diff --git a/pysisyphus/cos/ChainOfStates.py b/pysisyphus/cos/ChainOfStates.py index 4adbb100b..4a4f60d50 100644 --- a/pysisyphus/cos/ChainOfStates.py +++ b/pysisyphus/cos/ChainOfStates.py @@ -13,7 +13,7 @@ from scipy.interpolate import interp1d, splprep, splev from pysisyphus.helpers import align_coords, get_coords_diffs -from pysisyphus.helpers_pure import hash_arr +from pysisyphus.helpers_pure import hash_arr, rms from pysisyphus.modefollow import geom_lanczos @@ -713,22 +713,6 @@ def prepare_opt_cycle(self, last_coords, last_energies, last_forces): reset_flag = not already_climbing and self.started_climbing return reset_flag, messages - def rms(self, arr): - """Root mean square - - Returns the root mean square of the given array. - - Parameters - ---------- - arr : iterable of numbers - - Returns - ------- - rms : float - Root mean square of the given array. - """ - return np.sqrt(np.mean(np.square(arr))) - def compare_image_rms_forces(self, ref_rms): """Compare rms(forces) value of an image against a reference value. @@ -740,7 +724,7 @@ def compare_image_rms_forces(self, ref_rms): RMS force (rms_force) or from a multiple of the RMS force convergence threshold (rms_multiple, default). """ - rms_forces = self.rms(self.forces_list[-1]) + rms_forces = rms(self.perpendicular_forces) # Only start climbing when the COS is fully grown. This # attribute may not be defined in all subclasses, so it # defaults to True here. diff --git a/pysisyphus/helpers_pure.py b/pysisyphus/helpers_pure.py index 656f59fed..6eaccb312 100644 --- a/pysisyphus/helpers_pure.py +++ b/pysisyphus/helpers_pure.py @@ -658,5 +658,18 @@ def kill_dir(path): path.rmdir() -def rms(arr): +def rms(arr: np.ndarray) -> float: + """Root mean square + + Returns the root mean square of the given array. + + Parameters + ---------- + arr : iterable of numbers + + Returns + ------- + rms : float + Root mean square of the given array. + """ return np.sqrt(np.mean(arr**2)) diff --git a/tests/test_cos/test_cos.py b/tests/test_cos/test_cos.py index 679a40dec..d8b78ce2c 100644 --- a/tests/test_cos/test_cos.py +++ b/tests/test_cos/test_cos.py @@ -237,7 +237,7 @@ def test_stiff_neb_nfk(): # plt.show() -@pytest.mark.parametrize("climb, ref_cycles", ((True, 209), ("one", 109), (False, 120))) +@pytest.mark.parametrize("climb, ref_cycles", ((True, 217), ("one", 101), (False, 120))) def test_neb_climb(climb, ref_cycles): geoms = get_geoms() @@ -273,8 +273,9 @@ def test_cos_image_ts_opt(): cos_kwargs = { "k_min": 0.01, "climb": "one", + "climb_rms": 0.5, "ts_opt": True, - "ts_opt_rms": 0.0045, + "ts_opt_rms": 0.005, } cos = NEB(images, **cos_kwargs)