~ubuntu-branches/ubuntu/quantal/psicode/quantal

« back to all changes in this revision

Viewing changes to src/bin/input/build_cdsalc.cc

  • 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
/*! \file
 
2
    \ingroup INPUT
 
3
    \brief Enter brief description of file here 
 
4
*/
 
5
#define EXTERN
 
6
#include <cstdio>
 
7
#include <cstdlib>
 
8
#include <cstring>
 
9
#include <libciomr/libciomr.h>
 
10
#include <cmath>
 
11
#include "input.h"
 
12
#include "global.h"
 
13
#include "defines.h"
 
14
 
 
15
namespace psi { namespace input {
 
16
 
 
17
/*-----------------------------------------------------------------------------------------------------------------
 
18
  This function builds SALCs of cartesian displacements
 
19
 -----------------------------------------------------------------------------------------------------------------*/
 
20
 
 
21
void build_cartdisp_salcs()
 
22
{
 
23
  int num_cd = 3*num_atoms;
 
24
  int i, j, u, xyz, irrep, G, cd;
 
25
  /* salc_symblk[i][j] is the pointer to j-th SALC in irrep i. Each SALC is an array of num_cd coefficients */
 
26
  double*** salc_symblk = (double***) malloc(sizeof(double**)*nirreps);
 
27
  for(i=0; i<nirreps; i++)
 
28
    salc_symblk[i] = (double**) malloc(sizeof(double*)*num_cd);
 
29
  
 
30
  /* work array */
 
31
  double* salc = init_array(num_cd);
 
32
  
 
33
  cdsalc_pi = init_int_array(nirreps);
 
34
  cdsalc2cd = block_matrix(num_cd,num_cd);
 
35
  
 
36
  /* compute SALCs */
 
37
  for(u=0; u<num_uniques; u++) {
 
38
    int atom = u2a[u];
 
39
    /* project each displacement */
 
40
    for(xyz=0; xyz<3; xyz++) {
 
41
      int cd = 3*atom + xyz;
 
42
      /* on each irrep */
 
43
      for(irrep=0; irrep<nirreps; irrep++) {
 
44
        memset((void*)salc,0,sizeof(double)*num_cd);
 
45
        
 
46
        /* this is the order of the atom stabilizer (subgroup which preserves atom's position unchanged) */
 
47
        int stab_order = 0;
 
48
        /* apply the projector: */
 
49
        for(G=0; G<nirreps; G++) {
 
50
          int Gatom = atom_orbit[atom][G];
 
51
          if (Gatom == atom)
 
52
            ++stab_order;
 
53
          int Gcd = 3*Gatom + xyz;
 
54
          double coeff = ao_type_transmat[1][G][xyz] * irr_char[irrep][G];
 
55
          salc[Gcd] += coeff;
 
56
        }
 
57
        /* normalize this SALC -- this is why stab_order was needed */
 
58
        for(cd=0; cd<num_cd; cd++)
 
59
          salc[cd] /= sqrt((double)nirreps*stab_order);
 
60
        
 
61
        /* if result is non-zero then add this salc to salc_symblk and increment salc counter */
 
62
        for(i=0; i<num_cd; i++) {
 
63
          if (fabs(salc[i])>1e-10 ) {
 
64
            salc_symblk[irrep][cdsalc_pi[irrep]] = init_array(num_cd);
 
65
            memcpy(salc_symblk[irrep][cdsalc_pi[irrep]],salc,sizeof(double)*num_cd);
 
66
            ++cdsalc_pi[irrep];
 
67
            break;
 
68
          }
 
69
        }
 
70
      }
 
71
    }
 
72
  }
 
73
  
 
74
  /* copy salc_symblk to cdsalc2cd */
 
75
  {
 
76
    int c = 0;
 
77
    for(irrep=0; irrep<nirreps; irrep++) {
 
78
      int num_per_irrep = cdsalc_pi[irrep];
 
79
      for(i=0; i<num_per_irrep; i++,c++) {
 
80
        for(j=0; j<num_cd; j++) {
 
81
          cdsalc2cd[j][c] = salc_symblk[irrep][i][j];
 
82
        }
 
83
        free(salc_symblk[irrep][i]);
 
84
      }
 
85
      free(salc_symblk[irrep]);
 
86
    }
 
87
    free(salc_symblk);
 
88
  }
 
89
  
 
90
  
 
91
  if (print_lvl >= PRINTUSOTAO) {
 
92
    fprintf(outfile,"    -Cartesian displacement SALCs per irrep:\n");
 
93
    fprintf(outfile,"    Irrep  #SALCs\n");
 
94
    fprintf(outfile,"    -----  ------\n");
 
95
    for(irrep=0;irrep<nirreps;irrep++) {
 
96
      fprintf(outfile,"    %3d    %4d\n",irrep,cdsalc_pi[irrep]);
 
97
    }
 
98
    fprintf(outfile,"\n");
 
99
 
 
100
    fprintf(outfile,"    -Cartesian displacement SALCs:\n");
 
101
    print_mat(cdsalc2cd,num_cd,num_cd,outfile);
 
102
    fprintf(outfile,"\n");
 
103
  }
 
104
  
 
105
}
 
106
 
 
107
}} // namespace psi::input