tianjuxue / jax-am

Additive manufacturing simulation with JAX.
https://jax-am.readthedocs.io/en/latest/
GNU General Public License v3.0
265 stars 56 forks source link

Infinite while loop for non-linear case #28

Open SNMS95 opened 1 year ago

SNMS95 commented 1 year ago

In solver.py, the following lines

tol = 1e-6
while res_val > tol:
    dofs = linear_incremental_solver(problem, res_vec, A_fn, dofs,
                                     precond, use_petsc)
    res_vec, A_fn = newton_update_helper(dofs)
    # test_jacobi_precond(problem, jacobi_preconditioner(problem, dofs), A_fn)
    res_val = np.linalg.norm(res_vec)
    logger.debug(f"res l_2 = {res_val}")

can result in an infinite loop if there are convergence issues. This should be recified so that we break out of the loop after set number of iterations!