diff --git a/Cantera/src/numerics/NonlinearSolver.cpp b/Cantera/src/numerics/NonlinearSolver.cpp index a0eadc77e..5595564f2 100644 --- a/Cantera/src/numerics/NonlinearSolver.cpp +++ b/Cantera/src/numerics/NonlinearSolver.cpp @@ -465,9 +465,9 @@ namespace Cantera { * @param ydot_curr Current value of the time derivative of the solution vector */ void NonlinearSolver::doResidualCalc(const doublereal time_curr, const int typeCalc, const doublereal * const y_curr, - const doublereal * const ydot_curr) + const doublereal * const ydot_curr, const ResidEval_Type_Enum evalType) { - m_func->evalResidNJ(time_curr, delta_t_n, y_curr, ydot_curr, DATA_PTR(m_resid), Base_ResidEval); + m_func->evalResidNJ(time_curr, delta_t_n, y_curr, ydot_curr, DATA_PTR(m_resid), evalType); m_nfe++; m_resid_scaled = false; } @@ -955,9 +955,9 @@ namespace Cantera { * -> m_resid[] contains the result of the residual calculation */ if (solnType_ != NSOLN_TYPE_STEADY_STATE) { - doResidualCalc(time_curr, solnType_, y1, ydot1); + doResidualCalc(time_curr, solnType_, y1, ydot1, Base_LaggedSolutionComponents); } else { - doResidualCalc(time_curr, solnType_, y1, ydot0); + doResidualCalc(time_curr, solnType_, y1, ydot0, Base_LaggedSolutionComponents); } m_normResidTrial = residErrorNorm(DATA_PTR(m_resid)); diff --git a/Cantera/src/numerics/NonlinearSolver.h b/Cantera/src/numerics/NonlinearSolver.h index d3120195c..6232f9c67 100644 --- a/Cantera/src/numerics/NonlinearSolver.h +++ b/Cantera/src/numerics/NonlinearSolver.h @@ -141,9 +141,12 @@ namespace Cantera { * @param typeCalc Type of the calculation * @param y_curr Current value of the solution vector * @param ydot_curr Current value of the time derivative of the solution vector + * @param evalType Base evalulation type + * Defaults to Base_ResidEval */ void doResidualCalc(const doublereal time_curr, const int typeCalc, const doublereal * const y_curr, - const doublereal * const ydot_curr); + const doublereal * const ydot_curr, + const ResidEval_Type_Enum evalType = Base_ResidEval); //! Compute the undamped Newton step /*! diff --git a/Cantera/src/numerics/ResidJacEval.h b/Cantera/src/numerics/ResidJacEval.h index 085c7fe02..ee4c2a7d0 100644 --- a/Cantera/src/numerics/ResidJacEval.h +++ b/Cantera/src/numerics/ResidJacEval.h @@ -38,7 +38,14 @@ namespace Cantera { /*! * We calculate this when we want to display a solution */ - Base_ShowSolution + Base_ShowSolution, + //! Base residual calculation containing any lagged components + /*! + * We use this to calculate residuals when doing line searches along + * directions determined by Jacobians that are missing contributions + * from lagged entries. + */ + Base_LaggedSolutionComponents }; //! Wrappers for the function evaluators for Nonlinear solvers and Time steppers