4
** Routine for computing the expectation value of S^2.
5
** Useful for determining if spin-contamination (due to the davidson
6
** procedure) is a problem.
14
#include <libciomr/libciomr.h>
19
#define MIN0(a,b) (((a)<(b)) ? (a) : (b))
20
#define MAX0(a,b) (((a)>(b)) ? (a) : (b))
21
#define INDEX(i,j) ((i>j) ? (ioff[(i)]+(j)) : (ioff[(j)]+(i)))
27
** Calculates the expectation value of S^2.
30
double ssq(struct stringwr *alplist, struct stringwr *betlist,
31
double **CL, double **CR, int nas, int nbs,
32
int Ja_list, int Jb_list)
34
struct stringwr *Ia, *Ib ;
35
unsigned int Ia_ex, Ib_ex;
39
int ij, ji, i1, j1, i2, j2;
40
double tval, Ms, S2, smin_spls = 0.0;
42
int Iacnt, Jbcnt, *Iaij, *Ibij;
43
unsigned int *Iaridx, *Ibridx;
44
signed char *Iasgn, *Ibsgn;
46
/* <S^2> = <S_z> + <S_z>^2 + <S_S+> */
47
/* First determine the expection value of <S_S+> */
51
fprintf(outfile,"number of alpha strings = %d\n",nas);
53
for (Ia=alplist,Ia_idx=0; Ia_idx < nas; Ia_idx++,Ia++) {
55
/* loop over excitations E^a_{ji} from |A(I_a)> */
56
Iacnt = Ia->cnt[Ja_list];
57
Iaridx = Ia->ridx[Ja_list];
58
Iasgn = Ia->sgn[Ja_list];
59
Iaij = Ia->oij[Ja_list];
60
for (Ia_ex=0; Ia_ex < Iacnt; Ia_ex++) {
64
i1 = ji/CalcInfo.num_ci_orbs;
65
j1 = ji%CalcInfo.num_ci_orbs;
69
fprintf(outfile,"number of beta strings = %d\n",nbs);
71
for (Ib=betlist, Ib_idx=0; Ib_idx < nbs; Ib_idx++, Ib++) {
73
/* loop over excitations E^b_{ij} from |B(I_b)> */
74
Jbcnt = Ib->cnt[Jb_list];
75
Ibridx = Ib->ridx[Jb_list];
76
Ibsgn = Ib->sgn[Jb_list];
77
Ibij = Ib->oij[Jb_list];
80
for (Ib_ex=0; Ib_ex < Jbcnt; Ib_ex++) {
84
i2 = ij/CalcInfo.num_ci_orbs;
85
j2 = ij%CalcInfo.num_ci_orbs;
86
if (i1!=j2 || i2!=j1) continue;
87
tval += CR[Ia_idx][Ib_idx] * CL[Ja_idx][Jb_idx] *
88
(double) Ja_sgn * (double) Jb_sgn;
90
fprintf(outfile,"\n\nIa_idx = %d\n",Ia_idx);
91
fprintf(outfile,"Ib_idx = %d\n",Ib_idx);
92
fprintf(outfile,"Ja_idx = %d\n",Ja_idx);
93
fprintf(outfile,"Jb_idx = %d\n",Jb_idx);
94
fprintf(outfile,"tval_ssq = %lf\n",-tval);
95
fprintf(outfile,"CR = %lf\n",CR[Ia_idx][Ib_idx]);
96
fprintf(outfile,"LR = %lf\n",CL[Ja_idx][Jb_idx]);
97
fprintf(outfile,"Ja_sgn = %lf\n",Ja_sgn);
98
fprintf(outfile,"Jb_sgn = %lf\n",Jb_sgn);
103
} /* end loop over Ib */
104
} /* end loop over Ia excitations */
105
} /* end loop over Ia */