Skip to content

WP4: sonic anisotropy (gamma from Stoneley and dipole logs) - #5

Merged
ingehap merged 1 commit into
mainfrom
claude/blissful-gauss-3y1u5w
Oct 14, 2026
Merged

ingehap merged 1 commit into
mainfrom
claude/blissful-gauss-3y1u5w

Conversation

@ingehap

@ingehap ingehap commented Oct 14, 2026

Copy link
Copy Markdown
Owner

This PR implements work package 4 of docs/IMPLEMENTATION_PLAN.md: Thomsen's γ in a vertical well, from the dipole C44 and the Stoneley-derived C66 (Walsh et al., 2007). It is validated on the synthetic Wisting-like well, where the true γ is known.

What is added

  • iwt.sonic
    • Tube-wave relation with a concentric tool, and its inverse. Following Norris & Sinha (1993), the tube wave senses an effective shear modulus, which is C66 for a vertical well in a VTI formation. The tool term comes from the annulus compliance (Norris, 1990).
    • Exact Stoneley mode of a fluid-filled borehole along the axis of a TI formation, with a tool. It uses the formation fields of White & Tongtaow (1981) and handles leaky modes (complex slowness, outgoing radiation). It is solved for a whole log at once: 2400 depths take about 1.5 s.
    • Dispersion-corrected C66 inversion. The C11 and C13 that a vertical well does not measure come from assumed Thomsen ε and δ. The isotropic shortcut is available for comparison.
    • Dipole C44 matched to the Stoneley wave. C44 is moved to the Stoneley frequency (constant Q) and averaged over the Stoneley aperture before γ is formed.
    • Uncertainty: the exact Jacobian of γ, with linear propagation.
    • Mud-slowness calibration in a reference interval.
  • iwt.synthetic: a caliper log with washouts, and a Stoneley log computed with the exact mode in the Backus average of the model over the array aperture.
  • examples/wp4_sonic_anisotropy.py (about 50 s) and docs/figures/wp4_*.png.
  • README and plan: updated, with as-built notes and verified references. Version 0.4.0.

Results on the synthetic well

Check Result
Exact mode vs tube-wave limit (with tool) and Scholte limit match to 1e-6 and 1e-4
Round trip: forward exact mode → inversion C66 recovered to 1e-7
Stoneley wave in the overburden shales leaky: the C66 tube wave outruns the C44 axial shear wave. Radiation 1/Q ≈ 0.01 at 500 Hz; slowness 1.9 % above the tube wave
Isotropic substitute (μ = C66) vs TI with ε = δ = 0, at 500 Hz slowness error 1.1 % vs 0.2 %; the measured C44 matters more than ε and δ
γ with all corrections and the true mud slowness every unit within 0.014 of the truth
Effect of a 2.7 % mud-slowness error +0.05 to +0.10 in γ, the dominant error, as the plan expected
Mud calibrated in the Stø assumed isotropic (true γ = 0.023) mud velocity 1563 against 1540 m/s; γ errors −0.01 to −0.04
σ(γ) from the budget (2 % mud uncertainty) 0.033–0.055; Monte Carlo agrees to 0.001–0.003

Departures from the plan

  • Eccentricity is not modelled. Norris (1990) reports that eccentricity lowers the tube-wave speed. The plan had listed an eccentricity correction.
  • Added beyond the plan:
    • the exact (leaky) Stoneley mode;
    • matching the dipole's frequency and resolution to the Stoneley wave;
    • the mud calibration.
  • Ambiguity near the leaky–trapped transition. There, the measured real slowness can be matched by two C66 values (1 random sample in 2400). The Stoneley attenuation would resolve it. This is documented.

Tests

  • 18 new tests, 111 in all, passing on Python 3.13 with RuntimeWarning and DeprecationWarning raised as errors.
  • On Python 3.9 with numpy 1.21 and scipy 1.7: 107 pass and 1 module is skipped, because matplotlib is not installed there.
  • pyflakes is clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_019vaUDUPicoFeQaUhfhnoYq


Generated by Claude Code

- iwt.sonic: tube-wave relation with a concentric tool and its inverse
  (C66 as the effective modulus, Norris & Sinha 1993); the exact Stoneley
  mode of a fluid-filled borehole along the axis of a TI formation, with a
  tool, including leaky modes on the outgoing sheet, solved for whole logs at
  once; dispersion-corrected C66 inversion (TI with assumed eps, delta, or the
  isotropic shortcut); dipole C44 moved to the Stoneley frequency and averaged
  to its aperture; exact gamma Jacobian and linear uncertainty propagation;
  mud-slowness calibration in a reference interval.
- iwt.synthetic: caliper log with washouts and a Stoneley slowness log from
  the exact mode in the Backus medium of the array aperture.
- examples/wp4_sonic_anisotropy.py and docs/figures/wp4_*.png; README and
  plan updated (WP4 done, as-built notes, references); version 0.4.0.
- 18 new tests (111 in all).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019vaUDUPicoFeQaUhfhnoYq
@ingehap
ingehap marked this pull request as ready for review October 14, 2026 14:13
Copilot AI balanced review requested due to automatic review settings October 14, 2026 14:13
@ingehap
ingehap merged commit cd67dd7 into main Oct 14, 2026
4 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The leaky-mode determinant scaling and validation workflow contain correctness issues, and the uncertainty calculation omits dispersion dependence.

4 open findings
What changed in this PR

Implements WP4 sonic anisotropy, deriving Thomsen’s γ from dipole and Stoneley logs.

Changes:

  • Adds tube-wave and exact TI Stoneley modelling and inversion.
  • Adds synthetic caliper/Stoneley logs, uncertainty propagation, and validation.
  • Updates documentation and releases version 0.4.0.
File Description
iwt/​sonic.py Adds sonic anisotropy modelling and inversion.
iwt/​synthetic.py Adds caliper and Stoneley logs.
tests/​test_sonic.py Adds WP4 tests.
examples/​wp4_sonic_anisotropy.py Demonstrates processing and uncertainty analysis.
README.md Documents WP4 usage and results.
docs/​IMPLEMENTATION_PLAN.md Marks WP4 complete.
iwt/​__init__.py Exports the sonic module and version.
pyproject.toml Bumps version to 0.4.0.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread iwt/sonic.py
Comment on lines +232 to +240
ea = np.exp(-f * (b - a))
c = 0.0 if np.isinf(kt) else pf * a / (2.0 * kt)
M = np.array([
[f * ive(1, f * b), -f * kve(1, f * b) * ea, col[0][0], col[1][0]],
[-pf * ive(0, f * b) / sc, -pf * kve(0, f * b) * ea / sc, col[0][1], col[1][1]],
[zero, zero, col[0][2], col[1][2]],
[(f * ive(1, f * a) + c * ive(0, f * a)) * ea,
-f * kve(1, f * a) + c * kve(0, f * a), zero, zero],
])
Comment on lines +88 to +94
c44_m = S.running_average(z, logs.rho * logs.vs ** 2, APERTURE, harmonic=True)
rho_m = S.running_average(z, logs.rho, APERTURE)
vs_m = np.sqrt(c44_m / rho_m)
qs = 0.5 * model.qp[model.layer_index(z)]
f_dip = logs.meta["f_sonic_s"]
base = (logs.vp, logs.vs, logs.rho, st.slowness)
matched = (logs.vp, vs_m, rho_m, st.slowness)
Comment on lines +127 to +129
s_tube = st.slowness / final.dispersion
J = S.gamma_jacobian(s_tube, 1.0 / vs_m, rho_m, mud_cal.slowness, mud_cal.density, caliper,
TOOL.tool_radius, 0.0)
Comment on lines +245 to +246
- **Tool term:** built as planned. **Eccentricity is not modelled.** Norris (1990) reports
that it lowers the tube-wave speed, but the size of the effect was not quantified here.
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