3
\brief Enter brief description of file here
6
** CCDENSITY: Program to calculate the coupled-cluster one- and
7
** two-particle densities.
13
#include <libipv1/ip_lib.h>
14
#include <libpsio/psio.h>
15
#include <libciomr/libciomr.h>
16
#include <libdpd/dpd.h>
17
#include <libiwl/iwl.h>
25
namespace psi { namespace ccdensity {
27
void init_io(int argc, char *argv[]);
29
void get_moinfo(void);
30
void get_frozen(void);
31
void get_params(void);
33
void onepdm(struct RHO_Params);
34
void sortone(struct RHO_Params);
36
void energy(struct RHO_Params);
37
void resort_tei(void);
38
void resort_gamma(void);
39
void lag(struct RHO_Params rho_params);
44
void relax_D(struct RHO_Params rho_params);
46
void fold(struct RHO_Params rho_params);
47
void deanti(struct RHO_Params rho_params);
48
void add_ref_RHF(struct iwlbuf *);
49
void add_ref_ROHF(struct iwlbuf *);
50
void add_ref_UHF(struct iwlbuf *, struct iwlbuf *, struct iwlbuf *);
51
void add_core_ROHF(struct iwlbuf *);
52
void add_core_UHF(struct iwlbuf *, struct iwlbuf *, struct iwlbuf *);
53
void dump_RHF(struct iwlbuf *, struct RHO_Params rho_params);
54
void dump_ROHF(struct iwlbuf *, struct RHO_Params rho_params);
55
void dump_UHF(struct iwlbuf *, struct iwlbuf *, struct iwlbuf *, struct RHO_Params rho_params);
59
int **cacheprep_rhf(int level, int *cachefiles);
60
int **cacheprep_uhf(int level, int *cachefiles);
61
void cachedone_rhf(int **cachelist);
62
void cachedone_uhf(int **cachelist);
63
void setup_LR(struct RHO_Params);
65
void x_oe_intermediates(struct RHO_Params);
66
void x_onepdm(struct RHO_Params);
67
void x_te_intermediates(void);
78
void x_xi_oe_intermediates(void);
80
void zero_onepdm(struct RHO_Params rho_params);
81
void zero_twopdm(void);
82
void get_rho_params(void);
83
void get_td_params(void);
84
void td_setup(struct TD_Params S);
85
void tdensity(struct TD_Params S);
87
void oscillator_strength(struct TD_Params *S);
88
void rotational_strength(struct TD_Params *S);
89
void ael(struct RHO_Params *rho_params);
91
void td_cleanup(void);
92
void x_oe_intermediates_rhf(struct RHO_Params rho_params);
93
void x_te_intermediates_rhf(void);
94
void x_xi_intermediates(void);
97
}} // namespace psi::cdensity
99
using namespace psi::ccdensity;
101
int main(int argc, char *argv[])
104
int **cachelist, *cachefiles;
105
struct iwlbuf OutBuf;
106
struct iwlbuf OutBuf_AA, OutBuf_BB, OutBuf_AB;
117
if ((moinfo.nfzc || moinfo.nfzv) && params.relax_opdm) {
118
fprintf(outfile, "\n\tGradients/orbital relaxation involving frozen orbitals not yet available.\n");
119
exit(PSI_RETURN_FAILURE);
122
cachefiles = init_int_array(PSIO_MAXUNIT);
124
if(params.ref == 0 || params.ref == 1) { /** RHF or ROHF **/
125
cachelist = cacheprep_rhf(params.cachelev, cachefiles);
127
dpd_init(0, moinfo.nirreps, params.memory, 0, cachefiles, cachelist, NULL,
128
2, moinfo.occpi, moinfo.occ_sym, moinfo.virtpi, moinfo.vir_sym);
131
else if(params.ref == 2) { /** UHF **/
132
cachelist = cacheprep_uhf(params.cachelev, cachefiles);
134
dpd_init(0, moinfo.nirreps, params.memory, 0, cachefiles,
135
cachelist, NULL, 4, moinfo.aoccpi, moinfo.aocc_sym, moinfo.avirtpi,
136
moinfo.avir_sym, moinfo.boccpi, moinfo.bocc_sym, moinfo.bvirtpi, moinfo.bvir_sym);
139
for (i=0; i<params.nstates; ++i) {
141
/* CC_GLG will contain L, or R0*L + Zeta, if relaxed and zeta is available */
142
/* CC_GL will contain L */
143
setup_LR(rho_params[i]);
145
/* Calculate Xi, put Xi in EOM_XI, and quit */
146
if ( params.calc_xi ) {
147
/* these intermediates go into EOM_TMP and are used to compute Xi;
148
they may be reused to compute the excited-state density matrix */
149
if (params.ref == 0) {
150
x_oe_intermediates_rhf(rho_params[i]);
151
x_te_intermediates_rhf();
154
x_oe_intermediates(rho_params[i]);
155
x_te_intermediates();
157
x_xi_intermediates(); /*Xi intermediates put in EOM_TMP_XI */
158
x_xi_zero(); /* make blank Xi */
162
if(params.ref == 2) cachedone_uhf(cachelist);
163
else cachedone_rhf(cachelist);
166
psio_close(EOM_TMP_XI,0); /* delete EOM_TMP_XI */
167
psio_open(EOM_TMP_XI,PSIO_OPEN_NEW);
169
exit(PSI_RETURN_SUCCESS);
172
/* compute ground state parts of onepdm or put zeroes there */
173
if ( ((rho_params[i].L_irr == rho_params[i].G_irr) || (params.use_zeta)) ) {
174
zero_onepdm(rho_params[i]);
175
onepdm(rho_params[i]);
178
zero_onepdm(rho_params[i]);
180
/* if the one-electron excited-state intermediates are not already on disk (from a Xi
181
calculation, compute them. They are nearly all necessary to compute the excited-state
182
onepdm. Then complete excited-state onepdm.*/
183
if (!rho_params[i].R_ground) {
184
x_oe_intermediates(rho_params[i]); /* change to x_oe_intermediates_rhf() when rho gets spin-adapted */
185
x_onepdm(rho_params[i]);
188
/* begin construction of twopdm */
189
if (!params.onepdm) {
191
/* Compute intermediates for construction of ground-state twopdm */
192
if ( (params.L_irr == params.G_irr) || (params.use_zeta) ) {
193
V_build(); /* uses CC_GLG, writes tau2*L2 to CC_MISC */
194
G_build(); /* uses CC_GLG, writes t2*L2 to CC_GLG */
197
/* Compute ground-state twopdm or ground-state-like contributions to the excited twodpm */
198
if ( (params.L_irr == params.G_irr) || (params.use_zeta) )
203
/* Compute intermediates for construction of excited-state twopdm */
204
if (!params.ground) {
205
x_te_intermediates(); /* change to x_te_intermediates_rhf() when rho gets spin-adapted */
206
V_build_x(); /* uses CC_GL, writes t2*L2 to EOM_TMP */
208
/* add in non-R0 parts of onepdm and twopdm */
218
sortone(rho_params[i]); /* puts full 1-pdm into moinfo.opdm */
221
if (!params.onepdm) {
222
if(!params.aobasis) energy(rho_params[i]);
224
kinetic(); /* puts kinetic energy integrals into MO basis */
226
lag(rho_params[i]); /* builds the orbital lagrangian pieces, I */
228
/* dpd_init(1, moinfo.nirreps, params.memory, 2, frozen.occpi, frozen.occ_sym,
229
frozen.virtpi, frozen.vir_sym); */
231
/* if(moinfo.nfzc || moinfo.nfzv) {
236
build_X(); /* builds orbital rotation gradient X */
237
build_A(); /* construct MO Hessian A */
238
build_Z(); /* solves the orbital Z-vector equations */
240
relax_I(); /* adds orbital response contributions to Lagrangian */
242
if (params.relax_opdm) {
243
relax_D(rho_params[i]); /* adds orbital response contributions to onepdm */
245
sortone(rho_params[i]); /* builds large moinfo.opdm matrix */
246
sortI(); /* builds large lagrangian matrix I */
248
deanti(rho_params[i]);
251
/* dpd_close(0); dpd_close(1); */
253
if(params.ref == 0) { /** RHF **/
255
iwl_buf_init(&OutBuf, PSIF_MO_TPDM, params.tolerance, 0, 0);
257
add_core_ROHF(&OutBuf);
258
add_ref_RHF(&OutBuf);
259
dump_RHF(&OutBuf, rho_params[i]);
261
iwl_buf_flush(&OutBuf, 1);
262
iwl_buf_close(&OutBuf, 1);
264
else if(params.ref == 1) { /** ROHF **/
266
iwl_buf_init(&OutBuf, PSIF_MO_TPDM, params.tolerance, 0, 0);
268
add_core_ROHF(&OutBuf);
269
add_ref_ROHF(&OutBuf);
270
dump_ROHF(&OutBuf, rho_params[i]);
272
iwl_buf_flush(&OutBuf, 1);
273
iwl_buf_close(&OutBuf, 1);
275
else if(params.ref == 2) { /** UHF **/
277
iwl_buf_init(&OutBuf_AA, PSIF_MO_AA_TPDM, params.tolerance, 0, 0);
278
iwl_buf_init(&OutBuf_BB, PSIF_MO_BB_TPDM, params.tolerance, 0, 0);
279
iwl_buf_init(&OutBuf_AB, PSIF_MO_AB_TPDM, params.tolerance, 0, 0);
281
/* add_core_UHF(&OutBuf_AA, &OutBuf_BB, &OutBuf_AB); */
282
add_ref_UHF(&OutBuf_AA, &OutBuf_BB, &OutBuf_AB);
283
dump_UHF(&OutBuf_AA, &OutBuf_BB, &OutBuf_AB, rho_params[i]);
285
iwl_buf_flush(&OutBuf_AA, 1);
286
iwl_buf_flush(&OutBuf_BB, 1);
287
iwl_buf_flush(&OutBuf_AB, 1);
288
iwl_buf_close(&OutBuf_AA, 1);
289
iwl_buf_close(&OutBuf_BB, 1);
290
iwl_buf_close(&OutBuf_AB, 1);
292
free_block(moinfo.opdm);
294
psio_close(CC_TMP,0); psio_open(CC_TMP,PSIO_OPEN_NEW);
295
psio_close(EOM_TMP0,0); psio_open(EOM_TMP0,PSIO_OPEN_NEW);
296
psio_close(EOM_TMP1,0); psio_open(EOM_TMP1,PSIO_OPEN_NEW);
297
psio_close(CC_GLG,0); psio_open(CC_GLG,PSIO_OPEN_NEW);
298
psio_close(CC_GL,0); psio_open(CC_GL,PSIO_OPEN_NEW);
299
psio_close(CC_GR,0); psio_open(CC_GR,PSIO_OPEN_NEW);
300
if (!params.calc_xi) {
301
psio_close(EOM_TMP,0);
302
psio_open(EOM_TMP,PSIO_OPEN_NEW);
306
/* if ( params.ael && (params.nstates > 1) )
309
if(params.transition) {
312
for(i=0; i < params.nstates; i++) {
313
td_setup(td_params[i]);
314
tdensity(td_params[i]);
315
oscillator_strength(&(td_params[i]));
316
if(params.ref == 0) {
317
rotational_strength(&(td_params[i]));
326
if(params.ref == 2) cachedone_uhf(cachelist);
327
else cachedone_rhf(cachelist);
332
exit(PSI_RETURN_SUCCESS);
335
extern "C" {const char *gprgid() { const char *prgid = "CCDENSITY"; return(prgid); }}
337
namespace psi { namespace ccdensity {
339
void init_io(int argc, char *argv[])
342
char *progid, *argv_unparsed[100];;
344
progid = (char *) malloc(strlen(gprgid())+2);
345
sprintf(progid, ":%s",gprgid());
352
params.transition = 0;
354
for (i=1, num_unparsed=0; i<argc; ++i) {
355
if(!strcmp(argv[i], "--onepdm")) {
356
params.onepdm = 1; /* generate ONLY the onepdm (for one-electron properties) */
358
else if (!strcmp(argv[i],"--use_zeta")) {
363
else if (!strcmp(argv[i],"--calc_xi")) {
368
else if (!strcmp(argv[i],"--prop_all")) {
371
else if (!strcmp(argv[i],"--transition")) {
372
params.transition = 1;
373
params.relax_opdm = 0;
377
argv_unparsed[num_unparsed++] = argv[i];
381
psi_start(&infile,&outfile,&psi_file_prefix,num_unparsed,argv_unparsed,0);
385
psio_init(); psio_ipv1_config();
387
/* Open all dpd data files here */
388
/* erase files for easy debugging */
389
for(i=CC_MIN; i <= CC_MAX; i++) psio_open(i,PSIO_OPEN_OLD);
393
psio_close(EOM_TMP0,0);
394
psio_open(CC_GR,PSIO_OPEN_NEW);
395
psio_open(CC_GL,PSIO_OPEN_NEW);
396
psio_open(EOM_TMP0,PSIO_OPEN_NEW);
402
fprintf(outfile, "\n");
403
fprintf(outfile, "\t\t\t**************************\n");
404
fprintf(outfile, "\t\t\t* *\n");
405
fprintf(outfile, "\t\t\t* CCDENSITY *\n");
406
fprintf(outfile, "\t\t\t* *\n");
407
fprintf(outfile, "\t\t\t**************************\n");
408
fprintf(outfile, "\n");
415
/* delete temporary EOM files */
416
psio_close(EOM_TMP0,0);
417
psio_close(EOM_TMP1,0);
418
psio_close(CC_GLG,0);
419
psio_open(EOM_TMP0,PSIO_OPEN_NEW);
420
psio_open(EOM_TMP1,PSIO_OPEN_NEW);
421
psio_open(CC_GLG,PSIO_OPEN_NEW);
422
if (!params.calc_xi) {
423
psio_close(EOM_TMP,0);
424
psio_open(EOM_TMP,PSIO_OPEN_NEW);
426
if (params.use_zeta) { /* we're done with Xi amplitudes */
427
psio_close(EOM_XI,0);
428
psio_open(EOM_XI,PSIO_OPEN_NEW);
431
/* Close all dpd data files here */
432
for(i=CC_MIN; i <= CC_MAX; i++) psio_close(i,1);
436
psi_stop(infile,outfile,psi_file_prefix);
439
}} // namespace psi::ccdensity