<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div><br></div> Start with <a href="https://urldefense.us/v3/__https://petsc.org/release/faq/*why-is-newton-s-method-snes-not-converging-or-converges-slowly__;Iw!!G_uCfscf7eWS!au7FVXP89CeLcvEPaqyMevQ8XXBThUgOilXB2BskyYlAyPKwckhOPoT_TGVv_IKuZQTSFDRMPe3F09zTuhtno2k$">https://petsc.org/release/faq/#why-is-newton-s-method-snes-not-converging-or-converges-slowly</a><div><br></div><div> Next use</div><div><br></div><div><ul class="simple" style="box-sizing: border-box; padding-left: 2rem; margin-bottom: 1rem; margin-top: 0px; padding-inline-start: 2rem; caret-color: rgb(34, 40, 50); color: rgb(34, 40, 50);"><li style="box-sizing: border-box;"><p style="box-sizing: border-box; margin-bottom: 0.25rem; margin-top: 0px;"><em style="box-sizing: border-box;"><span style="box-sizing: border-box;">-snes_test_jacobian <optional threshold="" style="box-sizing: border-box;">-</optional></span></em> compare the user provided Jacobian with one computed via finite differences to check for errors. If a threshold is given, display only those entries whose difference is greater than the threshold.</p></li><li style="box-sizing: border-box;"><p style="box-sizing: border-box; margin-bottom: 0px; margin-top: 0px;"><em style="box-sizing: border-box;">-snes_test_jacobian_view -</em> display the user provided Jacobian, the finite difference Jacobian and the difference between them to help users detect the location of errors in the user provided Jacobian.</p><p style="box-sizing: border-box; margin-bottom: 0px; margin-top: 0px;"><br></p><p style="box-sizing: border-box; margin-bottom: 0px; margin-top: 0px;"><br></p><p style="box-sizing: border-box; margin-bottom: 0px; margin-top: 0px;">There are many, many reasons Newton can fail, usually they are due to bugs in the function evaluation or Jacobian evaluation. Occasionly they are due to it being a very difficult non-linear problem. You first need to use the tools above to verify there are no bugs anywhere.</p><p style="box-sizing: border-box; margin-bottom: 0px; margin-top: 0px;"><br></p><p style="box-sizing: border-box; margin-bottom: 0px; margin-top: 0px;">Barry</p><p style="box-sizing: border-box; margin-bottom: 0px; margin-top: 0px; font-size: 1em;"><br></p></li></ul><div><br><blockquote type="cite"><div>On Nov 21, 2024, at 7:11 AM, David Jiawei LUO LIANG <12431140@mail.sustech.edu.cn> wrote:</div><br class="Apple-interchange-newline"><div><div>I am using the Newton iteration to solve a nonlinear 1D heat equation problem by using FEM.</div><div><br></div><div>I attached my source code named "SNES_heat.cpp" </div><div><br></div><div>when I run the code</div><div><div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal; background-color: rgb(254, 244, 139);"><span style="font-variant-ligatures: no-common-ligatures"> 0 SNES Function norm 1.206289245288e+01</span></div><div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal; background-color: rgb(254, 244, 139);"><span style="font-variant-ligatures: no-common-ligatures"> 1 SNES Function norm 7.128802192789e+00</span></div><div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal; background-color: rgb(254, 244, 139);"><span style="font-variant-ligatures: no-common-ligatures"> 2 SNES Function norm 6.608812909525e+00</span></div></div><div><font><br></font></div><div><sign signid="99"><div><font>you can find that it only iterate 3 steps, and then do all the function evaluation and finally just stop the program. </font></div><div><font><br></font></div><div><font>I think it is not reasonble. I check my code, it is correct if I set it as a linear problem. it means my Jacobian and Residual function is correct.</font></div><div><font><br></font></div><div><font>But when I set it as a nonlinear, the residual seems reduces as not expected. </font></div><div><font><br></font></div><div><font>I doubt that whether my understanding of the newton iteration is different from SNES's newton iteration process.</font></div><div><font><br></font><font><br></font><font><br></font><font><br></font><div style="color:#909090;font-family:Arial Narrow;font-size:12px"></div></div><div style="font-size: 14px; font-family: Verdana;" class="signRealArea"><div><div class="logo" style="width:305px;height:35px;line-height:35px;margin:20px 0 0 0;"><img src="https://exmail.qq.com/cgi-bin/viewfile?type=logo&domain=mail.sustech.edu.cn"></div><div class="c_detail" style="margin:10px 0 0 0;"><h4 class="name" style="margin:0;font-size:14px;font-weight:bold;line-height:28px;zoom:1;">David Jiawei LUO LIANG</h4><p class="position" style="margin:0;line-height:22px;color:#a0a0a0;"></p><div style="margin: 0px; line-height: 22px; color: rgb(160, 160, 160);">南方科技大学/学生/研究生/2024</div><p class="phone" style="margin:0;line-height:22px;color:#a0a0a0;"></p><div style="margin: 0px; line-height: 22px; color: rgb(160, 160, 160);">广东省深圳市南山区学苑大道1088号</div></div></div></div></sign></div><div> </div><div><tincludetail><!--<![endif]--></tincludetail></div><!--<![endif]--><span id="cid:2922B63C-C1BF-4F6D-A3D7-CC3D7ADB0AC9"><SNES_heat.cpp></span></div></blockquote></div><br></div></body></html>