Commit 4813f74
committed
Fix zero-shear NaN/Inf in f_compute_hb_viscosity
When shear_rate == 0, the naive formula produces 0/0 (yield term) and
0^(nn-1) which is Inf for nn<1 (power-law term). Both corrupt viscosity
and propagate into Re, fluxes, and dt.
Fix:
- Yield term: use analytic L'Hopital limit (1-exp(-m*g))/g -> m at g=0,
so yield_term = tau0*hb_m when shear_rate <= verysmall
- Power-law term: use g_eff = max(shear_rate, verysmall) so nn<1 fluids
get a large-but-finite viscosity at rest, bounded by mu_max
Addresses reviewer comment from qodo-code-review.1 parent 3c636c5 commit 4813f74
1 file changed
Lines changed: 13 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
42 | 50 | | |
43 | 51 | | |
44 | 52 | | |
| |||
0 commit comments