3
#include <libdpd/dpd.h>
4
#include <libciomr/libciomr.h>
9
/* LHX1Y1(): Computes the <0|L*(HBAR*X1*Y1)c |0> contributions to the
10
** linear response function. Note that most of the work is actually
11
** already done in other codes because the contractions may all be
12
** formulated in as products of X1*Y1 with L*HBAR, the latter of which
13
** are referred to in this code as "lambda residuals".
15
** Type-I residuals are taken directly from cclambda: L2*D, L2*Wmnij,
16
** L2*Wabef, L2*Wamef, L2*Wmnie, and L2*three-body-terms.
18
** Type-II residuals are computed once in lambda_residuals(): L1*Fme
24
void build_XY(char *, char *, int, double, char *, char *, int, double);
26
double LHX1Y1(char *pert_x, char *cart_x, int irrep_x, double omega_x,
27
char *pert_y, char *cart_y, int irrep_y, double omega_y)
30
dpdfile2 F, X1, Y1, Zmi, Zae_1, Zae_2, Zfb, Znj, ZIA, L1, t1, z;
31
dpdbuf4 Z1, Z2, I, tau, W1, W2, ZIjAb, L2, T2, W, Z;
32
double polar, polar_I, polar_II;
34
int Gbm, Gfe, bm, b, m, Gb, Gm, Ge, Gf, B, M, fe, f, e, ef, nrows, ncols;
37
build_XY(pert_x, cart_x, irrep_x, omega_x, pert_y, cart_y, irrep_y, omega_y);
39
/* Type-I L2 residual */
40
dpd_buf4_init(&L2, CC_LAMPS, 0, 0, 5, 0, 5, 0, "LHX1Y1 I (2 Lijab - Lijba)");
41
dpd_buf4_init(&Z1, CC_TMP0, 0, 0, 5, 0, 5, 0, "X*Y(ij,ab)");
42
polar_I = 2.0 * dpd_buf4_dot(&L2, &Z1);
46
/* Type-II L2 residual */
47
dpd_buf4_init(&L2, CC_LAMPS, 0, 10, 10, 10, 10, 0, "LHX1Y1 Residual II");
48
dpd_buf4_init(&Z1, CC_TMP0, 0, 10, 10, 10, 10, 0, "(X*Y+Y*X)(ie,ma)");
49
polar_II = -2.0 * dpd_buf4_dot(&L2, &Z1);
53
return polar_I+polar_II;
56
/* build_XY(): Compute products of X1 and Y1 for the
57
** <0|L*(HBAR*X1*Y1)|0> part of the response function.
59
** For the Type-I residuals:
60
** X*Y(ij,ab) = X(i,a) * Y(j,b)
62
** For the Type-II residuals:
63
** (X*Y+Y*X)(ie,ma) = [X(i,e) * Y(m,a) + X(m,a) * Y(i,e)]
68
void build_XY(char *pert_x, char *cart_x, int irrep_x, double omega_x,
69
char *pert_y, char *cart_y, int irrep_y, double omega_y)
71
int h, row, col, i, j, m, e, f, a, I, J, M, E, F, A, ij, ef;
72
int Isym, Jsym, Msym, Esym, Fsym, Asym;
78
nirreps = moinfo.nirreps;
80
sprintf(lbl, "X_%s_%1s_IA (%5.3f)", pert_y, cart_y, omega_y);
81
dpd_file2_init(&Y1, CC_OEI, irrep_y, 0, 1, lbl);
82
dpd_file2_mat_init(&Y1);
83
dpd_file2_mat_rd(&Y1);
85
sprintf(lbl, "X_%s_%1s_IA (%5.3f)", pert_x, cart_x, omega_x);
86
dpd_file2_init(&X1, CC_OEI, irrep_x, 0, 1, lbl);
87
dpd_file2_mat_init(&X1);
88
dpd_file2_mat_rd(&X1);
90
dpd_buf4_init(&Z, CC_TMP0, 0, 0, 5, 0, 5, 0, "X*Y(ij,ab)");
91
dpd_buf4_scm(&Z, 0.0);
92
for(h=0; h< nirreps; h++) {
93
dpd_buf4_mat_irrep_init(&Z, h);
94
for(row=0; row < Z.params->rowtot[h]; row++) {
95
i = Z.params->roworb[h][row][0];
96
j = Z.params->roworb[h][row][1];
97
I = X1.params->rowidx[i];
98
J = Y1.params->rowidx[j];
99
Isym = X1.params->psym[i];
100
Jsym = Y1.params->psym[j];
101
for(col=0; col < Z.params->coltot[h]; col++) {
102
e = Z.params->colorb[h][col][0];
103
f = Z.params->colorb[h][col][1];
104
E = X1.params->colidx[e];
105
F = Y1.params->colidx[f];
106
Esym = X1.params->qsym[e];
107
Fsym = Y1.params->qsym[f];
108
if((Isym^Esym)==irrep_x && (Jsym^Fsym)==irrep_y)
109
Z.matrix[h][row][col] = (X1.matrix[Isym][I][E] * Y1.matrix[Jsym][J][F]);
112
dpd_buf4_mat_irrep_wrt(&Z, h);
113
dpd_buf4_mat_irrep_close(&Z, h);
117
dpd_buf4_init(&Z, CC_TMP0, 0, 10, 10, 10, 10, 0, "(X*Y+Y*X)(ie,ma)");
118
dpd_buf4_scm(&Z, 0.0);
119
for(h=0; h< nirreps; h++) {
120
dpd_buf4_mat_irrep_init(&Z, h);
121
for(row=0; row < Z.params->rowtot[h]; row++) {
122
i = Z.params->roworb[h][row][0];
123
e = Z.params->roworb[h][row][1];
124
I = X1.params->rowidx[i];
125
E = X1.params->colidx[e];
126
Isym = X1.params->psym[i];
127
Esym = X1.params->qsym[e];
128
for(col=0; col < Z.params->coltot[h]; col++) {
129
m = Z.params->colorb[h][col][0];
130
a = Z.params->colorb[h][col][1];
131
M = Y1.params->rowidx[m];
132
A = Y1.params->colidx[a];
133
Msym = Y1.params->psym[m];
134
Asym = Y1.params->qsym[a];
136
if(((Isym^Esym)==irrep_x) && ((Msym^Asym)==irrep_y))
137
Z.matrix[h][row][col] =
138
(X1.matrix[Isym][I][E] * Y1.matrix[Msym][M][A]) +
139
(Y1.matrix[Isym][I][E] * X1.matrix[Msym][M][A]);
142
dpd_buf4_mat_irrep_wrt(&Z, h);
143
dpd_buf4_mat_irrep_close(&Z, h);
147
dpd_file2_mat_close(&X1);
148
dpd_file2_close(&X1);
149
dpd_file2_mat_close(&Y1);
150
dpd_file2_close(&Y1);