This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

KrylovSolver relative tolerance

0 votes

I figured that if I set up a KrylovSolver like:

solver = KrylovSolver("gmres", "ml_amg")
solver.parameters["relative_tolerance"] = 0.75
solver.parameters["maximum_iterations"] = 200
solver.parameters["monitor_convergence"] = True

however, the relative tolerance is below 0.75 but the solver didn't stop ... (yes, I know that 0.75 is probably way too high).

194 KSP preconditioned resid norm 5.467875874924e+01 true resid norm 4.616074188122e-03 ||r(i)||/||b|| 6.662113600126e-01
195 KSP preconditioned resid norm 5.467875739536e+01 true resid norm 4.616078004382e-03 ||r(i)||/||b|| 6.662119107914e-01
196 KSP preconditioned resid norm 5.467875604046e+01 true resid norm 4.616077635943e-03 ||r(i)||/||b|| 6.662118576167e-01
197 KSP preconditioned resid norm 5.467875541936e+01 true resid norm 4.616092554551e-03 ||r(i)||/||b|| 6.662140107334e-01
198 KSP preconditioned resid norm 5.467875537716e+01 true resid norm 4.616093612623e-03 ||r(i)||/||b|| 6.662141634388e-01
199 KSP preconditioned resid norm 5.467875439581e+01 true resid norm 4.616148455643e-03 ||r(i)||/||b|| 6.662220786155e-01
200 KSP preconditioned resid norm 5.467875232867e+01 true resid norm 4.616110502291e-03 ||r(i)||/||b|| 6.662166010272e-01
asked May 12, 2014 by timm FEniCS User (2,100 points)

1 Answer

0 votes
 
Best answer

It's PETSc I take it? I haven't used the KrylovSolver object, but here are some suggestions:
Add the line:

PETScOptions.set('ksp_rtol', '.75')

To the beginning of the file. Sometimes what's in the parameters doesn't seem to get transferred over to the solver.
You can also try the "PETScKrylovSolver", which I use and with inputted tolerances...
BTW: Are you sure you're checking the correct 'norm'? i.e.: the true norm vs the preconditioned norm? From your output, they are quite different.

answered May 14, 2014 by mwelland FEniCS User (8,410 points)
selected May 14, 2014 by timm

Yes, it is PETSc ... I should probably read the documentation more carefully. I think that I just copied someone's code and liked how the option looked. Thanks!

...