<div dir="ltr"><div dir="ltr">On Thu, Sep 7, 2023 at 8:49 AM Karthikeyan Chockalingam - STFC UKRI via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="msg8798336016346207586">
<div lang="EN-GB" style="overflow-wrap: break-word;">
<div class="m_6963147566296146480WordSection1">
<p class="MsoNormal"><span style="font-size:11pt">I just noticed that the line search diverges even for the linear Poisson equation (where the Jacobian is a constant). I am not sure, what I am doing wrong.</span></p></div></div></div></blockquote><div><br></div><div>You need to test the Jacobian. We have facilities for this. Run using</div><div><br></div><div> --snes_test_jacobian</div><div><br></div><div>This will tell you at each step whether the Jacobian matches the finite difference approximant. It looks like your Jacobian at the second step is wrong. Is it possible that you are not zeroing out the matrix before adding in updates? That would make the second step wrong.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="msg8798336016346207586"><div lang="EN-GB" style="overflow-wrap: break-word;"><div class="m_6963147566296146480WordSection1"><p class="MsoNormal"><span style="font-size:11pt"> </span></p>
<p class="MsoNormal"><span style="font-size:11pt">Best,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt">Karthik.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt"><u></u> <u></u></span></p>
<div id="m_6963147566296146480mail-editor-reference-message-container">
<div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(181,196,223);padding:3pt 0cm 0cm">
<p class="MsoNormal" style="margin-bottom:12pt"><b><span style="font-size:12pt;color:black">From:
</span></b><span style="font-size:12pt;color:black">Chockalingam, Karthikeyan (STFC,DL,HC) <<a href="mailto:karthikeyan.chockalingam@stfc.ac.uk" target="_blank">karthikeyan.chockalingam@stfc.ac.uk</a>><br>
<b>Date: </b>Thursday, 7 September 2023 at 12:19<br>
<b>To: </b>Stefano Zampini <<a href="mailto:stefano.zampini@gmail.com" target="_blank">stefano.zampini@gmail.com</a>><br>
<b>Cc: </b><a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a> <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>><br>
<b>Subject: </b>Re: [petsc-users] Non-linear solve: DIVERGED_LINE_SEARCH<u></u><u></u></span></p>
</div>
<p class="MsoNormal"><span style="font-size:11pt">I am trying to solve the non-linear scalar problem</span><u></u><u></u></p>
<p class="m_6963147566296146480p1">-\nabla \cdot \big( (1+u^2)\nabla u\big)=f<u></u><u></u></p>
<p class="m_6963147566296146480p1">Using finite element formulation.<u></u><u></u></p>
<p class="m_6963147566296146480p1"> <u></u><u></u></p>
<p class="m_6963147566296146480p1">The linear iteration converged – does that mean my Jacobian is correct??<u></u><u></u></p>
<p class="m_6963147566296146480p1"> <u></u><u></u></p>
<p class="m_6963147566296146480p1">I am hoping the non-linear residual goes down to 1-e11.<u></u><u></u></p>
<p class="m_6963147566296146480p1"> <u></u><u></u></p>
<p class="m_6963147566296146480p1">Kind regards,<u></u><u></u></p>
<p class="m_6963147566296146480p1">Karthik.<u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<div id="m_6963147566296146480mail-editor-reference-message-container">
<div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(181,196,223);padding:3pt 0cm 0cm">
<p class="MsoNormal" style="margin-bottom:12pt"><b><span style="font-size:12pt;color:black">From:
</span></b><span style="font-size:12pt;color:black">Stefano Zampini <<a href="mailto:stefano.zampini@gmail.com" target="_blank">stefano.zampini@gmail.com</a>><br>
<b>Date: </b>Thursday, 7 September 2023 at 11:49<br>
<b>To: </b>Chockalingam, Karthikeyan (STFC,DL,HC) <<a href="mailto:karthikeyan.chockalingam@stfc.ac.uk" target="_blank">karthikeyan.chockalingam@stfc.ac.uk</a>><br>
<b>Cc: </b><a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a> <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>><br>
<b>Subject: </b>Re: [petsc-users] Non-linear solve: DIVERGED_LINE_SEARCH</span><u></u><u></u></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">The solver did not diverge.</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">It was the line search that was not able to make further progress in minimizing the 2-norm of the residual.</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">This is common in nonlinear solvers. It would help if you tell us what you are trying to solve.</span><u></u><u></u></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">Note that at the first step, your residual norm is already 1.e-6. What kind of accuracy do you want?</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
</div>
</div>
</div>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">Il giorno gio 7 set 2023 alle ore 13:08 Karthikeyan Chockalingam - STFC UKRI via petsc-users <</span><a href="mailto:petsc-users@mcs.anl.gov" target="_blank"><span style="font-size:11pt">petsc-users@mcs.anl.gov</span></a><span style="font-size:11pt">>
ha scritto:</span><u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt">
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">Hello,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt">The non-linear solution diverged. The final solution seems right and I believe the Jacobian is correct (not 100% certain).
</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt">I am not sure if I doing something wrong in the solver setting.
</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black"> </span></span><span style="color:black">0 SNES Function norm 3.890991210938e-03<span class="m_6963147566296146480m477101460960849173apple-converted-space"> </span></span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">0 KSP Residual norm 9.037762538598e+00<span class="m_6963147566296146480m477101460960849173apple-converted-space"> </span></span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">1 KSP Residual norm 2.120375403775e-01<span class="m_6963147566296146480m477101460960849173apple-converted-space"> </span></span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">2 KSP Residual norm 5.155439334511e-03<span class="m_6963147566296146480m477101460960849173apple-converted-space"> </span></span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">3 KSP Residual norm 1.394364169369e-04<span class="m_6963147566296146480m477101460960849173apple-converted-space"> </span></span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">4 KSP Residual norm 9.233543407204e-06<span class="m_6963147566296146480m477101460960849173apple-converted-space"> </span></span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">Linear solve converged due to CONVERGED_RTOL iterations 4</span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p2"><span style="color:black"> </span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">Line search: Using full step: fnorm 3.890991210938e-03 gnorm 7.701511565083e-06</span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">1 SNES Function norm 7.701511565083e-06<span class="m_6963147566296146480m477101460960849173apple-converted-space"> </span></span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">0 KSP Residual norm 5.630229687829e-03<span class="m_6963147566296146480m477101460960849173apple-converted-space"> </span></span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">1 KSP Residual norm 1.030475601271e-04<span class="m_6963147566296146480m477101460960849173apple-converted-space"> </span></span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">2 KSP Residual norm 2.576454714319e-06<span class="m_6963147566296146480m477101460960849173apple-converted-space"> </span></span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">3 KSP Residual norm 6.669316846898e-08<span class="m_6963147566296146480m477101460960849173apple-converted-space"> </span></span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">4 KSP Residual norm 3.215810984829e-09<span class="m_6963147566296146480m477101460960849173apple-converted-space"> </span></span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">Linear solve converged due to CONVERGED_RTOL iterations 4</span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p2"><span style="color:black"> </span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">Line search: gnorm after quadratic fit 1.805500533481e-05</span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">Line search: Cubic step no good, shrinking lambda, current gnorm 2.563759884284e-05 lambda=3.0804668685096816e-02</span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">Line search: Cubic step no good, shrinking lambda, current gnorm 3.332721829751e-05 lambda=3.0804668685096817e-03</span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">Line search: Cubic step no good, shrinking lambda, current gnorm 4.102754045833e-05 lambda=3.0804668685096822e-04</span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">Line search: Cubic step no good, shrinking lambda, current gnorm 4.872893294880e-05 lambda=3.0804668685096822e-05</span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">Line search: Cubic step no good, shrinking lambda, current gnorm 5.643043250787e-05 lambda=3.0804668685096822e-06</span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">Line search: Cubic step no good, shrinking lambda, current gnorm 6.413194279696e-05 lambda=3.0804668685096827e-07</span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">Line search: Cubic step no good, shrinking lambda, current gnorm 7.183345417492e-05 lambda=3.0804668685096828e-08</span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">Line search: Cubic step no good, shrinking lambda, current gnorm 7.953496567312e-05 lambda=3.0804668685096829e-09</span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">Line search: Cubic step no good, shrinking lambda, current gnorm 8.723647719173e-05 lambda=3.0804668685096831e-10</span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">Line search: Cubic step no good, shrinking lambda, current gnorm 9.493798871875e-05 lambda=3.0804668685096832e-11</span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">Line search: Cubic step no good, shrinking lambda, current gnorm 1.026395002516e-04 lambda=3.0804668685096835e-12</span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">Line search: Cubic step no good, shrinking lambda, current gnorm 1.103410117889e-04 lambda=3.0804668685096835e-13</span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">Line search: unable to find good step length! After 12 tries<span class="m_6963147566296146480m477101460960849173apple-converted-space"> </span></span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span class="m_6963147566296146480m477101460960849173apple-converted-space"><span style="color:black">
</span></span><span style="color:black">Line search: fnorm=7.7015115650831560e-06, gnorm=1.1034101178892401e-04, ynorm=6.2052357872955976e-03, minlambda=9.9999999999999998e-13, lambda=3.0804668685096835e-13, initial slope=-5.9313318983096354e-11</span><u></u><u></u></p>
<p class="m_6963147566296146480m477101460960849173p1"><span style="color:black">Nonlinear solve did not converge due to DIVERGED_LINE_SEARCH iterations 1</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt">Thank you for your help.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt">Kind regards,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt">Karthik.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">-- </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><b><span style="font-size:10.5pt;font-family:Arial,sans-serif;color:rgb(45,45,98)">Dr. Karthik Chockalingam</span></b><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:Arial,sans-serif;color:black">Senior Research Software Engineer</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:Arial,sans-serif;color:black">High Performance Systems Engineering Group</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:Arial,sans-serif;color:black">Hartree Centre | Science and Technology Facilities Council</span><u></u><u></u></p>
<p class="MsoNormal"><a href="mailto:karthikeyan.chockalingam@stfc.ac.uk" target="_blank"><span style="font-size:10.5pt;font-family:Arial,sans-serif;color:rgb(5,99,193)">karthikeyan.chockalingam@stfc.ac.uk</span></a><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif;color:black"> </span><span style="font-size:10.5pt;font-family:Arial,sans-serif;color:rgb(65,65,65)"> </span><u></u><u></u></p>
<p class="MsoNormal"><b><span style="font-size:10.5pt;font-family:Arial,sans-serif;color:rgb(65,65,65)"> </span></b><span style="font-size:12pt;font-family:"Times New Roman",serif;color:rgb(31,73,125)"><img border="0" width="254" height="116" style="width: 2.6458in; height: 1.2083in;" id="m_6963147566296146480_x0000_i1025" alt="signature_3970890138"></span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><span style="font-size:11pt"><br clear="all">
<br>
<span class="m_6963147566296146480gmailsignatureprefix">-- </span></span><u></u><u></u></p>
<div>
<p class="MsoNormal"><span style="font-size:11pt">Stefano</span><u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div></blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>