qtcad.device.schrodinger module

Schrodinger solver.

class Solver(d: Device | SubDevice, solver_params: SolverParams | None = None)

Bases: Solver

Finite-element solver for the Schrödinger equation.

All quantities are expressed in SI units unless otherwise specified.

Attributes:
  • d (device object) – Device on which the Schrödinger equation is solved.

  • num_states (int) – Number of eigenstates to compute, starting from the lowest eigenvalue.

  • tol (float) – Solver tolerance (stopping criterion). Specifies the relative accuracy of the eigenvalues. Units: eV.

  • maxiter (int) – Maximum number of iterations for the eigensolver.

  • method (string) – Algorithm used to solve the eigenvalue problem. Supported values are "robust" and "fast".

  • verbose (bool) – If True, print solver progress and diagnostic information.

  • mass_tensor (2D 3x3 array or None) – Optional inverse effective-mass tensor (shape (3, 3)) used in the Schrödinger equation. If None, the inverse effective-mass tensor is taken from the device.

Note

Electron case (conf_carriers = 'e'):

The Hamiltonian is constructed using either the device effective-mass tensor or the solver-provided mass_tensor. If the device’s electron_kp_model attribute is not None, the Hamiltonian is constructed from that \(\mathbf{k} \cdot \mathbf{p}\) model instead of using the effective-mass formulation.

Hole case (conf_carriers = 'h'):

The device D matrix is used. It must be expressed in units of \(\hbar^2 / m_e\) and must yield positive dispersion in \(k\)-space.

Default solver parameters:

If tol or maxiter are set to None, the default values of the underlying SciPy eigensolver are used.

__init__(d: Device | SubDevice, solver_params: SolverParams | None = None) None

Initialize from device object d.

Parameters:
  • d (Device object) – The device to simulate.

  • solver_params (SolverParams obj or None, optional) – The parameters of the solver.

band_structure(K: ndarray[tuple[Any, ...], dtype[_ScalarT]], basis_vec: ndarray[tuple[Any, ...], dtype[_ScalarT]] | None = None, mixing: bool = True) ndarray[tuple[Any, ...], dtype[_ScalarT]]

Computes the band structure for some translationally invariant problem

Parameters:
  • K (1d array) – Magnitudes to multiply the basis vector by to obtain the wavevectors for which we wish to compute the band structure

  • basis vector (1d array) – Direction along the translationally invariant directions. Defaults to None, in which case the basis vector is taken to be one with entries of 1 along each translationally invariant direction.

  • mixing (bool) – If False, the band off-diagonal matrix elements of the new a matrix will be set to 0

Returns:

2d array – Energies from the band structure calculation. First index runs over the k values and the second over the energy levels.

get_a_matrix_electrons(dim: int | None = None)

Return the electron effective-mass / k.p a matrix.

Parameters:

dim – Optional override for problem dimensionality.

get_a_matrix_holes(dim: int | None = None)

Return the hole a matrix.

Parameters:

dim – Optional override for problem dimensionality.

load(filename: str) None

Load energies and eigenfunctions from an HDF5 file.

This function reads the energies and eigenfunctions datasets from the specified file and sets them as attributes of the device passed to the solver (self.d). The HDF5 file must contain datasets with these exact names.

Parameters:

filename (str) – Path to the HDF5 file containing the data.

save(filename: str) None

Save energies and eigenfunctions to an HDF5 file.

This function writes the device attributes energies and eigenfunctions from the device passed to the solver to the specified HDF5 file. The datasets are created with these exact names so they can be loaded later by the corresponding load function.

Parameters:

filename (str) – Path to the HDF5 file where the data will be saved.

solve(k: ndarray[tuple[Any, ...], dtype[_ScalarT]] | None = None, mixing: bool = True) None

Solve Schrodinger’s equation.

Parameters:
  • k (1d numpy array) – k vector along translationally invariant directions. This array should have as many components as the length of the attribute ti_directions. Defaults to None in which case it is taken to be an array of zeros.

  • mixing (boolean) – Whether to consider band off-diagonal elements in the problem.

Note

Modifies: self.d.energies and self.d.eigenfunctions.

class SolverParams(inp_dict: dict | None = None)

Bases: SolverParams

Parameters to pass to a Schrödinger solver.

Attributes:
  • tol (float) – Tolerance to use in a calculation, in eV. Default: 1e-6.

  • maxiter (int) – Maximum number of iterations in the fast eigenvalue solver. Default: 1000.

  • errortype (str) – Type of error to use in a convergence criterion. Relative (‘rel’ or ‘relative’) or absolute (‘abs’ or ‘absolute’). Default: ‘abs’.

  • method (str) – The method to use to the eigenvalue problems: “robust” or “fast”. Default: “fast”.

  • parallel (bool) – Whether to use parallel algorithms to solve the eigenvalue problem. Only available for the “fast” method. The parallel algorithm is typically faster than the serial algorithm when (1) the system has at least 4 available logical cores and (2) the (sub)mesh on which the Schrödinger equation is solved has at least 10,000 nodes. Default: True.

  • num_states (int) – Number of states to solve for, starting from the lowest eigenvalue. Default: 10.

  • guess (tuple, str, or None) – Initial guess to use in the first Schrödinger iteration when the fast solver is used. If None, use default guess (random). If “box”, uses the particle-in-a-box eigenfunctions. Otherwise, must be a tuple whose first entry is the wave functions (with global node index first, and state index second), and whose second entry is the eigenenergies. Default: None.

  • mass_tensor (2D 3x3 array or None) – Inverse mass tensor to be used in Schrodinger equation eigenvalue problem that supersedes the mass tensor from the device. Default: None, meaning that the mass tensor of the device is used.

  • ti_directions (list) – List of strings labeling directions (‘x’, ‘y’, or ‘z’) along which translational invariance is assumed by the Schrödinger solver. Default: None.

  • verbose (bool) – Verbosity level. Default: True.

__init__(inp_dict: dict | None = None) None

Instantiate the SolverParams object.

Parameters:

inp_dict (dict, optional) – Dictionary specifying certain solver parameters to be used instead of their default values.