Skip to content

Commit

Permalink
test for Vasp multi-calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
bernstei committed Dec 19, 2023
1 parent cb4b743 commit 89dff5c
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/calculators/test_vasp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pathlib import Path
import shutil
import glob
import os
import copy
Expand Down Expand Up @@ -328,3 +329,36 @@ def test_vasp_per_configuration(tmp_path):

assert ats[0].info['TEST_energy'] > ats[1].info['TEST_energy'] > ats[2].info['TEST_energy']
# ase.io.write(sys.stdout, list(configs_eval), format='extxyz')


def test_vasp_multi_calc(tmp_path):
ase.io.write(tmp_path / 'vasp_in.xyz', Atoms('Si', cell=(2, 2, 2), pbc=[True] * 3), format='extxyz')

configs_eval = generic.calculate(
inputs=ConfigSet(tmp_path / 'vasp_in.xyz'),
outputs=OutputSpec("vasp_out_ref.xyz", file_root=tmp_path),
calculator=Vasp(workdir=tmp_path, encut=200, kspacing=1.0, pp=os.environ['PYTEST_VASP_POTCAR_DIR'],
keep_files=True),
output_prefix='TEST_')
e_GGA = list(configs_eval)[0].info["TEST_energy"]
run_dir = list(tmp_path.glob('run_VASP_*'))[0]
with open(run_dir / "OUTCAR") as fin:
n_loop_GGA = sum(["LOOP" in l for l in fin])
shutil.rmtree(run_dir)
print("GGA E", e_GGA, "loops", n_loop_GGA)

configs_eval = generic.calculate(
inputs=ConfigSet(tmp_path / 'vasp_in.xyz'),
outputs=OutputSpec('vasp_out.regular.xyz', file_root=tmp_path),
calculator=Vasp(workdir=tmp_path, encut=200, kspacing=1.0, pp=os.environ['PYTEST_VASP_POTCAR_DIR'],
# keep_files=True, gga='PZ'),
keep_files=True, multi_calculation_kwargs=[{'lwave': True, 'gga': 'PZ'}, {}]),
output_prefix='TEST_')
e_test = list(configs_eval)[0].info["TEST_energy"]
run_dir = list(tmp_path.glob('run_VASP_*'))[0]
with open(run_dir / "OUTCAR") as fin:
n_loop_test = sum(["LOOP" in l for l in fin])
print("LDA + GGA E", e_test, "loops", n_loop_test)

assert np.abs(e_GGA - e_test) < 1.0e-4
assert n_loop_test < n_loop_GGA - 2

0 comments on commit 89dff5c

Please sign in to comment.