Skip to content

Commit

Permalink
mod: use ONLY PERPENDICULAR force for climb check
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Steinmetzer committed Sep 5, 2023
1 parent bc49525 commit ec5fdb7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
20 changes: 2 additions & 18 deletions pysisyphus/cos/ChainOfStates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down
15 changes: 14 additions & 1 deletion pysisyphus/helpers_pure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
5 changes: 3 additions & 2 deletions tests/test_cos/test_cos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit ec5fdb7

Please sign in to comment.