142
142
C 1el. derivatives
143
143
if(.not.dobq) then
144
call intd_1eh1(basis,ish1,basis,ish2,lscr,scr,
144
call intd_1eh1(basis,ish1,basis,ish2,lscr,scr,
147
call intd_1epot(basis,ish1,basis,ish2,lscr,scr,
147
call intd_1epot(basis,ish1,basis,ish2,lscr,scr,
253
C> \brief calculate the gradient terms due to the interaction with the
253
255
subroutine grad_hnd_cos ( H, lbuf, scr, lscr,
254
$ dens, wdens, frc_nuc,
255
$ frc_kin, frc_wgh, g_force,
256
$ g_dens, g_wdens, basis, geom, nproc, nat,
256
$ dens, frc_cos_nucq, frc_cos_elq,
258
$ g_dens, basis, geom, nproc, nat,
257
259
$ max_at_bf, rtdb, oskel )
258
c$Id: grad1.F 19708 2010-10-29 18:04:21Z d3y133 $
260
c$Id: grad1.F 23020 2012-10-30 01:03:15Z d3y133 $
260
C one electron contribution to RHF, ROHF and UHF gradients
262
C COSMO one electron contribution to RHF, ROHF and UHF gradients
263
C now also UMP2 ??? unlikely as that requires solutions to the
266
c Terms included in this subroutine are:
267
c 1. Electron - COSMO charge interactions
268
c 2. Nuclear - COSMO charge interactions
269
c 3. COSMO charge - COSMO charge interactions
271
c Terms NOT included are:
272
c 1. All regular QM derivatives
276
#include "nwc_const.fh"
265
277
#include "mafdecls.fh"
278
#include "errquit.fh"
266
279
#include "global.fh"
267
281
#include "geom.fh"
268
283
#include "bas.fh"
269
284
#include "rtdb.fh"
270
285
#include "sym.fh"
271
286
#include "stdio.fh"
273
289
C-------------------------parameters--------------------------------
275
$ g_dens, ! density matrix (summed if ROHF, UHF)
276
$ g_wdens, ! weighted density (Lagrangian)
277
$ g_force, ! global force array
278
$ basis, geom, nproc, nat, max_at_bf, rtdb
280
double precision H, ! integral derivatives
282
$ dens, ! local density block
283
$ wdens, ! local weighted density block
284
$ frc_nuc, frc_kin, frc_wgh ! forces arrays
286
dimension H ( lbuf ), frc_nuc(3, nat), frc_kin(3, nat),
287
$ frc_wgh(3, nat), scr(lscr),
288
$ dens(max_at_bf,max_at_bf), wdens(max_at_bf,max_at_bf)
290
integer g_dens !< [Input] the total electron density matrix GA
291
integer basis !< [Input] the basis set handle
292
integer geom !< [Input] the geometry handle
293
integer rtdb !< [Input] the RTDB handle
294
integer lbuf !< [Input] the length of the integral buffer
295
integer lscr, !< [Input] the length of the scratch space
296
$ nproc, nat, max_at_bf
298
double precision frc_cos_nucq(3,nat) !< [Output] the forces due
299
!< nuclear-COSMO charge
301
double precision frc_cos_elq(3,nat) !< [Output] the forces due
302
!< electron-COSMO charge
304
double precision frc_cos_qq(3,nat) !< [Output] the forces due
305
!< COSMO charge-COSMO charge
307
double precision H(lbuf) !< [Scratch] the derivative integrals
308
double precision scr(lscr) !< [Scratch] scratch space
309
double precision dens(max_at_bf,max_at_bf) !< [Scratch] local
290
312
logical oskel ! symmetry?
314
double precision dielec, screen, rsolv
315
common/hnd_cospar/dielec, screen ,rsolv
292
317
C-------------------------local variables--------------------------
295
320
$ iab1f, iab1l, iab2f, iab2l, iac1f, iac1l, iac2f, iac2l,
296
321
$ if1, il1, if2, il2,
297
322
$ icart, ic, nint, ip1, ip2
299
double precision dE, qfac
323
integer im1, im2, nprim, ngen, sphcart, ityp1, ityp2
326
integer nefc ! the number of COSMO charges
327
integer l_efciat ! the handle of the COSMO charge-atom map
328
integer k_efciat ! the index of the COSMO charge-atom map
329
integer nefcl ! the number of COSMO charge for a given atom
330
integer iefc ! counter over COSMO charges
331
integer iefc_c ! memory index for COSMO charge coordinates
332
integer iefc_q ! memory index for COSMO charges
334
double precision dE, qfac, fact, dx, dy, dz, rr
335
double precision invscreen
301
337
logical status, pointforce
316
352
status = rtdb_parallel(.true.) ! Broadcast reads to all processes
318
354
pointforce = geom_include_bqbq(geom)
355
if (.not.bq_create('cosmo efc bq',cosmo_bq_efc))
356
$ call errquit("grad_hnd_cos: bq_create on cosmo failed",
358
if (.not.bq_rtdb_load(rtdb,cosmo_bq_efc))
359
$ call errquit('grad_hnd_cos: rtdb load failed for Bq',916,
361
if (.not.bq_ncenter(cosmo_bq_efc,nefc))
362
$ call errquit('grad_hnd_cos: could not retrieve nefc',917,
364
if (.not.bq_index_coord(cosmo_bq_efc,iefc_c))
365
$ call errquit('grad_hnd_cos: could not get coordinate index Bq',
366
$ cosmo_bq_efc,MA_ERR)
367
if (.not.bq_index_charge(cosmo_bq_efc,iefc_q))
368
$ call errquit('grad_hnd_cos: could not get charge index Bq',
369
$ cosmo_bq_efc,MA_ERR)
371
if (.not.ma_push_get(MT_INT,nefc,"efciat",l_efciat,k_efciat))
372
$ call errquit("grad_hnd_cos: could not allocate efciat",
373
$ ma_sizeof(MT_BYTE,nefc,MT_INT),MA_ERR)
374
if(.not.rtdb_get(rtdb,'cosmo:efciat',mt_int,nefc,
376
$ call errquit('grad_hnd_cos: rtdb get failed for iatefc',915,
320
379
call hf_print_set(1)
347
407
status = bas_ce2cnr(basis,iat1,iac1f,iac1l)
348
408
status = bas_ce2cnr(basis,iat2,iac2f,iac2l)
350
410
call ga_get (g_dens, iab1f,iab1l,iab2f,iab2l,dens,max_at_bf)
351
call ga_get(g_wdens,iab1f,iab1l,iab2f,iab2l,wdens,max_at_bf)
353
412
do 70, ish1 = iac1f, iac1l
354
413
if ( iat1.eq.iat2 ) iac2l = ish1
358
417
status = bas_cn2bfr(basis,ish1,if1,il1)
359
418
if1 = if1 - iab1f + 1
360
419
il1 = il1 - iab1f + 1
421
c Work out the number of Cartesian basis functions
422
c The integrals are evaluated in the Cartesian basis set
423
c and then transformed to spherical harmonics. So the
424
c buffer size depends on the number of Cartesian functions
426
status = bas_continfo(basis,ish1,ityp1,nprim,ngen,
428
if (sphcart.eq.1.and.ityp1.ge.2) then
429
im1 = if1 + (ityp1+1)*(ityp1+2)/2 - 1
361
433
status = bas_cn2bfr(basis,ish2,if2,il2)
362
434
if2 = if2 - iab2f + 1
363
435
il2 = il2 - iab2f + 1
365
nint = ( il1 - if1 + 1 ) * ( il2 - if2 + 1 )
437
c Same Cartesian vs spherical harmonic catastrophy as
440
status = bas_continfo(basis,ish2,ityp2,nprim,ngen,
442
if (sphcart.eq.1.and.ityp2.ge.2) then
443
im2 = if2 + (ityp2+1)*(ityp2+2)/2 - 1
448
nint = ( im1 - if1 + 1 ) * ( im2 - if2 + 1 )
453
do iat3 = 1, 3 ! centers A, B, and C
464
C 1el. -cosmo- derivatives
465
c Currently calculated on for every COSMO charge
467
call intd_1epot_cosmo(basis,ish1,basis,ish2,lscr,scr,
468
& lbuf,H,dbl_mb(iefc_c+3*(iefc-1)),
469
& dbl_mb(iefc_q+iefc-1),1)
473
c Do center A (associated with ish1)
480
dE = dE + dens(ip1,ip2) * H(ic)
484
if ( iat1.ne.iat2 .or. ish1.ne.ish2 ) dE = dE + dE
486
frc_cos_elq(icart,iat1)
487
& = frc_cos_elq(icart,iat1) - dE
490
c Do center B (associated with ish2)
496
dE = dE + dens(ip1,ip2) * H(ic)
500
if ( iat1.ne.iat2 .or. ish1.ne.ish2 ) then
506
frc_cos_elq(icart,iat2)
507
& = frc_cos_elq(icart,iat2) - dE
510
c Do center C, i.e. the Cosmo charge (associated with
511
c the atom stored in int_mb(k_efciat))
517
dE = dE + dens(ip1,ip2) * H(ic)
521
if ( iat1.ne.iat2 .or. ish1.ne.ish2 ) dE = dE + dE
523
frc_cos_elq(icart,int_mb(k_efciat+iefc-1))
524
& = frc_cos_elq(icart,int_mb(k_efciat+iefc-1)) - dE
379
C 1el. -cosmo- derivatives
380
c- call intd_1eh1(basis,ish1,basis,ish2,lscr,scr,
389
do 31, ip1 = if1, il1
390
do 30, ip2 = if2, il2
391
dE = dE + dens(ip1,ip2) * H(ic)
395
if ( iat1.ne.iat2 .or. ish1.ne.ish2 ) dE = dE + dE
397
frc_kin(icart,iat3) = frc_kin(icart,iat3) + dE
411
539
next = nxtask(-nproc,task_size)
541
if (ga_nodeid().eq.0) then
543
c Do the Nuclear - Cosmo charge part
547
dx = coords(1,iat1,geom) - dbl_mb(0+3*(ich1-1)+iefc_c)
548
dy = coords(2,iat1,geom) - dbl_mb(1+3*(ich1-1)+iefc_c)
549
dz = coords(3,iat1,geom) - dbl_mb(2+3*(ich1-1)+iefc_c)
550
fact = -charge(iat1,geom)*dbl_mb(iefc_q+ich1-1) /
551
$ sqrt(dx*dx+dy*dy+dz*dz)**3
553
frc_cos_nucq(1,iat1) = frc_cos_nucq(1,iat1) + dE
554
frc_cos_nucq(1,int_mb(k_efciat+ich1-1))
555
$ = frc_cos_nucq(1,int_mb(k_efciat+ich1-1)) - dE
557
frc_cos_nucq(2,iat1) = frc_cos_nucq(2,iat1) + dE
558
frc_cos_nucq(2,int_mb(k_efciat+ich1-1))
559
$ = frc_cos_nucq(2,int_mb(k_efciat+ich1-1)) - dE
561
frc_cos_nucq(3,iat1) = frc_cos_nucq(3,iat1) + dE
562
frc_cos_nucq(3,int_mb(k_efciat+ich1-1))
563
$ = frc_cos_nucq(3,int_mb(k_efciat+ich1-1)) - dE
567
c Do cosmo charge - cosmo charge interaction
569
invscreen = 1.0d0/(1.0d0*screen)
572
if (ich1.ne.ich2) then
573
dx = dbl_mb(0+3*(ich1-1)+iefc_c)
574
$ - dbl_mb(0+3*(ich2-1)+iefc_c)
575
dy = dbl_mb(1+3*(ich1-1)+iefc_c)
576
$ - dbl_mb(1+3*(ich2-1)+iefc_c)
577
dz = dbl_mb(2+3*(ich1-1)+iefc_c)
578
$ - dbl_mb(2+3*(ich2-1)+iefc_c)
579
rr = sqrt(dx*dx+dy*dy+dz*dz)
580
if (rr.lt.1.0d-10) then
583
fact = -invscreen*dbl_mb(iefc_q+ich1-1)
584
$ * dbl_mb(iefc_q+ich2-1) /
588
frc_cos_qq(1,int_mb(k_efciat+ich1-1))
589
$ = frc_cos_qq(1,int_mb(k_efciat+ich1-1)) + dE
590
frc_cos_qq(1,int_mb(k_efciat+ich2-1))
591
$ = frc_cos_qq(1,int_mb(k_efciat+ich2-1)) - dE
593
frc_cos_qq(2,int_mb(k_efciat+ich1-1))
594
$ = frc_cos_qq(2,int_mb(k_efciat+ich1-1)) + dE
595
frc_cos_qq(2,int_mb(k_efciat+ich2-1))
596
$ = frc_cos_qq(2,int_mb(k_efciat+ich2-1)) - dE
598
frc_cos_qq(3,int_mb(k_efciat+ich1-1))
599
$ = frc_cos_qq(3,int_mb(k_efciat+ich1-1)) + dE
600
frc_cos_qq(3,int_mb(k_efciat+ich2-1))
601
$ = frc_cos_qq(3,int_mb(k_efciat+ich2-1)) - dE
607
if (.not.ma_pop_stack(l_efciat))
608
$ call errquit("grad_hnd_cos: could not deallocate l_efciat",
610
if (.not.bq_destroy(cosmo_bq_efc))
611
$ call errquit("grad_hnd_cos: bq_destroy on cosmo failed",