3
\brief Enter brief description of file here
9
#include <libdpd/dpd.h>
17
namespace psi { namespace ccresponse {
19
void init_X(const char *pert, const char *cart, int irrep, double omega);
20
void sort_X(const char *pert, const char *cart, int irrep, double omega);
21
void cc2_sort_X(const char *pert, const char *cart, int irrep, double omega);
22
void X1_build(const char *pert, const char *cart, int irrep, double omega);
23
void X2_build(const char *pert, const char *cart, int irrep, double omega);
24
void cc2_X1_build(const char *pert, const char *cart, int irrep, double omega);
25
void cc2_X2_build(const char *pert, const char *cart, int irrep, double omega);
26
double converged(const char *pert, const char *cart, int irrep, double omega);
27
void save_X(const char *pert, const char *cart, int irrep, double omega);
28
void print_X(const char *pert, const char *cart, int irrep, double omega);
29
void update_X(const char *pert, const char *cart, int irrep, double omega);
30
void diis(int iter, const char *pert, const char *cart, int irrep, double omega);
31
double pseudopolar(const char *pert, const char *cart, int irrep, double omega);
34
void amp_write(const char *pert, const char *cart, int irrep, double omega);
36
void compute_X(const char *pert, const char *cart, int irrep, double omega)
38
int i, iter=0, done=0;
39
double rms, polar, X2_norm;
43
fprintf(outfile, "\n\tComputing %s-%1s-Perturbed Wave Function (%5.3f E_h).\n", pert, cart, omega);
44
init_X(pert, cart, irrep, omega);
45
fprintf(outfile, "\tIter Pseudopolarizability RMS \n");
46
fprintf(outfile, "\t---- -------------------- -----------\n");
49
if (!strcmp(params.wfn,"CC2"))
50
cc2_sort_X(pert, cart, irrep, omega);
52
sort_X(pert, cart, irrep, omega);
53
polar = -2.0*pseudopolar(pert, cart, irrep, omega);
54
fprintf(outfile, "\t%4d %20.12f\n", iter, polar);
57
for(iter=1; iter <= params.maxiter; iter++) {
59
if (!strcmp(params.wfn,"CC2")) {
60
cc2_sort_X(pert, cart, irrep, omega);
61
cc2_X1_build(pert, cart, irrep, omega);
62
cc2_X2_build(pert, cart, irrep, omega);
65
sort_X(pert, cart, irrep, omega);
66
X1_build(pert, cart, irrep, omega);
67
X2_build(pert, cart, irrep, omega);
69
update_X(pert, cart, irrep, omega);
70
rms = converged(pert, cart, irrep, omega);
71
if(rms <= params.convergence) {
73
save_X(pert, cart, irrep, omega);
74
if (!strcmp(params.wfn,"CC2"))
75
cc2_sort_X(pert, cart, irrep, omega);
77
sort_X(pert, cart, irrep, omega);
78
fprintf(outfile, "\t-----------------------------------------\n");
79
fprintf(outfile, "\tConverged %s-%1s-Perturbed Wfn to %4.3e\n", pert, cart, rms);
80
if(params.print & 2) {
81
sprintf(lbl, "X_%s_%1s_IjAb (%5.3f)", pert, cart, omega);
82
dpd_buf4_init(&X2, CC_LR, irrep, 0, 5, 0, 5, 0, lbl);
83
X2_norm = dpd_buf4_dot_self(&X2);
85
X2_norm = sqrt(X2_norm);
86
fprintf(outfile, "\tNorm of the converged X2 amplitudes %20.15f\n", X2_norm);
87
amp_write(pert, cart, irrep, omega);
92
if(params.diis) diis(iter, pert, cart, irrep, omega);
93
save_X(pert, cart, irrep, omega);
94
if (!strcmp(params.wfn,"CC2"))
95
cc2_sort_X(pert, cart, irrep, omega);
97
sort_X(pert, cart, irrep, omega);
99
polar = -2.0*pseudopolar(pert, cart, irrep, omega);
100
fprintf(outfile, "\t%4d %20.12f %4.3e\n", iter, polar, rms);
105
fprintf(outfile, "\t *** Failed to Converge Perturbed Wave Function to %2.1e.\n", params.convergence);
110
exit(PSI_RETURN_FAILURE);
113
/* Clean up disk space */
114
psio_close(CC_DIIS_AMP, 0);
115
psio_close(CC_DIIS_ERR, 0);
117
psio_open(CC_DIIS_AMP, 0);
118
psio_open(CC_DIIS_ERR, 0);
120
for(i=CC_TMP; i <= CC_TMP11; i++) {
125
/* print_X(pert, cart, irrep, omega); */
128
}} // namespace psi::ccresponse