Psi4
moinfo.h
Go to the documentation of this file.
1 /*
2  * @BEGIN LICENSE
3  *
4  * Psi4: an open-source quantum chemistry software package
5  *
6  * Copyright (c) 2007-2017 The Psi4 Developers.
7  *
8  * The copyrights for code used from other parties are included in
9  * the corresponding files.
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  *
25  * @END LICENSE
26  */
27 
28 #ifndef _psi_src_lib_libmoinfo_moinfo_h_
29 #define _psi_src_lib_libmoinfo_moinfo_h_
30 
31 #include <bitset>
32 #include <string>
33 #include <vector>
34 #include <utility>
35 
36 #include "moinfo_base.h"
37 
38 #define size_det 2048
39 
40 namespace psi {
41 
43 
44 class MOInfo : public MOInfoBase
45 {
46 
47  typedef std::vector<std::string> strvec;
48  typedef std::vector<std::pair<int,int> > intpairvec;
49 public:
50  /*********************************************************
51  SlaterDeterminant Class
52  1) Purpose
53  This class is used to store all the information that
54  belongs to a Slater Determinant
55  2) Use
56  3) Details
57  The MOs that describe the reference are stored in the
58  arrays aocc,bocc,avir and bvir. These refer to the MOs
59  in Pitzer order with the frozen occupied and virtual
60  already excluded. Therefore this code assumes that the
61  integral transformation code has already eliminated
62  the frozen integrals and relabeled them.
63 
64  type stores the type of reference
65  type = 0 -> closed-shell determinant
66  type = 2 -> open-shell determinant
67 
68  number stores the ID of this reference
69 
70  4) Uses
71  STL vector
72  *********************************************************/
74  const MOInfo* moinfo;
75  public:
76  typedef std::bitset<size_det> bitdet;
77  SlaterDeterminant(const MOInfo *);
79  void set(int n) {bits.set(n);}
80  bool test(int n) const {return(bits.test(n));}
81  bool is_closed_shell();
83  bitdet& get_bits() {return(bits);}
84  void get_internal_excitations(SlaterDeterminant& det, double& sign,
85  std::vector<std::pair<int,int> >& alpha_operators,
86  std::vector<std::pair<int,int> >& beta_operators);
87  char get_occupation_symbol(int i);
88  std::string get_label();
89  intvec get_aocc();
90  intvec get_bocc();
91  intvec get_avir();
92  intvec get_bvir();
97 
98  private:
99  double annihilate(bitdet& bits_det,int so);
100  double create(bitdet& bits_det,int so);
102  std::string type;
103  };
104 public:
105  friend class SlaterDeterminant;
106  MOInfo(Wavefunction& ref_wf_, Options& options_, bool silent_ = false);
107  ~MOInfo();
108 
109  // DGEMM timing
110  void set_dgemm_timing(double value) {dgemm_timing=value;}
111  void add_dgemm_timing(double value) {dgemm_timing+=value;}
112  double get_dgemm_timing() const {return(dgemm_timing);}
113 
114  // Convergence Options
116 
117  intvec get_mo_sym() const {return(all_sym);}
118  int get_mo_sym(int i) const {return(all_sym[i]);}
119  int get_wfn_sym() const {return(wfn_sym);}
120  int get_root() const {return(root);}
121 
122  int get_nmo() const {return(nmo);}
123  int get_nactive_ael() const {return(nactive_ael);}
124  int get_nactive_bel() const {return(nactive_bel);}
125 
126 
127  int get_nall() const {return(nall);}
128  int get_nfocc() const {return(nfocc);}
129  int get_nextr() const {return(nextr);}
130  int get_nfvir() const {return(nfvir);}
131  int get_nocc() const {return(nocc);}
132  int get_nvir() const {return(nvir);}
133 
134  intvec get_sopi() const {return(sopi);}
135  intvec get_mopi() const {return(mopi);}
136  intvec get_docc() const {return(docc);}
137  intvec get_actv() const {return(actv);}
138  intvec get_focc() const {return(focc);}
139  intvec get_extr() const {return(extr);}
140  intvec get_fvir() const {return(fvir);}
141  intvec get_occ() const {return(occ);}
142  intvec get_vir() const {return(vir);}
143  intvec get_all() const {return(all);}
144 
145  int get_sopi(int i) const {return(sopi[i]);}
146  int get_mopi(int i) const {return(mopi[i]);}
147  int get_focc(int i) const {return(focc[i]);}
148  int get_docc(int i) const {return(docc[i]);}
149  int get_actv(int i) const {return(actv[i]);}
150  int get_extr(int h) const {return(extr[h]);}
151  int get_fvir(int i) const {return(fvir[i]);}
152 
153  // Mapping functions
154  intvec get_focc_to_mo() const {return(focc_to_mo);}
155  intvec get_docc_to_mo() const {return(docc_to_mo);}
156  intvec get_actv_to_mo() const {return(actv_to_mo);}
157  intvec get_extr_to_mo() const {return(extr_to_mo);}
158  intvec get_fvir_to_mo() const {return(fvir_to_mo);}
159  intvec get_occ_to_mo() const {return(occ_to_mo);}
160  intvec get_vir_to_mo() const {return(vir_to_mo);}
161  intvec get_all_to_mo() const {return(all_to_mo);}
162  intvec get_mo_to_all() const {return(mo_to_all);}
163  intvec get_actv_to_occ() const {return(actv_to_occ);}
164  intvec get_actv_to_vir() const {return(actv_to_vir);}
165  intvec get_occ_to_actv() const {return(occ_to_actv);}
166  intvec get_vir_to_actv() const {return(vir_to_actv);}
169 
170  int get_all_to_occ(int i) const {return(all_to_occ[i]);}
171  int get_all_to_vir(int i) const {return(all_to_vir[i]);}
172  int get_all_to_mo(int i) const {return(all_to_mo[i]);}
173 
174 
175 
176  double get_scf_energy() const {return(scf_energy);}
177  double get_fzcore_energy() const {return(fzcore_energy);}
178  void set_fzcore_energy(double efzc) {fzcore_energy=efzc;}
179 
180  // Model space functions
181  void setup_model_space();
182  int get_nrefs() {return(all_refs.size());};
183  int get_nunique() {return(unique_refs.size());};
184  int get_ref_number(int n, ReferenceType ref_type = AllRefs);
185  int get_ref_size(ReferenceType ref_type);
186  std::string get_determinant_label(int i);
187 
188  strvec get_matrix_names(std::string str);
189  intvec get_aocc(int i, ReferenceType ref_type);
190  intvec get_bocc(int i, ReferenceType ref_type);
191  intvec get_avir(int i, ReferenceType ref_type);
192  intvec get_bvir(int i, ReferenceType ref_type);
193 
194  boolvec get_is_aocc(int i, ReferenceType ref_type);
195  boolvec get_is_bocc(int i, ReferenceType ref_type);
196  boolvec get_is_avir(int i, ReferenceType ref_type);
197  boolvec get_is_bvir(int i, ReferenceType ref_type);
198 
199  intvec get_determinant(int i); // Array with occupation of reference i (in all ordering)
200 
203  double get_sign_internal_excitation(int i,int j);
204 
205 private:
206  void tuning();
207  void read_info();
208  void read_mo_spaces();
209  void read_mo_spaces2();
210  void compute_mo_mappings();
211  void print_info();
212  void print_mo();
213  void free_memory();
214 
215  // Model space functions
216  void print_model_space();
217  void build_model_space();
219 
221  // MOInfo variables
222  int root;
223 
224 
225  double scf_energy;
227 
229  double dgemm_timing;
230  // In-core/Out-of-core
232 
233  int nel;
235 
236  // Total number of orbitals in each space
237  int nfocc; // Frozen doubly-occupied MOs
238  int nfvir; // Frozen external MOs
239  int nactv_docc; // Number of active ???
240  int nocc; // Generalized occupied (docc + actv)
241  int nvir; // Generalized virtual (actv + extr)
242  int nall; // Non-frozen MOs (docc + actv + extr)
243  int nextr; // Non-frozen external orbitals (extr)
244 
245  // Orbitals arrays
254 
255  // Mapping arrays
279 
280  // Symmetry
282 
283  // Model space
284  std::vector<SlaterDeterminant> references;
285  std::vector<std::vector<std::vector<std::pair<int,int> > > > alpha_internal_excitations;
286  std::vector<std::vector<std::vector<std::pair<int,int> > > > beta_internal_excitations;
287  std::vector<std::vector<double> > sign_internal_excitations;
288  std::vector<int> all_refs;
289  std::vector<int> unique_refs;
290  std::vector<int> closed_shell_refs;
291  std::vector<int> unique_open_shell_refs;
292 };
293 
294 }
295 
296 #endif // _psi_src_lib_libmoinfo_moinfo_h_
std::bitset< size_det > bitdet
Definition: moinfo.h:76
intvec extr_to_mo
Definition: moinfo.h:262
intvec get_extr_to_mo() const
Definition: moinfo.h:157
void set_dgemm_timing(double value)
Definition: moinfo.h:110
void read_mo_spaces()
Definition: moinfo.cc:242
int nfocc
Definition: moinfo.h:237
intvec get_docc() const
Definition: moinfo.h:136
bool is_closed_shell()
Definition: moinfo_slaterdeterminant.cc:51
void tuning()
boolvec get_is_actv_in_occ() const
Definition: moinfo.h:167
std::vector< std::vector< std::vector< std::pair< int, int > > > > alpha_internal_excitations
Definition: moinfo.h:285
int get_ref_number(int n, ReferenceType ref_type=AllRefs)
Definition: moinfo_model_space.cc:269
int reference
Definition: moinfo.h:234
int nall
Definition: moinfo.h:242
int get_nfocc() const
Definition: moinfo.h:128
intvec focc
Definition: moinfo.h:246
intvec get_focc() const
Definition: moinfo.h:138
int get_nall() const
Definition: moinfo.h:127
intvec occ_to_all
Definition: moinfo.h:275
intvec get_actv_to_mo() const
Definition: moinfo.h:156
int get_docc(int i) const
Definition: moinfo.h:148
intvec fvir_to_mo
Definition: moinfo.h:263
intvec occ
Definition: moinfo.h:248
intvec mo_to_occ_act
Definition: moinfo.h:266
Definition: moinfo_base.h:53
boolvec get_is_bocc()
Definition: moinfo_slaterdeterminant.cc:208
intvec all_to_mo
Definition: moinfo.h:256
int get_all_to_mo(int i) const
Definition: moinfo.h:172
int nactive_ael
Definition: moinfo_base.h:105
int get_wfn_sym() const
Definition: moinfo.h:119
Definition: moinfo.h:42
intvec sopi
Definition: moinfo_base.h:109
void print_model_space()
Definition: moinfo_model_space.cc:51
double create(bitdet &bits_det, int so)
Definition: moinfo_slaterdeterminant.cc:151
intvec get_actv_to_occ() const
Definition: moinfo.h:163
std::vector< std::string > strvec
Definition: moinfo.h:47
int nocc
Definition: moinfo.h:240
void add_dgemm_timing(double value)
Definition: moinfo.h:111
intvec get_occ_to_actv() const
Definition: moinfo.h:165
int get_nactive_bel() const
Definition: moinfo.h:124
intvec get_mo_to_all() const
Definition: moinfo.h:162
intvec get_determinant(int i)
Definition: moinfo_model_space.cc:242
strvec get_matrix_names(std::string str)
Definition: moinfo_model_space.cc:300
intvec get_vir_to_actv() const
Definition: moinfo.h:166
double annihilate(bitdet &bits_det, int so)
Definition: moinfo_slaterdeterminant.cc:138
intvec orbs_to_mo
Definition: moinfo.h:258
ReferenceType
Definition: moinfo.h:42
boolvec get_is_bocc(int i, ReferenceType ref_type)
Definition: moinfo_model_space.cc:350
int get_actv(int i) const
Definition: moinfo.h:149
int root
Definition: moinfo.h:222
intvec all_to_vir
Definition: moinfo.h:270
void read_mo_spaces2()
double get_fzcore_energy() const
Definition: moinfo.h:177
double get_no_damp_convergence() const
Definition: moinfo.h:115
intvec get_avir(int i, ReferenceType ref_type)
Definition: moinfo_model_space.cc:332
double dgemm_timing
Definition: moinfo.h:229
void print_info()
Definition: moinfo.cc:220
intpairvec get_alpha_internal_excitation(int i, int j)
Definition: moinfo_model_space.cc:251
intvec get_all_to_mo() const
Definition: moinfo.h:161
int get_focc(int i) const
Definition: moinfo.h:147
intvec get_bvir()
Definition: moinfo_slaterdeterminant.cc:191
bitdet bits
Definition: moinfo.h:101
Definition: pointgrp.h:105
intvec actv_docc
Definition: moinfo.h:252
boolvec get_is_avir()
Definition: moinfo_slaterdeterminant.cc:216
intvec vir_to_actv
Definition: moinfo.h:274
int get_all_to_vir(int i) const
Definition: moinfo.h:171
char get_occupation_symbol(int i)
Definition: moinfo_slaterdeterminant.cc:232
std::vector< std::string > strvec
Definition: libpsi4util.h:42
double scf_energy
Definition: moinfo.h:225
intvec get_extr() const
Definition: moinfo.h:139
Definition: moinfo.h:73
intvec vir_to_mo
Definition: moinfo.h:265
Definition: moinfo.h:42
int get_nmo() const
Definition: moinfo.h:122
void read_info()
Definition: moinfo.cc:117
int get_nrefs()
Definition: moinfo.h:182
intvec extr_to_all
Definition: moinfo.h:276
intvec get_aocc()
Definition: moinfo_slaterdeterminant.cc:164
void make_internal_excitations()
Definition: moinfo_model_space.cc:207
Definition: moinfo.h:44
SlaterDeterminant(const MOInfo *)
Definition: moinfo_slaterdeterminant.cc:37
intvec all_sym
Definition: moinfo.h:281
std::vector< int > all_refs
Definition: moinfo.h:288
double get_scf_energy() const
Definition: moinfo.h:176
intvec get_sopi() const
Definition: moinfo.h:134
int nactive_bel
Definition: moinfo_base.h:106
intvec occ_to_actv
Definition: moinfo.h:273
This class stores all the basic info regarding MOs.
intvec get_mopi() const
Definition: moinfo.h:135
int get_nocc() const
Definition: moinfo.h:131
void setup_model_space()
Definition: moinfo.cc:196
std::vector< SlaterDeterminant > references
Definition: moinfo.h:284
void compute_mo_mappings()
Definition: moinfo_mappings.cc:39
intvec get_actv_to_vir() const
Definition: moinfo.h:164
intvec get_all() const
Definition: moinfo.h:143
int nfvir
Definition: moinfo.h:238
intvec get_bvir(int i, ReferenceType ref_type)
Definition: moinfo_model_space.cc:338
int get_mo_sym(int i) const
Definition: moinfo.h:118
std::vector< int > unique_refs
Definition: moinfo.h:289
intvec get_vir_to_mo() const
Definition: moinfo.h:160
boolvec is_actv_in_vir
Definition: moinfo.h:278
int get_nunique()
Definition: moinfo.h:183
std::vector< std::vector< double > > sign_internal_excitations
Definition: moinfo.h:287
std::vector< std::pair< int, int > > intpairvec
Definition: moinfo.h:48
intvec actv_to_vir
Definition: moinfo.h:272
intvec all
Definition: moinfo.h:250
intpairvec get_beta_internal_excitation(int i, int j)
Definition: moinfo_model_space.cc:256
boolvec is_actv_in_occ
Definition: moinfo.h:277
int get_ref_size(ReferenceType ref_type)
Definition: moinfo_model_space.cc:286
intvec all_to_occ
Definition: moinfo.h:269
const MOInfo * moinfo
Definition: moinfo.h:74
void set_fzcore_energy(double efzc)
Definition: moinfo.h:178
intvec get_occ() const
Definition: moinfo.h:141
int get_root() const
Definition: moinfo.h:120
double fzcore_energy
Definition: moinfo.h:226
int nmo
Definition: moinfo_base.h:100
int get_nactive_ael() const
Definition: moinfo.h:123
std::string type
Definition: moinfo.h:102
Definition: moinfo.h:42
int get_nextr() const
Definition: moinfo.h:129
MOInfo(Wavefunction &ref_wf_, Options &options_, bool silent_=false)
Definition: moinfo.cc:58
boolvec get_is_bvir()
Definition: moinfo_slaterdeterminant.cc:224
std::vector< int > closed_shell_refs
Definition: moinfo.h:290
intvec get_bocc(int i, ReferenceType ref_type)
Definition: moinfo_model_space.cc:326
Definition: liboptions.h:359
intvec mopi
Definition: moinfo.h:253
int get_sopi(int i) const
Definition: moinfo.h:145
boolvec get_is_avir(int i, ReferenceType ref_type)
Definition: moinfo_model_space.cc:356
boolvec get_is_aocc(int i, ReferenceType ref_type)
Definition: moinfo_model_space.cc:344
int nactv_docc
Definition: moinfo.h:239
intvec actv_to_mo
Definition: moinfo.h:261
~MOInfo()
Definition: moinfo.cc:112
Definition: moinfo.h:42
boolvec get_is_actv_in_vir() const
Definition: moinfo.h:168
int wfn_sym
Definition: moinfo_base.h:95
intvec get_fvir_to_mo() const
Definition: moinfo.h:158
std::vector< int > unique_open_shell_refs
Definition: moinfo.h:291
int get_fvir(int i) const
Definition: moinfo.h:151
void free_memory()
Definition: moinfo.cc:452
std::vector< int > intvec
Definition: moinfo_base.h:45
void build_model_space()
Definition: moinfo_model_space.cc:66
intvec occ_to_mo
Definition: moinfo.h:264
int get_mopi(int i) const
Definition: moinfo.h:146
std::string get_determinant_label(int i)
Definition: moinfo_model_space.cc:46
intvec vir
Definition: moinfo.h:249
intvec actv
Definition: moinfo_base.h:111
Simple wavefunction base class.
Definition: wavefunction.h:85
~SlaterDeterminant()
Definition: moinfo_slaterdeterminant.cc:43
intvec get_occ_to_mo() const
Definition: moinfo.h:159
intvec extr
Definition: moinfo.h:251
intvec get_bocc()
Definition: moinfo_slaterdeterminant.cc:173
intvec mo_to_act_vir
Definition: moinfo.h:267
std::string get_label()
Definition: moinfo_slaterdeterminant.cc:77
int get_all_to_occ(int i) const
Definition: moinfo.h:170
std::vector< std::vector< std::vector< std::pair< int, int > > > > beta_internal_excitations
Definition: moinfo.h:286
intvec docc
Definition: moinfo_base.h:110
intvec actv_to_occ
Definition: moinfo.h:271
intvec get_vir() const
Definition: moinfo.h:142
int get_nfvir() const
Definition: moinfo.h:130
boolvec get_is_aocc()
Definition: moinfo_slaterdeterminant.cc:200
intvec get_focc_to_mo() const
Definition: moinfo.h:154
intvec focc_to_mo
Definition: moinfo.h:259
int nextr
Definition: moinfo.h:243
int get_nvir() const
Definition: moinfo.h:132
intvec get_actv() const
Definition: moinfo.h:137
int nel
Definition: moinfo.h:233
intvec get_docc_to_mo() const
Definition: moinfo.h:155
double get_sign_internal_excitation(int i, int j)
Definition: moinfo_model_space.cc:261
intvec get_fvir() const
Definition: moinfo.h:140
void get_internal_excitations(SlaterDeterminant &det, double &sign, std::vector< std::pair< int, int > > &alpha_operators, std::vector< std::pair< int, int > > &beta_operators)
Definition: moinfo_slaterdeterminant.cc:102
intvec fvir
Definition: moinfo.h:247
bool test(int n) const
Definition: moinfo.h:80
boolvec get_is_bvir(int i, ReferenceType ref_type)
Definition: moinfo_model_space.cc:362
int get_extr(int h) const
Definition: moinfo.h:150
void set(int n)
Definition: moinfo.h:79
intvec get_mo_sym() const
Definition: moinfo.h:117
intvec get_aocc(int i, ReferenceType ref_type)
Definition: moinfo_model_space.cc:320
std::vector< bool > boolvec
Definition: moinfo_base.h:46
intvec docc_to_mo
Definition: moinfo.h:260
intvec occ_to_vir
Definition: moinfo.h:268
void print_mo()
Definition: moinfo.cc:425
double no_damp_convergence
Definition: moinfo.h:231
bool is_spin_flipped(SlaterDeterminant &det)
Definition: moinfo_slaterdeterminant.cc:63
int nvir
Definition: moinfo.h:241
bitdet & get_bits()
Definition: moinfo.h:83
double get_dgemm_timing() const
Definition: moinfo.h:112
intvec mo_to_all
Definition: moinfo.h:257
intvec get_avir()
Definition: moinfo_slaterdeterminant.cc:182