source: ThirdParty/mpqc_open/src/lib/chemistry/qc/cints/cints.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: 9.7 KB
Line 
1//
2// cints.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#include <stdexcept>
29
30#include <util/state/stateio.h>
31#include <util/misc/formio.h>
32#include <chemistry/qc/cints/cints.h>
33#include <chemistry/qc/cints/cartit.h>
34#include <chemistry/qc/cints/tform.h>
35#include <chemistry/qc/cints/obintcints.h>
36#include <chemistry/qc/cints/tbintcints.h>
37#include <chemistry/qc/cints/eri.h>
38#include <chemistry/qc/cints/grt.h>
39
40using namespace std;
41using namespace sc;
42
43inline void fail()
44{
45 ExEnv::errn() << scprintf("failing module:\n%s",__FILE__) << endl;
46 abort();
47}
48
49static ClassDesc IntegralCints_cd(
50 typeid(IntegralCints),"IntegralCints",1,"public Integral",
51 0, create<IntegralCints>, create<IntegralCints>);
52
53IntegralCints::IntegralCints(const Ref<GaussianBasisSet> &b1,
54 const Ref<GaussianBasisSet> &b2,
55 const Ref<GaussianBasisSet> &b3,
56 const Ref<GaussianBasisSet> &b4):
57 Integral(b1,b2,b3,b4)
58{
59 initialize_transforms();
60}
61
62IntegralCints::IntegralCints(StateIn& s) :
63 Integral(s)
64{
65 initialize_transforms();
66}
67
68IntegralCints::IntegralCints(const Ref<KeyVal>& k) :
69 Integral(k)
70{
71 initialize_transforms();
72}
73
74void
75IntegralCints::save_data_state(StateOut& s)
76{
77 Integral::save_data_state(s);
78}
79
80IntegralCints::~IntegralCints()
81{
82 free_transforms();
83}
84
85Integral*
86IntegralCints::clone()
87{
88 return new IntegralCints;
89}
90
91size_t
92IntegralCints::storage_required_eri(const Ref<GaussianBasisSet> &b1,
93 const Ref<GaussianBasisSet> &b2,
94 const Ref<GaussianBasisSet> &b3,
95 const Ref<GaussianBasisSet> &b4)
96{
97 return EriCints::storage_required(b1,b2,b3,b4);
98}
99
100size_t
101IntegralCints::storage_required_grt(const Ref<GaussianBasisSet> &b1,
102 const Ref<GaussianBasisSet> &b2,
103 const Ref<GaussianBasisSet> &b3,
104 const Ref<GaussianBasisSet> &b4)
105{
106 return GRTCints::storage_required(b1,b2,b3,b4);
107}
108
109CartesianIter *
110IntegralCints::new_cartesian_iter(int l)
111{
112 return new CartesianIterCints(l);
113}
114
115RedundantCartesianIter *
116IntegralCints::new_redundant_cartesian_iter(int l)
117{
118 return new RedundantCartesianIterCints(l);
119}
120
121RedundantCartesianSubIter *
122IntegralCints::new_redundant_cartesian_sub_iter(int l)
123{
124 return new RedundantCartesianSubIterCints(l);
125}
126
127SphericalTransformIter *
128IntegralCints::new_spherical_transform_iter(int l, int inv, int subl)
129{
130 if (l>maxl_ || l<0) {
131 ExEnv::errn() << "IntegralCints::new_spherical_transform_iter: bad l" << endl;
132 abort();
133 }
134 if (subl == -1) subl = l;
135 if (subl < 0 || subl > l || (l-subl)%2 != 0) {
136 ExEnv::errn() << "IntegralCints::new_spherical_transform_iter: bad subl" << endl;
137 abort();
138 }
139 if (inv) {
140 return new SphericalTransformIter(ist_[l][(l-subl)/2]);
141 }
142 return new SphericalTransformIter(st_[l][(l-subl)/2]);
143}
144
145const SphericalTransform *
146IntegralCints::spherical_transform(int l, int inv, int subl)
147{
148 if (l>maxl_ || l<0) {
149 ExEnv::errn() << "IntegralCints::spherical_transform_iter: bad l" << endl;
150 abort();
151 }
152 if (subl == -1) subl = l;
153 if (subl < 0 || subl > l || (l-subl)%2 != 0) {
154 ExEnv::errn() << "IntegralCints::spherical_transform_iter: bad subl" << endl;
155 abort();
156 }
157 if (inv) {
158 return ist_[l][(l-subl)/2];
159 }
160 return st_[l][(l-subl)/2];
161}
162
163Ref<OneBodyInt>
164IntegralCints::overlap()
165{
166 return new OneBodyIntCints(this, bs1_, bs2_, &Int1eCints::overlap);
167}
168
169Ref<OneBodyInt>
170IntegralCints::kinetic()
171{
172 return new OneBodyIntCints(this, bs1_, bs2_, &Int1eCints::kinetic);
173}
174
175Ref<OneBodyInt>
176IntegralCints::nuclear()
177{
178 return new OneBodyIntCints(this, bs1_, bs2_, &Int1eCints::nuclear);
179}
180
181Ref<OneBodyInt>
182IntegralCints::hcore()
183{
184 return new OneBodyIntCints(this, bs1_, bs2_, &Int1eCints::hcore);
185}
186
187Ref<OneBodyInt>
188IntegralCints::point_charge(const Ref<PointChargeData>& dat)
189{
190 ExEnv::errn() << scprintf("IntegralCints::point_charge() is not yet implemented.\n");
191 ExEnv::errn() << scprintf("Try using the IntegralV3 factory instead.\n");
192 fail();
193 return 0;
194 // return new PointChargeIntV3(this, bs1_, bs2_, dat);
195}
196
197Ref<OneBodyInt>
198IntegralCints::efield_dot_vector(const Ref<EfieldDotVectorData>&dat)
199{
200 ExEnv::errn() << scprintf("IntegralCints::efield_dot_vector() is not yet implemented.\n");
201 ExEnv::errn() << scprintf("Try using the IntegralV3 factory instead.\n");
202 fail();
203 return 0;
204 // return new EfieldDotVectorIntV3(this, bs1_, bs2_, dat);
205}
206
207Ref<OneBodyInt>
208IntegralCints::dipole(const Ref<DipoleData>& dat)
209{
210 Ref<OneBodyIntCints> dipoleint = new OneBodyIntCints(this, bs1_, bs2_, &Int1eCints::edipole);
211 dipoleint->set_multipole_origin(dat);
212 return dipoleint;
213}
214
215Ref<OneBodyInt>
216IntegralCints::quadrupole(const Ref<DipoleData>& dat)
217{
218 Ref<OneBodyIntCints> quadint = new OneBodyIntCints(this, bs1_, bs2_, &Int1eCints::equadrupole);
219 quadint->set_multipole_origin(dat);
220 return quadint;
221}
222
223Ref<OneBodyDerivInt>
224IntegralCints::overlap_deriv()
225{
226 ExEnv::errn() << scprintf("IntegralCints::overlap_deriv() is not yet implemented.\n");
227 ExEnv::errn() << scprintf("Try using the IntegralV3 factory instead.\n");
228 fail();
229 return 0;
230 // return new OneBodyDerivIntV3(this, bs1_, bs2_, &Int1eV3::overlap_1der);
231}
232
233Ref<OneBodyDerivInt>
234IntegralCints::kinetic_deriv()
235{
236 ExEnv::errn() << scprintf("IntegralCints::kinetic_deriv() is not yet implemented.\n");
237 ExEnv::errn() << scprintf("Try using the IntegralV3 factory instead.\n");
238 fail();
239 return 0;
240 // return new OneBodyDerivIntV3(this, bs1_, bs2_, &Int1eV3::kinetic_1der);
241}
242
243Ref<OneBodyDerivInt>
244IntegralCints::nuclear_deriv()
245{
246 ExEnv::errn() << scprintf("IntegralCints::nuclear_deriv() is not yet implemented.\n");
247 ExEnv::errn() << scprintf("Try using the IntegralV3 factory instead.\n");
248 fail();
249 return 0;
250 // return new OneBodyDerivIntV3(this, bs1_, bs2_, &Int1eV3::nuclear_1der);
251}
252
253Ref<OneBodyDerivInt>
254IntegralCints::hcore_deriv()
255{
256 ExEnv::errn() << scprintf("IntegralCints::hcore_deriv() is not yet implemented.\n");
257 ExEnv::errn() << scprintf("Try using the IntegralV3 factory instead.\n");
258 fail();
259 return 0;
260 // return new OneBodyDerivIntV3(this, bs1_, bs2_, &Int1eV3::hcore_1der);
261}
262
263Ref<TwoBodyInt>
264IntegralCints::electron_repulsion()
265{
266 return new TwoBodyIntCints(this, bs1_, bs2_, bs3_, bs4_, storage_, erieval);
267}
268
269Ref<TwoBodyDerivInt>
270IntegralCints::electron_repulsion_deriv()
271{
272 ExEnv::errn() << scprintf("IntegralCints::electron_repulsion_deriv() is not yet implemented.\n");
273 ExEnv::errn() << scprintf("Try using the IntegralV3 factory instead.\n");
274 fail();
275 return 0;
276}
277
278Ref<TwoBodyInt>
279IntegralCints::grt()
280{
281 return new TwoBodyIntCints(this, bs1_, bs2_, bs3_, bs4_, storage_, grteval);
282}
283
284void
285IntegralCints::set_basis(const Ref<GaussianBasisSet> &b1,
286 const Ref<GaussianBasisSet> &b2,
287 const Ref<GaussianBasisSet> &b3,
288 const Ref<GaussianBasisSet> &b4)
289{
290 free_transforms();
291 Integral::set_basis(b1,b2,b3,b4);
292 check_fullgencon();
293 initialize_transforms();
294}
295
296void
297IntegralCints::free_transforms()
298{
299 int i,j;
300 for (i=0; i<=maxl_; i++) {
301 for (j=0; j<=i/2; j++) {
302 delete st_[i][j];
303 delete ist_[i][j];
304 }
305 delete[] st_[i];
306 delete[] ist_[i];
307 }
308 if (maxl_ >= 0) {
309 delete[] st_;
310 delete[] ist_;
311 }
312 st_ = NULL;
313 ist_ = NULL;
314}
315
316void
317IntegralCints::initialize_transforms()
318{
319 maxl_ = -1;
320 int maxam;
321 maxam = bs1_.nonnull()?bs1_->max_angular_momentum():-1;
322 if (maxl_ < maxam) maxl_ = maxam;
323 maxam = bs2_.nonnull()?bs2_->max_angular_momentum():-1;
324 if (maxl_ < maxam) maxl_ = maxam;
325 maxam = bs3_.nonnull()?bs3_->max_angular_momentum():-1;
326 if (maxl_ < maxam) maxl_ = maxam;
327 maxam = bs4_.nonnull()?bs4_->max_angular_momentum():-1;
328 if (maxl_ < maxam) maxl_ = maxam;
329
330 if (maxl_ >= 0) {
331 st_ = new SphericalTransformCints**[maxl_+1];
332 ist_ = new ISphericalTransformCints**[maxl_+1];;
333 int i,j;
334 for (i=0; i<=maxl_; i++) {
335 st_[i] = new SphericalTransformCints*[i/2+1];
336 ist_[i] = new ISphericalTransformCints*[i/2+1];
337 for (j=0; j<=i/2; j++) {
338 st_[i][j] = new SphericalTransformCints(i,i-2*j);
339 ist_[i][j] = new ISphericalTransformCints(i,i-2*j);
340 }
341 }
342 }
343 else {
344 st_ = NULL;
345 ist_ = NULL;
346 }
347}
348
349
350static bool has_fullgencon(const Ref<GaussianBasisSet>&);
351
352void
353IntegralCints::check_fullgencon() const
354{
355 if ( has_fullgencon(bs1_) ||
356 has_fullgencon(bs2_) ||
357 has_fullgencon(bs3_) ||
358 has_fullgencon(bs4_) ) {
359 throw std::runtime_error("IntegralCints cannot handle basis sets with fully general contractions yet, try IntegralV3 instead");
360 }
361}
362
363bool
364has_fullgencon(const Ref<GaussianBasisSet>& bs)
365{
366 bool has_it = false;
367 int nshell = bs->nshell();
368 for(int i=0; i<nshell; i++) {
369 GaussianShell& shell = bs->shell(i);
370 int minam = shell.min_am();
371 int maxam = shell.max_am();
372 if (minam != maxam)
373 has_it = true;
374 }
375
376 return has_it;
377}
378
379/////////////////////////////////////////////////////////////////////////////
380
381// Local Variables:
382// mode: c++
383// c-file-style: "CLJ"
384// End:
Note: See TracBrowser for help on using the repository browser.