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