From 9353a79da2c132c015a816c22810c3ff2ec932f9 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Sat, 19 Mar 2016 15:39:14 -0400 Subject: [PATCH] [1D] Switch to "steady mode" before attempting steady-state solve The solver could previously get left in transient mode if an exception occurred during time stepping, making it impossible to make a new attempt at solving the steady-state problem. --- src/oneD/OneDim.cpp | 8 ++++---- src/oneD/Sim1D.cpp | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/oneD/OneDim.cpp b/src/oneD/OneDim.cpp index e177d0117..c8b5bb4de 100644 --- a/src/oneD/OneDim.cpp +++ b/src/oneD/OneDim.cpp @@ -301,6 +301,10 @@ void OneDim::initTimeInteg(doublereal dt, doublereal* x) void OneDim::setSteadyMode() { + if (m_rdt == 0) { + return; + } + m_rdt = 0.0; m_jac->updateTransient(m_rdt, m_mask.data()); @@ -384,10 +388,6 @@ doublereal OneDim::timeStep(int nsteps, doublereal dt, doublereal* x, } } - // Prepare to solve the steady problem. - setSteadyMode(); - newton().setOptions(m_ss_jac_age); - // return the value of the last stepsize, which may be smaller // than the initial stepsize return dt; diff --git a/src/oneD/Sim1D.cpp b/src/oneD/Sim1D.cpp index 61a2d2529..a913c605a 100644 --- a/src/oneD/Sim1D.cpp +++ b/src/oneD/Sim1D.cpp @@ -5,6 +5,7 @@ #include "cantera/oneD/Sim1D.h" #include "cantera/oneD/MultiJac.h" #include "cantera/oneD/StFlow.h" +#include "cantera/oneD/MultiNewton.h" #include "cantera/numerics/funcs.h" #include "cantera/base/xml.h" @@ -244,6 +245,9 @@ void Sim1D::solve(int loglevel, bool refine_grid) writeline('.', 78, true, true); } while (!ok) { + // Attempt to solve the steady problem + setSteadyMode(); + newton().setOptions(m_ss_jac_age); debuglog("Attempt Newton solution of steady-state problem...", loglevel); int status = newtonSolve(loglevel-1);