@@ -145,3 +145,102 @@ def test_evaluate_basis_horton():
145145
146146 assert np .allclose (evaluate_basis (basis , grid_3d , coord_type = "cartesian" ), horton_eval_cart .T )
147147 assert np .allclose (evaluate_basis (basis , grid_3d , coord_type = "spherical" ), horton_eval_sph .T )
148+
149+
150+ def test_evaluate_basis_pyscf ():
151+ """Test gbasis.evals.eval.evaluate_basis against pyscf results."""
152+ pytest .importorskip ("pyscf" )
153+
154+ from pyscf import gto
155+ from gbasis .wrappers import from_pyscf
156+
157+ mol = gto .Mole ()
158+ mol .build (atom = "H 0 0 0; He 0.8 0 0" , basis = "ano-rcc" , spin = 1 )
159+ basis = from_pyscf (mol )
160+
161+ grid_1d = np .linspace (- 2 , 2 , num = 5 )
162+ grid_x , grid_y , grid_z = np .meshgrid (grid_1d , grid_1d , grid_1d )
163+ grid_3d = np .vstack ([grid_x .ravel (), grid_y .ravel (), grid_z .ravel ()]).T
164+
165+ pyscf_eval_sph = gto .eval_gto (mol , "GTOval_sph" , grid_3d )
166+ pyscf_eval_cart = gto .eval_gto (mol , "GTOval_cart" , grid_3d )
167+
168+ # s orbitals
169+ assert np .allclose (
170+ evaluate_basis (basis , grid_3d , coord_type = "cartesian" )[:6 ], pyscf_eval_cart .T [:6 ]
171+ )
172+ assert np .allclose (
173+ evaluate_basis (basis , grid_3d , coord_type = "cartesian" )[46 :53 ], pyscf_eval_cart .T [46 :53 ]
174+ )
175+ assert np .allclose (
176+ evaluate_basis (basis , grid_3d , coord_type = "spherical" )[:6 ], pyscf_eval_sph .T [:6 ]
177+ )
178+ assert np .allclose (
179+ evaluate_basis (basis , grid_3d , coord_type = "spherical" )[40 :47 ], pyscf_eval_sph .T [40 :47 ]
180+ )
181+ # p orbitals
182+ assert np .allclose (
183+ evaluate_basis (basis , grid_3d , coord_type = "cartesian" )[6 :18 ], pyscf_eval_cart .T [6 :18 ]
184+ )
185+ assert np .allclose (
186+ evaluate_basis (basis , grid_3d , coord_type = "cartesian" )[53 :65 ], pyscf_eval_cart .T [53 :65 ]
187+ )
188+ assert np .allclose (
189+ evaluate_basis (basis , grid_3d , coord_type = "spherical" )[6 :18 ], pyscf_eval_sph .T [6 :18 ]
190+ )
191+ assert np .allclose (
192+ evaluate_basis (basis , grid_3d , coord_type = "spherical" )[47 :59 ], pyscf_eval_sph .T [47 :59 ]
193+ )
194+ # d orbitals are off by some constant for the cartesian case
195+ assert np .allclose (
196+ evaluate_basis (basis , grid_3d , coord_type = "spherical" )[18 :33 ], pyscf_eval_sph .T [18 :33 ]
197+ )
198+ assert np .allclose (
199+ evaluate_basis (basis , grid_3d , coord_type = "spherical" )[59 :74 ], pyscf_eval_sph .T [59 :74 ]
200+ )
201+ # f orbitals are off by some constant for the cartesian case
202+ assert np .allclose (
203+ evaluate_basis (basis , grid_3d , coord_type = "spherical" )[33 :40 ], pyscf_eval_sph .T [33 :40 ]
204+ )
205+ assert np .allclose (
206+ evaluate_basis (basis , grid_3d , coord_type = "spherical" )[74 :88 ], pyscf_eval_sph .T [74 :88 ]
207+ )
208+
209+
210+ @pytest .mark .xfail
211+ def test_evaluate_basis_pyscf_cart_norm ():
212+ """Test gbasis.evals.eval.evaluate_basis against pyscf results.
213+
214+ These cases fail because pyscf seems to have a different normalization constant for the d and f
215+ orbitals.
216+
217+ """
218+ pytest .importorskip ("pyscf" )
219+
220+ from pyscf import gto
221+ from gbasis .wrappers import from_pyscf
222+
223+ mol = gto .Mole ()
224+ mol .build (atom = "H 0 0 0; He 0.8 0 0" , basis = "ano-rcc" , spin = 1 )
225+ basis = from_pyscf (mol )
226+
227+ grid_1d = np .linspace (- 2 , 2 , num = 5 )
228+ grid_x , grid_y , grid_z = np .meshgrid (grid_1d , grid_1d , grid_1d )
229+ grid_3d = np .vstack ([grid_x .ravel (), grid_y .ravel (), grid_z .ravel ()]).T
230+
231+ pyscf_eval_cart = gto .eval_gto (mol , "GTOval_cart" , grid_3d )
232+
233+ # d orbitals are all off by some scalar factor
234+ assert np .allclose (
235+ evaluate_basis (basis , grid_3d , coord_type = "cartesian" )[18 :36 ], pyscf_eval_cart .T [18 :36 ]
236+ )
237+ assert np .allclose (
238+ evaluate_basis (basis , grid_3d , coord_type = "cartesian" )[65 :83 ], pyscf_eval_cart .T [65 :83 ]
239+ )
240+ # f orbitals are all off by some scalar factor
241+ assert np .allclose (
242+ evaluate_basis (basis , grid_3d , coord_type = "cartesian" )[36 :46 ], pyscf_eval_cart .T [36 :46 ]
243+ )
244+ assert np .allclose (
245+ evaluate_basis (basis , grid_3d , coord_type = "cartesian" )[83 :103 ], pyscf_eval_cart .T [83 :103 ]
246+ )
0 commit comments