Coupling¶
The groundfield.coupling package collects every conductor-to-conductor
and conductor-to-earth coupling relation that the solvers consume.
The structure mirrors the physical decomposition: galvanic coupling
through cluster nodes (handled by the solver builder, no module of
its own), inductive coupling between distributed-conductor segments
(inductance.py, ADR-0004), and the Carson earth-return correction
that adds finite-conductivity effects to the inductive matrix
(carson.py, ADR-0005).
Inductance — Neumann self and mutual integrals (ADR-0004)¶
Implements the Neumann partial-inductance assembly under a perfect-mirror earth assumption. Each pair of distributed-conductor segments contributes a self- or mutual-inductance entry to the branch-impedance block
The thin-wire self-inductance uses Grover 1946 (closed form, plus optional internal-field \(\mu_0/(8\pi)\) contribution for the DC limit). Off-diagonal entries are evaluated by a closed-form parallel-segments fast path or, for arbitrary 3-D geometries, by a 16×16 Gauss–Legendre quadrature of the Neumann double-line integral. The image of every segment in the soil surface contributes one extra Neumann integral against the original — this is the perfect-mirror assumption and the starting point for the Carson refinement.
inductance ¶
Self- and mutual-inductance helpers for distributed conductors.
This module implements the inductance physics described in ADR-0004. It provides three public functions:
- :func:
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]\). - :func:
parallel_segments_mutual— closed-form mutual inductance of two parallel coaxial segments of equal length \(\ell\) at perpendicular distance \(d\). - :func:
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
:func:perfect_mirror_self_pair_inductance and the assembly logic
in :func:build_inductance_matrix).
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.
build_carson_correction_matrix ¶
build_carson_correction_matrix(
seg_endpoints: np.ndarray,
wire_radii: np.ndarray,
*,
omega: float,
sigma_earth: float
) -> np.ndarray
Assemble the dense Carson earth-return correction matrix.
Adds the per-segment-pair impedance correction
\(\Delta Z^{(i,j)}_\text{Carson}(\omega)\) described in ADR-0005
on top of the perfect-mirror Neumann inductance matrix. The
output has the same shape as :func:build_inductance_matrix
but is complex and frequency-dependent — it is therefore
rebuilt at every frequency by the solver.
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. The historic implementation additionally added a "mutual" term per collinear pair — with the axial midpoint distance misread as Carson's perpendicular wire separation — which made the assembled correction grow roughly linearly with the segment count (measured in the audit: no mesh convergence).
- Near-parallel pairs on distinct axes (
|cosφ| > 0.99): mutual correction per metre at the perpendicular horizontal axis separation, weighted by the axial overlap length of the two segment intervals. Summing over the segments of the other wire recoversz'_mutual · ℓ_iexactly — refinement- invariant. Non-overlapping (e.g. staggered or end-to-end) pairs contribute zero: the long-range log tail is treated as part of the infinite-wire per-metre value, in line with the transmission-line locality of Carson's derivation. - Oblique pairs (
1e-9 < |cosφ| ≤ 0.99): the historic projected geometric-mean heuristic is retained (Carson's derivation only covers parallel wires; oblique pairs are rare in Manhattan-routed networks). 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\)). For the PEN cable at
\(z = 0.6\,\mathrm{m}\) this produces the textbook
"1 m below surface" Carson result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seg_endpoints
|
ndarray
|
Array of shape |
required |
wire_radii
|
ndarray
|
Per-branch wire radii in metres (currently only used as a
regulariser when two segments would coincide; the Carson
kernel itself does not depend on the radius — that is in
the perfect-mirror \(\ln(2h/a)\) piece, which stays where
it was in :func: |
required |
omega
|
float
|
Angular frequency in rad/s. |
required |
sigma_earth
|
float
|
Earth conductivity in S/m. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dZ |
np.ndarray, shape (M, M), dtype complex
|
Symmetric Carson correction matrix in \(\Omega\). Entry
|
Source code in src/groundfield/coupling/inductance.py
721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 | |
build_inductance_matrix ¶
build_inductance_matrix(
seg_endpoints: np.ndarray,
wire_radii: np.ndarray,
*,
use_image: bool = True
) -> np.ndarray
Assemble the dense partial-inductance matrix over branches.
Vectorised implementation per ADR-0010 Tier 0b. Reproduces
:func:_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
|
When |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
L |
(ndarray, shape(M, M))
|
Symmetric partial-inductance matrix in H. Entry |
Notes
The legacy loop-based implementation is kept as
:func:_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
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 | |
neumann_mutual ¶
neumann_mutual(
p1_a: np.ndarray,
p2_a: np.ndarray,
p1_b: np.ndarray,
p2_b: np.ndarray,
*,
min_distance: float = 1e-06,
parallel_tol: float = 1e-09
) -> float
Neumann mutual-inductance integral between two straight segments.
Hybrid implementation:
- If the two segments are parallel (or anti-parallel) within
parallel_tol, the closed-form Grover expression in :func:_parallel_filaments_mutualis used — exact, no quadrature error. This fast path covers the bulk of the typical inductance assembly (parallel PEN strands, consecutive sub-segments along the same conductor). - Otherwise the Neumann double integral is evaluated by 16×16 Gauss–Legendre quadrature. Empirically accurate to ≲ 0.05 % across the typical geometry range; see ADR-0004 for the calibration data.
The kernel \(1/r\) is clamped at min_distance to suppress the
integrable singularity for segments that touch — physically the
diagonal uses :func: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
|
Returns:
| Name | Type | Description |
|---|---|---|
M |
float
|
Partial mutual inductance in H. |
Source code in src/groundfield/coupling/inductance.py
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |
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. |
Source code in src/groundfield/coupling/inductance.py
perfect_mirror_self_pair_inductance ¶
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.
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 |
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. For high-frequency studies
where the current flows on the surface only (skin effect at
\(f \gg f_\text{skin}\)), pass include_internal=False and
the external term alone is returned.
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. |
Source code in src/groundfield/coupling/inductance.py
Carson earth-return correction (ADR-0005)¶
Adds Carson 1926's finite-conductivity correction \(\Delta Z_\text{Carson}(\omega)\) on top of the perfect-mirror inductance. The branch-impedance block becomes
The correction is evaluated as
with \(D = 2h_i\) (\(\theta = 0\)) for the self contribution and \(D = \sqrt{(h_i+h_j)^2 + d_{ij}^2}\), \(\theta = \arctan(d_{ij}/(h_i+h_j))\) for the mutual contribution. \(\delta(\omega) = \sqrt{2 / (\omega\mu_0\sigma_\text{earth})}\) is the electromagnetic skin depth in soil — the natural length scale at which the perfect-mirror approximation starts to break down.
Three regimes¶
Following Carson 1926 §III the implementation switches between three numerical regimes:
| Regime | Range of \(a\) | Method |
|---|---|---|
| Small | \(a \le 0.25\) | Closed-form leading-term expansion (Carson eqs. 34/35) |
| Intermediate | \(0.25 < a \le 5\) | 64-point Gauss–Legendre quadrature of Carson eq. 29 |
| Asymptotic | \(a > 5\) | Inverse-power expansion (Carson eqs. 36/37) |
Validity and limitations¶
- Homogeneous soil — the Carson series is exact (within the quasi-static / sub-kHz assumption Carson himself states) when \(\sigma_\text{earth}\) is uniform.
- Layered soil — the implementation falls back to
\(\sigma = 1/\rho_1\) of the upper layer with a runtime
UserWarning. For a rigorous result switch tobackend="mom_sommerfeld", which uses the full Pollaczek kernel. - Frequency — derived for \(\omega \ll 1 / \mu_0\sigma\); for typical (sub-kHz, \(\rho_\text{earth} \in [50, 5000]\,\Omega\,\mathrm{m}\)) the assumption is comfortably satisfied.
- Geometry — Carson's derivation assumes parallel wires above a plane homogeneous half-space. Non-parallel segment pairs are handled by projection onto the parallel component (orthogonal components contribute zero by Neumann symmetry).
carson ¶
Carson 1926 correction for the earth-return path.
This module implements the magnetic-image correction described in
ADR-0005. It complements the perfect-mirror Neumann assembly from
ADR-0004 (in :mod:groundfield.coupling.inductance) with the
finite-conductivity contribution that Carson 1926 derived for a
homogeneous, semi-infinite, conductive half-space.
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 eqs. 34/35, leading-term form. Closed form, only \(\sin / \cos / \ln\).
- Intermediate \(a\) (\(0.25 < a \le 5\)) — direct numerical quadrature of Carson's \(J(p, q)\) via Gauss–Legendre on a truncated interval. The original Carson 1926 series in that range is technically convergent but its recurrence is numerically delicate; quadrature is robust and converges to machine precision in \(\le 64\) nodes.
- Large \(a\) (\(a > 5\)) — Carson eqs. 36/37, asymptotic expansion in inverse powers of \(a\).
Every regime boundary is smoke-tested for continuity at
\(\le 10^{-6}\) — see :mod:tests.test_carson_coupling.
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 (:func:
deri_semlyen_correction); it is not the production code path.
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.
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}\). |
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\): closed-form leading-term expansion (Carson eqs. 34/35).
- \(0.25 < a \le 5\): 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 > 5\): asymptotic expansion (Carson eqs. 36/37), except for \(\theta > 1.4\) rad where the expansion degrades and the quadrature path is used instead.
The regimes are continuous at the boundaries to within the tolerances documented in ADR-0005 §5/§6.
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\). |
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 :func: |
required |
height_i
|
float
|
Same meaning as in :func: |
required |
height_j
|
float
|
Same meaning as in :func: |
required |
horizontal_distance
|
float
|
Same meaning as in :func: |
required |
sigma_earth
|
float
|
Same meaning as in :func: |
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 geometric earth-return Green's function (ADR-0006)¶
The rigorous formulation of the earth-return inductive coupling. Integrates the σ-dependent vector-potential Green's function
over the actual segment-pair geometry, where the reflection coefficient \(\Gamma_\text{mag}\) encodes the homogeneous or layered-earth structure. Reduces to the perfect-mirror case at \(\sigma\to\infty\), to free space at \(\sigma\to 0\), and converges to ADR-0005's per-meter Carson asymptote for long parallel wires over homogeneous earth. Unlike Carson, it correctly handles short wires, non-parallel geometries, and layered earth without approximation (Pollaczek/Wait kernel).
When to use which¶
| Problem class | Recommended option |
|---|---|
| Reference computations, layered earth, mixed wire lengths | "sommerfeld" |
| Long parallel PEN over homogeneous earth, fast scoping | "carson_series" |
| Pure DC studies, perfect-mirror reference | "perfect_mirror" |
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
(Rewritten in the 2026-07-08 audit, WP-C1: the historic kernel
1/R + ∫Γ·e^{-λ(z+z')}J0 dropped the in-soil propagation of the
primary term — precisely where the buried-wire earth-return
resistance lives — and applied the soil-side reflection sign to
overhead conductors. The implemented kernel is now the genuine
quasi-static Pollaczek form, dispatched by which side of the soil
surface the two segments are on.)
For a horizontal current element in a conducting half-space (\(z > 0\) soil, \(z < 0\) air, \(\gamma^2 = j\omega\mu_0\sigma_1\), \(u_1 = \sqrt{\lambda^2 + \gamma^2}\)), the quasi-static vector-potential Green's functions are:
Buried source, buried observer (depths \(h, h' > 0\)):
Overhead source and observer (heights \(H, H' > 0\)):
Mixed (buried \(h\), overhead \(H\)):
with the reflection coefficient
- homogeneous earth (Pillar A): \(\Gamma(\lambda) = (u_1 - \lambda)/(u_1 + \lambda)\),
- \(n\)-layer earth (Pillar B): the recursive Wait-style reflection coefficient (Wait 1972 §3, Tleis 2008 §3.5); the \(\lambda/u_1\) weight and the exponents use the top-layer \(u_1\) (the conductors live in layer 1).
The functions in this module return the correction beyond the
ADR-0004 additive perfect-mirror baseline (\(1/R + 1/R'\)), so the
solver assembles Z_b = jω·(L_Neumann+mirror) + ΔZ_Sommerfeld.
The mirror deduplication \(-1/R'\) is carried in closed form; only
the smooth reflected/transmitted remainder is integrated
numerically.
Limit checks (built into the test suite)
- \(\sigma_e\to 0\): every kernel collapses to free space — the correction tends to \(-1/R'\) and exactly cancels the ADR-0004 mirror. (At DC the soil is magnetically transparent: no image.)
- \(\sigma_e\to\infty\), overhead pair: \(-\Gamma \to -1\), the net image becomes the anti-parallel PEC image \(-1/R'\) (Carson's baseline).
- \(\sigma_e\to\infty\), buried pair: \(e^{-\gamma R} \to 0\) — the conductor is screened by the surrounding medium and the total external coupling tends to zero.
- Long parallel buried wires: the per-metre limit reproduces Pollaczek's mutual $\frac{j\omega\mu_0}{2\pi}\bigl[K_0(\gamma d)
- K_0(\gamma D') + J_P\bigr]$, whose low-frequency real part is Carson's \(\omega\mu_0/8\) (with the positive sign — the historic kernel produced \(-\omega\mu_0/8\)).
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.
- Tleis, N. D. (2008). Power Systems Modelling and Fault Analysis, Newnes. Ch. 3.
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 (:func:reflection_coefficient_homogeneous,
:func: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 or the cross-backend
cross-check in
tests/test_layered_green.py::test_cross_backend_precision
will fail. 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.
build_sommerfeld_correction_matrix ¶
build_sommerfeld_correction_matrix(
seg_endpoints: np.ndarray,
wire_radii: np.ndarray,
*,
omega: float,
earth: LayeredEarth
) -> np.ndarray
Assemble the dense Sommerfeld earth-return correction matrix.
The output is the σ-dependent addition to the perfect-mirror
Neumann inductance matrix from
:func:groundfield.coupling.inductance.build_inductance_matrix.
The two should be added (after multiplying \(L_\text{Neumann}\)
by \(j\omega\)):
.. code-block:: python
Z_b = jω · L_Neumann + dZ_Sommerfeld
For earth.n_layers == 1 this is the homogeneous-earth
Sommerfeld kernel; for n >= 2 the layered Pollaczek-Wait
kernel is used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seg_endpoints
|
ndarray
|
Array of shape |
required |
wire_radii
|
ndarray
|
Per-branch wire radii. Currently unused (the radius is
already in the perfect-mirror diagonal handled by
|
required |
omega
|
float
|
Angular frequency in rad/s. |
required |
earth
|
LayeredEarth
|
Layered-earth configuration. |
required |
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
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 (audit 2026-07-08, WP-C1; 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\) (at DC the soil is magnetically transparent: no image). ✓
- \(\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). ✓ (The historic kernel instead returned the additive mirror in this limit, which is the electrostatic — not the magnetic — image; see the audit report.)
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; for wires at the surface (Sunde-equivalent depth = 0) use a small regularisation \(z = \max(|\text{depth}|, r)\) where \(r\) is the wire radius. |
required |
z_j
|
float
|
Depths (positive into soil) in m. Must be > 0 for the integral to converge; for wires at the surface (Sunde-equivalent depth = 0) use a small regularisation \(z = \max(|\text{depth}|, r)\) where \(r\) is the wire radius. |
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, dimensionless (the calling
:func: |
Source code in src/groundfield/coupling/sommerfeld_inductance.py
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 | |
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 :func:earth_return_correction_homogeneous.
Uses :func:reflection_coefficient_layered for the reflected
term; the \(\lambda/u_1\) weight, the exponents and the direct
attenuation use the top-layer parameters (conductors live in
layer 1). For earth.n_layers == 1 it short-circuits to the
single-layer formula.
Source code in src/groundfield/coupling/sommerfeld_inductance.py
reflection_coefficient_homogeneous ¶
reflection_coefficient_homogeneous(
lambdas: np.ndarray, *, omega: float, sigma_earth: float
) -> np.ndarray
Magnetic reflection coefficient for a homogeneous half-space.
.. math::
\Gamma_\text{mag}^{(1)}(\lambda) \;=\;
\frac{u_e - \lambda}{u_e + \lambda},
\qquad u_e \;=\; \sqrt{\lambda^2 + j\omega\mu_0\sigma_e}.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lambdas
|
ndarray
|
Spectral variable, 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\). |
Source code in src/groundfield/coupling/sommerfeld_inductance.py
reflection_coefficient_layered ¶
reflection_coefficient_layered(
lambdas: np.ndarray,
*,
omega: float,
earth: LayeredEarth
) -> np.ndarray
Magnetic reflection coefficient for an \(n\)-layer earth.
Implements the recursive Tagg/Sunde-Wait formula
.. math::
\Gamma_k(\lambda) \;=\;
\frac{u_k - u_{k+1} - (u_k + u_{k+1})\,\Gamma_{k+1}\,e^{-2 u_k h_k}}
{u_k + u_{k+1} + (u_k - u_{k+1})\,\Gamma_{k+1}\,e^{-2 u_k h_k}},
starting from \(\Gamma_n = 0\) (semi-infinite bottom layer) and walking up to layer 1. The top-layer reflection is \(\Gamma_\text{mag}^{(n)}(\lambda) = (u_e - \lambda)/(u_e+\lambda)\) with \(u_e \to u_1\) in the homogeneous limit, but for \(n>1\) the recursion modifies \(u_1\) effectively. The formulation below is the standard one in Tleis 2008 §3.5.
For \(n=1\) this collapses to
:func:reflection_coefficient_homogeneous.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lambdas
|
(ndarray, shape(N_lam))
|
|
required |
omega
|
float
|
Angular frequency in rad/s. |
required |
earth
|
LayeredEarth
|
Layered-earth configuration. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Gamma |
(ndarray, complex)
|
|
Source code in src/groundfield/coupling/sommerfeld_inductance.py
sommerfeld_pair_integral_homogeneous ¶
sommerfeld_pair_integral_homogeneous(
p1_a: np.ndarray,
p2_a: np.ndarray,
p1_b: np.ndarray,
p2_b: np.ndarray,
*,
omega: float,
sigma_earth: float
) -> complex
Integrate the σ-dependent magnetic Green function over a segment pair.
Computes
where \(\Delta G_\text{mag}\) is the σ-dependent earth-return
correction beyond the ADR-0004 additive-mirror baseline
(vanishes for σ → 0 together with the mirror; see the module
docstring for the case-dispatched Pollaczek kernels). Used by
:func:build_sommerfeld_correction_matrix.
The integration is 16×16 Gauss–Legendre over the two segment parameterisations. The Sommerfeld inner integral is not re-evaluated at every outer node — the spectral kernel is computed once per segment pair on a shared λ-grid and reused (valid because the segments are assumed approximately horizontal so the depth sum varies negligibly along them; see ADR-0006 numerical notes). The closed-form pieces (mirror deduplication \(-1/R'\); buried–buried direct attenuation \((e^{-\gamma R} - 1)/R\)) are evaluated exactly per outer node.
Returns:
| Name | Type | Description |
|---|---|---|
Z |
complex
|
Per-pair earth-return correction in \(\Omega\) (already includes the \(j\omega\mu_0/(4\pi)\) pre-factor). |
Source code in src/groundfield/coupling/sommerfeld_inductance.py
sommerfeld_pair_integral_layered ¶
sommerfeld_pair_integral_layered(
p1_a: np.ndarray,
p2_a: np.ndarray,
p1_b: np.ndarray,
p2_b: np.ndarray,
*,
omega: float,
earth: LayeredEarth
) -> complex
Layered-earth analogue of :func:sommerfeld_pair_integral_homogeneous.
The reflected term uses the layered reflection coefficient; the \(\lambda/u_1\) weight, the \(e^{-u_1(\cdot)}\) exponents and the buried direct-term attenuation use the top-layer \(u_1\) / \(\gamma_1\) (the conductors live in layer 1 — deeper layers act through the reflection coefficient only).
Source code in src/groundfield/coupling/sommerfeld_inductance.py
Cross-layer Green's function (ADR-0007 Phase B)¶
groundfield.coupling.layered_green solves the two-layer matching
problem for the electric Green's function — used by image_2layer,
mom_sommerfeld, cim, and bem whenever a source / observer pair
straddles the upper-layer interface (driven rods, deep meshes,
foundation electrodes that cross \(z = h_1\)).
Entry points:
two_layer_spectral_kernel— the kernel \(\widetilde{G}(\lambda; z, z_s)\) in spectral space,two_layer_real_space_kernel— its real-space counterpart \(G(s, z, z_s)\) obtained by Sommerfeld inversion,two_layer_layered_correction_real_space/two_layer_layered_correction_group— the layered correction \(\Delta G = G_\text{2-layer} - G_\text{homog}\) for one distance or for a whole reaction block at one \((z, z_s)\) pair,two_layer_probe_matrix— the post-processing potential matrix \(\varphi = G\,I\) for arbitrary probe/source layer combinations.
Together with the cross-layer-aware self-action factory
(_two_layer_self_kernel_factory) they lift the long-standing
z_max < h_1 precondition for n_layers == 2. For
n_layers >= 3 the layered backends still emit a documented
UserWarning — the n-layer extension is on the roadmap.
Numerical strategy: analytic primary term, quadrature for the rest¶
The spectral kernel splits into a primary term — the particular solution \(\rho_k/(2\lambda)\,e^{-\lambda|z-z_s|}\) in the layer that contains the source — and a reflected remainder generated by the free surface at \(z = 0\) and the interface at \(z = h_1\). The two behave very differently in \(\lambda\) and are treated differently:
The primary term is the only part that does not decay in \(\lambda\) at all, and its Hankel inverse is the exact \(1/R\) field. Since 0.15.0 it is evaluated in closed form.
The reflected remainder decays like \(e^{-\lambda d_\text{img}}\) with
\(d_\text{img}\) the smallest image distance — which is not by itself
a licence to truncate, because every image distance can degenerate:
\(z + z_s \to 0\) for a pair at the air/soil surface,
\(|2h_1 - z - z_s| \to 0\) for a pair at the interface, and
\(z_l - z_u \to 0\) for a pair straddling it. Up to 0.15.0.dev
\(\lambda_\text{max}\) was lambda_max_factor \(/\min(h_1, s+z+z_s)\),
which has no relation to \(d_\text{img}\), and those three regimes were
wrong by −2.7e-2, +4.1 % and −39.5 % respectively with no warning —
the last one growing as the mesh was refined towards \(h_1\).
Since 0.15.0 the truncation is guaranteed instead of assumed. The reflected kernel is written as its exact image superposition \(\sum_j \frac{c_j}{2\lambda}e^{-\lambda d_j}\) (the Sunde/Tagg series, for all four layer combinations); every term with \(\lambda_\text{max} d_j < 30\) is subtracted from the integrand and added back through its exact Hankel inverse \(c_j/(2R_j)\), so the discarded tail is bounded by \(\sum_j |c_j| e^{-\lambda_\text{max} d_j}/(2 d_j) \le e^{-30} \sum_j |c_j| / (2 d_j)\) by construction. Measured against an independently derived closed form, surface pairs, interface pairs, pairs a micrometre below the interface, pairs straddling it and radii from 0 to 20 km all agree to ~3e-10.
Up to 0.14.1 the primary term went through the quadrature as well, which left an \(O((\lambda_\text{max}R)^{-1/2})\) truncation residue oscillating in \(s\) with period \(2\pi/\lambda_\text{max}\): −4.5 % at \(s = 1\) m and ±4 % swings around \(s = 10\) m for an equal-depth pair in \(h_1 = 6.1\) m soil. The homogeneous limit \(\rho_2 = \rho_1 \Rightarrow \rho/2\,(1/r + 1/r')\) is now reproduced to ~1e-10 instead of ~1e-2 (ADR-0007 validation item 1 asks for 1e-9).
At \(s = 0\) with \(z = z_s\) every \(1/R\) pole is clamped at
\(R = 1/\lambda_\text{clamp}\), \(\lambda_\text{clamp} =\)
lambda_max_factor \(/\min(h_1, s+z+z_s)\) — so the clamp depends only
on the knob and the depths, never on the largest radius that happens to
share a group. The value stays finite and continuous but is not a
physical potential; the caller regularises at the wire radius.
Depths must satisfy \(z, z_s \ge 0\) (positive into the soil). Negative
depths raise ValueError; up to 0.15.0.dev they returned nan, which
propagated silently into grounding_impedance().
Oscillation resolution and SommerfeldResolutionWarning¶
The linear region of the \(\lambda\) grid places one 16-node Gauss panel per \(J_0(\lambda s)\) period, so the required node count grows with the oscillation content \(n_\text{osc} = \lambda_\text{max}\,s / 2\pi\). The policy has three tiers:
| Regime | Resolution |
|---|---|
| \(16\,n_\text{osc} \le 2^{16}\) nodes | one panel per period (16 nodes / oscillation) |
| beyond the soft budget | reduced to the floor of 8 nodes / oscillation |
| \(8\,n_\text{osc} > 2^{20}\) nodes | hard allocation budget — SommerfeldResolutionWarning |
Eight nodes per oscillation is the same adequacy criterion the
single-panel fast path uses at small radius. Before 0.15.0 the panel
count was capped at 4096 with no adequacy check, so raising
lambda_max_factor from 200 to 6000 turned a layered correction of
−0.2311 into +0.0349 — a sign flip with no diagnostic.
What lambda_max_factor does since 0.15.0¶
Because the truncated tail is bounded by the closed-form image split
above rather than by making \(\lambda_\text{max}\) large,
\(\lambda_\text{max}\) is now chosen by the module and
lambda_max_factor is only an upper bound on it plus the \(1/R\)
regularisation wavenumber. The choice is:
| Step | Rule |
|---|---|
| requested | \(\lambda_\text{user} =\) lambda_max_factor \(/\min(h_1, s_\text{min}+z+z_s)\) |
| cost cap | at most \(1024 \cdot\) lambda_max_factor\(/200\) panels, never more than 4096 (the historic allocation) |
| decay cap | \(120 / d_\text{rest}\) — no point integrating past \(e^{-120}\) |
| repair | raised back to \(30/d_\text{rest}\) if the image-term budget ran out (then also warns) |
Consequences, both intended:
- Raising the knob normally does nothing at all. Measured: the full kernel of a surface pair is identical to ten digits for any factor from 30 to 30 000. That is the resolution of F14 — the knob can no longer make the answer worse, because the answer no longer depends on it.
- Lowering it is cheap and equally exact, because work moves into the closed-form image sum. A convergence check should therefore sweep downwards as well, and see nothing move.
- Because \(\lambda_\text{max}\) no longer grows with the knob or with
\(s\),
SommerfeldResolutionWarningis no longer reachable from a public entry point; it remains as a guard behind the image-term budget, and is tested through it.
The cost cap is also what fixes the multi-kilometre performance of the remote-injection workload: at 0.15.0.dev a 4 km group cost 42x a 90 m one (the node count grew like \(\lambda_\text{max}\,s\) with nothing bounding it). Measured for a 4000-pair group, \(z = z_s = 0.7\) m, \(h_1 = 5\) m, \(\rho = 1000/30\), default knob:
| \(s_\text{max}\) | v0.14.1 | 0.15.0.dev | 0.15.0 |
|---|---|---|---|
| 90 m | 94 ms | 131 ms | 59 ms |
| 400 m | 186 ms | 418 ms | 49 ms |
| 1 km | 190 ms | 1 107 ms | 66 ms |
| 4 km | 199 ms | 11 216 ms | 71 ms |
| 20 km | 196 ms | 11 641 ms | 75 ms |
Note
coupling.sommerfeld_inductance._build_lambda_grid (the magnetic
counterpart, ADR-0006) still carries the historic unchecked
4096-panel cap with 8-node panels.
Large-group interpolation¶
Reaction blocks share one \((z, z_s)\) pair, so the kernel there depends on the horizontal distance only, and what is left for the quadrature after the closed-form split is analytic in \(t = \ln(s + c)\) with \(c = d_\text{rest}\), the decay length of that remainder. Groups above 64 distance pairs are therefore sampled on a log-spaced \(s\)-grid — sized from the group's actual dynamic range at ~12 nodes per e-fold — and interpolated with a cubic spline, turning a block from \(O(n_\text{pairs} \cdot n_\lambda)\) into \(O(n_\text{nodes} \cdot n_\lambda)\). Interpolation is skipped whenever it would need at least as many nodes as the group has pairs. The closed-form primary and image terms are always evaluated per pair, outside the interpolation.
Measured agreement with the exact per-pair contraction is ~1e-6
(worst case 1.1e-5, at a surface pair as \(s \to 0\) where the scalar
branch is the less accurate of the two), against ~1e-2 for the fixed
48-node linear interpolation used up to 0.14.1; for
two_layer_probe_matrix 8e-7 against a documented 1e-4. Because the
node count no longer depends on a fixed constant, the same matrix
entry no longer changes with the number of pairs in its block — that
discontinuity was ~3 % at the 64-pair threshold and is now below 1.1e-5
for every group size from 60 to 129 pairs.
Do not restate this as ~1e-8
Source comments claiming "~1e-8 relative" and "four orders of
margin" stood in layered_green.py at 0.15.0.dev; they were 2–3
orders optimistic and contradicted this page. The numbers above are
measured.
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
:mod:groundfield.solver.image_2layer (which assumes both points in
the upper layer) and the Sommerfeld kernel in
:mod: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 4×4 boundary-value system is solved numerically once per
\((\lambda, z_s)\) pair (4 unknowns: amplitudes in each layer for
each direction). Per call the cost is dominated by \(J_0\)
evaluation and the linear solve at each \(\lambda\) node — fully
vectorisable with numpy.
The implementation focuses on the 2-layer case
(:class: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
(:func:
_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}\) (:func:
_image_generationgives 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})\) (:func:_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 (:func:_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 a :class:SommerfeldResolutionWarningwhen 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 :data:_HANKEL_PANEL_TARGET panels (scaled
by lambda_max_factor / 200) and subtracts as many image terms as
that cap requires (:func:_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
:func: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
:func:
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
(:data:_HANKEL_MAX_LINEAR_NODES) bounds the transient allocation;
when that budget forces fewer than
:data:_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 (:func:_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 :class: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 <
$ :data:_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 :data:_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.
two_layer_layered_correction_group ¶
two_layer_layered_correction_group(
s_values: np.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
) -> np.ndarray
Vectorised form of :func: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
(:func:_plan_truncation).
Accuracy (review pass 9, finding F15)
Groups above :data:_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
(:func:
_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).
Source code in src/groundfield/coupling/layered_green.py
1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 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 | |
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
) -> 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
:func: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
:func:two_layer_real_space_kernel.
Source code in src/groundfield/coupling/layered_green.py
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 1849 1850 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 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 | |
two_layer_probe_matrix ¶
two_layer_probe_matrix(
probe_points: np.ndarray,
source_points: np.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 (:func: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.
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.
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
:data:_HANKEL_INTERP_THRESHOLD pairs are sampled on a log-spaced
s-grid whose node count is derived from the group's dynamic
range (:func:_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
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 1731 1732 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 | |
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
) -> 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}\)
(:func:_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
(:func:_reflected_image_terms, :func:_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
:mod: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.
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 :class: |
required |
z_s
|
float
|
Observer / source depths in m, \(\ge 0\) (positive into the
soil). Negative depths raise :class: |
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
(:func: |
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
|
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
1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 | |
two_layer_spectral_kernel ¶
two_layer_spectral_kernel(
lambdas: np.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-conductivity / earth-layer resolvers¶
These helpers normalise any soil model to a homogeneous \(\sigma_\text{earth}\) (Carson) or a layered structure (Sommerfeld). They are typically invoked by the engine builders, not by user code.
from groundfield.coupling import (
resolve_earth_conductivity, resolve_earth_layers,
)
sigma = resolve_earth_conductivity(world.soil) # Carson
layers = resolve_earth_layers(world.soil) # Sommerfeld
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:
- :class:
~groundfield.soil.models.HomogeneousSoil→ \(\sigma = 1/\rho\), exact. - :class:
~groundfield.soil.models.TwoLayerSoil→ \(\sigma = 1/\rho_1\) (upper layer), with a runtime warning. - :class:
~groundfield.soil.models.MultiLayerSoil→ \(\sigma = 1/\rho_1\) (top layer), with a runtime warning.
The layered cases are an approximation; ADR-0005 references the
Pollaczek/Sommerfeld kernel (via mom_sommerfeld) as the
rigorous alternative.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
soil
|
Any concrete soil model from
:mod: |
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 :class:LayeredEarth configuration.
Used by the Sommerfeld earth-return kernel (ADR-0006). Unlike
:func:resolve_earth_conductivity, this preserves the full
layered structure — no warning is emitted, and layered soils
are handled natively by the Pollaczek/Wait kernel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
soil
|
Any concrete soil model from
:mod: |
required |
Returns:
| Type | Description |
|---|---|
LayeredEarth
|
Frozen layered-earth configuration (resistivities and layer
thicknesses) consumable by
:func: |