adjtomo / seisflows

An automated workflow tool for full waveform inversion and adjoint tomography
http://seisflows.readthedocs.org
BSD 2-Clause "Simplified" License
178 stars 122 forks source link

methodology for line search inversion using the gradient #187

Open avinash07guddu opened 7 months ago

avinash07guddu commented 7 months ago

Hello, I am trying to run the 2D example walkthrough. I am interested in learning the math/methodology behind the line search / bracket search method used in this example for the inversion step.

It seems in this step "scaling gradient to absolute model perturbations", the misfit kernel (sum of kernels for individual sources) in the scratch/eval_grad/misfit_kernel/ directory is simply multiplied with model (Vs) to produce the gradient in the scratch/eval_grad/gradient/ directory. The misfit is the time integral of the square of the difference between observed and predicted waveforms. The initial candidate value of the steplength alpha (1.51E+12 in the example) that should be multiplied with the gradient to produce the model perturbations appears to be 1/sum(G.^2) where G is the gradient (a 2D matrix). I am trying to understand how next two considered values of alpha (1.21E+10, 1.95E+09) are produced.

2024-02-16 02:20:10 (I) | try: first evaluation, attempt guess step length, alpha=1.51E+12
2024-02-16 02:20:10 (I) | try: applying initial step length safegaurd as alpha has exceeded maximum step length, alpha_new=1.21E+10
2024-02-16 02:20:10 (D) | overwriting initial step length, alpha_new=1.95E+09

After this, it seems the alpha value is just multiplied by the golden ratio (1.62) again and again to find a local minima in the misfit. If you can please point the subroutine that does these calculations or some documentation for these steps, it will be very helpful. Thanks.

bch0w commented 7 months ago

Hi @avinash07guddu, thanks for the question. Optimization and line search are handled by the optimize module and the underlying line_search tools, the hierarchy here goes: Workflow.Inversion -> Optimize.Gradient -> LineSearch.Bracket.

For your specific question, alpha is calculated by the line search https://github.com/adjtomo/seisflows/blob/487b7383a82e9e47427d177372ae57c094dab1fe/seisflows/plugins/line_search/bracket.py#L133-L218

But the step length safeguard happens in the optimization module: https://github.com/adjtomo/seisflows/blob/487b7383a82e9e47427d177372ae57c094dab1fe/seisflows/optimize/gradient.py#L344-L347

Hopefully that answers your question, or provides you with the correct files to look at!

bch0w commented 6 months ago

Hi @avinash07guddu, just wondering if the above reply answered your question and we can close this issue?