11import unittest
2- from pyqint import PyQInt , Molecule , CGF
2+ from pyqint import PyQInt , Molecule , CGF , MoleculeBuilder
33import numpy as np
44import os
55
66class TestCGF (unittest .TestCase ):
7- def testFunctionsCGF (self ):
7+ def test_functions_cgf (self ):
88 """
99 Test getting amplitude from CGF
1010 """
@@ -49,7 +49,7 @@ def testFunctionsCGF(self):
4949
5050 np .testing .assert_almost_equal (amps , ans , 6 )
5151
52- def testPlotGrid (self ):
52+ def test_plot_grid (self ):
5353 """
5454 Test plotting of 1b2 molecular orbital of H2O
5555 """
@@ -77,7 +77,7 @@ def testPlotGrid(self):
7777 ans = np .load (os .path .join (os .path .dirname (__file__ ), 'results' , 'h2o_orb_1b2.npy' ))
7878 np .testing .assert_almost_equal (res , ans , 6 )
7979
80- def testSphericalHarmonicsOnSite (self ):
80+ def test_spherical_harmonic_on_site (self ):
8181 """
8282 Check if the overlap matrix of all spherical harmonics up to l=6 is the identity matrix
8383 """
@@ -97,7 +97,7 @@ def testSphericalHarmonicsOnSite(self):
9797 S [i ,j ] = integrator .overlap (orb1 , orb2 )
9898 np .testing .assert_almost_equal (S , np .eye (S .shape [0 ]), 6 )
9999
100- def testSinglePrimitiveNormalization (self ):
100+ def test_single_primitive_normalization (self ):
101101 """
102102 Test that a single primitive GTO has self-overlap of 1.0
103103 """
@@ -123,7 +123,7 @@ def testSinglePrimitiveNormalization(self):
123123 self .assertAlmostEqual (S , 1.0 , places = 10 ,
124124 msg = f"Single primitive ({ l } ,{ m } ,{ n } ) with alpha={ alpha } failed: S={ S } " )
125125
126- def testContractedBasisNormalization (self ):
126+ def test_contracted_basis_normalization (self ):
127127 """
128128 Test that contracted basis functions (STO-3G) have self-overlap of 1.0
129129 This verifies the contraction normalization is applied correctly.
@@ -142,7 +142,7 @@ def testContractedBasisNormalization(self):
142142 self .assertAlmostEqual (S_ii , 1.0 , places = 8 ,
143143 msg = f"Contracted basis function { i } has self-overlap { S_ii } " )
144144
145- def testOverlapMatrixSymmetryAndDiagonal (self ):
145+ def test_overlap_matrix (self ):
146146 """
147147 Test overlap matrix properties for a multi-atom system:
148148 1. Diagonal elements should be 1.0 (normalisation)
@@ -177,6 +177,33 @@ def testOverlapMatrixSymmetryAndDiagonal(self):
177177 off_diag = S - np .diag (np .diag (S ))
178178 self .assertTrue (np .all (np .abs (off_diag ) < 1.0 ),
179179 msg = "Off-diagonal overlap elements should have magnitude < 1.0" )
180+
181+ def test_nh3_symmetrized_cgf (self ):
182+ """
183+ Test whether symmetrized CGF is normalized
184+ """
185+ integrator = PyQInt ()
186+
187+ # Build water molecule with STO-3G basis
188+ mol = MoleculeBuilder .from_name ('NH3' )
189+ cgfs , _ = mol .build_basis ('sto3g' )
190+ self .assertEqual (len (cgfs ), 8 )
191+
192+ # build symmetrized CGF
193+ cgf = CGF ()
194+ for j ,c in enumerate (np .array ([0 ,0 ,0 ,0 ,0 ,1 ,1 ,- 2 ], dtype = int )):
195+ if c != 0 :
196+ for g in cgfs [j ].gtos :
197+ cgf .add_gto_with_position (
198+ g .c * c ,
199+ g .p ,
200+ g .alpha ,
201+ g .l ,
202+ g .m ,
203+ g .n
204+ )
205+ overlap = integrator .overlap (cgf , cgf )
206+ self .assertEqual (overlap , 1.0 )
180207
181208if __name__ == '__main__' :
182209 unittest .main ()
0 commit comments