Bugfix for nonlinear simulations with immediate_reset=.true.
David Dickinson
Branch: bugfix/avoid_double_shuffle_in_nonlinear_term
Branch: next
Merged
Merged pull request
Merged in bugfix/avoid_double_shuffle_in_nonlinear_term (pull request #107)
Merged in bugfix/avoid_double_shuffle_in_nonlinear_term (pull request #107)
Previously we recalculated the nonlinear term after deciding we have to reduce the time step. This introduced two bugs
We didn’t center the first calculation of g1 before returning to change the time step.
We shuffled the time history of the explicit source term (g1->g2->g3) both on the first call to add_explicit_terms (i.e. when we decide we need to reset) and then again on the next call once we’ve updated the time step.
This commit fixes both of these by ensuring the first calculation of g1 is completed before returning to change the time step and then skipping the recalculation of g1 after the time step has changed. We can skip this recalculation as this is an explicit term which only depends on g and the fields at the start of the time step, which do not change when we change the time step. This also provides a (very) small performance improvement.
Â
Fixes #61