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 include 'COMMON.CONTROL'
26 double precision fact(6)
27 cd write(iout, '(a,i2)')'Calling etotal ipot=',ipot
28 cd print *,'nnt=',nnt,' nct=',nct
30 C Compute the side-chain and electrostatic interaction energy
32 goto (101,102,103,104,105) ipot
33 C Lennard-Jones potential.
34 101 call elj(evdw,evdw_t)
35 cd print '(a)','Exit ELJ'
37 C Lennard-Jones-Kihara potential (shifted).
38 102 call eljk(evdw,evdw_t)
40 C Berne-Pechukas potential (dilated LJ, angular dependence).
41 103 call ebp(evdw,evdw_t)
43 C Gay-Berne potential (shifted LJ, angular dependence).
44 104 call egb(evdw,evdw_t)
46 C Gay-Berne-Vorobjev potential (shifted LJ, angular dependence).
47 105 call egbv(evdw,evdw_t)
49 C Calculate electrostatic (H-bonding) energy of the main chain.
51 106 call eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
53 C Calculate excluded-volume interaction energy between peptide groups
56 call escp(evdw2,evdw2_14)
58 c Calculate the bond-stretching energy
61 c write (iout,*) "estr",estr
63 C Calculate the disulfide-bridge and other energy and the contributions
64 C from other distance constraints.
65 cd print *,'Calling EHPB'
67 cd print *,'EHPB exitted succesfully.'
69 C Calculate the virtual-bond-angle energy.
72 cd print *,'Bend energy finished.'
74 C Calculate the SC local energy.
77 cd print *,'SCLOC energy finished.'
79 C Calculate the virtual-bond torsional energy.
81 cd print *,'nterm=',nterm
82 call etor(etors,edihcnstr,fact(1))
84 C 6/23/01 Calculate double-torsional energy
86 call etor_d(etors_d,fact(2))
88 C 21/5/07 Calculate local sicdechain correlation energy
90 call eback_sc_corr(esccor)
92 C 12/1/95 Multi-body terms
96 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0
97 & .or. wturn6.gt.0.0d0) then
98 c print *,"calling multibody_eello"
99 call multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
100 c write (*,*) 'n_corr=',n_corr,' n_corr1=',n_corr1
101 c print *,ecorr,ecorr5,ecorr6,eturn6
103 if (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) then
104 call multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
108 c write(iout,*) "TEST_ENE1 constr_homology=",constr_homology
109 if (constr_homology.ge.1) then
110 call e_modeller(ehomology_constr)
112 ehomology_constr=0.0d0
115 c write(iout,*) "TEST_ENE1 ehomology_constr=",ehomology_constr
118 c write (iout,*) "ft(6)",fact(6)," evdw",evdw," evdw_t",evdw_t
120 etot=wsc*(evdw+fact(6)*evdw_t)+wscp*evdw2+welec*fact(1)*ees
122 & +wang*ebe+wtor*fact(1)*etors+wscloc*escloc
123 & +wstrain*ehpb+wcorr*fact(3)*ecorr+wcorr5*fact(4)*ecorr5
124 & +wcorr6*fact(5)*ecorr6+wturn4*fact(3)*eello_turn4
125 & +wturn3*fact(2)*eello_turn3+wturn6*fact(5)*eturn6
126 & +wel_loc*fact(2)*eel_loc+edihcnstr+wtor_d*fact(2)*etors_d
127 & +wbond*estr+wsccor*fact(1)*esccor+ehomology_constr
129 etot=wsc*(evdw+fact(6)*evdw_t)+wscp*evdw2
130 & +welec*fact(1)*(ees+evdw1)
131 & +wang*ebe+wtor*fact(1)*etors+wscloc*escloc
132 & +wstrain*ehpb+wcorr*fact(3)*ecorr+wcorr5*fact(4)*ecorr5
133 & +wcorr6*fact(5)*ecorr6+wturn4*fact(3)*eello_turn4
134 & +wturn3*fact(2)*eello_turn3+wturn6*fact(5)*eturn6
135 & +wel_loc*fact(2)*eel_loc+edihcnstr+wtor_d*fact(2)*etors_d
136 & +wbond*estr+wsccor*fact(1)*esccor+ehomology_constr
141 energia(2)=evdw2-evdw2_14
158 energia(8)=eello_turn3
159 energia(9)=eello_turn4
168 energia(20)=edihcnstr
170 energia(22)=ehomology_constr
171 c if (dyn_ss) call dyn_set_nss
175 if (isnan(etot).ne.0) energia(0)=1.0d+99
177 if (isnan(etot)) energia(0)=1.0d+99
182 idumm=proc_proc(etot,i)
184 call proc_proc(etot,i)
186 if(i.eq.1)energia(0)=1.0d+99
193 C Sum up the components of the Cartesian gradient.
198 gradc(j,i,icg)=wsc*gvdwc(j,i)+wscp*gvdwc_scp(j,i)+
199 & welec*fact(1)*gelc(j,i)+wvdwpp*gvdwpp(j,i)+
201 & wstrain*ghpbc(j,i)+
202 & wcorr*fact(3)*gradcorr(j,i)+
203 & wel_loc*fact(2)*gel_loc(j,i)+
204 & wturn3*fact(2)*gcorr3_turn(j,i)+
205 & wturn4*fact(3)*gcorr4_turn(j,i)+
206 & wcorr5*fact(4)*gradcorr5(j,i)+
207 & wcorr6*fact(5)*gradcorr6(j,i)+
208 & wturn6*fact(5)*gcorr6_turn(j,i)+
209 & wsccor*fact(2)*gsccorc(j,i)
210 gradx(j,i,icg)=wsc*gvdwx(j,i)+wscp*gradx_scp(j,i)+
212 & wstrain*ghpbx(j,i)+wcorr*gradxorr(j,i)+
213 & wsccor*fact(2)*gsccorx(j,i)
218 gradc(j,i,icg)=wsc*gvdwc(j,i)+wscp*gvdwc_scp(j,i)+
219 & welec*fact(1)*gelc(j,i)+wstrain*ghpbc(j,i)+
221 & wcorr*fact(3)*gradcorr(j,i)+
222 & wel_loc*fact(2)*gel_loc(j,i)+
223 & wturn3*fact(2)*gcorr3_turn(j,i)+
224 & wturn4*fact(3)*gcorr4_turn(j,i)+
225 & wcorr5*fact(4)*gradcorr5(j,i)+
226 & wcorr6*fact(5)*gradcorr6(j,i)+
227 & wturn6*fact(5)*gcorr6_turn(j,i)+
228 & wsccor*fact(2)*gsccorc(j,i)
229 gradx(j,i,icg)=wsc*gvdwx(j,i)+wscp*gradx_scp(j,i)+
231 & wstrain*ghpbx(j,i)+wcorr*gradxorr(j,i)+
232 & wsccor*fact(1)*gsccorx(j,i)
239 gloc(i,icg)=gloc(i,icg)+wcorr*fact(3)*gcorr_loc(i)
240 & +wcorr5*fact(4)*g_corr5_loc(i)
241 & +wcorr6*fact(5)*g_corr6_loc(i)
242 & +wturn4*fact(3)*gel_loc_turn4(i)
243 & +wturn3*fact(2)*gel_loc_turn3(i)
244 & +wturn6*fact(5)*gel_loc_turn6(i)
245 & +wel_loc*fact(2)*gel_loc_loc(i)
246 & +wsccor*fact(1)*gsccor_loc(i)
251 C------------------------------------------------------------------------
252 subroutine enerprint(energia,fact)
253 implicit real*8 (a-h,o-z)
255 include 'DIMENSIONS.ZSCOPT'
256 include 'COMMON.IOUNITS'
257 include 'COMMON.FFIELD'
258 include 'COMMON.SBRIDGE'
259 double precision energia(0:max_ene),fact(6)
261 evdw=energia(1)+fact(6)*energia(21)
263 evdw2=energia(2)+energia(17)
275 eello_turn3=energia(8)
276 eello_turn4=energia(9)
277 eello_turn6=energia(10)
284 edihcnstr=energia(20)
286 ehomology_constr=energia(22)
288 write (iout,10) evdw,wsc,evdw2,wscp,ees,welec*fact(1),evdw1,
290 & estr,wbond,ebe,wang,escloc,wscloc,etors,wtor*fact(1),
291 & etors_d,wtor_d*fact(2),ehpb,wstrain,
292 & ecorr,wcorr*fact(3),ecorr5,wcorr5*fact(4),ecorr6,wcorr6*fact(5),
293 & eel_loc,wel_loc*fact(2),eello_turn3,wturn3*fact(2),
294 & eello_turn4,wturn4*fact(3),eello_turn6,wturn6*fact(5),
295 & esccor,wsccor*fact(1),edihcnstr,ehomology_constr,ebr*nss,etot
296 10 format (/'Virtual-chain energies:'//
297 & 'EVDW= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-SC)'/
298 & 'EVDW2= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-p)'/
299 & 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p elec)'/
300 & 'EVDWPP=',1pE16.6,' WEIGHT=',1pD16.6,' (p-p VDW)'/
301 & 'ESTR= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching)'/
302 & 'EBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (bending)'/
303 & 'ESC= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/
304 & 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/
305 & 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/
306 & 'EHBP= ',1pE16.6,' WEIGHT=',1pD16.6,
307 & ' (SS bridges & dist. cnstr.)'/
308 & 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
309 & 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
310 & 'ECORR6=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
311 & 'EELLO= ',1pE16.6,' WEIGHT=',1pD16.6,' (electrostatic-local)'/
312 & 'ETURN3=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 3rd order)'/
313 & 'ETURN4=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 4th order)'/
314 & 'ETURN6=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 6th order)'/
315 & 'ESCCOR=',1pE16.6,' WEIGHT=',1pD16.6,' (backbone-rotamer corr)'/
316 & 'EDIHC= ',1pE16.6,' (dihedral angle constraints)'/
317 & 'H_CONS=',1pE16.6,' (Homology model constraints energy)'/
318 & 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/
319 & 'ETOT= ',1pE16.6,' (total)')
321 write (iout,10) evdw,wsc,evdw2,wscp,ees,welec*fact(1),estr,wbond,
322 & ebe,wang,escloc,wscloc,etors,wtor*fact(1),etors_d,wtor_d*fact2,
323 & ehpb,wstrain,ecorr,wcorr*fact(3),ecorr5,wcorr5*fact(4),
324 & ecorr6,wcorr6*fact(5),eel_loc,wel_loc*fact(2),
325 & eello_turn3,wturn3*fact(2),eello_turn4,wturn4*fact(3),
326 & eello_turn6,wturn6*fact(5),esccor*fact(1),wsccor,
327 & edihcnstr,ehomology_constr,ebr*nss,etot
328 10 format (/'Virtual-chain energies:'//
329 & 'EVDW= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-SC)'/
330 & 'EVDW2= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-p)'/
331 & 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p)'/
332 & 'ESTR= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching)'/
333 & 'EBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (bending)'/
334 & 'ESC= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/
335 & 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/
336 & 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/
337 & 'EHBP= ',1pE16.6,' WEIGHT=',1pD16.6,
338 & ' (SS bridges & dist. cnstr.)'/
339 & 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
340 & 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
341 & 'ECORR6=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
342 & 'EELLO= ',1pE16.6,' WEIGHT=',1pD16.6,' (electrostatic-local)'/
343 & 'ETURN3=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 3rd order)'/
344 & 'ETURN4=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 4th order)'/
345 & 'ETURN6=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 6th order)'/
346 & 'ESCCOR=',1pE16.6,' WEIGHT=',1pD16.6,' (backbone-rotamer corr)'/
347 & 'EDIHC= ',1pE16.6,' (dihedral angle constraints)'/
348 & 'H_CONS=',1pE16.6,' (Homology model constraints energy)'/
349 & 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/
350 & 'ETOT= ',1pE16.6,' (total)')
354 C-----------------------------------------------------------------------
355 subroutine elj(evdw,evdw_t)
357 C This subroutine calculates the interaction energy of nonbonded side chains
358 C assuming the LJ potential of interaction.
360 implicit real*8 (a-h,o-z)
362 include 'DIMENSIONS.ZSCOPT'
363 include "DIMENSIONS.COMPAR"
364 parameter (accur=1.0d-10)
367 include 'COMMON.LOCAL'
368 include 'COMMON.CHAIN'
369 include 'COMMON.DERIV'
370 include 'COMMON.INTERACT'
371 include 'COMMON.TORSION'
372 include 'COMMON.ENEPS'
373 include 'COMMON.SBRIDGE'
374 include 'COMMON.NAMES'
375 include 'COMMON.IOUNITS'
376 include 'COMMON.CONTACTS'
380 cd print *,'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
383 eneps_temp(j,i)=0.0d0
397 C Calculate SC interaction energy.
400 cd write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
401 cd & 'iend=',iend(i,iint)
402 do j=istart(i,iint),iend(i,iint)
407 C Change 12/1/95 to calculate four-body interactions
408 rij=xj*xj+yj*yj+zj*zj
410 c write (iout,*)'i=',i,' j=',j,' itypi=',itypi,' itypj=',itypj
411 eps0ij=eps(itypi,itypj)
413 e1=fac*fac*aa(itypi,itypj)
414 e2=fac*bb(itypi,itypj)
416 ij=icant(itypi,itypj)
417 eneps_temp(1,ij)=eneps_temp(1,ij)+e1/dabs(eps0ij)
418 eneps_temp(2,ij)=eneps_temp(2,ij)+e2/eps0ij
419 cd sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
420 cd epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
421 cd write (iout,'(2(a3,i3,2x),6(1pd12.4)/2(3(1pd12.4),5x)/)')
422 cd & restyp(itypi),i,restyp(itypj),j,aa(itypi,itypj),
423 cd & bb(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,epsi,sigm,
424 cd & (c(k,i),k=1,3),(c(k,j),k=1,3)
425 if (bb(itypi,itypj).gt.0.0d0) then
432 C Calculate the components of the gradient in DC and X
434 fac=-rrij*(e1+evdwij)
439 gvdwx(k,i)=gvdwx(k,i)-gg(k)
440 gvdwx(k,j)=gvdwx(k,j)+gg(k)
444 gvdwc(l,k)=gvdwc(l,k)+gg(l)
449 C 12/1/95, revised on 5/20/97
451 C Calculate the contact function. The ith column of the array JCONT will
452 C contain the numbers of atoms that make contacts with the atom I (of numbers
453 C greater than I). The arrays FACONT and GACONT will contain the values of
454 C the contact function and its derivative.
456 C Uncomment next line, if the correlation interactions include EVDW explicitly.
457 c if (j.gt.i+1 .and. evdwij.le.0.0D0) then
458 C Uncomment next line, if the correlation interactions are contact function only
459 if (j.gt.i+1.and. eps0ij.gt.0.0D0) then
461 sigij=sigma(itypi,itypj)
462 r0ij=rs0(itypi,itypj)
464 C Check whether the SC's are not too far to make a contact.
467 call gcont(rij,rcut,1.0d0,0.2d0*rcut,fcont,fprimcont)
468 C Add a new contact, if the SC's are close enough, but not too close (r<sigma).
470 if (fcont.gt.0.0D0) then
471 C If the SC-SC distance if close to sigma, apply spline.
472 cAdam call gcont(-rij,-1.03d0*sigij,2.0d0*sigij,1.0d0,
473 cAdam & fcont1,fprimcont1)
474 cAdam fcont1=1.0d0-fcont1
475 cAdam if (fcont1.gt.0.0d0) then
476 cAdam fprimcont=fprimcont*fcont1+fcont*fprimcont1
477 cAdam fcont=fcont*fcont1
479 C Uncomment following 4 lines to have the geometric average of the epsilon0's
480 cga eps0ij=1.0d0/dsqrt(eps0ij)
482 cga gg(k)=gg(k)*eps0ij
484 cga eps0ij=-evdwij*eps0ij
485 C Uncomment for AL's type of SC correlation interactions.
487 num_conti=num_conti+1
489 facont(num_conti,i)=fcont*eps0ij
490 fprimcont=eps0ij*fprimcont/rij
492 cAdam gacont(1,num_conti,i)=-fprimcont*xj+fcont*gg(1)
493 cAdam gacont(2,num_conti,i)=-fprimcont*yj+fcont*gg(2)
494 cAdam gacont(3,num_conti,i)=-fprimcont*zj+fcont*gg(3)
495 C Uncomment following 3 lines for Skolnick's type of SC correlation.
496 gacont(1,num_conti,i)=-fprimcont*xj
497 gacont(2,num_conti,i)=-fprimcont*yj
498 gacont(3,num_conti,i)=-fprimcont*zj
499 cd write (iout,'(2i5,2f10.5)') i,j,rij,facont(num_conti,i)
500 cd write (iout,'(2i3,3f10.5)')
501 cd & i,j,(gacont(kk,num_conti,i),kk=1,3)
507 num_cont(i)=num_conti
512 gvdwc(j,i)=expon*gvdwc(j,i)
513 gvdwx(j,i)=expon*gvdwx(j,i)
517 C******************************************************************************
521 C To save time, the factor of EXPON has been extracted from ALL components
522 C of GVDWC and GRADX. Remember to multiply them by this factor before further
525 C******************************************************************************
528 C-----------------------------------------------------------------------------
529 subroutine eljk(evdw,evdw_t)
531 C This subroutine calculates the interaction energy of nonbonded side chains
532 C assuming the LJK potential of interaction.
534 implicit real*8 (a-h,o-z)
536 include 'DIMENSIONS.ZSCOPT'
537 include "DIMENSIONS.COMPAR"
540 include 'COMMON.LOCAL'
541 include 'COMMON.CHAIN'
542 include 'COMMON.DERIV'
543 include 'COMMON.INTERACT'
544 include 'COMMON.ENEPS'
545 include 'COMMON.IOUNITS'
546 include 'COMMON.NAMES'
551 c print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
554 eneps_temp(j,i)=0.0d0
566 C Calculate SC interaction energy.
569 do j=istart(i,iint),iend(i,iint)
574 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
576 e_augm=augm(itypi,itypj)*fac_augm
579 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
580 fac=r_shift_inv**expon
581 e1=fac*fac*aa(itypi,itypj)
582 e2=fac*bb(itypi,itypj)
584 ij=icant(itypi,itypj)
585 eneps_temp(1,ij)=eneps_temp(1,ij)+(e1+a_augm)
586 & /dabs(eps(itypi,itypj))
587 eneps_temp(2,ij)=eneps_temp(2,ij)+e2/eps(itypi,itypj)
588 cd sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
589 cd epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
590 cd write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
591 cd & restyp(itypi),i,restyp(itypj),j,aa(itypi,itypj),
592 cd & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
593 cd & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
594 cd & (c(k,i),k=1,3),(c(k,j),k=1,3)
595 if (bb(itypi,itypj).gt.0.0d0) then
602 C Calculate the components of the gradient in DC and X
604 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
609 gvdwx(k,i)=gvdwx(k,i)-gg(k)
610 gvdwx(k,j)=gvdwx(k,j)+gg(k)
614 gvdwc(l,k)=gvdwc(l,k)+gg(l)
624 gvdwc(j,i)=expon*gvdwc(j,i)
625 gvdwx(j,i)=expon*gvdwx(j,i)
631 C-----------------------------------------------------------------------------
632 subroutine ebp(evdw,evdw_t)
634 C This subroutine calculates the interaction energy of nonbonded side chains
635 C assuming the Berne-Pechukas potential of interaction.
637 implicit real*8 (a-h,o-z)
639 include 'DIMENSIONS.ZSCOPT'
640 include "DIMENSIONS.COMPAR"
643 include 'COMMON.LOCAL'
644 include 'COMMON.CHAIN'
645 include 'COMMON.DERIV'
646 include 'COMMON.NAMES'
647 include 'COMMON.INTERACT'
648 include 'COMMON.ENEPS'
649 include 'COMMON.IOUNITS'
650 include 'COMMON.CALC'
652 c double precision rrsave(maxdim)
658 eneps_temp(j,i)=0.0d0
663 c print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
664 c if (icall.eq.0) then
676 dxi=dc_norm(1,nres+i)
677 dyi=dc_norm(2,nres+i)
678 dzi=dc_norm(3,nres+i)
679 dsci_inv=vbld_inv(i+nres)
681 C Calculate SC interaction energy.
684 do j=istart(i,iint),iend(i,iint)
687 dscj_inv=vbld_inv(j+nres)
688 chi1=chi(itypi,itypj)
689 chi2=chi(itypj,itypi)
696 alf12=0.5D0*(alf1+alf2)
697 C For diagnostics only!!!
710 dxj=dc_norm(1,nres+j)
711 dyj=dc_norm(2,nres+j)
712 dzj=dc_norm(3,nres+j)
713 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
714 cd if (icall.eq.0) then
720 C Calculate the angle-dependent terms of energy & contributions to derivatives.
722 C Calculate whole angle-dependent part of epsilon and contributions
724 fac=(rrij*sigsq)**expon2
725 e1=fac*fac*aa(itypi,itypj)
726 e2=fac*bb(itypi,itypj)
727 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
728 eps2der=evdwij*eps3rt
729 eps3der=evdwij*eps2rt
730 evdwij=evdwij*eps2rt*eps3rt
731 ij=icant(itypi,itypj)
732 aux=eps1*eps2rt**2*eps3rt**2
733 eneps_temp(1,ij)=eneps_temp(1,ij)+e1*aux
734 & /dabs(eps(itypi,itypj))
735 eneps_temp(2,ij)=eneps_temp(2,ij)+e2*aux/eps(itypi,itypj)
736 if (bb(itypi,itypj).gt.0.0d0) then
743 sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
744 epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
745 cd write (iout,'(2(a3,i3,2x),15(0pf7.3))')
746 cd & restyp(itypi),i,restyp(itypj),j,
747 cd & epsi,sigm,chi1,chi2,chip1,chip2,
748 cd & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
749 cd & om1,om2,om12,1.0D0/dsqrt(rrij),
752 C Calculate gradient components.
753 e1=e1*eps1*eps2rt**2*eps3rt**2
754 fac=-expon*(e1+evdwij)
757 C Calculate radial part of the gradient
761 C Calculate the angular part of the gradient and sum add the contributions
762 C to the appropriate components of the Cartesian gradient.
771 C-----------------------------------------------------------------------------
772 subroutine egb(evdw,evdw_t)
774 C This subroutine calculates the interaction energy of nonbonded side chains
775 C assuming the Gay-Berne potential of interaction.
777 implicit real*8 (a-h,o-z)
779 include 'DIMENSIONS.ZSCOPT'
780 include "DIMENSIONS.COMPAR"
783 include 'COMMON.LOCAL'
784 include 'COMMON.CHAIN'
785 include 'COMMON.DERIV'
786 include 'COMMON.NAMES'
787 include 'COMMON.INTERACT'
788 include 'COMMON.ENEPS'
789 include 'COMMON.IOUNITS'
790 include 'COMMON.CALC'
791 include 'COMMON.SBRIDGE'
798 eneps_temp(j,i)=0.0d0
801 c print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
805 c if (icall.gt.0) lprn=.true.
813 dxi=dc_norm(1,nres+i)
814 dyi=dc_norm(2,nres+i)
815 dzi=dc_norm(3,nres+i)
816 dsci_inv=vbld_inv(i+nres)
818 C Calculate SC interaction energy.
821 do j=istart(i,iint),iend(i,iint)
822 C in case of diagnostics write (iout,*) "TU SZUKAJ",i,j,dyn_ss_mask(i),dyn_ss_mask(j)
823 C /06/28/2013 Adasko: In case of dyn_ss - dynamic disulfide bond
824 C formation no electrostatic interactions should be calculated. If it
825 C would be allowed NaN would appear
826 IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
827 C /06/28/2013 Adasko: dyn_ss_mask is logical statement wheather this Cys
828 C residue can or cannot form disulfide bond. There is still bug allowing
829 C Cys...Cys...Cys bond formation
830 call dyn_ssbond_ene(i,j,evdwij)
831 C /06/28/2013 Adasko: dyn_ssbond_ene is dynamic SS bond foration energy
834 c if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)')
835 c & 'evdw',i,j,evdwij,' ss'
839 dscj_inv=vbld_inv(j+nres)
840 sig0ij=sigma(itypi,itypj)
841 chi1=chi(itypi,itypj)
842 chi2=chi(itypj,itypi)
849 alf12=0.5D0*(alf1+alf2)
850 C For diagnostics only!!!
863 dxj=dc_norm(1,nres+j)
864 dyj=dc_norm(2,nres+j)
865 dzj=dc_norm(3,nres+j)
866 c write (iout,*) i,j,xj,yj,zj
867 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
869 C Calculate angle-dependent terms of energy and contributions to their
873 sig=sig0ij*dsqrt(sigsq)
874 rij_shift=1.0D0/rij-sig+sig0ij
875 C I hate to put IF's in the loops, but here don't have another choice!!!!
876 if (rij_shift.le.0.0D0) then
881 c---------------------------------------------------------------
882 rij_shift=1.0D0/rij_shift
884 e1=fac*fac*aa(itypi,itypj)
885 e2=fac*bb(itypi,itypj)
886 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
887 eps2der=evdwij*eps3rt
888 eps3der=evdwij*eps2rt
889 evdwij=evdwij*eps2rt*eps3rt
890 if (bb(itypi,itypj).gt.0) then
895 ij=icant(itypi,itypj)
896 aux=eps1*eps2rt**2*eps3rt**2
897 eneps_temp(1,ij)=eneps_temp(1,ij)+aux*e1
898 & /dabs(eps(itypi,itypj))
899 eneps_temp(2,ij)=eneps_temp(2,ij)+aux*e2/eps(itypi,itypj)
900 c write (iout,*) "i",i," j",j," itypi",itypi," itypj",itypj,
901 c & " ij",ij," eneps",aux*e1/dabs(eps(itypi,itypj)),
902 c & aux*e2/eps(itypi,itypj)
903 c write (iout,'(a6,2i5,0pf7.3)') 'evdw',i,j,evdwij
905 sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
906 epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
907 write (iout,'(2(a3,i3,2x),17(0pf7.3))')
908 & restyp(itypi),i,restyp(itypj),j,
909 & epsi,sigm,chi1,chi2,chip1,chip2,
910 & eps1,eps2rt**2,eps3rt**2,sig,sig0ij,
911 & om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,
915 C Calculate gradient components.
916 e1=e1*eps1*eps2rt**2*eps3rt**2
917 fac=-expon*(e1+evdwij)*rij_shift
920 C Calculate the radial part of the gradient
924 C Calculate angular part of the gradient.
933 C-----------------------------------------------------------------------------
934 subroutine egbv(evdw,evdw_t)
936 C This subroutine calculates the interaction energy of nonbonded side chains
937 C assuming the Gay-Berne-Vorobjev potential of interaction.
939 implicit real*8 (a-h,o-z)
941 include 'DIMENSIONS.ZSCOPT'
942 include "DIMENSIONS.COMPAR"
945 include 'COMMON.LOCAL'
946 include 'COMMON.CHAIN'
947 include 'COMMON.DERIV'
948 include 'COMMON.NAMES'
949 include 'COMMON.INTERACT'
950 include 'COMMON.ENEPS'
951 include 'COMMON.IOUNITS'
952 include 'COMMON.CALC'
959 eneps_temp(j,i)=0.0d0
964 c print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
967 c if (icall.gt.0) lprn=.true.
975 dxi=dc_norm(1,nres+i)
976 dyi=dc_norm(2,nres+i)
977 dzi=dc_norm(3,nres+i)
978 dsci_inv=vbld_inv(i+nres)
980 C Calculate SC interaction energy.
983 do j=istart(i,iint),iend(i,iint)
986 dscj_inv=vbld_inv(j+nres)
987 sig0ij=sigma(itypi,itypj)
989 chi1=chi(itypi,itypj)
990 chi2=chi(itypj,itypi)
997 alf12=0.5D0*(alf1+alf2)
998 C For diagnostics only!!!
1011 dxj=dc_norm(1,nres+j)
1012 dyj=dc_norm(2,nres+j)
1013 dzj=dc_norm(3,nres+j)
1014 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1016 C Calculate angle-dependent terms of energy and contributions to their
1020 sig=sig0ij*dsqrt(sigsq)
1021 rij_shift=1.0D0/rij-sig+r0ij
1022 C I hate to put IF's in the loops, but here don't have another choice!!!!
1023 if (rij_shift.le.0.0D0) then
1028 c---------------------------------------------------------------
1029 rij_shift=1.0D0/rij_shift
1030 fac=rij_shift**expon
1031 e1=fac*fac*aa(itypi,itypj)
1032 e2=fac*bb(itypi,itypj)
1033 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
1034 eps2der=evdwij*eps3rt
1035 eps3der=evdwij*eps2rt
1036 fac_augm=rrij**expon
1037 e_augm=augm(itypi,itypj)*fac_augm
1038 evdwij=evdwij*eps2rt*eps3rt
1039 if (bb(itypi,itypj).gt.0.0d0) then
1040 evdw=evdw+evdwij+e_augm
1042 evdw_t=evdw_t+evdwij+e_augm
1044 ij=icant(itypi,itypj)
1045 aux=eps1*eps2rt**2*eps3rt**2
1046 eneps_temp(1,ij)=eneps_temp(1,ij)+aux*(e1+e_augm)
1047 & /dabs(eps(itypi,itypj))
1048 eneps_temp(2,ij)=eneps_temp(2,ij)+aux*e2/eps(itypi,itypj)
1049 c eneps_temp(ij)=eneps_temp(ij)
1050 c & +(evdwij+e_augm)/eps(itypi,itypj)
1052 c sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1053 c epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1054 c write (iout,'(2(a3,i3,2x),17(0pf7.3))')
1055 c & restyp(itypi),i,restyp(itypj),j,
1056 c & epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),
1057 c & chi1,chi2,chip1,chip2,
1058 c & eps1,eps2rt**2,eps3rt**2,
1059 c & om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,
1063 C Calculate gradient components.
1064 e1=e1*eps1*eps2rt**2*eps3rt**2
1065 fac=-expon*(e1+evdwij)*rij_shift
1067 fac=rij*fac-2*expon*rrij*e_augm
1068 C Calculate the radial part of the gradient
1072 C Calculate angular part of the gradient.
1080 C-----------------------------------------------------------------------------
1081 subroutine sc_angular
1082 C Calculate eps1,eps2,eps3,sigma, and parts of their derivatives in om1,om2,
1083 C om12. Called by ebp, egb, and egbv.
1085 include 'COMMON.CALC'
1089 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
1090 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
1091 om12=dxi*dxj+dyi*dyj+dzi*dzj
1093 C Calculate eps1(om12) and its derivative in om12
1094 faceps1=1.0D0-om12*chiom12
1095 faceps1_inv=1.0D0/faceps1
1096 eps1=dsqrt(faceps1_inv)
1097 C Following variable is eps1*deps1/dom12
1098 eps1_om12=faceps1_inv*chiom12
1099 C Calculate sigma(om1,om2,om12) and the derivatives of sigma**2 in om1,om2,
1104 facsig=om1*chiom1+om2*chiom2-2.0D0*om1om2*chiom12
1105 sigsq=1.0D0-facsig*faceps1_inv
1106 sigsq_om1=(chiom1-chiom12*om2)*faceps1_inv
1107 sigsq_om2=(chiom2-chiom12*om1)*faceps1_inv
1108 sigsq_om12=-chi12*(om1om2*faceps1-om12*facsig)*faceps1_inv**2
1109 C Calculate eps2 and its derivatives in om1, om2, and om12.
1112 chipom12=chip12*om12
1113 facp=1.0D0-om12*chipom12
1115 facp1=om1*chipom1+om2*chipom2-2.0D0*om1om2*chipom12
1116 C Following variable is the square root of eps2
1117 eps2rt=1.0D0-facp1*facp_inv
1118 C Following three variables are the derivatives of the square root of eps
1119 C in om1, om2, and om12.
1120 eps2rt_om1=-4.0D0*(chipom1-chipom12*om2)*facp_inv
1121 eps2rt_om2=-4.0D0*(chipom2-chipom12*om1)*facp_inv
1122 eps2rt_om12=4.0D0*chip12*(om1om2*facp-om12*facp1)*facp_inv**2
1123 C Evaluate the "asymmetric" factor in the VDW constant, eps3
1124 eps3rt=1.0D0-alf1*om1+alf2*om2-alf12*om12
1125 C Calculate whole angle-dependent part of epsilon and contributions
1126 C to its derivatives
1129 C----------------------------------------------------------------------------
1131 implicit real*8 (a-h,o-z)
1132 include 'DIMENSIONS'
1133 include 'DIMENSIONS.ZSCOPT'
1134 include 'COMMON.CHAIN'
1135 include 'COMMON.DERIV'
1136 include 'COMMON.CALC'
1137 double precision dcosom1(3),dcosom2(3)
1138 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
1139 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
1140 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12
1141 & -2.0D0*alf12*eps3der+sigder*sigsq_om12
1143 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
1144 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
1147 gg(k)=gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
1150 gvdwx(k,i)=gvdwx(k,i)-gg(k)
1151 & +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))
1152 & +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
1153 gvdwx(k,j)=gvdwx(k,j)+gg(k)
1154 & +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))
1155 & +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
1158 C Calculate the components of the gradient in DC and X
1162 gvdwc(l,k)=gvdwc(l,k)+gg(l)
1167 c------------------------------------------------------------------------------
1168 subroutine vec_and_deriv
1169 implicit real*8 (a-h,o-z)
1170 include 'DIMENSIONS'
1171 include 'DIMENSIONS.ZSCOPT'
1172 include 'COMMON.IOUNITS'
1173 include 'COMMON.GEO'
1174 include 'COMMON.VAR'
1175 include 'COMMON.LOCAL'
1176 include 'COMMON.CHAIN'
1177 include 'COMMON.VECTORS'
1178 include 'COMMON.DERIV'
1179 include 'COMMON.INTERACT'
1180 dimension uyder(3,3,2),uzder(3,3,2),vbld_inv_temp(2)
1181 C Compute the local reference systems. For reference system (i), the
1182 C X-axis points from CA(i) to CA(i+1), the Y axis is in the
1183 C CA(i)-CA(i+1)-CA(i+2) plane, and the Z axis is perpendicular to this plane.
1185 c if (i.eq.nres-1 .or. itel(i+1).eq.0) then
1186 if (i.eq.nres-1) then
1187 C Case of the last full residue
1188 C Compute the Z-axis
1189 call vecpr(dc_norm(1,i),dc_norm(1,i-1),uz(1,i))
1190 costh=dcos(pi-theta(nres))
1191 fac=1.0d0/dsqrt(1.0d0-costh*costh)
1196 C Compute the derivatives of uz
1198 uzder(2,1,1)=-dc_norm(3,i-1)
1199 uzder(3,1,1)= dc_norm(2,i-1)
1200 uzder(1,2,1)= dc_norm(3,i-1)
1202 uzder(3,2,1)=-dc_norm(1,i-1)
1203 uzder(1,3,1)=-dc_norm(2,i-1)
1204 uzder(2,3,1)= dc_norm(1,i-1)
1207 uzder(2,1,2)= dc_norm(3,i)
1208 uzder(3,1,2)=-dc_norm(2,i)
1209 uzder(1,2,2)=-dc_norm(3,i)
1211 uzder(3,2,2)= dc_norm(1,i)
1212 uzder(1,3,2)= dc_norm(2,i)
1213 uzder(2,3,2)=-dc_norm(1,i)
1216 C Compute the Y-axis
1219 uy(k,i)=fac*(dc_norm(k,i-1)-costh*dc_norm(k,i))
1222 C Compute the derivatives of uy
1225 uyder(k,j,1)=2*dc_norm(k,i-1)*dc_norm(j,i)
1226 & -dc_norm(k,i)*dc_norm(j,i-1)
1227 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
1229 uyder(j,j,1)=uyder(j,j,1)-costh
1230 uyder(j,j,2)=1.0d0+uyder(j,j,2)
1235 uygrad(l,k,j,i)=uyder(l,k,j)
1236 uzgrad(l,k,j,i)=uzder(l,k,j)
1240 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
1241 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
1242 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
1243 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
1247 C Compute the Z-axis
1248 call vecpr(dc_norm(1,i),dc_norm(1,i+1),uz(1,i))
1249 costh=dcos(pi-theta(i+2))
1250 fac=1.0d0/dsqrt(1.0d0-costh*costh)
1255 C Compute the derivatives of uz
1257 uzder(2,1,1)=-dc_norm(3,i+1)
1258 uzder(3,1,1)= dc_norm(2,i+1)
1259 uzder(1,2,1)= dc_norm(3,i+1)
1261 uzder(3,2,1)=-dc_norm(1,i+1)
1262 uzder(1,3,1)=-dc_norm(2,i+1)
1263 uzder(2,3,1)= dc_norm(1,i+1)
1266 uzder(2,1,2)= dc_norm(3,i)
1267 uzder(3,1,2)=-dc_norm(2,i)
1268 uzder(1,2,2)=-dc_norm(3,i)
1270 uzder(3,2,2)= dc_norm(1,i)
1271 uzder(1,3,2)= dc_norm(2,i)
1272 uzder(2,3,2)=-dc_norm(1,i)
1275 C Compute the Y-axis
1278 uy(k,i)=facy*(dc_norm(k,i+1)-costh*dc_norm(k,i))
1281 C Compute the derivatives of uy
1284 uyder(k,j,1)=2*dc_norm(k,i+1)*dc_norm(j,i)
1285 & -dc_norm(k,i)*dc_norm(j,i+1)
1286 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
1288 uyder(j,j,1)=uyder(j,j,1)-costh
1289 uyder(j,j,2)=1.0d0+uyder(j,j,2)
1294 uygrad(l,k,j,i)=uyder(l,k,j)
1295 uzgrad(l,k,j,i)=uzder(l,k,j)
1299 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
1300 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
1301 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
1302 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
1308 vbld_inv_temp(1)=vbld_inv(i+1)
1309 if (i.lt.nres-1) then
1310 vbld_inv_temp(2)=vbld_inv(i+2)
1312 vbld_inv_temp(2)=vbld_inv(i)
1317 uygrad(l,k,j,i)=vbld_inv_temp(j)*uygrad(l,k,j,i)
1318 uzgrad(l,k,j,i)=vbld_inv_temp(j)*uzgrad(l,k,j,i)
1326 C-----------------------------------------------------------------------------
1327 subroutine vec_and_deriv_test
1328 implicit real*8 (a-h,o-z)
1329 include 'DIMENSIONS'
1330 include 'DIMENSIONS.ZSCOPT'
1331 include 'COMMON.IOUNITS'
1332 include 'COMMON.GEO'
1333 include 'COMMON.VAR'
1334 include 'COMMON.LOCAL'
1335 include 'COMMON.CHAIN'
1336 include 'COMMON.VECTORS'
1337 dimension uyder(3,3,2),uzder(3,3,2)
1338 C Compute the local reference systems. For reference system (i), the
1339 C X-axis points from CA(i) to CA(i+1), the Y axis is in the
1340 C CA(i)-CA(i+1)-CA(i+2) plane, and the Z axis is perpendicular to this plane.
1342 if (i.eq.nres-1) then
1343 C Case of the last full residue
1344 C Compute the Z-axis
1345 call vecpr(dc_norm(1,i),dc_norm(1,i-1),uz(1,i))
1346 costh=dcos(pi-theta(nres))
1347 fac=1.0d0/dsqrt(1.0d0-costh*costh)
1348 c write (iout,*) 'fac',fac,
1349 c & 1.0d0/dsqrt(scalar(uz(1,i),uz(1,i)))
1350 fac=1.0d0/dsqrt(scalar(uz(1,i),uz(1,i)))
1354 C Compute the derivatives of uz
1356 uzder(2,1,1)=-dc_norm(3,i-1)
1357 uzder(3,1,1)= dc_norm(2,i-1)
1358 uzder(1,2,1)= dc_norm(3,i-1)
1360 uzder(3,2,1)=-dc_norm(1,i-1)
1361 uzder(1,3,1)=-dc_norm(2,i-1)
1362 uzder(2,3,1)= dc_norm(1,i-1)
1365 uzder(2,1,2)= dc_norm(3,i)
1366 uzder(3,1,2)=-dc_norm(2,i)
1367 uzder(1,2,2)=-dc_norm(3,i)
1369 uzder(3,2,2)= dc_norm(1,i)
1370 uzder(1,3,2)= dc_norm(2,i)
1371 uzder(2,3,2)=-dc_norm(1,i)
1373 C Compute the Y-axis
1375 uy(k,i)=fac*(dc_norm(k,i-1)-costh*dc_norm(k,i))
1378 facy=1.0d0/dsqrt(scalar(dc_norm(1,i),dc_norm(1,i))*
1379 & (scalar(dc_norm(1,i-1),dc_norm(1,i-1))**2-
1380 & scalar(dc_norm(1,i),dc_norm(1,i-1))**2))
1382 c uy(k,i)=facy*(dc_norm(k,i+1)-costh*dc_norm(k,i))
1385 & dc_norm(k,i-1)*scalar(dc_norm(1,i),dc_norm(1,i))
1386 & -scalar(dc_norm(1,i),dc_norm(1,i-1))*dc_norm(k,i)
1389 c write (iout,*) 'facy',facy,
1390 c & 1.0d0/dsqrt(scalar(uy(1,i),uy(1,i)))
1391 facy=1.0d0/dsqrt(scalar(uy(1,i),uy(1,i)))
1393 uy(k,i)=facy*uy(k,i)
1395 C Compute the derivatives of uy
1398 uyder(k,j,1)=2*dc_norm(k,i-1)*dc_norm(j,i)
1399 & -dc_norm(k,i)*dc_norm(j,i-1)
1400 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
1402 c uyder(j,j,1)=uyder(j,j,1)-costh
1403 c uyder(j,j,2)=1.0d0+uyder(j,j,2)
1404 uyder(j,j,1)=uyder(j,j,1)
1405 & -scalar(dc_norm(1,i),dc_norm(1,i-1))
1406 uyder(j,j,2)=scalar(dc_norm(1,i),dc_norm(1,i))
1412 uygrad(l,k,j,i)=uyder(l,k,j)
1413 uzgrad(l,k,j,i)=uzder(l,k,j)
1417 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
1418 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
1419 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
1420 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
1423 C Compute the Z-axis
1424 call vecpr(dc_norm(1,i),dc_norm(1,i+1),uz(1,i))
1425 costh=dcos(pi-theta(i+2))
1426 fac=1.0d0/dsqrt(1.0d0-costh*costh)
1427 fac=1.0d0/dsqrt(scalar(uz(1,i),uz(1,i)))
1431 C Compute the derivatives of uz
1433 uzder(2,1,1)=-dc_norm(3,i+1)
1434 uzder(3,1,1)= dc_norm(2,i+1)
1435 uzder(1,2,1)= dc_norm(3,i+1)
1437 uzder(3,2,1)=-dc_norm(1,i+1)
1438 uzder(1,3,1)=-dc_norm(2,i+1)
1439 uzder(2,3,1)= dc_norm(1,i+1)
1442 uzder(2,1,2)= dc_norm(3,i)
1443 uzder(3,1,2)=-dc_norm(2,i)
1444 uzder(1,2,2)=-dc_norm(3,i)
1446 uzder(3,2,2)= dc_norm(1,i)
1447 uzder(1,3,2)= dc_norm(2,i)
1448 uzder(2,3,2)=-dc_norm(1,i)
1450 C Compute the Y-axis
1452 facy=1.0d0/dsqrt(scalar(dc_norm(1,i),dc_norm(1,i))*
1453 & (scalar(dc_norm(1,i+1),dc_norm(1,i+1))**2-
1454 & scalar(dc_norm(1,i),dc_norm(1,i+1))**2))
1456 c uy(k,i)=facy*(dc_norm(k,i+1)-costh*dc_norm(k,i))
1459 & dc_norm(k,i+1)*scalar(dc_norm(1,i),dc_norm(1,i))
1460 & -scalar(dc_norm(1,i),dc_norm(1,i+1))*dc_norm(k,i)
1463 c write (iout,*) 'facy',facy,
1464 c & 1.0d0/dsqrt(scalar(uy(1,i),uy(1,i)))
1465 facy=1.0d0/dsqrt(scalar(uy(1,i),uy(1,i)))
1467 uy(k,i)=facy*uy(k,i)
1469 C Compute the derivatives of uy
1472 uyder(k,j,1)=2*dc_norm(k,i+1)*dc_norm(j,i)
1473 & -dc_norm(k,i)*dc_norm(j,i+1)
1474 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
1476 c uyder(j,j,1)=uyder(j,j,1)-costh
1477 c uyder(j,j,2)=1.0d0+uyder(j,j,2)
1478 uyder(j,j,1)=uyder(j,j,1)
1479 & -scalar(dc_norm(1,i),dc_norm(1,i+1))
1480 uyder(j,j,2)=scalar(dc_norm(1,i),dc_norm(1,i))
1486 uygrad(l,k,j,i)=uyder(l,k,j)
1487 uzgrad(l,k,j,i)=uzder(l,k,j)
1491 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
1492 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
1493 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
1494 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
1501 uygrad(l,k,j,i)=vblinv*uygrad(l,k,j,i)
1502 uzgrad(l,k,j,i)=vblinv*uzgrad(l,k,j,i)
1509 C-----------------------------------------------------------------------------
1510 subroutine check_vecgrad
1511 implicit real*8 (a-h,o-z)
1512 include 'DIMENSIONS'
1513 include 'DIMENSIONS.ZSCOPT'
1514 include 'COMMON.IOUNITS'
1515 include 'COMMON.GEO'
1516 include 'COMMON.VAR'
1517 include 'COMMON.LOCAL'
1518 include 'COMMON.CHAIN'
1519 include 'COMMON.VECTORS'
1520 dimension uygradt(3,3,2,maxres),uzgradt(3,3,2,maxres)
1521 dimension uyt(3,maxres),uzt(3,maxres)
1522 dimension uygradn(3,3,2),uzgradn(3,3,2),erij(3)
1523 double precision delta /1.0d-7/
1526 crc write(iout,'(2i5,2(3f10.5,5x))') i,1,dc_norm(:,i)
1527 crc write(iout,'(2i5,2(3f10.5,5x))') i,2,uy(:,i)
1528 crc write(iout,'(2i5,2(3f10.5,5x)/)')i,3,uz(:,i)
1529 cd write(iout,'(2i5,2(3f10.5,5x))') i,1,
1530 cd & (dc_norm(if90,i),if90=1,3)
1531 cd write(iout,'(2i5,2(3f10.5,5x))') i,2,(uy(if90,i),if90=1,3)
1532 cd write(iout,'(2i5,2(3f10.5,5x)/)')i,3,(uz(if90,i),if90=1,3)
1533 cd write(iout,'(a)')
1539 uygradt(l,k,j,i)=uygrad(l,k,j,i)
1540 uzgradt(l,k,j,i)=uzgrad(l,k,j,i)
1553 cd write (iout,*) 'i=',i
1555 erij(k)=dc_norm(k,i)
1559 dc_norm(k,i)=erij(k)
1561 dc_norm(j,i)=dc_norm(j,i)+delta
1562 c fac=dsqrt(scalar(dc_norm(1,i),dc_norm(1,i)))
1564 c dc_norm(k,i)=dc_norm(k,i)/fac
1566 c write (iout,*) (dc_norm(k,i),k=1,3)
1567 c write (iout,*) (erij(k),k=1,3)
1570 uygradn(k,j,1)=(uy(k,i)-uyt(k,i))/delta
1571 uygradn(k,j,2)=(uy(k,i-1)-uyt(k,i-1))/delta
1572 uzgradn(k,j,1)=(uz(k,i)-uzt(k,i))/delta
1573 uzgradn(k,j,2)=(uz(k,i-1)-uzt(k,i-1))/delta
1575 c write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
1576 c & j,(uzgradt(k,j,1,i),k=1,3),(uzgradn(k,j,1),k=1,3),
1577 c & (uzgradt(k,j,2,i-1),k=1,3),(uzgradn(k,j,2),k=1,3)
1580 dc_norm(k,i)=erij(k)
1583 cd write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
1584 cd & k,(uygradt(k,l,1,i),l=1,3),(uygradn(k,l,1),l=1,3),
1585 cd & (uygradt(k,l,2,i-1),l=1,3),(uygradn(k,l,2),l=1,3)
1586 cd write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
1587 cd & k,(uzgradt(k,l,1,i),l=1,3),(uzgradn(k,l,1),l=1,3),
1588 cd & (uzgradt(k,l,2,i-1),l=1,3),(uzgradn(k,l,2),l=1,3)
1589 cd write (iout,'(a)')
1594 C--------------------------------------------------------------------------
1595 subroutine set_matrices
1596 implicit real*8 (a-h,o-z)
1597 include 'DIMENSIONS'
1598 include 'DIMENSIONS.ZSCOPT'
1599 include 'COMMON.IOUNITS'
1600 include 'COMMON.GEO'
1601 include 'COMMON.VAR'
1602 include 'COMMON.LOCAL'
1603 include 'COMMON.CHAIN'
1604 include 'COMMON.DERIV'
1605 include 'COMMON.INTERACT'
1606 include 'COMMON.CONTACTS'
1607 include 'COMMON.TORSION'
1608 include 'COMMON.VECTORS'
1609 include 'COMMON.FFIELD'
1610 double precision auxvec(2),auxmat(2,2)
1612 C Compute the virtual-bond-torsional-angle dependent quantities needed
1613 C to calculate the el-loc multibody terms of various order.
1616 if (i .lt. nres+1) then
1653 if (i .gt. 3 .and. i .lt. nres+1) then
1654 obrot_der(1,i-2)=-sin1
1655 obrot_der(2,i-2)= cos1
1656 Ugder(1,1,i-2)= sin1
1657 Ugder(1,2,i-2)=-cos1
1658 Ugder(2,1,i-2)=-cos1
1659 Ugder(2,2,i-2)=-sin1
1662 obrot2_der(1,i-2)=-dwasin2
1663 obrot2_der(2,i-2)= dwacos2
1664 Ug2der(1,1,i-2)= dwasin2
1665 Ug2der(1,2,i-2)=-dwacos2
1666 Ug2der(2,1,i-2)=-dwacos2
1667 Ug2der(2,2,i-2)=-dwasin2
1669 obrot_der(1,i-2)=0.0d0
1670 obrot_der(2,i-2)=0.0d0
1671 Ugder(1,1,i-2)=0.0d0
1672 Ugder(1,2,i-2)=0.0d0
1673 Ugder(2,1,i-2)=0.0d0
1674 Ugder(2,2,i-2)=0.0d0
1675 obrot2_der(1,i-2)=0.0d0
1676 obrot2_der(2,i-2)=0.0d0
1677 Ug2der(1,1,i-2)=0.0d0
1678 Ug2der(1,2,i-2)=0.0d0
1679 Ug2der(2,1,i-2)=0.0d0
1680 Ug2der(2,2,i-2)=0.0d0
1682 if (i.gt. iatel_s+2 .and. i.lt.iatel_e+5) then
1683 iti = itortyp(itype(i-2))
1687 if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
1688 iti1 = itortyp(itype(i-1))
1692 cd write (iout,*) '*******i',i,' iti1',iti
1693 cd write (iout,*) 'b1',b1(:,iti)
1694 cd write (iout,*) 'b2',b2(:,iti)
1695 cd write (iout,*) 'Ug',Ug(:,:,i-2)
1696 if (i .gt. iatel_s+2) then
1697 call matvec2(Ug(1,1,i-2),b2(1,iti),Ub2(1,i-2))
1698 call matmat2(EE(1,1,iti),Ug(1,1,i-2),EUg(1,1,i-2))
1699 call matmat2(CC(1,1,iti),Ug(1,1,i-2),CUg(1,1,i-2))
1700 call matmat2(DD(1,1,iti),Ug(1,1,i-2),DUg(1,1,i-2))
1701 call matmat2(Dtilde(1,1,iti),Ug2(1,1,i-2),DtUg2(1,1,i-2))
1702 call matvec2(Ctilde(1,1,iti1),obrot(1,i-2),Ctobr(1,i-2))
1703 call matvec2(Dtilde(1,1,iti),obrot2(1,i-2),Dtobr2(1,i-2))
1713 DtUg2(l,k,i-2)=0.0d0
1717 call matvec2(Ugder(1,1,i-2),b2(1,iti),Ub2der(1,i-2))
1718 call matmat2(EE(1,1,iti),Ugder(1,1,i-2),EUgder(1,1,i-2))
1719 call matmat2(CC(1,1,iti1),Ugder(1,1,i-2),CUgder(1,1,i-2))
1720 call matmat2(DD(1,1,iti),Ugder(1,1,i-2),DUgder(1,1,i-2))
1721 call matmat2(Dtilde(1,1,iti),Ug2der(1,1,i-2),DtUg2der(1,1,i-2))
1722 call matvec2(Ctilde(1,1,iti1),obrot_der(1,i-2),Ctobrder(1,i-2))
1723 call matvec2(Dtilde(1,1,iti),obrot2_der(1,i-2),Dtobr2der(1,i-2))
1725 muder(k,i-2)=Ub2der(k,i-2)
1727 if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
1728 iti1 = itortyp(itype(i-1))
1733 mu(k,i-2)=Ub2(k,i-2)+b1(k,iti1)
1735 C Vectors and matrices dependent on a single virtual-bond dihedral.
1736 call matvec2(DD(1,1,iti),b1tilde(1,iti1),auxvec(1))
1737 call matvec2(Ug2(1,1,i-2),auxvec(1),Ug2Db1t(1,i-2))
1738 call matvec2(Ug2der(1,1,i-2),auxvec(1),Ug2Db1tder(1,i-2))
1739 call matvec2(CC(1,1,iti1),Ub2(1,i-2),CUgb2(1,i-2))
1740 call matvec2(CC(1,1,iti1),Ub2der(1,i-2),CUgb2der(1,i-2))
1741 call matmat2(EUg(1,1,i-2),CC(1,1,iti1),EUgC(1,1,i-2))
1742 call matmat2(EUgder(1,1,i-2),CC(1,1,iti1),EUgCder(1,1,i-2))
1743 call matmat2(EUg(1,1,i-2),DD(1,1,iti1),EUgD(1,1,i-2))
1744 call matmat2(EUgder(1,1,i-2),DD(1,1,iti1),EUgDder(1,1,i-2))
1745 cd write (iout,*) 'i',i,' mu ',(mu(k,i-2),k=1,2),
1746 cd & ' mu1',(b1(k,i-2),k=1,2),' mu2',(Ub2(k,i-2),k=1,2)
1748 C Matrices dependent on two consecutive virtual-bond dihedrals.
1749 C The order of matrices is from left to right.
1751 call matmat2(DtUg2(1,1,i-1),EUg(1,1,i),DtUg2EUg(1,1,i))
1752 call matmat2(DtUg2der(1,1,i-1),EUg(1,1,i),DtUg2EUgder(1,1,1,i))
1753 call matmat2(DtUg2(1,1,i-1),EUgder(1,1,i),DtUg2EUgder(1,1,2,i))
1754 call transpose2(DtUg2(1,1,i-1),auxmat(1,1))
1755 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUg(1,1,i))
1756 call matmat2(auxmat(1,1),EUgder(1,1,i),Ug2DtEUgder(1,1,2,i))
1757 call transpose2(DtUg2der(1,1,i-1),auxmat(1,1))
1758 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUgder(1,1,1,i))
1761 cd iti = itortyp(itype(i))
1764 cd write (iout,'(2f10.5,5x,2f10.5,5x,2f10.5)')
1765 cd & (EE(j,k,iti),k=1,2),(Ug(j,k,i),k=1,2),(EUg(j,k,i),k=1,2)
1770 C--------------------------------------------------------------------------
1771 subroutine eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
1773 C This subroutine calculates the average interaction energy and its gradient
1774 C in the virtual-bond vectors between non-adjacent peptide groups, based on
1775 C the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
1776 C The potential depends both on the distance of peptide-group centers and on
1777 C the orientation of the CA-CA virtual bonds.
1779 implicit real*8 (a-h,o-z)
1780 include 'DIMENSIONS'
1781 include 'DIMENSIONS.ZSCOPT'
1782 include 'COMMON.CONTROL'
1783 include 'COMMON.IOUNITS'
1784 include 'COMMON.GEO'
1785 include 'COMMON.VAR'
1786 include 'COMMON.LOCAL'
1787 include 'COMMON.CHAIN'
1788 include 'COMMON.DERIV'
1789 include 'COMMON.INTERACT'
1790 include 'COMMON.CONTACTS'
1791 include 'COMMON.TORSION'
1792 include 'COMMON.VECTORS'
1793 include 'COMMON.FFIELD'
1794 dimension ggg(3),gggp(3),gggm(3),erij(3),dcosb(3),dcosg(3),
1795 & erder(3,3),uryg(3,3),urzg(3,3),vryg(3,3),vrzg(3,3)
1796 double precision acipa(2,2),agg(3,4),aggi(3,4),aggi1(3,4),
1797 & aggj(3,4),aggj1(3,4),a_temp(2,2),muij(4)
1798 common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,j1
1799 c 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
1800 double precision scal_el /0.5d0/
1802 C 13-go grudnia roku pamietnego...
1803 double precision unmat(3,3) /1.0d0,0.0d0,0.0d0,
1804 & 0.0d0,1.0d0,0.0d0,
1805 & 0.0d0,0.0d0,1.0d0/
1806 cd write(iout,*) 'In EELEC'
1808 cd write(iout,*) 'Type',i
1809 cd write(iout,*) 'B1',B1(:,i)
1810 cd write(iout,*) 'B2',B2(:,i)
1811 cd write(iout,*) 'CC',CC(:,:,i)
1812 cd write(iout,*) 'DD',DD(:,:,i)
1813 cd write(iout,*) 'EE',EE(:,:,i)
1815 cd call check_vecgrad
1817 if (icheckgrad.eq.1) then
1819 fac=1.0d0/dsqrt(scalar(dc(1,i),dc(1,i)))
1821 dc_norm(k,i)=dc(k,i)*fac
1823 c write (iout,*) 'i',i,' fac',fac
1826 if (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0
1827 & .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 .or.
1828 & wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) then
1829 cd if (wel_loc.gt.0.0d0) then
1830 if (icheckgrad.eq.1) then
1831 call vec_and_deriv_test
1838 cd write (iout,*) 'i=',i
1840 cd write (iout,'(i5,2f10.5)') k,uy(k,i),uz(k,i)
1843 cd write (iout,'(f10.5,2x,3f10.5,2x,3f10.5)')
1844 cd & uz(k,i),(uzgrad(k,l,1,i),l=1,3),(uzgrad(k,l,2,i),l=1,3)
1857 cd print '(a)','Enter EELEC'
1858 cd write (iout,*) 'iatel_s=',iatel_s,' iatel_e=',iatel_e
1860 gel_loc_loc(i)=0.0d0
1863 do i=iatel_s,iatel_e
1864 if (itel(i).eq.0) goto 1215
1868 dx_normi=dc_norm(1,i)
1869 dy_normi=dc_norm(2,i)
1870 dz_normi=dc_norm(3,i)
1871 xmedi=c(1,i)+0.5d0*dxi
1872 ymedi=c(2,i)+0.5d0*dyi
1873 zmedi=c(3,i)+0.5d0*dzi
1875 c write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
1876 do j=ielstart(i),ielend(i)
1877 if (itel(j).eq.0) goto 1216
1881 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
1882 aaa=app(iteli,itelj)
1883 bbb=bpp(iteli,itelj)
1884 C Diagnostics only!!!
1890 ael6i=ael6(iteli,itelj)
1891 ael3i=ael3(iteli,itelj)
1895 dx_normj=dc_norm(1,j)
1896 dy_normj=dc_norm(2,j)
1897 dz_normj=dc_norm(3,j)
1898 xj=c(1,j)+0.5D0*dxj-xmedi
1899 yj=c(2,j)+0.5D0*dyj-ymedi
1900 zj=c(3,j)+0.5D0*dzj-zmedi
1901 rij=xj*xj+yj*yj+zj*zj
1907 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
1908 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
1909 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
1910 fac=cosa-3.0D0*cosb*cosg
1912 c 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
1913 if (j.eq.i+2) ev1=scal_el*ev1
1918 el1=fac3*(4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg))
1921 c write (iout,*) "i",i,iteli," j",j,itelj," eesij",eesij
1922 C 12/26/95 - for the evaluation of multi-body H-bonding interactions
1923 ees0ij=4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg)
1926 cd write(iout,'(2(2i3,2x),7(1pd12.4)/2(3(1pd12.4),5x)/)')
1927 cd & iteli,i,itelj,j,aaa,bbb,ael6i,ael3i,
1928 cd & 1.0D0/dsqrt(rrmij),evdwij,eesij,
1929 cd & xmedi,ymedi,zmedi,xj,yj,zj
1931 C Calculate contributions to the Cartesian gradient.
1934 facvdw=-6*rrmij*(ev1+evdwij)
1935 facel=-3*rrmij*(el1+eesij)
1942 * Radial derivatives. First process both termini of the fragment (i,j)
1949 gelc(k,i)=gelc(k,i)+ghalf
1950 gelc(k,j)=gelc(k,j)+ghalf
1953 * Loop over residues i+1 thru j-1.
1957 gelc(l,k)=gelc(l,k)+ggg(l)
1965 gvdwpp(k,i)=gvdwpp(k,i)+ghalf
1966 gvdwpp(k,j)=gvdwpp(k,j)+ghalf
1969 * Loop over residues i+1 thru j-1.
1973 gvdwpp(l,k)=gvdwpp(l,k)+ggg(l)
1980 fac=-3*rrmij*(facvdw+facvdw+facel)
1986 * Radial derivatives. First process both termini of the fragment (i,j)
1993 gelc(k,i)=gelc(k,i)+ghalf
1994 gelc(k,j)=gelc(k,j)+ghalf
1997 * Loop over residues i+1 thru j-1.
2001 gelc(l,k)=gelc(l,k)+ggg(l)
2008 ecosa=2.0D0*fac3*fac1+fac4
2011 ecosb=(fac3*(fac1*cosg+cosb)+cosg*fac4)
2012 ecosg=(fac3*(fac1*cosb+cosg)+cosb*fac4)
2014 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
2015 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
2017 cd print '(2i3,2(3(1pd14.5),3x))',i,j,(dcosb(k),k=1,3),
2018 cd & (dcosg(k),k=1,3)
2020 ggg(k)=ecosb*dcosb(k)+ecosg*dcosg(k)
2024 gelc(k,i)=gelc(k,i)+ghalf
2025 & +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
2026 & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
2027 gelc(k,j)=gelc(k,j)+ghalf
2028 & +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
2029 & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
2033 gelc(l,k)=gelc(l,k)+ggg(l)
2038 IF (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0
2039 & .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0
2040 & .or. wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
2042 C 9/25/99 Mixed third-order local-electrostatic terms. The local-interaction
2043 C energy of a peptide unit is assumed in the form of a second-order
2044 C Fourier series in the angles lambda1 and lambda2 (see Nishikawa et al.
2045 C Macromolecules, 1974, 7, 797-806 for definition). This correlation terms
2046 C are computed for EVERY pair of non-contiguous peptide groups.
2048 if (j.lt.nres-1) then
2059 muij(kkk)=mu(k,i)*mu(l,j)
2062 cd write (iout,*) 'EELEC: i',i,' j',j
2063 cd write (iout,*) 'j',j,' j1',j1,' j2',j2
2064 cd write(iout,*) 'muij',muij
2065 ury=scalar(uy(1,i),erij)
2066 urz=scalar(uz(1,i),erij)
2067 vry=scalar(uy(1,j),erij)
2068 vrz=scalar(uz(1,j),erij)
2069 a22=scalar(uy(1,i),uy(1,j))-3*ury*vry
2070 a23=scalar(uy(1,i),uz(1,j))-3*ury*vrz
2071 a32=scalar(uz(1,i),uy(1,j))-3*urz*vry
2072 a33=scalar(uz(1,i),uz(1,j))-3*urz*vrz
2073 C For diagnostics only
2078 fac=dsqrt(-ael6i)*r3ij
2079 cd write (2,*) 'fac=',fac
2080 C For diagnostics only
2086 cd write (iout,'(4i5,4f10.5)')
2087 cd & i,itortyp(itype(i)),j,itortyp(itype(j)),a22,a23,a32,a33
2088 cd write (iout,'(6f10.5)') (muij(k),k=1,4),fac,eel_loc_ij
2089 cd write (iout,'(2(3f10.5,5x)/2(3f10.5,5x))') (uy(k,i),k=1,3),
2090 cd & (uz(k,i),k=1,3),(uy(k,j),k=1,3),(uz(k,j),k=1,3)
2091 cd write (iout,'(4f10.5)')
2092 cd & scalar(uy(1,i),uy(1,j)),scalar(uy(1,i),uz(1,j)),
2093 cd & scalar(uz(1,i),uy(1,j)),scalar(uz(1,i),uz(1,j))
2094 cd write (iout,'(4f10.5)') ury,urz,vry,vrz
2095 cd write (iout,'(2i3,9f10.5/)') i,j,
2096 cd & fac22,a22,fac23,a23,fac32,a32,fac33,a33,eel_loc_ij
2098 C Derivatives of the elements of A in virtual-bond vectors
2099 call unormderiv(erij(1),unmat(1,1),rmij,erder(1,1))
2106 uryg(k,1)=scalar(erder(1,k),uy(1,i))
2107 uryg(k,2)=scalar(uygrad(1,k,1,i),erij(1))
2108 uryg(k,3)=scalar(uygrad(1,k,2,i),erij(1))
2109 urzg(k,1)=scalar(erder(1,k),uz(1,i))
2110 urzg(k,2)=scalar(uzgrad(1,k,1,i),erij(1))
2111 urzg(k,3)=scalar(uzgrad(1,k,2,i),erij(1))
2112 vryg(k,1)=scalar(erder(1,k),uy(1,j))
2113 vryg(k,2)=scalar(uygrad(1,k,1,j),erij(1))
2114 vryg(k,3)=scalar(uygrad(1,k,2,j),erij(1))
2115 vrzg(k,1)=scalar(erder(1,k),uz(1,j))
2116 vrzg(k,2)=scalar(uzgrad(1,k,1,j),erij(1))
2117 vrzg(k,3)=scalar(uzgrad(1,k,2,j),erij(1))
2127 C Compute radial contributions to the gradient
2149 C Add the contributions coming from er
2152 agg(k,1)=agg(k,1)+fac3*(uryg(k,1)*vry+vryg(k,1)*ury)
2153 agg(k,2)=agg(k,2)+fac3*(uryg(k,1)*vrz+vrzg(k,1)*ury)
2154 agg(k,3)=agg(k,3)+fac3*(urzg(k,1)*vry+vryg(k,1)*urz)
2155 agg(k,4)=agg(k,4)+fac3*(urzg(k,1)*vrz+vrzg(k,1)*urz)
2158 C Derivatives in DC(i)
2159 ghalf1=0.5d0*agg(k,1)
2160 ghalf2=0.5d0*agg(k,2)
2161 ghalf3=0.5d0*agg(k,3)
2162 ghalf4=0.5d0*agg(k,4)
2163 aggi(k,1)=fac*(scalar(uygrad(1,k,1,i),uy(1,j))
2164 & -3.0d0*uryg(k,2)*vry)+ghalf1
2165 aggi(k,2)=fac*(scalar(uygrad(1,k,1,i),uz(1,j))
2166 & -3.0d0*uryg(k,2)*vrz)+ghalf2
2167 aggi(k,3)=fac*(scalar(uzgrad(1,k,1,i),uy(1,j))
2168 & -3.0d0*urzg(k,2)*vry)+ghalf3
2169 aggi(k,4)=fac*(scalar(uzgrad(1,k,1,i),uz(1,j))
2170 & -3.0d0*urzg(k,2)*vrz)+ghalf4
2171 C Derivatives in DC(i+1)
2172 aggi1(k,1)=fac*(scalar(uygrad(1,k,2,i),uy(1,j))
2173 & -3.0d0*uryg(k,3)*vry)+agg(k,1)
2174 aggi1(k,2)=fac*(scalar(uygrad(1,k,2,i),uz(1,j))
2175 & -3.0d0*uryg(k,3)*vrz)+agg(k,2)
2176 aggi1(k,3)=fac*(scalar(uzgrad(1,k,2,i),uy(1,j))
2177 & -3.0d0*urzg(k,3)*vry)+agg(k,3)
2178 aggi1(k,4)=fac*(scalar(uzgrad(1,k,2,i),uz(1,j))
2179 & -3.0d0*urzg(k,3)*vrz)+agg(k,4)
2180 C Derivatives in DC(j)
2181 aggj(k,1)=fac*(scalar(uygrad(1,k,1,j),uy(1,i))
2182 & -3.0d0*vryg(k,2)*ury)+ghalf1
2183 aggj(k,2)=fac*(scalar(uzgrad(1,k,1,j),uy(1,i))
2184 & -3.0d0*vrzg(k,2)*ury)+ghalf2
2185 aggj(k,3)=fac*(scalar(uygrad(1,k,1,j),uz(1,i))
2186 & -3.0d0*vryg(k,2)*urz)+ghalf3
2187 aggj(k,4)=fac*(scalar(uzgrad(1,k,1,j),uz(1,i))
2188 & -3.0d0*vrzg(k,2)*urz)+ghalf4
2189 C Derivatives in DC(j+1) or DC(nres-1)
2190 aggj1(k,1)=fac*(scalar(uygrad(1,k,2,j),uy(1,i))
2191 & -3.0d0*vryg(k,3)*ury)
2192 aggj1(k,2)=fac*(scalar(uzgrad(1,k,2,j),uy(1,i))
2193 & -3.0d0*vrzg(k,3)*ury)
2194 aggj1(k,3)=fac*(scalar(uygrad(1,k,2,j),uz(1,i))
2195 & -3.0d0*vryg(k,3)*urz)
2196 aggj1(k,4)=fac*(scalar(uzgrad(1,k,2,j),uz(1,i))
2197 & -3.0d0*vrzg(k,3)*urz)
2202 C Derivatives in DC(i+1)
2203 cd aggi1(k,1)=agg(k,1)
2204 cd aggi1(k,2)=agg(k,2)
2205 cd aggi1(k,3)=agg(k,3)
2206 cd aggi1(k,4)=agg(k,4)
2207 C Derivatives in DC(j)
2212 C Derivatives in DC(j+1)
2217 if (j.eq.nres-1 .and. i.lt.j-2) then
2219 aggj1(k,l)=aggj1(k,l)+agg(k,l)
2220 cd aggj1(k,l)=agg(k,l)
2226 C Check the loc-el terms by numerical integration
2236 aggi(k,l)=-aggi(k,l)
2237 aggi1(k,l)=-aggi1(k,l)
2238 aggj(k,l)=-aggj(k,l)
2239 aggj1(k,l)=-aggj1(k,l)
2242 if (j.lt.nres-1) then
2248 aggi(k,l)=-aggi(k,l)
2249 aggi1(k,l)=-aggi1(k,l)
2250 aggj(k,l)=-aggj(k,l)
2251 aggj1(k,l)=-aggj1(k,l)
2262 aggi(k,l)=-aggi(k,l)
2263 aggi1(k,l)=-aggi1(k,l)
2264 aggj(k,l)=-aggj(k,l)
2265 aggj1(k,l)=-aggj1(k,l)
2271 IF (wel_loc.gt.0.0d0) THEN
2272 C Contribution to the local-electrostatic energy coming from the i-j pair
2273 eel_loc_ij=a22*muij(1)+a23*muij(2)+a32*muij(3)
2275 cd write (iout,*) 'i',i,' j',j,' eel_loc_ij',eel_loc_ij
2276 cd write (iout,*) a22,muij(1),a23,muij(2),a32,muij(3)
2277 eel_loc=eel_loc+eel_loc_ij
2278 C Partial derivatives in virtual-bond dihedral angles gamma
2281 & gel_loc_loc(i-1)=gel_loc_loc(i-1)+
2282 & a22*muder(1,i)*mu(1,j)+a23*muder(1,i)*mu(2,j)
2283 & +a32*muder(2,i)*mu(1,j)+a33*muder(2,i)*mu(2,j)
2284 gel_loc_loc(j-1)=gel_loc_loc(j-1)+
2285 & a22*mu(1,i)*muder(1,j)+a23*mu(1,i)*muder(2,j)
2286 & +a32*mu(2,i)*muder(1,j)+a33*mu(2,i)*muder(2,j)
2287 cd call checkint3(i,j,mu1,mu2,a22,a23,a32,a33,acipa,eel_loc_ij)
2288 cd write(iout,*) 'agg ',agg
2289 cd write(iout,*) 'aggi ',aggi
2290 cd write(iout,*) 'aggi1',aggi1
2291 cd write(iout,*) 'aggj ',aggj
2292 cd write(iout,*) 'aggj1',aggj1
2294 C Derivatives of eello in DC(i+1) thru DC(j-1) or DC(nres-2)
2296 ggg(l)=agg(l,1)*muij(1)+
2297 & agg(l,2)*muij(2)+agg(l,3)*muij(3)+agg(l,4)*muij(4)
2301 gel_loc(l,k)=gel_loc(l,k)+ggg(l)
2304 C Remaining derivatives of eello
2306 gel_loc(l,i)=gel_loc(l,i)+aggi(l,1)*muij(1)+
2307 & aggi(l,2)*muij(2)+aggi(l,3)*muij(3)+aggi(l,4)*muij(4)
2308 gel_loc(l,i+1)=gel_loc(l,i+1)+aggi1(l,1)*muij(1)+
2309 & aggi1(l,2)*muij(2)+aggi1(l,3)*muij(3)+aggi1(l,4)*muij(4)
2310 gel_loc(l,j)=gel_loc(l,j)+aggj(l,1)*muij(1)+
2311 & aggj(l,2)*muij(2)+aggj(l,3)*muij(3)+aggj(l,4)*muij(4)
2312 gel_loc(l,j1)=gel_loc(l,j1)+aggj1(l,1)*muij(1)+
2313 & aggj1(l,2)*muij(2)+aggj1(l,3)*muij(3)+aggj1(l,4)*muij(4)
2317 if (wturn3.gt.0.0d0 .or. wturn4.gt.0.0d0) then
2318 C Contributions from turns
2323 call eturn34(i,j,eello_turn3,eello_turn4)
2325 C Change 12/26/95 to calculate four-body contributions to H-bonding energy
2326 if (j.gt.i+1 .and. num_conti.le.maxconts) then
2328 C Calculate the contact function. The ith column of the array JCONT will
2329 C contain the numbers of atoms that make contacts with the atom I (of numbers
2330 C greater than I). The arrays FACONT and GACONT will contain the values of
2331 C the contact function and its derivative.
2332 c r0ij=1.02D0*rpp(iteli,itelj)
2333 c r0ij=1.11D0*rpp(iteli,itelj)
2334 r0ij=2.20D0*rpp(iteli,itelj)
2335 c r0ij=1.55D0*rpp(iteli,itelj)
2336 call gcont(rij,r0ij,1.0D0,0.2d0*r0ij,fcont,fprimcont)
2337 if (fcont.gt.0.0D0) then
2338 num_conti=num_conti+1
2339 if (num_conti.gt.maxconts) then
2340 write (iout,*) 'WARNING - max. # of contacts exceeded;',
2341 & ' will skip next contacts for this conf.'
2343 jcont_hb(num_conti,i)=j
2344 IF (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.
2345 & wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
2346 C 9/30/99 (AL) - store components necessary to evaluate higher-order loc-el
2348 d_cont(num_conti,i)=rij
2349 cd write (2,'(3e15.5)') rij,r0ij+0.2d0*r0ij,rij
2350 C --- Electrostatic-interaction matrix ---
2351 a_chuj(1,1,num_conti,i)=a22
2352 a_chuj(1,2,num_conti,i)=a23
2353 a_chuj(2,1,num_conti,i)=a32
2354 a_chuj(2,2,num_conti,i)=a33
2355 C --- Gradient of rij
2357 grij_hb_cont(kkk,num_conti,i)=erij(kkk)
2360 c a_chuj(1,1,num_conti,i)=-0.61d0
2361 c a_chuj(1,2,num_conti,i)= 0.4d0
2362 c a_chuj(2,1,num_conti,i)= 0.65d0
2363 c a_chuj(2,2,num_conti,i)= 0.50d0
2364 c else if (i.eq.2) then
2365 c a_chuj(1,1,num_conti,i)= 0.0d0
2366 c a_chuj(1,2,num_conti,i)= 0.0d0
2367 c a_chuj(2,1,num_conti,i)= 0.0d0
2368 c a_chuj(2,2,num_conti,i)= 0.0d0
2370 C --- and its gradients
2371 cd write (iout,*) 'i',i,' j',j
2373 cd write (iout,*) 'iii 1 kkk',kkk
2374 cd write (iout,*) agg(kkk,:)
2377 cd write (iout,*) 'iii 2 kkk',kkk
2378 cd write (iout,*) aggi(kkk,:)
2381 cd write (iout,*) 'iii 3 kkk',kkk
2382 cd write (iout,*) aggi1(kkk,:)
2385 cd write (iout,*) 'iii 4 kkk',kkk
2386 cd write (iout,*) aggj(kkk,:)
2389 cd write (iout,*) 'iii 5 kkk',kkk
2390 cd write (iout,*) aggj1(kkk,:)
2397 a_chuj_der(k,l,m,1,num_conti,i)=agg(m,kkll)
2398 a_chuj_der(k,l,m,2,num_conti,i)=aggi(m,kkll)
2399 a_chuj_der(k,l,m,3,num_conti,i)=aggi1(m,kkll)
2400 a_chuj_der(k,l,m,4,num_conti,i)=aggj(m,kkll)
2401 a_chuj_der(k,l,m,5,num_conti,i)=aggj1(m,kkll)
2403 c a_chuj_der(k,l,m,mm,num_conti,i)=0.0d0
2409 IF (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) THEN
2410 C Calculate contact energies
2412 wij=cosa-3.0D0*cosb*cosg
2415 c fac3=dsqrt(-ael6i)/r0ij**3
2416 fac3=dsqrt(-ael6i)*r3ij
2417 ees0pij=dsqrt(4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1)
2418 ees0mij=dsqrt(4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2)
2420 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij)
2421 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij)
2422 C Diagnostics. Comment out or remove after debugging!
2423 c ees0p(num_conti,i)=0.5D0*fac3*ees0pij
2424 c ees0m(num_conti,i)=0.5D0*fac3*ees0mij
2425 c ees0m(num_conti,i)=0.0D0
2427 c write (iout,*) 'i=',i,' j=',j,' rij=',rij,' r0ij=',r0ij,
2428 c & ' ees0ij=',ees0p(num_conti,i),ees0m(num_conti,i),' fcont=',fcont
2429 facont_hb(num_conti,i)=fcont
2431 C Angular derivatives of the contact function
2432 ees0pij1=fac3/ees0pij
2433 ees0mij1=fac3/ees0mij
2434 fac3p=-3.0D0*fac3*rrmij
2435 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
2436 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
2438 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
2439 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
2440 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
2441 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
2442 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
2443 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
2444 ecosap=ecosa1+ecosa2
2445 ecosbp=ecosb1+ecosb2
2446 ecosgp=ecosg1+ecosg2
2447 ecosam=ecosa1-ecosa2
2448 ecosbm=ecosb1-ecosb2
2449 ecosgm=ecosg1-ecosg2
2458 fprimcont=fprimcont/rij
2459 cd facont_hb(num_conti,i)=1.0D0
2460 C Following line is for diagnostics.
2463 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
2464 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
2467 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
2468 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
2470 gggp(1)=gggp(1)+ees0pijp*xj
2471 gggp(2)=gggp(2)+ees0pijp*yj
2472 gggp(3)=gggp(3)+ees0pijp*zj
2473 gggm(1)=gggm(1)+ees0mijp*xj
2474 gggm(2)=gggm(2)+ees0mijp*yj
2475 gggm(3)=gggm(3)+ees0mijp*zj
2476 C Derivatives due to the contact function
2477 gacont_hbr(1,num_conti,i)=fprimcont*xj
2478 gacont_hbr(2,num_conti,i)=fprimcont*yj
2479 gacont_hbr(3,num_conti,i)=fprimcont*zj
2481 ghalfp=0.5D0*gggp(k)
2482 ghalfm=0.5D0*gggm(k)
2483 gacontp_hb1(k,num_conti,i)=ghalfp
2484 & +(ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i))
2485 & + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
2486 gacontp_hb2(k,num_conti,i)=ghalfp
2487 & +(ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j))
2488 & + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
2489 gacontp_hb3(k,num_conti,i)=gggp(k)
2490 gacontm_hb1(k,num_conti,i)=ghalfm
2491 & +(ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i))
2492 & + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
2493 gacontm_hb2(k,num_conti,i)=ghalfm
2494 & +(ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j))
2495 & + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
2496 gacontm_hb3(k,num_conti,i)=gggm(k)
2499 C Diagnostics. Comment out or remove after debugging!
2501 cdiag gacontp_hb1(k,num_conti,i)=0.0D0
2502 cdiag gacontp_hb2(k,num_conti,i)=0.0D0
2503 cdiag gacontp_hb3(k,num_conti,i)=0.0D0
2504 cdiag gacontm_hb1(k,num_conti,i)=0.0D0
2505 cdiag gacontm_hb2(k,num_conti,i)=0.0D0
2506 cdiag gacontm_hb3(k,num_conti,i)=0.0D0
2509 endif ! num_conti.le.maxconts
2514 num_cont_hb(i)=num_conti
2518 cd write (iout,'(i3,3f10.5,5x,3f10.5)')
2519 cd & i,(gel_loc(k,i),k=1,3),gel_loc_loc(i)
2521 c 12/7/99 Adam eello_turn3 will be considered as a separate energy term
2522 ccc eel_loc=eel_loc+eello_turn3
2525 C-----------------------------------------------------------------------------
2526 subroutine eturn34(i,j,eello_turn3,eello_turn4)
2527 C Third- and fourth-order contributions from turns
2528 implicit real*8 (a-h,o-z)
2529 include 'DIMENSIONS'
2530 include 'DIMENSIONS.ZSCOPT'
2531 include 'COMMON.IOUNITS'
2532 include 'COMMON.GEO'
2533 include 'COMMON.VAR'
2534 include 'COMMON.LOCAL'
2535 include 'COMMON.CHAIN'
2536 include 'COMMON.DERIV'
2537 include 'COMMON.INTERACT'
2538 include 'COMMON.CONTACTS'
2539 include 'COMMON.TORSION'
2540 include 'COMMON.VECTORS'
2541 include 'COMMON.FFIELD'
2543 double precision auxmat(2,2),auxmat1(2,2),auxmat2(2,2),pizda(2,2),
2544 & e1t(2,2),e2t(2,2),e3t(2,2),e1tder(2,2),e2tder(2,2),e3tder(2,2),
2545 & e1a(2,2),ae3(2,2),ae3e2(2,2),auxvec(2),auxvec1(2)
2546 double precision agg(3,4),aggi(3,4),aggi1(3,4),
2547 & aggj(3,4),aggj1(3,4),a_temp(2,2)
2548 common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,j1,j2
2550 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
2552 C Third-order contributions
2559 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
2560 cd call checkint_turn3(i,a_temp,eello_turn3_num)
2561 call matmat2(EUg(1,1,i+1),EUg(1,1,i+2),auxmat(1,1))
2562 call transpose2(auxmat(1,1),auxmat1(1,1))
2563 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
2564 eello_turn3=eello_turn3+0.5d0*(pizda(1,1)+pizda(2,2))
2565 cd write (2,*) 'i,',i,' j',j,'eello_turn3',
2566 cd & 0.5d0*(pizda(1,1)+pizda(2,2)),
2567 cd & ' eello_turn3_num',4*eello_turn3_num
2569 C Derivatives in gamma(i)
2570 call matmat2(EUgder(1,1,i+1),EUg(1,1,i+2),auxmat2(1,1))
2571 call transpose2(auxmat2(1,1),pizda(1,1))
2572 call matmat2(a_temp(1,1),pizda(1,1),pizda(1,1))
2573 gel_loc_turn3(i)=gel_loc_turn3(i)+0.5d0*(pizda(1,1)+pizda(2,2))
2574 C Derivatives in gamma(i+1)
2575 call matmat2(EUg(1,1,i+1),EUgder(1,1,i+2),auxmat2(1,1))
2576 call transpose2(auxmat2(1,1),pizda(1,1))
2577 call matmat2(a_temp(1,1),pizda(1,1),pizda(1,1))
2578 gel_loc_turn3(i+1)=gel_loc_turn3(i+1)
2579 & +0.5d0*(pizda(1,1)+pizda(2,2))
2580 C Cartesian derivatives
2582 a_temp(1,1)=aggi(l,1)
2583 a_temp(1,2)=aggi(l,2)
2584 a_temp(2,1)=aggi(l,3)
2585 a_temp(2,2)=aggi(l,4)
2586 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
2587 gcorr3_turn(l,i)=gcorr3_turn(l,i)
2588 & +0.5d0*(pizda(1,1)+pizda(2,2))
2589 a_temp(1,1)=aggi1(l,1)
2590 a_temp(1,2)=aggi1(l,2)
2591 a_temp(2,1)=aggi1(l,3)
2592 a_temp(2,2)=aggi1(l,4)
2593 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
2594 gcorr3_turn(l,i+1)=gcorr3_turn(l,i+1)
2595 & +0.5d0*(pizda(1,1)+pizda(2,2))
2596 a_temp(1,1)=aggj(l,1)
2597 a_temp(1,2)=aggj(l,2)
2598 a_temp(2,1)=aggj(l,3)
2599 a_temp(2,2)=aggj(l,4)
2600 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
2601 gcorr3_turn(l,j)=gcorr3_turn(l,j)
2602 & +0.5d0*(pizda(1,1)+pizda(2,2))
2603 a_temp(1,1)=aggj1(l,1)
2604 a_temp(1,2)=aggj1(l,2)
2605 a_temp(2,1)=aggj1(l,3)
2606 a_temp(2,2)=aggj1(l,4)
2607 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
2608 gcorr3_turn(l,j1)=gcorr3_turn(l,j1)
2609 & +0.5d0*(pizda(1,1)+pizda(2,2))
2612 else if (j.eq.i+3) then
2613 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
2615 C Fourth-order contributions
2623 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
2624 cd call checkint_turn4(i,a_temp,eello_turn4_num)
2625 iti1=itortyp(itype(i+1))
2626 iti2=itortyp(itype(i+2))
2627 iti3=itortyp(itype(i+3))
2628 call transpose2(EUg(1,1,i+1),e1t(1,1))
2629 call transpose2(Eug(1,1,i+2),e2t(1,1))
2630 call transpose2(Eug(1,1,i+3),e3t(1,1))
2631 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
2632 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
2633 s1=scalar2(b1(1,iti2),auxvec(1))
2634 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
2635 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
2636 s2=scalar2(b1(1,iti1),auxvec(1))
2637 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
2638 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
2639 s3=0.5d0*(pizda(1,1)+pizda(2,2))
2640 eello_turn4=eello_turn4-(s1+s2+s3)
2641 cd write (2,*) 'i,',i,' j',j,'eello_turn4',-(s1+s2+s3),
2642 cd & ' eello_turn4_num',8*eello_turn4_num
2643 C Derivatives in gamma(i)
2645 call transpose2(EUgder(1,1,i+1),e1tder(1,1))
2646 call matmat2(e1tder(1,1),a_temp(1,1),auxmat(1,1))
2647 call matvec2(auxmat(1,1),Ub2(1,i+3),auxvec(1))
2648 s1=scalar2(b1(1,iti2),auxvec(1))
2649 call matmat2(ae3e2(1,1),e1tder(1,1),pizda(1,1))
2650 s3=0.5d0*(pizda(1,1)+pizda(2,2))
2651 gel_loc_turn4(i)=gel_loc_turn4(i)-(s1+s3)
2652 C Derivatives in gamma(i+1)
2653 call transpose2(EUgder(1,1,i+2),e2tder(1,1))
2654 call matvec2(ae3(1,1),Ub2der(1,i+2),auxvec(1))
2655 s2=scalar2(b1(1,iti1),auxvec(1))
2656 call matmat2(ae3(1,1),e2tder(1,1),auxmat(1,1))
2657 call matmat2(auxmat(1,1),e1t(1,1),pizda(1,1))
2658 s3=0.5d0*(pizda(1,1)+pizda(2,2))
2659 gel_loc_turn4(i+1)=gel_loc_turn4(i+1)-(s2+s3)
2660 C Derivatives in gamma(i+2)
2661 call transpose2(EUgder(1,1,i+3),e3tder(1,1))
2662 call matvec2(e1a(1,1),Ub2der(1,i+3),auxvec(1))
2663 s1=scalar2(b1(1,iti2),auxvec(1))
2664 call matmat2(a_temp(1,1),e3tder(1,1),auxmat(1,1))
2665 call matvec2(auxmat(1,1),Ub2(1,i+2),auxvec(1))
2666 s2=scalar2(b1(1,iti1),auxvec(1))
2667 call matmat2(auxmat(1,1),e2t(1,1),auxmat(1,1))
2668 call matmat2(auxmat(1,1),e1t(1,1),pizda(1,1))
2669 s3=0.5d0*(pizda(1,1)+pizda(2,2))
2670 gel_loc_turn4(i+2)=gel_loc_turn4(i+2)-(s1+s2+s3)
2671 C Cartesian derivatives
2672 C Derivatives of this turn contributions in DC(i+2)
2673 if (j.lt.nres-1) then
2675 a_temp(1,1)=agg(l,1)
2676 a_temp(1,2)=agg(l,2)
2677 a_temp(2,1)=agg(l,3)
2678 a_temp(2,2)=agg(l,4)
2679 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
2680 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
2681 s1=scalar2(b1(1,iti2),auxvec(1))
2682 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
2683 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
2684 s2=scalar2(b1(1,iti1),auxvec(1))
2685 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
2686 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
2687 s3=0.5d0*(pizda(1,1)+pizda(2,2))
2689 gcorr4_turn(l,i+2)=gcorr4_turn(l,i+2)-(s1+s2+s3)
2692 C Remaining derivatives of this turn contribution
2694 a_temp(1,1)=aggi(l,1)
2695 a_temp(1,2)=aggi(l,2)
2696 a_temp(2,1)=aggi(l,3)
2697 a_temp(2,2)=aggi(l,4)
2698 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
2699 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
2700 s1=scalar2(b1(1,iti2),auxvec(1))
2701 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
2702 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
2703 s2=scalar2(b1(1,iti1),auxvec(1))
2704 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
2705 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
2706 s3=0.5d0*(pizda(1,1)+pizda(2,2))
2707 gcorr4_turn(l,i)=gcorr4_turn(l,i)-(s1+s2+s3)
2708 a_temp(1,1)=aggi1(l,1)
2709 a_temp(1,2)=aggi1(l,2)
2710 a_temp(2,1)=aggi1(l,3)
2711 a_temp(2,2)=aggi1(l,4)
2712 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
2713 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
2714 s1=scalar2(b1(1,iti2),auxvec(1))
2715 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
2716 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
2717 s2=scalar2(b1(1,iti1),auxvec(1))
2718 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
2719 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
2720 s3=0.5d0*(pizda(1,1)+pizda(2,2))
2721 gcorr4_turn(l,i+1)=gcorr4_turn(l,i+1)-(s1+s2+s3)
2722 a_temp(1,1)=aggj(l,1)
2723 a_temp(1,2)=aggj(l,2)
2724 a_temp(2,1)=aggj(l,3)
2725 a_temp(2,2)=aggj(l,4)
2726 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
2727 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
2728 s1=scalar2(b1(1,iti2),auxvec(1))
2729 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
2730 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
2731 s2=scalar2(b1(1,iti1),auxvec(1))
2732 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
2733 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
2734 s3=0.5d0*(pizda(1,1)+pizda(2,2))
2735 gcorr4_turn(l,j)=gcorr4_turn(l,j)-(s1+s2+s3)
2736 a_temp(1,1)=aggj1(l,1)
2737 a_temp(1,2)=aggj1(l,2)
2738 a_temp(2,1)=aggj1(l,3)
2739 a_temp(2,2)=aggj1(l,4)
2740 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
2741 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
2742 s1=scalar2(b1(1,iti2),auxvec(1))
2743 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
2744 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
2745 s2=scalar2(b1(1,iti1),auxvec(1))
2746 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
2747 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
2748 s3=0.5d0*(pizda(1,1)+pizda(2,2))
2749 gcorr4_turn(l,j1)=gcorr4_turn(l,j1)-(s1+s2+s3)
2755 C-----------------------------------------------------------------------------
2756 subroutine vecpr(u,v,w)
2757 implicit real*8(a-h,o-z)
2758 dimension u(3),v(3),w(3)
2759 w(1)=u(2)*v(3)-u(3)*v(2)
2760 w(2)=-u(1)*v(3)+u(3)*v(1)
2761 w(3)=u(1)*v(2)-u(2)*v(1)
2764 C-----------------------------------------------------------------------------
2765 subroutine unormderiv(u,ugrad,unorm,ungrad)
2766 C This subroutine computes the derivatives of a normalized vector u, given
2767 C the derivatives computed without normalization conditions, ugrad. Returns
2770 double precision u(3),ugrad(3,3),unorm,ungrad(3,3)
2771 double precision vec(3)
2772 double precision scalar
2774 c write (2,*) 'ugrad',ugrad
2777 vec(i)=scalar(ugrad(1,i),u(1))
2779 c write (2,*) 'vec',vec
2782 ungrad(j,i)=(ugrad(j,i)-u(j)*vec(i))*unorm
2785 c write (2,*) 'ungrad',ungrad
2788 C-----------------------------------------------------------------------------
2789 subroutine escp(evdw2,evdw2_14)
2791 C This subroutine calculates the excluded-volume interaction energy between
2792 C peptide-group centers and side chains and its gradient in virtual-bond and
2793 C side-chain vectors.
2795 implicit real*8 (a-h,o-z)
2796 include 'DIMENSIONS'
2797 include 'DIMENSIONS.ZSCOPT'
2798 include 'COMMON.GEO'
2799 include 'COMMON.VAR'
2800 include 'COMMON.LOCAL'
2801 include 'COMMON.CHAIN'
2802 include 'COMMON.DERIV'
2803 include 'COMMON.INTERACT'
2804 include 'COMMON.FFIELD'
2805 include 'COMMON.IOUNITS'
2809 cd print '(a)','Enter ESCP'
2810 c write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e,
2811 c & ' scal14',scal14
2812 do i=iatscp_s,iatscp_e
2814 c write (iout,*) "i",i," iteli",iteli," nscp_gr",nscp_gr(i),
2815 c & " iscp",(iscpstart(i,j),iscpend(i,j),j=1,nscp_gr(i))
2816 if (iteli.eq.0) goto 1225
2817 xi=0.5D0*(c(1,i)+c(1,i+1))
2818 yi=0.5D0*(c(2,i)+c(2,i+1))
2819 zi=0.5D0*(c(3,i)+c(3,i+1))
2821 do iint=1,nscp_gr(i)
2823 do j=iscpstart(i,iint),iscpend(i,iint)
2825 C Uncomment following three lines for SC-p interactions
2829 C Uncomment following three lines for Ca-p interactions
2833 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
2835 e1=fac*fac*aad(itypj,iteli)
2836 e2=fac*bad(itypj,iteli)
2837 if (iabs(j-i) .le. 2) then
2840 evdw2_14=evdw2_14+e1+e2
2843 c write (iout,*) i,j,evdwij
2847 C Calculate contributions to the gradient in the virtual-bond and SC vectors.
2849 fac=-(evdwij+e1)*rrij
2854 cd write (iout,*) 'j<i'
2855 C Uncomment following three lines for SC-p interactions
2857 c gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
2860 cd write (iout,*) 'j>i'
2863 C Uncomment following line for SC-p interactions
2864 c gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
2868 gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
2872 cd write (iout,*) 'i=',i,' j=',j,' kstart=',kstart,' kend=',kend
2873 cd write (iout,*) ggg(1),ggg(2),ggg(3)
2876 gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
2886 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
2887 gradx_scp(j,i)=expon*gradx_scp(j,i)
2890 C******************************************************************************
2894 C To save time the factor EXPON has been extracted from ALL components
2895 C of GVDWC and GRADX. Remember to multiply them by this factor before further
2898 C******************************************************************************
2901 C--------------------------------------------------------------------------
2902 subroutine edis(ehpb)
2904 C Evaluate bridge-strain energy and its gradient in virtual-bond and SC vectors.
2906 implicit real*8 (a-h,o-z)
2907 include 'DIMENSIONS'
2908 include 'COMMON.SBRIDGE'
2909 include 'COMMON.CHAIN'
2910 include 'COMMON.DERIV'
2911 include 'COMMON.VAR'
2912 include 'COMMON.INTERACT'
2913 include 'COMMON.IOUNITS'
2916 cd write(iout,*)'edis: nhpb=',nhpb,' fbr=',fbr
2917 cd write(iout,*)'link_start=',link_start,' link_end=',link_end
2918 if (link_end.eq.0) return
2919 do i=link_start,link_end
2920 C If ihpb(i) and jhpb(i) > NRES, this is a SC-SC distance, otherwise a
2921 C CA-CA distance used in regularization of structure.
2924 C iii and jjj point to the residues for which the distance is assigned.
2925 if (ii.gt.nres) then
2932 c write (iout,*) "i",i," ii",ii," iii",iii," jj",jj," jjj",jjj,
2933 c & dhpb(i),dhpb1(i),forcon(i)
2934 C 24/11/03 AL: SS bridges handled separately because of introducing a specific
2935 C distance and angle dependent SS bond potential.
2936 if (.not.dyn_ss .and. i.le.nss) then
2937 C 15/02/13 CC dynamic SSbond - additional check
2938 if (ii.gt.nres .and. itype(iii).eq.1 .and. itype(jjj).eq.1) then
2939 call ssbond_ene(iii,jjj,eij)
2942 cd write (iout,*) "eij",eij
2943 else if (ii.gt.nres .and. jj.gt.nres) then
2944 c Restraints from contact prediction
2946 if (dhpb1(i).gt.0.0d0) then
2947 ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
2948 fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
2949 c write (iout,*) "beta nmr",
2950 c & dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
2954 C Get the force constant corresponding to this distance.
2956 C Calculate the contribution to energy.
2957 ehpb=ehpb+waga*rdis*rdis
2958 c write (iout,*) "beta reg",dd,waga*rdis*rdis
2960 C Evaluate gradient.
2965 ggg(j)=fac*(c(j,jj)-c(j,ii))
2968 ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
2969 ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
2972 ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
2973 ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
2976 C Calculate the distance between the two points and its difference from the
2979 if (dhpb1(i).gt.0.0d0) then
2980 ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
2981 fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
2982 c write (iout,*) "alph nmr",
2983 c & dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
2986 C Get the force constant corresponding to this distance.
2988 C Calculate the contribution to energy.
2989 ehpb=ehpb+waga*rdis*rdis
2990 c write (iout,*) "alpha reg",dd,waga*rdis*rdis
2992 C Evaluate gradient.
2996 cd print *,'i=',i,' ii=',ii,' jj=',jj,' dhpb=',dhpb(i),' dd=',dd,
2997 cd & ' waga=',waga,' fac=',fac
2999 ggg(j)=fac*(c(j,jj)-c(j,ii))
3001 cd print '(i3,3(1pe14.5))',i,(ggg(j),j=1,3)
3002 C If this is a SC-SC distance, we need to calculate the contributions to the
3003 C Cartesian gradient in the SC vectors (ghpbx).
3006 ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
3007 ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
3011 ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
3012 ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
3019 C--------------------------------------------------------------------------
3020 subroutine ssbond_ene(i,j,eij)
3022 C Calculate the distance and angle dependent SS-bond potential energy
3023 C using a free-energy function derived based on RHF/6-31G** ab initio
3024 C calculations of diethyl disulfide.
3026 C A. Liwo and U. Kozlowska, 11/24/03
3028 implicit real*8 (a-h,o-z)
3029 include 'DIMENSIONS'
3030 include 'DIMENSIONS.ZSCOPT'
3031 include 'COMMON.SBRIDGE'
3032 include 'COMMON.CHAIN'
3033 include 'COMMON.DERIV'
3034 include 'COMMON.LOCAL'
3035 include 'COMMON.INTERACT'
3036 include 'COMMON.VAR'
3037 include 'COMMON.IOUNITS'
3038 double precision erij(3),dcosom1(3),dcosom2(3),gg(3)
3043 dxi=dc_norm(1,nres+i)
3044 dyi=dc_norm(2,nres+i)
3045 dzi=dc_norm(3,nres+i)
3046 dsci_inv=dsc_inv(itypi)
3048 dscj_inv=dsc_inv(itypj)
3052 dxj=dc_norm(1,nres+j)
3053 dyj=dc_norm(2,nres+j)
3054 dzj=dc_norm(3,nres+j)
3055 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
3060 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
3061 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
3062 om12=dxi*dxj+dyi*dyj+dzi*dzj
3064 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
3065 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
3071 deltat12=om2-om1+2.0d0
3073 eij=akcm*deltad*deltad+akth*(deltat1*deltat1+deltat2*deltat2)
3074 & +akct*deltad*deltat12+ebr
3075 c & +akct*deltad*deltat12
3076 & +v1ss*cosphi+v2ss*cosphi*cosphi+v3ss*cosphi*cosphi*cosphi
3077 write(iout,*) i,j,"rij",rij,"d0cm",d0cm," akcm",akcm," akth",akth,
3078 & " akct",akct," deltad",deltad," deltat",deltat1,deltat2,
3079 & " deltat12",deltat12," eij",eij,"ebr",ebr
3080 ed=2*akcm*deltad+akct*deltat12
3082 pom2=v1ss+2*v2ss*cosphi+3*v3ss*cosphi*cosphi
3083 eom1=-2*akth*deltat1-pom1-om2*pom2
3084 eom2= 2*akth*deltat2+pom1-om1*pom2
3087 gg(k)=ed*erij(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
3090 ghpbx(k,i)=ghpbx(k,i)-gg(k)
3091 & +(eom12*dc_norm(k,nres+j)+eom1*erij(k))*dsci_inv
3092 ghpbx(k,j)=ghpbx(k,j)+gg(k)
3093 & +(eom12*dc_norm(k,nres+i)+eom2*erij(k))*dscj_inv
3096 C Calculate the components of the gradient in DC and X
3100 ghpbc(l,k)=ghpbc(l,k)+gg(l)
3105 C--------------------------------------------------------------------------
3106 c MODELLER restraint function
3107 subroutine e_modeller(ehomology_constr)
3108 implicit real*8 (a-h,o-z)
3109 include 'DIMENSIONS'
3111 integer nnn, i, j, k, ki, irec, l
3112 integer katy, odleglosci, test7
3113 real*8 odleg, odleg2, odleg3, kat, kat2, kat3, gdih(max_template)
3114 real*8 distance(max_template),distancek(max_template),
3115 & min_odl,godl(max_template),dih_diff(max_template)
3117 include 'COMMON.SBRIDGE'
3118 include 'COMMON.CHAIN'
3119 include 'COMMON.GEO'
3120 include 'COMMON.DERIV'
3121 include 'COMMON.LOCAL'
3122 include 'COMMON.INTERACT'
3123 include 'COMMON.VAR'
3124 include 'COMMON.IOUNITS'
3125 include 'COMMON.CONTROL'
3129 distancek(i)=9999999.9
3134 c write (iout,*) "waga_dist",waga_dist
3136 c Pseudo-energy and gradient from homology restraints (MODELLER-like
3138 C AL 5/2/14 - Introduce list of restraints
3139 do ii = link_start_homo,link_end_homo
3143 do k=1,constr_homology
3144 distance(k)=odl(k,ii)-dij
3145 distancek(k)=0.5d0*waga_dist*distance(k)**2*sigma_odl(k,ii)
3148 min_odl=minval(distancek)
3150 write (iout,*) "ij dij",i,j,dij
3151 write (iout,*) "distance",(distance(k),k=1,constr_homology)
3152 write (iout,*) "distancek",(distancek(k),k=1,constr_homology)
3153 write (iout,* )"min_odl",min_odl
3156 do k=1,constr_homology
3157 c Nie wiem po co to liczycie jeszcze raz!
3158 c odleg3=-waga_dist*((distance(i,j,k)**2)/
3159 c & (2*(sigma_odl(i,j,k))**2))
3160 godl(k)=dexp(-distancek(k)+min_odl)
3161 odleg2=odleg2+godl(k)
3163 ccc write(iout,779) i,j,k, "odleg2=",odleg2, "odleg3=", odleg3,
3164 ccc & "dEXP(odleg3)=", dEXP(odleg3),"distance(i,j,k)^2=",
3165 ccc & distance(i,j,k)**2, "dist(i+1,j+1)=", dist(i+1,j+1),
3166 ccc & "sigma_odl(i,j,k)=", sigma_odl(i,j,k)
3170 write (iout,*) "godl",(godl(k),k=1,constr_homology)
3171 write (iout,*) "ii i j",ii,i,j," odleg2",odleg2
3173 odleg=odleg-dLOG(odleg2/constr_homology)+min_odl
3177 do k=1,constr_homology
3178 c godl=dexp(((-(distance(i,j,k)**2)/(2*(sigma_odl(i,j,k))**2))
3179 c & *waga_dist)+min_odl
3180 sgodl=-godl(k)*distance(k)*sigma_odl(k,ii)*waga_dist
3181 sum_sgodl=sum_sgodl+sgodl
3183 c sgodl2=sgodl2+sgodl
3184 c write(iout,*) i, j, k, distance(i,j,k), "W GRADIENCIE1"
3185 c write(iout,*) "constr_homology=",constr_homology
3186 c write(iout,*) i, j, k, "TEST K"
3189 grad_odl3=sum_sgodl/(sum_godl*dij)
3192 c write(iout,*) i, j, k, distance(i,j,k), "W GRADIENCIE2"
3193 c write(iout,*) (distance(i,j,k)**2), (2*(sigma_odl(i,j,k))**2),
3194 c & (-(distance(i,j,k)**2)/(2*(sigma_odl(i,j,k))**2))
3196 ccc write(iout,*) godl, sgodl, grad_odl3
3198 c grad_odl=grad_odl+grad_odl3
3201 ggodl=grad_odl3*(c(jik,i)-c(jik,j))
3202 ccc write(iout,*) c(jik,i+1), c(jik,j+1), (c(jik,i+1)-c(jik,j+1))
3203 ccc write(iout,746) "GRAD_ODL_1", i, j, jik, ggodl,
3204 ccc & ghpbc(jik,i+1), ghpbc(jik,j+1)
3205 ghpbc(jik,i)=ghpbc(jik,i)+ggodl
3206 ghpbc(jik,j)=ghpbc(jik,j)-ggodl
3207 ccc write(iout,746) "GRAD_ODL_2", i, j, jik, ggodl,
3208 ccc & ghpbc(jik,i+1), ghpbc(jik,j+1)
3211 ccc write(iout,778)"TEST: odleg2=", odleg2, "DLOG(odleg2)=",
3212 ccc & dLOG(odleg2),"-odleg=", -odleg
3215 c Pseudo-energy and gradient from dihedral-angle restraints from
3216 c homology templates
3217 c write (iout,*) "End of distance loop"
3220 c write (iout,*) idihconstr_start_homo,idihconstr_end_homo
3221 do i=idihconstr_start_homo,idihconstr_end_homo
3223 c betai=beta(i,i+1,i+2,i+3)
3225 do k=1,constr_homology
3226 dih_diff(k)=pinorm(dih(k,i)-betai)
3227 c if (dih_diff(i,k).gt.3.14159) dih_diff(i,k)=
3228 c & -(6.28318-dih_diff(i,k))
3229 c if (dih_diff(i,k).lt.-3.14159) dih_diff(i,k)=
3230 c & 6.28318+dih_diff(i,k)
3232 kat3=-0.5d0*waga_angle*dih_diff(k)**2*sigma_dih(k,i)
3235 c write(iout,*) "kat2=", kat2, "exp(kat3)=", exp(kat3)
3239 write (iout,*) "i",i," betai",betai," kat2",kat2
3240 write (iout,*) "gdih",(gdih(k),k=1,constr_homology)
3242 if (kat2.le.1.0d-14) cycle
3243 kat=kat-dLOG(kat2/constr_homology)
3245 ccc write(iout,778)"TEST: kat2=", kat2, "DLOG(kat2)=",
3246 ccc & dLOG(kat2), "-kat=", -kat
3248 c ----------------------------------------------------------------------
3250 c ----------------------------------------------------------------------
3254 do k=1,constr_homology
3255 sgdih=-gdih(k)*dih_diff(k)*sigma_dih(k,i)*waga_angle
3256 sum_sgdih=sum_sgdih+sgdih
3258 grad_dih3=sum_sgdih/sum_gdih
3260 c write(iout,*)i,k,gdih,sgdih,beta(i+1,i+2,i+3,i+4),grad_dih3
3261 ccc write(iout,747) "GRAD_KAT_1", i, nphi, icg, grad_dih3,
3262 ccc & gloc(nphi+i-3,icg)
3263 gloc(i,icg)=gloc(i,icg)+grad_dih3
3264 ccc write(iout,747) "GRAD_KAT_2", i, nphi, icg, grad_dih3,
3265 ccc & gloc(nphi+i-3,icg)
3270 c Total energy from homology restraints
3272 write (iout,*) "odleg",odleg," kat",kat
3274 ehomology_constr=odleg+kat
3277 748 format(a8,f12.3,a6,f12.3,a7,f12.3)
3278 747 format(a12,i4,i4,i4,f8.3,f8.3)
3279 746 format(a12,i4,i4,i4,f8.3,f8.3,f8.3)
3280 778 format(a7,1X,f10.3,1X,a4,1X,f10.3,1X,a5,1X,f10.3)
3281 779 format(i3,1X,i3,1X,i2,1X,a7,1X,f7.3,1X,a7,1X,f7.3,1X,a13,1X,
3282 & f7.3,1X,a17,1X,f9.3,1X,a10,1X,f8.3,1X,a10,1X,f8.3)
3284 c-----------------------------------------------------------------------
3285 subroutine ebond(estr)
3287 c Evaluate the energy of stretching of the CA-CA and CA-SC virtual bonds
3289 implicit real*8 (a-h,o-z)
3290 include 'DIMENSIONS'
3291 include 'DIMENSIONS.ZSCOPT'
3292 include 'COMMON.LOCAL'
3293 include 'COMMON.GEO'
3294 include 'COMMON.INTERACT'
3295 include 'COMMON.DERIV'
3296 include 'COMMON.VAR'
3297 include 'COMMON.CHAIN'
3298 include 'COMMON.IOUNITS'
3299 include 'COMMON.NAMES'
3300 include 'COMMON.FFIELD'
3301 include 'COMMON.CONTROL'
3302 double precision u(3),ud(3)
3303 logical :: lprn=.false.
3306 diff = vbld(i)-vbldp0
3307 c write (iout,*) i,vbld(i),vbldp0,diff,AKP*diff*diff
3310 gradb(j,i-1)=AKP*diff*dc(j,i-1)/vbld(i)
3315 c 09/18/07 AL: multimodal bond potential based on AM1 CA-SC PMF's included
3322 diff=vbld(i+nres)-vbldsc0(1,iti)
3324 & write (iout,*) i,iti,vbld(i+nres),vbldsc0(1,iti),diff,
3325 & AKSC(1,iti),AKSC(1,iti)*diff*diff
3326 estr=estr+0.5d0*AKSC(1,iti)*diff*diff
3328 gradbx(j,i)=AKSC(1,iti)*diff*dc(j,i+nres)/vbld(i+nres)
3332 diff=vbld(i+nres)-vbldsc0(j,iti)
3333 ud(j)=aksc(j,iti)*diff
3334 u(j)=abond0(j,iti)+0.5d0*ud(j)*diff
3348 uprod2=uprod2*u(k)*u(k)
3352 usumsqder=usumsqder+ud(j)*uprod2
3355 & write (iout,*) i,iti,vbld(i+nres),(vbldsc0(j,iti),
3356 & AKSC(j,iti),abond0(j,iti),u(j),j=1,nbi)
3357 estr=estr+uprod/usum
3359 gradbx(j,i)=usumsqder/(usum*usum)*dc(j,i+nres)/vbld(i+nres)
3367 C--------------------------------------------------------------------------
3368 subroutine ebend(etheta)
3370 C Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
3371 C angles gamma and its derivatives in consecutive thetas and gammas.
3373 implicit real*8 (a-h,o-z)
3374 include 'DIMENSIONS'
3375 include 'DIMENSIONS.ZSCOPT'
3376 include 'COMMON.LOCAL'
3377 include 'COMMON.GEO'
3378 include 'COMMON.INTERACT'
3379 include 'COMMON.DERIV'
3380 include 'COMMON.VAR'
3381 include 'COMMON.CHAIN'
3382 include 'COMMON.IOUNITS'
3383 include 'COMMON.NAMES'
3384 include 'COMMON.FFIELD'
3385 common /calcthet/ term1,term2,termm,diffak,ratak,
3386 & ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,
3387 & delthe0,sig0inv,sigtc,sigsqtc,delthec,it
3388 double precision y(2),z(2)
3390 time11=dexp(-2*time)
3393 c write (iout,*) "nres",nres
3394 c write (*,'(a,i2)') 'EBEND ICG=',icg
3395 c write (iout,*) ithet_start,ithet_end
3396 do i=ithet_start,ithet_end
3397 C Zero the energy function and its derivative at 0 or pi.
3398 call splinthet(theta(i),0.5d0*delta,ss,ssd)
3400 c if (i.gt.ithet_start .and.
3401 c & (itel(i-1).eq.0 .or. itel(i-2).eq.0)) goto 1215
3402 c if (i.gt.3 .and. (i.le.4 .or. itel(i-3).ne.0)) then
3410 c if (i.lt.nres .and. itel(i).ne.0) then
3422 call proc_proc(phii,icrc)
3423 if (icrc.eq.1) phii=150.0
3437 call proc_proc(phii1,icrc)
3438 if (icrc.eq.1) phii1=150.0
3450 C Calculate the "mean" value of theta from the part of the distribution
3451 C dependent on the adjacent virtual-bond-valence angles (gamma1 & gamma2).
3452 C In following comments this theta will be referred to as t_c.
3453 thet_pred_mean=0.0d0
3457 thet_pred_mean=thet_pred_mean+athetk*y(k)+bthetk*z(k)
3459 c write (iout,*) "thet_pred_mean",thet_pred_mean
3460 dthett=thet_pred_mean*ssd
3461 thet_pred_mean=thet_pred_mean*ss+a0thet(it)
3462 c write (iout,*) "thet_pred_mean",thet_pred_mean
3463 C Derivatives of the "mean" values in gamma1 and gamma2.
3464 dthetg1=(-athet(1,it)*y(2)+athet(2,it)*y(1))*ss
3465 dthetg2=(-bthet(1,it)*z(2)+bthet(2,it)*z(1))*ss
3466 if (theta(i).gt.pi-delta) then
3467 call theteng(pi-delta,thet_pred_mean,theta0(it),f0,fprim0,
3469 call mixder(pi-delta,thet_pred_mean,theta0(it),fprim_tc0)
3470 call theteng(pi,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
3471 call spline1(theta(i),pi-delta,delta,f0,f1,fprim0,ethetai,
3473 call spline2(theta(i),pi-delta,delta,E_tc0,E_tc1,fprim_tc0,
3475 else if (theta(i).lt.delta) then
3476 call theteng(delta,thet_pred_mean,theta0(it),f0,fprim0,E_tc0)
3477 call theteng(0.0d0,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
3478 call spline1(theta(i),delta,-delta,f0,f1,fprim0,ethetai,
3480 call mixder(delta,thet_pred_mean,theta0(it),fprim_tc0)
3481 call spline2(theta(i),delta,-delta,E_tc0,E_tc1,fprim_tc0,
3484 call theteng(theta(i),thet_pred_mean,theta0(it),ethetai,
3487 etheta=etheta+ethetai
3488 c write (iout,'(2i3,3f8.3,f10.5)') i,it,rad2deg*theta(i),
3489 c & rad2deg*phii,rad2deg*phii1,ethetai
3490 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*E_tc*dthetg1
3491 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*E_tc*dthetg2
3492 gloc(nphi+i-2,icg)=wang*(E_theta+E_tc*dthett)
3495 C Ufff.... We've done all this!!!
3498 C---------------------------------------------------------------------------
3499 subroutine theteng(thetai,thet_pred_mean,theta0i,ethetai,E_theta,
3501 implicit real*8 (a-h,o-z)
3502 include 'DIMENSIONS'
3503 include 'COMMON.LOCAL'
3504 include 'COMMON.IOUNITS'
3505 common /calcthet/ term1,term2,termm,diffak,ratak,
3506 & ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,
3507 & delthe0,sig0inv,sigtc,sigsqtc,delthec,it
3508 C Calculate the contributions to both Gaussian lobes.
3509 C 6/6/97 - Deform the Gaussians using the factor of 1/(1+time)
3510 C The "polynomial part" of the "standard deviation" of this part of
3514 sig=sig*thet_pred_mean+polthet(j,it)
3516 C Derivative of the "interior part" of the "standard deviation of the"
3517 C gamma-dependent Gaussian lobe in t_c.
3518 sigtc=3*polthet(3,it)
3520 sigtc=sigtc*thet_pred_mean+j*polthet(j,it)
3523 C Set the parameters of both Gaussian lobes of the distribution.
3524 C "Standard deviation" of the gamma-dependent Gaussian lobe (sigtc)
3525 fac=sig*sig+sigc0(it)
3528 C Following variable (sigsqtc) is -(1/2)d[sigma(t_c)**(-2))]/dt_c
3529 sigsqtc=-4.0D0*sigcsq*sigtc
3530 c print *,i,sig,sigtc,sigsqtc
3531 C Following variable (sigtc) is d[sigma(t_c)]/dt_c
3532 sigtc=-sigtc/(fac*fac)
3533 C Following variable is sigma(t_c)**(-2)
3534 sigcsq=sigcsq*sigcsq
3536 sig0inv=1.0D0/sig0i**2
3537 delthec=thetai-thet_pred_mean
3538 delthe0=thetai-theta0i
3539 term1=-0.5D0*sigcsq*delthec*delthec
3540 term2=-0.5D0*sig0inv*delthe0*delthe0
3541 C Following fuzzy logic is to avoid underflows in dexp and subsequent INFs and
3542 C NaNs in taking the logarithm. We extract the largest exponent which is added
3543 C to the energy (this being the log of the distribution) at the end of energy
3544 C term evaluation for this virtual-bond angle.
3545 if (term1.gt.term2) then
3547 term2=dexp(term2-termm)
3551 term1=dexp(term1-termm)
3554 C The ratio between the gamma-independent and gamma-dependent lobes of
3555 C the distribution is a Gaussian function of thet_pred_mean too.
3556 diffak=gthet(2,it)-thet_pred_mean
3557 ratak=diffak/gthet(3,it)**2
3558 ak=dexp(gthet(1,it)-0.5D0*diffak*ratak)
3559 C Let's differentiate it in thet_pred_mean NOW.
3561 C Now put together the distribution terms to make complete distribution.
3562 termexp=term1+ak*term2
3563 termpre=sigc+ak*sig0i
3564 C Contribution of the bending energy from this theta is just the -log of
3565 C the sum of the contributions from the two lobes and the pre-exponential
3566 C factor. Simple enough, isn't it?
3567 ethetai=(-dlog(termexp)-termm+dlog(termpre))
3568 C NOW the derivatives!!!
3569 C 6/6/97 Take into account the deformation.
3570 E_theta=(delthec*sigcsq*term1
3571 & +ak*delthe0*sig0inv*term2)/termexp
3572 E_tc=((sigtc+aktc*sig0i)/termpre
3573 & -((delthec*sigcsq+delthec*delthec*sigsqtc)*term1+
3574 & aktc*term2)/termexp)
3577 c-----------------------------------------------------------------------------
3578 subroutine mixder(thetai,thet_pred_mean,theta0i,E_tc_t)
3579 implicit real*8 (a-h,o-z)
3580 include 'DIMENSIONS'
3581 include 'COMMON.LOCAL'
3582 include 'COMMON.IOUNITS'
3583 common /calcthet/ term1,term2,termm,diffak,ratak,
3584 & ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,
3585 & delthe0,sig0inv,sigtc,sigsqtc,delthec,it
3586 delthec=thetai-thet_pred_mean
3587 delthe0=thetai-theta0i
3588 C "Thank you" to MAPLE (probably spared one day of hand-differentiation).
3589 t3 = thetai-thet_pred_mean
3593 t14 = t12+t6*sigsqtc
3595 t21 = thetai-theta0i
3601 E_tc_t = -((sigcsq+2.D0*t3*sigsqtc)*t9-t14*sigcsq*t3*t16*t9
3602 & -aktc*sig0inv*t27)/t32+(t14*t9+aktc*t26)/t40
3603 & *(-t12*t9-ak*sig0inv*t27)
3607 C--------------------------------------------------------------------------
3608 subroutine ebend(etheta)
3610 C Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
3611 C angles gamma and its derivatives in consecutive thetas and gammas.
3612 C ab initio-derived potentials from
3613 c Kozlowska et al., J. Phys.: Condens. Matter 19 (2007) 285203
3615 implicit real*8 (a-h,o-z)
3616 include 'DIMENSIONS'
3617 include 'DIMENSIONS.ZSCOPT'
3618 include 'COMMON.LOCAL'
3619 include 'COMMON.GEO'
3620 include 'COMMON.INTERACT'
3621 include 'COMMON.DERIV'
3622 include 'COMMON.VAR'
3623 include 'COMMON.CHAIN'
3624 include 'COMMON.IOUNITS'
3625 include 'COMMON.NAMES'
3626 include 'COMMON.FFIELD'
3627 include 'COMMON.CONTROL'
3628 double precision coskt(mmaxtheterm),sinkt(mmaxtheterm),
3629 & cosph1(maxsingle),sinph1(maxsingle),cosph2(maxsingle),
3630 & sinph2(maxsingle),cosph1ph2(maxdouble,maxdouble),
3631 & sinph1ph2(maxdouble,maxdouble)
3632 logical lprn /.false./, lprn1 /.false./
3634 c write (iout,*) "ithetyp",(ithetyp(i),i=1,ntyp1)
3635 do i=ithet_start,ithet_end
3639 theti2=0.5d0*theta(i)
3640 ityp2=ithetyp(itype(i-1))
3642 coskt(k)=dcos(k*theti2)
3643 sinkt(k)=dsin(k*theti2)
3648 if (phii.ne.phii) phii=150.0
3652 ityp1=ithetyp(itype(i-2))
3654 cosph1(k)=dcos(k*phii)
3655 sinph1(k)=dsin(k*phii)
3668 if (phii1.ne.phii1) phii1=150.0
3673 ityp3=ithetyp(itype(i))
3675 cosph2(k)=dcos(k*phii1)
3676 sinph2(k)=dsin(k*phii1)
3686 c write (iout,*) "i",i," ityp1",itype(i-2),ityp1,
3687 c & " ityp2",itype(i-1),ityp2," ityp3",itype(i),ityp3
3689 ethetai=aa0thet(ityp1,ityp2,ityp3)
3692 ccl=cosph1(l)*cosph2(k-l)
3693 ssl=sinph1(l)*sinph2(k-l)
3694 scl=sinph1(l)*cosph2(k-l)
3695 csl=cosph1(l)*sinph2(k-l)
3696 cosph1ph2(l,k)=ccl-ssl
3697 cosph1ph2(k,l)=ccl+ssl
3698 sinph1ph2(l,k)=scl+csl
3699 sinph1ph2(k,l)=scl-csl
3703 write (iout,*) "i",i," ityp1",ityp1," ityp2",ityp2,
3704 & " ityp3",ityp3," theti2",theti2," phii",phii," phii1",phii1
3705 write (iout,*) "coskt and sinkt"
3707 write (iout,*) k,coskt(k),sinkt(k)
3711 ethetai=ethetai+aathet(k,ityp1,ityp2,ityp3)*sinkt(k)
3712 dethetai=dethetai+0.5d0*k*aathet(k,ityp1,ityp2,ityp3)
3715 & write (iout,*) "k",k," aathet",aathet(k,ityp1,ityp2,ityp3),
3716 & " ethetai",ethetai
3719 write (iout,*) "cosph and sinph"
3721 write (iout,*) k,cosph1(k),sinph1(k),cosph2(k),sinph2(k)
3723 write (iout,*) "cosph1ph2 and sinph2ph2"
3726 write (iout,*) l,k,cosph1ph2(l,k),cosph1ph2(k,l),
3727 & sinph1ph2(l,k),sinph1ph2(k,l)
3730 write(iout,*) "ethetai",ethetai
3734 aux=bbthet(k,m,ityp1,ityp2,ityp3)*cosph1(k)
3735 & +ccthet(k,m,ityp1,ityp2,ityp3)*sinph1(k)
3736 & +ddthet(k,m,ityp1,ityp2,ityp3)*cosph2(k)
3737 & +eethet(k,m,ityp1,ityp2,ityp3)*sinph2(k)
3738 ethetai=ethetai+sinkt(m)*aux
3739 dethetai=dethetai+0.5d0*m*aux*coskt(m)
3740 dephii=dephii+k*sinkt(m)*(
3741 & ccthet(k,m,ityp1,ityp2,ityp3)*cosph1(k)-
3742 & bbthet(k,m,ityp1,ityp2,ityp3)*sinph1(k))
3743 dephii1=dephii1+k*sinkt(m)*(
3744 & eethet(k,m,ityp1,ityp2,ityp3)*cosph2(k)-
3745 & ddthet(k,m,ityp1,ityp2,ityp3)*sinph2(k))
3747 & write (iout,*) "m",m," k",k," bbthet",
3748 & bbthet(k,m,ityp1,ityp2,ityp3)," ccthet",
3749 & ccthet(k,m,ityp1,ityp2,ityp3)," ddthet",
3750 & ddthet(k,m,ityp1,ityp2,ityp3)," eethet",
3751 & eethet(k,m,ityp1,ityp2,ityp3)," ethetai",ethetai
3755 & write(iout,*) "ethetai",ethetai
3759 aux=ffthet(l,k,m,ityp1,ityp2,ityp3)*cosph1ph2(l,k)+
3760 & ffthet(k,l,m,ityp1,ityp2,ityp3)*cosph1ph2(k,l)+
3761 & ggthet(l,k,m,ityp1,ityp2,ityp3)*sinph1ph2(l,k)+
3762 & ggthet(k,l,m,ityp1,ityp2,ityp3)*sinph1ph2(k,l)
3763 ethetai=ethetai+sinkt(m)*aux
3764 dethetai=dethetai+0.5d0*m*coskt(m)*aux
3765 dephii=dephii+l*sinkt(m)*(
3766 & -ffthet(l,k,m,ityp1,ityp2,ityp3)*sinph1ph2(l,k)-
3767 & ffthet(k,l,m,ityp1,ityp2,ityp3)*sinph1ph2(k,l)+
3768 & ggthet(l,k,m,ityp1,ityp2,ityp3)*cosph1ph2(l,k)+
3769 & ggthet(k,l,m,ityp1,ityp2,ityp3)*cosph1ph2(k,l))
3770 dephii1=dephii1+(k-l)*sinkt(m)*(
3771 & -ffthet(l,k,m,ityp1,ityp2,ityp3)*sinph1ph2(l,k)+
3772 & ffthet(k,l,m,ityp1,ityp2,ityp3)*sinph1ph2(k,l)+
3773 & ggthet(l,k,m,ityp1,ityp2,ityp3)*cosph1ph2(l,k)-
3774 & ggthet(k,l,m,ityp1,ityp2,ityp3)*cosph1ph2(k,l))
3776 write (iout,*) "m",m," k",k," l",l," ffthet",
3777 & ffthet(l,k,m,ityp1,ityp2,ityp3),
3778 & ffthet(k,l,m,ityp1,ityp2,ityp3)," ggthet",
3779 & ggthet(l,k,m,ityp1,ityp2,ityp3),
3780 & ggthet(k,l,m,ityp1,ityp2,ityp3)," ethetai",ethetai
3781 write (iout,*) cosph1ph2(l,k)*sinkt(m),
3782 & cosph1ph2(k,l)*sinkt(m),
3783 & sinph1ph2(l,k)*sinkt(m),sinph1ph2(k,l)*sinkt(m)
3790 if (lprn1) write (iout,'(a4,i2,3f8.1,9h ethetai ,f10.5)')
3791 & 'ebe',i,theta(i)*rad2deg,phii*rad2deg,
3792 & phii1*rad2deg,ethetai
3794 etheta=etheta+ethetai
3796 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*dephii
3797 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*dephii1
3798 gloc(nphi+i-2,icg)=wang*dethetai
3804 c-----------------------------------------------------------------------------
3805 subroutine esc(escloc)
3806 C Calculate the local energy of a side chain and its derivatives in the
3807 C corresponding virtual-bond valence angles THETA and the spherical angles
3809 implicit real*8 (a-h,o-z)
3810 include 'DIMENSIONS'
3811 include 'DIMENSIONS.ZSCOPT'
3812 include 'COMMON.GEO'
3813 include 'COMMON.LOCAL'
3814 include 'COMMON.VAR'
3815 include 'COMMON.INTERACT'
3816 include 'COMMON.DERIV'
3817 include 'COMMON.CHAIN'
3818 include 'COMMON.IOUNITS'
3819 include 'COMMON.NAMES'
3820 include 'COMMON.FFIELD'
3821 double precision x(3),dersc(3),xemp(3),dersc0(3),dersc1(3),
3822 & ddersc0(3),ddummy(3),xtemp(3),temp(3)
3823 common /sccalc/ time11,time12,time112,theti,it,nlobit
3826 c write (iout,'(a)') 'ESC'
3827 do i=loc_start,loc_end
3829 if (it.eq.10) goto 1
3831 c print *,'i=',i,' it=',it,' nlobit=',nlobit
3832 c write (iout,*) 'i=',i,' ssa=',ssa,' ssad=',ssad
3833 theti=theta(i+1)-pipol
3837 c write (iout,*) "i",i," x",x(1),x(2),x(3)
3839 if (x(2).gt.pi-delta) then
3843 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
3845 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
3846 call spline1(x(2),pi-delta,delta,escloci0,escloci1,dersc0(2),
3848 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),
3849 & ddersc0(1),dersc(1))
3850 call spline2(x(2),pi-delta,delta,dersc0(3),dersc1(3),
3851 & ddersc0(3),dersc(3))
3853 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
3855 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
3856 call spline1(x(2),pi-delta,delta,esclocbi0,esclocbi1,
3857 & dersc0(2),esclocbi,dersc02)
3858 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),
3860 call splinthet(x(2),0.5d0*delta,ss,ssd)
3865 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
3867 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
3868 c write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
3870 escloci=ss*escloci+(1.0d0-ss)*esclocbi
3872 c write (iout,*) escloci
3873 else if (x(2).lt.delta) then
3877 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
3879 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
3880 call spline1(x(2),delta,-delta,escloci0,escloci1,dersc0(2),
3882 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),
3883 & ddersc0(1),dersc(1))
3884 call spline2(x(2),delta,-delta,dersc0(3),dersc1(3),
3885 & ddersc0(3),dersc(3))
3887 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
3889 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
3890 call spline1(x(2),delta,-delta,esclocbi0,esclocbi1,
3891 & dersc0(2),esclocbi,dersc02)
3892 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),
3897 call splinthet(x(2),0.5d0*delta,ss,ssd)
3899 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
3901 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
3902 c write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
3904 escloci=ss*escloci+(1.0d0-ss)*esclocbi
3905 c write (iout,*) escloci
3907 call enesc(x,escloci,dersc,ddummy,.false.)
3910 escloc=escloc+escloci
3911 c write (iout,*) 'i=',i,' escloci=',escloci,' dersc=',dersc
3913 gloc(nphi+i-1,icg)=gloc(nphi+i-1,icg)+
3915 gloc(ialph(i,1),icg)=wscloc*dersc(2)
3916 gloc(ialph(i,1)+nside,icg)=wscloc*dersc(3)
3921 C---------------------------------------------------------------------------
3922 subroutine enesc(x,escloci,dersc,ddersc,mixed)
3923 implicit real*8 (a-h,o-z)
3924 include 'DIMENSIONS'
3925 include 'COMMON.GEO'
3926 include 'COMMON.LOCAL'
3927 include 'COMMON.IOUNITS'
3928 common /sccalc/ time11,time12,time112,theti,it,nlobit
3929 double precision x(3),z(3),Ax(3,maxlob,-1:1),dersc(3),ddersc(3)
3930 double precision contr(maxlob,-1:1)
3932 c write (iout,*) 'it=',it,' nlobit=',nlobit
3936 if (mixed) ddersc(j)=0.0d0
3940 C Because of periodicity of the dependence of the SC energy in omega we have
3941 C to add up the contributions from x(3)-2*pi, x(3), and x(3+2*pi).
3942 C To avoid underflows, first compute & store the exponents.
3950 z(k)=x(k)-censc(k,j,it)
3955 Axk=Axk+gaussc(l,k,j,it)*z(l)
3961 expfac=expfac+Ax(k,j,iii)*z(k)
3969 C As in the case of ebend, we want to avoid underflows in exponentiation and
3970 C subsequent NaNs and INFs in energy calculation.
3971 C Find the largest exponent
3975 if (emin.gt.contr(j,iii)) emin=contr(j,iii)
3979 cd print *,'it=',it,' emin=',emin
3981 C Compute the contribution to SC energy and derivatives
3985 expfac=dexp(bsc(j,it)-0.5D0*contr(j,iii)+emin)
3986 cd print *,'j=',j,' expfac=',expfac
3987 escloc_i=escloc_i+expfac
3989 dersc(k)=dersc(k)+Ax(k,j,iii)*expfac
3993 ddersc(k)=ddersc(k)+(-Ax(2,j,iii)*Ax(k,j,iii)
3994 & +gaussc(k,2,j,it))*expfac
4001 dersc(1)=dersc(1)/cos(theti)**2
4002 ddersc(1)=ddersc(1)/cos(theti)**2
4005 escloci=-(dlog(escloc_i)-emin)
4007 dersc(j)=dersc(j)/escloc_i
4011 ddersc(j)=(ddersc(j)/escloc_i+dersc(2)*dersc(j))
4016 C------------------------------------------------------------------------------
4017 subroutine enesc_bound(x,escloci,dersc,dersc12,mixed)
4018 implicit real*8 (a-h,o-z)
4019 include 'DIMENSIONS'
4020 include 'COMMON.GEO'
4021 include 'COMMON.LOCAL'
4022 include 'COMMON.IOUNITS'
4023 common /sccalc/ time11,time12,time112,theti,it,nlobit
4024 double precision x(3),z(3),Ax(3,maxlob),dersc(3)
4025 double precision contr(maxlob)
4036 z(k)=x(k)-censc(k,j,it)
4042 Axk=Axk+gaussc(l,k,j,it)*z(l)
4048 expfac=expfac+Ax(k,j)*z(k)
4053 C As in the case of ebend, we want to avoid underflows in exponentiation and
4054 C subsequent NaNs and INFs in energy calculation.
4055 C Find the largest exponent
4058 if (emin.gt.contr(j)) emin=contr(j)
4062 C Compute the contribution to SC energy and derivatives
4066 expfac=dexp(bsc(j,it)-0.5D0*contr(j)+emin)
4067 escloc_i=escloc_i+expfac
4069 dersc(k)=dersc(k)+Ax(k,j)*expfac
4071 if (mixed) dersc12=dersc12+(-Ax(2,j)*Ax(1,j)
4072 & +gaussc(1,2,j,it))*expfac
4076 dersc(1)=dersc(1)/cos(theti)**2
4077 dersc12=dersc12/cos(theti)**2
4078 escloci=-(dlog(escloc_i)-emin)
4080 dersc(j)=dersc(j)/escloc_i
4082 if (mixed) dersc12=(dersc12/escloc_i+dersc(2)*dersc(1))
4086 c----------------------------------------------------------------------------------
4087 subroutine esc(escloc)
4088 C Calculate the local energy of a side chain and its derivatives in the
4089 C corresponding virtual-bond valence angles THETA and the spherical angles
4090 C ALPHA and OMEGA derived from AM1 all-atom calculations.
4091 C added by Urszula Kozlowska. 07/11/2007
4093 implicit real*8 (a-h,o-z)
4094 include 'DIMENSIONS'
4095 include 'DIMENSIONS.ZSCOPT'
4096 include 'COMMON.GEO'
4097 include 'COMMON.LOCAL'
4098 include 'COMMON.VAR'
4099 include 'COMMON.SCROT'
4100 include 'COMMON.INTERACT'
4101 include 'COMMON.DERIV'
4102 include 'COMMON.CHAIN'
4103 include 'COMMON.IOUNITS'
4104 include 'COMMON.NAMES'
4105 include 'COMMON.FFIELD'
4106 include 'COMMON.CONTROL'
4107 include 'COMMON.VECTORS'
4108 double precision x_prime(3),y_prime(3),z_prime(3)
4109 & , sumene,dsc_i,dp2_i,x(65),
4110 & xx,yy,zz,sumene1,sumene2,sumene3,sumene4,s1,s1_6,s2,s2_6,
4111 & de_dxx,de_dyy,de_dzz,de_dt
4112 double precision s1_t,s1_6_t,s2_t,s2_6_t
4114 & dXX_Ci1(3),dYY_Ci1(3),dZZ_Ci1(3),dXX_Ci(3),
4115 & dYY_Ci(3),dZZ_Ci(3),dXX_XYZ(3),dYY_XYZ(3),dZZ_XYZ(3),
4116 & dt_dCi(3),dt_dCi1(3)
4117 common /sccalc/ time11,time12,time112,theti,it,nlobit
4120 do i=loc_start,loc_end
4121 costtab(i+1) =dcos(theta(i+1))
4122 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
4123 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
4124 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
4125 cosfac2=0.5d0/(1.0d0+costtab(i+1))
4126 cosfac=dsqrt(cosfac2)
4127 sinfac2=0.5d0/(1.0d0-costtab(i+1))
4128 sinfac=dsqrt(sinfac2)
4130 if (it.eq.10) goto 1
4132 C Compute the axes of tghe local cartesian coordinates system; store in
4133 c x_prime, y_prime and z_prime
4140 C write(2,*) "dc_norm", dc_norm(1,i+nres),dc_norm(2,i+nres),
4141 C & dc_norm(3,i+nres)
4143 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
4144 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
4147 z_prime(j) = -uz(j,i-1)
4150 c write (2,*) "x_prime",(x_prime(j),j=1,3)
4151 c write (2,*) "y_prime",(y_prime(j),j=1,3)
4152 c write (2,*) "z_prime",(z_prime(j),j=1,3)
4153 c write (2,*) "xx",scalar(x_prime(1),x_prime(1)),
4154 c & " xy",scalar(x_prime(1),y_prime(1)),
4155 c & " xz",scalar(x_prime(1),z_prime(1)),
4156 c & " yy",scalar(y_prime(1),y_prime(1)),
4157 c & " yz",scalar(y_prime(1),z_prime(1)),
4158 c & " zz",scalar(z_prime(1),z_prime(1))
4160 C Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
4161 C to local coordinate system. Store in xx, yy, zz.
4167 xx = xx + x_prime(j)*dc_norm(j,i+nres)
4168 yy = yy + y_prime(j)*dc_norm(j,i+nres)
4169 zz = zz + z_prime(j)*dc_norm(j,i+nres)
4176 C Compute the energy of the ith side cbain
4178 c write (2,*) "xx",xx," yy",yy," zz",zz
4181 x(j) = sc_parmin(j,it)
4184 Cc diagnostics - remove later
4186 yy1 = dsin(alph(2))*dcos(omeg(2))
4187 zz1 = -dsin(alph(2))*dsin(omeg(2))
4188 write(2,'(3f8.1,3f9.3,1x,3f9.3)')
4189 & alph(2)*rad2deg,omeg(2)*rad2deg,theta(3)*rad2deg,xx,yy,zz,
4191 C," --- ", xx_w,yy_w,zz_w
4194 sumene1= x(1)+ x(2)*xx+ x(3)*yy+ x(4)*zz+ x(5)*xx**2
4195 & + x(6)*yy**2+ x(7)*zz**2+ x(8)*xx*zz+ x(9)*xx*yy
4197 sumene2= x(11) + x(12)*xx + x(13)*yy + x(14)*zz + x(15)*xx**2
4198 & + x(16)*yy**2 + x(17)*zz**2 + x(18)*xx*zz + x(19)*xx*yy
4200 sumene3= x(21) +x(22)*xx +x(23)*yy +x(24)*zz +x(25)*xx**2
4201 & +x(26)*yy**2 +x(27)*zz**2 +x(28)*xx*zz +x(29)*xx*yy
4202 & +x(30)*yy*zz +x(31)*xx**3 +x(32)*yy**3 +x(33)*zz**3
4203 & +x(34)*(xx**2)*yy +x(35)*(xx**2)*zz +x(36)*(yy**2)*xx
4204 & +x(37)*(yy**2)*zz +x(38)*(zz**2)*xx +x(39)*(zz**2)*yy
4206 sumene4= x(41) +x(42)*xx +x(43)*yy +x(44)*zz +x(45)*xx**2
4207 & +x(46)*yy**2 +x(47)*zz**2 +x(48)*xx*zz +x(49)*xx*yy
4208 & +x(50)*yy*zz +x(51)*xx**3 +x(52)*yy**3 +x(53)*zz**3
4209 & +x(54)*(xx**2)*yy +x(55)*(xx**2)*zz +x(56)*(yy**2)*xx
4210 & +x(57)*(yy**2)*zz +x(58)*(zz**2)*xx +x(59)*(zz**2)*yy
4212 dsc_i = 0.743d0+x(61)
4214 dscp1=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i
4215 & *(xx*cost2tab(i+1)+yy*sint2tab(i+1)))
4216 dscp2=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i
4217 & *(xx*cost2tab(i+1)-yy*sint2tab(i+1)))
4218 s1=(1+x(63))/(0.1d0 + dscp1)
4219 s1_6=(1+x(64))/(0.1d0 + dscp1**6)
4220 s2=(1+x(65))/(0.1d0 + dscp2)
4221 s2_6=(1+x(65))/(0.1d0 + dscp2**6)
4222 sumene = ( sumene3*sint2tab(i+1) + sumene1)*(s1+s1_6)
4223 & + (sumene4*cost2tab(i+1) +sumene2)*(s2+s2_6)
4224 c write(2,'(i2," sumene",7f9.3)') i,sumene1,sumene2,sumene3,
4226 c & dscp1,dscp2,sumene
4227 c sumene = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
4228 escloc = escloc + sumene
4229 c write (2,*) "escloc",escloc
4230 if (.not. calc_grad) goto 1
4234 C This section to check the numerical derivatives of the energy of ith side
4235 C chain in xx, yy, zz, and theta. Use the -DDEBUG compiler option or insert
4236 C #define DEBUG in the code to turn it on.
4238 write (2,*) "sumene =",sumene
4242 write (2,*) xx,yy,zz
4243 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
4244 de_dxx_num=(sumenep-sumene)/aincr
4246 write (2,*) "xx+ sumene from enesc=",sumenep
4249 write (2,*) xx,yy,zz
4250 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
4251 de_dyy_num=(sumenep-sumene)/aincr
4253 write (2,*) "yy+ sumene from enesc=",sumenep
4256 write (2,*) xx,yy,zz
4257 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
4258 de_dzz_num=(sumenep-sumene)/aincr
4260 write (2,*) "zz+ sumene from enesc=",sumenep
4261 costsave=cost2tab(i+1)
4262 sintsave=sint2tab(i+1)
4263 cost2tab(i+1)=dcos(0.5d0*(theta(i+1)+aincr))
4264 sint2tab(i+1)=dsin(0.5d0*(theta(i+1)+aincr))
4265 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
4266 de_dt_num=(sumenep-sumene)/aincr
4267 write (2,*) " t+ sumene from enesc=",sumenep
4268 cost2tab(i+1)=costsave
4269 sint2tab(i+1)=sintsave
4270 C End of diagnostics section.
4273 C Compute the gradient of esc
4275 pom_s1=(1.0d0+x(63))/(0.1d0 + dscp1)**2
4276 pom_s16=6*(1.0d0+x(64))/(0.1d0 + dscp1**6)**2
4277 pom_s2=(1.0d0+x(65))/(0.1d0 + dscp2)**2
4278 pom_s26=6*(1.0d0+x(65))/(0.1d0 + dscp2**6)**2
4279 pom_dx=dsc_i*dp2_i*cost2tab(i+1)
4280 pom_dy=dsc_i*dp2_i*sint2tab(i+1)
4281 pom_dt1=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)-yy*cost2tab(i+1))
4282 pom_dt2=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)+yy*cost2tab(i+1))
4283 pom1=(sumene3*sint2tab(i+1)+sumene1)
4284 & *(pom_s1/dscp1+pom_s16*dscp1**4)
4285 pom2=(sumene4*cost2tab(i+1)+sumene2)
4286 & *(pom_s2/dscp2+pom_s26*dscp2**4)
4287 sumene1x=x(2)+2*x(5)*xx+x(8)*zz+ x(9)*yy
4288 sumene3x=x(22)+2*x(25)*xx+x(28)*zz+x(29)*yy+3*x(31)*xx**2
4289 & +2*x(34)*xx*yy +2*x(35)*xx*zz +x(36)*(yy**2) +x(38)*(zz**2)
4291 sumene2x=x(12)+2*x(15)*xx+x(18)*zz+ x(19)*yy
4292 sumene4x=x(42)+2*x(45)*xx +x(48)*zz +x(49)*yy +3*x(51)*xx**2
4293 & +2*x(54)*xx*yy+2*x(55)*xx*zz+x(56)*(yy**2)+x(58)*(zz**2)
4295 de_dxx =(sumene1x+sumene3x*sint2tab(i+1))*(s1+s1_6)
4296 & +(sumene2x+sumene4x*cost2tab(i+1))*(s2+s2_6)
4297 & +(pom1+pom2)*pom_dx
4299 write(2,*), "de_dxx = ", de_dxx,de_dxx_num
4302 sumene1y=x(3) + 2*x(6)*yy + x(9)*xx + x(10)*zz
4303 sumene3y=x(23) +2*x(26)*yy +x(29)*xx +x(30)*zz +3*x(32)*yy**2
4304 & +x(34)*(xx**2) +2*x(36)*yy*xx +2*x(37)*yy*zz +x(39)*(zz**2)
4306 sumene2y=x(13) + 2*x(16)*yy + x(19)*xx + x(20)*zz
4307 sumene4y=x(43)+2*x(46)*yy+x(49)*xx +x(50)*zz
4308 & +3*x(52)*yy**2+x(54)*xx**2+2*x(56)*yy*xx +2*x(57)*yy*zz
4309 & +x(59)*zz**2 +x(60)*xx*zz
4310 de_dyy =(sumene1y+sumene3y*sint2tab(i+1))*(s1+s1_6)
4311 & +(sumene2y+sumene4y*cost2tab(i+1))*(s2+s2_6)
4312 & +(pom1-pom2)*pom_dy
4314 write(2,*), "de_dyy = ", de_dyy,de_dyy_num
4317 de_dzz =(x(24) +2*x(27)*zz +x(28)*xx +x(30)*yy
4318 & +3*x(33)*zz**2 +x(35)*xx**2 +x(37)*yy**2 +2*x(38)*zz*xx
4319 & +2*x(39)*zz*yy +x(40)*xx*yy)*sint2tab(i+1)*(s1+s1_6)
4320 & +(x(4) + 2*x(7)*zz+ x(8)*xx + x(10)*yy)*(s1+s1_6)
4321 & +(x(44)+2*x(47)*zz +x(48)*xx +x(50)*yy +3*x(53)*zz**2
4322 & +x(55)*xx**2 +x(57)*(yy**2)+2*x(58)*zz*xx +2*x(59)*zz*yy
4323 & +x(60)*xx*yy)*cost2tab(i+1)*(s2+s2_6)
4324 & + ( x(14) + 2*x(17)*zz+ x(18)*xx + x(20)*yy)*(s2+s2_6)
4326 write(2,*), "de_dzz = ", de_dzz,de_dzz_num
4329 de_dt = 0.5d0*sumene3*cost2tab(i+1)*(s1+s1_6)
4330 & -0.5d0*sumene4*sint2tab(i+1)*(s2+s2_6)
4331 & +pom1*pom_dt1+pom2*pom_dt2
4333 write(2,*), "de_dt = ", de_dt,de_dt_num
4337 cossc=scalar(dc_norm(1,i),dc_norm(1,i+nres))
4338 cossc1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
4339 cosfac2xx=cosfac2*xx
4340 sinfac2yy=sinfac2*yy
4342 dt_dCi(k) = -(dc_norm(k,i-1)+costtab(i+1)*dc_norm(k,i))*
4344 dt_dCi1(k)= -(dc_norm(k,i)+costtab(i+1)*dc_norm(k,i-1))*
4346 pom=(dC_norm(k,i+nres)-cossc*dC_norm(k,i))*vbld_inv(i+1)
4347 pom1=(dC_norm(k,i+nres)-cossc1*dC_norm(k,i-1))*vbld_inv(i)
4348 c write (iout,*) "i",i," k",k," pom",pom," pom1",pom1,
4349 c & " dt_dCi",dt_dCi(k)," dt_dCi1",dt_dCi1(k)
4350 c write (iout,*) "dC_norm",(dC_norm(j,i),j=1,3),
4351 c & (dC_norm(j,i-1),j=1,3)," vbld_inv",vbld_inv(i+1),vbld_inv(i)
4352 dXX_Ci(k)=pom*cosfac-dt_dCi(k)*cosfac2xx
4353 dXX_Ci1(k)=-pom1*cosfac-dt_dCi1(k)*cosfac2xx
4354 dYY_Ci(k)=pom*sinfac+dt_dCi(k)*sinfac2yy
4355 dYY_Ci1(k)=pom1*sinfac+dt_dCi1(k)*sinfac2yy
4359 dZZ_Ci(k)=dZZ_Ci(k)-uzgrad(j,k,2,i-1)*dC_norm(j,i+nres)
4360 dZZ_Ci1(k)=dZZ_Ci1(k)-uzgrad(j,k,1,i-1)*dC_norm(j,i+nres)
4363 dXX_XYZ(k)=vbld_inv(i+nres)*(x_prime(k)-xx*dC_norm(k,i+nres))
4364 dYY_XYZ(k)=vbld_inv(i+nres)*(y_prime(k)-yy*dC_norm(k,i+nres))
4365 dZZ_XYZ(k)=vbld_inv(i+nres)*(z_prime(k)-zz*dC_norm(k,i+nres))
4367 dt_dCi(k) = -dt_dCi(k)/sinttab(i+1)
4368 dt_dCi1(k)= -dt_dCi1(k)/sinttab(i+1)
4372 dXX_Ctab(k,i)=dXX_Ci(k)
4373 dXX_C1tab(k,i)=dXX_Ci1(k)
4374 dYY_Ctab(k,i)=dYY_Ci(k)
4375 dYY_C1tab(k,i)=dYY_Ci1(k)
4376 dZZ_Ctab(k,i)=dZZ_Ci(k)
4377 dZZ_C1tab(k,i)=dZZ_Ci1(k)
4378 dXX_XYZtab(k,i)=dXX_XYZ(k)
4379 dYY_XYZtab(k,i)=dYY_XYZ(k)
4380 dZZ_XYZtab(k,i)=dZZ_XYZ(k)
4384 c write (iout,*) "k",k," dxx_ci1",dxx_ci1(k)," dyy_ci1",
4385 c & dyy_ci1(k)," dzz_ci1",dzz_ci1(k)
4386 c write (iout,*) "k",k," dxx_ci",dxx_ci(k)," dyy_ci",
4387 c & dyy_ci(k)," dzz_ci",dzz_ci(k)
4388 c write (iout,*) "k",k," dt_dci",dt_dci(k)," dt_dci",
4390 c write (iout,*) "k",k," dxx_XYZ",dxx_XYZ(k)," dyy_XYZ",
4391 c & dyy_XYZ(k)," dzz_XYZ",dzz_XYZ(k)
4392 gscloc(k,i-1)=gscloc(k,i-1)+de_dxx*dxx_ci1(k)
4393 & +de_dyy*dyy_ci1(k)+de_dzz*dzz_ci1(k)+de_dt*dt_dCi1(k)
4394 gscloc(k,i)=gscloc(k,i)+de_dxx*dxx_Ci(k)
4395 & +de_dyy*dyy_Ci(k)+de_dzz*dzz_Ci(k)+de_dt*dt_dCi(k)
4396 gsclocx(k,i)= de_dxx*dxx_XYZ(k)
4397 & +de_dyy*dyy_XYZ(k)+de_dzz*dzz_XYZ(k)
4399 c write(iout,*) "ENERGY GRAD = ", (gscloc(k,i-1),k=1,3),
4400 c & (gscloc(k,i),k=1,3),(gsclocx(k,i),k=1,3)
4402 C to check gradient call subroutine check_grad
4409 c------------------------------------------------------------------------------
4410 subroutine gcont(rij,r0ij,eps0ij,delta,fcont,fprimcont)
4412 C This procedure calculates two-body contact function g(rij) and its derivative:
4415 C g(rij) = esp0ij*(-0.9375*x+0.625*x**3-0.1875*x**5) ! -1 =< x =< 1
4418 C where x=(rij-r0ij)/delta
4420 C rij - interbody distance, r0ij - contact distance, eps0ij - contact energy
4423 double precision rij,r0ij,eps0ij,fcont,fprimcont
4424 double precision x,x2,x4,delta
4428 if (x.lt.-1.0D0) then
4431 else if (x.le.1.0D0) then
4434 fcont=eps0ij*(x*(-0.9375D0+0.6250D0*x2-0.1875D0*x4)+0.5D0)
4435 fprimcont=eps0ij * (-0.9375D0+1.8750D0*x2-0.9375D0*x4)/delta
4442 c------------------------------------------------------------------------------
4443 subroutine splinthet(theti,delta,ss,ssder)
4444 implicit real*8 (a-h,o-z)
4445 include 'DIMENSIONS'
4446 include 'DIMENSIONS.ZSCOPT'
4447 include 'COMMON.VAR'
4448 include 'COMMON.GEO'
4451 if (theti.gt.pipol) then
4452 call gcont(theti,thetup,1.0d0,delta,ss,ssder)
4454 call gcont(-theti,-thetlow,1.0d0,delta,ss,ssder)
4459 c------------------------------------------------------------------------------
4460 subroutine spline1(x,x0,delta,f0,f1,fprim0,f,fprim)
4462 double precision x,x0,delta,f0,f1,fprim0,f,fprim
4463 double precision ksi,ksi2,ksi3,a1,a2,a3
4464 a1=fprim0*delta/(f1-f0)
4470 f=f0+(f1-f0)*ksi*(a1+ksi*(a2+a3*ksi))
4471 fprim=(f1-f0)/delta*(a1+ksi*(2*a2+3*ksi*a3))
4474 c------------------------------------------------------------------------------
4475 subroutine spline2(x,x0,delta,f0x,f1x,fprim0x,fx)
4477 double precision x,x0,delta,f0x,f1x,fprim0x,fx
4478 double precision ksi,ksi2,ksi3,a1,a2,a3
4483 a2=3*(f1x-f0x)-2*fprim0x*delta
4484 a3=fprim0x*delta-2*(f1x-f0x)
4485 fx=f0x+a1*ksi+a2*ksi2+a3*ksi3
4488 C-----------------------------------------------------------------------------
4490 C-----------------------------------------------------------------------------
4491 subroutine etor(etors,edihcnstr,fact)
4492 implicit real*8 (a-h,o-z)
4493 include 'DIMENSIONS'
4494 include 'DIMENSIONS.ZSCOPT'
4495 include 'COMMON.VAR'
4496 include 'COMMON.GEO'
4497 include 'COMMON.LOCAL'
4498 include 'COMMON.TORSION'
4499 include 'COMMON.INTERACT'
4500 include 'COMMON.DERIV'
4501 include 'COMMON.CHAIN'
4502 include 'COMMON.NAMES'
4503 include 'COMMON.IOUNITS'
4504 include 'COMMON.FFIELD'
4505 include 'COMMON.TORCNSTR'
4507 C Set lprn=.true. for debugging
4511 do i=iphi_start,iphi_end
4512 itori=itortyp(itype(i-2))
4513 itori1=itortyp(itype(i-1))
4516 C Proline-Proline pair is a special case...
4517 if (itori.eq.3 .and. itori1.eq.3) then
4518 if (phii.gt.-dwapi3) then
4520 fac=1.0D0/(1.0D0-cosphi)
4521 etorsi=v1(1,3,3)*fac
4522 etorsi=etorsi+etorsi
4523 etors=etors+etorsi-v1(1,3,3)
4524 gloci=gloci-3*fac*etorsi*dsin(3*phii)
4527 v1ij=v1(j+1,itori,itori1)
4528 v2ij=v2(j+1,itori,itori1)
4531 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
4532 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
4536 v1ij=v1(j,itori,itori1)
4537 v2ij=v2(j,itori,itori1)
4540 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
4541 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
4545 & write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)')
4546 & restyp(itype(i-2)),i-2,restyp(itype(i-1)),i-1,itori,itori1,
4547 & (v1(j,itori,itori1),j=1,6),(v2(j,itori,itori1),j=1,6)
4548 gloc(i-3,icg)=gloc(i-3,icg)+wtor*fact*gloci
4549 c write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
4551 ! 6/20/98 - dihedral angle constraints
4554 itori=idih_constr(i)
4557 if (difi.gt.drange(i)) then
4559 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
4560 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
4561 else if (difi.lt.-drange(i)) then
4563 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
4564 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
4566 ! write (iout,'(2i5,2f8.3,2e14.5)') i,itori,rad2deg*phii,
4567 ! & rad2deg*difi,0.25d0*ftors*difi**4,gloc(itori-3,icg)
4569 ! write (iout,*) 'edihcnstr',edihcnstr
4572 c------------------------------------------------------------------------------
4574 subroutine etor(etors,edihcnstr,fact)
4575 implicit real*8 (a-h,o-z)
4576 include 'DIMENSIONS'
4577 include 'DIMENSIONS.ZSCOPT'
4578 include 'COMMON.VAR'
4579 include 'COMMON.GEO'
4580 include 'COMMON.LOCAL'
4581 include 'COMMON.TORSION'
4582 include 'COMMON.INTERACT'
4583 include 'COMMON.DERIV'
4584 include 'COMMON.CHAIN'
4585 include 'COMMON.NAMES'
4586 include 'COMMON.IOUNITS'
4587 include 'COMMON.FFIELD'
4588 include 'COMMON.TORCNSTR'
4590 C Set lprn=.true. for debugging
4594 do i=iphi_start,iphi_end
4595 if (itel(i-2).eq.0 .or. itel(i-1).eq.0) goto 1215
4596 itori=itortyp(itype(i-2))
4597 itori1=itortyp(itype(i-1))
4600 C Regular cosine and sine terms
4601 do j=1,nterm(itori,itori1)
4602 v1ij=v1(j,itori,itori1)
4603 v2ij=v2(j,itori,itori1)
4606 etors=etors+v1ij*cosphi+v2ij*sinphi
4607 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
4611 C E = SUM ----------------------------------- - v1
4612 C [v2 cos(phi/2)+v3 sin(phi/2)]^2 + 1
4614 cosphi=dcos(0.5d0*phii)
4615 sinphi=dsin(0.5d0*phii)
4616 do j=1,nlor(itori,itori1)
4617 vl1ij=vlor1(j,itori,itori1)
4618 vl2ij=vlor2(j,itori,itori1)
4619 vl3ij=vlor3(j,itori,itori1)
4620 pom=vl2ij*cosphi+vl3ij*sinphi
4621 pom1=1.0d0/(pom*pom+1.0d0)
4622 etors=etors+vl1ij*pom1
4624 gloci=gloci+vl1ij*(vl3ij*cosphi-vl2ij*sinphi)*pom
4626 C Subtract the constant term
4627 etors=etors-v0(itori,itori1)
4629 & write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)')
4630 & restyp(itype(i-2)),i-2,restyp(itype(i-1)),i-1,itori,itori1,
4631 & (v1(j,itori,itori1),j=1,6),(v2(j,itori,itori1),j=1,6)
4632 gloc(i-3,icg)=gloc(i-3,icg)+wtor*fact*gloci
4633 c write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
4636 ! 6/20/98 - dihedral angle constraints
4639 itori=idih_constr(i)
4641 difi=pinorm(phii-phi0(i))
4643 if (difi.gt.drange(i)) then
4645 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
4646 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
4647 edihi=0.25d0*ftors*difi**4
4648 else if (difi.lt.-drange(i)) then
4650 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
4651 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
4652 edihi=0.25d0*ftors*difi**4
4656 c write (iout,'(2i5,4f10.5,e15.5)') i,itori,phii,phi0(i),difi,
4658 ! write (iout,'(2i5,2f8.3,2e14.5)') i,itori,rad2deg*phii,
4659 ! & rad2deg*difi,0.25d0*ftors*difi**4,gloc(itori-3,icg)
4661 ! write (iout,*) 'edihcnstr',edihcnstr
4664 c----------------------------------------------------------------------------
4665 subroutine etor_d(etors_d,fact2)
4666 C 6/23/01 Compute double torsional energy
4667 implicit real*8 (a-h,o-z)
4668 include 'DIMENSIONS'
4669 include 'DIMENSIONS.ZSCOPT'
4670 include 'COMMON.VAR'
4671 include 'COMMON.GEO'
4672 include 'COMMON.LOCAL'
4673 include 'COMMON.TORSION'
4674 include 'COMMON.INTERACT'
4675 include 'COMMON.DERIV'
4676 include 'COMMON.CHAIN'
4677 include 'COMMON.NAMES'
4678 include 'COMMON.IOUNITS'
4679 include 'COMMON.FFIELD'
4680 include 'COMMON.TORCNSTR'
4682 C Set lprn=.true. for debugging
4686 do i=iphi_start,iphi_end-1
4687 if (itel(i-2).eq.0 .or. itel(i-1).eq.0 .or. itel(i).eq.0)
4689 itori=itortyp(itype(i-2))
4690 itori1=itortyp(itype(i-1))
4691 itori2=itortyp(itype(i))
4696 C Regular cosine and sine terms
4697 do j=1,ntermd_1(itori,itori1,itori2)
4698 v1cij=v1c(1,j,itori,itori1,itori2)
4699 v1sij=v1s(1,j,itori,itori1,itori2)
4700 v2cij=v1c(2,j,itori,itori1,itori2)
4701 v2sij=v1s(2,j,itori,itori1,itori2)
4702 cosphi1=dcos(j*phii)
4703 sinphi1=dsin(j*phii)
4704 cosphi2=dcos(j*phii1)
4705 sinphi2=dsin(j*phii1)
4706 etors_d=etors_d+v1cij*cosphi1+v1sij*sinphi1+
4707 & v2cij*cosphi2+v2sij*sinphi2
4708 gloci1=gloci1+j*(v1sij*cosphi1-v1cij*sinphi1)
4709 gloci2=gloci2+j*(v2sij*cosphi2-v2cij*sinphi2)
4711 do k=2,ntermd_2(itori,itori1,itori2)
4713 v1cdij = v2c(k,l,itori,itori1,itori2)
4714 v2cdij = v2c(l,k,itori,itori1,itori2)
4715 v1sdij = v2s(k,l,itori,itori1,itori2)
4716 v2sdij = v2s(l,k,itori,itori1,itori2)
4717 cosphi1p2=dcos(l*phii+(k-l)*phii1)
4718 cosphi1m2=dcos(l*phii-(k-l)*phii1)
4719 sinphi1p2=dsin(l*phii+(k-l)*phii1)
4720 sinphi1m2=dsin(l*phii-(k-l)*phii1)
4721 etors_d=etors_d+v1cdij*cosphi1p2+v2cdij*cosphi1m2+
4722 & v1sdij*sinphi1p2+v2sdij*sinphi1m2
4723 gloci1=gloci1+l*(v1sdij*cosphi1p2+v2sdij*cosphi1m2
4724 & -v1cdij*sinphi1p2-v2cdij*sinphi1m2)
4725 gloci2=gloci2+(k-l)*(v1sdij*cosphi1p2-v2sdij*cosphi1m2
4726 & -v1cdij*sinphi1p2+v2cdij*sinphi1m2)
4729 gloc(i-3,icg)=gloc(i-3,icg)+wtor_d*fact2*gloci1
4730 gloc(i-2,icg)=gloc(i-2,icg)+wtor_d*fact2*gloci2
4736 c------------------------------------------------------------------------------
4737 subroutine eback_sc_corr(esccor)
4738 c 7/21/2007 Correlations between the backbone-local and side-chain-local
4739 c conformational states; temporarily implemented as differences
4740 c between UNRES torsional potentials (dependent on three types of
4741 c residues) and the torsional potentials dependent on all 20 types
4742 c of residues computed from AM1 energy surfaces of terminally-blocked
4743 c amino-acid residues.
4744 implicit real*8 (a-h,o-z)
4745 include 'DIMENSIONS'
4746 include 'DIMENSIONS.ZSCOPT'
4747 include 'COMMON.VAR'
4748 include 'COMMON.GEO'
4749 include 'COMMON.LOCAL'
4750 include 'COMMON.TORSION'
4751 include 'COMMON.SCCOR'
4752 include 'COMMON.INTERACT'
4753 include 'COMMON.DERIV'
4754 include 'COMMON.CHAIN'
4755 include 'COMMON.NAMES'
4756 include 'COMMON.IOUNITS'
4757 include 'COMMON.FFIELD'
4758 include 'COMMON.CONTROL'
4760 C Set lprn=.true. for debugging
4763 c write (iout,*) "EBACK_SC_COR",itau_start,itau_end,nterm_sccor
4765 do i=itau_start,itau_end
4767 isccori=isccortyp(itype(i-2))
4768 isccori1=isccortyp(itype(i-1))
4770 cccc Added 9 May 2012
4771 cc Tauangle is torsional engle depending on the value of first digit
4772 c(see comment below)
4773 cc Omicron is flat angle depending on the value of first digit
4774 c(see comment below)
4777 do intertyp=1,3 !intertyp
4778 cc Added 09 May 2012 (Adasko)
4779 cc Intertyp means interaction type of backbone mainchain correlation:
4780 c 1 = SC...Ca...Ca...Ca
4781 c 2 = Ca...Ca...Ca...SC
4782 c 3 = SC...Ca...Ca...SCi
4784 if (((intertyp.eq.3).and.((itype(i-2).eq.10).or.
4785 & (itype(i-1).eq.10).or.(itype(i-2).eq.21).or.
4786 & (itype(i-1).eq.21)))
4787 & .or. ((intertyp.eq.1).and.((itype(i-2).eq.10)
4788 & .or.(itype(i-2).eq.21)))
4789 & .or.((intertyp.eq.2).and.((itype(i-1).eq.10).or.
4790 & (itype(i-1).eq.21)))) cycle
4791 if ((intertyp.eq.2).and.(i.eq.4).and.(itype(1).eq.21)) cycle
4792 if ((intertyp.eq.1).and.(i.eq.nres).and.(itype(nres).eq.21))
4794 do j=1,nterm_sccor(isccori,isccori1)
4795 v1ij=v1sccor(j,intertyp,isccori,isccori1)
4796 v2ij=v2sccor(j,intertyp,isccori,isccori1)
4797 cosphi=dcos(j*tauangle(intertyp,i))
4798 sinphi=dsin(j*tauangle(intertyp,i))
4799 esccor=esccor+v1ij*cosphi+v2ij*sinphi
4800 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
4802 gloc_sc(intertyp,i-3,icg)=gloc_sc(intertyp,i-3,icg)+wsccor*gloci
4803 c write (iout,*) "WTF",intertyp,i,itype(i),v1ij*cosphi+v2ij*sinphi
4804 c &gloc_sc(intertyp,i-3,icg)
4806 & write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)')
4807 & restyp(itype(i-2)),i-2,restyp(itype(i-1)),i-1,itori,itori1,
4808 & (v1sccor(j,intertyp,itori,itori1),j=1,6)
4809 & ,(v2sccor(j,intertyp,itori,itori1),j=1,6)
4810 gsccor_loc(i-3)=gsccor_loc(i-3)+gloci
4814 c write (iout,*) "W@T@F", gloc_sc(1,i,icg),gloc(i,icg)
4818 c------------------------------------------------------------------------------
4819 subroutine multibody(ecorr)
4820 C This subroutine calculates multi-body contributions to energy following
4821 C the idea of Skolnick et al. If side chains I and J make a contact and
4822 C at the same time side chains I+1 and J+1 make a contact, an extra
4823 C contribution equal to sqrt(eps(i,j)*eps(i+1,j+1)) is added.
4824 implicit real*8 (a-h,o-z)
4825 include 'DIMENSIONS'
4826 include 'COMMON.IOUNITS'
4827 include 'COMMON.DERIV'
4828 include 'COMMON.INTERACT'
4829 include 'COMMON.CONTACTS'
4830 double precision gx(3),gx1(3)
4833 C Set lprn=.true. for debugging
4837 write (iout,'(a)') 'Contact function values:'
4839 write (iout,'(i2,20(1x,i2,f10.5))')
4840 & i,(jcont(j,i),facont(j,i),j=1,num_cont(i))
4855 num_conti=num_cont(i)
4856 num_conti1=num_cont(i1)
4861 if (j1.eq.j+ishift .or. j1.eq.j-ishift) then
4862 cd write(iout,*)'i=',i,' j=',j,' i1=',i1,' j1=',j1,
4863 cd & ' ishift=',ishift
4864 C Contacts I--J and I+ISHIFT--J+-ISHIFT1 occur simultaneously.
4865 C The system gains extra energy.
4866 ecorr=ecorr+esccorr(i,j,i1,j1,jj,kk)
4867 endif ! j1==j+-ishift
4876 c------------------------------------------------------------------------------
4877 double precision function esccorr(i,j,k,l,jj,kk)
4878 implicit real*8 (a-h,o-z)
4879 include 'DIMENSIONS'
4880 include 'COMMON.IOUNITS'
4881 include 'COMMON.DERIV'
4882 include 'COMMON.INTERACT'
4883 include 'COMMON.CONTACTS'
4884 double precision gx(3),gx1(3)
4889 cd write (iout,'(4i5,3f10.5)') i,j,k,l,eij,ekl,-eij*ekl
4890 C Calculate the multi-body contribution to energy.
4891 C Calculate multi-body contributions to the gradient.
4892 cd write (iout,'(2(2i3,3f10.5))')i,j,(gacont(m,jj,i),m=1,3),
4893 cd & k,l,(gacont(m,kk,k),m=1,3)
4895 gx(m) =ekl*gacont(m,jj,i)
4896 gx1(m)=eij*gacont(m,kk,k)
4897 gradxorr(m,i)=gradxorr(m,i)-gx(m)
4898 gradxorr(m,j)=gradxorr(m,j)+gx(m)
4899 gradxorr(m,k)=gradxorr(m,k)-gx1(m)
4900 gradxorr(m,l)=gradxorr(m,l)+gx1(m)
4904 gradcorr(ll,m)=gradcorr(ll,m)+gx(ll)
4909 gradcorr(ll,m)=gradcorr(ll,m)+gx1(ll)
4915 c------------------------------------------------------------------------------
4917 subroutine pack_buffer(dimen1,dimen2,atom,indx,buffer)
4918 implicit real*8 (a-h,o-z)
4919 include 'DIMENSIONS'
4920 integer dimen1,dimen2,atom,indx
4921 double precision buffer(dimen1,dimen2)
4922 double precision zapas
4923 common /contacts_hb/ zapas(3,20,maxres,7),
4924 & facont_hb(20,maxres),ees0p(20,maxres),ees0m(20,maxres),
4925 & num_cont_hb(maxres),jcont_hb(20,maxres)
4926 num_kont=num_cont_hb(atom)
4930 buffer(i,indx+(k-1)*3+j)=zapas(j,i,atom,k)
4933 buffer(i,indx+22)=facont_hb(i,atom)
4934 buffer(i,indx+23)=ees0p(i,atom)
4935 buffer(i,indx+24)=ees0m(i,atom)
4936 buffer(i,indx+25)=dfloat(jcont_hb(i,atom))
4938 buffer(1,indx+26)=dfloat(num_kont)
4941 c------------------------------------------------------------------------------
4942 subroutine unpack_buffer(dimen1,dimen2,atom,indx,buffer)
4943 implicit real*8 (a-h,o-z)
4944 include 'DIMENSIONS'
4945 integer dimen1,dimen2,atom,indx
4946 double precision buffer(dimen1,dimen2)
4947 double precision zapas
4948 common /contacts_hb/ zapas(3,20,maxres,7),
4949 & facont_hb(20,maxres),ees0p(20,maxres),ees0m(20,maxres),
4950 & num_cont_hb(maxres),jcont_hb(20,maxres)
4951 num_kont=buffer(1,indx+26)
4952 num_kont_old=num_cont_hb(atom)
4953 num_cont_hb(atom)=num_kont+num_kont_old
4958 zapas(j,ii,atom,k)=buffer(i,indx+(k-1)*3+j)
4961 facont_hb(ii,atom)=buffer(i,indx+22)
4962 ees0p(ii,atom)=buffer(i,indx+23)
4963 ees0m(ii,atom)=buffer(i,indx+24)
4964 jcont_hb(ii,atom)=buffer(i,indx+25)
4968 c------------------------------------------------------------------------------
4970 subroutine multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
4971 C This subroutine calculates multi-body contributions to hydrogen-bonding
4972 implicit real*8 (a-h,o-z)
4973 include 'DIMENSIONS'
4974 include 'DIMENSIONS.ZSCOPT'
4975 include 'COMMON.IOUNITS'
4977 include 'COMMON.INFO'
4979 include 'COMMON.FFIELD'
4980 include 'COMMON.DERIV'
4981 include 'COMMON.INTERACT'
4982 include 'COMMON.CONTACTS'
4984 parameter (max_cont=maxconts)
4985 parameter (max_dim=2*(8*3+2))
4986 parameter (msglen1=max_cont*max_dim*4)
4987 parameter (msglen2=2*msglen1)
4988 integer source,CorrelType,CorrelID,Error
4989 double precision buffer(max_cont,max_dim)
4991 double precision gx(3),gx1(3)
4994 C Set lprn=.true. for debugging
4999 if (fgProcs.le.1) goto 30
5001 write (iout,'(a)') 'Contact function values:'
5003 write (iout,'(2i3,50(1x,i2,f5.2))')
5004 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
5005 & j=1,num_cont_hb(i))
5008 C Caution! Following code assumes that electrostatic interactions concerning
5009 C a given atom are split among at most two processors!
5019 cd write (iout,*) 'MyRank',MyRank,' mm',mm
5022 cd write (iout,*) 'Sending: MyRank',MyRank,' mm',mm,' ldone',ldone
5023 if (MyRank.gt.0) then
5024 C Send correlation contributions to the preceding processor
5026 nn=num_cont_hb(iatel_s)
5027 call pack_buffer(max_cont,max_dim,iatel_s,0,buffer)
5028 cd write (iout,*) 'The BUFFER array:'
5030 cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,26)
5032 if (ielstart(iatel_s).gt.iatel_s+ispp) then
5034 call pack_buffer(max_cont,max_dim,iatel_s+1,26,buffer)
5035 C Clear the contacts of the atom passed to the neighboring processor
5036 nn=num_cont_hb(iatel_s+1)
5038 cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j+26),j=1,26)
5040 num_cont_hb(iatel_s)=0
5042 cd write (iout,*) 'Processor ',MyID,MyRank,
5043 cd & ' is sending correlation contribution to processor',MyID-1,
5044 cd & ' msglen=',msglen
5045 cd write (*,*) 'Processor ',MyID,MyRank,
5046 cd & ' is sending correlation contribution to processor',MyID-1,
5047 cd & ' msglen=',msglen,' CorrelType=',CorrelType
5048 call mp_bsend(buffer,msglen,MyID-1,CorrelType,CorrelID)
5049 cd write (iout,*) 'Processor ',MyID,
5050 cd & ' has sent correlation contribution to processor',MyID-1,
5051 cd & ' msglen=',msglen,' CorrelID=',CorrelID
5052 cd write (*,*) 'Processor ',MyID,
5053 cd & ' has sent correlation contribution to processor',MyID-1,
5054 cd & ' msglen=',msglen,' CorrelID=',CorrelID
5056 endif ! (MyRank.gt.0)
5060 cd write (iout,*) 'Receiving: MyRank',MyRank,' mm',mm,' ldone',ldone
5061 if (MyRank.lt.fgProcs-1) then
5062 C Receive correlation contributions from the next processor
5064 if (ielend(iatel_e).lt.nct-1) msglen=msglen2
5065 cd write (iout,*) 'Processor',MyID,
5066 cd & ' is receiving correlation contribution from processor',MyID+1,
5067 cd & ' msglen=',msglen,' CorrelType=',CorrelType
5068 cd write (*,*) 'Processor',MyID,
5069 cd & ' is receiving correlation contribution from processor',MyID+1,
5070 cd & ' msglen=',msglen,' CorrelType=',CorrelType
5072 do while (nbytes.le.0)
5073 call mp_probe(MyID+1,CorrelType,nbytes)
5075 cd print *,'Processor',MyID,' msglen',msglen,' nbytes',nbytes
5076 call mp_brecv(buffer,msglen,MyID+1,CorrelType,nbytes)
5077 cd write (iout,*) 'Processor',MyID,
5078 cd & ' has received correlation contribution from processor',MyID+1,
5079 cd & ' msglen=',msglen,' nbytes=',nbytes
5080 cd write (iout,*) 'The received BUFFER array:'
5082 cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,52)
5084 if (msglen.eq.msglen1) then
5085 call unpack_buffer(max_cont,max_dim,iatel_e+1,0,buffer)
5086 else if (msglen.eq.msglen2) then
5087 call unpack_buffer(max_cont,max_dim,iatel_e,0,buffer)
5088 call unpack_buffer(max_cont,max_dim,iatel_e+1,26,buffer)
5091 & 'ERROR!!!! message length changed while processing correlations.'
5093 & 'ERROR!!!! message length changed while processing correlations.'
5094 call mp_stopall(Error)
5095 endif ! msglen.eq.msglen1
5096 endif ! MyRank.lt.fgProcs-1
5103 write (iout,'(a)') 'Contact function values:'
5105 write (iout,'(2i3,50(1x,i2,f5.2))')
5106 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
5107 & j=1,num_cont_hb(i))
5111 C Remove the loop below after debugging !!!
5118 C Calculate the local-electrostatic correlation terms
5119 do i=iatel_s,iatel_e+1
5121 num_conti=num_cont_hb(i)
5122 num_conti1=num_cont_hb(i+1)
5127 c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
5128 c & ' jj=',jj,' kk=',kk
5129 if (j1.eq.j+1 .or. j1.eq.j-1) then
5130 C Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
5131 C The system gains extra energy.
5132 ecorr=ecorr+ehbcorr(i,j,i+1,j1,jj,kk,0.72D0,0.32D0)
5134 else if (j1.eq.j) then
5135 C Contacts I-J and I-(J+1) occur simultaneously.
5136 C The system loses extra energy.
5137 c ecorr=ecorr+ehbcorr(i,j,i+1,j,jj,kk,0.60D0,-0.40D0)
5142 c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
5143 c & ' jj=',jj,' kk=',kk
5145 C Contacts I-J and (I+1)-J occur simultaneously.
5146 C The system loses extra energy.
5147 c ecorr=ecorr+ehbcorr(i,j,i,j+1,jj,kk,0.60D0,-0.40D0)
5154 c------------------------------------------------------------------------------
5155 subroutine multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,
5157 C This subroutine calculates multi-body contributions to hydrogen-bonding
5158 implicit real*8 (a-h,o-z)
5159 include 'DIMENSIONS'
5160 include 'DIMENSIONS.ZSCOPT'
5161 include 'COMMON.IOUNITS'
5163 include 'COMMON.INFO'
5165 include 'COMMON.FFIELD'
5166 include 'COMMON.DERIV'
5167 include 'COMMON.INTERACT'
5168 include 'COMMON.CONTACTS'
5170 parameter (max_cont=maxconts)
5171 parameter (max_dim=2*(8*3+2))
5172 parameter (msglen1=max_cont*max_dim*4)
5173 parameter (msglen2=2*msglen1)
5174 integer source,CorrelType,CorrelID,Error
5175 double precision buffer(max_cont,max_dim)
5177 double precision gx(3),gx1(3)
5180 C Set lprn=.true. for debugging
5186 if (fgProcs.le.1) goto 30
5188 write (iout,'(a)') 'Contact function values:'
5190 write (iout,'(2i3,50(1x,i2,f5.2))')
5191 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
5192 & j=1,num_cont_hb(i))
5195 C Caution! Following code assumes that electrostatic interactions concerning
5196 C a given atom are split among at most two processors!
5206 cd write (iout,*) 'MyRank',MyRank,' mm',mm
5209 cd write (iout,*) 'Sending: MyRank',MyRank,' mm',mm,' ldone',ldone
5210 if (MyRank.gt.0) then
5211 C Send correlation contributions to the preceding processor
5213 nn=num_cont_hb(iatel_s)
5214 call pack_buffer(max_cont,max_dim,iatel_s,0,buffer)
5215 cd write (iout,*) 'The BUFFER array:'
5217 cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,26)
5219 if (ielstart(iatel_s).gt.iatel_s+ispp) then
5221 call pack_buffer(max_cont,max_dim,iatel_s+1,26,buffer)
5222 C Clear the contacts of the atom passed to the neighboring processor
5223 nn=num_cont_hb(iatel_s+1)
5225 cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j+26),j=1,26)
5227 num_cont_hb(iatel_s)=0
5229 cd write (iout,*) 'Processor ',MyID,MyRank,
5230 cd & ' is sending correlation contribution to processor',MyID-1,
5231 cd & ' msglen=',msglen
5232 cd write (*,*) 'Processor ',MyID,MyRank,
5233 cd & ' is sending correlation contribution to processor',MyID-1,
5234 cd & ' msglen=',msglen,' CorrelType=',CorrelType
5235 call mp_bsend(buffer,msglen,MyID-1,CorrelType,CorrelID)
5236 cd write (iout,*) 'Processor ',MyID,
5237 cd & ' has sent correlation contribution to processor',MyID-1,
5238 cd & ' msglen=',msglen,' CorrelID=',CorrelID
5239 cd write (*,*) 'Processor ',MyID,
5240 cd & ' has sent correlation contribution to processor',MyID-1,
5241 cd & ' msglen=',msglen,' CorrelID=',CorrelID
5243 endif ! (MyRank.gt.0)
5247 cd write (iout,*) 'Receiving: MyRank',MyRank,' mm',mm,' ldone',ldone
5248 if (MyRank.lt.fgProcs-1) then
5249 C Receive correlation contributions from the next processor
5251 if (ielend(iatel_e).lt.nct-1) msglen=msglen2
5252 cd write (iout,*) 'Processor',MyID,
5253 cd & ' is receiving correlation contribution from processor',MyID+1,
5254 cd & ' msglen=',msglen,' CorrelType=',CorrelType
5255 cd write (*,*) 'Processor',MyID,
5256 cd & ' is receiving correlation contribution from processor',MyID+1,
5257 cd & ' msglen=',msglen,' CorrelType=',CorrelType
5259 do while (nbytes.le.0)
5260 call mp_probe(MyID+1,CorrelType,nbytes)
5262 cd print *,'Processor',MyID,' msglen',msglen,' nbytes',nbytes
5263 call mp_brecv(buffer,msglen,MyID+1,CorrelType,nbytes)
5264 cd write (iout,*) 'Processor',MyID,
5265 cd & ' has received correlation contribution from processor',MyID+1,
5266 cd & ' msglen=',msglen,' nbytes=',nbytes
5267 cd write (iout,*) 'The received BUFFER array:'
5269 cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,52)
5271 if (msglen.eq.msglen1) then
5272 call unpack_buffer(max_cont,max_dim,iatel_e+1,0,buffer)
5273 else if (msglen.eq.msglen2) then
5274 call unpack_buffer(max_cont,max_dim,iatel_e,0,buffer)
5275 call unpack_buffer(max_cont,max_dim,iatel_e+1,26,buffer)
5278 & 'ERROR!!!! message length changed while processing correlations.'
5280 & 'ERROR!!!! message length changed while processing correlations.'
5281 call mp_stopall(Error)
5282 endif ! msglen.eq.msglen1
5283 endif ! MyRank.lt.fgProcs-1
5290 write (iout,'(a)') 'Contact function values:'
5292 write (iout,'(2i3,50(1x,i2,f5.2))')
5293 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
5294 & j=1,num_cont_hb(i))
5300 C Remove the loop below after debugging !!!
5307 C Calculate the dipole-dipole interaction energies
5308 if (wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) then
5309 do i=iatel_s,iatel_e+1
5310 num_conti=num_cont_hb(i)
5317 C Calculate the local-electrostatic correlation terms
5318 do i=iatel_s,iatel_e+1
5320 num_conti=num_cont_hb(i)
5321 num_conti1=num_cont_hb(i+1)
5326 c write (*,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
5327 c & ' jj=',jj,' kk=',kk
5328 if (j1.eq.j+1 .or. j1.eq.j-1) then
5329 C Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
5330 C The system gains extra energy.
5332 sqd1=dsqrt(d_cont(jj,i))
5333 sqd2=dsqrt(d_cont(kk,i1))
5334 sred_geom = sqd1*sqd2
5335 IF (sred_geom.lt.cutoff_corr) THEN
5336 call gcont(sred_geom,r0_corr,1.0D0,delt_corr,
5338 c write (*,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
5339 c & ' jj=',jj,' kk=',kk
5340 fac_prim1=0.5d0*sqd2/sqd1*fprimcont
5341 fac_prim2=0.5d0*sqd1/sqd2*fprimcont
5343 g_contij(l,1)=fac_prim1*grij_hb_cont(l,jj,i)
5344 g_contij(l,2)=fac_prim2*grij_hb_cont(l,kk,i1)
5347 cd write (iout,*) 'sred_geom=',sred_geom,
5348 cd & ' ekont=',ekont,' fprim=',fprimcont
5349 call calc_eello(i,j,i+1,j1,jj,kk)
5350 if (wcorr4.gt.0.0d0)
5351 & ecorr=ecorr+eello4(i,j,i+1,j1,jj,kk)
5352 if (wcorr5.gt.0.0d0)
5353 & ecorr5=ecorr5+eello5(i,j,i+1,j1,jj,kk)
5354 c print *,"wcorr5",ecorr5
5355 cd write(2,*)'wcorr6',wcorr6,' wturn6',wturn6
5356 cd write(2,*)'ijkl',i,j,i+1,j1
5357 if (wcorr6.gt.0.0d0 .and. (j.ne.i+4 .or. j1.ne.i+3
5358 & .or. wturn6.eq.0.0d0))then
5359 cd write (iout,*) '******ecorr6: i,j,i+1,j1',i,j,i+1,j1
5360 ecorr6=ecorr6+eello6(i,j,i+1,j1,jj,kk)
5361 cd write (iout,*) 'ecorr',ecorr,' ecorr5=',ecorr5,
5362 cd & 'ecorr6=',ecorr6
5363 cd write (iout,'(4e15.5)') sred_geom,
5364 cd & dabs(eello4(i,j,i+1,j1,jj,kk)),
5365 cd & dabs(eello5(i,j,i+1,j1,jj,kk)),
5366 cd & dabs(eello6(i,j,i+1,j1,jj,kk))
5367 else if (wturn6.gt.0.0d0
5368 & .and. (j.eq.i+4 .and. j1.eq.i+3)) then
5369 cd write (iout,*) '******eturn6: i,j,i+1,j1',i,j,i+1,j1
5370 eturn6=eturn6+eello_turn6(i,jj,kk)
5371 cd write (2,*) 'multibody_eello:eturn6',eturn6
5375 else if (j1.eq.j) then
5376 C Contacts I-J and I-(J+1) occur simultaneously.
5377 C The system loses extra energy.
5378 c ecorr=ecorr+ehbcorr(i,j,i+1,j,jj,kk,0.60D0,-0.40D0)
5383 c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
5384 c & ' jj=',jj,' kk=',kk
5386 C Contacts I-J and (I+1)-J occur simultaneously.
5387 C The system loses extra energy.
5388 c ecorr=ecorr+ehbcorr(i,j,i,j+1,jj,kk,0.60D0,-0.40D0)
5395 c------------------------------------------------------------------------------
5396 double precision function ehbcorr(i,j,k,l,jj,kk,coeffp,coeffm)
5397 implicit real*8 (a-h,o-z)
5398 include 'DIMENSIONS'
5399 include 'COMMON.IOUNITS'
5400 include 'COMMON.DERIV'
5401 include 'COMMON.INTERACT'
5402 include 'COMMON.CONTACTS'
5403 double precision gx(3),gx1(3)
5413 ees=-(coeffp*ees0pij*ees0pkl+coeffm*ees0mij*ees0mkl)
5414 cd ees=-(coeffp*ees0pkl+coeffm*ees0mkl)
5415 C Following 4 lines for diagnostics.
5420 c write (iout,*)'Contacts have occurred for peptide groups',i,j,
5422 c write (iout,*)'Contacts have occurred for peptide groups',
5423 c & i,j,' fcont:',eij,' eij',' eesij',ees0pij,ees0mij,' and ',k,l
5424 c & ,' fcont ',ekl,' eeskl',ees0pkl,ees0mkl,' ees=',ees
5425 C Calculate the multi-body contribution to energy.
5426 ecorr=ecorr+ekont*ees
5428 C Calculate multi-body contributions to the gradient.
5430 ghalf=0.5D0*ees*ekl*gacont_hbr(ll,jj,i)
5431 gradcorr(ll,i)=gradcorr(ll,i)+ghalf
5432 & -ekont*(coeffp*ees0pkl*gacontp_hb1(ll,jj,i)+
5433 & coeffm*ees0mkl*gacontm_hb1(ll,jj,i))
5434 gradcorr(ll,j)=gradcorr(ll,j)+ghalf
5435 & -ekont*(coeffp*ees0pkl*gacontp_hb2(ll,jj,i)+
5436 & coeffm*ees0mkl*gacontm_hb2(ll,jj,i))
5437 ghalf=0.5D0*ees*eij*gacont_hbr(ll,kk,k)
5438 gradcorr(ll,k)=gradcorr(ll,k)+ghalf
5439 & -ekont*(coeffp*ees0pij*gacontp_hb1(ll,kk,k)+
5440 & coeffm*ees0mij*gacontm_hb1(ll,kk,k))
5441 gradcorr(ll,l)=gradcorr(ll,l)+ghalf
5442 & -ekont*(coeffp*ees0pij*gacontp_hb2(ll,kk,k)+
5443 & coeffm*ees0mij*gacontm_hb2(ll,kk,k))
5447 gradcorr(ll,m)=gradcorr(ll,m)+
5448 & ees*ekl*gacont_hbr(ll,jj,i)-
5449 & ekont*(coeffp*ees0pkl*gacontp_hb3(ll,jj,i)+
5450 & coeffm*ees0mkl*gacontm_hb3(ll,jj,i))
5455 gradcorr(ll,m)=gradcorr(ll,m)+
5456 & ees*eij*gacont_hbr(ll,kk,k)-
5457 & ekont*(coeffp*ees0pij*gacontp_hb3(ll,kk,k)+
5458 & coeffm*ees0mij*gacontm_hb3(ll,kk,k))
5465 C---------------------------------------------------------------------------
5466 subroutine dipole(i,j,jj)
5467 implicit real*8 (a-h,o-z)
5468 include 'DIMENSIONS'
5469 include 'DIMENSIONS.ZSCOPT'
5470 include 'COMMON.IOUNITS'
5471 include 'COMMON.CHAIN'
5472 include 'COMMON.FFIELD'
5473 include 'COMMON.DERIV'
5474 include 'COMMON.INTERACT'
5475 include 'COMMON.CONTACTS'
5476 include 'COMMON.TORSION'
5477 include 'COMMON.VAR'
5478 include 'COMMON.GEO'
5479 dimension dipi(2,2),dipj(2,2),dipderi(2),dipderj(2),auxvec(2),
5481 iti1 = itortyp(itype(i+1))
5482 if (j.lt.nres-1) then
5483 itj1 = itortyp(itype(j+1))
5488 dipi(iii,1)=Ub2(iii,i)
5489 dipderi(iii)=Ub2der(iii,i)
5490 dipi(iii,2)=b1(iii,iti1)
5491 dipj(iii,1)=Ub2(iii,j)
5492 dipderj(iii)=Ub2der(iii,j)
5493 dipj(iii,2)=b1(iii,itj1)
5497 call matvec2(a_chuj(1,1,jj,i),dipj(1,iii),auxvec(1))
5500 dip(kkk,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
5503 if (.not.calc_grad) return
5508 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),dipj(1,iii),
5512 dipderx(lll,kkk,mmm,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
5517 call transpose2(a_chuj(1,1,jj,i),auxmat(1,1))
5518 call matvec2(auxmat(1,1),dipderi(1),auxvec(1))
5520 dipderg(iii,jj,i)=scalar2(auxvec(1),dipj(1,iii))
5522 call matvec2(a_chuj(1,1,jj,i),dipderj(1),auxvec(1))
5524 dipderg(iii+2,jj,i)=scalar2(auxvec(1),dipi(1,iii))
5528 C---------------------------------------------------------------------------
5529 subroutine calc_eello(i,j,k,l,jj,kk)
5531 C This subroutine computes matrices and vectors needed to calculate
5532 C the fourth-, fifth-, and sixth-order local-electrostatic terms.
5534 implicit real*8 (a-h,o-z)
5535 include 'DIMENSIONS'
5536 include 'DIMENSIONS.ZSCOPT'
5537 include 'COMMON.IOUNITS'
5538 include 'COMMON.CHAIN'
5539 include 'COMMON.DERIV'
5540 include 'COMMON.INTERACT'
5541 include 'COMMON.CONTACTS'
5542 include 'COMMON.TORSION'
5543 include 'COMMON.VAR'
5544 include 'COMMON.GEO'
5545 include 'COMMON.FFIELD'
5546 double precision aa1(2,2),aa2(2,2),aa1t(2,2),aa2t(2,2),
5547 & aa1tder(2,2,3,5),aa2tder(2,2,3,5),auxmat(2,2)
5550 cd write (iout,*) 'calc_eello: i=',i,' j=',j,' k=',k,' l=',l,
5551 cd & ' jj=',jj,' kk=',kk
5552 cd if (i.ne.2 .or. j.ne.4 .or. k.ne.3 .or. l.ne.5) return
5555 aa1(iii,jjj)=a_chuj(iii,jjj,jj,i)
5556 aa2(iii,jjj)=a_chuj(iii,jjj,kk,k)
5559 call transpose2(aa1(1,1),aa1t(1,1))
5560 call transpose2(aa2(1,1),aa2t(1,1))
5563 call transpose2(a_chuj_der(1,1,lll,kkk,jj,i),
5564 & aa1tder(1,1,lll,kkk))
5565 call transpose2(a_chuj_der(1,1,lll,kkk,kk,k),
5566 & aa2tder(1,1,lll,kkk))
5570 C parallel orientation of the two CA-CA-CA frames.
5572 iti=itortyp(itype(i))
5576 itk1=itortyp(itype(k+1))
5577 itj=itortyp(itype(j))
5578 if (l.lt.nres-1) then
5579 itl1=itortyp(itype(l+1))
5583 C A1 kernel(j+1) A2T
5585 cd write (iout,'(3f10.5,5x,3f10.5)')
5586 cd & (EUg(iii,jjj,k),jjj=1,2),(EUg(iii,jjj,l),jjj=1,2)
5588 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
5589 & aa2tder(1,1,1,1),1,.false.,EUg(1,1,l),EUgder(1,1,l),
5590 & AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
5591 C Following matrices are needed only for 6-th order cumulants
5592 IF (wcorr6.gt.0.0d0) THEN
5593 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
5594 & aa2tder(1,1,1,1),1,.false.,EUgC(1,1,l),EUgCder(1,1,l),
5595 & AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
5596 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
5597 & aa2tder(1,1,1,1),2,.false.,Ug2DtEUg(1,1,l),
5598 & Ug2DtEUgder(1,1,1,l),ADtEA(1,1,1),ADtEAderg(1,1,1,1),
5599 & ADtEAderx(1,1,1,1,1,1))
5601 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
5602 & aa2tder(1,1,1,1),2,.false.,DtUg2EUg(1,1,l),
5603 & DtUg2EUgder(1,1,1,l),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),
5604 & ADtEA1derx(1,1,1,1,1,1))
5606 C End 6-th order cumulants
5609 cd write (2,*) 'In calc_eello6'
5611 cd write (2,*) 'iii=',iii
5613 cd write (2,*) 'kkk=',kkk
5615 cd write (2,'(3(2f10.5),5x)')
5616 cd & ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
5621 call transpose2(EUgder(1,1,k),auxmat(1,1))
5622 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
5623 call transpose2(EUg(1,1,k),auxmat(1,1))
5624 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
5625 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
5629 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),
5630 & EAEAderx(1,1,lll,kkk,iii,1))
5634 C A1T kernel(i+1) A2
5635 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
5636 & a_chuj_der(1,1,1,1,kk,k),1,.false.,EUg(1,1,k),EUgder(1,1,k),
5637 & AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
5638 C Following matrices are needed only for 6-th order cumulants
5639 IF (wcorr6.gt.0.0d0) THEN
5640 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
5641 & a_chuj_der(1,1,1,1,kk,k),1,.false.,EUgC(1,1,k),EUgCder(1,1,k),
5642 & AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
5643 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
5644 & a_chuj_der(1,1,1,1,kk,k),2,.false.,Ug2DtEUg(1,1,k),
5645 & Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),
5646 & ADtEAderx(1,1,1,1,1,2))
5647 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
5648 & a_chuj_der(1,1,1,1,kk,k),2,.false.,DtUg2EUg(1,1,k),
5649 & DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),
5650 & ADtEA1derx(1,1,1,1,1,2))
5652 C End 6-th order cumulants
5653 call transpose2(EUgder(1,1,l),auxmat(1,1))
5654 call matmat2(auxmat(1,1),AEA(1,1,2),EAEAderg(1,1,1,2))
5655 call transpose2(EUg(1,1,l),auxmat(1,1))
5656 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
5657 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
5661 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
5662 & EAEAderx(1,1,lll,kkk,iii,2))
5667 C Calculate the vectors and their derivatives in virtual-bond dihedral angles.
5668 C They are needed only when the fifth- or the sixth-order cumulants are
5670 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) THEN
5671 call transpose2(AEA(1,1,1),auxmat(1,1))
5672 call matvec2(auxmat(1,1),b1(1,iti),AEAb1(1,1,1))
5673 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
5674 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
5675 call transpose2(AEAderg(1,1,1),auxmat(1,1))
5676 call matvec2(auxmat(1,1),b1(1,iti),AEAb1derg(1,1,1))
5677 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
5678 call matvec2(AEA(1,1,1),b1(1,itk1),AEAb1(1,2,1))
5679 call matvec2(AEAderg(1,1,1),b1(1,itk1),AEAb1derg(1,2,1))
5680 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
5681 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
5682 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
5683 call transpose2(AEA(1,1,2),auxmat(1,1))
5684 call matvec2(auxmat(1,1),b1(1,itj),AEAb1(1,1,2))
5685 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2(1,1,2))
5686 call matvec2(auxmat(1,1),Ub2der(1,j),AEAb2derg(1,2,1,2))
5687 call transpose2(AEAderg(1,1,2),auxmat(1,1))
5688 call matvec2(auxmat(1,1),b1(1,itj),AEAb1derg(1,1,2))
5689 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2derg(1,1,1,2))
5690 call matvec2(AEA(1,1,2),b1(1,itl1),AEAb1(1,2,2))
5691 call matvec2(AEAderg(1,1,2),b1(1,itl1),AEAb1derg(1,2,2))
5692 call matvec2(AEA(1,1,2),Ub2(1,l+1),AEAb2(1,2,2))
5693 call matvec2(AEAderg(1,1,2),Ub2(1,l+1),AEAb2derg(1,1,2,2))
5694 call matvec2(AEA(1,1,2),Ub2der(1,l+1),AEAb2derg(1,2,2,2))
5695 C Calculate the Cartesian derivatives of the vectors.
5699 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
5700 call matvec2(auxmat(1,1),b1(1,iti),
5701 & AEAb1derx(1,lll,kkk,iii,1,1))
5702 call matvec2(auxmat(1,1),Ub2(1,i),
5703 & AEAb2derx(1,lll,kkk,iii,1,1))
5704 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,itk1),
5705 & AEAb1derx(1,lll,kkk,iii,2,1))
5706 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),
5707 & AEAb2derx(1,lll,kkk,iii,2,1))
5708 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
5709 call matvec2(auxmat(1,1),b1(1,itj),
5710 & AEAb1derx(1,lll,kkk,iii,1,2))
5711 call matvec2(auxmat(1,1),Ub2(1,j),
5712 & AEAb2derx(1,lll,kkk,iii,1,2))
5713 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,itl1),
5714 & AEAb1derx(1,lll,kkk,iii,2,2))
5715 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,l+1),
5716 & AEAb2derx(1,lll,kkk,iii,2,2))
5723 C Antiparallel orientation of the two CA-CA-CA frames.
5725 iti=itortyp(itype(i))
5729 itk1=itortyp(itype(k+1))
5730 itl=itortyp(itype(l))
5731 itj=itortyp(itype(j))
5732 if (j.lt.nres-1) then
5733 itj1=itortyp(itype(j+1))
5737 C A2 kernel(j-1)T A1T
5738 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
5739 & aa2tder(1,1,1,1),1,.true.,EUg(1,1,j),EUgder(1,1,j),
5740 & AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
5741 C Following matrices are needed only for 6-th order cumulants
5742 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and.
5743 & j.eq.i+4 .and. l.eq.i+3)) THEN
5744 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
5745 & aa2tder(1,1,1,1),1,.true.,EUgC(1,1,j),EUgCder(1,1,j),
5746 & AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
5747 call kernel(aa2(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
5748 & aa2tder(1,1,1,1),2,.true.,Ug2DtEUg(1,1,j),
5749 & Ug2DtEUgder(1,1,1,j),ADtEA(1,1,1),ADtEAderg(1,1,1,1),
5750 & ADtEAderx(1,1,1,1,1,1))
5751 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
5752 & aa2tder(1,1,1,1),2,.true.,DtUg2EUg(1,1,j),
5753 & DtUg2EUgder(1,1,1,j),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),
5754 & ADtEA1derx(1,1,1,1,1,1))
5756 C End 6-th order cumulants
5757 call transpose2(EUgder(1,1,k),auxmat(1,1))
5758 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
5759 call transpose2(EUg(1,1,k),auxmat(1,1))
5760 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
5761 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
5765 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),
5766 & EAEAderx(1,1,lll,kkk,iii,1))
5770 C A2T kernel(i+1)T A1
5771 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
5772 & a_chuj_der(1,1,1,1,jj,i),1,.true.,EUg(1,1,k),EUgder(1,1,k),
5773 & AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
5774 C Following matrices are needed only for 6-th order cumulants
5775 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and.
5776 & j.eq.i+4 .and. l.eq.i+3)) THEN
5777 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
5778 & a_chuj_der(1,1,1,1,jj,i),1,.true.,EUgC(1,1,k),EUgCder(1,1,k),
5779 & AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
5780 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
5781 & a_chuj_der(1,1,1,1,jj,i),2,.true.,Ug2DtEUg(1,1,k),
5782 & Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),
5783 & ADtEAderx(1,1,1,1,1,2))
5784 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
5785 & a_chuj_der(1,1,1,1,jj,i),2,.true.,DtUg2EUg(1,1,k),
5786 & DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),
5787 & ADtEA1derx(1,1,1,1,1,2))
5789 C End 6-th order cumulants
5790 call transpose2(EUgder(1,1,j),auxmat(1,1))
5791 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,2,2))
5792 call transpose2(EUg(1,1,j),auxmat(1,1))
5793 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
5794 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
5798 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
5799 & EAEAderx(1,1,lll,kkk,iii,2))
5804 C Calculate the vectors and their derivatives in virtual-bond dihedral angles.
5805 C They are needed only when the fifth- or the sixth-order cumulants are
5807 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 .or.
5808 & (wturn6.gt.0.0d0 .and. j.eq.i+4 .and. l.eq.i+3)) THEN
5809 call transpose2(AEA(1,1,1),auxmat(1,1))
5810 call matvec2(auxmat(1,1),b1(1,iti),AEAb1(1,1,1))
5811 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
5812 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
5813 call transpose2(AEAderg(1,1,1),auxmat(1,1))
5814 call matvec2(auxmat(1,1),b1(1,iti),AEAb1derg(1,1,1))
5815 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
5816 call matvec2(AEA(1,1,1),b1(1,itk1),AEAb1(1,2,1))
5817 call matvec2(AEAderg(1,1,1),b1(1,itk1),AEAb1derg(1,2,1))
5818 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
5819 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
5820 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
5821 call transpose2(AEA(1,1,2),auxmat(1,1))
5822 call matvec2(auxmat(1,1),b1(1,itj1),AEAb1(1,1,2))
5823 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2(1,1,2))
5824 call matvec2(auxmat(1,1),Ub2der(1,l),AEAb2derg(1,2,1,2))
5825 call transpose2(AEAderg(1,1,2),auxmat(1,1))
5826 call matvec2(auxmat(1,1),b1(1,itl),AEAb1(1,1,2))
5827 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2derg(1,1,1,2))
5828 call matvec2(AEA(1,1,2),b1(1,itj1),AEAb1(1,2,2))
5829 call matvec2(AEAderg(1,1,2),b1(1,itj1),AEAb1derg(1,2,2))
5830 call matvec2(AEA(1,1,2),Ub2(1,j),AEAb2(1,2,2))
5831 call matvec2(AEAderg(1,1,2),Ub2(1,j),AEAb2derg(1,1,2,2))
5832 call matvec2(AEA(1,1,2),Ub2der(1,j),AEAb2derg(1,2,2,2))
5833 C Calculate the Cartesian derivatives of the vectors.
5837 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
5838 call matvec2(auxmat(1,1),b1(1,iti),
5839 & AEAb1derx(1,lll,kkk,iii,1,1))
5840 call matvec2(auxmat(1,1),Ub2(1,i),
5841 & AEAb2derx(1,lll,kkk,iii,1,1))
5842 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,itk1),
5843 & AEAb1derx(1,lll,kkk,iii,2,1))
5844 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),
5845 & AEAb2derx(1,lll,kkk,iii,2,1))
5846 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
5847 call matvec2(auxmat(1,1),b1(1,itl),
5848 & AEAb1derx(1,lll,kkk,iii,1,2))
5849 call matvec2(auxmat(1,1),Ub2(1,l),
5850 & AEAb2derx(1,lll,kkk,iii,1,2))
5851 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,itj1),
5852 & AEAb1derx(1,lll,kkk,iii,2,2))
5853 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,j),
5854 & AEAb2derx(1,lll,kkk,iii,2,2))
5863 C---------------------------------------------------------------------------
5864 subroutine kernel(aa1,aa2t,aa1derx,aa2tderx,nderg,transp,
5865 & KK,KKderg,AKA,AKAderg,AKAderx)
5869 double precision aa1(2,2),aa2t(2,2),aa1derx(2,2,3,5),
5870 & aa2tderx(2,2,3,5),KK(2,2),KKderg(2,2,nderg),AKA(2,2),
5871 & AKAderg(2,2,nderg),AKAderx(2,2,3,5,2)
5876 call prodmat3(aa1(1,1),aa2t(1,1),KK(1,1),transp,AKA(1,1))
5878 call prodmat3(aa1(1,1),aa2t(1,1),KKderg(1,1,iii),transp,
5881 cd if (lprn) write (2,*) 'In kernel'
5883 cd if (lprn) write (2,*) 'kkk=',kkk
5885 call prodmat3(aa1derx(1,1,lll,kkk),aa2t(1,1),
5886 & KK(1,1),transp,AKAderx(1,1,lll,kkk,1))
5888 cd write (2,*) 'lll=',lll
5889 cd write (2,*) 'iii=1'
5891 cd write (2,'(3(2f10.5),5x)')
5892 cd & (AKAderx(jjj,mmm,lll,kkk,1),mmm=1,2)
5895 call prodmat3(aa1(1,1),aa2tderx(1,1,lll,kkk),
5896 & KK(1,1),transp,AKAderx(1,1,lll,kkk,2))
5898 cd write (2,*) 'lll=',lll
5899 cd write (2,*) 'iii=2'
5901 cd write (2,'(3(2f10.5),5x)')
5902 cd & (AKAderx(jjj,mmm,lll,kkk,2),mmm=1,2)
5909 C---------------------------------------------------------------------------
5910 double precision function eello4(i,j,k,l,jj,kk)
5911 implicit real*8 (a-h,o-z)
5912 include 'DIMENSIONS'
5913 include 'DIMENSIONS.ZSCOPT'
5914 include 'COMMON.IOUNITS'
5915 include 'COMMON.CHAIN'
5916 include 'COMMON.DERIV'
5917 include 'COMMON.INTERACT'
5918 include 'COMMON.CONTACTS'
5919 include 'COMMON.TORSION'
5920 include 'COMMON.VAR'
5921 include 'COMMON.GEO'
5922 double precision pizda(2,2),ggg1(3),ggg2(3)
5923 cd if (i.ne.1 .or. j.ne.5 .or. k.ne.2 .or.l.ne.4) then
5927 cd print *,'eello4:',i,j,k,l,jj,kk
5928 cd write (2,*) 'i',i,' j',j,' k',k,' l',l
5929 cd call checkint4(i,j,k,l,jj,kk,eel4_num)
5930 cold eij=facont_hb(jj,i)
5931 cold ekl=facont_hb(kk,k)
5933 eel4=-EAEA(1,1,1)-EAEA(2,2,1)
5935 cd eel41=-EAEA(1,1,2)-EAEA(2,2,2)
5936 gcorr_loc(k-1)=gcorr_loc(k-1)
5937 & -ekont*(EAEAderg(1,1,1,1)+EAEAderg(2,2,1,1))
5939 gcorr_loc(l-1)=gcorr_loc(l-1)
5940 & -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
5942 gcorr_loc(j-1)=gcorr_loc(j-1)
5943 & -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
5948 derx(lll,kkk,iii)=-EAEAderx(1,1,lll,kkk,iii,1)
5949 & -EAEAderx(2,2,lll,kkk,iii,1)
5950 cd derx(lll,kkk,iii)=0.0d0
5954 cd gcorr_loc(l-1)=0.0d0
5955 cd gcorr_loc(j-1)=0.0d0
5956 cd gcorr_loc(k-1)=0.0d0
5958 cd write (iout,*)'Contacts have occurred for peptide groups',
5959 cd & i,j,' fcont:',eij,' eij',' and ',k,l,
5960 cd & ' fcont ',ekl,' eel4=',eel4,' eel4_num',16*eel4_num
5961 if (j.lt.nres-1) then
5968 if (l.lt.nres-1) then
5976 cold ghalf=0.5d0*eel4*ekl*gacont_hbr(ll,jj,i)
5977 ggg1(ll)=eel4*g_contij(ll,1)
5978 ggg2(ll)=eel4*g_contij(ll,2)
5979 ghalf=0.5d0*ggg1(ll)
5981 gradcorr(ll,i)=gradcorr(ll,i)+ghalf+ekont*derx(ll,2,1)
5982 gradcorr(ll,i+1)=gradcorr(ll,i+1)+ekont*derx(ll,3,1)
5983 gradcorr(ll,j)=gradcorr(ll,j)+ghalf+ekont*derx(ll,4,1)
5984 gradcorr(ll,j1)=gradcorr(ll,j1)+ekont*derx(ll,5,1)
5985 cold ghalf=0.5d0*eel4*eij*gacont_hbr(ll,kk,k)
5986 ghalf=0.5d0*ggg2(ll)
5988 gradcorr(ll,k)=gradcorr(ll,k)+ghalf+ekont*derx(ll,2,2)
5989 gradcorr(ll,k+1)=gradcorr(ll,k+1)+ekont*derx(ll,3,2)
5990 gradcorr(ll,l)=gradcorr(ll,l)+ghalf+ekont*derx(ll,4,2)
5991 gradcorr(ll,l1)=gradcorr(ll,l1)+ekont*derx(ll,5,2)
5996 cold gradcorr(ll,m)=gradcorr(ll,m)+eel4*ekl*gacont_hbr(ll,jj,i)
5997 gradcorr(ll,m)=gradcorr(ll,m)+ggg1(ll)
6002 cold gradcorr(ll,m)=gradcorr(ll,m)+eel4*eij*gacont_hbr(ll,kk,k)
6003 gradcorr(ll,m)=gradcorr(ll,m)+ggg2(ll)
6009 gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,1)
6014 gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,2)
6018 cd write (2,*) iii,gcorr_loc(iii)
6022 cd write (2,*) 'ekont',ekont
6023 cd write (iout,*) 'eello4',ekont*eel4
6026 C---------------------------------------------------------------------------
6027 double precision function eello5(i,j,k,l,jj,kk)
6028 implicit real*8 (a-h,o-z)
6029 include 'DIMENSIONS'
6030 include 'DIMENSIONS.ZSCOPT'
6031 include 'COMMON.IOUNITS'
6032 include 'COMMON.CHAIN'
6033 include 'COMMON.DERIV'
6034 include 'COMMON.INTERACT'
6035 include 'COMMON.CONTACTS'
6036 include 'COMMON.TORSION'
6037 include 'COMMON.VAR'
6038 include 'COMMON.GEO'
6039 double precision pizda(2,2),auxmat(2,2),auxmat1(2,2),vv(2)
6040 double precision ggg1(3),ggg2(3)
6041 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
6046 C /l\ / \ \ / \ / \ / C
6047 C / \ / \ \ / \ / \ / C
6048 C j| o |l1 | o | o| o | | o |o C
6049 C \ |/k\| |/ \| / |/ \| |/ \| C
6050 C \i/ \ / \ / / \ / \ C
6052 C (I) (II) (III) (IV) C
6054 C eello5_1 eello5_2 eello5_3 eello5_4 C
6056 C Antiparallel chains C
6059 C /j\ / \ \ / \ / \ / C
6060 C / \ / \ \ / \ / \ / C
6061 C j1| o |l | o | o| o | | o |o C
6062 C \ |/k\| |/ \| / |/ \| |/ \| C
6063 C \i/ \ / \ / / \ / \ C
6065 C (I) (II) (III) (IV) C
6067 C eello5_1 eello5_2 eello5_3 eello5_4 C
6069 C o denotes a local interaction, vertical lines an electrostatic interaction. C
6071 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
6072 cd if (i.ne.2 .or. j.ne.6 .or. k.ne.3 .or. l.ne.5) then
6077 cd & 'EELLO5: Contacts have occurred for peptide groups',i,j,
6079 itk=itortyp(itype(k))
6080 itl=itortyp(itype(l))
6081 itj=itortyp(itype(j))
6086 cd call checkint5(i,j,k,l,jj,kk,eel5_1_num,eel5_2_num,
6087 cd & eel5_3_num,eel5_4_num)
6091 derx(lll,kkk,iii)=0.0d0
6095 cd eij=facont_hb(jj,i)
6096 cd ekl=facont_hb(kk,k)
6098 cd write (iout,*)'Contacts have occurred for peptide groups',
6099 cd & i,j,' fcont:',eij,' eij',' and ',k,l
6101 C Contribution from the graph I.
6102 cd write (2,*) 'AEA ',AEA(1,1,1),AEA(2,1,1),AEA(1,2,1),AEA(2,2,1)
6103 cd write (2,*) 'AEAb2',AEAb2(1,1,1),AEAb2(2,1,1)
6104 call transpose2(EUg(1,1,k),auxmat(1,1))
6105 call matmat2(AEA(1,1,1),auxmat(1,1),pizda(1,1))
6106 vv(1)=pizda(1,1)-pizda(2,2)
6107 vv(2)=pizda(1,2)+pizda(2,1)
6108 eello5_1=scalar2(AEAb2(1,1,1),Ub2(1,k))
6109 & +0.5d0*scalar2(vv(1),Dtobr2(1,i))
6111 C Explicit gradient in virtual-dihedral angles.
6112 if (i.gt.1) g_corr5_loc(i-1)=g_corr5_loc(i-1)
6113 & +ekont*(scalar2(AEAb2derg(1,2,1,1),Ub2(1,k))
6114 & +0.5d0*scalar2(vv(1),Dtobr2der(1,i)))
6115 call transpose2(EUgder(1,1,k),auxmat1(1,1))
6116 call matmat2(AEA(1,1,1),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(k-1)=g_corr5_loc(k-1)
6120 & +ekont*(scalar2(AEAb2(1,1,1),Ub2der(1,k))
6121 & +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
6122 call matmat2(AEAderg(1,1,1),auxmat(1,1),pizda(1,1))
6123 vv(1)=pizda(1,1)-pizda(2,2)
6124 vv(2)=pizda(1,2)+pizda(2,1)
6126 if (l.lt.nres-1) g_corr5_loc(l-1)=g_corr5_loc(l-1)
6127 & +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k))
6128 & +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
6130 if (j.lt.nres-1) g_corr5_loc(j-1)=g_corr5_loc(j-1)
6131 & +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k))
6132 & +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
6134 C Cartesian gradient
6138 call matmat2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1),
6140 vv(1)=pizda(1,1)-pizda(2,2)
6141 vv(2)=pizda(1,2)+pizda(2,1)
6142 derx(lll,kkk,iii)=derx(lll,kkk,iii)
6143 & +scalar2(AEAb2derx(1,lll,kkk,iii,1,1),Ub2(1,k))
6144 & +0.5d0*scalar2(vv(1),Dtobr2(1,i))
6151 C Contribution from graph II
6152 call transpose2(EE(1,1,itk),auxmat(1,1))
6153 call matmat2(auxmat(1,1),AEA(1,1,1),pizda(1,1))
6154 vv(1)=pizda(1,1)+pizda(2,2)
6155 vv(2)=pizda(2,1)-pizda(1,2)
6156 eello5_2=scalar2(AEAb1(1,2,1),b1(1,itk))
6157 & -0.5d0*scalar2(vv(1),Ctobr(1,k))
6159 C Explicit gradient in virtual-dihedral angles.
6160 g_corr5_loc(k-1)=g_corr5_loc(k-1)
6161 & -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,k))
6162 call matmat2(auxmat(1,1),AEAderg(1,1,1),pizda(1,1))
6163 vv(1)=pizda(1,1)+pizda(2,2)
6164 vv(2)=pizda(2,1)-pizda(1,2)
6166 g_corr5_loc(l-1)=g_corr5_loc(l-1)
6167 & +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,itk))
6168 & -0.5d0*scalar2(vv(1),Ctobr(1,k)))
6170 g_corr5_loc(j-1)=g_corr5_loc(j-1)
6171 & +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,itk))
6172 & -0.5d0*scalar2(vv(1),Ctobr(1,k)))
6174 C Cartesian gradient
6178 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),
6180 vv(1)=pizda(1,1)+pizda(2,2)
6181 vv(2)=pizda(2,1)-pizda(1,2)
6182 derx(lll,kkk,iii)=derx(lll,kkk,iii)
6183 & +scalar2(AEAb1derx(1,lll,kkk,iii,2,1),b1(1,itk))
6184 & -0.5d0*scalar2(vv(1),Ctobr(1,k))
6193 C Parallel orientation
6194 C Contribution from graph III
6195 call transpose2(EUg(1,1,l),auxmat(1,1))
6196 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
6197 vv(1)=pizda(1,1)-pizda(2,2)
6198 vv(2)=pizda(1,2)+pizda(2,1)
6199 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,l))
6200 & +0.5d0*scalar2(vv(1),Dtobr2(1,j))
6202 C Explicit gradient in virtual-dihedral angles.
6203 g_corr5_loc(j-1)=g_corr5_loc(j-1)
6204 & +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,l))
6205 & +0.5d0*scalar2(vv(1),Dtobr2der(1,j)))
6206 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
6207 vv(1)=pizda(1,1)-pizda(2,2)
6208 vv(2)=pizda(1,2)+pizda(2,1)
6209 g_corr5_loc(k-1)=g_corr5_loc(k-1)
6210 & +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,l))
6211 & +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
6212 call transpose2(EUgder(1,1,l),auxmat1(1,1))
6213 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
6214 vv(1)=pizda(1,1)-pizda(2,2)
6215 vv(2)=pizda(1,2)+pizda(2,1)
6216 g_corr5_loc(l-1)=g_corr5_loc(l-1)
6217 & +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,l))
6218 & +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
6219 C Cartesian gradient
6223 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),
6225 vv(1)=pizda(1,1)-pizda(2,2)
6226 vv(2)=pizda(1,2)+pizda(2,1)
6227 derx(lll,kkk,iii)=derx(lll,kkk,iii)
6228 & +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,l))
6229 & +0.5d0*scalar2(vv(1),Dtobr2(1,j))
6235 C Contribution from graph IV
6237 call transpose2(EE(1,1,itl),auxmat(1,1))
6238 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
6239 vv(1)=pizda(1,1)+pizda(2,2)
6240 vv(2)=pizda(2,1)-pizda(1,2)
6241 eello5_4=scalar2(AEAb1(1,2,2),b1(1,itl))
6242 & -0.5d0*scalar2(vv(1),Ctobr(1,l))
6244 C Explicit gradient in virtual-dihedral angles.
6245 g_corr5_loc(l-1)=g_corr5_loc(l-1)
6246 & -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,l))
6247 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
6248 vv(1)=pizda(1,1)+pizda(2,2)
6249 vv(2)=pizda(2,1)-pizda(1,2)
6250 g_corr5_loc(k-1)=g_corr5_loc(k-1)
6251 & +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,itl))
6252 & -0.5d0*scalar2(vv(1),Ctobr(1,l)))
6253 C Cartesian gradient
6257 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
6259 vv(1)=pizda(1,1)+pizda(2,2)
6260 vv(2)=pizda(2,1)-pizda(1,2)
6261 derx(lll,kkk,iii)=derx(lll,kkk,iii)
6262 & +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,itl))
6263 & -0.5d0*scalar2(vv(1),Ctobr(1,l))
6269 C Antiparallel orientation
6270 C Contribution from graph III
6272 call transpose2(EUg(1,1,j),auxmat(1,1))
6273 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
6274 vv(1)=pizda(1,1)-pizda(2,2)
6275 vv(2)=pizda(1,2)+pizda(2,1)
6276 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,j))
6277 & +0.5d0*scalar2(vv(1),Dtobr2(1,l))
6279 C Explicit gradient in virtual-dihedral angles.
6280 g_corr5_loc(l-1)=g_corr5_loc(l-1)
6281 & +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,j))
6282 & +0.5d0*scalar2(vv(1),Dtobr2der(1,l)))
6283 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
6284 vv(1)=pizda(1,1)-pizda(2,2)
6285 vv(2)=pizda(1,2)+pizda(2,1)
6286 g_corr5_loc(k-1)=g_corr5_loc(k-1)
6287 & +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,j))
6288 & +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
6289 call transpose2(EUgder(1,1,j),auxmat1(1,1))
6290 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
6291 vv(1)=pizda(1,1)-pizda(2,2)
6292 vv(2)=pizda(1,2)+pizda(2,1)
6293 g_corr5_loc(j-1)=g_corr5_loc(j-1)
6294 & +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,j))
6295 & +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
6296 C Cartesian gradient
6300 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),
6302 vv(1)=pizda(1,1)-pizda(2,2)
6303 vv(2)=pizda(1,2)+pizda(2,1)
6304 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)
6305 & +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,j))
6306 & +0.5d0*scalar2(vv(1),Dtobr2(1,l))
6312 C Contribution from graph IV
6314 call transpose2(EE(1,1,itj),auxmat(1,1))
6315 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
6316 vv(1)=pizda(1,1)+pizda(2,2)
6317 vv(2)=pizda(2,1)-pizda(1,2)
6318 eello5_4=scalar2(AEAb1(1,2,2),b1(1,itj))
6319 & -0.5d0*scalar2(vv(1),Ctobr(1,j))
6321 C Explicit gradient in virtual-dihedral angles.
6322 g_corr5_loc(j-1)=g_corr5_loc(j-1)
6323 & -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,j))
6324 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
6325 vv(1)=pizda(1,1)+pizda(2,2)
6326 vv(2)=pizda(2,1)-pizda(1,2)
6327 g_corr5_loc(k-1)=g_corr5_loc(k-1)
6328 & +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,itj))
6329 & -0.5d0*scalar2(vv(1),Ctobr(1,j)))
6330 C Cartesian gradient
6334 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
6336 vv(1)=pizda(1,1)+pizda(2,2)
6337 vv(2)=pizda(2,1)-pizda(1,2)
6338 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)
6339 & +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,itj))
6340 & -0.5d0*scalar2(vv(1),Ctobr(1,j))
6347 eel5=eello5_1+eello5_2+eello5_3+eello5_4
6348 cd if (i.eq.2 .and. j.eq.8 .and. k.eq.3 .and. l.eq.7) then
6349 cd write (2,*) 'ijkl',i,j,k,l
6350 cd write (2,*) 'eello5_1',eello5_1,' eello5_2',eello5_2,
6351 cd & ' eello5_3',eello5_3,' eello5_4',eello5_4
6353 cd write(iout,*) 'eello5_1',eello5_1,' eel5_1_num',16*eel5_1_num
6354 cd write(iout,*) 'eello5_2',eello5_2,' eel5_2_num',16*eel5_2_num
6355 cd write(iout,*) 'eello5_3',eello5_3,' eel5_3_num',16*eel5_3_num
6356 cd write(iout,*) 'eello5_4',eello5_4,' eel5_4_num',16*eel5_4_num
6358 if (j.lt.nres-1) then
6365 if (l.lt.nres-1) then
6375 cd write (2,*) 'eij',eij,' ekl',ekl,' ekont',ekont
6377 ggg1(ll)=eel5*g_contij(ll,1)
6378 ggg2(ll)=eel5*g_contij(ll,2)
6379 cold ghalf=0.5d0*eel5*ekl*gacont_hbr(ll,jj,i)
6380 ghalf=0.5d0*ggg1(ll)
6382 gradcorr5(ll,i)=gradcorr5(ll,i)+ghalf+ekont*derx(ll,2,1)
6383 gradcorr5(ll,i+1)=gradcorr5(ll,i+1)+ekont*derx(ll,3,1)
6384 gradcorr5(ll,j)=gradcorr5(ll,j)+ghalf+ekont*derx(ll,4,1)
6385 gradcorr5(ll,j1)=gradcorr5(ll,j1)+ekont*derx(ll,5,1)
6386 cold ghalf=0.5d0*eel5*eij*gacont_hbr(ll,kk,k)
6387 ghalf=0.5d0*ggg2(ll)
6389 gradcorr5(ll,k)=gradcorr5(ll,k)+ghalf+ekont*derx(ll,2,2)
6390 gradcorr5(ll,k+1)=gradcorr5(ll,k+1)+ekont*derx(ll,3,2)
6391 gradcorr5(ll,l)=gradcorr5(ll,l)+ghalf+ekont*derx(ll,4,2)
6392 gradcorr5(ll,l1)=gradcorr5(ll,l1)+ekont*derx(ll,5,2)
6397 cold gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*ekl*gacont_hbr(ll,jj,i)
6398 gradcorr5(ll,m)=gradcorr5(ll,m)+ggg1(ll)
6403 cold gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*eij*gacont_hbr(ll,kk,k)
6404 gradcorr5(ll,m)=gradcorr5(ll,m)+ggg2(ll)
6410 gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,1)
6415 gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,2)
6419 cd write (2,*) iii,g_corr5_loc(iii)
6423 cd write (2,*) 'ekont',ekont
6424 cd write (iout,*) 'eello5',ekont*eel5
6427 c--------------------------------------------------------------------------
6428 double precision function eello6(i,j,k,l,jj,kk)
6429 implicit real*8 (a-h,o-z)
6430 include 'DIMENSIONS'
6431 include 'DIMENSIONS.ZSCOPT'
6432 include 'COMMON.IOUNITS'
6433 include 'COMMON.CHAIN'
6434 include 'COMMON.DERIV'
6435 include 'COMMON.INTERACT'
6436 include 'COMMON.CONTACTS'
6437 include 'COMMON.TORSION'
6438 include 'COMMON.VAR'
6439 include 'COMMON.GEO'
6440 include 'COMMON.FFIELD'
6441 double precision ggg1(3),ggg2(3)
6442 cd if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
6447 cd & 'EELLO6: Contacts have occurred for peptide groups',i,j,
6455 cd call checkint6(i,j,k,l,jj,kk,eel6_1_num,eel6_2_num,
6456 cd & eel6_3_num,eel6_4_num,eel6_5_num,eel6_6_num)
6460 derx(lll,kkk,iii)=0.0d0
6464 cd eij=facont_hb(jj,i)
6465 cd ekl=facont_hb(kk,k)
6471 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
6472 eello6_2=eello6_graph1(j,i,l,k,2,.false.)
6473 eello6_3=eello6_graph2(i,j,k,l,jj,kk,.false.)
6474 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
6475 eello6_5=eello6_graph4(j,i,l,k,jj,kk,2,.false.)
6476 eello6_6=eello6_graph3(i,j,k,l,jj,kk,.false.)
6478 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
6479 eello6_2=eello6_graph1(l,k,j,i,2,.true.)
6480 eello6_3=eello6_graph2(i,l,k,j,jj,kk,.true.)
6481 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
6482 if (wturn6.eq.0.0d0 .or. j.ne.i+4) then
6483 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
6487 eello6_6=eello6_graph3(i,l,k,j,jj,kk,.true.)
6489 C If turn contributions are considered, they will be handled separately.
6490 eel6=eello6_1+eello6_2+eello6_3+eello6_4+eello6_5+eello6_6
6491 cd write(iout,*) 'eello6_1',eello6_1,' eel6_1_num',16*eel6_1_num
6492 cd write(iout,*) 'eello6_2',eello6_2,' eel6_2_num',16*eel6_2_num
6493 cd write(iout,*) 'eello6_3',eello6_3,' eel6_3_num',16*eel6_3_num
6494 cd write(iout,*) 'eello6_4',eello6_4,' eel6_4_num',16*eel6_4_num
6495 cd write(iout,*) 'eello6_5',eello6_5,' eel6_5_num',16*eel6_5_num
6496 cd write(iout,*) 'eello6_6',eello6_6,' eel6_6_num',16*eel6_6_num
6499 if (j.lt.nres-1) then
6506 if (l.lt.nres-1) then
6514 ggg1(ll)=eel6*g_contij(ll,1)
6515 ggg2(ll)=eel6*g_contij(ll,2)
6516 cold ghalf=0.5d0*eel6*ekl*gacont_hbr(ll,jj,i)
6517 ghalf=0.5d0*ggg1(ll)
6519 gradcorr6(ll,i)=gradcorr6(ll,i)+ghalf+ekont*derx(ll,2,1)
6520 gradcorr6(ll,i+1)=gradcorr6(ll,i+1)+ekont*derx(ll,3,1)
6521 gradcorr6(ll,j)=gradcorr6(ll,j)+ghalf+ekont*derx(ll,4,1)
6522 gradcorr6(ll,j1)=gradcorr6(ll,j1)+ekont*derx(ll,5,1)
6523 ghalf=0.5d0*ggg2(ll)
6524 cold ghalf=0.5d0*eel6*eij*gacont_hbr(ll,kk,k)
6526 gradcorr6(ll,k)=gradcorr6(ll,k)+ghalf+ekont*derx(ll,2,2)
6527 gradcorr6(ll,k+1)=gradcorr6(ll,k+1)+ekont*derx(ll,3,2)
6528 gradcorr6(ll,l)=gradcorr6(ll,l)+ghalf+ekont*derx(ll,4,2)
6529 gradcorr6(ll,l1)=gradcorr6(ll,l1)+ekont*derx(ll,5,2)
6534 cold gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*ekl*gacont_hbr(ll,jj,i)
6535 gradcorr6(ll,m)=gradcorr6(ll,m)+ggg1(ll)
6540 cold gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*eij*gacont_hbr(ll,kk,k)
6541 gradcorr6(ll,m)=gradcorr6(ll,m)+ggg2(ll)
6547 gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,1)
6552 gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,2)
6556 cd write (2,*) iii,g_corr6_loc(iii)
6560 cd write (2,*) 'ekont',ekont
6561 cd write (iout,*) 'eello6',ekont*eel6
6564 c--------------------------------------------------------------------------
6565 double precision function eello6_graph1(i,j,k,l,imat,swap)
6566 implicit real*8 (a-h,o-z)
6567 include 'DIMENSIONS'
6568 include 'DIMENSIONS.ZSCOPT'
6569 include 'COMMON.IOUNITS'
6570 include 'COMMON.CHAIN'
6571 include 'COMMON.DERIV'
6572 include 'COMMON.INTERACT'
6573 include 'COMMON.CONTACTS'
6574 include 'COMMON.TORSION'
6575 include 'COMMON.VAR'
6576 include 'COMMON.GEO'
6577 double precision vv(2),vv1(2),pizda(2,2),auxmat(2,2),pizda1(2,2)
6581 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
6583 C Parallel Antiparallel C
6589 C \ j|/k\| / \ |/k\|l / C
6594 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
6595 itk=itortyp(itype(k))
6596 s1= scalar2(AEAb1(1,2,imat),CUgb2(1,i))
6597 s2=-scalar2(AEAb2(1,1,imat),Ug2Db1t(1,k))
6598 s3= scalar2(AEAb2(1,1,imat),CUgb2(1,k))
6599 call transpose2(EUgC(1,1,k),auxmat(1,1))
6600 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
6601 vv1(1)=pizda1(1,1)-pizda1(2,2)
6602 vv1(2)=pizda1(1,2)+pizda1(2,1)
6603 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
6604 vv(1)=AEAb1(1,2,imat)*b1(1,itk)-AEAb1(2,2,imat)*b1(2,itk)
6605 vv(2)=AEAb1(1,2,imat)*b1(2,itk)+AEAb1(2,2,imat)*b1(1,itk)
6606 s5=scalar2(vv(1),Dtobr2(1,i))
6607 cd write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4', s4,' s5',s5
6608 eello6_graph1=-0.5d0*(s1+s2+s3+s4+s5)
6609 if (.not. calc_grad) return
6610 if (i.gt.1) g_corr6_loc(i-1)=g_corr6_loc(i-1)
6611 & -0.5d0*ekont*(scalar2(AEAb1(1,2,imat),CUgb2der(1,i))
6612 & -scalar2(AEAb2derg(1,2,1,imat),Ug2Db1t(1,k))
6613 & +scalar2(AEAb2derg(1,2,1,imat),CUgb2(1,k))
6614 & +0.5d0*scalar2(vv1(1),Dtobr2der(1,i))
6615 & +scalar2(vv(1),Dtobr2der(1,i)))
6616 call matmat2(AEAderg(1,1,imat),auxmat(1,1),pizda1(1,1))
6617 vv1(1)=pizda1(1,1)-pizda1(2,2)
6618 vv1(2)=pizda1(1,2)+pizda1(2,1)
6619 vv(1)=AEAb1derg(1,2,imat)*b1(1,itk)-AEAb1derg(2,2,imat)*b1(2,itk)
6620 vv(2)=AEAb1derg(1,2,imat)*b1(2,itk)+AEAb1derg(2,2,imat)*b1(1,itk)
6622 g_corr6_loc(l-1)=g_corr6_loc(l-1)
6623 & +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i))
6624 & -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k))
6625 & +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k))
6626 & +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
6628 g_corr6_loc(j-1)=g_corr6_loc(j-1)
6629 & +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i))
6630 & -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k))
6631 & +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k))
6632 & +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
6634 call transpose2(EUgCder(1,1,k),auxmat(1,1))
6635 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
6636 vv1(1)=pizda1(1,1)-pizda1(2,2)
6637 vv1(2)=pizda1(1,2)+pizda1(2,1)
6638 if (k.gt.1) g_corr6_loc(k-1)=g_corr6_loc(k-1)
6639 & +ekont*(-0.5d0*(-scalar2(AEAb2(1,1,imat),Ug2Db1tder(1,k))
6640 & +scalar2(AEAb2(1,1,imat),CUgb2der(1,k))
6641 & +0.5d0*scalar2(vv1(1),Dtobr2(1,i))))
6650 s1= scalar2(AEAb1derx(1,lll,kkk,iii,2,imat),CUgb2(1,i))
6651 s2=-scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),Ug2Db1t(1,k))
6652 s3= scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),CUgb2(1,k))
6653 call transpose2(EUgC(1,1,k),auxmat(1,1))
6654 call matmat2(AEAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),
6656 vv1(1)=pizda1(1,1)-pizda1(2,2)
6657 vv1(2)=pizda1(1,2)+pizda1(2,1)
6658 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
6659 vv(1)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(1,itk)
6660 & -AEAb1derx(2,lll,kkk,iii,2,imat)*b1(2,itk)
6661 vv(2)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(2,itk)
6662 & +AEAb1derx(2,lll,kkk,iii,2,imat)*b1(1,itk)
6663 s5=scalar2(vv(1),Dtobr2(1,i))
6664 derx(lll,kkk,ind)=derx(lll,kkk,ind)-0.5d0*(s1+s2+s3+s4+s5)
6670 c----------------------------------------------------------------------------
6671 double precision function eello6_graph2(i,j,k,l,jj,kk,swap)
6672 implicit real*8 (a-h,o-z)
6673 include 'DIMENSIONS'
6674 include 'DIMENSIONS.ZSCOPT'
6675 include 'COMMON.IOUNITS'
6676 include 'COMMON.CHAIN'
6677 include 'COMMON.DERIV'
6678 include 'COMMON.INTERACT'
6679 include 'COMMON.CONTACTS'
6680 include 'COMMON.TORSION'
6681 include 'COMMON.VAR'
6682 include 'COMMON.GEO'
6684 double precision vv(2),pizda(2,2),auxmat(2,2),auxvec(2),
6685 & auxvec1(2),auxvec2(2),auxmat1(2,2)
6688 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
6690 C Parallel Antiparallel C
6696 C \ j|/k\| \ |/k\|l C
6701 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
6702 cd write (2,*) 'eello6_graph2: i,',i,' j',j,' k',k,' l',l
6703 C AL 7/4/01 s1 would occur in the sixth-order moment,
6704 C but not in a cluster cumulant
6706 s1=dip(1,jj,i)*dip(1,kk,k)
6708 call matvec2(ADtEA1(1,1,1),Ub2(1,k),auxvec(1))
6709 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
6710 call matvec2(ADtEA(1,1,2),Ub2(1,l),auxvec1(1))
6711 s3=-0.5d0*scalar2(Ub2(1,j),auxvec1(1))
6712 call transpose2(EUg(1,1,k),auxmat(1,1))
6713 call matmat2(ADtEA1(1,1,1),auxmat(1,1),pizda(1,1))
6714 vv(1)=pizda(1,1)-pizda(2,2)
6715 vv(2)=pizda(1,2)+pizda(2,1)
6716 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
6717 cd write (2,*) 'eello6_graph2:','s1',s1,' s2',s2,' s3',s3,' s4',s4
6719 eello6_graph2=-(s1+s2+s3+s4)
6721 eello6_graph2=-(s2+s3+s4)
6724 if (.not. calc_grad) return
6725 C Derivatives in gamma(i-1)
6728 s1=dipderg(1,jj,i)*dip(1,kk,k)
6730 s2=-0.5d0*scalar2(Ub2der(1,i),auxvec(1))
6731 call matvec2(ADtEAderg(1,1,1,2),Ub2(1,l),auxvec2(1))
6732 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
6733 s4=-0.25d0*scalar2(vv(1),Dtobr2der(1,i))
6735 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
6737 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
6739 c g_corr6_loc(i-1)=g_corr6_loc(i-1)-s3
6741 C Derivatives in gamma(k-1)
6743 s1=dip(1,jj,i)*dipderg(1,kk,k)
6745 call matvec2(ADtEA1(1,1,1),Ub2der(1,k),auxvec2(1))
6746 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
6747 call matvec2(ADtEAderg(1,1,2,2),Ub2(1,l),auxvec2(1))
6748 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
6749 call transpose2(EUgder(1,1,k),auxmat1(1,1))
6750 call matmat2(ADtEA1(1,1,1),auxmat1(1,1),pizda(1,1))
6751 vv(1)=pizda(1,1)-pizda(2,2)
6752 vv(2)=pizda(1,2)+pizda(2,1)
6753 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
6755 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
6757 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
6759 c g_corr6_loc(k-1)=g_corr6_loc(k-1)-s3
6760 C Derivatives in gamma(j-1) or gamma(l-1)
6763 s1=dipderg(3,jj,i)*dip(1,kk,k)
6765 call matvec2(ADtEA1derg(1,1,1,1),Ub2(1,k),auxvec2(1))
6766 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
6767 s3=-0.5d0*scalar2(Ub2der(1,j),auxvec1(1))
6768 call matmat2(ADtEA1derg(1,1,1,1),auxmat(1,1),pizda(1,1))
6769 vv(1)=pizda(1,1)-pizda(2,2)
6770 vv(2)=pizda(1,2)+pizda(2,1)
6771 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
6774 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
6776 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
6779 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s3+s4)
6780 c g_corr6_loc(j-1)=g_corr6_loc(j-1)-s3
6782 C Derivatives in gamma(l-1) or gamma(j-1)
6785 s1=dip(1,jj,i)*dipderg(3,kk,k)
6787 call matvec2(ADtEA1derg(1,1,2,1),Ub2(1,k),auxvec2(1))
6788 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
6789 call matvec2(ADtEA(1,1,2),Ub2der(1,l),auxvec2(1))
6790 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
6791 call matmat2(ADtEA1derg(1,1,2,1),auxmat(1,1),pizda(1,1))
6792 vv(1)=pizda(1,1)-pizda(2,2)
6793 vv(2)=pizda(1,2)+pizda(2,1)
6794 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
6797 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
6799 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
6802 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s3+s4)
6803 c g_corr6_loc(l-1)=g_corr6_loc(l-1)-s3
6805 C Cartesian derivatives.
6807 write (2,*) 'In eello6_graph2'
6809 write (2,*) 'iii=',iii
6811 write (2,*) 'kkk=',kkk
6813 write (2,'(3(2f10.5),5x)')
6814 & ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
6824 s1=dipderx(lll,kkk,1,jj,i)*dip(1,kk,k)
6826 s1=dip(1,jj,i)*dipderx(lll,kkk,1,kk,k)
6829 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,1),Ub2(1,k),
6831 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
6832 call matvec2(ADtEAderx(1,1,lll,kkk,iii,2),Ub2(1,l),
6834 s3=-0.5d0*scalar2(Ub2(1,j),auxvec(1))
6835 call transpose2(EUg(1,1,k),auxmat(1,1))
6836 call matmat2(ADtEA1derx(1,1,lll,kkk,iii,1),auxmat(1,1),
6838 vv(1)=pizda(1,1)-pizda(2,2)
6839 vv(2)=pizda(1,2)+pizda(2,1)
6840 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
6841 cd write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4',s4
6843 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
6845 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
6848 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
6850 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
6857 c----------------------------------------------------------------------------
6858 double precision function eello6_graph3(i,j,k,l,jj,kk,swap)
6859 implicit real*8 (a-h,o-z)
6860 include 'DIMENSIONS'
6861 include 'DIMENSIONS.ZSCOPT'
6862 include 'COMMON.IOUNITS'
6863 include 'COMMON.CHAIN'
6864 include 'COMMON.DERIV'
6865 include 'COMMON.INTERACT'
6866 include 'COMMON.CONTACTS'
6867 include 'COMMON.TORSION'
6868 include 'COMMON.VAR'
6869 include 'COMMON.GEO'
6870 double precision vv(2),pizda(2,2),auxmat(2,2),auxvec(2)
6872 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
6874 C Parallel Antiparallel C
6880 C j|/k\| / |/k\|l / C
6885 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
6887 C 4/7/01 AL Component s1 was removed, because it pertains to the respective
6888 C energy moment and not to the cluster cumulant.
6889 iti=itortyp(itype(i))
6890 if (j.lt.nres-1) then
6891 itj1=itortyp(itype(j+1))
6895 itk=itortyp(itype(k))
6896 itk1=itortyp(itype(k+1))
6897 if (l.lt.nres-1) then
6898 itl1=itortyp(itype(l+1))
6903 s1=dip(4,jj,i)*dip(4,kk,k)
6905 call matvec2(AECA(1,1,1),b1(1,itk1),auxvec(1))
6906 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
6907 call matvec2(AECA(1,1,2),b1(1,itl1),auxvec(1))
6908 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
6909 call transpose2(EE(1,1,itk),auxmat(1,1))
6910 call matmat2(auxmat(1,1),AECA(1,1,1),pizda(1,1))
6911 vv(1)=pizda(1,1)+pizda(2,2)
6912 vv(2)=pizda(2,1)-pizda(1,2)
6913 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
6914 cd write (2,*) 'eello6_graph3:','s1',s1,' s2',s2,' s3',s3,' s4',s4
6916 eello6_graph3=-(s1+s2+s3+s4)
6918 eello6_graph3=-(s2+s3+s4)
6921 if (.not. calc_grad) return
6922 C Derivatives in gamma(k-1)
6923 call matvec2(AECAderg(1,1,2),b1(1,itl1),auxvec(1))
6924 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
6925 s4=-0.25d0*scalar2(vv(1),Ctobrder(1,k))
6926 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s3+s4)
6927 C Derivatives in gamma(l-1)
6928 call matvec2(AECAderg(1,1,1),b1(1,itk1),auxvec(1))
6929 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
6930 call matmat2(auxmat(1,1),AECAderg(1,1,1),pizda(1,1))
6931 vv(1)=pizda(1,1)+pizda(2,2)
6932 vv(2)=pizda(2,1)-pizda(1,2)
6933 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
6934 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
6935 C Cartesian derivatives.
6941 s1=dipderx(lll,kkk,4,jj,i)*dip(4,kk,k)
6943 s1=dip(4,jj,i)*dipderx(lll,kkk,4,kk,k)
6946 call matvec2(AECAderx(1,1,lll,kkk,iii,1),b1(1,itk1),
6948 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
6949 call matvec2(AECAderx(1,1,lll,kkk,iii,2),b1(1,itl1),
6951 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
6952 call matmat2(auxmat(1,1),AECAderx(1,1,lll,kkk,iii,1),
6954 vv(1)=pizda(1,1)+pizda(2,2)
6955 vv(2)=pizda(2,1)-pizda(1,2)
6956 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
6958 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
6960 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
6963 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
6965 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
6967 c derx(lll,kkk,iii)=derx(lll,kkk,iii)-s4
6973 c----------------------------------------------------------------------------
6974 double precision function eello6_graph4(i,j,k,l,jj,kk,imat,swap)
6975 implicit real*8 (a-h,o-z)
6976 include 'DIMENSIONS'
6977 include 'DIMENSIONS.ZSCOPT'
6978 include 'COMMON.IOUNITS'
6979 include 'COMMON.CHAIN'
6980 include 'COMMON.DERIV'
6981 include 'COMMON.INTERACT'
6982 include 'COMMON.CONTACTS'
6983 include 'COMMON.TORSION'
6984 include 'COMMON.VAR'
6985 include 'COMMON.GEO'
6986 include 'COMMON.FFIELD'
6987 double precision vv(2),pizda(2,2),auxmat(2,2),auxvec(2),
6988 & auxvec1(2),auxmat1(2,2)
6990 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
6992 C Parallel Antiparallel C
6998 C \ j|/k\| \ |/k\|l C
7003 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
7005 C 4/7/01 AL Component s1 was removed, because it pertains to the respective
7006 C energy moment and not to the cluster cumulant.
7007 cd write (2,*) 'eello_graph4: wturn6',wturn6
7008 iti=itortyp(itype(i))
7009 itj=itortyp(itype(j))
7010 if (j.lt.nres-1) then
7011 itj1=itortyp(itype(j+1))
7015 itk=itortyp(itype(k))
7016 if (k.lt.nres-1) then
7017 itk1=itortyp(itype(k+1))
7021 itl=itortyp(itype(l))
7022 if (l.lt.nres-1) then
7023 itl1=itortyp(itype(l+1))
7027 cd write (2,*) 'eello6_graph4:','i',i,' j',j,' k',k,' l',l
7028 cd write (2,*) 'iti',iti,' itj',itj,' itj1',itj1,' itk',itk,
7029 cd & ' itl',itl,' itl1',itl1
7032 s1=dip(3,jj,i)*dip(3,kk,k)
7034 s1=dip(2,jj,j)*dip(2,kk,l)
7037 call matvec2(AECA(1,1,imat),Ub2(1,k),auxvec(1))
7038 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
7040 call matvec2(ADtEA1(1,1,3-imat),b1(1,itj1),auxvec1(1))
7041 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
7043 call matvec2(ADtEA1(1,1,3-imat),b1(1,itl1),auxvec1(1))
7044 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
7046 call transpose2(EUg(1,1,k),auxmat(1,1))
7047 call matmat2(AECA(1,1,imat),auxmat(1,1),pizda(1,1))
7048 vv(1)=pizda(1,1)-pizda(2,2)
7049 vv(2)=pizda(2,1)+pizda(1,2)
7050 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
7051 cd write (2,*) 'eello6_graph4:','s1',s1,' s2',s2,' s3',s3,' s4',s4
7053 eello6_graph4=-(s1+s2+s3+s4)
7055 eello6_graph4=-(s2+s3+s4)
7057 if (.not. calc_grad) return
7058 C Derivatives in gamma(i-1)
7062 s1=dipderg(2,jj,i)*dip(3,kk,k)
7064 s1=dipderg(4,jj,j)*dip(2,kk,l)
7067 s2=0.5d0*scalar2(Ub2der(1,i),auxvec(1))
7069 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,itj1),auxvec1(1))
7070 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
7072 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,itl1),auxvec1(1))
7073 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
7075 s4=0.25d0*scalar2(vv(1),Dtobr2der(1,i))
7076 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
7077 cd write (2,*) 'turn6 derivatives'
7079 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s1+s2+s3+s4)
7081 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s2+s3+s4)
7085 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
7087 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
7091 C Derivatives in gamma(k-1)
7094 s1=dip(3,jj,i)*dipderg(2,kk,k)
7096 s1=dip(2,jj,j)*dipderg(4,kk,l)
7099 call matvec2(AECA(1,1,imat),Ub2der(1,k),auxvec1(1))
7100 s2=0.5d0*scalar2(Ub2(1,i),auxvec1(1))
7102 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,itj1),auxvec1(1))
7103 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
7105 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,itl1),auxvec1(1))
7106 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
7108 call transpose2(EUgder(1,1,k),auxmat1(1,1))
7109 call matmat2(AECA(1,1,imat),auxmat1(1,1),pizda(1,1))
7110 vv(1)=pizda(1,1)-pizda(2,2)
7111 vv(2)=pizda(2,1)+pizda(1,2)
7112 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
7113 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
7115 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s1+s2+s3+s4)
7117 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s2+s3+s4)
7121 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
7123 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
7126 C Derivatives in gamma(j-1) or gamma(l-1)
7127 if (l.eq.j+1 .and. l.gt.1) then
7128 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
7129 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
7130 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
7131 vv(1)=pizda(1,1)-pizda(2,2)
7132 vv(2)=pizda(2,1)+pizda(1,2)
7133 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
7134 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
7135 else if (j.gt.1) then
7136 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
7137 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
7138 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
7139 vv(1)=pizda(1,1)-pizda(2,2)
7140 vv(2)=pizda(2,1)+pizda(1,2)
7141 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
7142 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
7143 gel_loc_turn6(j-1)=gel_loc_turn6(j-1)-ekont*(s2+s4)
7145 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s4)
7148 C Cartesian derivatives.
7155 s1=dipderx(lll,kkk,3,jj,i)*dip(3,kk,k)
7157 s1=dipderx(lll,kkk,2,jj,j)*dip(2,kk,l)
7161 s1=dip(3,jj,i)*dipderx(lll,kkk,3,kk,k)
7163 s1=dip(2,jj,j)*dipderx(lll,kkk,2,kk,l)
7167 call matvec2(AECAderx(1,1,lll,kkk,iii,imat),Ub2(1,k),
7169 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
7171 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),
7172 & b1(1,itj1),auxvec(1))
7173 s3=-0.5d0*scalar2(b1(1,itj),auxvec(1))
7175 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),
7176 & b1(1,itl1),auxvec(1))
7177 s3=-0.5d0*scalar2(b1(1,itl),auxvec(1))
7179 call matmat2(AECAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),
7181 vv(1)=pizda(1,1)-pizda(2,2)
7182 vv(2)=pizda(2,1)+pizda(1,2)
7183 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
7185 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
7187 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii)
7190 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii)
7193 derx_turn(lll,kkk,iii)=derx_turn(lll,kkk,iii)-s3
7196 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s1+s2+s4)
7198 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s2+s4)
7200 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
7204 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
7206 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
7209 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
7211 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
7219 c----------------------------------------------------------------------------
7220 double precision function eello_turn6(i,jj,kk)
7221 implicit real*8 (a-h,o-z)
7222 include 'DIMENSIONS'
7223 include 'DIMENSIONS.ZSCOPT'
7224 include 'COMMON.IOUNITS'
7225 include 'COMMON.CHAIN'
7226 include 'COMMON.DERIV'
7227 include 'COMMON.INTERACT'
7228 include 'COMMON.CONTACTS'
7229 include 'COMMON.TORSION'
7230 include 'COMMON.VAR'
7231 include 'COMMON.GEO'
7232 double precision vtemp1(2),vtemp2(2),vtemp3(2),vtemp4(2),
7233 & atemp(2,2),auxmat(2,2),achuj_temp(2,2),gtemp(2,2),gvec(2),
7235 double precision vtemp1d(2),vtemp2d(2),vtemp3d(2),vtemp4d(2),
7236 & atempd(2,2),auxmatd(2,2),achuj_tempd(2,2),gtempd(2,2),gvecd(2)
7237 C 4/7/01 AL Components s1, s8, and s13 were removed, because they pertain to
7238 C the respective energy moment and not to the cluster cumulant.
7243 iti=itortyp(itype(i))
7244 itk=itortyp(itype(k))
7245 itk1=itortyp(itype(k+1))
7246 itl=itortyp(itype(l))
7247 itj=itortyp(itype(j))
7248 cd write (2,*) 'itk',itk,' itk1',itk1,' itl',itl,' itj',itj
7249 cd write (2,*) 'i',i,' k',k,' j',j,' l',l
7250 cd if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
7255 cd & 'EELLO6: Contacts have occurred for peptide groups',i,j,
7257 cd call checkint_turn6(i,jj,kk,eel_turn6_num)
7261 derx_turn(lll,kkk,iii)=0.0d0
7268 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
7270 cd write (2,*) 'eello6_5',eello6_5
7272 call transpose2(AEA(1,1,1),auxmat(1,1))
7273 call matmat2(EUg(1,1,i+1),auxmat(1,1),auxmat(1,1))
7274 ss1=scalar2(Ub2(1,i+2),b1(1,itl))
7275 s1 = (auxmat(1,1)+auxmat(2,2))*ss1
7279 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1(1))
7280 call matvec2(AEA(1,1,1),vtemp1(1),vtemp1(1))
7281 s2 = scalar2(b1(1,itk),vtemp1(1))
7283 call transpose2(AEA(1,1,2),atemp(1,1))
7284 call matmat2(atemp(1,1),EUg(1,1,i+4),atemp(1,1))
7285 call matvec2(Ug2(1,1,i+2),dd(1,1,itk1),vtemp2(1))
7286 s8 = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
7290 call matmat2(EUg(1,1,i+3),AEA(1,1,2),auxmat(1,1))
7291 call matvec2(auxmat(1,1),Ub2(1,i+4),vtemp3(1))
7292 s12 = scalar2(Ub2(1,i+2),vtemp3(1))
7294 call transpose2(a_chuj(1,1,kk,i+1),achuj_temp(1,1))
7295 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtemp(1,1))
7296 call matmat2(gtemp(1,1),EUg(1,1,i+3),gtemp(1,1))
7297 call matvec2(a_chuj(1,1,jj,i),Ub2(1,i+4),vtemp4(1))
7298 ss13 = scalar2(b1(1,itk),vtemp4(1))
7299 s13 = (gtemp(1,1)+gtemp(2,2))*ss13
7303 c write (2,*) 's1,s2,s8,s12,s13',s1,s2,s8,s12,s13
7309 eel_turn6 = eello6_5 - 0.5d0*(s1+s2+s12+s8+s13)
7311 C Derivatives in gamma(i+2)
7313 call transpose2(AEA(1,1,1),auxmatd(1,1))
7314 call matmat2(EUgder(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
7315 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
7316 call transpose2(AEAderg(1,1,2),atempd(1,1))
7317 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
7318 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
7322 call matmat2(EUg(1,1,i+3),AEAderg(1,1,2),auxmatd(1,1))
7323 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
7324 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
7330 gel_loc_turn6(i)=gel_loc_turn6(i)-0.5d0*ekont*(s1d+s8d+s12d)
7331 C Derivatives in gamma(i+3)
7333 call transpose2(AEA(1,1,1),auxmatd(1,1))
7334 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
7335 ss1d=scalar2(Ub2der(1,i+2),b1(1,itl))
7336 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1d
7340 call matvec2(EUgder(1,1,i+2),b1(1,itl),vtemp1d(1))
7341 call matvec2(AEA(1,1,1),vtemp1d(1),vtemp1d(1))
7342 s2d = scalar2(b1(1,itk),vtemp1d(1))
7344 call matvec2(Ug2der(1,1,i+2),dd(1,1,itk1),vtemp2d(1))
7345 s8d = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,itl),vtemp2d(1))
7347 s12d = scalar2(Ub2der(1,i+2),vtemp3(1))
7349 call matmat2(achuj_temp(1,1),EUgder(1,1,i+2),gtempd(1,1))
7350 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
7351 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
7361 gel_loc_turn6(i+1)=gel_loc_turn6(i+1)
7362 & -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
7364 gel_loc_turn6(i+1)=gel_loc_turn6(i+1)
7365 & -0.5d0*ekont*(s2d+s12d)
7367 C Derivatives in gamma(i+4)
7368 call matmat2(EUgder(1,1,i+3),AEA(1,1,2),auxmatd(1,1))
7369 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
7370 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
7372 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtempd(1,1))
7373 call matmat2(gtempd(1,1),EUgder(1,1,i+3),gtempd(1,1))
7374 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
7384 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d+s13d)
7386 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d)
7388 C Derivatives in gamma(i+5)
7390 call transpose2(AEAderg(1,1,1),auxmatd(1,1))
7391 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
7392 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
7396 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1d(1))
7397 call matvec2(AEAderg(1,1,1),vtemp1d(1),vtemp1d(1))
7398 s2d = scalar2(b1(1,itk),vtemp1d(1))
7400 call transpose2(AEA(1,1,2),atempd(1,1))
7401 call matmat2(atempd(1,1),EUgder(1,1,i+4),atempd(1,1))
7402 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
7406 call matvec2(auxmat(1,1),Ub2der(1,i+4),vtemp3d(1))
7407 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
7409 call matvec2(a_chuj(1,1,jj,i),Ub2der(1,i+4),vtemp4d(1))
7410 ss13d = scalar2(b1(1,itk),vtemp4d(1))
7411 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
7421 gel_loc_turn6(i+3)=gel_loc_turn6(i+3)
7422 & -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
7424 gel_loc_turn6(i+3)=gel_loc_turn6(i+3)
7425 & -0.5d0*ekont*(s2d+s12d)
7427 C Cartesian derivatives
7432 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmatd(1,1))
7433 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
7434 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
7438 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1(1))
7439 call matvec2(AEAderx(1,1,lll,kkk,iii,1),vtemp1(1),
7441 s2d = scalar2(b1(1,itk),vtemp1d(1))
7443 call transpose2(AEAderx(1,1,lll,kkk,iii,2),atempd(1,1))
7444 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
7445 s8d = -(atempd(1,1)+atempd(2,2))*
7446 & scalar2(cc(1,1,itl),vtemp2(1))
7450 call matmat2(EUg(1,1,i+3),AEAderx(1,1,lll,kkk,iii,2),
7452 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
7453 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
7460 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii)
7463 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii)
7467 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii)
7468 & - 0.5d0*(s8d+s12d)
7470 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii)
7479 call transpose2(a_chuj_der(1,1,lll,kkk,kk,i+1),
7481 call matmat2(achuj_tempd(1,1),EUg(1,1,i+2),gtempd(1,1))
7482 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
7483 s13d=(gtempd(1,1)+gtempd(2,2))*ss13
7484 derx_turn(lll,kkk,2) = derx_turn(lll,kkk,2)-0.5d0*s13d
7485 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),Ub2(1,i+4),
7487 ss13d = scalar2(b1(1,itk),vtemp4d(1))
7488 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
7489 derx_turn(lll,kkk,1) = derx_turn(lll,kkk,1)-0.5d0*s13d
7493 cd write(iout,*) 'eel6_turn6',eel_turn6,' eel_turn6_num',
7494 cd & 16*eel_turn6_num
7496 if (j.lt.nres-1) then
7503 if (l.lt.nres-1) then
7511 ggg1(ll)=eel_turn6*g_contij(ll,1)
7512 ggg2(ll)=eel_turn6*g_contij(ll,2)
7513 ghalf=0.5d0*ggg1(ll)
7515 gcorr6_turn(ll,i)=gcorr6_turn(ll,i)+ghalf
7516 & +ekont*derx_turn(ll,2,1)
7517 gcorr6_turn(ll,i+1)=gcorr6_turn(ll,i+1)+ekont*derx_turn(ll,3,1)
7518 gcorr6_turn(ll,j)=gcorr6_turn(ll,j)+ghalf
7519 & +ekont*derx_turn(ll,4,1)
7520 gcorr6_turn(ll,j1)=gcorr6_turn(ll,j1)+ekont*derx_turn(ll,5,1)
7521 ghalf=0.5d0*ggg2(ll)
7523 gcorr6_turn(ll,k)=gcorr6_turn(ll,k)+ghalf
7524 & +ekont*derx_turn(ll,2,2)
7525 gcorr6_turn(ll,k+1)=gcorr6_turn(ll,k+1)+ekont*derx_turn(ll,3,2)
7526 gcorr6_turn(ll,l)=gcorr6_turn(ll,l)+ghalf
7527 & +ekont*derx_turn(ll,4,2)
7528 gcorr6_turn(ll,l1)=gcorr6_turn(ll,l1)+ekont*derx_turn(ll,5,2)
7533 gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg1(ll)
7538 gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg2(ll)
7544 gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,1)
7549 gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,2)
7553 cd write (2,*) iii,g_corr6_loc(iii)
7556 eello_turn6=ekont*eel_turn6
7557 cd write (2,*) 'ekont',ekont
7558 cd write (2,*) 'eel_turn6',ekont*eel_turn6
7561 crc-------------------------------------------------
7562 SUBROUTINE MATVEC2(A1,V1,V2)
7563 implicit real*8 (a-h,o-z)
7564 include 'DIMENSIONS'
7565 DIMENSION A1(2,2),V1(2),V2(2)
7569 c 3 VI=VI+A1(I,K)*V1(K)
7573 vaux1=a1(1,1)*v1(1)+a1(1,2)*v1(2)
7574 vaux2=a1(2,1)*v1(1)+a1(2,2)*v1(2)
7579 C---------------------------------------
7580 SUBROUTINE MATMAT2(A1,A2,A3)
7581 implicit real*8 (a-h,o-z)
7582 include 'DIMENSIONS'
7583 DIMENSION A1(2,2),A2(2,2),A3(2,2)
7584 c DIMENSION AI3(2,2)
7588 c A3IJ=A3IJ+A1(I,K)*A2(K,J)
7594 ai3_11=a1(1,1)*a2(1,1)+a1(1,2)*a2(2,1)
7595 ai3_12=a1(1,1)*a2(1,2)+a1(1,2)*a2(2,2)
7596 ai3_21=a1(2,1)*a2(1,1)+a1(2,2)*a2(2,1)
7597 ai3_22=a1(2,1)*a2(1,2)+a1(2,2)*a2(2,2)
7605 c-------------------------------------------------------------------------
7606 double precision function scalar2(u,v)
7608 double precision u(2),v(2)
7611 scalar2=u(1)*v(1)+u(2)*v(2)
7615 C-----------------------------------------------------------------------------
7617 subroutine transpose2(a,at)
7619 double precision a(2,2),at(2,2)
7626 c--------------------------------------------------------------------------
7627 subroutine transpose(n,a,at)
7630 double precision a(n,n),at(n,n)
7638 C---------------------------------------------------------------------------
7639 subroutine prodmat3(a1,a2,kk,transp,prod)
7642 double precision a1(2,2),a2(2,2),a2t(2,2),kk(2,2),prod(2,2)
7644 crc double precision auxmat(2,2),prod_(2,2)
7647 crc call transpose2(kk(1,1),auxmat(1,1))
7648 crc call matmat2(a1(1,1),auxmat(1,1),auxmat(1,1))
7649 crc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
7651 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,1)
7652 & +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,1)
7653 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,2)
7654 & +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,2)
7655 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,1)
7656 & +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,1)
7657 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,2)
7658 & +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,2)
7661 crc call matmat2(a1(1,1),kk(1,1),auxmat(1,1))
7662 crc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
7664 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,1)
7665 & +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,1)
7666 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,2)
7667 & +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,2)
7668 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,1)
7669 & +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,1)
7670 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,2)
7671 & +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,2)
7674 c call transpose2(a2(1,1),a2t(1,1))
7677 crc print *,((prod_(i,j),i=1,2),j=1,2)
7678 crc print *,((prod(i,j),i=1,2),j=1,2)
7682 C-----------------------------------------------------------------------------
7683 double precision function scalar(u,v)
7685 double precision u(3),v(3)