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) 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)
48 C Calculate electrostatic (H-bonding) energy of the main chain.
50 106 call eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
52 C Calculate excluded-volume interaction energy between peptide groups
55 call escp(evdw2,evdw2_14)
57 c Calculate the bond-stretching energy
60 c write (iout,*) "estr",estr
62 C Calculate the disulfide-bridge and other energy and the contributions
63 C from other distance constraints.
64 cd print *,'Calling EHPB'
66 cd print *,'EHPB exitted succesfully.'
68 C Calculate the virtual-bond-angle energy.
71 cd print *,'Bend energy finished.'
73 C Calculate the SC local energy.
76 cd print *,'SCLOC energy finished.'
78 C Calculate the virtual-bond torsional energy.
80 cd print *,'nterm=',nterm
81 call etor(etors,edihcnstr,fact(1))
83 C 6/23/01 Calculate double-torsional energy
85 call etor_d(etors_d,fact(2))
87 C 21/5/07 Calculate local sicdechain correlation energy
89 call eback_sc_corr(esccor)
91 C 12/1/95 Multi-body terms
95 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0
96 & .or. wturn6.gt.0.0d0) then
97 c print *,"calling multibody_eello"
98 call multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
99 c write (*,*) 'n_corr=',n_corr,' n_corr1=',n_corr1
100 c print *,ecorr,ecorr5,ecorr6,eturn6
102 if (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) then
103 call multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
105 c write (iout,*) "ft(6)",fact(6)," evdw",evdw," evdw_t",evdw_t
107 etot=wsc*(evdw+fact(6)*evdw_t)+wscp*evdw2+welec*fact(1)*ees
109 & +wang*ebe+wtor*fact(1)*etors+wscloc*escloc
110 & +wstrain*ehpb+nss*ebr+wcorr*fact(3)*ecorr+wcorr5*fact(4)*ecorr5
111 & +wcorr6*fact(5)*ecorr6+wturn4*fact(3)*eello_turn4
112 & +wturn3*fact(2)*eello_turn3+wturn6*fact(5)*eturn6
113 & +wel_loc*fact(2)*eel_loc+edihcnstr+wtor_d*fact(2)*etors_d
114 & +wbond*estr+wsccor*fact(1)*esccor
116 etot=wsc*(evdw+fact(6)*evdw_t)+wscp*evdw2
117 & +welec*fact(1)*(ees+evdw1)
118 & +wang*ebe+wtor*fact(1)*etors+wscloc*escloc
119 & +wstrain*ehpb+nss*ebr+wcorr*fact(3)*ecorr+wcorr5*fact(4)*ecorr5
120 & +wcorr6*fact(5)*ecorr6+wturn4*fact(3)*eello_turn4
121 & +wturn3*fact(2)*eello_turn3+wturn6*fact(5)*eturn6
122 & +wel_loc*fact(2)*eel_loc+edihcnstr+wtor_d*fact(2)*etors_d
123 & +wbond*estr+wsccor*fact(1)*esccor
128 energia(2)=evdw2-evdw2_14
145 energia(8)=eello_turn3
146 energia(9)=eello_turn4
155 energia(20)=edihcnstr
160 if (isnan(etot).ne.0) energia(0)=1.0d+99
162 if (isnan(etot)) energia(0)=1.0d+99
167 idumm=proc_proc(etot,i)
169 call proc_proc(etot,i)
171 if(i.eq.1)energia(0)=1.0d+99
178 C Sum up the components of the Cartesian gradient.
183 gradc(j,i,icg)=wsc*gvdwc(j,i)+wscp*gvdwc_scp(j,i)+
184 & welec*fact(1)*gelc(j,i)+wvdwpp*gvdwpp(j,i)+
186 & wstrain*ghpbc(j,i)+
187 & wcorr*fact(3)*gradcorr(j,i)+
188 & wel_loc*fact(2)*gel_loc(j,i)+
189 & wturn3*fact(2)*gcorr3_turn(j,i)+
190 & wturn4*fact(3)*gcorr4_turn(j,i)+
191 & wcorr5*fact(4)*gradcorr5(j,i)+
192 & wcorr6*fact(5)*gradcorr6(j,i)+
193 & wturn6*fact(5)*gcorr6_turn(j,i)+
194 & wsccor*fact(2)*gsccorc(j,i)
195 gradx(j,i,icg)=wsc*gvdwx(j,i)+wscp*gradx_scp(j,i)+
197 & wstrain*ghpbx(j,i)+wcorr*gradxorr(j,i)+
198 & wsccor*fact(2)*gsccorx(j,i)
203 gradc(j,i,icg)=wsc*gvdwc(j,i)+wscp*gvdwc_scp(j,i)+
204 & welec*fact(1)*gelc(j,i)+wstrain*ghpbc(j,i)+
206 & wcorr*fact(3)*gradcorr(j,i)+
207 & wel_loc*fact(2)*gel_loc(j,i)+
208 & wturn3*fact(2)*gcorr3_turn(j,i)+
209 & wturn4*fact(3)*gcorr4_turn(j,i)+
210 & wcorr5*fact(4)*gradcorr5(j,i)+
211 & wcorr6*fact(5)*gradcorr6(j,i)+
212 & wturn6*fact(5)*gcorr6_turn(j,i)+
213 & wsccor*fact(2)*gsccorc(j,i)
214 gradx(j,i,icg)=wsc*gvdwx(j,i)+wscp*gradx_scp(j,i)+
216 & wstrain*ghpbx(j,i)+wcorr*gradxorr(j,i)+
217 & wsccor*fact(1)*gsccorx(j,i)
224 gloc(i,icg)=gloc(i,icg)+wcorr*fact(3)*gcorr_loc(i)
225 & +wcorr5*fact(4)*g_corr5_loc(i)
226 & +wcorr6*fact(5)*g_corr6_loc(i)
227 & +wturn4*fact(3)*gel_loc_turn4(i)
228 & +wturn3*fact(2)*gel_loc_turn3(i)
229 & +wturn6*fact(5)*gel_loc_turn6(i)
230 & +wel_loc*fact(2)*gel_loc_loc(i)
231 c & +wsccor*fact(1)*gsccor_loc(i)
236 C------------------------------------------------------------------------
237 subroutine enerprint(energia,fact)
238 implicit real*8 (a-h,o-z)
240 include 'DIMENSIONS.ZSCOPT'
241 include 'COMMON.IOUNITS'
242 include 'COMMON.FFIELD'
243 include 'COMMON.SBRIDGE'
244 double precision energia(0:max_ene),fact(6)
246 evdw=energia(1)+fact(6)*energia(21)
248 evdw2=energia(2)+energia(17)
260 eello_turn3=energia(8)
261 eello_turn4=energia(9)
262 eello_turn6=energia(10)
269 edihcnstr=energia(20)
272 write (iout,10) evdw,wsc,evdw2,wscp,ees,welec*fact(1),evdw1,
274 & estr,wbond,ebe,wang,escloc,wscloc,etors,wtor*fact(1),
275 & etors_d,wtor_d*fact(2),ehpb,wstrain,
276 & ecorr,wcorr*fact(3),ecorr5,wcorr5*fact(4),ecorr6,wcorr6*fact(5),
277 & eel_loc,wel_loc*fact(2),eello_turn3,wturn3*fact(2),
278 & eello_turn4,wturn4*fact(3),eello_turn6,wturn6*fact(5),
279 & esccor,wsccor*fact(1),edihcnstr,ebr*nss,etot
280 10 format (/'Virtual-chain energies:'//
281 & 'EVDW= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-SC)'/
282 & 'EVDW2= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-p)'/
283 & 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p elec)'/
284 & 'EVDWPP=',1pE16.6,' WEIGHT=',1pD16.6,' (p-p VDW)'/
285 & 'ESTR= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching)'/
286 & 'EBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (bending)'/
287 & 'ESC= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/
288 & 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/
289 & 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/
290 & 'EHBP= ',1pE16.6,' WEIGHT=',1pD16.6,
291 & ' (SS bridges & dist. cnstr.)'/
292 & 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
293 & 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
294 & 'ECORR6=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
295 & 'EELLO= ',1pE16.6,' WEIGHT=',1pD16.6,' (electrostatic-local)'/
296 & 'ETURN3=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 3rd order)'/
297 & 'ETURN4=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 4th order)'/
298 & 'ETURN6=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 6th order)'/
299 & 'ESCCOR=',1pE16.6,' WEIGHT=',1pD16.6,' (backbone-rotamer corr)'/
300 & 'EDIHC= ',1pE16.6,' (dihedral angle constraints)'/
301 & 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/
302 & 'ETOT= ',1pE16.6,' (total)')
304 write (iout,10) evdw,wsc,evdw2,wscp,ees,welec*fact(1),estr,wbond,
305 & ebe,wang,escloc,wscloc,etors,wtor*fact(1),etors_d,wtor_d*fact2,
306 & ehpb,wstrain,ecorr,wcorr*fact(3),ecorr5,wcorr5*fact(4),
307 & ecorr6,wcorr6*fact(5),eel_loc,wel_loc*fact(2),
308 & eello_turn3,wturn3*fact(2),eello_turn4,wturn4*fact(3),
309 & eello_turn6,wturn6*fact(5),esccor*fact(1),wsccor,
310 & edihcnstr,ebr*nss,etot
311 10 format (/'Virtual-chain energies:'//
312 & 'EVDW= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-SC)'/
313 & 'EVDW2= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-p)'/
314 & 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p)'/
315 & 'ESTR= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching)'/
316 & 'EBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (bending)'/
317 & 'ESC= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/
318 & 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/
319 & 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/
320 & 'EHBP= ',1pE16.6,' WEIGHT=',1pD16.6,
321 & ' (SS bridges & dist. cnstr.)'/
322 & 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
323 & 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
324 & 'ECORR6=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
325 & 'EELLO= ',1pE16.6,' WEIGHT=',1pD16.6,' (electrostatic-local)'/
326 & 'ETURN3=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 3rd order)'/
327 & 'ETURN4=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 4th order)'/
328 & 'ETURN6=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 6th order)'/
329 & 'ESCCOR=',1pE16.6,' WEIGHT=',1pD16.6,' (backbone-rotamer corr)'/
330 & 'EDIHC= ',1pE16.6,' (dihedral angle constraints)'/
331 & 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/
332 & 'ETOT= ',1pE16.6,' (total)')
336 C-----------------------------------------------------------------------
337 subroutine elj(evdw,evdw_t)
339 C This subroutine calculates the interaction energy of nonbonded side chains
340 C assuming the LJ potential of interaction.
342 implicit real*8 (a-h,o-z)
344 include 'DIMENSIONS.ZSCOPT'
345 include "DIMENSIONS.COMPAR"
346 parameter (accur=1.0d-10)
349 include 'COMMON.LOCAL'
350 include 'COMMON.CHAIN'
351 include 'COMMON.DERIV'
352 include 'COMMON.INTERACT'
353 include 'COMMON.TORSION'
354 include 'COMMON.ENEPS'
355 include 'COMMON.SBRIDGE'
356 include 'COMMON.NAMES'
357 include 'COMMON.IOUNITS'
358 include 'COMMON.CONTACTS'
362 cd print *,'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
365 eneps_temp(j,i)=0.0d0
372 if (itypi.eq.ntyp1) cycle
373 itypi1=iabs(itype(i+1))
380 C Calculate SC interaction energy.
383 cd write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
384 cd & 'iend=',iend(i,iint)
385 do j=istart(i,iint),iend(i,iint)
387 if (itypj.eq.ntyp1) cycle
391 C Change 12/1/95 to calculate four-body interactions
392 rij=xj*xj+yj*yj+zj*zj
394 c write (iout,*)'i=',i,' j=',j,' itypi=',itypi,' itypj=',itypj
395 eps0ij=eps(itypi,itypj)
397 e1=fac*fac*aa(itypi,itypj)
398 e2=fac*bb(itypi,itypj)
400 ij=icant(itypi,itypj)
401 eneps_temp(1,ij)=eneps_temp(1,ij)+e1/dabs(eps0ij)
402 eneps_temp(2,ij)=eneps_temp(2,ij)+e2/eps0ij
403 cd sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
404 cd epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
405 cd write (iout,'(2(a3,i3,2x),6(1pd12.4)/2(3(1pd12.4),5x)/)')
406 cd & restyp(itypi),i,restyp(itypj),j,aa(itypi,itypj),
407 cd & bb(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,epsi,sigm,
408 cd & (c(k,i),k=1,3),(c(k,j),k=1,3)
409 if (bb(itypi,itypj).gt.0.0d0) then
416 C Calculate the components of the gradient in DC and X
418 fac=-rrij*(e1+evdwij)
423 gvdwx(k,i)=gvdwx(k,i)-gg(k)
424 gvdwx(k,j)=gvdwx(k,j)+gg(k)
428 gvdwc(l,k)=gvdwc(l,k)+gg(l)
433 C 12/1/95, revised on 5/20/97
435 C Calculate the contact function. The ith column of the array JCONT will
436 C contain the numbers of atoms that make contacts with the atom I (of numbers
437 C greater than I). The arrays FACONT and GACONT will contain the values of
438 C the contact function and its derivative.
440 C Uncomment next line, if the correlation interactions include EVDW explicitly.
441 c if (j.gt.i+1 .and. evdwij.le.0.0D0) then
442 C Uncomment next line, if the correlation interactions are contact function only
443 if (j.gt.i+1.and. eps0ij.gt.0.0D0) then
445 sigij=sigma(itypi,itypj)
446 r0ij=rs0(itypi,itypj)
448 C Check whether the SC's are not too far to make a contact.
451 call gcont(rij,rcut,1.0d0,0.2d0*rcut,fcont,fprimcont)
452 C Add a new contact, if the SC's are close enough, but not too close (r<sigma).
454 if (fcont.gt.0.0D0) then
455 C If the SC-SC distance if close to sigma, apply spline.
456 cAdam call gcont(-rij,-1.03d0*sigij,2.0d0*sigij,1.0d0,
457 cAdam & fcont1,fprimcont1)
458 cAdam fcont1=1.0d0-fcont1
459 cAdam if (fcont1.gt.0.0d0) then
460 cAdam fprimcont=fprimcont*fcont1+fcont*fprimcont1
461 cAdam fcont=fcont*fcont1
463 C Uncomment following 4 lines to have the geometric average of the epsilon0's
464 cga eps0ij=1.0d0/dsqrt(eps0ij)
466 cga gg(k)=gg(k)*eps0ij
468 cga eps0ij=-evdwij*eps0ij
469 C Uncomment for AL's type of SC correlation interactions.
471 num_conti=num_conti+1
473 facont(num_conti,i)=fcont*eps0ij
474 fprimcont=eps0ij*fprimcont/rij
476 cAdam gacont(1,num_conti,i)=-fprimcont*xj+fcont*gg(1)
477 cAdam gacont(2,num_conti,i)=-fprimcont*yj+fcont*gg(2)
478 cAdam gacont(3,num_conti,i)=-fprimcont*zj+fcont*gg(3)
479 C Uncomment following 3 lines for Skolnick's type of SC correlation.
480 gacont(1,num_conti,i)=-fprimcont*xj
481 gacont(2,num_conti,i)=-fprimcont*yj
482 gacont(3,num_conti,i)=-fprimcont*zj
483 cd write (iout,'(2i5,2f10.5)') i,j,rij,facont(num_conti,i)
484 cd write (iout,'(2i3,3f10.5)')
485 cd & i,j,(gacont(kk,num_conti,i),kk=1,3)
491 num_cont(i)=num_conti
496 gvdwc(j,i)=expon*gvdwc(j,i)
497 gvdwx(j,i)=expon*gvdwx(j,i)
501 C******************************************************************************
505 C To save time, the factor of EXPON has been extracted from ALL components
506 C of GVDWC and GRADX. Remember to multiply them by this factor before further
509 C******************************************************************************
512 C-----------------------------------------------------------------------------
513 subroutine eljk(evdw,evdw_t)
515 C This subroutine calculates the interaction energy of nonbonded side chains
516 C assuming the LJK potential of interaction.
518 implicit real*8 (a-h,o-z)
520 include 'DIMENSIONS.ZSCOPT'
521 include "DIMENSIONS.COMPAR"
524 include 'COMMON.LOCAL'
525 include 'COMMON.CHAIN'
526 include 'COMMON.DERIV'
527 include 'COMMON.INTERACT'
528 include 'COMMON.ENEPS'
529 include 'COMMON.IOUNITS'
530 include 'COMMON.NAMES'
535 c print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
538 eneps_temp(j,i)=0.0d0
545 if (itypi.eq.ntyp1) cycle
546 itypi1=iabs(itype(i+1))
551 C Calculate SC interaction energy.
554 do j=istart(i,iint),iend(i,iint)
556 if (itypj.eq.ntyp1) cycle
560 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
562 e_augm=augm(itypi,itypj)*fac_augm
565 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
566 fac=r_shift_inv**expon
567 e1=fac*fac*aa(itypi,itypj)
568 e2=fac*bb(itypi,itypj)
570 ij=icant(itypi,itypj)
571 eneps_temp(1,ij)=eneps_temp(1,ij)+(e1+a_augm)
572 & /dabs(eps(itypi,itypj))
573 eneps_temp(2,ij)=eneps_temp(2,ij)+e2/eps(itypi,itypj)
574 cd sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
575 cd epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
576 cd write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
577 cd & restyp(itypi),i,restyp(itypj),j,aa(itypi,itypj),
578 cd & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
579 cd & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
580 cd & (c(k,i),k=1,3),(c(k,j),k=1,3)
581 if (bb(itypi,itypj).gt.0.0d0) then
588 C Calculate the components of the gradient in DC and X
590 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
595 gvdwx(k,i)=gvdwx(k,i)-gg(k)
596 gvdwx(k,j)=gvdwx(k,j)+gg(k)
600 gvdwc(l,k)=gvdwc(l,k)+gg(l)
610 gvdwc(j,i)=expon*gvdwc(j,i)
611 gvdwx(j,i)=expon*gvdwx(j,i)
617 C-----------------------------------------------------------------------------
618 subroutine ebp(evdw,evdw_t)
620 C This subroutine calculates the interaction energy of nonbonded side chains
621 C assuming the Berne-Pechukas potential of interaction.
623 implicit real*8 (a-h,o-z)
625 include 'DIMENSIONS.ZSCOPT'
626 include "DIMENSIONS.COMPAR"
629 include 'COMMON.LOCAL'
630 include 'COMMON.CHAIN'
631 include 'COMMON.DERIV'
632 include 'COMMON.NAMES'
633 include 'COMMON.INTERACT'
634 include 'COMMON.ENEPS'
635 include 'COMMON.IOUNITS'
636 include 'COMMON.CALC'
638 c double precision rrsave(maxdim)
644 eneps_temp(j,i)=0.0d0
649 c print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
650 c if (icall.eq.0) then
658 itypi1=iabs(itype(i+1))
662 dxi=dc_norm(1,nres+i)
663 dyi=dc_norm(2,nres+i)
664 dzi=dc_norm(3,nres+i)
665 dsci_inv=vbld_inv(i+nres)
667 C Calculate SC interaction energy.
670 do j=istart(i,iint),iend(i,iint)
673 dscj_inv=vbld_inv(j+nres)
674 chi1=chi(itypi,itypj)
675 chi2=chi(itypj,itypi)
682 alf12=0.5D0*(alf1+alf2)
683 C For diagnostics only!!!
696 dxj=dc_norm(1,nres+j)
697 dyj=dc_norm(2,nres+j)
698 dzj=dc_norm(3,nres+j)
699 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
700 cd if (icall.eq.0) then
706 C Calculate the angle-dependent terms of energy & contributions to derivatives.
708 C Calculate whole angle-dependent part of epsilon and contributions
710 fac=(rrij*sigsq)**expon2
711 e1=fac*fac*aa(itypi,itypj)
712 e2=fac*bb(itypi,itypj)
713 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
714 eps2der=evdwij*eps3rt
715 eps3der=evdwij*eps2rt
716 evdwij=evdwij*eps2rt*eps3rt
717 ij=icant(itypi,itypj)
718 aux=eps1*eps2rt**2*eps3rt**2
719 eneps_temp(1,ij)=eneps_temp(1,ij)+e1*aux
720 & /dabs(eps(itypi,itypj))
721 eneps_temp(2,ij)=eneps_temp(2,ij)+e2*aux/eps(itypi,itypj)
722 if (bb(itypi,itypj).gt.0.0d0) then
729 sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
730 epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
731 cd write (iout,'(2(a3,i3,2x),15(0pf7.3))')
732 cd & restyp(itypi),i,restyp(itypj),j,
733 cd & epsi,sigm,chi1,chi2,chip1,chip2,
734 cd & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
735 cd & om1,om2,om12,1.0D0/dsqrt(rrij),
738 C Calculate gradient components.
739 e1=e1*eps1*eps2rt**2*eps3rt**2
740 fac=-expon*(e1+evdwij)
743 C Calculate radial part of the gradient
747 C Calculate the angular part of the gradient and sum add the contributions
748 C to the appropriate components of the Cartesian gradient.
757 C-----------------------------------------------------------------------------
758 subroutine egb(evdw,evdw_t)
760 C This subroutine calculates the interaction energy of nonbonded side chains
761 C assuming the Gay-Berne potential of interaction.
763 implicit real*8 (a-h,o-z)
765 include 'DIMENSIONS.ZSCOPT'
766 include "DIMENSIONS.COMPAR"
769 include 'COMMON.LOCAL'
770 include 'COMMON.CHAIN'
771 include 'COMMON.DERIV'
772 include 'COMMON.NAMES'
773 include 'COMMON.INTERACT'
774 include 'COMMON.ENEPS'
775 include 'COMMON.IOUNITS'
776 include 'COMMON.CALC'
783 eneps_temp(j,i)=0.0d0
786 c print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
790 c if (icall.gt.0) lprn=.true.
794 itypi1=iabs(itype(i+1))
798 dxi=dc_norm(1,nres+i)
799 dyi=dc_norm(2,nres+i)
800 dzi=dc_norm(3,nres+i)
801 dsci_inv=vbld_inv(i+nres)
803 C Calculate SC interaction energy.
806 do j=istart(i,iint),iend(i,iint)
809 dscj_inv=vbld_inv(j+nres)
810 sig0ij=sigma(itypi,itypj)
811 chi1=chi(itypi,itypj)
812 chi2=chi(itypj,itypi)
819 alf12=0.5D0*(alf1+alf2)
820 C For diagnostics only!!!
833 dxj=dc_norm(1,nres+j)
834 dyj=dc_norm(2,nres+j)
835 dzj=dc_norm(3,nres+j)
836 c write (iout,*) i,j,xj,yj,zj
837 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
839 C Calculate angle-dependent terms of energy and contributions to their
843 sig=sig0ij*dsqrt(sigsq)
844 rij_shift=1.0D0/rij-sig+sig0ij
845 C I hate to put IF's in the loops, but here don't have another choice!!!!
846 if (rij_shift.le.0.0D0) then
851 c---------------------------------------------------------------
852 rij_shift=1.0D0/rij_shift
854 e1=fac*fac*aa(itypi,itypj)
855 e2=fac*bb(itypi,itypj)
856 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
857 eps2der=evdwij*eps3rt
858 eps3der=evdwij*eps2rt
859 evdwij=evdwij*eps2rt*eps3rt
860 if (bb(itypi,itypj).gt.0) then
865 ij=icant(itypi,itypj)
866 aux=eps1*eps2rt**2*eps3rt**2
867 eneps_temp(1,ij)=eneps_temp(1,ij)+aux*e1
868 & /dabs(eps(itypi,itypj))
869 eneps_temp(2,ij)=eneps_temp(2,ij)+aux*e2/eps(itypi,itypj)
870 c write (iout,*) "i",i," j",j," itypi",itypi," itypj",itypj,
871 c & " ij",ij," eneps",aux*e1/dabs(eps(itypi,itypj)),
872 c & aux*e2/eps(itypi,itypj)
874 sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
875 epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
876 write (iout,'(2(a3,i3,2x),17(0pf7.3))')
877 & restyp(itypi),i,restyp(itypj),j,
878 & epsi,sigm,chi1,chi2,chip1,chip2,
879 & eps1,eps2rt**2,eps3rt**2,sig,sig0ij,
880 & om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,
884 C Calculate gradient components.
885 e1=e1*eps1*eps2rt**2*eps3rt**2
886 fac=-expon*(e1+evdwij)*rij_shift
889 C Calculate the radial part of the gradient
893 C Calculate angular part of the gradient.
901 C-----------------------------------------------------------------------------
902 subroutine egbv(evdw,evdw_t)
904 C This subroutine calculates the interaction energy of nonbonded side chains
905 C assuming the Gay-Berne-Vorobjev potential of interaction.
907 implicit real*8 (a-h,o-z)
909 include 'DIMENSIONS.ZSCOPT'
910 include "DIMENSIONS.COMPAR"
913 include 'COMMON.LOCAL'
914 include 'COMMON.CHAIN'
915 include 'COMMON.DERIV'
916 include 'COMMON.NAMES'
917 include 'COMMON.INTERACT'
918 include 'COMMON.ENEPS'
919 include 'COMMON.IOUNITS'
920 include 'COMMON.CALC'
927 eneps_temp(j,i)=0.0d0
932 c print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
935 c if (icall.gt.0) lprn=.true.
939 itypi1=iabs(itype(i+1))
943 dxi=dc_norm(1,nres+i)
944 dyi=dc_norm(2,nres+i)
945 dzi=dc_norm(3,nres+i)
946 dsci_inv=vbld_inv(i+nres)
948 C Calculate SC interaction energy.
951 do j=istart(i,iint),iend(i,iint)
954 dscj_inv=vbld_inv(j+nres)
955 sig0ij=sigma(itypi,itypj)
957 chi1=chi(itypi,itypj)
958 chi2=chi(itypj,itypi)
965 alf12=0.5D0*(alf1+alf2)
966 C For diagnostics only!!!
979 dxj=dc_norm(1,nres+j)
980 dyj=dc_norm(2,nres+j)
981 dzj=dc_norm(3,nres+j)
982 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
984 C Calculate angle-dependent terms of energy and contributions to their
988 sig=sig0ij*dsqrt(sigsq)
989 rij_shift=1.0D0/rij-sig+r0ij
990 C I hate to put IF's in the loops, but here don't have another choice!!!!
991 if (rij_shift.le.0.0D0) then
996 c---------------------------------------------------------------
997 rij_shift=1.0D0/rij_shift
999 e1=fac*fac*aa(itypi,itypj)
1000 e2=fac*bb(itypi,itypj)
1001 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
1002 eps2der=evdwij*eps3rt
1003 eps3der=evdwij*eps2rt
1004 fac_augm=rrij**expon
1005 e_augm=augm(itypi,itypj)*fac_augm
1006 evdwij=evdwij*eps2rt*eps3rt
1007 if (bb(itypi,itypj).gt.0.0d0) then
1008 evdw=evdw+evdwij+e_augm
1010 evdw_t=evdw_t+evdwij+e_augm
1012 ij=icant(itypi,itypj)
1013 aux=eps1*eps2rt**2*eps3rt**2
1014 eneps_temp(1,ij)=eneps_temp(1,ij)+aux*(e1+e_augm)
1015 & /dabs(eps(itypi,itypj))
1016 eneps_temp(2,ij)=eneps_temp(2,ij)+aux*e2/eps(itypi,itypj)
1017 c eneps_temp(ij)=eneps_temp(ij)
1018 c & +(evdwij+e_augm)/eps(itypi,itypj)
1020 c sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1021 c epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1022 c write (iout,'(2(a3,i3,2x),17(0pf7.3))')
1023 c & restyp(itypi),i,restyp(itypj),j,
1024 c & epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),
1025 c & chi1,chi2,chip1,chip2,
1026 c & eps1,eps2rt**2,eps3rt**2,
1027 c & om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,
1031 C Calculate gradient components.
1032 e1=e1*eps1*eps2rt**2*eps3rt**2
1033 fac=-expon*(e1+evdwij)*rij_shift
1035 fac=rij*fac-2*expon*rrij*e_augm
1036 C Calculate the radial part of the gradient
1040 C Calculate angular part of the gradient.
1048 C-----------------------------------------------------------------------------
1049 subroutine sc_angular
1050 C Calculate eps1,eps2,eps3,sigma, and parts of their derivatives in om1,om2,
1051 C om12. Called by ebp, egb, and egbv.
1053 include 'COMMON.CALC'
1057 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
1058 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
1059 om12=dxi*dxj+dyi*dyj+dzi*dzj
1061 C Calculate eps1(om12) and its derivative in om12
1062 faceps1=1.0D0-om12*chiom12
1063 faceps1_inv=1.0D0/faceps1
1064 eps1=dsqrt(faceps1_inv)
1065 C Following variable is eps1*deps1/dom12
1066 eps1_om12=faceps1_inv*chiom12
1067 C Calculate sigma(om1,om2,om12) and the derivatives of sigma**2 in om1,om2,
1072 facsig=om1*chiom1+om2*chiom2-2.0D0*om1om2*chiom12
1073 sigsq=1.0D0-facsig*faceps1_inv
1074 sigsq_om1=(chiom1-chiom12*om2)*faceps1_inv
1075 sigsq_om2=(chiom2-chiom12*om1)*faceps1_inv
1076 sigsq_om12=-chi12*(om1om2*faceps1-om12*facsig)*faceps1_inv**2
1077 C Calculate eps2 and its derivatives in om1, om2, and om12.
1080 chipom12=chip12*om12
1081 facp=1.0D0-om12*chipom12
1083 facp1=om1*chipom1+om2*chipom2-2.0D0*om1om2*chipom12
1084 C Following variable is the square root of eps2
1085 eps2rt=1.0D0-facp1*facp_inv
1086 C Following three variables are the derivatives of the square root of eps
1087 C in om1, om2, and om12.
1088 eps2rt_om1=-4.0D0*(chipom1-chipom12*om2)*facp_inv
1089 eps2rt_om2=-4.0D0*(chipom2-chipom12*om1)*facp_inv
1090 eps2rt_om12=4.0D0*chip12*(om1om2*facp-om12*facp1)*facp_inv**2
1091 C Evaluate the "asymmetric" factor in the VDW constant, eps3
1092 eps3rt=1.0D0-alf1*om1+alf2*om2-alf12*om12
1093 C Calculate whole angle-dependent part of epsilon and contributions
1094 C to its derivatives
1097 C----------------------------------------------------------------------------
1099 implicit real*8 (a-h,o-z)
1100 include 'DIMENSIONS'
1101 include 'DIMENSIONS.ZSCOPT'
1102 include 'COMMON.CHAIN'
1103 include 'COMMON.DERIV'
1104 include 'COMMON.CALC'
1105 double precision dcosom1(3),dcosom2(3)
1106 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
1107 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
1108 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12
1109 & -2.0D0*alf12*eps3der+sigder*sigsq_om12
1111 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
1112 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
1115 gg(k)=gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
1118 gvdwx(k,i)=gvdwx(k,i)-gg(k)
1119 & +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))
1120 & +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
1121 gvdwx(k,j)=gvdwx(k,j)+gg(k)
1122 & +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))
1123 & +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
1126 C Calculate the components of the gradient in DC and X
1130 gvdwc(l,k)=gvdwc(l,k)+gg(l)
1135 c------------------------------------------------------------------------------
1136 subroutine vec_and_deriv
1137 implicit real*8 (a-h,o-z)
1138 include 'DIMENSIONS'
1139 include 'DIMENSIONS.ZSCOPT'
1140 include 'COMMON.IOUNITS'
1141 include 'COMMON.GEO'
1142 include 'COMMON.VAR'
1143 include 'COMMON.LOCAL'
1144 include 'COMMON.CHAIN'
1145 include 'COMMON.VECTORS'
1146 include 'COMMON.DERIV'
1147 include 'COMMON.INTERACT'
1148 dimension uyder(3,3,2),uzder(3,3,2),vbld_inv_temp(2)
1149 C Compute the local reference systems. For reference system (i), the
1150 C X-axis points from CA(i) to CA(i+1), the Y axis is in the
1151 C CA(i)-CA(i+1)-CA(i+2) plane, and the Z axis is perpendicular to this plane.
1153 c if (i.eq.nres-1 .or. itel(i+1).eq.0) then
1154 if (i.eq.nres-1) then
1155 C Case of the last full residue
1156 C Compute the Z-axis
1157 call vecpr(dc_norm(1,i),dc_norm(1,i-1),uz(1,i))
1158 costh=dcos(pi-theta(nres))
1159 fac=1.0d0/dsqrt(1.0d0-costh*costh)
1164 C Compute the derivatives of uz
1166 uzder(2,1,1)=-dc_norm(3,i-1)
1167 uzder(3,1,1)= dc_norm(2,i-1)
1168 uzder(1,2,1)= dc_norm(3,i-1)
1170 uzder(3,2,1)=-dc_norm(1,i-1)
1171 uzder(1,3,1)=-dc_norm(2,i-1)
1172 uzder(2,3,1)= dc_norm(1,i-1)
1175 uzder(2,1,2)= dc_norm(3,i)
1176 uzder(3,1,2)=-dc_norm(2,i)
1177 uzder(1,2,2)=-dc_norm(3,i)
1179 uzder(3,2,2)= dc_norm(1,i)
1180 uzder(1,3,2)= dc_norm(2,i)
1181 uzder(2,3,2)=-dc_norm(1,i)
1184 C Compute the Y-axis
1187 uy(k,i)=fac*(dc_norm(k,i-1)-costh*dc_norm(k,i))
1190 C Compute the derivatives of uy
1193 uyder(k,j,1)=2*dc_norm(k,i-1)*dc_norm(j,i)
1194 & -dc_norm(k,i)*dc_norm(j,i-1)
1195 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
1197 uyder(j,j,1)=uyder(j,j,1)-costh
1198 uyder(j,j,2)=1.0d0+uyder(j,j,2)
1203 uygrad(l,k,j,i)=uyder(l,k,j)
1204 uzgrad(l,k,j,i)=uzder(l,k,j)
1208 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
1209 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
1210 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
1211 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
1215 C Compute the Z-axis
1216 call vecpr(dc_norm(1,i),dc_norm(1,i+1),uz(1,i))
1217 costh=dcos(pi-theta(i+2))
1218 fac=1.0d0/dsqrt(1.0d0-costh*costh)
1223 C Compute the derivatives of uz
1225 uzder(2,1,1)=-dc_norm(3,i+1)
1226 uzder(3,1,1)= dc_norm(2,i+1)
1227 uzder(1,2,1)= dc_norm(3,i+1)
1229 uzder(3,2,1)=-dc_norm(1,i+1)
1230 uzder(1,3,1)=-dc_norm(2,i+1)
1231 uzder(2,3,1)= dc_norm(1,i+1)
1234 uzder(2,1,2)= dc_norm(3,i)
1235 uzder(3,1,2)=-dc_norm(2,i)
1236 uzder(1,2,2)=-dc_norm(3,i)
1238 uzder(3,2,2)= dc_norm(1,i)
1239 uzder(1,3,2)= dc_norm(2,i)
1240 uzder(2,3,2)=-dc_norm(1,i)
1243 C Compute the Y-axis
1246 uy(k,i)=facy*(dc_norm(k,i+1)-costh*dc_norm(k,i))
1249 C Compute the derivatives of uy
1252 uyder(k,j,1)=2*dc_norm(k,i+1)*dc_norm(j,i)
1253 & -dc_norm(k,i)*dc_norm(j,i+1)
1254 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
1256 uyder(j,j,1)=uyder(j,j,1)-costh
1257 uyder(j,j,2)=1.0d0+uyder(j,j,2)
1262 uygrad(l,k,j,i)=uyder(l,k,j)
1263 uzgrad(l,k,j,i)=uzder(l,k,j)
1267 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
1268 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
1269 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
1270 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
1276 vbld_inv_temp(1)=vbld_inv(i+1)
1277 if (i.lt.nres-1) then
1278 vbld_inv_temp(2)=vbld_inv(i+2)
1280 vbld_inv_temp(2)=vbld_inv(i)
1285 uygrad(l,k,j,i)=vbld_inv_temp(j)*uygrad(l,k,j,i)
1286 uzgrad(l,k,j,i)=vbld_inv_temp(j)*uzgrad(l,k,j,i)
1294 C-----------------------------------------------------------------------------
1295 subroutine vec_and_deriv_test
1296 implicit real*8 (a-h,o-z)
1297 include 'DIMENSIONS'
1298 include 'DIMENSIONS.ZSCOPT'
1299 include 'COMMON.IOUNITS'
1300 include 'COMMON.GEO'
1301 include 'COMMON.VAR'
1302 include 'COMMON.LOCAL'
1303 include 'COMMON.CHAIN'
1304 include 'COMMON.VECTORS'
1305 dimension uyder(3,3,2),uzder(3,3,2)
1306 C Compute the local reference systems. For reference system (i), the
1307 C X-axis points from CA(i) to CA(i+1), the Y axis is in the
1308 C CA(i)-CA(i+1)-CA(i+2) plane, and the Z axis is perpendicular to this plane.
1310 if (i.eq.nres-1) then
1311 C Case of the last full residue
1312 C Compute the Z-axis
1313 call vecpr(dc_norm(1,i),dc_norm(1,i-1),uz(1,i))
1314 costh=dcos(pi-theta(nres))
1315 fac=1.0d0/dsqrt(1.0d0-costh*costh)
1316 c write (iout,*) 'fac',fac,
1317 c & 1.0d0/dsqrt(scalar(uz(1,i),uz(1,i)))
1318 fac=1.0d0/dsqrt(scalar(uz(1,i),uz(1,i)))
1322 C Compute the derivatives of uz
1324 uzder(2,1,1)=-dc_norm(3,i-1)
1325 uzder(3,1,1)= dc_norm(2,i-1)
1326 uzder(1,2,1)= dc_norm(3,i-1)
1328 uzder(3,2,1)=-dc_norm(1,i-1)
1329 uzder(1,3,1)=-dc_norm(2,i-1)
1330 uzder(2,3,1)= dc_norm(1,i-1)
1333 uzder(2,1,2)= dc_norm(3,i)
1334 uzder(3,1,2)=-dc_norm(2,i)
1335 uzder(1,2,2)=-dc_norm(3,i)
1337 uzder(3,2,2)= dc_norm(1,i)
1338 uzder(1,3,2)= dc_norm(2,i)
1339 uzder(2,3,2)=-dc_norm(1,i)
1341 C Compute the Y-axis
1343 uy(k,i)=fac*(dc_norm(k,i-1)-costh*dc_norm(k,i))
1346 facy=1.0d0/dsqrt(scalar(dc_norm(1,i),dc_norm(1,i))*
1347 & (scalar(dc_norm(1,i-1),dc_norm(1,i-1))**2-
1348 & scalar(dc_norm(1,i),dc_norm(1,i-1))**2))
1350 c uy(k,i)=facy*(dc_norm(k,i+1)-costh*dc_norm(k,i))
1353 & dc_norm(k,i-1)*scalar(dc_norm(1,i),dc_norm(1,i))
1354 & -scalar(dc_norm(1,i),dc_norm(1,i-1))*dc_norm(k,i)
1357 c write (iout,*) 'facy',facy,
1358 c & 1.0d0/dsqrt(scalar(uy(1,i),uy(1,i)))
1359 facy=1.0d0/dsqrt(scalar(uy(1,i),uy(1,i)))
1361 uy(k,i)=facy*uy(k,i)
1363 C Compute the derivatives of uy
1366 uyder(k,j,1)=2*dc_norm(k,i-1)*dc_norm(j,i)
1367 & -dc_norm(k,i)*dc_norm(j,i-1)
1368 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
1370 c uyder(j,j,1)=uyder(j,j,1)-costh
1371 c uyder(j,j,2)=1.0d0+uyder(j,j,2)
1372 uyder(j,j,1)=uyder(j,j,1)
1373 & -scalar(dc_norm(1,i),dc_norm(1,i-1))
1374 uyder(j,j,2)=scalar(dc_norm(1,i),dc_norm(1,i))
1380 uygrad(l,k,j,i)=uyder(l,k,j)
1381 uzgrad(l,k,j,i)=uzder(l,k,j)
1385 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
1386 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
1387 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
1388 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
1391 C Compute the Z-axis
1392 call vecpr(dc_norm(1,i),dc_norm(1,i+1),uz(1,i))
1393 costh=dcos(pi-theta(i+2))
1394 fac=1.0d0/dsqrt(1.0d0-costh*costh)
1395 fac=1.0d0/dsqrt(scalar(uz(1,i),uz(1,i)))
1399 C Compute the derivatives of uz
1401 uzder(2,1,1)=-dc_norm(3,i+1)
1402 uzder(3,1,1)= dc_norm(2,i+1)
1403 uzder(1,2,1)= dc_norm(3,i+1)
1405 uzder(3,2,1)=-dc_norm(1,i+1)
1406 uzder(1,3,1)=-dc_norm(2,i+1)
1407 uzder(2,3,1)= dc_norm(1,i+1)
1410 uzder(2,1,2)= dc_norm(3,i)
1411 uzder(3,1,2)=-dc_norm(2,i)
1412 uzder(1,2,2)=-dc_norm(3,i)
1414 uzder(3,2,2)= dc_norm(1,i)
1415 uzder(1,3,2)= dc_norm(2,i)
1416 uzder(2,3,2)=-dc_norm(1,i)
1418 C Compute the Y-axis
1420 facy=1.0d0/dsqrt(scalar(dc_norm(1,i),dc_norm(1,i))*
1421 & (scalar(dc_norm(1,i+1),dc_norm(1,i+1))**2-
1422 & scalar(dc_norm(1,i),dc_norm(1,i+1))**2))
1424 c uy(k,i)=facy*(dc_norm(k,i+1)-costh*dc_norm(k,i))
1427 & dc_norm(k,i+1)*scalar(dc_norm(1,i),dc_norm(1,i))
1428 & -scalar(dc_norm(1,i),dc_norm(1,i+1))*dc_norm(k,i)
1431 c write (iout,*) 'facy',facy,
1432 c & 1.0d0/dsqrt(scalar(uy(1,i),uy(1,i)))
1433 facy=1.0d0/dsqrt(scalar(uy(1,i),uy(1,i)))
1435 uy(k,i)=facy*uy(k,i)
1437 C Compute the derivatives of uy
1440 uyder(k,j,1)=2*dc_norm(k,i+1)*dc_norm(j,i)
1441 & -dc_norm(k,i)*dc_norm(j,i+1)
1442 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
1444 c uyder(j,j,1)=uyder(j,j,1)-costh
1445 c uyder(j,j,2)=1.0d0+uyder(j,j,2)
1446 uyder(j,j,1)=uyder(j,j,1)
1447 & -scalar(dc_norm(1,i),dc_norm(1,i+1))
1448 uyder(j,j,2)=scalar(dc_norm(1,i),dc_norm(1,i))
1454 uygrad(l,k,j,i)=uyder(l,k,j)
1455 uzgrad(l,k,j,i)=uzder(l,k,j)
1459 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
1460 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
1461 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
1462 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
1469 uygrad(l,k,j,i)=vblinv*uygrad(l,k,j,i)
1470 uzgrad(l,k,j,i)=vblinv*uzgrad(l,k,j,i)
1477 C-----------------------------------------------------------------------------
1478 subroutine check_vecgrad
1479 implicit real*8 (a-h,o-z)
1480 include 'DIMENSIONS'
1481 include 'DIMENSIONS.ZSCOPT'
1482 include 'COMMON.IOUNITS'
1483 include 'COMMON.GEO'
1484 include 'COMMON.VAR'
1485 include 'COMMON.LOCAL'
1486 include 'COMMON.CHAIN'
1487 include 'COMMON.VECTORS'
1488 dimension uygradt(3,3,2,maxres),uzgradt(3,3,2,maxres)
1489 dimension uyt(3,maxres),uzt(3,maxres)
1490 dimension uygradn(3,3,2),uzgradn(3,3,2),erij(3)
1491 double precision delta /1.0d-7/
1494 crc write(iout,'(2i5,2(3f10.5,5x))') i,1,dc_norm(:,i)
1495 crc write(iout,'(2i5,2(3f10.5,5x))') i,2,uy(:,i)
1496 crc write(iout,'(2i5,2(3f10.5,5x)/)')i,3,uz(:,i)
1497 cd write(iout,'(2i5,2(3f10.5,5x))') i,1,
1498 cd & (dc_norm(if90,i),if90=1,3)
1499 cd write(iout,'(2i5,2(3f10.5,5x))') i,2,(uy(if90,i),if90=1,3)
1500 cd write(iout,'(2i5,2(3f10.5,5x)/)')i,3,(uz(if90,i),if90=1,3)
1501 cd write(iout,'(a)')
1507 uygradt(l,k,j,i)=uygrad(l,k,j,i)
1508 uzgradt(l,k,j,i)=uzgrad(l,k,j,i)
1521 cd write (iout,*) 'i=',i
1523 erij(k)=dc_norm(k,i)
1527 dc_norm(k,i)=erij(k)
1529 dc_norm(j,i)=dc_norm(j,i)+delta
1530 c fac=dsqrt(scalar(dc_norm(1,i),dc_norm(1,i)))
1532 c dc_norm(k,i)=dc_norm(k,i)/fac
1534 c write (iout,*) (dc_norm(k,i),k=1,3)
1535 c write (iout,*) (erij(k),k=1,3)
1538 uygradn(k,j,1)=(uy(k,i)-uyt(k,i))/delta
1539 uygradn(k,j,2)=(uy(k,i-1)-uyt(k,i-1))/delta
1540 uzgradn(k,j,1)=(uz(k,i)-uzt(k,i))/delta
1541 uzgradn(k,j,2)=(uz(k,i-1)-uzt(k,i-1))/delta
1543 c write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
1544 c & j,(uzgradt(k,j,1,i),k=1,3),(uzgradn(k,j,1),k=1,3),
1545 c & (uzgradt(k,j,2,i-1),k=1,3),(uzgradn(k,j,2),k=1,3)
1548 dc_norm(k,i)=erij(k)
1551 cd write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
1552 cd & k,(uygradt(k,l,1,i),l=1,3),(uygradn(k,l,1),l=1,3),
1553 cd & (uygradt(k,l,2,i-1),l=1,3),(uygradn(k,l,2),l=1,3)
1554 cd write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
1555 cd & k,(uzgradt(k,l,1,i),l=1,3),(uzgradn(k,l,1),l=1,3),
1556 cd & (uzgradt(k,l,2,i-1),l=1,3),(uzgradn(k,l,2),l=1,3)
1557 cd write (iout,'(a)')
1562 C--------------------------------------------------------------------------
1563 subroutine set_matrices
1564 implicit real*8 (a-h,o-z)
1565 include 'DIMENSIONS'
1566 include 'DIMENSIONS.ZSCOPT'
1567 include 'COMMON.IOUNITS'
1568 include 'COMMON.GEO'
1569 include 'COMMON.VAR'
1570 include 'COMMON.LOCAL'
1571 include 'COMMON.CHAIN'
1572 include 'COMMON.DERIV'
1573 include 'COMMON.INTERACT'
1574 include 'COMMON.CONTACTS'
1575 include 'COMMON.TORSION'
1576 include 'COMMON.VECTORS'
1577 include 'COMMON.FFIELD'
1578 double precision auxvec(2),auxmat(2,2)
1580 C Compute the virtual-bond-torsional-angle dependent quantities needed
1581 C to calculate the el-loc multibody terms of various order.
1584 if (i .lt. nres+1) then
1621 if (i .gt. 3 .and. i .lt. nres+1) then
1622 obrot_der(1,i-2)=-sin1
1623 obrot_der(2,i-2)= cos1
1624 Ugder(1,1,i-2)= sin1
1625 Ugder(1,2,i-2)=-cos1
1626 Ugder(2,1,i-2)=-cos1
1627 Ugder(2,2,i-2)=-sin1
1630 obrot2_der(1,i-2)=-dwasin2
1631 obrot2_der(2,i-2)= dwacos2
1632 Ug2der(1,1,i-2)= dwasin2
1633 Ug2der(1,2,i-2)=-dwacos2
1634 Ug2der(2,1,i-2)=-dwacos2
1635 Ug2der(2,2,i-2)=-dwasin2
1637 obrot_der(1,i-2)=0.0d0
1638 obrot_der(2,i-2)=0.0d0
1639 Ugder(1,1,i-2)=0.0d0
1640 Ugder(1,2,i-2)=0.0d0
1641 Ugder(2,1,i-2)=0.0d0
1642 Ugder(2,2,i-2)=0.0d0
1643 obrot2_der(1,i-2)=0.0d0
1644 obrot2_der(2,i-2)=0.0d0
1645 Ug2der(1,1,i-2)=0.0d0
1646 Ug2der(1,2,i-2)=0.0d0
1647 Ug2der(2,1,i-2)=0.0d0
1648 Ug2der(2,2,i-2)=0.0d0
1650 if (i.gt. iatel_s+2 .and. i.lt.iatel_e+5) then
1651 iti = itortyp(itype(i-2))
1655 if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
1656 iti1 = itortyp(itype(i-1))
1660 cd write (iout,*) '*******i',i,' iti1',iti
1661 cd write (iout,*) 'b1',b1(:,iti)
1662 cd write (iout,*) 'b2',b2(:,iti)
1663 cd write (iout,*) 'Ug',Ug(:,:,i-2)
1664 if (i .gt. iatel_s+2) then
1665 call matvec2(Ug(1,1,i-2),b2(1,iti),Ub2(1,i-2))
1666 call matmat2(EE(1,1,iti),Ug(1,1,i-2),EUg(1,1,i-2))
1667 call matmat2(CC(1,1,iti),Ug(1,1,i-2),CUg(1,1,i-2))
1668 call matmat2(DD(1,1,iti),Ug(1,1,i-2),DUg(1,1,i-2))
1669 call matmat2(Dtilde(1,1,iti),Ug2(1,1,i-2),DtUg2(1,1,i-2))
1670 call matvec2(Ctilde(1,1,iti1),obrot(1,i-2),Ctobr(1,i-2))
1671 call matvec2(Dtilde(1,1,iti),obrot2(1,i-2),Dtobr2(1,i-2))
1681 DtUg2(l,k,i-2)=0.0d0
1685 call matvec2(Ugder(1,1,i-2),b2(1,iti),Ub2der(1,i-2))
1686 call matmat2(EE(1,1,iti),Ugder(1,1,i-2),EUgder(1,1,i-2))
1687 call matmat2(CC(1,1,iti1),Ugder(1,1,i-2),CUgder(1,1,i-2))
1688 call matmat2(DD(1,1,iti),Ugder(1,1,i-2),DUgder(1,1,i-2))
1689 call matmat2(Dtilde(1,1,iti),Ug2der(1,1,i-2),DtUg2der(1,1,i-2))
1690 call matvec2(Ctilde(1,1,iti1),obrot_der(1,i-2),Ctobrder(1,i-2))
1691 call matvec2(Dtilde(1,1,iti),obrot2_der(1,i-2),Dtobr2der(1,i-2))
1693 muder(k,i-2)=Ub2der(k,i-2)
1695 if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
1696 iti1 = itortyp(itype(i-1))
1701 mu(k,i-2)=Ub2(k,i-2)+b1(k,iti1)
1703 C Vectors and matrices dependent on a single virtual-bond dihedral.
1704 call matvec2(DD(1,1,iti),b1tilde(1,iti1),auxvec(1))
1705 call matvec2(Ug2(1,1,i-2),auxvec(1),Ug2Db1t(1,i-2))
1706 call matvec2(Ug2der(1,1,i-2),auxvec(1),Ug2Db1tder(1,i-2))
1707 call matvec2(CC(1,1,iti1),Ub2(1,i-2),CUgb2(1,i-2))
1708 call matvec2(CC(1,1,iti1),Ub2der(1,i-2),CUgb2der(1,i-2))
1709 call matmat2(EUg(1,1,i-2),CC(1,1,iti1),EUgC(1,1,i-2))
1710 call matmat2(EUgder(1,1,i-2),CC(1,1,iti1),EUgCder(1,1,i-2))
1711 call matmat2(EUg(1,1,i-2),DD(1,1,iti1),EUgD(1,1,i-2))
1712 call matmat2(EUgder(1,1,i-2),DD(1,1,iti1),EUgDder(1,1,i-2))
1713 cd write (iout,*) 'i',i,' mu ',(mu(k,i-2),k=1,2),
1714 cd & ' mu1',(b1(k,i-2),k=1,2),' mu2',(Ub2(k,i-2),k=1,2)
1716 C Matrices dependent on two consecutive virtual-bond dihedrals.
1717 C The order of matrices is from left to right.
1719 call matmat2(DtUg2(1,1,i-1),EUg(1,1,i),DtUg2EUg(1,1,i))
1720 call matmat2(DtUg2der(1,1,i-1),EUg(1,1,i),DtUg2EUgder(1,1,1,i))
1721 call matmat2(DtUg2(1,1,i-1),EUgder(1,1,i),DtUg2EUgder(1,1,2,i))
1722 call transpose2(DtUg2(1,1,i-1),auxmat(1,1))
1723 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUg(1,1,i))
1724 call matmat2(auxmat(1,1),EUgder(1,1,i),Ug2DtEUgder(1,1,2,i))
1725 call transpose2(DtUg2der(1,1,i-1),auxmat(1,1))
1726 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUgder(1,1,1,i))
1729 cd iti = itortyp(itype(i))
1732 cd write (iout,'(2f10.5,5x,2f10.5,5x,2f10.5)')
1733 cd & (EE(j,k,iti),k=1,2),(Ug(j,k,i),k=1,2),(EUg(j,k,i),k=1,2)
1738 C--------------------------------------------------------------------------
1739 subroutine eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
1741 C This subroutine calculates the average interaction energy and its gradient
1742 C in the virtual-bond vectors between non-adjacent peptide groups, based on
1743 C the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
1744 C The potential depends both on the distance of peptide-group centers and on
1745 C the orientation of the CA-CA virtual bonds.
1747 implicit real*8 (a-h,o-z)
1748 include 'DIMENSIONS'
1749 include 'DIMENSIONS.ZSCOPT'
1750 include 'COMMON.CONTROL'
1751 include 'COMMON.IOUNITS'
1752 include 'COMMON.GEO'
1753 include 'COMMON.VAR'
1754 include 'COMMON.LOCAL'
1755 include 'COMMON.CHAIN'
1756 include 'COMMON.DERIV'
1757 include 'COMMON.INTERACT'
1758 include 'COMMON.CONTACTS'
1759 include 'COMMON.TORSION'
1760 include 'COMMON.VECTORS'
1761 include 'COMMON.FFIELD'
1762 dimension ggg(3),gggp(3),gggm(3),erij(3),dcosb(3),dcosg(3),
1763 & erder(3,3),uryg(3,3),urzg(3,3),vryg(3,3),vrzg(3,3)
1764 double precision acipa(2,2),agg(3,4),aggi(3,4),aggi1(3,4),
1765 & aggj(3,4),aggj1(3,4),a_temp(2,2),muij(4)
1766 common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,j1
1767 c 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
1768 double precision scal_el /0.5d0/
1770 C 13-go grudnia roku pamietnego...
1771 double precision unmat(3,3) /1.0d0,0.0d0,0.0d0,
1772 & 0.0d0,1.0d0,0.0d0,
1773 & 0.0d0,0.0d0,1.0d0/
1774 cd write(iout,*) 'In EELEC'
1776 cd write(iout,*) 'Type',i
1777 cd write(iout,*) 'B1',B1(:,i)
1778 cd write(iout,*) 'B2',B2(:,i)
1779 cd write(iout,*) 'CC',CC(:,:,i)
1780 cd write(iout,*) 'DD',DD(:,:,i)
1781 cd write(iout,*) 'EE',EE(:,:,i)
1783 cd call check_vecgrad
1785 if (icheckgrad.eq.1) then
1787 fac=1.0d0/dsqrt(scalar(dc(1,i),dc(1,i)))
1789 dc_norm(k,i)=dc(k,i)*fac
1791 c write (iout,*) 'i',i,' fac',fac
1794 if (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0
1795 & .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 .or.
1796 & wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) then
1797 cd if (wel_loc.gt.0.0d0) then
1798 if (icheckgrad.eq.1) then
1799 call vec_and_deriv_test
1806 cd write (iout,*) 'i=',i
1808 cd write (iout,'(i5,2f10.5)') k,uy(k,i),uz(k,i)
1811 cd write (iout,'(f10.5,2x,3f10.5,2x,3f10.5)')
1812 cd & uz(k,i),(uzgrad(k,l,1,i),l=1,3),(uzgrad(k,l,2,i),l=1,3)
1825 cd print '(a)','Enter EELEC'
1826 cd write (iout,*) 'iatel_s=',iatel_s,' iatel_e=',iatel_e
1828 gel_loc_loc(i)=0.0d0
1831 do i=iatel_s,iatel_e
1832 if (itel(i).eq.0) goto 1215
1836 dx_normi=dc_norm(1,i)
1837 dy_normi=dc_norm(2,i)
1838 dz_normi=dc_norm(3,i)
1839 xmedi=c(1,i)+0.5d0*dxi
1840 ymedi=c(2,i)+0.5d0*dyi
1841 zmedi=c(3,i)+0.5d0*dzi
1843 c write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
1844 do j=ielstart(i),ielend(i)
1845 if (itel(j).eq.0) goto 1216
1849 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
1850 aaa=app(iteli,itelj)
1851 bbb=bpp(iteli,itelj)
1852 C Diagnostics only!!!
1858 ael6i=ael6(iteli,itelj)
1859 ael3i=ael3(iteli,itelj)
1863 dx_normj=dc_norm(1,j)
1864 dy_normj=dc_norm(2,j)
1865 dz_normj=dc_norm(3,j)
1866 xj=c(1,j)+0.5D0*dxj-xmedi
1867 yj=c(2,j)+0.5D0*dyj-ymedi
1868 zj=c(3,j)+0.5D0*dzj-zmedi
1869 rij=xj*xj+yj*yj+zj*zj
1875 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
1876 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
1877 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
1878 fac=cosa-3.0D0*cosb*cosg
1880 c 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
1881 if (j.eq.i+2) ev1=scal_el*ev1
1886 el1=fac3*(4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg))
1889 c write (iout,*) "i",i,iteli," j",j,itelj," eesij",eesij
1890 C 12/26/95 - for the evaluation of multi-body H-bonding interactions
1891 ees0ij=4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg)
1894 cd write(iout,'(2(2i3,2x),7(1pd12.4)/2(3(1pd12.4),5x)/)')
1895 cd & iteli,i,itelj,j,aaa,bbb,ael6i,ael3i,
1896 cd & 1.0D0/dsqrt(rrmij),evdwij,eesij,
1897 cd & xmedi,ymedi,zmedi,xj,yj,zj
1899 C Calculate contributions to the Cartesian gradient.
1902 facvdw=-6*rrmij*(ev1+evdwij)
1903 facel=-3*rrmij*(el1+eesij)
1910 * Radial derivatives. First process both termini of the fragment (i,j)
1917 gelc(k,i)=gelc(k,i)+ghalf
1918 gelc(k,j)=gelc(k,j)+ghalf
1921 * Loop over residues i+1 thru j-1.
1925 gelc(l,k)=gelc(l,k)+ggg(l)
1933 gvdwpp(k,i)=gvdwpp(k,i)+ghalf
1934 gvdwpp(k,j)=gvdwpp(k,j)+ghalf
1937 * Loop over residues i+1 thru j-1.
1941 gvdwpp(l,k)=gvdwpp(l,k)+ggg(l)
1948 fac=-3*rrmij*(facvdw+facvdw+facel)
1954 * Radial derivatives. First process both termini of the fragment (i,j)
1961 gelc(k,i)=gelc(k,i)+ghalf
1962 gelc(k,j)=gelc(k,j)+ghalf
1965 * Loop over residues i+1 thru j-1.
1969 gelc(l,k)=gelc(l,k)+ggg(l)
1976 ecosa=2.0D0*fac3*fac1+fac4
1979 ecosb=(fac3*(fac1*cosg+cosb)+cosg*fac4)
1980 ecosg=(fac3*(fac1*cosb+cosg)+cosb*fac4)
1982 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
1983 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
1985 cd print '(2i3,2(3(1pd14.5),3x))',i,j,(dcosb(k),k=1,3),
1986 cd & (dcosg(k),k=1,3)
1988 ggg(k)=ecosb*dcosb(k)+ecosg*dcosg(k)
1992 gelc(k,i)=gelc(k,i)+ghalf
1993 & +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
1994 & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
1995 gelc(k,j)=gelc(k,j)+ghalf
1996 & +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
1997 & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
2001 gelc(l,k)=gelc(l,k)+ggg(l)
2006 IF (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0
2007 & .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0
2008 & .or. wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
2010 C 9/25/99 Mixed third-order local-electrostatic terms. The local-interaction
2011 C energy of a peptide unit is assumed in the form of a second-order
2012 C Fourier series in the angles lambda1 and lambda2 (see Nishikawa et al.
2013 C Macromolecules, 1974, 7, 797-806 for definition). This correlation terms
2014 C are computed for EVERY pair of non-contiguous peptide groups.
2016 if (j.lt.nres-1) then
2027 muij(kkk)=mu(k,i)*mu(l,j)
2030 cd write (iout,*) 'EELEC: i',i,' j',j
2031 cd write (iout,*) 'j',j,' j1',j1,' j2',j2
2032 cd write(iout,*) 'muij',muij
2033 ury=scalar(uy(1,i),erij)
2034 urz=scalar(uz(1,i),erij)
2035 vry=scalar(uy(1,j),erij)
2036 vrz=scalar(uz(1,j),erij)
2037 a22=scalar(uy(1,i),uy(1,j))-3*ury*vry
2038 a23=scalar(uy(1,i),uz(1,j))-3*ury*vrz
2039 a32=scalar(uz(1,i),uy(1,j))-3*urz*vry
2040 a33=scalar(uz(1,i),uz(1,j))-3*urz*vrz
2041 C For diagnostics only
2046 fac=dsqrt(-ael6i)*r3ij
2047 cd write (2,*) 'fac=',fac
2048 C For diagnostics only
2054 cd write (iout,'(4i5,4f10.5)')
2055 cd & i,itortyp(itype(i)),j,itortyp(itype(j)),a22,a23,a32,a33
2056 cd write (iout,'(6f10.5)') (muij(k),k=1,4),fac,eel_loc_ij
2057 cd write (iout,'(2(3f10.5,5x)/2(3f10.5,5x))') (uy(k,i),k=1,3),
2058 cd & (uz(k,i),k=1,3),(uy(k,j),k=1,3),(uz(k,j),k=1,3)
2059 cd write (iout,'(4f10.5)')
2060 cd & scalar(uy(1,i),uy(1,j)),scalar(uy(1,i),uz(1,j)),
2061 cd & scalar(uz(1,i),uy(1,j)),scalar(uz(1,i),uz(1,j))
2062 cd write (iout,'(4f10.5)') ury,urz,vry,vrz
2063 cd write (iout,'(2i3,9f10.5/)') i,j,
2064 cd & fac22,a22,fac23,a23,fac32,a32,fac33,a33,eel_loc_ij
2066 C Derivatives of the elements of A in virtual-bond vectors
2067 call unormderiv(erij(1),unmat(1,1),rmij,erder(1,1))
2074 uryg(k,1)=scalar(erder(1,k),uy(1,i))
2075 uryg(k,2)=scalar(uygrad(1,k,1,i),erij(1))
2076 uryg(k,3)=scalar(uygrad(1,k,2,i),erij(1))
2077 urzg(k,1)=scalar(erder(1,k),uz(1,i))
2078 urzg(k,2)=scalar(uzgrad(1,k,1,i),erij(1))
2079 urzg(k,3)=scalar(uzgrad(1,k,2,i),erij(1))
2080 vryg(k,1)=scalar(erder(1,k),uy(1,j))
2081 vryg(k,2)=scalar(uygrad(1,k,1,j),erij(1))
2082 vryg(k,3)=scalar(uygrad(1,k,2,j),erij(1))
2083 vrzg(k,1)=scalar(erder(1,k),uz(1,j))
2084 vrzg(k,2)=scalar(uzgrad(1,k,1,j),erij(1))
2085 vrzg(k,3)=scalar(uzgrad(1,k,2,j),erij(1))
2095 C Compute radial contributions to the gradient
2117 C Add the contributions coming from er
2120 agg(k,1)=agg(k,1)+fac3*(uryg(k,1)*vry+vryg(k,1)*ury)
2121 agg(k,2)=agg(k,2)+fac3*(uryg(k,1)*vrz+vrzg(k,1)*ury)
2122 agg(k,3)=agg(k,3)+fac3*(urzg(k,1)*vry+vryg(k,1)*urz)
2123 agg(k,4)=agg(k,4)+fac3*(urzg(k,1)*vrz+vrzg(k,1)*urz)
2126 C Derivatives in DC(i)
2127 ghalf1=0.5d0*agg(k,1)
2128 ghalf2=0.5d0*agg(k,2)
2129 ghalf3=0.5d0*agg(k,3)
2130 ghalf4=0.5d0*agg(k,4)
2131 aggi(k,1)=fac*(scalar(uygrad(1,k,1,i),uy(1,j))
2132 & -3.0d0*uryg(k,2)*vry)+ghalf1
2133 aggi(k,2)=fac*(scalar(uygrad(1,k,1,i),uz(1,j))
2134 & -3.0d0*uryg(k,2)*vrz)+ghalf2
2135 aggi(k,3)=fac*(scalar(uzgrad(1,k,1,i),uy(1,j))
2136 & -3.0d0*urzg(k,2)*vry)+ghalf3
2137 aggi(k,4)=fac*(scalar(uzgrad(1,k,1,i),uz(1,j))
2138 & -3.0d0*urzg(k,2)*vrz)+ghalf4
2139 C Derivatives in DC(i+1)
2140 aggi1(k,1)=fac*(scalar(uygrad(1,k,2,i),uy(1,j))
2141 & -3.0d0*uryg(k,3)*vry)+agg(k,1)
2142 aggi1(k,2)=fac*(scalar(uygrad(1,k,2,i),uz(1,j))
2143 & -3.0d0*uryg(k,3)*vrz)+agg(k,2)
2144 aggi1(k,3)=fac*(scalar(uzgrad(1,k,2,i),uy(1,j))
2145 & -3.0d0*urzg(k,3)*vry)+agg(k,3)
2146 aggi1(k,4)=fac*(scalar(uzgrad(1,k,2,i),uz(1,j))
2147 & -3.0d0*urzg(k,3)*vrz)+agg(k,4)
2148 C Derivatives in DC(j)
2149 aggj(k,1)=fac*(scalar(uygrad(1,k,1,j),uy(1,i))
2150 & -3.0d0*vryg(k,2)*ury)+ghalf1
2151 aggj(k,2)=fac*(scalar(uzgrad(1,k,1,j),uy(1,i))
2152 & -3.0d0*vrzg(k,2)*ury)+ghalf2
2153 aggj(k,3)=fac*(scalar(uygrad(1,k,1,j),uz(1,i))
2154 & -3.0d0*vryg(k,2)*urz)+ghalf3
2155 aggj(k,4)=fac*(scalar(uzgrad(1,k,1,j),uz(1,i))
2156 & -3.0d0*vrzg(k,2)*urz)+ghalf4
2157 C Derivatives in DC(j+1) or DC(nres-1)
2158 aggj1(k,1)=fac*(scalar(uygrad(1,k,2,j),uy(1,i))
2159 & -3.0d0*vryg(k,3)*ury)
2160 aggj1(k,2)=fac*(scalar(uzgrad(1,k,2,j),uy(1,i))
2161 & -3.0d0*vrzg(k,3)*ury)
2162 aggj1(k,3)=fac*(scalar(uygrad(1,k,2,j),uz(1,i))
2163 & -3.0d0*vryg(k,3)*urz)
2164 aggj1(k,4)=fac*(scalar(uzgrad(1,k,2,j),uz(1,i))
2165 & -3.0d0*vrzg(k,3)*urz)
2170 C Derivatives in DC(i+1)
2171 cd aggi1(k,1)=agg(k,1)
2172 cd aggi1(k,2)=agg(k,2)
2173 cd aggi1(k,3)=agg(k,3)
2174 cd aggi1(k,4)=agg(k,4)
2175 C Derivatives in DC(j)
2180 C Derivatives in DC(j+1)
2185 if (j.eq.nres-1 .and. i.lt.j-2) then
2187 aggj1(k,l)=aggj1(k,l)+agg(k,l)
2188 cd aggj1(k,l)=agg(k,l)
2194 C Check the loc-el terms by numerical integration
2204 aggi(k,l)=-aggi(k,l)
2205 aggi1(k,l)=-aggi1(k,l)
2206 aggj(k,l)=-aggj(k,l)
2207 aggj1(k,l)=-aggj1(k,l)
2210 if (j.lt.nres-1) then
2216 aggi(k,l)=-aggi(k,l)
2217 aggi1(k,l)=-aggi1(k,l)
2218 aggj(k,l)=-aggj(k,l)
2219 aggj1(k,l)=-aggj1(k,l)
2230 aggi(k,l)=-aggi(k,l)
2231 aggi1(k,l)=-aggi1(k,l)
2232 aggj(k,l)=-aggj(k,l)
2233 aggj1(k,l)=-aggj1(k,l)
2239 IF (wel_loc.gt.0.0d0) THEN
2240 C Contribution to the local-electrostatic energy coming from the i-j pair
2241 eel_loc_ij=a22*muij(1)+a23*muij(2)+a32*muij(3)
2243 cd write (iout,*) 'i',i,' j',j,' eel_loc_ij',eel_loc_ij
2244 cd write (iout,*) a22,muij(1),a23,muij(2),a32,muij(3)
2245 eel_loc=eel_loc+eel_loc_ij
2246 C Partial derivatives in virtual-bond dihedral angles gamma
2249 & gel_loc_loc(i-1)=gel_loc_loc(i-1)+
2250 & a22*muder(1,i)*mu(1,j)+a23*muder(1,i)*mu(2,j)
2251 & +a32*muder(2,i)*mu(1,j)+a33*muder(2,i)*mu(2,j)
2252 gel_loc_loc(j-1)=gel_loc_loc(j-1)+
2253 & a22*mu(1,i)*muder(1,j)+a23*mu(1,i)*muder(2,j)
2254 & +a32*mu(2,i)*muder(1,j)+a33*mu(2,i)*muder(2,j)
2255 cd call checkint3(i,j,mu1,mu2,a22,a23,a32,a33,acipa,eel_loc_ij)
2256 cd write(iout,*) 'agg ',agg
2257 cd write(iout,*) 'aggi ',aggi
2258 cd write(iout,*) 'aggi1',aggi1
2259 cd write(iout,*) 'aggj ',aggj
2260 cd write(iout,*) 'aggj1',aggj1
2262 C Derivatives of eello in DC(i+1) thru DC(j-1) or DC(nres-2)
2264 ggg(l)=agg(l,1)*muij(1)+
2265 & agg(l,2)*muij(2)+agg(l,3)*muij(3)+agg(l,4)*muij(4)
2269 gel_loc(l,k)=gel_loc(l,k)+ggg(l)
2272 C Remaining derivatives of eello
2274 gel_loc(l,i)=gel_loc(l,i)+aggi(l,1)*muij(1)+
2275 & aggi(l,2)*muij(2)+aggi(l,3)*muij(3)+aggi(l,4)*muij(4)
2276 gel_loc(l,i+1)=gel_loc(l,i+1)+aggi1(l,1)*muij(1)+
2277 & aggi1(l,2)*muij(2)+aggi1(l,3)*muij(3)+aggi1(l,4)*muij(4)
2278 gel_loc(l,j)=gel_loc(l,j)+aggj(l,1)*muij(1)+
2279 & aggj(l,2)*muij(2)+aggj(l,3)*muij(3)+aggj(l,4)*muij(4)
2280 gel_loc(l,j1)=gel_loc(l,j1)+aggj1(l,1)*muij(1)+
2281 & aggj1(l,2)*muij(2)+aggj1(l,3)*muij(3)+aggj1(l,4)*muij(4)
2285 if (wturn3.gt.0.0d0 .or. wturn4.gt.0.0d0) then
2286 C Contributions from turns
2291 call eturn34(i,j,eello_turn3,eello_turn4)
2293 C Change 12/26/95 to calculate four-body contributions to H-bonding energy
2294 if (j.gt.i+1 .and. num_conti.le.maxconts) then
2296 C Calculate the contact function. The ith column of the array JCONT will
2297 C contain the numbers of atoms that make contacts with the atom I (of numbers
2298 C greater than I). The arrays FACONT and GACONT will contain the values of
2299 C the contact function and its derivative.
2300 c r0ij=1.02D0*rpp(iteli,itelj)
2301 c r0ij=1.11D0*rpp(iteli,itelj)
2302 r0ij=2.20D0*rpp(iteli,itelj)
2303 c r0ij=1.55D0*rpp(iteli,itelj)
2304 call gcont(rij,r0ij,1.0D0,0.2d0*r0ij,fcont,fprimcont)
2305 if (fcont.gt.0.0D0) then
2306 num_conti=num_conti+1
2307 if (num_conti.gt.maxconts) then
2308 write (iout,*) 'WARNING - max. # of contacts exceeded;',
2309 & ' will skip next contacts for this conf.'
2311 jcont_hb(num_conti,i)=j
2312 IF (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.
2313 & wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
2314 C 9/30/99 (AL) - store components necessary to evaluate higher-order loc-el
2316 d_cont(num_conti,i)=rij
2317 cd write (2,'(3e15.5)') rij,r0ij+0.2d0*r0ij,rij
2318 C --- Electrostatic-interaction matrix ---
2319 a_chuj(1,1,num_conti,i)=a22
2320 a_chuj(1,2,num_conti,i)=a23
2321 a_chuj(2,1,num_conti,i)=a32
2322 a_chuj(2,2,num_conti,i)=a33
2323 C --- Gradient of rij
2325 grij_hb_cont(kkk,num_conti,i)=erij(kkk)
2328 c a_chuj(1,1,num_conti,i)=-0.61d0
2329 c a_chuj(1,2,num_conti,i)= 0.4d0
2330 c a_chuj(2,1,num_conti,i)= 0.65d0
2331 c a_chuj(2,2,num_conti,i)= 0.50d0
2332 c else if (i.eq.2) then
2333 c a_chuj(1,1,num_conti,i)= 0.0d0
2334 c a_chuj(1,2,num_conti,i)= 0.0d0
2335 c a_chuj(2,1,num_conti,i)= 0.0d0
2336 c a_chuj(2,2,num_conti,i)= 0.0d0
2338 C --- and its gradients
2339 cd write (iout,*) 'i',i,' j',j
2341 cd write (iout,*) 'iii 1 kkk',kkk
2342 cd write (iout,*) agg(kkk,:)
2345 cd write (iout,*) 'iii 2 kkk',kkk
2346 cd write (iout,*) aggi(kkk,:)
2349 cd write (iout,*) 'iii 3 kkk',kkk
2350 cd write (iout,*) aggi1(kkk,:)
2353 cd write (iout,*) 'iii 4 kkk',kkk
2354 cd write (iout,*) aggj(kkk,:)
2357 cd write (iout,*) 'iii 5 kkk',kkk
2358 cd write (iout,*) aggj1(kkk,:)
2365 a_chuj_der(k,l,m,1,num_conti,i)=agg(m,kkll)
2366 a_chuj_der(k,l,m,2,num_conti,i)=aggi(m,kkll)
2367 a_chuj_der(k,l,m,3,num_conti,i)=aggi1(m,kkll)
2368 a_chuj_der(k,l,m,4,num_conti,i)=aggj(m,kkll)
2369 a_chuj_der(k,l,m,5,num_conti,i)=aggj1(m,kkll)
2371 c a_chuj_der(k,l,m,mm,num_conti,i)=0.0d0
2377 IF (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) THEN
2378 C Calculate contact energies
2380 wij=cosa-3.0D0*cosb*cosg
2383 c fac3=dsqrt(-ael6i)/r0ij**3
2384 fac3=dsqrt(-ael6i)*r3ij
2385 ees0pij=dsqrt(4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1)
2386 ees0mij=dsqrt(4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2)
2388 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij)
2389 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij)
2390 C Diagnostics. Comment out or remove after debugging!
2391 c ees0p(num_conti,i)=0.5D0*fac3*ees0pij
2392 c ees0m(num_conti,i)=0.5D0*fac3*ees0mij
2393 c ees0m(num_conti,i)=0.0D0
2395 c write (iout,*) 'i=',i,' j=',j,' rij=',rij,' r0ij=',r0ij,
2396 c & ' ees0ij=',ees0p(num_conti,i),ees0m(num_conti,i),' fcont=',fcont
2397 facont_hb(num_conti,i)=fcont
2399 C Angular derivatives of the contact function
2400 ees0pij1=fac3/ees0pij
2401 ees0mij1=fac3/ees0mij
2402 fac3p=-3.0D0*fac3*rrmij
2403 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
2404 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
2406 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
2407 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
2408 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
2409 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
2410 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
2411 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
2412 ecosap=ecosa1+ecosa2
2413 ecosbp=ecosb1+ecosb2
2414 ecosgp=ecosg1+ecosg2
2415 ecosam=ecosa1-ecosa2
2416 ecosbm=ecosb1-ecosb2
2417 ecosgm=ecosg1-ecosg2
2426 fprimcont=fprimcont/rij
2427 cd facont_hb(num_conti,i)=1.0D0
2428 C Following line is for diagnostics.
2431 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
2432 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
2435 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
2436 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
2438 gggp(1)=gggp(1)+ees0pijp*xj
2439 gggp(2)=gggp(2)+ees0pijp*yj
2440 gggp(3)=gggp(3)+ees0pijp*zj
2441 gggm(1)=gggm(1)+ees0mijp*xj
2442 gggm(2)=gggm(2)+ees0mijp*yj
2443 gggm(3)=gggm(3)+ees0mijp*zj
2444 C Derivatives due to the contact function
2445 gacont_hbr(1,num_conti,i)=fprimcont*xj
2446 gacont_hbr(2,num_conti,i)=fprimcont*yj
2447 gacont_hbr(3,num_conti,i)=fprimcont*zj
2449 ghalfp=0.5D0*gggp(k)
2450 ghalfm=0.5D0*gggm(k)
2451 gacontp_hb1(k,num_conti,i)=ghalfp
2452 & +(ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i))
2453 & + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
2454 gacontp_hb2(k,num_conti,i)=ghalfp
2455 & +(ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j))
2456 & + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
2457 gacontp_hb3(k,num_conti,i)=gggp(k)
2458 gacontm_hb1(k,num_conti,i)=ghalfm
2459 & +(ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i))
2460 & + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
2461 gacontm_hb2(k,num_conti,i)=ghalfm
2462 & +(ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j))
2463 & + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
2464 gacontm_hb3(k,num_conti,i)=gggm(k)
2467 C Diagnostics. Comment out or remove after debugging!
2469 cdiag gacontp_hb1(k,num_conti,i)=0.0D0
2470 cdiag gacontp_hb2(k,num_conti,i)=0.0D0
2471 cdiag gacontp_hb3(k,num_conti,i)=0.0D0
2472 cdiag gacontm_hb1(k,num_conti,i)=0.0D0
2473 cdiag gacontm_hb2(k,num_conti,i)=0.0D0
2474 cdiag gacontm_hb3(k,num_conti,i)=0.0D0
2477 endif ! num_conti.le.maxconts
2482 num_cont_hb(i)=num_conti
2486 cd write (iout,'(i3,3f10.5,5x,3f10.5)')
2487 cd & i,(gel_loc(k,i),k=1,3),gel_loc_loc(i)
2489 c 12/7/99 Adam eello_turn3 will be considered as a separate energy term
2490 ccc eel_loc=eel_loc+eello_turn3
2493 C-----------------------------------------------------------------------------
2494 subroutine eturn34(i,j,eello_turn3,eello_turn4)
2495 C Third- and fourth-order contributions from turns
2496 implicit real*8 (a-h,o-z)
2497 include 'DIMENSIONS'
2498 include 'DIMENSIONS.ZSCOPT'
2499 include 'COMMON.IOUNITS'
2500 include 'COMMON.GEO'
2501 include 'COMMON.VAR'
2502 include 'COMMON.LOCAL'
2503 include 'COMMON.CHAIN'
2504 include 'COMMON.DERIV'
2505 include 'COMMON.INTERACT'
2506 include 'COMMON.CONTACTS'
2507 include 'COMMON.TORSION'
2508 include 'COMMON.VECTORS'
2509 include 'COMMON.FFIELD'
2511 double precision auxmat(2,2),auxmat1(2,2),auxmat2(2,2),pizda(2,2),
2512 & e1t(2,2),e2t(2,2),e3t(2,2),e1tder(2,2),e2tder(2,2),e3tder(2,2),
2513 & e1a(2,2),ae3(2,2),ae3e2(2,2),auxvec(2),auxvec1(2)
2514 double precision agg(3,4),aggi(3,4),aggi1(3,4),
2515 & aggj(3,4),aggj1(3,4),a_temp(2,2)
2516 common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,j1,j2
2518 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
2520 C Third-order contributions
2527 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
2528 cd call checkint_turn3(i,a_temp,eello_turn3_num)
2529 call matmat2(EUg(1,1,i+1),EUg(1,1,i+2),auxmat(1,1))
2530 call transpose2(auxmat(1,1),auxmat1(1,1))
2531 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
2532 eello_turn3=eello_turn3+0.5d0*(pizda(1,1)+pizda(2,2))
2533 cd write (2,*) 'i,',i,' j',j,'eello_turn3',
2534 cd & 0.5d0*(pizda(1,1)+pizda(2,2)),
2535 cd & ' eello_turn3_num',4*eello_turn3_num
2537 C Derivatives in gamma(i)
2538 call matmat2(EUgder(1,1,i+1),EUg(1,1,i+2),auxmat2(1,1))
2539 call transpose2(auxmat2(1,1),pizda(1,1))
2540 call matmat2(a_temp(1,1),pizda(1,1),pizda(1,1))
2541 gel_loc_turn3(i)=gel_loc_turn3(i)+0.5d0*(pizda(1,1)+pizda(2,2))
2542 C Derivatives in gamma(i+1)
2543 call matmat2(EUg(1,1,i+1),EUgder(1,1,i+2),auxmat2(1,1))
2544 call transpose2(auxmat2(1,1),pizda(1,1))
2545 call matmat2(a_temp(1,1),pizda(1,1),pizda(1,1))
2546 gel_loc_turn3(i+1)=gel_loc_turn3(i+1)
2547 & +0.5d0*(pizda(1,1)+pizda(2,2))
2548 C Cartesian derivatives
2550 a_temp(1,1)=aggi(l,1)
2551 a_temp(1,2)=aggi(l,2)
2552 a_temp(2,1)=aggi(l,3)
2553 a_temp(2,2)=aggi(l,4)
2554 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
2555 gcorr3_turn(l,i)=gcorr3_turn(l,i)
2556 & +0.5d0*(pizda(1,1)+pizda(2,2))
2557 a_temp(1,1)=aggi1(l,1)
2558 a_temp(1,2)=aggi1(l,2)
2559 a_temp(2,1)=aggi1(l,3)
2560 a_temp(2,2)=aggi1(l,4)
2561 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
2562 gcorr3_turn(l,i+1)=gcorr3_turn(l,i+1)
2563 & +0.5d0*(pizda(1,1)+pizda(2,2))
2564 a_temp(1,1)=aggj(l,1)
2565 a_temp(1,2)=aggj(l,2)
2566 a_temp(2,1)=aggj(l,3)
2567 a_temp(2,2)=aggj(l,4)
2568 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
2569 gcorr3_turn(l,j)=gcorr3_turn(l,j)
2570 & +0.5d0*(pizda(1,1)+pizda(2,2))
2571 a_temp(1,1)=aggj1(l,1)
2572 a_temp(1,2)=aggj1(l,2)
2573 a_temp(2,1)=aggj1(l,3)
2574 a_temp(2,2)=aggj1(l,4)
2575 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
2576 gcorr3_turn(l,j1)=gcorr3_turn(l,j1)
2577 & +0.5d0*(pizda(1,1)+pizda(2,2))
2580 else if (j.eq.i+3) then
2581 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
2583 C Fourth-order contributions
2591 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
2592 cd call checkint_turn4(i,a_temp,eello_turn4_num)
2593 iti1=itortyp(itype(i+1))
2594 iti2=itortyp(itype(i+2))
2595 iti3=itortyp(itype(i+3))
2596 call transpose2(EUg(1,1,i+1),e1t(1,1))
2597 call transpose2(Eug(1,1,i+2),e2t(1,1))
2598 call transpose2(Eug(1,1,i+3),e3t(1,1))
2599 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
2600 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
2601 s1=scalar2(b1(1,iti2),auxvec(1))
2602 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
2603 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
2604 s2=scalar2(b1(1,iti1),auxvec(1))
2605 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
2606 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
2607 s3=0.5d0*(pizda(1,1)+pizda(2,2))
2608 eello_turn4=eello_turn4-(s1+s2+s3)
2609 cd write (2,*) 'i,',i,' j',j,'eello_turn4',-(s1+s2+s3),
2610 cd & ' eello_turn4_num',8*eello_turn4_num
2611 C Derivatives in gamma(i)
2613 call transpose2(EUgder(1,1,i+1),e1tder(1,1))
2614 call matmat2(e1tder(1,1),a_temp(1,1),auxmat(1,1))
2615 call matvec2(auxmat(1,1),Ub2(1,i+3),auxvec(1))
2616 s1=scalar2(b1(1,iti2),auxvec(1))
2617 call matmat2(ae3e2(1,1),e1tder(1,1),pizda(1,1))
2618 s3=0.5d0*(pizda(1,1)+pizda(2,2))
2619 gel_loc_turn4(i)=gel_loc_turn4(i)-(s1+s3)
2620 C Derivatives in gamma(i+1)
2621 call transpose2(EUgder(1,1,i+2),e2tder(1,1))
2622 call matvec2(ae3(1,1),Ub2der(1,i+2),auxvec(1))
2623 s2=scalar2(b1(1,iti1),auxvec(1))
2624 call matmat2(ae3(1,1),e2tder(1,1),auxmat(1,1))
2625 call matmat2(auxmat(1,1),e1t(1,1),pizda(1,1))
2626 s3=0.5d0*(pizda(1,1)+pizda(2,2))
2627 gel_loc_turn4(i+1)=gel_loc_turn4(i+1)-(s2+s3)
2628 C Derivatives in gamma(i+2)
2629 call transpose2(EUgder(1,1,i+3),e3tder(1,1))
2630 call matvec2(e1a(1,1),Ub2der(1,i+3),auxvec(1))
2631 s1=scalar2(b1(1,iti2),auxvec(1))
2632 call matmat2(a_temp(1,1),e3tder(1,1),auxmat(1,1))
2633 call matvec2(auxmat(1,1),Ub2(1,i+2),auxvec(1))
2634 s2=scalar2(b1(1,iti1),auxvec(1))
2635 call matmat2(auxmat(1,1),e2t(1,1),auxmat(1,1))
2636 call matmat2(auxmat(1,1),e1t(1,1),pizda(1,1))
2637 s3=0.5d0*(pizda(1,1)+pizda(2,2))
2638 gel_loc_turn4(i+2)=gel_loc_turn4(i+2)-(s1+s2+s3)
2639 C Cartesian derivatives
2640 C Derivatives of this turn contributions in DC(i+2)
2641 if (j.lt.nres-1) then
2643 a_temp(1,1)=agg(l,1)
2644 a_temp(1,2)=agg(l,2)
2645 a_temp(2,1)=agg(l,3)
2646 a_temp(2,2)=agg(l,4)
2647 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
2648 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
2649 s1=scalar2(b1(1,iti2),auxvec(1))
2650 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
2651 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
2652 s2=scalar2(b1(1,iti1),auxvec(1))
2653 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
2654 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
2655 s3=0.5d0*(pizda(1,1)+pizda(2,2))
2657 gcorr4_turn(l,i+2)=gcorr4_turn(l,i+2)-(s1+s2+s3)
2660 C Remaining derivatives of this turn contribution
2662 a_temp(1,1)=aggi(l,1)
2663 a_temp(1,2)=aggi(l,2)
2664 a_temp(2,1)=aggi(l,3)
2665 a_temp(2,2)=aggi(l,4)
2666 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
2667 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
2668 s1=scalar2(b1(1,iti2),auxvec(1))
2669 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
2670 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
2671 s2=scalar2(b1(1,iti1),auxvec(1))
2672 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
2673 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
2674 s3=0.5d0*(pizda(1,1)+pizda(2,2))
2675 gcorr4_turn(l,i)=gcorr4_turn(l,i)-(s1+s2+s3)
2676 a_temp(1,1)=aggi1(l,1)
2677 a_temp(1,2)=aggi1(l,2)
2678 a_temp(2,1)=aggi1(l,3)
2679 a_temp(2,2)=aggi1(l,4)
2680 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
2681 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
2682 s1=scalar2(b1(1,iti2),auxvec(1))
2683 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
2684 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
2685 s2=scalar2(b1(1,iti1),auxvec(1))
2686 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
2687 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
2688 s3=0.5d0*(pizda(1,1)+pizda(2,2))
2689 gcorr4_turn(l,i+1)=gcorr4_turn(l,i+1)-(s1+s2+s3)
2690 a_temp(1,1)=aggj(l,1)
2691 a_temp(1,2)=aggj(l,2)
2692 a_temp(2,1)=aggj(l,3)
2693 a_temp(2,2)=aggj(l,4)
2694 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
2695 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
2696 s1=scalar2(b1(1,iti2),auxvec(1))
2697 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
2698 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
2699 s2=scalar2(b1(1,iti1),auxvec(1))
2700 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
2701 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
2702 s3=0.5d0*(pizda(1,1)+pizda(2,2))
2703 gcorr4_turn(l,j)=gcorr4_turn(l,j)-(s1+s2+s3)
2704 a_temp(1,1)=aggj1(l,1)
2705 a_temp(1,2)=aggj1(l,2)
2706 a_temp(2,1)=aggj1(l,3)
2707 a_temp(2,2)=aggj1(l,4)
2708 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
2709 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
2710 s1=scalar2(b1(1,iti2),auxvec(1))
2711 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
2712 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
2713 s2=scalar2(b1(1,iti1),auxvec(1))
2714 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
2715 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
2716 s3=0.5d0*(pizda(1,1)+pizda(2,2))
2717 gcorr4_turn(l,j1)=gcorr4_turn(l,j1)-(s1+s2+s3)
2723 C-----------------------------------------------------------------------------
2724 subroutine vecpr(u,v,w)
2725 implicit real*8(a-h,o-z)
2726 dimension u(3),v(3),w(3)
2727 w(1)=u(2)*v(3)-u(3)*v(2)
2728 w(2)=-u(1)*v(3)+u(3)*v(1)
2729 w(3)=u(1)*v(2)-u(2)*v(1)
2732 C-----------------------------------------------------------------------------
2733 subroutine unormderiv(u,ugrad,unorm,ungrad)
2734 C This subroutine computes the derivatives of a normalized vector u, given
2735 C the derivatives computed without normalization conditions, ugrad. Returns
2738 double precision u(3),ugrad(3,3),unorm,ungrad(3,3)
2739 double precision vec(3)
2740 double precision scalar
2742 c write (2,*) 'ugrad',ugrad
2745 vec(i)=scalar(ugrad(1,i),u(1))
2747 c write (2,*) 'vec',vec
2750 ungrad(j,i)=(ugrad(j,i)-u(j)*vec(i))*unorm
2753 c write (2,*) 'ungrad',ungrad
2756 C-----------------------------------------------------------------------------
2757 subroutine escp(evdw2,evdw2_14)
2759 C This subroutine calculates the excluded-volume interaction energy between
2760 C peptide-group centers and side chains and its gradient in virtual-bond and
2761 C side-chain vectors.
2763 implicit real*8 (a-h,o-z)
2764 include 'DIMENSIONS'
2765 include 'DIMENSIONS.ZSCOPT'
2766 include 'COMMON.GEO'
2767 include 'COMMON.VAR'
2768 include 'COMMON.LOCAL'
2769 include 'COMMON.CHAIN'
2770 include 'COMMON.DERIV'
2771 include 'COMMON.INTERACT'
2772 include 'COMMON.FFIELD'
2773 include 'COMMON.IOUNITS'
2777 cd print '(a)','Enter ESCP'
2778 c write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e,
2779 c & ' scal14',scal14
2780 do i=iatscp_s,iatscp_e
2782 c write (iout,*) "i",i," iteli",iteli," nscp_gr",nscp_gr(i),
2783 c & " iscp",(iscpstart(i,j),iscpend(i,j),j=1,nscp_gr(i))
2784 if (iteli.eq.0) goto 1225
2785 xi=0.5D0*(c(1,i)+c(1,i+1))
2786 yi=0.5D0*(c(2,i)+c(2,i+1))
2787 zi=0.5D0*(c(3,i)+c(3,i+1))
2789 do iint=1,nscp_gr(i)
2791 do j=iscpstart(i,iint),iscpend(i,iint)
2792 itypj=iabs(itype(j))
2793 C Uncomment following three lines for SC-p interactions
2797 C Uncomment following three lines for Ca-p interactions
2801 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
2803 e1=fac*fac*aad(itypj,iteli)
2804 e2=fac*bad(itypj,iteli)
2805 if (iabs(j-i) .le. 2) then
2808 evdw2_14=evdw2_14+e1+e2
2811 c write (iout,*) i,j,evdwij
2815 C Calculate contributions to the gradient in the virtual-bond and SC vectors.
2817 fac=-(evdwij+e1)*rrij
2822 cd write (iout,*) 'j<i'
2823 C Uncomment following three lines for SC-p interactions
2825 c gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
2828 cd write (iout,*) 'j>i'
2831 C Uncomment following line for SC-p interactions
2832 c gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
2836 gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
2840 cd write (iout,*) 'i=',i,' j=',j,' kstart=',kstart,' kend=',kend
2841 cd write (iout,*) ggg(1),ggg(2),ggg(3)
2844 gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
2854 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
2855 gradx_scp(j,i)=expon*gradx_scp(j,i)
2858 C******************************************************************************
2862 C To save time the factor EXPON has been extracted from ALL components
2863 C of GVDWC and GRADX. Remember to multiply them by this factor before further
2866 C******************************************************************************
2869 C--------------------------------------------------------------------------
2870 subroutine edis(ehpb)
2872 C Evaluate bridge-strain energy and its gradient in virtual-bond and SC vectors.
2874 implicit real*8 (a-h,o-z)
2875 include 'DIMENSIONS'
2876 include 'COMMON.SBRIDGE'
2877 include 'COMMON.CHAIN'
2878 include 'COMMON.DERIV'
2879 include 'COMMON.VAR'
2880 include 'COMMON.INTERACT'
2881 include 'COMMON.IOUNITS'
2884 cd write(iout,*)'edis: nhpb=',nhpb,' fbr=',fbr
2885 cd write(iout,*)'link_start=',link_start,' link_end=',link_end
2886 if (link_end.eq.0) return
2887 do i=link_start,link_end
2888 C If ihpb(i) and jhpb(i) > NRES, this is a SC-SC distance, otherwise a
2889 C CA-CA distance used in regularization of structure.
2892 C iii and jjj point to the residues for which the distance is assigned.
2893 if (ii.gt.nres) then
2900 c write (iout,*) "i",i," ii",ii," iii",iii," jj",jj," jjj",jjj,
2901 c & dhpb(i),dhpb1(i),forcon(i)
2902 C 24/11/03 AL: SS bridges handled separately because of introducing a specific
2903 C distance and angle dependent SS bond potential.
2904 if (ii.gt.nres .and. iabs(itype(iii)).eq.1 .and.
2905 & iabs(itype(jjj)).eq.1) then
2906 call ssbond_ene(iii,jjj,eij)
2908 cd write (iout,*) "eij",eij
2909 else if (ii.gt.nres .and. jj.gt.nres) then
2910 c Restraints from contact prediction
2912 if (dhpb1(i).gt.0.0d0) then
2913 ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
2914 fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
2915 c write (iout,*) "beta nmr",
2916 c & dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
2920 C Get the force constant corresponding to this distance.
2922 C Calculate the contribution to energy.
2923 ehpb=ehpb+waga*rdis*rdis
2924 c write (iout,*) "beta reg",dd,waga*rdis*rdis
2926 C Evaluate gradient.
2931 ggg(j)=fac*(c(j,jj)-c(j,ii))
2934 ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
2935 ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
2938 ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
2939 ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
2942 C Calculate the distance between the two points and its difference from the
2945 if (dhpb1(i).gt.0.0d0) then
2946 ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
2947 fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
2948 c write (iout,*) "alph nmr",
2949 c & dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
2952 C Get the force constant corresponding to this distance.
2954 C Calculate the contribution to energy.
2955 ehpb=ehpb+waga*rdis*rdis
2956 c write (iout,*) "alpha reg",dd,waga*rdis*rdis
2958 C Evaluate gradient.
2962 cd print *,'i=',i,' ii=',ii,' jj=',jj,' dhpb=',dhpb(i),' dd=',dd,
2963 cd & ' waga=',waga,' fac=',fac
2965 ggg(j)=fac*(c(j,jj)-c(j,ii))
2967 cd print '(i3,3(1pe14.5))',i,(ggg(j),j=1,3)
2968 C If this is a SC-SC distance, we need to calculate the contributions to the
2969 C Cartesian gradient in the SC vectors (ghpbx).
2972 ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
2973 ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
2977 ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
2978 ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
2985 C--------------------------------------------------------------------------
2986 subroutine ssbond_ene(i,j,eij)
2988 C Calculate the distance and angle dependent SS-bond potential energy
2989 C using a free-energy function derived based on RHF/6-31G** ab initio
2990 C calculations of diethyl disulfide.
2992 C A. Liwo and U. Kozlowska, 11/24/03
2994 implicit real*8 (a-h,o-z)
2995 include 'DIMENSIONS'
2996 include 'DIMENSIONS.ZSCOPT'
2997 include 'COMMON.SBRIDGE'
2998 include 'COMMON.CHAIN'
2999 include 'COMMON.DERIV'
3000 include 'COMMON.LOCAL'
3001 include 'COMMON.INTERACT'
3002 include 'COMMON.VAR'
3003 include 'COMMON.IOUNITS'
3004 double precision erij(3),dcosom1(3),dcosom2(3),gg(3)
3005 itypi=iabs(itype(i))
3009 dxi=dc_norm(1,nres+i)
3010 dyi=dc_norm(2,nres+i)
3011 dzi=dc_norm(3,nres+i)
3012 dsci_inv=dsc_inv(itypi)
3013 itypj=iabs(itype(j))
3014 dscj_inv=dsc_inv(itypj)
3018 dxj=dc_norm(1,nres+j)
3019 dyj=dc_norm(2,nres+j)
3020 dzj=dc_norm(3,nres+j)
3021 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
3026 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
3027 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
3028 om12=dxi*dxj+dyi*dyj+dzi*dzj
3030 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
3031 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
3037 deltat12=om2-om1+2.0d0
3039 eij=akcm*deltad*deltad+akth*(deltat1*deltat1+deltat2*deltat2)
3040 & +akct*deltad*deltat12
3041 & +v1ss*cosphi+v2ss*cosphi*cosphi+v3ss*cosphi*cosphi*cosphi
3042 c write(iout,*) i,j,"rij",rij,"d0cm",d0cm," akcm",akcm," akth",akth,
3043 c & " akct",akct," deltad",deltad," deltat",deltat1,deltat2,
3044 c & " deltat12",deltat12," eij",eij
3045 ed=2*akcm*deltad+akct*deltat12
3047 pom2=v1ss+2*v2ss*cosphi+3*v3ss*cosphi*cosphi
3048 eom1=-2*akth*deltat1-pom1-om2*pom2
3049 eom2= 2*akth*deltat2+pom1-om1*pom2
3052 gg(k)=ed*erij(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
3055 ghpbx(k,i)=ghpbx(k,i)-gg(k)
3056 & +(eom12*dc_norm(k,nres+j)+eom1*erij(k))*dsci_inv
3057 ghpbx(k,j)=ghpbx(k,j)+gg(k)
3058 & +(eom12*dc_norm(k,nres+i)+eom2*erij(k))*dscj_inv
3061 C Calculate the components of the gradient in DC and X
3065 ghpbc(l,k)=ghpbc(l,k)+gg(l)
3070 C--------------------------------------------------------------------------
3071 subroutine ebond(estr)
3073 c Evaluate the energy of stretching of the CA-CA and CA-SC virtual bonds
3075 implicit real*8 (a-h,o-z)
3076 include 'DIMENSIONS'
3077 include 'DIMENSIONS.ZSCOPT'
3078 include 'COMMON.LOCAL'
3079 include 'COMMON.GEO'
3080 include 'COMMON.INTERACT'
3081 include 'COMMON.DERIV'
3082 include 'COMMON.VAR'
3083 include 'COMMON.CHAIN'
3084 include 'COMMON.IOUNITS'
3085 include 'COMMON.NAMES'
3086 include 'COMMON.FFIELD'
3087 include 'COMMON.CONTROL'
3088 double precision u(3),ud(3)
3091 diff = vbld(i)-vbldp0
3092 c write (iout,*) i,vbld(i),vbldp0,diff,AKP*diff*diff
3095 gradb(j,i-1)=AKP*diff*dc(j,i-1)/vbld(i)
3100 c 09/18/07 AL: multimodal bond potential based on AM1 CA-SC PMF's included
3107 diff=vbld(i+nres)-vbldsc0(1,iti)
3108 c write (iout,*) i,iti,vbld(i+nres),vbldsc0(1,iti),diff,
3109 c & AKSC(1,iti),AKSC(1,iti)*diff*diff
3110 estr=estr+0.5d0*AKSC(1,iti)*diff*diff
3112 gradbx(j,i)=AKSC(1,iti)*diff*dc(j,i+nres)/vbld(i+nres)
3116 diff=vbld(i+nres)-vbldsc0(j,iti)
3117 ud(j)=aksc(j,iti)*diff
3118 u(j)=abond0(j,iti)+0.5d0*ud(j)*diff
3132 uprod2=uprod2*u(k)*u(k)
3136 usumsqder=usumsqder+ud(j)*uprod2
3138 c write (iout,*) i,iti,vbld(i+nres),(vbldsc0(j,iti),
3139 c & AKSC(j,iti),abond0(j,iti),u(j),j=1,nbi)
3140 estr=estr+uprod/usum
3142 gradbx(j,i)=usumsqder/(usum*usum)*dc(j,i+nres)/vbld(i+nres)
3150 C--------------------------------------------------------------------------
3151 subroutine ebend(etheta)
3153 C Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
3154 C angles gamma and its derivatives in consecutive thetas and gammas.
3156 implicit real*8 (a-h,o-z)
3157 include 'DIMENSIONS'
3158 include 'DIMENSIONS.ZSCOPT'
3159 include 'COMMON.LOCAL'
3160 include 'COMMON.GEO'
3161 include 'COMMON.INTERACT'
3162 include 'COMMON.DERIV'
3163 include 'COMMON.VAR'
3164 include 'COMMON.CHAIN'
3165 include 'COMMON.IOUNITS'
3166 include 'COMMON.NAMES'
3167 include 'COMMON.FFIELD'
3168 common /calcthet/ term1,term2,termm,diffak,ratak,
3169 & ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,
3170 & delthe0,sig0inv,sigtc,sigsqtc,delthec,it
3171 double precision y(2),z(2)
3173 time11=dexp(-2*time)
3176 c write (iout,*) "nres",nres
3177 c write (*,'(a,i2)') 'EBEND ICG=',icg
3178 c write (iout,*) ithet_start,ithet_end
3179 do i=ithet_start,ithet_end
3180 C Zero the energy function and its derivative at 0 or pi.
3181 call splinthet(theta(i),0.5d0*delta,ss,ssd)
3183 ichir1=isign(1,itype(i-2))
3184 ichir2=isign(1,itype(i))
3185 if (itype(i-2).eq.10) ichir1=isign(1,itype(i-1))
3186 if (itype(i).eq.10) ichir2=isign(1,itype(i-1))
3187 if (itype(i-1).eq.10) then
3188 itype1=isign(10,itype(i-2))
3189 ichir11=isign(1,itype(i-2))
3190 ichir12=isign(1,itype(i-2))
3191 itype2=isign(10,itype(i))
3192 ichir21=isign(1,itype(i))
3193 ichir22=isign(1,itype(i))
3195 c if (i.gt.ithet_start .and.
3196 c & (itel(i-1).eq.0 .or. itel(i-2).eq.0)) goto 1215
3197 c if (i.gt.3 .and. (i.le.4 .or. itel(i-3).ne.0)) then
3205 c if (i.lt.nres .and. itel(i).ne.0) then
3217 call proc_proc(phii,icrc)
3218 if (icrc.eq.1) phii=150.0
3232 call proc_proc(phii1,icrc)
3233 if (icrc.eq.1) phii1=150.0
3245 C Calculate the "mean" value of theta from the part of the distribution
3246 C dependent on the adjacent virtual-bond-valence angles (gamma1 & gamma2).
3247 C In following comments this theta will be referred to as t_c.
3248 thet_pred_mean=0.0d0
3250 athetk=athet(k,it,ichir1,ichir2)
3251 bthetk=bthet(k,it,ichir1,ichir2)
3253 athetk=athet(k,itype1,ichir11,ichir12)
3254 bthetk=bthet(k,itype2,ichir21,ichir22)
3256 thet_pred_mean=thet_pred_mean+athetk*y(k)+bthetk*z(k)
3258 c write (iout,*) "thet_pred_mean",thet_pred_mean
3259 dthett=thet_pred_mean*ssd
3260 thet_pred_mean=thet_pred_mean*ss+a0thet(it)
3261 c write (iout,*) "thet_pred_mean",thet_pred_mean
3262 C Derivatives of the "mean" values in gamma1 and gamma2.
3263 dthetg1=(-athet(1,it,ichir1,ichir2)*y(2)
3264 &+athet(2,it,ichir1,ichir2)*y(1))*ss
3265 dthetg2=(-bthet(1,it,ichir1,ichir2)*z(2)
3266 & +bthet(2,it,ichir1,ichir2)*z(1))*ss
3268 dthetg1=(-athet(1,itype1,ichir11,ichir12)*y(2)
3269 &+athet(2,itype1,ichir11,ichir12)*y(1))*ss
3270 dthetg2=(-bthet(1,itype2,ichir21,ichir22)*z(2)
3271 & +bthet(2,itype2,ichir21,ichir22)*z(1))*ss
3273 if (theta(i).gt.pi-delta) then
3274 call theteng(pi-delta,thet_pred_mean,theta0(it),f0,fprim0,
3276 call mixder(pi-delta,thet_pred_mean,theta0(it),fprim_tc0)
3277 call theteng(pi,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
3278 call spline1(theta(i),pi-delta,delta,f0,f1,fprim0,ethetai,
3280 call spline2(theta(i),pi-delta,delta,E_tc0,E_tc1,fprim_tc0,
3282 else if (theta(i).lt.delta) then
3283 call theteng(delta,thet_pred_mean,theta0(it),f0,fprim0,E_tc0)
3284 call theteng(0.0d0,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
3285 call spline1(theta(i),delta,-delta,f0,f1,fprim0,ethetai,
3287 call mixder(delta,thet_pred_mean,theta0(it),fprim_tc0)
3288 call spline2(theta(i),delta,-delta,E_tc0,E_tc1,fprim_tc0,
3291 call theteng(theta(i),thet_pred_mean,theta0(it),ethetai,
3294 etheta=etheta+ethetai
3295 c write (iout,'(2i3,3f8.3,f10.5)') i,it,rad2deg*theta(i),
3296 c & rad2deg*phii,rad2deg*phii1,ethetai
3297 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*E_tc*dthetg1
3298 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*E_tc*dthetg2
3299 gloc(nphi+i-2,icg)=wang*(E_theta+E_tc*dthett)
3302 C Ufff.... We've done all this!!!
3305 C---------------------------------------------------------------------------
3306 subroutine theteng(thetai,thet_pred_mean,theta0i,ethetai,E_theta,
3308 implicit real*8 (a-h,o-z)
3309 include 'DIMENSIONS'
3310 include 'COMMON.LOCAL'
3311 include 'COMMON.IOUNITS'
3312 common /calcthet/ term1,term2,termm,diffak,ratak,
3313 & ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,
3314 & delthe0,sig0inv,sigtc,sigsqtc,delthec,it
3315 C Calculate the contributions to both Gaussian lobes.
3316 C 6/6/97 - Deform the Gaussians using the factor of 1/(1+time)
3317 C The "polynomial part" of the "standard deviation" of this part of
3321 sig=sig*thet_pred_mean+polthet(j,it)
3323 C Derivative of the "interior part" of the "standard deviation of the"
3324 C gamma-dependent Gaussian lobe in t_c.
3325 sigtc=3*polthet(3,it)
3327 sigtc=sigtc*thet_pred_mean+j*polthet(j,it)
3330 C Set the parameters of both Gaussian lobes of the distribution.
3331 C "Standard deviation" of the gamma-dependent Gaussian lobe (sigtc)
3332 fac=sig*sig+sigc0(it)
3335 C Following variable (sigsqtc) is -(1/2)d[sigma(t_c)**(-2))]/dt_c
3336 sigsqtc=-4.0D0*sigcsq*sigtc
3337 c print *,i,sig,sigtc,sigsqtc
3338 C Following variable (sigtc) is d[sigma(t_c)]/dt_c
3339 sigtc=-sigtc/(fac*fac)
3340 C Following variable is sigma(t_c)**(-2)
3341 sigcsq=sigcsq*sigcsq
3343 sig0inv=1.0D0/sig0i**2
3344 delthec=thetai-thet_pred_mean
3345 delthe0=thetai-theta0i
3346 term1=-0.5D0*sigcsq*delthec*delthec
3347 term2=-0.5D0*sig0inv*delthe0*delthe0
3348 C Following fuzzy logic is to avoid underflows in dexp and subsequent INFs and
3349 C NaNs in taking the logarithm. We extract the largest exponent which is added
3350 C to the energy (this being the log of the distribution) at the end of energy
3351 C term evaluation for this virtual-bond angle.
3352 if (term1.gt.term2) then
3354 term2=dexp(term2-termm)
3358 term1=dexp(term1-termm)
3361 C The ratio between the gamma-independent and gamma-dependent lobes of
3362 C the distribution is a Gaussian function of thet_pred_mean too.
3363 diffak=gthet(2,it)-thet_pred_mean
3364 ratak=diffak/gthet(3,it)**2
3365 ak=dexp(gthet(1,it)-0.5D0*diffak*ratak)
3366 C Let's differentiate it in thet_pred_mean NOW.
3368 C Now put together the distribution terms to make complete distribution.
3369 termexp=term1+ak*term2
3370 termpre=sigc+ak*sig0i
3371 C Contribution of the bending energy from this theta is just the -log of
3372 C the sum of the contributions from the two lobes and the pre-exponential
3373 C factor. Simple enough, isn't it?
3374 ethetai=(-dlog(termexp)-termm+dlog(termpre))
3375 C NOW the derivatives!!!
3376 C 6/6/97 Take into account the deformation.
3377 E_theta=(delthec*sigcsq*term1
3378 & +ak*delthe0*sig0inv*term2)/termexp
3379 E_tc=((sigtc+aktc*sig0i)/termpre
3380 & -((delthec*sigcsq+delthec*delthec*sigsqtc)*term1+
3381 & aktc*term2)/termexp)
3384 c-----------------------------------------------------------------------------
3385 subroutine mixder(thetai,thet_pred_mean,theta0i,E_tc_t)
3386 implicit real*8 (a-h,o-z)
3387 include 'DIMENSIONS'
3388 include 'COMMON.LOCAL'
3389 include 'COMMON.IOUNITS'
3390 common /calcthet/ term1,term2,termm,diffak,ratak,
3391 & ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,
3392 & delthe0,sig0inv,sigtc,sigsqtc,delthec,it
3393 delthec=thetai-thet_pred_mean
3394 delthe0=thetai-theta0i
3395 C "Thank you" to MAPLE (probably spared one day of hand-differentiation).
3396 t3 = thetai-thet_pred_mean
3400 t14 = t12+t6*sigsqtc
3402 t21 = thetai-theta0i
3408 E_tc_t = -((sigcsq+2.D0*t3*sigsqtc)*t9-t14*sigcsq*t3*t16*t9
3409 & -aktc*sig0inv*t27)/t32+(t14*t9+aktc*t26)/t40
3410 & *(-t12*t9-ak*sig0inv*t27)
3414 C--------------------------------------------------------------------------
3415 subroutine ebend(etheta)
3417 C Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
3418 C angles gamma and its derivatives in consecutive thetas and gammas.
3419 C ab initio-derived potentials from
3420 c Kozlowska et al., J. Phys.: Condens. Matter 19 (2007) 285203
3422 implicit real*8 (a-h,o-z)
3423 include 'DIMENSIONS'
3424 include 'DIMENSIONS.ZSCOPT'
3425 include 'COMMON.LOCAL'
3426 include 'COMMON.GEO'
3427 include 'COMMON.INTERACT'
3428 include 'COMMON.DERIV'
3429 include 'COMMON.VAR'
3430 include 'COMMON.CHAIN'
3431 include 'COMMON.IOUNITS'
3432 include 'COMMON.NAMES'
3433 include 'COMMON.FFIELD'
3434 include 'COMMON.CONTROL'
3435 double precision coskt(mmaxtheterm),sinkt(mmaxtheterm),
3436 & cosph1(maxsingle),sinph1(maxsingle),cosph2(maxsingle),
3437 & sinph2(maxsingle),cosph1ph2(maxdouble,maxdouble),
3438 & sinph1ph2(maxdouble,maxdouble)
3439 logical lprn /.false./, lprn1 /.false./
3441 c write (iout,*) "ithetyp",(ithetyp(i),i=1,ntyp1)
3442 do i=ithet_start,ithet_end
3443 if (iabs(itype(i+1)).eq.20) iblock=2
3444 if (iabs(itype(i+1)).ne.20) iblock=1
3448 theti2=0.5d0*theta(i)
3449 ityp2=ithetyp((itype(i-1)))
3451 coskt(k)=dcos(k*theti2)
3452 sinkt(k)=dsin(k*theti2)
3457 if (phii.ne.phii) phii=150.0
3461 ityp1=ithetyp(iabs(itype(i-2)))
3463 cosph1(k)=dcos(k*phii)
3464 sinph1(k)=dsin(k*phii)
3477 if (phii1.ne.phii1) phii1=150.0
3482 ityp3=ithetyp((itype(i)))
3484 cosph2(k)=dcos(k*phii1)
3485 sinph2(k)=dsin(k*phii1)
3495 c write (iout,*) "i",i," ityp1",itype(i-2),ityp1,
3496 c & " ityp2",itype(i-1),ityp2," ityp3",itype(i),ityp3
3498 ethetai=aa0thet(ityp1,ityp2,ityp3,iblock)
3501 ccl=cosph1(l)*cosph2(k-l)
3502 ssl=sinph1(l)*sinph2(k-l)
3503 scl=sinph1(l)*cosph2(k-l)
3504 csl=cosph1(l)*sinph2(k-l)
3505 cosph1ph2(l,k)=ccl-ssl
3506 cosph1ph2(k,l)=ccl+ssl
3507 sinph1ph2(l,k)=scl+csl
3508 sinph1ph2(k,l)=scl-csl
3512 write (iout,*) "i",i," ityp1",ityp1," ityp2",ityp2,
3513 & " ityp3",ityp3," theti2",theti2," phii",phii," phii1",phii1
3514 write (iout,*) "coskt and sinkt"
3516 write (iout,*) k,coskt(k),sinkt(k)
3520 ethetai=ethetai+aathet(k,ityp1,ityp2,ityp3,iblock)*sinkt(k)
3521 dethetai=dethetai+0.5d0*k*aathet(k,ityp1,ityp2,ityp3,iblock)
3524 & write (iout,*) "k",k," aathet",aathet(k,ityp1,ityp2,ityp3,
3526 & " ethetai",ethetai
3529 write (iout,*) "cosph and sinph"
3531 write (iout,*) k,cosph1(k),sinph1(k),cosph2(k),sinph2(k)
3533 write (iout,*) "cosph1ph2 and sinph2ph2"
3536 write (iout,*) l,k,cosph1ph2(l,k),cosph1ph2(k,l),
3537 & sinph1ph2(l,k),sinph1ph2(k,l)
3540 write(iout,*) "ethetai",ethetai
3544 aux=bbthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph1(k)
3545 & +ccthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph1(k)
3546 & +ddthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph2(k)
3547 & +eethet(k,m,ityp1,ityp2,ityp3,iblock)*sinph2(k)
3548 ethetai=ethetai+sinkt(m)*aux
3549 dethetai=dethetai+0.5d0*m*aux*coskt(m)
3550 dephii=dephii+k*sinkt(m)*(
3551 & ccthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph1(k)-
3552 & bbthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph1(k))
3553 dephii1=dephii1+k*sinkt(m)*(
3554 & eethet(k,m,ityp1,ityp2,ityp3,iblock)*cosph2(k)-
3555 & ddthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph2(k))
3557 & write (iout,*) "m",m," k",k," bbthet",
3558 & bbthet(k,m,ityp1,ityp2,ityp3,iblock)," ccthet",
3559 & ccthet(k,m,ityp1,ityp2,ityp3,iblock)," ddthet",
3560 & ddthet(k,m,ityp1,ityp2,ityp3,iblock)," eethet",
3561 & eethet(k,m,ityp1,ityp2,ityp3,iblock)," ethetai",ethetai
3565 & write(iout,*) "ethetai",ethetai
3569 aux=ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)+
3570 & ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l)+
3571 & ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)+
3572 & ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)
3573 ethetai=ethetai+sinkt(m)*aux
3574 dethetai=dethetai+0.5d0*m*coskt(m)*aux
3575 dephii=dephii+l*sinkt(m)*(
3576 & -ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)-
3577 & ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)+
3578 & ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)+
3579 & ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l))
3580 dephii1=dephii1+(k-l)*sinkt(m)*(
3581 & -ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)+
3582 & ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)+
3583 & ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)-
3584 & ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l))
3586 write (iout,*) "m",m," k",k," l",l," ffthet",
3587 & ffthet(l,k,m,ityp1,ityp2,ityp3,iblock),
3588 & ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)," ggthet",
3589 & ggthet(l,k,m,ityp1,ityp2,ityp3,iblock),
3590 & ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)," ethetai",
3592 write (iout,*) cosph1ph2(l,k)*sinkt(m),
3593 & cosph1ph2(k,l)*sinkt(m),
3594 & sinph1ph2(l,k)*sinkt(m),sinph1ph2(k,l)*sinkt(m)
3600 if (lprn1) write (iout,'(i2,3f8.1,9h ethetai ,f10.5)')
3601 & i,theta(i)*rad2deg,phii*rad2deg,
3602 & phii1*rad2deg,ethetai
3603 etheta=etheta+ethetai
3604 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*dephii
3605 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*dephii1
3606 gloc(nphi+i-2,icg)=wang*dethetai
3612 c-----------------------------------------------------------------------------
3613 subroutine esc(escloc)
3614 C Calculate the local energy of a side chain and its derivatives in the
3615 C corresponding virtual-bond valence angles THETA and the spherical angles
3617 implicit real*8 (a-h,o-z)
3618 include 'DIMENSIONS'
3619 include 'DIMENSIONS.ZSCOPT'
3620 include 'COMMON.GEO'
3621 include 'COMMON.LOCAL'
3622 include 'COMMON.VAR'
3623 include 'COMMON.INTERACT'
3624 include 'COMMON.DERIV'
3625 include 'COMMON.CHAIN'
3626 include 'COMMON.IOUNITS'
3627 include 'COMMON.NAMES'
3628 include 'COMMON.FFIELD'
3629 double precision x(3),dersc(3),xemp(3),dersc0(3),dersc1(3),
3630 & ddersc0(3),ddummy(3),xtemp(3),temp(3)
3631 common /sccalc/ time11,time12,time112,theti,it,nlobit
3634 c write (iout,'(a)') 'ESC'
3635 do i=loc_start,loc_end
3637 if (it.eq.10) goto 1
3638 nlobit=nlob(iabs(it))
3639 c print *,'i=',i,' it=',it,' nlobit=',nlobit
3640 c write (iout,*) 'i=',i,' ssa=',ssa,' ssad=',ssad
3641 theti=theta(i+1)-pipol
3645 c write (iout,*) "i",i," x",x(1),x(2),x(3)
3647 if (x(2).gt.pi-delta) then
3651 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
3653 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
3654 call spline1(x(2),pi-delta,delta,escloci0,escloci1,dersc0(2),
3656 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),
3657 & ddersc0(1),dersc(1))
3658 call spline2(x(2),pi-delta,delta,dersc0(3),dersc1(3),
3659 & ddersc0(3),dersc(3))
3661 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
3663 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
3664 call spline1(x(2),pi-delta,delta,esclocbi0,esclocbi1,
3665 & dersc0(2),esclocbi,dersc02)
3666 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),
3668 call splinthet(x(2),0.5d0*delta,ss,ssd)
3673 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
3675 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
3676 c write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
3678 escloci=ss*escloci+(1.0d0-ss)*esclocbi
3680 c write (iout,*) escloci
3681 else if (x(2).lt.delta) then
3685 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
3687 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
3688 call spline1(x(2),delta,-delta,escloci0,escloci1,dersc0(2),
3690 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),
3691 & ddersc0(1),dersc(1))
3692 call spline2(x(2),delta,-delta,dersc0(3),dersc1(3),
3693 & ddersc0(3),dersc(3))
3695 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
3697 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
3698 call spline1(x(2),delta,-delta,esclocbi0,esclocbi1,
3699 & dersc0(2),esclocbi,dersc02)
3700 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),
3705 call splinthet(x(2),0.5d0*delta,ss,ssd)
3707 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
3709 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
3710 c write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
3712 escloci=ss*escloci+(1.0d0-ss)*esclocbi
3713 c write (iout,*) escloci
3715 call enesc(x,escloci,dersc,ddummy,.false.)
3718 escloc=escloc+escloci
3719 c write (iout,*) 'i=',i,' escloci=',escloci,' dersc=',dersc
3721 gloc(nphi+i-1,icg)=gloc(nphi+i-1,icg)+
3723 gloc(ialph(i,1),icg)=wscloc*dersc(2)
3724 gloc(ialph(i,1)+nside,icg)=wscloc*dersc(3)
3729 C---------------------------------------------------------------------------
3730 subroutine enesc(x,escloci,dersc,ddersc,mixed)
3731 implicit real*8 (a-h,o-z)
3732 include 'DIMENSIONS'
3733 include 'COMMON.GEO'
3734 include 'COMMON.LOCAL'
3735 include 'COMMON.IOUNITS'
3736 common /sccalc/ time11,time12,time112,theti,it,nlobit
3737 double precision x(3),z(3),Ax(3,maxlob,-1:1),dersc(3),ddersc(3)
3738 double precision contr(maxlob,-1:1)
3740 c write (iout,*) 'it=',it,' nlobit=',nlobit
3744 if (mixed) ddersc(j)=0.0d0
3748 C Because of periodicity of the dependence of the SC energy in omega we have
3749 C to add up the contributions from x(3)-2*pi, x(3), and x(3+2*pi).
3750 C To avoid underflows, first compute & store the exponents.
3758 z(k)=x(k)-censc(k,j,it)
3763 Axk=Axk+gaussc(l,k,j,it)*z(l)
3769 expfac=expfac+Ax(k,j,iii)*z(k)
3777 C As in the case of ebend, we want to avoid underflows in exponentiation and
3778 C subsequent NaNs and INFs in energy calculation.
3779 C Find the largest exponent
3783 if (emin.gt.contr(j,iii)) emin=contr(j,iii)
3787 cd print *,'it=',it,' emin=',emin
3789 C Compute the contribution to SC energy and derivatives
3793 expfac=dexp(bsc(j,iabs(it))-0.5D0*contr(j,iii)+emin)
3794 cd print *,'j=',j,' expfac=',expfac
3795 escloc_i=escloc_i+expfac
3797 dersc(k)=dersc(k)+Ax(k,j,iii)*expfac
3801 ddersc(k)=ddersc(k)+(-Ax(2,j,iii)*Ax(k,j,iii)
3802 & +gaussc(k,2,j,it))*expfac
3809 dersc(1)=dersc(1)/cos(theti)**2
3810 ddersc(1)=ddersc(1)/cos(theti)**2
3813 escloci=-(dlog(escloc_i)-emin)
3815 dersc(j)=dersc(j)/escloc_i
3819 ddersc(j)=(ddersc(j)/escloc_i+dersc(2)*dersc(j))
3824 C------------------------------------------------------------------------------
3825 subroutine enesc_bound(x,escloci,dersc,dersc12,mixed)
3826 implicit real*8 (a-h,o-z)
3827 include 'DIMENSIONS'
3828 include 'COMMON.GEO'
3829 include 'COMMON.LOCAL'
3830 include 'COMMON.IOUNITS'
3831 common /sccalc/ time11,time12,time112,theti,it,nlobit
3832 double precision x(3),z(3),Ax(3,maxlob),dersc(3)
3833 double precision contr(maxlob)
3844 z(k)=x(k)-censc(k,j,it)
3850 Axk=Axk+gaussc(l,k,j,it)*z(l)
3856 expfac=expfac+Ax(k,j)*z(k)
3861 C As in the case of ebend, we want to avoid underflows in exponentiation and
3862 C subsequent NaNs and INFs in energy calculation.
3863 C Find the largest exponent
3866 if (emin.gt.contr(j)) emin=contr(j)
3870 C Compute the contribution to SC energy and derivatives
3874 expfac=dexp(bsc(j,iabs(it))-0.5D0*contr(j)+emin)
3875 escloc_i=escloc_i+expfac
3877 dersc(k)=dersc(k)+Ax(k,j)*expfac
3879 if (mixed) dersc12=dersc12+(-Ax(2,j)*Ax(1,j)
3880 & +gaussc(1,2,j,it))*expfac
3884 dersc(1)=dersc(1)/cos(theti)**2
3885 dersc12=dersc12/cos(theti)**2
3886 escloci=-(dlog(escloc_i)-emin)
3888 dersc(j)=dersc(j)/escloc_i
3890 if (mixed) dersc12=(dersc12/escloc_i+dersc(2)*dersc(1))
3894 c----------------------------------------------------------------------------------
3895 subroutine esc(escloc)
3896 C Calculate the local energy of a side chain and its derivatives in the
3897 C corresponding virtual-bond valence angles THETA and the spherical angles
3898 C ALPHA and OMEGA derived from AM1 all-atom calculations.
3899 C added by Urszula Kozlowska. 07/11/2007
3901 implicit real*8 (a-h,o-z)
3902 include 'DIMENSIONS'
3903 include 'DIMENSIONS.ZSCOPT'
3904 include 'COMMON.GEO'
3905 include 'COMMON.LOCAL'
3906 include 'COMMON.VAR'
3907 include 'COMMON.SCROT'
3908 include 'COMMON.INTERACT'
3909 include 'COMMON.DERIV'
3910 include 'COMMON.CHAIN'
3911 include 'COMMON.IOUNITS'
3912 include 'COMMON.NAMES'
3913 include 'COMMON.FFIELD'
3914 include 'COMMON.CONTROL'
3915 include 'COMMON.VECTORS'
3916 double precision x_prime(3),y_prime(3),z_prime(3)
3917 & , sumene,dsc_i,dp2_i,x(65),
3918 & xx,yy,zz,sumene1,sumene2,sumene3,sumene4,s1,s1_6,s2,s2_6,
3919 & de_dxx,de_dyy,de_dzz,de_dt
3920 double precision s1_t,s1_6_t,s2_t,s2_6_t
3922 & dXX_Ci1(3),dYY_Ci1(3),dZZ_Ci1(3),dXX_Ci(3),
3923 & dYY_Ci(3),dZZ_Ci(3),dXX_XYZ(3),dYY_XYZ(3),dZZ_XYZ(3),
3924 & dt_dCi(3),dt_dCi1(3)
3925 common /sccalc/ time11,time12,time112,theti,it,nlobit
3928 do i=loc_start,loc_end
3929 costtab(i+1) =dcos(theta(i+1))
3930 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
3931 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
3932 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
3933 cosfac2=0.5d0/(1.0d0+costtab(i+1))
3934 cosfac=dsqrt(cosfac2)
3935 sinfac2=0.5d0/(1.0d0-costtab(i+1))
3936 sinfac=dsqrt(sinfac2)
3938 if (it.eq.10) goto 1
3940 C Compute the axes of tghe local cartesian coordinates system; store in
3941 c x_prime, y_prime and z_prime
3948 C write(2,*) "dc_norm", dc_norm(1,i+nres),dc_norm(2,i+nres),
3949 C & dc_norm(3,i+nres)
3951 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
3952 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
3955 z_prime(j) = -uz(j,i-1)*dsign(1.0d0,dfloat(itype(i)))
3958 c write (2,*) "x_prime",(x_prime(j),j=1,3)
3959 c write (2,*) "y_prime",(y_prime(j),j=1,3)
3960 c write (2,*) "z_prime",(z_prime(j),j=1,3)
3961 c write (2,*) "xx",scalar(x_prime(1),x_prime(1)),
3962 c & " xy",scalar(x_prime(1),y_prime(1)),
3963 c & " xz",scalar(x_prime(1),z_prime(1)),
3964 c & " yy",scalar(y_prime(1),y_prime(1)),
3965 c & " yz",scalar(y_prime(1),z_prime(1)),
3966 c & " zz",scalar(z_prime(1),z_prime(1))
3968 C Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
3969 C to local coordinate system. Store in xx, yy, zz.
3975 xx = xx + x_prime(j)*dc_norm(j,i+nres)
3976 yy = yy + y_prime(j)*dc_norm(j,i+nres)
3977 zz = zz + z_prime(j)*dc_norm(j,i+nres)
3984 C Compute the energy of the ith side cbain
3986 c write (2,*) "xx",xx," yy",yy," zz",zz
3989 x(j) = sc_parmin(j,it)
3992 Cc diagnostics - remove later
3994 yy1 = dsin(alph(2))*dcos(omeg(2))
3995 zz1 = -dsign(1.0d0,itype(i))*dsin(alph(2))*dsin(omeg(2))
3996 write(2,'(3f8.1,3f9.3,1x,3f9.3)')
3997 & alph(2)*rad2deg,omeg(2)*rad2deg,theta(3)*rad2deg,xx,yy,zz,
3999 C," --- ", xx_w,yy_w,zz_w
4002 sumene1= x(1)+ x(2)*xx+ x(3)*yy+ x(4)*zz+ x(5)*xx**2
4003 & + x(6)*yy**2+ x(7)*zz**2+ x(8)*xx*zz+ x(9)*xx*yy
4005 sumene2= x(11) + x(12)*xx + x(13)*yy + x(14)*zz + x(15)*xx**2
4006 & + x(16)*yy**2 + x(17)*zz**2 + x(18)*xx*zz + x(19)*xx*yy
4008 sumene3= x(21) +x(22)*xx +x(23)*yy +x(24)*zz +x(25)*xx**2
4009 & +x(26)*yy**2 +x(27)*zz**2 +x(28)*xx*zz +x(29)*xx*yy
4010 & +x(30)*yy*zz +x(31)*xx**3 +x(32)*yy**3 +x(33)*zz**3
4011 & +x(34)*(xx**2)*yy +x(35)*(xx**2)*zz +x(36)*(yy**2)*xx
4012 & +x(37)*(yy**2)*zz +x(38)*(zz**2)*xx +x(39)*(zz**2)*yy
4014 sumene4= x(41) +x(42)*xx +x(43)*yy +x(44)*zz +x(45)*xx**2
4015 & +x(46)*yy**2 +x(47)*zz**2 +x(48)*xx*zz +x(49)*xx*yy
4016 & +x(50)*yy*zz +x(51)*xx**3 +x(52)*yy**3 +x(53)*zz**3
4017 & +x(54)*(xx**2)*yy +x(55)*(xx**2)*zz +x(56)*(yy**2)*xx
4018 & +x(57)*(yy**2)*zz +x(58)*(zz**2)*xx +x(59)*(zz**2)*yy
4020 dsc_i = 0.743d0+x(61)
4022 dscp1=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i
4023 & *(xx*cost2tab(i+1)+yy*sint2tab(i+1)))
4024 dscp2=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i
4025 & *(xx*cost2tab(i+1)-yy*sint2tab(i+1)))
4026 s1=(1+x(63))/(0.1d0 + dscp1)
4027 s1_6=(1+x(64))/(0.1d0 + dscp1**6)
4028 s2=(1+x(65))/(0.1d0 + dscp2)
4029 s2_6=(1+x(65))/(0.1d0 + dscp2**6)
4030 sumene = ( sumene3*sint2tab(i+1) + sumene1)*(s1+s1_6)
4031 & + (sumene4*cost2tab(i+1) +sumene2)*(s2+s2_6)
4032 c write(2,'(i2," sumene",7f9.3)') i,sumene1,sumene2,sumene3,
4034 c & dscp1,dscp2,sumene
4035 c sumene = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
4036 escloc = escloc + sumene
4037 c write (2,*) "escloc",escloc
4038 if (.not. calc_grad) goto 1
4041 C This section to check the numerical derivatives of the energy of ith side
4042 C chain in xx, yy, zz, and theta. Use the -DDEBUG compiler option or insert
4043 C #define DEBUG in the code to turn it on.
4045 write (2,*) "sumene =",sumene
4049 write (2,*) xx,yy,zz
4050 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
4051 de_dxx_num=(sumenep-sumene)/aincr
4053 write (2,*) "xx+ sumene from enesc=",sumenep
4056 write (2,*) xx,yy,zz
4057 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
4058 de_dyy_num=(sumenep-sumene)/aincr
4060 write (2,*) "yy+ sumene from enesc=",sumenep
4063 write (2,*) xx,yy,zz
4064 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
4065 de_dzz_num=(sumenep-sumene)/aincr
4067 write (2,*) "zz+ sumene from enesc=",sumenep
4068 costsave=cost2tab(i+1)
4069 sintsave=sint2tab(i+1)
4070 cost2tab(i+1)=dcos(0.5d0*(theta(i+1)+aincr))
4071 sint2tab(i+1)=dsin(0.5d0*(theta(i+1)+aincr))
4072 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
4073 de_dt_num=(sumenep-sumene)/aincr
4074 write (2,*) " t+ sumene from enesc=",sumenep
4075 cost2tab(i+1)=costsave
4076 sint2tab(i+1)=sintsave
4077 C End of diagnostics section.
4080 C Compute the gradient of esc
4082 pom_s1=(1.0d0+x(63))/(0.1d0 + dscp1)**2
4083 pom_s16=6*(1.0d0+x(64))/(0.1d0 + dscp1**6)**2
4084 pom_s2=(1.0d0+x(65))/(0.1d0 + dscp2)**2
4085 pom_s26=6*(1.0d0+x(65))/(0.1d0 + dscp2**6)**2
4086 pom_dx=dsc_i*dp2_i*cost2tab(i+1)
4087 pom_dy=dsc_i*dp2_i*sint2tab(i+1)
4088 pom_dt1=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)-yy*cost2tab(i+1))
4089 pom_dt2=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)+yy*cost2tab(i+1))
4090 pom1=(sumene3*sint2tab(i+1)+sumene1)
4091 & *(pom_s1/dscp1+pom_s16*dscp1**4)
4092 pom2=(sumene4*cost2tab(i+1)+sumene2)
4093 & *(pom_s2/dscp2+pom_s26*dscp2**4)
4094 sumene1x=x(2)+2*x(5)*xx+x(8)*zz+ x(9)*yy
4095 sumene3x=x(22)+2*x(25)*xx+x(28)*zz+x(29)*yy+3*x(31)*xx**2
4096 & +2*x(34)*xx*yy +2*x(35)*xx*zz +x(36)*(yy**2) +x(38)*(zz**2)
4098 sumene2x=x(12)+2*x(15)*xx+x(18)*zz+ x(19)*yy
4099 sumene4x=x(42)+2*x(45)*xx +x(48)*zz +x(49)*yy +3*x(51)*xx**2
4100 & +2*x(54)*xx*yy+2*x(55)*xx*zz+x(56)*(yy**2)+x(58)*(zz**2)
4102 de_dxx =(sumene1x+sumene3x*sint2tab(i+1))*(s1+s1_6)
4103 & +(sumene2x+sumene4x*cost2tab(i+1))*(s2+s2_6)
4104 & +(pom1+pom2)*pom_dx
4106 write(2,*), "de_dxx = ", de_dxx,de_dxx_num
4109 sumene1y=x(3) + 2*x(6)*yy + x(9)*xx + x(10)*zz
4110 sumene3y=x(23) +2*x(26)*yy +x(29)*xx +x(30)*zz +3*x(32)*yy**2
4111 & +x(34)*(xx**2) +2*x(36)*yy*xx +2*x(37)*yy*zz +x(39)*(zz**2)
4113 sumene2y=x(13) + 2*x(16)*yy + x(19)*xx + x(20)*zz
4114 sumene4y=x(43)+2*x(46)*yy+x(49)*xx +x(50)*zz
4115 & +3*x(52)*yy**2+x(54)*xx**2+2*x(56)*yy*xx +2*x(57)*yy*zz
4116 & +x(59)*zz**2 +x(60)*xx*zz
4117 de_dyy =(sumene1y+sumene3y*sint2tab(i+1))*(s1+s1_6)
4118 & +(sumene2y+sumene4y*cost2tab(i+1))*(s2+s2_6)
4119 & +(pom1-pom2)*pom_dy
4121 write(2,*), "de_dyy = ", de_dyy,de_dyy_num
4124 de_dzz =(x(24) +2*x(27)*zz +x(28)*xx +x(30)*yy
4125 & +3*x(33)*zz**2 +x(35)*xx**2 +x(37)*yy**2 +2*x(38)*zz*xx
4126 & +2*x(39)*zz*yy +x(40)*xx*yy)*sint2tab(i+1)*(s1+s1_6)
4127 & +(x(4) + 2*x(7)*zz+ x(8)*xx + x(10)*yy)*(s1+s1_6)
4128 & +(x(44)+2*x(47)*zz +x(48)*xx +x(50)*yy +3*x(53)*zz**2
4129 & +x(55)*xx**2 +x(57)*(yy**2)+2*x(58)*zz*xx +2*x(59)*zz*yy
4130 & +x(60)*xx*yy)*cost2tab(i+1)*(s2+s2_6)
4131 & + ( x(14) + 2*x(17)*zz+ x(18)*xx + x(20)*yy)*(s2+s2_6)
4133 write(2,*), "de_dzz = ", de_dzz,de_dzz_num
4136 de_dt = 0.5d0*sumene3*cost2tab(i+1)*(s1+s1_6)
4137 & -0.5d0*sumene4*sint2tab(i+1)*(s2+s2_6)
4138 & +pom1*pom_dt1+pom2*pom_dt2
4140 write(2,*), "de_dt = ", de_dt,de_dt_num
4144 cossc=scalar(dc_norm(1,i),dc_norm(1,i+nres))
4145 cossc1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
4146 cosfac2xx=cosfac2*xx
4147 sinfac2yy=sinfac2*yy
4149 dt_dCi(k) = -(dc_norm(k,i-1)+costtab(i+1)*dc_norm(k,i))*
4151 dt_dCi1(k)= -(dc_norm(k,i)+costtab(i+1)*dc_norm(k,i-1))*
4153 pom=(dC_norm(k,i+nres)-cossc*dC_norm(k,i))*vbld_inv(i+1)
4154 pom1=(dC_norm(k,i+nres)-cossc1*dC_norm(k,i-1))*vbld_inv(i)
4155 c write (iout,*) "i",i," k",k," pom",pom," pom1",pom1,
4156 c & " dt_dCi",dt_dCi(k)," dt_dCi1",dt_dCi1(k)
4157 c write (iout,*) "dC_norm",(dC_norm(j,i),j=1,3),
4158 c & (dC_norm(j,i-1),j=1,3)," vbld_inv",vbld_inv(i+1),vbld_inv(i)
4159 dXX_Ci(k)=pom*cosfac-dt_dCi(k)*cosfac2xx
4160 dXX_Ci1(k)=-pom1*cosfac-dt_dCi1(k)*cosfac2xx
4161 dYY_Ci(k)=pom*sinfac+dt_dCi(k)*sinfac2yy
4162 dYY_Ci1(k)=pom1*sinfac+dt_dCi1(k)*sinfac2yy
4166 dZZ_Ci(k)=dZZ_Ci(k)-uzgrad(j,k,2,i-1)
4167 & *dsign(1.0d0,dfloat(itype(i)))*dC_norm(j,i+nres)
4168 dZZ_Ci1(k)=dZZ_Ci1(k)-uzgrad(j,k,1,i-1)
4169 & *dsign(1.0d0,dfloat(itype(i)))*dC_norm(j,i+nres)
4173 dXX_XYZ(k)=vbld_inv(i+nres)*(x_prime(k)-xx*dC_norm(k,i+nres))
4174 dYY_XYZ(k)=vbld_inv(i+nres)*(y_prime(k)-yy*dC_norm(k,i+nres))
4175 dZZ_XYZ(k)=vbld_inv(i+nres)*(z_prime(k)-zz*dC_norm(k,i+nres))
4177 dt_dCi(k) = -dt_dCi(k)/sinttab(i+1)
4178 dt_dCi1(k)= -dt_dCi1(k)/sinttab(i+1)
4182 dXX_Ctab(k,i)=dXX_Ci(k)
4183 dXX_C1tab(k,i)=dXX_Ci1(k)
4184 dYY_Ctab(k,i)=dYY_Ci(k)
4185 dYY_C1tab(k,i)=dYY_Ci1(k)
4186 dZZ_Ctab(k,i)=dZZ_Ci(k)
4187 dZZ_C1tab(k,i)=dZZ_Ci1(k)
4188 dXX_XYZtab(k,i)=dXX_XYZ(k)
4189 dYY_XYZtab(k,i)=dYY_XYZ(k)
4190 dZZ_XYZtab(k,i)=dZZ_XYZ(k)
4194 c write (iout,*) "k",k," dxx_ci1",dxx_ci1(k)," dyy_ci1",
4195 c & dyy_ci1(k)," dzz_ci1",dzz_ci1(k)
4196 c write (iout,*) "k",k," dxx_ci",dxx_ci(k)," dyy_ci",
4197 c & dyy_ci(k)," dzz_ci",dzz_ci(k)
4198 c write (iout,*) "k",k," dt_dci",dt_dci(k)," dt_dci",
4200 c write (iout,*) "k",k," dxx_XYZ",dxx_XYZ(k)," dyy_XYZ",
4201 c & dyy_XYZ(k)," dzz_XYZ",dzz_XYZ(k)
4202 gscloc(k,i-1)=gscloc(k,i-1)+de_dxx*dxx_ci1(k)
4203 & +de_dyy*dyy_ci1(k)+de_dzz*dzz_ci1(k)+de_dt*dt_dCi1(k)
4204 gscloc(k,i)=gscloc(k,i)+de_dxx*dxx_Ci(k)
4205 & +de_dyy*dyy_Ci(k)+de_dzz*dzz_Ci(k)+de_dt*dt_dCi(k)
4206 gsclocx(k,i)= de_dxx*dxx_XYZ(k)
4207 & +de_dyy*dyy_XYZ(k)+de_dzz*dzz_XYZ(k)
4209 c write(iout,*) "ENERGY GRAD = ", (gscloc(k,i-1),k=1,3),
4210 c & (gscloc(k,i),k=1,3),(gsclocx(k,i),k=1,3)
4212 C to check gradient call subroutine check_grad
4219 c------------------------------------------------------------------------------
4220 subroutine gcont(rij,r0ij,eps0ij,delta,fcont,fprimcont)
4222 C This procedure calculates two-body contact function g(rij) and its derivative:
4225 C g(rij) = esp0ij*(-0.9375*x+0.625*x**3-0.1875*x**5) ! -1 =< x =< 1
4228 C where x=(rij-r0ij)/delta
4230 C rij - interbody distance, r0ij - contact distance, eps0ij - contact energy
4233 double precision rij,r0ij,eps0ij,fcont,fprimcont
4234 double precision x,x2,x4,delta
4238 if (x.lt.-1.0D0) then
4241 else if (x.le.1.0D0) then
4244 fcont=eps0ij*(x*(-0.9375D0+0.6250D0*x2-0.1875D0*x4)+0.5D0)
4245 fprimcont=eps0ij * (-0.9375D0+1.8750D0*x2-0.9375D0*x4)/delta
4252 c------------------------------------------------------------------------------
4253 subroutine splinthet(theti,delta,ss,ssder)
4254 implicit real*8 (a-h,o-z)
4255 include 'DIMENSIONS'
4256 include 'DIMENSIONS.ZSCOPT'
4257 include 'COMMON.VAR'
4258 include 'COMMON.GEO'
4261 if (theti.gt.pipol) then
4262 call gcont(theti,thetup,1.0d0,delta,ss,ssder)
4264 call gcont(-theti,-thetlow,1.0d0,delta,ss,ssder)
4269 c------------------------------------------------------------------------------
4270 subroutine spline1(x,x0,delta,f0,f1,fprim0,f,fprim)
4272 double precision x,x0,delta,f0,f1,fprim0,f,fprim
4273 double precision ksi,ksi2,ksi3,a1,a2,a3
4274 a1=fprim0*delta/(f1-f0)
4280 f=f0+(f1-f0)*ksi*(a1+ksi*(a2+a3*ksi))
4281 fprim=(f1-f0)/delta*(a1+ksi*(2*a2+3*ksi*a3))
4284 c------------------------------------------------------------------------------
4285 subroutine spline2(x,x0,delta,f0x,f1x,fprim0x,fx)
4287 double precision x,x0,delta,f0x,f1x,fprim0x,fx
4288 double precision ksi,ksi2,ksi3,a1,a2,a3
4293 a2=3*(f1x-f0x)-2*fprim0x*delta
4294 a3=fprim0x*delta-2*(f1x-f0x)
4295 fx=f0x+a1*ksi+a2*ksi2+a3*ksi3
4298 C-----------------------------------------------------------------------------
4300 C-----------------------------------------------------------------------------
4301 subroutine etor(etors,edihcnstr,fact)
4302 implicit real*8 (a-h,o-z)
4303 include 'DIMENSIONS'
4304 include 'DIMENSIONS.ZSCOPT'
4305 include 'COMMON.VAR'
4306 include 'COMMON.GEO'
4307 include 'COMMON.LOCAL'
4308 include 'COMMON.TORSION'
4309 include 'COMMON.INTERACT'
4310 include 'COMMON.DERIV'
4311 include 'COMMON.CHAIN'
4312 include 'COMMON.NAMES'
4313 include 'COMMON.IOUNITS'
4314 include 'COMMON.FFIELD'
4315 include 'COMMON.TORCNSTR'
4317 C Set lprn=.true. for debugging
4321 do i=iphi_start,iphi_end
4322 itori=itortyp(itype(i-2))
4323 itori1=itortyp(itype(i-1))
4326 C Proline-Proline pair is a special case...
4327 if (itori.eq.3 .and. itori1.eq.3) then
4328 if (phii.gt.-dwapi3) then
4330 fac=1.0D0/(1.0D0-cosphi)
4331 etorsi=v1(1,3,3)*fac
4332 etorsi=etorsi+etorsi
4333 etors=etors+etorsi-v1(1,3,3)
4334 gloci=gloci-3*fac*etorsi*dsin(3*phii)
4337 v1ij=v1(j+1,itori,itori1)
4338 v2ij=v2(j+1,itori,itori1)
4341 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
4342 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
4346 v1ij=v1(j,itori,itori1)
4347 v2ij=v2(j,itori,itori1)
4350 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
4351 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
4355 & write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)')
4356 & restyp(itype(i-2)),i-2,restyp(itype(i-1)),i-1,itori,itori1,
4357 & (v1(j,itori,itori1),j=1,6),(v2(j,itori,itori1),j=1,6)
4358 gloc(i-3,icg)=gloc(i-3,icg)+wtor*fact*gloci
4359 c write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
4361 ! 6/20/98 - dihedral angle constraints
4364 itori=idih_constr(i)
4367 if (difi.gt.drange(i)) then
4369 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
4370 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
4371 else if (difi.lt.-drange(i)) then
4373 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
4374 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
4376 ! write (iout,'(2i5,2f8.3,2e14.5)') i,itori,rad2deg*phii,
4377 ! & rad2deg*difi,0.25d0*ftors*difi**4,gloc(itori-3,icg)
4379 ! write (iout,*) 'edihcnstr',edihcnstr
4382 c------------------------------------------------------------------------------
4384 subroutine etor(etors,edihcnstr,fact)
4385 implicit real*8 (a-h,o-z)
4386 include 'DIMENSIONS'
4387 include 'DIMENSIONS.ZSCOPT'
4388 include 'COMMON.VAR'
4389 include 'COMMON.GEO'
4390 include 'COMMON.LOCAL'
4391 include 'COMMON.TORSION'
4392 include 'COMMON.INTERACT'
4393 include 'COMMON.DERIV'
4394 include 'COMMON.CHAIN'
4395 include 'COMMON.NAMES'
4396 include 'COMMON.IOUNITS'
4397 include 'COMMON.FFIELD'
4398 include 'COMMON.TORCNSTR'
4400 C Set lprn=.true. for debugging
4404 do i=iphi_start,iphi_end
4405 if (itel(i-2).eq.0 .or. itel(i-1).eq.0) goto 1215
4406 if (iabs(itype(i)).eq.20) then
4411 itori=itortyp(itype(i-2))
4412 itori1=itortyp(itype(i-1))
4415 C Regular cosine and sine terms
4416 do j=1,nterm(itori,itori1,iblock)
4417 v1ij=v1(j,itori,itori1,iblock)
4418 v2ij=v2(j,itori,itori1,iblock)
4421 etors=etors+v1ij*cosphi+v2ij*sinphi
4422 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
4426 C E = SUM ----------------------------------- - v1
4427 C [v2 cos(phi/2)+v3 sin(phi/2)]^2 + 1
4429 cosphi=dcos(0.5d0*phii)
4430 sinphi=dsin(0.5d0*phii)
4431 do j=1,nlor(itori,itori1,iblock)
4432 vl1ij=vlor1(j,itori,itori1)
4433 vl2ij=vlor2(j,itori,itori1)
4434 vl3ij=vlor3(j,itori,itori1)
4435 pom=vl2ij*cosphi+vl3ij*sinphi
4436 pom1=1.0d0/(pom*pom+1.0d0)
4437 etors=etors+vl1ij*pom1
4439 gloci=gloci+vl1ij*(vl3ij*cosphi-vl2ij*sinphi)*pom
4441 C Subtract the constant term
4442 etors=etors-v0(itori,itori1,iblock)
4444 & write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)')
4445 & restyp(itype(i-2)),i-2,restyp(itype(i-1)),i-1,itori,itori1,
4446 & (v1(j,itori,itori1,1),j=1,6),(v2(j,itori,itori1,1),j=1,6)
4447 gloc(i-3,icg)=gloc(i-3,icg)+wtor*fact*gloci
4448 c write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
4451 ! 6/20/98 - dihedral angle constraints
4454 itori=idih_constr(i)
4456 difi=pinorm(phii-phi0(i))
4458 if (difi.gt.drange(i)) then
4460 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
4461 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
4462 edihi=0.25d0*ftors*difi**4
4463 else if (difi.lt.-drange(i)) then
4465 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
4466 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
4467 edihi=0.25d0*ftors*difi**4
4471 c write (iout,'(2i5,4f10.5,e15.5)') i,itori,phii,phi0(i),difi,
4473 ! write (iout,'(2i5,2f8.3,2e14.5)') i,itori,rad2deg*phii,
4474 ! & rad2deg*difi,0.25d0*ftors*difi**4,gloc(itori-3,icg)
4476 ! write (iout,*) 'edihcnstr',edihcnstr
4479 c----------------------------------------------------------------------------
4480 subroutine etor_d(etors_d,fact2)
4481 C 6/23/01 Compute double torsional energy
4482 implicit real*8 (a-h,o-z)
4483 include 'DIMENSIONS'
4484 include 'DIMENSIONS.ZSCOPT'
4485 include 'COMMON.VAR'
4486 include 'COMMON.GEO'
4487 include 'COMMON.LOCAL'
4488 include 'COMMON.TORSION'
4489 include 'COMMON.INTERACT'
4490 include 'COMMON.DERIV'
4491 include 'COMMON.CHAIN'
4492 include 'COMMON.NAMES'
4493 include 'COMMON.IOUNITS'
4494 include 'COMMON.FFIELD'
4495 include 'COMMON.TORCNSTR'
4497 C Set lprn=.true. for debugging
4501 do i=iphi_start,iphi_end-1
4502 if (itel(i-2).eq.0 .or. itel(i-1).eq.0 .or. itel(i).eq.0)
4504 itori=itortyp(itype(i-2))
4505 itori1=itortyp(itype(i-1))
4506 itori2=itortyp(itype(i))
4508 c if (iabs(itype(i+1)).eq.20) iblock=2
4514 if (iabs(itype(i+1)).eq.20) iblock=2
4515 C Regular cosine and sine terms
4516 c c do j=1,ntermd_1(itori,itori1,itori2,iblock)
4517 c v1cij=v1c(1,j,itori,itori1,itori2,iblock)
4518 c v1sij=v1s(1,j,itori,itori1,itori2,iblock)
4519 c v2cij=v1c(2,j,itori,itori1,itori2,iblock)
4520 c v2sij=v1s(2,j,itori,itori1,itori2,iblock)
4521 do j=1,ntermd_1(itori,itori1,itori2,iblock)
4522 v1cij=v1c(1,j,itori,itori1,itori2,iblock)
4523 v1sij=v1s(1,j,itori,itori1,itori2,iblock)
4524 v2cij=v1c(2,j,itori,itori1,itori2,iblock)
4525 v2sij=v1s(2,j,itori,itori1,itori2,iblock)
4527 cosphi1=dcos(j*phii)
4528 sinphi1=dsin(j*phii)
4529 cosphi2=dcos(j*phii1)
4530 sinphi2=dsin(j*phii1)
4531 etors_d=etors_d+v1cij*cosphi1+v1sij*sinphi1+
4532 & v2cij*cosphi2+v2sij*sinphi2
4533 gloci1=gloci1+j*(v1sij*cosphi1-v1cij*sinphi1)
4534 gloci2=gloci2+j*(v2sij*cosphi2-v2cij*sinphi2)
4536 do k=2,ntermd_2(itori,itori1,itori2,iblock)
4538 v1cdij = v2c(k,l,itori,itori1,itori2,iblock)
4539 v2cdij = v2c(l,k,itori,itori1,itori2,iblock)
4540 v1sdij = v2s(k,l,itori,itori1,itori2,iblock)
4541 v2sdij = v2s(l,k,itori,itori1,itori2,iblock)
4542 cosphi1p2=dcos(l*phii+(k-l)*phii1)
4543 cosphi1m2=dcos(l*phii-(k-l)*phii1)
4544 sinphi1p2=dsin(l*phii+(k-l)*phii1)
4545 sinphi1m2=dsin(l*phii-(k-l)*phii1)
4546 etors_d=etors_d+v1cdij*cosphi1p2+v2cdij*cosphi1m2+
4547 & v1sdij*sinphi1p2+v2sdij*sinphi1m2
4548 gloci1=gloci1+l*(v1sdij*cosphi1p2+v2sdij*cosphi1m2
4549 & -v1cdij*sinphi1p2-v2cdij*sinphi1m2)
4550 gloci2=gloci2+(k-l)*(v1sdij*cosphi1p2-v2sdij*cosphi1m2
4551 & -v1cdij*sinphi1p2+v2cdij*sinphi1m2)
4554 gloc(i-3,icg)=gloc(i-3,icg)+wtor_d*fact2*gloci1
4555 gloc(i-2,icg)=gloc(i-2,icg)+wtor_d*fact2*gloci2
4561 c------------------------------------------------------------------------------
4562 subroutine eback_sc_corr(esccor)
4563 c 7/21/2007 Correlations between the backbone-local and side-chain-local
4564 c conformational states; temporarily implemented as differences
4565 c between UNRES torsional potentials (dependent on three types of
4566 c residues) and the torsional potentials dependent on all 20 types
4567 c of residues computed from AM1 energy surfaces of terminally-blocked
4568 c amino-acid residues.
4569 implicit real*8 (a-h,o-z)
4570 include 'DIMENSIONS'
4571 include 'DIMENSIONS.ZSCOPT'
4572 include 'COMMON.VAR'
4573 include 'COMMON.GEO'
4574 include 'COMMON.LOCAL'
4575 include 'COMMON.TORSION'
4576 include 'COMMON.SCCOR'
4577 include 'COMMON.INTERACT'
4578 include 'COMMON.DERIV'
4579 include 'COMMON.CHAIN'
4580 include 'COMMON.NAMES'
4581 include 'COMMON.IOUNITS'
4582 include 'COMMON.FFIELD'
4583 include 'COMMON.CONTROL'
4585 C Set lprn=.true. for debugging
4588 c write (iout,*) "EBACK_SC_COR",iphi_start,iphi_end,nterm_sccor
4590 do i=itau_start,itau_end
4592 isccori=isccortyp((itype(i-2)))
4593 isccori1=isccortyp((itype(i-1)))
4595 cccc Added 9 May 2012
4596 cc Tauangle is torsional engle depending on the value of first digit
4597 c(see comment below)
4598 cc Omicron is flat angle depending on the value of first digit
4599 c(see comment below)
4602 do intertyp=1,3 !intertyp
4603 cc Added 09 May 2012 (Adasko)
4604 cc Intertyp means interaction type of backbone mainchain correlation:
4605 c 1 = SC...Ca...Ca...Ca
4606 c 2 = Ca...Ca...Ca...SC
4607 c 3 = SC...Ca...Ca...SCi
4609 if (((intertyp.eq.3).and.((itype(i-2).eq.10).or.
4610 & (itype(i-1).eq.10).or.(itype(i-2).eq.ntyp1).or.
4611 & (itype(i-1).eq.ntyp1)))
4612 & .or. ((intertyp.eq.1).and.((itype(i-2).eq.10)
4613 & .or.(itype(i-2).eq.ntyp1)))
4614 & .or.((intertyp.eq.2).and.((itype(i-1).eq.10).or.
4615 & (itype(i-1).eq.ntyp1)))) cycle
4616 if ((intertyp.eq.2).and.(i.eq.4).and.(itype(1).eq.ntyp1)) cycle
4617 if ((intertyp.eq.1).and.(i.eq.nres).and.(itype(nres).eq.ntyp1))
4619 do j=1,nterm_sccor(isccori,isccori1)
4620 v1ij=v1sccor(j,intertyp,isccori,isccori1)
4621 v2ij=v2sccor(j,intertyp,isccori,isccori1)
4622 cosphi=dcos(j*tauangle(intertyp,i))
4623 sinphi=dsin(j*tauangle(intertyp,i))
4624 esccor=esccor+v1ij*cosphi+v2ij*sinphi
4625 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
4627 gloc_sc(intertyp,i-3,icg)=gloc_sc(intertyp,i-3,icg)+wsccor*gloci
4628 c write (iout,*) "WTF",intertyp,i,itype(i),v1ij*cosphi+v2ij*sinphi
4629 c &gloc_sc(intertyp,i-3,icg)
4631 & write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)')
4632 & restyp(itype(i-2)),i-2,restyp(itype(i-1)),i-1,itori,itori1,
4633 & (v1sccor(j,intertyp,itori,itori1),j=1,6)
4634 & ,(v2sccor(j,intertyp,itori,itori1),j=1,6)
4635 c gsccor_loc(i-3)=gsccor_loc(i-3)+gloci
4639 c write (iout,*) "W@T@F", gloc_sc(1,i,icg),gloc(i,icg)
4643 c------------------------------------------------------------------------------
4644 subroutine multibody(ecorr)
4645 C This subroutine calculates multi-body contributions to energy following
4646 C the idea of Skolnick et al. If side chains I and J make a contact and
4647 C at the same time side chains I+1 and J+1 make a contact, an extra
4648 C contribution equal to sqrt(eps(i,j)*eps(i+1,j+1)) is added.
4649 implicit real*8 (a-h,o-z)
4650 include 'DIMENSIONS'
4651 include 'COMMON.IOUNITS'
4652 include 'COMMON.DERIV'
4653 include 'COMMON.INTERACT'
4654 include 'COMMON.CONTACTS'
4655 double precision gx(3),gx1(3)
4658 C Set lprn=.true. for debugging
4662 write (iout,'(a)') 'Contact function values:'
4664 write (iout,'(i2,20(1x,i2,f10.5))')
4665 & i,(jcont(j,i),facont(j,i),j=1,num_cont(i))
4680 num_conti=num_cont(i)
4681 num_conti1=num_cont(i1)
4686 if (j1.eq.j+ishift .or. j1.eq.j-ishift) then
4687 cd write(iout,*)'i=',i,' j=',j,' i1=',i1,' j1=',j1,
4688 cd & ' ishift=',ishift
4689 C Contacts I--J and I+ISHIFT--J+-ISHIFT1 occur simultaneously.
4690 C The system gains extra energy.
4691 ecorr=ecorr+esccorr(i,j,i1,j1,jj,kk)
4692 endif ! j1==j+-ishift
4701 c------------------------------------------------------------------------------
4702 double precision function esccorr(i,j,k,l,jj,kk)
4703 implicit real*8 (a-h,o-z)
4704 include 'DIMENSIONS'
4705 include 'COMMON.IOUNITS'
4706 include 'COMMON.DERIV'
4707 include 'COMMON.INTERACT'
4708 include 'COMMON.CONTACTS'
4709 double precision gx(3),gx1(3)
4714 cd write (iout,'(4i5,3f10.5)') i,j,k,l,eij,ekl,-eij*ekl
4715 C Calculate the multi-body contribution to energy.
4716 C Calculate multi-body contributions to the gradient.
4717 cd write (iout,'(2(2i3,3f10.5))')i,j,(gacont(m,jj,i),m=1,3),
4718 cd & k,l,(gacont(m,kk,k),m=1,3)
4720 gx(m) =ekl*gacont(m,jj,i)
4721 gx1(m)=eij*gacont(m,kk,k)
4722 gradxorr(m,i)=gradxorr(m,i)-gx(m)
4723 gradxorr(m,j)=gradxorr(m,j)+gx(m)
4724 gradxorr(m,k)=gradxorr(m,k)-gx1(m)
4725 gradxorr(m,l)=gradxorr(m,l)+gx1(m)
4729 gradcorr(ll,m)=gradcorr(ll,m)+gx(ll)
4734 gradcorr(ll,m)=gradcorr(ll,m)+gx1(ll)
4740 c------------------------------------------------------------------------------
4742 subroutine pack_buffer(dimen1,dimen2,atom,indx,buffer)
4743 implicit real*8 (a-h,o-z)
4744 include 'DIMENSIONS'
4745 integer dimen1,dimen2,atom,indx
4746 double precision buffer(dimen1,dimen2)
4747 double precision zapas
4748 common /contacts_hb/ zapas(3,ntyp,maxres,7),
4749 & facont_hb(ntyp,maxres),ees0p(ntyp,maxres),ees0m(ntyp,maxres),
4750 & num_cont_hb(maxres),jcont_hb(ntyp,maxres)
4751 num_kont=num_cont_hb(atom)
4755 buffer(i,indx+(k-1)*3+j)=zapas(j,i,atom,k)
4758 buffer(i,indx+22)=facont_hb(i,atom)
4759 buffer(i,indx+23)=ees0p(i,atom)
4760 buffer(i,indx+24)=ees0m(i,atom)
4761 buffer(i,indx+25)=dfloat(jcont_hb(i,atom))
4763 buffer(1,indx+26)=dfloat(num_kont)
4766 c------------------------------------------------------------------------------
4767 subroutine unpack_buffer(dimen1,dimen2,atom,indx,buffer)
4768 implicit real*8 (a-h,o-z)
4769 include 'DIMENSIONS'
4770 integer dimen1,dimen2,atom,indx
4771 double precision buffer(dimen1,dimen2)
4772 double precision zapas
4773 common /contacts_hb/ zapas(3,ntyp,maxres,7),
4774 & facont_hb(ntyp,maxres),ees0p(ntyp,maxres),
4775 & ees0m(ntyp,maxres),
4776 & num_cont_hb(maxres),jcont_hb(ntyp,maxres)
4777 num_kont=buffer(1,indx+26)
4778 num_kont_old=num_cont_hb(atom)
4779 num_cont_hb(atom)=num_kont+num_kont_old
4784 zapas(j,ii,atom,k)=buffer(i,indx+(k-1)*3+j)
4787 facont_hb(ii,atom)=buffer(i,indx+22)
4788 ees0p(ii,atom)=buffer(i,indx+23)
4789 ees0m(ii,atom)=buffer(i,indx+24)
4790 jcont_hb(ii,atom)=buffer(i,indx+25)
4794 c------------------------------------------------------------------------------
4796 subroutine multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
4797 C This subroutine calculates multi-body contributions to hydrogen-bonding
4798 implicit real*8 (a-h,o-z)
4799 include 'DIMENSIONS'
4800 include 'DIMENSIONS.ZSCOPT'
4801 include 'COMMON.IOUNITS'
4803 include 'COMMON.INFO'
4805 include 'COMMON.FFIELD'
4806 include 'COMMON.DERIV'
4807 include 'COMMON.INTERACT'
4808 include 'COMMON.CONTACTS'
4810 parameter (max_cont=maxconts)
4811 parameter (max_dim=2*(8*3+2))
4812 parameter (msglen1=max_cont*max_dim*4)
4813 parameter (msglen2=2*msglen1)
4814 integer source,CorrelType,CorrelID,Error
4815 double precision buffer(max_cont,max_dim)
4817 double precision gx(3),gx1(3)
4820 C Set lprn=.true. for debugging
4825 if (fgProcs.le.1) goto 30
4827 write (iout,'(a)') 'Contact function values:'
4829 write (iout,'(2i3,50(1x,i2,f5.2))')
4830 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
4831 & j=1,num_cont_hb(i))
4834 C Caution! Following code assumes that electrostatic interactions concerning
4835 C a given atom are split among at most two processors!
4845 cd write (iout,*) 'MyRank',MyRank,' mm',mm
4848 cd write (iout,*) 'Sending: MyRank',MyRank,' mm',mm,' ldone',ldone
4849 if (MyRank.gt.0) then
4850 C Send correlation contributions to the preceding processor
4852 nn=num_cont_hb(iatel_s)
4853 call pack_buffer(max_cont,max_dim,iatel_s,0,buffer)
4854 cd write (iout,*) 'The BUFFER array:'
4856 cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,26)
4858 if (ielstart(iatel_s).gt.iatel_s+ispp) then
4860 call pack_buffer(max_cont,max_dim,iatel_s+1,26,buffer)
4861 C Clear the contacts of the atom passed to the neighboring processor
4862 nn=num_cont_hb(iatel_s+1)
4864 cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j+26),j=1,26)
4866 num_cont_hb(iatel_s)=0
4868 cd write (iout,*) 'Processor ',MyID,MyRank,
4869 cd & ' is sending correlation contribution to processor',MyID-1,
4870 cd & ' msglen=',msglen
4871 cd write (*,*) 'Processor ',MyID,MyRank,
4872 cd & ' is sending correlation contribution to processor',MyID-1,
4873 cd & ' msglen=',msglen,' CorrelType=',CorrelType
4874 call mp_bsend(buffer,msglen,MyID-1,CorrelType,CorrelID)
4875 cd write (iout,*) 'Processor ',MyID,
4876 cd & ' has sent correlation contribution to processor',MyID-1,
4877 cd & ' msglen=',msglen,' CorrelID=',CorrelID
4878 cd write (*,*) 'Processor ',MyID,
4879 cd & ' has sent correlation contribution to processor',MyID-1,
4880 cd & ' msglen=',msglen,' CorrelID=',CorrelID
4882 endif ! (MyRank.gt.0)
4886 cd write (iout,*) 'Receiving: MyRank',MyRank,' mm',mm,' ldone',ldone
4887 if (MyRank.lt.fgProcs-1) then
4888 C Receive correlation contributions from the next processor
4890 if (ielend(iatel_e).lt.nct-1) msglen=msglen2
4891 cd write (iout,*) 'Processor',MyID,
4892 cd & ' is receiving correlation contribution from processor',MyID+1,
4893 cd & ' msglen=',msglen,' CorrelType=',CorrelType
4894 cd write (*,*) 'Processor',MyID,
4895 cd & ' is receiving correlation contribution from processor',MyID+1,
4896 cd & ' msglen=',msglen,' CorrelType=',CorrelType
4898 do while (nbytes.le.0)
4899 call mp_probe(MyID+1,CorrelType,nbytes)
4901 cd print *,'Processor',MyID,' msglen',msglen,' nbytes',nbytes
4902 call mp_brecv(buffer,msglen,MyID+1,CorrelType,nbytes)
4903 cd write (iout,*) 'Processor',MyID,
4904 cd & ' has received correlation contribution from processor',MyID+1,
4905 cd & ' msglen=',msglen,' nbytes=',nbytes
4906 cd write (iout,*) 'The received BUFFER array:'
4908 cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,52)
4910 if (msglen.eq.msglen1) then
4911 call unpack_buffer(max_cont,max_dim,iatel_e+1,0,buffer)
4912 else if (msglen.eq.msglen2) then
4913 call unpack_buffer(max_cont,max_dim,iatel_e,0,buffer)
4914 call unpack_buffer(max_cont,max_dim,iatel_e+1,26,buffer)
4917 & 'ERROR!!!! message length changed while processing correlations.'
4919 & 'ERROR!!!! message length changed while processing correlations.'
4920 call mp_stopall(Error)
4921 endif ! msglen.eq.msglen1
4922 endif ! MyRank.lt.fgProcs-1
4929 write (iout,'(a)') 'Contact function values:'
4931 write (iout,'(2i3,50(1x,i2,f5.2))')
4932 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
4933 & j=1,num_cont_hb(i))
4937 C Remove the loop below after debugging !!!
4944 C Calculate the local-electrostatic correlation terms
4945 do i=iatel_s,iatel_e+1
4947 num_conti=num_cont_hb(i)
4948 num_conti1=num_cont_hb(i+1)
4953 c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
4954 c & ' jj=',jj,' kk=',kk
4955 if (j1.eq.j+1 .or. j1.eq.j-1) then
4956 C Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
4957 C The system gains extra energy.
4958 ecorr=ecorr+ehbcorr(i,j,i+1,j1,jj,kk,0.72D0,0.32D0)
4960 else if (j1.eq.j) then
4961 C Contacts I-J and I-(J+1) occur simultaneously.
4962 C The system loses extra energy.
4963 c ecorr=ecorr+ehbcorr(i,j,i+1,j,jj,kk,0.60D0,-0.40D0)
4968 c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
4969 c & ' jj=',jj,' kk=',kk
4971 C Contacts I-J and (I+1)-J occur simultaneously.
4972 C The system loses extra energy.
4973 c ecorr=ecorr+ehbcorr(i,j,i,j+1,jj,kk,0.60D0,-0.40D0)
4980 c------------------------------------------------------------------------------
4981 subroutine multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,
4983 C This subroutine calculates multi-body contributions to hydrogen-bonding
4984 implicit real*8 (a-h,o-z)
4985 include 'DIMENSIONS'
4986 include 'DIMENSIONS.ZSCOPT'
4987 include 'COMMON.IOUNITS'
4989 include 'COMMON.INFO'
4991 include 'COMMON.FFIELD'
4992 include 'COMMON.DERIV'
4993 include 'COMMON.INTERACT'
4994 include 'COMMON.CONTACTS'
4996 parameter (max_cont=maxconts)
4997 parameter (max_dim=2*(8*3+2))
4998 parameter (msglen1=max_cont*max_dim*4)
4999 parameter (msglen2=2*msglen1)
5000 integer source,CorrelType,CorrelID,Error
5001 double precision buffer(max_cont,max_dim)
5003 double precision gx(3),gx1(3)
5006 C Set lprn=.true. for debugging
5012 if (fgProcs.le.1) goto 30
5014 write (iout,'(a)') 'Contact function values:'
5016 write (iout,'(2i3,50(1x,i2,f5.2))')
5017 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
5018 & j=1,num_cont_hb(i))
5021 C Caution! Following code assumes that electrostatic interactions concerning
5022 C a given atom are split among at most two processors!
5032 cd write (iout,*) 'MyRank',MyRank,' mm',mm
5035 cd write (iout,*) 'Sending: MyRank',MyRank,' mm',mm,' ldone',ldone
5036 if (MyRank.gt.0) then
5037 C Send correlation contributions to the preceding processor
5039 nn=num_cont_hb(iatel_s)
5040 call pack_buffer(max_cont,max_dim,iatel_s,0,buffer)
5041 cd write (iout,*) 'The BUFFER array:'
5043 cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,26)
5045 if (ielstart(iatel_s).gt.iatel_s+ispp) then
5047 call pack_buffer(max_cont,max_dim,iatel_s+1,26,buffer)
5048 C Clear the contacts of the atom passed to the neighboring processor
5049 nn=num_cont_hb(iatel_s+1)
5051 cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j+26),j=1,26)
5053 num_cont_hb(iatel_s)=0
5055 cd write (iout,*) 'Processor ',MyID,MyRank,
5056 cd & ' is sending correlation contribution to processor',MyID-1,
5057 cd & ' msglen=',msglen
5058 cd write (*,*) 'Processor ',MyID,MyRank,
5059 cd & ' is sending correlation contribution to processor',MyID-1,
5060 cd & ' msglen=',msglen,' CorrelType=',CorrelType
5061 call mp_bsend(buffer,msglen,MyID-1,CorrelType,CorrelID)
5062 cd write (iout,*) 'Processor ',MyID,
5063 cd & ' has sent correlation contribution to processor',MyID-1,
5064 cd & ' msglen=',msglen,' CorrelID=',CorrelID
5065 cd write (*,*) 'Processor ',MyID,
5066 cd & ' has sent correlation contribution to processor',MyID-1,
5067 cd & ' msglen=',msglen,' CorrelID=',CorrelID
5069 endif ! (MyRank.gt.0)
5073 cd write (iout,*) 'Receiving: MyRank',MyRank,' mm',mm,' ldone',ldone
5074 if (MyRank.lt.fgProcs-1) then
5075 C Receive correlation contributions from the next processor
5077 if (ielend(iatel_e).lt.nct-1) msglen=msglen2
5078 cd write (iout,*) 'Processor',MyID,
5079 cd & ' is receiving correlation contribution from processor',MyID+1,
5080 cd & ' msglen=',msglen,' CorrelType=',CorrelType
5081 cd write (*,*) 'Processor',MyID,
5082 cd & ' is receiving correlation contribution from processor',MyID+1,
5083 cd & ' msglen=',msglen,' CorrelType=',CorrelType
5085 do while (nbytes.le.0)
5086 call mp_probe(MyID+1,CorrelType,nbytes)
5088 cd print *,'Processor',MyID,' msglen',msglen,' nbytes',nbytes
5089 call mp_brecv(buffer,msglen,MyID+1,CorrelType,nbytes)
5090 cd write (iout,*) 'Processor',MyID,
5091 cd & ' has received correlation contribution from processor',MyID+1,
5092 cd & ' msglen=',msglen,' nbytes=',nbytes
5093 cd write (iout,*) 'The received BUFFER array:'
5095 cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,52)
5097 if (msglen.eq.msglen1) then
5098 call unpack_buffer(max_cont,max_dim,iatel_e+1,0,buffer)
5099 else if (msglen.eq.msglen2) then
5100 call unpack_buffer(max_cont,max_dim,iatel_e,0,buffer)
5101 call unpack_buffer(max_cont,max_dim,iatel_e+1,26,buffer)
5104 & 'ERROR!!!! message length changed while processing correlations.'
5106 & 'ERROR!!!! message length changed while processing correlations.'
5107 call mp_stopall(Error)
5108 endif ! msglen.eq.msglen1
5109 endif ! MyRank.lt.fgProcs-1
5116 write (iout,'(a)') 'Contact function values:'
5118 write (iout,'(2i3,50(1x,i2,f5.2))')
5119 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
5120 & j=1,num_cont_hb(i))
5126 C Remove the loop below after debugging !!!
5133 C Calculate the dipole-dipole interaction energies
5134 if (wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) then
5135 do i=iatel_s,iatel_e+1
5136 num_conti=num_cont_hb(i)
5143 C Calculate the local-electrostatic correlation terms
5144 do i=iatel_s,iatel_e+1
5146 num_conti=num_cont_hb(i)
5147 num_conti1=num_cont_hb(i+1)
5152 c write (*,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
5153 c & ' jj=',jj,' kk=',kk
5154 if (j1.eq.j+1 .or. j1.eq.j-1) then
5155 C Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
5156 C The system gains extra energy.
5158 sqd1=dsqrt(d_cont(jj,i))
5159 sqd2=dsqrt(d_cont(kk,i1))
5160 sred_geom = sqd1*sqd2
5161 IF (sred_geom.lt.cutoff_corr) THEN
5162 call gcont(sred_geom,r0_corr,1.0D0,delt_corr,
5164 c write (*,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
5165 c & ' jj=',jj,' kk=',kk
5166 fac_prim1=0.5d0*sqd2/sqd1*fprimcont
5167 fac_prim2=0.5d0*sqd1/sqd2*fprimcont
5169 g_contij(l,1)=fac_prim1*grij_hb_cont(l,jj,i)
5170 g_contij(l,2)=fac_prim2*grij_hb_cont(l,kk,i1)
5173 cd write (iout,*) 'sred_geom=',sred_geom,
5174 cd & ' ekont=',ekont,' fprim=',fprimcont
5175 call calc_eello(i,j,i+1,j1,jj,kk)
5176 if (wcorr4.gt.0.0d0)
5177 & ecorr=ecorr+eello4(i,j,i+1,j1,jj,kk)
5178 if (wcorr5.gt.0.0d0)
5179 & ecorr5=ecorr5+eello5(i,j,i+1,j1,jj,kk)
5180 c print *,"wcorr5",ecorr5
5181 cd write(2,*)'wcorr6',wcorr6,' wturn6',wturn6
5182 cd write(2,*)'ijkl',i,j,i+1,j1
5183 if (wcorr6.gt.0.0d0 .and. (j.ne.i+4 .or. j1.ne.i+3
5184 & .or. wturn6.eq.0.0d0))then
5185 cd write (iout,*) '******ecorr6: i,j,i+1,j1',i,j,i+1,j1
5186 ecorr6=ecorr6+eello6(i,j,i+1,j1,jj,kk)
5187 cd write (iout,*) 'ecorr',ecorr,' ecorr5=',ecorr5,
5188 cd & 'ecorr6=',ecorr6
5189 cd write (iout,'(4e15.5)') sred_geom,
5190 cd & dabs(eello4(i,j,i+1,j1,jj,kk)),
5191 cd & dabs(eello5(i,j,i+1,j1,jj,kk)),
5192 cd & dabs(eello6(i,j,i+1,j1,jj,kk))
5193 else if (wturn6.gt.0.0d0
5194 & .and. (j.eq.i+4 .and. j1.eq.i+3)) then
5195 cd write (iout,*) '******eturn6: i,j,i+1,j1',i,j,i+1,j1
5196 eturn6=eturn6+eello_turn6(i,jj,kk)
5197 cd write (2,*) 'multibody_eello:eturn6',eturn6
5201 else if (j1.eq.j) then
5202 C Contacts I-J and I-(J+1) occur simultaneously.
5203 C The system loses extra energy.
5204 c ecorr=ecorr+ehbcorr(i,j,i+1,j,jj,kk,0.60D0,-0.40D0)
5209 c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
5210 c & ' jj=',jj,' kk=',kk
5212 C Contacts I-J and (I+1)-J occur simultaneously.
5213 C The system loses extra energy.
5214 c ecorr=ecorr+ehbcorr(i,j,i,j+1,jj,kk,0.60D0,-0.40D0)
5221 c------------------------------------------------------------------------------
5222 double precision function ehbcorr(i,j,k,l,jj,kk,coeffp,coeffm)
5223 implicit real*8 (a-h,o-z)
5224 include 'DIMENSIONS'
5225 include 'COMMON.IOUNITS'
5226 include 'COMMON.DERIV'
5227 include 'COMMON.INTERACT'
5228 include 'COMMON.CONTACTS'
5229 double precision gx(3),gx1(3)
5239 ees=-(coeffp*ees0pij*ees0pkl+coeffm*ees0mij*ees0mkl)
5240 cd ees=-(coeffp*ees0pkl+coeffm*ees0mkl)
5241 C Following 4 lines for diagnostics.
5246 c write (iout,*)'Contacts have occurred for peptide groups',i,j,
5248 c write (iout,*)'Contacts have occurred for peptide groups',
5249 c & i,j,' fcont:',eij,' eij',' eesij',ees0pij,ees0mij,' and ',k,l
5250 c & ,' fcont ',ekl,' eeskl',ees0pkl,ees0mkl,' ees=',ees
5251 C Calculate the multi-body contribution to energy.
5252 ecorr=ecorr+ekont*ees
5254 C Calculate multi-body contributions to the gradient.
5256 ghalf=0.5D0*ees*ekl*gacont_hbr(ll,jj,i)
5257 gradcorr(ll,i)=gradcorr(ll,i)+ghalf
5258 & -ekont*(coeffp*ees0pkl*gacontp_hb1(ll,jj,i)+
5259 & coeffm*ees0mkl*gacontm_hb1(ll,jj,i))
5260 gradcorr(ll,j)=gradcorr(ll,j)+ghalf
5261 & -ekont*(coeffp*ees0pkl*gacontp_hb2(ll,jj,i)+
5262 & coeffm*ees0mkl*gacontm_hb2(ll,jj,i))
5263 ghalf=0.5D0*ees*eij*gacont_hbr(ll,kk,k)
5264 gradcorr(ll,k)=gradcorr(ll,k)+ghalf
5265 & -ekont*(coeffp*ees0pij*gacontp_hb1(ll,kk,k)+
5266 & coeffm*ees0mij*gacontm_hb1(ll,kk,k))
5267 gradcorr(ll,l)=gradcorr(ll,l)+ghalf
5268 & -ekont*(coeffp*ees0pij*gacontp_hb2(ll,kk,k)+
5269 & coeffm*ees0mij*gacontm_hb2(ll,kk,k))
5273 gradcorr(ll,m)=gradcorr(ll,m)+
5274 & ees*ekl*gacont_hbr(ll,jj,i)-
5275 & ekont*(coeffp*ees0pkl*gacontp_hb3(ll,jj,i)+
5276 & coeffm*ees0mkl*gacontm_hb3(ll,jj,i))
5281 gradcorr(ll,m)=gradcorr(ll,m)+
5282 & ees*eij*gacont_hbr(ll,kk,k)-
5283 & ekont*(coeffp*ees0pij*gacontp_hb3(ll,kk,k)+
5284 & coeffm*ees0mij*gacontm_hb3(ll,kk,k))
5291 C---------------------------------------------------------------------------
5292 subroutine dipole(i,j,jj)
5293 implicit real*8 (a-h,o-z)
5294 include 'DIMENSIONS'
5295 include 'DIMENSIONS.ZSCOPT'
5296 include 'COMMON.IOUNITS'
5297 include 'COMMON.CHAIN'
5298 include 'COMMON.FFIELD'
5299 include 'COMMON.DERIV'
5300 include 'COMMON.INTERACT'
5301 include 'COMMON.CONTACTS'
5302 include 'COMMON.TORSION'
5303 include 'COMMON.VAR'
5304 include 'COMMON.GEO'
5305 dimension dipi(2,2),dipj(2,2),dipderi(2),dipderj(2),auxvec(2),
5307 iti1 = itortyp(itype(i+1))
5308 if (j.lt.nres-1) then
5309 itj1 = itortyp(itype(j+1))
5314 dipi(iii,1)=Ub2(iii,i)
5315 dipderi(iii)=Ub2der(iii,i)
5316 dipi(iii,2)=b1(iii,iti1)
5317 dipj(iii,1)=Ub2(iii,j)
5318 dipderj(iii)=Ub2der(iii,j)
5319 dipj(iii,2)=b1(iii,itj1)
5323 call matvec2(a_chuj(1,1,jj,i),dipj(1,iii),auxvec(1))
5326 dip(kkk,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
5329 if (.not.calc_grad) return
5334 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),dipj(1,iii),
5338 dipderx(lll,kkk,mmm,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
5343 call transpose2(a_chuj(1,1,jj,i),auxmat(1,1))
5344 call matvec2(auxmat(1,1),dipderi(1),auxvec(1))
5346 dipderg(iii,jj,i)=scalar2(auxvec(1),dipj(1,iii))
5348 call matvec2(a_chuj(1,1,jj,i),dipderj(1),auxvec(1))
5350 dipderg(iii+2,jj,i)=scalar2(auxvec(1),dipi(1,iii))
5354 C---------------------------------------------------------------------------
5355 subroutine calc_eello(i,j,k,l,jj,kk)
5357 C This subroutine computes matrices and vectors needed to calculate
5358 C the fourth-, fifth-, and sixth-order local-electrostatic terms.
5360 implicit real*8 (a-h,o-z)
5361 include 'DIMENSIONS'
5362 include 'DIMENSIONS.ZSCOPT'
5363 include 'COMMON.IOUNITS'
5364 include 'COMMON.CHAIN'
5365 include 'COMMON.DERIV'
5366 include 'COMMON.INTERACT'
5367 include 'COMMON.CONTACTS'
5368 include 'COMMON.TORSION'
5369 include 'COMMON.VAR'
5370 include 'COMMON.GEO'
5371 include 'COMMON.FFIELD'
5372 double precision aa1(2,2),aa2(2,2),aa1t(2,2),aa2t(2,2),
5373 & aa1tder(2,2,3,5),aa2tder(2,2,3,5),auxmat(2,2)
5376 cd write (iout,*) 'calc_eello: i=',i,' j=',j,' k=',k,' l=',l,
5377 cd & ' jj=',jj,' kk=',kk
5378 cd if (i.ne.2 .or. j.ne.4 .or. k.ne.3 .or. l.ne.5) return
5381 aa1(iii,jjj)=a_chuj(iii,jjj,jj,i)
5382 aa2(iii,jjj)=a_chuj(iii,jjj,kk,k)
5385 call transpose2(aa1(1,1),aa1t(1,1))
5386 call transpose2(aa2(1,1),aa2t(1,1))
5389 call transpose2(a_chuj_der(1,1,lll,kkk,jj,i),
5390 & aa1tder(1,1,lll,kkk))
5391 call transpose2(a_chuj_der(1,1,lll,kkk,kk,k),
5392 & aa2tder(1,1,lll,kkk))
5396 C parallel orientation of the two CA-CA-CA frames.
5398 iti=itortyp(itype(i))
5402 itk1=itortyp(itype(k+1))
5403 itj=itortyp(itype(j))
5404 if (l.lt.nres-1) then
5405 itl1=itortyp(itype(l+1))
5409 C A1 kernel(j+1) A2T
5411 cd write (iout,'(3f10.5,5x,3f10.5)')
5412 cd & (EUg(iii,jjj,k),jjj=1,2),(EUg(iii,jjj,l),jjj=1,2)
5414 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
5415 & aa2tder(1,1,1,1),1,.false.,EUg(1,1,l),EUgder(1,1,l),
5416 & AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
5417 C Following matrices are needed only for 6-th order cumulants
5418 IF (wcorr6.gt.0.0d0) THEN
5419 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
5420 & aa2tder(1,1,1,1),1,.false.,EUgC(1,1,l),EUgCder(1,1,l),
5421 & AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
5422 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
5423 & aa2tder(1,1,1,1),2,.false.,Ug2DtEUg(1,1,l),
5424 & Ug2DtEUgder(1,1,1,l),ADtEA(1,1,1),ADtEAderg(1,1,1,1),
5425 & ADtEAderx(1,1,1,1,1,1))
5427 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
5428 & aa2tder(1,1,1,1),2,.false.,DtUg2EUg(1,1,l),
5429 & DtUg2EUgder(1,1,1,l),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),
5430 & ADtEA1derx(1,1,1,1,1,1))
5432 C End 6-th order cumulants
5435 cd write (2,*) 'In calc_eello6'
5437 cd write (2,*) 'iii=',iii
5439 cd write (2,*) 'kkk=',kkk
5441 cd write (2,'(3(2f10.5),5x)')
5442 cd & ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
5447 call transpose2(EUgder(1,1,k),auxmat(1,1))
5448 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
5449 call transpose2(EUg(1,1,k),auxmat(1,1))
5450 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
5451 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
5455 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),
5456 & EAEAderx(1,1,lll,kkk,iii,1))
5460 C A1T kernel(i+1) A2
5461 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
5462 & a_chuj_der(1,1,1,1,kk,k),1,.false.,EUg(1,1,k),EUgder(1,1,k),
5463 & AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
5464 C Following matrices are needed only for 6-th order cumulants
5465 IF (wcorr6.gt.0.0d0) THEN
5466 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
5467 & a_chuj_der(1,1,1,1,kk,k),1,.false.,EUgC(1,1,k),EUgCder(1,1,k),
5468 & AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
5469 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
5470 & a_chuj_der(1,1,1,1,kk,k),2,.false.,Ug2DtEUg(1,1,k),
5471 & Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),
5472 & ADtEAderx(1,1,1,1,1,2))
5473 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
5474 & a_chuj_der(1,1,1,1,kk,k),2,.false.,DtUg2EUg(1,1,k),
5475 & DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),
5476 & ADtEA1derx(1,1,1,1,1,2))
5478 C End 6-th order cumulants
5479 call transpose2(EUgder(1,1,l),auxmat(1,1))
5480 call matmat2(auxmat(1,1),AEA(1,1,2),EAEAderg(1,1,1,2))
5481 call transpose2(EUg(1,1,l),auxmat(1,1))
5482 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
5483 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
5487 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
5488 & EAEAderx(1,1,lll,kkk,iii,2))
5493 C Calculate the vectors and their derivatives in virtual-bond dihedral angles.
5494 C They are needed only when the fifth- or the sixth-order cumulants are
5496 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) THEN
5497 call transpose2(AEA(1,1,1),auxmat(1,1))
5498 call matvec2(auxmat(1,1),b1(1,iti),AEAb1(1,1,1))
5499 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
5500 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
5501 call transpose2(AEAderg(1,1,1),auxmat(1,1))
5502 call matvec2(auxmat(1,1),b1(1,iti),AEAb1derg(1,1,1))
5503 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
5504 call matvec2(AEA(1,1,1),b1(1,itk1),AEAb1(1,2,1))
5505 call matvec2(AEAderg(1,1,1),b1(1,itk1),AEAb1derg(1,2,1))
5506 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
5507 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
5508 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
5509 call transpose2(AEA(1,1,2),auxmat(1,1))
5510 call matvec2(auxmat(1,1),b1(1,itj),AEAb1(1,1,2))
5511 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2(1,1,2))
5512 call matvec2(auxmat(1,1),Ub2der(1,j),AEAb2derg(1,2,1,2))
5513 call transpose2(AEAderg(1,1,2),auxmat(1,1))
5514 call matvec2(auxmat(1,1),b1(1,itj),AEAb1derg(1,1,2))
5515 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2derg(1,1,1,2))
5516 call matvec2(AEA(1,1,2),b1(1,itl1),AEAb1(1,2,2))
5517 call matvec2(AEAderg(1,1,2),b1(1,itl1),AEAb1derg(1,2,2))
5518 call matvec2(AEA(1,1,2),Ub2(1,l+1),AEAb2(1,2,2))
5519 call matvec2(AEAderg(1,1,2),Ub2(1,l+1),AEAb2derg(1,1,2,2))
5520 call matvec2(AEA(1,1,2),Ub2der(1,l+1),AEAb2derg(1,2,2,2))
5521 C Calculate the Cartesian derivatives of the vectors.
5525 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
5526 call matvec2(auxmat(1,1),b1(1,iti),
5527 & AEAb1derx(1,lll,kkk,iii,1,1))
5528 call matvec2(auxmat(1,1),Ub2(1,i),
5529 & AEAb2derx(1,lll,kkk,iii,1,1))
5530 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,itk1),
5531 & AEAb1derx(1,lll,kkk,iii,2,1))
5532 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),
5533 & AEAb2derx(1,lll,kkk,iii,2,1))
5534 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
5535 call matvec2(auxmat(1,1),b1(1,itj),
5536 & AEAb1derx(1,lll,kkk,iii,1,2))
5537 call matvec2(auxmat(1,1),Ub2(1,j),
5538 & AEAb2derx(1,lll,kkk,iii,1,2))
5539 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,itl1),
5540 & AEAb1derx(1,lll,kkk,iii,2,2))
5541 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,l+1),
5542 & AEAb2derx(1,lll,kkk,iii,2,2))
5549 C Antiparallel orientation of the two CA-CA-CA frames.
5551 iti=itortyp(itype(i))
5555 itk1=itortyp(itype(k+1))
5556 itl=itortyp(itype(l))
5557 itj=itortyp(itype(j))
5558 if (j.lt.nres-1) then
5559 itj1=itortyp(itype(j+1))
5563 C A2 kernel(j-1)T A1T
5564 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
5565 & aa2tder(1,1,1,1),1,.true.,EUg(1,1,j),EUgder(1,1,j),
5566 & AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
5567 C Following matrices are needed only for 6-th order cumulants
5568 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and.
5569 & j.eq.i+4 .and. l.eq.i+3)) THEN
5570 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
5571 & aa2tder(1,1,1,1),1,.true.,EUgC(1,1,j),EUgCder(1,1,j),
5572 & AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
5573 call kernel(aa2(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
5574 & aa2tder(1,1,1,1),2,.true.,Ug2DtEUg(1,1,j),
5575 & Ug2DtEUgder(1,1,1,j),ADtEA(1,1,1),ADtEAderg(1,1,1,1),
5576 & ADtEAderx(1,1,1,1,1,1))
5577 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
5578 & aa2tder(1,1,1,1),2,.true.,DtUg2EUg(1,1,j),
5579 & DtUg2EUgder(1,1,1,j),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),
5580 & ADtEA1derx(1,1,1,1,1,1))
5582 C End 6-th order cumulants
5583 call transpose2(EUgder(1,1,k),auxmat(1,1))
5584 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
5585 call transpose2(EUg(1,1,k),auxmat(1,1))
5586 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
5587 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
5591 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),
5592 & EAEAderx(1,1,lll,kkk,iii,1))
5596 C A2T kernel(i+1)T A1
5597 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
5598 & a_chuj_der(1,1,1,1,jj,i),1,.true.,EUg(1,1,k),EUgder(1,1,k),
5599 & AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
5600 C Following matrices are needed only for 6-th order cumulants
5601 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and.
5602 & j.eq.i+4 .and. l.eq.i+3)) THEN
5603 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
5604 & a_chuj_der(1,1,1,1,jj,i),1,.true.,EUgC(1,1,k),EUgCder(1,1,k),
5605 & AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
5606 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
5607 & a_chuj_der(1,1,1,1,jj,i),2,.true.,Ug2DtEUg(1,1,k),
5608 & Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),
5609 & ADtEAderx(1,1,1,1,1,2))
5610 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
5611 & a_chuj_der(1,1,1,1,jj,i),2,.true.,DtUg2EUg(1,1,k),
5612 & DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),
5613 & ADtEA1derx(1,1,1,1,1,2))
5615 C End 6-th order cumulants
5616 call transpose2(EUgder(1,1,j),auxmat(1,1))
5617 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,2,2))
5618 call transpose2(EUg(1,1,j),auxmat(1,1))
5619 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
5620 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
5624 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
5625 & EAEAderx(1,1,lll,kkk,iii,2))
5630 C Calculate the vectors and their derivatives in virtual-bond dihedral angles.
5631 C They are needed only when the fifth- or the sixth-order cumulants are
5633 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 .or.
5634 & (wturn6.gt.0.0d0 .and. j.eq.i+4 .and. l.eq.i+3)) THEN
5635 call transpose2(AEA(1,1,1),auxmat(1,1))
5636 call matvec2(auxmat(1,1),b1(1,iti),AEAb1(1,1,1))
5637 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
5638 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
5639 call transpose2(AEAderg(1,1,1),auxmat(1,1))
5640 call matvec2(auxmat(1,1),b1(1,iti),AEAb1derg(1,1,1))
5641 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
5642 call matvec2(AEA(1,1,1),b1(1,itk1),AEAb1(1,2,1))
5643 call matvec2(AEAderg(1,1,1),b1(1,itk1),AEAb1derg(1,2,1))
5644 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
5645 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
5646 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
5647 call transpose2(AEA(1,1,2),auxmat(1,1))
5648 call matvec2(auxmat(1,1),b1(1,itj1),AEAb1(1,1,2))
5649 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2(1,1,2))
5650 call matvec2(auxmat(1,1),Ub2der(1,l),AEAb2derg(1,2,1,2))
5651 call transpose2(AEAderg(1,1,2),auxmat(1,1))
5652 call matvec2(auxmat(1,1),b1(1,itl),AEAb1(1,1,2))
5653 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2derg(1,1,1,2))
5654 call matvec2(AEA(1,1,2),b1(1,itj1),AEAb1(1,2,2))
5655 call matvec2(AEAderg(1,1,2),b1(1,itj1),AEAb1derg(1,2,2))
5656 call matvec2(AEA(1,1,2),Ub2(1,j),AEAb2(1,2,2))
5657 call matvec2(AEAderg(1,1,2),Ub2(1,j),AEAb2derg(1,1,2,2))
5658 call matvec2(AEA(1,1,2),Ub2der(1,j),AEAb2derg(1,2,2,2))
5659 C Calculate the Cartesian derivatives of the vectors.
5663 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
5664 call matvec2(auxmat(1,1),b1(1,iti),
5665 & AEAb1derx(1,lll,kkk,iii,1,1))
5666 call matvec2(auxmat(1,1),Ub2(1,i),
5667 & AEAb2derx(1,lll,kkk,iii,1,1))
5668 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,itk1),
5669 & AEAb1derx(1,lll,kkk,iii,2,1))
5670 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),
5671 & AEAb2derx(1,lll,kkk,iii,2,1))
5672 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
5673 call matvec2(auxmat(1,1),b1(1,itl),
5674 & AEAb1derx(1,lll,kkk,iii,1,2))
5675 call matvec2(auxmat(1,1),Ub2(1,l),
5676 & AEAb2derx(1,lll,kkk,iii,1,2))
5677 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,itj1),
5678 & AEAb1derx(1,lll,kkk,iii,2,2))
5679 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,j),
5680 & AEAb2derx(1,lll,kkk,iii,2,2))
5689 C---------------------------------------------------------------------------
5690 subroutine kernel(aa1,aa2t,aa1derx,aa2tderx,nderg,transp,
5691 & KK,KKderg,AKA,AKAderg,AKAderx)
5695 double precision aa1(2,2),aa2t(2,2),aa1derx(2,2,3,5),
5696 & aa2tderx(2,2,3,5),KK(2,2),KKderg(2,2,nderg),AKA(2,2),
5697 & AKAderg(2,2,nderg),AKAderx(2,2,3,5,2)
5702 call prodmat3(aa1(1,1),aa2t(1,1),KK(1,1),transp,AKA(1,1))
5704 call prodmat3(aa1(1,1),aa2t(1,1),KKderg(1,1,iii),transp,
5707 cd if (lprn) write (2,*) 'In kernel'
5709 cd if (lprn) write (2,*) 'kkk=',kkk
5711 call prodmat3(aa1derx(1,1,lll,kkk),aa2t(1,1),
5712 & KK(1,1),transp,AKAderx(1,1,lll,kkk,1))
5714 cd write (2,*) 'lll=',lll
5715 cd write (2,*) 'iii=1'
5717 cd write (2,'(3(2f10.5),5x)')
5718 cd & (AKAderx(jjj,mmm,lll,kkk,1),mmm=1,2)
5721 call prodmat3(aa1(1,1),aa2tderx(1,1,lll,kkk),
5722 & KK(1,1),transp,AKAderx(1,1,lll,kkk,2))
5724 cd write (2,*) 'lll=',lll
5725 cd write (2,*) 'iii=2'
5727 cd write (2,'(3(2f10.5),5x)')
5728 cd & (AKAderx(jjj,mmm,lll,kkk,2),mmm=1,2)
5735 C---------------------------------------------------------------------------
5736 double precision function eello4(i,j,k,l,jj,kk)
5737 implicit real*8 (a-h,o-z)
5738 include 'DIMENSIONS'
5739 include 'DIMENSIONS.ZSCOPT'
5740 include 'COMMON.IOUNITS'
5741 include 'COMMON.CHAIN'
5742 include 'COMMON.DERIV'
5743 include 'COMMON.INTERACT'
5744 include 'COMMON.CONTACTS'
5745 include 'COMMON.TORSION'
5746 include 'COMMON.VAR'
5747 include 'COMMON.GEO'
5748 double precision pizda(2,2),ggg1(3),ggg2(3)
5749 cd if (i.ne.1 .or. j.ne.5 .or. k.ne.2 .or.l.ne.4) then
5753 cd print *,'eello4:',i,j,k,l,jj,kk
5754 cd write (2,*) 'i',i,' j',j,' k',k,' l',l
5755 cd call checkint4(i,j,k,l,jj,kk,eel4_num)
5756 cold eij=facont_hb(jj,i)
5757 cold ekl=facont_hb(kk,k)
5759 eel4=-EAEA(1,1,1)-EAEA(2,2,1)
5761 cd eel41=-EAEA(1,1,2)-EAEA(2,2,2)
5762 gcorr_loc(k-1)=gcorr_loc(k-1)
5763 & -ekont*(EAEAderg(1,1,1,1)+EAEAderg(2,2,1,1))
5765 gcorr_loc(l-1)=gcorr_loc(l-1)
5766 & -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
5768 gcorr_loc(j-1)=gcorr_loc(j-1)
5769 & -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
5774 derx(lll,kkk,iii)=-EAEAderx(1,1,lll,kkk,iii,1)
5775 & -EAEAderx(2,2,lll,kkk,iii,1)
5776 cd derx(lll,kkk,iii)=0.0d0
5780 cd gcorr_loc(l-1)=0.0d0
5781 cd gcorr_loc(j-1)=0.0d0
5782 cd gcorr_loc(k-1)=0.0d0
5784 cd write (iout,*)'Contacts have occurred for peptide groups',
5785 cd & i,j,' fcont:',eij,' eij',' and ',k,l,
5786 cd & ' fcont ',ekl,' eel4=',eel4,' eel4_num',16*eel4_num
5787 if (j.lt.nres-1) then
5794 if (l.lt.nres-1) then
5802 cold ghalf=0.5d0*eel4*ekl*gacont_hbr(ll,jj,i)
5803 ggg1(ll)=eel4*g_contij(ll,1)
5804 ggg2(ll)=eel4*g_contij(ll,2)
5805 ghalf=0.5d0*ggg1(ll)
5807 gradcorr(ll,i)=gradcorr(ll,i)+ghalf+ekont*derx(ll,2,1)
5808 gradcorr(ll,i+1)=gradcorr(ll,i+1)+ekont*derx(ll,3,1)
5809 gradcorr(ll,j)=gradcorr(ll,j)+ghalf+ekont*derx(ll,4,1)
5810 gradcorr(ll,j1)=gradcorr(ll,j1)+ekont*derx(ll,5,1)
5811 cold ghalf=0.5d0*eel4*eij*gacont_hbr(ll,kk,k)
5812 ghalf=0.5d0*ggg2(ll)
5814 gradcorr(ll,k)=gradcorr(ll,k)+ghalf+ekont*derx(ll,2,2)
5815 gradcorr(ll,k+1)=gradcorr(ll,k+1)+ekont*derx(ll,3,2)
5816 gradcorr(ll,l)=gradcorr(ll,l)+ghalf+ekont*derx(ll,4,2)
5817 gradcorr(ll,l1)=gradcorr(ll,l1)+ekont*derx(ll,5,2)
5822 cold gradcorr(ll,m)=gradcorr(ll,m)+eel4*ekl*gacont_hbr(ll,jj,i)
5823 gradcorr(ll,m)=gradcorr(ll,m)+ggg1(ll)
5828 cold gradcorr(ll,m)=gradcorr(ll,m)+eel4*eij*gacont_hbr(ll,kk,k)
5829 gradcorr(ll,m)=gradcorr(ll,m)+ggg2(ll)
5835 gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,1)
5840 gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,2)
5844 cd write (2,*) iii,gcorr_loc(iii)
5848 cd write (2,*) 'ekont',ekont
5849 cd write (iout,*) 'eello4',ekont*eel4
5852 C---------------------------------------------------------------------------
5853 double precision function eello5(i,j,k,l,jj,kk)
5854 implicit real*8 (a-h,o-z)
5855 include 'DIMENSIONS'
5856 include 'DIMENSIONS.ZSCOPT'
5857 include 'COMMON.IOUNITS'
5858 include 'COMMON.CHAIN'
5859 include 'COMMON.DERIV'
5860 include 'COMMON.INTERACT'
5861 include 'COMMON.CONTACTS'
5862 include 'COMMON.TORSION'
5863 include 'COMMON.VAR'
5864 include 'COMMON.GEO'
5865 double precision pizda(2,2),auxmat(2,2),auxmat1(2,2),vv(2)
5866 double precision ggg1(3),ggg2(3)
5867 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
5872 C /l\ / \ \ / \ / \ / C
5873 C / \ / \ \ / \ / \ / C
5874 C j| o |l1 | o | o| o | | o |o C
5875 C \ |/k\| |/ \| / |/ \| |/ \| C
5876 C \i/ \ / \ / / \ / \ C
5878 C (I) (II) (III) (IV) C
5880 C eello5_1 eello5_2 eello5_3 eello5_4 C
5882 C Antiparallel chains C
5885 C /j\ / \ \ / \ / \ / C
5886 C / \ / \ \ / \ / \ / C
5887 C j1| o |l | o | o| o | | o |o C
5888 C \ |/k\| |/ \| / |/ \| |/ \| C
5889 C \i/ \ / \ / / \ / \ C
5891 C (I) (II) (III) (IV) C
5893 C eello5_1 eello5_2 eello5_3 eello5_4 C
5895 C o denotes a local interaction, vertical lines an electrostatic interaction. C
5897 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
5898 cd if (i.ne.2 .or. j.ne.6 .or. k.ne.3 .or. l.ne.5) then
5903 cd & 'EELLO5: Contacts have occurred for peptide groups',i,j,
5905 itk=itortyp(itype(k))
5906 itl=itortyp(itype(l))
5907 itj=itortyp(itype(j))
5912 cd call checkint5(i,j,k,l,jj,kk,eel5_1_num,eel5_2_num,
5913 cd & eel5_3_num,eel5_4_num)
5917 derx(lll,kkk,iii)=0.0d0
5921 cd eij=facont_hb(jj,i)
5922 cd ekl=facont_hb(kk,k)
5924 cd write (iout,*)'Contacts have occurred for peptide groups',
5925 cd & i,j,' fcont:',eij,' eij',' and ',k,l
5927 C Contribution from the graph I.
5928 cd write (2,*) 'AEA ',AEA(1,1,1),AEA(2,1,1),AEA(1,2,1),AEA(2,2,1)
5929 cd write (2,*) 'AEAb2',AEAb2(1,1,1),AEAb2(2,1,1)
5930 call transpose2(EUg(1,1,k),auxmat(1,1))
5931 call matmat2(AEA(1,1,1),auxmat(1,1),pizda(1,1))
5932 vv(1)=pizda(1,1)-pizda(2,2)
5933 vv(2)=pizda(1,2)+pizda(2,1)
5934 eello5_1=scalar2(AEAb2(1,1,1),Ub2(1,k))
5935 & +0.5d0*scalar2(vv(1),Dtobr2(1,i))
5937 C Explicit gradient in virtual-dihedral angles.
5938 if (i.gt.1) g_corr5_loc(i-1)=g_corr5_loc(i-1)
5939 & +ekont*(scalar2(AEAb2derg(1,2,1,1),Ub2(1,k))
5940 & +0.5d0*scalar2(vv(1),Dtobr2der(1,i)))
5941 call transpose2(EUgder(1,1,k),auxmat1(1,1))
5942 call matmat2(AEA(1,1,1),auxmat1(1,1),pizda(1,1))
5943 vv(1)=pizda(1,1)-pizda(2,2)
5944 vv(2)=pizda(1,2)+pizda(2,1)
5945 g_corr5_loc(k-1)=g_corr5_loc(k-1)
5946 & +ekont*(scalar2(AEAb2(1,1,1),Ub2der(1,k))
5947 & +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
5948 call matmat2(AEAderg(1,1,1),auxmat(1,1),pizda(1,1))
5949 vv(1)=pizda(1,1)-pizda(2,2)
5950 vv(2)=pizda(1,2)+pizda(2,1)
5952 if (l.lt.nres-1) g_corr5_loc(l-1)=g_corr5_loc(l-1)
5953 & +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k))
5954 & +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
5956 if (j.lt.nres-1) g_corr5_loc(j-1)=g_corr5_loc(j-1)
5957 & +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k))
5958 & +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
5960 C Cartesian gradient
5964 call matmat2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1),
5966 vv(1)=pizda(1,1)-pizda(2,2)
5967 vv(2)=pizda(1,2)+pizda(2,1)
5968 derx(lll,kkk,iii)=derx(lll,kkk,iii)
5969 & +scalar2(AEAb2derx(1,lll,kkk,iii,1,1),Ub2(1,k))
5970 & +0.5d0*scalar2(vv(1),Dtobr2(1,i))
5977 C Contribution from graph II
5978 call transpose2(EE(1,1,itk),auxmat(1,1))
5979 call matmat2(auxmat(1,1),AEA(1,1,1),pizda(1,1))
5980 vv(1)=pizda(1,1)+pizda(2,2)
5981 vv(2)=pizda(2,1)-pizda(1,2)
5982 eello5_2=scalar2(AEAb1(1,2,1),b1(1,itk))
5983 & -0.5d0*scalar2(vv(1),Ctobr(1,k))
5985 C Explicit gradient in virtual-dihedral angles.
5986 g_corr5_loc(k-1)=g_corr5_loc(k-1)
5987 & -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,k))
5988 call matmat2(auxmat(1,1),AEAderg(1,1,1),pizda(1,1))
5989 vv(1)=pizda(1,1)+pizda(2,2)
5990 vv(2)=pizda(2,1)-pizda(1,2)
5992 g_corr5_loc(l-1)=g_corr5_loc(l-1)
5993 & +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,itk))
5994 & -0.5d0*scalar2(vv(1),Ctobr(1,k)))
5996 g_corr5_loc(j-1)=g_corr5_loc(j-1)
5997 & +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,itk))
5998 & -0.5d0*scalar2(vv(1),Ctobr(1,k)))
6000 C Cartesian gradient
6004 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),
6006 vv(1)=pizda(1,1)+pizda(2,2)
6007 vv(2)=pizda(2,1)-pizda(1,2)
6008 derx(lll,kkk,iii)=derx(lll,kkk,iii)
6009 & +scalar2(AEAb1derx(1,lll,kkk,iii,2,1),b1(1,itk))
6010 & -0.5d0*scalar2(vv(1),Ctobr(1,k))
6019 C Parallel orientation
6020 C Contribution from graph III
6021 call transpose2(EUg(1,1,l),auxmat(1,1))
6022 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
6023 vv(1)=pizda(1,1)-pizda(2,2)
6024 vv(2)=pizda(1,2)+pizda(2,1)
6025 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,l))
6026 & +0.5d0*scalar2(vv(1),Dtobr2(1,j))
6028 C Explicit gradient in virtual-dihedral angles.
6029 g_corr5_loc(j-1)=g_corr5_loc(j-1)
6030 & +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,l))
6031 & +0.5d0*scalar2(vv(1),Dtobr2der(1,j)))
6032 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
6033 vv(1)=pizda(1,1)-pizda(2,2)
6034 vv(2)=pizda(1,2)+pizda(2,1)
6035 g_corr5_loc(k-1)=g_corr5_loc(k-1)
6036 & +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,l))
6037 & +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
6038 call transpose2(EUgder(1,1,l),auxmat1(1,1))
6039 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
6040 vv(1)=pizda(1,1)-pizda(2,2)
6041 vv(2)=pizda(1,2)+pizda(2,1)
6042 g_corr5_loc(l-1)=g_corr5_loc(l-1)
6043 & +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,l))
6044 & +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
6045 C Cartesian gradient
6049 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),
6051 vv(1)=pizda(1,1)-pizda(2,2)
6052 vv(2)=pizda(1,2)+pizda(2,1)
6053 derx(lll,kkk,iii)=derx(lll,kkk,iii)
6054 & +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,l))
6055 & +0.5d0*scalar2(vv(1),Dtobr2(1,j))
6061 C Contribution from graph IV
6063 call transpose2(EE(1,1,itl),auxmat(1,1))
6064 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
6065 vv(1)=pizda(1,1)+pizda(2,2)
6066 vv(2)=pizda(2,1)-pizda(1,2)
6067 eello5_4=scalar2(AEAb1(1,2,2),b1(1,itl))
6068 & -0.5d0*scalar2(vv(1),Ctobr(1,l))
6070 C Explicit gradient in virtual-dihedral angles.
6071 g_corr5_loc(l-1)=g_corr5_loc(l-1)
6072 & -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,l))
6073 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
6074 vv(1)=pizda(1,1)+pizda(2,2)
6075 vv(2)=pizda(2,1)-pizda(1,2)
6076 g_corr5_loc(k-1)=g_corr5_loc(k-1)
6077 & +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,itl))
6078 & -0.5d0*scalar2(vv(1),Ctobr(1,l)))
6079 C Cartesian gradient
6083 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
6085 vv(1)=pizda(1,1)+pizda(2,2)
6086 vv(2)=pizda(2,1)-pizda(1,2)
6087 derx(lll,kkk,iii)=derx(lll,kkk,iii)
6088 & +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,itl))
6089 & -0.5d0*scalar2(vv(1),Ctobr(1,l))
6095 C Antiparallel orientation
6096 C Contribution from graph III
6098 call transpose2(EUg(1,1,j),auxmat(1,1))
6099 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
6100 vv(1)=pizda(1,1)-pizda(2,2)
6101 vv(2)=pizda(1,2)+pizda(2,1)
6102 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,j))
6103 & +0.5d0*scalar2(vv(1),Dtobr2(1,l))
6105 C Explicit gradient in virtual-dihedral angles.
6106 g_corr5_loc(l-1)=g_corr5_loc(l-1)
6107 & +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,j))
6108 & +0.5d0*scalar2(vv(1),Dtobr2der(1,l)))
6109 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
6110 vv(1)=pizda(1,1)-pizda(2,2)
6111 vv(2)=pizda(1,2)+pizda(2,1)
6112 g_corr5_loc(k-1)=g_corr5_loc(k-1)
6113 & +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,j))
6114 & +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
6115 call transpose2(EUgder(1,1,j),auxmat1(1,1))
6116 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
6117 vv(1)=pizda(1,1)-pizda(2,2)
6118 vv(2)=pizda(1,2)+pizda(2,1)
6119 g_corr5_loc(j-1)=g_corr5_loc(j-1)
6120 & +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,j))
6121 & +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
6122 C Cartesian gradient
6126 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),
6128 vv(1)=pizda(1,1)-pizda(2,2)
6129 vv(2)=pizda(1,2)+pizda(2,1)
6130 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)
6131 & +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,j))
6132 & +0.5d0*scalar2(vv(1),Dtobr2(1,l))
6138 C Contribution from graph IV
6140 call transpose2(EE(1,1,itj),auxmat(1,1))
6141 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
6142 vv(1)=pizda(1,1)+pizda(2,2)
6143 vv(2)=pizda(2,1)-pizda(1,2)
6144 eello5_4=scalar2(AEAb1(1,2,2),b1(1,itj))
6145 & -0.5d0*scalar2(vv(1),Ctobr(1,j))
6147 C Explicit gradient in virtual-dihedral angles.
6148 g_corr5_loc(j-1)=g_corr5_loc(j-1)
6149 & -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,j))
6150 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
6151 vv(1)=pizda(1,1)+pizda(2,2)
6152 vv(2)=pizda(2,1)-pizda(1,2)
6153 g_corr5_loc(k-1)=g_corr5_loc(k-1)
6154 & +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,itj))
6155 & -0.5d0*scalar2(vv(1),Ctobr(1,j)))
6156 C Cartesian gradient
6160 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
6162 vv(1)=pizda(1,1)+pizda(2,2)
6163 vv(2)=pizda(2,1)-pizda(1,2)
6164 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)
6165 & +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,itj))
6166 & -0.5d0*scalar2(vv(1),Ctobr(1,j))
6173 eel5=eello5_1+eello5_2+eello5_3+eello5_4
6174 cd if (i.eq.2 .and. j.eq.8 .and. k.eq.3 .and. l.eq.7) then
6175 cd write (2,*) 'ijkl',i,j,k,l
6176 cd write (2,*) 'eello5_1',eello5_1,' eello5_2',eello5_2,
6177 cd & ' eello5_3',eello5_3,' eello5_4',eello5_4
6179 cd write(iout,*) 'eello5_1',eello5_1,' eel5_1_num',16*eel5_1_num
6180 cd write(iout,*) 'eello5_2',eello5_2,' eel5_2_num',16*eel5_2_num
6181 cd write(iout,*) 'eello5_3',eello5_3,' eel5_3_num',16*eel5_3_num
6182 cd write(iout,*) 'eello5_4',eello5_4,' eel5_4_num',16*eel5_4_num
6184 if (j.lt.nres-1) then
6191 if (l.lt.nres-1) then
6201 cd write (2,*) 'eij',eij,' ekl',ekl,' ekont',ekont
6203 ggg1(ll)=eel5*g_contij(ll,1)
6204 ggg2(ll)=eel5*g_contij(ll,2)
6205 cold ghalf=0.5d0*eel5*ekl*gacont_hbr(ll,jj,i)
6206 ghalf=0.5d0*ggg1(ll)
6208 gradcorr5(ll,i)=gradcorr5(ll,i)+ghalf+ekont*derx(ll,2,1)
6209 gradcorr5(ll,i+1)=gradcorr5(ll,i+1)+ekont*derx(ll,3,1)
6210 gradcorr5(ll,j)=gradcorr5(ll,j)+ghalf+ekont*derx(ll,4,1)
6211 gradcorr5(ll,j1)=gradcorr5(ll,j1)+ekont*derx(ll,5,1)
6212 cold ghalf=0.5d0*eel5*eij*gacont_hbr(ll,kk,k)
6213 ghalf=0.5d0*ggg2(ll)
6215 gradcorr5(ll,k)=gradcorr5(ll,k)+ghalf+ekont*derx(ll,2,2)
6216 gradcorr5(ll,k+1)=gradcorr5(ll,k+1)+ekont*derx(ll,3,2)
6217 gradcorr5(ll,l)=gradcorr5(ll,l)+ghalf+ekont*derx(ll,4,2)
6218 gradcorr5(ll,l1)=gradcorr5(ll,l1)+ekont*derx(ll,5,2)
6223 cold gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*ekl*gacont_hbr(ll,jj,i)
6224 gradcorr5(ll,m)=gradcorr5(ll,m)+ggg1(ll)
6229 cold gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*eij*gacont_hbr(ll,kk,k)
6230 gradcorr5(ll,m)=gradcorr5(ll,m)+ggg2(ll)
6236 gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,1)
6241 gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,2)
6245 cd write (2,*) iii,g_corr5_loc(iii)
6249 cd write (2,*) 'ekont',ekont
6250 cd write (iout,*) 'eello5',ekont*eel5
6253 c--------------------------------------------------------------------------
6254 double precision function eello6(i,j,k,l,jj,kk)
6255 implicit real*8 (a-h,o-z)
6256 include 'DIMENSIONS'
6257 include 'DIMENSIONS.ZSCOPT'
6258 include 'COMMON.IOUNITS'
6259 include 'COMMON.CHAIN'
6260 include 'COMMON.DERIV'
6261 include 'COMMON.INTERACT'
6262 include 'COMMON.CONTACTS'
6263 include 'COMMON.TORSION'
6264 include 'COMMON.VAR'
6265 include 'COMMON.GEO'
6266 include 'COMMON.FFIELD'
6267 double precision ggg1(3),ggg2(3)
6268 cd if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
6273 cd & 'EELLO6: Contacts have occurred for peptide groups',i,j,
6281 cd call checkint6(i,j,k,l,jj,kk,eel6_1_num,eel6_2_num,
6282 cd & eel6_3_num,eel6_4_num,eel6_5_num,eel6_6_num)
6286 derx(lll,kkk,iii)=0.0d0
6290 cd eij=facont_hb(jj,i)
6291 cd ekl=facont_hb(kk,k)
6297 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
6298 eello6_2=eello6_graph1(j,i,l,k,2,.false.)
6299 eello6_3=eello6_graph2(i,j,k,l,jj,kk,.false.)
6300 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
6301 eello6_5=eello6_graph4(j,i,l,k,jj,kk,2,.false.)
6302 eello6_6=eello6_graph3(i,j,k,l,jj,kk,.false.)
6304 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
6305 eello6_2=eello6_graph1(l,k,j,i,2,.true.)
6306 eello6_3=eello6_graph2(i,l,k,j,jj,kk,.true.)
6307 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
6308 if (wturn6.eq.0.0d0 .or. j.ne.i+4) then
6309 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
6313 eello6_6=eello6_graph3(i,l,k,j,jj,kk,.true.)
6315 C If turn contributions are considered, they will be handled separately.
6316 eel6=eello6_1+eello6_2+eello6_3+eello6_4+eello6_5+eello6_6
6317 cd write(iout,*) 'eello6_1',eello6_1,' eel6_1_num',16*eel6_1_num
6318 cd write(iout,*) 'eello6_2',eello6_2,' eel6_2_num',16*eel6_2_num
6319 cd write(iout,*) 'eello6_3',eello6_3,' eel6_3_num',16*eel6_3_num
6320 cd write(iout,*) 'eello6_4',eello6_4,' eel6_4_num',16*eel6_4_num
6321 cd write(iout,*) 'eello6_5',eello6_5,' eel6_5_num',16*eel6_5_num
6322 cd write(iout,*) 'eello6_6',eello6_6,' eel6_6_num',16*eel6_6_num
6325 if (j.lt.nres-1) then
6332 if (l.lt.nres-1) then
6340 ggg1(ll)=eel6*g_contij(ll,1)
6341 ggg2(ll)=eel6*g_contij(ll,2)
6342 cold ghalf=0.5d0*eel6*ekl*gacont_hbr(ll,jj,i)
6343 ghalf=0.5d0*ggg1(ll)
6345 gradcorr6(ll,i)=gradcorr6(ll,i)+ghalf+ekont*derx(ll,2,1)
6346 gradcorr6(ll,i+1)=gradcorr6(ll,i+1)+ekont*derx(ll,3,1)
6347 gradcorr6(ll,j)=gradcorr6(ll,j)+ghalf+ekont*derx(ll,4,1)
6348 gradcorr6(ll,j1)=gradcorr6(ll,j1)+ekont*derx(ll,5,1)
6349 ghalf=0.5d0*ggg2(ll)
6350 cold ghalf=0.5d0*eel6*eij*gacont_hbr(ll,kk,k)
6352 gradcorr6(ll,k)=gradcorr6(ll,k)+ghalf+ekont*derx(ll,2,2)
6353 gradcorr6(ll,k+1)=gradcorr6(ll,k+1)+ekont*derx(ll,3,2)
6354 gradcorr6(ll,l)=gradcorr6(ll,l)+ghalf+ekont*derx(ll,4,2)
6355 gradcorr6(ll,l1)=gradcorr6(ll,l1)+ekont*derx(ll,5,2)
6360 cold gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*ekl*gacont_hbr(ll,jj,i)
6361 gradcorr6(ll,m)=gradcorr6(ll,m)+ggg1(ll)
6366 cold gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*eij*gacont_hbr(ll,kk,k)
6367 gradcorr6(ll,m)=gradcorr6(ll,m)+ggg2(ll)
6373 gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,1)
6378 gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,2)
6382 cd write (2,*) iii,g_corr6_loc(iii)
6386 cd write (2,*) 'ekont',ekont
6387 cd write (iout,*) 'eello6',ekont*eel6
6390 c--------------------------------------------------------------------------
6391 double precision function eello6_graph1(i,j,k,l,imat,swap)
6392 implicit real*8 (a-h,o-z)
6393 include 'DIMENSIONS'
6394 include 'DIMENSIONS.ZSCOPT'
6395 include 'COMMON.IOUNITS'
6396 include 'COMMON.CHAIN'
6397 include 'COMMON.DERIV'
6398 include 'COMMON.INTERACT'
6399 include 'COMMON.CONTACTS'
6400 include 'COMMON.TORSION'
6401 include 'COMMON.VAR'
6402 include 'COMMON.GEO'
6403 double precision vv(2),vv1(2),pizda(2,2),auxmat(2,2),pizda1(2,2)
6407 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
6409 C Parallel Antiparallel C
6415 C \ j|/k\| / \ |/k\|l / C
6420 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
6421 itk=itortyp(itype(k))
6422 s1= scalar2(AEAb1(1,2,imat),CUgb2(1,i))
6423 s2=-scalar2(AEAb2(1,1,imat),Ug2Db1t(1,k))
6424 s3= scalar2(AEAb2(1,1,imat),CUgb2(1,k))
6425 call transpose2(EUgC(1,1,k),auxmat(1,1))
6426 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
6427 vv1(1)=pizda1(1,1)-pizda1(2,2)
6428 vv1(2)=pizda1(1,2)+pizda1(2,1)
6429 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
6430 vv(1)=AEAb1(1,2,imat)*b1(1,itk)-AEAb1(2,2,imat)*b1(2,itk)
6431 vv(2)=AEAb1(1,2,imat)*b1(2,itk)+AEAb1(2,2,imat)*b1(1,itk)
6432 s5=scalar2(vv(1),Dtobr2(1,i))
6433 cd write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4', s4,' s5',s5
6434 eello6_graph1=-0.5d0*(s1+s2+s3+s4+s5)
6435 if (.not. calc_grad) return
6436 if (i.gt.1) g_corr6_loc(i-1)=g_corr6_loc(i-1)
6437 & -0.5d0*ekont*(scalar2(AEAb1(1,2,imat),CUgb2der(1,i))
6438 & -scalar2(AEAb2derg(1,2,1,imat),Ug2Db1t(1,k))
6439 & +scalar2(AEAb2derg(1,2,1,imat),CUgb2(1,k))
6440 & +0.5d0*scalar2(vv1(1),Dtobr2der(1,i))
6441 & +scalar2(vv(1),Dtobr2der(1,i)))
6442 call matmat2(AEAderg(1,1,imat),auxmat(1,1),pizda1(1,1))
6443 vv1(1)=pizda1(1,1)-pizda1(2,2)
6444 vv1(2)=pizda1(1,2)+pizda1(2,1)
6445 vv(1)=AEAb1derg(1,2,imat)*b1(1,itk)-AEAb1derg(2,2,imat)*b1(2,itk)
6446 vv(2)=AEAb1derg(1,2,imat)*b1(2,itk)+AEAb1derg(2,2,imat)*b1(1,itk)
6448 g_corr6_loc(l-1)=g_corr6_loc(l-1)
6449 & +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i))
6450 & -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k))
6451 & +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k))
6452 & +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
6454 g_corr6_loc(j-1)=g_corr6_loc(j-1)
6455 & +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i))
6456 & -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k))
6457 & +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k))
6458 & +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
6460 call transpose2(EUgCder(1,1,k),auxmat(1,1))
6461 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
6462 vv1(1)=pizda1(1,1)-pizda1(2,2)
6463 vv1(2)=pizda1(1,2)+pizda1(2,1)
6464 if (k.gt.1) g_corr6_loc(k-1)=g_corr6_loc(k-1)
6465 & +ekont*(-0.5d0*(-scalar2(AEAb2(1,1,imat),Ug2Db1tder(1,k))
6466 & +scalar2(AEAb2(1,1,imat),CUgb2der(1,k))
6467 & +0.5d0*scalar2(vv1(1),Dtobr2(1,i))))
6476 s1= scalar2(AEAb1derx(1,lll,kkk,iii,2,imat),CUgb2(1,i))
6477 s2=-scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),Ug2Db1t(1,k))
6478 s3= scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),CUgb2(1,k))
6479 call transpose2(EUgC(1,1,k),auxmat(1,1))
6480 call matmat2(AEAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),
6482 vv1(1)=pizda1(1,1)-pizda1(2,2)
6483 vv1(2)=pizda1(1,2)+pizda1(2,1)
6484 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
6485 vv(1)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(1,itk)
6486 & -AEAb1derx(2,lll,kkk,iii,2,imat)*b1(2,itk)
6487 vv(2)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(2,itk)
6488 & +AEAb1derx(2,lll,kkk,iii,2,imat)*b1(1,itk)
6489 s5=scalar2(vv(1),Dtobr2(1,i))
6490 derx(lll,kkk,ind)=derx(lll,kkk,ind)-0.5d0*(s1+s2+s3+s4+s5)
6496 c----------------------------------------------------------------------------
6497 double precision function eello6_graph2(i,j,k,l,jj,kk,swap)
6498 implicit real*8 (a-h,o-z)
6499 include 'DIMENSIONS'
6500 include 'DIMENSIONS.ZSCOPT'
6501 include 'COMMON.IOUNITS'
6502 include 'COMMON.CHAIN'
6503 include 'COMMON.DERIV'
6504 include 'COMMON.INTERACT'
6505 include 'COMMON.CONTACTS'
6506 include 'COMMON.TORSION'
6507 include 'COMMON.VAR'
6508 include 'COMMON.GEO'
6510 double precision vv(2),pizda(2,2),auxmat(2,2),auxvec(2),
6511 & auxvec1(2),auxvec2(1),auxmat1(2,2)
6514 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
6516 C Parallel Antiparallel C
6522 C \ j|/k\| \ |/k\|l C
6527 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
6528 cd write (2,*) 'eello6_graph2: i,',i,' j',j,' k',k,' l',l
6529 C AL 7/4/01 s1 would occur in the sixth-order moment,
6530 C but not in a cluster cumulant
6532 s1=dip(1,jj,i)*dip(1,kk,k)
6534 call matvec2(ADtEA1(1,1,1),Ub2(1,k),auxvec(1))
6535 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
6536 call matvec2(ADtEA(1,1,2),Ub2(1,l),auxvec1(1))
6537 s3=-0.5d0*scalar2(Ub2(1,j),auxvec1(1))
6538 call transpose2(EUg(1,1,k),auxmat(1,1))
6539 call matmat2(ADtEA1(1,1,1),auxmat(1,1),pizda(1,1))
6540 vv(1)=pizda(1,1)-pizda(2,2)
6541 vv(2)=pizda(1,2)+pizda(2,1)
6542 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
6543 cd write (2,*) 'eello6_graph2:','s1',s1,' s2',s2,' s3',s3,' s4',s4
6545 eello6_graph2=-(s1+s2+s3+s4)
6547 eello6_graph2=-(s2+s3+s4)
6550 if (.not. calc_grad) return
6551 C Derivatives in gamma(i-1)
6554 s1=dipderg(1,jj,i)*dip(1,kk,k)
6556 s2=-0.5d0*scalar2(Ub2der(1,i),auxvec(1))
6557 call matvec2(ADtEAderg(1,1,1,2),Ub2(1,l),auxvec2(1))
6558 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
6559 s4=-0.25d0*scalar2(vv(1),Dtobr2der(1,i))
6561 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
6563 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
6565 c g_corr6_loc(i-1)=g_corr6_loc(i-1)-s3
6567 C Derivatives in gamma(k-1)
6569 s1=dip(1,jj,i)*dipderg(1,kk,k)
6571 call matvec2(ADtEA1(1,1,1),Ub2der(1,k),auxvec2(1))
6572 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
6573 call matvec2(ADtEAderg(1,1,2,2),Ub2(1,l),auxvec2(1))
6574 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
6575 call transpose2(EUgder(1,1,k),auxmat1(1,1))
6576 call matmat2(ADtEA1(1,1,1),auxmat1(1,1),pizda(1,1))
6577 vv(1)=pizda(1,1)-pizda(2,2)
6578 vv(2)=pizda(1,2)+pizda(2,1)
6579 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
6581 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
6583 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
6585 c g_corr6_loc(k-1)=g_corr6_loc(k-1)-s3
6586 C Derivatives in gamma(j-1) or gamma(l-1)
6589 s1=dipderg(3,jj,i)*dip(1,kk,k)
6591 call matvec2(ADtEA1derg(1,1,1,1),Ub2(1,k),auxvec2(1))
6592 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
6593 s3=-0.5d0*scalar2(Ub2der(1,j),auxvec1(1))
6594 call matmat2(ADtEA1derg(1,1,1,1),auxmat(1,1),pizda(1,1))
6595 vv(1)=pizda(1,1)-pizda(2,2)
6596 vv(2)=pizda(1,2)+pizda(2,1)
6597 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
6600 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
6602 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
6605 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s3+s4)
6606 c g_corr6_loc(j-1)=g_corr6_loc(j-1)-s3
6608 C Derivatives in gamma(l-1) or gamma(j-1)
6611 s1=dip(1,jj,i)*dipderg(3,kk,k)
6613 call matvec2(ADtEA1derg(1,1,2,1),Ub2(1,k),auxvec2(1))
6614 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
6615 call matvec2(ADtEA(1,1,2),Ub2der(1,l),auxvec2(1))
6616 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
6617 call matmat2(ADtEA1derg(1,1,2,1),auxmat(1,1),pizda(1,1))
6618 vv(1)=pizda(1,1)-pizda(2,2)
6619 vv(2)=pizda(1,2)+pizda(2,1)
6620 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
6623 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
6625 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
6628 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s3+s4)
6629 c g_corr6_loc(l-1)=g_corr6_loc(l-1)-s3
6631 C Cartesian derivatives.
6633 write (2,*) 'In eello6_graph2'
6635 write (2,*) 'iii=',iii
6637 write (2,*) 'kkk=',kkk
6639 write (2,'(3(2f10.5),5x)')
6640 & ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
6650 s1=dipderx(lll,kkk,1,jj,i)*dip(1,kk,k)
6652 s1=dip(1,jj,i)*dipderx(lll,kkk,1,kk,k)
6655 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,1),Ub2(1,k),
6657 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
6658 call matvec2(ADtEAderx(1,1,lll,kkk,iii,2),Ub2(1,l),
6660 s3=-0.5d0*scalar2(Ub2(1,j),auxvec(1))
6661 call transpose2(EUg(1,1,k),auxmat(1,1))
6662 call matmat2(ADtEA1derx(1,1,lll,kkk,iii,1),auxmat(1,1),
6664 vv(1)=pizda(1,1)-pizda(2,2)
6665 vv(2)=pizda(1,2)+pizda(2,1)
6666 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
6667 cd write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4',s4
6669 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
6671 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
6674 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
6676 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
6683 c----------------------------------------------------------------------------
6684 double precision function eello6_graph3(i,j,k,l,jj,kk,swap)
6685 implicit real*8 (a-h,o-z)
6686 include 'DIMENSIONS'
6687 include 'DIMENSIONS.ZSCOPT'
6688 include 'COMMON.IOUNITS'
6689 include 'COMMON.CHAIN'
6690 include 'COMMON.DERIV'
6691 include 'COMMON.INTERACT'
6692 include 'COMMON.CONTACTS'
6693 include 'COMMON.TORSION'
6694 include 'COMMON.VAR'
6695 include 'COMMON.GEO'
6696 double precision vv(2),pizda(2,2),auxmat(2,2),auxvec(2)
6698 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
6700 C Parallel Antiparallel C
6706 C j|/k\| / |/k\|l / C
6711 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
6713 C 4/7/01 AL Component s1 was removed, because it pertains to the respective
6714 C energy moment and not to the cluster cumulant.
6715 iti=itortyp(itype(i))
6716 if (j.lt.nres-1) then
6717 itj1=itortyp(itype(j+1))
6721 itk=itortyp(itype(k))
6722 itk1=itortyp(itype(k+1))
6723 if (l.lt.nres-1) then
6724 itl1=itortyp(itype(l+1))
6729 s1=dip(4,jj,i)*dip(4,kk,k)
6731 call matvec2(AECA(1,1,1),b1(1,itk1),auxvec(1))
6732 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
6733 call matvec2(AECA(1,1,2),b1(1,itl1),auxvec(1))
6734 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
6735 call transpose2(EE(1,1,itk),auxmat(1,1))
6736 call matmat2(auxmat(1,1),AECA(1,1,1),pizda(1,1))
6737 vv(1)=pizda(1,1)+pizda(2,2)
6738 vv(2)=pizda(2,1)-pizda(1,2)
6739 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
6740 cd write (2,*) 'eello6_graph3:','s1',s1,' s2',s2,' s3',s3,' s4',s4
6742 eello6_graph3=-(s1+s2+s3+s4)
6744 eello6_graph3=-(s2+s3+s4)
6747 if (.not. calc_grad) return
6748 C Derivatives in gamma(k-1)
6749 call matvec2(AECAderg(1,1,2),b1(1,itl1),auxvec(1))
6750 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
6751 s4=-0.25d0*scalar2(vv(1),Ctobrder(1,k))
6752 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s3+s4)
6753 C Derivatives in gamma(l-1)
6754 call matvec2(AECAderg(1,1,1),b1(1,itk1),auxvec(1))
6755 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
6756 call matmat2(auxmat(1,1),AECAderg(1,1,1),pizda(1,1))
6757 vv(1)=pizda(1,1)+pizda(2,2)
6758 vv(2)=pizda(2,1)-pizda(1,2)
6759 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
6760 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
6761 C Cartesian derivatives.
6767 s1=dipderx(lll,kkk,4,jj,i)*dip(4,kk,k)
6769 s1=dip(4,jj,i)*dipderx(lll,kkk,4,kk,k)
6772 call matvec2(AECAderx(1,1,lll,kkk,iii,1),b1(1,itk1),
6774 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
6775 call matvec2(AECAderx(1,1,lll,kkk,iii,2),b1(1,itl1),
6777 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
6778 call matmat2(auxmat(1,1),AECAderx(1,1,lll,kkk,iii,1),
6780 vv(1)=pizda(1,1)+pizda(2,2)
6781 vv(2)=pizda(2,1)-pizda(1,2)
6782 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
6784 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
6786 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
6789 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
6791 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
6793 c derx(lll,kkk,iii)=derx(lll,kkk,iii)-s4
6799 c----------------------------------------------------------------------------
6800 double precision function eello6_graph4(i,j,k,l,jj,kk,imat,swap)
6801 implicit real*8 (a-h,o-z)
6802 include 'DIMENSIONS'
6803 include 'DIMENSIONS.ZSCOPT'
6804 include 'COMMON.IOUNITS'
6805 include 'COMMON.CHAIN'
6806 include 'COMMON.DERIV'
6807 include 'COMMON.INTERACT'
6808 include 'COMMON.CONTACTS'
6809 include 'COMMON.TORSION'
6810 include 'COMMON.VAR'
6811 include 'COMMON.GEO'
6812 include 'COMMON.FFIELD'
6813 double precision vv(2),pizda(2,2),auxmat(2,2),auxvec(2),
6814 & auxvec1(2),auxmat1(2,2)
6816 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
6818 C Parallel Antiparallel C
6824 C \ j|/k\| \ |/k\|l C
6829 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
6831 C 4/7/01 AL Component s1 was removed, because it pertains to the respective
6832 C energy moment and not to the cluster cumulant.
6833 cd write (2,*) 'eello_graph4: wturn6',wturn6
6834 iti=itortyp(itype(i))
6835 itj=itortyp(itype(j))
6836 if (j.lt.nres-1) then
6837 itj1=itortyp(itype(j+1))
6841 itk=itortyp(itype(k))
6842 if (k.lt.nres-1) then
6843 itk1=itortyp(itype(k+1))
6847 itl=itortyp(itype(l))
6848 if (l.lt.nres-1) then
6849 itl1=itortyp(itype(l+1))
6853 cd write (2,*) 'eello6_graph4:','i',i,' j',j,' k',k,' l',l
6854 cd write (2,*) 'iti',iti,' itj',itj,' itj1',itj1,' itk',itk,
6855 cd & ' itl',itl,' itl1',itl1
6858 s1=dip(3,jj,i)*dip(3,kk,k)
6860 s1=dip(2,jj,j)*dip(2,kk,l)
6863 call matvec2(AECA(1,1,imat),Ub2(1,k),auxvec(1))
6864 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
6866 call matvec2(ADtEA1(1,1,3-imat),b1(1,itj1),auxvec1(1))
6867 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
6869 call matvec2(ADtEA1(1,1,3-imat),b1(1,itl1),auxvec1(1))
6870 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
6872 call transpose2(EUg(1,1,k),auxmat(1,1))
6873 call matmat2(AECA(1,1,imat),auxmat(1,1),pizda(1,1))
6874 vv(1)=pizda(1,1)-pizda(2,2)
6875 vv(2)=pizda(2,1)+pizda(1,2)
6876 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
6877 cd write (2,*) 'eello6_graph4:','s1',s1,' s2',s2,' s3',s3,' s4',s4
6879 eello6_graph4=-(s1+s2+s3+s4)
6881 eello6_graph4=-(s2+s3+s4)
6883 if (.not. calc_grad) return
6884 C Derivatives in gamma(i-1)
6888 s1=dipderg(2,jj,i)*dip(3,kk,k)
6890 s1=dipderg(4,jj,j)*dip(2,kk,l)
6893 s2=0.5d0*scalar2(Ub2der(1,i),auxvec(1))
6895 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,itj1),auxvec1(1))
6896 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
6898 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,itl1),auxvec1(1))
6899 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
6901 s4=0.25d0*scalar2(vv(1),Dtobr2der(1,i))
6902 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
6903 cd write (2,*) 'turn6 derivatives'
6905 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s1+s2+s3+s4)
6907 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s2+s3+s4)
6911 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
6913 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
6917 C Derivatives in gamma(k-1)
6920 s1=dip(3,jj,i)*dipderg(2,kk,k)
6922 s1=dip(2,jj,j)*dipderg(4,kk,l)
6925 call matvec2(AECA(1,1,imat),Ub2der(1,k),auxvec1(1))
6926 s2=0.5d0*scalar2(Ub2(1,i),auxvec1(1))
6928 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,itj1),auxvec1(1))
6929 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
6931 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,itl1),auxvec1(1))
6932 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
6934 call transpose2(EUgder(1,1,k),auxmat1(1,1))
6935 call matmat2(AECA(1,1,imat),auxmat1(1,1),pizda(1,1))
6936 vv(1)=pizda(1,1)-pizda(2,2)
6937 vv(2)=pizda(2,1)+pizda(1,2)
6938 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
6939 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
6941 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s1+s2+s3+s4)
6943 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s2+s3+s4)
6947 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
6949 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
6952 C Derivatives in gamma(j-1) or gamma(l-1)
6953 if (l.eq.j+1 .and. l.gt.1) then
6954 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
6955 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
6956 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
6957 vv(1)=pizda(1,1)-pizda(2,2)
6958 vv(2)=pizda(2,1)+pizda(1,2)
6959 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
6960 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
6961 else if (j.gt.1) then
6962 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
6963 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
6964 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
6965 vv(1)=pizda(1,1)-pizda(2,2)
6966 vv(2)=pizda(2,1)+pizda(1,2)
6967 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
6968 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
6969 gel_loc_turn6(j-1)=gel_loc_turn6(j-1)-ekont*(s2+s4)
6971 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s4)
6974 C Cartesian derivatives.
6981 s1=dipderx(lll,kkk,3,jj,i)*dip(3,kk,k)
6983 s1=dipderx(lll,kkk,2,jj,j)*dip(2,kk,l)
6987 s1=dip(3,jj,i)*dipderx(lll,kkk,3,kk,k)
6989 s1=dip(2,jj,j)*dipderx(lll,kkk,2,kk,l)
6993 call matvec2(AECAderx(1,1,lll,kkk,iii,imat),Ub2(1,k),
6995 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
6997 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),
6998 & b1(1,itj1),auxvec(1))
6999 s3=-0.5d0*scalar2(b1(1,itj),auxvec(1))
7001 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),
7002 & b1(1,itl1),auxvec(1))
7003 s3=-0.5d0*scalar2(b1(1,itl),auxvec(1))
7005 call matmat2(AECAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),
7007 vv(1)=pizda(1,1)-pizda(2,2)
7008 vv(2)=pizda(2,1)+pizda(1,2)
7009 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
7011 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
7013 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii)
7016 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii)
7019 derx_turn(lll,kkk,iii)=derx_turn(lll,kkk,iii)-s3
7022 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s1+s2+s4)
7024 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s2+s4)
7026 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
7030 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
7032 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
7035 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
7037 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
7045 c----------------------------------------------------------------------------
7046 double precision function eello_turn6(i,jj,kk)
7047 implicit real*8 (a-h,o-z)
7048 include 'DIMENSIONS'
7049 include 'DIMENSIONS.ZSCOPT'
7050 include 'COMMON.IOUNITS'
7051 include 'COMMON.CHAIN'
7052 include 'COMMON.DERIV'
7053 include 'COMMON.INTERACT'
7054 include 'COMMON.CONTACTS'
7055 include 'COMMON.TORSION'
7056 include 'COMMON.VAR'
7057 include 'COMMON.GEO'
7058 double precision vtemp1(2),vtemp2(2),vtemp3(2),vtemp4(2),
7059 & atemp(2,2),auxmat(2,2),achuj_temp(2,2),gtemp(2,2),gvec(2),
7061 double precision vtemp1d(2),vtemp2d(2),vtemp3d(2),vtemp4d(2),
7062 & atempd(2,2),auxmatd(2,2),achuj_tempd(2,2),gtempd(2,2),gvecd(2)
7063 C 4/7/01 AL Components s1, s8, and s13 were removed, because they pertain to
7064 C the respective energy moment and not to the cluster cumulant.
7069 iti=itortyp(itype(i))
7070 itk=itortyp(itype(k))
7071 itk1=itortyp(itype(k+1))
7072 itl=itortyp(itype(l))
7073 itj=itortyp(itype(j))
7074 cd write (2,*) 'itk',itk,' itk1',itk1,' itl',itl,' itj',itj
7075 cd write (2,*) 'i',i,' k',k,' j',j,' l',l
7076 cd if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
7081 cd & 'EELLO6: Contacts have occurred for peptide groups',i,j,
7083 cd call checkint_turn6(i,jj,kk,eel_turn6_num)
7087 derx_turn(lll,kkk,iii)=0.0d0
7094 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
7096 cd write (2,*) 'eello6_5',eello6_5
7098 call transpose2(AEA(1,1,1),auxmat(1,1))
7099 call matmat2(EUg(1,1,i+1),auxmat(1,1),auxmat(1,1))
7100 ss1=scalar2(Ub2(1,i+2),b1(1,itl))
7101 s1 = (auxmat(1,1)+auxmat(2,2))*ss1
7105 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1(1))
7106 call matvec2(AEA(1,1,1),vtemp1(1),vtemp1(1))
7107 s2 = scalar2(b1(1,itk),vtemp1(1))
7109 call transpose2(AEA(1,1,2),atemp(1,1))
7110 call matmat2(atemp(1,1),EUg(1,1,i+4),atemp(1,1))
7111 call matvec2(Ug2(1,1,i+2),dd(1,1,itk1),vtemp2(1))
7112 s8 = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
7116 call matmat2(EUg(1,1,i+3),AEA(1,1,2),auxmat(1,1))
7117 call matvec2(auxmat(1,1),Ub2(1,i+4),vtemp3(1))
7118 s12 = scalar2(Ub2(1,i+2),vtemp3(1))
7120 call transpose2(a_chuj(1,1,kk,i+1),achuj_temp(1,1))
7121 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtemp(1,1))
7122 call matmat2(gtemp(1,1),EUg(1,1,i+3),gtemp(1,1))
7123 call matvec2(a_chuj(1,1,jj,i),Ub2(1,i+4),vtemp4(1))
7124 ss13 = scalar2(b1(1,itk),vtemp4(1))
7125 s13 = (gtemp(1,1)+gtemp(2,2))*ss13
7129 c write (2,*) 's1,s2,s8,s12,s13',s1,s2,s8,s12,s13
7135 eel_turn6 = eello6_5 - 0.5d0*(s1+s2+s12+s8+s13)
7137 C Derivatives in gamma(i+2)
7139 call transpose2(AEA(1,1,1),auxmatd(1,1))
7140 call matmat2(EUgder(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
7141 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
7142 call transpose2(AEAderg(1,1,2),atempd(1,1))
7143 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
7144 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
7148 call matmat2(EUg(1,1,i+3),AEAderg(1,1,2),auxmatd(1,1))
7149 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
7150 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
7156 gel_loc_turn6(i)=gel_loc_turn6(i)-0.5d0*ekont*(s1d+s8d+s12d)
7157 C Derivatives in gamma(i+3)
7159 call transpose2(AEA(1,1,1),auxmatd(1,1))
7160 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
7161 ss1d=scalar2(Ub2der(1,i+2),b1(1,itl))
7162 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1d
7166 call matvec2(EUgder(1,1,i+2),b1(1,itl),vtemp1d(1))
7167 call matvec2(AEA(1,1,1),vtemp1d(1),vtemp1d(1))
7168 s2d = scalar2(b1(1,itk),vtemp1d(1))
7170 call matvec2(Ug2der(1,1,i+2),dd(1,1,itk1),vtemp2d(1))
7171 s8d = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,itl),vtemp2d(1))
7173 s12d = scalar2(Ub2der(1,i+2),vtemp3(1))
7175 call matmat2(achuj_temp(1,1),EUgder(1,1,i+2),gtempd(1,1))
7176 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
7177 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
7187 gel_loc_turn6(i+1)=gel_loc_turn6(i+1)
7188 & -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
7190 gel_loc_turn6(i+1)=gel_loc_turn6(i+1)
7191 & -0.5d0*ekont*(s2d+s12d)
7193 C Derivatives in gamma(i+4)
7194 call matmat2(EUgder(1,1,i+3),AEA(1,1,2),auxmatd(1,1))
7195 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
7196 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
7198 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtempd(1,1))
7199 call matmat2(gtempd(1,1),EUgder(1,1,i+3),gtempd(1,1))
7200 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
7210 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d+s13d)
7212 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d)
7214 C Derivatives in gamma(i+5)
7216 call transpose2(AEAderg(1,1,1),auxmatd(1,1))
7217 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
7218 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
7222 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1d(1))
7223 call matvec2(AEAderg(1,1,1),vtemp1d(1),vtemp1d(1))
7224 s2d = scalar2(b1(1,itk),vtemp1d(1))
7226 call transpose2(AEA(1,1,2),atempd(1,1))
7227 call matmat2(atempd(1,1),EUgder(1,1,i+4),atempd(1,1))
7228 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
7232 call matvec2(auxmat(1,1),Ub2der(1,i+4),vtemp3d(1))
7233 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
7235 call matvec2(a_chuj(1,1,jj,i),Ub2der(1,i+4),vtemp4d(1))
7236 ss13d = scalar2(b1(1,itk),vtemp4d(1))
7237 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
7247 gel_loc_turn6(i+3)=gel_loc_turn6(i+3)
7248 & -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
7250 gel_loc_turn6(i+3)=gel_loc_turn6(i+3)
7251 & -0.5d0*ekont*(s2d+s12d)
7253 C Cartesian derivatives
7258 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmatd(1,1))
7259 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
7260 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
7264 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1(1))
7265 call matvec2(AEAderx(1,1,lll,kkk,iii,1),vtemp1(1),
7267 s2d = scalar2(b1(1,itk),vtemp1d(1))
7269 call transpose2(AEAderx(1,1,lll,kkk,iii,2),atempd(1,1))
7270 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
7271 s8d = -(atempd(1,1)+atempd(2,2))*
7272 & scalar2(cc(1,1,itl),vtemp2(1))
7276 call matmat2(EUg(1,1,i+3),AEAderx(1,1,lll,kkk,iii,2),
7278 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
7279 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
7286 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii)
7289 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii)
7293 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii)
7294 & - 0.5d0*(s8d+s12d)
7296 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii)
7305 call transpose2(a_chuj_der(1,1,lll,kkk,kk,i+1),
7307 call matmat2(achuj_tempd(1,1),EUg(1,1,i+2),gtempd(1,1))
7308 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
7309 s13d=(gtempd(1,1)+gtempd(2,2))*ss13
7310 derx_turn(lll,kkk,2) = derx_turn(lll,kkk,2)-0.5d0*s13d
7311 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),Ub2(1,i+4),
7313 ss13d = scalar2(b1(1,itk),vtemp4d(1))
7314 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
7315 derx_turn(lll,kkk,1) = derx_turn(lll,kkk,1)-0.5d0*s13d
7319 cd write(iout,*) 'eel6_turn6',eel_turn6,' eel_turn6_num',
7320 cd & 16*eel_turn6_num
7322 if (j.lt.nres-1) then
7329 if (l.lt.nres-1) then
7337 ggg1(ll)=eel_turn6*g_contij(ll,1)
7338 ggg2(ll)=eel_turn6*g_contij(ll,2)
7339 ghalf=0.5d0*ggg1(ll)
7341 gcorr6_turn(ll,i)=gcorr6_turn(ll,i)+ghalf
7342 & +ekont*derx_turn(ll,2,1)
7343 gcorr6_turn(ll,i+1)=gcorr6_turn(ll,i+1)+ekont*derx_turn(ll,3,1)
7344 gcorr6_turn(ll,j)=gcorr6_turn(ll,j)+ghalf
7345 & +ekont*derx_turn(ll,4,1)
7346 gcorr6_turn(ll,j1)=gcorr6_turn(ll,j1)+ekont*derx_turn(ll,5,1)
7347 ghalf=0.5d0*ggg2(ll)
7349 gcorr6_turn(ll,k)=gcorr6_turn(ll,k)+ghalf
7350 & +ekont*derx_turn(ll,2,2)
7351 gcorr6_turn(ll,k+1)=gcorr6_turn(ll,k+1)+ekont*derx_turn(ll,3,2)
7352 gcorr6_turn(ll,l)=gcorr6_turn(ll,l)+ghalf
7353 & +ekont*derx_turn(ll,4,2)
7354 gcorr6_turn(ll,l1)=gcorr6_turn(ll,l1)+ekont*derx_turn(ll,5,2)
7359 gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg1(ll)
7364 gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg2(ll)
7370 gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,1)
7375 gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,2)
7379 cd write (2,*) iii,g_corr6_loc(iii)
7382 eello_turn6=ekont*eel_turn6
7383 cd write (2,*) 'ekont',ekont
7384 cd write (2,*) 'eel_turn6',ekont*eel_turn6
7387 crc-------------------------------------------------
7388 SUBROUTINE MATVEC2(A1,V1,V2)
7389 implicit real*8 (a-h,o-z)
7390 include 'DIMENSIONS'
7391 DIMENSION A1(2,2),V1(2),V2(2)
7395 c 3 VI=VI+A1(I,K)*V1(K)
7399 vaux1=a1(1,1)*v1(1)+a1(1,2)*v1(2)
7400 vaux2=a1(2,1)*v1(1)+a1(2,2)*v1(2)
7405 C---------------------------------------
7406 SUBROUTINE MATMAT2(A1,A2,A3)
7407 implicit real*8 (a-h,o-z)
7408 include 'DIMENSIONS'
7409 DIMENSION A1(2,2),A2(2,2),A3(2,2)
7410 c DIMENSION AI3(2,2)
7414 c A3IJ=A3IJ+A1(I,K)*A2(K,J)
7420 ai3_11=a1(1,1)*a2(1,1)+a1(1,2)*a2(2,1)
7421 ai3_12=a1(1,1)*a2(1,2)+a1(1,2)*a2(2,2)
7422 ai3_21=a1(2,1)*a2(1,1)+a1(2,2)*a2(2,1)
7423 ai3_22=a1(2,1)*a2(1,2)+a1(2,2)*a2(2,2)
7431 c-------------------------------------------------------------------------
7432 double precision function scalar2(u,v)
7434 double precision u(2),v(2)
7437 scalar2=u(1)*v(1)+u(2)*v(2)
7441 C-----------------------------------------------------------------------------
7443 subroutine transpose2(a,at)
7445 double precision a(2,2),at(2,2)
7452 c--------------------------------------------------------------------------
7453 subroutine transpose(n,a,at)
7456 double precision a(n,n),at(n,n)
7464 C---------------------------------------------------------------------------
7465 subroutine prodmat3(a1,a2,kk,transp,prod)
7468 double precision a1(2,2),a2(2,2),a2t(2,2),kk(2,2),prod(2,2)
7470 crc double precision auxmat(2,2),prod_(2,2)
7473 crc call transpose2(kk(1,1),auxmat(1,1))
7474 crc call matmat2(a1(1,1),auxmat(1,1),auxmat(1,1))
7475 crc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
7477 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,1)
7478 & +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,1)
7479 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,2)
7480 & +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,2)
7481 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,1)
7482 & +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,1)
7483 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,2)
7484 & +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,2)
7487 crc call matmat2(a1(1,1),kk(1,1),auxmat(1,1))
7488 crc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
7490 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,1)
7491 & +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,1)
7492 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,2)
7493 & +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,2)
7494 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,1)
7495 & +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,1)
7496 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,2)
7497 & +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,2)
7500 c call transpose2(a2(1,1),a2t(1,1))
7503 crc print *,((prod_(i,j),i=1,2),j=1,2)
7504 crc print *,((prod(i,j),i=1,2),j=1,2)
7508 C-----------------------------------------------------------------------------
7509 double precision function scalar(u,v)
7511 double precision u(3),v(3)