Solver

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.solver Module

The actual multigrid solver routines. The most computationally intensive parts, however, are in the emg3d.core as numba-jitted functions.

Functions

solve(grid, model, sfield[, efield, cycle, …]) Solver for 3D CSEM data with tri-axial electrical anisotropy.
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

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.