I am trying to compare the computational cost of several methods of solving a nonlinear partial differential equation. One of the methods uses scipy.optimize.newton_krylov
. The other methods use scipy.sparese.linalg.lgmres
.
My first thought was to count the number of iterations of newton_krylov
using the 'callback'
keyword. This worked, to a point. The counter that I set up counts the number of iterations made by the newton_krylov
solver.
I would also like to count the number of steps it takes in each (Newton) iteration to solve the linear system. I thought that I could use a similar counter and try using a keyword like 'inner_callback'
, but that gave the number of iterations the newton_krylov
solver used rather than the number of steps to solve the inner linear system.
It is possible that I don't understand how newton_krylov
was implemented and that it is impossible to separate the the two types of iterations (Newton steps vs lgmres
steps) but it would be great if there was a way.
I tried posting this on scicomp.stackexchange, but I didn't get any answers. I think that the question might be too specific to Scipy to get a good answer there, so I hope that someone here can help me. Thank you for your help!