Repository navigation
Description
Describe the issue:
In the electric field formulations of the NSEM simulations (Simulation1DElectricField, Simulation2DElectricField and Simulation3DPrimarySecondary), the magnetic field lives at cell center elevations, so a receiver on the surface interpolates H between the ground cell below it and the air cell above it. The vertical derivative of H jumps across the surface (it's sigma * E in the ground and essentially 0 in the air), so that interpolation is only first order accurate. For a 10 ohm-m half space at 10 Hz this is about a 12% error in apparent resistivity with 100 m cells, and it only halves every time the cells are halved. I saw about the same error in 3D with 100 m vertical cells.
I see two ways we could fix this:
- Move the H locations up to the center of the first air cell above each station. H is nearly constant with height in the (quasi-static) air, so this drops the error to about 0.02% with 100 m cells, and it converges much faster. This can already be done by passing
locations_hto the receivers (see the example below). - Extrapolate H down to the surface from the two cells above it. In 1D this gives the same answer as the first option (H is flat through the air), but over 2D or 3D structure the anomalous magnetic field has a vertical gradient in the air, which this would also account for.
Either way, I think the receivers should do this by default when they sit on the surface, since most users won't know to set locations_h.
Also, the 1D receivers currently ignore locations_h. _eval_impedance (and its derivative) builds the H projection with getP(mesh, h_loc), which uses the default location_id=0 (the electric field locations), so the workaround above doesn't work for Simulation1DElectricField.
Reproducible code example:
import numpy as np
import discretize
from simpeg.electromagnetics import natural_source as nsem
from simpeg.utils import get_default_solver
rho, freq = 10.0, 10.0 # half space, so the answer is rho_a = 10 ohm-m
for h in [100.0, 50.0, 25.0]:
n_core = int(2000 / h)
hx = [(h, 10, -1.3), (h, 20), (h, 10, 1.3)]
hz = [(h, 30, -1.3), (h, n_core), (h, 30, 1.3)] # padding, ground core, air
mesh = discretize.TensorMesh([hx, hz], "C0")
mesh.origin = [mesh.origin[0], -mesh.h[1][: 30 + n_core].sum()] # surface at z = 0
sigma = np.where(mesh.cell_centers[:, 1] < 0, 1 / rho, 1e-8)
z_air = mesh.cell_centers_y[mesh.cell_centers_y > 0][0] # center of the first air cell
rx_e = np.array([[0.0, 0.0]])
rx_h = np.array([[0.0, z_air]])
rx = [
nsem.receivers.Impedance(rx_e, orientation="xy", component="app_res"),
nsem.receivers.Impedance(rx_e, locations_h=rx_h, orientation="xy", component="app_res"),
]
survey = nsem.Survey([nsem.sources.Planewave(rx, freq)])
sim = nsem.simulation.Simulation2DElectricField(
mesh, survey=survey, sigma=sigma, solver=get_default_solver()
)
at_surface, air_cell = 100 * (sim.dpred() / rho - 1)
print(f"h = {h:5.1f} m: rho_a error {at_surface:6.2f}% (H at the surface), {air_cell:6.3f}% (H from the first air cell)")which gives
h = 100.0 m: rho_a error 11.97% (H at the surface), -0.020% (H from the first air cell)
h = 50.0 m: rho_a error 5.79% (H at the surface), -0.001% (H from the first air cell)
h = 25.0 m: rho_a error 2.85% (H at the surface), -0.000% (H from the first air cell)
Error message:
No error, just an inaccurate result.
Runtime information:
--------------------------------------------------------------------------------
Date: Wed Oct 28 00:28:49 2026 UTC
OS : Darwin (macOS 27.0.1)
CPU(s) : 18
Machine : arm64
Architecture : 64bit
Environment : Python
Python 3.12.15 (main, Oct 6 2026, 23:42:14) [Clang 21.1.8 ]
simpeg : main (137a37216)
discretize : 0.12.0
pymatsolver : 0.4.0
numpy : 2.5.3
scipy : 1.18.1
matplotlib : 3.11.2
geoana : 0.8.1
libdlf : 0.3.0
--------------------------------------------------------------------------------
Context for the issue:
I ran into this while looking at the 2D NSEM boundary conditions. On meshes that are otherwise well padded, this is often the largest error left in the surface data.
Activity
Keep `shift_to_discrete_topography` locations on the discrete surface (…
dccowan commentedon Dec 2, 2026
I'm not sure this requires changes to the code. Would it be sufficient to include this in the user tutorials for natural sources?