# [petsc-users] Problems about Line Search

Matthew Knepley knepley at gmail.com
Mon Dec 24 10:29:49 CST 2018

On Mon, Dec 24, 2018 at 9:54 AM Yingjie Wu via petsc-users <
petsc-users at mcs.anl.gov> wrote:

> Dear Petsc developers:
> Hi,
> Recently I encounter an error message, but I don't know how to solve it. I
> solve a problem of a system of nonlinear equations in which the
> coefficients of the system vary with variables. The Args are:
>  mpiexec -n 1 ./myprogram -snes_mf_operator -snes_view
> -snes_converged_reason -snes_monitor -ksp_converged_reason -ksp_monitor
> -ksp_rtol 0.1 -snes_rtol 1e-8 -snes_max_funcs 10000000000 -snes_max_it
> 10000 -pc_factor_levels 6
>

It looks like your Jacobian is wrong. In order to confirm this, I would

a) Try it with exact linear solves, -pc_type lu

b) Check it against an FD Jacobian, -snes_test_jacobian

Matt

> The log is :
> 0 SNES Function norm 2.818062118573e+07
>     0 KSP Residual norm 1.967792312615e+05
>     1 KSP Residual norm 3.423312208841e+03
>   Linear solve converged due to CONVERGED_RTOL iterations 1
>   1 SNES Function norm 2.818049788401e+07
>     0 KSP Residual norm 1.960830037415e+05
>     1 KSP Residual norm 3.458649556419e+03
>   Linear solve converged due to CONVERGED_RTOL iterations 1
> Nonlinear solve did not converge due to DIVERGED_LINE_SEARCH iterations 1
> SNES Object: 1 MPI processes
>   type: newtonls
>   maximum iterations=10000, maximum function evaluations=1410065408
>   tolerances: relative=1e-08, absolute=1e-50, solution=1e-08
>   total number of linear solver iterations=2
>   total number of function evaluations=27
>   norm schedule ALWAYS
>   SNESLineSearch Object: 1 MPI processes
>     type: bt
>       interpolation: cubic
>       alpha=1.000000e-04
>     maxstep=1.000000e+08, minlambda=1.000000e-12
>     tolerances: relative=1.000000e-08, absolute=1.000000e-15,
> lambda=1.000000e-08
>     maximum iterations=40
>   KSP Object: 1 MPI processes
>     type: gmres
>       restart=30, using Classical (unmodified) Gram-Schmidt
> Orthogonalization with no iterative refinement
>       happy breakdown tolerance 1e-30
>     maximum iterations=10000, initial guess is zero
>     tolerances:  relative=0.1, absolute=1e-50, divergence=10000.
>     left preconditioning
>     using PRECONDITIONED norm type for convergence test
>   PC Object: 1 MPI processes
>     type: ilu
>       out-of-place factorization
>       6 levels of fill
>       tolerance for zero pivot 2.22045e-14
>       matrix ordering: natural
>       factor fill ratio given 1., needed 4.29616
>         Factored matrix follows:
>           Mat Object: 1 MPI processes
>             type: seqaij
>             rows=11368, cols=11368
>             package used to perform factorization: petsc
>             total: nonzeros=183764, allocated nonzeros=183764
>             total number of mallocs used during MatSetValues calls =0
>               not using I-node routines
>     linear system matrix followed by preconditioner matrix:
>     Mat Object: 1 MPI processes
>       type: mffd
>       rows=11368, cols=11368
>         Matrix-free approximation:
>           err=1.49012e-08 (relative error in function evaluation)
>           Using wp compute h routine
>               Does not compute normU
>     Mat Object: 1 MPI processes
>       type: seqaij
>       rows=11368, cols=11368
>       total: nonzeros=42774, allocated nonzeros=56840
>       total number of mallocs used during MatSetValues calls =0
>         not using I-node routines
>
>
> I don't know what causes Line_Search to diverge.
> The Ksp_rtol setting in the program is very small because I find that
> linear-step convergence is not good.
>
> My best wishes for Christmas,
> Yingjie
>

--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their