Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move sim_steps increment #1806

Merged
merged 3 commits into from
Jun 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions src/steadystateproblem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,18 @@ void SteadystateProblem::runSteadystateSimulation(const Solver &solver,
convergence_check_frequency = 25;

while (true) {
/* check for maxsteps */
if (sim_steps >= solver.getMaxSteps()) {
throw NewtonFailure(AMICI_TOO_MUCH_WORK,
"exceeded maximum number of steps");
}
if (state_.t >= 1e200) {
throw NewtonFailure(AMICI_NO_STEADY_STATE,
"simulated to late time"
" point without convergence of RHS");
}
/* increase counter */
sim_steps++;
/* One step of ODE integration
reason for tout specification:
max with 1 ensures correct direction (any positive value would do)
Expand All @@ -648,6 +660,7 @@ void SteadystateProblem::runSteadystateSimulation(const Solver &solver,
only direction w.r.t. current t
*/
solver.step(std::max(state_.t, 1.0) * 10);

if (backward) {
solver.writeSolution(&state_.t, xB_, state_.dx, state_.sx, xQ_);
} else {
Expand All @@ -670,17 +683,6 @@ void SteadystateProblem::runSteadystateSimulation(const Solver &solver,

if (wrms_ < conv_thresh)
break; // converged
/* increase counter, check for maxsteps */
sim_steps++;
if (sim_steps >= solver.getMaxSteps()) {
throw NewtonFailure(AMICI_TOO_MUCH_WORK,
"exceeded maximum number of steps");
}
if (state_.t >= 1e200) {
throw NewtonFailure(AMICI_NO_STEADY_STATE,
"simulated to late time"
" point without convergence of RHS");
}
}

// if check_sensi_conv_ is deactivated, we still have to update sensis
Expand Down