Skip to content

Commit

Permalink
separate tests for basis and potential
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielYang59 committed Sep 30, 2024
1 parent 73ddbd6 commit 8ef9e96
Showing 1 changed file with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions tests/io/cp2k/test_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,7 @@
"""


class TestBasisAndPotential(PymatgenTest):
all_hydrogen_str = """
H ALLELECTRON ALL
1 0 0
0.20000000 0
"""

pot_hydrogen_str = """
H GTH-PBE-q1 GTH-PBE
1
0.20000000 2 -4.17890044 0.72446331
0
"""

class TestBasis(PymatgenTest):
def test_basis_info(self):
# Ensure basis metadata can be read from string
basis_info = BasisInfo.from_str("cc-pc-DZVP-MOLOPT-q1-SCAN")
Expand All @@ -76,18 +63,6 @@ def test_basis_info(self):
assert basis_info3.polarization == 1
assert basis_info3.contracted, True

def test_potential_info(self):
# Ensure potential metadata can be read from string
pot_info = PotentialInfo.from_str("GTH-PBE-q1-NLCC")
assert pot_info.potential_type == "GTH"
assert pot_info.xc == "PBE"
assert pot_info.nlcc

# Ensure one-way soft-matching works
pot_info2 = PotentialInfo.from_str("GTH-q1-NLCC")
assert pot_info2.softmatch(pot_info)
assert not pot_info.softmatch(pot_info2)

def test_basis(self):
# Ensure cp2k formatted string can be read for data correctly
mol_opt = GaussianTypeOrbitalBasisSet.from_str(BASIS_FILE_STR)
Expand Down Expand Up @@ -116,6 +91,33 @@ def test_basis(self):
assert_array_equal(kw.values, ["AUX_FIT", "SZV-MOLOPT-GTH"])
mol_opt.info.admm = False


class TestPotential(PymatgenTest):
all_hydrogen_str = """
H ALLELECTRON ALL
1 0 0
0.20000000 0
"""

pot_hydrogen_str = """
H GTH-PBE-q1 GTH-PBE
1
0.20000000 2 -4.17890044 0.72446331
0
"""

def test_potential_info(self):
# Ensure potential metadata can be read from string
pot_info = PotentialInfo.from_str("GTH-PBE-q1-NLCC")
assert pot_info.potential_type == "GTH"
assert pot_info.xc == "PBE"
assert pot_info.nlcc

# Ensure one-way soft-matching works
pot_info2 = PotentialInfo.from_str("GTH-q1-NLCC")
assert pot_info2.softmatch(pot_info)
assert not pot_info.softmatch(pot_info2)

def test_potentials(self):
# Ensure cp2k formatted string can be read for data correctly
h_all_elec = GthPotential.from_str(self.all_hydrogen_str)
Expand Down

0 comments on commit 8ef9e96

Please sign in to comment.