From 133e03f23192c0657cdaf42b69443348a8a9b080 Mon Sep 17 00:00:00 2001 From: Igor Kowalec <58031188+ikowalec@users.noreply.github.com> Date: Mon, 17 Jun 2024 11:51:56 +0100 Subject: [PATCH] Always check stress if present in calc.results --- carmm/analyse/forces.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/carmm/analyse/forces.py b/carmm/analyse/forces.py index 424243d5..acf57e3c 100644 --- a/carmm/analyse/forces.py +++ b/carmm/analyse/forces.py @@ -15,16 +15,20 @@ def is_converged(atoms, fmax=0.01): converged = False if atoms.calc: - if not atoms.calc.calculation_required(atoms, ['forces']): - f = atoms.get_forces() - + if 'forces' in atoms.calc.results: + if not atoms.calc.calculation_required(atoms, ['forces']): + f = atoms.get_forces() if np.amax([np.linalg.norm(f[x]) for x in range(len(atoms))]) <= fmax: converged = True + else: + converged = False - elif not atoms.calc.calculation_required(atoms, ['stress']): - s = atoms.get_stress() - + if 'stress' in atoms.calc.results: + if not atoms.calc.calculation_required(atoms, ['stress']): + s = atoms.get_stress() if np.amax([np.linalg.norm(s[x]) for x in range(len(atoms))]) <= fmax: converged = True + else: + converged = False return converged