1 C-----------------------------------------------------------------------
2 double precision function sscale(r)
3 double precision r,gamm
4 include "COMMON.SPLITELE"
5 if(r.lt.r_cut-rlamb) then
7 else if(r.le.r_cut.and.r.ge.r_cut-rlamb) then
8 gamm=(r-(r_cut-rlamb))/rlamb
9 sscale=1.0d0+gamm*gamm*(2*gamm-3.0d0)
15 C-----------------------------------------------------------------------
16 C-----------------------------------------------------------------------
17 double precision function sscagrad(r)
18 double precision r,gamm
19 include "COMMON.SPLITELE"
20 if(r.lt.r_cut-rlamb) then
22 else if(r.le.r_cut.and.r.ge.r_cut-rlamb) then
23 gamm=(r-(r_cut-rlamb))/rlamb
24 sscagrad=gamm*(6*gamm-6.0d0)/rlamb
30 C-----------------------------------------------------------------------
31 subroutine elj_long(evdw)
33 C This subroutine calculates the interaction energy of nonbonded side chains
34 C assuming the LJ potential of interaction.
36 implicit real*8 (a-h,o-z)
38 parameter (accur=1.0d-10)
41 include 'COMMON.LOCAL'
42 include 'COMMON.CHAIN'
43 include 'COMMON.DERIV'
44 include 'COMMON.INTERACT'
45 include 'COMMON.TORSION'
46 include 'COMMON.SBRIDGE'
47 include 'COMMON.NAMES'
48 include 'COMMON.IOUNITS'
49 include 'COMMON.CONTACTS'
51 c write(iout,*)'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
55 if (itypi.eq.ntyp1) cycle
61 C Calculate SC interaction energy.
64 cd write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
65 cd & 'iend=',iend(i,iint)
66 do j=istart(i,iint),iend(i,iint)
68 if (itypj.eq.ntyp1) cycle
73 sss=sscale(dsqrt(rij)/sigma(itypi,itypj))
74 if (sss.lt.1.0d0) then
76 eps0ij=eps(itypi,itypj)
78 e1=fac*fac*aa(itypi,itypj)
79 e2=fac*bb(itypi,itypj)
81 evdw=evdw+(1.0d0-sss)*evdwij
83 C Calculate the components of the gradient in DC and X
85 fac=-rrij*(e1+evdwij)*(1.0d0-sss)
90 gvdwx(k,i)=gvdwx(k,i)-gg(k)
91 gvdwx(k,j)=gvdwx(k,j)+gg(k)
92 gvdwc(k,i)=gvdwc(k,i)-gg(k)
93 gvdwc(k,j)=gvdwc(k,j)+gg(k)
101 gvdwc(j,i)=expon*gvdwc(j,i)
102 gvdwx(j,i)=expon*gvdwx(j,i)
105 C******************************************************************************
109 C To save time, the factor of EXPON has been extracted from ALL components
110 C of GVDWC and GRADX. Remember to multiply them by this factor before further
113 C******************************************************************************
116 C-----------------------------------------------------------------------
117 subroutine elj_short(evdw)
119 C This subroutine calculates the interaction energy of nonbonded side chains
120 C assuming the LJ potential of interaction.
122 implicit real*8 (a-h,o-z)
124 parameter (accur=1.0d-10)
127 include 'COMMON.LOCAL'
128 include 'COMMON.CHAIN'
129 include 'COMMON.DERIV'
130 include 'COMMON.INTERACT'
131 include 'COMMON.TORSION'
132 include 'COMMON.SBRIDGE'
133 include 'COMMON.NAMES'
134 include 'COMMON.IOUNITS'
135 include 'COMMON.CONTACTS'
137 c write(iout,*)'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
141 if (itypi.eq.ntyp1) cycle
149 C Calculate SC interaction energy.
152 cd write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
153 cd & 'iend=',iend(i,iint)
154 do j=istart(i,iint),iend(i,iint)
156 if (itypj.eq.ntyp1) cycle
160 C Change 12/1/95 to calculate four-body interactions
161 rij=xj*xj+yj*yj+zj*zj
162 sss=sscale(dsqrt(rij)/sigma(itypi,itypj))
163 if (sss.gt.0.0d0) then
165 eps0ij=eps(itypi,itypj)
167 e1=fac*fac*aa(itypi,itypj)
168 e2=fac*bb(itypi,itypj)
172 C Calculate the components of the gradient in DC and X
174 fac=-rrij*(e1+evdwij)*sss
179 gvdwx(k,i)=gvdwx(k,i)-gg(k)
180 gvdwx(k,j)=gvdwx(k,j)+gg(k)
181 gvdwc(k,i)=gvdwc(k,i)-gg(k)
182 gvdwc(k,j)=gvdwc(k,j)+gg(k)
190 gvdwc(j,i)=expon*gvdwc(j,i)
191 gvdwx(j,i)=expon*gvdwx(j,i)
194 C******************************************************************************
198 C To save time, the factor of EXPON has been extracted from ALL components
199 C of GVDWC and GRADX. Remember to multiply them by this factor before further
202 C******************************************************************************
205 C-----------------------------------------------------------------------------
206 subroutine eljk_long(evdw)
208 C This subroutine calculates the interaction energy of nonbonded side chains
209 C assuming the LJK potential of interaction.
211 implicit real*8 (a-h,o-z)
215 include 'COMMON.LOCAL'
216 include 'COMMON.CHAIN'
217 include 'COMMON.DERIV'
218 include 'COMMON.INTERACT'
219 include 'COMMON.IOUNITS'
220 include 'COMMON.NAMES'
223 c print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
227 if (itypi.eq.ntyp1) cycle
233 C Calculate SC interaction energy.
236 do j=istart(i,iint),iend(i,iint)
238 if (itypj.eq.ntyp1) cycle
242 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
244 e_augm=augm(itypi,itypj)*fac_augm
247 sss=sscale(rij/sigma(itypi,itypj))
248 if (sss.lt.1.0d0) then
249 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
250 fac=r_shift_inv**expon
251 e1=fac*fac*aa(itypi,itypj)
252 e2=fac*bb(itypi,itypj)
254 cd sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
255 cd epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
256 cd write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
257 cd & restyp(itypi),i,restyp(itypj),j,aa(itypi,itypj),
258 cd & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
259 cd & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
260 cd & (c(k,i),k=1,3),(c(k,j),k=1,3)
261 evdw=evdw+(1.0d0-sss)*evdwij
263 C Calculate the components of the gradient in DC and X
265 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
271 gvdwx(k,i)=gvdwx(k,i)-gg(k)
272 gvdwx(k,j)=gvdwx(k,j)+gg(k)
273 gvdwc(k,i)=gvdwc(k,i)-gg(k)
274 gvdwc(k,j)=gvdwc(k,j)+gg(k)
282 gvdwc(j,i)=expon*gvdwc(j,i)
283 gvdwx(j,i)=expon*gvdwx(j,i)
288 C-----------------------------------------------------------------------------
289 subroutine eljk_short(evdw)
291 C This subroutine calculates the interaction energy of nonbonded side chains
292 C assuming the LJK potential of interaction.
294 implicit real*8 (a-h,o-z)
298 include 'COMMON.LOCAL'
299 include 'COMMON.CHAIN'
300 include 'COMMON.DERIV'
301 include 'COMMON.INTERACT'
302 include 'COMMON.IOUNITS'
303 include 'COMMON.NAMES'
306 c print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
310 if (itypi.eq.ntyp1) cycle
316 C Calculate SC interaction energy.
319 do j=istart(i,iint),iend(i,iint)
321 if (itypj.eq.ntyp1) cycle
325 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
327 e_augm=augm(itypi,itypj)*fac_augm
330 sss=sscale(rij/sigma(itypi,itypj))
331 if (sss.gt.0.0d0) then
332 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
333 fac=r_shift_inv**expon
334 e1=fac*fac*aa(itypi,itypj)
335 e2=fac*bb(itypi,itypj)
337 cd sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
338 cd epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
339 cd write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
340 cd & restyp(itypi),i,restyp(itypj),j,aa(itypi,itypj),
341 cd & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
342 cd & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
343 cd & (c(k,i),k=1,3),(c(k,j),k=1,3)
346 C Calculate the components of the gradient in DC and X
348 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
354 gvdwx(k,i)=gvdwx(k,i)-gg(k)
355 gvdwx(k,j)=gvdwx(k,j)+gg(k)
356 gvdwc(k,i)=gvdwc(k,i)-gg(k)
357 gvdwc(k,j)=gvdwc(k,j)+gg(k)
365 gvdwc(j,i)=expon*gvdwc(j,i)
366 gvdwx(j,i)=expon*gvdwx(j,i)
371 C-----------------------------------------------------------------------------
372 subroutine ebp_long(evdw)
374 C This subroutine calculates the interaction energy of nonbonded side chains
375 C assuming the Berne-Pechukas potential of interaction.
377 implicit real*8 (a-h,o-z)
381 include 'COMMON.LOCAL'
382 include 'COMMON.CHAIN'
383 include 'COMMON.DERIV'
384 include 'COMMON.NAMES'
385 include 'COMMON.INTERACT'
386 include 'COMMON.IOUNITS'
387 include 'COMMON.CALC'
389 c double precision rrsave(maxdim)
392 c print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
394 c if (icall.eq.0) then
402 if (itypi.eq.ntyp1) cycle
407 dxi=dc_norm(1,nres+i)
408 dyi=dc_norm(2,nres+i)
409 dzi=dc_norm(3,nres+i)
410 c dsci_inv=dsc_inv(itypi)
411 dsci_inv=vbld_inv(i+nres)
413 C Calculate SC interaction energy.
416 do j=istart(i,iint),iend(i,iint)
419 if (itypj.eq.ntyp1) cycle
420 c dscj_inv=dsc_inv(itypj)
421 dscj_inv=vbld_inv(j+nres)
422 chi1=chi(itypi,itypj)
423 chi2=chi(itypj,itypi)
430 alf12=0.5D0*(alf1+alf2)
434 dxj=dc_norm(1,nres+j)
435 dyj=dc_norm(2,nres+j)
436 dzj=dc_norm(3,nres+j)
437 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
439 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
441 if (sss.lt.1.0d0) then
443 C Calculate the angle-dependent terms of energy & contributions to derivatives.
445 C Calculate whole angle-dependent part of epsilon and contributions
447 fac=(rrij*sigsq)**expon2
448 e1=fac*fac*aa(itypi,itypj)
449 e2=fac*bb(itypi,itypj)
450 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
451 eps2der=evdwij*eps3rt
452 eps3der=evdwij*eps2rt
453 evdwij=evdwij*eps2rt*eps3rt
454 evdw=evdw+evdwij*(1.0d0-sss)
456 sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
457 epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
458 cd write (iout,'(2(a3,i3,2x),15(0pf7.3))')
459 cd & restyp(itypi),i,restyp(itypj),j,
460 cd & epsi,sigm,chi1,chi2,chip1,chip2,
461 cd & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
462 cd & om1,om2,om12,1.0D0/dsqrt(rrij),
465 C Calculate gradient components.
466 e1=e1*eps1*eps2rt**2*eps3rt**2
467 fac=-expon*(e1+evdwij)
470 C Calculate radial part of the gradient
474 C Calculate the angular part of the gradient and sum add the contributions
475 C to the appropriate components of the Cartesian gradient.
476 call sc_grad_scale(1.0d0-sss)
484 C-----------------------------------------------------------------------------
485 subroutine ebp_short(evdw)
487 C This subroutine calculates the interaction energy of nonbonded side chains
488 C assuming the Berne-Pechukas potential of interaction.
490 implicit real*8 (a-h,o-z)
494 include 'COMMON.LOCAL'
495 include 'COMMON.CHAIN'
496 include 'COMMON.DERIV'
497 include 'COMMON.NAMES'
498 include 'COMMON.INTERACT'
499 include 'COMMON.IOUNITS'
500 include 'COMMON.CALC'
502 c double precision rrsave(maxdim)
505 c print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
507 c if (icall.eq.0) then
515 if (itypi.eq.ntyp1) cycle
520 dxi=dc_norm(1,nres+i)
521 dyi=dc_norm(2,nres+i)
522 dzi=dc_norm(3,nres+i)
523 c dsci_inv=dsc_inv(itypi)
524 dsci_inv=vbld_inv(i+nres)
526 C Calculate SC interaction energy.
529 do j=istart(i,iint),iend(i,iint)
532 if (itypj.eq.ntyp1) cycle
533 c dscj_inv=dsc_inv(itypj)
534 dscj_inv=vbld_inv(j+nres)
535 chi1=chi(itypi,itypj)
536 chi2=chi(itypj,itypi)
543 alf12=0.5D0*(alf1+alf2)
547 dxj=dc_norm(1,nres+j)
548 dyj=dc_norm(2,nres+j)
549 dzj=dc_norm(3,nres+j)
550 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
552 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
554 if (sss.gt.0.0d0) then
556 C Calculate the angle-dependent terms of energy & contributions to derivatives.
558 C Calculate whole angle-dependent part of epsilon and contributions
560 fac=(rrij*sigsq)**expon2
561 e1=fac*fac*aa(itypi,itypj)
562 e2=fac*bb(itypi,itypj)
563 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
564 eps2der=evdwij*eps3rt
565 eps3der=evdwij*eps2rt
566 evdwij=evdwij*eps2rt*eps3rt
569 sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
570 epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
571 cd write (iout,'(2(a3,i3,2x),15(0pf7.3))')
572 cd & restyp(itypi),i,restyp(itypj),j,
573 cd & epsi,sigm,chi1,chi2,chip1,chip2,
574 cd & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
575 cd & om1,om2,om12,1.0D0/dsqrt(rrij),
578 C Calculate gradient components.
579 e1=e1*eps1*eps2rt**2*eps3rt**2
580 fac=-expon*(e1+evdwij)
583 C Calculate radial part of the gradient
587 C Calculate the angular part of the gradient and sum add the contributions
588 C to the appropriate components of the Cartesian gradient.
589 call sc_grad_scale(sss)
597 C-----------------------------------------------------------------------------
598 subroutine egb_long(evdw)
600 C This subroutine calculates the interaction energy of nonbonded side chains
601 C assuming the Gay-Berne potential of interaction.
603 implicit real*8 (a-h,o-z)
607 include 'COMMON.LOCAL'
608 include 'COMMON.CHAIN'
609 include 'COMMON.DERIV'
610 include 'COMMON.NAMES'
611 include 'COMMON.INTERACT'
612 include 'COMMON.IOUNITS'
613 include 'COMMON.CALC'
614 include 'COMMON.CONTROL'
617 ccccc energy_dec=.false.
618 c print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
621 c if (icall.eq.0) lprn=.false.
625 if (itypi.eq.ntyp1) cycle
631 if (xi.lt.0) xi=xi+boxxsize
633 if (yi.lt.0) yi=yi+boxysize
635 if (zi.lt.0) zi=zi+boxzsize
636 dxi=dc_norm(1,nres+i)
637 dyi=dc_norm(2,nres+i)
638 dzi=dc_norm(3,nres+i)
639 c dsci_inv=dsc_inv(itypi)
640 dsci_inv=vbld_inv(i+nres)
641 c write (iout,*) "i",i,dsc_inv(itypi),dsci_inv,1.0d0/vbld(i+nres)
642 c write (iout,*) "dcnori",dxi*dxi+dyi*dyi+dzi*dzi
644 C Calculate SC interaction energy.
647 do j=istart(i,iint),iend(i,iint)
650 if (itypj.eq.ntyp1) cycle
651 c dscj_inv=dsc_inv(itypj)
652 dscj_inv=vbld_inv(j+nres)
653 c write (iout,*) "j",j,dsc_inv(itypj),dscj_inv,
654 c & 1.0d0/vbld(j+nres)
655 c write (iout,*) "i",i," j", j," itype",itype(i),itype(j)
656 sig0ij=sigma(itypi,itypj)
657 chi1=chi(itypi,itypj)
658 chi2=chi(itypj,itypi)
665 alf12=0.5D0*(alf1+alf2)
670 if (xj.lt.0) xj=xj+boxxsize
672 if (yj.lt.0) yj=yj+boxysize
674 if (zj.lt.0) zj=zj+boxzsize
675 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
683 xj=xj_safe+xshift*boxxsize
684 yj=yj_safe+yshift*boxysize
685 zj=zj_safe+zshift*boxzsize
686 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
687 if(dist_temp.lt.dist_init) then
697 if (subchap.eq.1) then
706 dxj=dc_norm(1,nres+j)
707 dyj=dc_norm(2,nres+j)
708 dzj=dc_norm(3,nres+j)
709 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
711 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
712 sssgrad=sscagrad((1.0d0/rij)/sigmaii(itypi,itypj))
713 if (sss.lt.1.0d0) then
715 C Calculate angle-dependent terms of energy and contributions to their
719 sig=sig0ij*dsqrt(sigsq)
720 rij_shift=1.0D0/rij-sig+sig0ij
721 c for diagnostics; uncomment
722 c rij_shift=1.2*sig0ij
723 C I hate to put IF's in the loops, but here don't have another choice!!!!
724 if (rij_shift.le.0.0D0) then
726 cd write (iout,'(2(a3,i3,2x),17(0pf7.3))')
727 cd & restyp(itypi),i,restyp(itypj),j,
728 cd & rij_shift,1.0D0/rij,sig,sig0ij,sigsq,1-dsqrt(sigsq)
732 c---------------------------------------------------------------
733 rij_shift=1.0D0/rij_shift
735 e1=fac*fac*aa(itypi,itypj)
736 e2=fac*bb(itypi,itypj)
737 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
738 eps2der=evdwij*eps3rt
739 eps3der=evdwij*eps2rt
740 c write (iout,*) "sigsq",sigsq," sig",sig," eps2rt",eps2rt,
741 c & " eps3rt",eps3rt," eps1",eps1," e1",e1," e2",e2
742 evdwij=evdwij*eps2rt*eps3rt
743 evdw=evdw+evdwij*(1.0d0-sss)
745 sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
746 epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
747 write (iout,'(2(a3,i3,2x),17(0pf7.3))')
748 & restyp(itypi),i,restyp(itypj),j,
749 & epsi,sigm,chi1,chi2,chip1,chip2,
750 & eps1,eps2rt**2,eps3rt**2,sig,sig0ij,
751 & om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,
755 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)')
758 C Calculate gradient components.
759 e1=e1*eps1*eps2rt**2*eps3rt**2
760 fac=-expon*(e1+evdwij)*rij_shift
763 fac=fac+evdwij/(1.0-sss)*(-sssgrad)/sigmaii(itypi,itypj)*rij
765 C Calculate the radial part of the gradient
769 C Calculate angular part of the gradient.
770 call sc_grad_scale(1.0d0-sss)
775 c write (iout,*) "Number of loop steps in EGB:",ind
776 cccc energy_dec=.false.
779 C-----------------------------------------------------------------------------
780 subroutine egb_short(evdw)
782 C This subroutine calculates the interaction energy of nonbonded side chains
783 C assuming the Gay-Berne potential of interaction.
785 implicit real*8 (a-h,o-z)
789 include 'COMMON.LOCAL'
790 include 'COMMON.CHAIN'
791 include 'COMMON.DERIV'
792 include 'COMMON.NAMES'
793 include 'COMMON.INTERACT'
794 include 'COMMON.IOUNITS'
795 include 'COMMON.CALC'
796 include 'COMMON.CONTROL'
799 ccccc energy_dec=.false.
800 c print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
803 c if (icall.eq.0) lprn=.false.
807 if (itypi.eq.ntyp1) cycle
813 if (xi.lt.0) xi=xi+boxxsize
815 if (yi.lt.0) yi=yi+boxysize
817 if (zi.lt.0) zi=zi+boxzsize
818 dxi=dc_norm(1,nres+i)
819 dyi=dc_norm(2,nres+i)
820 dzi=dc_norm(3,nres+i)
821 c dsci_inv=dsc_inv(itypi)
822 dsci_inv=vbld_inv(i+nres)
823 c write (iout,*) "i",i,dsc_inv(itypi),dsci_inv,1.0d0/vbld(i+nres)
824 c write (iout,*) "dcnori",dxi*dxi+dyi*dyi+dzi*dzi
826 C Calculate SC interaction energy.
829 do j=istart(i,iint),iend(i,iint)
832 if (itypj.eq.ntyp1) cycle
833 c dscj_inv=dsc_inv(itypj)
834 dscj_inv=vbld_inv(j+nres)
835 c write (iout,*) "j",j,dsc_inv(itypj),dscj_inv,
836 c & 1.0d0/vbld(j+nres)
837 c write (iout,*) "i",i," j", j," itype",itype(i),itype(j)
838 sig0ij=sigma(itypi,itypj)
839 chi1=chi(itypi,itypj)
840 chi2=chi(itypj,itypi)
847 alf12=0.5D0*(alf1+alf2)
852 if (xj.lt.0) xj=xj+boxxsize
854 if (yj.lt.0) yj=yj+boxysize
856 if (zj.lt.0) zj=zj+boxzsize
857 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
865 xj=xj_safe+xshift*boxxsize
866 yj=yj_safe+yshift*boxysize
867 zj=zj_safe+zshift*boxzsize
868 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
869 if(dist_temp.lt.dist_init) then
879 if (subchap.eq.1) then
888 dxj=dc_norm(1,nres+j)
889 dyj=dc_norm(2,nres+j)
890 dzj=dc_norm(3,nres+j)
891 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
893 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
894 sssgrad=sscagrad((1.0d0/rij)/sigmaii(itypi,itypj))
895 if (sss.gt.0.0d0) then
897 C Calculate angle-dependent terms of energy and contributions to their
901 sig=sig0ij*dsqrt(sigsq)
902 rij_shift=1.0D0/rij-sig+sig0ij
903 c for diagnostics; uncomment
904 c rij_shift=1.2*sig0ij
905 C I hate to put IF's in the loops, but here don't have another choice!!!!
906 if (rij_shift.le.0.0D0) then
908 cd write (iout,'(2(a3,i3,2x),17(0pf7.3))')
909 cd & restyp(itypi),i,restyp(itypj),j,
910 cd & rij_shift,1.0D0/rij,sig,sig0ij,sigsq,1-dsqrt(sigsq)
914 c---------------------------------------------------------------
915 rij_shift=1.0D0/rij_shift
917 e1=fac*fac*aa(itypi,itypj)
918 e2=fac*bb(itypi,itypj)
919 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
920 eps2der=evdwij*eps3rt
921 eps3der=evdwij*eps2rt
922 c write (iout,*) "sigsq",sigsq," sig",sig," eps2rt",eps2rt,
923 c & " eps3rt",eps3rt," eps1",eps1," e1",e1," e2",e2
924 evdwij=evdwij*eps2rt*eps3rt
927 sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
928 epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
929 write (iout,'(2(a3,i3,2x),17(0pf7.3))')
930 & restyp(itypi),i,restyp(itypj),j,
931 & epsi,sigm,chi1,chi2,chip1,chip2,
932 & eps1,eps2rt**2,eps3rt**2,sig,sig0ij,
933 & om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,
937 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)')
940 C Calculate gradient components.
941 e1=e1*eps1*eps2rt**2*eps3rt**2
942 fac=-expon*(e1+evdwij)*rij_shift
945 fac=fac+evdwij/sss*sssgrad/sigmaii(itypi,itypj)*rij
947 C Calculate the radial part of the gradient
951 C Calculate angular part of the gradient.
952 call sc_grad_scale(sss)
957 c write (iout,*) "Number of loop steps in EGB:",ind
958 cccc energy_dec=.false.
961 C-----------------------------------------------------------------------------
962 subroutine egbv_long(evdw)
964 C This subroutine calculates the interaction energy of nonbonded side chains
965 C assuming the Gay-Berne-Vorobjev potential of interaction.
967 implicit real*8 (a-h,o-z)
971 include 'COMMON.LOCAL'
972 include 'COMMON.CHAIN'
973 include 'COMMON.DERIV'
974 include 'COMMON.NAMES'
975 include 'COMMON.INTERACT'
976 include 'COMMON.IOUNITS'
977 include 'COMMON.CALC'
981 c print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
984 c if (icall.eq.0) lprn=.true.
988 if (itypi.eq.ntyp1) cycle
993 dxi=dc_norm(1,nres+i)
994 dyi=dc_norm(2,nres+i)
995 dzi=dc_norm(3,nres+i)
996 c dsci_inv=dsc_inv(itypi)
997 dsci_inv=vbld_inv(i+nres)
999 C Calculate SC interaction energy.
1001 do iint=1,nint_gr(i)
1002 do j=istart(i,iint),iend(i,iint)
1005 if (itypj.eq.ntyp1) cycle
1006 c dscj_inv=dsc_inv(itypj)
1007 dscj_inv=vbld_inv(j+nres)
1008 sig0ij=sigma(itypi,itypj)
1009 r0ij=r0(itypi,itypj)
1010 chi1=chi(itypi,itypj)
1011 chi2=chi(itypj,itypi)
1018 alf12=0.5D0*(alf1+alf2)
1022 dxj=dc_norm(1,nres+j)
1023 dyj=dc_norm(2,nres+j)
1024 dzj=dc_norm(3,nres+j)
1025 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1028 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
1030 if (sss.lt.1.0d0) then
1032 C Calculate angle-dependent terms of energy and contributions to their
1036 sig=sig0ij*dsqrt(sigsq)
1037 rij_shift=1.0D0/rij-sig+r0ij
1038 C I hate to put IF's in the loops, but here don't have another choice!!!!
1039 if (rij_shift.le.0.0D0) then
1044 c---------------------------------------------------------------
1045 rij_shift=1.0D0/rij_shift
1046 fac=rij_shift**expon
1047 e1=fac*fac*aa(itypi,itypj)
1048 e2=fac*bb(itypi,itypj)
1049 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
1050 eps2der=evdwij*eps3rt
1051 eps3der=evdwij*eps2rt
1052 fac_augm=rrij**expon
1053 e_augm=augm(itypi,itypj)*fac_augm
1054 evdwij=evdwij*eps2rt*eps3rt
1055 evdw=evdw+(evdwij+e_augm)*(1.0d0-sss)
1057 sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1058 epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1059 write (iout,'(2(a3,i3,2x),17(0pf7.3))')
1060 & restyp(itypi),i,restyp(itypj),j,
1061 & epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),
1062 & chi1,chi2,chip1,chip2,
1063 & eps1,eps2rt**2,eps3rt**2,
1064 & om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,
1067 C Calculate gradient components.
1068 e1=e1*eps1*eps2rt**2*eps3rt**2
1069 fac=-expon*(e1+evdwij)*rij_shift
1071 fac=rij*fac-2*expon*rrij*e_augm
1072 C Calculate the radial part of the gradient
1076 C Calculate angular part of the gradient.
1077 call sc_grad_scale(1.0d0-sss)
1083 C-----------------------------------------------------------------------------
1084 subroutine egbv_short(evdw)
1086 C This subroutine calculates the interaction energy of nonbonded side chains
1087 C assuming the Gay-Berne-Vorobjev potential of interaction.
1089 implicit real*8 (a-h,o-z)
1090 include 'DIMENSIONS'
1091 include 'COMMON.GEO'
1092 include 'COMMON.VAR'
1093 include 'COMMON.LOCAL'
1094 include 'COMMON.CHAIN'
1095 include 'COMMON.DERIV'
1096 include 'COMMON.NAMES'
1097 include 'COMMON.INTERACT'
1098 include 'COMMON.IOUNITS'
1099 include 'COMMON.CALC'
1100 common /srutu/ icall
1103 c print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
1106 c if (icall.eq.0) lprn=.true.
1108 do i=iatsc_s,iatsc_e
1110 if (itypi.eq.ntyp1) cycle
1115 dxi=dc_norm(1,nres+i)
1116 dyi=dc_norm(2,nres+i)
1117 dzi=dc_norm(3,nres+i)
1118 c dsci_inv=dsc_inv(itypi)
1119 dsci_inv=vbld_inv(i+nres)
1121 C Calculate SC interaction energy.
1123 do iint=1,nint_gr(i)
1124 do j=istart(i,iint),iend(i,iint)
1127 if (itypj.eq.ntyp1) cycle
1128 c dscj_inv=dsc_inv(itypj)
1129 dscj_inv=vbld_inv(j+nres)
1130 sig0ij=sigma(itypi,itypj)
1131 r0ij=r0(itypi,itypj)
1132 chi1=chi(itypi,itypj)
1133 chi2=chi(itypj,itypi)
1140 alf12=0.5D0*(alf1+alf2)
1144 dxj=dc_norm(1,nres+j)
1145 dyj=dc_norm(2,nres+j)
1146 dzj=dc_norm(3,nres+j)
1147 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1150 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
1152 if (sss.gt.0.0d0) then
1154 C Calculate angle-dependent terms of energy and contributions to their
1158 sig=sig0ij*dsqrt(sigsq)
1159 rij_shift=1.0D0/rij-sig+r0ij
1160 C I hate to put IF's in the loops, but here don't have another choice!!!!
1161 if (rij_shift.le.0.0D0) then
1166 c---------------------------------------------------------------
1167 rij_shift=1.0D0/rij_shift
1168 fac=rij_shift**expon
1169 e1=fac*fac*aa(itypi,itypj)
1170 e2=fac*bb(itypi,itypj)
1171 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
1172 eps2der=evdwij*eps3rt
1173 eps3der=evdwij*eps2rt
1174 fac_augm=rrij**expon
1175 e_augm=augm(itypi,itypj)*fac_augm
1176 evdwij=evdwij*eps2rt*eps3rt
1177 evdw=evdw+(evdwij+e_augm)*sss
1179 sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1180 epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1181 write (iout,'(2(a3,i3,2x),17(0pf7.3))')
1182 & restyp(itypi),i,restyp(itypj),j,
1183 & epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),
1184 & chi1,chi2,chip1,chip2,
1185 & eps1,eps2rt**2,eps3rt**2,
1186 & om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,
1189 C Calculate gradient components.
1190 e1=e1*eps1*eps2rt**2*eps3rt**2
1191 fac=-expon*(e1+evdwij)*rij_shift
1193 fac=rij*fac-2*expon*rrij*e_augm
1194 C Calculate the radial part of the gradient
1198 C Calculate angular part of the gradient.
1199 call sc_grad_scale(sss)
1205 C----------------------------------------------------------------------------
1206 subroutine sc_grad_scale(scalfac)
1207 implicit real*8 (a-h,o-z)
1208 include 'DIMENSIONS'
1209 include 'COMMON.CHAIN'
1210 include 'COMMON.DERIV'
1211 include 'COMMON.CALC'
1212 include 'COMMON.IOUNITS'
1213 double precision dcosom1(3),dcosom2(3)
1214 double precision scalfac
1215 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
1216 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
1217 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12
1218 & -2.0D0*alf12*eps3der+sigder*sigsq_om12
1222 c eom12=evdwij*eps1_om12
1224 c write (iout,*) "eps2der",eps2der," eps3der",eps3der,
1225 c & " sigder",sigder
1226 c write (iout,*) "eps1_om12",eps1_om12," eps2rt_om12",eps2rt_om12
1227 c write (iout,*) "eom1",eom1," eom2",eom2," eom12",eom12
1229 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
1230 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
1233 gg(k)=(gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k))*scalfac
1235 c write (iout,*) "gg",(gg(k),k=1,3)
1237 gvdwx(k,i)=gvdwx(k,i)-gg(k)
1238 & +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))
1239 & +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv*scalfac
1240 gvdwx(k,j)=gvdwx(k,j)+gg(k)
1241 & +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))
1242 & +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv*scalfac
1243 c write (iout,*)(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))
1244 c & +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
1245 c write (iout,*)(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))
1246 c & +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
1249 C Calculate the components of the gradient in DC and X
1252 gvdwc(l,i)=gvdwc(l,i)-gg(l)
1253 gvdwc(l,j)=gvdwc(l,j)+gg(l)
1257 C--------------------------------------------------------------------------
1258 subroutine eelec_scale(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
1260 C This subroutine calculates the average interaction energy and its gradient
1261 C in the virtual-bond vectors between non-adjacent peptide groups, based on
1262 C the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
1263 C The potential depends both on the distance of peptide-group centers and on
1264 C the orientation of the CA-CA virtual bonds.
1266 implicit real*8 (a-h,o-z)
1270 include 'DIMENSIONS'
1271 include 'COMMON.CONTROL'
1272 include 'COMMON.SETUP'
1273 include 'COMMON.IOUNITS'
1274 include 'COMMON.GEO'
1275 include 'COMMON.VAR'
1276 include 'COMMON.LOCAL'
1277 include 'COMMON.CHAIN'
1278 include 'COMMON.DERIV'
1279 include 'COMMON.INTERACT'
1280 include 'COMMON.CONTACTS'
1281 include 'COMMON.TORSION'
1282 include 'COMMON.VECTORS'
1283 include 'COMMON.FFIELD'
1284 include 'COMMON.TIME1'
1285 dimension ggg(3),gggp(3),gggm(3),erij(3),dcosb(3),dcosg(3),
1286 & erder(3,3),uryg(3,3),urzg(3,3),vryg(3,3),vrzg(3,3)
1287 double precision acipa(2,2),agg(3,4),aggi(3,4),aggi1(3,4),
1288 & aggj(3,4),aggj1(3,4),a_temp(2,2),muij(4)
1289 common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,
1290 & dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,
1292 c 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
1294 double precision scal_el /1.0d0/
1296 double precision scal_el /0.5d0/
1299 C 13-go grudnia roku pamietnego...
1300 double precision unmat(3,3) /1.0d0,0.0d0,0.0d0,
1301 & 0.0d0,1.0d0,0.0d0,
1302 & 0.0d0,0.0d0,1.0d0/
1303 cd write(iout,*) 'In EELEC'
1305 cd write(iout,*) 'Type',i
1306 cd write(iout,*) 'B1',B1(:,i)
1307 cd write(iout,*) 'B2',B2(:,i)
1308 cd write(iout,*) 'CC',CC(:,:,i)
1309 cd write(iout,*) 'DD',DD(:,:,i)
1310 cd write(iout,*) 'EE',EE(:,:,i)
1312 cd call check_vecgrad
1314 if (icheckgrad.eq.1) then
1316 fac=1.0d0/dsqrt(scalar(dc(1,i),dc(1,i)))
1318 dc_norm(k,i)=dc(k,i)*fac
1320 c write (iout,*) 'i',i,' fac',fac
1323 if (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0
1324 & .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 .or.
1325 & wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) then
1326 c call vec_and_deriv
1332 time_mat=time_mat+MPI_Wtime()-time01
1336 cd write (iout,*) 'i=',i
1338 cd write (iout,'(i5,2f10.5)') k,uy(k,i),uz(k,i)
1341 cd write (iout,'(f10.5,2x,3f10.5,2x,3f10.5)')
1342 cd & uz(k,i),(uzgrad(k,l,1,i),l=1,3),(uzgrad(k,l,2,i),l=1,3)
1355 cd print '(a)','Enter EELEC'
1356 cd write (iout,*) 'iatel_s=',iatel_s,' iatel_e=',iatel_e
1358 gel_loc_loc(i)=0.0d0
1363 c 9/27/08 AL Split the interaction loop to ensure load balancing of turn terms
1365 C Loop over i,i+2 and i,i+3 pairs of the peptide groups
1367 do i=iturn3_start,iturn3_end
1368 if (itype(i).eq.ntyp1.or. itype(i+1).eq.ntyp1
1369 & .or. itype(i+2).eq.ntyp1 .or. itype(i+3).eq.ntyp1
1370 & .or. itype(i-1).eq.ntyp1
1371 & .or. itype(i+4).eq.ntyp1
1376 dx_normi=dc_norm(1,i)
1377 dy_normi=dc_norm(2,i)
1378 dz_normi=dc_norm(3,i)
1379 xmedi=c(1,i)+0.5d0*dxi
1380 ymedi=c(2,i)+0.5d0*dyi
1381 zmedi=c(3,i)+0.5d0*dzi
1382 xmedi=mod(xmedi,boxxsize)
1383 if (xmedi.lt.0) xmedi=xmedi+boxxsize
1384 ymedi=mod(ymedi,boxysize)
1385 if (ymedi.lt.0) ymedi=ymedi+boxysize
1386 zmedi=mod(zmedi,boxzsize)
1387 if (zmedi.lt.0) zmedi=zmedi+boxzsize
1389 call eelecij_scale(i,i+2,ees,evdw1,eel_loc)
1390 if (wturn3.gt.0.0d0) call eturn3(i,eello_turn3)
1391 num_cont_hb(i)=num_conti
1393 do i=iturn4_start,iturn4_end
1394 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1
1395 & .or. itype(i+3).eq.ntyp1
1396 & .or. itype(i+4).eq.ntyp1
1397 & .or. itype(i+5).eq.ntyp1
1398 & .or. itype(i-1).eq.ntyp1
1403 dx_normi=dc_norm(1,i)
1404 dy_normi=dc_norm(2,i)
1405 dz_normi=dc_norm(3,i)
1406 xmedi=c(1,i)+0.5d0*dxi
1407 ymedi=c(2,i)+0.5d0*dyi
1408 zmedi=c(3,i)+0.5d0*dzi
1409 num_conti=num_cont_hb(i)
1410 call eelecij_scale(i,i+3,ees,evdw1,eel_loc)
1411 if (wturn4.gt.0.0d0 .and. itype(i+2).ne.ntyp1)
1412 & call eturn4(i,eello_turn4)
1413 num_cont_hb(i)=num_conti
1416 c Loop over all pairs of interacting peptide groups except i,i+2 and i,i+3
1418 do i=iatel_s,iatel_e
1419 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1
1420 & .or. itype(i+2).eq.ntyp1
1421 & .or. itype(i-1).eq.ntyp1
1426 dx_normi=dc_norm(1,i)
1427 dy_normi=dc_norm(2,i)
1428 dz_normi=dc_norm(3,i)
1429 xmedi=c(1,i)+0.5d0*dxi
1430 ymedi=c(2,i)+0.5d0*dyi
1431 zmedi=c(3,i)+0.5d0*dzi
1432 xmedi=mod(xmedi,boxxsize)
1433 if (xmedi.lt.0) xmedi=xmedi+boxxsize
1434 ymedi=mod(ymedi,boxysize)
1435 if (ymedi.lt.0) ymedi=ymedi+boxysize
1436 zmedi=mod(zmedi,boxzsize)
1437 if (zmedi.lt.0) zmedi=zmedi+boxzsize
1438 c write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
1439 num_conti=num_cont_hb(i)
1440 do j=ielstart(i),ielend(i)
1441 if (itype(j).eq.ntyp1 .or. itype(j+1).eq.ntyp1
1442 & .or.itype(j+2).eq.ntyp1
1443 & .or.itype(j-1).eq.ntyp1
1445 call eelecij_scale(i,j,ees,evdw1,eel_loc)
1447 num_cont_hb(i)=num_conti
1449 c write (iout,*) "Number of loop steps in EELEC:",ind
1451 cd write (iout,'(i3,3f10.5,5x,3f10.5)')
1452 cd & i,(gel_loc(k,i),k=1,3),gel_loc_loc(i)
1454 c 12/7/99 Adam eello_turn3 will be considered as a separate energy term
1455 ccc eel_loc=eel_loc+eello_turn3
1456 cd print *,"Processor",fg_rank," t_eelecij",t_eelecij
1459 C-------------------------------------------------------------------------------
1460 subroutine eelecij_scale(i,j,ees,evdw1,eel_loc)
1461 implicit real*8 (a-h,o-z)
1462 include 'DIMENSIONS'
1466 include 'COMMON.CONTROL'
1467 include 'COMMON.IOUNITS'
1468 include 'COMMON.GEO'
1469 include 'COMMON.VAR'
1470 include 'COMMON.LOCAL'
1471 include 'COMMON.CHAIN'
1472 include 'COMMON.DERIV'
1473 include 'COMMON.INTERACT'
1474 include 'COMMON.CONTACTS'
1475 include 'COMMON.TORSION'
1476 include 'COMMON.VECTORS'
1477 include 'COMMON.FFIELD'
1478 include 'COMMON.TIME1'
1479 dimension ggg(3),gggp(3),gggm(3),erij(3),dcosb(3),dcosg(3),
1480 & erder(3,3),uryg(3,3),urzg(3,3),vryg(3,3),vrzg(3,3)
1481 double precision acipa(2,2),agg(3,4),aggi(3,4),aggi1(3,4),
1482 & aggj(3,4),aggj1(3,4),a_temp(2,2),muij(4)
1483 common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,
1484 & dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,
1486 c 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
1488 double precision scal_el /1.0d0/
1490 double precision scal_el /0.5d0/
1493 C 13-go grudnia roku pamietnego...
1494 double precision unmat(3,3) /1.0d0,0.0d0,0.0d0,
1495 & 0.0d0,1.0d0,0.0d0,
1496 & 0.0d0,0.0d0,1.0d0/
1497 c time00=MPI_Wtime()
1498 cd write (iout,*) "eelecij",i,j
1502 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
1503 aaa=app(iteli,itelj)
1504 bbb=bpp(iteli,itelj)
1505 ael6i=ael6(iteli,itelj)
1506 ael3i=ael3(iteli,itelj)
1510 dx_normj=dc_norm(1,j)
1511 dy_normj=dc_norm(2,j)
1512 dz_normj=dc_norm(3,j)
1517 if (xj.lt.0) xj=xj+boxxsize
1519 if (yj.lt.0) yj=yj+boxysize
1521 if (zj.lt.0) zj=zj+boxzsize
1522 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
1530 xj=xj_safe+xshift*boxxsize
1531 yj=yj_safe+yshift*boxysize
1532 zj=zj_safe+zshift*boxzsize
1533 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
1534 if(dist_temp.lt.dist_init) then
1544 if (isubchap.eq.1) then
1554 rij=xj*xj+yj*yj+zj*zj
1558 c For extracting the short-range part of Evdwpp
1559 sss=sscale(rij/rpp(iteli,itelj))
1560 sssgrad=sscagrad(rij/rpp(iteli,itelj))
1563 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
1564 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
1565 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
1566 fac=cosa-3.0D0*cosb*cosg
1568 c 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
1569 if (j.eq.i+2) ev1=scal_el*ev1
1574 el1=fac3*(4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg))
1577 C 12/26/95 - for the evaluation of multi-body H-bonding interactions
1578 ees0ij=4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg)
1580 evdw1=evdw1+evdwij*(1.0d0-sss)
1581 cd write(iout,'(2(2i3,2x),7(1pd12.4)/2(3(1pd12.4),5x)/)')
1582 cd & iteli,i,itelj,j,aaa,bbb,ael6i,ael3i,
1583 cd & 1.0D0/dsqrt(rrmij),evdwij,eesij,
1584 cd & xmedi,ymedi,zmedi,xj,yj,zj
1586 if (energy_dec) then
1587 write (iout,'(a6,2i5,0pf7.3,f7.3)') 'evdw1',i,j,evdwij,sss
1588 write (iout,'(a6,2i5,0pf7.3)') 'ees',i,j,eesij
1592 C Calculate contributions to the Cartesian gradient.
1595 facvdw=-6*rrmij*(ev1+evdwij)*(1.0d0-sss)
1596 facel=-3*rrmij*(el1+eesij)
1602 * Radial derivatives. First process both termini of the fragment (i,j)
1608 c ghalf=0.5D0*ggg(k)
1609 c gelc(k,i)=gelc(k,i)+ghalf
1610 c gelc(k,j)=gelc(k,j)+ghalf
1612 c 9/28/08 AL Gradient compotents will be summed only at the end
1614 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
1615 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
1618 * Loop over residues i+1 thru j-1.
1622 cgrad gelc(l,k)=gelc(l,k)+ggg(l)
1625 ggg(1)=facvdw*xj-sssgrad*rmij*evdwij*xj/rpp(iteli,itelj)
1626 ggg(2)=facvdw*yj-sssgrad*rmij*evdwij*yj/rpp(iteli,itelj)
1627 ggg(3)=facvdw*zj-sssgrad*rmij*evdwij*zj/rpp(iteli,itelj)
1629 c ghalf=0.5D0*ggg(k)
1630 c gvdwpp(k,i)=gvdwpp(k,i)+ghalf
1631 c gvdwpp(k,j)=gvdwpp(k,j)+ghalf
1633 c 9/28/08 AL Gradient compotents will be summed only at the end
1635 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
1636 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
1639 * Loop over residues i+1 thru j-1.
1643 cgrad gvdwpp(l,k)=gvdwpp(l,k)+ggg(l)
1647 facvdw=ev1+evdwij*(1.0d0-sss)
1650 fac=-3*rrmij*(facvdw+facvdw+facel)
1655 * Radial derivatives. First process both termini of the fragment (i,j)
1661 c ghalf=0.5D0*ggg(k)
1662 c gelc(k,i)=gelc(k,i)+ghalf
1663 c gelc(k,j)=gelc(k,j)+ghalf
1665 c 9/28/08 AL Gradient compotents will be summed only at the end
1667 gelc_long(k,j)=gelc(k,j)+ggg(k)
1668 gelc_long(k,i)=gelc(k,i)-ggg(k)
1671 * Loop over residues i+1 thru j-1.
1675 cgrad gelc(l,k)=gelc(l,k)+ggg(l)
1678 c 9/28/08 AL Gradient compotents will be summed only at the end
1682 ggg(1)=facvdw*xj-sssgrad*rmij*evdwij*xj/rpp(iteli,itelj)
1683 ggg(2)=facvdw*yj-sssgrad*rmij*evdwij*yj/rpp(iteli,itelj)
1684 ggg(3)=facvdw*zj-sssgrad*rmij*evdwij*zj/rpp(iteli,itelj)
1686 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
1687 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
1693 ecosa=2.0D0*fac3*fac1+fac4
1696 ecosb=(fac3*(fac1*cosg+cosb)+cosg*fac4)
1697 ecosg=(fac3*(fac1*cosb+cosg)+cosb*fac4)
1699 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
1700 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
1702 cd print '(2i3,2(3(1pd14.5),3x))',i,j,(dcosb(k),k=1,3),
1703 cd & (dcosg(k),k=1,3)
1705 ggg(k)=ecosb*dcosb(k)+ecosg*dcosg(k)
1708 c ghalf=0.5D0*ggg(k)
1709 c gelc(k,i)=gelc(k,i)+ghalf
1710 c & +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
1711 c & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
1712 c gelc(k,j)=gelc(k,j)+ghalf
1713 c & +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
1714 c & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
1718 cgrad gelc(l,k)=gelc(l,k)+ggg(l)
1723 & +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
1724 & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
1726 & +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
1727 & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
1728 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
1729 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
1731 IF (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0
1732 & .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0
1733 & .or. wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
1735 C 9/25/99 Mixed third-order local-electrostatic terms. The local-interaction
1736 C energy of a peptide unit is assumed in the form of a second-order
1737 C Fourier series in the angles lambda1 and lambda2 (see Nishikawa et al.
1738 C Macromolecules, 1974, 7, 797-806 for definition). This correlation terms
1739 C are computed for EVERY pair of non-contiguous peptide groups.
1741 if (j.lt.nres-1) then
1752 muij(kkk)=mu(k,i)*mu(l,j)
1755 cd write (iout,*) 'EELEC: i',i,' j',j
1756 cd write (iout,*) 'j',j,' j1',j1,' j2',j2
1757 cd write(iout,*) 'muij',muij
1758 ury=scalar(uy(1,i),erij)
1759 urz=scalar(uz(1,i),erij)
1760 vry=scalar(uy(1,j),erij)
1761 vrz=scalar(uz(1,j),erij)
1762 a22=scalar(uy(1,i),uy(1,j))-3*ury*vry
1763 a23=scalar(uy(1,i),uz(1,j))-3*ury*vrz
1764 a32=scalar(uz(1,i),uy(1,j))-3*urz*vry
1765 a33=scalar(uz(1,i),uz(1,j))-3*urz*vrz
1766 fac=dsqrt(-ael6i)*r3ij
1771 cd write (iout,'(4i5,4f10.5)')
1772 cd & i,itortyp(itype(i)),j,itortyp(itype(j)),a22,a23,a32,a33
1773 cd write (iout,'(6f10.5)') (muij(k),k=1,4),fac,eel_loc_ij
1774 cd write (iout,'(2(3f10.5,5x)/2(3f10.5,5x))') uy(:,i),uz(:,i),
1775 cd & uy(:,j),uz(:,j)
1776 cd write (iout,'(4f10.5)')
1777 cd & scalar(uy(1,i),uy(1,j)),scalar(uy(1,i),uz(1,j)),
1778 cd & scalar(uz(1,i),uy(1,j)),scalar(uz(1,i),uz(1,j))
1779 cd write (iout,'(4f10.5)') ury,urz,vry,vrz
1780 cd write (iout,'(9f10.5/)')
1781 cd & fac22,a22,fac23,a23,fac32,a32,fac33,a33,eel_loc_ij
1782 C Derivatives of the elements of A in virtual-bond vectors
1783 call unormderiv(erij(1),unmat(1,1),rmij,erder(1,1))
1785 uryg(k,1)=scalar(erder(1,k),uy(1,i))
1786 uryg(k,2)=scalar(uygrad(1,k,1,i),erij(1))
1787 uryg(k,3)=scalar(uygrad(1,k,2,i),erij(1))
1788 urzg(k,1)=scalar(erder(1,k),uz(1,i))
1789 urzg(k,2)=scalar(uzgrad(1,k,1,i),erij(1))
1790 urzg(k,3)=scalar(uzgrad(1,k,2,i),erij(1))
1791 vryg(k,1)=scalar(erder(1,k),uy(1,j))
1792 vryg(k,2)=scalar(uygrad(1,k,1,j),erij(1))
1793 vryg(k,3)=scalar(uygrad(1,k,2,j),erij(1))
1794 vrzg(k,1)=scalar(erder(1,k),uz(1,j))
1795 vrzg(k,2)=scalar(uzgrad(1,k,1,j),erij(1))
1796 vrzg(k,3)=scalar(uzgrad(1,k,2,j),erij(1))
1798 C Compute radial contributions to the gradient
1816 C Add the contributions coming from er
1819 agg(k,1)=agg(k,1)+fac3*(uryg(k,1)*vry+vryg(k,1)*ury)
1820 agg(k,2)=agg(k,2)+fac3*(uryg(k,1)*vrz+vrzg(k,1)*ury)
1821 agg(k,3)=agg(k,3)+fac3*(urzg(k,1)*vry+vryg(k,1)*urz)
1822 agg(k,4)=agg(k,4)+fac3*(urzg(k,1)*vrz+vrzg(k,1)*urz)
1825 C Derivatives in DC(i)
1826 cgrad ghalf1=0.5d0*agg(k,1)
1827 cgrad ghalf2=0.5d0*agg(k,2)
1828 cgrad ghalf3=0.5d0*agg(k,3)
1829 cgrad ghalf4=0.5d0*agg(k,4)
1830 aggi(k,1)=fac*(scalar(uygrad(1,k,1,i),uy(1,j))
1831 & -3.0d0*uryg(k,2)*vry)!+ghalf1
1832 aggi(k,2)=fac*(scalar(uygrad(1,k,1,i),uz(1,j))
1833 & -3.0d0*uryg(k,2)*vrz)!+ghalf2
1834 aggi(k,3)=fac*(scalar(uzgrad(1,k,1,i),uy(1,j))
1835 & -3.0d0*urzg(k,2)*vry)!+ghalf3
1836 aggi(k,4)=fac*(scalar(uzgrad(1,k,1,i),uz(1,j))
1837 & -3.0d0*urzg(k,2)*vrz)!+ghalf4
1838 C Derivatives in DC(i+1)
1839 aggi1(k,1)=fac*(scalar(uygrad(1,k,2,i),uy(1,j))
1840 & -3.0d0*uryg(k,3)*vry)!+agg(k,1)
1841 aggi1(k,2)=fac*(scalar(uygrad(1,k,2,i),uz(1,j))
1842 & -3.0d0*uryg(k,3)*vrz)!+agg(k,2)
1843 aggi1(k,3)=fac*(scalar(uzgrad(1,k,2,i),uy(1,j))
1844 & -3.0d0*urzg(k,3)*vry)!+agg(k,3)
1845 aggi1(k,4)=fac*(scalar(uzgrad(1,k,2,i),uz(1,j))
1846 & -3.0d0*urzg(k,3)*vrz)!+agg(k,4)
1847 C Derivatives in DC(j)
1848 aggj(k,1)=fac*(scalar(uygrad(1,k,1,j),uy(1,i))
1849 & -3.0d0*vryg(k,2)*ury)!+ghalf1
1850 aggj(k,2)=fac*(scalar(uzgrad(1,k,1,j),uy(1,i))
1851 & -3.0d0*vrzg(k,2)*ury)!+ghalf2
1852 aggj(k,3)=fac*(scalar(uygrad(1,k,1,j),uz(1,i))
1853 & -3.0d0*vryg(k,2)*urz)!+ghalf3
1854 aggj(k,4)=fac*(scalar(uzgrad(1,k,1,j),uz(1,i))
1855 & -3.0d0*vrzg(k,2)*urz)!+ghalf4
1856 C Derivatives in DC(j+1) or DC(nres-1)
1857 aggj1(k,1)=fac*(scalar(uygrad(1,k,2,j),uy(1,i))
1858 & -3.0d0*vryg(k,3)*ury)
1859 aggj1(k,2)=fac*(scalar(uzgrad(1,k,2,j),uy(1,i))
1860 & -3.0d0*vrzg(k,3)*ury)
1861 aggj1(k,3)=fac*(scalar(uygrad(1,k,2,j),uz(1,i))
1862 & -3.0d0*vryg(k,3)*urz)
1863 aggj1(k,4)=fac*(scalar(uzgrad(1,k,2,j),uz(1,i))
1864 & -3.0d0*vrzg(k,3)*urz)
1865 cgrad if (j.eq.nres-1 .and. i.lt.j-2) then
1867 cgrad aggj1(k,l)=aggj1(k,l)+agg(k,l)
1880 aggi(k,l)=-aggi(k,l)
1881 aggi1(k,l)=-aggi1(k,l)
1882 aggj(k,l)=-aggj(k,l)
1883 aggj1(k,l)=-aggj1(k,l)
1886 if (j.lt.nres-1) then
1892 aggi(k,l)=-aggi(k,l)
1893 aggi1(k,l)=-aggi1(k,l)
1894 aggj(k,l)=-aggj(k,l)
1895 aggj1(k,l)=-aggj1(k,l)
1906 aggi(k,l)=-aggi(k,l)
1907 aggi1(k,l)=-aggi1(k,l)
1908 aggj(k,l)=-aggj(k,l)
1909 aggj1(k,l)=-aggj1(k,l)
1914 IF (wel_loc.gt.0.0d0) THEN
1915 C Contribution to the local-electrostatic energy coming from the i-j pair
1916 eel_loc_ij=a22*muij(1)+a23*muij(2)+a32*muij(3)
1918 cd write (iout,*) 'i',i,' j',j,' eel_loc_ij',eel_loc_ij
1920 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)')
1921 & 'eelloc',i,j,eel_loc_ij
1923 eel_loc=eel_loc+eel_loc_ij
1924 C Partial derivatives in virtual-bond dihedral angles gamma
1926 & gel_loc_loc(i-1)=gel_loc_loc(i-1)+
1927 & a22*muder(1,i)*mu(1,j)+a23*muder(1,i)*mu(2,j)
1928 & +a32*muder(2,i)*mu(1,j)+a33*muder(2,i)*mu(2,j)
1929 gel_loc_loc(j-1)=gel_loc_loc(j-1)+
1930 & a22*mu(1,i)*muder(1,j)+a23*mu(1,i)*muder(2,j)
1931 & +a32*mu(2,i)*muder(1,j)+a33*mu(2,i)*muder(2,j)
1932 C Derivatives of eello in DC(i+1) thru DC(j-1) or DC(nres-2)
1934 ggg(l)=agg(l,1)*muij(1)+
1935 & agg(l,2)*muij(2)+agg(l,3)*muij(3)+agg(l,4)*muij(4)
1936 gel_loc_long(l,j)=gel_loc_long(l,j)+ggg(l)
1937 gel_loc_long(l,i)=gel_loc_long(l,i)-ggg(l)
1938 cgrad ghalf=0.5d0*ggg(l)
1939 cgrad gel_loc(l,i)=gel_loc(l,i)+ghalf
1940 cgrad gel_loc(l,j)=gel_loc(l,j)+ghalf
1944 cgrad gel_loc(l,k)=gel_loc(l,k)+ggg(l)
1947 C Remaining derivatives of eello
1949 gel_loc(l,i)=gel_loc(l,i)+aggi(l,1)*muij(1)+
1950 & aggi(l,2)*muij(2)+aggi(l,3)*muij(3)+aggi(l,4)*muij(4)
1951 gel_loc(l,i+1)=gel_loc(l,i+1)+aggi1(l,1)*muij(1)+
1952 & aggi1(l,2)*muij(2)+aggi1(l,3)*muij(3)+aggi1(l,4)*muij(4)
1953 gel_loc(l,j)=gel_loc(l,j)+aggj(l,1)*muij(1)+
1954 & aggj(l,2)*muij(2)+aggj(l,3)*muij(3)+aggj(l,4)*muij(4)
1955 gel_loc(l,j1)=gel_loc(l,j1)+aggj1(l,1)*muij(1)+
1956 & aggj1(l,2)*muij(2)+aggj1(l,3)*muij(3)+aggj1(l,4)*muij(4)
1959 C Change 12/26/95 to calculate four-body contributions to H-bonding energy
1960 c if (j.gt.i+1 .and. num_conti.le.maxconts) then
1961 if (wcorr+wcorr4+wcorr5+wcorr6.gt.0.0d0
1962 & .and. num_conti.le.maxconts) then
1963 c write (iout,*) i,j," entered corr"
1965 C Calculate the contact function. The ith column of the array JCONT will
1966 C contain the numbers of atoms that make contacts with the atom I (of numbers
1967 C greater than I). The arrays FACONT and GACONT will contain the values of
1968 C the contact function and its derivative.
1969 c r0ij=1.02D0*rpp(iteli,itelj)
1970 c r0ij=1.11D0*rpp(iteli,itelj)
1971 r0ij=2.20D0*rpp(iteli,itelj)
1972 c r0ij=1.55D0*rpp(iteli,itelj)
1973 call gcont(rij,r0ij,1.0D0,0.2d0*r0ij,fcont,fprimcont)
1974 if (fcont.gt.0.0D0) then
1975 num_conti=num_conti+1
1976 if (num_conti.gt.maxconts) then
1977 write (iout,*) 'WARNING - max. # of contacts exceeded;',
1978 & ' will skip next contacts for this conf.'
1980 jcont_hb(num_conti,i)=j
1981 cd write (iout,*) "i",i," j",j," num_conti",num_conti,
1982 cd & " jcont_hb",jcont_hb(num_conti,i)
1983 IF (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.
1984 & wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
1985 C 9/30/99 (AL) - store components necessary to evaluate higher-order loc-el
1987 d_cont(num_conti,i)=rij
1988 cd write (2,'(3e15.5)') rij,r0ij+0.2d0*r0ij,rij
1989 C --- Electrostatic-interaction matrix ---
1990 a_chuj(1,1,num_conti,i)=a22
1991 a_chuj(1,2,num_conti,i)=a23
1992 a_chuj(2,1,num_conti,i)=a32
1993 a_chuj(2,2,num_conti,i)=a33
1994 C --- Gradient of rij
1996 grij_hb_cont(kkk,num_conti,i)=erij(kkk)
2003 a_chuj_der(k,l,m,1,num_conti,i)=agg(m,kkll)
2004 a_chuj_der(k,l,m,2,num_conti,i)=aggi(m,kkll)
2005 a_chuj_der(k,l,m,3,num_conti,i)=aggi1(m,kkll)
2006 a_chuj_der(k,l,m,4,num_conti,i)=aggj(m,kkll)
2007 a_chuj_der(k,l,m,5,num_conti,i)=aggj1(m,kkll)
2012 IF (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) THEN
2013 C Calculate contact energies
2015 wij=cosa-3.0D0*cosb*cosg
2018 c fac3=dsqrt(-ael6i)/r0ij**3
2019 fac3=dsqrt(-ael6i)*r3ij
2020 c ees0pij=dsqrt(4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1)
2021 ees0tmp=4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1
2022 if (ees0tmp.gt.0) then
2023 ees0pij=dsqrt(ees0tmp)
2027 c ees0mij=dsqrt(4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2)
2028 ees0tmp=4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2
2029 if (ees0tmp.gt.0) then
2030 ees0mij=dsqrt(ees0tmp)
2035 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij)
2036 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij)
2037 C Diagnostics. Comment out or remove after debugging!
2038 c ees0p(num_conti,i)=0.5D0*fac3*ees0pij
2039 c ees0m(num_conti,i)=0.5D0*fac3*ees0mij
2040 c ees0m(num_conti,i)=0.0D0
2042 c write (iout,*) 'i=',i,' j=',j,' rij=',rij,' r0ij=',r0ij,
2043 c & ' ees0ij=',ees0p(num_conti,i),ees0m(num_conti,i),' fcont=',fcont
2044 C Angular derivatives of the contact function
2045 ees0pij1=fac3/ees0pij
2046 ees0mij1=fac3/ees0mij
2047 fac3p=-3.0D0*fac3*rrmij
2048 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
2049 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
2051 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
2052 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
2053 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
2054 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
2055 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
2056 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
2057 ecosap=ecosa1+ecosa2
2058 ecosbp=ecosb1+ecosb2
2059 ecosgp=ecosg1+ecosg2
2060 ecosam=ecosa1-ecosa2
2061 ecosbm=ecosb1-ecosb2
2062 ecosgm=ecosg1-ecosg2
2071 facont_hb(num_conti,i)=fcont
2072 fprimcont=fprimcont/rij
2073 cd facont_hb(num_conti,i)=1.0D0
2074 C Following line is for diagnostics.
2077 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
2078 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
2081 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
2082 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
2084 gggp(1)=gggp(1)+ees0pijp*xj
2085 gggp(2)=gggp(2)+ees0pijp*yj
2086 gggp(3)=gggp(3)+ees0pijp*zj
2087 gggm(1)=gggm(1)+ees0mijp*xj
2088 gggm(2)=gggm(2)+ees0mijp*yj
2089 gggm(3)=gggm(3)+ees0mijp*zj
2090 C Derivatives due to the contact function
2091 gacont_hbr(1,num_conti,i)=fprimcont*xj
2092 gacont_hbr(2,num_conti,i)=fprimcont*yj
2093 gacont_hbr(3,num_conti,i)=fprimcont*zj
2096 c 10/24/08 cgrad and ! comments indicate the parts of the code removed
2097 c following the change of gradient-summation algorithm.
2099 cgrad ghalfp=0.5D0*gggp(k)
2100 cgrad ghalfm=0.5D0*gggm(k)
2101 gacontp_hb1(k,num_conti,i)=!ghalfp
2102 & +(ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i))
2103 & + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
2104 gacontp_hb2(k,num_conti,i)=!ghalfp
2105 & +(ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j))
2106 & + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
2107 gacontp_hb3(k,num_conti,i)=gggp(k)
2108 gacontm_hb1(k,num_conti,i)=!ghalfm
2109 & +(ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i))
2110 & + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
2111 gacontm_hb2(k,num_conti,i)=!ghalfm
2112 & +(ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j))
2113 & + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
2114 gacontm_hb3(k,num_conti,i)=gggm(k)
2117 endif ! num_conti.le.maxconts
2120 if (wturn3.gt.0.0d0 .or. wturn4.gt.0.0d0) then
2123 ghalf=0.5d0*agg(l,k)
2124 aggi(l,k)=aggi(l,k)+ghalf
2125 aggi1(l,k)=aggi1(l,k)+agg(l,k)
2126 aggj(l,k)=aggj(l,k)+ghalf
2129 if (j.eq.nres-1 .and. i.lt.j-2) then
2132 aggj1(l,k)=aggj1(l,k)+agg(l,k)
2137 c t_eelecij=t_eelecij+MPI_Wtime()-time00
2140 C-----------------------------------------------------------------------
2141 subroutine evdwpp_short(evdw1)
2145 implicit real*8 (a-h,o-z)
2146 include 'DIMENSIONS'
2147 include 'COMMON.CONTROL'
2148 include 'COMMON.IOUNITS'
2149 include 'COMMON.GEO'
2150 include 'COMMON.VAR'
2151 include 'COMMON.LOCAL'
2152 include 'COMMON.CHAIN'
2153 include 'COMMON.DERIV'
2154 include 'COMMON.INTERACT'
2155 include 'COMMON.CONTACTS'
2156 include 'COMMON.TORSION'
2157 include 'COMMON.VECTORS'
2158 include 'COMMON.FFIELD'
2160 c 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
2162 double precision scal_el /1.0d0/
2164 double precision scal_el /0.5d0/
2167 c write (iout,*) "iatel_s_vdw",iatel_s_vdw,
2168 c & " iatel_e_vdw",iatel_e_vdw
2170 do i=iatel_s_vdw,iatel_e_vdw
2171 if (itype(i).eq.ntyp1.or. itype(i+1).eq.ntyp1) cycle
2175 dx_normi=dc_norm(1,i)
2176 dy_normi=dc_norm(2,i)
2177 dz_normi=dc_norm(3,i)
2178 xmedi=c(1,i)+0.5d0*dxi
2179 ymedi=c(2,i)+0.5d0*dyi
2180 zmedi=c(3,i)+0.5d0*dzi
2181 xmedi=mod(xmedi,boxxsize)
2182 if (xmedi.lt.0) xmedi=xmedi+boxxsize
2183 ymedi=mod(ymedi,boxysize)
2184 if (ymedi.lt.0) ymedi=ymedi+boxysize
2185 zmedi=mod(zmedi,boxzsize)
2186 if (zmedi.lt.0) zmedi=zmedi+boxzsize
2188 c write (iout,*) 'i',i,' ielstart',ielstart_vdw(i),
2189 c & ' ielend',ielend_vdw(i)
2191 do j=ielstart_vdw(i),ielend_vdw(i)
2192 if (itype(j).eq.ntyp1 .or. itype(j+1).eq.ntyp1) cycle
2196 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
2197 aaa=app(iteli,itelj)
2198 bbb=bpp(iteli,itelj)
2202 dx_normj=dc_norm(1,j)
2203 dy_normj=dc_norm(2,j)
2204 dz_normj=dc_norm(3,j)
2209 if (xj.lt.0) xj=xj+boxxsize
2211 if (yj.lt.0) yj=yj+boxysize
2213 if (zj.lt.0) zj=zj+boxzsize
2214 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
2222 xj=xj_safe+xshift*boxxsize
2223 yj=yj_safe+yshift*boxysize
2224 zj=zj_safe+zshift*boxzsize
2225 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
2226 if(dist_temp.lt.dist_init) then
2236 if (isubchap.eq.1) then
2245 rij=xj*xj+yj*yj+zj*zj
2248 sss=sscale(rij/rpp(iteli,itelj))
2249 sssgrad=sscagrad(rij/rpp(iteli,itelj))
2250 if (sss.gt.0.0d0) then
2255 c 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
2256 if (j.eq.i+2) ev1=scal_el*ev1
2259 if (energy_dec) then
2260 write (iout,'(a6,2i5,0pf7.3,f7.3)') 'evdw1',i,j,evdwij,sss
2262 evdw1=evdw1+evdwij*sss
2264 C Calculate contributions to the Cartesian gradient.
2266 facvdw=-6*rrmij*(ev1+evdwij)*sss
2267 ggg(1)=facvdw*xj+sssgrad*rmij*evdwij*xj/rpp(iteli,itelj)
2268 ggg(2)=facvdw*yj+sssgrad*rmij*evdwij*yj/rpp(iteli,itelj)
2269 ggg(3)=facvdw*zj+sssgrad*rmij*evdwij*zj/rpp(iteli,itelj)
2274 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
2275 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
2282 C-----------------------------------------------------------------------------
2283 subroutine escp_long(evdw2,evdw2_14)
2285 C This subroutine calculates the excluded-volume interaction energy between
2286 C peptide-group centers and side chains and its gradient in virtual-bond and
2287 C side-chain vectors.
2289 implicit real*8 (a-h,o-z)
2290 include 'DIMENSIONS'
2291 include 'COMMON.GEO'
2292 include 'COMMON.VAR'
2293 include 'COMMON.LOCAL'
2294 include 'COMMON.CHAIN'
2295 include 'COMMON.DERIV'
2296 include 'COMMON.INTERACT'
2297 include 'COMMON.FFIELD'
2298 include 'COMMON.IOUNITS'
2299 include 'COMMON.CONTROL'
2303 CD print '(a)','Enter ESCP KURWA'
2304 cd write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
2305 do i=iatscp_s,iatscp_e
2306 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1) cycle
2308 xi=0.5D0*(c(1,i)+c(1,i+1))
2309 yi=0.5D0*(c(2,i)+c(2,i+1))
2310 zi=0.5D0*(c(3,i)+c(3,i+1))
2312 if (xi.lt.0) xi=xi+boxxsize
2314 if (yi.lt.0) yi=yi+boxysize
2316 if (zi.lt.0) zi=zi+boxzsize
2317 do iint=1,nscp_gr(i)
2319 do j=iscpstart(i,iint),iscpend(i,iint)
2321 if (itypj.eq.ntyp1) cycle
2322 C Uncomment following three lines for SC-p interactions
2326 C Uncomment following three lines for Ca-p interactions
2330 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
2338 xj=xj_safe+xshift*boxxsize
2339 yj=yj_safe+yshift*boxysize
2340 zj=zj_safe+zshift*boxzsize
2341 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
2342 if(dist_temp.lt.dist_init) then
2352 if (subchap.eq.1) then
2362 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
2364 sss=sscale(1.0d0/(dsqrt(rrij)*rscp(itypj,iteli)))
2365 sssgrad=sscagrad(1.0d0/(dsqrt(rrij)*rscp(itypj,iteli)))
2366 if (sss.lt.1.0d0) then
2368 e1=fac*fac*aad(itypj,iteli)
2369 e2=fac*bad(itypj,iteli)
2370 if (iabs(j-i) .le. 2) then
2373 evdw2_14=evdw2_14+(e1+e2)*(1.0d0-sss)
2376 evdw2=evdw2+evdwij*(1.0d0-sss)
2377 if (energy_dec) write (iout,'(a6,2i5,2(0pf7.3))')
2378 & 'evdw2',i,j,sss,evdwij
2380 C Calculate contributions to the gradient in the virtual-bond and SC vectors.
2383 fac=-(evdwij+e1)*rrij*(1.0d0-sss)
2384 fac=fac-(evdwij)*sssgrad*dsqrt(rrij)/rscp(itypj,iteli)
2388 C Uncomment following three lines for SC-p interactions
2390 c gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
2392 C Uncomment following line for SC-p interactions
2393 c gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
2395 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
2396 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
2405 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
2406 gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
2407 gradx_scp(j,i)=expon*gradx_scp(j,i)
2410 C******************************************************************************
2414 C To save time the factor EXPON has been extracted from ALL components
2415 C of GVDWC and GRADX. Remember to multiply them by this factor before further
2418 C******************************************************************************
2421 C-----------------------------------------------------------------------------
2422 subroutine escp_short(evdw2,evdw2_14)
2424 C This subroutine calculates the excluded-volume interaction energy between
2425 C peptide-group centers and side chains and its gradient in virtual-bond and
2426 C side-chain vectors.
2428 implicit real*8 (a-h,o-z)
2429 include 'DIMENSIONS'
2430 include 'COMMON.GEO'
2431 include 'COMMON.VAR'
2432 include 'COMMON.LOCAL'
2433 include 'COMMON.CHAIN'
2434 include 'COMMON.DERIV'
2435 include 'COMMON.INTERACT'
2436 include 'COMMON.FFIELD'
2437 include 'COMMON.IOUNITS'
2438 include 'COMMON.CONTROL'
2442 cd print '(a)','Enter ESCP'
2443 cd write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
2444 do i=iatscp_s,iatscp_e
2445 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1) cycle
2447 xi=0.5D0*(c(1,i)+c(1,i+1))
2448 yi=0.5D0*(c(2,i)+c(2,i+1))
2449 zi=0.5D0*(c(3,i)+c(3,i+1))
2451 if (xi.lt.0) xi=xi+boxxsize
2453 if (yi.lt.0) yi=yi+boxysize
2455 if (zi.lt.0) zi=zi+boxzsize
2457 do iint=1,nscp_gr(i)
2459 do j=iscpstart(i,iint),iscpend(i,iint)
2461 if (itypj.eq.ntyp1) cycle
2462 C Uncomment following three lines for SC-p interactions
2466 C Uncomment following three lines for Ca-p interactions
2470 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
2478 xj=xj_safe+xshift*boxxsize
2479 yj=yj_safe+yshift*boxysize
2480 zj=zj_safe+zshift*boxzsize
2481 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
2482 if(dist_temp.lt.dist_init) then
2492 if (subchap.eq.1) then
2501 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
2502 sss=sscale(1.0d0/(dsqrt(rrij)*rscp(itypj,iteli)))
2503 sssgrad=sscagrad(1.0d0/(dsqrt(rrij)*rscp(itypj,iteli)))
2504 if (sss.gt.0.0d0) then
2507 e1=fac*fac*aad(itypj,iteli)
2508 e2=fac*bad(itypj,iteli)
2509 if (iabs(j-i) .le. 2) then
2512 evdw2_14=evdw2_14+(e1+e2)*sss
2515 evdw2=evdw2+evdwij*sss
2516 if (energy_dec) write (iout,'(a6,2i5,2(0pf7.3))')
2517 & 'evdw2',i,j,sss,evdwij
2519 C Calculate contributions to the gradient in the virtual-bond and SC vectors.
2521 fac=-(evdwij+e1)*rrij*sss
2522 fac=fac+(evdwij)*sssgrad*dsqrt(rrij)/rscp(itypj,iteli)
2526 C Uncomment following three lines for SC-p interactions
2528 c gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
2530 C Uncomment following line for SC-p interactions
2531 c gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
2533 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
2534 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
2543 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
2544 gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
2545 gradx_scp(j,i)=expon*gradx_scp(j,i)
2548 C******************************************************************************
2552 C To save time the factor EXPON has been extracted from ALL components
2553 C of GVDWC and GRADX. Remember to multiply them by this factor before further
2556 C******************************************************************************