1 subroutine etotal(energia,fact)
2 implicit real*8 (a-h,o-z)
4 include 'DIMENSIONS.ZSCOPT'
10 cMS$ATTRIBUTES C :: proc_proc
13 include 'COMMON.IOUNITS'
14 double precision energia(0:max_ene),energia1(0:max_ene+1)
20 include 'COMMON.FFIELD'
21 include 'COMMON.DERIV'
22 include 'COMMON.INTERACT'
23 include 'COMMON.SBRIDGE'
24 include 'COMMON.CHAIN'
25 double precision fact(6)
26 cd write(iout, '(a,i2)')'Calling etotal ipot=',ipot
27 cd print *,'nnt=',nnt,' nct=',nct
29 C Compute the side-chain and electrostatic interaction energy
31 goto (101,102,103,104,105,106) ipot
32 C Lennard-Jones potential.
33 101 call elj(evdw,evdw_t)
34 cd print '(a)','Exit ELJ'
36 C Lennard-Jones-Kihara potential (shifted).
37 102 call eljk(evdw,evdw_t)
39 C Berne-Pechukas potential (dilated LJ, angular dependence).
40 103 call ebp(evdw,evdw_t)
42 C Gay-Berne potential (shifted LJ, angular dependence).
43 104 call egb(evdw,evdw_t)
45 C Gay-Berne-Vorobjev potential (shifted LJ, angular dependence).
46 105 call egbv(evdw,evdw_t)
49 106 call emomo(evdw,evdw_p,evdw_m)
51 C Calculate electrostatic (H-bonding) energy of the main chain.
53 107 call eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
55 C Calculate excluded-volume interaction energy between peptide groups
58 call escp(evdw2,evdw2_14)
60 c Calculate the bond-stretching energy
63 c write (iout,*) "estr",estr
65 C Calculate the disulfide-bridge and other energy and the contributions
66 C from other distance constraints.
67 cd print *,'Calling EHPB'
69 cd print *,'EHPB exitted succesfully.'
71 C Calculate the virtual-bond-angle energy.
74 cd print *,'Bend energy finished.'
76 C Calculate the SC local energy.
79 cd print *,'SCLOC energy finished.'
81 C Calculate the virtual-bond torsional energy.
83 cd print *,'nterm=',nterm
84 call etor(etors,edihcnstr,fact(1))
86 C 6/23/01 Calculate double-torsional energy
88 call etor_d(etors_d,fact(2))
90 C 21/5/07 Calculate local sicdechain correlation energy
92 call eback_sc_corr(esccor)
94 C 12/1/95 Multi-body terms
98 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0
99 & .or. wturn6.gt.0.0d0) then
100 c print *,"calling multibody_eello"
101 call multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
102 c write (*,*) 'n_corr=',n_corr,' n_corr1=',n_corr1
103 c print *,ecorr,ecorr5,ecorr6,eturn6
105 if (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) then
106 call multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
108 c write (iout,*) "ft(6)",fact(6)," evdw",evdw," evdw_t",evdw_t
110 etot=wsc*(evdw+fact(6)*evdw_t)+wscp*evdw2+welec*fact(1)*ees
112 & +wang*ebe+wtor*fact(1)*etors+wscloc*escloc
113 & +wstrain*ehpb+nss*ebr+wcorr*fact(3)*ecorr+wcorr5*fact(4)*ecorr5
114 & +wcorr6*fact(5)*ecorr6+wturn4*fact(3)*eello_turn4
115 & +wturn3*fact(2)*eello_turn3+wturn6*fact(5)*eturn6
116 & +wel_loc*fact(2)*eel_loc+edihcnstr+wtor_d*fact(2)*etors_d
117 & +wbond*estr+wsccor*fact(1)*esccor
119 etot=wsc*(evdw+fact(6)*evdw_t)+wscp*evdw2
120 & +welec*fact(1)*(ees+evdw1)
121 & +wang*ebe+wtor*fact(1)*etors+wscloc*escloc
122 & +wstrain*ehpb+nss*ebr+wcorr*fact(3)*ecorr+wcorr5*fact(4)*ecorr5
123 & +wcorr6*fact(5)*ecorr6+wturn4*fact(3)*eello_turn4
124 & +wturn3*fact(2)*eello_turn3+wturn6*fact(5)*eturn6
125 & +wel_loc*fact(2)*eel_loc+edihcnstr+wtor_d*fact(2)*etors_d
126 & +wbond*estr+wsccor*fact(1)*esccor
131 energia(2)=evdw2-evdw2_14
148 energia(8)=eello_turn3
149 energia(9)=eello_turn4
158 energia(20)=edihcnstr
163 if (isnan(etot).ne.0) energia(0)=1.0d+99
165 if (isnan(etot)) energia(0)=1.0d+99
170 idumm=proc_proc(etot,i)
172 call proc_proc(etot,i)
174 if(i.eq.1)energia(0)=1.0d+99
181 C Sum up the components of the Cartesian gradient.
186 gradc(j,i,icg)=wsc*gvdwc(j,i)+wscp*gvdwc_scp(j,i)+
187 & welec*fact(1)*gelc(j,i)+wvdwpp*gvdwpp(j,i)+
189 & wstrain*ghpbc(j,i)+
190 & wcorr*fact(3)*gradcorr(j,i)+
191 & wel_loc*fact(2)*gel_loc(j,i)+
192 & wturn3*fact(2)*gcorr3_turn(j,i)+
193 & wturn4*fact(3)*gcorr4_turn(j,i)+
194 & wcorr5*fact(4)*gradcorr5(j,i)+
195 & wcorr6*fact(5)*gradcorr6(j,i)+
196 & wturn6*fact(5)*gcorr6_turn(j,i)+
197 & wsccor*fact(2)*gsccorc(j,i)
198 gradx(j,i,icg)=wsc*gvdwx(j,i)+wscp*gradx_scp(j,i)+
200 & wstrain*ghpbx(j,i)+wcorr*gradxorr(j,i)+
201 & wsccor*fact(2)*gsccorx(j,i)
206 gradc(j,i,icg)=wsc*gvdwc(j,i)+wscp*gvdwc_scp(j,i)+
207 & welec*fact(1)*gelc(j,i)+wstrain*ghpbc(j,i)+
209 & wcorr*fact(3)*gradcorr(j,i)+
210 & wel_loc*fact(2)*gel_loc(j,i)+
211 & wturn3*fact(2)*gcorr3_turn(j,i)+
212 & wturn4*fact(3)*gcorr4_turn(j,i)+
213 & wcorr5*fact(4)*gradcorr5(j,i)+
214 & wcorr6*fact(5)*gradcorr6(j,i)+
215 & wturn6*fact(5)*gcorr6_turn(j,i)+
216 & wsccor*fact(2)*gsccorc(j,i)
217 gradx(j,i,icg)=wsc*gvdwx(j,i)+wscp*gradx_scp(j,i)+
219 & wstrain*ghpbx(j,i)+wcorr*gradxorr(j,i)+
220 & wsccor*fact(1)*gsccorx(j,i)
227 gloc(i,icg)=gloc(i,icg)+wcorr*fact(3)*gcorr_loc(i)
228 & +wcorr5*fact(4)*g_corr5_loc(i)
229 & +wcorr6*fact(5)*g_corr6_loc(i)
230 & +wturn4*fact(3)*gel_loc_turn4(i)
231 & +wturn3*fact(2)*gel_loc_turn3(i)
232 & +wturn6*fact(5)*gel_loc_turn6(i)
233 & +wel_loc*fact(2)*gel_loc_loc(i)
234 & +wsccor*fact(1)*gsccor_loc(i)
239 C------------------------------------------------------------------------
240 subroutine enerprint(energia,fact)
241 implicit real*8 (a-h,o-z)
243 include 'DIMENSIONS.ZSCOPT'
244 include 'COMMON.IOUNITS'
245 include 'COMMON.FFIELD'
246 include 'COMMON.SBRIDGE'
247 double precision energia(0:max_ene),fact(6)
249 evdw=energia(1)+fact(6)*energia(21)
251 evdw2=energia(2)+energia(17)
263 eello_turn3=energia(8)
264 eello_turn4=energia(9)
265 eello_turn6=energia(10)
272 edihcnstr=energia(20)
275 write (iout,10) evdw,wsc,evdw2,wscp,ees,welec*fact(1),evdw1,
277 & estr,wbond,ebe,wang,escloc,wscloc,etors,wtor*fact(1),
278 & etors_d,wtor_d*fact(2),ehpb,wstrain,
279 & ecorr,wcorr*fact(3),ecorr5,wcorr5*fact(4),ecorr6,wcorr6*fact(5),
280 & eel_loc,wel_loc*fact(2),eello_turn3,wturn3*fact(2),
281 & eello_turn4,wturn4*fact(3),eello_turn6,wturn6*fact(5),
282 & esccor,wsccor*fact(1),edihcnstr,ebr*nss,etot
283 10 format (/'Virtual-chain energies:'//
284 & 'EVDW= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-SC)'/
285 & 'EVDW2= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-p)'/
286 & 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p elec)'/
287 & 'EVDWPP=',1pE16.6,' WEIGHT=',1pD16.6,' (p-p VDW)'/
288 & 'ESTR= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching)'/
289 & 'EBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (bending)'/
290 & 'ESC= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/
291 & 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/
292 & 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/
293 & 'EHBP= ',1pE16.6,' WEIGHT=',1pD16.6,
294 & ' (SS bridges & dist. cnstr.)'/
295 & 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
296 & 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
297 & 'ECORR6=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
298 & 'EELLO= ',1pE16.6,' WEIGHT=',1pD16.6,' (electrostatic-local)'/
299 & 'ETURN3=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 3rd order)'/
300 & 'ETURN4=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 4th order)'/
301 & 'ETURN6=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 6th order)'/
302 & 'ESCCOR=',1pE16.6,' WEIGHT=',1pD16.6,' (backbone-rotamer corr)'/
303 & 'EDIHC= ',1pE16.6,' (dihedral angle constraints)'/
304 & 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/
305 & 'ETOT= ',1pE16.6,' (total)')
307 write (iout,10) evdw,wsc,evdw2,wscp,ees,welec*fact(1),estr,wbond,
308 & ebe,wang,escloc,wscloc,etors,wtor*fact(1),etors_d,wtor_d*fact2,
309 & ehpb,wstrain,ecorr,wcorr*fact(3),ecorr5,wcorr5*fact(4),
310 & ecorr6,wcorr6*fact(5),eel_loc,wel_loc*fact(2),
311 & eello_turn3,wturn3*fact(2),eello_turn4,wturn4*fact(3),
312 & eello_turn6,wturn6*fact(5),esccor*fact(1),wsccor,
313 & edihcnstr,ebr*nss,etot
314 10 format (/'Virtual-chain energies:'//
315 & 'EVDW= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-SC)'/
316 & 'EVDW2= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-p)'/
317 & 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p)'/
318 & 'ESTR= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching)'/
319 & 'EBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (bending)'/
320 & 'ESC= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/
321 & 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/
322 & 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/
323 & 'EHBP= ',1pE16.6,' WEIGHT=',1pD16.6,
324 & ' (SS bridges & dist. cnstr.)'/
325 & 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
326 & 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
327 & 'ECORR6=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
328 & 'EELLO= ',1pE16.6,' WEIGHT=',1pD16.6,' (electrostatic-local)'/
329 & 'ETURN3=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 3rd order)'/
330 & 'ETURN4=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 4th order)'/
331 & 'ETURN6=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 6th order)'/
332 & 'ESCCOR=',1pE16.6,' WEIGHT=',1pD16.6,' (backbone-rotamer corr)'/
333 & 'EDIHC= ',1pE16.6,' (dihedral angle constraints)'/
334 & 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/
335 & 'ETOT= ',1pE16.6,' (total)')
339 C-----------------------------------------------------------------------
340 subroutine elj(evdw,evdw_t)
342 C This subroutine calculates the interaction energy of nonbonded side chains
343 C assuming the LJ potential of interaction.
345 implicit real*8 (a-h,o-z)
347 include 'DIMENSIONS.ZSCOPT'
348 include "DIMENSIONS.COMPAR"
349 parameter (accur=1.0d-10)
352 include 'COMMON.LOCAL'
353 include 'COMMON.CHAIN'
354 include 'COMMON.DERIV'
355 include 'COMMON.INTERACT'
356 include 'COMMON.TORSION'
357 include 'COMMON.ENEPS'
358 include 'COMMON.SBRIDGE'
359 include 'COMMON.NAMES'
360 include 'COMMON.IOUNITS'
361 include 'COMMON.CONTACTS'
365 cd print *,'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
368 eneps_temp(j,i)=0.0d0
382 C Calculate SC interaction energy.
385 cd write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
386 cd & 'iend=',iend(i,iint)
387 do j=istart(i,iint),iend(i,iint)
392 C Change 12/1/95 to calculate four-body interactions
393 rij=xj*xj+yj*yj+zj*zj
395 c write (iout,*)'i=',i,' j=',j,' itypi=',itypi,' itypj=',itypj
396 eps0ij=eps(itypi,itypj)
398 e1=fac*fac*aa(itypi,itypj)
399 e2=fac*bb(itypi,itypj)
401 ij=icant(itypi,itypj)
402 eneps_temp(1,ij)=eneps_temp(1,ij)+e1/dabs(eps0ij)
403 eneps_temp(2,ij)=eneps_temp(2,ij)+e2/eps0ij
404 cd sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
405 cd epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
406 cd write (iout,'(2(a3,i3,2x),6(1pd12.4)/2(3(1pd12.4),5x)/)')
407 cd & restyp(itypi),i,restyp(itypj),j,aa(itypi,itypj),
408 cd & bb(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,epsi,sigm,
409 cd & (c(k,i),k=1,3),(c(k,j),k=1,3)
410 if (bb(itypi,itypj).gt.0.0d0) then
417 C Calculate the components of the gradient in DC and X
419 fac=-rrij*(e1+evdwij)
424 gvdwx(k,i)=gvdwx(k,i)-gg(k)
425 gvdwx(k,j)=gvdwx(k,j)+gg(k)
429 gvdwc(l,k)=gvdwc(l,k)+gg(l)
434 C 12/1/95, revised on 5/20/97
436 C Calculate the contact function. The ith column of the array JCONT will
437 C contain the numbers of atoms that make contacts with the atom I (of numbers
438 C greater than I). The arrays FACONT and GACONT will contain the values of
439 C the contact function and its derivative.
441 C Uncomment next line, if the correlation interactions include EVDW explicitly.
442 c if (j.gt.i+1 .and. evdwij.le.0.0D0) then
443 C Uncomment next line, if the correlation interactions are contact function only
444 if (j.gt.i+1.and. eps0ij.gt.0.0D0) then
446 sigij=sigma(itypi,itypj)
447 r0ij=rs0(itypi,itypj)
449 C Check whether the SC's are not too far to make a contact.
452 call gcont(rij,rcut,1.0d0,0.2d0*rcut,fcont,fprimcont)
453 C Add a new contact, if the SC's are close enough, but not too close (r<sigma).
455 if (fcont.gt.0.0D0) then
456 C If the SC-SC distance if close to sigma, apply spline.
457 cAdam call gcont(-rij,-1.03d0*sigij,2.0d0*sigij,1.0d0,
458 cAdam & fcont1,fprimcont1)
459 cAdam fcont1=1.0d0-fcont1
460 cAdam if (fcont1.gt.0.0d0) then
461 cAdam fprimcont=fprimcont*fcont1+fcont*fprimcont1
462 cAdam fcont=fcont*fcont1
464 C Uncomment following 4 lines to have the geometric average of the epsilon0's
465 cga eps0ij=1.0d0/dsqrt(eps0ij)
467 cga gg(k)=gg(k)*eps0ij
469 cga eps0ij=-evdwij*eps0ij
470 C Uncomment for AL's type of SC correlation interactions.
472 num_conti=num_conti+1
474 facont(num_conti,i)=fcont*eps0ij
475 fprimcont=eps0ij*fprimcont/rij
477 cAdam gacont(1,num_conti,i)=-fprimcont*xj+fcont*gg(1)
478 cAdam gacont(2,num_conti,i)=-fprimcont*yj+fcont*gg(2)
479 cAdam gacont(3,num_conti,i)=-fprimcont*zj+fcont*gg(3)
480 C Uncomment following 3 lines for Skolnick's type of SC correlation.
481 gacont(1,num_conti,i)=-fprimcont*xj
482 gacont(2,num_conti,i)=-fprimcont*yj
483 gacont(3,num_conti,i)=-fprimcont*zj
484 cd write (iout,'(2i5,2f10.5)') i,j,rij,facont(num_conti,i)
485 cd write (iout,'(2i3,3f10.5)')
486 cd & i,j,(gacont(kk,num_conti,i),kk=1,3)
492 num_cont(i)=num_conti
497 gvdwc(j,i)=expon*gvdwc(j,i)
498 gvdwx(j,i)=expon*gvdwx(j,i)
502 C******************************************************************************
506 C To save time, the factor of EXPON has been extracted from ALL components
507 C of GVDWC and GRADX. Remember to multiply them by this factor before further
510 C******************************************************************************
513 C-----------------------------------------------------------------------------
514 subroutine eljk(evdw,evdw_t)
516 C This subroutine calculates the interaction energy of nonbonded side chains
517 C assuming the LJK potential of interaction.
519 implicit real*8 (a-h,o-z)
521 include 'DIMENSIONS.ZSCOPT'
522 include "DIMENSIONS.COMPAR"
525 include 'COMMON.LOCAL'
526 include 'COMMON.CHAIN'
527 include 'COMMON.DERIV'
528 include 'COMMON.INTERACT'
529 include 'COMMON.ENEPS'
530 include 'COMMON.IOUNITS'
531 include 'COMMON.NAMES'
536 c print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
539 eneps_temp(j,i)=0.0d0
551 C Calculate SC interaction energy.
554 do j=istart(i,iint),iend(i,iint)
559 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
561 e_augm=augm(itypi,itypj)*fac_augm
564 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
565 fac=r_shift_inv**expon
566 e1=fac*fac*aa(itypi,itypj)
567 e2=fac*bb(itypi,itypj)
569 ij=icant(itypi,itypj)
570 eneps_temp(1,ij)=eneps_temp(1,ij)+(e1+a_augm)
571 & /dabs(eps(itypi,itypj))
572 eneps_temp(2,ij)=eneps_temp(2,ij)+e2/eps(itypi,itypj)
573 cd sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
574 cd epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
575 cd write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
576 cd & restyp(itypi),i,restyp(itypj),j,aa(itypi,itypj),
577 cd & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
578 cd & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
579 cd & (c(k,i),k=1,3),(c(k,j),k=1,3)
580 if (bb(itypi,itypj).gt.0.0d0) then
587 C Calculate the components of the gradient in DC and X
589 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
594 gvdwx(k,i)=gvdwx(k,i)-gg(k)
595 gvdwx(k,j)=gvdwx(k,j)+gg(k)
599 gvdwc(l,k)=gvdwc(l,k)+gg(l)
609 gvdwc(j,i)=expon*gvdwc(j,i)
610 gvdwx(j,i)=expon*gvdwx(j,i)
616 C-----------------------------------------------------------------------------
617 subroutine ebp(evdw,evdw_t)
619 C This subroutine calculates the interaction energy of nonbonded side chains
620 C assuming the Berne-Pechukas potential of interaction.
622 implicit real*8 (a-h,o-z)
624 include 'DIMENSIONS.ZSCOPT'
625 include "DIMENSIONS.COMPAR"
628 include 'COMMON.LOCAL'
629 include 'COMMON.CHAIN'
630 include 'COMMON.DERIV'
631 include 'COMMON.NAMES'
632 include 'COMMON.INTERACT'
633 include 'COMMON.ENEPS'
634 include 'COMMON.IOUNITS'
635 include 'COMMON.CALC'
637 c double precision rrsave(maxdim)
643 eneps_temp(j,i)=0.0d0
648 c print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
649 c if (icall.eq.0) then
661 dxi=dc_norm(1,nres+i)
662 dyi=dc_norm(2,nres+i)
663 dzi=dc_norm(3,nres+i)
664 dsci_inv=vbld_inv(i+nres)
666 C Calculate SC interaction energy.
669 do j=istart(i,iint),iend(i,iint)
672 dscj_inv=vbld_inv(j+nres)
673 chi1=chi(itypi,itypj)
674 chi2=chi(itypj,itypi)
681 alf12=0.5D0*(alf1+alf2)
682 C For diagnostics only!!!
695 dxj=dc_norm(1,nres+j)
696 dyj=dc_norm(2,nres+j)
697 dzj=dc_norm(3,nres+j)
698 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
699 cd if (icall.eq.0) then
705 C Calculate the angle-dependent terms of energy & contributions to derivatives.
707 C Calculate whole angle-dependent part of epsilon and contributions
709 fac=(rrij*sigsq)**expon2
710 e1=fac*fac*aa(itypi,itypj)
711 e2=fac*bb(itypi,itypj)
712 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
713 eps2der=evdwij*eps3rt
714 eps3der=evdwij*eps2rt
715 evdwij=evdwij*eps2rt*eps3rt
716 ij=icant(itypi,itypj)
717 aux=eps1*eps2rt**2*eps3rt**2
718 eneps_temp(1,ij)=eneps_temp(1,ij)+e1*aux
719 & /dabs(eps(itypi,itypj))
720 eneps_temp(2,ij)=eneps_temp(2,ij)+e2*aux/eps(itypi,itypj)
721 if (bb(itypi,itypj).gt.0.0d0) then
728 sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
729 epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
730 cd write (iout,'(2(a3,i3,2x),15(0pf7.3))')
731 cd & restyp(itypi),i,restyp(itypj),j,
732 cd & epsi,sigm,chi1,chi2,chip1,chip2,
733 cd & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
734 cd & om1,om2,om12,1.0D0/dsqrt(rrij),
737 C Calculate gradient components.
738 e1=e1*eps1*eps2rt**2*eps3rt**2
739 fac=-expon*(e1+evdwij)
742 C Calculate radial part of the gradient
746 C Calculate the angular part of the gradient and sum add the contributions
747 C to the appropriate components of the Cartesian gradient.
756 C-----------------------------------------------------------------------------
757 subroutine egb(evdw,evdw_t)
759 C This subroutine calculates the interaction energy of nonbonded side chains
760 C assuming the Gay-Berne potential of interaction.
762 implicit real*8 (a-h,o-z)
764 include 'DIMENSIONS.ZSCOPT'
765 include "DIMENSIONS.COMPAR"
768 include 'COMMON.LOCAL'
769 include 'COMMON.CHAIN'
770 include 'COMMON.DERIV'
771 include 'COMMON.NAMES'
772 include 'COMMON.INTERACT'
773 include 'COMMON.ENEPS'
774 include 'COMMON.IOUNITS'
775 include 'COMMON.CALC'
782 eneps_temp(j,i)=0.0d0
785 c print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
789 c if (icall.gt.0) lprn=.true.
797 dxi=dc_norm(1,nres+i)
798 dyi=dc_norm(2,nres+i)
799 dzi=dc_norm(3,nres+i)
800 dsci_inv=vbld_inv(i+nres)
802 C Calculate SC interaction energy.
805 do j=istart(i,iint),iend(i,iint)
808 dscj_inv=vbld_inv(j+nres)
809 sig0ij=sigma(itypi,itypj)
810 chi1=chi(itypi,itypj)
811 chi2=chi(itypj,itypi)
818 alf12=0.5D0*(alf1+alf2)
819 C For diagnostics only!!!
832 dxj=dc_norm(1,nres+j)
833 dyj=dc_norm(2,nres+j)
834 dzj=dc_norm(3,nres+j)
835 c write (iout,*) i,j,xj,yj,zj
836 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
838 C Calculate angle-dependent terms of energy and contributions to their
842 sig=sig0ij*dsqrt(sigsq)
843 rij_shift=1.0D0/rij-sig+sig0ij
844 C I hate to put IF's in the loops, but here don't have another choice!!!!
845 if (rij_shift.le.0.0D0) then
850 c---------------------------------------------------------------
851 rij_shift=1.0D0/rij_shift
853 e1=fac*fac*aa(itypi,itypj)
854 e2=fac*bb(itypi,itypj)
855 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
856 eps2der=evdwij*eps3rt
857 eps3der=evdwij*eps2rt
858 evdwij=evdwij*eps2rt*eps3rt
859 if (bb(itypi,itypj).gt.0) then
864 ij=icant(itypi,itypj)
865 aux=eps1*eps2rt**2*eps3rt**2
866 eneps_temp(1,ij)=eneps_temp(1,ij)+aux*e1
867 & /dabs(eps(itypi,itypj))
868 eneps_temp(2,ij)=eneps_temp(2,ij)+aux*e2/eps(itypi,itypj)
869 c write (iout,*) "i",i," j",j," itypi",itypi," itypj",itypj,
870 c & " ij",ij," eneps",aux*e1/dabs(eps(itypi,itypj)),
871 c & aux*e2/eps(itypi,itypj)
873 sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
874 epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
875 write (iout,'(2(a3,i3,2x),17(0pf7.3))')
876 & restyp(itypi),i,restyp(itypj),j,
877 & epsi,sigm,chi1,chi2,chip1,chip2,
878 & eps1,eps2rt**2,eps3rt**2,sig,sig0ij,
879 & om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,
883 C Calculate gradient components.
884 e1=e1*eps1*eps2rt**2*eps3rt**2
885 fac=-expon*(e1+evdwij)*rij_shift
888 C Calculate the radial part of the gradient
892 C Calculate angular part of the gradient.
900 C-----------------------------------------------------------------------------
901 subroutine egbv(evdw,evdw_t)
903 C This subroutine calculates the interaction energy of nonbonded side chains
904 C assuming the Gay-Berne-Vorobjev potential of interaction.
906 implicit real*8 (a-h,o-z)
908 include 'DIMENSIONS.ZSCOPT'
909 include "DIMENSIONS.COMPAR"
912 include 'COMMON.LOCAL'
913 include 'COMMON.CHAIN'
914 include 'COMMON.DERIV'
915 include 'COMMON.NAMES'
916 include 'COMMON.INTERACT'
917 include 'COMMON.ENEPS'
918 include 'COMMON.IOUNITS'
919 include 'COMMON.CALC'
926 eneps_temp(j,i)=0.0d0
931 c print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
934 c if (icall.gt.0) lprn=.true.
942 dxi=dc_norm(1,nres+i)
943 dyi=dc_norm(2,nres+i)
944 dzi=dc_norm(3,nres+i)
945 dsci_inv=vbld_inv(i+nres)
947 C Calculate SC interaction energy.
950 do j=istart(i,iint),iend(i,iint)
953 dscj_inv=vbld_inv(j+nres)
954 sig0ij=sigma(itypi,itypj)
956 chi1=chi(itypi,itypj)
957 chi2=chi(itypj,itypi)
964 alf12=0.5D0*(alf1+alf2)
965 C For diagnostics only!!!
978 dxj=dc_norm(1,nres+j)
979 dyj=dc_norm(2,nres+j)
980 dzj=dc_norm(3,nres+j)
981 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
983 C Calculate angle-dependent terms of energy and contributions to their
987 sig=sig0ij*dsqrt(sigsq)
988 rij_shift=1.0D0/rij-sig+r0ij
989 C I hate to put IF's in the loops, but here don't have another choice!!!!
990 if (rij_shift.le.0.0D0) then
995 c---------------------------------------------------------------
996 rij_shift=1.0D0/rij_shift
998 e1=fac*fac*aa(itypi,itypj)
999 e2=fac*bb(itypi,itypj)
1000 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
1001 eps2der=evdwij*eps3rt
1002 eps3der=evdwij*eps2rt
1003 fac_augm=rrij**expon
1004 e_augm=augm(itypi,itypj)*fac_augm
1005 evdwij=evdwij*eps2rt*eps3rt
1006 if (bb(itypi,itypj).gt.0.0d0) then
1007 evdw=evdw+evdwij+e_augm
1009 evdw_t=evdw_t+evdwij+e_augm
1011 ij=icant(itypi,itypj)
1012 aux=eps1*eps2rt**2*eps3rt**2
1013 eneps_temp(1,ij)=eneps_temp(1,ij)+aux*(e1+e_augm)
1014 & /dabs(eps(itypi,itypj))
1015 eneps_temp(2,ij)=eneps_temp(2,ij)+aux*e2/eps(itypi,itypj)
1016 c eneps_temp(ij)=eneps_temp(ij)
1017 c & +(evdwij+e_augm)/eps(itypi,itypj)
1019 c sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1020 c epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1021 c write (iout,'(2(a3,i3,2x),17(0pf7.3))')
1022 c & restyp(itypi),i,restyp(itypj),j,
1023 c & epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),
1024 c & chi1,chi2,chip1,chip2,
1025 c & eps1,eps2rt**2,eps3rt**2,
1026 c & om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,
1030 C Calculate gradient components.
1031 e1=e1*eps1*eps2rt**2*eps3rt**2
1032 fac=-expon*(e1+evdwij)*rij_shift
1034 fac=rij*fac-2*expon*rrij*e_augm
1035 C Calculate the radial part of the gradient
1039 C Calculate angular part of the gradient.
1047 C-----------------------------------------------------------------------------
1050 SUBROUTINE emomo(evdw,evdw_p,evdw_m)
1052 C This subroutine calculates the interaction energy of nonbonded side chains
1053 C assuming the Gay-Berne potential of interaction.
1056 INCLUDE 'DIMENSIONS'
1057 INCLUDE 'DIMENSIONS.ZSCOPT'
1058 INCLUDE 'COMMON.CALC'
1059 INCLUDE 'COMMON.CONTROL'
1060 INCLUDE 'COMMON.CHAIN'
1061 INCLUDE 'COMMON.DERIV'
1062 INCLUDE 'COMMON.EMP'
1063 INCLUDE 'COMMON.GEO'
1064 INCLUDE 'COMMON.INTERACT'
1065 INCLUDE 'COMMON.IOUNITS'
1066 INCLUDE 'COMMON.LOCAL'
1067 INCLUDE 'COMMON.NAMES'
1068 INCLUDE 'COMMON.VAR'
1070 double precision scalar
1071 double precision ener(4)
1075 IF (energy_dec) write (iout,'(a)')
1076 & ' AAi i AAj j 1/rij Rtail Rhead evdwij Fcav Ecl
1077 & Egb Epol Fisocav Elj Equad evdw'
1082 ccccc energy_dec=.false.
1083 c print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
1085 c if (icall.eq.0) lprn=.false.
1088 DO i = iatsc_s, iatsc_e
1090 c itypi1 = itype(i+1)
1091 dxi = dc_norm(1,nres+i)
1092 dyi = dc_norm(2,nres+i)
1093 dzi = dc_norm(3,nres+i)
1094 c dsci_inv=dsc_inv(itypi)
1095 dsci_inv = vbld_inv(i+nres)
1097 c ctail(k,1) = c(k, i+nres)
1098 c & - dtail(1,itypi,itypj) * dc_norm(k, nres+i)
1103 c!-------------------------------------------------------------------
1104 C Calculate SC interaction energy.
1105 DO iint = 1, nint_gr(i)
1106 DO j = istart(i,iint), iend(i,iint)
1107 c! initialize variables for electrostatic gradients
1108 CALL elgrad_init(eheadtail,Egb,Ecl,Elj,Equad,Epol)
1110 c dscj_inv = dsc_inv(itypj)
1111 dscj_inv = vbld_inv(j+nres)
1112 c! rij holds 1/(distance of Calpha atoms)
1113 rrij = 1.0D0 / ( xj*xj + yj*yj + zj*zj)
1115 c!-------------------------------------------------------------------
1116 C Calculate angle-dependent terms of energy and contributions to their
1120 c! DO troll = 10, 5000
1124 c! sqom1 = om1 * om1
1125 c! sqom2 = om2 * om2
1126 c! sqom12 = om12 * om12
1127 c! rij = 5.0d0 / troll
1129 c! Rtail = troll / 5.0d0
1130 c! Rhead = troll / 5.0d0
1131 c! Rhead = dsqrt((Rtail**2)+((dabs(d1-d2))**2))
1132 c! Rtail = dsqrt((Rtail**2)
1133 c! & +((dabs(dtail(1,itypi,itypj)-dtail(2,itypi,itypj)))**2))
1134 c! rij = 1.0d0/Rtail
1138 c! this should be in elgrad_init but om's are calculated by sc_angular
1139 c! which in turn is used by older potentials
1140 c! which proves how tangled UNRES code is >.<
1141 c! om = omega, sqom = om^2
1144 sqom12 = om12 * om12
1146 c! now we calculate EGB - Gey-Berne
1147 c! It will be summed up in evdwij and saved in evdw
1148 sigsq = 1.0D0 / sigsq
1149 sig = sig0ij * dsqrt(sigsq)
1150 c! rij_shift = 1.0D0 / rij - sig + sig0ij
1151 rij_shift = Rtail - sig + sig0ij
1152 c write (2,*) "Rtal",Rtail," sig",sig," sigsq",sigsq,
1153 c & " sig0ij",sig0ij
1154 c write (2,*) "rij_shift",rij_shift
1155 IF (rij_shift.le.0.0D0) THEN
1159 sigder = -sig * sigsq
1160 rij_shift = 1.0D0 / rij_shift
1161 fac = rij_shift**expon
1162 c1 = fac * fac * aa(itypi,itypj)
1164 c2 = fac * bb(itypi,itypj)
1166 c write (2,*) "eps1",eps1," eps2rt",eps2rt," eps3rt",eps3rt,
1167 c & " c1",c1," c2",c2
1168 evdwij = eps1 * eps2rt * eps3rt * ( c1 + c2 )
1169 eps2der = eps3rt * evdwij
1170 eps3der = eps2rt * evdwij
1171 c! evdwij = 4.0d0 * eps2rt * eps3rt * evdwij
1172 evdwij = eps2rt * eps3rt * evdwij
1174 c! write (*,*) "Gey Berne = ", evdwij
1176 IF (bb(itypi,itypj).gt.0) THEN
1177 evdw_p = evdw_p + evdwij
1179 evdw_m = evdw_m + evdwij
1185 c!-------------------------------------------------------------------
1186 c! Calculate some components of GGB
1187 c1 = c1 * eps1 * eps2rt**2 * eps3rt**2
1188 fac = -expon * (c1 + evdwij) * rij_shift
1189 sigder = fac * sigder
1191 c! Calculate distance derivative
1198 c! write (*,*) "gg(1) = ", gg(1)
1199 c! write (*,*) "gg(2) = ", gg(2)
1200 c! write (*,*) "gg(3) = ", gg(3)
1201 c! The angular derivatives of GGB are brought together in sc_grad
1202 c!-------------------------------------------------------------------
1205 c! Catch gly-gly interactions to skip calculation of something that
1208 IF (itypi.eq.10.and.itypj.eq.10) THEN
1216 c! we are not 2 glycines, so we calculate Fcav (and maybe more)
1217 fac = chis1 * sqom1 + chis2 * sqom2
1218 & - 2.0d0 * chis12 * om1 * om2 * om12
1219 c! we will use pom later in Gcav, so dont mess with it!
1220 pom = 1.0d0 - chis1 * chis2 * sqom12
1222 Lambf = (1.0d0 - (fac / pom))
1223 Lambf = dsqrt(Lambf)
1226 sparrow = 1.0d0 / dsqrt(sig1**2.0d0 + sig2**2.0d0)
1227 c! write (*,*) "sparrow = ", sparrow
1228 Chif = Rtail * sparrow
1229 ChiLambf = Chif * Lambf
1230 eagle = dsqrt(ChiLambf)
1231 bat = ChiLambf ** 11.0d0
1233 top = b1 * ( eagle + b2 * ChiLambf - b3 )
1234 bot = 1.0d0 + b4 * (ChiLambf ** 12.0d0)
1237 c! write (*,*) "sig1 = ",sig1
1238 c! write (*,*) "sig2 = ",sig2
1239 c! write (*,*) "Rtail = ",Rtail
1240 c! write (*,*) "sparrow = ",sparrow
1241 c! write (*,*) "Chis1 = ", chis1
1242 c! write (*,*) "Chis2 = ", chis2
1243 c! write (*,*) "Chis12 = ", chis12
1244 c! write (*,*) "om1 = ", om1
1245 c! write (*,*) "om2 = ", om2
1246 c! write (*,*) "om12 = ", om12
1247 c! write (*,*) "sqom1 = ", sqom1
1248 c! write (*,*) "sqom2 = ", sqom2
1249 c! write (*,*) "sqom12 = ", sqom12
1250 c! write (*,*) "Lambf = ",Lambf
1251 c! write (*,*) "b1 = ",b1
1252 c! write (*,*) "b2 = ",b2
1253 c! write (*,*) "b3 = ",b3
1254 c! write (*,*) "b4 = ",b4
1255 c! write (*,*) "top = ",top
1256 c! write (*,*) "bot = ",bot
1259 c! write (*,*) "Fcav = ", Fcav
1260 c!-------------------------------------------------------------------
1261 c! derivative of Fcav is Gcav...
1262 c!---------------------------------------------------
1264 dtop = b1 * ((Lambf / (2.0d0 * eagle)) + (b2 * Lambf))
1265 dbot = 12.0d0 * b4 * bat * Lambf
1266 dFdR = ((dtop * bot - top * dbot) / botsq) * sparrow
1268 c! write (*,*) "dFcav/dR = ", dFdR
1270 dtop = b1 * ((Chif / (2.0d0 * eagle)) + (b2 * Chif))
1271 dbot = 12.0d0 * b4 * bat * Chif
1273 dFdOM1 = -(chis1 * om1 - chis12 * om2 * om12) / (eagle)
1274 dFdOM2 = -(chis2 * om2 - chis12 * om1 * om12) / (eagle)
1275 dFdOM12 = chis12 * (chis1 * om1 * om12 - om2)
1276 & * (chis2 * om2 * om12 - om1) / (eagle * pom)
1278 dFdL = ((dtop * bot - top * dbot) / botsq)
1280 dCAVdOM1 = dFdL * ( dFdOM1 )
1281 dCAVdOM2 = dFdL * ( dFdOM2 )
1282 dCAVdOM12 = dFdL * ( dFdOM12 )
1283 c! write (*,*) "dFcav/dOM1 = ", dCAVdOM1
1284 c! write (*,*) "dFcav/dOM2 = ", dCAVdOM2
1285 c! write (*,*) "dFcav/dOM12 = ", dCAVdOM12
1287 c!-------------------------------------------------------------------
1288 c! Finally, add the distance derivatives of GB and Fcav to gvdwc
1289 c! Pom is used here to project the gradient vector into
1290 c! cartesian coordinates and at the same time contains
1291 c! dXhb/dXsc derivative (for charged amino acids
1292 c! location of hydrophobic centre of interaction is not
1293 c! the same as geometric centre of side chain, this
1294 c! derivative takes that into account)
1295 c! derivatives of omega angles will be added in sc_grad
1298 ertail(k) = Rtail_distance(k)/Rtail
1300 erdxi = scalar( ertail(1), dC_norm(1,i+nres) )
1301 erdxj = scalar( ertail(1), dC_norm(1,j+nres) )
1302 facd1 = dtail(1,itypi,itypj) * vbld_inv(i+nres)
1303 facd2 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
1305 c! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
1306 c! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
1307 pom = ertail(k)-facd1*(ertail(k)-erdxi*dC_norm(k,i+nres))
1308 gvdwx(k,i) = gvdwx(k,i)
1309 & - (( dFdR + gg(k) ) * pom)
1310 c! & - ( dFdR * pom )
1311 pom = ertail(k)-facd2*(ertail(k)-erdxj*dC_norm(k,j+nres))
1312 gvdwx(k,j) = gvdwx(k,j)
1313 & + (( dFdR + gg(k) ) * pom)
1314 c! & + ( dFdR * pom )
1316 gvdwc(k,i) = gvdwc(k,i)
1317 & - (( dFdR + gg(k) ) * ertail(k))
1318 c! & - ( dFdR * ertail(k))
1320 gvdwc(k,j) = gvdwc(k,j)
1321 & + (( dFdR + gg(k) ) * ertail(k))
1322 c! & + ( dFdR * ertail(k))
1325 c! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
1326 c! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
1329 c!-------------------------------------------------------------------
1330 c! Compute head-head and head-tail energies for each state
1332 isel = iabs(Qi) + iabs(Qj)
1334 c! No charges - do nothing
1337 ELSE IF (isel.eq.4) THEN
1338 c! Calculate dipole-dipole interactions
1342 ELSE IF (isel.eq.1 .and. iabs(Qi).eq.1) THEN
1343 c! Charge-nonpolar interactions
1347 ELSE IF (isel.eq.1 .and. iabs(Qj).eq.1) THEN
1348 c! Nonpolar-charge interactions
1352 ELSE IF (isel.eq.3 .and. icharge(itypj).eq.2) THEN
1353 c! Charge-dipole interactions
1354 CALL eqd(ecl, elj, epol)
1355 eheadtail = ECL + elj + epol
1357 ELSE IF (isel.eq.3 .and. icharge(itypi).eq.2) THEN
1358 c! Dipole-charge interactions
1359 CALL edq(ecl, elj, epol)
1360 eheadtail = ECL + elj + epol
1362 ELSE IF ((isel.eq.2.and.
1363 & iabs(Qi).eq.1).and.
1364 & nstate(itypi,itypj).eq.1) THEN
1365 c! Same charge-charge interaction ( +/+ or -/- )
1366 CALL eqq(Ecl,Egb,Epol,Fisocav,Elj)
1367 eheadtail = ECL + Egb + Epol + Fisocav + Elj
1369 ELSE IF ((isel.eq.2.and.
1370 & iabs(Qi).eq.1).and.
1371 & nstate(itypi,itypj).ne.1) THEN
1372 c! Different charge-charge interaction ( +/- or -/+ )
1374 & (istate,eheadtail,Ecl,Egb,Epol,Fisocav,Elj,Equad)
1376 END IF ! this endif ends the "catch the gly-gly" at the beggining of Fcav
1377 c! write (*,*) "evdw = ", evdw
1378 c! write (*,*) "Fcav = ", Fcav
1379 c! write (*,*) "eheadtail = ", eheadtail
1384 IF (energy_dec) write (iout,'(2(1x,a3,i3),3f6.2,9f16.7)')
1385 & restyp(itype(i)),i,restyp(itype(j)),j,
1386 & 1.0d0/rij,Rtail,Rhead,evdwij,Fcav,Ecl,Egb,Epol,Fisocav,Elj,
1388 IF (energy_dec) write (*,'(2(1x,a3,i3),3f6.2,9f16.7)')
1389 & restyp(itype(i)),i,restyp(itype(j)),j,
1390 & 1.0d0/rij,Rtail,Rhead,evdwij,Fcav,Ecl,Egb,Epol,Fisocav,Elj,
1397 c!-------------------------------------------------------------------
1398 c! As all angular derivatives are done, now we sum them up,
1399 c! then transform and project into cartesian vectors and add to gvdwc
1400 c! We call sc_grad always, with the exception of +/- interaction.
1401 c! This is because energy_quad subroutine needs to handle
1402 c! this job in his own way.
1403 c! This IS probably not very efficient and SHOULD be optimised
1404 c! but it will require major restructurization of emomo
1405 c! so it will be left as it is for now
1406 c! write (*,*) 'troll1, nstate =', nstate (itypi,itypj)
1407 IF (nstate(itypi,itypj).eq.1) THEN
1409 IF (bb(itypi,itypj).gt.0) THEN
1418 c!-------------------------------------------------------------------
1423 c write (iout,*) "Number of loop steps in EGB:",ind
1424 c energy_dec=.false.
1426 END SUBROUTINE emomo
1430 C-----------------------------------------------------------------------------
1433 SUBROUTINE eqq(Ecl,Egb,Epol,Fisocav,Elj)
1435 INCLUDE 'DIMENSIONS'
1436 INCLUDE 'DIMENSIONS.ZSCOPT'
1437 INCLUDE 'COMMON.CALC'
1438 INCLUDE 'COMMON.CHAIN'
1439 INCLUDE 'COMMON.CONTROL'
1440 INCLUDE 'COMMON.DERIV'
1441 INCLUDE 'COMMON.EMP'
1442 INCLUDE 'COMMON.GEO'
1443 INCLUDE 'COMMON.INTERACT'
1444 INCLUDE 'COMMON.IOUNITS'
1445 INCLUDE 'COMMON.LOCAL'
1446 INCLUDE 'COMMON.NAMES'
1447 INCLUDE 'COMMON.VAR'
1448 double precision scalar, facd3, facd4, federmaus, adler
1449 c! Epol and Gpol analytical parameters
1450 alphapol1 = alphapol(itypi,itypj)
1451 alphapol2 = alphapol(itypj,itypi)
1452 c! Fisocav and Gisocav analytical parameters
1453 al1 = alphiso(1,itypi,itypj)
1454 al2 = alphiso(2,itypi,itypj)
1455 al3 = alphiso(3,itypi,itypj)
1456 al4 = alphiso(4,itypi,itypj)
1458 & / dsqrt(sigiso1(itypi, itypj)**2.0d0
1459 & + sigiso2(itypi,itypj)**2.0d0))
1461 pis = sig0head(itypi,itypj)
1462 eps_head = epshead(itypi,itypj)
1463 Rhead_sq = Rhead * Rhead
1464 c! R1 - distance between head of ith side chain and tail of jth sidechain
1465 c! R2 - distance between head of jth side chain and tail of ith sidechain
1469 c! Calculate head-to-tail distances needed by Epol
1470 R1=R1+(ctail(k,2)-chead(k,1))**2
1471 R2=R2+(chead(k,2)-ctail(k,1))**2
1477 c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
1478 c! & +dhead(1,1,itypi,itypj))**2))
1479 c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
1480 c! & +dhead(2,1,itypi,itypj))**2))
1482 c!-------------------------------------------------------------------
1483 c! Coulomb electrostatic interaction
1484 Ecl = (332.0d0 * Qij) / Rhead
1485 c! derivative of Ecl is Gcl...
1486 dGCLdR = (-332.0d0 * Qij ) / Rhead_sq
1490 c!-------------------------------------------------------------------
1491 c! Generalised Born Solvent Polarization
1492 c! Charged head polarizes the solvent
1493 ee = dexp(-( Rhead_sq ) / (4.0d0 * a12sq))
1494 Fgb = sqrt( ( Rhead_sq ) + a12sq * ee)
1495 Egb = -(332.0d0 * Qij * eps_inout_fac) / Fgb
1496 c! Derivative of Egb is Ggb...
1497 dGGBdFGB = -(-332.0d0 * Qij * eps_inout_fac) / (Fgb * Fgb)
1498 dFGBdR = ( Rhead * ( 2.0d0 - (0.5d0 * ee) ) )
1500 dGGBdR = dGGBdFGB * dFGBdR
1501 c!-------------------------------------------------------------------
1502 c! Fisocav - isotropic cavity creation term
1503 c! or "how much energy it costs to put charged head in water"
1505 top = al1 * (dsqrt(pom) + al2 * pom - al3)
1506 bot = (1.0d0 + al4 * pom**12.0d0)
1509 c! write (*,*) "Rhead = ",Rhead
1510 c! write (*,*) "csig = ",csig
1511 c! write (*,*) "pom = ",pom
1512 c! write (*,*) "al1 = ",al1
1513 c! write (*,*) "al2 = ",al2
1514 c! write (*,*) "al3 = ",al3
1515 c! write (*,*) "al4 = ",al4
1516 c! write (*,*) "top = ",top
1517 c! write (*,*) "bot = ",bot
1518 c! Derivative of Fisocav is GCV...
1519 dtop = al1 * ((1.0d0 / (2.0d0 * dsqrt(pom))) + al2)
1520 dbot = 12.0d0 * al4 * pom ** 11.0d0
1521 dGCVdR = ((dtop * bot - top * dbot) / botsq) * csig
1522 c!-------------------------------------------------------------------
1524 c! Polarization energy - charged heads polarize hydrophobic "neck"
1525 MomoFac1 = (1.0d0 - chi1 * sqom2)
1526 MomoFac2 = (1.0d0 - chi2 * sqom1)
1527 RR1 = ( R1 * R1 ) / MomoFac1
1528 RR2 = ( R2 * R2 ) / MomoFac2
1529 ee1 = exp(-( RR1 / (4.0d0 * a12sq) ))
1530 ee2 = exp(-( RR2 / (4.0d0 * a12sq) ))
1531 fgb1 = sqrt( RR1 + a12sq * ee1 )
1532 fgb2 = sqrt( RR2 + a12sq * ee2 )
1533 epol = 332.0d0 * eps_inout_fac * (
1534 & (( alphapol1 / fgb1 )**4.0d0)+((alphapol2/fgb2) ** 4.0d0 ))
1536 c write (*,*) "eps_inout_fac = ",eps_inout_fac
1537 c write (*,*) "alphapol1 = ", alphapol1
1538 c write (*,*) "alphapol2 = ", alphapol2
1539 c write (*,*) "fgb1 = ", fgb1
1540 c write (*,*) "fgb2 = ", fgb2
1541 c write (*,*) "epol = ", epol
1542 c! derivative of Epol is Gpol...
1543 dPOLdFGB1 = -(1328.0d0 * eps_inout_fac * alphapol1 ** 4.0d0)
1545 dPOLdFGB2 = -(1328.0d0 * eps_inout_fac * alphapol2 ** 4.0d0)
1547 dFGBdR1 = ( (R1 / MomoFac1)
1548 & * ( 2.0d0 - (0.5d0 * ee1) ) )
1549 & / ( 2.0d0 * fgb1 )
1550 dFGBdR2 = ( (R2 / MomoFac2)
1551 & * ( 2.0d0 - (0.5d0 * ee2) ) )
1552 & / ( 2.0d0 * fgb2 )
1553 dFGBdOM2 = (((R1 * R1 * chi1 * om2) / (MomoFac1 * MomoFac1))
1554 & * ( 2.0d0 - 0.5d0 * ee1) )
1555 & / ( 2.0d0 * fgb1 )
1556 dFGBdOM1 = (((R2 * R2 * chi2 * om1) / (MomoFac2 * MomoFac2))
1557 & * ( 2.0d0 - 0.5d0 * ee2) )
1558 & / ( 2.0d0 * fgb2 )
1559 dPOLdR1 = dPOLdFGB1 * dFGBdR1
1561 dPOLdR2 = dPOLdFGB2 * dFGBdR2
1563 dPOLdOM1 = dPOLdFGB2 * dFGBdOM1
1565 dPOLdOM2 = dPOLdFGB1 * dFGBdOM2
1567 c!-------------------------------------------------------------------
1569 c! Lennard-Jones 6-12 interaction between heads
1570 pom = (pis / Rhead)**6.0d0
1571 Elj = 4.0d0 * eps_head * pom * (pom-1.0d0)
1572 c! derivative of Elj is Glj
1573 dGLJdR = 4.0d0 * eps_head
1574 & * (((-12.0d0*pis**12.0d0)/(Rhead**13.0d0))
1575 & + (( 6.0d0*pis**6.0d0) /(Rhead**7.0d0)))
1576 c!-------------------------------------------------------------------
1577 c! Return the results
1578 c! These things do the dRdX derivatives, that is
1579 c! allow us to change what we see from function that changes with
1580 c! distance to function that changes with LOCATION (of the interaction
1583 erhead(k) = Rhead_distance(k)/Rhead
1584 erhead_tail(k,1) = ((ctail(k,2)-chead(k,1))/R1)
1585 erhead_tail(k,2) = ((chead(k,2)-ctail(k,1))/R2)
1588 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
1589 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
1590 bat = scalar( erhead_tail(1,1), dC_norm(1,i+nres) )
1591 federmaus = scalar(erhead_tail(1,1),dC_norm(1,j+nres))
1592 eagle = scalar( erhead_tail(1,2), dC_norm(1,j+nres) )
1593 adler = scalar( erhead_tail(1,2), dC_norm(1,i+nres) )
1594 facd1 = d1 * vbld_inv(i+nres)
1595 facd2 = d2 * vbld_inv(j+nres)
1596 facd3 = dtail(1,itypi,itypj) * vbld_inv(i+nres)
1597 facd4 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
1599 c! Now we add appropriate partial derivatives (one in each dimension)
1601 hawk = (erhead_tail(k,1) +
1602 & facd1 * (erhead_tail(k,1) - bat * dC_norm(k,i+nres)))
1603 condor = (erhead_tail(k,2) +
1604 & facd2 * (erhead_tail(k,2) - eagle * dC_norm(k,j+nres)))
1606 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
1607 gvdwx(k,i) = gvdwx(k,i)
1612 & - dPOLdR2 * (erhead_tail(k,2)
1613 & -facd3 * (erhead_tail(k,2) - adler * dC_norm(k,i+nres)))
1616 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
1617 gvdwx(k,j) = gvdwx(k,j)
1621 & + dPOLdR1 * (erhead_tail(k,1)
1622 & -facd4 * (erhead_tail(k,1) - federmaus * dC_norm(k,j+nres)))
1623 & + dPOLdR2 * condor
1626 gvdwc(k,i) = gvdwc(k,i)
1627 & - dGCLdR * erhead(k)
1628 & - dGGBdR * erhead(k)
1629 & - dGCVdR * erhead(k)
1630 & - dPOLdR1 * erhead_tail(k,1)
1631 & - dPOLdR2 * erhead_tail(k,2)
1632 & - dGLJdR * erhead(k)
1634 gvdwc(k,j) = gvdwc(k,j)
1635 & + dGCLdR * erhead(k)
1636 & + dGGBdR * erhead(k)
1637 & + dGCVdR * erhead(k)
1638 & + dPOLdR1 * erhead_tail(k,1)
1639 & + dPOLdR2 * erhead_tail(k,2)
1640 & + dGLJdR * erhead(k)
1645 c!-------------------------------------------------------------------
1646 SUBROUTINE energy_quad
1647 &(istate,eheadtail,Ecl,Egb,Epol,Fisocav,Elj,Equad)
1649 INCLUDE 'DIMENSIONS'
1650 INCLUDE 'DIMENSIONS.ZSCOPT'
1651 INCLUDE 'COMMON.CALC'
1652 INCLUDE 'COMMON.CHAIN'
1653 INCLUDE 'COMMON.CONTROL'
1654 INCLUDE 'COMMON.DERIV'
1655 INCLUDE 'COMMON.EMP'
1656 INCLUDE 'COMMON.GEO'
1657 INCLUDE 'COMMON.INTERACT'
1658 INCLUDE 'COMMON.IOUNITS'
1659 INCLUDE 'COMMON.LOCAL'
1660 INCLUDE 'COMMON.NAMES'
1661 INCLUDE 'COMMON.VAR'
1662 double precision scalar
1663 double precision ener(4)
1664 double precision dcosom1(3),dcosom2(3)
1665 c! used in Epol derivatives
1666 double precision facd3, facd4
1667 double precision federmaus, adler
1668 c! Epol and Gpol analytical parameters
1669 alphapol1 = alphapol(itypi,itypj)
1670 alphapol2 = alphapol(itypj,itypi)
1671 c! Fisocav and Gisocav analytical parameters
1672 al1 = alphiso(1,itypi,itypj)
1673 al2 = alphiso(2,itypi,itypj)
1674 al3 = alphiso(3,itypi,itypj)
1675 al4 = alphiso(4,itypi,itypj)
1677 & / dsqrt(sigiso1(itypi, itypj)**2.0d0
1678 & + sigiso2(itypi,itypj)**2.0d0))
1680 w1 = wqdip(1,itypi,itypj)
1681 w2 = wqdip(2,itypi,itypj)
1682 pis = sig0head(itypi,itypj)
1683 eps_head = epshead(itypi,itypj)
1684 c! First things first:
1685 c! We need to do sc_grad's job with GB and Fcav
1687 & eps2der * eps2rt_om1
1688 & - 2.0D0 * alf1 * eps3der
1689 & + sigder * sigsq_om1
1692 & eps2der * eps2rt_om2
1693 & + 2.0D0 * alf2 * eps3der
1694 & + sigder * sigsq_om2
1697 & evdwij * eps1_om12
1698 & + eps2der * eps2rt_om12
1699 & - 2.0D0 * alf12 * eps3der
1700 & + sigder *sigsq_om12
1702 c! now some magical transformations to project gradient into
1703 c! three cartesian vectors
1705 dcosom1(k) = rij * (dc_norm(k,nres+i) - om1 * erij(k))
1706 dcosom2(k) = rij * (dc_norm(k,nres+j) - om2 * erij(k))
1707 gg(k) = gg(k) + eom1 * dcosom1(k) + eom2 * dcosom2(k)
1708 c! this acts on hydrophobic center of interaction
1709 gvdwx(k,i)= gvdwx(k,i) - gg(k)
1710 & + (eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))
1711 & + eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
1712 gvdwx(k,j)= gvdwx(k,j) + gg(k)
1713 & + (eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))
1714 & + eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
1715 c! this acts on Calpha
1716 gvdwc(k,i)=gvdwc(k,i)-gg(k)
1717 gvdwc(k,j)=gvdwc(k,j)+gg(k)
1719 c! sc_grad is done, now we will compute
1728 c! d1 = dhead(1, 1, itypi, itypj)
1729 c! d2 = dhead(2, 1, itypi, itypj)
1730 c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
1731 c! & +dhead(1,ii,itypi,itypj))**2))
1732 c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
1733 c! & +dhead(2,jj,itypi,itypj))**2))
1734 c! Rhead = dsqrt((Rtail**2)+((dabs(d1-d2))**2))
1735 c! END OF ENERGY DEBUG
1736 c*************************************************************
1737 DO istate = 1, nstate(itypi,itypj)
1738 c*************************************************************
1739 IF (istate.ne.1) THEN
1740 IF (istate.lt.3) THEN
1746 d1 = dhead(1,ii,itypi,itypj)
1747 d2 = dhead(2,jj,itypi,itypj)
1749 chead(k,1) = c(k, i+nres) + d1 * dc_norm(k, i+nres)
1750 chead(k,2) = c(k, j+nres) + d2 * dc_norm(k, j+nres)
1751 Rhead_distance(k) = chead(k,2) - chead(k,1)
1753 c! pitagoras (root of sum of squares)
1755 & (Rhead_distance(1)*Rhead_distance(1))
1756 & + (Rhead_distance(2)*Rhead_distance(2))
1757 & + (Rhead_distance(3)*Rhead_distance(3)))
1759 Rhead_sq = Rhead * Rhead
1761 c! R1 - distance between head of ith side chain and tail of jth sidechain
1762 c! R2 - distance between head of jth side chain and tail of ith sidechain
1766 c! Calculate head-to-tail distances
1767 R1=R1+(ctail(k,2)-chead(k,1))**2
1768 R2=R2+(chead(k,2)-ctail(k,1))**2
1775 c! write (*,*) "istate = ", istate
1776 c! write (*,*) "ii = ", ii
1777 c! write (*,*) "jj = ", jj
1778 c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
1779 c! & +dhead(1,ii,itypi,itypj))**2))
1780 c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
1781 c! & +dhead(2,jj,itypi,itypj))**2))
1782 c! Rhead = dsqrt((Rtail**2)+((dabs(d1-d2))**2))
1783 c! Rhead_sq = Rhead * Rhead
1784 c! write (*,*) "d1 = ",d1
1785 c! write (*,*) "d2 = ",d2
1786 c! write (*,*) "R1 = ",R1
1787 c! write (*,*) "R2 = ",R2
1788 c! write (*,*) "Rhead = ",Rhead
1789 c! END OF ENERGY DEBUG
1791 c!-------------------------------------------------------------------
1792 c! Coulomb electrostatic interaction
1793 Ecl = (332.0d0 * Qij) / (Rhead * eps_in)
1795 c! write (*,*) "Ecl = ", Ecl
1796 c! derivative of Ecl is Gcl...
1797 dGCLdR = (-332.0d0 * Qij ) / (Rhead_sq * eps_in)
1802 c!-------------------------------------------------------------------
1803 c! Generalised Born Solvent Polarization
1804 ee = dexp(-( Rhead_sq ) / (4.0d0 * a12sq))
1805 Fgb = sqrt( ( Rhead_sq ) + a12sq * ee)
1806 Egb = -(332.0d0 * Qij * eps_inout_fac) / Fgb
1808 c! write (*,*) "a1*a2 = ", a12sq
1809 c! write (*,*) "Rhead = ", Rhead
1810 c! write (*,*) "Rhead_sq = ", Rhead_sq
1811 c! write (*,*) "ee = ", ee
1812 c! write (*,*) "Fgb = ", Fgb
1813 c! write (*,*) "fac = ", eps_inout_fac
1814 c! write (*,*) "Qij = ", Qij
1815 c! write (*,*) "Egb = ", Egb
1816 c! Derivative of Egb is Ggb...
1817 c! dFGBdR is used by Quad's later...
1818 dGGBdFGB = -(-332.0d0 * Qij * eps_inout_fac) / (Fgb * Fgb)
1819 dFGBdR = ( Rhead * ( 2.0d0 - (0.5d0 * ee) ) )
1821 dGGBdR = dGGBdFGB * dFGBdR
1823 c!-------------------------------------------------------------------
1824 c! Fisocav - isotropic cavity creation term
1826 top = al1 * (dsqrt(pom) + al2 * pom - al3)
1827 bot = (1.0d0 + al4 * pom**12.0d0)
1831 c! write (*,*) "pom = ",pom
1832 c! write (*,*) "al1 = ",al1
1833 c! write (*,*) "al2 = ",al2
1834 c! write (*,*) "al3 = ",al3
1835 c! write (*,*) "al4 = ",al4
1836 c! write (*,*) "top = ",top
1837 c! write (*,*) "bot = ",bot
1838 c! write (*,*) "Fisocav = ", Fisocav
1840 c! Derivative of Fisocav is GCV...
1841 dtop = al1 * ((1.0d0 / (2.0d0 * dsqrt(pom))) + al2)
1842 dbot = 12.0d0 * al4 * pom ** 11.0d0
1843 dGCVdR = ((dtop * bot - top * dbot) / botsq) * csig
1845 c!-------------------------------------------------------------------
1846 c! Polarization energy
1848 MomoFac1 = (1.0d0 - chi1 * sqom2)
1849 MomoFac2 = (1.0d0 - chi2 * sqom1)
1850 RR1 = ( R1 * R1 ) / MomoFac1
1851 RR2 = ( R2 * R2 ) / MomoFac2
1852 ee1 = exp(-( RR1 / (4.0d0 * a12sq) ))
1853 ee2 = exp(-( RR2 / (4.0d0 * a12sq) ))
1854 fgb1 = sqrt( RR1 + a12sq * ee1 )
1855 fgb2 = sqrt( RR2 + a12sq * ee2 )
1856 epol = 332.0d0 * eps_inout_fac * (
1857 & (( alphapol1 / fgb1 )**4.0d0)+((alphapol2/fgb2) ** 4.0d0 ))
1859 c! derivative of Epol is Gpol...
1860 dPOLdFGB1 = -(1328.0d0 * eps_inout_fac * alphapol1 ** 4.0d0)
1862 dPOLdFGB2 = -(1328.0d0 * eps_inout_fac * alphapol2 ** 4.0d0)
1864 dFGBdR1 = ( (R1 / MomoFac1)
1865 & * ( 2.0d0 - (0.5d0 * ee1) ) )
1866 & / ( 2.0d0 * fgb1 )
1867 dFGBdR2 = ( (R2 / MomoFac2)
1868 & * ( 2.0d0 - (0.5d0 * ee2) ) )
1869 & / ( 2.0d0 * fgb2 )
1870 dFGBdOM2 = (((R1 * R1 * chi1 * om2) / (MomoFac1 * MomoFac1))
1871 & * ( 2.0d0 - 0.5d0 * ee1) )
1872 & / ( 2.0d0 * fgb1 )
1873 dFGBdOM1 = (((R2 * R2 * chi2 * om1) / (MomoFac2 * MomoFac2))
1874 & * ( 2.0d0 - 0.5d0 * ee2) )
1875 & / ( 2.0d0 * fgb2 )
1876 dPOLdR1 = dPOLdFGB1 * dFGBdR1
1878 dPOLdR2 = dPOLdFGB2 * dFGBdR2
1880 dPOLdOM1 = dPOLdFGB2 * dFGBdOM1
1882 dPOLdOM2 = dPOLdFGB1 * dFGBdOM2
1884 c!-------------------------------------------------------------------
1886 pom = (pis / Rhead)**6.0d0
1887 Elj = 4.0d0 * eps_head * pom * (pom-1.0d0)
1889 c! derivative of Elj is Glj
1890 dGLJdR = 4.0d0 * eps_head
1891 & * (((-12.0d0*pis**12.0d0)/(Rhead**13.0d0))
1892 & + (( 6.0d0*pis**6.0d0) /(Rhead**7.0d0)))
1894 c!-------------------------------------------------------------------
1896 IF (Wqd.ne.0.0d0) THEN
1897 Beta1 = 5.0d0 + 3.0d0 * (sqom12 - 1.0d0)
1898 & - 37.5d0 * ( sqom1 + sqom2 )
1899 & + 157.5d0 * ( sqom1 * sqom2 )
1900 & - 45.0d0 * om1*om2*om12
1901 fac = -( Wqd / (2.0d0 * Fgb**5.0d0) )
1904 c! derivative of Equad...
1905 dQUADdR = ((2.5d0 * Wqd * Beta1) / (Fgb**6.0d0)) * dFGBdR
1908 & * (-75.0d0*om1 + 315.0d0*om1*sqom2 - 45.0d0*om2*om12)
1909 c! dQUADdOM1 = 0.0d0
1911 & * (-75.0d0*om2 + 315.0d0*sqom1*om2 - 45.0d0*om1*om12)
1912 c! dQUADdOM2 = 0.0d0
1914 & * ( 6.0d0*om12 - 45.0d0*om1*om2 )
1915 c! dQUADdOM12 = 0.0d0
1920 c!-------------------------------------------------------------------
1921 c! Return the results
1923 eom1 = dPOLdOM1 + dQUADdOM1
1924 eom2 = dPOLdOM2 + dQUADdOM2
1926 c! now some magical transformations to project gradient into
1927 c! three cartesian vectors
1929 dcosom1(k) = rij * (dc_norm(k,nres+i) - om1 * erij(k))
1930 dcosom2(k) = rij * (dc_norm(k,nres+j) - om2 * erij(k))
1931 tuna(k) = eom1 * dcosom1(k) + eom2 * dcosom2(k)
1935 erhead(k) = Rhead_distance(k)/Rhead
1936 erhead_tail(k,1) = ((ctail(k,2)-chead(k,1))/R1)
1937 erhead_tail(k,2) = ((chead(k,2)-ctail(k,1))/R2)
1939 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
1940 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
1941 bat = scalar( erhead_tail(1,1), dC_norm(1,i+nres) )
1942 federmaus = scalar(erhead_tail(1,1),dC_norm(1,j+nres))
1943 eagle = scalar( erhead_tail(1,2), dC_norm(1,j+nres) )
1944 adler = scalar( erhead_tail(1,2), dC_norm(1,i+nres) )
1945 facd1 = d1 * vbld_inv(i+nres)
1946 facd2 = d2 * vbld_inv(j+nres)
1947 facd3 = dtail(1,itypi,itypj) * vbld_inv(i+nres)
1948 facd4 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
1949 c! Throw the results into gheadtail which holds gradients
1950 c! for each micro-state
1952 hawk = erhead_tail(k,1) +
1953 & facd1 * (erhead_tail(k,1) - bat * dC_norm(k,i+nres))
1954 condor = erhead_tail(k,2) +
1955 & facd2 * (erhead_tail(k,2) - eagle * dC_norm(k,j+nres))
1957 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
1958 c! this acts on hydrophobic center of interaction
1959 gheadtail(k,1,1) = gheadtail(k,1,1)
1964 & - dPOLdR2 * (erhead_tail(k,2)
1965 & -facd3 * (erhead_tail(k,2) - adler * dC_norm(k,i+nres)))
1969 & + (eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))
1970 & + eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
1972 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
1973 c! this acts on hydrophobic center of interaction
1974 gheadtail(k,2,1) = gheadtail(k,2,1)
1978 & + dPOLdR1 * (erhead_tail(k,1)
1979 & -facd4 * (erhead_tail(k,1) - federmaus * dC_norm(k,j+nres)))
1980 & + dPOLdR2 * condor
1984 & + (eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))
1985 & + eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
1987 c! this acts on Calpha
1988 gheadtail(k,3,1) = gheadtail(k,3,1)
1989 & - dGCLdR * erhead(k)
1990 & - dGGBdR * erhead(k)
1991 & - dGCVdR * erhead(k)
1992 & - dPOLdR1 * erhead_tail(k,1)
1993 & - dPOLdR2 * erhead_tail(k,2)
1994 & - dGLJdR * erhead(k)
1995 & - dQUADdR * erhead(k)
1998 c! this acts on Calpha
1999 gheadtail(k,4,1) = gheadtail(k,4,1)
2000 & + dGCLdR * erhead(k)
2001 & + dGGBdR * erhead(k)
2002 & + dGCVdR * erhead(k)
2003 & + dPOLdR1 * erhead_tail(k,1)
2004 & + dPOLdR2 * erhead_tail(k,2)
2005 & + dGLJdR * erhead(k)
2006 & + dQUADdR * erhead(k)
2009 c! write(*,*) "ECL = ", Ecl
2010 c! write(*,*) "Egb = ", Egb
2011 c! write(*,*) "Epol = ", Epol
2012 c! write(*,*) "Fisocav = ", Fisocav
2013 c! write(*,*) "Elj = ", Elj
2014 c! write(*,*) "Equad = ", Equad
2015 c! write(*,*) "wstate = ", wstate(istate,itypi,itypj)
2016 c! write(*,*) "eheadtail = ", eheadtail
2017 c! write(*,*) "TROLL = ", dexp(-betaT * ener(istate))
2018 c! write(*,*) "dGCLdR = ", dGCLdR
2019 c! write(*,*) "dGGBdR = ", dGGBdR
2020 c! write(*,*) "dGCVdR = ", dGCVdR
2021 c! write(*,*) "dPOLdR1 = ", dPOLdR1
2022 c! write(*,*) "dPOLdR2 = ", dPOLdR2
2023 c! write(*,*) "dGLJdR = ", dGLJdR
2024 c! write(*,*) "dQUADdR = ", dQUADdR
2025 c! write(*,*) "tuna(",k,") = ", tuna(k)
2026 ener(istate) = ECL + Egb + Epol + Fisocav + Elj + Equad
2027 eheadtail = eheadtail
2028 & + wstate(istate, itypi, itypj)
2029 & * dexp(-betaT * ener(istate))
2030 c! foreach cartesian dimension
2032 c! foreach of two gvdwx and gvdwc
2034 gheadtail(k,l,2) = gheadtail(k,l,2)
2035 & + wstate( istate, itypi, itypj )
2036 & * dexp(-betaT * ener(istate))
2037 & * gheadtail(k,l,1)
2038 gheadtail(k,l,1) = 0.0d0
2042 c! Here ended the gigantic DO istate = 1, 4, which starts
2043 c! at the beggining of the subroutine
2047 gheadtail(k,l,2) = gheadtail(k,l,2) / eheadtail
2049 gvdwx(k,i) = gvdwx(k,i) + gheadtail(k,1,2)
2050 gvdwx(k,j) = gvdwx(k,j) + gheadtail(k,2,2)
2051 gvdwc(k,i) = gvdwc(k,i) + gheadtail(k,3,2)
2052 gvdwc(k,j) = gvdwc(k,j) + gheadtail(k,4,2)
2054 gheadtail(k,l,1) = 0.0d0
2055 gheadtail(k,l,2) = 0.0d0
2058 eheadtail = (-dlog(eheadtail)) / betaT
2065 END SUBROUTINE energy_quad
2068 c!-------------------------------------------------------------------
2071 SUBROUTINE eqn(Epol)
2073 INCLUDE 'DIMENSIONS'
2074 INCLUDE 'DIMENSIONS.ZSCOPT'
2075 INCLUDE 'COMMON.CALC'
2076 INCLUDE 'COMMON.CHAIN'
2077 INCLUDE 'COMMON.CONTROL'
2078 INCLUDE 'COMMON.DERIV'
2079 INCLUDE 'COMMON.EMP'
2080 INCLUDE 'COMMON.GEO'
2081 INCLUDE 'COMMON.INTERACT'
2082 INCLUDE 'COMMON.IOUNITS'
2083 INCLUDE 'COMMON.LOCAL'
2084 INCLUDE 'COMMON.NAMES'
2085 INCLUDE 'COMMON.VAR'
2086 double precision scalar, facd4, federmaus
2087 alphapol1 = alphapol(itypi,itypj)
2088 c! R1 - distance between head of ith side chain and tail of jth sidechain
2091 c! Calculate head-to-tail distances
2092 R1=R1+(ctail(k,2)-chead(k,1))**2
2097 c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
2098 c! & +dhead(1,1,itypi,itypj))**2))
2099 c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
2100 c! & +dhead(2,1,itypi,itypj))**2))
2101 c--------------------------------------------------------------------
2102 c Polarization energy
2104 MomoFac1 = (1.0d0 - chi1 * sqom2)
2105 RR1 = R1 * R1 / MomoFac1
2106 ee1 = exp(-( RR1 / (4.0d0 * a12sq) ))
2107 fgb1 = sqrt( RR1 + a12sq * ee1)
2108 epol = 332.0d0 * eps_inout_fac * (( alphapol1 / fgb1 )**4.0d0)
2110 c!------------------------------------------------------------------
2111 c! derivative of Epol is Gpol...
2112 dPOLdFGB1 = -(1328.0d0 * eps_inout_fac * alphapol1 ** 4.0d0)
2114 dFGBdR1 = ( (R1 / MomoFac1)
2115 & * ( 2.0d0 - (0.5d0 * ee1) ) )
2116 & / ( 2.0d0 * fgb1 )
2117 dFGBdOM2 = (((R1 * R1 * chi1 * om2) / (MomoFac1 * MomoFac1))
2118 & * (2.0d0 - 0.5d0 * ee1) )
2120 dPOLdR1 = dPOLdFGB1 * dFGBdR1
2123 dPOLdOM2 = dPOLdFGB1 * dFGBdOM2
2125 c!-------------------------------------------------------------------
2126 c! Return the results
2127 c! (see comments in Eqq)
2129 erhead_tail(k,1) = ((ctail(k,2)-chead(k,1))/R1)
2131 bat = scalar( erhead_tail(1,1), dC_norm(1,i+nres) )
2132 federmaus = scalar(erhead_tail(1,1),dC_norm(1,j+nres))
2133 facd1 = d1 * vbld_inv(i+nres)
2134 facd4 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
2137 hawk = (erhead_tail(k,1) +
2138 & facd1 * (erhead_tail(k,1) - bat * dC_norm(k,i+nres)))
2140 gvdwx(k,i) = gvdwx(k,i)
2142 gvdwx(k,j) = gvdwx(k,j)
2143 & + dPOLdR1 * (erhead_tail(k,1)
2144 & -facd4 * (erhead_tail(k,1) - federmaus * dC_norm(k,j+nres)))
2146 gvdwc(k,i) = gvdwc(k,i)
2147 & - dPOLdR1 * erhead_tail(k,1)
2148 gvdwc(k,j) = gvdwc(k,j)
2149 & + dPOLdR1 * erhead_tail(k,1)
2156 c!-------------------------------------------------------------------
2160 SUBROUTINE enq(Epol)
2162 INCLUDE 'DIMENSIONS'
2163 INCLUDE 'DIMENSIONS.ZSCOPT'
2164 INCLUDE 'COMMON.CALC'
2165 INCLUDE 'COMMON.CHAIN'
2166 INCLUDE 'COMMON.CONTROL'
2167 INCLUDE 'COMMON.DERIV'
2168 INCLUDE 'COMMON.EMP'
2169 INCLUDE 'COMMON.GEO'
2170 INCLUDE 'COMMON.INTERACT'
2171 INCLUDE 'COMMON.IOUNITS'
2172 INCLUDE 'COMMON.LOCAL'
2173 INCLUDE 'COMMON.NAMES'
2174 INCLUDE 'COMMON.VAR'
2175 double precision scalar, facd3, adler
2176 alphapol2 = alphapol(itypj,itypi)
2177 c! R2 - distance between head of jth side chain and tail of ith sidechain
2180 c! Calculate head-to-tail distances
2181 R2=R2+(chead(k,2)-ctail(k,1))**2
2186 c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
2187 c! & +dhead(1,1,itypi,itypj))**2))
2188 c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
2189 c! & +dhead(2,1,itypi,itypj))**2))
2190 c------------------------------------------------------------------------
2191 c Polarization energy
2192 MomoFac2 = (1.0d0 - chi2 * sqom1)
2193 RR2 = R2 * R2 / MomoFac2
2194 ee2 = exp(-(RR2 / (4.0d0 * a12sq)))
2195 fgb2 = sqrt(RR2 + a12sq * ee2)
2196 epol = 332.0d0 * eps_inout_fac * ((alphapol2/fgb2) ** 4.0d0 )
2198 c!-------------------------------------------------------------------
2199 c! derivative of Epol is Gpol...
2200 dPOLdFGB2 = -(1328.0d0 * eps_inout_fac * alphapol2 ** 4.0d0)
2202 dFGBdR2 = ( (R2 / MomoFac2)
2203 & * ( 2.0d0 - (0.5d0 * ee2) ) )
2205 dFGBdOM1 = (((R2 * R2 * chi2 * om1) / (MomoFac2 * MomoFac2))
2206 & * (2.0d0 - 0.5d0 * ee2) )
2208 dPOLdR2 = dPOLdFGB2 * dFGBdR2
2210 dPOLdOM1 = dPOLdFGB2 * dFGBdOM1
2213 c!-------------------------------------------------------------------
2214 c! Return the results
2215 c! (See comments in Eqq)
2217 erhead_tail(k,2) = ((chead(k,2)-ctail(k,1))/R2)
2219 eagle = scalar( erhead_tail(1,2), dC_norm(1,j+nres) )
2220 adler = scalar( erhead_tail(1,2), dC_norm(1,i+nres) )
2221 facd2 = d2 * vbld_inv(j+nres)
2222 facd3 = dtail(1,itypi,itypj) * vbld_inv(i+nres)
2224 condor = (erhead_tail(k,2)
2225 & + facd2 * (erhead_tail(k,2) - eagle * dC_norm(k,j+nres)))
2227 gvdwx(k,i) = gvdwx(k,i)
2228 & - dPOLdR2 * (erhead_tail(k,2)
2229 & -facd3 * (erhead_tail(k,2) - adler * dC_norm(k,i+nres)))
2230 gvdwx(k,j) = gvdwx(k,j)
2231 & + dPOLdR2 * condor
2233 gvdwc(k,i) = gvdwc(k,i)
2234 & - dPOLdR2 * erhead_tail(k,2)
2235 gvdwc(k,j) = gvdwc(k,j)
2236 & + dPOLdR2 * erhead_tail(k,2)
2243 c!-------------------------------------------------------------------
2246 SUBROUTINE eqd(Ecl,Elj,Epol)
2248 INCLUDE 'DIMENSIONS'
2249 INCLUDE 'DIMENSIONS.ZSCOPT'
2250 INCLUDE 'COMMON.CALC'
2251 INCLUDE 'COMMON.CHAIN'
2252 INCLUDE 'COMMON.CONTROL'
2253 INCLUDE 'COMMON.DERIV'
2254 INCLUDE 'COMMON.EMP'
2255 INCLUDE 'COMMON.GEO'
2256 INCLUDE 'COMMON.INTERACT'
2257 INCLUDE 'COMMON.IOUNITS'
2258 INCLUDE 'COMMON.LOCAL'
2259 INCLUDE 'COMMON.NAMES'
2260 INCLUDE 'COMMON.VAR'
2261 double precision scalar, facd4, federmaus
2262 alphapol1 = alphapol(itypi,itypj)
2263 w1 = wqdip(1,itypi,itypj)
2264 w2 = wqdip(2,itypi,itypj)
2265 pis = sig0head(itypi,itypj)
2266 eps_head = epshead(itypi,itypj)
2267 c!-------------------------------------------------------------------
2268 c! R1 - distance between head of ith side chain and tail of jth sidechain
2271 c! Calculate head-to-tail distances
2272 R1=R1+(ctail(k,2)-chead(k,1))**2
2277 c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
2278 c! & +dhead(1,1,itypi,itypj))**2))
2279 c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
2280 c! & +dhead(2,1,itypi,itypj))**2))
2282 c!-------------------------------------------------------------------
2284 sparrow = w1 * Qi * om1
2285 hawk = w2 * Qi * Qi * (1.0d0 - sqom2)
2286 Ecl = sparrow / Rhead**2.0d0
2287 & - hawk / Rhead**4.0d0
2288 c!-------------------------------------------------------------------
2289 c! derivative of ecl is Gcl
2291 dGCLdR = - 2.0d0 * sparrow / Rhead**3.0d0
2292 & + 4.0d0 * hawk / Rhead**5.0d0
2294 dGCLdOM1 = (w1 * Qi) / (Rhead**2.0d0)
2296 dGCLdOM2 = (2.0d0 * w2 * Qi * Qi * om2) / (Rhead ** 4.0d0)
2297 c--------------------------------------------------------------------
2298 c Polarization energy
2300 MomoFac1 = (1.0d0 - chi1 * sqom2)
2301 RR1 = R1 * R1 / MomoFac1
2302 ee1 = exp(-( RR1 / (4.0d0 * a12sq) ))
2303 fgb1 = sqrt( RR1 + a12sq * ee1)
2304 epol = 332.0d0 * eps_inout_fac * (( alphapol1 / fgb1 )**4.0d0)
2306 c!------------------------------------------------------------------
2307 c! derivative of Epol is Gpol...
2308 dPOLdFGB1 = -(1328.0d0 * eps_inout_fac * alphapol1 ** 4.0d0)
2310 dFGBdR1 = ( (R1 / MomoFac1)
2311 & * ( 2.0d0 - (0.5d0 * ee1) ) )
2312 & / ( 2.0d0 * fgb1 )
2313 dFGBdOM2 = (((R1 * R1 * chi1 * om2) / (MomoFac1 * MomoFac1))
2314 & * (2.0d0 - 0.5d0 * ee1) )
2316 dPOLdR1 = dPOLdFGB1 * dFGBdR1
2319 dPOLdOM2 = dPOLdFGB1 * dFGBdOM2
2321 c!-------------------------------------------------------------------
2323 pom = (pis / Rhead)**6.0d0
2324 Elj = 4.0d0 * eps_head * pom * (pom-1.0d0)
2325 c! derivative of Elj is Glj
2326 dGLJdR = 4.0d0 * eps_head
2327 & * (((-12.0d0*pis**12.0d0)/(Rhead**13.0d0))
2328 & + (( 6.0d0*pis**6.0d0) /(Rhead**7.0d0)))
2329 c!-------------------------------------------------------------------
2330 c! Return the results
2332 erhead(k) = Rhead_distance(k)/Rhead
2333 erhead_tail(k,1) = ((ctail(k,2)-chead(k,1))/R1)
2336 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
2337 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
2338 bat = scalar( erhead_tail(1,1), dC_norm(1,i+nres) )
2339 federmaus = scalar(erhead_tail(1,1),dC_norm(1,j+nres))
2340 facd1 = d1 * vbld_inv(i+nres)
2341 facd2 = d2 * vbld_inv(j+nres)
2342 facd4 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
2345 hawk = (erhead_tail(k,1) +
2346 & facd1 * (erhead_tail(k,1) - bat * dC_norm(k,i+nres)))
2348 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
2349 gvdwx(k,i) = gvdwx(k,i)
2354 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
2355 gvdwx(k,j) = gvdwx(k,j)
2357 & + dPOLdR1 * (erhead_tail(k,1)
2358 & -facd4 * (erhead_tail(k,1) - federmaus * dC_norm(k,j+nres)))
2362 gvdwc(k,i) = gvdwc(k,i)
2363 & - dGCLdR * erhead(k)
2364 & - dPOLdR1 * erhead_tail(k,1)
2365 & - dGLJdR * erhead(k)
2367 gvdwc(k,j) = gvdwc(k,j)
2368 & + dGCLdR * erhead(k)
2369 & + dPOLdR1 * erhead_tail(k,1)
2370 & + dGLJdR * erhead(k)
2377 c!-------------------------------------------------------------------
2380 SUBROUTINE edq(Ecl,Elj,Epol)
2382 INCLUDE 'DIMENSIONS'
2383 INCLUDE 'DIMENSIONS.ZSCOPT'
2384 INCLUDE 'COMMON.CALC'
2385 INCLUDE 'COMMON.CHAIN'
2386 INCLUDE 'COMMON.CONTROL'
2387 INCLUDE 'COMMON.DERIV'
2388 INCLUDE 'COMMON.EMP'
2389 INCLUDE 'COMMON.GEO'
2390 INCLUDE 'COMMON.INTERACT'
2391 INCLUDE 'COMMON.IOUNITS'
2392 INCLUDE 'COMMON.LOCAL'
2393 INCLUDE 'COMMON.NAMES'
2394 INCLUDE 'COMMON.VAR'
2395 double precision scalar, facd3, adler
2396 alphapol2 = alphapol(itypj,itypi)
2397 w1 = wqdip(1,itypi,itypj)
2398 w2 = wqdip(2,itypi,itypj)
2399 pis = sig0head(itypi,itypj)
2400 eps_head = epshead(itypi,itypj)
2401 c!-------------------------------------------------------------------
2402 c! R2 - distance between head of jth side chain and tail of ith sidechain
2405 c! Calculate head-to-tail distances
2406 R2=R2+(chead(k,2)-ctail(k,1))**2
2411 c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
2412 c! & +dhead(1,1,itypi,itypj))**2))
2413 c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
2414 c! & +dhead(2,1,itypi,itypj))**2))
2417 c!-------------------------------------------------------------------
2419 sparrow = w1 * Qi * om1
2420 hawk = w2 * Qi * Qi * (1.0d0 - sqom2)
2421 ECL = sparrow / Rhead**2.0d0
2422 & - hawk / Rhead**4.0d0
2423 c!-------------------------------------------------------------------
2424 c! derivative of ecl is Gcl
2426 dGCLdR = - 2.0d0 * sparrow / Rhead**3.0d0
2427 & + 4.0d0 * hawk / Rhead**5.0d0
2429 dGCLdOM1 = (w1 * Qi) / (Rhead**2.0d0)
2431 dGCLdOM2 = (2.0d0 * w2 * Qi * Qi * om2) / (Rhead ** 4.0d0)
2432 c--------------------------------------------------------------------
2433 c Polarization energy
2435 MomoFac2 = (1.0d0 - chi2 * sqom1)
2436 RR2 = R2 * R2 / MomoFac2
2437 ee2 = exp(-(RR2 / (4.0d0 * a12sq)))
2438 fgb2 = sqrt(RR2 + a12sq * ee2)
2439 epol = 332.0d0 * eps_inout_fac * ((alphapol2/fgb2) ** 4.0d0 )
2441 c! derivative of Epol is Gpol...
2442 dPOLdFGB2 = -(1328.0d0 * eps_inout_fac * alphapol2 ** 4.0d0)
2444 dFGBdR2 = ( (R2 / MomoFac2)
2445 & * ( 2.0d0 - (0.5d0 * ee2) ) )
2447 dFGBdOM1 = (((R2 * R2 * chi2 * om1) / (MomoFac2 * MomoFac2))
2448 & * (2.0d0 - 0.5d0 * ee2) )
2450 dPOLdR2 = dPOLdFGB2 * dFGBdR2
2452 dPOLdOM1 = dPOLdFGB2 * dFGBdOM1
2455 c!-------------------------------------------------------------------
2457 pom = (pis / Rhead)**6.0d0
2458 Elj = 4.0d0 * eps_head * pom * (pom-1.0d0)
2459 c! derivative of Elj is Glj
2460 dGLJdR = 4.0d0 * eps_head
2461 & * (((-12.0d0*pis**12.0d0)/(Rhead**13.0d0))
2462 & + (( 6.0d0*pis**6.0d0) /(Rhead**7.0d0)))
2463 c!-------------------------------------------------------------------
2464 c! Return the results
2465 c! (see comments in Eqq)
2467 erhead(k) = Rhead_distance(k)/Rhead
2468 erhead_tail(k,2) = ((chead(k,2)-ctail(k,1))/R2)
2470 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
2471 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
2472 eagle = scalar( erhead_tail(1,2), dC_norm(1,j+nres) )
2473 adler = scalar( erhead_tail(1,2), dC_norm(1,i+nres) )
2474 facd1 = d1 * vbld_inv(i+nres)
2475 facd2 = d2 * vbld_inv(j+nres)
2476 facd3 = dtail(1,itypi,itypj) * vbld_inv(i+nres)
2479 condor = (erhead_tail(k,2)
2480 & + facd2 * (erhead_tail(k,2) - eagle * dC_norm(k,j+nres)))
2482 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
2483 gvdwx(k,i) = gvdwx(k,i)
2485 & - dPOLdR2 * (erhead_tail(k,2)
2486 & -facd3 * (erhead_tail(k,2) - adler * dC_norm(k,i+nres)))
2489 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
2490 gvdwx(k,j) = gvdwx(k,j)
2492 & + dPOLdR2 * condor
2496 gvdwc(k,i) = gvdwc(k,i)
2497 & - dGCLdR * erhead(k)
2498 & - dPOLdR2 * erhead_tail(k,2)
2499 & - dGLJdR * erhead(k)
2501 gvdwc(k,j) = gvdwc(k,j)
2502 & + dGCLdR * erhead(k)
2503 & + dPOLdR2 * erhead_tail(k,2)
2504 & + dGLJdR * erhead(k)
2511 C--------------------------------------------------------------------
2516 INCLUDE 'DIMENSIONS'
2517 INCLUDE 'DIMENSIONS.ZSCOPT'
2518 INCLUDE 'COMMON.CALC'
2519 INCLUDE 'COMMON.CHAIN'
2520 INCLUDE 'COMMON.CONTROL'
2521 INCLUDE 'COMMON.DERIV'
2522 INCLUDE 'COMMON.EMP'
2523 INCLUDE 'COMMON.GEO'
2524 INCLUDE 'COMMON.INTERACT'
2525 INCLUDE 'COMMON.IOUNITS'
2526 INCLUDE 'COMMON.LOCAL'
2527 INCLUDE 'COMMON.NAMES'
2528 INCLUDE 'COMMON.VAR'
2529 double precision scalar
2530 c! csig = sigiso(itypi,itypj)
2531 w1 = wqdip(1,itypi,itypj)
2532 w2 = wqdip(2,itypi,itypj)
2533 c!-------------------------------------------------------------------
2535 fac = (om12 - 3.0d0 * om1 * om2)
2536 c1 = (w1 / (Rhead**3.0d0)) * fac
2537 c2 = (w2 / Rhead ** 6.0d0)
2538 & * (4.0d0 + fac * fac -3.0d0 * (sqom1 + sqom2))
2540 c! write (*,*) "w1 = ", w1
2541 c! write (*,*) "w2 = ", w2
2542 c! write (*,*) "om1 = ", om1
2543 c! write (*,*) "om2 = ", om2
2544 c! write (*,*) "om12 = ", om12
2545 c! write (*,*) "fac = ", fac
2546 c! write (*,*) "c1 = ", c1
2547 c! write (*,*) "c2 = ", c2
2548 c! write (*,*) "Ecl = ", Ecl
2549 c! write (*,*) "c2_1 = ", (w2 / Rhead ** 6.0d0)
2550 c! write (*,*) "c2_2 = ",
2551 c! & (4.0d0 + fac * fac -3.0d0 * (sqom1 + sqom2))
2552 c!-------------------------------------------------------------------
2553 c! dervative of ECL is GCL...
2555 c1 = (-3.0d0 * w1 * fac) / (Rhead ** 4.0d0)
2556 c2 = (-6.0d0 * w2) / (Rhead ** 7.0d0)
2557 & * (4.0d0 + fac * fac - 3.0d0 * (sqom1 + sqom2))
2560 c1 = (-3.0d0 * w1 * om2 ) / (Rhead**3.0d0)
2561 c2 = (-6.0d0 * w2) / (Rhead**6.0d0)
2562 & * ( om2 * om12 - 3.0d0 * om1 * sqom2 + om1 )
2565 c1 = (-3.0d0 * w1 * om1 ) / (Rhead**3.0d0)
2566 c2 = (-6.0d0 * w2) / (Rhead**6.0d0)
2567 & * ( om1 * om12 - 3.0d0 * sqom1 * om2 + om2 )
2570 c1 = w1 / (Rhead ** 3.0d0)
2571 c2 = ( 2.0d0 * w2 * fac ) / Rhead ** 6.0d0
2573 c!-------------------------------------------------------------------
2574 c! Return the results
2575 c! (see comments in Eqq)
2577 erhead(k) = Rhead_distance(k)/Rhead
2579 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
2580 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
2581 facd1 = d1 * vbld_inv(i+nres)
2582 facd2 = d2 * vbld_inv(j+nres)
2585 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
2586 gvdwx(k,i) = gvdwx(k,i)
2588 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
2589 gvdwx(k,j) = gvdwx(k,j)
2592 gvdwc(k,i) = gvdwc(k,i)
2593 & - dGCLdR * erhead(k)
2594 gvdwc(k,j) = gvdwc(k,j)
2595 & + dGCLdR * erhead(k)
2601 c!-------------------------------------------------------------------
2604 SUBROUTINE elgrad_init(eheadtail,Egb,Ecl,Elj,Equad,Epol)
2607 INCLUDE 'DIMENSIONS'
2608 c! itypi, itypj, i, j, k, l, chead,
2609 INCLUDE 'COMMON.CALC'
2611 INCLUDE 'COMMON.CHAIN'
2613 INCLUDE 'COMMON.DERIV'
2614 c! electrostatic gradients-specific variables
2615 INCLUDE 'COMMON.EMP'
2616 c! wquad, dhead, alphiso, alphasur, rborn, epsintab
2617 INCLUDE 'COMMON.INTERACT'
2618 c! io for debug, disable it in final builds
2619 INCLUDE 'COMMON.IOUNITS'
2620 c!-------------------------------------------------------------------
2623 c! what amino acid is the aminoacid j'th?
2625 c! 1/(Gas Constant * Thermostate temperature) = BetaT
2626 c! ENABLE THIS LINE WHEN USING CHECKGRAD!!!
2627 BetaT = 1.0d0 / (298 * 1.987d-3)
2629 sig0ij = sigma( itypi,itypj )
2630 chi1 = chi( itypi, itypj )
2631 chi2 = chi( itypj, itypi )
2633 chip1 = chipp( itypi, itypj )
2634 chip2 = chipp( itypj, itypi )
2635 chip12 = chip1 * chip2
2636 c! write (2,*) "elgrad types",itypi,itypj,
2637 c! & " chi1",chi1," chi2",chi2," chi12",chi12,
2638 c! & " chip1",chip1," chip2",chip2," chip12",chip12
2639 c! not used by momo potential, but needed by sc_angular which is shared
2640 c! by all energy_potential subroutines
2644 c! location, location, location
2645 xj = c( 1, nres+j ) - xi
2646 yj = c( 2, nres+j ) - yi
2647 zj = c( 3, nres+j ) - zi
2648 dxj = dc_norm( 1, nres+j )
2649 dyj = dc_norm( 2, nres+j )
2650 dzj = dc_norm( 3, nres+j )
2651 c! distance from center of chain(?) to polar/charged head
2652 c! write (*,*) "istate = ", 1
2653 c! write (*,*) "ii = ", 1
2654 c! write (*,*) "jj = ", 1
2655 d1 = dhead(1, 1, itypi, itypj)
2656 d2 = dhead(2, 1, itypi, itypj)
2658 a12sq = rborn(itypi,itypj) * rborn(itypj,itypi)
2659 c! a12sq = a12sq * a12sq
2660 c! charge of amino acid itypi is...
2665 chis1 = chis(itypi,itypj)
2666 chis2 = chis(itypj,itypi)
2667 chis12 = chis1 * chis2
2668 sig1 = sigmap1(itypi,itypj)
2669 sig2 = sigmap2(itypi,itypj)
2670 c! write (*,*) "sig1 = ", sig1
2671 c! write (*,*) "sig2 = ", sig2
2672 c! alpha factors from Fcav/Gcav
2673 b1 = alphasur(1,itypi,itypj)
2674 b2 = alphasur(2,itypi,itypj)
2675 b3 = alphasur(3,itypi,itypj)
2676 b4 = alphasur(4,itypi,itypj)
2677 c! used to determine whether we want to do quadrupole calculations
2678 wqd = wquad(itypi, itypj)
2680 eps_in = epsintab(itypi,itypj)
2681 eps_inout_fac = ( (1.0d0/eps_in) - (1.0d0/eps_out))
2682 c! write (*,*) "eps_inout_fac = ", eps_inout_fac
2683 c!-------------------------------------------------------------------
2684 c! tail location and distance calculations
2687 ctail(k,1)=c(k,i+nres)-dtail(1,itypi,itypj)*dc_norm(k,nres+i)
2688 ctail(k,2)=c(k,j+nres)-dtail(2,itypi,itypj)*dc_norm(k,nres+j)
2690 c! tail distances will be themselves usefull elswhere
2691 c1 (in Gcav, for example)
2692 Rtail_distance(1) = ctail( 1, 2 ) - ctail( 1,1 )
2693 Rtail_distance(2) = ctail( 2, 2 ) - ctail( 2,1 )
2694 Rtail_distance(3) = ctail( 3, 2 ) - ctail( 3,1 )
2696 & (Rtail_distance(1)*Rtail_distance(1))
2697 & + (Rtail_distance(2)*Rtail_distance(2))
2698 & + (Rtail_distance(3)*Rtail_distance(3)))
2699 c!-------------------------------------------------------------------
2700 c! Calculate location and distance between polar heads
2701 c! distance between heads
2702 c! for each one of our three dimensional space...
2704 c! location of polar head is computed by taking hydrophobic centre
2705 c! and moving by a d1 * dc_norm vector
2706 c! see unres publications for very informative images
2707 chead(k,1) = c(k, i+nres) + d1 * dc_norm(k, i+nres)
2708 chead(k,2) = c(k, j+nres) + d2 * dc_norm(k, j+nres)
2710 c! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
2711 c! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
2712 Rhead_distance(k) = chead(k,2) - chead(k,1)
2714 c! pitagoras (root of sum of squares)
2716 & (Rhead_distance(1)*Rhead_distance(1))
2717 & + (Rhead_distance(2)*Rhead_distance(2))
2718 & + (Rhead_distance(3)*Rhead_distance(3)))
2719 c!-------------------------------------------------------------------
2720 c! zero everything that should be zero'ed
2733 END SUBROUTINE elgrad_init
2734 c!-------------------------------------------------------------------
2735 subroutine sc_angular
2736 C Calculate eps1,eps2,eps3,sigma, and parts of their derivatives in om1,om2,
2737 C om12. Called by ebp, egb, and egbv.
2739 include 'COMMON.CALC'
2740 include 'COMMON.IOUNITS'
2744 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
2745 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
2746 om12=dxi*dxj+dyi*dyj+dzi*dzj
2751 C Calculate eps1(om12) and its derivative in om12
2752 faceps1=1.0D0-om12*chiom12
2753 faceps1_inv=1.0D0/faceps1
2754 eps1=dsqrt(faceps1_inv)
2755 c write (2,*) "chi1",chi1," chi2",chi2," chi12",chi12
2756 c write (2,*) "fsceps1",faceps1," faceps1_inv",faceps1_inv,
2758 C Following variable is eps1*deps1/dom12
2759 eps1_om12=faceps1_inv*chiom12
2764 c write (iout,*) "om12",om12," eps1",eps1
2765 C Calculate sigma(om1,om2,om12) and the derivatives of sigma**2 in om1,om2,
2770 facsig=om1*chiom1+om2*chiom2-2.0D0*om1om2*chiom12
2771 sigsq=1.0D0-facsig*faceps1_inv
2772 c write (2,*) "om1",om1," om2",om2," om1om2",om1om2,
2773 c & " chiom1",chiom1,
2774 c & " chiom2",chiom2," facsig",facsig," sigsq",sigsq
2775 sigsq_om1=(chiom1-chiom12*om2)*faceps1_inv
2776 sigsq_om2=(chiom2-chiom12*om1)*faceps1_inv
2777 sigsq_om12=-chi12*(om1om2*faceps1-om12*facsig)*faceps1_inv**2
2783 c write (iout,*) "chiom1",chiom1," chiom2",chiom2," chiom12",chiom12
2784 c write (iout,*) "faceps1",faceps1," faceps1_inv",faceps1_inv,
2786 C Calculate eps2 and its derivatives in om1, om2, and om12.
2789 chipom12=chip12*om12
2790 facp=1.0D0-om12*chipom12
2792 facp1=om1*chipom1+om2*chipom2-2.0D0*om1om2*chipom12
2793 c write (iout,*) "chipom1",chipom1," chipom2",chipom2,
2794 c & " chipom12",chipom12," facp",facp," facp_inv",facp_inv
2795 C Following variable is the square root of eps2
2796 eps2rt=1.0D0-facp1*facp_inv
2797 C Following three variables are the derivatives of the square root of eps
2798 C in om1, om2, and om12.
2799 eps2rt_om1=-4.0D0*(chipom1-chipom12*om2)*facp_inv
2800 eps2rt_om2=-4.0D0*(chipom2-chipom12*om1)*facp_inv
2801 eps2rt_om12=4.0D0*chip12*(om1om2*facp-om12*facp1)*facp_inv**2
2802 C Evaluate the "asymmetric" factor in the VDW constant, eps3
2803 c! Note that THIS is 0 in emomo, so we should probably move it out of sc_angular
2804 c! Or frankly, we should restructurize the whole energy section
2805 eps3rt=1.0D0-alf1*om1+alf2*om2-alf12*om12
2806 c write (iout,*) "eps2rt",eps2rt," eps3rt",eps3rt
2807 c write (iout,*) "eps2rt_om1",eps2rt_om1," eps2rt_om2",eps2rt_om2,
2808 c & " eps2rt_om12",eps2rt_om12
2809 C Calculate whole angle-dependent part of epsilon and contributions
2810 C to its derivatives
2813 C----------------------------------------------------------------------------
2815 implicit real*8 (a-h,o-z)
2816 include 'DIMENSIONS'
2817 include 'DIMENSIONS.ZSCOPT'
2818 include 'COMMON.CHAIN'
2819 include 'COMMON.DERIV'
2820 include 'COMMON.CALC'
2821 double precision dcosom1(3),dcosom2(3)
2822 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
2823 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
2824 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12
2825 & -2.0D0*alf12*eps3der+sigder*sigsq_om12
2827 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
2828 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
2831 gg(k)=gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
2834 gvdwx(k,i)=gvdwx(k,i)-gg(k)
2835 & +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))
2836 & +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
2837 gvdwx(k,j)=gvdwx(k,j)+gg(k)
2838 & +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))
2839 & +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
2842 C Calculate the components of the gradient in DC and X
2846 gvdwc(l,k)=gvdwc(l,k)+gg(l)
2851 c------------------------------------------------------------------------------
2852 subroutine vec_and_deriv
2853 implicit real*8 (a-h,o-z)
2854 include 'DIMENSIONS'
2855 include 'DIMENSIONS.ZSCOPT'
2856 include 'COMMON.IOUNITS'
2857 include 'COMMON.GEO'
2858 include 'COMMON.VAR'
2859 include 'COMMON.LOCAL'
2860 include 'COMMON.CHAIN'
2861 include 'COMMON.VECTORS'
2862 include 'COMMON.DERIV'
2863 include 'COMMON.INTERACT'
2864 dimension uyder(3,3,2),uzder(3,3,2),vbld_inv_temp(2)
2865 C Compute the local reference systems. For reference system (i), the
2866 C X-axis points from CA(i) to CA(i+1), the Y axis is in the
2867 C CA(i)-CA(i+1)-CA(i+2) plane, and the Z axis is perpendicular to this plane.
2869 c if (i.eq.nres-1 .or. itel(i+1).eq.0) then
2870 if (i.eq.nres-1) then
2871 C Case of the last full residue
2872 C Compute the Z-axis
2873 call vecpr(dc_norm(1,i),dc_norm(1,i-1),uz(1,i))
2874 costh=dcos(pi-theta(nres))
2875 fac=1.0d0/dsqrt(1.0d0-costh*costh)
2880 C Compute the derivatives of uz
2882 uzder(2,1,1)=-dc_norm(3,i-1)
2883 uzder(3,1,1)= dc_norm(2,i-1)
2884 uzder(1,2,1)= dc_norm(3,i-1)
2886 uzder(3,2,1)=-dc_norm(1,i-1)
2887 uzder(1,3,1)=-dc_norm(2,i-1)
2888 uzder(2,3,1)= dc_norm(1,i-1)
2891 uzder(2,1,2)= dc_norm(3,i)
2892 uzder(3,1,2)=-dc_norm(2,i)
2893 uzder(1,2,2)=-dc_norm(3,i)
2895 uzder(3,2,2)= dc_norm(1,i)
2896 uzder(1,3,2)= dc_norm(2,i)
2897 uzder(2,3,2)=-dc_norm(1,i)
2900 C Compute the Y-axis
2903 uy(k,i)=fac*(dc_norm(k,i-1)-costh*dc_norm(k,i))
2906 C Compute the derivatives of uy
2909 uyder(k,j,1)=2*dc_norm(k,i-1)*dc_norm(j,i)
2910 & -dc_norm(k,i)*dc_norm(j,i-1)
2911 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
2913 uyder(j,j,1)=uyder(j,j,1)-costh
2914 uyder(j,j,2)=1.0d0+uyder(j,j,2)
2919 uygrad(l,k,j,i)=uyder(l,k,j)
2920 uzgrad(l,k,j,i)=uzder(l,k,j)
2924 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
2925 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
2926 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
2927 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
2931 C Compute the Z-axis
2932 call vecpr(dc_norm(1,i),dc_norm(1,i+1),uz(1,i))
2933 costh=dcos(pi-theta(i+2))
2934 fac=1.0d0/dsqrt(1.0d0-costh*costh)
2939 C Compute the derivatives of uz
2941 uzder(2,1,1)=-dc_norm(3,i+1)
2942 uzder(3,1,1)= dc_norm(2,i+1)
2943 uzder(1,2,1)= dc_norm(3,i+1)
2945 uzder(3,2,1)=-dc_norm(1,i+1)
2946 uzder(1,3,1)=-dc_norm(2,i+1)
2947 uzder(2,3,1)= dc_norm(1,i+1)
2950 uzder(2,1,2)= dc_norm(3,i)
2951 uzder(3,1,2)=-dc_norm(2,i)
2952 uzder(1,2,2)=-dc_norm(3,i)
2954 uzder(3,2,2)= dc_norm(1,i)
2955 uzder(1,3,2)= dc_norm(2,i)
2956 uzder(2,3,2)=-dc_norm(1,i)
2959 C Compute the Y-axis
2962 uy(k,i)=facy*(dc_norm(k,i+1)-costh*dc_norm(k,i))
2965 C Compute the derivatives of uy
2968 uyder(k,j,1)=2*dc_norm(k,i+1)*dc_norm(j,i)
2969 & -dc_norm(k,i)*dc_norm(j,i+1)
2970 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
2972 uyder(j,j,1)=uyder(j,j,1)-costh
2973 uyder(j,j,2)=1.0d0+uyder(j,j,2)
2978 uygrad(l,k,j,i)=uyder(l,k,j)
2979 uzgrad(l,k,j,i)=uzder(l,k,j)
2983 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
2984 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
2985 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
2986 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
2992 vbld_inv_temp(1)=vbld_inv(i+1)
2993 if (i.lt.nres-1) then
2994 vbld_inv_temp(2)=vbld_inv(i+2)
2996 vbld_inv_temp(2)=vbld_inv(i)
3001 uygrad(l,k,j,i)=vbld_inv_temp(j)*uygrad(l,k,j,i)
3002 uzgrad(l,k,j,i)=vbld_inv_temp(j)*uzgrad(l,k,j,i)
3010 C-----------------------------------------------------------------------------
3011 subroutine vec_and_deriv_test
3012 implicit real*8 (a-h,o-z)
3013 include 'DIMENSIONS'
3014 include 'DIMENSIONS.ZSCOPT'
3015 include 'COMMON.IOUNITS'
3016 include 'COMMON.GEO'
3017 include 'COMMON.VAR'
3018 include 'COMMON.LOCAL'
3019 include 'COMMON.CHAIN'
3020 include 'COMMON.VECTORS'
3021 dimension uyder(3,3,2),uzder(3,3,2)
3022 C Compute the local reference systems. For reference system (i), the
3023 C X-axis points from CA(i) to CA(i+1), the Y axis is in the
3024 C CA(i)-CA(i+1)-CA(i+2) plane, and the Z axis is perpendicular to this plane.
3026 if (i.eq.nres-1) then
3027 C Case of the last full residue
3028 C Compute the Z-axis
3029 call vecpr(dc_norm(1,i),dc_norm(1,i-1),uz(1,i))
3030 costh=dcos(pi-theta(nres))
3031 fac=1.0d0/dsqrt(1.0d0-costh*costh)
3032 c write (iout,*) 'fac',fac,
3033 c & 1.0d0/dsqrt(scalar(uz(1,i),uz(1,i)))
3034 fac=1.0d0/dsqrt(scalar(uz(1,i),uz(1,i)))
3038 C Compute the derivatives of uz
3040 uzder(2,1,1)=-dc_norm(3,i-1)
3041 uzder(3,1,1)= dc_norm(2,i-1)
3042 uzder(1,2,1)= dc_norm(3,i-1)
3044 uzder(3,2,1)=-dc_norm(1,i-1)
3045 uzder(1,3,1)=-dc_norm(2,i-1)
3046 uzder(2,3,1)= dc_norm(1,i-1)
3049 uzder(2,1,2)= dc_norm(3,i)
3050 uzder(3,1,2)=-dc_norm(2,i)
3051 uzder(1,2,2)=-dc_norm(3,i)
3053 uzder(3,2,2)= dc_norm(1,i)
3054 uzder(1,3,2)= dc_norm(2,i)
3055 uzder(2,3,2)=-dc_norm(1,i)
3057 C Compute the Y-axis
3059 uy(k,i)=fac*(dc_norm(k,i-1)-costh*dc_norm(k,i))
3062 facy=1.0d0/dsqrt(scalar(dc_norm(1,i),dc_norm(1,i))*
3063 & (scalar(dc_norm(1,i-1),dc_norm(1,i-1))**2-
3064 & scalar(dc_norm(1,i),dc_norm(1,i-1))**2))
3066 c uy(k,i)=facy*(dc_norm(k,i+1)-costh*dc_norm(k,i))
3069 & dc_norm(k,i-1)*scalar(dc_norm(1,i),dc_norm(1,i))
3070 & -scalar(dc_norm(1,i),dc_norm(1,i-1))*dc_norm(k,i)
3073 c write (iout,*) 'facy',facy,
3074 c & 1.0d0/dsqrt(scalar(uy(1,i),uy(1,i)))
3075 facy=1.0d0/dsqrt(scalar(uy(1,i),uy(1,i)))
3077 uy(k,i)=facy*uy(k,i)
3079 C Compute the derivatives of uy
3082 uyder(k,j,1)=2*dc_norm(k,i-1)*dc_norm(j,i)
3083 & -dc_norm(k,i)*dc_norm(j,i-1)
3084 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
3086 c uyder(j,j,1)=uyder(j,j,1)-costh
3087 c uyder(j,j,2)=1.0d0+uyder(j,j,2)
3088 uyder(j,j,1)=uyder(j,j,1)
3089 & -scalar(dc_norm(1,i),dc_norm(1,i-1))
3090 uyder(j,j,2)=scalar(dc_norm(1,i),dc_norm(1,i))
3096 uygrad(l,k,j,i)=uyder(l,k,j)
3097 uzgrad(l,k,j,i)=uzder(l,k,j)
3101 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
3102 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
3103 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
3104 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
3107 C Compute the Z-axis
3108 call vecpr(dc_norm(1,i),dc_norm(1,i+1),uz(1,i))
3109 costh=dcos(pi-theta(i+2))
3110 fac=1.0d0/dsqrt(1.0d0-costh*costh)
3111 fac=1.0d0/dsqrt(scalar(uz(1,i),uz(1,i)))
3115 C Compute the derivatives of uz
3117 uzder(2,1,1)=-dc_norm(3,i+1)
3118 uzder(3,1,1)= dc_norm(2,i+1)
3119 uzder(1,2,1)= dc_norm(3,i+1)
3121 uzder(3,2,1)=-dc_norm(1,i+1)
3122 uzder(1,3,1)=-dc_norm(2,i+1)
3123 uzder(2,3,1)= dc_norm(1,i+1)
3126 uzder(2,1,2)= dc_norm(3,i)
3127 uzder(3,1,2)=-dc_norm(2,i)
3128 uzder(1,2,2)=-dc_norm(3,i)
3130 uzder(3,2,2)= dc_norm(1,i)
3131 uzder(1,3,2)= dc_norm(2,i)
3132 uzder(2,3,2)=-dc_norm(1,i)
3134 C Compute the Y-axis
3136 facy=1.0d0/dsqrt(scalar(dc_norm(1,i),dc_norm(1,i))*
3137 & (scalar(dc_norm(1,i+1),dc_norm(1,i+1))**2-
3138 & scalar(dc_norm(1,i),dc_norm(1,i+1))**2))
3140 c uy(k,i)=facy*(dc_norm(k,i+1)-costh*dc_norm(k,i))
3143 & dc_norm(k,i+1)*scalar(dc_norm(1,i),dc_norm(1,i))
3144 & -scalar(dc_norm(1,i),dc_norm(1,i+1))*dc_norm(k,i)
3147 c write (iout,*) 'facy',facy,
3148 c & 1.0d0/dsqrt(scalar(uy(1,i),uy(1,i)))
3149 facy=1.0d0/dsqrt(scalar(uy(1,i),uy(1,i)))
3151 uy(k,i)=facy*uy(k,i)
3153 C Compute the derivatives of uy
3156 uyder(k,j,1)=2*dc_norm(k,i+1)*dc_norm(j,i)
3157 & -dc_norm(k,i)*dc_norm(j,i+1)
3158 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
3160 c uyder(j,j,1)=uyder(j,j,1)-costh
3161 c uyder(j,j,2)=1.0d0+uyder(j,j,2)
3162 uyder(j,j,1)=uyder(j,j,1)
3163 & -scalar(dc_norm(1,i),dc_norm(1,i+1))
3164 uyder(j,j,2)=scalar(dc_norm(1,i),dc_norm(1,i))
3170 uygrad(l,k,j,i)=uyder(l,k,j)
3171 uzgrad(l,k,j,i)=uzder(l,k,j)
3175 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
3176 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
3177 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
3178 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
3185 uygrad(l,k,j,i)=vblinv*uygrad(l,k,j,i)
3186 uzgrad(l,k,j,i)=vblinv*uzgrad(l,k,j,i)
3193 C-----------------------------------------------------------------------------
3194 subroutine check_vecgrad
3195 implicit real*8 (a-h,o-z)
3196 include 'DIMENSIONS'
3197 include 'DIMENSIONS.ZSCOPT'
3198 include 'COMMON.IOUNITS'
3199 include 'COMMON.GEO'
3200 include 'COMMON.VAR'
3201 include 'COMMON.LOCAL'
3202 include 'COMMON.CHAIN'
3203 include 'COMMON.VECTORS'
3204 dimension uygradt(3,3,2,maxres),uzgradt(3,3,2,maxres)
3205 dimension uyt(3,maxres),uzt(3,maxres)
3206 dimension uygradn(3,3,2),uzgradn(3,3,2),erij(3)
3207 double precision delta /1.0d-7/
3210 crc write(iout,'(2i5,2(3f10.5,5x))') i,1,dc_norm(:,i)
3211 crc write(iout,'(2i5,2(3f10.5,5x))') i,2,uy(:,i)
3212 crc write(iout,'(2i5,2(3f10.5,5x)/)')i,3,uz(:,i)
3213 cd write(iout,'(2i5,2(3f10.5,5x))') i,1,
3214 cd & (dc_norm(if90,i),if90=1,3)
3215 cd write(iout,'(2i5,2(3f10.5,5x))') i,2,(uy(if90,i),if90=1,3)
3216 cd write(iout,'(2i5,2(3f10.5,5x)/)')i,3,(uz(if90,i),if90=1,3)
3217 cd write(iout,'(a)')
3223 uygradt(l,k,j,i)=uygrad(l,k,j,i)
3224 uzgradt(l,k,j,i)=uzgrad(l,k,j,i)
3237 cd write (iout,*) 'i=',i
3239 erij(k)=dc_norm(k,i)
3243 dc_norm(k,i)=erij(k)
3245 dc_norm(j,i)=dc_norm(j,i)+delta
3246 c fac=dsqrt(scalar(dc_norm(1,i),dc_norm(1,i)))
3248 c dc_norm(k,i)=dc_norm(k,i)/fac
3250 c write (iout,*) (dc_norm(k,i),k=1,3)
3251 c write (iout,*) (erij(k),k=1,3)
3254 uygradn(k,j,1)=(uy(k,i)-uyt(k,i))/delta
3255 uygradn(k,j,2)=(uy(k,i-1)-uyt(k,i-1))/delta
3256 uzgradn(k,j,1)=(uz(k,i)-uzt(k,i))/delta
3257 uzgradn(k,j,2)=(uz(k,i-1)-uzt(k,i-1))/delta
3259 c write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
3260 c & j,(uzgradt(k,j,1,i),k=1,3),(uzgradn(k,j,1),k=1,3),
3261 c & (uzgradt(k,j,2,i-1),k=1,3),(uzgradn(k,j,2),k=1,3)
3264 dc_norm(k,i)=erij(k)
3267 cd write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
3268 cd & k,(uygradt(k,l,1,i),l=1,3),(uygradn(k,l,1),l=1,3),
3269 cd & (uygradt(k,l,2,i-1),l=1,3),(uygradn(k,l,2),l=1,3)
3270 cd write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
3271 cd & k,(uzgradt(k,l,1,i),l=1,3),(uzgradn(k,l,1),l=1,3),
3272 cd & (uzgradt(k,l,2,i-1),l=1,3),(uzgradn(k,l,2),l=1,3)
3273 cd write (iout,'(a)')
3278 C--------------------------------------------------------------------------
3279 subroutine set_matrices
3280 implicit real*8 (a-h,o-z)
3281 include 'DIMENSIONS'
3282 include 'DIMENSIONS.ZSCOPT'
3283 include 'COMMON.IOUNITS'
3284 include 'COMMON.GEO'
3285 include 'COMMON.VAR'
3286 include 'COMMON.LOCAL'
3287 include 'COMMON.CHAIN'
3288 include 'COMMON.DERIV'
3289 include 'COMMON.INTERACT'
3290 include 'COMMON.CONTACTS'
3291 include 'COMMON.TORSION'
3292 include 'COMMON.VECTORS'
3293 include 'COMMON.FFIELD'
3294 double precision auxvec(2),auxmat(2,2)
3296 C Compute the virtual-bond-torsional-angle dependent quantities needed
3297 C to calculate the el-loc multibody terms of various order.
3300 if (i .lt. nres+1) then
3337 if (i .gt. 3 .and. i .lt. nres+1) then
3338 obrot_der(1,i-2)=-sin1
3339 obrot_der(2,i-2)= cos1
3340 Ugder(1,1,i-2)= sin1
3341 Ugder(1,2,i-2)=-cos1
3342 Ugder(2,1,i-2)=-cos1
3343 Ugder(2,2,i-2)=-sin1
3346 obrot2_der(1,i-2)=-dwasin2
3347 obrot2_der(2,i-2)= dwacos2
3348 Ug2der(1,1,i-2)= dwasin2
3349 Ug2der(1,2,i-2)=-dwacos2
3350 Ug2der(2,1,i-2)=-dwacos2
3351 Ug2der(2,2,i-2)=-dwasin2
3353 obrot_der(1,i-2)=0.0d0
3354 obrot_der(2,i-2)=0.0d0
3355 Ugder(1,1,i-2)=0.0d0
3356 Ugder(1,2,i-2)=0.0d0
3357 Ugder(2,1,i-2)=0.0d0
3358 Ugder(2,2,i-2)=0.0d0
3359 obrot2_der(1,i-2)=0.0d0
3360 obrot2_der(2,i-2)=0.0d0
3361 Ug2der(1,1,i-2)=0.0d0
3362 Ug2der(1,2,i-2)=0.0d0
3363 Ug2der(2,1,i-2)=0.0d0
3364 Ug2der(2,2,i-2)=0.0d0
3366 if (i.gt. iatel_s+2 .and. i.lt.iatel_e+5) then
3367 iti = itortyp(itype(i-2))
3371 if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
3372 iti1 = itortyp(itype(i-1))
3376 cd write (iout,*) '*******i',i,' iti1',iti
3377 cd write (iout,*) 'b1',b1(:,iti)
3378 cd write (iout,*) 'b2',b2(:,iti)
3379 cd write (iout,*) 'Ug',Ug(:,:,i-2)
3380 if (i .gt. iatel_s+2) then
3381 call matvec2(Ug(1,1,i-2),b2(1,iti),Ub2(1,i-2))
3382 call matmat2(EE(1,1,iti),Ug(1,1,i-2),EUg(1,1,i-2))
3383 call matmat2(CC(1,1,iti),Ug(1,1,i-2),CUg(1,1,i-2))
3384 call matmat2(DD(1,1,iti),Ug(1,1,i-2),DUg(1,1,i-2))
3385 call matmat2(Dtilde(1,1,iti),Ug2(1,1,i-2),DtUg2(1,1,i-2))
3386 call matvec2(Ctilde(1,1,iti1),obrot(1,i-2),Ctobr(1,i-2))
3387 call matvec2(Dtilde(1,1,iti),obrot2(1,i-2),Dtobr2(1,i-2))
3397 DtUg2(l,k,i-2)=0.0d0
3401 call matvec2(Ugder(1,1,i-2),b2(1,iti),Ub2der(1,i-2))
3402 call matmat2(EE(1,1,iti),Ugder(1,1,i-2),EUgder(1,1,i-2))
3403 call matmat2(CC(1,1,iti1),Ugder(1,1,i-2),CUgder(1,1,i-2))
3404 call matmat2(DD(1,1,iti),Ugder(1,1,i-2),DUgder(1,1,i-2))
3405 call matmat2(Dtilde(1,1,iti),Ug2der(1,1,i-2),DtUg2der(1,1,i-2))
3406 call matvec2(Ctilde(1,1,iti1),obrot_der(1,i-2),Ctobrder(1,i-2))
3407 call matvec2(Dtilde(1,1,iti),obrot2_der(1,i-2),Dtobr2der(1,i-2))
3409 muder(k,i-2)=Ub2der(k,i-2)
3411 if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
3412 iti1 = itortyp(itype(i-1))
3417 mu(k,i-2)=Ub2(k,i-2)+b1(k,iti1)
3419 C Vectors and matrices dependent on a single virtual-bond dihedral.
3420 call matvec2(DD(1,1,iti),b1tilde(1,iti1),auxvec(1))
3421 call matvec2(Ug2(1,1,i-2),auxvec(1),Ug2Db1t(1,i-2))
3422 call matvec2(Ug2der(1,1,i-2),auxvec(1),Ug2Db1tder(1,i-2))
3423 call matvec2(CC(1,1,iti1),Ub2(1,i-2),CUgb2(1,i-2))
3424 call matvec2(CC(1,1,iti1),Ub2der(1,i-2),CUgb2der(1,i-2))
3425 call matmat2(EUg(1,1,i-2),CC(1,1,iti1),EUgC(1,1,i-2))
3426 call matmat2(EUgder(1,1,i-2),CC(1,1,iti1),EUgCder(1,1,i-2))
3427 call matmat2(EUg(1,1,i-2),DD(1,1,iti1),EUgD(1,1,i-2))
3428 call matmat2(EUgder(1,1,i-2),DD(1,1,iti1),EUgDder(1,1,i-2))
3429 cd write (iout,*) 'i',i,' mu ',(mu(k,i-2),k=1,2),
3430 cd & ' mu1',(b1(k,i-2),k=1,2),' mu2',(Ub2(k,i-2),k=1,2)
3432 C Matrices dependent on two consecutive virtual-bond dihedrals.
3433 C The order of matrices is from left to right.
3435 call matmat2(DtUg2(1,1,i-1),EUg(1,1,i),DtUg2EUg(1,1,i))
3436 call matmat2(DtUg2der(1,1,i-1),EUg(1,1,i),DtUg2EUgder(1,1,1,i))
3437 call matmat2(DtUg2(1,1,i-1),EUgder(1,1,i),DtUg2EUgder(1,1,2,i))
3438 call transpose2(DtUg2(1,1,i-1),auxmat(1,1))
3439 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUg(1,1,i))
3440 call matmat2(auxmat(1,1),EUgder(1,1,i),Ug2DtEUgder(1,1,2,i))
3441 call transpose2(DtUg2der(1,1,i-1),auxmat(1,1))
3442 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUgder(1,1,1,i))
3445 cd iti = itortyp(itype(i))
3448 cd write (iout,'(2f10.5,5x,2f10.5,5x,2f10.5)')
3449 cd & (EE(j,k,iti),k=1,2),(Ug(j,k,i),k=1,2),(EUg(j,k,i),k=1,2)
3454 C--------------------------------------------------------------------------
3455 subroutine eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
3457 C This subroutine calculates the average interaction energy and its gradient
3458 C in the virtual-bond vectors between non-adjacent peptide groups, based on
3459 C the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
3460 C The potential depends both on the distance of peptide-group centers and on
3461 C the orientation of the CA-CA virtual bonds.
3463 implicit real*8 (a-h,o-z)
3464 include 'DIMENSIONS'
3465 include 'DIMENSIONS.ZSCOPT'
3466 include 'COMMON.CONTROL'
3467 include 'COMMON.IOUNITS'
3468 include 'COMMON.GEO'
3469 include 'COMMON.VAR'
3470 include 'COMMON.LOCAL'
3471 include 'COMMON.CHAIN'
3472 include 'COMMON.DERIV'
3473 include 'COMMON.INTERACT'
3474 include 'COMMON.CONTACTS'
3475 include 'COMMON.TORSION'
3476 include 'COMMON.VECTORS'
3477 include 'COMMON.FFIELD'
3478 dimension ggg(3),gggp(3),gggm(3),erij(3),dcosb(3),dcosg(3),
3479 & erder(3,3),uryg(3,3),urzg(3,3),vryg(3,3),vrzg(3,3)
3480 double precision acipa(2,2),agg(3,4),aggi(3,4),aggi1(3,4),
3481 & aggj(3,4),aggj1(3,4),a_temp(2,2),muij(4)
3482 common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,j1
3483 c 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
3484 double precision scal_el /0.5d0/
3486 C 13-go grudnia roku pamietnego...
3487 double precision unmat(3,3) /1.0d0,0.0d0,0.0d0,
3488 & 0.0d0,1.0d0,0.0d0,
3489 & 0.0d0,0.0d0,1.0d0/
3490 cd write(iout,*) 'In EELEC'
3492 cd write(iout,*) 'Type',i
3493 cd write(iout,*) 'B1',B1(:,i)
3494 cd write(iout,*) 'B2',B2(:,i)
3495 cd write(iout,*) 'CC',CC(:,:,i)
3496 cd write(iout,*) 'DD',DD(:,:,i)
3497 cd write(iout,*) 'EE',EE(:,:,i)
3499 cd call check_vecgrad
3501 if (icheckgrad.eq.1) then
3503 fac=1.0d0/dsqrt(scalar(dc(1,i),dc(1,i)))
3505 dc_norm(k,i)=dc(k,i)*fac
3507 c write (iout,*) 'i',i,' fac',fac
3510 if (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0
3511 & .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 .or.
3512 & wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) then
3513 cd if (wel_loc.gt.0.0d0) then
3514 if (icheckgrad.eq.1) then
3515 call vec_and_deriv_test
3522 cd write (iout,*) 'i=',i
3524 cd write (iout,'(i5,2f10.5)') k,uy(k,i),uz(k,i)
3527 cd write (iout,'(f10.5,2x,3f10.5,2x,3f10.5)')
3528 cd & uz(k,i),(uzgrad(k,l,1,i),l=1,3),(uzgrad(k,l,2,i),l=1,3)
3541 cd print '(a)','Enter EELEC'
3542 cd write (iout,*) 'iatel_s=',iatel_s,' iatel_e=',iatel_e
3544 gel_loc_loc(i)=0.0d0
3547 do i=iatel_s,iatel_e
3548 if (itel(i).eq.0) goto 1215
3552 dx_normi=dc_norm(1,i)
3553 dy_normi=dc_norm(2,i)
3554 dz_normi=dc_norm(3,i)
3555 xmedi=c(1,i)+0.5d0*dxi
3556 ymedi=c(2,i)+0.5d0*dyi
3557 zmedi=c(3,i)+0.5d0*dzi
3559 c write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
3560 do j=ielstart(i),ielend(i)
3561 if (itel(j).eq.0) goto 1216
3565 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
3566 aaa=app(iteli,itelj)
3567 bbb=bpp(iteli,itelj)
3568 C Diagnostics only!!!
3574 ael6i=ael6(iteli,itelj)
3575 ael3i=ael3(iteli,itelj)
3579 dx_normj=dc_norm(1,j)
3580 dy_normj=dc_norm(2,j)
3581 dz_normj=dc_norm(3,j)
3582 xj=c(1,j)+0.5D0*dxj-xmedi
3583 yj=c(2,j)+0.5D0*dyj-ymedi
3584 zj=c(3,j)+0.5D0*dzj-zmedi
3585 rij=xj*xj+yj*yj+zj*zj
3591 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
3592 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
3593 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
3594 fac=cosa-3.0D0*cosb*cosg
3596 c 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
3597 if (j.eq.i+2) ev1=scal_el*ev1
3602 el1=fac3*(4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg))
3605 c write (iout,*) "i",i,iteli," j",j,itelj," eesij",eesij
3606 C 12/26/95 - for the evaluation of multi-body H-bonding interactions
3607 ees0ij=4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg)
3610 cd write(iout,'(2(2i3,2x),7(1pd12.4)/2(3(1pd12.4),5x)/)')
3611 cd & iteli,i,itelj,j,aaa,bbb,ael6i,ael3i,
3612 cd & 1.0D0/dsqrt(rrmij),evdwij,eesij,
3613 cd & xmedi,ymedi,zmedi,xj,yj,zj
3615 C Calculate contributions to the Cartesian gradient.
3618 facvdw=-6*rrmij*(ev1+evdwij)
3619 facel=-3*rrmij*(el1+eesij)
3626 * Radial derivatives. First process both termini of the fragment (i,j)
3633 gelc(k,i)=gelc(k,i)+ghalf
3634 gelc(k,j)=gelc(k,j)+ghalf
3637 * Loop over residues i+1 thru j-1.
3641 gelc(l,k)=gelc(l,k)+ggg(l)
3649 gvdwpp(k,i)=gvdwpp(k,i)+ghalf
3650 gvdwpp(k,j)=gvdwpp(k,j)+ghalf
3653 * Loop over residues i+1 thru j-1.
3657 gvdwpp(l,k)=gvdwpp(l,k)+ggg(l)
3664 fac=-3*rrmij*(facvdw+facvdw+facel)
3670 * Radial derivatives. First process both termini of the fragment (i,j)
3677 gelc(k,i)=gelc(k,i)+ghalf
3678 gelc(k,j)=gelc(k,j)+ghalf
3681 * Loop over residues i+1 thru j-1.
3685 gelc(l,k)=gelc(l,k)+ggg(l)
3692 ecosa=2.0D0*fac3*fac1+fac4
3695 ecosb=(fac3*(fac1*cosg+cosb)+cosg*fac4)
3696 ecosg=(fac3*(fac1*cosb+cosg)+cosb*fac4)
3698 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
3699 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
3701 cd print '(2i3,2(3(1pd14.5),3x))',i,j,(dcosb(k),k=1,3),
3702 cd & (dcosg(k),k=1,3)
3704 ggg(k)=ecosb*dcosb(k)+ecosg*dcosg(k)
3708 gelc(k,i)=gelc(k,i)+ghalf
3709 & +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
3710 & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
3711 gelc(k,j)=gelc(k,j)+ghalf
3712 & +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
3713 & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
3717 gelc(l,k)=gelc(l,k)+ggg(l)
3722 IF (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0
3723 & .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0
3724 & .or. wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
3726 C 9/25/99 Mixed third-order local-electrostatic terms. The local-interaction
3727 C energy of a peptide unit is assumed in the form of a second-order
3728 C Fourier series in the angles lambda1 and lambda2 (see Nishikawa et al.
3729 C Macromolecules, 1974, 7, 797-806 for definition). This correlation terms
3730 C are computed for EVERY pair of non-contiguous peptide groups.
3732 if (j.lt.nres-1) then
3743 muij(kkk)=mu(k,i)*mu(l,j)
3746 cd write (iout,*) 'EELEC: i',i,' j',j
3747 cd write (iout,*) 'j',j,' j1',j1,' j2',j2
3748 cd write(iout,*) 'muij',muij
3749 ury=scalar(uy(1,i),erij)
3750 urz=scalar(uz(1,i),erij)
3751 vry=scalar(uy(1,j),erij)
3752 vrz=scalar(uz(1,j),erij)
3753 a22=scalar(uy(1,i),uy(1,j))-3*ury*vry
3754 a23=scalar(uy(1,i),uz(1,j))-3*ury*vrz
3755 a32=scalar(uz(1,i),uy(1,j))-3*urz*vry
3756 a33=scalar(uz(1,i),uz(1,j))-3*urz*vrz
3757 C For diagnostics only
3762 fac=dsqrt(-ael6i)*r3ij
3763 cd write (2,*) 'fac=',fac
3764 C For diagnostics only
3770 cd write (iout,'(4i5,4f10.5)')
3771 cd & i,itortyp(itype(i)),j,itortyp(itype(j)),a22,a23,a32,a33
3772 cd write (iout,'(6f10.5)') (muij(k),k=1,4),fac,eel_loc_ij
3773 cd write (iout,'(2(3f10.5,5x)/2(3f10.5,5x))') (uy(k,i),k=1,3),
3774 cd & (uz(k,i),k=1,3),(uy(k,j),k=1,3),(uz(k,j),k=1,3)
3775 cd write (iout,'(4f10.5)')
3776 cd & scalar(uy(1,i),uy(1,j)),scalar(uy(1,i),uz(1,j)),
3777 cd & scalar(uz(1,i),uy(1,j)),scalar(uz(1,i),uz(1,j))
3778 cd write (iout,'(4f10.5)') ury,urz,vry,vrz
3779 cd write (iout,'(2i3,9f10.5/)') i,j,
3780 cd & fac22,a22,fac23,a23,fac32,a32,fac33,a33,eel_loc_ij
3782 C Derivatives of the elements of A in virtual-bond vectors
3783 call unormderiv(erij(1),unmat(1,1),rmij,erder(1,1))
3790 uryg(k,1)=scalar(erder(1,k),uy(1,i))
3791 uryg(k,2)=scalar(uygrad(1,k,1,i),erij(1))
3792 uryg(k,3)=scalar(uygrad(1,k,2,i),erij(1))
3793 urzg(k,1)=scalar(erder(1,k),uz(1,i))
3794 urzg(k,2)=scalar(uzgrad(1,k,1,i),erij(1))
3795 urzg(k,3)=scalar(uzgrad(1,k,2,i),erij(1))
3796 vryg(k,1)=scalar(erder(1,k),uy(1,j))
3797 vryg(k,2)=scalar(uygrad(1,k,1,j),erij(1))
3798 vryg(k,3)=scalar(uygrad(1,k,2,j),erij(1))
3799 vrzg(k,1)=scalar(erder(1,k),uz(1,j))
3800 vrzg(k,2)=scalar(uzgrad(1,k,1,j),erij(1))
3801 vrzg(k,3)=scalar(uzgrad(1,k,2,j),erij(1))
3811 C Compute radial contributions to the gradient
3833 C Add the contributions coming from er
3836 agg(k,1)=agg(k,1)+fac3*(uryg(k,1)*vry+vryg(k,1)*ury)
3837 agg(k,2)=agg(k,2)+fac3*(uryg(k,1)*vrz+vrzg(k,1)*ury)
3838 agg(k,3)=agg(k,3)+fac3*(urzg(k,1)*vry+vryg(k,1)*urz)
3839 agg(k,4)=agg(k,4)+fac3*(urzg(k,1)*vrz+vrzg(k,1)*urz)
3842 C Derivatives in DC(i)
3843 ghalf1=0.5d0*agg(k,1)
3844 ghalf2=0.5d0*agg(k,2)
3845 ghalf3=0.5d0*agg(k,3)
3846 ghalf4=0.5d0*agg(k,4)
3847 aggi(k,1)=fac*(scalar(uygrad(1,k,1,i),uy(1,j))
3848 & -3.0d0*uryg(k,2)*vry)+ghalf1
3849 aggi(k,2)=fac*(scalar(uygrad(1,k,1,i),uz(1,j))
3850 & -3.0d0*uryg(k,2)*vrz)+ghalf2
3851 aggi(k,3)=fac*(scalar(uzgrad(1,k,1,i),uy(1,j))
3852 & -3.0d0*urzg(k,2)*vry)+ghalf3
3853 aggi(k,4)=fac*(scalar(uzgrad(1,k,1,i),uz(1,j))
3854 & -3.0d0*urzg(k,2)*vrz)+ghalf4
3855 C Derivatives in DC(i+1)
3856 aggi1(k,1)=fac*(scalar(uygrad(1,k,2,i),uy(1,j))
3857 & -3.0d0*uryg(k,3)*vry)+agg(k,1)
3858 aggi1(k,2)=fac*(scalar(uygrad(1,k,2,i),uz(1,j))
3859 & -3.0d0*uryg(k,3)*vrz)+agg(k,2)
3860 aggi1(k,3)=fac*(scalar(uzgrad(1,k,2,i),uy(1,j))
3861 & -3.0d0*urzg(k,3)*vry)+agg(k,3)
3862 aggi1(k,4)=fac*(scalar(uzgrad(1,k,2,i),uz(1,j))
3863 & -3.0d0*urzg(k,3)*vrz)+agg(k,4)
3864 C Derivatives in DC(j)
3865 aggj(k,1)=fac*(scalar(uygrad(1,k,1,j),uy(1,i))
3866 & -3.0d0*vryg(k,2)*ury)+ghalf1
3867 aggj(k,2)=fac*(scalar(uzgrad(1,k,1,j),uy(1,i))
3868 & -3.0d0*vrzg(k,2)*ury)+ghalf2
3869 aggj(k,3)=fac*(scalar(uygrad(1,k,1,j),uz(1,i))
3870 & -3.0d0*vryg(k,2)*urz)+ghalf3
3871 aggj(k,4)=fac*(scalar(uzgrad(1,k,1,j),uz(1,i))
3872 & -3.0d0*vrzg(k,2)*urz)+ghalf4
3873 C Derivatives in DC(j+1) or DC(nres-1)
3874 aggj1(k,1)=fac*(scalar(uygrad(1,k,2,j),uy(1,i))
3875 & -3.0d0*vryg(k,3)*ury)
3876 aggj1(k,2)=fac*(scalar(uzgrad(1,k,2,j),uy(1,i))
3877 & -3.0d0*vrzg(k,3)*ury)
3878 aggj1(k,3)=fac*(scalar(uygrad(1,k,2,j),uz(1,i))
3879 & -3.0d0*vryg(k,3)*urz)
3880 aggj1(k,4)=fac*(scalar(uzgrad(1,k,2,j),uz(1,i))
3881 & -3.0d0*vrzg(k,3)*urz)
3886 C Derivatives in DC(i+1)
3887 cd aggi1(k,1)=agg(k,1)
3888 cd aggi1(k,2)=agg(k,2)
3889 cd aggi1(k,3)=agg(k,3)
3890 cd aggi1(k,4)=agg(k,4)
3891 C Derivatives in DC(j)
3896 C Derivatives in DC(j+1)
3901 if (j.eq.nres-1 .and. i.lt.j-2) then
3903 aggj1(k,l)=aggj1(k,l)+agg(k,l)
3904 cd aggj1(k,l)=agg(k,l)
3910 C Check the loc-el terms by numerical integration
3920 aggi(k,l)=-aggi(k,l)
3921 aggi1(k,l)=-aggi1(k,l)
3922 aggj(k,l)=-aggj(k,l)
3923 aggj1(k,l)=-aggj1(k,l)
3926 if (j.lt.nres-1) then
3932 aggi(k,l)=-aggi(k,l)
3933 aggi1(k,l)=-aggi1(k,l)
3934 aggj(k,l)=-aggj(k,l)
3935 aggj1(k,l)=-aggj1(k,l)
3946 aggi(k,l)=-aggi(k,l)
3947 aggi1(k,l)=-aggi1(k,l)
3948 aggj(k,l)=-aggj(k,l)
3949 aggj1(k,l)=-aggj1(k,l)
3955 IF (wel_loc.gt.0.0d0) THEN
3956 C Contribution to the local-electrostatic energy coming from the i-j pair
3957 eel_loc_ij=a22*muij(1)+a23*muij(2)+a32*muij(3)
3959 cd write (iout,*) 'i',i,' j',j,' eel_loc_ij',eel_loc_ij
3960 cd write (iout,*) a22,muij(1),a23,muij(2),a32,muij(3)
3961 eel_loc=eel_loc+eel_loc_ij
3962 C Partial derivatives in virtual-bond dihedral angles gamma
3965 & gel_loc_loc(i-1)=gel_loc_loc(i-1)+
3966 & a22*muder(1,i)*mu(1,j)+a23*muder(1,i)*mu(2,j)
3967 & +a32*muder(2,i)*mu(1,j)+a33*muder(2,i)*mu(2,j)
3968 gel_loc_loc(j-1)=gel_loc_loc(j-1)+
3969 & a22*mu(1,i)*muder(1,j)+a23*mu(1,i)*muder(2,j)
3970 & +a32*mu(2,i)*muder(1,j)+a33*mu(2,i)*muder(2,j)
3971 cd call checkint3(i,j,mu1,mu2,a22,a23,a32,a33,acipa,eel_loc_ij)
3972 cd write(iout,*) 'agg ',agg
3973 cd write(iout,*) 'aggi ',aggi
3974 cd write(iout,*) 'aggi1',aggi1
3975 cd write(iout,*) 'aggj ',aggj
3976 cd write(iout,*) 'aggj1',aggj1
3978 C Derivatives of eello in DC(i+1) thru DC(j-1) or DC(nres-2)
3980 ggg(l)=agg(l,1)*muij(1)+
3981 & agg(l,2)*muij(2)+agg(l,3)*muij(3)+agg(l,4)*muij(4)
3985 gel_loc(l,k)=gel_loc(l,k)+ggg(l)
3988 C Remaining derivatives of eello
3990 gel_loc(l,i)=gel_loc(l,i)+aggi(l,1)*muij(1)+
3991 & aggi(l,2)*muij(2)+aggi(l,3)*muij(3)+aggi(l,4)*muij(4)
3992 gel_loc(l,i+1)=gel_loc(l,i+1)+aggi1(l,1)*muij(1)+
3993 & aggi1(l,2)*muij(2)+aggi1(l,3)*muij(3)+aggi1(l,4)*muij(4)
3994 gel_loc(l,j)=gel_loc(l,j)+aggj(l,1)*muij(1)+
3995 & aggj(l,2)*muij(2)+aggj(l,3)*muij(3)+aggj(l,4)*muij(4)
3996 gel_loc(l,j1)=gel_loc(l,j1)+aggj1(l,1)*muij(1)+
3997 & aggj1(l,2)*muij(2)+aggj1(l,3)*muij(3)+aggj1(l,4)*muij(4)
4001 if (wturn3.gt.0.0d0 .or. wturn4.gt.0.0d0) then
4002 C Contributions from turns
4007 call eturn34(i,j,eello_turn3,eello_turn4)
4009 C Change 12/26/95 to calculate four-body contributions to H-bonding energy
4010 if (j.gt.i+1 .and. num_conti.le.maxconts) then
4012 C Calculate the contact function. The ith column of the array JCONT will
4013 C contain the numbers of atoms that make contacts with the atom I (of numbers
4014 C greater than I). The arrays FACONT and GACONT will contain the values of
4015 C the contact function and its derivative.
4016 c r0ij=1.02D0*rpp(iteli,itelj)
4017 c r0ij=1.11D0*rpp(iteli,itelj)
4018 r0ij=2.20D0*rpp(iteli,itelj)
4019 c r0ij=1.55D0*rpp(iteli,itelj)
4020 call gcont(rij,r0ij,1.0D0,0.2d0*r0ij,fcont,fprimcont)
4021 if (fcont.gt.0.0D0) then
4022 num_conti=num_conti+1
4023 if (num_conti.gt.maxconts) then
4024 write (iout,*) 'WARNING - max. # of contacts exceeded;',
4025 & ' will skip next contacts for this conf.'
4027 jcont_hb(num_conti,i)=j
4028 IF (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.
4029 & wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
4030 C 9/30/99 (AL) - store components necessary to evaluate higher-order loc-el
4032 d_cont(num_conti,i)=rij
4033 cd write (2,'(3e15.5)') rij,r0ij+0.2d0*r0ij,rij
4034 C --- Electrostatic-interaction matrix ---
4035 a_chuj(1,1,num_conti,i)=a22
4036 a_chuj(1,2,num_conti,i)=a23
4037 a_chuj(2,1,num_conti,i)=a32
4038 a_chuj(2,2,num_conti,i)=a33
4039 C --- Gradient of rij
4041 grij_hb_cont(kkk,num_conti,i)=erij(kkk)
4044 c a_chuj(1,1,num_conti,i)=-0.61d0
4045 c a_chuj(1,2,num_conti,i)= 0.4d0
4046 c a_chuj(2,1,num_conti,i)= 0.65d0
4047 c a_chuj(2,2,num_conti,i)= 0.50d0
4048 c else if (i.eq.2) then
4049 c a_chuj(1,1,num_conti,i)= 0.0d0
4050 c a_chuj(1,2,num_conti,i)= 0.0d0
4051 c a_chuj(2,1,num_conti,i)= 0.0d0
4052 c a_chuj(2,2,num_conti,i)= 0.0d0
4054 C --- and its gradients
4055 cd write (iout,*) 'i',i,' j',j
4057 cd write (iout,*) 'iii 1 kkk',kkk
4058 cd write (iout,*) agg(kkk,:)
4061 cd write (iout,*) 'iii 2 kkk',kkk
4062 cd write (iout,*) aggi(kkk,:)
4065 cd write (iout,*) 'iii 3 kkk',kkk
4066 cd write (iout,*) aggi1(kkk,:)
4069 cd write (iout,*) 'iii 4 kkk',kkk
4070 cd write (iout,*) aggj(kkk,:)
4073 cd write (iout,*) 'iii 5 kkk',kkk
4074 cd write (iout,*) aggj1(kkk,:)
4081 a_chuj_der(k,l,m,1,num_conti,i)=agg(m,kkll)
4082 a_chuj_der(k,l,m,2,num_conti,i)=aggi(m,kkll)
4083 a_chuj_der(k,l,m,3,num_conti,i)=aggi1(m,kkll)
4084 a_chuj_der(k,l,m,4,num_conti,i)=aggj(m,kkll)
4085 a_chuj_der(k,l,m,5,num_conti,i)=aggj1(m,kkll)
4087 c a_chuj_der(k,l,m,mm,num_conti,i)=0.0d0
4093 IF (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) THEN
4094 C Calculate contact energies
4096 wij=cosa-3.0D0*cosb*cosg
4099 c fac3=dsqrt(-ael6i)/r0ij**3
4100 fac3=dsqrt(-ael6i)*r3ij
4101 ees0pij=dsqrt(4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1)
4102 ees0mij=dsqrt(4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2)
4104 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij)
4105 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij)
4106 C Diagnostics. Comment out or remove after debugging!
4107 c ees0p(num_conti,i)=0.5D0*fac3*ees0pij
4108 c ees0m(num_conti,i)=0.5D0*fac3*ees0mij
4109 c ees0m(num_conti,i)=0.0D0
4111 c write (iout,*) 'i=',i,' j=',j,' rij=',rij,' r0ij=',r0ij,
4112 c & ' ees0ij=',ees0p(num_conti,i),ees0m(num_conti,i),' fcont=',fcont
4113 facont_hb(num_conti,i)=fcont
4115 C Angular derivatives of the contact function
4116 ees0pij1=fac3/ees0pij
4117 ees0mij1=fac3/ees0mij
4118 fac3p=-3.0D0*fac3*rrmij
4119 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
4120 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
4122 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
4123 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
4124 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
4125 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
4126 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
4127 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
4128 ecosap=ecosa1+ecosa2
4129 ecosbp=ecosb1+ecosb2
4130 ecosgp=ecosg1+ecosg2
4131 ecosam=ecosa1-ecosa2
4132 ecosbm=ecosb1-ecosb2
4133 ecosgm=ecosg1-ecosg2
4142 fprimcont=fprimcont/rij
4143 cd facont_hb(num_conti,i)=1.0D0
4144 C Following line is for diagnostics.
4147 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
4148 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
4151 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
4152 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
4154 gggp(1)=gggp(1)+ees0pijp*xj
4155 gggp(2)=gggp(2)+ees0pijp*yj
4156 gggp(3)=gggp(3)+ees0pijp*zj
4157 gggm(1)=gggm(1)+ees0mijp*xj
4158 gggm(2)=gggm(2)+ees0mijp*yj
4159 gggm(3)=gggm(3)+ees0mijp*zj
4160 C Derivatives due to the contact function
4161 gacont_hbr(1,num_conti,i)=fprimcont*xj
4162 gacont_hbr(2,num_conti,i)=fprimcont*yj
4163 gacont_hbr(3,num_conti,i)=fprimcont*zj
4165 ghalfp=0.5D0*gggp(k)
4166 ghalfm=0.5D0*gggm(k)
4167 gacontp_hb1(k,num_conti,i)=ghalfp
4168 & +(ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i))
4169 & + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
4170 gacontp_hb2(k,num_conti,i)=ghalfp
4171 & +(ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j))
4172 & + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
4173 gacontp_hb3(k,num_conti,i)=gggp(k)
4174 gacontm_hb1(k,num_conti,i)=ghalfm
4175 & +(ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i))
4176 & + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
4177 gacontm_hb2(k,num_conti,i)=ghalfm
4178 & +(ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j))
4179 & + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
4180 gacontm_hb3(k,num_conti,i)=gggm(k)
4183 C Diagnostics. Comment out or remove after debugging!
4185 cdiag gacontp_hb1(k,num_conti,i)=0.0D0
4186 cdiag gacontp_hb2(k,num_conti,i)=0.0D0
4187 cdiag gacontp_hb3(k,num_conti,i)=0.0D0
4188 cdiag gacontm_hb1(k,num_conti,i)=0.0D0
4189 cdiag gacontm_hb2(k,num_conti,i)=0.0D0
4190 cdiag gacontm_hb3(k,num_conti,i)=0.0D0
4193 endif ! num_conti.le.maxconts
4198 num_cont_hb(i)=num_conti
4202 cd write (iout,'(i3,3f10.5,5x,3f10.5)')
4203 cd & i,(gel_loc(k,i),k=1,3),gel_loc_loc(i)
4205 c 12/7/99 Adam eello_turn3 will be considered as a separate energy term
4206 ccc eel_loc=eel_loc+eello_turn3
4209 C-----------------------------------------------------------------------------
4210 subroutine eturn34(i,j,eello_turn3,eello_turn4)
4211 C Third- and fourth-order contributions from turns
4212 implicit real*8 (a-h,o-z)
4213 include 'DIMENSIONS'
4214 include 'DIMENSIONS.ZSCOPT'
4215 include 'COMMON.IOUNITS'
4216 include 'COMMON.GEO'
4217 include 'COMMON.VAR'
4218 include 'COMMON.LOCAL'
4219 include 'COMMON.CHAIN'
4220 include 'COMMON.DERIV'
4221 include 'COMMON.INTERACT'
4222 include 'COMMON.CONTACTS'
4223 include 'COMMON.TORSION'
4224 include 'COMMON.VECTORS'
4225 include 'COMMON.FFIELD'
4227 double precision auxmat(2,2),auxmat1(2,2),auxmat2(2,2),pizda(2,2),
4228 & e1t(2,2),e2t(2,2),e3t(2,2),e1tder(2,2),e2tder(2,2),e3tder(2,2),
4229 & e1a(2,2),ae3(2,2),ae3e2(2,2),auxvec(2),auxvec1(2)
4230 double precision agg(3,4),aggi(3,4),aggi1(3,4),
4231 & aggj(3,4),aggj1(3,4),a_temp(2,2)
4232 common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,j1,j2
4234 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4236 C Third-order contributions
4243 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4244 cd call checkint_turn3(i,a_temp,eello_turn3_num)
4245 call matmat2(EUg(1,1,i+1),EUg(1,1,i+2),auxmat(1,1))
4246 call transpose2(auxmat(1,1),auxmat1(1,1))
4247 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4248 eello_turn3=eello_turn3+0.5d0*(pizda(1,1)+pizda(2,2))
4249 cd write (2,*) 'i,',i,' j',j,'eello_turn3',
4250 cd & 0.5d0*(pizda(1,1)+pizda(2,2)),
4251 cd & ' eello_turn3_num',4*eello_turn3_num
4253 C Derivatives in gamma(i)
4254 call matmat2(EUgder(1,1,i+1),EUg(1,1,i+2),auxmat2(1,1))
4255 call transpose2(auxmat2(1,1),pizda(1,1))
4256 call matmat2(a_temp(1,1),pizda(1,1),pizda(1,1))
4257 gel_loc_turn3(i)=gel_loc_turn3(i)+0.5d0*(pizda(1,1)+pizda(2,2))
4258 C Derivatives in gamma(i+1)
4259 call matmat2(EUg(1,1,i+1),EUgder(1,1,i+2),auxmat2(1,1))
4260 call transpose2(auxmat2(1,1),pizda(1,1))
4261 call matmat2(a_temp(1,1),pizda(1,1),pizda(1,1))
4262 gel_loc_turn3(i+1)=gel_loc_turn3(i+1)
4263 & +0.5d0*(pizda(1,1)+pizda(2,2))
4264 C Cartesian derivatives
4266 a_temp(1,1)=aggi(l,1)
4267 a_temp(1,2)=aggi(l,2)
4268 a_temp(2,1)=aggi(l,3)
4269 a_temp(2,2)=aggi(l,4)
4270 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4271 gcorr3_turn(l,i)=gcorr3_turn(l,i)
4272 & +0.5d0*(pizda(1,1)+pizda(2,2))
4273 a_temp(1,1)=aggi1(l,1)
4274 a_temp(1,2)=aggi1(l,2)
4275 a_temp(2,1)=aggi1(l,3)
4276 a_temp(2,2)=aggi1(l,4)
4277 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4278 gcorr3_turn(l,i+1)=gcorr3_turn(l,i+1)
4279 & +0.5d0*(pizda(1,1)+pizda(2,2))
4280 a_temp(1,1)=aggj(l,1)
4281 a_temp(1,2)=aggj(l,2)
4282 a_temp(2,1)=aggj(l,3)
4283 a_temp(2,2)=aggj(l,4)
4284 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4285 gcorr3_turn(l,j)=gcorr3_turn(l,j)
4286 & +0.5d0*(pizda(1,1)+pizda(2,2))
4287 a_temp(1,1)=aggj1(l,1)
4288 a_temp(1,2)=aggj1(l,2)
4289 a_temp(2,1)=aggj1(l,3)
4290 a_temp(2,2)=aggj1(l,4)
4291 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4292 gcorr3_turn(l,j1)=gcorr3_turn(l,j1)
4293 & +0.5d0*(pizda(1,1)+pizda(2,2))
4296 else if (j.eq.i+3) then
4297 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4299 C Fourth-order contributions
4307 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4308 cd call checkint_turn4(i,a_temp,eello_turn4_num)
4309 iti1=itortyp(itype(i+1))
4310 iti2=itortyp(itype(i+2))
4311 iti3=itortyp(itype(i+3))
4312 call transpose2(EUg(1,1,i+1),e1t(1,1))
4313 call transpose2(Eug(1,1,i+2),e2t(1,1))
4314 call transpose2(Eug(1,1,i+3),e3t(1,1))
4315 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4316 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4317 s1=scalar2(b1(1,iti2),auxvec(1))
4318 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4319 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4320 s2=scalar2(b1(1,iti1),auxvec(1))
4321 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4322 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4323 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4324 eello_turn4=eello_turn4-(s1+s2+s3)
4325 cd write (2,*) 'i,',i,' j',j,'eello_turn4',-(s1+s2+s3),
4326 cd & ' eello_turn4_num',8*eello_turn4_num
4327 C Derivatives in gamma(i)
4329 call transpose2(EUgder(1,1,i+1),e1tder(1,1))
4330 call matmat2(e1tder(1,1),a_temp(1,1),auxmat(1,1))
4331 call matvec2(auxmat(1,1),Ub2(1,i+3),auxvec(1))
4332 s1=scalar2(b1(1,iti2),auxvec(1))
4333 call matmat2(ae3e2(1,1),e1tder(1,1),pizda(1,1))
4334 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4335 gel_loc_turn4(i)=gel_loc_turn4(i)-(s1+s3)
4336 C Derivatives in gamma(i+1)
4337 call transpose2(EUgder(1,1,i+2),e2tder(1,1))
4338 call matvec2(ae3(1,1),Ub2der(1,i+2),auxvec(1))
4339 s2=scalar2(b1(1,iti1),auxvec(1))
4340 call matmat2(ae3(1,1),e2tder(1,1),auxmat(1,1))
4341 call matmat2(auxmat(1,1),e1t(1,1),pizda(1,1))
4342 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4343 gel_loc_turn4(i+1)=gel_loc_turn4(i+1)-(s2+s3)
4344 C Derivatives in gamma(i+2)
4345 call transpose2(EUgder(1,1,i+3),e3tder(1,1))
4346 call matvec2(e1a(1,1),Ub2der(1,i+3),auxvec(1))
4347 s1=scalar2(b1(1,iti2),auxvec(1))
4348 call matmat2(a_temp(1,1),e3tder(1,1),auxmat(1,1))
4349 call matvec2(auxmat(1,1),Ub2(1,i+2),auxvec(1))
4350 s2=scalar2(b1(1,iti1),auxvec(1))
4351 call matmat2(auxmat(1,1),e2t(1,1),auxmat(1,1))
4352 call matmat2(auxmat(1,1),e1t(1,1),pizda(1,1))
4353 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4354 gel_loc_turn4(i+2)=gel_loc_turn4(i+2)-(s1+s2+s3)
4355 C Cartesian derivatives
4356 C Derivatives of this turn contributions in DC(i+2)
4357 if (j.lt.nres-1) then
4359 a_temp(1,1)=agg(l,1)
4360 a_temp(1,2)=agg(l,2)
4361 a_temp(2,1)=agg(l,3)
4362 a_temp(2,2)=agg(l,4)
4363 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4364 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4365 s1=scalar2(b1(1,iti2),auxvec(1))
4366 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4367 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4368 s2=scalar2(b1(1,iti1),auxvec(1))
4369 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4370 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4371 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4373 gcorr4_turn(l,i+2)=gcorr4_turn(l,i+2)-(s1+s2+s3)
4376 C Remaining derivatives of this turn contribution
4378 a_temp(1,1)=aggi(l,1)
4379 a_temp(1,2)=aggi(l,2)
4380 a_temp(2,1)=aggi(l,3)
4381 a_temp(2,2)=aggi(l,4)
4382 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4383 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4384 s1=scalar2(b1(1,iti2),auxvec(1))
4385 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4386 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4387 s2=scalar2(b1(1,iti1),auxvec(1))
4388 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4389 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4390 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4391 gcorr4_turn(l,i)=gcorr4_turn(l,i)-(s1+s2+s3)
4392 a_temp(1,1)=aggi1(l,1)
4393 a_temp(1,2)=aggi1(l,2)
4394 a_temp(2,1)=aggi1(l,3)
4395 a_temp(2,2)=aggi1(l,4)
4396 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4397 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4398 s1=scalar2(b1(1,iti2),auxvec(1))
4399 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4400 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4401 s2=scalar2(b1(1,iti1),auxvec(1))
4402 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4403 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4404 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4405 gcorr4_turn(l,i+1)=gcorr4_turn(l,i+1)-(s1+s2+s3)
4406 a_temp(1,1)=aggj(l,1)
4407 a_temp(1,2)=aggj(l,2)
4408 a_temp(2,1)=aggj(l,3)
4409 a_temp(2,2)=aggj(l,4)
4410 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4411 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4412 s1=scalar2(b1(1,iti2),auxvec(1))
4413 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4414 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4415 s2=scalar2(b1(1,iti1),auxvec(1))
4416 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4417 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4418 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4419 gcorr4_turn(l,j)=gcorr4_turn(l,j)-(s1+s2+s3)
4420 a_temp(1,1)=aggj1(l,1)
4421 a_temp(1,2)=aggj1(l,2)
4422 a_temp(2,1)=aggj1(l,3)
4423 a_temp(2,2)=aggj1(l,4)
4424 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4425 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4426 s1=scalar2(b1(1,iti2),auxvec(1))
4427 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4428 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4429 s2=scalar2(b1(1,iti1),auxvec(1))
4430 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4431 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4432 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4433 gcorr4_turn(l,j1)=gcorr4_turn(l,j1)-(s1+s2+s3)
4439 C-----------------------------------------------------------------------------
4440 subroutine vecpr(u,v,w)
4441 implicit real*8(a-h,o-z)
4442 dimension u(3),v(3),w(3)
4443 w(1)=u(2)*v(3)-u(3)*v(2)
4444 w(2)=-u(1)*v(3)+u(3)*v(1)
4445 w(3)=u(1)*v(2)-u(2)*v(1)
4448 C-----------------------------------------------------------------------------
4449 subroutine unormderiv(u,ugrad,unorm,ungrad)
4450 C This subroutine computes the derivatives of a normalized vector u, given
4451 C the derivatives computed without normalization conditions, ugrad. Returns
4454 double precision u(3),ugrad(3,3),unorm,ungrad(3,3)
4455 double precision vec(3)
4456 double precision scalar
4458 c write (2,*) 'ugrad',ugrad
4461 vec(i)=scalar(ugrad(1,i),u(1))
4463 c write (2,*) 'vec',vec
4466 ungrad(j,i)=(ugrad(j,i)-u(j)*vec(i))*unorm
4469 c write (2,*) 'ungrad',ungrad
4472 C-----------------------------------------------------------------------------
4473 subroutine escp(evdw2,evdw2_14)
4475 C This subroutine calculates the excluded-volume interaction energy between
4476 C peptide-group centers and side chains and its gradient in virtual-bond and
4477 C side-chain vectors.
4479 implicit real*8 (a-h,o-z)
4480 include 'DIMENSIONS'
4481 include 'DIMENSIONS.ZSCOPT'
4482 include 'COMMON.GEO'
4483 include 'COMMON.VAR'
4484 include 'COMMON.LOCAL'
4485 include 'COMMON.CHAIN'
4486 include 'COMMON.DERIV'
4487 include 'COMMON.INTERACT'
4488 include 'COMMON.FFIELD'
4489 include 'COMMON.IOUNITS'
4493 cd print '(a)','Enter ESCP'
4494 c write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e,
4495 c & ' scal14',scal14
4496 do i=iatscp_s,iatscp_e
4498 c write (iout,*) "i",i," iteli",iteli," nscp_gr",nscp_gr(i),
4499 c & " iscp",(iscpstart(i,j),iscpend(i,j),j=1,nscp_gr(i))
4500 if (iteli.eq.0) goto 1225
4501 xi=0.5D0*(c(1,i)+c(1,i+1))
4502 yi=0.5D0*(c(2,i)+c(2,i+1))
4503 zi=0.5D0*(c(3,i)+c(3,i+1))
4505 do iint=1,nscp_gr(i)
4507 do j=iscpstart(i,iint),iscpend(i,iint)
4509 C Uncomment following three lines for SC-p interactions
4513 C Uncomment following three lines for Ca-p interactions
4517 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
4519 e1=fac*fac*aad(itypj,iteli)
4520 e2=fac*bad(itypj,iteli)
4521 if (iabs(j-i) .le. 2) then
4524 evdw2_14=evdw2_14+e1+e2
4527 c write (iout,*) i,j,evdwij
4531 C Calculate contributions to the gradient in the virtual-bond and SC vectors.
4533 fac=-(evdwij+e1)*rrij
4538 cd write (iout,*) 'j<i'
4539 C Uncomment following three lines for SC-p interactions
4541 c gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
4544 cd write (iout,*) 'j>i'
4547 C Uncomment following line for SC-p interactions
4548 c gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
4552 gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
4556 cd write (iout,*) 'i=',i,' j=',j,' kstart=',kstart,' kend=',kend
4557 cd write (iout,*) ggg(1),ggg(2),ggg(3)
4560 gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
4570 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
4571 gradx_scp(j,i)=expon*gradx_scp(j,i)
4574 C******************************************************************************
4578 C To save time the factor EXPON has been extracted from ALL components
4579 C of GVDWC and GRADX. Remember to multiply them by this factor before further
4582 C******************************************************************************
4585 C--------------------------------------------------------------------------
4586 subroutine edis(ehpb)
4588 C Evaluate bridge-strain energy and its gradient in virtual-bond and SC vectors.
4590 implicit real*8 (a-h,o-z)
4591 include 'DIMENSIONS'
4592 include 'COMMON.SBRIDGE'
4593 include 'COMMON.CHAIN'
4594 include 'COMMON.DERIV'
4595 include 'COMMON.VAR'
4596 include 'COMMON.INTERACT'
4597 include 'COMMON.IOUNITS'
4600 cd write(iout,*)'edis: nhpb=',nhpb,' fbr=',fbr
4601 cd write(iout,*)'link_start=',link_start,' link_end=',link_end
4602 if (link_end.eq.0) return
4603 do i=link_start,link_end
4604 C If ihpb(i) and jhpb(i) > NRES, this is a SC-SC distance, otherwise a
4605 C CA-CA distance used in regularization of structure.
4608 C iii and jjj point to the residues for which the distance is assigned.
4609 if (ii.gt.nres) then
4616 c write (iout,*) "i",i," ii",ii," iii",iii," jj",jj," jjj",jjj,
4617 c & dhpb(i),dhpb1(i),forcon(i)
4618 C 24/11/03 AL: SS bridges handled separately because of introducing a specific
4619 C distance and angle dependent SS bond potential.
4620 if (ii.gt.nres .and. itype(iii).eq.1 .and. itype(jjj).eq.1) then
4621 call ssbond_ene(iii,jjj,eij)
4623 cd write (iout,*) "eij",eij
4624 else if (ii.gt.nres .and. jj.gt.nres) then
4625 c Restraints from contact prediction
4627 if (dhpb1(i).gt.0.0d0) then
4628 ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
4629 fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
4630 c write (iout,*) "beta nmr",
4631 c & dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
4635 C Get the force constant corresponding to this distance.
4637 C Calculate the contribution to energy.
4638 ehpb=ehpb+waga*rdis*rdis
4639 c write (iout,*) "beta reg",dd,waga*rdis*rdis
4641 C Evaluate gradient.
4646 ggg(j)=fac*(c(j,jj)-c(j,ii))
4649 ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
4650 ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
4653 ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
4654 ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
4657 C Calculate the distance between the two points and its difference from the
4660 if (dhpb1(i).gt.0.0d0) then
4661 ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
4662 fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
4663 c write (iout,*) "alph nmr",
4664 c & dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
4667 C Get the force constant corresponding to this distance.
4669 C Calculate the contribution to energy.
4670 ehpb=ehpb+waga*rdis*rdis
4671 c write (iout,*) "alpha reg",dd,waga*rdis*rdis
4673 C Evaluate gradient.
4677 cd print *,'i=',i,' ii=',ii,' jj=',jj,' dhpb=',dhpb(i),' dd=',dd,
4678 cd & ' waga=',waga,' fac=',fac
4680 ggg(j)=fac*(c(j,jj)-c(j,ii))
4682 cd print '(i3,3(1pe14.5))',i,(ggg(j),j=1,3)
4683 C If this is a SC-SC distance, we need to calculate the contributions to the
4684 C Cartesian gradient in the SC vectors (ghpbx).
4687 ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
4688 ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
4692 ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
4693 ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
4700 C--------------------------------------------------------------------------
4701 subroutine ssbond_ene(i,j,eij)
4703 C Calculate the distance and angle dependent SS-bond potential energy
4704 C using a free-energy function derived based on RHF/6-31G** ab initio
4705 C calculations of diethyl disulfide.
4707 C A. Liwo and U. Kozlowska, 11/24/03
4709 implicit real*8 (a-h,o-z)
4710 include 'DIMENSIONS'
4711 include 'DIMENSIONS.ZSCOPT'
4712 include 'COMMON.SBRIDGE'
4713 include 'COMMON.CHAIN'
4714 include 'COMMON.DERIV'
4715 include 'COMMON.LOCAL'
4716 include 'COMMON.INTERACT'
4717 include 'COMMON.VAR'
4718 include 'COMMON.IOUNITS'
4719 double precision erij(3),dcosom1(3),dcosom2(3),gg(3)
4724 dxi=dc_norm(1,nres+i)
4725 dyi=dc_norm(2,nres+i)
4726 dzi=dc_norm(3,nres+i)
4727 dsci_inv=dsc_inv(itypi)
4729 dscj_inv=dsc_inv(itypj)
4733 dxj=dc_norm(1,nres+j)
4734 dyj=dc_norm(2,nres+j)
4735 dzj=dc_norm(3,nres+j)
4736 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
4741 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
4742 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
4743 om12=dxi*dxj+dyi*dyj+dzi*dzj
4745 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
4746 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
4752 deltat12=om2-om1+2.0d0
4754 eij=akcm*deltad*deltad+akth*(deltat1*deltat1+deltat2*deltat2)
4755 & +akct*deltad*deltat12
4756 & +v1ss*cosphi+v2ss*cosphi*cosphi+v3ss*cosphi*cosphi*cosphi
4757 c write(iout,*) i,j,"rij",rij,"d0cm",d0cm," akcm",akcm," akth",akth,
4758 c & " akct",akct," deltad",deltad," deltat",deltat1,deltat2,
4759 c & " deltat12",deltat12," eij",eij
4760 ed=2*akcm*deltad+akct*deltat12
4762 pom2=v1ss+2*v2ss*cosphi+3*v3ss*cosphi*cosphi
4763 eom1=-2*akth*deltat1-pom1-om2*pom2
4764 eom2= 2*akth*deltat2+pom1-om1*pom2
4767 gg(k)=ed*erij(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
4770 ghpbx(k,i)=ghpbx(k,i)-gg(k)
4771 & +(eom12*dc_norm(k,nres+j)+eom1*erij(k))*dsci_inv
4772 ghpbx(k,j)=ghpbx(k,j)+gg(k)
4773 & +(eom12*dc_norm(k,nres+i)+eom2*erij(k))*dscj_inv
4776 C Calculate the components of the gradient in DC and X
4780 ghpbc(l,k)=ghpbc(l,k)+gg(l)
4785 C--------------------------------------------------------------------------
4786 subroutine ebond(estr)
4788 c Evaluate the energy of stretching of the CA-CA and CA-SC virtual bonds
4790 implicit real*8 (a-h,o-z)
4791 include 'DIMENSIONS'
4792 include 'DIMENSIONS.ZSCOPT'
4793 include 'COMMON.LOCAL'
4794 include 'COMMON.GEO'
4795 include 'COMMON.INTERACT'
4796 include 'COMMON.DERIV'
4797 include 'COMMON.VAR'
4798 include 'COMMON.CHAIN'
4799 include 'COMMON.IOUNITS'
4800 include 'COMMON.NAMES'
4801 include 'COMMON.FFIELD'
4802 include 'COMMON.CONTROL'
4803 double precision u(3),ud(3)
4806 diff = vbld(i)-vbldp0
4807 c write (iout,*) i,vbld(i),vbldp0,diff,AKP*diff*diff
4810 gradb(j,i-1)=AKP*diff*dc(j,i-1)/vbld(i)
4815 c 09/18/07 AL: multimodal bond potential based on AM1 CA-SC PMF's included
4822 diff=vbld(i+nres)-vbldsc0(1,iti)
4823 write (iout,*) i,iti,vbld(i+nres),vbldsc0(1,iti),diff,
4824 & AKSC(1,iti),AKSC(1,iti)*diff*diff
4825 estr=estr+0.5d0*AKSC(1,iti)*diff*diff
4827 gradbx(j,i)=AKSC(1,iti)*diff*dc(j,i+nres)/vbld(i+nres)
4831 diff=vbld(i+nres)-vbldsc0(j,iti)
4832 ud(j)=aksc(j,iti)*diff
4833 u(j)=abond0(j,iti)+0.5d0*ud(j)*diff
4847 uprod2=uprod2*u(k)*u(k)
4851 usumsqder=usumsqder+ud(j)*uprod2
4853 write (iout,*) i,iti,vbld(i+nres),(vbldsc0(j,iti),
4854 & AKSC(j,iti),abond0(j,iti),u(j),j=1,nbi)
4855 estr=estr+uprod/usum
4857 gradbx(j,i)=usumsqder/(usum*usum)*dc(j,i+nres)/vbld(i+nres)
4865 C--------------------------------------------------------------------------
4866 subroutine ebend(etheta)
4868 C Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
4869 C angles gamma and its derivatives in consecutive thetas and gammas.
4871 implicit real*8 (a-h,o-z)
4872 include 'DIMENSIONS'
4873 include 'DIMENSIONS.ZSCOPT'
4874 include 'COMMON.LOCAL'
4875 include 'COMMON.GEO'
4876 include 'COMMON.INTERACT'
4877 include 'COMMON.DERIV'
4878 include 'COMMON.VAR'
4879 include 'COMMON.CHAIN'
4880 include 'COMMON.IOUNITS'
4881 include 'COMMON.NAMES'
4882 include 'COMMON.FFIELD'
4883 common /calcthet/ term1,term2,termm,diffak,ratak,
4884 & ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,
4885 & delthe0,sig0inv,sigtc,sigsqtc,delthec,it
4886 double precision y(2),z(2)
4888 time11=dexp(-2*time)
4891 c write (iout,*) "nres",nres
4892 c write (*,'(a,i2)') 'EBEND ICG=',icg
4893 c write (iout,*) ithet_start,ithet_end
4894 do i=ithet_start,ithet_end
4895 C Zero the energy function and its derivative at 0 or pi.
4896 call splinthet(theta(i),0.5d0*delta,ss,ssd)
4898 c if (i.gt.ithet_start .and.
4899 c & (itel(i-1).eq.0 .or. itel(i-2).eq.0)) goto 1215
4900 c if (i.gt.3 .and. (i.le.4 .or. itel(i-3).ne.0)) then
4908 c if (i.lt.nres .and. itel(i).ne.0) then
4920 call proc_proc(phii,icrc)
4921 if (icrc.eq.1) phii=150.0
4935 call proc_proc(phii1,icrc)
4936 if (icrc.eq.1) phii1=150.0
4948 C Calculate the "mean" value of theta from the part of the distribution
4949 C dependent on the adjacent virtual-bond-valence angles (gamma1 & gamma2).
4950 C In following comments this theta will be referred to as t_c.
4951 thet_pred_mean=0.0d0
4955 thet_pred_mean=thet_pred_mean+athetk*y(k)+bthetk*z(k)
4957 c write (iout,*) "thet_pred_mean",thet_pred_mean
4958 dthett=thet_pred_mean*ssd
4959 thet_pred_mean=thet_pred_mean*ss+a0thet(it)
4960 c write (iout,*) "thet_pred_mean",thet_pred_mean
4961 C Derivatives of the "mean" values in gamma1 and gamma2.
4962 dthetg1=(-athet(1,it)*y(2)+athet(2,it)*y(1))*ss
4963 dthetg2=(-bthet(1,it)*z(2)+bthet(2,it)*z(1))*ss
4964 if (theta(i).gt.pi-delta) then
4965 call theteng(pi-delta,thet_pred_mean,theta0(it),f0,fprim0,
4967 call mixder(pi-delta,thet_pred_mean,theta0(it),fprim_tc0)
4968 call theteng(pi,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
4969 call spline1(theta(i),pi-delta,delta,f0,f1,fprim0,ethetai,
4971 call spline2(theta(i),pi-delta,delta,E_tc0,E_tc1,fprim_tc0,
4973 else if (theta(i).lt.delta) then
4974 call theteng(delta,thet_pred_mean,theta0(it),f0,fprim0,E_tc0)
4975 call theteng(0.0d0,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
4976 call spline1(theta(i),delta,-delta,f0,f1,fprim0,ethetai,
4978 call mixder(delta,thet_pred_mean,theta0(it),fprim_tc0)
4979 call spline2(theta(i),delta,-delta,E_tc0,E_tc1,fprim_tc0,
4982 call theteng(theta(i),thet_pred_mean,theta0(it),ethetai,
4985 etheta=etheta+ethetai
4986 c write (iout,'(2i3,3f8.3,f10.5)') i,it,rad2deg*theta(i),
4987 c & rad2deg*phii,rad2deg*phii1,ethetai
4988 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*E_tc*dthetg1
4989 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*E_tc*dthetg2
4990 gloc(nphi+i-2,icg)=wang*(E_theta+E_tc*dthett)
4993 C Ufff.... We've done all this!!!
4996 C---------------------------------------------------------------------------
4997 subroutine theteng(thetai,thet_pred_mean,theta0i,ethetai,E_theta,
4999 implicit real*8 (a-h,o-z)
5000 include 'DIMENSIONS'
5001 include 'COMMON.LOCAL'
5002 include 'COMMON.IOUNITS'
5003 common /calcthet/ term1,term2,termm,diffak,ratak,
5004 & ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,
5005 & delthe0,sig0inv,sigtc,sigsqtc,delthec,it
5006 C Calculate the contributions to both Gaussian lobes.
5007 C 6/6/97 - Deform the Gaussians using the factor of 1/(1+time)
5008 C The "polynomial part" of the "standard deviation" of this part of
5012 sig=sig*thet_pred_mean+polthet(j,it)
5014 C Derivative of the "interior part" of the "standard deviation of the"
5015 C gamma-dependent Gaussian lobe in t_c.
5016 sigtc=3*polthet(3,it)
5018 sigtc=sigtc*thet_pred_mean+j*polthet(j,it)
5021 C Set the parameters of both Gaussian lobes of the distribution.
5022 C "Standard deviation" of the gamma-dependent Gaussian lobe (sigtc)
5023 fac=sig*sig+sigc0(it)
5026 C Following variable (sigsqtc) is -(1/2)d[sigma(t_c)**(-2))]/dt_c
5027 sigsqtc=-4.0D0*sigcsq*sigtc
5028 c print *,i,sig,sigtc,sigsqtc
5029 C Following variable (sigtc) is d[sigma(t_c)]/dt_c
5030 sigtc=-sigtc/(fac*fac)
5031 C Following variable is sigma(t_c)**(-2)
5032 sigcsq=sigcsq*sigcsq
5034 sig0inv=1.0D0/sig0i**2
5035 delthec=thetai-thet_pred_mean
5036 delthe0=thetai-theta0i
5037 term1=-0.5D0*sigcsq*delthec*delthec
5038 term2=-0.5D0*sig0inv*delthe0*delthe0
5039 C Following fuzzy logic is to avoid underflows in dexp and subsequent INFs and
5040 C NaNs in taking the logarithm. We extract the largest exponent which is added
5041 C to the energy (this being the log of the distribution) at the end of energy
5042 C term evaluation for this virtual-bond angle.
5043 if (term1.gt.term2) then
5045 term2=dexp(term2-termm)
5049 term1=dexp(term1-termm)
5052 C The ratio between the gamma-independent and gamma-dependent lobes of
5053 C the distribution is a Gaussian function of thet_pred_mean too.
5054 diffak=gthet(2,it)-thet_pred_mean
5055 ratak=diffak/gthet(3,it)**2
5056 ak=dexp(gthet(1,it)-0.5D0*diffak*ratak)
5057 C Let's differentiate it in thet_pred_mean NOW.
5059 C Now put together the distribution terms to make complete distribution.
5060 termexp=term1+ak*term2
5061 termpre=sigc+ak*sig0i
5062 C Contribution of the bending energy from this theta is just the -log of
5063 C the sum of the contributions from the two lobes and the pre-exponential
5064 C factor. Simple enough, isn't it?
5065 ethetai=(-dlog(termexp)-termm+dlog(termpre))
5066 C NOW the derivatives!!!
5067 C 6/6/97 Take into account the deformation.
5068 E_theta=(delthec*sigcsq*term1
5069 & +ak*delthe0*sig0inv*term2)/termexp
5070 E_tc=((sigtc+aktc*sig0i)/termpre
5071 & -((delthec*sigcsq+delthec*delthec*sigsqtc)*term1+
5072 & aktc*term2)/termexp)
5075 c-----------------------------------------------------------------------------
5076 subroutine mixder(thetai,thet_pred_mean,theta0i,E_tc_t)
5077 implicit real*8 (a-h,o-z)
5078 include 'DIMENSIONS'
5079 include 'COMMON.LOCAL'
5080 include 'COMMON.IOUNITS'
5081 common /calcthet/ term1,term2,termm,diffak,ratak,
5082 & ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,
5083 & delthe0,sig0inv,sigtc,sigsqtc,delthec,it
5084 delthec=thetai-thet_pred_mean
5085 delthe0=thetai-theta0i
5086 C "Thank you" to MAPLE (probably spared one day of hand-differentiation).
5087 t3 = thetai-thet_pred_mean
5091 t14 = t12+t6*sigsqtc
5093 t21 = thetai-theta0i
5099 E_tc_t = -((sigcsq+2.D0*t3*sigsqtc)*t9-t14*sigcsq*t3*t16*t9
5100 & -aktc*sig0inv*t27)/t32+(t14*t9+aktc*t26)/t40
5101 & *(-t12*t9-ak*sig0inv*t27)
5105 C--------------------------------------------------------------------------
5106 subroutine ebend(etheta)
5108 C Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
5109 C angles gamma and its derivatives in consecutive thetas and gammas.
5110 C ab initio-derived potentials from
5111 c Kozlowska et al., J. Phys.: Condens. Matter 19 (2007) 285203
5113 implicit real*8 (a-h,o-z)
5114 include 'DIMENSIONS'
5115 include 'DIMENSIONS.ZSCOPT'
5116 include 'COMMON.LOCAL'
5117 include 'COMMON.GEO'
5118 include 'COMMON.INTERACT'
5119 include 'COMMON.DERIV'
5120 include 'COMMON.VAR'
5121 include 'COMMON.CHAIN'
5122 include 'COMMON.IOUNITS'
5123 include 'COMMON.NAMES'
5124 include 'COMMON.FFIELD'
5125 include 'COMMON.CONTROL'
5126 double precision coskt(mmaxtheterm),sinkt(mmaxtheterm),
5127 & cosph1(maxsingle),sinph1(maxsingle),cosph2(maxsingle),
5128 & sinph2(maxsingle),cosph1ph2(maxdouble,maxdouble),
5129 & sinph1ph2(maxdouble,maxdouble)
5130 logical lprn /.false./, lprn1 /.false./
5132 c write (iout,*) "ithetyp",(ithetyp(i),i=1,ntyp1)
5133 do i=ithet_start,ithet_end
5137 theti2=0.5d0*theta(i)
5138 ityp2=ithetyp(itype(i-1))
5140 coskt(k)=dcos(k*theti2)
5141 sinkt(k)=dsin(k*theti2)
5146 if (phii.ne.phii) phii=150.0
5150 ityp1=ithetyp(itype(i-2))
5152 cosph1(k)=dcos(k*phii)
5153 sinph1(k)=dsin(k*phii)
5166 if (phii1.ne.phii1) phii1=150.0
5171 ityp3=ithetyp(itype(i))
5173 cosph2(k)=dcos(k*phii1)
5174 sinph2(k)=dsin(k*phii1)
5184 c write (iout,*) "i",i," ityp1",itype(i-2),ityp1,
5185 c & " ityp2",itype(i-1),ityp2," ityp3",itype(i),ityp3
5187 ethetai=aa0thet(ityp1,ityp2,ityp3)
5190 ccl=cosph1(l)*cosph2(k-l)
5191 ssl=sinph1(l)*sinph2(k-l)
5192 scl=sinph1(l)*cosph2(k-l)
5193 csl=cosph1(l)*sinph2(k-l)
5194 cosph1ph2(l,k)=ccl-ssl
5195 cosph1ph2(k,l)=ccl+ssl
5196 sinph1ph2(l,k)=scl+csl
5197 sinph1ph2(k,l)=scl-csl
5201 write (iout,*) "i",i," ityp1",ityp1," ityp2",ityp2,
5202 & " ityp3",ityp3," theti2",theti2," phii",phii," phii1",phii1
5203 write (iout,*) "coskt and sinkt"
5205 write (iout,*) k,coskt(k),sinkt(k)
5209 ethetai=ethetai+aathet(k,ityp1,ityp2,ityp3)*sinkt(k)
5210 dethetai=dethetai+0.5d0*k*aathet(k,ityp1,ityp2,ityp3)
5213 & write (iout,*) "k",k," aathet",aathet(k,ityp1,ityp2,ityp3),
5214 & " ethetai",ethetai
5217 write (iout,*) "cosph and sinph"
5219 write (iout,*) k,cosph1(k),sinph1(k),cosph2(k),sinph2(k)
5221 write (iout,*) "cosph1ph2 and sinph2ph2"
5224 write (iout,*) l,k,cosph1ph2(l,k),cosph1ph2(k,l),
5225 & sinph1ph2(l,k),sinph1ph2(k,l)
5228 write(iout,*) "ethetai",ethetai
5232 aux=bbthet(k,m,ityp1,ityp2,ityp3)*cosph1(k)
5233 & +ccthet(k,m,ityp1,ityp2,ityp3)*sinph1(k)
5234 & +ddthet(k,m,ityp1,ityp2,ityp3)*cosph2(k)
5235 & +eethet(k,m,ityp1,ityp2,ityp3)*sinph2(k)
5236 ethetai=ethetai+sinkt(m)*aux
5237 dethetai=dethetai+0.5d0*m*aux*coskt(m)
5238 dephii=dephii+k*sinkt(m)*(
5239 & ccthet(k,m,ityp1,ityp2,ityp3)*cosph1(k)-
5240 & bbthet(k,m,ityp1,ityp2,ityp3)*sinph1(k))
5241 dephii1=dephii1+k*sinkt(m)*(
5242 & eethet(k,m,ityp1,ityp2,ityp3)*cosph2(k)-
5243 & ddthet(k,m,ityp1,ityp2,ityp3)*sinph2(k))
5245 & write (iout,*) "m",m," k",k," bbthet",
5246 & bbthet(k,m,ityp1,ityp2,ityp3)," ccthet",
5247 & ccthet(k,m,ityp1,ityp2,ityp3)," ddthet",
5248 & ddthet(k,m,ityp1,ityp2,ityp3)," eethet",
5249 & eethet(k,m,ityp1,ityp2,ityp3)," ethetai",ethetai
5253 & write(iout,*) "ethetai",ethetai
5257 aux=ffthet(l,k,m,ityp1,ityp2,ityp3)*cosph1ph2(l,k)+
5258 & ffthet(k,l,m,ityp1,ityp2,ityp3)*cosph1ph2(k,l)+
5259 & ggthet(l,k,m,ityp1,ityp2,ityp3)*sinph1ph2(l,k)+
5260 & ggthet(k,l,m,ityp1,ityp2,ityp3)*sinph1ph2(k,l)
5261 ethetai=ethetai+sinkt(m)*aux
5262 dethetai=dethetai+0.5d0*m*coskt(m)*aux
5263 dephii=dephii+l*sinkt(m)*(
5264 & -ffthet(l,k,m,ityp1,ityp2,ityp3)*sinph1ph2(l,k)-
5265 & ffthet(k,l,m,ityp1,ityp2,ityp3)*sinph1ph2(k,l)+
5266 & ggthet(l,k,m,ityp1,ityp2,ityp3)*cosph1ph2(l,k)+
5267 & ggthet(k,l,m,ityp1,ityp2,ityp3)*cosph1ph2(k,l))
5268 dephii1=dephii1+(k-l)*sinkt(m)*(
5269 & -ffthet(l,k,m,ityp1,ityp2,ityp3)*sinph1ph2(l,k)+
5270 & ffthet(k,l,m,ityp1,ityp2,ityp3)*sinph1ph2(k,l)+
5271 & ggthet(l,k,m,ityp1,ityp2,ityp3)*cosph1ph2(l,k)-
5272 & ggthet(k,l,m,ityp1,ityp2,ityp3)*cosph1ph2(k,l))
5274 write (iout,*) "m",m," k",k," l",l," ffthet",
5275 & ffthet(l,k,m,ityp1,ityp2,ityp3),
5276 & ffthet(k,l,m,ityp1,ityp2,ityp3)," ggthet",
5277 & ggthet(l,k,m,ityp1,ityp2,ityp3),
5278 & ggthet(k,l,m,ityp1,ityp2,ityp3)," ethetai",ethetai
5279 write (iout,*) cosph1ph2(l,k)*sinkt(m),
5280 & cosph1ph2(k,l)*sinkt(m),
5281 & sinph1ph2(l,k)*sinkt(m),sinph1ph2(k,l)*sinkt(m)
5287 if (lprn1) write (iout,'(i2,3f8.1,9h ethetai ,f10.5)')
5288 & i,theta(i)*rad2deg,phii*rad2deg,
5289 & phii1*rad2deg,ethetai
5290 etheta=etheta+ethetai
5291 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*dephii
5292 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*dephii1
5293 gloc(nphi+i-2,icg)=wang*dethetai
5299 c-----------------------------------------------------------------------------
5300 subroutine esc(escloc)
5301 C Calculate the local energy of a side chain and its derivatives in the
5302 C corresponding virtual-bond valence angles THETA and the spherical angles
5304 implicit real*8 (a-h,o-z)
5305 include 'DIMENSIONS'
5306 include 'DIMENSIONS.ZSCOPT'
5307 include 'COMMON.GEO'
5308 include 'COMMON.LOCAL'
5309 include 'COMMON.VAR'
5310 include 'COMMON.INTERACT'
5311 include 'COMMON.DERIV'
5312 include 'COMMON.CHAIN'
5313 include 'COMMON.IOUNITS'
5314 include 'COMMON.NAMES'
5315 include 'COMMON.FFIELD'
5316 double precision x(3),dersc(3),xemp(3),dersc0(3),dersc1(3),
5317 & ddersc0(3),ddummy(3),xtemp(3),temp(3)
5318 common /sccalc/ time11,time12,time112,theti,it,nlobit
5321 c write (iout,'(a)') 'ESC'
5322 do i=loc_start,loc_end
5324 if (it.eq.10) goto 1
5326 c print *,'i=',i,' it=',it,' nlobit=',nlobit
5327 c write (iout,*) 'i=',i,' ssa=',ssa,' ssad=',ssad
5328 theti=theta(i+1)-pipol
5332 c write (iout,*) "i",i," x",x(1),x(2),x(3)
5334 if (x(2).gt.pi-delta) then
5338 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
5340 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
5341 call spline1(x(2),pi-delta,delta,escloci0,escloci1,dersc0(2),
5343 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),
5344 & ddersc0(1),dersc(1))
5345 call spline2(x(2),pi-delta,delta,dersc0(3),dersc1(3),
5346 & ddersc0(3),dersc(3))
5348 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
5350 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
5351 call spline1(x(2),pi-delta,delta,esclocbi0,esclocbi1,
5352 & dersc0(2),esclocbi,dersc02)
5353 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),
5355 call splinthet(x(2),0.5d0*delta,ss,ssd)
5360 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
5362 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
5363 c write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
5365 escloci=ss*escloci+(1.0d0-ss)*esclocbi
5367 c write (iout,*) escloci
5368 else if (x(2).lt.delta) then
5372 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
5374 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
5375 call spline1(x(2),delta,-delta,escloci0,escloci1,dersc0(2),
5377 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),
5378 & ddersc0(1),dersc(1))
5379 call spline2(x(2),delta,-delta,dersc0(3),dersc1(3),
5380 & ddersc0(3),dersc(3))
5382 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
5384 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
5385 call spline1(x(2),delta,-delta,esclocbi0,esclocbi1,
5386 & dersc0(2),esclocbi,dersc02)
5387 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),
5392 call splinthet(x(2),0.5d0*delta,ss,ssd)
5394 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
5396 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
5397 c write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
5399 escloci=ss*escloci+(1.0d0-ss)*esclocbi
5400 c write (iout,*) escloci
5402 call enesc(x,escloci,dersc,ddummy,.false.)
5405 escloc=escloc+escloci
5406 c write (iout,*) 'i=',i,' escloci=',escloci,' dersc=',dersc
5408 gloc(nphi+i-1,icg)=gloc(nphi+i-1,icg)+
5410 gloc(ialph(i,1),icg)=wscloc*dersc(2)
5411 gloc(ialph(i,1)+nside,icg)=wscloc*dersc(3)
5416 C---------------------------------------------------------------------------
5417 subroutine enesc(x,escloci,dersc,ddersc,mixed)
5418 implicit real*8 (a-h,o-z)
5419 include 'DIMENSIONS'
5420 include 'COMMON.GEO'
5421 include 'COMMON.LOCAL'
5422 include 'COMMON.IOUNITS'
5423 common /sccalc/ time11,time12,time112,theti,it,nlobit
5424 double precision x(3),z(3),Ax(3,maxlob,-1:1),dersc(3),ddersc(3)
5425 double precision contr(maxlob,-1:1)
5427 c write (iout,*) 'it=',it,' nlobit=',nlobit
5431 if (mixed) ddersc(j)=0.0d0
5435 C Because of periodicity of the dependence of the SC energy in omega we have
5436 C to add up the contributions from x(3)-2*pi, x(3), and x(3+2*pi).
5437 C To avoid underflows, first compute & store the exponents.
5445 z(k)=x(k)-censc(k,j,it)
5450 Axk=Axk+gaussc(l,k,j,it)*z(l)
5456 expfac=expfac+Ax(k,j,iii)*z(k)
5464 C As in the case of ebend, we want to avoid underflows in exponentiation and
5465 C subsequent NaNs and INFs in energy calculation.
5466 C Find the largest exponent
5470 if (emin.gt.contr(j,iii)) emin=contr(j,iii)
5474 cd print *,'it=',it,' emin=',emin
5476 C Compute the contribution to SC energy and derivatives
5480 expfac=dexp(bsc(j,it)-0.5D0*contr(j,iii)+emin)
5481 cd print *,'j=',j,' expfac=',expfac
5482 escloc_i=escloc_i+expfac
5484 dersc(k)=dersc(k)+Ax(k,j,iii)*expfac
5488 ddersc(k)=ddersc(k)+(-Ax(2,j,iii)*Ax(k,j,iii)
5489 & +gaussc(k,2,j,it))*expfac
5496 dersc(1)=dersc(1)/cos(theti)**2
5497 ddersc(1)=ddersc(1)/cos(theti)**2
5500 escloci=-(dlog(escloc_i)-emin)
5502 dersc(j)=dersc(j)/escloc_i
5506 ddersc(j)=(ddersc(j)/escloc_i+dersc(2)*dersc(j))
5511 C------------------------------------------------------------------------------
5512 subroutine enesc_bound(x,escloci,dersc,dersc12,mixed)
5513 implicit real*8 (a-h,o-z)
5514 include 'DIMENSIONS'
5515 include 'COMMON.GEO'
5516 include 'COMMON.LOCAL'
5517 include 'COMMON.IOUNITS'
5518 common /sccalc/ time11,time12,time112,theti,it,nlobit
5519 double precision x(3),z(3),Ax(3,maxlob),dersc(3)
5520 double precision contr(maxlob)
5531 z(k)=x(k)-censc(k,j,it)
5537 Axk=Axk+gaussc(l,k,j,it)*z(l)
5543 expfac=expfac+Ax(k,j)*z(k)
5548 C As in the case of ebend, we want to avoid underflows in exponentiation and
5549 C subsequent NaNs and INFs in energy calculation.
5550 C Find the largest exponent
5553 if (emin.gt.contr(j)) emin=contr(j)
5557 C Compute the contribution to SC energy and derivatives
5561 expfac=dexp(bsc(j,it)-0.5D0*contr(j)+emin)
5562 escloc_i=escloc_i+expfac
5564 dersc(k)=dersc(k)+Ax(k,j)*expfac
5566 if (mixed) dersc12=dersc12+(-Ax(2,j)*Ax(1,j)
5567 & +gaussc(1,2,j,it))*expfac
5571 dersc(1)=dersc(1)/cos(theti)**2
5572 dersc12=dersc12/cos(theti)**2
5573 escloci=-(dlog(escloc_i)-emin)
5575 dersc(j)=dersc(j)/escloc_i
5577 if (mixed) dersc12=(dersc12/escloc_i+dersc(2)*dersc(1))
5581 c----------------------------------------------------------------------------------
5582 subroutine esc(escloc)
5583 C Calculate the local energy of a side chain and its derivatives in the
5584 C corresponding virtual-bond valence angles THETA and the spherical angles
5585 C ALPHA and OMEGA derived from AM1 all-atom calculations.
5586 C added by Urszula Kozlowska. 07/11/2007
5588 implicit real*8 (a-h,o-z)
5589 include 'DIMENSIONS'
5590 include 'DIMENSIONS.ZSCOPT'
5591 include 'COMMON.GEO'
5592 include 'COMMON.LOCAL'
5593 include 'COMMON.VAR'
5594 include 'COMMON.SCROT'
5595 include 'COMMON.INTERACT'
5596 include 'COMMON.DERIV'
5597 include 'COMMON.CHAIN'
5598 include 'COMMON.IOUNITS'
5599 include 'COMMON.NAMES'
5600 include 'COMMON.FFIELD'
5601 include 'COMMON.CONTROL'
5602 include 'COMMON.VECTORS'
5603 double precision x_prime(3),y_prime(3),z_prime(3)
5604 & , sumene,dsc_i,dp2_i,x(65),
5605 & xx,yy,zz,sumene1,sumene2,sumene3,sumene4,s1,s1_6,s2,s2_6,
5606 & de_dxx,de_dyy,de_dzz,de_dt
5607 double precision s1_t,s1_6_t,s2_t,s2_6_t
5609 & dXX_Ci1(3),dYY_Ci1(3),dZZ_Ci1(3),dXX_Ci(3),
5610 & dYY_Ci(3),dZZ_Ci(3),dXX_XYZ(3),dYY_XYZ(3),dZZ_XYZ(3),
5611 & dt_dCi(3),dt_dCi1(3)
5612 common /sccalc/ time11,time12,time112,theti,it,nlobit
5615 do i=loc_start,loc_end
5616 costtab(i+1) =dcos(theta(i+1))
5617 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
5618 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
5619 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
5620 cosfac2=0.5d0/(1.0d0+costtab(i+1))
5621 cosfac=dsqrt(cosfac2)
5622 sinfac2=0.5d0/(1.0d0-costtab(i+1))
5623 sinfac=dsqrt(sinfac2)
5625 if (it.eq.10) goto 1
5627 C Compute the axes of tghe local cartesian coordinates system; store in
5628 c x_prime, y_prime and z_prime
5635 C write(2,*) "dc_norm", dc_norm(1,i+nres),dc_norm(2,i+nres),
5636 C & dc_norm(3,i+nres)
5638 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
5639 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
5642 z_prime(j) = -uz(j,i-1)
5645 c write (2,*) "x_prime",(x_prime(j),j=1,3)
5646 c write (2,*) "y_prime",(y_prime(j),j=1,3)
5647 c write (2,*) "z_prime",(z_prime(j),j=1,3)
5648 c write (2,*) "xx",scalar(x_prime(1),x_prime(1)),
5649 c & " xy",scalar(x_prime(1),y_prime(1)),
5650 c & " xz",scalar(x_prime(1),z_prime(1)),
5651 c & " yy",scalar(y_prime(1),y_prime(1)),
5652 c & " yz",scalar(y_prime(1),z_prime(1)),
5653 c & " zz",scalar(z_prime(1),z_prime(1))
5655 C Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
5656 C to local coordinate system. Store in xx, yy, zz.
5662 xx = xx + x_prime(j)*dc_norm(j,i+nres)
5663 yy = yy + y_prime(j)*dc_norm(j,i+nres)
5664 zz = zz + z_prime(j)*dc_norm(j,i+nres)
5671 C Compute the energy of the ith side cbain
5673 c write (2,*) "xx",xx," yy",yy," zz",zz
5676 x(j) = sc_parmin(j,it)
5679 Cc diagnostics - remove later
5681 yy1 = dsin(alph(2))*dcos(omeg(2))
5682 zz1 = -dsin(alph(2))*dsin(omeg(2))
5683 write(2,'(3f8.1,3f9.3,1x,3f9.3)')
5684 & alph(2)*rad2deg,omeg(2)*rad2deg,theta(3)*rad2deg,xx,yy,zz,
5686 C," --- ", xx_w,yy_w,zz_w
5689 sumene1= x(1)+ x(2)*xx+ x(3)*yy+ x(4)*zz+ x(5)*xx**2
5690 & + x(6)*yy**2+ x(7)*zz**2+ x(8)*xx*zz+ x(9)*xx*yy
5692 sumene2= x(11) + x(12)*xx + x(13)*yy + x(14)*zz + x(15)*xx**2
5693 & + x(16)*yy**2 + x(17)*zz**2 + x(18)*xx*zz + x(19)*xx*yy
5695 sumene3= x(21) +x(22)*xx +x(23)*yy +x(24)*zz +x(25)*xx**2
5696 & +x(26)*yy**2 +x(27)*zz**2 +x(28)*xx*zz +x(29)*xx*yy
5697 & +x(30)*yy*zz +x(31)*xx**3 +x(32)*yy**3 +x(33)*zz**3
5698 & +x(34)*(xx**2)*yy +x(35)*(xx**2)*zz +x(36)*(yy**2)*xx
5699 & +x(37)*(yy**2)*zz +x(38)*(zz**2)*xx +x(39)*(zz**2)*yy
5701 sumene4= x(41) +x(42)*xx +x(43)*yy +x(44)*zz +x(45)*xx**2
5702 & +x(46)*yy**2 +x(47)*zz**2 +x(48)*xx*zz +x(49)*xx*yy
5703 & +x(50)*yy*zz +x(51)*xx**3 +x(52)*yy**3 +x(53)*zz**3
5704 & +x(54)*(xx**2)*yy +x(55)*(xx**2)*zz +x(56)*(yy**2)*xx
5705 & +x(57)*(yy**2)*zz +x(58)*(zz**2)*xx +x(59)*(zz**2)*yy
5707 dsc_i = 0.743d0+x(61)
5709 dscp1=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i
5710 & *(xx*cost2tab(i+1)+yy*sint2tab(i+1)))
5711 dscp2=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i
5712 & *(xx*cost2tab(i+1)-yy*sint2tab(i+1)))
5713 s1=(1+x(63))/(0.1d0 + dscp1)
5714 s1_6=(1+x(64))/(0.1d0 + dscp1**6)
5715 s2=(1+x(65))/(0.1d0 + dscp2)
5716 s2_6=(1+x(65))/(0.1d0 + dscp2**6)
5717 sumene = ( sumene3*sint2tab(i+1) + sumene1)*(s1+s1_6)
5718 & + (sumene4*cost2tab(i+1) +sumene2)*(s2+s2_6)
5719 c write(2,'(i2," sumene",7f9.3)') i,sumene1,sumene2,sumene3,
5721 c & dscp1,dscp2,sumene
5722 c sumene = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
5723 escloc = escloc + sumene
5724 c write (2,*) "escloc",escloc
5725 if (.not. calc_grad) goto 1
5728 C This section to check the numerical derivatives of the energy of ith side
5729 C chain in xx, yy, zz, and theta. Use the -DDEBUG compiler option or insert
5730 C #define DEBUG in the code to turn it on.
5732 write (2,*) "sumene =",sumene
5736 write (2,*) xx,yy,zz
5737 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
5738 de_dxx_num=(sumenep-sumene)/aincr
5740 write (2,*) "xx+ sumene from enesc=",sumenep
5743 write (2,*) xx,yy,zz
5744 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
5745 de_dyy_num=(sumenep-sumene)/aincr
5747 write (2,*) "yy+ sumene from enesc=",sumenep
5750 write (2,*) xx,yy,zz
5751 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
5752 de_dzz_num=(sumenep-sumene)/aincr
5754 write (2,*) "zz+ sumene from enesc=",sumenep
5755 costsave=cost2tab(i+1)
5756 sintsave=sint2tab(i+1)
5757 cost2tab(i+1)=dcos(0.5d0*(theta(i+1)+aincr))
5758 sint2tab(i+1)=dsin(0.5d0*(theta(i+1)+aincr))
5759 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
5760 de_dt_num=(sumenep-sumene)/aincr
5761 write (2,*) " t+ sumene from enesc=",sumenep
5762 cost2tab(i+1)=costsave
5763 sint2tab(i+1)=sintsave
5764 C End of diagnostics section.
5767 C Compute the gradient of esc
5769 pom_s1=(1.0d0+x(63))/(0.1d0 + dscp1)**2
5770 pom_s16=6*(1.0d0+x(64))/(0.1d0 + dscp1**6)**2
5771 pom_s2=(1.0d0+x(65))/(0.1d0 + dscp2)**2
5772 pom_s26=6*(1.0d0+x(65))/(0.1d0 + dscp2**6)**2
5773 pom_dx=dsc_i*dp2_i*cost2tab(i+1)
5774 pom_dy=dsc_i*dp2_i*sint2tab(i+1)
5775 pom_dt1=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)-yy*cost2tab(i+1))
5776 pom_dt2=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)+yy*cost2tab(i+1))
5777 pom1=(sumene3*sint2tab(i+1)+sumene1)
5778 & *(pom_s1/dscp1+pom_s16*dscp1**4)
5779 pom2=(sumene4*cost2tab(i+1)+sumene2)
5780 & *(pom_s2/dscp2+pom_s26*dscp2**4)
5781 sumene1x=x(2)+2*x(5)*xx+x(8)*zz+ x(9)*yy
5782 sumene3x=x(22)+2*x(25)*xx+x(28)*zz+x(29)*yy+3*x(31)*xx**2
5783 & +2*x(34)*xx*yy +2*x(35)*xx*zz +x(36)*(yy**2) +x(38)*(zz**2)
5785 sumene2x=x(12)+2*x(15)*xx+x(18)*zz+ x(19)*yy
5786 sumene4x=x(42)+2*x(45)*xx +x(48)*zz +x(49)*yy +3*x(51)*xx**2
5787 & +2*x(54)*xx*yy+2*x(55)*xx*zz+x(56)*(yy**2)+x(58)*(zz**2)
5789 de_dxx =(sumene1x+sumene3x*sint2tab(i+1))*(s1+s1_6)
5790 & +(sumene2x+sumene4x*cost2tab(i+1))*(s2+s2_6)
5791 & +(pom1+pom2)*pom_dx
5793 write(2,*), "de_dxx = ", de_dxx,de_dxx_num
5796 sumene1y=x(3) + 2*x(6)*yy + x(9)*xx + x(10)*zz
5797 sumene3y=x(23) +2*x(26)*yy +x(29)*xx +x(30)*zz +3*x(32)*yy**2
5798 & +x(34)*(xx**2) +2*x(36)*yy*xx +2*x(37)*yy*zz +x(39)*(zz**2)
5800 sumene2y=x(13) + 2*x(16)*yy + x(19)*xx + x(20)*zz
5801 sumene4y=x(43)+2*x(46)*yy+x(49)*xx +x(50)*zz
5802 & +3*x(52)*yy**2+x(54)*xx**2+2*x(56)*yy*xx +2*x(57)*yy*zz
5803 & +x(59)*zz**2 +x(60)*xx*zz
5804 de_dyy =(sumene1y+sumene3y*sint2tab(i+1))*(s1+s1_6)
5805 & +(sumene2y+sumene4y*cost2tab(i+1))*(s2+s2_6)
5806 & +(pom1-pom2)*pom_dy
5808 write(2,*), "de_dyy = ", de_dyy,de_dyy_num
5811 de_dzz =(x(24) +2*x(27)*zz +x(28)*xx +x(30)*yy
5812 & +3*x(33)*zz**2 +x(35)*xx**2 +x(37)*yy**2 +2*x(38)*zz*xx
5813 & +2*x(39)*zz*yy +x(40)*xx*yy)*sint2tab(i+1)*(s1+s1_6)
5814 & +(x(4) + 2*x(7)*zz+ x(8)*xx + x(10)*yy)*(s1+s1_6)
5815 & +(x(44)+2*x(47)*zz +x(48)*xx +x(50)*yy +3*x(53)*zz**2
5816 & +x(55)*xx**2 +x(57)*(yy**2)+2*x(58)*zz*xx +2*x(59)*zz*yy
5817 & +x(60)*xx*yy)*cost2tab(i+1)*(s2+s2_6)
5818 & + ( x(14) + 2*x(17)*zz+ x(18)*xx + x(20)*yy)*(s2+s2_6)
5820 write(2,*), "de_dzz = ", de_dzz,de_dzz_num
5823 de_dt = 0.5d0*sumene3*cost2tab(i+1)*(s1+s1_6)
5824 & -0.5d0*sumene4*sint2tab(i+1)*(s2+s2_6)
5825 & +pom1*pom_dt1+pom2*pom_dt2
5827 write(2,*), "de_dt = ", de_dt,de_dt_num
5831 cossc=scalar(dc_norm(1,i),dc_norm(1,i+nres))
5832 cossc1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
5833 cosfac2xx=cosfac2*xx
5834 sinfac2yy=sinfac2*yy
5836 dt_dCi(k) = -(dc_norm(k,i-1)+costtab(i+1)*dc_norm(k,i))*
5838 dt_dCi1(k)= -(dc_norm(k,i)+costtab(i+1)*dc_norm(k,i-1))*
5840 pom=(dC_norm(k,i+nres)-cossc*dC_norm(k,i))*vbld_inv(i+1)
5841 pom1=(dC_norm(k,i+nres)-cossc1*dC_norm(k,i-1))*vbld_inv(i)
5842 c write (iout,*) "i",i," k",k," pom",pom," pom1",pom1,
5843 c & " dt_dCi",dt_dCi(k)," dt_dCi1",dt_dCi1(k)
5844 c write (iout,*) "dC_norm",(dC_norm(j,i),j=1,3),
5845 c & (dC_norm(j,i-1),j=1,3)," vbld_inv",vbld_inv(i+1),vbld_inv(i)
5846 dXX_Ci(k)=pom*cosfac-dt_dCi(k)*cosfac2xx
5847 dXX_Ci1(k)=-pom1*cosfac-dt_dCi1(k)*cosfac2xx
5848 dYY_Ci(k)=pom*sinfac+dt_dCi(k)*sinfac2yy
5849 dYY_Ci1(k)=pom1*sinfac+dt_dCi1(k)*sinfac2yy
5853 dZZ_Ci(k)=dZZ_Ci(k)-uzgrad(j,k,2,i-1)*dC_norm(j,i+nres)
5854 dZZ_Ci1(k)=dZZ_Ci1(k)-uzgrad(j,k,1,i-1)*dC_norm(j,i+nres)
5857 dXX_XYZ(k)=vbld_inv(i+nres)*(x_prime(k)-xx*dC_norm(k,i+nres))
5858 dYY_XYZ(k)=vbld_inv(i+nres)*(y_prime(k)-yy*dC_norm(k,i+nres))
5859 dZZ_XYZ(k)=vbld_inv(i+nres)*(z_prime(k)-zz*dC_norm(k,i+nres))
5861 dt_dCi(k) = -dt_dCi(k)/sinttab(i+1)
5862 dt_dCi1(k)= -dt_dCi1(k)/sinttab(i+1)
5866 dXX_Ctab(k,i)=dXX_Ci(k)
5867 dXX_C1tab(k,i)=dXX_Ci1(k)
5868 dYY_Ctab(k,i)=dYY_Ci(k)
5869 dYY_C1tab(k,i)=dYY_Ci1(k)
5870 dZZ_Ctab(k,i)=dZZ_Ci(k)
5871 dZZ_C1tab(k,i)=dZZ_Ci1(k)
5872 dXX_XYZtab(k,i)=dXX_XYZ(k)
5873 dYY_XYZtab(k,i)=dYY_XYZ(k)
5874 dZZ_XYZtab(k,i)=dZZ_XYZ(k)
5878 c write (iout,*) "k",k," dxx_ci1",dxx_ci1(k)," dyy_ci1",
5879 c & dyy_ci1(k)," dzz_ci1",dzz_ci1(k)
5880 c write (iout,*) "k",k," dxx_ci",dxx_ci(k)," dyy_ci",
5881 c & dyy_ci(k)," dzz_ci",dzz_ci(k)
5882 c write (iout,*) "k",k," dt_dci",dt_dci(k)," dt_dci",
5884 c write (iout,*) "k",k," dxx_XYZ",dxx_XYZ(k)," dyy_XYZ",
5885 c & dyy_XYZ(k)," dzz_XYZ",dzz_XYZ(k)
5886 gscloc(k,i-1)=gscloc(k,i-1)+de_dxx*dxx_ci1(k)
5887 & +de_dyy*dyy_ci1(k)+de_dzz*dzz_ci1(k)+de_dt*dt_dCi1(k)
5888 gscloc(k,i)=gscloc(k,i)+de_dxx*dxx_Ci(k)
5889 & +de_dyy*dyy_Ci(k)+de_dzz*dzz_Ci(k)+de_dt*dt_dCi(k)
5890 gsclocx(k,i)= de_dxx*dxx_XYZ(k)
5891 & +de_dyy*dyy_XYZ(k)+de_dzz*dzz_XYZ(k)
5893 c write(iout,*) "ENERGY GRAD = ", (gscloc(k,i-1),k=1,3),
5894 c & (gscloc(k,i),k=1,3),(gsclocx(k,i),k=1,3)
5896 C to check gradient call subroutine check_grad
5903 c------------------------------------------------------------------------------
5904 subroutine gcont(rij,r0ij,eps0ij,delta,fcont,fprimcont)
5906 C This procedure calculates two-body contact function g(rij) and its derivative:
5909 C g(rij) = esp0ij*(-0.9375*x+0.625*x**3-0.1875*x**5) ! -1 =< x =< 1
5912 C where x=(rij-r0ij)/delta
5914 C rij - interbody distance, r0ij - contact distance, eps0ij - contact energy
5917 double precision rij,r0ij,eps0ij,fcont,fprimcont
5918 double precision x,x2,x4,delta
5922 if (x.lt.-1.0D0) then
5925 else if (x.le.1.0D0) then
5928 fcont=eps0ij*(x*(-0.9375D0+0.6250D0*x2-0.1875D0*x4)+0.5D0)
5929 fprimcont=eps0ij * (-0.9375D0+1.8750D0*x2-0.9375D0*x4)/delta
5936 c------------------------------------------------------------------------------
5937 subroutine splinthet(theti,delta,ss,ssder)
5938 implicit real*8 (a-h,o-z)
5939 include 'DIMENSIONS'
5940 include 'DIMENSIONS.ZSCOPT'
5941 include 'COMMON.VAR'
5942 include 'COMMON.GEO'
5945 if (theti.gt.pipol) then
5946 call gcont(theti,thetup,1.0d0,delta,ss,ssder)
5948 call gcont(-theti,-thetlow,1.0d0,delta,ss,ssder)
5953 c------------------------------------------------------------------------------
5954 subroutine spline1(x,x0,delta,f0,f1,fprim0,f,fprim)
5956 double precision x,x0,delta,f0,f1,fprim0,f,fprim
5957 double precision ksi,ksi2,ksi3,a1,a2,a3
5958 a1=fprim0*delta/(f1-f0)
5964 f=f0+(f1-f0)*ksi*(a1+ksi*(a2+a3*ksi))
5965 fprim=(f1-f0)/delta*(a1+ksi*(2*a2+3*ksi*a3))
5968 c------------------------------------------------------------------------------
5969 subroutine spline2(x,x0,delta,f0x,f1x,fprim0x,fx)
5971 double precision x,x0,delta,f0x,f1x,fprim0x,fx
5972 double precision ksi,ksi2,ksi3,a1,a2,a3
5977 a2=3*(f1x-f0x)-2*fprim0x*delta
5978 a3=fprim0x*delta-2*(f1x-f0x)
5979 fx=f0x+a1*ksi+a2*ksi2+a3*ksi3
5982 C-----------------------------------------------------------------------------
5984 C-----------------------------------------------------------------------------
5985 subroutine etor(etors,edihcnstr,fact)
5986 implicit real*8 (a-h,o-z)
5987 include 'DIMENSIONS'
5988 include 'DIMENSIONS.ZSCOPT'
5989 include 'COMMON.VAR'
5990 include 'COMMON.GEO'
5991 include 'COMMON.LOCAL'
5992 include 'COMMON.TORSION'
5993 include 'COMMON.INTERACT'
5994 include 'COMMON.DERIV'
5995 include 'COMMON.CHAIN'
5996 include 'COMMON.NAMES'
5997 include 'COMMON.IOUNITS'
5998 include 'COMMON.FFIELD'
5999 include 'COMMON.TORCNSTR'
6001 C Set lprn=.true. for debugging
6005 do i=iphi_start,iphi_end
6006 itori=itortyp(itype(i-2))
6007 itori1=itortyp(itype(i-1))
6010 C Proline-Proline pair is a special case...
6011 if (itori.eq.3 .and. itori1.eq.3) then
6012 if (phii.gt.-dwapi3) then
6014 fac=1.0D0/(1.0D0-cosphi)
6015 etorsi=v1(1,3,3)*fac
6016 etorsi=etorsi+etorsi
6017 etors=etors+etorsi-v1(1,3,3)
6018 gloci=gloci-3*fac*etorsi*dsin(3*phii)
6021 v1ij=v1(j+1,itori,itori1)
6022 v2ij=v2(j+1,itori,itori1)
6025 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
6026 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
6030 v1ij=v1(j,itori,itori1)
6031 v2ij=v2(j,itori,itori1)
6034 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
6035 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
6039 & write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)')
6040 & restyp(itype(i-2)),i-2,restyp(itype(i-1)),i-1,itori,itori1,
6041 & (v1(j,itori,itori1),j=1,6),(v2(j,itori,itori1),j=1,6)
6042 gloc(i-3,icg)=gloc(i-3,icg)+wtor*fact*gloci
6043 c write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
6045 ! 6/20/98 - dihedral angle constraints
6048 itori=idih_constr(i)
6051 if (difi.gt.drange(i)) then
6053 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
6054 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
6055 else if (difi.lt.-drange(i)) then
6057 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
6058 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
6060 ! write (iout,'(2i5,2f8.3,2e14.5)') i,itori,rad2deg*phii,
6061 ! & rad2deg*difi,0.25d0*ftors*difi**4,gloc(itori-3,icg)
6063 ! write (iout,*) 'edihcnstr',edihcnstr
6066 c------------------------------------------------------------------------------
6068 subroutine etor(etors,edihcnstr,fact)
6069 implicit real*8 (a-h,o-z)
6070 include 'DIMENSIONS'
6071 include 'DIMENSIONS.ZSCOPT'
6072 include 'COMMON.VAR'
6073 include 'COMMON.GEO'
6074 include 'COMMON.LOCAL'
6075 include 'COMMON.TORSION'
6076 include 'COMMON.INTERACT'
6077 include 'COMMON.DERIV'
6078 include 'COMMON.CHAIN'
6079 include 'COMMON.NAMES'
6080 include 'COMMON.IOUNITS'
6081 include 'COMMON.FFIELD'
6082 include 'COMMON.TORCNSTR'
6084 C Set lprn=.true. for debugging
6088 do i=iphi_start,iphi_end
6089 if (itel(i-2).eq.0 .or. itel(i-1).eq.0) goto 1215
6090 itori=itortyp(itype(i-2))
6091 itori1=itortyp(itype(i-1))
6094 C Regular cosine and sine terms
6095 do j=1,nterm(itori,itori1)
6096 v1ij=v1(j,itori,itori1)
6097 v2ij=v2(j,itori,itori1)
6100 etors=etors+v1ij*cosphi+v2ij*sinphi
6101 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
6105 C E = SUM ----------------------------------- - v1
6106 C [v2 cos(phi/2)+v3 sin(phi/2)]^2 + 1
6108 cosphi=dcos(0.5d0*phii)
6109 sinphi=dsin(0.5d0*phii)
6110 do j=1,nlor(itori,itori1)
6111 vl1ij=vlor1(j,itori,itori1)
6112 vl2ij=vlor2(j,itori,itori1)
6113 vl3ij=vlor3(j,itori,itori1)
6114 pom=vl2ij*cosphi+vl3ij*sinphi
6115 pom1=1.0d0/(pom*pom+1.0d0)
6116 etors=etors+vl1ij*pom1
6118 gloci=gloci+vl1ij*(vl3ij*cosphi-vl2ij*sinphi)*pom
6120 C Subtract the constant term
6121 etors=etors-v0(itori,itori1)
6123 & write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)')
6124 & restyp(itype(i-2)),i-2,restyp(itype(i-1)),i-1,itori,itori1,
6125 & (v1(j,itori,itori1),j=1,6),(v2(j,itori,itori1),j=1,6)
6126 gloc(i-3,icg)=gloc(i-3,icg)+wtor*fact*gloci
6127 c write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
6130 ! 6/20/98 - dihedral angle constraints
6133 itori=idih_constr(i)
6135 difi=pinorm(phii-phi0(i))
6137 if (difi.gt.drange(i)) then
6139 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
6140 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
6141 edihi=0.25d0*ftors*difi**4
6142 else if (difi.lt.-drange(i)) then
6144 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
6145 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
6146 edihi=0.25d0*ftors*difi**4
6150 c write (iout,'(2i5,4f10.5,e15.5)') i,itori,phii,phi0(i),difi,
6152 ! write (iout,'(2i5,2f8.3,2e14.5)') i,itori,rad2deg*phii,
6153 ! & rad2deg*difi,0.25d0*ftors*difi**4,gloc(itori-3,icg)
6155 ! write (iout,*) 'edihcnstr',edihcnstr
6158 c----------------------------------------------------------------------------
6159 subroutine etor_d(etors_d,fact2)
6160 C 6/23/01 Compute double torsional energy
6161 implicit real*8 (a-h,o-z)
6162 include 'DIMENSIONS'
6163 include 'DIMENSIONS.ZSCOPT'
6164 include 'COMMON.VAR'
6165 include 'COMMON.GEO'
6166 include 'COMMON.LOCAL'
6167 include 'COMMON.TORSION'
6168 include 'COMMON.INTERACT'
6169 include 'COMMON.DERIV'
6170 include 'COMMON.CHAIN'
6171 include 'COMMON.NAMES'
6172 include 'COMMON.IOUNITS'
6173 include 'COMMON.FFIELD'
6174 include 'COMMON.TORCNSTR'
6176 C Set lprn=.true. for debugging
6180 do i=iphi_start,iphi_end-1
6181 if (itel(i-2).eq.0 .or. itel(i-1).eq.0 .or. itel(i).eq.0)
6183 itori=itortyp(itype(i-2))
6184 itori1=itortyp(itype(i-1))
6185 itori2=itortyp(itype(i))
6190 C Regular cosine and sine terms
6191 do j=1,ntermd_1(itori,itori1,itori2)
6192 v1cij=v1c(1,j,itori,itori1,itori2)
6193 v1sij=v1s(1,j,itori,itori1,itori2)
6194 v2cij=v1c(2,j,itori,itori1,itori2)
6195 v2sij=v1s(2,j,itori,itori1,itori2)
6196 cosphi1=dcos(j*phii)
6197 sinphi1=dsin(j*phii)
6198 cosphi2=dcos(j*phii1)
6199 sinphi2=dsin(j*phii1)
6200 etors_d=etors_d+v1cij*cosphi1+v1sij*sinphi1+
6201 & v2cij*cosphi2+v2sij*sinphi2
6202 gloci1=gloci1+j*(v1sij*cosphi1-v1cij*sinphi1)
6203 gloci2=gloci2+j*(v2sij*cosphi2-v2cij*sinphi2)
6205 do k=2,ntermd_2(itori,itori1,itori2)
6207 v1cdij = v2c(k,l,itori,itori1,itori2)
6208 v2cdij = v2c(l,k,itori,itori1,itori2)
6209 v1sdij = v2s(k,l,itori,itori1,itori2)
6210 v2sdij = v2s(l,k,itori,itori1,itori2)
6211 cosphi1p2=dcos(l*phii+(k-l)*phii1)
6212 cosphi1m2=dcos(l*phii-(k-l)*phii1)
6213 sinphi1p2=dsin(l*phii+(k-l)*phii1)
6214 sinphi1m2=dsin(l*phii-(k-l)*phii1)
6215 etors_d=etors_d+v1cdij*cosphi1p2+v2cdij*cosphi1m2+
6216 & v1sdij*sinphi1p2+v2sdij*sinphi1m2
6217 gloci1=gloci1+l*(v1sdij*cosphi1p2+v2sdij*cosphi1m2
6218 & -v1cdij*sinphi1p2-v2cdij*sinphi1m2)
6219 gloci2=gloci2+(k-l)*(v1sdij*cosphi1p2-v2sdij*cosphi1m2
6220 & -v1cdij*sinphi1p2+v2cdij*sinphi1m2)
6223 gloc(i-3,icg)=gloc(i-3,icg)+wtor_d*fact2*gloci1
6224 gloc(i-2,icg)=gloc(i-2,icg)+wtor_d*fact2*gloci2
6230 c------------------------------------------------------------------------------
6231 subroutine eback_sc_corr(esccor)
6232 c 7/21/2007 Correlations between the backbone-local and side-chain-local
6233 c conformational states; temporarily implemented as differences
6234 c between UNRES torsional potentials (dependent on three types of
6235 c residues) and the torsional potentials dependent on all 20 types
6236 c of residues computed from AM1 energy surfaces of terminally-blocked
6237 c amino-acid residues.
6238 implicit real*8 (a-h,o-z)
6239 include 'DIMENSIONS'
6240 include 'DIMENSIONS.ZSCOPT'
6241 include 'COMMON.VAR'
6242 include 'COMMON.GEO'
6243 include 'COMMON.LOCAL'
6244 include 'COMMON.TORSION'
6245 include 'COMMON.SCCOR'
6246 include 'COMMON.INTERACT'
6247 include 'COMMON.DERIV'
6248 include 'COMMON.CHAIN'
6249 include 'COMMON.NAMES'
6250 include 'COMMON.IOUNITS'
6251 include 'COMMON.FFIELD'
6252 include 'COMMON.CONTROL'
6254 C Set lprn=.true. for debugging
6257 c write (iout,*) "EBACK_SC_COR",itau_start,itau_end,nterm_sccor
6259 do i=itau_start,itau_end
6261 isccori=isccortyp(itype(i-2))
6262 isccori1=isccortyp(itype(i-1))
6264 cccc Added 9 May 2012
6265 cc Tauangle is torsional engle depending on the value of first digit
6266 c(see comment below)
6267 cc Omicron is flat angle depending on the value of first digit
6268 c(see comment below)
6271 do intertyp=1,3 !intertyp
6272 cc Added 09 May 2012 (Adasko)
6273 cc Intertyp means interaction type of backbone mainchain correlation:
6274 c 1 = SC...Ca...Ca...Ca
6275 c 2 = Ca...Ca...Ca...SC
6276 c 3 = SC...Ca...Ca...SCi
6278 if (((intertyp.eq.3).and.((itype(i-2).eq.10).or.
6279 & (itype(i-1).eq.10).or.(itype(i-2).eq.21).or.
6280 & (itype(i-1).eq.21)))
6281 & .or. ((intertyp.eq.1).and.((itype(i-2).eq.10)
6282 & .or.(itype(i-2).eq.21)))
6283 & .or.((intertyp.eq.2).and.((itype(i-1).eq.10).or.
6284 & (itype(i-1).eq.21)))) cycle
6285 if ((intertyp.eq.2).and.(i.eq.4).and.(itype(1).eq.21)) cycle
6286 if ((intertyp.eq.1).and.(i.eq.nres).and.(itype(nres).eq.21))
6288 do j=1,nterm_sccor(isccori,isccori1)
6289 v1ij=v1sccor(j,intertyp,isccori,isccori1)
6290 v2ij=v2sccor(j,intertyp,isccori,isccori1)
6291 cosphi=dcos(j*tauangle(intertyp,i))
6292 sinphi=dsin(j*tauangle(intertyp,i))
6293 esccor=esccor+v1ij*cosphi+v2ij*sinphi
6294 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
6296 gloc_sc(intertyp,i-3,icg)=gloc_sc(intertyp,i-3,icg)+wsccor*gloci
6297 c write (iout,*) "WTF",intertyp,i,itype(i),v1ij*cosphi+v2ij*sinphi
6298 c &gloc_sc(intertyp,i-3,icg)
6300 & write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)')
6301 & restyp(itype(i-2)),i-2,restyp(itype(i-1)),i-1,itori,itori1,
6302 & (v1sccor(j,intertyp,itori,itori1),j=1,6)
6303 & ,(v2sccor(j,intertyp,itori,itori1),j=1,6)
6304 gsccor_loc(i-3)=gsccor_loc(i-3)+gloci
6308 c write (iout,*) "W@T@F", gloc_sc(1,i,icg),gloc(i,icg)
6312 c------------------------------------------------------------------------------
6313 subroutine multibody(ecorr)
6314 C This subroutine calculates multi-body contributions to energy following
6315 C the idea of Skolnick et al. If side chains I and J make a contact and
6316 C at the same time side chains I+1 and J+1 make a contact, an extra
6317 C contribution equal to sqrt(eps(i,j)*eps(i+1,j+1)) is added.
6318 implicit real*8 (a-h,o-z)
6319 include 'DIMENSIONS'
6320 include 'COMMON.IOUNITS'
6321 include 'COMMON.DERIV'
6322 include 'COMMON.INTERACT'
6323 include 'COMMON.CONTACTS'
6324 double precision gx(3),gx1(3)
6327 C Set lprn=.true. for debugging
6331 write (iout,'(a)') 'Contact function values:'
6333 write (iout,'(i2,20(1x,i2,f10.5))')
6334 & i,(jcont(j,i),facont(j,i),j=1,num_cont(i))
6349 num_conti=num_cont(i)
6350 num_conti1=num_cont(i1)
6355 if (j1.eq.j+ishift .or. j1.eq.j-ishift) then
6356 cd write(iout,*)'i=',i,' j=',j,' i1=',i1,' j1=',j1,
6357 cd & ' ishift=',ishift
6358 C Contacts I--J and I+ISHIFT--J+-ISHIFT1 occur simultaneously.
6359 C The system gains extra energy.
6360 ecorr=ecorr+esccorr(i,j,i1,j1,jj,kk)
6361 endif ! j1==j+-ishift
6370 c------------------------------------------------------------------------------
6371 double precision function esccorr(i,j,k,l,jj,kk)
6372 implicit real*8 (a-h,o-z)
6373 include 'DIMENSIONS'
6374 include 'COMMON.IOUNITS'
6375 include 'COMMON.DERIV'
6376 include 'COMMON.INTERACT'
6377 include 'COMMON.CONTACTS'
6378 double precision gx(3),gx1(3)
6383 cd write (iout,'(4i5,3f10.5)') i,j,k,l,eij,ekl,-eij*ekl
6384 C Calculate the multi-body contribution to energy.
6385 C Calculate multi-body contributions to the gradient.
6386 cd write (iout,'(2(2i3,3f10.5))')i,j,(gacont(m,jj,i),m=1,3),
6387 cd & k,l,(gacont(m,kk,k),m=1,3)
6389 gx(m) =ekl*gacont(m,jj,i)
6390 gx1(m)=eij*gacont(m,kk,k)
6391 gradxorr(m,i)=gradxorr(m,i)-gx(m)
6392 gradxorr(m,j)=gradxorr(m,j)+gx(m)
6393 gradxorr(m,k)=gradxorr(m,k)-gx1(m)
6394 gradxorr(m,l)=gradxorr(m,l)+gx1(m)
6398 gradcorr(ll,m)=gradcorr(ll,m)+gx(ll)
6403 gradcorr(ll,m)=gradcorr(ll,m)+gx1(ll)
6409 c------------------------------------------------------------------------------
6411 subroutine pack_buffer(dimen1,dimen2,atom,indx,buffer)
6412 implicit real*8 (a-h,o-z)
6413 include 'DIMENSIONS'
6414 integer dimen1,dimen2,atom,indx
6415 double precision buffer(dimen1,dimen2)
6416 double precision zapas
6417 common /contacts_hb/ zapas(3,20,maxres,7),
6418 & facont_hb(20,maxres),ees0p(20,maxres),ees0m(20,maxres),
6419 & num_cont_hb(maxres),jcont_hb(20,maxres)
6420 num_kont=num_cont_hb(atom)
6424 buffer(i,indx+(k-1)*3+j)=zapas(j,i,atom,k)
6427 buffer(i,indx+22)=facont_hb(i,atom)
6428 buffer(i,indx+23)=ees0p(i,atom)
6429 buffer(i,indx+24)=ees0m(i,atom)
6430 buffer(i,indx+25)=dfloat(jcont_hb(i,atom))
6432 buffer(1,indx+26)=dfloat(num_kont)
6435 c------------------------------------------------------------------------------
6436 subroutine unpack_buffer(dimen1,dimen2,atom,indx,buffer)
6437 implicit real*8 (a-h,o-z)
6438 include 'DIMENSIONS'
6439 integer dimen1,dimen2,atom,indx
6440 double precision buffer(dimen1,dimen2)
6441 double precision zapas
6442 common /contacts_hb/ zapas(3,20,maxres,7),
6443 & facont_hb(20,maxres),ees0p(20,maxres),ees0m(20,maxres),
6444 & num_cont_hb(maxres),jcont_hb(20,maxres)
6445 num_kont=buffer(1,indx+26)
6446 num_kont_old=num_cont_hb(atom)
6447 num_cont_hb(atom)=num_kont+num_kont_old
6452 zapas(j,ii,atom,k)=buffer(i,indx+(k-1)*3+j)
6455 facont_hb(ii,atom)=buffer(i,indx+22)
6456 ees0p(ii,atom)=buffer(i,indx+23)
6457 ees0m(ii,atom)=buffer(i,indx+24)
6458 jcont_hb(ii,atom)=buffer(i,indx+25)
6462 c------------------------------------------------------------------------------
6464 subroutine multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
6465 C This subroutine calculates multi-body contributions to hydrogen-bonding
6466 implicit real*8 (a-h,o-z)
6467 include 'DIMENSIONS'
6468 include 'DIMENSIONS.ZSCOPT'
6469 include 'COMMON.IOUNITS'
6471 include 'COMMON.INFO'
6473 include 'COMMON.FFIELD'
6474 include 'COMMON.DERIV'
6475 include 'COMMON.INTERACT'
6476 include 'COMMON.CONTACTS'
6478 parameter (max_cont=maxconts)
6479 parameter (max_dim=2*(8*3+2))
6480 parameter (msglen1=max_cont*max_dim*4)
6481 parameter (msglen2=2*msglen1)
6482 integer source,CorrelType,CorrelID,Error
6483 double precision buffer(max_cont,max_dim)
6485 double precision gx(3),gx1(3)
6488 C Set lprn=.true. for debugging
6493 if (fgProcs.le.1) goto 30
6495 write (iout,'(a)') 'Contact function values:'
6497 write (iout,'(2i3,50(1x,i2,f5.2))')
6498 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
6499 & j=1,num_cont_hb(i))
6502 C Caution! Following code assumes that electrostatic interactions concerning
6503 C a given atom are split among at most two processors!
6513 cd write (iout,*) 'MyRank',MyRank,' mm',mm
6516 cd write (iout,*) 'Sending: MyRank',MyRank,' mm',mm,' ldone',ldone
6517 if (MyRank.gt.0) then
6518 C Send correlation contributions to the preceding processor
6520 nn=num_cont_hb(iatel_s)
6521 call pack_buffer(max_cont,max_dim,iatel_s,0,buffer)
6522 cd write (iout,*) 'The BUFFER array:'
6524 cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,26)
6526 if (ielstart(iatel_s).gt.iatel_s+ispp) then
6528 call pack_buffer(max_cont,max_dim,iatel_s+1,26,buffer)
6529 C Clear the contacts of the atom passed to the neighboring processor
6530 nn=num_cont_hb(iatel_s+1)
6532 cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j+26),j=1,26)
6534 num_cont_hb(iatel_s)=0
6536 cd write (iout,*) 'Processor ',MyID,MyRank,
6537 cd & ' is sending correlation contribution to processor',MyID-1,
6538 cd & ' msglen=',msglen
6539 cd write (*,*) 'Processor ',MyID,MyRank,
6540 cd & ' is sending correlation contribution to processor',MyID-1,
6541 cd & ' msglen=',msglen,' CorrelType=',CorrelType
6542 call mp_bsend(buffer,msglen,MyID-1,CorrelType,CorrelID)
6543 cd write (iout,*) 'Processor ',MyID,
6544 cd & ' has sent correlation contribution to processor',MyID-1,
6545 cd & ' msglen=',msglen,' CorrelID=',CorrelID
6546 cd write (*,*) 'Processor ',MyID,
6547 cd & ' has sent correlation contribution to processor',MyID-1,
6548 cd & ' msglen=',msglen,' CorrelID=',CorrelID
6550 endif ! (MyRank.gt.0)
6554 cd write (iout,*) 'Receiving: MyRank',MyRank,' mm',mm,' ldone',ldone
6555 if (MyRank.lt.fgProcs-1) then
6556 C Receive correlation contributions from the next processor
6558 if (ielend(iatel_e).lt.nct-1) msglen=msglen2
6559 cd write (iout,*) 'Processor',MyID,
6560 cd & ' is receiving correlation contribution from processor',MyID+1,
6561 cd & ' msglen=',msglen,' CorrelType=',CorrelType
6562 cd write (*,*) 'Processor',MyID,
6563 cd & ' is receiving correlation contribution from processor',MyID+1,
6564 cd & ' msglen=',msglen,' CorrelType=',CorrelType
6566 do while (nbytes.le.0)
6567 call mp_probe(MyID+1,CorrelType,nbytes)
6569 cd print *,'Processor',MyID,' msglen',msglen,' nbytes',nbytes
6570 call mp_brecv(buffer,msglen,MyID+1,CorrelType,nbytes)
6571 cd write (iout,*) 'Processor',MyID,
6572 cd & ' has received correlation contribution from processor',MyID+1,
6573 cd & ' msglen=',msglen,' nbytes=',nbytes
6574 cd write (iout,*) 'The received BUFFER array:'
6576 cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,52)
6578 if (msglen.eq.msglen1) then
6579 call unpack_buffer(max_cont,max_dim,iatel_e+1,0,buffer)
6580 else if (msglen.eq.msglen2) then
6581 call unpack_buffer(max_cont,max_dim,iatel_e,0,buffer)
6582 call unpack_buffer(max_cont,max_dim,iatel_e+1,26,buffer)
6585 & 'ERROR!!!! message length changed while processing correlations.'
6587 & 'ERROR!!!! message length changed while processing correlations.'
6588 call mp_stopall(Error)
6589 endif ! msglen.eq.msglen1
6590 endif ! MyRank.lt.fgProcs-1
6597 write (iout,'(a)') 'Contact function values:'
6599 write (iout,'(2i3,50(1x,i2,f5.2))')
6600 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
6601 & j=1,num_cont_hb(i))
6605 C Remove the loop below after debugging !!!
6612 C Calculate the local-electrostatic correlation terms
6613 do i=iatel_s,iatel_e+1
6615 num_conti=num_cont_hb(i)
6616 num_conti1=num_cont_hb(i+1)
6621 c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
6622 c & ' jj=',jj,' kk=',kk
6623 if (j1.eq.j+1 .or. j1.eq.j-1) then
6624 C Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
6625 C The system gains extra energy.
6626 ecorr=ecorr+ehbcorr(i,j,i+1,j1,jj,kk,0.72D0,0.32D0)
6628 else if (j1.eq.j) then
6629 C Contacts I-J and I-(J+1) occur simultaneously.
6630 C The system loses extra energy.
6631 c ecorr=ecorr+ehbcorr(i,j,i+1,j,jj,kk,0.60D0,-0.40D0)
6636 c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
6637 c & ' jj=',jj,' kk=',kk
6639 C Contacts I-J and (I+1)-J occur simultaneously.
6640 C The system loses extra energy.
6641 c ecorr=ecorr+ehbcorr(i,j,i,j+1,jj,kk,0.60D0,-0.40D0)
6648 c------------------------------------------------------------------------------
6649 subroutine multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,
6651 C This subroutine calculates multi-body contributions to hydrogen-bonding
6652 implicit real*8 (a-h,o-z)
6653 include 'DIMENSIONS'
6654 include 'DIMENSIONS.ZSCOPT'
6655 include 'COMMON.IOUNITS'
6657 include 'COMMON.INFO'
6659 include 'COMMON.FFIELD'
6660 include 'COMMON.DERIV'
6661 include 'COMMON.INTERACT'
6662 include 'COMMON.CONTACTS'
6664 parameter (max_cont=maxconts)
6665 parameter (max_dim=2*(8*3+2))
6666 parameter (msglen1=max_cont*max_dim*4)
6667 parameter (msglen2=2*msglen1)
6668 integer source,CorrelType,CorrelID,Error
6669 double precision buffer(max_cont,max_dim)
6671 double precision gx(3),gx1(3)
6674 C Set lprn=.true. for debugging
6680 if (fgProcs.le.1) goto 30
6682 write (iout,'(a)') 'Contact function values:'
6684 write (iout,'(2i3,50(1x,i2,f5.2))')
6685 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
6686 & j=1,num_cont_hb(i))
6689 C Caution! Following code assumes that electrostatic interactions concerning
6690 C a given atom are split among at most two processors!
6700 cd write (iout,*) 'MyRank',MyRank,' mm',mm
6703 cd write (iout,*) 'Sending: MyRank',MyRank,' mm',mm,' ldone',ldone
6704 if (MyRank.gt.0) then
6705 C Send correlation contributions to the preceding processor
6707 nn=num_cont_hb(iatel_s)
6708 call pack_buffer(max_cont,max_dim,iatel_s,0,buffer)
6709 cd write (iout,*) 'The BUFFER array:'
6711 cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,26)
6713 if (ielstart(iatel_s).gt.iatel_s+ispp) then
6715 call pack_buffer(max_cont,max_dim,iatel_s+1,26,buffer)
6716 C Clear the contacts of the atom passed to the neighboring processor
6717 nn=num_cont_hb(iatel_s+1)
6719 cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j+26),j=1,26)
6721 num_cont_hb(iatel_s)=0
6723 cd write (iout,*) 'Processor ',MyID,MyRank,
6724 cd & ' is sending correlation contribution to processor',MyID-1,
6725 cd & ' msglen=',msglen
6726 cd write (*,*) 'Processor ',MyID,MyRank,
6727 cd & ' is sending correlation contribution to processor',MyID-1,
6728 cd & ' msglen=',msglen,' CorrelType=',CorrelType
6729 call mp_bsend(buffer,msglen,MyID-1,CorrelType,CorrelID)
6730 cd write (iout,*) 'Processor ',MyID,
6731 cd & ' has sent correlation contribution to processor',MyID-1,
6732 cd & ' msglen=',msglen,' CorrelID=',CorrelID
6733 cd write (*,*) 'Processor ',MyID,
6734 cd & ' has sent correlation contribution to processor',MyID-1,
6735 cd & ' msglen=',msglen,' CorrelID=',CorrelID
6737 endif ! (MyRank.gt.0)
6741 cd write (iout,*) 'Receiving: MyRank',MyRank,' mm',mm,' ldone',ldone
6742 if (MyRank.lt.fgProcs-1) then
6743 C Receive correlation contributions from the next processor
6745 if (ielend(iatel_e).lt.nct-1) msglen=msglen2
6746 cd write (iout,*) 'Processor',MyID,
6747 cd & ' is receiving correlation contribution from processor',MyID+1,
6748 cd & ' msglen=',msglen,' CorrelType=',CorrelType
6749 cd write (*,*) 'Processor',MyID,
6750 cd & ' is receiving correlation contribution from processor',MyID+1,
6751 cd & ' msglen=',msglen,' CorrelType=',CorrelType
6753 do while (nbytes.le.0)
6754 call mp_probe(MyID+1,CorrelType,nbytes)
6756 cd print *,'Processor',MyID,' msglen',msglen,' nbytes',nbytes
6757 call mp_brecv(buffer,msglen,MyID+1,CorrelType,nbytes)
6758 cd write (iout,*) 'Processor',MyID,
6759 cd & ' has received correlation contribution from processor',MyID+1,
6760 cd & ' msglen=',msglen,' nbytes=',nbytes
6761 cd write (iout,*) 'The received BUFFER array:'
6763 cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,52)
6765 if (msglen.eq.msglen1) then
6766 call unpack_buffer(max_cont,max_dim,iatel_e+1,0,buffer)
6767 else if (msglen.eq.msglen2) then
6768 call unpack_buffer(max_cont,max_dim,iatel_e,0,buffer)
6769 call unpack_buffer(max_cont,max_dim,iatel_e+1,26,buffer)
6772 & 'ERROR!!!! message length changed while processing correlations.'
6774 & 'ERROR!!!! message length changed while processing correlations.'
6775 call mp_stopall(Error)
6776 endif ! msglen.eq.msglen1
6777 endif ! MyRank.lt.fgProcs-1
6784 write (iout,'(a)') 'Contact function values:'
6786 write (iout,'(2i3,50(1x,i2,f5.2))')
6787 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
6788 & j=1,num_cont_hb(i))
6794 C Remove the loop below after debugging !!!
6801 C Calculate the dipole-dipole interaction energies
6802 if (wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) then
6803 do i=iatel_s,iatel_e+1
6804 num_conti=num_cont_hb(i)
6811 C Calculate the local-electrostatic correlation terms
6812 do i=iatel_s,iatel_e+1
6814 num_conti=num_cont_hb(i)
6815 num_conti1=num_cont_hb(i+1)
6820 c write (*,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
6821 c & ' jj=',jj,' kk=',kk
6822 if (j1.eq.j+1 .or. j1.eq.j-1) then
6823 C Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
6824 C The system gains extra energy.
6826 sqd1=dsqrt(d_cont(jj,i))
6827 sqd2=dsqrt(d_cont(kk,i1))
6828 sred_geom = sqd1*sqd2
6829 IF (sred_geom.lt.cutoff_corr) THEN
6830 call gcont(sred_geom,r0_corr,1.0D0,delt_corr,
6832 c write (*,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
6833 c & ' jj=',jj,' kk=',kk
6834 fac_prim1=0.5d0*sqd2/sqd1*fprimcont
6835 fac_prim2=0.5d0*sqd1/sqd2*fprimcont
6837 g_contij(l,1)=fac_prim1*grij_hb_cont(l,jj,i)
6838 g_contij(l,2)=fac_prim2*grij_hb_cont(l,kk,i1)
6841 cd write (iout,*) 'sred_geom=',sred_geom,
6842 cd & ' ekont=',ekont,' fprim=',fprimcont
6843 call calc_eello(i,j,i+1,j1,jj,kk)
6844 if (wcorr4.gt.0.0d0)
6845 & ecorr=ecorr+eello4(i,j,i+1,j1,jj,kk)
6846 if (wcorr5.gt.0.0d0)
6847 & ecorr5=ecorr5+eello5(i,j,i+1,j1,jj,kk)
6848 c print *,"wcorr5",ecorr5
6849 cd write(2,*)'wcorr6',wcorr6,' wturn6',wturn6
6850 cd write(2,*)'ijkl',i,j,i+1,j1
6851 if (wcorr6.gt.0.0d0 .and. (j.ne.i+4 .or. j1.ne.i+3
6852 & .or. wturn6.eq.0.0d0))then
6853 cd write (iout,*) '******ecorr6: i,j,i+1,j1',i,j,i+1,j1
6854 ecorr6=ecorr6+eello6(i,j,i+1,j1,jj,kk)
6855 cd write (iout,*) 'ecorr',ecorr,' ecorr5=',ecorr5,
6856 cd & 'ecorr6=',ecorr6
6857 cd write (iout,'(4e15.5)') sred_geom,
6858 cd & dabs(eello4(i,j,i+1,j1,jj,kk)),
6859 cd & dabs(eello5(i,j,i+1,j1,jj,kk)),
6860 cd & dabs(eello6(i,j,i+1,j1,jj,kk))
6861 else if (wturn6.gt.0.0d0
6862 & .and. (j.eq.i+4 .and. j1.eq.i+3)) then
6863 cd write (iout,*) '******eturn6: i,j,i+1,j1',i,j,i+1,j1
6864 eturn6=eturn6+eello_turn6(i,jj,kk)
6865 cd write (2,*) 'multibody_eello:eturn6',eturn6
6869 else if (j1.eq.j) then
6870 C Contacts I-J and I-(J+1) occur simultaneously.
6871 C The system loses extra energy.
6872 c ecorr=ecorr+ehbcorr(i,j,i+1,j,jj,kk,0.60D0,-0.40D0)
6877 c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
6878 c & ' jj=',jj,' kk=',kk
6880 C Contacts I-J and (I+1)-J occur simultaneously.
6881 C The system loses extra energy.
6882 c ecorr=ecorr+ehbcorr(i,j,i,j+1,jj,kk,0.60D0,-0.40D0)
6889 c------------------------------------------------------------------------------
6890 double precision function ehbcorr(i,j,k,l,jj,kk,coeffp,coeffm)
6891 implicit real*8 (a-h,o-z)
6892 include 'DIMENSIONS'
6893 include 'COMMON.IOUNITS'
6894 include 'COMMON.DERIV'
6895 include 'COMMON.INTERACT'
6896 include 'COMMON.CONTACTS'
6897 double precision gx(3),gx1(3)
6907 ees=-(coeffp*ees0pij*ees0pkl+coeffm*ees0mij*ees0mkl)
6908 cd ees=-(coeffp*ees0pkl+coeffm*ees0mkl)
6909 C Following 4 lines for diagnostics.
6914 c write (iout,*)'Contacts have occurred for peptide groups',i,j,
6916 c write (iout,*)'Contacts have occurred for peptide groups',
6917 c & i,j,' fcont:',eij,' eij',' eesij',ees0pij,ees0mij,' and ',k,l
6918 c & ,' fcont ',ekl,' eeskl',ees0pkl,ees0mkl,' ees=',ees
6919 C Calculate the multi-body contribution to energy.
6920 ecorr=ecorr+ekont*ees
6922 C Calculate multi-body contributions to the gradient.
6924 ghalf=0.5D0*ees*ekl*gacont_hbr(ll,jj,i)
6925 gradcorr(ll,i)=gradcorr(ll,i)+ghalf
6926 & -ekont*(coeffp*ees0pkl*gacontp_hb1(ll,jj,i)+
6927 & coeffm*ees0mkl*gacontm_hb1(ll,jj,i))
6928 gradcorr(ll,j)=gradcorr(ll,j)+ghalf
6929 & -ekont*(coeffp*ees0pkl*gacontp_hb2(ll,jj,i)+
6930 & coeffm*ees0mkl*gacontm_hb2(ll,jj,i))
6931 ghalf=0.5D0*ees*eij*gacont_hbr(ll,kk,k)
6932 gradcorr(ll,k)=gradcorr(ll,k)+ghalf
6933 & -ekont*(coeffp*ees0pij*gacontp_hb1(ll,kk,k)+
6934 & coeffm*ees0mij*gacontm_hb1(ll,kk,k))
6935 gradcorr(ll,l)=gradcorr(ll,l)+ghalf
6936 & -ekont*(coeffp*ees0pij*gacontp_hb2(ll,kk,k)+
6937 & coeffm*ees0mij*gacontm_hb2(ll,kk,k))
6941 gradcorr(ll,m)=gradcorr(ll,m)+
6942 & ees*ekl*gacont_hbr(ll,jj,i)-
6943 & ekont*(coeffp*ees0pkl*gacontp_hb3(ll,jj,i)+
6944 & coeffm*ees0mkl*gacontm_hb3(ll,jj,i))
6949 gradcorr(ll,m)=gradcorr(ll,m)+
6950 & ees*eij*gacont_hbr(ll,kk,k)-
6951 & ekont*(coeffp*ees0pij*gacontp_hb3(ll,kk,k)+
6952 & coeffm*ees0mij*gacontm_hb3(ll,kk,k))
6959 C---------------------------------------------------------------------------
6960 subroutine dipole(i,j,jj)
6961 implicit real*8 (a-h,o-z)
6962 include 'DIMENSIONS'
6963 include 'DIMENSIONS.ZSCOPT'
6964 include 'COMMON.IOUNITS'
6965 include 'COMMON.CHAIN'
6966 include 'COMMON.FFIELD'
6967 include 'COMMON.DERIV'
6968 include 'COMMON.INTERACT'
6969 include 'COMMON.CONTACTS'
6970 include 'COMMON.TORSION'
6971 include 'COMMON.VAR'
6972 include 'COMMON.GEO'
6973 dimension dipi(2,2),dipj(2,2),dipderi(2),dipderj(2),auxvec(2),
6975 iti1 = itortyp(itype(i+1))
6976 if (j.lt.nres-1) then
6977 itj1 = itortyp(itype(j+1))
6982 dipi(iii,1)=Ub2(iii,i)
6983 dipderi(iii)=Ub2der(iii,i)
6984 dipi(iii,2)=b1(iii,iti1)
6985 dipj(iii,1)=Ub2(iii,j)
6986 dipderj(iii)=Ub2der(iii,j)
6987 dipj(iii,2)=b1(iii,itj1)
6991 call matvec2(a_chuj(1,1,jj,i),dipj(1,iii),auxvec(1))
6994 dip(kkk,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
6997 if (.not.calc_grad) return
7002 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),dipj(1,iii),
7006 dipderx(lll,kkk,mmm,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
7011 call transpose2(a_chuj(1,1,jj,i),auxmat(1,1))
7012 call matvec2(auxmat(1,1),dipderi(1),auxvec(1))
7014 dipderg(iii,jj,i)=scalar2(auxvec(1),dipj(1,iii))
7016 call matvec2(a_chuj(1,1,jj,i),dipderj(1),auxvec(1))
7018 dipderg(iii+2,jj,i)=scalar2(auxvec(1),dipi(1,iii))
7022 C---------------------------------------------------------------------------
7023 subroutine calc_eello(i,j,k,l,jj,kk)
7025 C This subroutine computes matrices and vectors needed to calculate
7026 C the fourth-, fifth-, and sixth-order local-electrostatic terms.
7028 implicit real*8 (a-h,o-z)
7029 include 'DIMENSIONS'
7030 include 'DIMENSIONS.ZSCOPT'
7031 include 'COMMON.IOUNITS'
7032 include 'COMMON.CHAIN'
7033 include 'COMMON.DERIV'
7034 include 'COMMON.INTERACT'
7035 include 'COMMON.CONTACTS'
7036 include 'COMMON.TORSION'
7037 include 'COMMON.VAR'
7038 include 'COMMON.GEO'
7039 include 'COMMON.FFIELD'
7040 double precision aa1(2,2),aa2(2,2),aa1t(2,2),aa2t(2,2),
7041 & aa1tder(2,2,3,5),aa2tder(2,2,3,5),auxmat(2,2)
7044 cd write (iout,*) 'calc_eello: i=',i,' j=',j,' k=',k,' l=',l,
7045 cd & ' jj=',jj,' kk=',kk
7046 cd if (i.ne.2 .or. j.ne.4 .or. k.ne.3 .or. l.ne.5) return
7049 aa1(iii,jjj)=a_chuj(iii,jjj,jj,i)
7050 aa2(iii,jjj)=a_chuj(iii,jjj,kk,k)
7053 call transpose2(aa1(1,1),aa1t(1,1))
7054 call transpose2(aa2(1,1),aa2t(1,1))
7057 call transpose2(a_chuj_der(1,1,lll,kkk,jj,i),
7058 & aa1tder(1,1,lll,kkk))
7059 call transpose2(a_chuj_der(1,1,lll,kkk,kk,k),
7060 & aa2tder(1,1,lll,kkk))
7064 C parallel orientation of the two CA-CA-CA frames.
7066 iti=itortyp(itype(i))
7070 itk1=itortyp(itype(k+1))
7071 itj=itortyp(itype(j))
7072 if (l.lt.nres-1) then
7073 itl1=itortyp(itype(l+1))
7077 C A1 kernel(j+1) A2T
7079 cd write (iout,'(3f10.5,5x,3f10.5)')
7080 cd & (EUg(iii,jjj,k),jjj=1,2),(EUg(iii,jjj,l),jjj=1,2)
7082 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
7083 & aa2tder(1,1,1,1),1,.false.,EUg(1,1,l),EUgder(1,1,l),
7084 & AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
7085 C Following matrices are needed only for 6-th order cumulants
7086 IF (wcorr6.gt.0.0d0) THEN
7087 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
7088 & aa2tder(1,1,1,1),1,.false.,EUgC(1,1,l),EUgCder(1,1,l),
7089 & AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
7090 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
7091 & aa2tder(1,1,1,1),2,.false.,Ug2DtEUg(1,1,l),
7092 & Ug2DtEUgder(1,1,1,l),ADtEA(1,1,1),ADtEAderg(1,1,1,1),
7093 & ADtEAderx(1,1,1,1,1,1))
7095 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
7096 & aa2tder(1,1,1,1),2,.false.,DtUg2EUg(1,1,l),
7097 & DtUg2EUgder(1,1,1,l),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),
7098 & ADtEA1derx(1,1,1,1,1,1))
7100 C End 6-th order cumulants
7103 cd write (2,*) 'In calc_eello6'
7105 cd write (2,*) 'iii=',iii
7107 cd write (2,*) 'kkk=',kkk
7109 cd write (2,'(3(2f10.5),5x)')
7110 cd & ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
7115 call transpose2(EUgder(1,1,k),auxmat(1,1))
7116 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
7117 call transpose2(EUg(1,1,k),auxmat(1,1))
7118 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
7119 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
7123 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),
7124 & EAEAderx(1,1,lll,kkk,iii,1))
7128 C A1T kernel(i+1) A2
7129 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
7130 & a_chuj_der(1,1,1,1,kk,k),1,.false.,EUg(1,1,k),EUgder(1,1,k),
7131 & AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
7132 C Following matrices are needed only for 6-th order cumulants
7133 IF (wcorr6.gt.0.0d0) THEN
7134 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
7135 & a_chuj_der(1,1,1,1,kk,k),1,.false.,EUgC(1,1,k),EUgCder(1,1,k),
7136 & AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
7137 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
7138 & a_chuj_der(1,1,1,1,kk,k),2,.false.,Ug2DtEUg(1,1,k),
7139 & Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),
7140 & ADtEAderx(1,1,1,1,1,2))
7141 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
7142 & a_chuj_der(1,1,1,1,kk,k),2,.false.,DtUg2EUg(1,1,k),
7143 & DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),
7144 & ADtEA1derx(1,1,1,1,1,2))
7146 C End 6-th order cumulants
7147 call transpose2(EUgder(1,1,l),auxmat(1,1))
7148 call matmat2(auxmat(1,1),AEA(1,1,2),EAEAderg(1,1,1,2))
7149 call transpose2(EUg(1,1,l),auxmat(1,1))
7150 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
7151 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
7155 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
7156 & EAEAderx(1,1,lll,kkk,iii,2))
7161 C Calculate the vectors and their derivatives in virtual-bond dihedral angles.
7162 C They are needed only when the fifth- or the sixth-order cumulants are
7164 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) THEN
7165 call transpose2(AEA(1,1,1),auxmat(1,1))
7166 call matvec2(auxmat(1,1),b1(1,iti),AEAb1(1,1,1))
7167 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
7168 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
7169 call transpose2(AEAderg(1,1,1),auxmat(1,1))
7170 call matvec2(auxmat(1,1),b1(1,iti),AEAb1derg(1,1,1))
7171 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
7172 call matvec2(AEA(1,1,1),b1(1,itk1),AEAb1(1,2,1))
7173 call matvec2(AEAderg(1,1,1),b1(1,itk1),AEAb1derg(1,2,1))
7174 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
7175 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
7176 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
7177 call transpose2(AEA(1,1,2),auxmat(1,1))
7178 call matvec2(auxmat(1,1),b1(1,itj),AEAb1(1,1,2))
7179 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2(1,1,2))
7180 call matvec2(auxmat(1,1),Ub2der(1,j),AEAb2derg(1,2,1,2))
7181 call transpose2(AEAderg(1,1,2),auxmat(1,1))
7182 call matvec2(auxmat(1,1),b1(1,itj),AEAb1derg(1,1,2))
7183 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2derg(1,1,1,2))
7184 call matvec2(AEA(1,1,2),b1(1,itl1),AEAb1(1,2,2))
7185 call matvec2(AEAderg(1,1,2),b1(1,itl1),AEAb1derg(1,2,2))
7186 call matvec2(AEA(1,1,2),Ub2(1,l+1),AEAb2(1,2,2))
7187 call matvec2(AEAderg(1,1,2),Ub2(1,l+1),AEAb2derg(1,1,2,2))
7188 call matvec2(AEA(1,1,2),Ub2der(1,l+1),AEAb2derg(1,2,2,2))
7189 C Calculate the Cartesian derivatives of the vectors.
7193 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
7194 call matvec2(auxmat(1,1),b1(1,iti),
7195 & AEAb1derx(1,lll,kkk,iii,1,1))
7196 call matvec2(auxmat(1,1),Ub2(1,i),
7197 & AEAb2derx(1,lll,kkk,iii,1,1))
7198 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,itk1),
7199 & AEAb1derx(1,lll,kkk,iii,2,1))
7200 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),
7201 & AEAb2derx(1,lll,kkk,iii,2,1))
7202 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
7203 call matvec2(auxmat(1,1),b1(1,itj),
7204 & AEAb1derx(1,lll,kkk,iii,1,2))
7205 call matvec2(auxmat(1,1),Ub2(1,j),
7206 & AEAb2derx(1,lll,kkk,iii,1,2))
7207 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,itl1),
7208 & AEAb1derx(1,lll,kkk,iii,2,2))
7209 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,l+1),
7210 & AEAb2derx(1,lll,kkk,iii,2,2))
7217 C Antiparallel orientation of the two CA-CA-CA frames.
7219 iti=itortyp(itype(i))
7223 itk1=itortyp(itype(k+1))
7224 itl=itortyp(itype(l))
7225 itj=itortyp(itype(j))
7226 if (j.lt.nres-1) then
7227 itj1=itortyp(itype(j+1))
7231 C A2 kernel(j-1)T A1T
7232 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
7233 & aa2tder(1,1,1,1),1,.true.,EUg(1,1,j),EUgder(1,1,j),
7234 & AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
7235 C Following matrices are needed only for 6-th order cumulants
7236 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and.
7237 & j.eq.i+4 .and. l.eq.i+3)) THEN
7238 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
7239 & aa2tder(1,1,1,1),1,.true.,EUgC(1,1,j),EUgCder(1,1,j),
7240 & AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
7241 call kernel(aa2(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
7242 & aa2tder(1,1,1,1),2,.true.,Ug2DtEUg(1,1,j),
7243 & Ug2DtEUgder(1,1,1,j),ADtEA(1,1,1),ADtEAderg(1,1,1,1),
7244 & ADtEAderx(1,1,1,1,1,1))
7245 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
7246 & aa2tder(1,1,1,1),2,.true.,DtUg2EUg(1,1,j),
7247 & DtUg2EUgder(1,1,1,j),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),
7248 & ADtEA1derx(1,1,1,1,1,1))
7250 C End 6-th order cumulants
7251 call transpose2(EUgder(1,1,k),auxmat(1,1))
7252 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
7253 call transpose2(EUg(1,1,k),auxmat(1,1))
7254 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
7255 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
7259 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),
7260 & EAEAderx(1,1,lll,kkk,iii,1))
7264 C A2T kernel(i+1)T A1
7265 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
7266 & a_chuj_der(1,1,1,1,jj,i),1,.true.,EUg(1,1,k),EUgder(1,1,k),
7267 & AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
7268 C Following matrices are needed only for 6-th order cumulants
7269 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and.
7270 & j.eq.i+4 .and. l.eq.i+3)) THEN
7271 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
7272 & a_chuj_der(1,1,1,1,jj,i),1,.true.,EUgC(1,1,k),EUgCder(1,1,k),
7273 & AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
7274 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
7275 & a_chuj_der(1,1,1,1,jj,i),2,.true.,Ug2DtEUg(1,1,k),
7276 & Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),
7277 & ADtEAderx(1,1,1,1,1,2))
7278 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
7279 & a_chuj_der(1,1,1,1,jj,i),2,.true.,DtUg2EUg(1,1,k),
7280 & DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),
7281 & ADtEA1derx(1,1,1,1,1,2))
7283 C End 6-th order cumulants
7284 call transpose2(EUgder(1,1,j),auxmat(1,1))
7285 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,2,2))
7286 call transpose2(EUg(1,1,j),auxmat(1,1))
7287 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
7288 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
7292 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
7293 & EAEAderx(1,1,lll,kkk,iii,2))
7298 C Calculate the vectors and their derivatives in virtual-bond dihedral angles.
7299 C They are needed only when the fifth- or the sixth-order cumulants are
7301 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 .or.
7302 & (wturn6.gt.0.0d0 .and. j.eq.i+4 .and. l.eq.i+3)) THEN
7303 call transpose2(AEA(1,1,1),auxmat(1,1))
7304 call matvec2(auxmat(1,1),b1(1,iti),AEAb1(1,1,1))
7305 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
7306 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
7307 call transpose2(AEAderg(1,1,1),auxmat(1,1))
7308 call matvec2(auxmat(1,1),b1(1,iti),AEAb1derg(1,1,1))
7309 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
7310 call matvec2(AEA(1,1,1),b1(1,itk1),AEAb1(1,2,1))
7311 call matvec2(AEAderg(1,1,1),b1(1,itk1),AEAb1derg(1,2,1))
7312 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
7313 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
7314 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
7315 call transpose2(AEA(1,1,2),auxmat(1,1))
7316 call matvec2(auxmat(1,1),b1(1,itj1),AEAb1(1,1,2))
7317 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2(1,1,2))
7318 call matvec2(auxmat(1,1),Ub2der(1,l),AEAb2derg(1,2,1,2))
7319 call transpose2(AEAderg(1,1,2),auxmat(1,1))
7320 call matvec2(auxmat(1,1),b1(1,itl),AEAb1(1,1,2))
7321 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2derg(1,1,1,2))
7322 call matvec2(AEA(1,1,2),b1(1,itj1),AEAb1(1,2,2))
7323 call matvec2(AEAderg(1,1,2),b1(1,itj1),AEAb1derg(1,2,2))
7324 call matvec2(AEA(1,1,2),Ub2(1,j),AEAb2(1,2,2))
7325 call matvec2(AEAderg(1,1,2),Ub2(1,j),AEAb2derg(1,1,2,2))
7326 call matvec2(AEA(1,1,2),Ub2der(1,j),AEAb2derg(1,2,2,2))
7327 C Calculate the Cartesian derivatives of the vectors.
7331 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
7332 call matvec2(auxmat(1,1),b1(1,iti),
7333 & AEAb1derx(1,lll,kkk,iii,1,1))
7334 call matvec2(auxmat(1,1),Ub2(1,i),
7335 & AEAb2derx(1,lll,kkk,iii,1,1))
7336 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,itk1),
7337 & AEAb1derx(1,lll,kkk,iii,2,1))
7338 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),
7339 & AEAb2derx(1,lll,kkk,iii,2,1))
7340 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
7341 call matvec2(auxmat(1,1),b1(1,itl),
7342 & AEAb1derx(1,lll,kkk,iii,1,2))
7343 call matvec2(auxmat(1,1),Ub2(1,l),
7344 & AEAb2derx(1,lll,kkk,iii,1,2))
7345 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,itj1),
7346 & AEAb1derx(1,lll,kkk,iii,2,2))
7347 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,j),
7348 & AEAb2derx(1,lll,kkk,iii,2,2))
7357 C---------------------------------------------------------------------------
7358 subroutine kernel(aa1,aa2t,aa1derx,aa2tderx,nderg,transp,
7359 & KK,KKderg,AKA,AKAderg,AKAderx)
7363 double precision aa1(2,2),aa2t(2,2),aa1derx(2,2,3,5),
7364 & aa2tderx(2,2,3,5),KK(2,2),KKderg(2,2,nderg),AKA(2,2),
7365 & AKAderg(2,2,nderg),AKAderx(2,2,3,5,2)
7370 call prodmat3(aa1(1,1),aa2t(1,1),KK(1,1),transp,AKA(1,1))
7372 call prodmat3(aa1(1,1),aa2t(1,1),KKderg(1,1,iii),transp,
7375 cd if (lprn) write (2,*) 'In kernel'
7377 cd if (lprn) write (2,*) 'kkk=',kkk
7379 call prodmat3(aa1derx(1,1,lll,kkk),aa2t(1,1),
7380 & KK(1,1),transp,AKAderx(1,1,lll,kkk,1))
7382 cd write (2,*) 'lll=',lll
7383 cd write (2,*) 'iii=1'
7385 cd write (2,'(3(2f10.5),5x)')
7386 cd & (AKAderx(jjj,mmm,lll,kkk,1),mmm=1,2)
7389 call prodmat3(aa1(1,1),aa2tderx(1,1,lll,kkk),
7390 & KK(1,1),transp,AKAderx(1,1,lll,kkk,2))
7392 cd write (2,*) 'lll=',lll
7393 cd write (2,*) 'iii=2'
7395 cd write (2,'(3(2f10.5),5x)')
7396 cd & (AKAderx(jjj,mmm,lll,kkk,2),mmm=1,2)
7403 C---------------------------------------------------------------------------
7404 double precision function eello4(i,j,k,l,jj,kk)
7405 implicit real*8 (a-h,o-z)
7406 include 'DIMENSIONS'
7407 include 'DIMENSIONS.ZSCOPT'
7408 include 'COMMON.IOUNITS'
7409 include 'COMMON.CHAIN'
7410 include 'COMMON.DERIV'
7411 include 'COMMON.INTERACT'
7412 include 'COMMON.CONTACTS'
7413 include 'COMMON.TORSION'
7414 include 'COMMON.VAR'
7415 include 'COMMON.GEO'
7416 double precision pizda(2,2),ggg1(3),ggg2(3)
7417 cd if (i.ne.1 .or. j.ne.5 .or. k.ne.2 .or.l.ne.4) then
7421 cd print *,'eello4:',i,j,k,l,jj,kk
7422 cd write (2,*) 'i',i,' j',j,' k',k,' l',l
7423 cd call checkint4(i,j,k,l,jj,kk,eel4_num)
7424 cold eij=facont_hb(jj,i)
7425 cold ekl=facont_hb(kk,k)
7427 eel4=-EAEA(1,1,1)-EAEA(2,2,1)
7429 cd eel41=-EAEA(1,1,2)-EAEA(2,2,2)
7430 gcorr_loc(k-1)=gcorr_loc(k-1)
7431 & -ekont*(EAEAderg(1,1,1,1)+EAEAderg(2,2,1,1))
7433 gcorr_loc(l-1)=gcorr_loc(l-1)
7434 & -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
7436 gcorr_loc(j-1)=gcorr_loc(j-1)
7437 & -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
7442 derx(lll,kkk,iii)=-EAEAderx(1,1,lll,kkk,iii,1)
7443 & -EAEAderx(2,2,lll,kkk,iii,1)
7444 cd derx(lll,kkk,iii)=0.0d0
7448 cd gcorr_loc(l-1)=0.0d0
7449 cd gcorr_loc(j-1)=0.0d0
7450 cd gcorr_loc(k-1)=0.0d0
7452 cd write (iout,*)'Contacts have occurred for peptide groups',
7453 cd & i,j,' fcont:',eij,' eij',' and ',k,l,
7454 cd & ' fcont ',ekl,' eel4=',eel4,' eel4_num',16*eel4_num
7455 if (j.lt.nres-1) then
7462 if (l.lt.nres-1) then
7470 cold ghalf=0.5d0*eel4*ekl*gacont_hbr(ll,jj,i)
7471 ggg1(ll)=eel4*g_contij(ll,1)
7472 ggg2(ll)=eel4*g_contij(ll,2)
7473 ghalf=0.5d0*ggg1(ll)
7475 gradcorr(ll,i)=gradcorr(ll,i)+ghalf+ekont*derx(ll,2,1)
7476 gradcorr(ll,i+1)=gradcorr(ll,i+1)+ekont*derx(ll,3,1)
7477 gradcorr(ll,j)=gradcorr(ll,j)+ghalf+ekont*derx(ll,4,1)
7478 gradcorr(ll,j1)=gradcorr(ll,j1)+ekont*derx(ll,5,1)
7479 cold ghalf=0.5d0*eel4*eij*gacont_hbr(ll,kk,k)
7480 ghalf=0.5d0*ggg2(ll)
7482 gradcorr(ll,k)=gradcorr(ll,k)+ghalf+ekont*derx(ll,2,2)
7483 gradcorr(ll,k+1)=gradcorr(ll,k+1)+ekont*derx(ll,3,2)
7484 gradcorr(ll,l)=gradcorr(ll,l)+ghalf+ekont*derx(ll,4,2)
7485 gradcorr(ll,l1)=gradcorr(ll,l1)+ekont*derx(ll,5,2)
7490 cold gradcorr(ll,m)=gradcorr(ll,m)+eel4*ekl*gacont_hbr(ll,jj,i)
7491 gradcorr(ll,m)=gradcorr(ll,m)+ggg1(ll)
7496 cold gradcorr(ll,m)=gradcorr(ll,m)+eel4*eij*gacont_hbr(ll,kk,k)
7497 gradcorr(ll,m)=gradcorr(ll,m)+ggg2(ll)
7503 gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,1)
7508 gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,2)
7512 cd write (2,*) iii,gcorr_loc(iii)
7516 cd write (2,*) 'ekont',ekont
7517 cd write (iout,*) 'eello4',ekont*eel4
7520 C---------------------------------------------------------------------------
7521 double precision function eello5(i,j,k,l,jj,kk)
7522 implicit real*8 (a-h,o-z)
7523 include 'DIMENSIONS'
7524 include 'DIMENSIONS.ZSCOPT'
7525 include 'COMMON.IOUNITS'
7526 include 'COMMON.CHAIN'
7527 include 'COMMON.DERIV'
7528 include 'COMMON.INTERACT'
7529 include 'COMMON.CONTACTS'
7530 include 'COMMON.TORSION'
7531 include 'COMMON.VAR'
7532 include 'COMMON.GEO'
7533 double precision pizda(2,2),auxmat(2,2),auxmat1(2,2),vv(2)
7534 double precision ggg1(3),ggg2(3)
7535 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
7540 C /l\ / \ \ / \ / \ / C
7541 C / \ / \ \ / \ / \ / C
7542 C j| o |l1 | o | o| o | | o |o C
7543 C \ |/k\| |/ \| / |/ \| |/ \| C
7544 C \i/ \ / \ / / \ / \ C
7546 C (I) (II) (III) (IV) C
7548 C eello5_1 eello5_2 eello5_3 eello5_4 C
7550 C Antiparallel chains C
7553 C /j\ / \ \ / \ / \ / C
7554 C / \ / \ \ / \ / \ / C
7555 C j1| o |l | o | o| o | | o |o C
7556 C \ |/k\| |/ \| / |/ \| |/ \| C
7557 C \i/ \ / \ / / \ / \ C
7559 C (I) (II) (III) (IV) C
7561 C eello5_1 eello5_2 eello5_3 eello5_4 C
7563 C o denotes a local interaction, vertical lines an electrostatic interaction. C
7565 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
7566 cd if (i.ne.2 .or. j.ne.6 .or. k.ne.3 .or. l.ne.5) then
7571 cd & 'EELLO5: Contacts have occurred for peptide groups',i,j,
7573 itk=itortyp(itype(k))
7574 itl=itortyp(itype(l))
7575 itj=itortyp(itype(j))
7580 cd call checkint5(i,j,k,l,jj,kk,eel5_1_num,eel5_2_num,
7581 cd & eel5_3_num,eel5_4_num)
7585 derx(lll,kkk,iii)=0.0d0
7589 cd eij=facont_hb(jj,i)
7590 cd ekl=facont_hb(kk,k)
7592 cd write (iout,*)'Contacts have occurred for peptide groups',
7593 cd & i,j,' fcont:',eij,' eij',' and ',k,l
7595 C Contribution from the graph I.
7596 cd write (2,*) 'AEA ',AEA(1,1,1),AEA(2,1,1),AEA(1,2,1),AEA(2,2,1)
7597 cd write (2,*) 'AEAb2',AEAb2(1,1,1),AEAb2(2,1,1)
7598 call transpose2(EUg(1,1,k),auxmat(1,1))
7599 call matmat2(AEA(1,1,1),auxmat(1,1),pizda(1,1))
7600 vv(1)=pizda(1,1)-pizda(2,2)
7601 vv(2)=pizda(1,2)+pizda(2,1)
7602 eello5_1=scalar2(AEAb2(1,1,1),Ub2(1,k))
7603 & +0.5d0*scalar2(vv(1),Dtobr2(1,i))
7605 C Explicit gradient in virtual-dihedral angles.
7606 if (i.gt.1) g_corr5_loc(i-1)=g_corr5_loc(i-1)
7607 & +ekont*(scalar2(AEAb2derg(1,2,1,1),Ub2(1,k))
7608 & +0.5d0*scalar2(vv(1),Dtobr2der(1,i)))
7609 call transpose2(EUgder(1,1,k),auxmat1(1,1))
7610 call matmat2(AEA(1,1,1),auxmat1(1,1),pizda(1,1))
7611 vv(1)=pizda(1,1)-pizda(2,2)
7612 vv(2)=pizda(1,2)+pizda(2,1)
7613 g_corr5_loc(k-1)=g_corr5_loc(k-1)
7614 & +ekont*(scalar2(AEAb2(1,1,1),Ub2der(1,k))
7615 & +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
7616 call matmat2(AEAderg(1,1,1),auxmat(1,1),pizda(1,1))
7617 vv(1)=pizda(1,1)-pizda(2,2)
7618 vv(2)=pizda(1,2)+pizda(2,1)
7620 if (l.lt.nres-1) g_corr5_loc(l-1)=g_corr5_loc(l-1)
7621 & +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k))
7622 & +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
7624 if (j.lt.nres-1) g_corr5_loc(j-1)=g_corr5_loc(j-1)
7625 & +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k))
7626 & +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
7628 C Cartesian gradient
7632 call matmat2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1),
7634 vv(1)=pizda(1,1)-pizda(2,2)
7635 vv(2)=pizda(1,2)+pizda(2,1)
7636 derx(lll,kkk,iii)=derx(lll,kkk,iii)
7637 & +scalar2(AEAb2derx(1,lll,kkk,iii,1,1),Ub2(1,k))
7638 & +0.5d0*scalar2(vv(1),Dtobr2(1,i))
7645 C Contribution from graph II
7646 call transpose2(EE(1,1,itk),auxmat(1,1))
7647 call matmat2(auxmat(1,1),AEA(1,1,1),pizda(1,1))
7648 vv(1)=pizda(1,1)+pizda(2,2)
7649 vv(2)=pizda(2,1)-pizda(1,2)
7650 eello5_2=scalar2(AEAb1(1,2,1),b1(1,itk))
7651 & -0.5d0*scalar2(vv(1),Ctobr(1,k))
7653 C Explicit gradient in virtual-dihedral angles.
7654 g_corr5_loc(k-1)=g_corr5_loc(k-1)
7655 & -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,k))
7656 call matmat2(auxmat(1,1),AEAderg(1,1,1),pizda(1,1))
7657 vv(1)=pizda(1,1)+pizda(2,2)
7658 vv(2)=pizda(2,1)-pizda(1,2)
7660 g_corr5_loc(l-1)=g_corr5_loc(l-1)
7661 & +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,itk))
7662 & -0.5d0*scalar2(vv(1),Ctobr(1,k)))
7664 g_corr5_loc(j-1)=g_corr5_loc(j-1)
7665 & +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,itk))
7666 & -0.5d0*scalar2(vv(1),Ctobr(1,k)))
7668 C Cartesian gradient
7672 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),
7674 vv(1)=pizda(1,1)+pizda(2,2)
7675 vv(2)=pizda(2,1)-pizda(1,2)
7676 derx(lll,kkk,iii)=derx(lll,kkk,iii)
7677 & +scalar2(AEAb1derx(1,lll,kkk,iii,2,1),b1(1,itk))
7678 & -0.5d0*scalar2(vv(1),Ctobr(1,k))
7687 C Parallel orientation
7688 C Contribution from graph III
7689 call transpose2(EUg(1,1,l),auxmat(1,1))
7690 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
7691 vv(1)=pizda(1,1)-pizda(2,2)
7692 vv(2)=pizda(1,2)+pizda(2,1)
7693 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,l))
7694 & +0.5d0*scalar2(vv(1),Dtobr2(1,j))
7696 C Explicit gradient in virtual-dihedral angles.
7697 g_corr5_loc(j-1)=g_corr5_loc(j-1)
7698 & +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,l))
7699 & +0.5d0*scalar2(vv(1),Dtobr2der(1,j)))
7700 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
7701 vv(1)=pizda(1,1)-pizda(2,2)
7702 vv(2)=pizda(1,2)+pizda(2,1)
7703 g_corr5_loc(k-1)=g_corr5_loc(k-1)
7704 & +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,l))
7705 & +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
7706 call transpose2(EUgder(1,1,l),auxmat1(1,1))
7707 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
7708 vv(1)=pizda(1,1)-pizda(2,2)
7709 vv(2)=pizda(1,2)+pizda(2,1)
7710 g_corr5_loc(l-1)=g_corr5_loc(l-1)
7711 & +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,l))
7712 & +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
7713 C Cartesian gradient
7717 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),
7719 vv(1)=pizda(1,1)-pizda(2,2)
7720 vv(2)=pizda(1,2)+pizda(2,1)
7721 derx(lll,kkk,iii)=derx(lll,kkk,iii)
7722 & +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,l))
7723 & +0.5d0*scalar2(vv(1),Dtobr2(1,j))
7729 C Contribution from graph IV
7731 call transpose2(EE(1,1,itl),auxmat(1,1))
7732 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
7733 vv(1)=pizda(1,1)+pizda(2,2)
7734 vv(2)=pizda(2,1)-pizda(1,2)
7735 eello5_4=scalar2(AEAb1(1,2,2),b1(1,itl))
7736 & -0.5d0*scalar2(vv(1),Ctobr(1,l))
7738 C Explicit gradient in virtual-dihedral angles.
7739 g_corr5_loc(l-1)=g_corr5_loc(l-1)
7740 & -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,l))
7741 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
7742 vv(1)=pizda(1,1)+pizda(2,2)
7743 vv(2)=pizda(2,1)-pizda(1,2)
7744 g_corr5_loc(k-1)=g_corr5_loc(k-1)
7745 & +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,itl))
7746 & -0.5d0*scalar2(vv(1),Ctobr(1,l)))
7747 C Cartesian gradient
7751 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
7753 vv(1)=pizda(1,1)+pizda(2,2)
7754 vv(2)=pizda(2,1)-pizda(1,2)
7755 derx(lll,kkk,iii)=derx(lll,kkk,iii)
7756 & +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,itl))
7757 & -0.5d0*scalar2(vv(1),Ctobr(1,l))
7763 C Antiparallel orientation
7764 C Contribution from graph III
7766 call transpose2(EUg(1,1,j),auxmat(1,1))
7767 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
7768 vv(1)=pizda(1,1)-pizda(2,2)
7769 vv(2)=pizda(1,2)+pizda(2,1)
7770 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,j))
7771 & +0.5d0*scalar2(vv(1),Dtobr2(1,l))
7773 C Explicit gradient in virtual-dihedral angles.
7774 g_corr5_loc(l-1)=g_corr5_loc(l-1)
7775 & +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,j))
7776 & +0.5d0*scalar2(vv(1),Dtobr2der(1,l)))
7777 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
7778 vv(1)=pizda(1,1)-pizda(2,2)
7779 vv(2)=pizda(1,2)+pizda(2,1)
7780 g_corr5_loc(k-1)=g_corr5_loc(k-1)
7781 & +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,j))
7782 & +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
7783 call transpose2(EUgder(1,1,j),auxmat1(1,1))
7784 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
7785 vv(1)=pizda(1,1)-pizda(2,2)
7786 vv(2)=pizda(1,2)+pizda(2,1)
7787 g_corr5_loc(j-1)=g_corr5_loc(j-1)
7788 & +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,j))
7789 & +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
7790 C Cartesian gradient
7794 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),
7796 vv(1)=pizda(1,1)-pizda(2,2)
7797 vv(2)=pizda(1,2)+pizda(2,1)
7798 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)
7799 & +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,j))
7800 & +0.5d0*scalar2(vv(1),Dtobr2(1,l))
7806 C Contribution from graph IV
7808 call transpose2(EE(1,1,itj),auxmat(1,1))
7809 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
7810 vv(1)=pizda(1,1)+pizda(2,2)
7811 vv(2)=pizda(2,1)-pizda(1,2)
7812 eello5_4=scalar2(AEAb1(1,2,2),b1(1,itj))
7813 & -0.5d0*scalar2(vv(1),Ctobr(1,j))
7815 C Explicit gradient in virtual-dihedral angles.
7816 g_corr5_loc(j-1)=g_corr5_loc(j-1)
7817 & -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,j))
7818 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
7819 vv(1)=pizda(1,1)+pizda(2,2)
7820 vv(2)=pizda(2,1)-pizda(1,2)
7821 g_corr5_loc(k-1)=g_corr5_loc(k-1)
7822 & +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,itj))
7823 & -0.5d0*scalar2(vv(1),Ctobr(1,j)))
7824 C Cartesian gradient
7828 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
7830 vv(1)=pizda(1,1)+pizda(2,2)
7831 vv(2)=pizda(2,1)-pizda(1,2)
7832 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)
7833 & +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,itj))
7834 & -0.5d0*scalar2(vv(1),Ctobr(1,j))
7841 eel5=eello5_1+eello5_2+eello5_3+eello5_4
7842 cd if (i.eq.2 .and. j.eq.8 .and. k.eq.3 .and. l.eq.7) then
7843 cd write (2,*) 'ijkl',i,j,k,l
7844 cd write (2,*) 'eello5_1',eello5_1,' eello5_2',eello5_2,
7845 cd & ' eello5_3',eello5_3,' eello5_4',eello5_4
7847 cd write(iout,*) 'eello5_1',eello5_1,' eel5_1_num',16*eel5_1_num
7848 cd write(iout,*) 'eello5_2',eello5_2,' eel5_2_num',16*eel5_2_num
7849 cd write(iout,*) 'eello5_3',eello5_3,' eel5_3_num',16*eel5_3_num
7850 cd write(iout,*) 'eello5_4',eello5_4,' eel5_4_num',16*eel5_4_num
7852 if (j.lt.nres-1) then
7859 if (l.lt.nres-1) then
7869 cd write (2,*) 'eij',eij,' ekl',ekl,' ekont',ekont
7871 ggg1(ll)=eel5*g_contij(ll,1)
7872 ggg2(ll)=eel5*g_contij(ll,2)
7873 cold ghalf=0.5d0*eel5*ekl*gacont_hbr(ll,jj,i)
7874 ghalf=0.5d0*ggg1(ll)
7876 gradcorr5(ll,i)=gradcorr5(ll,i)+ghalf+ekont*derx(ll,2,1)
7877 gradcorr5(ll,i+1)=gradcorr5(ll,i+1)+ekont*derx(ll,3,1)
7878 gradcorr5(ll,j)=gradcorr5(ll,j)+ghalf+ekont*derx(ll,4,1)
7879 gradcorr5(ll,j1)=gradcorr5(ll,j1)+ekont*derx(ll,5,1)
7880 cold ghalf=0.5d0*eel5*eij*gacont_hbr(ll,kk,k)
7881 ghalf=0.5d0*ggg2(ll)
7883 gradcorr5(ll,k)=gradcorr5(ll,k)+ghalf+ekont*derx(ll,2,2)
7884 gradcorr5(ll,k+1)=gradcorr5(ll,k+1)+ekont*derx(ll,3,2)
7885 gradcorr5(ll,l)=gradcorr5(ll,l)+ghalf+ekont*derx(ll,4,2)
7886 gradcorr5(ll,l1)=gradcorr5(ll,l1)+ekont*derx(ll,5,2)
7891 cold gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*ekl*gacont_hbr(ll,jj,i)
7892 gradcorr5(ll,m)=gradcorr5(ll,m)+ggg1(ll)
7897 cold gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*eij*gacont_hbr(ll,kk,k)
7898 gradcorr5(ll,m)=gradcorr5(ll,m)+ggg2(ll)
7904 gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,1)
7909 gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,2)
7913 cd write (2,*) iii,g_corr5_loc(iii)
7917 cd write (2,*) 'ekont',ekont
7918 cd write (iout,*) 'eello5',ekont*eel5
7921 c--------------------------------------------------------------------------
7922 double precision function eello6(i,j,k,l,jj,kk)
7923 implicit real*8 (a-h,o-z)
7924 include 'DIMENSIONS'
7925 include 'DIMENSIONS.ZSCOPT'
7926 include 'COMMON.IOUNITS'
7927 include 'COMMON.CHAIN'
7928 include 'COMMON.DERIV'
7929 include 'COMMON.INTERACT'
7930 include 'COMMON.CONTACTS'
7931 include 'COMMON.TORSION'
7932 include 'COMMON.VAR'
7933 include 'COMMON.GEO'
7934 include 'COMMON.FFIELD'
7935 double precision ggg1(3),ggg2(3)
7936 cd if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
7941 cd & 'EELLO6: Contacts have occurred for peptide groups',i,j,
7949 cd call checkint6(i,j,k,l,jj,kk,eel6_1_num,eel6_2_num,
7950 cd & eel6_3_num,eel6_4_num,eel6_5_num,eel6_6_num)
7954 derx(lll,kkk,iii)=0.0d0
7958 cd eij=facont_hb(jj,i)
7959 cd ekl=facont_hb(kk,k)
7965 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
7966 eello6_2=eello6_graph1(j,i,l,k,2,.false.)
7967 eello6_3=eello6_graph2(i,j,k,l,jj,kk,.false.)
7968 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
7969 eello6_5=eello6_graph4(j,i,l,k,jj,kk,2,.false.)
7970 eello6_6=eello6_graph3(i,j,k,l,jj,kk,.false.)
7972 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
7973 eello6_2=eello6_graph1(l,k,j,i,2,.true.)
7974 eello6_3=eello6_graph2(i,l,k,j,jj,kk,.true.)
7975 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
7976 if (wturn6.eq.0.0d0 .or. j.ne.i+4) then
7977 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
7981 eello6_6=eello6_graph3(i,l,k,j,jj,kk,.true.)
7983 C If turn contributions are considered, they will be handled separately.
7984 eel6=eello6_1+eello6_2+eello6_3+eello6_4+eello6_5+eello6_6
7985 cd write(iout,*) 'eello6_1',eello6_1,' eel6_1_num',16*eel6_1_num
7986 cd write(iout,*) 'eello6_2',eello6_2,' eel6_2_num',16*eel6_2_num
7987 cd write(iout,*) 'eello6_3',eello6_3,' eel6_3_num',16*eel6_3_num
7988 cd write(iout,*) 'eello6_4',eello6_4,' eel6_4_num',16*eel6_4_num
7989 cd write(iout,*) 'eello6_5',eello6_5,' eel6_5_num',16*eel6_5_num
7990 cd write(iout,*) 'eello6_6',eello6_6,' eel6_6_num',16*eel6_6_num
7993 if (j.lt.nres-1) then
8000 if (l.lt.nres-1) then
8008 ggg1(ll)=eel6*g_contij(ll,1)
8009 ggg2(ll)=eel6*g_contij(ll,2)
8010 cold ghalf=0.5d0*eel6*ekl*gacont_hbr(ll,jj,i)
8011 ghalf=0.5d0*ggg1(ll)
8013 gradcorr6(ll,i)=gradcorr6(ll,i)+ghalf+ekont*derx(ll,2,1)
8014 gradcorr6(ll,i+1)=gradcorr6(ll,i+1)+ekont*derx(ll,3,1)
8015 gradcorr6(ll,j)=gradcorr6(ll,j)+ghalf+ekont*derx(ll,4,1)
8016 gradcorr6(ll,j1)=gradcorr6(ll,j1)+ekont*derx(ll,5,1)
8017 ghalf=0.5d0*ggg2(ll)
8018 cold ghalf=0.5d0*eel6*eij*gacont_hbr(ll,kk,k)
8020 gradcorr6(ll,k)=gradcorr6(ll,k)+ghalf+ekont*derx(ll,2,2)
8021 gradcorr6(ll,k+1)=gradcorr6(ll,k+1)+ekont*derx(ll,3,2)
8022 gradcorr6(ll,l)=gradcorr6(ll,l)+ghalf+ekont*derx(ll,4,2)
8023 gradcorr6(ll,l1)=gradcorr6(ll,l1)+ekont*derx(ll,5,2)
8028 cold gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*ekl*gacont_hbr(ll,jj,i)
8029 gradcorr6(ll,m)=gradcorr6(ll,m)+ggg1(ll)
8034 cold gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*eij*gacont_hbr(ll,kk,k)
8035 gradcorr6(ll,m)=gradcorr6(ll,m)+ggg2(ll)
8041 gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,1)
8046 gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,2)
8050 cd write (2,*) iii,g_corr6_loc(iii)
8054 cd write (2,*) 'ekont',ekont
8055 cd write (iout,*) 'eello6',ekont*eel6
8058 c--------------------------------------------------------------------------
8059 double precision function eello6_graph1(i,j,k,l,imat,swap)
8060 implicit real*8 (a-h,o-z)
8061 include 'DIMENSIONS'
8062 include 'DIMENSIONS.ZSCOPT'
8063 include 'COMMON.IOUNITS'
8064 include 'COMMON.CHAIN'
8065 include 'COMMON.DERIV'
8066 include 'COMMON.INTERACT'
8067 include 'COMMON.CONTACTS'
8068 include 'COMMON.TORSION'
8069 include 'COMMON.VAR'
8070 include 'COMMON.GEO'
8071 double precision vv(2),vv1(2),pizda(2,2),auxmat(2,2),pizda1(2,2)
8075 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8077 C Parallel Antiparallel C
8083 C \ j|/k\| / \ |/k\|l / C
8088 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8089 itk=itortyp(itype(k))
8090 s1= scalar2(AEAb1(1,2,imat),CUgb2(1,i))
8091 s2=-scalar2(AEAb2(1,1,imat),Ug2Db1t(1,k))
8092 s3= scalar2(AEAb2(1,1,imat),CUgb2(1,k))
8093 call transpose2(EUgC(1,1,k),auxmat(1,1))
8094 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
8095 vv1(1)=pizda1(1,1)-pizda1(2,2)
8096 vv1(2)=pizda1(1,2)+pizda1(2,1)
8097 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
8098 vv(1)=AEAb1(1,2,imat)*b1(1,itk)-AEAb1(2,2,imat)*b1(2,itk)
8099 vv(2)=AEAb1(1,2,imat)*b1(2,itk)+AEAb1(2,2,imat)*b1(1,itk)
8100 s5=scalar2(vv(1),Dtobr2(1,i))
8101 cd write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4', s4,' s5',s5
8102 eello6_graph1=-0.5d0*(s1+s2+s3+s4+s5)
8103 if (.not. calc_grad) return
8104 if (i.gt.1) g_corr6_loc(i-1)=g_corr6_loc(i-1)
8105 & -0.5d0*ekont*(scalar2(AEAb1(1,2,imat),CUgb2der(1,i))
8106 & -scalar2(AEAb2derg(1,2,1,imat),Ug2Db1t(1,k))
8107 & +scalar2(AEAb2derg(1,2,1,imat),CUgb2(1,k))
8108 & +0.5d0*scalar2(vv1(1),Dtobr2der(1,i))
8109 & +scalar2(vv(1),Dtobr2der(1,i)))
8110 call matmat2(AEAderg(1,1,imat),auxmat(1,1),pizda1(1,1))
8111 vv1(1)=pizda1(1,1)-pizda1(2,2)
8112 vv1(2)=pizda1(1,2)+pizda1(2,1)
8113 vv(1)=AEAb1derg(1,2,imat)*b1(1,itk)-AEAb1derg(2,2,imat)*b1(2,itk)
8114 vv(2)=AEAb1derg(1,2,imat)*b1(2,itk)+AEAb1derg(2,2,imat)*b1(1,itk)
8116 g_corr6_loc(l-1)=g_corr6_loc(l-1)
8117 & +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i))
8118 & -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k))
8119 & +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k))
8120 & +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
8122 g_corr6_loc(j-1)=g_corr6_loc(j-1)
8123 & +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i))
8124 & -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k))
8125 & +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k))
8126 & +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
8128 call transpose2(EUgCder(1,1,k),auxmat(1,1))
8129 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
8130 vv1(1)=pizda1(1,1)-pizda1(2,2)
8131 vv1(2)=pizda1(1,2)+pizda1(2,1)
8132 if (k.gt.1) g_corr6_loc(k-1)=g_corr6_loc(k-1)
8133 & +ekont*(-0.5d0*(-scalar2(AEAb2(1,1,imat),Ug2Db1tder(1,k))
8134 & +scalar2(AEAb2(1,1,imat),CUgb2der(1,k))
8135 & +0.5d0*scalar2(vv1(1),Dtobr2(1,i))))
8144 s1= scalar2(AEAb1derx(1,lll,kkk,iii,2,imat),CUgb2(1,i))
8145 s2=-scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),Ug2Db1t(1,k))
8146 s3= scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),CUgb2(1,k))
8147 call transpose2(EUgC(1,1,k),auxmat(1,1))
8148 call matmat2(AEAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),
8150 vv1(1)=pizda1(1,1)-pizda1(2,2)
8151 vv1(2)=pizda1(1,2)+pizda1(2,1)
8152 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
8153 vv(1)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(1,itk)
8154 & -AEAb1derx(2,lll,kkk,iii,2,imat)*b1(2,itk)
8155 vv(2)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(2,itk)
8156 & +AEAb1derx(2,lll,kkk,iii,2,imat)*b1(1,itk)
8157 s5=scalar2(vv(1),Dtobr2(1,i))
8158 derx(lll,kkk,ind)=derx(lll,kkk,ind)-0.5d0*(s1+s2+s3+s4+s5)
8164 c----------------------------------------------------------------------------
8165 double precision function eello6_graph2(i,j,k,l,jj,kk,swap)
8166 implicit real*8 (a-h,o-z)
8167 include 'DIMENSIONS'
8168 include 'DIMENSIONS.ZSCOPT'
8169 include 'COMMON.IOUNITS'
8170 include 'COMMON.CHAIN'
8171 include 'COMMON.DERIV'
8172 include 'COMMON.INTERACT'
8173 include 'COMMON.CONTACTS'
8174 include 'COMMON.TORSION'
8175 include 'COMMON.VAR'
8176 include 'COMMON.GEO'
8178 double precision vv(2),pizda(2,2),auxmat(2,2),auxvec(2),
8179 & auxvec1(2),auxvec2(1),auxmat1(2,2)
8182 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8184 C Parallel Antiparallel C
8190 C \ j|/k\| \ |/k\|l C
8195 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8196 cd write (2,*) 'eello6_graph2: i,',i,' j',j,' k',k,' l',l
8197 C AL 7/4/01 s1 would occur in the sixth-order moment,
8198 C but not in a cluster cumulant
8200 s1=dip(1,jj,i)*dip(1,kk,k)
8202 call matvec2(ADtEA1(1,1,1),Ub2(1,k),auxvec(1))
8203 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
8204 call matvec2(ADtEA(1,1,2),Ub2(1,l),auxvec1(1))
8205 s3=-0.5d0*scalar2(Ub2(1,j),auxvec1(1))
8206 call transpose2(EUg(1,1,k),auxmat(1,1))
8207 call matmat2(ADtEA1(1,1,1),auxmat(1,1),pizda(1,1))
8208 vv(1)=pizda(1,1)-pizda(2,2)
8209 vv(2)=pizda(1,2)+pizda(2,1)
8210 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
8211 cd write (2,*) 'eello6_graph2:','s1',s1,' s2',s2,' s3',s3,' s4',s4
8213 eello6_graph2=-(s1+s2+s3+s4)
8215 eello6_graph2=-(s2+s3+s4)
8218 if (.not. calc_grad) return
8219 C Derivatives in gamma(i-1)
8222 s1=dipderg(1,jj,i)*dip(1,kk,k)
8224 s2=-0.5d0*scalar2(Ub2der(1,i),auxvec(1))
8225 call matvec2(ADtEAderg(1,1,1,2),Ub2(1,l),auxvec2(1))
8226 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
8227 s4=-0.25d0*scalar2(vv(1),Dtobr2der(1,i))
8229 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
8231 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
8233 c g_corr6_loc(i-1)=g_corr6_loc(i-1)-s3
8235 C Derivatives in gamma(k-1)
8237 s1=dip(1,jj,i)*dipderg(1,kk,k)
8239 call matvec2(ADtEA1(1,1,1),Ub2der(1,k),auxvec2(1))
8240 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
8241 call matvec2(ADtEAderg(1,1,2,2),Ub2(1,l),auxvec2(1))
8242 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
8243 call transpose2(EUgder(1,1,k),auxmat1(1,1))
8244 call matmat2(ADtEA1(1,1,1),auxmat1(1,1),pizda(1,1))
8245 vv(1)=pizda(1,1)-pizda(2,2)
8246 vv(2)=pizda(1,2)+pizda(2,1)
8247 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
8249 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
8251 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
8253 c g_corr6_loc(k-1)=g_corr6_loc(k-1)-s3
8254 C Derivatives in gamma(j-1) or gamma(l-1)
8257 s1=dipderg(3,jj,i)*dip(1,kk,k)
8259 call matvec2(ADtEA1derg(1,1,1,1),Ub2(1,k),auxvec2(1))
8260 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
8261 s3=-0.5d0*scalar2(Ub2der(1,j),auxvec1(1))
8262 call matmat2(ADtEA1derg(1,1,1,1),auxmat(1,1),pizda(1,1))
8263 vv(1)=pizda(1,1)-pizda(2,2)
8264 vv(2)=pizda(1,2)+pizda(2,1)
8265 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
8268 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
8270 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
8273 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s3+s4)
8274 c g_corr6_loc(j-1)=g_corr6_loc(j-1)-s3
8276 C Derivatives in gamma(l-1) or gamma(j-1)
8279 s1=dip(1,jj,i)*dipderg(3,kk,k)
8281 call matvec2(ADtEA1derg(1,1,2,1),Ub2(1,k),auxvec2(1))
8282 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
8283 call matvec2(ADtEA(1,1,2),Ub2der(1,l),auxvec2(1))
8284 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
8285 call matmat2(ADtEA1derg(1,1,2,1),auxmat(1,1),pizda(1,1))
8286 vv(1)=pizda(1,1)-pizda(2,2)
8287 vv(2)=pizda(1,2)+pizda(2,1)
8288 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
8291 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
8293 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
8296 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s3+s4)
8297 c g_corr6_loc(l-1)=g_corr6_loc(l-1)-s3
8299 C Cartesian derivatives.
8301 write (2,*) 'In eello6_graph2'
8303 write (2,*) 'iii=',iii
8305 write (2,*) 'kkk=',kkk
8307 write (2,'(3(2f10.5),5x)')
8308 & ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
8318 s1=dipderx(lll,kkk,1,jj,i)*dip(1,kk,k)
8320 s1=dip(1,jj,i)*dipderx(lll,kkk,1,kk,k)
8323 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,1),Ub2(1,k),
8325 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
8326 call matvec2(ADtEAderx(1,1,lll,kkk,iii,2),Ub2(1,l),
8328 s3=-0.5d0*scalar2(Ub2(1,j),auxvec(1))
8329 call transpose2(EUg(1,1,k),auxmat(1,1))
8330 call matmat2(ADtEA1derx(1,1,lll,kkk,iii,1),auxmat(1,1),
8332 vv(1)=pizda(1,1)-pizda(2,2)
8333 vv(2)=pizda(1,2)+pizda(2,1)
8334 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
8335 cd write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4',s4
8337 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
8339 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
8342 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
8344 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
8351 c----------------------------------------------------------------------------
8352 double precision function eello6_graph3(i,j,k,l,jj,kk,swap)
8353 implicit real*8 (a-h,o-z)
8354 include 'DIMENSIONS'
8355 include 'DIMENSIONS.ZSCOPT'
8356 include 'COMMON.IOUNITS'
8357 include 'COMMON.CHAIN'
8358 include 'COMMON.DERIV'
8359 include 'COMMON.INTERACT'
8360 include 'COMMON.CONTACTS'
8361 include 'COMMON.TORSION'
8362 include 'COMMON.VAR'
8363 include 'COMMON.GEO'
8364 double precision vv(2),pizda(2,2),auxmat(2,2),auxvec(2)
8366 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8368 C Parallel Antiparallel C
8374 C j|/k\| / |/k\|l / C
8379 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8381 C 4/7/01 AL Component s1 was removed, because it pertains to the respective
8382 C energy moment and not to the cluster cumulant.
8383 iti=itortyp(itype(i))
8384 if (j.lt.nres-1) then
8385 itj1=itortyp(itype(j+1))
8389 itk=itortyp(itype(k))
8390 itk1=itortyp(itype(k+1))
8391 if (l.lt.nres-1) then
8392 itl1=itortyp(itype(l+1))
8397 s1=dip(4,jj,i)*dip(4,kk,k)
8399 call matvec2(AECA(1,1,1),b1(1,itk1),auxvec(1))
8400 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
8401 call matvec2(AECA(1,1,2),b1(1,itl1),auxvec(1))
8402 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
8403 call transpose2(EE(1,1,itk),auxmat(1,1))
8404 call matmat2(auxmat(1,1),AECA(1,1,1),pizda(1,1))
8405 vv(1)=pizda(1,1)+pizda(2,2)
8406 vv(2)=pizda(2,1)-pizda(1,2)
8407 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
8408 cd write (2,*) 'eello6_graph3:','s1',s1,' s2',s2,' s3',s3,' s4',s4
8410 eello6_graph3=-(s1+s2+s3+s4)
8412 eello6_graph3=-(s2+s3+s4)
8415 if (.not. calc_grad) return
8416 C Derivatives in gamma(k-1)
8417 call matvec2(AECAderg(1,1,2),b1(1,itl1),auxvec(1))
8418 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
8419 s4=-0.25d0*scalar2(vv(1),Ctobrder(1,k))
8420 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s3+s4)
8421 C Derivatives in gamma(l-1)
8422 call matvec2(AECAderg(1,1,1),b1(1,itk1),auxvec(1))
8423 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
8424 call matmat2(auxmat(1,1),AECAderg(1,1,1),pizda(1,1))
8425 vv(1)=pizda(1,1)+pizda(2,2)
8426 vv(2)=pizda(2,1)-pizda(1,2)
8427 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
8428 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
8429 C Cartesian derivatives.
8435 s1=dipderx(lll,kkk,4,jj,i)*dip(4,kk,k)
8437 s1=dip(4,jj,i)*dipderx(lll,kkk,4,kk,k)
8440 call matvec2(AECAderx(1,1,lll,kkk,iii,1),b1(1,itk1),
8442 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
8443 call matvec2(AECAderx(1,1,lll,kkk,iii,2),b1(1,itl1),
8445 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
8446 call matmat2(auxmat(1,1),AECAderx(1,1,lll,kkk,iii,1),
8448 vv(1)=pizda(1,1)+pizda(2,2)
8449 vv(2)=pizda(2,1)-pizda(1,2)
8450 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
8452 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
8454 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
8457 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
8459 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
8461 c derx(lll,kkk,iii)=derx(lll,kkk,iii)-s4
8467 c----------------------------------------------------------------------------
8468 double precision function eello6_graph4(i,j,k,l,jj,kk,imat,swap)
8469 implicit real*8 (a-h,o-z)
8470 include 'DIMENSIONS'
8471 include 'DIMENSIONS.ZSCOPT'
8472 include 'COMMON.IOUNITS'
8473 include 'COMMON.CHAIN'
8474 include 'COMMON.DERIV'
8475 include 'COMMON.INTERACT'
8476 include 'COMMON.CONTACTS'
8477 include 'COMMON.TORSION'
8478 include 'COMMON.VAR'
8479 include 'COMMON.GEO'
8480 include 'COMMON.FFIELD'
8481 double precision vv(2),pizda(2,2),auxmat(2,2),auxvec(2),
8482 & auxvec1(2),auxmat1(2,2)
8484 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8486 C Parallel Antiparallel C
8492 C \ j|/k\| \ |/k\|l C
8497 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8499 C 4/7/01 AL Component s1 was removed, because it pertains to the respective
8500 C energy moment and not to the cluster cumulant.
8501 cd write (2,*) 'eello_graph4: wturn6',wturn6
8502 iti=itortyp(itype(i))
8503 itj=itortyp(itype(j))
8504 if (j.lt.nres-1) then
8505 itj1=itortyp(itype(j+1))
8509 itk=itortyp(itype(k))
8510 if (k.lt.nres-1) then
8511 itk1=itortyp(itype(k+1))
8515 itl=itortyp(itype(l))
8516 if (l.lt.nres-1) then
8517 itl1=itortyp(itype(l+1))
8521 cd write (2,*) 'eello6_graph4:','i',i,' j',j,' k',k,' l',l
8522 cd write (2,*) 'iti',iti,' itj',itj,' itj1',itj1,' itk',itk,
8523 cd & ' itl',itl,' itl1',itl1
8526 s1=dip(3,jj,i)*dip(3,kk,k)
8528 s1=dip(2,jj,j)*dip(2,kk,l)
8531 call matvec2(AECA(1,1,imat),Ub2(1,k),auxvec(1))
8532 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
8534 call matvec2(ADtEA1(1,1,3-imat),b1(1,itj1),auxvec1(1))
8535 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
8537 call matvec2(ADtEA1(1,1,3-imat),b1(1,itl1),auxvec1(1))
8538 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
8540 call transpose2(EUg(1,1,k),auxmat(1,1))
8541 call matmat2(AECA(1,1,imat),auxmat(1,1),pizda(1,1))
8542 vv(1)=pizda(1,1)-pizda(2,2)
8543 vv(2)=pizda(2,1)+pizda(1,2)
8544 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
8545 cd write (2,*) 'eello6_graph4:','s1',s1,' s2',s2,' s3',s3,' s4',s4
8547 eello6_graph4=-(s1+s2+s3+s4)
8549 eello6_graph4=-(s2+s3+s4)
8551 if (.not. calc_grad) return
8552 C Derivatives in gamma(i-1)
8556 s1=dipderg(2,jj,i)*dip(3,kk,k)
8558 s1=dipderg(4,jj,j)*dip(2,kk,l)
8561 s2=0.5d0*scalar2(Ub2der(1,i),auxvec(1))
8563 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,itj1),auxvec1(1))
8564 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
8566 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,itl1),auxvec1(1))
8567 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
8569 s4=0.25d0*scalar2(vv(1),Dtobr2der(1,i))
8570 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
8571 cd write (2,*) 'turn6 derivatives'
8573 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s1+s2+s3+s4)
8575 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s2+s3+s4)
8579 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
8581 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
8585 C Derivatives in gamma(k-1)
8588 s1=dip(3,jj,i)*dipderg(2,kk,k)
8590 s1=dip(2,jj,j)*dipderg(4,kk,l)
8593 call matvec2(AECA(1,1,imat),Ub2der(1,k),auxvec1(1))
8594 s2=0.5d0*scalar2(Ub2(1,i),auxvec1(1))
8596 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,itj1),auxvec1(1))
8597 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
8599 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,itl1),auxvec1(1))
8600 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
8602 call transpose2(EUgder(1,1,k),auxmat1(1,1))
8603 call matmat2(AECA(1,1,imat),auxmat1(1,1),pizda(1,1))
8604 vv(1)=pizda(1,1)-pizda(2,2)
8605 vv(2)=pizda(2,1)+pizda(1,2)
8606 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
8607 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
8609 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s1+s2+s3+s4)
8611 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s2+s3+s4)
8615 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
8617 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
8620 C Derivatives in gamma(j-1) or gamma(l-1)
8621 if (l.eq.j+1 .and. l.gt.1) then
8622 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
8623 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
8624 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
8625 vv(1)=pizda(1,1)-pizda(2,2)
8626 vv(2)=pizda(2,1)+pizda(1,2)
8627 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
8628 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
8629 else if (j.gt.1) then
8630 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
8631 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
8632 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
8633 vv(1)=pizda(1,1)-pizda(2,2)
8634 vv(2)=pizda(2,1)+pizda(1,2)
8635 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
8636 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
8637 gel_loc_turn6(j-1)=gel_loc_turn6(j-1)-ekont*(s2+s4)
8639 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s4)
8642 C Cartesian derivatives.
8649 s1=dipderx(lll,kkk,3,jj,i)*dip(3,kk,k)
8651 s1=dipderx(lll,kkk,2,jj,j)*dip(2,kk,l)
8655 s1=dip(3,jj,i)*dipderx(lll,kkk,3,kk,k)
8657 s1=dip(2,jj,j)*dipderx(lll,kkk,2,kk,l)
8661 call matvec2(AECAderx(1,1,lll,kkk,iii,imat),Ub2(1,k),
8663 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
8665 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),
8666 & b1(1,itj1),auxvec(1))
8667 s3=-0.5d0*scalar2(b1(1,itj),auxvec(1))
8669 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),
8670 & b1(1,itl1),auxvec(1))
8671 s3=-0.5d0*scalar2(b1(1,itl),auxvec(1))
8673 call matmat2(AECAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),
8675 vv(1)=pizda(1,1)-pizda(2,2)
8676 vv(2)=pizda(2,1)+pizda(1,2)
8677 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
8679 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
8681 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii)
8684 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii)
8687 derx_turn(lll,kkk,iii)=derx_turn(lll,kkk,iii)-s3
8690 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s1+s2+s4)
8692 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s2+s4)
8694 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
8698 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
8700 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
8703 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
8705 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
8713 c----------------------------------------------------------------------------
8714 double precision function eello_turn6(i,jj,kk)
8715 implicit real*8 (a-h,o-z)
8716 include 'DIMENSIONS'
8717 include 'DIMENSIONS.ZSCOPT'
8718 include 'COMMON.IOUNITS'
8719 include 'COMMON.CHAIN'
8720 include 'COMMON.DERIV'
8721 include 'COMMON.INTERACT'
8722 include 'COMMON.CONTACTS'
8723 include 'COMMON.TORSION'
8724 include 'COMMON.VAR'
8725 include 'COMMON.GEO'
8726 double precision vtemp1(2),vtemp2(2),vtemp3(2),vtemp4(2),
8727 & atemp(2,2),auxmat(2,2),achuj_temp(2,2),gtemp(2,2),gvec(2),
8729 double precision vtemp1d(2),vtemp2d(2),vtemp3d(2),vtemp4d(2),
8730 & atempd(2,2),auxmatd(2,2),achuj_tempd(2,2),gtempd(2,2),gvecd(2)
8731 C 4/7/01 AL Components s1, s8, and s13 were removed, because they pertain to
8732 C the respective energy moment and not to the cluster cumulant.
8737 iti=itortyp(itype(i))
8738 itk=itortyp(itype(k))
8739 itk1=itortyp(itype(k+1))
8740 itl=itortyp(itype(l))
8741 itj=itortyp(itype(j))
8742 cd write (2,*) 'itk',itk,' itk1',itk1,' itl',itl,' itj',itj
8743 cd write (2,*) 'i',i,' k',k,' j',j,' l',l
8744 cd if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
8749 cd & 'EELLO6: Contacts have occurred for peptide groups',i,j,
8751 cd call checkint_turn6(i,jj,kk,eel_turn6_num)
8755 derx_turn(lll,kkk,iii)=0.0d0
8762 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
8764 cd write (2,*) 'eello6_5',eello6_5
8766 call transpose2(AEA(1,1,1),auxmat(1,1))
8767 call matmat2(EUg(1,1,i+1),auxmat(1,1),auxmat(1,1))
8768 ss1=scalar2(Ub2(1,i+2),b1(1,itl))
8769 s1 = (auxmat(1,1)+auxmat(2,2))*ss1
8773 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1(1))
8774 call matvec2(AEA(1,1,1),vtemp1(1),vtemp1(1))
8775 s2 = scalar2(b1(1,itk),vtemp1(1))
8777 call transpose2(AEA(1,1,2),atemp(1,1))
8778 call matmat2(atemp(1,1),EUg(1,1,i+4),atemp(1,1))
8779 call matvec2(Ug2(1,1,i+2),dd(1,1,itk1),vtemp2(1))
8780 s8 = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
8784 call matmat2(EUg(1,1,i+3),AEA(1,1,2),auxmat(1,1))
8785 call matvec2(auxmat(1,1),Ub2(1,i+4),vtemp3(1))
8786 s12 = scalar2(Ub2(1,i+2),vtemp3(1))
8788 call transpose2(a_chuj(1,1,kk,i+1),achuj_temp(1,1))
8789 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtemp(1,1))
8790 call matmat2(gtemp(1,1),EUg(1,1,i+3),gtemp(1,1))
8791 call matvec2(a_chuj(1,1,jj,i),Ub2(1,i+4),vtemp4(1))
8792 ss13 = scalar2(b1(1,itk),vtemp4(1))
8793 s13 = (gtemp(1,1)+gtemp(2,2))*ss13
8797 c write (2,*) 's1,s2,s8,s12,s13',s1,s2,s8,s12,s13
8803 eel_turn6 = eello6_5 - 0.5d0*(s1+s2+s12+s8+s13)
8805 C Derivatives in gamma(i+2)
8807 call transpose2(AEA(1,1,1),auxmatd(1,1))
8808 call matmat2(EUgder(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
8809 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
8810 call transpose2(AEAderg(1,1,2),atempd(1,1))
8811 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
8812 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
8816 call matmat2(EUg(1,1,i+3),AEAderg(1,1,2),auxmatd(1,1))
8817 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
8818 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
8824 gel_loc_turn6(i)=gel_loc_turn6(i)-0.5d0*ekont*(s1d+s8d+s12d)
8825 C Derivatives in gamma(i+3)
8827 call transpose2(AEA(1,1,1),auxmatd(1,1))
8828 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
8829 ss1d=scalar2(Ub2der(1,i+2),b1(1,itl))
8830 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1d
8834 call matvec2(EUgder(1,1,i+2),b1(1,itl),vtemp1d(1))
8835 call matvec2(AEA(1,1,1),vtemp1d(1),vtemp1d(1))
8836 s2d = scalar2(b1(1,itk),vtemp1d(1))
8838 call matvec2(Ug2der(1,1,i+2),dd(1,1,itk1),vtemp2d(1))
8839 s8d = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,itl),vtemp2d(1))
8841 s12d = scalar2(Ub2der(1,i+2),vtemp3(1))
8843 call matmat2(achuj_temp(1,1),EUgder(1,1,i+2),gtempd(1,1))
8844 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
8845 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
8855 gel_loc_turn6(i+1)=gel_loc_turn6(i+1)
8856 & -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
8858 gel_loc_turn6(i+1)=gel_loc_turn6(i+1)
8859 & -0.5d0*ekont*(s2d+s12d)
8861 C Derivatives in gamma(i+4)
8862 call matmat2(EUgder(1,1,i+3),AEA(1,1,2),auxmatd(1,1))
8863 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
8864 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
8866 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtempd(1,1))
8867 call matmat2(gtempd(1,1),EUgder(1,1,i+3),gtempd(1,1))
8868 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
8878 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d+s13d)
8880 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d)
8882 C Derivatives in gamma(i+5)
8884 call transpose2(AEAderg(1,1,1),auxmatd(1,1))
8885 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
8886 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
8890 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1d(1))
8891 call matvec2(AEAderg(1,1,1),vtemp1d(1),vtemp1d(1))
8892 s2d = scalar2(b1(1,itk),vtemp1d(1))
8894 call transpose2(AEA(1,1,2),atempd(1,1))
8895 call matmat2(atempd(1,1),EUgder(1,1,i+4),atempd(1,1))
8896 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
8900 call matvec2(auxmat(1,1),Ub2der(1,i+4),vtemp3d(1))
8901 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
8903 call matvec2(a_chuj(1,1,jj,i),Ub2der(1,i+4),vtemp4d(1))
8904 ss13d = scalar2(b1(1,itk),vtemp4d(1))
8905 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
8915 gel_loc_turn6(i+3)=gel_loc_turn6(i+3)
8916 & -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
8918 gel_loc_turn6(i+3)=gel_loc_turn6(i+3)
8919 & -0.5d0*ekont*(s2d+s12d)
8921 C Cartesian derivatives
8926 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmatd(1,1))
8927 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
8928 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
8932 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1(1))
8933 call matvec2(AEAderx(1,1,lll,kkk,iii,1),vtemp1(1),
8935 s2d = scalar2(b1(1,itk),vtemp1d(1))
8937 call transpose2(AEAderx(1,1,lll,kkk,iii,2),atempd(1,1))
8938 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
8939 s8d = -(atempd(1,1)+atempd(2,2))*
8940 & scalar2(cc(1,1,itl),vtemp2(1))
8944 call matmat2(EUg(1,1,i+3),AEAderx(1,1,lll,kkk,iii,2),
8946 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
8947 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
8954 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii)
8957 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii)
8961 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii)
8962 & - 0.5d0*(s8d+s12d)
8964 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii)
8973 call transpose2(a_chuj_der(1,1,lll,kkk,kk,i+1),
8975 call matmat2(achuj_tempd(1,1),EUg(1,1,i+2),gtempd(1,1))
8976 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
8977 s13d=(gtempd(1,1)+gtempd(2,2))*ss13
8978 derx_turn(lll,kkk,2) = derx_turn(lll,kkk,2)-0.5d0*s13d
8979 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),Ub2(1,i+4),
8981 ss13d = scalar2(b1(1,itk),vtemp4d(1))
8982 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
8983 derx_turn(lll,kkk,1) = derx_turn(lll,kkk,1)-0.5d0*s13d
8987 cd write(iout,*) 'eel6_turn6',eel_turn6,' eel_turn6_num',
8988 cd & 16*eel_turn6_num
8990 if (j.lt.nres-1) then
8997 if (l.lt.nres-1) then
9005 ggg1(ll)=eel_turn6*g_contij(ll,1)
9006 ggg2(ll)=eel_turn6*g_contij(ll,2)
9007 ghalf=0.5d0*ggg1(ll)
9009 gcorr6_turn(ll,i)=gcorr6_turn(ll,i)+ghalf
9010 & +ekont*derx_turn(ll,2,1)
9011 gcorr6_turn(ll,i+1)=gcorr6_turn(ll,i+1)+ekont*derx_turn(ll,3,1)
9012 gcorr6_turn(ll,j)=gcorr6_turn(ll,j)+ghalf
9013 & +ekont*derx_turn(ll,4,1)
9014 gcorr6_turn(ll,j1)=gcorr6_turn(ll,j1)+ekont*derx_turn(ll,5,1)
9015 ghalf=0.5d0*ggg2(ll)
9017 gcorr6_turn(ll,k)=gcorr6_turn(ll,k)+ghalf
9018 & +ekont*derx_turn(ll,2,2)
9019 gcorr6_turn(ll,k+1)=gcorr6_turn(ll,k+1)+ekont*derx_turn(ll,3,2)
9020 gcorr6_turn(ll,l)=gcorr6_turn(ll,l)+ghalf
9021 & +ekont*derx_turn(ll,4,2)
9022 gcorr6_turn(ll,l1)=gcorr6_turn(ll,l1)+ekont*derx_turn(ll,5,2)
9027 gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg1(ll)
9032 gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg2(ll)
9038 gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,1)
9043 gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,2)
9047 cd write (2,*) iii,g_corr6_loc(iii)
9050 eello_turn6=ekont*eel_turn6
9051 cd write (2,*) 'ekont',ekont
9052 cd write (2,*) 'eel_turn6',ekont*eel_turn6
9055 crc-------------------------------------------------
9056 SUBROUTINE MATVEC2(A1,V1,V2)
9057 implicit real*8 (a-h,o-z)
9058 include 'DIMENSIONS'
9059 DIMENSION A1(2,2),V1(2),V2(2)
9063 c 3 VI=VI+A1(I,K)*V1(K)
9067 vaux1=a1(1,1)*v1(1)+a1(1,2)*v1(2)
9068 vaux2=a1(2,1)*v1(1)+a1(2,2)*v1(2)
9073 C---------------------------------------
9074 SUBROUTINE MATMAT2(A1,A2,A3)
9075 implicit real*8 (a-h,o-z)
9076 include 'DIMENSIONS'
9077 DIMENSION A1(2,2),A2(2,2),A3(2,2)
9078 c DIMENSION AI3(2,2)
9082 c A3IJ=A3IJ+A1(I,K)*A2(K,J)
9088 ai3_11=a1(1,1)*a2(1,1)+a1(1,2)*a2(2,1)
9089 ai3_12=a1(1,1)*a2(1,2)+a1(1,2)*a2(2,2)
9090 ai3_21=a1(2,1)*a2(1,1)+a1(2,2)*a2(2,1)
9091 ai3_22=a1(2,1)*a2(1,2)+a1(2,2)*a2(2,2)
9099 c-------------------------------------------------------------------------
9100 double precision function scalar2(u,v)
9102 double precision u(2),v(2)
9105 scalar2=u(1)*v(1)+u(2)*v(2)
9109 C-----------------------------------------------------------------------------
9111 subroutine transpose2(a,at)
9113 double precision a(2,2),at(2,2)
9120 c--------------------------------------------------------------------------
9121 subroutine transpose(n,a,at)
9124 double precision a(n,n),at(n,n)
9132 C---------------------------------------------------------------------------
9133 subroutine prodmat3(a1,a2,kk,transp,prod)
9136 double precision a1(2,2),a2(2,2),a2t(2,2),kk(2,2),prod(2,2)
9138 crc double precision auxmat(2,2),prod_(2,2)
9141 crc call transpose2(kk(1,1),auxmat(1,1))
9142 crc call matmat2(a1(1,1),auxmat(1,1),auxmat(1,1))
9143 crc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
9145 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,1)
9146 & +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,1)
9147 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,2)
9148 & +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,2)
9149 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,1)
9150 & +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,1)
9151 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,2)
9152 & +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,2)
9155 crc call matmat2(a1(1,1),kk(1,1),auxmat(1,1))
9156 crc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
9158 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,1)
9159 & +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,1)
9160 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,2)
9161 & +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,2)
9162 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,1)
9163 & +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,1)
9164 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,2)
9165 & +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,2)
9168 c call transpose2(a2(1,1),a2t(1,1))
9171 crc print *,((prod_(i,j),i=1,2),j=1,2)
9172 crc print *,((prod(i,j),i=1,2),j=1,2)
9176 C-----------------------------------------------------------------------------
9177 double precision function scalar(u,v)
9179 double precision u(3),v(3)