Skip to content

Commit 290d278

Browse files
committed
VODE: bail out of the nonlinear solve if we predict negative mass fractions
1 parent 4fdcf27 commit 290d278

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

integration/VODE/vode_dvnlsd.H

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,32 @@ amrex::Real dvnlsd (int& NFLAG, BurnT& state, DvodeT& vstate)
112112
(vstate.RL1 * vstate.yh(i,2) + vstate.acor(i));
113113
}
114114

115+
// sometime VODE goes way off tangent. If these mass fractions
116+
// are really bad, then let's just bail now
117+
118+
{
119+
amrex::Real rho_current = state.rho_orig + vstate.tn * state.ydot_a[SRHO];
120+
#ifdef SDC
121+
amrex::Real thresh = species_failure_tolerance * rho_current;
122+
#else
123+
amrex::Real thresh = species_failure_tolerance;
124+
#endif
125+
bool fail{};
126+
for (int i = 1; i <= NumSpec; ++i) {
127+
if (vstate.y(i) < -thresh) {
128+
fail = true;
129+
break;
130+
}
131+
}
132+
133+
if (fail) {
134+
NFLAG = -1;
135+
vstate.ICF = 2;
136+
vstate.IPUP = 1;
137+
return ACNRM;
138+
}
139+
}
140+
115141
#ifdef NEW_NETWORK_IMPLEMENTATION
116142
RHS::dgesl(vstate.jac, vstate.y);
117143
#else

0 commit comments

Comments
 (0)