# The error in SOR algorithm suddenly falls to zero when it reaches 1e-7 range

I am solving the Poisson equation for heterojunction using Fortran90. I use the SOR algorithm to arrive at the potential profile.

1. I see the weird behavior where the error (the difference between the $$n$$-th and $$(n-1)$$-th iteration of the solution) abruptly falls to zero when the error reaches 1e-7 range. Is this behavior expected?

2. Also, the solution is depending weakly on the choice of the mesh, e.g. potential profiles are off by about 0.02 eV when I choose a coarser mesh. Is this behavior to be expected?

Let me know if I need to provide any additional details.

• You need to give us more information. What is the matrix size for example? Or are you declaring your variables as floats or doubles? SOR solver is not a so-called optimal solver for your problem - number of iterations to convergence may increase as you refine the mesh. – Abdullah Ali Sivas Aug 8 '20 at 6:21
• Is your error measure a relative or absolute difference between iterates? Are you using single or double precision? – Brian Borchers Aug 8 '20 at 14:09
• @AbdullahAliSivas The matrix is about 40000-by-40000. And as you said, the size of the matrix varies with the mesh. All the variables I declare are using selected_real_kind(10,30), which gives a double precision. – prananna Aug 9 '20 at 8:05
• @BrianBorchers It is the absolute difference between the iterates. I take the maximum of the absolute value of the matrix resulting from the difference between the two iterates and I use this value to compare with the tolerance in the stopping criteria. – prananna Aug 9 '20 at 8:09
• Are you sure that all of your variables are double precision? What your reporting looks as though the method has converged to single precision and can't make any further progress. What are the computed residuals at the end? – Brian Borchers Aug 10 '20 at 20:05