1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
# fmt: off
import os
import pytest
from ase.build import bulk, molecule
from ase.calculators.vasp import Vasp
@pytest.fixture()
def nacl():
atoms = bulk("NaCl", crystalstructure="rocksalt", a=4.1, cubic=True)
return atoms
@pytest.fixture()
def nh3():
atoms = molecule("NH3", vacuum=10)
return atoms
def get_suffixes(ppp_list):
suffixes = []
for p in ppp_list:
name = p.split("/")[-2]
# since the H PPs with fractional valence
# do not have an '_', we need to handle them
element = name.split("_")[0] if "." not in name else "H"
suffix = name[len(element):]
suffixes.append(suffix)
return suffixes
@pytest.mark.skipif(
"VASP_PP_PATH" not in os.environ, reason="VASP_PP_PATH not set"
)
def test_potcar_setups(nacl):
setups = {
"recommended": ["_pv", ""],
"GW": ["_sv_GW", "_GW"],
"custom": ["", "_h"],
}
calc = Vasp(setups="recommended")
calc.initialize(nacl)
assert get_suffixes(calc.ppp_list) == setups["recommended"]
calc = Vasp(setups="GW")
calc.initialize(nacl)
assert get_suffixes(calc.ppp_list) == setups["GW"]
calc = Vasp(setups={"base": "minimal", "Cl": "_h"})
calc.initialize(nacl)
assert get_suffixes(calc.ppp_list) == setups["custom"]
@pytest.mark.skipif(
"VASP_PP_PATH" not in os.environ, reason="VASP_PP_PATH not set"
)
def test_potcar_setups_fractional_valence(nh3):
setups = {"base": "recommended", 1: "H.5", 2: "H1.75", 3: "H.75"}
calc = Vasp(setups=setups, xc="PBE")
calc.initialize(nh3)
assert get_suffixes(calc.ppp_list) == [".5", "1.75", ".75", ""]
|