Add Herschel-Bulkley non-Newtonian viscosity model#1545
Conversation
…e seq-routine dummies, doc accuracy
Claude Code ReviewHead SHA: f1a27cf Files changed:
FindingsNaN in
|
… the case validator
|
Thanks for the review — responses to both findings: Finding 1 ( Finding 2 ( |
…scosity-design.md
…on-Newtonian fluids
There was a problem hiding this comment.
Pull request overview
Adds a per-fluid Herschel–Bulkley (HB) non-Newtonian viscosity option (with Papanastasiou regularization) to the simulation target, integrating shear-dependent viscosity into existing viscous flux / stress machinery, plus toolchain validation and example/benchmark cases.
Changes:
- Introduces HB utilities (
m_hb_function) for viscosity evaluation, shear-rate computation, and mixture effective Reynolds-number computation. - Threads HB-aware viscosity into key simulation paths (viscous stresses/fluxes, dt/CFL stability reporting, and MPI parameter broadcast), gated by
any_non_newtonian. - Extends toolchain parameter inventory/validation and adds/updates non-Newtonian example cases + test goldens.
Reviewed changes
Copilot reviewed 46 out of 48 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| toolchain/mfc/test/cases.py | Adds NN smoke/regression cases and skips slow NN examples in CI example sweep. |
| toolchain/mfc/params/descriptions.py | Adds human-readable descriptions for new fluid_pp(i)%* NN parameters. |
| toolchain/mfc/params/definitions.py | Registers new NN parameters in the toolchain parameter registry. |
| toolchain/mfc/params_tests/negative_tests.py | Adds negative validator tests for NN constraints. |
| toolchain/mfc/case_validator.py | Adds check_non_newtonian constraints and hooks it into simulation validation. |
| tests/EE8D38CF/golden-metadata.txt | Adds golden metadata for NN test generation. |
| tests/E18624FD/golden-metadata.txt | Adds golden metadata for NN test generation. |
| tests/A582B270/golden-metadata.txt | Adds golden metadata for NN-related test. |
| tests/78EB6879/golden-metadata.txt | Adds golden metadata for NN test generation. |
| tests/5304E59F/golden-metadata.txt | Adds golden metadata for NN-related test. |
| tests/122B0BF3/golden-metadata.txt | Adds golden metadata for NN test generation. |
| tests/00C20EE8/golden-metadata.txt | Adds golden metadata for NN-related test. |
| src/simulation/m_viscous.fpp | Uses HB utilities to compute axis-cell effective viscosity/Re when NN is enabled; updates IBM stress tensor to use local NN viscosity. |
| src/simulation/m_time_steppers.fpp | Adjusts dt/CFL computation to use NN viscosity bounds when enabled. |
| src/simulation/m_riemann_solvers.fpp | Extends viscous source-flux routines to compute local NN effective Re at interfaces. |
| src/simulation/m_mpi_proxy.fpp | Broadcasts new NN fluid parameters and flags across ranks. |
| src/simulation/m_hb_function.fpp | New module providing HB viscosity formula, shear-rate, and mixture effective-Re routines (GPU-routine compatible). |
| src/simulation/m_global_parameters.fpp | Adds any_non_newtonian and per-fluid HB parameter arrays; populates and GPU-updates them at startup. |
| src/simulation/m_data_output.fpp | Updates stability-criteria output to account for NN viscosity bounds when enabled. |
| src/pre_process/m_mpi_proxy.fpp | Broadcasts NN fluid parameters/flag in pre_process. |
| src/pre_process/m_global_parameters.fpp | Initializes new NN fields in fluid_pp defaults. |
| src/post_process/m_mpi_proxy.fpp | Broadcasts NN fluid parameters/flag in post_process. |
| src/post_process/m_global_parameters.fpp | Initializes new NN fields in fluid_pp defaults. |
| src/common/m_derived_types.fpp | Extends physical_parameters with NN fields (flag + HB/clamp parameters). |
| examples/2D_poiseuille_thickening_nn/README.md | Documents shear-thickening power-law Poiseuille validation case. |
| examples/2D_poiseuille_thickening_nn/compare_analytic.py | Adds analytic comparison script for shear-thickening Poiseuille. |
| examples/2D_poiseuille_thickening_nn/case.py | Adds shear-thickening power-law Poiseuille input case. |
| examples/2D_poiseuille_nn/README.md | Documents shear-thinning power-law Poiseuille validation case. |
| examples/2D_poiseuille_nn/compare_analytic.py | Adds analytic comparison script for shear-thinning Poiseuille. |
| examples/2D_poiseuille_nn/case.py | Adds shear-thinning power-law Poiseuille input case. |
| examples/2D_lid_driven_cavity_nn/README.md | Documents qualitative lid-driven cavity NN example. |
| examples/2D_lid_driven_cavity_nn/case.py | Adds lid-driven cavity NN case. |
| examples/2D_herschel_bulkley_poiseuille_nn/README.md | Documents general HB (yield + power-law) Poiseuille validation case. |
| examples/2D_herschel_bulkley_poiseuille_nn/compare_analytic.py | Adds analytic comparison script for general HB Poiseuille. |
| examples/2D_herschel_bulkley_poiseuille_nn/case.py | Adds general HB Poiseuille input case. |
| examples/2D_bingham_poiseuille_nn/README.md | Documents Bingham (yield-stress) Poiseuille validation case. |
| examples/2D_bingham_poiseuille_nn/compare_analytic.py | Adds analytic comparison script for Bingham Poiseuille. |
| examples/2D_bingham_poiseuille_nn/case.py | Adds Bingham Poiseuille input case. |
| docs/references.bib | Adds the Papanastasiou (1987) reference entry. |
| docs/module_categories.json | Registers m_hb_function under Physics Models for documentation tooling. |
| docs/documentation/case.md | Documents the new NN viscosity inputs, formula, and usage notes. |
| #! Fill Re_visc(1:2) at a cylindrical-axis cell. Non-Newtonian path uses a | ||
| #! Herschel-Bulkley mixture inv-Re from the local strain rate; Newtonian path is | ||
| #! the original alpha-weighted harmonic average. Component-3 strain terms are | ||
| #! gated for compile validity (num_dims <= 2) and runtime safety (p > 0). |
| @@ -0,0 +1,96 @@ | |||
| !> | |||
| !! @file m_hb_function.f90 | |||
Comprehensive Multi-Agent Review (round 2, HEAD
|
…lt, stray HB params)
…raints, drop dev-history notes
|
All findings from the round-2 review are now addressed, in four commits:
Deliberately not addressed (disclosed scope limits in the PR description): cylindrical/IBM/3D NN paths have no independent benchmark beyond Newtonian invariance + shared-code reuse, and the |
Summary
Adds per-fluid Herschel–Bulkley (HB) non-Newtonian viscosity with Papanastasiou regularization to the simulation target. The effective viscosity is computed from the local strain-rate tensor every step, so it varies in space and time. Fully backward-compatible: all new parameters default to Newtonian behavior, and when no fluid is non-Newtonian every code path is bitwise-identical to today.
This is a clean reimplementation on current
master, replacing the stale #1298 (which could no longer be merged aftermasterrefactored the Riemann reconstruction buffers and IB types). It reuses the validated HB formula from that work and routes the shear-dependent viscosity through MFC's existing viscous machinery rather than recomputing gradients — which structurally avoids the rotated→physical index-mapping bug that affected #1298.What it can model
Effective viscosity:
tau0=0, nn=1(μ = K)tau0=0, nn≠1nn=1, tau0>0tau0>0, nn≠1Parameters (per fluid)
fluid_pp(i)%:non_newtonian(enable),K(consistency),nn(flow index),tau0(yield stress),hb_m(Papanastasiou regularization),mu_min/mu_max(viscosity clamps;mu_maxrequired),mu_bulk(optional bulk viscosity). All HB parameters are nondimensional (scaled byρ_ref U_ref L_ref), so1/μequals the local effective Reynolds number — consistent with howRe(1)is used for Newtonian fluids. See the newdocs/documentation/case.mdsection.Scope / integration
Shear-dependent viscosity is injected into MFC's existing viscous paths, all gated behind a global
any_non_newtonianflag:riemann_solver=1, HLLC=2) — via the shared source-flux routines, reusing the interface strain tensor and its existing physical indexing.mu_maxfor a guaranteed-stable timestep../mfc.sh validate): requiresviscous,K,nn,mu_max;tau0>0requireshb_m; incompatible withigr;model_eqns ∈ {2,3};riemann_solver ∈ {1,2}.Validation
y₀ = τ₀/(ρg)any_non_newtonian = .false.Examples added:
2D_poiseuille_nn(power-law + analytic check),2D_bingham_poiseuille_nn(yield-stress + plug-flow check),2D_lid_driven_cavity_nn(Li et al. 2015).Known limitations (honest)
riemann_solver1, 2); LF/HLLD are guarded off.Opening as draft for review.