Skip to content

Commit

Permalink
whoops thats why
Browse files Browse the repository at this point in the history
  • Loading branch information
esoteric-ephemera committed Nov 15, 2024
1 parent 1063547 commit f3ac76b
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions tests/vasp/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import pytest
from monty.os import cd
from monty.tempfile import ScratchDir
from pymatgen.core import Structure
from pymatgen.io.vasp import Incar, Kpoints, Poscar
from pymatgen.io.vasp.sets import MPRelaxSet

from custodian.vasp.jobs import GenerateVaspInputJob, VaspJob, VaspNEBJob, _gamma_point_only_check
from tests.conftest import TEST_FILES
Expand Down Expand Up @@ -183,32 +185,32 @@ def test_run(self) -> None:
kpoints = Kpoints.from_file("KPOINTS")
assert str(kpoints.style) == "Reciprocal"


class TestAutoGamma:
"""
Test that a VASP job can automatically detect when only 1 k-point at GAMMA is used.
"""
from pymatgen.core import Structure
from pymatgen.io.vasp.sets import MPRelaxSet

# Isolated atom in PBC
structure = Structure(
lattice = [[15 + 0.1*i if i == j else 0. for j in range(3)] for i in range(3)],
species = ["Na"],
coords = [[0.5 for _ in range(3)]]
)

vis = MPRelaxSet(structure=structure)
assert vis.kpoints.kpts == [(1, 1, 1)]
assert vis.kpoints.style.name == "Gamma"
assert _gamma_point_only_check(vis.get_input_set())

# no longer Gamma-centered
vis = MPRelaxSet(structure=structure,user_kpoints_settings=Kpoints(kpts_shift=(0.1,0.,0.)))
assert not _gamma_point_only_check(vis.get_input_set())

# have to increase KSPACING or this will result in a non 1 x 1 x 1 grid
vis = MPRelaxSet(structure=structure,user_incar_settings={"KSPACING": 0.5})
assert _gamma_point_only_check(vis.get_input_set())

vis = MPRelaxSet(structure=structure,user_incar_settings={"KSPACING": 0.5, "KGAMMA": False})
assert not _gamma_point_only_check(vis.get_input_set())

def test_gamma_checks(self) -> None:
# Isolated atom in PBC
structure = Structure(
lattice=[[15 + 0.1 * i if i == j else 0.0 for j in range(3)] for i in range(3)],
species=["Na"],
coords=[[0.5 for _ in range(3)]],
)

vis = MPRelaxSet(structure=structure)
assert vis.kpoints.kpts == [(1, 1, 1)]
assert vis.kpoints.style.name == "Gamma"
assert _gamma_point_only_check(vis.get_input_set())

# no longer Gamma-centered
vis = MPRelaxSet(structure=structure, user_kpoints_settings=Kpoints(kpts_shift=(0.1, 0.0, 0.0)))
assert not _gamma_point_only_check(vis.get_input_set())

# have to increase KSPACING or this will result in a non 1 x 1 x 1 grid
vis = MPRelaxSet(structure=structure, user_incar_settings={"KSPACING": 0.5})
assert _gamma_point_only_check(vis.get_input_set())

vis = MPRelaxSet(structure=structure, user_incar_settings={"KSPACING": 0.5, "KGAMMA": False})
assert not _gamma_point_only_check(vis.get_input_set())

0 comments on commit f3ac76b

Please sign in to comment.