Solver

Simulating the dynamics of a tdgl.Device for a given applied magnetic vector potential and set of bias currents is as simple as calling the tdgl.solve() function. The solver implements the finite-volume and implicit Euler methods described in detail in Theoretical Background. The behavior of the solver is determined an instance of tdgl.SolverOptions.

The applied vector potential can be specified as a scalar (indicating the vector potential associated with a uniform magnetic field), a function with signature func(x, y, z) -> [Ax, Ay, Az], or a tdgl.Parameter. The physical units for the applied vector potential are field_units * device.length_units.

The bias or terminal currents (if any) can be specified as a dictionary like terminal_currents = {terminal_name: current}, where current is a float in units of the specified current_units. For time-dependent applied currents, one can provide a function with signature terminal_currents(time: float) -> {terminal_name: current}, where time is the dimensionless time. In either case, the sum of all terminal currents must be zero at every time step and every terminal in the device must be included in the dictionary to ensure current conservation.

tdgl.solve(device, options, applied_vector_potential=0, terminal_currents=None, disorder_epsilon=1, seed_solution=None)[source]

Solve a TDGL model.

Parameters
  • device (Device) – The tdgl.Device to solve.

  • options (SolverOptions) – An instance tdgl.SolverOptions specifying the solver parameters.

  • applied_vector_potential (Union[Callable, float]) – A function or tdgl.Parameter that computes the applied vector potential as a function of position (x, y, z). If a float B is given, the applied vector potential will be that of a uniform magnetic field with strength B field_units.

  • terminal_currents (Union[Callable, Dict[str, float], None]) – A dict of {terminal_name: current} or a callable with signature func(time: float) -> {terminal_name: current}, where current is a float in units of current_units and time is the dimensionless time.

  • disorder_epsilon (Union[float, Callable]) – A float in range [-1, 1], or a callable with signature disorder_epsilon(r: Tuple[float, float]) -> epsilon, where epsilon is a float in range [-1, 1]. Setting \(\epsilon(\mathbf{r})=T_c(\mathbf{r})/T_c - 1 < 1\) suppresses the critical temperature at position \(\mathbf{r}\), which can be used to model inhomogeneity.

  • seed_solution (Optional[Solution]) – A tdgl.Solution instance to use as the initial state for the simulation.

Returns

A tdgl.Solution instance.

class tdgl.SolverOptions(solve_time, skip_time=0.0, dt_init=1e-06, dt_max=0.1, adaptive=True, adaptive_window=10, max_solve_retries=10, adaptive_time_step_multiplier=0.25, sparse_solver=SparseSolver.SUPERLU, terminal_psi=0.0, pause_on_interrupt=True, save_every=100, progress_interval=0, field_units='mT', current_units='uA', output_file=None, include_screening=False, max_iterations_per_step=1000, screening_tolerance=0.001, screening_step_size=1.0, screening_step_drag=0.5, screening_use_numba=True, screening_use_jax=False)[source]

Options for the TDGL solver.

Parameters
  • solve_time (float) – Total simulation time, after any thermalization.

  • skip_time (float) – Amount of ‘thermalization’ time to simulate before recording data.

  • dt_init (float) – Initial time step.

  • dt_max (float) – Maximum adaptive time step.

  • adaptive (bool) – Whether to use an adpative time step. Setting dt_init = dt_max is equivalent to setting adaptive = False.

  • adaptive_window (int) – Number of most recent solve steps to consider when computing the time step adaptively.

  • max_solve_retries (int) – The maximum number of times to reduce the time step in a given solve iteration before giving up.

  • adaptive_time_step_multiplier (float) – The factor by which to multiple the time step dt for each adaptive solve retry.

  • sparse_solver (Union[SparseSolver, str]) – One of “superlu”, “umfpack”, or “pardiso”. “umfpack” requires suitesparse, which can be installed via conda, and scikit-umfpack, which can be installed via pip. “pardiso” requires an Intel CPU and the pypardiso package, which can be installed via pip or conda.

  • terminal_psi (Union[float, complex, None]) – Fixed value for the order parameter in current terminals.

  • field_units (str) – The units for magnetic fields.

  • current_units (str) – The units for currents.

  • output_file (Optional[PathLike]) – Path to an HDF5 file in which to save the data. If the file name already exists, a unique name will be generated. If output_file is None, the solver results will not be saved to disk.

  • pause_on_interrupt (bool) – Pause the simulation in the event of a KeyboardInterrupt.

  • save_every (int) – Save interval in units of solve steps.

  • progress_interval (int) – Minimum number of solve steps between progress bar updates.

  • include_screening (bool) – Whether to include screening in the simulation.

  • max_iterations_per_step (int) – The maximum number of screening iterations per solve step.

  • screening_tolerance (float) – Relative tolerance for the induced vector potential, used to evaluate convergence of the screening calculation within a single time step.

  • screening_step_size (float) – Step size \(\alpha\) for Polyak’s method.

  • screening_step_drag (float) – Drag parameter \(\beta\) for Polyak’s method.

  • screening_use_numba (bool) – Use numba for the screening calculation.

  • screening_use_jax (bool) – Use jax for the screenig calculation.

enum tdgl.solver.options.SparseSolver(value)[source]

Supported sparse linear solvers.

Valid values are as follows:

SUPERLU: str = <SparseSolver.SUPERLU: 'superlu'>
UMFPACK: str = <SparseSolver.UMFPACK: 'umfpack'>
PARDISO: str = <SparseSolver.PARDISO: 'pardiso'>
class tdgl.Parameter(func, time_dependent=False, **kwargs)[source]

A callable object that computes a scalar or vector quantity as a function of position coordinates x, y (and optionally z and time t).

Addition, subtraction, multiplication, and division between multiple Parameters and/or real numbers (ints and floats) is supported. The result of any of these operations is a CompositeParameter object.

Parameters
  • func (Callable) – A callable/function that actually calculates the parameter’s value. The function must take x, y (and optionally z) as the first and only positional arguments, and all other arguments must be keyword arguments. Therefore func should have a signature like func(x, y, z, a=1, b=2, c=True), func(x, y, *, a, b, c), func(x, y, z, *, a, b, c), or func(x, y, z, *, a, b=None, c=3). For time-dependent Parameters, func must also take time t as a keyword-only argument.

  • time_dependent (bool) – Specifies that func is a function of time t.

  • kwargs – Keyword arguments for func.