Skip to content

Commit

Permalink
Add test that compares density eval with horton
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kimt33 committed Jun 26, 2019
1 parent 03eff2c commit e04378d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
Binary file added tests/data_horton_hhe_cart_density_rand.npy
Binary file not shown.
Binary file added tests/data_horton_hhe_cart_dm_rand.npy
Binary file not shown.
Binary file added tests/data_horton_hhe_sph_density_rand.npy
Binary file not shown.
Binary file added tests/data_horton_hhe_sph_dm_rand.npy
Binary file not shown.
32 changes: 32 additions & 0 deletions tests/test_density.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,38 @@ def test_evaluate_density_horton():
)


def test_evaluate_density_horton_nonidentity_dm():
"""Test gbasis.evals.density.evaluate_density against result from HORTON.
The test case is diatomic with H and He separated by 0.8 angstroms with basis set ANO-RCC.
Density matrix here is not an identity matrix and is instead a random symmetric matrix.
"""
basis_dict = parse_nwchem(find_datafile("data_anorcc.nwchem"))
points = np.array([[0, 0, 0], [0.8, 0, 0]])
basis = make_contractions(basis_dict, ["H", "He"], points)
basis = [HortonContractions(i.angmom, i.coord, i.coeffs, i.exps) for i in basis]

grid_1d = np.linspace(-2, 2, num=5)
grid_x, grid_y, grid_z = np.meshgrid(grid_1d, grid_1d, grid_1d)
grid_3d = np.vstack([grid_x.ravel(), grid_y.ravel(), grid_z.ravel()]).T
grid_3d = np.ascontiguousarray(grid_3d)

horton_density = np.load(find_datafile("data_horton_hhe_cart_density_rand.npy"))
density_matrix = np.load(find_datafile("data_horton_hhe_cart_dm_rand.npy"))

assert np.allclose(
evaluate_density(density_matrix, basis, grid_3d, coord_type="cartesian"), horton_density
)

horton_density = np.load(find_datafile("data_horton_hhe_sph_density_rand.npy"))
density_matrix = np.load(find_datafile("data_horton_hhe_sph_dm_rand.npy"))

assert np.allclose(
evaluate_density(density_matrix, basis, grid_3d, coord_type="spherical"), horton_density
)


def test_evaluate_density_gradient_horton():
"""Test gbasis.evals.density.evaluate_density_gradient against result from HORTON.
Expand Down

0 comments on commit e04378d

Please sign in to comment.