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
) – Thetdgl.Device
to solve.options (
SolverOptions
) – An instancetdgl.SolverOptions
specifying the solver parameters.applied_vector_potential (
Union
[Callable
,float
]) – A function ortdgl.Parameter
that computes the applied vector potential as a function of position(x, y, z)
. If a floatB
is given, the applied vector potential will be that of a uniform magnetic field with strengthB
field_units
.terminal_currents (
Union
[Callable
,Dict
[str
,float
],None
]) – A dict of{terminal_name: current}
or a callable with signaturefunc(time: float) -> {terminal_name: current}
, wherecurrent
is a float in units ofcurrent_units
andtime
is the dimensionless time.disorder_epsilon (
Union
[float
,Callable
]) – A float in range [-1, 1], or a callable with signaturedisorder_epsilon(r: Tuple[float, float]) -> epsilon
, whereepsilon
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
]) – Atdgl.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, 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)[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. Settingdt_init = dt_max
is equivalent to settingadaptive = 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 stepdt
for each adaptive solve retry.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. Ifoutput_file
isNone
, the solver results will not be saved to disk.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.
- class tdgl.Parameter(func, **kwargs)[source]
A callable object that computes a scalar or vector quantity as a function of position coordinates x, y (and optionally z).
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 likefunc(x, y, z, a=1, b=2, c=True)
,func(x, y, *, a, b, c)
,func(x, y, z, *, a, b, c)
, orfunc(x, y, z, *, a, b=None, c=3)
.kwargs – Keyword arguments for func.