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
|
# -*- coding: utf-8 -*-
#
# Copyright (c) 2023, the cclib development team
#
# This file is part of cclib (http://cclib.github.io) and is distributed under
# the terms of the BSD 3-Clause License.
import unittest
import numpy
from cclib.bridge import cclib2pyquante
from ..test_data import getdatafile
from cclib.parser.utils import find_package
from numpy.testing import assert_array_almost_equal
class pyquante2Test(unittest.TestCase):
"""Tests for the cclib2pyquante bridge in cclib."""
def setUp(self):
super(pyquante2Test, self).setUp()
if not find_package("pyquante2"):
raise ImportError("Must install pyquante2 to run this test")
self.data, self.logfile = getdatafile("Gaussian", "basicGaussian16", ["water_ccsd.log"])
def test_makepyquante(self):
# Test pyquante2 bridge
from pyquante2 import molecule, rhf, h2o, basisset
bfs = basisset(h2o)
# Copied from water_ccsd.log
refmol = molecule(
[(8, 0.0, 0.0, 0.119159), (1, 0, 0.790649, -0.476637), (1, 0, -0.790649, -0.476637)],
units="Angstroms",
)
refsolver = rhf(refmol, bfs)
refsolver.converge()
pyqmol = cclib2pyquante.makepyquante(self.data)
pyqsolver = rhf(pyqmol, bfs)
pyqsolver.converge()
assert_array_almost_equal(refsolver.energies[-1], pyqsolver.energies[-1], decimal=6)
if __name__ == "__main__":
unittest.main()
|