[petsc-users] SNES convergence issue

Barry Smith bsmith at mcs.anl.gov
Mon May 16 20:37:49 CDT 2011


   My conclusion based on the two sets of output (with -pc_type none and -snes_mf_operator and then without the -snes_mf_operator) I need to conclude that 

1) the function is bad (likely a bug in the code)** and

2) the Jacobian is possibly wrong, that is it is not a Jacobian for the function.

   Reason: The finite differencing of the function (with -snes_mf_operator) gives as Jed says "This is remarkably early loss of orthogonality."  Now if the differencing doesn't work this is usually because the function code is wrong.

   Now because the explicit Jacobian linear solve actually works but Newton's method doesn't converge that could indicate the Jacobian is wrong. But since the function is suspicious it could just be do to the bad function.

   ** of course sometimes finite differencing doesn't work for the correctly coded function but usually that is because the function is hugely nonlinear which is not common for most PDEs people solve.

   Suggest you work on your function evaluation to make sure it makes sense (for example run with valgrind: http://www.mcs.anl.gov/petsc/petsc-as/documentation/faq.html#valgrind)

   
   Barry



  From Jed's email.

On Tue, May 17, 2011 at 01:25, Tian(ICT) <rongtian at ncic.ac.cn> wrote:
pgfem -snes_monitor -snes_mf_operator -mat_mffd_type ds -ksp_type fgmres -ksp_monitor_true_residual -ksp_gmres_modifiedgramschmidt -ksp_rtol 1e-10 -pc_type none

atol=1e-050, rtol=1e-008, stol=1e-008, maxit=50, maxf=10000
  0 SNES Function norm 7.071067809722e+001 
  0 KSP preconditioned resid norm 7.071067809722e+001 true resid norm 7.071067809722e+001 ||Ae||/||Ax|| 1.000000000000e+000
  1 KSP preconditioned resid norm 6.628127802131e+001 true resid norm 6.628127802131e+001 ||Ae||/||Ax|| 9.373588233757e-001
  2 KSP preconditioned resid norm 6.060349268020e+001 true resid norm 8.023787055846e+001 ||Ae||/||Ax|| 1.134734847941e+000
  3 KSP preconditioned resid norm 5.893436541308e+001 true resid norm 1.661766291099e+002 ||Ae||/||Ax|| 2.350092427079e+000

This is remarkably early loss of orthogonality. Does it do the same thing if you remove -snes_mf_operator?

./pgfem -snes_monitor -ksp_type fgmres -ksp_monitor_true_residual -ksp_gmres_modifiedgramschmidt -ksp_rtol 1e-10 -pc_type none

If so, add -ksp_view_binary and send the matrix (probably named "binaryoutput") to petsc-maint at mcs.anl.gov .


On May 16, 2011, at 8:04 PM, Tian(ICT) wrote:

> RE: Does it do the same thing if you remove -snes_mf_operator?
> the output is attached:
> 
> ./pgfem -snes_monitor -ksp_type fgmres -ksp_monitor_true_residual -ksp_gmres_modifiedgramschmidt -ksp_rtol 1e-10 -pc_type none
> 
>  
> atol=1e-050, rtol=1e-008, stol=1e-008, maxit=50, maxf=10000
>   0 SNES Function norm 7.071067809722e+001 
>   0 KSP preconditioned resid norm 7.071067809722e+001 true resid norm 7.071067809722e+001 ||Ae||/||Ax|| 1.000000000000e+000
>   1 KSP preconditioned resid norm 6.487377579675e+001 true resid norm 6.487377579675e+001 ||Ae||/||Ax|| 9.174537360193e-001
>   2 KSP preconditioned resid norm 5.946077820276e+001 true resid norm 5.946077820276e+001 ||Ae||/||Ax|| 8.409023898909e-001
>   3 KSP preconditioned resid norm 5.819067642395e+001 true resid norm 5.819067642395e+001 ||Ae||/||Ax|| 8.229404382736e-001
>   4 KSP preconditioned resid norm 5.782978385330e+001 true resid norm 5.782978385330e+001 ||Ae||/||Ax|| 8.178366465923e-001
>   5 KSP preconditioned resid norm 5.781901277269e+001 true resid norm 5.781901277269e+001 ||Ae||/||Ax|| 8.176843205094e-001
>   6 KSP preconditioned resid norm 5.206124924795e+001 true resid norm 5.206124924794e+001 ||Ae||/||Ax|| 7.362572478284e-001
>   7 KSP preconditioned resid norm 4.698325359049e+001 true resid norm 4.698325359046e+001 ||Ae||/||Ax|| 6.644435445218e-001
>   8 KSP preconditioned resid norm 2.252503506952e+001 true resid norm 2.252503506964e+001 ||Ae||/||Ax|| 3.185521009807e-001
>   9 KSP preconditioned resid norm 6.934718778605e+000 true resid norm 6.934718778631e+000 ||Ae||/||Ax|| 9.807173350955e-002
>  10 KSP preconditioned resid norm 2.116841820236e-001 true resid norm 2.116841820007e-001 ||Ae||/||Ax|| 2.993666412160e-003
>  11 KSP preconditioned resid norm 2.248667031844e-003 true resid norm 2.248666418030e-003 ||Ae||/||Ax|| 3.180094546595e-005
>  12 KSP preconditioned resid norm 1.982189998703e-003 true resid norm 1.982189392148e-003 ||Ae||/||Ax|| 2.803239122418e-005
>  13 KSP preconditioned resid norm 7.277701878363e-005 true resid norm 7.277706020826e-005 ||Ae||/||Ax|| 1.029223056074e-006
>  14 KSP preconditioned resid norm 5.491342233241e-005 true resid norm 5.491344683351e-005 ||Ae||/||Ax|| 7.765934129213e-007
>  15 KSP preconditioned resid norm 1.985911495745e-006 true resid norm 1.987317308127e-006 ||Ae||/||Ax|| 2.810491090744e-008
>  16 KSP preconditioned resid norm 8.806822122196e-010 true resid norm 2.040010932359e-009 ||Ae||/||Ax|| 2.885011128806e-011
>   1 SNES Function norm 7.037540247543e+001 
>   0 KSP preconditioned resid norm 7.037540247543e+001 true resid norm 7.037540247543e+001 ||Ae||/||Ax|| 1.000000000000e+000
>   1 KSP preconditioned resid norm 6.014879337697e+001 true resid norm 6.014879337697e+001 ||Ae||/||Ax|| 8.546848936029e-001
>   2 KSP preconditioned resid norm 5.936532946785e+001 true resid norm 5.936532946785e+001 ||Ae||/||Ax|| 8.435522551872e-001
>   3 KSP preconditioned resid norm 5.806472337970e+001 true resid norm 5.806472337970e+001 ||Ae||/||Ax|| 8.250712796986e-001
>   4 KSP preconditioned resid norm 5.776376194749e+001 true resid norm 5.776376194749e+001 ||Ae||/||Ax|| 8.207947651547e-001
>   5 KSP preconditioned resid norm 5.775321493826e+001 true resid norm 5.775321493826e+001 ||Ae||/||Ax|| 8.206448973194e-001
>   6 KSP preconditioned resid norm 5.200122358332e+001 true resid norm 5.200122358332e+001 ||Ae||/||Ax|| 7.389119174342e-001
>   7 KSP preconditioned resid norm 4.692806395721e+001 true resid norm 4.692806395717e+001 ||Ae||/||Ax|| 6.668248039300e-001
>   8 KSP preconditioned resid norm 2.249722526208e+001 true resid norm 2.249722526213e+001 ||Ae||/||Ax|| 3.196745520566e-001
>   9 KSP preconditioned resid norm 6.926914352987e+000 true resid norm 6.926914353057e+000 ||Ae||/||Ax|| 9.842806022282e-002
>  10 KSP preconditioned resid norm 2.112669106382e-001 true resid norm 2.112669106262e-001 ||Ae||/||Ax|| 3.001999323555e-003
>  11 KSP preconditioned resid norm 2.205894521142e-003 true resid norm 2.205894348027e-003 ||Ae||/||Ax|| 3.134467826024e-005
>  12 KSP preconditioned resid norm 1.997274432688e-003 true resid norm 1.997274203505e-003 ||Ae||/||Ax|| 2.838028818666e-005
>  13 KSP preconditioned resid norm 1.074423963192e-003 true resid norm 1.074423723438e-003 ||Ae||/||Ax|| 1.526703486794e-005
>  14 KSP preconditioned resid norm 2.196883599631e-008 true resid norm 2.193274946006e-008 ||Ae||/||Ax|| 3.116536273838e-010
>  15 KSP preconditioned resid norm 6.701870711306e-010 true resid norm 2.507972672018e-009 ||Ae||/||Ax|| 3.563706328918e-011
>   2 SNES Function norm 7.036650604408e+001 
>   0 KSP preconditioned resid norm 7.036650604408e+001 true resid norm 7.036650604408e+001 ||Ae||/||Ax|| 1.000000000000e+000
>   1 KSP preconditioned resid norm 5.961660984718e+001 true resid norm 5.961660984718e+001 ||Ae||/||Ax|| 8.472299279693e-001
>   2 KSP preconditioned resid norm 5.898186321330e+001 true resid norm 5.898186321330e+001 ||Ae||/||Ax|| 8.382093488676e-001
>   3 KSP preconditioned resid norm 5.803844203063e+001 true resid norm 5.803844203063e+001 ||Ae||/||Ax|| 8.248021010773e-001
>   4 KSP preconditioned resid norm 5.775247508524e+001 true resid norm 5.775247508524e+001 ||Ae||/||Ax|| 8.207381371055e-001
>   5 KSP preconditioned resid norm 5.774197168106e+001 true resid norm 5.774197168106e+001 ||Ae||/||Ax|| 8.205888700071e-001
>   6 KSP preconditioned resid norm 5.199097115954e+001 true resid norm 5.199097115953e+001 ||Ae||/||Ax|| 7.388596376656e-001
>   7 KSP preconditioned resid norm 4.691863775585e+001 true resid norm 4.691863775585e+001 ||Ae||/||Ax|| 6.667751518948e-001
>   8 KSP preconditioned resid norm 2.249247574480e+001 true resid norm 2.249247574465e+001 ||Ae||/||Ax|| 3.196474716331e-001
>   9 KSP preconditioned resid norm 6.925581352168e+000 true resid norm 6.925581352175e+000 ||Ae||/||Ax|| 9.842156078967e-002
>  10 KSP preconditioned resid norm 2.111959897559e-001 true resid norm 2.111959897926e-001 ||Ae||/||Ax|| 3.001370988355e-003
>  11 KSP preconditioned resid norm 2.197554118182e-003 true resid norm 2.197554117525e-003 ||Ae||/||Ax|| 3.123011559148e-005
>  12 KSP preconditioned resid norm 1.997607369649e-003 true resid norm 1.997607414609e-003 ||Ae||/||Ax|| 2.838861166927e-005
>  13 KSP preconditioned resid norm 1.000748904690e-003 true resid norm 1.000748843027e-003 ||Ae||/||Ax|| 1.422194875499e-005
>  14 KSP preconditioned resid norm 8.525193893681e-007 true resid norm 8.526861878498e-007 ||Ae||/||Ax|| 1.211778494893e-008
>  15 KSP preconditioned resid norm 5.457483213140e-009 true resid norm 7.175955157596e-009 ||Ae||/||Ax|| 1.019796997324e-010
>   3 SNES Function norm 7.036650590325e+001 
>   0 KSP preconditioned resid norm 7.036650590325e+001 true resid norm 7.036650590325e+001 ||Ae||/||Ax|| 1.000000000000e+000
>   1 KSP preconditioned resid norm 5.961656312518e+001 true resid norm 5.961656312518e+001 ||Ae||/||Ax|| 8.472292656843e-001
>   2 KSP preconditioned resid norm 5.898128385953e+001 true resid norm 5.898128385953e+001 ||Ae||/||Ax|| 8.382011171710e-001
>   3 KSP preconditioned resid norm 5.803842974968e+001 true resid norm 5.803842974968e+001 ||Ae||/||Ax|| 8.248019281997e-001
>   4 KSP preconditioned resid norm 5.775247225502e+001 true resid norm 5.775247225502e+001 ||Ae||/||Ax|| 8.207380985270e-001
>   5 KSP preconditioned resid norm 5.774196886175e+001 true resid norm 5.774196886175e+001 ||Ae||/||Ax|| 8.205888315833e-001
>   6 KSP preconditioned resid norm 5.199096858866e+001 true resid norm 5.199096858865e+001 ||Ae||/||Ax|| 7.388596026089e-001
>   7 KSP preconditioned resid norm 4.691863539211e+001 true resid norm 4.691863539209e+001 ||Ae||/||Ax|| 6.667751196372e-001
>   8 KSP preconditioned resid norm 2.249247455418e+001 true resid norm 2.249247455410e+001 ||Ae||/||Ax|| 3.196474553536e-001
>   9 KSP preconditioned resid norm 6.925581017184e+000 true resid norm 6.925581017176e+000 ||Ae||/||Ax|| 9.842155622589e-002
>  10 KSP preconditioned resid norm 2.111959721825e-001 true resid norm 2.111959721155e-001 ||Ae||/||Ax|| 3.001370743147e-003
>  11 KSP preconditioned resid norm 2.197552999267e-003 true resid norm 2.197553329081e-003 ||Ae||/||Ax|| 3.123010444916e-005
>  12 KSP preconditioned resid norm 1.997607044290e-003 true resid norm 1.997607318404e-003 ||Ae||/||Ax|| 2.838861035889e-005
>  13 KSP preconditioned resid norm 1.000461310492e-003 true resid norm 1.000461552464e-003 ||Ae||/||Ax|| 1.421786600915e-005
>  14 KSP preconditioned resid norm 8.488175184617e-007 true resid norm 8.484518586716e-007 ||Ae||/||Ax|| 1.205760962237e-008
>  15 KSP preconditioned resid norm 5.589522141624e-009 true resid norm 5.386565191049e-009 ||Ae||/||Ax|| 7.655013023463e-011
>   4 SNES Function norm 7.036650608027e+001 
> STEP 0 (Newton iterations: 4)
>  
> diverged reason: DIVERGED_LS_FAILURE



More information about the petsc-users mailing list