Skip to content

Commit 47696e4

Browse files
authored
[VODE] Allow small margin for negativity caused by interpolation (#2017)
1 parent d76fd20 commit 47696e4

5 files changed

Lines changed: 20 additions & 6 deletions

File tree

integration/VODE/actual_integrator.H

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ void actual_integrator (BurnT& state, amrex::Real dt, bool is_retry=false)
2222

2323
auto istate = dvode(state, vode_state);
2424

25-
integrator_cleanup(vode_state, state, istate, state_save, dt);
25+
integrator_cleanup(vode_state, state, istate, state_save, dt,
26+
vode_final_state_species_failure_tolerance_factor);
2627

2728
}
2829

integration/VODE/actual_integrator_sdc.H

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ void actual_integrator (BurnT& state, amrex::Real dt, bool is_retry=false)
2727
auto istate = dvode(state, vode_state);
2828
state.error_code = istate;
2929

30-
integrator_cleanup(vode_state, state, istate, state_save, dt);
30+
integrator_cleanup(vode_state, state, istate, state_save, dt,
31+
vode_final_state_species_failure_tolerance_factor);
3132

3233

3334
}

integration/VODE/vode_type.H

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ constexpr amrex::Real HMIN = 0.0_rt;
2222
constexpr amrex::Real vode_increase_change_factor = 4.0_rt;
2323
constexpr amrex::Real vode_decrease_change_factor = 0.25_rt;
2424

25+
// The interpolation back to tout is not monotonic, so the final state
26+
// allows slightly more negativity than internal integration nodes.
27+
constexpr amrex::Real vode_final_state_species_failure_tolerance_factor = 1.5_rt;
28+
2529
// For the backward differentiation formula (BDF) integration
2630
// the maximum order should be no greater than 5.
2731
constexpr int VODE_MAXORD = 5;

integration/integrator_setup_sdc.H

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ state_backup_t integrator_backup (const BurnT& state) {
135135
template <typename BurnT, typename IntegratorT>
136136
AMREX_GPU_HOST_DEVICE AMREX_INLINE
137137
void integrator_cleanup (IntegratorT& int_state, BurnT& state,
138-
int istate, const state_backup_t& state_save, amrex::Real dt)
138+
int istate, const state_backup_t& state_save, amrex::Real dt,
139+
const amrex::Real final_state_species_failure_tolerance_factor = 1.0_rt)
139140
{
140141

141142
// Copy the integration data back to the burn state.
@@ -185,8 +186,11 @@ void integrator_cleanup (IntegratorT& int_state, BurnT& state,
185186
state.success = false;
186187
}
187188

189+
const amrex::Real final_state_species_failure_tolerance =
190+
final_state_species_failure_tolerance_factor * state.rho * integrator_rp::species_failure_tolerance;
191+
188192
for (int n = 0; n < NumSpec; ++n) {
189-
if (state.y[SFS+n] < -state.rho * integrator_rp::species_failure_tolerance) {
193+
if (state.y[SFS+n] < -final_state_species_failure_tolerance) {
190194
state.success = false;
191195
}
192196

integration/integrator_setup_strang.H

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ state_backup_t integrator_backup (const BurnT& state) {
119119
template <typename BurnT, typename IntegratorT>
120120
AMREX_GPU_HOST_DEVICE AMREX_INLINE
121121
void integrator_cleanup (IntegratorT& int_state, BurnT& state,
122-
int istate, const state_backup_t& state_save, amrex::Real dt)
122+
int istate, const state_backup_t& state_save, amrex::Real dt,
123+
const amrex::Real final_state_species_failure_tolerance_factor = 1.0_rt)
123124
{
124125

125126
// Copy the integration data back to the burn state.
@@ -156,8 +157,11 @@ void integrator_cleanup (IntegratorT& int_state, BurnT& state,
156157
state.success = false;
157158
}
158159

160+
const amrex::Real final_state_species_failure_tolerance =
161+
final_state_species_failure_tolerance_factor * integrator_rp::species_failure_tolerance;
162+
159163
for (int n = 1; n <= NumSpec; ++n) {
160-
if (int_state.y(n) < -integrator_rp::species_failure_tolerance) {
164+
if (int_state.y(n) < -final_state_species_failure_tolerance) {
161165
state.success = false;
162166
}
163167

0 commit comments

Comments
 (0)