Skip to content

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

\[ \Gamma_i = \{\mathbf{x}_i^{(0)} + \xi\,(\mathbf{x}_i^{(1)} - \mathbf{x}_i^{(0)}) : \xi \in [0, 1]\}, \qquad i = 1 \ldots N, \]

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

\[ C = \frac{\rho_c}{2\pi}\,\ln\frac{a + t}{a} \quad [\Omega\,\mathrm{m}], \]

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 (x, y, z) in metres (min-x, min-y, depth).

size tuple[PositiveLength, PositiveLength]

Extent (dx, dy) of the rectangle in metres.

n_x int

Number of meshes along \(x\) (must be ≥ 1). The number of longitudinal wires is n_y + 1.

n_y int

Number of meshes along \(y\) (must be ≥ 1). The number of transverse wires is n_x + 1.

concrete_shell_coefficient_ohm_m float

Per-length concrete-shell coefficient in Ω·m (ADR-0012, default 0: no shell); see concrete_shell_coefficient().

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

connection_point: Point3D

Centre of the grid rectangle in m, where conductors attach.

min_feature_length

min_feature_length() -> float

Smaller mesh span in m.

Source code in src/groundfield/geometry/electrodes.py
def min_feature_length(self) -> float:
    """Smaller mesh span in m."""
    return float(min(self.size[0] / self.n_x, self.size[1] / self.n_y))

segments

segments(ds: float, layer_interfaces: Sequence[float] | None = None) -> WireSegments

Grid of n_y + 1 by n_x + 1 wires (see base class).

Source code in src/groundfield/geometry/electrodes.py
def segments(
    self, ds: float, layer_interfaces: Sequence[float] | None = None
) -> WireSegments:
    """Grid of ``n_y + 1`` by ``n_x + 1`` wires (see base class)."""
    cx, cy, cz = self.corner
    dx, dy = self.size
    return _grid_wires(
        cx=cx,
        cy=cy,
        cz=cz,
        dx=dx,
        dy=dy,
        nx_wires=self.n_y + 1,
        ny_wires=self.n_x + 1,
        ds=ds,
    )

total_length

total_length() -> float

Length of all wires in m.

Source code in src/groundfield/geometry/electrodes.py
def total_length(self) -> float:
    """Length of all wires in m."""
    dx, dy = self.size
    return float((self.n_y + 1) * dx + (self.n_x + 1) * dy)

wire_polylines

wire_polylines(n_arc: int = 64) -> list[np.ndarray]

Every wire of the grid (see base class).

Source code in src/groundfield/geometry/electrodes.py
def wire_polylines(self, n_arc: int = 64) -> list[np.ndarray]:
    """Every wire of the grid (see base class)."""
    cx, cy, cz = self.corner
    dx, dy = self.size
    return _grid_wire_polylines(
        cx=cx,
        cy=cy,
        cz=cz,
        dx=dx,
        dy=dy,
        nx_wires=self.n_y + 1,
        ny_wires=self.n_x + 1,
    )

Junction

Bases: BaseModel

Named leakage-free network node.

Attributes:

Name Type Description
name str

Unique node name within the World (shared namespace with the electrodes).

kind Literal['junction']

Always "junction".

position Point3D

Location (x, y, z) in m, z positive downwards. Above the surface (z < 0) is allowed: a junction has no soil contact. Conductors ending on the junction use it as their end point.

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

connection_point: Point3D

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 (x, y, z) in metres (min-x, min-y, depth).

size tuple[PositiveLength, PositiveLength]

Extent (dx, dy) of the mesh in metres.

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 concrete_shell_coefficient().

connection_point property

connection_point: Point3D

Centre of the mesh rectangle in m, where conductors attach.

min_feature_length

min_feature_length() -> float

Smallest of the two extents and the spacing, in m.

Source code in src/groundfield/geometry/electrodes.py
def min_feature_length(self) -> float:
    """Smallest of the two extents and the spacing, in m."""
    return float(min(self.size[0], self.size[1], self.spacing))

segments

segments(ds: float, layer_interfaces: Sequence[float] | None = None) -> WireSegments

Grid of wires at spacing (see base class).

Source code in src/groundfield/geometry/electrodes.py
def segments(
    self, ds: float, layer_interfaces: Sequence[float] | None = None
) -> WireSegments:
    """Grid of wires at ``spacing`` (see base class)."""
    cx, cy, cz = self.corner
    dx, dy = self.size
    nx, ny = self._wire_counts()
    return _grid_wires(
        cx=cx, cy=cy, cz=cz, dx=dx, dy=dy, nx_wires=ny, ny_wires=nx, ds=ds
    )

total_length

total_length() -> float

Length of all wires in m.

Source code in src/groundfield/geometry/electrodes.py
def total_length(self) -> float:
    """Length of all wires in m."""
    dx, dy = self.size
    nx, ny = self._wire_counts()
    return float(ny * dx + nx * dy)

wire_polylines

wire_polylines(n_arc: int = 64) -> list[np.ndarray]

Every wire of the mesh (see base class).

Source code in src/groundfield/geometry/electrodes.py
def wire_polylines(self, n_arc: int = 64) -> list[np.ndarray]:
    """Every wire of the mesh (see base class)."""
    cx, cy, cz = self.corner
    dx, dy = self.size
    nx, ny = self._wire_counts()
    return _grid_wire_polylines(
        cx=cx, cy=cy, cz=cz, dx=dx, dy=dy, nx_wires=ny, ny_wires=nx
    )

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 (x, y, z) in metres, at least two. For closed = True do not repeat the first vertex at the end — the closing edge is implicit.

closed bool

Whether the polyline is closed into a ring (default True).

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

connection_point: Point3D

First vertex of the polyline in m, where conductors attach.

edges property

edges: list[tuple[Point3D, Point3D]]

Straight wires making up the polyline (closing edge included).

length property

length: float

Total wire length in metres (sum over all edges).

min_feature_length

min_feature_length() -> float

Shortest edge in m.

Source code in src/groundfield/geometry/electrodes.py
def min_feature_length(self) -> float:
    """Shortest edge in m."""
    return float(
        min(
            ((ex - sx) ** 2 + (ey - sy) ** 2) ** 0.5
            for (sx, sy, _), (ex, ey, _) in self.edges
        )
    )

segments

segments(ds: float, layer_interfaces: Sequence[float] | None = None) -> WireSegments

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
def segments(
    self, ds: float, layer_interfaces: Sequence[float] | None = None
) -> WireSegments:
    """One strip-style chain per edge (see base class).

    Every edge is discretised exactly like a :class:`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
    (:attr:`~groundfield.geometry.primitives.WireSegments.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.
    """
    return _edge_wires(
        self.edges, ds, skip_degenerate=True, edge_wires=self._edge_wire_index()
    )

total_length

total_length() -> float

Sum of the edge lengths in m.

Source code in src/groundfield/geometry/electrodes.py
def total_length(self) -> float:
    """Sum of the edge lengths in m."""
    return float(self.length)

wire_polylines

wire_polylines(n_arc: int = 64) -> list[np.ndarray]

The vertex chain, closed if closed (see base class).

Source code in src/groundfield/geometry/electrodes.py
def wire_polylines(self, n_arc: int = 64) -> list[np.ndarray]:
    """The vertex chain, closed if ``closed`` (see base class)."""
    pts = [list(v) for v in self.vertices]
    if self.closed and len(pts) > 2:
        pts.append(list(self.vertices[0]))
    return [np.array(pts, dtype=float)]

RingElectrode

Bases: _ElectrodeBase

Horizontal ring electrode (foundation / ring earth electrode).

Attributes:

Name Type Description
center Point3D

Ring centre (x, y, z) in metres. Typically buried 0.5 to 1.0 m below the surface.

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 concrete_shell_coefficient().

connection_point property

connection_point: Point3D

Point of the ring on the +x side of the centre in m, for conductors.

bounds

bounds() -> tuple[np.ndarray, np.ndarray]

Exact bounding box of the circle (see base class).

Source code in src/groundfield/geometry/electrodes.py
def bounds(self) -> tuple[np.ndarray, np.ndarray]:
    """Exact bounding box of the circle (see base class)."""
    cx, cy, cz = self.center
    r = self.radius
    return np.array([cx - r, cy - r, cz]), np.array([cx + r, cy + r, cz])

min_feature_length

min_feature_length() -> float

Circumference 2πr in m.

Source code in src/groundfield/geometry/electrodes.py
def min_feature_length(self) -> float:
    """Circumference ``2πr`` in m."""
    return float(2.0 * math.pi * self.radius)

segments

segments(ds: float, layer_interfaces: Sequence[float] | None = None) -> WireSegments

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
def segments(
    self, ds: float, layer_interfaces: Sequence[float] | None = None
) -> WireSegments:
    """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.
    """
    perimeter = 2.0 * np.pi * self.radius
    n = _segment_count(perimeter, ds, minimum=8)
    seg_len = perimeter / n
    cx, cy, cz = self.center
    mids = np.empty((n, 3))
    dirs = np.empty((n, 3))
    for k in range(n):
        # Scalar trigonometry, kept from the historic discretiser so
        # the midpoints stay bit-identical across platforms.
        phi = 2.0 * np.pi * (k + 0.5) / n
        mids[k] = (
            cx + self.radius * np.cos(phi),
            cy + self.radius * np.sin(phi),
            cz,
        )
        dirs[k] = (-np.sin(phi), np.cos(phi), 0.0)
    return WireSegments(mids, np.full(n, seg_len), dirs)

total_length

total_length() -> float

Circumference 2πr in m.

Source code in src/groundfield/geometry/electrodes.py
def total_length(self) -> float:
    """Circumference ``2πr`` in m."""
    return float(2.0 * math.pi * self.radius)

wire_polylines

wire_polylines(n_arc: int = 64) -> list[np.ndarray]

Closed circle sampled at n_arc points (see base class).

Source code in src/groundfield/geometry/electrodes.py
def wire_polylines(self, n_arc: int = 64) -> list[np.ndarray]:
    """Closed circle sampled at ``n_arc`` points (see base class)."""
    cx, cy, cz = self.center
    theta = np.linspace(0.0, 2.0 * np.pi, n_arc)
    return [
        np.column_stack(
            [
                cx + self.radius * np.cos(theta),
                cy + self.radius * np.sin(theta),
                np.full_like(theta, cz),
            ]
        )
    ]

RodElectrode

Bases: _ElectrodeBase

Vertical driven rod (Tiefenerder).

Attributes:

Name Type Description
position Point3D

Position of the head (top end) as (x, y, z) in metres. Typically the head sits just below the soil surface, e.g. z = 0.5.

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 concrete_shell_coefficient().

connection_point property

connection_point: Point3D

Top end of the rod (position) in m, where conductors attach.

min_feature_length

min_feature_length() -> float

Rod length in m.

Source code in src/groundfield/geometry/electrodes.py
def min_feature_length(self) -> float:
    """Rod length in m."""
    return float(self.length)

segments

segments(ds: float, layer_interfaces: Sequence[float] | None = None) -> WireSegments

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
def segments(
    self, ds: float, layer_interfaces: Sequence[float] | None = None
) -> WireSegments:
    """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).
    """
    x0, y0, z0 = self.position
    head = np.array([x0, y0, 0.0])
    tangent = np.array([0.0, 0.0, 1.0])
    intervals = _split_interval_at_interfaces(
        z0, z0 + self.length, layer_interfaces
    )
    parts = []
    for z_lo, z_hi in intervals:
        part_len = z_hi - z_lo
        n = _segment_count(part_len, ds)
        parts.append(_straight_wire(head, tangent, z_lo, part_len / n, n))
    return WireSegments.concatenate(parts)

total_length

total_length() -> float

Rod length in m.

Source code in src/groundfield/geometry/electrodes.py
def total_length(self) -> float:
    """Rod length in m."""
    return float(self.length)

wire_polylines

wire_polylines(n_arc: int = 64) -> list[np.ndarray]

Head and foot of the rod (see base class).

Source code in src/groundfield/geometry/electrodes.py
def wire_polylines(self, n_arc: int = 64) -> list[np.ndarray]:
    """Head and foot of the rod (see base class)."""
    x, y, z = self.position
    return [np.array([[x, y, z], [x, y, z + self.length]], dtype=float)]

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 (x, y, z) in metres. Every arm shares this point and stays at z = center[2] — the wire is horizontal.

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 +x axis in degrees; the remaining arms follow at multiples of \(360^\circ / n\).

concrete_shell_coefficient_ohm_m float

Optional per-segment radial concrete-shell coefficient, same semantics as on StripElectrode (ADR-0012 V2).

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.

arm_tips property

arm_tips: list[Point3D]

Outer endpoint (x, y, z) of each arm.

connection_point property

connection_point: Point3D

Centre of the star (center) in m, where conductors attach.

edges property

edges: list[tuple[Point3D, Point3D]]

Straight wires making up the star (centre → each tip).

length property

length: float

Total wire length in metres (n_arms * arm_length).

min_feature_length

min_feature_length() -> float

Arm length in m.

Source code in src/groundfield/geometry/electrodes.py
def min_feature_length(self) -> float:
    """Arm length in m."""
    return float(self.arm_length)

segments

segments(ds: float, layer_interfaces: Sequence[float] | None = None) -> WireSegments

One strip-style chain per arm, centre to tip (see base class).

Source code in src/groundfield/geometry/electrodes.py
def segments(
    self, ds: float, layer_interfaces: Sequence[float] | None = None
) -> WireSegments:
    """One strip-style chain per arm, centre to tip (see base class)."""
    return _edge_wires(self.edges, ds, skip_degenerate=False)

total_length

total_length() -> float

n_arms * arm_length in m.

Source code in src/groundfield/geometry/electrodes.py
def total_length(self) -> float:
    """``n_arms * arm_length`` in m."""
    return float(self.length)

wire_polylines

wire_polylines(n_arc: int = 64) -> list[np.ndarray]

One straight wire per arm (see base class).

Source code in src/groundfield/geometry/electrodes.py
def wire_polylines(self, n_arc: int = 64) -> list[np.ndarray]:
    """One straight wire per arm (see base class)."""
    return [np.array([list(a), list(b)], dtype=float) for a, b in self.edges]

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 (x, y, z) in metres.

end Point3D

Strip end (x, y, z) in metres. Must have the same \(z\) as start.

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

connection_point: Point3D

Start point of the strip (start) in m, where conductors attach.

length property

length: float

Euclidean strip length in metres.

min_feature_length

min_feature_length() -> float

Strip length in m.

Source code in src/groundfield/geometry/electrodes.py
def min_feature_length(self) -> float:
    """Strip length in m."""
    return float(self.length)

segments

segments(ds: float, layer_interfaces: Sequence[float] | None = None) -> WireSegments

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
def segments(
    self, ds: float, layer_interfaces: Sequence[float] | None = None
) -> WireSegments:
    """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.
    """
    L = self.length
    p0 = np.array(self.start, dtype=float)
    p1 = np.array(self.end, dtype=float)
    direction = (p1 - p0) / L
    # Map interface depths to axis parameters t in [0, L].
    t_cuts: list[float] = []
    dz = p1[2] - p0[2]
    if layer_interfaces and abs(dz) > 1e-12:
        for h in layer_interfaces:
            t_cuts.append((h - p0[2]) / dz * L)
    intervals = _split_interval_at_interfaces(0.0, L, t_cuts)
    # The length comes from the end points: allow their round-off.
    scale = _coordinate_scale(p0, p1)
    parts = []
    for t_lo, t_hi in intervals:
        part_len = t_hi - t_lo
        n = _segment_count(part_len, ds, scale=scale)
        parts.append(_straight_wire(p0, direction, t_lo, part_len / n, n))
    return WireSegments.concatenate(parts)

total_length

total_length() -> float

Strip length in m.

Source code in src/groundfield/geometry/electrodes.py
def total_length(self) -> float:
    """Strip length in m."""
    return float(self.length)

wire_polylines

wire_polylines(n_arc: int = 64) -> list[np.ndarray]

Start and end point (see base class).

Source code in src/groundfield/geometry/electrodes.py
def wire_polylines(self, n_arc: int = 64) -> list[np.ndarray]:
    """Start and end point (see base class)."""
    return [np.array([list(self.start), list(self.end)], dtype=float)]

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 (x, y, z) in m, shape (N, 3). The solvers place the point source (point kernel) or the centre of the line source (line kernel) here.

lengths ndarray

Segment lengths in m, shape (N,). For a ring this is the arc length represented by the segment.

directions ndarray

Unit tangents of the segment axes, shape (N, 3).

wires ndarray | None

Index of the straight wire every segment lies on, shape (N,) (integers from 0), or None for one wire (all segments on wire 0). A grid numbers its full wire lines (longitudinal ones first), a star its arms, a polyline its straight runs (consecutive edges that continue in the same direction are one wire); a rod, a strip and a ring are one wire. The image family gives every wire of an electrode its own uniform current (user decision Q30 of 2026.11), see wire_index.

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.

ends property

ends: ndarray

Segment end points in m, shape (N, 3).

n_wires property

n_wires: int

Number of distinct straight wires (0 without segments).

starts property

starts: ndarray

Segment start points in m, shape (N, 3).

total_length property

total_length: float

Sum of the segment lengths in m.

wire_index property

wire_index: ndarray

Wire index per segment, shape (N,) (zeros for one wire).

concatenate classmethod

concatenate(parts: Iterable[WireSegments]) -> WireSegments

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
@classmethod
def concatenate(cls, parts: Iterable[WireSegments]) -> WireSegments:
    """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 (:func:`_edge_wires`).
    """
    parts = [p for p in parts if len(p)]
    if not parts:
        return cls.empty()
    wires = None
    if any(p.wires is not None for p in parts):
        wires = np.concatenate([p.wire_index for p in parts])
    return cls(
        np.concatenate([p.midpoints for p in parts], axis=0),
        np.concatenate([p.lengths for p in parts]),
        np.concatenate([p.directions for p in parts], axis=0),
        wires,
    )

empty classmethod

empty() -> WireSegments

Container without segments.

Source code in src/groundfield/geometry/primitives.py
@classmethod
def empty(cls) -> WireSegments:
    """Container without segments."""
    return cls(np.zeros((0, 3)), np.zeros(0), np.zeros((0, 3)))

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

concrete_shell_coefficient(rho_c: float, wire_radius: float, thickness: float) -> float

Per-length coefficient of a cylindrical concrete shell (ADR-0012).

\[ C = \frac{\rho_c}{2\pi}\,\ln\frac{r_a + t}{r_a} \]

Parameters:

Name Type Description Default
rho_c float

Resistivity of the concrete in Ω·m, >= 0.

required
wire_radius float

Radius \(r_a\) of the bare wire in m, > 0.

required
thickness float

Radial thickness \(t\) of the shell in m, >= 0.

required

Returns:

Type Description
float

\(C\) in Ω·m; 0.0 for rho_c = 0 or thickness = 0.

Raises:

Type Description
ValueError

If an argument is negative or not finite, or wire_radius is not positive.

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
def concrete_shell_coefficient(
    rho_c: float, wire_radius: float, thickness: float
) -> float:
    r"""Per-length coefficient of a cylindrical concrete shell (ADR-0012).

    .. math::

        C = \frac{\rho_c}{2\pi}\,\ln\frac{r_a + t}{r_a}

    Parameters
    ----------
    rho_c
        Resistivity of the concrete in Ω·m, ``>= 0``.
    wire_radius
        Radius :math:`r_a` of the bare wire in m, ``> 0``.
    thickness
        Radial thickness :math:`t` of the shell in m, ``>= 0``.

    Returns
    -------
    float
        :math:`C` in Ω·m; ``0.0`` for ``rho_c = 0`` or ``thickness = 0``.

    Raises
    ------
    ValueError
        If an argument is negative or not finite, or ``wire_radius`` is
        not positive.

    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, :math:`C` = 38.16 Ω·m.
    """
    values = {"rho_c": rho_c, "wire_radius": wire_radius, "thickness": thickness}
    for name, value in values.items():
        if not math.isfinite(float(value)) or float(value) < 0.0:
            raise ValueError(f"{name} must be finite and non-negative, got {value!r}.")
    if float(wire_radius) <= 0.0:
        raise ValueError(f"wire_radius must be positive (m), got {wire_radius!r}.")
    r_a = float(wire_radius)
    return float(rho_c) / (2.0 * math.pi) * math.log((r_a + float(thickness)) / r_a)

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 (default) takes the electrode's own concrete_shell_coefficient_ohm_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
def 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 :func:`shell_coefficient_from_resistance`:
    :math:`R = C / L` in Ω with the total wire length :math:`L` in m.

    Parameters
    ----------
    electrode
        Encased electrode.
    coefficient_ohm_m
        Coefficient :math:`C` in Ω·m; ``None`` (default) takes the
        electrode's own ``concrete_shell_coefficient_ohm_m``.

    Returns
    -------
    float
        :math:`R` in Ω.

    Raises
    ------
    ValueError
        If the coefficient is negative or not finite.
    """
    coefficient = float(
        electrode.concrete_shell_coefficient_ohm_m
        if coefficient_ohm_m is None
        else coefficient_ohm_m
    )
    if not math.isfinite(coefficient) or coefficient < 0.0:
        raise ValueError(
            f"coefficient_ohm_m must be finite and non-negative, got {coefficient!r}."
        )
    return coefficient / electrode.total_length()

shell_coefficient_from_resistance

shell_coefficient_from_resistance(electrode: '_ElectrodeBase', resistance_ohm: float) -> float

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 Ω, >= 0.

required

Returns:

Type Description
float

\(C\) in Ω·m, for concrete_shell_coefficient_ohm_m.

Raises:

Type Description
ValueError

If resistance_ohm is negative or not finite.

Source code in src/groundfield/geometry/electrodes.py
def shell_coefficient_from_resistance(
    electrode: "_ElectrodeBase", resistance_ohm: float
) -> float:
    r"""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 :math:`R` in series with the
    soil. Spread uniformly over the electrode's wire, it becomes the
    per-length coefficient :math:`C = R\,L` with the total wire length
    :math:`L` (:meth:`~_ElectrodeBase.total_length`); the image family then
    adds exactly :math:`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 :math:`C` from the concrete resistivity with
    :func:`concrete_shell_coefficient` and put it on every wire of an
    encased foundation, cross-braces included.

    Parameters
    ----------
    electrode
        Encased electrode (all of its wire is encased).
    resistance_ohm
        Lumped shell resistance :math:`R` in Ω, ``>= 0``.

    Returns
    -------
    float
        :math:`C` in Ω·m, for ``concrete_shell_coefficient_ohm_m``.

    Raises
    ------
    ValueError
        If ``resistance_ohm`` is negative or not finite.
    """
    resistance = float(resistance_ohm)
    if not math.isfinite(resistance) or resistance < 0.0:
        raise ValueError(
            f"resistance_ohm must be finite and non-negative, got {resistance_ohm!r}."
        )
    return resistance * electrode.total_length()