~ubuntu-branches/ubuntu/vivid/psicode/vivid

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck
  • Date: 2008-06-07 16:49:57 UTC
  • mfrom: (2.1.2 hardy)
  • Revision ID: james.westby@ubuntu.com-20080607164957-8pifvb133yjlkagn
Tags: 3.3.0-3
* debian/rules (DEB_MAKE_CHECK_TARGET): Do not abort test suite on
  failures.
* debian/rules (DEB_CONFIGURE_EXTRA_FLAGS): Set ${bindir} to /usr/lib/psi.
* debian/rules (install/psi3): Move psi3 file to /usr/bin.
* debian/patches/07_464867_move_executables.dpatch: New patch, add
  /usr/lib/psi to the $PATH, so that the moved executables are found.
  (closes: #464867)
* debian/patches/00list: Adjusted.

Show diffs side-by-side

added added

removed removed

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