Skip to content

Commit

Permalink
bugfix: test adapted to new optimizer
Browse files Browse the repository at this point in the history
  • Loading branch information
galjos committed Aug 1, 2024
1 parent d03ade4 commit 68968dc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
32 changes: 18 additions & 14 deletions tests/calculator/test_dftbplus.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ class TestDftbplus:

# Test the DFTB+ calculator
def test_dftb(self):
assert os.system("which dftb+ > /dev/null") == 0, "DFTB+ is not installed."
assert os.system("which modes > /dev/null") == 0, "Modes is not installed."
assert os.system(
"which dftb+ > /dev/null") == 0, "DFTB+ is not installed."
assert os.system(
"which modes > /dev/null") == 0, "Modes is not installed."

# Test the Geoopt class
@pytest.mark.parametrize("example_dir", ["calculator"])
Expand Down Expand Up @@ -57,9 +59,12 @@ def test_hessian(self, test_with_data_dir):

# create an instance of the Hessian class
optimizer = Geoopt(atoms, charge=0, **dftb_3ob_parameters)
hessian = Hessian(
optimizer.read(), charge=0, **dftb_3ob_parameters, delta=0.0005
)
atoms = optimizer.read()
print(atoms.get_positions())
hessian = Hessian(optimizer.read(),
charge=0,
**dftb_3ob_parameters,
delta=0.0005)

assert hessian.atoms == optimizer.read()
assert hessian.label == "second_derivative"
Expand All @@ -79,9 +84,10 @@ def test_modes(self, test_with_data_dir):

# create an instance of the Modes class
optimizer = Geoopt(atoms, charge=0, **dftb_3ob_parameters)
hessian = Hessian(
optimizer.read(), charge=0, **dftb_3ob_parameters, delta=0.0005
)
hessian = Hessian(optimizer.read(),
charge=0,
**dftb_3ob_parameters,
delta=0.0005)

assert os.path.exists("hessian.out")
assert os.path.exists("geo_opt.gen")
Expand All @@ -99,16 +105,14 @@ def test_modes(self, test_with_data_dir):

assert np.allclose(
wave_numbers[6:],
[
1.46185721e03,
3.60476561e03,
3.87736051e03,
],
[1462.29964226, 3604.10862879, 3876.6277397],
atol=1e-5,
)

@pytest.mark.parametrize("example_dir", ["calculator"])
def test_dftbplus_thermo(self, test_with_data_dir):
atoms = ase_io.read("water.xyz")
thermo = dftbplus_thermo(atoms, **dftb_3ob_parameters, delta=0.0005)
assert np.allclose(thermo.total_EeGtot(),-4.063049633277606 , atol=1e-5) # old value -4.064982703661
assert np.allclose(thermo.total_EeGtot(),
-4.0595598803365744,
atol=1e-5)
6 changes: 3 additions & 3 deletions tests/data/calculator/water.xyz
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
3
Properties=species:S:1:pos:R:3 pbc="F F F"
O -0.00566600 0.40130200 -0.00000000
H 0.79261600 -0.19855100 0.00000000
H -0.78695000 -0.20275100 -0.00000000
O -0.00566600 0.40130200 -1.00000000
H 0.79261600 -0.19855100 -1.00000000
H -0.78695000 -0.20275100 -1.00000000

0 comments on commit 68968dc

Please sign in to comment.