qtcad.device.poisson_linear module
Linear Poisson solver.
- class Solver(d, solver_params=None, geo_file: str = None)
Bases:
SolverFinite element solver for linear Poisson’s equation, given a charge density stored in the ‘rho’ attribute of the input device. All units are SI.
- Attributes:
d (device object) – The device for which to solve Poisson’s equation
- __init__(d, solver_params=None, geo_file: str = None)
Constructor of the solver class.
- Parameters:
d (device object) – Device for which Poisson’s equation must be solved.
solver_params (SolverParams obj or None, optional) – The parameters of the solver.
geo_file (str, optional) – Path to file containing the geometry of the problem. Available formats are .geo_unrolled (recommended when using the built-in Gmsh geometry kernel) and .xao (recommended when using the OpenCASCADE Gmsh geometry kernel). If geo_file is None then Poisson’s equation is solved over the mesh saved in
d, and the mesh is static. Ifgeo_fileis not None, adaptive meshing will be used.
- load(filename)
Load the potential from an HDF5 file.
This function reads the
phidataset from the specified file and sets it as attribute of the device passed to the solver (self.d). The HDF5 file must contain a dataset with this exact name.- Parameters:
filename (str) – Path to the HDF5 file containing the data.
- save(filename)
Save the solved potential to an HDF5 file.
This function writes the device attribute
phito the specified file. The dataset is stored with the name ‘phi’.- Parameters:
filename (str) – Path to the HDF5 file where the data will be saved.
- solve()
Solves the linear Poisson equation.
- class SolverParams(inp_dict=None)
Bases:
SolverParamsParameters to pass to a linear Poisson solver.
- Attributes:
tol (float) – Tolerance to use in an iterative solution, in volts. Default: 1e-6.
maxiter (int) – Maximum number of iterations in an iterative solution. If None, the maximum number of iterations is set to a value that typically leads to convergence. Default: None
method (str) – The method to use to solve the linear problem: “direct” or “iterative”. Default: “iterative”.
eta0 (float) – Tolerance on the potential to use in an adaptive calculation.
refined_mesh_filename (str) – Path to the file containing the refined mesh.
h_max (float) – Maximum characteristic length of the mesh. To be used if mesh is refined.
refined_region – (list of any combination of strings and lists of two 3-tuples or a single list of two 3-tuples or a single string): Regions where we would like to set the maximal value of the characteristic length. These regions are identified either by their physical name or by a list of two 3-tuples, specifying the minimum and maximum (x, y, z) coordinates of the two opposite corners of a box containing the region. Defaults to None, in which case no maximal characteristic length will be set in any region. Used only for adaptive Poisson solver.
h_refined (float or list of floats) – Maximal value of the characteristic length in each of the regions defined in refined_region. If a list, the index of each element must correspond to the index of the region in refined_region. If a single float, the same value is used for all regions. Used only for adaptive Poisson solver.
print_gmsh_outputs (bool) – If True, print the outputs of gmsh. Default: False.
- __init__(inp_dict=None)
Constructor of the SolverParams class.
- Parameters:
inp_dict (dict, optional) – Dictionary specifying certain solver parameters to be used instead of their default values.