1
/* transform_two_rhf(): Carry out a four-index transform of the
2
** SO-basis two-electron integrals using DPD constructs.
4
** NB: Two key DPD pairs for the SO/MO subspaces:
16
#include <libciomr/libciomr.h>
17
#include <libiwl/iwl.h>
19
#include <libchkpt/chkpt.h>
22
#include <libdpd/dpd.h>
28
#define CC_TEI_HALFT0 91
29
#define CC_TEI_HALFT1 92
31
int file_build_presort(dpdfile4 *, int, double, int);
33
void transform_two_rhf(void)
40
int nso, nmo, nrows, ncols, nlinks, J_rs, K_rs, Gs, Gr;
42
int *pitz2dpd_occ, *pitz2dpd_vir;
48
C = (double ***) malloc(moinfo.nirreps * sizeof(double **));
49
chkpt_init(PSIO_OPEN_OLD);
50
for(h=0; h < moinfo.nirreps; h++)
51
C[h] = chkpt_rd_scf_irrep(h);
54
/* We'll need to map from Pitzer directly to CC/DPD ordering, so let's build the lookups */
55
pitz2dpd_occ = init_int_array(moinfo.nactive);
56
pitz2dpd_vir = init_int_array(moinfo.nactive);
57
for(i=0; i < moinfo.nactive; i++) {
58
pitz2dpd_occ[i] = moinfo.cc_occ[moinfo.pitz2qt[i]];
59
pitz2dpd_vir[i] = moinfo.cc_vir[moinfo.pitz2qt[i]];
62
psio_open(PSIF_SO_PRESORT, 0); /* presorted integrals */
64
dpd_file4_init(&I, PSIF_SO_PRESORT, 0, 3, 3, "SO Ints (pq,rs)");
65
file_build_presort(&I, PSIF_SO_TEI, params.tolerance, 1); /* still need to add frozen-core operator in here */
68
TMP = block_matrix(nso,nso);
70
psio_open(CC_TEI_HALFT0, 0); /* half-transformed integrals */
72
dpd_buf4_init(&J, PSIF_SO_PRESORT, 0, 3, 0, 3, 3, 0, "SO Ints (pq,rs)");
73
dpd_buf4_init(&K, CC_TEI_HALFT0, 0, 3, 5, 3, 8, 0, "Half-Transformed Ints (pq,ij)");
74
for(h=0; h < moinfo.nirreps; h++) {
75
dpd_buf4_mat_irrep_row_init(&J, h);
76
dpd_buf4_mat_irrep_row_init(&K, h);
78
for(pq=0; pq < J.params->rowtot[h]; pq++) {
79
dpd_buf4_mat_irrep_row_rd(&J, h, pq);
81
for(Gr=0; Gr < moinfo.nirreps; Gr++) {
87
J_rs = J.col_offset[h][Gr];
88
if(nrows && ncols && nlinks)
89
C_DGEMM('n','n',nrows,ncols,nlinks,1.0,&J.matrix[h][0][J_rs],nlinks,C[Gs][0],
90
nlinks,0.0,TMP[0],nso);
95
K_rs = K.col_offset[h][Gr];
96
if(nrows && ncols && nlinks)
97
C_DGEMM('t','n',nrows,ncols,nlinks,1.0,C[Gr][0],nlinks,TMP[0],nso,
98
0.0,&K.matrix[h][0][K_rs],ncols);
101
dpd_buf4_mat_irrep_row_wrt(&K, h, pq);
104
dpd_buf4_mat_irrep_row_close(&J, h);
105
dpd_buf4_mat_irrep_row_close(&K, h);
110
psio_close(PSIF_SO_PRESORT, 0); /* delete the presorted integrals */
111
psio_open(CC_TEI_HALFT1, 0); /* transposed half-transformed integrals */
113
dpd_buf4_init(&K, CC_TEI_HALFT0, 0, 3, 5, 3, 8, 0, "Half-Transformed Ints (pq,ij)");
114
dpd_buf4_sort(&K, CC_TEI_HALFT1, rspq, 8, 3, "Half-Transformed Ints (ij,pq)");
117
psio_close(CC_TEI_HALFT0, 0); /* delete the original half-transformed integrals */
119
dpd_buf4_init(&J, CC_TEI_HALFT1, 0, 8, 0, 8, 3, 0, "Half-Transformed Ints (ij,pq)");
120
dpd_buf4_init(&K, CC_MISC, 0, 8, 5, 8, 8, 0, "MO Ints (ij,kl)"); /* place-holder buffer */
121
for(h=0; h < moinfo.nirreps; h++) {
122
dpd_buf4_mat_irrep_row_init(&J, h);
123
buffer = init_array(K.params->coltot[h]);
125
for(pq=0; pq < J.params->rowtot[h]; pq++) {
127
p = J.params->roworb[h][pq][0];
128
q = J.params->roworb[h][pq][1];
130
dpd_buf4_mat_irrep_row_rd(&J, h, pq);
132
for(Gr=0; Gr < moinfo.nirreps; Gr++) {
138
J_rs = J.col_offset[h][Gr];
139
if(nrows && ncols && nlinks)
140
C_DGEMM('n','n',nrows,ncols,nlinks,1.0,&J.matrix[h][0][J_rs],nlinks,C[Gs][0],
141
nlinks,0.0,TMP[0],nso);
146
K_rs = K.col_offset[h][Gr];
147
if(nrows && ncols && nlinks)
148
C_DGEMM('t','n',nrows,ncols,nlinks,1.0,C[Gr][0],nlinks,TMP[0],nso,
149
0.0,&buffer[K_rs],ncols);
151
/* dump the result straight into the distribute function */
153
for(rs=0; rs < J.params->coltot[h]; rs++) {
154
r = J.params->colworb[h][rs][0];
155
s = J.params->colworb[h][rs][1];
161
dpd_buf4_mat_irrep_row_close(&J, h);
162
dpd_buf4_mat_irrep_row_close(&K, h);
164
dpd_buf4_print(&K, outfile, 1);
168
psio_close(CC_TEI_HALFT1, 0); /* delete the transposed half-transformed integrals */
171
for(h=0; h < moinfo.nirreps; h++)