Skip to content

Commit fdb05a7

Browse files
authored
Don't use set_calculator for atoms object (#37)
1 parent d66468b commit fdb05a7

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

xtb/ase/calculator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
>>> from ase.build import molecule
3434
>>> from xtb.ase.calculator import XTB
3535
>>> atoms = molecule('H2O')
36-
>>> atoms.set_calculator(XTB(method="GFN2-xTB"))
36+
>>> atoms.calc = XTB(method="GFN2-xTB")
3737
>>> atoms.get_potential_energy()
3838
-137.9677758730299
3939
>>> atoms.get_forces()

xtb/ase/test_calculator.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ def test_gfn1_xtb_3d():
199199
-0.37178059, -0.37127074,
200200
])
201201

202-
calc = XTB(method="GFN1-xTB")
203-
atoms.set_calculator(calc)
202+
atoms.calc = XTB(method="GFN1-xTB")
204203
assert atoms.pbc.all()
205204

206205
assert approx(atoms.get_potential_energy(), abs=thr) == -1256.768167202048
@@ -233,7 +232,7 @@ def test_gfn2_xtb_3d():
233232
)
234233

235234
calc = XTB(method="GFN2-xTB")
236-
atoms.set_calculator(calc)
235+
atoms.calc = calc
237236

238237
with raises(CalculationFailed):
239238
atoms.get_potential_energy()

xtb/ase/test_optimize.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ def test_gfn2xtb_lbfgs():
100100
]),
101101
)
102102

103-
calc = XTB(method="GFN2-xTB", solvent="water", accuracy=0.1)
104-
atoms.set_calculator(calc)
103+
atoms.calc = XTB(method="GFN2-xTB", solvent="water", accuracy=0.1)
105104
opt = LBFGS(atoms)
106105
opt.run(fmax=0.1)
107106

@@ -142,8 +141,7 @@ def test_gfn2xtb_velocityverlet():
142141
]),
143142
)
144143

145-
calc = XTB(method="GFN2-xTB", cache_api=False)
146-
atoms.set_calculator(calc)
144+
atoms.calc = XTB(method="GFN2-xTB", cache_api=False)
147145

148146
dyn = VelocityVerlet(atoms, timestep=1.0*fs)
149147
dyn.run(20)

0 commit comments

Comments
 (0)