Skip to content

Commit fd7d4c5

Browse files
committed
Add test that compares density eval with horton
There already is a test that compares density evaluation with horton, but the density matrix used was an identity matrix. Just in case, the density evaluations are compared for both spherical and cartesian contractions for random symmetric density matrix.
1 parent a965bd4 commit fd7d4c5

File tree

5 files changed

+32
-0
lines changed

5 files changed

+32
-0
lines changed
1.05 KB
Binary file not shown.
83 KB
Binary file not shown.
1.05 KB
Binary file not shown.
60.6 KB
Binary file not shown.

tests/test_density.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,38 @@ def test_evaluate_density_horton():
297297
)
298298

299299

300+
def test_evaluate_density_horton_nonidentity_dm():
301+
"""Test gbasis.evals.density.evaluate_density against result from HORTON.
302+
303+
The test case is diatomic with H and He separated by 0.8 angstroms with basis set ANO-RCC.
304+
Density matrix here is not an identity matrix and is instead a random symmetric matrix.
305+
306+
"""
307+
basis_dict = parse_nwchem(find_datafile("data_anorcc.nwchem"))
308+
points = np.array([[0, 0, 0], [0.8, 0, 0]])
309+
basis = make_contractions(basis_dict, ["H", "He"], points)
310+
basis = [HortonContractions(i.angmom, i.coord, i.coeffs, i.exps) for i in basis]
311+
312+
grid_1d = np.linspace(-2, 2, num=5)
313+
grid_x, grid_y, grid_z = np.meshgrid(grid_1d, grid_1d, grid_1d)
314+
grid_3d = np.vstack([grid_x.ravel(), grid_y.ravel(), grid_z.ravel()]).T
315+
grid_3d = np.ascontiguousarray(grid_3d)
316+
317+
horton_density = np.load(find_datafile("data_horton_hhe_cart_density_rand.npy"))
318+
density_matrix = np.load(find_datafile("data_horton_hhe_cart_dm_rand.npy"))
319+
320+
assert np.allclose(
321+
evaluate_density(density_matrix, basis, grid_3d, coord_type="cartesian"), horton_density
322+
)
323+
324+
horton_density = np.load(find_datafile("data_horton_hhe_sph_density_rand.npy"))
325+
density_matrix = np.load(find_datafile("data_horton_hhe_sph_dm_rand.npy"))
326+
327+
assert np.allclose(
328+
evaluate_density(density_matrix, basis, grid_3d, coord_type="spherical"), horton_density
329+
)
330+
331+
300332
def test_evaluate_density_gradient_horton():
301333
"""Test gbasis.evals.density.evaluate_density_gradient against result from HORTON.
302334

0 commit comments

Comments
 (0)