Coupling¶
The coupling package collects the coupling relations the solvers
consume: the Neumann partial inductances between conductor segments
(inductance, ADR-0004), the earth-return correction of that
inductance — Carson's per-metre series for long parallel wires over
homogeneous earth (carson, ADR-0005) and the geometric
Sommerfeld/Pollaczek integral for any geometry and any number of
layers (sommerfeld_inductance, ADR-0006) — and the scalar Green's
function of two-layer soil for electrodes through the layer interface
(layered_green, ADR-0007). There is no capacitive coupling: below
1 kHz it is negligible for buried conductors.
Mathematical and physical context¶
Conductors with inductance_model="neumann" are split into segments
whose series impedance matrix is
the Neumann double-line integral (closed forms for parallel and touching
segments, Gauss–Legendre otherwise) plus the internal inductance
\(\mu_0\ell/(8\pi)\) on the diagonal. The earth enters twice: as an image
term in \(\mathbf{L}\) and as the frequency-dependent correction
\(\Delta\mathbf{Z}_\text{earth}\); the two are only meaningful together,
which is why every builder takes the same image= convention
("none": free space; "additive": perfect magnetic mirror;
"antiparallel": perfect electric conductor).
Carson (1926). For a long straight wire above homogeneous earth of conductivity \(\sigma\), against the antiparallel image,
with \(D = 2h\) (self) or the image distance of a pair (mutual) and \(\delta = \sqrt{2/(\omega\mu_0\sigma)}\) the skin depth in the soil. \(P, Q\) are evaluated by Carson's series (\(a \le 0.25\)), quadrature (\(0.25 < a \le 15\)) and the asymptotic expansion (\(a > 15\)). The correction is per metre and scaled by the segment-pair length, so it is exact only for long parallel wires; for a layered soil the upper-layer resistivity is used with a warning.
Sommerfeld / Pollaczek. The quasi-static vector-potential Green's function of the layered half-space,
is integrated over every segment pair (time convention \(e^{+j\omega t}\)).
It handles short and non-parallel wires, buried and overhead conductors
and any number of layers, and is the default
(Engine.earth_inductive_model="sommerfeld"). In the long-wire limit it
gives the Pollaczek line impedance with the earth-return resistance
\(R' \approx \omega\mu_0/8\).
Choosing the earth-return model¶
earth_inductive_model |
Use for | Limits |
|---|---|---|
"sommerfeld" (default) |
quantitative \(Z(f)\) of buried and overhead conductors, layered soil, short or bent conductors | cost grows with the number of segment pairs; the default tabulated assembly (Engine.sommerfeld_assembly) shares one table per pair of depth groups, "exact" integrates every pair |
"carson_series" |
fast scoping of long parallel conductors over homogeneous soil | per-metre approximation; layered soil uses \(\rho_1\) (warning); rejects segments in the surface plane |
"perfect_mirror" |
diagnostic baseline only | frequency-independent image, far from the physics of buried conductors below 1 kHz |
The theory, the validation against Carson's and Pollaczek's line impedances, and the history of these models are on the earth return page.
Example¶
The per-metre impedance of a conductor buried 0.7 m deep (wire radius 5 mm, internal inductance included via \(\mathrm{GMR} = a\,e^{-1/4}\)), from the closed-form references the solver is validated against:
import math
from groundfield.references import earth_return, pollaczek
gmr = 0.005 * math.exp(-0.25)
for f in (50.0, 1000.0):
z_carson = earth_return.carson_self_impedance(100.0, f, gmr=gmr) # Ω/m
z_buried = pollaczek.pollaczek_self_impedance(100.0, 100.0, 5.0, f, depth=0.7, gmr=gmr)
z_layered = pollaczek.pollaczek_self_impedance(100.0, 1000.0, 5.0, f, depth=0.7, gmr=gmr)
# homogeneous soil: the buried (Pollaczek) and Carson line impedances agree
assert abs(z_buried - z_carson) / abs(z_carson) < 1e-3
# earth-return resistance omega*mu0/8: 49.3 mOhm/km at 50 Hz
assert abs(z_carson.real - earth_return.carson_earth_return_resistance(f)) < 1e-12
# 1000 Ohm m below 5 m of 100 Ohm m soil: about 9 % more reactance
assert 1.08 < z_layered.imag / z_buried.imag < 1.10
Neumann inductance (ADR-0004)¶
inductance ¶
Self- and mutual-inductance helpers for distributed conductors.
This module implements the inductance physics described in ADR-0004. It provides three public functions:
thin_wire_self_inductance()— closed-form self-inductance of a straight thin-wire segment of length \(\ell\) and radius \(a\) (Grover 1946): \(L_\text{self} = (\mu_0\,\ell)/(2\pi) \bigl[\ln(2\ell/a) - 1\bigr]\).parallel_segments_mutual()— closed-form mutual inductance of two parallel coaxial segments of equal length \(\ell\) at perpendicular distance \(d\).neumann_mutual()— generic Neumann double-line integral via two-point Gauss–Legendre quadrature, valid for any 3-D segment-pair geometry.
Earth-image contributions are handled by the caller: for a
perfect-mirror earth the caller adds the integral against the
mirror image of the source segment (see
perfect_mirror_self_pair_inductance() and the assembly logic
in build_inductance_matrix()).
Conventions
Image convention (image=). The earth image of a segment
\((p_1 \to p_2)\) is the segment \((p_1' \to p_2')\) with
\(z \to -z\) (the \(z\)-axis points into the soil). Its Neumann
integral against a partner carries the orientation through the dot
product, so the mirrored-endpoint image is the image in a
perfect magnetic conductor (horizontal currents co-directed,
vertical currents reversed). Three conventions are offered:
"none"— free space, \(L = L_\text{dir}\). The exact quasi-static baseline of the Sommerfeld earth-return correction (groundfield.coupling.sommerfeld_inductance): at DC the soil is magnetically transparent."additive"— \(L = L_\text{dir} + L_\text{img}\), the ADR-0004 "perfect mirror" (historic default,use_image=True)."antiparallel"— \(L = L_\text{dir} - L_\text{img}\), the perfect-electric-conductor image (horizontal currents reversed). This is the baseline against which Carson's correction \(\Delta Z = (\omega\mu_0/\pi)(P + jQ)\) is defined (groundfield.coupling.carson). A perfect conductor screens the soil: a pair on opposite sides of the surface has \(L = 0\) (since audit round 2 of the calendar release; the mirrored-endpoint image of a buried partner lands above ground and gave \(\ln(D_\text{mirror}/D) < 0\)), and its whole coupling is in the earth-return correction.
An earth-return correction matrix is only meaningful together with
the image convention of the inductance matrix it is added to; the
correction builders therefore take the same image= argument.
Internal inductance (include_internal=). The diagonal
(partial self) term is the external thin-wire inductance plus, by
default, the DC internal inductance of a solid round conductor,
\(\mu_0 \ell/(8\pi)\). Every function of this package that returns
a self term uses this one convention, controlled by
include_internal (default True; the solver passes False for
the conductors of conductor_type="cable_shield", thin-walled tubes,
user decision Q33). A per-unit-length
reference that includes the internal flux uses the geometric mean
radius \(\mathrm{GMR} = a\,e^{-1/4}\); with include_internal=False
the matching reference uses \(\mathrm{GMR} = a\). The frequency
dependence of the internal impedance (skin effect) is provided by
groundfield.conductors.Conductor.internal_impedance_per_length()
as a correction relative to this DC convention.
Wires lying beside each other. Where a point of one wire lies
beside another wire (its foot on that wire's axis falls inside the
wire) closer than the sum of the radii \(r_i + r_j\) — two conductors in
one trench, a service drop routed back along its PEN main, coincident
leads, wires leaving a junction or crossing at a small angle — the
distance from the other axis is taken as \(r_i + r_j\) (touching wires)
inside the Neumann integral of build_inductance_matrix(), or as
the radius of the thicker wire where the thinner one runs inside it and
the thicker one is marked as a cable shield (shields=; a core inside
a cable shield couples as a filament inside a thin tube). The marker is
explicit since the user decision Q32 of 2026.11: two unmarked wires on
one axis are separate conductors that touch. For parallel wires the rule
refers to whole conductors (conductors=, one label per conductor, as
the solver passes them; audit W1A-02 of the calendar release): a thinner
wire inside a cable shield couples at the shield radius at every axial
offset (exact for a filament on the axis of a thin tube), and a point lies
beside another conductor when its foot falls inside that conductor, so
the sub-pieces of two conductors lying beside each other add up to the
lumped pair (a 100 m coax in 1 m pieces read 2.2 % low before). Pieces
tilted against each other by more than the closed form's tolerance of
about 4.5e-5 rad, at any angle and whatever their length, get the same
two readings with the stretches inside, beside and away from the partner
found exactly (audits W1R2-01, W1R3-01, W1R3-02; a core tilted by 4.5e-5
rad read 7.4 % low in 0.25 m pieces, with a step at the tolerance; until
W1R3 the rule stopped where the lateral distance changed by more than the
touching distance along a piece, or at \(|\cos\varphi| = 0.99\), and a core
crossing its shield's axis read -8.6e-5 of the loop off the lumped pair
in 10 m pieces, two wires leaving a junction stepped by 1.5e-3 at 8.1°).
The filament integral diverges for coincident axes (two coincident 50 m
leads read +587j Ω at 50 Hz) and exceeds the self inductance once the
wires are closer than about their radius (an indefinite matrix, a TN
network with drops along its PEN main had a negative input reactance).
The rule acts pointwise and on both one-sided integrals, so the value
is continuous in the geometry and independent of the order and
direction of the segments (audit round 3 of the calendar release; the
whole-pair switch of audit round 2 depended on which segment was the
row). Chain neighbours and bends turning by less than 90° keep their
closed forms.
Close pairs. Nearly parallel wires close together whose directions
differ by more than the closed form's tolerance, crossing and skew pairs
are integrated semi-analytically with touching="exact"; the 16x16
rule was +12 % at 10 cm and up to +250 % at 1 cm for two 5 m segments
(audit round 2 of the calendar release).
Touching segments (touching=). The Neumann integrand is
log-singular for segments that share an end point (bends, chain
neighbours) or lie on one axis. "exact" (the default since the
calendar release 2026.11) uses the closed forms (Grover 1946: two
filaments meeting at a point; coaxial filaments with a gap), accurate
to machine precision; a straight wire split into any number of
segments keeps the self inductance of the unsplit wire.
"quadrature" (the default up to 0.15.0, kept to reproduce old
numbers) integrates such pairs with the 16x16 Gauss–Legendre rule,
which is accurate to about -0.3 % ... +0.8 % for them (review pass
10, finding 10.46). The closed forms of all coaxial pairs of a segment
are evaluated in one vectorised call — a straight conductor of \(M\)
sub-segments has \(M(M-1)/2\) of them — bit-identical with the scalar
routine (audit round 2 of the calendar release, A2C-5).
References
- Grover, F. W. (1946). Inductance Calculations: Working Formulas and Tables. Dover (reprint 2004).
- Sunde, E. D. (1968). Earth Conduction Effects in Transmission Systems. Dover, ch. 7.
- Paul, C. R. (2010). Inductance: Loop and Partial. Wiley.
ImageConvention
module-attribute
¶
Image convention of an inductance matrix.
"none": free space, no image;"additive": perfect magnetic mirror at the soil surface (ADR-0004);"antiparallel": perfect electric mirror, Carson's baseline.
MU_0
module-attribute
¶
Vacuum permeability μ0 = 4π · 10⁻⁷ H/m (the conventional value).
Exact in the pre-2019 SI; the CODATA 2018 value 1.25663706212e-6 differs by 5.5 · 10⁻¹⁰ relative, which is irrelevant here.
TouchingRule
module-attribute
¶
Treatment of touching and coaxial segment pairs in the Neumann integral.
"exact": closed forms (the default);"quadrature": the 16 x 16 Gauss–Legendre rule (the default up to 0.15.0).
build_carson_correction_matrices ¶
build_carson_correction_matrices(seg_endpoints: ndarray, wire_radii: ndarray, *, omegas, sigma_earth: float, image: ImageConvention = 'antiparallel') -> np.ndarray
Carson earth-return correction matrices for several frequencies.
Multi-frequency form of build_carson_correction_matrix(): the
frequency-independent tiling geometry (pair classification, axial
overlaps, Carson heights) is built once and every frequency only
evaluates the per-metre Carson values. Entry k equals
build_carson_correction_matrix(..., omega=omegas[k]) bit for
bit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seg_endpoints
|
ndarray
|
Array of shape |
required |
wire_radii
|
ndarray
|
Per-branch wire radii in m, shape |
required |
omegas
|
Angular frequencies in rad/s (sequence of floats); entries
|
required | |
sigma_earth
|
float
|
Earth conductivity in S/m. |
required |
image
|
ImageConvention
|
Image convention of the inductance matrix this correction is
added to (see |
'antiparallel'
|
Returns:
| Name | Type | Description |
|---|---|---|
dZ |
np.ndarray, shape (n_f, M, M), dtype complex
|
Correction matrices in Ω. |
Source code in src/groundfield/coupling/inductance.py
3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 | |
build_carson_correction_matrix ¶
build_carson_correction_matrix(seg_endpoints: ndarray, wire_radii: ndarray, *, omega: float, sigma_earth: float, image: ImageConvention = 'antiparallel') -> np.ndarray
Assemble the dense Carson earth-return correction matrix.
Returns the per-segment-pair impedance correction
\(\Delta Z^{(i,j)}_\text{Carson}(\omega)\) described in ADR-0005.
The output has the same shape as build_inductance_matrix()
but is complex and frequency-dependent — it is therefore
rebuilt at every frequency by the solver (or built for all
frequencies at once with build_carson_correction_matrices()).
Image baseline (review pass 10, findings 10.20 / F32)
Carson's correction \((\omega\mu_0/\pi)(P + jQ)\) is defined
against the anti-parallel (perfect-electric-conductor) image:
the complete series impedance is
\(Z = j\omega L_\text{antiparallel} + \Delta Z_\text{Carson}\)
with \(L_\text{antiparallel}\) from
build_inductance_matrix(image="antiparallel"). The image
argument names the image convention of the inductance matrix the
returned correction is added to; for "additive" /
"none" the matrix is shifted by \(-2j\omega L_\text{img}\) /
\(-j\omega L_\text{img}\) so that the sum is the same physical
impedance. The default "antiparallel" returns the plain Carson
correction (bit-identical to earlier releases). The docstring of
earlier releases said the correction goes "on top of the
perfect-mirror (additive) Neumann matrix" — that pairing
double-counts the image and gives 1.66–2.25× the earth-return
reactance on 100 m – 1 km lines.
Tiling convention (audit 2026-07-08, WP-C3)
Carson's correction is an infinite-wire, per-unit-length concept. To make the assembled matrix consistent — and, crucially, convergent under mesh refinement — the per-pair entries tile the per-unit-length values without double counting:
- Diagonal
dZ[i, i]: self correction per metre × segment length. Summed over a refined straight wire this reproduces the fullz'_self · ℓexactly, independent of the segment count. - Collinear pairs (same axis, negligible perpendicular offset): zero. The infinite-wire self value on the diagonal already contains the interaction with the rest of the same wire.
- Near-parallel pairs on distinct axes (
|cosφ| > 0.99) of near-horizontal segments: mutual correction per metre at the perpendicular horizontal axis separation, weighted by the axial overlap length of the two segment intervals — measured along the bisector of the two axes for a pair that is not exactly parallel, so that the order of the segments does not matter (audit round 3 of the calendar release; on the first segment's axis the entries moved by up to 3.1 % of the largest one). Non-overlapping (e.g. staggered or end-to-end) pairs contribute zero. Two different conductors that overlap on one axis are wires lying side by side: the mutual at the distance of touching wires \(r_i + r_j\) (they used to get none). - Pairs on opposite sides of the surface (an overhead wire
parallel to a buried one): the field transmitted into the soil,
carson_mixed_mutual_correction()— the anti-parallel baseline of such a pair is zero (audit round 2 of the calendar release, A2C-1; the buried wire used to be treated as an overhead wire at height \(|z|\) on the mirrored-endpoint image: -36 % mutual reactance for a lead 1 m above a PEN at 0.7 m, 1 kHz). - Outside Carson's domain — oblique pairs
(
1e-9 < |cosφ| ≤ 0.99) and every pair and self term of a segment inclined by more than 8.1 deg: the exact quasi-static Sommerfeld correction of a homogeneous earth of the same conductivity (tabulated assembly), moved onto the anti-parallel baseline. Up to audit round 2 oblique pairs got the projected geometric-mean heuristic \(\sqrt{\ell_i\ell_j}\,|\cos\varphi|\) per segment pair, which grows with the number of segments (a probe lead turning 8.1 deg against the feed lead changed the reading 17.6-fold). At the domain boundary the result steps from the per-metre tiling to the Sommerfeld value, by the model error of the tiling there (two 1 km leads 2 m apart, 1 kHz: 13 %). Orthogonal pairs contribute zero by symmetry.
Earth-conductivity sign convention
In groundfield the \(z\)-axis points into the soil. A wire
above ground has \(z < 0\) and height = -z > 0. A wire just
below the surface has \(z > 0\) and we use height = z as the
Sunde-equivalent depth (Carson's \(h\)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seg_endpoints
|
ndarray
|
Array of shape |
required |
wire_radii
|
ndarray
|
Per-branch wire radii in metres (only used as a regulariser for a wire exactly at the surface; the Carson kernel itself does not depend on the radius). |
required |
omega
|
float
|
Angular frequency in rad/s. |
required |
sigma_earth
|
float
|
Earth conductivity in S/m. |
required |
image
|
ImageConvention
|
Image convention of the inductance matrix the correction is
added to: |
'antiparallel'
|
Returns:
| Name | Type | Description |
|---|---|---|
dZ |
np.ndarray, shape (M, M), dtype complex
|
Symmetric Carson correction matrix in \(\Omega\). |
Source code in src/groundfield/coupling/inductance.py
3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 | |
build_inductance_matrix ¶
build_inductance_matrix(seg_endpoints: ndarray, wire_radii: ndarray, *, use_image: bool | None = None, image: ImageConvention | None = None, include_internal: bool | ndarray = True, touching: TouchingRule = 'exact', shields: bool | ndarray | None = None, conductors: ndarray | None = None) -> np.ndarray
Assemble the dense partial-inductance matrix over branches.
Vectorised implementation per ADR-0010 Tier 0b. Reproduces
_build_inductance_matrix_loop() bit-exactly to floating-
point precision but evaluates the off-diagonal entries one row
at a time in batched NumPy calls — typical networks
(~1000 segments) speed up by 1–2 orders of magnitude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seg_endpoints
|
ndarray
|
Array of shape |
required |
wire_radii
|
ndarray
|
Per-branch wire radii in metres, shape |
required |
use_image
|
bool | None
|
Legacy switch: |
None
|
image
|
ImageConvention | None
|
Image convention of the returned matrix (see the module
docstring): |
None
|
include_internal
|
bool | ndarray
|
Add the DC internal inductance \(\mu_0\ell/(8\pi)\) to the
self terms (default |
True
|
touching
|
TouchingRule
|
|
'exact'
|
shields
|
bool | ndarray | None
|
Segments of cable shields (a bool for all, or an array of shape
|
None
|
conductors
|
ndarray | None
|
Conductor label of every segment, shape |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
L |
(ndarray, shape(M, M))
|
Symmetric partial-inductance matrix in H. Entry |
Raises:
| Type | Description |
|---|---|
ValueError
|
With an image convention other than |
Notes
The legacy loop-based implementation is kept as
_build_inductance_matrix_loop() for regression testing.
See :file:tests/test_inductance_vectorised.py for the
bit-exact regression suite.
Source code in src/groundfield/coupling/inductance.py
2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 | |
neumann_mutual ¶
neumann_mutual(p1_a: ndarray, p2_a: ndarray, p1_b: ndarray, p2_b: ndarray, *, min_distance: float = 1e-06, parallel_tol: float = 1e-09, touching: TouchingRule = 'exact') -> float
Neumann mutual-inductance integral between two straight segments.
Hybrid implementation:
- If the two segments are parallel (or anti-parallel) within
parallel_tolon distinct axes, the closed-form Grover expression in_parallel_filaments_mutual()is used — exact, no quadrature error. This fast path covers the bulk of the typical inductance assembly (parallel PEN strands). - With
touching="exact", pairs that share an end point (chain neighbours, bends) or lie on one axis without overlapping use their closed forms (Grover 1946; see the module docstring). - Otherwise the Neumann double integral is evaluated by 16×16
Gauss–Legendre quadrature: exact to round-off for pairs
separated by more than about half their length, but only
to -0.3 % ... +0.8 % for touching pairs (review pass 10,
finding 10.46), and up to +250 % for nearly parallel wires 1 cm
apart (audit round 2 of the calendar release). With
touching="exact"such close pairs — nearest quadrature nodes within half the longer segment, no shared end point, not coaxial — are integrated semi-analytically instead (inner integral in closed form, outer panels graded towards the near-singular points;_close_pair_mutual()).
Accuracy (measured against adaptive mpmath references, audit round 3
of the calendar release): closed forms to round-off; filaments from
one vertex to round-off on axis-parallel geometry and to 4e-10 in a
general orientation down to 3e-9 rad (the angle itself carries about
1e-16/angle); close pairs as stated in _close_pair_mutual()
(5e-11 above 1e-6 rad, 1.0e-9 at 1e-8 rad). Pairs inside the
parallel tolerance — directions within parallel_tol in cos (4.5e-5
rad) and a lateral offset that varies by at most parallel_tol m
along the segment — use the parallel closed form at the offset of the
start point, off by about the relative variation of the offset
(4.2e-9 for wires 1 cm apart tilted by 1e-10 rad over 5 m, 1.7e-5 at
1 µm).
The kernel \(1/r\) is clamped at min_distance to suppress the
integrable singularity for segments that touch — physically the
diagonal uses thin_wire_self_inductance() instead, so
this only affects pathological inputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p1_a
|
ndarray
|
Endpoints of segment a as |
required |
p2_a
|
ndarray
|
Endpoints of segment a as |
required |
p1_b
|
ndarray
|
Endpoints of segment b. |
required |
p2_b
|
ndarray
|
Endpoints of segment b. |
required |
min_distance
|
float
|
Numerical floor on \(|r_a - r_b|\) in metres. |
1e-06
|
parallel_tol
|
float
|
Tolerance on \(||\hat{u}_a\cdot\hat{u}_b| - 1|\) that triggers the closed-form fast path. |
1e-09
|
touching
|
TouchingRule
|
|
'exact'
|
Returns:
| Name | Type | Description |
|---|---|---|
M |
float
|
Partial mutual inductance in H. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/groundfield/coupling/inductance.py
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 954 955 956 957 958 959 960 961 962 963 964 965 | |
parallel_segments_mutual ¶
Closed-form mutual inductance of two parallel coaxial segments.
For two segments of equal length \(\ell\) that share the same axis direction and are placed at perpendicular distance \(d\),
Used both as an internal closed-form fast path (when the segment pair geometry matches the assumption) and as a reference in the test suite.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
length
|
float
|
Segment length \(\ell\) in m (both segments have the same). |
required |
distance
|
float
|
Perpendicular distance \(d\) between the two parallel axes in m. Must be > 0. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
M |
float
|
Partial mutual inductance in H. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/groundfield/coupling/inductance.py
perfect_mirror_self_pair_inductance ¶
perfect_mirror_self_pair_inductance(p1: ndarray, p2: ndarray, wire_radius: float, *, include_internal: bool = True, touching: TouchingRule = 'exact') -> float
Self-inductance contribution of a segment plus its earth image.
For a single segment the partial self-inductance against itself
uses the thin-wire formula. The image segment (mirrored at the
soil surface) is treated as an external segment whose Neumann
integral with the original is added to the total (the
"additive" image convention of ADR-0004).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p1
|
ndarray
|
Endpoints in metres (with \(z > 0\) pointing into the soil). |
required |
p2
|
ndarray
|
Endpoints in metres (with \(z > 0\) pointing into the soil). |
required |
wire_radius
|
float
|
Wire radius in m (only used for the thin-wire self term). |
required |
include_internal
|
bool
|
Add the DC internal inductance \(\mu_0\ell/(8\pi)\) (default,
see |
True
|
touching
|
TouchingRule
|
Rule for the segment–image pair when the segment touches the
surface with one end point (see |
'exact'
|
Returns:
| Name | Type | Description |
|---|---|---|
L |
float
|
Self-inductance plus image contribution, in henries. |
Source code in src/groundfield/coupling/inductance.py
thin_wire_self_inductance ¶
thin_wire_self_inductance(length: float, wire_radius: float, *, include_internal: bool = True) -> float
Closed-form self-inductance of a straight thin-wire segment.
Decomposed into the external Grover 1946 thin-wire term and the internal contribution from the magnetic field inside the conductor (uniform DC current distribution, non-magnetic material):
Adding the internal term reproduces the standard Oeding/Oswald
loop-inductance formula (Gl. 9.13c) when used as the diagonal
contribution of a two-wire loop. This is the package-wide
internal-inductance convention (see the module docstring): a
per-unit-length reference consistent with
include_internal=True uses \(\mathrm{GMR} = a\,e^{-1/4}\).
For the frequency-dependent internal impedance (skin effect) see
groundfield.conductors.Conductor.internal_impedance_per_length().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
length
|
float
|
Segment length \(\ell\) in metres. |
required |
wire_radius
|
float
|
Wire radius \(a\) in metres. |
required |
include_internal
|
bool
|
|
True
|
Returns:
| Name | Type | Description |
|---|---|---|
L |
float
|
Partial self-inductance in henries. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/groundfield/coupling/inductance.py
Carson earth return (ADR-0005)¶
carson ¶
Carson 1926 correction for the earth-return path.
This module implements the earth-return correction described in
ADR-0005: the finite-conductivity contribution that Carson 1926
derived for a homogeneous, semi-infinite, conductive half-space. It is
defined against the anti-parallel (perfect-electric-conductor)
image of the Neumann inductance matrix
(build_inductance_matrix(image="antiparallel") in
groundfield.coupling.inductance): the complete per-metre series
impedance of a wire at height \(h\) is
\(j\omega(\mu_0/2\pi)\ln(2h/\mathrm{GMR}) + \Delta Z_\text{Carson}\).
Up to 0.15.0 the solver added it on top of the additive
("perfect-mirror") image instead, which double-counts the image
(review pass 10, finding 10.20 / F32).
Mathematical background
Carson 1926 (Bell Syst. Tech. J. 5(4)) writes the earth-return correction to the per-unit-length series impedance of a long straight wire above a homogeneous earth as
with the dimensionless Carson parameter
where \(D = 2h_i\) for the self-impedance correction (\(\theta = 0\)) and \(D = \sqrt{(h_i + h_j)^2 + d_{ij}^2}\), \(\theta = \arctan(d_{ij} / (h_i + h_j))\) for the mutual-impedance correction between two parallel wires at heights \(h_i, h_j\) with horizontal separation \(d_{ij}\).
The functions \(P, Q\) are the real and imaginary parts of Carson's infinite integral \(J(p, q)\) (Carson eq. 29, with \(p = a\cos\theta\), \(q = a\sin\theta\)):
Three evaluation regimes
We follow Carson's own discussion in section III of the original paper:
- Small \(a\) (\(a \le 0.25\)) — Carson's convergent series (eqs. 34/35), summed to order \(a^{12}\) with the exact constants \(c_2 = 5/4 + \ln 2 - \gamma_E\) and \(Q_0 = \tfrac12(\tfrac12 - \gamma_E)\). Closed form, only \(\sin / \cos / \ln\).
- Intermediate \(a\) (\(0.25 < a \le 15\)) — direct numerical quadrature of Carson's \(J(p, q)\): a composite, geometrically graded Gauss–Legendre rule for \(\theta \approx 0\) and QUADPACK's Fourier integrator otherwise. The original Carson 1926 series in that range is technically convergent but its recurrence is numerically delicate; quadrature is robust.
- Large \(a\) (\(a > 15\)) — Carson eqs. 36/37, asymptotic expansion in inverse powers of \(a\) up to \(a^{-7}\) (for \(\theta \le 1.4\) rad; steeper angles stay on the quadrature).
Accuracy against mpmath (review pass 10): the series and the quadrature are accurate to round-off for \(a \le 0.25\) and \(a > 0.25\) respectively, the asymptote to \(\le 10^{-7}\) above \(a = 15\); both regime boundaries are continuous to those levels. At large \(a\) and steep angles (\(\theta > 1.4\) rad, where the asymptote is not used) QUADPACK's Fourier rule limits the quadrature: 1.5e-9 at \(a = 8.9\) and 1.2e-7 at \(a = 28\), \(\theta = 89.9°\) — two wires 1 km apart at 1 kHz in 10 Ω·m (measured in audit round 3 of the calendar release against an independent quadrature of the \(\lambda\) integral). Until the calendar release 2026.11 the small-\(a\) form kept only the leading terms (no \(a^2\) term \(-(\pi/64)\,a^2\cos 2\theta\) of \(Q\), constant rounded to \(-0.0386\), \(P\) and \(Q\) off by up to \(2.4\cdot 10^{-4}\) and \(3.0\cdot 10^{-3}\) at \(a = 0.25\)) and the \(\theta = 0\) quadrature used 64 nodes on \([0, 30/p]\) (\(6\cdot 10^{-6}\) off at \(a = 0.25\)): the boundary at \(a = 0.25\) jumped by up to \(2.9\cdot 10^{-3}\) in \(Q\) (findings 10.46, 10.20).
Implementation notes
- All formulas use SI units throughout. Carson's CGS pre-factor \(4\omega\) becomes \(\omega\mu_0 / \pi\) in SI.
- \(\sigma_\text{earth}\) is an explicit argument; the caller is responsible for selecting the right resistivity (homogeneous \(1/\rho\), or upper-layer \(1/\rho_1\) with a warning).
- \(\omega = 0\) or \(\sigma = 0\) short-circuit to
0+0j: the prefactor \(\omega\mu_0/\pi\) vanishes, so the (logarithmically diverging) \(Q\)-asymptote is harmless. - The complex-depth Deri/Semlyen approximation is provided as an
internal sanity check (
deri_semlyen_correction()); it is not the production code path. - A wire above the surface parallel to a wire below it is not a Carson
pair (both wires overhead) nor a buried pair: its mutual impedance is
the field transmitted into the soil,
carson_mixed_mutual_correction()(Carson's \(J\) plus a bounded remainder for the buried wire's attenuation; audit round 2 of the calendar release, A2C-1).
References
- Carson, J. R. (1926). Wave propagation in overhead wires with ground return. Bell Syst. Tech. J. 5(4), 539–554.
- Deri, A.; Tevan, G.; Semlyen, A.; Castanheira, A. (1981). The complex ground return plane. IEEE Trans. PAS 100(8), 3686–3693.
- Tleis, N. D. (2008). Power Systems Modelling and Fault Analysis, Newnes, ch. 3.
MU_0
module-attribute
¶
Vacuum permeability μ0 = 4π · 10⁻⁷ H/m (the conventional value).
The CODATA 2018 value differs by 5.5 · 10⁻¹⁰ relative.
carson_mixed_mutual_correction ¶
carson_mixed_mutual_correction(omega: float, height: float, depth: float, horizontal_distance: float, sigma_earth: float) -> complex
Mutual impedance of an overhead wire parallel to a buried wire.
Per-unit-length mutual impedance of two long parallel horizontal wires on opposite sides of the soil surface — one at height \(h\) above it, one at depth \(d\) below it, horizontal separation \(x\) — over a homogeneous earth (quasi-static, the regime of Carson's theory):
the field of the overhead wire transmitted into the soil, with Carson's variables \(\lambda = \mu\sqrt{\omega\mu_0\sigma}\), \(p_h = h\sqrt{\omega\mu_0\sigma}\), \(p_d = d\sqrt{\omega\mu_0\sigma}\), \(q = x\sqrt{\omega\mu_0\sigma}\) and
For \(d \to 0\) this is Carson's \(J\) of two overhead wires at
heights \(h\) and \(0\); it is evaluated as Carson's
\(J(p_h + p_d, q)\) (carson_p_q(), every regime) plus the
bounded remainder of the buried wire's attenuation
(_mixed_remainder()). Measured remainder: \(10^{-5}\) to
\(4\cdot 10^{-1}\) of \(J\) (shallow conductors at 50 Hz in resistive
soil to deep ones at 5 kHz in 10 \(\Omega\)m). The remainder is accurate
to round-off; the whole agrees with an independent quadrature of the
\(\lambda\) integral to 4.2e-9 for x ≤ 300 m (\(q \le 8.4\); f ≤ 1 kHz,
\(\rho \ge 10\,\Omega\)m, h and d from 1 mm to 10 m; 1e-10 at
50 Hz) and to 1.2e-7 at x = 1 km at 1 kHz in 10 \(\Omega\)m
(\(q = 28\)), the accuracy of Carson's \(J\) there (carson_p_q();
audit round 3 of the calendar release).
Image baseline. Relative to the anti-parallel
(perfect-electric-conductor) image of
build_inductance_matrix(image="antiparallel") this is the
whole coupling: a perfect conductor screens the soil, so the
baseline of a pair on opposite sides of the surface is zero.
Treating the buried wire as an overhead wire at height \(d\)
(Carson's correction on the mirrored-endpoint image, as the solver
did up to audit round 2 of the calendar release) gives 36 % too
little mutual reactance for a lead 1 m above a PEN at 0.7 m depth
at 1 kHz, 14 % at 1 m offset, 3 % for a lead 0.1 m above it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
omega
|
float
|
Angular frequency in rad/s. |
required |
height
|
float
|
Height \(h\) of the overhead wire above the surface in m (positive). |
required |
depth
|
float
|
Depth \(d\) of the buried wire below the surface in m (positive). |
required |
horizontal_distance
|
float
|
Horizontal separation \(x\) of the two wires in m. |
required |
sigma_earth
|
float
|
Earth conductivity in S/m. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Z |
complex
|
Per-unit-length mutual impedance in \(\Omega/\text{m}\). |
Raises:
| Type | Description |
|---|---|
ValueError
|
For a non-positive height or depth, or a negative distance. |
References
- Ametani, A.; Yoneda, T.; Baba, Y.; Nagaoka, N. (2009). An investigation of earth-return impedance between overhead and underground conductors and its approximation. IEEE Trans. Electromagn. Compat. 51(3), 860–867, doi:10.1109/TEMC.2009.2019953.
Source code in src/groundfield/coupling/carson.py
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 | |
carson_mutual_correction ¶
carson_mutual_correction(omega: float, height_i: float, height_j: float, horizontal_distance: float, sigma_earth: float) -> complex
Carson earth-return correction between two parallel horizontal wires.
Evaluates the per-unit-length mutual-impedance correction
with
after Carson eq. 31. The parallel-wire assumption is the same as for ADR-0004's Neumann fast path; for non-parallel segments the caller must split into projection components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
omega
|
float
|
Angular frequency in rad/s. |
required |
height_i
|
float
|
Heights above earth surface in metres (both positive). |
required |
height_j
|
float
|
Heights above earth surface in metres (both positive). |
required |
horizontal_distance
|
float
|
Horizontal separation \(d\) between the two wires in metres. |
required |
sigma_earth
|
float
|
Earth conductivity in S/m. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Z |
complex
|
Per-unit-length mutual correction in \(\Omega/\text{m}\). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/groundfield/coupling/carson.py
carson_p_q ¶
Evaluate Carson's \(P(a, \theta)\), \(Q(a, \theta)\).
Dispatches to the appropriate regime based on the magnitude of \(a\):
- \(a \le 0.25\): Carson's convergent series (eqs. 34/35) to order \(a^{12}\).
- \(0.25 < a \le 15\): direct numerical quadrature of Carson's \(J(p, q)\) (Gauss–Legendre for \(\theta \approx 0\), QUADPACK Fourier integrator otherwise — audit 2026-07-08, WP-B2).
- \(a > 15\): asymptotic expansion (Carson eqs. 36/37, \(a^{-7}\) term of \(Q\) with the corrected sign), except for \(\theta > 1.4\) rad where the expansion degrades and the quadrature path is used instead.
The small-\(a\) boundary is continuous to round-off, the large-\(a\)
boundary to \(\le 10^{-7}\) (see the module docstring). Results are
memoised on (a, theta).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
float
|
Dimensionless Carson parameter \(a = D \sqrt{\omega \mu_0 \sigma_\text{earth}}\). Must be \(\ge 0\). |
required |
theta
|
float
|
Angle of the image-distance vector to the vertical, in radians. \(\theta = 0\) for the self-impedance correction, \(\theta = \arctan(d/(h_i+h_j))\) for the mutual. |
required |
Returns:
| Type | Description |
|---|---|
P, Q : tuple[float, float]
|
Real and imaginary parts of Carson's integral \(J\). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/groundfield/coupling/carson.py
carson_parameter ¶
Dimensionless Carson parameter \(a = D \sqrt{\omega\mu_0\sigma}\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
distance
|
float
|
Geometric distance \(D\) in metres (\(2h\) for self-impedance, \(\sqrt{(h_i+h_j)^2 + d^2}\) for mutual). |
required |
omega
|
float
|
Angular frequency in rad/s. |
required |
sigma_earth
|
float
|
Earth conductivity in S/m. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
a |
float
|
Dimensionless Carson parameter \(a\) (0 for a non-positive
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/groundfield/coupling/carson.py
carson_self_correction ¶
Carson earth-return correction for a single horizontal wire.
Evaluates the per-unit-length impedance correction
with \(a_s = 2h\sqrt{\omega\mu_0\sigma_\text{earth}}\) and \(\theta = 0\) (Carson eq. 30, ADR-0005).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
omega
|
float
|
Angular frequency \(\omega = 2\pi f\) in rad/s. |
required |
height
|
float
|
Height of the wire above the earth surface in metres (positive — for buried wires use the Sunde-equivalent height). |
required |
sigma_earth
|
float
|
Earth conductivity in S/m (\(\sigma = 1/\rho\) for a homogeneous earth). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Z |
complex
|
Per-unit-length earth-return correction in \(\Omega/\text{m}\). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/groundfield/coupling/carson.py
deri_semlyen_correction ¶
deri_semlyen_correction(omega: float, height_i: float, height_j: float, horizontal_distance: float, sigma_earth: float) -> complex
Deri/Semlyen 1981 complex-depth approximation.
Replaces the Carson integral by the closed-form expression
with \(D = \sqrt{(h_i - h_j)^2 + d^2}\) the direct distance, \(D' = \sqrt{(h_i + h_j + 2p)^2 + d^2}\) the distance to a complex-depth image, and the complex penetration depth
The Deri/Semlyen approximation is not the production code path. It is provided as an alternative independent estimator that the test suite can compare against the Carson series — agreement within \(\approx 5\,\%\) over the typical parameter range confirms that neither implementation contains a sign or pre-factor bug.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
omega
|
float
|
Same meaning as in |
required |
height_i
|
float
|
Same meaning as in |
required |
height_j
|
float
|
Same meaning as in |
required |
horizontal_distance
|
float
|
Same meaning as in |
required |
sigma_earth
|
float
|
Same meaning as in |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Z |
complex
|
Per-unit-length earth-return correction in \(\Omega/\text{m}\) according to Deri/Semlyen 1981. |
Notes
The "self" version is recovered by setting
height_i = height_j and horizontal_distance = 0: the
direct-distance term degenerates to the wire radius, which the
caller must substitute manually (the formula does not include
a wire-radius regularisation by itself).
Source code in src/groundfield/coupling/carson.py
skin_depth ¶
Electromagnetic skin depth in soil.
Returns \(\delta = \sqrt{2 / (\omega \mu_0 \sigma)}\) in metres. Diverges at \(\omega = 0\) (purely conductive earth- return path); the caller must handle that case by skipping the Carson correction altogether.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
omega
|
float
|
Angular frequency \(\omega = 2\pi f\) in rad/s. |
required |
sigma_earth
|
float
|
Earth conductivity \(\sigma\) in S/m. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
delta |
float
|
Skin depth in metres. |
Source code in src/groundfield/coupling/carson.py
Sommerfeld / Pollaczek earth return (ADR-0006)¶
sommerfeld_inductance ¶
Geometric Sommerfeld earth-return Green function (ADR-0006).
This module implements the rigorous geometric formulation of the inductive earth-return coupling described in ADR-0006. Compared to ADR-0005's Carson per-meter scaling, it integrates the actual vector-potential Green's function over the segment-pair geometry, which correctly handles short wires, non-parallel arrangements, and layered earth.
Mathematical background
For a horizontal current element in a stratified, quasi-static medium (\(z > 0\) soil, \(z < 0\) air, layer \(k\) with \(\gamma_k^2 = j\omega\mu_0\sigma_k\) and vertical wavenumber \(u_k = \sqrt{\lambda^2 + \gamma_k^2}\), \(u_0 = \lambda\) in air; time convention \(e^{+j\omega t}\)), the vector-potential Green's function of a source at depth \(z'\) and an observer at depth \(z\) is
with \(k\) / \(j\) the layers of observer / source. The spectral amplitude \(F\) follows from the continuity of \(A\) and \(\partial A/\partial z\) at every interface. For source and observer in the same layer \(k\) (top at \(z_{k-1}\), thickness \(t\), depths \(h, h'\) measured from its top) it is the closed form
where \(\tilde R_\uparrow\), \(\tilde R_\downarrow\) are the generalised reflection coefficients of the stack above and below layer \(k\) (bottom-up / top-down recursions over \(r_{k,m} = (u_k - u_m)/(u_k + u_m)\)). For the homogeneous half-space this is the familiar \((\lambda/u_1)\Gamma e^{-u_1(h+h')}\) with \(\Gamma = (u_1-\lambda)/(u_1+\lambda)\); for two layers it is the four-term buried-in-layer-1 amplitude validated against Tsiamitros (2005) Eq. (8) (WP-D2, 2026-07-20); for \(n \ge 3\) layers the generalised \(\tilde R_\downarrow\) makes it exact as well (review pass 10, finding 10.35 — the historic \(n \ge 3\) path used the single air-image form and was 17–25 % off in \(X'\)). Pairs in different layers (including a buried / overhead pair over a layered earth) use the transmitted amplitude, obtained from the same interface conditions by a small linear solve per \(\lambda\).
The overhead pair keeps Carson's geometry, \(\lambda F_{00} = -\Gamma_s(\lambda) e^{-\lambda(H+H')}\), with the surface reflection coefficient \(\Gamma_s\) of the whole stack.
Earth-return correction and image conventions
The functions here return the earth-return correction
\(\Delta Z\) that is added to \(j\omega L\), the Neumann
partial-inductance matrix of
groundfield.coupling.inductance.build_inductance_matrix(). The
correction depends on which image that matrix carries (image=):
"none"— \(\Delta G = G - 1/R\), the exact quasi-static correction to free space. At DC the soil is magnetically transparent: no image at all."additive"(historic default, ADR-0004) — the matrix carries the perfect-magnetic-mirror image \(L_\text{img}\); the correction removes it exactly: \(\Delta Z_\text{additive} = \Delta Z_\text{none} - j\omega L_\text{img}\), with \(L_\text{img}\) computed by the same routine that added it (closed form for parallel pairs, the mirrored orientation for inclined and vertical segments)."antiparallel"— \(\Delta Z_\text{none} + j\omega L_\text{img}\); for a pair on opposite sides of the surface, whose anti-parallel baseline is zero (a perfect conductor screens the soil), \(\Delta Z_\text{none} + j\omega L_\text{dir}\).
Before review pass 10 the image was removed as \(-1/R'\) integrated by the 16x16 outer rule and weighted with the direct orientation: vertical segments kept twice the image in the \(\sigma \to 0\) limit, and segments much longer than twice their depth lost 0.6 % (25 m) to 5.7 % (50 m) of the image term (finding 10.46).
Numerical method
Each segment pair is integrated by 16x16 Gauss–Legendre over the two segments; the closed-form direct term \((e^{-\gamma R}-1)/R\) is evaluated at every node, the spectral part \(S(\rho) = \int \lambda F J_0(\lambda\rho)\,d\lambda\) on 24 log-spaced \(\rho\) nodes and interpolated (segments assumed approximately horizontal, mean depths per segment). Segments that cross the soil surface or a layer interface are split there first.
Along the line of closest approach of a segment with itself, or of two segments that come close (wires beside each other, a core in its shield), the integrand has a kink: the \(\gamma^2 R/2\) term of the direct part and the corresponding term of \(S\), smoothed only over the decay length of the spectral weight. The tensor rule cannot follow it: the self correction of a buried segment was 4.8e-4 off at a quarter skin depth (100 Ω·m), up to 1.5e-3 for two wires 1 mm apart in 30 over 1000 Ω·m. Since user decision Q34
- the self term of a (sub-)segment is the exact one-dimensional
reduction \(2\int_0^L (L - u)\,g(u)\,du\) of its double integral (one
spectral plan per segment, so \(g\) depends on \(u = |s - s'|\) only), with
graded 16-node panels (
_self_values()); - a close pair (closest distance of the Gauss nodes below half the
longer segment) gets a graded rule along the line of closest approach
(
_close_pair_values()); for two coinciding segments it is the self rule; - the other pairs keep the tensor rule (16x16, composite for segments longer than a quarter skin depth).
The self correction is within 1.1e-9 of a refined rule (1024 logarithmic \(\lambda\) nodes) and of an independent reference (closed-form direct part, the \(\mathrm{Ji}_0\) kernel of the spectral part; audit W3B) from 1 m and 0.01 skin depths to 3 km at 50 Hz and 1 kHz and has no step where the rule changes (below 3e-13); close pairs are within about 4e-8 of the same two references (3.5e-8 for two 1 m wires 1 mm apart in 30 over 1000 Ω·m at 1 kHz, 2.7e-9 at a quarter skin depth). Up to audit W3B-01 the logarithmic region of the \(\lambda\) grid had 64 nodes and short segments missed the skin-scale part of \(S\): 1e-5 … 7.4e-5 at 0.01 skin depths, up to 3e-4 at 1 m (9e-9 of the input impedance of a 200 m PEN in 1 m pieces). Both rules cost at most linearly in the length: a lumped conductor of 2 km between a rod and a junction is solved in 1.1 s within 0.21 GB (audit W2B-05: 28 s, 1.6 GB, about \(L^{2.7}\)).
The \(\lambda\) quadrature (review pass 10, finding 10.36) follows the
F14 policy of groundfield.coupling.layered_green: a
logarithmic region on \([\epsilon, \lambda_\text{b}]\) with
\(\lambda_\text{b} \le \pi/(4\rho_\text{max})\) so that it is free
of \(J_0\) oscillations, followed by Gauss panels of width
\(\le \pi/\rho_\text{max}\) (16 nodes per \(J_0\) period), geometrically
graded near the skin and decay scales, up to
\(\lambda_\text{max} = 30/z\). Before the fix the log region ended at
\(\max(p_\text{skin}, 1/z)\) regardless of the distance, so \(J_0\) went
unresolved for distant pairs (Re −24 % at 200 m, +274 % at 400 m),
and a 4096-panel cap truncated silently. The node budget is now
explicit: beyond a soft limit the density drops to 8 nodes per period,
and a SommerfeldResolutionWarning
is raised instead of a silent truncation when even that does not fit.
build_sommerfeld_correction_matrices() evaluates several
frequencies at once (finding 10.60): geometry, \(\lambda\) grid and the
Bessel table are built once per pair and reused for every frequency
whose grid is identical (the common case — the grid depends on the
frequency only through skin scales above \(1/z\)). Each frequency's
matrix equals the single-frequency result bit for bit.
Limit checks (built into the test suite)
- \(\sigma_e\to 0\): \(\Delta Z_\text{none} \to 0\), and with
image="additive"the correction cancels the mirror exactly for every orientation. - \(\sigma_e\to\infty\), overhead pair: \(-\Gamma \to -1\), the net image becomes the anti-parallel PEC image (Carson's baseline).
- \(\sigma_e\to\infty\), buried pair: \(e^{-\gamma R} \to 0\) — the conductor is screened by the surrounding medium.
- Long parallel buried wires: the per-metre limit reproduces Pollaczek's \(\frac{j\omega\mu_0}{2\pi}\bigl[K_0(\gamma d) - K_0(\gamma D') + J_P\bigr]\).
- A three-layer earth with \(\rho_2 = \rho_3\) reproduces the two-layer result.
References
- Stratton, J. A. (1941). Electromagnetic Theory, McGraw-Hill, §9-10 — derivation of the half-space vector potential.
- Sommerfeld, A. (1909). Über die Ausbreitung der Wellen in der drahtlosen Telegraphie. Ann. Phys. 28(4), 665–736.
- Wait, J. R. (1972). Electromagnetic Waves in Stratified Media, Pergamon. Ch. 3.
- Chew, W. C. (1995). Waves and Fields in Inhomogeneous Media, IEEE Press, §2.1 (generalised reflection coefficients).
- Tsiamitros, D. A. et al. (2005). Earth return path impedances of underground cables for the two-layer earth case. IEEE Trans. Power Delivery 20(3), 2174–2181.
ImageConvention
module-attribute
¶
Image convention of an inductance matrix.
"none": free space, no image;"additive": perfect magnetic mirror at the soil surface (ADR-0004);"antiparallel": perfect electric mirror, Carson's baseline.
MU_0
module-attribute
¶
Vacuum permeability μ0 = 4π · 10⁻⁷ H/m (the conventional value).
SommerfeldAssembly
module-attribute
¶
Assembly of the Sommerfeld earth-return correction matrix.
"exact": one spectral quadrature per segment pair;"tabulated": shared S(rho) tables per pair of depth groups and frequency (the default ofgroundfield.Engine.sommerfeld_assemblysince 2026.11).
LayeredEarth
dataclass
¶
Frozen layered-earth configuration for the Sommerfeld kernel.
Attributes:
| Name | Type | Description |
|---|---|---|
rhos |
tuple[float, ...]
|
Resistivities \(\rho_1, \dots, \rho_n\) of the layers in \(\Omega\,\mathrm{m}\). The last entry is the semi-infinite bottom layer. |
thicknesses |
tuple[float, ...]
|
Thicknesses \(h_1, \dots, h_{n-1}\) in metres. The bottom
layer has no thickness (semi-infinite). For
|
Notes
Numerical precision contract. The reflection-coefficient
evaluators (reflection_coefficient_homogeneous(),
reflection_coefficient_layered()) and every consumer of
this dataclass operate in IEEE-754 double precision (FP64).
Future hardware-accelerated backends (e.g. an MLX path on Apple
silicon) must honour the same precision. np.complex128 is the
default at every entry point and is preserved through the
Sommerfeld quadrature; do not silently down-cast to FP32 in a
derived backend.
SommerfeldResolutionWarning ¶
Bases: UserWarning
The Sommerfeld quadrature could not resolve the \(J_0\) oscillations.
The linear region of the Hankel grid places one Gauss panel per
\(J_0(\lambda s)\) period, so the node count grows like
\(\lambda_\text{max}\,s\). A hard node budget
(_HANKEL_MAX_LINEAR_NODES) bounds the transient allocation;
when that budget forces fewer than
_HANKEL_MIN_NODES_PER_OSCILLATION nodes per period the
quadrature is no longer converged and this warning is raised
instead of returning a silently wrong number (a coarse grid on an
oscillatory integrand does not merely lose digits — it can flip the
sign of the result).
The remedy is always to lower lambda_max_factor or to reduce
the horizontal distance range of the group. Lowering the factor
does not lose accuracy: the truncated tail is subtracted in
closed form (_reflected_image_terms()), so a smaller
\(\lambda_\text{max}\) only moves work from the quadrature into the
exact image sum. Silence with
warnings.simplefilter("ignore", SommerfeldResolutionWarning)
only if the affected entries are known to be negligible.
build_sommerfeld_correction_matrices ¶
build_sommerfeld_correction_matrices(seg_endpoints: ndarray, wire_radii: ndarray | None = None, *, omegas: Sequence[float], earth: LayeredEarth, image: ImageConvention = 'additive', method: SommerfeldAssembly = 'exact') -> np.ndarray
Sommerfeld earth-return correction matrices for several frequencies.
Multi-frequency form of build_sommerfeld_correction_matrix()
(finding 10.60): per segment pair the outer geometry, the
\(\lambda\) grid and the Bessel table \(J_0(\lambda\rho)\) — about
three quarters of the historic per-frequency cost — are built once
and reused for every frequency with the same grid. Entry k
equals build_sommerfeld_correction_matrix(..., omega=omegas[k])
bit for bit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seg_endpoints
|
ndarray
|
Array of shape |
required |
wire_radii
|
ndarray | None
|
Per-branch wire radii in m. Only used with an image convention:
a mirrored partner that interpenetrates a segment is evaluated as
a touching wire, as in
|
None
|
omegas
|
Sequence[float]
|
Angular frequencies in rad/s; entries |
required |
earth
|
LayeredEarth
|
Layered-earth configuration. |
required |
image
|
ImageConvention
|
Image convention of the inductance matrix the corrections are
added to: |
'additive'
|
method
|
SommerfeldAssembly
|
|
'exact'
|
Returns:
| Name | Type | Description |
|---|---|---|
dZ |
np.ndarray, shape (n_f, M, M), dtype complex
|
Symmetric correction matrices in Ω. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/groundfield/coupling/sommerfeld_inductance.py
2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 | |
build_sommerfeld_correction_matrix ¶
build_sommerfeld_correction_matrix(seg_endpoints: ndarray, wire_radii: ndarray | None = None, *, omega: float, earth: LayeredEarth, image: ImageConvention = 'additive', method: SommerfeldAssembly = 'exact') -> np.ndarray
Assemble the dense Sommerfeld earth-return correction matrix.
The output is the σ-dependent addition to the Neumann inductance
matrix of
groundfield.coupling.inductance.build_inductance_matrix()
built with the same image convention:
.. code-block:: python
Z_b = jω · L(image=image) + dZ_Sommerfeld(image=image)
For earth.n_layers == 1 this is the homogeneous-earth
Pollaczek kernel; for n >= 2 the exact layered kernel is used.
Several frequencies at once: build_sommerfeld_correction_matrices().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seg_endpoints
|
ndarray
|
Array of shape |
required |
wire_radii
|
ndarray | None
|
Per-branch wire radii in m (only used with an image convention,
see |
None
|
omega
|
float
|
Angular frequency in rad/s. |
required |
earth
|
LayeredEarth
|
Layered-earth configuration. |
required |
image
|
ImageConvention
|
|
'additive'
|
method
|
SommerfeldAssembly
|
|
'exact'
|
Returns:
| Name | Type | Description |
|---|---|---|
dZ |
np.ndarray, shape (M, M), dtype complex
|
Symmetric Sommerfeld correction matrix in \(\Omega\). |
Source code in src/groundfield/coupling/sommerfeld_inductance.py
2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 | |
earth_return_correction_homogeneous ¶
earth_return_correction_homogeneous(*, rho: float, z_i: float, z_j: float, omega: float, sigma_earth: float) -> complex
σ-dependent earth-return correction beyond the additive mirror.
Point-kernel form of the buried–buried Pollaczek correction (see the module docstring):
with \(R = \sqrt{\rho^2 + (z - z')^2}\), \(R' = \sqrt{\rho^2 + (z + z')^2}\). This is the σ-dependent piece to be added to the ADR-0004 result (which carries \(1/R + 1/R'\)): the \(-1/R'\) removes the additive mirror, the attenuated direct term carries the buried-path earth-return resistance, and the \(\lambda/u_1\)-weighted reflection is the genuine soil-side boundary response.
Limit checks:
- \(\sigma_e \to 0\): \(\gamma \to 0\), \(\Gamma \to 0\) — correction \(\to -1/R'\) → cancels the ADR-0004 image, total → free space \(1/R\).
- \(\sigma_e \to \infty\): \(e^{-\gamma R} \to 0\), \(\lambda/u_1 \to 0\) — correction \(\to -1/R - 1/R'\), total → 0 (buried conductor screened by the surrounding medium).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rho
|
float
|
Horizontal distance between source and field point in m. Must be ≥ 0. |
required |
z_i
|
float
|
Depths (positive into soil) in m. Must be > 0 for the integral to converge. |
required |
z_j
|
float
|
Depths (positive into soil) in m. Must be > 0 for the integral to converge. |
required |
omega
|
float
|
Angular frequency in rad/s. |
required |
sigma_earth
|
float
|
Earth conductivity in S/m. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
correction |
complex
|
The kernel above in 1/m (the pair integrals multiply by \(j\omega\mu_0/(4\pi)\) and integrate over both segments). |
Source code in src/groundfield/coupling/sommerfeld_inductance.py
earth_return_correction_layered ¶
earth_return_correction_layered(*, rho: float, z_i: float, z_j: float, omega: float, earth: LayeredEarth) -> complex
Layered-earth analogue of earth_return_correction_homogeneous().
Buried–buried point kernel beyond the additive mirror, \(\Delta G = G - 1/R - 1/R'\), with the exact layered Green's function of the module docstring: the generalised-reflection closed form for points in the same layer, the transmitted amplitude otherwise. Review pass 10 (finding 10.46, pass-9 F50): the historic implementation used the single air-image form with the stack's surface reflection coefficient, whose reflected term has the opposite sign of the exact two-layer kernel (e.g. +8.7e-3 instead of −6.3e-3 at \(\rho = 0\) for earth (100, 10) Ω·m, \(h_1\) = 3 m, 1 kHz, \(z = z' = 0.6\) m).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rho
|
float
|
Horizontal distance in m (≥ 0). |
required |
z_i
|
float
|
Depths of observer and source in m (> 0, in the soil). |
required |
z_j
|
float
|
Depths of observer and source in m (> 0, in the soil). |
required |
omega
|
float
|
Angular frequency in rad/s. |
required |
earth
|
LayeredEarth
|
Layered-earth configuration. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
correction |
complex
|
Kernel value in 1/m. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/groundfield/coupling/sommerfeld_inductance.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 | |
per_metre_mutual_impedance ¶
per_metre_mutual_impedance(z_i: float, z_j: float, distance: float, *, omega: float, earth: LayeredEarth) -> complex
Mutual impedance per metre of two infinite parallel horizontal wires.
Exact quasi-static earth-return impedance (Ω/m) of two long parallel
wires at depths z_i, z_j (m, z > 0 in the soil, z < 0
overhead; both on one side of the surface, buried ones in one layer) at
the horizontal distance distance (m) over the layered earth: the
line integral of the Green's function of the module docstring,
\(\int_{-\infty}^{\infty} J_0(\lambda\sqrt{x^2 + s^2})\,ds =
2\cos(\lambda x)/\lambda\),
for wires in layer \(k\) (\(R = \sqrt{x^2 + (z_i - z_j)^2}\), \(w\) the
reflected amplitude of the same-layer kernel, exact for any number of
layers), and \(\frac{j\omega\mu_0}{4\pi}\int_0^\infty
[e^{-\lambda|z_i - z_j|} - \Gamma(\lambda)e^{-\lambda(h_i + h_j)}]
\,2\cos(\lambda x)/\lambda\,d\lambda\) for overhead wires (Carson's
integral with the surface reflection coefficient of the stack). The
self impedance per metre of a wire is the value at distance equal to
its radius (or GMR). The \(\lambda\) quadrature is the one of the segment
pairs (finding 10.36) with four times the nodes. For a homogeneous earth
this is Carson's (overhead) and Pollaczek's (buried) impedance; it agrees
with Carson to 2e-9 and with the two-layer Pollaczek integral of
groundfield.references.pollaczek to 5e-8 of the impedance
(0.1 … 300 m). Against an independent integral (audit W3B-08: composite
Gauss, checked against mpmath to 2e-15; one to four layers, 50 Hz and
1 kHz, 1 cm … 1 km) it is within 6e-8 of the earth-return correction up
to 300 m and 7e-7 at 1 km for buried pairs, 4e-8 for overhead pairs;
the remainder is not the logarithmic region of the \(\lambda\) grid (the
same with 256 and 1024 nodes there).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z_i
|
float
|
Depths of the two wires in m ( |
required |
z_j
|
float
|
Depths of the two wires in m ( |
required |
distance
|
float
|
Horizontal distance in m ( |
required |
omega
|
float
|
Angular frequency in rad/s ( |
required |
earth
|
LayeredEarth
|
Layered-earth configuration. |
required |
Returns:
| Type | Description |
|---|---|
complex
|
Mutual impedance per metre in Ω/m. |
Raises:
| Type | Description |
|---|---|
ValueError
|
For wires on opposite sides of the surface or in different layers, a non-positive distance or frequency. |
Source code in src/groundfield/coupling/sommerfeld_inductance.py
2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 | |
reflection_coefficient_homogeneous ¶
reflection_coefficient_homogeneous(lambdas: ndarray, *, omega: float, sigma_earth: float) -> np.ndarray
Magnetic reflection coefficient for a homogeneous half-space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lambdas
|
ndarray
|
Spectral variable in 1/m, shape |
required |
omega
|
float
|
Angular frequency in rad/s. |
required |
sigma_earth
|
float
|
Earth conductivity in S/m. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Gamma |
(ndarray, complex, shape(N_lam))
|
Reflection coefficient at each \(\lambda\) (dimensionless). |
Source code in src/groundfield/coupling/sommerfeld_inductance.py
reflection_coefficient_layered ¶
reflection_coefficient_layered(lambdas: ndarray, *, omega: float, earth: LayeredEarth) -> np.ndarray
Magnetic surface reflection coefficient of an \(n\)-layer earth.
The generalised reflection coefficient of the whole stack seen
from the air, in the convention of
reflection_coefficient_homogeneous() (so that the air-side
reflection of a downward wave is \(-\Gamma\)). It is built from the
deepest interface upwards,
with \(u_0 = \lambda\) (air) and \(u_k\) the vertical wavenumber of
layer \(k\). It reduces to the homogeneous \(\rho_1\) half-space as
\(h_1 \to \infty\) and to the \(\rho_2\) half-space as \(h_1 \to 0\).
For \(n = 1\) it is reflection_coefficient_homogeneous().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lambdas
|
ndarray
|
Spectral variable in 1/m, shape |
required |
omega
|
float
|
Angular frequency in rad/s. |
required |
earth
|
LayeredEarth
|
Layered-earth configuration. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Gamma |
(ndarray, complex)
|
Surface reflection coefficient (dimensionless). |
Source code in src/groundfield/coupling/sommerfeld_inductance.py
sommerfeld_pair_integral_homogeneous ¶
sommerfeld_pair_integral_homogeneous(p1_a: ndarray, p2_a: ndarray, p1_b: ndarray, p2_b: ndarray, *, omega: float, sigma_earth: float, image: ImageConvention = 'additive') -> complex
Integrate the σ-dependent magnetic Green function over a segment pair.
Computes
the earth-return correction of a homogeneous earth relative to the
image convention image of the inductance matrix it is added to
(see the module docstring). Used by
build_sommerfeld_correction_matrix().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p1_a
|
ndarray
|
End points of the two segments in m (\(z > 0\) in the soil). |
required |
p2_a
|
ndarray
|
End points of the two segments in m (\(z > 0\) in the soil). |
required |
p1_b
|
ndarray
|
End points of the two segments in m (\(z > 0\) in the soil). |
required |
p2_b
|
ndarray
|
End points of the two segments in m (\(z > 0\) in the soil). |
required |
omega
|
float
|
Angular frequency in rad/s. |
required |
sigma_earth
|
float
|
Earth conductivity in S/m. |
required |
image
|
ImageConvention
|
|
'additive'
|
Returns:
| Name | Type | Description |
|---|---|---|
Z |
complex
|
Per-pair earth-return correction in \(\Omega\). |
Source code in src/groundfield/coupling/sommerfeld_inductance.py
sommerfeld_pair_integral_layered ¶
sommerfeld_pair_integral_layered(p1_a: ndarray, p2_a: ndarray, p1_b: ndarray, p2_b: ndarray, *, omega: float, earth: LayeredEarth, image: ImageConvention = 'additive') -> complex
Layered-earth analogue of sommerfeld_pair_integral_homogeneous().
Exact layered kernel for any number of layers (generalised reflection coefficients; transmitted amplitudes for pairs in different media). Segments that cross the soil surface or a layer interface are split there.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p1_a
|
ndarray
|
End points of the two segments in m. |
required |
p2_a
|
ndarray
|
End points of the two segments in m. |
required |
p1_b
|
ndarray
|
End points of the two segments in m. |
required |
p2_b
|
ndarray
|
End points of the two segments in m. |
required |
omega
|
float
|
Angular frequency in rad/s. |
required |
earth
|
LayeredEarth
|
Layered-earth configuration. |
required |
image
|
ImageConvention
|
Image convention of the inductance matrix the correction is
added to ( |
'additive'
|
Returns:
| Name | Type | Description |
|---|---|---|
Z |
complex
|
Per-pair earth-return correction in \(\Omega\). |
Source code in src/groundfield/coupling/sommerfeld_inductance.py
Two-layer scalar Green's function (ADR-0007)¶
layered_green ¶
Cross-layer scalar Green's function for layered soil (ADR-0007).
This module implements the electric (scalar-potential) Green's
function for a 2-layer soil where source and observer can be in
either layer. It complements the existing image-series solver in
groundfield.solver.image_2layer (which assumes both points in
the upper layer) and the Sommerfeld kernel in
groundfield.solver.mom_sommerfeld (same restriction).
Mathematical background
For a 2-layer soil with upper-layer resistivity \(\rho_1\) and thickness \(h_1\), lower-layer resistivity \(\rho_2\) semi-infinite, the scalar Green's function for a unit point source at depth \(z_s\) observed at depth \(z\) takes the Hankel-transform form
where the spectral kernel \(\Phi(\lambda, z, z_s)\) is determined by the boundary-value problem
- \(\partial\Phi/\partial z = 0\) at \(z = 0\) (free surface),
- \(\Phi\) continuous at \(z = h_1\),
- \(\sigma_k\,\partial\Phi/\partial z\) continuous at \(z = h_1\).
In each layer \(\Phi\) is a sum of \(e^{\pm\lambda z}\) plus a particular solution \(e^{-\lambda|z-z_s|}/(2\lambda\sigma_k)\) in the layer that contains the source. The four layer-pair cases — \(\Phi_{uu}, \Phi_{ul}, \Phi_{lu}, \Phi_{ll}\) — correspond to the four (source-layer, observer-layer) combinations and are related by reciprocity (\(\Phi_{ul} = \Phi_{lu}\)).
Implementation
The boundary-value system is solved once per \((\lambda, z_s)\) pair; in its stable form it has three unknowns, and since 2026.11 it is eliminated in closed form, vectorised over the \(\lambda\) nodes (one LAPACK solve per node before, half the time of a cross-layer solve). Per call the cost is then dominated by the \(J_0\) evaluation.
The implementation focuses on the 2-layer case
(groundfield.soil.models.TwoLayerSoil); the n-layer
extension follows the same recursion and is deferred to ADR-0007
Phase C.
Numerical strategy
The Hankel inversion is split into an analytic and a numerical part, because the two halves of \(\Phi\) behave completely differently in \(\lambda\):
- Primary term — the particular solution
\(\rho_k/(2\lambda)\,e^{-\lambda|z-z_s|}\) in the layer that
contains the source. It does not decay when
\(|z - z_s| \to 0\), and its Hankel inverse is known exactly,
\(\rho_k/(2R)\) with \(R = \sqrt{s^2 + (z-z_s)^2}\). It is
therefore evaluated in closed form
(
_primary_term_real_space()). Integrating it numerically instead — as versions up to 0.14.1 did — truncates at \(\lambda_\text{max}\) and leaves an \(O((\lambda_\text{max}R)^{-1/2})\) residue that oscillates in \(s\) with period \(2\pi/\lambda_\text{max}\): up to 4.5 % on the total kernel, and non-monotone inlambda_max_factor. - Reflected remainder — everything generated by the free
surface and the interface. It is a superposition of image terms
\(c_j/(2\lambda)\,e^{-\lambda d_j}\) (
_image_generation()gives the exact coefficients and distances), so it decays like \(e^{-\lambda d_\text{img}}\) with \(d_\text{img} = \min_j d_j\) the smallest image distance — but only in proportion to that distance. Every image distance can degenerate to zero (\(z + z_s \to 0\) for a surface pair, \(|2h_1 - z - z_s| \to 0\) for a pair at the interface, \(z_l - z_u \to 0\) for a cross-layer pair straddling it), and then the remainder does not decay at all and truncating it is not safe. Versions up to 0.15.0.dev sized \(\lambda_\text{max}\) from \(\min(h_1, s + z + z_s)\), which has no relation to \(d_\text{img}\), and were consequently wrong by 0.7 % … 40 % on such pairs with no warning (review pass 9 re-audit). Since 0.15.0 the truncation is guaranteed: every image term with \(\lambda_\text{max} d_j < 30\) is subtracted from the spectral integrand and added back through its exact Hankel inverse \(c_j/(2\sqrt{s^2 + d_j^2})\) (_reflected_image_terms()), so the numerically integrated rest provably decays like \(e^{-\lambda d_\text{rest}}\) with \(\lambda_\text{max} d_\text{rest} \ge 30\) and the discarded tail is bounded by \(e^{-30} \approx 10^{-13}\). The rest goes through the split-grid quadrature (_hankel_lambda_grid()): logarithmic nodes below the first \(J_0\) oscillation, then one Gauss panel per oscillation period, with a documented resolution floor of eight nodes per period and aSommerfeldResolutionWarningwhen the allocation budget cannot meet it.
Because the tail bound above is analytic, \(\lambda_\text{max}\) no
longer has to be large — it only has to be consistent with the set
of subtracted image terms. That is what makes the cost of a remote
pair bounded: the node count of the oscillation-resolved grid grows
like \(\lambda_\text{max}\,s\), so the module caps
\(\lambda_\text{max}\) at _HANKEL_PANEL_TARGET panels (scaled
by lambda_max_factor / 200) and subtracts as many image terms as
that cap requires (_plan_truncation()). A 4 km pair costs the
same as a 90 m one, and lambda_max_factor becomes a genuine
convergence knob: raising it moves work from the closed form into the
quadrature and must not change the answer.
Because the numerically integrated rest is analytic in
\(t = \ln(s + c)\) — and, after the image split above, has no scale
shorter than \(d_\text{rest}\), which is what \(c\) is set to —
reaction blocks with many distance pairs at one \((z, z_s)\) are
evaluated on a range-sized log grid and cubic-spline interpolated
instead of pair by pair (~1e-6 relative, worst case 3e-5; see
two_layer_layered_correction_group()).
Limit checks (in the test suite)
- \(\rho_2 = \rho_1\): all four pair kernels reduce to the homogeneous Green's function \(\rho/(4\pi r) + \rho/(4\pi r')\).
- \(\rho_2 \to \infty\) (PEC bottom): for source in upper layer, \(G_{ul} \to 0\) (no penetration into the lower layer); \(G_{uu} \to G_{uu}^{K \to 1}\) — image structure with \(K \to 1\).
- \(\rho_2 \to 0\) (sink): \(G_{uu} \to G_{uu}^{K \to -1}\), spreading resistance drops dramatically.
- Source/observer in upper layer: bit-exact match to the
Tagg/Sunde image series in
groundfield.solver.image_2layer.solve_image_2layer().
References
- Sunde, E. D. (1968). Earth Conduction Effects in Transmission Systems, Dover, Ch. 3.
- Tagg, G. F. (1964). Earth Resistances, Newnes.
- Wait, J. R. (1972). Electromagnetic Waves in Stratified Media, Pergamon.
SommerfeldResolutionWarning ¶
Bases: UserWarning
The Sommerfeld quadrature could not resolve the \(J_0\) oscillations.
The linear region of the Hankel grid places one Gauss panel per
\(J_0(\lambda s)\) period, so the node count grows like
\(\lambda_\text{max}\,s\). A hard node budget
(_HANKEL_MAX_LINEAR_NODES) bounds the transient allocation;
when that budget forces fewer than
_HANKEL_MIN_NODES_PER_OSCILLATION nodes per period the
quadrature is no longer converged and this warning is raised
instead of returning a silently wrong number (a coarse grid on an
oscillatory integrand does not merely lose digits — it can flip the
sign of the result).
The remedy is always to lower lambda_max_factor or to reduce
the horizontal distance range of the group. Lowering the factor
does not lose accuracy: the truncated tail is subtracted in
closed form (_reflected_image_terms()), so a smaller
\(\lambda_\text{max}\) only moves work from the quadrature into the
exact image sum. Silence with
warnings.simplefilter("ignore", SommerfeldResolutionWarning)
only if the affected entries are known to be negligible.
SommerfeldTailTruncationWarning ¶
Bases: UserWarning
The \(\lambda\)-truncated tail of the reflected kernel is not bounded.
Sibling of SommerfeldResolutionWarning: that one reports a
grid too coarse to follow \(J_0(\lambda s)\), this one a grid too
short to have integrated the reflected remainder.
The reflected part of \(\Phi\) is a superposition of image terms
\(c_j/(2\lambda)\,e^{-\lambda d_j}\), so truncating the Hankel
integral at \(\lambda_\text{max}\) discards
\(\sum_j c_j/2 \int_{\lambda_\text{max}}^\infty e^{-\lambda d_j}
J_0(\lambda s)\,d\lambda\), bounded by
\(\sum_j |c_j| e^{-\lambda_\text{max} d_j}/(2 d_j)\). The bound is
only small if \(\lambda_\text{max} d_j\) is large for every
retained term, and \(d_j\) has nothing to do with the historic
$\lambda_\text{max} = $ lambda_max_factor \(/\min(h_1, s + z +
z_s)\): a pair at the air/soil surface (\(z + z_s \to 0\)), at the
layer interface (\(|2h_1 - z - z_s| \to 0\)) or straddling it has
\(d_j \to 0\) and a tail of order one. Review pass 9 measured
−39.5 % on such a pair with no diagnostic; the failure grows as
a mesh is refined towards the interface, which is what makes it
release-blocking rather than cosmetic.
Every term with $\lambda_\text{max} d_j <
$ _HANKEL_TAIL_DECAY_TARGET is therefore taken out of the
quadrature and inverted in closed form. This warning fires when
that could not be completed — in practice only when the term
budget _HANKEL_IMAGE_TERM_BUDGET is exhausted, which needs
a very thin top layer, \(|K| \to 1\) and a multi-kilometre span at
once. The result is then not bounded by the documented tolerance:
lower lambda_max_factor (fewer image terms are needed), reduce
the distance range, or raise the budget.
layered_correction_group_plan ¶
layered_correction_group_plan(z: float, z_s: float, *, rho_1: float, rho_2: float, h_1: float, rho_baseline: float | None = None, s_min: float, s_max: float, n_pairs: int, lambda_max_factor: float = 200.0, n_log: int = 32, n_lin: int = 96, min_distance: float | None = None, warn_stacklevel: int = 3) -> _CorrectionGroup | None
Plan of two_layer_layered_correction_group() for one depth group.
The λ-grid, the spectral amplitudes, the closed-form image split and the
interpolation of a group depend on its depths, on the range
[s_min, s_max] of its horizontal distances and on its size only. The
returned callable evaluates the correction at any distances of the group
and gives, piece by piece, the values of the one-shot call bit for bit
(except the exact branch, see _SmoothContraction), so the
cross-layer reaction matrix can be assembled in blocks of bounded memory
(review pass 10, 10.56).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z
|
float
|
required | |
z_s
|
float
|
required | |
rho_1
|
float
|
required | |
rho_2
|
float
|
required | |
h_1
|
float
|
required | |
rho_baseline
|
float
|
required | |
lambda_max_factor
|
float
|
required | |
n_log
|
float
|
required | |
n_lin
|
float
|
required | |
min_distance
|
float
|
required | |
s_min
|
float
|
Smallest and largest horizontal distance of the group in m. |
required |
s_max
|
float
|
Smallest and largest horizontal distance of the group in m. |
required |
n_pairs
|
int
|
Number of distance pairs of the group. |
required |
warn_stacklevel
|
int
|
Frames between the warning calls and the caller of this function's caller (3: warnings point at the code that calls this function). |
3
|
Returns:
| Type | Description |
|---|---|
callable or None
|
|
Source code in src/groundfield/coupling/layered_green.py
1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 | |
two_layer_layered_correction_group ¶
two_layer_layered_correction_group(s_values: ndarray, z: float, z_s: float, *, rho_1: float, rho_2: float, h_1: float, rho_baseline: float | None = None, lambda_max_factor: float = 200.0, n_log: int = 32, n_lin: int = 96, min_distance: float | None = None) -> np.ndarray
Vectorised form of two_layer_layered_correction_real_space().
Evaluates the layered correction for many horizontal distances
at one (z, z_s) pair with a single spectral-amplitude solve:
the amplitudes depend on (λ, z, z_s) only, so the per-pair cost
of the historic scalar loop (one BVP solve per matrix entry —
the dominant cost of the ADR-0007 cross-layer reaction-matrix
assembly after the WP-B1 oscillation-resolved grids) collapses
to one BVP solve per (z, z_s) group plus a J0 contraction.
The shared λ-grid is built for the most demanding radius of the
group: the lambda_max_factor bound and the \(1/R\) regularisation
from the smallest s (near-field content), oscillation
resolution, log-region cap and panel-cost budget from the largest
(_plan_truncation()).
Accuracy (review pass 9, finding F15)
Groups above _HANKEL_INTERP_THRESHOLD pairs are sampled on
a log-spaced s-grid and interpolated. Three changes make that
branch agree with the exact per-pair contraction to ~1e-6 relative
(worst case measured 1.1e-5, over ten geometries and every group
size from 60 to 129 pairs; previously up to 1 % for a 400 m span
and 17 % when rho_baseline did not match the source layer):
- the residual primary term
\((\rho_\text{src} - \rho_\text{baseline})/(2\lambda)\,
e^{-\lambda|z-z_s|}\) — which is not zero unless the caller
matches
rho_baselineto the source layer, and which carries a \(1/R\) singularity plus a \(2\pi/\lambda_\text{max}\)-periodic truncation ripple ins— is taken out of the quadrature and added back in closed form, leaving a genuinely analytic integrand; - the node count is sized from the actual dynamic range of the group and the interpolant is a cubic spline, so the accuracy no longer depends on the network extent;
- every reflected image term short enough for the λ-truncation to
matter gets the same treatment as the primary term — closed form,
per pair, outside the interpolation
(
_reflected_image_terms()). This is what removes the 0.7 % … 40 % errors of surface, interface and interface-straddling pairs, and it also smooths what remains: the interpolated function then has no length scale shorter thand_rest, which is what the log-coordinate offset is set to.
Because interpolation is skipped whenever it would need at least as many nodes as the group has pairs, the exact and the interpolated branch also no longer differ observably at the threshold (the historic ~3 % jump between a 64-pair and a 65-pair block is gone; worst deviation over every size from 60 to 129 pairs is 1.1e-5).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
s_values
|
ndarray
|
Horizontal distances in m (any shape, |
required |
z
|
float
|
Observer / source depth in m ( |
required |
z_s
|
float
|
Observer / source depth in m ( |
required |
rho_1
|
float
|
Resistivities of the upper / lower layer in Ω·m. |
required |
rho_2
|
float
|
Resistivities of the upper / lower layer in Ω·m. |
required |
h_1
|
float
|
Upper-layer thickness in m. |
required |
rho_baseline
|
float | None
|
Resistivity of the subtracted homogeneous half-space in Ω·m;
|
None
|
lambda_max_factor
|
float
|
Quadrature controls as in
|
200.0
|
n_log
|
float
|
Quadrature controls as in
|
200.0
|
n_lin
|
float
|
Quadrature controls as in
|
200.0
|
min_distance
|
float | None
|
Regularisation length of the closed-form \(1/R\) terms in m, as in
|
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
The correction, same shape as |
Source code in src/groundfield/coupling/layered_green.py
1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 | |
two_layer_layered_correction_real_space ¶
two_layer_layered_correction_real_space(s: float, z: float, z_s: float, *, rho_1: float, rho_2: float, h_1: float, rho_baseline: float | None = None, lambda_max_factor: float = 200.0, n_log: int = 32, n_lin: int = 96, min_distance: float | None = None) -> float
Real-space layered correction over the homogeneous-rho_1 baseline.
Computes $$ \Delta G(s, z, z_s) \;=\; G_{\text{2-layer}}(s, z, z_s; \rho_1, \rho_2, h_1) \;-\; G_{\text{homog}}(s, z, z_s; \rho_1) $$ by subtracting the spectral kernels before the Hankel integration. The singular source term \(\rho_1/(2\lambda)\,e^{-\lambda|z-z_s|}\) is identical in both spectral kernels and cancels exactly, leaving a smooth, exponentially decaying integrand. Two big advantages:
- In the homogeneous limit \(\rho_2 = \rho_1\) the spectral difference is identically zero at every \(\lambda\), so the integrator returns 0 to machine precision (no spurious diagonal contribution from finite-Sommerfeld-quadrature error at \(z = z_s\)).
- The kernel difference \((a_1 - a_1^{\text{hom}})e^{\lambda z} + (b_1 - b_1^{\text{hom}})e^{-\lambda z}\) has no \(1/(2\lambda)\) piece, so the small-\(\lambda\) region is finite and easy to integrate.
The caller adds this correction on top of the homogeneous
potential computed with the existing
groundfield.solver.image._self_corrected_kernel() (which
correctly handles the line-self diagonal).
The optional rho_baseline parameter selects which homog
soil to subtract:
None(default): subtract homog with \(\rho_1\). Suitable when the calling solver builds \(\phi_\text{hom}\) uniformly with \(\rho_1\).- explicit float: subtract homog with the given resistivity.
Use
rho_2for source segments in the lower layer when the calling solver matches its \(\phi_\text{hom}\) baseline to the source layer (recommended for production-grade solver, ADR-0007 §"Phase A.1").
Returns 0 in the homogeneous limit by construction; otherwise
a finite real value with the same units as
two_layer_real_space_kernel().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
s
|
float
|
Horizontal distance in m ( |
required |
z
|
float
|
Observer / source depth in m ( |
required |
z_s
|
float
|
Observer / source depth in m ( |
required |
rho_1
|
float
|
Resistivities of the upper / lower layer in Ω·m. |
required |
rho_2
|
float
|
Resistivities of the upper / lower layer in Ω·m. |
required |
h_1
|
float
|
Upper-layer thickness in m. |
required |
rho_baseline
|
float | None
|
Resistivity of the subtracted homogeneous half-space in Ω·m (see above). |
None
|
lambda_max_factor
|
float
|
Upper bound on the quadrature truncation and default
regularisation wavenumber, as in
|
200.0
|
n_log
|
int
|
Number of nodes in the logarithmic / linear part of the quadrature grid. |
32
|
n_lin
|
int
|
Number of nodes in the logarithmic / linear part of the quadrature grid. |
32
|
min_distance
|
float | None
|
Regularisation length of the closed-form \(1/R\) terms in m: the
clamp becomes \(\min(1/\lambda_\text{clamp},\) |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
dG |
float
|
Layered correction \(\Delta G\) in the units of
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/groundfield/coupling/layered_green.py
2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 | |
two_layer_probe_matrix ¶
two_layer_probe_matrix(probe_points: ndarray, source_points: ndarray, *, rho_1: float, rho_2: float, h_1: float, min_distance: float = 0.001, lambda_max_factor: float = 200.0) -> np.ndarray
Potential matrix phi = G @ I for arbitrary layer combinations.
Returns the (M, N) matrix with G[m, n] = potential at
probe_points[m] per unit current injected at
source_points[n], evaluated with the full two-layer spectral
kernel (two_layer_real_space_kernel()). Valid for every
probe/source layer combination — upper–upper, cross-layer and
lower–lower — unlike the Tagg/Sunde uu image series that the
fast paths use (audit 2026-07-08, WP-D1: the uu series applied to
layer-2 points was measured +7 % at z = 7 m and +25 % at z = 12 m
for K = +0.818, h_1 = 5 m).
Cost: one spectral-amplitude solve per (z, z_s) depth group plus a
J0 contraction (see "Cost control" below) — reserve for the
sub-blocks that the uu series cannot handle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
probe_points
|
ndarray
|
Observation points, shape |
required |
source_points
|
ndarray
|
Point-source positions, shape |
required |
rho_1
|
float
|
Resistivities of the upper / lower layer in Ω·m. |
required |
rho_2
|
float
|
Resistivities of the upper / lower layer in Ω·m. |
required |
h_1
|
float
|
Upper-layer thickness in m. |
required |
min_distance
|
float
|
Regularisation length of the near-singular pairs in m (see Notes). |
1e-3
|
lambda_max_factor
|
float
|
Upper bound on the quadrature truncation and regularisation
wavenumber, as in |
200.0
|
Returns:
| Name | Type | Description |
|---|---|---|
G |
ndarray
|
Real |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a probe or source point lies above the soil surface
( |
Notes
The near-singularity is regularised like the image-series paths:
the horizontal distance is clamped at min_distance whenever
the vertical separation is below min_distance as well, and the
closed-form \(1/R\) terms are clamped at no more than min_distance
(they were clamped at \(h_1/200\), 25 mm for \(h_1 = 5\) m, up to this
release; audit A3S-01).
Cost control: probe/source pairs are grouped by their (z, z_s)
depth combination (rounded to 1 µm). Within a group the primary
\(1/R\) field is evaluated in closed form at every pair, and the
reflected remainder — analytic in \(t = \ln(s + c)\) — is what the
interpolation sees. Groups larger than
_HANKEL_INTERP_THRESHOLD pairs are sampled on a log-spaced
s-grid whose node count is derived from the group's dynamic
range (_interp_node_count()) and interpolated with a cubic
spline, keeping surface-grid evaluations tractable.
Accuracy (review pass 9, finding F15)
The historic fixed 48-node linear interpolation of the total
kernel was documented at "relative error ≲ 1e-4" but measured
2.1e-3, because (a) the node count ignored the dynamic range of
s and (b) the total kernel contains the \(1/R\) primary term
whose λ-truncated quadrature ripples in s with period
\(2\pi/\lambda_\text{max}\) — a ripple no coarse interpolant can
follow. With the primary term and the degenerate image terms in
closed form and range-sized cubic nodes, the interpolated and the
exact per-pair branch agree to 8e-7 relative (measured over
surface, equal-depth-in-layer-2 and cross-layer probe/source
combinations, 400 probes over a 90 m square), i.e. the documented
1e-4 holds with two orders of margin — not the "four orders" and
"~1e-8" that stood here at 0.15.0.dev, which were 2–3 orders
optimistic and contradicted both the module header and
docs/api/coupling.md.
Source code in src/groundfield/coupling/layered_green.py
2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 | |
two_layer_real_space_kernel ¶
two_layer_real_space_kernel(s: float, z: float, z_s: float, *, rho_1: float, rho_2: float, h_1: float, lambda_max_factor: float = 200.0, n_log: int = 32, n_lin: int = 96, min_distance: float | None = None) -> float
Cross-layer real-space scalar Green's function \(\varphi(s, z, z_s)\).
Computes \(\varphi(s, z, z_s) / I = \int_0^\infty
\Phi(\lambda, z, z_s)\,J_0(\lambda s)\,\lambda\,d\lambda\)
for a unit point source at \((0, 0, z_s)\) observed at \((s, 0, z)\).
The result already includes the \(1/(4\pi)\)-style prefactor that
is conventional in the existing mom_sommerfeld kernel
representation.
Numerical strategy: the primary (source-layer particular) term is
evaluated in closed form as \(\rho_k/(2R)\) with
\(R = \sqrt{s^2 + (z-z_s)^2}\)
(_primary_term_real_space()), and so is every reflected image
term whose distance is too short for the truncation at
\(\lambda_\text{max}\) to be negligible
(_reflected_image_terms(), _plan_truncation()); only the
provably fast-decaying rest goes through the split-grid Sommerfeld
quadrature (logarithmic for small \(\lambda\), oscillation-resolved
for large \(\lambda\)) consistent with
groundfield.coupling.sommerfeld_inductance (ADR-0006).
Measured against an independently derived closed form (image
expansion summed to convergence): ~3e-10 relative for surface
pairs, interface pairs, pairs a millimetre below the interface,
cross-layer pairs straddling it, and radii from 0 to 20 km — and
identical to ten digits for lambda_max_factor anywhere in
30 … 30 000. Up to 0.15.0.dev the same geometries were wrong by
0.7 % … 40 % with no warning, and non-monotone in the knob.
Splitting the primary term off matters because it is the only part
of \(\Phi\) that does not decay in \(\lambda\): integrating it
numerically up to \(\lambda_\text{max}\) left an
\(O((\lambda_\text{max}R)^{-1/2})\) oscillatory residue — measured
−4.5 % at \(s = 1\) m and ±4 % swings with period
\(2\pi/\lambda_\text{max} \approx 0.03\) m for equal-depth pairs,
and non-monotone in lambda_max_factor. In the homogeneous
limit \(\rho_2 = \rho_1\) the closed form now reproduces
\(\rho/2\,(1/r + 1/r')\) to ~1e-13 instead of ~1e-2.
For s = 0 and z = z_s every \(1/R\) pole is clamped at
\(R = 1/\lambda_\text{clamp}\) with \(\lambda_\text{clamp} =\)
lambda_max_factor \(/\min(h_1, s + z + z_s)\) — so the return
value stays finite and continuous and depends only on the knob and
the depths, but it is not a physical potential: the caller must
regularise at the wire radius. The same clamp applies to every
\(R < 1/\lambda_\text{clamp}\) (25 mm for \(h_1 = 5\) m); a caller
that evaluates closer pairs passes its own min_distance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
s
|
float
|
Cylindrical radius in m, \(\ge 0\). |
required |
z
|
float
|
Observer / source depths in m, \(\ge 0\) (positive into the
soil). Negative depths raise |
required |
z_s
|
float
|
Observer / source depths in m, \(\ge 0\) (positive into the
soil). Negative depths raise |
required |
rho_1
|
float
|
Two-layer soil parameters. |
required |
rho_2
|
float
|
Two-layer soil parameters. |
required |
h_1
|
float
|
Two-layer soil parameters. |
required |
lambda_max_factor
|
float
|
Upper bound on the quadrature truncation, as a multiple of
\(1/\bar h\) with \(\bar h = \min(h_1, s + z + z_s)\), and the
regularisation wavenumber of the \(1/R\) poles. It is not the
truncation actually used: since 0.15.0 the truncated tail is
bounded by a closed-form image split rather than by making
\(\lambda_\text{max}\) large, so \(\lambda_\text{max}\) is
lowered to whatever that split allows
( |
200.0
|
n_log
|
int
|
Number of nodes in the logarithmic / linear part of the quadrature grid. |
32
|
n_lin
|
int
|
Number of nodes in the logarithmic / linear part of the quadrature grid. |
32
|
min_distance
|
float | None
|
Regularisation length of the closed-form \(1/R\) terms in m: they
are clamped at \(\min(1/\lambda_\text{clamp},\) |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
G |
float
|
Real-space scalar Green's function (dimensionless after dividing by \(\rho\)). |
Source code in src/groundfield/coupling/layered_green.py
1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 | |
two_layer_spectral_kernel ¶
two_layer_spectral_kernel(lambdas: ndarray, z: float, z_s: float, *, rho_1: float, rho_2: float, h_1: float) -> np.ndarray
Spectral Green's function \(\Phi(\lambda, z, z_s)\).
Returns the value of the spectral kernel at every \(\lambda\)
in lambdas for given source depth \(z_s\) and observer depth
\(z\). Both depths can be in either layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lambdas
|
ndarray
|
1-D array of spectral variable values, \(\lambda > 0\) in units of m⁻¹. |
required |
z
|
float
|
Observer / source depth in metres (\(z \ge 0\), positive into the soil). |
required |
z_s
|
float
|
Observer / source depth in metres (\(z \ge 0\), positive into the soil). |
required |
rho_1
|
float
|
Resistivities of upper / lower layer in \(\Omega\,\mathrm{m}\). |
required |
rho_2
|
float
|
Resistivities of upper / lower layer in \(\Omega\,\mathrm{m}\). |
required |
h_1
|
float
|
Upper-layer thickness in m. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Phi |
(ndarray, shape(n_lambda))
|
|
Source code in src/groundfield/coupling/layered_green.py
Earth-model resolvers¶
resolve_earth_conductivity ¶
Resolve earth conductivity \(\sigma_\text{earth}\) from a soil model.
Used by the Carson earth-return correction (ADR-0005) to get a single scalar conductivity from the (potentially layered) soil model. The mapping is:
HomogeneousSoil→ \(\sigma = 1/\rho\), exact.TwoLayerSoil→ \(\sigma = 1/\rho_1\) (upper layer), with a runtime warning.MultiLayerSoil→ \(\sigma = 1/\rho_1\) (top layer), with a runtime warning.
The layered cases are an approximation; the Pollaczek/Sommerfeld
kernel (earth_inductive_model="sommerfeld") is the rigorous
alternative.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
soil
|
Any concrete soil model from
|
required |
Returns:
| Name | Type | Description |
|---|---|---|
sigma_earth |
float
|
Earth conductivity in S/m. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the soil model has no resistivity field that can be interpreted as an upper-layer value. |
Source code in src/groundfield/coupling/__init__.py
resolve_earth_layers ¶
Resolve a soil model into a LayeredEarth configuration.
Used by the Sommerfeld earth-return kernel (ADR-0006). Unlike
resolve_earth_conductivity(), this preserves the full
layered structure — no warning is emitted: the kernel is exact for
any number of layers (generalised reflection coefficients, review
pass 10, finding 10.35; before that, n >= 3 used a single
air-image approximation that was 17–25 % off in the earth-return
reactance).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
soil
|
Any concrete soil model from
|
required |
Returns:
| Type | Description |
|---|---|
LayeredEarth
|
Frozen layered-earth configuration (resistivities and layer
thicknesses) consumable by
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |