Backend registry¶
Every numerical backend of Engine is a registered backend
(groundfield.solver.registry, ADR-0014). A registration ties a name to
its solve function, its declared capabilities, an optional
options model for Engine.options, and flags for deprecated aliases,
experimental status and the automatic forwarding by soil model.
Engine.solve resolves the name, applies the forwarding, checks the
capabilities against the world before any backend code runs, calls the
solve function and fills the common metadata of the result.
Built-in backends¶
| Name | Soils | Kernels | Concrete shells | Two-terminal sources | Junctions | Voltage sources | Status |
|---|---|---|---|---|---|---|---|
image |
homogeneous (forwards two- and multi-layer) | line, point | yes | yes | yes | yes | default |
image_2layer |
two-layer | line, point | yes | yes | yes | yes | |
mom |
homogeneous, two-layer | point | yes (since 2026.11) | yes | yes | yes | |
mom_sommerfeld |
any number of layers | point | yes (since 2026.11) | yes | yes | yes | options: MomSommerfeldOptions |
fem |
any number of layers | — | yes (since 2026.11) | yes (since 2026.11) | yes (since 2026.11) | yes (since 2026.11) | experimental; axisymmetric model for coaxial rods and rings, 3-D model otherwise (fem3d extra); options: FemOptions |
cim |
→ image |
deprecated alias | |||||
bem |
→ mom |
deprecated alias | |||||
image_nlayer |
homogeneous, two-layer | line, point | yes | yes | yes | yes | deprecated name of the image dispatch |
Every built-in backend honours every conductor model (lumped,
distributed, inductive, skin effect). Since its conforming model of
2026.11 (user decision Q37) fem runs the network of the shared pipeline
like the integral backends: its axisymmetric model solves rods on one
vertical axis and horizontal rings centred on it, its three-dimensional
model (the optional fem3d extra) every other world, galvanic
distributed conductors included (FemOptions.model). Up to then it
solved distributed and inductive conductors as lumped resistive
branches and rejected shells, junctions, two-terminal and voltage
sources. The table is checked against the registry:
import groundfield as gf
from groundfield.solver import get_backend
assert gf.available_backends() == ("image", "image_2layer", "mom", "mom_sommerfeld", "fem")
assert set(gf.available_backends(include_deprecated=True)) - set(gf.available_backends()) == {
"cim", "bem", "image_nlayer"
}
caps = {name: get_backend(name).capabilities for name in gf.available_backends()}
assert caps["image"].kernels == {"line", "point"} and caps["mom"].kernels == {"point"}
assert caps["mom_sommerfeld"].soils == {"homogeneous", "two_layer", "multi_layer"}
assert caps["image"].concrete_shells and caps["mom"].concrete_shells
assert caps["mom_sommerfeld"].concrete_shells and caps["fem"].concrete_shells
assert caps["fem"].two_terminal_sources and caps["fem"].junctions
assert caps["fem"].conductors == {"lumped", "distributed", "inductive", "skin"}
assert all(caps[n].voltage_sources for n in gf.available_backends())
assert get_backend("fem").experimental
assert get_backend("cim").deprecated_alias_of == "image"
assert get_backend("bem").deprecated_alias_of == "mom"
What the capability check does¶
A world that a backend cannot represent raises
BackendCapabilityError (a subclass of ValueError and
NotImplementedError) naming the backends that can: an unsupported
layer count, electrodes with a concrete-shell coefficient, junction
nodes, voltage sources, or an explicitly requested kernel the backend
does not have.
Adjacent layers of equal resistivity count as one layer.
A world that a backend solves with a documented simplification
warns with BackendCapabilityWarning and solves: conductor models the
backend reduces (no built-in backend since 2026.11), or a return_to
terminal on a backend that returns the current through remote earth.
Solving with a deprecated alias warns with DeprecationWarning; the
first solve with an experimental backend in a process warns once with
ExperimentalBackendWarning. Options for a backend that will not run
warn with BackendOptionsWarning.
Registering a backend¶
register_backend(name, solve_fn, capabilities=..., options_model=...)
adds a backend without changing Engine.solve; the solve function has
the signature solve_fn(world, engine, **options) -> FieldResult. A
registered name is accepted by Engine(backend=...) and listed by
available_backends().
API reference¶
registry ¶
Backend registry: names, capabilities, options and the solve contract.
Every numerical backend of Engine
is a registered backend. A registration ties a name to
- a solve function
solve_fn(world, engine, **options) -> FieldResult; - the capabilities of the backend (
BackendCapabilities): which soil models, conductor models and source kinds it can represent; - an optional options model (a
BackendOptionssubclass) that validates the backend-specific settings inEngine.options; the validated options are passed to the solve function as keyword arguments; - optional aliases, a deprecated-alias target, an experimental flag and an auto-forwarding rule by soil model.
Engine.solve resolves
the requested name, applies the auto-forwarding, checks the
capabilities against the world before any backend code runs, calls
the solve function and fills the common metadata core of the result.
Adding a backend therefore needs one register_backend() call and
no change to Engine.solve.
Capability checks
A world that a backend cannot represent raises
BackendCapabilityError naming the backends that can solve it:
- the soil: homogeneous (one layer), two-layer, or n-layer (\(n \ge 3\)). Adjacent layers of equal resistivity are one layer physically, so a stack is acceptable to a backend that supports any layer count between the merged and the declared one (the check is conservative: it never rejects a world the backend could solve);
- electrodes with a concrete-shell correction (ADR-0012);
- leakage-free junction nodes (
World.junctions) on a backend that does not build its nodal system through the shared pipeline; - a source kernel requested explicitly that the backend does not implement.
A world that a backend solves with a documented simplification
emits BackendCapabilityWarning and solves:
- conductor models the backend reduces (no built-in backend since
2026.11;
femtreated distributed conductors as lumped branches and ignored inductance and the skin effect up to its conforming model, user decision Q37); - sources with a
return_toelectrode on a backend that returns the current through remote earth instead.
Deprecated aliases and experimental backends
Solving with a deprecated alias emits a DeprecationWarning
that names the replacement and the earliest removal
(DEPRECATION_REMOVAL). The first solve with an experimental
backend in a process emits ExperimentalBackendWarning once.
Neither is emitted for the internal auto-forwarding.
Since review pass 10 (10.76) cim and bem are pure deprecated
aliases of image and mom (both assembled the same system as
their target), image_nlayer is a deprecated name of the image
auto-dispatch that keeps its own solve function, so the forwarding of
image to it stays silent, and fem is experimental.
DEFAULT_IMAGE_MAX_TERMS
module-attribute
¶
Default cap on the number of Tagg / Sunde image-series terms.
One value for the engine, every layered backend and the post-solve field evaluation. The geometric tail bound |K|^(n+1)/(1-|K|) falls below the default tolerance after 277 terms for the AP1 corner soil rho_1 = 1000, rho_2 = 30 Ohm m (|K| = 0.9417), so the cap stays unused there.
DEFAULT_IMAGE_SERIES_TOL
module-attribute
¶
Default stop tolerance of the Tagg / Sunde image series.
Summation ends when the geometric tail bound |K|^(n+1)/(1-|K|) falls below this value.
DEPRECATION_REMOVAL
module-attribute
¶
Earliest calendar version in which deprecated names are removed.
BackendCapabilities
dataclass
¶
BackendCapabilities(soils: Set[str], conductors: Set[str] = frozenset(_CONDUCTOR_FEATURES), concrete_shells: bool = False, two_terminal_sources: bool = False, kernels: Set[str] = frozenset({'point'}), junctions: bool = False, voltage_sources: bool = False)
What a backend can represent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
soils
|
Set[str]
|
Soil layer counts the backend solves: |
required |
conductors
|
Set[str]
|
Conductor models the backend honours: |
frozenset(_CONDUCTOR_FEATURES)
|
concrete_shells
|
bool
|
Whether the backend consumes the per-electrode concrete-shell
coefficient |
False
|
two_terminal_sources
|
bool
|
Whether the backend returns a source current through
|
False
|
junctions
|
bool
|
Whether the backend represents leakage-free junction nodes
( |
False
|
voltage_sources
|
bool
|
Whether the backend solves impressed voltage sources
( |
False
|
kernels
|
Set[str]
|
Source kernels the backend implements ( |
frozenset({'point'})
|
BackendCapabilityError ¶
Bases: ValueError, NotImplementedError
The selected backend cannot represent the world.
Raised by Engine.solve() before any backend code runs. The
message names the missing capability and the registered backends
that can solve the world. The backend functions raise it as well
when they are called directly with a soil model they cannot solve
(solve_image with a layered soil, solve_image_2layer with a
homogeneous soil, solve_image_nlayer and solve_mom with three
or more distinct layers), and so does the concrete-shell guard of
the backends without the shell correction: one error type for one
situation (audit A1-08). TypeError is left for a
world.soil that is no soil model at all.
Subclasses both ValueError and NotImplementedError,
the types image_nlayer, cim, bem and the concrete-shell
guard raised for the same situations in 0.15.0. Changed in 2026.11:
image_2layer (homogeneous soil, layer stack) and mom (three
or more layers) raised TypeError, which does not catch this
error; catch BackendCapabilityError (or ValueError).
BackendCapabilityWarning ¶
Bases: UserWarning
The backend solves the world with a documented simplification.
BackendOptions ¶
Bases: BaseModel
Base class of the backend-specific option models.
Subclasses declare the keyword arguments of one backend's solve function as validated, immutable fields. Unknown keys are rejected.
BackendOptionsWarning ¶
Bases: UserWarning
Engine.options configures a backend that will not run.
BackendSpec
dataclass
¶
BackendSpec(name: str, solve_fn: SolveFunction | str | None, capabilities: BackendCapabilities | None, options_model: type[BackendOptions] | None = None, aliases: tuple[str, ...] = (), deprecated_alias_of: str | None = None, experimental: bool = False, forward: tuple[tuple[str, str], ...] = (), summary: str = '')
Registration record of one backend name.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Registered name. |
solve_fn |
SolveFunction | str | None
|
Solve function, or a lazy |
capabilities |
BackendCapabilities | None
|
Declared capabilities; |
options_model |
type[BackendOptions] | None
|
|
aliases |
tuple[str, ...]
|
Further accepted names (resolved silently). |
deprecated_alias_of |
str | None
|
Replacement name if this name is deprecated. |
experimental |
bool
|
Whether solving with the backend emits
|
forward |
tuple[tuple[str, str], ...]
|
Auto-forwarding rule: pairs |
summary |
str
|
One-line description. |
forward_target ¶
Backend the call is forwarded to for a soil model kind, if any.
resolve_solve_fn ¶
Return the callable solve function (imports lazy references).
Returns:
| Type | Description |
|---|---|
Callable
|
|
Raises:
| Type | Description |
|---|---|
TypeError
|
For a pure alias, which has no solve function of its own. |
Source code in src/groundfield/solver/registry.py
ExperimentalBackendWarning ¶
Bases: UserWarning
An experimental backend was used (emitted once per process).
FemOptions ¶
Bases: BackendOptions
Mesh, extrapolation and truncation controls of the fem backend.
Forwarded to groundfield.solver.fem.solve_fem(). The defaults
reproduce the backend's own signature defaults. Since 2026.11 fem
is a conforming finite-element model (user decision Q37): axisymmetric
for rods on one axis and rings around it, three-dimensional for every
other world (model, source_radius, growth,
concrete_resistivity, max_nodes_3d, max_ports_3d; the
optional fem3d extra). The controls of
the equivalent-hemisphere mesh (n_radial, n_axial,
z_far_factor) are gone.
MomSommerfeldOptions ¶
Bases: BackendOptions
Accuracy controls of the mom_sommerfeld backend.
Forwarded to
groundfield.solver.mom_sommerfeld.solve_mom_sommerfeld(). The
defaults reproduce the backend's own signature defaults.
ResolvedBackend
dataclass
¶
Outcome of resolve_backend() for one world.
Attributes:
| Name | Type | Description |
|---|---|---|
requested |
str
|
Name as given in |
spec |
BackendSpec
|
Record of the backend that runs (after alias resolution and auto-forwarding). |
deprecated |
BackendSpec | None
|
Record of the requested deprecated alias, or |
available_backends ¶
Registered backend names in registration order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_deprecated
|
bool
|
Also list deprecated aliases. |
False
|
Returns:
| Type | Description |
|---|---|
tuple of str
|
Backend names (aliases from |
Source code in src/groundfield/solver/registry.py
check_capabilities ¶
check_capabilities(resolved: ResolvedBackend, world: World, *, kernel: str | None = None, kernel_explicit: bool = False) -> None
Check that the resolved backend can represent world.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resolved
|
ResolvedBackend
|
Outcome of |
required |
world
|
World
|
World to be solved. |
required |
kernel
|
str | None
|
Source kernel requested by the engine, if the engine has one. |
None
|
kernel_explicit
|
bool
|
Whether the kernel was set explicitly (a default kernel that the backend does not implement is replaced by the backend's own). |
False
|
Raises:
| Type | Description |
|---|---|
BackendCapabilityError
|
If the backend cannot represent the world. |
Warns:
| Type | Description |
|---|---|
BackendCapabilityWarning
|
If the backend solves the world with a documented
simplification (reduced conductor model, ignored
|
Source code in src/groundfield/solver/registry.py
1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 | |
effective_kernel ¶
Kernel a backend uses when the engine requests requested.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
BackendSpec
|
Record of the backend that runs. |
required |
requested
|
str | None
|
Kernel requested by the engine, or |
required |
Returns:
| Type | Description |
|---|---|
str or None
|
|
Source code in src/groundfield/solver/registry.py
emit_resolution_warnings ¶
Deprecation warning for a requested alias; experimental warning once.
Source code in src/groundfield/solver/registry.py
get_backend ¶
Look up a backend by name or alias.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Backend name or alias. |
required |
Returns:
| Type | Description |
|---|---|
BackendSpec
|
The registration record (for a deprecated alias: the alias's
own record, whose |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the name is unknown; the message suggests the closest registered name. |
Source code in src/groundfield/solver/registry.py
options_key ¶
reachable_backends ¶
Backends that can run when name is requested (any soil).
Source code in src/groundfield/solver/registry.py
register_backend ¶
register_backend(name: str, solve_fn: SolveFunction | str | None, *, capabilities: BackendCapabilities | None = None, options_model: type[BackendOptions] | None = None, aliases: Iterable[str] = (), deprecated_alias_of: str | None = None, experimental: bool = False, forward: Mapping[str, str] | None = None, summary: str = '', replace: bool = False) -> BackendSpec
Register a backend name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Backend name as used in |
required |
solve_fn
|
SolveFunction | str | None
|
|
required |
capabilities
|
BackendCapabilities | None
|
What the backend can represent. Required unless |
None
|
options_model
|
type[BackendOptions] | None
|
|
None
|
aliases
|
Iterable[str]
|
Further accepted names, resolved without a warning. |
()
|
deprecated_alias_of
|
str | None
|
Registered replacement name. Solving with |
None
|
experimental
|
bool
|
Emit |
False
|
forward
|
Mapping[str, str] | None
|
Auto-forwarding by soil model kind, e.g. |
None
|
summary
|
str
|
One-line description. |
''
|
replace
|
bool
|
Allow replacing an existing registration of |
False
|
Returns:
| Type | Description |
|---|---|
BackendSpec
|
The stored registration record. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the name is taken (and |
Source code in src/groundfield/solver/registry.py
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 | |
resolve_backend ¶
Resolve aliases and the auto-forwarding for world.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
requested
|
str
|
Backend name as given in |
required |
world
|
World
|
World to be solved (its soil model kind drives the forwarding). |
required |
Returns:
| Type | Description |
|---|---|
ResolvedBackend
|
The backend that runs; emits no warning. |
Source code in src/groundfield/solver/registry.py
soil_kinds ¶
Layer-count kinds a soil model can be solved as.
A stack whose adjacent layers share a resistivity can be solved with any layer count between the merged and the declared one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
soil
|
SoilModel
|
Soil model of the world. |
required |
Returns:
| Type | Description |
|---|---|
frozenset of str
|
Subset of |
Source code in src/groundfield/solver/registry.py
unregister_backend ¶
Remove a registration together with its aliases.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Registered name (not an alias). |
required |
Returns:
| Type | Description |
|---|---|
BackendSpec
|
The removed record. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If |
Source code in src/groundfield/solver/registry.py
validate_options_entry ¶
Validate one Engine.options entry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Backend name or alias. |
required |
value
|
Any
|
Options model instance or mapping of option values. |
required |
Returns:
| Type | Description |
|---|---|
tuple
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
For an unknown backend, a backend without options, an unknown option name (with a suggestion) or a wrong value type. |
Source code in src/groundfield/solver/registry.py
warn_external ¶
Emit a warning attributed to the first frame outside the package.
Frames inside groundfield and pydantic (model validators) and
in the standard library's copy module (copy.replace on
Python >= 3.13 calls pydantic's __replace__; audit R2B-06) are
skipped, so the warning points at the user's line. This matters most
for DeprecationWarning, which Python only shows by default
when it is attributed to __main__.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Warning text. |
required |
category
|
type[Warning]
|
Warning class. |
required |