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

« back to all changes in this revision

Viewing changes to .pc/08_525758_ftbfs_with_gcc44.patch/src/lib/libmoinfo/moinfo_slaterdeterminant.cc

  • Committer: Package Import Robot
  • Author(s): Michael Banck
  • Date: 2012-03-29 01:26:55 UTC
  • mfrom: (5.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20120329012655-8lnngrup9p40ow4z
Tags: 3.4.0-3
* debian/control: Add CC3, MRCCSD and SCS-MP2 energies, RHF hessian and
  closed-shell MP2 gradient to features, clarify that MP2-R12 is an
  explicitly correlated method.
* debian/patches/09_system_libint.dpatch: New patch, modifies the build
  system to use the system libint and not compile and link in the shipped
  libint codes.
* debian/control (Build-Depends): Added libint-dev.
* debian/rules (DEB_MAKE_CHECK_TARGET): Run quicktests target to invoke the
  test suite.
* debian/rules: Rewritten for dh.
* debian/control (Build-Depends): Bumped debhelper version to 8, removed
  cdbs and dpatch.
* debian/patches: Moved to source version 3.0 (quilt).
* debian/source/format: New file.
* debian/rules (override_dh_auto_install): Install some test suite input
  files as examples.
* debian/dirs: Added examples directory.
* debian/TODO: Updated.
* debian/control (Standards-Version): Bumped to 3.9.3.
* debian/rules (override_dh_auto_test): Do not abort build on test suite
  failure.
* debian/rules (override_dh_auto_build): New rule, build the user manual in
  addition to the main code.
* debian/control (Build-Depends): Added texlive-latex-recommended.
* debian/patches/10_makerules_doc.patch: New patch, build the postscript
  file by default and deletes some more generated files on realclean.
* debian/rules (override_dh_auto_install): Install postscript user manual
  into documentation directory.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <iostream>
 
2
#include "moinfo.h"
 
3
 
 
4
extern FILE *infile, *outfile;
 
5
 
 
6
using namespace std;
 
7
 
 
8
namespace psi {
 
9
 
 
10
MOInfo::SlaterDeterminant::SlaterDeterminant()
 
11
{
 
12
}
 
13
 
 
14
 
 
15
MOInfo::SlaterDeterminant::~SlaterDeterminant()
 
16
{
 
17
}
 
18
 
 
19
 
 
20
/**
 
21
 * @fn MOInfo::SlaterDeterminant::is_closed_shell()
 
22
 */
 
23
bool MOInfo::SlaterDeterminant::is_closed_shell()
 
24
{
 
25
  for(int i=0;i<moinfo->get_nmo();i++)
 
26
    if(bits[i]!=bits[i+moinfo->get_nmo()])
 
27
      return(false);
 
28
  return(true);
 
29
}
 
30
 
 
31
 
 
32
/**
 
33
 * @fn MOInfo::SlaterDeterminant::is_spin_flip(SlaterDeterminant& det)
 
34
 */
 
35
bool MOInfo::SlaterDeterminant::is_spin_flipped(SlaterDeterminant& det)
 
36
{
 
37
  for(int i=0;i<moinfo->get_nmo();i++){
 
38
    if(bits[i]!=det.test(i+moinfo->get_nmo()))
 
39
      return(false);
 
40
    if(bits[i+moinfo->get_nmo()]!=det.test(i))
 
41
      return(false);
 
42
  }
 
43
  return(true);
 
44
}
 
45
 
 
46
 
 
47
/**
 
48
 * @fn MOInfo::SlaterDeterminant::print(int n)
 
49
 */
 
50
void MOInfo::SlaterDeterminant::print()
 
51
{
 
52
  fprintf(outfile,"|");
 
53
  for(int i=0;i<moinfo->get_nmo();i++){
 
54
    fprintf(outfile,"%s",get_occupation_symbol(i));
 
55
  }
 
56
  fprintf(outfile,">");
 
57
}
 
58
 
 
59
/**
 
60
 * @fn MOInfo::SlaterDeterminant::print(int n)
 
61
 */
 
62
void MOInfo::SlaterDeterminant::print_occ()
 
63
{
 
64
  fprintf(outfile,"|");
 
65
  int counter = 0;
 
66
  for(int h=0;h<moinfo->get_nirreps();h++){
 
67
    fprintf(outfile,"[");
 
68
    for(int i=0;i<moinfo->get_docc(h);i++){
 
69
      fprintf(outfile,"%c",get_occupation_symbol(counter));
 
70
      counter++;
 
71
    }
 
72
    for(int i=0;i<moinfo->get_actv(h);i++){
 
73
      fprintf(outfile,"%c",get_occupation_symbol(counter));
 
74
      counter++;
 
75
    }
 
76
    counter+=moinfo->get_avir(h);
 
77
    fprintf(outfile,"]");
 
78
  }
 
79
  fprintf(outfile,">");
 
80
}
 
81
 
 
82
/**
 
83
 * @fn MOInfo::SlaterDeterminant::get_internal_excitations(...)
 
84
 */
 
85
void MOInfo::SlaterDeterminant::get_internal_excitations(SlaterDeterminant& det,double& sign,
 
86
                                                 vector<pair<int,int> >& alpha_operators,
 
87
                                                 vector<pair<int,int> >& beta_operators)
 
88
{
 
89
  int ann, cre;
 
90
  int nmo = moinfo->get_nmo();
 
91
  bitdet bits_exc = det.get_bits();
 
92
  bitdet bits_tmp = bits;
 
93
  sign = 1.0;
 
94
  // Find one set of excitations at a time
 
95
  ann = -1; cre = -1;
 
96
  while(cre<nmo){
 
97
    while(++ann<nmo)
 
98
      if(bits[ann] && !bits_exc[ann]) break;
 
99
    while(++cre<nmo)
 
100
      if(!bits[cre] && bits_exc[cre]) break;
 
101
    if(cre<nmo){
 
102
      alpha_operators.push_back(make_pair(moinfo->get_all_to_occ(ann),moinfo->get_all_to_vir(cre)));
 
103
      sign *= annihilate(bits_tmp,ann);
 
104
      sign *=     create(bits_tmp,cre);
 
105
    }
 
106
  }
 
107
  ann = -1; cre = -1;
 
108
  while(cre<nmo){
 
109
    while(++ann<nmo)
 
110
      if(bits[ann+nmo] && !bits_exc[ann+nmo]) break;
 
111
    while(++cre<nmo)
 
112
      if(!bits[cre+nmo] && bits_exc[cre+nmo]) break;
 
113
    if(cre<nmo){
 
114
      beta_operators.push_back(make_pair(moinfo->get_all_to_occ(ann),moinfo->get_all_to_vir(cre)));
 
115
      sign *= annihilate(bits_tmp,ann+nmo);
 
116
      sign *=     create(bits_tmp,cre+nmo);
 
117
    }
 
118
  }
 
119
}
 
120
 
 
121
double MOInfo::SlaterDeterminant::annihilate(bitdet& bits_det,int so)
 
122
{
 
123
  if(bits_det.test(so)){
 
124
    bits_det.flip(so);
 
125
    double sign = 1.0;
 
126
    for(int i=0;i<so;i++)
 
127
      if(bits_det.test(i)) sign *= -1.0;
 
128
    return(sign);
 
129
  }
 
130
  else
 
131
    return(0.0);
 
132
}
 
133
 
 
134
double MOInfo::SlaterDeterminant::create(bitdet& bits_det,int so)
 
135
{
 
136
  if(!bits_det.test(so)){
 
137
    bits_det.flip(so);
 
138
    double sign = 1.0;
 
139
    for(int i=0;i<so;i++)
 
140
      if(bits_det.test(i)) sign *= -1.0;
 
141
    return(sign);
 
142
  }
 
143
  else
 
144
    return(0.0);
 
145
}
 
146
 
 
147
vector<int> MOInfo::SlaterDeterminant::get_aocc()
 
148
{
 
149
  vector<int> aocc;
 
150
  for(int i=0;i<moinfo->get_nmo();i++)
 
151
    if(bits[i])
 
152
      aocc.push_back(moinfo->get_all_to_occ(i));
 
153
  return(aocc);
 
154
}
 
155
 
 
156
vector<int> MOInfo::SlaterDeterminant::get_bocc()
 
157
{
 
158
  vector<int> bocc;
 
159
  for(int i=0;i<moinfo->get_nmo();i++)
 
160
    if(bits[i+moinfo->get_nmo()])
 
161
      bocc.push_back(moinfo->get_all_to_occ(i));
 
162
  return(bocc);
 
163
}
 
164
 
 
165
vector<int> MOInfo::SlaterDeterminant::get_avir()
 
166
{
 
167
  vector<int> avir;
 
168
  for(int i=0;i<moinfo->get_nmo();i++)
 
169
    if(!bits[i])
 
170
      avir.push_back(moinfo->get_all_to_vir(i));
 
171
  return(avir);
 
172
}
 
173
 
 
174
vector<int> MOInfo::SlaterDeterminant::get_bvir()
 
175
{
 
176
  vector<int> bvir;
 
177
  for(int i=0;i<moinfo->get_nmo();i++)
 
178
    if(!bits[i+moinfo->get_nmo()])
 
179
      bvir.push_back(moinfo->get_all_to_vir(i));
 
180
  return(bvir);
 
181
}
 
182
 
 
183
char MOInfo::SlaterDeterminant::get_occupation_symbol(int i)
 
184
{
 
185
  int occupation=bits[i]+bits[i+moinfo->get_nmo()];
 
186
  if(occupation==0)                     return('0');
 
187
  if(occupation==2)                     return('2');
 
188
  if((occupation==1) && bits.test(i))   return('+');
 
189
  if((occupation==1) && bits.test(i+moinfo->get_nmo())) return('-');
 
190
  return(' ');
 
191
}
 
192
 
 
193
}