Psi4
sort.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_bin_psimrcc_ccsort_h
29 #define _psi_src_bin_psimrcc_ccsort_h
30 
36 #include <iostream>
37 #include <map>
38 #include <vector>
39 
40 
41 namespace psi{
42 
43 class IntegralTransform;
44 
45 namespace psimrcc{
46 
47 class CCMatrix;
48 
49 #include "matrix_types.h"
50 
51 #ifndef INDEX
52 #define INDEX(i,j) ((i>j) ? (ioff[(i)]+(j)) : (ioff[(j)]+(i)))
53 #endif
54 #define four(i,j,k,l) INDEX(INDEX(i,j),INDEX(k,l))
55 
56 enum SortAlgorithm {out_of_core_sort,mrpt2_sort};
57 
62 class CCSort{
63 public:
64  CCSort(SharedWavefunction ref_wfn, SortAlgorithm algorithm);
65  ~CCSort();
66 private:
67  void init();
68  void cleanup();
69 
70 // // In-core algorithm
71 // void build_integrals_in_core();
72 // void frozen_core_energy_in_core();
73 // void sort_integrals_in_core();
74 // void form_two_electron_integrals_in_core(MatrixMap::iterator& iter);
75 // void form_fock_in_core(MatrixMap::iterator& iter);
76 // double add_fock_two_in_core(int p, int q, int k, bool exchange);
77 
78  // Out-of-core algorithm
79  void build_integrals_out_of_core();
80  void frozen_core_energy_out_of_core();
81  void sort_integrals_out_of_core(int first_irrep, int last_irrep, MatrixBlks& to_be_processed);
82  void form_fock_one_out_of_core(MatrixBlks& to_be_processed);
83  void form_fock_out_of_core(CCMatrix* Matrix, int h);
84  void form_two_electron_integrals_out_of_core(CCMatrix* Matrix, int h);
85  double add_fock_two_out_of_core(int p, int q, int k, bool exchange);
86  void setup_out_of_core_list(MatMapIt& mat_it,int& mat_irrep,MatMapIt& mat_end,MatrixBlks& to_be_processed);
87  void dump_integrals_to_disk(MatrixBlks& to_be_processed);
88 
89  // MRPT2 algorithm
90  void build_integrals_mrpt2(IntegralTransform *ints);
91  void frozen_core_energy_mrpt2();
92  void allocate_and_sort_integrals_mrpt2();
93  void allocate_amplitudes_mrpt2();
94  void form_two_electron_integrals_mrpt2(MatrixMap::iterator& iter);
95  void form_fock_mrpt2(MatrixMap::iterator& iter);
96  double add_fock_two_mrpt2(int p, int q, int k, bool exchange);
97 
98  // Data
99  double fraction_of_memory_for_sorting;
100  int nfzc;
101  double efzc;
102  int* frozen_core;
103 };
104 
105 extern CCSort *sorter;
106 
107 }} /* End Namespaces */
108 
109 #endif // _psi_src_bin_psimrcc_ccsort_h
PsiReturnType psimrcc(SharedWavefunction, Options &)
Definition: psimrcc/main.cc:86
std::vector< std::pair< psi::psimrcc::CCMatrix *, int > > MatrixBlks
Definition: matrix_types.h:34
CCSort * sorter
Definition: psimrcc/main.cc:78
std::map< std::string, psi::psimrcc::CCMatrix * >::iterator MatMapIt
Definition: matrix_types.h:33
void cleanup(void)
Definition: ccdensity/get_moinfo.cc:296
std::shared_ptr< Wavefunction > SharedWavefunction
Definition: typedefs.h:50