4
#include <libipv1/ip_lib.h>
5
#include <libciomr/libciomr.h>
7
#include "globaldefs.h"
14
** Calculates the orbital gradient from the MO Lagrangian read in
15
** from the CLAG program
17
** An alternative method is available using calc_grad_2()
19
void calc_grad_1(int npair, int *ppair, int *qpair, double **lag, double *grad)
24
/* this def of the gradient is consistent with orbital rotations defined
25
* in the same sense as our VBD paper...also, what we would call the
26
* Lagrangian in the VBD paper is actually twice the Lagrangian computed
27
* by CLAG, so double the contribution.
29
for (pair=0; pair<npair; pair++) {
32
value = 2.0 * (lag[q][p] - lag[p][q]);
44
** Calculates the orbital gradient from the F_core and F_act quantities,
47
** I am assuming that the pairs (p,q) are always given such that p>=q
50
void calc_grad_2(int npairs, int *ppair, int *qpair, double *F_core,
51
double *tei, double **opdm, double *tpdm, double *F_act,
52
int firstact, int lastact, double *grad)
55
int pair, p, q, pq, pp, qq;
56
int i,ii,a,aa,t,tt,ti,u,tu,au,iu,v,w,vw,tuvw,auvw,iuvw;
59
/* this def of the gradient is consistent with orbital rotations defined
60
* in the same sense as our VBD paper...we have to reverse the sign
64
/* loop over the independent pairs */
65
for (pair=0; pair<npairs; pair++) {
72
/* g_{ai}, i.e., inactive virt/inactive occ */
73
if (p >= lastact && q < firstact) {
74
grad[pair] = -4.0 * (F_core[pq] + F_act[pq]);
77
/* g_{at}, i.e., inactive virt with active orb */
78
else if (p >= lastact && q >= firstact) {
83
for (u=firstact; u<lastact; u++) {
85
value += opdm[t][u] * F_core[au];
87
grad[pair] = -2.0 * value;
90
for (u=firstact; u<lastact; u++) {
93
/* loop over active v,w ... later restrict to symmetry allowed */
94
for (v=firstact; v<lastact; v++) {
95
for (w=firstact; w<lastact; w++) {
99
value += tpdm[tuvw] * tei[auvw];
103
grad[pair] -= 2.0 * value;
107
/* g_{ti}, i.e., active orb with inactive occ */
108
else if (p >= firstact && q < firstact) {
114
grad[pair] = -4.0 * (F_core[ti] + F_act[ti]);
117
for (u=firstact; u<lastact; u++) {
120
value += opdm[t][u] * F_core[iu];
122
grad[pair] += 2.0 * value;
125
for (u=firstact; u<lastact; u++) {
129
/* loop over active v,w ... later restrict to symmetry allowed */
130
for (v=firstact; v<lastact; v++) {
131
for (w=firstact; w<lastact; w++) {
135
value += tpdm[tuvw] * tei[iuvw];
140
grad[pair] += 2.0 * value;
145
"(calc_grad_2): Error, unrecognized class of indep pair\n");
148
} /* end loop over pairs */