forked from TinkerTools/tinker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesolv.f
1972 lines (1972 loc) · 62.5 KB
/
esolv.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
c
c
c ################################################################
c ## COPYRIGHT (C) 1993 by Jay William Ponder ##
c ## COPYRIGHT (C) 2006 by Michael Schnieders & Jay W. Ponder ##
c ## All Rights Reserved ##
c ################################################################
c
c #################################################################
c ## ##
c ## subroutine esolv -- implicit solvation potential energy ##
c ## ##
c #################################################################
c
c
c "esolv" calculates the implicit solvation energy for surface area,
c generalized Born, generalized Kirkwood and Poisson-Boltzmann
c solvation models
c
c
subroutine esolv
use atoms
use energi
use limits
use math
use potent
use solpot
use solute
use warp
implicit none
integer i
real*8 e,ai,ri,rb
real*8 term,probe
real*8 esurf,ehp,eace
real*8 ecav,edisp
real*8, allocatable :: aes(:)
c
c
c zero out the implicit solvation energy components
c
es = 0.0d0
esurf = 0.0d0
ecav = 0.0d0
edisp = 0.0d0
ehp = 0.0d0
eace = 0.0d0
c
c set a value for the solvent molecule probe radius
c
probe = 1.4d0
c
c perform dynamic allocation of some local arrays
c
allocate (aes(n))
c
c total solvation energy for surface area only models
c
if (solvtyp.eq.'ASP' .or. solvtyp.eq.'SASA') then
call surface (es,aes,rsolv,asolv,probe)
c
c nonpolar energy as hydrophobic potential of mean force
c
else if (solvtyp.eq.'GB-HPMF' .or. solvtyp.eq.'GK-HPMF'
& .or. solvtyp.eq.'PB-HPMF') then
call ehpmf (ehp)
es = ehp
c
c nonpolar energy for Onion GB method via exact area
c
else if (solvtyp.eq.'GB' .and. borntyp.eq.'ONION') then
call surface (esurf,aes,rsolv,asolv,probe)
es = esurf
c
c nonpolar energy as cavity formation plus dispersion
c
else if (solvtyp.eq.'GK' .or. solvtyp.eq.'PB') then
call enp (ecav,edisp)
es = ecav + edisp
c
c nonpolar energy for GB via ACE surface area approximation
c
else
term = 4.0d0 * pi
do i = 1, n
ai = asolv(i)
ri = rsolv(i)
rb = rborn(i)
if (rb .ne. 0.0d0) then
e = ai * term * (ri+probe)**2 * (ri/rb)**6
eace = eace + e
end if
end do
es = eace
end if
c
c perform deallocation of some local arrays
c
deallocate (aes)
c
c get polarization energy term for the solvation methods
c
if (solvtyp(1:2) .eq. 'GK') then
if (.not.use_mpole .and. .not.use_polar) then
call chkpole
call rotpole
call induce
end if
call egk
else if (solvtyp(1:2) .eq. 'PB') then
call epb
else if (use_born) then
if (use_smooth) then
call egb0c
else if (use_clist) then
call egb0b
else
call egb0a
end if
end if
return
end
c
c
c #############################################################
c ## ##
c ## subroutine egb0a -- GB polarization via double loop ##
c ## ##
c #############################################################
c
c
c "egb0a" calculates the generalized Born polarization energy
c for the GB/SA solvation models using a pairwise double loop
c
c
subroutine egb0a
use atoms
use charge
use chgpot
use energi
use group
use shunt
use solute
use usage
implicit none
integer i,k,ii,kk
real*8 e,f,fi,fik
real*8 dwater,fgrp
real*8 rb2,rm2,fgb,fgm
real*8 xi,yi,zi
real*8 xr,yr,zr
real*8 r,r2,r3,r4
real*8 r5,r6,r7
real*8 shift,taper,trans
logical proceed,usei
character*6 mode
c
c
c set the solvent dielectric and energy conversion factor
c
if (nion .eq. 0) return
dwater = 78.3d0
f = -electric * (1.0d0 - 1.0d0/dwater)
c
c set cutoff distances and switching function coefficients
c
mode = 'CHARGE'
call switch (mode)
c
c OpenMP directives for the major loop structure
c
!$OMP PARALLEL default(private) shared(nion,iion,use,x,y,z,f,
!$OMP& pchg,rborn,use_group,off,off2,cut,cut2,c0,c1,c2,c3,c4,c5,
!$OMP& f0,f1,f2,f3,f4,f5,f6,f7)
!$OMP& shared(es)
!$OMP DO reduction(+:es) schedule(guided)
c
c calculate GB electrostatic polarization energy term
c
do ii = 1, nion
i = iion(ii)
usei = use(i)
xi = x(i)
yi = y(i)
zi = z(i)
fi = f * pchg(ii)
c
c decide whether to compute the current interaction
c
do kk = ii, nion
k = iion(kk)
proceed = .true.
if (use_group) call groups (proceed,fgrp,i,k,0,0,0,0)
if (proceed) proceed = (usei .or. use(k))
c
c compute the energy contribution for this interaction
c
if (proceed) then
xr = xi - x(k)
yr = yi - y(k)
zr = zi - z(k)
r2 = xr*xr + yr*yr + zr*zr
if (r2 .le. off2) then
fik = fi * pchg(kk)
rb2 = rborn(i) * rborn(k)
fgb = sqrt(r2 + rb2*exp(-0.25d0*r2/rb2))
e = fik / fgb
c
c use shifted energy switching if near the cutoff distance
c
rm2 = (0.5d0 * (off+cut))**2
fgm = sqrt(rm2 + rb2*exp(-0.25d0*rm2/rb2))
shift = fik / fgm
e = e - shift
if (r2 .gt. cut2) then
r = sqrt(r2)
r3 = r2 * r
r4 = r2 * r2
r5 = r2 * r3
r6 = r3 * r3
r7 = r3 * r4
taper = c5*r5 + c4*r4 + c3*r3
& + c2*r2 + c1*r + c0
trans = fik * (f7*r7 + f6*r6 + f5*r5 + f4*r4
& + f3*r3 + f2*r2 + f1*r + f0)
e = e*taper + trans
end if
c
c scale the interaction based on its group membership
c
if (use_group) e = e * fgrp
c
c increment the overall GB solvation energy component
c
if (i .eq. k) e = 0.5d0 * e
es = es + e
end if
end if
end do
end do
c
c OpenMP directives for the major loop structure
c
!$OMP END DO
!$OMP END PARALLEL
return
end
c
c
c ###############################################################
c ## ##
c ## subroutine egb0b -- GB polarization via neighbor list ##
c ## ##
c ###############################################################
c
c
c "egb0b" calculates the generalized Born polarization energy
c for the GB/SA solvation models using a pairwise neighbor list
c
c
subroutine egb0b
use atoms
use charge
use chgpot
use energi
use group
use neigh
use shunt
use solute
use usage
implicit none
integer i,k
integer ii,kk,kkk
real*8 e,f,fi,fik
real*8 dwater,fgrp
real*8 rbi,rb2,rm2
real*8 fgb,fgm
real*8 xi,yi,zi
real*8 xr,yr,zr
real*8 r,r2,r3,r4
real*8 r5,r6,r7
real*8 shift,taper,trans
logical proceed,usei
character*6 mode
c
c
c set the solvent dielectric and energy conversion factor
c
if (nion .eq. 0) return
dwater = 78.3d0
f = -electric * (1.0d0 - 1.0d0/dwater)
c
c set cutoff distances and switching function coefficients
c
mode = 'CHARGE'
call switch (mode)
c
c OpenMP directives for the major loop structure
c
!$OMP PARALLEL default(private) shared(nion,iion,use,x,y,z,
!$OMP& f,pchg,rborn,nelst,elst,use_group,off,off2,cut,cut2,
!$OMP& c0,c1,c2,c3,c4,c5,f0,f1,f2,f3,f4,f5,f6,f7)
!$OMP& shared(es)
!$OMP DO reduction(+:es) schedule(guided)
c
c calculate GB electrostatic polarization energy term
c
do ii = 1, nion
i = iion(ii)
usei = use(i)
xi = x(i)
yi = y(i)
zi = z(i)
fi = f * pchg(ii)
rbi = rborn(i)
c
c calculate the self-energy term for the current atom
c
fik = fi * pchg(ii)
rb2 = rbi * rbi
e = fik / rbi
rm2 = (0.5d0 * (off+cut))**2
fgm = sqrt(rm2 + rb2*exp(-0.25d0*rm2/rb2))
shift = fik / fgm
e = e - shift
es = es + 0.5d0*e
c
c decide whether to compute the current interaction
c
do kkk = 1, nelst(ii)
kk = elst(kkk,ii)
k = iion(kk)
proceed = .true.
if (use_group) call groups (proceed,fgrp,i,k,0,0,0,0)
if (proceed) proceed = (usei .or. use(k))
c
c compute the energy contribution for this interaction
c
if (proceed) then
xr = xi - x(k)
yr = yi - y(k)
zr = zi - z(k)
r2 = xr*xr + yr*yr + zr*zr
if (r2 .le. off2) then
fik = fi * pchg(kk)
rb2 = rbi * rborn(k)
fgb = sqrt(r2 + rb2*exp(-0.25d0*r2/rb2))
e = fik / fgb
c
c use shifted energy switching if near the cutoff distance
c
rm2 = (0.5d0 * (off+cut))**2
fgm = sqrt(rm2 + rb2*exp(-0.25d0*rm2/rb2))
shift = fik / fgm
e = e - shift
if (r2 .gt. cut2) then
r = sqrt(r2)
r3 = r2 * r
r4 = r2 * r2
r5 = r2 * r3
r6 = r3 * r3
r7 = r3 * r4
taper = c5*r5 + c4*r4 + c3*r3
& + c2*r2 + c1*r + c0
trans = fik * (f7*r7 + f6*r6 + f5*r5 + f4*r4
& + f3*r3 + f2*r2 + f1*r + f0)
e = e*taper + trans
end if
c
c scale the interaction based on its group membership
c
if (use_group) e = e * fgrp
c
c increment the overall GB solvation energy component
c
es = es + e
end if
end if
end do
end do
c
c OpenMP directives for the major loop structure
c
!$OMP END DO
!$OMP END PARALLEL
return
end
c
c
c ##################################################################
c ## ##
c ## subroutine egb0c -- GB polarization energy for smoothing ##
c ## ##
c ##################################################################
c
c
c "egb0c" calculates the generalized Born polarization energy
c for the GB/SA solvation models for use with potential smoothing
c methods via analogy to the smoothing of Coulomb's law
c
c
subroutine egb0c
use atoms
use charge
use chgpot
use energi
use group
use solute
use usage
use warp
implicit none
integer i,k,ii,kk
real*8 e,fgrp
real*8 f,fi,fik
real*8 xi,yi,zi
real*8 xr,yr,zr
real*8 dwater,width
real*8 erf,sterm
real*8 r2,fgb,rb2
logical proceed,usei
external erf
c
c
c set the solvent dielectric and energy conversion factor
c
if (nion .eq. 0) return
dwater = 78.3d0
f = -electric * (1.0d0 - 1.0d0/dwater)
c
c set the extent of smoothing to be performed
c
sterm = 0.5d0 / sqrt(diffc)
c
c calculate GB electrostatic polarization energy term
c
do ii = 1, nion
i = iion(ii)
usei = use(i)
xi = x(i)
yi = y(i)
zi = z(i)
fi = f * pchg(ii)
c
c decide whether to compute the current interaction
c
do kk = ii, nion
k = iion(kk)
proceed = .true.
if (use_group) call groups (proceed,fgrp,i,k,0,0,0,0)
if (proceed) proceed = (usei .or. use(k))
c
c compute the energy contribution for this interaction
c
if (proceed) then
xr = xi - x(k)
yr = yi - y(k)
zr = zi - z(k)
r2 = xr*xr + yr*yr + zr*zr
fik = fi * pchg(kk)
rb2 = rborn(i) * rborn(k)
fgb = sqrt(r2 + rb2*exp(-0.25d0*r2/rb2))
e = fik / fgb
c
c use a smoothable GB analogous to Coulomb's law solution
c
if (deform .gt. 0.0d0) then
width = deform + 0.15d0*rb2*exp(-0.006d0*rb2/deform)
width = sterm / sqrt(width)
e = e * erf(width*fgb)
end if
c
c scale the interaction based on its group membership
c
if (use_group) e = e * fgrp
c
c increment the overall GB solvation energy component
c
if (i .eq. k) e = 0.5d0 * e
es = es + e
end if
end do
end do
return
end
c
c
c ################################################################
c ## ##
c ## subroutine egk -- generalized Kirkwood solvation model ##
c ## ##
c ################################################################
c
c
c "egk" calculates the generalized Kirkwood electrostatic
c solvation free energy for the GK/NP implicit solvation model
c
c
subroutine egk
use potent
implicit none
c
c
c setup the multipoles for solvation only calculations
c
if (.not. use_mpole) then
call chkpole
call rotpole
end if
if (.not. use_polar) then
call induce
end if
c
c compute the generalized Kirkwood electrostatic energy
c
call egk0a
c
c correct solvation energy for vacuum to polarized state
c
if (use_polar) then
call ediff
end if
return
end
c
c
c ##############################################################
c ## ##
c ## subroutine egk0a -- find generalized Kirkwood energy ##
c ## ##
c ##############################################################
c
c
c "egk0a" calculates the electrostatic portion of the implicit
c solvation energy via the generalized Kirkwood model
c
c
subroutine egk0a
use atoms
use chgpot
use energi
use gkstuf
use group
use mpole
use polar
use shunt
use solute
use usage
implicit none
integer i,k,ii,kk
real*8 e,ei
real*8 fc,fd,fq
real*8 dwater,fgrp
real*8 r2,rb2
real*8 xi,yi,zi
real*8 xr,yr,zr
real*8 xr2,yr2,zr2
real*8 ci,ck
real*8 uxi,uyi,uzi
real*8 uxk,uyk,uzk
real*8 dxi,dyi,dzi
real*8 dxk,dyk,dzk
real*8 qxxi,qxyi,qxzi
real*8 qyyi,qyzi,qzzi
real*8 qxxk,qxyk,qxzk
real*8 qyyk,qyzk,qzzk
real*8 rbi,rbk
real*8 expterm
real*8 gf,gf2,gf3
real*8 gf5,gf7,gf9
real*8 expc,dexpc
real*8 expc1,expcdexpc
real*8 esym,ewi,ewk
real*8 esymi,ewii,ewki
real*8 a(0:4,0:2)
real*8 gc(10),gux(10)
real*8 guy(10),guz(10)
real*8 gqxx(10),gqxy(10)
real*8 gqxz(10),gqyy(10)
real*8 gqyz(10),gqzz(10)
logical proceed,usei
character*6 mode
c
c
c set the bulk dielectric constant to the water value
c
if (npole .eq. 0) return
dwater = 78.3d0
fc = electric * 1.0d0 * (1.0d0-dwater)/(0.0d0+1.0d0*dwater)
fd = electric * 2.0d0 * (1.0d0-dwater)/(1.0d0+2.0d0*dwater)
fq = electric * 3.0d0 * (1.0d0-dwater)/(2.0d0+3.0d0*dwater)
c
c set cutoff distances and switching function coefficients
c
mode = 'MPOLE'
call switch (mode)
c
c OpenMP directives for the major loop structure
c
!$OMP PARALLEL default(private) shared(npole,ipole,use,x,y,z,
!$OMP& rborn,rpole,uinds,use_group,off2,gkc,fc,fd,fq)
!$OMP& shared(es)
!$OMP DO reduction(+:es) schedule(guided)
c
c calculate GK electrostatic solvation free energy
c
do ii = 1, npole
i = ipole(ii)
usei = use(i)
xi = x(i)
yi = y(i)
zi = z(i)
rbi = rborn(i)
ci = rpole(1,ii)
uxi = rpole(2,ii)
uyi = rpole(3,ii)
uzi = rpole(4,ii)
qxxi = rpole(5,ii)
qxyi = rpole(6,ii)
qxzi = rpole(7,ii)
qyyi = rpole(9,ii)
qyzi = rpole(10,ii)
qzzi = rpole(13,ii)
dxi = uinds(1,ii)
dyi = uinds(2,ii)
dzi = uinds(3,ii)
c
c decide whether to compute the current interaction
c
do kk = ii, npole
k = ipole(kk)
proceed = .true.
if (use_group) call groups (proceed,fgrp,i,k,0,0,0,0)
if (proceed) proceed = (usei .or. use(k))
c
c compute the energy contribution for this interaction
c
if (proceed) then
xr = x(k) - xi
yr = y(k) - yi
zr = z(k) - zi
xr2 = xr * xr
yr2 = yr * yr
zr2 = zr * zr
r2 = xr2 + yr2 + zr2
if (r2 .le. off2) then
rbk = rborn(k)
ck = rpole(1,kk)
uxk = rpole(2,kk)
uyk = rpole(3,kk)
uzk = rpole(4,kk)
qxxk = rpole(5,kk)
qxyk = rpole(6,kk)
qxzk = rpole(7,kk)
qyyk = rpole(9,kk)
qyzk = rpole(10,kk)
qzzk = rpole(13,kk)
dxk = uinds(1,kk)
dyk = uinds(2,kk)
dzk = uinds(3,kk)
rb2 = rbi * rbk
expterm = exp(-r2/(gkc*rb2))
expc = expterm / gkc
dexpc = -2.0d0 / (gkc*rbi*rbk)
gf2 = 1.0d0 / (r2 + rb2*expterm)
gf = sqrt(gf2)
gf3 = gf2 * gf
gf5 = gf3 * gf2
gf7 = gf5 * gf2
gf9 = gf7 * gf2
c
c reaction potential auxiliary terms
c
a(0,0) = gf
a(1,0) = -gf3
a(2,0) = 3.0d0 * gf5
a(3,0) = -15.0d0 * gf7
a(4,0) = 105.0d0 * gf9
c
c reaction potential gradient auxiliary terms
c
expc1 = 1.0d0 - expc
a(0,1) = expc1 * a(1,0)
a(1,1) = expc1 * a(2,0)
a(2,1) = expc1 * a(3,0)
a(3,1) = expc1 * a(4,0)
c
c second reaction potential gradient auxiliary terms
c
expcdexpc = -expc * dexpc
a(0,2) = expc1*a(1,1) + expcdexpc*a(1,0)
a(1,2) = expc1*a(2,1) + expcdexpc*a(2,0)
a(2,2) = expc1*a(3,1) + expcdexpc*a(3,0)
c
c multiply the auxillary terms by their dieletric functions
c
a(0,0) = fc * a(0,0)
a(0,1) = fc * a(0,1)
a(0,2) = fc * a(0,2)
a(1,0) = fd * a(1,0)
a(1,1) = fd * a(1,1)
a(1,2) = fd * a(1,2)
a(2,0) = fq * a(2,0)
a(2,1) = fq * a(2,1)
a(2,2) = fq * a(2,2)
c
c unweighted reaction potential tensor
c
gc(1) = a(0,0)
gux(1) = xr * a(1,0)
guy(1) = yr * a(1,0)
guz(1) = zr * a(1,0)
gqxx(1) = xr2 * a(2,0)
gqyy(1) = yr2 * a(2,0)
gqzz(1) = zr2 * a(2,0)
gqxy(1) = xr * yr * a(2,0)
gqxz(1) = xr * zr * a(2,0)
gqyz(1) = yr * zr * a(2,0)
c
c unweighted reaction potential gradient tensor
c
gc(2) = xr * a(0,1)
gc(3) = yr * a(0,1)
gc(4) = zr * a(0,1)
gux(2) = a(1,0) + xr2*a(1,1)
gux(3) = xr * yr * a(1,1)
gux(4) = xr * zr * a(1,1)
guy(2) = gux(3)
guy(3) = a(1,0) + yr2*a(1,1)
guy(4) = yr * zr * a(1,1)
guz(2) = gux(4)
guz(3) = guy(4)
guz(4) = a(1,0) + zr2*a(1,1)
gqxx(2) = xr * (2.0d0*a(2,0)+xr2*a(2,1))
gqxx(3) = yr * xr2 * a(2,1)
gqxx(4) = zr * xr2 * a(2,1)
gqyy(2) = xr * yr2 * a(2,1)
gqyy(3) = yr * (2.0d0*a(2,0)+yr2*a(2,1))
gqyy(4) = zr * yr2 * a(2,1)
gqzz(2) = xr * zr2 * a(2,1)
gqzz(3) = yr * zr2 * a(2,1)
gqzz(4) = zr * (2.0d0*a(2,0)+zr2*a(2,1))
gqxy(2) = yr * (a(2,0)+xr2*a(2,1))
gqxy(3) = xr * (a(2,0)+yr2*a(2,1))
gqxy(4) = zr * xr * yr * a(2,1)
gqxz(2) = zr * (a(2,0)+xr2*a(2,1))
gqxz(3) = gqxy(4)
gqxz(4) = xr * (a(2,0)+zr2*a(2,1))
gqyz(2) = gqxy(4)
gqyz(3) = zr * (a(2,0)+yr2*a(2,1))
gqyz(4) = yr * (a(2,0)+zr2*a(2,1))
c
c unweighted second reaction potential gradient tensor
c
gc(5) = a(0,1) + xr2*a(0,2)
gc(6) = xr * yr * a(0,2)
gc(7) = xr * zr * a(0,2)
gc(8) = a(0,1) + yr2*a(0,2)
gc(9) = yr * zr * a(0,2)
gc(10) = a(0,1) + zr2*a(0,2)
gux(5) = xr * (a(1,1)+2.0d0*a(1,1)+xr2*a(1,2))
gux(6) = yr * (a(1,1)+xr2*a(1,2))
gux(7) = zr * (a(1,1)+xr2*a(1,2))
gux(8) = xr * (a(1,1)+yr2*a(1,2))
gux(9) = zr * xr * yr * a(1,2)
gux(10) = xr * (a(1,1)+zr2*a(1,2))
guy(5) = yr * (a(1,1)+xr2*a(1,2))
guy(6) = xr * (a(1,1)+yr2*a(1,2))
guy(7) = gux(9)
guy(8) = yr * (a(1,1)+2.0d0*a(1,1)+yr2*a(1,2))
guy(9) = zr * (a(1,1)+yr2*a(1,2))
guy(10) = yr * (a(1,1)+zr2*a(1,2))
guz(5) = zr * (a(1,1)+xr2*a(1,2))
guz(6) = gux(9)
guz(7) = xr * (a(1,1)+zr2*a(1,2))
guz(8) = zr * (a(1,1)+yr2*a(1,2))
guz(9) = yr * (a(1,1)+zr2*a(1,2))
guz(10) = zr * (a(1,1)+2.0d0*a(1,1)+zr2*a(1,2))
gqxx(5) = 2.0d0*a(2,0) + xr2*(5.0d0*a(2,1)+xr2*a(2,2))
gqxx(6) = yr * xr *(2.0d0*a(2,1)+xr2*a(2,2))
gqxx(7) = zr * xr *(2.0d0*a(2,1)+xr2*a(2,2))
gqxx(8) = xr2 * (a(2,1)+yr2*a(2,2))
gqxx(9) = zr * yr * xr2 * a(2,2)
gqxx(10) = xr2 * (a(2,1)+zr2*a(2,2))
gqyy(5) = yr2 * (a(2,1)+xr2*a(2,2))
gqyy(6) = xr * yr * (2.0d0*a(2,1)+yr2*a(2,2))
gqyy(7) = xr * zr * yr2 * a(2,2)
gqyy(8) = 2.0d0*a(2,0) + yr2*(5.0d0*a(2,1)+yr2*a(2,2))
gqyy(9) = yr * zr * (2.0d0*a(2,1)+yr2*a(2,2))
gqyy(10) = yr2 * (a(2,1)+zr2*a(2,2))
gqzz(5) = zr2 * (a(2,1)+xr2*a(2,2))
gqzz(6) = xr * yr * zr2 * a(2,2)
gqzz(7) = xr * zr * (2.0d0*a(2,1)+zr2*a(2,2))
gqzz(8) = zr2 * (a(2,1)+yr2*a(2,2))
gqzz(9) = yr * zr * (2.0d0*a(2,1)+zr2*a(2,2))
gqzz(10) = 2.0d0*a(2,0)
& + zr2*(5.0d0*a(2,1)+zr2*a(2,2))
gqxy(5) = xr * yr * (3.0d0*a(2,1)+xr2*a(2,2))
gqxy(6) = a(2,0) + (xr2+yr2)*a(2,1) + xr2*yr2*a(2,2)
gqxy(7) = zr * yr * (a(2,1)+xr2*a(2,2))
gqxy(8) = xr * yr * (3.0d0*a(2,1)+yr2*a(2,2))
gqxy(9) = zr * xr * (a(2,1)+yr2*a(2,2))
gqxy(10) = xr * yr * (a(2,1)+zr2*a(2,2))
gqxz(5) = xr * zr * (3.0d0*a(2,1)+xr2*a(2,2))
gqxz(6) = yr * zr * (a(2,1)+xr2*a(2,2))
gqxz(7) = a(2,0) + (xr2+zr2)*a(2,1) + xr2*zr2*a(2,2)
gqxz(8) = xr * zr * (a(2,1)+yr2*a(2,2))
gqxz(9) = xr * yr * (a(2,1)+zr2*a(2,2))
gqxz(10) = xr * zr * (3.0d0*a(2,1)+zr2*a(2,2))
gqyz(5) = zr * yr * (a(2,1)+xr2*a(2,2))
gqyz(6) = xr * zr * (a(2,1)+yr2*a(2,2))
gqyz(7) = xr * yr * (a(2,1)+zr2*a(2,2))
gqyz(8) = yr * zr * (3.0d0*a(2,1)+yr2*a(2,2))
gqyz(9) = a(2,0) + (yr2+zr2)*a(2,1) + yr2*zr2*a(2,2)
gqyz(10) = yr * zr * (3.0d0*a(2,1)+zr2*a(2,2))
c
c electrostatic solvation free energy of the permanent multipoles
c in their own GK reaction potential
c
esym = ci*ck*gc(1)
& - uxi*(uxk*gux(2)+uyk*guy(2)+uzk*guz(2))
& - uyi*(uxk*gux(3)+uyk*guy(3)+uzk*guz(3))
& - uzi*(uxk*gux(4)+uyk*guy(4)+uzk*guz(4))
ewi = ci*(uxk*gc(2)+uyk*gc(3)+uzk*gc(4))
& - ck*(uxi*gux(1)+uyi*guy(1)+uzi*guz(1))
& + ci*(qxxk*gc(5)+qyyk*gc(8)+qzzk*gc(10)
& +2.0d0*(qxyk*gc(6)+qxzk*gc(7)+qyzk*gc(9)))
& + ck*(qxxi*gqxx(1)+qyyi*gqyy(1)+qzzi*gqzz(1)
& +2.0d0*(qxyi*gqxy(1)+qxzi*gqxz(1)+qyzi*gqyz(1)))
& - uxi*(qxxk*gux(5)+qyyk*gux(8)+qzzk*gux(10)
& +2.0d0*(qxyk*gux(6)+qxzk*gux(7)+qyzk*gux(9)))
& - uyi*(qxxk*guy(5)+qyyk*guy(8)+qzzk*guy(10)
& +2.0d0*(qxyk*guy(6)+qxzk*guy(7)+qyzk*guy(9)))
& - uzi*(qxxk*guz(5)+qyyk*guz(8)+qz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
& +2.0d0*(qxyk*gqxy(6)+qxzk*gqxz(6)+qyzk*gqyz(6)))
& + qxzi*(qxxk*gqxx(7)+qyyk*gqyy(7)+qzzk*gqzz(7)
& +2.0d0*(qxyk*gqxy(7)+qxzk*gqxz(7)+qyzk*gqyz(7)))
& + qyzi*(qxxk*gqxx(9)+qyyk*gqyy(9)+qzzk*gqzz(9)
& +2.0d0*(qxyk*gqxy(9)+qxzk*gqxz(9)+qyzk*gqyz(9))))
c
c electrostatic solvation free energy of the permenant multipoles
c in the GK reaction potential of the induced dipoles
c
esymi = -uxi*(dxk*gux(2)+dyk*guy(2)+dzk*guz(2))
& - uyi*(dxk*gux(3)+dyk*guy(3)+dzk*guz(3))
& - uzi*(dxk*gux(4)+dyk*guy(4)+dzk*guz(4))
& - uxk*(dxi*gux(2)+dyi*guy(2)+dzi*guz(2))
& - uyk*(dxi*gux(3)+dyi*guy(3)+dzi*guz(3))
& - uzk*(dxi*gux(4)+dyi*guy(4)+dzi*guz(4))
ewii = ci*(dxk*gc(2)+dyk*gc(3)+dzk*gc(4))
& - ck*(dxi*gux(1)+dyi*guy(1)+dzi*guz(1))
& - dxi*(qxxk*gux(5)+qyyk*gux(8)+qzzk*gux(10)
& +2.0d0*(qxyk*gux(6)+qxzk*gux(7)+qyzk*gux(9)))
& - dyi*(qxxk*guy(5)+qyyk*guy(8)+qzzk*guy(10)
& +2.0d0*(qxyk*guy(6)+qxzk*guy(7)+qyzk*guy(9)))
& - dzi*(qxxk*guz(5)+qyyk*guz(8)+qzzk*guz(10)
& +2.0d0*(qxyk*guz(6)+qxzk*guz(7)+qyzk*guz(9)))
& + dxk*(qxxi*gqxx(2)+qyyi*gqyy(2)+qzzi*gqzz(2)
& +2.0d0*(qxyi*gqxy(2)+qxzi*gqxz(2)+qyzi*gqyz(2)))
& + dyk*(qxxi*gqxx(3)+qyyi*gqyy(3)+qzzi*gqzz(3)
& +2.0d0*(qxyi*gqxy(3)+qxzi*gqxz(3)+qyzi*gqyz(3)))
& + dzk*(qxxi*gqxx(4)+qyyi*gqyy(4)+qzzi*gqzz(4)
& +2.0d0*(qxyi*gqxy(4)+qxzi*gqxz(4)+qyzi*gqyz(4)))
ewki = ci*(dxk*gux(1)+dyk*guy(1)+dzk*guz(1))
& - ck*(dxi*gc(2)+dyi*gc(3)+dzi*gc(4))
& - dxi*(qxxk*gqxx(2)+qyyk*gqyy(2)+qzzk*gqzz(2)
& +2.0d0*(qxyk*gqxy(2)+qxzk*gqxz(2)+qyzk*gqyz(2)))
& - dyi*(qxxk*gqxx(3)+qyyk*gqyy(3)+qzzk*gqzz(3)
& +2.0d0*(qxyk*gqxy(3)+qxzk*gqxz(3)+qyzk*gqyz(3)))
& - dzi*(qxxk*gqxx(4)+qyyk*gqyy(4)+qzzk*gqzz(4)
& +2.0d0*(qxyk*gqxy(4)+qxzk*gqxz(4)+qyzk*gqyz(4)))
& + dxk*(qxxi*gux(5)+qyyi*gux(8)+qzzi*gux(10)
& +2.0d0*(qxyi*gux(6)+qxzi*gux(7)+qyzi*gux(9)))
& + dyk*(qxxi*guy(5)+qyyi*guy(8)+qzzi*guy(10)
& +2.0d0*(qxyi*guy(6)+qxzi*guy(7)+qyzi*guy(9)))
& + dzk*(qxxi*guz(5)+qyyi*guz(8)+qzzi*guz(10)
& +2.0d0*(qxyi*guz(6)+qxzi*guz(7)+qyzi*guz(9)))
c
c total permanent and induced energies for this interaction
c
e = esym + 0.5d0*(ewi+ewk)
ei = 0.5d0 * (esymi + 0.5d0*(ewii+ewki))
c
c scale the interaction based on its group membership
c
if (use_group) then
e = e * fgrp
ei = ei * fgrp
end if
c
c increment the total GK electrostatic solvation energy
c
if (i .eq. k) then
e = 0.5d0 * e
ei = 0.5d0 * ei
end if
es = es + e + ei
end if
end if
end do
end do
c
c OpenMP directives for the major loop structure
c
!$OMP END DO
!$OMP END PARALLEL
return
end
c
c
c #############################################################
c ## ##
c ## subroutine epb -- Poisson-Boltzmann solvation model ##
c ## ##
c #############################################################
c
c
c "epb" calculates the implicit solvation energy via the
c Poisson-Boltzmann plus nonpolar implicit solvation
c
c
subroutine epb
use chgpot
use energi
use mpole
use pbstuf
use polar
use potent
implicit none
integer i,ii
real*8 etot
c
c
c compute the electrostatic energy via Poisson-Boltzmann
c
if (use_polar) then
etot = 0.0d0
do ii = 1, npole
i = ipole(ii)
etot = etot + uinds(1,ii)*pbep(1,i) + uinds(2,ii)*pbep(2,i)
& + uinds(3,ii)*pbep(3,i)
end do
etot = -0.5d0 * electric * etot
pbe = pbe + etot
else
call pbempole
end if
c
c increment solvation energy by Poisson-Boltzmann results
c
es = es + pbe
c
c correct the solvation energy for vacuum to polarized state
c
call ediff
return
end
c