Cantera  2.1.2
NonlinearSolver Class Reference

Class that calculates the solution to a nonlinear system. More...

#include <NonlinearSolver.h>

Collaboration diagram for NonlinearSolver:
[legend]

## Public Member Functions

NonlinearSolver (ResidJacEval *func)
Default constructor. More...

NonlinearSolver (const NonlinearSolver &right)
Copy Constructor. More...

~NonlinearSolver ()
Destructor. More...

NonlinearSolveroperator= (const NonlinearSolver &right)
Assignment operator. More...

void createSolnWeights (const doublereal *const y)
Create solution weights for convergence criteria. More...

doublereal solnErrorNorm (const doublereal *const delta_y, const char *title=0, int printLargest=0, const doublereal dampFactor=1.0) const
L2 norm of the delta of the solution vector. More...

doublereal residErrorNorm (const doublereal *const resid, const char *title=0, const int printLargest=0, const doublereal *const y=0) const
L2 norm of the residual of the equation system. More...

int doResidualCalc (const doublereal time_curr, const int typeCalc, const doublereal *const y_curr, const doublereal *const ydot_curr, const ResidEval_Type_Enum evalType=Base_ResidEval) const
Compute the current residual. More...

int doNewtonSolve (const doublereal time_curr, const doublereal *const y_curr, const doublereal *const ydot_curr, doublereal *const delta_y, GeneralMatrix &jac)
Compute the undamped Newton step. More...

int doAffineNewtonSolve (const doublereal *const y_curr, const doublereal *const ydot_curr, doublereal *const delta_y, GeneralMatrix &jac)
Compute the newton step, either by direct newton's or by solving a close problem that is represented by a Hessian. More...

doublereal trustRegionLength () const
Calculate the length of the current trust region in terms of the solution error norm. More...

void setDefaultDeltaBoundsMagnitudes ()
Set default deulta bounds amounts. More...

void setDeltaBoundsMagnitudes (const doublereal *const deltaBoundsMagnitudes)
Set the delta Bounds magnitudes by hand. More...

doublereal boundStep (const doublereal *const y, const doublereal *const step0)
Bound the step. More...

void setBoundsConstraints (const doublereal *const y_low_bounds, const doublereal *const y_high_bounds)
Set bounds constraints for all variables in the problem. More...

std::vector< doublereal > & lowBoundsConstraintVector ()
Return an editable vector of the low bounds constraints. More...

std::vector< doublereal > & highBoundsConstraintVector ()
Return an editable vector of the high bounds constraints. More...

void calc_ydot (const int order, const doublereal *const y_curr, doublereal *const ydot_curr) const
Internal function to calculate the time derivative of the solution at the new step. More...

int beuler_jac (GeneralMatrix &J, doublereal *const f, doublereal time_curr, doublereal CJ, doublereal *const y, doublereal *const ydot, int num_newt_its)
Function called to evaluate the jacobian matrix and the current residual vector at the current time step. More...

doublereal filterNewStep (const doublereal timeCurrent, const doublereal *const ybase, doublereal *const step0)
Apply a filtering process to the step. More...

doublereal filterNewSolution (const doublereal timeCurrent, doublereal *const y_current, doublereal *const ydot_current)
Apply a filter to the solution. More...

doublereal deltaBoundStep (const doublereal *const y, const doublereal *const step0)
Return the factor by which the undamped Newton step 'step0' must be multiplied in order to keep the update within the bounds of an accurate jacobian. More...

int dampStep (const doublereal time_curr, const doublereal *const y_n_curr, const doublereal *const ydot_n_curr, doublereal *const step_1, doublereal *const y_n_1, doublereal *const ydot_n_1, doublereal *step_2, doublereal &stepNorm_2, GeneralMatrix &jac, bool writetitle, int &num_backtracks)
Find a damping coefficient through a look-ahead mechanism. More...

int solve_nonlinear_problem (int SolnType, doublereal *const y_comm, doublereal *const ydot_comm, doublereal CJ, doublereal time_curr, GeneralMatrix &jac, int &num_newt_its, int &num_linear_solves, int &num_backtracks, int loglevelInput)
Find the solution to F(X) = 0 by damped Newton iteration. More...

virtual void setPreviousTimeStep (const std::vector< doublereal > &y_nm1, const std::vector< doublereal > &ydot_nm1)
Set the values for the previous time step. More...

void setColumnScaling (bool useColScaling, const double *const scaleFactors=0)
Set the column scaling that are used for the inversion of the matrix. More...

void setRowScaling (bool useRowScaling)
Set the rowscaling that are used for the inversion of the matrix. More...

void scaleMatrix (GeneralMatrix &jac, doublereal *const y_comm, doublereal *const ydot_comm, doublereal time_curr, int num_newt_its)
Scale the matrix. More...

void print_solnDelta_norm_contrib (const doublereal *const step_1, const char *const stepNorm_1, const doublereal *const step_2, const char *const stepNorm_2, const char *const title, const doublereal *const y_n_curr, const doublereal *const y_n_1, doublereal damp, size_t num_entries)
Print solution norm contribution. More...

void computeResidWts ()
Compute the Residual Weights. More...

void getResidWts (doublereal *const residWts) const
Return the residual weights. More...

int convergenceCheck (int dampCode, doublereal s1)
Check to see if the nonlinear problem has converged. More...

void setAtol (const doublereal *const atol)
Set the absolute tolerances for the solution variables. More...

void setRtol (const doublereal rtol)
Set the relative tolerances for the solution variables. More...

void setResidualTols (double residRtol, double *residAtol, int residNormHandling=2)
Set the relative and absolute tolerances for the Residual norm comparisons, if used. More...

void setMaxNewtIts (const int maxNewtIts)
Set the value of the maximum # of newton iterations. More...

void calcSolnToResNormVector ()
Calculate the scaling factor for translating residual norms into solution norms. More...

doublereal doCauchyPointSolve (GeneralMatrix &jac)
Calculate the steepest descent direction and the Cauchy Point where the quadratic formulation of the nonlinear problem expects a minimum along the descent direction. More...

void descentComparison (doublereal time_curr, doublereal *ydot0, doublereal *ydot1, int &numTrials)
This is a utility routine that can be used to print out the rates of the initial residual decline. More...

void setupDoubleDogleg ()
Setup the parameters for the double dog leg. More...

int lambdaToLeg (const doublereal lambda, doublereal &alpha) const
Change the global lambda coordinate into the (leg,alpha) coordinate for the double dogleg. More...

int calcTrustIntersection (doublereal trustVal, doublereal &lambda, doublereal &alpha) const
Given a trust distance, this routine calculates the intersection of the this distance with the double dogleg curve. More...

void initializeTrustRegion ()
Initialize the size of the trust vector. More...

void setTrustRegionInitializationMethod (int method, doublereal factor)
Set Trust region initialization strategy. More...

int dampDogLeg (const doublereal time_curr, const doublereal *y_n_curr, const doublereal *ydot_n_curr, std::vector< doublereal > &step_1, doublereal *const y_n_1, doublereal *const ydot_n_1, doublereal &stepNorm_1, doublereal &stepNorm_2, GeneralMatrix &jac, int &num_backtracks)
Damp using the dog leg approach. More...

int decideStep (const doublereal time_curr, int leg, doublereal alpha, const doublereal *const y_n_curr, const doublereal *const ydot_n_curr, const std::vector< doublereal > &step_1, const doublereal *const y_n_1, const doublereal *const ydot_n_1, doublereal trustDeltaOld)
Decide whether the current step is acceptable and adjust the trust region size. More...

doublereal expectedResidLeg (int leg, doublereal alpha) const
Calculated the expected residual along the double dogleg curve. More...

void residualComparisonLeg (const doublereal time_curr, const doublereal *const ydot0, int &legBest, doublereal &alphaBest) const
Here we print out the residual at various points along the double dogleg, comparing against the quadratic model in a table format. More...

void setPrintLvl (int printLvl)
Set the print level from the nonlinear solver. More...

void setSolverScheme (int doDogLeg, int doAffineSolve)
Parameter to turn on solution solver schemes. More...

## Public Attributes

int m_min_newt_its
Minimum number of newton iterations to use. More...

## Static Public Attributes

static bool s_TurnOffTiming
Turn off printing of time. More...

static bool s_print_NumJac
Turn on or off printing of the Jacobian. More...

static bool s_print_DogLeg
Turn on extra printing of dogleg information. More...

static bool s_doBothSolvesAndCompare
Turn on solving both the Newton and Hessian systems and comparing the results. More...

static bool s_alwaysAssumeNewtonGood
This toggle turns off the use of the Hessian when it is warranted by the condition number. More...

## Protected Member Functions

Readjust the trust region vectors. More...

void fillDogLegStep (int leg, doublereal alpha, std::vector< doublereal > &deltaX) const
Fill a dogleg solution step vector. More...

doublereal calcTrustDistance (std::vector< doublereal > const &deltaX) const
Calculate the trust distance of a step in the solution variables. More...

## Private Member Functions

void calcColumnScales ()
Set the column scaling vector at the current time. More...

## Private Attributes

ResidJacEvalm_func
Pointer to the residual and jacobian evaluator for the function. More...

int solnType_
Solution type. More...

size_t neq_
Local copy of the number of equations. More...

std::vector< doublereal > m_ewt
Soln error weights. More...

int m_manualDeltaStepSet
Boolean indicating whether a manual delta bounds has been input. More...

std::vector< doublereal > m_deltaStepMinimum
Soln Delta bounds magnitudes. More...

std::vector< doublereal > m_deltaStepMaximum
Value of the delta step magnitudes. More...

std::vector< doublereal > m_y_n_curr
Vector containing the current solution vector within the nonlinear solver. More...

std::vector< doublereal > m_ydot_n_curr
Vector containing the time derivative of the current solution vector within the nonlinear solver (where applicable) More...

std::vector< doublereal > m_y_nm1
Vector containing the solution at the previous time step. More...

std::vector< doublereal > m_ydot_nm1
Vector containing the solution derivative at the previous time step. More...

std::vector< doublereal > m_y_n_trial
Vector containing the solution at the new point that is to be considered. More...

std::vector< doublereal > m_ydot_trial
Value of the solution time derivative at the new point that is to be considered. More...

std::vector< doublereal > m_step_1
Value of the step to be taken in the solution. More...

std::vector< doublereal > m_colScales
Vector of column scaling factors. More...

std::vector< doublereal > m_rowScales
Weights for normalizing the values of the residuals. More...

std::vector< doublereal > m_rowWtScales
Weights for normalizing the values of the residuals. More...

std::vector< doublereal > m_resid
Value of the residual for the nonlinear problem. More...

std::vector< doublereal > m_wksp
Workspace of length neq_. More...

std::vector< doublereal > m_wksp_2
Workspace of length neq_. More...

std::vector< doublereal > m_residWts
Vector of residual weights. More...

doublereal m_normResid_0
Norm of the residual at the start of each nonlinear iteration. More...

doublereal m_normResid_Bound
Norm of the residual after it has been bounded. More...

doublereal m_normResid_1
Norm of the residual at the end of the first leg of the current iteration. More...

doublereal m_normResid_full
Norm of the residual at the end of the first leg of the current iteration. More...

doublereal m_normDeltaSoln_Newton
Norm of the solution update created by the iteration in its raw, undamped form, using the solution norm. More...

doublereal m_normDeltaSoln_CP
Norm of the distance to the cauchy point using the solution norm. More...

doublereal m_normResidTrial
Norm of the residual for a trial calculation which may or may not be used. More...

doublereal m_normResidPoints [15]
Vector of the norm. More...

bool m_resid_scaled
Boolean indicating whether we should scale the residual. More...

std::vector< doublereal > m_y_high_bounds
Bounds vector for each species. More...

std::vector< doublereal > m_y_low_bounds
Lower bounds vector for each species. More...

doublereal m_dampBound
Damping factor imposed by hard bounds and by delta bounds. More...

doublereal m_dampRes
Additional damping factor due to bounds on the residual and solution norms. More...

doublereal delta_t_n
Delta t for the current step. More...

int m_nfe
Counter for the total number of function evaluations. More...

int m_colScaling
The type of column scaling used in the matrix inversion of the problem. More...

int m_rowScaling
int indicating whether row scaling is turned on (1) or not (0) More...

int m_numTotalLinearSolves
Total number of linear solves taken by the solver object. More...

int m_numLocalLinearSolves
Number of local linear solves done during the current iteration. More...

int m_numTotalNewtIts
Total number of newton iterations. More...

int maxNewtIts_
Maximum number of newton iterations. More...

int m_jacFormMethod
Jacobian formation method. More...

int m_nJacEval
Number of Jacobian evaluations. More...

doublereal time_n
Current system time. More...

int m_matrixConditioning
Boolean indicating matrix conditioning. More...

int m_order
Order of the time step method = 1. More...

doublereal rtol_
value of the relative tolerance to use in solving the equation set More...

doublereal atolBase_
Base value of the absolute tolerance. More...

std::vector< doublereal > atolk_
absolute tolerance in the solution unknown More...

std::vector< doublereal > userResidAtol_
absolute tolerance in the unscaled solution unknowns More...

doublereal userResidRtol_
absolute tolerance in the unscaled solution unknowns More...

int checkUserResidualTols_
Check the residual tolerances explicitly against user input. More...

int m_print_flag
Determines the level of printing for each time step. More...

doublereal m_ScaleSolnNormToResNorm
Scale factor for turning residual norms into solution norms. More...

Cantera::GeneralMatrixjacCopyPtr_
Copy of the jacobian that doesn't get overwritten when the inverse is determined. More...

Cantera::GeneralMatrixHessianPtr_
Hessian. More...

std::vector< doublereal > deltaX_CP_
Steepest descent direction. This is also the distance to the Cauchy Point. More...

std::vector< doublereal > deltaX_Newton_
Newton Step - This is the newton step determined from the straight Jacobian. More...

doublereal residNorm2Cauchy_
Expected value of the residual norm at the Cauchy point if the quadratic model were valid. More...

int dogLegID_
Current leg. More...

doublereal dogLegAlpha_
Current Alpha param along the leg. More...

doublereal RJd_norm_
Residual dot Jd norm. More...

doublereal lambdaStar_
Value of lambdaStar_ which is used to calculate the Cauchy point. More...

std::vector< doublereal > Jd_
Jacobian times the steepest descent direction in the normalized coordinates. More...

std::vector< doublereal > deltaX_trust_
Vector of trust region values. More...

doublereal norm_deltaX_trust_
Current norm of the vector deltaX_trust_ in terms of the solution norm. More...

doublereal trustDelta_
Current value of trust radius. More...

int trustRegionInitializationMethod_
Method for handling the trust region initialization. More...

doublereal trustRegionInitializationFactor_
Factor used to set the initial trust region. More...

doublereal Nuu_
Relative distance down the Newton step that the second dogleg starts. More...

doublereal dist_R0_
Distance of the zeroeth leg of the dogleg in terms of the solution norm. More...

doublereal dist_R1_
Distance of the first leg of the dogleg in terms of the solution norm. More...

doublereal dist_R2_
Distance of the second leg of the dogleg in terms of the solution norm. More...

doublereal dist_Total_
Distance of the sum of all legs of the doglegs in terms of the solution norm. More...

doublereal JdJd_norm_
Dot product of the Jd_ variable defined above with itself. More...

doublereal normTrust_Newton_
Norm of the Newton Step wrt trust region. More...

doublereal normTrust_CP_
Norm of the Cauchy Step direction wrt trust region. More...

int doDogLeg_
General toggle for turning on dog leg damping. More...

int doAffineSolve_
General toggle for turning on Affine solve with Hessian. More...

doublereal m_conditionNumber
Condition number of the matrix. More...

doublereal CurrentTrustFactor_
Factor indicating how much trust region has been changed this iteration - output variable. More...

doublereal NextTrustFactor_
Factor indicating how much trust region has been changed next iteration - output variable. More...

bool ResidWtsReevaluated_
Boolean indicating that the residual weights have been reevaluated this iteration - output variable. More...

doublereal ResidDecreaseSDExp_
Expected DResid_dS for the steepest descent path - output variable. More...

doublereal ResidDecreaseSD_
Actual DResid_dS for the steepest descent path - output variable. More...

doublereal ResidDecreaseNewtExp_
Expected DResid_dS for the Newton path - output variable. More...

doublereal ResidDecreaseNewt_
Actual DResid_dS for the newton path - output variable. More...

## Detailed Description

Class that calculates the solution to a nonlinear system.

This is a small nonlinear solver that can solve highly nonlinear problems that must use a dense matrix to relax the system.

Newton's method is used.

Damping is used extensively when relaxing the system.

The basic idea is that we predict a direction that is parameterized by an overall coordinate value, beta, from zero to one, This may or may not be the same as the value, damp, depending upon whether the direction is straight.

TIME STEP TYPE

The code solves a nonlinear problem. Frequently the nonlinear problem is created from time-dependent residual. Whenever you change the solution vector, you are also changing the derivative of the solution vector. Therefore, the code has the option of altering ydot, a vector of time derivatives of the solution in tandem with the solution vector and then feeding a residual and Jacobian routine with the time derivatives as well as the solution. The code has support for a backwards euler method and a second order Adams-Bashforth or Trapezoidal Rule.

In order to use these methods, the solver must be initialized with delta_t and m_y_nm1[i] to specify the conditions at the previous time step. For second order methods, the time derivative at t_nm1 must also be supplied, m_ydot_nm1[i]. Then the solution type NSOLN_TYPE_TIME_DEPENDENT may be used to solve the problem.

For steady state problem whose residual doesn't have a solution time derivative in it, you should use the NSOLN_TYPE_STEADY_STATE problem type.

We have a NSOLN_TYPE_PSEUDO_TIME_DEPENDENT defined. However, this is not implemented yet. This would be a pseudo time dependent calculation, where an optional time derivative could be added in order to help equilibrate a nonlinear steady state system. The time transient is not important in and of itself. Many physical systems have a time dependence to them that provides a natural way to relax the nonlinear system.

MATRIX SCALING

nls->setDeltaBoundsMagnitudes(deltaBounds);
nls->solve_nonlinear_problem(solnType, y_comm, ydot_comm, CJ, time_curr, jac,
num_newt_its, num_linear_solves, numBacktracks,
loglevelInput);

Definition at line 125 of file NonlinearSolver.h.

## Constructor & Destructor Documentation

 NonlinearSolver ( ResidJacEval * func )
 NonlinearSolver ( const NonlinearSolver & right )

Copy Constructor.

Definition at line 198 of file NonlinearSolver.cpp.

References NonlinearSolver::operator=().

 ~NonlinearSolver ( )

Destructor.

Definition at line 287 of file NonlinearSolver.cpp.

References NonlinearSolver::HessianPtr_, and NonlinearSolver::jacCopyPtr_.

## Member Function Documentation

 void createSolnWeights ( const doublereal *const y )

Create solution weights for convergence criteria.

We create soln weights from the following formula

wt[i] = rtol * abs(y[i]) + atol[i]

The program always assumes that atol is specific to the solution component

Parameters
 y vector of the current solution values

Definition at line 394 of file NonlinearSolver.cpp.

Referenced by NonlinearSolver::solve_nonlinear_problem().

 doublereal solnErrorNorm ( const doublereal *const delta_y, const char * title = 0, int printLargest = 0, const doublereal dampFactor = 1.0 ) const

L2 norm of the delta of the solution vector.

calculate the norm of the solution vector. This will involve the column scaling of the matrix

The third argument has a default of false. However, if true, then a table of the largest values is printed out to standard output.

Parameters
 delta_y Vector to take the norm of title Optional title to be printed out printLargest int indicating how many specific lines should be printed out dampFactor Current value of the damping factor. Defaults to 1. only used for printout out a table.
Returns
Returns the L2 norm of the delta

Definition at line 431 of file NonlinearSolver.cpp.

 doublereal residErrorNorm ( const doublereal *const resid, const char * title = 0, const int printLargest = 0, const doublereal *const y = 0 ) const

L2 norm of the residual of the equation system.

Calculate the norm of the residual vector. This may involve using the row sum scaling from the matrix problem.

The third argument has a default of false. However, if true, then a table of the largest values is printed out to standard output.

Parameters
 resid Vector of the residuals title Optional title to be printed out printLargest Number of specific entries to be printed y Current value of y - only used for printouts
Returns
Returns the L2 norm of the delta

Definition at line 508 of file NonlinearSolver.cpp.

 int doResidualCalc ( const doublereal time_curr, const int typeCalc, const doublereal *const y_curr, const doublereal *const ydot_curr, const ResidEval_Type_Enum evalType = Base_ResidEval ) const

Compute the current residual.

The current value of the residual is stored in the internal work array m_resid, which is defined as mutable

Parameters
 time_curr Value of the time typeCalc Type of the calculation y_curr Current value of the solution vector ydot_curr Current value of the time derivative of the solution vector evalType Base evaluation type. Defaults to Base_ResidEval
Returns
Returns a flag to indicate that operation is successful. 1 Means a successful operation. 0 or neg value Means an unsuccessful operation.

Definition at line 629 of file NonlinearSolver.cpp.

 int doNewtonSolve ( const doublereal time_curr, const doublereal *const y_curr, const doublereal *const ydot_curr, doublereal *const delta_y, GeneralMatrix & jac )

Compute the undamped Newton step.

The residual function is evaluated at the current time, t_n, at the current values of the solution vector, m_y_n, and the solution time derivative, m_ydot_n. The Jacobian is not recomputed.

A factored jacobian is reused, if available. If a factored jacobian is not available, then the jacobian is factored. Before factoring, the jacobian is row and column-scaled. Column scaling is not recomputed. The row scales are recomputed here, after column scaling has been implemented.

Parameters
 time_curr Current value of the time y_curr Current value of the solution ydot_curr Current value of the solution derivative. delta_y return value of the raw change in y jac Jacobian
Returns
Returns the result code from lapack. A zero means success. Anything else indicates a failure.

Definition at line 843 of file NonlinearSolver.cpp.

Referenced by NonlinearSolver::dampStep(), and NonlinearSolver::solve_nonlinear_problem().

 int doAffineNewtonSolve ( const doublereal *const y_curr, const doublereal *const ydot_curr, doublereal *const delta_y, GeneralMatrix & jac )

Compute the newton step, either by direct newton's or by solving a close problem that is represented by a Hessian.

This is algorith A.6.5.1 in Dennis / Schnabel

Compute the QR decomposition

Compute the undamped Newton step. The residual function is evaluated at the current time, t_n, at the current values of the solution vector, m_y_n, and the solution time derivative, m_ydot_n. The Jacobian is not recomputed.

A factored jacobian is reused, if available. If a factored jacobian is not available, then the jacobian is factored. Before factoring, the jacobian is row and column-scaled. Column scaling is not recomputed. The row scales are recomputed here, after column scaling has been implemented.

Parameters
 y_curr Current value of the solution ydot_curr Current value of the solution derivative. delta_y return value of the raw change in y jac Jacobian

## Internal input

internal m_resid Stored residual is used as input

Returns
Returns the result code from lapack. A zero means success. Anything else indicates a failure.

Definition at line 926 of file NonlinearSolver.cpp.

Referenced by NonlinearSolver::solve_nonlinear_problem().

 doublereal trustRegionLength ( ) const

Calculate the length of the current trust region in terms of the solution error norm.

We carry out a norm of deltaX_trust_ first. Then, we multiply that value by trustDelta_

Definition at line 1804 of file NonlinearSolver.cpp.

Referenced by NonlinearSolver::dampDogLeg(), and NonlinearSolver::decideStep().

 void setDefaultDeltaBoundsMagnitudes ( )

Set default deulta bounds amounts.

Delta bounds are set to 0.01 for all unknowns arbitrarily and capriciously Then, for each call to the nonlinear solver Then, they are increased to 1000 x atol then, they are increased to 0.1 fab(y[i])

Definition at line 1810 of file NonlinearSolver.cpp.

Referenced by NonlinearSolver::solve_nonlinear_problem().

Definition at line 1818 of file NonlinearSolver.cpp.

Referenced by NonlinearSolver::decideStep().

 void setDeltaBoundsMagnitudes ( const doublereal *const deltaBoundsMagnitudes )

Set the delta Bounds magnitudes by hand.

Parameters
 deltaBoundsMagnitudes set the deltaBoundsMagnitude vector

Definition at line 1829 of file NonlinearSolver.cpp.

protected

The trust region is made up of the trust region vector calculation and the trustDelta_ value We periodically recalculate the trustVector_ values so that they renormalize to the correct length. We change the trustDelta_ values regularly

The trust region calculate is based on

|| delta_x   dot  1/trustDeltaX_ ||   <= trustDelta_

Definition at line 1935 of file NonlinearSolver.cpp.

 void fillDogLegStep ( int leg, doublereal alpha, std::vector< doublereal > & deltaX ) const
protected

Fill a dogleg solution step vector.

Previously, we have filled up deltaX_Newton_[], deltaX_CP_[], and Nuu_, so that this routine is straightforward.

Parameters
 leg Leg of the dog leg you are on (0, 1, or 2) alpha Relative length along the dog length that you are on. deltaX Vector to be filled up

Definition at line 2041 of file NonlinearSolver.cpp.

Referenced by NonlinearSolver::dampDogLeg().

 doublereal calcTrustDistance ( std::vector< doublereal > const & deltaX ) const
protected

Calculate the trust distance of a step in the solution variables.

The trust distance is defined as the length of the step according to the norm wrt to the trust region. We calculate the trust distance by the following method.

trustDist =  || delta_x   dot  1/trustDeltaX_ ||

Parameters
 deltaX Current value of deltaX

Definition at line 2058 of file NonlinearSolver.cpp.

 doublereal boundStep ( const doublereal *const y, const doublereal *const step0 )

Bound the step.

Return the factor by which the undamped Newton step 'step0' must be multiplied in order to keep all solution components in all domains between their specified lower and upper bounds. Other bounds may be applied here as well.

Currently the bounds are hard coded into this routine:

Minimum value for all variables: - 0.01 * m_ewt[i] Maximum value = none.

Thus, this means that all solution components are expected to be numerical greater than zero in the limit of time step truncation errors going to zero.

Delta bounds: The idea behind these is that the Jacobian couldn't possibly be representative if the variable is changed by a lot. (true for nonlinear systems, false for linear systems) Maximum increase in variable in any one newton iteration: factor of 2 Maximum decrease in variable in any one newton iteration: factor of 5

Parameters
 y Current solution value of the old step step0 Proposed step change in the solution
Returns
Returns the damping factor determined by the bounds calculation

Definition at line 2108 of file NonlinearSolver.cpp.

Referenced by NonlinearSolver::dampDogLeg(), and NonlinearSolver::dampStep().

 void setBoundsConstraints ( const doublereal *const y_low_bounds, const doublereal *const y_high_bounds )

Set bounds constraints for all variables in the problem.

Parameters
 y_low_bounds Vector of lower bounds y_high_bounds Vector of high bounds

Definition at line 406 of file NonlinearSolver.cpp.

 std::vector< doublereal > & lowBoundsConstraintVector ( )

Return an editable vector of the low bounds constraints.

Definition at line 421 of file NonlinearSolver.cpp.

References NonlinearSolver::m_y_low_bounds.

 std::vector< doublereal > & highBoundsConstraintVector ( )

Return an editable vector of the high bounds constraints.

Definition at line 426 of file NonlinearSolver.cpp.

References NonlinearSolver::m_y_high_bounds.

 void calc_ydot ( const int order, const doublereal *const y_curr, doublereal *const ydot_curr ) const

Internal function to calculate the time derivative of the solution at the new step.

Previously, the user must have supplied information about the previous time step for this routine to work as intended.

Parameters
 order of the BDF method y_curr current value of the solution ydot_curr Calculated value of the solution derivative that is consistent with y_curr

Definition at line 3612 of file NonlinearSolver.cpp.

 int beuler_jac ( GeneralMatrix & J, doublereal *const f, doublereal time_curr, doublereal CJ, doublereal *const y, doublereal *const ydot, int num_newt_its )

Function called to evaluate the jacobian matrix and the current residual vector at the current time step.

Parameters
 J Jacobian matrix to be filled in f Right hand side. This routine returns the current value of the rhs (output), so that it does not have to be computed again. time_curr Current time CJ inverse of the value of deltaT y value of the solution vector ydot value of the time derivative of the solution vector num_newt_its Number of newton iterations
Returns
Returns a flag to indicate that operation is successful. 1 Means a successful operation 0 Means an unsuccessful operation

Definition at line 3338 of file NonlinearSolver.cpp.

Referenced by NonlinearSolver::solve_nonlinear_problem().

 doublereal filterNewStep ( const doublereal timeCurrent, const doublereal *const ybase, doublereal *const step0 )

Apply a filtering process to the step.

Parameters
 timeCurrent Current value of the time ybase current value of the solution step0 Proposed step change in the solution
Returns
Returns the norm of the value of the amount filtered

Definition at line 3638 of file NonlinearSolver.cpp.

References ResidJacEval::filterNewStep(), and NonlinearSolver::m_func.

Referenced by NonlinearSolver::solve_nonlinear_problem().

 doublereal filterNewSolution ( const doublereal timeCurrent, doublereal *const y_current, doublereal *const ydot_current )

Apply a filter to the solution.

Parameters
 timeCurrent Current value of the time y_current current value of the solution ydot_current Current value of the solution derivative.
Returns
Returns the norm of the value of the amount filtered

Definition at line 3644 of file NonlinearSolver.cpp.

References ResidJacEval::filterSolnPrediction(), and NonlinearSolver::m_func.

Referenced by NonlinearSolver::solve_nonlinear_problem().

 double deltaBoundStep ( const doublereal *const y, const doublereal *const step0 )

Return the factor by which the undamped Newton step 'step0' must be multiplied in order to keep the update within the bounds of an accurate jacobian.

The idea behind these is that the Jacobian couldn't possibly be representative, if the variable is changed by a lot. (true for nonlinear systems, false for linear systems) Maximum increase in variable in any one newton iteration: factor of 1.5 Maximum decrease in variable in any one newton iteration: factor of 2

Parameters
 y Initial value of the solution vector step0 initial proposed step size
Returns
returns the damping factor

Definition at line 1838 of file NonlinearSolver.cpp.

Referenced by NonlinearSolver::boundStep().

 int dampStep ( const doublereal time_curr, const doublereal *const y_n_curr, const doublereal *const ydot_n_curr, doublereal *const step_1, doublereal *const y_n_1, doublereal *const ydot_n_1, doublereal * step_2, doublereal & stepNorm_2, GeneralMatrix & jac, bool writetitle, int & num_backtracks )

Find a damping coefficient through a look-ahead mechanism.

On entry, step_1 must contain an undamped Newton step for the solution y_n_curr. This method attempts to find a damping coefficient such that all components stay in bounds, and the next undamped step would have a norm smaller than that of step_1. If successful, the new solution after taking the damped step is returned in y_n_1, and the undamped step at y_n_1 is returned in step_2.

Parameters
 time_curr Current physical time y_n_curr Base value of the solution before any steps are taken ydot_n_curr Base value of the time derivative of the solution step_1 Initial step suggested. y_n_1 Value of y1, the suggested solution after damping ydot_n_1 Value of the time derivative of the solution at y_n_1 step_2 Value of the step change from y_n_1 to y_n_2 stepNorm_2 norm of the step change in going from y_n_1 to y_n_2 jac Jacobian writetitle Write a title line num_backtracks Number of backtracks taken
Returns
1 Successful step was taken: Next step was less than previous step. s1 is calculated 2 Successful step: Next step's norm is less than 0.8 3 Success: The final residual is less than 1.0 A predicted deltaSoln1 is not produced however. s1 is estimated. 4 Success: The final residual is less than the residual from the previous step. A predicted deltaSoln1 is not produced however. s1 is estimated. 0 Uncertain Success: s1 is about the same as s0 NSOLN_RETN_FAIL_DAMPSTEP Unsuccessful step. We can not find a damping factor that is suitable.

Definition at line 2158 of file NonlinearSolver.cpp.

Referenced by NonlinearSolver::solve_nonlinear_problem().

 int solve_nonlinear_problem ( int SolnType, doublereal *const y_comm, doublereal *const ydot_comm, doublereal CJ, doublereal time_curr, GeneralMatrix & jac, int & num_newt_its, int & num_linear_solves, int & num_backtracks, int loglevelInput )

Find the solution to F(X) = 0 by damped Newton iteration.

On entry, x0 contains an initial estimate of the solution. On successful return, x1 contains the converged solution.

SolnType = TRANSIENT -> we will assume we are relaxing a transient equation system for now. Will make it more general later, if an application comes up.

Parameters
 SolnType Solution type y_comm Initial value of the solution. On return this is the converged value of the solution ydot_comm Initial value of the solution derivative. On return this is the converged value of the solution derivative. CJ Inverse of the value of deltaT time_curr Current value of the time jac Matrix that will be used to store the jacobian num_newt_its Number of newton iterations taken num_linear_solves Number of linear solves taken num_backtracks Number of backtracking steps taken loglevelInput Input log level determines the amount of printing.
Returns
A positive value indicates a successful convergence -1 Failed convergence

Definition at line 2682 of file NonlinearSolver.cpp.

 void setPreviousTimeStep ( const std::vector< doublereal > & y_nm1, const std::vector< doublereal > & ydot_nm1 )
virtual

Set the values for the previous time step.

We set the values for the previous time step here. These are used in the nonlinear solve because they affect the calculation of ydot.

Parameters
 y_nm1 Value of the solution vector at the previous time step ydot_nm1 Value of the solution vector derivative at the previous time step

Definition at line 3244 of file NonlinearSolver.cpp.

References NonlinearSolver::m_y_nm1, and NonlinearSolver::m_ydot_nm1.

 void calcColumnScales ( )
private

Set the column scaling vector at the current time.

Definition at line 613 of file NonlinearSolver.cpp.

Referenced by NonlinearSolver::solve_nonlinear_problem().

 void setColumnScaling ( bool useColScaling, const double *const scaleFactors = 0 )

Set the column scaling that are used for the inversion of the matrix.

There are three ways to do this.

The first method is to set the bool useColScaling to true, leaving the scaling factors unset. Then, the column scales will be set to the solution error weighting factors. This has the effect of ensuring that all delta variables will have the same order of magnitude at convergence end.

The second way is the explicitly set the column factors in the second argument of this function call.

The final way to input the scales is to override the ResidJacEval member function call,

calcSolnScales(double time_n, const double *m_y_n_curr, const double *m_y_nm1, double *m_colScales)

Overriding this function call will trump all other ways to specify the column scaling factors.

Parameters
 useColScaling Turn this on if you want to use column scaling in the calculations scaleFactors A vector of doubles that specifies the column factors.

Definition at line 589 of file NonlinearSolver.cpp.

 void setRowScaling ( bool useRowScaling )

Set the rowscaling that are used for the inversion of the matrix.

Row scaling is set here. Right now the row scaling is set internally in the code.

Parameters
 useRowScaling Turn row scaling on or off.

Definition at line 608 of file NonlinearSolver.cpp.

References NonlinearSolver::m_rowScaling.

 void scaleMatrix ( GeneralMatrix & jac, doublereal *const y_comm, doublereal *const ydot_comm, doublereal time_curr, int num_newt_its )

Scale the matrix.

Parameters
 jac Jacobian y_comm Current value of the solution vector ydot_comm Current value of the time derivative of the solution vector time_curr current value of the time num_newt_its Current value of the number of newt its

Definition at line 638 of file NonlinearSolver.cpp.

Referenced by NonlinearSolver::solve_nonlinear_problem().

 void print_solnDelta_norm_contrib ( const doublereal *const step_1, const char *const stepNorm_1, const doublereal *const step_2, const char *const stepNorm_2, const char *const title, const doublereal *const y_n_curr, const doublereal *const y_n_1, doublereal damp, size_t num_entries )

Print solution norm contribution.

Prints out the most important entries to the update to the solution vector for the current step

Parameters
 step_1 Raw update vector for the current nonlinear step stepNorm_1 Norm of the vector step_1 step_2 Raw update vector for the next solution value based on the old matrix stepNorm_2 Norm of the vector step_2 title title of the printout y_n_curr Old value of the solution y_n_1 New value of the solution after damping corrections damp Value of the damping factor num_entries Number of entries to print out

Definition at line 3251 of file NonlinearSolver.cpp.

Referenced by NonlinearSolver::dampStep().

 void computeResidWts ( )

Compute the Residual Weights.

The residual weights are defined here to be equal to the inverse of the row scaling factors used to row scale the matrix, after column scaling is used. They are multiplied by 10-3 because the column weights are also multiplied by that same quantity.

The basic idea is that a change in the solution vector on the order of the convergence tolerance multiplied by [RJC] which is of order one after row scaling should give you the relative weight of the row. Values of the residual for that row can then be normalized by the value of this weight. When the tolerance in delta x is achieved, the tolerance in the residual is also achieved.

Definition at line 3650 of file NonlinearSolver.cpp.

Referenced by NonlinearSolver::calcSolnToResNormVector(), and NonlinearSolver::scaleMatrix().

 void getResidWts ( doublereal *const residWts ) const

Return the residual weights.

Parameters
 residWts Vector of length neq_

Definition at line 3682 of file NonlinearSolver.cpp.

References NonlinearSolver::m_residWts, and NonlinearSolver::neq_.

 int convergenceCheck ( int dampCode, doublereal s1 )

Check to see if the nonlinear problem has converged.

Parameters
 dampCode Code from the damping routine s1 Value of the norm of the step change
Returns
integer is returned. If positive, then the problem has converged 1 Successful step was taken: Next step's norm is less than 1.0. The final residual norm is less than 1.0. 2 Successful step: Next step's norm is less than 0.8. This step's norm is less than 1.0. The residual norm can be anything. 3 Success: The final residual is less than 1.0 The predicted deltaSoln is below 1.0. 0 Not converged yet

Definition at line 3689 of file NonlinearSolver.cpp.

Referenced by NonlinearSolver::solve_nonlinear_problem().

 void setAtol ( const doublereal *const atol )

Set the absolute tolerances for the solution variables.

Set the absolute tolerances used in the calculation

Parameters
 atol Vector of length neq_ that contains the tolerances to be used for the solution variables

Definition at line 3740 of file NonlinearSolver.cpp.

References NonlinearSolver::atolk_, and NonlinearSolver::neq_.

 void setRtol ( const doublereal rtol )

Set the relative tolerances for the solution variables.

Set the relative tolerances used in the calculation

Parameters
 rtol single double

Definition at line 3751 of file NonlinearSolver.cpp.

References NonlinearSolver::rtol_.

 void setResidualTols ( double residRtol, double * residAtol, int residNormHandling = 2 )

Set the relative and absolute tolerances for the Residual norm comparisons, if used.

Residual norms are used to calculate convergence within the nonlinear solver, since these are the norms that are associated with convergence proofs, especially for ill-conditioned systems. Usually the residual weights for each row are calculated by the program such that they correlate with the convergence requirements on the solution variables input by the user using the routines setAtol() and setRtol(). The residual weights are essentially calculated from the value

 residWeightNorm[i]  = m_ScaleSolnNormToResNorm  * sum_j ( fabs(A_i,j) ewt(j))


The factor, m_ScaleSolnNormToResNorm, is computed periodically to ensure that the solution norms and the residual norms are converging at the same time and thus accounts for some-illconditioning issues but not all.

With this routine the user can override or add to the residual weighting norm evaluation by specifying their own vector of residual absolute and relative tolerances.

The user specified tolerance for the residual is given by the following quantity

residWeightNorm[i] = residAtol[i] + residRtol * m_rowWtScales[i] / neq

Parameters
 residRtol scalar residual relative tolerance residAtol vector of residual absolute tolerances residNormHandling Parameter that sets the default handling of the residual norms 0 The residual weighting vector is calculated to make sure that the solution norms are roughly 1 when the residual norm is roughly 1. This is the default if this routine is not called. 1 Use the user residual norm specified by the parameters in this routine 2 Use the minimum value of the residual weights calculated by method 1 and 2. This is the default if this routine is called and this parameter isn't specified.

Definition at line 3760 of file NonlinearSolver.cpp.

 void setMaxNewtIts ( const int maxNewtIts )

Set the value of the maximum # of newton iterations.

Parameters
 maxNewtIts Maximum number of newton iterations
 void calcSolnToResNormVector ( )

Calculate the scaling factor for translating residual norms into solution norms.

This routine calls computeResidWts() a couple of times in the calculation of m_ScaleSolnNormToResNorm. A more sophisticated routine may do more with signs to get a better value. Perhaps, a series of calculations with different signs attached may be in order. Then, m_ScaleSolnNormToResNorm would be calculated as the minimum of a series of calculations.

Definition at line 784 of file NonlinearSolver.cpp.

 doublereal doCauchyPointSolve ( GeneralMatrix & jac )

Calculate the steepest descent direction and the Cauchy Point where the quadratic formulation of the nonlinear problem expects a minimum along the descent direction.

Parameters
 jac Jacobian matrix: must be unfactored.
Returns
Returns the norm of the solution update

Definition at line 1272 of file NonlinearSolver.cpp.

Referenced by NonlinearSolver::solve_nonlinear_problem().

 void descentComparison ( doublereal time_curr, doublereal * ydot0, doublereal * ydot1, int & numTrials )

This is a utility routine that can be used to print out the rates of the initial residual decline.

The residual**2 decline for various directions is printed out. The rate of decline of the square of the residuals multiplied by the number of equations along each direction is printed out This quantity can be directly related to the theory, and may be calculated from derivatives at the original point.

( (r)**2 * neq - (r0)**2 * neq ) / distance

What's printed out:

The theoretical linearized residual decline The actual residual decline in the steepest descent direction determined by numerical differencing The actual residual decline in the newton direction determined by numerical differencing

This routine doesn't need to be called for the solution of the nonlinear problem.

Parameters
 time_curr Current time ydot0 INPUT Current value of the derivative of the solution vector ydot1 INPUT Time derivatives of solution at the conditions which are evaluated for success numTrials OUTPUT Counter for the number of residual evaluations

Definition at line 1402 of file NonlinearSolver.cpp.

Referenced by NonlinearSolver::solve_nonlinear_problem().

 void setupDoubleDogleg ( )

Setup the parameters for the double dog leg.

The calls to the doCauchySolve() and doNewtonSolve() routines are done at the main level. This routine comes after those calls. We calculate the point Nuu_ here, the distances of the dog-legs, and the norms of the CP and Newton points in terms of the trust vectors.

Definition at line 1525 of file NonlinearSolver.cpp.

Referenced by NonlinearSolver::solve_nonlinear_problem().

 int lambdaToLeg ( const doublereal lambda, doublereal & alpha ) const

Change the global lambda coordinate into the (leg,alpha) coordinate for the double dogleg.

Parameters
 lambda Global value of the distance along the double dogleg alpha relative value along the particular leg
Returns
Returns the leg number ( 0, 1, or 2).

Definition at line 1581 of file NonlinearSolver.cpp.

 int calcTrustIntersection ( doublereal trustVal, doublereal & lambda, doublereal & alpha ) const

Given a trust distance, this routine calculates the intersection of the this distance with the double dogleg curve.

Parameters
 trustVal (INPUT) Value of the trust distance lambda (OUTPUT) Returns the internal coordinate of the double dogleg alpha (OUTPUT) Returns the relative distance along the appropriate leg
Returns
leg (OUTPUT) Returns the leg ID (0, 1, or 2)

Definition at line 2069 of file NonlinearSolver.cpp.

Referenced by NonlinearSolver::dampDogLeg().

 void initializeTrustRegion ( )

Initialize the size of the trust vector.

The algorithm we use is to set it equal to the length of the Distance to the Cauchy point.

Definition at line 1998 of file NonlinearSolver.cpp.

Referenced by NonlinearSolver::solve_nonlinear_problem().

 void setTrustRegionInitializationMethod ( int method, doublereal factor )

Set Trust region initialization strategy.

The default is use method 2 with a factor of 1. Then, on subsequent invocations of solve_nonlinear_problem() the strategy flips to method 0.

Parameters
 method Method to set the strategy 0 No strategy - Use the previous strategy 1 Factor of the solution error weights 2 Factor of the first Cauchy Point distance 3 Factor of the first Newton step distance factor Factor to use in combination with the method
 int dampDogLeg ( const doublereal time_curr, const doublereal * y_n_curr, const doublereal * ydot_n_curr, std::vector< doublereal > & step_1, doublereal *const y_n_1, doublereal *const ydot_n_1, doublereal & stepNorm_1, doublereal & stepNorm_2, GeneralMatrix & jac, int & num_backtracks )

Damp using the dog leg approach.

Parameters
 time_curr INPUT Current value of the time y_n_curr INPUT Current value of the solution vector ydot_n_curr INPUT Current value of the derivative of the solution vector step_1 INPUT First trial step for the first iteration y_n_1 INPUT First trial value of the solution vector ydot_n_1 INPUT First trial value of the derivative of the solution vector stepNorm_1 OUTPUT Norm of the vector step_1 stepNorm_2 OUTPUT Estimated norm of the vector step_2 jac INPUT jacobian num_backtracks OUTPUT number of backtracks taken in the current damping step
Returns
1 Successful step was taken. The predicted residual norm is less than one 2 Successful step: Next step's norm is less than 0.8 3 Success: The final residual is less than 1.0 A predicted deltaSoln1 is not produced however. s1 is estimated. 4 Success: The final residual is less than the residual from the previous step. A predicted deltaSoln1 is not produced however. s1 is estimated. 0 Uncertain Success: s1 is about the same as s0 -2 Unsuccessful step.

Definition at line 2366 of file NonlinearSolver.cpp.

Referenced by NonlinearSolver::solve_nonlinear_problem().

 int decideStep ( const doublereal time_curr, int leg, doublereal alpha, const doublereal *const y_n_curr, const doublereal *const ydot_n_curr, const std::vector< doublereal > & step_1, const doublereal *const y_n_1, const doublereal *const ydot_n_1, doublereal trustDeltaOld )

Decide whether the current step is acceptable and adjust the trust region size.

This is an extension of algorithm 6.4.5 of Dennis and Schnabel.

Here we decide whether to accept the current step At the end of the calculation a new estimate of the trust region is calculated

Parameters
 time_curr INPUT Current value of the time leg INPUT Leg of the dogleg that we are on alpha INPUT Distance down that leg that we are on y_n_curr INPUT Current value of the solution vector ydot_n_curr INPUT Current value of the derivative of the solution vector step_1 INPUT Trial step y_n_1 OUTPUT Solution values at the conditions which are evaluated for success ydot_n_1 OUTPUT Time derivatives of solution at the conditions which are evaluated for success trustDeltaOld INPUT Value of the trust length at the old conditions
Returns
This function returns a code which indicates whether the step will be accepted or not. 3 Step passed with flying colors. Try redoing the calculation with a bigger trust region. 2 Step didn't pass deltaF requirement. Decrease the size of the next trust region for a retry and return 0 The step passed. -1 The step size is now too small (||d || < 0.1). A really small step isn't decreasing the function. This is an error condition. -2 Current value of the solution vector caused a residual error in its evaluation. Step is a failure, and the step size must be reduced in order to proceed further.

Definition at line 2515 of file NonlinearSolver.cpp.

Referenced by NonlinearSolver::dampDogLeg().

 doublereal expectedResidLeg ( int leg, doublereal alpha ) const

Calculated the expected residual along the double dogleg curve.

Parameters
 leg 0, 1, or 2 representing the curves of the dogleg alpha Relative distance along the particular curve.
Returns
Returns the expected value of the residual at that point according to the quadratic model. The residual at the newton point will always be zero.

Definition at line 1595 of file NonlinearSolver.cpp.

 void residualComparisonLeg ( const doublereal time_curr, const doublereal *const ydot0, int & legBest, doublereal & alphaBest ) const

Here we print out the residual at various points along the double dogleg, comparing against the quadratic model in a table format.

Parameters
 time_curr INPUT current time ydot0 INPUT Current value of the derivative of the solution vector for non-time dependent determinations legBest OUTPUT leg of the dogleg that gives the lowest residual alphaBest OUTPUT distance along dogleg for best result.

Definition at line 1648 of file NonlinearSolver.cpp.

Referenced by NonlinearSolver::solve_nonlinear_problem().

 void setPrintLvl ( int printLvl )

Set the print level from the nonlinear solver.

0 -> absolutely nothing is printed for a single time step. 1 -> One line summary per solve_nonlinear call 2 -> short description, points of interest: Table of nonlinear solve - one line per iteration 3 -> Table is included -> More printing per nonlinear iteration (default) that occurs during the table 4 -> Summaries of the nonlinear solve iteration as they are occurring -> table no longer printed 5 -> Algorithm information on the nonlinear iterates are printed out 6 -> Additional info on the nonlinear iterates are printed out 7 -> Additional info on the linear solve is printed out. 8 -> Info on a per iterate of the linear solve is printed out.

Parameters
 printLvl integer value

Definition at line 3781 of file NonlinearSolver.cpp.

References NonlinearSolver::m_print_flag.

 void setSolverScheme ( int doDogLeg, int doAffineSolve )

Parameter to turn on solution solver schemes.

Parameters
 doDogLeg Parameter to turn on the double dog leg scheme Default is to always use a damping scheme in the Newton Direction. When this is nonzero, a model trust region approach is used using a double dog leg with the steepest descent direction used for small step sizes. doAffineSolve Parameter to turn on or off the solution of the system using a Hessian if the matrix has a bad condition number.

Definition at line 415 of file NonlinearSolver.cpp.

References NonlinearSolver::doAffineSolve_, and NonlinearSolver::doDogLeg_.

## Member Data Documentation

 ResidJacEval* m_func
private

Pointer to the residual and jacobian evaluator for the function.

See ResidJacEval.h for an evaluator.

Definition at line 898 of file NonlinearSolver.h.

 int solnType_
private

Solution type.

Definition at line 901 of file NonlinearSolver.h.

 std::vector m_ewt
private
 int m_manualDeltaStepSet
private

Boolean indicating whether a manual delta bounds has been input.

Definition at line 910 of file NonlinearSolver.h.

 std::vector m_deltaStepMinimum
private

Soln Delta bounds magnitudes.

Definition at line 913 of file NonlinearSolver.h.

 std::vector m_deltaStepMaximum
private

Value of the delta step magnitudes.

Definition at line 916 of file NonlinearSolver.h.

 std::vector m_y_n_curr
private

Vector containing the current solution vector within the nonlinear solver.

Definition at line 919 of file NonlinearSolver.h.

 std::vector m_ydot_n_curr
private

Vector containing the time derivative of the current solution vector within the nonlinear solver (where applicable)

Definition at line 923 of file NonlinearSolver.h.

 std::vector m_y_nm1
private

Vector containing the solution at the previous time step.

Definition at line 926 of file NonlinearSolver.h.

 std::vector m_ydot_nm1
private

Vector containing the solution derivative at the previous time step.

Definition at line 929 of file NonlinearSolver.h.

 std::vector m_y_n_trial
private

Vector containing the solution at the new point that is to be considered.

Definition at line 932 of file NonlinearSolver.h.

 std::vector m_ydot_trial
private

Value of the solution time derivative at the new point that is to be considered.

Definition at line 935 of file NonlinearSolver.h.

 std::vector m_step_1
private

Value of the step to be taken in the solution.

Definition at line 938 of file NonlinearSolver.h.

 std::vector m_colScales
private

Vector of column scaling factors.

Definition at line 941 of file NonlinearSolver.h.

 std::vector m_rowScales
private

Weights for normalizing the values of the residuals.

These are computed if row scaling, m_rowScaling, is turned on. They are calculated currently as the sum of the absolute values of the rows of the jacobian.

Definition at line 948 of file NonlinearSolver.h.

 std::vector m_rowWtScales
private

Weights for normalizing the values of the residuals.

They are calculated as the sum of the absolute values of the jacobian multiplied by the solution weight function. This is carried out in scaleMatrix().

Definition at line 956 of file NonlinearSolver.h.

 std::vector m_resid
mutableprivate

Value of the residual for the nonlinear problem.

Definition at line 959 of file NonlinearSolver.h.

 std::vector m_wksp
mutableprivate

Workspace of length neq_.

Definition at line 962 of file NonlinearSolver.h.

 std::vector m_wksp_2
mutableprivate

Workspace of length neq_.

Definition at line 965 of file NonlinearSolver.h.

 std::vector m_residWts
private

Vector of residual weights.

These are used to establish useful and informative weighted norms of the residual vector.

Definition at line 974 of file NonlinearSolver.h.

 doublereal m_normResid_0
private

Norm of the residual at the start of each nonlinear iteration.

Definition at line 977 of file NonlinearSolver.h.

 doublereal m_normResid_Bound
private

Norm of the residual after it has been bounded.

Definition at line 980 of file NonlinearSolver.h.

 doublereal m_normResid_1
private

Norm of the residual at the end of the first leg of the current iteration.

Definition at line 983 of file NonlinearSolver.h.

 doublereal m_normResid_full
private

Norm of the residual at the end of the first leg of the current iteration.

Definition at line 986 of file NonlinearSolver.h.

 doublereal m_normDeltaSoln_Newton
private

Norm of the solution update created by the iteration in its raw, undamped form, using the solution norm.

Definition at line 989 of file NonlinearSolver.h.

 doublereal m_normDeltaSoln_CP
private

Norm of the distance to the cauchy point using the solution norm.

Definition at line 992 of file NonlinearSolver.h.

 doublereal m_normResidTrial
private

Norm of the residual for a trial calculation which may or may not be used.

Definition at line 995 of file NonlinearSolver.h.

 doublereal m_normResidPoints[15]
private

Vector of the norm.

Definition at line 998 of file NonlinearSolver.h.

 bool m_resid_scaled
mutableprivate

Boolean indicating whether we should scale the residual.

Definition at line 1001 of file NonlinearSolver.h.

 std::vector m_y_high_bounds
private

Bounds vector for each species.

Definition at line 1008 of file NonlinearSolver.h.

 std::vector m_y_low_bounds
private

Lower bounds vector for each species.

Definition at line 1011 of file NonlinearSolver.h.

 doublereal m_dampBound
private

Damping factor imposed by hard bounds and by delta bounds.

Definition at line 1014 of file NonlinearSolver.h.

 doublereal m_dampRes
private

Additional damping factor due to bounds on the residual and solution norms.

Definition at line 1017 of file NonlinearSolver.h.

 doublereal delta_t_n
private

Delta t for the current step.

Definition at line 1020 of file NonlinearSolver.h.

 int m_nfe
mutableprivate

Counter for the total number of function evaluations.

Definition at line 1023 of file NonlinearSolver.h.

 int m_colScaling
private

The type of column scaling used in the matrix inversion of the problem.

If 1 then colScaling = m_ewt[] If 2 then colScaling = user set if 0 then colScaling = 1.0

Definition at line 1035 of file NonlinearSolver.h.

 int m_rowScaling
private

int indicating whether row scaling is turned on (1) or not (0)

Definition at line 1038 of file NonlinearSolver.h.

 int m_numTotalLinearSolves
private

Total number of linear solves taken by the solver object.

Definition at line 1041 of file NonlinearSolver.h.

 int m_numLocalLinearSolves
private

Number of local linear solves done during the current iteration.

Definition at line 1044 of file NonlinearSolver.h.

 int m_numTotalNewtIts
private

Total number of newton iterations.

Definition at line 1047 of file NonlinearSolver.h.

Referenced by NonlinearSolver::operator=(), and NonlinearSolver::solve_nonlinear_problem().

 int m_min_newt_its

Minimum number of newton iterations to use.

Definition at line 1051 of file NonlinearSolver.h.

Referenced by NonlinearSolver::operator=(), and NonlinearSolver::solve_nonlinear_problem().

 int maxNewtIts_
private

Maximum number of newton iterations.

Definition at line 1055 of file NonlinearSolver.h.

Referenced by NonlinearSolver::operator=(), and NonlinearSolver::solve_nonlinear_problem().

 int m_jacFormMethod
private

Jacobian formation method.

1 = numerical (default) 2 = analytical

Definition at line 1062 of file NonlinearSolver.h.

Referenced by NonlinearSolver::beuler_jac(), and NonlinearSolver::operator=().

 int m_nJacEval
private

Number of Jacobian evaluations.

Definition at line 1065 of file NonlinearSolver.h.

Referenced by NonlinearSolver::beuler_jac(), and NonlinearSolver::operator=().

 doublereal time_n
private

Current system time.

Note, we assume even for steady state problems that the residual is a function of a system time.

Definition at line 1072 of file NonlinearSolver.h.

 int m_matrixConditioning
private

Boolean indicating matrix conditioning.

Definition at line 1075 of file NonlinearSolver.h.

Referenced by NonlinearSolver::operator=().

 int m_order
private

Order of the time step method = 1.

Definition at line 1078 of file NonlinearSolver.h.

 doublereal rtol_
private

value of the relative tolerance to use in solving the equation set

Definition at line 1081 of file NonlinearSolver.h.

 doublereal atolBase_
private

Base value of the absolute tolerance.

Definition at line 1084 of file NonlinearSolver.h.

 std::vector atolk_
private

absolute tolerance in the solution unknown

This is used to evaluating the weighting factor

Definition at line 1090 of file NonlinearSolver.h.

 std::vector userResidAtol_
private

absolute tolerance in the unscaled solution unknowns

Definition at line 1093 of file NonlinearSolver.h.

 doublereal userResidRtol_
private

absolute tolerance in the unscaled solution unknowns

Definition at line 1096 of file NonlinearSolver.h.

 int checkUserResidualTols_
private

Check the residual tolerances explicitly against user input.

0 Don't calculate residual weights from residual tolerance inputs 1 Calculate residual weights from residual tolerance inputs only 2 Calculate residual weights from a minimum of the solution error weights process and the direct residual tolerance inputs

Definition at line 1104 of file NonlinearSolver.h.

 int m_print_flag
private

Determines the level of printing for each time step.

0 -> absolutely nothing is printed for a single time step. 1 -> One line summary per solve_nonlinear call 2 -> short description, points of interest: Table of nonlinear solve - one line per iteration 3 -> Table is included -> More printing per nonlinear iteration (default) that occurs during the table 4 -> Summaries of the nonlinear solve iteration as they are occurring -> table no longer printed Base_ShowSolution Residual called for residual printing at the end of convergence. 5 -> Algorithm information on the nonlinear iterates are printed out 6 -> Additional info on the nonlinear iterates are printed out Base_ShowSolution Residual called for residual printing at the end of each step. 7 -> Additional info on the linear solve is printed out. 8 -> Info on a per iterate of the linear solve is printed out.

Definition at line 1120 of file NonlinearSolver.h.

 doublereal m_ScaleSolnNormToResNorm
private

Scale factor for turning residual norms into solution norms.

Definition at line 1123 of file NonlinearSolver.h.

 Cantera::GeneralMatrix* jacCopyPtr_
private

Copy of the jacobian that doesn't get overwritten when the inverse is determined.

The jacobian stored here is the raw matrix, before any row or column scaling is carried out

Definition at line 1129 of file NonlinearSolver.h.

 Cantera::GeneralMatrix* HessianPtr_
private

Hessian.

Definition at line 1132 of file NonlinearSolver.h.

 std::vector deltaX_CP_
private

Steepest descent direction. This is also the distance to the Cauchy Point.

Definition at line 1139 of file NonlinearSolver.h.

 std::vector deltaX_Newton_
private

Newton Step - This is the newton step determined from the straight Jacobian.

Definition at line 1145 of file NonlinearSolver.h.

 doublereal residNorm2Cauchy_
private

Expected value of the residual norm at the Cauchy point if the quadratic model were valid.

Definition at line 1149 of file NonlinearSolver.h.

Referenced by NonlinearSolver::doCauchyPointSolve(), and NonlinearSolver::operator=().

 int dogLegID_
private

Current leg.

Definition at line 1152 of file NonlinearSolver.h.

 doublereal dogLegAlpha_
private

Current Alpha param along the leg.

Definition at line 1155 of file NonlinearSolver.h.

 doublereal RJd_norm_
private

Residual dot Jd norm.

This is equal to R_hat dot J_hat d_y_descent

Definition at line 1161 of file NonlinearSolver.h.

 doublereal lambdaStar_
private

Value of lambdaStar_ which is used to calculate the Cauchy point.

Definition at line 1164 of file NonlinearSolver.h.

 std::vector Jd_
private

Jacobian times the steepest descent direction in the normalized coordinates.

This is equal to [ Jhat d^y_{descent} ] in the notes, Eqn. 18.

Definition at line 1170 of file NonlinearSolver.h.

 std::vector deltaX_trust_
private

Vector of trust region values.

Definition at line 1173 of file NonlinearSolver.h.

 doublereal norm_deltaX_trust_
mutableprivate

Current norm of the vector deltaX_trust_ in terms of the solution norm.

Definition at line 1176 of file NonlinearSolver.h.

 doublereal trustDelta_
private

This is used with deltaX_trust_ to calculate the max step size.

Definition at line 1180 of file NonlinearSolver.h.

 int trustRegionInitializationMethod_
private

Method for handling the trust region initialization.

Then, on subsequent invocations of solve_nonlinear_problem() the strategy flips to method 0.

method Method to set the strategy 0 No strategy - Use the previous strategy 1 Factor of the solution error weights 2 Factor of the first Cauchy Point distance 3 Factor of the first Newton step distance

Definition at line 1192 of file NonlinearSolver.h.

 doublereal trustRegionInitializationFactor_
private

Factor used to set the initial trust region.

Definition at line 1195 of file NonlinearSolver.h.

 doublereal Nuu_
private

Relative distance down the Newton step that the second dogleg starts.

Definition at line 1198 of file NonlinearSolver.h.

 doublereal dist_R0_
private

Distance of the zeroeth leg of the dogleg in terms of the solution norm.

Definition at line 1201 of file NonlinearSolver.h.

 doublereal dist_R1_
private

Distance of the first leg of the dogleg in terms of the solution norm.

Definition at line 1204 of file NonlinearSolver.h.

 doublereal dist_R2_
private

Distance of the second leg of the dogleg in terms of the solution norm.

Definition at line 1207 of file NonlinearSolver.h.

 doublereal dist_Total_
private

Distance of the sum of all legs of the doglegs in terms of the solution norm.

Definition at line 1210 of file NonlinearSolver.h.

 doublereal JdJd_norm_
private

Dot product of the Jd_ variable defined above with itself.

Definition at line 1213 of file NonlinearSolver.h.

Referenced by NonlinearSolver::doCauchyPointSolve(), and NonlinearSolver::operator=().

 doublereal normTrust_Newton_
private

Norm of the Newton Step wrt trust region.

Definition at line 1216 of file NonlinearSolver.h.

 doublereal normTrust_CP_
private

Norm of the Cauchy Step direction wrt trust region.

Definition at line 1219 of file NonlinearSolver.h.

 int doDogLeg_
private

General toggle for turning on dog leg damping.

Definition at line 1222 of file NonlinearSolver.h.

 int doAffineSolve_
private

General toggle for turning on Affine solve with Hessian.

Definition at line 1225 of file NonlinearSolver.h.

 doublereal m_conditionNumber
private

Condition number of the matrix.

Definition at line 1228 of file NonlinearSolver.h.

 doublereal CurrentTrustFactor_
private

Factor indicating how much trust region has been changed this iteration - output variable.

Definition at line 1231 of file NonlinearSolver.h.

 doublereal NextTrustFactor_
private

Factor indicating how much trust region has been changed next iteration - output variable.

Definition at line 1234 of file NonlinearSolver.h.

 bool ResidWtsReevaluated_
private

Boolean indicating that the residual weights have been reevaluated this iteration - output variable.

Definition at line 1237 of file NonlinearSolver.h.

 doublereal ResidDecreaseSDExp_
private

Expected DResid_dS for the steepest descent path - output variable.

Definition at line 1240 of file NonlinearSolver.h.

 doublereal ResidDecreaseSD_
private

Actual DResid_dS for the steepest descent path - output variable.

Definition at line 1243 of file NonlinearSolver.h.

 doublereal ResidDecreaseNewtExp_
private

Expected DResid_dS for the Newton path - output variable.

Definition at line 1246 of file NonlinearSolver.h.

 doublereal ResidDecreaseNewt_
private

Actual DResid_dS for the newton path - output variable.

Definition at line 1249 of file NonlinearSolver.h.

 bool s_TurnOffTiming
static

Turn off printing of time.

Necessary to do for test suites

Definition at line 1260 of file NonlinearSolver.h.

Referenced by NonlinearSolver::solve_nonlinear_problem().

 bool s_print_NumJac
static

Turn on or off printing of the Jacobian.

Definition at line 1263 of file NonlinearSolver.h.

Referenced by NonlinearSolver::beuler_jac().

 bool s_print_DogLeg
static

Turn on extra printing of dogleg information.

Definition at line 1266 of file NonlinearSolver.h.

 bool s_doBothSolvesAndCompare
static

Turn on solving both the Newton and Hessian systems and comparing the results.

This is off by default

Definition at line 1272 of file NonlinearSolver.h.

Referenced by NonlinearSolver::doAffineNewtonSolve().

 bool s_alwaysAssumeNewtonGood
static

This toggle turns off the use of the Hessian when it is warranted by the condition number.

This is a debugging option.

Definition at line 1278 of file NonlinearSolver.h.

Referenced by NonlinearSolver::doAffineNewtonSolve().

The documentation for this class was generated from the following files: