2
** phi(): Compute the values of the atomic orbitals at a given point.
9
#include <libipv1/ip_lib.h>
10
#include <libciomr/libciomr.h>
11
#include <libchkpt/chkpt.h>
12
#include <libint/libint.h> /* for the maximum angluar momentum, LIBINT_MAX_AM */
17
int nao, natom, nprim, nshell;
18
int *stype, *snuc, *snumg, *sprim;
19
double *a, *c, **geom, df[MAXFACT], **norm;
20
int **xexp, **yexp, **zexp, *l_length;
29
chkpt_init(PSIO_OPEN_OLD);
31
natom = chkpt_rd_natom();
32
nprim = chkpt_rd_nprim();
33
nshell = chkpt_rd_nshell();
34
stype = chkpt_rd_stype();
35
snuc = chkpt_rd_snuc();
36
snumg = chkpt_rd_snumg();
37
sprim = chkpt_rd_sprim();
40
geom = chkpt_rd_geom();
43
/* compute double factorial --- df[n] = (n-1)!! */
44
df[0] = 1.0; df[1] = 1.0; df[2] = 1.0;
45
for(i=3; i < MAXFACT; i++) df[i] = (i-1) * df[i-2];
47
/* Compute the AO ordering within a shell and the angle-independent
48
normalization contants */
49
xexp = (int **) malloc(LIBINT_MAX_AM * sizeof(int *));
50
yexp = (int **) malloc(LIBINT_MAX_AM * sizeof(int *));
51
zexp = (int **) malloc(LIBINT_MAX_AM * sizeof(int *));
52
norm = (double **) malloc(LIBINT_MAX_AM * sizeof(double *));
53
l_length = init_int_array(LIBINT_MAX_AM);
55
for(l=0; l < (LIBINT_MAX_AM); l++) {
57
if(l) l_length[l] = l_length[l-1] + l + 1;
59
xexp[l] = init_int_array(l_length[l]);
60
yexp[l] = init_int_array(l_length[l]);
61
zexp[l] = init_int_array(l_length[l]);
62
norm[l] = init_array(l_length[l]);
64
for(i=0,ao=0; i <= l; i++) {
66
for(j=0; j <= i; j++) {
72
norm[l][ao] = sqrt(df[2*l]/(df[2*(l-i)]*df[2*(i-j)]*df[2*j]));
74
/* printf("%d %d %20.10f\n", l, ao, norm[l][ao]); */
85
void compute_phi(double *phi, double x, double y, double z)
87
int i, j, l, firstp, lastp;
89
double cexpr, dx, dy, dz, rr;
93
/* Loop over the shells */
94
for(i=0,ao=0; i < nshell; i++) {
97
lastp = firstp + snumg[i];
100
dx = x - geom[atom][0];
101
dy = y - geom[atom][1];
102
dz = z - geom[atom][2];
104
/* Compute r^2 for this center */
105
rr = dx*dx + dy*dy + dz*dz;
107
/* Angular momentum level for this shell */
110
if(am > LIBINT_MAX_AM) {
111
printf("Angular momentum max. exceeded.\n");
112
exit(PSI_RETURN_FAILURE);
115
/* Loop over the primitive Gaussians in this shell */
117
for(j=firstp; j < lastp; j++) {
118
cexpr += c[j] * exp(-a[j] * rr);
121
for(l=0; l < l_length[am]; l++) {
122
phi[ao+l] += pow(dx,(double) xexp[am][l]) *
123
pow(dy,(double) yexp[am][l]) *
124
pow(dz,(double) zexp[am][l]) *