Geophysical modeling and inversion with Python for geothermal monitoring

An introduction to pyGIMLi

Get slides

or

https://easygo-on.pygimli.org

Geophysical monitoring of subsurface processes

Binley et al. (2015)

Quantitative imaging and monitoring is challenging

The evolution of geophysical imaging for subsurface characterization

(Wagner & Uhlemann, 2021)

–> model coupling is challenging and requires versatile open-source software

Introduction to pyGIMLi

pyGIMLi is a versatile open-source toolbox with:

  • management tools for structured and unstructured meshes in 2D & 3D
  • computationally efficient finite-element and finite-volume solvers
  • various geophysical forward operators: ERT/IP, Seismics/GPR traveltime, Gravity, Magnetics, SP, EM
  • frameworks for constrained, joint and process-based inversions with region-specific regularization
  • open-source, platform compatible, documented & tested code
  • suitability for teaching & reproducible research
  • v1.0 published in Computers and Geosciences (Rücker et al., 2017) (among 5 Most Downloaded papers and 480 citations) and broadly used since

Basic inversion framework

The default inversion framework is based on the generalized Gauss-Newton method and is compatible with any given forward operator and thus applicable to various physical problems.

\[ \mathbf{W}_\text{d} (\mathbf{F}(\mathbf{m})-\mathbf{d}) \|^2_2 + \lambda \| \mathbf{W}_\text{m} (\mathbf{m}-\mathbf{m_0}) \|^2_2 \rightarrow\min \]

Note

The inversion is physics-independent and very flexible in terms of adding prior information, regularization and integrating different geophysical methods.

Website and documentation: https://pygimli.org

Rücker, C., Günther, T., Wagner, F.M., 2017. pyGIMLi: An open-source library for modelling and inversion in geophysics, Computers and Geosciences, 109, 106-123.

Rücker et al. (2017)

Software design

pyGIMLi is organized in three different abstraction levels:

In the application level, ready-to-use method managers and frameworks are provided. Method managers (pygimli.manager) hold all relevant functionality related to a geophysical method. A method manager can be initialized with a data set and used to analyze and visualize this data set, create a corresponding mesh, and carry out an inversion. Various method managers are available in pygimli.physics. Frameworks (pygimli.frameworks) are generalized abstractions of standard and advanced inversions tasks such as time-lapse or joint inversion for example. Since frameworks communicate through a unified interface, they are method independent.

In the modelling level, users can set up customized forward operators that map discretized parameter distributions to a data vector. Once defined, it is straightforward to set up a corresponding inversion workflow or combine the forward operator with existing ones.

The underlying equation level allows to directly access the finite element (pygimli.solver.solveFiniteElements()) and finite volume (pygimli.solver.solveFiniteVolume()) solvers to solve various partial differential equations on unstructured meshes, i.e. to approach various physical problems with possibly complex 2D and 3D geometries.

Rücker et al. (2017)

Existing tutorials

  • Transform 2021: creating geometries & meshes, modeling PDEs, synthetic data, inversion (also with external forward operator).
  • Transform 2022: fundamental pyGIMLi objects (Mesh, DataContainer, matrix types, etc.), geostatistical vs. smoothness regularization, treatment of subsurface regions, adding prior data.
  • SEG webinar 2024: invert real-life 3D data (Hübner et al., 2017) to tweak your inversion beyond the standard practice.
  • GELMON 2025: ERT time-lapse data processing and inversion + image appraisal

Recent developments in pyGIMLi

  • Improved 3D visualization powered by pyvista (including filters, slices and interactive notebook compatibility)
  • 3D gravity and (full-tensor) magnetics operators and managers
  • New matrices and matrix generators
  • LSQRinversion framework enabling additional parameter relations (from Wagner et al., 2019)
  • MultiFrameModelling framework for temporally/spectrally/spatially constrained inversion
  • TimelapseERT class with different strategies, e.g. 4D inversion
  • New examples on ERT (2D/3D crosshole, 3D surface, timelapse), IP, 3D magnetics
  • Improved website and new user-guide coming soon
  • enabled pip install pygimli for easier installation (e.g. on Google Colab)
  • fully complex-valued (FD) ERT-IP inversion (also for TD)

Join the pyGIMLi user community!

“In open source, we feel strongly that to really do something well, you have to get a lot of people involved.”

– Linus Torvalds

  1. Join the #pyGIMLi chat on Mattermost!
  2. Open a discussion or raise an issue on GitHub.
  3. Contribute to the website via the “Improve this page” button in the right sidebar.
  4. Add your pyGIMLi-powered publication to this database.
  5. Send your example to mail@pygimli.org.
  6. Contribute to the code as described in our contribution guidelines.

Modeling demonstration

Creating a simple subsurface model

import pygimli as pg
import pygimli.meshtools as mt

# Create a simple 3 layer model
world = mt.createWorld(start=[-20, 0], end=[20, -16], layers=[-2, -8],
                       worldMarker=False)

pg.show(world, markers=True)

Creating a simple subsurface model

import pygimli as pg
import pygimli.meshtools as mt

# Create a simple 3 layer model
world = mt.createWorld(start=[-20, 0], end=[20, -16], layers=[-2, -8],
                       worldMarker=False)

# Create a heterogeneous block
block = mt.createRectangle(start=[-6, -3.5], end=[6, -6.0],
                           marker=4,  boundaryMarker=10, area=0.1)

# Merge geometrical entities
geom = world + block

pg.show(geom, markers=True)

Meshing the geometry

mesh = mt.createMesh(geom, quality=33, area=0.2, smooth=[1, 10])
pg.show(mesh)

Solving a PDE on the mesh

\[c \frac{\partial u}{\partial t} = \nabla\cdot(a \nabla u) + b u + f(\mathbf{r},t)~~|~~\Omega_{\text{Mesh}}\]

T = pg.solver.solveFiniteElements(mesh,
                                  a={1: 1.0, 2: 2.0, 3: 3.0, 4:0.1},
                                  bc={'Dirichlet': {8: 1.0, 4: 0.0}},
                                  verbose=True)
ax, _ = pg.show(mesh, data=T, label='Temperature $T$',
                cMap="hot_r", nCols=8, contourLines=False)

pg.show(geom, ax=ax, fillRegion=False)
Mesh:  Mesh: Nodes: 2987 Cells: 5782 Boundaries: 8768
Assembling time:  0.0465015
Solving time:  0.005456584

Gravity modeling and inversion

References

Binley, A., Hubbard, S. S., Huisman, J. A., Revil, A., Robinson, D. A., Singha, K., & Slater, L. D. (2015). The emergence of hydrogeophysics for improved understanding of subsurface processes over multiple scales. Water Resources Research, 51(6), 3837–3866. https://doi.org/https://doi.org/10.1002/2015WR017016
Hübner, R., Günther, T., Heller, K., Noell, U., & Kleber, A. (2017). Impacts of a capillary barrier on infiltration and subsurface stormflow in layered slope deposits monitored with 3-d ERT and hydrometric measurements. Hydrology and Earth System Sciences, 21(10), 5181–5199. https://doi.org/10.5194/hess-21-5181-2017
Rücker, C., Günther, T., & Wagner, F. M. (2017). pyGIMLi: An open-source library for modelling and inversion in geophysics. Computers and Geosciences, 109, 106–123. https://doi.org/10.1016/j.cageo.2017.07.011
Wagner, F. M., Mollaret, C., Günther, T., Kemna, A., & Hauck, C. (2019). Quantitative imaging of water, ice, and air in permafrost systems through petrophysical joint inversion of seismic refraction and electrical resistivity data. Geophysical Journal International, 219(3), 1866–1875. https://doi.org/10.1093/gji/ggz402
Wagner, F. M., & Uhlemann, S. (2021). An overview of multimethod imaging approaches in environmental geophysics. Advances in Geophysics, Vol. 44, 62, 1–72. https://doi.org/10.1016/bs.agph.2021.06.001