~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_model_space.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 <cmath>
 
3
#include <cstdlib>
 
4
 
 
5
#include <psifiles.h>
 
6
#include <liboptions/liboptions.h>
 
7
#include <libutil/libutil.h>
 
8
 
 
9
#include "moinfo.h"
 
10
 
 
11
extern FILE *outfile;
 
12
 
 
13
using namespace std;
 
14
 
 
15
namespace psi {
 
16
 
 
17
void MOInfo::print_model_space()
 
18
{
 
19
  fprintf(outfile,"\n");
 
20
  fprintf(outfile,"\n  Model space");
 
21
  fprintf(outfile,"\n  ------------------------------------------------------------------------------");
 
22
  for(int i=0;i<references.size();i++){
 
23
    fprintf(outfile,"\n  %2d) ",i);
 
24
    references[i].print_occ();
 
25
  }
 
26
  fprintf(outfile,"\n  ==============================================================================");
 
27
}
 
28
 
 
29
void MOInfo::build_model_space()
 
30
{
 
31
  /********************************************************
 
32
    Generate all the Slater Determinants belonging to the
 
33
    model space using the following restrictions:
 
34
    -docc are doubly    occupied
 
35
    -actv are partially occupied
 
36
    -the generalized occupied orbital indexing (docc + actv)
 
37
     is assumed (see moinfo.cpp)
 
38
  ********************************************************/
 
39
  int index;
 
40
  MOInfo::SlaterDeterminant docc_det;
 
41
 
 
42
  /***********************************************
 
43
    Generate all combinations of active orbitals
 
44
  ***********************************************/
 
45
  if(options_get_str("CORR_WFN") != "MP2-CCSD"){
 
46
    /********************************************************
 
47
      Set up the doubly occupied part of all the
 
48
      determinants in the model space
 
49
    ********************************************************/
 
50
    index = 0;
 
51
    for(int h=0;h<nirreps;h++){
 
52
      for(int i=0;i<docc[h];i++){
 
53
        docc_det.set(index);
 
54
        docc_det.set(index+nmo);
 
55
        index++;
 
56
      }
 
57
      index+=actv[h];
 
58
      index+=avir[h];
 
59
    }
 
60
    
 
61
    /********************************************************
 
62
      Set up the a vectors containing the active orbitals and
 
63
      their symmetry
 
64
    ********************************************************/
 
65
    std::vector<int> alpha_active,alpha_active_sym,beta_active,beta_active_sym;
 
66
    index = 0;
 
67
    for(int h=0;h<nirreps;h++){
 
68
      index+=docc[h];
 
69
      for(int i=0;i<actv[h];i++){
 
70
        alpha_active.push_back(index);
 
71
        alpha_active_sym.push_back(h);
 
72
        beta_active.push_back(index + nmo);
 
73
        beta_active_sym.push_back(h);
 
74
        index++;
 
75
      }
 
76
      index+=avir[h];
 
77
    }
 
78
    
 
79
    std::vector<std::vector<int> > alpha_combinations,beta_combinations;
 
80
    generate_combinations(nactv,nactive_ael,alpha_combinations);
 
81
    generate_combinations(nactv,nactive_bel,beta_combinations);
 
82
    if(alpha_combinations.size()==0)
 
83
      alpha_combinations.push_back(vector<int>(0));
 
84
    if(beta_combinations.size()==0)
 
85
      beta_combinations.push_back(vector<int>(0));
 
86
    for(int a=0;a<alpha_combinations.size();a++){
 
87
      for(int b=0;b<beta_combinations.size();b++){
 
88
        int sym = 0; // Symmetry of the determinant
 
89
        // Create a copy of the docc_det
 
90
        SlaterDeterminant det(docc_det);
 
91
        // Fill the alpha active orbitals
 
92
        for(int i=0;i<nactive_ael;i++){
 
93
          det.set(alpha_active[alpha_combinations[a][i]]);
 
94
          sym = sym ^ alpha_active_sym[alpha_combinations[a][i]];
 
95
        }
 
96
        // Fill the beta active orbitals
 
97
        for(int i=0;i<nactive_bel;i++){
 
98
          det.set(beta_active[beta_combinations[b][i]]);
 
99
          sym = sym ^  beta_active_sym[beta_combinations[b][i]];
 
100
        }
 
101
        // Test the wfn symmetry
 
102
        if(sym==wfn_sym){
 
103
          if(det.is_closed_shell()){
 
104
            // Closed-shell determinant
 
105
            closed_shell_refs.push_back(references.size());
 
106
            unique_refs.push_back(references.size());
 
107
            all_refs.push_back(references.size());
 
108
          }else{
 
109
            // Open-shell determinant
 
110
            bool add_it = true;
 
111
            int  spin_mirror = references.size();
 
112
            if(options_get_bool("USE_SPIN_SYMMETRY")){
 
113
              // Check if this is a spin-flipped determinant
 
114
              for(int ref=0;ref<references.size();ref++){
 
115
                if(references[ref].is_spin_flipped(det)){
 
116
                  add_it      = false;
 
117
                  spin_mirror = ref;
 
118
                }
 
119
              }
 
120
              if(add_it){
 
121
                unique_open_shell_refs.push_back(references.size());
 
122
                unique_refs.push_back(references.size());
 
123
                all_refs.push_back(references.size());
 
124
              }else{
 
125
                all_refs.push_back(spin_mirror);
 
126
              }
 
127
            }
 
128
          }
 
129
          references.push_back(det);
 
130
        }
 
131
      }
 
132
    }
 
133
  }else{
 
134
    /********************************************************
 
135
      Set up the doubly occupied part of all the
 
136
      determinants in the model space
 
137
    ********************************************************/
 
138
    index = 0;
 
139
    for(int h=0;h<nirreps;h++){
 
140
      for(int i=0;i<docc[h] + actv_docc[h];i++){
 
141
        docc_det.set(index);
 
142
        docc_det.set(index+nmo);
 
143
        index++;
 
144
      }
 
145
      index+=actv[h] - actv_docc[h];
 
146
      index+=avir[h];
 
147
    }   
 
148
    closed_shell_refs.push_back(references.size());
 
149
    unique_refs.push_back(references.size());
 
150
    all_refs.push_back(references.size());
 
151
    references.push_back(docc_det);
 
152
  }
 
153
 
 
154
  if(references.size() == 0){
 
155
    fprintf(outfile,"\n\n  MOInfo found no reference in the model space");
 
156
    fprintf(outfile,"\n  Please check the following:");
 
157
    fprintf(outfile,"\n  1) Definition of FOCC, DOCC, ACTV, and FVIR");
 
158
    fprintf(outfile,"\n  2) Symmetry of the wavefunction");
 
159
    fprintf(outfile,"\n  3) Charge and multiplicity");
 
160
    fprintf(outfile,"\n\n  PSIMRCC will end the computation.\n");
 
161
    fflush(outfile);
 
162
    exit(PSI_RETURN_FAILURE);
 
163
  }
 
164
}
 
165
 
 
166
/*!
 
167
    \fn MOInfo::make_internal_excitations()
 
168
 */
 
169
void MOInfo::make_internal_excitations()
 
170
{
 
171
  /****************************************
 
172
    Build the mappings between references
 
173
    |m> = (+/-) ... b+ j a+ i |n>
 
174
  ****************************************/
 
175
  for(int m=0;m<references.size();m++){
 
176
    vector<vector<pair<int,int> > > alpha_internals_ref_m;
 
177
    vector<vector<pair<int,int> > >  beta_internals_ref_m;
 
178
    vector<double>                   sign_internals_ref_m;
 
179
//     DEBUGGING(1,
 
180
//       fprintf(outfile,"\n\n\tReference ");
 
181
//       references[m].print_occ();
 
182
//       fprintf(outfile," gives:");
 
183
//     );
 
184
    for(int n=0;n<references.size();n++){
 
185
      double sign=1.0;
 
186
      std::vector<pair<int,int> > alpha_operators;
 
187
      std::vector<pair<int,int> > beta_operators;
 
188
      references[m].get_internal_excitations(references[n],sign,alpha_operators,beta_operators);
 
189
      alpha_internals_ref_m.push_back(alpha_operators);
 
190
      beta_internals_ref_m.push_back(beta_operators);
 
191
      sign_internals_ref_m.push_back(sign);
 
192
//       DEBUGGING(1,
 
193
//         fprintf(outfile,"\n\t  ");
 
194
//         references[n].print_occ();
 
195
//         fprintf(outfile," = %s{",sign > 0.0 ? "+" : (sign == 0.0 ? "0" : "-"));
 
196
//         for(int i = 0; i<beta_operators.size();i++)
 
197
//           fprintf(outfile," %db+ %db-",beta_operators[i].second,beta_operators[i].first);
 
198
//         for(int i = 0; i<alpha_operators.size();i++)
 
199
//           fprintf(outfile," %da+ %da-",alpha_operators[i].second,alpha_operators[i].first);
 
200
//         fprintf(outfile," }");
 
201
//         references[m].print_occ();
 
202
//       );
 
203
    }
 
204
    alpha_internal_excitations.push_back(alpha_internals_ref_m);
 
205
    beta_internal_excitations.push_back(beta_internals_ref_m);
 
206
    sign_internal_excitations.push_back(sign_internals_ref_m);
 
207
  }
 
208
}
 
209
 
 
210
vector<int> MOInfo::get_aocc(string str,int i)
 
211
{
 
212
  int i_ref = get_ref_number(str,i);
 
213
  return(references[i_ref].get_aocc());
 
214
}
 
215
 
 
216
vector<int> MOInfo::get_bocc(std::string str,int i)
 
217
{
 
218
  int i_ref = get_ref_number(str,i);
 
219
  return(references[i_ref].get_bocc());
 
220
}
 
221
 
 
222
vector<int> MOInfo::get_avir(std::string str,int i)
 
223
{
 
224
  int i_ref = get_ref_number(str,i);
 
225
  return(references[i_ref].get_avir());
 
226
}
 
227
 
 
228
vector<int> MOInfo::get_bvir(std::string str,int i)
 
229
{
 
230
  int i_ref = get_ref_number(str,i);
 
231
  return(references[i_ref].get_bvir());
 
232
}
 
233
 
 
234
vector<int> MOInfo::get_aocc(int i)
 
235
{
 
236
  return(references[i].get_aocc());
 
237
}
 
238
 
 
239
vector<int> MOInfo::get_bocc(int i)
 
240
{
 
241
  return(references[i].get_bocc());
 
242
}
 
243
 
 
244
vector<int> MOInfo::get_auoc(int i)
 
245
{
 
246
  return(references[i].get_avir());
 
247
}
 
248
 
 
249
vector<int> MOInfo::get_buoc(int i)
 
250
{
 
251
  return(references[i].get_bvir());
 
252
}
 
253
 
 
254
 
 
255
 
 
256
vector<pair<int,int> > MOInfo::get_alpha_internal_excitation(int i,int j)
 
257
{
 
258
  return(alpha_internal_excitations[i][j]);
 
259
}
 
260
 
 
261
vector<pair<int,int> > MOInfo::get_beta_internal_excitation(int i,int j)
 
262
{
 
263
  return(beta_internal_excitations[i][j]);
 
264
}
 
265
 
 
266
double  MOInfo::get_sign_internal_excitation(int i,int j)
 
267
{
 
268
  return(sign_internal_excitations[i][j]);
 
269
}
 
270
 
 
271
/*!
 
272
    \fn MOInfo::get_ref_number(string str, int n)
 
273
 */
 
274
int MOInfo::get_ref_number(string str, int n)
 
275
{
 
276
  if(str=="a")
 
277
    return(all_refs[n]);
 
278
  if(str=="u")
 
279
    return(unique_refs[n]);
 
280
  if(str=="c")
 
281
    return(closed_shell_refs[n]);
 
282
  if(str=="o")
 
283
    return(unique_open_shell_refs[n]);
 
284
  print_error("MOInfo::get_ref_number(string str, int n) undefined space", __FILE__,__LINE__);
 
285
  return(NULL);
 
286
}
 
287
 
 
288
/*!
 
289
    \fn MOInfo::get_ref_size(string str)
 
290
 */
 
291
int MOInfo::get_ref_size(string str)
 
292
{
 
293
  if(str=="a")
 
294
    return(all_refs.size());
 
295
  if(str=="u")
 
296
    return(unique_refs.size());
 
297
  if(str=="c")
 
298
    return(closed_shell_refs.size());
 
299
  if(str=="o")
 
300
    return(unique_open_shell_refs.size());
 
301
  print_error("MOInfo::get_ref_size(string str) undefined space", __FILE__,__LINE__);
 
302
  return(NULL);
 
303
}
 
304
 
 
305
vector<string> MOInfo::get_matrix_names(std::string str)
 
306
{
 
307
  vector<string> names;
 
308
  if(str.find("{a}")!=string::npos){
 
309
    for(int n=0;n<all_refs.size();n++)
 
310
      names.push_back(find_and_replace(str,"{a}","{" + to_string(all_refs[n]) +"}"));
 
311
  }else if(str.find("{u}")!=string::npos){
 
312
    for(int n=0;n<unique_refs.size();n++)
 
313
      names.push_back(find_and_replace(str,"{u}","{" + to_string(unique_refs[n]) +"}"));
 
314
  }else if(str.find("{c}")!=string::npos){
 
315
    for(int n=0;n<closed_shell_refs.size();n++)
 
316
      names.push_back(find_and_replace(str,"{c}","{" + to_string(closed_shell_refs[n]) +"}"));
 
317
  }else if(str.find("{o}")!=string::npos){
 
318
    for(int n=0;n<unique_open_shell_refs.size();n++)
 
319
      names.push_back(find_and_replace(str,"{o}","{" + to_string(unique_open_shell_refs[n]) +"}"));
 
320
  }else 
 
321
    names.push_back(str);
 
322
  return(names);
 
323
}
 
324
 
 
325
}
 
 
b'\\ No newline at end of file'