Skip to content

NavierStokesSLCN takes a viscoelastic model's stress as its momentum flux, with the history at the model's order (UNFILED 39) - #1300

Open
lmoresi wants to merge 2 commits into
developmentfrom
bugfix/slcn-stress-flux-not-averaged
Open

lmoresi wants to merge 2 commits into
developmentfrom
bugfix/slcn-stress-flux-not-averaged

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member

NavierStokesSLCN with a viscoelastic model now takes the model's stress as its momentum flux, as Stokes does. It also builds the stress history at the model's order. No issue was filed: this is UNFILED 39 (H1, review of #1256), and this body is the report.

Measurements are by H7 (the stress-history desk, a Claude session on a 96-thread Linux workstation: Intel Xeon Gold 6240R, MPICH), serial.

The cause

  • The flux was integrated in time twice. The solver's momentum flux was the Adams-Moulton combination of its flux history, F1 = a0 σ^{n+1} + a1 σ*_0 + a2 σ*_1, with weights (5/12, 8/12, -1/12) at order 2. With a viscoelastic model that history is the stress, which the model's own BDF or exponential update already integrates in time. The average was a second integration on top. Stokes and the composed NavierStokes use σ^{n+1}.
  • The solver's order overwrote the model's. The base class's model setter gives the model the solver's order. A BDF-2 model on a solver built with order=1 therefore ran at order 1, because effective_order is the smaller of the model's and the history's.

What changes

  • With a model that needs a stress history, F1 is the model's flux, constitutive_model.flux (its total stress, a solvent viscosity included). A viscous flux keeps the Adams-Moulton average, which is its time integration, so viscous-only runs are unchanged.
  • NavierStokesSLCN.constitutive_model's setter builds the stress history at the order the model asks for, and leaves the model at that order. A history that has already been used cannot change order, and the setter refuses that case.

Measured

30 steps, Δt 0.1, BDF-2, rho 1e-6, 16×8 quads, against Stokes:

case development this PR
shear box, stress at the origin, largest relative difference over 30 steps 2.95 at step 30, diverging 1.04e-4 at step 13, falling to 5.3e-5
stiff inclusion (η = 1 + 9 exp(-r²/0.04) at (0.2, 0)), velocity at 5 points, step 30 277, diverging 3.2e-2 (NavierStokes against Stokes: 4.8e-2 on this box)
NavierStokesSLCN(order=1) given an order-2 model runs at order 1 history and model at order 2

Behaviour change, order 1 included:

  • The theta-0.5 average of the stress goes at every order. On the stiff-inclusion box at order 1 (BDF-1, 12 steps), the velocity's distance from Stokes falls from 1.04e-1 to 5.7e-3: this closes SLCN's gap at order 1.
  • On the Maxwell box after 5 ETD-1 solves, psi_star[0] reads 0.393424 against 0.393421 on development (exact 0.393469). NavierStokesSLCN commits its stress history after the solve (#742); it refuses a stress_transport it does not honour #1256's numbers stand.
  • A viscoelastic NavierStokesSLCN checkpoint written before this change will not restart identically after it: the momentum flux it was solved with is different.

Tests

tests/test_1297_navier_stokes_slcn_viscoelastic_order_two.py, level 2, tier B:

  • the shear box, SLCN against Stokes, every step, within 2e-4 of the peak stress;
  • the stiff-inclusion box, velocity within 0.1 of Stokes;
  • the model keeps order 2 and the history is built at it.

All three fail on development and pass here. With test_1059, test_1063 and every file that builds NavierStokesSLCN, SNES_NavierStokes or NavierStokesSwarm (test_1247 among them): 113 passed.

Checklist (UW3 Style Charter)

  • Style Charter followed (S2); no drive-by changes (S9)
  • Regression test written first, with level_2 and tier_b markers; it fails on development (S8)
  • No hedging names, commented-out code or exception swallows (S3, S4)
  • No new collective; serial-equivalent change (S11)
  • No coordinates identify entities (S12); no dependency changes
  • AI-assisted

Underworld development team with AI support from Claude Code

…flux, with the history at the model's order (UNFILED 39)

The solver formed its momentum flux as the Adams-Moulton average of its flux history. With
a viscoelastic model that history is the stress, which the model's BDF or exponential
update already integrates in time, so the average was a second integration on top: at
order 2 it diverged (the BDF-2 shear box 2.95 from Stokes at step 30; with a stiff
inclusion 277). With a stress history the momentum flux is now the model's flux, as in
Stokes; a viscous flux keeps the average. The solver's order also overwrote the model's,
so a BDF-2 model on a solver of order 1 ran at order 1; the history is now built at the
model's order, and the model keeps it.

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

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