1 | //
|
---|
2 | // comp_grt.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 <stdarg.h>
|
---|
29 |
|
---|
30 | #include <util/misc/formio.h>
|
---|
31 | #include <chemistry/qc/cints/macros.h>
|
---|
32 | #include <chemistry/qc/cints/grt.h>
|
---|
33 | #include <chemistry/qc/cints/tform.h>
|
---|
34 | #ifdef DMALLOC
|
---|
35 | #include <dmalloc.h>
|
---|
36 | #endif
|
---|
37 |
|
---|
38 | using namespace std;
|
---|
39 | using namespace sc;
|
---|
40 |
|
---|
41 | static inline void
|
---|
42 | swtch(GaussianBasisSet* &i,GaussianBasisSet* &j)
|
---|
43 | {
|
---|
44 | GaussianBasisSet *tmp;
|
---|
45 | tmp = i;
|
---|
46 | i = j;
|
---|
47 | j = tmp;
|
---|
48 | }
|
---|
49 |
|
---|
50 | static inline void
|
---|
51 | pswtch(void**i,void**j)
|
---|
52 | {
|
---|
53 | void*tmp;
|
---|
54 | tmp = *i;
|
---|
55 | *i = *j;
|
---|
56 | *j = tmp;
|
---|
57 | }
|
---|
58 |
|
---|
59 | static inline void
|
---|
60 | iswtch(int *i,int *j)
|
---|
61 | {
|
---|
62 | int tmp;
|
---|
63 | tmp = *i;
|
---|
64 | *i = *j;
|
---|
65 | *j = tmp;
|
---|
66 | }
|
---|
67 |
|
---|
68 | static void
|
---|
69 | fail()
|
---|
70 | {
|
---|
71 | ExEnv::errn() << scprintf("failing module:\n%s",__FILE__) << endl;
|
---|
72 | abort();
|
---|
73 | }
|
---|
74 |
|
---|
75 | void
|
---|
76 | GRTCints::compute_quartet(int *psh1, int *psh2, int *psh3, int *psh4)
|
---|
77 | {
|
---|
78 | #ifdef EREP_TIMING
|
---|
79 | char section[30];
|
---|
80 | #endif
|
---|
81 | GaussianBasisSet *pbs1=bs1_.pointer();
|
---|
82 | GaussianBasisSet *pbs2=bs2_.pointer();
|
---|
83 | GaussianBasisSet *pbs3=bs3_.pointer();
|
---|
84 | GaussianBasisSet *pbs4=bs4_.pointer();
|
---|
85 | int int_expweight1; // For exponent weighted contractions.
|
---|
86 | int int_expweight2; // For exponent weighted contractions.
|
---|
87 | int int_expweight3; // For exponent weighted contractions.
|
---|
88 | int int_expweight4; // For exponent weighted contractions.
|
---|
89 | int size;
|
---|
90 | int ii;
|
---|
91 | int size1, size2, size3, size4;
|
---|
92 | int tam1,tam2,tam3,tam4;
|
---|
93 | int i,j,k,l;
|
---|
94 | int pi, pj, pk, pl;
|
---|
95 | int gci, gcj, gck, gcl;
|
---|
96 | int sh1,sh2,sh3,sh4; // Shell indices (may be permuted)
|
---|
97 | int osh1,osh2,osh3,osh4; // Shell indices (never permuted)
|
---|
98 | int am1,am2,am3,am4,am12,am34;
|
---|
99 | int minam1,minam2,minam3,minam4;
|
---|
100 | int redundant_index;
|
---|
101 | int e12,e13e24,e34;
|
---|
102 | int p12,p34,p13p24;
|
---|
103 | int eAB;
|
---|
104 |
|
---|
105 | #ifdef DMALLOC
|
---|
106 | /*--- Test heap before ---*/
|
---|
107 | int heapstate;
|
---|
108 | heapstate = dmalloc_verify(target_ints_buffer_[0]);
|
---|
109 | if (heapstate == DMALLOC_VERIFY_ERROR)
|
---|
110 | fail();
|
---|
111 | heapstate = dmalloc_verify(cart_ints_[0]);
|
---|
112 | if (heapstate == DMALLOC_VERIFY_ERROR)
|
---|
113 | fail();
|
---|
114 | heapstate = dmalloc_verify(sphharm_ints_);
|
---|
115 | if (heapstate == DMALLOC_VERIFY_ERROR)
|
---|
116 | fail();
|
---|
117 | heapstate = dmalloc_verify(perm_ints_);
|
---|
118 | if (heapstate == DMALLOC_VERIFY_ERROR)
|
---|
119 | fail();
|
---|
120 | heapstate = dmalloc_verify(tformbuf_);
|
---|
121 | if (heapstate == DMALLOC_VERIFY_ERROR)
|
---|
122 | fail();
|
---|
123 | #endif
|
---|
124 |
|
---|
125 | osh1 = sh1 = *psh1;
|
---|
126 | osh2 = sh2 = *psh2;
|
---|
127 | osh3 = sh3 = *psh3;
|
---|
128 | osh4 = sh4 = *psh4;
|
---|
129 |
|
---|
130 | /* Test the arguments to make sure that they are sensible. */
|
---|
131 | if ( sh1 < 0 || sh1 >= bs1_->nbasis()
|
---|
132 | || sh2 < 0 || sh2 >= bs2_->nbasis()
|
---|
133 | || sh3 < 0 || sh3 >= bs3_->nbasis()
|
---|
134 | || sh4 < 0 || sh4 >= bs4_->nbasis() ) {
|
---|
135 | ExEnv::errn() << scprintf("compute_erep has been incorrectly used\n");
|
---|
136 | ExEnv::errn() << scprintf("shells (bounds): %d (%d), %d (%d), %d (%d), %d (%d)\n",
|
---|
137 | sh1,bs1_->nbasis()-1,
|
---|
138 | sh2,bs2_->nbasis()-1,
|
---|
139 | sh3,bs3_->nbasis()-1,
|
---|
140 | sh4,bs4_->nbasis()-1);
|
---|
141 | fail();
|
---|
142 | }
|
---|
143 |
|
---|
144 | /* Set up pointers to the current shells. */
|
---|
145 | int_shell1_ = &bs1_->shell(sh1);
|
---|
146 | int_shell2_ = &bs2_->shell(sh2);
|
---|
147 | int_shell3_ = &bs3_->shell(sh3);
|
---|
148 | int_shell4_ = &bs4_->shell(sh4);
|
---|
149 |
|
---|
150 | /* Compute the maximum angular momentum on each centers to
|
---|
151 | * determine the most efficient way to invoke the building and shifting
|
---|
152 | * routines. The minimum angular momentum will be computed at the
|
---|
153 | * same time. */
|
---|
154 | minam1 = int_shell1_->min_am();
|
---|
155 | minam2 = int_shell2_->min_am();
|
---|
156 | minam3 = int_shell3_->min_am();
|
---|
157 | minam4 = int_shell4_->min_am();
|
---|
158 | am1 = int_shell1_->max_am();
|
---|
159 | am2 = int_shell2_->max_am();
|
---|
160 | am3 = int_shell3_->max_am();
|
---|
161 | am4 = int_shell4_->max_am();
|
---|
162 | am12 = am1 + am2;
|
---|
163 | am34 = am3 + am4;
|
---|
164 |
|
---|
165 | // This condition being true is guaranteed by the constructor of IntegralCints
|
---|
166 | //if (minam1 != am1 ||
|
---|
167 | // minam2 != am2 ||
|
---|
168 | // minam3 != am3 ||
|
---|
169 | // minam4 != am4 ) {
|
---|
170 | // ExEnv::errn() << scprintf("Int2eCints::comp_eri() cannot yet handle fully general contractions") << endl;
|
---|
171 | // fail();
|
---|
172 | //}
|
---|
173 |
|
---|
174 | /* See if need to transform to spherical harmonics */
|
---|
175 | bool need_cart2sph_transform = false;
|
---|
176 | if (int_shell1_->has_pure() ||
|
---|
177 | int_shell2_->has_pure() ||
|
---|
178 | int_shell3_->has_pure() ||
|
---|
179 | int_shell4_->has_pure())
|
---|
180 | need_cart2sph_transform = true;
|
---|
181 |
|
---|
182 |
|
---|
183 | /* See if contraction quartets need to be resorted into a shell quartet */
|
---|
184 | bool need_sort_to_shell_quartet = false;
|
---|
185 | int num_gen_shells = 0;
|
---|
186 | if (int_shell1_->ncontraction() > 1)
|
---|
187 | num_gen_shells++;
|
---|
188 | if (int_shell2_->ncontraction() > 1)
|
---|
189 | num_gen_shells++;
|
---|
190 | if (int_shell3_->ncontraction() > 1)
|
---|
191 | num_gen_shells++;
|
---|
192 | if (int_shell4_->ncontraction() > 1)
|
---|
193 | num_gen_shells++;
|
---|
194 | if (am12+am34 && num_gen_shells >= 1)
|
---|
195 | need_sort_to_shell_quartet = true;
|
---|
196 |
|
---|
197 | /* Unique integrals are needed only ?*/
|
---|
198 | bool need_unique_ints_only = false;
|
---|
199 | if (!redundant_) {
|
---|
200 | e12 = 0;
|
---|
201 | if (int_shell1_ == int_shell2_ && int_shell1_->nfunction()>1)
|
---|
202 | e12 = 1;
|
---|
203 | e34 = 0;
|
---|
204 | if (int_shell3_ == int_shell4_ && int_shell3_->nfunction()>1)
|
---|
205 | e34 = 1;
|
---|
206 | e13e24 = 0;
|
---|
207 | if (int_shell1_ == int_shell3_ && int_shell2_ == int_shell4_ && int_shell1_->nfunction()*int_shell2_->nfunction()>1)
|
---|
208 | e13e24 = 1;
|
---|
209 |
|
---|
210 | if ( e12 || e34 || e13e24 )
|
---|
211 | need_unique_ints_only = true;
|
---|
212 | }
|
---|
213 |
|
---|
214 |
|
---|
215 | #ifdef EREP_TIMING
|
---|
216 | sprintf(section,"erep am=%02d",am12+am34);
|
---|
217 | tim_enter(section);
|
---|
218 | tim_enter("setup");
|
---|
219 | #endif
|
---|
220 |
|
---|
221 | /* Convert the integral to the most efficient form. */
|
---|
222 | p12 = 0;
|
---|
223 | p34 = 0;
|
---|
224 | p13p24 = 0;
|
---|
225 |
|
---|
226 | if (am2 > am1) {
|
---|
227 | p12 = 1;
|
---|
228 | iswtch(&am1,&am2);iswtch(&sh1,&sh2);iswtch(psh1,psh2);
|
---|
229 | iswtch(&minam1,&minam2);
|
---|
230 | pswtch((void**)&int_shell1_,(void**)&int_shell2_);
|
---|
231 | swtch(pbs1,pbs2);
|
---|
232 | }
|
---|
233 | if (am4 > am3) {
|
---|
234 | p34 = 1;
|
---|
235 | iswtch(&am3,&am4);iswtch(&sh3,&sh4);iswtch(psh3,psh4);
|
---|
236 | iswtch(&minam3,&minam4);
|
---|
237 | pswtch((void**)&int_shell3_,(void**)&int_shell4_);
|
---|
238 | swtch(pbs3,pbs4);
|
---|
239 | }
|
---|
240 | if (am12 > am34) {
|
---|
241 | p13p24 = 1;
|
---|
242 | iswtch(&am1,&am3);iswtch(&sh1,&sh3);iswtch(psh1,psh3);
|
---|
243 | iswtch(&am2,&am4);iswtch(&sh2,&sh4);iswtch(psh2,psh4);
|
---|
244 | iswtch(&am12,&am34);
|
---|
245 | iswtch(&minam1,&minam3);
|
---|
246 | iswtch(&minam2,&minam4);
|
---|
247 | pswtch((void**)&int_shell1_,(void**)&int_shell3_);
|
---|
248 | swtch(pbs1,pbs3);
|
---|
249 | pswtch((void**)&int_shell2_,(void**)&int_shell4_);
|
---|
250 | swtch(pbs2,pbs4);
|
---|
251 | }
|
---|
252 | bool shells_were_permuted = (p12||p34||p13p24);
|
---|
253 |
|
---|
254 | /* If the centers were permuted, then the int_expweighted variable may
|
---|
255 | * need to be changed. */
|
---|
256 | if (p12) {
|
---|
257 | iswtch(&int_expweight1,&int_expweight2);
|
---|
258 | }
|
---|
259 | if (p34) {
|
---|
260 | iswtch(&int_expweight3,&int_expweight4);
|
---|
261 | }
|
---|
262 | if (p13p24) {
|
---|
263 | iswtch(&int_expweight1,&int_expweight3);
|
---|
264 | iswtch(&int_expweight2,&int_expweight4);
|
---|
265 | }
|
---|
266 |
|
---|
267 | /* Compute the shell sizes. */
|
---|
268 | size1 = int_shell1_->ncartesian();
|
---|
269 | size2 = int_shell2_->ncartesian();
|
---|
270 | size3 = int_shell3_->ncartesian();
|
---|
271 | size4 = int_shell4_->ncartesian();
|
---|
272 | size = size1*size2*size3*size4;
|
---|
273 |
|
---|
274 | /* Compute center data for Libint */
|
---|
275 | int ctr1 = pbs1->shell_to_center(sh1);
|
---|
276 | int ctr2 = pbs2->shell_to_center(sh2);
|
---|
277 | int ctr3 = pbs3->shell_to_center(sh3);
|
---|
278 | int ctr4 = pbs4->shell_to_center(sh4);
|
---|
279 | for(i=0;i<3;i++) {
|
---|
280 | double A = pbs1->r(ctr1,i);
|
---|
281 | double B = pbs2->r(ctr2,i);
|
---|
282 | double C = pbs3->r(ctr3,i);
|
---|
283 | double D = pbs4->r(ctr4,i);
|
---|
284 | quartet_info_.A[i] = A;
|
---|
285 | quartet_info_.B[i] = B;
|
---|
286 | quartet_info_.C[i] = C;
|
---|
287 | quartet_info_.D[i] = D;
|
---|
288 | Libr12_.ShellQuartet.AB[i] = A - B;
|
---|
289 | Libr12_.ShellQuartet.CD[i] = C - D;
|
---|
290 | Libr12_.ShellQuartet.AC[i] = A - C;
|
---|
291 | }
|
---|
292 | quartet_info_.AB2 = Libr12_.ShellQuartet.AB[0]*Libr12_.ShellQuartet.AB[0] +
|
---|
293 | Libr12_.ShellQuartet.AB[1]*Libr12_.ShellQuartet.AB[1] +
|
---|
294 | Libr12_.ShellQuartet.AB[2]*Libr12_.ShellQuartet.AB[2];
|
---|
295 | quartet_info_.CD2 = Libr12_.ShellQuartet.CD[0]*Libr12_.ShellQuartet.CD[0] +
|
---|
296 | Libr12_.ShellQuartet.CD[1]*Libr12_.ShellQuartet.CD[1] +
|
---|
297 | Libr12_.ShellQuartet.CD[2]*Libr12_.ShellQuartet.CD[2];
|
---|
298 | Libr12_.ShellQuartet.ABdotAC = Libr12_.ShellQuartet.AB[0]*Libr12_.ShellQuartet.AC[0]+
|
---|
299 | Libr12_.ShellQuartet.AB[1]*Libr12_.ShellQuartet.AC[1]+
|
---|
300 | Libr12_.ShellQuartet.AB[2]*Libr12_.ShellQuartet.AC[2];
|
---|
301 | Libr12_.ShellQuartet.CDdotCA = -1.0*(Libr12_.ShellQuartet.CD[0]*Libr12_.ShellQuartet.AC[0]+
|
---|
302 | Libr12_.ShellQuartet.CD[1]*Libr12_.ShellQuartet.AC[1]+
|
---|
303 | Libr12_.ShellQuartet.CD[2]*Libr12_.ShellQuartet.AC[2]);
|
---|
304 |
|
---|
305 | /* Set up pointers to the current shell pairs. */
|
---|
306 | quartet_info_.shell_pair12 = shell_pairs12_->shell_pair(osh1,osh2);
|
---|
307 | quartet_info_.shell_pair34 = shell_pairs34_->shell_pair(osh3,osh4);
|
---|
308 |
|
---|
309 | /* Remember how permuted - will need to access shell pairs in grt_quartet_data_() using the original
|
---|
310 | primitive indices */
|
---|
311 | quartet_info_.p12 = p12;
|
---|
312 | quartet_info_.p34 = p34;
|
---|
313 | quartet_info_.p13p24 = p13p24;
|
---|
314 |
|
---|
315 | /* Remember the original primitive indices to access shell pair data
|
---|
316 | Note the reverse order of switching, p13p24 first,
|
---|
317 | then p12 and p34 - because we need the inverse mapping! */
|
---|
318 | quartet_info_.op1 = &quartet_info_.p1;
|
---|
319 | quartet_info_.op2 = &quartet_info_.p2;
|
---|
320 | quartet_info_.op3 = &quartet_info_.p3;
|
---|
321 | quartet_info_.op4 = &quartet_info_.p4;
|
---|
322 | if (p13p24) {
|
---|
323 | pswtch((void **)&quartet_info_.op1,(void **)&quartet_info_.op3);
|
---|
324 | pswtch((void **)&quartet_info_.op2,(void **)&quartet_info_.op4);
|
---|
325 | }
|
---|
326 | if (p12)
|
---|
327 | pswtch((void **)&quartet_info_.op1,(void **)&quartet_info_.op2);
|
---|
328 | if (p34)
|
---|
329 | pswtch((void **)&quartet_info_.op3,(void **)&quartet_info_.op4);
|
---|
330 |
|
---|
331 | /* Determine where integrals need to go at each stage */
|
---|
332 | if (shells_were_permuted)
|
---|
333 | if (need_sort_to_shell_quartet) {
|
---|
334 | for(int te_type=0; te_type<num_te_types_; te_type++)
|
---|
335 | prim_ints_[te_type] = cart_ints_[te_type];
|
---|
336 | if (need_cart2sph_transform)
|
---|
337 | for(int te_type=0; te_type<num_te_types_; te_type++)
|
---|
338 | contr_quartets_[te_type] = sphharm_ints_;
|
---|
339 | else
|
---|
340 | for(int te_type=0; te_type<num_te_types_; te_type++)
|
---|
341 | contr_quartets_[te_type] = cart_ints_[te_type];
|
---|
342 | for(int te_type=0; te_type<num_te_types_; te_type++)
|
---|
343 | shell_quartet_[te_type] = perm_ints_;
|
---|
344 | }
|
---|
345 | else {
|
---|
346 | for(int te_type=0; te_type<num_te_types_; te_type++)
|
---|
347 | prim_ints_[te_type] = cart_ints_[te_type];
|
---|
348 | if (need_cart2sph_transform) {
|
---|
349 | for(int te_type=0; te_type<num_te_types_; te_type++) {
|
---|
350 | contr_quartets_[te_type] = sphharm_ints_;
|
---|
351 | shell_quartet_[te_type] = contr_quartets_[te_type];
|
---|
352 | }
|
---|
353 | }
|
---|
354 | else
|
---|
355 | for(int te_type=0; te_type<num_te_types_; te_type++)
|
---|
356 | shell_quartet_[te_type] = cart_ints_[te_type];
|
---|
357 | }
|
---|
358 | else
|
---|
359 | if (need_sort_to_shell_quartet) {
|
---|
360 | for(int te_type=0; te_type<num_te_types_; te_type++)
|
---|
361 | prim_ints_[te_type] = cart_ints_[te_type];
|
---|
362 | if (need_cart2sph_transform)
|
---|
363 | for(int te_type=0; te_type<num_te_types_; te_type++)
|
---|
364 | contr_quartets_[te_type] = sphharm_ints_;
|
---|
365 | else
|
---|
366 | for(int te_type=0; te_type<num_te_types_; te_type++)
|
---|
367 | contr_quartets_[te_type] = cart_ints_[te_type];
|
---|
368 | for(int te_type=0; te_type<num_te_types_; te_type++)
|
---|
369 | shell_quartet_[te_type] = target_ints_buffer_[te_type];
|
---|
370 | }
|
---|
371 | else {
|
---|
372 | if (need_cart2sph_transform) {
|
---|
373 | for(int te_type=0; te_type<num_te_types_; te_type++) {
|
---|
374 | prim_ints_[te_type] = cart_ints_[te_type];
|
---|
375 | contr_quartets_[te_type] = target_ints_buffer_[te_type];
|
---|
376 | shell_quartet_[te_type] = target_ints_buffer_[te_type];
|
---|
377 | }
|
---|
378 | }
|
---|
379 | else {
|
---|
380 | for(int te_type=0; te_type<num_te_types_; te_type++) {
|
---|
381 | prim_ints_[te_type] = target_ints_buffer_[te_type];
|
---|
382 | shell_quartet_[te_type] = target_ints_buffer_[te_type];
|
---|
383 | }
|
---|
384 | }
|
---|
385 | }
|
---|
386 |
|
---|
387 | /* Begin loops over generalized contractions. */
|
---|
388 | int buffer_offset = 0;
|
---|
389 | for (gci=0; gci<int_shell1_->ncontraction(); gci++) {
|
---|
390 | tam1 = int_shell1_->am(gci);
|
---|
391 | int tsize1 = INT_NCART_NN(tam1);
|
---|
392 | quartet_info_.gc1 = gci;
|
---|
393 | for (gcj=0; gcj<int_shell2_->ncontraction(); gcj++) {
|
---|
394 | tam2 = int_shell2_->am(gcj);
|
---|
395 | int tsize2 = INT_NCART_NN(tam2);
|
---|
396 | quartet_info_.gc2 = gcj;
|
---|
397 | for (gck=0; gck<int_shell3_->ncontraction(); gck++) {
|
---|
398 | tam3 = int_shell3_->am(gck);
|
---|
399 | int tsize3 = INT_NCART_NN(tam3);
|
---|
400 | quartet_info_.gc3 = gck;
|
---|
401 | for (gcl=0; gcl<int_shell4_->ncontraction(); gcl++) {
|
---|
402 | tam4 = int_shell4_->am(gcl);
|
---|
403 | int tsize4 = INT_NCART_NN(tam4);
|
---|
404 | quartet_info_.gc4 = gcl;
|
---|
405 | quartet_info_.am = tam1 + tam2 + tam3 + tam4;
|
---|
406 | int size = tsize1*tsize2*tsize3*tsize4;
|
---|
407 |
|
---|
408 | /*---------------------------
|
---|
409 | Begin loop over primitives
|
---|
410 | ---------------------------*/
|
---|
411 | int num_prim_comb = 0;
|
---|
412 | for (pi=0; pi<int_shell1_->nprimitive(); pi++) {
|
---|
413 | quartet_info_.p1 = pi;
|
---|
414 | for (pj=0; pj<int_shell2_->nprimitive(); pj++) {
|
---|
415 | quartet_info_.p2 = pj;
|
---|
416 | for (pk=0; pk<int_shell3_->nprimitive(); pk++) {
|
---|
417 | quartet_info_.p3 = pk;
|
---|
418 | for (pl=0; pl<int_shell4_->nprimitive(); pl++) {
|
---|
419 | quartet_info_.p4 = pl;
|
---|
420 |
|
---|
421 | /* Compute primitive data for Libint */
|
---|
422 | grt_quartet_data_(&(Libr12_.PrimQuartet[num_prim_comb++]), 1.0);
|
---|
423 |
|
---|
424 | }}}}
|
---|
425 | /*-------------------------------------------
|
---|
426 | Evaluate the integrals.
|
---|
427 | 1) if not allowed to leave shells permuted
|
---|
428 | in the result - have to take into account
|
---|
429 | non-hemiticity of commutator integrals
|
---|
430 | -------------------------------------------*/
|
---|
431 | if (quartet_info_.am) {
|
---|
432 | build_r12_grt[tam1][tam2][tam3][tam4](&Libr12_, num_prim_comb);
|
---|
433 | if (!permute_ && p13p24) {
|
---|
434 | // (usi usj|[r12,T1]|usk usl) = (usk usl|[r12,T2]|usi usj)
|
---|
435 | double *tmp_ptr = Libr12_.te_ptr[2];
|
---|
436 | Libr12_.te_ptr[2] = Libr12_.te_ptr[3];
|
---|
437 | Libr12_.te_ptr[3] = tmp_ptr;
|
---|
438 | }
|
---|
439 | for(int te_type=0; te_type<num_te_types_; te_type++) {
|
---|
440 | REALTYPE *raw_data = Libr12_.te_ptr[te_type];
|
---|
441 | double *prim_ints_ptr = &(prim_ints_[te_type][buffer_offset]);
|
---|
442 | if (!permute_ && ((te_type==2 && p12) || (te_type==3 && p34)))
|
---|
443 | for(int ijkl=0; ijkl<size; ijkl++)
|
---|
444 | *(prim_ints_ptr++) = (-1.0) * ((double) *(raw_data++));
|
---|
445 | else
|
---|
446 | for(int ijkl=0; ijkl<size; ijkl++)
|
---|
447 | *(prim_ints_ptr++) = (double) *(raw_data++);
|
---|
448 | }
|
---|
449 | }
|
---|
450 | else {
|
---|
451 | REALTYPE ssss = 0.0;
|
---|
452 | REALTYPE ss_r12_ss = 0.0;
|
---|
453 | for(int i=0;i<num_prim_comb;i++) {
|
---|
454 | ssss += Libr12_.PrimQuartet[i].F[0];
|
---|
455 | ss_r12_ss += Libr12_.PrimQuartet[i].ss_r12_ss;
|
---|
456 | }
|
---|
457 | build_r12_grt[0][0][0][0](&Libr12_,num_prim_comb);
|
---|
458 | if (!permute_ && p13p24) {
|
---|
459 | // (usi usj|[r12,T1]|usk usl) = (usk usl|[r12,T2]|usi usj)
|
---|
460 | double *tmp_ptr = Libr12_.te_ptr[2];
|
---|
461 | Libr12_.te_ptr[2] = Libr12_.te_ptr[3];
|
---|
462 | Libr12_.te_ptr[3] = tmp_ptr;
|
---|
463 | }
|
---|
464 | prim_ints_[0][buffer_offset] = ssss;
|
---|
465 | prim_ints_[1][buffer_offset] = ss_r12_ss;
|
---|
466 | prim_ints_[2][buffer_offset] = (double) Libr12_.te_ptr[2][0];
|
---|
467 | prim_ints_[3][buffer_offset] = (double) Libr12_.te_ptr[3][0];
|
---|
468 | }
|
---|
469 | buffer_offset += size;
|
---|
470 | }}}}
|
---|
471 |
|
---|
472 | for(int te_type=0; te_type < num_te_types_; te_type++) {
|
---|
473 | /*-------------------------------------------
|
---|
474 | Transform to spherical harmonics if needed
|
---|
475 | -------------------------------------------*/
|
---|
476 | if (need_cart2sph_transform)
|
---|
477 | transform_contrquartets_(prim_ints_[te_type],contr_quartets_[te_type]);
|
---|
478 |
|
---|
479 | /*----------------------------------------------
|
---|
480 | Resort integrals from by-contraction-quartets
|
---|
481 | into shell-quartet order if needed
|
---|
482 | ----------------------------------------------*/
|
---|
483 | if (need_sort_to_shell_quartet)
|
---|
484 | sort_contrquartets_to_shellquartet_(contr_quartets_[te_type],shell_quartet_[te_type]);
|
---|
485 |
|
---|
486 | /*---------------------------------
|
---|
487 | Permute integrals back if needed
|
---|
488 | ---------------------------------*/
|
---|
489 | if ((!permute_)&&shells_were_permuted) {
|
---|
490 | // handle integrals first
|
---|
491 | permute_target_(shell_quartet_[te_type],target_ints_buffer_[te_type],p13p24,p12,p34);
|
---|
492 | }
|
---|
493 | }
|
---|
494 |
|
---|
495 | if ((!permute_)&&shells_were_permuted) {
|
---|
496 | // then indices
|
---|
497 | if (p13p24) {
|
---|
498 | iswtch(&sh1,&sh3);iswtch(psh1,psh3);
|
---|
499 | iswtch(&sh2,&sh4);iswtch(psh2,psh4);
|
---|
500 | iswtch(&am1,&am3);
|
---|
501 | iswtch(&am2,&am4);
|
---|
502 | iswtch(&am12,&am34);
|
---|
503 | pswtch((void**)&int_shell1_,(void**)&int_shell3_);
|
---|
504 | swtch(pbs1,pbs3);
|
---|
505 | pswtch((void**)&int_shell2_,(void**)&int_shell4_);
|
---|
506 | swtch(pbs2,pbs4);
|
---|
507 | iswtch(&int_expweight1,&int_expweight3);
|
---|
508 | iswtch(&int_expweight2,&int_expweight4);
|
---|
509 | }
|
---|
510 | if (p34) {
|
---|
511 | iswtch(&sh3,&sh4);iswtch(psh3,psh4);
|
---|
512 | iswtch(&am3,&am4);
|
---|
513 | pswtch((void**)&int_shell3_,(void**)&int_shell4_);
|
---|
514 | swtch(pbs3,pbs4);
|
---|
515 | iswtch(&int_expweight3,&int_expweight4);
|
---|
516 | }
|
---|
517 | if (p12) {
|
---|
518 | iswtch(&sh1,&sh2);iswtch(psh1,psh2);
|
---|
519 | iswtch(&am1,&am2);
|
---|
520 | pswtch((void**)&int_shell1_,(void**)&int_shell2_);
|
---|
521 | swtch(pbs1,pbs2);
|
---|
522 | iswtch(&int_expweight1,&int_expweight2);
|
---|
523 | }
|
---|
524 | }
|
---|
525 |
|
---|
526 | for(int te_type=0; te_type<num_te_types_; te_type++) {
|
---|
527 | /*--- Extract unique integrals (needed? probably not for linear R12 methods) ---*/
|
---|
528 | if (need_unique_ints_only// && te_type <= 1
|
---|
529 | )
|
---|
530 | get_nonredundant_ints_(target_ints_buffer_[te_type],target_ints_buffer_[te_type],e13e24,e12,e34);
|
---|
531 | }
|
---|
532 |
|
---|
533 | #ifdef DMALLOC
|
---|
534 | /*--- Test heap after ---*/
|
---|
535 | heapstate = dmalloc_verify(target_ints_buffer_[0]);
|
---|
536 | if (heapstate == DMALLOC_VERIFY_ERROR)
|
---|
537 | fail();
|
---|
538 | heapstate = dmalloc_verify(cart_ints_[0]);
|
---|
539 | if (heapstate == DMALLOC_VERIFY_ERROR)
|
---|
540 | fail();
|
---|
541 | heapstate = dmalloc_verify(sphharm_ints_);
|
---|
542 | if (heapstate == DMALLOC_VERIFY_ERROR)
|
---|
543 | fail();
|
---|
544 | heapstate = dmalloc_verify(perm_ints_);
|
---|
545 | if (heapstate == DMALLOC_VERIFY_ERROR)
|
---|
546 | fail();
|
---|
547 | heapstate = dmalloc_verify(tformbuf_);
|
---|
548 | if (heapstate == DMALLOC_VERIFY_ERROR)
|
---|
549 | fail();
|
---|
550 | #endif
|
---|
551 |
|
---|
552 | return;
|
---|
553 | }
|
---|
554 |
|
---|
555 |
|
---|
556 | /////////////////////////////////////////////////////////////////////////////
|
---|
557 |
|
---|
558 | // Local Variables:
|
---|
559 | // mode: c++
|
---|
560 | // c-file-style: "CLJ-CONDENSED"
|
---|
561 | // End:
|
---|