/
test_potentials.py
107 lines (95 loc) · 3.24 KB
/
test_potentials.py
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# coding: utf-8
# Copyright (c) Max-Planck-Institut für Eisenforschung GmbH - Computational Materials Design (CM) Department
# Distributed under the terms of "New BSD License", see the LICENSE file.
import os
import unittest
from pyiron.lammps.potential import LammpsPotentialFile
from pyiron.vasp.potential import VaspPotential
class TestLammpsPotentialFile(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.kim = LammpsPotentialFile()
cls.potential_path = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "../../static/lammps/potentials"
)
def test_find(self):
Fe_lst = ["Fe_C_Becquart_eam", "Fe_C_Hepburn_Ackland_eam"]
self.assertEqual(sorted(list(self.kim.find("Fe")["Name"])), sorted(Fe_lst))
AlMg_lst = ["Al_Mg_Mendelev_eam"]
self.assertEqual(sorted(list(self.kim.find({"Al", "Mg"})["Name"])), AlMg_lst)
def test_pythonic_functions(self):
self.assertEqual(
list(self.kim.find("Fe")["Name"]), list(self.kim["Fe"].list()["Name"])
)
self.assertEqual(
list(self.kim.find("Fe")["Name"]), list(self.kim.Fe.list()["Name"])
)
self.assertEqual(
list(self.kim.find({"Al", "Mg"})["Name"]),
list(self.kim["Al"]["Mg"].list()["Name"]),
)
self.assertEqual(
list(self.kim.find({"Al", "Mg"})["Name"]),
list(self.kim.Mg.Al.list()["Name"]),
)
class TestVaspPotential(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.vasp = VaspPotential()
cls.potential_path = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "../../static/vasp/potentials"
)
def test_find(self):
self.assertEqual(
list(self.vasp.pbe.find("Fe")["Name"]),
[
"Fe-gga-pbe",
"Fe_GW-gga-pbe",
"Fe_pv-gga-pbe",
"Fe_sv-gga-pbe",
"Fe_sv_GW-gga-pbe",
],
)
self.assertEqual(
sorted(list(self.vasp.pbe.find({"Fe", "C"})["Name"])),
[
"C-gga-pbe",
"C_GW-gga-pbe",
"C_GW_new-gga-pbe",
"C_h-gga-pbe",
"C_s-gga-pbe",
"Fe-gga-pbe",
"Fe_GW-gga-pbe",
"Fe_pv-gga-pbe",
"Fe_sv-gga-pbe",
"Fe_sv_GW-gga-pbe",
],
)
def test_pythonic_functions(self):
self.assertEqual(
list(self.vasp.pbe.Fe.list()["Name"]),
[
"Fe-gga-pbe",
"Fe_GW-gga-pbe",
"Fe_pv-gga-pbe",
"Fe_sv-gga-pbe",
"Fe_sv_GW-gga-pbe",
],
)
self.assertEqual(
sorted(list(self.vasp.pbe.Fe.C.list()["Name"])),
[
"C-gga-pbe",
"C_GW-gga-pbe",
"C_GW_new-gga-pbe",
"C_h-gga-pbe",
"C_s-gga-pbe",
"Fe-gga-pbe",
"Fe_GW-gga-pbe",
"Fe_pv-gga-pbe",
"Fe_sv-gga-pbe",
"Fe_sv_GW-gga-pbe",
],
)
if __name__ == "__main__":
unittest.main()