[petsc-users] 2-norm of solution update suddenly becomes zero after a few iterations

Barry Smith bsmith at petsc.dev
Sat Aug 22 17:44:44 CDT 2020



  Pranay

  This is due to you using the "full" Picard iteration

   Solve A(x^{i-1}) x^{i} = b(x^{i-1}) 

implementation. The defect correction implementation, which is what PETSc provides is given by

  Solve A(x^{i}) (x^{i+1} - x^{i}) = b(x^{i}) - A(x^{i})x^{i}

will not have this problem.

  The full Picard iteration requires a very accurate linear solve (which is expensive). The defect correction implementation can work with linear solves that only give a couple of digits of accuracy. The reason is you are computing

    x^{i} = x^{i-1} + (x^{i+1} - x^{i})  

where (x^{i+1} - x^{i})  begins to become much smaller than x^{i-1}  so only a few digits in (x^{i+1} - x^{i}) matter. While with the full Picard iteration more and more of the digits in x^{i} (which is computed directly by the linear solve matter) so the linear solver that gives you those digits must be solved more and more accurately.

  Just don't use the full Picard iteration.

   Barry


> On Aug 22, 2020, at 5:14 PM, baikadi pranay <pranayreddy865 at gmail.com> wrote:
> 
> Hi,
> Thank you for the suggestions. I am attaching a text file which might help you better understand the problem. 
> 1) The first column is iteration number of the outer loop (not that of BiCGStab itself, but the loop I mentioned previously)
> 2) The second column is the output from KSPGetConvergedReason().
> 3) The third column is the 2-norm of the solution update || xi-xi-1||2
> 4) The last column is the infinity norm of the solution update  || xi-xi-1||∞
> 
> 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. 
> 
> Best Regards,
> Pranay.
>> 
> On Sat, Aug 22, 2020 at 8:10 AM Barry Smith <bsmith at petsc.dev <mailto:bsmith at petsc.dev>> wrote:
> 
> 
>   Pranay
> 
>    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() https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESSetPicard.html <https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESSetPicard.html>
> 
>    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.
> 
>    Based on your email it looks like you using the direct Picard iteration algorithm. 
> 
>    With your current code you can likely easily switch to trying SNESSetPicard() and then switch to trying Newton with  SNESSetFunction(), https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESSetFunction.html <https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESSetFunction.html>  and SNESSetJacobian() https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESSetJacobian.html <https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESSetJacobian.html>
> 
>    PETSc is designed to make it as simple as possible to switch between various algorithms to help determine the best for your exact problem. 
> 
>    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.
> 
>     Barry
> 
> 
>> On Aug 22, 2020, at 7:24 AM, Matthew Knepley <knepley at gmail.com <mailto:knepley at gmail.com>> wrote:
>> 
>> On Sat, Aug 22, 2020 at 2:07 AM baikadi pranay <pranayreddy865 at gmail.com <mailto:pranayreddy865 at gmail.com>> wrote:
>> Hello,
>> 
>> 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:
>> 
>> Step 1: Solve A^(i-1) x^(i) = b^(i-1)     {i = 1 to N where convergence is reached}
>> 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}
>> 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.
>> 1) I am facing the following problem with this procedure:
>> 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.
>> 
>> 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.  
>> 
>> Any help with this problem is greatly appreciated. Please let me know if you need any further information. 
>> 
>> 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
>>     could try another solver, like Newton's method. We have a variety of nonlinear solves in the SNES class.
>> 
>> 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
>>     recommend starting with Algebraic Multigrid, like Hypre which is great at 2D Poisson. You can monitor the convergence of your linear solver using
>> 
>>       -knp_monitor_true_solution -ksp_converged_reason
>> 
>>    We want to see this information with any questions about convergence.
>> 
>>   Thanks,
>> 
>>      Matt
>>  
>> Thank you,
>> 
>> Sincerely,
>> Pranay.
>> 
>>>> 
>> 
>> -- 
>> 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://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
> 
> <norm.txt>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200822/a23c293f/attachment-0001.html>


More information about the petsc-users mailing list