~ubuntu-branches/ubuntu/karmic/psicode/karmic

« back to all changes in this revision

Viewing changes to src/bin/ccresponse/LHX1Y1.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck, Michael Banck, Daniel Leidert
  • Date: 2009-02-23 00:12:02 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090223001202-rutldoy3dimfpesc
Tags: 3.4.0-1
* New upstream release.

[ Michael Banck ]
* debian/patches/01_DESTDIR.dpatch: Refreshed.
* debian/patches/02_FHS.dpatch: Removed, applied upstream.
* debian/patches/03_debian_docdir: Likewise.
* debian/patches/04_man.dpatch: Likewise.
* debian/patches/06_466828_fix_gcc_43_ftbfs.dpatch: Likewise.
* debian/patches/07_464867_move_executables: Fixed and refreshed.
* debian/patches/00list: Adjusted.
* debian/control: Improved description.
* debian/patches-held: Removed.
* debian/rules (install/psi3): Do not ship the ruby bindings for now.

[ Daniel Leidert ]
* debian/rules: Fix txtdir via DEB_MAKE_INSTALL_TARGET.
* debian/patches/01_DESTDIR.dpatch: Refreshed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <stdio.h>
2
 
#include <string.h>
3
 
#include <libdpd/dpd.h>
4
 
#include <libciomr/libciomr.h>
5
 
#include <libqt/qt.h>
6
 
#define EXTERN
7
 
#include "globals.h"
8
 
 
9
 
/* LHX1Y1(): Computes the <0|L*(HBAR*X1*Y1)c |0> contributions to the
10
 
** linear response function.  Note that most of the work is actually
11
 
** already done in other codes because the contractions may all be
12
 
** formulated in as products of X1*Y1 with L*HBAR, the latter of which
13
 
** are referred to in this code as "lambda residuals".  
14
 
**
15
 
** Type-I residuals are taken directly from cclambda: L2*D, L2*Wmnij,
16
 
** L2*Wabef, L2*Wamef, L2*Wmnie, and L2*three-body-terms.
17
 
**
18
 
** Type-II residuals are computed once in lambda_residuals(): L1*Fme
19
 
** and L2*Wmbej.
20
 
**
21
 
** TDC, 9/10/05
22
 
*/
23
 
 
24
 
void build_XY(char *, char *, int, double, char *, char *, int, double);
25
 
 
26
 
double LHX1Y1(char *pert_x, char *cart_x, int irrep_x, double omega_x, 
27
 
              char *pert_y, char *cart_y, int irrep_y, double omega_y)
28
 
{
29
 
 
30
 
  dpdfile2 F, X1, Y1, Zmi, Zae_1, Zae_2, Zfb, Znj, ZIA, L1, t1, z;
31
 
  dpdbuf4 Z1, Z2, I, tau, W1, W2, ZIjAb, L2, T2, W, Z;
32
 
  double polar, polar_I, polar_II;
33
 
  char lbl[32];
34
 
  int Gbm, Gfe, bm, b, m, Gb, Gm, Ge, Gf, B, M, fe, f, e, ef, nrows, ncols;
35
 
  double *X;
36
 
 
37
 
  build_XY(pert_x, cart_x, irrep_x, omega_x, pert_y, cart_y, irrep_y, omega_y);
38
 
 
39
 
  /* Type-I L2 residual */
40
 
  dpd_buf4_init(&L2, CC_LAMPS, 0, 0, 5, 0, 5, 0, "LHX1Y1 I (2 Lijab - Lijba)");
41
 
  dpd_buf4_init(&Z1, CC_TMP0, 0, 0, 5, 0, 5, 0, "X*Y(ij,ab)");
42
 
  polar_I = 2.0 * dpd_buf4_dot(&L2, &Z1);
43
 
  dpd_buf4_close(&Z1);
44
 
  dpd_buf4_close(&L2);
45
 
 
46
 
  /* Type-II L2 residual */
47
 
  dpd_buf4_init(&L2, CC_LAMPS, 0, 10, 10, 10, 10, 0, "LHX1Y1 Residual II");
48
 
  dpd_buf4_init(&Z1, CC_TMP0, 0, 10, 10, 10, 10, 0, "(X*Y+Y*X)(ie,ma)");
49
 
  polar_II = -2.0 * dpd_buf4_dot(&L2, &Z1);
50
 
  dpd_buf4_close(&Z1);
51
 
  dpd_buf4_close(&L2);
52
 
 
53
 
  return polar_I+polar_II;
54
 
}
55
 
 
56
 
/* build_XY(): Compute products of X1 and Y1 for the
57
 
** <0|L*(HBAR*X1*Y1)|0> part of the response function.
58
 
** 
59
 
** For the Type-I residuals:
60
 
** X*Y(ij,ab) = X(i,a) * Y(j,b)
61
 
**
62
 
** For the Type-II residuals:
63
 
** (X*Y+Y*X)(ie,ma) = [X(i,e) * Y(m,a) + X(m,a) * Y(i,e)]
64
 
** 
65
 
** TDC, 9/10/05
66
 
**/
67
 
 
68
 
void build_XY(char *pert_x, char *cart_x, int irrep_x, double omega_x, 
69
 
                 char *pert_y, char *cart_y, int irrep_y, double omega_y)
70
 
{
71
 
  int h, row, col, i, j, m, e, f, a, I, J, M, E, F, A, ij, ef;
72
 
  int Isym, Jsym, Msym, Esym, Fsym, Asym;
73
 
  int nirreps;
74
 
  dpdbuf4 Z, Z1;
75
 
  dpdfile2 X1, Y1;
76
 
  char lbl[32];
77
 
 
78
 
  nirreps = moinfo.nirreps;
79
 
 
80
 
  sprintf(lbl, "X_%s_%1s_IA (%5.3f)", pert_y, cart_y, omega_y);
81
 
  dpd_file2_init(&Y1, CC_OEI, irrep_y, 0, 1, lbl);
82
 
  dpd_file2_mat_init(&Y1);
83
 
  dpd_file2_mat_rd(&Y1);
84
 
 
85
 
  sprintf(lbl, "X_%s_%1s_IA (%5.3f)", pert_x, cart_x, omega_x);
86
 
  dpd_file2_init(&X1, CC_OEI, irrep_x, 0, 1, lbl);
87
 
  dpd_file2_mat_init(&X1);
88
 
  dpd_file2_mat_rd(&X1);
89
 
 
90
 
  dpd_buf4_init(&Z, CC_TMP0, 0, 0, 5, 0, 5, 0, "X*Y(ij,ab)");
91
 
  dpd_buf4_scm(&Z, 0.0);
92
 
  for(h=0; h< nirreps; h++) {
93
 
    dpd_buf4_mat_irrep_init(&Z, h);
94
 
    for(row=0; row < Z.params->rowtot[h]; row++) {
95
 
      i = Z.params->roworb[h][row][0];
96
 
      j = Z.params->roworb[h][row][1];
97
 
      I = X1.params->rowidx[i];
98
 
      J = Y1.params->rowidx[j];
99
 
      Isym = X1.params->psym[i];
100
 
      Jsym = Y1.params->psym[j];
101
 
      for(col=0; col < Z.params->coltot[h]; col++) {
102
 
        e = Z.params->colorb[h][col][0];
103
 
        f = Z.params->colorb[h][col][1];
104
 
        E = X1.params->colidx[e];
105
 
        F = Y1.params->colidx[f];
106
 
        Esym = X1.params->qsym[e];
107
 
        Fsym = Y1.params->qsym[f];
108
 
        if((Isym^Esym)==irrep_x && (Jsym^Fsym)==irrep_y)
109
 
          Z.matrix[h][row][col] = (X1.matrix[Isym][I][E] * Y1.matrix[Jsym][J][F]);
110
 
      }
111
 
    }
112
 
    dpd_buf4_mat_irrep_wrt(&Z, h);
113
 
    dpd_buf4_mat_irrep_close(&Z, h);
114
 
  }
115
 
  dpd_buf4_close(&Z);
116
 
 
117
 
  dpd_buf4_init(&Z, CC_TMP0, 0, 10, 10, 10, 10, 0, "(X*Y+Y*X)(ie,ma)");
118
 
  dpd_buf4_scm(&Z, 0.0);
119
 
  for(h=0; h< nirreps; h++) {
120
 
    dpd_buf4_mat_irrep_init(&Z, h);
121
 
    for(row=0; row < Z.params->rowtot[h]; row++) {
122
 
      i = Z.params->roworb[h][row][0];
123
 
      e = Z.params->roworb[h][row][1];
124
 
      I = X1.params->rowidx[i];
125
 
      E = X1.params->colidx[e];
126
 
      Isym = X1.params->psym[i];
127
 
      Esym = X1.params->qsym[e];
128
 
      for(col=0; col < Z.params->coltot[h]; col++) {
129
 
        m = Z.params->colorb[h][col][0];
130
 
        a = Z.params->colorb[h][col][1];
131
 
        M = Y1.params->rowidx[m];
132
 
        A = Y1.params->colidx[a];
133
 
        Msym = Y1.params->psym[m];
134
 
        Asym = Y1.params->qsym[a];
135
 
 
136
 
        if(((Isym^Esym)==irrep_x) && ((Msym^Asym)==irrep_y))
137
 
          Z.matrix[h][row][col] = 
138
 
            (X1.matrix[Isym][I][E] * Y1.matrix[Msym][M][A]) +
139
 
            (Y1.matrix[Isym][I][E] * X1.matrix[Msym][M][A]);
140
 
      }       
141
 
    }
142
 
    dpd_buf4_mat_irrep_wrt(&Z, h);
143
 
    dpd_buf4_mat_irrep_close(&Z, h);
144
 
  }
145
 
  dpd_buf4_close(&Z);
146
 
 
147
 
  dpd_file2_mat_close(&X1);
148
 
  dpd_file2_close(&X1);
149
 
  dpd_file2_mat_close(&Y1);
150
 
  dpd_file2_close(&Y1);
151
 
 
152
 
}