6
#include <liboptions/liboptions.h>
7
#include <libutil/libutil.h>
17
void MOInfo::print_model_space()
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();
26
fprintf(outfile,"\n ==============================================================================");
29
void MOInfo::build_model_space()
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
********************************************************/
40
MOInfo::SlaterDeterminant docc_det;
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
********************************************************/
51
for(int h=0;h<nirreps;h++){
52
for(int i=0;i<docc[h];i++){
54
docc_det.set(index+nmo);
61
/********************************************************
62
Set up the a vectors containing the active orbitals and
64
********************************************************/
65
std::vector<int> alpha_active,alpha_active_sym,beta_active,beta_active_sym;
67
for(int h=0;h<nirreps;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);
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]];
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]];
101
// Test the wfn symmetry
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());
109
// Open-shell determinant
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)){
121
unique_open_shell_refs.push_back(references.size());
122
unique_refs.push_back(references.size());
123
all_refs.push_back(references.size());
125
all_refs.push_back(spin_mirror);
129
references.push_back(det);
134
/********************************************************
135
Set up the doubly occupied part of all the
136
determinants in the model space
137
********************************************************/
139
for(int h=0;h<nirreps;h++){
140
for(int i=0;i<docc[h] + actv_docc[h];i++){
142
docc_det.set(index+nmo);
145
index+=actv[h] - actv_docc[h];
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);
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");
162
exit(PSI_RETURN_FAILURE);
167
\fn MOInfo::make_internal_excitations()
169
void MOInfo::make_internal_excitations()
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;
180
// fprintf(outfile,"\n\n\tReference ");
181
// references[m].print_occ();
182
// fprintf(outfile," gives:");
184
for(int n=0;n<references.size();n++){
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);
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();
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);
210
vector<int> MOInfo::get_aocc(string str,int i)
212
int i_ref = get_ref_number(str,i);
213
return(references[i_ref].get_aocc());
216
vector<int> MOInfo::get_bocc(std::string str,int i)
218
int i_ref = get_ref_number(str,i);
219
return(references[i_ref].get_bocc());
222
vector<int> MOInfo::get_avir(std::string str,int i)
224
int i_ref = get_ref_number(str,i);
225
return(references[i_ref].get_avir());
228
vector<int> MOInfo::get_bvir(std::string str,int i)
230
int i_ref = get_ref_number(str,i);
231
return(references[i_ref].get_bvir());
234
vector<int> MOInfo::get_aocc(int i)
236
return(references[i].get_aocc());
239
vector<int> MOInfo::get_bocc(int i)
241
return(references[i].get_bocc());
244
vector<int> MOInfo::get_auoc(int i)
246
return(references[i].get_avir());
249
vector<int> MOInfo::get_buoc(int i)
251
return(references[i].get_bvir());
256
vector<pair<int,int> > MOInfo::get_alpha_internal_excitation(int i,int j)
258
return(alpha_internal_excitations[i][j]);
261
vector<pair<int,int> > MOInfo::get_beta_internal_excitation(int i,int j)
263
return(beta_internal_excitations[i][j]);
266
double MOInfo::get_sign_internal_excitation(int i,int j)
268
return(sign_internal_excitations[i][j]);
272
\fn MOInfo::get_ref_number(string str, int n)
274
int MOInfo::get_ref_number(string str, int n)
279
return(unique_refs[n]);
281
return(closed_shell_refs[n]);
283
return(unique_open_shell_refs[n]);
284
print_error("MOInfo::get_ref_number(string str, int n) undefined space", __FILE__,__LINE__);
289
\fn MOInfo::get_ref_size(string str)
291
int MOInfo::get_ref_size(string str)
294
return(all_refs.size());
296
return(unique_refs.size());
298
return(closed_shell_refs.size());
300
return(unique_open_shell_refs.size());
301
print_error("MOInfo::get_ref_size(string str) undefined space", __FILE__,__LINE__);
305
vector<string> MOInfo::get_matrix_names(std::string str)
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]) +"}"));
321
names.push_back(str);
b'\\ No newline at end of file'