Adding an algorithm
The 2D deterministic inversion is built so that a new algorithm only has to say how it chooses a direction. The driver in Inv2D.jl does the rest: stopping tests, step capping, line search, history and file output.
Steps
Create
src/Inv2D_<Name>.jland include it afterInv2D.jlinsrc/MTGeophysics.jl.Inv2D_NLCG.jlis the smallest complete example.Define a config type
<: AbstractInversion2D.Define these methods for it:
inv2d_taginv2d_initinv2d_prepare!, which returns the gradientinv2d_directioninv2d_accept!
Optional methods have defaults:
inv2d_reject!returns false, so a failed search ends the run.inv2d_inforeturns no extra history columns.inv2d_validateperforms no checks.
Building blocks
Inv2D.jl provides:
inv2d_frechet(problem, state): the weighted2n_data × n_activeFréchet derivativeinv2d_gradient(problem, state, G):Gᵗr + βRᵗ reginv2d_gradient(problem, state): the same gradient from adjoint solves, for gradient-only methods
See 2D inversion theory for the objective these act on.