MPQC 2.3.1

- Main Page
- Related Pages
- Classes
- Files

- File List

transform_tbint.h
1 //
2 // transform_tbint.h
3 //
4 // Copyright (C) 2004 Edward Valeev
5 //
6 // Author: Edward Valeev <edward.valeev@chemistry.gatech.edu>
7 // Maintainer: EV
8 //
9 // This file is part of the SC Toolkit.
10 //
11 // The SC Toolkit is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU Library General Public License as published by
13 // the Free Software Foundation; either version 2, or (at your option)
14 // any later version.
15 //
16 // The SC Toolkit 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 Library General Public License for more details.
20 //
21 // You should have received a copy of the GNU Library General Public License
22 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 //
25 // The U.S. Government is granted a limited license as per AL 91-7.
26 //
27
28 #ifdef __GNUG__
29 #pragma interface
30 #endif
31
32 #ifndef _chemistry_qc_mbptr12_transformtbint_h
33 #define _chemistry_qc_mbptr12_transformtbint_h
34
35 #include <string>
36 #include <util/ref/ref.h>
37 #include <util/class/scexception.h>
38 #include <chemistry/qc/basis/distshpair.h>
39 #include <chemistry/qc/mbptr12/r12ia.h>
40 #include <chemistry/qc/mbptr12/moindexspace.h>
41 #include <chemistry/qc/mbptr12/transform_factory.h>
42
43 using namespace std;
44
45 namespace sc {
46
47 class MOIntsTransformFactory;
48
52 class TwoBodyMOIntsTransform : virtual public SavableState {
53
54 // Construct the integrals accumulator object
55 // This function depends on the particulars of the transformation
56 virtual void init_acc() = 0;
57 // Compute required dynamic memory for a given batch size
58 // implementation depends on the particulars of the concrete type
59 virtual distsize_t compute_transform_dynamic_memory_(int ni) const = 0;
60
61 protected:
64 static const double zero_integral = 1.0e-12;
66 typedef struct {
67 enum {Space1, Space2, Space3, Space4};
68 } MOSpaces;
69
70 std::string name_;
71 Ref<MOIntsTransformFactory> factory_;
72
73 Ref<MolecularEnergy> top_mole_; // Top-level molecular energy to enable checkpointing
74 Ref<MessageGrp> msg_;
75 Ref<MemoryGrp> mem_;
76 Ref<ThreadGrp> thr_;
77 // Integrals accumulator
78 Ref<R12IntsAcc> ints_acc_;
79
80 Ref<MOIndexSpace> space1_;
81 Ref<MOIndexSpace> space2_;
82 Ref<MOIndexSpace> space3_;
83 Ref<MOIndexSpace> space4_;
84
85 int num_te_types_;
86 size_t memory_;
87 bool dynamic_;
88 double print_percent_;
89 DistShellPair::SharedData spdata_;
90 int debug_;
91 MOIntsTransformFactory::StoreMethod ints_method_;
92 std::string file_prefix_;
93
94 // These variables are never saved but computed every time in case environment
95 // has changed or it's a restart
96 size_t mem_static_;
97 int batchsize_;
98 int npass_;
99
101 unsigned int restart_orbital() const;
102
103 // Compute used static memory and batch size
104 void init_vars();
105 // Re-construct the integrals accumulator object
106 void reinit_acc();
107 // Allocate distributed memory
108 void alloc_mem(const size_t localmem);
109 // Deallocate distributed memory
110 void dealloc_mem();
111
112 // Compute batchsize given the amount of used static memory and
113 // the number of i-orbitals
114 int compute_transform_batchsize_(size_t mem_static, int rank_i);
115
116 // Compute the number of ij-pairs per this task
117 static int compute_nij(const int rank_i, const int rank_j, const int nproc, const int me);
118
122 void memory_report(std::ostream& os = ExEnv::out0()) const;
126 void mospace_report(std::ostream& os = ExEnv::out0()) const;
127
130 void print_header(std::ostream& os = ExEnv::out0()) const;
133 void print_footer(std::ostream& os = ExEnv::out0()) const;
134
135 public:
136
137 TwoBodyMOIntsTransform(StateIn&);
138 TwoBodyMOIntsTransform(const std::string& name, const Ref<MOIntsTransformFactory>& factory,
139 const Ref<MOIndexSpace>& space1, const Ref<MOIndexSpace>& space2,
140 const Ref<MOIndexSpace>& space3, const Ref<MOIndexSpace>& space4);
141 ~TwoBodyMOIntsTransform();
142
143 void save_data_state(StateOut&);
144
146 std::string name() const {return name_;}
148 virtual std::string type() const =0;
150 Ref<MemoryGrp> mem() const;
152 Ref<MessageGrp> msg() const;
154 Ref<R12IntsAcc> ints_acc() const;
156 Ref<MOIndexSpace> space1() const;
158 Ref<MOIndexSpace> space2() const;
160 Ref<MOIndexSpace> space3() const;
162 Ref<MOIndexSpace> space4() const;
163
165 double print_percent() const;
167 int batchsize() const;
169 int debug() const;
171 bool dynamic() const;
173 int num_te_types() const;
177 virtual const size_t memgrp_blksize() const =0;
178
180 void set_top_mole(const Ref<MolecularEnergy>& top_mole) { top_mole_ = top_mole; }
181
184 void set_num_te_types(const int num_te_types);
185 void set_memory(const size_t memory);
186 void set_debug(int debug) { debug_ = debug; }
187 void set_dynamic(bool dynamic) { dynamic_ = dynamic; }
188 void set_print_percent(double print_percent) { print_percent_ = print_percent; }
189
191 virtual void compute() = 0;
193 virtual void check_int_symm(double threshold = TwoBodyMOIntsTransform::zero_integral) const throw (ProgrammingError) =0;
195 virtual void obsolete();
196
199 DistShellPair::SharedData *shell_pair_data() { return &spdata_; }
200
201 };
202
203 }
204
205 #endif
206
207 // Local Variables:
208 // mode: c++
209 // c-file-style: "CLJ"
210 // End:
211
212