Cannot iterate well when using Newton iteration of SNES
I am using the Newton iteration to solve a nonlinear 1D heat equation problem by using FEM. I attached my source code named "SNES_heat.cpp" when I run the code 0 SNES Function norm 1.206289245288e+01 1 SNES Function norm 7.128802192789e+00 2 SNES Function norm 6.608812909525e+00 you can find that it only iterate 3 steps, and then do all the function evaluation and finally just stop the program. 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. But when I set it as a nonlinear, the residual seems reduces as not expected. I doubt that whether my understanding of the newton iteration is different from SNES's newton iteration process. David Jiawei LUO LIANG 南方科技大学/学生/研究生/2024 广东省深圳市南山区学苑大道1088号
You should add VecZeroEntries(f) near the top of your FormFunction (it's currently accumulating into whatever was there last) and MatZeroEntries(B) to FormJacobian. I reduced to nElem = 5 for ease of viewing. With these changes, I see quadratic convergence but the problem is still nonlinear. To explore further, consider using these diagnostics ./SNES_heat -{snes,ksp}_monitor -{snes,ksp}_converged_reason -snes_linesearch_monitor -ksp_view_mat with and without -snes_fd. For readability, I would suggest consistency in "u" vs "x". "David Jiawei LUO LIANG" <[email protected]> writes:
I am using the Newton iteration to solve a nonlinear 1D heat equation problem by using FEM.
I attached my source code named "SNES_heat.cpp"
when I run the code
0 SNES Function norm 1.206289245288e+01
1 SNES Function norm 7.128802192789e+00
2 SNES Function norm 6.608812909525e+00
you can find that it only iterate 3 steps, and then do all the function evaluation and finally just stop the program.
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.
But when I set it as a nonlinear, the residual seems reduces as not expected.
I doubt that whether my understanding of the newton iteration is different from SNES's newton iteration process.
David Jiawei LUO LIANG
南方科技大学/学生/研究生/2024
广东省深圳市南山区学苑大道1088号
Thank you Jed. It works, and the result is identical to the exact solution! Hope you best! David Jiawei LUO LIANG 南方科技大学/学生/研究生/2024 广东省深圳市南山区学苑大道1088号 ------------------ Original ------------------ From: "Jed Brown"<[email protected]>; Date: Thu, Nov 21, 2024 11:05 PM To: "David Jiawei LUO LIANG"<[email protected]>; "petsc-users"<[email protected]>; Subject: Re: [petsc-users] Cannot iterate well when using Newton iteration of SNES You should add VecZeroEntries(f) near the top of your FormFunction (it's currently accumulating into whatever was there last) and MatZeroEntries(B) to FormJacobian. I reduced to nElem = 5 for ease of viewing. With these changes, I see quadratic convergence but the problem is still nonlinear. To explore further, consider using these diagnostics ./SNES_heat -{snes,ksp}_monitor -{snes,ksp}_converged_reason -snes_linesearch_monitor -ksp_view_mat with and without -snes_fd. For readability, I would suggest consistency in "u" vs "x". "David Jiawei LUO LIANG" <[email protected]> writes: > I am using the Newton iteration to solve a nonlinear 1D heat equation problem by using FEM. > > > I attached my source code named "SNES_heat.cpp" > > > when I run the code > > 0 SNES Function norm 1.206289245288e+01 > > 1 SNES Function norm 7.128802192789e+00 > > 2 SNES Function norm 6.608812909525e+00 > > > > you can find that it only iterate 3 steps, and then do all the function evaluation and finally just stop the program. > > > 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. > > > But when I set it as a nonlinear, the residual seems reduces as not expected. > > > I doubt that whether my understanding of the newton iteration is different from SNES's newton iteration process. > > > > > > > > > David Jiawei LUO LIANG > > > > 南方科技大学/学生/研究生/2024 > > > > 广东省深圳市南山区学苑大道1088号 > > > > >
One more suggestion email. I solve the linear version myself in ts/tutorials/ex45.c Thanks, Matt On Thu, Nov 21, 2024 at 10:35 AM Jed Brown <[email protected]> wrote:
You should add VecZeroEntries(f) near the top of your FormFunction (it's currently accumulating into whatever was there last) and MatZeroEntries(B) to FormJacobian.
I reduced to nElem = 5 for ease of viewing. With these changes, I see quadratic convergence but the problem is still nonlinear. To explore further, consider using these diagnostics
./SNES_heat -{snes,ksp}_monitor -{snes,ksp}_converged_reason -snes_linesearch_monitor -ksp_view_mat
with and without -snes_fd.
For readability, I would suggest consistency in "u" vs "x".
"David Jiawei LUO LIANG" <[email protected]> writes:
I am using the Newton iteration to solve a nonlinear 1D heat equation problem by using FEM.
I attached my source code named "SNES_heat.cpp"
when I run the code
0 SNES Function norm 1.206289245288e+01
1 SNES Function norm 7.128802192789e+00
2 SNES Function norm 6.608812909525e+00
you can find that it only iterate 3 steps, and then do all the function evaluation and finally just stop the program.
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.
But when I set it as a nonlinear, the residual seems reduces as not expected.
I doubt that whether my understanding of the newton iteration is different from SNES's newton iteration process.
David Jiawei LUO LIANG
南方科技大学/学生/研究生/2024
广东省深圳市南山区学苑大道1088号
-- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener https://urldefense.us/v3/__https://www.cse.buffalo.edu/*knepley/__;fg!!G_uCf... <https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfs... >
Coincidentally, Matt. I am gonna write the 2d heat dynamic problem. Now I still not that much understand how DM mesh works. It is a good chance to learn DM by studying your example. Hope you the best! David Jiawei LUO LIANG 南方科技大学/学生/研究生/2024 广东省深圳市南山区学苑大道1088号 ------------------ Original ------------------ From: "Matthew Knepley"<[email protected]>; Date: Thu, Nov 21, 2024 11:37 PM To: "Jed Brown"<[email protected]>; Cc: "David Jiawei LUO LIANG"<[email protected]>; "petsc-users"<[email protected]>; Subject: Re: [petsc-users] Cannot iterate well when using Newton iteration of SNES One more suggestion email. I solve the linear version myself in ts/tutorials/ex45.c Thanks, Matt On Thu, Nov 21, 2024 at 10:35 AM Jed Brown <[email protected]> wrote: You should add VecZeroEntries(f) near the top of your FormFunction (it's currently accumulating into whatever was there last) and MatZeroEntries(B) to FormJacobian. I reduced to nElem = 5 for ease of viewing. With these changes, I see quadratic convergence but the problem is still nonlinear. To explore further, consider using these diagnostics ./SNES_heat -{snes,ksp}_monitor -{snes,ksp}_converged_reason -snes_linesearch_monitor -ksp_view_mat with and without -snes_fd. For readability, I would suggest consistency in "u" vs "x". "David Jiawei LUO LIANG" <[email protected]> writes: > I am using the Newton iteration to solve a nonlinear 1D heat equation problem by using FEM. > > > I attached my source code named "SNES_heat.cpp" > > > when I run the code > > 0 SNES Function norm 1.206289245288e+01 > > 1 SNES Function norm 7.128802192789e+00 > > 2 SNES Function norm 6.608812909525e+00 > > > > you can find that it only iterate 3 steps, and then do all the function evaluation and finally just stop the program. > > > 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. > > > But when I set it as a nonlinear, the residual seems reduces as not expected. > > > I doubt that whether my understanding of the newton iteration is different from SNES's newton iteration process. > > > > > > > > > David Jiawei LUO LIANG > > > > 南方科技大学/学生/研究生/2024 > > > > 广东省深圳市南山区学苑大道1088号 > > > > > -- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener https://urldefense.us/v3/__https://www.cse.buffalo.edu/*knepley/__;fg!!G_uCf...
Start with https://urldefense.us/v3/__https://petsc.org/release/faq/*why-is-newton-s-me... Next use -snes_test_jacobian - 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. -snes_test_jacobian_view - 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. 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. Barry
On Nov 21, 2024, at 7:11 AM, David Jiawei LUO LIANG <[email protected]> wrote:
I am using the Newton iteration to solve a nonlinear 1D heat equation problem by using FEM.
I attached my source code named "SNES_heat.cpp"
when I run the code 0 SNES Function norm 1.206289245288e+01 1 SNES Function norm 7.128802192789e+00 2 SNES Function norm 6.608812909525e+00
you can find that it only iterate 3 steps, and then do all the function evaluation and finally just stop the program.
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.
But when I set it as a nonlinear, the residual seems reduces as not expected.
I doubt that whether my understanding of the newton iteration is different from SNES's newton iteration process.
David Jiawei LUO LIANG 南方科技大学/学生/研究生/2024 广东省深圳市南山区学苑大道1088号
<SNES_heat.cpp>
Hi Barry, The problem is I forgot (or say that I didn't know) to initialize the Vec f in residual function and Mat B in Jacobian function. Anyway, thanks for sharing me the link, it is helpful for debugging the program next time. Hope you the best! David Jiawei LUO LIANG 南方科技大学/学生/研究生/2024 广东省深圳市南山区学苑大道1088号 ------------------ Original ------------------ From: "Barry Smith"<[email protected]>; Date: Thu, Nov 21, 2024 11:20 PM To: "David Jiawei LUO LIANG"<[email protected]>; Cc: "petsc-users"<[email protected]>; Subject: Re: [petsc-users] Cannot iterate well when using Newton iteration of SNES Start with https://urldefense.us/v3/__https://petsc.org/release/faq/*why-is-newton-s-me... Next use -snes_test_jacobian - 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. -snes_test_jacobian_view - 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. 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. Barry On Nov 21, 2024, at 7:11 AM, David Jiawei LUO LIANG <[email protected]> wrote: I am using the Newton iteration to solve a nonlinear 1D heat equation problem by using FEM. I attached my source code named "SNES_heat.cpp" when I run the code 0 SNES Function norm 1.206289245288e+01 1 SNES Function norm 7.128802192789e+00 2 SNES Function norm 6.608812909525e+00 you can find that it only iterate 3 steps, and then do all the function evaluation and finally just stop the program. 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. But when I set it as a nonlinear, the residual seems reduces as not expected. I doubt that whether my understanding of the newton iteration is different from SNES's newton iteration process. David Jiawei LUO LIANG 南方科技大学/学生/研究生/2024 广东省深圳市南山区学苑大道1088号 <SNES_heat.cpp>
On Thu, Nov 21, 2024 at 8:57 AM David Jiawei LUO LIANG < [email protected]> wrote:
I am using the Newton iteration to solve a nonlinear 1D heat equation problem by using FEM.
I attached my source code named "SNES_heat.cpp"
when I run the code
0 SNES Function norm 1.206289245288e+01
1 SNES Function norm 7.128802192789e+00
2 SNES Function norm 6.608812909525e+00
you can find that it only iterate 3 steps, and then do all the function evaluation and finally just stop the program.
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.
But when I set it as a nonlinear, the residual seems reduces as not expected.
I doubt that whether my understanding of the newton iteration is different from SNES's newton iteration process.
Here is what happens with the code as it is: master *:~/Downloads/tmp/Liang$ ./SNES_heat -snes_monitor -ksp_converged_reason -snes_converged_reason -pc_type lu -snes_view -snes_linesearch_monitor pp 1 nElem 10 nqp 2 n_np 11 n_en 2 n_eq 10 qp: 0.57735 -0.57735 wq: 1 1 IEN: 1 2 3 4 5 6 7 8 9 10 2 3 4 5 6 7 8 9 10 11 x_coor: 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 ID: 1 2 3 4 5 6 7 8 9 10 0 0 SNES Function norm 1.206289245288e+01 Linear solve converged due to CONVERGED_RTOL iterations 1 Line search: Using full step: fnorm 1.206289245288e+01 gnorm 7.128802192789e+00 1 SNES Function norm 7.128802192789e+00 Linear solve converged due to CONVERGED_RTOL iterations 1 Line search: Using full step: fnorm 7.128802192789e+00 gnorm 6.608812909525e+00 2 SNES Function norm 6.608812909525e+00 Linear solve converged due to CONVERGED_RTOL iterations 1 Line search: gnorm after quadratic fit 1.265375106867e+01 Line search: Cubic step no good, shrinking lambda, current gnorm 1.328962011911e+01 lambda=1.7500506382162818e-02 Line search: Cubic step no good, shrinking lambda, current gnorm 1.275802797864e+01 lambda=1.7500506382162819e-03 Line search: Cubic step no good, shrinking lambda, current gnorm 1.327920917220e+01 lambda=1.7500506382162821e-04 Line search: Cubic step no good, shrinking lambda, current gnorm 1.275906891232e+01 lambda=1.7500506382162820e-05 Line search: Cubic step no good, shrinking lambda, current gnorm 1.327910508109e+01 lambda=1.7500506382162821e-06 Line search: Cubic step no good, shrinking lambda, current gnorm 1.275907932147e+01 lambda=1.7500506382162822e-07 Line search: Cubic step no good, shrinking lambda, current gnorm 1.327910404018e+01 lambda=1.7500506382162823e-08 Line search: Cubic step no good, shrinking lambda, current gnorm 1.275907942556e+01 lambda=1.7500506382162823e-09 Line search: Cubic step no good, shrinking lambda, current gnorm 1.327910402977e+01 lambda=1.7500506382162824e-10 Line search: Cubic step no good, shrinking lambda, current gnorm 1.275907942660e+01 lambda=1.7500506382162825e-11 Line search: Cubic step no good, shrinking lambda, current gnorm 1.327910402966e+01 lambda=1.7500506382162826e-12 Line search: Cubic step no good, shrinking lambda, current gnorm 1.275907942661e+01 lambda=1.7500506382162828e-13 Line search: unable to find good step length! After 12 tries Line search: fnorm=6.6088129095253478e+00, gnorm=1.2759079426614502e+01, ynorm=5.3714153713436097e-01, minlambda=9.9999999999999998e-13, lambda=1.7500506382162828e-13, initial slope=-4.3676408073108860e+01 Nonlinear solve did not converge due to DIVERGED_LINE_SEARCH iterations 2 Usually, we suspect that the Jacobian is incorrect in this case. Thus we can have it formed automatically, master *:~/Downloads/tmp/Liang$ ./SNES_heat -snes_monitor -ksp_converged_reason -snes_converged_reason -snes_fd -pc_type lu -snes_view -snes_linesearch_monitor pp 1 nElem 10 nqp 2 n_np 11 n_en 2 n_eq 10 qp: 0.57735 -0.57735 wq: 1 1 IEN: 1 2 3 4 5 6 7 8 9 10 2 3 4 5 6 7 8 9 10 11 x_coor: 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 ID: 1 2 3 4 5 6 7 8 9 10 0 0 SNES Function norm 1.206289245288e+01 Linear solve converged due to CONVERGED_RTOL iterations 1 Line search: Scaling step by 1.837216392007e-47 old ynorm 5.443016970405e+54 Line search: gnorm after quadratic fit 3.704240795372e+16 Line search: Cubic step no good, shrinking lambda, current gnorm 3.704614960636e+16 lambda=1.0000000000000002e-02 Line search: Cubic step no good, shrinking lambda, current gnorm 3.704611219026e+16 lambda=1.0000000000000002e-03 Line search: Cubic step no good, shrinking lambda, current gnorm 3.704611256438e+16 lambda=1.0000000000000003e-04 Line search: Cubic step no good, shrinking lambda, current gnorm 3.704611256064e+16 lambda=1.0000000000000004e-05 Line search: Cubic step no good, shrinking lambda, current gnorm 3.704611256068e+16 lambda=1.0000000000000004e-06 Line search: Cubic step no good, shrinking lambda, current gnorm 3.704611256068e+16 lambda=1.0000000000000005e-07 Line search: Cubic step no good, shrinking lambda, current gnorm 3.704611256068e+16 lambda=1.0000000000000005e-08 Line search: Cubic step no good, shrinking lambda, current gnorm 3.704611256068e+16 lambda=1.0000000000000005e-09 Line search: Cubic step no good, shrinking lambda, current gnorm 3.704611256068e+16 lambda=1.0000000000000006e-10 Line search: Cubic step no good, shrinking lambda, current gnorm 3.704611256068e+16 lambda=1.0000000000000006e-11 Line search: Cubic step no good, shrinking lambda, current gnorm 3.704611256068e+16 lambda=1.0000000000000006e-12 Line search: Cubic step no good, shrinking lambda, current gnorm 3.704611256068e+16 lambda=1.0000000000000007e-13 Line search: unable to find good step length! After 12 tries Line search: fnorm=1.2062892452882465e+01, gnorm=3.7046112560677824e+16, ynorm=1.0000000000000000e+08, minlambda=9.9999999999999998e-13, lambda=1.0000000000000007e-13, initial slope=-4.6079597780656769e+00 Nonlinear solve did not converge due to DIVERGED_LINE_SEARCH iterations 0 So it is clear that the Jacobian do not match. Moreover, it appears that Newton is not going to converge from this initial guess. It suggests that the residual is wrong somehow. I suggest coding up a MMS to prove to yourself that the residual is correct. Thanks, Matt
David Jiawei LUO LIANG
南方科技大学/学生/研究生/2024
广东省深圳市南山区学苑大道1088号
-- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener https://urldefense.us/v3/__https://www.cse.buffalo.edu/*knepley/__;fg!!G_uCf... <https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfs... >
Hi Matt, Yes, the residual and Jacobin function are both incorrect. Both of the Vec f and Mat B haven't initialized as zeros. Jed caught that bug, thanks Jed. Anyway, thank you for your method to debug my program for the next time bug.. Hope you the best! David Jiawei LUO LIANG 南方科技大学/学生/研究生/2024 广东省深圳市南山区学苑大道1088号 ------------------ Original ------------------ From: "Matthew Knepley"<[email protected]>; Date: Thu, Nov 21, 2024 11:21 PM To: "David Jiawei LUO LIANG"<[email protected]>; Cc: "petsc-users"<[email protected]>; Subject: Re: [petsc-users] Cannot iterate well when using Newton iteration of SNES On Thu, Nov 21, 2024 at 8:57 AM David Jiawei LUO LIANG <[email protected]> wrote: I am using the Newton iteration to solve a nonlinear 1D heat equation problem by using FEM. I attached my source code named "SNES_heat.cpp" when I run the code 0 SNES Function norm 1.206289245288e+01 1 SNES Function norm 7.128802192789e+00 2 SNES Function norm 6.608812909525e+00 you can find that it only iterate 3 steps, and then do all the function evaluation and finally just stop the program. 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. But when I set it as a nonlinear, the residual seems reduces as not expected. I doubt that whether my understanding of the newton iteration is different from SNES's newton iteration process. Here is what happens with the code as it is: master *:~/Downloads/tmp/Liang$ ./SNES_heat -snes_monitor -ksp_converged_reason -snes_converged_reason -pc_type lu -snes_view -snes_linesearch_monitor pp 1 nElem 10 nqp 2 n_np 11 n_en 2 n_eq 10 qp: 0.57735 -0.57735 wq: 1 1 IEN: 1 2 3 4 5 6 7 8 9 10 2 3 4 5 6 7 8 9 10 11 x_coor: 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 ID: 1 2 3 4 5 6 7 8 9 10 0 0 SNES Function norm 1.206289245288e+01 Linear solve converged due to CONVERGED_RTOL iterations 1 Line search: Using full step: fnorm 1.206289245288e+01 gnorm 7.128802192789e+00 1 SNES Function norm 7.128802192789e+00 Linear solve converged due to CONVERGED_RTOL iterations 1 Line search: Using full step: fnorm 7.128802192789e+00 gnorm 6.608812909525e+00 2 SNES Function norm 6.608812909525e+00 Linear solve converged due to CONVERGED_RTOL iterations 1 Line search: gnorm after quadratic fit 1.265375106867e+01 Line search: Cubic step no good, shrinking lambda, current gnorm 1.328962011911e+01 lambda=1.7500506382162818e-02 Line search: Cubic step no good, shrinking lambda, current gnorm 1.275802797864e+01 lambda=1.7500506382162819e-03 Line search: Cubic step no good, shrinking lambda, current gnorm 1.327920917220e+01 lambda=1.7500506382162821e-04 Line search: Cubic step no good, shrinking lambda, current gnorm 1.275906891232e+01 lambda=1.7500506382162820e-05 Line search: Cubic step no good, shrinking lambda, current gnorm 1.327910508109e+01 lambda=1.7500506382162821e-06 Line search: Cubic step no good, shrinking lambda, current gnorm 1.275907932147e+01 lambda=1.7500506382162822e-07 Line search: Cubic step no good, shrinking lambda, current gnorm 1.327910404018e+01 lambda=1.7500506382162823e-08 Line search: Cubic step no good, shrinking lambda, current gnorm 1.275907942556e+01 lambda=1.7500506382162823e-09 Line search: Cubic step no good, shrinking lambda, current gnorm 1.327910402977e+01 lambda=1.7500506382162824e-10 Line search: Cubic step no good, shrinking lambda, current gnorm 1.275907942660e+01 lambda=1.7500506382162825e-11 Line search: Cubic step no good, shrinking lambda, current gnorm 1.327910402966e+01 lambda=1.7500506382162826e-12 Line search: Cubic step no good, shrinking lambda, current gnorm 1.275907942661e+01 lambda=1.7500506382162828e-13 Line search: unable to find good step length! After 12 tries Line search: fnorm=6.6088129095253478e+00, gnorm=1.2759079426614502e+01, ynorm=5.3714153713436097e-01, minlambda=9.9999999999999998e-13, lambda=1.7500506382162828e-13, initial slope=-4.3676408073108860e+01 Nonlinear solve did not converge due to DIVERGED_LINE_SEARCH iterations 2 Usually, we suspect that the Jacobian is incorrect in this case. Thus we can have it formed automatically, master *:~/Downloads/tmp/Liang$ ./SNES_heat -snes_monitor -ksp_converged_reason -snes_converged_reason -snes_fd -pc_type lu -snes_view -snes_linesearch_monitor pp 1 nElem 10 nqp 2 n_np 11 n_en 2 n_eq 10 qp: 0.57735 -0.57735 wq: 1 1 IEN: 1 2 3 4 5 6 7 8 9 10 2 3 4 5 6 7 8 9 10 11 x_coor: 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 ID: 1 2 3 4 5 6 7 8 9 10 0 0 SNES Function norm 1.206289245288e+01 Linear solve converged due to CONVERGED_RTOL iterations 1 Line search: Scaling step by 1.837216392007e-47 old ynorm 5.443016970405e+54 Line search: gnorm after quadratic fit 3.704240795372e+16 Line search: Cubic step no good, shrinking lambda, current gnorm 3.704614960636e+16 lambda=1.0000000000000002e-02 Line search: Cubic step no good, shrinking lambda, current gnorm 3.704611219026e+16 lambda=1.0000000000000002e-03 Line search: Cubic step no good, shrinking lambda, current gnorm 3.704611256438e+16 lambda=1.0000000000000003e-04 Line search: Cubic step no good, shrinking lambda, current gnorm 3.704611256064e+16 lambda=1.0000000000000004e-05 Line search: Cubic step no good, shrinking lambda, current gnorm 3.704611256068e+16 lambda=1.0000000000000004e-06 Line search: Cubic step no good, shrinking lambda, current gnorm 3.704611256068e+16 lambda=1.0000000000000005e-07 Line search: Cubic step no good, shrinking lambda, current gnorm 3.704611256068e+16 lambda=1.0000000000000005e-08 Line search: Cubic step no good, shrinking lambda, current gnorm 3.704611256068e+16 lambda=1.0000000000000005e-09 Line search: Cubic step no good, shrinking lambda, current gnorm 3.704611256068e+16 lambda=1.0000000000000006e-10 Line search: Cubic step no good, shrinking lambda, current gnorm 3.704611256068e+16 lambda=1.0000000000000006e-11 Line search: Cubic step no good, shrinking lambda, current gnorm 3.704611256068e+16 lambda=1.0000000000000006e-12 Line search: Cubic step no good, shrinking lambda, current gnorm 3.704611256068e+16 lambda=1.0000000000000007e-13 Line search: unable to find good step length! After 12 tries Line search: fnorm=1.2062892452882465e+01, gnorm=3.7046112560677824e+16, ynorm=1.0000000000000000e+08, minlambda=9.9999999999999998e-13, lambda=1.0000000000000007e-13, initial slope=-4.6079597780656769e+00 Nonlinear solve did not converge due to DIVERGED_LINE_SEARCH iterations 0 So it is clear that the Jacobian do not match. Moreover, it appears that Newton is not going to converge from this initial guess. It suggests that the residual is wrong somehow. I suggest coding up a MMS to prove to yourself that the residual is correct. Thanks, Matt David Jiawei LUO LIANG 南方科技大学/学生/研究生/2024 广东省深圳市南山区学苑大道1088号 -- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener https://urldefense.us/v3/__https://www.cse.buffalo.edu/*knepley/__;fg!!G_uCf...
participants (4)
-
Barry Smith -
David Jiawei LUO LIANG -
Jed Brown -
Matthew Knepley