Generators¶
The generators package builds complete worlds of TN low-voltage
networks (Ortsnetze): a substation earth, the foundation earths of the
buildings, cable distribution cabinets, the PEN network that joins them
and, optionally, a fall-of-potential measurement set-up. It contains no
physics of its own; it decides geometry and topology and hands a
World to the solver. Design and validation programme: ADR-0009.
Two front-ends share one data model:
TnNetworkGenerator(config, seed=...)draws a network from population parameters (TnNetworkConfig: building counts and types, soil, placement, PEN topology), every numeric field a fixed value or aDistribution;LvNetworkLayoutcomposes one deterministic network step by step, as an engineer draws it: real building footprints (OSM), a hand-placed substation and cabinets, PEN cables routed on a Manhattan grid around the buildings, and the measurement loop.
Both produce a pure-data NetworkPlan; one materialiser,
materialise_plan(plan), turns every plan into a World, so both
front-ends build foundations, concrete shells, PEN junctions and
measurement leads in the same way.
Mathematical and physical context¶
The generated world is solved like any other: Laplace's equation in the layered soil with the electrodes as equipotential clusters and the PEN network as branches. What the generator controls is the parameter space of the study (AP1):
| Axis | Config field |
|---|---|
| building mix (single-family houses, small and medium commercial) | building_counts, building_types |
| grounding system per building type (foundation, ring, rods, strips) | BuildingTypeSpec.grounding (GroundingSystemSpec of ElectrodeSpec) |
| penetration of foundation earths | FoundationElectrodeSpec.presence_prob |
| concrete encasement (moisture) | FoundationElectrodeSpec.concrete_rho_ohm_m, concrete_thickness_m |
| substation earth | substation |
| cable distribution cabinets | cabinets |
| PEN topology and cable data | pen_topology, pen |
| soil \(\rho_1\), \(\rho_2\), \(h_1\) | soil (HomogeneousSoilSpec, TwoLayerSoilSpec, MultiLayerSoilSpec) |
Reproducibility. All random draws come from one generator seeded by
seed (or rng= of build, plan and sample_world), in a canonical
order: the same configuration and seed give the same world, independent
of the order in which mapping keys were written. sample_world(rng=...)
also returns the resolved configuration (every distribution replaced by
its drawn value); it replays the world exactly when no per-site draws
remain (presence probabilities 0 or 1, no placement jitter), otherwise
keep the seed or the plan / world JSON. Successive build() or plan()
calls on one generator draw successive realisations from its stream;
build() right after plan() (no rng= in either, nothing drawn from
generator.rng since, the same configuration) gives the world of that plan
— up to audit W3R2B it drew a second realisation, another world with
placement jitter. The foundation penetration mask
of the layout builder is a stable hash of the building ids and is nested
in the penetration rate (a house equipped at 10 % is also equipped at
20 %).
Foundations and PEN cables. A mesh foundation (style="mesh") is
one wire electrode per mesh line at every orientation (<name>,
<name>_w<j>, bonded into one cluster), bare or encased; an encased
foundation (concrete_rho_ohm_m) carries the concrete shell on every
wire, its cross-braces included (DIN 18014, see
concrete shells).
The image
family solves one uniform current per straight wire (since user decision
Q30 also inside a grid, so a mesh electrode built by hand and the
generated foundation of bonded wires are the same model). Against the
per-segment mom solution (100 Ω·m, 1 m segments; mom uses the point
kernel), one current per wire is +1.1 % with the default line kernel
and +0.3 … +0.5 % with kernel="point" for 10 m 2 × 2 to 30 m 4 × 4
meshes; one current for the whole mesh was +2.4 … +3.7 % (point kernel
+1.5 … +3.1 %) and depended on the orientation.
A rectangle without cross-braces (style="ring", or "mesh" with
n_x = n_y = 1) is one strip per side at every orientation (user
decision Q38); up to that decision an axis-aligned one was one
grid_mesh electrode connected at its centre, and per side its input
impedance is lower by less than 1 % up to aspect ratio 4 and 2 % up to 50
for a short side of at least 1 m over the soils of the AP1 grid, equal for
a square (scope and numbers on the
concrete-shell page).
electrode_currents[<name>] and grounding_impedance(<name>) therefore
refer to the first wire (the local −y side, whose start, a corner of the
rectangle, is the connection point of conductors attached to <name> by
name); use cluster_impedance or the sum over the wires for the
foundation. A rectangle at a multiple of 90° is rotated exactly (no
round-off), so the local −y side stays the first wire. A polygon outline
is one closed polyline with one owner per straight side (one current per
straight wire, user decisions Q30, Q44). The deprecated concrete_model has
no effect (drop the argument, see Deprecations); an
outline narrower than MIN_FOUNDATION_SIDE_M (1 m) is widened to it, with
a warning, for both foundation_outline="ombr" and "polygon".
Cable cabinets per building group (user decisions Q22 and Q35). In
the star topology TnNetworkGenerator places one cable cabinet per
building group, at the far end of the houses it feeds
(CabinetConfig.placement=None, the default): the buildings are ordered
by their bearing around the substation, counter-clockwise from the widest
angular gap between two neighbouring bearings, and cut into as many runs
of consecutive bearings as there are cabinets (count_per_100_buildings
or fixed_count), of sizes that differ by at most one
(StarCabinetTopology.group_buildings); the cabinet of a group stands on
the ray from the substation through the group's centroid,
CabinetConfig.end_clearance_m (1 m, positive) beyond the largest
projection on that ray of the group's earth electrodes (horizontal wires
and rods) plus the plan extent of the cabinet's own grounding — when it
stands there within CabinetConfig.max_far_end_gap_m (20 m, positive,
larger than end_clearance_m) of the nearest electrode of its group: a
cabinet stands next to the houses it feeds. A wider group, whose centroid
ray leads past its houses, has its cabinet on the ray through its far-end
building (the largest projection of its position on the direction of the
centroid, ties to the one nearest to that direction), end_clearance_m
beyond that building's electrodes. The cabinet feeds its group (audits
W1B-01, W1B-02). 10 houses and one small commercial building had their
cabinet 50.4 m from the nearest building on the centroid ray (drops
527.4 m), now 1.56 m (311.8 m) on the far-end ray; with the far-end ray for
every group, six houses of the 50-house grid were fed straight from the
substation (up to 116.8 m). The plan records per cabinet which rule placed
it, PlannedSite.cabinet_rule ("centroid_ray" / "far_end_ray"), and its
distance from the group on the centroid ray, PlannedSite.centroid_ray_gap_m
(None for every other site and for cabinets of a given placement or of
the radial topology; materialising ignores both).
The threshold is a step, kept for 2026.11 (user decision D7, audit W1R2-02). Groups lie on both sides of it: on the centroid ray the groups of the default 50-house grid stand 8.8 … 12.8 m from their houses, those of the 100-house grid 10.05 … 23.01 m (its two groups beyond 20 m are on the far-end ray; 15 / 25 m put four / none there), and over the 80 AP1 mixes the 118 groups beyond it stand 20.21 … 53.56 m from their houses and the largest gap kept is 18.84 m (19 mixes have a group between 15 and 25 m). A group whose distance crosses the threshold moves its cabinet by up to the width of the group, and the results jump:
| layout change (homogeneous 100 Ω·m) | cabinet moves | drops | R at 50 Hz | X at 1 kHz, inductive PEN (carson_series / sommerfeld) |
|---|---|---|---|---|
| 50-house grid, house columns 32.0 → 32.2 m apart (one group 19.99 → 20.22 m) | 141.8 m | 1 788.9 → 1 443.0 m | −0.36 % (−0.14 % beyond the smooth trend) | −21.6 / −18.9 % |
| 100-house grid, columns across 22.95 m (two groups cross 20 m) | 65.6 m each | +15.8 % | −0.03 % | +1.5 / −3.1 % |
80 houses + 5 medium commercial (AP1), one group at 20.21 m: max_far_end_gap_m 20 → 20.5 m |
31.4 m | 1 960.6 → 1 968.2 m | −0.02 % | +1.5 / +1.1 % |
The 100-house row is the difference of straight lines through three
spacings on each side of the crossing, at the crossing; R at 50 Hz with the
image backend (2 m and 1 m segments agree), Z at 1 kHz with the isolated
Neumann PEN in 5 m pieces. A study that varies the layout can read where a
group crosses from the plan. A cabinet whose
electrodes would come closer than end_clearance_m to those of another
site — a building of its own or of another group, the substation, another
cabinet — raises a ValueError that names both (3 of 100 random layouts of
200 houses 12 m apart; none of the default grids and AP1 mixes). In the default grid of 30 houses (three
rows of ten, 25 m × 30 m, the substation in the middle row) the groups
are the western and the eastern half, with their cabinets at
(−118.5, 0) m and (118.5, 0) m; each main runs along the middle row,
whose houses are joined to it, and the 20 houses of the outer rows tap it
with drops of 25 m (before: both cabinets west of the substation, at
(−180, 0) m and (−140, 0) m on a strip along the substation row, and 25
drops of 1 140 m, the 15 eastern ones from the substation, 3.5 … 106.5 m).
A single group around the substation (one cabinet for a row through it)
gets its cabinet beyond its farthest house, ties to the first in bearing
order. A given CabinetConfig.placement keeps the former rule — the
given positions, every building fed by its nearest cabinet (Manhattan
metric) — and a configuration stored before the decision carries the
former strip and keeps its cabinets. In RadialTrunkTopology a building
in a substation slot that no trunk crosses taps its feeder's trunk at the
closest pair, like the buildings of the cabinets, instead of getting its
own line from the substation (default 30 houses: drops 1 115 → 778 m,
14 → 4 from the substation, those of the two feeders without a trunk).
In TnNetworkGenerator every cable cabinet has its own PEN cable, as
the topology documents: from the substation (StarCabinetTopology), or
one cable per trunk segment (RadialTrunkTopology). A service drop taps
the cable path that feeds its own building — the cable of its cabinet,
or the trunk from the substation to its tap source, for a building in a
substation slot its feeder's whole trunk — at the point nearest to the
building: a leakage-free tap junction
pen_tap_<k> that splits the cable into sections <cable>_s<k>, or the
substation or cabinet at the end of the cable; a building in a
substation slot of a feeder without a trunk is connected to the
substation. The
router guarantees that a drop never starts on another building's drop,
never runs along a cable (the one it taps, a trunk, another cabinet's
main) farther than one minimum section, and that no cable section is
shorter than that minimum section, 1 cm (a tap closer to a node is that
node; longer for PEN radii above 7.3 mm, so that every section stays a
finite resistance). "Along" means both ends of a cable section within
1 cm of the drop's line; the one overlap left is that 1 cm, where a
foundation touches the end node of its cable from beyond and is tapped
1 cm before the node. Drops that leave one tap in one direction — the
drops of houses behind each other, such as the five drops of the 5-house
radial network from the substation ring along −x, or the five drops of the
10-house star from the substation — lie side by side at the touching
distance \(2r\) of the PEN (decision D9 of 2026.11), so that only neighbours
touch: sorted by length, shortest first (equal lengths in plan order), and
centred on their common axis, drop \(k\) of \(n\) at \((k - (n - 1)/2)\,2r\)
along the normal \((-d_y, d_x)/|d|\) of the drop direction \(d\). The plan
records the offset as PlannedBranch.axis_offset_m; the materialiser
moves both ends of the conductor by it, and the drop stays attached to
its tap and its building (it starts up to \((n - 1)/2 \cdot 2r\) off the tap,
2 cm in a row of five). Two drops of one node are in a row when their start
points lie within \(2r\) of each other and the end of the shorter one within
\(2r\) of the line of the longer one — the overlap criterion — so the rows
hold under placement jitter (audit W3R2B-01): drops that are not exactly
parallel are shifted along one common normal (recorded as
PlannedBranch.axis_offset_normal_xy), each just far enough to lie at
least \(2r\) from every shorter one, and a drop that would come closer than
touching to a drop of a row — of the same tap, or of a tap 1 … 4 cm away
on the same trunk — joins the row. No generated network reports an overlap
(star and radial networks of 5 … 200 houses, jitter_m 0 … 0.1 m), and
the input impedance is continuous in the jitter: the reactance of the
10-house radial network at 1 kHz moves by −8.5e-10 at 1 nm and −4.5e-4 at
1 mm (carson_series; up to then +2.4 % at 1 nm, where the rows fell
apart). Before D9 such drops lay on one axis and the
inductance matrix read them as a bundle in which every pair touches,
which no cross-section of four or more equal wires realises;
gf.diagnose() reported every pair (audit W3B-05). With an inductive
PEN (5 m pieces, 100 Ω·m) the input reactance moves at 1 kHz by
−2.3 / −2.7 % (carson_series / sommerfeld) in the 5-house radial
network, −2.3 / −2.8 % with 10 houses, −1.1 / −1.3 % in the 10-house
star, and by at most 1.1e-6 (30 houses) and 5e-4 (80 and 200 houses,
both frequencies) in the radial networks; the star networks of 5, 30, 80 and
200 houses have no such drops and build the same world, those of 40, 60,
100, 120, 140 and 180 houses have (the 60-house star: X −1.0e-3 / −6.1e-4
at 50 Hz / 1 kHz under carson_series, −1.3e-3 / −8.1e-4 under
sommerfeld; the 40-house star, all 40 drops in rows, 3e-7), and plans
written before (no offsets) build the worlds they built. LvNetworkLayout
draws no rows. Conductors that overlap otherwise (in a hand-made plan)
are evaluated as touching wires. A drop may also pass over other buildings'
foundations, 0.2 m above their wires (PEN at 0.6 m, foundations at
0.8 m): the contact of a house lies at the corner of the side facing its
cable (the tie rule below), so a drop to a house behind others of its
grid column runs above their side wires. In the default grids of 10 to
200 houses that is 0 … 100 % of the drops (star, 30 houses: all 20
drops, each over 5 m above a side wire of the middle-row house it passes
on its way from the main, 100 m in all; star 50, 150 and 200: none; radial 150: 87 of
140 drops, 1 805 m, up to 40 m over 4 houses); drops are not routed
around foundations (user decision Q42). A drop has no inductive coupling
to these wires in the field model (an electrode carries no current along
itself), a bare one leaks next to them through the soil; moved 1 m aside
as a whole, those drops change the input impedance by at most 0.006 % with
an insulated PEN and by up to −0.40 % with a bare one (default grids of 30
and 150 houses, 50 Hz and 1 kHz; see the
known limitations). The layout
builder merges cable nodes closer than the same length.
Where conductors meet a site (user decisions Q41 and Q43). Every
conductor the generators route to a site with a horizontal earth
electrode ends at the point of that electrode nearest to it, in
TnNetworkGenerator and in the layout builder: at a foundation of every
form (rectangles at any orientation, building outlines) since user
decision Q41, at a circular ring (RingElectrodeSpec, e.g. the default
substation of both generators, a 4 m ring with four rods) and a strip
since user decision Q43. A site with horizontal electrodes and rods is met
at the nearest point of the horizontal ones, a site with several of them
(the large_industry ring, mesh and strips) at the nearest point of all;
rods (vertical) keep their head. A circle is met at its exact nearest
point (it is searched on an inscribed polygon with a sagitta of at most
1 mm and refined to the circle). The default mains now leave the
substation ring at its point nearest to their cabinets — the western ones
at (−4, 0) m instead of (4, 0) m, through the ring — and drops from the
substation at the point of the ring nearest to the house.
- a service drop is the shortest connection in plan between its feeding
cable and the horizontal wires of the building (their closest pair):
the tap on the cable and the end on the foundation, ring or strip, at
the PEN depth (layout builder: at the wire's depth), attached to the
wire that holds the point (
PlannedBranch.end_contact, aPlannedContact); - a cable leaving a substation or cabinet with horizontal electrodes starts at their point nearest to its next node;
- a building that a cable crosses is joined to it and fed by it: a cable of the building's feeding path that crosses or touches its foundation in plan is joined to the wire there, and the building gets no drop; every trunk of the radial topology counts as a cable of the feeding path for this rule (a building in a substation slot has no cable of its own), and in the star topology a building that a main crosses is fed by that main's cabinet (the nearest of the cabinets whose mains cross it, ties to the lower cabinet index) instead of its nearest one; a main that crosses a building it does not feed stays unjoined (no cross-tie between cabinets through a house); where the foundation touches the cable at a node (a cabinet on a wire) and the cable crosses it elsewhere, it is joined where it crosses (audit R5A-03), otherwise the joint lies 1 cm from the node (audits R4A-02, R4B-01);
- a drop whose closest pair lies at such a joint starts there, on the cable (audit R4A-01); a drop from a node that would run along a trunk or another main (both ends of a section within 1 cm of the drop's line, audit R5A-01) starts where it leaves it, at its node at the end of the shared stretch (audit R4B-01);
- the layout builder keeps its taps on the layout polyline, where the cable's junctions are. The leading run of waypoints inside the start site's closed electrodes (a rectangle, a building outline, a circle) and the trailing run inside the end site's are part of those sites (audit R6A-01 — a router corner inside a small cabinet ring was a node that houses tapped, 82 of 2 540 drops in 200 random layouts with a 2 m cabinet ring started inside it), and the segment that leaves (enters) the site is clipped at the projection of the site's point nearest to its far waypoint. Every other passage of the cable through the closed electrodes of the substation or a cabinet — another cabinet on its way, or its own start or end site when it comes back through it — is clipped the same way: the cable reaches the site where it enters and leaves it where it leaves, joined to it there, and the waypoints in between are part of it (audits W1B-03, W1B-04; up to then a cable to a far cabinet kept a tap inside a near cabinet's ring, and a leg that left its start site and came back through it, or overshot its cabinet, was merged into the site and lost its taps: 142.8 m instead of 30.0 m of drops in the audit's loop case). So no tap and no corner lies inside the foundation of the substation or a cabinet, also for a rotated, polygon or offset one; a tap at a clip point, or at the site's waypoint, is the site (audits R4A-03, R5A-02). A cable through a house foundation is not joined to it: the house keeps its own drop, of no length in plan where the cable crosses its foundation;
- ties go to the lowest wire index, then to the smallest arc position along the wire: a cable parallel to the side facing it meets the side at the start of the range of equal distance, for a side it passes along its whole length the corner where that wire starts.
Sites with rods only keep the connection point of their anchor (the head
of the first rod), and so does everything attached by name
(site_anchor_point, create_conductor(start=<foundation>)).
site_contact_wires(site) returns the wires the rule uses (named
site_foundation_wires before user decision Q43, foundations only).
materialise_plan rejects a PlannedContact that names no horizontal
wire (foundation, ring, strip) of the branch's site (a direct
materialise_branch call without foundation_wires checks only that it
names a strip, polyline or ring electrode; a NetworkPlan rejects another
site's electrode when it is validated) or lies farther from its wire — from
the exact circle of a ring — than one minimum cable section (1 cm; a joined
cable's point may lie that far off the wire it crosses; audit R4A-05).
LvNetworkLayout.plot(world=...) draws the drops as built (tap to
foundation contact) instead of the layout's centroid stubs.
Coordinates. Both generators build in local coordinates around the
origin. SubstationConfig.position moves the substation only: the
buildings, cabinets and the measurement stay around (0, 0), so a substation
placed at projected coordinates builds a world that mixes projected and
local coordinates (10 houses with the substation at the UTM origin: one PEN
cable of 33 118 km), which diagnose() reports and the solve warns about
with MixedCoordinatesWarning; RadialTrunkTopology then drops every
building and fails to build (audit W2R2-07). To place a network at
projected coordinates, build it around the origin and translate the whole
built world — every electrode, conductor and junction by the same offset;
groundfield has no public helper for that, and the solve does not need it,
since every result depends on coordinate differences only (the translated
network of 10 houses has the input impedance of the local one to twelve
digits).
Measurement set-up. A fall-of-potential measurement is a
two-terminal source between the earthing system and an auxiliary
electrode; the current and probe leads end on leakage-free junctions at
the instrument, and measured_impedance(result) returns the reading of
the simulated earth tester, probe voltage over source current. The leads
can be overhead or buried (overhead_lead, buried_lead); their
inductive coupling to the PEN network is part of the solve.
Example¶
import groundfield as gf
config = gf.TnNetworkConfig(
soil=gf.TwoLayerSoilSpec(rho_1=gf.Uniform(low=80.0, high=300.0), rho_2=100.0, h_1=5.0),
building_counts={"residential": 5},
)
world = gf.TnNetworkGenerator(config, seed=42).build()
again = gf.TnNetworkGenerator(config, seed=42).build()
assert gf.world_fingerprint(world) == gf.world_fingerprint(again) # same seed, same world
stats = gf.world_statistics(world)
# each house has a 2 × 2 mesh foundation, one wire electrode per mesh line
assert stats["n_electrodes_by_kind"]["polyline"] == 5 * 6
result = gf.create_engine(frequencies=[50.0]).solve(world)
assert 1.0 < result.input_impedance()[0].real < 5.0 # Ω, substation with the PEN network
Tutorial T06 builds a network synthetically and from OpenStreetMap data,
T07 adds the fall-of-potential measurement. The German names of releases
up to 0.15.0 (OrtsnetzLayout, kvs, KvsConfig, …) keep working with a
DeprecationWarning; see Deprecations and the
glossary.
API reference¶
generators ¶
World generators for reference networks.
This subpackage hosts the factory layer that turns high-level
parameter sets — for example "N single-family houses on a two-layer
soil" — into a fully populated groundfield.World that the
solver can consume.
The framework is organised in five composable spec layers:
distributions— Constant, Uniform, Normal, LogNormal, Weibull, Discrete, Categorical. Each numerical / categorical field of any spec class accepts a fixed value or aDistribution.electrode_specs— single-electrode specs (rod / ring / strip / foundation) withpresence_probandoffset_xy_m.grounding—GroundingSystemSpeccomposes a list ofElectrodeSpecinto one cluster.placement— Manhattan-grid and explicit-coordinate placement strategies.soil_specs— homogeneous / two-layer / multi-layer soil specs that resolve to thegroundfield.soil.modelstypes.building—BuildingTypeSpecbundles a name with a grounding system and an optional plot size.
Two front-ends compose these layers into a TN low-voltage network:
TnNetworkGenerator
(stochastic population parameters) and
LvNetworkLayout (real footprints
and routed PEN cables). Both produce a pure-data
NetworkPlan; one materialiser
(materialise_plan()) turns
every plan into a groundfield.World.
See docs/adr/0009-world-generators.md for the design rationale
and the validation programme.
AnyDistribution
module-attribute
¶
AnyDistribution = Annotated[Union[Constant, Uniform, Normal, LogNormal, Weibull, Discrete, Categorical], Field(discriminator='kind')]
Any concrete distribution, as a union discriminated by kind.
Used in the field annotations of
GeneratorConfig so that
Pydantic deserialises the right subclass from JSON by its kind
field: "constant", "uniform", "normal", "lognormal",
"weibull", "discrete" or "categorical".
ElectrodeSpec
module-attribute
¶
ElectrodeSpec = Annotated[Union[RodElectrodeSpec, RingElectrodeSpec, StripElectrodeSpec, FoundationElectrodeSpec], Field(discriminator='kind')]
JSON-serialisable union of electrode specs.
Use this alias as the field type in any GeneratorConfig
that holds a list of electrodes (e.g. electrodes:
list[ElectrodeSpec]). Pydantic dispatches on kind.
MEASUREMENT_H_TERMINAL
module-attribute
¶
Name of the instrument's current terminal (a junction).
Created when MeasurementInjectionConfig.feed_lead is set: the feed
lead runs from this junction to the auxiliary electrode and the current
source of the measurement returns its current here.
MEASUREMENT_S_TERMINAL
module-attribute
¶
Name of the instrument's voltage terminal (a junction).
Created when MeasurementProbeConfig.lead is set: the probe lead
runs from this junction to the voltage probe; the voltmeter reads the
potential difference between the earthing system and this junction.
PenTopology
module-attribute
¶
PenTopology = Annotated[Union[StarCabinetTopology, RadialTrunkTopology], Field(discriminator='kind')]
JSON-serialisable union of PEN topologies.
Add new topology classes here when a future Ortsnetz layout
(meshed-LV, ring, mixed) is implemented; the
TnNetworkGenerator
dispatches on kind.
PlacementSpec
module-attribute
¶
PlacementSpec = Annotated[Union[ManhattanGridPlacement, ExplicitPlacement, OsmBuildingPlacement], Field(discriminator='kind')]
JSON-serialisable union of placement strategies.
SoilSpec
module-attribute
¶
SoilSpec = Annotated[Union[HomogeneousSoilSpec, TwoLayerSoilSpec, MultiLayerSoilSpec], Field(discriminator='kind')]
JSON-serialisable union of soil specs (homogeneous / two-layer / multi-layer).
AuxiliaryElectrodePlacement ¶
Bases: BaseModel
Auxiliary current electrode (Hilfserder) for a fall-of- potential measurement of the substation grounding.
The auxiliary electrode closes the test-current loop. It is
materialised in LvNetworkLayout.to_world() via
GroundingSystemSpec.build_at(), giving the user full
control over its geometry (single rod, ring, mesh, foundation,
or any combination). The default is a bundle of three 0.5 m
rods in a 0.5 m equilateral triangle, parallel-bonded —
matching real-world practice and yielding a
spreading resistance roughly a third of a single rod.
In LvNetworkLayout.to_world() the substation's current
source returns its current through the auxiliary electrode's anchor
(Source.return_to), so the potential field develops the
expected dipole pattern (positive trumpet at the substation,
negative trumpet at the auxiliary electrode). Up to 0.15.0 the
solver ignored return_to and a second source with
phase_deg=180 on the auxiliary electrode stood in for it.
BuildingConnection ¶
Bases: BaseModel
Stub from one house's foundation centre to its serving cable.
Attributes:
| Name | Type | Description |
|---|---|---|
house_idx |
int
|
Index into |
cable_name |
str
|
Name of the |
stub_waypoints |
list[tuple[float, float]]
|
Polyline from the house centroid to the tap point on the
cable. |
tap_point_xy |
tuple[float, float]
|
The tap point on the cable polyline nearest to the house centroid
(Manhattan), the end of |
total_length_m ¶
Route length of the stub in m.
Sums the Manhattan length abs(dx) + abs(dy) of every piece
between consecutive stub_waypoints.
Returns:
| Type | Description |
|---|---|
float
|
Length of the stub in m. |
Source code in src/groundfield/generators/layout/routing.py
BuildingTypeSpec ¶
Bases: GeneratorConfig
Definition of one building type.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Identifier used as the lookup key in
|
grounding |
GroundingSystemSpec
|
|
plot_size_m |
Optional[tuple[float, float]]
|
Optional typical plot size \((dx, dy)\) in metres. v1 of the TN network generator does not consume this — it is exposed so future placement strategies (street-grid, OSM-driven) can pack buildings with type-aware footprints. |
description |
Optional[str]
|
Free-form note describing the type (use case, source of the geometry, …). Stored verbatim, not validated. |
CabinetConfig ¶
Bases: GeneratorConfig
Cable-cabinet block (German KVS) — placement, count, grounding.
Attributes:
| Name | Type | Description |
|---|---|---|
placement |
Optional[PlacementSpec]
|
Where to place the cabinets (star topology only). |
count_per_100_buildings |
Union[float, AnyDistribution]
|
Number of cabinets per 100 buildings; the count is
|
fixed_count |
Optional[Union[int, AnyDistribution]]
|
Optional fixed cabinet count (overrides the rate). |
grounding |
GroundingSystemSpec
|
Grounding system of every cabinet. |
end_clearance_m |
Union[_PositiveDistance, AnyDistribution]
|
Smallest plan distance in m between the earth electrodes of a
cabinet and those of any other site (building groups only),
positive, finite and smaller than |
max_far_end_gap_m |
Union[_PositiveDistance, AnyDistribution]
|
Largest plan distance in m (default 20, positive, finite, larger than
|
quote_per_100_buildings
property
¶
Deprecated alias of count_per_100_buildings.
CabinetPlacement ¶
Bases: PickleUpgrade, BaseModel
One user-placed cable cabinet (German KVS).
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Cabinet name; also the name of its grounding site. |
position_xy |
tuple[float, float]
|
Cabinet position |
Categorical ¶
Bases: Distribution
Categorical distribution over a finite string set.
Used for non-numeric parameters such as the electrode kind per
house (\(\in \{\text{foundation}, \text{rod}, \text{mesh}\}\)). weights
biases the choice; uniform if omitted.
sample ¶
Draw one entry of values, weighted by weights if given.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rng
|
Generator
|
Random number generator that supplies the draw. |
required |
Returns:
| Type | Description |
|---|---|
str
|
One entry of |
Source code in src/groundfield/generators/distributions.py
ConductorParameters ¶
Bases: BaseModel
Electrical and discretisation parameters of a branch conductor.
Attributes:
| Name | Type | Description |
|---|---|---|
conductor_type |
str
|
Conductor type tag ( |
wire_radius_m |
float
|
Wire radius in m. |
cross_section |
Union[float, Literal['from_radius'], None]
|
Cross section in m², |
coupling_to_soil |
str
|
|
segment_length_m |
Optional[float]
|
Discretisation length in m of the distributed conductor model;
|
inductance_model |
Optional[str]
|
|
Constant ¶
Bases: Distribution
Degenerate distribution returning value deterministically.
Useful as a placeholder or in code paths that always expect a
Distribution instance.
sample ¶
Return value; the generator is not used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rng
|
Generator
|
Random number generator (ignored; kept for the common interface). |
required |
Returns:
| Type | Description |
|---|---|
float
|
|
Source code in src/groundfield/generators/distributions.py
Discrete ¶
Bases: Distribution
Discrete numerical distribution over a finite value set.
Mirrors typical parameter axes such as
\(n_\text{EFH} \in \{5, 10, 30, 80, 200\}\). weights may be
supplied to bias the choice; if omitted the values are sampled
uniformly.
sample ¶
Draw one entry of values, weighted by weights if given.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rng
|
Generator
|
Random number generator that supplies the draw. |
required |
Returns:
| Type | Description |
|---|---|
float
|
One entry of |
Source code in src/groundfield/generators/distributions.py
Distribution ¶
Bases: BaseModel
Abstract base for probability distributions.
Subclasses must:
- set a literal
kindfield (used as the JSON discriminator), - implement
sample()returning a single draw.
The base class is intentionally a regular Pydantic model rather
than an abc.ABC so it composes cleanly with discriminated
unions in pydantic.BaseModel field annotations.
sample ¶
Draw one sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rng
|
Generator
|
Random number generator that supplies the draw. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
One draw of the distribution (a float or a string in the concrete subclasses). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Always: the base class is abstract, a concrete subclass implements the draw. |
Source code in src/groundfield/generators/distributions.py
ExplicitPlacement ¶
Bases: BaseModel
Explicit caller-supplied list of \((x, y)\) positions.
The list must be at least as long as the requested count; extras are ignored. Order is preserved (so the k-th building from the count list ends up at the k-th position).
generate ¶
Return the first n of the given positions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of sites. |
required |
rng
|
Generator
|
Random number generator (not used; kept for the common interface of the placement strategies). |
required |
Returns:
| Type | Description |
|---|---|
list of tuple of float
|
The first |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/groundfield/generators/placement.py
FoundationElectrodeSpec ¶
Bases: _ElectrodeSpecBase
Rectangular foundation electrode (Fundamenterder).
A rectangle of side length size_m (or size_xy_m for an
asymmetric footprint) at depth depth_m. The internal
structure is selected by style:
"ring"— only the rectangle's perimeter is buried (a closed wire loop). No internal cross-bracing.n_xandn_yare ignored. Use this for the Ringerder-style foundation electrode in residential buildings where only the strip foundation is electrically connected."mesh"(default) — perimeter plus horizontal and vertical cross-braces, dividing the foundation inton_x × n_ycells. The Maschenerder-style foundation electrode found in larger buildings, transformer stations and industrial sites. Withn_x = n_y = 2(the default) the rectangle gets exactly one internal horizontal plus one internal vertical wire.
The image family solves one uniform leakage current per straight wire
(an owner; user decisions Q30, Q44): an outline is one owner per
straight side. The owners of a foundation depend only on its
structure, never on the orientation, on whether a shell is configured
(audit A2G-04) or on the deprecated concrete_model, which has
no effect (user decision Q38). A "mesh" foundation is one straight
wire per mesh line (a polyline split at the crossings), bonded to the
first: one owner over perimeter and braces was 2.4 % (2 × 2) to 3.7 %
(4 × 4) high against mom (one current per segment) with the
default line kernel, one owner per wire is 1.1 % high (0.3–0.5 % with
the point kernel, the kernel of mom). A rectangle without
cross-braces ("ring", or "mesh" with n_x = n_y = 1) is one
straight wire per side, bonded to the first, at every angle (user
decision Q38). Up to then an axis-aligned one (also one turned by a
multiple of 90°) was one
groundfield.geometry.electrodes.GridMeshElectrode (one owner)
with the default value; per side its input impedance is lower by less
than 1 % up to aspect ratio 4 and 2 % up to 50 for a short side of at
least 1 m, and equal for a square (see concrete_model for the
scope). A polygon_xy_m outline is one closed polyline, solved as
one owner per straight side (user decisions Q30/Q44).
The first wire of a rectangle (the anchor, named after the foundation)
is its local \(-y\) side; its connection point, where conductors
attached to the foundation by name start, is the corner at the start
of that side (a building outline: its first vertex). The generators
end their cables and service drops at the point of the foundation
nearest to each conductor instead (user decision Q41, see
groundfield.generators.materialise).
With a shell (concrete_rho_ohm_m) every wire of the
foundation, the cross-braces of a mesh included, is encased (DIN
18014, user decision Q20); see ADR-0012.
For an asymmetric footprint set size_xy_m instead of
size_m (when both are given, size_xy_m wins).
model_copy ¶
Copy of the spec; validates an update of concrete_model.
Pydantic stores update without validation, so the deprecated
concrete_model (user decision Q21) is validated here like
in the constructor: a value outside {"lumped", "distributed"}
raises the constructor's pydantic.ValidationError (no
warning, nothing stored; audit D2B-04), "distributed" emits
the constructor's DeprecationWarning at the caller's line
and "lumped" is silent. Only that field is validated (on a
shallow copy), so the other fields, also the required fields of a
subclass, are copied as they are (audit R2B-05).
copy.replace (Python >= 3.13) calls this method. Copies that
leave the field alone (every copy the generators make) are silent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update
|
Optional[Mapping[str, Any]]
|
Field values to change. |
None
|
deep
|
bool
|
Deep copy instead of a shallow one. |
False
|
Returns:
| Type | Description |
|---|---|
FoundationElectrodeSpec
|
The copy (the receiver is not changed). |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If |
Source code in src/groundfield/generators/electrode_specs.py
GeneratorConfig ¶
Bases: PickleUpgrade, BaseModel
Base class for generator configurations.
Subclasses declare their parameters as Pydantic fields. Numerical
fields are typed as T | <distribution alias> so the user can
pass a fixed value or a Distribution. Categorical
fields use str | Categorical.
Two introspection helpers are provided:
has_distributions()returnsTrueif any field still carries aDistributioninstance — useful as a guard before passing the config toWorldGenerator.build().sample()returns a copy of the config with everyDistributionfield resolved to a concrete value via its.sample(rng)method. NestedGeneratorConfigsub-fields are recursed into; lists are processed element-wise.
A config pickled by an earlier release unpickles with its renamed
fields moved to the current names (_field_renames of the
subclass) and fields added since filled with their defaults
(PickleUpgrade, audit A2G-07).
has_distributions ¶
Return whether any field still carries a Distribution.
Recursive: a nested GeneratorConfig whose own field
carries a distribution counts as "has distributions".
Source code in src/groundfield/generators/base.py
sample ¶
Return a copy with every Distribution resolved.
Each distribution anywhere in the config tree — fields of this
config, of nested generator configs and of the spec models they
hold (soil, placement, electrode, measurement specs), list items
and dict values (e.g. building_counts) — is replaced by
exactly one .sample(rng) draw. Fields are visited in
declaration order, lists in order, dicts in sorted key order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rng
|
Optional[Union[int, Generator]]
|
Either an integer seed, a |
None
|
Returns:
| Type | Description |
|---|---|
GeneratorConfig
|
A resolved config of the same concrete type;
|
Notes
Population parameters that are plain numbers stay as they are:
a presence_prob of 0.5 or a positive placement
jitter_m still makes per-site draws when the resolved config
is built (see WorldGenerator.sample_world()).
Source code in src/groundfield/generators/base.py
GroundingSystemSpec ¶
Bases: GeneratorConfig
A complete grounding installation.
Attributes:
| Name | Type | Description |
|---|---|---|
electrodes |
list[ElectrodeSpec]
|
Ordered list of electrode specs. Order matters only for the choice of anchor (first present electrode) and for the electrode names. All present electrodes are bonded into one cluster. |
bond_conductor_type |
str
|
Conductor type used to bond the electrodes together. Default
|
build_at ¶
build_at(world: World, site_xy: tuple[float, float], name_prefix: str, rng: Generator) -> Optional[str]
Materialise the grounding system inside world.
Equivalent to plan_site() followed by
groundfield.generators.materialise.materialise_site().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
world
|
World
|
The |
required |
site_xy
|
tuple[float, float]
|
Centre position |
required |
name_prefix
|
str
|
Prefix of every created electrode name. The actual name is
|
required |
rng
|
Generator
|
Random generator used for |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The name of the anchor electrode (the first present one).
|
Source code in src/groundfield/generators/grounding.py
plan_site ¶
plan_site(name: str, *, role: str, position_xy: tuple[float, float], rng: Generator, footprint: 'Optional[BuildingFootprint]' = None, building_type: Optional[str] = None, outline: FoundationOutline = 'spec') -> PlannedSite
Resolve the system into a PlannedSite.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Site name (electrode-name prefix). |
required |
role
|
str
|
Site role, see |
required |
position_xy
|
tuple[float, float]
|
Site reference point |
required |
rng
|
Generator
|
Random generator (see |
required |
footprint
|
'Optional[BuildingFootprint]'
|
Recorded on the site for information. |
None
|
building_type
|
'Optional[BuildingFootprint]'
|
Recorded on the site for information. |
None
|
outline
|
FoundationOutline
|
|
'spec'
|
Returns:
| Type | Description |
|---|---|
PlannedSite
|
The concrete site. |
Source code in src/groundfield/generators/grounding.py
resolve_electrodes ¶
Make every random decision of this grounding system.
For each electrode in list order: one draw for a distributed
presence_prob, one Bernoulli draw when the probability is
below one, and — for a present electrode — one draw per
distribution field (see _resolve_spec() for the order).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rng
|
Generator
|
Random generator. |
required |
Returns:
| Type | Description |
|---|---|
list of PlannedElectrode
|
The present electrodes with concrete values, each tagged with
its index in |
Source code in src/groundfield/generators/grounding.py
with_footprint ¶
with_footprint(footprint: 'BuildingFootprint', *, site_xy: Optional[tuple[float, float]] = None, outline: FoundationOutline = 'ombr') -> 'GroundingSystemSpec'
Return a copy whose foundation electrodes follow footprint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
footprint
|
'BuildingFootprint'
|
Building outline in the world's local frame (m). |
required |
site_xy
|
Optional[tuple[float, float]]
|
Site position the spec will be built at, i.e. the origin of
every |
None
|
outline
|
FoundationOutline
|
|
'ombr'
|
Returns:
| Type | Description |
|---|---|
GroundingSystemSpec
|
A new spec ( |
Raises:
| Type | Description |
|---|---|
ValueError
|
For |
ImportError
|
|
Source code in src/groundfield/generators/grounding.py
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 | |
HomogeneousSoilSpec ¶
Bases: PickleUpgrade, BaseModel
Homogeneous soil with a single resistivity \(\rho\).
Use as a sanity check (every layered backend collapses to this when \(K = 0\)) or for very simple studies.
to_soil ¶
Draw the distributions and return the soil model.
A non-default relative_permittivity warns with
InertConfigurationWarning (no backend
reads it).
Source code in src/groundfield/generators/soil_specs.py
KvsConfig ¶
KvsPlacement ¶
LateralCoverageResult ¶
Bases: NamedTuple
Outcome of LvNetworkLayout.connect_all_buildings().
Attributes:
| Name | Type | Description |
|---|---|---|
laterals |
list[str]
|
Names of the PEN lateral cables that were added to reach otherwise-unconnected houses, in the order they were created. |
islands |
list[int]
|
Indices of footprints that still could not be connected -- houses enclosed by other footprints on every side, for which no obstacle-free service stub exists even after adding a lateral. An empty list means full coverage. |
connections |
list['BuildingConnection']
|
Snapshot of |
LogNormal ¶
Bases: Distribution
Log-normal distribution.
The default parameterisation matches NumPy's: mu and sigma
are the mean and standard deviation of the underlying normal
\(Y \sim \mathcal{N}(\mu, \sigma^2)\), and the log-normal sample
is \(X = e^{Y}\).
Use from_moments() to construct an instance from the
physical mean and standard deviation of \(X\) instead.
from_moments
classmethod
¶
Build a LogNormal from the physical mean and std.
Solves \(\mu = \ln(\text{mean}^2/\sqrt{\text{std}^2 + \text{mean}^2})\) and \(\sigma^2 = \ln(1 + \text{std}^2/\text{mean}^2)\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mean
|
float
|
Target physical mean \(\mathbb{E}[X] > 0\). |
required |
std
|
float
|
Target physical standard deviation \(\sqrt{\mathrm{Var}(X)} > 0\). |
required |
Source code in src/groundfield/generators/distributions.py
sample ¶
Draw one sample \(X = e^{Y}\) with \(Y \sim \mathcal{N}(\mu, \sigma^2)\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rng
|
Generator
|
Random number generator that supplies the draw. |
required |
Returns:
| Type | Description |
|---|---|
float
|
One log-normal draw (positive). |
Source code in src/groundfield/generators/distributions.py
LvNetworkLayout ¶
Bases: _RoutingMixin, _MeasurementMixin, _PenetrationMixin, _PlotMixin, PickleUpgrade, BaseModel
Imperative LV network layout builder.
The builder is constructed empty (no buildings, no substation, no cables) and filled up by calling its methods in the order a planner would naturally take. Every state-changing method returns the new object (or its key) so the calls can be chained or stored:
layout = LvNetworkLayout.from_footprints(footprints, ... substation_xy=(0, 0)) cabinet_1 = layout.add_cabinet((120, 0)) cable = layout.add_pen_cable(start="substation", ... end_xy=(250, 0)) layout.connect_buildings() ax = layout.plot()
Attributes:
| Name | Type | Description |
|---|---|---|
footprints |
list[BuildingFootprint]
|
Building footprints (already projected into the local ENU frame). Their axis-aligned bounding rectangles serve both as house positions and as PEN-routing obstacles. |
substation_xy |
tuple[float, float]
|
Substation centre in metres. |
substation_name |
str
|
Substation anchor id used everywhere else (default
|
cabinet_placements |
list[CabinetPlacement]
|
Optional pre-populated cabinet list. Most callers leave this
empty and use |
pen_cables |
list[PenCable]
|
Optional pre-populated PEN cables. Most callers leave
this empty and use |
connections |
list[BuildingConnection]
|
Optional pre-populated building connections. Most callers
leave this empty and use |
obstacle_clearance_m |
float
|
Inflation applied to every footprint AABB before routing. Defaults to 1 m so cables keep a small visible distance from the foundation walls. |
kvs_placements
property
¶
Deprecated alias of cabinet_placements.
projector
property
¶
Lazy Projector for the layout's ENU frame.
Returns None when frame_origin_lat_lon is not
set (the layout is in an anonymous local frame). The
projector is reconstructed on every access; pyproj caches
the underlying CRS objects so this stays cheap.
add_cabinet ¶
add_cabinet(position_xy: Optional[tuple[float, float]] = None, *, position_lat_lon: Optional[tuple[float, float]] = None, name: Optional[str] = None) -> str
Place a cable cabinet at position_xy or position_lat_lon.
Exactly one of position_xy (local ENU metres) or
position_lat_lon (WGS84 degrees) must be set. The lat /
lon variant projects through the layout's
frame_origin_lat_lon; if no frame origin is set, a
RuntimeError is raised.
Returns the assigned cabinet name (auto-generated when name
is None). The returned name is what callers pass to
add_pen_cable() as start=....
Source code in src/groundfield/generators/layout/model.py
add_kvs ¶
add_kvs(position_xy: Optional[tuple[float, float]] = None, *, position_lat_lon: Optional[tuple[float, float]] = None, name: Optional[str] = None) -> str
Deprecated alias of add_cabinet().
Source code in src/groundfield/generators/layout/model.py
from_footprints
classmethod
¶
from_footprints(footprints: list[BuildingFootprint], *, substation_xy: tuple[float, float], substation_name: str = 'substation', obstacle_clearance_m: float = 1.0, frame_origin_lat_lon: Optional[tuple[float, float]] = None) -> 'LvNetworkLayout'
Build an empty layout from a list of footprints.
frame_origin_lat_lon is optional; pass it when the
footprints were projected by an external pipeline and you
still want to add cabinets / PEN endpoints by lat / lon later.
Source code in src/groundfield/generators/layout/model.py
from_osm
classmethod
¶
from_osm(*, center_lat_deg: float, center_lon_deg: float, radius_m: float, substation_lat_lon: Optional[tuple[float, float]] = None, substation_xy: Optional[tuple[float, float]] = None, cabinet_lat_lons: Optional[list[tuple[float, float]]] = None, cabinet_xys: Optional[list[tuple[float, float]]] = None, substation_name: str = 'substation', obstacle_clearance_m: float = 1.0, min_area_m2: float = 16.0, cache_dir=None, force_refresh: bool = False, endpoint: Optional[str] = None, timeout_s: Optional[int] = None, max_retries: int = 1, exclude_building_tags: Optional[Collection[str]] = None, **deprecated: object) -> 'LvNetworkLayout'
One-shot constructor: query OSM and pre-place anchors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center_lat_deg
|
float
|
Centre of the buildings-in-radius Overpass query. Also
the WGS84 origin of the local ENU frame
|
required |
center_lon_deg
|
float
|
Centre of the buildings-in-radius Overpass query. Also
the WGS84 origin of the local ENU frame
|
required |
radius_m
|
float
|
Search radius in metres. |
required |
substation_lat_lon
|
Optional[tuple[float, float]]
|
Optional substation location as WGS84 |
None
|
substation_xy
|
Optional[tuple[float, float]]
|
Substation location in already-projected metres.
Mutually exclusive with |
None
|
cabinet_lat_lons
|
Optional[list[tuple[float, float]]]
|
Optional list of cabinet locations in WGS84 |
None
|
cabinet_xys
|
Optional[list[tuple[float, float]]]
|
Optional list of cabinet locations in already-projected
metres. Mutually exclusive with |
None
|
substation_name
|
str
|
Anchor id for the substation. Default |
'substation'
|
obstacle_clearance_m
|
float
|
Forwarded to the layout / OSM query respectively. |
1.0
|
min_area_m2
|
float
|
Forwarded to the layout / OSM query respectively. |
1.0
|
cache_dir
|
Forwarded to |
None
|
|
force_refresh
|
Forwarded to |
None
|
|
endpoint
|
Forwarded to |
None
|
|
timeout_s
|
Forwarded to |
None
|
|
max_retries
|
Forwarded to |
None
|
|
exclude_building_tags
|
Optional[Collection[str]]
|
|
None
|
Returns:
| Type | Description |
|---|---|
LvNetworkLayout
|
Layout with footprints loaded, projector seeded, and substation / cabinets pre-placed. Routing and connections are still up to the caller. |
Examples:
Build the layout for Mulmke (Heudeber / Nordharz) in a 300 m radius around the village centre, with the substation at a chosen lat / lon and two cabinets along the main road:
>>> layout = LvNetworkLayout.from_osm(
... center_lat_deg=51.9136, center_lon_deg=10.8432,
... radius_m=300.0,
... substation_lat_lon=(51.9138, 10.8418),
... cabinet_lat_lons=[
... (51.9133, 10.8445),
... (51.9140, 10.8460),
... ],
... )
Source code in src/groundfield/generators/layout/model.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 | |
lat_lon_to_xy ¶
Project a WGS84 (lat, lon) to the layout's local frame.
Raises RuntimeError when no
frame_origin_lat_lon has been set (i.e. the layout
was not built via from_osm()).
Source code in src/groundfield/generators/layout/model.py
plan ¶
plan(*, name: str = 'ortsnetz_layout', soil: Optional[SoilModel] = None, substation_grounding: Optional[GroundingSystemSpec] = None, cabinet_grounding: Optional[GroundingSystemSpec] = None, house_grounding: Optional[GroundingSystemSpec] = None, pen_wire_radius_m: float = 0.005, pen_segment_length_m: Optional[float] = 5.0, include_source: bool = True, source_magnitude_a: float = 1.0, seed: int = 0, foundation_mask: Optional[list[bool]] = None, foundation_outline: FoundationOutline = 'ombr', **deprecated: object) -> NetworkPlan
Resolve the layout into a NetworkPlan.
Parameters are those of to_world(). Random draws (presence
probabilities and distributions in the grounding specs) use
numpy.random.default_rng(seed) in the order substation,
cabinets, houses, auxiliary electrode. Each house's foundation
electrodes are shaped after its footprint once its draws are made
(see foundation_outline in to_world()), so the outline
does not change which optional electrodes a seed produces.
Returns:
| Type | Description |
|---|---|
NetworkPlan
|
The concrete network. Every PEN cable becomes a chain of branches between junctions at its corners and tap points; cable ends at the substation or a cabinet attach to that site. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
RuntimeError
|
If the substation, a cabinet or the auxiliary electrode grounding produces zero electrodes. |
Source code in src/groundfield/generators/layout/model.py
574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 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 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 | |
to_world ¶
to_world(*, name: str = 'ortsnetz_layout', soil: Optional[SoilModel] = None, substation_grounding: Optional[GroundingSystemSpec] = None, cabinet_grounding: Optional[GroundingSystemSpec] = None, house_grounding: Optional[GroundingSystemSpec] = None, pen_wire_radius_m: float = 0.005, pen_segment_length_m: Optional[float] = 5.0, include_source: bool = True, source_magnitude_a: float = 1.0, seed: int = 0, foundation_mask: Optional[list[bool]] = None, foundation_outline: FoundationOutline = 'ombr', **deprecated: object) -> World
Materialise the layout into a groundfield.World.
Equivalent to materialise_plan(self.plan(...)). Each
PenCable becomes a chain of straight conductors between
junctions at its corners and tap points, so the cable follows its
Manhattan polyline; each BuildingConnection becomes one
conductor from the tap junction to the house foundation. A
conductor routed to a site with a horizontal earth electrode (a
foundation, since user decision Q43 also a circular ring or a
strip) ends at the point of that electrode nearest to it (user
decision Q41): such a house is tapped at the closest pair in plan of
its cable and its horizontal wires (not at the tap point of its
BuildingConnection, the cable point nearest to the
centroid), and its drop ends there, at the wire's depth, attached to
that wire; a cable leaves a substation or a cabinet with horizontal
electrodes (the default substation ring) at their point nearest to
the cable's next node. Taps lie on the layout polyline where the
cable is built: the leading run of its waypoints inside the start
site's closed electrodes (a rectangle, a building outline, a circle)
and the trailing run inside the end site's are part of those sites
(audit R6A-01: a router corner inside a small cabinet ring was a
node that houses tapped), and the segment that leaves (reaches) the
site is clipped at the projection onto it of the site's point
nearest to its far waypoint; a cable that passes through the closed
electrodes of the substation or a cabinet elsewhere — another
cabinet, or its own start or end site again — is clipped there the
same way and joined to that site where it enters and where it
leaves it (audits W1B-03, W1B-04). So no tap and no corner lies
inside the foundation of the substation or a cabinet, and a rotated,
polygon or offset site foundation leaves the taps of the houses on
the cable (audits R4A-03, R5A-02); a tap at a clip point, or at the
site's waypoint, is the site itself. A site with rods only keeps the
connection point of its anchor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
World name. |
'ortsnetz_layout'
|
soil
|
Optional[SoilModel]
|
Soil model; default homogeneous 100 Ω·m. |
None
|
substation_grounding
|
Optional[GroundingSystemSpec]
|
Grounding specs of the substation, every cabinet and every house (defaults: ring + 4 rods, one 1.5 m rod, 2 × 2 foundation mesh shaped after the footprint). |
None
|
cabinet_grounding
|
Optional[GroundingSystemSpec]
|
Grounding specs of the substation, every cabinet and every house (defaults: ring + 4 rods, one 1.5 m rod, 2 × 2 foundation mesh shaped after the footprint). |
None
|
house_grounding
|
Optional[GroundingSystemSpec]
|
Grounding specs of the substation, every cabinet and every house (defaults: ring + 4 rods, one 1.5 m rod, 2 × 2 foundation mesh shaped after the footprint). |
None
|
pen_wire_radius_m
|
float
|
PEN wire radius in m. |
0.005
|
pen_segment_length_m
|
Optional[float]
|
Discretisation length in m of the PEN conductors ( |
5.0
|
include_source
|
bool
|
Add the current source at the substation. With an
auxiliary electrode it is a two-terminal source that
returns its current through that electrode
( |
True
|
source_magnitude_a
|
float
|
Source current in A. |
1.0
|
seed
|
int
|
Seed of the random draws in the grounding specs. |
0
|
foundation_mask
|
Optional[list[bool]]
|
Optional per-house bool list. Only houses with |
None
|
foundation_outline
|
FoundationOutline
|
How each footprint shapes the foundation electrodes of
|
'ombr'
|
Returns:
| Type | Description |
|---|---|
World
|
The materialised network. |
Source code in src/groundfield/generators/layout/model.py
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 | |
xy_to_lat_lon ¶
Inverse projection: local frame (x, y) → WGS84.
Mirrors lat_lon_to_xy().
Source code in src/groundfield/generators/layout/model.py
ManhattanGridPlacement ¶
Bases: BaseModel
Regular Manhattan-grid placement.
Houses are placed on a grid centred on centre_xy with
n_per_row columns and as many rows as needed to fit n
sites (the last row may be partially filled).
Spacings are configurable as fixed values or distributions; they
are sampled once per generate() call (one draw used for
the whole grid). Per-site jitter_m adds an additional
uniform offset in the box
\([-\text{jitter}/2, +\text{jitter}/2]^2\) to each grid point —
sample once per site. jitter_m may itself be a
Distribution; it is then drawn once per site (a draw
\(\le 0\) means no jitter for that site).
Notes
The grid is centred so the geometric centroid of a fully filled
grid coincides with centre_xy. For a partial last row the
centroid drifts slightly; if you need exact symmetry, request
a count that is a multiple of n_per_row.
generate ¶
Place n sites on the grid, row by row.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of sites. |
required |
rng
|
Generator
|
Random number generator for the spacings (one draw each per call) and the per-site jitter. |
required |
Returns:
| Type | Description |
|---|---|
list of tuple of float
|
|
Source code in src/groundfield/generators/placement.py
MeasurementInjectionConfig ¶
Bases: GeneratorConfig
Auxiliary current electrode + optional metallic feed lead.
The auxiliary electrode (Hilfserder) is the remote electrode
through which the test current returns to the source. Default:
a single driven rod at \((200, 0)\) m. For studies that model the
measurement against a neighbouring substation, point grounding
at neighbour_substation_grounding().
feed_lead is the metallic Stromeinspeiseleitung from the
instrument's current terminal MEASUREMENT_H_TERMINAL to the
aux electrode; the source drives the test current between the
substation and that terminal. None (default) means
galvanic-only: the source's return_to is the aux electrode
itself, i.e. an ideal return path without impedance or inductive
coupling. Setting feed_lead to a MeasurementLeadConfig
(often via overhead_lead() or buried_lead()) adds the
physical wire and enables the inductive coupling.
MeasurementLeadConfig ¶
Bases: GeneratorConfig
One physical measurement lead (current feed or voltage probe).
A measurement lead is a finite-impedance Conductor that
connects two anchor electrodes (typically the substation cluster
and the auxiliary or probe cluster). It runs horizontally at
\(z\) = depth_m (see lead_axis_z()) between the
horizontal positions of the two anchors. Typical variants:
depth_m = 0.0— laid out on the ground (the classical feed lead of a fall-of-potential measurement); modelledSURFACE_LEAD_HEIGHT_Mabove the surface.depth_m < 0.0— strung above ground at height-depth_m.depth_m > 0.0(e.g. 0.6 m) — buried cable. Used when the study models a permanently installed measurement infrastructure or a measurement that uses an existing buried PEN cable as the feed.
The default settings (conductor_type="bare_copper",
coupling_to_soil="isolated", inductance_model="neumann")
match a bare overhead measurement wire that does not leak
current to the soil along its length but does generate a magnetic
field that couples to every parallel conductor — exactly the
inductive-coupling problem.
MeasurementProbeConfig ¶
Bases: GeneratorConfig
Voltage probe + optional metallic measurement lead.
The voltage probe (Spannungssonde) is the second remote electrode; the post-processing evaluates the potential at its location. Default: a short (0.5 m) driven rod at \((60, 0)\) m — the classical 62 % point in fall-of-potential measurements.
lead is the metallic measurement wire from the instrument's
voltage terminal MEASUREMENT_S_TERMINAL to the probe; it
carries no current (ideal voltmeter), so its resistance does not
enter the reading, but the voltage induced in it does. As with
MeasurementInjectionConfig.feed_lead, None is
galvanic-only (the voltmeter reads the probe electrode directly);
setting it enables inductive coupling.
MeasurementSetupConfig ¶
Bases: GeneratorConfig
Earth-resistance measurement setup.
When TnNetworkConfig.measurement is set, the generator:
- builds the auxiliary electrode at
injection.position_xyviainjection.grounding.build_at(...); - builds the voltage probe at
probe.position_xyviaprobe.grounding.build_at(...); - if
injection.feed_leadis set, adds the instrument's current terminal, the junctionMEASUREMENT_H_TERMINALat the substation position, and aConductorfrom it to the aux anchor with the configured depth, conductor type, and inductance model; - if
probe.leadis set, adds the voltage terminal, the junctionMEASUREMENT_S_TERMINAL, and a similar conductor from it to the probe anchor; - attaches the source to the substation anchor with
return_topointing at the end of the current loop (MEASUREMENT_H_TERMINALwith a feed lead, else the aux anchor): the test current flows through the soil from the substation to the auxiliary electrode and back through the feed lead.
The reading of the simulated instrument is
measured_impedance() (three-pole, E-S) and
result.input_impedance() (two-pole, E-H).
The default factory leaves both leads as None (galvanic
only). To enable inductive coupling, set, e.g.,
measurement = MeasurementSetupConfig( ... injection=MeasurementInjectionConfig( ... position_xy=(200.0, 0.0), ... feed_lead=overhead_lead(), ... ), ... probe=MeasurementProbeConfig( ... position_xy=(60.0, 0.0), ... lead=overhead_lead(), ... ), ... )
MultiLayerSoilSpec ¶
Bases: PickleUpgrade, BaseModel
Multi-layer horizontally stratified soil.
The list layers is consumed top-down: the first entry is the
surface layer, the last entry must have h=None
(semi-infinite). Each layer's resistivity (and finite-layer
thickness) may carry a Distribution.
to_soil ¶
Draw the distributions and return the soil model.
Per layer the thickness is drawn before the resistivity. A
non-default relative_permittivity of any layer warns with
InertConfigurationWarning (no backend
reads it).
Source code in src/groundfield/generators/soil_specs.py
NetworkPlan ¶
Bases: BaseModel
Concrete, serialisable description of a generated network.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
World name. |
soil |
SoilModel
|
Concrete soil model. |
sites |
list[PlannedSite]
|
Substation, cable cabinets and buildings, in materialisation order. |
junctions |
list[PlannedJunction]
|
PEN cable junctions, in materialisation order. |
branches |
list[PlannedBranch]
|
PEN cable sections and service drops, in materialisation order. |
measurement |
Optional[PlannedMeasurement]
|
Optional measurement set-up. |
sources |
list[PlannedSource]
|
Sources, in materialisation order. |
Notes
materialise_plan() builds
the world in a fixed order: sites, measurement sites, junctions,
instrument terminals, branches, measurement leads, sources.
Electrodes, junctions and conductors therefore appear in the world
in that order.
all_branches
property
¶
Branches including the measurement leads, in build order.
all_junctions
property
¶
PEN junctions and the instrument terminals, in build order.
all_sites
property
¶
Sites including the measurement electrodes, in build order.
site ¶
Return the site called name (measurement sites included).
sites_with_role ¶
to_world ¶
Normal ¶
Bases: Distribution
Normal distribution \(\mathcal{N}(\mu, \sigma^2)\) with optional truncation.
Truncation is implemented via rejection sampling. A
RuntimeError is raised if more than max_attempts
rejections occur in a row, which protects against pathological
bound configurations (e.g. truncate_low more than ten standard
deviations away from the mean).
sample ¶
Draw one sample, rejecting draws outside the truncation bounds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rng
|
Generator
|
Random number generator that supplies the draws. |
required |
Returns:
| Type | Description |
|---|---|
float
|
One draw of the (truncated) normal distribution. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If |
Source code in src/groundfield/generators/distributions.py
ObstacleBox ¶
Bases: BaseModel
Axis-aligned bounding box used as a routing obstacle.
Attributes:
| Name | Type | Description |
|---|---|---|
x_min, y_min, x_max, y_max |
Lower-left and upper-right corner in metres. |
|
name |
Optional[str]
|
Optional label (typically the OSM building id or a human- readable house identifier). Pure metadata; the router does not consume it. |
contains_point ¶
Whether the point (x, y) lies in the closed box.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Coordinates of the point in m. |
required |
y
|
float
|
Coordinates of the point in m. |
required |
tol
|
float
|
Margin in m by which the box is enlarged on every side for the test. |
0.0
|
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in src/groundfield/generators/manhattan_routing.py
inflated ¶
Return a copy enlarged by padding_m on every side.
Source code in src/groundfield/generators/manhattan_routing.py
rectangle_overlaps ¶
Does the square [cx-half, cx+half]^2 overlap the box?
Source code in src/groundfield/generators/manhattan_routing.py
OrtsnetzLayout ¶
OsmBuildingPlacement ¶
Bases: BaseModel
Placement driven by a list of pre-projected building footprints.
The class implements the same generate(n, rng) -> list[(x, y)]
interface as generators.placement.ManhattanGridPlacement
and generators.placement.ExplicitPlacement, so any
consumer that accepts a PlacementSpec will accept this
placement too (once it has been added to the discriminated union;
see Task 3 in ADR-0011's implementation plan).
Attributes:
| Name | Type | Description |
|---|---|---|
footprints |
list[BuildingFootprint]
|
Pre-projected building polygons in the local ENU frame. Order is preserved; the k-th footprint corresponds to the k-th building site. |
min_area_m2 |
float
|
Skip footprints whose area is strictly below this threshold
on |
selection |
Literal['first_n', 'all']
|
How to choose footprints when the generator requests fewer than are available:
|
Notes
The class is intentionally a plain Pydantic BaseModel with
a kind discriminator field; it does not inherit from a
common PlacementSpec ABC because the existing union uses
structural typing via the kind literal. Adding this class
to generators.placement.PlacementSpec is a one-line union
update tracked as a follow-up task.
n_footprints
property
¶
Number of footprints surviving the min_area_m2 filter.
Identical to len(placement) and provided as an explicit
attribute so consumers can pre-flight an i against
footprint_at() without invoking len() on the model
instance.
__len__ ¶
footprint_at ¶
Return the footprint associated with site i.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
i
|
int
|
Site index, matching the order returned by
|
required |
strict
|
bool
|
If If |
False
|
Returns:
| Type | Description |
|---|---|
BuildingFootprint or None
|
The footprint at index |
Raises:
| Type | Description |
|---|---|
IndexError
|
If |
Source code in src/groundfield/geo/placement.py
generate ¶
Return n site positions as polygon centroids.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of sites the generator wants to populate. |
required |
rng
|
'np.random.Generator'
|
Unused. Accepted for interface parity with the other
|
required |
Returns:
| Type | Description |
|---|---|
list[tuple[float, float]]
|
Polygon centroids in metres. Length is |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Notes
The reported site is the polygon's area centroid, not
the centre of its oriented minimum bounding rectangle
(OMBR); the two coincide only for outlines with a centre of
symmetry (an L-shaped house separates them by several
metres). Consumers that build OMBR-aligned geometry — i.e.
footprint-driven FoundationElectrodeSpec in
TnNetworkGenerator
— must therefore compensate the centroid-to-OMBR-centre
difference themselves via offset_xy_m. The service-drop
/ PEN routing consumers legitimately use the centroid,
which is why generate keeps returning it.
Source code in src/groundfield/geo/placement.py
PenCable ¶
Bases: BaseModel
One PEN cable as a polyline of axis-aligned waypoints.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Unique cable id used for diagnostics, |
start_anchor |
str
|
Name of the anchor (substation or cable cabinet) the cable roots at. |
waypoints |
list[tuple[float, float]]
|
Ordered list of \((x, y)\) corners. The first entry equals the start anchor's position and consecutive entries differ in exactly one coordinate (Manhattan). |
end_anchor |
Optional[str]
|
Optional name of the anchor (cable cabinet) the cable terminates at.
|
grid_size_m |
float
|
The grid size used when this cable was routed -- kept on
the model so |
segments ¶
Straight pieces of the cable between consecutive waypoints.
Returns:
| Type | Description |
|---|---|
list of tuple
|
|
Source code in src/groundfield/generators/layout/routing.py
total_length_m ¶
Route length of the cable in m.
Sums the Manhattan length abs(dx) + abs(dy) of every piece;
for the axis-aligned pieces of a routed cable this is the
Euclidean length.
Returns:
| Type | Description |
|---|---|
float
|
Length of the cable in m. |
Source code in src/groundfield/generators/layout/routing.py
PenConfig ¶
Bases: GeneratorConfig
PEN cable backbone (distributed conductor, ADR-0003).
Every PEN section (substation to cabinet, trunk) and service drop runs
horizontally at z = depth_m between the horizontal positions of
the connection points of its two end electrodes, i.e. in the cable
trench; the short vertical risers to the electrode heads are not
modelled. Up to 0.15.0 depth_m was ignored and the sections ran
straight between the connection points (e.g. from the substation ring
at 0.6 m to a cabinet rod head at 0 m).
PlannedBranch ¶
Bases: BaseModel
A conductor between two nodes of the plan.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Conductor name in the world. |
role |
BranchRole
|
|
start, end |
Node names: a site (resolved to its anchor electrode) or a junction. A name that is neither is used verbatim as an electrode name. |
|
conductor |
ConductorParameters
|
Conductor parameters. |
cable |
Optional[str]
|
Name of the routed cable the section belongs to (informational). |
axis_z_m |
Optional[float]
|
|
start_contact, end_contact |
|
|
axis_offset_m |
float
|
Horizontal offset in m of the conductor from the straight line
between the plan positions of its two end points, perpendicular to
it: both ends move by |
axis_offset_normal_xy |
Optional[tuple[Annotated[float, Field(allow_inf_nan=False)], Annotated[float, Field(allow_inf_nan=False)]]]
|
|
PlannedContact ¶
Bases: BaseModel
Where a branch meets a foundation of a site (user decision Q41).
Attributes:
| Name | Type | Description |
|---|---|---|
electrode |
str
|
Name of the electrode (a wire of the site's foundation) that holds the point; the branch is attached to it. |
position_xy |
tuple[float, float]
|
Plan position |
Notes
New in 2026.11. The generators set it on every branch end at a site with
a foundation (FoundationElectrodeSpec):
the branch ends at the point of the foundation nearest to it instead of
the connection point of the site's anchor electrode (a corner of a
rectangular foundation, the first vertex of a building outline).
materialise_branch() rejects a
contact that names no foundation wire of the site or lies farther than
that from it (audit R4A-05).
PlannedElectrode ¶
Bases: BaseModel
One present electrode of a site, with every value resolved.
Attributes:
| Name | Type | Description |
|---|---|---|
index |
int
|
Position of the electrode in the
|
spec |
ElectrodeSpec
|
The electrode specification with concrete values only (no
|
PlannedJunction ¶
Bases: BaseModel
Interior node of a PEN cable (a corner or a tap point).
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Node name, unique among sites and junctions. |
position_xy |
tuple[float, float]
|
Horizontal position in m. |
depth_m |
float
|
Burial depth in m (positive into the soil). |
Notes
A junction is materialised as a leakage-free
Junction node at
(x, y, depth_m) (see
groundfield.generators.materialise.materialise_junction()); it
injects no current into the soil. Up to 0.15.0 it was a 5 cm rod
electrode that leaked part of the cable current (review finding
10.38).
PlannedMeasurement ¶
Bases: BaseModel
Fall-of-potential measurement set-up.
Attributes:
| Name | Type | Description |
|---|---|---|
auxiliary |
PlannedSite
|
Auxiliary current electrode (role |
probe |
Optional[PlannedSite]
|
Voltage probe electrode (role |
feed_lead, probe_lead |
Optional metallic leads (role |
|
terminals |
list[PlannedJunction]
|
Leakage-free junctions at the instrument at which the leads end:
the current terminal |
PlannedSite ¶
Bases: BaseModel
A grounding site: bonded electrodes forming one galvanic cluster.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Site name; every electrode is named |
role |
SiteRole
|
|
position_xy |
tuple[float, float]
|
Site reference point |
electrodes |
list[PlannedElectrode]
|
Present electrodes in spec order. Empty when every electrode of the spec was absent in this realisation (the site then has no anchor and is not wired). |
bond_conductor_type |
str
|
Conductor type of the bonds between the anchor and the other electrodes of the site. |
footprint |
Optional[BuildingFootprint]
|
Building outline the foundation geometry was derived from (buildings with a footprint only; informational). |
building_type |
Optional[str]
|
Name of the building type the site was drawn from (buildings of
|
cabinet_rule |
Optional[CabinetRule]
|
Rule that placed a cable cabinet of a building group
( |
centroid_ray_gap_m |
Optional[Annotated[float, Field(ge=0.0, allow_inf_nan=False)]]
|
Recorded with |
PlannedSource ¶
Bases: BaseModel
A current or voltage source.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
Optional[str]
|
Source name; |
attached_to, return_to |
Node names (sites resolve to their anchor electrode); a name that
is neither a site nor a junction is used verbatim as an
electrode name. |
|
kind |
Literal['current', 'voltage']
|
|
magnitude |
float
|
Amplitude in A (current source) or V (voltage source). |
phase_deg |
float
|
Phase angle in degrees. |
RadialTrunkTopology ¶
Bases: PickleUpgrade, BaseModel
Radial-feeder PEN topology with finite per-source slot budget.
The substation feeds n_feeders radial feeders. Each
feeder runs along its own discrete direction (feeder_directions_deg
or — by default — evenly spaced around the substation starting
at 0°). Buildings are assigned to the angularly closest feeder,
then sorted by distance from the substation along that feeder
axis. The first slots_per_substation buildings tap
directly to the substation; once the budget is exhausted, a cable
cabinet is inserted along the feeder axis and the next
slots_per_cabinet buildings tap to that cabinet, and so on.
Attributes:
| Name | Type | Description |
|---|---|---|
n_feeders |
int
|
Number of radial feeders emanating from the substation. Default 4 (a typical "north / east / south / west" TN-Ortsnetz). |
feeder_directions_deg |
Optional[list[float]]
|
Optional explicit feeder angles in degrees (CCW from +x).
Length must equal |
max_feeder_length_m |
float
|
Maximum trunk length per feeder. Buildings beyond this
distance (measured along the feeder axis) are dropped from
the assignment and trigger a |
slots_per_substation |
int
|
Number of direct building taps each feeder may have at the substation. Once this many buildings have been wired, the next building forces a cabinet extension. |
slots_per_cabinet |
int
|
Number of direct building taps per cabinet. After the substation
budget is exhausted, cabinets are inserted along the feeder
until every assigned building is wired or the feeder reaches
|
cabinet_spacing_m |
float
|
Step length (along the feeder axis) between adjacent cabinets when the topology decides to insert a new one. Default 60 m matches the typical street-section length between cable cabinets in urban LV networks. |
name_prefix |
str
|
Prefix used to name the inserted cabinets
( |
Notes
Trunk segments (substation → cabinet and cabinet → cabinet, one cable each) and service drops are realised as straight conductors at the PEN depth. A building fed by a cabinet taps the trunk from the substation to its cabinet at the point nearest to the building (the closest pair of trunk and foundation, user decision Q41; a leakage-free tap junction, or the cabinet); a building in a substation slot taps its feeder's whole trunk the same way (user decisions Q22, Q35; up to then it was connected to the substation, as it still is on a feeder without a cabinet). A building that a trunk crosses (any trunk) is joined to it there without a drop (audit R4A-02). A drop may run along another drop (one trench), never along a trunk farther than one minimum section (1 cm): a drop from a node that would run along a trunk — both ends of a trunk section within 1 cm of its line (audit R5A-01) — leaves it at the end of the shared stretch (audit R4B-01). The Manhattan-ness of the layout is reflected in (a) the discrete feeder directions which keep the trunk axis-aligned and (b) the angular feeder assignment, which steers buildings toward the geometrically closest street axis. Corner-routed service drops are tracked as a v2 enhancement.
assign_buildings_to_feeders ¶
assign_buildings_to_feeders(substation_xy: tuple[float, float], building_positions: list[tuple[float, float]]) -> list[list[int]]
Group building indices by angularly closest feeder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
substation_xy
|
tuple[float, float]
|
Substation centre in m. |
required |
building_positions
|
list[tuple[float, float]]
|
Per-building centres in m. Order is preserved across the assignment. |
required |
Returns:
| Type | Description |
|---|---|
list of lists of int
|
|
Source code in src/groundfield/generators/pen_topology.py
plan_feeder_cabinet_positions ¶
plan_feeder_cabinet_positions(substation_xy: tuple[float, float], feeder_idx: int, n_buildings_on_feeder: int) -> list[tuple[float, float]]
Compute cabinet positions for a feeder given its building count.
The first slots_per_substation buildings tap directly
to the substation. The next batch of up to
slots_per_cabinet buildings shares one cabinet, the batch
after that shares the next cabinet, and so on. Each cabinet sits on
the feeder axis at the smallest multiple of
cabinet_spacing_m that is \(\ge\) the projection of
the first building it serves — but we don't have that
projection here; we approximate by stepping one
cabinet_spacing_m per cabinet. This keeps the layout
predictable (cabinets are equispaced along the street) and
matches typical Ortsnetz cable cabinet spacing.
Positions beyond max_feeder_length_m are clipped to
max_feeder_length_m; if multiple cabinets would be
clipped to the same maximum distance, only the first is
kept and the remaining buildings will trigger a
UserWarning from the caller.
Source code in src/groundfield/generators/pen_topology.py
plan_feeder_kvs_positions ¶
plan_feeder_kvs_positions(substation_xy: tuple[float, float], feeder_idx: int, n_buildings_on_feeder: int) -> list[tuple[float, float]]
Deprecated alias of plan_feeder_cabinet_positions().
Source code in src/groundfield/generators/pen_topology.py
resolved_directions_rad ¶
Return the feeder directions in radians.
If feeder_directions_deg is None, the directions
are auto-distributed evenly around the substation. Otherwise
the explicit list is consumed verbatim (after the
field_validator() check that the length matches
n_feeders).
Source code in src/groundfield/generators/pen_topology.py
RingElectrodeSpec ¶
Bases: _ElectrodeSpecBase
Ring earth electrode.
Horizontal circle of radius radius_m at depth depth_m.
The classical foundation-ring or substation-ring electrode.
RodElectrodeSpec ¶
Bases: _ElectrodeSpecBase
Driven rod (Tiefenerder).
Modelled as a vertical line conductor of length length_m
starting at depth depth_m (rod head, 0 m = ground surface).
SoilLayerSpec ¶
Bases: PickleUpgrade, BaseModel
A single layer used by MultiLayerSoilSpec.
h=None marks the semi-infinite bottom layer (only valid as the
last entry in MultiLayerSoilSpec.layers).
StarCabinetTopology ¶
Bases: PickleUpgrade, BaseModel
Star PEN topology (default).
The substation feeds each cable cabinet directly, through a cable of
its own (cabinets in a line get separate cables in one trench). By
default (CabinetConfig.placement None, user decisions Q22 and
Q35 of 2026.11) the cabinets stand per building group: the buildings
are grouped by group_buildings() (runs of consecutive bearings
around the substation, one per cabinet), and the cabinet of a group
stands at the group's far end — on the ray from the substation
through the group's centroid, CabinetConfig.end_clearance_m beyond
the group's earth electrodes along it, rods included, when it stands
there within CabinetConfig.max_far_end_gap_m of its houses,
otherwise on the ray through the group's far-end building (the largest
projection of its position on the direction of the centroid), beyond
that building (audits W1B-01, W1B-02) — and feeds the group. With a given placement every building is fed by its nearest
cabinet (Manhattan metric between the site positions), as before. A
building that a cabinet's cable (main) crosses is joined to that main
where it crosses the foundation, without a service drop, and is fed
by that main's cabinet — the nearest of the cabinets whose mains
cross it, ties to the lower cabinet index (user decision Q41, audit
R4A-02; with building groups no house of the default grids of 10 to
200 houses and 58 of 1 000, with the former cabinet strip 1 of 50 and
3 of 150); a main that crosses a building it does not feed stays
unjoined. A service drop taps its cabinet's cable at the point
nearest to the building — the closest pair of cable and the
building's horizontal wires, or the point nearest to the anchor of a
building with rods only; a T-joint, or the substation / the cabinet
at the cable's ends — never another building's drop, and leaves the
main of another cabinet it would run along at that main's node
(audit R4B-01); the rules are in
groundfield.generators._pen_routing. Cabinet placement and count
come from groundfield.generators.tn_network.CabinetConfig.
The JSON tag is kind="star_cabinet"; configurations written with
the former tag "star_kvs" still load (with a
DeprecationWarning).
group_buildings
staticmethod
¶
group_buildings(substation_xy: tuple[float, float], building_positions: list[tuple[float, float]], n_groups: int) -> list[list[int]]
Building groups of the cabinets: consecutive bearings, equal sizes.
The rule of the default cabinet placement (user decisions Q22 and
Q35 of 2026.11): the buildings are ordered by their bearing
\(\theta = \operatorname{atan2}(y - y_s, x - x_s)\) around the
substation, counter-clockwise, starting after the widest angular gap
between two neighbouring bearings (so that no group straddles an
empty direction; ties to the gap that starts at the smaller bearing
from the \(+x\) axis, gaps within \(10^{-9}\) rad tie), and
cut into n_groups runs of consecutive buildings whose sizes differ
by at most one (the first runs take the extra buildings). Buildings
of equal bearing are ordered by their distance to the substation,
then by index. In the default grid of 30 houses (three rows of ten,
the substation in the middle row) the two groups are the western and
the eastern half.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
substation_xy
|
tuple[float, float]
|
Substation position in m. |
required |
building_positions
|
list[tuple[float, float]]
|
Building positions in m (one per building, in index order). |
required |
n_groups
|
int
|
Number of groups (cabinets), at least 1; at most one group per building. |
required |
Returns:
| Type | Description |
|---|---|
list of lists of int
|
Building indices per group, each in bearing order; the groups in the order of their bearings. |
Source code in src/groundfield/generators/pen_topology.py
StarKvsTopology ¶
StripElectrodeSpec ¶
Bases: _ElectrodeSpecBase
Horizontal strip earth electrode (Banderder).
Straight buried wire of length length_m at depth depth_m,
rotated by orientation_deg around the vertical axis (0° = +x).
SubstationConfig ¶
Bases: GeneratorConfig
Substation block — position + grounding system.
Attributes:
| Name | Type | Description |
|---|---|---|
position |
tuple[float, float]
|
Substation centre (x, y) in m, in the local coordinates in which
the generator builds the network. It moves the substation only:
the buildings, cable cabinets and the measurement set-up are
placed around (0, 0) whatever |
grounding |
GroundingSystemSpec
|
Substation grounding system. |
TnNetworkConfig ¶
Bases: GeneratorConfig
Top-level configuration for a TN low-voltage distribution network.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
World name. |
soil |
SoilSpec
|
Soil-model spec — homogeneous, two-layer, or multi-layer
(see |
substation |
SubstationConfig
|
Substation block (position + grounding system). |
cabinets |
CabinetConfig
|
Cable-cabinet block (placement, count, grounding). |
placement |
PlacementSpec
|
Building placement strategy. Default: Manhattan grid. |
building_types |
list[BuildingTypeSpec]
|
Catalog of building types available in this run. Each type carries its own grounding system. Defaults to a four-type catalog (residential, small/medium/large industry). |
building_counts |
dict[str, Union[int, AnyDistribution]]
|
Number of buildings per type. Keys must match a
|
pen |
PenConfig
|
PEN backbone configuration. |
source_magnitude_a |
Union[float, AnyDistribution]
|
Driving current at the substation cluster, in A. |
TnNetworkGenerator ¶
Bases: WorldGenerator[TnNetworkConfig]
Generator for TN low-voltage distribution network reference worlds.
See the module docstring for the full pipeline. In one sentence:
resolve soil → substation grounding → place buildings (one per
type-and-count) → per-building grounding → cable cabinets → wire the
PEN backbone → measurement set-up → source, as a
NetworkPlan
(plan()), then materialise the plan (build()).
Source code in src/groundfield/generators/base.py
build ¶
build(cfg: Optional[TnNetworkConfig] = None, *, rng: Optional[Union[int, Generator]] = None) -> World
Materialise one realisation of the configured TN network.
Equivalent to materialise_plan(self.plan(cfg, rng=rng)), with
one exception: right after plan() on this generator — without
rng in either call, nothing drawn from the generator's RNG since
and the same configuration — it materialises the plan that
plan() returned (once; the next call draws the next
realisation). Before, it drew a second realisation, which differs
from the plan with placement jitter or other per-site randomness
(audit W3R2B).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
TnNetworkConfig
|
Configuration overriding |
None
|
rng
|
int or Generator
|
Draw the realisation from this seed / generator instead of the generator's own RNG. |
None
|
Returns:
| Type | Description |
|---|---|
World
|
The assembled world with soil, electrodes, conductors and the configured source. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the substation grounding resolves to zero electrodes, if the total building count is zero, or if a configured placement returns fewer positions than buildings. |
Source code in src/groundfield/generators/tn_network.py
plan ¶
plan(cfg: Optional[TnNetworkConfig] = None, *, rng: Optional[Union[int, Generator]] = None) -> NetworkPlan
Resolve one realisation into a NetworkPlan.
Every random decision is made here, against rng (default:
the generator's RNG), in a fixed order: soil, substation grounding, building
counts, building positions, per-building grounding, cable
cabinets (count, positions, groundings), measurement electrodes
and leads, source magnitude. Materialising the returned plan
draws no further random numbers. A plan drawn from the generator's
RNG is remembered (a copy): build() right after it gives its
world (audit W3R2B).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
TnNetworkConfig
|
Configuration overriding |
None
|
rng
|
int or Generator
|
Seed / generator of the random draws (default: the generator's own RNG). |
None
|
Returns:
| Type | Description |
|---|---|
NetworkPlan
|
The concrete network. |
Raises:
| Type | Description |
|---|---|
ValueError
|
See |
Source code in src/groundfield/generators/tn_network.py
1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 | |
TwoLayerSoilSpec ¶
Bases: PickleUpgrade, BaseModel
Two-layer model — the default.
Upper layer of resistivity \(\rho_1\) and thickness \(h_1\) over a semi-infinite lower layer of resistivity \(\rho_2\).
to_soil ¶
Draw the distributions and return the soil model.
A non-default relative_permittivity warns with
InertConfigurationWarning (no backend
reads it).
Source code in src/groundfield/generators/soil_specs.py
Uniform ¶
Bases: Distribution
Continuous uniform on \([\text{low}, \text{high})\).
The bounds are stored as Pydantic fields low and high;
the model validator enforces high > low.
sample ¶
Draw one sample from the interval [low, high).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rng
|
Generator
|
Random number generator that supplies the draw. |
required |
Returns:
| Type | Description |
|---|---|
float
|
One uniform draw. |
Source code in src/groundfield/generators/distributions.py
VoltageProbePlacement ¶
Bases: BaseModel
Voltage probe (Spannungssonde) used during the simulated fall-of-potential measurement.
Unlike the AuxiliaryElectrodePlacement, the probe is
modelled as a pure sampling point in 3-D space: an ideal
voltmeter has infinite input impedance, so a physical probe
rod would carry zero current and therefore must not perturb
the engine's potential field. In LvNetworkLayout.to_world()
no rod electrode is created for the probe; in
LvNetworkLayout.measured_grounding_impedance() the field
is sampled at position_xy via
FieldResult.potential().
Weibull ¶
Bases: Distribution
Weibull distribution with shape \(k\) and scale \(\lambda\).
pdf \(f(x) = (k/\lambda)\,(x/\lambda)^{k-1}\,e^{-(x/\lambda)^k}\)
on \(x \ge 0\). NumPy's rng.weibull(k) returns a sample from the
Weibull with scale 1; we multiply by scale to obtain the
desired scale parameter.
sample ¶
Draw one sample with shape shape and scale scale.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rng
|
Generator
|
Random number generator that supplies the draw. |
required |
Returns:
| Type | Description |
|---|---|
float
|
One Weibull draw (non-negative). |
Source code in src/groundfield/generators/distributions.py
WorldGenerator ¶
Bases: Generic[C]
Abstract base for World-producing generators.
Subclasses parameterise themselves on a concrete
GeneratorConfig subclass C and implement
build(), which constructs a World from a
resolved config (one with no remaining
Distribution fields).
The base class supplies:
- RNG wiring via the
seedconstructor argument; sample_world()that resolves any distributions and hands the resolved config tobuild();- a guard in
_assert_resolved()that surfaces a clear error ifbuild()is called with an unresolved config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
GeneratorConfig
|
Configuration of the generator; may still contain
|
required |
seed
|
int or Generator
|
Seed or generator of the random draws. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
Source code in src/groundfield/generators/base.py
build
abstractmethod
¶
Build a World from a resolved config.
Subclasses must implement this method. They may assume that
cfg (or self.cfg if cfg is None) has no remaining
Distribution fields and may call
_assert_resolved() defensively.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
Optional[C]
|
Optional override for |
None
|
Source code in src/groundfield/generators/base.py
sample_world ¶
Resolve any distributions in self.cfg and build a world.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rng
|
Optional[Union[int, Generator]]
|
Optional seed or generator. When given, every random
number of the realisation is drawn from it: first the config
resolution, then the per-site draws of the build (presence
Bernoullis, placement jitter). The generator's construction
seed then has no influence. |
None
|
Returns:
| Type | Description |
|---|---|
tuple[World, GeneratorConfig]
|
The constructed world and the resolved config (same type
as |
Notes
Reproducing a realisation: sample_world(rng=seed) with the
same config and seed always gives the same world. The resolved
config alone replays the world bit-exactly with any seed when it
has no per-site randomness (every presence_prob 0 or 1, no
placement jitter); otherwise persist the seed, or the network
plan / world JSON.
Source code in src/groundfield/generators/base.py
buried_lead ¶
buried_lead(*, depth_m: float = 0.6, wire_radius_m: float = 0.005, inductance_model: Optional[str] = 'neumann', segment_length_m: Optional[float] = 5.0) -> MeasurementLeadConfig
Convenience factory for a buried-cable measurement lead.
Default depth 0.6 m (typical NS cable trench). Insulated cable (no soil leakage along the lead), Neumann inductance enabled.
The lead is built as a cable shield (conductor_type="cable_shield",
user decisions Q32 and Q33 of 2026.11): a thin-walled tube, so its self
inductance carries no internal inductance of a solid wire,
μ₀/(8π) = 50 nH/m less than the same lead as a solid
wire (a 150 m lead: 7.5 µH, 2.4 mΩ of reactance at 50 Hz), and a
thinner conductor drawn on its axis is read as its core, coupled at the
lead radius (a filament inside a tube). Its skin effect is not modelled
(resistance_model="skin" is rejected for a shield). For a lead that
is a solid wire, build a MeasurementLeadConfig with
conductor_type="bare_copper".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
depth_m
|
float
|
Depth of the lead axis in m (positive into the soil). |
0.6
|
wire_radius_m
|
float
|
Radius of the lead in m. |
0.005
|
inductance_model
|
Optional[str]
|
|
'neumann'
|
segment_length_m
|
Optional[float]
|
Sub-piece length in m; |
5.0
|
Returns:
| Type | Description |
|---|---|
MeasurementLeadConfig
|
The lead configuration. |
Source code in src/groundfield/generators/measurement.py
default_building_catalog ¶
Return a sensible starting catalog of four building types.
Returns:
| Type | Description |
|---|---|
list[BuildingTypeSpec]
|
Four entries: |
Source code in src/groundfield/generators/building.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
materialise_plan ¶
Build the World described by plan.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plan
|
NetworkPlan
|
A concrete network plan. |
required |
Returns:
| Type | Description |
|---|---|
World
|
The world, ready for |
Notes
Construction order: sites, measurement sites, junctions, instrument terminals, branches, measurement leads, sources (each in plan order). No random numbers are drawn, so the same plan always gives the same world.
Source code in src/groundfield/generators/materialise.py
materialise_soil ¶
materialise_soil(spec: Union[HomogeneousSoilSpec, TwoLayerSoilSpec, MultiLayerSoilSpec], rng: Generator) -> SoilModel
Convenience dispatcher: spec.to_soil(rng).
Provided so callers can write materialise_soil(cfg.soil, rng)
without having to discriminate by isinstance themselves.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
(HomogeneousSoilSpec, TwoLayerSoilSpec or MultiLayerSoilSpec)
|
Soil spec; its fields may be fixed values or distributions. |
required |
rng
|
Generator
|
Random number generator for the draws of the distribution fields. |
required |
Returns:
| Type | Description |
|---|---|
SoilModel
|
The concrete soil model ( |
Source code in src/groundfield/generators/soil_specs.py
measured_impedance ¶
measured_impedance(result: 'FieldResult', probe: Optional[str] = None, *, source: Optional[str] = None) -> list[complex]
Reading of a simulated fall-of-potential measurement.
with \(\varphi_E\) the potential of the earthing system the test
current is fed into (the galvanic cluster of the source's
attached_to node, length-weighted as in
input_impedance()),
\(\varphi_S\) the potential of the voltage terminal and \(I\)
the source current. This is the three-pole reading of an earth
tester. The two-pole reading, the voltage across the current source
(terminals E and H) over \(I\), is
input_impedance().
The source is the current source of the measurement or, since 2026.11, a voltage source (audit W2A-10): \(I\) is then its solved current, and the reading is the same as with a current source at the same terminals (the problem is linear; an internal impedance of the source changes \(I\), not the reading).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
'FieldResult'
|
Solved result of a world with a current or voltage source. |
required |
probe
|
Optional[str]
|
Node the voltmeter reads against the earthing system: the name of
a junction or of an electrode (an electrode stands for its
galvanic cluster). Default: the instrument terminal
|
None
|
source
|
Optional[str]
|
Name of the measurement's source. Omitted, the reading takes the result's single current source, or, when it has no current source, its single voltage source (audit W2R2-05: a result with one current source and voltage sources besides reads the current source, as up to 2026.11); several current sources, or several voltage sources and no current source, need the name. |
None
|
Returns:
| Type | Description |
|---|---|
list of complex
|
\(Z_\text{meas}\) in Ω per frequency ( |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the result carries no source snapshot (hand-built results), no
current or voltage source, or, with |
KeyError
|
If |
Notes
With metallic leads (MeasurementInjectionConfig.feed_lead,
MeasurementProbeConfig.lead) the voltage terminal carries the
voltage induced in the probe lead by the feed loop and the other
conductors (inductive coupling, ADR-0004); without a probe lead the
reading is the galvanic one. A non-inductive lead does not change the
reading: the feed lead is in series with an ideal current source and
the probe lead carries no current.
Source code in src/groundfield/generators/measurement.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | |
merge_collinear_waypoints ¶
Drop interior waypoints that lie on the line of their neighbours.
The result keeps the polyline's geometric shape (every actual corner) but discards the artificial mid-cell stops that the A* search produced. Endpoints are always kept.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
waypoints
|
list of tuple of float
|
Axis-aligned polyline as |
required |
Returns:
| Type | Description |
|---|---|
list of tuple of float
|
The reduced waypoint list; a copy of the input when it has fewer than three points. |
Source code in src/groundfield/generators/manhattan_routing.py
neighbour_substation_grounding ¶
A neighbour substation's typical grounding (ring + 4 rods).
Used as the auxiliary electrode in measurements where the current returns through a remote, well-grounded substation instead of a single driven rod.
Returns:
| Type | Description |
|---|---|
GroundingSystemSpec
|
A ring of radius 4 m at 0.6 m depth and four 2.5 m rods on a
circle of radius 2 m ( |
Source code in src/groundfield/generators/measurement.py
overhead_lead ¶
overhead_lead(*, wire_radius_m: float = 0.005, inductance_model: Optional[str] = 'neumann', segment_length_m: Optional[float] = 5.0) -> MeasurementLeadConfig
Convenience factory for an overhead bare-copper measurement lead.
Laid out on the ground (depth_m=0, modelled
SURFACE_LEAD_HEIGHT_M above the surface), bare copper,
isolated soil coupling, Neumann inductance enabled.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wire_radius_m
|
float
|
Radius of the lead in m. |
0.005
|
inductance_model
|
str or None
|
|
"neumann"
|
segment_length_m
|
float or None
|
Sub-piece length in m; |
5.0
|
Returns:
| Type | Description |
|---|---|
MeasurementLeadConfig
|
The lead configuration. |
Source code in src/groundfield/generators/measurement.py
resolve_value ¶
Resolve a T | Distribution field to a concrete value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Either a fixed Python value (passed through unchanged) or a
|
required |
rng
|
Generator
|
Random generator forwarded to |
required |
Returns:
| Type | Description |
|---|---|
object
|
The fixed value, or one sample from the distribution. |
Source code in src/groundfield/generators/base.py
rod_circle ¶
rod_circle(n: int, radius_m: float, *, length_m: Union[float, AnyDistribution] = 1.5, depth_m: Union[float, AnyDistribution] = 0.0, wire_radius_m: float = 0.008, presence_prob: Union[float, AnyDistribution] = 1.0, angle_offset_deg: float = 0.0) -> list[RodElectrodeSpec]
Build n RodElectrodeSpec arranged on a circle.
Typical use case: the four (or eight) driven rods inside the
substation ring earth electrode. Each rod's offset_xy_m is
set so the rods sit at angles
\(\theta_k = \text{angle\_offset} + 2\pi k / n\) on a circle
of radius radius_m centred on the site.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of rods. |
required |
radius_m
|
float
|
Circle radius in m. |
required |
length_m
|
Union[float, AnyDistribution]
|
Forwarded to every |
1.5
|
depth_m
|
Union[float, AnyDistribution]
|
Forwarded to every |
1.5
|
wire_radius_m
|
Union[float, AnyDistribution]
|
Forwarded to every |
1.5
|
presence_prob
|
Union[float, AnyDistribution]
|
Forwarded to every |
1.5
|
angle_offset_deg
|
float
|
Phase offset in degrees so the first rod can be rotated from the +x axis. |
0.0
|
Returns:
| Type | Description |
|---|---|
list[RodElectrodeSpec]
|
Length |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/groundfield/generators/electrode_specs.py
route_manhattan ¶
route_manhattan(start: tuple[float, float], end: tuple[float, float], obstacles: Iterable[ObstacleBox] = (), *, grid_size: float = 10.0, clearance_m: float = 0.5, escape_radius_m: Optional[float] = None, max_iterations: int = 200000) -> list[tuple[float, float]]
Route a Manhattan polyline from start to end.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
tuple[float, float]
|
Endpoint coordinates in metres. The grid origin is locked
to |
required |
end
|
tuple[float, float]
|
Endpoint coordinates in metres. The grid origin is locked
to |
required |
obstacles
|
Iterable[ObstacleBox]
|
Building obstacle boxes the cable must avoid. |
()
|
grid_size
|
float
|
Cell size in metres. The minimum segment length of the
returned polyline (after merging collinear segments) is at
least |
10.0
|
clearance_m
|
float
|
Additional padding around each obstacle. Defaults to
|
0.5
|
escape_radius_m
|
Optional[float]
|
Inside a disk of this radius around The escape zone applies to the A* grid cells and to the
trailing bridge from the last cell centre to |
None
|
max_iterations
|
int
|
Upper bound on the A* loop body. Increase for very large layouts (hundreds of obstacles spread across kilometres). |
200000
|
Returns:
| Type | Description |
|---|---|
list of (float, float)
|
Polyline waypoints. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
When no path exists (obstacle field encloses the
substation or KVS), or when neither candidate bridge from
the last grid cell to |
Source code in src/groundfield/generators/manhattan_routing.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 | |
segment_intersects_box ¶
segment_intersects_box(p0: tuple[float, float], p1: tuple[float, float], box: ObstacleBox, *, tol: float = 1e-09) -> bool
True if the axis-aligned segment \(p_0 \to p_1\) enters box.
The segment is assumed axis-aligned (one of x or y
coincides on both endpoints). Touching the box on the open
boundary is not considered an intersection -- that is what
makes the router happy when the cable runs along a street
that is exactly tangent to a foundation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p0
|
tuple[float, float]
|
Segment endpoints. |
required |
p1
|
tuple[float, float]
|
Segment endpoints. |
required |
box
|
ObstacleBox
|
Obstacle box. |
required |
tol
|
float
|
Small slack so a segment running on the boundary of the box does not count as intersecting. |
1e-09
|
Returns:
| Type | Description |
|---|---|
bool
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the segment is not axis-aligned (neither its |
Source code in src/groundfield/generators/manhattan_routing.py
single_rod_grounding ¶
single_rod_grounding(*, length_m: Union[float, AnyDistribution] = 1.5, depth_m: Union[float, AnyDistribution] = 0.0) -> GroundingSystemSpec
One driven rod — a typical Erdungsspieß used as an aux electrode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
length_m
|
float or Distribution
|
Rod length in m. |
1.5
|
depth_m
|
float or Distribution
|
Depth of the rod head in m below the surface. |
0.0
|
Returns:
| Type | Description |
|---|---|
GroundingSystemSpec
|
A grounding system with one |
Source code in src/groundfield/generators/measurement.py
triangle_rod_grounding ¶
triangle_rod_grounding(rod_length_m: float = 0.5, triangle_side_m: float = 0.5) -> GroundingSystemSpec
Default auxiliary-electrode geometry: three parallel vertical rods in an equilateral triangle.
Real-world fall-of-potential test sets use a bundle of rods rather than a single driven rod so the auxiliary's own spreading resistance stays well below the substation's. Three 0.5 m rods at the corners of a 0.5 m equilateral triangle give roughly a third of the single-rod impedance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rod_length_m
|
float
|
Length of each rod in m; the rod heads lie at the soil surface. |
0.5
|
triangle_side_m
|
float
|
Side length of the equilateral triangle in m; the centroid lies at the origin of the electrode's local frame. |
0.5
|
Returns:
| Type | Description |
|---|---|
GroundingSystemSpec
|
Three |
Source code in src/groundfield/generators/layout/measurement.py
Materialisation building blocks¶
materialise_plan turns a NetworkPlan into the objects of a World;
it is the only place where generated networks become worlds. The
functions below are its steps, one per kind of object, and are public
for a custom generator that builds part of a world itself. They draw no
random numbers: every value of a plan is already concrete.
materialise_site ¶
Create the electrodes of one site and bond them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
world
|
World
|
Target world. |
required |
site
|
PlannedSite
|
The planned site. |
required |
Returns:
| Type | Description |
|---|---|
str or None
|
The anchor electrode name, or |
Notes
Every non-anchor electrode is bonded to the anchor by a conductor of
type site.bond_conductor_type (an ideal galvanic short), so the
site is one cluster. A concrete shell lives on the encased wires of
its foundation (materialise_electrode()), so the current of a
bonded rod does not pass through it; nothing is written to
World.concrete_shell_corrections (up to 0.15.0 the lumped shells
of a site were folded there for the PEN service drop to carry,
review findings 10.12 / 10.13).
Source code in src/groundfield/generators/materialise.py
materialise_electrode ¶
materialise_electrode(world: World, spec: ElectrodeSpec, *, centre_xy: tuple[float, float], name: str, bond_conductor_type: str = 'bare_copper') -> None
Create one resolved electrode spec in world.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
world
|
World
|
Target world. |
required |
spec
|
ElectrodeSpec
|
Resolved electrode spec (concrete values only). |
required |
centre_xy
|
tuple[float, float]
|
Electrode reference point |
required |
name
|
str
|
Electrode name; a foundation built from several primitives uses it for its anchor primitive. |
required |
bond_conductor_type
|
str
|
Conductor type of the internal bonds of a multi-primitive foundation. |
'bare_copper'
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If a rectangular foundation has a side that is not positive (after the draws of a distribution). |
Source code in src/groundfield/generators/materialise.py
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 | |
materialise_junction ¶
Create a PEN cable joint and return its node name.
The joint is a leakage-free Junction
at (x, y, depth_m): a node of the conductor network with
Kirchhoff's current law and no soil contact. Up to 0.15.0 it was a
5 cm driven rod, which leaked 3 to 7 % of a test current through the
nominally isolated cable (review finding 10.38).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
world
|
World
|
Target world. |
required |
junction
|
PlannedJunction
|
The planned joint: its name, plan position |
required |
Returns:
| Type | Description |
|---|---|
str
|
The name of the created junction ( |
Source code in src/groundfield/generators/materialise.py
materialise_branch ¶
materialise_branch(world: World, branch: PlannedBranch, nodes: dict[str, str], *, index: Optional[dict[str, Any]] = None, foundation_wires: Optional[Mapping[str, Collection[str]]] = None) -> Conductor
Create the conductor of one branch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
world
|
World
|
Target world. |
required |
branch
|
PlannedBranch
|
The planned branch. |
required |
nodes
|
dict[str, str]
|
Map from node name (site or junction) to electrode name; a name missing from the map is used verbatim. |
required |
index
|
Optional[dict[str, Any]]
|
Optional map from electrode / junction name to the object in
|
None
|
foundation_wires
|
Optional[Mapping[str, Collection[str]]]
|
Optional map from site name to the names of its horizontal wires
(foundations, rings, strips; |
None
|
Returns:
| Type | Description |
|---|---|
Conductor
|
The created conductor. |
Notes
An end with a PlannedContact is
the contact's point on the wire it names, and the conductor is attached
to that wire (user decisions Q41, Q43); an end without one is the connection
point of the node (the site's anchor electrode, or the junction). With
axis_z_m both ends are moved to that depth, with axis_offset_m
both ends move by that distance along the normal of the plan direction
(decision D9: service drops in a row), or along
axis_offset_normal_xy when the plan gives one (the common normal of
a row of drops that are not exactly parallel, audit W3R2B-01).
Raises:
| Type | Description |
|---|---|
ValueError
|
If a contact names an electrode that is not a horizontal wire
(foundation, ring, strip) of the site the branch ends at (with
|
Source code in src/groundfield/generators/materialise.py
1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 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 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 | |
site_anchor_point ¶
Connection point in m of the anchor electrode of site.
The site is materialised into a scratch world, so the point is exactly
the one a branch without a contact attaches to (None for a site
without present electrodes). For a rectangular foundation it is a
corner — the start of its local \(-y\) side (meshes since audit
A2G-04, rectangles without cross-braces since user decision Q38) — and
for a building outline its first vertex, for a circular ring its
\(+x\) point, for a strip its start, for a rod its head. The
generators connect their cables to a site with a horizontal electrode (a
foundation, a ring, a strip) at the point of those electrodes nearest to
each cable instead (site_contact_wires(), user decisions Q41,
Q43); this point stays the end of everything attached to the site by
name, and of the generators' conductors at a site with rods only.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site
|
PlannedSite
|
A planned site. |
required |
Returns:
| Type | Description |
|---|---|
tuple of float or None
|
|
Source code in src/groundfield/generators/materialise.py
site_contact_wires ¶
The horizontal wires of site, in plan (user decisions Q41, Q43).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site
|
PlannedSite
|
A planned site. |
required |
Returns:
| Type | Description |
|---|---|
list of FoundationWire
|
One entry per electrode built from a
|
Notes
New in 2026.11 (as site_foundation_wires with the foundations only,
user decision Q41; renamed and extended to rings and strips by user
decision Q43). The generators end every conductor they route to a site
with horizontal electrodes at the point of these wires nearest to the
conductor (groundfield.generators._contact); a site with rods only
keeps the connection point of its anchor, the head of its first rod
(site_anchor_point()). The site is materialised into a scratch
world, so the wires are exactly those of the materialised plan.
Source code in src/groundfield/generators/materialise.py
clean_polygon ¶
clean_polygon(polygon_xy: 'tuple[tuple[float, float], ...] | list[tuple[float, float]]', *, min_edge_m: float = MIN_POLYGON_EDGE_M) -> list[tuple[float, float]]
Drop duplicate and sub-min_edge_m vertices from a closed ring.
Walks the ring once and keeps a vertex only when it is at least
min_edge_m away from the last kept one; finally drops trailing
vertices whose closing edge (last → first) would be too short. An
explicitly repeated closing vertex is removed first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
polygon_xy
|
'tuple[tuple[float, float], ...] | list[tuple[float, float]]'
|
Ring vertices |
required |
min_edge_m
|
float
|
Shortest edge in m that is kept. |
MIN_POLYGON_EDGE_M
|
Returns:
| Type | Description |
|---|---|
list of tuple
|
The cleaned, open ring. |
Source code in src/groundfield/generators/materialise.py
concrete_shell ¶
concrete_shell(spec: FoundationElectrodeSpec, *, encased_length_m: float) -> tuple[float, float, float]
Effective radius, lumped resistance and coefficient of a shell.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
FoundationElectrodeSpec
|
Resolved foundation spec (concrete values only). |
required |
encased_length_m
|
float
|
Total length \(L\) in m of the encased wire: every wire of the foundation — the perimeter of a ring or of a building outline, the perimeter plus the cross-braces of a mesh (user decision Q20). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
effective_radius_m |
float
|
\(r_b = r_a + t\) in m when a shell is configured, else the bare wire radius \(r_a\). |
shell_total_ohm |
float
|
\(R_\text{shell} = C / L\) in Ω (0 without shell): the shell resistance of the whole foundation under a uniform leakage current, equal to the per-wire shells \(C / L_j\) in parallel. Informational; the solver sees the coefficient. |
shell_coefficient_ohm_m |
float
|
\(C = \rho_c/(2\pi)\,\ln(r_b/r_a)\) in Ω·m (0 without shell),
|
Notes
New in 2026.11. Before the user decision Q20 the development line kept
the braces of a mesh bare and took the perimeter as the length (keyword
perimeter_m); 0.15.0 had no such function (its private
grounding._maybe_concrete_shell divided by the perimeter).
Source code in src/groundfield/generators/materialise.py
MIN_POLYGON_EDGE_M
module-attribute
¶
Shortest polygon edge (m) kept in a foundation along a building outline.
Shorter edges are merged away: a segment shorter than the (concrete-inflated) wire radius would trip the solver's thin-wire guard, and OSM footprints routinely carry centimetre-scale edges without physical meaning for the strip foundation.
footprint_mask_key ¶
Key of a footprint in LvNetworkLayout.foundation_mask().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
footprint
|
BuildingFootprint
|
The building footprint. |
required |
Returns:
| Type | Description |
|---|---|
int or str
|
|
Source code in src/groundfield/generators/layout/penetration.py
Plan vocabulary and constants¶
The literal types of the plan records and the geometric limits the generators apply.
SiteRole
module-attribute
¶
Role of a PlannedSite in the network.
"substation"— the secondary substation (Ortsnetzstation)."cabinet"— a cable distribution cabinet."building"— a building of the network (a house or a commercial building)."auxiliary"— the current return electrode of a measurement."probe"— the voltage probe electrode of a measurement.
BranchRole
module-attribute
¶
Role of a PlannedBranch in the network.
"pen"— a section of a PEN cable."service_drop"— the connection of a building to its cable."measurement_lead"— a metallic lead of a measurement set-up.
CabinetRule
module-attribute
¶
Rule that placed the cable cabinet of a building group
(PlannedSite.cabinet_rule, audit W1R2-02).
"centroid_ray"— on the ray from the substation through the group's centroid."far_end_ray"— on the ray through the group's far-end building, because on the centroid ray the cabinet would have stood farther thanCabinetConfig.max_far_end_gap_mfrom its group.
FoundationOutline
module-attribute
¶
How a building footprint shapes a foundation electrode.
"ombr"— oriented minimum bounding rectangle of the outline (size, orientation and centre)."polygon"— the outline itself (closed ring;style="ring"foundations only)."spec"— ignore the footprint; keep the spec geometry.
MIN_FOUNDATION_SIDE_M
module-attribute
¶
Shortest side (m) of a foundation rectangle taken from a footprint's OMBR.
A narrower outline — a mapped wall or fence, e.g. 10 m x 5 mm — is widened
to this side with a UserWarning; as a 5 mm wide mesh it could not
even be built (the mesh span is shorter than the wire radius, audit L5).
The AP1 pipeline applied the same 1 m floor to its OMBR foundations.
SURFACE_LEAD_HEIGHT_M
module-attribute
¶
Distance in m of a lead "on the surface" (depth_m = 0) from the ground plane.
A wire exactly in the soil-surface plane is singular for the image kernels (source and image coincide), and the Sommerfeld earth-return kernel degrades for \(|z|\) below about ten wire radii. 0.1 m keeps a 5 mm lead clear of both; the earth-return impedance of a surface lead is insensitive to the exact height while it is small against the skin depth (hundreds of metres below 1 kHz).
lead_axis_z ¶
\(z\) coordinate in m of a measurement lead's axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
depth_m
|
float
|
Configured depth in m: positive into the soil, negative above
ground, |
required |
coupling_to_soil
|
str
|
|
'isolated'
|
Returns:
| Type | Description |
|---|---|
float
|
|