Skip to content

Commit

Permalink
Use isapprox for calculating convergence
Browse files Browse the repository at this point in the history
  • Loading branch information
iagoleal committed Jan 9, 2025
1 parent c2739fd commit b56a6ee
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ mutable struct ConvergenceObserver <: AbstractObserver
end

function ITensorMPS.checkdone!(o::ConvergenceObserver; energy, sweep, kwargs...)
abs_err = abs(energy - o.previous_energy)
rel_err = abs_err / abs(energy)
converged = isapprox(energy, o.previous_energy; atol = o.atol, rtol = o.rtol)
o.previous_energy = energy

return abs_err < o.atol || rel_err < o.rtol
return converged
end


Expand Down

0 comments on commit b56a6ee

Please sign in to comment.