qtcad.device.mesh1d module

1d Mesh and SubMesh classes.

class qtcad.device.mesh1d.Mesh(scaling_factor=1e-09, filename=None, glob_nodes=None, verbose=True)

Bases: Mesh

Class to store and process mesh properties such as node coordinates and elements.

  • dim (int) – Dimension of the mesh

  • line_number (int) – Number of line elements in the mesh.

  • point_number (int) – Number of point elements in the mesh.

  • node_number (int) – Number of global nodes.

  • glob_nodes (2D array) – Coordinates of the global nodes. First array index: global node index. Second array index: Cartesian direction (x).

  • elem_number (int) – Number of elements in the mesh including boundary elements.

  • all_connectivity (list) – Global nodes contained by all elements, including boundary elements.

  • connectivity (2D array) – Global nodes contained by each line element. The row index labels distinct elements, while the column index labels local nodes for each element, so the array shape is Nlines x 2, where Nlines is the number of line elements. Values stored in the array are global node indices, starting from 0.

__init__(scaling_factor=1e-09, filename=None, glob_nodes=None, verbose=True)

Constructor for the mesh class.

  • scaling_factor (float) – Factor by which node coordinates are multiplied to correspond to SI units. Default: 1e-9, meaning that units of length in the mesh file are assumed to be nm.

  • filename (str, optional) – Path to the mesh file to use to build the mesh. Only the Gmsh .msh2 format is supported.

  • glob_nodes (1D or 2D array, optional) – Location of each global node along x.

  • verbose (bool, optional) – If True, print mesh statistics. Default: True.


Though both ‘filename’ and ‘glob_nodes’ are optional, at least one of these arguments must be specified to instantiate the mesh. If glob_nodes is a 1D array, it is turned into a 2D array to comply with convetions for higher order meshes. If glob_nodes are specified, no file will be loaded.


Calculate the centroid of each triangular element.


2D array – Centroid of each element.


The output is a 2D array corresponding to a column vector to comply with the indexing convention used for higher dimensinal meshes


Calculate the length of each line element.


1D array – The length of each element.


Get arrays containing the local-node coordinates for each element.


2D array – x coordinate at each local node (column idx) and element (row idx)

nodes_in_box(x_min, x_max)

Gets indices of global nodes within a box.

  • x_min (float) – Minimum x coordinate values.

  • x_max (float) – Maximum x coordinate values.


1d array of int – The indices of the global nodes within the box.


Display the mesh using pyplot.


length_unit (str, optional) – Units of length to use when plotting. Default: “nm”. Other choices are: “um”, “mm”, and “m”.

class qtcad.device.mesh1d.SubMesh(parent, nodes, verbose=True)

Bases: SubMesh

A submesh is a subset of a parent mesh.


nodes_in_parent (1d array) – Number of each node belonging to the submesh in the parent mesh.


All other attributes are inherited from the parent mesh.

__init__(parent, nodes, verbose=True)

Constructor of the submesh class.

  • parent (mesh object) – The parent mesh.

  • nodes (1d array, string, or list of strings) – The nodes defining the subset of the parent mesh, or region label, or list of region labels.

  • verbose (bool, optional) – If True, print mesh statistics. Default: True.