-
Notifications
You must be signed in to change notification settings - Fork 0
/
SimintERI.cpp
143 lines (105 loc) · 4.69 KB
/
SimintERI.cpp
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#include <pulsar/output/OutputStream.hpp>
#include <pulsar/system/AOOrdering.hpp>
#include <pulsar/system/SphericalTransformIntegral.hpp>
#include "SimintERI.hpp"
#include "simint/simint_init.h"
#include "simint/eri/eri.h"
using namespace pulsar::output;
using namespace pulsar::exception;
using namespace pulsar::system;
using namespace pulsar::datastore;
static
gaussian_shell ToSimintShell(const BasisSetShell & shell, int igen)
{
size_t nprim = shell.n_primitives();
gaussian_shell gs;
allocate_gaussian_shell(nprim, &gs);
gs.nprim = nprim;
gs.am = shell.general_am(igen);
gs.x = shell.get_coord(0);
gs.y = shell.get_coord(1);
gs.z = shell.get_coord(2);
const double * alphas = shell.alpha_ptr();
const double * coefs = shell.coef_ptr(igen);
std::copy(alphas, alphas + nprim, gs.alpha);
std::copy(coefs, coefs + nprim, gs.coef);
normalize_gaussian_shells(1, &gs);
return gs;
}
uint64_t SimintERI::calculate_(size_t shell1, size_t shell2,
size_t shell3, size_t shell4,
double * outbuffer, size_t bufsize)
{
const BasisSetShell & sh1 = bs1_.shell(shell1);
const BasisSetShell & sh2 = bs2_.shell(shell2);
const BasisSetShell & sh3 = bs3_.shell(shell3);
const BasisSetShell & sh4 = bs4_.shell(shell4);
size_t nfunc = sh1.n_functions() * sh2.n_functions() * sh3.n_functions() * sh4.n_functions();
if(bufsize < nfunc)
throw GeneralException("Buffer to small for ERI", "bufsize", bufsize, "nfunc", nfunc);
double * srcptr = sourcework_;
for(size_t ng1 = 0; ng1 < sh1.n_general_contractions(); ng1++)
{
gaussian_shell gs1 = ToSimintShell(sh1, ng1);
const size_t ncart1 = n_cartesian_gaussian(sh1.general_am(ng1));
for(size_t ng2 = 0; ng2 < sh2.n_general_contractions(); ng2++)
{
gaussian_shell gs2 = ToSimintShell(sh2, ng2);
const size_t ncart2 = n_cartesian_gaussian(sh2.general_am(ng2));
multishell_pair bra_pair = create_multishell_pair(1, &gs1, 1, &gs2);
for(size_t ng3 = 0; ng3 < sh3.n_general_contractions(); ng3++)
{
gaussian_shell gs3 = ToSimintShell(sh3, ng3);
const size_t ncart3 = n_cartesian_gaussian(sh3.general_am(ng3));
for(size_t ng4 = 0; ng4 < sh4.n_general_contractions(); ng4++)
{
// form the shell pair info
gaussian_shell gs4 = ToSimintShell(sh4, ng4);
multishell_pair ket_pair = create_multishell_pair(1, &gs3, 1, &gs4);
const size_t ncart4 = n_cartesian_gaussian(sh4.general_am(ng4));
const size_t ncart = ncart1 * ncart2 * ncart3 * ncart4;
size_t ncalc = simint_compute_eri(bra_pair, ket_pair, srcptr);
free_gaussian_shell(gs4);
free_multishell_pair(ket_pair);
srcptr += ncalc * ncart;
}
free_gaussian_shell(gs3);
}
free_gaussian_shell(gs2);
free_multishell_pair(bra_pair);
}
free_gaussian_shell(gs1);
}
CartesianToSpherical_4Center(sh1, sh2, sh3, sh4, sourcework_, outbuffer, transformwork_, 1);
return nfunc;
}
void SimintERI::initialize_(unsigned int deriv,
const Wavefunction & wfn,
const BasisSet & bs1, const BasisSet & bs2,
const BasisSet & bs3, const BasisSet & bs4)
{
if(deriv != 0)
throw NotYetImplementedException("Not Yet Implemented: Simint with deriv != 0");
// initialize the simint library
simint_init();
// get the basis sets from the system
// Note - storing un-normalized
bs1_ = bs1;
bs2_ = bs2;
bs3_ = bs3;
bs4_ = bs4;
// determine work sizes
size_t maxsize1 = bs1_.max_property(n_cartesian_gaussian_for_shell_am);
size_t maxsize2 = bs2_.max_property(n_cartesian_gaussian_for_shell_am);
size_t maxsize3 = bs3_.max_property(n_cartesian_gaussian_for_shell_am);
size_t maxsize4 = bs4_.max_property(n_cartesian_gaussian_for_shell_am);
size_t transformwork_size = maxsize1*maxsize2*maxsize3*maxsize4;
maxsize1 = bs1_.max_property(n_cartesian_gaussian_in_shell);
maxsize2 = bs2_.max_property(n_cartesian_gaussian_in_shell);
maxsize3 = bs3_.max_property(n_cartesian_gaussian_in_shell);
maxsize4 = bs4_.max_property(n_cartesian_gaussian_in_shell);
size_t sourcework_size = maxsize1*maxsize2*maxsize3*maxsize4;
work_.resize(sourcework_size+transformwork_size);
sourcework_ = work_.data();
transformwork_ = sourcework_ + sourcework_size;
}