libEMM is a C/CUDA codebase for 3D controlled-source electromagnetic (CSEM) forward modelling. The main solver uses a high-order finite-difference time-domain (FDTD) scheme in a fictitious wave domain, with MPI for distributed execution, OpenMP for shared-memory parallelism, and optional CUDA acceleration.
The repository includes the core library, standalone solver variants, reproducible example models, and the accompanying papers/manual.
- Problem class: land and marine CSEM forward modelling
- Governing equations: first-order diffusive Maxwell equations
- Numerical method: high-order staggered-grid FDTD in a fictitious wave domain transformation
- Parallelization: MPI + OpenMP, with optional CUDA support
- Primary platform: Linux
Required for the main solver in src:
mpicc/ MPI development libraries- FFTW3
- POSIX threads / OpenMP-capable compiler toolchain
- Standard C math library
Optional:
- NVIDIA CUDA toolkit for GPU builds
- Python 3 for the plotting scripts in the example directories
gnuplot/ MATLAB or compatible tools for some auxiliary visualization scripts
The main executable is built from src and written to bin/fdtd.
cd src
makecd src
make GPU=1Notes:
- The Makefile uses
mpiccby default. - For GPU builds, review
CUDA_PATHand-arch=sm_50insrc/Makefileand adapt them to your local CUDA installation and GPU architecture. - The default
maketarget runscleanbefore rebuilding.
The primary executable is bin/fdtd. Runtime parameters are passed on the command line in key=value form.
Typical required inputs include:
- source file:
fsrc=... - receiver file:
frec=... - source-receiver table:
fsrcrec=... - resistivity volumes:
frho11=...,frho22=...,frho33=... - active source/receiver channels:
chsrc=...,chrec=... - model extents and sampling:
x1min,x1max,x2min,x2max,x3min,x3max,n1,n2,n3,d1,d2,d3 - absorbing boundary / interpolation controls:
nb,ne,rd - frequencies:
freqs=...
Optional nonuniform vertical grid support is enabled with:
nugrid=1fx3nu=...
run_1d contains a simple example that runs the main solver on a 3D grid representing a layered structure.
cd run_1d
bash run.sh
python3 plot_emdata.pyThe example writes modeled EM responses such as emf_0001.txt and comparison figures such as comparison.png.
run_bathy_2d demonstrates a marine model with seafloor bathymetry and nonuniform vertical gridding.
cd run_bathy_2d
bash run.sh
python3 plot_emdata.py
python3 plot_cmp_libEMM_mare2dem.pyThis example compares libEMM output with MARE2DEM-style reference data and includes plotting utilities for survey geometry and response curves.
The example directories expect local input files such as:
sources.txtreceivers.txtsrc_rec_table.txtrho11,rho22,rho33x3nufor nonuniform vertical grids
Some of these binary model files are generated by the mesh/nonuniform-grid utilities rather than written by hand. In this repository, the relevant helper code lives in directories such as src_mesh_seafloor and the standalone nonuniform-grid solver folders.
If you regenerate model files, make sure the expected binary inputs are copied into the example run directory before launching ../bin/fdtd.
src: main MPI/OpenMP solver, plus optional CUDA implementationinclude: shared headers and runtime data structuresbin: compiled executablesdoc: manual and publication PDFsrun_1d: reproducible layered-model examplerun_bathy_2d: reproducible bathymetry examplesrc_fdtd_nugrid: standalone solver for fully nonuniform grids inx,y, andzsrc_fdtd_unigrid: standalone solver for fully uniform grids with padded layers on all sidessrc_fdtd_unigrid_v2: optimized uniform-grid variant that removes extra layers above the sea surface for better efficiencysrc_mesh_seafloor: mesh generation / preprocessing utilities for seafloor-oriented models
Additional documentation is available in doc, including:
libEMM_mannual.pdfcpc_libEMM.pdf
If libEMM contributes to published research, cite:
- Pengliang Yang, 2023, “libEMM: A fictitious wave domain 3D CSEM modelling library bridging sequential and parallel GPU implementation,” Computer Physics Communications, 288, 108745. DOI: 10.1016/j.cpc.2023.108745
- Pengliang Yang and Rune Mittet, 2023, “Controlled-source electromagnetics modelling using high order finite-difference time-domain method on a nonuniform grid,” Geophysics, 88(2), E53-E67. DOI: 10.1190/geo2022-0134.1
The project originated from earlier CSEM modelling work started during the author's time at Electromagnetic Geoservices ASA (EMGS), and was later rebuilt from scratch into the current implementation. The development also benefited from discussions with Rune Mittet.
Pengliang Yang
Harbin Institute of Technology, China
Email: ypl.2100@gmail.com