diff --git a/Cantera/src/numerics/NonlinearSolver.cpp b/Cantera/src/numerics/NonlinearSolver.cpp index f1115589c..b632f72d1 100644 --- a/Cantera/src/numerics/NonlinearSolver.cpp +++ b/Cantera/src/numerics/NonlinearSolver.cpp @@ -502,20 +502,14 @@ namespace Cantera { m_resid_scaled = false; return retn; } - //==================================================================================================================== - // Compute the undamped Newton step + //==================================================================================================================== + // Scale the matrix /* - * 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. - */ + * @param jac Jacobian + * @param y_comm Current value of the solution vector + * @param ydot_comm Current value of the time derivative of the solution vector + * @param time_curr current value of the time + */ void NonlinearSolver::scaleMatrix(SquareMatrix& jac, double* y_comm, double* ydot_comm, doublereal time_curr) { int irow, jcol; @@ -1480,9 +1474,19 @@ namespace Cantera { return m; } //==================================================================================================================== + // Print solution norm contribution /* + * Prints out the most important entries to the update to the solution vector for the current step * - * + * @param solnDelta0 Raw update vector for the current nonlinear step + * @param s0 Norm of the vector solnDelta0 + * @param solnDelta1 Raw update vector for the next solution value based on the old matrix + * @param s1 Norm of the vector solnDelta1 + * @param title title of the printout + * @param y0 Old value of the solution + * @param y1 New value of the solution after damping corrections + * @param damp Value of the damping factor + * @param num_entries Number of entries to print out */ void NonlinearSolver:: print_solnDelta_norm_contrib(const doublereal * const solnDelta0, diff --git a/Cantera/src/numerics/NonlinearSolver.h b/Cantera/src/numerics/NonlinearSolver.h index 918e2f50c..aeec870e5 100644 --- a/Cantera/src/numerics/NonlinearSolver.h +++ b/Cantera/src/numerics/NonlinearSolver.h @@ -102,7 +102,6 @@ namespace Cantera { */ NonlinearSolver& operator=(const NonlinearSolver &right); - //! Create solution weights for convergence criteria /*! * We create soln weights from the following formula @@ -116,7 +115,6 @@ namespace Cantera { */ void createSolnWeights(const doublereal * const y); - //! L2 norm of the delta of the solution vector /*! * calculate the norm of the solution vector. This will @@ -204,7 +202,6 @@ namespace Cantera { const doublereal * const ydot_curr, doublereal * const delta_y, SquareMatrix& jac, int loglevel); - //! Set default deulta bounds amounts /*! * Delta bounds are set to 0.01 for all unknowns arbitrarily and capriciously @@ -219,7 +216,6 @@ namespace Cantera { * @param deltaBoundsMagnitudes set the deltaBoundsMagnitude vector */ void setDeltaBoundsMagnitudes(const doublereal * const deltaBoundsMagnitudes); - //! Bound the step /*! @@ -255,7 +251,6 @@ namespace Cantera { */ doublereal boundStep(const doublereal * const y, const doublereal * const step0, const int loglevel); - //! Set bounds constraints for all variables in the problem /*! * @@ -320,9 +315,9 @@ namespace Cantera { * * @return Returns the norm of the value of the amount filtered */ - doublereal filterNewSolution(const doublereal timeCurrent, doublereal * const y_current, doublereal * const ydot_current); + doublereal filterNewSolution(const doublereal timeCurrent, doublereal * const y_current, + doublereal * const ydot_current); - //! 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. /*! @@ -372,12 +367,9 @@ namespace Cantera { int dampStep(const doublereal time_curr, const double* y0, const doublereal *ydot0, const double* step0, double* const y1, double* const ydot1, double* step1, - double& s1, SquareMatrix& jac, - int& loglevel, bool writetitle, + double& s1, SquareMatrix& jac, int& loglevel, bool writetitle, int& num_backtracks); - - //! Find the solution to F(X) = 0 by damped Newton iteration. /*! * On @@ -405,37 +397,41 @@ namespace Cantera { * @return A positive value indicates a successful convergence * -1 Failed convergence */ - int solve_nonlinear_problem(int SolnType, double* y_comm, - double* ydot_comm, doublereal CJ, - doublereal time_curr, - SquareMatrix& jac, - int &num_newt_its, - int &num_linear_solves, - int &num_backtracks, - int loglevelInput); - + int solve_nonlinear_problem(int SolnType, double* y_comm,double* ydot_comm, doublereal CJ, + doublereal time_curr, SquareMatrix& jac,int &num_newt_its, + int &num_linear_solves, int &num_backtracks, int loglevelInput); //! Set the column scales void setColumnScales(); //! Scale the matrix /*! - * + * @param jac Jacobian + * @param y_comm Current value of the solution vector + * @param ydot_comm Current value of the time derivative of the solution vector + * @param time_curr current value of the time */ void scaleMatrix(SquareMatrix& jac, double* y_comm, double* ydot_comm, doublereal time_curr); - //! Print solution norm contribution + /*! + * Prints out the most important entries to the update to the solution vector for the current step + * + * @param solnDelta0 Raw update vector for the current nonlinear step + * @param s0 Norm of the vector solnDelta0 + * @param solnDelta1 Raw update vector for the next solution value based on the old matrix + * @param s1 Norm of the vector solnDelta1 + * @param title title of the printout + * @param y0 Old value of the solution + * @param y1 New value of the solution after damping corrections + * @param damp Value of the damping factor + * @param num_entries Number of entries to print out + */ void - print_solnDelta_norm_contrib(const doublereal * const solnDelta0, - const char * const s0, - const doublereal * const solnDelta1, - const char * const s1, - const char * const title, - const doublereal * const y0, - const doublereal * const y1, - doublereal damp, - int num_entries); + print_solnDelta_norm_contrib(const doublereal * const solnDelta0, const char * const s0, + const doublereal * const solnDelta1, const char * const s1, + const char * const title, const doublereal * const y0, const doublereal * const y1, + doublereal damp, int num_entries); //! Compute the Residual Weights /*! @@ -474,7 +470,6 @@ namespace Cantera { */ int convergenceCheck(int dampCode, doublereal s1); - //! Set the absolute tolerances for the solution variables /*! * Set the absolute tolerances used in the calculation @@ -607,7 +602,6 @@ namespace Cantera { //! Boolean indicating whether we should scale the residual bool m_resid_scaled; - /***************************************************************************************** * INTERNAL BOUNDARY INFO FOR SOLUTIONS *****************************************************************************************/ diff --git a/Cantera/src/numerics/RootFind.cpp b/Cantera/src/numerics/RootFind.cpp index c209026cb..cc1b2c103 100644 --- a/Cantera/src/numerics/RootFind.cpp +++ b/Cantera/src/numerics/RootFind.cpp @@ -52,6 +52,13 @@ namespace Cantera { /*****************************************************************************/ /*****************************************************************************/ #ifdef DEBUG_MODE + //! Print out a form for the current function evaluation + /*! + * @param fp Pointer to the FILE object + * @param xval Current value of x + * @param fval Current value of f + * @param its Current iteration value + */ static void print_funcEval(FILE *fp, doublereal xval, doublereal fval, int its) { fprintf(fp,"\n"); @@ -65,6 +72,14 @@ namespace Cantera { } #endif //================================================================================================ + //! Solve Ax = b using gauss's method + /*! + * @param c Matrix + * @param idem Assumed number of rows in the matrix + * @param n Number of rows and columns + * @param b right hand side + * @param m Number of right hand sides + */ static int smlequ(doublereal *c, int idem, int n, doublereal *b, int m) { int i, j, k, l; doublereal R;