7
#include <libciomr/libciomr.h>
8
#include <libint/libint.h>
9
#include <libderiv/libderiv.h>
14
#include"taylor_fm_eval.h"
18
#include "deriv1_quartet_data.h"
19
#include "small_fns.h"
21
void te_deriv1_print(void)
23
Libderiv_t Libderiv; /* Integrals library object */
25
double_array_t fjt_table; /* table of auxiliary function F_m(u) for each primitive combination */
29
int max_cart_class_size;
30
int max_num_prim_comb, num_prim_comb;
31
int max_num_unique_quartets;
32
int *sj_arr, *sk_arr, *sl_arr;
33
int usii, usjj, uskk, usll;
34
PSI_INT_LEAST64 quartet_index;
35
int sii, sjj, skk, sll;
36
int num_unique_quartets;
40
int switch_ij, switch_kl, switch_ijkl;
41
int np_i, np_j, np_k, np_l;
44
struct shell_pair *sp_ij, *sp_kl;
47
int si_fao, sj_fao, sk_fao, sl_fao;
48
int ao_i, ao_j, ao_k, ao_l;
50
int center_i, center_j, center_k, center_l;
51
int iout, jout, kout, lout;
59
/* some error checking up front */
60
if(Symmetry.nirreps > 1 || BasisSet.puream) {
61
fprintf(outfile, "\nThe derivative integral printing code will almost certainly fail\n");
62
fprintf(outfile, "for non-C1 and/or puream cases. Exiting.\n");
63
punt("no symmetry or puream cases allowed when printing deriv. ints.");
70
init_fjt_table(&fjt_table);
73
max_cart_class_size = ioff[BasisSet.max_am]*ioff[BasisSet.max_am]*ioff[BasisSet.max_am]*ioff[BasisSet.max_am];
74
max_class_size = max_cart_class_size;
75
max_num_prim_comb = (BasisSet.max_num_prims*BasisSet.max_num_prims)*
76
(BasisSet.max_num_prims*BasisSet.max_num_prims);
77
init_libderiv1(&Libderiv,BasisSet.max_am-1,max_num_prim_comb,max_class_size);
78
PrintFourInd = init_array(max_cart_class_size);
79
derivs = block_matrix(Molecule.num_atoms*3,max_cart_class_size);
80
out = (FILE **) malloc(Molecule.num_atoms * 3 * sizeof(FILE *));
82
for(i=0; i < Molecule.num_atoms*3; i++) {
83
sprintf(lbl,"eri%d.dat", i);
84
ffile(&out[i], lbl, 0);
87
max_num_unique_quartets = Symmetry.max_stab_index*
88
Symmetry.max_stab_index*
89
Symmetry.max_stab_index;
90
sj_arr = (int *)malloc(sizeof(int)*max_num_unique_quartets);
91
sk_arr = (int *)malloc(sizeof(int)*max_num_unique_quartets);
92
sl_arr = (int *)malloc(sizeof(int)*max_num_unique_quartets);
94
for (usii=0; usii<Symmetry.num_unique_shells; usii++)
95
for (usjj=0; usjj<Symmetry.num_unique_shells; usjj++)
96
for (uskk=0; uskk<Symmetry.num_unique_shells; uskk++)
97
for (usll=0; usll<Symmetry.num_unique_shells; usll++, quartet_index++){
99
sii = Symmetry.us2s[usii];
100
sjj = Symmetry.us2s[usjj];
101
skk = Symmetry.us2s[uskk];
102
sll = Symmetry.us2s[usll];
104
num_unique_quartets = 1;
109
/*----------------------------------
110
Compute the nonredundant quartets
111
----------------------------------*/
112
for(plquartet=0;plquartet<num_unique_quartets;plquartet++) {
113
si = Symmetry.us2s[usii];
114
sj = sj_arr[plquartet];
115
sk = sk_arr[plquartet];
116
sl = sl_arr[plquartet];
118
/*--- Skip this quartet if all four centers are the same ---*/
119
if (BasisSet.shells[si].center == BasisSet.shells[sj].center &&
120
BasisSet.shells[si].center == BasisSet.shells[sk].center &&
121
BasisSet.shells[si].center == BasisSet.shells[sl].center &&
128
/* place in "ascending" angular mom-
129
my simple way of optimizing PHG recursion (VRR) */
130
/* these first two are good for the HRR */
131
if(BasisSet.shells[si].am < BasisSet.shells[sj].am){
137
if(BasisSet.shells[sk].am < BasisSet.shells[sl].am){
143
/* this should be /good/ for the VRR */
144
if(BasisSet.shells[si].am + BasisSet.shells[sj].am > BasisSet.shells[sk].am + BasisSet.shells[sl].am){
154
ni = ioff[BasisSet.shells[si].am];
155
nj = ioff[BasisSet.shells[sj].am];
156
nk = ioff[BasisSet.shells[sk].am];
157
nl = ioff[BasisSet.shells[sl].am];
158
quartet_size = ni*nj*nk*nl;
160
np_i = BasisSet.shells[si].n_prims;
161
np_j = BasisSet.shells[sj].n_prims;
162
np_k = BasisSet.shells[sk].n_prims;
163
np_l = BasisSet.shells[sl].n_prims;
165
orig_am[0] = BasisSet.shells[si].am-1;
166
orig_am[1] = BasisSet.shells[sj].am-1;
167
orig_am[2] = BasisSet.shells[sk].am-1;
168
orig_am[3] = BasisSet.shells[sl].am-1;
169
am = orig_am[0] + orig_am[1] + orig_am[2] + orig_am[3];
171
sp_ij = &(BasisSet.shell_pairs[si][sj]);
172
sp_kl = &(BasisSet.shell_pairs[sk][sl]);
174
Libderiv.AB[0] = sp_ij->AB[0];
175
Libderiv.AB[1] = sp_ij->AB[1];
176
Libderiv.AB[2] = sp_ij->AB[2];
177
Libderiv.CD[0] = sp_kl->AB[0];
178
Libderiv.CD[1] = sp_kl->AB[1];
179
Libderiv.CD[2] = sp_kl->AB[2];
181
AB2 = Libderiv.AB[0]*Libderiv.AB[0]+
182
Libderiv.AB[1]*Libderiv.AB[1]+
183
Libderiv.AB[2]*Libderiv.AB[2];
184
CD2 = Libderiv.CD[0]*Libderiv.CD[0]+
185
Libderiv.CD[1]*Libderiv.CD[1]+
186
Libderiv.CD[2]*Libderiv.CD[2];
189
for (pi = 0; pi < np_i; pi++) {
190
for (pj = 0; pj < np_j; pj++) {
191
for (pk = 0; pk < np_k; pk++) {
192
for (pl = 0; pl < np_l; pl++){
194
deriv1_quartet_data(&(Libderiv.PrimQuartet[num_prim_comb++]),
196
sp_ij, sp_kl, am, pi, pj, pk, pl, 1);
198
deriv1_quartet_data(&(Libderiv.PrimQuartet[num_prim_comb++]),
199
&fjt_table, AB2, CD2,
200
sp_ij, sp_kl, am, pi, pj, pk, pl, 1);
207
si_fao = BasisSet.shells[si].fao-1;
208
sj_fao = BasisSet.shells[sj].fao-1;
209
sk_fao = BasisSet.shells[sk].fao-1;
210
sl_fao = BasisSet.shells[sl].fao-1;
212
for (ao_i = si_fao; ao_i < si_fao+ni; ao_i++)
213
for (ao_j = sj_fao; ao_j < sj_fao+nj; ao_j++)
214
for (ao_k = sk_fao; ao_k < sk_fao+nk; ao_k++)
215
for (ao_l = sl_fao; ao_l < sl_fao+nl; ao_l++) {
216
PrintFourInd[count] = GTOs.bf_norm[orig_am[0]][ao_i-si_fao] *
217
GTOs.bf_norm[orig_am[1]][ao_j-sj_fao] *
218
GTOs.bf_norm[orig_am[2]][ao_k-sk_fao] *
219
GTOs.bf_norm[orig_am[3]][ao_l-sl_fao];
223
build_deriv1_eri[orig_am[0]][orig_am[1]][orig_am[2]][orig_am[3]](&Libderiv,num_prim_comb);
225
center_i = BasisSet.shells[si].center-1;
226
center_j = BasisSet.shells[sj].center-1;
227
center_k = BasisSet.shells[sk].center-1;
228
center_l = BasisSet.shells[sl].center-1;
230
zero_mat(derivs, Molecule.num_atoms*3, max_cart_class_size);
231
for(k=0; k < quartet_size; k++) {
232
derivs[center_i*3+0][k] += Libderiv.ABCD[0][k] * PrintFourInd[k];
233
derivs[center_i*3+1][k] += Libderiv.ABCD[1][k] * PrintFourInd[k];
234
derivs[center_i*3+2][k] += Libderiv.ABCD[2][k] * PrintFourInd[k];
236
derivs[center_j*3+0][k] -= (Libderiv.ABCD[0][k] + Libderiv.ABCD[6][k] + Libderiv.ABCD[9][k]) * PrintFourInd[k];
237
derivs[center_j*3+1][k] -= (Libderiv.ABCD[1][k] + Libderiv.ABCD[7][k] + Libderiv.ABCD[10][k]) * PrintFourInd[k];
238
derivs[center_j*3+2][k] -= (Libderiv.ABCD[2][k] + Libderiv.ABCD[8][k] + Libderiv.ABCD[11][k]) * PrintFourInd[k];
240
derivs[center_k*3+0][k] += Libderiv.ABCD[6][k] * PrintFourInd[k];
241
derivs[center_k*3+1][k] += Libderiv.ABCD[7][k] * PrintFourInd[k];
242
derivs[center_k*3+2][k] += Libderiv.ABCD[8][k] * PrintFourInd[k];
244
derivs[center_l*3+0][k] += Libderiv.ABCD[9][k] * PrintFourInd[k];
245
derivs[center_l*3+1][k] += Libderiv.ABCD[10][k] * PrintFourInd[k];
246
derivs[center_l*3+2][k] += Libderiv.ABCD[11][k] * PrintFourInd[k];
249
for(k=0; k < Molecule.num_atoms*3; k++) {
251
for (ao_i = si_fao; ao_i < si_fao+ni; ao_i++)
252
for (ao_j = sj_fao; ao_j < sj_fao+nj; ao_j++)
253
for (ao_k = sk_fao; ao_k < sk_fao+nk; ao_k++)
254
for (ao_l = sl_fao; ao_l < sl_fao+nl; ao_l++) {
255
if(fabs(derivs[k][count]) > 1e-6) {
256
iout = ao_i; jout = ao_j; kout = ao_k; lout = ao_l;
257
if(switch_ijkl) { dum = iout; iout = kout; kout = dum; dum = jout; jout = lout; lout = dum; }
258
if(switch_kl) { dum = kout; kout = lout; lout = dum; }
259
if(switch_ij) { dum = iout; iout = jout; jout = dum; }
260
ij = INDEX(iout,jout); kl = INDEX(kout,lout);
261
if(iout >= jout && kout >= lout && ij >= kl)
262
fprintf(out[k], "%3d %3d %3d %3d %20.14f\n", iout, jout, kout, lout, derivs[k][count]);
269
} /* end of loop over symmetry unique quartets */
271
} /* end of unique shell loops */
277
for(i=0; i < Molecule.num_atoms*3; i++) fclose(out[i]);
280
free_libderiv(&Libderiv);
281
#ifndef USE_TAYLOR_FM
282
free_fjt_table(&fjt_table);