6
#include <libciomr/libciomr.h>
7
#include <libchkpt/chkpt.hpp>
16
BasisSet::BasisSet(Ref<Chkpt> &chkpt)
19
nshells_ = chkpt->rd_nshell();
20
nprimitives_ = chkpt->rd_nprim();
21
nao_ = chkpt->rd_nao();
22
max_stability_index_ = 0;
24
// Psi3 only allows either all Cartesian or all Spherical harmonic
25
nbf_ = chkpt->rd_nso();
26
puream_ = chkpt->rd_puream() ? true : false;
27
max_am_ = chkpt->rd_max_am();
28
uso2ao_ = chkpt->rd_usotao();
30
// Allocate memory for the shells
31
shells_ = new Ref<GaussianShell>[nshells_];
33
// Initialize the shells
34
initialize_shells(chkpt);
39
Chkpt::free(shell_first_basis_function_);
40
Chkpt::free(shell_first_ao_);
41
Chkpt::free(shell_center_);
45
void BasisSet::initialize_shells(Ref<Chkpt> &chkpt)
47
// Retrieve angular momentum of each shell (1=s, 2=p, ...)
48
int *shell_am = chkpt->rd_stype();
50
// Retrieve number of primitives per shell
51
int *shell_num_prims = chkpt->rd_snumg();
53
// Retrieve exponents of primitive Gaussians
54
double *exponents = chkpt->rd_exps();
56
// Retrieve coefficients of primitive Gaussian
57
double **ccoeffs = chkpt->rd_contr_full();
59
// Retrieve pointer to first primitive in shell
60
int *shell_fprim = chkpt->rd_sprim();
62
// Retrieve pointer to first basis function in shell
63
shell_first_basis_function_ = chkpt->rd_sloc_new();
65
// Retrieve pointer to first AO in shell
66
shell_first_ao_ = chkpt->rd_sloc();
68
// Retrieve location of shells (which atom it's centered on)
69
shell_center_ = chkpt->rd_snuc();
71
// Initialize molecule, retrieves number of center and geometry
72
molecule_ = new Molecule;
73
molecule_->init_with_chkpt(chkpt);
75
// Initialize SphericalTransform
76
for (int i=0; i<=max_am_; ++i) {
77
sphericaltransforms_.push_back(SphericalTransform(i));
80
// Initialize SOTransform
81
sotransform_ = new SOTransform;
82
sotransform_->init(nshells_);
84
int *so2symblk = new int[nbf_];
85
int *so2index = new int[nbf_];
86
int *sopi = chkpt->rd_sopi();
87
int nirreps = chkpt->rd_nirreps();
89
// Create so2symblk and so2index
90
int ij = 0; int offset = 0;
91
for (int h=0; h<nirreps; ++h) {
92
for (int i=0; i<sopi[h]; ++i) {
94
so2index[ij] = ij-offset;
101
// Currently all basis sets are treated as segmented contractions
102
// even though GaussianShell is generalized (well not really).
105
int puream_start = 0;
106
int *sym_transform = new int[nirreps];
108
// We need access to symmetry information found in the checkpoint file.
109
Symmetry symmetry(chkpt);
111
for (int i=0; i<nshells_; ++i) {
112
int *am = new int[ncontr];
113
am[0] = shell_am[i] - 1;
114
int fprim = shell_fprim[i] - 1;
115
int nprims = shell_num_prims[i];
116
Vector3 center = molecule_->xyz(shell_center_[i] - 1);
117
double **cc = new double*[nprims];
118
for (int p=0; p<nprims; ++p) {
119
cc[p] = new double[ncontr];
120
cc[p][0] = ccoeffs[fprim+p][am[0]];
123
// Construct a new shell. GaussianShell copies the data to new memory
124
shells_[i] = new GaussianShell(ncontr, nprims, &(exponents[fprim]), am,
125
puream_ ? GaussianShell::Pure : GaussianShell::Cartesian, cc, shell_center_[i]-1, center,
128
if (nprims > max_nprimitives_)
129
max_nprimitives_ = nprims;
131
for (int p=0; p<nprims; p++) {
136
// OK, for a given number of AO functions in a shell INT_NCART(am)
137
// beginning at column ao_start go through all rows finding where this
138
// AO function contributes to an SO.
139
for (int ao = 0; ao < INT_NCART(am[0]); ++ao) {
140
int aooffset = ao_start + ao;
141
for (int so = 0; so < nbf_; ++so) {
142
if (fabs(uso2ao_[so][aooffset]) >= 1.0e-14)
143
sotransform_->add_transform(i, so2symblk[so], so2index[so], uso2ao_[so][aooffset], ao, so);
147
// Set the symmetry transform vector of the shell
148
for (int j=0; j<nirreps; ++j) {
149
sym_transform[j] = symmetry.trans_vec(i, j);
151
// The shell will copy the elements into a new vector.
152
shells_[i]->set_sym_transform(nirreps, sym_transform);
154
// Compute index of the stabilizer for the shell
156
for (int g=1; g<nirreps; ++g) {
157
if (i == symmetry.trans_vec(i, g)-1)
160
int stab_index = nirreps / count;
161
if (max_stability_index_ < stab_index)
162
max_stability_index_ = stab_index;
164
// Shift the ao starting index over to the next shell
165
ao_start += INT_NCART(am[0]);
166
puream_start += INT_NFUNC(puream_, am[0]);
169
delete[] sym_transform;
176
free(shell_num_prims);
180
void BasisSet::print(FILE *out) const
182
fprintf(out, " Basis Set\n");
183
fprintf(out, " Number of shells: %d\n", nshell());
184
fprintf(out, " Number of basis function: %d\n", nbf());
185
fprintf(out, " Number of Cartesian functions: %d\n", nao());
186
fprintf(out, " Spherical Harmonics?: %s\n", has_puream() ? "true" : "false");
187
fprintf(out, " Max angular momentum: %d\n\n", max_am());
189
fprintf(out, " Shells:\n\n");
190
for (int s=0; s<nshell(); ++s)
191
shells_[s]->print(out);
194
Ref<GaussianShell>& BasisSet::shell(int si) const
197
assert(si < nshell());