Mathematical Formulation¶
Last changes: Documentation changelog
This page fixes the common magnetostatic equations used by every demagnetization realization.
Physical problem¶
The field is generated by the divergence and boundary trace of \(\mathbf M\), not by a local material coefficient. The exterior domain is part of the open-boundary problem even when a numerical method eliminates it analytically.
Governing equations¶
Symbols and SI units¶
Symbol |
Definition |
SI unit |
|---|---|---|
\(\mathbf M\) |
magnetization |
\(\mathrm{A\,m^{-1}}\) |
\(\mathbf H_{\mathrm d}\) |
demagnetizing field |
\(\mathrm{A\,m^{-1}}\) |
\(u\) |
scalar potential |
\(\mathrm{A}\) |
\(\mathbf B\) |
magnetic flux density |
\(\mathrm{T}\) |
\(\mu_0\) |
vacuum permeability |
\(\mathrm{N\,A^{-2}}\) |
\(E_{\mathrm d}\) |
demagnetization energy |
\(\mathrm{J}\) |
\(\Omega_m\) |
magnetic domain |
\(\mathrm{m^3}\) |
\(N_{pq}^{ij}\) |
discrete demagnetization tensor from source cell \(q\) to destination cell \(p\) |
\(1\) |
\(p,q\) |
destination and source cell indices |
\(1\) |
\(i,j\) |
Cartesian component indices |
\(1\) |
\(w_i\) |
cell volume or FEM integration weight |
\(\mathrm{m^3}\) |
Assumptions and validity¶
The equations assume quasistatic, source-free magnetostatics and a continuum magnetization. The potential representation requires the selected domain topology to be handled by the solver. The open-boundary decay condition is exact at infinity; finite airbox and periodic realizations replace it with separately documented discrete conditions.
Python API¶
Python parameter |
Type |
Default |
SI unit |
Validation |
Meaning |
Backend support |
ProblemIR |
|---|---|---|---|---|---|---|---|
|
|
|
\(1\) |
Canonical model name. |
Selects the physical realization family. |
Planner-dependent. |
|
|
|
|
\(1\) |
Valid only for |
Selects Robin or Dirichlet airbox closure. |
FEM airbox. |
|
Stage-first realization request¶
The common equations are selected through a solver-specific stage request. This example uses the public stage API and records a FEM Poisson Robin realization; it does not imply that the same finite-domain operator is used by FDM.
# %% FEM realization and physical state
import fullmag as fm
nm = 1e-9
study = fm.study("demag_formulation_reference")
study.engine("fem")
study.device("cpu", precision="double")
study.mode("strict")
study.demag(realization="poisson_robin")
study.fem_demag_solver(
solver="CG",
preconditioner="AMG",
rtol=1e-12,
max_iterations=600,
)
body = study.geometry(fm.Box(100 * nm, 20 * nm, 5 * nm), name="film")
body.Ms = 800e3
body.Aex = 13e-12
body.alpha = 0.02
body.m = fm.texture.uniform(1.0, 0.0, 0.0)
study.stages.add_relax(
stage_id="relax",
algorithm="llg_overdamped",
solver="rk23",
dt_initial=1e-15,
dt_min=1e-17,
dt_max=1e-14,
max_err=1e-7,
relax_alpha=1.0,
tolT=1e-6,
max_steps=50_000,
)
The selected realization is a requested intent. The resolved plan must additionally record the magnetic domain, air domain, outer marker, boundary variant, linear solver, preconditioner, tolerances, mesh identity, field recovery, and energy reduction.
Realization hierarchy¶
FDM CPU and GPU: discrete Green operator¶
FDM represents the magnetization by cell averages. The demagnetizing field is a discrete convolution with a translation-invariant tensor on a common grid:
The CPU reference constructs the tensor spectrum and applies the reduction in host memory. The CUDA lane uses device kernels and device reductions. The mathematical input is the same, but padding, FFT layout, precision, reduction order, and device residency are not. Neither lane solves a finite airbox Poisson equation.
FEM CPU and GPU: scalar potential¶
FEM introduces a scalar potential over the magnetic body and, for the airbox variant, an exterior air region. The magnetic source enters through the divergence of \(mathbf M\) and its boundary trace. The CPU path assembles and solves the operator using MFEM/Hypre components; the GPU path has a separate CSR/device-Hypre realization. The recovered field and energy must use the same sign convention as the common continuum equations.
Energy and observable ownership¶
The field-derived energy is not an arbitrary post-processing scalar. For a resolved field, the implementation must reduce
where \(w_i\) is the cell volume or FEM quadrature/lumped weight selected by the backend. The weight, field location, masking of non-magnetic air nodes, and reduction precision are part of provenance. A reported energy without these facts is not reproducible.
ProblemIR¶
The lowered interaction is {"kind": "demag", "realization": "poisson_robin"} for the example.
The IR records semantic intent; it does not encode an unreported discretization approximation.
Round-trip and failure semantics¶
Export preserves requested intent and resolved execution separately. Invalid model/variant pairs are validation errors. Unsupported combinations are rejected as unsupported combinations rather than converted to an open-boundary default.
Discrete realization¶
FDM approximates the Green operator by a cell-averaged tensor. FEM approximates the scalar potential weak form. Both must reproduce the same sign convention and energy derivative.
Implementation mapping¶
Newell tensor construction is in compute_newell_kernels; FEM source assembly is in
assemble_demag_poisson_rhs; energy reduction is in demag_poisson_energy_from_field.
Validation¶
Check Maxwell residuals, field sign, self-demagnetizing factors of uniformly magnetized bodies, and the identity between field-derived energy and the reported scalar energy.
Limitations¶
The scalar-potential page does not claim that every listed backend is qualified for every mesh, precision, periodicity, or airbox policy.
Scientific bibliography¶
Brown, W. F., Micromagnetics, Wiley, 1963.
Fredkin, D. R. and Koehler, T. R., IEEE Transactions on Magnetics 26, 1990.
Control Room crosswalk¶
Use Model Explorer -> Objects -> <object> -> Physics when PhysicsInteractionPanel exposes the interaction. Status: partial. frontend support is not implemented applies to physical parameters without a matching control. See {doc}/frontend/capability-register; do not infer UI support from backend or Python availability.
Python/API crosswalk¶
The linked Python API page is authoritative for exact functions, arguments, units, and failure semantics. If this page is a foundation or category overview, runnable Python is ot applicable here and must be taken from the terminal API page.
Bibliography and source scope¶
Use the scientific bibliography and source-code index on the linked terminal page. This block adds no new equation or unverified implementation claim.
Source-code index¶
Repository path |
Stable symbol |
Responsibility |
|---|---|---|
|
|
Cell-averaged FDM demag tensor. |
|
|
FEM weak-form right-hand side. |
|
|
FEM demag energy reduction. |