From 8987213172034f73a354ae2dad2d77d041297b99 Mon Sep 17 00:00:00 2001 From: ifilot Date: Sun, 14 Jan 2024 21:11:52 +0100 Subject: [PATCH] Adding custom basis set interface --- pyqint/molecule.py | 3 +++ tests/test_custom_basis_set.py | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tests/test_custom_basis_set.py diff --git a/pyqint/molecule.py b/pyqint/molecule.py index e5b0443..6787e40 100644 --- a/pyqint/molecule.py +++ b/pyqint/molecule.py @@ -150,4 +150,7 @@ def get_nuclei(self): self.__charges[aidx] = getattr(el, atom[0]) self.__nuclei.append([atom[1], self.__charges[aidx]]) + # populate number of electrons + self.__nelec = np.sum(self.__charges) + return self.__nuclei \ No newline at end of file diff --git a/tests/test_custom_basis_set.py b/tests/test_custom_basis_set.py new file mode 100644 index 0000000..42bca08 --- /dev/null +++ b/tests/test_custom_basis_set.py @@ -0,0 +1,27 @@ +import unittest +from pyqint import Molecule, cgf, HF +import numpy as np + +class TestCustomBasisSet(unittest.TestCase): + + def test_custom_basis_set_h2(self): + mol = Molecule() + mol.add_atom('H', 0.0000, 0.0000, 0.3561150187, unit='angstrom') + mol.add_atom('H', 0.0000, 0.0000, -0.3561150187, unit='angstrom') + nuclei = mol.get_nuclei() + + cgfs = [] + for n in nuclei: + _cgf = cgf(n[0]) + + _cgf.add_gto(0.154329, 3.425251, 0, 0, 0) + _cgf.add_gto(0.535328, 0.623914, 0, 0, 0) + _cgf.add_gto(0.444635, 0.168855, 0, 0, 0) + + cgfs.append(_cgf) + + res = HF().rhf(mol, basis=cgfs) + np.testing.assert_almost_equal(res['energy'], -1.1175059, 5) + +if __name__ == '__main__': + unittest.main()