qtcad.device.capacitance module
- class Solver(d: Device, signal_conductors: list[str] | dict[str, list[str]], solver_params: SolverParams | None = None, geo_file: str | Path | None = None)
Bases:
SolverCapacitance solver class.
- Attributes:
d (device object) – The device for which to extract the capacitance.
signal_conductors (list or dictionary) – surfaces of signal conductors.
geo_file (str, Path, or None) – Geometry file (needed if adaptive meshing is used).
refined_mesh_files (list[Path]) – Paths to the refined mesh files associated to the different iterations. The list if not empty only if adaptive mesh refinement is active.
See SolverParams docstring for other attributes.
- __init__(d: Device, signal_conductors: list[str] | dict[str, list[str]], solver_params: SolverParams | None = None, geo_file: str | Path | None = None)
Constructor for the Solver class.
- Parameters:
d – Device for which capacitance is to be extracted.
signal_conductors – Option 1: list of Dirichlet boundaries corresponding to each signal conductor.
Option 2: dictionary specifying the signal conductors. The keys in the dictionary are the names to be given to the conductors. The values are the lists of Dirichlet boundaries comprising conductor surfaces.
All Dirichlet boundaries excluded from the signal_conductors are assumed to correspond to the ground conductors.
solver_params – parameters of the capacitance solver. See SolverParams docstring for defaults.
geo_file – required for adaptive meshing. It is the path to the raw geometry file (recommended format: .xao) containing the geometry of the problem. If geo_file is not given, then the capacitance is found using the mesh of the device dvc, and the mesh is static. If geo_file is provided, adaptive meshing will be used, with dvc.mesh as the starting coarse mesh.
- parse_iter_results(qty: str | None = 'values') tuple[dict[str, np.ndarray[Any]], dict[str, np.ndarray[float]]]
Extract the results of all iterations into arrays for further processing.
This allows the inspection of the convergence of the capacitance matrix entries (or their absolute or relative differences, see below) of the current simulation set up as a function of the iteration number.
- Parameters:
qty (str, optional) – Which quantity to extract. It should be:
"values"forthe capacitance values across iterations, `”delta”` for the difference
between the capacitance entries of two consecutive iterations or
`”delta_rel”` for the relative difference between the capacitance entries of
two consecutive iterations. Default –
"values".
- Returns:
Tuple containing –
Dictionary with keys
"iter","nodes","elems","dt","t"and
values being 1D arrays that contain the corresponding values for each iteration. Note:
"elems"specifies the count only for the elements with the same dimension as the mesh.Dictionary with keys being the capacitance matrix keys and values being 1D
arrays containing the results of each iteration.
- static parse_iter_results_from_file(path: str | Path) tuple[dict[str, np.ndarray[Any]], dict[str, np.ndarray[float]]]
Extract the results from a capacitance-matrix convergence file.
This allows the inspection of a convergence file with capacitance-matrix data (either their entries, their absolute or their relative differences) as a function of the iteration number.
- Parameters:
path (str | Path) – Path to a capacitance-matrix convergence file.
- Returns:
Tuple containing –
Dictionary with keys
"iter","nodes","elems","dt","t"and
values being 1D arrays that contain the corresponding values for each iteration. Note:
"elems"specifies the count only for the elements with the same dimension as the mesh.Dictionary with keys being the capacitance matrix keys and values being 1D
arrays containing the results of each iteration.
- print_cap(cap: dict[tuple[str, str], float], decimals: int = 4)
Prints capacitance matrix in dictionary form.
- Parameters:
cap – the capacitance matrix represented as a dictionary with the keys being pairs of signal nets and values being the corresponding capacitance values.
decimals – how many digits after decimal point to print.
- class SolverParams(inp_dict=None)
Bases:
SolverParamsParameters to pass to the capacitance solver.
- Attributes:
tol_rel (float) – relative tolerance (see Note). Default: 0.02.
tol_abs (float) – absolute tolerance (see Note). Default: 0.0.
min_converged_iters (int) – how many consecutive iterations are required to give results that agree within the tolerance thresholds (minimum value is 1, meaning that the last result needs to match well with the result computed in the previous interation). Default: 3. Reducing this value should be done with caution, as this could lead to false convergence. Increasing this value gives a more robust convergence criterion but slows down the simulation.
min_iters (int) – the solver does not terminate until at least min_iters iterations (refinements) have been completed, even if the values have converged. Default: 0.
output_dir (Path or str, optional) – the directory where output will be stored in adaptive meshing. Default: the current working directory.
name – name that can be specified for the device, the test, or solver call. For example, it will be used to name files or folders created in adaptive meshing, if applicable.
make_subdir (bool) – if True, computation results will be stored in a new subdirectory within output_dir, labeled by the current date and time. Default: False.
max_cpus (int) – the largest number of CPUs to use during the solution. Default: the number of logical CPUs available (CPU count on the machine or len(os.sched_getaffinity(0)), if available and has a lower value).
save_intermediate_results (bool, optional) – when adaptive meshing is used, if True then refined mesh will be saved at every iteration. Otherwise, only convergence files are updated at every iteration and mesh is saved only at the end of the solver execution. Default: False.
Note
The convergence threshold for each entry of the capacitance matrix \(C_{ij}\) is set as \(\mbox{tol_rel} * |C_{ij}| + \mbox{tol_abs}\). The attribute tol_abs is useful when \(|C_{ij}|\) is expected to be zero or very small.