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

« back to all changes in this revision

Viewing changes to src/bin/cscf/check_rot.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
 
/*
2
 
** CHECK_ROT.C
3
 
** 
4
 
** Check the MO rotation performed in rotate_vector() to make sure that
5
 
** columns of the C matrix haven't swapped.  If so, swap them (and their
6
 
** eigenvalues) back to the correct ordering.
7
 
**
8
 
** David Sherrill and Daniel Crawford, July 1995
9
 
**
10
 
*/
11
 
 
12
 
#include <stdio.h>
13
 
#include <libciomr/libciomr.h>
14
 
#define EXTERN
15
 
#include "includes.h"
16
 
#include "common.h"
17
 
 
18
 
void swap_vectors(double **c, int nn, int j, int i);
19
 
 
20
 
void check_rot(int nn, int num_mo, double **cold, double **cnew, double *smat_pac, 
21
 
      double *fock_evals, int irrep)
22
 
{
23
 
  int i,j,jmaxcoeff,swapped;
24
 
  double maxcoeff=0.0, tval;
25
 
  double **smat;
26
 
  double **tmp1, **tmp2;
27
 
  static int printed=0;
28
 
  int count=0;
29
 
 
30
 
  smat = init_matrix(nn,nn);
31
 
  tmp1 = init_matrix(nn,nn);
32
 
  tmp2 = init_matrix(nn,nn);
33
 
 
34
 
  tri_to_sq(smat_pac,smat,nn);
35
 
 
36
 
  do {
37
 
      swapped = 0;
38
 
/*      mxmb(cnew,nn,1,smat,1,nn,tmp1,1,nn,nn,nn,nn);
39
 
      mxmb(tmp1,1,nn,cold,1,nn,tmp2,1,nn,nn,nn,nn);*/
40
 
      mmult(cnew,1,smat,0,tmp1,0,num_mo,nn,nn,0);
41
 
      mmult(tmp1,0,cold,0,tmp2,0,num_mo,nn,num_mo,0);
42
 
 
43
 
/*       fprintf(outfile, "C_New Matrix:\n");
44
 
         print_mat(cnew,nn,nn,outfile);
45
 
         fprintf(outfile, "C_New * S * C_old:\n");
46
 
         print_mat(tmp2,nn,nn,outfile); */
47
 
         
48
 
 
49
 
      for(i=0; i < num_mo; i++) {
50
 
        maxcoeff = 0.0;
51
 
        for(j=0; j < num_mo; j++) {
52
 
          if(fabs(tmp2[j][i]) > maxcoeff) { 
53
 
            maxcoeff = fabs(tmp2[j][i]);
54
 
            jmaxcoeff = j;
55
 
          }
56
 
        }
57
 
        if (maxcoeff < 0.75) {
58
 
           fprintf(outfile, "\n   Warning!  Diagonality check C'SC gives ");
59
 
           fprintf(outfile, "a maximum element of\n   %lf for (%d,%d)\n",
60
 
                   maxcoeff, jmaxcoeff+1, i+1);
61
 
           fprintf(outfile, "   Won't perform MO swapping for this column\n");
62
 
           }
63
 
        else if (jmaxcoeff != i) {
64
 
            swap_vectors(cnew,nn,jmaxcoeff,i);
65
 
            tval = fock_evals[jmaxcoeff];
66
 
            fock_evals[jmaxcoeff] = fock_evals[i];
67
 
            fock_evals[i] = tval;
68
 
            swapped = 1;  count++;
69
 
            if (!printed) {
70
 
               fprintf(outfile, 
71
 
                  "\n   Warning!  MO rotation swapped columns of C matrix\n");
72
 
               printed = 1;
73
 
               }
74
 
            fprintf(outfile, 
75
 
               "   Swapping back columns %d and %d for irrep %d\n",
76
 
               jmaxcoeff+1,i+1,irrep+1);
77
 
            break;
78
 
         }
79
 
      }
80
 
  } while(swapped && count < 50);
81
 
 
82
 
  if (count == 50) {
83
 
     fprintf(outfile, "(check_rot): This is bad.  Tried 50 swaps for ");
84
 
     fprintf(outfile, "irrep %d!\n", irrep+1);
85
 
     fprintf(outfile, "   You may want to set check_rot = false\n");
86
 
     }
87
 
 
88
 
  free_matrix(smat,nn);
89
 
  free_matrix(tmp1,nn);
90
 
  free_matrix(tmp2,nn);
91
 
  
92
 
  /*  
93
 
  fprintf(outfile, "C_New Matrix(after phase change):\n");
94
 
  print_mat(cnew,nn,nn,outfile); 
95
 
  */
96
 
}
97
 
 
98
 
 
99
 
void swap_vectors(double **c, int nn, int j, int i)
100
 
{
101
 
  int k;
102
 
  double tmp;
103
 
 
104
 
  for(k=0; k < nn; k++)  {
105
 
      tmp = c[k][j];
106
 
      c[k][j] = c[k][i];
107
 
      c[k][i] = tmp;
108
 
    }
109
 
}