FEM Poisson airbox solver¶
Last changes: Documentation changelog
Scope and purpose¶
The canonical physical demagnetization definition is owned by Demagnetization. This page describes the shared-domain FEM realization: the magnetic body \(\Omega_m\) is embedded in an airbox so that a scalar potential can be solved on \(\Omega_a=\Omega_m\cup\Omega_{\mathrm{air}}\). The airbox boundary marker, outer closure, linear-solver policy, field recovery and energy reduction are one numerical problem.
The page has two distinct closures. Dirichlet fixes the outer potential; Robin adds a boundary operator approximating open decay. They are not two names for one solver setting and results must record the selected closure.
Scientific and numerical model¶
The magnetostatic scalar-potential field is recovered as
In the magnetic domain, the strong equation is
For test function \(v\), the Robin weak form is
The Robin boundary condition is
For Dirichlet, the selected outer degrees of freedom satisfy \(u=0\) and the boundary mass term is absent. After solving, the demagnetization energy is reduced from the recovered magnetic field:
Symbols and SI units¶
Symbol |
Meaning |
SI unit |
|---|---|---|
\(u\) |
magnetic scalar potential |
\(\mathrm{A}\) |
\(v\) |
FEM test function |
\(1\) |
\(\mathbf M\) |
magnetization field |
\(\mathrm{A\,m^{-1}}\) |
\(\mathbf H_{\mathrm d}\) |
recovered demagnetizing field |
\(\mathrm{A\,m^{-1}}\) |
\(\Omega_a\) |
complete magnetic-plus-air domain |
\(\mathrm{m^3}\) |
\(\Omega_m\) |
magnetic subdomain |
\(\mathrm{m^3}\) |
\(\Gamma_a\) |
selected outer airbox boundary |
\(\mathrm{m^2}\) |
\(\mathbf n\) |
outward unit normal on \(\Gamma_a\) |
\(1\) |
\(\beta\) |
Robin boundary coefficient |
\(\mathrm{m^{-1}}\) |
\(c\) |
dimensionless Robin coefficient |
\(1\) |
\(R_\star\) |
open-axis reference radius |
\(\mathrm{m}\) |
\(\mu_0\) |
vacuum permeability |
\(\mathrm{N\,A^{-2}}\) |
\(E_{\mathrm d}\) |
demagnetization energy |
\(\mathrm{J}\) |
\(K\) |
volume stiffness matrix |
\(\mathrm{m}\) |
\(B_{\Gamma}\) |
boundary mass matrix |
\(\mathrm{m^2}\) |
\(A_{\mathrm R}\) |
Robin matrix \(K+\beta B_{\Gamma}\) |
\(\mathrm{m}\) |
\(b\) |
assembled magnetic right-hand side |
\(\mathrm{A\,m}\) |
\(\widehat u\) |
potential degree-of-freedom vector |
\(\mathrm{A}\) |
Assumptions and validity¶
The mesh is conforming across the magnetic body and airbox and carries a stable outer boundary marker. A magnetic-only mesh is not a Poisson airbox problem.
Dirichlet is a finite-domain truncation, not the exact infinite-domain condition.
Robin is a mesh-scaled open-boundary approximation. Its coefficient and selected open axes must be recorded; it is not a universal constant.
rtolandmax_iterationscontrol the algebraic linear solve. They do not establish airbox, mesh, quadrature or field-recovery accuracy.The energy is computed from the recovered magnetic field and must not be replaced by a matrix quadratic form unless the implementation records that alternative reduction.
Python API¶
# %% Configure a shared-domain FEM Poisson demag stage
import fullmag as fm
nm = 1.0e-9
study = fm.study("fem_poisson_airbox_demag")
study.engine("fem")
study.device("cpu", precision="double")
study.mode("strict")
study.universe(mode="manual", size=(700 * nm, 250 * nm, 250 * nm))
study.universe.mesh(
minimum_element_size=3 * nm,
maximum_element_size=20 * nm,
maximum_element_growth_rate=1.7,
grading="geometric",
)
film = study.geometry(
fm.Box(size=(500 * nm, 125 * nm, 3 * nm), name="film"),
name="film",
)
film.Ms = 8.0e5
film.Aex = 1.3e-11
film.alpha = 0.02
film.m = fm.init.UniformMagnetization((1.0, 0.1, 0.0))
study.demag(realization="poisson_robin")
study.fem_demag_solver(
solver="CG",
preconditioner="AMG",
rtol=1.0e-12,
max_iterations=500,
)
study.stages.add_relax(
stage_id="relax",
algorithm="llg_overdamped",
solver="rk45",
dt_initial=1.0e-15,
dt_min=1.0e-17,
dt_max=1.0e-14,
max_err=1.0e-7,
tolT=1.0e-6,
max_steps=50_000,
)
Parameters¶
Python parameter |
Type |
Default |
SI unit |
Validation |
Meaning |
Backend support |
ProblemIR |
|---|---|---|---|---|---|---|---|
|
|
|
\(1\) |
|
realization family |
FEM planner |
|
|
|
|
\(1\) |
with |
outer closure |
FEM CPU/GPU subject to qualification |
|
|
|
|
\(1\) |
legacy aliases normalize before planning |
compatibility selector |
normalized before planning |
|
|
|
required |
\(1\) |
integer greater than or equal to \(1\) |
finite-element polynomial order |
FEM CPU/GPU |
|
|
|
required |
\(\mathrm{m}\) |
finite positive; |
target mesh size |
FEM CPU/GPU |
|
|
|
|
\(1\) |
|
Krylov method |
FEM CPU/GPU |
|
|
|
|
\(1\) |
|
preconditioner |
FEM CPU/GPU |
|
|
|
|
\(1\) |
finite and strictly positive |
relative algebraic tolerance |
FEM CPU/GPU |
|
|
|
|
\(1\) |
positive when supplied |
optional absolute algebraic tolerance |
FEM CPU/GPU |
|
|
|
|
\(1\) |
integer greater than or equal to \(1\) |
Krylov iteration ceiling |
FEM CPU/GPU |
|
|
|
inherited/default |
\(\mathrm{m}\) |
finite positive |
airbox mesh maximum size |
FEM meshing |
|
|
|
|
\(\mathrm{m}\) |
positive and no larger than maximum |
airbox mesh lower bound |
FEM meshing |
|
ProblemIR and provenance¶
The interaction and FEM solver policy remain distinct:
{
"energy_terms": [{"kind": "demag", "realization": "poisson_robin"}],
"backend_policy": {
"discretization_hints": {
"fem": {
"order": 1,
"hmax": 2e-8,
"demag_solver_policy": {
"solver": "CG",
"preconditioner": "AMG",
"rtol": 1e-12,
"max_iterations": 500
}
}
}
}
}
airbox with omitted or auto variant normalizes to the Robin family. Explicit dirichlet
remains distinct. Resolved mesh topology, boundary marker, essential DOFs, solver residual,
iteration count, precision, CPU/GPU lane and actual device are provenance, not inferred defaults.
Diagnostics and failure semantics¶
Script export preserves the stage-first workflow and separate airbox/solver policies. Validation
errors include conflicting model and legacy realization, invalid variant, missing conforming
airbox, invalid rtol, invalid solver/preconditioner, and exhausted max_iterations. Unsupported combinations
are explicit: a FDM request cannot silently select Poisson, and an unavailable GPU
Hypre path cannot silently fall back to CPU. A linear-solver non-convergence is a failed demag
evaluation, not an accepted field.
Requested intent, resolved execution and validation errors are recorded separately. Unsupported combinations remain explicit in planner provenance rather than being replaced by a different solver.
Discrete realization and CPU/GPU separation¶
Solver |
Device |
Status |
Realization |
|---|---|---|---|
FEM |
CPU |
implemented/source-backed |
MFEM assembly, explicit Dirichlet/Robin operator, Hypre/MFEM solve, field recovery and energy |
FEM |
GPU |
source-backed/qualification-dependent |
device CSR RHS/recovery, device Hypre policy and staged energy reduction |
FDM |
CPU |
not applicable |
uses the Newell tensor convolution page |
FDM |
GPU |
not applicable |
uses the CUDA tensor convolution page |
The weak form is shared by CPU/GPU. The assembled operator, sparse solver library, memory residency, boundary-DOF preparation, reductions and telemetry are separate lane contracts.
Where this is implemented¶
Claim |
Repository path |
Stable symbol |
Responsibility |
Lane |
|---|---|---|---|---|
Demag normalization |
|
|
model/variant aliases and IR |
public API |
FEM solver policy |
|
|
CG/GMRES, preconditioner, tolerances and limits |
public API |
RHS |
|
|
magnetic Poisson RHS |
FEM CPU |
Boundary operator |
|
|
Dirichlet/Robin construction |
FEM CPU |
Linear solve |
|
|
solver and telemetry |
FEM CPU |
Field recovery |
|
|
gradient, mask and field handoff |
FEM CPU |
Energy reduction |
|
|
demagnetization energy reduction |
FEM CPU |
Device RHS/recovery |
|
|
device CSR RHS and recovery kernels |
FEM GPU |
Validation¶
Validation must separately test boundary markers and operators, manufactured Poisson fields, solver
residual/iteration telemetry, airbox-size and mesh convergence, recovered-field energy identity,
Dirichlet-versus-Robin differences, and executed CPU/GPU evidence. rtol=1e-12 proves only an
algebraic policy if mesh and airbox convergence are not also measured.
Limitations¶
Robin is an approximation to open decay and depends on the airbox/reference-radius policy. Dirichlet is a finite truncation. This page does not claim universal GPU Hypre qualification or equivalence between the two closures.
Scientific bibliography¶
W. F. Brown, Jr., Micromagnetics, Wiley, 1963.
A. J. F. Siegert and A. J. Newell, open-boundary scalar-potential formulations as summarized in the canonical Fullmag demagnetization note.
Canonical physics owner: FEM Poisson airbox demagnetization.
Control Room workflow¶
Use Model Explorer -> Stages -> Add stage -> <stage kind> for stage-level controls when the terminal page identifies a matching field. The current editor is partial: only fields surfaced by the stage draft are authorable. Numerical parameters without a matching control are not implemented in the frontend. Do not infer frontend support from Python or backend availability. See {doc}/frontend/capability-register for the current register and exact source owner.
Source-code index¶
Claim |
Repository path |
Stable symbol |
Responsibility |
Lane |
Evidence |
|---|---|---|---|---|---|
Public realization |
|
|
model and variant normalization |
public API |
Python tests |
Solver policy |
|
|
linear solver controls |
public API |
Python tests |
RHS assembly |
|
|
magnetic source term |
FEM CPU |
source contracts |
Boundary closure |
|
|
Dirichlet and Robin operators |
FEM CPU |
boundary contracts |
CPU solve |
|
|
Hypre/MFEM solve and telemetry |
FEM CPU |
managed runtime evidence |
Field recovery |
|
|
recovered field |
FEM CPU |
recovery contracts |
Energy reduction |
|
|
energy reduction |
FEM CPU |
reduction contracts |
GPU RHS |
|
|
device RHS |
FEM GPU |
CUDA/source contract |