forked from theochem/gbasis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_overlap_asymm.py
90 lines (77 loc) · 3.69 KB
/
test_overlap_asymm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
"""Test gbasis.integrals.overlap_asymm."""
from gbasis.integrals.overlap import overlap_integral
from gbasis.integrals.overlap_asymm import overlap_integral_asymmetric
from gbasis.parsers import make_contractions, parse_nwchem
import numpy as np
from utils import find_datafile, HortonContractions
def test_overlap_integral_asymmetric_horton_anorcc_hhe():
"""Test gbasis.integrals.overlap_asymm.overlap_integral_asymmetric against HORTON's overlap matrix.
The test case is diatomic with H and He separated by 0.8 angstroms with basis set ANO-RCC.
"""
basis_dict = parse_nwchem(find_datafile("data_anorcc.nwchem"))
# NOTE: used HORTON's conversion factor for angstroms to bohr
basis = make_contractions(
basis_dict, ["H", "He"], np.array([[0, 0, 0], [0.8 * 1.0 / 0.5291772083, 0, 0]]), "cartesian"
)
basis = [HortonContractions(i.angmom, i.coord, i.coeffs, i.exps, i.coord_type) for i in basis]
horton_overlap_integral_asymmetric = np.load(find_datafile("data_horton_hhe_cart_overlap.npy"))
assert np.allclose(
overlap_integral_asymmetric(
basis, basis
),
horton_overlap_integral_asymmetric,
)
def test_overlap_integral_asymmetric_horton_anorcc_bec():
"""Test integrals.overlap_asymm.overlap_integral_asymmetric against HORTON's overlap matrix.
The test case is diatomic with Be and C separated by 1.0 angstroms with basis set ANO-RCC.
"""
basis_dict = parse_nwchem(find_datafile("data_anorcc.nwchem"))
# NOTE: used HORTON's conversion factor for angstroms to bohr
basis = make_contractions(
basis_dict, ["Be", "C"], np.array([[0, 0, 0], [1.0 * 1.0 / 0.5291772083, 0, 0]]), "cartesian"
)
basis = [HortonContractions(i.angmom, i.coord, i.coeffs, i.exps, i.coord_type) for i in basis]
horton_overlap_integral_asymmetric = np.load(find_datafile("data_horton_bec_cart_overlap.npy"))
assert np.allclose(
overlap_integral_asymmetric(
basis, basis
),
horton_overlap_integral_asymmetric,
)
def test_overlap_integral_asymmetric_compare():
"""Test overlap_asymm.overlap_integral_asymmetric against overlap.overlap_integral."""
basis_dict = parse_nwchem(find_datafile("data_anorcc.nwchem"))
cartesian_basis = make_contractions(basis_dict, ["Kr", "Kr"], np.array([[0, 0, 0], [1.0, 0, 0]]), "cartesian")
spherical_basis = make_contractions(basis_dict, ["Kr", "Kr"], np.array([[0, 0, 0], [1.0, 0, 0]]), "spherical")
mixed_basis = make_contractions(basis_dict, ["Kr", "Kr"], np.array([[0, 0, 0], [1.0, 0, 0]]), ['spherical'] * 9 + ['cartesian'])
cartesian_basis = [HortonContractions(i.angmom, i.coord, i.coeffs, i.exps, i.coord_type) for i in cartesian_basis]
spherical_basis = [HortonContractions(i.angmom, i.coord, i.coeffs, i.exps, i.coord_type) for i in spherical_basis]
mixed_basis = [HortonContractions(i.angmom, i.coord, i.coeffs, i.exps, i.coord_type) for i in mixed_basis]
assert np.allclose(
overlap_integral(cartesian_basis),
overlap_integral_asymmetric(
cartesian_basis, cartesian_basis
),
)
assert np.allclose(
overlap_integral(spherical_basis),
overlap_integral_asymmetric(
spherical_basis, spherical_basis
),
)
assert np.allclose(
overlap_integral(spherical_basis, transform=np.identity(218)),
overlap_integral_asymmetric(
spherical_basis,
spherical_basis,
transform_one=np.identity(218),
transform_two=np.identity(218),
),
)
assert np.allclose(
overlap_integral(mixed_basis),
overlap_integral_asymmetric(
mixed_basis,
mixed_basis,
),
)