Retrieve the number of Newton iterations per loading step

Hello everyone,

I am working on a contact problem , and at each loading step, I would like to retrieve the number of Newton iterations required for convergence.

Currently, I solve my problem using:

model.solve()

However, I haven’t found a direct way to get this iteration count. I have tried:

model.get_iter()
model.get("iter")

but without success (these commands are not recognized).

Is there any way to obtain the number of Newton iterations performed by model.solve()?

Thank you in advance for your help,

read the documentation

in general, the different solvers in model.solve are a bit obscure, I recommend writing your own Newton loop:

  for j in range(newton_iter):
    md.assembly("build_all")
    dx = gf.linsolve_mumps(md.tangent_matrix(), md.rhs()).flatten()
    md.to_variables(md.from_variables()+dx)
    md.assembly("build_rhs")
    restot = np.linalg.norm(md.rhs())
    if np.isnan(restot) or restot < eps:
      break

Thank you for your help. I completely missed that part of the documentation, sorry about that.
Regarding the custom Newton implementation, I’ve already started working on it. I’ll definitely get back to you if I have any questions.
Thanks again!