Code¶
Electromagnetic modeller in the diffusive limit (low frequencies) for 3D media
with tri-axial electrical anisotropy. The matrix-free multigrid solver can be
used as main solver or as preconditioner for one of the Krylov subspace methods
implemented in scipy.sparse.linalg
, and the governing equations are
discretized on a staggered Yee grid. The code is written completely in Python
using the numpy
/scipy
-stack, where the most time-consuming parts are
sped-up through jitted numba
-functions.
emg3d.meshes Module¶
meshes
– Discretization¶
Everything related to meshes appropriate for the multigrid solver.
Functions¶
get_hx_h0 (freq, res, domain[, fixed, …]) |
Return cell widths and origin for given parameters. |
get_cell_numbers (max_nr[, max_prime, min_div]) |
Returns ‘good’ cell numbers for the multigrid method. |
get_stretched_h (min_width, domain, nx[, x0, …]) |
Return cell widths for a stretched grid within the domain. |
get_domain ([x0, freq, res, limits, …]) |
Get domain extent and minimum cell width as a function of skin depth. |
get_hx (alpha, domain, nx, x0[, resp_domain]) |
Return cell widths for given input. |
Classes¶
TensorMesh (h, x0) |
A slightly modified discretize.TensorMesh . |
emg3d.models Module¶
models
– Earth properties¶
Everything to create model-properties for the multigrid solver.
Classes¶
Model (grid[, property_x, property_y, …]) |
Create a model instance. |
VolumeModel (grid, model, sfield) |
Return a volume-averaged version of provided model. |
emg3d.fields Module¶
fields
– Electric and magnetic fields¶
Everything related to the multigrid solver that is a field: source field, electric and magnetic fields, and fields at receivers.
Functions¶
get_source_field (grid, src, freq[, strength]) |
Return the source field. |
get_receiver (grid, values, coordinates[, …]) |
Return values corresponding to grid at coordinates. |
get_receiver_response (grid, field, rec) |
Return the field (response) at receiver coordinates. |
get_h_field (grid, model, field) |
Return magnetic field corresponding to provided electric field. |
Classes¶
Field |
Create a Field instance with x-, y-, and z-views of the field. |
SourceField |
Create a Source-Field instance with x-, y-, and z-views of the field. |
emg3d.surveys Module¶
survey
– Surveys¶
A survey stores a set of sources, receivers, and the measured data.
Classes¶
Survey (name, sources, receivers, frequencies) |
Create a survey with sources, receivers, and data. |
Dipole (name, coordinates[, electric]) |
Finite length dipole or point dipole. |
PointDipole (name, xco, yco, zco, azm, dip, …) |
Infinitesimal small electric or magnetic point dipole. |
emg3d.simulations Module¶
simulation
– Model a survey¶
A simulation is the computation (modelling) of electromagnetic responses of a resistivity (conductivity) model for a given survey.
In its heart, emg3d is a multigrid solver for 3D electromagnetic diffusion with tri-axial electrical anisotropy. However, it contains most functionalities to also act as a modeller. The simulation module combines all these things by combining surveys with computational meshes and fields and providing high-level, specialised modelling routines.
Classes¶
Simulation (name, survey, grid, model[, …]) |
Create a simulation for a given survey on a given model. |
emg3d.maps Module¶
maps
– Interpolation routines¶
Interpolation routines mapping grids to grids, grids to fields, and fields to grids.
Functions¶
grid2grid (grid, values, new_grid[, method, …]) |
Interpolate values located on grid to new_grid. |
interp3d (points, values, new_points, method, …) |
Interpolate values in 3D either linearly or with a cubic spline. |
edges2cellaverages (ex, ey, ez, vol, out_x, …) |
Interpolate fields defined on edges to volume-averaged cell values. |
Classes¶
MapConductivity () |
Maps σ to computational variable σ (conductivity). |
MapLgConductivity () |
Maps log_10(σ) to computational variable σ (conductivity). |
MapLnConductivity () |
Maps log_e(σ) to computational variable σ (conductivity). |
MapResistivity () |
Maps ρ to computational variable σ (conductivity). |
MapLgResistivity () |
Maps log_10(ρ) to computational variable σ (conductivity). |
MapLnResistivity () |
Maps log_e(ρ) to computational variable σ (conductivity). |
emg3d.optimize Module¶
optimize
– Inversion¶
Functionalities related to optimization (inversion), e.g., misfit function, gradient of the misfit function, or data- and depth-weighting.
Currently it follows the implementation of [PlMu08], using the adjoint-state technique for the gradient.
Functions¶
gradient (simulation) |
Compute the discrete gradient using the adjoint-state method. |
misfit (simulation) |
Return the misfit function. |
data_weighting (simulation) |
Return weighted residual. |
emg3d.solver Module¶
solver
– Multigrid solver¶
The actual solver routines. The most computationally intensive parts, however,
are in the emg3d.core
as numba-jitted functions.
Functions¶
multigrid (grid, model, sfield, efield, var, …) |
Multigrid solver for 3D controlled-source electromagnetic (CSEM) data. |
smoothing (grid, model, sfield, efield, nu, …) |
Reducing high-frequency error by smoothing. |
restriction (grid, model, sfield, residual, …) |
Downsampling of grid, model, and fields to a coarser grid. |
prolongation (grid, efield, cgrid, cefield, …) |
Interpolating the electric field from coarse grid to fine grid. |
residual (grid, model, sfield, efield[, norm]) |
Computing the residual. |
krylov (grid, model, sfield, efield, var) |
Krylov Subspace iterative solver for 3D CSEM data. |
Classes¶
MGParameters (verb, cycle, sslsolver, …) |
Collect multigrid solver settings. |
RegularGridProlongator (x, y, cxy) |
Prolongate field from coarse to fine grid. |
emg3d.core Module¶
core
– Number crunching¶
The core functionalities, the most computationally demanding parts, of the
emg3d.solver
as just-in-time (jit) compiled functions using numba
.
Functions¶
amat_x (rx, ry, rz, ex, ey, ez, eta_x, eta_y, …) |
Residual without or with source term. |
blocks_to_amat (amat, bvec, middle, left, …) |
Insert middle, left, and rhs into main arrays amat and bvec. |
gauss_seidel (ex, ey, ez, sx, sy, sz, eta_x, …) |
Gauss-Seidel method. |
gauss_seidel_x (ex, ey, ez, sx, sy, sz, …) |
Gauss-Seidel method with line relaxation in x-direction. |
gauss_seidel_y (ex, ey, ez, sx, sy, sz, …) |
Gauss-Seidel method with line relaxation in y-direction. |
gauss_seidel_z (ex, ey, ez, sx, sy, sz, …) |
Gauss-Seidel method with line relaxation in z-direction. |
restrict (crx, cry, crz, rx, ry, rz, wx, wy, …) |
Restriction of residual from fine to coarse grid. |
restrict_weights (vectorN, vectorCC, h, …) |
Restriction weights for the coarse-grid correction operator. |
solve (amat, bvec) |
Solve A x = b using a non-standard Cholesky factorisation. |