source: ThirdParty/mpqc_open/src/lib/chemistry/qc/mbptr12/transform_ixjy.cc@ 47b463

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests AutomationFragmentation_failures Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_ChronosMutex Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction Subpackage_levmar Subpackage_vmg ThirdParty_MPQC_rebuilt_buildsystem TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since 47b463 was 860145, checked in by Frederik Heber <heber@…>, 8 years ago

Merge commit '0b990dfaa8c6007a996d030163a25f7f5fc8a7e7' as 'ThirdParty/mpqc_open'

  • Property mode set to 100644
File size: 8.6 KB
Line 
1//
2// transform_ixjy.cc
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 implementation
30#endif
31
32#include <stdexcept>
33
34#include <util/misc/formio.h>
35#include <util/state/state_bin.h>
36#include <util/ref/ref.h>
37#include <math/scmat/local.h>
38#include <chemistry/qc/mbptr12/transform_ixjy.h>
39#include <chemistry/qc/mbptr12/r12ia_memgrp.h>
40#include <chemistry/qc/mbptr12/r12ia_node0file.h>
41#ifdef HAVE_MPIIO
42 #include <chemistry/qc/mbptr12/r12ia_mpiiofile.h>
43#endif
44#include <chemistry/qc/mbptr12/transform_123inds.h>
45
46using namespace std;
47using namespace sc;
48
49inline int max(int a,int b) { return (a > b) ? a : b;}
50
51/*-----------
52 TwoBodyMOIntsTransform_ixjy
53 -----------*/
54static ClassDesc TwoBodyMOIntsTransform_ixjy_cd(
55 typeid(TwoBodyMOIntsTransform_ixjy),"TwoBodyMOIntsTransform_ixjy",1,"public TwoBodyMOIntsTransform",
56 0, 0, create<TwoBodyMOIntsTransform_ixjy>);
57
58TwoBodyMOIntsTransform_ixjy::TwoBodyMOIntsTransform_ixjy(const std::string& name, const Ref<MOIntsTransformFactory>& factory,
59 const Ref<MOIndexSpace>& space1, const Ref<MOIndexSpace>& space2,
60 const Ref<MOIndexSpace>& space3, const Ref<MOIndexSpace>& space4) :
61 TwoBodyMOIntsTransform(name,factory,space1,space2,space3,space4)
62{
63 init_vars();
64}
65
66TwoBodyMOIntsTransform_ixjy::TwoBodyMOIntsTransform_ixjy(StateIn& si) : TwoBodyMOIntsTransform(si)
67{
68 init_vars();
69}
70
71TwoBodyMOIntsTransform_ixjy::~TwoBodyMOIntsTransform_ixjy()
72{
73}
74
75void
76TwoBodyMOIntsTransform_ixjy::save_data_state(StateOut& so)
77{
78 TwoBodyMOIntsTransform::save_data_state(so);
79}
80
81//////////////////////////////////////////////////////
82// Compute required (dynamic) memory
83// for a given batch size of the transformation
84//
85// Only arrays allocated before exiting the loop over
86// i-batches are included here - only these arrays
87// affect the batch size.
88//////////////////////////////////////////////////////
89distsize_t
90TwoBodyMOIntsTransform_ixjy::compute_transform_dynamic_memory_(int ni) const
91{
92 int nproc = msg_->n();
93 int nthread = thr_->nthread();
94
95 ///////////////////////////////////////
96 // the largest memory requirement will
97 // occur just before
98 // the end of the i-batch loop (mem)
99 ///////////////////////////////////////
100
101 int rank3 = space3_->rank();
102
103 // compute nij as nij on node 0, since nij on node 0 is >= nij on other nodes
104 int nij = compute_nij(ni, rank3, nproc, 0);
105
106 int nbasis2 = space2_->basis()->nbasis();
107 int nbasis4 = space4_->basis()->nbasis();
108 int nfuncmax3 = space3_->basis()->max_nfunction_in_shell();
109 int nfuncmax4 = space4_->basis()->max_nfunction_in_shell();
110
111 // If basis3 == basis4 then permutational symmetry will be used in second step
112 bool basis3_eq_basis4 = (space3_->basis() == space4_->basis());
113
114 distsize_t memsize = sizeof(double)*(num_te_types_*((distsize_t)nthread * ni * nbasis2 * nfuncmax3 * nfuncmax4 // iqrs
115 + (distsize_t)nij * (basis3_eq_basis4 ? 2 : 1) * nbasis2 * nfuncmax4 // iqjs (and iqjr, if necessary) buffers
116 + (distsize_t)nij * nbasis2 * nbasis4 // iqjs_contrib - buffer of half and higher
117 // transformed integrals
118 )
119 );
120 return memsize;
121}
122
123const size_t
124TwoBodyMOIntsTransform_ixjy::memgrp_blksize() const
125{
126 const int nbasis2 = space2_->basis()->nbasis();
127 const int rank2 = space2_->rank();
128 const int dim2 = (nbasis2 > rank2) ? nbasis2 : rank2;
129 const int nbasis4 = space4_->basis()->nbasis();
130 const int rank4 = space4_->rank();
131 const int dim4 = (nbasis4 > rank4) ? nbasis4 : rank4;
132 return dim2*dim4*sizeof(double);
133}
134
135void
136TwoBodyMOIntsTransform_ixjy::init_acc()
137{
138 if (ints_acc_.nonnull())
139 return;
140
141 int nij = compute_nij(batchsize_, space3_->rank(), msg_->n(), msg_->me());
142
143 alloc_mem((size_t)num_te_types_*nij*memgrp_blksize());
144
145 switch (ints_method_) {
146
147 case MOIntsTransformFactory::mem_only:
148 if (npass_ > 1)
149 throw std::runtime_error("TwoBodyMOIntsTransform_ixjy::init_acc() -- cannot use MemoryGrp-based accumulator in multi-pass transformations");
150 ints_acc_ = new R12IntsAcc_MemoryGrp(mem_, num_te_types_, space1_->rank(), space3_->rank(), space2_->rank(), space4_->rank()); // Hack to avoid using nfzc and nocc
151 break;
152
153 case MOIntsTransformFactory::mem_posix:
154 if (npass_ == 1) {
155 ints_acc_ = new R12IntsAcc_MemoryGrp(mem_, num_te_types_, space1_->rank(), space3_->rank(), space2_->rank(), space4_->rank());
156 break;
157 }
158 // else use the next case
159
160 case MOIntsTransformFactory::posix:
161 ints_acc_ = new R12IntsAcc_Node0File(mem_, (file_prefix_+"."+name_).c_str(), num_te_types_,
162 space1_->rank(), space3_->rank(), space2_->rank(), space4_->rank());
163 break;
164
165#if HAVE_MPIIO
166 case MOIntsTransformFactory::mem_mpi:
167 if (npass_ == 1) {
168 ints_acc_ = new R12IntsAcc_MemoryGrp(mem_, num_te_types_, space1_->rank(), space3_->rank(), space2_->rank(), space4_->rank());
169 break;
170 }
171 // else use the next case
172
173 case MOIntsTransformFactory::mpi:
174 ints_acc_ = new R12IntsAcc_MPIIOFile_Ind(mem_, (file_prefix_+"."+name_).c_str(), num_te_types_,
175 space1_->rank(), space3_->rank(), space2_->rank(), space4_->rank());
176 break;
177#endif
178
179 default:
180 throw std::runtime_error("TwoBodyMOIntsTransform_ixjy::init_acc() -- invalid integrals store method");
181 }
182}
183
184void
185TwoBodyMOIntsTransform_ixjy::check_int_symm(double threshold) const throw (ProgrammingError)
186{
187 Ref<R12IntsAcc> iacc = ints_acc();
188 if (!iacc->is_committed())
189 throw ProgrammingError("TwoBodyMOIntsTransform_ixjy::check_int_symm() is called but integrals not computed yet",
190 __FILE__, __LINE__);
191
192 int num_te_types = iacc->num_te_types();
193 int ni = iacc->ni();
194 int nj = iacc->nj();
195 int nx = iacc->nx();
196 int ny = iacc->ny();
197 vector<int> isyms = space1_->mosym();
198 vector<int> jsyms = space3_->mosym();
199 vector<int> xsyms = space2_->mosym();
200 vector<int> ysyms = space4_->mosym();
201
202 int me = msg_->me();
203 vector<int> twi_map;
204 int ntasks_with_ints = iacc->tasks_with_access(twi_map);
205 if (!iacc->has_access(me))
206 return;
207
208 int ij=0;
209 for(int i=0; i<ni; i++) {
210 int isym = isyms[i];
211 for(int j=0; j<nj; j++, ij++) {
212 int jsym = jsyms[j];
213 if (ij%ntasks_with_ints != twi_map[me])
214 continue;
215
216 for(int t=0; t<num_te_types; t++) {
217 const double* ints = iacc->retrieve_pair_block(i,j,static_cast<R12IntsAcc::tbint_type>(t));
218 int xy=0;
219 for(int x=0; x<nx; x++) {
220 int xsym = xsyms[x];
221 for(int y=0; y<ny; y++, xy++) {
222 int ysym = ysyms[y];
223 if ( (isym^jsym^xsym^ysym) != 0 && fabs(ints[xy]) > threshold) {
224 ExEnv::outn() << scprintf("Integral type=%d i=%d x=%d j=%d y=%d should be zero\n",t,i,x,j,y);
225 throw ProgrammingError("TwoBodyMOIntsTransform_ixjy::check_int_symm() -- nonzero nonsymmetric integrals are detected",
226 __FILE__, __LINE__);
227 }
228 }
229 }
230 iacc->release_pair_block(i,j,static_cast<R12IntsAcc::tbint_type>(t));
231 }
232 }
233 }
234}
235
236/*void
237TwoBodyMOIntsTransform_ixjy::compute()
238{
239 init_acc();
240
241 Ref<ThreadLock> lock = thr_->new_lock();
242 Ref<Integral> int_factory = factory_->integral();
243 int_factory->set_basis(space1_->basis(),space2_->basis(),space3_->basis(),space4_->basis());
244 Ref<TwoBodyInt> tbint = int_factory->grt();
245 Ref<TwoBodyMOIntsTransform> this_tform = this;
246 TwoBodyMOIntsTransform_123Inds* tform_123 = new TwoBodyMOIntsTransform_123Inds(this_tform,0,1,lock,tbint,-100.0,0);
247 tform_123->run();
248}*/
249
250/////////////////////////////////////////////////////////////////////////////
251
252// Local Variables:
253// mode: c++
254// c-file-style: "CLJ-CONDENSED"
255// End:
Note: See TracBrowser for help on using the repository browser.