3
#include <libdpd/dpd.h>
8
/* Wabei_RHF_FT2_a(): Computes the following contribution to the Wabei HBAR
9
** matrix elements for RHF references:
11
** Z_aeib = <am|ef> [ 2 t_mi^fb - t_mi^bf ] - <mf|ae> t_mi^fb
13
** This is the final term of the Wabef HBAR element's contribution to Wabei.
14
** [cf. Gauss and Stanton, JCP 103, 3561-3577 (1995).]
19
void Wabei_RHF_FT2_a(void)
23
int Gef, Gmf, Ge, Gf, Gae;
24
int a, A, e, E, m, M, f, FF;
26
int *virtpi, *vir_off, *occpi, *occ_off;
31
nirreps = moinfo.nirreps;
32
virtpi = moinfo.virtpi;
33
vir_off = moinfo.vir_off;
35
occ_off = moinfo.occ_off;
37
/* Zaeib <-- - <mf|ae> t_mi^fb */
38
/**** this contraction still requires storage of a full <ia|bc> set *****/
39
dpd_buf4_init(&F, CC_FINTS, 0, 10, 5, 10, 5, 0, "F <ia|bc>");
40
dpd_buf4_init(&T2, CC_TAMPS, 0, 10, 10, 10, 10, 0, "tIAjb");
41
dpd_buf4_init(&Z, CC_TMP2, 0, 5, 10, 5, 10, 0, "Z(AE,ib)");
42
dpd_contract444(&F, &T2, &Z, 1, 1, -1, 0);
47
/* Zaeib <-- <am|ef> [ 2 t_mi^fb - t_mi^bf ] */
49
dpd_buf4_init(&Z, CC_TMP2, 0, 5, 10, 5, 10, 0, "Z(AE,ib)");
50
dpd_buf4_init(&F, CC_FINTS, 0, 11, 5, 11, 5, 0, "F <ai|bc>");
51
dpd_buf4_init(&T2, CC_TAMPS, 0, 10, 10, 10, 10, 0, "2 tIAjb - tIBja");
52
for(h=0; h < nirreps; h++) {
53
dpd_buf4_mat_irrep_init(&T2, h);
54
dpd_buf4_mat_irrep_rd(&T2, h);
57
W = (double ***) malloc(nirreps * sizeof(double **));
59
for(Ga=0; Ga < nirreps; Ga++) {
61
/* allocate space for the input integrals */
62
for(Gm=0; Gm < nirreps; Gm++) {
64
F.matrix[Gam] = dpd_block_matrix(occpi[Gm], F.params->coltot[Gam]);
67
/* allocate space for the reordered integrals, W[e][mf] and target, Z[e][ib] */
68
for(Ge=0; Ge < nirreps; Ge++) {
69
Gae = Ga^Ge; Gmf = Gae;
70
W[Ge] = dpd_block_matrix(virtpi[Ge], Z.params->coltot[Gmf]);
71
Z.matrix[Gae] = dpd_block_matrix(virtpi[Ge], Z.params->coltot[Gmf]);
74
for(a=0; a < virtpi[Ga]; a++) {
77
for(Gm=0; Gm < nirreps; Gm++) {
81
/* read all <am|ef> integrals for given orbital index a --> F[m][ef] */
82
dpd_buf4_mat_irrep_rd_block(&F, Gam, F.params->start13[Gam][A], occpi[Gm]);
85
for(Ge=0; Ge < nirreps; Ge++) {
86
Gae = Ga^Ge; Gmf = Gae;
88
/* sort F[m][ef] --> W[e][mf] */
89
for(e=0; e < virtpi[Ge]; e++) {
92
for(Gm=0; Gm < nirreps; Gm++) {
96
for(m=0; m < occpi[Gm]; m++) {
99
for(f=0; f < virtpi[Gf]; f++) {
100
FF = vir_off[Gf] + f;
102
mf = Z.params->colidx[M][FF];
103
am = F.params->rowidx[A][M];
104
ef = F.params->colidx[E][FF];
106
W[Ge][e][mf] = F.matrix[Gam][am-F.params->start13[Gam][A]][ef];
112
/* read all existing Z(ae,ib) for a given orbital index a --> Z[e][ib] */
113
dpd_buf4_mat_irrep_rd_block(&Z, Gae, Z.params->start13[Gae][A], virtpi[Ge]);
115
/* contract W[e][mf] * T[mf][ib] -> Z[e][ib] */
116
if(virtpi[Ge] && Z.params->coltot[Gmf])
117
C_DGEMM('n','n', virtpi[Ge], Z.params->coltot[Gmf], Z.params->coltot[Gmf], 1.0,
118
W[Ge][0], Z.params->coltot[Gmf], T2.matrix[Gmf][0], Z.params->coltot[Gmf],
119
1.0, Z.matrix[Gae][0], Z.params->coltot[Gmf]);
121
/* write out the new Z(ae,ib) */
122
dpd_buf4_mat_irrep_wrt_block(&Z, Gae, Z.params->start13[Gae][A], virtpi[Ge]);
128
for(Gm=0; Gm < nirreps; Gm++) {
130
dpd_free_block(F.matrix[Gam], occpi[Gm], F.params->coltot[Gam]);
133
for(Ge=0; Ge < nirreps; Ge++) {
134
Gae = Ga^Ge; Gmf = Gae;
135
dpd_free_block(W[Ge], virtpi[Ge], Z.params->coltot[Gmf]);
136
dpd_free_block(Z.matrix[Gae], virtpi[Ge], Z.params->coltot[Gmf]);
141
for(h=0; h < nirreps; h++) dpd_buf4_mat_irrep_close(&T2, h);
143
dpd_buf4_sort_axpy(&Z, CC_HBAR, prqs, 11, 5, "WAbEi (Ei,Ab)", 1);