Skip to content

Enhance field_dot_global function with detailed comments and update i… - #29

Merged
HouseJaay merged 5 commits into
develfrom
devel_MX
Jul 28, 2026
Merged

HouseJaay merged 5 commits into
develfrom
devel_MX

Conversation

@xumi1993

@xumi1993 xumi1993 commented Jul 26, 2026 •

Copy link
Copy Markdown
Member

close #28

xumi1993 added 2 commits July 26, 2026 15:43
…ts signature to include path_alpha for improved directional derivative calculations
…ter and optimize kernel value calculation for improved clarity and performance

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the L-BFGS line-search directional-derivative computation (field_dot_global) to better reflect the physical model update rules (multiplicative vs/vp/rho/gamma vs additive gc/gs) and adds more detailed logging/comments, aiming to address the stalling reported in issue #28.

Changes:

  • Replaces the previous simple inner-product reduction with an MPI-reduced directional derivative that includes spherical surface-area quadrature weights.
  • Adds chain-rule handling notes and additional debug logging for Wolfe-condition evaluation.
  • Introduces a helper for trapezoidal nodal quadrature widths in lon/lat.
Comments suppressed due to low confidence (1)

src/optimize.cpp:139

  • For radial anisotropy, the p==5 kernel is applied to vsh = vs*gamma (Love waves), but the code currently uses (vsh/vs) * dir[5], which corresponds to gamma * d_gamma and misses the vs factor needed for -d(vsh)/dalpha = vsh0 * d_gamma under the multiplicative gamma update (gamma *= (1 - alpha*dir[5])). This will under-scale q/q1 and can break Wolfe line search decisions.
                    } else if (p == 5 &&
                               IP.inversion().model_para_type == MODEL_RADIAL_ANI) {
                        minus_dm_dalpha = (mg.vsh3d[index] / mg.vs3d[index]) * direction[p](ix, iy, iz);
                    } else {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/optimize.cpp
Comment on lines +121 to +127
if (p == 0) {
// vs(alpha) = vs0 * (1 - alpha*d_vs)
minus_dm_dalpha =
mg.vs3d[index] * direction[p](ix, iy, iz);
if (IP.inversion().model_para_type == MODEL_RADIAL_ANI) {
kernel_val = kernel[0](ix, iy, iz) + kernel[5](ix, iy, iz);
}
Comment thread src/optimize.cpp
Comment on lines +78 to +80
const int n = static_cast<int>(coords_deg.size());
if (n < 2) return _0_CR;

xumi1993 added 3 commits July 26, 2026 20:29
- Modified the `dep_anom` function to build depth anomalies using symmetric half-sines, improving clarity and performance.
- Updated error handling to ensure `nz` is greater than 0 and that `zgrids` is strictly increasing.
- Removed dependency on the `minpack` library for fitting parameters, simplifying the implementation.
- Adjusted the perturbation pattern generation to directly use the new `dep_anom` function.
- Changed the perturbation parameters in the example script to maintain consistency with the updated depth anomaly calculations.
@HouseJaay
HouseJaay merged commit 1d7a614 into devel Jul 28, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants