qtcad.device.maxwell_eigenmode module
Maxwell eigenmode solver.
- class Solver(d: Device, solver_params: SolverParams | None = None, geo_file: str | Path | None = None)
Bases:
SolverEigenmodeFinite element solver for finding eigenmodes in cavities by solving Maxwell equations.
- Attributes:
d (device object) – the device for which modes are to be found. Results are assigned to the corresponding attributes.
geo_file (str or Path, optional) – geometry file.
field_files (list[list[Path]]) – Paths to the files storing the field results. Each nested list contains: for VTU, a single entry, for POS, multiple entries. If
save_intermediate_resultswas enabled, the nested lists are associated to different iterations. Otherwise, there will be a single nested list.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 the SolverParams docstring for other attributes.
- __init__(d: Device, solver_params: SolverParams | None = None, geo_file: str | Path | None = None)
Constructor of the Solver class (Maxwell eigensolver).
- Parameters:
d – the device for which modes are to be found. Results are assigned to the corresponding attributes.
solver_params – The parameters of the solver. See SolverParams docstring for details.
geo_file (string) – path to a raw geometry file (recommended format: .xao) containing the geometry of the problem. If geo_file is None then the solver will be applied to a static mesh. If it is not None, the adaptive solver will be used.
- solve()
Solve for eigenvalues of electromagnetic fields in a cavity using Maxwell equations.
Note
The field normalization is such that the electromagnetic energy (including the energy stored in capacitive or inductive ports) is equal to 1.
The frequencies are stored in d.maxwell_freqs. The fields are also stored in an attribute of d and can be retrieved by calling the corresponding field finding methods such as d.get_e_field_maxwell.
- class SolverParams(inp_dict=None)
Bases:
SolverEigenmodeParamsParameters to pass to the Maxwell eigenmode solver (Solver constructor).
- Attributes:
num_modes (int) – Number of modes to solve for. Default: 3.
tol_rel (float) – the adaptive meshing tolerance on frequency. Default: 0.05.
min_freq – the resonant frequencies the solver looks for will be above this value.
Note: if the frequency is complex,
min_freqapplies to the real part.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: 5. 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.
min_nodes (int) – the solver does not terminate until the refined mesh contains at least min_nodes nodes. 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. By default, the name of the mesh file for the initial mesh is used.
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 all intermediate results will be saved at every iteration (for example refined meshes). Otherwise, only convergence files are updated at every iteration and other files are saved only at the end of the solver execution. Default: False.
field_results_fmts (str) – list containing “pos”, “vtu”, or both, specifying which file formats to save the results in. Default: [“vtu”].
field_results_pos (list[str]) – list that can include any of the following: “e-magn”, “b-magn”, “ex”, “ey”, “ez”, “bx-imag”, “by-imag”, “bz-imag”. The list specifies which field results to save as .pos files. Default: [“e-magn”].
- __init__(inp_dict=None)
Instantiate the SolverParams object.
- Parameters:
inp_dict (dict, optional) – Dictionary specifying certain solver parameters to be used instead of their default values.