Skip to content

Repository files navigation

libEMM

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.

Scope

  • 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

Dependencies

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

Build

The main executable is built from src and written to bin/fdtd.

CPU build

cd src
make

GPU build

cd src
make GPU=1

Notes:

  • The Makefile uses mpicc by default.
  • For GPU builds, review CUDA_PATH and -arch=sm_50 in src/Makefile and adapt them to your local CUDA installation and GPU architecture.
  • The default make target runs clean before rebuilding.

Main Workflow

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=1
  • fx3nu=...

Reproducible Examples

1. Layered 1D-style model

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.py

The example writes modeled EM responses such as emf_0001.txt and comparison figures such as comparison.png.

2. Bathymetry / 2D seafloor structure

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.py

This example compares libEMM output with MARE2DEM-style reference data and includes plotting utilities for survey geometry and response curves.

Input Data Preparation

The example directories expect local input files such as:

  • sources.txt
  • receivers.txt
  • src_rec_table.txt
  • rho11, rho22, rho33
  • x3nu for 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.

Repository Layout

  • src: main MPI/OpenMP solver, plus optional CUDA implementation
  • include: shared headers and runtime data structures
  • bin: compiled executables
  • doc: manual and publication PDFs
  • run_1d: reproducible layered-model example
  • run_bathy_2d: reproducible bathymetry example
  • src_fdtd_nugrid: standalone solver for fully nonuniform grids in x, y, and z
  • src_fdtd_unigrid: standalone solver for fully uniform grids with padded layers on all sides
  • src_fdtd_unigrid_v2: optimized uniform-grid variant that removes extra layers above the sea surface for better efficiency
  • src_mesh_seafloor: mesh generation / preprocessing utilities for seafloor-oriented models

Documentation

Additional documentation is available in doc, including:

  • libEMM_mannual.pdf
  • cpc_libEMM.pdf

Citation

If libEMM contributes to published research, cite:

  1. 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
  2. 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

Acknowledgement

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.

Author

Pengliang Yang
Harbin Institute of Technology, China
Email: ypl.2100@gmail.com

About

A C + CUDA library for 3D CSEM modelling

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages