MPQC 3.0.0-alpha
Loading...
Searching...
No Matches
int2e.h
1//
2// int2e.h
3//
4// Copyright (C) 1996 Limit Point Systems, Inc.
5//
6// Author: Curtis Janssen <cljanss@limitpt.com>
7// Maintainer: LPS
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#ifndef _chemistry_qc_intv3_int2e_h
29#define _chemistry_qc_intv3_int2e_h
30
31#include <limits.h>
32
33#include <util/ref/ref.h>
34#include <chemistry/qc/basis/basis.h>
35#include <chemistry/qc/oint3/build.h>
36#include <chemistry/qc/basis/fjt.h>
37#include <chemistry/qc/intv3/types.h>
38#include <chemistry/qc/intv3/storage.h>
39#include <chemistry/qc/intv3/array.h>
40#include <chemistry/qc/intv3/macros.h>
41
42namespace sc {
43
44class Integral;
45
46#define CHECK_INTEGRAL_ALGORITHM 0
47
51class Int2eV3: public RefCount {
52 protected:
53 Integral *integral_;
54
55 BuildIntV3 build;
57
62
63 // the permuted bases
64 GaussianBasisSet *pbs1_;
65 GaussianBasisSet *pbs2_;
66 GaussianBasisSet *pbs3_;
67 GaussianBasisSet *pbs4_;
68
69 Ref<MessageGrp> grp_;
70
71 int bs1_shell_offset_;
72 int bs2_shell_offset_;
73 int bs3_shell_offset_;
74 int bs4_shell_offset_;
75 int bs1_func_offset_;
76 int bs2_func_offset_;
77 int bs3_func_offset_;
78 int bs4_func_offset_;
79 int bs1_prim_offset_;
80 int bs2_prim_offset_;
81 int bs3_prim_offset_;
82 int bs4_prim_offset_;
83
84 // statics from vrr.cc
85 public:
86 enum { STORAGE_CHUNK = 4096 };
87 protected:
88 struct store_list {
89 void* data[STORAGE_CHUNK];
90 struct store_list* p;
91 };
92 typedef struct store_list store_list_t;
93 int n_store_last;
94 store_list_t* store;
95 typedef int (BuildIntV3::*intfunc)();
96 intfunc build_routine[4][4][4][4][2];
97 /* Offset shell numbers. */
98 int osh1, osh2, osh3, osh4;
99 /* Offset primitive numbers. */
100 int opr1, opr2, opr3, opr4;
101 /* Saved initialization parameters used to free data. */
102 int saved_am12,saved_am34,saved_ncon;
103 /* Stores the length of the inner loop for integral contraction. */
104 IntV3Arrayint3 contract_length;
105
106 // statics from hrr.cc
107 protected:
108 /* The general contraction numbers. */
109 int g1,g2,g3,g4;
110 /* A[] - B[] */
111 double AmB[3];
112 /* C[] - D[] */
113 double CmD[3];
114 int eAB;
115 double *buf34;
116 double *buf12;
117 double *bufshared;
118
119 int redundant_;
120 int permute_;
121
122 protected:
123 Ref<FJT> fjt_;
124
125 int *int_shell_to_prim;
126 IntV3Arraydouble2 int_shell_r;
127 IntV3Arraydouble2 int_prim_zeta;
128 IntV3Arraydouble2 int_prim_k;
129 IntV3Arraydouble2 int_prim_oo2zeta;
130 IntV3Arraydouble3 int_prim_p;
131
132 double *int_buffer;
133 double *int_derint_buffer;
134
135 Ref<GaussianBasisSet> int_cs1;
136 Ref<GaussianBasisSet> int_cs2;
137 Ref<GaussianBasisSet> int_cs3;
138 Ref<GaussianBasisSet> int_cs4;
139
140 GaussianShell *int_shell1;
141 GaussianShell *int_shell2;
142 GaussianShell *int_shell3;
143 GaussianShell *int_shell4;
144
145 IntV3Arraydoublep2 ****e0f0_con_ints_array; /* The contr. int. inter. */
146
147 int int_expweight1; // For exponent weighted contractions.
148 int int_expweight2; // For exponent weighted contractions.
149 int int_expweight3; // For exponent weighted contractions.
150 int int_expweight4; // For exponent weighted contractions.
151
152 // These are used to compute two and three center electron repulsion
153 // integrals. int_unit2 is 1 if shell 2 is to have value one everywhere
154 // and int_unit4 is 1 if shell4 is to be a unit function. Otherwise,
155 // they should be zero.
156 //
157
158 int int_unit2;
159 int int_unit4;
160 GaussianShell* int_unit_shell;
161
162 int int_integral_storage;
163 int int_store1;
164 int int_store2;
165 int int_derivative_bounds;
166
167 // locals from vrr.cc
168 protected:
169 void add_store(void *p);
170 void free_store();
171 void _free_store(store_list_t* s, int n);
172 void build_not_using_gcs(int nc1, int nc2, int nc3, int nc4,
173 int minam1, int minam3, int maxam12, int maxam34,
174 int dam1, int dam2, int dam3, int dam4, int eAB);
175 void build_using_gcs(int nc1, int nc2, int nc3, int nc4,
176 int minam1, int minam3, int maxam12, int maxam34,
177 int dam1, int dam2, int dam3, int dam4, int eAB);
178 void gen_prim_intermediates(int pr1, int pr2, int pr3, int pr4, int am);
179 void gen_prim_intermediates_with_norm(int pr1, int pr2, int pr3, int pr4,
180 int am, double norm);
181 void gen_shell_intermediates(int sh1, int sh2, int sh3, int sh4);
182 void blockbuildprim(int minam1, int maxam12, int minam3, int maxam34);
183 void blockbuildprim_1(int am12min, int am12max, int am34, int m);
184 void blockbuildprim_3(int am34min, int am34max, int m);
185
186 // globals from vrr.cc
187 protected:
188 void int_init_buildgc(int order,
189 int am1, int am2, int am3, int am4,
190 int nc1, int nc2, int nc3, int nc4);
191 void int_done_buildgc();
192 void int_buildgcam(int minam1, int minam2, int minam3, int minam4,
193 int maxam1, int maxam2, int maxam3, int maxam4,
194 int dam1, int dam2, int dam3, int dam4,
195 int sh1, int sh2, int sh3, int sh4,
196 int eAB);
197
198 // globals from print2e.cc
199 protected:
200 void int_offset_print(std::ostream &,
201 double *buffer,
202 Ref<GaussianBasisSet> c1, int s1,
203 Ref<GaussianBasisSet> c2, int s2,
204 Ref<GaussianBasisSet> c3, int s3,
205 Ref<GaussianBasisSet> c4, int s4);
206 void int_offset_print_n(std::ostream &, double *buffer,
207 int n1, int n2, int n3, int n4,
208 int o1, int o2, int o3, int o4,
209 int e12, int e13e24, int e34);
210 void int_print(std::ostream &, double *buffer,
211 Ref<GaussianBasisSet> c1, int s1,
212 Ref<GaussianBasisSet> c2, int s2,
213 Ref<GaussianBasisSet> c3, int s3,
214 Ref<GaussianBasisSet> c4, int s4);
215 void int_print_n(std::ostream &, double *buffer,
216 int n1, int n2, int n3, int n4,
217 int e12, int e13e24, int e34);
218 void int_print_intermediates(std::ostream &);
219
220 // locals from hrr.cc
221 protected:
222 void shiftam_12(double *I0100, double *I1000, double *I0000,
223 int am1, int am2, int am3, int am4);
224 void shiftam_12eAB(double *I0100, double *I1000, double *I0000,
225 int am1, int am2, int am3, int am4);
226 void shiftam_34(double *I0001, double *I0010, double *I0000,
227 int am1, int am2, int am3, int am4);
228
229 // globals from hrr.cc
230 protected:
231 void int_init_shiftgc(int order, int am1, int am2, int am3, int am4);
232 void int_done_shiftgc();
233 double *int_shiftgcam(int gc1, int gc2, int gc3, int gc4,
234 int tam1, int tam2, int tam3, int tam4, int peAB);
235
236 // locals from init2e.cc
237 protected:
238 void alloc_inter(int nprim,int nshell);
239 void compute_shell_1(Ref<GaussianBasisSet> cs, int, int);
240 void compute_prim_2(Ref<GaussianBasisSet> cs1,int,int,
241 Ref<GaussianBasisSet> cs2,int,int);
242
243
244 // globals from init2e.cc
245 protected:
246 double *int_initialize_erep(size_t storage, int order,
247 const Ref<GaussianBasisSet> &cs1,
248 const Ref<GaussianBasisSet> &cs2,
249 const Ref<GaussianBasisSet> &cs3,
250 const Ref<GaussianBasisSet> &cs4);
251 void int_done_erep();
252
253 // from tformv3.cc
254 protected:
255 double *source;
256 double *target;
257 double *scratch;
258 int nsourcemax;
259 // transform implementation functions:
260 void transform_init();
261 void transform_done();
262 void source_space(int nsource);
263 void copy_to_source(double *integrals, int nsource);
264 void do_gencon_sparse_transform_2e(Integral*integ,
265 double *integrals, double *target,
266 int index,
267 GaussianShell *sh1, GaussianShell *sh2,
268 GaussianShell *sh3, GaussianShell *sh4);
269 // functions for general use outside of tformv3.cc:
270 // integrals and target may overlap
271 void transform_2e_slow(Integral *,
272 double *integrals, double *target,
273 GaussianShell *sh1, GaussianShell *sh2,
274 GaussianShell *sh3, GaussianShell *sh4);
275 void transform_2e(Integral *,
276 double *integrals, double *target,
277 GaussianShell *sh1, GaussianShell *sh2,
278 GaussianShell *sh3, GaussianShell *sh4);
279
280 // locals from comp2e.cc
281 protected:
282 void compute_erep(int flags, int *psh1, int *psh2, int *psh3, int *psh4,
283 int dam1, int dam2, int dam3, int dam4);
284 void compute_erep_1der(int flags, double *buffer,
285 int *psh1, int *psh2, int *psh3, int *psh4,
286 int dercenter);
287 void nonredundant_erep(double *buffer, int e12, int e34, int e13e24,
288 int n1, int n2, int n3, int n4,
289 int *red_off, int *nonred_off);
290 void compute_erep_bound1der(int flags, double *buffer,
291 int *psh1, int *psh2, int *psh3, int *psh4);
292
293 // globals from comp2e.cc
294 protected:
295 void int_erep_bound1der(int flags, int bsh1, int bsh2, int *size);
296
297
298 // global vars from bounds.h
299 protected:
300 typedef signed char int_bound_t;
301 enum { int_bound_min = SCHAR_MIN, int_bound_max = SCHAR_MAX };
302 int_bound_t int_Q;
303 int_bound_t int_R;
304 int_bound_t *int_Qvec;
305 int_bound_t *int_Rvec;
306
307 // global routines from bounds.cc
308 protected:
309 void int_init_bounds_nocomp();
310 void int_init_bounds_1der_nocomp();
311 void int_bounds_comp(int s1, int s2);
312 void int_bounds_1der_comp(int s1, int s2);
313 int int_erep_2bound(int s1, int s2);
314 int int_erep_0bound_1der();
315 int int_erep_2bound_1der(int s1, int s2);
316
317 // local routines from bounds.cc
318 protected:
319 void compute_bounds(int_bound_t *overall, int_bound_t *vec, int flag);
320 void compute_bounds_shell(int_bound_t *overall, int_bound_t *vec,
321 int flag, int sh1, int sh2);
322
323 // global routines from storage.cc
324 protected:
325 int int_have_stored_integral(int sh1,int sh2,int sh3,int sh4,
326 int p12,int p34,int p13p24);
327 void int_store_integral(int sh1,int sh2,int sh3,int sh4,
328 int p12,int p34,int p13p24,
329 int size);
330
331 // from offsets.cc
332 protected:
333 void int_initialize_offsets2();
334 void int_done_offsets2();
335
336 // from comp2e3c.cc
337 protected:
338 void make_int_unit_shell();
339 void delete_int_unit_shell();
340
341 protected:
342 // for intermediate storage:
343 int used_storage_;
344 int used_storage_build_;
345 int used_storage_shift_;
346
347 public:
348 // bs4 must be null for 3 center integrals
349 // bs2 must be null for 2 center integrals
350 // bs1 and bs3 must be nonnull.
352 const Ref<GaussianBasisSet>&bs1,
353 const Ref<GaussianBasisSet>&bs2,
354 const Ref<GaussianBasisSet>&bs3,
355 const Ref<GaussianBasisSet>&bs4,
356 int order, size_t storage);
357 ~Int2eV3();
358
359 // storage.cc: for the storage of integrals
360 void init_storage(int size);
361 void done_storage();
362
363 // for intermediate storage
364 int storage_used() { return used_storage_; }
365
366 // bounds.cc
367 void init_bounds();
368 void init_bounds_1der();
369 void done_bounds();
370 void done_bounds_1der();
371 // Covert a bound to/from the log of the bound (returns 2^bound)
372 // replace:
373 //double int_bound_to_double(int bound);
374 //double int_bound_double(int value);
375 //int int_bound_log(double value);
376 static double logbound_to_bound(int);
377 static int bound_to_logbound(double value);
378
379 // If redundant is false the redundant integrals that arise
380 // when a shell index is repeated are stored.
381 // The default is true.
382 int redundant() { return redundant_; }
383 void set_redundant(int i) { redundant_ = i; }
384
385 // If permute is true the routines are allowed to permute indices.
386 // The default is false.
387 int permute() { return permute_; }
388 void set_permute(int i) { permute_ = i; }
389
390 int used_storage() const { return used_storage_; }
391
392 // from comp2e.cc
393 void erep(int &psh1, int &psh2, int &psh3, int &psh4);
394 void erep(int *shells, int *sizes);
395 void erep_all1der(int &psh1, int &psh2, int &psh3, int &psh4,
396 der_centersv3_t *der_centers);
397 void erep_all1der(int *shells, int *sizes,
398 der_centersv3_t *dercenters);
399
400 // from comp2e3c.cc
401 void erep_2center(int &psh1, int &psh2);
402 void erep_2center(int *shells, int *sizes);
403 void erep_3center(int &psh1, int &psh2, int &psh3);
404 void erep_3center(int *shells, int *sizes);
405
406 // from bounds.cc
407 int erep_4bound(int s1, int s2, int s3, int s4);
408 int erep_4bound_1der(int s1, int s2, int s3, int s4);
409
410 double *buffer() { return int_buffer; }
411
412 Ref<GaussianBasisSet> basis()
413 {
414 if (bs1_==bs2_ && bs1_ == bs3_ && bs1_ == bs4_) return bs1_;
415 return 0;
416 }
417 Ref<GaussianBasisSet> basis1() { return bs1_; }
418 Ref<GaussianBasisSet> basis2() { return bs2_; }
419 Ref<GaussianBasisSet> basis3() { return bs3_; }
420 Ref<GaussianBasisSet> basis4() { return bs4_; }
421
422 Ref<GaussianBasisSet> cs1() const { return int_cs1; }
423 Ref<GaussianBasisSet> cs2() const { return int_cs2; }
424 Ref<GaussianBasisSet> cs3() const { return int_cs3; }
425 Ref<GaussianBasisSet> cs4() const { return int_cs4; }
426
427 GaussianBasisSet * pcs1() const { return int_cs1.pointer(); }
428 GaussianBasisSet * pcs2() const { return int_cs2.pointer(); }
429 GaussianBasisSet * pcs3() const { return int_cs3.pointer(); }
430 GaussianBasisSet * pcs4() const { return int_cs4.pointer(); }
431};
432
433}
434
435#endif
436
437// Local Variables:
438// mode: c++
439// c-file-style: "CLJ"
440// End:
Definition build.h:15
The GaussianBasisSet class is used describe a basis set composed of atomic gaussian orbitals.
Definition gaussbas.h:145
A shell of Gaussian functions.
Definition gaussshell.h:57
Int2eV3 is a class wrapper for the two body part of the C language IntV3 library.
Definition int2e.h:51
Definition array.h:35
Definition array.h:48
Definition array.h:62
Definition array.h:108
The Integral abstract class acts as a factory to provide objects that compute one and two electron in...
Definition integral.h:111
The base class for all reference counted objects.
Definition ref.h:192
A template class that maintains references counts.
Definition ref.h:361
T * pointer() const
Returns a pointer the reference counted object.
Definition ref.h:413
Contains all MPQC code up to version 3.
Definition mpqcin.h:14
Definition int2e.h:88

Generated at Wed Sep 25 2024 02:45:29 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.12.0.