Geometry¶
The geometry package describes the buried metal: parametric
electrodes (rod, ring, strip, polyline, star, mesh, grid mesh), the
leakage-free Junction node, and the discretisation of every electrode
into straight wire segments that the solvers consume.
| Kind | Class | Parameters (m) | Typical use |
|---|---|---|---|
rod |
RodElectrode |
position (top end), length |
driven rod (Tiefenerder) |
ring |
RingElectrode |
center, radius |
ring earth around a building or substation |
strip |
StripElectrode |
start, end |
horizontal earth strip, counterpoise |
polyline |
PolylineElectrode |
vertices, closed |
foundation earth following a building outline |
star |
StarElectrode |
center, n_arms, arm_length, orientation_deg |
star earth (Sternerder) |
mesh |
MeshElectrode |
corner, size, spacing |
mesh with a given spacing |
grid_mesh |
GridMeshElectrode |
corner, size, n_x, n_y |
substation grid with a given number of wires |
Every kind also takes wire_radius (default 5 mm) and
concrete_shell_coefficient_ohm_m (default 0, see below).
Mathematical and physical context¶
An electrode is a thin wire: its radius \(a\) is small against its length and against the distance to other wires, so the current leaving the surface can be represented by a current on the wire axis and the potential is evaluated on the surface (at distance \(a\)). Each geometry is cut into straight segments
no longer than Engine.segment_length. Grid and mesh wires are split
so that wire crossings fall on segment end points, and every wire is
cut at the soil-layer interfaces so that each segment lies in one
layer; every interface cut is kept, however short the piece beyond it,
so a rod tip that reaches a few millimetres into a layer is in contact
with it. (The thin wire has no end face, so a rod end within one wire
radius of an interface is a limit of the model — up to +21 % against the
solid rod — and warns with InterfaceContactWarning; see the
image_2layer page.)
How the current is
distributed over the segments — uniform per unit length on each
electrode (image family) or one unknown per segment (mom family) — is
a property of the backend, see Solver and
source kernels.
Concrete encasement. A foundation earth in concrete adds the radial resistance of the concrete shell. Every electrode kind carries it as a per-length coefficient
for concrete resistivity \(\rho_c\), bare wire radius \(a\) and shell
thickness \(t\); the electrode's wire_radius is then the outer radius
\(a + t\) (the soil sees the shell surface), and every segment of length
\(\Delta s\) adds the series resistance \(C/\Delta s\) of its shell to its
self term. Only the image family (image, image_2layer) and
solve_mutual_* represent a non-zero coefficient; the other backends
reject such a world before they run. The helpers
concrete_shell_coefficient, shell_resistance_from_coefficient and
shell_coefficient_from_resistance convert between the coefficient and
a lumped resistance; the physics is explained in
concrete shells and ADR-0012.
Validity. Thin-wire approximation (\(a \ll\) segment length and wire spacing); wires must be in the soil (\(z > 0\)) — the solver rejects segments in the air and warns about leakage segments that are long compared with their depth.
Example¶
import groundfield as gf
from groundfield.references import dwight1936
world = gf.create_world(soil=gf.HomogeneousSoil(rho=100.0))
star = gf.create_electrode(
world, "star", name="star", center=(0.0, 0.0, 0.5), n_arms=4, arm_length=5.0
)
gf.create_source(world, attached_to="star", magnitude=1.0)
result = gf.create_engine(segment_length=0.5).solve(world)
assert abs(star.total_length() - 20.0) < 1e-12 # four arms of 5 m
R = result.input_impedance()[0].real # 10.05 Ω
R_ref = dwight1936.n_point_star(rho=100.0, arm_length=5.0, radius=0.005, depth=0.5, n_arms=4)
assert abs(R - R_ref) / R_ref < 1e-3 # Dwight (1936), Eqs. 23-26
The geometry queries segments(ds), segment_count(ds),
wire_polylines(), bounds(), total_length() and
min_feature_length() are available on every electrode without a
solve, for example to check a model before a long computation.
API reference¶
geometry ¶
Geometries of electrodes and grounding systems.
This subpackage provides the 3-D geometry of the grounding system:
the standard parametric electrode geometries and their discretisation
into straight wire segments (WireSegments), which every
electrode produces itself through segments(ds).
Contents
RodElectrode, RingElectrode, StripElectrode, PolylineElectrode,
StarElectrode, MeshElectrode, GridMeshElectrode
Parametric standard electrode geometries. Each answers the
geometry queries segments(ds), segment_count(ds),
wire_polylines(), bounds(), total_length() and
min_feature_length().
Electrode
Discriminated union over all electrode types.
WireSegments
Midpoints, lengths and unit tangents of a discretised wire
geometry.
Notes
The geometry layer is deliberately decoupled from the solver, so the same geometry can be fed into the image-charge backend, MoM, or FEM.
Electrode
module-attribute
¶
Electrode = Union[RodElectrode, RingElectrode, StripElectrode, PolylineElectrode, StarElectrode, MeshElectrode, GridMeshElectrode]
Union of the electrode classes; their kind field tells them apart.
RodElectrode, RingElectrode, StripElectrode,
PolylineElectrode, StarElectrode, MeshElectrode
and GridMeshElectrode. The item type of World.electrodes.
GridMeshElectrode ¶
Bases: _ElectrodeBase
Rectangular meshed earth electrode with explicit n × m divisions.
Defines an axis-aligned rectangle of size (dx, dy) at depth
corner[2], divided into n_x × n_y internal meshes.
The geometry consists of n_x + 1 longitudinal wires (running
along the local \(x\) axis from corner to corner + (dx, 0))
and n_y + 1 transverse wires (running along the local \(y\)
axis). All wires share the same depth.
Attributes:
| Name | Type | Description |
|---|---|---|
corner |
Point3D
|
Corner point |
size |
tuple[PositiveLength, PositiveLength]
|
Extent |
n_x |
int
|
Number of meshes along \(x\) (must be ≥ 1). The number of
longitudinal wires is |
n_y |
int
|
Number of meshes along \(y\) (must be ≥ 1). The number of
transverse wires is |
concrete_shell_coefficient_ohm_m |
float
|
Per-length concrete-shell coefficient in Ω·m (ADR-0012, default
0: no shell); see |
Notes
Naming convention: n_x × n_y is the count of meshes
(cells), not of wires.
A grid with n_x = n_y = 1 is therefore a single closed
rectangle (the perimeter wires only).
connection_point
property
¶
Centre of the grid rectangle in m, where conductors attach.
min_feature_length ¶
segments ¶
Grid of n_y + 1 by n_x + 1 wires (see base class).
Source code in src/groundfield/geometry/electrodes.py
total_length ¶
wire_polylines ¶
Every wire of the grid (see base class).
Source code in src/groundfield/geometry/electrodes.py
Junction ¶
Bases: BaseModel
Named leakage-free network node.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Unique node name within the |
kind |
Literal['junction']
|
Always |
position |
Point3D
|
Location |
Notes
Conductors refer to a junction by name through
Conductor.start_electrode / end_electrode, sources through
attached_to / return_to. Results report the junction
potential per frequency in FieldResult.metadata
["junction_potentials"][name] (V).
connection_point
property
¶
End point used by conductors that start or end here (m).
MeshElectrode ¶
Bases: _ElectrodeBase
Rectangular mesh earth electrode (uniform spacing).
Backwards-compatible primitive that sets the inner mesh density
via a single spacing parameter. For finer control over the
column / row count, prefer GridMeshElectrode.
Attributes:
| Name | Type | Description |
|---|---|---|
corner |
Point3D
|
Corner point |
size |
tuple[PositiveLength, PositiveLength]
|
Extent |
spacing |
PositiveLength
|
Spacing between adjacent longitudinal / transverse wires in m. |
concrete_shell_coefficient_ohm_m |
float
|
Per-length concrete-shell coefficient in Ω·m (ADR-0012, default
0: no shell); see |
connection_point
property
¶
Centre of the mesh rectangle in m, where conductors attach.
min_feature_length ¶
segments ¶
Grid of wires at spacing (see base class).
Source code in src/groundfield/geometry/electrodes.py
total_length ¶
wire_polylines ¶
Every wire of the mesh (see base class).
Source code in src/groundfield/geometry/electrodes.py
PolylineElectrode ¶
Bases: _ElectrodeBase
Buried wire following an arbitrary horizontal polyline.
Generalises StripElectrode from a single straight wire to
a chain of straight wires through vertices. With
closed = True the last vertex is wired back to the first,
which makes this the Ringerder along an arbitrary building
outline — the DIN-18014 Streifenfundament that follows the real
building perimeter instead of its bounding rectangle.
All vertices must lie at the same depth (the wire is horizontal),
consistent with StripElectrode.
Attributes:
| Name | Type | Description |
|---|---|---|
vertices |
list[Point3D]
|
Ordered polyline vertices |
closed |
bool
|
Whether the polyline is closed into a ring (default
|
Notes
Motivation (AP1): approximating a building footprint by its oriented bounding rectangle (OMBR) overestimates the electrode perimeter for L- and U-shaped buildings and — worse — lets the rectangles of neighbouring buildings coincide or overlap, which drives distinct segments into the solver's 1 mm singularity clamp. Following the real polygon removes both artefacts by construction.
connection_point
property
¶
First vertex of the polyline in m, where conductors attach.
edges
property
¶
Straight wires making up the polyline (closing edge included).
min_feature_length ¶
segments ¶
One strip-style chain per edge (see base class).
Every edge is discretised exactly like a StripElectrode,
so a closed rectangular polyline reproduces the four perimeter
wires of the equivalent strip chain. Degenerate edges (zero
length) are skipped. Consecutive edges that continue in the same
direction form one straight wire
(wires): the
image family gives every straight wire of the polyline its own
uniform current (user decisions Q30 and Q44 of 2026.11), so a
building outline has one owner per side and a generated mesh wire,
which has a vertex at every crossing, stays one owner.
Source code in src/groundfield/geometry/electrodes.py
total_length ¶
wire_polylines ¶
The vertex chain, closed if closed (see base class).
Source code in src/groundfield/geometry/electrodes.py
RingElectrode ¶
Bases: _ElectrodeBase
Horizontal ring electrode (foundation / ring earth electrode).
Attributes:
| Name | Type | Description |
|---|---|---|
center |
Point3D
|
Ring centre |
radius |
PositiveLength
|
Ring radius in metres. |
concrete_shell_coefficient_ohm_m |
float
|
Per-length concrete-shell coefficient in Ω·m (ADR-0012, default
0: no shell); see |
connection_point
property
¶
Point of the ring on the +x side of the centre in m, for conductors.
bounds ¶
Exact bounding box of the circle (see base class).
min_feature_length ¶
segments ¶
Horizontal ring: max(8, ceil(2πr/ds)) equal arcs (see base class).
Each arc is represented by its midpoint on the circle, its arc length and the tangent there.
Source code in src/groundfield/geometry/electrodes.py
total_length ¶
wire_polylines ¶
Closed circle sampled at n_arc points (see base class).
Source code in src/groundfield/geometry/electrodes.py
RodElectrode ¶
Bases: _ElectrodeBase
Vertical driven rod (Tiefenerder).
Attributes:
| Name | Type | Description |
|---|---|---|
position |
Point3D
|
Position of the head (top end) as |
length |
PositiveLength
|
Rod length in metres (downwards along \(+z\)). |
concrete_shell_coefficient_ohm_m |
float
|
Per-length concrete-shell coefficient in Ω·m (ADR-0012, default
0: no shell); see |
connection_point
property
¶
Top end of the rod (position) in m, where conductors attach.
min_feature_length ¶
segments ¶
Vertical rod: equal segments per soil layer (see base class).
The rod is cut at every interface it crosses; a part beyond a cut keeps its own segment however short it is (it may be shorter than the wire radius), so a tip that reaches into a layer is in contact with it (audit round 2, A2S-01).
Source code in src/groundfield/geometry/electrodes.py
total_length ¶
wire_polylines ¶
Head and foot of the rod (see base class).
StarElectrode ¶
Bases: _ElectrodeBase
Buried horizontal star electrode (Sternerder).
n_arms equal-length wires radiate from a common centre node at a
single depth, spaced uniformly by \(360^\circ / n\). This is the
classic \(n\)-point star of Dwight (1936, Eqs. 23–26); the closed-form
grounding resistance is available as
groundfield.references.dwight1936.n_point_star() for
validation (Dwight covers 3, 4, 6 and 8 arms).
Attributes:
| Name | Type | Description |
|---|---|---|
center |
Point3D
|
Hub |
n_arms |
int
|
Number of radial arms (\(\ge 2\)). |
arm_length |
PositiveLength
|
Length \(L\) of a single arm in metres. |
orientation_deg |
FiniteFloat
|
Azimuth of the first arm measured from the world |
concrete_shell_coefficient_ohm_m |
float
|
Optional per-segment radial concrete-shell coefficient, same
semantics as on |
Notes
Discretisation and the reaction-matrix assembly treat the star as
n_arms straight wires sharing the centre node, so it forms a
single galvanic cluster — exactly the physical Sternerder.
StripElectrode ¶
Bases: _ElectrodeBase
Horizontal straight strip earth electrode (Banderder).
A buried straight wire from start to end. Both end points
must lie at the same depth (\(z_\text{start} = z_\text{end}\));
the in-plane direction is arbitrary, not restricted to the \(x\)
or \(y\) axis. The strip's length is the Euclidean distance between
the end points.
Attributes:
| Name | Type | Description |
|---|---|---|
start |
Point3D
|
Strip start |
end |
Point3D
|
Strip end |
Notes
The strip is the canonical Banderder. For the image /
mom family the discretisation produces one chain of wire
segments (no doubled-wire approximation). Plausibility tests
compare against
groundfield.references.dwight1936.horizontal_wire().
connection_point
property
¶
Start point of the strip (start) in m, where conductors attach.
min_feature_length ¶
segments ¶
Straight strip: equal segments along the axis (see base class).
A sloped strip whose depth range crosses a layer interface would be split there first (ADR-0007 step 1); the model validator keeps strips horizontal, so this only guards the invariant.
Source code in src/groundfield/geometry/electrodes.py
total_length ¶
wire_polylines ¶
WireSegments
dataclass
¶
WireSegments(midpoints: ndarray, lengths: ndarray, directions: ndarray, wires: ndarray | None = None)
Straight segments of a discretised wire geometry.
Attributes:
| Name | Type | Description |
|---|---|---|
midpoints |
ndarray
|
Segment midpoints |
lengths |
ndarray
|
Segment lengths in m, shape |
directions |
ndarray
|
Unit tangents of the segment axes, shape |
wires |
ndarray | None
|
Index of the straight wire every segment lies on, shape |
Notes
The end points follow as midpoints ∓ lengths/2 · directions
(starts, ends). For a ring they are the end points
of the tangent chord through the arc midpoint, not points on the
circle.
concatenate
classmethod
¶
Join several containers in order.
The wire indices are kept as they are (no offset): the parts of
one wire cut at a layer interface stay one wire. A caller that
joins different wires numbers them itself (_edge_wires()).
Source code in src/groundfield/geometry/primitives.py
electrodes ¶
Electrode geometries.
Defines the electrode primitives supported by the PDE / field model as plain data containers (Pydantic v2). Each class describes the geometric parameters (position, dimensions, wire radius). The discretisation into segments is performed inside the solver backend.
Conventions
- Coordinate system: right-handed; the \(z\) axis points downwards into the soil. The soil surface is at \(z = 0\). A depth of 1 m therefore corresponds to \(z = 1.0\) (positive depth values).
- Lengths in metres, wire radii in metres.
Notes
For TN distribution networks, RodElectrode (driven rod),
RingElectrode (foundation / ring earth electrode) and
MeshElectrode (mesh / foundation earth electrode) are the most
relevant primitives.
concrete_shell_coefficient ¶
Per-length coefficient of a cylindrical concrete shell (ADR-0012).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rho_c
|
float
|
Resistivity of the concrete in Ω·m, |
required |
wire_radius
|
float
|
Radius \(r_a\) of the bare wire in m, |
required |
thickness
|
float
|
Radial thickness \(t\) of the shell in m, |
required |
Returns:
| Type | Description |
|---|---|
float
|
\(C\) in Ω·m; |
Raises:
| Type | Description |
|---|---|
ValueError
|
If an argument is negative or not finite, or |
Notes
The electrode then carries wire_radius = r_a + t and
concrete_shell_coefficient_ohm_m = C. For rho_c = 100 Ω·m and
5 cm of concrete around a 5 mm wire, \(C\) = 38.16 Ω·m.
Source code in src/groundfield/geometry/electrodes.py
shell_resistance_from_coefficient ¶
shell_resistance_from_coefficient(electrode: '_ElectrodeBase', coefficient_ohm_m: float | None = None) -> float
Lumped shell resistance of electrode for a per-length coefficient.
Inverse of shell_coefficient_from_resistance():
\(R = C / L\) in Ω with the total wire length \(L\) in m.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
electrode
|
'_ElectrodeBase'
|
Encased electrode. |
required |
coefficient_ohm_m
|
float | None
|
Coefficient \(C\) in Ω·m; |
None
|
Returns:
| Type | Description |
|---|---|
float
|
\(R\) in Ω. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the coefficient is negative or not finite. |
Source code in src/groundfield/geometry/electrodes.py
shell_coefficient_from_resistance ¶
Coefficient that gives electrode a lumped shell resistance.
The lumped shell model (ADR-0012 V1) describes the shell of one
electrode by its total radial resistance \(R\) in series with the
soil. Spread uniformly over the electrode's wire, it becomes the
per-length coefficient \(C = R\,L\) with the total wire length
\(L\) (total_length()); the image family then
adds exactly \(R\) per ampere to the electrode potential. Use it
when a shell is known as a lumped resistance (a measured value, or
the World.concrete_shell_corrections entry of a 0.15.0 world);
the generators compute \(C\) from the concrete resistivity with
concrete_shell_coefficient() and put it on every wire of an
encased foundation, cross-braces included.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
electrode
|
'_ElectrodeBase'
|
Encased electrode (all of its wire is encased). |
required |
resistance_ohm
|
float
|
Lumped shell resistance \(R\) in Ω, |
required |
Returns:
| Type | Description |
|---|---|
float
|
\(C\) in Ω·m, for |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |