@@ -223,12 +223,18 @@ int dvstep (BurnT& state, DvodeT& vstate)
223223
224224#ifdef SDC
225225 if (vstate.y (SEINT+1 ) < 0 .0_rt) {
226+ #ifdef MICROPHYSICS_DEBUG
227+ std::cout << " rejecting due to rho e" << std::endl;
228+ #endif
226229 valid_update = false ;
227230 }
228231
229232 amrex::Real rho_current = state.rho_orig + vstate.tn * state.ydot_a [SRHO];
230233
231234 if (rho_current < 0 .0_rt) {
235+ #ifdef MICROPHYSICS_DEBUG
236+ std::cout << " rejecting due to rho" << std::endl;
237+ #endif
232238 valid_update = false ;
233239 }
234240#endif
@@ -294,11 +300,17 @@ int dvstep (BurnT& state, DvodeT& vstate)
294300 }
295301
296302 if (vstate.y (SFS+i) < -species_failure_tolerance * rho_current) {
303+ #ifdef MICROPHYSICS_DEBUG
304+ std::cout << " rejecting step due to negative species " << i << std::endl;
305+ #endif
297306 valid_update = false ;
298307 break ;
299308 }
300309
301310 if (vstate.y (SFS+i) > (1 .0_rt + species_failure_tolerance) * rho_current) {
311+ #ifdef MICROPHYSICS_DEBUG
312+ std::cout << " rejecting step due to large species " << i << std::endl;
313+ #endif
302314 valid_update = false ;
303315 break ;
304316 }
@@ -313,6 +325,19 @@ int dvstep (BurnT& state, DvodeT& vstate)
313325 DSM = ACNRM / vstate.tq (2 );
314326 if (DSM <= 1 .0_rt && valid_update) {
315327
328+ #ifdef SDC
329+ // do normalization if desired
330+ amrex::Real rhoX_sum{};
331+ for (int n = 1 ; n <= NumSpec; ++n) {
332+ vstate.y (SFS+n) = amrex::Clamp (vstate.y (SFS+n), 0.0 , rho_current);
333+ rhoX_sum += vstate.y (SFS+n);
334+ }
335+
336+ amrex::Real fac = rho_current / rhoX_sum;
337+ for (int n = 1 ; n <= NumSpec; ++n) {
338+ vstate.y (SFS+n) *= fac;
339+ }
340+ #endif
316341 // After a successful step, update the yh and TAU arrays and decrement
317342 // NQWAIT. If NQWAIT is then 1 and NQ .lt. MAXORD, then ACOR is saved
318343 // for use in a possible order increase on the next step.
0 commit comments