Skip to content

Commit

Permalink
smoke tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maxscheurer committed Jan 14, 2022
1 parent 8b03f3c commit af628c3
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 0 deletions.
2 changes: 2 additions & 0 deletions MANIFEST.in
Expand Up @@ -4,3 +4,5 @@ exclude adcc/conftest.py
global-include libadcc/**/*.hh libadcc/**/*.cc
include LICENSE
include README.md
include adcc/smoketests/test_smoke.py
include adcc/testdata/static_data.py
22 changes: 22 additions & 0 deletions adcc/smoketests/__init__.py
@@ -0,0 +1,22 @@
#!/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/>.
##
## ---------------------------------------------------------------------
91 changes: 91 additions & 0 deletions adcc/smoketests/test_smoke.py
@@ -0,0 +1,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)

0 comments on commit af628c3

Please sign in to comment.