-
Notifications
You must be signed in to change notification settings - Fork 19
/
test_smoke.py
91 lines (82 loc) · 3.48 KB
/
test_smoke.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
#!/usr/bin/env python3
## vi: tabstop=4 shiftwidth=4 softtabstop=4 expandtab
## ---------------------------------------------------------------------
##
## Copyright (C) 2022 by the adcc authors
##
## This file is part of adcc.
##
## adcc is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published
## by the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## adcc is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with adcc. If not, see <http://www.gnu.org/licenses/>.
##
## ---------------------------------------------------------------------
import unittest
import pytest
from numpy.testing import assert_allclose
import adcc
from adcc.backends.testing import cached_backend_hf
from ..misc import expand_test_templates
methods = ["adc0", "adc1", "adc2", "adc2x", "adc3"]
_singlets = {
"adc0": [0.99048446, 1.04450741, 1.15356339],
"adc1": [0.48343609, 0.57420044, 0.60213699],
"adc2": [0.47051314, 0.57255495, 0.59367339],
"adc2x": [0.44511182, 0.55139508, 0.57146893],
"adc3": [0.45197068, 0.55572706, 0.57861241],
}
_triplets = {
"adc0": [0.99048446, 1.04450741, 1.15356339],
"adc1": [0.40544164, 0.48351268, 0.52489129],
"adc2": [0.40288477, 0.4913253, 0.52854722],
"adc2x": [0.38557787, 0.48177562, 0.51336301],
"adc3": [0.3924605, 0.4877098, 0.51755258]
}
_singlets_cvs = {
"adc0": [20.83623681, 20.99931574],
"adc1": [20.10577515, 20.16512502],
"adc2": [20.0045422, 20.08771799],
"adc2x": [19.90528006, 19.9990468],
"adc3": [19.93138526, 20.02055267],
}
_triplets_cvs = {
"adc0": [20.83623681, 20.99931574],
"adc1": [20.04302084, 20.12099631],
"adc2": [19.95732865, 20.05239094],
"adc2x": [19.86572075, 19.97241019],
"adc3": [19.89172578, 19.99386631],
}
@pytest.mark.skipif("pyscf" not in adcc.backends.available(),
reason="PySCF not found.")
@expand_test_templates(methods)
class TestSmoke(unittest.TestCase):
def template_test_h2o_sto3g(self, method):
scfres = cached_backend_hf("pyscf", "h2o", "sto-3g")
refstate = adcc.ReferenceState(scfres)
state_singlets = adcc.run_adc(refstate, method=method,
n_singlets=3, conv_tol=1e-7)
state_triplets = adcc.run_adc(refstate, method=method,
n_triplets=3, conv_tol=1e-7)
assert_allclose(state_singlets.excitation_energy,
_singlets[method], atol=1e-6)
assert_allclose(state_triplets.excitation_energy,
_triplets[method], atol=1e-6)
def template_test_h2o_sto3g_cvs(self, method):
scfres = cached_backend_hf("pyscf", "h2o", "sto-3g")
refstate = adcc.ReferenceState(scfres, core_orbitals=1)
cvsmethod = f"cvs-{method}"
state_singlets = adcc.run_adc(refstate, n_singlets=2, method=cvsmethod)
state_triplets = adcc.run_adc(refstate, n_triplets=2, method=cvsmethod)
assert_allclose(state_singlets.excitation_energy,
_singlets_cvs[method], atol=1e-6)
assert_allclose(state_triplets.excitation_energy,
_triplets_cvs[method], atol=1e-6)