Skip to content

Code layout ​

This section is for people who want to change or extend MTGeophysics.jl. It collects the details that the user pages leave out: every control file key, how the 2D solver treats topography, the equations of the 2D inversions, and how to add a new inversion algorithm.

For how to contribute (branches, tests, pull requests) see CONTRIBUTING.md.

1D ​

FileContents
src/Fwd1D.jllayer recursion, mt1d_layers, MakeMesh1D, Fréchet derivatives, ForwardSolve1D
src/Inv1D.jlInvCtrl1D, Invert1D (its own GN and VFSA), 1D plots

1D is self-contained: it shares only the data and model file formats and the plot style with 2D, so changes to the 2D solver or inversions cannot change 1D results.

2D ​

FileContents
src/Control2D.jlfwd.ctrl, inv.ctrl, VFSA control, cov.ctrl and mask.ctrl readers and writers
src/Mesh2D.jlmesh geometry, topography helpers, model builders and model I/O
src/Fwd2D.jlTE/TM solver, data I/O, misfit, Fréchet derivatives (G, G δm, Gᵗ δd̂)
src/Strike2D.jlphase tensor strike estimate and rotation to the strike frame
src/Topo2D.jltopo.dat, topography and water cut into models
src/Mask2D.jlmasks for cov.ctrl and mask.ctrl
src/MakeMesh2D.jl, src/MakeMesh2DGUI.jlthe 2D mesh tool, batch and GLMakie
src/Inv2D.jlproblem setup, objective, regularisation, line search, driver, six-file Invert2D
src/Inv2D_GN.jldamped Gauss–Newton
src/Inv2D_NLCG.jlpreconditioned nonlinear conjugate gradients
src/Inv2D_VFSA.jlvery fast simulated annealing, its ensemble and the five-file VFSA2D
src/PlotModel2D.jlresistivity sections and the mesh
src/PlotData2D.jldata curves and fit, convergence, PlotInversion2D

The continuous problem the 2D solver discretises is stated at the top of src/Fwd2D.jl.

3D and shared ​

FileContents
src/Data.jl, src/Model.jlModEM data and model I/O
src/WS3DModel.jlWS3D model I/O
src/Rotate.jlrotate_data and the rotation history
src/Chi2RMS.jl, src/Distortion.jl3D misfit, with and without galvanic distortion
src/MakeMesh3D.jl, src/MakeMesh3DGUI.jlthe 3D mesh tool
src/MeshToMesh.jlresampling a model onto another mesh
src/Mask3D.jltopography and bathymetry of 3D models
src/VFSA3DMT.jl3D VFSA with ModEM as the forward solver, and ensemble statistics
src/CoreUtils3D.jlcore and padding detection
src/PhaseTensor.jlphase tensors, induction vectors and their GIS export
src/PlotModel3D.jl, src/PlotData3D.jl, src/EditModel3D.jlGLMakie viewers and editors

Tests ​

bash
julia --project=. test/runtests.jl

test/TestFrechet2D.jl checks the 2D Fréchet derivatives against finite differences and with the dot-product test; test/TestTopography2D.jl checks the solver against a published topography model (see 2D solver notes).