// // compute_ixjy.cc // // Copyright (C) 2004 Edward Valeev // // Author: Edward Valeev // Maintainer: EV // // This file is part of the SC Toolkit. // // The SC Toolkit is free software; you can redistribute it and/or modify // it under the terms of the GNU Library General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // The SC Toolkit is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with the SC Toolkit; see the file COPYING.LIB. If not, write to // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. // // The U.S. Government is granted a limited license as per AL 91-7. // #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using namespace sc; #define SINGLE_THREAD_E13 0 #define PRINT2Q 0 #define PRINT3Q 0 #define PRINT4Q 0 #define PRINT_NUM_TE_TYPES 1 #define CHECK_INTS_SYMM 1 /*------------------------------------- Based on MBPT2::compute_mp2_energy() -------------------------------------*/ void TwoBodyMOIntsTransform_ixjy::compute() { init_acc(); if (ints_acc_->is_committed()) return; Ref integral = factory_->integral(); Ref bs1 = space1_->basis(); Ref bs2 = space2_->basis(); Ref bs3 = space3_->basis(); Ref bs4 = space4_->basis(); int rank1 = space1_->rank(); int rank2 = space2_->rank(); int rank3 = space3_->rank(); int rank4 = space4_->rank(); int nbasis1 = bs1->nbasis(); int nbasis2 = bs2->nbasis(); int nbasis3 = bs3->nbasis(); int nbasis4 = bs4->nbasis(); int nshell1 = bs1->nshell(); int nshell2 = bs2->nshell(); int nshell3 = bs3->nshell(); int nshell4 = bs4->nshell(); int nfuncmax1 = bs1->max_nfunction_in_shell(); int nfuncmax2 = bs2->max_nfunction_in_shell(); int nfuncmax3 = bs3->max_nfunction_in_shell(); int nfuncmax4 = bs4->max_nfunction_in_shell(); enum te_types {eri=0, r12=1, r12t1=2}; const size_t memgrp_blocksize = memgrp_blksize(); // log2 of the erep tolerance // (erep < 2^tol => discard) const int tol = (int) (-10.0/log10(2.0)); // discard ints smaller than 10^-20 int aoint_computed = 0; std::string tim_label("tbint_tform_ikjy "); tim_label += name_; tim_enter(tim_label.c_str()); print_header(); // Compute the storage remaining for the integral routines size_t dyn_mem = distsize_to_size(compute_transform_dynamic_memory_(batchsize_)); int me = msg_->me(); int nproc = msg_->n(); const int restart_orb = restart_orbital(); int nijmax = compute_nij(batchsize_,rank3,nproc,me); vector mosym1 = space1_->mosym(); vector mosym2 = space2_->mosym(); vector mosym3 = space3_->mosym(); vector mosym4 = space4_->mosym(); double** vector2 = new double*[nbasis2]; double** vector4 = new double*[nbasis4]; vector2[0] = new double[rank2*nbasis2]; vector4[0] = new double[rank4*nbasis4]; for(int i=1; icoefs().convert(vector2); space4_->coefs().convert(vector4); ///////////////////////////////////// // Begin transformation loops ///////////////////////////////////// // debug print if (debug_ >= 2) { ExEnv::outn() << indent << scprintf("node %i, begin loop over i-batches",me) << endl; } // end of debug print // Initialize the integrals integral->set_storage(memory_ - dyn_mem); integral->set_basis(space1_->basis(),space2_->basis(),space3_->basis(),space4_->basis()); Ref* tbints = new Ref[thr_->nthread()]; for (int i=0; inthread(); i++) { tbints[i] = integral->grt(); } if (debug_ >= 1) ExEnv::out0() << indent << scprintf("Memory used for integral storage: %i Bytes", integral->storage_used()) << endl; Ref lock = thr_->new_lock(); TwoBodyMOIntsTransform_13Inds** e13thread = new TwoBodyMOIntsTransform_13Inds*[thr_->nthread()]; for (int i=0; inthread(); i++) { e13thread[i] = new TwoBodyMOIntsTransform_13Inds(this,i,thr_->nthread(),lock,tbints[i],-100.0,debug_); } /*----------------------------------- Start the integrals transformation -----------------------------------*/ tim_enter("mp2-r12/a passes"); if (me == 0 && top_mole_.nonnull() && top_mole_->if_to_checkpoint() && ints_acc_->can_restart()) { StateOutBin stateout(top_mole_->checkpoint_file()); SavableState::save_state(top_mole_,stateout); ExEnv::out0() << indent << "Checkpointed the wave function" << endl; } for (int pass=0; passinit(); for (int i=0; inthread(); i++) { e13thread[i]->set_i_offset(i_offset); e13thread[i]->set_ni(ni); thr_->add_thread(i,e13thread[i]); # if SINGLE_THREAD_E13 e13thread[i]->run(); # endif } # if !SINGLE_THREAD_E13 thr_->start_threads(); thr_->wait_threads(); # endif tim_exit("ints+1qt+2qt"); ExEnv::out0() << indent << "End of loop over shells" << endl; mem_->sync(); // Make sure ijsq is complete on each node before continuing integral_ijsq = (double*) mem_->localdata(); #if PRINT2Q { for(int te_type=0; te_typelocaldata(); #if PRINT3Q { for(int te_type=0; te_typelocaldata(); // Zero out nonsymmetric integrals -- Pitzer theorem in action { for (int i = 0; isync(); #if PRINT4Q { for(int te_type=0; te_typestore_memorygrp(mem_,ni,memgrp_blocksize); tim_exit("MO ints store"); mem_->sync(); if (me == 0 && top_mole_.nonnull() && top_mole_->if_to_checkpoint() && ints_acc_->can_restart()) { StateOutBin stateout(top_mole_->checkpoint_file()); SavableState::save_state(top_mole_,stateout); ExEnv::out0() << indent << "Checkpointed the wave function" << endl; } } // end of loop over passes tim_exit("mp2-r12/a passes"); if (debug_) ExEnv::out0() << indent << "End of mp2-r12/a transformation" << endl; // Done storing integrals - commit the content // WARNING: it is not safe to use mem until deactivate has been called on the accumulator // After that deactivate the size of mem will be 0 [mem->set_localsize(0)] ints_acc_->commit(); for (int i=0; inthread(); i++) { delete e13thread[i]; } delete[] e13thread; delete[] tbints; tbints = 0; delete[] vector2[0]; delete[] vector2; delete[] vector4[0]; delete[] vector4; tim_exit(tim_label.c_str()); if (me == 0 && top_mole_.nonnull() && top_mole_->if_to_checkpoint()) { StateOutBin stateout(top_mole_->checkpoint_file()); SavableState::save_state(top_mole_,stateout); ExEnv::out0() << indent << "Checkpointed the wave function" << endl; } print_footer(); #if CHECK_INTS_SYMM ExEnv::out0() << indent << "Detecting non-totally-symmetric integrals ... "; check_int_symm(); ExEnv::out0() << "none" << endl; #endif } //////////////////////////////////////////////////////////////////////////// // Local Variables: // mode: c++ // c-file-style: "CLJ-CONDENSED" // End: