source: ThirdParty/mpqc_open/src/lib/chemistry/qc/cints/eri.cc@ 860145

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests Automaking_mpqc_open 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_mpqc_open Subpackage_vmg ThirdParty_MPQC_rebuilt_buildsystem TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since 860145 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: 6.8 KB
Line 
1//
2// eri.cc
3//
4// Copyright (C) 2001 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 <util/misc/formio.h>
33#include <chemistry/qc/basis/integral.h>
34#include <chemistry/qc/cints/eri.h>
35#ifdef DMALLOC
36#include <dmalloc.h>
37#endif
38
39#define STORE_PAIR_DATA 1
40
41using namespace std;
42using namespace sc;
43
44// This global object initializes the static interface of libint
45LibintStaticInterface LibintStaticInitializer;
46
47inline int max(int a,int b) { return (a > b) ? a : b;}
48inline void fail()
49{
50 ExEnv::errn() << scprintf("failing module:\n%s",__FILE__) << endl;
51 abort();
52}
53
54EriCints::EriCints(Integral *integral,
55 const Ref<GaussianBasisSet>& b1,
56 const Ref<GaussianBasisSet>& b2,
57 const Ref<GaussianBasisSet>& b3,
58 const Ref<GaussianBasisSet>& b4,
59 size_t storage) :
60 Int2eCints(integral,b1,b2,b3,b4,storage)
61{
62 // The static part of Libint's interface is automatically initialized in libint.cc
63 int l1 = bs1_->max_angular_momentum();
64 int l2 = bs2_->max_angular_momentum();
65 int l3 = bs3_->max_angular_momentum();
66 int l4 = bs4_->max_angular_momentum();
67 int lmax = max(max(l1,l2),max(l3,l4));
68 if (lmax + 1 > LIBINT_MAX_AM) {
69 ExEnv::errn() << scprintf("libint: the maximum angular momentum of the basis\n");
70 ExEnv::errn() << scprintf("is too high - need to recompile libint\n");
71 fail();
72 }
73
74 /*--- Initialize storage ---*/
75 int max_num_prim_comb = bs1_->max_nprimitive_in_shell()*
76 bs2_->max_nprimitive_in_shell()*
77 bs3_->max_nprimitive_in_shell()*
78 bs4_->max_nprimitive_in_shell();
79 int max_cart_target_size = bs1_->max_ncartesian_in_shell()*bs2_->max_ncartesian_in_shell()*
80 bs3_->max_ncartesian_in_shell()*bs4_->max_ncartesian_in_shell();
81 int max_target_size = bs1_->max_nfunction_in_shell()*bs2_->max_nfunction_in_shell()*
82 bs3_->max_nfunction_in_shell()*bs4_->max_nfunction_in_shell();
83 size_t storage_needed = libint_storage_required(lmax,max_num_prim_comb)*sizeof(REALTYPE) +
84 (max_target_size+max_cart_target_size)*sizeof(double);
85 init_libint(&Libint_,lmax,max_num_prim_comb);
86 target_ints_buffer_ = new double[max_target_size];
87 cart_ints_ = new double[max_cart_target_size];
88 if (bs1_->has_pure() || bs2_->has_pure() || bs3_->has_pure() || bs4_->has_pure() ||
89 bs1_->max_ncontraction() != 1 || bs2_->max_ncontraction() != 1 ||
90 bs3_->max_ncontraction() != 1 || bs4_->max_ncontraction() != 1) {
91 sphharm_ints_ = new double[max_target_size];
92 storage_needed += max_target_size*sizeof(double);
93 }
94 else {
95 sphharm_ints_ = 0;
96 }
97 if (l1 || l2 || l3 || l4) {
98 perm_ints_ = new double[max_target_size];
99 storage_needed += max_target_size*sizeof(double);
100 }
101 else
102 perm_ints_ = 0;
103
104 // See if can store primitive-pair data
105 size_t primitive_pair_storage_estimate = (bs1_->nprimitive()*bs2_->nprimitive() +
106 bs3_->nprimitive()*bs4_->nprimitive())*sizeof(prim_pair_t);
107 // ExEnv::errn() << scprintf("need %d bytes to store primitive pair data\n",primitive_pair_storage_estimate);
108#if STORE_PAIR_DATA
109 shell_pairs12_ = new ShellPairsCints(bs1_,bs2_);
110 if ( (bs1_ == bs3_ && bs2_ == bs4_) /*||
111 // if this is (ab|ba) case -- should i try to save storage?
112 (bs1_ == bs4_ && bs2_ == bs3_)*/ )
113 shell_pairs34_ = new ShellPairsCints(shell_pairs12_);
114 else
115 shell_pairs34_ = new ShellPairsCints(bs3_,bs4_);
116 storage_needed += primitive_pair_storage_estimate;
117#endif
118
119 storage_used_ = storage_needed;
120 // Check if storage_ > storage_needed
121 check_storage_();
122
123 int mmax = bs1_->max_angular_momentum() +
124 bs2_->max_angular_momentum() +
125 bs3_->max_angular_momentum() +
126 bs4_->max_angular_momentum();
127 Fm_Eval_ = new FJT(mmax);
128}
129
130
131EriCints::~EriCints()
132{
133 free_libint(&Libint_);
134 delete[] target_ints_buffer_;
135 delete[] cart_ints_;
136 if (sphharm_ints_)
137 delete[] sphharm_ints_;
138 if (perm_ints_)
139 delete[] perm_ints_;
140#ifdef DMALLOC
141 dmalloc_shutdown();
142#endif
143}
144
145size_t
146EriCints::storage_required(const Ref<GaussianBasisSet>& b1,
147 const Ref<GaussianBasisSet>& b2,
148 const Ref<GaussianBasisSet>& b3,
149 const Ref<GaussianBasisSet>& b4)
150{
151 Ref<GaussianBasisSet> bs1 = b1;
152 Ref<GaussianBasisSet> bs2 = b2;
153 Ref<GaussianBasisSet> bs3 = b3;
154 Ref<GaussianBasisSet> bs4 = b4;
155
156 if (bs2.null())
157 bs2 = bs1;
158 if (bs3.null())
159 bs3 = bs1;
160 if (bs4.null())
161 bs4 = bs1;
162
163 int l1 = bs1->max_angular_momentum();
164 int l2 = bs2->max_angular_momentum();
165 int l3 = bs3->max_angular_momentum();
166 int l4 = bs4->max_angular_momentum();
167 int lmax = max(max(l1,l2),max(l3,l4));
168
169 size_t storage_required = storage_required_(bs1,bs2,bs3,bs4);
170
171 int max_num_prim_comb = bs1->max_nprimitive_in_shell()*
172 bs2->max_nprimitive_in_shell()*
173 bs3->max_nprimitive_in_shell()*
174 bs4->max_nprimitive_in_shell();
175 int max_cart_target_size = bs1->max_ncartesian_in_shell()*bs2->max_ncartesian_in_shell()*
176 bs3->max_ncartesian_in_shell()*bs4->max_ncartesian_in_shell();
177 int max_target_size = bs1->max_nfunction_in_shell()*bs2->max_nfunction_in_shell()*
178 bs3->max_nfunction_in_shell()*bs4->max_nfunction_in_shell();
179
180 storage_required += libint_storage_required(lmax,max_num_prim_comb)*sizeof(REALTYPE) +
181 (max_target_size+max_cart_target_size)*sizeof(double);
182
183 if (bs1->has_pure() || bs2->has_pure() || bs3->has_pure() || bs4->has_pure() ||
184 bs1->max_ncontraction() != 1 || bs2->max_ncontraction() != 1 ||
185 bs3->max_ncontraction() != 1 || bs4->max_ncontraction() != 1) {
186 storage_required += max_target_size*sizeof(double);
187 }
188
189 if (l1 || l2 || l3 || l4) {
190 storage_required += max_target_size*sizeof(double);
191 }
192
193 // See if can store primitive-pair data
194 size_t primitive_pair_storage_estimate = (bs1->nprimitive()*bs2->nprimitive() +
195 bs3->nprimitive()*bs4->nprimitive())*sizeof(prim_pair_t);
196#if STORE_PAIR_DATA
197 storage_required += primitive_pair_storage_estimate;
198#endif
199
200 return storage_required;
201}
202
203
204/////////////////////////////////////////////////////////////////////////////
205
206// Local Variables:
207// mode: c++
208// c-file-style: "CLJ-CONDENSED"
209// End:
Note: See TracBrowser for help on using the repository browser.