Skip to content

Fix the transverse-isotropic viscosity tensor in docstring and docs - #1228

Open
lmoresi wants to merge 1 commit into
developmentfrom
claude/blissful-planck-7xoylp
Open

lmoresi wants to merge 1 commit into
developmentfrom
claude/blissful-planck-7xoylp

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 18, 2026

Copy link
Copy Markdown
Member

The TransverseIsotropicFlowModel docstring printed the viscosity tensor with two errors. _build_c_tensor is correct and is unchanged.

  1. Sign. The code computes C = 2 eta_0 I - 2 (eta_0 - eta_1) Lambda. The docstring had +, which would make the plane stiffer than the bulk.
  2. Repeated term. n_i n_l delta_jk appeared twice. The first should be n_i n_k delta_jl.

The docstring now gives (Moresi & Muhlhaus 2006):

eta_ijkl = eta_0 I_ijkl - (eta_0 - eta_1) Lambda_ijkl,   tau_ij = 2 eta_ijkl edot_kl
Lambda_ijkl = 1/2 (n_i n_k d_jl + n_j n_k d_il + n_i n_l d_jk + n_j n_l d_ik) - 2 n_i n_j n_k n_l

It also states that viscous_model.c holds 2 eta_ijkl. The old text wrote tau = eta : edot, which is off by that factor of 2.

Other places that quoted the formula:

  • docs/advanced/vep-transverse-isotropy-faults.md gave 2 eta_0 I - (eta_0 - eta_1) Lambda, so the two terms were off by a factor of 2 from each other. It now uses the same form as the docstring, with sigma = 2 eta : edot.
  • In docs/examples/fluid_mechanics/intermediate/shear_box_2d_fault.py the correction had a + sign. Changed to -.
  • Ex_Anisotropy.py and Ex_ConstitutiveTensors.py printed I_ijkl = 1/2(d_ij d_kj + d_kl d_il), which pairs the wrong indices. Changed to d_ik d_jl + d_il d_jk. This is the identity tensor rather than the TI formula, but it is a one-line fix to a formula in the same section.
  • The TransverseIsotropicVEPFlowModel docstring doesn't quote the formula, so it is unchanged.

New tests/test_0611_transverse_isotropic_tensor.py (level_1, tier_b) contracts the model's c tensor with exact symbolic strain rates, using off-axis directors in 2D and 3D:

  • pure plane shear gives tau = 2 eta_1 edot, so tau_nt = 2 eta_1 edot_nt (this pins the sign);
  • a deviatoric stretch normal to the plane gives tau = 2 eta_0 edot.

Checklist (UW3 Style Charter — docs/developer/UW3_STYLE_CHARTER.md)

  • I have read the Style Charter and followed it over the surrounding code (S2)
  • No drive-by refactors, renames, or "while I was here" cleanups (S9). The only extra is the identity-tensor index fix noted above.
  • Bug fixes ship the regression test, written first, with level_* and tier_* markers (S8). The algebra was checked in standalone sympy: the code's sign passes both tests and the old docstring's + fails the shear test. This test has not been run against an installed build. The session container had no pixi or PETSc, so CI is the first real run.
  • No hedging names and no commented-out code (S3, S4)
  • Every exception swallow states its sanctioned failure mode in a comment (S4). N/A
  • New data access uses .array / mesh.X.coords (S7). N/A
  • Parallel safety considered (S11). N/A, symbolic only
  • No mesh entity or rank identified by coordinates (S12). N/A
  • No pixi.toml / pixi.lock changes
  • AI-assisted work carries the attribution line below

Noticed but not changed: constitutive_models.py:2136 raises SyntaxWarning: invalid escape sequence '\p' (a docstring that isn't a raw string). It is already on development.

Underworld development team with AI support from Claude Code


Generated by Claude Code

The TransverseIsotropicFlowModel docstring printed the anisotropic
correction with a + sign and repeated the n_i n_l delta_jk term (the
first should be n_i n_k delta_jl). _build_c_tensor computes
C = 2 eta_0 I - 2 (eta_0 - eta_1) Lambda, which is correct. The docstring
now states eta_ijkl = eta_0 I - (eta_0 - eta_1) Lambda with
tau = 2 eta : edot (Moresi & Muhlhaus 2006).

Same correction in docs/advanced/vep-transverse-isotropy-faults.md
(factor-of-2 inconsistency between the eta_0 and Lambda terms) and in
the shear_box_2d_fault example (+ sign). The I_ijkl printed in
Ex_Anisotropy and Ex_ConstitutiveTensors had the wrong index pairing.

New test_0611 pins the sign: pure plane shear gives tau_nt = 2 eta_1
edot_nt exactly, and a deviatoric stretch normal to the plane sees only
eta_0, in 2D and 3D with off-axis directors.

No code change.

Underworld development team with AI support from Claude Code
Copilot AI balanced review requested due to automatic review settings November 18, 2026 06:20

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
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