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 <[email protected]> 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 > > 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 > and SNESSetJacobian() > 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 <[email protected]> wrote: > > On Sat, Aug 22, 2020 at 2:07 AM baikadi pranay <[email protected]> > 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/> > > >
1 2 13124.30945 390.72893 2 2 7631.38526 83.77839 3 2 3628.89484 22.70774 4 2 2835.57475 16.24984 5 2 1118.29504 52.39736 6 2 201.33808 5.93052 7 2 152.59920 2.10226 8 2 135.95135 8.68023 9 2 162.77195 49.23192 10 2 146.73950 53.37312 11 2 110.92144 37.54294 12 2 62.47228 12.88331 13 2 59.92464 8.22509 14 2 118.13048 49.34283 15 2 74.24096 17.75077 16 2 113.74954 33.55566 17 2 57.55951 6.03360 18 2 57.31492 8.76227 19 2 59.64794 8.12482 20 2 124.94885 35.86473 21 2 83.40711 22.57516 22 2 54.06012 3.11328 23 2 53.95904 2.23418 24 2 54.11551 4.61540 25 2 101.26445 33.92082 26 2 55.20264 8.28690 27 2 52.16077 4.67542 28 2 52.46353 7.96665 29 2 50.40224 5.04300 30 2 64.34241 15.84481 31 2 97.33783 29.84633 32 2 49.88432 9.48937 33 2 48.35499 6.81308 34 2 56.02825 16.59957 35 2 44.94613 3.68454 36 2 45.31085 5.02417 37 2 46.45370 7.86148 38 2 48.35202 7.45577 39 2 159.02393 60.69175 40 2 140.68775 42.35607 41 2 63.85090 14.53674 42 2 44.69606 2.33555 43 2 46.08288 3.53488 44 2 50.53235 11.96550 45 2 102.94297 24.58494 46 2 154.02986 40.02237 47 2 47.04888 6.31340 48 2 52.00559 8.76507 49 2 147.79451 35.21966 50 2 136.99033 31.78769 51 2 50.85379 8.06005 52 2 100.42847 15.81859 53 2 562.54537 104.29386 54 2 50.06653 1.99792 55 2 55.31731 7.42284 56 2 444.96391 107.83397 57 2 84.10197 16.58726 58 2 394.20170 87.15730 59 2 70.09014 11.32516 60 2 179.69804 42.51805 61 2 53.12296 8.11494 62 2 57.90019 10.78737 63 2 185.69650 35.65920 64 2 304.99610 60.21665 65 2 50.43410 5.79141 66 2 131.31947 19.13589 67 2 459.10314 78.69138 68 2 44.83491 4.06550 69 2 54.81529 10.66011 70 2 228.15471 78.58078 71 2 101.79257 23.86673 72 2 480.58671 64.86570 73 2 279.27030 24.60649 74 2 1005.79888 103.74193 75 2 1254.44115 111.83908 76 2 657.22281 82.86932 77 2 56.37964 2.34575 78 2 59.73578 8.19196 79 2 65.20465 12.30647 80 2 63.69281 2.03619 81 2 68.67820 1.91895 82 2 79.25878 2.39632 83 2 103.49986 7.63864 84 2 414.29181 33.46999 85 2 767.31593 61.80309 86 2 523.70259 29.21437 87 2 1086.23508 40.38881 88 2 3366.14573 97.62876 89 2 2852.64799 127.31142 90 2 144.41587 1.59447 91 2 136.49564 3.41243 92 2 116.30267 13.21697 93 2 101.51899 8.39333 94 2 80.89365 4.03447 95 2 64.63812 10.91171 96 2 47.41314 4.94550 97 2 45.64313 6.54045 98 2 42.12346 1.50149 99 2 40.23948 2.23758 100 2 47.95494 6.17719 101 2 44.51530 5.69793 102 2 46.68990 11.25752 103 2 44.72751 2.94589 104 2 48.84677 11.22236 105 2 41.34298 4.57479 106 2 43.11769 1.61734 107 2 40.16490 3.53333 108 2 44.19556 12.87755 109 2 36.78342 2.58973 110 2 45.25303 7.97519 111 2 34.42245 5.97650 112 2 37.20395 11.57894 113 2 36.99031 8.18363 114 2 30.04802 4.24234 115 2 29.05911 1.93466 116 2 30.65247 5.52962 117 2 39.25919 12.60553 118 2 31.37479 6.23143 119 2 32.95480 8.71476 120 2 33.34683 9.14877 121 2 28.64018 2.23928 122 2 30.96161 6.73283 123 2 32.27548 6.66316 124 2 38.87176 13.60993 125 2 28.34918 2.28963 126 2 30.89377 7.04422 127 2 30.69550 6.49067 128 2 28.73492 2.87596 129 2 33.50048 9.39073 130 2 29.46175 3.39530 131 2 36.49282 11.61143 132 2 31.79454 6.72216 133 2 30.31759 4.56391 134 2 42.75370 14.83077 135 2 32.16942 8.62399 136 2 29.02617 4.69046 137 2 28.32183 2.90256 138 2 33.24142 9.42903 139 2 34.48308 9.68168 140 2 35.92134 10.54897 141 2 38.29803 8.11770 142 2 43.13167 14.46956 143 2 28.45875 1.64274 144 2 32.15664 3.74557 145 2 47.83797 15.08145 146 2 31.07124 4.13721 147 2 34.89141 5.90824 148 2 45.91680 14.25379 149 2 29.01324 2.38663 150 2 32.35149 7.58427 151 2 31.88630 6.05307 152 2 41.04729 8.80713 153 2 45.83311 11.50142 154 2 37.92755 5.60077 155 2 57.60880 15.66695 156 2 36.78120 3.17010 157 2 40.80703 3.75769 158 2 63.20205 16.52362 159 2 43.99623 3.38244 160 2 43.41530 3.44272 161 2 48.83611 7.69024 162 2 48.02654 4.55997 163 2 46.76826 2.01315 164 2 57.05013 6.56364 165 2 84.48355 17.53791 166 2 56.78274 5.66436 167 2 84.23674 19.89337 168 2 50.49174 3.74315 169 2 60.20342 5.85562 170 2 54.14879 4.05940 171 2 189.21591 72.41638 172 2 124.19466 50.48550 173 2 81.58599 18.93813 174 2 75.36313 9.28344 175 2 115.81593 25.39800 176 2 102.71146 24.48289 177 2 63.24702 7.47907 178 2 105.46140 25.57530 179 2 42.47659 9.02126 180 2 57.00335 9.05072 181 2 67.50768 8.50419 182 2 138.45400 29.51914 183 2 92.12635 16.93663 184 2 101.38409 21.50513 185 2 66.64650 10.78565 186 2 129.47977 34.04078 187 2 38.42077 8.04871 188 2 55.73455 10.12391 189 2 57.09683 7.17040 190 2 100.29849 12.89213 191 2 212.18613 32.00684 192 2 76.18711 9.93337 193 2 140.57416 35.17933 194 2 37.95314 8.72272 195 2 66.64926 14.64538 196 2 48.09355 9.37456 197 2 68.81235 13.34293 198 2 142.85657 38.69665 199 2 108.57613 17.95671 200 2 121.33428 32.36562 201 2 159.28792 39.30868 202 2 80.03162 15.72035 203 2 85.57498 18.27559 204 2 133.66726 33.96868 205 2 153.44562 35.79877 206 2 67.59698 16.33144 207 2 170.34290 42.72268 208 2 74.93545 16.60116 209 2 149.92604 42.60370 210 2 129.23181 22.91909 211 2 169.72095 35.29440 212 2 173.62245 39.32415 213 2 110.22268 20.48081 214 2 251.86620 48.34705 215 2 566.88933 88.52235 216 2 832.93588 97.99458 217 2 578.54941 88.60411 218 2 172.77563 29.03878 219 2 1163.93830 109.84525 220 2 897.87959 116.96158 221 2 1029.20109 115.61124 222 2 2304.85722 115.83554 223 2 2492.73911 115.17508 224 2 2841.14228 124.36860 225 2 1626.63461 122.73285 226 2 264.21654 50.97592 227 2 638.83174 101.83662 228 2 776.23451 95.92944 229 2 198.46686 38.58590 230 2 67.98385 7.54171 231 2 55.55435 1.37469 232 2 56.00709 1.78829 233 2 58.59405 1.92599 234 2 63.32928 1.55966 235 2 76.63288 3.01666 236 2 119.21013 6.71854 237 2 217.36198 20.07005 238 2 98.10471 4.08328 239 2 158.50519 18.27863 240 2 132.44524 6.77678 241 2 181.56934 27.83192 242 2 234.13469 10.53000 243 2 866.27178 72.24490 244 2 536.06810 26.51613 245 2 733.03491 34.84524 246 2 545.75933 15.97669 247 2 776.70681 34.06130 248 2 2151.03393 41.24975 249 2 1573.39566 46.18526 250 2 3339.70076 56.70606 251 2 16834.87050 140.54872 252 2 18807.89700 170.68123 253 2 972.59103 56.53599 254 2 470.87485 4.91924 255 2 463.44086 40.01454 256 2 432.69679 4.34140 257 2 421.70473 2.61176 258 2 435.00925 19.69636 259 2 626.86302 114.24779 260 2 408.66518 2.00536 261 2 420.56472 1.99646 262 2 420.08806 1.98525 263 2 399.15693 1.94706 264 2 415.12787 1.95216 265 2 407.06814 1.94565 266 2 416.15120 1.96190 267 2 411.03292 1.96881 268 2 423.88868 2.01362 269 2 422.64839 2.04560 270 2 430.37453 2.10408 271 2 436.93216 2.20171 272 2 434.55991 2.31131 273 2 369.99956 2.25757 274 2 229.52903 1.39717 275 2 168.52262 1.00000 276 2 167.21900 1.00000 277 2 167.33114 1.00000 278 2 165.29601 1.00000 279 2 166.13481 1.00000 280 2 165.18580 1.00000 281 2 163.02447 1.00000 282 2 160.83555 1.00000 283 2 163.40987 1.00000 284 2 155.88426 1.00000 285 2 156.72291 1.00000 286 2 155.05760 1.00000 287 2 152.73031 1.00001 288 2 149.54299 1.00000 289 2 151.38646 1.00000 290 2 145.49351 1.00000 291 2 144.41058 1.00001 292 2 142.85468 1.00000 293 2 139.31548 1.00002 294 2 138.50696 1.00001 295 2 135.65517 1.00001 296 2 133.26915 1.00000 297 2 131.12657 1.00000 298 2 128.02357 1.00001 299 2 125.81751 1.00001 300 2 123.18214 1.00005 301 2 119.85496 1.00002 302 2 116.95172 1.00005 303 2 113.37712 1.00002 304 2 109.87568 1.00003 305 2 105.81895 1.00004 306 2 101.29727 1.00008 307 2 96.31139 1.00017 308 2 90.21892 1.00013 309 2 82.90779 1.00014 310 2 72.32880 1.00018 311 2 58.74452 0.99881 312 2 42.49284 0.95881 313 2 23.77822 0.70753 314 2 6.72280 0.24092 315 2 0.48017 0.01811 316 2 0.00000 0.00000
