<div dir="ltr">Hi,<br>Thank you for the suggestions. I am attaching a text file which might help you better understand the problem. <br>1) The first column is iteration number of the outer loop (not that of BiCGStab itself, but the loop I mentioned previously)<br>2) The second column is the output from KSPGetConvergedReason().<br>3) The third column is the 2-norm of the solution update <span><span style="font-style:italic">|| x<sup><span style="font-size:92%">i</span></sup>-x<sup><span style="font-size:92%">i-1</span></sup>||<sub><span style="font-size:92%">2</span></sub></span></span><br>4) The last column is the infinity norm of the solution update
<span><span style="font-style:italic">|| x<sup><span style="font-size:92%">i</span></sup>-x<sup><span style="font-size:92%">i-1</span></sup>||<sub><span style="font-size:92%">∞</span></sub></span><br><br>As can be seen from the file, both the 2-norm and the infinity norm are highly oscillating and become zero at the end. Please let me know if any more information is required. <br><br>Best Regards,<br>Pranay.</span></div><div hspace="streak-pt-mark" style="max-height:1px"><img alt="" style="width:0px;max-height:0px;overflow:hidden" src="https://mailfoogae.appspot.com/t?sender=acHJhbmF5cmVkZHk4NjVAZ21haWwuY29t&type=zerocontent&guid=5156b77b-43dc-4f97-8295-9111aa8aedca"><font color="#ffffff" size="1">ᐧ</font></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Aug 22, 2020 at 8:10 AM Barry Smith <<a href="mailto:bsmith@petsc.dev" target="_blank">bsmith@petsc.dev</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><br><br></div><div> Pranay</div><div><br></div> Newton's method is generally the best choice for nonlinear problems as Matt notes but PETSc also provides an implementation of Picard's method with SNESSetPicard() <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESSetPicard.html" target="_blank">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESSetPicard.html</a><div><br></div><div> We implement the defect correction form of the Picard iteration because it converges much more generally when inexact linear solvers are used then the direct Picard iteration A(x^n) x^{n+1} = b(x^n), which is what Matt just said.</div><div><br></div><div> Based on your email it looks like you using the direct Picard iteration algorithm. </div><div><br></div><div> With your current code you can likely easily switch to trying SNESSetPicard() and then switch to trying Newton with SNESSetFunction(), <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESSetFunction.html" target="_blank">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESSetFunction.html</a> and SNESSetJacobian() <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESSetJacobian.html" target="_blank">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESSetJacobian.html</a></div><div><br></div><div> PETSc is designed to make it as simple as possible to switch between various algorithms to help determine the best for your exact problem. </div><div><br></div><div> SNES uses KSP for is linear solvers so you get full access to all the possible preconditioners, for larger problems as Matt notes, once you have the best nonlinear convergence selected tuning the linear solver is the most important thing to do for speed. We recommend when possible first getting good nonlinear convergence using a direct linear solver and then switching to an iterative solver as an optimization, for large problems you almost always should to switch to an iterative solver when the problem size increases.<br><div><br></div><div> Barry</div><div><br><div><div><br><blockquote type="cite"><div>On Aug 22, 2020, at 7:24 AM, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><div dir="ltr">On Sat, Aug 22, 2020 at 2:07 AM baikadi pranay <<a href="mailto:pranayreddy865@gmail.com" target="_blank">pranayreddy865@gmail.com</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 dir="ltr">Hello,<br><br>I am trying to solve the Poisson equation in 2D for heterostructure devices. I have linearized the equation and discretized it using FDM. I am using BiCGStab to iteratively solve for the solution as follows:<br><br>Step 1: Solve A^(i-1) x^(i) = b^(i-1) {i = 1 to N where convergence is reached}<br>Step 2: Use x^{i} to update the central coefficients of A^{i-1} to get A^{i} and similarly update b^{i-1} to get b^{i}<br>Step3: If ( ||x^{i}-x^{i-1}||_2 , the 2-norm of the solution update, is greater than a tolerance, then go back to Step 1 to solve the new system of equations using BiCGStab. Else, exit the loop.<br><b><u>1) I am facing the following problem with this procedure</u></b>:<br>The 2-norm of the solution update is suddenly becoming zero after a few iterations in some cases. I print out the getconvergedreason and there are not red flags there, so I am kind of confused whey this behaviour is being observed. This behaviour is leading to "false convergences", in the sense that the solutions obtained are not physical.<br><br>A similar behaviour was observed when I used SOR instead of BiCGStab. At this point I am starting to suspect if it is wrong to use linear solvers on the poisson equation which is a nonlinear equation (although linearized). If you could please comment on this, that would be very helpful. <br><br>Any help with this problem is greatly appreciated. Please let me know if you need any further information. <br></div></blockquote><div><br></div><div>1) You are coding up the Picard method by hand to solve your nonlinear equation. If the operator is not contractive, this can stagnate, as you are seeing. You</div><div> could try another solver, like Newton's method. We have a variety of nonlinear solves in the SNES class.</div><div><br></div><div>2) It is not clear from your description whether you linear solver is converging. BiCGStab without a preconditioner is a terrible solver for Poisson. We usually</div><div> recommend starting with Algebraic Multigrid, like Hypre which is great at 2D Poisson. You can monitor the convergence of your linear solver using</div><div><br></div><div> -knp_monitor_true_solution -ksp_converged_reason</div><div><br></div><div> We want to see this information with any questions about convergence.</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 dir="ltr">Thank you,<br><br>Sincerely,<br>Pranay.<br><br></div><div hspace="streak-pt-mark" style="max-height:1px"><img alt="" style="width: 0px; max-height: 0px; overflow: hidden;" src="https://mailfoogae.appspot.com/t?sender=acHJhbmF5cmVkZHk4NjVAZ21haWwuY29t&type=zerocontent&guid=e91af943-626d-449a-b812-eafec67b8f5a"><font color="#ffffff" size="1">ᐧ</font></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><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>
</div></blockquote></div><br></div></div></div></div></blockquote></div>