Skip to content

Commit e9d5db9

Browse files
Add unit tests for autogen and graphgen
1 parent 815f0fe commit e9d5db9

File tree

1 file changed

+378
-0
lines changed

1 file changed

+378
-0
lines changed

tests/fragmentation_test.py

Lines changed: 378 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,378 @@
1+
"""
2+
Tests for the fragmentation modules.
3+
4+
Author(s): Shaun Weatherly
5+
"""
6+
7+
import os
8+
import unittest
9+
10+
from pyscf import gto, scf
11+
12+
from quemb.molbe import fragpart
13+
14+
15+
class TestBE_Fragmentation(unittest.TestCase):
16+
def test_autogen_h_linear_be1(self):
17+
mol = gto.M()
18+
mol.atom = [["H", (0.0, 0.0, i)] for i in range(8)]
19+
mol.basis = "sto-3g"
20+
mol.charge = 0.0
21+
mol.spin = 0.0
22+
mol.build()
23+
24+
mf = scf.RHF(mol)
25+
26+
target = {
27+
"fsites": [[0], [1], [2], [3], [4], [5], [6], [7]],
28+
"edge": [],
29+
"center": [],
30+
"centerf_idx": [[0], [0], [0], [0], [0], [0], [0], [0]],
31+
"ebe_weight": [
32+
[1.0, [0]],
33+
[1.0, [0]],
34+
[1.0, [0]],
35+
[1.0, [0]],
36+
[1.0, [0]],
37+
[1.0, [0]],
38+
[1.0, [0]],
39+
[1.0, [0]]
40+
],
41+
}
42+
43+
self.run_test(
44+
mf,
45+
"be1",
46+
"autogen_h_linear_be1",
47+
"autogen",
48+
target,
49+
)
50+
51+
def test_autogen_h_linear_be2(self):
52+
mol = gto.M()
53+
mol.atom = [["H", (0.0, 0.0, i)] for i in range(8)]
54+
mol.basis = "sto-3g"
55+
mol.charge = 0.0
56+
mol.spin = 0.0
57+
mol.build()
58+
59+
mf = scf.RHF(mol)
60+
61+
target = {
62+
"fsites": [
63+
[1, 0, 2], [2, 1, 3], [3, 2, 4], [4, 3, 5], [5, 4, 6], [6, 7, 5]
64+
],
65+
"edge": [
66+
[[2]], [[1], [3]], [[2], [4]], [[3], [5]], [[4], [6]], [[5]]
67+
],
68+
"center": [[1], [0, 2], [1, 3], [2, 4], [3, 5], [4]],
69+
"centerf_idx": [[0], [0], [0], [0], [0], [0]],
70+
"ebe_weight": [
71+
[1.0, [0, 1]],
72+
[1.0, [0]],
73+
[1.0, [0]],
74+
[1.0, [0]],
75+
[1.0, [0]],
76+
[1.0, [0, 1]]
77+
],
78+
}
79+
80+
self.run_test(
81+
mf,
82+
"be2",
83+
"autogen_h_linear_be2",
84+
"autogen",
85+
target,
86+
)
87+
88+
def test_autogen_h_linear_be3(self):
89+
mol = gto.M()
90+
mol.atom = [["H", (0.0, 0.0, i)] for i in range(8)]
91+
mol.basis = "sto-3g"
92+
mol.charge = 0.0
93+
mol.spin = 0.0
94+
mol.build()
95+
96+
mf = scf.RHF(mol)
97+
98+
target = {
99+
"fsites": [
100+
[2, 0, 1, 3, 4], [3, 2, 1, 4, 5], [4, 3, 2, 5, 6], [5, 6, 7, 4, 3]
101+
],
102+
"edge": [
103+
[[3], [4]], [[2], [1], [4], [5]], [[3], [2], [5], [6]], [[4], [3]]
104+
],
105+
"center": [[1, 2], [0, 0, 2, 3], [1, 0, 3, 3], [2, 1]],
106+
"centerf_idx": [[0], [0], [0], [0]],
107+
"ebe_weight": [
108+
[1.0, [0, 1, 2]], [1.0, [0]], [1.0, [0]], [1.0, [0, 1, 2]]
109+
],
110+
}
111+
112+
self.run_test(
113+
mf,
114+
"be3",
115+
"autogen_h_linear_be3",
116+
"autogen",
117+
target,
118+
)
119+
120+
def test_autogen_octane_be1(self):
121+
mol = gto.M()
122+
mol.atom = os.path.join(os.path.dirname(__file__), "xyz/octane.xyz")
123+
mol.basis = "sto-3g"
124+
mol.charge = 0.0
125+
mol.spin = 0.0
126+
mol.build()
127+
128+
mf = scf.RHF(mol)
129+
130+
target = {
131+
"fsites": [[0, 1, 2, 3, 4, 11, 13], [5, 6, 7, 8, 9, 10, 12], [14, 15, 16, 17, 18, 24, 26], [19, 20, 21, 22, 23, 25, 27], [28, 29, 30, 31, 32, 38, 40], [33, 34, 35, 36, 37, 39, 41], [42, 43, 44, 45, 46, 52, 54, 57], [47, 48, 49, 50, 51, 53, 55, 56]],
132+
"edge": [],
133+
"center": [],
134+
"centerf_idx": [[0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7]],
135+
"ebe_weight": [[1.0, [0, 1, 2, 3, 4, 5, 6]], [1.0, [0, 1, 2, 3, 4, 5, 6]], [1.0, [0, 1, 2, 3, 4, 5, 6]], [1.0, [0, 1, 2, 3, 4, 5, 6]], [1.0, [0, 1, 2, 3, 4, 5, 6]], [1.0, [0, 1, 2, 3, 4, 5, 6]], [1.0, [0, 1, 2, 3, 4, 5, 6, 7]], [1.0, [0, 1, 2, 3, 4, 5, 6, 7]]],
136+
}
137+
138+
self.run_test(
139+
mf,
140+
"be1",
141+
"autogen_octane_be1",
142+
"autogen",
143+
target,
144+
)
145+
146+
def test_autogen_octane_be2(self):
147+
mol = gto.M()
148+
mol.atom = os.path.join(os.path.dirname(__file__), "xyz/octane.xyz")
149+
mol.basis = "sto-3g"
150+
mol.charge = 0.0
151+
mol.spin = 0.0
152+
mol.build()
153+
154+
mf = scf.RHF(mol)
155+
156+
target = {
157+
"fsites": [[0, 1, 2, 3, 4, 11, 13, 5, 6, 7, 8, 9, 10, 12, 19, 20, 21, 22, 23, 25, 27], [5, 6, 7, 8, 9, 10, 12, 0, 1, 2, 3, 4, 11, 13, 14, 15, 16, 17, 18, 24, 26], [14, 15, 16, 17, 18, 24, 26, 5, 6, 7, 8, 9, 10, 12, 28, 29, 30, 31, 32, 38, 40], [19, 20, 21, 22, 23, 25, 27, 0, 1, 2, 3, 4, 11, 13, 33, 34, 35, 36, 37, 39, 41], [28, 29, 30, 31, 32, 38, 40, 42, 43, 44, 45, 46, 52, 54, 57, 14, 15, 16, 17, 18, 24, 26], [33, 34, 35, 36, 37, 39, 41, 47, 48, 49, 50, 51, 53, 55, 56, 19, 20, 21, 22, 23, 25, 27]],
158+
"edge": [[[5, 6, 7, 8, 9, 10, 12], [19, 20, 21, 22, 23, 25, 27]], [[0, 1, 2, 3, 4, 11, 13], [14, 15, 16, 17, 18, 24, 26]], [[5, 6, 7, 8, 9, 10, 12], [28, 29, 30, 31, 32, 38, 40]], [[0, 1, 2, 3, 4, 11, 13], [33, 34, 35, 36, 37, 39, 41]], [[14, 15, 16, 17, 18, 24, 26]], [[19, 20, 21, 22, 23, 25, 27]]],
159+
"center": [[1, 3], [0, 2], [1, 4], [0, 5], [2], [3]],
160+
"centerf_idx": [[0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6]],
161+
"ebe_weight": [[1.0, [0, 1, 2, 3, 4, 5, 6]], [1.0, [0, 1, 2, 3, 4, 5, 6]], [1.0, [0, 1, 2, 3, 4, 5, 6]], [1.0, [0, 1, 2, 3, 4, 5, 6]], [1.0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]], [1.0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]]],
162+
}
163+
164+
self.run_test(
165+
mf,
166+
"be2",
167+
"autogen_octane_be2",
168+
"autogen",
169+
target,
170+
)
171+
172+
def test_autogen_octane_be3(self):
173+
mol = gto.M()
174+
mol.atom = os.path.join(os.path.dirname(__file__), "xyz/octane.xyz")
175+
mol.basis = "sto-3g"
176+
mol.charge = 0.0
177+
mol.spin = 0.0
178+
mol.build()
179+
180+
mf = scf.RHF(mol)
181+
182+
target = {
183+
"fsites": [[0, 1, 2, 3, 4, 11, 13, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 17, 18, 24, 26, 19, 20, 21, 22, 23, 25, 27, 33, 34, 35, 36, 37, 39, 41], [5, 6, 7, 8, 9, 10, 12, 0, 1, 2, 3, 4, 11, 13, 19, 20, 21, 22, 23, 25, 27, 14, 15, 16, 17, 18, 24, 26, 28, 29, 30, 31, 32, 38, 40], [14, 15, 16, 17, 18, 24, 26, 28, 29, 30, 31, 32, 38, 40, 42, 43, 44, 45, 46, 52, 54, 57, 5, 6, 7, 8, 9, 10, 12, 0, 1, 2, 3, 4, 11, 13], [19, 20, 21, 22, 23, 25, 27, 33, 34, 35, 36, 37, 39, 41, 47, 48, 49, 50, 51, 53, 55, 56, 0, 1, 2, 3, 4, 11, 13, 5, 6, 7, 8, 9, 10, 12]],
184+
"edge": [[[5, 6, 7, 8, 9, 10, 12], [14, 15, 16, 17, 18, 24, 26], [19, 20, 21, 22, 23, 25, 27], [33, 34, 35, 36, 37, 39, 41]], [[0, 1, 2, 3, 4, 11, 13], [19, 20, 21, 22, 23, 25, 27], [14, 15, 16, 17, 18, 24, 26], [28, 29, 30, 31, 32, 38, 40]], [[5, 6, 7, 8, 9, 10, 12], [0, 1, 2, 3, 4, 11, 13]], [[0, 1, 2, 3, 4, 11, 13], [5, 6, 7, 8, 9, 10, 12]]],
185+
"center": [[1, 2, 3, 3], [0, 3, 2, 2], [1, 0], [0, 1]],
186+
"centerf_idx": [[0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6]],
187+
"ebe_weight": [[1.0, [0, 1, 2, 3, 4, 5, 6]], [1.0, [0, 1, 2, 3, 4, 5, 6]], [1.0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]], [1.0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]]],
188+
}
189+
190+
self.run_test(
191+
mf,
192+
"be3",
193+
"autogen_octane_be3",
194+
"autogen",
195+
target,
196+
)
197+
198+
def test_graphgen_h_linear_be1(self):
199+
mol = gto.M()
200+
mol.atom = [["H", (0.0, 0.0, i)] for i in range(8)]
201+
mol.basis = "sto-3g"
202+
mol.charge = 0.0
203+
mol.spin = 0.0
204+
mol.build()
205+
206+
mf = scf.RHF(mol)
207+
208+
target = {
209+
"fsites": [(0,), (1,), (2,), (3,), (4,), (5,), (6,), (7,)],
210+
"edge": [(), (), (), (), (), (), (), ()],
211+
"center": [(0,), (1,), (2,), (3,), (4,), (5,), (6,), (7,)],
212+
"centerf_idx": [(0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,)],
213+
"ebe_weight": [
214+
(1.0, (0,)),
215+
(1.0, (0,)),
216+
(1.0, (0,)),
217+
(1.0, (0,)),
218+
(1.0, (0,)),
219+
(1.0, (0,)),
220+
(1.0, (0,)),
221+
(1.0, (0,))
222+
],
223+
}
224+
225+
self.run_test(
226+
mf,
227+
"be1",
228+
"graphgen_h_linear_be1",
229+
"graphgen",
230+
target,
231+
)
232+
233+
def test_graphgen_h_linear_be2(self):
234+
mol = gto.M()
235+
mol.atom = [["H", (0.0, 0.0, i)] for i in range(8)]
236+
mol.basis = "sto-3g"
237+
mol.charge = 0.0
238+
mol.spin = 0.0
239+
mol.build()
240+
241+
mf = scf.RHF(mol)
242+
243+
target = {
244+
"fsites": [(1, 0, 2), (2, 1, 3), (3, 2, 4), (4, 3, 5), (5, 4, 6), (6, 5, 7)],
245+
"edge": [((2,),), ((3,),), ((2,), (4,)), ((3,), (5,)), ((4,),), ((5,),)],
246+
"center": [(0, 1), (2,), (3,), (4,), (5,), (6, 7)],
247+
"centerf_idx": [(0, 1), (0,), (0,), (0,), (0,), (0, 2)],
248+
"ebe_weight": [(1.0, (0, 1)), (1.0, (0,)), (1.0, (0,)), (1.0, (0,)), (1.0, (0,)), (1.0, (0, 2))],
249+
}
250+
251+
self.run_test(
252+
mf,
253+
"be2",
254+
"graphgen_h_linear_be2",
255+
"graphgen",
256+
target,
257+
)
258+
259+
def test_graphgen_h_linear_be3(self):
260+
mol = gto.M()
261+
mol.atom = [["H", (0.0, 0.0, i)] for i in range(8)]
262+
mol.basis = "sto-3g"
263+
mol.charge = 0.0
264+
mol.spin = 0.0
265+
mol.build()
266+
267+
mf = scf.RHF(mol)
268+
269+
target = {
270+
"fsites": [(2, 0, 1, 3, 4), (3, 1, 2, 4, 5), (4, 2, 3, 5, 6), (5, 3, 4, 6, 7)],
271+
"edge": [((3,), (4,)), ((4,),), ((3,),), ((3,), (4,))],
272+
"center": [(0, 1, 2), (3,), (4,), (5, 6, 7)],
273+
"centerf_idx": [(0, 1, 2), (0,), (0,), (0, 3, 4)],
274+
"ebe_weight": [(1.0, (0, 1, 2)), (1.0, (0,)), (1.0, (0,)), (1.0, (0, 3, 4))],
275+
}
276+
277+
self.run_test(
278+
mf,
279+
"be3",
280+
"graphgen_h_linear_be3",
281+
"graphgen",
282+
target,
283+
)
284+
285+
def test_graphgen_octane_be1(self):
286+
mol = gto.M()
287+
mol.atom = os.path.join(os.path.dirname(__file__), "xyz/octane.xyz")
288+
mol.basis = "sto-3g"
289+
mol.charge = 0.0
290+
mol.spin = 0.0
291+
mol.build()
292+
293+
mf = scf.RHF(mol)
294+
295+
target = {
296+
"fsites": [(0, 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,)],
297+
"edge": [(), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ()],
298+
"center": [(0, 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,)],
299+
"centerf_idx": [(0, 1, 2, 3, 4), (0, 1, 2, 3, 4), (0,), (0,), (0,), (0,), (0, 1, 2, 3, 4), (0, 1, 2, 3, 4), (0,), (0,), (0,), (0,), (0, 1, 2, 3, 4), (0, 1, 2, 3, 4), (0,), (0,), (0,), (0,), (0, 1, 2, 3, 4), (0, 1, 2, 3, 4), (0,), (0,), (0,), (0,), (0,), (0,)],
300+
"ebe_weight": [(1.0, (0, 1, 2, 3, 4)), (1.0, (0, 1, 2, 3, 4)), (1.0, (0,)), (1.0, (0,)), (1.0, (0,)), (1.0, (0,)), (1.0, (0, 1, 2, 3, 4)), (1.0, (0, 1, 2, 3, 4)), (1.0, (0,)), (1.0, (0,)), (1.0, (0,)), (1.0, (0,)), (1.0, (0, 1, 2, 3, 4)), (1.0, (0, 1, 2, 3, 4)), (1.0, (0,)), (1.0, (0,)), (1.0, (0,)), (1.0, (0,)), (1.0, (0, 1, 2, 3, 4)), (1.0, (0, 1, 2, 3, 4)), (1.0, (0,)), (1.0, (0,)), (1.0, (0,)), (1.0, (0,)), (1.0, (0,)), (1.0, (0,))],
301+
}
302+
303+
self.run_test(
304+
mf,
305+
"be1",
306+
"graphgen_octane_be1",
307+
"graphgen",
308+
target,
309+
)
310+
311+
def test_graphgen_octane_be2(self):
312+
mol = gto.M()
313+
mol.atom = os.path.join(os.path.dirname(__file__), "xyz/octane.xyz")
314+
mol.basis = "sto-3g"
315+
mol.charge = 0.0
316+
mol.spin = 0.0
317+
mol.build()
318+
319+
mf = scf.RHF(mol)
320+
321+
target = {
322+
"fsites": [(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 13, 19, 20, 21, 22, 23), (5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 10, 12, 14, 15, 16, 17, 18), (10, 5, 6, 7, 8, 9, 27, 40), (11, 0, 1, 2, 3, 4, 26, 41), (12, 5, 6, 7, 8, 9, 25, 38), (13, 0, 1, 2, 3, 4, 24, 39), (14, 15, 16, 17, 18, 5, 6, 7, 8, 9, 24, 26, 28, 29, 30, 31, 32), (19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 25, 27, 33, 34, 35, 36, 37), (24, 13, 14, 15, 16, 17, 18, 52), (25, 12, 19, 20, 21, 22, 23, 53), (26, 11, 14, 15, 16, 17, 18, 54), (27, 10, 19, 20, 21, 22, 23, 55), (28, 29, 30, 31, 32, 14, 15, 16, 17, 18, 38, 40, 42, 43, 44, 45, 46), (33, 34, 35, 36, 37, 19, 20, 21, 22, 23, 39, 41, 47, 48, 49, 50, 51), (38, 12, 28, 29, 30, 31, 32), (39, 13, 33, 34, 35, 36, 37), (40, 10, 28, 29, 30, 31, 32), (41, 11, 33, 34, 35, 36, 37), (42, 43, 44, 45, 46, 28, 29, 30, 31, 32, 52, 54, 57), (47, 48, 49, 50, 51, 33, 34, 35, 36, 37, 53, 55, 56), (52, 24, 42, 43, 44, 45, 46), (53, 25, 47, 48, 49, 50, 51), (54, 26, 42, 43, 44, 45, 46), (55, 27, 47, 48, 49, 50, 51)],
323+
"edge": [((5, 6, 7, 8, 9), (13,), (19, 20, 21, 22, 23), (11,)), ((12,), (0, 1, 2, 3, 4), (10,), (14, 15, 16, 17, 18)), ((5, 6, 7, 8, 9), (40,), (27,)), ((41,), (0, 1, 2, 3, 4), (26,)), ((5, 6, 7, 8, 9), (25,), (38,)), ((24,), (0, 1, 2, 3, 4), (39,)), ((5, 6, 7, 8, 9), (28, 29, 30, 31, 32), (24,), (26,)), ((0, 1, 2, 3, 4), (25,), (27,), (33, 34, 35, 36, 37)), ((52,), (13,), (14, 15, 16, 17, 18)), ((12,), (53,), (19, 20, 21, 22, 23)), ((11,), (54,), (14, 15, 16, 17, 18)), ((55,), (19, 20, 21, 22, 23), (10,)), ((40,), (38,), (14, 15, 16, 17, 18)), ((41,), (19, 20, 21, 22, 23), (39,)), ((28, 29, 30, 31, 32), (12,)), ((13,), (33, 34, 35, 36, 37)), ((28, 29, 30, 31, 32), (10,)), ((11,), (33, 34, 35, 36, 37)), ((28, 29, 30, 31, 32), (52,), (54,)), ((53,), (55,), (33, 34, 35, 36, 37)), ((24,),), ((25,),), ((26,),), ((27,),)],
324+
"center": [(0, 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, 57), (47, 48, 49, 50, 51, 56), (52,), (53,), (54,), (55,)],
325+
"centerf_idx": [(0, 1, 2, 3, 4), (0, 1, 2, 3, 4), (0,), (0,), (0,), (0,), (0, 1, 2, 3, 4), (0, 1, 2, 3, 4), (0,), (0,), (0,), (0,), (0, 1, 2, 3, 4), (0, 1, 2, 3, 4), (0,), (0,), (0,), (0,), (0, 1, 2, 3, 4, 12), (0, 1, 2, 3, 4, 12), (0,), (0,), (0,), (0,)],
326+
"ebe_weight": [(1.0, (0, 1, 2, 3, 4)), (1.0, (0, 1, 2, 3, 4)), (1.0, (0,)), (1.0, (0,)), (1.0, (0,)), (1.0, (0,)), (1.0, (0, 1, 2, 3, 4)), (1.0, (0, 1, 2, 3, 4)), (1.0, (0,)), (1.0, (0,)), (1.0, (0,)), (1.0, (0,)), (1.0, (0, 1, 2, 3, 4)), (1.0, (0, 1, 2, 3, 4)), (1.0, (0,)), (1.0, (0,)), (1.0, (0,)), (1.0, (0,)), (1.0, (0, 1, 2, 3, 4, 12)), (1.0, (0, 1, 2, 3, 4, 12)), (1.0, (0,)), (1.0, (0,)), (1.0, (0,)), (1.0, (0,))],
327+
}
328+
329+
self.run_test(
330+
mf,
331+
"be2",
332+
"graphgen_octane_be2",
333+
"graphgen",
334+
target,
335+
)
336+
337+
def test_graphgen_octane_be3(self):
338+
mol = gto.M()
339+
mol.atom = os.path.join(os.path.dirname(__file__), "xyz/octane.xyz")
340+
mol.basis = "sto-3g"
341+
mol.charge = 0.0
342+
mol.spin = 0.0
343+
mol.build()
344+
345+
mf = scf.RHF(mol)
346+
347+
target = {
348+
"fsites": [(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 27, 33, 34, 35, 36, 37), (5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 28, 29, 30, 31, 32), (10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 14, 15, 16, 17, 18, 27, 40), (11, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 13, 19, 20, 21, 22, 23, 26, 41), (12, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 14, 15, 16, 17, 18, 25, 38), (13, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 19, 20, 21, 22, 23, 24, 39), (14, 15, 16, 17, 18, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 24, 26, 28, 29, 30, 31, 32, 38, 40, 42, 43, 44, 45, 46), (19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 13, 25, 27, 33, 34, 35, 36, 37, 39, 41, 47, 48, 49, 50, 51), (24, 5, 6, 7, 8, 9, 13, 14, 15, 16, 17, 18, 26, 28, 29, 30, 31, 32, 52), (25, 0, 1, 2, 3, 4, 12, 19, 20, 21, 22, 23, 27, 33, 34, 35, 36, 37, 53), (26, 5, 6, 7, 8, 9, 11, 14, 15, 16, 17, 18, 24, 28, 29, 30, 31, 32, 54), (27, 0, 1, 2, 3, 4, 10, 19, 20, 21, 22, 23, 25, 33, 34, 35, 36, 37, 55), (28, 29, 30, 31, 32, 5, 6, 7, 8, 9, 14, 15, 16, 17, 18, 24, 26, 38, 40, 42, 43, 44, 45, 46, 52, 54, 57), (33, 34, 35, 36, 37, 0, 1, 2, 3, 4, 19, 20, 21, 22, 23, 25, 27, 39, 41, 47, 48, 49, 50, 51, 53, 55, 56)],
349+
"edge": [((5, 6, 7, 8, 9), (12,), (10,), (11,), (13,), (25,), (27,)), ((12,), (26,), (10,), (24,), (11,), (13,), (0, 1, 2, 3, 4)), ((5, 6, 7, 8, 9), (12,), (0, 1, 2, 3, 4), (27,)), ((5, 6, 7, 8, 9), (13,), (0, 1, 2, 3, 4), (26,)), ((5, 6, 7, 8, 9), (0, 1, 2, 3, 4), (25,), (10,)), ((5, 6, 7, 8, 9), (24,), (0, 1, 2, 3, 4), (11,)), ((5, 6, 7, 8, 9), (12,), (26,), (10,), (24,), (0, 1, 2, 3, 4)), ((5, 6, 7, 8, 9), (11,), (13,), (0, 1, 2, 3, 4), (25,), (27,)), ((5, 6, 7, 8, 9), (13,), (26,)), ((12,), (0, 1, 2, 3, 4), (27,)), ((5, 6, 7, 8, 9), (24,), (11,)), ((0, 1, 2, 3, 4), (25,), (10,)), ((5, 6, 7, 8, 9), (24,), (26,)), ((0, 1, 2, 3, 4), (25,), (27,))],
350+
"center": [(0, 1, 2, 3, 4), (5, 6, 7, 8, 9), (10,), (11,), (12,), (13,), (38, 40, 14, 15, 16, 17, 18), (39, 41, 19, 20, 21, 22, 23), (24,), (25,), (26,), (27,), (32, 42, 43, 44, 45, 46, 52, 54, 57, 28, 29, 30, 31), (33, 34, 35, 36, 37, 47, 48, 49, 50, 51, 53, 55, 56)],
351+
"centerf_idx": [(0, 1, 2, 3, 4), (0, 1, 2, 3, 4), (0,), (0,), (0,), (0,), (0, 1, 2, 3, 4, 24, 25), (0, 1, 2, 3, 4, 24, 25), (0,), (0,), (0,), (0,), (0, 1, 2, 3, 4, 19, 20, 21, 22, 23, 24, 25, 26), (0, 1, 2, 3, 4, 19, 20, 21, 22, 23, 24, 25, 26)],
352+
"ebe_weight": [(1.0, (0, 1, 2, 3, 4)), (1.0, (0, 1, 2, 3, 4)), (1.0, (0,)), (1.0, (0,)), (1.0, (0,)), (1.0, (0,)), (1.0, (0, 1, 2, 3, 4, 24, 25)), (1.0, (0, 1, 2, 3, 4, 24, 25)), (1.0, (0,)), (1.0, (0,)), (1.0, (0,)), (1.0, (0,)), (1.0, (0, 1, 2, 3, 4, 19, 20, 21, 22, 23, 24, 25, 26)), (1.0, (0, 1, 2, 3, 4, 19, 20, 21, 22, 23, 24, 25, 26))],
353+
}
354+
355+
self.run_test(
356+
mf,
357+
"be3",
358+
"graphgen_octane_be3",
359+
"graphgen",
360+
target,
361+
)
362+
363+
def run_test(
364+
self, mf, be_type, test_name, frag_type, target,
365+
):
366+
fobj = fragpart(frag_type=frag_type, be_type=be_type, mol=mf.mol)
367+
try:
368+
assert fobj.fsites == target["fsites"]
369+
assert fobj.edge == target["edge"]
370+
assert fobj.center == target["center"]
371+
assert fobj.centerf_idx == target["centerf_idx"]
372+
assert fobj.ebe_weight == target["ebe_weight"]
373+
except AssertionError as e:
374+
print(f"Fragmentation test failed at {test_name}:")
375+
raise e
376+
377+
if __name__ == "__main__":
378+
unittest.main()

0 commit comments

Comments
 (0)