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(struct coordinates geom){
47
struct coordinates *dist_coord;
48
struct den_info_s den_info;
49
struct shell_pair *sp;
55
num_ao = BasisSet.num_ao;
57
temp_arr = init_array(num_ao);
58
dist_atom = init_array(Molecule.num_atoms);
59
dist_coord = (struct coordinates *)malloc(sizeof(struct coordinates)*Molecule.num_atoms);
61
for(i=0;i<Molecule.num_atoms;i++){
62
dist_coord[i].x = x-Molecule.centers[i].x;
63
dist_coord[i].y = y-Molecule.centers[i].y;
64
dist_coord[i].z = z-Molecule.centers[i].z;
65
dist_atom[i] = dist_coord[i].x*dist_coord[i].x
66
+dist_coord[i].y*dist_coord[i].y
67
+dist_coord[i].z*dist_coord[i].z;
69
n_shells = BasisSet.num_shells;
70
timer_off("distance");
72
for(i=k=0;i<n_shells;i++){
74
shell_type = BasisSet.shells[i].am;
75
shell_center = BasisSet.shells[i].center-1;
76
xa = dist_coord[shell_center].x;
77
ya = dist_coord[shell_center].y;
78
za = dist_coord[shell_center].z;
79
rr = dist_atom[shell_center];
82
shell_start = BasisSet.shells[i].fprim-1;
83
shell_end = shell_start+BasisSet.shells[i].n_prims;
85
norm_ptr = GTOs.bf_norm[shell_type-1];
87
/*bastmp1 = calc_exp_basis(i,rr);*/
90
for(j=shell_start;j<shell_end;j++){
91
expon = -BasisSet.cgtos[j].exp;
92
coeff = BasisSet.cgtos[j].ccoeff[shell_type-1];
93
bastmp += coeff*exp(expon*rr);
95
/*if(bastmp != bastmp1)
96
fprintf(outfile,"\nbastmp1 = %10.15lf bastmp2 = %10.15lf for shell %d at rr = %e",bastmp1,bastmp,i,rr);*/
97
timer_off("exponent");
98
/*----------------------------------
99
Compute values of basis functions
101
NOTE: using Psi 3 ordering of
102
functions within shells
103
----------------------------------*/
104
switch (shell_type) {
107
DFT_options.basis[k] = norm_ptr[0]*bastmp;
112
DFT_options.basis[k] = norm_ptr[0]*bastmp*xa;
115
DFT_options.basis[k] = norm_ptr[1]*bastmp*ya;
118
DFT_options.basis[k] = norm_ptr[2]*bastmp*za;
122
DFT_options.basis[k] = norm_ptr[0]*bastmp*xa*xa;
125
DFT_options.basis[k] = norm_ptr[1]*bastmp*xa*ya;
128
DFT_options.basis[k] = norm_ptr[2]*bastmp*xa*za;
131
DFT_options.basis[k] = norm_ptr[3]*bastmp*ya*ya;
134
DFT_options.basis[k] = norm_ptr[4]*bastmp*ya*za;
137
DFT_options.basis[k] = norm_ptr[5]*bastmp*za*za;
141
DFT_options.basis[k] = norm_ptr[0]*bastmp*xa*xa*xa;
144
DFT_options.basis[k] = norm_ptr[1]*bastmp*xa*xa*ya;
147
DFT_options.basis[k] = norm_ptr[2]*bastmp*xa*xa*za;
150
DFT_options.basis[k] = norm_ptr[3]*bastmp*xa*ya*ya;
153
DFT_options.basis[k] = norm_ptr[4]*bastmp*xa*ya*za;
156
DFT_options.basis[k] = norm_ptr[5]*bastmp*xa*za*za;
159
DFT_options.basis[k] = norm_ptr[6]*bastmp*ya*ya*ya;
162
DFT_options.basis[k] = norm_ptr[7]*bastmp*ya*ya*za;
165
DFT_options.basis[k] = norm_ptr[8]*bastmp*ya*za*za;
168
DFT_options.basis[k] = norm_ptr[9]*bastmp*za*za*za;
172
DFT_options.basis[k] = norm_ptr[0]*bastmp*xa*xa*xa*xa;
175
DFT_options.basis[k] = norm_ptr[1]*bastmp*xa*xa*xa*ya;
178
DFT_options.basis[k] = norm_ptr[2]*bastmp*xa*xa*xa*za;
181
DFT_options.basis[k] = norm_ptr[3]*bastmp*xa*xa*ya*ya;
184
DFT_options.basis[k] = norm_ptr[4]*bastmp*xa*xa*ya*za;
187
DFT_options.basis[k] = norm_ptr[5]*bastmp*xa*xa*za*za;
190
DFT_options.basis[k] = norm_ptr[6]*bastmp*xa*ya*ya*ya;
193
DFT_options.basis[k] = norm_ptr[7]*bastmp*xa*ya*ya*za;
196
DFT_options.basis[k] = norm_ptr[8]*bastmp*xa*ya*za*za;
199
DFT_options.basis[k] = norm_ptr[9]*bastmp*xa*za*za*za;
202
DFT_options.basis[k] = norm_ptr[10]*bastmp*ya*ya*ya*ya;
205
DFT_options.basis[k] = norm_ptr[11]*bastmp*ya*ya*ya*za;
208
DFT_options.basis[k] = norm_ptr[12]*bastmp*ya*ya*za*za;
211
DFT_options.basis[k] = norm_ptr[13]*bastmp*ya*za*za*za;
214
DFT_options.basis[k] = norm_ptr[14]*bastmp*za*za*za*za;
218
fprintf(stderr,"Basis Functions of Angular Momentum %d not implemented in get_density function",shell_type);
219
fprintf(outfile,"Basis Functions of Angular Momentum %d not implemented in get_density function",shell_type);
225
/* Now contract the basis functions with the AO density matrix elements */
228
if(UserOptions.reftype == rhf){
231
C_DGEMV('t',num_ao,ndocc,1.0,Cocc[0],ndocc,
232
DFT_options.basis,1,0.0,temp_arr,1);
234
den_sum = C_DDOT(ndocc,temp_arr,1,temp_arr,1);
236
for(i=0;i<ndocc;i++){
237
for(j=0;j<num_ao;j++){
238
temp_arr[i] += Cocc[j][i]*DFT_options.basis[j];
242
dot_arr(temp_arr,temp_arr,MOInfo.ndocc,&den_sum);
244
den_info.den = den_sum;
248
timer_off("density");