3
#include <libipv1/ip_lib.h>
4
#include <libciomr/libciomr.h>
5
#include <libchkpt/chkpt.h>
8
#include "globaldefs.h"
11
#define MO_HESS_MIN 1.0E-2
17
** This function calculates the step in theta space for the orbitals
18
** given the orbital gradient and an approximate orbital Hessian
23
void calc_orb_step(int npairs, double *grad, double *hess_diag, double *theta)
29
for (pair=0; pair<npairs; pair++) {
31
denom = hess_diag[pair];
33
fprintf(outfile, "Warning: MO Hessian denominator negative\n");
36
if (denom < MO_HESS_MIN) {
37
fprintf(outfile, "Warning: MO Hessian denominator too small\n");
40
theta[pair] = - numer / denom;
49
** This function prints out the information for a given orbital iteration
51
int print_step(int npairs, int steptype)
54
char sumfile_name[] = "file14.dat";
55
int i, entries, iter, *nind;
56
double *rmsgrad, *scaled_rmsgrad, *energies, energy;
59
/* open ascii file, get number of entries already in it */
61
sumfile = fopen(sumfile_name, "r");
62
if (sumfile == NULL) { /* the file doesn't exist yet */
65
fprintf(outfile, "\nPreparing new file %s\n", sumfile_name);
68
if (fscanf(sumfile, "%d", &entries) != 1) {
69
fprintf(outfile,"(print_step): Trouble reading num entries in file %s\n",
76
rmsgrad = init_array(entries+1);
77
scaled_rmsgrad = init_array(entries+1);
78
energies= init_array(entries+1);
79
nind = init_int_array(entries+1);
80
comments = (char **) malloc ((entries+1) * sizeof (char *));
81
for (i=0; i<entries+1; i++) {
82
comments[i] = (char *) malloc (MAX_COMMENT * sizeof(char));
85
for (i=0; i<entries; i++) {
86
fscanf(sumfile, "%d %d %lf %lf %lf %s", &iter, &(nind[i]),
87
&(scaled_rmsgrad[i]), &(rmsgrad[i]), &(energies[i]), comments[i]);
90
chkpt_init(PSIO_OPEN_OLD);
91
energy = chkpt_rd_etot();
94
scaled_rmsgrad[entries] = CalcInfo.scaled_mo_grad_rms;
95
rmsgrad[entries] = CalcInfo.mo_grad_rms;
96
energies[entries] = energy;
97
nind[entries] = npairs;
100
strcpy(comments[entries], "CONV");
101
else if (steptype == 1)
102
strcpy(comments[entries], "NR");
103
else if (steptype == 2)
104
strcpy(comments[entries], "DIIS");
106
fprintf(outfile, "(print_step): Unrecognized steptype %d\n", steptype);
107
strcpy(comments[entries], "?");
110
if (entries) fclose(sumfile);
112
/* now open file for writing, write out old info plus new */
113
if ((sumfile = fopen("file14.dat", "w")) == NULL) {
114
fprintf(outfile, "(print_step): Unable to open file %s\n", sumfile_name);
118
fprintf(sumfile, "%5d\n", entries);
119
for (i=0; i<entries; i++) {
120
fprintf(sumfile, "%5d %5d %14.9lf %14.9lf %20.12lf %9s\n", i+1, nind[i],
121
scaled_rmsgrad[i], rmsgrad[i], energies[i], comments[i]);
126
free(scaled_rmsgrad);
130
for (i=0; i<entries; i++)