petsc-3.7.1 2016-05-15
Report Typos and Errors

# SNESConvergedReason

reason a SNES method was said to have converged or diverged

### Synopsis

    typedef enum {/* converged */
                  SNES_CONVERGED_FNORM_ABS         =  2, /* ||F|| < atol */
                  SNES_CONVERGED_FNORM_RELATIVE    =  3, /* ||F|| < rtol*||F_initial|| */
                  SNES_CONVERGED_SNORM_RELATIVE    =  4, /* Newton computed step size small; || delta x || < stol || x ||*/
                  SNES_CONVERGED_ITS               =  5, /* maximum iterations reached */
                  SNES_CONVERGED_TR_DELTA          =  7,
                  /* diverged */
                  SNES_DIVERGED_FUNCTION_DOMAIN     = -1, /* the new x location passed the function is not in the domain of F */
                  SNES_DIVERGED_FUNCTION_COUNT      = -2,
                  SNES_DIVERGED_LINEAR_SOLVE        = -3, /* the linear solve failed */
                  SNES_DIVERGED_FNORM_NAN           = -4,
                  SNES_DIVERGED_MAX_IT              = -5,
                  SNES_DIVERGED_LINE_SEARCH         = -6, /* the line search failed */
                  SNES_DIVERGED_INNER               = -7, /* inner solve failed */
                  SNES_DIVERGED_LOCAL_MIN           = -8, /* || J^T b || is small, implies converged to local minimum of F() */
                  SNES_CONVERGED_ITERATING          =  0} SNESConvergedReason;

Many br

The two most common reasons for divergence are Many br

      1) an incorrectly coded or computed Jacobian or

      2) failure or lack of convergence in the linear system (in this case we recommend

         testing with -pc_type lu to eliminate the linear solver as the cause of the problem).

### Diverged Reasons

SNES_DIVERGED_LOCAL_MIN -this can only occur when using the line-search variant of SNES. Many brThe line search wants to minimize Q(alpha) = 1/2 || F(x + alpha s) ||^2_2 this occurs Many brat Q'(alpha) = s^T F'(x+alpha s)^T F(x+alpha s) = 0. If s is the Newton direction - F'(x)^(-1)F(x) then Many bryou get Q'(alpha) = -F(x)^T F'(x)^(-1)^T F'(x+alpha s)F(x+alpha s); when alpha = 0 Many brQ'(0) = - ||F(x)||^2_2 which is always NEGATIVE if F'(x) is invertible. This means the Newton Many brdirection is a descent direction and the line search should succeed if alpha is small enough. Many br

If F'(x) is NOT invertible AND F'(x)^T F(x) = 0 then Q'(0) = 0 and the Newton direction Many bris NOT a descent direction so the line search will fail. All one can do at this point Many bris change the initial guess and try again. Many br

An alternative explanation: Newton's method can be regarded as replacing the function with Many brits linear approximation and minimizing the 2-norm of that. That is F(x+s) approx F(x) + F'(x)s Many brso we minimize || F(x) + F'(x) s ||^2_2; do this using Least Squares. If F'(x) is invertible then Many brs = - F'(x)^(-1)F(x) otherwise F'(x)^T F'(x) s = -F'(x)^T F(x). If F'(x)^T F(x) is NOT zero then there Many brexists a nontrival (that is F'(x)s != 0) solution to the equation and this direction is Many brs = - [F'(x)^T F'(x)]^(-1) F'(x)^T F(x) so Q'(0) = - F(x)^T F'(x) [F'(x)^T F'(x)]^(-T) F'(x)^T F(x) Many br= - (F'(x)^T F(x)) [F'(x)^T F'(x)]^(-T) (F'(x)^T F(x)). Since we are assuming (F'(x)^T F(x)) != 0 Many brand F'(x)^T F'(x) has no negative eigenvalues Q'(0) < 0 so s is a descent direction and the line Many brsearch should succeed for small enough alpha. Many br

Note that this RARELY happens in practice. Far more likely the linear system is not being solved Many br(well enough?) or the Jacobian is wrong. Many br

SNES_DIVERGED_MAX_IT means that the solver reached the maximum number of iterations without satisfying any Many brconvergence criteria. SNES_CONVERGED_ITS means that SNESConvergedSkip() was chosen as the convergence test; Many brthus the usual convergence criteria have not been checked and may or may not be satisfied. Many br

Developer Notes: this must match petsc/finclude/petscsnes.h Many br

The string versions of these are in SNESConvergedReason, if you change any value here you must Many bralso adjust that array. Many br

Each reason has its own manual page. Many br

### See Also

SNESSolve(), SNESGetConvergedReason(), KSPConvergedReason, SNESSetConvergenceTest()

Level:beginner
Location:src/snes/../../include/petscsnes.h
Index of all SNES routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/snes/examples/tutorials/ex30.c.html