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-2018 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  typedef std::vector<std::string> strvec;
47  typedef std::vector<std::pair<int, int> > intpairvec;
48 
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 
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 
106  public:
107  friend class SlaterDeterminant;
108  MOInfo(Wavefunction& ref_wf_, Options& options_, bool silent_ = false);
109  ~MOInfo();
110 
111  // DGEMM timing
112  void set_dgemm_timing(double value) { dgemm_timing = value; }
113  void add_dgemm_timing(double value) { dgemm_timing += value; }
114  double get_dgemm_timing() const { return (dgemm_timing); }
115 
116  // Convergence Options
117  double get_no_damp_convergence() const { return (no_damp_convergence); }
118 
119  intvec get_mo_sym() const { return (all_sym); }
120  int get_mo_sym(int i) const { return (all_sym[i]); }
121  int get_wfn_sym() const { return (wfn_sym); }
122  int get_root() const { return (root); }
123 
124  int get_nmo() const { return (nmo); }
125  int get_nactive_ael() const { return (nactive_ael); }
126  int get_nactive_bel() const { return (nactive_bel); }
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  double get_scf_energy() const { return (scf_energy); }
176  double get_fzcore_energy() const { return (fzcore_energy); }
177  void set_fzcore_energy(double efzc) { fzcore_energy = efzc; }
178 
179  // Model space functions
180  void setup_model_space();
181  int get_nrefs() { return (all_refs.size()); };
182  int get_nunique() { return (unique_refs.size()); };
183  int get_ref_number(int n, ReferenceType ref_type = AllRefs);
184  int get_ref_size(ReferenceType ref_type);
185  std::string get_determinant_label(int i);
186 
187  strvec get_matrix_names(std::string str);
188  intvec get_aocc(int i, ReferenceType ref_type);
189  intvec get_bocc(int i, ReferenceType ref_type);
190  intvec get_avir(int i, ReferenceType ref_type);
191  intvec get_bvir(int i, ReferenceType ref_type);
192 
193  boolvec get_is_aocc(int i, ReferenceType ref_type);
194  boolvec get_is_bocc(int i, ReferenceType ref_type);
195  boolvec get_is_avir(int i, ReferenceType ref_type);
196  boolvec get_is_bvir(int i, ReferenceType ref_type);
197 
198  intvec get_determinant(int i); // Array with occupation of reference i (in all ordering)
199 
202  double get_sign_internal_excitation(int i, int j);
203 
204  private:
205  void tuning();
206  void read_info();
207  void read_mo_spaces();
208  void read_mo_spaces2();
209  void compute_mo_mappings();
210  void print_info();
211  void print_mo();
212  void free_memory();
213 
214  // Model space functions
215  void print_model_space();
216  void build_model_space();
218 
220  // MOInfo variables
221  int root;
222 
223  double scf_energy;
225 
227  double dgemm_timing;
228  // In-core/Out-of-core
230 
231  int nel;
233 
234  // Total number of orbitals in each space
235  int nfocc; // Frozen doubly-occupied MOs
236  int nfvir; // Frozen external MOs
237  int nactv_docc; // Number of active ???
238  int nocc; // Generalized occupied (docc + actv)
239  int nvir; // Generalized virtual (actv + extr)
240  int nall; // Non-frozen MOs (docc + actv + extr)
241  int nextr; // Non-frozen external orbitals (extr)
242 
243  // Orbitals arrays
252 
253  // Mapping arrays
277 
278  // Symmetry
280 
281  // Model space
282  std::vector<SlaterDeterminant> references;
283  std::vector<std::vector<std::vector<std::pair<int, int> > > > alpha_internal_excitations;
284  std::vector<std::vector<std::vector<std::pair<int, int> > > > beta_internal_excitations;
285  std::vector<std::vector<double> > sign_internal_excitations;
286  std::vector<int> all_refs;
287  std::vector<int> unique_refs;
288  std::vector<int> closed_shell_refs;
289  std::vector<int> unique_open_shell_refs;
290 };
291 
292 } // namespace psi
293 
294 #endif // _psi_src_lib_libmoinfo_moinfo_h_
std::bitset< size_det > bitdet
Definition: moinfo.h:77
intvec extr_to_mo
Definition: moinfo.h:260
intvec get_extr_to_mo() const
Definition: moinfo.h:158
void set_dgemm_timing(double value)
Definition: moinfo.h:112
void read_mo_spaces()
Definition: moinfo.cc:227
int nfocc
Definition: moinfo.h:235
intvec get_docc() const
Definition: moinfo.h:137
bool is_closed_shell()
Definition: moinfo_slaterdeterminant.cc:41
void tuning()
boolvec get_is_actv_in_occ() const
Definition: moinfo.h:168
int get_ref_number(int n, ReferenceType ref_type=AllRefs)
Definition: moinfo_model_space.cc:253
std::vector< std::vector< std::vector< std::pair< int, int > > > > alpha_internal_excitations
Definition: moinfo.h:283
boolvec get_is_avir()
Definition: moinfo_slaterdeterminant.cc:186
intvec get_bvir(int i, ReferenceType ref_type)
Definition: moinfo_model_space.cc:316
int reference
Definition: moinfo.h:232
int nall
Definition: moinfo.h:240
int get_nfocc() const
Definition: moinfo.h:129
intvec focc
Definition: moinfo.h:244
intvec get_focc() const
Definition: moinfo.h:139
int get_nall() const
Definition: moinfo.h:128
intvec occ_to_all
Definition: moinfo.h:273
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:261
intvec occ
Definition: moinfo.h:246
intvec mo_to_occ_act
Definition: moinfo.h:264
Definition: moinfo_base.h:57
intvec all_to_mo
Definition: moinfo.h:254
int get_all_to_mo(int i) const
Definition: moinfo.h:173
strvec get_matrix_names(std::string str)
Definition: moinfo_model_space.cc:282
int nactive_ael
Definition: moinfo_base.h:115
int get_wfn_sym() const
Definition: moinfo.h:121
Definition: moinfo.h:43
intvec sopi
Definition: moinfo_base.h:119
void print_model_space()
Definition: moinfo_model_space.cc:47
boolvec get_is_bvir()
Definition: moinfo_slaterdeterminant.cc:193
double create(bitdet &bits_det, int so)
Definition: moinfo_slaterdeterminant.cc:133
intvec get_actv_to_occ() const
Definition: moinfo.h:164
intvec get_aocc()
Definition: moinfo_slaterdeterminant.cc:144
std::vector< std::string > strvec
Definition: moinfo.h:46
int nocc
Definition: moinfo.h:238
void add_dgemm_timing(double value)
Definition: moinfo.h:113
intvec get_occ_to_actv() const
Definition: moinfo.h:166
int get_nactive_bel() const
Definition: moinfo.h:126
intvec get_mo_to_all() const
Definition: moinfo.h:163
intvec get_vir_to_actv() const
Definition: moinfo.h:167
double annihilate(bitdet &bits_det, int so)
Definition: moinfo_slaterdeterminant.cc:122
intvec orbs_to_mo
Definition: moinfo.h:256
ReferenceType
Definition: moinfo.h:43
intvec get_aocc(int i, ReferenceType ref_type)
Definition: moinfo_model_space.cc:301
int get_actv(int i) const
Definition: moinfo.h:150
int root
Definition: moinfo.h:221
intvec all_to_vir
Definition: moinfo.h:268
void read_mo_spaces2()
double get_fzcore_energy() const
Definition: moinfo.h:176
double get_no_damp_convergence() const
Definition: moinfo.h:117
double dgemm_timing
Definition: moinfo.h:227
void print_info()
Definition: moinfo.cc:206
intvec get_all_to_mo() const
Definition: moinfo.h:162
int get_focc(int i) const
Definition: moinfo.h:148
bitdet bits
Definition: moinfo.h:102
boolvec get_is_avir(int i, ReferenceType ref_type)
Definition: moinfo_model_space.cc:331
Definition: pointgrp.h:104
intvec actv_docc
Definition: moinfo.h:250
intvec vir_to_actv
Definition: moinfo.h:272
int get_all_to_vir(int i) const
Definition: moinfo.h:172
char get_occupation_symbol(int i)
Definition: moinfo_slaterdeterminant.cc:200
std::vector< std::string > strvec
Definition: libpsi4util.h:41
double scf_energy
Definition: moinfo.h:223
intvec get_extr() const
Definition: moinfo.h:140
Definition: moinfo.h:73
intvec vir_to_mo
Definition: moinfo.h:263
Definition: moinfo.h:43
int get_nmo() const
Definition: moinfo.h:124
void read_info()
Definition: moinfo.cc:109
int get_nrefs()
Definition: moinfo.h:181
intvec extr_to_all
Definition: moinfo.h:274
void make_internal_excitations()
Definition: moinfo_model_space.cc:199
Definition: moinfo.h:45
SlaterDeterminant(const MOInfo *)
Definition: moinfo_slaterdeterminant.cc:34
intvec all_sym
Definition: moinfo.h:279
std::vector< int > all_refs
Definition: moinfo.h:286
double get_scf_energy() const
Definition: moinfo.h:175
intvec get_sopi() const
Definition: moinfo.h:135
boolvec get_is_bocc()
Definition: moinfo_slaterdeterminant.cc:179
int nactive_bel
Definition: moinfo_base.h:116
boolvec get_is_bvir(int i, ReferenceType ref_type)
Definition: moinfo_model_space.cc:336
intvec occ_to_actv
Definition: moinfo.h:271
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:187
std::vector< SlaterDeterminant > references
Definition: moinfo.h:282
void compute_mo_mappings()
Definition: moinfo_mappings.cc:36
intvec get_actv_to_vir() const
Definition: moinfo.h:165
intvec get_all() const
Definition: moinfo.h:144
int nfvir
Definition: moinfo.h:236
int get_mo_sym(int i) const
Definition: moinfo.h:120
std::vector< int > unique_refs
Definition: moinfo.h:287
intvec get_vir_to_mo() const
Definition: moinfo.h:161
boolvec is_actv_in_vir
Definition: moinfo.h:276
int get_nunique()
Definition: moinfo.h:182
std::vector< std::vector< double > > sign_internal_excitations
Definition: moinfo.h:285
intvec actv_to_vir
Definition: moinfo.h:270
intvec all
Definition: moinfo.h:248
boolvec is_actv_in_occ
Definition: moinfo.h:275
int get_ref_size(ReferenceType ref_type)
Definition: moinfo_model_space.cc:269
intvec all_to_occ
Definition: moinfo.h:267
const MOInfo * moinfo
Definition: moinfo.h:74
void set_fzcore_energy(double efzc)
Definition: moinfo.h:177
intvec get_occ() const
Definition: moinfo.h:142
int get_root() const
Definition: moinfo.h:122
double fzcore_energy
Definition: moinfo.h:224
intpairvec get_alpha_internal_excitation(int i, int j)
Definition: moinfo_model_space.cc:240
intpairvec get_beta_internal_excitation(int i, int j)
Definition: moinfo_model_space.cc:244
intvec get_bvir()
Definition: moinfo_slaterdeterminant.cc:165
int nmo
Definition: moinfo_base.h:110
int get_nactive_ael() const
Definition: moinfo.h:125
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:57
intvec get_bocc()
Definition: moinfo_slaterdeterminant.cc:151
std::vector< int > closed_shell_refs
Definition: moinfo.h:288
Definition: liboptions.h:353
intvec mopi
Definition: moinfo.h:251
int get_sopi(int i) const
Definition: moinfo.h:146
int nactv_docc
Definition: moinfo.h:237
intvec actv_to_mo
Definition: moinfo.h:259
~MOInfo()
Definition: moinfo.cc:107
Definition: moinfo.h:43
boolvec get_is_actv_in_vir() const
Definition: moinfo.h:169
int wfn_sym
Definition: moinfo_base.h:105
intvec get_fvir_to_mo() const
Definition: moinfo.h:159
intvec get_avir()
Definition: moinfo_slaterdeterminant.cc:158
std::vector< int > unique_open_shell_refs
Definition: moinfo.h:289
int get_fvir(int i) const
Definition: moinfo.h:152
void free_memory()
Definition: moinfo.cc:428
boolvec get_is_aocc()
Definition: moinfo_slaterdeterminant.cc:172
std::vector< int > intvec
Definition: moinfo_base.h:49
void build_model_space()
Definition: moinfo_model_space.cc:61
intvec occ_to_mo
Definition: moinfo.h:262
int get_mopi(int i) const
Definition: moinfo.h:147
std::string get_determinant_label(int i)
Definition: moinfo_model_space.cc:45
intvec vir
Definition: moinfo.h:247
intvec actv
Definition: moinfo_base.h:121
Simple wavefunction base class.
Definition: wavefunction.h:85
~SlaterDeterminant()
Definition: moinfo_slaterdeterminant.cc:36
intvec get_occ_to_mo() const
Definition: moinfo.h:160
intvec extr
Definition: moinfo.h:249
intvec mo_to_act_vir
Definition: moinfo.h:265
std::string get_label()
Definition: moinfo_slaterdeterminant.cc:61
int get_all_to_occ(int i) const
Definition: moinfo.h:171
intvec docc
Definition: moinfo_base.h:120
intvec actv_to_occ
Definition: moinfo.h:269
intvec get_vir() const
Definition: moinfo.h:143
int get_nfvir() const
Definition: moinfo.h:131
intvec get_focc_to_mo() const
Definition: moinfo.h:155
intvec focc_to_mo
Definition: moinfo.h:257
int nextr
Definition: moinfo.h:241
intvec get_avir(int i, ReferenceType ref_type)
Definition: moinfo_model_space.cc:311
int get_nvir() const
Definition: moinfo.h:133
intvec get_actv() const
Definition: moinfo.h:138
int nel
Definition: moinfo.h:231
std::vector< std::vector< std::vector< std::pair< int, int > > > > beta_internal_excitations
Definition: moinfo.h:284
intvec get_docc_to_mo() const
Definition: moinfo.h:156
double get_sign_internal_excitation(int i, int j)
Definition: moinfo_model_space.cc:248
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:85
intvec fvir
Definition: moinfo.h:245
bool test(int n) const
Definition: moinfo.h:81
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:119
std::vector< bool > boolvec
Definition: moinfo_base.h:50
intvec docc_to_mo
Definition: moinfo.h:258
intvec occ_to_vir
Definition: moinfo.h:266
intvec get_bocc(int i, ReferenceType ref_type)
Definition: moinfo_model_space.cc:306
std::vector< std::pair< int, int > > intpairvec
Definition: moinfo.h:47
void print_mo()
Definition: moinfo.cc:405
double no_damp_convergence
Definition: moinfo.h:229
bool is_spin_flipped(SlaterDeterminant &det)
Definition: moinfo_slaterdeterminant.cc:50
int nvir
Definition: moinfo.h:239
bitdet & get_bits()
Definition: moinfo.h:84
boolvec get_is_bocc(int i, ReferenceType ref_type)
Definition: moinfo_model_space.cc:326
double get_dgemm_timing() const
Definition: moinfo.h:114
intvec get_determinant(int i)
Definition: moinfo_model_space.cc:233
intvec mo_to_all
Definition: moinfo.h:255
boolvec get_is_aocc(int i, ReferenceType ref_type)
Definition: moinfo_model_space.cc:321