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.SHIELD'
26 include 'COMMON.CONTROL'
27 double precision fact(6)
28 cd write(iout, '(a,i2)')'Calling etotal ipot=',ipot
29 cd print *,'nnt=',nnt,' nct=',nct
31 C Compute the side-chain and electrostatic interaction energy
33 goto (101,102,103,104,105) ipot
34 C Lennard-Jones potential.
35 101 call elj(evdw,evdw_t)
36 cd print '(a)','Exit ELJ'
38 C Lennard-Jones-Kihara potential (shifted).
39 102 call eljk(evdw,evdw_t)
41 C Berne-Pechukas potential (dilated LJ, angular dependence).
42 103 call ebp(evdw,evdw_t)
44 C Gay-Berne potential (shifted LJ, angular dependence).
45 104 call egb(evdw,evdw_t)
47 C Gay-Berne-Vorobjev potential (shifted LJ, angular dependence).
48 105 call egbv(evdw,evdw_t)
49 C write(iout,*) 'po elektostatyce'
51 C Calculate electrostatic (H-bonding) energy of the main chain.
54 if (shield_mode.eq.1) then
56 else if (shield_mode.eq.2) then
59 call eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
60 C write(iout,*) 'po eelec'
62 C Calculate excluded-volume interaction energy between peptide groups
65 call escp(evdw2,evdw2_14)
67 c Calculate the bond-stretching energy
71 C write (iout,*) "estr",estr
73 C Calculate the disulfide-bridge and other energy and the contributions
74 C from other distance constraints.
75 cd print *,'Calling EHPB'
77 cd print *,'EHPB exitted succesfully.'
79 C Calculate the virtual-bond-angle energy.
81 C print *,'Bend energy finished.'
82 call ebend(ebe,ethetacnstr)
83 cd print *,'Bend energy finished.'
85 C Calculate the SC local energy.
88 C print *,'SCLOC energy finished.'
90 C Calculate the virtual-bond torsional energy.
92 cd print *,'nterm=',nterm
93 call etor(etors,edihcnstr,fact(1))
95 C 6/23/01 Calculate double-torsional energy
97 call etor_d(etors_d,fact(2))
99 C 21/5/07 Calculate local sicdechain correlation energy
101 call eback_sc_corr(esccor)
103 if (wliptran.gt.0) then
104 call Eliptransfer(eliptran)
108 C 12/1/95 Multi-body terms
112 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0
113 & .or. wturn6.gt.0.0d0) then
114 c print *,"calling multibody_eello"
115 call multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
116 c write (*,*) 'n_corr=',n_corr,' n_corr1=',n_corr1
117 c print *,ecorr,ecorr5,ecorr6,eturn6
124 if (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) then
125 call multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
127 c write (iout,*) "ft(6)",fact(6)," evdw",evdw," evdw_t",evdw_t
129 if (shield_mode.gt.0) then
130 etot=fact(1)*wsc*(evdw+fact(6)*evdw_t)+fact(1)*wscp*evdw2
132 & +fact(1)*wvdwpp*evdw1
133 & +wang*ebe+wtor*fact(1)*etors+wscloc*escloc
134 & +wstrain*ehpb+wcorr*fact(3)*ecorr+wcorr5*fact(4)*ecorr5
135 & +wcorr6*fact(5)*ecorr6+wturn4*fact(3)*eello_turn4
136 & +wturn3*fact(2)*eello_turn3+wturn6*fact(5)*eturn6
137 & +wel_loc*fact(2)*eel_loc+edihcnstr+wtor_d*fact(2)*etors_d
138 & +wbond*estr+wsccor*fact(1)*esccor+ethetacnstr
141 etot=wsc*(evdw+fact(6)*evdw_t)+wscp*evdw2+welec*fact(1)*ees
143 & +wang*ebe+wtor*fact(1)*etors+wscloc*escloc
144 & +wstrain*ehpb+wcorr*fact(3)*ecorr+wcorr5*fact(4)*ecorr5
145 & +wcorr6*fact(5)*ecorr6+wturn4*fact(3)*eello_turn4
146 & +wturn3*fact(2)*eello_turn3+wturn6*fact(5)*eturn6
147 & +wel_loc*fact(2)*eel_loc+edihcnstr+wtor_d*fact(2)*etors_d
148 & +wbond*estr+wsccor*fact(1)*esccor+ethetacnstr
152 if (shield_mode.gt.0) then
153 etot=fact(1)wsc*(evdw+fact(6)*evdw_t)+fact(1)*wscp*evdw2
154 & +welec*fact(1)*(ees+evdw1)
155 & +wang*ebe+wtor*fact(1)*etors+wscloc*escloc
156 & +wstrain*ehpb+wcorr*fact(3)*ecorr+wcorr5*fact(4)*ecorr5
157 & +wcorr6*fact(5)*ecorr6+wturn4*fact(3)*eello_turn4
158 & +wturn3*fact(2)*eello_turn3+wturn6*fact(5)*eturn6
159 & +wel_loc*fact(2)*eel_loc+edihcnstr+wtor_d*fact(2)*etors_d
160 & +wbond*estr+wsccor*fact(1)*esccor+ethetacnstr
163 etot=wsc*(evdw+fact(6)*evdw_t)+wscp*evdw2
164 & +welec*fact(1)*(ees+evdw1)
165 & +wang*ebe+wtor*fact(1)*etors+wscloc*escloc
166 & +wstrain*ehpb+wcorr*fact(3)*ecorr+wcorr5*fact(4)*ecorr5
167 & +wcorr6*fact(5)*ecorr6+wturn4*fact(3)*eello_turn4
168 & +wturn3*fact(2)*eello_turn3+wturn6*fact(5)*eturn6
169 & +wel_loc*fact(2)*eel_loc+edihcnstr+wtor_d*fact(2)*etors_d
170 & +wbond*estr+wsccor*fact(1)*esccor+ethetacnstr
177 energia(2)=evdw2-evdw2_14
194 energia(8)=eello_turn3
195 energia(9)=eello_turn4
204 energia(20)=edihcnstr
206 energia(24)=ethetacnstr
211 if (isnan(etot).ne.0) energia(0)=1.0d+99
213 if (isnan(etot)) energia(0)=1.0d+99
218 idumm=proc_proc(etot,i)
220 call proc_proc(etot,i)
222 if(i.eq.1)energia(0)=1.0d+99
229 call enerprint(energia,fact)
234 C Sum up the components of the Cartesian gradient.
239 if (shield_mode.eq.0) then
240 gradc(j,i,icg)=wsc*gvdwc(j,i)+wscp*gvdwc_scp(j,i)+
241 & welec*fact(1)*gelc(j,i)+wvdwpp*gvdwpp(j,i)+
243 & wstrain*ghpbc(j,i)+
244 & wcorr*fact(3)*gradcorr(j,i)+
245 & wel_loc*fact(2)*gel_loc(j,i)+
246 & wturn3*fact(2)*gcorr3_turn(j,i)+
247 & wturn4*fact(3)*gcorr4_turn(j,i)+
248 & wcorr5*fact(4)*gradcorr5(j,i)+
249 & wcorr6*fact(5)*gradcorr6(j,i)+
250 & wturn6*fact(5)*gcorr6_turn(j,i)+
251 & wsccor*fact(2)*gsccorc(j,i)
252 & +wliptran*gliptranc(j,i)
253 gradx(j,i,icg)=wsc*gvdwx(j,i)+wscp*gradx_scp(j,i)+
255 & wstrain*ghpbx(j,i)+wcorr*gradxorr(j,i)+
256 & wsccor*fact(2)*gsccorx(j,i)
257 & +wliptran*gliptranx(j,i)
259 gradc(j,i,icg)=fact(1)*wsc*gvdwc(j,i)
260 & +fact(1)*wscp*gvdwc_scp(j,i)+
261 & welec*fact(1)*gelc(j,i)+fact(1)*wvdwpp*gvdwpp(j,i)+
263 & wstrain*ghpbc(j,i)+
264 & wcorr*fact(3)*gradcorr(j,i)+
265 & wel_loc*fact(2)*gel_loc(j,i)+
266 & wturn3*fact(2)*gcorr3_turn(j,i)+
267 & wturn4*fact(3)*gcorr4_turn(j,i)+
268 & wcorr5*fact(4)*gradcorr5(j,i)+
269 & wcorr6*fact(5)*gradcorr6(j,i)+
270 & wturn6*fact(5)*gcorr6_turn(j,i)+
271 & wsccor*fact(2)*gsccorc(j,i)
272 & +wliptran*gliptranc(j,i)
273 & +welec*gshieldc(j,i)
274 & +welec*gshieldc_loc(j,i)
275 & +wcorr*gshieldc_ec(j,i)
276 & +wcorr*gshieldc_loc_ec(j,i)
277 & +wturn3*gshieldc_t3(j,i)
278 & +wturn3*gshieldc_loc_t3(j,i)
279 & +wturn4*gshieldc_t4(j,i)
280 & +wturn4*gshieldc_loc_t4(j,i)
281 & +wel_loc*gshieldc_ll(j,i)
282 & +wel_loc*gshieldc_loc_ll(j,i)
284 gradx(j,i,icg)=fact(1)*wsc*gvdwx(j,i)
285 & +fact(1)*wscp*gradx_scp(j,i)+
287 & wstrain*ghpbx(j,i)+wcorr*gradxorr(j,i)+
288 & wsccor*fact(2)*gsccorx(j,i)
289 & +wliptran*gliptranx(j,i)
290 & +welec*gshieldx(j,i)
291 & +wcorr*gshieldx_ec(j,i)
292 & +wturn3*gshieldx_t3(j,i)
293 & +wturn4*gshieldx_t4(j,i)
294 & +wel_loc*gshieldx_ll(j,i)
302 if (shield_mode.eq.0) then
303 gradc(j,i,icg)=wsc*gvdwc(j,i)+wscp*gvdwc_scp(j,i)+
304 & welec*fact(1)*gelc(j,i)+wstrain*ghpbc(j,i)+
306 & wcorr*fact(3)*gradcorr(j,i)+
307 & wel_loc*fact(2)*gel_loc(j,i)+
308 & wturn3*fact(2)*gcorr3_turn(j,i)+
309 & wturn4*fact(3)*gcorr4_turn(j,i)+
310 & wcorr5*fact(4)*gradcorr5(j,i)+
311 & wcorr6*fact(5)*gradcorr6(j,i)+
312 & wturn6*fact(5)*gcorr6_turn(j,i)+
313 & wsccor*fact(2)*gsccorc(j,i)
314 & +wliptran*gliptranc(j,i)
315 gradx(j,i,icg)=wsc*gvdwx(j,i)+wscp*gradx_scp(j,i)+
317 & wstrain*ghpbx(j,i)+wcorr*gradxorr(j,i)+
318 & wsccor*fact(1)*gsccorx(j,i)
319 & +wliptran*gliptranx(j,i)
321 gradc(j,i,icg)=fact(1)*wsc*gvdwc(j,i)+
322 & fact(1)*wscp*gvdwc_scp(j,i)+
323 & welec*fact(1)*gelc(j,i)+wstrain*ghpbc(j,i)+
325 & wcorr*fact(3)*gradcorr(j,i)+
326 & wel_loc*fact(2)*gel_loc(j,i)+
327 & wturn3*fact(2)*gcorr3_turn(j,i)+
328 & wturn4*fact(3)*gcorr4_turn(j,i)+
329 & wcorr5*fact(4)*gradcorr5(j,i)+
330 & wcorr6*fact(5)*gradcorr6(j,i)+
331 & wturn6*fact(5)*gcorr6_turn(j,i)+
332 & wsccor*fact(2)*gsccorc(j,i)
333 & +wliptran*gliptranc(j,i)
334 & +welec*gshieldc(j,i)
335 & +welec*gshieldc_loc(j,i)
336 & +wcorr*gshieldc_ec(j,i)
337 & +wcorr*gshieldc_loc_ec(j,i)
338 & +wturn3*gshieldc_t3(j,i)
339 & +wturn3*gshieldc_loc_t3(j,i)
340 & +wturn4*gshieldc_t4(j,i)
341 & +wturn4*gshieldc_loc_t4(j,i)
342 & +wel_loc*gshieldc_ll(j,i)
343 & +wel_loc*gshieldc_loc_ll(j,i)
345 gradx(j,i,icg)=fact(1)*wsc*gvdwx(j,i)+
346 & fact(1)*wscp*gradx_scp(j,i)+
348 & wstrain*ghpbx(j,i)+wcorr*gradxorr(j,i)+
349 & wsccor*fact(1)*gsccorx(j,i)
350 & +wliptran*gliptranx(j,i)
351 & +welec*gshieldx(j,i)
352 & +wcorr*gshieldx_ec(j,i)
353 & +wturn3*gshieldx_t3(j,i)
354 & +wturn4*gshieldx_t4(j,i)
355 & +wel_loc*gshieldx_ll(j,i)
364 gloc(i,icg)=gloc(i,icg)+wcorr*fact(3)*gcorr_loc(i)
365 & +wcorr5*fact(4)*g_corr5_loc(i)
366 & +wcorr6*fact(5)*g_corr6_loc(i)
367 & +wturn4*fact(3)*gel_loc_turn4(i)
368 & +wturn3*fact(2)*gel_loc_turn3(i)
369 & +wturn6*fact(5)*gel_loc_turn6(i)
370 & +wel_loc*fact(2)*gel_loc_loc(i)
371 c & +wsccor*fact(1)*gsccor_loc(i)
372 c BYLA ROZNICA Z CLUSTER< OSTATNIA LINIA DODANA
375 if (dyn_ss) call dyn_set_nss
378 C------------------------------------------------------------------------
379 subroutine enerprint(energia,fact)
380 implicit real*8 (a-h,o-z)
382 include 'DIMENSIONS.ZSCOPT'
383 include 'COMMON.IOUNITS'
384 include 'COMMON.FFIELD'
385 include 'COMMON.SBRIDGE'
386 double precision energia(0:max_ene),fact(6)
388 evdw=energia(1)+fact(6)*energia(21)
390 evdw2=energia(2)+energia(17)
402 eello_turn3=energia(8)
403 eello_turn4=energia(9)
404 eello_turn6=energia(10)
411 edihcnstr=energia(20)
413 ethetacnstr=energia(24)
416 write (iout,10) evdw,wsc,evdw2,wscp,ees,welec*fact(1),evdw1,
418 & estr,wbond,ebe,wang,escloc,wscloc,etors,wtor*fact(1),
419 & etors_d,wtor_d*fact(2),ehpb,wstrain,
420 & ecorr,wcorr*fact(3),ecorr5,wcorr5*fact(4),ecorr6,wcorr6*fact(5),
421 & eel_loc,wel_loc*fact(2),eello_turn3,wturn3*fact(2),
422 & eello_turn4,wturn4*fact(3),eello_turn6,wturn6*fact(5),
423 & esccor,wsccor*fact(1),edihcnstr,ethetacnstr,ebr*nss,
424 & eliptran,wliptran,etot
425 10 format (/'Virtual-chain energies:'//
426 & 'EVDW= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-SC)'/
427 & 'EVDW2= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-p)'/
428 & 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p elec)'/
429 & 'EVDWPP=',1pE16.6,' WEIGHT=',1pD16.6,' (p-p VDW)'/
430 & 'ESTR= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching)'/
431 & 'EBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (bending)'/
432 & 'ESC= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/
433 & 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/
434 & 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/
435 & 'EHBP= ',1pE16.6,' WEIGHT=',1pD16.6,
436 & ' (SS bridges & dist. cnstr.)'/
437 & 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
438 & 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
439 & 'ECORR6=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
440 & 'EELLO= ',1pE16.6,' WEIGHT=',1pD16.6,' (electrostatic-local)'/
441 & 'ETURN3=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 3rd order)'/
442 & 'ETURN4=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 4th order)'/
443 & 'ETURN6=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 6th order)'/
444 & 'ESCCOR=',1pE16.6,' WEIGHT=',1pD16.6,' (backbone-rotamer corr)'/
445 & 'EDIHC= ',1pE16.6,' (dihedral angle constraints)'/
446 & 'ETHETC= ',1pE16.6,' (valence angle constraints)'/
447 & 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/
448 & 'ELT=',1pE16.6, ' WEIGHT=',1pD16.6,' (Lipid transfer energy)'/
449 & 'ETOT= ',1pE16.6,' (total)')
451 write (iout,10) evdw,wsc,evdw2,wscp,ees,welec*fact(1),estr,wbond,
452 & ebe,wang,escloc,wscloc,etors,wtor*fact(1),etors_d,wtor_d*fact2,
453 & ehpb,wstrain,ecorr,wcorr*fact(3),ecorr5,wcorr5*fact(4),
454 & ecorr6,wcorr6*fact(5),eel_loc,wel_loc*fact(2),
455 & eello_turn3,wturn3*fact(2),eello_turn4,wturn4*fact(3),
456 & eello_turn6,wturn6*fact(5),esccor*fact(1),wsccor,
457 & edihcnstr,ethetacnstr,ebr*nss,eliptran,wliptran,etot
458 10 format (/'Virtual-chain energies:'//
459 & 'EVDW= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-SC)'/
460 & 'EVDW2= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-p)'/
461 & 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p)'/
462 & 'ESTR= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching)'/
463 & 'EBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (bending)'/
464 & 'ESC= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/
465 & 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/
466 & 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/
467 & 'EHBP= ',1pE16.6,' WEIGHT=',1pD16.6,
468 & ' (SS bridges & dist. cnstr.)'/
469 & 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
470 & 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
471 & 'ECORR6=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
472 & 'EELLO= ',1pE16.6,' WEIGHT=',1pD16.6,' (electrostatic-local)'/
473 & 'ETURN3=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 3rd order)'/
474 & 'ETURN4=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 4th order)'/
475 & 'ETURN6=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 6th order)'/
476 & 'ESCCOR=',1pE16.6,' WEIGHT=',1pD16.6,' (backbone-rotamer corr)'/
477 & 'EDIHC= ',1pE16.6,' (dihedral angle constraints)'/
478 & 'ETHETC= ',1pE16.6,' (valence angle constraints)'/
479 & 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/
480 & 'ELT=',1pE16.6, ' WEIGHT=',1pD16.6,' (Lipid transfer energy)'/
481 & 'ETOT= ',1pE16.6,' (total)')
485 C-----------------------------------------------------------------------
486 subroutine elj(evdw,evdw_t)
488 C This subroutine calculates the interaction energy of nonbonded side chains
489 C assuming the LJ potential of interaction.
491 implicit real*8 (a-h,o-z)
493 include 'DIMENSIONS.ZSCOPT'
494 include "DIMENSIONS.COMPAR"
495 parameter (accur=1.0d-10)
498 include 'COMMON.LOCAL'
499 include 'COMMON.CHAIN'
500 include 'COMMON.DERIV'
501 include 'COMMON.INTERACT'
502 include 'COMMON.TORSION'
503 include 'COMMON.ENEPS'
504 include 'COMMON.SBRIDGE'
505 include 'COMMON.NAMES'
506 include 'COMMON.IOUNITS'
507 include 'COMMON.CONTACTS'
511 cd print *,'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
515 eneps_temp(j,i)=0.0d0
524 if (itypi.eq.ntyp1) cycle
525 itypi1=iabs(itype(i+1))
532 C Calculate SC interaction energy.
535 cd write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
536 cd & 'iend=',iend(i,iint)
537 do j=istart(i,iint),iend(i,iint)
539 if (itypj.eq.ntyp1) cycle
543 C Change 12/1/95 to calculate four-body interactions
544 rij=xj*xj+yj*yj+zj*zj
546 c write (iout,*)'i=',i,' j=',j,' itypi=',itypi,' itypj=',itypj
547 eps0ij=eps(itypi,itypj)
552 ij=icant(itypi,itypj)
554 eneps_temp(1,ij)=eneps_temp(1,ij)+e1/dabs(eps0ij)
555 eneps_temp(2,ij)=eneps_temp(2,ij)+e2/eps0ij
558 cd sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
559 cd epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
560 cd write (iout,'(2(a3,i3,2x),6(1pd12.4)/2(3(1pd12.4),5x)/)')
561 cd & restyp(itypi),i,restyp(itypj),j,aa(itypi,itypj),
562 cd & bb(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,epsi,sigm,
563 cd & (c(k,i),k=1,3),(c(k,j),k=1,3)
564 if (bb.gt.0.0d0) then
571 C Calculate the components of the gradient in DC and X
573 fac=-rrij*(e1+evdwij)
578 gvdwx(k,i)=gvdwx(k,i)-gg(k)
579 gvdwx(k,j)=gvdwx(k,j)+gg(k)
583 gvdwc(l,k)=gvdwc(l,k)+gg(l)
588 C 12/1/95, revised on 5/20/97
590 C Calculate the contact function. The ith column of the array JCONT will
591 C contain the numbers of atoms that make contacts with the atom I (of numbers
592 C greater than I). The arrays FACONT and GACONT will contain the values of
593 C the contact function and its derivative.
595 C Uncomment next line, if the correlation interactions include EVDW explicitly.
596 c if (j.gt.i+1 .and. evdwij.le.0.0D0) then
597 C Uncomment next line, if the correlation interactions are contact function only
598 if (j.gt.i+1.and. eps0ij.gt.0.0D0) then
600 sigij=sigma(itypi,itypj)
601 r0ij=rs0(itypi,itypj)
603 C Check whether the SC's are not too far to make a contact.
606 call gcont(rij,rcut,1.0d0,0.2d0*rcut,fcont,fprimcont)
607 C Add a new contact, if the SC's are close enough, but not too close (r<sigma).
609 if (fcont.gt.0.0D0) then
610 C If the SC-SC distance if close to sigma, apply spline.
611 cAdam call gcont(-rij,-1.03d0*sigij,2.0d0*sigij,1.0d0,
612 cAdam & fcont1,fprimcont1)
613 cAdam fcont1=1.0d0-fcont1
614 cAdam if (fcont1.gt.0.0d0) then
615 cAdam fprimcont=fprimcont*fcont1+fcont*fprimcont1
616 cAdam fcont=fcont*fcont1
618 C Uncomment following 4 lines to have the geometric average of the epsilon0's
619 cga eps0ij=1.0d0/dsqrt(eps0ij)
621 cga gg(k)=gg(k)*eps0ij
623 cga eps0ij=-evdwij*eps0ij
624 C Uncomment for AL's type of SC correlation interactions.
626 num_conti=num_conti+1
628 facont(num_conti,i)=fcont*eps0ij
629 fprimcont=eps0ij*fprimcont/rij
631 cAdam gacont(1,num_conti,i)=-fprimcont*xj+fcont*gg(1)
632 cAdam gacont(2,num_conti,i)=-fprimcont*yj+fcont*gg(2)
633 cAdam gacont(3,num_conti,i)=-fprimcont*zj+fcont*gg(3)
634 C Uncomment following 3 lines for Skolnick's type of SC correlation.
635 gacont(1,num_conti,i)=-fprimcont*xj
636 gacont(2,num_conti,i)=-fprimcont*yj
637 gacont(3,num_conti,i)=-fprimcont*zj
638 cd write (iout,'(2i5,2f10.5)') i,j,rij,facont(num_conti,i)
639 cd write (iout,'(2i3,3f10.5)')
640 cd & i,j,(gacont(kk,num_conti,i),kk=1,3)
646 num_cont(i)=num_conti
651 gvdwc(j,i)=expon*gvdwc(j,i)
652 gvdwx(j,i)=expon*gvdwx(j,i)
656 C******************************************************************************
660 C To save time, the factor of EXPON has been extracted from ALL components
661 C of GVDWC and GRADX. Remember to multiply them by this factor before further
664 C******************************************************************************
667 C-----------------------------------------------------------------------------
668 subroutine eljk(evdw,evdw_t)
670 C This subroutine calculates the interaction energy of nonbonded side chains
671 C assuming the LJK potential of interaction.
673 implicit real*8 (a-h,o-z)
675 include 'DIMENSIONS.ZSCOPT'
676 include "DIMENSIONS.COMPAR"
679 include 'COMMON.LOCAL'
680 include 'COMMON.CHAIN'
681 include 'COMMON.DERIV'
682 include 'COMMON.INTERACT'
683 include 'COMMON.ENEPS'
684 include 'COMMON.IOUNITS'
685 include 'COMMON.NAMES'
690 c print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
693 eneps_temp(j,i)=0.0d0
700 if (itypi.eq.ntyp1) cycle
701 itypi1=iabs(itype(i+1))
706 C Calculate SC interaction energy.
709 do j=istart(i,iint),iend(i,iint)
711 if (itypj.eq.ntyp1) cycle
715 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
717 e_augm=augm(itypi,itypj)*fac_augm
720 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
721 fac=r_shift_inv**expon
725 ij=icant(itypi,itypj)
726 eneps_temp(1,ij)=eneps_temp(1,ij)+(e1+a_augm)
727 & /dabs(eps(itypi,itypj))
728 eneps_temp(2,ij)=eneps_temp(2,ij)+e2/eps(itypi,itypj)
729 cd sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
730 cd epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
731 cd write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
732 cd & restyp(itypi),i,restyp(itypj),j,aa(itypi,itypj),
733 cd & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
734 cd & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
735 cd & (c(k,i),k=1,3),(c(k,j),k=1,3)
736 if (bb.gt.0.0d0) then
743 C Calculate the components of the gradient in DC and X
745 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
750 gvdwx(k,i)=gvdwx(k,i)-gg(k)
751 gvdwx(k,j)=gvdwx(k,j)+gg(k)
755 gvdwc(l,k)=gvdwc(l,k)+gg(l)
765 gvdwc(j,i)=expon*gvdwc(j,i)
766 gvdwx(j,i)=expon*gvdwx(j,i)
772 C-----------------------------------------------------------------------------
773 subroutine ebp(evdw,evdw_t)
775 C This subroutine calculates the interaction energy of nonbonded side chains
776 C assuming the Berne-Pechukas potential of interaction.
778 implicit real*8 (a-h,o-z)
780 include 'DIMENSIONS.ZSCOPT'
781 include "DIMENSIONS.COMPAR"
784 include 'COMMON.LOCAL'
785 include 'COMMON.CHAIN'
786 include 'COMMON.DERIV'
787 include 'COMMON.NAMES'
788 include 'COMMON.INTERACT'
789 include 'COMMON.ENEPS'
790 include 'COMMON.IOUNITS'
791 include 'COMMON.CALC'
793 c double precision rrsave(maxdim)
799 eneps_temp(j,i)=0.0d0
804 c print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
805 c if (icall.eq.0) then
813 if (itypi.eq.ntyp1) cycle
814 itypi1=iabs(itype(i+1))
818 dxi=dc_norm(1,nres+i)
819 dyi=dc_norm(2,nres+i)
820 dzi=dc_norm(3,nres+i)
821 dsci_inv=vbld_inv(i+nres)
823 C Calculate SC interaction energy.
826 do j=istart(i,iint),iend(i,iint)
829 if (itypj.eq.ntyp1) cycle
830 dscj_inv=vbld_inv(j+nres)
831 chi1=chi(itypi,itypj)
832 chi2=chi(itypj,itypi)
839 alf12=0.5D0*(alf1+alf2)
840 C For diagnostics only!!!
853 dxj=dc_norm(1,nres+j)
854 dyj=dc_norm(2,nres+j)
855 dzj=dc_norm(3,nres+j)
856 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
857 cd if (icall.eq.0) then
863 C Calculate the angle-dependent terms of energy & contributions to derivatives.
865 C Calculate whole angle-dependent part of epsilon and contributions
867 fac=(rrij*sigsq)**expon2
870 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
871 eps2der=evdwij*eps3rt
872 eps3der=evdwij*eps2rt
873 evdwij=evdwij*eps2rt*eps3rt
874 ij=icant(itypi,itypj)
875 aux=eps1*eps2rt**2*eps3rt**2
876 eneps_temp(1,ij)=eneps_temp(1,ij)+e1*aux
877 & /dabs(eps(itypi,itypj))
878 eneps_temp(2,ij)=eneps_temp(2,ij)+e2*aux/eps(itypi,itypj)
879 if (bb.gt.0.0d0) then
886 sigm=dabs(aa/bb)**(1.0D0/6.0D0)
888 write (iout,'(2(a3,i3,2x),15(0pf7.3))')
889 & restyp(itypi),i,restyp(itypj),j,
890 & epsi,sigm,chi1,chi2,chip1,chip2,
891 & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
892 & om1,om2,om12,1.0D0/dsqrt(rrij),
895 C Calculate gradient components.
896 e1=e1*eps1*eps2rt**2*eps3rt**2
897 fac=-expon*(e1+evdwij)
900 C Calculate radial part of the gradient
904 C Calculate the angular part of the gradient and sum add the contributions
905 C to the appropriate components of the Cartesian gradient.
914 C-----------------------------------------------------------------------------
915 subroutine egb(evdw,evdw_t)
917 C This subroutine calculates the interaction energy of nonbonded side chains
918 C assuming the Gay-Berne potential of interaction.
920 implicit real*8 (a-h,o-z)
922 include 'DIMENSIONS.ZSCOPT'
923 include "DIMENSIONS.COMPAR"
926 include 'COMMON.LOCAL'
927 include 'COMMON.CHAIN'
928 include 'COMMON.DERIV'
929 include 'COMMON.NAMES'
930 include 'COMMON.INTERACT'
931 include 'COMMON.ENEPS'
932 include 'COMMON.IOUNITS'
933 include 'COMMON.CALC'
934 include 'COMMON.SBRIDGE'
937 integer icant,xshift,yshift,zshift
941 eneps_temp(j,i)=0.0d0
944 c print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
948 c if (icall.gt.0) lprn=.true.
952 if (itypi.eq.ntyp1) cycle
953 itypi1=iabs(itype(i+1))
957 C returning the ith atom to box
959 if (xi.lt.0) xi=xi+boxxsize
961 if (yi.lt.0) yi=yi+boxysize
963 if (zi.lt.0) zi=zi+boxzsize
964 if ((zi.gt.bordlipbot)
965 &.and.(zi.lt.bordliptop)) then
966 C the energy transfer exist
967 if (zi.lt.buflipbot) then
968 C what fraction I am in
970 & ((zi-bordlipbot)/lipbufthick)
971 C lipbufthick is thickenes of lipid buffore
972 sslipi=sscalelip(fracinbuf)
973 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
974 elseif (zi.gt.bufliptop) then
975 fracinbuf=1.0d0-((bordliptop-zi)/lipbufthick)
976 sslipi=sscalelip(fracinbuf)
977 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
987 dxi=dc_norm(1,nres+i)
988 dyi=dc_norm(2,nres+i)
989 dzi=dc_norm(3,nres+i)
990 dsci_inv=vbld_inv(i+nres)
992 C Calculate SC interaction energy.
995 do j=istart(i,iint),iend(i,iint)
996 IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
997 call dyn_ssbond_ene(i,j,evdwij)
999 C write (iout,'(a6,2i5,0pf7.3,a3,2f10.3)')
1000 C & 'evdw',i,j,evdwij,' ss',evdw,evdw_t
1001 C triple bond artifac removal
1002 do k=j+1,iend(i,iint)
1003 C search over all next residues
1004 if (dyn_ss_mask(k)) then
1005 C check if they are cysteins
1006 C write(iout,*) 'k=',k
1007 call triple_ssbond_ene(i,j,k,evdwij)
1008 C call the energy function that removes the artifical triple disulfide
1009 C bond the soubroutine is located in ssMD.F
1011 C write (iout,'(a6,2i5,0pf7.3,a3,2f10.3)')
1012 C & 'evdw',i,j,evdwij,'tss',evdw,evdw_t
1013 endif!dyn_ss_mask(k)
1017 itypj=iabs(itype(j))
1018 if (itypj.eq.ntyp1) cycle
1019 dscj_inv=vbld_inv(j+nres)
1020 sig0ij=sigma(itypi,itypj)
1021 chi1=chi(itypi,itypj)
1022 chi2=chi(itypj,itypi)
1029 alf12=0.5D0*(alf1+alf2)
1030 C For diagnostics only!!!
1043 C returning jth atom to box
1045 if (xj.lt.0) xj=xj+boxxsize
1047 if (yj.lt.0) yj=yj+boxysize
1049 if (zj.lt.0) zj=zj+boxzsize
1050 if ((zj.gt.bordlipbot)
1051 &.and.(zj.lt.bordliptop)) then
1052 C the energy transfer exist
1053 if (zj.lt.buflipbot) then
1054 C what fraction I am in
1056 & ((zj-bordlipbot)/lipbufthick)
1057 C lipbufthick is thickenes of lipid buffore
1058 sslipj=sscalelip(fracinbuf)
1059 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
1060 elseif (zj.gt.bufliptop) then
1061 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
1062 sslipj=sscalelip(fracinbuf)
1063 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
1072 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0
1073 & +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
1074 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0
1075 & +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
1076 C if (aa.ne.aa_aq(itypi,itypj)) then
1078 write(iout,*) "tu,", i,j,aa_aq(itypi,itypj)-aa,
1079 & bb_aq(itypi,itypj)-bb,
1083 C write(iout,*),aa,aa_lip(itypi,itypj),aa_aq(itypi,itypj)
1084 C checking the distance
1085 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
1090 C finding the closest
1094 xj=xj_safe+xshift*boxxsize
1095 yj=yj_safe+yshift*boxysize
1096 zj=zj_safe+zshift*boxzsize
1097 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
1098 if(dist_temp.lt.dist_init) then
1108 if (subchap.eq.1) then
1118 dxj=dc_norm(1,nres+j)
1119 dyj=dc_norm(2,nres+j)
1120 dzj=dc_norm(3,nres+j)
1121 c write (iout,*) i,j,xj,yj,zj
1122 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1124 sss=sscale((1.0d0/rij)/sigma(itypi,itypj))
1125 sssgrad=sscagrad((1.0d0/rij)/sigma(itypi,itypj))
1126 if (sss.le.0.0) cycle
1127 C Calculate angle-dependent terms of energy and contributions to their
1132 sig=sig0ij*dsqrt(sigsq)
1133 rij_shift=1.0D0/rij-sig+sig0ij
1134 C I hate to put IF's in the loops, but here don't have another choice!!!!
1135 if (rij_shift.le.0.0D0) then
1140 c---------------------------------------------------------------
1141 rij_shift=1.0D0/rij_shift
1142 fac=rij_shift**expon
1145 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
1146 eps2der=evdwij*eps3rt
1147 eps3der=evdwij*eps2rt
1148 evdwij=evdwij*eps2rt*eps3rt
1150 evdw=evdw+evdwij*sss
1152 evdw_t=evdw_t+evdwij*sss
1154 ij=icant(itypi,itypj)
1155 aux=eps1*eps2rt**2*eps3rt**2
1156 eneps_temp(1,ij)=eneps_temp(1,ij)+aux*e1
1157 & /dabs(eps(itypi,itypj))
1158 eneps_temp(2,ij)=eneps_temp(2,ij)+aux*e2/eps(itypi,itypj)
1159 c write (iout,*) "i",i," j",j," itypi",itypi," itypj",itypj,
1160 c & " ij",ij," eneps",aux*e1/dabs(eps(itypi,itypj)),
1161 c & aux*e2/eps(itypi,itypj)
1163 sigm=dabs(aa/bb)**(1.0D0/6.0D0)
1167 write (iout,'(2(a3,i3,2x),17(0pf7.3))')
1168 & restyp(itypi),i,restyp(itypj),j,
1169 & epsi,sigm,chi1,chi2,chip1,chip2,
1170 & eps1,eps2rt**2,eps3rt**2,sig,sig0ij,
1171 & om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,
1173 write (iout,*) "partial sum", evdw, evdw_t
1178 C Calculate gradient components.
1179 e1=e1*eps1*eps2rt**2*eps3rt**2
1180 fac=-expon*(e1+evdwij)*rij_shift
1183 fac=fac+evdwij/sss*sssgrad/sigma(itypi,itypj)*rij
1184 C Calculate the radial part of the gradient
1188 C Calculate angular part of the gradient.
1191 C write(iout,*) "partial sum", evdw, evdw_t
1198 C-----------------------------------------------------------------------------
1199 subroutine egbv(evdw,evdw_t)
1201 C This subroutine calculates the interaction energy of nonbonded side chains
1202 C assuming the Gay-Berne-Vorobjev potential of interaction.
1204 implicit real*8 (a-h,o-z)
1205 include 'DIMENSIONS'
1206 include 'DIMENSIONS.ZSCOPT'
1207 include "DIMENSIONS.COMPAR"
1208 include 'COMMON.GEO'
1209 include 'COMMON.VAR'
1210 include 'COMMON.LOCAL'
1211 include 'COMMON.CHAIN'
1212 include 'COMMON.DERIV'
1213 include 'COMMON.NAMES'
1214 include 'COMMON.INTERACT'
1215 include 'COMMON.ENEPS'
1216 include 'COMMON.IOUNITS'
1217 include 'COMMON.CALC'
1218 common /srutu/ icall
1224 eneps_temp(j,i)=0.0d0
1229 c print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
1232 c if (icall.gt.0) lprn=.true.
1234 do i=iatsc_s,iatsc_e
1235 itypi=iabs(itype(i))
1236 if (itypi.eq.ntyp1) cycle
1237 itypi1=iabs(itype(i+1))
1241 dxi=dc_norm(1,nres+i)
1242 dyi=dc_norm(2,nres+i)
1243 dzi=dc_norm(3,nres+i)
1244 dsci_inv=vbld_inv(i+nres)
1246 C Calculate SC interaction energy.
1248 do iint=1,nint_gr(i)
1249 do j=istart(i,iint),iend(i,iint)
1251 itypj=iabs(itype(j))
1252 if (itypj.eq.ntyp1) cycle
1253 dscj_inv=vbld_inv(j+nres)
1254 sig0ij=sigma(itypi,itypj)
1255 r0ij=r0(itypi,itypj)
1256 chi1=chi(itypi,itypj)
1257 chi2=chi(itypj,itypi)
1264 alf12=0.5D0*(alf1+alf2)
1265 C For diagnostics only!!!
1278 dxj=dc_norm(1,nres+j)
1279 dyj=dc_norm(2,nres+j)
1280 dzj=dc_norm(3,nres+j)
1281 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1283 C Calculate angle-dependent terms of energy and contributions to their
1287 sig=sig0ij*dsqrt(sigsq)
1288 rij_shift=1.0D0/rij-sig+r0ij
1289 C I hate to put IF's in the loops, but here don't have another choice!!!!
1290 if (rij_shift.le.0.0D0) then
1295 c---------------------------------------------------------------
1296 rij_shift=1.0D0/rij_shift
1297 fac=rij_shift**expon
1300 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
1301 eps2der=evdwij*eps3rt
1302 eps3der=evdwij*eps2rt
1303 fac_augm=rrij**expon
1304 e_augm=augm(itypi,itypj)*fac_augm
1305 evdwij=evdwij*eps2rt*eps3rt
1306 if (bb.gt.0.0d0) then
1307 evdw=evdw+evdwij+e_augm
1309 evdw_t=evdw_t+evdwij+e_augm
1311 ij=icant(itypi,itypj)
1312 aux=eps1*eps2rt**2*eps3rt**2
1313 eneps_temp(1,ij)=eneps_temp(1,ij)+aux*(e1+e_augm)
1314 & /dabs(eps(itypi,itypj))
1315 eneps_temp(2,ij)=eneps_temp(2,ij)+aux*e2/eps(itypi,itypj)
1316 c eneps_temp(ij)=eneps_temp(ij)
1317 c & +(evdwij+e_augm)/eps(itypi,itypj)
1319 c sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1320 c epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1321 c write (iout,'(2(a3,i3,2x),17(0pf7.3))')
1322 c & restyp(itypi),i,restyp(itypj),j,
1323 c & epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),
1324 c & chi1,chi2,chip1,chip2,
1325 c & eps1,eps2rt**2,eps3rt**2,
1326 c & om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,
1330 C Calculate gradient components.
1331 e1=e1*eps1*eps2rt**2*eps3rt**2
1332 fac=-expon*(e1+evdwij)*rij_shift
1334 fac=rij*fac-2*expon*rrij*e_augm
1335 C Calculate the radial part of the gradient
1339 C Calculate angular part of the gradient.
1347 C-----------------------------------------------------------------------------
1348 subroutine sc_angular
1349 C Calculate eps1,eps2,eps3,sigma, and parts of their derivatives in om1,om2,
1350 C om12. Called by ebp, egb, and egbv.
1352 include 'COMMON.CALC'
1356 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
1357 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
1358 om12=dxi*dxj+dyi*dyj+dzi*dzj
1360 C Calculate eps1(om12) and its derivative in om12
1361 faceps1=1.0D0-om12*chiom12
1362 faceps1_inv=1.0D0/faceps1
1363 eps1=dsqrt(faceps1_inv)
1364 C Following variable is eps1*deps1/dom12
1365 eps1_om12=faceps1_inv*chiom12
1366 C Calculate sigma(om1,om2,om12) and the derivatives of sigma**2 in om1,om2,
1371 facsig=om1*chiom1+om2*chiom2-2.0D0*om1om2*chiom12
1372 sigsq=1.0D0-facsig*faceps1_inv
1373 sigsq_om1=(chiom1-chiom12*om2)*faceps1_inv
1374 sigsq_om2=(chiom2-chiom12*om1)*faceps1_inv
1375 sigsq_om12=-chi12*(om1om2*faceps1-om12*facsig)*faceps1_inv**2
1376 C Calculate eps2 and its derivatives in om1, om2, and om12.
1379 chipom12=chip12*om12
1380 facp=1.0D0-om12*chipom12
1382 facp1=om1*chipom1+om2*chipom2-2.0D0*om1om2*chipom12
1383 C Following variable is the square root of eps2
1384 eps2rt=1.0D0-facp1*facp_inv
1385 C Following three variables are the derivatives of the square root of eps
1386 C in om1, om2, and om12.
1387 eps2rt_om1=-4.0D0*(chipom1-chipom12*om2)*facp_inv
1388 eps2rt_om2=-4.0D0*(chipom2-chipom12*om1)*facp_inv
1389 eps2rt_om12=4.0D0*chip12*(om1om2*facp-om12*facp1)*facp_inv**2
1390 C Evaluate the "asymmetric" factor in the VDW constant, eps3
1391 eps3rt=1.0D0-alf1*om1+alf2*om2-alf12*om12
1392 C Calculate whole angle-dependent part of epsilon and contributions
1393 C to its derivatives
1396 C----------------------------------------------------------------------------
1398 implicit real*8 (a-h,o-z)
1399 include 'DIMENSIONS'
1400 include 'DIMENSIONS.ZSCOPT'
1401 include 'COMMON.CHAIN'
1402 include 'COMMON.DERIV'
1403 include 'COMMON.CALC'
1404 double precision dcosom1(3),dcosom2(3)
1405 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
1406 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
1407 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12
1408 & -2.0D0*alf12*eps3der+sigder*sigsq_om12
1410 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
1411 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
1414 gg(k)=gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
1417 gvdwx(k,i)=gvdwx(k,i)-gg(k)
1418 & +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))
1419 & +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
1420 gvdwx(k,j)=gvdwx(k,j)+gg(k)
1421 & +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))
1422 & +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
1425 C Calculate the components of the gradient in DC and X
1429 gvdwc(l,k)=gvdwc(l,k)+gg(l)
1434 c------------------------------------------------------------------------------
1435 subroutine vec_and_deriv
1436 implicit real*8 (a-h,o-z)
1437 include 'DIMENSIONS'
1438 include 'DIMENSIONS.ZSCOPT'
1439 include 'COMMON.IOUNITS'
1440 include 'COMMON.GEO'
1441 include 'COMMON.VAR'
1442 include 'COMMON.LOCAL'
1443 include 'COMMON.CHAIN'
1444 include 'COMMON.VECTORS'
1445 include 'COMMON.DERIV'
1446 include 'COMMON.INTERACT'
1447 dimension uyder(3,3,2),uzder(3,3,2),vbld_inv_temp(2)
1448 C Compute the local reference systems. For reference system (i), the
1449 C X-axis points from CA(i) to CA(i+1), the Y axis is in the
1450 C CA(i)-CA(i+1)-CA(i+2) plane, and the Z axis is perpendicular to this plane.
1452 c if (i.eq.nres-1 .or. itel(i+1).eq.0) then
1453 if (i.eq.nres-1) then
1454 C Case of the last full residue
1455 C Compute the Z-axis
1456 call vecpr(dc_norm(1,i),dc_norm(1,i-1),uz(1,i))
1457 costh=dcos(pi-theta(nres))
1458 fac=1.0d0/dsqrt(1.0d0-costh*costh)
1463 C Compute the derivatives of uz
1465 uzder(2,1,1)=-dc_norm(3,i-1)
1466 uzder(3,1,1)= dc_norm(2,i-1)
1467 uzder(1,2,1)= dc_norm(3,i-1)
1469 uzder(3,2,1)=-dc_norm(1,i-1)
1470 uzder(1,3,1)=-dc_norm(2,i-1)
1471 uzder(2,3,1)= dc_norm(1,i-1)
1474 uzder(2,1,2)= dc_norm(3,i)
1475 uzder(3,1,2)=-dc_norm(2,i)
1476 uzder(1,2,2)=-dc_norm(3,i)
1478 uzder(3,2,2)= dc_norm(1,i)
1479 uzder(1,3,2)= dc_norm(2,i)
1480 uzder(2,3,2)=-dc_norm(1,i)
1483 C Compute the Y-axis
1486 uy(k,i)=fac*(dc_norm(k,i-1)-costh*dc_norm(k,i))
1489 C Compute the derivatives of uy
1492 uyder(k,j,1)=2*dc_norm(k,i-1)*dc_norm(j,i)
1493 & -dc_norm(k,i)*dc_norm(j,i-1)
1494 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
1496 uyder(j,j,1)=uyder(j,j,1)-costh
1497 uyder(j,j,2)=1.0d0+uyder(j,j,2)
1502 uygrad(l,k,j,i)=uyder(l,k,j)
1503 uzgrad(l,k,j,i)=uzder(l,k,j)
1507 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
1508 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
1509 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
1510 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
1514 C Compute the Z-axis
1515 call vecpr(dc_norm(1,i),dc_norm(1,i+1),uz(1,i))
1516 costh=dcos(pi-theta(i+2))
1517 fac=1.0d0/dsqrt(1.0d0-costh*costh)
1522 C Compute the derivatives of uz
1524 uzder(2,1,1)=-dc_norm(3,i+1)
1525 uzder(3,1,1)= dc_norm(2,i+1)
1526 uzder(1,2,1)= dc_norm(3,i+1)
1528 uzder(3,2,1)=-dc_norm(1,i+1)
1529 uzder(1,3,1)=-dc_norm(2,i+1)
1530 uzder(2,3,1)= dc_norm(1,i+1)
1533 uzder(2,1,2)= dc_norm(3,i)
1534 uzder(3,1,2)=-dc_norm(2,i)
1535 uzder(1,2,2)=-dc_norm(3,i)
1537 uzder(3,2,2)= dc_norm(1,i)
1538 uzder(1,3,2)= dc_norm(2,i)
1539 uzder(2,3,2)=-dc_norm(1,i)
1542 C Compute the Y-axis
1545 uy(k,i)=facy*(dc_norm(k,i+1)-costh*dc_norm(k,i))
1548 C Compute the derivatives of uy
1551 uyder(k,j,1)=2*dc_norm(k,i+1)*dc_norm(j,i)
1552 & -dc_norm(k,i)*dc_norm(j,i+1)
1553 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
1555 uyder(j,j,1)=uyder(j,j,1)-costh
1556 uyder(j,j,2)=1.0d0+uyder(j,j,2)
1561 uygrad(l,k,j,i)=uyder(l,k,j)
1562 uzgrad(l,k,j,i)=uzder(l,k,j)
1566 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
1567 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
1568 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
1569 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
1575 vbld_inv_temp(1)=vbld_inv(i+1)
1576 if (i.lt.nres-1) then
1577 vbld_inv_temp(2)=vbld_inv(i+2)
1579 vbld_inv_temp(2)=vbld_inv(i)
1584 uygrad(l,k,j,i)=vbld_inv_temp(j)*uygrad(l,k,j,i)
1585 uzgrad(l,k,j,i)=vbld_inv_temp(j)*uzgrad(l,k,j,i)
1593 C-----------------------------------------------------------------------------
1594 subroutine vec_and_deriv_test
1595 implicit real*8 (a-h,o-z)
1596 include 'DIMENSIONS'
1597 include 'DIMENSIONS.ZSCOPT'
1598 include 'COMMON.IOUNITS'
1599 include 'COMMON.GEO'
1600 include 'COMMON.VAR'
1601 include 'COMMON.LOCAL'
1602 include 'COMMON.CHAIN'
1603 include 'COMMON.VECTORS'
1604 dimension uyder(3,3,2),uzder(3,3,2)
1605 C Compute the local reference systems. For reference system (i), the
1606 C X-axis points from CA(i) to CA(i+1), the Y axis is in the
1607 C CA(i)-CA(i+1)-CA(i+2) plane, and the Z axis is perpendicular to this plane.
1609 if (i.eq.nres-1) then
1610 C Case of the last full residue
1611 C Compute the Z-axis
1612 call vecpr(dc_norm(1,i),dc_norm(1,i-1),uz(1,i))
1613 costh=dcos(pi-theta(nres))
1614 fac=1.0d0/dsqrt(1.0d0-costh*costh)
1615 c write (iout,*) 'fac',fac,
1616 c & 1.0d0/dsqrt(scalar(uz(1,i),uz(1,i)))
1617 fac=1.0d0/dsqrt(scalar(uz(1,i),uz(1,i)))
1621 C Compute the derivatives of uz
1623 uzder(2,1,1)=-dc_norm(3,i-1)
1624 uzder(3,1,1)= dc_norm(2,i-1)
1625 uzder(1,2,1)= dc_norm(3,i-1)
1627 uzder(3,2,1)=-dc_norm(1,i-1)
1628 uzder(1,3,1)=-dc_norm(2,i-1)
1629 uzder(2,3,1)= dc_norm(1,i-1)
1632 uzder(2,1,2)= dc_norm(3,i)
1633 uzder(3,1,2)=-dc_norm(2,i)
1634 uzder(1,2,2)=-dc_norm(3,i)
1636 uzder(3,2,2)= dc_norm(1,i)
1637 uzder(1,3,2)= dc_norm(2,i)
1638 uzder(2,3,2)=-dc_norm(1,i)
1640 C Compute the Y-axis
1642 uy(k,i)=fac*(dc_norm(k,i-1)-costh*dc_norm(k,i))
1645 facy=1.0d0/dsqrt(scalar(dc_norm(1,i),dc_norm(1,i))*
1646 & (scalar(dc_norm(1,i-1),dc_norm(1,i-1))**2-
1647 & scalar(dc_norm(1,i),dc_norm(1,i-1))**2))
1649 c uy(k,i)=facy*(dc_norm(k,i+1)-costh*dc_norm(k,i))
1652 & dc_norm(k,i-1)*scalar(dc_norm(1,i),dc_norm(1,i))
1653 & -scalar(dc_norm(1,i),dc_norm(1,i-1))*dc_norm(k,i)
1656 c write (iout,*) 'facy',facy,
1657 c & 1.0d0/dsqrt(scalar(uy(1,i),uy(1,i)))
1658 facy=1.0d0/dsqrt(scalar(uy(1,i),uy(1,i)))
1660 uy(k,i)=facy*uy(k,i)
1662 C Compute the derivatives of uy
1665 uyder(k,j,1)=2*dc_norm(k,i-1)*dc_norm(j,i)
1666 & -dc_norm(k,i)*dc_norm(j,i-1)
1667 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
1669 c uyder(j,j,1)=uyder(j,j,1)-costh
1670 c uyder(j,j,2)=1.0d0+uyder(j,j,2)
1671 uyder(j,j,1)=uyder(j,j,1)
1672 & -scalar(dc_norm(1,i),dc_norm(1,i-1))
1673 uyder(j,j,2)=scalar(dc_norm(1,i),dc_norm(1,i))
1679 uygrad(l,k,j,i)=uyder(l,k,j)
1680 uzgrad(l,k,j,i)=uzder(l,k,j)
1684 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
1685 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
1686 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
1687 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
1690 C Compute the Z-axis
1691 call vecpr(dc_norm(1,i),dc_norm(1,i+1),uz(1,i))
1692 costh=dcos(pi-theta(i+2))
1693 fac=1.0d0/dsqrt(1.0d0-costh*costh)
1694 fac=1.0d0/dsqrt(scalar(uz(1,i),uz(1,i)))
1698 C Compute the derivatives of uz
1700 uzder(2,1,1)=-dc_norm(3,i+1)
1701 uzder(3,1,1)= dc_norm(2,i+1)
1702 uzder(1,2,1)= dc_norm(3,i+1)
1704 uzder(3,2,1)=-dc_norm(1,i+1)
1705 uzder(1,3,1)=-dc_norm(2,i+1)
1706 uzder(2,3,1)= dc_norm(1,i+1)
1709 uzder(2,1,2)= dc_norm(3,i)
1710 uzder(3,1,2)=-dc_norm(2,i)
1711 uzder(1,2,2)=-dc_norm(3,i)
1713 uzder(3,2,2)= dc_norm(1,i)
1714 uzder(1,3,2)= dc_norm(2,i)
1715 uzder(2,3,2)=-dc_norm(1,i)
1717 C Compute the Y-axis
1719 facy=1.0d0/dsqrt(scalar(dc_norm(1,i),dc_norm(1,i))*
1720 & (scalar(dc_norm(1,i+1),dc_norm(1,i+1))**2-
1721 & scalar(dc_norm(1,i),dc_norm(1,i+1))**2))
1723 c uy(k,i)=facy*(dc_norm(k,i+1)-costh*dc_norm(k,i))
1726 & dc_norm(k,i+1)*scalar(dc_norm(1,i),dc_norm(1,i))
1727 & -scalar(dc_norm(1,i),dc_norm(1,i+1))*dc_norm(k,i)
1730 c write (iout,*) 'facy',facy,
1731 c & 1.0d0/dsqrt(scalar(uy(1,i),uy(1,i)))
1732 facy=1.0d0/dsqrt(scalar(uy(1,i),uy(1,i)))
1734 uy(k,i)=facy*uy(k,i)
1736 C Compute the derivatives of uy
1739 uyder(k,j,1)=2*dc_norm(k,i+1)*dc_norm(j,i)
1740 & -dc_norm(k,i)*dc_norm(j,i+1)
1741 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
1743 c uyder(j,j,1)=uyder(j,j,1)-costh
1744 c uyder(j,j,2)=1.0d0+uyder(j,j,2)
1745 uyder(j,j,1)=uyder(j,j,1)
1746 & -scalar(dc_norm(1,i),dc_norm(1,i+1))
1747 uyder(j,j,2)=scalar(dc_norm(1,i),dc_norm(1,i))
1753 uygrad(l,k,j,i)=uyder(l,k,j)
1754 uzgrad(l,k,j,i)=uzder(l,k,j)
1758 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
1759 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
1760 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
1761 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
1768 uygrad(l,k,j,i)=vblinv*uygrad(l,k,j,i)
1769 uzgrad(l,k,j,i)=vblinv*uzgrad(l,k,j,i)
1776 C-----------------------------------------------------------------------------
1777 subroutine check_vecgrad
1778 implicit real*8 (a-h,o-z)
1779 include 'DIMENSIONS'
1780 include 'DIMENSIONS.ZSCOPT'
1781 include 'COMMON.IOUNITS'
1782 include 'COMMON.GEO'
1783 include 'COMMON.VAR'
1784 include 'COMMON.LOCAL'
1785 include 'COMMON.CHAIN'
1786 include 'COMMON.VECTORS'
1787 dimension uygradt(3,3,2,maxres),uzgradt(3,3,2,maxres)
1788 dimension uyt(3,maxres),uzt(3,maxres)
1789 dimension uygradn(3,3,2),uzgradn(3,3,2),erij(3)
1790 double precision delta /1.0d-7/
1793 crc write(iout,'(2i5,2(3f10.5,5x))') i,1,dc_norm(:,i)
1794 crc write(iout,'(2i5,2(3f10.5,5x))') i,2,uy(:,i)
1795 crc write(iout,'(2i5,2(3f10.5,5x)/)')i,3,uz(:,i)
1796 cd write(iout,'(2i5,2(3f10.5,5x))') i,1,
1797 cd & (dc_norm(if90,i),if90=1,3)
1798 cd write(iout,'(2i5,2(3f10.5,5x))') i,2,(uy(if90,i),if90=1,3)
1799 cd write(iout,'(2i5,2(3f10.5,5x)/)')i,3,(uz(if90,i),if90=1,3)
1800 cd write(iout,'(a)')
1806 uygradt(l,k,j,i)=uygrad(l,k,j,i)
1807 uzgradt(l,k,j,i)=uzgrad(l,k,j,i)
1820 cd write (iout,*) 'i=',i
1822 erij(k)=dc_norm(k,i)
1826 dc_norm(k,i)=erij(k)
1828 dc_norm(j,i)=dc_norm(j,i)+delta
1829 c fac=dsqrt(scalar(dc_norm(1,i),dc_norm(1,i)))
1831 c dc_norm(k,i)=dc_norm(k,i)/fac
1833 c write (iout,*) (dc_norm(k,i),k=1,3)
1834 c write (iout,*) (erij(k),k=1,3)
1837 uygradn(k,j,1)=(uy(k,i)-uyt(k,i))/delta
1838 uygradn(k,j,2)=(uy(k,i-1)-uyt(k,i-1))/delta
1839 uzgradn(k,j,1)=(uz(k,i)-uzt(k,i))/delta
1840 uzgradn(k,j,2)=(uz(k,i-1)-uzt(k,i-1))/delta
1842 c write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
1843 c & j,(uzgradt(k,j,1,i),k=1,3),(uzgradn(k,j,1),k=1,3),
1844 c & (uzgradt(k,j,2,i-1),k=1,3),(uzgradn(k,j,2),k=1,3)
1847 dc_norm(k,i)=erij(k)
1850 cd write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
1851 cd & k,(uygradt(k,l,1,i),l=1,3),(uygradn(k,l,1),l=1,3),
1852 cd & (uygradt(k,l,2,i-1),l=1,3),(uygradn(k,l,2),l=1,3)
1853 cd write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
1854 cd & k,(uzgradt(k,l,1,i),l=1,3),(uzgradn(k,l,1),l=1,3),
1855 cd & (uzgradt(k,l,2,i-1),l=1,3),(uzgradn(k,l,2),l=1,3)
1856 cd write (iout,'(a)')
1861 C--------------------------------------------------------------------------
1862 subroutine set_matrices
1863 implicit real*8 (a-h,o-z)
1864 include 'DIMENSIONS'
1865 include 'DIMENSIONS.ZSCOPT'
1866 include 'COMMON.IOUNITS'
1867 include 'COMMON.GEO'
1868 include 'COMMON.VAR'
1869 include 'COMMON.LOCAL'
1870 include 'COMMON.CHAIN'
1871 include 'COMMON.DERIV'
1872 include 'COMMON.INTERACT'
1873 include 'COMMON.CONTACTS'
1874 include 'COMMON.TORSION'
1875 include 'COMMON.VECTORS'
1876 include 'COMMON.FFIELD'
1877 double precision auxvec(2),auxmat(2,2)
1879 C Compute the virtual-bond-torsional-angle dependent quantities needed
1880 C to calculate the el-loc multibody terms of various order.
1883 if (i .lt. nres+1) then
1920 if (i .gt. 3 .and. i .lt. nres+1) then
1921 obrot_der(1,i-2)=-sin1
1922 obrot_der(2,i-2)= cos1
1923 Ugder(1,1,i-2)= sin1
1924 Ugder(1,2,i-2)=-cos1
1925 Ugder(2,1,i-2)=-cos1
1926 Ugder(2,2,i-2)=-sin1
1929 obrot2_der(1,i-2)=-dwasin2
1930 obrot2_der(2,i-2)= dwacos2
1931 Ug2der(1,1,i-2)= dwasin2
1932 Ug2der(1,2,i-2)=-dwacos2
1933 Ug2der(2,1,i-2)=-dwacos2
1934 Ug2der(2,2,i-2)=-dwasin2
1936 obrot_der(1,i-2)=0.0d0
1937 obrot_der(2,i-2)=0.0d0
1938 Ugder(1,1,i-2)=0.0d0
1939 Ugder(1,2,i-2)=0.0d0
1940 Ugder(2,1,i-2)=0.0d0
1941 Ugder(2,2,i-2)=0.0d0
1942 obrot2_der(1,i-2)=0.0d0
1943 obrot2_der(2,i-2)=0.0d0
1944 Ug2der(1,1,i-2)=0.0d0
1945 Ug2der(1,2,i-2)=0.0d0
1946 Ug2der(2,1,i-2)=0.0d0
1947 Ug2der(2,2,i-2)=0.0d0
1949 if (i.gt. nnt+2 .and. i.lt.nct+2) then
1950 if (itype(i-2).le.ntyp) then
1951 iti = itortyp(itype(i-2))
1958 if (i.gt. nnt+1 .and. i.lt.nct+1) then
1959 if (itype(i-1).le.ntyp) then
1960 iti1 = itortyp(itype(i-1))
1967 cd write (iout,*) '*******i',i,' iti1',iti
1968 cd write (iout,*) 'b1',b1(:,iti)
1969 cd write (iout,*) 'b2',b2(:,iti)
1970 cd write (iout,*) 'Ug',Ug(:,:,i-2)
1971 c print *,"itilde1 i iti iti1",i,iti,iti1
1972 if (i .gt. iatel_s+2) then
1973 call matvec2(Ug(1,1,i-2),b2(1,iti),Ub2(1,i-2))
1974 call matmat2(EE(1,1,iti),Ug(1,1,i-2),EUg(1,1,i-2))
1975 call matmat2(CC(1,1,iti),Ug(1,1,i-2),CUg(1,1,i-2))
1976 call matmat2(DD(1,1,iti),Ug(1,1,i-2),DUg(1,1,i-2))
1977 call matmat2(Dtilde(1,1,iti),Ug2(1,1,i-2),DtUg2(1,1,i-2))
1978 call matvec2(Ctilde(1,1,iti1),obrot(1,i-2),Ctobr(1,i-2))
1979 call matvec2(Dtilde(1,1,iti),obrot2(1,i-2),Dtobr2(1,i-2))
1989 DtUg2(l,k,i-2)=0.0d0
1993 c print *,"itilde2 i iti iti1",i,iti,iti1
1994 call matvec2(Ugder(1,1,i-2),b2(1,iti),Ub2der(1,i-2))
1995 call matmat2(EE(1,1,iti),Ugder(1,1,i-2),EUgder(1,1,i-2))
1996 call matmat2(CC(1,1,iti1),Ugder(1,1,i-2),CUgder(1,1,i-2))
1997 call matmat2(DD(1,1,iti),Ugder(1,1,i-2),DUgder(1,1,i-2))
1998 call matmat2(Dtilde(1,1,iti),Ug2der(1,1,i-2),DtUg2der(1,1,i-2))
1999 call matvec2(Ctilde(1,1,iti1),obrot_der(1,i-2),Ctobrder(1,i-2))
2000 call matvec2(Dtilde(1,1,iti),obrot2_der(1,i-2),Dtobr2der(1,i-2))
2001 c print *,"itilde3 i iti iti1",i,iti,iti1
2003 muder(k,i-2)=Ub2der(k,i-2)
2005 if (i.gt. nnt+1 .and. i.lt.nct+1) then
2006 if (itype(i-1).le.ntyp) then
2007 iti1 = itortyp(itype(i-1))
2015 mu(k,i-2)=Ub2(k,i-2)+b1(k,iti1)
2017 C write (iout,*) 'mumu',i,b1(1,iti),Ub2(1,i-2)
2019 C Vectors and matrices dependent on a single virtual-bond dihedral.
2020 call matvec2(DD(1,1,iti),b1tilde(1,iti1),auxvec(1))
2021 call matvec2(Ug2(1,1,i-2),auxvec(1),Ug2Db1t(1,i-2))
2022 call matvec2(Ug2der(1,1,i-2),auxvec(1),Ug2Db1tder(1,i-2))
2023 call matvec2(CC(1,1,iti1),Ub2(1,i-2),CUgb2(1,i-2))
2024 call matvec2(CC(1,1,iti1),Ub2der(1,i-2),CUgb2der(1,i-2))
2025 call matmat2(EUg(1,1,i-2),CC(1,1,iti1),EUgC(1,1,i-2))
2026 call matmat2(EUgder(1,1,i-2),CC(1,1,iti1),EUgCder(1,1,i-2))
2027 call matmat2(EUg(1,1,i-2),DD(1,1,iti1),EUgD(1,1,i-2))
2028 call matmat2(EUgder(1,1,i-2),DD(1,1,iti1),EUgDder(1,1,i-2))
2029 cd write (iout,*) 'i',i,' mu ',(mu(k,i-2),k=1,2),
2030 cd & ' mu1',(b1(k,i-2),k=1,2),' mu2',(Ub2(k,i-2),k=1,2)
2032 C Matrices dependent on two consecutive virtual-bond dihedrals.
2033 C The order of matrices is from left to right.
2035 call matmat2(DtUg2(1,1,i-1),EUg(1,1,i),DtUg2EUg(1,1,i))
2036 call matmat2(DtUg2der(1,1,i-1),EUg(1,1,i),DtUg2EUgder(1,1,1,i))
2037 call matmat2(DtUg2(1,1,i-1),EUgder(1,1,i),DtUg2EUgder(1,1,2,i))
2038 call transpose2(DtUg2(1,1,i-1),auxmat(1,1))
2039 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUg(1,1,i))
2040 call matmat2(auxmat(1,1),EUgder(1,1,i),Ug2DtEUgder(1,1,2,i))
2041 call transpose2(DtUg2der(1,1,i-1),auxmat(1,1))
2042 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUgder(1,1,1,i))
2045 cd iti = itortyp(itype(i))
2048 cd write (iout,'(2f10.5,5x,2f10.5,5x,2f10.5)')
2049 cd & (EE(j,k,iti),k=1,2),(Ug(j,k,i),k=1,2),(EUg(j,k,i),k=1,2)
2054 C--------------------------------------------------------------------------
2055 subroutine eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
2057 C This subroutine calculates the average interaction energy and its gradient
2058 C in the virtual-bond vectors between non-adjacent peptide groups, based on
2059 C the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
2060 C The potential depends both on the distance of peptide-group centers and on
2061 C the orientation of the CA-CA virtual bonds.
2063 implicit real*8 (a-h,o-z)
2064 include 'DIMENSIONS'
2065 include 'DIMENSIONS.ZSCOPT'
2066 include 'COMMON.CONTROL'
2067 include 'COMMON.IOUNITS'
2068 include 'COMMON.GEO'
2069 include 'COMMON.VAR'
2070 include 'COMMON.LOCAL'
2071 include 'COMMON.CHAIN'
2072 include 'COMMON.DERIV'
2073 include 'COMMON.INTERACT'
2074 include 'COMMON.CONTACTS'
2075 include 'COMMON.TORSION'
2076 include 'COMMON.VECTORS'
2077 include 'COMMON.FFIELD'
2078 include 'COMMON.SHIELD'
2079 dimension ggg(3),gggp(3),gggm(3),erij(3),dcosb(3),dcosg(3),
2080 & erder(3,3),uryg(3,3),urzg(3,3),vryg(3,3),vrzg(3,3)
2081 double precision acipa(2,2),agg(3,4),aggi(3,4),aggi1(3,4),
2082 & aggj(3,4),aggj1(3,4),a_temp(2,2),muij(4)
2083 common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,j1
2084 c 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
2085 double precision scal_el /0.5d0/
2087 C 13-go grudnia roku pamietnego...
2088 double precision unmat(3,3) /1.0d0,0.0d0,0.0d0,
2089 & 0.0d0,1.0d0,0.0d0,
2090 & 0.0d0,0.0d0,1.0d0/
2091 cd write(iout,*) 'In EELEC'
2093 cd write(iout,*) 'Type',i
2094 cd write(iout,*) 'B1',B1(:,i)
2095 cd write(iout,*) 'B2',B2(:,i)
2096 cd write(iout,*) 'CC',CC(:,:,i)
2097 cd write(iout,*) 'DD',DD(:,:,i)
2098 cd write(iout,*) 'EE',EE(:,:,i)
2100 cd call check_vecgrad
2102 if (icheckgrad.eq.1) then
2104 fac=1.0d0/dsqrt(scalar(dc(1,i),dc(1,i)))
2106 dc_norm(k,i)=dc(k,i)*fac
2108 c write (iout,*) 'i',i,' fac',fac
2111 if (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0
2112 & .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 .or.
2113 & wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) then
2114 cd if (wel_loc.gt.0.0d0) then
2115 if (icheckgrad.eq.1) then
2116 call vec_and_deriv_test
2123 cd write (iout,*) 'i=',i
2125 cd write (iout,'(i5,2f10.5)') k,uy(k,i),uz(k,i)
2128 cd write (iout,'(f10.5,2x,3f10.5,2x,3f10.5)')
2129 cd & uz(k,i),(uzgrad(k,l,1,i),l=1,3),(uzgrad(k,l,2,i),l=1,3)
2142 C print '(a)','Enter EELEC'
2143 C write (iout,*) 'iatel_s=',iatel_s,' iatel_e=',iatel_e
2145 gel_loc_loc(i)=0.0d0
2148 do i=iatel_s,iatel_e
2150 if (itype(i).eq.ntyp1.or. itype(i+1).eq.ntyp1
2151 C & .or. itype(i+2).eq.ntyp1) cycle
2153 C if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1
2154 C & .or. itype(i+2).eq.ntyp1
2155 C & .or. itype(i-1).eq.ntyp1
2158 if (itel(i).eq.0) goto 1215
2162 dx_normi=dc_norm(1,i)
2163 dy_normi=dc_norm(2,i)
2164 dz_normi=dc_norm(3,i)
2165 xmedi=c(1,i)+0.5d0*dxi
2166 ymedi=c(2,i)+0.5d0*dyi
2167 zmedi=c(3,i)+0.5d0*dzi
2168 xmedi=mod(xmedi,boxxsize)
2169 if (xmedi.lt.0) xmedi=xmedi+boxxsize
2170 ymedi=mod(ymedi,boxysize)
2171 if (ymedi.lt.0) ymedi=ymedi+boxysize
2172 zmedi=mod(zmedi,boxzsize)
2173 if (zmedi.lt.0) zmedi=zmedi+boxzsize
2175 C write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
2176 do j=ielstart(i),ielend(i)
2178 C if (itype(j).eq.ntyp1 .or. itype(j+1).eq.ntyp1
2179 C & .or.itype(j+2).eq.ntyp1
2182 if (itype(j).eq.ntyp1 .or. itype(j+1).eq.ntyp1
2183 C & .or.itype(j+2).eq.ntyp1
2184 C & .or.itype(j-1).eq.ntyp1
2189 if (itel(j).eq.0) goto 1216
2193 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
2194 aaa=app(iteli,itelj)
2195 bbb=bpp(iteli,itelj)
2196 C Diagnostics only!!!
2202 ael6i=ael6(iteli,itelj)
2203 ael3i=ael3(iteli,itelj)
2207 dx_normj=dc_norm(1,j)
2208 dy_normj=dc_norm(2,j)
2209 dz_normj=dc_norm(3,j)
2214 if (xj.lt.0) xj=xj+boxxsize
2216 if (yj.lt.0) yj=yj+boxysize
2218 if (zj.lt.0) zj=zj+boxzsize
2219 dist_init=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
2227 xj=xj_safe+xshift*boxxsize
2228 yj=yj_safe+yshift*boxysize
2229 zj=zj_safe+zshift*boxzsize
2230 dist_temp=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
2231 if(dist_temp.lt.dist_init) then
2241 if (isubchap.eq.1) then
2250 rij=xj*xj+yj*yj+zj*zj
2251 sss=sscale(sqrt(rij))
2252 sssgrad=sscagrad(sqrt(rij))
2258 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
2259 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
2260 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
2261 fac=cosa-3.0D0*cosb*cosg
2263 c 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
2264 if (j.eq.i+2) ev1=scal_el*ev1
2269 el1=fac3*(4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg))
2272 c write (iout,*) "i",i,iteli," j",j,itelj," eesij",eesij
2273 C 12/26/95 - for the evaluation of multi-body H-bonding interactions
2274 ees0ij=4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg)
2275 if (shield_mode.gt.0) then
2278 el1=el1*fac_shield(i)**2*fac_shield(j)**2
2279 el2=el2*fac_shield(i)**2*fac_shield(j)**2
2288 evdw1=evdw1+evdwij*sss
2289 c write (iout,'(a6,2i5,0pf7.3,2i5,2e11.3)')
2290 c &'evdw1',i,j,evdwij
2291 c &,iteli,itelj,aaa,evdw1
2293 C write (iout,'(a6,2i5,0pf7.3)') 'ees',i,j,eesij
2294 c write(iout,'(2(2i3,2x),7(1pd12.4)/2(3(1pd12.4),5x)/)')
2295 c & iteli,i,itelj,j,aaa,bbb,ael6i,ael3i,
2296 c & 1.0D0/dsqrt(rrmij),evdwij,eesij,
2297 c & xmedi,ymedi,zmedi,xj,yj,zj
2299 C Calculate contributions to the Cartesian gradient.
2302 facvdw=-6*rrmij*(ev1+evdwij)*sss
2303 facel=-3*rrmij*(el1+eesij)
2310 * Radial derivatives. First process both termini of the fragment (i,j)
2315 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and.
2316 & (shield_mode.gt.0)) then
2318 do ilist=1,ishield_list(i)
2319 iresshield=shield_list(ilist,i)
2321 rlocshield=grad_shield_side(k,ilist,i)*eesij/fac_shield(i)
2323 gshieldx(k,iresshield)=gshieldx(k,iresshield)+
2325 & +grad_shield_loc(k,ilist,i)*eesij/fac_shield(i)*2.0
2326 gshieldc(k,iresshield-1)=gshieldc(k,iresshield-1)+rlocshield
2327 C gshieldc_loc(k,iresshield)=gshieldc_loc(k,iresshield)
2328 C & +grad_shield_loc(k,ilist,i)*eesij/fac_shield(i)
2329 C if (iresshield.gt.i) then
2330 C do ishi=i+1,iresshield-1
2331 C gshieldc(k,ishi)=gshieldc(k,ishi)+rlocshield
2332 C & +grad_shield_loc(k,ilist,i)*eesij/fac_shield(i)
2336 C do ishi=iresshield,i
2337 C gshieldc(k,ishi)=gshieldc(k,ishi)-rlocshield
2338 C & -grad_shield_loc(k,ilist,i)*eesij/fac_shield(i)
2344 do ilist=1,ishield_list(j)
2345 iresshield=shield_list(ilist,j)
2347 rlocshield=grad_shield_side(k,ilist,j)*eesij/fac_shield(j)
2349 gshieldx(k,iresshield)=gshieldx(k,iresshield)+
2351 & +grad_shield_loc(k,ilist,j)*eesij/fac_shield(j)*2.0
2352 gshieldc(k,iresshield-1)=gshieldc(k,iresshield-1)+rlocshield
2357 gshieldc(k,i)=gshieldc(k,i)+
2358 & grad_shield(k,i)*eesij/fac_shield(i)*2.0
2359 gshieldc(k,j)=gshieldc(k,j)+
2360 & grad_shield(k,j)*eesij/fac_shield(j)*2.0
2361 gshieldc(k,i-1)=gshieldc(k,i-1)+
2362 & grad_shield(k,i)*eesij/fac_shield(i)*2.0
2363 gshieldc(k,j-1)=gshieldc(k,j-1)+
2364 & grad_shield(k,j)*eesij/fac_shield(j)*2.0
2371 gelc(k,i)=gelc(k,i)+ghalf
2372 gelc(k,j)=gelc(k,j)+ghalf
2375 * Loop over residues i+1 thru j-1.
2379 gelc(l,k)=gelc(l,k)+ggg(l)
2385 if (sss.gt.0.0) then
2386 ggg(1)=facvdw*xj+sssgrad*rmij*evdwij*xj
2387 ggg(2)=facvdw*yj+sssgrad*rmij*evdwij*yj
2388 ggg(3)=facvdw*zj+sssgrad*rmij*evdwij*zj
2396 gvdwpp(k,i)=gvdwpp(k,i)+ghalf
2397 gvdwpp(k,j)=gvdwpp(k,j)+ghalf
2400 * Loop over residues i+1 thru j-1.
2404 gvdwpp(l,k)=gvdwpp(l,k)+ggg(l)
2408 facvdw=(ev1+evdwij)*sss
2411 fac=-3*rrmij*(facvdw+facvdw+facel)
2417 * Radial derivatives. First process both termini of the fragment (i,j)
2424 gelc(k,i)=gelc(k,i)+ghalf
2425 gelc(k,j)=gelc(k,j)+ghalf
2428 * Loop over residues i+1 thru j-1.
2432 gelc(l,k)=gelc(l,k)+ggg(l)
2439 ecosa=2.0D0*fac3*fac1+fac4
2442 ecosb=(fac3*(fac1*cosg+cosb)+cosg*fac4)
2443 ecosg=(fac3*(fac1*cosb+cosg)+cosb*fac4)
2445 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
2446 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
2448 cd print '(2i3,2(3(1pd14.5),3x))',i,j,(dcosb(k),k=1,3),
2449 cd & (dcosg(k),k=1,3)
2451 ggg(k)=ecosb*dcosb(k)+ecosg*dcosg(k)
2452 & *fac_shield(i)**2*fac_shield(j)**2
2456 gelc(k,i)=gelc(k,i)+ghalf
2457 & +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
2458 & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
2459 & *fac_shield(i)**2*fac_shield(j)**2
2461 gelc(k,j)=gelc(k,j)+ghalf
2462 & +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
2463 & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
2464 & *fac_shield(i)**2*fac_shield(j)**2
2468 gelc(l,k)=gelc(l,k)+ggg(l)
2473 IF (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0
2474 & .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0
2475 & .or. wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
2477 C 9/25/99 Mixed third-order local-electrostatic terms. The local-interaction
2478 C energy of a peptide unit is assumed in the form of a second-order
2479 C Fourier series in the angles lambda1 and lambda2 (see Nishikawa et al.
2480 C Macromolecules, 1974, 7, 797-806 for definition). This correlation terms
2481 C are computed for EVERY pair of non-contiguous peptide groups.
2483 if (j.lt.nres-1) then
2494 muij(kkk)=mu(k,i)*mu(l,j)
2497 cd write (iout,*) 'EELEC: i',i,' j',j
2498 cd write (iout,*) 'j',j,' j1',j1,' j2',j2
2499 cd write(iout,*) 'muij',muij
2500 ury=scalar(uy(1,i),erij)
2501 urz=scalar(uz(1,i),erij)
2502 vry=scalar(uy(1,j),erij)
2503 vrz=scalar(uz(1,j),erij)
2504 a22=scalar(uy(1,i),uy(1,j))-3*ury*vry
2505 a23=scalar(uy(1,i),uz(1,j))-3*ury*vrz
2506 a32=scalar(uz(1,i),uy(1,j))-3*urz*vry
2507 a33=scalar(uz(1,i),uz(1,j))-3*urz*vrz
2508 C For diagnostics only
2513 fac=dsqrt(-ael6i)*r3ij
2514 cd write (2,*) 'fac=',fac
2515 C For diagnostics only
2521 cd write (iout,'(4i5,4f10.5)')
2522 cd & i,itortyp(itype(i)),j,itortyp(itype(j)),a22,a23,a32,a33
2523 cd write (iout,'(6f10.5)') (muij(k),k=1,4),fac,eel_loc_ij
2524 cd write (iout,'(2(3f10.5,5x)/2(3f10.5,5x))') (uy(k,i),k=1,3),
2525 cd & (uz(k,i),k=1,3),(uy(k,j),k=1,3),(uz(k,j),k=1,3)
2526 cd write (iout,'(4f10.5)')
2527 cd & scalar(uy(1,i),uy(1,j)),scalar(uy(1,i),uz(1,j)),
2528 cd & scalar(uz(1,i),uy(1,j)),scalar(uz(1,i),uz(1,j))
2529 cd write (iout,'(4f10.5)') ury,urz,vry,vrz
2530 cd write (iout,'(2i3,9f10.5/)') i,j,
2531 cd & fac22,a22,fac23,a23,fac32,a32,fac33,a33,eel_loc_ij
2533 C Derivatives of the elements of A in virtual-bond vectors
2534 call unormderiv(erij(1),unmat(1,1),rmij,erder(1,1))
2541 uryg(k,1)=scalar(erder(1,k),uy(1,i))
2542 uryg(k,2)=scalar(uygrad(1,k,1,i),erij(1))
2543 uryg(k,3)=scalar(uygrad(1,k,2,i),erij(1))
2544 urzg(k,1)=scalar(erder(1,k),uz(1,i))
2545 urzg(k,2)=scalar(uzgrad(1,k,1,i),erij(1))
2546 urzg(k,3)=scalar(uzgrad(1,k,2,i),erij(1))
2547 vryg(k,1)=scalar(erder(1,k),uy(1,j))
2548 vryg(k,2)=scalar(uygrad(1,k,1,j),erij(1))
2549 vryg(k,3)=scalar(uygrad(1,k,2,j),erij(1))
2550 vrzg(k,1)=scalar(erder(1,k),uz(1,j))
2551 vrzg(k,2)=scalar(uzgrad(1,k,1,j),erij(1))
2552 vrzg(k,3)=scalar(uzgrad(1,k,2,j),erij(1))
2562 C Compute radial contributions to the gradient
2584 C Add the contributions coming from er
2587 agg(k,1)=agg(k,1)+fac3*(uryg(k,1)*vry+vryg(k,1)*ury)
2588 agg(k,2)=agg(k,2)+fac3*(uryg(k,1)*vrz+vrzg(k,1)*ury)
2589 agg(k,3)=agg(k,3)+fac3*(urzg(k,1)*vry+vryg(k,1)*urz)
2590 agg(k,4)=agg(k,4)+fac3*(urzg(k,1)*vrz+vrzg(k,1)*urz)
2593 C Derivatives in DC(i)
2594 ghalf1=0.5d0*agg(k,1)
2595 ghalf2=0.5d0*agg(k,2)
2596 ghalf3=0.5d0*agg(k,3)
2597 ghalf4=0.5d0*agg(k,4)
2598 aggi(k,1)=fac*(scalar(uygrad(1,k,1,i),uy(1,j))
2599 & -3.0d0*uryg(k,2)*vry)+ghalf1
2600 aggi(k,2)=fac*(scalar(uygrad(1,k,1,i),uz(1,j))
2601 & -3.0d0*uryg(k,2)*vrz)+ghalf2
2602 aggi(k,3)=fac*(scalar(uzgrad(1,k,1,i),uy(1,j))
2603 & -3.0d0*urzg(k,2)*vry)+ghalf3
2604 aggi(k,4)=fac*(scalar(uzgrad(1,k,1,i),uz(1,j))
2605 & -3.0d0*urzg(k,2)*vrz)+ghalf4
2606 C Derivatives in DC(i+1)
2607 aggi1(k,1)=fac*(scalar(uygrad(1,k,2,i),uy(1,j))
2608 & -3.0d0*uryg(k,3)*vry)+agg(k,1)
2609 aggi1(k,2)=fac*(scalar(uygrad(1,k,2,i),uz(1,j))
2610 & -3.0d0*uryg(k,3)*vrz)+agg(k,2)
2611 aggi1(k,3)=fac*(scalar(uzgrad(1,k,2,i),uy(1,j))
2612 & -3.0d0*urzg(k,3)*vry)+agg(k,3)
2613 aggi1(k,4)=fac*(scalar(uzgrad(1,k,2,i),uz(1,j))
2614 & -3.0d0*urzg(k,3)*vrz)+agg(k,4)
2615 C Derivatives in DC(j)
2616 aggj(k,1)=fac*(scalar(uygrad(1,k,1,j),uy(1,i))
2617 & -3.0d0*vryg(k,2)*ury)+ghalf1
2618 aggj(k,2)=fac*(scalar(uzgrad(1,k,1,j),uy(1,i))
2619 & -3.0d0*vrzg(k,2)*ury)+ghalf2
2620 aggj(k,3)=fac*(scalar(uygrad(1,k,1,j),uz(1,i))
2621 & -3.0d0*vryg(k,2)*urz)+ghalf3
2622 aggj(k,4)=fac*(scalar(uzgrad(1,k,1,j),uz(1,i))
2623 & -3.0d0*vrzg(k,2)*urz)+ghalf4
2624 C Derivatives in DC(j+1) or DC(nres-1)
2625 aggj1(k,1)=fac*(scalar(uygrad(1,k,2,j),uy(1,i))
2626 & -3.0d0*vryg(k,3)*ury)
2627 aggj1(k,2)=fac*(scalar(uzgrad(1,k,2,j),uy(1,i))
2628 & -3.0d0*vrzg(k,3)*ury)
2629 aggj1(k,3)=fac*(scalar(uygrad(1,k,2,j),uz(1,i))
2630 & -3.0d0*vryg(k,3)*urz)
2631 aggj1(k,4)=fac*(scalar(uzgrad(1,k,2,j),uz(1,i))
2632 & -3.0d0*vrzg(k,3)*urz)
2637 C Derivatives in DC(i+1)
2638 cd aggi1(k,1)=agg(k,1)
2639 cd aggi1(k,2)=agg(k,2)
2640 cd aggi1(k,3)=agg(k,3)
2641 cd aggi1(k,4)=agg(k,4)
2642 C Derivatives in DC(j)
2647 C Derivatives in DC(j+1)
2652 if (j.eq.nres-1 .and. i.lt.j-2) then
2654 aggj1(k,l)=aggj1(k,l)+agg(k,l)
2655 cd aggj1(k,l)=agg(k,l)
2661 C Check the loc-el terms by numerical integration
2671 aggi(k,l)=-aggi(k,l)
2672 aggi1(k,l)=-aggi1(k,l)
2673 aggj(k,l)=-aggj(k,l)
2674 aggj1(k,l)=-aggj1(k,l)
2677 if (j.lt.nres-1) then
2683 aggi(k,l)=-aggi(k,l)
2684 aggi1(k,l)=-aggi1(k,l)
2685 aggj(k,l)=-aggj(k,l)
2686 aggj1(k,l)=-aggj1(k,l)
2697 aggi(k,l)=-aggi(k,l)
2698 aggi1(k,l)=-aggi1(k,l)
2699 aggj(k,l)=-aggj(k,l)
2700 aggj1(k,l)=-aggj1(k,l)
2706 IF (wel_loc.gt.0.0d0) THEN
2707 C Contribution to the local-electrostatic energy coming from the i-j pair
2708 eel_loc_ij=a22*muij(1)+a23*muij(2)+a32*muij(3)
2710 if (shield_mode.eq.0) then
2717 eel_loc_ij=eel_loc_ij
2718 & *fac_shield(i)*fac_shield(j)
2719 c write (iout,*) 'i',i,' j',j,' eel_loc_ij',eel_loc_ij
2720 C write (iout,'(a6,2i5,0pf7.3)')
2721 C & 'eelloc',i,j,eel_loc_ij
2722 C write(iout,*) 'muije=',i,j,muij(1),muij(2),muij(3),muij(4)
2723 c write (iout,*) a22,muij(1),a23,muij(2),a32,muij(3)
2724 C eel_loc=eel_loc+eel_loc_ij
2725 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and.
2726 & (shield_mode.gt.0)) then
2729 do ilist=1,ishield_list(i)
2730 iresshield=shield_list(ilist,i)
2732 rlocshield=grad_shield_side(k,ilist,i)*eel_loc_ij
2735 gshieldx_ll(k,iresshield)=gshieldx_ll(k,iresshield)+
2737 & +grad_shield_loc(k,ilist,i)*eel_loc_ij/fac_shield(i)
2738 gshieldc_ll(k,iresshield-1)=gshieldc_ll(k,iresshield-1)
2742 do ilist=1,ishield_list(j)
2743 iresshield=shield_list(ilist,j)
2745 rlocshield=grad_shield_side(k,ilist,j)*eel_loc_ij
2748 gshieldx_ll(k,iresshield)=gshieldx_ll(k,iresshield)+
2750 & +grad_shield_loc(k,ilist,j)*eel_loc_ij/fac_shield(j)
2751 gshieldc_ll(k,iresshield-1)=gshieldc_ll(k,iresshield-1)
2757 gshieldc_ll(k,i)=gshieldc_ll(k,i)+
2758 & grad_shield(k,i)*eel_loc_ij/fac_shield(i)
2759 gshieldc_ll(k,j)=gshieldc_ll(k,j)+
2760 & grad_shield(k,j)*eel_loc_ij/fac_shield(j)
2761 gshieldc_ll(k,i-1)=gshieldc_ll(k,i-1)+
2762 & grad_shield(k,i)*eel_loc_ij/fac_shield(i)
2763 gshieldc_ll(k,j-1)=gshieldc_ll(k,j-1)+
2764 & grad_shield(k,j)*eel_loc_ij/fac_shield(j)
2767 eel_loc=eel_loc+eel_loc_ij
2769 C Partial derivatives in virtual-bond dihedral angles gamma
2772 & gel_loc_loc(i-1)=gel_loc_loc(i-1)+
2773 & (a22*muder(1,i)*mu(1,j)+a23*muder(1,i)*mu(2,j)
2774 & +a32*muder(2,i)*mu(1,j)+a33*muder(2,i)*mu(2,j))
2775 & *fac_shield(i)*fac_shield(j)
2777 gel_loc_loc(j-1)=gel_loc_loc(j-1)+
2778 & (a22*mu(1,i)*muder(1,j)+a23*mu(1,i)*muder(2,j)
2779 & +a32*mu(2,i)*muder(1,j)+a33*mu(2,i)*muder(2,j))
2780 & *fac_shield(i)*fac_shield(j)
2782 cd call checkint3(i,j,mu1,mu2,a22,a23,a32,a33,acipa,eel_loc_ij)
2783 cd write(iout,*) 'agg ',agg
2784 cd write(iout,*) 'aggi ',aggi
2785 cd write(iout,*) 'aggi1',aggi1
2786 cd write(iout,*) 'aggj ',aggj
2787 cd write(iout,*) 'aggj1',aggj1
2789 C Derivatives of eello in DC(i+1) thru DC(j-1) or DC(nres-2)
2791 ggg(l)=(agg(l,1)*muij(1)+
2792 & agg(l,2)*muij(2)+agg(l,3)*muij(3)+agg(l,4)*muij(4))
2793 & *fac_shield(i)*fac_shield(j)
2798 gel_loc(l,k)=gel_loc(l,k)+ggg(l)
2801 C Remaining derivatives of eello
2803 gel_loc(l,i)=gel_loc(l,i)+(aggi(l,1)*muij(1)+
2804 & aggi(l,2)*muij(2)+aggi(l,3)*muij(3)+aggi(l,4)*muij(4))
2805 & *fac_shield(i)*fac_shield(j)
2807 gel_loc(l,i+1)=gel_loc(l,i+1)+(aggi1(l,1)*muij(1)+
2808 & aggi1(l,2)*muij(2)+aggi1(l,3)*muij(3)+aggi1(l,4)*muij(4))
2809 & *fac_shield(i)*fac_shield(j)
2811 gel_loc(l,j)=gel_loc(l,j)+(aggj(l,1)*muij(1)+
2812 & aggj(l,2)*muij(2)+aggj(l,3)*muij(3)+aggj(l,4)*muij(4))
2813 & *fac_shield(i)*fac_shield(j)
2815 gel_loc(l,j1)=gel_loc(l,j1)+(aggj1(l,1)*muij(1)+
2816 & aggj1(l,2)*muij(2)+aggj1(l,3)*muij(3)+aggj1(l,4)*muij(4))
2817 & *fac_shield(i)*fac_shield(j)
2822 if (wturn3.gt.0.0d0 .or. wturn4.gt.0.0d0) then
2823 C Contributions from turns
2828 call eturn34(i,j,eello_turn3,eello_turn4)
2830 C Change 12/26/95 to calculate four-body contributions to H-bonding energy
2831 if (j.gt.i+1 .and. num_conti.le.maxconts) then
2833 C Calculate the contact function. The ith column of the array JCONT will
2834 C contain the numbers of atoms that make contacts with the atom I (of numbers
2835 C greater than I). The arrays FACONT and GACONT will contain the values of
2836 C the contact function and its derivative.
2837 c r0ij=1.02D0*rpp(iteli,itelj)
2838 c r0ij=1.11D0*rpp(iteli,itelj)
2839 r0ij=2.20D0*rpp(iteli,itelj)
2840 c r0ij=1.55D0*rpp(iteli,itelj)
2841 call gcont(rij,r0ij,1.0D0,0.2d0*r0ij,fcont,fprimcont)
2842 if (fcont.gt.0.0D0) then
2843 num_conti=num_conti+1
2844 if (num_conti.gt.maxconts) then
2845 write (iout,*) 'WARNING - max. # of contacts exceeded;',
2846 & ' will skip next contacts for this conf.'
2848 jcont_hb(num_conti,i)=j
2849 IF (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.
2850 & wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
2851 C 9/30/99 (AL) - store components necessary to evaluate higher-order loc-el
2853 d_cont(num_conti,i)=rij
2854 cd write (2,'(3e15.5)') rij,r0ij+0.2d0*r0ij,rij
2855 C --- Electrostatic-interaction matrix ---
2856 a_chuj(1,1,num_conti,i)=a22
2857 a_chuj(1,2,num_conti,i)=a23
2858 a_chuj(2,1,num_conti,i)=a32
2859 a_chuj(2,2,num_conti,i)=a33
2860 C --- Gradient of rij
2862 grij_hb_cont(kkk,num_conti,i)=erij(kkk)
2865 c a_chuj(1,1,num_conti,i)=-0.61d0
2866 c a_chuj(1,2,num_conti,i)= 0.4d0
2867 c a_chuj(2,1,num_conti,i)= 0.65d0
2868 c a_chuj(2,2,num_conti,i)= 0.50d0
2869 c else if (i.eq.2) then
2870 c a_chuj(1,1,num_conti,i)= 0.0d0
2871 c a_chuj(1,2,num_conti,i)= 0.0d0
2872 c a_chuj(2,1,num_conti,i)= 0.0d0
2873 c a_chuj(2,2,num_conti,i)= 0.0d0
2875 C --- and its gradients
2876 cd write (iout,*) 'i',i,' j',j
2878 cd write (iout,*) 'iii 1 kkk',kkk
2879 cd write (iout,*) agg(kkk,:)
2882 cd write (iout,*) 'iii 2 kkk',kkk
2883 cd write (iout,*) aggi(kkk,:)
2886 cd write (iout,*) 'iii 3 kkk',kkk
2887 cd write (iout,*) aggi1(kkk,:)
2890 cd write (iout,*) 'iii 4 kkk',kkk
2891 cd write (iout,*) aggj(kkk,:)
2894 cd write (iout,*) 'iii 5 kkk',kkk
2895 cd write (iout,*) aggj1(kkk,:)
2902 a_chuj_der(k,l,m,1,num_conti,i)=agg(m,kkll)
2903 a_chuj_der(k,l,m,2,num_conti,i)=aggi(m,kkll)
2904 a_chuj_der(k,l,m,3,num_conti,i)=aggi1(m,kkll)
2905 a_chuj_der(k,l,m,4,num_conti,i)=aggj(m,kkll)
2906 a_chuj_der(k,l,m,5,num_conti,i)=aggj1(m,kkll)
2908 c a_chuj_der(k,l,m,mm,num_conti,i)=0.0d0
2914 IF (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) THEN
2915 C Calculate contact energies
2917 wij=cosa-3.0D0*cosb*cosg
2920 c fac3=dsqrt(-ael6i)/r0ij**3
2921 fac3=dsqrt(-ael6i)*r3ij
2922 ees0pij=dsqrt(4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1)
2923 ees0mij=dsqrt(4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2)
2925 if (shield_mode.eq.0) then
2929 ees0plist(num_conti,i)=j
2930 C fac_shield(i)=0.4d0
2931 C fac_shield(j)=0.6d0
2933 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij)
2934 & *fac_shield(i)*fac_shield(j)
2936 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij)
2937 & *fac_shield(i)*fac_shield(j)
2939 C Diagnostics. Comment out or remove after debugging!
2940 c ees0p(num_conti,i)=0.5D0*fac3*ees0pij
2941 c ees0m(num_conti,i)=0.5D0*fac3*ees0mij
2942 c ees0m(num_conti,i)=0.0D0
2944 c write (iout,*) 'i=',i,' j=',j,' rij=',rij,' r0ij=',r0ij,
2945 c & ' ees0ij=',ees0p(num_conti,i),ees0m(num_conti,i),' fcont=',fcont
2946 facont_hb(num_conti,i)=fcont
2948 C Angular derivatives of the contact function
2949 ees0pij1=fac3/ees0pij
2950 ees0mij1=fac3/ees0mij
2951 fac3p=-3.0D0*fac3*rrmij
2952 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
2953 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
2955 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
2956 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
2957 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
2958 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
2959 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
2960 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
2961 ecosap=ecosa1+ecosa2
2962 ecosbp=ecosb1+ecosb2
2963 ecosgp=ecosg1+ecosg2
2964 ecosam=ecosa1-ecosa2
2965 ecosbm=ecosb1-ecosb2
2966 ecosgm=ecosg1-ecosg2
2975 fprimcont=fprimcont/rij
2976 cd facont_hb(num_conti,i)=1.0D0
2977 C Following line is for diagnostics.
2980 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
2981 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
2984 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
2985 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
2987 gggp(1)=gggp(1)+ees0pijp*xj
2988 gggp(2)=gggp(2)+ees0pijp*yj
2989 gggp(3)=gggp(3)+ees0pijp*zj
2990 gggm(1)=gggm(1)+ees0mijp*xj
2991 gggm(2)=gggm(2)+ees0mijp*yj
2992 gggm(3)=gggm(3)+ees0mijp*zj
2993 C Derivatives due to the contact function
2994 gacont_hbr(1,num_conti,i)=fprimcont*xj
2995 gacont_hbr(2,num_conti,i)=fprimcont*yj
2996 gacont_hbr(3,num_conti,i)=fprimcont*zj
2998 ghalfp=0.5D0*gggp(k)
2999 ghalfm=0.5D0*gggm(k)
3000 gacontp_hb1(k,num_conti,i)=ghalfp
3001 & +(ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i))
3002 & + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
3003 & *fac_shield(i)*fac_shield(j)
3005 gacontp_hb2(k,num_conti,i)=ghalfp
3006 & +(ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j))
3007 & + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
3008 & *fac_shield(i)*fac_shield(j)
3010 gacontp_hb3(k,num_conti,i)=gggp(k)
3011 & *fac_shield(i)*fac_shield(j)
3013 gacontm_hb1(k,num_conti,i)=ghalfm
3014 & +(ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i))
3015 & + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
3016 & *fac_shield(i)*fac_shield(j)
3018 gacontm_hb2(k,num_conti,i)=ghalfm
3019 & +(ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j))
3020 & + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
3021 & *fac_shield(i)*fac_shield(j)
3023 gacontm_hb3(k,num_conti,i)=gggm(k)
3024 & *fac_shield(i)*fac_shield(j)
3028 C Diagnostics. Comment out or remove after debugging!
3030 cdiag gacontp_hb1(k,num_conti,i)=0.0D0
3031 cdiag gacontp_hb2(k,num_conti,i)=0.0D0
3032 cdiag gacontp_hb3(k,num_conti,i)=0.0D0
3033 cdiag gacontm_hb1(k,num_conti,i)=0.0D0
3034 cdiag gacontm_hb2(k,num_conti,i)=0.0D0
3035 cdiag gacontm_hb3(k,num_conti,i)=0.0D0
3038 endif ! num_conti.le.maxconts
3043 num_cont_hb(i)=num_conti
3047 cd write (iout,'(i3,3f10.5,5x,3f10.5)')
3048 cd & i,(gel_loc(k,i),k=1,3),gel_loc_loc(i)
3050 c 12/7/99 Adam eello_turn3 will be considered as a separate energy term
3051 ccc eel_loc=eel_loc+eello_turn3
3054 C-----------------------------------------------------------------------------
3055 subroutine eturn34(i,j,eello_turn3,eello_turn4)
3056 C Third- and fourth-order contributions from turns
3057 implicit real*8 (a-h,o-z)
3058 include 'DIMENSIONS'
3059 include 'DIMENSIONS.ZSCOPT'
3060 include 'COMMON.IOUNITS'
3061 include 'COMMON.GEO'
3062 include 'COMMON.VAR'
3063 include 'COMMON.LOCAL'
3064 include 'COMMON.CHAIN'
3065 include 'COMMON.DERIV'
3066 include 'COMMON.INTERACT'
3067 include 'COMMON.CONTACTS'
3068 include 'COMMON.TORSION'
3069 include 'COMMON.VECTORS'
3070 include 'COMMON.FFIELD'
3071 include 'COMMON.SHIELD'
3072 include 'COMMON.CONTROL'
3074 double precision auxmat(2,2),auxmat1(2,2),auxmat2(2,2),pizda(2,2),
3075 & e1t(2,2),e2t(2,2),e3t(2,2),e1tder(2,2),e2tder(2,2),e3tder(2,2),
3076 & e1a(2,2),ae3(2,2),ae3e2(2,2),auxvec(2),auxvec1(2)
3077 double precision agg(3,4),aggi(3,4),aggi1(3,4),
3078 & aggj(3,4),aggj1(3,4),a_temp(2,2)
3079 common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,j1,j2
3081 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1
3082 C changes suggested by Ana to avoid out of bounds
3083 C & .or.((i+5).gt.nres)
3084 C & .or.((i-1).le.0)
3085 C end of changes suggested by Ana
3086 & .or. itype(i+2).eq.ntyp1
3087 & .or. itype(i+3).eq.ntyp1
3088 C & .or. itype(i+5).eq.ntyp1
3089 C & .or. itype(i).eq.ntyp1
3090 C & .or. itype(i-1).eq.ntyp1
3093 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
3095 C Third-order contributions
3102 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
3103 cd call checkint_turn3(i,a_temp,eello_turn3_num)
3104 call matmat2(EUg(1,1,i+1),EUg(1,1,i+2),auxmat(1,1))
3105 call transpose2(auxmat(1,1),auxmat1(1,1))
3106 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
3107 if (shield_mode.eq.0) then
3115 eello_turn3=eello_turn3+0.5d0*(pizda(1,1)+pizda(2,2))
3116 & *fac_shield(i)*fac_shield(j)
3117 eello_t3=0.5d0*(pizda(1,1)+pizda(2,2))
3118 & *fac_shield(i)*fac_shield(j)
3120 cd write (2,*) 'i,',i,' j',j,'eello_turn3',
3121 cd & 0.5d0*(pizda(1,1)+pizda(2,2)),
3122 cd & ' eello_turn3_num',4*eello_turn3_num
3124 C Derivatives in shield mode
3125 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and.
3126 & (shield_mode.gt.0)) then
3129 do ilist=1,ishield_list(i)
3130 iresshield=shield_list(ilist,i)
3132 rlocshield=grad_shield_side(k,ilist,i)*eello_t3/fac_shield(i)
3134 gshieldx_t3(k,iresshield)=gshieldx_t3(k,iresshield)+
3136 & +grad_shield_loc(k,ilist,i)*eello_t3/fac_shield(i)
3137 gshieldc_t3(k,iresshield-1)=gshieldc_t3(k,iresshield-1)
3141 do ilist=1,ishield_list(j)
3142 iresshield=shield_list(ilist,j)
3144 rlocshield=grad_shield_side(k,ilist,j)*eello_t3/fac_shield(j)
3146 gshieldx_t3(k,iresshield)=gshieldx_t3(k,iresshield)+
3148 & +grad_shield_loc(k,ilist,j)*eello_t3/fac_shield(j)
3149 gshieldc_t3(k,iresshield-1)=gshieldc_t3(k,iresshield-1)
3156 gshieldc_t3(k,i)=gshieldc_t3(k,i)+
3157 & grad_shield(k,i)*eello_t3/fac_shield(i)
3158 gshieldc_t3(k,j)=gshieldc_t3(k,j)+
3159 & grad_shield(k,j)*eello_t3/fac_shield(j)
3160 gshieldc_t3(k,i-1)=gshieldc_t3(k,i-1)+
3161 & grad_shield(k,i)*eello_t3/fac_shield(i)
3162 gshieldc_t3(k,j-1)=gshieldc_t3(k,j-1)+
3163 & grad_shield(k,j)*eello_t3/fac_shield(j)
3167 C Derivatives in gamma(i)
3168 call matmat2(EUgder(1,1,i+1),EUg(1,1,i+2),auxmat2(1,1))
3169 call transpose2(auxmat2(1,1),pizda(1,1))
3170 call matmat2(a_temp(1,1),pizda(1,1),pizda(1,1))
3171 gel_loc_turn3(i)=gel_loc_turn3(i)+0.5d0*(pizda(1,1)+pizda(2,2))
3172 & *fac_shield(i)*fac_shield(j)
3173 C Derivatives in gamma(i+1)
3174 call matmat2(EUg(1,1,i+1),EUgder(1,1,i+2),auxmat2(1,1))
3175 call transpose2(auxmat2(1,1),pizda(1,1))
3176 call matmat2(a_temp(1,1),pizda(1,1),pizda(1,1))
3177 gel_loc_turn3(i+1)=gel_loc_turn3(i+1)
3178 & +0.5d0*(pizda(1,1)+pizda(2,2))
3179 & *fac_shield(i)*fac_shield(j)
3181 C Cartesian derivatives
3183 a_temp(1,1)=aggi(l,1)
3184 a_temp(1,2)=aggi(l,2)
3185 a_temp(2,1)=aggi(l,3)
3186 a_temp(2,2)=aggi(l,4)
3187 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
3188 gcorr3_turn(l,i)=gcorr3_turn(l,i)
3189 & +0.5d0*(pizda(1,1)+pizda(2,2))
3190 & *fac_shield(i)*fac_shield(j)
3192 a_temp(1,1)=aggi1(l,1)
3193 a_temp(1,2)=aggi1(l,2)
3194 a_temp(2,1)=aggi1(l,3)
3195 a_temp(2,2)=aggi1(l,4)
3196 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
3197 gcorr3_turn(l,i+1)=gcorr3_turn(l,i+1)
3198 & +0.5d0*(pizda(1,1)+pizda(2,2))
3199 & *fac_shield(i)*fac_shield(j)
3201 a_temp(1,1)=aggj(l,1)
3202 a_temp(1,2)=aggj(l,2)
3203 a_temp(2,1)=aggj(l,3)
3204 a_temp(2,2)=aggj(l,4)
3205 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
3206 gcorr3_turn(l,j)=gcorr3_turn(l,j)
3207 & +0.5d0*(pizda(1,1)+pizda(2,2))
3208 & *fac_shield(i)*fac_shield(j)
3210 a_temp(1,1)=aggj1(l,1)
3211 a_temp(1,2)=aggj1(l,2)
3212 a_temp(2,1)=aggj1(l,3)
3213 a_temp(2,2)=aggj1(l,4)
3214 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
3215 gcorr3_turn(l,j1)=gcorr3_turn(l,j1)
3216 & +0.5d0*(pizda(1,1)+pizda(2,2))
3217 & *fac_shield(i)*fac_shield(j)
3222 else if (j.eq.i+3 .and. itype(i+2).ne.ntyp1) then
3223 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1
3224 C changes suggested by Ana to avoid out of bounds
3225 C & .or.((i+5).gt.nres)
3226 C & .or.((i-1).le.0)
3227 C end of changes suggested by Ana
3228 & .or. itype(i+3).eq.ntyp1
3229 & .or. itype(i+4).eq.ntyp1
3230 C & .or. itype(i+5).eq.ntyp1
3231 & .or. itype(i).eq.ntyp1
3232 C & .or. itype(i-1).eq.ntyp1
3234 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
3236 C Fourth-order contributions
3244 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
3245 cd call checkint_turn4(i,a_temp,eello_turn4_num)
3246 iti1=itortyp(itype(i+1))
3247 iti2=itortyp(itype(i+2))
3248 iti3=itortyp(itype(i+3))
3249 call transpose2(EUg(1,1,i+1),e1t(1,1))
3250 call transpose2(Eug(1,1,i+2),e2t(1,1))
3251 call transpose2(Eug(1,1,i+3),e3t(1,1))
3252 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
3253 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
3254 s1=scalar2(b1(1,iti2),auxvec(1))
3255 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
3256 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
3257 s2=scalar2(b1(1,iti1),auxvec(1))
3258 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
3259 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
3260 s3=0.5d0*(pizda(1,1)+pizda(2,2))
3261 if (shield_mode.eq.0) then
3269 eello_turn4=eello_turn4-(s1+s2+s3)
3270 & *fac_shield(i)*fac_shield(j)
3271 eello_t4=-(s1+s2+s3)
3272 & *fac_shield(i)*fac_shield(j)
3274 cd write (2,*) 'i,',i,' j',j,'eello_turn4',-(s1+s2+s3),
3275 cd & ' eello_turn4_num',8*eello_turn4_num
3276 C Derivatives in gamma(i)
3278 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and.
3279 & (shield_mode.gt.0)) then
3282 do ilist=1,ishield_list(i)
3283 iresshield=shield_list(ilist,i)
3285 rlocshield=grad_shield_side(k,ilist,i)*eello_t4/fac_shield(i)
3287 gshieldx_t4(k,iresshield)=gshieldx_t4(k,iresshield)+
3289 & +grad_shield_loc(k,ilist,i)*eello_t4/fac_shield(i)
3290 gshieldc_t4(k,iresshield-1)=gshieldc_t4(k,iresshield-1)
3294 do ilist=1,ishield_list(j)
3295 iresshield=shield_list(ilist,j)
3297 rlocshield=grad_shield_side(k,ilist,j)*eello_t4/fac_shield(j)
3299 gshieldx_t4(k,iresshield)=gshieldx_t4(k,iresshield)+
3301 & +grad_shield_loc(k,ilist,j)*eello_t4/fac_shield(j)
3302 gshieldc_t4(k,iresshield-1)=gshieldc_t4(k,iresshield-1)
3309 gshieldc_t4(k,i)=gshieldc_t4(k,i)+
3310 & grad_shield(k,i)*eello_t4/fac_shield(i)
3311 gshieldc_t4(k,j)=gshieldc_t4(k,j)+
3312 & grad_shield(k,j)*eello_t4/fac_shield(j)
3313 gshieldc_t4(k,i-1)=gshieldc_t4(k,i-1)+
3314 & grad_shield(k,i)*eello_t4/fac_shield(i)
3315 gshieldc_t4(k,j-1)=gshieldc_t4(k,j-1)+
3316 & grad_shield(k,j)*eello_t4/fac_shield(j)
3319 call transpose2(EUgder(1,1,i+1),e1tder(1,1))
3320 call matmat2(e1tder(1,1),a_temp(1,1),auxmat(1,1))
3321 call matvec2(auxmat(1,1),Ub2(1,i+3),auxvec(1))
3322 s1=scalar2(b1(1,iti2),auxvec(1))
3323 call matmat2(ae3e2(1,1),e1tder(1,1),pizda(1,1))
3324 s3=0.5d0*(pizda(1,1)+pizda(2,2))
3325 gel_loc_turn4(i)=gel_loc_turn4(i)-(s1+s3)
3326 & *fac_shield(i)*fac_shield(j)
3328 C Derivatives in gamma(i+1)
3329 call transpose2(EUgder(1,1,i+2),e2tder(1,1))
3330 call matvec2(ae3(1,1),Ub2der(1,i+2),auxvec(1))
3331 s2=scalar2(b1(1,iti1),auxvec(1))
3332 call matmat2(ae3(1,1),e2tder(1,1),auxmat(1,1))
3333 call matmat2(auxmat(1,1),e1t(1,1),pizda(1,1))
3334 s3=0.5d0*(pizda(1,1)+pizda(2,2))
3335 gel_loc_turn4(i+1)=gel_loc_turn4(i+1)-(s2+s3)
3336 & *fac_shield(i)*fac_shield(j)
3338 C Derivatives in gamma(i+2)
3339 call transpose2(EUgder(1,1,i+3),e3tder(1,1))
3340 call matvec2(e1a(1,1),Ub2der(1,i+3),auxvec(1))
3341 s1=scalar2(b1(1,iti2),auxvec(1))
3342 call matmat2(a_temp(1,1),e3tder(1,1),auxmat(1,1))
3343 call matvec2(auxmat(1,1),Ub2(1,i+2),auxvec(1))
3344 s2=scalar2(b1(1,iti1),auxvec(1))
3345 call matmat2(auxmat(1,1),e2t(1,1),auxmat(1,1))
3346 call matmat2(auxmat(1,1),e1t(1,1),pizda(1,1))
3347 s3=0.5d0*(pizda(1,1)+pizda(2,2))
3348 gel_loc_turn4(i+2)=gel_loc_turn4(i+2)-(s1+s2+s3)
3349 & *fac_shield(i)*fac_shield(j)
3351 C Cartesian derivatives
3353 C Derivatives of this turn contributions in DC(i+2)
3354 if (j.lt.nres-1) then
3356 a_temp(1,1)=agg(l,1)
3357 a_temp(1,2)=agg(l,2)
3358 a_temp(2,1)=agg(l,3)
3359 a_temp(2,2)=agg(l,4)
3360 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
3361 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
3362 s1=scalar2(b1(1,iti2),auxvec(1))
3363 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
3364 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
3365 s2=scalar2(b1(1,iti1),auxvec(1))
3366 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
3367 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
3368 s3=0.5d0*(pizda(1,1)+pizda(2,2))
3370 gcorr4_turn(l,i+2)=gcorr4_turn(l,i+2)-(s1+s2+s3)
3371 & *fac_shield(i)*fac_shield(j)
3375 C Remaining derivatives of this turn contribution
3377 a_temp(1,1)=aggi(l,1)
3378 a_temp(1,2)=aggi(l,2)
3379 a_temp(2,1)=aggi(l,3)
3380 a_temp(2,2)=aggi(l,4)
3381 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
3382 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
3383 s1=scalar2(b1(1,iti2),auxvec(1))
3384 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
3385 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
3386 s2=scalar2(b1(1,iti1),auxvec(1))
3387 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
3388 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
3389 s3=0.5d0*(pizda(1,1)+pizda(2,2))
3390 gcorr4_turn(l,i)=gcorr4_turn(l,i)-(s1+s2+s3)
3391 & *fac_shield(i)*fac_shield(j)
3393 a_temp(1,1)=aggi1(l,1)
3394 a_temp(1,2)=aggi1(l,2)
3395 a_temp(2,1)=aggi1(l,3)
3396 a_temp(2,2)=aggi1(l,4)
3397 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
3398 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
3399 s1=scalar2(b1(1,iti2),auxvec(1))
3400 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
3401 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
3402 s2=scalar2(b1(1,iti1),auxvec(1))
3403 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
3404 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
3405 s3=0.5d0*(pizda(1,1)+pizda(2,2))
3406 gcorr4_turn(l,i+1)=gcorr4_turn(l,i+1)-(s1+s2+s3)
3407 & *fac_shield(i)*fac_shield(j)
3409 a_temp(1,1)=aggj(l,1)
3410 a_temp(1,2)=aggj(l,2)
3411 a_temp(2,1)=aggj(l,3)
3412 a_temp(2,2)=aggj(l,4)
3413 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
3414 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
3415 s1=scalar2(b1(1,iti2),auxvec(1))
3416 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
3417 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
3418 s2=scalar2(b1(1,iti1),auxvec(1))
3419 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
3420 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
3421 s3=0.5d0*(pizda(1,1)+pizda(2,2))
3422 gcorr4_turn(l,j)=gcorr4_turn(l,j)-(s1+s2+s3)
3423 & *fac_shield(i)*fac_shield(j)
3425 a_temp(1,1)=aggj1(l,1)
3426 a_temp(1,2)=aggj1(l,2)
3427 a_temp(2,1)=aggj1(l,3)
3428 a_temp(2,2)=aggj1(l,4)
3429 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
3430 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
3431 s1=scalar2(b1(1,iti2),auxvec(1))
3432 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
3433 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
3434 s2=scalar2(b1(1,iti1),auxvec(1))
3435 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
3436 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
3437 s3=0.5d0*(pizda(1,1)+pizda(2,2))
3438 gcorr4_turn(l,j1)=gcorr4_turn(l,j1)-(s1+s2+s3)
3439 & *fac_shield(i)*fac_shield(j)
3447 C-----------------------------------------------------------------------------
3448 subroutine vecpr(u,v,w)
3449 implicit real*8(a-h,o-z)
3450 dimension u(3),v(3),w(3)
3451 w(1)=u(2)*v(3)-u(3)*v(2)
3452 w(2)=-u(1)*v(3)+u(3)*v(1)
3453 w(3)=u(1)*v(2)-u(2)*v(1)
3456 C-----------------------------------------------------------------------------
3457 subroutine unormderiv(u,ugrad,unorm,ungrad)
3458 C This subroutine computes the derivatives of a normalized vector u, given
3459 C the derivatives computed without normalization conditions, ugrad. Returns
3462 double precision u(3),ugrad(3,3),unorm,ungrad(3,3)
3463 double precision vec(3)
3464 double precision scalar
3466 c write (2,*) 'ugrad',ugrad
3469 vec(i)=scalar(ugrad(1,i),u(1))
3471 c write (2,*) 'vec',vec
3474 ungrad(j,i)=(ugrad(j,i)-u(j)*vec(i))*unorm
3477 c write (2,*) 'ungrad',ungrad
3480 C-----------------------------------------------------------------------------
3481 subroutine escp(evdw2,evdw2_14)
3483 C This subroutine calculates the excluded-volume interaction energy between
3484 C peptide-group centers and side chains and its gradient in virtual-bond and
3485 C side-chain vectors.
3487 implicit real*8 (a-h,o-z)
3488 include 'DIMENSIONS'
3489 include 'DIMENSIONS.ZSCOPT'
3490 include 'COMMON.GEO'
3491 include 'COMMON.VAR'
3492 include 'COMMON.LOCAL'
3493 include 'COMMON.CHAIN'
3494 include 'COMMON.DERIV'
3495 include 'COMMON.INTERACT'
3496 include 'COMMON.FFIELD'
3497 include 'COMMON.IOUNITS'
3501 cd print '(a)','Enter ESCP'
3502 c write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e,
3503 c & ' scal14',scal14
3504 do i=iatscp_s,iatscp_e
3505 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1) cycle
3507 c write (iout,*) "i",i," iteli",iteli," nscp_gr",nscp_gr(i),
3508 c & " iscp",(iscpstart(i,j),iscpend(i,j),j=1,nscp_gr(i))
3509 if (iteli.eq.0) goto 1225
3510 xi=0.5D0*(c(1,i)+c(1,i+1))
3511 yi=0.5D0*(c(2,i)+c(2,i+1))
3512 zi=0.5D0*(c(3,i)+c(3,i+1))
3513 C Returning the ith atom to box
3515 if (xi.lt.0) xi=xi+boxxsize
3517 if (yi.lt.0) yi=yi+boxysize
3519 if (zi.lt.0) zi=zi+boxzsize
3520 do iint=1,nscp_gr(i)
3522 do j=iscpstart(i,iint),iscpend(i,iint)
3523 itypj=iabs(itype(j))
3524 if (itypj.eq.ntyp1) cycle
3525 C Uncomment following three lines for SC-p interactions
3529 C Uncomment following three lines for Ca-p interactions
3533 C returning the jth atom to box
3535 if (xj.lt.0) xj=xj+boxxsize
3537 if (yj.lt.0) yj=yj+boxysize
3539 if (zj.lt.0) zj=zj+boxzsize
3540 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
3545 C Finding the closest jth atom
3549 xj=xj_safe+xshift*boxxsize
3550 yj=yj_safe+yshift*boxysize
3551 zj=zj_safe+zshift*boxzsize
3552 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
3553 if(dist_temp.lt.dist_init) then
3563 if (subchap.eq.1) then
3572 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
3573 C sss is scaling function for smoothing the cutoff gradient otherwise
3574 C the gradient would not be continuouse
3575 sss=sscale(1.0d0/(dsqrt(rrij)))
3576 if (sss.le.0.0d0) cycle
3577 sssgrad=sscagrad(1.0d0/(dsqrt(rrij)))
3579 e1=fac*fac*aad(itypj,iteli)
3580 e2=fac*bad(itypj,iteli)
3581 if (iabs(j-i) .le. 2) then
3584 evdw2_14=evdw2_14+(e1+e2)*sss
3587 c write (iout,'(a6,2i5,0pf7.3,2i3,3e11.3)')
3588 c & 'evdw2',i,j,evdwij,iteli,itypj,fac,aad(itypj,iteli),
3589 c & bad(itypj,iteli)
3590 evdw2=evdw2+evdwij*sss
3593 C Calculate contributions to the gradient in the virtual-bond and SC vectors.
3595 fac=-(evdwij+e1)*rrij*sss
3596 fac=fac+(evdwij)*sssgrad*dsqrt(rrij)/expon
3601 cd write (iout,*) 'j<i'
3602 C Uncomment following three lines for SC-p interactions
3604 c gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
3607 cd write (iout,*) 'j>i'
3610 C Uncomment following line for SC-p interactions
3611 c gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
3615 gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
3619 cd write (iout,*) 'i=',i,' j=',j,' kstart=',kstart,' kend=',kend
3620 cd write (iout,*) ggg(1),ggg(2),ggg(3)
3623 gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
3633 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
3634 gradx_scp(j,i)=expon*gradx_scp(j,i)
3637 C******************************************************************************
3641 C To save time the factor EXPON has been extracted from ALL components
3642 C of GVDWC and GRADX. Remember to multiply them by this factor before further
3645 C******************************************************************************
3648 C--------------------------------------------------------------------------
3649 subroutine edis(ehpb)
3651 C Evaluate bridge-strain energy and its gradient in virtual-bond and SC vectors.
3653 implicit real*8 (a-h,o-z)
3654 include 'DIMENSIONS'
3655 include 'DIMENSIONS.ZSCOPT'
3656 include 'COMMON.SBRIDGE'
3657 include 'COMMON.CHAIN'
3658 include 'COMMON.DERIV'
3659 include 'COMMON.VAR'
3660 include 'COMMON.INTERACT'
3661 include 'COMMON.CONTROL'
3662 include 'COMMON.IOUNITS'
3665 cd print *,'edis: nhpb=',nhpb,' fbr=',fbr
3666 cd print *,'link_start=',link_start,' link_end=',link_end
3667 C write(iout,*) link_end, "link_end"
3668 if (link_end.eq.0) return
3669 do i=link_start,link_end
3670 C If ihpb(i) and jhpb(i) > NRES, this is a SC-SC distance, otherwise a
3671 C CA-CA distance used in regularization of structure.
3674 C iii and jjj point to the residues for which the distance is assigned.
3675 if (ii.gt.nres) then
3682 C 24/11/03 AL: SS bridges handled separately because of introducing a specific
3683 C distance and angle dependent SS bond potential.
3684 C if (ii.gt.nres .and. iabs(itype(iii)).eq.1 .and.
3685 C & iabs(itype(jjj)).eq.1) then
3686 C write(iout,*) constr_dist,"const"
3687 if (.not.dyn_ss .and. i.le.nss) then
3688 if (ii.gt.nres .and. iabs(itype(iii)).eq.1 .and.
3689 & iabs(itype(jjj)).eq.1) then
3690 call ssbond_ene(iii,jjj,eij)
3693 else if (ii.gt.nres .and. jj.gt.nres) then
3694 c Restraints from contact prediction
3696 if (constr_dist.eq.11) then
3697 C ehpb=ehpb+fordepth(i)**4.0d0
3698 C & *rlornmr1(dd,dhpb(i),dhpb1(i),forcon(i))
3699 ehpb=ehpb+fordepth(i)**4.0d0
3700 & *rlornmr1(dd,dhpb(i),dhpb1(i),forcon(i))
3701 fac=fordepth(i)**4.0d0
3702 & *rlornmr1prim(dd,dhpb(i),dhpb1(i),forcon(i))/dd
3703 C write (iout,'(a6,2i5,3f8.3)') "edisl",ii,jj,
3704 C & ehpb,fordepth(i),dd
3705 C write(iout,*) ehpb,"atu?"
3707 C fac=fordepth(i)**4.0d0
3708 C & *rlornmr1prim(dd,dhpb(i),dhpb1(i),forcon(i))/dd
3710 if (dhpb1(i).gt.0.0d0) then
3711 ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
3712 fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
3713 c write (iout,*) "beta nmr",
3714 c & dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
3718 C Get the force constant corresponding to this distance.
3720 C Calculate the contribution to energy.
3721 ehpb=ehpb+waga*rdis*rdis
3722 c write (iout,*) "beta reg",dd,waga*rdis*rdis
3724 C Evaluate gradient.
3727 endif !end dhpb1(i).gt.0
3728 endif !end const_dist=11
3730 ggg(j)=fac*(c(j,jj)-c(j,ii))
3733 ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
3734 ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
3737 ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
3738 ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
3741 C write(iout,*) "before"
3743 C write(iout,*) "after",dd
3744 if (constr_dist.eq.11) then
3745 ehpb=ehpb+fordepth(i)**4.0d0
3746 & *rlornmr1(dd,dhpb(i),dhpb1(i),forcon(i))
3747 fac=fordepth(i)**4.0d0
3748 & *rlornmr1prim(dd,dhpb(i),dhpb1(i),forcon(i))/dd
3749 C ehpb=ehpb+fordepth(i)**4*rlornmr1(dd,dhpb(i),dhpb1(i))
3750 C fac=fordepth(i)**4*rlornmr1prim(dd,dhpb(i),dhpb1(i))/dd
3751 C print *,ehpb,"tu?"
3752 C write(iout,*) ehpb,"btu?",
3753 C & dd,dhpb(i),dhpb1(i),fordepth(i),forcon(i)
3754 C write (iout,'(a6,2i5,3f8.3)') "edisl",ii,jj,
3755 C & ehpb,fordepth(i),dd
3757 if (dhpb1(i).gt.0.0d0) then
3758 ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
3759 fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
3760 c write (iout,*) "alph nmr",
3761 c & dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
3764 C Get the force constant corresponding to this distance.
3766 C Calculate the contribution to energy.
3767 ehpb=ehpb+waga*rdis*rdis
3768 c write (iout,*) "alpha reg",dd,waga*rdis*rdis
3770 C Evaluate gradient.
3777 ggg(j)=fac*(c(j,jj)-c(j,ii))
3779 cd print '(i3,3(1pe14.5))',i,(ggg(j),j=1,3)
3780 C If this is a SC-SC distance, we need to calculate the contributions to the
3781 C Cartesian gradient in the SC vectors (ghpbx).
3784 ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
3785 ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
3790 ghpbc(k,j)=ghpbc(k,j)+ggg(k)
3795 if (constr_dist.ne.11) ehpb=0.5D0*ehpb
3798 C--------------------------------------------------------------------------
3799 subroutine ssbond_ene(i,j,eij)
3801 C Calculate the distance and angle dependent SS-bond potential energy
3802 C using a free-energy function derived based on RHF/6-31G** ab initio
3803 C calculations of diethyl disulfide.
3805 C A. Liwo and U. Kozlowska, 11/24/03
3807 implicit real*8 (a-h,o-z)
3808 include 'DIMENSIONS'
3809 include 'DIMENSIONS.ZSCOPT'
3810 include 'COMMON.SBRIDGE'
3811 include 'COMMON.CHAIN'
3812 include 'COMMON.DERIV'
3813 include 'COMMON.LOCAL'
3814 include 'COMMON.INTERACT'
3815 include 'COMMON.VAR'
3816 include 'COMMON.IOUNITS'
3817 double precision erij(3),dcosom1(3),dcosom2(3),gg(3)
3818 itypi=iabs(itype(i))
3822 dxi=dc_norm(1,nres+i)
3823 dyi=dc_norm(2,nres+i)
3824 dzi=dc_norm(3,nres+i)
3825 dsci_inv=dsc_inv(itypi)
3826 itypj=iabs(itype(j))
3827 dscj_inv=dsc_inv(itypj)
3831 dxj=dc_norm(1,nres+j)
3832 dyj=dc_norm(2,nres+j)
3833 dzj=dc_norm(3,nres+j)
3834 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
3839 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
3840 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
3841 om12=dxi*dxj+dyi*dyj+dzi*dzj
3843 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
3844 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
3850 deltat12=om2-om1+2.0d0
3852 eij=akcm*deltad*deltad+akth*(deltat1*deltat1+deltat2*deltat2)
3853 & +akct*deltad*deltat12
3854 & +v1ss*cosphi+v2ss*cosphi*cosphi+v3ss*cosphi*cosphi*cosphi
3855 c write(iout,*) i,j,"rij",rij,"d0cm",d0cm," akcm",akcm," akth",akth,
3856 c & " akct",akct," deltad",deltad," deltat",deltat1,deltat2,
3857 c & " deltat12",deltat12," eij",eij
3858 ed=2*akcm*deltad+akct*deltat12
3860 pom2=v1ss+2*v2ss*cosphi+3*v3ss*cosphi*cosphi
3861 eom1=-2*akth*deltat1-pom1-om2*pom2
3862 eom2= 2*akth*deltat2+pom1-om1*pom2
3865 gg(k)=ed*erij(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
3868 ghpbx(k,i)=ghpbx(k,i)-gg(k)
3869 & +(eom12*dc_norm(k,nres+j)+eom1*erij(k))*dsci_inv
3870 ghpbx(k,j)=ghpbx(k,j)+gg(k)
3871 & +(eom12*dc_norm(k,nres+i)+eom2*erij(k))*dscj_inv
3874 C Calculate the components of the gradient in DC and X
3878 ghpbc(l,k)=ghpbc(l,k)+gg(l)
3883 C--------------------------------------------------------------------------
3884 subroutine ebond(estr)
3886 c Evaluate the energy of stretching of the CA-CA and CA-SC virtual bonds
3888 implicit real*8 (a-h,o-z)
3889 include 'DIMENSIONS'
3890 include 'DIMENSIONS.ZSCOPT'
3891 include 'COMMON.LOCAL'
3892 include 'COMMON.GEO'
3893 include 'COMMON.INTERACT'
3894 include 'COMMON.DERIV'
3895 include 'COMMON.VAR'
3896 include 'COMMON.CHAIN'
3897 include 'COMMON.IOUNITS'
3898 include 'COMMON.NAMES'
3899 include 'COMMON.FFIELD'
3900 include 'COMMON.CONTROL'
3901 logical energy_dec /.false./
3902 double precision u(3),ud(3)
3905 c write (iout,*) "distchainmax",distchainmax
3907 if (itype(i-1).eq.ntyp1 .and. itype(i).eq.ntyp1) cycle
3908 C estr1=estr1+gnmr1(vbld(i),-1.0d0,distchainmax)
3910 C gradb(j,i-1)=gnmr1prim(vbld(i),-1.0d0,distchainmax)
3911 C & *dc(j,i-1)/vbld(i)
3913 C if (energy_dec) write(iout,*)
3914 C & "estr1",i,vbld(i),distchainmax,
3915 C & gnmr1(vbld(i),-1.0d0,distchainmax)
3917 if (itype(i-1).eq.ntyp1 .or. itype(i).eq.ntyp1) then
3918 diff = vbld(i)-vbldpDUM
3919 C write(iout,*) i,diff
3921 diff = vbld(i)-vbldp0
3922 c write (iout,*) i,vbld(i),vbldp0,diff,AKP*diff*diff
3926 gradb(j,i-1)=AKP*diff*dc(j,i-1)/vbld(i)
3929 C write (iout,'(a7,i5,4f7.3)')
3930 C & "estr bb",i,vbld(i),vbldp0,diff,AKP*diff*diff
3932 estr=0.5d0*AKP*estr+estr1
3934 c 09/18/07 AL: multimodal bond potential based on AM1 CA-SC PMF's included
3938 if (iti.ne.10 .and. iti.ne.ntyp1) then
3941 diff=vbld(i+nres)-vbldsc0(1,iti)
3942 C write (iout,*) i,iti,vbld(i+nres),vbldsc0(1,iti),diff,
3943 C & AKSC(1,iti),AKSC(1,iti)*diff*diff
3944 estr=estr+0.5d0*AKSC(1,iti)*diff*diff
3946 gradbx(j,i)=AKSC(1,iti)*diff*dc(j,i+nres)/vbld(i+nres)
3950 diff=vbld(i+nres)-vbldsc0(j,iti)
3951 ud(j)=aksc(j,iti)*diff
3952 u(j)=abond0(j,iti)+0.5d0*ud(j)*diff
3966 uprod2=uprod2*u(k)*u(k)
3970 usumsqder=usumsqder+ud(j)*uprod2
3972 c write (iout,*) i,iti,vbld(i+nres),(vbldsc0(j,iti),
3973 c & AKSC(j,iti),abond0(j,iti),u(j),j=1,nbi)
3974 estr=estr+uprod/usum
3976 gradbx(j,i)=usumsqder/(usum*usum)*dc(j,i+nres)/vbld(i+nres)
3984 C--------------------------------------------------------------------------
3985 subroutine ebend(etheta,ethetacnstr)
3987 C Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
3988 C angles gamma and its derivatives in consecutive thetas and gammas.
3990 implicit real*8 (a-h,o-z)
3991 include 'DIMENSIONS'
3992 include 'DIMENSIONS.ZSCOPT'
3993 include 'COMMON.LOCAL'
3994 include 'COMMON.GEO'
3995 include 'COMMON.INTERACT'
3996 include 'COMMON.DERIV'
3997 include 'COMMON.VAR'
3998 include 'COMMON.CHAIN'
3999 include 'COMMON.IOUNITS'
4000 include 'COMMON.NAMES'
4001 include 'COMMON.FFIELD'
4002 include 'COMMON.TORCNSTR'
4003 common /calcthet/ term1,term2,termm,diffak,ratak,
4004 & ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,
4005 & delthe0,sig0inv,sigtc,sigsqtc,delthec,it
4006 double precision y(2),z(2)
4008 c time11=dexp(-2*time)
4011 c write (iout,*) "nres",nres
4012 c write (*,'(a,i2)') 'EBEND ICG=',icg
4013 c write (iout,*) ithet_start,ithet_end
4014 do i=ithet_start,ithet_end
4015 C if (itype(i-1).eq.ntyp1) cycle
4017 if ((itype(i-1).eq.ntyp1).or.itype(i-2).eq.ntyp1
4018 & .or.itype(i).eq.ntyp1) cycle
4019 C Zero the energy function and its derivative at 0 or pi.
4020 call splinthet(theta(i),0.5d0*delta,ss,ssd)
4022 ichir1=isign(1,itype(i-2))
4023 ichir2=isign(1,itype(i))
4024 if (itype(i-2).eq.10) ichir1=isign(1,itype(i-1))
4025 if (itype(i).eq.10) ichir2=isign(1,itype(i-1))
4026 if (itype(i-1).eq.10) then
4027 itype1=isign(10,itype(i-2))
4028 ichir11=isign(1,itype(i-2))
4029 ichir12=isign(1,itype(i-2))
4030 itype2=isign(10,itype(i))
4031 ichir21=isign(1,itype(i))
4032 ichir22=isign(1,itype(i))
4039 if (i.gt.3 .and. itype(i-3).ne.ntyp1) then
4043 c call proc_proc(phii,icrc)
4044 if (icrc.eq.1) phii=150.0
4055 if (i.lt.nres .and. itype(i+1).ne.ntyp1) then
4059 c call proc_proc(phii1,icrc)
4060 if (icrc.eq.1) phii1=150.0
4072 C Calculate the "mean" value of theta from the part of the distribution
4073 C dependent on the adjacent virtual-bond-valence angles (gamma1 & gamma2).
4074 C In following comments this theta will be referred to as t_c.
4075 thet_pred_mean=0.0d0
4077 athetk=athet(k,it,ichir1,ichir2)
4078 bthetk=bthet(k,it,ichir1,ichir2)
4080 athetk=athet(k,itype1,ichir11,ichir12)
4081 bthetk=bthet(k,itype2,ichir21,ichir22)
4083 thet_pred_mean=thet_pred_mean+athetk*y(k)+bthetk*z(k)
4085 c write (iout,*) "thet_pred_mean",thet_pred_mean
4086 dthett=thet_pred_mean*ssd
4087 thet_pred_mean=thet_pred_mean*ss+a0thet(it)
4088 c write (iout,*) "thet_pred_mean",thet_pred_mean
4089 C Derivatives of the "mean" values in gamma1 and gamma2.
4090 dthetg1=(-athet(1,it,ichir1,ichir2)*y(2)
4091 &+athet(2,it,ichir1,ichir2)*y(1))*ss
4092 dthetg2=(-bthet(1,it,ichir1,ichir2)*z(2)
4093 & +bthet(2,it,ichir1,ichir2)*z(1))*ss
4095 dthetg1=(-athet(1,itype1,ichir11,ichir12)*y(2)
4096 &+athet(2,itype1,ichir11,ichir12)*y(1))*ss
4097 dthetg2=(-bthet(1,itype2,ichir21,ichir22)*z(2)
4098 & +bthet(2,itype2,ichir21,ichir22)*z(1))*ss
4100 if (theta(i).gt.pi-delta) then
4101 call theteng(pi-delta,thet_pred_mean,theta0(it),f0,fprim0,
4103 call mixder(pi-delta,thet_pred_mean,theta0(it),fprim_tc0)
4104 call theteng(pi,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
4105 call spline1(theta(i),pi-delta,delta,f0,f1,fprim0,ethetai,
4107 call spline2(theta(i),pi-delta,delta,E_tc0,E_tc1,fprim_tc0,
4109 else if (theta(i).lt.delta) then
4110 call theteng(delta,thet_pred_mean,theta0(it),f0,fprim0,E_tc0)
4111 call theteng(0.0d0,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
4112 call spline1(theta(i),delta,-delta,f0,f1,fprim0,ethetai,
4114 call mixder(delta,thet_pred_mean,theta0(it),fprim_tc0)
4115 call spline2(theta(i),delta,-delta,E_tc0,E_tc1,fprim_tc0,
4118 call theteng(theta(i),thet_pred_mean,theta0(it),ethetai,
4121 etheta=etheta+ethetai
4122 c write (iout,'(a6,i5,0pf7.3,f7.3,i5)')
4123 c & 'ebend',i,ethetai,theta(i),itype(i)
4124 c write (iout,'(2i3,3f8.3,f10.5)') i,it,rad2deg*theta(i),
4125 c & rad2deg*phii,rad2deg*phii1,ethetai
4126 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*E_tc*dthetg1
4127 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*E_tc*dthetg2
4128 gloc(nphi+i-2,icg)=wang*(E_theta+E_tc*dthett)
4132 C print *,ithetaconstr_start,ithetaconstr_end,"TU"
4133 do i=1,ntheta_constr
4134 itheta=itheta_constr(i)
4135 thetiii=theta(itheta)
4136 difi=pinorm(thetiii-theta_constr0(i))
4137 if (difi.gt.theta_drange(i)) then
4138 difi=difi-theta_drange(i)
4139 ethetacnstr=ethetacnstr+0.25d0*for_thet_constr(i)*difi**4
4140 gloc(itheta+nphi-2,icg)=gloc(itheta+nphi-2,icg)
4141 & +for_thet_constr(i)*difi**3
4142 else if (difi.lt.-drange(i)) then
4144 ethetacnstr=ethetacnstr+0.25d0*for_thet_constr(i)*difi**4
4145 gloc(itheta+nphi-2,icg)=gloc(itheta+nphi-2,icg)
4146 & +for_thet_constr(i)*difi**3
4150 C if (energy_dec) then
4151 C write (iout,'(a6,2i5,4f8.3,2e14.5)') "ethetc",
4152 C & i,itheta,rad2deg*thetiii,
4153 C & rad2deg*theta_constr0(i), rad2deg*theta_drange(i),
4154 C & rad2deg*difi,0.25d0*for_thet_constr(i)*difi**4,
4155 C & gloc(itheta+nphi-2,icg)
4158 C Ufff.... We've done all this!!!
4161 C---------------------------------------------------------------------------
4162 subroutine theteng(thetai,thet_pred_mean,theta0i,ethetai,E_theta,
4164 implicit real*8 (a-h,o-z)
4165 include 'DIMENSIONS'
4166 include 'COMMON.LOCAL'
4167 include 'COMMON.IOUNITS'
4168 common /calcthet/ term1,term2,termm,diffak,ratak,
4169 & ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,
4170 & delthe0,sig0inv,sigtc,sigsqtc,delthec,it
4171 C Calculate the contributions to both Gaussian lobes.
4172 C 6/6/97 - Deform the Gaussians using the factor of 1/(1+time)
4173 C The "polynomial part" of the "standard deviation" of this part of
4177 sig=sig*thet_pred_mean+polthet(j,it)
4179 C Derivative of the "interior part" of the "standard deviation of the"
4180 C gamma-dependent Gaussian lobe in t_c.
4181 sigtc=3*polthet(3,it)
4183 sigtc=sigtc*thet_pred_mean+j*polthet(j,it)
4186 C Set the parameters of both Gaussian lobes of the distribution.
4187 C "Standard deviation" of the gamma-dependent Gaussian lobe (sigtc)
4188 fac=sig*sig+sigc0(it)
4191 C Following variable (sigsqtc) is -(1/2)d[sigma(t_c)**(-2))]/dt_c
4192 sigsqtc=-4.0D0*sigcsq*sigtc
4193 c print *,i,sig,sigtc,sigsqtc
4194 C Following variable (sigtc) is d[sigma(t_c)]/dt_c
4195 sigtc=-sigtc/(fac*fac)
4196 C Following variable is sigma(t_c)**(-2)
4197 sigcsq=sigcsq*sigcsq
4199 sig0inv=1.0D0/sig0i**2
4200 delthec=thetai-thet_pred_mean
4201 delthe0=thetai-theta0i
4202 term1=-0.5D0*sigcsq*delthec*delthec
4203 term2=-0.5D0*sig0inv*delthe0*delthe0
4204 C Following fuzzy logic is to avoid underflows in dexp and subsequent INFs and
4205 C NaNs in taking the logarithm. We extract the largest exponent which is added
4206 C to the energy (this being the log of the distribution) at the end of energy
4207 C term evaluation for this virtual-bond angle.
4208 if (term1.gt.term2) then
4210 term2=dexp(term2-termm)
4214 term1=dexp(term1-termm)
4217 C The ratio between the gamma-independent and gamma-dependent lobes of
4218 C the distribution is a Gaussian function of thet_pred_mean too.
4219 diffak=gthet(2,it)-thet_pred_mean
4220 ratak=diffak/gthet(3,it)**2
4221 ak=dexp(gthet(1,it)-0.5D0*diffak*ratak)
4222 C Let's differentiate it in thet_pred_mean NOW.
4224 C Now put together the distribution terms to make complete distribution.
4225 termexp=term1+ak*term2
4226 termpre=sigc+ak*sig0i
4227 C Contribution of the bending energy from this theta is just the -log of
4228 C the sum of the contributions from the two lobes and the pre-exponential
4229 C factor. Simple enough, isn't it?
4230 ethetai=(-dlog(termexp)-termm+dlog(termpre))
4231 C NOW the derivatives!!!
4232 C 6/6/97 Take into account the deformation.
4233 E_theta=(delthec*sigcsq*term1
4234 & +ak*delthe0*sig0inv*term2)/termexp
4235 E_tc=((sigtc+aktc*sig0i)/termpre
4236 & -((delthec*sigcsq+delthec*delthec*sigsqtc)*term1+
4237 & aktc*term2)/termexp)
4240 c-----------------------------------------------------------------------------
4241 subroutine mixder(thetai,thet_pred_mean,theta0i,E_tc_t)
4242 implicit real*8 (a-h,o-z)
4243 include 'DIMENSIONS'
4244 include 'COMMON.LOCAL'
4245 include 'COMMON.IOUNITS'
4246 common /calcthet/ term1,term2,termm,diffak,ratak,
4247 & ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,
4248 & delthe0,sig0inv,sigtc,sigsqtc,delthec,it
4249 delthec=thetai-thet_pred_mean
4250 delthe0=thetai-theta0i
4251 C "Thank you" to MAPLE (probably spared one day of hand-differentiation).
4252 t3 = thetai-thet_pred_mean
4256 t14 = t12+t6*sigsqtc
4258 t21 = thetai-theta0i
4264 E_tc_t = -((sigcsq+2.D0*t3*sigsqtc)*t9-t14*sigcsq*t3*t16*t9
4265 & -aktc*sig0inv*t27)/t32+(t14*t9+aktc*t26)/t40
4266 & *(-t12*t9-ak*sig0inv*t27)
4270 C--------------------------------------------------------------------------
4271 subroutine ebend(etheta,ethetacnstr)
4273 C Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
4274 C angles gamma and its derivatives in consecutive thetas and gammas.
4275 C ab initio-derived potentials from
4276 c Kozlowska et al., J. Phys.: Condens. Matter 19 (2007) 285203
4278 implicit real*8 (a-h,o-z)
4279 include 'DIMENSIONS'
4280 include 'DIMENSIONS.ZSCOPT'
4281 include 'COMMON.LOCAL'
4282 include 'COMMON.GEO'
4283 include 'COMMON.INTERACT'
4284 include 'COMMON.DERIV'
4285 include 'COMMON.VAR'
4286 include 'COMMON.CHAIN'
4287 include 'COMMON.IOUNITS'
4288 include 'COMMON.NAMES'
4289 include 'COMMON.FFIELD'
4290 include 'COMMON.CONTROL'
4291 include 'COMMON.TORCNSTR'
4292 double precision coskt(mmaxtheterm),sinkt(mmaxtheterm),
4293 & cosph1(maxsingle),sinph1(maxsingle),cosph2(maxsingle),
4294 & sinph2(maxsingle),cosph1ph2(maxdouble,maxdouble),
4295 & sinph1ph2(maxdouble,maxdouble)
4296 logical lprn /.false./, lprn1 /.false./
4298 c write (iout,*) "ithetyp",(ithetyp(i),i=1,ntyp1)
4299 do i=ithet_start,ithet_end
4301 C if (itype(i-1).eq.ntyp1) cycle
4303 if ((itype(i-1).eq.ntyp1).or.itype(i-2).eq.ntyp1
4304 & .or.itype(i).eq.ntyp1) cycle
4305 if (iabs(itype(i+1)).eq.20) iblock=2
4306 if (iabs(itype(i+1)).ne.20) iblock=1
4310 theti2=0.5d0*theta(i)
4311 ityp2=ithetyp((itype(i-1)))
4313 coskt(k)=dcos(k*theti2)
4314 sinkt(k)=dsin(k*theti2)
4324 if (i.gt.3 .and. itype(i-3).ne.ntyp1) then
4327 if (phii.ne.phii) phii=150.0
4331 ityp1=ithetyp((itype(i-2)))
4333 cosph1(k)=dcos(k*phii)
4334 sinph1(k)=dsin(k*phii)
4340 ityp1=ithetyp((itype(i-2)))
4346 if (i.lt.nres .and. itype(i+1).ne.ntyp1) then
4349 if (phii1.ne.phii1) phii1=150.0
4354 ityp3=ithetyp((itype(i)))
4356 cosph2(k)=dcos(k*phii1)
4357 sinph2(k)=dsin(k*phii1)
4362 ityp3=ithetyp((itype(i)))
4368 c write (iout,*) "i",i," ityp1",itype(i-2),ityp1,
4369 c & " ityp2",itype(i-1),ityp2," ityp3",itype(i),ityp3
4371 ethetai=aa0thet(ityp1,ityp2,ityp3,iblock)
4374 ccl=cosph1(l)*cosph2(k-l)
4375 ssl=sinph1(l)*sinph2(k-l)
4376 scl=sinph1(l)*cosph2(k-l)
4377 csl=cosph1(l)*sinph2(k-l)
4378 cosph1ph2(l,k)=ccl-ssl
4379 cosph1ph2(k,l)=ccl+ssl
4380 sinph1ph2(l,k)=scl+csl
4381 sinph1ph2(k,l)=scl-csl
4385 write (iout,*) "i",i," ityp1",ityp1," ityp2",ityp2,
4386 & " ityp3",ityp3," theti2",theti2," phii",phii," phii1",phii1
4387 write (iout,*) "coskt and sinkt"
4389 write (iout,*) k,coskt(k),sinkt(k)
4393 ethetai=ethetai+aathet(k,ityp1,ityp2,ityp3,iblock)*sinkt(k)
4394 dethetai=dethetai+0.5d0*k*aathet(k,ityp1,ityp2,ityp3,iblock)
4397 & write (iout,*) "k",k,"
4398 & aathet",aathet(k,ityp1,ityp2,ityp3,iblock),
4399 & " ethetai",ethetai
4402 write (iout,*) "cosph and sinph"
4404 write (iout,*) k,cosph1(k),sinph1(k),cosph2(k),sinph2(k)
4406 write (iout,*) "cosph1ph2 and sinph2ph2"
4409 write (iout,*) l,k,cosph1ph2(l,k),cosph1ph2(k,l),
4410 & sinph1ph2(l,k),sinph1ph2(k,l)
4413 write(iout,*) "ethetai",ethetai
4417 aux=bbthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph1(k)
4418 & +ccthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph1(k)
4419 & +ddthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph2(k)
4420 & +eethet(k,m,ityp1,ityp2,ityp3,iblock)*sinph2(k)
4421 ethetai=ethetai+sinkt(m)*aux
4422 dethetai=dethetai+0.5d0*m*aux*coskt(m)
4423 dephii=dephii+k*sinkt(m)*(
4424 & ccthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph1(k)-
4425 & bbthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph1(k))
4426 dephii1=dephii1+k*sinkt(m)*(
4427 & eethet(k,m,ityp1,ityp2,ityp3,iblock)*cosph2(k)-
4428 & ddthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph2(k))
4430 & write (iout,*) "m",m," k",k," bbthet",
4431 & bbthet(k,m,ityp1,ityp2,ityp3,iblock)," ccthet",
4432 & ccthet(k,m,ityp1,ityp2,ityp3,iblock)," ddthet",
4433 & ddthet(k,m,ityp1,ityp2,ityp3,iblock)," eethet",
4434 & eethet(k,m,ityp1,ityp2,ityp3,iblock)," ethetai",ethetai
4438 & write(iout,*) "ethetai",ethetai
4442 aux=ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)+
4443 & ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l)+
4444 & ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)+
4445 & ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)
4446 ethetai=ethetai+sinkt(m)*aux
4447 dethetai=dethetai+0.5d0*m*coskt(m)*aux
4448 dephii=dephii+l*sinkt(m)*(
4449 & -ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)-
4450 & ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)+
4451 & ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)+
4452 & ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l))
4453 dephii1=dephii1+(k-l)*sinkt(m)*(
4454 & -ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)+
4455 & ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)+
4456 & ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)-
4457 & ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l))
4459 write (iout,*) "m",m," k",k," l",l," ffthet",
4460 & ffthet(l,k,m,ityp1,ityp2,ityp3,iblock),
4461 & ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)," ggthet",
4462 & ggthet(l,k,m,ityp1,ityp2,ityp3,iblock),
4463 & ggthet(k,l,m,ityp1,ityp2,ityp3,iblock),
4464 & " ethetai",ethetai
4465 write (iout,*) cosph1ph2(l,k)*sinkt(m),
4466 & cosph1ph2(k,l)*sinkt(m),
4467 & sinph1ph2(l,k)*sinkt(m),sinph1ph2(k,l)*sinkt(m)
4473 if (lprn1) write (iout,'(i2,3f8.1,9h ethetai ,f10.5)')
4474 & i,theta(i)*rad2deg,phii*rad2deg,
4475 & phii1*rad2deg,ethetai
4476 etheta=etheta+ethetai
4477 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*dephii
4478 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*dephii1
4479 c gloc(nphi+i-2,icg)=wang*dethetai
4480 gloc(nphi+i-2,icg)=gloc(nphi+i-2,icg)+wang*dethetai
4484 C print *,ithetaconstr_start,ithetaconstr_end,"TU"
4485 do i=1,ntheta_constr
4486 itheta=itheta_constr(i)
4487 thetiii=theta(itheta)
4488 difi=pinorm(thetiii-theta_constr0(i))
4489 if (difi.gt.theta_drange(i)) then
4490 difi=difi-theta_drange(i)
4491 ethetacnstr=ethetacnstr+0.25d0*for_thet_constr(i)*difi**4
4492 gloc(itheta+nphi-2,icg)=gloc(itheta+nphi-2,icg)
4493 & +for_thet_constr(i)*difi**3
4494 else if (difi.lt.-drange(i)) then
4496 ethetacnstr=ethetacnstr+0.25d0*for_thet_constr(i)*difi**4
4497 gloc(itheta+nphi-2,icg)=gloc(itheta+nphi-2,icg)
4498 & +for_thet_constr(i)*difi**3
4502 C if (energy_dec) then
4503 C write (iout,'(a6,2i5,4f8.3,2e14.5)') "ethetc",
4504 C & i,itheta,rad2deg*thetiii,
4505 C & rad2deg*theta_constr0(i), rad2deg*theta_drange(i),
4506 C & rad2deg*difi,0.25d0*for_thet_constr(i)*difi**4,
4507 C & gloc(itheta+nphi-2,icg)
4514 c-----------------------------------------------------------------------------
4515 subroutine esc(escloc)
4516 C Calculate the local energy of a side chain and its derivatives in the
4517 C corresponding virtual-bond valence angles THETA and the spherical angles
4519 implicit real*8 (a-h,o-z)
4520 include 'DIMENSIONS'
4521 include 'DIMENSIONS.ZSCOPT'
4522 include 'COMMON.GEO'
4523 include 'COMMON.LOCAL'
4524 include 'COMMON.VAR'
4525 include 'COMMON.INTERACT'
4526 include 'COMMON.DERIV'
4527 include 'COMMON.CHAIN'
4528 include 'COMMON.IOUNITS'
4529 include 'COMMON.NAMES'
4530 include 'COMMON.FFIELD'
4531 double precision x(3),dersc(3),xemp(3),dersc0(3),dersc1(3),
4532 & ddersc0(3),ddummy(3),xtemp(3),temp(3)
4533 common /sccalc/ time11,time12,time112,theti,it,nlobit
4536 C write (iout,*) 'ESC'
4537 do i=loc_start,loc_end
4539 if (it.eq.ntyp1) cycle
4540 if (it.eq.10) goto 1
4541 nlobit=nlob(iabs(it))
4542 c print *,'i=',i,' it=',it,' nlobit=',nlobit
4543 C write (iout,*) 'i=',i,' ssa=',ssa,' ssad=',ssad
4544 theti=theta(i+1)-pipol
4548 c write (iout,*) "i",i," x",x(1),x(2),x(3)
4550 if (x(2).gt.pi-delta) then
4554 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
4556 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
4557 call spline1(x(2),pi-delta,delta,escloci0,escloci1,dersc0(2),
4559 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),
4560 & ddersc0(1),dersc(1))
4561 call spline2(x(2),pi-delta,delta,dersc0(3),dersc1(3),
4562 & ddersc0(3),dersc(3))
4564 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
4566 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
4567 call spline1(x(2),pi-delta,delta,esclocbi0,esclocbi1,
4568 & dersc0(2),esclocbi,dersc02)
4569 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),
4571 call splinthet(x(2),0.5d0*delta,ss,ssd)
4576 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
4578 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
4579 write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
4581 escloci=ss*escloci+(1.0d0-ss)*esclocbi
4583 c write (iout,*) escloci
4584 else if (x(2).lt.delta) then
4588 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
4590 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
4591 call spline1(x(2),delta,-delta,escloci0,escloci1,dersc0(2),
4593 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),
4594 & ddersc0(1),dersc(1))
4595 call spline2(x(2),delta,-delta,dersc0(3),dersc1(3),
4596 & ddersc0(3),dersc(3))
4598 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
4600 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
4601 call spline1(x(2),delta,-delta,esclocbi0,esclocbi1,
4602 & dersc0(2),esclocbi,dersc02)
4603 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),
4608 call splinthet(x(2),0.5d0*delta,ss,ssd)
4610 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
4612 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
4613 c write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
4615 escloci=ss*escloci+(1.0d0-ss)*esclocbi
4616 C write (iout,*) 'i=',i, escloci
4618 call enesc(x,escloci,dersc,ddummy,.false.)
4621 escloc=escloc+escloci
4622 C write (iout,*) 'i=',i,' escloci=',escloci,' dersc=',dersc
4623 write (iout,'(a6,i5,0pf7.3)')
4624 & 'escloc',i,escloci
4626 gloc(nphi+i-1,icg)=gloc(nphi+i-1,icg)+
4628 gloc(ialph(i,1),icg)=wscloc*dersc(2)
4629 gloc(ialph(i,1)+nside,icg)=wscloc*dersc(3)
4634 C---------------------------------------------------------------------------
4635 subroutine enesc(x,escloci,dersc,ddersc,mixed)
4636 implicit real*8 (a-h,o-z)
4637 include 'DIMENSIONS'
4638 include 'COMMON.GEO'
4639 include 'COMMON.LOCAL'
4640 include 'COMMON.IOUNITS'
4641 common /sccalc/ time11,time12,time112,theti,it,nlobit
4642 double precision x(3),z(3),Ax(3,maxlob,-1:1),dersc(3),ddersc(3)
4643 double precision contr(maxlob,-1:1)
4645 c write (iout,*) 'it=',it,' nlobit=',nlobit
4649 if (mixed) ddersc(j)=0.0d0
4653 C Because of periodicity of the dependence of the SC energy in omega we have
4654 C to add up the contributions from x(3)-2*pi, x(3), and x(3+2*pi).
4655 C To avoid underflows, first compute & store the exponents.
4663 z(k)=x(k)-censc(k,j,it)
4668 Axk=Axk+gaussc(l,k,j,it)*z(l)
4674 expfac=expfac+Ax(k,j,iii)*z(k)
4682 C As in the case of ebend, we want to avoid underflows in exponentiation and
4683 C subsequent NaNs and INFs in energy calculation.
4684 C Find the largest exponent
4688 if (emin.gt.contr(j,iii)) emin=contr(j,iii)
4692 cd print *,'it=',it,' emin=',emin
4694 C Compute the contribution to SC energy and derivatives
4698 expfac=dexp(bsc(j,iabs(it))-0.5D0*contr(j,iii)+emin)
4699 cd print *,'j=',j,' expfac=',expfac
4700 escloc_i=escloc_i+expfac
4702 dersc(k)=dersc(k)+Ax(k,j,iii)*expfac
4706 ddersc(k)=ddersc(k)+(-Ax(2,j,iii)*Ax(k,j,iii)
4707 & +gaussc(k,2,j,it))*expfac
4714 dersc(1)=dersc(1)/cos(theti)**2
4715 ddersc(1)=ddersc(1)/cos(theti)**2
4718 escloci=-(dlog(escloc_i)-emin)
4720 dersc(j)=dersc(j)/escloc_i
4724 ddersc(j)=(ddersc(j)/escloc_i+dersc(2)*dersc(j))
4729 C------------------------------------------------------------------------------
4730 subroutine enesc_bound(x,escloci,dersc,dersc12,mixed)
4731 implicit real*8 (a-h,o-z)
4732 include 'DIMENSIONS'
4733 include 'COMMON.GEO'
4734 include 'COMMON.LOCAL'
4735 include 'COMMON.IOUNITS'
4736 common /sccalc/ time11,time12,time112,theti,it,nlobit
4737 double precision x(3),z(3),Ax(3,maxlob),dersc(3)
4738 double precision contr(maxlob)
4749 z(k)=x(k)-censc(k,j,it)
4755 Axk=Axk+gaussc(l,k,j,it)*z(l)
4761 expfac=expfac+Ax(k,j)*z(k)
4766 C As in the case of ebend, we want to avoid underflows in exponentiation and
4767 C subsequent NaNs and INFs in energy calculation.
4768 C Find the largest exponent
4771 if (emin.gt.contr(j)) emin=contr(j)
4775 C Compute the contribution to SC energy and derivatives
4779 expfac=dexp(bsc(j,iabs(it))-0.5D0*contr(j)+emin)
4780 escloc_i=escloc_i+expfac
4782 dersc(k)=dersc(k)+Ax(k,j)*expfac
4784 if (mixed) dersc12=dersc12+(-Ax(2,j)*Ax(1,j)
4785 & +gaussc(1,2,j,it))*expfac
4789 dersc(1)=dersc(1)/cos(theti)**2
4790 dersc12=dersc12/cos(theti)**2
4791 escloci=-(dlog(escloc_i)-emin)
4793 dersc(j)=dersc(j)/escloc_i
4795 if (mixed) dersc12=(dersc12/escloc_i+dersc(2)*dersc(1))
4799 c----------------------------------------------------------------------------------
4800 subroutine esc(escloc)
4801 C Calculate the local energy of a side chain and its derivatives in the
4802 C corresponding virtual-bond valence angles THETA and the spherical angles
4803 C ALPHA and OMEGA derived from AM1 all-atom calculations.
4804 C added by Urszula Kozlowska. 07/11/2007
4806 implicit real*8 (a-h,o-z)
4807 include 'DIMENSIONS'
4808 include 'DIMENSIONS.ZSCOPT'
4809 include 'COMMON.GEO'
4810 include 'COMMON.LOCAL'
4811 include 'COMMON.VAR'
4812 include 'COMMON.SCROT'
4813 include 'COMMON.INTERACT'
4814 include 'COMMON.DERIV'
4815 include 'COMMON.CHAIN'
4816 include 'COMMON.IOUNITS'
4817 include 'COMMON.NAMES'
4818 include 'COMMON.FFIELD'
4819 include 'COMMON.CONTROL'
4820 include 'COMMON.VECTORS'
4821 double precision x_prime(3),y_prime(3),z_prime(3)
4822 & , sumene,dsc_i,dp2_i,x(65),
4823 & xx,yy,zz,sumene1,sumene2,sumene3,sumene4,s1,s1_6,s2,s2_6,
4824 & de_dxx,de_dyy,de_dzz,de_dt
4825 double precision s1_t,s1_6_t,s2_t,s2_6_t
4827 & dXX_Ci1(3),dYY_Ci1(3),dZZ_Ci1(3),dXX_Ci(3),
4828 & dYY_Ci(3),dZZ_Ci(3),dXX_XYZ(3),dYY_XYZ(3),dZZ_XYZ(3),
4829 & dt_dCi(3),dt_dCi1(3)
4830 common /sccalc/ time11,time12,time112,theti,it,nlobit
4833 do i=loc_start,loc_end
4834 if (itype(i).eq.ntyp1) cycle
4835 costtab(i+1) =dcos(theta(i+1))
4836 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
4837 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
4838 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
4839 cosfac2=0.5d0/(1.0d0+costtab(i+1))
4840 cosfac=dsqrt(cosfac2)
4841 sinfac2=0.5d0/(1.0d0-costtab(i+1))
4842 sinfac=dsqrt(sinfac2)
4844 if (it.eq.10) goto 1
4846 C Compute the axes of tghe local cartesian coordinates system; store in
4847 c x_prime, y_prime and z_prime
4854 C write(2,*) "dc_norm", dc_norm(1,i+nres),dc_norm(2,i+nres),
4855 C & dc_norm(3,i+nres)
4857 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
4858 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
4861 z_prime(j) = -uz(j,i-1)*dsign(1.0d0,dfloat(itype(i)))
4864 c write (2,*) "x_prime",(x_prime(j),j=1,3)
4865 c write (2,*) "y_prime",(y_prime(j),j=1,3)
4866 c write (2,*) "z_prime",(z_prime(j),j=1,3)
4867 c write (2,*) "xx",scalar(x_prime(1),x_prime(1)),
4868 c & " xy",scalar(x_prime(1),y_prime(1)),
4869 c & " xz",scalar(x_prime(1),z_prime(1)),
4870 c & " yy",scalar(y_prime(1),y_prime(1)),
4871 c & " yz",scalar(y_prime(1),z_prime(1)),
4872 c & " zz",scalar(z_prime(1),z_prime(1))
4874 C Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
4875 C to local coordinate system. Store in xx, yy, zz.
4881 xx = xx + x_prime(j)*dc_norm(j,i+nres)
4882 yy = yy + y_prime(j)*dc_norm(j,i+nres)
4883 zz = zz + z_prime(j)*dc_norm(j,i+nres)
4890 C Compute the energy of the ith side cbain
4892 c write (2,*) "xx",xx," yy",yy," zz",zz
4895 x(j) = sc_parmin(j,it)
4898 Cc diagnostics - remove later
4900 yy1 = dsin(alph(2))*dcos(omeg(2))
4901 zz1 = -dsign(1.0d0,itype(i))*dsin(alph(2))*dsin(omeg(2))
4902 write(2,'(3f8.1,3f9.3,1x,3f9.3)')
4903 & alph(2)*rad2deg,omeg(2)*rad2deg,theta(3)*rad2deg,xx,yy,zz,
4905 C," --- ", xx_w,yy_w,zz_w
4908 sumene1= x(1)+ x(2)*xx+ x(3)*yy+ x(4)*zz+ x(5)*xx**2
4909 & + x(6)*yy**2+ x(7)*zz**2+ x(8)*xx*zz+ x(9)*xx*yy
4911 sumene2= x(11) + x(12)*xx + x(13)*yy + x(14)*zz + x(15)*xx**2
4912 & + x(16)*yy**2 + x(17)*zz**2 + x(18)*xx*zz + x(19)*xx*yy
4914 sumene3= x(21) +x(22)*xx +x(23)*yy +x(24)*zz +x(25)*xx**2
4915 & +x(26)*yy**2 +x(27)*zz**2 +x(28)*xx*zz +x(29)*xx*yy
4916 & +x(30)*yy*zz +x(31)*xx**3 +x(32)*yy**3 +x(33)*zz**3
4917 & +x(34)*(xx**2)*yy +x(35)*(xx**2)*zz +x(36)*(yy**2)*xx
4918 & +x(37)*(yy**2)*zz +x(38)*(zz**2)*xx +x(39)*(zz**2)*yy
4920 sumene4= x(41) +x(42)*xx +x(43)*yy +x(44)*zz +x(45)*xx**2
4921 & +x(46)*yy**2 +x(47)*zz**2 +x(48)*xx*zz +x(49)*xx*yy
4922 & +x(50)*yy*zz +x(51)*xx**3 +x(52)*yy**3 +x(53)*zz**3
4923 & +x(54)*(xx**2)*yy +x(55)*(xx**2)*zz +x(56)*(yy**2)*xx
4924 & +x(57)*(yy**2)*zz +x(58)*(zz**2)*xx +x(59)*(zz**2)*yy
4926 dsc_i = 0.743d0+x(61)
4928 dscp1=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i
4929 & *(xx*cost2tab(i+1)+yy*sint2tab(i+1)))
4930 dscp2=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i
4931 & *(xx*cost2tab(i+1)-yy*sint2tab(i+1)))
4932 s1=(1+x(63))/(0.1d0 + dscp1)
4933 s1_6=(1+x(64))/(0.1d0 + dscp1**6)
4934 s2=(1+x(65))/(0.1d0 + dscp2)
4935 s2_6=(1+x(65))/(0.1d0 + dscp2**6)
4936 sumene = ( sumene3*sint2tab(i+1) + sumene1)*(s1+s1_6)
4937 & + (sumene4*cost2tab(i+1) +sumene2)*(s2+s2_6)
4938 c write(2,'(i2," sumene",7f9.3)') i,sumene1,sumene2,sumene3,
4940 c & dscp1,dscp2,sumene
4941 c sumene = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
4942 escloc = escloc + sumene
4943 c write (2,*) "escloc",escloc
4944 c write (2,*) "i",i," escloc",sumene,escloc,it,itype(i),
4946 if (.not. calc_grad) goto 1
4949 C This section to check the numerical derivatives of the energy of ith side
4950 C chain in xx, yy, zz, and theta. Use the -DDEBUG compiler option or insert
4951 C #define DEBUG in the code to turn it on.
4953 write (2,*) "sumene =",sumene
4957 write (2,*) xx,yy,zz
4958 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
4959 de_dxx_num=(sumenep-sumene)/aincr
4961 write (2,*) "xx+ sumene from enesc=",sumenep
4964 write (2,*) xx,yy,zz
4965 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
4966 de_dyy_num=(sumenep-sumene)/aincr
4968 write (2,*) "yy+ sumene from enesc=",sumenep
4971 write (2,*) xx,yy,zz
4972 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
4973 de_dzz_num=(sumenep-sumene)/aincr
4975 write (2,*) "zz+ sumene from enesc=",sumenep
4976 costsave=cost2tab(i+1)
4977 sintsave=sint2tab(i+1)
4978 cost2tab(i+1)=dcos(0.5d0*(theta(i+1)+aincr))
4979 sint2tab(i+1)=dsin(0.5d0*(theta(i+1)+aincr))
4980 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
4981 de_dt_num=(sumenep-sumene)/aincr
4982 write (2,*) " t+ sumene from enesc=",sumenep
4983 cost2tab(i+1)=costsave
4984 sint2tab(i+1)=sintsave
4985 C End of diagnostics section.
4988 C Compute the gradient of esc
4990 pom_s1=(1.0d0+x(63))/(0.1d0 + dscp1)**2
4991 pom_s16=6*(1.0d0+x(64))/(0.1d0 + dscp1**6)**2
4992 pom_s2=(1.0d0+x(65))/(0.1d0 + dscp2)**2
4993 pom_s26=6*(1.0d0+x(65))/(0.1d0 + dscp2**6)**2
4994 pom_dx=dsc_i*dp2_i*cost2tab(i+1)
4995 pom_dy=dsc_i*dp2_i*sint2tab(i+1)
4996 pom_dt1=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)-yy*cost2tab(i+1))
4997 pom_dt2=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)+yy*cost2tab(i+1))
4998 pom1=(sumene3*sint2tab(i+1)+sumene1)
4999 & *(pom_s1/dscp1+pom_s16*dscp1**4)
5000 pom2=(sumene4*cost2tab(i+1)+sumene2)
5001 & *(pom_s2/dscp2+pom_s26*dscp2**4)
5002 sumene1x=x(2)+2*x(5)*xx+x(8)*zz+ x(9)*yy
5003 sumene3x=x(22)+2*x(25)*xx+x(28)*zz+x(29)*yy+3*x(31)*xx**2
5004 & +2*x(34)*xx*yy +2*x(35)*xx*zz +x(36)*(yy**2) +x(38)*(zz**2)
5006 sumene2x=x(12)+2*x(15)*xx+x(18)*zz+ x(19)*yy
5007 sumene4x=x(42)+2*x(45)*xx +x(48)*zz +x(49)*yy +3*x(51)*xx**2
5008 & +2*x(54)*xx*yy+2*x(55)*xx*zz+x(56)*(yy**2)+x(58)*(zz**2)
5010 de_dxx =(sumene1x+sumene3x*sint2tab(i+1))*(s1+s1_6)
5011 & +(sumene2x+sumene4x*cost2tab(i+1))*(s2+s2_6)
5012 & +(pom1+pom2)*pom_dx
5014 write(2,*), "de_dxx = ", de_dxx,de_dxx_num
5017 sumene1y=x(3) + 2*x(6)*yy + x(9)*xx + x(10)*zz
5018 sumene3y=x(23) +2*x(26)*yy +x(29)*xx +x(30)*zz +3*x(32)*yy**2
5019 & +x(34)*(xx**2) +2*x(36)*yy*xx +2*x(37)*yy*zz +x(39)*(zz**2)
5021 sumene2y=x(13) + 2*x(16)*yy + x(19)*xx + x(20)*zz
5022 sumene4y=x(43)+2*x(46)*yy+x(49)*xx +x(50)*zz
5023 & +3*x(52)*yy**2+x(54)*xx**2+2*x(56)*yy*xx +2*x(57)*yy*zz
5024 & +x(59)*zz**2 +x(60)*xx*zz
5025 de_dyy =(sumene1y+sumene3y*sint2tab(i+1))*(s1+s1_6)
5026 & +(sumene2y+sumene4y*cost2tab(i+1))*(s2+s2_6)
5027 & +(pom1-pom2)*pom_dy
5029 write(2,*), "de_dyy = ", de_dyy,de_dyy_num
5032 de_dzz =(x(24) +2*x(27)*zz +x(28)*xx +x(30)*yy
5033 & +3*x(33)*zz**2 +x(35)*xx**2 +x(37)*yy**2 +2*x(38)*zz*xx
5034 & +2*x(39)*zz*yy +x(40)*xx*yy)*sint2tab(i+1)*(s1+s1_6)
5035 & +(x(4) + 2*x(7)*zz+ x(8)*xx + x(10)*yy)*(s1+s1_6)
5036 & +(x(44)+2*x(47)*zz +x(48)*xx +x(50)*yy +3*x(53)*zz**2
5037 & +x(55)*xx**2 +x(57)*(yy**2)+2*x(58)*zz*xx +2*x(59)*zz*yy
5038 & +x(60)*xx*yy)*cost2tab(i+1)*(s2+s2_6)
5039 & + ( x(14) + 2*x(17)*zz+ x(18)*xx + x(20)*yy)*(s2+s2_6)
5041 write(2,*), "de_dzz = ", de_dzz,de_dzz_num
5044 de_dt = 0.5d0*sumene3*cost2tab(i+1)*(s1+s1_6)
5045 & -0.5d0*sumene4*sint2tab(i+1)*(s2+s2_6)
5046 & +pom1*pom_dt1+pom2*pom_dt2
5048 write(2,*), "de_dt = ", de_dt,de_dt_num
5052 cossc=scalar(dc_norm(1,i),dc_norm(1,i+nres))
5053 cossc1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
5054 cosfac2xx=cosfac2*xx
5055 sinfac2yy=sinfac2*yy
5057 dt_dCi(k) = -(dc_norm(k,i-1)+costtab(i+1)*dc_norm(k,i))*
5059 dt_dCi1(k)= -(dc_norm(k,i)+costtab(i+1)*dc_norm(k,i-1))*
5061 pom=(dC_norm(k,i+nres)-cossc*dC_norm(k,i))*vbld_inv(i+1)
5062 pom1=(dC_norm(k,i+nres)-cossc1*dC_norm(k,i-1))*vbld_inv(i)
5063 c write (iout,*) "i",i," k",k," pom",pom," pom1",pom1,
5064 c & " dt_dCi",dt_dCi(k)," dt_dCi1",dt_dCi1(k)
5065 c write (iout,*) "dC_norm",(dC_norm(j,i),j=1,3),
5066 c & (dC_norm(j,i-1),j=1,3)," vbld_inv",vbld_inv(i+1),vbld_inv(i)
5067 dXX_Ci(k)=pom*cosfac-dt_dCi(k)*cosfac2xx
5068 dXX_Ci1(k)=-pom1*cosfac-dt_dCi1(k)*cosfac2xx
5069 dYY_Ci(k)=pom*sinfac+dt_dCi(k)*sinfac2yy
5070 dYY_Ci1(k)=pom1*sinfac+dt_dCi1(k)*sinfac2yy
5074 dZZ_Ci(k)=dZZ_Ci(k)-uzgrad(j,k,2,i-1)
5075 & *dsign(1.0d0,dfloat(itype(i)))*dC_norm(j,i+nres)
5076 dZZ_Ci1(k)=dZZ_Ci1(k)-uzgrad(j,k,1,i-1)
5077 & *dsign(1.0d0,dfloat(itype(i)))*dC_norm(j,i+nres)
5080 dXX_XYZ(k)=vbld_inv(i+nres)*(x_prime(k)-xx*dC_norm(k,i+nres))
5081 dYY_XYZ(k)=vbld_inv(i+nres)*(y_prime(k)-yy*dC_norm(k,i+nres))
5082 dZZ_XYZ(k)=vbld_inv(i+nres)*(z_prime(k)-zz*dC_norm(k,i+nres))
5084 dt_dCi(k) = -dt_dCi(k)/sinttab(i+1)
5085 dt_dCi1(k)= -dt_dCi1(k)/sinttab(i+1)
5089 dXX_Ctab(k,i)=dXX_Ci(k)
5090 dXX_C1tab(k,i)=dXX_Ci1(k)
5091 dYY_Ctab(k,i)=dYY_Ci(k)
5092 dYY_C1tab(k,i)=dYY_Ci1(k)
5093 dZZ_Ctab(k,i)=dZZ_Ci(k)
5094 dZZ_C1tab(k,i)=dZZ_Ci1(k)
5095 dXX_XYZtab(k,i)=dXX_XYZ(k)
5096 dYY_XYZtab(k,i)=dYY_XYZ(k)
5097 dZZ_XYZtab(k,i)=dZZ_XYZ(k)
5101 c write (iout,*) "k",k," dxx_ci1",dxx_ci1(k)," dyy_ci1",
5102 c & dyy_ci1(k)," dzz_ci1",dzz_ci1(k)
5103 c write (iout,*) "k",k," dxx_ci",dxx_ci(k)," dyy_ci",
5104 c & dyy_ci(k)," dzz_ci",dzz_ci(k)
5105 c write (iout,*) "k",k," dt_dci",dt_dci(k)," dt_dci",
5107 c write (iout,*) "k",k," dxx_XYZ",dxx_XYZ(k)," dyy_XYZ",
5108 c & dyy_XYZ(k)," dzz_XYZ",dzz_XYZ(k)
5109 gscloc(k,i-1)=gscloc(k,i-1)+de_dxx*dxx_ci1(k)
5110 & +de_dyy*dyy_ci1(k)+de_dzz*dzz_ci1(k)+de_dt*dt_dCi1(k)
5111 gscloc(k,i)=gscloc(k,i)+de_dxx*dxx_Ci(k)
5112 & +de_dyy*dyy_Ci(k)+de_dzz*dzz_Ci(k)+de_dt*dt_dCi(k)
5113 gsclocx(k,i)= de_dxx*dxx_XYZ(k)
5114 & +de_dyy*dyy_XYZ(k)+de_dzz*dzz_XYZ(k)
5116 c write(iout,*) "ENERGY GRAD = ", (gscloc(k,i-1),k=1,3),
5117 c & (gscloc(k,i),k=1,3),(gsclocx(k,i),k=1,3)
5119 C to check gradient call subroutine check_grad
5126 c------------------------------------------------------------------------------
5127 subroutine gcont(rij,r0ij,eps0ij,delta,fcont,fprimcont)
5129 C This procedure calculates two-body contact function g(rij) and its derivative:
5132 C g(rij) = esp0ij*(-0.9375*x+0.625*x**3-0.1875*x**5) ! -1 =< x =< 1
5135 C where x=(rij-r0ij)/delta
5137 C rij - interbody distance, r0ij - contact distance, eps0ij - contact energy
5140 double precision rij,r0ij,eps0ij,fcont,fprimcont
5141 double precision x,x2,x4,delta
5145 if (x.lt.-1.0D0) then
5148 else if (x.le.1.0D0) then
5151 fcont=eps0ij*(x*(-0.9375D0+0.6250D0*x2-0.1875D0*x4)+0.5D0)
5152 fprimcont=eps0ij * (-0.9375D0+1.8750D0*x2-0.9375D0*x4)/delta
5159 c------------------------------------------------------------------------------
5160 subroutine splinthet(theti,delta,ss,ssder)
5161 implicit real*8 (a-h,o-z)
5162 include 'DIMENSIONS'
5163 include 'DIMENSIONS.ZSCOPT'
5164 include 'COMMON.VAR'
5165 include 'COMMON.GEO'
5168 if (theti.gt.pipol) then
5169 call gcont(theti,thetup,1.0d0,delta,ss,ssder)
5171 call gcont(-theti,-thetlow,1.0d0,delta,ss,ssder)
5176 c------------------------------------------------------------------------------
5177 subroutine spline1(x,x0,delta,f0,f1,fprim0,f,fprim)
5179 double precision x,x0,delta,f0,f1,fprim0,f,fprim
5180 double precision ksi,ksi2,ksi3,a1,a2,a3
5181 a1=fprim0*delta/(f1-f0)
5187 f=f0+(f1-f0)*ksi*(a1+ksi*(a2+a3*ksi))
5188 fprim=(f1-f0)/delta*(a1+ksi*(2*a2+3*ksi*a3))
5191 c------------------------------------------------------------------------------
5192 subroutine spline2(x,x0,delta,f0x,f1x,fprim0x,fx)
5194 double precision x,x0,delta,f0x,f1x,fprim0x,fx
5195 double precision ksi,ksi2,ksi3,a1,a2,a3
5200 a2=3*(f1x-f0x)-2*fprim0x*delta
5201 a3=fprim0x*delta-2*(f1x-f0x)
5202 fx=f0x+a1*ksi+a2*ksi2+a3*ksi3
5205 C-----------------------------------------------------------------------------
5207 C-----------------------------------------------------------------------------
5208 subroutine etor(etors,edihcnstr,fact)
5209 implicit real*8 (a-h,o-z)
5210 include 'DIMENSIONS'
5211 include 'DIMENSIONS.ZSCOPT'
5212 include 'COMMON.VAR'
5213 include 'COMMON.GEO'
5214 include 'COMMON.LOCAL'
5215 include 'COMMON.TORSION'
5216 include 'COMMON.INTERACT'
5217 include 'COMMON.DERIV'
5218 include 'COMMON.CHAIN'
5219 include 'COMMON.NAMES'
5220 include 'COMMON.IOUNITS'
5221 include 'COMMON.FFIELD'
5222 include 'COMMON.TORCNSTR'
5224 C Set lprn=.true. for debugging
5228 do i=iphi_start,iphi_end
5229 if (itype(i-2).eq.ntyp1 .or. itype(i-1).eq.ntyp1
5230 & .or. itype(i).eq.ntyp1) cycle
5231 itori=itortyp(itype(i-2))
5232 itori1=itortyp(itype(i-1))
5235 C Proline-Proline pair is a special case...
5236 if (itori.eq.3 .and. itori1.eq.3) then
5237 if (phii.gt.-dwapi3) then
5239 fac=1.0D0/(1.0D0-cosphi)
5240 etorsi=v1(1,3,3)*fac
5241 etorsi=etorsi+etorsi
5242 etors=etors+etorsi-v1(1,3,3)
5243 gloci=gloci-3*fac*etorsi*dsin(3*phii)
5246 v1ij=v1(j+1,itori,itori1)
5247 v2ij=v2(j+1,itori,itori1)
5250 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
5251 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
5255 v1ij=v1(j,itori,itori1)
5256 v2ij=v2(j,itori,itori1)
5259 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
5260 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
5264 & write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)')
5265 & restyp(itype(i-2)),i-2,restyp(itype(i-1)),i-1,itori,itori1,
5266 & (v1(j,itori,itori1),j=1,6),(v2(j,itori,itori1),j=1,6)
5267 gloc(i-3,icg)=gloc(i-3,icg)+wtor*fact*gloci
5268 c write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
5270 ! 6/20/98 - dihedral angle constraints
5273 itori=idih_constr(i)
5276 if (difi.gt.drange(i)) then
5278 edihcnstr=edihcnstr+0.25d0*ftors(i)*difi**4
5279 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors(i)*difi**3
5280 else if (difi.lt.-drange(i)) then
5282 edihcnstr=edihcnstr+0.25d0*ftors(i)*difi**4
5283 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors(i)*difi**3
5285 C write (iout,'(a6,2i5,2f8.3,2e14.5)') "edih",
5286 C & i,itori,rad2deg*phii,
5287 C & rad2deg*difi,0.25d0*ftors(i)*difi**4,gloc(itori-3,icg)
5289 ! write (iout,*) 'edihcnstr',edihcnstr
5292 c------------------------------------------------------------------------------
5294 subroutine etor(etors,edihcnstr,fact)
5295 implicit real*8 (a-h,o-z)
5296 include 'DIMENSIONS'
5297 include 'DIMENSIONS.ZSCOPT'
5298 include 'COMMON.VAR'
5299 include 'COMMON.GEO'
5300 include 'COMMON.LOCAL'
5301 include 'COMMON.TORSION'
5302 include 'COMMON.INTERACT'
5303 include 'COMMON.DERIV'
5304 include 'COMMON.CHAIN'
5305 include 'COMMON.NAMES'
5306 include 'COMMON.IOUNITS'
5307 include 'COMMON.FFIELD'
5308 include 'COMMON.TORCNSTR'
5310 C Set lprn=.true. for debugging
5314 do i=iphi_start,iphi_end
5316 if (itype(i-2).eq.ntyp1.or. itype(i-1).eq.ntyp1
5317 & .or. itype(i).eq.ntyp1 .or. itype(i-3).eq.ntyp1) cycle
5318 C if (itype(i-2).eq.ntyp1 .or. itype(i-1).eq.ntyp1
5319 C & .or. itype(i).eq.ntyp1) cycle
5320 if (itel(i-2).eq.0 .or. itel(i-1).eq.0) goto 1215
5321 if (iabs(itype(i)).eq.20) then
5326 itori=itortyp(itype(i-2))
5327 itori1=itortyp(itype(i-1))
5330 C Regular cosine and sine terms
5331 do j=1,nterm(itori,itori1,iblock)
5332 v1ij=v1(j,itori,itori1,iblock)
5333 v2ij=v2(j,itori,itori1,iblock)
5336 etors=etors+v1ij*cosphi+v2ij*sinphi
5337 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
5341 C E = SUM ----------------------------------- - v1
5342 C [v2 cos(phi/2)+v3 sin(phi/2)]^2 + 1
5344 cosphi=dcos(0.5d0*phii)
5345 sinphi=dsin(0.5d0*phii)
5346 do j=1,nlor(itori,itori1,iblock)
5347 vl1ij=vlor1(j,itori,itori1)
5348 vl2ij=vlor2(j,itori,itori1)
5349 vl3ij=vlor3(j,itori,itori1)
5350 pom=vl2ij*cosphi+vl3ij*sinphi
5351 pom1=1.0d0/(pom*pom+1.0d0)
5352 etors=etors+vl1ij*pom1
5353 c if (energy_dec) etors_ii=etors_ii+
5356 gloci=gloci+vl1ij*(vl3ij*cosphi-vl2ij*sinphi)*pom
5358 C Subtract the constant term
5359 etors=etors-v0(itori,itori1,iblock)
5361 & write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)')
5362 & restyp(itype(i-2)),i-2,restyp(itype(i-1)),i-1,itori,itori1,
5363 & (v1(j,itori,itori1,1),j=1,6),(v2(j,itori,itori1,1),j=1,6)
5364 gloc(i-3,icg)=gloc(i-3,icg)+wtor*fact*gloci
5365 c write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
5368 ! 6/20/98 - dihedral angle constraints
5371 itori=idih_constr(i)
5373 difi=pinorm(phii-phi0(i))
5375 if (difi.gt.drange(i)) then
5377 edihcnstr=edihcnstr+0.25d0*ftors(i)*difi**4
5378 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors(i)*difi**3
5379 edihi=0.25d0*ftors(i)*difi**4
5380 else if (difi.lt.-drange(i)) then
5382 edihcnstr=edihcnstr+0.25d0*ftors(i)*difi**4
5383 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors(i)*difi**3
5384 edihi=0.25d0*ftors(i)*difi**4
5388 write (iout,'(a6,2i5,2f8.3,2e14.5)') "edih",
5389 & i,itori,rad2deg*phii,
5390 & rad2deg*difi,0.25d0*ftors(i)*difi**4
5391 c write (iout,'(2i5,4f10.5,e15.5)') i,itori,phii,phi0(i),difi,
5393 ! write (iout,'(2i5,2f8.3,2e14.5)') i,itori,rad2deg*phii,
5394 ! & rad2deg*difi,0.25d0*ftors(i)*difi**4,gloc(itori-3,icg)
5396 ! write (iout,*) 'edihcnstr',edihcnstr
5399 c----------------------------------------------------------------------------
5400 subroutine etor_d(etors_d,fact2)
5401 C 6/23/01 Compute double torsional energy
5402 implicit real*8 (a-h,o-z)
5403 include 'DIMENSIONS'
5404 include 'DIMENSIONS.ZSCOPT'
5405 include 'COMMON.VAR'
5406 include 'COMMON.GEO'
5407 include 'COMMON.LOCAL'
5408 include 'COMMON.TORSION'
5409 include 'COMMON.INTERACT'
5410 include 'COMMON.DERIV'
5411 include 'COMMON.CHAIN'
5412 include 'COMMON.NAMES'
5413 include 'COMMON.IOUNITS'
5414 include 'COMMON.FFIELD'
5415 include 'COMMON.TORCNSTR'
5417 C Set lprn=.true. for debugging
5421 do i=iphi_start,iphi_end-1
5423 C if (itype(i-2).eq.ntyp1.or. itype(i-1).eq.ntyp1
5424 C & .or. itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1) cycle
5425 if ((itype(i-2).eq.ntyp1).or.itype(i-3).eq.ntyp1.or.
5426 & (itype(i-1).eq.ntyp1).or.(itype(i).eq.ntyp1).or.
5427 & (itype(i+1).eq.ntyp1)) cycle
5428 if (itel(i-2).eq.0 .or. itel(i-1).eq.0 .or. itel(i).eq.0)
5430 itori=itortyp(itype(i-2))
5431 itori1=itortyp(itype(i-1))
5432 itori2=itortyp(itype(i))
5438 if (iabs(itype(i+1)).eq.20) iblock=2
5439 C Regular cosine and sine terms
5440 do j=1,ntermd_1(itori,itori1,itori2,iblock)
5441 v1cij=v1c(1,j,itori,itori1,itori2,iblock)
5442 v1sij=v1s(1,j,itori,itori1,itori2,iblock)
5443 v2cij=v1c(2,j,itori,itori1,itori2,iblock)
5444 v2sij=v1s(2,j,itori,itori1,itori2,iblock)
5445 cosphi1=dcos(j*phii)
5446 sinphi1=dsin(j*phii)
5447 cosphi2=dcos(j*phii1)
5448 sinphi2=dsin(j*phii1)
5449 etors_d=etors_d+v1cij*cosphi1+v1sij*sinphi1+
5450 & v2cij*cosphi2+v2sij*sinphi2
5451 gloci1=gloci1+j*(v1sij*cosphi1-v1cij*sinphi1)
5452 gloci2=gloci2+j*(v2sij*cosphi2-v2cij*sinphi2)
5454 do k=2,ntermd_2(itori,itori1,itori2,iblock)
5456 v1cdij = v2c(k,l,itori,itori1,itori2,iblock)
5457 v2cdij = v2c(l,k,itori,itori1,itori2,iblock)
5458 v1sdij = v2s(k,l,itori,itori1,itori2,iblock)
5459 v2sdij = v2s(l,k,itori,itori1,itori2,iblock)
5460 cosphi1p2=dcos(l*phii+(k-l)*phii1)
5461 cosphi1m2=dcos(l*phii-(k-l)*phii1)
5462 sinphi1p2=dsin(l*phii+(k-l)*phii1)
5463 sinphi1m2=dsin(l*phii-(k-l)*phii1)
5464 etors_d=etors_d+v1cdij*cosphi1p2+v2cdij*cosphi1m2+
5465 & v1sdij*sinphi1p2+v2sdij*sinphi1m2
5466 gloci1=gloci1+l*(v1sdij*cosphi1p2+v2sdij*cosphi1m2
5467 & -v1cdij*sinphi1p2-v2cdij*sinphi1m2)
5468 gloci2=gloci2+(k-l)*(v1sdij*cosphi1p2-v2sdij*cosphi1m2
5469 & -v1cdij*sinphi1p2+v2cdij*sinphi1m2)
5472 gloc(i-3,icg)=gloc(i-3,icg)+wtor_d*fact2*gloci1
5473 gloc(i-2,icg)=gloc(i-2,icg)+wtor_d*fact2*gloci2
5479 c------------------------------------------------------------------------------
5480 subroutine eback_sc_corr(esccor)
5481 c 7/21/2007 Correlations between the backbone-local and side-chain-local
5482 c conformational states; temporarily implemented as differences
5483 c between UNRES torsional potentials (dependent on three types of
5484 c residues) and the torsional potentials dependent on all 20 types
5485 c of residues computed from AM1 energy surfaces of terminally-blocked
5486 c amino-acid residues.
5487 implicit real*8 (a-h,o-z)
5488 include 'DIMENSIONS'
5489 include 'DIMENSIONS.ZSCOPT'
5490 include 'COMMON.VAR'
5491 include 'COMMON.GEO'
5492 include 'COMMON.LOCAL'
5493 include 'COMMON.TORSION'
5494 include 'COMMON.SCCOR'
5495 include 'COMMON.INTERACT'
5496 include 'COMMON.DERIV'
5497 include 'COMMON.CHAIN'
5498 include 'COMMON.NAMES'
5499 include 'COMMON.IOUNITS'
5500 include 'COMMON.FFIELD'
5501 include 'COMMON.CONTROL'
5503 C Set lprn=.true. for debugging
5506 c write (iout,*) "EBACK_SC_COR",iphi_start,iphi_end,nterm_sccor
5508 do i=itau_start,itau_end
5509 if ((itype(i-2).eq.ntyp1).or.(itype(i-1).eq.ntyp1)) cycle
5511 isccori=isccortyp(itype(i-2))
5512 isccori1=isccortyp(itype(i-1))
5514 do intertyp=1,3 !intertyp
5515 cc Added 09 May 2012 (Adasko)
5516 cc Intertyp means interaction type of backbone mainchain correlation:
5517 c 1 = SC...Ca...Ca...Ca
5518 c 2 = Ca...Ca...Ca...SC
5519 c 3 = SC...Ca...Ca...SCi
5521 if (((intertyp.eq.3).and.((itype(i-2).eq.10).or.
5522 & (itype(i-1).eq.10).or.(itype(i-2).eq.ntyp1).or.
5523 & (itype(i-1).eq.ntyp1)))
5524 & .or. ((intertyp.eq.1).and.((itype(i-2).eq.10)
5525 & .or.(itype(i-2).eq.ntyp1).or.(itype(i-1).eq.ntyp1)
5526 & .or.(itype(i).eq.ntyp1)))
5527 & .or.((intertyp.eq.2).and.((itype(i-1).eq.10).or.
5528 & (itype(i-1).eq.ntyp1).or.(itype(i-2).eq.ntyp1).or.
5529 & (itype(i-3).eq.ntyp1)))) cycle
5530 if ((intertyp.eq.2).and.(i.eq.4).and.(itype(1).eq.ntyp1)) cycle
5531 if ((intertyp.eq.1).and.(i.eq.nres).and.(itype(nres).eq.ntyp1))
5533 do j=1,nterm_sccor(isccori,isccori1)
5534 v1ij=v1sccor(j,intertyp,isccori,isccori1)
5535 v2ij=v2sccor(j,intertyp,isccori,isccori1)
5536 cosphi=dcos(j*tauangle(intertyp,i))
5537 sinphi=dsin(j*tauangle(intertyp,i))
5538 esccor=esccor+v1ij*cosphi+v2ij*sinphi
5539 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
5541 C write (iout,*)"EBACK_SC_COR",esccor,i
5542 c write (iout,*) "EBACK_SC_COR",i,v1ij*cosphi+v2ij*sinphi,intertyp,
5543 c & nterm_sccor(isccori,isccori1),isccori,isccori1
5544 c gloc_sc(intertyp,i-3,icg)=gloc_sc(intertyp,i-3,icg)+wsccor*gloci
5546 & write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)')
5547 & restyp(itype(i-2)),i-2,restyp(itype(i-1)),i-1,itori,itori1,
5548 & (v1sccor(j,1,itori,itori1),j=1,6)
5549 & ,(v2sccor(j,1,itori,itori1),j=1,6)
5550 c gsccor_loc(i-3)=gloci
5555 c------------------------------------------------------------------------------
5556 subroutine multibody(ecorr)
5557 C This subroutine calculates multi-body contributions to energy following
5558 C the idea of Skolnick et al. If side chains I and J make a contact and
5559 C at the same time side chains I+1 and J+1 make a contact, an extra
5560 C contribution equal to sqrt(eps(i,j)*eps(i+1,j+1)) is added.
5561 implicit real*8 (a-h,o-z)
5562 include 'DIMENSIONS'
5563 include 'COMMON.IOUNITS'
5564 include 'COMMON.DERIV'
5565 include 'COMMON.INTERACT'
5566 include 'COMMON.CONTACTS'
5567 double precision gx(3),gx1(3)
5570 C Set lprn=.true. for debugging
5574 write (iout,'(a)') 'Contact function values:'
5576 write (iout,'(i2,20(1x,i2,f10.5))')
5577 & i,(jcont(j,i),facont(j,i),j=1,num_cont(i))
5592 num_conti=num_cont(i)
5593 num_conti1=num_cont(i1)
5598 if (j1.eq.j+ishift .or. j1.eq.j-ishift) then
5599 cd write(iout,*)'i=',i,' j=',j,' i1=',i1,' j1=',j1,
5600 cd & ' ishift=',ishift
5601 C Contacts I--J and I+ISHIFT--J+-ISHIFT1 occur simultaneously.
5602 C The system gains extra energy.
5603 ecorr=ecorr+esccorr(i,j,i1,j1,jj,kk)
5604 endif ! j1==j+-ishift
5613 c------------------------------------------------------------------------------
5614 double precision function esccorr(i,j,k,l,jj,kk)
5615 implicit real*8 (a-h,o-z)
5616 include 'DIMENSIONS'
5617 include 'COMMON.IOUNITS'
5618 include 'COMMON.DERIV'
5619 include 'COMMON.INTERACT'
5620 include 'COMMON.CONTACTS'
5621 double precision gx(3),gx1(3)
5626 cd write (iout,'(4i5,3f10.5)') i,j,k,l,eij,ekl,-eij*ekl
5627 C Calculate the multi-body contribution to energy.
5628 C Calculate multi-body contributions to the gradient.
5629 cd write (iout,'(2(2i3,3f10.5))')i,j,(gacont(m,jj,i),m=1,3),
5630 cd & k,l,(gacont(m,kk,k),m=1,3)
5632 gx(m) =ekl*gacont(m,jj,i)
5633 gx1(m)=eij*gacont(m,kk,k)
5634 gradxorr(m,i)=gradxorr(m,i)-gx(m)
5635 gradxorr(m,j)=gradxorr(m,j)+gx(m)
5636 gradxorr(m,k)=gradxorr(m,k)-gx1(m)
5637 gradxorr(m,l)=gradxorr(m,l)+gx1(m)
5641 gradcorr(ll,m)=gradcorr(ll,m)+gx(ll)
5646 gradcorr(ll,m)=gradcorr(ll,m)+gx1(ll)
5652 c------------------------------------------------------------------------------
5654 subroutine pack_buffer(dimen1,dimen2,atom,indx,buffer)
5655 implicit real*8 (a-h,o-z)
5656 include 'DIMENSIONS'
5657 integer dimen1,dimen2,atom,indx
5658 double precision buffer(dimen1,dimen2)
5659 double precision zapas
5660 common /contacts_hb/ zapas(3,ntyp,maxres,7),
5661 & facont_hb(ntyp,maxres),ees0p(ntyp,maxres),ees0m(ntyp,maxres),
5662 & num_cont_hb(maxres),jcont_hb(ntyp,maxres)
5663 num_kont=num_cont_hb(atom)
5667 buffer(i,indx+(k-1)*3+j)=zapas(j,i,atom,k)
5670 buffer(i,indx+22)=facont_hb(i,atom)
5671 buffer(i,indx+23)=ees0p(i,atom)
5672 buffer(i,indx+24)=ees0m(i,atom)
5673 buffer(i,indx+25)=dfloat(jcont_hb(i,atom))
5675 buffer(1,indx+26)=dfloat(num_kont)
5678 c------------------------------------------------------------------------------
5679 subroutine unpack_buffer(dimen1,dimen2,atom,indx,buffer)
5680 implicit real*8 (a-h,o-z)
5681 include 'DIMENSIONS'
5682 integer dimen1,dimen2,atom,indx
5683 double precision buffer(dimen1,dimen2)
5684 double precision zapas
5685 common /contacts_hb/ zapas(3,ntyp,maxres,7),
5686 & facont_hb(ntyp,maxres),ees0p(ntyp,maxres),
5687 & ees0m(ntyp,maxres),
5688 & num_cont_hb(maxres),jcont_hb(ntyp,maxres)
5689 num_kont=buffer(1,indx+26)
5690 num_kont_old=num_cont_hb(atom)
5691 num_cont_hb(atom)=num_kont+num_kont_old
5696 zapas(j,ii,atom,k)=buffer(i,indx+(k-1)*3+j)
5699 facont_hb(ii,atom)=buffer(i,indx+22)
5700 ees0p(ii,atom)=buffer(i,indx+23)
5701 ees0m(ii,atom)=buffer(i,indx+24)
5702 jcont_hb(ii,atom)=buffer(i,indx+25)
5706 c------------------------------------------------------------------------------
5708 subroutine multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
5709 C This subroutine calculates multi-body contributions to hydrogen-bonding
5710 implicit real*8 (a-h,o-z)
5711 include 'DIMENSIONS'
5712 include 'DIMENSIONS.ZSCOPT'
5713 include 'COMMON.IOUNITS'
5715 include 'COMMON.INFO'
5717 include 'COMMON.FFIELD'
5718 include 'COMMON.DERIV'
5719 include 'COMMON.INTERACT'
5720 include 'COMMON.CONTACTS'
5722 parameter (max_cont=maxconts)
5723 parameter (max_dim=2*(8*3+2))
5724 parameter (msglen1=max_cont*max_dim*4)
5725 parameter (msglen2=2*msglen1)
5726 integer source,CorrelType,CorrelID,Error
5727 double precision buffer(max_cont,max_dim)
5729 double precision gx(3),gx1(3)
5732 C Set lprn=.true. for debugging
5737 if (fgProcs.le.1) goto 30
5739 write (iout,'(a)') 'Contact function values:'
5741 write (iout,'(2i3,50(1x,i2,f5.2))')
5742 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
5743 & j=1,num_cont_hb(i))
5746 C Caution! Following code assumes that electrostatic interactions concerning
5747 C a given atom are split among at most two processors!
5757 cd write (iout,*) 'MyRank',MyRank,' mm',mm
5760 cd write (iout,*) 'Sending: MyRank',MyRank,' mm',mm,' ldone',ldone
5761 if (MyRank.gt.0) then
5762 C Send correlation contributions to the preceding processor
5764 nn=num_cont_hb(iatel_s)
5765 call pack_buffer(max_cont,max_dim,iatel_s,0,buffer)
5766 cd write (iout,*) 'The BUFFER array:'
5768 cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,26)
5770 if (ielstart(iatel_s).gt.iatel_s+ispp) then
5772 call pack_buffer(max_cont,max_dim,iatel_s+1,26,buffer)
5773 C Clear the contacts of the atom passed to the neighboring processor
5774 nn=num_cont_hb(iatel_s+1)
5776 cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j+26),j=1,26)
5778 num_cont_hb(iatel_s)=0
5780 cd write (iout,*) 'Processor ',MyID,MyRank,
5781 cd & ' is sending correlation contribution to processor',MyID-1,
5782 cd & ' msglen=',msglen
5783 cd write (*,*) 'Processor ',MyID,MyRank,
5784 cd & ' is sending correlation contribution to processor',MyID-1,
5785 cd & ' msglen=',msglen,' CorrelType=',CorrelType
5786 call mp_bsend(buffer,msglen,MyID-1,CorrelType,CorrelID)
5787 cd write (iout,*) 'Processor ',MyID,
5788 cd & ' has sent correlation contribution to processor',MyID-1,
5789 cd & ' msglen=',msglen,' CorrelID=',CorrelID
5790 cd write (*,*) 'Processor ',MyID,
5791 cd & ' has sent correlation contribution to processor',MyID-1,
5792 cd & ' msglen=',msglen,' CorrelID=',CorrelID
5794 endif ! (MyRank.gt.0)
5798 cd write (iout,*) 'Receiving: MyRank',MyRank,' mm',mm,' ldone',ldone
5799 if (MyRank.lt.fgProcs-1) then
5800 C Receive correlation contributions from the next processor
5802 if (ielend(iatel_e).lt.nct-1) msglen=msglen2
5803 cd write (iout,*) 'Processor',MyID,
5804 cd & ' is receiving correlation contribution from processor',MyID+1,
5805 cd & ' msglen=',msglen,' CorrelType=',CorrelType
5806 cd write (*,*) 'Processor',MyID,
5807 cd & ' is receiving correlation contribution from processor',MyID+1,
5808 cd & ' msglen=',msglen,' CorrelType=',CorrelType
5810 do while (nbytes.le.0)
5811 call mp_probe(MyID+1,CorrelType,nbytes)
5813 cd print *,'Processor',MyID,' msglen',msglen,' nbytes',nbytes
5814 call mp_brecv(buffer,msglen,MyID+1,CorrelType,nbytes)
5815 cd write (iout,*) 'Processor',MyID,
5816 cd & ' has received correlation contribution from processor',MyID+1,
5817 cd & ' msglen=',msglen,' nbytes=',nbytes
5818 cd write (iout,*) 'The received BUFFER array:'
5820 cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,52)
5822 if (msglen.eq.msglen1) then
5823 call unpack_buffer(max_cont,max_dim,iatel_e+1,0,buffer)
5824 else if (msglen.eq.msglen2) then
5825 call unpack_buffer(max_cont,max_dim,iatel_e,0,buffer)
5826 call unpack_buffer(max_cont,max_dim,iatel_e+1,26,buffer)
5829 & 'ERROR!!!! message length changed while processing correlations.'
5831 & 'ERROR!!!! message length changed while processing correlations.'
5832 call mp_stopall(Error)
5833 endif ! msglen.eq.msglen1
5834 endif ! MyRank.lt.fgProcs-1
5841 write (iout,'(a)') 'Contact function values:'
5843 write (iout,'(2i3,50(1x,i2,f5.2))')
5844 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
5845 & j=1,num_cont_hb(i))
5849 C Remove the loop below after debugging !!!
5856 C Calculate the local-electrostatic correlation terms
5857 do i=iatel_s,iatel_e+1
5859 num_conti=num_cont_hb(i)
5860 num_conti1=num_cont_hb(i+1)
5865 c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
5866 c & ' jj=',jj,' kk=',kk
5867 if (j1.eq.j+1 .or. j1.eq.j-1) then
5868 C Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
5869 C The system gains extra energy.
5870 ecorr=ecorr+ehbcorr(i,j,i+1,j1,jj,kk,0.72D0,0.32D0)
5872 else if (j1.eq.j) then
5873 C Contacts I-J and I-(J+1) occur simultaneously.
5874 C The system loses extra energy.
5875 c ecorr=ecorr+ehbcorr(i,j,i+1,j,jj,kk,0.60D0,-0.40D0)
5880 c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
5881 c & ' jj=',jj,' kk=',kk
5883 C Contacts I-J and (I+1)-J occur simultaneously.
5884 C The system loses extra energy.
5885 c ecorr=ecorr+ehbcorr(i,j,i,j+1,jj,kk,0.60D0,-0.40D0)
5892 c------------------------------------------------------------------------------
5893 subroutine multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,
5895 C This subroutine calculates multi-body contributions to hydrogen-bonding
5896 implicit real*8 (a-h,o-z)
5897 include 'DIMENSIONS'
5898 include 'DIMENSIONS.ZSCOPT'
5899 include 'COMMON.IOUNITS'
5901 include 'COMMON.INFO'
5903 include 'COMMON.FFIELD'
5904 include 'COMMON.DERIV'
5905 include 'COMMON.INTERACT'
5906 include 'COMMON.CONTACTS'
5908 parameter (max_cont=maxconts)
5909 parameter (max_dim=2*(8*3+2))
5910 parameter (msglen1=max_cont*max_dim*4)
5911 parameter (msglen2=2*msglen1)
5912 integer source,CorrelType,CorrelID,Error
5913 double precision buffer(max_cont,max_dim)
5915 double precision gx(3),gx1(3)
5918 C Set lprn=.true. for debugging
5925 if (fgProcs.le.1) goto 30
5927 write (iout,'(a)') 'Contact function values:'
5929 write (iout,'(2i3,50(1x,i2,f5.2))')
5930 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
5931 & j=1,num_cont_hb(i))
5934 C Caution! Following code assumes that electrostatic interactions concerning
5935 C a given atom are split among at most two processors!
5945 cd write (iout,*) 'MyRank',MyRank,' mm',mm
5948 cd write (iout,*) 'Sending: MyRank',MyRank,' mm',mm,' ldone',ldone
5949 if (MyRank.gt.0) then
5950 C Send correlation contributions to the preceding processor
5952 nn=num_cont_hb(iatel_s)
5953 call pack_buffer(max_cont,max_dim,iatel_s,0,buffer)
5954 cd write (iout,*) 'The BUFFER array:'
5956 cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,26)
5958 if (ielstart(iatel_s).gt.iatel_s+ispp) then
5960 call pack_buffer(max_cont,max_dim,iatel_s+1,26,buffer)
5961 C Clear the contacts of the atom passed to the neighboring processor
5962 nn=num_cont_hb(iatel_s+1)
5964 cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j+26),j=1,26)
5966 num_cont_hb(iatel_s)=0
5968 cd write (iout,*) 'Processor ',MyID,MyRank,
5969 cd & ' is sending correlation contribution to processor',MyID-1,
5970 cd & ' msglen=',msglen
5971 cd write (*,*) 'Processor ',MyID,MyRank,
5972 cd & ' is sending correlation contribution to processor',MyID-1,
5973 cd & ' msglen=',msglen,' CorrelType=',CorrelType
5974 call mp_bsend(buffer,msglen,MyID-1,CorrelType,CorrelID)
5975 cd write (iout,*) 'Processor ',MyID,
5976 cd & ' has sent correlation contribution to processor',MyID-1,
5977 cd & ' msglen=',msglen,' CorrelID=',CorrelID
5978 cd write (*,*) 'Processor ',MyID,
5979 cd & ' has sent correlation contribution to processor',MyID-1,
5980 cd & ' msglen=',msglen,' CorrelID=',CorrelID
5982 endif ! (MyRank.gt.0)
5986 cd write (iout,*) 'Receiving: MyRank',MyRank,' mm',mm,' ldone',ldone
5987 if (MyRank.lt.fgProcs-1) then
5988 C Receive correlation contributions from the next processor
5990 if (ielend(iatel_e).lt.nct-1) msglen=msglen2
5991 cd write (iout,*) 'Processor',MyID,
5992 cd & ' is receiving correlation contribution from processor',MyID+1,
5993 cd & ' msglen=',msglen,' CorrelType=',CorrelType
5994 cd write (*,*) 'Processor',MyID,
5995 cd & ' is receiving correlation contribution from processor',MyID+1,
5996 cd & ' msglen=',msglen,' CorrelType=',CorrelType
5998 do while (nbytes.le.0)
5999 call mp_probe(MyID+1,CorrelType,nbytes)
6001 cd print *,'Processor',MyID,' msglen',msglen,' nbytes',nbytes
6002 call mp_brecv(buffer,msglen,MyID+1,CorrelType,nbytes)
6003 cd write (iout,*) 'Processor',MyID,
6004 cd & ' has received correlation contribution from processor',MyID+1,
6005 cd & ' msglen=',msglen,' nbytes=',nbytes
6006 cd write (iout,*) 'The received BUFFER array:'
6008 cd write (iout,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,52)
6010 if (msglen.eq.msglen1) then
6011 call unpack_buffer(max_cont,max_dim,iatel_e+1,0,buffer)
6012 else if (msglen.eq.msglen2) then
6013 call unpack_buffer(max_cont,max_dim,iatel_e,0,buffer)
6014 call unpack_buffer(max_cont,max_dim,iatel_e+1,26,buffer)
6017 & 'ERROR!!!! message length changed while processing correlations.'
6019 & 'ERROR!!!! message length changed while processing correlations.'
6020 call mp_stopall(Error)
6021 endif ! msglen.eq.msglen1
6022 endif ! MyRank.lt.fgProcs-1
6029 write (iout,'(a)') 'Contact function values:'
6031 write (iout,'(2i3,50(1x,i2,f5.2))')
6032 & i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),
6033 & j=1,num_cont_hb(i))
6039 C Remove the loop below after debugging !!!
6046 C Calculate the dipole-dipole interaction energies
6047 if (wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) then
6048 do i=iatel_s,iatel_e+1
6049 num_conti=num_cont_hb(i)
6056 C Calculate the local-electrostatic correlation terms
6057 do i=iatel_s,iatel_e+1
6059 num_conti=num_cont_hb(i)
6060 num_conti1=num_cont_hb(i+1)
6065 c write (*,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
6066 c & ' jj=',jj,' kk=',kk
6067 if (j1.eq.j+1 .or. j1.eq.j-1) then
6068 C Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
6069 C The system gains extra energy.
6071 sqd1=dsqrt(d_cont(jj,i))
6072 sqd2=dsqrt(d_cont(kk,i1))
6073 sred_geom = sqd1*sqd2
6074 IF (sred_geom.lt.cutoff_corr) THEN
6075 call gcont(sred_geom,r0_corr,1.0D0,delt_corr,
6077 c write (*,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
6078 c & ' jj=',jj,' kk=',kk
6079 fac_prim1=0.5d0*sqd2/sqd1*fprimcont
6080 fac_prim2=0.5d0*sqd1/sqd2*fprimcont
6082 g_contij(l,1)=fac_prim1*grij_hb_cont(l,jj,i)
6083 g_contij(l,2)=fac_prim2*grij_hb_cont(l,kk,i1)
6086 cd write (iout,*) 'sred_geom=',sred_geom,
6087 cd & ' ekont=',ekont,' fprim=',fprimcont
6088 call calc_eello(i,j,i+1,j1,jj,kk)
6089 if (wcorr4.gt.0.0d0)
6090 & ecorr=ecorr+eello4(i,j,i+1,j1,jj,kk)
6091 if (wcorr5.gt.0.0d0)
6092 & ecorr5=ecorr5+eello5(i,j,i+1,j1,jj,kk)
6093 c print *,"wcorr5",ecorr5
6094 cd write(2,*)'wcorr6',wcorr6,' wturn6',wturn6
6095 cd write(2,*)'ijkl',i,j,i+1,j1
6096 if (wcorr6.gt.0.0d0 .and. (j.ne.i+4 .or. j1.ne.i+3
6097 & .or. wturn6.eq.0.0d0))then
6098 cd write (iout,*) '******ecorr6: i,j,i+1,j1',i,j,i+1,j1
6099 ecorr6=ecorr6+eello6(i,j,i+1,j1,jj,kk)
6100 cd write (iout,*) 'ecorr',ecorr,' ecorr5=',ecorr5,
6101 cd & 'ecorr6=',ecorr6
6102 cd write (iout,'(4e15.5)') sred_geom,
6103 cd & dabs(eello4(i,j,i+1,j1,jj,kk)),
6104 cd & dabs(eello5(i,j,i+1,j1,jj,kk)),
6105 cd & dabs(eello6(i,j,i+1,j1,jj,kk))
6106 else if (wturn6.gt.0.0d0
6107 & .and. (j.eq.i+4 .and. j1.eq.i+3)) then
6108 cd write (iout,*) '******eturn6: i,j,i+1,j1',i,j,i+1,j1
6109 eturn6=eturn6+eello_turn6(i,jj,kk)
6110 cd write (2,*) 'multibody_eello:eturn6',eturn6
6111 else if ((wturn6.eq.0.0d0).and.(wcorr6.eq.0.0d0)) then
6118 else if (j1.eq.j) then
6119 C Contacts I-J and I-(J+1) occur simultaneously.
6120 C The system loses extra energy.
6121 c ecorr=ecorr+ehbcorr(i,j,i+1,j,jj,kk,0.60D0,-0.40D0)
6126 c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
6127 c & ' jj=',jj,' kk=',kk
6129 C Contacts I-J and (I+1)-J occur simultaneously.
6130 C The system loses extra energy.
6131 c ecorr=ecorr+ehbcorr(i,j,i,j+1,jj,kk,0.60D0,-0.40D0)
6136 write (iout,*) "eturn6",eturn6,ecorr6
6139 c------------------------------------------------------------------------------
6140 double precision function ehbcorr(i,j,k,l,jj,kk,coeffp,coeffm)
6141 implicit real*8 (a-h,o-z)
6142 include 'DIMENSIONS'
6143 include 'COMMON.IOUNITS'
6144 include 'COMMON.DERIV'
6145 include 'COMMON.INTERACT'
6146 include 'COMMON.CONTACTS'
6147 include 'COMMON.CONTROL'
6148 include 'COMMON.SHIELD'
6149 double precision gx(3),gx1(3)
6159 ees=-(coeffp*ees0pij*ees0pkl+coeffm*ees0mij*ees0mkl)
6160 cd ees=-(coeffp*ees0pkl+coeffm*ees0mkl)
6161 C Following 4 lines for diagnostics.
6166 c write (iout,*)'Contacts have occurred for peptide groups',i,j,
6168 c write (iout,*)'Contacts have occurred for peptide groups',
6169 c & i,j,' fcont:',eij,' eij',' eesij',ees0pij,ees0mij,' and ',k,l
6170 c & ,' fcont ',ekl,' eeskl',ees0pkl,ees0mkl,' ees=',ees
6171 C Calculate the multi-body contribution to energy.
6172 C ecorr=ecorr+ekont*ees
6174 C Calculate multi-body contributions to the gradient.
6176 ghalf=0.5D0*ees*ekl*gacont_hbr(ll,jj,i)
6177 gradcorr(ll,i)=gradcorr(ll,i)+ghalf
6178 & -ekont*(coeffp*ees0pkl*gacontp_hb1(ll,jj,i)+
6179 & coeffm*ees0mkl*gacontm_hb1(ll,jj,i))
6180 gradcorr(ll,j)=gradcorr(ll,j)+ghalf
6181 & -ekont*(coeffp*ees0pkl*gacontp_hb2(ll,jj,i)+
6182 & coeffm*ees0mkl*gacontm_hb2(ll,jj,i))
6183 ghalf=0.5D0*ees*eij*gacont_hbr(ll,kk,k)
6184 gradcorr(ll,k)=gradcorr(ll,k)+ghalf
6185 & -ekont*(coeffp*ees0pij*gacontp_hb1(ll,kk,k)+
6186 & coeffm*ees0mij*gacontm_hb1(ll,kk,k))
6187 gradcorr(ll,l)=gradcorr(ll,l)+ghalf
6188 & -ekont*(coeffp*ees0pij*gacontp_hb2(ll,kk,k)+
6189 & coeffm*ees0mij*gacontm_hb2(ll,kk,k))
6193 gradcorr(ll,m)=gradcorr(ll,m)+
6194 & ees*ekl*gacont_hbr(ll,jj,i)-
6195 & ekont*(coeffp*ees0pkl*gacontp_hb3(ll,jj,i)+
6196 & coeffm*ees0mkl*gacontm_hb3(ll,jj,i))
6201 gradcorr(ll,m)=gradcorr(ll,m)+
6202 & ees*eij*gacont_hbr(ll,kk,k)-
6203 & ekont*(coeffp*ees0pij*gacontp_hb3(ll,kk,k)+
6204 & coeffm*ees0mij*gacontm_hb3(ll,kk,k))
6207 if (shield_mode.gt.0) then
6210 C print *,i,j,fac_shield(i),fac_shield(j),
6211 C &fac_shield(k),fac_shield(l)
6212 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and.
6213 & (fac_shield(k).gt.0).and.(fac_shield(l).gt.0)) then
6214 do ilist=1,ishield_list(i)
6215 iresshield=shield_list(ilist,i)
6217 rlocshield=grad_shield_side(m,ilist,i)*ehbcorr/fac_shield(i)
6219 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+
6221 & +grad_shield_loc(m,ilist,i)*ehbcorr/fac_shield(i)
6222 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1)
6226 do ilist=1,ishield_list(j)
6227 iresshield=shield_list(ilist,j)
6229 rlocshield=grad_shield_side(m,ilist,j)*ehbcorr/fac_shield(j)
6231 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+
6233 & +grad_shield_loc(m,ilist,j)*ehbcorr/fac_shield(j)
6234 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1)
6238 do ilist=1,ishield_list(k)
6239 iresshield=shield_list(ilist,k)
6241 rlocshield=grad_shield_side(m,ilist,k)*ehbcorr/fac_shield(k)
6243 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+
6245 & +grad_shield_loc(m,ilist,k)*ehbcorr/fac_shield(k)
6246 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1)
6250 do ilist=1,ishield_list(l)
6251 iresshield=shield_list(ilist,l)
6253 rlocshield=grad_shield_side(m,ilist,l)*ehbcorr/fac_shield(l)
6255 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+
6257 & +grad_shield_loc(m,ilist,l)*ehbcorr/fac_shield(l)
6258 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1)
6262 C print *,gshieldx(m,iresshield)
6264 gshieldc_ec(m,i)=gshieldc_ec(m,i)+
6265 & grad_shield(m,i)*ehbcorr/fac_shield(i)
6266 gshieldc_ec(m,j)=gshieldc_ec(m,j)+
6267 & grad_shield(m,j)*ehbcorr/fac_shield(j)
6268 gshieldc_ec(m,i-1)=gshieldc_ec(m,i-1)+
6269 & grad_shield(m,i)*ehbcorr/fac_shield(i)
6270 gshieldc_ec(m,j-1)=gshieldc_ec(m,j-1)+
6271 & grad_shield(m,j)*ehbcorr/fac_shield(j)
6273 gshieldc_ec(m,k)=gshieldc_ec(m,k)+
6274 & grad_shield(m,k)*ehbcorr/fac_shield(k)
6275 gshieldc_ec(m,l)=gshieldc_ec(m,l)+
6276 & grad_shield(m,l)*ehbcorr/fac_shield(l)
6277 gshieldc_ec(m,k-1)=gshieldc_ec(m,k-1)+
6278 & grad_shield(m,k)*ehbcorr/fac_shield(k)
6279 gshieldc_ec(m,l-1)=gshieldc_ec(m,l-1)+
6280 & grad_shield(m,l)*ehbcorr/fac_shield(l)
6289 C---------------------------------------------------------------------------
6290 subroutine dipole(i,j,jj)
6291 implicit real*8 (a-h,o-z)
6292 include 'DIMENSIONS'
6293 include 'DIMENSIONS.ZSCOPT'
6294 include 'COMMON.IOUNITS'
6295 include 'COMMON.CHAIN'
6296 include 'COMMON.FFIELD'
6297 include 'COMMON.DERIV'
6298 include 'COMMON.INTERACT'
6299 include 'COMMON.CONTACTS'
6300 include 'COMMON.TORSION'
6301 include 'COMMON.VAR'
6302 include 'COMMON.GEO'
6303 dimension dipi(2,2),dipj(2,2),dipderi(2),dipderj(2),auxvec(2),
6305 iti1 = itortyp(itype(i+1))
6306 if (j.lt.nres-1) then
6307 if (itype(j).le.ntyp) then
6308 itj1 = itortyp(itype(j+1))
6316 dipi(iii,1)=Ub2(iii,i)
6317 dipderi(iii)=Ub2der(iii,i)
6318 dipi(iii,2)=b1(iii,iti1)
6319 dipj(iii,1)=Ub2(iii,j)
6320 dipderj(iii)=Ub2der(iii,j)
6321 dipj(iii,2)=b1(iii,itj1)
6325 call matvec2(a_chuj(1,1,jj,i),dipj(1,iii),auxvec(1))
6328 dip(kkk,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
6331 if (.not.calc_grad) return
6336 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),dipj(1,iii),
6340 dipderx(lll,kkk,mmm,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
6345 call transpose2(a_chuj(1,1,jj,i),auxmat(1,1))
6346 call matvec2(auxmat(1,1),dipderi(1),auxvec(1))
6348 dipderg(iii,jj,i)=scalar2(auxvec(1),dipj(1,iii))
6350 call matvec2(a_chuj(1,1,jj,i),dipderj(1),auxvec(1))
6352 dipderg(iii+2,jj,i)=scalar2(auxvec(1),dipi(1,iii))
6356 C---------------------------------------------------------------------------
6357 subroutine calc_eello(i,j,k,l,jj,kk)
6359 C This subroutine computes matrices and vectors needed to calculate
6360 C the fourth-, fifth-, and sixth-order local-electrostatic terms.
6362 implicit real*8 (a-h,o-z)
6363 include 'DIMENSIONS'
6364 include 'DIMENSIONS.ZSCOPT'
6365 include 'COMMON.IOUNITS'
6366 include 'COMMON.CHAIN'
6367 include 'COMMON.DERIV'
6368 include 'COMMON.INTERACT'
6369 include 'COMMON.CONTACTS'
6370 include 'COMMON.TORSION'
6371 include 'COMMON.VAR'
6372 include 'COMMON.GEO'
6373 include 'COMMON.FFIELD'
6374 double precision aa1(2,2),aa2(2,2),aa1t(2,2),aa2t(2,2),
6375 & aa1tder(2,2,3,5),aa2tder(2,2,3,5),auxmat(2,2)
6378 cd write (iout,*) 'calc_eello: i=',i,' j=',j,' k=',k,' l=',l,
6379 cd & ' jj=',jj,' kk=',kk
6380 cd if (i.ne.2 .or. j.ne.4 .or. k.ne.3 .or. l.ne.5) return
6383 aa1(iii,jjj)=a_chuj(iii,jjj,jj,i)
6384 aa2(iii,jjj)=a_chuj(iii,jjj,kk,k)
6387 call transpose2(aa1(1,1),aa1t(1,1))
6388 call transpose2(aa2(1,1),aa2t(1,1))
6391 call transpose2(a_chuj_der(1,1,lll,kkk,jj,i),
6392 & aa1tder(1,1,lll,kkk))
6393 call transpose2(a_chuj_der(1,1,lll,kkk,kk,k),
6394 & aa2tder(1,1,lll,kkk))
6398 C parallel orientation of the two CA-CA-CA frames.
6399 if (i.gt.1 .and. itype(i).le.ntyp) then
6400 iti=itortyp(itype(i))
6404 itk1=itortyp(itype(k+1))
6405 itj=itortyp(itype(j))
6406 if (l.lt.nres-1 .and. itype(l+1).le.ntyp) then
6407 itl1=itortyp(itype(l+1))
6411 C A1 kernel(j+1) A2T
6413 cd write (iout,'(3f10.5,5x,3f10.5)')
6414 cd & (EUg(iii,jjj,k),jjj=1,2),(EUg(iii,jjj,l),jjj=1,2)
6416 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
6417 & aa2tder(1,1,1,1),1,.false.,EUg(1,1,l),EUgder(1,1,l),
6418 & AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
6419 C Following matrices are needed only for 6-th order cumulants
6420 IF (wcorr6.gt.0.0d0) THEN
6421 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
6422 & aa2tder(1,1,1,1),1,.false.,EUgC(1,1,l),EUgCder(1,1,l),
6423 & AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
6424 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
6425 & aa2tder(1,1,1,1),2,.false.,Ug2DtEUg(1,1,l),
6426 & Ug2DtEUgder(1,1,1,l),ADtEA(1,1,1),ADtEAderg(1,1,1,1),
6427 & ADtEAderx(1,1,1,1,1,1))
6429 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
6430 & aa2tder(1,1,1,1),2,.false.,DtUg2EUg(1,1,l),
6431 & DtUg2EUgder(1,1,1,l),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),
6432 & ADtEA1derx(1,1,1,1,1,1))
6434 C End 6-th order cumulants
6437 cd write (2,*) 'In calc_eello6'
6439 cd write (2,*) 'iii=',iii
6441 cd write (2,*) 'kkk=',kkk
6443 cd write (2,'(3(2f10.5),5x)')
6444 cd & ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
6449 call transpose2(EUgder(1,1,k),auxmat(1,1))
6450 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
6451 call transpose2(EUg(1,1,k),auxmat(1,1))
6452 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
6453 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
6457 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),
6458 & EAEAderx(1,1,lll,kkk,iii,1))
6462 C A1T kernel(i+1) A2
6463 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
6464 & a_chuj_der(1,1,1,1,kk,k),1,.false.,EUg(1,1,k),EUgder(1,1,k),
6465 & AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
6466 C Following matrices are needed only for 6-th order cumulants
6467 IF (wcorr6.gt.0.0d0) THEN
6468 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
6469 & a_chuj_der(1,1,1,1,kk,k),1,.false.,EUgC(1,1,k),EUgCder(1,1,k),
6470 & AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
6471 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
6472 & a_chuj_der(1,1,1,1,kk,k),2,.false.,Ug2DtEUg(1,1,k),
6473 & Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),
6474 & ADtEAderx(1,1,1,1,1,2))
6475 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),
6476 & a_chuj_der(1,1,1,1,kk,k),2,.false.,DtUg2EUg(1,1,k),
6477 & DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),
6478 & ADtEA1derx(1,1,1,1,1,2))
6480 C End 6-th order cumulants
6481 call transpose2(EUgder(1,1,l),auxmat(1,1))
6482 call matmat2(auxmat(1,1),AEA(1,1,2),EAEAderg(1,1,1,2))
6483 call transpose2(EUg(1,1,l),auxmat(1,1))
6484 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
6485 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
6489 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
6490 & EAEAderx(1,1,lll,kkk,iii,2))
6495 C Calculate the vectors and their derivatives in virtual-bond dihedral angles.
6496 C They are needed only when the fifth- or the sixth-order cumulants are
6498 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) THEN
6499 call transpose2(AEA(1,1,1),auxmat(1,1))
6500 call matvec2(auxmat(1,1),b1(1,iti),AEAb1(1,1,1))
6501 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
6502 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
6503 call transpose2(AEAderg(1,1,1),auxmat(1,1))
6504 call matvec2(auxmat(1,1),b1(1,iti),AEAb1derg(1,1,1))
6505 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
6506 call matvec2(AEA(1,1,1),b1(1,itk1),AEAb1(1,2,1))
6507 call matvec2(AEAderg(1,1,1),b1(1,itk1),AEAb1derg(1,2,1))
6508 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
6509 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
6510 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
6511 call transpose2(AEA(1,1,2),auxmat(1,1))
6512 call matvec2(auxmat(1,1),b1(1,itj),AEAb1(1,1,2))
6513 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2(1,1,2))
6514 call matvec2(auxmat(1,1),Ub2der(1,j),AEAb2derg(1,2,1,2))
6515 call transpose2(AEAderg(1,1,2),auxmat(1,1))
6516 call matvec2(auxmat(1,1),b1(1,itj),AEAb1derg(1,1,2))
6517 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2derg(1,1,1,2))
6518 call matvec2(AEA(1,1,2),b1(1,itl1),AEAb1(1,2,2))
6519 call matvec2(AEAderg(1,1,2),b1(1,itl1),AEAb1derg(1,2,2))
6520 call matvec2(AEA(1,1,2),Ub2(1,l+1),AEAb2(1,2,2))
6521 call matvec2(AEAderg(1,1,2),Ub2(1,l+1),AEAb2derg(1,1,2,2))
6522 call matvec2(AEA(1,1,2),Ub2der(1,l+1),AEAb2derg(1,2,2,2))
6523 C Calculate the Cartesian derivatives of the vectors.
6527 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
6528 call matvec2(auxmat(1,1),b1(1,iti),
6529 & AEAb1derx(1,lll,kkk,iii,1,1))
6530 call matvec2(auxmat(1,1),Ub2(1,i),
6531 & AEAb2derx(1,lll,kkk,iii,1,1))
6532 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,itk1),
6533 & AEAb1derx(1,lll,kkk,iii,2,1))
6534 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),
6535 & AEAb2derx(1,lll,kkk,iii,2,1))
6536 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
6537 call matvec2(auxmat(1,1),b1(1,itj),
6538 & AEAb1derx(1,lll,kkk,iii,1,2))
6539 call matvec2(auxmat(1,1),Ub2(1,j),
6540 & AEAb2derx(1,lll,kkk,iii,1,2))
6541 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,itl1),
6542 & AEAb1derx(1,lll,kkk,iii,2,2))
6543 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,l+1),
6544 & AEAb2derx(1,lll,kkk,iii,2,2))
6551 C Antiparallel orientation of the two CA-CA-CA frames.
6552 if (i.gt.1 .and. itype(i).le.ntyp) then
6553 iti=itortyp(itype(i))
6557 itk1=itortyp(itype(k+1))
6558 itl=itortyp(itype(l))
6559 itj=itortyp(itype(j))
6560 if (j.lt.nres-1 .and. itype(j+1).le.ntyp) then
6561 itj1=itortyp(itype(j+1))
6565 C A2 kernel(j-1)T A1T
6566 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
6567 & aa2tder(1,1,1,1),1,.true.,EUg(1,1,j),EUgder(1,1,j),
6568 & AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
6569 C Following matrices are needed only for 6-th order cumulants
6570 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and.
6571 & j.eq.i+4 .and. l.eq.i+3)) THEN
6572 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
6573 & aa2tder(1,1,1,1),1,.true.,EUgC(1,1,j),EUgCder(1,1,j),
6574 & AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
6575 call kernel(aa2(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
6576 & aa2tder(1,1,1,1),2,.true.,Ug2DtEUg(1,1,j),
6577 & Ug2DtEUgder(1,1,1,j),ADtEA(1,1,1),ADtEAderg(1,1,1,1),
6578 & ADtEAderx(1,1,1,1,1,1))
6579 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),
6580 & aa2tder(1,1,1,1),2,.true.,DtUg2EUg(1,1,j),
6581 & DtUg2EUgder(1,1,1,j),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),
6582 & ADtEA1derx(1,1,1,1,1,1))
6584 C End 6-th order cumulants
6585 call transpose2(EUgder(1,1,k),auxmat(1,1))
6586 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
6587 call transpose2(EUg(1,1,k),auxmat(1,1))
6588 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
6589 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
6593 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),
6594 & EAEAderx(1,1,lll,kkk,iii,1))
6598 C A2T kernel(i+1)T A1
6599 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
6600 & a_chuj_der(1,1,1,1,jj,i),1,.true.,EUg(1,1,k),EUgder(1,1,k),
6601 & AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
6602 C Following matrices are needed only for 6-th order cumulants
6603 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and.
6604 & j.eq.i+4 .and. l.eq.i+3)) THEN
6605 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
6606 & a_chuj_der(1,1,1,1,jj,i),1,.true.,EUgC(1,1,k),EUgCder(1,1,k),
6607 & AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
6608 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
6609 & a_chuj_der(1,1,1,1,jj,i),2,.true.,Ug2DtEUg(1,1,k),
6610 & Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),
6611 & ADtEAderx(1,1,1,1,1,2))
6612 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),
6613 & a_chuj_der(1,1,1,1,jj,i),2,.true.,DtUg2EUg(1,1,k),
6614 & DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),
6615 & ADtEA1derx(1,1,1,1,1,2))
6617 C End 6-th order cumulants
6618 call transpose2(EUgder(1,1,j),auxmat(1,1))
6619 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,2,2))
6620 call transpose2(EUg(1,1,j),auxmat(1,1))
6621 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
6622 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
6626 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
6627 & EAEAderx(1,1,lll,kkk,iii,2))
6632 C Calculate the vectors and their derivatives in virtual-bond dihedral angles.
6633 C They are needed only when the fifth- or the sixth-order cumulants are
6635 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 .or.
6636 & (wturn6.gt.0.0d0 .and. j.eq.i+4 .and. l.eq.i+3)) THEN
6637 call transpose2(AEA(1,1,1),auxmat(1,1))
6638 call matvec2(auxmat(1,1),b1(1,iti),AEAb1(1,1,1))
6639 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
6640 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
6641 call transpose2(AEAderg(1,1,1),auxmat(1,1))
6642 call matvec2(auxmat(1,1),b1(1,iti),AEAb1derg(1,1,1))
6643 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
6644 call matvec2(AEA(1,1,1),b1(1,itk1),AEAb1(1,2,1))
6645 call matvec2(AEAderg(1,1,1),b1(1,itk1),AEAb1derg(1,2,1))
6646 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
6647 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
6648 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
6649 call transpose2(AEA(1,1,2),auxmat(1,1))
6650 call matvec2(auxmat(1,1),b1(1,itj1),AEAb1(1,1,2))
6651 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2(1,1,2))
6652 call matvec2(auxmat(1,1),Ub2der(1,l),AEAb2derg(1,2,1,2))
6653 call transpose2(AEAderg(1,1,2),auxmat(1,1))
6654 call matvec2(auxmat(1,1),b1(1,itl),AEAb1(1,1,2))
6655 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2derg(1,1,1,2))
6656 call matvec2(AEA(1,1,2),b1(1,itj1),AEAb1(1,2,2))
6657 call matvec2(AEAderg(1,1,2),b1(1,itj1),AEAb1derg(1,2,2))
6658 call matvec2(AEA(1,1,2),Ub2(1,j),AEAb2(1,2,2))
6659 call matvec2(AEAderg(1,1,2),Ub2(1,j),AEAb2derg(1,1,2,2))
6660 call matvec2(AEA(1,1,2),Ub2der(1,j),AEAb2derg(1,2,2,2))
6661 C Calculate the Cartesian derivatives of the vectors.
6665 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
6666 call matvec2(auxmat(1,1),b1(1,iti),
6667 & AEAb1derx(1,lll,kkk,iii,1,1))
6668 call matvec2(auxmat(1,1),Ub2(1,i),
6669 & AEAb2derx(1,lll,kkk,iii,1,1))
6670 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,itk1),
6671 & AEAb1derx(1,lll,kkk,iii,2,1))
6672 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),
6673 & AEAb2derx(1,lll,kkk,iii,2,1))
6674 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
6675 call matvec2(auxmat(1,1),b1(1,itl),
6676 & AEAb1derx(1,lll,kkk,iii,1,2))
6677 call matvec2(auxmat(1,1),Ub2(1,l),
6678 & AEAb2derx(1,lll,kkk,iii,1,2))
6679 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,itj1),
6680 & AEAb1derx(1,lll,kkk,iii,2,2))
6681 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,j),
6682 & AEAb2derx(1,lll,kkk,iii,2,2))
6691 C---------------------------------------------------------------------------
6692 subroutine kernel(aa1,aa2t,aa1derx,aa2tderx,nderg,transp,
6693 & KK,KKderg,AKA,AKAderg,AKAderx)
6697 double precision aa1(2,2),aa2t(2,2),aa1derx(2,2,3,5),
6698 & aa2tderx(2,2,3,5),KK(2,2),KKderg(2,2,nderg),AKA(2,2),
6699 & AKAderg(2,2,nderg),AKAderx(2,2,3,5,2)
6704 call prodmat3(aa1(1,1),aa2t(1,1),KK(1,1),transp,AKA(1,1))
6706 call prodmat3(aa1(1,1),aa2t(1,1),KKderg(1,1,iii),transp,
6709 cd if (lprn) write (2,*) 'In kernel'
6711 cd if (lprn) write (2,*) 'kkk=',kkk
6713 call prodmat3(aa1derx(1,1,lll,kkk),aa2t(1,1),
6714 & KK(1,1),transp,AKAderx(1,1,lll,kkk,1))
6716 cd write (2,*) 'lll=',lll
6717 cd write (2,*) 'iii=1'
6719 cd write (2,'(3(2f10.5),5x)')
6720 cd & (AKAderx(jjj,mmm,lll,kkk,1),mmm=1,2)
6723 call prodmat3(aa1(1,1),aa2tderx(1,1,lll,kkk),
6724 & KK(1,1),transp,AKAderx(1,1,lll,kkk,2))
6726 cd write (2,*) 'lll=',lll
6727 cd write (2,*) 'iii=2'
6729 cd write (2,'(3(2f10.5),5x)')
6730 cd & (AKAderx(jjj,mmm,lll,kkk,2),mmm=1,2)
6737 C---------------------------------------------------------------------------
6738 double precision function eello4(i,j,k,l,jj,kk)
6739 implicit real*8 (a-h,o-z)
6740 include 'DIMENSIONS'
6741 include 'DIMENSIONS.ZSCOPT'
6742 include 'COMMON.IOUNITS'
6743 include 'COMMON.CHAIN'
6744 include 'COMMON.DERIV'
6745 include 'COMMON.INTERACT'
6746 include 'COMMON.CONTACTS'
6747 include 'COMMON.TORSION'
6748 include 'COMMON.VAR'
6749 include 'COMMON.GEO'
6750 double precision pizda(2,2),ggg1(3),ggg2(3)
6751 cd if (i.ne.1 .or. j.ne.5 .or. k.ne.2 .or.l.ne.4) then
6755 cd print *,'eello4:',i,j,k,l,jj,kk
6756 cd write (2,*) 'i',i,' j',j,' k',k,' l',l
6757 cd call checkint4(i,j,k,l,jj,kk,eel4_num)
6758 cold eij=facont_hb(jj,i)
6759 cold ekl=facont_hb(kk,k)
6761 eel4=-EAEA(1,1,1)-EAEA(2,2,1)
6763 cd eel41=-EAEA(1,1,2)-EAEA(2,2,2)
6764 gcorr_loc(k-1)=gcorr_loc(k-1)
6765 & -ekont*(EAEAderg(1,1,1,1)+EAEAderg(2,2,1,1))
6767 gcorr_loc(l-1)=gcorr_loc(l-1)
6768 & -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
6770 gcorr_loc(j-1)=gcorr_loc(j-1)
6771 & -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
6776 derx(lll,kkk,iii)=-EAEAderx(1,1,lll,kkk,iii,1)
6777 & -EAEAderx(2,2,lll,kkk,iii,1)
6778 cd derx(lll,kkk,iii)=0.0d0
6782 cd gcorr_loc(l-1)=0.0d0
6783 cd gcorr_loc(j-1)=0.0d0
6784 cd gcorr_loc(k-1)=0.0d0
6786 cd write (iout,*)'Contacts have occurred for peptide groups',
6787 cd & i,j,' fcont:',eij,' eij',' and ',k,l,
6788 cd & ' fcont ',ekl,' eel4=',eel4,' eel4_num',16*eel4_num
6789 if (j.lt.nres-1) then
6796 if (l.lt.nres-1) then
6804 cold ghalf=0.5d0*eel4*ekl*gacont_hbr(ll,jj,i)
6805 ggg1(ll)=eel4*g_contij(ll,1)
6806 ggg2(ll)=eel4*g_contij(ll,2)
6807 ghalf=0.5d0*ggg1(ll)
6809 gradcorr(ll,i)=gradcorr(ll,i)+ghalf+ekont*derx(ll,2,1)
6810 gradcorr(ll,i+1)=gradcorr(ll,i+1)+ekont*derx(ll,3,1)
6811 gradcorr(ll,j)=gradcorr(ll,j)+ghalf+ekont*derx(ll,4,1)
6812 gradcorr(ll,j1)=gradcorr(ll,j1)+ekont*derx(ll,5,1)
6813 cold ghalf=0.5d0*eel4*eij*gacont_hbr(ll,kk,k)
6814 ghalf=0.5d0*ggg2(ll)
6816 gradcorr(ll,k)=gradcorr(ll,k)+ghalf+ekont*derx(ll,2,2)
6817 gradcorr(ll,k+1)=gradcorr(ll,k+1)+ekont*derx(ll,3,2)
6818 gradcorr(ll,l)=gradcorr(ll,l)+ghalf+ekont*derx(ll,4,2)
6819 gradcorr(ll,l1)=gradcorr(ll,l1)+ekont*derx(ll,5,2)
6824 cold gradcorr(ll,m)=gradcorr(ll,m)+eel4*ekl*gacont_hbr(ll,jj,i)
6825 gradcorr(ll,m)=gradcorr(ll,m)+ggg1(ll)
6830 cold gradcorr(ll,m)=gradcorr(ll,m)+eel4*eij*gacont_hbr(ll,kk,k)
6831 gradcorr(ll,m)=gradcorr(ll,m)+ggg2(ll)
6837 gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,1)
6842 gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,2)
6846 cd write (2,*) iii,gcorr_loc(iii)
6850 cd write (2,*) 'ekont',ekont
6851 cd write (iout,*) 'eello4',ekont*eel4
6854 C---------------------------------------------------------------------------
6855 double precision function eello5(i,j,k,l,jj,kk)
6856 implicit real*8 (a-h,o-z)
6857 include 'DIMENSIONS'
6858 include 'DIMENSIONS.ZSCOPT'
6859 include 'COMMON.IOUNITS'
6860 include 'COMMON.CHAIN'
6861 include 'COMMON.DERIV'
6862 include 'COMMON.INTERACT'
6863 include 'COMMON.CONTACTS'
6864 include 'COMMON.TORSION'
6865 include 'COMMON.VAR'
6866 include 'COMMON.GEO'
6867 double precision pizda(2,2),auxmat(2,2),auxmat1(2,2),vv(2)
6868 double precision ggg1(3),ggg2(3)
6869 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
6874 C /l\ / \ \ / \ / \ / C
6875 C / \ / \ \ / \ / \ / C
6876 C j| o |l1 | o | o| o | | o |o C
6877 C \ |/k\| |/ \| / |/ \| |/ \| C
6878 C \i/ \ / \ / / \ / \ C
6880 C (I) (II) (III) (IV) C
6882 C eello5_1 eello5_2 eello5_3 eello5_4 C
6884 C Antiparallel chains C
6887 C /j\ / \ \ / \ / \ / C
6888 C / \ / \ \ / \ / \ / C
6889 C j1| o |l | o | o| o | | o |o C
6890 C \ |/k\| |/ \| / |/ \| |/ \| C
6891 C \i/ \ / \ / / \ / \ C
6893 C (I) (II) (III) (IV) C
6895 C eello5_1 eello5_2 eello5_3 eello5_4 C
6897 C o denotes a local interaction, vertical lines an electrostatic interaction. C
6899 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
6900 cd if (i.ne.2 .or. j.ne.6 .or. k.ne.3 .or. l.ne.5) then
6905 cd & 'EELLO5: Contacts have occurred for peptide groups',i,j,
6907 itk=itortyp(itype(k))
6908 itl=itortyp(itype(l))
6909 itj=itortyp(itype(j))
6914 cd call checkint5(i,j,k,l,jj,kk,eel5_1_num,eel5_2_num,
6915 cd & eel5_3_num,eel5_4_num)
6919 derx(lll,kkk,iii)=0.0d0
6923 cd eij=facont_hb(jj,i)
6924 cd ekl=facont_hb(kk,k)
6926 cd write (iout,*)'Contacts have occurred for peptide groups',
6927 cd & i,j,' fcont:',eij,' eij',' and ',k,l
6929 C Contribution from the graph I.
6930 cd write (2,*) 'AEA ',AEA(1,1,1),AEA(2,1,1),AEA(1,2,1),AEA(2,2,1)
6931 cd write (2,*) 'AEAb2',AEAb2(1,1,1),AEAb2(2,1,1)
6932 call transpose2(EUg(1,1,k),auxmat(1,1))
6933 call matmat2(AEA(1,1,1),auxmat(1,1),pizda(1,1))
6934 vv(1)=pizda(1,1)-pizda(2,2)
6935 vv(2)=pizda(1,2)+pizda(2,1)
6936 eello5_1=scalar2(AEAb2(1,1,1),Ub2(1,k))
6937 & +0.5d0*scalar2(vv(1),Dtobr2(1,i))
6939 C Explicit gradient in virtual-dihedral angles.
6940 if (i.gt.1) g_corr5_loc(i-1)=g_corr5_loc(i-1)
6941 & +ekont*(scalar2(AEAb2derg(1,2,1,1),Ub2(1,k))
6942 & +0.5d0*scalar2(vv(1),Dtobr2der(1,i)))
6943 call transpose2(EUgder(1,1,k),auxmat1(1,1))
6944 call matmat2(AEA(1,1,1),auxmat1(1,1),pizda(1,1))
6945 vv(1)=pizda(1,1)-pizda(2,2)
6946 vv(2)=pizda(1,2)+pizda(2,1)
6947 g_corr5_loc(k-1)=g_corr5_loc(k-1)
6948 & +ekont*(scalar2(AEAb2(1,1,1),Ub2der(1,k))
6949 & +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
6950 call matmat2(AEAderg(1,1,1),auxmat(1,1),pizda(1,1))
6951 vv(1)=pizda(1,1)-pizda(2,2)
6952 vv(2)=pizda(1,2)+pizda(2,1)
6954 if (l.lt.nres-1) g_corr5_loc(l-1)=g_corr5_loc(l-1)
6955 & +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k))
6956 & +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
6958 if (j.lt.nres-1) g_corr5_loc(j-1)=g_corr5_loc(j-1)
6959 & +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k))
6960 & +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
6962 C Cartesian gradient
6966 call matmat2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1),
6968 vv(1)=pizda(1,1)-pizda(2,2)
6969 vv(2)=pizda(1,2)+pizda(2,1)
6970 derx(lll,kkk,iii)=derx(lll,kkk,iii)
6971 & +scalar2(AEAb2derx(1,lll,kkk,iii,1,1),Ub2(1,k))
6972 & +0.5d0*scalar2(vv(1),Dtobr2(1,i))
6979 C Contribution from graph II
6980 call transpose2(EE(1,1,itk),auxmat(1,1))
6981 call matmat2(auxmat(1,1),AEA(1,1,1),pizda(1,1))
6982 vv(1)=pizda(1,1)+pizda(2,2)
6983 vv(2)=pizda(2,1)-pizda(1,2)
6984 eello5_2=scalar2(AEAb1(1,2,1),b1(1,itk))
6985 & -0.5d0*scalar2(vv(1),Ctobr(1,k))
6987 C Explicit gradient in virtual-dihedral angles.
6988 g_corr5_loc(k-1)=g_corr5_loc(k-1)
6989 & -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,k))
6990 call matmat2(auxmat(1,1),AEAderg(1,1,1),pizda(1,1))
6991 vv(1)=pizda(1,1)+pizda(2,2)
6992 vv(2)=pizda(2,1)-pizda(1,2)
6994 g_corr5_loc(l-1)=g_corr5_loc(l-1)
6995 & +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,itk))
6996 & -0.5d0*scalar2(vv(1),Ctobr(1,k)))
6998 g_corr5_loc(j-1)=g_corr5_loc(j-1)
6999 & +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,itk))
7000 & -0.5d0*scalar2(vv(1),Ctobr(1,k)))
7002 C Cartesian gradient
7006 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),
7008 vv(1)=pizda(1,1)+pizda(2,2)
7009 vv(2)=pizda(2,1)-pizda(1,2)
7010 derx(lll,kkk,iii)=derx(lll,kkk,iii)
7011 & +scalar2(AEAb1derx(1,lll,kkk,iii,2,1),b1(1,itk))
7012 & -0.5d0*scalar2(vv(1),Ctobr(1,k))
7021 C Parallel orientation
7022 C Contribution from graph III
7023 call transpose2(EUg(1,1,l),auxmat(1,1))
7024 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
7025 vv(1)=pizda(1,1)-pizda(2,2)
7026 vv(2)=pizda(1,2)+pizda(2,1)
7027 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,l))
7028 & +0.5d0*scalar2(vv(1),Dtobr2(1,j))
7030 C Explicit gradient in virtual-dihedral angles.
7031 g_corr5_loc(j-1)=g_corr5_loc(j-1)
7032 & +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,l))
7033 & +0.5d0*scalar2(vv(1),Dtobr2der(1,j)))
7034 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
7035 vv(1)=pizda(1,1)-pizda(2,2)
7036 vv(2)=pizda(1,2)+pizda(2,1)
7037 g_corr5_loc(k-1)=g_corr5_loc(k-1)
7038 & +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,l))
7039 & +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
7040 call transpose2(EUgder(1,1,l),auxmat1(1,1))
7041 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
7042 vv(1)=pizda(1,1)-pizda(2,2)
7043 vv(2)=pizda(1,2)+pizda(2,1)
7044 g_corr5_loc(l-1)=g_corr5_loc(l-1)
7045 & +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,l))
7046 & +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
7047 C Cartesian gradient
7051 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),
7053 vv(1)=pizda(1,1)-pizda(2,2)
7054 vv(2)=pizda(1,2)+pizda(2,1)
7055 derx(lll,kkk,iii)=derx(lll,kkk,iii)
7056 & +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,l))
7057 & +0.5d0*scalar2(vv(1),Dtobr2(1,j))
7063 C Contribution from graph IV
7065 call transpose2(EE(1,1,itl),auxmat(1,1))
7066 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
7067 vv(1)=pizda(1,1)+pizda(2,2)
7068 vv(2)=pizda(2,1)-pizda(1,2)
7069 eello5_4=scalar2(AEAb1(1,2,2),b1(1,itl))
7070 & -0.5d0*scalar2(vv(1),Ctobr(1,l))
7072 C Explicit gradient in virtual-dihedral angles.
7073 g_corr5_loc(l-1)=g_corr5_loc(l-1)
7074 & -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,l))
7075 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
7076 vv(1)=pizda(1,1)+pizda(2,2)
7077 vv(2)=pizda(2,1)-pizda(1,2)
7078 g_corr5_loc(k-1)=g_corr5_loc(k-1)
7079 & +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,itl))
7080 & -0.5d0*scalar2(vv(1),Ctobr(1,l)))
7081 C Cartesian gradient
7085 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
7087 vv(1)=pizda(1,1)+pizda(2,2)
7088 vv(2)=pizda(2,1)-pizda(1,2)
7089 derx(lll,kkk,iii)=derx(lll,kkk,iii)
7090 & +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,itl))
7091 & -0.5d0*scalar2(vv(1),Ctobr(1,l))
7097 C Antiparallel orientation
7098 C Contribution from graph III
7100 call transpose2(EUg(1,1,j),auxmat(1,1))
7101 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
7102 vv(1)=pizda(1,1)-pizda(2,2)
7103 vv(2)=pizda(1,2)+pizda(2,1)
7104 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,j))
7105 & +0.5d0*scalar2(vv(1),Dtobr2(1,l))
7107 C Explicit gradient in virtual-dihedral angles.
7108 g_corr5_loc(l-1)=g_corr5_loc(l-1)
7109 & +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,j))
7110 & +0.5d0*scalar2(vv(1),Dtobr2der(1,l)))
7111 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
7112 vv(1)=pizda(1,1)-pizda(2,2)
7113 vv(2)=pizda(1,2)+pizda(2,1)
7114 g_corr5_loc(k-1)=g_corr5_loc(k-1)
7115 & +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,j))
7116 & +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
7117 call transpose2(EUgder(1,1,j),auxmat1(1,1))
7118 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
7119 vv(1)=pizda(1,1)-pizda(2,2)
7120 vv(2)=pizda(1,2)+pizda(2,1)
7121 g_corr5_loc(j-1)=g_corr5_loc(j-1)
7122 & +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,j))
7123 & +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
7124 C Cartesian gradient
7128 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),
7130 vv(1)=pizda(1,1)-pizda(2,2)
7131 vv(2)=pizda(1,2)+pizda(2,1)
7132 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)
7133 & +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,j))
7134 & +0.5d0*scalar2(vv(1),Dtobr2(1,l))
7140 C Contribution from graph IV
7142 call transpose2(EE(1,1,itj),auxmat(1,1))
7143 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
7144 vv(1)=pizda(1,1)+pizda(2,2)
7145 vv(2)=pizda(2,1)-pizda(1,2)
7146 eello5_4=scalar2(AEAb1(1,2,2),b1(1,itj))
7147 & -0.5d0*scalar2(vv(1),Ctobr(1,j))
7149 C Explicit gradient in virtual-dihedral angles.
7150 g_corr5_loc(j-1)=g_corr5_loc(j-1)
7151 & -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,j))
7152 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
7153 vv(1)=pizda(1,1)+pizda(2,2)
7154 vv(2)=pizda(2,1)-pizda(1,2)
7155 g_corr5_loc(k-1)=g_corr5_loc(k-1)
7156 & +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,itj))
7157 & -0.5d0*scalar2(vv(1),Ctobr(1,j)))
7158 C Cartesian gradient
7162 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),
7164 vv(1)=pizda(1,1)+pizda(2,2)
7165 vv(2)=pizda(2,1)-pizda(1,2)
7166 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)
7167 & +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,itj))
7168 & -0.5d0*scalar2(vv(1),Ctobr(1,j))
7175 eel5=eello5_1+eello5_2+eello5_3+eello5_4
7176 cd if (i.eq.2 .and. j.eq.8 .and. k.eq.3 .and. l.eq.7) then
7177 cd write (2,*) 'ijkl',i,j,k,l
7178 cd write (2,*) 'eello5_1',eello5_1,' eello5_2',eello5_2,
7179 cd & ' eello5_3',eello5_3,' eello5_4',eello5_4
7181 cd write(iout,*) 'eello5_1',eello5_1,' eel5_1_num',16*eel5_1_num
7182 cd write(iout,*) 'eello5_2',eello5_2,' eel5_2_num',16*eel5_2_num
7183 cd write(iout,*) 'eello5_3',eello5_3,' eel5_3_num',16*eel5_3_num
7184 cd write(iout,*) 'eello5_4',eello5_4,' eel5_4_num',16*eel5_4_num
7186 if (j.lt.nres-1) then
7193 if (l.lt.nres-1) then
7203 cd write (2,*) 'eij',eij,' ekl',ekl,' ekont',ekont
7205 ggg1(ll)=eel5*g_contij(ll,1)
7206 ggg2(ll)=eel5*g_contij(ll,2)
7207 cold ghalf=0.5d0*eel5*ekl*gacont_hbr(ll,jj,i)
7208 ghalf=0.5d0*ggg1(ll)
7210 gradcorr5(ll,i)=gradcorr5(ll,i)+ghalf+ekont*derx(ll,2,1)
7211 gradcorr5(ll,i+1)=gradcorr5(ll,i+1)+ekont*derx(ll,3,1)
7212 gradcorr5(ll,j)=gradcorr5(ll,j)+ghalf+ekont*derx(ll,4,1)
7213 gradcorr5(ll,j1)=gradcorr5(ll,j1)+ekont*derx(ll,5,1)
7214 cold ghalf=0.5d0*eel5*eij*gacont_hbr(ll,kk,k)
7215 ghalf=0.5d0*ggg2(ll)
7217 gradcorr5(ll,k)=gradcorr5(ll,k)+ghalf+ekont*derx(ll,2,2)
7218 gradcorr5(ll,k+1)=gradcorr5(ll,k+1)+ekont*derx(ll,3,2)
7219 gradcorr5(ll,l)=gradcorr5(ll,l)+ghalf+ekont*derx(ll,4,2)
7220 gradcorr5(ll,l1)=gradcorr5(ll,l1)+ekont*derx(ll,5,2)
7225 cold gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*ekl*gacont_hbr(ll,jj,i)
7226 gradcorr5(ll,m)=gradcorr5(ll,m)+ggg1(ll)
7231 cold gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*eij*gacont_hbr(ll,kk,k)
7232 gradcorr5(ll,m)=gradcorr5(ll,m)+ggg2(ll)
7238 gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,1)
7243 gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,2)
7247 cd write (2,*) iii,g_corr5_loc(iii)
7251 cd write (2,*) 'ekont',ekont
7252 cd write (iout,*) 'eello5',ekont*eel5
7255 c--------------------------------------------------------------------------
7256 double precision function eello6(i,j,k,l,jj,kk)
7257 implicit real*8 (a-h,o-z)
7258 include 'DIMENSIONS'
7259 include 'DIMENSIONS.ZSCOPT'
7260 include 'COMMON.IOUNITS'
7261 include 'COMMON.CHAIN'
7262 include 'COMMON.DERIV'
7263 include 'COMMON.INTERACT'
7264 include 'COMMON.CONTACTS'
7265 include 'COMMON.TORSION'
7266 include 'COMMON.VAR'
7267 include 'COMMON.GEO'
7268 include 'COMMON.FFIELD'
7269 double precision ggg1(3),ggg2(3)
7270 cd if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
7275 cd & 'EELLO6: Contacts have occurred for peptide groups',i,j,
7283 cd call checkint6(i,j,k,l,jj,kk,eel6_1_num,eel6_2_num,
7284 cd & eel6_3_num,eel6_4_num,eel6_5_num,eel6_6_num)
7288 derx(lll,kkk,iii)=0.0d0
7292 cd eij=facont_hb(jj,i)
7293 cd ekl=facont_hb(kk,k)
7299 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
7300 eello6_2=eello6_graph1(j,i,l,k,2,.false.)
7301 eello6_3=eello6_graph2(i,j,k,l,jj,kk,.false.)
7302 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
7303 eello6_5=eello6_graph4(j,i,l,k,jj,kk,2,.false.)
7304 eello6_6=eello6_graph3(i,j,k,l,jj,kk,.false.)
7306 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
7307 eello6_2=eello6_graph1(l,k,j,i,2,.true.)
7308 eello6_3=eello6_graph2(i,l,k,j,jj,kk,.true.)
7309 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
7310 if (wturn6.eq.0.0d0 .or. j.ne.i+4) then
7311 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
7315 eello6_6=eello6_graph3(i,l,k,j,jj,kk,.true.)
7317 C If turn contributions are considered, they will be handled separately.
7318 eel6=eello6_1+eello6_2+eello6_3+eello6_4+eello6_5+eello6_6
7319 cd write(iout,*) 'eello6_1',eello6_1,' eel6_1_num',16*eel6_1_num
7320 cd write(iout,*) 'eello6_2',eello6_2,' eel6_2_num',16*eel6_2_num
7321 cd write(iout,*) 'eello6_3',eello6_3,' eel6_3_num',16*eel6_3_num
7322 cd write(iout,*) 'eello6_4',eello6_4,' eel6_4_num',16*eel6_4_num
7323 cd write(iout,*) 'eello6_5',eello6_5,' eel6_5_num',16*eel6_5_num
7324 cd write(iout,*) 'eello6_6',eello6_6,' eel6_6_num',16*eel6_6_num
7327 if (j.lt.nres-1) then
7334 if (l.lt.nres-1) then
7342 ggg1(ll)=eel6*g_contij(ll,1)
7343 ggg2(ll)=eel6*g_contij(ll,2)
7344 cold ghalf=0.5d0*eel6*ekl*gacont_hbr(ll,jj,i)
7345 ghalf=0.5d0*ggg1(ll)
7347 gradcorr6(ll,i)=gradcorr6(ll,i)+ghalf+ekont*derx(ll,2,1)
7348 gradcorr6(ll,i+1)=gradcorr6(ll,i+1)+ekont*derx(ll,3,1)
7349 gradcorr6(ll,j)=gradcorr6(ll,j)+ghalf+ekont*derx(ll,4,1)
7350 gradcorr6(ll,j1)=gradcorr6(ll,j1)+ekont*derx(ll,5,1)
7351 ghalf=0.5d0*ggg2(ll)
7352 cold ghalf=0.5d0*eel6*eij*gacont_hbr(ll,kk,k)
7354 gradcorr6(ll,k)=gradcorr6(ll,k)+ghalf+ekont*derx(ll,2,2)
7355 gradcorr6(ll,k+1)=gradcorr6(ll,k+1)+ekont*derx(ll,3,2)
7356 gradcorr6(ll,l)=gradcorr6(ll,l)+ghalf+ekont*derx(ll,4,2)
7357 gradcorr6(ll,l1)=gradcorr6(ll,l1)+ekont*derx(ll,5,2)
7362 cold gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*ekl*gacont_hbr(ll,jj,i)
7363 gradcorr6(ll,m)=gradcorr6(ll,m)+ggg1(ll)
7368 cold gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*eij*gacont_hbr(ll,kk,k)
7369 gradcorr6(ll,m)=gradcorr6(ll,m)+ggg2(ll)
7375 gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,1)
7380 gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,2)
7384 cd write (2,*) iii,g_corr6_loc(iii)
7388 cd write (2,*) 'ekont',ekont
7389 cd write (iout,*) 'eello6',ekont*eel6
7392 c--------------------------------------------------------------------------
7393 double precision function eello6_graph1(i,j,k,l,imat,swap)
7394 implicit real*8 (a-h,o-z)
7395 include 'DIMENSIONS'
7396 include 'DIMENSIONS.ZSCOPT'
7397 include 'COMMON.IOUNITS'
7398 include 'COMMON.CHAIN'
7399 include 'COMMON.DERIV'
7400 include 'COMMON.INTERACT'
7401 include 'COMMON.CONTACTS'
7402 include 'COMMON.TORSION'
7403 include 'COMMON.VAR'
7404 include 'COMMON.GEO'
7405 double precision vv(2),vv1(2),pizda(2,2),auxmat(2,2),pizda1(2,2)
7409 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
7411 C Parallel Antiparallel C
7417 C \ j|/k\| / \ |/k\|l / C
7422 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
7423 itk=itortyp(itype(k))
7424 s1= scalar2(AEAb1(1,2,imat),CUgb2(1,i))
7425 s2=-scalar2(AEAb2(1,1,imat),Ug2Db1t(1,k))
7426 s3= scalar2(AEAb2(1,1,imat),CUgb2(1,k))
7427 call transpose2(EUgC(1,1,k),auxmat(1,1))
7428 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
7429 vv1(1)=pizda1(1,1)-pizda1(2,2)
7430 vv1(2)=pizda1(1,2)+pizda1(2,1)
7431 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
7432 vv(1)=AEAb1(1,2,imat)*b1(1,itk)-AEAb1(2,2,imat)*b1(2,itk)
7433 vv(2)=AEAb1(1,2,imat)*b1(2,itk)+AEAb1(2,2,imat)*b1(1,itk)
7434 s5=scalar2(vv(1),Dtobr2(1,i))
7435 cd write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4', s4,' s5',s5
7436 eello6_graph1=-0.5d0*(s1+s2+s3+s4+s5)
7437 if (.not. calc_grad) return
7438 if (i.gt.1) g_corr6_loc(i-1)=g_corr6_loc(i-1)
7439 & -0.5d0*ekont*(scalar2(AEAb1(1,2,imat),CUgb2der(1,i))
7440 & -scalar2(AEAb2derg(1,2,1,imat),Ug2Db1t(1,k))
7441 & +scalar2(AEAb2derg(1,2,1,imat),CUgb2(1,k))
7442 & +0.5d0*scalar2(vv1(1),Dtobr2der(1,i))
7443 & +scalar2(vv(1),Dtobr2der(1,i)))
7444 call matmat2(AEAderg(1,1,imat),auxmat(1,1),pizda1(1,1))
7445 vv1(1)=pizda1(1,1)-pizda1(2,2)
7446 vv1(2)=pizda1(1,2)+pizda1(2,1)
7447 vv(1)=AEAb1derg(1,2,imat)*b1(1,itk)-AEAb1derg(2,2,imat)*b1(2,itk)
7448 vv(2)=AEAb1derg(1,2,imat)*b1(2,itk)+AEAb1derg(2,2,imat)*b1(1,itk)
7450 g_corr6_loc(l-1)=g_corr6_loc(l-1)
7451 & +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i))
7452 & -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k))
7453 & +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k))
7454 & +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
7456 g_corr6_loc(j-1)=g_corr6_loc(j-1)
7457 & +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i))
7458 & -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k))
7459 & +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k))
7460 & +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
7462 call transpose2(EUgCder(1,1,k),auxmat(1,1))
7463 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
7464 vv1(1)=pizda1(1,1)-pizda1(2,2)
7465 vv1(2)=pizda1(1,2)+pizda1(2,1)
7466 if (k.gt.1) g_corr6_loc(k-1)=g_corr6_loc(k-1)
7467 & +ekont*(-0.5d0*(-scalar2(AEAb2(1,1,imat),Ug2Db1tder(1,k))
7468 & +scalar2(AEAb2(1,1,imat),CUgb2der(1,k))
7469 & +0.5d0*scalar2(vv1(1),Dtobr2(1,i))))
7478 s1= scalar2(AEAb1derx(1,lll,kkk,iii,2,imat),CUgb2(1,i))
7479 s2=-scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),Ug2Db1t(1,k))
7480 s3= scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),CUgb2(1,k))
7481 call transpose2(EUgC(1,1,k),auxmat(1,1))
7482 call matmat2(AEAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),
7484 vv1(1)=pizda1(1,1)-pizda1(2,2)
7485 vv1(2)=pizda1(1,2)+pizda1(2,1)
7486 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
7487 vv(1)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(1,itk)
7488 & -AEAb1derx(2,lll,kkk,iii,2,imat)*b1(2,itk)
7489 vv(2)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(2,itk)
7490 & +AEAb1derx(2,lll,kkk,iii,2,imat)*b1(1,itk)
7491 s5=scalar2(vv(1),Dtobr2(1,i))
7492 derx(lll,kkk,ind)=derx(lll,kkk,ind)-0.5d0*(s1+s2+s3+s4+s5)
7498 c----------------------------------------------------------------------------
7499 double precision function eello6_graph2(i,j,k,l,jj,kk,swap)
7500 implicit real*8 (a-h,o-z)
7501 include 'DIMENSIONS'
7502 include 'DIMENSIONS.ZSCOPT'
7503 include 'COMMON.IOUNITS'
7504 include 'COMMON.CHAIN'
7505 include 'COMMON.DERIV'
7506 include 'COMMON.INTERACT'
7507 include 'COMMON.CONTACTS'
7508 include 'COMMON.TORSION'
7509 include 'COMMON.VAR'
7510 include 'COMMON.GEO'
7512 double precision vv(2),pizda(2,2),auxmat(2,2),auxvec(2),
7513 & auxvec1(2),auxvec2(2),auxmat1(2,2)
7516 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
7518 C Parallel Antiparallel C
7524 C \ j|/k\| \ |/k\|l C
7529 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
7530 cd write (2,*) 'eello6_graph2: i,',i,' j',j,' k',k,' l',l
7531 C AL 7/4/01 s1 would occur in the sixth-order moment,
7532 C but not in a cluster cumulant
7534 s1=dip(1,jj,i)*dip(1,kk,k)
7536 call matvec2(ADtEA1(1,1,1),Ub2(1,k),auxvec(1))
7537 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
7538 call matvec2(ADtEA(1,1,2),Ub2(1,l),auxvec1(1))
7539 s3=-0.5d0*scalar2(Ub2(1,j),auxvec1(1))
7540 call transpose2(EUg(1,1,k),auxmat(1,1))
7541 call matmat2(ADtEA1(1,1,1),auxmat(1,1),pizda(1,1))
7542 vv(1)=pizda(1,1)-pizda(2,2)
7543 vv(2)=pizda(1,2)+pizda(2,1)
7544 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
7545 cd write (2,*) 'eello6_graph2:','s1',s1,' s2',s2,' s3',s3,' s4',s4
7547 eello6_graph2=-(s1+s2+s3+s4)
7549 eello6_graph2=-(s2+s3+s4)
7552 if (.not. calc_grad) return
7553 C Derivatives in gamma(i-1)
7556 s1=dipderg(1,jj,i)*dip(1,kk,k)
7558 s2=-0.5d0*scalar2(Ub2der(1,i),auxvec(1))
7559 call matvec2(ADtEAderg(1,1,1,2),Ub2(1,l),auxvec2(1))
7560 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
7561 s4=-0.25d0*scalar2(vv(1),Dtobr2der(1,i))
7563 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
7565 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
7567 c g_corr6_loc(i-1)=g_corr6_loc(i-1)-s3
7569 C Derivatives in gamma(k-1)
7571 s1=dip(1,jj,i)*dipderg(1,kk,k)
7573 call matvec2(ADtEA1(1,1,1),Ub2der(1,k),auxvec2(1))
7574 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
7575 call matvec2(ADtEAderg(1,1,2,2),Ub2(1,l),auxvec2(1))
7576 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
7577 call transpose2(EUgder(1,1,k),auxmat1(1,1))
7578 call matmat2(ADtEA1(1,1,1),auxmat1(1,1),pizda(1,1))
7579 vv(1)=pizda(1,1)-pizda(2,2)
7580 vv(2)=pizda(1,2)+pizda(2,1)
7581 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
7583 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
7585 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
7587 c g_corr6_loc(k-1)=g_corr6_loc(k-1)-s3
7588 C Derivatives in gamma(j-1) or gamma(l-1)
7591 s1=dipderg(3,jj,i)*dip(1,kk,k)
7593 call matvec2(ADtEA1derg(1,1,1,1),Ub2(1,k),auxvec2(1))
7594 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
7595 s3=-0.5d0*scalar2(Ub2der(1,j),auxvec1(1))
7596 call matmat2(ADtEA1derg(1,1,1,1),auxmat(1,1),pizda(1,1))
7597 vv(1)=pizda(1,1)-pizda(2,2)
7598 vv(2)=pizda(1,2)+pizda(2,1)
7599 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
7602 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
7604 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
7607 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s3+s4)
7608 c g_corr6_loc(j-1)=g_corr6_loc(j-1)-s3
7610 C Derivatives in gamma(l-1) or gamma(j-1)
7613 s1=dip(1,jj,i)*dipderg(3,kk,k)
7615 call matvec2(ADtEA1derg(1,1,2,1),Ub2(1,k),auxvec2(1))
7616 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
7617 call matvec2(ADtEA(1,1,2),Ub2der(1,l),auxvec2(1))
7618 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
7619 call matmat2(ADtEA1derg(1,1,2,1),auxmat(1,1),pizda(1,1))
7620 vv(1)=pizda(1,1)-pizda(2,2)
7621 vv(2)=pizda(1,2)+pizda(2,1)
7622 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
7625 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
7627 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
7630 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s3+s4)
7631 c g_corr6_loc(l-1)=g_corr6_loc(l-1)-s3
7633 C Cartesian derivatives.
7635 write (2,*) 'In eello6_graph2'
7637 write (2,*) 'iii=',iii
7639 write (2,*) 'kkk=',kkk
7641 write (2,'(3(2f10.5),5x)')
7642 & ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
7652 s1=dipderx(lll,kkk,1,jj,i)*dip(1,kk,k)
7654 s1=dip(1,jj,i)*dipderx(lll,kkk,1,kk,k)
7657 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,1),Ub2(1,k),
7659 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
7660 call matvec2(ADtEAderx(1,1,lll,kkk,iii,2),Ub2(1,l),
7662 s3=-0.5d0*scalar2(Ub2(1,j),auxvec(1))
7663 call transpose2(EUg(1,1,k),auxmat(1,1))
7664 call matmat2(ADtEA1derx(1,1,lll,kkk,iii,1),auxmat(1,1),
7666 vv(1)=pizda(1,1)-pizda(2,2)
7667 vv(2)=pizda(1,2)+pizda(2,1)
7668 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
7669 cd write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4',s4
7671 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
7673 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
7676 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
7678 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
7685 c----------------------------------------------------------------------------
7686 double precision function eello6_graph3(i,j,k,l,jj,kk,swap)
7687 implicit real*8 (a-h,o-z)
7688 include 'DIMENSIONS'
7689 include 'DIMENSIONS.ZSCOPT'
7690 include 'COMMON.IOUNITS'
7691 include 'COMMON.CHAIN'
7692 include 'COMMON.DERIV'
7693 include 'COMMON.INTERACT'
7694 include 'COMMON.CONTACTS'
7695 include 'COMMON.TORSION'
7696 include 'COMMON.VAR'
7697 include 'COMMON.GEO'
7698 double precision vv(2),pizda(2,2),auxmat(2,2),auxvec(2)
7700 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
7702 C Parallel Antiparallel C
7708 C j|/k\| / |/k\|l / C
7713 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
7715 C 4/7/01 AL Component s1 was removed, because it pertains to the respective
7716 C energy moment and not to the cluster cumulant.
7717 iti=itortyp(itype(i))
7718 if (j.lt.nres-1 .and. itype(j+1).le.ntyp) then
7719 itj1=itortyp(itype(j+1))
7723 itk=itortyp(itype(k))
7724 itk1=itortyp(itype(k+1))
7725 if (l.lt.nres-1 .and. itype(l+1).le.ntyp) then
7726 itl1=itortyp(itype(l+1))
7731 s1=dip(4,jj,i)*dip(4,kk,k)
7733 call matvec2(AECA(1,1,1),b1(1,itk1),auxvec(1))
7734 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
7735 call matvec2(AECA(1,1,2),b1(1,itl1),auxvec(1))
7736 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
7737 call transpose2(EE(1,1,itk),auxmat(1,1))
7738 call matmat2(auxmat(1,1),AECA(1,1,1),pizda(1,1))
7739 vv(1)=pizda(1,1)+pizda(2,2)
7740 vv(2)=pizda(2,1)-pizda(1,2)
7741 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
7742 cd write (2,*) 'eello6_graph3:','s1',s1,' s2',s2,' s3',s3,' s4',s4
7744 eello6_graph3=-(s1+s2+s3+s4)
7746 eello6_graph3=-(s2+s3+s4)
7749 if (.not. calc_grad) return
7750 C Derivatives in gamma(k-1)
7751 call matvec2(AECAderg(1,1,2),b1(1,itl1),auxvec(1))
7752 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
7753 s4=-0.25d0*scalar2(vv(1),Ctobrder(1,k))
7754 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s3+s4)
7755 C Derivatives in gamma(l-1)
7756 call matvec2(AECAderg(1,1,1),b1(1,itk1),auxvec(1))
7757 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
7758 call matmat2(auxmat(1,1),AECAderg(1,1,1),pizda(1,1))
7759 vv(1)=pizda(1,1)+pizda(2,2)
7760 vv(2)=pizda(2,1)-pizda(1,2)
7761 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
7762 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
7763 C Cartesian derivatives.
7769 s1=dipderx(lll,kkk,4,jj,i)*dip(4,kk,k)
7771 s1=dip(4,jj,i)*dipderx(lll,kkk,4,kk,k)
7774 call matvec2(AECAderx(1,1,lll,kkk,iii,1),b1(1,itk1),
7776 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
7777 call matvec2(AECAderx(1,1,lll,kkk,iii,2),b1(1,itl1),
7779 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
7780 call matmat2(auxmat(1,1),AECAderx(1,1,lll,kkk,iii,1),
7782 vv(1)=pizda(1,1)+pizda(2,2)
7783 vv(2)=pizda(2,1)-pizda(1,2)
7784 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
7786 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
7788 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
7791 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
7793 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
7795 c derx(lll,kkk,iii)=derx(lll,kkk,iii)-s4
7801 c----------------------------------------------------------------------------
7802 double precision function eello6_graph4(i,j,k,l,jj,kk,imat,swap)
7803 implicit real*8 (a-h,o-z)
7804 include 'DIMENSIONS'
7805 include 'DIMENSIONS.ZSCOPT'
7806 include 'COMMON.IOUNITS'
7807 include 'COMMON.CHAIN'
7808 include 'COMMON.DERIV'
7809 include 'COMMON.INTERACT'
7810 include 'COMMON.CONTACTS'
7811 include 'COMMON.TORSION'
7812 include 'COMMON.VAR'
7813 include 'COMMON.GEO'
7814 include 'COMMON.FFIELD'
7815 double precision vv(2),pizda(2,2),auxmat(2,2),auxvec(2),
7816 & auxvec1(2),auxmat1(2,2)
7818 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
7820 C Parallel Antiparallel C
7826 C \ j|/k\| \ |/k\|l C
7831 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
7833 C 4/7/01 AL Component s1 was removed, because it pertains to the respective
7834 C energy moment and not to the cluster cumulant.
7835 cd write (2,*) 'eello_graph4: wturn6',wturn6
7836 iti=itortyp(itype(i))
7837 itj=itortyp(itype(j))
7838 if (j.lt.nres-1 .and. itype(j+1).le.ntyp) then
7839 itj1=itortyp(itype(j+1))
7843 itk=itortyp(itype(k))
7844 if (k.lt.nres-1 .and. itype(k+1).le.ntyp) then
7845 itk1=itortyp(itype(k+1))
7849 itl=itortyp(itype(l))
7850 if (l.lt.nres-1) then
7851 itl1=itortyp(itype(l+1))
7855 cd write (2,*) 'eello6_graph4:','i',i,' j',j,' k',k,' l',l
7856 cd write (2,*) 'iti',iti,' itj',itj,' itj1',itj1,' itk',itk,
7857 cd & ' itl',itl,' itl1',itl1
7860 s1=dip(3,jj,i)*dip(3,kk,k)
7862 s1=dip(2,jj,j)*dip(2,kk,l)
7865 call matvec2(AECA(1,1,imat),Ub2(1,k),auxvec(1))
7866 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
7868 call matvec2(ADtEA1(1,1,3-imat),b1(1,itj1),auxvec1(1))
7869 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
7871 call matvec2(ADtEA1(1,1,3-imat),b1(1,itl1),auxvec1(1))
7872 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
7874 call transpose2(EUg(1,1,k),auxmat(1,1))
7875 call matmat2(AECA(1,1,imat),auxmat(1,1),pizda(1,1))
7876 vv(1)=pizda(1,1)-pizda(2,2)
7877 vv(2)=pizda(2,1)+pizda(1,2)
7878 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
7879 cd write (2,*) 'eello6_graph4:','s1',s1,' s2',s2,' s3',s3,' s4',s4
7881 eello6_graph4=-(s1+s2+s3+s4)
7883 eello6_graph4=-(s2+s3+s4)
7885 if (.not. calc_grad) return
7886 C Derivatives in gamma(i-1)
7890 s1=dipderg(2,jj,i)*dip(3,kk,k)
7892 s1=dipderg(4,jj,j)*dip(2,kk,l)
7895 s2=0.5d0*scalar2(Ub2der(1,i),auxvec(1))
7897 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,itj1),auxvec1(1))
7898 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
7900 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,itl1),auxvec1(1))
7901 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
7903 s4=0.25d0*scalar2(vv(1),Dtobr2der(1,i))
7904 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
7905 cd write (2,*) 'turn6 derivatives'
7907 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s1+s2+s3+s4)
7909 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s2+s3+s4)
7913 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
7915 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
7919 C Derivatives in gamma(k-1)
7922 s1=dip(3,jj,i)*dipderg(2,kk,k)
7924 s1=dip(2,jj,j)*dipderg(4,kk,l)
7927 call matvec2(AECA(1,1,imat),Ub2der(1,k),auxvec1(1))
7928 s2=0.5d0*scalar2(Ub2(1,i),auxvec1(1))
7930 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,itj1),auxvec1(1))
7931 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
7933 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,itl1),auxvec1(1))
7934 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
7936 call transpose2(EUgder(1,1,k),auxmat1(1,1))
7937 call matmat2(AECA(1,1,imat),auxmat1(1,1),pizda(1,1))
7938 vv(1)=pizda(1,1)-pizda(2,2)
7939 vv(2)=pizda(2,1)+pizda(1,2)
7940 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
7941 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
7943 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s1+s2+s3+s4)
7945 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s2+s3+s4)
7949 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
7951 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
7954 C Derivatives in gamma(j-1) or gamma(l-1)
7955 if (l.eq.j+1 .and. l.gt.1) then
7956 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
7957 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
7958 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
7959 vv(1)=pizda(1,1)-pizda(2,2)
7960 vv(2)=pizda(2,1)+pizda(1,2)
7961 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
7962 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
7963 else if (j.gt.1) then
7964 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
7965 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
7966 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
7967 vv(1)=pizda(1,1)-pizda(2,2)
7968 vv(2)=pizda(2,1)+pizda(1,2)
7969 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
7970 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
7971 gel_loc_turn6(j-1)=gel_loc_turn6(j-1)-ekont*(s2+s4)
7973 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s4)
7976 C Cartesian derivatives.
7983 s1=dipderx(lll,kkk,3,jj,i)*dip(3,kk,k)
7985 s1=dipderx(lll,kkk,2,jj,j)*dip(2,kk,l)
7989 s1=dip(3,jj,i)*dipderx(lll,kkk,3,kk,k)
7991 s1=dip(2,jj,j)*dipderx(lll,kkk,2,kk,l)
7995 call matvec2(AECAderx(1,1,lll,kkk,iii,imat),Ub2(1,k),
7997 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
7999 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),
8000 & b1(1,itj1),auxvec(1))
8001 s3=-0.5d0*scalar2(b1(1,itj),auxvec(1))
8003 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),
8004 & b1(1,itl1),auxvec(1))
8005 s3=-0.5d0*scalar2(b1(1,itl),auxvec(1))
8007 call matmat2(AECAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),
8009 vv(1)=pizda(1,1)-pizda(2,2)
8010 vv(2)=pizda(2,1)+pizda(1,2)
8011 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
8013 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
8015 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii)
8018 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii)
8021 derx_turn(lll,kkk,iii)=derx_turn(lll,kkk,iii)-s3
8024 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s1+s2+s4)
8026 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s2+s4)
8028 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
8032 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
8034 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
8037 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
8039 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
8047 c----------------------------------------------------------------------------
8048 double precision function eello_turn6(i,jj,kk)
8049 implicit real*8 (a-h,o-z)
8050 include 'DIMENSIONS'
8051 include 'DIMENSIONS.ZSCOPT'
8052 include 'COMMON.IOUNITS'
8053 include 'COMMON.CHAIN'
8054 include 'COMMON.DERIV'
8055 include 'COMMON.INTERACT'
8056 include 'COMMON.CONTACTS'
8057 include 'COMMON.TORSION'
8058 include 'COMMON.VAR'
8059 include 'COMMON.GEO'
8060 double precision vtemp1(2),vtemp2(2),vtemp3(2),vtemp4(2),
8061 & atemp(2,2),auxmat(2,2),achuj_temp(2,2),gtemp(2,2),gvec(2),
8063 double precision vtemp1d(2),vtemp2d(2),vtemp3d(2),vtemp4d(2),
8064 & atempd(2,2),auxmatd(2,2),achuj_tempd(2,2),gtempd(2,2),gvecd(2)
8065 C 4/7/01 AL Components s1, s8, and s13 were removed, because they pertain to
8066 C the respective energy moment and not to the cluster cumulant.
8071 iti=itortyp(itype(i))
8072 itk=itortyp(itype(k))
8073 itk1=itortyp(itype(k+1))
8074 itl=itortyp(itype(l))
8075 itj=itortyp(itype(j))
8076 cd write (2,*) 'itk',itk,' itk1',itk1,' itl',itl,' itj',itj
8077 cd write (2,*) 'i',i,' k',k,' j',j,' l',l
8078 cd if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
8083 cd & 'EELLO6: Contacts have occurred for peptide groups',i,j,
8085 cd call checkint_turn6(i,jj,kk,eel_turn6_num)
8089 derx_turn(lll,kkk,iii)=0.0d0
8096 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
8098 cd write (2,*) 'eello6_5',eello6_5
8100 call transpose2(AEA(1,1,1),auxmat(1,1))
8101 call matmat2(EUg(1,1,i+1),auxmat(1,1),auxmat(1,1))
8102 ss1=scalar2(Ub2(1,i+2),b1(1,itl))
8103 s1 = (auxmat(1,1)+auxmat(2,2))*ss1
8107 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1(1))
8108 call matvec2(AEA(1,1,1),vtemp1(1),vtemp1(1))
8109 s2 = scalar2(b1(1,itk),vtemp1(1))
8111 call transpose2(AEA(1,1,2),atemp(1,1))
8112 call matmat2(atemp(1,1),EUg(1,1,i+4),atemp(1,1))
8113 call matvec2(Ug2(1,1,i+2),dd(1,1,itk1),vtemp2(1))
8114 s8 = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
8118 call matmat2(EUg(1,1,i+3),AEA(1,1,2),auxmat(1,1))
8119 call matvec2(auxmat(1,1),Ub2(1,i+4),vtemp3(1))
8120 s12 = scalar2(Ub2(1,i+2),vtemp3(1))
8122 call transpose2(a_chuj(1,1,kk,i+1),achuj_temp(1,1))
8123 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtemp(1,1))
8124 call matmat2(gtemp(1,1),EUg(1,1,i+3),gtemp(1,1))
8125 call matvec2(a_chuj(1,1,jj,i),Ub2(1,i+4),vtemp4(1))
8126 ss13 = scalar2(b1(1,itk),vtemp4(1))
8127 s13 = (gtemp(1,1)+gtemp(2,2))*ss13
8131 c write (2,*) 's1,s2,s8,s12,s13',s1,s2,s8,s12,s13
8137 eel_turn6 = eello6_5 - 0.5d0*(s1+s2+s12+s8+s13)
8139 C Derivatives in gamma(i+2)
8141 call transpose2(AEA(1,1,1),auxmatd(1,1))
8142 call matmat2(EUgder(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
8143 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
8144 call transpose2(AEAderg(1,1,2),atempd(1,1))
8145 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
8146 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
8150 call matmat2(EUg(1,1,i+3),AEAderg(1,1,2),auxmatd(1,1))
8151 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
8152 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
8158 gel_loc_turn6(i)=gel_loc_turn6(i)-0.5d0*ekont*(s1d+s8d+s12d)
8159 C Derivatives in gamma(i+3)
8161 call transpose2(AEA(1,1,1),auxmatd(1,1))
8162 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
8163 ss1d=scalar2(Ub2der(1,i+2),b1(1,itl))
8164 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1d
8168 call matvec2(EUgder(1,1,i+2),b1(1,itl),vtemp1d(1))
8169 call matvec2(AEA(1,1,1),vtemp1d(1),vtemp1d(1))
8170 s2d = scalar2(b1(1,itk),vtemp1d(1))
8172 call matvec2(Ug2der(1,1,i+2),dd(1,1,itk1),vtemp2d(1))
8173 s8d = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,itl),vtemp2d(1))
8175 s12d = scalar2(Ub2der(1,i+2),vtemp3(1))
8177 call matmat2(achuj_temp(1,1),EUgder(1,1,i+2),gtempd(1,1))
8178 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
8179 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
8189 gel_loc_turn6(i+1)=gel_loc_turn6(i+1)
8190 & -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
8192 gel_loc_turn6(i+1)=gel_loc_turn6(i+1)
8193 & -0.5d0*ekont*(s2d+s12d)
8195 C Derivatives in gamma(i+4)
8196 call matmat2(EUgder(1,1,i+3),AEA(1,1,2),auxmatd(1,1))
8197 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
8198 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
8200 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtempd(1,1))
8201 call matmat2(gtempd(1,1),EUgder(1,1,i+3),gtempd(1,1))
8202 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
8212 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d+s13d)
8214 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d)
8216 C Derivatives in gamma(i+5)
8218 call transpose2(AEAderg(1,1,1),auxmatd(1,1))
8219 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
8220 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
8224 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1d(1))
8225 call matvec2(AEAderg(1,1,1),vtemp1d(1),vtemp1d(1))
8226 s2d = scalar2(b1(1,itk),vtemp1d(1))
8228 call transpose2(AEA(1,1,2),atempd(1,1))
8229 call matmat2(atempd(1,1),EUgder(1,1,i+4),atempd(1,1))
8230 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
8234 call matvec2(auxmat(1,1),Ub2der(1,i+4),vtemp3d(1))
8235 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
8237 call matvec2(a_chuj(1,1,jj,i),Ub2der(1,i+4),vtemp4d(1))
8238 ss13d = scalar2(b1(1,itk),vtemp4d(1))
8239 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
8249 gel_loc_turn6(i+3)=gel_loc_turn6(i+3)
8250 & -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
8252 gel_loc_turn6(i+3)=gel_loc_turn6(i+3)
8253 & -0.5d0*ekont*(s2d+s12d)
8255 C Cartesian derivatives
8260 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmatd(1,1))
8261 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
8262 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
8266 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1(1))
8267 call matvec2(AEAderx(1,1,lll,kkk,iii,1),vtemp1(1),
8269 s2d = scalar2(b1(1,itk),vtemp1d(1))
8271 call transpose2(AEAderx(1,1,lll,kkk,iii,2),atempd(1,1))
8272 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
8273 s8d = -(atempd(1,1)+atempd(2,2))*
8274 & scalar2(cc(1,1,itl),vtemp2(1))
8278 call matmat2(EUg(1,1,i+3),AEAderx(1,1,lll,kkk,iii,2),
8280 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
8281 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
8288 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii)
8291 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii)
8295 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii)
8296 & - 0.5d0*(s8d+s12d)
8298 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii)
8307 call transpose2(a_chuj_der(1,1,lll,kkk,kk,i+1),
8309 call matmat2(achuj_tempd(1,1),EUg(1,1,i+2),gtempd(1,1))
8310 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
8311 s13d=(gtempd(1,1)+gtempd(2,2))*ss13
8312 derx_turn(lll,kkk,2) = derx_turn(lll,kkk,2)-0.5d0*s13d
8313 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),Ub2(1,i+4),
8315 ss13d = scalar2(b1(1,itk),vtemp4d(1))
8316 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
8317 derx_turn(lll,kkk,1) = derx_turn(lll,kkk,1)-0.5d0*s13d
8321 cd write(iout,*) 'eel6_turn6',eel_turn6,' eel_turn6_num',
8322 cd & 16*eel_turn6_num
8324 if (j.lt.nres-1) then
8331 if (l.lt.nres-1) then
8339 ggg1(ll)=eel_turn6*g_contij(ll,1)
8340 ggg2(ll)=eel_turn6*g_contij(ll,2)
8341 ghalf=0.5d0*ggg1(ll)
8343 gcorr6_turn(ll,i)=gcorr6_turn(ll,i)+ghalf
8344 & +ekont*derx_turn(ll,2,1)
8345 gcorr6_turn(ll,i+1)=gcorr6_turn(ll,i+1)+ekont*derx_turn(ll,3,1)
8346 gcorr6_turn(ll,j)=gcorr6_turn(ll,j)+ghalf
8347 & +ekont*derx_turn(ll,4,1)
8348 gcorr6_turn(ll,j1)=gcorr6_turn(ll,j1)+ekont*derx_turn(ll,5,1)
8349 ghalf=0.5d0*ggg2(ll)
8351 gcorr6_turn(ll,k)=gcorr6_turn(ll,k)+ghalf
8352 & +ekont*derx_turn(ll,2,2)
8353 gcorr6_turn(ll,k+1)=gcorr6_turn(ll,k+1)+ekont*derx_turn(ll,3,2)
8354 gcorr6_turn(ll,l)=gcorr6_turn(ll,l)+ghalf
8355 & +ekont*derx_turn(ll,4,2)
8356 gcorr6_turn(ll,l1)=gcorr6_turn(ll,l1)+ekont*derx_turn(ll,5,2)
8361 gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg1(ll)
8366 gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg2(ll)
8372 gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,1)
8377 gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,2)
8381 cd write (2,*) iii,g_corr6_loc(iii)
8384 eello_turn6=ekont*eel_turn6
8385 cd write (2,*) 'ekont',ekont
8386 cd write (2,*) 'eel_turn6',ekont*eel_turn6
8389 crc-------------------------------------------------
8390 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8391 subroutine Eliptransfer(eliptran)
8392 implicit real*8 (a-h,o-z)
8393 include 'DIMENSIONS'
8394 include 'COMMON.GEO'
8395 include 'COMMON.VAR'
8396 include 'COMMON.LOCAL'
8397 include 'COMMON.CHAIN'
8398 include 'COMMON.DERIV'
8399 include 'COMMON.INTERACT'
8400 include 'COMMON.IOUNITS'
8401 include 'COMMON.CALC'
8402 include 'COMMON.CONTROL'
8403 include 'COMMON.SPLITELE'
8404 include 'COMMON.SBRIDGE'
8405 C this is done by Adasko
8409 C--bordliptop-- buffore starts
8410 C--bufliptop--- here true lipid starts
8412 C--buflipbot--- lipid ends buffore starts
8413 C--bordlipbot--buffore ends
8417 if (itype(i).eq.ntyp1) cycle
8419 positi=(mod(((c(3,i)+c(3,i+1))/2.0d0),boxzsize))
8420 if (positi.le.0) positi=positi+boxzsize
8422 C first for peptide groups
8423 c for each residue check if it is in lipid or lipid water border area
8424 if ((positi.gt.bordlipbot)
8425 &.and.(positi.lt.bordliptop)) then
8426 C the energy transfer exist
8427 if (positi.lt.buflipbot) then
8428 C what fraction I am in
8430 & ((positi-bordlipbot)/lipbufthick)
8431 C lipbufthick is thickenes of lipid buffore
8432 sslip=sscalelip(fracinbuf)
8433 ssgradlip=-sscagradlip(fracinbuf)/lipbufthick
8434 eliptran=eliptran+sslip*pepliptran
8435 gliptranc(3,i)=gliptranc(3,i)+ssgradlip*pepliptran/2.0d0
8436 gliptranc(3,i-1)=gliptranc(3,i-1)+ssgradlip*pepliptran/2.0d0
8437 C gliptranc(3,i-2)=gliptranc(3,i)+ssgradlip*pepliptran
8438 elseif (positi.gt.bufliptop) then
8439 fracinbuf=1.0d0-((bordliptop-positi)/lipbufthick)
8440 sslip=sscalelip(fracinbuf)
8441 ssgradlip=sscagradlip(fracinbuf)/lipbufthick
8442 eliptran=eliptran+sslip*pepliptran
8443 gliptranc(3,i)=gliptranc(3,i)+ssgradlip*pepliptran/2.0d0
8444 gliptranc(3,i-1)=gliptranc(3,i-1)+ssgradlip*pepliptran/2.0d0
8445 C gliptranc(3,i-2)=gliptranc(3,i)+ssgradlip*pepliptran
8446 C print *, "doing sscalefor top part"
8447 C print *,i,sslip,fracinbuf,ssgradlip
8449 eliptran=eliptran+pepliptran
8450 C print *,"I am in true lipid"
8453 C eliptran=elpitran+0.0 ! I am in water
8456 C print *, "nic nie bylo w lipidzie?"
8457 C now multiply all by the peptide group transfer factor
8458 C eliptran=eliptran*pepliptran
8459 C now the same for side chains
8462 if (itype(i).eq.ntyp1) cycle
8463 positi=(mod(c(3,i+nres),boxzsize))
8464 if (positi.le.0) positi=positi+boxzsize
8465 C print *,mod(c(3,i+nres),boxzsize),bordlipbot,bordliptop
8466 c for each residue check if it is in lipid or lipid water border area
8467 C respos=mod(c(3,i+nres),boxzsize)
8468 C print *,positi,bordlipbot,buflipbot
8469 if ((positi.gt.bordlipbot)
8470 & .and.(positi.lt.bordliptop)) then
8471 C the energy transfer exist
8472 if (positi.lt.buflipbot) then
8474 & ((positi-bordlipbot)/lipbufthick)
8475 C lipbufthick is thickenes of lipid buffore
8476 sslip=sscalelip(fracinbuf)
8477 ssgradlip=-sscagradlip(fracinbuf)/lipbufthick
8478 eliptran=eliptran+sslip*liptranene(itype(i))
8479 gliptranx(3,i)=gliptranx(3,i)
8480 &+ssgradlip*liptranene(itype(i))
8481 gliptranc(3,i-1)= gliptranc(3,i-1)
8482 &+ssgradlip*liptranene(itype(i))
8483 C print *,"doing sccale for lower part"
8484 elseif (positi.gt.bufliptop) then
8486 &((bordliptop-positi)/lipbufthick)
8487 sslip=sscalelip(fracinbuf)
8488 ssgradlip=sscagradlip(fracinbuf)/lipbufthick
8489 eliptran=eliptran+sslip*liptranene(itype(i))
8490 gliptranx(3,i)=gliptranx(3,i)
8491 &+ssgradlip*liptranene(itype(i))
8492 gliptranc(3,i-1)= gliptranc(3,i-1)
8493 &+ssgradlip*liptranene(itype(i))
8494 C print *, "doing sscalefor top part",sslip,fracinbuf
8496 eliptran=eliptran+liptranene(itype(i))
8497 C print *,"I am in true lipid"
8499 endif ! if in lipid or buffor
8501 C eliptran=elpitran+0.0 ! I am in water
8507 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8509 SUBROUTINE MATVEC2(A1,V1,V2)
8510 implicit real*8 (a-h,o-z)
8511 include 'DIMENSIONS'
8512 DIMENSION A1(2,2),V1(2),V2(2)
8516 c 3 VI=VI+A1(I,K)*V1(K)
8520 vaux1=a1(1,1)*v1(1)+a1(1,2)*v1(2)
8521 vaux2=a1(2,1)*v1(1)+a1(2,2)*v1(2)
8526 C---------------------------------------
8527 SUBROUTINE MATMAT2(A1,A2,A3)
8528 implicit real*8 (a-h,o-z)
8529 include 'DIMENSIONS'
8530 DIMENSION A1(2,2),A2(2,2),A3(2,2)
8531 c DIMENSION AI3(2,2)
8535 c A3IJ=A3IJ+A1(I,K)*A2(K,J)
8541 ai3_11=a1(1,1)*a2(1,1)+a1(1,2)*a2(2,1)
8542 ai3_12=a1(1,1)*a2(1,2)+a1(1,2)*a2(2,2)
8543 ai3_21=a1(2,1)*a2(1,1)+a1(2,2)*a2(2,1)
8544 ai3_22=a1(2,1)*a2(1,2)+a1(2,2)*a2(2,2)
8552 c-------------------------------------------------------------------------
8553 double precision function scalar2(u,v)
8555 double precision u(2),v(2)
8558 scalar2=u(1)*v(1)+u(2)*v(2)
8562 C-----------------------------------------------------------------------------
8564 subroutine transpose2(a,at)
8566 double precision a(2,2),at(2,2)
8573 c--------------------------------------------------------------------------
8574 subroutine transpose(n,a,at)
8577 double precision a(n,n),at(n,n)
8585 C---------------------------------------------------------------------------
8586 subroutine prodmat3(a1,a2,kk,transp,prod)
8589 double precision a1(2,2),a2(2,2),a2t(2,2),kk(2,2),prod(2,2)
8591 crc double precision auxmat(2,2),prod_(2,2)
8594 crc call transpose2(kk(1,1),auxmat(1,1))
8595 crc call matmat2(a1(1,1),auxmat(1,1),auxmat(1,1))
8596 crc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
8598 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,1)
8599 & +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,1)
8600 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,2)
8601 & +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,2)
8602 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,1)
8603 & +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,1)
8604 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,2)
8605 & +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,2)
8608 crc call matmat2(a1(1,1),kk(1,1),auxmat(1,1))
8609 crc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
8611 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,1)
8612 & +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,1)
8613 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,2)
8614 & +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,2)
8615 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,1)
8616 & +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,1)
8617 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,2)
8618 & +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,2)
8621 c call transpose2(a2(1,1),a2t(1,1))
8624 crc print *,((prod_(i,j),i=1,2),j=1,2)
8625 crc print *,((prod(i,j),i=1,2),j=1,2)
8629 C-----------------------------------------------------------------------------
8630 double precision function scalar(u,v)
8632 double precision u(3),v(3)
8642 C-----------------------------------------------------------------------
8643 double precision function sscale(r)
8644 double precision r,gamm
8645 include "COMMON.SPLITELE"
8646 if(r.lt.r_cut-rlamb) then
8648 else if(r.le.r_cut.and.r.ge.r_cut-rlamb) then
8649 gamm=(r-(r_cut-rlamb))/rlamb
8650 sscale=1.0d0+gamm*gamm*(2*gamm-3.0d0)
8656 C-----------------------------------------------------------------------
8657 C-----------------------------------------------------------------------
8658 double precision function sscagrad(r)
8659 double precision r,gamm
8660 include "COMMON.SPLITELE"
8661 if(r.lt.r_cut-rlamb) then
8663 else if(r.le.r_cut.and.r.ge.r_cut-rlamb) then
8664 gamm=(r-(r_cut-rlamb))/rlamb
8665 sscagrad=gamm*(6*gamm-6.0d0)/rlamb
8671 C-----------------------------------------------------------------------
8672 C-----------------------------------------------------------------------
8673 double precision function sscalelip(r)
8674 double precision r,gamm
8675 include "COMMON.SPLITELE"
8676 C if(r.lt.r_cut-rlamb) then
8678 C else if(r.le.r_cut.and.r.ge.r_cut-rlamb) then
8679 C gamm=(r-(r_cut-rlamb))/rlamb
8680 sscalelip=1.0d0+r*r*(2*r-3.0d0)
8686 C-----------------------------------------------------------------------
8687 double precision function sscagradlip(r)
8688 double precision r,gamm
8689 include "COMMON.SPLITELE"
8690 C if(r.lt.r_cut-rlamb) then
8692 C else if(r.le.r_cut.and.r.ge.r_cut-rlamb) then
8693 C gamm=(r-(r_cut-rlamb))/rlamb
8694 sscagradlip=r*(6*r-6.0d0)
8701 C-----------------------------------------------------------------------
8702 subroutine set_shield_fac
8703 implicit real*8 (a-h,o-z)
8704 include 'DIMENSIONS'
8705 include 'COMMON.CHAIN'
8706 include 'COMMON.DERIV'
8707 include 'COMMON.IOUNITS'
8708 include 'COMMON.SHIELD'
8709 include 'COMMON.INTERACT'
8710 C this is the squar root 77 devided by 81 the epislion in lipid (in protein)
8711 double precision div77_81/0.974996043d0/,
8712 &div4_81/0.2222222222d0/,sh_frac_dist_grad(3)
8714 C the vector between center of side_chain and peptide group
8715 double precision pep_side(3),long,side_calf(3),
8716 &pept_group(3),costhet_grad(3),cosphi_grad_long(3),
8717 &cosphi_grad_loc(3),pep_side_norm(3),side_calf_norm(3)
8718 C the line belowe needs to be changed for FGPROC>1
8720 if ((itype(i).eq.ntyp1).and.itype(i+1).eq.ntyp1) cycle
8722 Cif there two consequtive dummy atoms there is no peptide group between them
8723 C the line below has to be changed for FGPROC>1
8726 if ((itype(k).eq.ntyp1).or.(itype(k).eq.10)) cycle
8730 C first lets set vector conecting the ithe side-chain with kth side-chain
8731 pep_side(j)=c(j,k+nres)-(c(j,i)+c(j,i+1))/2.0d0
8733 C and vector conecting the side-chain with its proper calfa
8734 side_calf(j)=c(j,k+nres)-c(j,k)
8735 C side_calf(j)=2.0d0
8736 pept_group(j)=c(j,i)-c(j,i+1)
8737 C lets have their lenght
8738 dist_pep_side=pep_side(j)**2+dist_pep_side
8739 dist_side_calf=dist_side_calf+side_calf(j)**2
8740 dist_pept_group=dist_pept_group+pept_group(j)**2
8742 dist_pep_side=dsqrt(dist_pep_side)
8743 dist_pept_group=dsqrt(dist_pept_group)
8744 dist_side_calf=dsqrt(dist_side_calf)
8746 pep_side_norm(j)=pep_side(j)/dist_pep_side
8747 side_calf_norm(j)=dist_side_calf
8749 C now sscale fraction
8750 sh_frac_dist=-(dist_pep_side-rpp(1,1)-buff_shield)/buff_shield
8751 C print *,buff_shield,"buff"
8753 if (sh_frac_dist.le.0.0) cycle
8754 C If we reach here it means that this side chain reaches the shielding sphere
8755 C Lets add him to the list for gradient
8756 ishield_list(i)=ishield_list(i)+1
8757 C ishield_list is a list of non 0 side-chain that contribute to factor gradient
8758 C this list is essential otherwise problem would be O3
8759 shield_list(ishield_list(i),i)=k
8760 C Lets have the sscale value
8761 if (sh_frac_dist.gt.1.0) then
8762 scale_fac_dist=1.0d0
8764 sh_frac_dist_grad(j)=0.0d0
8767 scale_fac_dist=-sh_frac_dist*sh_frac_dist
8768 & *(2.0*sh_frac_dist-3.0d0)
8769 fac_help_scale=6.0*(sh_frac_dist-sh_frac_dist**2)
8770 & /dist_pep_side/buff_shield*0.5
8771 C remember for the final gradient multiply sh_frac_dist_grad(j)
8772 C for side_chain by factor -2 !
8774 sh_frac_dist_grad(j)=fac_help_scale*pep_side(j)
8775 C print *,"jestem",scale_fac_dist,fac_help_scale,
8776 C & sh_frac_dist_grad(j)
8779 C if ((i.eq.3).and.(k.eq.2)) then
8780 C print *,i,sh_frac_dist,dist_pep,fac_help_scale,scale_fac_dist
8784 C this is what is now we have the distance scaling now volume...
8785 short=short_r_sidechain(itype(k))
8786 long=long_r_sidechain(itype(k))
8787 costhet=1.0d0/dsqrt(1.0+short**2/dist_pep_side**2)
8790 costhet_fac=costhet**3*short**2*(-0.5)/dist_pep_side**4
8793 costhet_grad(j)=costhet_fac*pep_side(j)
8795 C remember for the final gradient multiply costhet_grad(j)
8796 C for side_chain by factor -2 !
8797 C fac alfa is angle between CB_k,CA_k, CA_i,CA_i+1
8798 C pep_side0pept_group is vector multiplication
8799 pep_side0pept_group=0.0
8801 pep_side0pept_group=pep_side0pept_group+pep_side(j)*side_calf(j)
8803 cosalfa=(pep_side0pept_group/
8804 & (dist_pep_side*dist_side_calf))
8805 fac_alfa_sin=1.0-cosalfa**2
8806 fac_alfa_sin=dsqrt(fac_alfa_sin)
8807 rkprim=fac_alfa_sin*(long-short)+short
8809 cosphi=1.0d0/dsqrt(1.0+rkprim**2/dist_pep_side**2)
8810 cosphi_fac=cosphi**3*rkprim**2*(-0.5)/dist_pep_side**4
8813 cosphi_grad_long(j)=cosphi_fac*pep_side(j)
8814 &+cosphi**3*0.5/dist_pep_side**2*(-rkprim)
8815 &*(long-short)/fac_alfa_sin*cosalfa/
8816 &((dist_pep_side*dist_side_calf))*
8817 &((side_calf(j))-cosalfa*
8818 &((pep_side(j)/dist_pep_side)*dist_side_calf))
8820 cosphi_grad_loc(j)=cosphi**3*0.5/dist_pep_side**2*(-rkprim)
8821 &*(long-short)/fac_alfa_sin*cosalfa
8822 &/((dist_pep_side*dist_side_calf))*
8824 &cosalfa*side_calf(j)/dist_side_calf*dist_pep_side)
8827 VofOverlap=VSolvSphere/2.0d0*(1.0-costhet)*(1.0-cosphi)
8830 C now the gradient...
8831 C grad_shield is gradient of Calfa for peptide groups
8832 C write(iout,*) "shield_compon",i,k,VSolvSphere,scale_fac_dist,
8834 C write(iout,*) "cosphi_compon",i,k,pep_side0pept_group,
8835 C & dist_pep_side,dist_side_calf,c(1,k+nres),c(1,k),itype(k)
8837 grad_shield(j,i)=grad_shield(j,i)
8838 C gradient po skalowaniu
8839 & +(sh_frac_dist_grad(j)
8840 C gradient po costhet
8841 &-scale_fac_dist*costhet_grad(j)/(1.0-costhet)
8842 &-scale_fac_dist*(cosphi_grad_long(j))
8843 &/(1.0-cosphi) )*div77_81
8845 C grad_shield_side is Cbeta sidechain gradient
8846 grad_shield_side(j,ishield_list(i),i)=
8847 & (sh_frac_dist_grad(j)*-2.0d0
8848 & +scale_fac_dist*costhet_grad(j)*2.0d0/(1.0-costhet)
8849 & +scale_fac_dist*(cosphi_grad_long(j))
8850 & *2.0d0/(1.0-cosphi))
8851 & *div77_81*VofOverlap
8853 grad_shield_loc(j,ishield_list(i),i)=
8854 & scale_fac_dist*cosphi_grad_loc(j)
8855 & *2.0d0/(1.0-cosphi)
8856 & *div77_81*VofOverlap
8858 VolumeTotal=VolumeTotal+VofOverlap*scale_fac_dist
8860 fac_shield(i)=VolumeTotal*div77_81+div4_81
8861 C write(2,*) "TOTAL VOLUME",i,VolumeTotal,fac_shield(i)
8865 C--------------------------------------------------------------------------
8866 C first for shielding is setting of function of side-chains
8867 subroutine set_shield_fac2
8868 implicit real*8 (a-h,o-z)
8869 include 'DIMENSIONS'
8870 include 'COMMON.CHAIN'
8871 include 'COMMON.DERIV'
8872 include 'COMMON.IOUNITS'
8873 include 'COMMON.SHIELD'
8874 include 'COMMON.INTERACT'
8875 C this is the squar root 77 devided by 81 the epislion in lipid (in protein)
8876 double precision div77_81/0.974996043d0/,
8877 &div4_81/0.2222222222d0/,sh_frac_dist_grad(3)
8879 C the vector between center of side_chain and peptide group
8880 double precision pep_side(3),long,side_calf(3),
8881 &pept_group(3),costhet_grad(3),cosphi_grad_long(3),
8882 &cosphi_grad_loc(3),pep_side_norm(3),side_calf_norm(3)
8883 C the line belowe needs to be changed for FGPROC>1
8885 if ((itype(i).eq.ntyp1).and.itype(i+1).eq.ntyp1) cycle
8887 Cif there two consequtive dummy atoms there is no peptide group between them
8888 C the line below has to be changed for FGPROC>1
8891 if ((itype(k).eq.ntyp1).or.(itype(k).eq.10)) cycle
8895 C first lets set vector conecting the ithe side-chain with kth side-chain
8896 pep_side(j)=c(j,k+nres)-(c(j,i)+c(j,i+1))/2.0d0
8898 C and vector conecting the side-chain with its proper calfa
8899 side_calf(j)=c(j,k+nres)-c(j,k)
8900 C side_calf(j)=2.0d0
8901 pept_group(j)=c(j,i)-c(j,i+1)
8902 C lets have their lenght
8903 dist_pep_side=pep_side(j)**2+dist_pep_side
8904 dist_side_calf=dist_side_calf+side_calf(j)**2
8905 dist_pept_group=dist_pept_group+pept_group(j)**2
8907 dist_pep_side=dsqrt(dist_pep_side)
8908 dist_pept_group=dsqrt(dist_pept_group)
8909 dist_side_calf=dsqrt(dist_side_calf)
8911 pep_side_norm(j)=pep_side(j)/dist_pep_side
8912 side_calf_norm(j)=dist_side_calf
8914 C now sscale fraction
8915 sh_frac_dist=-(dist_pep_side-rpp(1,1)-buff_shield)/buff_shield
8916 C print *,buff_shield,"buff"
8918 if (sh_frac_dist.le.0.0) cycle
8919 C If we reach here it means that this side chain reaches the shielding sphere
8920 C Lets add him to the list for gradient
8921 ishield_list(i)=ishield_list(i)+1
8922 C ishield_list is a list of non 0 side-chain that contribute to factor gradient
8923 C this list is essential otherwise problem would be O3
8924 shield_list(ishield_list(i),i)=k
8925 C Lets have the sscale value
8926 if (sh_frac_dist.gt.1.0) then
8927 scale_fac_dist=1.0d0
8929 sh_frac_dist_grad(j)=0.0d0
8932 scale_fac_dist=-sh_frac_dist*sh_frac_dist
8933 & *(2.0d0*sh_frac_dist-3.0d0)
8934 fac_help_scale=6.0d0*(sh_frac_dist-sh_frac_dist**2)
8935 & /dist_pep_side/buff_shield*0.5d0
8936 C remember for the final gradient multiply sh_frac_dist_grad(j)
8937 C for side_chain by factor -2 !
8939 sh_frac_dist_grad(j)=fac_help_scale*pep_side(j)
8940 C sh_frac_dist_grad(j)=0.0d0
8941 C scale_fac_dist=1.0d0
8942 C print *,"jestem",scale_fac_dist,fac_help_scale,
8943 C & sh_frac_dist_grad(j)
8946 C this is what is now we have the distance scaling now volume...
8947 short=short_r_sidechain(itype(k))
8948 long=long_r_sidechain(itype(k))
8949 costhet=1.0d0/dsqrt(1.0d0+short**2/dist_pep_side**2)
8950 sinthet=short/dist_pep_side*costhet
8954 costhet_fac=costhet**3*short**2*(-0.5d0)/dist_pep_side**4
8955 C sinthet_fac=costhet**2*0.5d0*(short**3/dist_pep_side**4*costhet
8956 C & -short/dist_pep_side**2/costhet)
8959 costhet_grad(j)=costhet_fac*pep_side(j)
8961 C remember for the final gradient multiply costhet_grad(j)
8962 C for side_chain by factor -2 !
8963 C fac alfa is angle between CB_k,CA_k, CA_i,CA_i+1
8964 C pep_side0pept_group is vector multiplication
8965 pep_side0pept_group=0.0d0
8967 pep_side0pept_group=pep_side0pept_group+pep_side(j)*side_calf(j)
8969 cosalfa=(pep_side0pept_group/
8970 & (dist_pep_side*dist_side_calf))
8971 fac_alfa_sin=1.0d0-cosalfa**2
8972 fac_alfa_sin=dsqrt(fac_alfa_sin)
8973 rkprim=fac_alfa_sin*(long-short)+short
8977 cosphi=1.0d0/dsqrt(1.0d0+rkprim**2/dist_pep_side**2)
8979 cosphi_fac=cosphi**3*rkprim**2*(-0.5d0)/dist_pep_side**4
8980 sinphi=rkprim/dist_pep_side/dsqrt(1.0d0+rkprim**2/
8984 cosphi_grad_long(j)=cosphi_fac*pep_side(j)
8985 &+cosphi**3*0.5d0/dist_pep_side**2*(-rkprim)
8986 &*(long-short)/fac_alfa_sin*cosalfa/
8987 &((dist_pep_side*dist_side_calf))*
8988 &((side_calf(j))-cosalfa*
8989 &((pep_side(j)/dist_pep_side)*dist_side_calf))
8990 C cosphi_grad_long(j)=0.0d0
8991 cosphi_grad_loc(j)=cosphi**3*0.5d0/dist_pep_side**2*(-rkprim)
8992 &*(long-short)/fac_alfa_sin*cosalfa
8993 &/((dist_pep_side*dist_side_calf))*
8995 &cosalfa*side_calf(j)/dist_side_calf*dist_pep_side)
8996 C cosphi_grad_loc(j)=0.0d0
8998 C print *,sinphi,sinthet
8999 VofOverlap=VSolvSphere/2.0d0*(1.0d0-dsqrt(1.0d0-sinphi*sinthet))
9002 C now the gradient...
9004 grad_shield(j,i)=grad_shield(j,i)
9005 C gradient po skalowaniu
9006 & +(sh_frac_dist_grad(j)*VofOverlap
9007 C gradient po costhet
9008 & +scale_fac_dist*VSolvSphere/VSolvSphere_div/4.0d0*
9009 &(1.0d0/(-dsqrt(1.0d0-sinphi*sinthet))*(
9010 & sinphi/sinthet*costhet*costhet_grad(j)
9011 & +sinthet/sinphi*cosphi*cosphi_grad_long(j)))
9013 C grad_shield_side is Cbeta sidechain gradient
9014 grad_shield_side(j,ishield_list(i),i)=
9015 & (sh_frac_dist_grad(j)*-2.0d0
9017 & -scale_fac_dist*VSolvSphere/VSolvSphere_div/2.0d0*
9018 &(1.0d0/(-dsqrt(1.0d0-sinphi*sinthet))*(
9019 & sinphi/sinthet*costhet*costhet_grad(j)
9020 & +sinthet/sinphi*cosphi*cosphi_grad_long(j)))
9023 grad_shield_loc(j,ishield_list(i),i)=
9024 & scale_fac_dist*VSolvSphere/VSolvSphere_div/2.0d0*
9025 &(1.0d0/(dsqrt(1.0d0-sinphi*sinthet))*(
9026 & sinthet/sinphi*cosphi*cosphi_grad_loc(j)
9030 VolumeTotal=VolumeTotal+VofOverlap*scale_fac_dist
9032 fac_shield(i)=VolumeTotal*wshield+(1.0d0-wshield)
9033 C write(2,*) "TOTAL VOLUME",i,VolumeTotal,fac_shield(i)
9034 C write(2,*) "TU",rpp(1,1),short,long,buff_shield