qtcad.device.analysis module

Functions to plot and save simulation outputs.

qtcad.device.analysis.analyze_dot(dvc, eigenstate=0, verbose=False)

Gets the average position and size of the probability distribution of an electron or hole in a quantum dot.

Parameters:
  • dvc (Device or SubDevice) – A Device or SubDevice object on which the single-particle Schrödinger’s equation has been solved.

  • eigenstate (int) – Which eigenstate to use to compute statistics, where 0 means the ground state, 1 means the first excited state, etc.

  • verbose (bool, optional) – If True, print the dot properties.

Returns:

dict – A dictionary containing the following entries: “position”, a 1D array containing the average xyz coordinates of the dot (defined as the average position of the particle in its ground state); “std”, a 1D array containing the standard deviation \(\sigma\) of the particle probability density in the dot ground state in each Cartesian direction; and “size”, a 1D array containing the dot size in each direction, defined as four times the standard deviation sigma (\(\pm 2\sigma\)) in each direction.

Note

It is strongly recommended to first plot the eigenstates of the quantum dot being analyzed here to make sure that these eigenstates are bound.

qtcad.device.analysis.get_slices(mesh, array, title='untitled', x=None, y=None, z=None, path=None, length_unit='nm')

Produce slices in xy, yz, or zx plane.

Parameters:
  • mesh (mesh object) – The mesh over which data is defined.

  • array (list of 1d arrays) – The arrays to save.

  • title (str, optional) – Title of the slices.

  • x (float or None, optional) – Position of the slice perpendicular to the x axis.

  • y (float or None, optional) – Position of the slice perpendicular to the y axis.

  • z (float or None, optional) – Position of the slice perpendicular to the z axis.

  • path (str or None, optional) – If not None, path of the vtu file in which to save the pyvista grids.

  • length_unit (str) – Units of length to use when exporting into vtu format. Default: “nm”. Other choices are: “um”, “mm”, and “m”.

Returns:

pyvista grid, or list of pyvista grid – The slices.

Note

If no xyz coordinate is specified, slices are taken at the middle of each axis. Otherwise, a slice is shown for each axis whose coordinate is specified.

qtcad.device.analysis.integrate(mesh, func)

Integrates a function evaluated at global or local nodes over the entire simulation domain.

Parameters:
  • mesh (Mesh) – The mesh over which to integrate

  • func (ndarray) – The function to integrate at each global node (1d array) or local node (2d array). If 2d array, 1st index is element, second index is local node.

Returns:

float – The value of the integral.

qtcad.device.analysis.linecut(mesh, array, begin, end, method='default', res=500, array_name='Untitled quantity')

Produce linecut for some array quantity defined over mesh nodes.

Parameters:
  • mesh (mesh object) – The mesh over which data is defined.

  • array (list of 1d arrays) – The array for which to calculate the linecut.

  • begin (tuple) – xyz coordinates of the first point along the linecut

  • end (tuple) – xyz coordinats of the last point along the linecut

  • method (string, optional) – linecutting method. For 3D can be “default” or “pyvista” (default is “default”). For 2D, is is ignored, and the “pyvista” method is used.

  • res (int, optional) – number of points over which to interpolate. Default: 500. Only used by PyVista linecutter.

  • array_name (str, optional) – name of the array to consider (3D only).

Returns:

tuple – a tuple (d, v) where d is a 1d array containing distance along linecut and v in a 1d array containing values of the attribute

qtcad.device.analysis.plot(mesh, array, scaling=1.0, title=None, cmap='jet', show_mesh=False, cb_axis_label=None, ylabel='y', path=None, show_figure=True, length_unit='nm')

Plot on the surface of a mesh.

Parameters:
  • mesh (Mesh object) – The mesh to plot.

  • array (1d or 2d array) – The variable to plot at global or local nodes

  • scaling (float, optional) – Prefactor by which to multiply the attribute, e.g. for unit conversion. Default: 1.

  • title (str, optional) – Title of the plot. If None, uses the name of the attribute. Default: None.

  • cmap (str, optional) – The matplotlib colormap to use. Default: ‘jet’.

  • show_mesh (bool, optional) – If true, display the mesh in addition to the data (2D only). Default: False.

  • cb_axis_label (str, optional) – Label of the colorbar (2D only).

  • ylabel (str, optional) – Label of the y axis (1D only). Default: “y”.

  • path (str, optional) – String for the path in which the plot is saved in .png format, or None. If None, no file is saved. Default: None.

  • show_figure (bool, optional) – Whether figure should be shown. Default: True.

  • length_unit (str, optional) – Units of length to use (1D and 2D only). Default: “nm”. Other choices are: “um”, “mm”, and “m”.

qtcad.device.analysis.plot_bands(device, begin=None, end=None, method='default', res=500, title='Band diagram', path=None, show_figure=True, length_unit='nm')

Produce band diagram along some linecut.

Parameters:
  • device (device object) – The device to plot.

  • begin (tuple, optional) – xyz coordinates of the first point along the linecut. Mandatory in 2d or 3d, unused in 1d.

  • end (tuple, optional) – xyz coordinats of the last point along the linecut. Mandatory in 2d or 3d, unused in 1d.

  • method (string, optional) – linecutting method. Can be “default” or “pyvista”.

  • res (int, optional) – number of points over which to interpolate. Default: 500. Only used by PyVista linecutter.

  • title (str, optional) – Title of the plot

  • path (str, optional) – String for the path in which the plot is saved in .png format, or None. If None, no file is saved. Default: None.

  • show_figure (bool, optional) – Whether figure should be shown. Default: True.

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

qtcad.device.analysis.plot_linecut(mesh, array, begin, end, method='default', res=500, title='Untitled', ylabel='y', path=None, show_figure=True, length_unit='nm', return_linecut=False)

Produce linecut for some array quantity defined over mesh nodes and plot it.

Parameters:
  • mesh (mesh object) – The mesh over which data is defined.

  • array (1d array) – The array to plot.

  • begin (tuple) – xyz coordinates of the first point along the linecut

  • end (tuple) – xyz coordinats of the last point along the linecut

  • method (string, optional) – linecutting method. For 3D can be “default” or “pyvista” (default is “default”). For 2D, is is ignored, and the “pyvista” method is used.

  • res (int, optional) – number of points over which to interpolate. Default: 500. Only used by PyVista linecutter.

  • title (str, optional) – Name of the linecut.

  • ylabel (str, optional) – Label of the y axis.

  • path (str, optional) – String for the path in which the plot is saved in .png format, or None. If None, no file is saved. Default: None.

  • show_figure (bool, optional) – Whether figure should be shown. Default: True.

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

  • return_linecut (bool, optional) – Whether the function provides the linecut as an output. Default: False (True is not recommended; it is recommended to use \(linecut <qtcad.device.analysis.linecut>\) if the information is needed).

Returns:

tuple – a tuple (d, v) where d is a 1d array containing distance along linecut and v in a 1d array containing values of the attribute This tuple is only output if return_linecut is True.

qtcad.device.analysis.plot_slice(mesh, arr, normal, origin, bounds=None, scaling=1.0, title=None, path=None, show_figure=True, cmap='jet', theta=0, show_mesh=False, cb_axis_label=None, length_unit='nm', figsize=(6, 4))

Density plot over a 2D plane slicing through the mesh.

Parameters:
  • mesh (mesh object) – The mesh over which to plot.

  • arr (ndarray) – The array to plot over the mesh, in either global or local node representation.

  • normal (tuple) – The normal vector for the slice.

  • origin (tuple) – The origin for the slice.

  • bounds (tuple) – Specifies the bounds for the colormap. Additionally, This can be passed as a tuple (None, value) to set only the upper bound, or (value, None) to set only the lower bound.

  • scaling (float, optional) – Prefactor by which to multiply the attribute, e.g. for unit conversion. Default: 1.

  • title (str, optional) – Title of the plot. If None, do not use any title.

  • path (str, optional) – String for the path in which the plot is saved in .png format, or None. If None, no file is saved. Default: None.

  • show_figure (bool, optional) – Whether figure should be shown. Default: True.

  • cmap (str, optional) – The matplotlib colormap to use. Default: ‘jet’.

  • theta (float, optional) – The angle (in degrees) to rotate the plot around the surface’s normal axis. This parameter allows further adjustments for diagonal slices for better visualization.

  • show_mesh (bool, optional) – If true, display the mesh in addition to the data. Default: False.

  • cb_axis_label (str, optional) – Label of the colorbar

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

  • figsize (tuple of two int) – size of the figure.

qtcad.device.analysis.plot_slices(mesh, array, x=None, y=None, z=None, cmap='jet', title='untitled plot', path=None, show_grid=False, show_figure=True, length_unit='nm')

3D density plot of an array defined over a mesh on orthogonal slices inside the mesh.

Parameters:
  • mesh (mesh object) – The mesh over which data is defined.

  • array (list of 1d arrays) – The arrays to save.

  • x (float or None) – Position of the slice perpendicular to the x axis.

  • y (float or None) – Position of the slice perpendicular to the y axis.

  • z (float or None) – Position of the slice perpendicular to the z axis.

  • cmap (str, optional) – The matplotlib colormap to use.

  • title (str, optional) – Title of the plot.

  • path (str, optional) – String for the path in which the plot is saved in .png format, or None. If None, no file is saved.

  • show_grid (bool, optional) – Whether to show axes grid or not.

  • show_figure (bool, optional) – Whether figure should be shown.

  • length_unit (str) – Units of length to use in the output vtu file, if any. Choices are: “nm”, “um”, “mm”, and “m”.

Note

If no xyz coordinate is specified, slices are taken at the middle of each axis. Otherwise, a slice is shown for each axis whose coordinate is specified. Length units are only used in the output vtu files; for determining the slice positions, SI units are assumed.

qtcad.device.analysis.point_eval(mesh, array, point)

Produce a point interpolation for some array quantity defined over mesh nodes.

Parameters:
  • mesh (mesh object) – The mesh over which data is defined.

  • array (1d array or 2d array) – The array defined over local (2d) or global nodes (1d), or elements (1d), for which to calculate the point interpolation.

  • point (tuple) – Coordinates of the interpolation point.

Returns:

float – interpolated value at the given point

qtcad.device.analysis.region_statistics(dvc, var, region, verbose=False)

Calculates the statistics of a variable over a region.

Parameters:
  • dvc (Device or SubDevice) – A Device or SubDevice object.

  • var (string or Field) – A variable for which statistical calculations are performed. If the variable is a string, then it must correspond to an attribute of the device dvc. If the variable is a Field or a numpy array, then its shape must be compatible with the dimensions of the mesh over which dvc is defined.

  • verbose (bool, optional) – If True, print the statistical properties.

  • region (str, list) – string or list of strings labeling regions of the device (Gmsh physical groups), or list of lists/tuples specifying corners that define a box-shaped region.

  • verbose (bool, optional) – If True, print the statistical properties.

Returns:

dict – A dictionary containing the following entries: “min”, the minimum value of the given variable; “max”, the maximum value of the given variable; “mean” the average value of the given variable over the given region. “std” the standard deviation of the given variable over the given region.

qtcad.device.analysis.save_linecut(path, mesh, arrays, begin, end, method='default', res=500, array_names=None, length_unit='nm')

Produce linecuts for some array quantities defined over mesh nodes and save them.

Parameters:
  • path (str) – The path to the text file.

  • arrays (list of 1d arrays or dict_values) – The arrays to save.

  • begin (tuple) – xyz coordinates of the first point along the linecut

  • end (tuple) – xyz coordinats of the last point along the linecut

  • method (string, optional) – linecutting method. For 3D can be “default” or “pyvista” (default is “default”). For 2D it is ignored.

  • res (int, optional) – number of points over which to interpolate. Default: 500. Only used by PyVista linecutter.

  • array_names (list of str or dict_keys, optional) – The names of the arrays to save.

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

qtcad.device.analysis.save_mesh_arrays(path, mesh, arrays, array_names=None, format=None)

Saves a list of arrays defined on mesh nodes into a text file.

Parameters:
  • path (str) – The path to the text file.

  • mesh (mesh object) – The mesh over which data is defined.

  • arrays (list of arrays) – The arrays to save. All arrays must have the same dimensions.

  • array_names (list of str, optional) – The names of the arrays to save.

  • format (str, optional) – if not specified, data will be separated by spaces. If “csv”, data will be separated by commas.