1
/*----------------------------------------------------
7
The code contains functions that will retrieve
8
and process the density at a given x,y,z coord
11
--------------------------------------------------*/
15
#include <libipv1/ip_lib.h>
16
#include <libciomr/libciomr.h>
18
#include <libint/libint.h>
23
#include"bas_comp_functions.h"
25
struct den_info_s calc_density_fast(struct coordinates geom, int atom_num){
46
double *coord_array[14];
48
double norm_ptr0,norm_ptr1,norm_ptr2;
49
double norm_ptr3,norm_ptr4,norm_ptr5;
50
double norm_ptr6,norm_ptr7,norm_ptr8;
51
double norm_ptr9,norm_ptr10,norm_ptr11;
52
double norm_ptr12,norm_ptr13,norm_ptr14;
53
double xx,yy,zz,xy,xz,yz;
54
double bxx,byy,bzz,bxy,bxz,byz;
57
struct coordinates *dist_coord;
58
struct leb_chunk_s *chunk;
59
struct den_info_s den_info;
60
struct close_shell_info_s *close;
66
num_ao = BasisSet.num_ao;
68
temp_arr = init_array(ndocc);
69
close = &(DFT_options.close_shell_info);
70
/* ---------------------------------
71
Compute distances from atom that
72
the basis function is centered on
74
--------------------------------*/
75
zero_arr(DFT_options.basis,num_ao);
76
dist_atom = init_array(Molecule.num_atoms);
77
dist_coord = (struct coordinates *)
78
malloc(sizeof(struct coordinates)*Molecule.num_atoms);
80
for(i=0;i<Molecule.num_atoms;i++){
81
dist_coord[i].x = x-Molecule.centers[i].x;
82
dist_coord[i].y = y-Molecule.centers[i].y;
83
dist_coord[i].z = z-Molecule.centers[i].z;
84
dist_atom[i] = dist_coord[i].x*dist_coord[i].x
85
+dist_coord[i].y*dist_coord[i].y
86
+dist_coord[i].z*dist_coord[i].z;
89
n_shells = BasisSet.num_shells;
90
timer_off("distance");
95
for(i=0;i<BasisSet.max_am;i++){
97
norm_ptr = GTOs.bf_norm[i];
101
/* ------------------------------------------------------*/
102
/* S-type functions */
105
norm_ptr0 = norm_ptr[0];
106
for(j=0;j<close->close_shells_per_am[i];j++){
108
am2shell = close->shells_close_to_chunk[m];
109
shell_center = BasisSet.shells[am2shell].center-1;
110
xa = dist_coord[shell_center].x;
111
ya = dist_coord[shell_center].y;
112
za = dist_coord[shell_center].z;
113
rr = dist_atom[shell_center];
115
shell_start = BasisSet.shells[am2shell].fprim-1;
116
shell_end = shell_start
117
+BasisSet.shells[am2shell].n_prims;
120
timer_on("exponent");
123
/*bastmp = calc_exp_basis(am2shell,rr);*/
124
for(k=shell_start;k<shell_end;k++){
125
expon = -BasisSet.cgtos[k].exp;
126
coeff = BasisSet.cgtos[k].ccoeff[shell_type];
127
bastmp += coeff*exp(expon*rr);
131
timer_off("exponent");
133
DFT_options.basis[l] = norm_ptr0*bastmp;
140
/* ------------------------------------------------------*/
143
/* ------------------------------------------------------*/
144
/* P-type functions */
147
norm_ptr0 = norm_ptr[0];
148
norm_ptr1 = norm_ptr[1];
149
norm_ptr2 = norm_ptr[2];
151
for(j=0;j<close->close_shells_per_am[i];j++){
153
am2shell = close->shells_close_to_chunk[m];
154
shell_center = BasisSet.shells[am2shell].center-1;
156
xa = dist_coord[shell_center].x;
157
ya = dist_coord[shell_center].y;
158
za = dist_coord[shell_center].z;
159
rr = dist_atom[shell_center];
161
shell_start = BasisSet.shells[am2shell].fprim-1;
162
shell_end = shell_start
163
+BasisSet.shells[am2shell].n_prims;
166
timer_on("exponent");
168
for(k=shell_start;k<shell_end;k++){
169
expon = -BasisSet.cgtos[k].exp*rr;
170
coeff = BasisSet.cgtos[k].ccoeff[shell_type];
171
bastmp += coeff*exp(expon);
175
timer_off("exponent");
177
DFT_options.basis[l] = norm_ptr0*bastmp*xa;
180
DFT_options.basis[l] = norm_ptr1*bastmp*ya;
183
DFT_options.basis[l] = norm_ptr2*bastmp*za;
188
/* ------------------------------------------------------*/
190
/* ------------------------------------------------------*/
191
/* D-type functions */
194
norm_ptr0 = norm_ptr[0];
195
norm_ptr1 = norm_ptr[1];
196
norm_ptr2 = norm_ptr[2];
197
norm_ptr3 = norm_ptr[3];
198
norm_ptr4 = norm_ptr[4];
199
norm_ptr5 = norm_ptr[5];
200
for(j=0;j<close->close_shells_per_am[i];j++){
201
am2shell = close->shells_close_to_chunk[m];
202
shell_center = BasisSet.shells[am2shell].center-1;
203
xa = dist_coord[shell_center].x;
204
ya = dist_coord[shell_center].y;
205
za = dist_coord[shell_center].z;
206
rr = dist_atom[shell_center];
208
shell_start = BasisSet.shells[am2shell].fprim-1;
209
shell_end = shell_start
210
+BasisSet.shells[am2shell].n_prims;
213
timer_on("exponent");
215
for(k=shell_start;k<shell_end;k++){
216
expon = -BasisSet.cgtos[k].exp*rr;
217
coeff = BasisSet.cgtos[k].ccoeff[shell_type];
218
bastmp += coeff*exp(expon);
221
timer_off("exponent");
223
DFT_options.basis[l] = norm_ptr0*bastmp*xa*xa;
226
DFT_options.basis[l] = norm_ptr1*bastmp*xa*ya;
229
DFT_options.basis[l] = norm_ptr2*bastmp*xa*za;
232
DFT_options.basis[l] = norm_ptr3*bastmp*ya*ya;
235
DFT_options.basis[l] = norm_ptr4*bastmp*ya*za;
238
DFT_options.basis[l] = norm_ptr5*bastmp*za*za;
243
/* ------------------------------------------------------*/
245
/* ------------------------------------------------------*/
246
/* F-type functions */
249
norm_ptr0 = norm_ptr[0];
250
norm_ptr1 = norm_ptr[1];
251
norm_ptr2 = norm_ptr[2];
252
norm_ptr3 = norm_ptr[3];
253
norm_ptr4 = norm_ptr[4];
254
norm_ptr5 = norm_ptr[5];
255
norm_ptr6 = norm_ptr[6];
256
norm_ptr7 = norm_ptr[7];
257
norm_ptr8 = norm_ptr[8];
258
norm_ptr9 = norm_ptr[9];
260
for(j=0;j<close->close_shells_per_am[i];j++){
261
am2shell = close->shells_close_to_chunk[m];
262
shell_center = BasisSet.shells[am2shell].center-1;
263
xa = dist_coord[shell_center].x;
264
ya = dist_coord[shell_center].y;
265
za = dist_coord[shell_center].z;
266
rr = dist_atom[shell_center];
278
shell_start = BasisSet.shells[am2shell].fprim-1;
279
shell_end = shell_start
280
+BasisSet.shells[am2shell].n_prims;
283
timer_on("exponent");
285
for(k=shell_start;k<shell_end;k++){
286
expon = -BasisSet.cgtos[k].exp*rr;
287
coeff = BasisSet.cgtos[k].ccoeff[shell_type];
288
bastmp += coeff*exp(expon);
290
timer_off("exponent");
292
DFT_options.basis[l] = norm_ptr0*bxx*xa;
295
DFT_options.basis[l] = norm_ptr1*bxx*ya;
298
DFT_options.basis[l] = norm_ptr2*bxx*za;
301
DFT_options.basis[l] = norm_ptr3*byy*xa;
304
DFT_options.basis[l] = norm_ptr4*bxy*za;
307
DFT_options.basis[l] = norm_ptr5*bzz*xa;
310
DFT_options.basis[l] = norm_ptr6*byy*ya;
313
DFT_options.basis[l] = norm_ptr7*byy*za;
316
DFT_options.basis[l] = norm_ptr8*bzz*ya;
319
DFT_options.basis[l] = norm_ptr9*bzz*za;
326
/* ------------------------------------------------------*/
328
/* ------------------------------------------------------*/
329
/* G-type functions */
331
norm_ptr0 = norm_ptr[0];
332
norm_ptr1 = norm_ptr[1];
333
norm_ptr2 = norm_ptr[2];
334
norm_ptr3 = norm_ptr[3];
335
norm_ptr4 = norm_ptr[4];
336
norm_ptr5 = norm_ptr[5];
337
norm_ptr6 = norm_ptr[6];
338
norm_ptr7 = norm_ptr[7];
339
norm_ptr8 = norm_ptr[8];
340
norm_ptr9 = norm_ptr[9];
341
norm_ptr10 = norm_ptr[10];
342
norm_ptr11 = norm_ptr[11];
343
norm_ptr12 = norm_ptr[12];
344
norm_ptr13 = norm_ptr[13];
345
norm_ptr14 = norm_ptr[14];
346
for(j=0;j<close->close_shells_per_am[i];j++){
347
am2shell = close->shells_close_to_chunk[m];
348
shell_center = BasisSet.shells[am2shell].center-1;
349
xa = dist_coord[shell_center].x;
350
ya = dist_coord[shell_center].y;
351
za = dist_coord[shell_center].z;
352
rr = dist_atom[shell_center];
354
shell_start = BasisSet.shells[am2shell].fprim-1;
355
shell_end = shell_start
356
+BasisSet.shells[am2shell].n_prims;
359
timer_on("exponent");
361
for(k=shell_start;k<shell_end;k++){
362
expon = -BasisSet.cgtos[k].exp;
363
coeff = BasisSet.cgtos[k].ccoeff[shell_type];
364
bastmp += coeff*exp(expon*rr);
366
timer_off("exponent");
367
DFT_options.basis[l] = norm_ptr0*bastmp*xa*xa*xa*xa;
370
DFT_options.basis[l] = norm_ptr1*bastmp*xa*xa*xa*ya;
373
DFT_options.basis[l] = norm_ptr2*bastmp*xa*xa*xa*za;
376
DFT_options.basis[l] = norm_ptr3*bastmp*xa*xa*ya*ya;
379
DFT_options.basis[l] = norm_ptr4*bastmp*xa*xa*ya*za;
382
DFT_options.basis[l] = norm_ptr5*bastmp*xa*xa*za*za;
385
DFT_options.basis[l] = norm_ptr6*bastmp*xa*ya*ya*ya;
388
DFT_options.basis[l] = norm_ptr7*bastmp*xa*ya*ya*za;
391
DFT_options.basis[l] = norm_ptr8*bastmp*xa*ya*za*za;
394
DFT_options.basis[l] = norm_ptr9*bastmp*xa*za*za*za;
397
DFT_options.basis[l] = norm_ptr10*bastmp*ya*ya*ya*ya;
400
DFT_options.basis[l] = norm_ptr11*bastmp*ya*ya*ya*za;
403
DFT_options.basis[l] = norm_ptr12*bastmp*ya*ya*za*za;
406
DFT_options.basis[l] = norm_ptr13*bastmp*ya*za*za*za;
409
DFT_options.basis[l] = norm_ptr14*bastmp*za*za*za*za;
417
fprintf(stderr,"Basis Functions of Angular Momentum \n \
418
%d not implemented in get_density function",shell_type);
419
fprintf(outfile,"Basis Functions of Angular Momentum \n \
420
%d not implemented in get_density function",shell_type);
426
/* Now contract the basis functions with the AO density matrix elements */
428
/*for(i=0;i<close->num_close_aos;i++)
429
fprintf(outfile,"\nBasis[%d] = %10.10lf",i,DFT_options.basis[i]);*/
433
C_DGEMV('t',close->num_close_aos,ndocc,1.0,close->close_COCC[0],ndocc,
434
DFT_options.basis,1,0.0,temp_arr,1);
435
den_sum = C_DDOT(ndocc,temp_arr,1,temp_arr,1);
437
for(i=0;i<ndocc;i++){
438
for(j=0;j<close->num_close_aos;j++){
439
temp_arr[i] += close->close_COCC[j][i]*DFT_options.basis[j];
441
/*fprintf(outfile,"\ntemp_arr[%d] = %10.10lf",i,temp_arr[i]);*/
443
dot_arr(temp_arr,temp_arr,MOInfo.ndocc,&den_sum);
445
den_info.den = den_sum;
446
/*fprintf(outfile,"\nden = %10.10lf",den_info.den);*/
450
timer_off("density");