Configuration reference¶
Stereographic dynamic solvers are configured through Python dictionaries passed at
construction and initialization. Shared validation and defaults live in
Zmag_bins.Zmag_dynamic_stereo_base; model-specific keys are read by
Zmag_bins.Zmag_dynamic_stereo_demag and
Zmag_bins.Zmag_dynamic_stereo_nodemag.
The sections below follow the usual setup order: constructor options, time-integration
options, material and field data, magnetostatics (demag only), then outputs and
checkpoints.
Constructor options¶
Passed as args_init_sim to the solver constructor (or to
create_stereo_solver()).
Required keys¶
Key |
Description |
|---|---|
|
Spatial dimension (typically |
|
Gilbert damping parameter in the chart matrix \(\mathcal{L}_\mu\) (Stereographic formulation). |
|
Active energy contributions (see Energy terms). |
|
If |
|
Enable rank-0 diagnostic printing. |
|
|
Optional keys¶
Key |
Default / role |
|---|---|
|
Unit vector for stereographic pole (default |
|
Lower bound on \(\sigma^2\) in \(\mathcal{L}_\mu\) for numerical stability (default |
Energy terms¶
Values of energy_terms and which solver variants accept them:
Term |
|
|
|---|---|---|
|
required |
not allowed |
|
optional |
optional |
|
optional |
optional |
|
optional |
optional |
|
optional |
optional |
Time-integration options¶
Passed as args_init_dyn to init_dynamic.
Required keys¶
Key |
Description |
|---|---|
|
Initial time \(t^\ast\). |
|
Initial non-dimensional timestep \(\Delta t^\ast\). |
|
First step index (use the checkpoint value on restart). |
|
Last step index (inclusive upper bound in the driver loop). |
|
|
|
Write a checkpoint every this many accepted steps. |
|
List of output field names (see Output targets). |
|
Adaptive timestep control (see Adaptive timestep (cfl_settings)). |
Adaptive timestep (cfl_settings)¶
Sub-dictionary for the embedded BDF error estimate, CFL safety cap, and thermodynamic
retry budget. Keys omitted here are filled from
DEFAULT_CFL_SETTINGS.
Key |
Default |
Role |
|---|---|---|
|
|
Target CFL number for the precession limit. |
|
|
Hard bounds on \(\Delta t^\ast\). |
|
|
Smoothing of timestep changes. |
|
|
Maximum growth and minimum shrink factors per step. |
|
|
Tolerances for the embedded BDF temporal error estimate that drives \(\Delta t_{\mathrm{error}}\) (see Solver algorithms). |
|
|
Retries with thermodynamic backtracking before cutting |
Optional keys¶
Solver and iteration control¶
Key |
Role |
|---|---|
|
Retries per timestep on SNES failure (default |
|
Target BDF order ( |
|
Matrix-free SNES Jacobian when supported. |
|
FFCx JIT control (a per-rank cache is recommended on clusters). |
|
Steady-state stopping: |
Atlas and chart control¶
Key |
Role |
|---|---|
|
|
|
Hysteresis width for atlas chart switching (default from |
|
Relaxation factor in |
|
Hard cap on the effective chart radius. |
Continuation ramps¶
Key |
Role |
|---|---|
|
Demagnetizing-field continuation ( |
|
Zeeman-field continuation. |
Checkpoint snapshots¶
Key |
Role |
|---|---|
|
List of XDMF snapshot names written on checkpoint steps (for example
|
Acceptance and outer-split gates¶
These keys control the algebraic, thermodynamic, and (for demag) outer-split
acceptance logic. See Solver algorithms for the full workflow.
Key |
Role |
|---|---|
|
If |
|
Auxiliary Cartesian energy-spike detector (default |
|
EMA budget on past thermo defects. |
|
Adaptive floor for the physical guard. |
|
State-space line search before cutting |
|
Relative energy floor in the thermo budget (demag problems). |
|
Algebraic residual gate after SNES. |
|
Force BDF1 for this many steps after thermo-related events. |
|
Require outer-split \((q,\varphi)\) fixed-point convergence ( |
|
Outer iteration cap and defect tolerances ( |
|
Anderson acceleration on the outer split ( |
|
Verbose thermo logging. |
Materials¶
Passed as a list to set_materials. Each entry describes one cell-tag region;
fields are interpolated to DG0.
Key |
Description |
|---|---|
|
Integer cell marker (Gmsh physical group). |
|
\(M_{\mathrm s}^\ast = M_{\mathrm{s}i}/M_{\mathrm{s}1}\) (reference tag: |
|
\(A^\ast = A_i/A_1\) (reference tag: |
|
\(K^\ast = K_{1i}/K_{11}\) (reference tag: |
|
\(2K_{11}/(\mu_0 M_{\mathrm{s}1}^2)\) of the reference material. |
|
\(K_{2i}/K_{1i}\) for cubic anisotropy. |
|
Unit vector |
See Micromagnetic energy and Stereographic formulation for the scaling derivation.
External field¶
set_external_field accepts either:
A length-3 sequence or NumPy array — constant non-dimensional \(\mathbf{H}_{\mathrm{zee}}^\ast\).
A coil dictionary with keys
wire_path,N_turns,current,l_ex,Ms_ref,size_scale_fac, and optionalwrite_Hzee_to_file.
Magnetostatics (demag only)¶
set_magnetostatics(interfaces, surface_tag) registers interface facet tags for
magnetostatic measures and the exterior Dirichlet tag for \(\varphi\).
set_BEMcpp(BEM_dir) loads the C++ BEM assembler built as described in
Installation.
Output targets¶
Requested through write_target in args_init_dyn.
demag only¶
Target |
Content |
|---|---|
|
Demagnetizing field |
|
Total scalar potential |
|
Boundary contribution \(\varphi_1\) |
|
Scaled demagnetizing field and induction |
Requesting a demag-only target with model="nodemag" raises ValueError.
Checkpoints¶
Checkpoints are written automatically during solve_problem and are the
supported way to interrupt and resume a run. Each checkpoint uses three
kinds of files:
ADIOS2 BP files (
.bp) — distributed mesh and cell/facet tags, written throughadios4dolfinx. Mesh topology must be stored and reread under MPI in the layout DOLFINx expects; ADIOS2 is the FEniCSx mechanism for that.NumPy archives (
.npz) — chart fields, BDF history, atlas metadata, controller state, and (fordemag) a warm-startphi. These are dense arrays attached to an already reconstructed function space, so a lightweight archive is sufficient and easier to inspect than packing every field into the ADIOS file.Optional XDMF — visualization snapshots from
xdmf_checkpoint_targets. Not used for restart.
A restart needs the BP stem and its .npz companions for the same timestep.
Writing¶
Every checkpoint_every accepted steps the solver writes into
path_dirs["checkpoint_dir"]:
File |
Content |
|---|---|
|
Mesh and cell/facet tags (ADIOS2). |
|
Current chart fields (required for restart). |
|
Optional BDF history. If missing on load, the current chart state is repeated so the run can continue at BDF1. |
|
Atlas metadata used to rebuild chart masks and weights. |
|
Adaptive timestep / BDF / thermo-gate controller state. |
|
Scalar potential ( |
|
Energy log used by |
|
Optional visualization snapshots from |
Restarting¶
Restart is driven by the user script, not by create_stereo_solver alone.
Three settings matter:
Setting |
Role on restart |
|---|---|
|
Directory that contains the checkpoint to load. |
|
Directory where new checkpoints will be written (may differ from
|
|
|
Recommended sequence:
Create the solver with
loading_dirset to the previous checkpoint directory.Call
read_checkpoint_timeto recover the latest step, time, and timestep from that directory (it selects the newestcheckpoint_timestep_*.bpfile).Rebuild the mesh from that BP file with
read_checkpoint_mesh, then call the usual setup methods (set_mesh, materials, and fordemagmagnetostatics / BEM).Restore chart and controller state with
restore_checkpoint_atlas_state.Call
init_dynamicwithfirst_run=Falseand the recoveredstep_start/t_start/dt, thensolve_problem.
For demag, init_dynamic re-equilibrates the magnetostatic potential
with the live BEM assembled in step 3 before seeding the thermodynamic
baseline. Restored phi is a warm start only; see Checkpoint and restart chain.
path_dirs["loading_dir"] = previous_checkpoint_dir
sim = create_stereo_solver(args_init_sim, model="demag")
step, t, dt = sim.read_checkpoint_time(
previous_checkpoint_dir,
previous_checkpoint_dir + "/checkpoint_energies.txt",
)
bp = f"{previous_checkpoint_dir}/checkpoint_timestep_{step}.bp"
domain, _, cell_tags, facet_tags = sim.read_checkpoint_mesh(comm, bp)
sim.set_mesh(domain, cell_tags, facet_tags, surface_tag)
# ... materials, magnetostatics, BEM as usual ...
sim.restore_checkpoint_atlas_state(bp)
args_init_dyn.update(first_run=False, step_start=step, t_start=t, dt=dt)
sim.init_dynamic(args_init_dyn)
sim.solve_problem()
The full pattern is exercised by test_dynamic_checkpoints.py at the
repository root. See also Getting started and Shared base module.