Skip to content

Commit 9d24b7e

Browse files
committed
removing the requirement of the indices argument for instantiation, now moving atoms are checked automatically
1 parent bb33d80 commit 9d24b7e

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

examples/XNO-H-XC_using_QE/saddleclimb/run_climb.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,5 @@
3939
init=read('../init/opt.traj')
4040
final=read('../final/opt.traj')
4141

42-
no_slab=18
43-
total=init.get_global_number_of_atoms()
44-
idx=list(np.arange(no_slab,total,1))
45-
46-
climber = SaddleClimb(init, final, calc, idx)
42+
climber = SaddleClimb(init, final, calc)
4743
climber.run()

examples/minimal_using_EMT/saddleclimb/run_climb.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
calc = EMT()
77
init=read('../init/opt.traj')
88
final=read('../final/opt.traj')
9-
idx = list(range(18,37))
109

11-
climber = SaddleClimb(init, final, calc, idx)
10+
climber = SaddleClimb(init, final, calc)
1211
climber.run()

saddleclimb/saddleclimb.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(
1616
atoms_initial: Atoms,
1717
atoms_final: Atoms,
1818
calculator: Calculator,
19-
indices: list,
19+
indices: list = None,
2020
fmax: float = 0.01,
2121
maxstepsize: float = 0.2,
2222
delta0: float = 0.05,
@@ -27,13 +27,23 @@ def __init__(
2727
self.atoms_initial = atoms_initial
2828
self.atoms_final = atoms_final
2929
self.indices = indices
30-
self.hessian = 100 * np.eye(3*len(self.indices))
3130
self.calculator = calculator
3231
self.fmax = fmax
3332
self.maxstepsize = maxstepsize
3433
self.delta = delta0
3534
self.logfile = logfile
3635
self.trajfile = trajfile
36+
if not self.indices:
37+
self._get_moving_atoms()
38+
self.hessian = 100 * np.eye(3*len(self.indices))
39+
40+
def _get_moving_atoms(self):
41+
dpos = self.atoms_final.positions - self.atoms_initial.positions
42+
idx = []
43+
for i in range(dpos.shape[0]):
44+
if LA.norm(dpos[i, :]) > 1e-6:
45+
idx.append(i)
46+
self.indices = idx.copy()
3747

3848
def _get_step(self, B, g, pos_1D):
3949
dxi = self._pos_i_1D - pos_1D

0 commit comments

Comments
 (0)