Skip to content

Commit

Permalink
[1D] Switch to "steady mode" before attempting steady-state solve
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
speth committed Mar 27, 2016
1 parent 85c3bf5 commit 9353a79
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/oneD/OneDim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/oneD/Sim1D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 9353a79

Please sign in to comment.