2 !-----------------------------------------------------------------------------
13 !-----------------------------------------------------------------------------
14 ! Max. number of contacts per residue
16 !-----------------------------------------------------------------------------
17 ! Max. number of derivatives of virtual-bond and side-chain vectors in theta
20 !-----------------------------------------------------------------------------
21 ! Max. number of SC contacts
23 !-----------------------------------------------------------------------------
24 ! Max. number of variables
26 !-----------------------------------------------------------------------------
27 ! Max number of torsional terms in SCCOR in control_data
28 ! integer,parameter :: maxterm_sccor=6
29 !-----------------------------------------------------------------------------
30 ! Maximum number of SC local term fitting function coefficiants
31 integer,parameter :: maxsccoef=65
32 !-----------------------------------------------------------------------------
33 ! commom.calc common/calc/
34 !-----------------------------------------------------------------------------
37 ! Change 12/1/95 - common block CONTACTS1 included.
39 integer,dimension(:),allocatable :: num_cont !(maxres)
40 integer,dimension(:,:),allocatable :: jcont !(maxconts,maxres)
41 real(kind=8),dimension(:,:),allocatable :: facont !(maxconts,maxres)
42 real(kind=8),dimension(:,:,:),allocatable :: gacont !(3,maxconts,maxres)
44 ! 12/26/95 - H-bonding contacts
45 ! common /contacts_hb/
46 real(kind=8),dimension(:,:,:),allocatable :: gacontp_hb1,gacontp_hb2,&
47 gacontp_hb3,gacontm_hb1,gacontm_hb2,gacontm_hb3,gacont_hbr,grij_hb_cont !(3,maxconts,maxres)
48 real(kind=8),dimension(:,:),allocatable :: facont_hb,ees0p,&
49 ees0m,d_cont !(maxconts,maxres)
50 integer,dimension(:),allocatable :: num_cont_hb !(maxres)
51 integer,dimension(:,:),allocatable :: jcont_hb !(maxconts,maxres)
52 ! 9/23/99 Added improper rotation matrices and matrices of dipole-dipole
54 ! 7/25/08 commented out; not needed when cumulants used
55 ! Interactions of pseudo-dipoles generated by loc-el interactions.
57 real(kind=8),dimension(:,:,:),allocatable :: dip,&
58 dipderg !(4,maxconts,maxres)
59 real(kind=8),dimension(:,:,:,:,:),allocatable :: dipderx !(3,5,4,maxconts,maxres)
60 ! 10/30/99 Added other pre-computed vectors and matrices needed
61 ! to calculate three - six-order el-loc correlation terms
63 real(kind=8),dimension(:,:,:),allocatable :: Ug,Ugder,Ug2,Ug2der !(2,2,maxres)
64 real(kind=8),dimension(:,:),allocatable :: obrot,obrot2,obrot_der,&
65 obrot2_der !(2,maxres)
67 ! This common block contains vectors and matrices dependent on a single
70 real(kind=8),dimension(:,:),allocatable :: mu,muder,Ub2,Ub2der,&
71 Ctobr,Ctobrder,Dtobr2,Dtobr2der !(2,maxres)
72 real(kind=8),dimension(:,:,:),allocatable :: EUg,EUgder,CUg,&
73 CUgder,DUg,Dugder,DtUg2,DtUg2der !(2,2,maxres)
74 ! This common block contains vectors and matrices dependent on two
75 ! consecutive amino-acid residues.
77 real(kind=8),dimension(:,:),allocatable :: Ug2Db1t,Ug2Db1tder,&
78 CUgb2,CUgb2der !(2,maxres)
79 real(kind=8),dimension(:,:,:),allocatable :: EUgC,EUgCder,&
80 EUgD,EUgDder,DtUg2EUg,Ug2DtEUg !(2,2,maxres)
81 real(kind=8),dimension(:,:,:,:),allocatable :: Ug2DtEUgder,&
82 DtUg2EUgder !(2,2,2,maxres)
84 real(kind=8),dimension(:),allocatable :: costab,sintab,&
85 costab2,sintab2 !(maxres)
86 ! This common block contains dipole-interaction matrices and their
87 ! Cartesian derivatives.
89 real(kind=8),dimension(:,:,:,:),allocatable :: a_chuj !(2,2,maxconts,maxres)
90 real(kind=8),dimension(:,:,:,:,:,:),allocatable :: a_chuj_der !(2,2,3,5,maxconts,maxres)
92 real(kind=8),dimension(2,2,2) :: AEA,AEAderg,EAEA,AECA,&
93 AECAderg,ADtEA,ADtEA1,AEAb1,AEAb1derg,AEAb2
94 real(kind=8),dimension(2,2,2,2) :: EAEAderg,ADtEAderg,&
96 real(kind=8),dimension(2,2,3,5,2,2) :: AEAderx,EAEAderx,&
97 AECAderx,ADtEAderx,ADtEA1derx
98 real(kind=8),dimension(2,3,5,2,2,2) :: AEAb1derx,AEAb2derx
99 real(kind=8),dimension(3,2) :: g_contij
100 real(kind=8) :: ekont
101 ! 12/13/2008 (again Poland-Jaruzel war anniversary)
102 ! RE: Parallelization of 4th and higher order loc-el correlations
103 ! common /contdistrib/
104 integer,dimension(:),allocatable :: ncont_sent,ncont_recv !(maxres)
105 ! ncont_sent,ncont_recv są w multibody_ello i multibody_hb
106 !-----------------------------------------------------------------------------
109 ! real(kind=8),dimension(:,:),allocatable :: dcdv,dxdv !(6,maxdim)
110 ! real(kind=8),dimension(:,:),allocatable :: dxds !(6,maxres)
111 ! real(kind=8),dimension(:,:,:),allocatable :: gradx,gradc !(3,maxres,2)
112 real(kind=8),dimension(:,:),allocatable :: gvdwc,gelc,gelc_long,&
113 gvdwpp,gvdwc_scpp,gradx_scp,gvdwc_scp,ghpbx,ghpbc,&
114 gradcorr,gradcorr_long,gradcorr5_long,gradcorr6_long,&
115 gcorr6_turn_long,gradxorr,gradcorr5,gradcorr6 !(3,maxres)
116 ! real(kind=8),dimension(:,:),allocatable :: gloc,gloc_x !(maxvar,2)
117 real(kind=8),dimension(:,:),allocatable :: gel_loc,gel_loc_long,&
118 gcorr3_turn,gcorr4_turn,gcorr6_turn,gradb,gradbx !(3,maxres)
119 real(kind=8),dimension(:),allocatable :: gel_loc_loc,&
120 gel_loc_turn3,gel_loc_turn4,gel_loc_turn6,gcorr_loc,g_corr5_loc,&
121 g_corr6_loc !(maxvar)
122 real(kind=8),dimension(:,:),allocatable :: gsccorc,gsccorx !(3,maxres)
123 real(kind=8),dimension(:),allocatable :: gsccor_loc !(maxres)
124 ! real(kind=8),dimension(:,:,:),allocatable :: dtheta !(3,2,maxres)
125 real(kind=8),dimension(:,:),allocatable :: gscloc,gsclocx !(3,maxres)
126 ! real(kind=8),dimension(:,:,:),allocatable :: dphi,dalpha,domega !(3,3,maxres)
129 real(kind=8),dimension(3,5,2) :: derx,derx_turn
130 ! common /deriv_scloc/
131 real(kind=8),dimension(:,:),allocatable :: dXX_C1tab,dYY_C1tab,&
132 dZZ_C1tab,dXX_Ctab,dYY_Ctab,dZZ_Ctab,dXX_XYZtab,dYY_XYZtab,&
133 dZZ_XYZtab !(3,maxres)
134 !-----------------------------------------------------------------------------
137 real(kind=8) :: gvdwc_max,gvdwc_scp_max,gelc_max,gvdwpp_max,&
138 gradb_max,ghpbc_max,&
139 gradcorr_max,gel_loc_max,gcorr3_turn_max,gcorr4_turn_max,&
140 gradcorr5_max,gradcorr6_max,gcorr6_turn_max,gsccorc_max,&
141 gscloc_max,gvdwx_max,gradx_scp_max,ghpbx_max,gradxorr_max,&
142 gsccorx_max,gsclocx_max
143 !-----------------------------------------------------------------------------
145 ! common /back_constr/
146 real(kind=8),dimension(:),allocatable :: dutheta,dugamma !(maxres)
147 real(kind=8),dimension(:,:),allocatable :: duscdiff,duscdiffx !(3,maxres)
149 real(kind=8) :: Ucdfrag,Ucdpair
150 real(kind=8),dimension(:,:),allocatable :: dUdconst,dUdxconst,&
151 dqwol,dxqwol !(3,0:MAXRES)
152 !-----------------------------------------------------------------------------
154 ! common /dyn_ssbond/
155 real(kind=8),dimension(:,:),allocatable :: dyn_ssbond_ij !(maxres,maxres)
156 !-----------------------------------------------------------------------------
158 ! Parameters of the SCCOR term
160 real(kind=8),dimension(:,:,:,:),allocatable :: dcostau,dsintau,&
161 dcosomicron,domicron !(3,3,3,maxres2)
162 !-----------------------------------------------------------------------------
165 real(kind=8),dimension(:,:),allocatable :: uy,uz !(3,maxres)
166 real(kind=8),dimension(:,:,:,:),allocatable :: uygrad,uzgrad !(3,3,2,maxres)
167 !-----------------------------------------------------------------------------
168 ! common /przechowalnia/
169 real(kind=8),dimension(:,:,:),allocatable :: zapas !(max_dim,maxconts,max_fg_procs)
170 real(kind=8),dimension(:,:,:),allocatable :: fromto !(3,3,maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
171 !-----------------------------------------------------------------------------
172 !-----------------------------------------------------------------------------
175 !-----------------------------------------------------------------------------
177 !-----------------------------------------------------------------------------
178 ! energy_p_new_barrier.F
179 !-----------------------------------------------------------------------------
180 subroutine etotal(energia)
181 ! implicit real*8 (a-h,o-z)
182 ! include 'DIMENSIONS'
187 !MS$ATTRIBUTES C :: proc_proc
193 ! include 'COMMON.SETUP'
194 ! include 'COMMON.IOUNITS'
195 real(kind=8),dimension(0:n_ene) :: energia
196 ! include 'COMMON.LOCAL'
197 ! include 'COMMON.FFIELD'
198 ! include 'COMMON.DERIV'
199 ! include 'COMMON.INTERACT'
200 ! include 'COMMON.SBRIDGE'
201 ! include 'COMMON.CHAIN'
202 ! include 'COMMON.VAR'
203 ! include 'COMMON.MD'
204 ! include 'COMMON.CONTROL'
205 ! include 'COMMON.TIME1'
206 real(kind=8) :: time00
208 integer :: n_corr,n_corr1,ierror
209 real(kind=8) :: etors,edihcnstr,etors_d,esccor,ehpb
210 real(kind=8) :: evdw,evdw1,evdw2,evdw2_14,escloc,ees,eel_loc
211 real(kind=8) :: eello_turn3,eello_turn4,estr,ebe
212 real(kind=8) :: ecorr,ecorr5,ecorr6,eturn6
215 real(kind=8) :: weights_(n_ene) !,time_Bcast,time_Bcastw
216 ! shielding effect varibles for MPI
217 ! real(kind=8) fac_shieldbuf(maxres),
218 ! & grad_shield_locbuf(3,maxcontsshi,-1:maxres),
219 ! & grad_shield_sidebuf(3,maxcontsshi,-1:maxres),
220 ! & grad_shieldbuf(3,-1:maxres)
221 ! integer ishield_listbuf(maxres),
222 ! &shield_listbuf(maxcontsshi,maxres)
224 ! print*,"ETOTAL Processor",fg_rank," absolute rank",myrank,
225 ! & " nfgtasks",nfgtasks
226 if (nfgtasks.gt.1) then
228 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
229 if (fg_rank.eq.0) then
230 call MPI_Bcast(0,1,MPI_INTEGER,king,FG_COMM,IERROR)
231 ! print *,"Processor",myrank," BROADCAST iorder"
232 ! FG master sets up the WEIGHTS_ array which will be broadcast to the
233 ! FG slaves as WEIGHTS array.
253 ! FG Master broadcasts the WEIGHTS_ array
254 call MPI_Bcast(weights_(1),n_ene,&
255 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
257 ! FG slaves receive the WEIGHTS array
258 call MPI_Bcast(weights(1),n_ene,&
259 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
280 time_Bcast=time_Bcast+MPI_Wtime()-time00
281 time_Bcastw=time_Bcastw+MPI_Wtime()-time00
282 ! call chainbuild_cart
284 ! print *,'Processor',myrank,' calling etotal ipot=',ipot
285 ! print *,'Processor',myrank,' nnt=',nnt,' nct=',nct
287 ! if (modecalc.eq.12.or.modecalc.eq.14) then
288 ! call int_from_cart1(.false.)
295 ! Compute the side-chain and electrostatic interaction energy
297 ! goto (101,102,103,104,105,106) ipot
299 ! Lennard-Jones potential.
303 !d print '(a)','Exit ELJcall el'
305 ! Lennard-Jones-Kihara potential (shifted).
306 ! 102 call eljk(evdw)
310 ! Berne-Pechukas potential (dilated LJ, angular dependence).
315 ! Gay-Berne potential (shifted LJ, angular dependence).
320 ! Gay-Berne-Vorobjev potential (shifted LJ, angular dependence).
321 ! 105 call egbv(evdw)
325 ! Soft-sphere potential
326 ! 106 call e_softsphere(evdw)
328 call e_softsphere(evdw)
330 ! Calculate electrostatic (H-bonding) energy of the main chain.
334 write(iout,*)"Wrong ipot"
341 !mc Sep-06: egb takes care of dynamic ss bonds too
343 ! if (dyn_ss) call dyn_set_nss
344 ! print *,"Processor",myrank," computed USCSC"
350 time_vec=time_vec+MPI_Wtime()-time01
352 ! print *,"Processor",myrank," left VEC_AND_DERIV"
355 if (welec.gt.0d0.or.wvdwpp.gt.0d0.or.wel_loc.gt.0d0.or. &
356 wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0 &
357 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
358 .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
360 if (welec.gt.0d0.or.wel_loc.gt.0d0.or. &
361 wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0 &
362 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
363 .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
365 call eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
366 ! write (iout,*) "ELEC calc"
375 ! write (iout,*) "Soft-spheer ELEC potential"
376 call eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,&
379 ! print *,"Processor",myrank," computed UELEC"
381 ! Calculate excluded-volume interaction energy between peptide groups
384 !elwrite(iout,*) "in etotal calc exc;luded",ipot
388 call escp(evdw2,evdw2_14)
394 ! write (iout,*) "Soft-sphere SCP potential"
395 call escp_soft_sphere(evdw2,evdw2_14)
397 !elwrite(iout,*) "in etotal before ebond",ipot
400 ! Calculate the bond-stretching energy
403 !elwrite(iout,*) "in etotal afer ebond",ipot
406 ! Calculate the disulfide-bridge and other energy and the contributions
407 ! from other distance constraints.
408 ! print *,'Calling EHPB'
410 !elwrite(iout,*) "in etotal afer edis",ipot
411 ! print *,'EHPB exitted succesfully.'
413 ! Calculate the virtual-bond-angle energy.
415 if (wang.gt.0d0) then
420 ! print *,"Processor",myrank," computed UB"
422 ! Calculate the SC local energy.
425 !elwrite(iout,*) "in etotal afer esc",ipot
426 ! print *,"Processor",myrank," computed USC"
428 ! Calculate the virtual-bond torsional energy.
430 !d print *,'nterm=',nterm
432 call etor(etors,edihcnstr)
437 ! print *,"Processor",myrank," computed Utor"
439 ! 6/23/01 Calculate double-torsional energy
441 !elwrite(iout,*) "in etotal",ipot
442 if (wtor_d.gt.0) then
447 ! print *,"Processor",myrank," computed Utord"
449 ! 21/5/07 Calculate local sicdechain correlation energy
451 if (wsccor.gt.0.0d0) then
452 call eback_sc_corr(esccor)
456 ! print *,"Processor",myrank," computed Usccorr"
458 ! 12/1/95 Multi-body terms
462 if ((wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 &
463 .or. wturn6.gt.0.0d0) .and. ipot.lt.6) then
464 call multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
465 !d write(2,*)'multibody_eello n_corr=',n_corr,' n_corr1=',n_corr1,
466 !d &" ecorr",ecorr," ecorr5",ecorr5," ecorr6",ecorr6," eturn6",eturn6
473 !elwrite(iout,*) "in etotal",ipot
474 if ((wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) .and. ipot.lt.6) then
475 call multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
476 !d write (iout,*) "multibody_hb ecorr",ecorr
478 !elwrite(iout,*) "afeter multibody hb"
480 ! print *,"Processor",myrank," computed Ucorr"
482 ! If performing constraint dynamics, call the constraint energy
483 ! after the equilibration time
484 if(usampl.and.totT.gt.eq_time) then
485 !elwrite(iout,*) "afeter multibody hb"
487 !elwrite(iout,*) "afeter multibody hb"
489 !elwrite(iout,*) "afeter multibody hb"
494 !elwrite(iout,*) "after Econstr"
497 time_enecalc=time_enecalc+MPI_Wtime()-time00
499 ! print *,"Processor",myrank," computed Uconstr"
508 energia(2)=evdw2-evdw2_14
525 energia(8)=eello_turn3
526 energia(9)=eello_turn4
533 energia(19)=edihcnstr
535 energia(20)=Uconst+Uconst_back
537 ! Here are the energies showed per procesor if the are more processors
538 ! per molecule then we sum it up in sum_energy subroutine
539 ! print *," Processor",myrank," calls SUM_ENERGY"
540 call sum_energy(energia,.true.)
541 if (dyn_ss) call dyn_set_nss
542 ! print *," Processor",myrank," left SUM_ENERGY"
544 time_sumene=time_sumene+MPI_Wtime()-time00
546 !el call enerprint(energia)
547 !elwrite(iout,*)"finish etotal"
549 end subroutine etotal
550 !-----------------------------------------------------------------------------
551 subroutine sum_energy(energia,reduce)
552 ! implicit real*8 (a-h,o-z)
553 ! include 'DIMENSIONS'
557 !MS$ATTRIBUTES C :: proc_proc
563 ! include 'COMMON.SETUP'
564 ! include 'COMMON.IOUNITS'
565 real(kind=8) :: energia(0:n_ene),enebuff(0:n_ene+1)
566 ! include 'COMMON.FFIELD'
567 ! include 'COMMON.DERIV'
568 ! include 'COMMON.INTERACT'
569 ! include 'COMMON.SBRIDGE'
570 ! include 'COMMON.CHAIN'
571 ! include 'COMMON.VAR'
572 ! include 'COMMON.CONTROL'
573 ! include 'COMMON.TIME1'
575 real(kind=8) :: evdw,evdw2,evdw2_14,ees,evdw1,ecorr,ecorr5,ecorr6
576 real(kind=8) :: eel_loc,eello_turn3,eello_turn4,eturn6,ebe,escloc
577 real(kind=8) :: etors,etors_d,ehpb,edihcnstr,estr,esccor,etot
581 real(kind=8) :: time00
582 if (nfgtasks.gt.1 .and. reduce) then
585 write (iout,*) "energies before REDUCE"
586 call enerprint(energia)
590 enebuff(i)=energia(i)
593 call MPI_Barrier(FG_COMM,IERR)
594 time_barrier_e=time_barrier_e+MPI_Wtime()-time00
596 call MPI_Reduce(enebuff(0),energia(0),n_ene+1,&
597 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
599 write (iout,*) "energies after REDUCE"
600 call enerprint(energia)
603 time_Reduce=time_Reduce+MPI_Wtime()-time00
605 if (fg_rank.eq.0) then
609 evdw2=energia(2)+energia(18)
625 eello_turn3=energia(8)
626 eello_turn4=energia(9)
633 edihcnstr=energia(19)
638 etot=wsc*evdw+wscp*evdw2+welec*ees+wvdwpp*evdw1 &
639 +wang*ebe+wtor*etors+wscloc*escloc &
640 +wstrain*ehpb+wcorr*ecorr+wcorr5*ecorr5 &
641 +wcorr6*ecorr6+wturn4*eello_turn4+wturn3*eello_turn3 &
642 +wturn6*eturn6+wel_loc*eel_loc+edihcnstr+wtor_d*etors_d &
643 +wbond*estr+Uconst+wsccor*esccor
645 etot=wsc*evdw+wscp*evdw2+welec*(ees+evdw1) &
646 +wang*ebe+wtor*etors+wscloc*escloc &
647 +wstrain*ehpb+wcorr*ecorr+wcorr5*ecorr5 &
648 +wcorr6*ecorr6+wturn4*eello_turn4+wturn3*eello_turn3 &
649 +wturn6*eturn6+wel_loc*eel_loc+edihcnstr+wtor_d*etors_d &
650 +wbond*estr+Uconst+wsccor*esccor
656 if (isnan(etot).ne.0) energia(0)=1.0d+99
658 if (isnan(etot)) energia(0)=1.0d+99
663 idumm=proc_proc(etot,i)
665 call proc_proc(etot,i)
667 if(i.eq.1)energia(0)=1.0d+99
672 ! call enerprint(energia)
675 end subroutine sum_energy
676 !-----------------------------------------------------------------------------
677 subroutine rescale_weights(t_bath)
678 ! implicit real*8 (a-h,o-z)
682 ! include 'DIMENSIONS'
683 ! include 'COMMON.IOUNITS'
684 ! include 'COMMON.FFIELD'
685 ! include 'COMMON.SBRIDGE'
686 real(kind=8) :: kfac=2.4d0
687 real(kind=8) :: x,x2,x3,x4,x5,licznik=1.12692801104297249644
689 real(kind=8) :: t_bath,facT(6) !,facT2,facT3,facT4,facT5,facT6
690 real(kind=8) :: T0=3.0d2
693 ! facT=2*temp0/(t_bath+temp0)
694 if (rescale_mode.eq.0) then
701 else if (rescale_mode.eq.1) then
702 facT(1)=kfac/(kfac-1.0d0+t_bath/temp0)
703 facT(2)=kfac**2/(kfac**2-1.0d0+(t_bath/temp0)**2)
704 facT(3)=kfac**3/(kfac**3-1.0d0+(t_bath/temp0)**3)
705 facT(4)=kfac**4/(kfac**4-1.0d0+(t_bath/temp0)**4)
706 facT(5)=kfac**5/(kfac**5-1.0d0+(t_bath/temp0)**5)
708 !#if defined(WHAM_RUN) || defined(CLUSTER)
710 ! tt = 1.0d0/(beta_h(ib,ipar)*1.987D-3)
711 facT(6)=(320.0+80.0*dtanh((t_bath-320.0)/80.0))/320.0
718 else if (rescale_mode.eq.2) then
724 facT(1)=licznik/dlog(dexp(x)+dexp(-x))
725 facT(2)=licznik/dlog(dexp(x2)+dexp(-x2))
726 facT(3)=licznik/dlog(dexp(x3)+dexp(-x3))
727 facT(4)=licznik/dlog(dexp(x4)+dexp(-x4))
728 facT(5)=licznik/dlog(dexp(x5)+dexp(-x5))
730 !#if defined(WHAM_RUN) || defined(CLUSTER)
732 facT(6)=(320.0+80.0*dtanh((t_bath-320.0)/80.0))/320.0
740 write (iout,*) "Wrong RESCALE_MODE",rescale_mode
741 write (*,*) "Wrong RESCALE_MODE",rescale_mode
743 call MPI_Finalize(MPI_COMM_WORLD,IERROR)
747 welec=weights(3)*fact(1)
748 wcorr=weights(4)*fact(3)
749 wcorr5=weights(5)*fact(4)
750 wcorr6=weights(6)*fact(5)
751 wel_loc=weights(7)*fact(2)
752 wturn3=weights(8)*fact(2)
753 wturn4=weights(9)*fact(3)
754 wturn6=weights(10)*fact(5)
755 wtor=weights(13)*fact(1)
756 wtor_d=weights(14)*fact(2)
757 wsccor=weights(21)*fact(1)
760 end subroutine rescale_weights
761 !-----------------------------------------------------------------------------
762 subroutine enerprint(energia)
763 ! implicit real*8 (a-h,o-z)
764 ! include 'DIMENSIONS'
765 ! include 'COMMON.IOUNITS'
766 ! include 'COMMON.FFIELD'
767 ! include 'COMMON.SBRIDGE'
768 ! include 'COMMON.MD'
769 real(kind=8) :: energia(0:n_ene)
771 real(kind=8) :: etot,evdw,evdw2,ees,evdw1,ecorr,ecorr5,ecorr6,eel_loc
772 real(kind=8) :: eello_turn6,eello_turn3,eello_turn4,ebe,escloc
773 real(kind=8) :: etors,etors_d,ehpb,edihcnstr,estr,Uconst,esccor
779 evdw2=energia(2)+energia(18)
791 eello_turn3=energia(8)
792 eello_turn4=energia(9)
793 eello_turn6=energia(10)
799 edihcnstr=energia(19)
804 write (iout,10) evdw,wsc,evdw2,wscp,ees,welec,evdw1,wvdwpp,&
805 estr,wbond,ebe,wang,&
806 escloc,wscloc,etors,wtor,etors_d,wtor_d,ehpb,wstrain,&
808 ecorr5,wcorr5,ecorr6,wcorr6,eel_loc,wel_loc,eello_turn3,wturn3,&
809 eello_turn4,wturn4,eello_turn6,wturn6,esccor,wsccor,&
812 10 format (/'Virtual-chain energies:'// &
813 'EVDW= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-SC)'/ &
814 'EVDW2= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-p)'/ &
815 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p)'/ &
816 'EVDWPP=',1pE16.6,' WEIGHT=',1pD16.6,' (p-p VDW)'/ &
817 'ESTR= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching)'/ &
818 'EBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (bending)'/ &
819 'ESC= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/ &
820 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/ &
821 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/ &
822 'EHBP= ',1pE16.6,' WEIGHT=',1pD16.6, &
823 ' (SS bridges & dist. cnstr.)'/ &
824 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
825 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
826 'ECORR6=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
827 'EELLO= ',1pE16.6,' WEIGHT=',1pD16.6,' (electrostatic-local)'/ &
828 'ETURN3=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 3rd order)'/ &
829 'ETURN4=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 4th order)'/ &
830 'ETURN6=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 6th order)'/ &
831 'ESCCOR=',1pE16.6,' WEIGHT=',1pD16.6,' (backbone-rotamer corr)'/ &
832 'EDIHC= ',1pE16.6,' (dihedral angle constraints)'/ &
833 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/ &
834 'UCONST= ',1pE16.6,' (Constraint energy)'/ &
835 'ETOT= ',1pE16.6,' (total)')
837 write (iout,10) evdw,wsc,evdw2,wscp,ees,welec,&
838 estr,wbond,ebe,wang,&
839 escloc,wscloc,etors,wtor,etors_d,wtor_d,ehpb,wstrain,&
841 ecorr5,wcorr5,ecorr6,wcorr6,eel_loc,wel_loc,eello_turn3,wturn3,&
842 eello_turn4,wturn4,eello_turn6,wturn6,esccor,wsccor,edihcnstr,&
844 10 format (/'Virtual-chain energies:'// &
845 'EVDW= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-SC)'/ &
846 'EVDW2= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-p)'/ &
847 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p)'/ &
848 'ESTR= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching)'/ &
849 'EBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (bending)'/ &
850 'ESC= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/ &
851 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/ &
852 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/ &
853 'EHBP= ',1pE16.6,' WEIGHT=',1pD16.6, &
854 ' (SS bridges & dist. cnstr.)'/ &
855 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
856 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
857 'ECORR6=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
858 'EELLO= ',1pE16.6,' WEIGHT=',1pD16.6,' (electrostatic-local)'/ &
859 'ETURN3=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 3rd order)'/ &
860 'ETURN4=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 4th order)'/ &
861 'ETURN6=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 6th order)'/ &
862 'ESCCOR=',1pE16.6,' WEIGHT=',1pD16.6,' (backbone-rotamer corr)'/ &
863 'EDIHC= ',1pE16.6,' (dihedral angle constraints)'/ &
864 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/ &
865 'UCONST=',1pE16.6,' (Constraint energy)'/ &
866 'ETOT= ',1pE16.6,' (total)')
869 end subroutine enerprint
870 !-----------------------------------------------------------------------------
873 ! This subroutine calculates the interaction energy of nonbonded side chains
874 ! assuming the LJ potential of interaction.
876 ! implicit real*8 (a-h,o-z)
877 ! include 'DIMENSIONS'
878 real(kind=8),parameter :: accur=1.0d-10
879 ! include 'COMMON.GEO'
880 ! include 'COMMON.VAR'
881 ! include 'COMMON.LOCAL'
882 ! include 'COMMON.CHAIN'
883 ! include 'COMMON.DERIV'
884 ! include 'COMMON.INTERACT'
885 ! include 'COMMON.TORSION'
886 ! include 'COMMON.SBRIDGE'
887 ! include 'COMMON.NAMES'
888 ! include 'COMMON.IOUNITS'
889 ! include 'COMMON.CONTACTS'
890 real(kind=8),dimension(3) :: gg
893 integer :: i,itypi,iint,j,itypi1,itypj,k
894 real(kind=8) :: rij,rcut,fcont,fprimcont,rrij
895 real(kind=8) :: evdw,xi,yi,zi,xj,yj,zj
896 real(kind=8) :: eps0ij,fac,e1,e2,evdwij,sigij,r0ij
898 ! write(iout,*)'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
900 ! allocate(num_cont(iatsc_s:iatsc_e)) !(maxres) nnt,nct-2
901 ! allocate(jcont(nres/4,iatsc_s:iatsc_e)) !(maxconts,maxres) (maxconts=maxres/4)
902 ! allocate(facont(nres/4,iatsc_s:iatsc_e)) !(maxconts,maxres)
903 ! allocate(gacont(3,nres/4,iatsc_s:iatsc_e)) !(3,maxconts,maxres)
907 if (itypi.eq.ntyp1) cycle
908 itypi1=iabs(itype(i+1))
915 ! Calculate SC interaction energy.
918 !d write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
919 !d & 'iend=',iend(i,iint)
920 do j=istart(i,iint),iend(i,iint)
922 if (itypj.eq.ntyp1) cycle
926 ! Change 12/1/95 to calculate four-body interactions
927 rij=xj*xj+yj*yj+zj*zj
929 ! write (iout,*)'i=',i,' j=',j,' itypi=',itypi,' itypj=',itypj
930 eps0ij=eps(itypi,itypj)
932 e1=fac*fac*aa(itypi,itypj)
933 e2=fac*bb(itypi,itypj)
935 !d sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
936 !d epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
937 !d write (iout,'(2(a3,i3,2x),6(1pd12.4)/2(3(1pd12.4),5x)/)')
938 !d & restyp(itypi),i,restyp(itypj),j,aa(itypi,itypj),
939 !d & bb(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,epsi,sigm,
940 !d & (c(k,i),k=1,3),(c(k,j),k=1,3)
943 ! Calculate the components of the gradient in DC and X
945 fac=-rrij*(e1+evdwij)
950 gvdwx(k,i)=gvdwx(k,i)-gg(k)
951 gvdwx(k,j)=gvdwx(k,j)+gg(k)
952 gvdwc(k,i)=gvdwc(k,i)-gg(k)
953 gvdwc(k,j)=gvdwc(k,j)+gg(k)
957 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
961 ! 12/1/95, revised on 5/20/97
963 ! Calculate the contact function. The ith column of the array JCONT will
964 ! contain the numbers of atoms that make contacts with the atom I (of numbers
965 ! greater than I). The arrays FACONT and GACONT will contain the values of
966 ! the contact function and its derivative.
968 ! Uncomment next line, if the correlation interactions include EVDW explicitly.
969 ! if (j.gt.i+1 .and. evdwij.le.0.0D0) then
970 ! Uncomment next line, if the correlation interactions are contact function only
971 if (j.gt.i+1.and. eps0ij.gt.0.0D0) then
973 sigij=sigma(itypi,itypj)
974 r0ij=rs0(itypi,itypj)
976 ! Check whether the SC's are not too far to make a contact.
979 call gcont(rij,rcut,1.0d0,0.2d0*rcut,fcont,fprimcont)
980 ! Add a new contact, if the SC's are close enough, but not too close (r<sigma).
982 if (fcont.gt.0.0D0) then
983 ! If the SC-SC distance if close to sigma, apply spline.
984 !Adam call gcont(-rij,-1.03d0*sigij,2.0d0*sigij,1.0d0,
985 !Adam & fcont1,fprimcont1)
986 !Adam fcont1=1.0d0-fcont1
987 !Adam if (fcont1.gt.0.0d0) then
988 !Adam fprimcont=fprimcont*fcont1+fcont*fprimcont1
989 !Adam fcont=fcont*fcont1
991 ! Uncomment following 4 lines to have the geometric average of the epsilon0's
992 !ga eps0ij=1.0d0/dsqrt(eps0ij)
994 !ga gg(k)=gg(k)*eps0ij
996 !ga eps0ij=-evdwij*eps0ij
997 ! Uncomment for AL's type of SC correlation interactions.
999 num_conti=num_conti+1
1000 jcont(num_conti,i)=j
1001 facont(num_conti,i)=fcont*eps0ij
1002 fprimcont=eps0ij*fprimcont/rij
1004 !Adam gacont(1,num_conti,i)=-fprimcont*xj+fcont*gg(1)
1005 !Adam gacont(2,num_conti,i)=-fprimcont*yj+fcont*gg(2)
1006 !Adam gacont(3,num_conti,i)=-fprimcont*zj+fcont*gg(3)
1007 ! Uncomment following 3 lines for Skolnick's type of SC correlation.
1008 gacont(1,num_conti,i)=-fprimcont*xj
1009 gacont(2,num_conti,i)=-fprimcont*yj
1010 gacont(3,num_conti,i)=-fprimcont*zj
1011 !d write (iout,'(2i5,2f10.5)') i,j,rij,facont(num_conti,i)
1012 !d write (iout,'(2i3,3f10.5)')
1013 !d & i,j,(gacont(kk,num_conti,i),kk=1,3)
1019 num_cont(i)=num_conti
1023 gvdwc(j,i)=expon*gvdwc(j,i)
1024 gvdwx(j,i)=expon*gvdwx(j,i)
1027 !******************************************************************************
1031 ! To save time, the factor of EXPON has been extracted from ALL components
1032 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
1035 !******************************************************************************
1038 !-----------------------------------------------------------------------------
1039 subroutine eljk(evdw)
1041 ! This subroutine calculates the interaction energy of nonbonded side chains
1042 ! assuming the LJK potential of interaction.
1044 ! implicit real*8 (a-h,o-z)
1045 ! include 'DIMENSIONS'
1046 ! include 'COMMON.GEO'
1047 ! include 'COMMON.VAR'
1048 ! include 'COMMON.LOCAL'
1049 ! include 'COMMON.CHAIN'
1050 ! include 'COMMON.DERIV'
1051 ! include 'COMMON.INTERACT'
1052 ! include 'COMMON.IOUNITS'
1053 ! include 'COMMON.NAMES'
1054 real(kind=8),dimension(3) :: gg
1057 integer :: i,iint,j,itypi,itypi1,k,itypj
1058 real(kind=8) :: rrij,xi,yi,zi,xj,yj,zj,fac_augm,e_augm,r_inv_ij
1059 real(kind=8) :: evdw,rij,r_shift_inv,fac,e1,e2,evdwij
1061 ! print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
1063 do i=iatsc_s,iatsc_e
1064 itypi=iabs(itype(i))
1065 if (itypi.eq.ntyp1) cycle
1066 itypi1=iabs(itype(i+1))
1071 ! Calculate SC interaction energy.
1073 do iint=1,nint_gr(i)
1074 do j=istart(i,iint),iend(i,iint)
1075 itypj=iabs(itype(j))
1076 if (itypj.eq.ntyp1) cycle
1080 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1081 fac_augm=rrij**expon
1082 e_augm=augm(itypi,itypj)*fac_augm
1083 r_inv_ij=dsqrt(rrij)
1085 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
1086 fac=r_shift_inv**expon
1087 e1=fac*fac*aa(itypi,itypj)
1088 e2=fac*bb(itypi,itypj)
1090 !d sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1091 !d epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1092 !d write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
1093 !d & restyp(itypi),i,restyp(itypj),j,aa(itypi,itypj),
1094 !d & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
1095 !d & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
1096 !d & (c(k,i),k=1,3),(c(k,j),k=1,3)
1099 ! Calculate the components of the gradient in DC and X
1101 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
1106 gvdwx(k,i)=gvdwx(k,i)-gg(k)
1107 gvdwx(k,j)=gvdwx(k,j)+gg(k)
1108 gvdwc(k,i)=gvdwc(k,i)-gg(k)
1109 gvdwc(k,j)=gvdwc(k,j)+gg(k)
1113 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
1121 gvdwc(j,i)=expon*gvdwc(j,i)
1122 gvdwx(j,i)=expon*gvdwx(j,i)
1127 !-----------------------------------------------------------------------------
1128 subroutine ebp(evdw)
1130 ! This subroutine calculates the interaction energy of nonbonded side chains
1131 ! assuming the Berne-Pechukas potential of interaction.
1135 ! implicit real*8 (a-h,o-z)
1136 ! include 'DIMENSIONS'
1137 ! include 'COMMON.GEO'
1138 ! include 'COMMON.VAR'
1139 ! include 'COMMON.LOCAL'
1140 ! include 'COMMON.CHAIN'
1141 ! include 'COMMON.DERIV'
1142 ! include 'COMMON.NAMES'
1143 ! include 'COMMON.INTERACT'
1144 ! include 'COMMON.IOUNITS'
1145 ! include 'COMMON.CALC'
1147 !el integer :: icall
1148 !el common /srutu/ icall
1149 ! double precision rrsave(maxdim)
1152 integer :: iint,itypi,itypi1,itypj
1153 real(kind=8) :: rrij,xi,yi,zi
1154 real(kind=8) :: evdw,fac,e1,e2,sigm,epsi
1156 ! print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
1158 ! if (icall.eq.0) then
1164 do i=iatsc_s,iatsc_e
1165 itypi=iabs(itype(i))
1166 if (itypi.eq.ntyp1) cycle
1167 itypi1=iabs(itype(i+1))
1171 dxi=dc_norm(1,nres+i)
1172 dyi=dc_norm(2,nres+i)
1173 dzi=dc_norm(3,nres+i)
1174 ! dsci_inv=dsc_inv(itypi)
1175 dsci_inv=vbld_inv(i+nres)
1177 ! Calculate SC interaction energy.
1179 do iint=1,nint_gr(i)
1180 do j=istart(i,iint),iend(i,iint)
1182 itypj=iabs(itype(j))
1183 if (itypj.eq.ntyp1) cycle
1184 ! dscj_inv=dsc_inv(itypj)
1185 dscj_inv=vbld_inv(j+nres)
1186 chi1=chi(itypi,itypj)
1187 chi2=chi(itypj,itypi)
1194 alf12=0.5D0*(alf1+alf2)
1195 ! For diagnostics only!!!
1208 dxj=dc_norm(1,nres+j)
1209 dyj=dc_norm(2,nres+j)
1210 dzj=dc_norm(3,nres+j)
1211 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1212 !d if (icall.eq.0) then
1218 ! Calculate the angle-dependent terms of energy & contributions to derivatives.
1220 ! Calculate whole angle-dependent part of epsilon and contributions
1221 ! to its derivatives
1222 fac=(rrij*sigsq)**expon2
1223 e1=fac*fac*aa(itypi,itypj)
1224 e2=fac*bb(itypi,itypj)
1225 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
1226 eps2der=evdwij*eps3rt
1227 eps3der=evdwij*eps2rt
1228 evdwij=evdwij*eps2rt*eps3rt
1231 sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1232 epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1233 !d write (iout,'(2(a3,i3,2x),15(0pf7.3))')
1234 !d & restyp(itypi),i,restyp(itypj),j,
1235 !d & epsi,sigm,chi1,chi2,chip1,chip2,
1236 !d & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
1237 !d & om1,om2,om12,1.0D0/dsqrt(rrij),
1240 ! Calculate gradient components.
1241 e1=e1*eps1*eps2rt**2*eps3rt**2
1242 fac=-expon*(e1+evdwij)
1245 ! Calculate radial part of the gradient
1249 ! Calculate the angular part of the gradient and sum add the contributions
1250 ! to the appropriate components of the Cartesian gradient.
1258 !-----------------------------------------------------------------------------
1259 subroutine egb(evdw)
1261 ! This subroutine calculates the interaction energy of nonbonded side chains
1262 ! assuming the Gay-Berne potential of interaction.
1265 ! implicit real*8 (a-h,o-z)
1266 ! include 'DIMENSIONS'
1267 ! include 'COMMON.GEO'
1268 ! include 'COMMON.VAR'
1269 ! include 'COMMON.LOCAL'
1270 ! include 'COMMON.CHAIN'
1271 ! include 'COMMON.DERIV'
1272 ! include 'COMMON.NAMES'
1273 ! include 'COMMON.INTERACT'
1274 ! include 'COMMON.IOUNITS'
1275 ! include 'COMMON.CALC'
1276 ! include 'COMMON.CONTROL'
1277 ! include 'COMMON.SBRIDGE'
1280 integer :: iint,itypi,itypi1,itypj,subchap
1281 real(kind=8) :: rrij,xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
1282 real(kind=8) :: evdw,sig0ij
1283 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
1284 dist_temp, dist_init
1286 !cccc energy_dec=.false.
1287 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
1290 ! if (icall.eq.0) lprn=.false.
1292 do i=iatsc_s,iatsc_e
1293 itypi=iabs(itype(i))
1294 if (itypi.eq.ntyp1) cycle
1295 itypi1=iabs(itype(i+1))
1299 xi=dmod(xi,boxxsize)
1300 if (xi.lt.0) xi=xi+boxxsize
1301 yi=dmod(yi,boxysize)
1302 if (yi.lt.0) yi=yi+boxysize
1303 zi=dmod(zi,boxzsize)
1304 if (zi.lt.0) zi=zi+boxzsize
1306 dxi=dc_norm(1,nres+i)
1307 dyi=dc_norm(2,nres+i)
1308 dzi=dc_norm(3,nres+i)
1309 ! dsci_inv=dsc_inv(itypi)
1310 dsci_inv=vbld_inv(i+nres)
1311 ! write (iout,*) "i",i,dsc_inv(itypi),dsci_inv,1.0d0/vbld(i+nres)
1312 ! write (iout,*) "dcnori",dxi*dxi+dyi*dyi+dzi*dzi
1314 ! Calculate SC interaction energy.
1316 do iint=1,nint_gr(i)
1317 do j=istart(i,iint),iend(i,iint)
1318 IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
1319 call dyn_ssbond_ene(i,j,evdwij)
1321 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
1322 'evdw',i,j,evdwij,' ss'
1323 ! if (energy_dec) write (iout,*) &
1324 ! 'evdw',i,j,evdwij,' ss'
1327 itypj=iabs(itype(j))
1328 if (itypj.eq.ntyp1) cycle
1329 ! dscj_inv=dsc_inv(itypj)
1330 dscj_inv=vbld_inv(j+nres)
1331 ! write (iout,*) "j",j,dsc_inv(itypj),dscj_inv,&
1332 ! 1.0d0/vbld(j+nres) !d
1333 ! write (iout,*) "i",i," j", j," itype",itype(i),itype(j)
1334 sig0ij=sigma(itypi,itypj)
1335 chi1=chi(itypi,itypj)
1336 chi2=chi(itypj,itypi)
1343 alf12=0.5D0*(alf1+alf2)
1344 ! For diagnostics only!!!
1357 xj=dmod(xj,boxxsize)
1358 if (xj.lt.0) xj=xj+boxxsize
1359 yj=dmod(yj,boxysize)
1360 if (yj.lt.0) yj=yj+boxysize
1361 zj=dmod(zj,boxzsize)
1362 if (zj.lt.0) zj=zj+boxzsize
1363 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
1371 xj=xj_safe+xshift*boxxsize
1372 yj=yj_safe+yshift*boxysize
1373 zj=zj_safe+zshift*boxzsize
1374 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
1375 if(dist_temp.lt.dist_init) then
1385 if (subchap.eq.1) then
1394 dxj=dc_norm(1,nres+j)
1395 dyj=dc_norm(2,nres+j)
1396 dzj=dc_norm(3,nres+j)
1397 ! write (iout,*) "dcnorj",dxi*dxi+dyi*dyi+dzi*dzi
1398 ! write (iout,*) "j",j," dc_norm",& !d
1399 ! dc_norm(1,nres+j),dc_norm(2,nres+j),dc_norm(3,nres+j)
1400 ! write(iout,*)"rrij ",rrij
1401 ! write(iout,*)"xj yj zj ", xj, yj, zj
1402 ! write(iout,*)"xi yi zi ", xi, yi, zi
1403 ! write(iout,*)"c ", c(1,:), c(2,:), c(3,:)
1404 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1406 sss_ele_cut=sscale_ele(1.0d0/(rij*sigma(itypi,itypj)))
1407 sss_ele_grad=sscagrad_ele(1.0d0/(rij*sigma(itypi,itypj)))
1408 ! print *,sss_ele_cut,sss_ele_grad,&
1409 ! 1.0d0/(rij),r_cut_ele,rlamb_ele
1410 if (sss_ele_cut.le.0.0) cycle
1411 ! Calculate angle-dependent terms of energy and contributions to their
1415 sig=sig0ij*dsqrt(sigsq)
1416 rij_shift=1.0D0/rij-sig+sig0ij
1417 ! write(iout,*)" rij_shift",rij_shift," rij",rij," sig",sig,&
1419 ! for diagnostics; uncomment
1420 ! rij_shift=1.2*sig0ij
1421 ! I hate to put IF's in the loops, but here don't have another choice!!!!
1422 if (rij_shift.le.0.0D0) then
1424 !d write (iout,'(2(a3,i3,2x),17(0pf7.3))')
1425 !d & restyp(itypi),i,restyp(itypj),j,
1426 !d & rij_shift,1.0D0/rij,sig,sig0ij,sigsq,1-dsqrt(sigsq)
1430 !---------------------------------------------------------------
1431 rij_shift=1.0D0/rij_shift
1432 fac=rij_shift**expon
1433 e1=fac*fac*aa(itypi,itypj)
1434 e2=fac*bb(itypi,itypj)
1435 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
1436 eps2der=evdwij*eps3rt
1437 eps3der=evdwij*eps2rt
1438 ! write(iout,*)"aa, bb ",aa(:,:),bb(:,:)
1439 ! write (iout,*) "sigsq",sigsq," sig",sig," eps2rt",eps2rt,& !d
1440 ! " eps3rt",eps3rt," eps1",eps1," e1",e1," e2",e2," fac",fac !d
1441 evdwij=evdwij*eps2rt*eps3rt
1442 evdw=evdw+evdwij*sss_ele_cut
1444 sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1445 epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1446 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
1447 restyp(itypi),i,restyp(itypj),j, &
1448 epsi,sigm,chi1,chi2,chip1,chip2, &
1449 eps1,eps2rt**2,eps3rt**2,sig,sig0ij, &
1450 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift, &
1454 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
1455 'evdw',i,j,evdwij !,"egb"
1456 ! if (energy_dec) write (iout,*) &
1459 ! Calculate gradient components.
1460 e1=e1*eps1*eps2rt**2*eps3rt**2
1461 fac=-expon*(e1+evdwij)*rij_shift
1464 ! print *,'before fac',fac,rij,evdwij
1465 fac=fac+evdwij*sss_ele_grad/sss_ele_cut&
1466 /sigma(itypi,itypj)*rij
1467 ! print *,'grad part scale',fac, &
1468 ! evdwij*sss_ele_grad/sss_ele_cut &
1469 ! /sigma(itypi,itypj)*rij
1471 ! Calculate the radial part of the gradient
1475 ! print *,'before sc_grad', gg(1),gg(2),gg(3)
1476 ! Calculate angular part of the gradient.
1482 ! write (iout,*) "Number of loop steps in EGB:",ind
1483 !ccc energy_dec=.false.
1486 !-----------------------------------------------------------------------------
1487 subroutine egbv(evdw)
1489 ! This subroutine calculates the interaction energy of nonbonded side chains
1490 ! assuming the Gay-Berne-Vorobjev potential of interaction.
1494 ! implicit real*8 (a-h,o-z)
1495 ! include 'DIMENSIONS'
1496 ! include 'COMMON.GEO'
1497 ! include 'COMMON.VAR'
1498 ! include 'COMMON.LOCAL'
1499 ! include 'COMMON.CHAIN'
1500 ! include 'COMMON.DERIV'
1501 ! include 'COMMON.NAMES'
1502 ! include 'COMMON.INTERACT'
1503 ! include 'COMMON.IOUNITS'
1504 ! include 'COMMON.CALC'
1506 !el integer :: icall
1507 !el common /srutu/ icall
1510 integer :: iint,itypi,itypi1,itypj
1511 real(kind=8) :: rrij,xi,yi,zi,r0ij,fac_augm,e_augm,fac,e1,e2,sigm
1512 real(kind=8) :: evdw,sig0ij,sig,rij_shift,epsi
1514 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
1517 ! if (icall.eq.0) lprn=.true.
1519 do i=iatsc_s,iatsc_e
1520 itypi=iabs(itype(i))
1521 if (itypi.eq.ntyp1) cycle
1522 itypi1=iabs(itype(i+1))
1526 dxi=dc_norm(1,nres+i)
1527 dyi=dc_norm(2,nres+i)
1528 dzi=dc_norm(3,nres+i)
1529 ! dsci_inv=dsc_inv(itypi)
1530 dsci_inv=vbld_inv(i+nres)
1532 ! Calculate SC interaction energy.
1534 do iint=1,nint_gr(i)
1535 do j=istart(i,iint),iend(i,iint)
1537 itypj=iabs(itype(j))
1538 if (itypj.eq.ntyp1) cycle
1539 ! dscj_inv=dsc_inv(itypj)
1540 dscj_inv=vbld_inv(j+nres)
1541 sig0ij=sigma(itypi,itypj)
1542 r0ij=r0(itypi,itypj)
1543 chi1=chi(itypi,itypj)
1544 chi2=chi(itypj,itypi)
1551 alf12=0.5D0*(alf1+alf2)
1552 ! For diagnostics only!!!
1565 dxj=dc_norm(1,nres+j)
1566 dyj=dc_norm(2,nres+j)
1567 dzj=dc_norm(3,nres+j)
1568 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1570 ! Calculate angle-dependent terms of energy and contributions to their
1574 sig=sig0ij*dsqrt(sigsq)
1575 rij_shift=1.0D0/rij-sig+r0ij
1576 ! I hate to put IF's in the loops, but here don't have another choice!!!!
1577 if (rij_shift.le.0.0D0) then
1582 !---------------------------------------------------------------
1583 rij_shift=1.0D0/rij_shift
1584 fac=rij_shift**expon
1585 e1=fac*fac*aa(itypi,itypj)
1586 e2=fac*bb(itypi,itypj)
1587 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
1588 eps2der=evdwij*eps3rt
1589 eps3der=evdwij*eps2rt
1590 fac_augm=rrij**expon
1591 e_augm=augm(itypi,itypj)*fac_augm
1592 evdwij=evdwij*eps2rt*eps3rt
1593 evdw=evdw+evdwij+e_augm
1595 sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1596 epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1597 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
1598 restyp(itypi),i,restyp(itypj),j,&
1599 epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),&
1600 chi1,chi2,chip1,chip2,&
1601 eps1,eps2rt**2,eps3rt**2,&
1602 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
1605 ! Calculate gradient components.
1606 e1=e1*eps1*eps2rt**2*eps3rt**2
1607 fac=-expon*(e1+evdwij)*rij_shift
1609 fac=rij*fac-2*expon*rrij*e_augm
1610 ! Calculate the radial part of the gradient
1614 ! Calculate angular part of the gradient.
1620 !-----------------------------------------------------------------------------
1621 !el subroutine sc_angular in module geometry
1622 !-----------------------------------------------------------------------------
1623 subroutine e_softsphere(evdw)
1625 ! This subroutine calculates the interaction energy of nonbonded side chains
1626 ! assuming the LJ potential of interaction.
1628 ! implicit real*8 (a-h,o-z)
1629 ! include 'DIMENSIONS'
1630 real(kind=8),parameter :: accur=1.0d-10
1631 ! include 'COMMON.GEO'
1632 ! include 'COMMON.VAR'
1633 ! include 'COMMON.LOCAL'
1634 ! include 'COMMON.CHAIN'
1635 ! include 'COMMON.DERIV'
1636 ! include 'COMMON.INTERACT'
1637 ! include 'COMMON.TORSION'
1638 ! include 'COMMON.SBRIDGE'
1639 ! include 'COMMON.NAMES'
1640 ! include 'COMMON.IOUNITS'
1641 ! include 'COMMON.CONTACTS'
1642 real(kind=8),dimension(3) :: gg
1643 !d print *,'Entering Esoft_sphere nnt=',nnt,' nct=',nct
1645 integer :: i,iint,j,itypi,itypi1,itypj,k
1646 real(kind=8) :: evdw,xj,yj,zj,xi,yi,zi,rij,r0ij,r0ijsq,evdwij
1650 do i=iatsc_s,iatsc_e
1651 itypi=iabs(itype(i))
1652 if (itypi.eq.ntyp1) cycle
1653 itypi1=iabs(itype(i+1))
1658 ! Calculate SC interaction energy.
1660 do iint=1,nint_gr(i)
1661 !d write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
1662 !d & 'iend=',iend(i,iint)
1663 do j=istart(i,iint),iend(i,iint)
1664 itypj=iabs(itype(j))
1665 if (itypj.eq.ntyp1) cycle
1669 rij=xj*xj+yj*yj+zj*zj
1670 ! write (iout,*)'i=',i,' j=',j,' itypi=',itypi,' itypj=',itypj
1671 r0ij=r0(itypi,itypj)
1673 ! print *,i,j,r0ij,dsqrt(rij)
1674 if (rij.lt.r0ijsq) then
1675 evdwij=0.25d0*(rij-r0ijsq)**2
1683 ! Calculate the components of the gradient in DC and X
1689 gvdwx(k,i)=gvdwx(k,i)-gg(k)
1690 gvdwx(k,j)=gvdwx(k,j)+gg(k)
1691 gvdwc(k,i)=gvdwc(k,i)-gg(k)
1692 gvdwc(k,j)=gvdwc(k,j)+gg(k)
1696 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
1703 end subroutine e_softsphere
1704 !-----------------------------------------------------------------------------
1705 subroutine eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
1707 ! Soft-sphere potential of p-p interaction
1709 ! implicit real*8 (a-h,o-z)
1710 ! include 'DIMENSIONS'
1711 ! include 'COMMON.CONTROL'
1712 ! include 'COMMON.IOUNITS'
1713 ! include 'COMMON.GEO'
1714 ! include 'COMMON.VAR'
1715 ! include 'COMMON.LOCAL'
1716 ! include 'COMMON.CHAIN'
1717 ! include 'COMMON.DERIV'
1718 ! include 'COMMON.INTERACT'
1719 ! include 'COMMON.CONTACTS'
1720 ! include 'COMMON.TORSION'
1721 ! include 'COMMON.VECTORS'
1722 ! include 'COMMON.FFIELD'
1723 real(kind=8),dimension(3) :: ggg
1724 !d write(iout,*) 'In EELEC_soft_sphere'
1726 integer :: i,j,k,num_conti,iteli,itelj
1727 real(kind=8) :: ees,evdw1,eel_loc,eello_turn3,eello_turn4
1728 real(kind=8) :: dxi,dyi,dzi,xmedi,ymedi,zmedi,r0ij,r0ijsq
1729 real(kind=8) :: dxj,dyj,dzj,xj,yj,zj,rij,evdw1ij,fac
1737 do i=iatel_s,iatel_e
1738 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1) cycle
1742 xmedi=c(1,i)+0.5d0*dxi
1743 ymedi=c(2,i)+0.5d0*dyi
1744 zmedi=c(3,i)+0.5d0*dzi
1746 ! write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
1747 do j=ielstart(i),ielend(i)
1748 if (itype(j).eq.ntyp1 .or. itype(j+1).eq.ntyp1) cycle
1752 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
1753 r0ij=rpp(iteli,itelj)
1758 xj=c(1,j)+0.5D0*dxj-xmedi
1759 yj=c(2,j)+0.5D0*dyj-ymedi
1760 zj=c(3,j)+0.5D0*dzj-zmedi
1761 rij=xj*xj+yj*yj+zj*zj
1762 if (rij.lt.r0ijsq) then
1763 evdw1ij=0.25d0*(rij-r0ijsq)**2
1771 ! Calculate contributions to the Cartesian gradient.
1777 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
1778 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
1781 ! Loop over residues i+1 thru j-1.
1785 !grad gelc(l,k)=gelc(l,k)+ggg(l)
1790 !grad do i=nnt,nct-1
1792 !grad gelc(k,i)=gelc(k,i)+0.5d0*gelc(k,i)
1794 !grad do j=i+1,nct-1
1796 !grad gelc(k,i)=gelc(k,i)+gelc(k,j)
1801 end subroutine eelec_soft_sphere
1802 !-----------------------------------------------------------------------------
1803 subroutine vec_and_deriv
1804 ! implicit real*8 (a-h,o-z)
1805 ! include 'DIMENSIONS'
1809 ! include 'COMMON.IOUNITS'
1810 ! include 'COMMON.GEO'
1811 ! include 'COMMON.VAR'
1812 ! include 'COMMON.LOCAL'
1813 ! include 'COMMON.CHAIN'
1814 ! include 'COMMON.VECTORS'
1815 ! include 'COMMON.SETUP'
1816 ! include 'COMMON.TIME1'
1817 real(kind=8),dimension(3,3,2) :: uyder,uzder
1818 real(kind=8),dimension(2) :: vbld_inv_temp
1819 ! Compute the local reference systems. For reference system (i), the
1820 ! X-axis points from CA(i) to CA(i+1), the Y axis is in the
1821 ! CA(i)-CA(i+1)-CA(i+2) plane, and the Z axis is perpendicular to this plane.
1824 real(kind=8) :: facy,fac,costh
1827 do i=ivec_start,ivec_end
1831 if (i.eq.nres-1) then
1832 ! Case of the last full residue
1833 ! Compute the Z-axis
1834 call vecpr(dc_norm(1,i),dc_norm(1,i-1),uz(1,i))
1835 costh=dcos(pi-theta(nres))
1836 fac=1.0d0/dsqrt(1.0d0-costh*costh)
1840 ! Compute the derivatives of uz
1842 uzder(2,1,1)=-dc_norm(3,i-1)
1843 uzder(3,1,1)= dc_norm(2,i-1)
1844 uzder(1,2,1)= dc_norm(3,i-1)
1846 uzder(3,2,1)=-dc_norm(1,i-1)
1847 uzder(1,3,1)=-dc_norm(2,i-1)
1848 uzder(2,3,1)= dc_norm(1,i-1)
1851 uzder(2,1,2)= dc_norm(3,i)
1852 uzder(3,1,2)=-dc_norm(2,i)
1853 uzder(1,2,2)=-dc_norm(3,i)
1855 uzder(3,2,2)= dc_norm(1,i)
1856 uzder(1,3,2)= dc_norm(2,i)
1857 uzder(2,3,2)=-dc_norm(1,i)
1859 ! Compute the Y-axis
1862 uy(k,i)=fac*(dc_norm(k,i-1)-costh*dc_norm(k,i))
1864 ! Compute the derivatives of uy
1867 uyder(k,j,1)=2*dc_norm(k,i-1)*dc_norm(j,i) &
1868 -dc_norm(k,i)*dc_norm(j,i-1)
1869 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
1871 uyder(j,j,1)=uyder(j,j,1)-costh
1872 uyder(j,j,2)=1.0d0+uyder(j,j,2)
1877 uygrad(l,k,j,i)=uyder(l,k,j)
1878 uzgrad(l,k,j,i)=uzder(l,k,j)
1882 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
1883 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
1884 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
1885 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
1888 ! Compute the Z-axis
1889 call vecpr(dc_norm(1,i),dc_norm(1,i+1),uz(1,i))
1890 costh=dcos(pi-theta(i+2))
1891 fac=1.0d0/dsqrt(1.0d0-costh*costh)
1895 ! Compute the derivatives of uz
1897 uzder(2,1,1)=-dc_norm(3,i+1)
1898 uzder(3,1,1)= dc_norm(2,i+1)
1899 uzder(1,2,1)= dc_norm(3,i+1)
1901 uzder(3,2,1)=-dc_norm(1,i+1)
1902 uzder(1,3,1)=-dc_norm(2,i+1)
1903 uzder(2,3,1)= dc_norm(1,i+1)
1906 uzder(2,1,2)= dc_norm(3,i)
1907 uzder(3,1,2)=-dc_norm(2,i)
1908 uzder(1,2,2)=-dc_norm(3,i)
1910 uzder(3,2,2)= dc_norm(1,i)
1911 uzder(1,3,2)= dc_norm(2,i)
1912 uzder(2,3,2)=-dc_norm(1,i)
1914 ! Compute the Y-axis
1917 uy(k,i)=facy*(dc_norm(k,i+1)-costh*dc_norm(k,i))
1919 ! Compute the derivatives of uy
1922 uyder(k,j,1)=2*dc_norm(k,i+1)*dc_norm(j,i) &
1923 -dc_norm(k,i)*dc_norm(j,i+1)
1924 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
1926 uyder(j,j,1)=uyder(j,j,1)-costh
1927 uyder(j,j,2)=1.0d0+uyder(j,j,2)
1932 uygrad(l,k,j,i)=uyder(l,k,j)
1933 uzgrad(l,k,j,i)=uzder(l,k,j)
1937 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
1938 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
1939 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
1940 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
1944 vbld_inv_temp(1)=vbld_inv(i+1)
1945 if (i.lt.nres-1) then
1946 vbld_inv_temp(2)=vbld_inv(i+2)
1948 vbld_inv_temp(2)=vbld_inv(i)
1953 uygrad(l,k,j,i)=vbld_inv_temp(j)*uygrad(l,k,j,i)
1954 uzgrad(l,k,j,i)=vbld_inv_temp(j)*uzgrad(l,k,j,i)
1959 #if defined(PARVEC) && defined(MPI)
1960 if (nfgtasks1.gt.1) then
1962 ! print *,"Processor",fg_rank1,kolor1," ivec_start",ivec_start,
1963 ! & " ivec_displ",(ivec_displ(i),i=0,nfgtasks1-1),
1964 ! & " ivec_count",(ivec_count(i),i=0,nfgtasks1-1)
1965 call MPI_Allgatherv(uy(1,ivec_start),ivec_count(fg_rank1),&
1966 MPI_UYZ,uy(1,1),ivec_count(0),ivec_displ(0),MPI_UYZ,&
1968 call MPI_Allgatherv(uz(1,ivec_start),ivec_count(fg_rank1),&
1969 MPI_UYZ,uz(1,1),ivec_count(0),ivec_displ(0),MPI_UYZ,&
1971 call MPI_Allgatherv(uygrad(1,1,1,ivec_start),&
1972 ivec_count(fg_rank1),MPI_UYZGRAD,uygrad(1,1,1,1),ivec_count(0),&
1973 ivec_displ(0),MPI_UYZGRAD,FG_COMM1,IERR)
1974 call MPI_Allgatherv(uzgrad(1,1,1,ivec_start),&
1975 ivec_count(fg_rank1),MPI_UYZGRAD,uzgrad(1,1,1,1),ivec_count(0),&
1976 ivec_displ(0),MPI_UYZGRAD,FG_COMM1,IERR)
1977 time_gather=time_gather+MPI_Wtime()-time00
1979 ! if (fg_rank.eq.0) then
1980 ! write (iout,*) "Arrays UY and UZ"
1982 ! write (iout,'(i5,3f10.5,5x,3f10.5)') i,(uy(k,i),k=1,3),
1988 end subroutine vec_and_deriv
1989 !-----------------------------------------------------------------------------
1990 subroutine check_vecgrad
1991 ! implicit real*8 (a-h,o-z)
1992 ! include 'DIMENSIONS'
1993 ! include 'COMMON.IOUNITS'
1994 ! include 'COMMON.GEO'
1995 ! include 'COMMON.VAR'
1996 ! include 'COMMON.LOCAL'
1997 ! include 'COMMON.CHAIN'
1998 ! include 'COMMON.VECTORS'
1999 real(kind=8),dimension(3,3,2,nres) :: uygradt,uzgradt !(3,3,2,maxres)
2000 real(kind=8),dimension(3,nres) :: uyt,uzt !(3,maxres)
2001 real(kind=8),dimension(3,3,2) :: uygradn,uzgradn
2002 real(kind=8),dimension(3) :: erij
2003 real(kind=8) :: delta=1.0d-7
2009 !rc write(iout,'(2i5,2(3f10.5,5x))') i,1,dc_norm(:,i)
2010 !rc write(iout,'(2i5,2(3f10.5,5x))') i,2,uy(:,i)
2011 !rc write(iout,'(2i5,2(3f10.5,5x)/)')i,3,uz(:,i)
2012 !d write(iout,'(2i5,2(3f10.5,5x))') i,1,
2013 !d & (dc_norm(if90,i),if90=1,3)
2014 !d write(iout,'(2i5,2(3f10.5,5x))') i,2,(uy(if90,i),if90=1,3)
2015 !d write(iout,'(2i5,2(3f10.5,5x)/)')i,3,(uz(if90,i),if90=1,3)
2016 !d write(iout,'(a)')
2022 uygradt(l,k,j,i)=uygrad(l,k,j,i)
2023 uzgradt(l,k,j,i)=uzgrad(l,k,j,i)
2036 !d write (iout,*) 'i=',i
2038 erij(k)=dc_norm(k,i)
2042 dc_norm(k,i)=erij(k)
2044 dc_norm(j,i)=dc_norm(j,i)+delta
2045 ! fac=dsqrt(scalar(dc_norm(1,i),dc_norm(1,i)))
2047 ! dc_norm(k,i)=dc_norm(k,i)/fac
2049 ! write (iout,*) (dc_norm(k,i),k=1,3)
2050 ! write (iout,*) (erij(k),k=1,3)
2053 uygradn(k,j,1)=(uy(k,i)-uyt(k,i))/delta
2054 uygradn(k,j,2)=(uy(k,i-1)-uyt(k,i-1))/delta
2055 uzgradn(k,j,1)=(uz(k,i)-uzt(k,i))/delta
2056 uzgradn(k,j,2)=(uz(k,i-1)-uzt(k,i-1))/delta
2058 ! write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2059 ! & j,(uzgradt(k,j,1,i),k=1,3),(uzgradn(k,j,1),k=1,3),
2060 ! & (uzgradt(k,j,2,i-1),k=1,3),(uzgradn(k,j,2),k=1,3)
2063 dc_norm(k,i)=erij(k)
2066 !d write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2067 !d & k,(uygradt(k,l,1,i),l=1,3),(uygradn(k,l,1),l=1,3),
2068 !d & (uygradt(k,l,2,i-1),l=1,3),(uygradn(k,l,2),l=1,3)
2069 !d write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2070 !d & k,(uzgradt(k,l,1,i),l=1,3),(uzgradn(k,l,1),l=1,3),
2071 !d & (uzgradt(k,l,2,i-1),l=1,3),(uzgradn(k,l,2),l=1,3)
2072 !d write (iout,'(a)')
2076 end subroutine check_vecgrad
2077 !-----------------------------------------------------------------------------
2078 subroutine set_matrices
2079 ! implicit real*8 (a-h,o-z)
2080 ! include 'DIMENSIONS'
2083 ! include "COMMON.SETUP"
2085 integer :: status(MPI_STATUS_SIZE)
2087 ! include 'COMMON.IOUNITS'
2088 ! include 'COMMON.GEO'
2089 ! include 'COMMON.VAR'
2090 ! include 'COMMON.LOCAL'
2091 ! include 'COMMON.CHAIN'
2092 ! include 'COMMON.DERIV'
2093 ! include 'COMMON.INTERACT'
2094 ! include 'COMMON.CONTACTS'
2095 ! include 'COMMON.TORSION'
2096 ! include 'COMMON.VECTORS'
2097 ! include 'COMMON.FFIELD'
2098 real(kind=8) :: auxvec(2),auxmat(2,2)
2099 integer :: i,iti1,iti,k,l
2100 real(kind=8) :: sin1,cos1,sin2,cos2,dwacos2,dwasin2
2103 ! Compute the virtual-bond-torsional-angle dependent quantities needed
2104 ! to calculate the el-loc multibody terms of various order.
2108 do i=ivec_start+2,ivec_end+2
2112 if (i .lt. nres+1) then
2149 if (i .gt. 3 .and. i .lt. nres+1) then
2150 obrot_der(1,i-2)=-sin1
2151 obrot_der(2,i-2)= cos1
2152 Ugder(1,1,i-2)= sin1
2153 Ugder(1,2,i-2)=-cos1
2154 Ugder(2,1,i-2)=-cos1
2155 Ugder(2,2,i-2)=-sin1
2158 obrot2_der(1,i-2)=-dwasin2
2159 obrot2_der(2,i-2)= dwacos2
2160 Ug2der(1,1,i-2)= dwasin2
2161 Ug2der(1,2,i-2)=-dwacos2
2162 Ug2der(2,1,i-2)=-dwacos2
2163 Ug2der(2,2,i-2)=-dwasin2
2165 obrot_der(1,i-2)=0.0d0
2166 obrot_der(2,i-2)=0.0d0
2167 Ugder(1,1,i-2)=0.0d0
2168 Ugder(1,2,i-2)=0.0d0
2169 Ugder(2,1,i-2)=0.0d0
2170 Ugder(2,2,i-2)=0.0d0
2171 obrot2_der(1,i-2)=0.0d0
2172 obrot2_der(2,i-2)=0.0d0
2173 Ug2der(1,1,i-2)=0.0d0
2174 Ug2der(1,2,i-2)=0.0d0
2175 Ug2der(2,1,i-2)=0.0d0
2176 Ug2der(2,2,i-2)=0.0d0
2178 ! if (i.gt. iatel_s+2 .and. i.lt.iatel_e+5) then
2179 if (i.gt. nnt+2 .and. i.lt.nct+2) then
2180 iti = itortyp(itype(i-2))
2184 ! if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
2185 if (i.gt. nnt+1 .and. i.lt.nct+1) then
2186 iti1 = itortyp(itype(i-1))
2190 !d write (iout,*) '*******i',i,' iti1',iti
2191 !d write (iout,*) 'b1',b1(:,iti)
2192 !d write (iout,*) 'b2',b2(:,iti)
2193 !d write (iout,*) 'Ug',Ug(:,:,i-2)
2194 ! if (i .gt. iatel_s+2) then
2195 if (i .gt. nnt+2) then
2196 call matvec2(Ug(1,1,i-2),b2(1,iti),Ub2(1,i-2))
2197 call matmat2(EE(1,1,iti),Ug(1,1,i-2),EUg(1,1,i-2))
2198 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) &
2200 call matmat2(CC(1,1,iti),Ug(1,1,i-2),CUg(1,1,i-2))
2201 call matmat2(DD(1,1,iti),Ug(1,1,i-2),DUg(1,1,i-2))
2202 call matmat2(Dtilde(1,1,iti),Ug2(1,1,i-2),DtUg2(1,1,i-2))
2203 call matvec2(Ctilde(1,1,iti1),obrot(1,i-2),Ctobr(1,i-2))
2204 call matvec2(Dtilde(1,1,iti),obrot2(1,i-2),Dtobr2(1,i-2))
2215 DtUg2(l,k,i-2)=0.0d0
2219 call matvec2(Ugder(1,1,i-2),b2(1,iti),Ub2der(1,i-2))
2220 call matmat2(EE(1,1,iti),Ugder(1,1,i-2),EUgder(1,1,i-2))
2222 muder(k,i-2)=Ub2der(k,i-2)
2224 ! if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
2225 if (i.gt. nnt+1 .and. i.lt.nct+1) then
2226 if (itype(i-1).le.ntyp) then
2227 iti1 = itortyp(itype(i-1))
2235 mu(k,i-2)=Ub2(k,i-2)+b1(k,iti1)
2237 ! if (energy_dec) write (iout,*) 'Ub2 ',i,Ub2(:,i-2)
2238 ! if (energy_dec) write (iout,*) 'b1 ',iti1,b1(:,iti1)
2239 ! if (energy_dec) write (iout,*) 'mu ',i,iti1,mu(:,i-2)
2240 !d write (iout,*) 'mu1',mu1(:,i-2)
2241 !d write (iout,*) 'mu2',mu2(:,i-2)
2242 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.wcorr6.gt.0.0d0) &
2244 call matmat2(CC(1,1,iti1),Ugder(1,1,i-2),CUgder(1,1,i-2))
2245 call matmat2(DD(1,1,iti),Ugder(1,1,i-2),DUgder(1,1,i-2))
2246 call matmat2(Dtilde(1,1,iti),Ug2der(1,1,i-2),DtUg2der(1,1,i-2))
2247 call matvec2(Ctilde(1,1,iti1),obrot_der(1,i-2),Ctobrder(1,i-2))
2248 call matvec2(Dtilde(1,1,iti),obrot2_der(1,i-2),Dtobr2der(1,i-2))
2249 ! Vectors and matrices dependent on a single virtual-bond dihedral.
2250 call matvec2(DD(1,1,iti),b1tilde(1,iti1),auxvec(1))
2251 call matvec2(Ug2(1,1,i-2),auxvec(1),Ug2Db1t(1,i-2))
2252 call matvec2(Ug2der(1,1,i-2),auxvec(1),Ug2Db1tder(1,i-2))
2253 call matvec2(CC(1,1,iti1),Ub2(1,i-2),CUgb2(1,i-2))
2254 call matvec2(CC(1,1,iti1),Ub2der(1,i-2),CUgb2der(1,i-2))
2255 call matmat2(EUg(1,1,i-2),CC(1,1,iti1),EUgC(1,1,i-2))
2256 call matmat2(EUgder(1,1,i-2),CC(1,1,iti1),EUgCder(1,1,i-2))
2257 call matmat2(EUg(1,1,i-2),DD(1,1,iti1),EUgD(1,1,i-2))
2258 call matmat2(EUgder(1,1,i-2),DD(1,1,iti1),EUgDder(1,1,i-2))
2261 ! Matrices dependent on two consecutive virtual-bond dihedrals.
2262 ! The order of matrices is from left to right.
2263 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.wcorr6.gt.0.0d0) &
2265 ! do i=max0(ivec_start,2),ivec_end
2267 call matmat2(DtUg2(1,1,i-1),EUg(1,1,i),DtUg2EUg(1,1,i))
2268 call matmat2(DtUg2der(1,1,i-1),EUg(1,1,i),DtUg2EUgder(1,1,1,i))
2269 call matmat2(DtUg2(1,1,i-1),EUgder(1,1,i),DtUg2EUgder(1,1,2,i))
2270 call transpose2(DtUg2(1,1,i-1),auxmat(1,1))
2271 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUg(1,1,i))
2272 call matmat2(auxmat(1,1),EUgder(1,1,i),Ug2DtEUgder(1,1,2,i))
2273 call transpose2(DtUg2der(1,1,i-1),auxmat(1,1))
2274 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUgder(1,1,1,i))
2277 #if defined(MPI) && defined(PARMAT)
2279 ! if (fg_rank.eq.0) then
2280 write (iout,*) "Arrays UG and UGDER before GATHER"
2282 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2283 ((ug(l,k,i),l=1,2),k=1,2),&
2284 ((ugder(l,k,i),l=1,2),k=1,2)
2286 write (iout,*) "Arrays UG2 and UG2DER"
2288 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2289 ((ug2(l,k,i),l=1,2),k=1,2),&
2290 ((ug2der(l,k,i),l=1,2),k=1,2)
2292 write (iout,*) "Arrays OBROT OBROT2 OBROTDER and OBROT2DER"
2294 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2295 (obrot(k,i),k=1,2),(obrot2(k,i),k=1,2),&
2296 (obrot_der(k,i),k=1,2),(obrot2_der(k,i),k=1,2)
2298 write (iout,*) "Arrays COSTAB SINTAB COSTAB2 and SINTAB2"
2300 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2301 costab(i),sintab(i),costab2(i),sintab2(i)
2303 write (iout,*) "Array MUDER"
2305 write (iout,'(i5,2f10.5)') i,muder(1,i),muder(2,i)
2309 if (nfgtasks.gt.1) then
2311 ! write(iout,*)"Processor",fg_rank,kolor," ivec_start",ivec_start,
2312 ! & " ivec_displ",(ivec_displ(i),i=0,nfgtasks-1),
2313 ! & " ivec_count",(ivec_count(i),i=0,nfgtasks-1)
2315 call MPI_Allgatherv(Ub2(1,ivec_start),ivec_count(fg_rank1),&
2316 MPI_MU,Ub2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2318 call MPI_Allgatherv(Ub2der(1,ivec_start),ivec_count(fg_rank1),&
2319 MPI_MU,Ub2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2321 call MPI_Allgatherv(mu(1,ivec_start),ivec_count(fg_rank1),&
2322 MPI_MU,mu(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2324 call MPI_Allgatherv(muder(1,ivec_start),ivec_count(fg_rank1),&
2325 MPI_MU,muder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2327 call MPI_Allgatherv(Eug(1,1,ivec_start),ivec_count(fg_rank1),&
2328 MPI_MAT1,Eug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2330 call MPI_Allgatherv(Eugder(1,1,ivec_start),ivec_count(fg_rank1),&
2331 MPI_MAT1,Eugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2333 call MPI_Allgatherv(costab(ivec_start),ivec_count(fg_rank1),&
2334 MPI_DOUBLE_PRECISION,costab(1),ivec_count(0),ivec_displ(0),&
2335 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
2336 call MPI_Allgatherv(sintab(ivec_start),ivec_count(fg_rank1),&
2337 MPI_DOUBLE_PRECISION,sintab(1),ivec_count(0),ivec_displ(0),&
2338 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
2339 call MPI_Allgatherv(costab2(ivec_start),ivec_count(fg_rank1),&
2340 MPI_DOUBLE_PRECISION,costab2(1),ivec_count(0),ivec_displ(0),&
2341 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
2342 call MPI_Allgatherv(sintab2(ivec_start),ivec_count(fg_rank1),&
2343 MPI_DOUBLE_PRECISION,sintab2(1),ivec_count(0),ivec_displ(0),&
2344 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
2345 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) &
2347 call MPI_Allgatherv(Ctobr(1,ivec_start),ivec_count(fg_rank1),&
2348 MPI_MU,Ctobr(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2350 call MPI_Allgatherv(Ctobrder(1,ivec_start),ivec_count(fg_rank1),&
2351 MPI_MU,Ctobrder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2353 call MPI_Allgatherv(Dtobr2(1,ivec_start),ivec_count(fg_rank1),&
2354 MPI_MU,Dtobr2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2356 call MPI_Allgatherv(Dtobr2der(1,ivec_start),ivec_count(fg_rank1),&
2357 MPI_MU,Dtobr2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2359 call MPI_Allgatherv(Ug2Db1t(1,ivec_start),ivec_count(fg_rank1),&
2360 MPI_MU,Ug2Db1t(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2362 call MPI_Allgatherv(Ug2Db1tder(1,ivec_start),&
2363 ivec_count(fg_rank1),&
2364 MPI_MU,Ug2Db1tder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2366 call MPI_Allgatherv(CUgb2(1,ivec_start),ivec_count(fg_rank1),&
2367 MPI_MU,CUgb2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2369 call MPI_Allgatherv(CUgb2der(1,ivec_start),ivec_count(fg_rank1),&
2370 MPI_MU,CUgb2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2372 call MPI_Allgatherv(Cug(1,1,ivec_start),ivec_count(fg_rank1),&
2373 MPI_MAT1,Cug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2375 call MPI_Allgatherv(Cugder(1,1,ivec_start),ivec_count(fg_rank1),&
2376 MPI_MAT1,Cugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2378 call MPI_Allgatherv(Dug(1,1,ivec_start),ivec_count(fg_rank1),&
2379 MPI_MAT1,Dug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2381 call MPI_Allgatherv(Dugder(1,1,ivec_start),ivec_count(fg_rank1),&
2382 MPI_MAT1,Dugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2384 call MPI_Allgatherv(Dtug2(1,1,ivec_start),ivec_count(fg_rank1),&
2385 MPI_MAT1,Dtug2(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2387 call MPI_Allgatherv(Dtug2der(1,1,ivec_start),&
2388 ivec_count(fg_rank1),&
2389 MPI_MAT1,Dtug2der(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2391 call MPI_Allgatherv(EugC(1,1,ivec_start),ivec_count(fg_rank1),&
2392 MPI_MAT1,EugC(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2394 call MPI_Allgatherv(EugCder(1,1,ivec_start),ivec_count(fg_rank1),&
2395 MPI_MAT1,EugCder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2397 call MPI_Allgatherv(EugD(1,1,ivec_start),ivec_count(fg_rank1),&
2398 MPI_MAT1,EugD(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2400 call MPI_Allgatherv(EugDder(1,1,ivec_start),ivec_count(fg_rank1),&
2401 MPI_MAT1,EugDder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2403 call MPI_Allgatherv(DtUg2EUg(1,1,ivec_start),&
2404 ivec_count(fg_rank1),&
2405 MPI_MAT1,DtUg2EUg(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2407 call MPI_Allgatherv(Ug2DtEUg(1,1,ivec_start),&
2408 ivec_count(fg_rank1),&
2409 MPI_MAT1,Ug2DtEUg(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2411 call MPI_Allgatherv(DtUg2EUgder(1,1,1,ivec_start),&
2412 ivec_count(fg_rank1),&
2413 MPI_MAT2,DtUg2EUgder(1,1,1,1),ivec_count(0),ivec_displ(0),&
2414 MPI_MAT2,FG_COMM1,IERR)
2415 call MPI_Allgatherv(Ug2DtEUgder(1,1,1,ivec_start),&
2416 ivec_count(fg_rank1),&
2417 MPI_MAT2,Ug2DtEUgder(1,1,1,1),ivec_count(0),ivec_displ(0),&
2418 MPI_MAT2,FG_COMM1,IERR)
2421 ! Passes matrix info through the ring
2424 if (irecv.lt.0) irecv=nfgtasks1-1
2427 if (inext.ge.nfgtasks1) inext=0
2429 ! write (iout,*) "isend",isend," irecv",irecv
2431 lensend=lentyp(isend)
2432 lenrecv=lentyp(irecv)
2433 ! write (iout,*) "lensend",lensend," lenrecv",lenrecv
2434 ! call MPI_SENDRECV(ug(1,1,ivec_displ(isend)+1),1,
2435 ! & MPI_ROTAT1(lensend),inext,2200+isend,
2436 ! & ug(1,1,ivec_displ(irecv)+1),1,MPI_ROTAT1(lenrecv),
2437 ! & iprev,2200+irecv,FG_COMM,status,IERR)
2438 ! write (iout,*) "Gather ROTAT1"
2440 ! call MPI_SENDRECV(obrot(1,ivec_displ(isend)+1),1,
2441 ! & MPI_ROTAT2(lensend),inext,3300+isend,
2442 ! & obrot(1,ivec_displ(irecv)+1),1,MPI_ROTAT2(lenrecv),
2443 ! & iprev,3300+irecv,FG_COMM,status,IERR)
2444 ! write (iout,*) "Gather ROTAT2"
2446 call MPI_SENDRECV(costab(ivec_displ(isend)+1),1,&
2447 MPI_ROTAT_OLD(lensend),inext,4400+isend,&
2448 costab(ivec_displ(irecv)+1),1,MPI_ROTAT_OLD(lenrecv),&
2449 iprev,4400+irecv,FG_COMM,status,IERR)
2450 ! write (iout,*) "Gather ROTAT_OLD"
2452 call MPI_SENDRECV(mu(1,ivec_displ(isend)+1),1,&
2453 MPI_PRECOMP11(lensend),inext,5500+isend,&
2454 mu(1,ivec_displ(irecv)+1),1,MPI_PRECOMP11(lenrecv),&
2455 iprev,5500+irecv,FG_COMM,status,IERR)
2456 ! write (iout,*) "Gather PRECOMP11"
2458 call MPI_SENDRECV(Eug(1,1,ivec_displ(isend)+1),1,&
2459 MPI_PRECOMP12(lensend),inext,6600+isend,&
2460 Eug(1,1,ivec_displ(irecv)+1),1,MPI_PRECOMP12(lenrecv),&
2461 iprev,6600+irecv,FG_COMM,status,IERR)
2462 ! write (iout,*) "Gather PRECOMP12"
2464 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) &
2466 call MPI_SENDRECV(ug2db1t(1,ivec_displ(isend)+1),1,&
2467 MPI_ROTAT2(lensend),inext,7700+isend,&
2468 ug2db1t(1,ivec_displ(irecv)+1),1,MPI_ROTAT2(lenrecv),&
2469 iprev,7700+irecv,FG_COMM,status,IERR)
2470 ! write (iout,*) "Gather PRECOMP21"
2472 call MPI_SENDRECV(EUgC(1,1,ivec_displ(isend)+1),1,&
2473 MPI_PRECOMP22(lensend),inext,8800+isend,&
2474 EUgC(1,1,ivec_displ(irecv)+1),1,MPI_PRECOMP22(lenrecv),&
2475 iprev,8800+irecv,FG_COMM,status,IERR)
2476 ! write (iout,*) "Gather PRECOMP22"
2478 call MPI_SENDRECV(Ug2DtEUgder(1,1,1,ivec_displ(isend)+1),1,&
2479 MPI_PRECOMP23(lensend),inext,9900+isend,&
2480 Ug2DtEUgder(1,1,1,ivec_displ(irecv)+1),1,&
2481 MPI_PRECOMP23(lenrecv),&
2482 iprev,9900+irecv,FG_COMM,status,IERR)
2483 ! write (iout,*) "Gather PRECOMP23"
2488 if (irecv.lt.0) irecv=nfgtasks1-1
2491 time_gather=time_gather+MPI_Wtime()-time00
2494 ! if (fg_rank.eq.0) then
2495 write (iout,*) "Arrays UG and UGDER"
2497 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2498 ((ug(l,k,i),l=1,2),k=1,2),&
2499 ((ugder(l,k,i),l=1,2),k=1,2)
2501 write (iout,*) "Arrays UG2 and UG2DER"
2503 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2504 ((ug2(l,k,i),l=1,2),k=1,2),&
2505 ((ug2der(l,k,i),l=1,2),k=1,2)
2507 write (iout,*) "Arrays OBROT OBROT2 OBROTDER and OBROT2DER"
2509 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2510 (obrot(k,i),k=1,2),(obrot2(k,i),k=1,2),&
2511 (obrot_der(k,i),k=1,2),(obrot2_der(k,i),k=1,2)
2513 write (iout,*) "Arrays COSTAB SINTAB COSTAB2 and SINTAB2"
2515 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2516 costab(i),sintab(i),costab2(i),sintab2(i)
2518 write (iout,*) "Array MUDER"
2520 write (iout,'(i5,2f10.5)') i,muder(1,i),muder(2,i)
2526 !d iti = itortyp(itype(i))
2529 !d write (iout,'(2f10.5,5x,2f10.5,5x,2f10.5)')
2530 !d & (EE(j,k,iti),k=1,2),(Ug(j,k,i),k=1,2),(EUg(j,k,i),k=1,2)
2534 end subroutine set_matrices
2535 !-----------------------------------------------------------------------------
2536 subroutine eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
2538 ! This subroutine calculates the average interaction energy and its gradient
2539 ! in the virtual-bond vectors between non-adjacent peptide groups, based on
2540 ! the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
2541 ! The potential depends both on the distance of peptide-group centers and on
2542 ! the orientation of the CA-CA virtual bonds.
2545 ! implicit real*8 (a-h,o-z)
2549 ! include 'DIMENSIONS'
2550 ! include 'COMMON.CONTROL'
2551 ! include 'COMMON.SETUP'
2552 ! include 'COMMON.IOUNITS'
2553 ! include 'COMMON.GEO'
2554 ! include 'COMMON.VAR'
2555 ! include 'COMMON.LOCAL'
2556 ! include 'COMMON.CHAIN'
2557 ! include 'COMMON.DERIV'
2558 ! include 'COMMON.INTERACT'
2559 ! include 'COMMON.CONTACTS'
2560 ! include 'COMMON.TORSION'
2561 ! include 'COMMON.VECTORS'
2562 ! include 'COMMON.FFIELD'
2563 ! include 'COMMON.TIME1'
2564 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg
2565 real(kind=8),dimension(3,3) :: erder,uryg,urzg,vryg,vrzg
2566 real(kind=8),dimension(2,2) :: acipa !el,a_temp
2567 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
2568 real(kind=8),dimension(4) :: muij
2569 !el integer :: num_conti,j1,j2
2570 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
2571 !el dz_normi,xmedi,ymedi,zmedi
2573 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
2574 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
2577 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
2579 real(kind=8) :: scal_el=1.0d0
2581 real(kind=8) :: scal_el=0.5d0
2584 ! 13-go grudnia roku pamietnego...
2585 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
2587 0.0d0,0.0d0,1.0d0/),shape(unmat))
2590 real(kind=8) :: ees,evdw1,eel_loc,eello_turn3,eello_turn4
2591 real(kind=8) :: fac,t_eelecij
2594 !d write(iout,*) 'In EELEC'
2596 !d write(iout,*) 'Type',i
2597 !d write(iout,*) 'B1',B1(:,i)
2598 !d write(iout,*) 'B2',B2(:,i)
2599 !d write(iout,*) 'CC',CC(:,:,i)
2600 !d write(iout,*) 'DD',DD(:,:,i)
2601 !d write(iout,*) 'EE',EE(:,:,i)
2603 !d call check_vecgrad
2618 if (icheckgrad.eq.1) then
2621 ! dc_norm(1,i)=0.0d0
2622 ! dc_norm(2,i)=0.0d0
2623 ! dc_norm(3,i)=0.0d0
2626 fac=1.0d0/dsqrt(scalar(dc(1,i),dc(1,i)))
2628 dc_norm(k,i)=dc(k,i)*fac
2630 ! write (iout,*) 'i',i,' fac',fac
2633 if (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
2634 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 .or. &
2635 wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) then
2636 ! call vec_and_deriv
2642 time_mat=time_mat+MPI_Wtime()-time01
2646 !d write (iout,*) 'i=',i
2648 !d write (iout,'(i5,2f10.5)') k,uy(k,i),uz(k,i)
2651 !d write (iout,'(f10.5,2x,3f10.5,2x,3f10.5)')
2652 !d & uz(k,i),(uzgrad(k,l,1,i),l=1,3),(uzgrad(k,l,2,i),l=1,3)
2665 !d print '(a)','Enter EELEC'
2666 !d write (iout,*) 'iatel_s=',iatel_s,' iatel_e=',iatel_e
2667 ! if (.not.allocated(gel_loc_loc)) allocate(gel_loc_loc(nres)) !(maxvar)(maxvar=6*maxres)
2668 ! if (.not.allocated(gcorr_loc)) allocate(gcorr_loc(nres)) !(maxvar)(maxvar=6*maxres)
2670 gel_loc_loc(i)=0.0d0
2675 ! 9/27/08 AL Split the interaction loop to ensure load balancing of turn terms
2677 ! Loop over i,i+2 and i,i+3 pairs of the peptide groups
2682 do i=iturn3_start,iturn3_end
2683 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1 &
2684 .or. itype(i+2).eq.ntyp1 .or. itype(i+3).eq.ntyp1) cycle
2688 dx_normi=dc_norm(1,i)
2689 dy_normi=dc_norm(2,i)
2690 dz_normi=dc_norm(3,i)
2691 xmedi=c(1,i)+0.5d0*dxi
2692 ymedi=c(2,i)+0.5d0*dyi
2693 zmedi=c(3,i)+0.5d0*dzi
2694 xmedi=dmod(xmedi,boxxsize)
2695 if (xmedi.lt.0) xmedi=xmedi+boxxsize
2696 ymedi=dmod(ymedi,boxysize)
2697 if (ymedi.lt.0) ymedi=ymedi+boxysize
2698 zmedi=dmod(zmedi,boxzsize)
2699 if (zmedi.lt.0) zmedi=zmedi+boxzsize
2701 call eelecij(i,i+2,ees,evdw1,eel_loc)
2702 if (wturn3.gt.0.0d0) call eturn3(i,eello_turn3)
2703 num_cont_hb(i)=num_conti
2705 do i=iturn4_start,iturn4_end
2706 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1 &
2707 .or. itype(i+3).eq.ntyp1 &
2708 .or. itype(i+4).eq.ntyp1) cycle
2712 dx_normi=dc_norm(1,i)
2713 dy_normi=dc_norm(2,i)
2714 dz_normi=dc_norm(3,i)
2715 xmedi=c(1,i)+0.5d0*dxi
2716 ymedi=c(2,i)+0.5d0*dyi
2717 zmedi=c(3,i)+0.5d0*dzi
2718 xmedi=dmod(xmedi,boxxsize)
2719 if (xmedi.lt.0) xmedi=xmedi+boxxsize
2720 ymedi=dmod(ymedi,boxysize)
2721 if (ymedi.lt.0) ymedi=ymedi+boxysize
2722 zmedi=dmod(zmedi,boxzsize)
2723 if (zmedi.lt.0) zmedi=zmedi+boxzsize
2724 num_conti=num_cont_hb(i)
2725 call eelecij(i,i+3,ees,evdw1,eel_loc)
2726 if (wturn4.gt.0.0d0 .and. itype(i+2).ne.ntyp1) &
2727 call eturn4(i,eello_turn4)
2728 num_cont_hb(i)=num_conti
2731 ! Loop over all pairs of interacting peptide groups except i,i+2 and i,i+3
2733 do i=iatel_s,iatel_e
2734 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1) cycle
2738 dx_normi=dc_norm(1,i)
2739 dy_normi=dc_norm(2,i)
2740 dz_normi=dc_norm(3,i)
2741 xmedi=c(1,i)+0.5d0*dxi
2742 ymedi=c(2,i)+0.5d0*dyi
2743 zmedi=c(3,i)+0.5d0*dzi
2744 xmedi=dmod(xmedi,boxxsize)
2745 if (xmedi.lt.0) xmedi=xmedi+boxxsize
2746 ymedi=dmod(ymedi,boxysize)
2747 if (ymedi.lt.0) ymedi=ymedi+boxysize
2748 zmedi=dmod(zmedi,boxzsize)
2749 if (zmedi.lt.0) zmedi=zmedi+boxzsize
2751 ! write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
2752 num_conti=num_cont_hb(i)
2753 do j=ielstart(i),ielend(i)
2754 ! write (iout,*) i,j,itype(i),itype(j)
2755 if (itype(j).eq.ntyp1.or. itype(j+1).eq.ntyp1) cycle
2756 call eelecij(i,j,ees,evdw1,eel_loc)
2758 num_cont_hb(i)=num_conti
2760 ! write (iout,*) "Number of loop steps in EELEC:",ind
2762 !d write (iout,'(i3,3f10.5,5x,3f10.5)')
2763 !d & i,(gel_loc(k,i),k=1,3),gel_loc_loc(i)
2765 ! 12/7/99 Adam eello_turn3 will be considered as a separate energy term
2766 !cc eel_loc=eel_loc+eello_turn3
2767 !d print *,"Processor",fg_rank," t_eelecij",t_eelecij
2769 end subroutine eelec
2770 !-----------------------------------------------------------------------------
2771 subroutine eelecij(i,j,ees,evdw1,eel_loc)
2774 ! implicit real*8 (a-h,o-z)
2775 ! include 'DIMENSIONS'
2779 ! include 'COMMON.CONTROL'
2780 ! include 'COMMON.IOUNITS'
2781 ! include 'COMMON.GEO'
2782 ! include 'COMMON.VAR'
2783 ! include 'COMMON.LOCAL'
2784 ! include 'COMMON.CHAIN'
2785 ! include 'COMMON.DERIV'
2786 ! include 'COMMON.INTERACT'
2787 ! include 'COMMON.CONTACTS'
2788 ! include 'COMMON.TORSION'
2789 ! include 'COMMON.VECTORS'
2790 ! include 'COMMON.FFIELD'
2791 ! include 'COMMON.TIME1'
2792 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg,xtemp
2793 real(kind=8),dimension(3,3) :: erder,uryg,urzg,vryg,vrzg
2794 real(kind=8),dimension(2,2) :: acipa !el,a_temp
2795 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
2796 real(kind=8),dimension(4) :: muij
2797 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
2798 dist_temp, dist_init
2799 integer xshift,yshift,zshift
2800 !el integer :: num_conti,j1,j2
2801 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
2802 !el dz_normi,xmedi,ymedi,zmedi
2804 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
2805 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
2808 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
2810 real(kind=8) :: scal_el=1.0d0
2812 real(kind=8) :: scal_el=0.5d0
2815 ! 13-go grudnia roku pamietnego...
2816 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
2818 0.0d0,0.0d0,1.0d0/),shape(unmat))
2819 ! integer :: maxconts=nres/4
2821 integer :: k,i,j,iteli,itelj,kkk,l,kkll,m,isubchap
2822 real(kind=8) :: ael6i,rrmij,rmij,r0ij,fcont,fprimcont,ees0tmp
2823 real(kind=8) :: ees,evdw1,eel_loc,aaa,bbb,ael3i
2824 real(kind=8) :: dxj,dyj,dzj,dx_normj,dy_normj,dz_normj,xj,yj,zj,&
2825 rij,r3ij,r6ij,cosa,cosb,cosg,fac,ev1,ev2,fac3,fac4,&
2826 evdwij,el1,el2,eesij,ees0ij,facvdw,facel,fac1,ecosa,&
2827 ecosb,ecosg,ury,urz,vry,vrz,facr,a22der,a23der,a32der,&
2828 a33der,eel_loc_ij,cosa4,wij,cosbg1,cosbg2,ees0pij,&
2829 ees0pij1,ees0mij,ees0mij1,fac3p,ees0mijp,ees0pijp,&
2830 ecosa1,ecosb1,ecosg1,ecosa2,ecosb2,ecosg2,ecosap,ecosbp,&
2831 ecosgp,ecosam,ecosbm,ecosgm,ghalf
2833 ! allocate(a_chuj(2,2,maxconts,nres)) !(2,2,maxconts,maxres)
2834 ! allocate(a_chuj_der(2,2,3,5,maxconts,nres)) !(2,2,3,5,maxconts,maxres)
2836 ! time00=MPI_Wtime()
2837 !d write (iout,*) "eelecij",i,j
2841 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
2842 aaa=app(iteli,itelj)
2843 bbb=bpp(iteli,itelj)
2844 ael6i=ael6(iteli,itelj)
2845 ael3i=ael3(iteli,itelj)
2849 dx_normj=dc_norm(1,j)
2850 dy_normj=dc_norm(2,j)
2851 dz_normj=dc_norm(3,j)
2852 ! xj=c(1,j)+0.5D0*dxj-xmedi
2853 ! yj=c(2,j)+0.5D0*dyj-ymedi
2854 ! zj=c(3,j)+0.5D0*dzj-zmedi
2859 if (xj.lt.0) xj=xj+boxxsize
2861 if (yj.lt.0) yj=yj+boxysize
2863 if (zj.lt.0) zj=zj+boxzsize
2865 dist_init=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
2872 xj=xj_safe+xshift*boxxsize
2873 yj=yj_safe+yshift*boxysize
2874 zj=zj_safe+zshift*boxzsize
2875 dist_temp=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
2876 if(dist_temp.lt.dist_init) then
2886 if (isubchap.eq.1) then
2897 rij=xj*xj+yj*yj+zj*zj
2900 !C print *,xmedi,ymedi,zmedi,xj,yj,zj,boxxsize,rij
2901 sss_ele_cut=sscale_ele(rij)
2902 sss_ele_grad=sscagrad_ele(rij)
2904 ! sss_ele_grad=0.0d0
2905 ! print *,sss_ele_cut,sss_ele_grad,&
2906 ! (rij),r_cut_ele,rlamb_ele
2907 ! if (sss_ele_cut.le.0.0) go to 128
2912 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
2913 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
2914 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
2915 fac=cosa-3.0D0*cosb*cosg
2917 ! 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
2918 if (j.eq.i+2) ev1=scal_el*ev1
2923 el1=fac3*(4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg))
2926 ! 12/26/95 - for the evaluation of multi-body H-bonding interactions
2927 ees0ij=4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg)
2928 ees=ees+eesij*sss_ele_cut
2929 evdw1=evdw1+evdwij*sss_ele_cut
2930 !d write(iout,'(2(2i3,2x),7(1pd12.4)/2(3(1pd12.4),5x)/)')
2931 !d & iteli,i,itelj,j,aaa,bbb,ael6i,ael3i,
2932 !d & 1.0D0/dsqrt(rrmij),evdwij,eesij,
2933 !d & xmedi,ymedi,zmedi,xj,yj,zj
2935 if (energy_dec) then
2936 ! write (iout,'(a6,2i5,0pf7.3,2i5,2e11.3)') &
2937 ! 'evdw1',i,j,evdwij,&
2938 ! iteli,itelj,aaa,evdw1
2939 write (iout,'(a6,2i5,0pf7.3)') 'evdw1',i,j,evdwij
2940 write (iout,'(a6,2i5,0pf7.3)') 'ees',i,j,eesij
2943 ! Calculate contributions to the Cartesian gradient.
2946 facvdw=-6*rrmij*(ev1+evdwij)*sss_ele_cut
2947 facel=-3*rrmij*(el1+eesij)*sss_ele_cut
2953 ! Radial derivatives. First process both termini of the fragment (i,j)
2955 ggg(1)=facel*xj+sss_ele_grad*rmij*eesij*xj
2956 ggg(2)=facel*yj+sss_ele_grad*rmij*eesij*yj
2957 ggg(3)=facel*zj+sss_ele_grad*rmij*eesij*zj
2960 ! ghalf=0.5D0*ggg(k)
2961 ! gelc(k,i)=gelc(k,i)+ghalf
2962 ! gelc(k,j)=gelc(k,j)+ghalf
2964 ! 9/28/08 AL Gradient compotents will be summed only at the end
2966 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
2967 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
2970 ! Loop over residues i+1 thru j-1.
2974 !grad gelc(l,k)=gelc(l,k)+ggg(l)
2977 ggg(1)=facvdw*xj+sss_ele_grad*rmij*evdwij*xj
2978 ggg(2)=facvdw*yj+sss_ele_grad*rmij*evdwij*yj
2979 ggg(3)=facvdw*zj+sss_ele_grad*rmij*evdwij*zj
2981 ! ghalf=0.5D0*ggg(k)
2982 ! gvdwpp(k,i)=gvdwpp(k,i)+ghalf
2983 ! gvdwpp(k,j)=gvdwpp(k,j)+ghalf
2985 ! 9/28/08 AL Gradient compotents will be summed only at the end
2987 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
2988 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
2991 ! Loop over residues i+1 thru j-1.
2995 !grad gvdwpp(l,k)=gvdwpp(l,k)+ggg(l)
2999 facvdw=(ev1+evdwij)*sss_ele_cut
3000 facel=(el1+eesij)*sss_ele_cut
3002 fac=-3*rrmij*(facvdw+facvdw+facel)
3007 ! Radial derivatives. First process both termini of the fragment (i,j)
3009 ggg(1)=fac*xj+sss_ele_grad*rmij*(eesij+evdwij)*xj
3010 ggg(2)=fac*yj+sss_ele_grad*rmij*(eesij+evdwij)*yj
3011 ggg(3)=fac*zj+sss_ele_grad*rmij*(eesij+evdwij)*zj
3013 ! ghalf=0.5D0*ggg(k)
3014 ! gelc(k,i)=gelc(k,i)+ghalf
3015 ! gelc(k,j)=gelc(k,j)+ghalf
3017 ! 9/28/08 AL Gradient compotents will be summed only at the end
3019 gelc_long(k,j)=gelc(k,j)+ggg(k)
3020 gelc_long(k,i)=gelc(k,i)-ggg(k)
3023 ! Loop over residues i+1 thru j-1.
3027 !grad gelc(l,k)=gelc(l,k)+ggg(l)
3030 ! 9/28/08 AL Gradient compotents will be summed only at the end
3035 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
3036 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
3042 ecosa=2.0D0*fac3*fac1+fac4
3045 ecosb=(fac3*(fac1*cosg+cosb)+cosg*fac4)
3046 ecosg=(fac3*(fac1*cosb+cosg)+cosb*fac4)
3048 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
3049 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
3051 !d print '(2i3,2(3(1pd14.5),3x))',i,j,(dcosb(k),k=1,3),
3052 !d & (dcosg(k),k=1,3)
3054 ggg(k)=(ecosb*dcosb(k)+ecosg*dcosg(k))*sss_ele_cut
3057 ! ghalf=0.5D0*ggg(k)
3058 ! gelc(k,i)=gelc(k,i)+ghalf
3059 ! & +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
3060 ! & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
3061 ! gelc(k,j)=gelc(k,j)+ghalf
3062 ! & +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
3063 ! & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
3067 !grad gelc(l,k)=gelc(l,k)+ggg(l)
3071 gelc(k,i)=gelc(k,i) &
3072 +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
3073 + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)&
3075 gelc(k,j)=gelc(k,j) &
3076 +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
3077 + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
3079 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
3080 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
3083 IF (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
3084 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 &
3085 .or. wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
3087 ! 9/25/99 Mixed third-order local-electrostatic terms. The local-interaction
3088 ! energy of a peptide unit is assumed in the form of a second-order
3089 ! Fourier series in the angles lambda1 and lambda2 (see Nishikawa et al.
3090 ! Macromolecules, 1974, 7, 797-806 for definition). This correlation terms
3091 ! are computed for EVERY pair of non-contiguous peptide groups.
3093 if (j.lt.nres-1) then
3104 muij(kkk)=mu(k,i)*mu(l,j)
3107 !d write (iout,*) 'EELEC: i',i,' j',j
3108 !d write (iout,*) 'j',j,' j1',j1,' j2',j2
3109 !d write(iout,*) 'muij',muij
3110 ury=scalar(uy(1,i),erij)
3111 urz=scalar(uz(1,i),erij)
3112 vry=scalar(uy(1,j),erij)
3113 vrz=scalar(uz(1,j),erij)
3114 a22=scalar(uy(1,i),uy(1,j))-3*ury*vry
3115 a23=scalar(uy(1,i),uz(1,j))-3*ury*vrz
3116 a32=scalar(uz(1,i),uy(1,j))-3*urz*vry
3117 a33=scalar(uz(1,i),uz(1,j))-3*urz*vrz
3118 fac=dsqrt(-ael6i)*r3ij
3123 !d write (iout,'(4i5,4f10.5)')
3124 !d & i,itortyp(itype(i)),j,itortyp(itype(j)),a22,a23,a32,a33
3125 !d write (iout,'(6f10.5)') (muij(k),k=1,4),fac,eel_loc_ij
3126 !d write (iout,'(2(3f10.5,5x)/2(3f10.5,5x))') uy(:,i),uz(:,i),
3127 !d & uy(:,j),uz(:,j)
3128 !d write (iout,'(4f10.5)')
3129 !d & scalar(uy(1,i),uy(1,j)),scalar(uy(1,i),uz(1,j)),
3130 !d & scalar(uz(1,i),uy(1,j)),scalar(uz(1,i),uz(1,j))
3131 !d write (iout,'(4f10.5)') ury,urz,vry,vrz
3132 !d write (iout,'(9f10.5/)')
3133 !d & fac22,a22,fac23,a23,fac32,a32,fac33,a33,eel_loc_ij
3134 ! Derivatives of the elements of A in virtual-bond vectors
3135 call unormderiv(erij(1),unmat(1,1),rmij,erder(1,1))
3137 uryg(k,1)=scalar(erder(1,k),uy(1,i))
3138 uryg(k,2)=scalar(uygrad(1,k,1,i),erij(1))
3139 uryg(k,3)=scalar(uygrad(1,k,2,i),erij(1))
3140 urzg(k,1)=scalar(erder(1,k),uz(1,i))
3141 urzg(k,2)=scalar(uzgrad(1,k,1,i),erij(1))
3142 urzg(k,3)=scalar(uzgrad(1,k,2,i),erij(1))
3143 vryg(k,1)=scalar(erder(1,k),uy(1,j))
3144 vryg(k,2)=scalar(uygrad(1,k,1,j),erij(1))
3145 vryg(k,3)=scalar(uygrad(1,k,2,j),erij(1))
3146 vrzg(k,1)=scalar(erder(1,k),uz(1,j))
3147 vrzg(k,2)=scalar(uzgrad(1,k,1,j),erij(1))
3148 vrzg(k,3)=scalar(uzgrad(1,k,2,j),erij(1))
3150 ! Compute radial contributions to the gradient
3168 ! Add the contributions coming from er
3171 agg(k,1)=agg(k,1)+fac3*(uryg(k,1)*vry+vryg(k,1)*ury)
3172 agg(k,2)=agg(k,2)+fac3*(uryg(k,1)*vrz+vrzg(k,1)*ury)
3173 agg(k,3)=agg(k,3)+fac3*(urzg(k,1)*vry+vryg(k,1)*urz)
3174 agg(k,4)=agg(k,4)+fac3*(urzg(k,1)*vrz+vrzg(k,1)*urz)
3177 ! Derivatives in DC(i)
3178 !grad ghalf1=0.5d0*agg(k,1)
3179 !grad ghalf2=0.5d0*agg(k,2)
3180 !grad ghalf3=0.5d0*agg(k,3)
3181 !grad ghalf4=0.5d0*agg(k,4)
3182 aggi(k,1)=fac*(scalar(uygrad(1,k,1,i),uy(1,j)) &
3183 -3.0d0*uryg(k,2)*vry)!+ghalf1
3184 aggi(k,2)=fac*(scalar(uygrad(1,k,1,i),uz(1,j)) &
3185 -3.0d0*uryg(k,2)*vrz)!+ghalf2
3186 aggi(k,3)=fac*(scalar(uzgrad(1,k,1,i),uy(1,j)) &
3187 -3.0d0*urzg(k,2)*vry)!+ghalf3
3188 aggi(k,4)=fac*(scalar(uzgrad(1,k,1,i),uz(1,j)) &
3189 -3.0d0*urzg(k,2)*vrz)!+ghalf4
3190 ! Derivatives in DC(i+1)
3191 aggi1(k,1)=fac*(scalar(uygrad(1,k,2,i),uy(1,j)) &
3192 -3.0d0*uryg(k,3)*vry)!+agg(k,1)
3193 aggi1(k,2)=fac*(scalar(uygrad(1,k,2,i),uz(1,j)) &
3194 -3.0d0*uryg(k,3)*vrz)!+agg(k,2)
3195 aggi1(k,3)=fac*(scalar(uzgrad(1,k,2,i),uy(1,j)) &
3196 -3.0d0*urzg(k,3)*vry)!+agg(k,3)
3197 aggi1(k,4)=fac*(scalar(uzgrad(1,k,2,i),uz(1,j)) &
3198 -3.0d0*urzg(k,3)*vrz)!+agg(k,4)
3199 ! Derivatives in DC(j)
3200 aggj(k,1)=fac*(scalar(uygrad(1,k,1,j),uy(1,i)) &
3201 -3.0d0*vryg(k,2)*ury)!+ghalf1
3202 aggj(k,2)=fac*(scalar(uzgrad(1,k,1,j),uy(1,i)) &
3203 -3.0d0*vrzg(k,2)*ury)!+ghalf2
3204 aggj(k,3)=fac*(scalar(uygrad(1,k,1,j),uz(1,i)) &
3205 -3.0d0*vryg(k,2)*urz)!+ghalf3
3206 aggj(k,4)=fac*(scalar(uzgrad(1,k,1,j),uz(1,i)) &
3207 -3.0d0*vrzg(k,2)*urz)!+ghalf4
3208 ! Derivatives in DC(j+1) or DC(nres-1)
3209 aggj1(k,1)=fac*(scalar(uygrad(1,k,2,j),uy(1,i)) &
3210 -3.0d0*vryg(k,3)*ury)
3211 aggj1(k,2)=fac*(scalar(uzgrad(1,k,2,j),uy(1,i)) &
3212 -3.0d0*vrzg(k,3)*ury)
3213 aggj1(k,3)=fac*(scalar(uygrad(1,k,2,j),uz(1,i)) &
3214 -3.0d0*vryg(k,3)*urz)
3215 aggj1(k,4)=fac*(scalar(uzgrad(1,k,2,j),uz(1,i)) &
3216 -3.0d0*vrzg(k,3)*urz)
3217 !grad if (j.eq.nres-1 .and. i.lt.j-2) then
3219 !grad aggj1(k,l)=aggj1(k,l)+agg(k,l)
3232 aggi(k,l)=-aggi(k,l)
3233 aggi1(k,l)=-aggi1(k,l)
3234 aggj(k,l)=-aggj(k,l)
3235 aggj1(k,l)=-aggj1(k,l)
3238 if (j.lt.nres-1) then
3244 aggi(k,l)=-aggi(k,l)
3245 aggi1(k,l)=-aggi1(k,l)
3246 aggj(k,l)=-aggj(k,l)
3247 aggj1(k,l)=-aggj1(k,l)
3258 aggi(k,l)=-aggi(k,l)
3259 aggi1(k,l)=-aggi1(k,l)
3260 aggj(k,l)=-aggj(k,l)
3261 aggj1(k,l)=-aggj1(k,l)
3266 IF (wel_loc.gt.0.0d0) THEN
3267 ! Contribution to the local-electrostatic energy coming from the i-j pair
3268 eel_loc_ij=a22*muij(1)+a23*muij(2)+a32*muij(3) &
3270 ! write (iout,*) 'i',i,' j',j,' eel_loc_ij',eel_loc_ij
3272 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
3273 'eelloc',i,j,eel_loc_ij
3274 ! if (energy_dec) write (iout,*) "a22",a22," a23",a23," a32",a32," a33",a33
3275 ! if (energy_dec) write (iout,*) "muij",muij
3276 ! write (iout,*) a22,muij(1),a23,muij(2),a32,muij(3)
3278 eel_loc=eel_loc+eel_loc_ij*sss_ele_cut
3279 ! Partial derivatives in virtual-bond dihedral angles gamma
3281 gel_loc_loc(i-1)=gel_loc_loc(i-1)+ &
3282 (a22*muder(1,i)*mu(1,j)+a23*muder(1,i)*mu(2,j) &
3283 +a32*muder(2,i)*mu(1,j)+a33*muder(2,i)*mu(2,j)) &
3285 gel_loc_loc(j-1)=gel_loc_loc(j-1)+ &
3286 (a22*mu(1,i)*muder(1,j)+a23*mu(1,i)*muder(2,j) &
3287 +a32*mu(2,i)*muder(1,j)+a33*mu(2,i)*muder(2,j)) &
3289 ! Derivatives of eello in DC(i+1) thru DC(j-1) or DC(nres-2)
3291 ! ggg(1)=(agg(1,1)*muij(1)+ &
3292 ! agg(1,2)*muij(2)+agg(1,3)*muij(3)+agg(1,4)*muij(4)) &
3294 ! +eel_loc_ij*sss_ele_grad*rmij*xj
3295 ! ggg(2)=(agg(2,1)*muij(1)+ &
3296 ! agg(2,2)*muij(2)+agg(2,3)*muij(3)+agg(2,4)*muij(4)) &
3298 ! +eel_loc_ij*sss_ele_grad*rmij*yj
3299 ! ggg(3)=(agg(3,1)*muij(1)+ &
3300 ! agg(3,2)*muij(2)+agg(3,3)*muij(3)+agg(3,4)*muij(4)) &
3302 ! +eel_loc_ij*sss_ele_grad*rmij*zj
3308 ggg(l)=(agg(l,1)*muij(1)+ &
3309 agg(l,2)*muij(2)+agg(l,3)*muij(3)+agg(l,4)*muij(4))&
3311 +eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
3313 gel_loc_long(l,j)=gel_loc_long(l,j)+ggg(l)
3314 gel_loc_long(l,i)=gel_loc_long(l,i)-ggg(l)
3315 !grad ghalf=0.5d0*ggg(l)
3316 !grad gel_loc(l,i)=gel_loc(l,i)+ghalf
3317 !grad gel_loc(l,j)=gel_loc(l,j)+ghalf
3321 !grad gel_loc(l,k)=gel_loc(l,k)+ggg(l)
3324 ! Remaining derivatives of eello
3326 gel_loc(l,i)=gel_loc(l,i)+(aggi(l,1)*muij(1)+ &
3327 aggi(l,2)*muij(2)+aggi(l,3)*muij(3)+aggi(l,4)*muij(4))&
3329 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
3330 gel_loc(l,i+1)=gel_loc(l,i+1)+(aggi1(l,1)*muij(1)+ &
3331 aggi1(l,2)*muij(2)+aggi1(l,3)*muij(3) &
3332 +aggi1(l,4)*muij(4))&
3334 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
3335 gel_loc(l,j)=gel_loc(l,j)+(aggj(l,1)*muij(1)+ &
3336 aggj(l,2)*muij(2)+aggj(l,3)*muij(3)+aggj(l,4)*muij(4))&
3338 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
3339 gel_loc(l,j1)=gel_loc(l,j1)+(aggj1(l,1)*muij(1)+ &
3340 aggj1(l,2)*muij(2)+aggj1(l,3)*muij(3) &
3341 +aggj1(l,4)*muij(4))&
3343 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
3346 ! Change 12/26/95 to calculate four-body contributions to H-bonding energy
3347 ! if (j.gt.i+1 .and. num_conti.le.maxconts) then
3348 if (wcorr+wcorr4+wcorr5+wcorr6.gt.0.0d0 &
3349 .and. num_conti.le.maxconts) then
3350 ! write (iout,*) i,j," entered corr"
3352 ! Calculate the contact function. The ith column of the array JCONT will
3353 ! contain the numbers of atoms that make contacts with the atom I (of numbers
3354 ! greater than I). The arrays FACONT and GACONT will contain the values of
3355 ! the contact function and its derivative.
3356 ! r0ij=1.02D0*rpp(iteli,itelj)
3357 ! r0ij=1.11D0*rpp(iteli,itelj)
3358 r0ij=2.20D0*rpp(iteli,itelj)
3359 ! r0ij=1.55D0*rpp(iteli,itelj)
3360 call gcont(rij,r0ij,1.0D0,0.2d0*r0ij,fcont,fprimcont)
3361 !elwrite(iout,*) "num_conti",num_conti, "maxconts",maxconts
3362 if (fcont.gt.0.0D0) then
3363 num_conti=num_conti+1
3364 if (num_conti.gt.maxconts) then
3365 !el write (iout,*) "esrgresgdsrgdfsrgdswrgaresfgaerwgae"
3366 !el write (iout,*) "num_conti",num_conti, "maxconts",maxconts
3367 write (iout,*) 'WARNING - max. # of contacts exceeded;',&
3368 ' will skip next contacts for this conf.', num_conti
3370 jcont_hb(num_conti,i)=j
3371 !d write (iout,*) "i",i," j",j," num_conti",num_conti,
3372 !d & " jcont_hb",jcont_hb(num_conti,i)
3373 IF (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. &
3374 wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
3375 ! 9/30/99 (AL) - store components necessary to evaluate higher-order loc-el
3377 d_cont(num_conti,i)=rij
3378 !d write (2,'(3e15.5)') rij,r0ij+0.2d0*r0ij,rij
3379 ! --- Electrostatic-interaction matrix ---
3380 a_chuj(1,1,num_conti,i)=a22
3381 a_chuj(1,2,num_conti,i)=a23
3382 a_chuj(2,1,num_conti,i)=a32
3383 a_chuj(2,2,num_conti,i)=a33
3384 ! --- Gradient of rij
3386 grij_hb_cont(kkk,num_conti,i)=erij(kkk)
3393 a_chuj_der(k,l,m,1,num_conti,i)=agg(m,kkll)
3394 a_chuj_der(k,l,m,2,num_conti,i)=aggi(m,kkll)
3395 a_chuj_der(k,l,m,3,num_conti,i)=aggi1(m,kkll)
3396 a_chuj_der(k,l,m,4,num_conti,i)=aggj(m,kkll)
3397 a_chuj_der(k,l,m,5,num_conti,i)=aggj1(m,kkll)
3402 IF (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) THEN
3403 ! Calculate contact energies
3405 wij=cosa-3.0D0*cosb*cosg
3408 ! fac3=dsqrt(-ael6i)/r0ij**3
3409 fac3=dsqrt(-ael6i)*r3ij
3410 ! ees0pij=dsqrt(4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1)
3411 ees0tmp=4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1
3412 if (ees0tmp.gt.0) then
3413 ees0pij=dsqrt(ees0tmp)
3417 ! ees0mij=dsqrt(4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2)
3418 ees0tmp=4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2
3419 if (ees0tmp.gt.0) then
3420 ees0mij=dsqrt(ees0tmp)
3425 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij) &
3428 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij) &
3431 ! Diagnostics. Comment out or remove after debugging!
3432 ! ees0p(num_conti,i)=0.5D0*fac3*ees0pij
3433 ! ees0m(num_conti,i)=0.5D0*fac3*ees0mij
3434 ! ees0m(num_conti,i)=0.0D0
3436 ! write (iout,*) 'i=',i,' j=',j,' rij=',rij,' r0ij=',r0ij,
3437 ! & ' ees0ij=',ees0p(num_conti,i),ees0m(num_conti,i),' fcont=',fcont
3438 ! Angular derivatives of the contact function
3439 ees0pij1=fac3/ees0pij
3440 ees0mij1=fac3/ees0mij
3441 fac3p=-3.0D0*fac3*rrmij
3442 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
3443 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
3445 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
3446 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
3447 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
3448 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
3449 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
3450 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
3451 ecosap=ecosa1+ecosa2
3452 ecosbp=ecosb1+ecosb2
3453 ecosgp=ecosg1+ecosg2
3454 ecosam=ecosa1-ecosa2
3455 ecosbm=ecosb1-ecosb2
3456 ecosgm=ecosg1-ecosg2
3465 facont_hb(num_conti,i)=fcont
3466 fprimcont=fprimcont/rij
3467 !d facont_hb(num_conti,i)=1.0D0
3468 ! Following line is for diagnostics.
3471 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
3472 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
3475 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
3476 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
3478 gggp(1)=gggp(1)+ees0pijp*xj &
3479 +ees0p(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
3480 gggp(2)=gggp(2)+ees0pijp*yj &
3481 +ees0p(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
3482 gggp(3)=gggp(3)+ees0pijp*zj &
3483 +ees0p(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
3485 gggm(1)=gggm(1)+ees0mijp*xj &
3486 +ees0m(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
3488 gggm(2)=gggm(2)+ees0mijp*yj &
3489 +ees0m(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
3491 gggm(3)=gggm(3)+ees0mijp*zj &
3492 +ees0m(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
3494 ! Derivatives due to the contact function
3495 gacont_hbr(1,num_conti,i)=fprimcont*xj
3496 gacont_hbr(2,num_conti,i)=fprimcont*yj
3497 gacont_hbr(3,num_conti,i)=fprimcont*zj
3500 ! 10/24/08 cgrad and ! comments indicate the parts of the code removed
3501 ! following the change of gradient-summation algorithm.
3503 !grad ghalfp=0.5D0*gggp(k)
3504 !grad ghalfm=0.5D0*gggm(k)
3505 gacontp_hb1(k,num_conti,i)= & !ghalfp+
3506 (ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
3507 + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
3510 gacontp_hb2(k,num_conti,i)= & !ghalfp+
3511 (ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
3512 + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
3515 gacontp_hb3(k,num_conti,i)=gggp(k) &
3518 gacontm_hb1(k,num_conti,i)= & !ghalfm+
3519 (ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
3520 + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
3523 gacontm_hb2(k,num_conti,i)= & !ghalfm+
3524 (ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
3525 + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1) &
3528 gacontm_hb3(k,num_conti,i)=gggm(k) &
3532 ! Diagnostics. Comment out or remove after debugging!
3534 !diag gacontp_hb1(k,num_conti,i)=0.0D0
3535 !diag gacontp_hb2(k,num_conti,i)=0.0D0
3536 !diag gacontp_hb3(k,num_conti,i)=0.0D0
3537 !diag gacontm_hb1(k,num_conti,i)=0.0D0
3538 !diag gacontm_hb2(k,num_conti,i)=0.0D0
3539 !diag gacontm_hb3(k,num_conti,i)=0.0D0
3542 endif ! num_conti.le.maxconts
3545 if (wturn3.gt.0.0d0 .or. wturn4.gt.0.0d0) then
3548 ghalf=0.5d0*agg(l,k)
3549 aggi(l,k)=aggi(l,k)+ghalf
3550 aggi1(l,k)=aggi1(l,k)+agg(l,k)
3551 aggj(l,k)=aggj(l,k)+ghalf
3554 if (j.eq.nres-1 .and. i.lt.j-2) then
3557 aggj1(l,k)=aggj1(l,k)+agg(l,k)
3563 ! t_eelecij=t_eelecij+MPI_Wtime()-time00
3565 end subroutine eelecij
3566 !-----------------------------------------------------------------------------
3567 subroutine eturn3(i,eello_turn3)
3568 ! Third- and fourth-order contributions from turns
3571 ! implicit real*8 (a-h,o-z)
3572 ! include 'DIMENSIONS'
3573 ! include 'COMMON.IOUNITS'
3574 ! include 'COMMON.GEO'
3575 ! include 'COMMON.VAR'
3576 ! include 'COMMON.LOCAL'
3577 ! include 'COMMON.CHAIN'
3578 ! include 'COMMON.DERIV'
3579 ! include 'COMMON.INTERACT'
3580 ! include 'COMMON.CONTACTS'
3581 ! include 'COMMON.TORSION'
3582 ! include 'COMMON.VECTORS'
3583 ! include 'COMMON.FFIELD'
3584 ! include 'COMMON.CONTROL'
3585 real(kind=8),dimension(3) :: ggg
3586 real(kind=8),dimension(2,2) :: auxmat,auxmat1,auxmat2,pizda,&
3587 e1t,e2t,e3t,e1tder,e2tder,e3tder,e1a,ae3,ae3e2
3588 real(kind=8),dimension(2) :: auxvec,auxvec1
3589 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
3590 real(kind=8),dimension(2,2) :: auxmat3 !el, a_temp
3591 !el integer :: num_conti,j1,j2
3592 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
3593 !el dz_normi,xmedi,ymedi,zmedi
3595 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
3596 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
3600 real(kind=8) :: eello_turn3
3603 ! write (iout,*) "eturn3",i,j,j1,j2
3608 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
3610 ! Third-order contributions
3617 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
3618 !d call checkint_turn3(i,a_temp,eello_turn3_num)
3619 call matmat2(EUg(1,1,i+1),EUg(1,1,i+2),auxmat(1,1))
3620 call transpose2(auxmat(1,1),auxmat1(1,1))
3621 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
3622 eello_turn3=eello_turn3+0.5d0*(pizda(1,1)+pizda(2,2))
3623 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
3624 'eturn3',i,j,0.5d0*(pizda(1,1)+pizda(2,2))
3625 !d write (2,*) 'i,',i,' j',j,'eello_turn3',
3626 !d & 0.5d0*(pizda(1,1)+pizda(2,2)),
3627 !d & ' eello_turn3_num',4*eello_turn3_num
3628 ! Derivatives in gamma(i)
3629 call matmat2(EUgder(1,1,i+1),EUg(1,1,i+2),auxmat2(1,1))
3630 call transpose2(auxmat2(1,1),auxmat3(1,1))
3631 call matmat2(a_temp(1,1),auxmat3(1,1),pizda(1,1))
3632 gel_loc_turn3(i)=gel_loc_turn3(i)+0.5d0*(pizda(1,1)+pizda(2,2))
3633 ! Derivatives in gamma(i+1)
3634 call matmat2(EUg(1,1,i+1),EUgder(1,1,i+2),auxmat2(1,1))
3635 call transpose2(auxmat2(1,1),auxmat3(1,1))
3636 call matmat2(a_temp(1,1),auxmat3(1,1),pizda(1,1))
3637 gel_loc_turn3(i+1)=gel_loc_turn3(i+1) &
3638 +0.5d0*(pizda(1,1)+pizda(2,2))
3639 ! Cartesian derivatives
3641 ! ghalf1=0.5d0*agg(l,1)
3642 ! ghalf2=0.5d0*agg(l,2)
3643 ! ghalf3=0.5d0*agg(l,3)
3644 ! ghalf4=0.5d0*agg(l,4)
3645 a_temp(1,1)=aggi(l,1)!+ghalf1
3646 a_temp(1,2)=aggi(l,2)!+ghalf2
3647 a_temp(2,1)=aggi(l,3)!+ghalf3
3648 a_temp(2,2)=aggi(l,4)!+ghalf4
3649 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
3650 gcorr3_turn(l,i)=gcorr3_turn(l,i) &
3651 +0.5d0*(pizda(1,1)+pizda(2,2))
3652 a_temp(1,1)=aggi1(l,1)!+agg(l,1)
3653 a_temp(1,2)=aggi1(l,2)!+agg(l,2)
3654 a_temp(2,1)=aggi1(l,3)!+agg(l,3)
3655 a_temp(2,2)=aggi1(l,4)!+agg(l,4)
3656 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
3657 gcorr3_turn(l,i+1)=gcorr3_turn(l,i+1) &
3658 +0.5d0*(pizda(1,1)+pizda(2,2))
3659 a_temp(1,1)=aggj(l,1)!+ghalf1
3660 a_temp(1,2)=aggj(l,2)!+ghalf2
3661 a_temp(2,1)=aggj(l,3)!+ghalf3
3662 a_temp(2,2)=aggj(l,4)!+ghalf4
3663 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
3664 gcorr3_turn(l,j)=gcorr3_turn(l,j) &
3665 +0.5d0*(pizda(1,1)+pizda(2,2))
3666 a_temp(1,1)=aggj1(l,1)
3667 a_temp(1,2)=aggj1(l,2)
3668 a_temp(2,1)=aggj1(l,3)
3669 a_temp(2,2)=aggj1(l,4)
3670 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
3671 gcorr3_turn(l,j1)=gcorr3_turn(l,j1) &
3672 +0.5d0*(pizda(1,1)+pizda(2,2))
3675 end subroutine eturn3
3676 !-----------------------------------------------------------------------------
3677 subroutine eturn4(i,eello_turn4)
3678 ! Third- and fourth-order contributions from turns
3681 ! implicit real*8 (a-h,o-z)
3682 ! include 'DIMENSIONS'
3683 ! include 'COMMON.IOUNITS'
3684 ! include 'COMMON.GEO'
3685 ! include 'COMMON.VAR'
3686 ! include 'COMMON.LOCAL'
3687 ! include 'COMMON.CHAIN'
3688 ! include 'COMMON.DERIV'
3689 ! include 'COMMON.INTERACT'
3690 ! include 'COMMON.CONTACTS'
3691 ! include 'COMMON.TORSION'
3692 ! include 'COMMON.VECTORS'
3693 ! include 'COMMON.FFIELD'
3694 ! include 'COMMON.CONTROL'
3695 real(kind=8),dimension(3) :: ggg
3696 real(kind=8),dimension(2,2) :: auxmat,auxmat1,auxmat2,pizda,&
3697 e1t,e2t,e3t,e1tder,e2tder,e3tder,e1a,ae3,ae3e2
3698 real(kind=8),dimension(2) :: auxvec,auxvec1
3699 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
3700 real(kind=8),dimension(2,2) :: auxmat3 !el a_temp
3701 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
3702 !el dz_normi,xmedi,ymedi,zmedi
3703 !el integer :: num_conti,j1,j2
3704 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
3705 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
3708 integer :: i,j,iti1,iti2,iti3,l
3709 real(kind=8) :: eello_turn4,s1,s2,s3
3712 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
3714 ! Fourth-order contributions
3722 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
3723 !d call checkint_turn4(i,a_temp,eello_turn4_num)
3724 ! write (iout,*) "eturn4 i",i," j",j," j1",j1," j2",j2
3729 iti1=itortyp(itype(i+1))
3730 iti2=itortyp(itype(i+2))
3731 iti3=itortyp(itype(i+3))
3732 ! write(iout,*) "iti1",iti1," iti2",iti2," iti3",iti3
3733 call transpose2(EUg(1,1,i+1),e1t(1,1))
3734 call transpose2(Eug(1,1,i+2),e2t(1,1))
3735 call transpose2(Eug(1,1,i+3),e3t(1,1))
3736 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
3737 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
3738 s1=scalar2(b1(1,iti2),auxvec(1))
3739 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
3740 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
3741 s2=scalar2(b1(1,iti1),auxvec(1))
3742 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
3743 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
3744 s3=0.5d0*(pizda(1,1)+pizda(2,2))
3745 eello_turn4=eello_turn4-(s1+s2+s3)
3746 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
3747 'eturn4',i,j,-(s1+s2+s3)
3748 !d write (2,*) 'i,',i,' j',j,'eello_turn4',-(s1+s2+s3),
3749 !d & ' eello_turn4_num',8*eello_turn4_num
3750 ! Derivatives in gamma(i)
3751 call transpose2(EUgder(1,1,i+1),e1tder(1,1))
3752 call matmat2(e1tder(1,1),a_temp(1,1),auxmat(1,1))
3753 call matvec2(auxmat(1,1),Ub2(1,i+3),auxvec(1))
3754 s1=scalar2(b1(1,iti2),auxvec(1))
3755 call matmat2(ae3e2(1,1),e1tder(1,1),pizda(1,1))
3756 s3=0.5d0*(pizda(1,1)+pizda(2,2))
3757 gel_loc_turn4(i)=gel_loc_turn4(i)-(s1+s3)
3758 ! Derivatives in gamma(i+1)
3759 call transpose2(EUgder(1,1,i+2),e2tder(1,1))
3760 call matvec2(ae3(1,1),Ub2der(1,i+2),auxvec(1))
3761 s2=scalar2(b1(1,iti1),auxvec(1))
3762 call matmat2(ae3(1,1),e2tder(1,1),auxmat(1,1))
3763 call matmat2(auxmat(1,1),e1t(1,1),pizda(1,1))
3764 s3=0.5d0*(pizda(1,1)+pizda(2,2))
3765 gel_loc_turn4(i+1)=gel_loc_turn4(i+1)-(s2+s3)
3766 ! Derivatives in gamma(i+2)
3767 call transpose2(EUgder(1,1,i+3),e3tder(1,1))
3768 call matvec2(e1a(1,1),Ub2der(1,i+3),auxvec(1))
3769 s1=scalar2(b1(1,iti2),auxvec(1))
3770 call matmat2(a_temp(1,1),e3tder(1,1),auxmat(1,1))
3771 call matvec2(auxmat(1,1),Ub2(1,i+2),auxvec(1))
3772 s2=scalar2(b1(1,iti1),auxvec(1))
3773 call matmat2(auxmat(1,1),e2t(1,1),auxmat3(1,1))
3774 call matmat2(auxmat3(1,1),e1t(1,1),pizda(1,1))
3775 s3=0.5d0*(pizda(1,1)+pizda(2,2))
3776 gel_loc_turn4(i+2)=gel_loc_turn4(i+2)-(s1+s2+s3)
3777 ! Cartesian derivatives
3778 ! Derivatives of this turn contributions in DC(i+2)
3779 if (j.lt.nres-1) then
3781 a_temp(1,1)=agg(l,1)
3782 a_temp(1,2)=agg(l,2)
3783 a_temp(2,1)=agg(l,3)
3784 a_temp(2,2)=agg(l,4)
3785 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
3786 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
3787 s1=scalar2(b1(1,iti2),auxvec(1))
3788 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
3789 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
3790 s2=scalar2(b1(1,iti1),auxvec(1))
3791 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
3792 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
3793 s3=0.5d0*(pizda(1,1)+pizda(2,2))
3795 gcorr4_turn(l,i+2)=gcorr4_turn(l,i+2)-(s1+s2+s3)
3798 ! Remaining derivatives of this turn contribution
3800 a_temp(1,1)=aggi(l,1)
3801 a_temp(1,2)=aggi(l,2)
3802 a_temp(2,1)=aggi(l,3)
3803 a_temp(2,2)=aggi(l,4)
3804 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
3805 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
3806 s1=scalar2(b1(1,iti2),auxvec(1))
3807 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
3808 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
3809 s2=scalar2(b1(1,iti1),auxvec(1))
3810 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
3811 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
3812 s3=0.5d0*(pizda(1,1)+pizda(2,2))
3813 gcorr4_turn(l,i)=gcorr4_turn(l,i)-(s1+s2+s3)
3814 a_temp(1,1)=aggi1(l,1)
3815 a_temp(1,2)=aggi1(l,2)
3816 a_temp(2,1)=aggi1(l,3)
3817 a_temp(2,2)=aggi1(l,4)
3818 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
3819 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
3820 s1=scalar2(b1(1,iti2),auxvec(1))
3821 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
3822 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
3823 s2=scalar2(b1(1,iti1),auxvec(1))
3824 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
3825 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
3826 s3=0.5d0*(pizda(1,1)+pizda(2,2))
3827 gcorr4_turn(l,i+1)=gcorr4_turn(l,i+1)-(s1+s2+s3)
3828 a_temp(1,1)=aggj(l,1)
3829 a_temp(1,2)=aggj(l,2)
3830 a_temp(2,1)=aggj(l,3)
3831 a_temp(2,2)=aggj(l,4)
3832 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
3833 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
3834 s1=scalar2(b1(1,iti2),auxvec(1))
3835 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
3836 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
3837 s2=scalar2(b1(1,iti1),auxvec(1))
3838 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
3839 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
3840 s3=0.5d0*(pizda(1,1)+pizda(2,2))
3841 gcorr4_turn(l,j)=gcorr4_turn(l,j)-(s1+s2+s3)
3842 a_temp(1,1)=aggj1(l,1)
3843 a_temp(1,2)=aggj1(l,2)
3844 a_temp(2,1)=aggj1(l,3)
3845 a_temp(2,2)=aggj1(l,4)
3846 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
3847 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
3848 s1=scalar2(b1(1,iti2),auxvec(1))
3849 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
3850 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
3851 s2=scalar2(b1(1,iti1),auxvec(1))
3852 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
3853 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
3854 s3=0.5d0*(pizda(1,1)+pizda(2,2))
3855 ! write (iout,*) "s1",s1," s2",s2," s3",s3," s1+s2+s3",s1+s2+s3
3856 gcorr4_turn(l,j1)=gcorr4_turn(l,j1)-(s1+s2+s3)
3859 end subroutine eturn4
3860 !-----------------------------------------------------------------------------
3861 subroutine unormderiv(u,ugrad,unorm,ungrad)
3862 ! This subroutine computes the derivatives of a normalized vector u, given
3863 ! the derivatives computed without normalization conditions, ugrad. Returns
3866 real(kind=8),dimension(3) :: u,vec
3867 real(kind=8),dimension(3,3) ::ugrad,ungrad
3868 real(kind=8) :: unorm !,scalar
3870 ! write (2,*) 'ugrad',ugrad
3873 vec(i)=scalar(ugrad(1,i),u(1))
3875 ! write (2,*) 'vec',vec
3878 ungrad(j,i)=(ugrad(j,i)-u(j)*vec(i))*unorm
3881 ! write (2,*) 'ungrad',ungrad
3883 end subroutine unormderiv
3884 !-----------------------------------------------------------------------------
3885 subroutine escp_soft_sphere(evdw2,evdw2_14)
3887 ! This subroutine calculates the excluded-volume interaction energy between
3888 ! peptide-group centers and side chains and its gradient in virtual-bond and
3889 ! side-chain vectors.
3891 ! implicit real*8 (a-h,o-z)
3892 ! include 'DIMENSIONS'
3893 ! include 'COMMON.GEO'
3894 ! include 'COMMON.VAR'
3895 ! include 'COMMON.LOCAL'
3896 ! include 'COMMON.CHAIN'
3897 ! include 'COMMON.DERIV'
3898 ! include 'COMMON.INTERACT'
3899 ! include 'COMMON.FFIELD'
3900 ! include 'COMMON.IOUNITS'
3901 ! include 'COMMON.CONTROL'
3902 real(kind=8),dimension(3) :: ggg
3904 integer :: i,iint,j,k,iteli,itypj
3905 real(kind=8) :: evdw2,evdw2_14,r0_scp,xi,yi,zi,xj,yj,zj,&
3906 fac,rij,r0ij,r0ijsq,evdwij,e1,e2
3911 !d print '(a)','Enter ESCP'
3912 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
3913 do i=iatscp_s,iatscp_e
3914 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1) cycle
3916 xi=0.5D0*(c(1,i)+c(1,i+1))
3917 yi=0.5D0*(c(2,i)+c(2,i+1))
3918 zi=0.5D0*(c(3,i)+c(3,i+1))
3920 do iint=1,nscp_gr(i)
3922 do j=iscpstart(i,iint),iscpend(i,iint)
3923 if (itype(j).eq.ntyp1) cycle
3924 itypj=iabs(itype(j))
3925 ! Uncomment following three lines for SC-p interactions
3929 ! Uncomment following three lines for Ca-p interactions
3933 rij=xj*xj+yj*yj+zj*zj
3936 if (rij.lt.r0ijsq) then
3937 evdwij=0.25d0*(rij-r0ijsq)**2
3945 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
3950 !grad if (j.lt.i) then
3951 !d write (iout,*) 'j<i'
3952 ! Uncomment following three lines for SC-p interactions
3954 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
3957 !d write (iout,*) 'j>i'
3959 !grad ggg(k)=-ggg(k)
3960 ! Uncomment following line for SC-p interactions
3961 ! gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
3965 !grad gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
3967 !grad kstart=min0(i+1,j)
3968 !grad kend=max0(i-1,j-1)
3969 !d write (iout,*) 'i=',i,' j=',j,' kstart=',kstart,' kend=',kend
3970 !d write (iout,*) ggg(1),ggg(2),ggg(3)
3971 !grad do k=kstart,kend
3973 !grad gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
3977 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
3978 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
3985 end subroutine escp_soft_sphere
3986 !-----------------------------------------------------------------------------
3987 subroutine escp(evdw2,evdw2_14)
3989 ! This subroutine calculates the excluded-volume interaction energy between
3990 ! peptide-group centers and side chains and its gradient in virtual-bond and
3991 ! side-chain vectors.
3993 ! implicit real*8 (a-h,o-z)
3994 ! include 'DIMENSIONS'
3995 ! include 'COMMON.GEO'
3996 ! include 'COMMON.VAR'
3997 ! include 'COMMON.LOCAL'
3998 ! include 'COMMON.CHAIN'
3999 ! include 'COMMON.DERIV'
4000 ! include 'COMMON.INTERACT'
4001 ! include 'COMMON.FFIELD'
4002 ! include 'COMMON.IOUNITS'
4003 ! include 'COMMON.CONTROL'
4004 real(kind=8),dimension(3) :: ggg
4006 integer :: i,iint,j,k,iteli,itypj,subchap
4007 real(kind=8) :: evdw2,evdw2_14,xi,yi,zi,xj,yj,zj,rrij,fac,&
4009 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
4010 dist_temp, dist_init
4011 integer xshift,yshift,zshift
4015 !d print '(a)','Enter ESCP'
4016 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
4017 do i=iatscp_s,iatscp_e
4018 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1) cycle
4020 xi=0.5D0*(c(1,i)+c(1,i+1))
4021 yi=0.5D0*(c(2,i)+c(2,i+1))
4022 zi=0.5D0*(c(3,i)+c(3,i+1))
4024 if (xi.lt.0) xi=xi+boxxsize
4026 if (yi.lt.0) yi=yi+boxysize
4028 if (zi.lt.0) zi=zi+boxzsize
4030 do iint=1,nscp_gr(i)
4032 do j=iscpstart(i,iint),iscpend(i,iint)
4033 itypj=iabs(itype(j))
4034 if (itypj.eq.ntyp1) cycle
4035 ! Uncomment following three lines for SC-p interactions
4039 ! Uncomment following three lines for Ca-p interactions
4047 if (xj.lt.0) xj=xj+boxxsize
4049 if (yj.lt.0) yj=yj+boxysize
4051 if (zj.lt.0) zj=zj+boxzsize
4052 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
4060 xj=xj_safe+xshift*boxxsize
4061 yj=yj_safe+yshift*boxysize
4062 zj=zj_safe+zshift*boxzsize
4063 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
4064 if(dist_temp.lt.dist_init) then
4074 if (subchap.eq.1) then
4084 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
4085 rij=dsqrt(1.0d0/rrij)
4086 sss_ele_cut=sscale_ele(rij)
4087 sss_ele_grad=sscagrad_ele(rij)
4088 ! print *,sss_ele_cut,sss_ele_grad,&
4089 ! (rij),r_cut_ele,rlamb_ele
4090 if (sss_ele_cut.le.0.0) cycle
4092 e1=fac*fac*aad(itypj,iteli)
4093 e2=fac*bad(itypj,iteli)
4094 if (iabs(j-i) .le. 2) then
4097 evdw2_14=evdw2_14+(e1+e2)*sss_ele_cut
4100 evdw2=evdw2+evdwij*sss_ele_cut
4101 ! if (energy_dec) write (iout,'(a6,2i5,0pf7.3,2i3,3e11.3)') &
4102 ! 'evdw2',i,j,evdwij,iteli,itypj,fac,aad(itypj,iteli),&
4103 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
4106 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
4108 fac=-(evdwij+e1)*rrij*sss_ele_cut
4109 fac=fac+evdwij*sss_ele_grad/rij/expon
4113 !grad if (j.lt.i) then
4114 !d write (iout,*) 'j<i'
4115 ! Uncomment following three lines for SC-p interactions
4117 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
4120 !d write (iout,*) 'j>i'
4122 !grad ggg(k)=-ggg(k)
4123 ! Uncomment following line for SC-p interactions
4124 !cgrad gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
4125 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
4129 !grad gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
4131 !grad kstart=min0(i+1,j)
4132 !grad kend=max0(i-1,j-1)
4133 !d write (iout,*) 'i=',i,' j=',j,' kstart=',kstart,' kend=',kend
4134 !d write (iout,*) ggg(1),ggg(2),ggg(3)
4135 !grad do k=kstart,kend
4137 !grad gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
4141 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
4142 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
4150 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
4151 gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
4152 gradx_scp(j,i)=expon*gradx_scp(j,i)
4155 !******************************************************************************
4159 ! To save time the factor EXPON has been extracted from ALL components
4160 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
4163 !******************************************************************************
4166 !-----------------------------------------------------------------------------
4167 subroutine edis(ehpb)
4169 ! Evaluate bridge-strain energy and its gradient in virtual-bond and SC vectors.
4171 ! implicit real*8 (a-h,o-z)
4172 ! include 'DIMENSIONS'
4173 ! include 'COMMON.SBRIDGE'
4174 ! include 'COMMON.CHAIN'
4175 ! include 'COMMON.DERIV'
4176 ! include 'COMMON.VAR'
4177 ! include 'COMMON.INTERACT'
4178 ! include 'COMMON.IOUNITS'
4179 real(kind=8),dimension(3) :: ggg
4181 integer :: i,j,ii,jj,iii,jjj,k
4182 real(kind=8) :: fac,eij,rdis,ehpb,dd,waga
4185 !d write(iout,*)'edis: nhpb=',nhpb,' fbr=',fbr
4186 !d write(iout,*)'link_start=',link_start,' link_end=',link_end
4187 if (link_end.eq.0) return
4188 do i=link_start,link_end
4189 ! If ihpb(i) and jhpb(i) > NRES, this is a SC-SC distance, otherwise a
4190 ! CA-CA distance used in regularization of structure.
4193 ! iii and jjj point to the residues for which the distance is assigned.
4194 if (ii.gt.nres) then
4201 ! write (iout,*) "i",i," ii",ii," iii",iii," jj",jj," jjj",jjj,
4202 ! & dhpb(i),dhpb1(i),forcon(i)
4203 ! 24/11/03 AL: SS bridges handled separately because of introducing a specific
4204 ! distance and angle dependent SS bond potential.
4205 !mc if (ii.gt.nres .and. itype(iii).eq.1 .and. itype(jjj).eq.1) then
4206 ! 18/07/06 MC: Use the convention that the first nss pairs are SS bonds
4207 if (.not.dyn_ss .and. i.le.nss) then
4208 ! 15/02/13 CC dynamic SSbond - additional check
4209 if (ii.gt.nres .and. iabs(itype(iii)).eq.1 .and. &
4210 iabs(itype(jjj)).eq.1) then
4211 call ssbond_ene(iii,jjj,eij)
4213 !d write (iout,*) "eij",eij
4216 ! Calculate the distance between the two points and its difference from the
4220 ! Get the force constant corresponding to this distance.
4222 ! Calculate the contribution to energy.
4223 ehpb=ehpb+waga*rdis*rdis
4225 ! Evaluate gradient.
4228 !d print *,'i=',i,' ii=',ii,' jj=',jj,' dhpb=',dhpb(i),' dd=',dd,
4229 !d & ' waga=',waga,' fac=',fac
4231 ggg(j)=fac*(c(j,jj)-c(j,ii))
4233 !d print '(i3,3(1pe14.5))',i,(ggg(j),j=1,3)
4234 ! If this is a SC-SC distance, we need to calculate the contributions to the
4235 ! Cartesian gradient in the SC vectors (ghpbx).
4238 ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
4239 ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
4242 !grad do j=iii,jjj-1
4244 !grad ghpbc(k,j)=ghpbc(k,j)+ggg(k)
4248 ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
4249 ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
4256 !-----------------------------------------------------------------------------
4257 subroutine ssbond_ene(i,j,eij)
4259 ! Calculate the distance and angle dependent SS-bond potential energy
4260 ! using a free-energy function derived based on RHF/6-31G** ab initio
4261 ! calculations of diethyl disulfide.
4263 ! A. Liwo and U. Kozlowska, 11/24/03
4265 ! implicit real*8 (a-h,o-z)
4266 ! include 'DIMENSIONS'
4267 ! include 'COMMON.SBRIDGE'
4268 ! include 'COMMON.CHAIN'
4269 ! include 'COMMON.DERIV'
4270 ! include 'COMMON.LOCAL'
4271 ! include 'COMMON.INTERACT'
4272 ! include 'COMMON.VAR'
4273 ! include 'COMMON.IOUNITS'
4274 real(kind=8),dimension(3) :: erij,dcosom1,dcosom2,gg
4276 integer :: i,j,itypi,itypj,k
4277 real(kind=8) :: eij,rij,rrij,xi,yi,zi,dxi,dyi,dzi,dsci_inv,&
4278 xj,yj,zj,dxj,dyj,dzj,om1,om2,om12,deltad,dscj_inv,&
4279 deltat1,deltat2,deltat12,ed,pom1,pom2,eom1,eom2,eom12,&
4282 itypi=iabs(itype(i))
4286 dxi=dc_norm(1,nres+i)
4287 dyi=dc_norm(2,nres+i)
4288 dzi=dc_norm(3,nres+i)
4289 ! dsci_inv=dsc_inv(itypi)
4290 dsci_inv=vbld_inv(nres+i)
4291 itypj=iabs(itype(j))
4292 ! dscj_inv=dsc_inv(itypj)
4293 dscj_inv=vbld_inv(nres+j)
4297 dxj=dc_norm(1,nres+j)
4298 dyj=dc_norm(2,nres+j)
4299 dzj=dc_norm(3,nres+j)
4300 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
4305 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
4306 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
4307 om12=dxi*dxj+dyi*dyj+dzi*dzj
4309 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
4310 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
4316 deltat12=om2-om1+2.0d0
4318 eij=akcm*deltad*deltad+akth*(deltat1*deltat1+deltat2*deltat2) &
4319 +akct*deltad*deltat12 &
4320 +v1ss*cosphi+v2ss*cosphi*cosphi+v3ss*cosphi*cosphi*cosphi+ebr
4321 ! write(iout,*) i,j,"rij",rij,"d0cm",d0cm," akcm",akcm," akth",akth,
4322 ! & " akct",akct," deltad",deltad," deltat",deltat1,deltat2,
4323 ! & " deltat12",deltat12," eij",eij
4324 ed=2*akcm*deltad+akct*deltat12
4326 pom2=v1ss+2*v2ss*cosphi+3*v3ss*cosphi*cosphi
4327 eom1=-2*akth*deltat1-pom1-om2*pom2
4328 eom2= 2*akth*deltat2+pom1-om1*pom2
4331 ggk=ed*erij(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
4332 ghpbx(k,i)=ghpbx(k,i)-ggk &
4333 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
4334 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
4335 ghpbx(k,j)=ghpbx(k,j)+ggk &
4336 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
4337 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
4338 ghpbc(k,i)=ghpbc(k,i)-ggk
4339 ghpbc(k,j)=ghpbc(k,j)+ggk
4342 ! Calculate the components of the gradient in DC and X
4346 !grad ghpbc(l,k)=ghpbc(l,k)+gg(l)
4350 end subroutine ssbond_ene
4351 !-----------------------------------------------------------------------------
4352 subroutine ebond(estr)
4354 ! Evaluate the energy of stretching of the CA-CA and CA-SC virtual bonds
4356 ! implicit real*8 (a-h,o-z)
4357 ! include 'DIMENSIONS'
4358 ! include 'COMMON.LOCAL'
4359 ! include 'COMMON.GEO'
4360 ! include 'COMMON.INTERACT'
4361 ! include 'COMMON.DERIV'
4362 ! include 'COMMON.VAR'
4363 ! include 'COMMON.CHAIN'
4364 ! include 'COMMON.IOUNITS'
4365 ! include 'COMMON.NAMES'
4366 ! include 'COMMON.FFIELD'
4367 ! include 'COMMON.CONTROL'
4368 ! include 'COMMON.SETUP'
4369 real(kind=8),dimension(3) :: u,ud
4371 integer :: i,j,iti,nbi,k
4372 real(kind=8) :: estr,estr1,diff,uprod,usum,usumsqder,&
4377 ! if (.not.allocated(gradb)) allocate(gradb(3,nres)) !(3,maxres)
4378 ! if (.not.allocated(gradbx)) allocate(gradbx(3,nres)) !(3,maxres)
4380 do i=ibondp_start,ibondp_end
4381 if (itype(i-1).eq.ntyp1 .and. itype(i).eq.ntyp1) cycle
4382 if (itype(i-1).eq.ntyp1 .or. itype(i).eq.ntyp1) then
4383 !C estr1=estr1+gnmr1(vbld(i),-1.0d0,distchainmax)
4385 !C gradb(j,i-1)=gnmr1prim(vbld(i),-1.0d0,distchainmax) &
4386 !C *dc(j,i-1)/vbld(i)
4388 !C if (energy_dec) write(iout,*) &
4389 !C "estr1",i,gnmr1(vbld(i),-1.0d0,distchainmax)
4390 diff = vbld(i)-vbldpDUM
4392 diff = vbld(i)-vbldp0
4394 if (energy_dec) write (iout,'(a7,i5,4f7.3)') &
4395 "estr bb",i,vbld(i),vbldp0,diff,AKP*diff*diff
4398 gradb(j,i-1)=AKP*diff*dc(j,i-1)/vbld(i)
4400 ! write (iout,'(i5,3f10.5)') i,(gradb(j,i-1),j=1,3)
4403 estr=0.5d0*AKP*estr+estr1
4405 ! 09/18/07 AL: multimodal bond potential based on AM1 CA-SC PMF's included
4407 do i=ibond_start,ibond_end
4409 if (iti.ne.10 .and. iti.ne.ntyp1) then
4412 diff=vbld(i+nres)-vbldsc0(1,iti)
4413 if (energy_dec) write (iout,*) &
4414 "estr sc",i,iti,vbld(i+nres),vbldsc0(1,iti),diff,&
4415 AKSC(1,iti),AKSC(1,iti)*diff*diff
4416 estr=estr+0.5d0*AKSC(1,iti)*diff*diff
4418 gradbx(j,i)=AKSC(1,iti)*diff*dc(j,i+nres)/vbld(i+nres)
4422 diff=vbld(i+nres)-vbldsc0(j,iti)
4423 ud(j)=aksc(j,iti)*diff
4424 u(j)=abond0(j,iti)+0.5d0*ud(j)*diff
4438 uprod2=uprod2*u(k)*u(k)
4442 usumsqder=usumsqder+ud(j)*uprod2
4444 estr=estr+uprod/usum
4446 gradbx(j,i)=usumsqder/(usum*usum)*dc(j,i+nres)/vbld(i+nres)
4452 end subroutine ebond
4454 !-----------------------------------------------------------------------------
4455 subroutine ebend(etheta)
4457 ! Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
4458 ! angles gamma and its derivatives in consecutive thetas and gammas.
4461 ! implicit real*8 (a-h,o-z)
4462 ! include 'DIMENSIONS'
4463 ! include 'COMMON.LOCAL'
4464 ! include 'COMMON.GEO'
4465 ! include 'COMMON.INTERACT'
4466 ! include 'COMMON.DERIV'
4467 ! include 'COMMON.VAR'
4468 ! include 'COMMON.CHAIN'
4469 ! include 'COMMON.IOUNITS'
4470 ! include 'COMMON.NAMES'
4471 ! include 'COMMON.FFIELD'
4472 ! include 'COMMON.CONTROL'
4473 !el real(kind=8) :: term1,term2,termm,diffak,ratak,&
4474 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
4475 !el delthe0,sig0inv,sigtc,sigsqtc,delthec
4477 !el common /calcthet/ term1,term2,termm,diffak,ratak,&
4478 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
4479 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,it
4481 integer :: i,k,ichir1,ichir2,itype1,ichir11,ichir12,itype2,&
4483 real(kind=8) :: etheta,delta,ss,ssd,phii,phii1,thet_pred_mean,&
4484 athetk,bthetk,dthett,dthetg1,dthetg2,f0,fprim0,E_tc0,fprim_tc0,&
4485 f1,fprim1,E_tc1,ethetai,E_theta,E_tc
4486 real(kind=8),dimension(2) :: y,z
4489 ! time11=dexp(-2*time)
4492 ! write (*,'(a,i2)') 'EBEND ICG=',icg
4493 do i=ithet_start,ithet_end
4494 if (itype(i-1).eq.ntyp1) cycle
4495 ! Zero the energy function and its derivative at 0 or pi.
4496 call splinthet(theta(i),0.5d0*delta,ss,ssd)
4498 ichir1=isign(1,itype(i-2))
4499 ichir2=isign(1,itype(i))
4500 if (itype(i-2).eq.10) ichir1=isign(1,itype(i-1))
4501 if (itype(i).eq.10) ichir2=isign(1,itype(i-1))
4502 if (itype(i-1).eq.10) then
4503 itype1=isign(10,itype(i-2))
4504 ichir11=isign(1,itype(i-2))
4505 ichir12=isign(1,itype(i-2))
4506 itype2=isign(10,itype(i))
4507 ichir21=isign(1,itype(i))
4508 ichir22=isign(1,itype(i))
4511 if (i.gt.3 .and. itype(i-2).ne.ntyp1) then
4514 if (phii.ne.phii) phii=150.0
4524 if (i.lt.nres .and. itype(i).ne.ntyp1) then
4527 if (phii1.ne.phii1) phii1=150.0
4539 ! Calculate the "mean" value of theta from the part of the distribution
4540 ! dependent on the adjacent virtual-bond-valence angles (gamma1 & gamma2).
4541 ! In following comments this theta will be referred to as t_c.
4542 thet_pred_mean=0.0d0
4544 athetk=athet(k,it,ichir1,ichir2)
4545 bthetk=bthet(k,it,ichir1,ichir2)
4547 athetk=athet(k,itype1,ichir11,ichir12)
4548 bthetk=bthet(k,itype2,ichir21,ichir22)
4550 thet_pred_mean=thet_pred_mean+athetk*y(k)+bthetk*z(k)
4552 dthett=thet_pred_mean*ssd
4553 thet_pred_mean=thet_pred_mean*ss+a0thet(it)
4554 ! Derivatives of the "mean" values in gamma1 and gamma2.
4555 dthetg1=(-athet(1,it,ichir1,ichir2)*y(2) &
4556 +athet(2,it,ichir1,ichir2)*y(1))*ss
4557 dthetg2=(-bthet(1,it,ichir1,ichir2)*z(2) &
4558 +bthet(2,it,ichir1,ichir2)*z(1))*ss
4560 dthetg1=(-athet(1,itype1,ichir11,ichir12)*y(2) &
4561 +athet(2,itype1,ichir11,ichir12)*y(1))*ss
4562 dthetg2=(-bthet(1,itype2,ichir21,ichir22)*z(2) &
4563 +bthet(2,itype2,ichir21,ichir22)*z(1))*ss
4565 if (theta(i).gt.pi-delta) then
4566 call theteng(pi-delta,thet_pred_mean,theta0(it),f0,fprim0,&
4568 call mixder(pi-delta,thet_pred_mean,theta0(it),fprim_tc0)
4569 call theteng(pi,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
4570 call spline1(theta(i),pi-delta,delta,f0,f1,fprim0,ethetai,&
4572 call spline2(theta(i),pi-delta,delta,E_tc0,E_tc1,fprim_tc0,&
4574 else if (theta(i).lt.delta) then
4575 call theteng(delta,thet_pred_mean,theta0(it),f0,fprim0,E_tc0)
4576 call theteng(0.0d0,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
4577 call spline1(theta(i),delta,-delta,f0,f1,fprim0,ethetai,&
4579 call mixder(delta,thet_pred_mean,theta0(it),fprim_tc0)
4580 call spline2(theta(i),delta,-delta,E_tc0,E_tc1,fprim_tc0,&
4583 call theteng(theta(i),thet_pred_mean,theta0(it),ethetai,&
4586 etheta=etheta+ethetai
4587 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
4589 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*E_tc*dthetg1
4590 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*E_tc*dthetg2
4591 gloc(nphi+i-2,icg)=wang*(E_theta+E_tc*dthett)
4593 ! Ufff.... We've done all this!!!
4595 end subroutine ebend
4596 !-----------------------------------------------------------------------------
4597 subroutine theteng(thetai,thet_pred_mean,theta0i,ethetai,E_theta,E_tc)
4600 ! implicit real*8 (a-h,o-z)
4601 ! include 'DIMENSIONS'
4602 ! include 'COMMON.LOCAL'
4603 ! include 'COMMON.IOUNITS'
4604 !el real(kind=8) :: term1,term2,termm,diffak,ratak,&
4605 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
4606 !el delthe0,sig0inv,sigtc,sigsqtc,delthec
4608 real(kind=8) :: thetai,thet_pred_mean,theta0i,ethetai,E_theta,E_tc
4610 !el common /calcthet/ term1,term2,termm,diffak,ratak,&
4611 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
4612 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,it
4614 real(kind=8) :: sig,fac,escloci0,escloci1,esclocbi0,dersc12,&
4615 esclocbi1,chuju,esclocbi,dersc02,dersc01,ss,ssd
4617 ! Calculate the contributions to both Gaussian lobes.
4618 ! 6/6/97 - Deform the Gaussians using the factor of 1/(1+time)
4619 ! The "polynomial part" of the "standard deviation" of this part of
4623 sig=sig*thet_pred_mean+polthet(j,it)
4625 ! Derivative of the "interior part" of the "standard deviation of the"
4626 ! gamma-dependent Gaussian lobe in t_c.
4627 sigtc=3*polthet(3,it)
4629 sigtc=sigtc*thet_pred_mean+j*polthet(j,it)
4632 ! Set the parameters of both Gaussian lobes of the distribution.
4633 ! "Standard deviation" of the gamma-dependent Gaussian lobe (sigtc)
4634 fac=sig*sig+sigc0(it)
4637 ! Following variable (sigsqtc) is -(1/2)d[sigma(t_c)**(-2))]/dt_c
4638 sigsqtc=-4.0D0*sigcsq*sigtc
4639 ! print *,i,sig,sigtc,sigsqtc
4640 ! Following variable (sigtc) is d[sigma(t_c)]/dt_c
4641 sigtc=-sigtc/(fac*fac)
4642 ! Following variable is sigma(t_c)**(-2)
4643 sigcsq=sigcsq*sigcsq
4645 sig0inv=1.0D0/sig0i**2
4646 delthec=thetai-thet_pred_mean
4647 delthe0=thetai-theta0i
4648 term1=-0.5D0*sigcsq*delthec*delthec
4649 term2=-0.5D0*sig0inv*delthe0*delthe0
4650 ! Following fuzzy logic is to avoid underflows in dexp and subsequent INFs and
4651 ! NaNs in taking the logarithm. We extract the largest exponent which is added
4652 ! to the energy (this being the log of the distribution) at the end of energy
4653 ! term evaluation for this virtual-bond angle.
4654 if (term1.gt.term2) then
4656 term2=dexp(term2-termm)
4660 term1=dexp(term1-termm)
4663 ! The ratio between the gamma-independent and gamma-dependent lobes of
4664 ! the distribution is a Gaussian function of thet_pred_mean too.
4665 diffak=gthet(2,it)-thet_pred_mean
4666 ratak=diffak/gthet(3,it)**2
4667 ak=dexp(gthet(1,it)-0.5D0*diffak*ratak)
4668 ! Let's differentiate it in thet_pred_mean NOW.
4670 ! Now put together the distribution terms to make complete distribution.
4671 termexp=term1+ak*term2
4672 termpre=sigc+ak*sig0i
4673 ! Contribution of the bending energy from this theta is just the -log of
4674 ! the sum of the contributions from the two lobes and the pre-exponential
4675 ! factor. Simple enough, isn't it?
4676 ethetai=(-dlog(termexp)-termm+dlog(termpre))
4677 ! NOW the derivatives!!!
4678 ! 6/6/97 Take into account the deformation.
4679 E_theta=(delthec*sigcsq*term1 &
4680 +ak*delthe0*sig0inv*term2)/termexp
4681 E_tc=((sigtc+aktc*sig0i)/termpre &
4682 -((delthec*sigcsq+delthec*delthec*sigsqtc)*term1+ &
4683 aktc*term2)/termexp)
4685 end subroutine theteng
4687 !-----------------------------------------------------------------------------
4688 subroutine ebend(etheta)
4690 ! Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
4691 ! angles gamma and its derivatives in consecutive thetas and gammas.
4692 ! ab initio-derived potentials from
4693 ! Kozlowska et al., J. Phys.: Condens. Matter 19 (2007) 285203
4695 ! implicit real*8 (a-h,o-z)
4696 ! include 'DIMENSIONS'
4697 ! include 'COMMON.LOCAL'
4698 ! include 'COMMON.GEO'
4699 ! include 'COMMON.INTERACT'
4700 ! include 'COMMON.DERIV'
4701 ! include 'COMMON.VAR'
4702 ! include 'COMMON.CHAIN'
4703 ! include 'COMMON.IOUNITS'
4704 ! include 'COMMON.NAMES'
4705 ! include 'COMMON.FFIELD'
4706 ! include 'COMMON.CONTROL'
4707 real(kind=8),dimension(nntheterm) :: coskt,sinkt !mmaxtheterm
4708 real(kind=8),dimension(nsingle) :: cosph1,sinph1,cosph2,sinph2 !maxsingle
4709 real(kind=8),dimension(ndouble,ndouble) :: cosph1ph2,sinph1ph2 !maxdouble,maxdouble
4710 logical :: lprn=.false., lprn1=.false.
4712 integer :: i,k,iblock,ityp1,ityp2,ityp3,l,m
4713 real(kind=8) :: dethetai,dephii,dephii1,theti2,phii,phii1,ethetai
4714 real(kind=8) :: aux,etheta,ccl,ssl,scl,csl
4717 do i=ithet_start,ithet_end
4718 if (itype(i-1).eq.ntyp1) cycle
4719 if (itype(i-2).eq.ntyp1.or.itype(i).eq.ntyp1) cycle
4720 if (iabs(itype(i+1)).eq.20) iblock=2
4721 if (iabs(itype(i+1)).ne.20) iblock=1
4725 theti2=0.5d0*theta(i)
4726 ityp2=ithetyp((itype(i-1)))
4728 coskt(k)=dcos(k*theti2)
4729 sinkt(k)=dsin(k*theti2)
4731 if (i.gt.3 .and. itype(max0(i-3,1)).ne.ntyp1) then
4734 if (phii.ne.phii) phii=150.0
4738 ityp1=ithetyp((itype(i-2)))
4739 ! propagation of chirality for glycine type
4741 cosph1(k)=dcos(k*phii)
4742 sinph1(k)=dsin(k*phii)
4746 ityp1=ithetyp(itype(i-2))
4752 if (i.lt.nres .and. itype(i+1).ne.ntyp1) then
4755 if (phii1.ne.phii1) phii1=150.0
4760 ityp3=ithetyp((itype(i)))
4762 cosph2(k)=dcos(k*phii1)
4763 sinph2(k)=dsin(k*phii1)
4767 ityp3=ithetyp(itype(i))
4773 ethetai=aa0thet(ityp1,ityp2,ityp3,iblock)
4776 ccl=cosph1(l)*cosph2(k-l)
4777 ssl=sinph1(l)*sinph2(k-l)
4778 scl=sinph1(l)*cosph2(k-l)
4779 csl=cosph1(l)*sinph2(k-l)
4780 cosph1ph2(l,k)=ccl-ssl
4781 cosph1ph2(k,l)=ccl+ssl
4782 sinph1ph2(l,k)=scl+csl
4783 sinph1ph2(k,l)=scl-csl
4787 write (iout,*) "i",i," ityp1",ityp1," ityp2",ityp2,&
4788 " ityp3",ityp3," theti2",theti2," phii",phii," phii1",phii1
4789 write (iout,*) "coskt and sinkt"
4791 write (iout,*) k,coskt(k),sinkt(k)
4795 ethetai=ethetai+aathet(k,ityp1,ityp2,ityp3,iblock)*sinkt(k)
4796 dethetai=dethetai+0.5d0*k*aathet(k,ityp1,ityp2,ityp3,iblock) &
4799 write (iout,*) "k",k,&
4800 "aathet",aathet(k,ityp1,ityp2,ityp3,iblock),&
4804 write (iout,*) "cosph and sinph"
4806 write (iout,*) k,cosph1(k),sinph1(k),cosph2(k),sinph2(k)
4808 write (iout,*) "cosph1ph2 and sinph2ph2"
4811 write (iout,*) l,k,cosph1ph2(l,k),cosph1ph2(k,l),&
4812 sinph1ph2(l,k),sinph1ph2(k,l)
4815 write(iout,*) "ethetai",ethetai
4819 aux=bbthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph1(k) &
4820 +ccthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph1(k) &
4821 +ddthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph2(k) &
4822 +eethet(k,m,ityp1,ityp2,ityp3,iblock)*sinph2(k)
4823 ethetai=ethetai+sinkt(m)*aux
4824 dethetai=dethetai+0.5d0*m*aux*coskt(m)
4825 dephii=dephii+k*sinkt(m)* &
4826 (ccthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph1(k)- &
4827 bbthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph1(k))
4828 dephii1=dephii1+k*sinkt(m)* &
4829 (eethet(k,m,ityp1,ityp2,ityp3,iblock)*cosph2(k)- &
4830 ddthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph2(k))
4832 write (iout,*) "m",m," k",k," bbthet", &
4833 bbthet(k,m,ityp1,ityp2,ityp3,iblock)," ccthet", &
4834 ccthet(k,m,ityp1,ityp2,ityp3,iblock)," ddthet", &
4835 ddthet(k,m,ityp1,ityp2,ityp3,iblock)," eethet", &
4836 eethet(k,m,ityp1,ityp2,ityp3,iblock)," ethetai",ethetai
4840 write(iout,*) "ethetai",ethetai
4844 aux=ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)+ &
4845 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l)+ &
4846 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)+ &
4847 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)
4848 ethetai=ethetai+sinkt(m)*aux
4849 dethetai=dethetai+0.5d0*m*coskt(m)*aux
4850 dephii=dephii+l*sinkt(m)* &
4851 (-ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)- &
4852 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)+ &
4853 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)+ &
4854 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l))
4855 dephii1=dephii1+(k-l)*sinkt(m)* &
4856 (-ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)+ &
4857 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)+ &
4858 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)- &
4859 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l))
4861 write (iout,*) "m",m," k",k," l",l," ffthet",&
4862 ffthet(l,k,m,ityp1,ityp2,ityp3,iblock),&
4863 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)," ggthet",&
4864 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock),&
4865 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock),&
4867 write (iout,*) cosph1ph2(l,k)*sinkt(m),&
4868 cosph1ph2(k,l)*sinkt(m),&
4869 sinph1ph2(l,k)*sinkt(m),sinph1ph2(k,l)*sinkt(m)
4877 write (iout,'(i2,3f8.1,9h ethetai ,f10.5)') &
4878 i,theta(i)*rad2deg,phii*rad2deg,&
4879 phii1*rad2deg,ethetai
4881 etheta=etheta+ethetai
4882 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
4884 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*dephii
4885 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*dephii1
4886 gloc(nphi+i-2,icg)=wang*dethetai
4889 end subroutine ebend
4892 !-----------------------------------------------------------------------------
4893 subroutine esc(escloc)
4894 ! Calculate the local energy of a side chain and its derivatives in the
4895 ! corresponding virtual-bond valence angles THETA and the spherical angles
4899 ! implicit real*8 (a-h,o-z)
4900 ! include 'DIMENSIONS'
4901 ! include 'COMMON.GEO'
4902 ! include 'COMMON.LOCAL'
4903 ! include 'COMMON.VAR'
4904 ! include 'COMMON.INTERACT'
4905 ! include 'COMMON.DERIV'
4906 ! include 'COMMON.CHAIN'
4907 ! include 'COMMON.IOUNITS'
4908 ! include 'COMMON.NAMES'
4909 ! include 'COMMON.FFIELD'
4910 ! include 'COMMON.CONTROL'
4911 real(kind=8),dimension(3) :: x,dersc,xemp,dersc0,dersc1,&
4912 ddersc0,ddummy,xtemp,temp
4913 !el real(kind=8) :: time11,time12,time112,theti
4914 real(kind=8) :: escloc,delta
4915 !el integer :: it,nlobit
4916 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
4919 real(kind=8) :: escloci0,escloci1,escloci,esclocbi0,&
4920 dersc12,esclocbi1,chuju,esclocbi,dersc02,dersc01,ss,ssd
4923 ! write (iout,'(a)') 'ESC'
4924 do i=loc_start,loc_end
4926 if (it.eq.ntyp1) cycle
4927 if (it.eq.10) goto 1
4928 nlobit=nlob(iabs(it))
4929 ! print *,'i=',i,' it=',it,' nlobit=',nlobit
4930 ! write (iout,*) 'i=',i,' ssa=',ssa,' ssad=',ssad
4931 theti=theta(i+1)-pipol
4936 if (x(2).gt.pi-delta) then
4940 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
4942 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
4943 call spline1(x(2),pi-delta,delta,escloci0,escloci1,dersc0(2),&
4945 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),&
4946 ddersc0(1),dersc(1))
4947 call spline2(x(2),pi-delta,delta,dersc0(3),dersc1(3),&
4948 ddersc0(3),dersc(3))
4950 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
4952 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
4953 call spline1(x(2),pi-delta,delta,esclocbi0,esclocbi1,&
4954 dersc0(2),esclocbi,dersc02)
4955 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),&
4957 call splinthet(x(2),0.5d0*delta,ss,ssd)
4962 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
4964 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
4965 ! write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
4967 escloci=ss*escloci+(1.0d0-ss)*esclocbi
4969 ! write (iout,*) escloci
4970 else if (x(2).lt.delta) then
4974 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
4976 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
4977 call spline1(x(2),delta,-delta,escloci0,escloci1,dersc0(2),&
4979 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),&
4980 ddersc0(1),dersc(1))
4981 call spline2(x(2),delta,-delta,dersc0(3),dersc1(3),&
4982 ddersc0(3),dersc(3))
4984 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
4986 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
4987 call spline1(x(2),delta,-delta,esclocbi0,esclocbi1,&
4988 dersc0(2),esclocbi,dersc02)
4989 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),&
4994 call splinthet(x(2),0.5d0*delta,ss,ssd)
4996 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
4998 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
4999 ! write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
5001 escloci=ss*escloci+(1.0d0-ss)*esclocbi
5002 ! write (iout,*) escloci
5004 call enesc(x,escloci,dersc,ddummy,.false.)
5007 escloc=escloc+escloci
5008 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
5010 ! write (iout,*) 'i=',i,' escloci=',escloci,' dersc=',dersc
5012 gloc(nphi+i-1,icg)=gloc(nphi+i-1,icg)+ &
5014 gloc(ialph(i,1),icg)=wscloc*dersc(2)
5015 gloc(ialph(i,1)+nside,icg)=wscloc*dersc(3)
5020 !-----------------------------------------------------------------------------
5021 subroutine enesc(x,escloci,dersc,ddersc,mixed)
5024 ! implicit real*8 (a-h,o-z)
5025 ! include 'DIMENSIONS'
5026 ! include 'COMMON.GEO'
5027 ! include 'COMMON.LOCAL'
5028 ! include 'COMMON.IOUNITS'
5029 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
5030 real(kind=8),dimension(3) :: x,z,dersc,ddersc
5031 real(kind=8),dimension(3,nlobit,-1:1) :: Ax !(3,maxlob,-1:1)
5032 real(kind=8),dimension(nlobit,-1:1) :: contr !(maxlob,-1:1)
5033 real(kind=8) :: escloci
5036 integer :: j,iii,l,k !el,it,nlobit
5037 real(kind=8) :: escloc_i,x3,Axk,expfac,emin !el,theti,&
5038 !el time11,time12,time112
5039 ! write (iout,*) 'it=',it,' nlobit=',nlobit
5043 if (mixed) ddersc(j)=0.0d0
5047 ! Because of periodicity of the dependence of the SC energy in omega we have
5048 ! to add up the contributions from x(3)-2*pi, x(3), and x(3+2*pi).
5049 ! To avoid underflows, first compute & store the exponents.
5057 z(k)=x(k)-censc(k,j,it)
5062 Axk=Axk+gaussc(l,k,j,it)*z(l)
5068 expfac=expfac+Ax(k,j,iii)*z(k)
5076 ! As in the case of ebend, we want to avoid underflows in exponentiation and
5077 ! subsequent NaNs and INFs in energy calculation.
5078 ! Find the largest exponent
5082 if (emin.gt.contr(j,iii)) emin=contr(j,iii)
5086 !d print *,'it=',it,' emin=',emin
5088 ! Compute the contribution to SC energy and derivatives
5093 adexp=bsc(j,iabs(it))-0.5D0*contr(j,iii)+emin
5094 if(adexp.ne.adexp) adexp=1.0
5097 expfac=dexp(bsc(j,iabs(it))-0.5D0*contr(j,iii)+emin)
5099 !d print *,'j=',j,' expfac=',expfac
5100 escloc_i=escloc_i+expfac
5102 dersc(k)=dersc(k)+Ax(k,j,iii)*expfac
5106 ddersc(k)=ddersc(k)+(-Ax(2,j,iii)*Ax(k,j,iii) &
5107 +gaussc(k,2,j,it))*expfac
5114 dersc(1)=dersc(1)/cos(theti)**2
5115 ddersc(1)=ddersc(1)/cos(theti)**2
5118 escloci=-(dlog(escloc_i)-emin)
5120 dersc(j)=dersc(j)/escloc_i
5124 ddersc(j)=(ddersc(j)/escloc_i+dersc(2)*dersc(j))
5128 end subroutine enesc
5129 !-----------------------------------------------------------------------------
5130 subroutine enesc_bound(x,escloci,dersc,dersc12,mixed)
5133 ! implicit real*8 (a-h,o-z)
5134 ! include 'DIMENSIONS'
5135 ! include 'COMMON.GEO'
5136 ! include 'COMMON.LOCAL'
5137 ! include 'COMMON.IOUNITS'
5138 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
5139 real(kind=8),dimension(3) :: x,z,dersc
5140 real(kind=8),dimension(3,nlobit) :: Ax !(3,maxlob)
5141 real(kind=8),dimension(nlobit) :: contr !(maxlob)
5142 real(kind=8) :: escloci,dersc12,emin
5145 integer :: j,k,l !el,it,nlobit
5146 real(kind=8) :: escloc_i,Axk,expfac !el,time11,time12,time112,theti
5156 z(k)=x(k)-censc(k,j,it)
5162 Axk=Axk+gaussc(l,k,j,it)*z(l)
5168 expfac=expfac+Ax(k,j)*z(k)
5173 ! As in the case of ebend, we want to avoid underflows in exponentiation and
5174 ! subsequent NaNs and INFs in energy calculation.
5175 ! Find the largest exponent
5178 if (emin.gt.contr(j)) emin=contr(j)
5182 ! Compute the contribution to SC energy and derivatives
5186 expfac=dexp(bsc(j,iabs(it))-0.5D0*contr(j)+emin)
5187 escloc_i=escloc_i+expfac
5189 dersc(k)=dersc(k)+Ax(k,j)*expfac
5191 if (mixed) dersc12=dersc12+(-Ax(2,j)*Ax(1,j) &
5192 +gaussc(1,2,j,it))*expfac
5196 dersc(1)=dersc(1)/cos(theti)**2
5197 dersc12=dersc12/cos(theti)**2
5198 escloci=-(dlog(escloc_i)-emin)
5200 dersc(j)=dersc(j)/escloc_i
5202 if (mixed) dersc12=(dersc12/escloc_i+dersc(2)*dersc(1))
5204 end subroutine enesc_bound
5206 !-----------------------------------------------------------------------------
5207 subroutine esc(escloc)
5208 ! Calculate the local energy of a side chain and its derivatives in the
5209 ! corresponding virtual-bond valence angles THETA and the spherical angles
5210 ! ALPHA and OMEGA derived from AM1 all-atom calculations.
5211 ! added by Urszula Kozlowska. 07/11/2007
5214 ! implicit real*8 (a-h,o-z)
5215 ! include 'DIMENSIONS'
5216 ! include 'COMMON.GEO'
5217 ! include 'COMMON.LOCAL'
5218 ! include 'COMMON.VAR'
5219 ! include 'COMMON.SCROT'
5220 ! include 'COMMON.INTERACT'
5221 ! include 'COMMON.DERIV'
5222 ! include 'COMMON.CHAIN'
5223 ! include 'COMMON.IOUNITS'
5224 ! include 'COMMON.NAMES'
5225 ! include 'COMMON.FFIELD'
5226 ! include 'COMMON.CONTROL'
5227 ! include 'COMMON.VECTORS'
5228 real(kind=8),dimension(3) :: x_prime,y_prime,z_prime
5229 real(kind=8),dimension(65) :: x
5230 real(kind=8) :: sumene,dsc_i,dp2_i,xx,yy,zz,sumene1,sumene2,sumene3,&
5231 sumene4,s1,s1_6,s2,s2_6,de_dxx,de_dyy,de_dzz,de_dt
5232 real(kind=8) :: s1_t,s1_6_t,s2_t,s2_6_t
5233 real(kind=8),dimension(3) :: dXX_Ci1,dYY_Ci1,dZZ_Ci1,dXX_Ci,dYY_Ci,&
5234 dZZ_Ci,dXX_XYZ,dYY_XYZ,dZZ_XYZ,dt_dCi,dt_dCi1
5236 integer :: i,j,k !el,it,nlobit
5237 real(kind=8) :: cosfac2,sinfac2,cosfac,sinfac,escloc,delta
5238 !el real(kind=8) :: time11,time12,time112,theti
5239 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
5240 real(kind=8) :: dscp1,dscp2,pom_s1,pom_s16,pom_s2,pom_s26,&
5241 pom,pom_dx,pom_dy,pom_dt1,pom_dt2,pom1,pom2,&
5242 sumene1x,sumene2x,sumene3x,sumene4x,&
5243 sumene1y,sumene2y,sumene3y,sumene4y,cossc,cossc1,&
5246 real(kind=8) :: aincr,xxsave,sumenep,de_dxx_num,yysave,&
5247 de_dyy_num,zzsave,de_dzz_num,costsave,sintsave,&
5250 ! if (.not.allocated(gsclocx)) allocate(gsclocx(3,nres)) !(3,maxres)
5254 do i=loc_start,loc_end
5255 if (itype(i).eq.ntyp1) cycle
5256 costtab(i+1) =dcos(theta(i+1))
5257 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
5258 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
5259 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
5260 cosfac2=0.5d0/(1.0d0+costtab(i+1))
5261 cosfac=dsqrt(cosfac2)
5262 sinfac2=0.5d0/(1.0d0-costtab(i+1))
5263 sinfac=dsqrt(sinfac2)
5265 if (it.eq.10) goto 1
5267 ! Compute the axes of tghe local cartesian coordinates system; store in
5268 ! x_prime, y_prime and z_prime
5275 ! write(2,*) "dc_norm", dc_norm(1,i+nres),dc_norm(2,i+nres),
5276 ! & dc_norm(3,i+nres)
5278 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
5279 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
5282 z_prime(j) = -uz(j,i-1)*dsign(1.0d0,dfloat(itype(i)))
5285 ! write (2,*) "x_prime",(x_prime(j),j=1,3)
5286 ! write (2,*) "y_prime",(y_prime(j),j=1,3)
5287 ! write (2,*) "z_prime",(z_prime(j),j=1,3)
5288 ! write (2,*) "xx",scalar(x_prime(1),x_prime(1)),
5289 ! & " xy",scalar(x_prime(1),y_prime(1)),
5290 ! & " xz",scalar(x_prime(1),z_prime(1)),
5291 ! & " yy",scalar(y_prime(1),y_prime(1)),
5292 ! & " yz",scalar(y_prime(1),z_prime(1)),
5293 ! & " zz",scalar(z_prime(1),z_prime(1))
5295 ! Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
5296 ! to local coordinate system. Store in xx, yy, zz.
5302 xx = xx + x_prime(j)*dc_norm(j,i+nres)
5303 yy = yy + y_prime(j)*dc_norm(j,i+nres)
5304 zz = zz + z_prime(j)*dc_norm(j,i+nres)
5311 ! Compute the energy of the ith side cbain
5313 ! write (2,*) "xx",xx," yy",yy," zz",zz
5316 x(j) = sc_parmin(j,it)
5319 !c diagnostics - remove later
5321 yy1 = dsin(alph(2))*dcos(omeg(2))
5322 zz1 = -dsign(1.0,dfloat(itype(i)))*dsin(alph(2))*dsin(omeg(2))
5323 write(2,'(3f8.1,3f9.3,1x,3f9.3)') &
5324 alph(2)*rad2deg,omeg(2)*rad2deg,theta(3)*rad2deg,xx,yy,zz,&
5326 !," --- ", xx_w,yy_w,zz_w
5329 sumene1= x(1)+ x(2)*xx+ x(3)*yy+ x(4)*zz+ x(5)*xx**2 &
5330 + x(6)*yy**2+ x(7)*zz**2+ x(8)*xx*zz+ x(9)*xx*yy &
5332 sumene2= x(11) + x(12)*xx + x(13)*yy + x(14)*zz + x(15)*xx**2 &
5333 + x(16)*yy**2 + x(17)*zz**2 + x(18)*xx*zz + x(19)*xx*yy &
5335 sumene3= x(21) +x(22)*xx +x(23)*yy +x(24)*zz +x(25)*xx**2 &
5336 +x(26)*yy**2 +x(27)*zz**2 +x(28)*xx*zz +x(29)*xx*yy &
5337 +x(30)*yy*zz +x(31)*xx**3 +x(32)*yy**3 +x(33)*zz**3 &
5338 +x(34)*(xx**2)*yy +x(35)*(xx**2)*zz +x(36)*(yy**2)*xx &
5339 +x(37)*(yy**2)*zz +x(38)*(zz**2)*xx +x(39)*(zz**2)*yy &
5341 sumene4= x(41) +x(42)*xx +x(43)*yy +x(44)*zz +x(45)*xx**2 &
5342 +x(46)*yy**2 +x(47)*zz**2 +x(48)*xx*zz +x(49)*xx*yy &
5343 +x(50)*yy*zz +x(51)*xx**3 +x(52)*yy**3 +x(53)*zz**3 &
5344 +x(54)*(xx**2)*yy +x(55)*(xx**2)*zz +x(56)*(yy**2)*xx &
5345 +x(57)*(yy**2)*zz +x(58)*(zz**2)*xx +x(59)*(zz**2)*yy &
5347 dsc_i = 0.743d0+x(61)
5349 dscp1=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
5350 *(xx*cost2tab(i+1)+yy*sint2tab(i+1)))
5351 dscp2=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
5352 *(xx*cost2tab(i+1)-yy*sint2tab(i+1)))
5353 s1=(1+x(63))/(0.1d0 + dscp1)
5354 s1_6=(1+x(64))/(0.1d0 + dscp1**6)
5355 s2=(1+x(65))/(0.1d0 + dscp2)
5356 s2_6=(1+x(65))/(0.1d0 + dscp2**6)
5357 sumene = ( sumene3*sint2tab(i+1) + sumene1)*(s1+s1_6) &
5358 + (sumene4*cost2tab(i+1) +sumene2)*(s2+s2_6)
5359 ! write(2,'(i2," sumene",7f9.3)') i,sumene1,sumene2,sumene3,
5361 ! & dscp1,dscp2,sumene
5362 ! sumene = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
5363 escloc = escloc + sumene
5364 ! write (2,*) "i",i," escloc",sumene,escloc,it,itype(i)
5369 ! This section to check the numerical derivatives of the energy of ith side
5370 ! chain in xx, yy, zz, and theta. Use the -DDEBUG compiler option or insert
5371 ! #define DEBUG in the code to turn it on.
5373 write (2,*) "sumene =",sumene
5377 write (2,*) xx,yy,zz
5378 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
5379 de_dxx_num=(sumenep-sumene)/aincr
5381 write (2,*) "xx+ sumene from enesc=",sumenep
5384 write (2,*) xx,yy,zz
5385 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
5386 de_dyy_num=(sumenep-sumene)/aincr
5388 write (2,*) "yy+ sumene from enesc=",sumenep
5391 write (2,*) xx,yy,zz
5392 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
5393 de_dzz_num=(sumenep-sumene)/aincr
5395 write (2,*) "zz+ sumene from enesc=",sumenep
5396 costsave=cost2tab(i+1)
5397 sintsave=sint2tab(i+1)
5398 cost2tab(i+1)=dcos(0.5d0*(theta(i+1)+aincr))
5399 sint2tab(i+1)=dsin(0.5d0*(theta(i+1)+aincr))
5400 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
5401 de_dt_num=(sumenep-sumene)/aincr
5402 write (2,*) " t+ sumene from enesc=",sumenep
5403 cost2tab(i+1)=costsave
5404 sint2tab(i+1)=sintsave
5405 ! End of diagnostics section.
5408 ! Compute the gradient of esc
5410 ! zz=zz*dsign(1.0,dfloat(itype(i)))
5411 pom_s1=(1.0d0+x(63))/(0.1d0 + dscp1)**2
5412 pom_s16=6*(1.0d0+x(64))/(0.1d0 + dscp1**6)**2
5413 pom_s2=(1.0d0+x(65))/(0.1d0 + dscp2)**2
5414 pom_s26=6*(1.0d0+x(65))/(0.1d0 + dscp2**6)**2
5415 pom_dx=dsc_i*dp2_i*cost2tab(i+1)
5416 pom_dy=dsc_i*dp2_i*sint2tab(i+1)
5417 pom_dt1=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)-yy*cost2tab(i+1))
5418 pom_dt2=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)+yy*cost2tab(i+1))
5419 pom1=(sumene3*sint2tab(i+1)+sumene1) &
5420 *(pom_s1/dscp1+pom_s16*dscp1**4)
5421 pom2=(sumene4*cost2tab(i+1)+sumene2) &
5422 *(pom_s2/dscp2+pom_s26*dscp2**4)
5423 sumene1x=x(2)+2*x(5)*xx+x(8)*zz+ x(9)*yy
5424 sumene3x=x(22)+2*x(25)*xx+x(28)*zz+x(29)*yy+3*x(31)*xx**2 &
5425 +2*x(34)*xx*yy +2*x(35)*xx*zz +x(36)*(yy**2) +x(38)*(zz**2) &
5427 sumene2x=x(12)+2*x(15)*xx+x(18)*zz+ x(19)*yy
5428 sumene4x=x(42)+2*x(45)*xx +x(48)*zz +x(49)*yy +3*x(51)*xx**2 &
5429 +2*x(54)*xx*yy+2*x(55)*xx*zz+x(56)*(yy**2)+x(58)*(zz**2) &
5431 de_dxx =(sumene1x+sumene3x*sint2tab(i+1))*(s1+s1_6) &
5432 +(sumene2x+sumene4x*cost2tab(i+1))*(s2+s2_6) &
5435 write(2,*), "de_dxx = ", de_dxx,de_dxx_num,itype(i)
5438 sumene1y=x(3) + 2*x(6)*yy + x(9)*xx + x(10)*zz
5439 sumene3y=x(23) +2*x(26)*yy +x(29)*xx +x(30)*zz +3*x(32)*yy**2 &
5440 +x(34)*(xx**2) +2*x(36)*yy*xx +2*x(37)*yy*zz +x(39)*(zz**2) &
5442 sumene2y=x(13) + 2*x(16)*yy + x(19)*xx + x(20)*zz
5443 sumene4y=x(43)+2*x(46)*yy+x(49)*xx +x(50)*zz &
5444 +3*x(52)*yy**2+x(54)*xx**2+2*x(56)*yy*xx +2*x(57)*yy*zz &
5445 +x(59)*zz**2 +x(60)*xx*zz
5446 de_dyy =(sumene1y+sumene3y*sint2tab(i+1))*(s1+s1_6) &
5447 +(sumene2y+sumene4y*cost2tab(i+1))*(s2+s2_6) &
5450 write(2,*), "de_dyy = ", de_dyy,de_dyy_num,itype(i)
5453 de_dzz =(x(24) +2*x(27)*zz +x(28)*xx +x(30)*yy &
5454 +3*x(33)*zz**2 +x(35)*xx**2 +x(37)*yy**2 +2*x(38)*zz*xx &
5455 +2*x(39)*zz*yy +x(40)*xx*yy)*sint2tab(i+1)*(s1+s1_6) &
5456 +(x(4) + 2*x(7)*zz+ x(8)*xx + x(10)*yy)*(s1+s1_6) &
5457 +(x(44)+2*x(47)*zz +x(48)*xx +x(50)*yy +3*x(53)*zz**2 &
5458 +x(55)*xx**2 +x(57)*(yy**2)+2*x(58)*zz*xx +2*x(59)*zz*yy &
5459 +x(60)*xx*yy)*cost2tab(i+1)*(s2+s2_6) &
5460 + ( x(14) + 2*x(17)*zz+ x(18)*xx + x(20)*yy)*(s2+s2_6)
5462 write(2,*), "de_dzz = ", de_dzz,de_dzz_num,itype(i)
5465 de_dt = 0.5d0*sumene3*cost2tab(i+1)*(s1+s1_6) &
5466 -0.5d0*sumene4*sint2tab(i+1)*(s2+s2_6) &
5467 +pom1*pom_dt1+pom2*pom_dt2
5469 write(2,*), "de_dt = ", de_dt,de_dt_num,itype(i)
5473 cossc=scalar(dc_norm(1,i),dc_norm(1,i+nres))
5474 cossc1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
5475 cosfac2xx=cosfac2*xx
5476 sinfac2yy=sinfac2*yy
5478 dt_dCi(k) = -(dc_norm(k,i-1)+costtab(i+1)*dc_norm(k,i))* &
5480 dt_dCi1(k)= -(dc_norm(k,i)+costtab(i+1)*dc_norm(k,i-1))* &
5482 pom=(dC_norm(k,i+nres)-cossc*dC_norm(k,i))*vbld_inv(i+1)
5483 pom1=(dC_norm(k,i+nres)-cossc1*dC_norm(k,i-1))*vbld_inv(i)
5484 ! write (iout,*) "i",i," k",k," pom",pom," pom1",pom1,
5485 ! & " dt_dCi",dt_dCi(k)," dt_dCi1",dt_dCi1(k)
5486 ! write (iout,*) "dC_norm",(dC_norm(j,i),j=1,3),
5487 ! & (dC_norm(j,i-1),j=1,3)," vbld_inv",vbld_inv(i+1),vbld_inv(i)
5488 dXX_Ci(k)=pom*cosfac-dt_dCi(k)*cosfac2xx
5489 dXX_Ci1(k)=-pom1*cosfac-dt_dCi1(k)*cosfac2xx
5490 dYY_Ci(k)=pom*sinfac+dt_dCi(k)*sinfac2yy
5491 dYY_Ci1(k)=pom1*sinfac+dt_dCi1(k)*sinfac2yy
5495 dZZ_Ci(k)=dZZ_Ci(k)-uzgrad(j,k,2,i-1) &
5496 *dsign(1.0d0,dfloat(itype(i)))*dC_norm(j,i+nres)
5497 dZZ_Ci1(k)=dZZ_Ci1(k)-uzgrad(j,k,1,i-1) &
5498 *dsign(1.0d0,dfloat(itype(i)))*dC_norm(j,i+nres)
5501 dXX_XYZ(k)=vbld_inv(i+nres)*(x_prime(k)-xx*dC_norm(k,i+nres))
5502 dYY_XYZ(k)=vbld_inv(i+nres)*(y_prime(k)-yy*dC_norm(k,i+nres))
5503 dZZ_XYZ(k)=vbld_inv(i+nres)* &
5504 (z_prime(k)-zz*dC_norm(k,i+nres))
5506 dt_dCi(k) = -dt_dCi(k)/sinttab(i+1)
5507 dt_dCi1(k)= -dt_dCi1(k)/sinttab(i+1)
5511 dXX_Ctab(k,i)=dXX_Ci(k)
5512 dXX_C1tab(k,i)=dXX_Ci1(k)
5513 dYY_Ctab(k,i)=dYY_Ci(k)
5514 dYY_C1tab(k,i)=dYY_Ci1(k)
5515 dZZ_Ctab(k,i)=dZZ_Ci(k)
5516 dZZ_C1tab(k,i)=dZZ_Ci1(k)
5517 dXX_XYZtab(k,i)=dXX_XYZ(k)
5518 dYY_XYZtab(k,i)=dYY_XYZ(k)
5519 dZZ_XYZtab(k,i)=dZZ_XYZ(k)
5523 ! write (iout,*) "k",k," dxx_ci1",dxx_ci1(k)," dyy_ci1",
5524 ! & dyy_ci1(k)," dzz_ci1",dzz_ci1(k)
5525 ! write (iout,*) "k",k," dxx_ci",dxx_ci(k)," dyy_ci",
5526 ! & dyy_ci(k)," dzz_ci",dzz_ci(k)
5527 ! write (iout,*) "k",k," dt_dci",dt_dci(k)," dt_dci",
5529 ! write (iout,*) "k",k," dxx_XYZ",dxx_XYZ(k)," dyy_XYZ",
5530 ! & dyy_XYZ(k)," dzz_XYZ",dzz_XYZ(k)
5531 gscloc(k,i-1)=gscloc(k,i-1)+de_dxx*dxx_ci1(k) &
5532 +de_dyy*dyy_ci1(k)+de_dzz*dzz_ci1(k)+de_dt*dt_dCi1(k)
5533 gscloc(k,i)=gscloc(k,i)+de_dxx*dxx_Ci(k) &
5534 +de_dyy*dyy_Ci(k)+de_dzz*dzz_Ci(k)+de_dt*dt_dCi(k)
5535 gsclocx(k,i)= de_dxx*dxx_XYZ(k) &
5536 +de_dyy*dyy_XYZ(k)+de_dzz*dzz_XYZ(k)
5538 ! write(iout,*) "ENERGY GRAD = ", (gscloc(k,i-1),k=1,3),
5539 ! & (gscloc(k,i),k=1,3),(gsclocx(k,i),k=1,3)
5541 ! to check gradient call subroutine check_grad
5547 !-----------------------------------------------------------------------------
5548 real(kind=8) function enesc(x,xx,yy,zz,cost2,sint2)
5550 real(kind=8),dimension(65) :: x
5551 real(kind=8) :: xx,yy,zz,cost2,sint2,sumene1,sumene2,sumene3,&
5552 sumene4,sumene,dsc_i,dp2_i,dscp1,dscp2,s1,s1_6,s2,s2_6
5554 sumene1= x(1)+ x(2)*xx+ x(3)*yy+ x(4)*zz+ x(5)*xx**2 &
5555 + x(6)*yy**2+ x(7)*zz**2+ x(8)*xx*zz+ x(9)*xx*yy &
5557 sumene2= x(11) + x(12)*xx + x(13)*yy + x(14)*zz + x(15)*xx**2 &
5558 + x(16)*yy**2 + x(17)*zz**2 + x(18)*xx*zz + x(19)*xx*yy &
5560 sumene3= x(21) +x(22)*xx +x(23)*yy +x(24)*zz +x(25)*xx**2 &
5561 +x(26)*yy**2 +x(27)*zz**2 +x(28)*xx*zz +x(29)*xx*yy &
5562 +x(30)*yy*zz +x(31)*xx**3 +x(32)*yy**3 +x(33)*zz**3 &
5563 +x(34)*(xx**2)*yy +x(35)*(xx**2)*zz +x(36)*(yy**2)*xx &
5564 +x(37)*(yy**2)*zz +x(38)*(zz**2)*xx +x(39)*(zz**2)*yy &
5566 sumene4= x(41) +x(42)*xx +x(43)*yy +x(44)*zz +x(45)*xx**2 &
5567 +x(46)*yy**2 +x(47)*zz**2 +x(48)*xx*zz +x(49)*xx*yy &
5568 +x(50)*yy*zz +x(51)*xx**3 +x(52)*yy**3 +x(53)*zz**3 &
5569 +x(54)*(xx**2)*yy +x(55)*(xx**2)*zz +x(56)*(yy**2)*xx &
5570 +x(57)*(yy**2)*zz +x(58)*(zz**2)*xx +x(59)*(zz**2)*yy &
5572 dsc_i = 0.743d0+x(61)
5574 dscp1=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
5575 *(xx*cost2+yy*sint2))
5576 dscp2=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
5577 *(xx*cost2-yy*sint2))
5578 s1=(1+x(63))/(0.1d0 + dscp1)
5579 s1_6=(1+x(64))/(0.1d0 + dscp1**6)
5580 s2=(1+x(65))/(0.1d0 + dscp2)
5581 s2_6=(1+x(65))/(0.1d0 + dscp2**6)
5582 sumene = ( sumene3*sint2 + sumene1)*(s1+s1_6) &
5583 + (sumene4*cost2 +sumene2)*(s2+s2_6)
5588 !-----------------------------------------------------------------------------
5589 subroutine gcont(rij,r0ij,eps0ij,delta,fcont,fprimcont)
5591 ! This procedure calculates two-body contact function g(rij) and its derivative:
5594 ! g(rij) = esp0ij*(-0.9375*x+0.625*x**3-0.1875*x**5) ! -1 =< x =< 1
5597 ! where x=(rij-r0ij)/delta
5599 ! rij - interbody distance, r0ij - contact distance, eps0ij - contact energy
5602 real(kind=8) :: rij,r0ij,eps0ij,fcont,fprimcont
5603 real(kind=8) :: x,x2,x4,delta
5607 if (x.lt.-1.0D0) then
5610 else if (x.le.1.0D0) then
5613 fcont=eps0ij*(x*(-0.9375D0+0.6250D0*x2-0.1875D0*x4)+0.5D0)
5614 fprimcont=eps0ij * (-0.9375D0+1.8750D0*x2-0.9375D0*x4)/delta
5620 end subroutine gcont
5621 !-----------------------------------------------------------------------------
5622 subroutine splinthet(theti,delta,ss,ssder)
5623 ! implicit real*8 (a-h,o-z)
5624 ! include 'DIMENSIONS'
5625 ! include 'COMMON.VAR'
5626 ! include 'COMMON.GEO'
5627 real(kind=8) :: theti,delta,ss,ssder
5628 real(kind=8) :: thetup,thetlow
5631 if (theti.gt.pipol) then
5632 call gcont(theti,thetup,1.0d0,delta,ss,ssder)
5634 call gcont(-theti,-thetlow,1.0d0,delta,ss,ssder)
5638 end subroutine splinthet
5639 !-----------------------------------------------------------------------------
5640 subroutine spline1(x,x0,delta,f0,f1,fprim0,f,fprim)
5642 real(kind=8) :: x,x0,delta,f0,f1,fprim0,f,fprim
5643 real(kind=8) :: ksi,ksi2,ksi3,a1,a2,a3
5644 a1=fprim0*delta/(f1-f0)
5650 f=f0+(f1-f0)*ksi*(a1+ksi*(a2+a3*ksi))
5651 fprim=(f1-f0)/delta*(a1+ksi*(2*a2+3*ksi*a3))
5653 end subroutine spline1
5654 !-----------------------------------------------------------------------------
5655 subroutine spline2(x,x0,delta,f0x,f1x,fprim0x,fx)
5657 real(kind=8) :: x,x0,delta,f0x,f1x,fprim0x,fx
5658 real(kind=8) :: ksi,ksi2,ksi3,a1,a2,a3
5663 a2=3*(f1x-f0x)-2*fprim0x*delta
5664 a3=fprim0x*delta-2*(f1x-f0x)
5665 fx=f0x+a1*ksi+a2*ksi2+a3*ksi3
5667 end subroutine spline2
5668 !-----------------------------------------------------------------------------
5670 !-----------------------------------------------------------------------------
5671 subroutine etor(etors,edihcnstr)
5672 ! implicit real*8 (a-h,o-z)
5673 ! include 'DIMENSIONS'
5674 ! include 'COMMON.VAR'
5675 ! include 'COMMON.GEO'
5676 ! include 'COMMON.LOCAL'
5677 ! include 'COMMON.TORSION'
5678 ! include 'COMMON.INTERACT'
5679 ! include 'COMMON.DERIV'
5680 ! include 'COMMON.CHAIN'
5681 ! include 'COMMON.NAMES'
5682 ! include 'COMMON.IOUNITS'
5683 ! include 'COMMON.FFIELD'
5684 ! include 'COMMON.TORCNSTR'
5685 ! include 'COMMON.CONTROL'
5686 real(kind=8) :: etors,edihcnstr
5690 real(kind=8) :: phii,fac,etors_ii
5692 ! Set lprn=.true. for debugging
5696 do i=iphi_start,iphi_end
5698 if (itype(i-2).eq.ntyp1.or. itype(i-1).eq.ntyp1 &
5699 .or. itype(i).eq.ntyp1) cycle
5700 itori=itortyp(itype(i-2))
5701 itori1=itortyp(itype(i-1))
5704 ! Proline-Proline pair is a special case...
5705 if (itori.eq.3 .and. itori1.eq.3) then
5706 if (phii.gt.-dwapi3) then
5708 fac=1.0D0/(1.0D0-cosphi)
5709 etorsi=v1(1,3,3)*fac
5710 etorsi=etorsi+etorsi
5711 etors=etors+etorsi-v1(1,3,3)
5712 if (energy_dec) etors_ii=etors_ii+etorsi-v1(1,3,3)
5713 gloci=gloci-3*fac*etorsi*dsin(3*phii)
5716 v1ij=v1(j+1,itori,itori1)
5717 v2ij=v2(j+1,itori,itori1)
5720 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
5721 if (energy_dec) etors_ii=etors_ii+ &
5722 v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
5723 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
5727 v1ij=v1(j,itori,itori1)
5728 v2ij=v2(j,itori,itori1)
5731 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
5732 if (energy_dec) etors_ii=etors_ii+ &
5733 v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
5734 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
5737 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
5740 write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)') &
5741 restyp(itype(i-2)),i-2,restyp(itype(i-1)),i-1,itori,itori1,&
5742 (v1(j,itori,itori1),j=1,6),(v2(j,itori,itori1),j=1,6)
5743 gloc(i-3,icg)=gloc(i-3,icg)+wtor*gloci
5744 ! write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
5746 ! 6/20/98 - dihedral angle constraints
5749 itori=idih_constr(i)
5752 if (difi.gt.drange(i)) then
5754 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
5755 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
5756 else if (difi.lt.-drange(i)) then
5758 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
5759 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
5761 ! write (iout,'(2i5,2f8.3,2e14.5)') i,itori,rad2deg*phii,
5762 ! & rad2deg*difi,0.25d0*ftors*difi**4,gloc(itori-3,icg)
5764 ! write (iout,*) 'edihcnstr',edihcnstr
5767 !-----------------------------------------------------------------------------
5768 subroutine etor_d(etors_d)
5769 real(kind=8) :: etors_d
5772 end subroutine etor_d
5774 !-----------------------------------------------------------------------------
5775 subroutine etor(etors,edihcnstr)
5776 ! implicit real*8 (a-h,o-z)
5777 ! include 'DIMENSIONS'
5778 ! include 'COMMON.VAR'
5779 ! include 'COMMON.GEO'
5780 ! include 'COMMON.LOCAL'
5781 ! include 'COMMON.TORSION'
5782 ! include 'COMMON.INTERACT'
5783 ! include 'COMMON.DERIV'
5784 ! include 'COMMON.CHAIN'
5785 ! include 'COMMON.NAMES'
5786 ! include 'COMMON.IOUNITS'
5787 ! include 'COMMON.FFIELD'
5788 ! include 'COMMON.TORCNSTR'
5789 ! include 'COMMON.CONTROL'
5790 real(kind=8) :: etors,edihcnstr
5793 integer :: i,j,iblock,itori,itori1
5794 real(kind=8) :: phii,gloci,v1ij,v2ij,cosphi,sinphi,&
5795 vl1ij,vl2ij,vl3ij,pom1,difi,etors_ii,pom
5796 ! Set lprn=.true. for debugging
5800 do i=iphi_start,iphi_end
5801 if (itype(i-2).eq.ntyp1 .or. itype(i-1).eq.ntyp1 &
5802 .or. itype(i-3).eq.ntyp1 &
5803 .or. itype(i).eq.ntyp1) cycle
5805 if (iabs(itype(i)).eq.20) then
5810 itori=itortyp(itype(i-2))
5811 itori1=itortyp(itype(i-1))
5814 ! Regular cosine and sine terms
5815 do j=1,nterm(itori,itori1,iblock)
5816 v1ij=v1(j,itori,itori1,iblock)
5817 v2ij=v2(j,itori,itori1,iblock)
5820 etors=etors+v1ij*cosphi+v2ij*sinphi
5821 if (energy_dec) etors_ii=etors_ii+ &
5822 v1ij*cosphi+v2ij*sinphi
5823 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
5827 ! E = SUM ----------------------------------- - v1
5828 ! [v2 cos(phi/2)+v3 sin(phi/2)]^2 + 1
5830 cosphi=dcos(0.5d0*phii)
5831 sinphi=dsin(0.5d0*phii)
5832 do j=1,nlor(itori,itori1,iblock)
5833 vl1ij=vlor1(j,itori,itori1)
5834 vl2ij=vlor2(j,itori,itori1)
5835 vl3ij=vlor3(j,itori,itori1)
5836 pom=vl2ij*cosphi+vl3ij*sinphi
5837 pom1=1.0d0/(pom*pom+1.0d0)
5838 etors=etors+vl1ij*pom1
5839 if (energy_dec) etors_ii=etors_ii+ &
5842 gloci=gloci+vl1ij*(vl3ij*cosphi-vl2ij*sinphi)*pom
5844 ! Subtract the constant term
5845 etors=etors-v0(itori,itori1,iblock)
5846 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
5847 'etor',i,etors_ii-v0(itori,itori1,iblock)
5849 write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)') &
5850 restyp(itype(i-2)),i-2,restyp(itype(i-1)),i-1,itori,itori1,&
5851 (v1(j,itori,itori1,iblock),j=1,6),&
5852 (v2(j,itori,itori1,iblock),j=1,6)
5853 gloc(i-3,icg)=gloc(i-3,icg)+wtor*gloci
5854 ! write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
5856 ! 6/20/98 - dihedral angle constraints
5858 ! do i=1,ndih_constr
5859 do i=idihconstr_start,idihconstr_end
5860 itori=idih_constr(i)
5862 difi=pinorm(phii-phi0(i))
5863 if (difi.gt.drange(i)) then
5865 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
5866 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
5867 else if (difi.lt.-drange(i)) then
5869 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
5870 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
5874 !d write (iout,'(2i5,4f8.3,2e14.5)') i,itori,rad2deg*phii,
5875 !d & rad2deg*phi0(i), rad2deg*drange(i),
5876 !d & rad2deg*difi,0.25d0*ftors*difi**4,gloc(itori-3,icg)
5878 !d write (iout,*) 'edihcnstr',edihcnstr
5881 !-----------------------------------------------------------------------------
5882 subroutine etor_d(etors_d)
5883 ! 6/23/01 Compute double torsional energy
5884 ! implicit real*8 (a-h,o-z)
5885 ! include 'DIMENSIONS'
5886 ! include 'COMMON.VAR'
5887 ! include 'COMMON.GEO'
5888 ! include 'COMMON.LOCAL'
5889 ! include 'COMMON.TORSION'
5890 ! include 'COMMON.INTERACT'
5891 ! include 'COMMON.DERIV'
5892 ! include 'COMMON.CHAIN'
5893 ! include 'COMMON.NAMES'
5894 ! include 'COMMON.IOUNITS'
5895 ! include 'COMMON.FFIELD'
5896 ! include 'COMMON.TORCNSTR'
5897 real(kind=8) :: etors_d,etors_d_ii
5900 integer :: i,j,k,l,itori,itori1,itori2,iblock
5901 real(kind=8) :: phii,phii1,gloci1,gloci2,&
5902 v1cij,v1sij,v2cij,v2sij,cosphi1,sinphi1,&
5903 sinphi2,cosphi2,v1cdij,v2cdij,v1sdij,v2sdij,&
5904 cosphi1p2,cosphi1m2,sinphi1p2,sinphi1m2
5905 ! Set lprn=.true. for debugging
5909 ! write(iout,*) "a tu??"
5910 do i=iphid_start,iphid_end
5912 if (itype(i-2).eq.ntyp1 .or. itype(i-1).eq.ntyp1 &
5913 .or. itype(i-3).eq.ntyp1 &
5914 .or. itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1) cycle
5915 itori=itortyp(itype(i-2))
5916 itori1=itortyp(itype(i-1))
5917 itori2=itortyp(itype(i))
5923 if (iabs(itype(i+1)).eq.20) iblock=2
5925 ! Regular cosine and sine terms
5926 do j=1,ntermd_1(itori,itori1,itori2,iblock)
5927 v1cij=v1c(1,j,itori,itori1,itori2,iblock)
5928 v1sij=v1s(1,j,itori,itori1,itori2,iblock)
5929 v2cij=v1c(2,j,itori,itori1,itori2,iblock)
5930 v2sij=v1s(2,j,itori,itori1,itori2,iblock)
5931 cosphi1=dcos(j*phii)
5932 sinphi1=dsin(j*phii)
5933 cosphi2=dcos(j*phii1)
5934 sinphi2=dsin(j*phii1)
5935 etors_d=etors_d+v1cij*cosphi1+v1sij*sinphi1+ &
5936 v2cij*cosphi2+v2sij*sinphi2
5937 if (energy_dec) etors_d_ii=etors_d_ii+ &
5938 v1cij*cosphi1+v1sij*sinphi1+v2cij*cosphi2+v2sij*sinphi2
5939 gloci1=gloci1+j*(v1sij*cosphi1-v1cij*sinphi1)
5940 gloci2=gloci2+j*(v2sij*cosphi2-v2cij*sinphi2)
5942 do k=2,ntermd_2(itori,itori1,itori2,iblock)
5944 v1cdij = v2c(k,l,itori,itori1,itori2,iblock)
5945 v2cdij = v2c(l,k,itori,itori1,itori2,iblock)
5946 v1sdij = v2s(k,l,itori,itori1,itori2,iblock)
5947 v2sdij = v2s(l,k,itori,itori1,itori2,iblock)
5948 cosphi1p2=dcos(l*phii+(k-l)*phii1)
5949 cosphi1m2=dcos(l*phii-(k-l)*phii1)
5950 sinphi1p2=dsin(l*phii+(k-l)*phii1)
5951 sinphi1m2=dsin(l*phii-(k-l)*phii1)
5952 etors_d=etors_d+v1cdij*cosphi1p2+v2cdij*cosphi1m2+ &
5953 v1sdij*sinphi1p2+v2sdij*sinphi1m2
5954 if (energy_dec) etors_d_ii=etors_d_ii+ &
5955 v1cdij*cosphi1p2+v2cdij*cosphi1m2+ &
5956 v1sdij*sinphi1p2+v2sdij*sinphi1m2
5957 gloci1=gloci1+l*(v1sdij*cosphi1p2+v2sdij*cosphi1m2 &
5958 -v1cdij*sinphi1p2-v2cdij*sinphi1m2)
5959 gloci2=gloci2+(k-l)*(v1sdij*cosphi1p2-v2sdij*cosphi1m2 &
5960 -v1cdij*sinphi1p2+v2cdij*sinphi1m2)
5963 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
5964 'etor_d',i,etors_d_ii
5965 gloc(i-3,icg)=gloc(i-3,icg)+wtor_d*gloci1
5966 gloc(i-2,icg)=gloc(i-2,icg)+wtor_d*gloci2
5969 end subroutine etor_d
5971 !-----------------------------------------------------------------------------
5972 subroutine eback_sc_corr(esccor)
5973 ! 7/21/2007 Correlations between the backbone-local and side-chain-local
5974 ! conformational states; temporarily implemented as differences
5975 ! between UNRES torsional potentials (dependent on three types of
5976 ! residues) and the torsional potentials dependent on all 20 types
5977 ! of residues computed from AM1 energy surfaces of terminally-blocked
5978 ! amino-acid residues.
5979 ! implicit real*8 (a-h,o-z)
5980 ! include 'DIMENSIONS'
5981 ! include 'COMMON.VAR'
5982 ! include 'COMMON.GEO'
5983 ! include 'COMMON.LOCAL'
5984 ! include 'COMMON.TORSION'
5985 ! include 'COMMON.SCCOR'
5986 ! include 'COMMON.INTERACT'
5987 ! include 'COMMON.DERIV'
5988 ! include 'COMMON.CHAIN'
5989 ! include 'COMMON.NAMES'
5990 ! include 'COMMON.IOUNITS'
5991 ! include 'COMMON.FFIELD'
5992 ! include 'COMMON.CONTROL'
5993 real(kind=8) :: esccor,esccor_ii,phii,gloci,v1ij,v2ij,&
5996 integer :: i,interty,j,isccori,isccori1,intertyp
5997 ! Set lprn=.true. for debugging
6000 ! write (iout,*) "EBACK_SC_COR",itau_start,itau_end
6002 do i=itau_start,itau_end
6003 if ((itype(i-2).eq.ntyp1).or.(itype(i-1).eq.ntyp1)) cycle
6005 isccori=isccortyp(itype(i-2))
6006 isccori1=isccortyp(itype(i-1))
6008 ! write (iout,*) "EBACK_SC_COR",i,nterm_sccor(isccori,isccori1)
6010 do intertyp=1,3 !intertyp
6012 !c Added 09 May 2012 (Adasko)
6013 !c Intertyp means interaction type of backbone mainchain correlation:
6014 ! 1 = SC...Ca...Ca...Ca
6015 ! 2 = Ca...Ca...Ca...SC
6016 ! 3 = SC...Ca...Ca...SCi
6018 if (((intertyp.eq.3).and.((itype(i-2).eq.10).or. &
6019 (itype(i-1).eq.10).or.(itype(i-2).eq.ntyp1).or. &
6020 (itype(i-1).eq.ntyp1))) &
6021 .or. ((intertyp.eq.1).and.((itype(i-2).eq.10) &
6022 .or.(itype(i-2).eq.ntyp1).or.(itype(i-1).eq.ntyp1) &
6023 .or.(itype(i).eq.ntyp1))) &
6024 .or.((intertyp.eq.2).and.((itype(i-1).eq.10).or. &
6025 (itype(i-1).eq.ntyp1).or.(itype(i-2).eq.ntyp1).or. &
6026 (itype(i-3).eq.ntyp1)))) cycle
6027 if ((intertyp.eq.2).and.(i.eq.4).and.(itype(1).eq.ntyp1)) cycle
6028 if ((intertyp.eq.1).and.(i.eq.nres).and.(itype(nres).eq.ntyp1)) &
6030 do j=1,nterm_sccor(isccori,isccori1)
6031 v1ij=v1sccor(j,intertyp,isccori,isccori1)
6032 v2ij=v2sccor(j,intertyp,isccori,isccori1)
6033 cosphi=dcos(j*tauangle(intertyp,i))
6034 sinphi=dsin(j*tauangle(intertyp,i))
6035 if (energy_dec) esccor_ii=esccor_ii+v1ij*cosphi+v2ij*sinphi
6036 esccor=esccor+v1ij*cosphi+v2ij*sinphi
6037 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
6039 if (energy_dec) write (iout,'(a6,i5,i2,0pf7.3)') &
6040 'esccor',i,intertyp,esccor_ii
6041 ! write (iout,*) "EBACK_SC_COR",i,v1ij*cosphi+v2ij*sinphi,intertyp
6042 gloc_sc(intertyp,i-3,icg)=gloc_sc(intertyp,i-3,icg)+wsccor*gloci
6044 write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)') &
6045 restyp(itype(i-2)),i-2,restyp(itype(i-1)),i-1,isccori,isccori1,&
6046 (v1sccor(j,intertyp,isccori,isccori1),j=1,6),&
6047 (v2sccor(j,intertyp,isccori,isccori1),j=1,6)
6048 gsccor_loc(i-3)=gsccor_loc(i-3)+gloci
6053 end subroutine eback_sc_corr
6054 !-----------------------------------------------------------------------------
6055 subroutine multibody(ecorr)
6056 ! This subroutine calculates multi-body contributions to energy following
6057 ! the idea of Skolnick et al. If side chains I and J make a contact and
6058 ! at the same time side chains I+1 and J+1 make a contact, an extra
6059 ! contribution equal to sqrt(eps(i,j)*eps(i+1,j+1)) is added.
6060 ! implicit real*8 (a-h,o-z)
6061 ! include 'DIMENSIONS'
6062 ! include 'COMMON.IOUNITS'
6063 ! include 'COMMON.DERIV'
6064 ! include 'COMMON.INTERACT'
6065 ! include 'COMMON.CONTACTS'
6066 real(kind=8),dimension(3) :: gx,gx1
6068 real(kind=8) :: ecorr
6069 integer :: i,j,ishift,i1,num_conti,num_conti1,j1,jj,kk
6070 ! Set lprn=.true. for debugging
6074 write (iout,'(a)') 'Contact function values:'
6076 write (iout,'(i2,20(1x,i2,f10.5))') &
6077 i,(jcont(j,i),facont(j,i),j=1,num_cont(i))
6082 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres))
6083 ! if (.not.allocated(gradxorr)) allocate(gradxorr(3,nres))
6095 num_conti=num_cont(i)
6096 num_conti1=num_cont(i1)
6101 if (j1.eq.j+ishift .or. j1.eq.j-ishift) then
6102 !d write(iout,*)'i=',i,' j=',j,' i1=',i1,' j1=',j1,
6103 !d & ' ishift=',ishift
6104 ! Contacts I--J and I+ISHIFT--J+-ISHIFT1 occur simultaneously.
6105 ! The system gains extra energy.
6106 ecorr=ecorr+esccorr(i,j,i1,j1,jj,kk)
6107 endif ! j1==j+-ishift
6115 end subroutine multibody
6116 !-----------------------------------------------------------------------------
6117 real(kind=8) function esccorr(i,j,k,l,jj,kk)
6118 ! implicit real*8 (a-h,o-z)
6119 ! include 'DIMENSIONS'
6120 ! include 'COMMON.IOUNITS'
6121 ! include 'COMMON.DERIV'
6122 ! include 'COMMON.INTERACT'
6123 ! include 'COMMON.CONTACTS'
6124 real(kind=8),dimension(3) :: gx,gx1
6126 integer :: i,j,k,l,jj,kk,m,ll
6127 real(kind=8) :: eij,ekl
6131 !d write (iout,'(4i5,3f10.5)') i,j,k,l,eij,ekl,-eij*ekl
6132 ! Calculate the multi-body contribution to energy.
6133 ! Calculate multi-body contributions to the gradient.
6134 !d write (iout,'(2(2i3,3f10.5))')i,j,(gacont(m,jj,i),m=1,3),
6135 !d & k,l,(gacont(m,kk,k),m=1,3)
6137 gx(m) =ekl*gacont(m,jj,i)
6138 gx1(m)=eij*gacont(m,kk,k)
6139 gradxorr(m,i)=gradxorr(m,i)-gx(m)
6140 gradxorr(m,j)=gradxorr(m,j)+gx(m)
6141 gradxorr(m,k)=gradxorr(m,k)-gx1(m)
6142 gradxorr(m,l)=gradxorr(m,l)+gx1(m)
6146 gradcorr(ll,m)=gradcorr(ll,m)+gx(ll)
6151 gradcorr(ll,m)=gradcorr(ll,m)+gx1(ll)
6156 end function esccorr
6157 !-----------------------------------------------------------------------------
6158 subroutine multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
6159 ! This subroutine calculates multi-body contributions to hydrogen-bonding
6160 ! implicit real*8 (a-h,o-z)
6161 ! include 'DIMENSIONS'
6162 ! include 'COMMON.IOUNITS'
6165 ! integer :: maxconts !max_cont=maxconts =nres/4
6166 integer,parameter :: max_dim=26
6167 integer :: source,CorrelType,CorrelID,CorrelType1,CorrelID1,Error
6168 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
6169 !el real(kind=8) :: zapas(max_dim,maxconts,nfgtasks)
6170 !el common /przechowalnia/ zapas
6171 integer :: status(MPI_STATUS_SIZE)
6172 integer,dimension((nres/4)*2) :: req !maxconts*2
6173 integer :: status_array(MPI_STATUS_SIZE,(nres/4)*2),nn,ireq,ierr
6175 ! include 'COMMON.SETUP'
6176 ! include 'COMMON.FFIELD'
6177 ! include 'COMMON.DERIV'
6178 ! include 'COMMON.INTERACT'
6179 ! include 'COMMON.CONTACTS'
6180 ! include 'COMMON.CONTROL'
6181 ! include 'COMMON.LOCAL'
6182 real(kind=8),dimension(3) :: gx,gx1
6183 real(kind=8) :: time00,ecorr,ecorr5,ecorr6
6184 logical :: lprn,ldone
6186 integer :: i,j,ii,k,n_corr,n_corr1,i1,num_conti,num_conti1,&
6187 jj,jp,kk,j1,jp1,jjc,iii,nnn,iproc
6189 ! Set lprn=.true. for debugging
6193 if(.not.allocated(zapas)) allocate(zapas(max_dim,maxconts,nfgtasks))
6196 if (nfgtasks.le.1) goto 30
6198 write (iout,'(a)') 'Contact function values before RECEIVE:'
6200 write (iout,'(2i3,50(1x,i2,f5.2))') &
6201 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
6206 do i=1,ntask_cont_from
6209 do i=1,ntask_cont_to
6212 ! write (iout,*) "ntask_cont_from",ntask_cont_from," ntask_cont_to",
6214 ! Make the list of contacts to send to send to other procesors
6215 ! write (iout,*) "limits",max0(iturn4_end-1,iatel_s),iturn3_end
6217 do i=iturn3_start,iturn3_end
6218 ! write (iout,*) "make contact list turn3",i," num_cont",
6220 call add_hb_contact(i,i+2,iturn3_sent_local(1,i))
6222 do i=iturn4_start,iturn4_end
6223 ! write (iout,*) "make contact list turn4",i," num_cont",
6225 call add_hb_contact(i,i+3,iturn4_sent_local(1,i))
6229 ! write (iout,*) "make contact list longrange",i,ii," num_cont",
6231 do j=1,num_cont_hb(i)
6234 iproc=iint_sent_local(k,jjc,ii)
6235 ! write (iout,*) "i",i," j",j," k",k," jjc",jjc," iproc",iproc
6236 if (iproc.gt.0) then
6237 ncont_sent(iproc)=ncont_sent(iproc)+1
6238 nn=ncont_sent(iproc)
6240 zapas(2,nn,iproc)=jjc
6241 zapas(3,nn,iproc)=facont_hb(j,i)
6242 zapas(4,nn,iproc)=ees0p(j,i)
6243 zapas(5,nn,iproc)=ees0m(j,i)
6244 zapas(6,nn,iproc)=gacont_hbr(1,j,i)
6245 zapas(7,nn,iproc)=gacont_hbr(2,j,i)
6246 zapas(8,nn,iproc)=gacont_hbr(3,j,i)
6247 zapas(9,nn,iproc)=gacontm_hb1(1,j,i)
6248 zapas(10,nn,iproc)=gacontm_hb1(2,j,i)
6249 zapas(11,nn,iproc)=gacontm_hb1(3,j,i)
6250 zapas(12,nn,iproc)=gacontp_hb1(1,j,i)
6251 zapas(13,nn,iproc)=gacontp_hb1(2,j,i)
6252 zapas(14,nn,iproc)=gacontp_hb1(3,j,i)
6253 zapas(15,nn,iproc)=gacontm_hb2(1,j,i)
6254 zapas(16,nn,iproc)=gacontm_hb2(2,j,i)
6255 zapas(17,nn,iproc)=gacontm_hb2(3,j,i)
6256 zapas(18,nn,iproc)=gacontp_hb2(1,j,i)
6257 zapas(19,nn,iproc)=gacontp_hb2(2,j,i)
6258 zapas(20,nn,iproc)=gacontp_hb2(3,j,i)
6259 zapas(21,nn,iproc)=gacontm_hb3(1,j,i)
6260 zapas(22,nn,iproc)=gacontm_hb3(2,j,i)
6261 zapas(23,nn,iproc)=gacontm_hb3(3,j,i)
6262 zapas(24,nn,iproc)=gacontp_hb3(1,j,i)
6263 zapas(25,nn,iproc)=gacontp_hb3(2,j,i)
6264 zapas(26,nn,iproc)=gacontp_hb3(3,j,i)
6271 "Numbers of contacts to be sent to other processors",&
6272 (ncont_sent(i),i=1,ntask_cont_to)
6273 write (iout,*) "Contacts sent"
6274 do ii=1,ntask_cont_to
6276 iproc=itask_cont_to(ii)
6277 write (iout,*) nn," contacts to processor",iproc,&
6278 " of CONT_TO_COMM group"
6280 write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
6288 CorrelID1=nfgtasks+fg_rank+1
6290 ! Receive the numbers of needed contacts from other processors
6291 do ii=1,ntask_cont_from
6292 iproc=itask_cont_from(ii)
6294 call MPI_Irecv(ncont_recv(ii),1,MPI_INTEGER,iproc,CorrelType,&
6295 FG_COMM,req(ireq),IERR)
6297 ! write (iout,*) "IRECV ended"
6299 ! Send the number of contacts needed by other processors
6300 do ii=1,ntask_cont_to
6301 iproc=itask_cont_to(ii)
6303 call MPI_Isend(ncont_sent(ii),1,MPI_INTEGER,iproc,CorrelType,&
6304 FG_COMM,req(ireq),IERR)
6306 ! write (iout,*) "ISEND ended"
6307 ! write (iout,*) "number of requests (nn)",ireq
6310 call MPI_Waitall(ireq,req,status_array,ierr)
6312 ! & "Numbers of contacts to be received from other processors",
6313 ! & (ncont_recv(i),i=1,ntask_cont_from)
6317 do ii=1,ntask_cont_from
6318 iproc=itask_cont_from(ii)
6320 ! write (iout,*) "Receiving",nn," contacts from processor",iproc,
6321 ! & " of CONT_TO_COMM group"
6325 call MPI_Irecv(zapas_recv(1,1,ii),nn*max_dim,&
6326 MPI_DOUBLE_PRECISION,iproc,CorrelType1,FG_COMM,req(ireq),IERR)
6327 ! write (iout,*) "ireq,req",ireq,req(ireq)
6330 ! Send the contacts to processors that need them
6331 do ii=1,ntask_cont_to
6332 iproc=itask_cont_to(ii)
6334 ! write (iout,*) nn," contacts to processor",iproc,
6335 ! & " of CONT_TO_COMM group"
6338 call MPI_Isend(zapas(1,1,ii),nn*max_dim,MPI_DOUBLE_PRECISION,&
6339 iproc,CorrelType1,FG_COMM,req(ireq),IERR)
6340 ! write (iout,*) "ireq,req",ireq,req(ireq)
6342 ! write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
6346 ! write (iout,*) "number of requests (contacts)",ireq
6347 ! write (iout,*) "req",(req(i),i=1,4)
6350 call MPI_Waitall(ireq,req,status_array,ierr)
6351 do iii=1,ntask_cont_from
6352 iproc=itask_cont_from(iii)
6355 write (iout,*) "Received",nn," contacts from processor",iproc,&
6356 " of CONT_FROM_COMM group"
6359 write(iout,'(2f5.0,4f10.5)')(zapas_recv(j,i,iii),j=1,5)
6364 ii=zapas_recv(1,i,iii)
6365 ! Flag the received contacts to prevent double-counting
6366 jj=-zapas_recv(2,i,iii)
6367 ! write (iout,*) "iii",iii," i",i," ii",ii," jj",jj
6369 nnn=num_cont_hb(ii)+1
6372 facont_hb(nnn,ii)=zapas_recv(3,i,iii)
6373 ees0p(nnn,ii)=zapas_recv(4,i,iii)
6374 ees0m(nnn,ii)=zapas_recv(5,i,iii)
6375 gacont_hbr(1,nnn,ii)=zapas_recv(6,i,iii)
6376 gacont_hbr(2,nnn,ii)=zapas_recv(7,i,iii)
6377 gacont_hbr(3,nnn,ii)=zapas_recv(8,i,iii)
6378 gacontm_hb1(1,nnn,ii)=zapas_recv(9,i,iii)
6379 gacontm_hb1(2,nnn,ii)=zapas_recv(10,i,iii)
6380 gacontm_hb1(3,nnn,ii)=zapas_recv(11,i,iii)
6381 gacontp_hb1(1,nnn,ii)=zapas_recv(12,i,iii)
6382 gacontp_hb1(2,nnn,ii)=zapas_recv(13,i,iii)
6383 gacontp_hb1(3,nnn,ii)=zapas_recv(14,i,iii)
6384 gacontm_hb2(1,nnn,ii)=zapas_recv(15,i,iii)
6385 gacontm_hb2(2,nnn,ii)=zapas_recv(16,i,iii)
6386 gacontm_hb2(3,nnn,ii)=zapas_recv(17,i,iii)
6387 gacontp_hb2(1,nnn,ii)=zapas_recv(18,i,iii)
6388 gacontp_hb2(2,nnn,ii)=zapas_recv(19,i,iii)
6389 gacontp_hb2(3,nnn,ii)=zapas_recv(20,i,iii)
6390 gacontm_hb3(1,nnn,ii)=zapas_recv(21,i,iii)
6391 gacontm_hb3(2,nnn,ii)=zapas_recv(22,i,iii)
6392 gacontm_hb3(3,nnn,ii)=zapas_recv(23,i,iii)
6393 gacontp_hb3(1,nnn,ii)=zapas_recv(24,i,iii)
6394 gacontp_hb3(2,nnn,ii)=zapas_recv(25,i,iii)
6395 gacontp_hb3(3,nnn,ii)=zapas_recv(26,i,iii)
6400 write (iout,'(a)') 'Contact function values after receive:'
6402 write (iout,'(2i3,50(1x,i3,f5.2))') &
6403 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
6411 write (iout,'(a)') 'Contact function values:'
6413 write (iout,'(2i3,50(1x,i3,f5.2))') &
6414 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
6420 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres))
6421 ! if (.not.allocated(gradxorr)) allocate(gradxorr(3,nres))
6422 ! Remove the loop below after debugging !!!
6429 ! Calculate the local-electrostatic correlation terms
6430 do i=min0(iatel_s,iturn4_start),max0(iatel_e,iturn3_end)
6432 num_conti=num_cont_hb(i)
6433 num_conti1=num_cont_hb(i+1)
6440 ! write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,&
6441 ! ' jj=',jj,' kk=',kk,"jp=",jp,"jp1",jp1
6442 if ((j.gt.0 .and. j1.gt.0 .or. j.gt.0 .and. j1.lt.0 &
6443 .or. j.lt.0 .and. j1.gt.0) .and. &
6444 (jp1.eq.jp+1 .or. jp1.eq.jp-1)) then
6445 ! Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
6446 ! The system gains extra energy.
6447 ecorr=ecorr+ehbcorr(i,jp,i+1,jp1,jj,kk,0.72D0,0.32D0)
6448 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
6449 'ecorrh',i,j,ehbcorr(i,jp,i+1,jp1,jj,kk,0.72D0,0.32D0)
6451 else if (j1.eq.j) then
6452 ! Contacts I-J and I-(J+1) occur simultaneously.
6453 ! The system loses extra energy.
6454 ! ecorr=ecorr+ehbcorr(i,j,i+1,j,jj,kk,0.60D0,-0.40D0)
6459 ! write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
6460 ! & ' jj=',jj,' kk=',kk
6462 ! Contacts I-J and (I+1)-J occur simultaneously.
6463 ! The system loses extra energy.
6464 ! ecorr=ecorr+ehbcorr(i,j,i,j+1,jj,kk,0.60D0,-0.40D0)
6470 end subroutine multibody_hb
6471 !-----------------------------------------------------------------------------
6472 subroutine add_hb_contact(ii,jj,itask)
6473 ! implicit real*8 (a-h,o-z)
6474 ! include "DIMENSIONS"
6475 ! include "COMMON.IOUNITS"
6476 ! include "COMMON.CONTACTS"
6477 ! integer,parameter :: maxconts=nres/4
6478 integer,parameter :: max_dim=26
6479 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
6480 ! real(kind=8) :: zapas(max_dim,maxconts,nfgtasks)
6481 ! common /przechowalnia/ zapas
6482 integer :: i,j,ii,jj,iproc,nn,jjc
6483 integer,dimension(4) :: itask
6484 ! write (iout,*) "itask",itask
6487 if (iproc.gt.0) then
6488 do j=1,num_cont_hb(ii)
6490 ! write (iout,*) "i",ii," j",jj," jjc",jjc
6492 ncont_sent(iproc)=ncont_sent(iproc)+1
6493 nn=ncont_sent(iproc)
6494 zapas(1,nn,iproc)=ii
6495 zapas(2,nn,iproc)=jjc
6496 zapas(3,nn,iproc)=facont_hb(j,ii)
6497 zapas(4,nn,iproc)=ees0p(j,ii)
6498 zapas(5,nn,iproc)=ees0m(j,ii)
6499 zapas(6,nn,iproc)=gacont_hbr(1,j,ii)
6500 zapas(7,nn,iproc)=gacont_hbr(2,j,ii)
6501 zapas(8,nn,iproc)=gacont_hbr(3,j,ii)
6502 zapas(9,nn,iproc)=gacontm_hb1(1,j,ii)
6503 zapas(10,nn,iproc)=gacontm_hb1(2,j,ii)
6504 zapas(11,nn,iproc)=gacontm_hb1(3,j,ii)
6505 zapas(12,nn,iproc)=gacontp_hb1(1,j,ii)
6506 zapas(13,nn,iproc)=gacontp_hb1(2,j,ii)
6507 zapas(14,nn,iproc)=gacontp_hb1(3,j,ii)
6508 zapas(15,nn,iproc)=gacontm_hb2(1,j,ii)
6509 zapas(16,nn,iproc)=gacontm_hb2(2,j,ii)
6510 zapas(17,nn,iproc)=gacontm_hb2(3,j,ii)
6511 zapas(18,nn,iproc)=gacontp_hb2(1,j,ii)
6512 zapas(19,nn,iproc)=gacontp_hb2(2,j,ii)
6513 zapas(20,nn,iproc)=gacontp_hb2(3,j,ii)
6514 zapas(21,nn,iproc)=gacontm_hb3(1,j,ii)
6515 zapas(22,nn,iproc)=gacontm_hb3(2,j,ii)
6516 zapas(23,nn,iproc)=gacontm_hb3(3,j,ii)
6517 zapas(24,nn,iproc)=gacontp_hb3(1,j,ii)
6518 zapas(25,nn,iproc)=gacontp_hb3(2,j,ii)
6519 zapas(26,nn,iproc)=gacontp_hb3(3,j,ii)
6526 end subroutine add_hb_contact
6527 !-----------------------------------------------------------------------------
6528 subroutine multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
6529 ! This subroutine calculates multi-body contributions to hydrogen-bonding
6530 ! implicit real*8 (a-h,o-z)
6531 ! include 'DIMENSIONS'
6532 ! include 'COMMON.IOUNITS'
6533 integer,parameter :: max_dim=70
6536 ! integer :: maxconts !max_cont=maxconts=nres/4
6537 integer :: source,CorrelType,CorrelID,CorrelType1,CorrelID1,Error
6538 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks)
6539 ! real(kind=8) :: zapas(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
6540 ! common /przechowalnia/ zapas
6541 integer :: status(MPI_STATUS_SIZE),req((nres/4)*2),&
6542 status_array(MPI_STATUS_SIZE,(nres/4)*2),jjc,iproc,ireq,nn,ind,&
6545 ! include 'COMMON.SETUP'
6546 ! include 'COMMON.FFIELD'
6547 ! include 'COMMON.DERIV'
6548 ! include 'COMMON.LOCAL'
6549 ! include 'COMMON.INTERACT'
6550 ! include 'COMMON.CONTACTS'
6551 ! include 'COMMON.CHAIN'
6552 ! include 'COMMON.CONTROL'
6553 real(kind=8),dimension(3) :: gx,gx1
6554 integer,dimension(nres) :: num_cont_hb_old
6555 logical :: lprn,ldone
6556 !EL double precision eello4,eello5,eelo6,eello_turn6
6557 !EL external eello4,eello5,eello6,eello_turn6
6559 integer :: i,ii,j,k,l,jj,kk,ll,mm,n_corr,n_corr1,num_conti,jp,&
6560 j1,jp1,i1,num_conti1
6561 real(kind=8) :: sqd1,sqd2,sred_geom,fac_prim1,fac_prim2,fprimcont
6562 real(kind=8) :: ecorr,ecorr5,ecorr6,eturn6
6564 ! Set lprn=.true. for debugging
6569 if(.not.allocated(zapas)) allocate(zapas(max_dim,maxconts,nfgtasks))
6571 num_cont_hb_old(i)=num_cont_hb(i)
6575 if (nfgtasks.le.1) goto 30
6577 write (iout,'(a)') 'Contact function values before RECEIVE:'
6579 write (iout,'(2i3,50(1x,i2,f5.2))') &
6580 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
6585 do i=1,ntask_cont_from
6588 do i=1,ntask_cont_to
6591 ! write (iout,*) "ntask_cont_from",ntask_cont_from," ntask_cont_to",
6593 ! Make the list of contacts to send to send to other procesors
6594 do i=iturn3_start,iturn3_end
6595 ! write (iout,*) "make contact list turn3",i," num_cont",
6597 call add_hb_contact_eello(i,i+2,iturn3_sent_local(1,i))
6599 do i=iturn4_start,iturn4_end
6600 ! write (iout,*) "make contact list turn4",i," num_cont",
6602 call add_hb_contact_eello(i,i+3,iturn4_sent_local(1,i))
6606 ! write (iout,*) "make contact list longrange",i,ii," num_cont",
6608 do j=1,num_cont_hb(i)
6611 iproc=iint_sent_local(k,jjc,ii)
6612 ! write (iout,*) "i",i," j",j," k",k," jjc",jjc," iproc",iproc
6613 if (iproc.ne.0) then
6614 ncont_sent(iproc)=ncont_sent(iproc)+1
6615 nn=ncont_sent(iproc)
6617 zapas(2,nn,iproc)=jjc
6618 zapas(3,nn,iproc)=d_cont(j,i)
6622 zapas(ind,nn,iproc)=grij_hb_cont(kk,j,i)
6627 zapas(ind,nn,iproc)=a_chuj(ll,kk,j,i)
6635 zapas(ind,nn,iproc)=a_chuj_der(mm,ll,kk,jj,j,i)
6646 "Numbers of contacts to be sent to other processors",&
6647 (ncont_sent(i),i=1,ntask_cont_to)
6648 write (iout,*) "Contacts sent"
6649 do ii=1,ntask_cont_to
6651 iproc=itask_cont_to(ii)
6652 write (iout,*) nn," contacts to processor",iproc,&
6653 " of CONT_TO_COMM group"
6655 write(iout,'(2f5.0,10f10.5)')(zapas(j,i,ii),j=1,10)
6663 CorrelID1=nfgtasks+fg_rank+1
6665 ! Receive the numbers of needed contacts from other processors
6666 do ii=1,ntask_cont_from
6667 iproc=itask_cont_from(ii)
6669 call MPI_Irecv(ncont_recv(ii),1,MPI_INTEGER,iproc,CorrelType,&
6670 FG_COMM,req(ireq),IERR)
6672 ! write (iout,*) "IRECV ended"
6674 ! Send the number of contacts needed by other processors
6675 do ii=1,ntask_cont_to
6676 iproc=itask_cont_to(ii)
6678 call MPI_Isend(ncont_sent(ii),1,MPI_INTEGER,iproc,CorrelType,&
6679 FG_COMM,req(ireq),IERR)
6681 ! write (iout,*) "ISEND ended"
6682 ! write (iout,*) "number of requests (nn)",ireq
6685 call MPI_Waitall(ireq,req,status_array,ierr)
6687 ! & "Numbers of contacts to be received from other processors",
6688 ! & (ncont_recv(i),i=1,ntask_cont_from)
6692 do ii=1,ntask_cont_from
6693 iproc=itask_cont_from(ii)
6695 ! write (iout,*) "Receiving",nn," contacts from processor",iproc,
6696 ! & " of CONT_TO_COMM group"
6700 call MPI_Irecv(zapas_recv(1,1,ii),nn*max_dim,&
6701 MPI_DOUBLE_PRECISION,iproc,CorrelType1,FG_COMM,req(ireq),IERR)
6702 ! write (iout,*) "ireq,req",ireq,req(ireq)
6705 ! Send the contacts to processors that need them
6706 do ii=1,ntask_cont_to
6707 iproc=itask_cont_to(ii)
6709 ! write (iout,*) nn," contacts to processor",iproc,
6710 ! & " of CONT_TO_COMM group"
6713 call MPI_Isend(zapas(1,1,ii),nn*max_dim,MPI_DOUBLE_PRECISION,&
6714 iproc,CorrelType1,FG_COMM,req(ireq),IERR)
6715 ! write (iout,*) "ireq,req",ireq,req(ireq)
6717 ! write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
6721 ! write (iout,*) "number of requests (contacts)",ireq
6722 ! write (iout,*) "req",(req(i),i=1,4)
6725 call MPI_Waitall(ireq,req,status_array,ierr)
6726 do iii=1,ntask_cont_from
6727 iproc=itask_cont_from(iii)
6730 write (iout,*) "Received",nn," contacts from processor",iproc,&
6731 " of CONT_FROM_COMM group"
6734 write(iout,'(2f5.0,10f10.5)')(zapas_recv(j,i,iii),j=1,10)
6739 ii=zapas_recv(1,i,iii)
6740 ! Flag the received contacts to prevent double-counting
6741 jj=-zapas_recv(2,i,iii)
6742 ! write (iout,*) "iii",iii," i",i," ii",ii," jj",jj
6744 nnn=num_cont_hb(ii)+1
6747 d_cont(nnn,ii)=zapas_recv(3,i,iii)
6751 grij_hb_cont(kk,nnn,ii)=zapas_recv(ind,i,iii)
6756 a_chuj(ll,kk,nnn,ii)=zapas_recv(ind,i,iii)
6764 a_chuj_der(mm,ll,kk,jj,nnn,ii)=zapas_recv(ind,i,iii)
6773 write (iout,'(a)') 'Contact function values after receive:'
6775 write (iout,'(2i3,50(1x,i3,5f6.3))') &
6776 i,num_cont_hb(i),(jcont_hb(j,i),d_cont(j,i),&
6777 ((a_chuj(ll,kk,j,i),ll=1,2),kk=1,2),j=1,num_cont_hb(i))
6784 write (iout,'(a)') 'Contact function values:'
6786 write (iout,'(2i3,50(1x,i2,5f6.3))') &
6787 i,num_cont_hb(i),(jcont_hb(j,i),d_cont(j,i),&
6788 ((a_chuj(ll,kk,j,i),ll=1,2),kk=1,2),j=1,num_cont_hb(i))
6795 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres))
6796 ! if (.not.allocated(gradxorr)) allocate(gradxorr(3,nres))
6797 ! Remove the loop below after debugging !!!
6804 ! Calculate the dipole-dipole interaction energies
6805 if (wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) then
6806 do i=iatel_s,iatel_e+1
6807 num_conti=num_cont_hb(i)
6816 ! Calculate the local-electrostatic correlation terms
6817 ! write (iout,*) "gradcorr5 in eello5 before loop"
6819 ! write (iout,'(i5,3f10.5)')
6820 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
6822 do i=min0(iatel_s,iturn4_start),max0(iatel_e+1,iturn3_end+1)
6823 ! write (iout,*) "corr loop i",i
6825 num_conti=num_cont_hb(i)
6826 num_conti1=num_cont_hb(i+1)
6833 ! write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
6834 ! & ' jj=',jj,' kk=',kk
6835 ! if (j1.eq.j+1 .or. j1.eq.j-1) then
6836 if ((j.gt.0 .and. j1.gt.0 .or. j.gt.0 .and. j1.lt.0 &
6837 .or. j.lt.0 .and. j1.gt.0) .and. &
6838 (jp1.eq.jp+1 .or. jp1.eq.jp-1)) then
6839 ! Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
6840 ! The system gains extra energy.
6842 sqd1=dsqrt(d_cont(jj,i))
6843 sqd2=dsqrt(d_cont(kk,i1))
6844 sred_geom = sqd1*sqd2
6845 IF (sred_geom.lt.cutoff_corr) THEN
6846 call gcont(sred_geom,r0_corr,1.0D0,delt_corr,&
6848 !d write (iout,*) 'i=',i,' j=',jp,' i1=',i1,' j1=',jp1,
6849 !d & ' jj=',jj,' kk=',kk
6850 fac_prim1=0.5d0*sqd2/sqd1*fprimcont
6851 fac_prim2=0.5d0*sqd1/sqd2*fprimcont
6853 g_contij(l,1)=fac_prim1*grij_hb_cont(l,jj,i)
6854 g_contij(l,2)=fac_prim2*grij_hb_cont(l,kk,i1)
6857 !d write (iout,*) 'sred_geom=',sred_geom,
6858 !d & ' ekont=',ekont,' fprim=',fprimcont,
6859 !d & ' fac_prim1',fac_prim1,' fac_prim2',fac_prim2
6860 !d write (iout,*) "g_contij",g_contij
6861 !d write (iout,*) "grij_hb_cont i",grij_hb_cont(:,jj,i)
6862 !d write (iout,*) "grij_hb_cont i1",grij_hb_cont(:,jj,i1)
6863 call calc_eello(i,jp,i+1,jp1,jj,kk)
6864 if (wcorr4.gt.0.0d0) &
6865 ecorr=ecorr+eello4(i,jp,i+1,jp1,jj,kk)
6866 if (energy_dec.and.wcorr4.gt.0.0d0) &
6867 write (iout,'(a6,4i5,0pf7.3)') &
6868 'ecorr4',i,j,i+1,j1,eello4(i,jp,i+1,jp1,jj,kk)
6869 ! write (iout,*) "gradcorr5 before eello5"
6871 ! write (iout,'(i5,3f10.5)')
6872 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
6874 if (wcorr5.gt.0.0d0) &
6875 ecorr5=ecorr5+eello5(i,jp,i+1,jp1,jj,kk)
6876 ! write (iout,*) "gradcorr5 after eello5"
6878 ! write (iout,'(i5,3f10.5)')
6879 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
6881 if (energy_dec.and.wcorr5.gt.0.0d0) &
6882 write (iout,'(a6,4i5,0pf7.3)') &
6883 'ecorr5',i,j,i+1,j1,eello5(i,jp,i+1,jp1,jj,kk)
6884 !d write(2,*)'wcorr6',wcorr6,' wturn6',wturn6
6885 !d write(2,*)'ijkl',i,jp,i+1,jp1
6886 if (wcorr6.gt.0.0d0 .and. (jp.ne.i+4 .or. jp1.ne.i+3 &
6887 .or. wturn6.eq.0.0d0))then
6888 !d write (iout,*) '******ecorr6: i,j,i+1,j1',i,j,i+1,j1
6889 ecorr6=ecorr6+eello6(i,jp,i+1,jp1,jj,kk)
6890 if (energy_dec) write (iout,'(a6,4i5,0pf7.3)') &
6891 'ecorr6',i,j,i+1,j1,eello6(i,jp,i+1,jp1,jj,kk)
6892 !d write (iout,*) 'ecorr',ecorr,' ecorr5=',ecorr5,
6893 !d & 'ecorr6=',ecorr6
6894 !d write (iout,'(4e15.5)') sred_geom,
6895 !d & dabs(eello4(i,jp,i+1,jp1,jj,kk)),
6896 !d & dabs(eello5(i,jp,i+1,jp1,jj,kk)),
6897 !d & dabs(eello6(i,jp,i+1,jp1,jj,kk))
6898 else if (wturn6.gt.0.0d0 &
6899 .and. (jp.eq.i+4 .and. jp1.eq.i+3)) then
6900 !d write (iout,*) '******eturn6: i,j,i+1,j1',i,jip,i+1,jp1
6901 eturn6=eturn6+eello_turn6(i,jj,kk)
6902 if (energy_dec) write (iout,'(a6,4i5,0pf7.3)') &
6903 'eturn6',i,j,i+1,j1,eello_turn6(i,jj,kk)
6904 !d write (2,*) 'multibody_eello:eturn6',eturn6
6913 num_cont_hb(i)=num_cont_hb_old(i)
6915 ! write (iout,*) "gradcorr5 in eello5"
6917 ! write (iout,'(i5,3f10.5)')
6918 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
6921 end subroutine multibody_eello
6922 !-----------------------------------------------------------------------------
6923 subroutine add_hb_contact_eello(ii,jj,itask)
6924 ! implicit real*8 (a-h,o-z)
6925 ! include "DIMENSIONS"
6926 ! include "COMMON.IOUNITS"
6927 ! include "COMMON.CONTACTS"
6928 ! integer,parameter :: maxconts=nres/4
6929 integer,parameter :: max_dim=70
6930 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks)
6931 ! real(kind=8) :: zapas(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
6932 ! common /przechowalnia/ zapas
6934 integer :: i,j,ii,jj,iproc,nn,ind,jjc,kk,ll,mm
6935 integer,dimension(4) ::itask
6936 ! write (iout,*) "itask",itask
6939 if (iproc.gt.0) then
6940 do j=1,num_cont_hb(ii)
6942 ! write (iout,*) "send turns i",ii," j",jj," jjc",jjc
6944 ncont_sent(iproc)=ncont_sent(iproc)+1
6945 nn=ncont_sent(iproc)
6946 zapas(1,nn,iproc)=ii
6947 zapas(2,nn,iproc)=jjc
6948 zapas(3,nn,iproc)=d_cont(j,ii)
6952 zapas(ind,nn,iproc)=grij_hb_cont(kk,j,ii)
6957 zapas(ind,nn,iproc)=a_chuj(ll,kk,j,ii)
6965 zapas(ind,nn,iproc)=a_chuj_der(mm,ll,kk,jj,j,ii)
6976 end subroutine add_hb_contact_eello
6977 !-----------------------------------------------------------------------------
6978 real(kind=8) function ehbcorr(i,j,k,l,jj,kk,coeffp,coeffm)
6979 ! implicit real*8 (a-h,o-z)
6980 ! include 'DIMENSIONS'
6981 ! include 'COMMON.IOUNITS'
6982 ! include 'COMMON.DERIV'
6983 ! include 'COMMON.INTERACT'
6984 ! include 'COMMON.CONTACTS'
6985 real(kind=8),dimension(3) :: gx,gx1
6988 integer :: i,j,k,l,jj,kk,ll
6989 real(kind=8) :: coeffp,coeffm,eij,ekl,ees0pij,ees0pkl,ees0mij,&
6990 ees0mkl,ees,coeffpees0pij,coeffmees0mij,&
6991 coeffpees0pkl,coeffmees0mkl,gradlongij,gradlongkl
7001 ees=-(coeffp*ees0pij*ees0pkl+coeffm*ees0mij*ees0mkl)
7002 !d ees=-(coeffp*ees0pkl+coeffm*ees0mkl)
7003 ! Following 4 lines for diagnostics.
7008 ! write (iout,'(2(a,2i3,a,f10.5,a,2f10.5),a,f10.5,a,$)')
7009 ! & 'Contacts ',i,j,
7010 ! & ' eij',eij,' eesij',ees0pij,ees0mij,' and ',k,l
7011 ! & ,' fcont ',ekl,' eeskl',ees0pkl,ees0mkl,' energy=',ekont*ees,
7013 ! Calculate the multi-body contribution to energy.
7014 ! ecorr=ecorr+ekont*ees
7015 ! Calculate multi-body contributions to the gradient.
7016 coeffpees0pij=coeffp*ees0pij
7017 coeffmees0mij=coeffm*ees0mij
7018 coeffpees0pkl=coeffp*ees0pkl
7019 coeffmees0mkl=coeffm*ees0mkl
7021 !grad ghalfi=ees*ekl*gacont_hbr(ll,jj,i)
7022 gradcorr(ll,i)=gradcorr(ll,i) & !+0.5d0*ghalfi
7023 -ekont*(coeffpees0pkl*gacontp_hb1(ll,jj,i)+ &
7024 coeffmees0mkl*gacontm_hb1(ll,jj,i))
7025 gradcorr(ll,j)=gradcorr(ll,j) & !+0.5d0*ghalfi
7026 -ekont*(coeffpees0pkl*gacontp_hb2(ll,jj,i)+ &
7027 coeffmees0mkl*gacontm_hb2(ll,jj,i))
7028 !grad ghalfk=ees*eij*gacont_hbr(ll,kk,k)
7029 gradcorr(ll,k)=gradcorr(ll,k) & !+0.5d0*ghalfk
7030 -ekont*(coeffpees0pij*gacontp_hb1(ll,kk,k)+&
7031 coeffmees0mij*gacontm_hb1(ll,kk,k))
7032 gradcorr(ll,l)=gradcorr(ll,l) & !+0.5d0*ghalfk
7033 -ekont*(coeffpees0pij*gacontp_hb2(ll,kk,k)+ &
7034 coeffmees0mij*gacontm_hb2(ll,kk,k))
7035 gradlongij=ees*ekl*gacont_hbr(ll,jj,i)- &
7036 ekont*(coeffpees0pkl*gacontp_hb3(ll,jj,i)+ &
7037 coeffmees0mkl*gacontm_hb3(ll,jj,i))
7038 gradcorr_long(ll,j)=gradcorr_long(ll,j)+gradlongij
7039 gradcorr_long(ll,i)=gradcorr_long(ll,i)-gradlongij
7040 gradlongkl=ees*eij*gacont_hbr(ll,kk,k)- &
7041 ekont*(coeffpees0pij*gacontp_hb3(ll,kk,k)+ &
7042 coeffmees0mij*gacontm_hb3(ll,kk,k))
7043 gradcorr_long(ll,l)=gradcorr_long(ll,l)+gradlongkl
7044 gradcorr_long(ll,k)=gradcorr_long(ll,k)-gradlongkl
7045 ! write (iout,'(2f10.5,2x,$)') gradlongij,gradlongkl
7050 !grad gradcorr(ll,m)=gradcorr(ll,m)+
7051 !grad & ees*ekl*gacont_hbr(ll,jj,i)-
7052 !grad & ekont*(coeffp*ees0pkl*gacontp_hb3(ll,jj,i)+
7053 !grad & coeffm*ees0mkl*gacontm_hb3(ll,jj,i))
7058 !grad gradcorr(ll,m)=gradcorr(ll,m)+
7059 !grad & ees*eij*gacont_hbr(ll,kk,k)-
7060 !grad & ekont*(coeffp*ees0pij*gacontp_hb3(ll,kk,k)+
7061 !grad & coeffm*ees0mij*gacontm_hb3(ll,kk,k))
7064 ! write (iout,*) "ehbcorr",ekont*ees
7067 end function ehbcorr
7069 !-----------------------------------------------------------------------------
7070 subroutine dipole(i,j,jj)
7071 ! implicit real*8 (a-h,o-z)
7072 ! include 'DIMENSIONS'
7073 ! include 'COMMON.IOUNITS'
7074 ! include 'COMMON.CHAIN'
7075 ! include 'COMMON.FFIELD'
7076 ! include 'COMMON.DERIV'
7077 ! include 'COMMON.INTERACT'
7078 ! include 'COMMON.CONTACTS'
7079 ! include 'COMMON.TORSION'
7080 ! include 'COMMON.VAR'
7081 ! include 'COMMON.GEO'
7082 real(kind=8),dimension(2,2) :: dipi,dipj,auxmat
7083 real(kind=8),dimension(2) :: dipderi,dipderj,auxvec
7084 integer :: i,j,jj,iii,jjj,kkk,lll,iti1,itj1
7086 allocate(dip(4,maxconts,nres),dipderg(4,maxconts,nres))
7087 allocate(dipderx(3,5,4,maxconts,nres))
7090 iti1 = itortyp(itype(i+1))
7091 if (j.lt.nres-1) then
7092 itj1 = itortyp(itype(j+1))
7097 dipi(iii,1)=Ub2(iii,i)
7098 dipderi(iii)=Ub2der(iii,i)
7099 dipi(iii,2)=b1(iii,iti1)
7100 dipj(iii,1)=Ub2(iii,j)
7101 dipderj(iii)=Ub2der(iii,j)
7102 dipj(iii,2)=b1(iii,itj1)
7106 call matvec2(a_chuj(1,1,jj,i),dipj(1,iii),auxvec(1))
7109 dip(kkk,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
7116 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),dipj(1,iii),&
7120 dipderx(lll,kkk,mmm,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
7125 call transpose2(a_chuj(1,1,jj,i),auxmat(1,1))
7126 call matvec2(auxmat(1,1),dipderi(1),auxvec(1))
7128 dipderg(iii,jj,i)=scalar2(auxvec(1),dipj(1,iii))
7130 call matvec2(a_chuj(1,1,jj,i),dipderj(1),auxvec(1))
7132 dipderg(iii+2,jj,i)=scalar2(auxvec(1),dipi(1,iii))
7135 end subroutine dipole
7137 !-----------------------------------------------------------------------------
7138 subroutine calc_eello(i,j,k,l,jj,kk)
7140 ! This subroutine computes matrices and vectors needed to calculate
7141 ! the fourth-, fifth-, and sixth-order local-electrostatic terms.
7144 ! implicit real*8 (a-h,o-z)
7145 ! include 'DIMENSIONS'
7146 ! include 'COMMON.IOUNITS'
7147 ! include 'COMMON.CHAIN'
7148 ! include 'COMMON.DERIV'
7149 ! include 'COMMON.INTERACT'
7150 ! include 'COMMON.CONTACTS'
7151 ! include 'COMMON.TORSION'
7152 ! include 'COMMON.VAR'
7153 ! include 'COMMON.GEO'
7154 ! include 'COMMON.FFIELD'
7155 real(kind=8),dimension(2,2) :: aa1,aa2,aa1t,aa2t,auxmat
7156 real(kind=8),dimension(2,2,3,5) :: aa1tder,aa2tder
7157 integer :: i,j,k,l,jj,kk,iii,jjj,kkk,lll,iti,itk1,itj,itl,itl1,&
7160 !el common /kutas/ lprn
7161 !d write (iout,*) 'calc_eello: i=',i,' j=',j,' k=',k,' l=',l,
7162 !d & ' jj=',jj,' kk=',kk
7163 !d if (i.ne.2 .or. j.ne.4 .or. k.ne.3 .or. l.ne.5) return
7164 !d write (iout,*) "a_chujij",((a_chuj(iii,jjj,jj,i),iii=1,2),jjj=1,2)
7165 !d write (iout,*) "a_chujkl",((a_chuj(iii,jjj,kk,k),iii=1,2),jjj=1,2)
7168 aa1(iii,jjj)=a_chuj(iii,jjj,jj,i)
7169 aa2(iii,jjj)=a_chuj(iii,jjj,kk,k)
7172 call transpose2(aa1(1,1),aa1t(1,1))
7173 call transpose2(aa2(1,1),aa2t(1,1))
7176 call transpose2(a_chuj_der(1,1,lll,kkk,jj,i),&
7177 aa1tder(1,1,lll,kkk))
7178 call transpose2(a_chuj_der(1,1,lll,kkk,kk,k),&
7179 aa2tder(1,1,lll,kkk))
7183 ! parallel orientation of the two CA-CA-CA frames.
7185 iti=itortyp(itype(i))
7189 itk1=itortyp(itype(k+1))
7190 itj=itortyp(itype(j))
7191 if (l.lt.nres-1) then
7192 itl1=itortyp(itype(l+1))
7196 ! A1 kernel(j+1) A2T
7198 !d write (iout,'(3f10.5,5x,3f10.5)')
7199 !d & (EUg(iii,jjj,k),jjj=1,2),(EUg(iii,jjj,l),jjj=1,2)
7201 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
7202 aa2tder(1,1,1,1),1,.false.,EUg(1,1,l),EUgder(1,1,l),&
7203 AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
7204 ! Following matrices are needed only for 6-th order cumulants
7205 IF (wcorr6.gt.0.0d0) THEN
7206 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
7207 aa2tder(1,1,1,1),1,.false.,EUgC(1,1,l),EUgCder(1,1,l),&
7208 AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
7209 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
7210 aa2tder(1,1,1,1),2,.false.,Ug2DtEUg(1,1,l),&
7211 Ug2DtEUgder(1,1,1,l),ADtEA(1,1,1),ADtEAderg(1,1,1,1),&
7212 ADtEAderx(1,1,1,1,1,1))
7214 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
7215 aa2tder(1,1,1,1),2,.false.,DtUg2EUg(1,1,l),&
7216 DtUg2EUgder(1,1,1,l),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),&
7217 ADtEA1derx(1,1,1,1,1,1))
7219 ! End 6-th order cumulants
7222 !d write (2,*) 'In calc_eello6'
7224 !d write (2,*) 'iii=',iii
7226 !d write (2,*) 'kkk=',kkk
7228 !d write (2,'(3(2f10.5),5x)')
7229 !d & ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
7234 call transpose2(EUgder(1,1,k),auxmat(1,1))
7235 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
7236 call transpose2(EUg(1,1,k),auxmat(1,1))
7237 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
7238 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
7242 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),&
7243 EAEAderx(1,1,lll,kkk,iii,1))
7247 ! A1T kernel(i+1) A2
7248 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
7249 a_chuj_der(1,1,1,1,kk,k),1,.false.,EUg(1,1,k),EUgder(1,1,k),&
7250 AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
7251 ! Following matrices are needed only for 6-th order cumulants
7252 IF (wcorr6.gt.0.0d0) THEN
7253 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
7254 a_chuj_der(1,1,1,1,kk,k),1,.false.,EUgC(1,1,k),EUgCder(1,1,k),&
7255 AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
7256 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
7257 a_chuj_der(1,1,1,1,kk,k),2,.false.,Ug2DtEUg(1,1,k),&
7258 Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),&
7259 ADtEAderx(1,1,1,1,1,2))
7260 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
7261 a_chuj_der(1,1,1,1,kk,k),2,.false.,DtUg2EUg(1,1,k),&
7262 DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),&
7263 ADtEA1derx(1,1,1,1,1,2))
7265 ! End 6-th order cumulants
7266 call transpose2(EUgder(1,1,l),auxmat(1,1))
7267 call matmat2(auxmat(1,1),AEA(1,1,2),EAEAderg(1,1,1,2))
7268 call transpose2(EUg(1,1,l),auxmat(1,1))
7269 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
7270 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
7274 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
7275 EAEAderx(1,1,lll,kkk,iii,2))
7280 ! Calculate the vectors and their derivatives in virtual-bond dihedral angles.
7281 ! They are needed only when the fifth- or the sixth-order cumulants are
7283 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) THEN
7284 call transpose2(AEA(1,1,1),auxmat(1,1))
7285 call matvec2(auxmat(1,1),b1(1,iti),AEAb1(1,1,1))
7286 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
7287 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
7288 call transpose2(AEAderg(1,1,1),auxmat(1,1))
7289 call matvec2(auxmat(1,1),b1(1,iti),AEAb1derg(1,1,1))
7290 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
7291 call matvec2(AEA(1,1,1),b1(1,itk1),AEAb1(1,2,1))
7292 call matvec2(AEAderg(1,1,1),b1(1,itk1),AEAb1derg(1,2,1))
7293 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
7294 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
7295 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
7296 call transpose2(AEA(1,1,2),auxmat(1,1))
7297 call matvec2(auxmat(1,1),b1(1,itj),AEAb1(1,1,2))
7298 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2(1,1,2))
7299 call matvec2(auxmat(1,1),Ub2der(1,j),AEAb2derg(1,2,1,2))
7300 call transpose2(AEAderg(1,1,2),auxmat(1,1))
7301 call matvec2(auxmat(1,1),b1(1,itj),AEAb1derg(1,1,2))
7302 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2derg(1,1,1,2))
7303 call matvec2(AEA(1,1,2),b1(1,itl1),AEAb1(1,2,2))
7304 call matvec2(AEAderg(1,1,2),b1(1,itl1),AEAb1derg(1,2,2))
7305 call matvec2(AEA(1,1,2),Ub2(1,l+1),AEAb2(1,2,2))
7306 call matvec2(AEAderg(1,1,2),Ub2(1,l+1),AEAb2derg(1,1,2,2))
7307 call matvec2(AEA(1,1,2),Ub2der(1,l+1),AEAb2derg(1,2,2,2))
7308 ! Calculate the Cartesian derivatives of the vectors.
7312 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
7313 call matvec2(auxmat(1,1),b1(1,iti),&
7314 AEAb1derx(1,lll,kkk,iii,1,1))
7315 call matvec2(auxmat(1,1),Ub2(1,i),&
7316 AEAb2derx(1,lll,kkk,iii,1,1))
7317 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,itk1),&
7318 AEAb1derx(1,lll,kkk,iii,2,1))
7319 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),&
7320 AEAb2derx(1,lll,kkk,iii,2,1))
7321 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
7322 call matvec2(auxmat(1,1),b1(1,itj),&
7323 AEAb1derx(1,lll,kkk,iii,1,2))
7324 call matvec2(auxmat(1,1),Ub2(1,j),&
7325 AEAb2derx(1,lll,kkk,iii,1,2))
7326 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,itl1),&
7327 AEAb1derx(1,lll,kkk,iii,2,2))
7328 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,l+1),&
7329 AEAb2derx(1,lll,kkk,iii,2,2))
7336 ! Antiparallel orientation of the two CA-CA-CA frames.
7338 iti=itortyp(itype(i))
7342 itk1=itortyp(itype(k+1))
7343 itl=itortyp(itype(l))
7344 itj=itortyp(itype(j))
7345 if (j.lt.nres-1) then
7346 itj1=itortyp(itype(j+1))
7350 ! A2 kernel(j-1)T A1T
7351 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
7352 aa2tder(1,1,1,1),1,.true.,EUg(1,1,j),EUgder(1,1,j),&
7353 AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
7354 ! Following matrices are needed only for 6-th order cumulants
7355 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and. &
7356 j.eq.i+4 .and. l.eq.i+3)) THEN
7357 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
7358 aa2tder(1,1,1,1),1,.true.,EUgC(1,1,j),EUgCder(1,1,j),&
7359 AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
7360 call kernel(aa2(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
7361 aa2tder(1,1,1,1),2,.true.,Ug2DtEUg(1,1,j),&
7362 Ug2DtEUgder(1,1,1,j),ADtEA(1,1,1),ADtEAderg(1,1,1,1),&
7363 ADtEAderx(1,1,1,1,1,1))
7364 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
7365 aa2tder(1,1,1,1),2,.true.,DtUg2EUg(1,1,j),&
7366 DtUg2EUgder(1,1,1,j),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),&
7367 ADtEA1derx(1,1,1,1,1,1))
7369 ! End 6-th order cumulants
7370 call transpose2(EUgder(1,1,k),auxmat(1,1))
7371 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
7372 call transpose2(EUg(1,1,k),auxmat(1,1))
7373 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
7374 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
7378 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),&
7379 EAEAderx(1,1,lll,kkk,iii,1))
7383 ! A2T kernel(i+1)T A1
7384 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
7385 a_chuj_der(1,1,1,1,jj,i),1,.true.,EUg(1,1,k),EUgder(1,1,k),&
7386 AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
7387 ! Following matrices are needed only for 6-th order cumulants
7388 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and. &
7389 j.eq.i+4 .and. l.eq.i+3)) THEN
7390 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
7391 a_chuj_der(1,1,1,1,jj,i),1,.true.,EUgC(1,1,k),EUgCder(1,1,k),&
7392 AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
7393 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
7394 a_chuj_der(1,1,1,1,jj,i),2,.true.,Ug2DtEUg(1,1,k),&
7395 Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),&
7396 ADtEAderx(1,1,1,1,1,2))
7397 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
7398 a_chuj_der(1,1,1,1,jj,i),2,.true.,DtUg2EUg(1,1,k),&
7399 DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),&
7400 ADtEA1derx(1,1,1,1,1,2))
7402 ! End 6-th order cumulants
7403 call transpose2(EUgder(1,1,j),auxmat(1,1))
7404 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,2,2))
7405 call transpose2(EUg(1,1,j),auxmat(1,1))
7406 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
7407 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
7411 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
7412 EAEAderx(1,1,lll,kkk,iii,2))
7417 ! Calculate the vectors and their derivatives in virtual-bond dihedral angles.
7418 ! They are needed only when the fifth- or the sixth-order cumulants are
7420 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 .or. &
7421 (wturn6.gt.0.0d0 .and. j.eq.i+4 .and. l.eq.i+3)) THEN
7422 call transpose2(AEA(1,1,1),auxmat(1,1))
7423 call matvec2(auxmat(1,1),b1(1,iti),AEAb1(1,1,1))
7424 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
7425 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
7426 call transpose2(AEAderg(1,1,1),auxmat(1,1))
7427 call matvec2(auxmat(1,1),b1(1,iti),AEAb1derg(1,1,1))
7428 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
7429 call matvec2(AEA(1,1,1),b1(1,itk1),AEAb1(1,2,1))
7430 call matvec2(AEAderg(1,1,1),b1(1,itk1),AEAb1derg(1,2,1))
7431 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
7432 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
7433 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
7434 call transpose2(AEA(1,1,2),auxmat(1,1))
7435 call matvec2(auxmat(1,1),b1(1,itj1),AEAb1(1,1,2))
7436 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2(1,1,2))
7437 call matvec2(auxmat(1,1),Ub2der(1,l),AEAb2derg(1,2,1,2))
7438 call transpose2(AEAderg(1,1,2),auxmat(1,1))
7439 call matvec2(auxmat(1,1),b1(1,itl),AEAb1(1,1,2))
7440 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2derg(1,1,1,2))
7441 call matvec2(AEA(1,1,2),b1(1,itj1),AEAb1(1,2,2))
7442 call matvec2(AEAderg(1,1,2),b1(1,itj1),AEAb1derg(1,2,2))
7443 call matvec2(AEA(1,1,2),Ub2(1,j),AEAb2(1,2,2))
7444 call matvec2(AEAderg(1,1,2),Ub2(1,j),AEAb2derg(1,1,2,2))
7445 call matvec2(AEA(1,1,2),Ub2der(1,j),AEAb2derg(1,2,2,2))
7446 ! Calculate the Cartesian derivatives of the vectors.
7450 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
7451 call matvec2(auxmat(1,1),b1(1,iti),&
7452 AEAb1derx(1,lll,kkk,iii,1,1))
7453 call matvec2(auxmat(1,1),Ub2(1,i),&
7454 AEAb2derx(1,lll,kkk,iii,1,1))
7455 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,itk1),&
7456 AEAb1derx(1,lll,kkk,iii,2,1))
7457 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),&
7458 AEAb2derx(1,lll,kkk,iii,2,1))
7459 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
7460 call matvec2(auxmat(1,1),b1(1,itl),&
7461 AEAb1derx(1,lll,kkk,iii,1,2))
7462 call matvec2(auxmat(1,1),Ub2(1,l),&
7463 AEAb2derx(1,lll,kkk,iii,1,2))
7464 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,itj1),&
7465 AEAb1derx(1,lll,kkk,iii,2,2))
7466 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,j),&
7467 AEAb2derx(1,lll,kkk,iii,2,2))
7475 end subroutine calc_eello
7476 !-----------------------------------------------------------------------------
7477 subroutine kernel(aa1,aa2t,aa1derx,aa2tderx,nderg,transp,KK,KKderg,AKA,AKAderg,AKAderx)
7482 real(kind=8),dimension(2,2) :: aa1,aa2t,KK,AKA
7483 real(kind=8),dimension(2,2,3,5) :: aa1derx,aa2tderx
7484 real(kind=8),dimension(2,2,3,5,2) :: AKAderx
7485 real(kind=8),dimension(2,2,nderg) :: KKderg,AKAderg
7486 integer :: iii,kkk,lll
7489 !el common /kutas/ lprn
7490 call prodmat3(aa1(1,1),aa2t(1,1),KK(1,1),transp,AKA(1,1))
7492 call prodmat3(aa1(1,1),aa2t(1,1),KKderg(1,1,iii),transp,&
7495 !d if (lprn) write (2,*) 'In kernel'
7497 !d if (lprn) write (2,*) 'kkk=',kkk
7499 call prodmat3(aa1derx(1,1,lll,kkk),aa2t(1,1),&
7500 KK(1,1),transp,AKAderx(1,1,lll,kkk,1))
7502 !d write (2,*) 'lll=',lll
7503 !d write (2,*) 'iii=1'
7505 !d write (2,'(3(2f10.5),5x)')
7506 !d & (AKAderx(jjj,mmm,lll,kkk,1),mmm=1,2)
7509 call prodmat3(aa1(1,1),aa2tderx(1,1,lll,kkk),&
7510 KK(1,1),transp,AKAderx(1,1,lll,kkk,2))
7512 !d write (2,*) 'lll=',lll
7513 !d write (2,*) 'iii=2'
7515 !d write (2,'(3(2f10.5),5x)')
7516 !d & (AKAderx(jjj,mmm,lll,kkk,2),mmm=1,2)
7522 end subroutine kernel
7523 !-----------------------------------------------------------------------------
7524 real(kind=8) function eello4(i,j,k,l,jj,kk)
7525 ! implicit real*8 (a-h,o-z)
7526 ! include 'DIMENSIONS'
7527 ! include 'COMMON.IOUNITS'
7528 ! include 'COMMON.CHAIN'
7529 ! include 'COMMON.DERIV'
7530 ! include 'COMMON.INTERACT'
7531 ! include 'COMMON.CONTACTS'
7532 ! include 'COMMON.TORSION'
7533 ! include 'COMMON.VAR'
7534 ! include 'COMMON.GEO'
7535 real(kind=8),dimension(2,2) :: pizda
7536 real(kind=8),dimension(3) :: ggg1,ggg2
7537 real(kind=8) :: eel4,glongij,glongkl
7538 integer :: i,j,k,l,jj,kk,iii,kkk,lll,j1,j2,l1,l2,ll
7539 !d if (i.ne.1 .or. j.ne.5 .or. k.ne.2 .or.l.ne.4) then
7543 !d print *,'eello4:',i,j,k,l,jj,kk
7544 !d write (2,*) 'i',i,' j',j,' k',k,' l',l
7545 !d call checkint4(i,j,k,l,jj,kk,eel4_num)
7546 !old eij=facont_hb(jj,i)
7547 !old ekl=facont_hb(kk,k)
7549 eel4=-EAEA(1,1,1)-EAEA(2,2,1)
7550 !d eel41=-EAEA(1,1,2)-EAEA(2,2,2)
7551 gcorr_loc(k-1)=gcorr_loc(k-1) &
7552 -ekont*(EAEAderg(1,1,1,1)+EAEAderg(2,2,1,1))
7554 gcorr_loc(l-1)=gcorr_loc(l-1) &
7555 -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
7557 gcorr_loc(j-1)=gcorr_loc(j-1) &
7558 -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
7563 derx(lll,kkk,iii)=-EAEAderx(1,1,lll,kkk,iii,1) &
7564 -EAEAderx(2,2,lll,kkk,iii,1)
7565 !d derx(lll,kkk,iii)=0.0d0
7569 !d gcorr_loc(l-1)=0.0d0
7570 !d gcorr_loc(j-1)=0.0d0
7571 !d gcorr_loc(k-1)=0.0d0
7573 !d write (iout,*)'Contacts have occurred for peptide groups',
7574 !d & i,j,' fcont:',eij,' eij',' and ',k,l,
7575 !d & ' fcont ',ekl,' eel4=',eel4,' eel4_num',16*eel4_num
7576 if (j.lt.nres-1) then
7583 if (l.lt.nres-1) then
7591 !grad ggg1(ll)=eel4*g_contij(ll,1)
7592 !grad ggg2(ll)=eel4*g_contij(ll,2)
7593 glongij=eel4*g_contij(ll,1)+ekont*derx(ll,1,1)
7594 glongkl=eel4*g_contij(ll,2)+ekont*derx(ll,1,2)
7595 !grad ghalf=0.5d0*ggg1(ll)
7596 gradcorr(ll,i)=gradcorr(ll,i)+ekont*derx(ll,2,1)
7597 gradcorr(ll,i+1)=gradcorr(ll,i+1)+ekont*derx(ll,3,1)
7598 gradcorr(ll,j)=gradcorr(ll,j)+ekont*derx(ll,4,1)
7599 gradcorr(ll,j1)=gradcorr(ll,j1)+ekont*derx(ll,5,1)
7600 gradcorr_long(ll,j)=gradcorr_long(ll,j)+glongij
7601 gradcorr_long(ll,i)=gradcorr_long(ll,i)-glongij
7602 !grad ghalf=0.5d0*ggg2(ll)
7603 gradcorr(ll,k)=gradcorr(ll,k)+ekont*derx(ll,2,2)
7604 gradcorr(ll,k+1)=gradcorr(ll,k+1)+ekont*derx(ll,3,2)
7605 gradcorr(ll,l)=gradcorr(ll,l)+ekont*derx(ll,4,2)
7606 gradcorr(ll,l1)=gradcorr(ll,l1)+ekont*derx(ll,5,2)
7607 gradcorr_long(ll,l)=gradcorr_long(ll,l)+glongkl
7608 gradcorr_long(ll,k)=gradcorr_long(ll,k)-glongkl
7612 !grad gradcorr(ll,m)=gradcorr(ll,m)+ggg1(ll)
7617 !grad gradcorr(ll,m)=gradcorr(ll,m)+ggg2(ll)
7622 !grad gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,1)
7627 !grad gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,2)
7631 !d write (2,*) iii,gcorr_loc(iii)
7634 !d write (2,*) 'ekont',ekont
7635 !d write (iout,*) 'eello4',ekont*eel4
7638 !-----------------------------------------------------------------------------
7639 real(kind=8) function eello5(i,j,k,l,jj,kk)
7640 ! implicit real*8 (a-h,o-z)
7641 ! include 'DIMENSIONS'
7642 ! include 'COMMON.IOUNITS'
7643 ! include 'COMMON.CHAIN'
7644 ! include 'COMMON.DERIV'
7645 ! include 'COMMON.INTERACT'
7646 ! include 'COMMON.CONTACTS'
7647 ! include 'COMMON.TORSION'
7648 ! include 'COMMON.VAR'
7649 ! include 'COMMON.GEO'
7650 real(kind=8),dimension(2,2) :: pizda,auxmat,auxmat1
7651 real(kind=8),dimension(2) :: vv
7652 real(kind=8),dimension(3) :: ggg1,ggg2
7653 real(kind=8) :: eello5_1,eello5_2,eello5_3,eello5_4,eel5
7654 real(kind=8) :: gradcorr5ij,gradcorr5kl,ghalf
7655 integer :: i,j,k,l,jj,kk,itk,itl,itj,iii,kkk,lll,j1,j2,l1,l2,ll
7656 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
7661 ! /l\ / \ \ / \ / \ / C
7662 ! / \ / \ \ / \ / \ / C
7663 ! j| o |l1 | o | o| o | | o |o C
7664 ! \ |/k\| |/ \| / |/ \| |/ \| C
7665 ! \i/ \ / \ / / \ / \ C
7667 ! (I) (II) (III) (IV) C
7669 ! eello5_1 eello5_2 eello5_3 eello5_4 C
7671 ! Antiparallel chains C
7674 ! /j\ / \ \ / \ / \ / C
7675 ! / \ / \ \ / \ / \ / C
7676 ! j1| o |l | o | o| o | | o |o C
7677 ! \ |/k\| |/ \| / |/ \| |/ \| C
7678 ! \i/ \ / \ / / \ / \ C
7680 ! (I) (II) (III) (IV) C
7682 ! eello5_1 eello5_2 eello5_3 eello5_4 C
7684 ! o denotes a local interaction, vertical lines an electrostatic interaction. C
7686 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
7687 !d if (i.ne.2 .or. j.ne.6 .or. k.ne.3 .or. l.ne.5) then
7692 !d & 'EELLO5: Contacts have occurred for peptide groups',i,j,
7694 itk=itortyp(itype(k))
7695 itl=itortyp(itype(l))
7696 itj=itortyp(itype(j))
7701 !d call checkint5(i,j,k,l,jj,kk,eel5_1_num,eel5_2_num,
7702 !d & eel5_3_num,eel5_4_num)
7706 derx(lll,kkk,iii)=0.0d0
7710 !d eij=facont_hb(jj,i)
7711 !d ekl=facont_hb(kk,k)
7713 !d write (iout,*)'Contacts have occurred for peptide groups',
7714 !d & i,j,' fcont:',eij,' eij',' and ',k,l
7716 ! Contribution from the graph I.
7717 !d write (2,*) 'AEA ',AEA(1,1,1),AEA(2,1,1),AEA(1,2,1),AEA(2,2,1)
7718 !d write (2,*) 'AEAb2',AEAb2(1,1,1),AEAb2(2,1,1)
7719 call transpose2(EUg(1,1,k),auxmat(1,1))
7720 call matmat2(AEA(1,1,1),auxmat(1,1),pizda(1,1))
7721 vv(1)=pizda(1,1)-pizda(2,2)
7722 vv(2)=pizda(1,2)+pizda(2,1)
7723 eello5_1=scalar2(AEAb2(1,1,1),Ub2(1,k)) &
7724 +0.5d0*scalar2(vv(1),Dtobr2(1,i))
7725 ! Explicit gradient in virtual-dihedral angles.
7726 if (i.gt.1) g_corr5_loc(i-1)=g_corr5_loc(i-1) &
7727 +ekont*(scalar2(AEAb2derg(1,2,1,1),Ub2(1,k)) &
7728 +0.5d0*scalar2(vv(1),Dtobr2der(1,i)))
7729 call transpose2(EUgder(1,1,k),auxmat1(1,1))
7730 call matmat2(AEA(1,1,1),auxmat1(1,1),pizda(1,1))
7731 vv(1)=pizda(1,1)-pizda(2,2)
7732 vv(2)=pizda(1,2)+pizda(2,1)
7733 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
7734 +ekont*(scalar2(AEAb2(1,1,1),Ub2der(1,k)) &
7735 +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
7736 call matmat2(AEAderg(1,1,1),auxmat(1,1),pizda(1,1))
7737 vv(1)=pizda(1,1)-pizda(2,2)
7738 vv(2)=pizda(1,2)+pizda(2,1)
7740 if (l.lt.nres-1) g_corr5_loc(l-1)=g_corr5_loc(l-1) &
7741 +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k)) &
7742 +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
7744 if (j.lt.nres-1) g_corr5_loc(j-1)=g_corr5_loc(j-1) &
7745 +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k)) &
7746 +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
7748 ! Cartesian gradient
7752 call matmat2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1),&
7754 vv(1)=pizda(1,1)-pizda(2,2)
7755 vv(2)=pizda(1,2)+pizda(2,1)
7756 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
7757 +scalar2(AEAb2derx(1,lll,kkk,iii,1,1),Ub2(1,k)) &
7758 +0.5d0*scalar2(vv(1),Dtobr2(1,i))
7764 ! Contribution from graph II
7765 call transpose2(EE(1,1,itk),auxmat(1,1))
7766 call matmat2(auxmat(1,1),AEA(1,1,1),pizda(1,1))
7767 vv(1)=pizda(1,1)+pizda(2,2)
7768 vv(2)=pizda(2,1)-pizda(1,2)
7769 eello5_2=scalar2(AEAb1(1,2,1),b1(1,itk)) &
7770 -0.5d0*scalar2(vv(1),Ctobr(1,k))
7771 ! Explicit gradient in virtual-dihedral angles.
7772 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
7773 -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,k))
7774 call matmat2(auxmat(1,1),AEAderg(1,1,1),pizda(1,1))
7775 vv(1)=pizda(1,1)+pizda(2,2)
7776 vv(2)=pizda(2,1)-pizda(1,2)
7778 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
7779 +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,itk)) &
7780 -0.5d0*scalar2(vv(1),Ctobr(1,k)))
7782 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
7783 +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,itk)) &
7784 -0.5d0*scalar2(vv(1),Ctobr(1,k)))
7786 ! Cartesian gradient
7790 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),&
7792 vv(1)=pizda(1,1)+pizda(2,2)
7793 vv(2)=pizda(2,1)-pizda(1,2)
7794 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
7795 +scalar2(AEAb1derx(1,lll,kkk,iii,2,1),b1(1,itk)) &
7796 -0.5d0*scalar2(vv(1),Ctobr(1,k))
7804 ! Parallel orientation
7805 ! Contribution from graph III
7806 call transpose2(EUg(1,1,l),auxmat(1,1))
7807 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
7808 vv(1)=pizda(1,1)-pizda(2,2)
7809 vv(2)=pizda(1,2)+pizda(2,1)
7810 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,l)) &
7811 +0.5d0*scalar2(vv(1),Dtobr2(1,j))
7812 ! Explicit gradient in virtual-dihedral angles.
7813 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
7814 +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,l)) &
7815 +0.5d0*scalar2(vv(1),Dtobr2der(1,j)))
7816 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
7817 vv(1)=pizda(1,1)-pizda(2,2)
7818 vv(2)=pizda(1,2)+pizda(2,1)
7819 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
7820 +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,l)) &
7821 +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
7822 call transpose2(EUgder(1,1,l),auxmat1(1,1))
7823 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
7824 vv(1)=pizda(1,1)-pizda(2,2)
7825 vv(2)=pizda(1,2)+pizda(2,1)
7826 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
7827 +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,l)) &
7828 +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
7829 ! Cartesian gradient
7833 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),&
7835 vv(1)=pizda(1,1)-pizda(2,2)
7836 vv(2)=pizda(1,2)+pizda(2,1)
7837 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
7838 +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,l)) &
7839 +0.5d0*scalar2(vv(1),Dtobr2(1,j))
7844 ! Contribution from graph IV
7846 call transpose2(EE(1,1,itl),auxmat(1,1))
7847 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
7848 vv(1)=pizda(1,1)+pizda(2,2)
7849 vv(2)=pizda(2,1)-pizda(1,2)
7850 eello5_4=scalar2(AEAb1(1,2,2),b1(1,itl)) &
7851 -0.5d0*scalar2(vv(1),Ctobr(1,l))
7852 ! Explicit gradient in virtual-dihedral angles.
7853 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
7854 -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,l))
7855 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
7856 vv(1)=pizda(1,1)+pizda(2,2)
7857 vv(2)=pizda(2,1)-pizda(1,2)
7858 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
7859 +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,itl)) &
7860 -0.5d0*scalar2(vv(1),Ctobr(1,l)))
7861 ! Cartesian gradient
7865 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
7867 vv(1)=pizda(1,1)+pizda(2,2)
7868 vv(2)=pizda(2,1)-pizda(1,2)
7869 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
7870 +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,itl)) &
7871 -0.5d0*scalar2(vv(1),Ctobr(1,l))
7876 ! Antiparallel orientation
7877 ! Contribution from graph III
7879 call transpose2(EUg(1,1,j),auxmat(1,1))
7880 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
7881 vv(1)=pizda(1,1)-pizda(2,2)
7882 vv(2)=pizda(1,2)+pizda(2,1)
7883 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,j)) &
7884 +0.5d0*scalar2(vv(1),Dtobr2(1,l))
7885 ! Explicit gradient in virtual-dihedral angles.
7886 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
7887 +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,j)) &
7888 +0.5d0*scalar2(vv(1),Dtobr2der(1,l)))
7889 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
7890 vv(1)=pizda(1,1)-pizda(2,2)
7891 vv(2)=pizda(1,2)+pizda(2,1)
7892 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
7893 +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,j)) &
7894 +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
7895 call transpose2(EUgder(1,1,j),auxmat1(1,1))
7896 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
7897 vv(1)=pizda(1,1)-pizda(2,2)
7898 vv(2)=pizda(1,2)+pizda(2,1)
7899 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
7900 +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,j)) &
7901 +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
7902 ! Cartesian gradient
7906 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),&
7908 vv(1)=pizda(1,1)-pizda(2,2)
7909 vv(2)=pizda(1,2)+pizda(2,1)
7910 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii) &
7911 +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,j)) &
7912 +0.5d0*scalar2(vv(1),Dtobr2(1,l))
7917 ! Contribution from graph IV
7919 call transpose2(EE(1,1,itj),auxmat(1,1))
7920 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
7921 vv(1)=pizda(1,1)+pizda(2,2)
7922 vv(2)=pizda(2,1)-pizda(1,2)
7923 eello5_4=scalar2(AEAb1(1,2,2),b1(1,itj)) &
7924 -0.5d0*scalar2(vv(1),Ctobr(1,j))
7925 ! Explicit gradient in virtual-dihedral angles.
7926 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
7927 -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,j))
7928 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
7929 vv(1)=pizda(1,1)+pizda(2,2)
7930 vv(2)=pizda(2,1)-pizda(1,2)
7931 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
7932 +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,itj)) &
7933 -0.5d0*scalar2(vv(1),Ctobr(1,j)))
7934 ! Cartesian gradient
7938 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
7940 vv(1)=pizda(1,1)+pizda(2,2)
7941 vv(2)=pizda(2,1)-pizda(1,2)
7942 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii) &
7943 +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,itj)) &
7944 -0.5d0*scalar2(vv(1),Ctobr(1,j))
7950 eel5=eello5_1+eello5_2+eello5_3+eello5_4
7951 !d if (i.eq.2 .and. j.eq.8 .and. k.eq.3 .and. l.eq.7) then
7952 !d write (2,*) 'ijkl',i,j,k,l
7953 !d write (2,*) 'eello5_1',eello5_1,' eello5_2',eello5_2,
7954 !d & ' eello5_3',eello5_3,' eello5_4',eello5_4
7956 !d write(iout,*) 'eello5_1',eello5_1,' eel5_1_num',16*eel5_1_num
7957 !d write(iout,*) 'eello5_2',eello5_2,' eel5_2_num',16*eel5_2_num
7958 !d write(iout,*) 'eello5_3',eello5_3,' eel5_3_num',16*eel5_3_num
7959 !d write(iout,*) 'eello5_4',eello5_4,' eel5_4_num',16*eel5_4_num
7960 if (j.lt.nres-1) then
7967 if (l.lt.nres-1) then
7977 !d write (2,*) 'eij',eij,' ekl',ekl,' ekont',ekont
7978 ! 2/11/08 AL Gradients over DC's connecting interacting sites will be
7979 ! summed up outside the subrouine as for the other subroutines
7980 ! handling long-range interactions. The old code is commented out
7981 ! with "cgrad" to keep track of changes.
7983 !grad ggg1(ll)=eel5*g_contij(ll,1)
7984 !grad ggg2(ll)=eel5*g_contij(ll,2)
7985 gradcorr5ij=eel5*g_contij(ll,1)+ekont*derx(ll,1,1)
7986 gradcorr5kl=eel5*g_contij(ll,2)+ekont*derx(ll,1,2)
7987 ! write (iout,'(a,3i3,a,5f8.3,2i3,a,5f8.3,a,f8.3)')
7988 ! & "ecorr5",ll,i,j," derx",derx(ll,2,1),derx(ll,3,1),derx(ll,4,1),
7989 ! & derx(ll,5,1),k,l," derx",derx(ll,2,2),derx(ll,3,2),
7990 ! & derx(ll,4,2),derx(ll,5,2)," ekont",ekont
7991 ! write (iout,'(a,3i3,a,3f8.3,2i3,a,3f8.3)')
7992 ! & "ecorr5",ll,i,j," gradcorr5",g_contij(ll,1),derx(ll,1,1),
7994 ! & k,l," gradcorr5",g_contij(ll,2),derx(ll,1,2),gradcorr5kl
7995 !old ghalf=0.5d0*eel5*ekl*gacont_hbr(ll,jj,i)
7996 !grad ghalf=0.5d0*ggg1(ll)
7998 gradcorr5(ll,i)=gradcorr5(ll,i)+ekont*derx(ll,2,1)
7999 gradcorr5(ll,i+1)=gradcorr5(ll,i+1)+ekont*derx(ll,3,1)
8000 gradcorr5(ll,j)=gradcorr5(ll,j)+ekont*derx(ll,4,1)
8001 gradcorr5(ll,j1)=gradcorr5(ll,j1)+ekont*derx(ll,5,1)
8002 gradcorr5_long(ll,j)=gradcorr5_long(ll,j)+gradcorr5ij
8003 gradcorr5_long(ll,i)=gradcorr5_long(ll,i)-gradcorr5ij
8004 !old ghalf=0.5d0*eel5*eij*gacont_hbr(ll,kk,k)
8005 !grad ghalf=0.5d0*ggg2(ll)
8007 gradcorr5(ll,k)=gradcorr5(ll,k)+ghalf+ekont*derx(ll,2,2)
8008 gradcorr5(ll,k+1)=gradcorr5(ll,k+1)+ekont*derx(ll,3,2)
8009 gradcorr5(ll,l)=gradcorr5(ll,l)+ghalf+ekont*derx(ll,4,2)
8010 gradcorr5(ll,l1)=gradcorr5(ll,l1)+ekont*derx(ll,5,2)
8011 gradcorr5_long(ll,l)=gradcorr5_long(ll,l)+gradcorr5kl
8012 gradcorr5_long(ll,k)=gradcorr5_long(ll,k)-gradcorr5kl
8017 !old gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*ekl*gacont_hbr(ll,jj,i)
8018 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ggg1(ll)
8023 !old gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*eij*gacont_hbr(ll,kk,k)
8024 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ggg2(ll)
8030 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,1)
8035 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,2)
8039 !d write (2,*) iii,g_corr5_loc(iii)
8042 !d write (2,*) 'ekont',ekont
8043 !d write (iout,*) 'eello5',ekont*eel5
8046 !-----------------------------------------------------------------------------
8047 real(kind=8) function eello6(i,j,k,l,jj,kk)
8048 ! implicit real*8 (a-h,o-z)
8049 ! include 'DIMENSIONS'
8050 ! include 'COMMON.IOUNITS'
8051 ! include 'COMMON.CHAIN'
8052 ! include 'COMMON.DERIV'
8053 ! include 'COMMON.INTERACT'
8054 ! include 'COMMON.CONTACTS'
8055 ! include 'COMMON.TORSION'
8056 ! include 'COMMON.VAR'
8057 ! include 'COMMON.GEO'
8058 ! include 'COMMON.FFIELD'
8059 real(kind=8),dimension(3) :: ggg1,ggg2
8060 real(kind=8) :: eello6_1,eello6_2,eello6_3,eello6_4,eello6_5,&
8062 real(kind=8) :: gradcorr6ij,gradcorr6kl
8063 integer :: i,j,k,l,jj,kk,iii,kkk,lll,j1,j2,l1,l2,ll
8064 !d if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
8069 !d & 'EELLO6: Contacts have occurred for peptide groups',i,j,
8077 !d call checkint6(i,j,k,l,jj,kk,eel6_1_num,eel6_2_num,
8078 !d & eel6_3_num,eel6_4_num,eel6_5_num,eel6_6_num)
8082 derx(lll,kkk,iii)=0.0d0
8086 !d eij=facont_hb(jj,i)
8087 !d ekl=facont_hb(kk,k)
8093 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
8094 eello6_2=eello6_graph1(j,i,l,k,2,.false.)
8095 eello6_3=eello6_graph2(i,j,k,l,jj,kk,.false.)
8096 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
8097 eello6_5=eello6_graph4(j,i,l,k,jj,kk,2,.false.)
8098 eello6_6=eello6_graph3(i,j,k,l,jj,kk,.false.)
8100 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
8101 eello6_2=eello6_graph1(l,k,j,i,2,.true.)
8102 eello6_3=eello6_graph2(i,l,k,j,jj,kk,.true.)
8103 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
8104 if (wturn6.eq.0.0d0 .or. j.ne.i+4) then
8105 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
8109 eello6_6=eello6_graph3(i,l,k,j,jj,kk,.true.)
8111 ! If turn contributions are considered, they will be handled separately.
8112 eel6=eello6_1+eello6_2+eello6_3+eello6_4+eello6_5+eello6_6
8113 !d write(iout,*) 'eello6_1',eello6_1!,' eel6_1_num',16*eel6_1_num
8114 !d write(iout,*) 'eello6_2',eello6_2!,' eel6_2_num',16*eel6_2_num
8115 !d write(iout,*) 'eello6_3',eello6_3!,' eel6_3_num',16*eel6_3_num
8116 !d write(iout,*) 'eello6_4',eello6_4!,' eel6_4_num',16*eel6_4_num
8117 !d write(iout,*) 'eello6_5',eello6_5!,' eel6_5_num',16*eel6_5_num
8118 !d write(iout,*) 'eello6_6',eello6_6!,' eel6_6_num',16*eel6_6_num
8120 if (j.lt.nres-1) then
8127 if (l.lt.nres-1) then
8135 !grad ggg1(ll)=eel6*g_contij(ll,1)
8136 !grad ggg2(ll)=eel6*g_contij(ll,2)
8137 !old ghalf=0.5d0*eel6*ekl*gacont_hbr(ll,jj,i)
8138 !grad ghalf=0.5d0*ggg1(ll)
8140 gradcorr6ij=eel6*g_contij(ll,1)+ekont*derx(ll,1,1)
8141 gradcorr6kl=eel6*g_contij(ll,2)+ekont*derx(ll,1,2)
8142 gradcorr6(ll,i)=gradcorr6(ll,i)+ekont*derx(ll,2,1)
8143 gradcorr6(ll,i+1)=gradcorr6(ll,i+1)+ekont*derx(ll,3,1)
8144 gradcorr6(ll,j)=gradcorr6(ll,j)+ekont*derx(ll,4,1)
8145 gradcorr6(ll,j1)=gradcorr6(ll,j1)+ekont*derx(ll,5,1)
8146 gradcorr6_long(ll,j)=gradcorr6_long(ll,j)+gradcorr6ij
8147 gradcorr6_long(ll,i)=gradcorr6_long(ll,i)-gradcorr6ij
8148 !grad ghalf=0.5d0*ggg2(ll)
8149 !old ghalf=0.5d0*eel6*eij*gacont_hbr(ll,kk,k)
8151 gradcorr6(ll,k)=gradcorr6(ll,k)+ekont*derx(ll,2,2)
8152 gradcorr6(ll,k+1)=gradcorr6(ll,k+1)+ekont*derx(ll,3,2)
8153 gradcorr6(ll,l)=gradcorr6(ll,l)+ekont*derx(ll,4,2)
8154 gradcorr6(ll,l1)=gradcorr6(ll,l1)+ekont*derx(ll,5,2)
8155 gradcorr6_long(ll,l)=gradcorr6_long(ll,l)+gradcorr6kl
8156 gradcorr6_long(ll,k)=gradcorr6_long(ll,k)-gradcorr6kl
8161 !old gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*ekl*gacont_hbr(ll,jj,i)
8162 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ggg1(ll)
8167 !old gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*eij*gacont_hbr(ll,kk,k)
8168 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ggg2(ll)
8174 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,1)
8179 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,2)
8183 !d write (2,*) iii,g_corr6_loc(iii)
8186 !d write (2,*) 'ekont',ekont
8187 !d write (iout,*) 'eello6',ekont*eel6
8190 !-----------------------------------------------------------------------------
8191 real(kind=8) function eello6_graph1(i,j,k,l,imat,swap)
8193 ! implicit real*8 (a-h,o-z)
8194 ! include 'DIMENSIONS'
8195 ! include 'COMMON.IOUNITS'
8196 ! include 'COMMON.CHAIN'
8197 ! include 'COMMON.DERIV'
8198 ! include 'COMMON.INTERACT'
8199 ! include 'COMMON.CONTACTS'
8200 ! include 'COMMON.TORSION'
8201 ! include 'COMMON.VAR'
8202 ! include 'COMMON.GEO'
8203 real(kind=8),dimension(2) :: vv,vv1
8204 real(kind=8),dimension(2,2) :: pizda,auxmat,pizda1
8207 !el common /kutas/ lprn
8208 integer :: i,j,k,l,imat,itk,iii,kkk,lll,ind
8209 real(kind=8) :: s1,s2,s3,s4,s5
8210 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8212 ! Parallel Antiparallel C
8218 ! \ j|/k\| / \ |/k\|l / C
8223 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8224 itk=itortyp(itype(k))
8225 s1= scalar2(AEAb1(1,2,imat),CUgb2(1,i))
8226 s2=-scalar2(AEAb2(1,1,imat),Ug2Db1t(1,k))
8227 s3= scalar2(AEAb2(1,1,imat),CUgb2(1,k))
8228 call transpose2(EUgC(1,1,k),auxmat(1,1))
8229 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
8230 vv1(1)=pizda1(1,1)-pizda1(2,2)
8231 vv1(2)=pizda1(1,2)+pizda1(2,1)
8232 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
8233 vv(1)=AEAb1(1,2,imat)*b1(1,itk)-AEAb1(2,2,imat)*b1(2,itk)
8234 vv(2)=AEAb1(1,2,imat)*b1(2,itk)+AEAb1(2,2,imat)*b1(1,itk)
8235 s5=scalar2(vv(1),Dtobr2(1,i))
8236 !d write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4', s4,' s5',s5
8237 eello6_graph1=-0.5d0*(s1+s2+s3+s4+s5)
8238 if (i.gt.1) g_corr6_loc(i-1)=g_corr6_loc(i-1) &
8239 -0.5d0*ekont*(scalar2(AEAb1(1,2,imat),CUgb2der(1,i)) &
8240 -scalar2(AEAb2derg(1,2,1,imat),Ug2Db1t(1,k)) &
8241 +scalar2(AEAb2derg(1,2,1,imat),CUgb2(1,k)) &
8242 +0.5d0*scalar2(vv1(1),Dtobr2der(1,i)) &
8243 +scalar2(vv(1),Dtobr2der(1,i)))
8244 call matmat2(AEAderg(1,1,imat),auxmat(1,1),pizda1(1,1))
8245 vv1(1)=pizda1(1,1)-pizda1(2,2)
8246 vv1(2)=pizda1(1,2)+pizda1(2,1)
8247 vv(1)=AEAb1derg(1,2,imat)*b1(1,itk)-AEAb1derg(2,2,imat)*b1(2,itk)
8248 vv(2)=AEAb1derg(1,2,imat)*b1(2,itk)+AEAb1derg(2,2,imat)*b1(1,itk)
8250 g_corr6_loc(l-1)=g_corr6_loc(l-1) &
8251 +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i)) &
8252 -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k)) &
8253 +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k)) &
8254 +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
8256 g_corr6_loc(j-1)=g_corr6_loc(j-1) &
8257 +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i)) &
8258 -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k)) &
8259 +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k)) &
8260 +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
8262 call transpose2(EUgCder(1,1,k),auxmat(1,1))
8263 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
8264 vv1(1)=pizda1(1,1)-pizda1(2,2)
8265 vv1(2)=pizda1(1,2)+pizda1(2,1)
8266 if (k.gt.1) g_corr6_loc(k-1)=g_corr6_loc(k-1) &
8267 +ekont*(-0.5d0*(-scalar2(AEAb2(1,1,imat),Ug2Db1tder(1,k)) &
8268 +scalar2(AEAb2(1,1,imat),CUgb2der(1,k)) &
8269 +0.5d0*scalar2(vv1(1),Dtobr2(1,i))))
8278 s1= scalar2(AEAb1derx(1,lll,kkk,iii,2,imat),CUgb2(1,i))
8279 s2=-scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),Ug2Db1t(1,k))
8280 s3= scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),CUgb2(1,k))
8281 call transpose2(EUgC(1,1,k),auxmat(1,1))
8282 call matmat2(AEAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),&
8284 vv1(1)=pizda1(1,1)-pizda1(2,2)
8285 vv1(2)=pizda1(1,2)+pizda1(2,1)
8286 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
8287 vv(1)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(1,itk) &
8288 -AEAb1derx(2,lll,kkk,iii,2,imat)*b1(2,itk)
8289 vv(2)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(2,itk) &
8290 +AEAb1derx(2,lll,kkk,iii,2,imat)*b1(1,itk)
8291 s5=scalar2(vv(1),Dtobr2(1,i))
8292 derx(lll,kkk,ind)=derx(lll,kkk,ind)-0.5d0*(s1+s2+s3+s4+s5)
8297 end function eello6_graph1
8298 !-----------------------------------------------------------------------------
8299 real(kind=8) function eello6_graph2(i,j,k,l,jj,kk,swap)
8301 ! implicit real*8 (a-h,o-z)
8302 ! include 'DIMENSIONS'
8303 ! include 'COMMON.IOUNITS'
8304 ! include 'COMMON.CHAIN'
8305 ! include 'COMMON.DERIV'
8306 ! include 'COMMON.INTERACT'
8307 ! include 'COMMON.CONTACTS'
8308 ! include 'COMMON.TORSION'
8309 ! include 'COMMON.VAR'
8310 ! include 'COMMON.GEO'
8312 real(kind=8),dimension(2) :: vv,auxvec,auxvec1,auxvec2
8313 real(kind=8),dimension(2,2) :: pizda,auxmat,auxmat1
8315 !el common /kutas/ lprn
8316 integer :: i,j,k,l,jj,kk,iii,kkk,lll,jjj,mmm
8317 real(kind=8) :: s2,s3,s4
8318 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8320 ! Parallel Antiparallel C
8326 ! \ j|/k\| \ |/k\|l C
8331 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8332 !d write (2,*) 'eello6_graph2: i,',i,' j',j,' k',k,' l',l
8333 ! AL 7/4/01 s1 would occur in the sixth-order moment,
8334 ! but not in a cluster cumulant
8336 s1=dip(1,jj,i)*dip(1,kk,k)
8338 call matvec2(ADtEA1(1,1,1),Ub2(1,k),auxvec(1))
8339 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
8340 call matvec2(ADtEA(1,1,2),Ub2(1,l),auxvec1(1))
8341 s3=-0.5d0*scalar2(Ub2(1,j),auxvec1(1))
8342 call transpose2(EUg(1,1,k),auxmat(1,1))
8343 call matmat2(ADtEA1(1,1,1),auxmat(1,1),pizda(1,1))
8344 vv(1)=pizda(1,1)-pizda(2,2)
8345 vv(2)=pizda(1,2)+pizda(2,1)
8346 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
8347 !d write (2,*) 'eello6_graph2:','s1',s1,' s2',s2,' s3',s3,' s4',s4
8349 eello6_graph2=-(s1+s2+s3+s4)
8351 eello6_graph2=-(s2+s3+s4)
8354 ! Derivatives in gamma(i-1)
8357 s1=dipderg(1,jj,i)*dip(1,kk,k)
8359 s2=-0.5d0*scalar2(Ub2der(1,i),auxvec(1))
8360 call matvec2(ADtEAderg(1,1,1,2),Ub2(1,l),auxvec2(1))
8361 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
8362 s4=-0.25d0*scalar2(vv(1),Dtobr2der(1,i))
8364 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
8366 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
8368 ! g_corr6_loc(i-1)=g_corr6_loc(i-1)-s3
8370 ! Derivatives in gamma(k-1)
8372 s1=dip(1,jj,i)*dipderg(1,kk,k)
8374 call matvec2(ADtEA1(1,1,1),Ub2der(1,k),auxvec2(1))
8375 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
8376 call matvec2(ADtEAderg(1,1,2,2),Ub2(1,l),auxvec2(1))
8377 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
8378 call transpose2(EUgder(1,1,k),auxmat1(1,1))
8379 call matmat2(ADtEA1(1,1,1),auxmat1(1,1),pizda(1,1))
8380 vv(1)=pizda(1,1)-pizda(2,2)
8381 vv(2)=pizda(1,2)+pizda(2,1)
8382 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
8384 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
8386 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
8388 ! g_corr6_loc(k-1)=g_corr6_loc(k-1)-s3
8389 ! Derivatives in gamma(j-1) or gamma(l-1)
8392 s1=dipderg(3,jj,i)*dip(1,kk,k)
8394 call matvec2(ADtEA1derg(1,1,1,1),Ub2(1,k),auxvec2(1))
8395 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
8396 s3=-0.5d0*scalar2(Ub2der(1,j),auxvec1(1))
8397 call matmat2(ADtEA1derg(1,1,1,1),auxmat(1,1),pizda(1,1))
8398 vv(1)=pizda(1,1)-pizda(2,2)
8399 vv(2)=pizda(1,2)+pizda(2,1)
8400 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
8403 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
8405 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
8408 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s3+s4)
8409 ! g_corr6_loc(j-1)=g_corr6_loc(j-1)-s3
8411 ! Derivatives in gamma(l-1) or gamma(j-1)
8414 s1=dip(1,jj,i)*dipderg(3,kk,k)
8416 call matvec2(ADtEA1derg(1,1,2,1),Ub2(1,k),auxvec2(1))
8417 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
8418 call matvec2(ADtEA(1,1,2),Ub2der(1,l),auxvec2(1))
8419 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
8420 call matmat2(ADtEA1derg(1,1,2,1),auxmat(1,1),pizda(1,1))
8421 vv(1)=pizda(1,1)-pizda(2,2)
8422 vv(2)=pizda(1,2)+pizda(2,1)
8423 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
8426 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
8428 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
8431 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s3+s4)
8432 ! g_corr6_loc(l-1)=g_corr6_loc(l-1)-s3
8434 ! Cartesian derivatives.
8436 write (2,*) 'In eello6_graph2'
8438 write (2,*) 'iii=',iii
8440 write (2,*) 'kkk=',kkk
8442 write (2,'(3(2f10.5),5x)') &
8443 ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
8453 s1=dipderx(lll,kkk,1,jj,i)*dip(1,kk,k)
8455 s1=dip(1,jj,i)*dipderx(lll,kkk,1,kk,k)
8458 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,1),Ub2(1,k),&
8460 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
8461 call matvec2(ADtEAderx(1,1,lll,kkk,iii,2),Ub2(1,l),&
8463 s3=-0.5d0*scalar2(Ub2(1,j),auxvec(1))
8464 call transpose2(EUg(1,1,k),auxmat(1,1))
8465 call matmat2(ADtEA1derx(1,1,lll,kkk,iii,1),auxmat(1,1),&
8467 vv(1)=pizda(1,1)-pizda(2,2)
8468 vv(2)=pizda(1,2)+pizda(2,1)
8469 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
8470 !d write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4',s4
8472 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
8474 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
8477 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
8479 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
8485 end function eello6_graph2
8486 !-----------------------------------------------------------------------------
8487 real(kind=8) function eello6_graph3(i,j,k,l,jj,kk,swap)
8488 ! implicit real*8 (a-h,o-z)
8489 ! include 'DIMENSIONS'
8490 ! include 'COMMON.IOUNITS'
8491 ! include 'COMMON.CHAIN'
8492 ! include 'COMMON.DERIV'
8493 ! include 'COMMON.INTERACT'
8494 ! include 'COMMON.CONTACTS'
8495 ! include 'COMMON.TORSION'
8496 ! include 'COMMON.VAR'
8497 ! include 'COMMON.GEO'
8498 real(kind=8),dimension(2) :: vv,auxvec
8499 real(kind=8),dimension(2,2) :: pizda,auxmat
8501 integer :: i,j,k,l,jj,kk,iti,itj1,itk,itk1,iii,lll,kkk,itl1
8502 real(kind=8) :: s1,s2,s3,s4
8503 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8505 ! Parallel Antiparallel C
8511 ! j|/k\| / |/k\|l / C
8516 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8518 ! 4/7/01 AL Component s1 was removed, because it pertains to the respective
8519 ! energy moment and not to the cluster cumulant.
8520 iti=itortyp(itype(i))
8521 if (j.lt.nres-1) then
8522 itj1=itortyp(itype(j+1))
8526 itk=itortyp(itype(k))
8527 itk1=itortyp(itype(k+1))
8528 if (l.lt.nres-1) then
8529 itl1=itortyp(itype(l+1))
8534 s1=dip(4,jj,i)*dip(4,kk,k)
8536 call matvec2(AECA(1,1,1),b1(1,itk1),auxvec(1))
8537 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
8538 call matvec2(AECA(1,1,2),b1(1,itl1),auxvec(1))
8539 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
8540 call transpose2(EE(1,1,itk),auxmat(1,1))
8541 call matmat2(auxmat(1,1),AECA(1,1,1),pizda(1,1))
8542 vv(1)=pizda(1,1)+pizda(2,2)
8543 vv(2)=pizda(2,1)-pizda(1,2)
8544 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
8545 !d write (2,*) 'eello6_graph3:','s1',s1,' s2',s2,' s3',s3,' s4',s4,
8546 !d & "sum",-(s2+s3+s4)
8548 eello6_graph3=-(s1+s2+s3+s4)
8550 eello6_graph3=-(s2+s3+s4)
8553 ! Derivatives in gamma(k-1)
8554 call matvec2(AECAderg(1,1,2),b1(1,itl1),auxvec(1))
8555 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
8556 s4=-0.25d0*scalar2(vv(1),Ctobrder(1,k))
8557 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s3+s4)
8558 ! Derivatives in gamma(l-1)
8559 call matvec2(AECAderg(1,1,1),b1(1,itk1),auxvec(1))
8560 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
8561 call matmat2(auxmat(1,1),AECAderg(1,1,1),pizda(1,1))
8562 vv(1)=pizda(1,1)+pizda(2,2)
8563 vv(2)=pizda(2,1)-pizda(1,2)
8564 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
8565 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
8566 ! Cartesian derivatives.
8572 s1=dipderx(lll,kkk,4,jj,i)*dip(4,kk,k)
8574 s1=dip(4,jj,i)*dipderx(lll,kkk,4,kk,k)
8577 call matvec2(AECAderx(1,1,lll,kkk,iii,1),b1(1,itk1),&
8579 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
8580 call matvec2(AECAderx(1,1,lll,kkk,iii,2),b1(1,itl1),&
8582 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
8583 call matmat2(auxmat(1,1),AECAderx(1,1,lll,kkk,iii,1),&
8585 vv(1)=pizda(1,1)+pizda(2,2)
8586 vv(2)=pizda(2,1)-pizda(1,2)
8587 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
8589 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
8591 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
8594 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
8596 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
8598 ! derx(lll,kkk,iii)=derx(lll,kkk,iii)-s4
8603 end function eello6_graph3
8604 !-----------------------------------------------------------------------------
8605 real(kind=8) function eello6_graph4(i,j,k,l,jj,kk,imat,swap)
8606 ! implicit real*8 (a-h,o-z)
8607 ! include 'DIMENSIONS'
8608 ! include 'COMMON.IOUNITS'
8609 ! include 'COMMON.CHAIN'
8610 ! include 'COMMON.DERIV'
8611 ! include 'COMMON.INTERACT'
8612 ! include 'COMMON.CONTACTS'
8613 ! include 'COMMON.TORSION'
8614 ! include 'COMMON.VAR'
8615 ! include 'COMMON.GEO'
8616 ! include 'COMMON.FFIELD'
8617 real(kind=8),dimension(2) :: vv,auxvec,auxvec1
8618 real(kind=8),dimension(2,2) :: pizda,auxmat,auxmat1
8620 integer :: i,j,k,l,jj,kk,imat,iti,itj,itj1,itk,itk1,itl,itl1,&
8622 real(kind=8) :: s1,s2,s3,s4
8623 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8625 ! Parallel Antiparallel C
8631 ! \ j|/k\| \ |/k\|l C
8636 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8638 ! 4/7/01 AL Component s1 was removed, because it pertains to the respective
8639 ! energy moment and not to the cluster cumulant.
8640 !d write (2,*) 'eello_graph4: wturn6',wturn6
8641 iti=itortyp(itype(i))
8642 itj=itortyp(itype(j))
8643 if (j.lt.nres-1) then
8644 itj1=itortyp(itype(j+1))
8648 itk=itortyp(itype(k))
8649 if (k.lt.nres-1) then
8650 itk1=itortyp(itype(k+1))
8654 itl=itortyp(itype(l))
8655 if (l.lt.nres-1) then
8656 itl1=itortyp(itype(l+1))
8660 !d write (2,*) 'eello6_graph4:','i',i,' j',j,' k',k,' l',l
8661 !d write (2,*) 'iti',iti,' itj',itj,' itj1',itj1,' itk',itk,
8662 !d & ' itl',itl,' itl1',itl1
8665 s1=dip(3,jj,i)*dip(3,kk,k)
8667 s1=dip(2,jj,j)*dip(2,kk,l)
8670 call matvec2(AECA(1,1,imat),Ub2(1,k),auxvec(1))
8671 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
8673 call matvec2(ADtEA1(1,1,3-imat),b1(1,itj1),auxvec1(1))
8674 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
8676 call matvec2(ADtEA1(1,1,3-imat),b1(1,itl1),auxvec1(1))
8677 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
8679 call transpose2(EUg(1,1,k),auxmat(1,1))
8680 call matmat2(AECA(1,1,imat),auxmat(1,1),pizda(1,1))
8681 vv(1)=pizda(1,1)-pizda(2,2)
8682 vv(2)=pizda(2,1)+pizda(1,2)
8683 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
8684 !d write (2,*) 'eello6_graph4:','s1',s1,' s2',s2,' s3',s3,' s4',s4
8686 eello6_graph4=-(s1+s2+s3+s4)
8688 eello6_graph4=-(s2+s3+s4)
8690 ! Derivatives in gamma(i-1)
8694 s1=dipderg(2,jj,i)*dip(3,kk,k)
8696 s1=dipderg(4,jj,j)*dip(2,kk,l)
8699 s2=0.5d0*scalar2(Ub2der(1,i),auxvec(1))
8701 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,itj1),auxvec1(1))
8702 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
8704 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,itl1),auxvec1(1))
8705 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
8707 s4=0.25d0*scalar2(vv(1),Dtobr2der(1,i))
8708 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
8709 !d write (2,*) 'turn6 derivatives'
8711 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s1+s2+s3+s4)
8713 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s2+s3+s4)
8717 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
8719 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
8723 ! Derivatives in gamma(k-1)
8726 s1=dip(3,jj,i)*dipderg(2,kk,k)
8728 s1=dip(2,jj,j)*dipderg(4,kk,l)
8731 call matvec2(AECA(1,1,imat),Ub2der(1,k),auxvec1(1))
8732 s2=0.5d0*scalar2(Ub2(1,i),auxvec1(1))
8734 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,itj1),auxvec1(1))
8735 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
8737 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,itl1),auxvec1(1))
8738 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
8740 call transpose2(EUgder(1,1,k),auxmat1(1,1))
8741 call matmat2(AECA(1,1,imat),auxmat1(1,1),pizda(1,1))
8742 vv(1)=pizda(1,1)-pizda(2,2)
8743 vv(2)=pizda(2,1)+pizda(1,2)
8744 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
8745 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
8747 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s1+s2+s3+s4)
8749 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s2+s3+s4)
8753 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
8755 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
8758 ! Derivatives in gamma(j-1) or gamma(l-1)
8759 if (l.eq.j+1 .and. l.gt.1) then
8760 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
8761 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
8762 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
8763 vv(1)=pizda(1,1)-pizda(2,2)
8764 vv(2)=pizda(2,1)+pizda(1,2)
8765 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
8766 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
8767 else if (j.gt.1) then
8768 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
8769 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
8770 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
8771 vv(1)=pizda(1,1)-pizda(2,2)
8772 vv(2)=pizda(2,1)+pizda(1,2)
8773 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
8774 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
8775 gel_loc_turn6(j-1)=gel_loc_turn6(j-1)-ekont*(s2+s4)
8777 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s4)
8780 ! Cartesian derivatives.
8787 s1=dipderx(lll,kkk,3,jj,i)*dip(3,kk,k)
8789 s1=dipderx(lll,kkk,2,jj,j)*dip(2,kk,l)
8793 s1=dip(3,jj,i)*dipderx(lll,kkk,3,kk,k)
8795 s1=dip(2,jj,j)*dipderx(lll,kkk,2,kk,l)
8799 call matvec2(AECAderx(1,1,lll,kkk,iii,imat),Ub2(1,k),&
8801 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
8803 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),&
8804 b1(1,itj1),auxvec(1))
8805 s3=-0.5d0*scalar2(b1(1,itj),auxvec(1))
8807 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),&
8808 b1(1,itl1),auxvec(1))
8809 s3=-0.5d0*scalar2(b1(1,itl),auxvec(1))
8811 call matmat2(AECAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),&
8813 vv(1)=pizda(1,1)-pizda(2,2)
8814 vv(2)=pizda(2,1)+pizda(1,2)
8815 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
8817 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
8819 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii) &
8822 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii) &
8825 derx_turn(lll,kkk,iii)=derx_turn(lll,kkk,iii)-s3
8828 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s1+s2+s4)
8830 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s2+s4)
8832 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
8836 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
8838 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
8841 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
8843 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
8850 end function eello6_graph4
8851 !-----------------------------------------------------------------------------
8852 real(kind=8) function eello_turn6(i,jj,kk)
8853 ! implicit real*8 (a-h,o-z)
8854 ! include 'DIMENSIONS'
8855 ! include 'COMMON.IOUNITS'
8856 ! include 'COMMON.CHAIN'
8857 ! include 'COMMON.DERIV'
8858 ! include 'COMMON.INTERACT'
8859 ! include 'COMMON.CONTACTS'
8860 ! include 'COMMON.TORSION'
8861 ! include 'COMMON.VAR'
8862 ! include 'COMMON.GEO'
8863 real(kind=8),dimension(2) :: vtemp1,vtemp2,vtemp3,vtemp4,gvec
8864 real(kind=8),dimension(2,2) :: atemp,auxmat,achuj_temp,gtemp
8865 real(kind=8),dimension(3) :: ggg1,ggg2
8866 real(kind=8),dimension(2) :: vtemp1d,vtemp2d,vtemp3d,vtemp4d,gvecd
8867 real(kind=8),dimension(2,2) :: atempd,auxmatd,achuj_tempd,gtempd
8868 ! 4/7/01 AL Components s1, s8, and s13 were removed, because they pertain to
8869 ! the respective energy moment and not to the cluster cumulant.
8871 integer :: i,jj,kk,j,k,l,iti,itk,itk1,itl,itj,iii,kkk,lll
8872 integer :: j1,j2,l1,l2,ll
8873 real(kind=8) :: s1,s2,s8,s13,s12,eello6_5,eel_turn6
8874 real(kind=8) :: s1d,s8d,s12d,s2d,gturn6ij,gturn6kl
8883 iti=itortyp(itype(i))
8884 itk=itortyp(itype(k))
8885 itk1=itortyp(itype(k+1))
8886 itl=itortyp(itype(l))
8887 itj=itortyp(itype(j))
8888 !d write (2,*) 'itk',itk,' itk1',itk1,' itl',itl,' itj',itj
8889 !d write (2,*) 'i',i,' k',k,' j',j,' l',l
8890 !d if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
8895 !d & 'EELLO6: Contacts have occurred for peptide groups',i,j,
8897 !d call checkint_turn6(i,jj,kk,eel_turn6_num)
8901 derx_turn(lll,kkk,iii)=0.0d0
8908 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
8910 !d write (2,*) 'eello6_5',eello6_5
8912 call transpose2(AEA(1,1,1),auxmat(1,1))
8913 call matmat2(EUg(1,1,i+1),auxmat(1,1),auxmat(1,1))
8914 ss1=scalar2(Ub2(1,i+2),b1(1,itl))
8915 s1 = (auxmat(1,1)+auxmat(2,2))*ss1
8917 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1(1))
8918 call matvec2(AEA(1,1,1),vtemp1(1),vtemp1(1))
8919 s2 = scalar2(b1(1,itk),vtemp1(1))
8921 call transpose2(AEA(1,1,2),atemp(1,1))
8922 call matmat2(atemp(1,1),EUg(1,1,i+4),atemp(1,1))
8923 call matvec2(Ug2(1,1,i+2),dd(1,1,itk1),vtemp2(1))
8924 s8 = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
8926 call matmat2(EUg(1,1,i+3),AEA(1,1,2),auxmat(1,1))
8927 call matvec2(auxmat(1,1),Ub2(1,i+4),vtemp3(1))
8928 s12 = scalar2(Ub2(1,i+2),vtemp3(1))
8930 call transpose2(a_chuj(1,1,kk,i+1),achuj_temp(1,1))
8931 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtemp(1,1))
8932 call matmat2(gtemp(1,1),EUg(1,1,i+3),gtemp(1,1))
8933 call matvec2(a_chuj(1,1,jj,i),Ub2(1,i+4),vtemp4(1))
8934 ss13 = scalar2(b1(1,itk),vtemp4(1))
8935 s13 = (gtemp(1,1)+gtemp(2,2))*ss13
8937 ! write (2,*) 's1,s2,s8,s12,s13',s1,s2,s8,s12,s13
8943 eel_turn6 = eello6_5 - 0.5d0*(s1+s2+s12+s8+s13)
8944 ! Derivatives in gamma(i+2)
8948 call transpose2(AEA(1,1,1),auxmatd(1,1))
8949 call matmat2(EUgder(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
8950 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
8951 call transpose2(AEAderg(1,1,2),atempd(1,1))
8952 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
8953 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
8955 call matmat2(EUg(1,1,i+3),AEAderg(1,1,2),auxmatd(1,1))
8956 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
8957 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
8963 gel_loc_turn6(i)=gel_loc_turn6(i)-0.5d0*ekont*(s1d+s8d+s12d)
8964 ! Derivatives in gamma(i+3)
8966 call transpose2(AEA(1,1,1),auxmatd(1,1))
8967 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
8968 ss1d=scalar2(Ub2der(1,i+2),b1(1,itl))
8969 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1d
8971 call matvec2(EUgder(1,1,i+2),b1(1,itl),vtemp1d(1))
8972 call matvec2(AEA(1,1,1),vtemp1d(1),vtemp1d(1))
8973 s2d = scalar2(b1(1,itk),vtemp1d(1))
8975 call matvec2(Ug2der(1,1,i+2),dd(1,1,itk1),vtemp2d(1))
8976 s8d = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,itl),vtemp2d(1))
8978 s12d = scalar2(Ub2der(1,i+2),vtemp3(1))
8980 call matmat2(achuj_temp(1,1),EUgder(1,1,i+2),gtempd(1,1))
8981 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
8982 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
8990 gel_loc_turn6(i+1)=gel_loc_turn6(i+1) &
8991 -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
8993 gel_loc_turn6(i+1)=gel_loc_turn6(i+1) &
8994 -0.5d0*ekont*(s2d+s12d)
8996 ! Derivatives in gamma(i+4)
8997 call matmat2(EUgder(1,1,i+3),AEA(1,1,2),auxmatd(1,1))
8998 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
8999 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
9001 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtempd(1,1))
9002 call matmat2(gtempd(1,1),EUgder(1,1,i+3),gtempd(1,1))
9003 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
9011 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d+s13d)
9013 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d)
9015 ! Derivatives in gamma(i+5)
9017 call transpose2(AEAderg(1,1,1),auxmatd(1,1))
9018 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
9019 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
9021 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1d(1))
9022 call matvec2(AEAderg(1,1,1),vtemp1d(1),vtemp1d(1))
9023 s2d = scalar2(b1(1,itk),vtemp1d(1))
9025 call transpose2(AEA(1,1,2),atempd(1,1))
9026 call matmat2(atempd(1,1),EUgder(1,1,i+4),atempd(1,1))
9027 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
9029 call matvec2(auxmat(1,1),Ub2der(1,i+4),vtemp3d(1))
9030 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
9032 call matvec2(a_chuj(1,1,jj,i),Ub2der(1,i+4),vtemp4d(1))
9033 ss13d = scalar2(b1(1,itk),vtemp4d(1))
9034 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
9042 gel_loc_turn6(i+3)=gel_loc_turn6(i+3) &
9043 -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
9045 gel_loc_turn6(i+3)=gel_loc_turn6(i+3) &
9046 -0.5d0*ekont*(s2d+s12d)
9048 ! Cartesian derivatives
9053 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmatd(1,1))
9054 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
9055 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
9057 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1(1))
9058 call matvec2(AEAderx(1,1,lll,kkk,iii,1),vtemp1(1),&
9060 s2d = scalar2(b1(1,itk),vtemp1d(1))
9062 call transpose2(AEAderx(1,1,lll,kkk,iii,2),atempd(1,1))
9063 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
9064 s8d = -(atempd(1,1)+atempd(2,2))* &
9065 scalar2(cc(1,1,itl),vtemp2(1))
9067 call matmat2(EUg(1,1,i+3),AEAderx(1,1,lll,kkk,iii,2),&
9069 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
9070 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
9077 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii) &
9080 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii) &
9084 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii) &
9087 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii) &
9096 call transpose2(a_chuj_der(1,1,lll,kkk,kk,i+1),&
9098 call matmat2(achuj_tempd(1,1),EUg(1,1,i+2),gtempd(1,1))
9099 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
9100 s13d=(gtempd(1,1)+gtempd(2,2))*ss13
9101 derx_turn(lll,kkk,2) = derx_turn(lll,kkk,2)-0.5d0*s13d
9102 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),Ub2(1,i+4),&
9104 ss13d = scalar2(b1(1,itk),vtemp4d(1))
9105 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
9106 derx_turn(lll,kkk,1) = derx_turn(lll,kkk,1)-0.5d0*s13d
9110 !d write(iout,*) 'eel6_turn6',eel_turn6,' eel_turn6_num',
9111 !d & 16*eel_turn6_num
9113 if (j.lt.nres-1) then
9120 if (l.lt.nres-1) then
9128 !grad ggg1(ll)=eel_turn6*g_contij(ll,1)
9129 !grad ggg2(ll)=eel_turn6*g_contij(ll,2)
9130 !grad ghalf=0.5d0*ggg1(ll)
9132 gturn6ij=eel_turn6*g_contij(ll,1)+ekont*derx_turn(ll,1,1)
9133 gturn6kl=eel_turn6*g_contij(ll,2)+ekont*derx_turn(ll,1,2)
9134 gcorr6_turn(ll,i)=gcorr6_turn(ll,i) & !+ghalf
9135 +ekont*derx_turn(ll,2,1)
9136 gcorr6_turn(ll,i+1)=gcorr6_turn(ll,i+1)+ekont*derx_turn(ll,3,1)
9137 gcorr6_turn(ll,j)=gcorr6_turn(ll,j) & !+ghalf
9138 +ekont*derx_turn(ll,4,1)
9139 gcorr6_turn(ll,j1)=gcorr6_turn(ll,j1)+ekont*derx_turn(ll,5,1)
9140 gcorr6_turn_long(ll,j)=gcorr6_turn_long(ll,j)+gturn6ij
9141 gcorr6_turn_long(ll,i)=gcorr6_turn_long(ll,i)-gturn6ij
9142 !grad ghalf=0.5d0*ggg2(ll)
9144 gcorr6_turn(ll,k)=gcorr6_turn(ll,k) & !+ghalf
9145 +ekont*derx_turn(ll,2,2)
9146 gcorr6_turn(ll,k+1)=gcorr6_turn(ll,k+1)+ekont*derx_turn(ll,3,2)
9147 gcorr6_turn(ll,l)=gcorr6_turn(ll,l) & !+ghalf
9148 +ekont*derx_turn(ll,4,2)
9149 gcorr6_turn(ll,l1)=gcorr6_turn(ll,l1)+ekont*derx_turn(ll,5,2)
9150 gcorr6_turn_long(ll,l)=gcorr6_turn_long(ll,l)+gturn6kl
9151 gcorr6_turn_long(ll,k)=gcorr6_turn_long(ll,k)-gturn6kl
9156 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg1(ll)
9161 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg2(ll)
9167 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,1)
9172 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,2)
9176 !d write (2,*) iii,g_corr6_loc(iii)
9178 eello_turn6=ekont*eel_turn6
9179 !d write (2,*) 'ekont',ekont
9180 !d write (2,*) 'eel_turn6',ekont*eel_turn6
9182 end function eello_turn6
9183 !-----------------------------------------------------------------------------
9184 subroutine MATVEC2(A1,V1,V2)
9185 !DIR$ INLINEALWAYS MATVEC2
9187 !DEC$ ATTRIBUTES FORCEINLINE::MATVEC2
9189 ! implicit real*8 (a-h,o-z)
9190 ! include 'DIMENSIONS'
9191 real(kind=8),dimension(2) :: V1,V2
9192 real(kind=8),dimension(2,2) :: A1
9193 real(kind=8) :: vaux1,vaux2
9197 ! 3 VI=VI+A1(I,K)*V1(K)
9201 vaux1=a1(1,1)*v1(1)+a1(1,2)*v1(2)
9202 vaux2=a1(2,1)*v1(1)+a1(2,2)*v1(2)
9206 end subroutine MATVEC2
9207 !-----------------------------------------------------------------------------
9208 subroutine MATMAT2(A1,A2,A3)
9210 !DEC$ ATTRIBUTES FORCEINLINE::MATMAT2
9212 ! implicit real*8 (a-h,o-z)
9213 ! include 'DIMENSIONS'
9214 real(kind=8),dimension(2,2) :: A1,A2,A3
9215 real(kind=8) :: ai3_11,ai3_12,ai3_21,ai3_22
9216 ! DIMENSION AI3(2,2)
9220 ! A3IJ=A3IJ+A1(I,K)*A2(K,J)
9226 ai3_11=a1(1,1)*a2(1,1)+a1(1,2)*a2(2,1)
9227 ai3_12=a1(1,1)*a2(1,2)+a1(1,2)*a2(2,2)
9228 ai3_21=a1(2,1)*a2(1,1)+a1(2,2)*a2(2,1)
9229 ai3_22=a1(2,1)*a2(1,2)+a1(2,2)*a2(2,2)
9235 end subroutine MATMAT2
9236 !-----------------------------------------------------------------------------
9237 real(kind=8) function scalar2(u,v)
9238 !DIR$ INLINEALWAYS scalar2
9240 real(kind=8),dimension(2) :: u,v
9243 scalar2=u(1)*v(1)+u(2)*v(2)
9245 end function scalar2
9246 !-----------------------------------------------------------------------------
9247 subroutine transpose2(a,at)
9248 !DIR$ INLINEALWAYS transpose2
9250 !DEC$ ATTRIBUTES FORCEINLINE::transpose2
9253 real(kind=8),dimension(2,2) :: a,at
9259 end subroutine transpose2
9260 !-----------------------------------------------------------------------------
9261 subroutine transpose(n,a,at)
9264 real(kind=8),dimension(n,n) :: a,at
9271 end subroutine transpose
9272 !-----------------------------------------------------------------------------
9273 subroutine prodmat3(a1,a2,kk,transp,prod)
9274 !DIR$ INLINEALWAYS prodmat3
9276 !DEC$ ATTRIBUTES FORCEINLINE::prodmat3
9280 real(kind=8),dimension(2,2) :: a1,a2,a2t,kk,prod
9282 !rc double precision auxmat(2,2),prod_(2,2)
9285 !rc call transpose2(kk(1,1),auxmat(1,1))
9286 !rc call matmat2(a1(1,1),auxmat(1,1),auxmat(1,1))
9287 !rc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
9289 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,1) &
9290 +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,1)
9291 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,2) &
9292 +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,2)
9293 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,1) &
9294 +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,1)
9295 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,2) &
9296 +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,2)
9299 !rc call matmat2(a1(1,1),kk(1,1),auxmat(1,1))
9300 !rc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
9302 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,1) &
9303 +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,1)
9304 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,2) &
9305 +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,2)
9306 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,1) &
9307 +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,1)
9308 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,2) &
9309 +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,2)
9312 ! call transpose2(a2(1,1),a2t(1,1))
9315 !rc print *,((prod_(i,j),i=1,2),j=1,2)
9316 !rc print *,((prod(i,j),i=1,2),j=1,2)
9319 end subroutine prodmat3
9320 !-----------------------------------------------------------------------------
9321 ! energy_p_new_barrier.F
9322 !-----------------------------------------------------------------------------
9323 subroutine sum_gradient
9324 ! implicit real*8 (a-h,o-z)
9325 use io_base, only: pdbout
9326 ! include 'DIMENSIONS'
9330 !MS$ATTRIBUTES C :: proc_proc
9336 real(kind=8),dimension(3,nres) :: gradbufc,gradbufx,gradbufc_sum,&
9337 gloc_scbuf !(3,maxres)
9339 real(kind=8),dimension(4*nres) :: glocbuf !(4*maxres)
9342 integer :: i,j,k,ierror,ierr
9343 real(kind=8) :: gvdwc_norm,gvdwc_scp_norm,gelc_norm,gvdwpp_norm,&
9344 gradb_norm,ghpbc_norm,gradcorr_norm,gel_loc_norm,&
9345 gcorr3_turn_norm,gcorr4_turn_norm,gradcorr5_norm,&
9346 gradcorr6_norm,gcorr6_turn_norm,gsccorr_norm,&
9347 gscloc_norm,gvdwx_norm,gradx_scp_norm,ghpbx_norm,&
9348 gradxorr_norm,gsccorrx_norm,gsclocx_norm,gcorr6_max,&
9349 gsccorr_max,gsccorrx_max,time00
9351 ! include 'COMMON.SETUP'
9352 ! include 'COMMON.IOUNITS'
9353 ! include 'COMMON.FFIELD'
9354 ! include 'COMMON.DERIV'
9355 ! include 'COMMON.INTERACT'
9356 ! include 'COMMON.SBRIDGE'
9357 ! include 'COMMON.CHAIN'
9358 ! include 'COMMON.VAR'
9359 ! include 'COMMON.CONTROL'
9360 ! include 'COMMON.TIME1'
9361 ! include 'COMMON.MAXGRAD'
9362 ! include 'COMMON.SCCOR'
9367 write (iout,*) "sum_gradient gvdwc, gvdwx"
9369 write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)') &
9370 i,(gvdwx(j,i),j=1,3),(gvdwc(j,i),j=1,3)
9380 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
9381 if (nfgtasks.gt.1 .and. fg_rank.eq.0) &
9382 call MPI_Bcast(1,1,MPI_INTEGER,king,FG_COMM,IERROR)
9385 ! 9/29/08 AL Transform parts of gradients in site coordinates to the gradient
9386 ! in virtual-bond-vector coordinates
9389 ! write (iout,*) "gel_loc gel_loc_long and gel_loc_loc"
9391 ! write (iout,'(i5,3f10.5,2x,3f10.5,2x,f10.5)')
9392 ! & i,(gel_loc(j,i),j=1,3),(gel_loc_long(j,i),j=1,3),gel_loc_loc(i)
9394 ! write (iout,*) "gel_loc_tur3 gel_loc_turn4"
9396 ! write (iout,'(i5,3f10.5,2x,f10.5)')
9397 ! & i,(gcorr4_turn(j,i),j=1,3),gel_loc_turn4(i)
9399 write (iout,*) "gvdwc gvdwc_scp gvdwc_scpp"
9401 write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)') &
9402 i,(gvdwc(j,i),j=1,3),(gvdwc_scp(j,i),j=1,3),&
9403 (gvdwc_scpp(j,i),j=1,3)
9405 write (iout,*) "gelc_long gvdwpp gel_loc_long"
9407 write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)') &
9408 i,(gelc_long(j,i),j=1,3),(gvdwpp(j,i),j=1,3),&
9409 (gelc_loc_long(j,i),j=1,3)
9416 gradbufc(j,i)=wsc*gvdwc(j,i)+ &
9417 wscp*(gvdwc_scp(j,i)+gvdwc_scpp(j,i))+ &
9418 welec*gelc_long(j,i)+wvdwpp*gvdwpp(j,i)+ &
9419 wel_loc*gel_loc_long(j,i)+ &
9420 wcorr*gradcorr_long(j,i)+ &
9421 wcorr5*gradcorr5_long(j,i)+ &
9422 wcorr6*gradcorr6_long(j,i)+ &
9423 wturn6*gcorr6_turn_long(j,i)+ &
9430 gradbufc(j,i)=wsc*gvdwc(j,i)+ &
9431 wscp*(gvdwc_scp(j,i)+gvdwc_scpp(j,i))+ &
9432 welec*gelc_long(j,i)+ &
9434 wel_loc*gel_loc_long(j,i)+ &
9435 wcorr*gradcorr_long(j,i)+ &
9436 wcorr5*gradcorr5_long(j,i)+ &
9437 wcorr6*gradcorr6_long(j,i)+ &
9438 wturn6*gcorr6_turn_long(j,i)+ &
9444 if (nfgtasks.gt.1) then
9447 write (iout,*) "gradbufc before allreduce"
9449 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
9455 gradbufc_sum(j,i)=gradbufc(j,i)
9458 ! call MPI_AllReduce(gradbufc(1,1),gradbufc_sum(1,1),3*nres,
9459 ! & MPI_DOUBLE_PRECISION,MPI_SUM,FG_COMM,IERR)
9460 ! time_reduce=time_reduce+MPI_Wtime()-time00
9462 ! write (iout,*) "gradbufc_sum after allreduce"
9464 ! write (iout,'(i3,3f10.5)') i,(gradbufc_sum(j,i),j=1,3)
9469 ! time_allreduce=time_allreduce+MPI_Wtime()-time00
9477 write (iout,*) "igrad_start",igrad_start," igrad_end",igrad_end
9478 write (iout,*) (i," jgrad_start",jgrad_start(i),&
9479 " jgrad_end ",jgrad_end(i),&
9480 i=igrad_start,igrad_end)
9483 ! Obsolete and inefficient code; we can make the effort O(n) and, therefore,
9484 ! do not parallelize this part.
9486 ! do i=igrad_start,igrad_end
9487 ! do j=jgrad_start(i),jgrad_end(i)
9489 ! gradbufc(k,i)=gradbufc(k,i)+gradbufc_sum(k,j)
9494 gradbufc(j,nres-1)=gradbufc_sum(j,nres)
9498 gradbufc(j,i)=gradbufc(j,i+1)+gradbufc_sum(j,i+1)
9502 write (iout,*) "gradbufc after summing"
9504 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
9512 write (iout,*) "gradbufc"
9514 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
9521 gradbufc_sum(j,i)=gradbufc(j,i)
9526 gradbufc(j,nres-1)=gradbufc_sum(j,nres)
9530 gradbufc(j,i)=gradbufc(j,i+1)+gradbufc_sum(j,i+1)
9535 ! gradbufc(k,i)=0.0d0
9539 ! gradbufc(k,i)=gradbufc(k,i)+gradbufc(k,j)
9545 write (iout,*) "gradbufc after summing"
9547 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
9556 gradbufc(k,nres)=0.0d0
9559 !el if (.not.allocated(gradx)) allocate(gradx(3,nres,2)) !(3,maxres,2)
9560 !el if (.not.allocated(gradc)) allocate(gradc(3,nres,2)) !(3,maxres,2)
9561 !el-----------------
9565 gradc(j,i,icg)=gradbufc(j,i)+welec*gelc(j,i)+ &
9566 wel_loc*gel_loc(j,i)+ &
9567 0.5d0*(wscp*gvdwc_scpp(j,i)+ &
9568 welec*gelc_long(j,i)+wvdwpp*gvdwpp(j,i)+ &
9569 wel_loc*gel_loc_long(j,i)+ &
9570 wcorr*gradcorr_long(j,i)+ &
9571 wcorr5*gradcorr5_long(j,i)+ &
9572 wcorr6*gradcorr6_long(j,i)+ &
9573 wturn6*gcorr6_turn_long(j,i))+ &
9575 wcorr*gradcorr(j,i)+ &
9576 wturn3*gcorr3_turn(j,i)+ &
9577 wturn4*gcorr4_turn(j,i)+ &
9578 wcorr5*gradcorr5(j,i)+ &
9579 wcorr6*gradcorr6(j,i)+ &
9580 wturn6*gcorr6_turn(j,i)+ &
9581 wsccor*gsccorc(j,i) &
9584 gradc(j,i,icg)=gradbufc(j,i)+welec*gelc(j,i)+ &
9585 wel_loc*gel_loc(j,i)+ &
9586 0.5d0*(wscp*gvdwc_scpp(j,i)+ &
9587 welec*gelc_long(j,i)+ &
9588 wel_loc*gel_loc_long(j,i)+ &
9589 !el wcorr*gcorr_long(j,i)+ & !el gcorr_long- brak deklaracji
9590 wcorr5*gradcorr5_long(j,i)+ &
9591 wcorr6*gradcorr6_long(j,i)+ &
9592 wturn6*gcorr6_turn_long(j,i))+ &
9594 wcorr*gradcorr(j,i)+ &
9595 wturn3*gcorr3_turn(j,i)+ &
9596 wturn4*gcorr4_turn(j,i)+ &
9597 wcorr5*gradcorr5(j,i)+ &
9598 wcorr6*gradcorr6(j,i)+ &
9599 wturn6*gcorr6_turn(j,i)+ &
9600 wsccor*gsccorc(j,i) &
9603 gradx(j,i,icg)=wsc*gvdwx(j,i)+wscp*gradx_scp(j,i)+ &
9604 wbond*gradbx(j,i)+ &
9605 wstrain*ghpbx(j,i)+wcorr*gradxorr(j,i)+ &
9606 wsccor*gsccorx(j,i) &
9607 +wscloc*gsclocx(j,i)
9611 write (iout,*) "gloc before adding corr"
9613 write (iout,*) i,gloc(i,icg)
9617 gloc(i,icg)=gloc(i,icg)+wcorr*gcorr_loc(i) &
9618 +wcorr5*g_corr5_loc(i) &
9619 +wcorr6*g_corr6_loc(i) &
9620 +wturn4*gel_loc_turn4(i) &
9621 +wturn3*gel_loc_turn3(i) &
9622 +wturn6*gel_loc_turn6(i) &
9623 +wel_loc*gel_loc_loc(i)
9626 write (iout,*) "gloc after adding corr"
9628 write (iout,*) i,gloc(i,icg)
9632 if (nfgtasks.gt.1) then
9635 gradbufc(j,i)=gradc(j,i,icg)
9636 gradbufx(j,i)=gradx(j,i,icg)
9640 glocbuf(i)=gloc(i,icg)
9644 write (iout,*) "gloc_sc before reduce"
9647 write (iout,*) i,j,gloc_sc(j,i,icg)
9654 gloc_scbuf(j,i)=gloc_sc(j,i,icg)
9658 call MPI_Barrier(FG_COMM,IERR)
9659 time_barrier_g=time_barrier_g+MPI_Wtime()-time00
9661 call MPI_Reduce(gradbufc(1,1),gradc(1,1,icg),3*nres,&
9662 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
9663 call MPI_Reduce(gradbufx(1,1),gradx(1,1,icg),3*nres,&
9664 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
9665 call MPI_Reduce(glocbuf(1),gloc(1,icg),4*nres,&
9666 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
9667 time_reduce=time_reduce+MPI_Wtime()-time00
9668 call MPI_Reduce(gloc_scbuf(1,1),gloc_sc(1,1,icg),3*nres,&
9669 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
9670 time_reduce=time_reduce+MPI_Wtime()-time00
9673 write (iout,*) "gloc_sc after reduce"
9676 write (iout,*) i,j,gloc_sc(j,i,icg)
9682 write (iout,*) "gloc after reduce"
9684 write (iout,*) i,gloc(i,icg)
9689 if (gnorm_check) then
9691 ! Compute the maximum elements of the gradient
9701 gcorr3_turn_max=0.0d0
9702 gcorr4_turn_max=0.0d0
9705 gcorr6_turn_max=0.0d0
9715 gvdwc_norm=dsqrt(scalar(gvdwc(1,i),gvdwc(1,i)))
9716 if (gvdwc_norm.gt.gvdwc_max) gvdwc_max=gvdwc_norm
9717 gvdwc_scp_norm=dsqrt(scalar(gvdwc_scp(1,i),gvdwc_scp(1,i)))
9718 if (gvdwc_scp_norm.gt.gvdwc_scp_max) &
9719 gvdwc_scp_max=gvdwc_scp_norm
9720 gelc_norm=dsqrt(scalar(gelc(1,i),gelc(1,i)))
9721 if (gelc_norm.gt.gelc_max) gelc_max=gelc_norm
9722 gvdwpp_norm=dsqrt(scalar(gvdwpp(1,i),gvdwpp(1,i)))
9723 if (gvdwpp_norm.gt.gvdwpp_max) gvdwpp_max=gvdwpp_norm
9724 gradb_norm=dsqrt(scalar(gradb(1,i),gradb(1,i)))
9725 if (gradb_norm.gt.gradb_max) gradb_max=gradb_norm
9726 ghpbc_norm=dsqrt(scalar(ghpbc(1,i),ghpbc(1,i)))
9727 if (ghpbc_norm.gt.ghpbc_max) ghpbc_max=ghpbc_norm
9728 gradcorr_norm=dsqrt(scalar(gradcorr(1,i),gradcorr(1,i)))
9729 if (gradcorr_norm.gt.gradcorr_max) gradcorr_max=gradcorr_norm
9730 gel_loc_norm=dsqrt(scalar(gel_loc(1,i),gel_loc(1,i)))
9731 if (gel_loc_norm.gt.gel_loc_max) gel_loc_max=gel_loc_norm
9732 gcorr3_turn_norm=dsqrt(scalar(gcorr3_turn(1,i),&
9734 if (gcorr3_turn_norm.gt.gcorr3_turn_max) &
9735 gcorr3_turn_max=gcorr3_turn_norm
9736 gcorr4_turn_norm=dsqrt(scalar(gcorr4_turn(1,i),&
9738 if (gcorr4_turn_norm.gt.gcorr4_turn_max) &
9739 gcorr4_turn_max=gcorr4_turn_norm
9740 gradcorr5_norm=dsqrt(scalar(gradcorr5(1,i),gradcorr5(1,i)))
9741 if (gradcorr5_norm.gt.gradcorr5_max) &
9742 gradcorr5_max=gradcorr5_norm
9743 gradcorr6_norm=dsqrt(scalar(gradcorr6(1,i),gradcorr6(1,i)))
9744 if (gradcorr6_norm.gt.gradcorr6_max) gcorr6_max=gradcorr6_norm
9745 gcorr6_turn_norm=dsqrt(scalar(gcorr6_turn(1,i),&
9747 if (gcorr6_turn_norm.gt.gcorr6_turn_max) &
9748 gcorr6_turn_max=gcorr6_turn_norm
9749 gsccorr_norm=dsqrt(scalar(gsccorc(1,i),gsccorc(1,i)))
9750 if (gsccorr_norm.gt.gsccorr_max) gsccorr_max=gsccorr_norm
9751 gscloc_norm=dsqrt(scalar(gscloc(1,i),gscloc(1,i)))
9752 if (gscloc_norm.gt.gscloc_max) gscloc_max=gscloc_norm
9753 gvdwx_norm=dsqrt(scalar(gvdwx(1,i),gvdwx(1,i)))
9754 if (gvdwx_norm.gt.gvdwx_max) gvdwx_max=gvdwx_norm
9755 gradx_scp_norm=dsqrt(scalar(gradx_scp(1,i),gradx_scp(1,i)))
9756 if (gradx_scp_norm.gt.gradx_scp_max) &
9757 gradx_scp_max=gradx_scp_norm
9758 ghpbx_norm=dsqrt(scalar(ghpbx(1,i),ghpbx(1,i)))
9759 if (ghpbx_norm.gt.ghpbx_max) ghpbx_max=ghpbx_norm
9760 gradxorr_norm=dsqrt(scalar(gradxorr(1,i),gradxorr(1,i)))
9761 if (gradxorr_norm.gt.gradxorr_max) gradxorr_max=gradxorr_norm
9762 gsccorrx_norm=dsqrt(scalar(gsccorx(1,i),gsccorx(1,i)))
9763 if (gsccorrx_norm.gt.gsccorrx_max) gsccorrx_max=gsccorrx_norm
9764 gsclocx_norm=dsqrt(scalar(gsclocx(1,i),gsclocx(1,i)))
9765 if (gsclocx_norm.gt.gsclocx_max) gsclocx_max=gsclocx_norm
9769 open(istat,file=statname,position="append")
9771 open(istat,file=statname,access="append")
9773 write (istat,'(1h#,21f10.2)') gvdwc_max,gvdwc_scp_max,&
9774 gelc_max,gvdwpp_max,gradb_max,ghpbc_max,&
9775 gradcorr_max,gel_loc_max,gcorr3_turn_max,gcorr4_turn_max,&
9776 gradcorr5_max,gradcorr6_max,gcorr6_turn_max,gsccorc_max,&
9777 gscloc_max,gvdwx_max,gradx_scp_max,ghpbx_max,gradxorr_max,&
9778 gsccorx_max,gsclocx_max
9780 if (gvdwc_max.gt.1.0d4) then
9781 write (iout,*) "gvdwc gvdwx gradb gradbx"
9783 write(iout,'(i5,4(3f10.2,5x))') i,(gvdwc(j,i),gvdwx(j,i),&
9784 gradb(j,i),gradbx(j,i),j=1,3)
9786 call pdbout(0.0d0,'cipiszcze',iout)
9793 write (iout,*) "gradc gradx gloc"
9795 write (iout,'(i5,3f10.5,5x,3f10.5,5x,f10.5)') &
9796 i,(gradc(j,i,icg),j=1,3),(gradx(j,i,icg),j=1,3),gloc(i,icg)
9801 time_sumgradient=time_sumgradient+MPI_Wtime()-time01
9804 end subroutine sum_gradient
9805 !-----------------------------------------------------------------------------
9807 ! implicit real*8 (a-h,o-z)
9809 ! include 'DIMENSIONS'
9810 ! include 'COMMON.CHAIN'
9811 ! include 'COMMON.DERIV'
9812 ! include 'COMMON.CALC'
9813 ! include 'COMMON.IOUNITS'
9814 real(kind=8), dimension(3) :: dcosom1,dcosom2
9816 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
9817 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
9818 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12 &
9819 -2.0D0*alf12*eps3der+sigder*sigsq_om12
9823 ! eom12=evdwij*eps1_om12
9825 ! write (iout,*) "eps2der",eps2der," eps3der",eps3der,&
9827 ! write (iout,*) "eps1_om12",eps1_om12," eps2rt_om12",eps2rt_om12
9828 ! write (iout,*) "eom1",eom1," eom2",eom2," eom12",eom12
9829 !C print *,sss_ele_cut,'in sc_grad'
9831 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
9832 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
9835 gg(k)=(gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k))*sss_ele_cut
9836 !C print *,'gg',k,gg(k)
9838 ! write (iout,*) "gg",(gg(k),k=1,3)
9840 gvdwx(k,i)=gvdwx(k,i)-gg(k) &
9841 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
9842 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv &
9845 gvdwx(k,j)=gvdwx(k,j)+gg(k) &
9846 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
9847 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv &
9850 ! write (iout,*)(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
9851 ! +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
9852 ! write (iout,*)(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
9853 ! +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
9856 ! Calculate the components of the gradient in DC and X
9860 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
9864 gvdwc(l,i)=gvdwc(l,i)-gg(l)
9865 gvdwc(l,j)=gvdwc(l,j)+gg(l)
9868 end subroutine sc_grad
9870 !-----------------------------------------------------------------------------
9871 subroutine mixder(thetai,thet_pred_mean,theta0i,E_tc_t)
9874 ! implicit real*8 (a-h,o-z)
9875 ! include 'DIMENSIONS'
9876 ! include 'COMMON.LOCAL'
9877 ! include 'COMMON.IOUNITS'
9878 !el real(kind=8) :: term1,term2,termm,diffak,ratak,&
9879 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
9880 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,
9881 real(kind=8) :: thetai,thet_pred_mean,theta0i,E_tc_t
9882 real(kind=8) :: t3,t6,t9,t12,t14,t16,t21,t23,t26,t27,t32,t40
9884 !el common /calcthet/ term1,term2,termm,diffak,ratak,&
9885 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
9886 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,it
9889 delthec=thetai-thet_pred_mean
9890 delthe0=thetai-theta0i
9891 ! "Thank you" to MAPLE (probably spared one day of hand-differentiation).
9892 t3 = thetai-thet_pred_mean
9896 t14 = t12+t6*sigsqtc
9898 t21 = thetai-theta0i
9904 E_tc_t = -((sigcsq+2.D0*t3*sigsqtc)*t9-t14*sigcsq*t3*t16*t9 &
9905 -aktc*sig0inv*t27)/t32+(t14*t9+aktc*t26)/t40 &
9906 *(-t12*t9-ak*sig0inv*t27)
9908 end subroutine mixder
9910 !-----------------------------------------------------------------------------
9912 !-----------------------------------------------------------------------------
9914 !-----------------------------------------------------------------------------
9915 ! This subroutine calculates the derivatives of the consecutive virtual
9916 ! bond vectors and the SC vectors in the virtual-bond angles theta and
9917 ! virtual-torsional angles phi, as well as the derivatives of SC vectors
9918 ! in the angles alpha and omega, describing the location of a side chain
9919 ! in its local coordinate system.
9921 ! The derivatives are stored in the following arrays:
9923 ! DDCDV - the derivatives of virtual-bond vectors DC in theta and phi.
9924 ! The structure is as follows:
9926 ! dDC(x,2)/dT(3),...,dDC(z,2)/dT(3),0, 0, 0
9927 ! dDC(x,3)/dT(4),...,dDC(z,3)/dT(4),dDC(x,3)/dP(4),dDC(y,4)/dP(4),dDC(z,4)/dP(4)
9928 ! . . . . . . . . . . . . . . . . . .
9929 ! dDC(x,N-1)/dT(4),...,dDC(z,N-1)/dT(4),dDC(x,N-1)/dP(4),dDC(y,N-1)/dP(4),dDC(z,N-1)/dP(4)
9933 ! dDC(x,N-1)/dT(N),...,dDC(z,N-1)/dT(N),dDC(x,N-1)/dP(N),dDC(y,N-1)/dP(N),dDC(z,N-1)/dP(N)
9935 ! DXDV - the derivatives of the side-chain vectors in theta and phi.
9936 ! The structure is same as above.
9938 ! DCDS - the derivatives of the side chain vectors in the local spherical
9939 ! andgles alph and omega:
9941 ! dX(x,2)/dA(2),dX(y,2)/dA(2),dX(z,2)/dA(2),dX(x,2)/dO(2),dX(y,2)/dO(2),dX(z,2)/dO(2)
9942 ! dX(x,3)/dA(3),dX(y,3)/dA(3),dX(z,3)/dA(3),dX(x,3)/dO(3),dX(y,3)/dO(3),dX(z,3)/dO(3)
9946 ! dX(x,N-1)/dA(N-1),dX(y,N-1)/dA(N-1),dX(z,N-1)/dA(N-1),dX(x,N-1)/dO(N-1),dX(y,N-1)/dO(N-1),dX(z,N-1)/dO(N-1)
9948 ! Version of March '95, based on an early version of November '91.
9950 !**********************************************************************
9951 ! implicit real*8 (a-h,o-z)
9952 ! include 'DIMENSIONS'
9953 ! include 'COMMON.VAR'
9954 ! include 'COMMON.CHAIN'
9955 ! include 'COMMON.DERIV'
9956 ! include 'COMMON.GEO'
9957 ! include 'COMMON.LOCAL'
9958 ! include 'COMMON.INTERACT'
9959 real(kind=8),dimension(3,3,nres) :: drt,rdt,prordt,prodrt !(3,3,maxres)
9960 real(kind=8),dimension(3,3) :: dp,temp
9961 !el real(kind=8) :: fromto(3,3,maxdim) !(3,3,maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
9962 real(kind=8),dimension(3) :: xx,xx1
9964 integer :: i,k,l,j,m,ind,ind1,jjj
9965 real(kind=8) :: alphi,omegi,theta2,dpkl,dpjk,xj,rj,dxoijk,dxoiij,&
9966 tempkl,dsci,cosalphi,sinalphi,cosomegi,sinomegi,cost2,&
9967 sint2,xp,yp,xxp,yyp,zzp,dj
9969 ! common /przechowalnia/ fromto
9970 if(.not. allocated(fromto)) allocate(fromto(3,3,maxdim))
9971 ! get the position of the jth ijth fragment of the chain coordinate system
9972 ! in the fromto array.
9973 ! indmat(i,j)=((2*(nres-2)-i)*(i-1))/2+j-1
9975 ! maxdim=(nres-1)*(nres-2)/2
9976 ! allocate(dcdv(6,maxdim),dxds(6,nres))
9977 ! calculate the derivatives of transformation matrix elements in theta
9980 !el call flush(iout) !el
9982 rdt(1,1,i)=-rt(1,2,i)
9983 rdt(1,2,i)= rt(1,1,i)
9985 rdt(2,1,i)=-rt(2,2,i)
9986 rdt(2,2,i)= rt(2,1,i)
9988 rdt(3,1,i)=-rt(3,2,i)
9989 rdt(3,2,i)= rt(3,1,i)
9993 ! derivatives in phi
9999 drt(2,1,i)= rt(3,1,i)
10000 drt(2,2,i)= rt(3,2,i)
10001 drt(2,3,i)= rt(3,3,i)
10002 drt(3,1,i)=-rt(2,1,i)
10003 drt(3,2,i)=-rt(2,2,i)
10004 drt(3,3,i)=-rt(2,3,i)
10007 ! generate the matrix products of type r(i)t(i)...r(j)t(j)
10013 temp(k,l)=rt(k,l,i)
10018 fromto(k,l,ind)=temp(k,l)
10027 dpkl=dpkl+temp(k,m)*rt(m,l,j)
10030 fromto(k,l,ind)=dpkl
10041 ! Calculate derivatives.
10047 ! Derivatives of DC(i+1) in theta(i+2)
10053 dpjk=dpjk+prod(j,l,i)*rdt(l,k,i)
10056 prordt(j,k,i)=dp(j,k)
10059 dcdv(j,ind1)=vbld(i+1)*dp(j,1)
10062 ! Derivatives of SC(i+1) in theta(i+2)
10064 xx1(1)=-0.5D0*xloc(2,i+1)
10065 xx1(2)= 0.5D0*xloc(1,i+1)
10069 xj=xj+r(j,k,i)*xx1(k)
10076 rj=rj+prod(j,k,i)*xx(k)
10081 ! Derivatives of SC(i+1) in theta(i+3). The have to be handled differently
10082 ! than the other off-diagonal derivatives.
10087 dxoiij=dxoiij+dp(j,k)*xrot(k,i+2)
10089 dxdv(j,ind1+1)=dxoiij
10091 !d print *,ind1+1,(dxdv(j,ind1+1),j=1,3)
10093 ! Derivatives of DC(i+1) in phi(i+2)
10099 dpjk=dpjk+prod(j,l,i)*drt(l,k,i)
10102 prodrt(j,k,i)=dp(j,k)
10104 dcdv(j+3,ind1)=vbld(i+1)*dp(j,1)
10107 ! Derivatives of SC(i+1) in phi(i+2)
10110 xx(3)= xloc(2,i+1)*r(2,2,i)+xloc(3,i+1)*r(2,3,i)
10111 xx(2)=-xloc(2,i+1)*r(3,2,i)-xloc(3,i+1)*r(3,3,i)
10115 rj=rj+prod(j,k,i)*xx(k)
10120 ! Derivatives of SC(i+1) in phi(i+3).
10125 dxoiij=dxoiij+dp(j,k)*xrot(k,i+2)
10127 dxdv(j+3,ind1+1)=dxoiij
10130 ! Calculate the derivatives of DC(i+1) and SC(i+1) in theta(i+3) thru
10131 ! theta(nres) and phi(i+3) thru phi(nres).
10135 ind=indmat(i+1,j+1)
10136 !d print *,'i=',i,' j=',j,' ind=',ind,' ind1=',ind1
10141 tempkl=tempkl+prordt(k,m,i)*fromto(m,l,ind)
10146 !d print '(9f8.3)',((fromto(k,l,ind),l=1,3),k=1,3)
10147 !d print '(9f8.3)',((prod(k,l,i),l=1,3),k=1,3)
10148 !d print '(9f8.3)',((temp(k,l),l=1,3),k=1,3)
10149 ! Derivatives of virtual-bond vectors in theta
10151 dcdv(k,ind1)=vbld(i+1)*temp(k,1)
10153 !d print '(3f8.3)',(dcdv(k,ind1),k=1,3)
10154 ! Derivatives of SC vectors in theta
10158 dxoijk=dxoijk+temp(k,l)*xrot(l,j+2)
10160 dxdv(k,ind1+1)=dxoijk
10163 !--- Calculate the derivatives in phi
10169 tempkl=tempkl+prodrt(k,m,i)*fromto(m,l,ind)
10175 dcdv(k+3,ind1)=vbld(i+1)*temp(k,1)
10180 dxoijk=dxoijk+temp(k,l)*xrot(l,j+2)
10182 dxdv(k+3,ind1+1)=dxoijk
10187 ! Derivatives in alpha and omega:
10190 ! dsci=dsc(itype(i))
10195 if(alphi.ne.alphi) alphi=100.0
10196 if(omegi.ne.omegi) omegi=-100.0
10201 !d print *,'i=',i,' dsci=',dsci,' alphi=',alphi,' omegi=',omegi
10202 cosalphi=dcos(alphi)
10203 sinalphi=dsin(alphi)
10204 cosomegi=dcos(omegi)
10205 sinomegi=dsin(omegi)
10206 temp(1,1)=-dsci*sinalphi
10207 temp(2,1)= dsci*cosalphi*cosomegi
10208 temp(3,1)=-dsci*cosalphi*sinomegi
10210 temp(2,2)=-dsci*sinalphi*sinomegi
10211 temp(3,2)=-dsci*sinalphi*cosomegi
10212 theta2=pi-0.5D0*theta(i+1)
10216 !d print *,((temp(l,k),l=1,3),k=1,2)
10220 xxp= xp*cost2+yp*sint2
10221 yyp=-xp*sint2+yp*cost2
10224 xx(2)=yyp*r(2,2,i-1)+zzp*r(2,3,i-1)
10225 xx(3)=yyp*r(3,2,i-1)+zzp*r(3,3,i-1)
10229 dj=dj+prod(k,l,i-1)*xx(l)
10237 end subroutine cartder
10238 !-----------------------------------------------------------------------------
10240 !-----------------------------------------------------------------------------
10241 subroutine check_cartgrad
10242 ! Check the gradient of Cartesian coordinates in internal coordinates.
10243 ! implicit real*8 (a-h,o-z)
10244 ! include 'DIMENSIONS'
10245 ! include 'COMMON.IOUNITS'
10246 ! include 'COMMON.VAR'
10247 ! include 'COMMON.CHAIN'
10248 ! include 'COMMON.GEO'
10249 ! include 'COMMON.LOCAL'
10250 ! include 'COMMON.DERIV'
10251 real(kind=8),dimension(6,nres) :: temp
10252 real(kind=8),dimension(3) :: xx,gg
10253 integer :: i,k,j,ii
10254 real(kind=8) :: aincr,aincr2,alphi,omegi,theti,thet,phii
10255 ! indmat(i,j)=((2*(nres-2)-i)*(i-1))/2+j-1
10257 ! Check the gradient of the virtual-bond and SC vectors in the internal
10263 write (iout,'(a)') '**************** dx/dalpha'
10267 alph(i)=alph(i)+aincr
10269 temp(k,i)=dc(k,nres+i)
10273 gg(k)=(dc(k,nres+i)-temp(k,i))/aincr
10274 xx(k)=dabs((gg(k)-dxds(k,i))/(aincr*dabs(dxds(k,i))+aincr))
10276 write (iout,'(i4,3e15.6/4x,3e15.6,3f9.3)') &
10277 i,(gg(k),k=1,3),(dxds(k,i),k=1,3),(xx(k),k=1,3)
10283 write (iout,'(a)') '**************** dx/domega'
10287 omeg(i)=omeg(i)+aincr
10289 temp(k,i)=dc(k,nres+i)
10293 gg(k)=(dc(k,nres+i)-temp(k,i))/aincr
10294 xx(k)=dabs((gg(k)-dxds(k+3,i))/ &
10295 (aincr*dabs(dxds(k+3,i))+aincr))
10297 write (iout,'(i4,3e15.6/4x,3e15.6,3f9.3)') &
10298 i,(gg(k),k=1,3),(dxds(k+3,i),k=1,3),(xx(k),k=1,3)
10304 write (iout,'(a)') '**************** dx/dtheta'
10308 theta(i)=theta(i)+aincr
10311 temp(k,j)=dc(k,nres+j)
10317 ! print *,'i=',i-2,' j=',j-1,' ii=',ii
10319 gg(k)=(dc(k,nres+j)-temp(k,j))/aincr
10320 xx(k)=dabs((gg(k)-dxdv(k,ii))/ &
10321 (aincr*dabs(dxdv(k,ii))+aincr))
10323 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
10324 i,j,(gg(k),k=1,3),(dxdv(k,ii),k=1,3),(xx(k),k=1,3)
10331 write (iout,'(a)') '***************** dx/dphi'
10334 phi(i)=phi(i)+aincr
10337 temp(k,j)=dc(k,nres+j)
10345 gg(k)=(dc(k,nres+j)-temp(k,j))/aincr
10346 xx(k)=dabs((gg(k)-dxdv(k+3,ii))/ &
10347 (aincr*dabs(dxdv(k+3,ii))+aincr))
10349 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
10350 i,j,(gg(k),k=1,3),(dxdv(k+3,ii),k=1,3),(xx(k),k=1,3)
10353 phi(i)=phi(i)-aincr
10356 write (iout,'(a)') '****************** ddc/dtheta'
10359 theta(i+2)=thet+aincr
10370 gg(k)=(dc(k,j)-temp(k,j))/aincr
10371 xx(k)=dabs((gg(k)-dcdv(k,ii))/ &
10372 (aincr*dabs(dcdv(k,ii))+aincr))
10374 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
10375 i,j,(gg(k),k=1,3),(dcdv(k,ii),k=1,3),(xx(k),k=1,3)
10385 write (iout,'(a)') '******************* ddc/dphi'
10388 phi(i+3)=phii+aincr
10399 gg(k)=(dc(k,j)-temp(k,j))/aincr
10400 xx(k)=dabs((gg(k)-dcdv(k+3,ii))/ &
10401 (aincr*dabs(dcdv(k+3,ii))+aincr))
10403 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
10404 i,j,(gg(k),k=1,3),(dcdv(k+3,ii),k=1,3),(xx(k),k=1,3)
10415 end subroutine check_cartgrad
10416 !-----------------------------------------------------------------------------
10417 subroutine check_ecart
10418 ! Check the gradient of the energy in Cartesian coordinates.
10419 ! implicit real*8 (a-h,o-z)
10420 ! include 'DIMENSIONS'
10421 ! include 'COMMON.CHAIN'
10422 ! include 'COMMON.DERIV'
10423 ! include 'COMMON.IOUNITS'
10424 ! include 'COMMON.VAR'
10425 ! include 'COMMON.CONTACTS'
10427 !el integer :: icall
10428 !el common /srutu/ icall
10429 real(kind=8),dimension(6) :: ggg
10430 real(kind=8),dimension(3) :: cc,xx,ddc,ddx
10431 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
10432 real(kind=8),dimension(6,nres) :: grad_s
10433 real(kind=8),dimension(0:n_ene) :: energia,energia1
10434 integer :: uiparm(1)
10435 real(kind=8) :: urparm(1)
10437 integer :: nf,i,j,k
10438 real(kind=8) :: aincr,etot,etot1
10444 print '(a)','CG processor',me,' calling CHECK_CART.',aincr
10447 call geom_to_var(nvar,x)
10448 call etotal(energia)
10450 !el call enerprint(energia)
10451 call gradient(nvar,x,nf,g,uiparm,urparm,fdum)
10454 write (iout,'(i5,3f10.5)') i,(gradxorr(j,i),j=1,3)
10458 grad_s(j,i)=gradc(j,i,icg)
10459 grad_s(j+3,i)=gradx(j,i,icg)
10463 write (iout,'(/a/)') 'Gradient in virtual-bond and SC vectors'
10468 ddx(j)=dc(j,i+nres)
10471 dc(j,i)=dc(j,i)+aincr
10473 c(j,k)=c(j,k)+aincr
10474 c(j,k+nres)=c(j,k+nres)+aincr
10476 call etotal(energia1)
10478 ggg(j)=(etot1-etot)/aincr
10481 c(j,k)=c(j,k)-aincr
10482 c(j,k+nres)=c(j,k+nres)-aincr
10486 c(j,i+nres)=c(j,i+nres)+aincr
10487 dc(j,i+nres)=dc(j,i+nres)+aincr
10488 call etotal(energia1)
10490 ggg(j+3)=(etot1-etot)/aincr
10492 dc(j,i+nres)=ddx(j)
10494 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/)') &
10495 i,(ggg(k),k=1,6),(grad_s(k,i),k=1,6)
10498 end subroutine check_ecart
10500 !-----------------------------------------------------------------------------
10501 subroutine check_ecartint
10502 ! Check the gradient of the energy in Cartesian coordinates.
10503 use io_base, only: intout
10504 ! implicit real*8 (a-h,o-z)
10505 ! include 'DIMENSIONS'
10506 ! include 'COMMON.CONTROL'
10507 ! include 'COMMON.CHAIN'
10508 ! include 'COMMON.DERIV'
10509 ! include 'COMMON.IOUNITS'
10510 ! include 'COMMON.VAR'
10511 ! include 'COMMON.CONTACTS'
10512 ! include 'COMMON.MD'
10513 ! include 'COMMON.LOCAL'
10514 ! include 'COMMON.SPLITELE'
10516 !el integer :: icall
10517 !el common /srutu/ icall
10518 real(kind=8),dimension(6) :: ggg,ggg1
10519 real(kind=8),dimension(3) :: cc,xx,ddc,ddx,ddc1,ddcn
10520 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
10521 real(kind=8),dimension(3) :: dcnorm_safe1,dcnorm_safe2,dxnorm_safe
10522 real(kind=8),dimension(6,0:nres) :: grad_s,grad_s1 !(6,0:maxres)
10523 real(kind=8),dimension(nres) :: phi_temp,theta_temp,alph_temp,omeg_temp !(maxres)
10524 real(kind=8),dimension(0:n_ene) :: energia,energia1
10525 integer :: uiparm(1)
10526 real(kind=8) :: urparm(1)
10528 integer :: i,j,k,nf
10529 real(kind=8) :: rlambd,aincr,etot,etot1,etot11,etot12,etot2,&
10537 ! call intcartderiv
10538 ! call checkintcartgrad
10541 write(iout,*) 'Calling CHECK_ECARTINT.'
10544 write (iout,*) "Before geom_to_var"
10545 call geom_to_var(nvar,x)
10546 write (iout,*) "after geom_to_var"
10547 write (iout,*) "split_ene ",split_ene
10549 if (.not.split_ene) then
10550 write(iout,*) 'Calling CHECK_ECARTINT if'
10551 call etotal(energia)
10552 !elwrite(iout,*) 'Calling CHECK_ECARTINT if'
10554 write (iout,*) "etot",etot
10556 !el call enerprint(energia)
10557 !elwrite(iout,*) 'Calling CHECK_ECARTINT if'
10559 write (iout,*) "enter cartgrad"
10562 !elwrite(iout,*) 'Calling CHECK_ECARTINT if'
10563 write (iout,*) "exit cartgrad"
10567 write (iout,'(i5,3f10.5)') i,(gradxorr(j,i),j=1,3)
10570 grad_s(j,0)=gcart(j,0)
10572 !elwrite(iout,*) 'Calling CHECK_ECARTINT if'
10575 grad_s(j,i)=gcart(j,i)
10576 grad_s(j+3,i)=gxcart(j,i)
10580 write(iout,*) 'Calling CHECK_ECARTIN else.'
10581 !- split gradient check
10583 call etotal_long(energia)
10584 !el call enerprint(energia)
10586 write (iout,*) "enter cartgrad"
10589 write (iout,*) "exit cartgrad"
10592 write (iout,*) "longrange grad"
10594 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
10595 (gxcart(j,i),j=1,3)
10598 grad_s(j,0)=gcart(j,0)
10602 grad_s(j,i)=gcart(j,i)
10603 grad_s(j+3,i)=gxcart(j,i)
10607 call etotal_short(energia)
10608 !el call enerprint(energia)
10610 write (iout,*) "enter cartgrad"
10613 write (iout,*) "exit cartgrad"
10616 write (iout,*) "shortrange grad"
10618 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
10619 (gxcart(j,i),j=1,3)
10622 grad_s1(j,0)=gcart(j,0)
10626 grad_s1(j,i)=gcart(j,i)
10627 grad_s1(j+3,i)=gxcart(j,i)
10631 write (iout,'(/a/)') 'Gradient in virtual-bond and SC vectors'
10635 if (nnt.gt.1 .and. i.eq.nnt) ddc1(j)=c(j,1)
10636 if (nct.lt.nres .and. i.eq.nct) ddcn(j)=c(j,nres)
10639 dcnorm_safe1(j)=dc_norm(j,i-1)
10640 dcnorm_safe2(j)=dc_norm(j,i)
10641 dxnorm_safe(j)=dc_norm(j,i+nres)
10644 c(j,i)=ddc(j)+aincr
10645 if (nnt.gt.1 .and. i.eq.nnt) c(j,1)=c(j,1)+aincr
10646 if (nct.lt.nres .and. i.eq.nct) c(j,nres)=c(j,nres)+aincr
10647 if (i.gt.1) dc(j,i-1)=c(j,i)-c(j,i-1)
10648 dc(j,i)=c(j,i+1)-c(j,i)
10649 dc(j,i+nres)=c(j,i+nres)-c(j,i)
10650 call int_from_cart1(.false.)
10651 if (.not.split_ene) then
10652 call etotal(energia1)
10654 write (iout,*) "ij",i,j," etot1",etot1
10657 call etotal_long(energia1)
10659 call etotal_short(energia1)
10662 !- end split gradient
10663 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot1",etot1
10664 c(j,i)=ddc(j)-aincr
10665 if (nnt.gt.1 .and. i.eq.nnt) c(j,1)=ddc1(j)-aincr
10666 if (nct.lt.nres .and. i.eq.nct) c(j,nres)=ddcn(j)-aincr
10667 if (i.gt.1) dc(j,i-1)=c(j,i)-c(j,i-1)
10668 dc(j,i)=c(j,i+1)-c(j,i)
10669 dc(j,i+nres)=c(j,i+nres)-c(j,i)
10670 call int_from_cart1(.false.)
10671 if (.not.split_ene) then
10672 call etotal(energia1)
10674 write (iout,*) "ij",i,j," etot2",etot2
10675 ggg(j)=(etot1-etot2)/(2*aincr)
10678 call etotal_long(energia1)
10680 ggg(j)=(etot11-etot21)/(2*aincr)
10681 call etotal_short(energia1)
10683 ggg1(j)=(etot12-etot22)/(2*aincr)
10684 !- end split gradient
10685 ! write (iout,*) "etot21",etot21," etot22",etot22
10687 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
10689 if (nnt.gt.1 .and. i.eq.nnt) c(j,1)=ddc1(j)
10690 if (nct.lt.nres .and. i.eq.nct) c(j,nres)=ddcn(j)
10691 if (i.gt.1) dc(j,i-1)=c(j,i)-c(j,i-1)
10692 dc(j,i)=c(j,i+1)-c(j,i)
10693 dc(j,i+nres)=c(j,i+nres)-c(j,i)
10694 dc_norm(j,i-1)=dcnorm_safe1(j)
10695 dc_norm(j,i)=dcnorm_safe2(j)
10696 dc_norm(j,i+nres)=dxnorm_safe(j)
10699 c(j,i+nres)=ddx(j)+aincr
10700 dc(j,i+nres)=c(j,i+nres)-c(j,i)
10701 call int_from_cart1(.false.)
10702 if (.not.split_ene) then
10703 call etotal(energia1)
10707 call etotal_long(energia1)
10709 call etotal_short(energia1)
10712 !- end split gradient
10713 c(j,i+nres)=ddx(j)-aincr
10714 dc(j,i+nres)=c(j,i+nres)-c(j,i)
10715 call int_from_cart1(.false.)
10716 if (.not.split_ene) then
10717 call etotal(energia1)
10719 ggg(j+3)=(etot1-etot2)/(2*aincr)
10722 call etotal_long(energia1)
10724 ggg(j+3)=(etot11-etot21)/(2*aincr)
10725 call etotal_short(energia1)
10727 ggg1(j+3)=(etot12-etot22)/(2*aincr)
10728 !- end split gradient
10730 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
10732 dc(j,i+nres)=c(j,i+nres)-c(j,i)
10733 dc_norm(j,i+nres)=dxnorm_safe(j)
10734 call int_from_cart1(.false.)
10736 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
10737 i,(ggg(k),k=1,6),(grad_s(k,i),k=1,6),(ggg(k)/grad_s(k,i),k=1,6)
10738 if (split_ene) then
10739 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
10740 i,(ggg1(k),k=1,6),(grad_s1(k,i),k=1,6),(ggg1(k)/grad_s1(k,i),&
10742 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
10743 i,(ggg(k)+ggg1(k),k=1,6),(grad_s(k,i)+grad_s1(k,i),k=1,6),&
10744 ((ggg(k)+ggg1(k))/(grad_s(k,i)+grad_s1(k,i)),k=1,6)
10748 end subroutine check_ecartint
10750 !-----------------------------------------------------------------------------
10751 subroutine check_ecartint
10752 ! Check the gradient of the energy in Cartesian coordinates.
10753 use io_base, only: intout
10754 ! implicit real*8 (a-h,o-z)
10755 ! include 'DIMENSIONS'
10756 ! include 'COMMON.CONTROL'
10757 ! include 'COMMON.CHAIN'
10758 ! include 'COMMON.DERIV'
10759 ! include 'COMMON.IOUNITS'
10760 ! include 'COMMON.VAR'
10761 ! include 'COMMON.CONTACTS'
10762 ! include 'COMMON.MD'
10763 ! include 'COMMON.LOCAL'
10764 ! include 'COMMON.SPLITELE'
10766 !el integer :: icall
10767 !el common /srutu/ icall
10768 real(kind=8),dimension(6) :: ggg,ggg1
10769 real(kind=8),dimension(3) :: cc,xx,ddc,ddx
10770 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
10771 real(kind=8),dimension(3) :: dcnorm_safe,dxnorm_safe
10772 real(kind=8),dimension(6,0:nres) :: grad_s,grad_s1 !(6,0:maxres)
10773 real(kind=8),dimension(nres) :: phi_temp,theta_temp,alph_temp,omeg_temp !(maxres)
10774 real(kind=8),dimension(0:n_ene) :: energia,energia1
10775 integer :: uiparm(1)
10776 real(kind=8) :: urparm(1)
10778 integer :: i,j,k,nf
10779 real(kind=8) :: rlambd,aincr,etot,etot1,etot11,etot12,etot2,&
10787 ! call intcartderiv
10788 ! call checkintcartgrad
10791 write(iout,*) 'Calling CHECK_ECARTINT.',aincr
10794 call geom_to_var(nvar,x)
10795 if (.not.split_ene) then
10796 call etotal(energia)
10798 !el call enerprint(energia)
10800 write (iout,*) "enter cartgrad"
10803 write (iout,*) "exit cartgrad"
10807 write (iout,'(i5,3f10.5)') i,(gradxorr(j,i),j=1,3)
10810 grad_s(j,0)=gcart(j,0)
10814 grad_s(j,i)=gcart(j,i)
10815 grad_s(j+3,i)=gxcart(j,i)
10819 !- split gradient check
10821 call etotal_long(energia)
10822 !el call enerprint(energia)
10824 write (iout,*) "enter cartgrad"
10827 write (iout,*) "exit cartgrad"
10830 write (iout,*) "longrange grad"
10832 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
10833 (gxcart(j,i),j=1,3)
10836 grad_s(j,0)=gcart(j,0)
10840 grad_s(j,i)=gcart(j,i)
10841 grad_s(j+3,i)=gxcart(j,i)
10845 call etotal_short(energia)
10846 !el call enerprint(energia)
10848 write (iout,*) "enter cartgrad"
10851 write (iout,*) "exit cartgrad"
10854 write (iout,*) "shortrange grad"
10856 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
10857 (gxcart(j,i),j=1,3)
10860 grad_s1(j,0)=gcart(j,0)
10864 grad_s1(j,i)=gcart(j,i)
10865 grad_s1(j+3,i)=gxcart(j,i)
10869 write (iout,'(/a/)') 'Gradient in virtual-bond and SC vectors'
10874 ddx(j)=dc(j,i+nres)
10876 dcnorm_safe(k)=dc_norm(k,i)
10877 dxnorm_safe(k)=dc_norm(k,i+nres)
10881 dc(j,i)=ddc(j)+aincr
10882 call chainbuild_cart
10884 ! Broadcast the order to compute internal coordinates to the slaves.
10885 ! if (nfgtasks.gt.1)
10886 ! & call MPI_Bcast(6,1,MPI_INTEGER,king,FG_COMM,IERROR)
10888 ! call int_from_cart1(.false.)
10889 if (.not.split_ene) then
10890 call etotal(energia1)
10894 call etotal_long(energia1)
10896 call etotal_short(energia1)
10898 ! write (iout,*) "etot11",etot11," etot12",etot12
10900 !- end split gradient
10901 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot1",etot1
10902 dc(j,i)=ddc(j)-aincr
10903 call chainbuild_cart
10904 ! call int_from_cart1(.false.)
10905 if (.not.split_ene) then
10906 call etotal(energia1)
10908 ggg(j)=(etot1-etot2)/(2*aincr)
10911 call etotal_long(energia1)
10913 ggg(j)=(etot11-etot21)/(2*aincr)
10914 call etotal_short(energia1)
10916 ggg1(j)=(etot12-etot22)/(2*aincr)
10917 !- end split gradient
10918 ! write (iout,*) "etot21",etot21," etot22",etot22
10920 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
10922 call chainbuild_cart
10925 dc(j,i+nres)=ddx(j)+aincr
10926 call chainbuild_cart
10927 ! write (iout,*) "i",i," j",j," dxnorm+ and dxnorm"
10928 ! write (iout,'(3f15.10)') (dc_norm(k,i+nres),k=1,3)
10929 ! write (iout,'(3f15.10)') (dxnorm_safe(k),k=1,3)
10930 ! write (iout,*) "dxnormnorm",dsqrt(
10931 ! & dc_norm(1,i+nres)**2+dc_norm(2,i+nres)**2+dc_norm(3,i+nres)**2)
10932 ! write (iout,*) "dxnormnormsafe",dsqrt(
10933 ! & dxnorm_safe(1)**2+dxnorm_safe(2)**2+dxnorm_safe(3)**2)
10935 if (.not.split_ene) then
10936 call etotal(energia1)
10940 call etotal_long(energia1)
10942 call etotal_short(energia1)
10945 !- end split gradient
10946 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot1",etot1
10947 dc(j,i+nres)=ddx(j)-aincr
10948 call chainbuild_cart
10949 ! write (iout,*) "i",i," j",j," dxnorm- and dxnorm"
10950 ! write (iout,'(3f15.10)') (dc_norm(k,i+nres),k=1,3)
10951 ! write (iout,'(3f15.10)') (dxnorm_safe(k),k=1,3)
10953 ! write (iout,*) "dxnormnorm",dsqrt(
10954 ! & dc_norm(1,i+nres)**2+dc_norm(2,i+nres)**2+dc_norm(3,i+nres)**2)
10955 ! write (iout,*) "dxnormnormsafe",dsqrt(
10956 ! & dxnorm_safe(1)**2+dxnorm_safe(2)**2+dxnorm_safe(3)**2)
10957 if (.not.split_ene) then
10958 call etotal(energia1)
10960 ggg(j+3)=(etot1-etot2)/(2*aincr)
10963 call etotal_long(energia1)
10965 ggg(j+3)=(etot11-etot21)/(2*aincr)
10966 call etotal_short(energia1)
10968 ggg1(j+3)=(etot12-etot22)/(2*aincr)
10969 !- end split gradient
10971 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
10972 dc(j,i+nres)=ddx(j)
10973 call chainbuild_cart
10975 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
10976 i,(ggg(k),k=1,6),(grad_s(k,i),k=1,6),(ggg(k)/grad_s(k,i),k=1,6)
10977 if (split_ene) then
10978 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
10979 i,(ggg1(k),k=1,6),(grad_s1(k,i),k=1,6),(ggg1(k)/grad_s1(k,i),&
10981 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
10982 i,(ggg(k)+ggg1(k),k=1,6),(grad_s(k,i)+grad_s1(k,i),k=1,6),&
10983 ((ggg(k)+ggg1(k))/(grad_s(k,i)+grad_s1(k,i)),k=1,6)
10987 end subroutine check_ecartint
10989 !-----------------------------------------------------------------------------
10990 subroutine check_eint
10991 ! Check the gradient of energy in internal coordinates.
10992 ! implicit real*8 (a-h,o-z)
10993 ! include 'DIMENSIONS'
10994 ! include 'COMMON.CHAIN'
10995 ! include 'COMMON.DERIV'
10996 ! include 'COMMON.IOUNITS'
10997 ! include 'COMMON.VAR'
10998 ! include 'COMMON.GEO'
11000 !el integer :: icall
11001 !el common /srutu/ icall
11002 real(kind=8),dimension(6*nres) :: x,gana,gg !(maxvar) (maxvar=6*maxres)
11003 integer :: uiparm(1)
11004 real(kind=8) :: urparm(1)
11005 real(kind=8),dimension(0:n_ene) :: energia,energia1,energia2
11006 character(len=6) :: key
11009 real(kind=8) :: xi,aincr,etot,etot1,etot2
11012 print '(a)','Calling CHECK_INT.'
11016 call geom_to_var(nvar,x)
11017 call var_to_geom(nvar,x)
11021 call etotal(energia)
11023 !el call enerprint(energia)
11026 if (MyID.ne.BossID) then
11027 call mp_bcast(x(1),8*(nvar+3),BossID,fgGroupID)
11035 !d write (iout,'(10f8.3)') (rad2deg*x(i),i=1,nvar)
11036 call gradient(nvar,x,nf,gana,uiparm,urparm,fdum)
11037 !d write (iout,'(i3,1pe14.4)') (i,gana(i),i=1,nvar+20) !sp
11041 x(i)=xi-0.5D0*aincr
11042 call var_to_geom(nvar,x)
11044 call etotal(energia1)
11046 x(i)=xi+0.5D0*aincr
11047 call var_to_geom(nvar,x)
11049 call etotal(energia2)
11051 gg(i)=(etot2-etot1)/aincr
11052 write (iout,*) i,etot1,etot2
11055 write (iout,'(/2a)')' Variable Numerical Analytical',&
11058 if (i.le.nphi) then
11061 else if (i.le.nphi+ntheta) then
11064 else if (i.le.nphi+ntheta+nside) then
11068 ii=i-(nphi+ntheta+nside)
11071 write (iout,'(i3,a,i3,3(1pd16.6))') &
11072 i,key,ii,gg(i),gana(i),&
11073 100.0D0*dabs(gg(i)-gana(i))/(dabs(gana(i))+aincr)
11076 end subroutine check_eint
11077 !-----------------------------------------------------------------------------
11079 !-----------------------------------------------------------------------------
11080 subroutine Econstr_back
11081 ! MD with umbrella_sampling using Wolyne's distance measure as a constraint
11082 ! implicit real*8 (a-h,o-z)
11083 ! include 'DIMENSIONS'
11084 ! include 'COMMON.CONTROL'
11085 ! include 'COMMON.VAR'
11086 ! include 'COMMON.MD'
11089 ! include 'COMMON.LANGEVIN'
11091 ! include 'COMMON.LANGEVIN.lang0'
11093 ! include 'COMMON.CHAIN'
11094 ! include 'COMMON.DERIV'
11095 ! include 'COMMON.GEO'
11096 ! include 'COMMON.LOCAL'
11097 ! include 'COMMON.INTERACT'
11098 ! include 'COMMON.IOUNITS'
11099 ! include 'COMMON.NAMES'
11100 ! include 'COMMON.TIME1'
11101 integer :: i,j,ii,k
11102 real(kind=8) :: utheta_i,dtheta_i,ugamma_i,dgamma_i,dxx,dyy,dzz
11104 if(.not.allocated(utheta)) allocate(utheta(nfrag_back))
11105 if(.not.allocated(ugamma)) allocate(ugamma(nfrag_back))
11106 if(.not.allocated(uscdiff)) allocate(uscdiff(nfrag_back))
11113 duscdiff(j,i)=0.0d0
11114 duscdiffx(j,i)=0.0d0
11118 ii = ifrag_back(2,i,iset)-ifrag_back(1,i,iset)
11120 ! Deviations from theta angles
11123 do j=ifrag_back(1,i,iset)+2,ifrag_back(2,i,iset)
11124 dtheta_i=theta(j)-thetaref(j)
11125 utheta_i=utheta_i+0.5d0*dtheta_i*dtheta_i
11126 dutheta(j-2)=dutheta(j-2)+wfrag_back(1,i,iset)*dtheta_i/(ii-1)
11128 utheta(i)=utheta_i/(ii-1)
11130 ! Deviations from gamma angles
11133 do j=ifrag_back(1,i,iset)+3,ifrag_back(2,i,iset)
11134 dgamma_i=pinorm(phi(j)-phiref(j))
11135 ! write (iout,*) j,phi(j),phi(j)-phiref(j)
11136 ugamma_i=ugamma_i+0.5d0*dgamma_i*dgamma_i
11137 dugamma(j-3)=dugamma(j-3)+wfrag_back(2,i,iset)*dgamma_i/(ii-2)
11138 ! write (iout,*) i,j,dgamma_i,wfrag_back(2,i,iset),dugamma(j-3)
11140 ugamma(i)=ugamma_i/(ii-2)
11142 ! Deviations from local SC geometry
11145 do j=ifrag_back(1,i,iset)+1,ifrag_back(2,i,iset)-1
11146 dxx=xxtab(j)-xxref(j)
11147 dyy=yytab(j)-yyref(j)
11148 dzz=zztab(j)-zzref(j)
11149 uscdiff(i)=uscdiff(i)+dxx*dxx+dyy*dyy+dzz*dzz
11151 duscdiff(k,j-1)=duscdiff(k,j-1)+wfrag_back(3,i,iset)* &
11152 (dXX_C1tab(k,j)*dxx+dYY_C1tab(k,j)*dyy+dZZ_C1tab(k,j)*dzz)/ &
11154 duscdiff(k,j)=duscdiff(k,j)+wfrag_back(3,i,iset)* &
11155 (dXX_Ctab(k,j)*dxx+dYY_Ctab(k,j)*dyy+dZZ_Ctab(k,j)*dzz)/ &
11157 duscdiffx(k,j)=duscdiffx(k,j)+wfrag_back(3,i,iset)* &
11158 (dXX_XYZtab(k,j)*dxx+dYY_XYZtab(k,j)*dyy+dZZ_XYZtab(k,j)*dzz) &
11161 ! write (iout,'(i5,6f10.5)') j,xxtab(j),yytab(j),zztab(j),
11162 ! & xxref(j),yyref(j),zzref(j)
11164 uscdiff(i)=0.5d0*uscdiff(i)/(ii-1)
11165 ! write (iout,*) i," uscdiff",uscdiff(i)
11167 ! Put together deviations from local geometry
11169 Uconst_back=Uconst_back+wfrag_back(1,i,iset)*utheta(i)+ &
11170 wfrag_back(2,i,iset)*ugamma(i)+wfrag_back(3,i,iset)*uscdiff(i)
11171 ! write(iout,*) "i",i," utheta",utheta(i)," ugamma",ugamma(i),
11172 ! & " uconst_back",uconst_back
11173 utheta(i)=dsqrt(utheta(i))
11174 ugamma(i)=dsqrt(ugamma(i))
11175 uscdiff(i)=dsqrt(uscdiff(i))
11178 end subroutine Econstr_back
11179 !-----------------------------------------------------------------------------
11180 ! energy_p_new-sep_barrier.F
11181 !-----------------------------------------------------------------------------
11182 real(kind=8) function sscale(r)
11183 ! include "COMMON.SPLITELE"
11184 real(kind=8) :: r,gamm
11185 if(r.lt.r_cut-rlamb) then
11187 else if(r.le.r_cut.and.r.ge.r_cut-rlamb) then
11188 gamm=(r-(r_cut-rlamb))/rlamb
11189 sscale=1.0d0+gamm*gamm*(2*gamm-3.0d0)
11194 end function sscale
11195 real(kind=8) function sscale_grad(r)
11196 ! include "COMMON.SPLITELE"
11197 real(kind=8) :: r,gamm
11198 if(r.lt.r_cut-rlamb) then
11200 else if(r.le.r_cut.and.r.ge.r_cut-rlamb) then
11201 gamm=(r-(r_cut-rlamb))/rlamb
11202 sscale_grad=gamm*(6*gamm-6.0d0)/rlamb
11207 end function sscale_grad
11209 !!!!!!!!!! PBCSCALE
11210 real(kind=8) function sscale_ele(r)
11211 ! include "COMMON.SPLITELE"
11212 real(kind=8) :: r,gamm
11213 if(r.lt.r_cut_ele-rlamb_ele) then
11215 else if(r.le.r_cut_ele.and.r.ge.r_cut_ele-rlamb_ele) then
11216 gamm=(r-(r_cut_ele-rlamb_ele))/rlamb_ele
11217 sscale_ele=1.0d0+gamm*gamm*(2*gamm-3.0d0)
11222 end function sscale_ele
11224 real(kind=8) function sscagrad_ele(r)
11225 real(kind=8) :: r,gamm
11226 ! include "COMMON.SPLITELE"
11227 if(r.lt.r_cut_ele-rlamb_ele) then
11229 else if(r.le.r_cut_ele.and.r.ge.r_cut_ele-rlamb_ele) then
11230 gamm=(r-(r_cut_ele-rlamb_ele))/rlamb_ele
11231 sscagrad_ele=gamm*(6*gamm-6.0d0)/rlamb_ele
11236 end function sscagrad_ele
11238 !-----------------------------------------------------------------------------
11239 subroutine elj_long(evdw)
11241 ! This subroutine calculates the interaction energy of nonbonded side chains
11242 ! assuming the LJ potential of interaction.
11244 ! implicit real*8 (a-h,o-z)
11245 ! include 'DIMENSIONS'
11246 ! include 'COMMON.GEO'
11247 ! include 'COMMON.VAR'
11248 ! include 'COMMON.LOCAL'
11249 ! include 'COMMON.CHAIN'
11250 ! include 'COMMON.DERIV'
11251 ! include 'COMMON.INTERACT'
11252 ! include 'COMMON.TORSION'
11253 ! include 'COMMON.SBRIDGE'
11254 ! include 'COMMON.NAMES'
11255 ! include 'COMMON.IOUNITS'
11256 ! include 'COMMON.CONTACTS'
11257 real(kind=8),parameter :: accur=1.0d-10
11258 real(kind=8),dimension(3) :: gg
11259 !el local variables
11260 integer :: i,iint,j,k,itypi,itypi1,itypj
11261 real(kind=8) :: xi,yi,zi,xj,yj,zj,rij,sss,rrij,fac,eps0ij
11262 real(kind=8) :: e1,e2,evdwij,evdw
11263 ! write(iout,*)'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
11265 do i=iatsc_s,iatsc_e
11267 if (itypi.eq.ntyp1) cycle
11273 ! Calculate SC interaction energy.
11275 do iint=1,nint_gr(i)
11276 !d write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
11277 !d & 'iend=',iend(i,iint)
11278 do j=istart(i,iint),iend(i,iint)
11280 if (itypj.eq.ntyp1) cycle
11284 rij=xj*xj+yj*yj+zj*zj
11285 sss=sscale(dsqrt(rij)/sigma(itypi,itypj))
11286 if (sss.lt.1.0d0) then
11288 eps0ij=eps(itypi,itypj)
11290 e1=fac*fac*aa(itypi,itypj)
11291 e2=fac*bb(itypi,itypj)
11293 evdw=evdw+(1.0d0-sss)*evdwij
11295 ! Calculate the components of the gradient in DC and X
11297 fac=-rrij*(e1+evdwij)*(1.0d0-sss)
11302 gvdwx(k,i)=gvdwx(k,i)-gg(k)
11303 gvdwx(k,j)=gvdwx(k,j)+gg(k)
11304 gvdwc(k,i)=gvdwc(k,i)-gg(k)
11305 gvdwc(k,j)=gvdwc(k,j)+gg(k)
11313 gvdwc(j,i)=expon*gvdwc(j,i)
11314 gvdwx(j,i)=expon*gvdwx(j,i)
11317 !******************************************************************************
11321 ! To save time, the factor of EXPON has been extracted from ALL components
11322 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
11325 !******************************************************************************
11327 end subroutine elj_long
11328 !-----------------------------------------------------------------------------
11329 subroutine elj_short(evdw)
11331 ! This subroutine calculates the interaction energy of nonbonded side chains
11332 ! assuming the LJ potential of interaction.
11334 ! implicit real*8 (a-h,o-z)
11335 ! include 'DIMENSIONS'
11336 ! include 'COMMON.GEO'
11337 ! include 'COMMON.VAR'
11338 ! include 'COMMON.LOCAL'
11339 ! include 'COMMON.CHAIN'
11340 ! include 'COMMON.DERIV'
11341 ! include 'COMMON.INTERACT'
11342 ! include 'COMMON.TORSION'
11343 ! include 'COMMON.SBRIDGE'
11344 ! include 'COMMON.NAMES'
11345 ! include 'COMMON.IOUNITS'
11346 ! include 'COMMON.CONTACTS'
11347 real(kind=8),parameter :: accur=1.0d-10
11348 real(kind=8),dimension(3) :: gg
11349 !el local variables
11350 integer :: i,iint,j,k,itypi,itypi1,itypj,num_conti
11351 real(kind=8) :: xi,yi,zi,xj,yj,zj,rij,sss,rrij,fac,eps0ij
11352 real(kind=8) :: e1,e2,evdwij,evdw
11353 ! write(iout,*)'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
11355 do i=iatsc_s,iatsc_e
11357 if (itypi.eq.ntyp1) cycle
11365 ! Calculate SC interaction energy.
11367 do iint=1,nint_gr(i)
11368 !d write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
11369 !d & 'iend=',iend(i,iint)
11370 do j=istart(i,iint),iend(i,iint)
11372 if (itypj.eq.ntyp1) cycle
11376 ! Change 12/1/95 to calculate four-body interactions
11377 rij=xj*xj+yj*yj+zj*zj
11378 sss=sscale(dsqrt(rij)/sigma(itypi,itypj))
11379 if (sss.gt.0.0d0) then
11381 eps0ij=eps(itypi,itypj)
11383 e1=fac*fac*aa(itypi,itypj)
11384 e2=fac*bb(itypi,itypj)
11386 evdw=evdw+sss*evdwij
11388 ! Calculate the components of the gradient in DC and X
11390 fac=-rrij*(e1+evdwij)*sss
11395 gvdwx(k,i)=gvdwx(k,i)-gg(k)
11396 gvdwx(k,j)=gvdwx(k,j)+gg(k)
11397 gvdwc(k,i)=gvdwc(k,i)-gg(k)
11398 gvdwc(k,j)=gvdwc(k,j)+gg(k)
11406 gvdwc(j,i)=expon*gvdwc(j,i)
11407 gvdwx(j,i)=expon*gvdwx(j,i)
11410 !******************************************************************************
11414 ! To save time, the factor of EXPON has been extracted from ALL components
11415 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
11418 !******************************************************************************
11420 end subroutine elj_short
11421 !-----------------------------------------------------------------------------
11422 subroutine eljk_long(evdw)
11424 ! This subroutine calculates the interaction energy of nonbonded side chains
11425 ! assuming the LJK potential of interaction.
11427 ! implicit real*8 (a-h,o-z)
11428 ! include 'DIMENSIONS'
11429 ! include 'COMMON.GEO'
11430 ! include 'COMMON.VAR'
11431 ! include 'COMMON.LOCAL'
11432 ! include 'COMMON.CHAIN'
11433 ! include 'COMMON.DERIV'
11434 ! include 'COMMON.INTERACT'
11435 ! include 'COMMON.IOUNITS'
11436 ! include 'COMMON.NAMES'
11437 real(kind=8),dimension(3) :: gg
11439 !el local variables
11440 integer :: i,iint,j,k,itypi,itypi1,itypj
11441 real(kind=8) :: rrij,r_inv_ij,xj,yj,zj,xi,yi,zi,fac,evdw,&
11442 fac_augm,e_augm,rij,sss,r_shift_inv,e1,e2,evdwij
11443 ! print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
11445 do i=iatsc_s,iatsc_e
11447 if (itypi.eq.ntyp1) cycle
11453 ! Calculate SC interaction energy.
11455 do iint=1,nint_gr(i)
11456 do j=istart(i,iint),iend(i,iint)
11458 if (itypj.eq.ntyp1) cycle
11462 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
11463 fac_augm=rrij**expon
11464 e_augm=augm(itypi,itypj)*fac_augm
11465 r_inv_ij=dsqrt(rrij)
11467 sss=sscale(rij/sigma(itypi,itypj))
11468 if (sss.lt.1.0d0) then
11469 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
11470 fac=r_shift_inv**expon
11471 e1=fac*fac*aa(itypi,itypj)
11472 e2=fac*bb(itypi,itypj)
11473 evdwij=e_augm+e1+e2
11474 !d sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
11475 !d epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
11476 !d write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
11477 !d & restyp(itypi),i,restyp(itypj),j,aa(itypi,itypj),
11478 !d & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
11479 !d & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
11480 !d & (c(k,i),k=1,3),(c(k,j),k=1,3)
11481 evdw=evdw+(1.0d0-sss)*evdwij
11483 ! Calculate the components of the gradient in DC and X
11485 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
11486 fac=fac*(1.0d0-sss)
11491 gvdwx(k,i)=gvdwx(k,i)-gg(k)
11492 gvdwx(k,j)=gvdwx(k,j)+gg(k)
11493 gvdwc(k,i)=gvdwc(k,i)-gg(k)
11494 gvdwc(k,j)=gvdwc(k,j)+gg(k)
11502 gvdwc(j,i)=expon*gvdwc(j,i)
11503 gvdwx(j,i)=expon*gvdwx(j,i)
11507 end subroutine eljk_long
11508 !-----------------------------------------------------------------------------
11509 subroutine eljk_short(evdw)
11511 ! This subroutine calculates the interaction energy of nonbonded side chains
11512 ! assuming the LJK potential of interaction.
11514 ! implicit real*8 (a-h,o-z)
11515 ! include 'DIMENSIONS'
11516 ! include 'COMMON.GEO'
11517 ! include 'COMMON.VAR'
11518 ! include 'COMMON.LOCAL'
11519 ! include 'COMMON.CHAIN'
11520 ! include 'COMMON.DERIV'
11521 ! include 'COMMON.INTERACT'
11522 ! include 'COMMON.IOUNITS'
11523 ! include 'COMMON.NAMES'
11524 real(kind=8),dimension(3) :: gg
11526 !el local variables
11527 integer :: i,iint,j,k,itypi,itypi1,itypj
11528 real(kind=8) :: rrij,r_inv_ij,xj,yj,zj,xi,yi,zi,fac,evdw,&
11529 fac_augm,e_augm,rij,sss,r_shift_inv,e1,e2,evdwij
11530 ! print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
11532 do i=iatsc_s,iatsc_e
11534 if (itypi.eq.ntyp1) cycle
11540 ! Calculate SC interaction energy.
11542 do iint=1,nint_gr(i)
11543 do j=istart(i,iint),iend(i,iint)
11545 if (itypj.eq.ntyp1) cycle
11549 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
11550 fac_augm=rrij**expon
11551 e_augm=augm(itypi,itypj)*fac_augm
11552 r_inv_ij=dsqrt(rrij)
11554 sss=sscale(rij/sigma(itypi,itypj))
11555 if (sss.gt.0.0d0) then
11556 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
11557 fac=r_shift_inv**expon
11558 e1=fac*fac*aa(itypi,itypj)
11559 e2=fac*bb(itypi,itypj)
11560 evdwij=e_augm+e1+e2
11561 !d sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
11562 !d epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
11563 !d write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
11564 !d & restyp(itypi),i,restyp(itypj),j,aa(itypi,itypj),
11565 !d & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
11566 !d & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
11567 !d & (c(k,i),k=1,3),(c(k,j),k=1,3)
11568 evdw=evdw+sss*evdwij
11570 ! Calculate the components of the gradient in DC and X
11572 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
11578 gvdwx(k,i)=gvdwx(k,i)-gg(k)
11579 gvdwx(k,j)=gvdwx(k,j)+gg(k)
11580 gvdwc(k,i)=gvdwc(k,i)-gg(k)
11581 gvdwc(k,j)=gvdwc(k,j)+gg(k)
11589 gvdwc(j,i)=expon*gvdwc(j,i)
11590 gvdwx(j,i)=expon*gvdwx(j,i)
11594 end subroutine eljk_short
11595 !-----------------------------------------------------------------------------
11596 subroutine ebp_long(evdw)
11598 ! This subroutine calculates the interaction energy of nonbonded side chains
11599 ! assuming the Berne-Pechukas potential of interaction.
11602 ! implicit real*8 (a-h,o-z)
11603 ! include 'DIMENSIONS'
11604 ! include 'COMMON.GEO'
11605 ! include 'COMMON.VAR'
11606 ! include 'COMMON.LOCAL'
11607 ! include 'COMMON.CHAIN'
11608 ! include 'COMMON.DERIV'
11609 ! include 'COMMON.NAMES'
11610 ! include 'COMMON.INTERACT'
11611 ! include 'COMMON.IOUNITS'
11612 ! include 'COMMON.CALC'
11614 !el integer :: icall
11615 !el common /srutu/ icall
11616 ! double precision rrsave(maxdim)
11618 !el local variables
11619 integer :: iint,itypi,itypi1,itypj
11620 real(kind=8) :: rrij,xi,yi,zi,fac
11621 real(kind=8) :: sss,e1,e2,evdw,sigm,epsi
11623 ! print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
11625 ! if (icall.eq.0) then
11631 do i=iatsc_s,iatsc_e
11633 if (itypi.eq.ntyp1) cycle
11638 dxi=dc_norm(1,nres+i)
11639 dyi=dc_norm(2,nres+i)
11640 dzi=dc_norm(3,nres+i)
11641 ! dsci_inv=dsc_inv(itypi)
11642 dsci_inv=vbld_inv(i+nres)
11644 ! Calculate SC interaction energy.
11646 do iint=1,nint_gr(i)
11647 do j=istart(i,iint),iend(i,iint)
11650 if (itypj.eq.ntyp1) cycle
11651 ! dscj_inv=dsc_inv(itypj)
11652 dscj_inv=vbld_inv(j+nres)
11653 chi1=chi(itypi,itypj)
11654 chi2=chi(itypj,itypi)
11661 alf12=0.5D0*(alf1+alf2)
11665 dxj=dc_norm(1,nres+j)
11666 dyj=dc_norm(2,nres+j)
11667 dzj=dc_norm(3,nres+j)
11668 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
11670 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
11672 if (sss.lt.1.0d0) then
11674 ! Calculate the angle-dependent terms of energy & contributions to derivatives.
11676 ! Calculate whole angle-dependent part of epsilon and contributions
11677 ! to its derivatives
11678 fac=(rrij*sigsq)**expon2
11679 e1=fac*fac*aa(itypi,itypj)
11680 e2=fac*bb(itypi,itypj)
11681 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
11682 eps2der=evdwij*eps3rt
11683 eps3der=evdwij*eps2rt
11684 evdwij=evdwij*eps2rt*eps3rt
11685 evdw=evdw+evdwij*(1.0d0-sss)
11687 sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
11688 epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
11689 !d write (iout,'(2(a3,i3,2x),15(0pf7.3))')
11690 !d & restyp(itypi),i,restyp(itypj),j,
11691 !d & epsi,sigm,chi1,chi2,chip1,chip2,
11692 !d & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
11693 !d & om1,om2,om12,1.0D0/dsqrt(rrij),
11696 ! Calculate gradient components.
11697 e1=e1*eps1*eps2rt**2*eps3rt**2
11698 fac=-expon*(e1+evdwij)
11701 ! Calculate radial part of the gradient
11705 ! Calculate the angular part of the gradient and sum add the contributions
11706 ! to the appropriate components of the Cartesian gradient.
11707 call sc_grad_scale(1.0d0-sss)
11714 end subroutine ebp_long
11715 !-----------------------------------------------------------------------------
11716 subroutine ebp_short(evdw)
11718 ! This subroutine calculates the interaction energy of nonbonded side chains
11719 ! assuming the Berne-Pechukas potential of interaction.
11722 ! implicit real*8 (a-h,o-z)
11723 ! include 'DIMENSIONS'
11724 ! include 'COMMON.GEO'
11725 ! include 'COMMON.VAR'
11726 ! include 'COMMON.LOCAL'
11727 ! include 'COMMON.CHAIN'
11728 ! include 'COMMON.DERIV'
11729 ! include 'COMMON.NAMES'
11730 ! include 'COMMON.INTERACT'
11731 ! include 'COMMON.IOUNITS'
11732 ! include 'COMMON.CALC'
11734 !el integer :: icall
11735 !el common /srutu/ icall
11736 ! double precision rrsave(maxdim)
11738 !el local variables
11739 integer :: iint,itypi,itypi1,itypj
11740 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi
11741 real(kind=8) :: sss,e1,e2,evdw
11743 ! print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
11745 ! if (icall.eq.0) then
11751 do i=iatsc_s,iatsc_e
11753 if (itypi.eq.ntyp1) cycle
11758 dxi=dc_norm(1,nres+i)
11759 dyi=dc_norm(2,nres+i)
11760 dzi=dc_norm(3,nres+i)
11761 ! dsci_inv=dsc_inv(itypi)
11762 dsci_inv=vbld_inv(i+nres)
11764 ! Calculate SC interaction energy.
11766 do iint=1,nint_gr(i)
11767 do j=istart(i,iint),iend(i,iint)
11770 if (itypj.eq.ntyp1) cycle
11771 ! dscj_inv=dsc_inv(itypj)
11772 dscj_inv=vbld_inv(j+nres)
11773 chi1=chi(itypi,itypj)
11774 chi2=chi(itypj,itypi)
11781 alf12=0.5D0*(alf1+alf2)
11785 dxj=dc_norm(1,nres+j)
11786 dyj=dc_norm(2,nres+j)
11787 dzj=dc_norm(3,nres+j)
11788 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
11790 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
11792 if (sss.gt.0.0d0) then
11794 ! Calculate the angle-dependent terms of energy & contributions to derivatives.
11796 ! Calculate whole angle-dependent part of epsilon and contributions
11797 ! to its derivatives
11798 fac=(rrij*sigsq)**expon2
11799 e1=fac*fac*aa(itypi,itypj)
11800 e2=fac*bb(itypi,itypj)
11801 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
11802 eps2der=evdwij*eps3rt
11803 eps3der=evdwij*eps2rt
11804 evdwij=evdwij*eps2rt*eps3rt
11805 evdw=evdw+evdwij*sss
11807 sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
11808 epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
11809 !d write (iout,'(2(a3,i3,2x),15(0pf7.3))')
11810 !d & restyp(itypi),i,restyp(itypj),j,
11811 !d & epsi,sigm,chi1,chi2,chip1,chip2,
11812 !d & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
11813 !d & om1,om2,om12,1.0D0/dsqrt(rrij),
11816 ! Calculate gradient components.
11817 e1=e1*eps1*eps2rt**2*eps3rt**2
11818 fac=-expon*(e1+evdwij)
11821 ! Calculate radial part of the gradient
11825 ! Calculate the angular part of the gradient and sum add the contributions
11826 ! to the appropriate components of the Cartesian gradient.
11827 call sc_grad_scale(sss)
11834 end subroutine ebp_short
11835 !-----------------------------------------------------------------------------
11836 subroutine egb_long(evdw)
11838 ! This subroutine calculates the interaction energy of nonbonded side chains
11839 ! assuming the Gay-Berne potential of interaction.
11842 ! implicit real*8 (a-h,o-z)
11843 ! include 'DIMENSIONS'
11844 ! include 'COMMON.GEO'
11845 ! include 'COMMON.VAR'
11846 ! include 'COMMON.LOCAL'
11847 ! include 'COMMON.CHAIN'
11848 ! include 'COMMON.DERIV'
11849 ! include 'COMMON.NAMES'
11850 ! include 'COMMON.INTERACT'
11851 ! include 'COMMON.IOUNITS'
11852 ! include 'COMMON.CALC'
11853 ! include 'COMMON.CONTROL'
11855 !el local variables
11856 integer :: iint,itypi,itypi1,itypj,subchap
11857 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,sig,sig0ij,rij_shift
11858 real(kind=8) :: sss,e1,e2,evdw,sss_grad
11859 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
11860 dist_temp, dist_init
11863 !cccc energy_dec=.false.
11864 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
11867 ! if (icall.eq.0) lprn=.false.
11869 do i=iatsc_s,iatsc_e
11871 if (itypi.eq.ntyp1) cycle
11876 xi=mod(xi,boxxsize)
11877 if (xi.lt.0) xi=xi+boxxsize
11878 yi=mod(yi,boxysize)
11879 if (yi.lt.0) yi=yi+boxysize
11880 zi=mod(zi,boxzsize)
11881 if (zi.lt.0) zi=zi+boxzsize
11882 dxi=dc_norm(1,nres+i)
11883 dyi=dc_norm(2,nres+i)
11884 dzi=dc_norm(3,nres+i)
11885 ! dsci_inv=dsc_inv(itypi)
11886 dsci_inv=vbld_inv(i+nres)
11887 ! write (iout,*) "i",i,dsc_inv(itypi),dsci_inv,1.0d0/vbld(i+nres)
11888 ! write (iout,*) "dcnori",dxi*dxi+dyi*dyi+dzi*dzi
11890 ! Calculate SC interaction energy.
11892 do iint=1,nint_gr(i)
11893 do j=istart(i,iint),iend(i,iint)
11896 if (itypj.eq.ntyp1) cycle
11897 ! dscj_inv=dsc_inv(itypj)
11898 dscj_inv=vbld_inv(j+nres)
11899 ! write (iout,*) "j",j,dsc_inv(itypj),dscj_inv,
11900 ! & 1.0d0/vbld(j+nres)
11901 ! write (iout,*) "i",i," j", j," itype",itype(i),itype(j)
11902 sig0ij=sigma(itypi,itypj)
11903 chi1=chi(itypi,itypj)
11904 chi2=chi(itypj,itypi)
11911 alf12=0.5D0*(alf1+alf2)
11915 ! Searching for nearest neighbour
11916 xj=mod(xj,boxxsize)
11917 if (xj.lt.0) xj=xj+boxxsize
11918 yj=mod(yj,boxysize)
11919 if (yj.lt.0) yj=yj+boxysize
11920 zj=mod(zj,boxzsize)
11921 if (zj.lt.0) zj=zj+boxzsize
11922 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
11930 xj=xj_safe+xshift*boxxsize
11931 yj=yj_safe+yshift*boxysize
11932 zj=zj_safe+zshift*boxzsize
11933 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
11934 if(dist_temp.lt.dist_init) then
11935 dist_init=dist_temp
11944 if (subchap.eq.1) then
11954 dxj=dc_norm(1,nres+j)
11955 dyj=dc_norm(2,nres+j)
11956 dzj=dc_norm(3,nres+j)
11957 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
11959 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
11960 sss_ele_cut=sscale_ele(1.0d0/(rij*sigma(itypi,itypj)))
11961 sss_ele_grad=sscagrad_ele(1.0d0/(rij*sigma(itypi,itypj)))
11962 sss_grad=sscale_grad(1.0d0/(rij*sigmaii(itypi,itypj)))
11963 if (sss_ele_cut.le.0.0) cycle
11964 if (sss.lt.1.0d0) then
11966 ! Calculate angle-dependent terms of energy and contributions to their
11970 sig=sig0ij*dsqrt(sigsq)
11971 rij_shift=1.0D0/rij-sig+sig0ij
11972 ! for diagnostics; uncomment
11973 ! rij_shift=1.2*sig0ij
11974 ! I hate to put IF's in the loops, but here don't have another choice!!!!
11975 if (rij_shift.le.0.0D0) then
11977 !d write (iout,'(2(a3,i3,2x),17(0pf7.3))')
11978 !d & restyp(itypi),i,restyp(itypj),j,
11979 !d & rij_shift,1.0D0/rij,sig,sig0ij,sigsq,1-dsqrt(sigsq)
11983 !---------------------------------------------------------------
11984 rij_shift=1.0D0/rij_shift
11985 fac=rij_shift**expon
11986 e1=fac*fac*aa(itypi,itypj)
11987 e2=fac*bb(itypi,itypj)
11988 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
11989 eps2der=evdwij*eps3rt
11990 eps3der=evdwij*eps2rt
11991 ! write (iout,*) "sigsq",sigsq," sig",sig," eps2rt",eps2rt,
11992 ! & " eps3rt",eps3rt," eps1",eps1," e1",e1," e2",e2
11993 evdwij=evdwij*eps2rt*eps3rt
11994 evdw=evdw+evdwij*(1.0d0-sss)*sss_ele_cut
11996 sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
11997 epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
11998 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
11999 restyp(itypi),i,restyp(itypj),j,&
12000 epsi,sigm,chi1,chi2,chip1,chip2,&
12001 eps1,eps2rt**2,eps3rt**2,sig,sig0ij,&
12002 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
12006 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
12008 ! if (energy_dec) write (iout,*) &
12009 ! 'evdw',i,j,evdwij,"egb_long"
12011 ! Calculate gradient components.
12012 e1=e1*eps1*eps2rt**2*eps3rt**2
12013 fac=-expon*(e1+evdwij)*rij_shift
12016 fac=fac+evdwij*(sss_ele_grad/sss_ele_cut&
12017 /sigma(itypi,itypj)*rij-sss_grad/(1.0-sss)*rij &
12018 /sigmaii(itypi,itypj))
12020 ! Calculate the radial part of the gradient
12024 ! Calculate angular part of the gradient.
12025 call sc_grad_scale(1.0d0-sss)
12030 ! write (iout,*) "Number of loop steps in EGB:",ind
12031 !ccc energy_dec=.false.
12033 end subroutine egb_long
12034 !-----------------------------------------------------------------------------
12035 subroutine egb_short(evdw)
12037 ! This subroutine calculates the interaction energy of nonbonded side chains
12038 ! assuming the Gay-Berne potential of interaction.
12041 ! implicit real*8 (a-h,o-z)
12042 ! include 'DIMENSIONS'
12043 ! include 'COMMON.GEO'
12044 ! include 'COMMON.VAR'
12045 ! include 'COMMON.LOCAL'
12046 ! include 'COMMON.CHAIN'
12047 ! include 'COMMON.DERIV'
12048 ! include 'COMMON.NAMES'
12049 ! include 'COMMON.INTERACT'
12050 ! include 'COMMON.IOUNITS'
12051 ! include 'COMMON.CALC'
12052 ! include 'COMMON.CONTROL'
12054 !el local variables
12055 integer :: iint,itypi,itypi1,itypj,subchap
12056 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,sig0ij,sig
12057 real(kind=8) :: sss,e1,e2,evdw,rij_shift,sss_grad
12058 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
12059 dist_temp, dist_init
12061 !cccc energy_dec=.false.
12062 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
12065 ! if (icall.eq.0) lprn=.false.
12067 do i=iatsc_s,iatsc_e
12069 if (itypi.eq.ntyp1) cycle
12074 xi=mod(xi,boxxsize)
12075 if (xi.lt.0) xi=xi+boxxsize
12076 yi=mod(yi,boxysize)
12077 if (yi.lt.0) yi=yi+boxysize
12078 zi=mod(zi,boxzsize)
12079 if (zi.lt.0) zi=zi+boxzsize
12080 dxi=dc_norm(1,nres+i)
12081 dyi=dc_norm(2,nres+i)
12082 dzi=dc_norm(3,nres+i)
12083 ! dsci_inv=dsc_inv(itypi)
12084 dsci_inv=vbld_inv(i+nres)
12086 dxi=dc_norm(1,nres+i)
12087 dyi=dc_norm(2,nres+i)
12088 dzi=dc_norm(3,nres+i)
12089 ! dsci_inv=dsc_inv(itypi)
12090 dsci_inv=vbld_inv(i+nres)
12091 ! write (iout,*) "i",i,dsc_inv(itypi),dsci_inv,1.0d0/vbld(i+nres)
12092 ! write (iout,*) "dcnori",dxi*dxi+dyi*dyi+dzi*dzi
12094 ! Calculate SC interaction energy.
12096 do iint=1,nint_gr(i)
12097 do j=istart(i,iint),iend(i,iint)
12100 if (itypj.eq.ntyp1) cycle
12101 ! dscj_inv=dsc_inv(itypj)
12102 dscj_inv=vbld_inv(j+nres)
12103 ! write (iout,*) "j",j,dsc_inv(itypj),dscj_inv,
12104 ! & 1.0d0/vbld(j+nres)
12105 ! write (iout,*) "i",i," j", j," itype",itype(i),itype(j)
12106 sig0ij=sigma(itypi,itypj)
12107 chi1=chi(itypi,itypj)
12108 chi2=chi(itypj,itypi)
12115 alf12=0.5D0*(alf1+alf2)
12116 ! xj=c(1,nres+j)-xi
12117 ! yj=c(2,nres+j)-yi
12118 ! zj=c(3,nres+j)-zi
12122 ! Searching for nearest neighbour
12123 xj=mod(xj,boxxsize)
12124 if (xj.lt.0) xj=xj+boxxsize
12125 yj=mod(yj,boxysize)
12126 if (yj.lt.0) yj=yj+boxysize
12127 zj=mod(zj,boxzsize)
12128 if (zj.lt.0) zj=zj+boxzsize
12129 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
12137 xj=xj_safe+xshift*boxxsize
12138 yj=yj_safe+yshift*boxysize
12139 zj=zj_safe+zshift*boxzsize
12140 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
12141 if(dist_temp.lt.dist_init) then
12142 dist_init=dist_temp
12151 if (subchap.eq.1) then
12161 dxj=dc_norm(1,nres+j)
12162 dyj=dc_norm(2,nres+j)
12163 dzj=dc_norm(3,nres+j)
12164 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
12166 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
12167 sss_grad=sscale_grad(1.0d0/(rij*sigmaii(itypi,itypj)))
12168 sss_ele_cut=sscale_ele(1.0d0/(rij*sigma(itypi,itypj)))
12169 sss_ele_grad=sscagrad_ele(1.0d0/(rij*sigma(itypi,itypj)))
12170 if (sss_ele_cut.le.0.0) cycle
12172 if (sss.gt.0.0d0) then
12174 ! Calculate angle-dependent terms of energy and contributions to their
12178 sig=sig0ij*dsqrt(sigsq)
12179 rij_shift=1.0D0/rij-sig+sig0ij
12180 ! for diagnostics; uncomment
12181 ! rij_shift=1.2*sig0ij
12182 ! I hate to put IF's in the loops, but here don't have another choice!!!!
12183 if (rij_shift.le.0.0D0) then
12185 !d write (iout,'(2(a3,i3,2x),17(0pf7.3))')
12186 !d & restyp(itypi),i,restyp(itypj),j,
12187 !d & rij_shift,1.0D0/rij,sig,sig0ij,sigsq,1-dsqrt(sigsq)
12191 !---------------------------------------------------------------
12192 rij_shift=1.0D0/rij_shift
12193 fac=rij_shift**expon
12194 e1=fac*fac*aa(itypi,itypj)
12195 e2=fac*bb(itypi,itypj)
12196 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
12197 eps2der=evdwij*eps3rt
12198 eps3der=evdwij*eps2rt
12199 ! write (iout,*) "sigsq",sigsq," sig",sig," eps2rt",eps2rt,
12200 ! & " eps3rt",eps3rt," eps1",eps1," e1",e1," e2",e2
12201 evdwij=evdwij*eps2rt*eps3rt
12202 evdw=evdw+evdwij*sss*sss_ele_cut
12204 sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
12205 epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
12206 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
12207 restyp(itypi),i,restyp(itypj),j,&
12208 epsi,sigm,chi1,chi2,chip1,chip2,&
12209 eps1,eps2rt**2,eps3rt**2,sig,sig0ij,&
12210 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
12214 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
12216 ! if (energy_dec) write (iout,*) &
12217 ! 'evdw',i,j,evdwij,"egb_short"
12219 ! Calculate gradient components.
12220 e1=e1*eps1*eps2rt**2*eps3rt**2
12221 fac=-expon*(e1+evdwij)*rij_shift
12224 fac=fac+evdwij*(sss_ele_grad/sss_ele_cut&
12225 /sigma(itypi,itypj)*rij+sss_grad/sss*rij &
12226 /sigmaii(itypi,itypj))
12229 ! Calculate the radial part of the gradient
12233 ! Calculate angular part of the gradient.
12234 call sc_grad_scale(sss)
12239 ! write (iout,*) "Number of loop steps in EGB:",ind
12240 !ccc energy_dec=.false.
12242 end subroutine egb_short
12243 !-----------------------------------------------------------------------------
12244 subroutine egbv_long(evdw)
12246 ! This subroutine calculates the interaction energy of nonbonded side chains
12247 ! assuming the Gay-Berne-Vorobjev potential of interaction.
12250 ! implicit real*8 (a-h,o-z)
12251 ! include 'DIMENSIONS'
12252 ! include 'COMMON.GEO'
12253 ! include 'COMMON.VAR'
12254 ! include 'COMMON.LOCAL'
12255 ! include 'COMMON.CHAIN'
12256 ! include 'COMMON.DERIV'
12257 ! include 'COMMON.NAMES'
12258 ! include 'COMMON.INTERACT'
12259 ! include 'COMMON.IOUNITS'
12260 ! include 'COMMON.CALC'
12262 !el integer :: icall
12263 !el common /srutu/ icall
12265 !el local variables
12266 integer :: iint,itypi,itypi1,itypj
12267 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,r0ij,sig,sig0ij
12268 real(kind=8) :: sss,e1,e2,evdw,fac_augm,e_augm,rij_shift
12270 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
12273 ! if (icall.eq.0) lprn=.true.
12275 do i=iatsc_s,iatsc_e
12277 if (itypi.eq.ntyp1) cycle
12282 dxi=dc_norm(1,nres+i)
12283 dyi=dc_norm(2,nres+i)
12284 dzi=dc_norm(3,nres+i)
12285 ! dsci_inv=dsc_inv(itypi)
12286 dsci_inv=vbld_inv(i+nres)
12288 ! Calculate SC interaction energy.
12290 do iint=1,nint_gr(i)
12291 do j=istart(i,iint),iend(i,iint)
12294 if (itypj.eq.ntyp1) cycle
12295 ! dscj_inv=dsc_inv(itypj)
12296 dscj_inv=vbld_inv(j+nres)
12297 sig0ij=sigma(itypi,itypj)
12298 r0ij=r0(itypi,itypj)
12299 chi1=chi(itypi,itypj)
12300 chi2=chi(itypj,itypi)
12307 alf12=0.5D0*(alf1+alf2)
12311 dxj=dc_norm(1,nres+j)
12312 dyj=dc_norm(2,nres+j)
12313 dzj=dc_norm(3,nres+j)
12314 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
12317 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
12319 if (sss.lt.1.0d0) then
12321 ! Calculate angle-dependent terms of energy and contributions to their
12325 sig=sig0ij*dsqrt(sigsq)
12326 rij_shift=1.0D0/rij-sig+r0ij
12327 ! I hate to put IF's in the loops, but here don't have another choice!!!!
12328 if (rij_shift.le.0.0D0) then
12333 !---------------------------------------------------------------
12334 rij_shift=1.0D0/rij_shift
12335 fac=rij_shift**expon
12336 e1=fac*fac*aa(itypi,itypj)
12337 e2=fac*bb(itypi,itypj)
12338 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
12339 eps2der=evdwij*eps3rt
12340 eps3der=evdwij*eps2rt
12341 fac_augm=rrij**expon
12342 e_augm=augm(itypi,itypj)*fac_augm
12343 evdwij=evdwij*eps2rt*eps3rt
12344 evdw=evdw+(evdwij+e_augm)*(1.0d0-sss)
12346 sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
12347 epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
12348 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
12349 restyp(itypi),i,restyp(itypj),j,&
12350 epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),&
12351 chi1,chi2,chip1,chip2,&
12352 eps1,eps2rt**2,eps3rt**2,&
12353 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
12356 ! Calculate gradient components.
12357 e1=e1*eps1*eps2rt**2*eps3rt**2
12358 fac=-expon*(e1+evdwij)*rij_shift
12360 fac=rij*fac-2*expon*rrij*e_augm
12361 ! Calculate the radial part of the gradient
12365 ! Calculate angular part of the gradient.
12366 call sc_grad_scale(1.0d0-sss)
12371 end subroutine egbv_long
12372 !-----------------------------------------------------------------------------
12373 subroutine egbv_short(evdw)
12375 ! This subroutine calculates the interaction energy of nonbonded side chains
12376 ! assuming the Gay-Berne-Vorobjev potential of interaction.
12379 ! implicit real*8 (a-h,o-z)
12380 ! include 'DIMENSIONS'
12381 ! include 'COMMON.GEO'
12382 ! include 'COMMON.VAR'
12383 ! include 'COMMON.LOCAL'
12384 ! include 'COMMON.CHAIN'
12385 ! include 'COMMON.DERIV'
12386 ! include 'COMMON.NAMES'
12387 ! include 'COMMON.INTERACT'
12388 ! include 'COMMON.IOUNITS'
12389 ! include 'COMMON.CALC'
12391 !el integer :: icall
12392 !el common /srutu/ icall
12394 !el local variables
12395 integer :: iint,itypi,itypi1,itypj
12396 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,rij_shift
12397 real(kind=8) :: sss,e1,e2,evdw,r0ij,sig,sig0ij,fac_augm,e_augm
12399 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
12402 ! if (icall.eq.0) lprn=.true.
12404 do i=iatsc_s,iatsc_e
12406 if (itypi.eq.ntyp1) cycle
12411 dxi=dc_norm(1,nres+i)
12412 dyi=dc_norm(2,nres+i)
12413 dzi=dc_norm(3,nres+i)
12414 ! dsci_inv=dsc_inv(itypi)
12415 dsci_inv=vbld_inv(i+nres)
12417 ! Calculate SC interaction energy.
12419 do iint=1,nint_gr(i)
12420 do j=istart(i,iint),iend(i,iint)
12423 if (itypj.eq.ntyp1) cycle
12424 ! dscj_inv=dsc_inv(itypj)
12425 dscj_inv=vbld_inv(j+nres)
12426 sig0ij=sigma(itypi,itypj)
12427 r0ij=r0(itypi,itypj)
12428 chi1=chi(itypi,itypj)
12429 chi2=chi(itypj,itypi)
12436 alf12=0.5D0*(alf1+alf2)
12440 dxj=dc_norm(1,nres+j)
12441 dyj=dc_norm(2,nres+j)
12442 dzj=dc_norm(3,nres+j)
12443 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
12446 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
12448 if (sss.gt.0.0d0) then
12450 ! Calculate angle-dependent terms of energy and contributions to their
12454 sig=sig0ij*dsqrt(sigsq)
12455 rij_shift=1.0D0/rij-sig+r0ij
12456 ! I hate to put IF's in the loops, but here don't have another choice!!!!
12457 if (rij_shift.le.0.0D0) then
12462 !---------------------------------------------------------------
12463 rij_shift=1.0D0/rij_shift
12464 fac=rij_shift**expon
12465 e1=fac*fac*aa(itypi,itypj)
12466 e2=fac*bb(itypi,itypj)
12467 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
12468 eps2der=evdwij*eps3rt
12469 eps3der=evdwij*eps2rt
12470 fac_augm=rrij**expon
12471 e_augm=augm(itypi,itypj)*fac_augm
12472 evdwij=evdwij*eps2rt*eps3rt
12473 evdw=evdw+(evdwij+e_augm)*sss
12475 sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
12476 epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
12477 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
12478 restyp(itypi),i,restyp(itypj),j,&
12479 epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),&
12480 chi1,chi2,chip1,chip2,&
12481 eps1,eps2rt**2,eps3rt**2,&
12482 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
12485 ! Calculate gradient components.
12486 e1=e1*eps1*eps2rt**2*eps3rt**2
12487 fac=-expon*(e1+evdwij)*rij_shift
12489 fac=rij*fac-2*expon*rrij*e_augm
12490 ! Calculate the radial part of the gradient
12494 ! Calculate angular part of the gradient.
12495 call sc_grad_scale(sss)
12500 end subroutine egbv_short
12501 !-----------------------------------------------------------------------------
12502 subroutine eelec_scale(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
12504 ! This subroutine calculates the average interaction energy and its gradient
12505 ! in the virtual-bond vectors between non-adjacent peptide groups, based on
12506 ! the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
12507 ! The potential depends both on the distance of peptide-group centers and on
12508 ! the orientation of the CA-CA virtual bonds.
12510 ! implicit real*8 (a-h,o-z)
12516 ! include 'DIMENSIONS'
12517 ! include 'COMMON.CONTROL'
12518 ! include 'COMMON.SETUP'
12519 ! include 'COMMON.IOUNITS'
12520 ! include 'COMMON.GEO'
12521 ! include 'COMMON.VAR'
12522 ! include 'COMMON.LOCAL'
12523 ! include 'COMMON.CHAIN'
12524 ! include 'COMMON.DERIV'
12525 ! include 'COMMON.INTERACT'
12526 ! include 'COMMON.CONTACTS'
12527 ! include 'COMMON.TORSION'
12528 ! include 'COMMON.VECTORS'
12529 ! include 'COMMON.FFIELD'
12530 ! include 'COMMON.TIME1'
12531 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg
12532 real(kind=8),dimension(3,3) ::erder,uryg,urzg,vryg,vrzg
12533 real(kind=8),dimension(2,2) :: acipa !el,a_temp
12534 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
12535 real(kind=8),dimension(4) :: muij
12536 !el integer :: num_conti,j1,j2
12537 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
12538 !el dz_normi,xmedi,ymedi,zmedi
12539 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
12540 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
12541 !el num_conti,j1,j2
12542 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
12544 real(kind=8) :: scal_el=1.0d0
12546 real(kind=8) :: scal_el=0.5d0
12549 ! 13-go grudnia roku pamietnego...
12550 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
12551 0.0d0,1.0d0,0.0d0,&
12552 0.0d0,0.0d0,1.0d0/),shape(unmat))
12553 !el local variables
12555 real(kind=8) :: fac
12556 real(kind=8) :: dxj,dyj,dzj
12557 real(kind=8) :: ees,evdw1,eel_loc,eello_turn3,eello_turn4
12559 ! allocate(num_cont_hb(nres)) !(maxres)
12560 !d write(iout,*) 'In EELEC'
12562 !d write(iout,*) 'Type',i
12563 !d write(iout,*) 'B1',B1(:,i)
12564 !d write(iout,*) 'B2',B2(:,i)
12565 !d write(iout,*) 'CC',CC(:,:,i)
12566 !d write(iout,*) 'DD',DD(:,:,i)
12567 !d write(iout,*) 'EE',EE(:,:,i)
12569 !d call check_vecgrad
12571 if (icheckgrad.eq.1) then
12573 fac=1.0d0/dsqrt(scalar(dc(1,i),dc(1,i)))
12575 dc_norm(k,i)=dc(k,i)*fac
12577 ! write (iout,*) 'i',i,' fac',fac
12580 if (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
12581 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 .or. &
12582 wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) then
12583 ! call vec_and_deriv
12589 time_mat=time_mat+MPI_Wtime()-time01
12593 !d write (iout,*) 'i=',i
12595 !d write (iout,'(i5,2f10.5)') k,uy(k,i),uz(k,i)
12598 !d write (iout,'(f10.5,2x,3f10.5,2x,3f10.5)')
12599 !d & uz(k,i),(uzgrad(k,l,1,i),l=1,3),(uzgrad(k,l,2,i),l=1,3)
12612 !d print '(a)','Enter EELEC'
12613 !d write (iout,*) 'iatel_s=',iatel_s,' iatel_e=',iatel_e
12614 ! if (.not.allocated(gel_loc_loc)) allocate(gel_loc_loc(nres)) !(maxvar)(maxvar=6*maxres)
12615 ! if (.not.allocated(gcorr_loc)) allocate(gcorr_loc(nres)) !(maxvar)(maxvar=6*maxres)
12617 gel_loc_loc(i)=0.0d0
12622 ! 9/27/08 AL Split the interaction loop to ensure load balancing of turn terms
12624 ! Loop over i,i+2 and i,i+3 pairs of the peptide groups
12626 do i=iturn3_start,iturn3_end
12627 if (itype(i).eq.ntyp1.or. itype(i+1).eq.ntyp1 &
12628 .or. itype(i+2).eq.ntyp1 .or. itype(i+3).eq.ntyp1) cycle
12632 dx_normi=dc_norm(1,i)
12633 dy_normi=dc_norm(2,i)
12634 dz_normi=dc_norm(3,i)
12635 xmedi=c(1,i)+0.5d0*dxi
12636 ymedi=c(2,i)+0.5d0*dyi
12637 zmedi=c(3,i)+0.5d0*dzi
12638 xmedi=dmod(xmedi,boxxsize)
12639 if (xmedi.lt.0) xmedi=xmedi+boxxsize
12640 ymedi=dmod(ymedi,boxysize)
12641 if (ymedi.lt.0) ymedi=ymedi+boxysize
12642 zmedi=dmod(zmedi,boxzsize)
12643 if (zmedi.lt.0) zmedi=zmedi+boxzsize
12645 call eelecij_scale(i,i+2,ees,evdw1,eel_loc)
12646 if (wturn3.gt.0.0d0) call eturn3(i,eello_turn3)
12647 num_cont_hb(i)=num_conti
12649 do i=iturn4_start,iturn4_end
12650 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1 &
12651 .or. itype(i+3).eq.ntyp1 &
12652 .or. itype(i+4).eq.ntyp1) cycle
12656 dx_normi=dc_norm(1,i)
12657 dy_normi=dc_norm(2,i)
12658 dz_normi=dc_norm(3,i)
12659 xmedi=c(1,i)+0.5d0*dxi
12660 ymedi=c(2,i)+0.5d0*dyi
12661 zmedi=c(3,i)+0.5d0*dzi
12662 xmedi=dmod(xmedi,boxxsize)
12663 if (xmedi.lt.0) xmedi=xmedi+boxxsize
12664 ymedi=dmod(ymedi,boxysize)
12665 if (ymedi.lt.0) ymedi=ymedi+boxysize
12666 zmedi=dmod(zmedi,boxzsize)
12667 if (zmedi.lt.0) zmedi=zmedi+boxzsize
12668 num_conti=num_cont_hb(i)
12669 call eelecij_scale(i,i+3,ees,evdw1,eel_loc)
12670 if (wturn4.gt.0.0d0 .and. itype(i+2).ne.ntyp1) &
12671 call eturn4(i,eello_turn4)
12672 num_cont_hb(i)=num_conti
12675 ! Loop over all pairs of interacting peptide groups except i,i+2 and i,i+3
12677 do i=iatel_s,iatel_e
12678 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1) cycle
12682 dx_normi=dc_norm(1,i)
12683 dy_normi=dc_norm(2,i)
12684 dz_normi=dc_norm(3,i)
12685 xmedi=c(1,i)+0.5d0*dxi
12686 ymedi=c(2,i)+0.5d0*dyi
12687 zmedi=c(3,i)+0.5d0*dzi
12688 xmedi=dmod(xmedi,boxxsize)
12689 if (xmedi.lt.0) xmedi=xmedi+boxxsize
12690 ymedi=dmod(ymedi,boxysize)
12691 if (ymedi.lt.0) ymedi=ymedi+boxysize
12692 zmedi=dmod(zmedi,boxzsize)
12693 if (zmedi.lt.0) zmedi=zmedi+boxzsize
12694 ! write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
12695 num_conti=num_cont_hb(i)
12696 do j=ielstart(i),ielend(i)
12697 if (itype(j).eq.ntyp1 .or. itype(j+1).eq.ntyp1) cycle
12698 call eelecij_scale(i,j,ees,evdw1,eel_loc)
12700 num_cont_hb(i)=num_conti
12702 ! write (iout,*) "Number of loop steps in EELEC:",ind
12704 !d write (iout,'(i3,3f10.5,5x,3f10.5)')
12705 !d & i,(gel_loc(k,i),k=1,3),gel_loc_loc(i)
12707 ! 12/7/99 Adam eello_turn3 will be considered as a separate energy term
12708 !cc eel_loc=eel_loc+eello_turn3
12709 !d print *,"Processor",fg_rank," t_eelecij",t_eelecij
12711 end subroutine eelec_scale
12712 !-----------------------------------------------------------------------------
12713 subroutine eelecij_scale(i,j,ees,evdw1,eel_loc)
12714 ! implicit real*8 (a-h,o-z)
12717 ! include 'DIMENSIONS'
12721 ! include 'COMMON.CONTROL'
12722 ! include 'COMMON.IOUNITS'
12723 ! include 'COMMON.GEO'
12724 ! include 'COMMON.VAR'
12725 ! include 'COMMON.LOCAL'
12726 ! include 'COMMON.CHAIN'
12727 ! include 'COMMON.DERIV'
12728 ! include 'COMMON.INTERACT'
12729 ! include 'COMMON.CONTACTS'
12730 ! include 'COMMON.TORSION'
12731 ! include 'COMMON.VECTORS'
12732 ! include 'COMMON.FFIELD'
12733 ! include 'COMMON.TIME1'
12734 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg,xtemp
12735 real(kind=8),dimension(3,3) :: erder,uryg,urzg,vryg,vrzg
12736 real(kind=8),dimension(2,2) :: acipa !el,a_temp
12737 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
12738 real(kind=8),dimension(4) :: muij
12739 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
12740 dist_temp, dist_init,sss_grad
12741 integer xshift,yshift,zshift
12743 !el integer :: num_conti,j1,j2
12744 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
12745 !el dz_normi,xmedi,ymedi,zmedi
12746 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
12747 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
12748 !el num_conti,j1,j2
12749 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
12751 real(kind=8) :: scal_el=1.0d0
12753 real(kind=8) :: scal_el=0.5d0
12756 ! 13-go grudnia roku pamietnego...
12757 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
12758 0.0d0,1.0d0,0.0d0,&
12759 0.0d0,0.0d0,1.0d0/),shape(unmat))
12760 !el local variables
12761 integer :: i,j,k,l,iteli,itelj,kkk,kkll,m,isubchap
12762 real(kind=8) :: aaa,bbb,ael6i,ael3i,dxj,dyj,dzj
12763 real(kind=8) :: xj,yj,zj,rij,rrmij,rmij,sss,r3ij,r6ij,fac
12764 real(kind=8) :: cosa,cosb,cosg,ev1,ev2,fac3,fac4,evdwij
12765 real(kind=8) :: el1,el2,eesij,ees0ij,r0ij,fcont,fprimcont
12766 real(kind=8) :: ees0tmp,ees0pij1,ees0mij1,ees0pijp,ees0mijp
12767 real(kind=8) :: ees,evdw1,eel_loc,eel_loc_ij,dx_normj,dy_normj,&
12768 dz_normj,facvdw,facel,fac1,facr,ecosa,ecosb,ecosg,&
12769 ury,urz,vry,vrz,a22der,a23der,a32der,a33der,cosa4,&
12770 wij,cosbg1,cosbg2,ees0pij,ees0mij,fac3p,ecosa1,ecosb1,&
12771 ecosg1,ecosa2,ecosb2,ecosg2,ecosap,ecosbp,ecosgp,&
12772 ecosam,ecosbm,ecosgm,ghalf,time00
12773 ! integer :: maxconts
12774 ! maxconts = nres/4
12775 ! allocate(gacontp_hb1(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
12776 ! allocate(gacontp_hb2(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
12777 ! allocate(gacontp_hb3(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
12778 ! allocate(gacontm_hb1(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
12779 ! allocate(gacontm_hb2(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
12780 ! allocate(gacontm_hb3(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
12781 ! allocate(gacont_hbr(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
12782 ! allocate(grij_hb_cont(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
12783 ! allocate(facont_hb(maxconts,nres)) !(maxconts,maxres)
12784 ! allocate(ees0p(maxconts,nres)) !(maxconts,maxres)
12785 ! allocate(ees0m(maxconts,nres)) !(maxconts,maxres)
12786 ! allocate(d_cont(maxconts,nres)) !(maxconts,maxres)
12787 ! allocate(jcont_hb(maxconts,nres)) !(maxconts,maxres)
12789 ! allocate(a_chuj(2,2,maxconts,nres)) !(2,2,maxconts,maxres)
12790 ! allocate(a_chuj_der(2,2,3,5,maxconts,nres)) !(2,2,3,5,maxconts,maxres)
12795 !d write (iout,*) "eelecij",i,j
12799 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
12800 aaa=app(iteli,itelj)
12801 bbb=bpp(iteli,itelj)
12802 ael6i=ael6(iteli,itelj)
12803 ael3i=ael3(iteli,itelj)
12807 dx_normj=dc_norm(1,j)
12808 dy_normj=dc_norm(2,j)
12809 dz_normj=dc_norm(3,j)
12810 ! xj=c(1,j)+0.5D0*dxj-xmedi
12811 ! yj=c(2,j)+0.5D0*dyj-ymedi
12812 ! zj=c(3,j)+0.5D0*dzj-zmedi
12813 xj=c(1,j)+0.5D0*dxj
12814 yj=c(2,j)+0.5D0*dyj
12815 zj=c(3,j)+0.5D0*dzj
12816 xj=mod(xj,boxxsize)
12817 if (xj.lt.0) xj=xj+boxxsize
12818 yj=mod(yj,boxysize)
12819 if (yj.lt.0) yj=yj+boxysize
12820 zj=mod(zj,boxzsize)
12821 if (zj.lt.0) zj=zj+boxzsize
12823 dist_init=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
12830 xj=xj_safe+xshift*boxxsize
12831 yj=yj_safe+yshift*boxysize
12832 zj=zj_safe+zshift*boxzsize
12833 dist_temp=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
12834 if(dist_temp.lt.dist_init) then
12835 dist_init=dist_temp
12844 if (isubchap.eq.1) then
12855 rij=xj*xj+yj*yj+zj*zj
12859 ! For extracting the short-range part of Evdwpp
12860 sss=sscale(rij/rpp(iteli,itelj))
12861 sss_ele_cut=sscale_ele(rij)
12862 sss_ele_grad=sscagrad_ele(rij)
12863 sss_grad=sscale_grad((rij/rpp(iteli,itelj)))
12864 ! sss_ele_cut=1.0d0
12865 ! sss_ele_grad=0.0d0
12866 if (sss_ele_cut.le.0.0) go to 128
12870 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
12871 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
12872 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
12873 fac=cosa-3.0D0*cosb*cosg
12875 ! 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
12876 if (j.eq.i+2) ev1=scal_el*ev1
12881 el1=fac3*(4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg))
12884 ! 12/26/95 - for the evaluation of multi-body H-bonding interactions
12885 ees0ij=4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg)
12886 ees=ees+eesij*sss_ele_cut
12887 evdw1=evdw1+evdwij*(1.0d0-sss)*sss_ele_cut
12888 !d write(iout,'(2(2i3,2x),7(1pd12.4)/2(3(1pd12.4),5x)/)')
12889 !d & iteli,i,itelj,j,aaa,bbb,ael6i,ael3i,
12890 !d & 1.0D0/dsqrt(rrmij),evdwij,eesij,
12891 !d & xmedi,ymedi,zmedi,xj,yj,zj
12893 if (energy_dec) then
12894 write (iout,'(a6,2i5,0pf7.3,f7.3)') 'evdw1',i,j,evdwij,sss
12895 write (iout,'(a6,2i5,0pf7.3)') 'ees',i,j,eesij
12899 ! Calculate contributions to the Cartesian gradient.
12902 facvdw=-6*rrmij*(ev1+evdwij)*(1.0d0-sss)*sss_ele_cut
12903 facel=-3*rrmij*(el1+eesij)*sss_ele_cut
12909 ! Radial derivatives. First process both termini of the fragment (i,j)
12911 ggg(1)=facel*xj+sss_ele_grad*rmij*eesij*xj
12912 ggg(2)=facel*yj+sss_ele_grad*rmij*eesij*yj
12913 ggg(3)=facel*zj+sss_ele_grad*rmij*eesij*zj
12915 ! ghalf=0.5D0*ggg(k)
12916 ! gelc(k,i)=gelc(k,i)+ghalf
12917 ! gelc(k,j)=gelc(k,j)+ghalf
12919 ! 9/28/08 AL Gradient compotents will be summed only at the end
12921 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
12922 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
12925 ! Loop over residues i+1 thru j-1.
12929 !grad gelc(l,k)=gelc(l,k)+ggg(l)
12932 ggg(1)=facvdw*xj+sss_ele_grad*rmij*evdwij*xj*(1.0d0-sss) &
12933 -evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*xj
12934 ggg(2)=facvdw*yj+sss_ele_grad*rmij*evdwij*yj*(1.0d0-sss) &
12935 -evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*yj
12936 ggg(3)=facvdw*zj+sss_ele_grad*rmij*evdwij*zj*(1.0d0-sss) &
12937 -evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*zj
12939 ! ghalf=0.5D0*ggg(k)
12940 ! gvdwpp(k,i)=gvdwpp(k,i)+ghalf
12941 ! gvdwpp(k,j)=gvdwpp(k,j)+ghalf
12943 ! 9/28/08 AL Gradient compotents will be summed only at the end
12945 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
12946 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
12949 ! Loop over residues i+1 thru j-1.
12953 !grad gvdwpp(l,k)=gvdwpp(l,k)+ggg(l)
12957 facvdw=(ev1+evdwij)*(1.0d0-sss)*sss_ele_cut
12958 facel=(el1+eesij)*sss_ele_cut
12960 fac=-3*rrmij*(facvdw+facvdw+facel)
12965 ! Radial derivatives. First process both termini of the fragment (i,j)
12971 ! ghalf=0.5D0*ggg(k)
12972 ! gelc(k,i)=gelc(k,i)+ghalf
12973 ! gelc(k,j)=gelc(k,j)+ghalf
12975 ! 9/28/08 AL Gradient compotents will be summed only at the end
12977 gelc_long(k,j)=gelc(k,j)+ggg(k)
12978 gelc_long(k,i)=gelc(k,i)-ggg(k)
12981 ! Loop over residues i+1 thru j-1.
12985 !grad gelc(l,k)=gelc(l,k)+ggg(l)
12988 ! 9/28/08 AL Gradient compotents will be summed only at the end
12993 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
12994 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
13000 ecosa=2.0D0*fac3*fac1+fac4
13003 ecosb=(fac3*(fac1*cosg+cosb)+cosg*fac4)
13004 ecosg=(fac3*(fac1*cosb+cosg)+cosb*fac4)
13006 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
13007 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
13009 !d print '(2i3,2(3(1pd14.5),3x))',i,j,(dcosb(k),k=1,3),
13010 !d & (dcosg(k),k=1,3)
13012 ggg(k)=(ecosb*dcosb(k)+ecosg*dcosg(k) )*sss_ele_cut
13015 ! ghalf=0.5D0*ggg(k)
13016 ! gelc(k,i)=gelc(k,i)+ghalf
13017 ! & +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
13018 ! & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
13019 ! gelc(k,j)=gelc(k,j)+ghalf
13020 ! & +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
13021 ! & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
13025 !grad gelc(l,k)=gelc(l,k)+ggg(l)
13029 gelc(k,i)=gelc(k,i) &
13030 +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
13031 + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)&
13033 gelc(k,j)=gelc(k,j) &
13034 +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
13035 + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
13037 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
13038 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
13040 IF (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
13041 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 &
13042 .or. wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
13044 ! 9/25/99 Mixed third-order local-electrostatic terms. The local-interaction
13045 ! energy of a peptide unit is assumed in the form of a second-order
13046 ! Fourier series in the angles lambda1 and lambda2 (see Nishikawa et al.
13047 ! Macromolecules, 1974, 7, 797-806 for definition). This correlation terms
13048 ! are computed for EVERY pair of non-contiguous peptide groups.
13050 if (j.lt.nres-1) then
13061 muij(kkk)=mu(k,i)*mu(l,j)
13064 !d write (iout,*) 'EELEC: i',i,' j',j
13065 !d write (iout,*) 'j',j,' j1',j1,' j2',j2
13066 !d write(iout,*) 'muij',muij
13067 ury=scalar(uy(1,i),erij)
13068 urz=scalar(uz(1,i),erij)
13069 vry=scalar(uy(1,j),erij)
13070 vrz=scalar(uz(1,j),erij)
13071 a22=scalar(uy(1,i),uy(1,j))-3*ury*vry
13072 a23=scalar(uy(1,i),uz(1,j))-3*ury*vrz
13073 a32=scalar(uz(1,i),uy(1,j))-3*urz*vry
13074 a33=scalar(uz(1,i),uz(1,j))-3*urz*vrz
13075 fac=dsqrt(-ael6i)*r3ij
13080 !d write (iout,'(4i5,4f10.5)')
13081 !d & i,itortyp(itype(i)),j,itortyp(itype(j)),a22,a23,a32,a33
13082 !d write (iout,'(6f10.5)') (muij(k),k=1,4),fac,eel_loc_ij
13083 !d write (iout,'(2(3f10.5,5x)/2(3f10.5,5x))') uy(:,i),uz(:,i),
13084 !d & uy(:,j),uz(:,j)
13085 !d write (iout,'(4f10.5)')
13086 !d & scalar(uy(1,i),uy(1,j)),scalar(uy(1,i),uz(1,j)),
13087 !d & scalar(uz(1,i),uy(1,j)),scalar(uz(1,i),uz(1,j))
13088 !d write (iout,'(4f10.5)') ury,urz,vry,vrz
13089 !d write (iout,'(9f10.5/)')
13090 !d & fac22,a22,fac23,a23,fac32,a32,fac33,a33,eel_loc_ij
13091 ! Derivatives of the elements of A in virtual-bond vectors
13092 call unormderiv(erij(1),unmat(1,1),rmij,erder(1,1))
13094 uryg(k,1)=scalar(erder(1,k),uy(1,i))
13095 uryg(k,2)=scalar(uygrad(1,k,1,i),erij(1))
13096 uryg(k,3)=scalar(uygrad(1,k,2,i),erij(1))
13097 urzg(k,1)=scalar(erder(1,k),uz(1,i))
13098 urzg(k,2)=scalar(uzgrad(1,k,1,i),erij(1))
13099 urzg(k,3)=scalar(uzgrad(1,k,2,i),erij(1))
13100 vryg(k,1)=scalar(erder(1,k),uy(1,j))
13101 vryg(k,2)=scalar(uygrad(1,k,1,j),erij(1))
13102 vryg(k,3)=scalar(uygrad(1,k,2,j),erij(1))
13103 vrzg(k,1)=scalar(erder(1,k),uz(1,j))
13104 vrzg(k,2)=scalar(uzgrad(1,k,1,j),erij(1))
13105 vrzg(k,3)=scalar(uzgrad(1,k,2,j),erij(1))
13107 ! Compute radial contributions to the gradient
13125 ! Add the contributions coming from er
13128 agg(k,1)=agg(k,1)+fac3*(uryg(k,1)*vry+vryg(k,1)*ury)
13129 agg(k,2)=agg(k,2)+fac3*(uryg(k,1)*vrz+vrzg(k,1)*ury)
13130 agg(k,3)=agg(k,3)+fac3*(urzg(k,1)*vry+vryg(k,1)*urz)
13131 agg(k,4)=agg(k,4)+fac3*(urzg(k,1)*vrz+vrzg(k,1)*urz)
13134 ! Derivatives in DC(i)
13135 !grad ghalf1=0.5d0*agg(k,1)
13136 !grad ghalf2=0.5d0*agg(k,2)
13137 !grad ghalf3=0.5d0*agg(k,3)
13138 !grad ghalf4=0.5d0*agg(k,4)
13139 aggi(k,1)=fac*(scalar(uygrad(1,k,1,i),uy(1,j)) &
13140 -3.0d0*uryg(k,2)*vry)!+ghalf1
13141 aggi(k,2)=fac*(scalar(uygrad(1,k,1,i),uz(1,j)) &
13142 -3.0d0*uryg(k,2)*vrz)!+ghalf2
13143 aggi(k,3)=fac*(scalar(uzgrad(1,k,1,i),uy(1,j)) &
13144 -3.0d0*urzg(k,2)*vry)!+ghalf3
13145 aggi(k,4)=fac*(scalar(uzgrad(1,k,1,i),uz(1,j)) &
13146 -3.0d0*urzg(k,2)*vrz)!+ghalf4
13147 ! Derivatives in DC(i+1)
13148 aggi1(k,1)=fac*(scalar(uygrad(1,k,2,i),uy(1,j)) &
13149 -3.0d0*uryg(k,3)*vry)!+agg(k,1)
13150 aggi1(k,2)=fac*(scalar(uygrad(1,k,2,i),uz(1,j)) &
13151 -3.0d0*uryg(k,3)*vrz)!+agg(k,2)
13152 aggi1(k,3)=fac*(scalar(uzgrad(1,k,2,i),uy(1,j)) &
13153 -3.0d0*urzg(k,3)*vry)!+agg(k,3)
13154 aggi1(k,4)=fac*(scalar(uzgrad(1,k,2,i),uz(1,j)) &
13155 -3.0d0*urzg(k,3)*vrz)!+agg(k,4)
13156 ! Derivatives in DC(j)
13157 aggj(k,1)=fac*(scalar(uygrad(1,k,1,j),uy(1,i)) &
13158 -3.0d0*vryg(k,2)*ury)!+ghalf1
13159 aggj(k,2)=fac*(scalar(uzgrad(1,k,1,j),uy(1,i)) &
13160 -3.0d0*vrzg(k,2)*ury)!+ghalf2
13161 aggj(k,3)=fac*(scalar(uygrad(1,k,1,j),uz(1,i)) &
13162 -3.0d0*vryg(k,2)*urz)!+ghalf3
13163 aggj(k,4)=fac*(scalar(uzgrad(1,k,1,j),uz(1,i)) &
13164 -3.0d0*vrzg(k,2)*urz)!+ghalf4
13165 ! Derivatives in DC(j+1) or DC(nres-1)
13166 aggj1(k,1)=fac*(scalar(uygrad(1,k,2,j),uy(1,i)) &
13167 -3.0d0*vryg(k,3)*ury)
13168 aggj1(k,2)=fac*(scalar(uzgrad(1,k,2,j),uy(1,i)) &
13169 -3.0d0*vrzg(k,3)*ury)
13170 aggj1(k,3)=fac*(scalar(uygrad(1,k,2,j),uz(1,i)) &
13171 -3.0d0*vryg(k,3)*urz)
13172 aggj1(k,4)=fac*(scalar(uzgrad(1,k,2,j),uz(1,i)) &
13173 -3.0d0*vrzg(k,3)*urz)
13174 !grad if (j.eq.nres-1 .and. i.lt.j-2) then
13176 !grad aggj1(k,l)=aggj1(k,l)+agg(k,l)
13189 aggi(k,l)=-aggi(k,l)
13190 aggi1(k,l)=-aggi1(k,l)
13191 aggj(k,l)=-aggj(k,l)
13192 aggj1(k,l)=-aggj1(k,l)
13195 if (j.lt.nres-1) then
13201 aggi(k,l)=-aggi(k,l)
13202 aggi1(k,l)=-aggi1(k,l)
13203 aggj(k,l)=-aggj(k,l)
13204 aggj1(k,l)=-aggj1(k,l)
13215 aggi(k,l)=-aggi(k,l)
13216 aggi1(k,l)=-aggi1(k,l)
13217 aggj(k,l)=-aggj(k,l)
13218 aggj1(k,l)=-aggj1(k,l)
13223 IF (wel_loc.gt.0.0d0) THEN
13224 ! Contribution to the local-electrostatic energy coming from the i-j pair
13225 eel_loc_ij=a22*muij(1)+a23*muij(2)+a32*muij(3) &
13227 ! write (iout,*) 'i',i,' j',j,' eel_loc_ij',eel_loc_ij
13229 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
13230 'eelloc',i,j,eel_loc_ij
13231 ! write (iout,*) a22,muij(1),a23,muij(2),a32,muij(3) !d
13233 eel_loc=eel_loc+eel_loc_ij*sss_ele_cut
13234 ! Partial derivatives in virtual-bond dihedral angles gamma
13236 gel_loc_loc(i-1)=gel_loc_loc(i-1)+ &
13237 (a22*muder(1,i)*mu(1,j)+a23*muder(1,i)*mu(2,j) &
13238 +a32*muder(2,i)*mu(1,j)+a33*muder(2,i)*mu(2,j)) &
13240 gel_loc_loc(j-1)=gel_loc_loc(j-1)+ &
13241 (a22*mu(1,i)*muder(1,j)+a23*mu(1,i)*muder(2,j) &
13242 +a32*mu(2,i)*muder(1,j)+a33*mu(2,i)*muder(2,j)) &
13248 ! Derivatives of eello in DC(i+1) thru DC(j-1) or DC(nres-2)
13250 ggg(l)=(agg(l,1)*muij(1)+ &
13251 agg(l,2)*muij(2)+agg(l,3)*muij(3)+agg(l,4)*muij(4))&
13253 +eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
13255 gel_loc_long(l,j)=gel_loc_long(l,j)+ggg(l)
13256 gel_loc_long(l,i)=gel_loc_long(l,i)-ggg(l)
13257 !grad ghalf=0.5d0*ggg(l)
13258 !grad gel_loc(l,i)=gel_loc(l,i)+ghalf
13259 !grad gel_loc(l,j)=gel_loc(l,j)+ghalf
13263 !grad gel_loc(l,k)=gel_loc(l,k)+ggg(l)
13266 ! Remaining derivatives of eello
13268 gel_loc(l,i)=gel_loc(l,i)+(aggi(l,1)*muij(1)+ &
13269 aggi(l,2)*muij(2)+aggi(l,3)*muij(3)+aggi(l,4)*muij(4))&
13272 gel_loc(l,i+1)=gel_loc(l,i+1)+(aggi1(l,1)*muij(1)+ &
13273 aggi1(l,2)*muij(2)+aggi1(l,3)*muij(3)+aggi1(l,4)*muij(4))&
13276 gel_loc(l,j)=gel_loc(l,j)+(aggj(l,1)*muij(1)+ &
13277 aggj(l,2)*muij(2)+aggj(l,3)*muij(3)+aggj(l,4)*muij(4))&
13280 gel_loc(l,j1)=gel_loc(l,j1)+(aggj1(l,1)*muij(1)+ &
13281 aggj1(l,2)*muij(2)+aggj1(l,3)*muij(3)+aggj1(l,4)*muij(4))&
13286 ! Change 12/26/95 to calculate four-body contributions to H-bonding energy
13287 ! if (j.gt.i+1 .and. num_conti.le.maxconts) then
13288 if (wcorr+wcorr4+wcorr5+wcorr6.gt.0.0d0 &
13289 .and. num_conti.le.maxconts) then
13290 ! write (iout,*) i,j," entered corr"
13292 ! Calculate the contact function. The ith column of the array JCONT will
13293 ! contain the numbers of atoms that make contacts with the atom I (of numbers
13294 ! greater than I). The arrays FACONT and GACONT will contain the values of
13295 ! the contact function and its derivative.
13296 ! r0ij=1.02D0*rpp(iteli,itelj)
13297 ! r0ij=1.11D0*rpp(iteli,itelj)
13298 r0ij=2.20D0*rpp(iteli,itelj)
13299 ! r0ij=1.55D0*rpp(iteli,itelj)
13300 call gcont(rij,r0ij,1.0D0,0.2d0*r0ij,fcont,fprimcont)
13301 !elwrite(iout,*) "num_conti",num_conti, "maxconts",maxconts
13302 if (fcont.gt.0.0D0) then
13303 num_conti=num_conti+1
13304 if (num_conti.gt.maxconts) then
13305 !elwrite(iout,*) "num_conti",num_conti, "maxconts",maxconts
13306 write (iout,*) 'WARNING - max. # of contacts exceeded;',&
13307 ' will skip next contacts for this conf.',num_conti
13309 jcont_hb(num_conti,i)=j
13310 !d write (iout,*) "i",i," j",j," num_conti",num_conti,
13311 !d & " jcont_hb",jcont_hb(num_conti,i)
13312 IF (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. &
13313 wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
13314 ! 9/30/99 (AL) - store components necessary to evaluate higher-order loc-el
13316 d_cont(num_conti,i)=rij
13317 !d write (2,'(3e15.5)') rij,r0ij+0.2d0*r0ij,rij
13318 ! --- Electrostatic-interaction matrix ---
13319 a_chuj(1,1,num_conti,i)=a22
13320 a_chuj(1,2,num_conti,i)=a23
13321 a_chuj(2,1,num_conti,i)=a32
13322 a_chuj(2,2,num_conti,i)=a33
13323 ! --- Gradient of rij
13325 grij_hb_cont(kkk,num_conti,i)=erij(kkk)
13332 a_chuj_der(k,l,m,1,num_conti,i)=agg(m,kkll)
13333 a_chuj_der(k,l,m,2,num_conti,i)=aggi(m,kkll)
13334 a_chuj_der(k,l,m,3,num_conti,i)=aggi1(m,kkll)
13335 a_chuj_der(k,l,m,4,num_conti,i)=aggj(m,kkll)
13336 a_chuj_der(k,l,m,5,num_conti,i)=aggj1(m,kkll)
13341 IF (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) THEN
13342 ! Calculate contact energies
13344 wij=cosa-3.0D0*cosb*cosg
13347 ! fac3=dsqrt(-ael6i)/r0ij**3
13348 fac3=dsqrt(-ael6i)*r3ij
13349 ! ees0pij=dsqrt(4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1)
13350 ees0tmp=4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1
13351 if (ees0tmp.gt.0) then
13352 ees0pij=dsqrt(ees0tmp)
13356 ! ees0mij=dsqrt(4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2)
13357 ees0tmp=4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2
13358 if (ees0tmp.gt.0) then
13359 ees0mij=dsqrt(ees0tmp)
13364 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij) &
13367 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij) &
13370 ! Diagnostics. Comment out or remove after debugging!
13371 ! ees0p(num_conti,i)=0.5D0*fac3*ees0pij
13372 ! ees0m(num_conti,i)=0.5D0*fac3*ees0mij
13373 ! ees0m(num_conti,i)=0.0D0
13375 ! write (iout,*) 'i=',i,' j=',j,' rij=',rij,' r0ij=',r0ij,
13376 ! & ' ees0ij=',ees0p(num_conti,i),ees0m(num_conti,i),' fcont=',fcont
13377 ! Angular derivatives of the contact function
13378 ees0pij1=fac3/ees0pij
13379 ees0mij1=fac3/ees0mij
13380 fac3p=-3.0D0*fac3*rrmij
13381 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
13382 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
13384 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
13385 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
13386 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
13387 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
13388 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
13389 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
13390 ecosap=ecosa1+ecosa2
13391 ecosbp=ecosb1+ecosb2
13392 ecosgp=ecosg1+ecosg2
13393 ecosam=ecosa1-ecosa2
13394 ecosbm=ecosb1-ecosb2
13395 ecosgm=ecosg1-ecosg2
13404 facont_hb(num_conti,i)=fcont
13405 fprimcont=fprimcont/rij
13406 !d facont_hb(num_conti,i)=1.0D0
13407 ! Following line is for diagnostics.
13410 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
13411 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
13414 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
13415 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
13417 ! gggp(1)=gggp(1)+ees0pijp*xj
13418 ! gggp(2)=gggp(2)+ees0pijp*yj
13419 ! gggp(3)=gggp(3)+ees0pijp*zj
13420 ! gggm(1)=gggm(1)+ees0mijp*xj
13421 ! gggm(2)=gggm(2)+ees0mijp*yj
13422 ! gggm(3)=gggm(3)+ees0mijp*zj
13423 gggp(1)=gggp(1)+ees0pijp*xj &
13424 +ees0p(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
13425 gggp(2)=gggp(2)+ees0pijp*yj &
13426 +ees0p(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
13427 gggp(3)=gggp(3)+ees0pijp*zj &
13428 +ees0p(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
13430 gggm(1)=gggm(1)+ees0mijp*xj &
13431 +ees0m(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
13433 gggm(2)=gggm(2)+ees0mijp*yj &
13434 +ees0m(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
13436 gggm(3)=gggm(3)+ees0mijp*zj &
13437 +ees0m(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
13439 ! Derivatives due to the contact function
13440 gacont_hbr(1,num_conti,i)=fprimcont*xj
13441 gacont_hbr(2,num_conti,i)=fprimcont*yj
13442 gacont_hbr(3,num_conti,i)=fprimcont*zj
13445 ! 10/24/08 cgrad and ! comments indicate the parts of the code removed
13446 ! following the change of gradient-summation algorithm.
13448 !grad ghalfp=0.5D0*gggp(k)
13449 !grad ghalfm=0.5D0*gggm(k)
13450 ! gacontp_hb1(k,num_conti,i)= & !ghalfp
13451 ! +(ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
13452 ! + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
13453 ! gacontp_hb2(k,num_conti,i)= & !ghalfp
13454 ! +(ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
13455 ! + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
13456 ! gacontp_hb3(k,num_conti,i)=gggp(k)
13457 ! gacontm_hb1(k,num_conti,i)= &!ghalfm
13458 ! +(ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
13459 ! + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
13460 ! gacontm_hb2(k,num_conti,i)= & !ghalfm
13461 ! +(ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
13462 ! + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
13463 ! gacontm_hb3(k,num_conti,i)=gggm(k)
13464 gacontp_hb1(k,num_conti,i)= & !ghalfp+
13465 (ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
13466 + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
13469 gacontp_hb2(k,num_conti,i)= & !ghalfp+
13470 (ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
13471 + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
13474 gacontp_hb3(k,num_conti,i)=gggp(k) &
13477 gacontm_hb1(k,num_conti,i)= & !ghalfm+
13478 (ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
13479 + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
13482 gacontm_hb2(k,num_conti,i)= & !ghalfm+
13483 (ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
13484 + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1) &
13487 gacontm_hb3(k,num_conti,i)=gggm(k) &
13492 endif ! num_conti.le.maxconts
13495 if (wturn3.gt.0.0d0 .or. wturn4.gt.0.0d0) then
13498 ghalf=0.5d0*agg(l,k)
13499 aggi(l,k)=aggi(l,k)+ghalf
13500 aggi1(l,k)=aggi1(l,k)+agg(l,k)
13501 aggj(l,k)=aggj(l,k)+ghalf
13504 if (j.eq.nres-1 .and. i.lt.j-2) then
13507 aggj1(l,k)=aggj1(l,k)+agg(l,k)
13513 ! t_eelecij=t_eelecij+MPI_Wtime()-time00
13515 end subroutine eelecij_scale
13516 !-----------------------------------------------------------------------------
13517 subroutine evdwpp_short(evdw1)
13521 ! implicit real*8 (a-h,o-z)
13522 ! include 'DIMENSIONS'
13523 ! include 'COMMON.CONTROL'
13524 ! include 'COMMON.IOUNITS'
13525 ! include 'COMMON.GEO'
13526 ! include 'COMMON.VAR'
13527 ! include 'COMMON.LOCAL'
13528 ! include 'COMMON.CHAIN'
13529 ! include 'COMMON.DERIV'
13530 ! include 'COMMON.INTERACT'
13531 ! include 'COMMON.CONTACTS'
13532 ! include 'COMMON.TORSION'
13533 ! include 'COMMON.VECTORS'
13534 ! include 'COMMON.FFIELD'
13535 real(kind=8),dimension(3) :: ggg
13536 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
13538 real(kind=8) :: scal_el=1.0d0
13540 real(kind=8) :: scal_el=0.5d0
13542 !el local variables
13543 integer :: i,j,k,iteli,itelj,num_conti,isubchap
13544 real(kind=8) :: dxi,dyi,dzi,dxj,dyj,dzj,aaa,bbb
13545 real(kind=8) :: xj,yj,zj,rij,rrmij,sss,r3ij,r6ij,evdw1,&
13546 dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
13547 dx_normj,dy_normj,dz_normj,rmij,ev1,ev2,evdwij,facvdw
13548 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
13549 dist_temp, dist_init,sss_grad
13550 integer xshift,yshift,zshift
13554 ! write (iout,*) "iatel_s_vdw",iatel_s_vdw,
13555 ! & " iatel_e_vdw",iatel_e_vdw
13557 do i=iatel_s_vdw,iatel_e_vdw
13558 if (itype(i).eq.ntyp1.or. itype(i+1).eq.ntyp1) cycle
13562 dx_normi=dc_norm(1,i)
13563 dy_normi=dc_norm(2,i)
13564 dz_normi=dc_norm(3,i)
13565 xmedi=c(1,i)+0.5d0*dxi
13566 ymedi=c(2,i)+0.5d0*dyi
13567 zmedi=c(3,i)+0.5d0*dzi
13568 xmedi=dmod(xmedi,boxxsize)
13569 if (xmedi.lt.0) xmedi=xmedi+boxxsize
13570 ymedi=dmod(ymedi,boxysize)
13571 if (ymedi.lt.0) ymedi=ymedi+boxysize
13572 zmedi=dmod(zmedi,boxzsize)
13573 if (zmedi.lt.0) zmedi=zmedi+boxzsize
13575 ! write (iout,*) 'i',i,' ielstart',ielstart_vdw(i),
13576 ! & ' ielend',ielend_vdw(i)
13578 do j=ielstart_vdw(i),ielend_vdw(i)
13579 if (itype(j).eq.ntyp1 .or. itype(j+1).eq.ntyp1) cycle
13583 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
13584 aaa=app(iteli,itelj)
13585 bbb=bpp(iteli,itelj)
13589 dx_normj=dc_norm(1,j)
13590 dy_normj=dc_norm(2,j)
13591 dz_normj=dc_norm(3,j)
13592 ! xj=c(1,j)+0.5D0*dxj-xmedi
13593 ! yj=c(2,j)+0.5D0*dyj-ymedi
13594 ! zj=c(3,j)+0.5D0*dzj-zmedi
13595 xj=c(1,j)+0.5D0*dxj
13596 yj=c(2,j)+0.5D0*dyj
13597 zj=c(3,j)+0.5D0*dzj
13598 xj=mod(xj,boxxsize)
13599 if (xj.lt.0) xj=xj+boxxsize
13600 yj=mod(yj,boxysize)
13601 if (yj.lt.0) yj=yj+boxysize
13602 zj=mod(zj,boxzsize)
13603 if (zj.lt.0) zj=zj+boxzsize
13605 dist_init=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
13612 xj=xj_safe+xshift*boxxsize
13613 yj=yj_safe+yshift*boxysize
13614 zj=zj_safe+zshift*boxzsize
13615 dist_temp=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
13616 if(dist_temp.lt.dist_init) then
13617 dist_init=dist_temp
13626 if (isubchap.eq.1) then
13637 rij=xj*xj+yj*yj+zj*zj
13640 sss=sscale(rij/rpp(iteli,itelj))
13641 sss_ele_cut=sscale_ele(rij)
13642 sss_ele_grad=sscagrad_ele(rij)
13643 sss_grad=sscale_grad((rij/rpp(iteli,itelj)))
13644 if (sss_ele_cut.le.0.0) cycle
13645 if (sss.gt.0.0d0) then
13650 ! 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
13651 if (j.eq.i+2) ev1=scal_el*ev1
13654 if (energy_dec) then
13655 write (iout,'(a6,2i5,0pf7.3,f7.3)') 'evdw1',i,j,evdwij,sss
13657 evdw1=evdw1+evdwij*sss*sss_ele_cut
13659 ! Calculate contributions to the Cartesian gradient.
13661 facvdw=-6*rrmij*(ev1+evdwij)*sss*sss_ele_cut
13665 ggg(1)=facvdw*xj+sss_ele_grad*rmij*evdwij*xj*sss &
13666 +evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*xj
13667 ggg(2)=facvdw*yj+sss_ele_grad*rmij*evdwij*yj*sss &
13668 +evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*yj
13669 ggg(3)=facvdw*zj+sss_ele_grad*rmij*evdwij*zj*sss &
13670 +evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*zj
13673 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
13674 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
13680 end subroutine evdwpp_short
13681 !-----------------------------------------------------------------------------
13682 subroutine escp_long(evdw2,evdw2_14)
13684 ! This subroutine calculates the excluded-volume interaction energy between
13685 ! peptide-group centers and side chains and its gradient in virtual-bond and
13686 ! side-chain vectors.
13688 ! implicit real*8 (a-h,o-z)
13689 ! include 'DIMENSIONS'
13690 ! include 'COMMON.GEO'
13691 ! include 'COMMON.VAR'
13692 ! include 'COMMON.LOCAL'
13693 ! include 'COMMON.CHAIN'
13694 ! include 'COMMON.DERIV'
13695 ! include 'COMMON.INTERACT'
13696 ! include 'COMMON.FFIELD'
13697 ! include 'COMMON.IOUNITS'
13698 ! include 'COMMON.CONTROL'
13699 real(kind=8),dimension(3) :: ggg
13700 !el local variables
13701 integer :: i,iint,j,k,iteli,itypj,subchap
13702 real(kind=8) :: xi,yi,zi,xj,yj,zj,rrij,sss,fac,e1,e2,sss_grad,rij
13703 real(kind=8) :: evdw2,evdw2_14,evdwij
13704 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
13705 dist_temp, dist_init
13709 !d print '(a)','Enter ESCP'
13710 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
13711 do i=iatscp_s,iatscp_e
13712 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1) cycle
13714 xi=0.5D0*(c(1,i)+c(1,i+1))
13715 yi=0.5D0*(c(2,i)+c(2,i+1))
13716 zi=0.5D0*(c(3,i)+c(3,i+1))
13717 xi=mod(xi,boxxsize)
13718 if (xi.lt.0) xi=xi+boxxsize
13719 yi=mod(yi,boxysize)
13720 if (yi.lt.0) yi=yi+boxysize
13721 zi=mod(zi,boxzsize)
13722 if (zi.lt.0) zi=zi+boxzsize
13724 do iint=1,nscp_gr(i)
13726 do j=iscpstart(i,iint),iscpend(i,iint)
13728 if (itypj.eq.ntyp1) cycle
13729 ! Uncomment following three lines for SC-p interactions
13730 ! xj=c(1,nres+j)-xi
13731 ! yj=c(2,nres+j)-yi
13732 ! zj=c(3,nres+j)-zi
13733 ! Uncomment following three lines for Ca-p interactions
13737 xj=mod(xj,boxxsize)
13738 if (xj.lt.0) xj=xj+boxxsize
13739 yj=mod(yj,boxysize)
13740 if (yj.lt.0) yj=yj+boxysize
13741 zj=mod(zj,boxzsize)
13742 if (zj.lt.0) zj=zj+boxzsize
13743 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
13751 xj=xj_safe+xshift*boxxsize
13752 yj=yj_safe+yshift*boxysize
13753 zj=zj_safe+zshift*boxzsize
13754 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
13755 if(dist_temp.lt.dist_init) then
13756 dist_init=dist_temp
13765 if (subchap.eq.1) then
13774 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
13776 rij=dsqrt(1.0d0/rrij)
13777 sss_ele_cut=sscale_ele(rij)
13778 sss_ele_grad=sscagrad_ele(rij)
13779 ! print *,sss_ele_cut,sss_ele_grad,&
13780 ! (rij),r_cut_ele,rlamb_ele
13781 if (sss_ele_cut.le.0.0) cycle
13782 sss=sscale((rij/rscp(itypj,iteli)))
13783 sss_grad=sscale_grad(rij/rscp(itypj,iteli))
13784 if (sss.lt.1.0d0) then
13787 e1=fac*fac*aad(itypj,iteli)
13788 e2=fac*bad(itypj,iteli)
13789 if (iabs(j-i) .le. 2) then
13792 evdw2_14=evdw2_14+(e1+e2)*(1.0d0-sss)*sss_ele_cut
13795 evdw2=evdw2+evdwij*(1.0d0-sss)*sss_ele_cut
13796 if (energy_dec) write (iout,'(a6,2i5,2(0pf7.3))') &
13797 'evdw2',i,j,sss,evdwij
13799 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
13801 fac=-(evdwij+e1)*rrij*(1.0d0-sss)*sss_ele_cut
13802 fac=fac+evdwij*sss_ele_grad/rij/expon*(1.0d0-sss)&
13803 -evdwij*sss_ele_cut/rij/expon*sss_grad/rscp(itypj,iteli)
13807 ! Uncomment following three lines for SC-p interactions
13809 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
13811 ! Uncomment following line for SC-p interactions
13812 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
13814 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
13815 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
13824 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
13825 gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
13826 gradx_scp(j,i)=expon*gradx_scp(j,i)
13829 !******************************************************************************
13833 ! To save time the factor EXPON has been extracted from ALL components
13834 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
13837 !******************************************************************************
13839 end subroutine escp_long
13840 !-----------------------------------------------------------------------------
13841 subroutine escp_short(evdw2,evdw2_14)
13843 ! This subroutine calculates the excluded-volume interaction energy between
13844 ! peptide-group centers and side chains and its gradient in virtual-bond and
13845 ! side-chain vectors.
13847 ! implicit real*8 (a-h,o-z)
13848 ! include 'DIMENSIONS'
13849 ! include 'COMMON.GEO'
13850 ! include 'COMMON.VAR'
13851 ! include 'COMMON.LOCAL'
13852 ! include 'COMMON.CHAIN'
13853 ! include 'COMMON.DERIV'
13854 ! include 'COMMON.INTERACT'
13855 ! include 'COMMON.FFIELD'
13856 ! include 'COMMON.IOUNITS'
13857 ! include 'COMMON.CONTROL'
13858 real(kind=8),dimension(3) :: ggg
13859 !el local variables
13860 integer :: i,iint,j,k,iteli,itypj,subchap
13861 real(kind=8) :: xi,yi,zi,xj,yj,zj,rrij,sss,fac,e1,e2,sss_grad,rij
13862 real(kind=8) :: evdw2,evdw2_14,evdwij
13863 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
13864 dist_temp, dist_init
13868 !d print '(a)','Enter ESCP'
13869 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
13870 do i=iatscp_s,iatscp_e
13871 if (itype(i).eq.ntyp1 .or. itype(i+1).eq.ntyp1) cycle
13873 xi=0.5D0*(c(1,i)+c(1,i+1))
13874 yi=0.5D0*(c(2,i)+c(2,i+1))
13875 zi=0.5D0*(c(3,i)+c(3,i+1))
13876 xi=mod(xi,boxxsize)
13877 if (xi.lt.0) xi=xi+boxxsize
13878 yi=mod(yi,boxysize)
13879 if (yi.lt.0) yi=yi+boxysize
13880 zi=mod(zi,boxzsize)
13881 if (zi.lt.0) zi=zi+boxzsize
13883 do iint=1,nscp_gr(i)
13885 do j=iscpstart(i,iint),iscpend(i,iint)
13887 if (itypj.eq.ntyp1) cycle
13888 ! Uncomment following three lines for SC-p interactions
13889 ! xj=c(1,nres+j)-xi
13890 ! yj=c(2,nres+j)-yi
13891 ! zj=c(3,nres+j)-zi
13892 ! Uncomment following three lines for Ca-p interactions
13899 xj=mod(xj,boxxsize)
13900 if (xj.lt.0) xj=xj+boxxsize
13901 yj=mod(yj,boxysize)
13902 if (yj.lt.0) yj=yj+boxysize
13903 zj=mod(zj,boxzsize)
13904 if (zj.lt.0) zj=zj+boxzsize
13905 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
13913 xj=xj_safe+xshift*boxxsize
13914 yj=yj_safe+yshift*boxysize
13915 zj=zj_safe+zshift*boxzsize
13916 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
13917 if(dist_temp.lt.dist_init) then
13918 dist_init=dist_temp
13927 if (subchap.eq.1) then
13937 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
13938 rij=dsqrt(1.0d0/rrij)
13939 sss_ele_cut=sscale_ele(rij)
13940 sss_ele_grad=sscagrad_ele(rij)
13941 ! print *,sss_ele_cut,sss_ele_grad,&
13942 ! (rij),r_cut_ele,rlamb_ele
13943 if (sss_ele_cut.le.0.0) cycle
13944 sss=sscale(rij/rscp(itypj,iteli))
13945 sss_grad=sscale_grad(rij/rscp(itypj,iteli))
13946 if (sss.gt.0.0d0) then
13949 e1=fac*fac*aad(itypj,iteli)
13950 e2=fac*bad(itypj,iteli)
13951 if (iabs(j-i) .le. 2) then
13954 evdw2_14=evdw2_14+(e1+e2)*sss*sss_ele_cut
13957 evdw2=evdw2+evdwij*sss*sss_ele_cut
13958 if (energy_dec) write (iout,'(a6,2i5,2(0pf7.3))') &
13959 'evdw2',i,j,sss,evdwij
13961 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
13963 fac=-(evdwij+e1)*rrij*sss*sss_ele_cut
13964 fac=fac+evdwij*sss_ele_grad/rij/expon*sss &
13965 +evdwij*sss_ele_cut/rij/expon*sss_grad/rscp(itypj,iteli)
13970 ! Uncomment following three lines for SC-p interactions
13972 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
13974 ! Uncomment following line for SC-p interactions
13975 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
13977 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
13978 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
13987 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
13988 gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
13989 gradx_scp(j,i)=expon*gradx_scp(j,i)
13992 !******************************************************************************
13996 ! To save time the factor EXPON has been extracted from ALL components
13997 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
14000 !******************************************************************************
14002 end subroutine escp_short
14003 !-----------------------------------------------------------------------------
14004 ! energy_p_new-sep_barrier.F
14005 !-----------------------------------------------------------------------------
14006 subroutine sc_grad_scale(scalfac)
14007 ! implicit real*8 (a-h,o-z)
14009 ! include 'DIMENSIONS'
14010 ! include 'COMMON.CHAIN'
14011 ! include 'COMMON.DERIV'
14012 ! include 'COMMON.CALC'
14013 ! include 'COMMON.IOUNITS'
14014 real(kind=8),dimension(3) :: dcosom1,dcosom2
14015 real(kind=8) :: scalfac
14016 !el local variables
14017 ! integer :: i,j,k,l
14019 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
14020 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
14021 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12 &
14022 -2.0D0*alf12*eps3der+sigder*sigsq_om12
14026 ! eom12=evdwij*eps1_om12
14028 ! write (iout,*) "eps2der",eps2der," eps3der",eps3der,
14029 ! & " sigder",sigder
14030 ! write (iout,*) "eps1_om12",eps1_om12," eps2rt_om12",eps2rt_om12
14031 ! write (iout,*) "eom1",eom1," eom2",eom2," eom12",eom12
14033 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
14034 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
14037 gg(k)=(gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k))*scalfac&
14040 ! write (iout,*) "gg",(gg(k),k=1,3)
14042 gvdwx(k,i)=gvdwx(k,i)-gg(k) &
14043 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
14044 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv*scalfac&
14046 gvdwx(k,j)=gvdwx(k,j)+gg(k) &
14047 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
14048 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv*scalfac&
14050 ! write (iout,*)(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))
14051 ! & +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
14052 ! write (iout,*)(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))
14053 ! & +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
14056 ! Calculate the components of the gradient in DC and X
14059 gvdwc(l,i)=gvdwc(l,i)-gg(l)
14060 gvdwc(l,j)=gvdwc(l,j)+gg(l)
14063 end subroutine sc_grad_scale
14064 !-----------------------------------------------------------------------------
14065 ! energy_split-sep.F
14066 !-----------------------------------------------------------------------------
14067 subroutine etotal_long(energia)
14069 ! Compute the long-range slow-varying contributions to the energy
14071 ! implicit real*8 (a-h,o-z)
14072 ! include 'DIMENSIONS'
14073 use MD_data, only: totT,usampl,eq_time
14077 !MS$ATTRIBUTES C :: proc_proc
14082 real(kind=8),dimension(n_ene) :: weights_!,time_Bcast,time_Bcastw
14084 ! include 'COMMON.SETUP'
14085 ! include 'COMMON.IOUNITS'
14086 ! include 'COMMON.FFIELD'
14087 ! include 'COMMON.DERIV'
14088 ! include 'COMMON.INTERACT'
14089 ! include 'COMMON.SBRIDGE'
14090 ! include 'COMMON.CHAIN'
14091 ! include 'COMMON.VAR'
14092 ! include 'COMMON.LOCAL'
14093 ! include 'COMMON.MD'
14094 real(kind=8),dimension(0:n_ene) :: energia
14095 !el local variables
14096 integer :: i,n_corr,n_corr1,ierror,ierr
14097 real(kind=8) :: evdw2,evdw2_14,ehpb,etors,edihcnstr,etors_d,esccor,&
14098 evdw,ees,evdw1,eel_loc,eello_turn3,eello_turn4,&
14099 ecorr,ecorr5,ecorr6,eturn6,time00
14100 ! write(iout,'(a,i2)')'Calling etotal_long ipot=',ipot
14101 !elwrite(iout,*)"in etotal long"
14103 if (modecalc.eq.12.or.modecalc.eq.14) then
14105 ! if (fg_rank.eq.0) call int_from_cart1(.false.)
14107 call int_from_cart1(.false.)
14110 !elwrite(iout,*)"in etotal long"
14113 ! write(iout,*) "ETOTAL_LONG Processor",fg_rank,
14114 ! & " absolute rank",myrank," nfgtasks",nfgtasks
14116 if (nfgtasks.gt.1) then
14118 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
14119 if (fg_rank.eq.0) then
14120 call MPI_Bcast(3,1,MPI_INTEGER,king,FG_COMM,IERROR)
14121 ! write (iout,*) "Processor",myrank," BROADCAST iorder"
14123 ! FG master sets up the WEIGHTS_ array which will be broadcast to the
14124 ! FG slaves as WEIGHTS array.
14131 weights_(7)=wel_loc
14134 weights_(10)=wturn6
14136 weights_(12)=wscloc
14138 weights_(14)=wtor_d
14139 weights_(15)=wstrain
14140 weights_(16)=wvdwpp
14142 weights_(18)=scal14
14143 weights_(21)=wsccor
14144 ! FG Master broadcasts the WEIGHTS_ array
14145 call MPI_Bcast(weights_(1),n_ene,&
14146 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
14148 ! FG slaves receive the WEIGHTS array
14149 call MPI_Bcast(weights(1),n_ene,&
14150 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
14165 wstrain=weights(15)
14171 call MPI_Bcast(dc(1,1),6*nres,MPI_DOUBLE_PRECISION,&
14173 time_Bcast=time_Bcast+MPI_Wtime()-time00
14174 time_Bcastw=time_Bcastw+MPI_Wtime()-time00
14175 ! call chainbuild_cart
14176 ! call int_from_cart1(.false.)
14178 ! write (iout,*) 'Processor',myrank,
14179 ! & ' calling etotal_short ipot=',ipot
14181 ! print *,'Processor',myrank,' nnt=',nnt,' nct=',nct
14183 !d print *,'nnt=',nnt,' nct=',nct
14185 !elwrite(iout,*)"in etotal long"
14186 ! Compute the side-chain and electrostatic interaction energy
14188 goto (101,102,103,104,105,106) ipot
14189 ! Lennard-Jones potential.
14190 101 call elj_long(evdw)
14191 !d print '(a)','Exit ELJ'
14193 ! Lennard-Jones-Kihara potential (shifted).
14194 102 call eljk_long(evdw)
14196 ! Berne-Pechukas potential (dilated LJ, angular dependence).
14197 103 call ebp_long(evdw)
14199 ! Gay-Berne potential (shifted LJ, angular dependence).
14200 104 call egb_long(evdw)
14202 ! Gay-Berne-Vorobjev potential (shifted LJ, angular dependence).
14203 105 call egbv_long(evdw)
14205 ! Soft-sphere potential
14206 106 call e_softsphere(evdw)
14208 ! Calculate electrostatic (H-bonding) energy of the main chain.
14212 if (ipot.lt.6) then
14214 if (welec.gt.0d0.or.wvdwpp.gt.0d0.or.wel_loc.gt.0d0.or. &
14215 wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0 &
14216 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
14217 .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
14219 if (welec.gt.0d0.or.wel_loc.gt.0d0.or. &
14220 wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0 &
14221 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
14222 .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
14224 call eelec_scale(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
14233 ! write (iout,*) "Soft-spheer ELEC potential"
14234 call eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,&
14238 ! Calculate excluded-volume interaction energy between peptide groups
14241 if (ipot.lt.6) then
14242 if(wscp.gt.0d0) then
14243 call escp_long(evdw2,evdw2_14)
14249 call escp_soft_sphere(evdw2,evdw2_14)
14252 ! 12/1/95 Multi-body terms
14256 if ((wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 &
14257 .or. wturn6.gt.0.0d0) .and. ipot.lt.6) then
14258 call multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
14259 ! write (2,*) 'n_corr=',n_corr,' n_corr1=',n_corr1,
14260 ! &" ecorr",ecorr," ecorr5",ecorr5," ecorr6",ecorr6," eturn6",eturn6
14267 if ((wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) .and. ipot.lt.6) then
14268 call multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
14271 ! If performing constraint dynamics, call the constraint energy
14272 ! after the equilibration time
14273 if(usampl.and.totT.gt.eq_time) then
14288 energia(2)=evdw2-evdw2_14
14289 energia(18)=evdw2_14
14298 energia(3)=ees+evdw1
14305 energia(8)=eello_turn3
14306 energia(9)=eello_turn4
14308 energia(20)=Uconst+Uconst_back
14309 call sum_energy(energia,.true.)
14310 ! write (iout,*) "Exit ETOTAL_LONG"
14313 end subroutine etotal_long
14314 !-----------------------------------------------------------------------------
14315 subroutine etotal_short(energia)
14317 ! Compute the short-range fast-varying contributions to the energy
14319 ! implicit real*8 (a-h,o-z)
14320 ! include 'DIMENSIONS'
14324 !MS$ATTRIBUTES C :: proc_proc
14329 integer :: ierror,ierr
14330 real(kind=8),dimension(n_ene) :: weights_
14331 real(kind=8) :: time00
14333 ! include 'COMMON.SETUP'
14334 ! include 'COMMON.IOUNITS'
14335 ! include 'COMMON.FFIELD'
14336 ! include 'COMMON.DERIV'
14337 ! include 'COMMON.INTERACT'
14338 ! include 'COMMON.SBRIDGE'
14339 ! include 'COMMON.CHAIN'
14340 ! include 'COMMON.VAR'
14341 ! include 'COMMON.LOCAL'
14342 real(kind=8),dimension(0:n_ene) :: energia
14343 !el local variables
14345 real(kind=8) :: evdw,evdw1,evdw2,evdw2_14,esccor,etors_d,etors
14346 real(kind=8) :: ehpb,escloc,estr,ebe,edihcnstr
14349 ! write(iout,'(a,i2)')'Calling etotal_short ipot=',ipot
14351 if (modecalc.eq.12.or.modecalc.eq.14) then
14353 if (fg_rank.eq.0) call int_from_cart1(.false.)
14355 call int_from_cart1(.false.)
14359 ! write(iout,*) "ETOTAL_SHORT Processor",fg_rank,
14360 ! & " absolute rank",myrank," nfgtasks",nfgtasks
14362 if (nfgtasks.gt.1) then
14364 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
14365 if (fg_rank.eq.0) then
14366 call MPI_Bcast(2,1,MPI_INTEGER,king,FG_COMM,IERROR)
14367 ! write (iout,*) "Processor",myrank," BROADCAST iorder"
14369 ! FG master sets up the WEIGHTS_ array which will be broadcast to the
14370 ! FG slaves as WEIGHTS array.
14377 weights_(7)=wel_loc
14380 weights_(10)=wturn6
14382 weights_(12)=wscloc
14384 weights_(14)=wtor_d
14385 weights_(15)=wstrain
14386 weights_(16)=wvdwpp
14388 weights_(18)=scal14
14389 weights_(21)=wsccor
14390 ! FG Master broadcasts the WEIGHTS_ array
14391 call MPI_Bcast(weights_(1),n_ene,&
14392 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
14394 ! FG slaves receive the WEIGHTS array
14395 call MPI_Bcast(weights(1),n_ene,&
14396 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
14411 wstrain=weights(15)
14417 ! write (iout,*),"Processor",myrank," BROADCAST weights"
14418 call MPI_Bcast(c(1,1),nres6,MPI_DOUBLE_PRECISION,&
14420 ! write (iout,*) "Processor",myrank," BROADCAST c"
14421 call MPI_Bcast(dc(1,1),nres6,MPI_DOUBLE_PRECISION,&
14423 ! write (iout,*) "Processor",myrank," BROADCAST dc"
14424 call MPI_Bcast(dc_norm(1,1),nres6,MPI_DOUBLE_PRECISION,&
14426 ! write (iout,*) "Processor",myrank," BROADCAST dc_norm"
14427 call MPI_Bcast(theta(1),nres,MPI_DOUBLE_PRECISION,&
14429 ! write (iout,*) "Processor",myrank," BROADCAST theta"
14430 call MPI_Bcast(phi(1),nres,MPI_DOUBLE_PRECISION,&
14432 ! write (iout,*) "Processor",myrank," BROADCAST phi"
14433 call MPI_Bcast(alph(1),nres,MPI_DOUBLE_PRECISION,&
14435 ! write (iout,*) "Processor",myrank," BROADCAST alph"
14436 call MPI_Bcast(omeg(1),nres,MPI_DOUBLE_PRECISION,&
14438 ! write (iout,*) "Processor",myrank," BROADCAST omeg"
14439 call MPI_Bcast(vbld(1),2*nres,MPI_DOUBLE_PRECISION,&
14441 ! write (iout,*) "Processor",myrank," BROADCAST vbld"
14442 call MPI_Bcast(vbld_inv(1),2*nres,MPI_DOUBLE_PRECISION,&
14444 time_Bcast=time_Bcast+MPI_Wtime()-time00
14445 ! write (iout,*) "Processor",myrank," BROADCAST vbld_inv"
14447 ! write (iout,*) 'Processor',myrank,
14448 ! & ' calling etotal_short ipot=',ipot
14450 ! print *,'Processor',myrank,' nnt=',nnt,' nct=',nct
14452 ! call int_from_cart1(.false.)
14454 ! Compute the side-chain and electrostatic interaction energy
14456 goto (101,102,103,104,105,106) ipot
14457 ! Lennard-Jones potential.
14458 101 call elj_short(evdw)
14459 !d print '(a)','Exit ELJ'
14461 ! Lennard-Jones-Kihara potential (shifted).
14462 102 call eljk_short(evdw)
14464 ! Berne-Pechukas potential (dilated LJ, angular dependence).
14465 103 call ebp_short(evdw)
14467 ! Gay-Berne potential (shifted LJ, angular dependence).
14468 104 call egb_short(evdw)
14470 ! Gay-Berne-Vorobjev potential (shifted LJ, angular dependence).
14471 105 call egbv_short(evdw)
14473 ! Soft-sphere potential - already dealt with in the long-range part
14475 ! 106 call e_softsphere_short(evdw)
14477 ! Calculate electrostatic (H-bonding) energy of the main chain.
14481 ! Calculate the short-range part of Evdwpp
14483 call evdwpp_short(evdw1)
14485 ! Calculate the short-range part of ESCp
14487 if (ipot.lt.6) then
14488 call escp_short(evdw2,evdw2_14)
14491 ! Calculate the bond-stretching energy
14495 ! Calculate the disulfide-bridge and other energy and the contributions
14496 ! from other distance constraints.
14499 ! Calculate the virtual-bond-angle energy.
14503 ! Calculate the SC local energy.
14508 ! Calculate the virtual-bond torsional energy.
14510 call etor(etors,edihcnstr)
14512 ! 6/23/01 Calculate double-torsional energy
14514 call etor_d(etors_d)
14516 ! 21/5/07 Calculate local sicdechain correlation energy
14518 if (wsccor.gt.0.0d0) then
14519 call eback_sc_corr(esccor)
14524 ! Put energy components into an array
14531 energia(2)=evdw2-evdw2_14
14532 energia(18)=evdw2_14
14545 energia(14)=etors_d
14548 energia(19)=edihcnstr
14550 ! write (iout,*) "ETOTAL_SHORT before SUM_ENERGY"
14552 call sum_energy(energia,.true.)
14553 ! write (iout,*) "Exit ETOTAL_SHORT"
14556 end subroutine etotal_short
14557 !-----------------------------------------------------------------------------
14559 !-----------------------------------------------------------------------------
14560 real(kind=8) function gnmr1(y,ymin,ymax)
14562 real(kind=8) :: y,ymin,ymax
14563 real(kind=8) :: wykl=4.0d0
14564 if (y.lt.ymin) then
14565 gnmr1=(ymin-y)**wykl/wykl
14566 else if (y.gt.ymax) then
14567 gnmr1=(y-ymax)**wykl/wykl
14573 !-----------------------------------------------------------------------------
14574 real(kind=8) function gnmr1prim(y,ymin,ymax)
14576 real(kind=8) :: y,ymin,ymax
14577 real(kind=8) :: wykl=4.0d0
14578 if (y.lt.ymin) then
14579 gnmr1prim=-(ymin-y)**(wykl-1)
14580 else if (y.gt.ymax) then
14581 gnmr1prim=(y-ymax)**(wykl-1)
14586 end function gnmr1prim
14587 !-----------------------------------------------------------------------------
14588 real(kind=8) function harmonic(y,ymax)
14590 real(kind=8) :: y,ymax
14591 real(kind=8) :: wykl=2.0d0
14592 harmonic=(y-ymax)**wykl
14594 end function harmonic
14595 !-----------------------------------------------------------------------------
14596 real(kind=8) function harmonicprim(y,ymax)
14597 real(kind=8) :: y,ymin,ymax
14598 real(kind=8) :: wykl=2.0d0
14599 harmonicprim=(y-ymax)*wykl
14601 end function harmonicprim
14602 !-----------------------------------------------------------------------------
14604 !-----------------------------------------------------------------------------
14605 subroutine gradient(n,x,nf,g,uiparm,urparm,ufparm)
14607 use io_base, only:intout,briefout
14608 ! implicit real*8 (a-h,o-z)
14609 ! include 'DIMENSIONS'
14610 ! include 'COMMON.CHAIN'
14611 ! include 'COMMON.DERIV'
14612 ! include 'COMMON.VAR'
14613 ! include 'COMMON.INTERACT'
14614 ! include 'COMMON.FFIELD'
14615 ! include 'COMMON.MD'
14616 ! include 'COMMON.IOUNITS'
14617 real(kind=8),external :: ufparm
14618 integer :: uiparm(1)
14619 real(kind=8) :: urparm(1)
14620 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
14621 real(kind=8) :: f,gthetai,gphii,galphai,gomegai
14622 integer :: n,nf,ind,ind1,i,k,j
14624 ! This subroutine calculates total internal coordinate gradient.
14625 ! Depending on the number of function evaluations, either whole energy
14626 ! is evaluated beforehand, Cartesian coordinates and their derivatives in
14627 ! internal coordinates are reevaluated or only the cartesian-in-internal
14628 ! coordinate derivatives are evaluated. The subroutine was designed to work
14634 !d print *,'grad',nf,icg
14635 if (nf-nfl+1) 20,30,40
14636 20 call func(n,x,nf,f,uiparm,urparm,ufparm)
14637 ! write (iout,*) 'grad 20'
14638 if (nf.eq.0) return
14640 30 call var_to_geom(n,x)
14642 ! write (iout,*) 'grad 30'
14644 ! Evaluate the derivatives of virtual bond lengths and SC vectors in variables.
14647 ! write (iout,*) 'grad 40'
14648 ! print *,'GRADIENT: nnt=',nnt,' nct=',nct,' expon=',expon
14650 ! Convert the Cartesian gradient into internal-coordinate gradient.
14660 ! print *,'GRAD: i=',i,' jc=',j,' ind=',ind
14662 gthetai=gthetai+dcdv(k,ind)*gradc(k,j,icg)
14665 gphii=gphii+dcdv(k+3,ind)*gradc(k,j,icg)
14671 ! print *,'GRAD: i=',i,' jx=',j,' ind1=',ind1
14673 gthetai=gthetai+dxdv(k,ind1)*gradx(k,j,icg)
14674 gphii=gphii+dxdv(k+3,ind1)*gradx(k,j,icg)
14677 if (i.gt.1) g(i-1)=gphii
14678 if (n.gt.nphi) g(nphi+i)=gthetai
14680 if (n.le.nphi+ntheta) goto 10
14682 if (itype(i).ne.10) then
14686 galphai=galphai+dxds(k,i)*gradx(k,i,icg)
14689 gomegai=gomegai+dxds(k+3,i)*gradx(k,i,icg)
14691 g(ialph(i,1))=galphai
14692 g(ialph(i,1)+nside)=gomegai
14696 ! Add the components corresponding to local energy terms.
14700 !d write (iout,*) 'i=',i,'g=',g(i),' gloc=',gloc(i,icg)
14701 g(i)=g(i)+gloc(i,icg)
14703 ! Uncomment following three lines for diagnostics.
14705 !elwrite(iout,*) "in gradient after calling intout"
14706 !d call briefout(0,0.0d0)
14707 !d write (iout,'(i3,1pe15.5)') (k,g(k),k=1,n)
14709 end subroutine gradient
14710 !-----------------------------------------------------------------------------
14711 subroutine func(n,x,nf,f,uiparm,urparm,ufparm) !from minimize_p.F
14714 ! implicit real*8 (a-h,o-z)
14715 ! include 'DIMENSIONS'
14716 ! include 'COMMON.DERIV'
14717 ! include 'COMMON.IOUNITS'
14718 ! include 'COMMON.GEO'
14721 !el common /chuju/ jjj
14722 real(kind=8) :: energia(0:n_ene)
14723 integer :: uiparm(1)
14724 real(kind=8) :: urparm(1)
14726 real(kind=8),external :: ufparm
14727 real(kind=8),dimension(6*nres) :: x !(maxvar) (maxvar=6*maxres)
14728 ! if (jjj.gt.0) then
14729 ! write (iout,'(10f8.3)') (rad2deg*x(i),i=1,n)
14733 !d print *,'func',nf,nfl,icg
14734 call var_to_geom(n,x)
14737 !d write (iout,*) 'ETOTAL called from FUNC'
14738 call etotal(energia)
14741 ! if (jjj.gt.0) then
14742 ! write (iout,'(10f8.3)') (rad2deg*x(i),i=1,n)
14743 ! write (iout,*) 'f=',etot
14747 end subroutine func
14748 !-----------------------------------------------------------------------------
14749 subroutine cartgrad
14750 ! implicit real*8 (a-h,o-z)
14751 ! include 'DIMENSIONS'
14753 use MD_data, only: totT,usampl,eq_time
14757 ! include 'COMMON.CHAIN'
14758 ! include 'COMMON.DERIV'
14759 ! include 'COMMON.VAR'
14760 ! include 'COMMON.INTERACT'
14761 ! include 'COMMON.FFIELD'
14762 ! include 'COMMON.MD'
14763 ! include 'COMMON.IOUNITS'
14764 ! include 'COMMON.TIME1'
14768 ! This subrouting calculates total Cartesian coordinate gradient.
14769 ! The subroutine chainbuild_cart and energy MUST be called beforehand.
14779 !el write (iout,*) "After sum_gradient"
14781 !el write (iout,*) "After sum_gradient"
14783 write (iout,*) i," gradc ",(gradc(j,i,icg),j=1,3)
14784 write (iout,*) i," gradx ",(gradx(j,i,icg),j=1,3)
14787 ! If performing constraint dynamics, add the gradients of the constraint energy
14788 if(usampl.and.totT.gt.eq_time) then
14791 gradc(j,i,icg)=gradc(j,i,icg)+dudconst(j,i)+duscdiff(j,i)
14792 gradx(j,i,icg)=gradx(j,i,icg)+dudxconst(j,i)+duscdiffx(j,i)
14796 gloc(i,icg)=gloc(i,icg)+dugamma(i)
14799 gloc(nphi+i,icg)=gloc(nphi+i,icg)+dutheta(i)
14802 !elwrite (iout,*) "After sum_gradient"
14807 !elwrite (iout,*) "After sum_gradient"
14809 time_intcartderiv=time_intcartderiv+MPI_Wtime()-time01
14811 ! call checkintcartgrad
14812 ! write(iout,*) 'calling int_to_cart'
14814 write (iout,*) "gcart, gxcart, gloc before int_to_cart"
14818 gcart(j,i)=gradc(j,i,icg)
14819 gxcart(j,i)=gradx(j,i,icg)
14822 write (iout,'(i5,2(3f10.5,5x),f10.5)') i,(gcart(j,i),j=1,3),&
14823 (gxcart(j,i),j=1,3),gloc(i,icg)
14831 time_inttocart=time_inttocart+MPI_Wtime()-time01
14834 write (iout,*) "gcart and gxcart after int_to_cart"
14836 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
14837 (gxcart(j,i),j=1,3)
14842 write (iout,*) "CARGRAD"
14846 gcart(j,i)=-gcart(j,i)+gcart(j,i-1)-gxcart(j,i)
14847 ! gcart_new(j,i)=-gcart(j,i)+gcart(j,i-1)-gxcart(j,i)
14849 ! write (iout,'(i5,3f10.5,5x,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3), &
14850 ! (gcart_new(j,i),j=1,3),(gxcart(j,i),j=1,3)
14852 ! Correction: dummy residues
14855 ! gcart_new(j,nnt)=gcart_new(j,nnt)+gcart_new(j,1)
14856 gcart(j,nnt)=gcart(j,nnt)+gcart(j,1)
14859 if (nct.lt.nres) then
14861 ! gcart_new(j,nct)=gcart_new(j,nct)+gcart_new(j,nres)
14862 gcart(j,nct)=gcart(j,nct)+gcart(j,nres)
14867 time_cartgrad=time_cartgrad+MPI_Wtime()-time00
14871 end subroutine cartgrad
14872 !-----------------------------------------------------------------------------
14873 subroutine zerograd
14874 ! implicit real*8 (a-h,o-z)
14875 ! include 'DIMENSIONS'
14876 ! include 'COMMON.DERIV'
14877 ! include 'COMMON.CHAIN'
14878 ! include 'COMMON.VAR'
14879 ! include 'COMMON.MD'
14880 ! include 'COMMON.SCCOR'
14882 !el local variables
14883 integer :: i,j,intertyp
14884 ! Initialize Cartesian-coordinate gradient
14886 ! if (.not.allocated(gradx)) allocate(gradx(3,nres,2)) !(3,maxres,2)
14887 ! if (.not.allocated(gradc)) allocate(gradc(3,nres,2)) !(3,maxres,2)
14889 ! allocate(gvdwx(3,nres),gvdwc(3,nres),gelc(3,nres),gelc_long(3,nres))
14890 ! allocate(gvdwpp(3,nres),gvdwc_scpp(3,nres),gradx_scp(3,nres))
14891 ! allocate(gvdwc_scp(3,nres),ghpbx(3,nres),ghpbc(3,nres))
14892 ! allocate(gradcorr_long(3,nres))
14893 ! allocate(gradcorr5_long(3,nres),gradcorr6_long(3,nres))
14894 ! allocate(gcorr6_turn_long(3,nres))
14895 ! allocate(gradcorr5(3,nres),gradcorr6(3,nres)) !(3,maxres)
14897 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres)) !(3,maxres)
14899 ! allocate(gel_loc(3,nres),gel_loc_long(3,nres),gcorr3_turn(3,nres))
14900 ! allocate(gcorr4_turn(3,nres),gcorr6_turn(3,nres))
14902 ! if (.not.allocated(gradb)) allocate(gradb(3,nres)) !(3,maxres)
14903 ! if (.not.allocated(gradbx)) allocate(gradbx(3,nres)) !(3,maxres)
14905 ! allocate(gsccorc(3,nres),gsccorx(3,nres)) !(3,maxres)
14906 ! allocate(gscloc(3,nres)) !(3,maxres)
14907 ! if (.not.allocated(gsclocx)) allocate(gsclocx(3,nres)) !(3,maxres)
14911 ! common /deriv_scloc/
14912 ! allocate(dXX_C1tab(3,nres),dYY_C1tab(3,nres),dZZ_C1tab(3,nres))
14913 ! allocate(dXX_Ctab(3,nres),dYY_Ctab(3,nres),dZZ_Ctab(3,nres))
14914 ! allocate(dXX_XYZtab(3,nres),dYY_XYZtab(3,nres),dZZ_XYZtab(3,nres)) !(3,maxres)
14916 ! allocate(jgrad_start(nres),jgrad_end(nres)) !(maxres)
14920 ! gradc(j,i,icg)=0.0d0
14921 ! gradx(j,i,icg)=0.0d0
14923 ! allocate(gloc_sc(3,nres,10)) !(3,0:maxres2,10)maxres2=2*maxres
14924 !elwrite(iout,*) "icg",icg
14928 gradx_scp(j,i)=0.0D0
14930 gvdwc_scp(j,i)=0.0D0
14931 gvdwc_scpp(j,i)=0.0d0
14933 gelc_long(j,i)=0.0D0
14938 gel_loc_long(j,i)=0.0d0
14941 gcorr3_turn(j,i)=0.0d0
14942 gcorr4_turn(j,i)=0.0d0
14943 gradcorr(j,i)=0.0d0
14944 gradcorr_long(j,i)=0.0d0
14945 gradcorr5_long(j,i)=0.0d0
14946 gradcorr6_long(j,i)=0.0d0
14947 gcorr6_turn_long(j,i)=0.0d0
14948 gradcorr5(j,i)=0.0d0
14949 gradcorr6(j,i)=0.0d0
14950 gcorr6_turn(j,i)=0.0d0
14953 gradc(j,i,icg)=0.0d0
14954 gradx(j,i,icg)=0.0d0
14958 gloc_sc(intertyp,i,icg)=0.0d0
14963 ! Initialize the gradient of local energy terms.
14965 ! allocate(gloc(4*nres,2)) !!(maxvar,2)(maxvar=6*maxres)
14966 ! if (.not.allocated(gel_loc_loc)) allocate(gel_loc_loc(nres)) !(maxvar)(maxvar=6*maxres)
14967 ! if (.not.allocated(gcorr_loc)) allocate(gcorr_loc(nres)) !(maxvar)(maxvar=6*maxres)
14968 ! allocate(g_corr5_loc(nres),g_corr6_loc(nres)) !(maxvar)(maxvar=6*maxres)
14969 ! allocate(gel_loc_turn3(nres))
14970 ! allocate(gel_loc_turn4(nres),gel_loc_turn6(nres)) !(maxvar)(maxvar=6*maxres)
14971 ! allocate(gsccor_loc(nres)) !(maxres)
14977 gel_loc_loc(i)=0.0d0
14979 g_corr5_loc(i)=0.0d0
14980 g_corr6_loc(i)=0.0d0
14981 gel_loc_turn3(i)=0.0d0
14982 gel_loc_turn4(i)=0.0d0
14983 gel_loc_turn6(i)=0.0d0
14984 gsccor_loc(i)=0.0d0
14986 ! initialize gcart and gxcart
14987 ! allocate(gcart(3,0:nres),gxcart(3,0:nres)) !(3,0:MAXRES)
14995 end subroutine zerograd
14996 !-----------------------------------------------------------------------------
14997 real(kind=8) function fdum()
15001 !-----------------------------------------------------------------------------
15003 !-----------------------------------------------------------------------------
15004 subroutine intcartderiv
15005 ! implicit real*8 (a-h,o-z)
15006 ! include 'DIMENSIONS'
15010 ! include 'COMMON.SETUP'
15011 ! include 'COMMON.CHAIN'
15012 ! include 'COMMON.VAR'
15013 ! include 'COMMON.GEO'
15014 ! include 'COMMON.INTERACT'
15015 ! include 'COMMON.DERIV'
15016 ! include 'COMMON.IOUNITS'
15017 ! include 'COMMON.LOCAL'
15018 ! include 'COMMON.SCCOR'
15019 real(kind=8) :: pi4,pi34
15020 real(kind=8),dimension(3,2,nres) :: dcostheta ! (3,2,maxres)
15021 real(kind=8),dimension(3,3,nres) :: dcosphi,dsinphi,dcosalpha,&
15022 dcosomega,dsinomega !(3,3,maxres)
15023 real(kind=8),dimension(3) :: vo1,vo2,vo3,dummy,vp1,vp2,vp3,vpp1,n
15026 real(kind=8) :: cost,sint,cost1,sint1,cost2,sint2,sing,cosg,scalp,&
15027 fac0,fac1,fac2,fac3,fac4,fac5,fac6,ctgt,ctgt1,cosg_inv,&
15028 fac7,fac8,fac9,scala1,scala2,cosa,sina,sino,fac15,fac16,&
15029 fac17,coso_inv,fac10,fac11,fac12,fac13,fac14
15033 !el from module energy-------------
15034 !el allocate(dcostau(3,3,3,itau_start:itau_end)) !(3,3,3,maxres2)maxres2=2*maxres
15035 !el allocate(dsintau(3,3,3,itau_start:itau_end))
15036 !el allocate(dtauangle(3,3,3,itau_start:itau_end))
15038 !el allocate(dcostau(3,3,3,0:nres2)) !(3,3,3,maxres2)maxres2=2*maxres
15039 !el allocate(dsintau(3,3,3,0:nres2))
15040 !el allocate(dtauangle(3,3,3,0:nres2))
15041 !el allocate(domicron(3,2,2,0:nres2))
15042 !el allocate(dcosomicron(3,2,2,0:nres2))
15046 #if defined(MPI) && defined(PARINTDER)
15047 if (nfgtasks.gt.1 .and. me.eq.king) &
15048 call MPI_Bcast(8,1,MPI_INTEGER,king,FG_COMM,IERROR)
15053 ! allocate(dtheta(3,2,nres)) !(3,2,maxres)
15054 ! allocate(dphi(3,3,nres),dalpha(3,3,nres),domega(3,3,nres)) !(3,3,maxres)
15056 ! write (iout,*) "iphi1_start",iphi1_start," iphi1_end",iphi1_end
15059 dtheta(j,1,i)=0.0d0
15060 dtheta(j,2,i)=0.0d0
15066 ! Derivatives of theta's
15067 #if defined(MPI) && defined(PARINTDER)
15068 ! We need dtheta(:,:,i-1) to compute dphi(:,:,i)
15069 do i=max0(ithet_start-1,3),ithet_end
15073 cost=dcos(theta(i))
15074 sint=sqrt(1-cost*cost)
15076 dcostheta(j,1,i)=-(dc_norm(j,i-1)+cost*dc_norm(j,i-2))/&
15078 if (itype(i-1).ne.ntyp1) dtheta(j,1,i)=-dcostheta(j,1,i)/sint
15079 dcostheta(j,2,i)=-(dc_norm(j,i-2)+cost*dc_norm(j,i-1))/&
15081 if (itype(i-1).ne.ntyp1) dtheta(j,2,i)=-dcostheta(j,2,i)/sint
15084 #if defined(MPI) && defined(PARINTDER)
15085 ! We need dtheta(:,:,i-1) to compute dphi(:,:,i)
15086 do i=max0(ithet_start-1,3),ithet_end
15090 if ((itype(i-1).ne.10).and.(itype(i-1).ne.ntyp1)) then
15091 cost1=dcos(omicron(1,i))
15092 sint1=sqrt(1-cost1*cost1)
15093 cost2=dcos(omicron(2,i))
15094 sint2=sqrt(1-cost2*cost2)
15096 !C Calculate derivative over first omicron (Cai-2,Cai-1,SCi-1)
15097 dcosomicron(j,1,1,i)=-(dc_norm(j,i-1+nres)+ &
15098 cost1*dc_norm(j,i-2))/ &
15100 domicron(j,1,1,i)=-1/sint1*dcosomicron(j,1,1,i)
15101 dcosomicron(j,1,2,i)=-(dc_norm(j,i-2) &
15102 +cost1*(dc_norm(j,i-1+nres)))/ &
15104 domicron(j,1,2,i)=-1/sint1*dcosomicron(j,1,2,i)
15105 !C Calculate derivative over second omicron Sci-1,Cai-1 Cai
15106 !C Looks messy but better than if in loop
15107 dcosomicron(j,2,1,i)=-(-dc_norm(j,i-1+nres) &
15108 +cost2*dc_norm(j,i-1))/ &
15110 domicron(j,2,1,i)=-1/sint2*dcosomicron(j,2,1,i)
15111 dcosomicron(j,2,2,i)=-(dc_norm(j,i-1) &
15112 +cost2*(-dc_norm(j,i-1+nres)))/ &
15114 ! write(iout,*) "vbld", i,itype(i),vbld(i-1+nres)
15115 domicron(j,2,2,i)=-1/sint2*dcosomicron(j,2,2,i)
15119 !elwrite(iout,*) "after vbld write"
15120 ! Derivatives of phi:
15121 ! If phi is 0 or 180 degrees, then the formulas
15122 ! have to be derived by power series expansion of the
15123 ! conventional formulas around 0 and 180.
15125 do i=iphi1_start,iphi1_end
15129 ! if (itype(i-1).eq.21 .or. itype(i-2).eq.21 ) cycle
15130 ! the conventional case
15131 sint=dsin(theta(i))
15132 sint1=dsin(theta(i-1))
15134 cost=dcos(theta(i))
15135 cost1=dcos(theta(i-1))
15137 scalp=scalar(dc_norm(1,i-3),dc_norm(1,i-1))
15138 fac0=1.0d0/(sint1*sint)
15141 fac3=cosg*cost1/(sint1*sint1)
15142 fac4=cosg*cost/(sint*sint)
15143 ! Obtaining the gamma derivatives from sine derivative
15144 if (phi(i).gt.-pi4.and.phi(i).le.pi4.or. &
15145 phi(i).gt.pi34.and.phi(i).le.pi.or. &
15146 phi(i).ge.-pi.and.phi(i).le.-pi34) then
15147 call vecpr(dc_norm(1,i-1),dc_norm(1,i-2),vp1)
15148 call vecpr(dc_norm(1,i-3),dc_norm(1,i-1),vp2)
15149 call vecpr(dc_norm(1,i-3),dc_norm(1,i-2),vp3)
15153 cosg_inv=1.0d0/cosg
15154 if (itype(i-1).ne.ntyp1 .and. itype(i-2).ne.ntyp1) then
15155 dsinphi(j,1,i)=-sing*ctgt1*dtheta(j,1,i-1) &
15156 -(fac0*vp1(j)+sing*dc_norm(j,i-3))*vbld_inv(i-2)
15157 dphi(j,1,i)=cosg_inv*dsinphi(j,1,i)
15159 -sing*(ctgt1*dtheta(j,2,i-1)+ctgt*dtheta(j,1,i)) &
15160 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
15161 dphi(j,2,i)=cosg_inv*dsinphi(j,2,i)
15162 dsinphi(j,3,i)=-sing*ctgt*dtheta(j,2,i) &
15163 +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i)
15164 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
15165 dphi(j,3,i)=cosg_inv*dsinphi(j,3,i)
15167 ! Bug fixed 3/24/05 (AL)
15169 ! Obtaining the gamma derivatives from cosine derivative
15172 if (itype(i-1).ne.ntyp1 .and. itype(i-2).ne.ntyp1) then
15173 dcosphi(j,1,i)=fac1*dcostheta(j,1,i-1)+fac3* &
15174 dcostheta(j,1,i-1)-fac0*(dc_norm(j,i-1)-scalp* &
15175 dc_norm(j,i-3))/vbld(i-2)
15176 dphi(j,1,i)=-1/sing*dcosphi(j,1,i)
15177 dcosphi(j,2,i)=fac1*dcostheta(j,2,i-1)+fac2* &
15178 dcostheta(j,1,i)+fac3*dcostheta(j,2,i-1)+fac4* &
15180 dphi(j,2,i)=-1/sing*dcosphi(j,2,i)
15181 dcosphi(j,3,i)=fac2*dcostheta(j,2,i)+fac4* &
15182 dcostheta(j,2,i)-fac0*(dc_norm(j,i-3)-scalp* &
15183 dc_norm(j,i-1))/vbld(i)
15184 dphi(j,3,i)=-1/sing*dcosphi(j,3,i)
15189 !alculate derivative of Tauangle
15191 do i=itau_start,itau_end
15194 !elwrite(iout,*) " vecpr",i,nres
15196 if ((itype(i-2).eq.ntyp1).or.(itype(i-2).eq.10)) cycle
15197 ! if ((itype(i-2).eq.ntyp1).or.(itype(i-2).eq.10).or.
15198 ! & (itype(i-1).eq.ntyp1).or.(itype(i).eq.ntyp1)) cycle
15199 !c dtauangle(j,intertyp,dervityp,residue number)
15200 !c INTERTYP=1 SC...Ca...Ca..Ca
15201 ! the conventional case
15202 sint=dsin(theta(i))
15203 sint1=dsin(omicron(2,i-1))
15204 sing=dsin(tauangle(1,i))
15205 cost=dcos(theta(i))
15206 cost1=dcos(omicron(2,i-1))
15207 cosg=dcos(tauangle(1,i))
15208 !elwrite(iout,*) " vecpr5",i,nres
15210 !elwrite(iout,*) " vecpreee",i,nres,j,i-2+nres
15211 !elwrite(iout,*) " vecpr5",dc_norm2(1,1)
15212 dc_norm2(j,i-2+nres)=-dc_norm(j,i-2+nres)
15213 ! write(iout,*) dc_norm2(j,i-2+nres),"dcnorm"
15215 scalp=scalar(dc_norm2(1,i-2+nres),dc_norm(1,i-1))
15216 fac0=1.0d0/(sint1*sint)
15219 fac3=cosg*cost1/(sint1*sint1)
15220 fac4=cosg*cost/(sint*sint)
15221 ! write(iout,*) "faki",fac0,fac1,fac2,fac3,fac4
15222 ! Obtaining the gamma derivatives from sine derivative
15223 if (tauangle(1,i).gt.-pi4.and.tauangle(1,i).le.pi4.or. &
15224 tauangle(1,i).gt.pi34.and.tauangle(1,i).le.pi.or. &
15225 tauangle(1,i).gt.-pi.and.tauangle(1,i).le.-pi34) then
15226 call vecpr(dc_norm(1,i-1),dc_norm(1,i-2),vp1)
15227 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-1),vp2)
15228 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-2),vp3)
15232 cosg_inv=1.0d0/cosg
15233 dsintau(j,1,1,i)=-sing*ctgt1*domicron(j,2,2,i-1) &
15234 -(fac0*vp1(j)+sing*(dc_norm2(j,i-2+nres))) &
15235 *vbld_inv(i-2+nres)
15236 dtauangle(j,1,1,i)=cosg_inv*dsintau(j,1,1,i)
15237 dsintau(j,1,2,i)= &
15238 -sing*(ctgt1*domicron(j,2,1,i-1)+ctgt*dtheta(j,1,i)) &
15239 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
15240 ! write(iout,*) "dsintau", dsintau(j,1,2,i)
15241 dtauangle(j,1,2,i)=cosg_inv*dsintau(j,1,2,i)
15242 ! Bug fixed 3/24/05 (AL)
15243 dsintau(j,1,3,i)=-sing*ctgt*dtheta(j,2,i) &
15244 +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i)
15245 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
15246 dtauangle(j,1,3,i)=cosg_inv*dsintau(j,1,3,i)
15248 ! Obtaining the gamma derivatives from cosine derivative
15251 dcostau(j,1,1,i)=fac1*dcosomicron(j,2,2,i-1)+fac3* &
15252 dcosomicron(j,2,2,i-1)-fac0*(dc_norm(j,i-1)-scalp* &
15253 (dc_norm2(j,i-2+nres)))/vbld(i-2+nres)
15254 dtauangle(j,1,1,i)=-1/sing*dcostau(j,1,1,i)
15255 dcostau(j,1,2,i)=fac1*dcosomicron(j,2,1,i-1)+fac2* &
15256 dcostheta(j,1,i)+fac3*dcosomicron(j,2,1,i-1)+fac4* &
15258 dtauangle(j,1,2,i)=-1/sing*dcostau(j,1,2,i)
15259 dcostau(j,1,3,i)=fac2*dcostheta(j,2,i)+fac4* &
15260 dcostheta(j,2,i)-fac0*(-dc_norm(j,i-2+nres)-scalp* &
15261 dc_norm(j,i-1))/vbld(i)
15262 dtauangle(j,1,3,i)=-1/sing*dcostau(j,1,3,i)
15263 ! write (iout,*) "else",i
15267 ! write(iout,*) "tu",i,k,(dtauangle(j,1,k,i),j=1,3)
15270 !C Second case Ca...Ca...Ca...SC
15272 do i=itau_start,itau_end
15276 if ((itype(i-1).eq.ntyp1).or.(itype(i-1).eq.10).or. &
15277 (itype(i-2).eq.ntyp1).or.(itype(i-3).eq.ntyp1)) cycle
15278 ! the conventional case
15279 sint=dsin(omicron(1,i))
15280 sint1=dsin(theta(i-1))
15281 sing=dsin(tauangle(2,i))
15282 cost=dcos(omicron(1,i))
15283 cost1=dcos(theta(i-1))
15284 cosg=dcos(tauangle(2,i))
15286 ! dc_norm2(j,i-1+nres)=-dc_norm(j,i-1+nres)
15288 scalp=scalar(dc_norm(1,i-3),dc_norm(1,i-1+nres))
15289 fac0=1.0d0/(sint1*sint)
15292 fac3=cosg*cost1/(sint1*sint1)
15293 fac4=cosg*cost/(sint*sint)
15294 ! Obtaining the gamma derivatives from sine derivative
15295 if (tauangle(2,i).gt.-pi4.and.tauangle(2,i).le.pi4.or. &
15296 tauangle(2,i).gt.pi34.and.tauangle(2,i).le.pi.or. &
15297 tauangle(2,i).gt.-pi.and.tauangle(2,i).le.-pi34) then
15298 call vecpr(dc_norm2(1,i-1+nres),dc_norm(1,i-2),vp1)
15299 call vecpr(dc_norm(1,i-3),dc_norm(1,i-1+nres),vp2)
15300 call vecpr(dc_norm(1,i-3),dc_norm(1,i-2),vp3)
15304 cosg_inv=1.0d0/cosg
15305 dsintau(j,2,1,i)=-sing*ctgt1*dtheta(j,1,i-1) &
15306 +(fac0*vp1(j)-sing*dc_norm(j,i-3))*vbld_inv(i-2)
15307 ! write(iout,*) i,j,dsintau(j,2,1,i),sing*ctgt1*dtheta(j,1,i-1),
15308 ! &fac0*vp1(j),sing*dc_norm(j,i-3),vbld_inv(i-2),"dsintau(2,1)"
15309 dtauangle(j,2,1,i)=cosg_inv*dsintau(j,2,1,i)
15310 dsintau(j,2,2,i)= &
15311 -sing*(ctgt1*dtheta(j,2,i-1)+ctgt*domicron(j,1,1,i)) &
15312 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
15313 ! write(iout,*) "sprawdzenie",i,j,sing*ctgt1*dtheta(j,2,i-1),
15314 ! & sing*ctgt*domicron(j,1,2,i),
15315 ! & (fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
15316 dtauangle(j,2,2,i)=cosg_inv*dsintau(j,2,2,i)
15317 ! Bug fixed 3/24/05 (AL)
15318 dsintau(j,2,3,i)=-sing*ctgt*domicron(j,1,2,i) &
15319 +(fac0*vp3(j)-sing*dc_norm(j,i-1+nres))*vbld_inv(i-1+nres)
15320 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
15321 dtauangle(j,2,3,i)=cosg_inv*dsintau(j,2,3,i)
15323 ! Obtaining the gamma derivatives from cosine derivative
15326 dcostau(j,2,1,i)=fac1*dcostheta(j,1,i-1)+fac3* &
15327 dcostheta(j,1,i-1)-fac0*(dc_norm(j,i-1+nres)-scalp* &
15328 dc_norm(j,i-3))/vbld(i-2)
15329 dtauangle(j,2,1,i)=-1/sing*dcostau(j,2,1,i)
15330 dcostau(j,2,2,i)=fac1*dcostheta(j,2,i-1)+fac2* &
15331 dcosomicron(j,1,1,i)+fac3*dcostheta(j,2,i-1)+fac4* &
15332 dcosomicron(j,1,1,i)
15333 dtauangle(j,2,2,i)=-1/sing*dcostau(j,2,2,i)
15334 dcostau(j,2,3,i)=fac2*dcosomicron(j,1,2,i)+fac4* &
15335 dcosomicron(j,1,2,i)-fac0*(dc_norm(j,i-3)-scalp* &
15336 dc_norm(j,i-1+nres))/vbld(i-1+nres)
15337 dtauangle(j,2,3,i)=-1/sing*dcostau(j,2,3,i)
15338 ! write(iout,*) i,j,"else", dtauangle(j,2,3,i)
15343 !CC third case SC...Ca...Ca...SC
15346 do i=itau_start,itau_end
15350 ! the conventional case
15351 if ((itype(i-1).eq.ntyp1).or.(itype(i-1).eq.10).or. &
15352 (itype(i-2).eq.ntyp1).or.(itype(i-2).eq.10)) cycle
15353 sint=dsin(omicron(1,i))
15354 sint1=dsin(omicron(2,i-1))
15355 sing=dsin(tauangle(3,i))
15356 cost=dcos(omicron(1,i))
15357 cost1=dcos(omicron(2,i-1))
15358 cosg=dcos(tauangle(3,i))
15360 dc_norm2(j,i-2+nres)=-dc_norm(j,i-2+nres)
15361 ! dc_norm2(j,i-1+nres)=-dc_norm(j,i-1+nres)
15363 scalp=scalar(dc_norm2(1,i-2+nres),dc_norm(1,i-1+nres))
15364 fac0=1.0d0/(sint1*sint)
15367 fac3=cosg*cost1/(sint1*sint1)
15368 fac4=cosg*cost/(sint*sint)
15369 ! Obtaining the gamma derivatives from sine derivative
15370 if (tauangle(3,i).gt.-pi4.and.tauangle(3,i).le.pi4.or. &
15371 tauangle(3,i).gt.pi34.and.tauangle(3,i).le.pi.or. &
15372 tauangle(3,i).gt.-pi.and.tauangle(3,i).le.-pi34) then
15373 call vecpr(dc_norm(1,i-1+nres),dc_norm(1,i-2),vp1)
15374 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-1+nres),vp2)
15375 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-2),vp3)
15379 cosg_inv=1.0d0/cosg
15380 dsintau(j,3,1,i)=-sing*ctgt1*domicron(j,2,2,i-1) &
15381 -(fac0*vp1(j)-sing*dc_norm(j,i-2+nres)) &
15382 *vbld_inv(i-2+nres)
15383 dtauangle(j,3,1,i)=cosg_inv*dsintau(j,3,1,i)
15384 dsintau(j,3,2,i)= &
15385 -sing*(ctgt1*domicron(j,2,1,i-1)+ctgt*domicron(j,1,1,i)) &
15386 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
15387 dtauangle(j,3,2,i)=cosg_inv*dsintau(j,3,2,i)
15388 ! Bug fixed 3/24/05 (AL)
15389 dsintau(j,3,3,i)=-sing*ctgt*domicron(j,1,2,i) &
15390 +(fac0*vp3(j)-sing*dc_norm(j,i-1+nres)) &
15391 *vbld_inv(i-1+nres)
15392 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
15393 dtauangle(j,3,3,i)=cosg_inv*dsintau(j,3,3,i)
15395 ! Obtaining the gamma derivatives from cosine derivative
15398 dcostau(j,3,1,i)=fac1*dcosomicron(j,2,2,i-1)+fac3* &
15399 dcosomicron(j,2,2,i-1)-fac0*(dc_norm(j,i-1+nres)-scalp* &
15400 dc_norm2(j,i-2+nres))/vbld(i-2+nres)
15401 dtauangle(j,3,1,i)=-1/sing*dcostau(j,3,1,i)
15402 dcostau(j,3,2,i)=fac1*dcosomicron(j,2,1,i-1)+fac2* &
15403 dcosomicron(j,1,1,i)+fac3*dcosomicron(j,2,1,i-1)+fac4* &
15404 dcosomicron(j,1,1,i)
15405 dtauangle(j,3,2,i)=-1/sing*dcostau(j,3,2,i)
15406 dcostau(j,3,3,i)=fac2*dcosomicron(j,1,2,i)+fac4* &
15407 dcosomicron(j,1,2,i)-fac0*(dc_norm2(j,i-2+nres)-scalp* &
15408 dc_norm(j,i-1+nres))/vbld(i-1+nres)
15409 dtauangle(j,3,3,i)=-1/sing*dcostau(j,3,3,i)
15410 ! write(iout,*) "else",i
15416 ! Derivatives of side-chain angles alpha and omega
15417 #if defined(MPI) && defined(PARINTDER)
15418 do i=ibond_start,ibond_end
15422 if(itype(i).ne.10 .and. itype(i).ne.ntyp1) then
15423 fac5=1.0d0/dsqrt(2*(1+dcos(theta(i+1))))
15426 fac8=fac5/vbld(i+1)
15427 fac9=fac5/vbld(i+nres)
15428 scala1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
15429 scala2=scalar(dc_norm(1,i),dc_norm(1,i+nres))
15430 cosa=dsqrt(0.5d0/(1.0d0+dcos(theta(i+1))))* &
15431 (scalar(dC_norm(1,i),dC_norm(1,i+nres)) &
15432 -scalar(dC_norm(1,i-1),dC_norm(1,i+nres)))
15433 sina=sqrt(1-cosa*cosa)
15435 ! write (iout,*) "i",i," cosa",cosa," sina",sina," sino",sino
15437 dcosalpha(j,1,i)=fac6*(scala1*dc_norm(j,i-1)- &
15438 dc_norm(j,i+nres))-cosa*fac7*dcostheta(j,1,i+1)
15439 dalpha(j,1,i)=-1/sina*dcosalpha(j,1,i)
15440 dcosalpha(j,2,i)=fac8*(dc_norm(j,i+nres)- &
15441 scala2*dc_norm(j,i))-cosa*fac7*dcostheta(j,2,i+1)
15442 dalpha(j,2,i)=-1/sina*dcosalpha(j,2,i)
15443 dcosalpha(j,3,i)=(fac9*(dc_norm(j,i)- &
15444 dc_norm(j,i-1))-(cosa*dc_norm(j,i+nres))/ &
15446 dalpha(j,3,i)=-1/sina*dcosalpha(j,3,i)
15448 ! obtaining the derivatives of omega from sines
15449 if(omeg(i).gt.-pi4.and.omeg(i).le.pi4.or. &
15450 omeg(i).gt.pi34.and.omeg(i).le.pi.or. &
15451 omeg(i).gt.-pi.and.omeg(i).le.-pi34) then
15452 fac15=dcos(theta(i+1))/(dsin(theta(i+1))* &
15454 fac16=dcos(alph(i))/(dsin(alph(i))*dsin(alph(i)))
15455 fac17=1.0d0/(dsin(theta(i+1))*dsin(alph(i)))
15456 call vecpr(dc_norm(1,i+nres),dc_norm(1,i),vo1)
15457 call vecpr(dc_norm(1,i+nres),dc_norm(1,i-1),vo2)
15458 call vecpr(dc_norm(1,i),dc_norm(1,i-1),vo3)
15459 coso_inv=1.0d0/dcos(omeg(i))
15461 dsinomega(j,1,i)=sino*(fac15*dcostheta(j,1,i+1) &
15462 +fac16*dcosalpha(j,1,i))-fac17/vbld(i)*vo1(j)- &
15463 (sino*dc_norm(j,i-1))/vbld(i)
15464 domega(j,1,i)=coso_inv*dsinomega(j,1,i)
15465 dsinomega(j,2,i)=sino*(fac15*dcostheta(j,2,i+1) &
15466 +fac16*dcosalpha(j,2,i))+fac17/vbld(i+1)*vo2(j) &
15467 -sino*dc_norm(j,i)/vbld(i+1)
15468 domega(j,2,i)=coso_inv*dsinomega(j,2,i)
15469 dsinomega(j,3,i)=sino*fac16*dcosalpha(j,3,i)- &
15470 fac17/vbld(i+nres)*vo3(j)-sino*dc_norm(j,i+nres)/ &
15472 domega(j,3,i)=coso_inv*dsinomega(j,3,i)
15475 ! obtaining the derivatives of omega from cosines
15476 fac10=sqrt(0.5d0*(1-dcos(theta(i+1))))
15477 fac11=sqrt(0.5d0*(1+dcos(theta(i+1))))
15482 dcosomega(j,1,i)=(-(0.25d0*cosa/fac11* &
15483 dcostheta(j,1,i+1)+fac11*dcosalpha(j,1,i))*fac12+ &
15484 (0.25d0/fac10*sina*dcostheta(j,1,i+1)+cosa/sina* &
15485 fac10*dcosalpha(j,1,i))*(scala2-fac11*cosa))/fac13
15486 domega(j,1,i)=-1/sino*dcosomega(j,1,i)
15487 dcosomega(j,2,i)=(((dc_norm(j,i+nres)-scala2* &
15488 dc_norm(j,i))/vbld(i+1)-0.25d0*cosa/fac11* &
15489 dcostheta(j,2,i+1)-fac11*dcosalpha(j,2,i))*fac12+ &
15490 (scala2-fac11*cosa)*(0.25d0*sina/fac10* &
15491 dcostheta(j,2,i+1)+fac10*cosa/sina*dcosalpha(j,2,i)))/fac13
15492 domega(j,2,i)=-1/sino*dcosomega(j,2,i)
15493 dcosomega(j,3,i)=1/fac10*((1/vbld(i+nres)*(dc_norm(j,i)- &
15494 scala2*dc_norm(j,i+nres))-fac11*dcosalpha(j,3,i))*sina+ &
15495 (scala2-fac11*cosa)*(cosa/sina*dcosalpha(j,3,i)))/fac14
15496 domega(j,3,i)=-1/sino*dcosomega(j,3,i)
15502 dalpha(k,j,i)=0.0d0
15503 domega(k,j,i)=0.0d0
15509 #if defined(MPI) && defined(PARINTDER)
15510 if (nfgtasks.gt.1) then
15512 !d write (iout,*) "Gather dtheta"
15513 !d call flush(iout)
15514 write (iout,*) "dtheta before gather"
15516 write (iout,'(i3,3(3f8.5,3x))') i,((dtheta(j,k,i),k=1,3),j=1,2)
15519 call MPI_Gatherv(dtheta(1,1,ithet_start),ithet_count(fg_rank),&
15520 MPI_THET,dtheta(1,1,1),ithet_count(0),ithet_displ(0),MPI_THET,&
15521 king,FG_COMM,IERROR)
15523 !d write (iout,*) "Gather dphi"
15524 !d call flush(iout)
15525 write (iout,*) "dphi before gather"
15527 write (iout,'(i3,3(3f8.5,3x))') i,((dphi(j,k,i),k=1,3),j=1,3)
15530 call MPI_Gatherv(dphi(1,1,iphi1_start),iphi1_count(fg_rank),&
15531 MPI_GAM,dphi(1,1,1),iphi1_count(0),iphi1_displ(0),MPI_GAM,&
15532 king,FG_COMM,IERROR)
15533 !d write (iout,*) "Gather dalpha"
15534 !d call flush(iout)
15536 call MPI_Gatherv(dalpha(1,1,ibond_start),ibond_count(fg_rank),&
15537 MPI_GAM,dalpha(1,1,1),ibond_count(0),ibond_displ(0),MPI_GAM,&
15538 king,FG_COMM,IERROR)
15539 !d write (iout,*) "Gather domega"
15540 !d call flush(iout)
15541 call MPI_Gatherv(domega(1,1,ibond_start),ibond_count(fg_rank),&
15542 MPI_GAM,domega(1,1,1),ibond_count(0),ibond_displ(0),MPI_GAM,&
15543 king,FG_COMM,IERROR)
15548 write (iout,*) "dtheta after gather"
15550 write (iout,'(i3,3(3f8.5,3x))') i,((dtheta(j,k,i),j=1,3),k=1,2)
15552 write (iout,*) "dphi after gather"
15554 write (iout,'(i3,3(3f8.5,3x))') i,((dphi(j,k,i),j=1,3),k=1,3)
15556 write (iout,*) "dalpha after gather"
15558 write (iout,'(i3,3(3f8.5,3x))') i,((dalpha(j,k,i),j=1,3),k=1,3)
15560 write (iout,*) "domega after gather"
15562 write (iout,'(i3,3(3f8.5,3x))') i,((domega(j,k,i),j=1,3),k=1,3)
15566 end subroutine intcartderiv
15567 !-----------------------------------------------------------------------------
15568 subroutine checkintcartgrad
15569 ! implicit real*8 (a-h,o-z)
15570 ! include 'DIMENSIONS'
15574 ! include 'COMMON.CHAIN'
15575 ! include 'COMMON.VAR'
15576 ! include 'COMMON.GEO'
15577 ! include 'COMMON.INTERACT'
15578 ! include 'COMMON.DERIV'
15579 ! include 'COMMON.IOUNITS'
15580 ! include 'COMMON.SETUP'
15581 real(kind=8),dimension(3,2,nres) :: dthetanum !(3,2,maxres)
15582 real(kind=8),dimension(3,3,nres) :: dphinum,dalphanum,domeganum !(3,3,maxres)
15583 real(kind=8),dimension(nres) :: theta_s,phi_s,alph_s,omeg_s !(maxres)
15584 real(kind=8),dimension(3) :: dc_norm_s
15585 real(kind=8) :: aincr=1.0d-5
15587 real(kind=8) :: dcji
15590 theta_s(i)=theta(i)
15594 ! Check theta gradient
15596 "Analytical (upper) and numerical (lower) gradient of theta"
15601 dc(j,i-2)=dcji+aincr
15602 call chainbuild_cart
15603 call int_from_cart1(.false.)
15604 dthetanum(j,1,i)=(theta(i)-theta_s(i))/aincr
15607 dc(j,i-1)=dc(j,i-1)+aincr
15608 call chainbuild_cart
15609 dthetanum(j,2,i)=(theta(i)-theta_s(i))/aincr
15612 !el write (iout,'(i5,3f10.5,5x,3f10.5)') i,(dtheta(j,1,i),j=1,3),&
15613 !el (dtheta(j,2,i),j=1,3)
15614 !el write (iout,'(5x,3f10.5,5x,3f10.5)') (dthetanum(j,1,i),j=1,3),&
15615 !el (dthetanum(j,2,i),j=1,3)
15616 !el write (iout,'(5x,3f10.5,5x,3f10.5)') &
15617 !el (dthetanum(j,1,i)/dtheta(j,1,i),j=1,3),&
15618 !el (dthetanum(j,2,i)/dtheta(j,2,i),j=1,3)
15621 ! Check gamma gradient
15623 "Analytical (upper) and numerical (lower) gradient of gamma"
15627 dc(j,i-3)=dcji+aincr
15628 call chainbuild_cart
15629 dphinum(j,1,i)=(phi(i)-phi_s(i))/aincr
15632 dc(j,i-2)=dcji+aincr
15633 call chainbuild_cart
15634 dphinum(j,2,i)=(phi(i)-phi_s(i))/aincr
15637 dc(j,i-1)=dc(j,i-1)+aincr
15638 call chainbuild_cart
15639 dphinum(j,3,i)=(phi(i)-phi_s(i))/aincr
15642 !el write (iout,'(i5,3(3f10.5,5x))') i,(dphi(j,1,i),j=1,3),&
15643 !el (dphi(j,2,i),j=1,3),(dphi(j,3,i),j=1,3)
15644 !el write (iout,'(5x,3(3f10.5,5x))') (dphinum(j,1,i),j=1,3),&
15645 !el (dphinum(j,2,i),j=1,3),(dphinum(j,3,i),j=1,3)
15646 !el write (iout,'(5x,3(3f10.5,5x))') &
15647 !el (dphinum(j,1,i)/dphi(j,1,i),j=1,3),&
15648 !el (dphinum(j,2,i)/dphi(j,2,i),j=1,3),&
15649 !el (dphinum(j,3,i)/dphi(j,3,i),j=1,3)
15652 ! Check alpha gradient
15654 "Analytical (upper) and numerical (lower) gradient of alpha"
15656 if(itype(i).ne.10) then
15659 dc(j,i-1)=dcji+aincr
15660 call chainbuild_cart
15661 dalphanum(j,1,i)=(alph(i)-alph_s(i)) &
15666 call chainbuild_cart
15667 dalphanum(j,2,i)=(alph(i)-alph_s(i)) &
15671 dc(j,i+nres)=dc(j,i+nres)+aincr
15672 call chainbuild_cart
15673 dalphanum(j,3,i)=(alph(i)-alph_s(i)) &
15678 !el write (iout,'(i5,3(3f10.5,5x))') i,(dalpha(j,1,i),j=1,3),&
15679 !el (dalpha(j,2,i),j=1,3),(dalpha(j,3,i),j=1,3)
15680 !el write (iout,'(5x,3(3f10.5,5x))') (dalphanum(j,1,i),j=1,3),&
15681 !el (dalphanum(j,2,i),j=1,3),(dalphanum(j,3,i),j=1,3)
15682 !el write (iout,'(5x,3(3f10.5,5x))') &
15683 !el (dalphanum(j,1,i)/dalpha(j,1,i),j=1,3),&
15684 !el (dalphanum(j,2,i)/dalpha(j,2,i),j=1,3),&
15685 !el (dalphanum(j,3,i)/dalpha(j,3,i),j=1,3)
15688 ! Check omega gradient
15690 "Analytical (upper) and numerical (lower) gradient of omega"
15692 if(itype(i).ne.10) then
15695 dc(j,i-1)=dcji+aincr
15696 call chainbuild_cart
15697 domeganum(j,1,i)=(omeg(i)-omeg_s(i)) &
15702 call chainbuild_cart
15703 domeganum(j,2,i)=(omeg(i)-omeg_s(i)) &
15707 dc(j,i+nres)=dc(j,i+nres)+aincr
15708 call chainbuild_cart
15709 domeganum(j,3,i)=(omeg(i)-omeg_s(i)) &
15714 !el write (iout,'(i5,3(3f10.5,5x))') i,(domega(j,1,i),j=1,3),&
15715 !el (domega(j,2,i),j=1,3),(domega(j,3,i),j=1,3)
15716 !el write (iout,'(5x,3(3f10.5,5x))') (domeganum(j,1,i),j=1,3),&
15717 !el (domeganum(j,2,i),j=1,3),(domeganum(j,3,i),j=1,3)
15718 !el write (iout,'(5x,3(3f10.5,5x))') &
15719 !el (domeganum(j,1,i)/domega(j,1,i),j=1,3),&
15720 !el (domeganum(j,2,i)/domega(j,2,i),j=1,3),&
15721 !el (domeganum(j,3,i)/domega(j,3,i),j=1,3)
15725 end subroutine checkintcartgrad
15726 !-----------------------------------------------------------------------------
15728 !-----------------------------------------------------------------------------
15729 real(kind=8) function qwolynes(seg1,seg2,flag,seg3,seg4)
15730 ! implicit real*8 (a-h,o-z)
15731 ! include 'DIMENSIONS'
15732 ! include 'COMMON.IOUNITS'
15733 ! include 'COMMON.CHAIN'
15734 ! include 'COMMON.INTERACT'
15735 ! include 'COMMON.VAR'
15736 integer :: i,j,jl,k,l,il,kl,nl,np,ip,kp,seg1,seg2,seg3,seg4,secseg
15737 integer :: kkk,nsep=3
15738 real(kind=8) :: qm !dist,
15739 real(kind=8) :: qq,qqij,qqijCM,dij,d0ij,dijCM,d0ijCM,qqmax
15740 logical :: lprn=.false.
15742 ! real(kind=8) :: sigm,x
15744 !el sigm(x)=0.25d0*x ! local function
15750 do il=seg1+nsep,seg2
15753 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2 + &
15754 (cref(2,jl,kkk)-cref(2,il,kkk))**2 + &
15755 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
15757 qqij = dexp(-0.5d0*((dij-d0ij)/(sigm(d0ij)))**2)
15758 if (itype(il).ne.10 .or. itype(jl).ne.10) then
15761 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
15762 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
15763 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
15764 dijCM=dist(il+nres,jl+nres)
15765 qqijCM = dexp(-0.5d0*((dijCM-d0ijCM)/(sigm(d0ijCM)))**2)
15767 qq = qq+qqij+qqijCM
15773 if((seg3-il).lt.3) then
15780 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2+ &
15781 (cref(2,jl,kkk)-cref(2,il,kkk))**2+ &
15782 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
15784 qqij = dexp(-0.5d0*((dij-d0ij)/(sigm(d0ij)))**2)
15785 if (itype(il).ne.10 .or. itype(jl).ne.10) then
15788 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
15789 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
15790 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
15791 dijCM=dist(il+nres,jl+nres)
15792 qqijCM = dexp(-0.5d0*((dijCM-d0ijCM)/(sigm(d0ijCM)))**2)
15794 qq = qq+qqij+qqijCM
15799 if (qqmax.le.qq) qqmax=qq
15801 qwolynes=1.0d0-qqmax
15803 end function qwolynes
15804 !-----------------------------------------------------------------------------
15805 subroutine qwolynes_prim(seg1,seg2,flag,seg3,seg4)
15806 ! implicit real*8 (a-h,o-z)
15807 ! include 'DIMENSIONS'
15808 ! include 'COMMON.IOUNITS'
15809 ! include 'COMMON.CHAIN'
15810 ! include 'COMMON.INTERACT'
15811 ! include 'COMMON.VAR'
15812 ! include 'COMMON.MD'
15813 integer :: i,j,jl,k,l,il,nl,seg1,seg2,seg3,seg4,secseg
15814 integer :: nsep=3, kkk
15815 !el real(kind=8) :: dist
15816 real(kind=8) :: dij,d0ij,dijCM,d0ijCM
15817 logical :: lprn=.false.
15819 real(kind=8) :: sim,dd0,fac,ddqij
15820 !el sigm(x)=0.25d0*x ! local function
15830 do il=seg1+nsep,seg2
15833 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2+ &
15834 (cref(2,jl,kkk)-cref(2,il,kkk))**2+ &
15835 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
15837 sim = 1.0d0/sigm(d0ij)
15840 fac = dd0*sim/dij*dexp(-0.5d0*dd0*dd0*sim)
15842 ddqij = (c(k,il)-c(k,jl))*fac
15843 dqwol(k,il)=dqwol(k,il)+ddqij
15844 dqwol(k,jl)=dqwol(k,jl)-ddqij
15847 if (itype(il).ne.10 .or. itype(jl).ne.10) then
15850 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
15851 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
15852 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
15853 dijCM=dist(il+nres,jl+nres)
15854 sim = 1.0d0/sigm(d0ijCM)
15857 fac=dd0*sim/dijCM*dexp(-0.5d0*dd0*dd0*sim)
15859 ddqij = (c(k,il+nres)-c(k,jl+nres))*fac
15860 dxqwol(k,il)=dxqwol(k,il)+ddqij
15861 dxqwol(k,jl)=dxqwol(k,jl)-ddqij
15868 if((seg3-il).lt.3) then
15875 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2+ &
15876 (cref(2,jl,kkk)-cref(2,il,kkk))**2+ &
15877 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
15879 sim = 1.0d0/sigm(d0ij)
15882 fac = dd0*sim/dij*dexp(-0.5d0*dd0*dd0*sim)
15884 ddqij = (c(k,il)-c(k,jl))*fac
15885 dqwol(k,il)=dqwol(k,il)+ddqij
15886 dqwol(k,jl)=dqwol(k,jl)-ddqij
15888 if (itype(il).ne.10 .or. itype(jl).ne.10) then
15891 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
15892 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
15893 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
15894 dijCM=dist(il+nres,jl+nres)
15895 sim = 1.0d0/sigm(d0ijCM)
15898 fac = dd0*sim/dijCM*dexp(-0.5d0*dd0*dd0*sim)
15900 ddqij = (c(k,il+nres)-c(k,jl+nres))*fac
15901 dxqwol(k,il)=dxqwol(k,il)+ddqij
15902 dxqwol(k,jl)=dxqwol(k,jl)-ddqij
15911 dqwol(j,i)=dqwol(j,i)/nl
15912 dxqwol(j,i)=dxqwol(j,i)/nl
15916 end subroutine qwolynes_prim
15917 !-----------------------------------------------------------------------------
15918 subroutine qwol_num(seg1,seg2,flag,seg3,seg4)
15919 ! implicit real*8 (a-h,o-z)
15920 ! include 'DIMENSIONS'
15921 ! include 'COMMON.IOUNITS'
15922 ! include 'COMMON.CHAIN'
15923 ! include 'COMMON.INTERACT'
15924 ! include 'COMMON.VAR'
15925 integer :: seg1,seg2,seg3,seg4
15927 real(kind=8),dimension(3,0:nres) :: qwolan,qwolxan
15928 real(kind=8),dimension(3,0:2*nres) :: cdummy
15929 real(kind=8) :: q1,q2
15930 real(kind=8) :: delta=1.0d-10
15935 q1=qwolynes(seg1,seg2,flag,seg3,seg4)
15937 c(j,i)=c(j,i)+delta
15938 q2=qwolynes(seg1,seg2,flag,seg3,seg4)
15939 qwolan(j,i)=(q2-q1)/delta
15945 q1=qwolynes(seg1,seg2,flag,seg3,seg4)
15946 cdummy(j,i+nres)=c(j,i+nres)
15947 c(j,i+nres)=c(j,i+nres)+delta
15948 q2=qwolynes(seg1,seg2,flag,seg3,seg4)
15949 qwolxan(j,i)=(q2-q1)/delta
15950 c(j,i+nres)=cdummy(j,i+nres)
15953 ! write(iout,*) "Numerical Q carteisan gradients backbone: "
15955 ! write(iout,'(i5,3e15.5)') i, (qwolan(j,i),j=1,3)
15957 ! write(iout,*) "Numerical Q carteisan gradients side-chain: "
15959 ! write(iout,'(i5,3e15.5)') i, (qwolxan(j,i),j=1,3)
15962 end subroutine qwol_num
15963 !-----------------------------------------------------------------------------
15964 subroutine EconstrQ
15965 ! MD with umbrella_sampling using Wolyne's distance measure as a constraint
15966 ! implicit real*8 (a-h,o-z)
15967 ! include 'DIMENSIONS'
15968 ! include 'COMMON.CONTROL'
15969 ! include 'COMMON.VAR'
15970 ! include 'COMMON.MD'
15973 ! include 'COMMON.LANGEVIN'
15975 ! include 'COMMON.LANGEVIN.lang0'
15977 ! include 'COMMON.CHAIN'
15978 ! include 'COMMON.DERIV'
15979 ! include 'COMMON.GEO'
15980 ! include 'COMMON.LOCAL'
15981 ! include 'COMMON.INTERACT'
15982 ! include 'COMMON.IOUNITS'
15983 ! include 'COMMON.NAMES'
15984 ! include 'COMMON.TIME1'
15985 real(kind=8) :: uzap1,uzap2,hm1,hm2,hmnum,ucdelan
15986 real(kind=8),dimension(3,0:nres) :: dUcartan,dUxcartan,cdummy,&
15988 integer :: kstart,kend,lstart,lend,idummy
15989 real(kind=8) :: delta=1.0d-7
15990 integer :: i,j,k,ii
15994 dudconst(j,i)=0.0d0
15995 duxconst(j,i)=0.0d0
15996 dudxconst(j,i)=0.0d0
16001 qfrag(i)=qwolynes(ifrag(1,i,iset),ifrag(2,i,iset),.true.,&
16003 Uconst=Uconst+wfrag(i,iset)*harmonic(qfrag(i),qinfrag(i,iset))
16004 ! Calculating the derivatives of Constraint energy with respect to Q
16005 Ucdfrag=wfrag(i,iset)*harmonicprim(qfrag(i),&
16007 ! hm1=harmonic(qfrag(i,iset),qinfrag(i,iset))
16008 ! hm2=harmonic(qfrag(i,iset)+delta,qinfrag(i,iset))
16009 ! hmnum=(hm2-hm1)/delta
16010 ! write(iout,*) "harmonicprim frag",harmonicprim(qfrag(i,iset),
16011 ! & qinfrag(i,iset))
16012 ! write(iout,*) "harmonicnum frag", hmnum
16013 ! Calculating the derivatives of Q with respect to cartesian coordinates
16014 call qwolynes_prim(ifrag(1,i,iset),ifrag(2,i,iset),.true.,&
16016 ! write(iout,*) "dqwol "
16018 ! write(iout,'(i5,3e15.5)') ii,(dqwol(j,ii),j=1,3)
16020 ! write(iout,*) "dxqwol "
16022 ! write(iout,'(i5,3e15.5)') ii,(dxqwol(j,ii),j=1,3)
16024 ! Calculating numerical gradients of dU/dQi and dQi/dxi
16025 ! call qwol_num(ifrag(1,i,iset),ifrag(2,i,iset),.true.
16026 ! & ,idummy,idummy)
16027 ! The gradients of Uconst in Cs
16030 duconst(j,ii)=dUconst(j,ii)+ucdfrag*dqwol(j,ii)
16031 dUxconst(j,ii)=dUxconst(j,ii)+ucdfrag*dxqwol(j,ii)
16036 kstart=ifrag(1,ipair(1,i,iset),iset)
16037 kend=ifrag(2,ipair(1,i,iset),iset)
16038 lstart=ifrag(1,ipair(2,i,iset),iset)
16039 lend=ifrag(2,ipair(2,i,iset),iset)
16040 qpair(i)=qwolynes(kstart,kend,.false.,lstart,lend)
16041 Uconst=Uconst+wpair(i,iset)*harmonic(qpair(i),qinpair(i,iset))
16042 ! Calculating dU/dQ
16043 Ucdpair=wpair(i,iset)*harmonicprim(qpair(i),qinpair(i,iset))
16044 ! hm1=harmonic(qpair(i),qinpair(i,iset))
16045 ! hm2=harmonic(qpair(i)+delta,qinpair(i,iset))
16046 ! hmnum=(hm2-hm1)/delta
16047 ! write(iout,*) "harmonicprim pair ",harmonicprim(qpair(i),
16048 ! & qinpair(i,iset))
16049 ! write(iout,*) "harmonicnum pair ", hmnum
16050 ! Calculating dQ/dXi
16051 call qwolynes_prim(kstart,kend,.false.,&
16053 ! write(iout,*) "dqwol "
16055 ! write(iout,'(i5,3e15.5)') ii,(dqwol(j,ii),j=1,3)
16057 ! write(iout,*) "dxqwol "
16059 ! write(iout,'(i5,3e15.5)') ii,(dxqwol(j,ii),j=1,3)
16061 ! Calculating numerical gradients
16062 ! call qwol_num(kstart,kend,.false.
16064 ! The gradients of Uconst in Cs
16067 duconst(j,ii)=dUconst(j,ii)+ucdpair*dqwol(j,ii)
16068 dUxconst(j,ii)=dUxconst(j,ii)+ucdpair*dxqwol(j,ii)
16072 ! write(iout,*) "Uconst inside subroutine ", Uconst
16073 ! Transforming the gradients from Cs to dCs for the backbone
16077 dudconst(k,i)=dudconst(k,i)+duconst(k,j)+duxconst(k,j)
16081 ! Transforming the gradients from Cs to dCs for the side chains
16084 dudxconst(j,i)=duxconst(j,i)
16087 ! write(iout,*) "dU/ddc backbone "
16089 ! write(iout,'(i5,3e15.5)') ii, (dudconst(j,ii),j=1,3)
16091 ! write(iout,*) "dU/ddX side chain "
16093 ! write(iout,'(i5,3e15.5)') ii,(duxconst(j,ii),j=1,3)
16095 ! Calculating numerical gradients of dUconst/ddc and dUconst/ddx
16096 ! call dEconstrQ_num
16098 end subroutine EconstrQ
16099 !-----------------------------------------------------------------------------
16100 subroutine dEconstrQ_num
16101 ! Calculating numerical dUconst/ddc and dUconst/ddx
16102 ! implicit real*8 (a-h,o-z)
16103 ! include 'DIMENSIONS'
16104 ! include 'COMMON.CONTROL'
16105 ! include 'COMMON.VAR'
16106 ! include 'COMMON.MD'
16109 ! include 'COMMON.LANGEVIN'
16111 ! include 'COMMON.LANGEVIN.lang0'
16113 ! include 'COMMON.CHAIN'
16114 ! include 'COMMON.DERIV'
16115 ! include 'COMMON.GEO'
16116 ! include 'COMMON.LOCAL'
16117 ! include 'COMMON.INTERACT'
16118 ! include 'COMMON.IOUNITS'
16119 ! include 'COMMON.NAMES'
16120 ! include 'COMMON.TIME1'
16121 real(kind=8) :: uzap1,uzap2
16122 real(kind=8),dimension(3,0:nres) :: dUcartan,dUxcartan,cdummy
16123 integer :: kstart,kend,lstart,lend,idummy
16124 real(kind=8) :: delta=1.0d-7
16125 !el local variables
16131 dUcartan(j,i)=0.0d0
16132 cdummy(j,i)=dc(j,i)
16133 dc(j,i)=dc(j,i)+delta
16134 call chainbuild_cart
16137 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),.true.,&
16139 uzap2=uzap2+wfrag(ii,iset)*harmonic(qfrag(ii),&
16143 kstart=ifrag(1,ipair(1,ii,iset),iset)
16144 kend=ifrag(2,ipair(1,ii,iset),iset)
16145 lstart=ifrag(1,ipair(2,ii,iset),iset)
16146 lend=ifrag(2,ipair(2,ii,iset),iset)
16147 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
16148 uzap2=uzap2+wpair(ii,iset)*harmonic(qpair(ii),&
16151 dc(j,i)=cdummy(j,i)
16152 call chainbuild_cart
16155 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),.true.,&
16157 uzap1=uzap1+wfrag(ii,iset)*harmonic(qfrag(ii),&
16161 kstart=ifrag(1,ipair(1,ii,iset),iset)
16162 kend=ifrag(2,ipair(1,ii,iset),iset)
16163 lstart=ifrag(1,ipair(2,ii,iset),iset)
16164 lend=ifrag(2,ipair(2,ii,iset),iset)
16165 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
16166 uzap1=uzap1+wpair(ii,iset)*harmonic(qpair(ii),&
16169 ducartan(j,i)=(uzap2-uzap1)/(delta)
16172 ! Calculating numerical gradients for dU/ddx
16174 duxcartan(j,i)=0.0d0
16176 cdummy(j,i)=dc(j,i+nres)
16177 dc(j,i+nres)=dc(j,i+nres)+delta
16178 call chainbuild_cart
16181 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),.true.,&
16183 uzap2=uzap2+wfrag(ii,iset)*harmonic(qfrag(ii),&
16187 kstart=ifrag(1,ipair(1,ii,iset),iset)
16188 kend=ifrag(2,ipair(1,ii,iset),iset)
16189 lstart=ifrag(1,ipair(2,ii,iset),iset)
16190 lend=ifrag(2,ipair(2,ii,iset),iset)
16191 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
16192 uzap2=uzap2+wpair(ii,iset)*harmonic(qpair(ii),&
16195 dc(j,i+nres)=cdummy(j,i)
16196 call chainbuild_cart
16199 qfrag(ii)=qwolynes(ifrag(1,ii,iset),&
16200 ifrag(2,ii,iset),.true.,idummy,idummy)
16201 uzap1=uzap1+wfrag(ii,iset)*harmonic(qfrag(ii),&
16205 kstart=ifrag(1,ipair(1,ii,iset),iset)
16206 kend=ifrag(2,ipair(1,ii,iset),iset)
16207 lstart=ifrag(1,ipair(2,ii,iset),iset)
16208 lend=ifrag(2,ipair(2,ii,iset),iset)
16209 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
16210 uzap1=uzap1+wpair(ii,iset)*harmonic(qpair(ii),&
16213 duxcartan(j,i)=(uzap2-uzap1)/(delta)
16216 write(iout,*) "Numerical dUconst/ddc backbone "
16218 write(iout,'(i5,3e15.5)') ii,(dUcartan(j,ii),j=1,3)
16220 ! write(iout,*) "Numerical dUconst/ddx side-chain "
16222 ! write(iout,'(i5,3e15.5)') ii,(dUxcartan(j,ii),j=1,3)
16225 end subroutine dEconstrQ_num
16226 !-----------------------------------------------------------------------------
16228 !-----------------------------------------------------------------------------
16229 subroutine check_energies
16231 ! use random, only: ran_number
16235 ! include 'DIMENSIONS'
16236 ! include 'COMMON.CHAIN'
16237 ! include 'COMMON.VAR'
16238 ! include 'COMMON.IOUNITS'
16239 ! include 'COMMON.SBRIDGE'
16240 ! include 'COMMON.LOCAL'
16241 ! include 'COMMON.GEO'
16243 ! External functions
16244 !EL double precision ran_number
16245 !EL external ran_number
16248 integer :: i,j,k,l,lmax,p,pmax
16249 real(kind=8) :: rmin,rmax
16250 real(kind=8) :: eij
16253 real(kind=8) :: wi,rij,tj,pj
16275 !t wi=ran_number(0.0D0,pi)
16276 ! wi=ran_number(0.0D0,pi/6.0D0)
16278 !t tj=ran_number(0.0D0,pi)
16279 !t pj=ran_number(0.0D0,pi)
16280 ! pj=ran_number(0.0D0,pi/6.0D0)
16284 !t rij=ran_number(rmin,rmax)
16286 c(1,j)=d*sin(pj)*cos(tj)
16287 c(2,j)=d*sin(pj)*sin(tj)
16293 c(3,i)=-rij-d*cos(wi)
16296 dc(k,nres+i)=c(k,nres+i)-c(k,i)
16297 dc_norm(k,nres+i)=dc(k,nres+i)/d
16298 dc(k,nres+j)=c(k,nres+j)-c(k,j)
16299 dc_norm(k,nres+j)=dc(k,nres+j)/d
16302 call dyn_ssbond_ene(i,j,eij)
16307 end subroutine check_energies
16308 !-----------------------------------------------------------------------------
16309 subroutine dyn_ssbond_ene(resi,resj,eij)
16314 ! include 'DIMENSIONS'
16315 ! include 'COMMON.SBRIDGE'
16316 ! include 'COMMON.CHAIN'
16317 ! include 'COMMON.DERIV'
16318 ! include 'COMMON.LOCAL'
16319 ! include 'COMMON.INTERACT'
16320 ! include 'COMMON.VAR'
16321 ! include 'COMMON.IOUNITS'
16322 ! include 'COMMON.CALC'
16326 ! include 'COMMON.MD'
16327 ! use MD, only: totT,t_bath
16330 ! External functions
16331 !EL double precision h_base
16332 !EL external h_base
16335 integer :: resi,resj
16338 real(kind=8) :: eij
16341 logical :: havebond
16342 integer itypi,itypj
16343 real(kind=8) :: rrij,ssd,deltat1,deltat2,deltat12,cosphi
16344 real(kind=8) :: sig0ij,ljd,sig,fac,e1,e2
16345 real(kind=8),dimension(3) :: dcosom1,dcosom2
16347 real(kind=8) :: pom1,pom2
16348 real(kind=8) :: ljA,ljB,ljXs
16349 real(kind=8),dimension(1:3) :: d_ljB
16350 real(kind=8) :: ssA,ssB,ssC,ssXs
16351 real(kind=8) :: ssxm,ljxm,ssm,ljm
16352 real(kind=8),dimension(1:3) :: d_ssxm,d_ljxm,d_ssm,d_ljm
16353 real(kind=8) :: f1,f2,h1,h2,hd1,hd2
16354 real(kind=8) :: omega,delta_inv,deltasq_inv,fac1,fac2
16355 !-------FIRST METHOD
16357 real(kind=8),dimension(1:3) :: d_xm
16358 !-------END FIRST METHOD
16359 !-------SECOND METHOD
16360 !$$$ double precision ss,d_ss(0:3),ljf,d_ljf(0:3)
16361 !-------END SECOND METHOD
16363 !-------TESTING CODE
16364 !el logical :: checkstop,transgrad
16365 !el common /sschecks/ checkstop,transgrad
16367 integer :: icheck,nicheck,jcheck,njcheck
16368 real(kind=8),dimension(-1:1) :: echeck
16369 real(kind=8) :: deps,ssx0,ljx0
16370 !-------END TESTING CODE
16376 !el allocate(dyn_ssbond_ij(iatsc_s:iatsc_e,nres))
16377 !el allocate(dyn_ssbond_ij(0:nres+4,nres))
16380 dxi=dc_norm(1,nres+i)
16381 dyi=dc_norm(2,nres+i)
16382 dzi=dc_norm(3,nres+i)
16383 dsci_inv=vbld_inv(i+nres)
16386 xj=c(1,nres+j)-c(1,nres+i)
16387 yj=c(2,nres+j)-c(2,nres+i)
16388 zj=c(3,nres+j)-c(3,nres+i)
16389 dxj=dc_norm(1,nres+j)
16390 dyj=dc_norm(2,nres+j)
16391 dzj=dc_norm(3,nres+j)
16392 dscj_inv=vbld_inv(j+nres)
16394 chi1=chi(itypi,itypj)
16395 chi2=chi(itypj,itypi)
16402 alf12=0.5D0*(alf1+alf2)
16404 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
16405 rij=dsqrt(rrij) ! sc_angular needs rij to really be the inverse
16406 ! The following are set in sc_angular
16410 ! om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
16411 ! om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
16412 ! om12=dxi*dxj+dyi*dyj+dzi*dzj
16414 rij=1.0D0/rij ! Reset this so it makes sense
16416 sig0ij=sigma(itypi,itypj)
16417 sig=sig0ij*dsqrt(1.0D0/sigsq)
16420 ljA=eps1*eps2rt**2*eps3rt**2
16421 ljB=ljA*bb(itypi,itypj)
16422 ljA=ljA*aa(itypi,itypj)
16423 ljxm=ljXs+(-2.0D0*aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
16428 deltat12=om2-om1+2.0d0
16429 cosphi=om12-om1*om2
16433 +akth*(deltat1*deltat1+deltat2*deltat2) &
16434 +v1ss*cosphi+v2ss*cosphi*cosphi+v3ss*cosphi*cosphi*cosphi
16435 ssxm=ssXs-0.5D0*ssB/ssA
16437 !-------TESTING CODE
16438 !$$$c Some extra output
16439 !$$$ ssm=ssC-0.25D0*ssB*ssB/ssA
16440 !$$$ ljm=-0.25D0*ljB*bb(itypi,itypj)/aa(itypi,itypj)
16441 !$$$ ssx0=ssB*ssB-4.0d0*ssA*ssC
16442 !$$$ if (ssx0.gt.0.0d0) then
16443 !$$$ ssx0=ssXs+0.5d0*(-ssB+sqrt(ssx0))/ssA
16447 !$$$ ljx0=ljXs+(-aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
16448 !$$$ write(iout,'(a,4f8.2,2f15.2,3f6.2)')"SSENERGIES ",
16449 !$$$ & ssxm,ljxm,ssx0,ljx0,ssm,ljm,om1,om2,om12
16451 !-------END TESTING CODE
16453 !-------TESTING CODE
16454 ! Stop and plot energy and derivative as a function of distance
16455 if (checkstop) then
16456 ssm=ssC-0.25D0*ssB*ssB/ssA
16457 ljm=-0.25D0*ljB*bb(itypi,itypj)/aa(itypi,itypj)
16458 if (ssm.lt.ljm .and. &
16459 dabs(rij-0.5d0*(ssxm+ljxm)).lt.0.35d0*(ljxm-ssxm)) then
16467 if (.not.checkstop) then
16472 do icheck=0,nicheck
16473 do jcheck=-1,njcheck
16474 if (checkstop) rij=(ssxm-1.0d0)+ &
16475 ((ljxm-ssxm+2.0d0)*icheck)/nicheck+jcheck*deps
16476 !-------END TESTING CODE
16478 if (rij.gt.ljxm) then
16481 fac=(1.0D0/ljd)**expon
16482 e1=fac*fac*aa(itypi,itypj)
16483 e2=fac*bb(itypi,itypj)
16484 eij=eps1*eps2rt*eps3rt*(e1+e2)
16487 eij=eij*eps2rt*eps3rt
16490 e1=e1*eps1*eps2rt**2*eps3rt**2
16491 ed=-expon*(e1+eij)/ljd
16493 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
16494 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
16495 eom12=eij*eps1_om12+eps2der*eps2rt_om12 &
16496 -2.0D0*alf12*eps3der+sigder*sigsq_om12
16497 else if (rij.lt.ssxm) then
16500 eij=ssA*ssd*ssd+ssB*ssd+ssC
16502 ed=2*akcm*ssd+akct*deltat12
16504 pom2=v1ss+2*v2ss*cosphi+3*v3ss*cosphi*cosphi
16505 eom1=-2*akth*deltat1-pom1-om2*pom2
16506 eom2= 2*akth*deltat2+pom1-om1*pom2
16509 omega=v1ss+2.0d0*v2ss*cosphi+3.0d0*v3ss*cosphi*cosphi
16511 d_ssxm(1)=0.5D0*akct/ssA
16512 d_ssxm(2)=-d_ssxm(1)
16515 d_ljxm(1)=sig0ij/sqrt(sigsq**3)
16516 d_ljxm(2)=d_ljxm(1)*sigsq_om2
16517 d_ljxm(3)=d_ljxm(1)*sigsq_om12
16518 d_ljxm(1)=d_ljxm(1)*sigsq_om1
16520 !-------FIRST METHOD, DISCONTINUOUS SECOND DERIVATIVE
16521 xm=0.5d0*(ssxm+ljxm)
16523 d_xm(k)=0.5d0*(d_ssxm(k)+d_ljxm(k))
16525 if (rij.lt.xm) then
16527 ssm=ssC-0.25D0*ssB*ssB/ssA
16528 d_ssm(1)=0.5D0*akct*ssB/ssA
16529 d_ssm(2)=2.0D0*akth*deltat2-om1*omega-d_ssm(1)
16530 d_ssm(1)=-2.0D0*akth*deltat1-om2*omega+d_ssm(1)
16532 f1=(rij-xm)/(ssxm-xm)
16533 f2=(rij-ssxm)/(xm-ssxm)
16537 delta_inv=1.0d0/(xm-ssxm)
16538 deltasq_inv=delta_inv*delta_inv
16540 fac1=deltasq_inv*fac*(xm-rij)
16541 fac2=deltasq_inv*fac*(rij-ssxm)
16542 ed=delta_inv*(Ht*hd2-ssm*hd1)
16543 eom1=fac1*d_ssxm(1)+fac2*d_xm(1)+h1*d_ssm(1)
16544 eom2=fac1*d_ssxm(2)+fac2*d_xm(2)+h1*d_ssm(2)
16545 eom12=fac1*d_ssxm(3)+fac2*d_xm(3)+h1*d_ssm(3)
16548 ljm=-0.25D0*ljB*bb(itypi,itypj)/aa(itypi,itypj)
16549 d_ljm(1)=-0.5D0*bb(itypi,itypj)/aa(itypi,itypj)*ljB
16550 d_ljm(2)=d_ljm(1)*(0.5D0*eps2rt_om2/eps2rt+alf2/eps3rt)
16551 d_ljm(3)=d_ljm(1)*(0.5D0*eps1_om12+0.5D0*eps2rt_om12/eps2rt- &
16553 d_ljm(1)=d_ljm(1)*(0.5D0*eps2rt_om1/eps2rt-alf1/eps3rt)
16554 f1=(rij-ljxm)/(xm-ljxm)
16555 f2=(rij-xm)/(ljxm-xm)
16559 delta_inv=1.0d0/(ljxm-xm)
16560 deltasq_inv=delta_inv*delta_inv
16562 fac1=deltasq_inv*fac*(ljxm-rij)
16563 fac2=deltasq_inv*fac*(rij-xm)
16564 ed=delta_inv*(ljm*hd2-Ht*hd1)
16565 eom1=fac1*d_xm(1)+fac2*d_ljxm(1)+h2*d_ljm(1)
16566 eom2=fac1*d_xm(2)+fac2*d_ljxm(2)+h2*d_ljm(2)
16567 eom12=fac1*d_xm(3)+fac2*d_ljxm(3)+h2*d_ljm(3)
16569 !-------END FIRST METHOD, DISCONTINUOUS SECOND DERIVATIVE
16571 !-------SECOND METHOD, CONTINUOUS SECOND DERIVATIVE
16577 !$$$ d_ljB(1)=ljB*(eps2rt_om1/eps2rt-2.0d0*alf1/eps3rt)
16578 !$$$ d_ljB(2)=ljB*(eps2rt_om2/eps2rt+2.0d0*alf2/eps3rt)
16579 !$$$ d_ljB(3)=ljB*(eps1_om12+eps2rt_om12/eps2rt-2.0d0*alf12/eps3rt)
16581 !$$$ ssm=ssC-0.25D0*ssB*ssB/ssA
16582 !$$$ d_ssm(1)=0.5D0*akct*ssB/ssA
16583 !$$$ d_ssm(2)=2.0D0*akth*deltat2-om1*omega-d_ssm(1)
16584 !$$$ d_ssm(1)=-2.0D0*akth*deltat1-om2*omega+d_ssm(1)
16585 !$$$ d_ssm(3)=omega
16587 !$$$ ljm=-0.25D0*bb(itypi,itypj)/aa(itypi,itypj)
16589 !$$$ d_ljm(k)=ljm*d_ljB(k)
16593 !$$$ ss=ssA*ssd*ssd+ssB*ssd+ssC
16594 !$$$ d_ss(0)=2.0d0*ssA*ssd+ssB
16595 !$$$ d_ss(2)=akct*ssd
16596 !$$$ d_ss(1)=-d_ss(2)-2.0d0*akth*deltat1-om2*omega
16597 !$$$ d_ss(2)=d_ss(2)+2.0d0*akth*deltat2-om1*omega
16600 !$$$ ljf=bb(itypi,itypj)/aa(itypi,itypj)
16601 !$$$ ljf=9.0d0*ljf*(-0.5d0*ljf)**(1.0d0/3.0d0)
16602 !$$$ d_ljf(0)=ljf*2.0d0*ljB*fac1
16604 !$$$ d_ljf(k)=d_ljm(k)+ljf*(d_ljB(k)*fac1*fac1-
16605 !$$$ & 2.0d0*ljB*fac1*d_ljxm(k))
16607 !$$$ ljf=ljm+ljf*ljB*fac1*fac1
16609 !$$$ f1=(rij-ljxm)/(ssxm-ljxm)
16610 !$$$ f2=(rij-ssxm)/(ljxm-ssxm)
16611 !$$$ h1=h_base(f1,hd1)
16612 !$$$ h2=h_base(f2,hd2)
16613 !$$$ eij=ss*h1+ljf*h2
16614 !$$$ delta_inv=1.0d0/(ljxm-ssxm)
16615 !$$$ deltasq_inv=delta_inv*delta_inv
16616 !$$$ fac=ljf*hd2-ss*hd1
16617 !$$$ ed=d_ss(0)*h1+d_ljf(0)*h2+delta_inv*fac
16618 !$$$ eom1=d_ss(1)*h1+d_ljf(1)*h2+deltasq_inv*fac*
16619 !$$$ & (fac1*d_ssxm(1)-fac2*(d_ljxm(1)))
16620 !$$$ eom2=d_ss(2)*h1+d_ljf(2)*h2+deltasq_inv*fac*
16621 !$$$ & (fac1*d_ssxm(2)-fac2*(d_ljxm(2)))
16622 !$$$ eom12=d_ss(3)*h1+d_ljf(3)*h2+deltasq_inv*fac*
16623 !$$$ & (fac1*d_ssxm(3)-fac2*(d_ljxm(3)))
16625 !$$$ havebond=.false.
16626 !$$$ if (ed.gt.0.0d0) havebond=.true.
16627 !-------END SECOND METHOD, CONTINUOUS SECOND DERIVATIVE
16634 ! if (dyn_ssbond_ij(i,j).eq.1.0d300) then
16635 ! write(iout,'(a15,f12.2,f8.1,2i5)')
16636 ! & "SSBOND_E_FORM",totT,t_bath,i,j
16640 dyn_ssbond_ij(i,j)=eij
16641 else if (.not.havebond .and. dyn_ssbond_ij(i,j).lt.1.0d300) then
16642 dyn_ssbond_ij(i,j)=1.0d300
16645 ! write(iout,'(a15,f12.2,f8.1,2i5)')
16646 ! & "SSBOND_E_BREAK",totT,t_bath,i,j
16651 !-------TESTING CODE
16652 !el if (checkstop) then
16653 if (jcheck.eq.0) write(iout,'(a,3f15.8,$)') &
16654 "CHECKSTOP",rij,eij,ed
16658 if (checkstop) then
16659 write(iout,'(f15.8)')(echeck(1)-echeck(-1))*0.5d0/deps
16662 if (checkstop) then
16666 !-------END TESTING CODE
16669 dcosom1(k)=(dc_norm(k,nres+i)-om1*erij(k))/rij
16670 dcosom2(k)=(dc_norm(k,nres+j)-om2*erij(k))/rij
16673 gg(k)=ed*erij(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
16676 gvdwx(k,i)=gvdwx(k,i)-gg(k) &
16677 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
16678 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
16679 gvdwx(k,j)=gvdwx(k,j)+gg(k) &
16680 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
16681 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
16685 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
16690 gvdwc(l,i)=gvdwc(l,i)-gg(l)
16691 gvdwc(l,j)=gvdwc(l,j)+gg(l)
16695 end subroutine dyn_ssbond_ene
16696 !-----------------------------------------------------------------------------
16697 real(kind=8) function h_base(x,deriv)
16698 ! A smooth function going 0->1 in range [0,1]
16699 ! It should NOT be called outside range [0,1], it will not work there.
16706 real(kind=8) :: deriv
16709 real(kind=8) :: xsq
16712 ! Two parabolas put together. First derivative zero at extrema
16713 !$$$ if (x.lt.0.5D0) then
16714 !$$$ h_base=2.0D0*x*x
16718 !$$$ h_base=1.0D0-2.0D0*deriv*deriv
16719 !$$$ deriv=4.0D0*deriv
16722 ! Third degree polynomial. First derivative zero at extrema
16723 h_base=x*x*(3.0d0-2.0d0*x)
16724 deriv=6.0d0*x*(1.0d0-x)
16726 ! Fifth degree polynomial. First and second derivatives zero at extrema
16728 !$$$ h_base=x*xsq*(6.0d0*xsq-15.0d0*x+10.0d0)
16730 !$$$ deriv=deriv*deriv
16731 !$$$ deriv=30.0d0*xsq*deriv
16734 end function h_base
16735 !-----------------------------------------------------------------------------
16736 subroutine dyn_set_nss
16737 ! Adjust nss and other relevant variables based on dyn_ssbond_ij
16739 use MD_data, only: totT,t_bath
16741 ! include 'DIMENSIONS'
16745 ! include 'COMMON.SBRIDGE'
16746 ! include 'COMMON.CHAIN'
16747 ! include 'COMMON.IOUNITS'
16748 ! include 'COMMON.SETUP'
16749 ! include 'COMMON.MD'
16751 real(kind=8) :: emin
16752 integer :: i,j,imin,ierr
16753 integer :: diff,allnss,newnss
16754 integer,dimension(maxdim) :: allflag,allihpb,alljhpb,& !(maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
16757 integer,dimension(0:nfgtasks) :: i_newnss
16758 integer,dimension(0:nfgtasks) :: displ
16759 integer,dimension(maxdim) :: g_newihpb,g_newjhpb !(maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
16760 integer :: g_newnss
16765 if (dyn_ssbond_ij(i,j).lt.1.0d300) then
16774 !mc write(iout,*)"ALLNSS ",allnss,(allihpb(i),alljhpb(i),i=1,allnss)
16778 if (allflag(i).eq.0 .and. &
16779 dyn_ssbond_ij(allihpb(i),alljhpb(i)).lt.emin) then
16780 emin=dyn_ssbond_ij(allihpb(i),alljhpb(i))
16784 if (emin.lt.1.0d300) then
16787 if (allflag(i).eq.0 .and. &
16788 (allihpb(i).eq.allihpb(imin) .or. &
16789 alljhpb(i).eq.allihpb(imin) .or. &
16790 allihpb(i).eq.alljhpb(imin) .or. &
16791 alljhpb(i).eq.alljhpb(imin))) then
16798 !mc write(iout,*)"ALLNSS ",allnss,(allihpb(i),alljhpb(i),i=1,allnss)
16802 if (allflag(i).eq.1) then
16804 newihpb(newnss)=allihpb(i)
16805 newjhpb(newnss)=alljhpb(i)
16810 if (nfgtasks.gt.1)then
16812 call MPI_Reduce(newnss,g_newnss,1,&
16813 MPI_INTEGER,MPI_SUM,king,FG_COMM,IERR)
16814 call MPI_Gather(newnss,1,MPI_INTEGER,&
16815 i_newnss,1,MPI_INTEGER,king,FG_COMM,IERR)
16817 do i=1,nfgtasks-1,1
16818 displ(i)=i_newnss(i-1)+displ(i-1)
16820 call MPI_Gatherv(newihpb,newnss,MPI_INTEGER,&
16821 g_newihpb,i_newnss,displ,MPI_INTEGER,&
16823 call MPI_Gatherv(newjhpb,newnss,MPI_INTEGER,&
16824 g_newjhpb,i_newnss,displ,MPI_INTEGER,&
16826 if(fg_rank.eq.0) then
16827 ! print *,'g_newnss',g_newnss
16828 ! print *,'g_newihpb',(g_newihpb(i),i=1,g_newnss)
16829 ! print *,'g_newjhpb',(g_newjhpb(i),i=1,g_newnss)
16832 newihpb(i)=g_newihpb(i)
16833 newjhpb(i)=g_newjhpb(i)
16841 !mc write(iout,*)"NEWNSS ",newnss,(newihpb(i),newjhpb(i),i=1,newnss)
16846 if (idssb(i).eq.newihpb(j) .and. &
16847 jdssb(i).eq.newjhpb(j)) found=.true.
16851 if (.not.found.and.fg_rank.eq.0) &
16852 write(iout,'(a15,f12.2,f8.1,2i5)') &
16853 "SSBOND_BREAK",totT,t_bath,idssb(i),jdssb(i)
16861 if (newihpb(i).eq.idssb(j) .and. &
16862 newjhpb(i).eq.jdssb(j)) found=.true.
16866 if (.not.found.and.fg_rank.eq.0) &
16867 write(iout,'(a15,f12.2,f8.1,2i5)') &
16868 "SSBOND_FORM",totT,t_bath,newihpb(i),newjhpb(i)
16875 idssb(i)=newihpb(i)
16876 jdssb(i)=newjhpb(i)
16880 end subroutine dyn_set_nss
16881 !-----------------------------------------------------------------------------
16883 subroutine read_ssHist
16886 ! include 'DIMENSIONS'
16887 ! include "DIMENSIONS.FREE"
16888 ! include 'COMMON.FREE'
16891 character(len=80) :: controlcard
16894 call card_concat(controlcard,.true.)
16895 read(controlcard,*) &
16896 dyn_ssHist(i,0),(dyn_ssHist(i,j),j=1,2*dyn_ssHist(i,0))
16900 end subroutine read_ssHist
16902 !-----------------------------------------------------------------------------
16903 integer function indmat(i,j)
16905 ! get the position of the jth ijth fragment of the chain coordinate system
16906 ! in the fromto array.
16909 indmat=((2*(nres-2)-i)*(i-1))/2+j-1
16911 end function indmat
16912 !-----------------------------------------------------------------------------
16913 real(kind=8) function sigm(x)
16919 !-----------------------------------------------------------------------------
16920 !-----------------------------------------------------------------------------
16921 subroutine alloc_ener_arrays
16922 !EL Allocation of arrays used by module energy
16923 use MD_data, only: mset
16924 !el local variables
16927 if(nres.lt.100) then
16929 elseif(nres.lt.200) then
16930 maxconts=0.8*nres ! Max. number of contacts per residue
16932 maxconts=0.6*nres ! (maxconts=maxres/4)
16934 maxcont=12*nres ! Max. number of SC contacts
16935 maxvar=6*nres ! Max. number of variables
16936 !el maxdim=(nres-1)*(nres-2)/2 ! Max. number of derivatives of virtual-bond
16937 maxdim=nres*(nres-2)/2 ! Max. number of derivatives of virtual-bond
16938 !----------------------
16939 ! arrays in subroutine init_int_table
16941 !el allocate(itask_cont_from(0:nfgtasks-1)) !(0:max_fg_procs-1)
16942 !el allocate(itask_cont_to(0:nfgtasks-1)) !(0:max_fg_procs-1)
16944 allocate(nint_gr(nres))
16945 allocate(nscp_gr(nres))
16946 allocate(ielstart(nres))
16947 allocate(ielend(nres))
16949 allocate(istart(nres,maxint_gr))
16950 allocate(iend(nres,maxint_gr))
16951 !(maxres,maxint_gr)
16952 allocate(iscpstart(nres,maxint_gr))
16953 allocate(iscpend(nres,maxint_gr))
16954 !(maxres,maxint_gr)
16955 allocate(ielstart_vdw(nres))
16956 allocate(ielend_vdw(nres))
16959 allocate(lentyp(0:nfgtasks-1))
16961 !----------------------
16963 ! common /contacts/
16964 if(.not.allocated(icont_ref)) allocate(icont_ref(2,maxcont))
16965 allocate(icont(2,maxcont))
16967 ! common /contacts1/
16968 allocate(num_cont(0:nres+4))
16970 allocate(jcont(maxconts,nres))
16972 allocate(facont(maxconts,nres))
16974 allocate(gacont(3,maxconts,nres))
16975 !(3,maxconts,maxres)
16976 ! common /contacts_hb/
16977 allocate(gacontp_hb1(3,maxconts,nres))
16978 allocate(gacontp_hb2(3,maxconts,nres))
16979 allocate(gacontp_hb3(3,maxconts,nres))
16980 allocate(gacontm_hb1(3,maxconts,nres))
16981 allocate(gacontm_hb2(3,maxconts,nres))
16982 allocate(gacontm_hb3(3,maxconts,nres))
16983 allocate(gacont_hbr(3,maxconts,nres))
16984 allocate(grij_hb_cont(3,maxconts,nres))
16985 !(3,maxconts,maxres)
16986 allocate(facont_hb(maxconts,nres))
16987 allocate(ees0p(maxconts,nres))
16988 allocate(ees0m(maxconts,nres))
16989 allocate(d_cont(maxconts,nres))
16991 allocate(num_cont_hb(nres))
16993 allocate(jcont_hb(maxconts,nres))
16996 allocate(Ug(2,2,nres))
16997 allocate(Ugder(2,2,nres))
16998 allocate(Ug2(2,2,nres))
16999 allocate(Ug2der(2,2,nres))
17001 allocate(obrot(2,nres))
17002 allocate(obrot2(2,nres))
17003 allocate(obrot_der(2,nres))
17004 allocate(obrot2_der(2,nres))
17006 ! common /precomp1/
17007 allocate(mu(2,nres))
17008 allocate(muder(2,nres))
17009 allocate(Ub2(2,nres))
17012 allocate(Ub2der(2,nres))
17013 allocate(Ctobr(2,nres))
17014 allocate(Ctobrder(2,nres))
17015 allocate(Dtobr2(2,nres))
17016 allocate(Dtobr2der(2,nres))
17018 allocate(EUg(2,2,nres))
17019 allocate(EUgder(2,2,nres))
17020 allocate(CUg(2,2,nres))
17021 allocate(CUgder(2,2,nres))
17022 allocate(DUg(2,2,nres))
17023 allocate(Dugder(2,2,nres))
17024 allocate(DtUg2(2,2,nres))
17025 allocate(DtUg2der(2,2,nres))
17027 ! common /precomp2/
17028 allocate(Ug2Db1t(2,nres))
17029 allocate(Ug2Db1tder(2,nres))
17030 allocate(CUgb2(2,nres))
17031 allocate(CUgb2der(2,nres))
17033 allocate(EUgC(2,2,nres))
17034 allocate(EUgCder(2,2,nres))
17035 allocate(EUgD(2,2,nres))
17036 allocate(EUgDder(2,2,nres))
17037 allocate(DtUg2EUg(2,2,nres))
17038 allocate(Ug2DtEUg(2,2,nres))
17040 allocate(Ug2DtEUgder(2,2,2,nres))
17041 allocate(DtUg2EUgder(2,2,2,nres))
17043 ! common /rotat_old/
17044 allocate(costab(nres))
17045 allocate(sintab(nres))
17046 allocate(costab2(nres))
17047 allocate(sintab2(nres))
17050 allocate(a_chuj(2,2,maxconts,nres))
17051 !(2,2,maxconts,maxres)(maxconts=maxres/4)
17052 allocate(a_chuj_der(2,2,3,5,maxconts,nres))
17053 !(2,2,3,5,maxconts,maxres)(maxconts=maxres/4)
17054 ! common /contdistrib/
17055 allocate(ncont_sent(nres))
17056 allocate(ncont_recv(nres))
17058 allocate(iat_sent(nres))
17060 allocate(iint_sent(4,nres,nres))
17061 allocate(iint_sent_local(4,nres,nres))
17063 allocate(iturn3_sent(4,0:nres+4))
17064 allocate(iturn4_sent(4,0:nres+4))
17065 allocate(iturn3_sent_local(4,nres))
17066 allocate(iturn4_sent_local(4,nres))
17068 allocate(itask_cont_from(0:nfgtasks-1))
17069 allocate(itask_cont_to(0:nfgtasks-1))
17070 !(0:max_fg_procs-1)
17074 !----------------------
17077 allocate(dcdv(6,maxdim))
17078 allocate(dxdv(6,maxdim))
17080 allocate(dxds(6,nres))
17082 allocate(gradx(3,nres,0:2))
17083 allocate(gradc(3,nres,0:2))
17085 allocate(gvdwx(3,nres))
17086 allocate(gvdwc(3,nres))
17087 allocate(gelc(3,nres))
17088 allocate(gelc_long(3,nres))
17089 allocate(gvdwpp(3,nres))
17090 allocate(gvdwc_scpp(3,nres))
17091 allocate(gradx_scp(3,nres))
17092 allocate(gvdwc_scp(3,nres))
17093 allocate(ghpbx(3,nres))
17094 allocate(ghpbc(3,nres))
17095 allocate(gradcorr(3,nres))
17096 allocate(gradcorr_long(3,nres))
17097 allocate(gradcorr5_long(3,nres))
17098 allocate(gradcorr6_long(3,nres))
17099 allocate(gcorr6_turn_long(3,nres))
17100 allocate(gradxorr(3,nres))
17101 allocate(gradcorr5(3,nres))
17102 allocate(gradcorr6(3,nres))
17104 allocate(gloc(0:maxvar,0:2))
17105 allocate(gloc_x(0:maxvar,2))
17107 allocate(gel_loc(3,nres))
17108 allocate(gel_loc_long(3,nres))
17109 allocate(gcorr3_turn(3,nres))
17110 allocate(gcorr4_turn(3,nres))
17111 allocate(gcorr6_turn(3,nres))
17112 allocate(gradb(3,nres))
17113 allocate(gradbx(3,nres))
17115 allocate(gel_loc_loc(maxvar))
17116 allocate(gel_loc_turn3(maxvar))
17117 allocate(gel_loc_turn4(maxvar))
17118 allocate(gel_loc_turn6(maxvar))
17119 allocate(gcorr_loc(maxvar))
17120 allocate(g_corr5_loc(maxvar))
17121 allocate(g_corr6_loc(maxvar))
17123 allocate(gsccorc(3,nres))
17124 allocate(gsccorx(3,nres))
17126 allocate(gsccor_loc(nres))
17128 allocate(dtheta(3,2,nres))
17130 allocate(gscloc(3,nres))
17131 allocate(gsclocx(3,nres))
17133 allocate(dphi(3,3,nres))
17134 allocate(dalpha(3,3,nres))
17135 allocate(domega(3,3,nres))
17137 ! common /deriv_scloc/
17138 allocate(dXX_C1tab(3,nres))
17139 allocate(dYY_C1tab(3,nres))
17140 allocate(dZZ_C1tab(3,nres))
17141 allocate(dXX_Ctab(3,nres))
17142 allocate(dYY_Ctab(3,nres))
17143 allocate(dZZ_Ctab(3,nres))
17144 allocate(dXX_XYZtab(3,nres))
17145 allocate(dYY_XYZtab(3,nres))
17146 allocate(dZZ_XYZtab(3,nres))
17149 allocate(jgrad_start(nres))
17150 allocate(jgrad_end(nres))
17152 !----------------------
17155 allocate(ibond_displ(0:nfgtasks-1))
17156 allocate(ibond_count(0:nfgtasks-1))
17157 allocate(ithet_displ(0:nfgtasks-1))
17158 allocate(ithet_count(0:nfgtasks-1))
17159 allocate(iphi_displ(0:nfgtasks-1))
17160 allocate(iphi_count(0:nfgtasks-1))
17161 allocate(iphi1_displ(0:nfgtasks-1))
17162 allocate(iphi1_count(0:nfgtasks-1))
17163 allocate(ivec_displ(0:nfgtasks-1))
17164 allocate(ivec_count(0:nfgtasks-1))
17165 allocate(iset_displ(0:nfgtasks-1))
17166 allocate(iset_count(0:nfgtasks-1))
17167 allocate(iint_count(0:nfgtasks-1))
17168 allocate(iint_displ(0:nfgtasks-1))
17169 !(0:max_fg_procs-1)
17170 !----------------------
17173 allocate(gcart(3,0:nres))
17174 allocate(gxcart(3,0:nres))
17176 allocate(gradcag(3,nres))
17177 allocate(gradxag(3,nres))
17179 ! common /back_constr/
17180 !el in energy:Econstr_back allocate((:),allocatable :: utheta,ugamma,uscdiff !(maxfrag_back)
17181 allocate(dutheta(nres))
17182 allocate(dugamma(nres))
17184 allocate(duscdiff(3,nres))
17185 allocate(duscdiffx(3,nres))
17187 !el i io:read_fragments
17188 ! allocate((:,:,:),allocatable :: wfrag_back !(3,maxfrag_back,maxprocs/20)
17189 ! allocate((:,:,:),allocatable :: ifrag_back !(3,maxfrag_back,maxprocs/20)
17191 ! allocate(qinfrag(50,nprocs/20),wfrag(50,nprocs/20)) !(50,maxprocs/20)
17192 ! allocate(qinpair(100,nprocs/20),wpair(100,nprocs/20)) !(100,maxprocs/20)
17193 allocate(mset(0:nprocs)) !(maxprocs/20)
17195 ! allocate(ifrag(2,50,nprocs/20)) !(2,50,maxprocs/20)
17196 ! allocate(ipair(2,100,nprocs/20)) !(2,100,maxprocs/20)
17197 allocate(dUdconst(3,0:nres))
17198 allocate(dUdxconst(3,0:nres))
17199 allocate(dqwol(3,0:nres))
17200 allocate(dxqwol(3,0:nres))
17202 !----------------------
17204 ! common /sbridge/ in io_common: read_bridge
17205 !el allocate((:),allocatable :: iss !(maxss)
17206 ! common /links/ in io_common: read_bridge
17207 !el real(kind=8),dimension(:),allocatable :: dhpb,forcon,dhpb1 !(maxdim) !el dhpb1 !!! nie używane
17208 !el integer,dimension(:),allocatable :: ihpb,jhpb,ibecarb !(maxdim) !el ibecarb !!! nie używane
17209 ! common /dyn_ssbond/
17210 ! and side-chain vectors in theta or phi.
17211 allocate(dyn_ssbond_ij(0:nres+4,0:nres+4))
17215 dyn_ssbond_ij(:,:)=1.0d300
17220 allocate(idssb(nss),jdssb(nss))
17223 allocate(dyn_ss_mask(nres))
17225 dyn_ss_mask(:)=.false.
17226 !----------------------
17228 ! Parameters of the SCCOR term
17230 !el in io_conf: parmread
17231 ! allocate(v1sccor(maxterm_sccor,3,-ntyp:ntyp,-ntyp:ntyp))
17232 ! allocate(v2sccor(maxterm_sccor,3,-ntyp:ntyp,-ntyp:ntyp)) !(maxterm_sccor,3,-ntyp:ntyp,-ntyp:ntyp)
17233 ! allocate(v0sccor(maxterm_sccor,-ntyp:ntyp,-ntyp:ntyp)) !(maxterm_sccor,-ntyp:ntyp,-ntyp:ntyp)
17234 ! allocate(isccortyp(-ntyp:ntyp)) !(-ntyp:ntyp)
17235 ! allocate(nterm_sccor(-ntyp:ntyp,-ntyp:ntyp))
17236 ! allocate(nlor_sccor(-ntyp:ntyp,-ntyp:ntyp)) !(-ntyp:ntyp,-ntyp:ntyp)
17237 ! allocate(vlor1sccor(maxterm_sccor,20,20))
17238 ! allocate(vlor2sccor(maxterm_sccor,20,20))
17239 ! allocate(vlor3sccor(maxterm_sccor,20,20)) !(maxterm_sccor,20,20)
17241 allocate(gloc_sc(3,0:2*nres,0:10))
17242 !(3,0:maxres2,10)maxres2=2*maxres
17243 allocate(dcostau(3,3,3,2*nres))
17244 allocate(dsintau(3,3,3,2*nres))
17245 allocate(dtauangle(3,3,3,2*nres))
17246 allocate(dcosomicron(3,3,3,2*nres))
17247 allocate(domicron(3,3,3,2*nres))
17248 !(3,3,3,maxres2)maxres2=2*maxres
17249 !----------------------
17252 allocate(varall(maxvar))
17253 !(maxvar)(maxvar=6*maxres)
17254 allocate(mask_theta(nres))
17255 allocate(mask_phi(nres))
17256 allocate(mask_side(nres))
17258 !----------------------
17261 allocate(uy(3,nres))
17262 allocate(uz(3,nres))
17264 allocate(uygrad(3,3,2,nres))
17265 allocate(uzgrad(3,3,2,nres))
17269 end subroutine alloc_ener_arrays
17270 !-----------------------------------------------------------------------------
17271 !-----------------------------------------------------------------------------