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 ! Maximum number of local shielding effectors
33 integer,parameter :: maxcontsshi=50
34 !-----------------------------------------------------------------------------
35 ! commom.calc common/calc/
36 !-----------------------------------------------------------------------------
39 ! Change 12/1/95 - common block CONTACTS1 included.
42 integer,dimension(:),allocatable :: num_cont !(maxres)
43 integer,dimension(:,:),allocatable :: jcont !(maxconts,maxres)
44 real(kind=8),dimension(:,:),allocatable :: facont,ees0plist !(maxconts,maxres)
45 real(kind=8),dimension(:,:,:),allocatable :: gacont !(3,maxconts,maxres)
46 integer,dimension(:),allocatable :: ishield_list
47 integer,dimension(:,:),allocatable :: shield_list
48 real(kind=8),dimension(:),allocatable :: enetube,enecavtube
50 ! 12/26/95 - H-bonding contacts
51 ! common /contacts_hb/
52 real(kind=8),dimension(:,:,:),allocatable :: gacontp_hb1,gacontp_hb2,&
53 gacontp_hb3,gacontm_hb1,gacontm_hb2,gacontm_hb3,gacont_hbr,grij_hb_cont !(3,maxconts,maxres)
54 real(kind=8),dimension(:,:),allocatable :: facont_hb,ees0p,&
55 ees0m,d_cont !(maxconts,maxres)
56 integer,dimension(:),allocatable :: num_cont_hb !(maxres)
57 integer,dimension(:,:),allocatable :: jcont_hb !(maxconts,maxres)
58 ! 9/23/99 Added improper rotation matrices and matrices of dipole-dipole
60 ! 7/25/08 commented out; not needed when cumulants used
61 ! Interactions of pseudo-dipoles generated by loc-el interactions.
63 real(kind=8),dimension(:,:,:),allocatable :: dip,&
64 dipderg !(4,maxconts,maxres)
65 real(kind=8),dimension(:,:,:,:,:),allocatable :: dipderx !(3,5,4,maxconts,maxres)
66 ! 10/30/99 Added other pre-computed vectors and matrices needed
67 ! to calculate three - six-order el-loc correlation terms
69 real(kind=8),dimension(:,:,:),allocatable :: Ug,Ugder,Ug2,Ug2der !(2,2,maxres)
70 real(kind=8),dimension(:,:),allocatable :: obrot,obrot2,obrot_der,&
71 obrot2_der !(2,maxres)
73 ! This common block contains vectors and matrices dependent on a single
76 real(kind=8),dimension(:,:),allocatable :: mu,muder,Ub2,Ub2der,&
77 Ctobr,Ctobrder,Dtobr2,Dtobr2der !(2,maxres)
78 real(kind=8),dimension(:,:,:),allocatable :: EUg,EUgder,CUg,&
79 CUgder,DUg,Dugder,DtUg2,DtUg2der !(2,2,maxres)
80 ! This common block contains vectors and matrices dependent on two
81 ! consecutive amino-acid residues.
83 real(kind=8),dimension(:,:),allocatable :: Ug2Db1t,Ug2Db1tder,&
84 CUgb2,CUgb2der !(2,maxres)
85 real(kind=8),dimension(:,:,:),allocatable :: EUgC,EUgCder,&
86 EUgD,EUgDder,DtUg2EUg,Ug2DtEUg !(2,2,maxres)
87 real(kind=8),dimension(:,:,:,:),allocatable :: Ug2DtEUgder,&
88 DtUg2EUgder !(2,2,2,maxres)
90 real(kind=8),dimension(:),allocatable :: costab,sintab,&
91 costab2,sintab2 !(maxres)
92 ! This common block contains dipole-interaction matrices and their
93 ! Cartesian derivatives.
95 real(kind=8),dimension(:,:,:,:),allocatable :: a_chuj !(2,2,maxconts,maxres)
96 real(kind=8),dimension(:,:,:,:,:,:),allocatable :: a_chuj_der !(2,2,3,5,maxconts,maxres)
98 real(kind=8),dimension(2,2,2) :: AEA,AEAderg,EAEA,AECA,&
99 AECAderg,ADtEA,ADtEA1,AEAb1,AEAb1derg,AEAb2
100 real(kind=8),dimension(2,2,2,2) :: EAEAderg,ADtEAderg,&
102 real(kind=8),dimension(2,2,3,5,2,2) :: AEAderx,EAEAderx,&
103 AECAderx,ADtEAderx,ADtEA1derx
104 real(kind=8),dimension(2,3,5,2,2,2) :: AEAb1derx,AEAb2derx
105 real(kind=8),dimension(3,2) :: g_contij
106 real(kind=8) :: ekont
107 ! 12/13/2008 (again Poland-Jaruzel war anniversary)
108 ! RE: Parallelization of 4th and higher order loc-el correlations
109 ! common /contdistrib/
110 integer,dimension(:),allocatable :: ncont_sent,ncont_recv !(maxres)
111 ! ncont_sent,ncont_recv są w multibody_ello i multibody_hb
112 !-----------------------------------------------------------------------------
115 ! real(kind=8),dimension(:,:),allocatable :: dcdv,dxdv !(6,maxdim)
116 ! real(kind=8),dimension(:,:),allocatable :: dxds !(6,maxres)
117 ! real(kind=8),dimension(:,:,:),allocatable :: gradx,gradc !(3,maxres,2)
118 real(kind=8),dimension(:,:),allocatable :: gvdwc,gelc,gelc_long,&
119 gvdwpp,gvdwc_scpp,gradx_scp,gvdwc_scp,ghpbx,ghpbc,&
120 gradcorr,gradcorr_long,gradcorr5_long,gradcorr6_long,&
121 gcorr6_turn_long,gradxorr,gradcorr5,gradcorr6,gliptran,gliptranc,&
123 gshieldx,gshieldc,gshieldc_loc,gshieldx_ec,&
124 gshieldc_ec,gshieldc_loc_ec,gshieldx_t3, &
125 gshieldc_t3,gshieldc_loc_t3,gshieldx_t4,gshieldc_t4, &
126 gshieldc_loc_t4,gshieldx_ll,gshieldc_ll,gshieldc_loc_ll,&
127 grad_shield,gg_tube,gg_tube_sc,gradafm !(3,maxres)
128 ! real(kind=8),dimension(:,:),allocatable :: gloc,gloc_x !(maxvar,2)
129 real(kind=8),dimension(:,:),allocatable :: gel_loc,gel_loc_long,&
130 gcorr3_turn,gcorr4_turn,gcorr6_turn,gradb,gradbx !(3,maxres)
131 real(kind=8),dimension(:),allocatable :: gel_loc_loc,&
132 gel_loc_turn3,gel_loc_turn4,gel_loc_turn6,gcorr_loc,g_corr5_loc,&
133 g_corr6_loc !(maxvar)
134 real(kind=8),dimension(:,:),allocatable :: gsccorc,gsccorx !(3,maxres)
135 real(kind=8),dimension(:),allocatable :: gsccor_loc !(maxres)
136 ! real(kind=8),dimension(:,:,:),allocatable :: dtheta !(3,2,maxres)
137 real(kind=8),dimension(:,:),allocatable :: gscloc,gsclocx !(3,maxres)
138 ! real(kind=8),dimension(:,:,:),allocatable :: dphi,dalpha,domega !(3,3,maxres)
139 real(kind=8),dimension(:,:,:),allocatable :: grad_shield_side, &
140 grad_shield_loc ! (3,maxcontsshileding,maxnres)
143 real(kind=8), dimension(:),allocatable :: fac_shield
144 real(kind=8),dimension(3,5,2) :: derx,derx_turn
145 ! common /deriv_scloc/
146 real(kind=8),dimension(:,:),allocatable :: dXX_C1tab,dYY_C1tab,&
147 dZZ_C1tab,dXX_Ctab,dYY_Ctab,dZZ_Ctab,dXX_XYZtab,dYY_XYZtab,&
148 dZZ_XYZtab !(3,maxres)
149 !-----------------------------------------------------------------------------
152 real(kind=8) :: gvdwc_max,gvdwc_scp_max,gelc_max,gvdwpp_max,&
153 gradb_max,ghpbc_max,&
154 gradcorr_max,gel_loc_max,gcorr3_turn_max,gcorr4_turn_max,&
155 gradcorr5_max,gradcorr6_max,gcorr6_turn_max,gsccorc_max,&
156 gscloc_max,gvdwx_max,gradx_scp_max,ghpbx_max,gradxorr_max,&
157 gsccorx_max,gsclocx_max
158 !-----------------------------------------------------------------------------
160 ! common /back_constr/
161 real(kind=8),dimension(:),allocatable :: dutheta,dugamma !(maxres)
162 real(kind=8),dimension(:,:),allocatable :: duscdiff,duscdiffx !(3,maxres)
164 real(kind=8) :: Ucdfrag,Ucdpair
165 real(kind=8),dimension(:,:),allocatable :: dUdconst,dUdxconst,&
166 dqwol,dxqwol !(3,0:MAXRES)
167 !-----------------------------------------------------------------------------
169 ! common /dyn_ssbond/
170 real(kind=8),dimension(:,:),allocatable :: dyn_ssbond_ij !(maxres,maxres)
171 !-----------------------------------------------------------------------------
173 ! Parameters of the SCCOR term
175 real(kind=8),dimension(:,:,:,:),allocatable :: dcostau,dsintau,&
176 dcosomicron,domicron !(3,3,3,maxres2)
177 !-----------------------------------------------------------------------------
180 real(kind=8),dimension(:,:),allocatable :: uy,uz !(3,maxres)
181 real(kind=8),dimension(:,:,:,:),allocatable :: uygrad,uzgrad !(3,3,2,maxres)
182 !-----------------------------------------------------------------------------
183 ! common /przechowalnia/
184 real(kind=8),dimension(:,:,:),allocatable :: zapas !(max_dim,maxconts,max_fg_procs)
185 real(kind=8),dimension(:,:,:),allocatable :: fromto !(3,3,maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
186 !-----------------------------------------------------------------------------
187 !-----------------------------------------------------------------------------
190 !-----------------------------------------------------------------------------
192 !-----------------------------------------------------------------------------
193 ! energy_p_new_barrier.F
194 !-----------------------------------------------------------------------------
195 subroutine etotal(energia)
196 ! implicit real*8 (a-h,o-z)
197 ! include 'DIMENSIONS'
202 !MS$ATTRIBUTES C :: proc_proc
208 ! include 'COMMON.SETUP'
209 ! include 'COMMON.IOUNITS'
210 real(kind=8),dimension(0:n_ene) :: energia
211 ! include 'COMMON.LOCAL'
212 ! include 'COMMON.FFIELD'
213 ! include 'COMMON.DERIV'
214 ! include 'COMMON.INTERACT'
215 ! include 'COMMON.SBRIDGE'
216 ! include 'COMMON.CHAIN'
217 ! include 'COMMON.VAR'
218 ! include 'COMMON.MD'
219 ! include 'COMMON.CONTROL'
220 ! include 'COMMON.TIME1'
221 real(kind=8) :: time00
223 integer :: n_corr,n_corr1,ierror
224 real(kind=8) :: etors,edihcnstr,etors_d,esccor,ehpb
225 real(kind=8) :: evdw,evdw1,evdw2,evdw2_14,escloc,ees,eel_loc
226 real(kind=8) :: eello_turn3,eello_turn4,estr,ebe,eliptran,etube, &
227 Eafmforce,ethetacnstr
228 real(kind=8) :: ecorr,ecorr5,ecorr6,eturn6
231 real(kind=8) :: weights_(n_ene) !,time_Bcast,time_Bcastw
232 ! shielding effect varibles for MPI
233 ! real(kind=8) fac_shieldbuf(maxres),
234 ! & grad_shield_locbuf(3,maxcontsshi,-1:maxres),
235 ! & grad_shield_sidebuf(3,maxcontsshi,-1:maxres),
236 ! & grad_shieldbuf(3,-1:maxres)
237 ! integer ishield_listbuf(maxres),
238 ! &shield_listbuf(maxcontsshi,maxres)
240 ! print*,"ETOTAL Processor",fg_rank," absolute rank",myrank,
241 ! & " nfgtasks",nfgtasks
242 if (nfgtasks.gt.1) then
244 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
245 if (fg_rank.eq.0) then
246 call MPI_Bcast(0,1,MPI_INTEGER,king,FG_COMM,IERROR)
247 ! print *,"Processor",myrank," BROADCAST iorder"
248 ! FG master sets up the WEIGHTS_ array which will be broadcast to the
249 ! FG slaves as WEIGHTS array.
269 ! FG Master broadcasts the WEIGHTS_ array
270 call MPI_Bcast(weights_(1),n_ene,&
271 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
273 ! FG slaves receive the WEIGHTS array
274 call MPI_Bcast(weights(1),n_ene,&
275 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
296 time_Bcast=time_Bcast+MPI_Wtime()-time00
297 time_Bcastw=time_Bcastw+MPI_Wtime()-time00
298 ! call chainbuild_cart
300 ! print *,'Processor',myrank,' calling etotal ipot=',ipot
301 ! print *,'Processor',myrank,' nnt=',nnt,' nct=',nct
303 ! if (modecalc.eq.12.or.modecalc.eq.14) then
304 ! call int_from_cart1(.false.)
311 ! Compute the side-chain and electrostatic interaction energy
312 ! print *, "Before EVDW"
313 ! goto (101,102,103,104,105,106) ipot
315 ! Lennard-Jones potential.
319 !d print '(a)','Exit ELJcall el'
321 ! Lennard-Jones-Kihara potential (shifted).
322 ! 102 call eljk(evdw)
326 ! Berne-Pechukas potential (dilated LJ, angular dependence).
331 ! Gay-Berne potential (shifted LJ, angular dependence).
336 ! Gay-Berne-Vorobjev potential (shifted LJ, angular dependence).
337 ! 105 call egbv(evdw)
341 ! Soft-sphere potential
342 ! 106 call e_softsphere(evdw)
344 call e_softsphere(evdw)
346 ! Calculate electrostatic (H-bonding) energy of the main chain.
350 write(iout,*)"Wrong ipot"
355 ! print *,"after EGB"
357 if (shield_mode.eq.2) then
361 !mc Sep-06: egb takes care of dynamic ss bonds too
363 ! if (dyn_ss) call dyn_set_nss
364 ! print *,"Processor",myrank," computed USCSC"
370 time_vec=time_vec+MPI_Wtime()-time01
372 ! print *,"Processor",myrank," left VEC_AND_DERIV"
375 ! print *,"after ipot if", ipot
376 if (welec.gt.0d0.or.wvdwpp.gt.0d0.or.wel_loc.gt.0d0.or. &
377 wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0 &
378 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
379 .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
381 if (welec.gt.0d0.or.wel_loc.gt.0d0.or. &
382 wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0 &
383 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
384 .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
386 ! print *,"just befor eelec call"
387 call eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
388 ! write (iout,*) "ELEC calc"
397 ! write (iout,*) "Soft-spheer ELEC potential"
398 call eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,&
401 ! print *,"Processor",myrank," computed UELEC"
403 ! Calculate excluded-volume interaction energy between peptide groups
406 !elwrite(iout,*) "in etotal calc exc;luded",ipot
410 call escp(evdw2,evdw2_14)
416 ! write (iout,*) "Soft-sphere SCP potential"
417 call escp_soft_sphere(evdw2,evdw2_14)
419 ! write(iout,*) "in etotal before ebond",ipot
422 ! Calculate the bond-stretching energy
426 ! write(iout,*) "in etotal afer ebond",ipot
429 ! Calculate the disulfide-bridge and other energy and the contributions
430 ! from other distance constraints.
431 ! print *,'Calling EHPB'
433 !elwrite(iout,*) "in etotal afer edis",ipot
434 ! print *,'EHPB exitted succesfully.'
436 ! Calculate the virtual-bond-angle energy.
438 if (wang.gt.0d0) then
439 call ebend(ebe,ethetacnstr)
443 ! print *,"Processor",myrank," computed UB"
445 ! Calculate the SC local energy.
448 !elwrite(iout,*) "in etotal afer esc",ipot
449 ! print *,"Processor",myrank," computed USC"
451 ! Calculate the virtual-bond torsional energy.
453 !d print *,'nterm=',nterm
455 call etor(etors,edihcnstr)
460 ! print *,"Processor",myrank," computed Utor"
462 ! 6/23/01 Calculate double-torsional energy
464 !elwrite(iout,*) "in etotal",ipot
465 if (wtor_d.gt.0) then
470 ! print *,"Processor",myrank," computed Utord"
472 ! 21/5/07 Calculate local sicdechain correlation energy
474 if (wsccor.gt.0.0d0) then
475 call eback_sc_corr(esccor)
479 ! print *,"Processor",myrank," computed Usccorr"
481 ! 12/1/95 Multi-body terms
485 if ((wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 &
486 .or. wturn6.gt.0.0d0) .and. ipot.lt.6) then
487 call multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
488 !d write(2,*)'multibody_eello n_corr=',n_corr,' n_corr1=',n_corr1,
489 !d &" ecorr",ecorr," ecorr5",ecorr5," ecorr6",ecorr6," eturn6",eturn6
496 !elwrite(iout,*) "in etotal",ipot
497 if ((wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) .and. ipot.lt.6) then
498 call multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
499 !d write (iout,*) "multibody_hb ecorr",ecorr
501 !elwrite(iout,*) "afeter multibody hb"
503 ! print *,"Processor",myrank," computed Ucorr"
505 ! If performing constraint dynamics, call the constraint energy
506 ! after the equilibration time
507 if(usampl.and.totT.gt.eq_time) then
508 !elwrite(iout,*) "afeter multibody hb"
510 !elwrite(iout,*) "afeter multibody hb"
512 !elwrite(iout,*) "afeter multibody hb"
518 ! write(iout,*) "after Econstr"
520 if (wliptran.gt.0) then
521 ! print *,"PRZED WYWOLANIEM"
522 call Eliptransfer(eliptran)
526 if (fg_rank.eq.0) then
527 if (AFMlog.gt.0) then
528 call AFMforce(Eafmforce)
529 else if (selfguide.gt.0) then
530 call AFMvel(Eafmforce)
533 if (tubemode.eq.1) then
535 else if (tubemode.eq.2) then
536 call calctube2(etube)
537 elseif (tubemode.eq.3) then
544 time_enecalc=time_enecalc+MPI_Wtime()-time00
546 ! print *,"Processor",myrank," computed Uconstr"
555 energia(2)=evdw2-evdw2_14
572 energia(8)=eello_turn3
573 energia(9)=eello_turn4
580 energia(19)=edihcnstr
582 energia(20)=Uconst+Uconst_back
585 energia(23)=Eafmforce
586 energia(24)=ethetacnstr
588 ! Here are the energies showed per procesor if the are more processors
589 ! per molecule then we sum it up in sum_energy subroutine
590 ! print *," Processor",myrank," calls SUM_ENERGY"
591 call sum_energy(energia,.true.)
592 if (dyn_ss) call dyn_set_nss
593 ! print *," Processor",myrank," left SUM_ENERGY"
595 time_sumene=time_sumene+MPI_Wtime()-time00
597 !el call enerprint(energia)
598 !elwrite(iout,*)"finish etotal"
600 end subroutine etotal
601 !-----------------------------------------------------------------------------
602 subroutine sum_energy(energia,reduce)
603 ! implicit real*8 (a-h,o-z)
604 ! include 'DIMENSIONS'
608 !MS$ATTRIBUTES C :: proc_proc
614 ! include 'COMMON.SETUP'
615 ! include 'COMMON.IOUNITS'
616 real(kind=8) :: energia(0:n_ene),enebuff(0:n_ene+1)
617 ! include 'COMMON.FFIELD'
618 ! include 'COMMON.DERIV'
619 ! include 'COMMON.INTERACT'
620 ! include 'COMMON.SBRIDGE'
621 ! include 'COMMON.CHAIN'
622 ! include 'COMMON.VAR'
623 ! include 'COMMON.CONTROL'
624 ! include 'COMMON.TIME1'
626 real(kind=8) :: evdw,evdw2,evdw2_14,ees,evdw1,ecorr,ecorr5,ecorr6
627 real(kind=8) :: eel_loc,eello_turn3,eello_turn4,eturn6,ebe,escloc
628 real(kind=8) :: etors,etors_d,ehpb,edihcnstr,estr,esccor,etot, &
629 eliptran,etube, Eafmforce,ethetacnstr
633 real(kind=8) :: time00
634 if (nfgtasks.gt.1 .and. reduce) then
637 write (iout,*) "energies before REDUCE"
638 call enerprint(energia)
642 enebuff(i)=energia(i)
645 call MPI_Barrier(FG_COMM,IERR)
646 time_barrier_e=time_barrier_e+MPI_Wtime()-time00
648 call MPI_Reduce(enebuff(0),energia(0),n_ene+1,&
649 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
651 write (iout,*) "energies after REDUCE"
652 call enerprint(energia)
655 time_Reduce=time_Reduce+MPI_Wtime()-time00
657 if (fg_rank.eq.0) then
661 evdw2=energia(2)+energia(18)
677 eello_turn3=energia(8)
678 eello_turn4=energia(9)
685 edihcnstr=energia(19)
690 Eafmforce=energia(23)
691 ethetacnstr=energia(24)
694 etot=wsc*evdw+wscp*evdw2+welec*ees+wvdwpp*evdw1 &
695 +wang*ebe+wtor*etors+wscloc*escloc &
696 +wstrain*ehpb+wcorr*ecorr+wcorr5*ecorr5 &
697 +wcorr6*ecorr6+wturn4*eello_turn4+wturn3*eello_turn3 &
698 +wturn6*eturn6+wel_loc*eel_loc+edihcnstr+wtor_d*etors_d &
699 +wbond*estr+Uconst+wsccor*esccor+wliptran*eliptran+wtube*etube&
700 +Eafmforce+ethetacnstr
702 etot=wsc*evdw+wscp*evdw2+welec*(ees+evdw1) &
703 +wang*ebe+wtor*etors+wscloc*escloc &
704 +wstrain*ehpb+wcorr*ecorr+wcorr5*ecorr5 &
705 +wcorr6*ecorr6+wturn4*eello_turn4+wturn3*eello_turn3 &
706 +wturn6*eturn6+wel_loc*eel_loc+edihcnstr+wtor_d*etors_d &
707 +wbond*estr+Uconst+wsccor*esccor+wliptran*eliptran+wtube*etube&
708 +Eafmforce+ethetacnstr
715 if (isnan(etot).ne.0) energia(0)=1.0d+99
717 if (isnan(etot)) energia(0)=1.0d+99
722 idumm=proc_proc(etot,i)
724 call proc_proc(etot,i)
726 if(i.eq.1)energia(0)=1.0d+99
731 ! call enerprint(energia)
734 end subroutine sum_energy
735 !-----------------------------------------------------------------------------
736 subroutine rescale_weights(t_bath)
737 ! implicit real*8 (a-h,o-z)
741 ! include 'DIMENSIONS'
742 ! include 'COMMON.IOUNITS'
743 ! include 'COMMON.FFIELD'
744 ! include 'COMMON.SBRIDGE'
745 real(kind=8) :: kfac=2.4d0
746 real(kind=8) :: x,x2,x3,x4,x5,licznik=1.12692801104297249644
748 real(kind=8) :: t_bath,facT(6) !,facT2,facT3,facT4,facT5,facT6
749 real(kind=8) :: T0=3.0d2
752 ! facT=2*temp0/(t_bath+temp0)
753 if (rescale_mode.eq.0) then
760 else if (rescale_mode.eq.1) then
761 facT(1)=kfac/(kfac-1.0d0+t_bath/temp0)
762 facT(2)=kfac**2/(kfac**2-1.0d0+(t_bath/temp0)**2)
763 facT(3)=kfac**3/(kfac**3-1.0d0+(t_bath/temp0)**3)
764 facT(4)=kfac**4/(kfac**4-1.0d0+(t_bath/temp0)**4)
765 facT(5)=kfac**5/(kfac**5-1.0d0+(t_bath/temp0)**5)
767 !#if defined(WHAM_RUN) || defined(CLUSTER)
769 ! tt = 1.0d0/(beta_h(ib,ipar)*1.987D-3)
770 facT(6)=(320.0+80.0*dtanh((t_bath-320.0)/80.0))/320.0
777 else if (rescale_mode.eq.2) then
783 facT(1)=licznik/dlog(dexp(x)+dexp(-x))
784 facT(2)=licznik/dlog(dexp(x2)+dexp(-x2))
785 facT(3)=licznik/dlog(dexp(x3)+dexp(-x3))
786 facT(4)=licznik/dlog(dexp(x4)+dexp(-x4))
787 facT(5)=licznik/dlog(dexp(x5)+dexp(-x5))
789 !#if defined(WHAM_RUN) || defined(CLUSTER)
791 facT(6)=(320.0+80.0*dtanh((t_bath-320.0)/80.0))/320.0
799 write (iout,*) "Wrong RESCALE_MODE",rescale_mode
800 write (*,*) "Wrong RESCALE_MODE",rescale_mode
802 call MPI_Finalize(MPI_COMM_WORLD,IERROR)
806 welec=weights(3)*fact(1)
807 wcorr=weights(4)*fact(3)
808 wcorr5=weights(5)*fact(4)
809 wcorr6=weights(6)*fact(5)
810 wel_loc=weights(7)*fact(2)
811 wturn3=weights(8)*fact(2)
812 wturn4=weights(9)*fact(3)
813 wturn6=weights(10)*fact(5)
814 wtor=weights(13)*fact(1)
815 wtor_d=weights(14)*fact(2)
816 wsccor=weights(21)*fact(1)
819 end subroutine rescale_weights
820 !-----------------------------------------------------------------------------
821 subroutine enerprint(energia)
822 ! implicit real*8 (a-h,o-z)
823 ! include 'DIMENSIONS'
824 ! include 'COMMON.IOUNITS'
825 ! include 'COMMON.FFIELD'
826 ! include 'COMMON.SBRIDGE'
827 ! include 'COMMON.MD'
828 real(kind=8) :: energia(0:n_ene)
830 real(kind=8) :: etot,evdw,evdw2,ees,evdw1,ecorr,ecorr5,ecorr6,eel_loc
831 real(kind=8) :: eello_turn6,eello_turn3,eello_turn4,ebe,escloc
832 real(kind=8) :: etors,etors_d,ehpb,edihcnstr,estr,Uconst,esccor,eliptran,&
833 etube,ethetacnstr,Eafmforce
839 evdw2=energia(2)+energia(18)
851 eello_turn3=energia(8)
852 eello_turn4=energia(9)
853 eello_turn6=energia(10)
859 edihcnstr=energia(19)
864 Eafmforce=energia(23)
865 ethetacnstr=energia(24)
868 write (iout,10) evdw,wsc,evdw2,wscp,ees,welec,evdw1,wvdwpp,&
869 estr,wbond,ebe,wang,&
870 escloc,wscloc,etors,wtor,etors_d,wtor_d,ehpb,wstrain,&
872 ecorr5,wcorr5,ecorr6,wcorr6,eel_loc,wel_loc,eello_turn3,wturn3,&
873 eello_turn4,wturn4,eello_turn6,wturn6,esccor,wsccor,&
874 edihcnstr,ethetacnstr,ebr*nss,&
875 Uconst,eliptran,wliptran,Eafmforce,etube,wtube,etot
876 10 format (/'Virtual-chain energies:'// &
877 'EVDW= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-SC)'/ &
878 'EVDW2= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-p)'/ &
879 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p)'/ &
880 'EVDWPP=',1pE16.6,' WEIGHT=',1pD16.6,' (p-p VDW)'/ &
881 'ESTR= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching)'/ &
882 'EBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (bending)'/ &
883 'ESC= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/ &
884 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/ &
885 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/ &
886 'EHBP= ',1pE16.6,' WEIGHT=',1pD16.6, &
887 ' (SS bridges & dist. cnstr.)'/ &
888 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
889 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
890 'ECORR6=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
891 'EELLO= ',1pE16.6,' WEIGHT=',1pD16.6,' (electrostatic-local)'/ &
892 'ETURN3=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 3rd order)'/ &
893 'ETURN4=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 4th order)'/ &
894 'ETURN6=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 6th order)'/ &
895 'ESCCOR=',1pE16.6,' WEIGHT=',1pD16.6,' (backbone-rotamer corr)'/ &
896 'EDIHC= ',1pE16.6,' (dihedral angle constraints)'/ &
897 'ETHETC= ',1pE16.6,' (valence angle constraints)'/ &
898 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/ &
899 'UCONST= ',1pE16.6,' (Constraint energy)'/ &
900 'ELT=',1pE16.6, ' WEIGHT=',1pD16.6,' (Lipid transfer energy)'/&
901 'EAFM= ',1pE16.6,' (atomic-force microscopy)'/ &
902 'ETUBE=',1pE16.6, ' WEIGHT=',1pD16.6,' (cylindrical energy)'/ &
903 'ETOT= ',1pE16.6,' (total)')
905 write (iout,10) evdw,wsc,evdw2,wscp,ees,welec,&
906 estr,wbond,ebe,wang,&
907 escloc,wscloc,etors,wtor,etors_d,wtor_d,ehpb,wstrain,&
909 ecorr5,wcorr5,ecorr6,wcorr6,eel_loc,wel_loc,eello_turn3,wturn3,&
910 eello_turn4,wturn4,eello_turn6,wturn6,esccor,wsccor,edihcnstr,&
911 ethetacnstr,ebr*nss,Uconst,eliptran,wliptran,Eafmforc, &
913 10 format (/'Virtual-chain energies:'// &
914 'EVDW= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-SC)'/ &
915 'EVDW2= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-p)'/ &
916 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p)'/ &
917 'ESTR= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching)'/ &
918 'EBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (bending)'/ &
919 'ESC= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/ &
920 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/ &
921 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/ &
922 'EHBP= ',1pE16.6,' WEIGHT=',1pD16.6, &
923 ' (SS bridges & dist. cnstr.)'/ &
924 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
925 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
926 'ECORR6=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
927 'EELLO= ',1pE16.6,' WEIGHT=',1pD16.6,' (electrostatic-local)'/ &
928 'ETURN3=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 3rd order)'/ &
929 'ETURN4=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 4th order)'/ &
930 'ETURN6=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 6th order)'/ &
931 'ESCCOR=',1pE16.6,' WEIGHT=',1pD16.6,' (backbone-rotamer corr)'/ &
932 'EDIHC= ',1pE16.6,' (dihedral angle constraints)'/ &
933 'ETHETC= ',1pE16.6,' (valence angle constraints)'/ &
934 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/ &
935 'UCONST=',1pE16.6,' (Constraint energy)'/ &
936 'ELT=',1pE16.6, ' WEIGHT=',1pD16.6,' (Lipid transfer energy)'/ &
937 'EAFM= ',1pE16.6,' (atomic-force microscopy)'/ &
938 'ETUBE=',1pE16.6, ' WEIGHT=',1pD16.6,' (cylindrical energy)'/ &
939 'ETOT= ',1pE16.6,' (total)')
942 end subroutine enerprint
943 !-----------------------------------------------------------------------------
946 ! This subroutine calculates the interaction energy of nonbonded side chains
947 ! assuming the LJ potential of interaction.
949 ! implicit real*8 (a-h,o-z)
950 ! include 'DIMENSIONS'
951 real(kind=8),parameter :: accur=1.0d-10
952 ! include 'COMMON.GEO'
953 ! include 'COMMON.VAR'
954 ! include 'COMMON.LOCAL'
955 ! include 'COMMON.CHAIN'
956 ! include 'COMMON.DERIV'
957 ! include 'COMMON.INTERACT'
958 ! include 'COMMON.TORSION'
959 ! include 'COMMON.SBRIDGE'
960 ! include 'COMMON.NAMES'
961 ! include 'COMMON.IOUNITS'
962 ! include 'COMMON.CONTACTS'
963 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
966 integer :: i,itypi,iint,j,itypi1,itypj,k
967 real(kind=8) :: rij,rcut,fcont,fprimcont,rrij
968 real(kind=8) :: evdw,xi,yi,zi,xj,yj,zj
969 real(kind=8) :: eps0ij,fac,e1,e2,evdwij,sigij,r0ij
971 ! write(iout,*)'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
973 ! allocate(num_cont(iatsc_s:iatsc_e)) !(maxres) nnt,nct-2
974 ! allocate(jcont(nres/4,iatsc_s:iatsc_e)) !(maxconts,maxres) (maxconts=maxres/4)
975 ! allocate(facont(nres/4,iatsc_s:iatsc_e)) !(maxconts,maxres)
976 ! allocate(gacont(3,nres/4,iatsc_s:iatsc_e)) !(3,maxconts,maxres)
979 itypi=iabs(itype(i,1))
980 if (itypi.eq.ntyp1) cycle
981 itypi1=iabs(itype(i+1,1))
988 ! Calculate SC interaction energy.
991 !d write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
992 !d & 'iend=',iend(i,iint)
993 do j=istart(i,iint),iend(i,iint)
994 itypj=iabs(itype(j,1))
995 if (itypj.eq.ntyp1) cycle
999 ! Change 12/1/95 to calculate four-body interactions
1000 rij=xj*xj+yj*yj+zj*zj
1002 ! write (iout,*)'i=',i,' j=',j,' itypi=',itypi,' itypj=',itypj
1003 eps0ij=eps(itypi,itypj)
1005 e1=fac*fac*aa_aq(itypi,itypj)
1006 e2=fac*bb_aq(itypi,itypj)
1008 !d sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1009 !d epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1010 !d write (iout,'(2(a3,i3,2x),6(1pd12.4)/2(3(1pd12.4),5x)/)')
1011 !d & restyp(itypi,1),i,restyp(itypj,1),j,aa(itypi,itypj),
1012 !d & bb(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,epsi,sigm,
1013 !d & (c(k,i),k=1,3),(c(k,j),k=1,3)
1016 ! Calculate the components of the gradient in DC and X
1018 fac=-rrij*(e1+evdwij)
1023 gvdwx(k,i)=gvdwx(k,i)-gg(k)
1024 gvdwx(k,j)=gvdwx(k,j)+gg(k)
1025 gvdwc(k,i)=gvdwc(k,i)-gg(k)
1026 gvdwc(k,j)=gvdwc(k,j)+gg(k)
1030 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
1034 ! 12/1/95, revised on 5/20/97
1036 ! Calculate the contact function. The ith column of the array JCONT will
1037 ! contain the numbers of atoms that make contacts with the atom I (of numbers
1038 ! greater than I). The arrays FACONT and GACONT will contain the values of
1039 ! the contact function and its derivative.
1041 ! Uncomment next line, if the correlation interactions include EVDW explicitly.
1042 ! if (j.gt.i+1 .and. evdwij.le.0.0D0) then
1043 ! Uncomment next line, if the correlation interactions are contact function only
1044 if (j.gt.i+1.and. eps0ij.gt.0.0D0) then
1046 sigij=sigma(itypi,itypj)
1047 r0ij=rs0(itypi,itypj)
1049 ! Check whether the SC's are not too far to make a contact.
1052 call gcont(rij,rcut,1.0d0,0.2d0*rcut,fcont,fprimcont)
1053 ! Add a new contact, if the SC's are close enough, but not too close (r<sigma).
1055 if (fcont.gt.0.0D0) then
1056 ! If the SC-SC distance if close to sigma, apply spline.
1057 !Adam call gcont(-rij,-1.03d0*sigij,2.0d0*sigij,1.0d0,
1058 !Adam & fcont1,fprimcont1)
1059 !Adam fcont1=1.0d0-fcont1
1060 !Adam if (fcont1.gt.0.0d0) then
1061 !Adam fprimcont=fprimcont*fcont1+fcont*fprimcont1
1062 !Adam fcont=fcont*fcont1
1064 ! Uncomment following 4 lines to have the geometric average of the epsilon0's
1065 !ga eps0ij=1.0d0/dsqrt(eps0ij)
1067 !ga gg(k)=gg(k)*eps0ij
1069 !ga eps0ij=-evdwij*eps0ij
1070 ! Uncomment for AL's type of SC correlation interactions.
1071 !adam eps0ij=-evdwij
1072 num_conti=num_conti+1
1073 jcont(num_conti,i)=j
1074 facont(num_conti,i)=fcont*eps0ij
1075 fprimcont=eps0ij*fprimcont/rij
1077 !Adam gacont(1,num_conti,i)=-fprimcont*xj+fcont*gg(1)
1078 !Adam gacont(2,num_conti,i)=-fprimcont*yj+fcont*gg(2)
1079 !Adam gacont(3,num_conti,i)=-fprimcont*zj+fcont*gg(3)
1080 ! Uncomment following 3 lines for Skolnick's type of SC correlation.
1081 gacont(1,num_conti,i)=-fprimcont*xj
1082 gacont(2,num_conti,i)=-fprimcont*yj
1083 gacont(3,num_conti,i)=-fprimcont*zj
1084 !d write (iout,'(2i5,2f10.5)') i,j,rij,facont(num_conti,i)
1085 !d write (iout,'(2i3,3f10.5)')
1086 !d & i,j,(gacont(kk,num_conti,i),kk=1,3)
1092 num_cont(i)=num_conti
1096 gvdwc(j,i)=expon*gvdwc(j,i)
1097 gvdwx(j,i)=expon*gvdwx(j,i)
1100 !******************************************************************************
1104 ! To save time, the factor of EXPON has been extracted from ALL components
1105 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
1108 !******************************************************************************
1111 !-----------------------------------------------------------------------------
1112 subroutine eljk(evdw)
1114 ! This subroutine calculates the interaction energy of nonbonded side chains
1115 ! assuming the LJK potential of interaction.
1117 ! implicit real*8 (a-h,o-z)
1118 ! include 'DIMENSIONS'
1119 ! include 'COMMON.GEO'
1120 ! include 'COMMON.VAR'
1121 ! include 'COMMON.LOCAL'
1122 ! include 'COMMON.CHAIN'
1123 ! include 'COMMON.DERIV'
1124 ! include 'COMMON.INTERACT'
1125 ! include 'COMMON.IOUNITS'
1126 ! include 'COMMON.NAMES'
1127 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
1130 integer :: i,iint,j,itypi,itypi1,k,itypj
1131 real(kind=8) :: rrij,xi,yi,zi,xj,yj,zj,fac_augm,e_augm,r_inv_ij
1132 real(kind=8) :: evdw,rij,r_shift_inv,fac,e1,e2,evdwij
1134 ! print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
1136 do i=iatsc_s,iatsc_e
1137 itypi=iabs(itype(i,1))
1138 if (itypi.eq.ntyp1) cycle
1139 itypi1=iabs(itype(i+1,1))
1144 ! Calculate SC interaction energy.
1146 do iint=1,nint_gr(i)
1147 do j=istart(i,iint),iend(i,iint)
1148 itypj=iabs(itype(j,1))
1149 if (itypj.eq.ntyp1) cycle
1153 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1154 fac_augm=rrij**expon
1155 e_augm=augm(itypi,itypj)*fac_augm
1156 r_inv_ij=dsqrt(rrij)
1158 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
1159 fac=r_shift_inv**expon
1160 e1=fac*fac*aa_aq(itypi,itypj)
1161 e2=fac*bb_aq(itypi,itypj)
1163 !d sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1164 !d epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1165 !d write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
1166 !d & restyp(itypi,1),i,restyp(itypj,1),j,aa(itypi,itypj),
1167 !d & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
1168 !d & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
1169 !d & (c(k,i),k=1,3),(c(k,j),k=1,3)
1172 ! Calculate the components of the gradient in DC and X
1174 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
1179 gvdwx(k,i)=gvdwx(k,i)-gg(k)
1180 gvdwx(k,j)=gvdwx(k,j)+gg(k)
1181 gvdwc(k,i)=gvdwc(k,i)-gg(k)
1182 gvdwc(k,j)=gvdwc(k,j)+gg(k)
1186 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
1194 gvdwc(j,i)=expon*gvdwc(j,i)
1195 gvdwx(j,i)=expon*gvdwx(j,i)
1200 !-----------------------------------------------------------------------------
1201 subroutine ebp(evdw)
1203 ! This subroutine calculates the interaction energy of nonbonded side chains
1204 ! assuming the Berne-Pechukas potential of interaction.
1208 ! implicit real*8 (a-h,o-z)
1209 ! include 'DIMENSIONS'
1210 ! include 'COMMON.GEO'
1211 ! include 'COMMON.VAR'
1212 ! include 'COMMON.LOCAL'
1213 ! include 'COMMON.CHAIN'
1214 ! include 'COMMON.DERIV'
1215 ! include 'COMMON.NAMES'
1216 ! include 'COMMON.INTERACT'
1217 ! include 'COMMON.IOUNITS'
1218 ! include 'COMMON.CALC'
1220 !el integer :: icall
1221 !el common /srutu/ icall
1222 ! double precision rrsave(maxdim)
1225 integer :: iint,itypi,itypi1,itypj
1226 real(kind=8) :: rrij,xi,yi,zi
1227 real(kind=8) :: evdw,fac,e1,e2,sigm,epsi
1229 ! print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
1231 ! if (icall.eq.0) then
1237 do i=iatsc_s,iatsc_e
1238 itypi=iabs(itype(i,1))
1239 if (itypi.eq.ntyp1) cycle
1240 itypi1=iabs(itype(i+1,1))
1244 dxi=dc_norm(1,nres+i)
1245 dyi=dc_norm(2,nres+i)
1246 dzi=dc_norm(3,nres+i)
1247 ! dsci_inv=dsc_inv(itypi)
1248 dsci_inv=vbld_inv(i+nres)
1250 ! Calculate SC interaction energy.
1252 do iint=1,nint_gr(i)
1253 do j=istart(i,iint),iend(i,iint)
1255 itypj=iabs(itype(j,1))
1256 if (itypj.eq.ntyp1) cycle
1257 ! dscj_inv=dsc_inv(itypj)
1258 dscj_inv=vbld_inv(j+nres)
1259 chi1=chi(itypi,itypj)
1260 chi2=chi(itypj,itypi)
1267 alf12=0.5D0*(alf1+alf2)
1268 ! For diagnostics only!!!
1281 dxj=dc_norm(1,nres+j)
1282 dyj=dc_norm(2,nres+j)
1283 dzj=dc_norm(3,nres+j)
1284 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1285 !d if (icall.eq.0) then
1291 ! Calculate the angle-dependent terms of energy & contributions to derivatives.
1293 ! Calculate whole angle-dependent part of epsilon and contributions
1294 ! to its derivatives
1295 fac=(rrij*sigsq)**expon2
1296 e1=fac*fac*aa_aq(itypi,itypj)
1297 e2=fac*bb_aq(itypi,itypj)
1298 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
1299 eps2der=evdwij*eps3rt
1300 eps3der=evdwij*eps2rt
1301 evdwij=evdwij*eps2rt*eps3rt
1304 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
1305 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
1306 !d write (iout,'(2(a3,i3,2x),15(0pf7.3))')
1307 !d & restyp(itypi,1),i,restyp(itypj,1),j,
1308 !d & epsi,sigm,chi1,chi2,chip1,chip2,
1309 !d & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
1310 !d & om1,om2,om12,1.0D0/dsqrt(rrij),
1313 ! Calculate gradient components.
1314 e1=e1*eps1*eps2rt**2*eps3rt**2
1315 fac=-expon*(e1+evdwij)
1318 ! Calculate radial part of the gradient
1322 ! Calculate the angular part of the gradient and sum add the contributions
1323 ! to the appropriate components of the Cartesian gradient.
1331 !-----------------------------------------------------------------------------
1332 subroutine egb(evdw)
1334 ! This subroutine calculates the interaction energy of nonbonded side chains
1335 ! assuming the Gay-Berne potential of interaction.
1338 ! implicit real*8 (a-h,o-z)
1339 ! include 'DIMENSIONS'
1340 ! include 'COMMON.GEO'
1341 ! include 'COMMON.VAR'
1342 ! include 'COMMON.LOCAL'
1343 ! include 'COMMON.CHAIN'
1344 ! include 'COMMON.DERIV'
1345 ! include 'COMMON.NAMES'
1346 ! include 'COMMON.INTERACT'
1347 ! include 'COMMON.IOUNITS'
1348 ! include 'COMMON.CALC'
1349 ! include 'COMMON.CONTROL'
1350 ! include 'COMMON.SBRIDGE'
1353 integer :: iint,itypi,itypi1,itypj,subchap
1354 real(kind=8) :: rrij,xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
1355 real(kind=8) :: evdw,sig0ij
1356 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
1357 dist_temp, dist_init,aa,bb,ssgradlipi,ssgradlipj, &
1358 sslipi,sslipj,faclip
1360 real(kind=8) :: fracinbuf
1362 !cccc energy_dec=.false.
1363 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
1366 ! if (icall.eq.0) lprn=.false.
1368 do i=iatsc_s,iatsc_e
1369 !C print *,"I am in EVDW",i
1370 itypi=iabs(itype(i,1))
1371 ! if (i.ne.47) cycle
1372 if (itypi.eq.ntyp1) cycle
1373 itypi1=iabs(itype(i+1,1))
1377 xi=dmod(xi,boxxsize)
1378 if (xi.lt.0) xi=xi+boxxsize
1379 yi=dmod(yi,boxysize)
1380 if (yi.lt.0) yi=yi+boxysize
1381 zi=dmod(zi,boxzsize)
1382 if (zi.lt.0) zi=zi+boxzsize
1384 if ((zi.gt.bordlipbot) &
1385 .and.(zi.lt.bordliptop)) then
1386 !C the energy transfer exist
1387 if (zi.lt.buflipbot) then
1388 !C what fraction I am in
1390 ((zi-bordlipbot)/lipbufthick)
1391 !C lipbufthick is thickenes of lipid buffore
1392 sslipi=sscalelip(fracinbuf)
1393 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
1394 elseif (zi.gt.bufliptop) then
1395 fracinbuf=1.0d0-((bordliptop-zi)/lipbufthick)
1396 sslipi=sscalelip(fracinbuf)
1397 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
1406 ! print *, sslipi,ssgradlipi
1407 dxi=dc_norm(1,nres+i)
1408 dyi=dc_norm(2,nres+i)
1409 dzi=dc_norm(3,nres+i)
1410 ! dsci_inv=dsc_inv(itypi)
1411 dsci_inv=vbld_inv(i+nres)
1412 ! write (iout,*) "i",i,dsc_inv(itypi),dsci_inv,1.0d0/vbld(i+nres)
1413 ! write (iout,*) "dcnori",dxi*dxi+dyi*dyi+dzi*dzi
1415 ! Calculate SC interaction energy.
1417 do iint=1,nint_gr(i)
1418 do j=istart(i,iint),iend(i,iint)
1419 IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
1420 call dyn_ssbond_ene(i,j,evdwij)
1422 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
1423 'evdw',i,j,evdwij,' ss'
1424 ! if (energy_dec) write (iout,*) &
1425 ! 'evdw',i,j,evdwij,' ss'
1426 do k=j+1,iend(i,iint)
1427 !C search over all next residues
1428 if (dyn_ss_mask(k)) then
1429 !C check if they are cysteins
1430 !C write(iout,*) 'k=',k
1432 !c write(iout,*) "PRZED TRI", evdwij
1433 ! evdwij_przed_tri=evdwij
1434 call triple_ssbond_ene(i,j,k,evdwij)
1435 !c if(evdwij_przed_tri.ne.evdwij) then
1436 !c write (iout,*) "TRI:", evdwij, evdwij_przed_tri
1439 !c write(iout,*) "PO TRI", evdwij
1440 !C call the energy function that removes the artifical triple disulfide
1441 !C bond the soubroutine is located in ssMD.F
1443 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
1444 'evdw',i,j,evdwij,'tss'
1445 endif!dyn_ss_mask(k)
1449 itypj=iabs(itype(j,1))
1450 if (itypj.eq.ntyp1) cycle
1451 ! if (j.ne.78) cycle
1452 ! dscj_inv=dsc_inv(itypj)
1453 dscj_inv=vbld_inv(j+nres)
1454 ! write (iout,*) "j",j,dsc_inv(itypj),dscj_inv,&
1455 ! 1.0d0/vbld(j+nres) !d
1456 ! write (iout,*) "i",i," j", j," itype",itype(i,1),itype(j,1)
1457 sig0ij=sigma(itypi,itypj)
1458 chi1=chi(itypi,itypj)
1459 chi2=chi(itypj,itypi)
1466 alf12=0.5D0*(alf1+alf2)
1467 ! For diagnostics only!!!
1480 xj=dmod(xj,boxxsize)
1481 if (xj.lt.0) xj=xj+boxxsize
1482 yj=dmod(yj,boxysize)
1483 if (yj.lt.0) yj=yj+boxysize
1484 zj=dmod(zj,boxzsize)
1485 if (zj.lt.0) zj=zj+boxzsize
1486 ! print *,"tu",xi,yi,zi,xj,yj,zj
1487 ! print *,"tu2",j,j+nres,c(1,j),c(1,j+nres)
1488 ! this fragment set correct epsilon for lipid phase
1489 if ((zj.gt.bordlipbot) &
1490 .and.(zj.lt.bordliptop)) then
1491 !C the energy transfer exist
1492 if (zj.lt.buflipbot) then
1493 !C what fraction I am in
1495 ((zj-bordlipbot)/lipbufthick)
1496 !C lipbufthick is thickenes of lipid buffore
1497 sslipj=sscalelip(fracinbuf)
1498 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
1499 elseif (zj.gt.bufliptop) then
1500 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
1501 sslipj=sscalelip(fracinbuf)
1502 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
1511 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
1512 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
1513 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
1514 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
1515 !------------------------------------------------
1516 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
1524 xj=xj_safe+xshift*boxxsize
1525 yj=yj_safe+yshift*boxysize
1526 zj=zj_safe+zshift*boxzsize
1527 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
1528 if(dist_temp.lt.dist_init) then
1538 if (subchap.eq.1) then
1547 dxj=dc_norm(1,nres+j)
1548 dyj=dc_norm(2,nres+j)
1549 dzj=dc_norm(3,nres+j)
1550 ! write (iout,*) "dcnorj",dxi*dxi+dyi*dyi+dzi*dzi
1551 ! write (iout,*) "j",j," dc_norm",& !d
1552 ! dc_norm(1,nres+j),dc_norm(2,nres+j),dc_norm(3,nres+j)
1553 ! write(iout,*)"rrij ",rrij
1554 ! write(iout,*)"xj yj zj ", xj, yj, zj
1555 ! write(iout,*)"xi yi zi ", xi, yi, zi
1556 ! write(iout,*)"c ", c(1,:), c(2,:), c(3,:)
1557 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1559 sss_ele_cut=sscale_ele(1.0d0/(rij*sigma(itypi,itypj)))
1560 sss_ele_grad=sscagrad_ele(1.0d0/(rij*sigma(itypi,itypj)))
1561 ! print *,sss_ele_cut,sss_ele_grad,&
1562 ! 1.0d0/(rij),r_cut_ele,rlamb_ele
1563 if (sss_ele_cut.le.0.0) cycle
1564 ! Calculate angle-dependent terms of energy and contributions to their
1568 sig=sig0ij*dsqrt(sigsq)
1569 rij_shift=1.0D0/rij-sig+sig0ij
1570 ! write(iout,*)" rij_shift",rij_shift," rij",rij," sig",sig,&
1572 ! for diagnostics; uncomment
1573 ! rij_shift=1.2*sig0ij
1574 ! I hate to put IF's in the loops, but here don't have another choice!!!!
1575 if (rij_shift.le.0.0D0) then
1577 !d write (iout,'(2(a3,i3,2x),17(0pf7.3))')
1578 !d & restyp(itypi,1),i,restyp(itypj,1),j,
1579 !d & rij_shift,1.0D0/rij,sig,sig0ij,sigsq,1-dsqrt(sigsq)
1583 !---------------------------------------------------------------
1584 rij_shift=1.0D0/rij_shift
1585 fac=rij_shift**expon
1587 e1=fac*fac*aa!(itypi,itypj)
1588 e2=fac*bb!(itypi,itypj)
1589 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
1590 eps2der=evdwij*eps3rt
1591 eps3der=evdwij*eps2rt
1592 ! write(iout,*)"aa, bb ",aa(:,:),bb(:,:)
1593 ! write (iout,*) "sigsq",sigsq," sig",sig," eps2rt",eps2rt,& !d
1594 ! " eps3rt",eps3rt," eps1",eps1," e1",e1," e2",e2," fac",fac !d
1595 evdwij=evdwij*eps2rt*eps3rt
1596 evdw=evdw+evdwij*sss_ele_cut
1598 sigm=dabs(aa/bb)**(1.0D0/6.0D0)
1599 epsi=bb**2/aa!(itypi,itypj)
1600 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
1601 restyp(itypi,1),i,restyp(itypj,1),j, &
1602 epsi,sigm,chi1,chi2,chip1,chip2, &
1603 eps1,eps2rt**2,eps3rt**2,sig,sig0ij, &
1604 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift, &
1608 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,2e10.2,e11.3)')&
1609 'evdw',i,j,evdwij,xi,xj,rij !,"egb"
1610 !C print *,i,j,c(1,i),c(1,j),c(2,i),c(2,j),c(3,i),c(3,j)
1611 ! if (energy_dec) write (iout,*) &
1614 ! Calculate gradient components.
1615 e1=e1*eps1*eps2rt**2*eps3rt**2
1616 fac=-expon*(e1+evdwij)*rij_shift
1619 ! print *,'before fac',fac,rij,evdwij
1620 fac=fac+evdwij*sss_ele_grad/sss_ele_cut&
1621 /sigma(itypi,itypj)*rij
1622 ! print *,'grad part scale',fac, &
1623 ! evdwij*sss_ele_grad/sss_ele_cut &
1624 ! /sigma(itypi,itypj)*rij
1626 ! Calculate the radial part of the gradient
1630 !C Calculate the radial part of the gradient
1631 gg_lipi(3)=eps1*(eps2rt*eps2rt)&
1632 *(eps3rt*eps3rt)*sss_ele_cut/2.0d0*(faclip*faclip*&
1633 (aa_lip(itypi,itypj)-aa_aq(itypi,itypj))&
1634 +faclip*(bb_lip(itypi,itypj)-bb_aq(itypi,itypj)))
1635 gg_lipj(3)=ssgradlipj*gg_lipi(3)
1636 gg_lipi(3)=gg_lipi(3)*ssgradlipi
1638 ! print *,'before sc_grad', gg(1),gg(2),gg(3)
1639 ! Calculate angular part of the gradient.
1645 ! write (iout,*) "Number of loop steps in EGB:",ind
1646 !ccc energy_dec=.false.
1649 !-----------------------------------------------------------------------------
1650 subroutine egbv(evdw)
1652 ! This subroutine calculates the interaction energy of nonbonded side chains
1653 ! assuming the Gay-Berne-Vorobjev potential of interaction.
1657 ! implicit real*8 (a-h,o-z)
1658 ! include 'DIMENSIONS'
1659 ! include 'COMMON.GEO'
1660 ! include 'COMMON.VAR'
1661 ! include 'COMMON.LOCAL'
1662 ! include 'COMMON.CHAIN'
1663 ! include 'COMMON.DERIV'
1664 ! include 'COMMON.NAMES'
1665 ! include 'COMMON.INTERACT'
1666 ! include 'COMMON.IOUNITS'
1667 ! include 'COMMON.CALC'
1669 !el integer :: icall
1670 !el common /srutu/ icall
1673 integer :: iint,itypi,itypi1,itypj
1674 real(kind=8) :: rrij,xi,yi,zi,r0ij,fac_augm,e_augm,fac,e1,e2,sigm
1675 real(kind=8) :: evdw,sig0ij,sig,rij_shift,epsi
1677 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
1680 ! if (icall.eq.0) lprn=.true.
1682 do i=iatsc_s,iatsc_e
1683 itypi=iabs(itype(i,1))
1684 if (itypi.eq.ntyp1) cycle
1685 itypi1=iabs(itype(i+1,1))
1689 dxi=dc_norm(1,nres+i)
1690 dyi=dc_norm(2,nres+i)
1691 dzi=dc_norm(3,nres+i)
1692 ! dsci_inv=dsc_inv(itypi)
1693 dsci_inv=vbld_inv(i+nres)
1695 ! Calculate SC interaction energy.
1697 do iint=1,nint_gr(i)
1698 do j=istart(i,iint),iend(i,iint)
1700 itypj=iabs(itype(j,1))
1701 if (itypj.eq.ntyp1) cycle
1702 ! dscj_inv=dsc_inv(itypj)
1703 dscj_inv=vbld_inv(j+nres)
1704 sig0ij=sigma(itypi,itypj)
1705 r0ij=r0(itypi,itypj)
1706 chi1=chi(itypi,itypj)
1707 chi2=chi(itypj,itypi)
1714 alf12=0.5D0*(alf1+alf2)
1715 ! For diagnostics only!!!
1728 dxj=dc_norm(1,nres+j)
1729 dyj=dc_norm(2,nres+j)
1730 dzj=dc_norm(3,nres+j)
1731 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1733 ! Calculate angle-dependent terms of energy and contributions to their
1737 sig=sig0ij*dsqrt(sigsq)
1738 rij_shift=1.0D0/rij-sig+r0ij
1739 ! I hate to put IF's in the loops, but here don't have another choice!!!!
1740 if (rij_shift.le.0.0D0) then
1745 !---------------------------------------------------------------
1746 rij_shift=1.0D0/rij_shift
1747 fac=rij_shift**expon
1748 e1=fac*fac*aa_aq(itypi,itypj)
1749 e2=fac*bb_aq(itypi,itypj)
1750 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
1751 eps2der=evdwij*eps3rt
1752 eps3der=evdwij*eps2rt
1753 fac_augm=rrij**expon
1754 e_augm=augm(itypi,itypj)*fac_augm
1755 evdwij=evdwij*eps2rt*eps3rt
1756 evdw=evdw+evdwij+e_augm
1758 sigm=dabs(aa_aq(itypi,itypj)/&
1759 bb_aq(itypi,itypj))**(1.0D0/6.0D0)
1760 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
1761 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
1762 restyp(itypi,1),i,restyp(itypj,1),j,&
1763 epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),&
1764 chi1,chi2,chip1,chip2,&
1765 eps1,eps2rt**2,eps3rt**2,&
1766 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
1769 ! Calculate gradient components.
1770 e1=e1*eps1*eps2rt**2*eps3rt**2
1771 fac=-expon*(e1+evdwij)*rij_shift
1773 fac=rij*fac-2*expon*rrij*e_augm
1774 ! Calculate the radial part of the gradient
1778 ! Calculate angular part of the gradient.
1784 !-----------------------------------------------------------------------------
1785 !el subroutine sc_angular in module geometry
1786 !-----------------------------------------------------------------------------
1787 subroutine e_softsphere(evdw)
1789 ! This subroutine calculates the interaction energy of nonbonded side chains
1790 ! assuming the LJ potential of interaction.
1792 ! implicit real*8 (a-h,o-z)
1793 ! include 'DIMENSIONS'
1794 real(kind=8),parameter :: accur=1.0d-10
1795 ! include 'COMMON.GEO'
1796 ! include 'COMMON.VAR'
1797 ! include 'COMMON.LOCAL'
1798 ! include 'COMMON.CHAIN'
1799 ! include 'COMMON.DERIV'
1800 ! include 'COMMON.INTERACT'
1801 ! include 'COMMON.TORSION'
1802 ! include 'COMMON.SBRIDGE'
1803 ! include 'COMMON.NAMES'
1804 ! include 'COMMON.IOUNITS'
1805 ! include 'COMMON.CONTACTS'
1806 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
1807 !d print *,'Entering Esoft_sphere nnt=',nnt,' nct=',nct
1809 integer :: i,iint,j,itypi,itypi1,itypj,k
1810 real(kind=8) :: evdw,xj,yj,zj,xi,yi,zi,rij,r0ij,r0ijsq,evdwij
1814 do i=iatsc_s,iatsc_e
1815 itypi=iabs(itype(i,1))
1816 if (itypi.eq.ntyp1) cycle
1817 itypi1=iabs(itype(i+1,1))
1822 ! Calculate SC interaction energy.
1824 do iint=1,nint_gr(i)
1825 !d write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
1826 !d & 'iend=',iend(i,iint)
1827 do j=istart(i,iint),iend(i,iint)
1828 itypj=iabs(itype(j,1))
1829 if (itypj.eq.ntyp1) cycle
1833 rij=xj*xj+yj*yj+zj*zj
1834 ! write (iout,*)'i=',i,' j=',j,' itypi=',itypi,' itypj=',itypj
1835 r0ij=r0(itypi,itypj)
1837 ! print *,i,j,r0ij,dsqrt(rij)
1838 if (rij.lt.r0ijsq) then
1839 evdwij=0.25d0*(rij-r0ijsq)**2
1847 ! Calculate the components of the gradient in DC and X
1853 gvdwx(k,i)=gvdwx(k,i)-gg(k)
1854 gvdwx(k,j)=gvdwx(k,j)+gg(k)
1855 gvdwc(k,i)=gvdwc(k,i)-gg(k)
1856 gvdwc(k,j)=gvdwc(k,j)+gg(k)
1860 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
1867 end subroutine e_softsphere
1868 !-----------------------------------------------------------------------------
1869 subroutine eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
1871 ! Soft-sphere potential of p-p interaction
1873 ! implicit real*8 (a-h,o-z)
1874 ! include 'DIMENSIONS'
1875 ! include 'COMMON.CONTROL'
1876 ! include 'COMMON.IOUNITS'
1877 ! include 'COMMON.GEO'
1878 ! include 'COMMON.VAR'
1879 ! include 'COMMON.LOCAL'
1880 ! include 'COMMON.CHAIN'
1881 ! include 'COMMON.DERIV'
1882 ! include 'COMMON.INTERACT'
1883 ! include 'COMMON.CONTACTS'
1884 ! include 'COMMON.TORSION'
1885 ! include 'COMMON.VECTORS'
1886 ! include 'COMMON.FFIELD'
1887 real(kind=8),dimension(3) :: ggg
1888 !d write(iout,*) 'In EELEC_soft_sphere'
1890 integer :: i,j,k,num_conti,iteli,itelj
1891 real(kind=8) :: ees,evdw1,eel_loc,eello_turn3,eello_turn4
1892 real(kind=8) :: dxi,dyi,dzi,xmedi,ymedi,zmedi,r0ij,r0ijsq
1893 real(kind=8) :: dxj,dyj,dzj,xj,yj,zj,rij,evdw1ij,fac
1901 do i=iatel_s,iatel_e
1902 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
1906 xmedi=c(1,i)+0.5d0*dxi
1907 ymedi=c(2,i)+0.5d0*dyi
1908 zmedi=c(3,i)+0.5d0*dzi
1910 ! write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
1911 do j=ielstart(i),ielend(i)
1912 if (itype(j,1).eq.ntyp1 .or. itype(j+1,1).eq.ntyp1) cycle
1916 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
1917 r0ij=rpp(iteli,itelj)
1922 xj=c(1,j)+0.5D0*dxj-xmedi
1923 yj=c(2,j)+0.5D0*dyj-ymedi
1924 zj=c(3,j)+0.5D0*dzj-zmedi
1925 rij=xj*xj+yj*yj+zj*zj
1926 if (rij.lt.r0ijsq) then
1927 evdw1ij=0.25d0*(rij-r0ijsq)**2
1935 ! Calculate contributions to the Cartesian gradient.
1941 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
1942 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
1945 ! Loop over residues i+1 thru j-1.
1949 !grad gelc(l,k)=gelc(l,k)+ggg(l)
1954 !grad do i=nnt,nct-1
1956 !grad gelc(k,i)=gelc(k,i)+0.5d0*gelc(k,i)
1958 !grad do j=i+1,nct-1
1960 !grad gelc(k,i)=gelc(k,i)+gelc(k,j)
1965 end subroutine eelec_soft_sphere
1966 !-----------------------------------------------------------------------------
1967 subroutine vec_and_deriv
1968 ! implicit real*8 (a-h,o-z)
1969 ! include 'DIMENSIONS'
1973 ! include 'COMMON.IOUNITS'
1974 ! include 'COMMON.GEO'
1975 ! include 'COMMON.VAR'
1976 ! include 'COMMON.LOCAL'
1977 ! include 'COMMON.CHAIN'
1978 ! include 'COMMON.VECTORS'
1979 ! include 'COMMON.SETUP'
1980 ! include 'COMMON.TIME1'
1981 real(kind=8),dimension(3,3,2) :: uyder,uzder
1982 real(kind=8),dimension(2) :: vbld_inv_temp
1983 ! Compute the local reference systems. For reference system (i), the
1984 ! X-axis points from CA(i) to CA(i+1), the Y axis is in the
1985 ! CA(i)-CA(i+1)-CA(i+2) plane, and the Z axis is perpendicular to this plane.
1988 real(kind=8) :: facy,fac,costh
1991 do i=ivec_start,ivec_end
1995 if (i.eq.nres-1) then
1996 ! Case of the last full residue
1997 ! Compute the Z-axis
1998 call vecpr(dc_norm(1,i),dc_norm(1,i-1),uz(1,i))
1999 costh=dcos(pi-theta(nres))
2000 fac=1.0d0/dsqrt(1.0d0-costh*costh)
2004 ! Compute the derivatives of uz
2006 uzder(2,1,1)=-dc_norm(3,i-1)
2007 uzder(3,1,1)= dc_norm(2,i-1)
2008 uzder(1,2,1)= dc_norm(3,i-1)
2010 uzder(3,2,1)=-dc_norm(1,i-1)
2011 uzder(1,3,1)=-dc_norm(2,i-1)
2012 uzder(2,3,1)= dc_norm(1,i-1)
2015 uzder(2,1,2)= dc_norm(3,i)
2016 uzder(3,1,2)=-dc_norm(2,i)
2017 uzder(1,2,2)=-dc_norm(3,i)
2019 uzder(3,2,2)= dc_norm(1,i)
2020 uzder(1,3,2)= dc_norm(2,i)
2021 uzder(2,3,2)=-dc_norm(1,i)
2023 ! Compute the Y-axis
2026 uy(k,i)=fac*(dc_norm(k,i-1)-costh*dc_norm(k,i))
2028 ! Compute the derivatives of uy
2031 uyder(k,j,1)=2*dc_norm(k,i-1)*dc_norm(j,i) &
2032 -dc_norm(k,i)*dc_norm(j,i-1)
2033 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
2035 uyder(j,j,1)=uyder(j,j,1)-costh
2036 uyder(j,j,2)=1.0d0+uyder(j,j,2)
2041 uygrad(l,k,j,i)=uyder(l,k,j)
2042 uzgrad(l,k,j,i)=uzder(l,k,j)
2046 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
2047 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
2048 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
2049 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
2052 ! Compute the Z-axis
2053 call vecpr(dc_norm(1,i),dc_norm(1,i+1),uz(1,i))
2054 costh=dcos(pi-theta(i+2))
2055 fac=1.0d0/dsqrt(1.0d0-costh*costh)
2059 ! Compute the derivatives of uz
2061 uzder(2,1,1)=-dc_norm(3,i+1)
2062 uzder(3,1,1)= dc_norm(2,i+1)
2063 uzder(1,2,1)= dc_norm(3,i+1)
2065 uzder(3,2,1)=-dc_norm(1,i+1)
2066 uzder(1,3,1)=-dc_norm(2,i+1)
2067 uzder(2,3,1)= dc_norm(1,i+1)
2070 uzder(2,1,2)= dc_norm(3,i)
2071 uzder(3,1,2)=-dc_norm(2,i)
2072 uzder(1,2,2)=-dc_norm(3,i)
2074 uzder(3,2,2)= dc_norm(1,i)
2075 uzder(1,3,2)= dc_norm(2,i)
2076 uzder(2,3,2)=-dc_norm(1,i)
2078 ! Compute the Y-axis
2081 uy(k,i)=facy*(dc_norm(k,i+1)-costh*dc_norm(k,i))
2083 ! Compute the derivatives of uy
2086 uyder(k,j,1)=2*dc_norm(k,i+1)*dc_norm(j,i) &
2087 -dc_norm(k,i)*dc_norm(j,i+1)
2088 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
2090 uyder(j,j,1)=uyder(j,j,1)-costh
2091 uyder(j,j,2)=1.0d0+uyder(j,j,2)
2096 uygrad(l,k,j,i)=uyder(l,k,j)
2097 uzgrad(l,k,j,i)=uzder(l,k,j)
2101 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
2102 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
2103 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
2104 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
2108 vbld_inv_temp(1)=vbld_inv(i+1)
2109 if (i.lt.nres-1) then
2110 vbld_inv_temp(2)=vbld_inv(i+2)
2112 vbld_inv_temp(2)=vbld_inv(i)
2117 uygrad(l,k,j,i)=vbld_inv_temp(j)*uygrad(l,k,j,i)
2118 uzgrad(l,k,j,i)=vbld_inv_temp(j)*uzgrad(l,k,j,i)
2123 #if defined(PARVEC) && defined(MPI)
2124 if (nfgtasks1.gt.1) then
2126 ! print *,"Processor",fg_rank1,kolor1," ivec_start",ivec_start,
2127 ! & " ivec_displ",(ivec_displ(i),i=0,nfgtasks1-1),
2128 ! & " ivec_count",(ivec_count(i),i=0,nfgtasks1-1)
2129 call MPI_Allgatherv(uy(1,ivec_start),ivec_count(fg_rank1),&
2130 MPI_UYZ,uy(1,1),ivec_count(0),ivec_displ(0),MPI_UYZ,&
2132 call MPI_Allgatherv(uz(1,ivec_start),ivec_count(fg_rank1),&
2133 MPI_UYZ,uz(1,1),ivec_count(0),ivec_displ(0),MPI_UYZ,&
2135 call MPI_Allgatherv(uygrad(1,1,1,ivec_start),&
2136 ivec_count(fg_rank1),MPI_UYZGRAD,uygrad(1,1,1,1),ivec_count(0),&
2137 ivec_displ(0),MPI_UYZGRAD,FG_COMM1,IERR)
2138 call MPI_Allgatherv(uzgrad(1,1,1,ivec_start),&
2139 ivec_count(fg_rank1),MPI_UYZGRAD,uzgrad(1,1,1,1),ivec_count(0),&
2140 ivec_displ(0),MPI_UYZGRAD,FG_COMM1,IERR)
2141 time_gather=time_gather+MPI_Wtime()-time00
2143 ! if (fg_rank.eq.0) then
2144 ! write (iout,*) "Arrays UY and UZ"
2146 ! write (iout,'(i5,3f10.5,5x,3f10.5)') i,(uy(k,i),k=1,3),
2152 end subroutine vec_and_deriv
2153 !-----------------------------------------------------------------------------
2154 subroutine check_vecgrad
2155 ! implicit real*8 (a-h,o-z)
2156 ! include 'DIMENSIONS'
2157 ! include 'COMMON.IOUNITS'
2158 ! include 'COMMON.GEO'
2159 ! include 'COMMON.VAR'
2160 ! include 'COMMON.LOCAL'
2161 ! include 'COMMON.CHAIN'
2162 ! include 'COMMON.VECTORS'
2163 real(kind=8),dimension(3,3,2,nres) :: uygradt,uzgradt !(3,3,2,maxres)
2164 real(kind=8),dimension(3,nres) :: uyt,uzt !(3,maxres)
2165 real(kind=8),dimension(3,3,2) :: uygradn,uzgradn
2166 real(kind=8),dimension(3) :: erij
2167 real(kind=8) :: delta=1.0d-7
2173 !rc write(iout,'(2i5,2(3f10.5,5x))') i,1,dc_norm(:,i)
2174 !rc write(iout,'(2i5,2(3f10.5,5x))') i,2,uy(:,i)
2175 !rc write(iout,'(2i5,2(3f10.5,5x)/)')i,3,uz(:,i)
2176 !d write(iout,'(2i5,2(3f10.5,5x))') i,1,
2177 !d & (dc_norm(if90,i),if90=1,3)
2178 !d write(iout,'(2i5,2(3f10.5,5x))') i,2,(uy(if90,i),if90=1,3)
2179 !d write(iout,'(2i5,2(3f10.5,5x)/)')i,3,(uz(if90,i),if90=1,3)
2180 !d write(iout,'(a)')
2186 uygradt(l,k,j,i)=uygrad(l,k,j,i)
2187 uzgradt(l,k,j,i)=uzgrad(l,k,j,i)
2200 !d write (iout,*) 'i=',i
2202 erij(k)=dc_norm(k,i)
2206 dc_norm(k,i)=erij(k)
2208 dc_norm(j,i)=dc_norm(j,i)+delta
2209 ! fac=dsqrt(scalar(dc_norm(1,i),dc_norm(1,i)))
2211 ! dc_norm(k,i)=dc_norm(k,i)/fac
2213 ! write (iout,*) (dc_norm(k,i),k=1,3)
2214 ! write (iout,*) (erij(k),k=1,3)
2217 uygradn(k,j,1)=(uy(k,i)-uyt(k,i))/delta
2218 uygradn(k,j,2)=(uy(k,i-1)-uyt(k,i-1))/delta
2219 uzgradn(k,j,1)=(uz(k,i)-uzt(k,i))/delta
2220 uzgradn(k,j,2)=(uz(k,i-1)-uzt(k,i-1))/delta
2222 ! write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2223 ! & j,(uzgradt(k,j,1,i),k=1,3),(uzgradn(k,j,1),k=1,3),
2224 ! & (uzgradt(k,j,2,i-1),k=1,3),(uzgradn(k,j,2),k=1,3)
2227 dc_norm(k,i)=erij(k)
2230 !d write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2231 !d & k,(uygradt(k,l,1,i),l=1,3),(uygradn(k,l,1),l=1,3),
2232 !d & (uygradt(k,l,2,i-1),l=1,3),(uygradn(k,l,2),l=1,3)
2233 !d write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2234 !d & k,(uzgradt(k,l,1,i),l=1,3),(uzgradn(k,l,1),l=1,3),
2235 !d & (uzgradt(k,l,2,i-1),l=1,3),(uzgradn(k,l,2),l=1,3)
2236 !d write (iout,'(a)')
2240 end subroutine check_vecgrad
2241 !-----------------------------------------------------------------------------
2242 subroutine set_matrices
2243 ! implicit real*8 (a-h,o-z)
2244 ! include 'DIMENSIONS'
2247 ! include "COMMON.SETUP"
2249 integer :: status(MPI_STATUS_SIZE)
2251 ! include 'COMMON.IOUNITS'
2252 ! include 'COMMON.GEO'
2253 ! include 'COMMON.VAR'
2254 ! include 'COMMON.LOCAL'
2255 ! include 'COMMON.CHAIN'
2256 ! include 'COMMON.DERIV'
2257 ! include 'COMMON.INTERACT'
2258 ! include 'COMMON.CONTACTS'
2259 ! include 'COMMON.TORSION'
2260 ! include 'COMMON.VECTORS'
2261 ! include 'COMMON.FFIELD'
2262 real(kind=8) :: auxvec(2),auxmat(2,2)
2263 integer :: i,iti1,iti,k,l
2264 real(kind=8) :: sin1,cos1,sin2,cos2,dwacos2,dwasin2
2265 ! print *,"in set matrices"
2267 ! Compute the virtual-bond-torsional-angle dependent quantities needed
2268 ! to calculate the el-loc multibody terms of various order.
2272 do i=ivec_start+2,ivec_end+2
2277 if (i .lt. nres+1) then
2314 if (i .gt. 3 .and. i .lt. nres+1) then
2315 obrot_der(1,i-2)=-sin1
2316 obrot_der(2,i-2)= cos1
2317 Ugder(1,1,i-2)= sin1
2318 Ugder(1,2,i-2)=-cos1
2319 Ugder(2,1,i-2)=-cos1
2320 Ugder(2,2,i-2)=-sin1
2323 obrot2_der(1,i-2)=-dwasin2
2324 obrot2_der(2,i-2)= dwacos2
2325 Ug2der(1,1,i-2)= dwasin2
2326 Ug2der(1,2,i-2)=-dwacos2
2327 Ug2der(2,1,i-2)=-dwacos2
2328 Ug2der(2,2,i-2)=-dwasin2
2330 obrot_der(1,i-2)=0.0d0
2331 obrot_der(2,i-2)=0.0d0
2332 Ugder(1,1,i-2)=0.0d0
2333 Ugder(1,2,i-2)=0.0d0
2334 Ugder(2,1,i-2)=0.0d0
2335 Ugder(2,2,i-2)=0.0d0
2336 obrot2_der(1,i-2)=0.0d0
2337 obrot2_der(2,i-2)=0.0d0
2338 Ug2der(1,1,i-2)=0.0d0
2339 Ug2der(1,2,i-2)=0.0d0
2340 Ug2der(2,1,i-2)=0.0d0
2341 Ug2der(2,2,i-2)=0.0d0
2343 ! if (i.gt. iatel_s+2 .and. i.lt.iatel_e+5) then
2344 if (i.gt. nnt+2 .and. i.lt.nct+2) then
2345 iti = itortyp(itype(i-2,1))
2349 ! if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
2350 if (i.gt. nnt+1 .and. i.lt.nct+1) then
2351 iti1 = itortyp(itype(i-1,1))
2355 ! print *,iti,i,"iti",iti1,itype(i-1,1),itype(i-2,1)
2356 !d write (iout,*) '*******i',i,' iti1',iti
2357 !d write (iout,*) 'b1',b1(:,iti)
2358 !d write (iout,*) 'b2',b2(:,iti)
2359 !d write (iout,*) 'Ug',Ug(:,:,i-2)
2360 ! if (i .gt. iatel_s+2) then
2361 if (i .gt. nnt+2) then
2362 call matvec2(Ug(1,1,i-2),b2(1,iti),Ub2(1,i-2))
2363 call matmat2(EE(1,1,iti),Ug(1,1,i-2),EUg(1,1,i-2))
2364 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) &
2366 call matmat2(CC(1,1,iti),Ug(1,1,i-2),CUg(1,1,i-2))
2367 call matmat2(DD(1,1,iti),Ug(1,1,i-2),DUg(1,1,i-2))
2368 call matmat2(Dtilde(1,1,iti),Ug2(1,1,i-2),DtUg2(1,1,i-2))
2369 call matvec2(Ctilde(1,1,iti1),obrot(1,i-2),Ctobr(1,i-2))
2370 call matvec2(Dtilde(1,1,iti),obrot2(1,i-2),Dtobr2(1,i-2))
2381 DtUg2(l,k,i-2)=0.0d0
2385 call matvec2(Ugder(1,1,i-2),b2(1,iti),Ub2der(1,i-2))
2386 call matmat2(EE(1,1,iti),Ugder(1,1,i-2),EUgder(1,1,i-2))
2388 muder(k,i-2)=Ub2der(k,i-2)
2390 ! if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
2391 if (i.gt. nnt+1 .and. i.lt.nct+1) then
2392 if (itype(i-1,1).le.ntyp) then
2393 iti1 = itortyp(itype(i-1,1))
2401 mu(k,i-2)=Ub2(k,i-2)+b1(k,iti1)
2403 ! if (energy_dec) write (iout,*) 'Ub2 ',i,Ub2(:,i-2)
2404 ! if (energy_dec) write (iout,*) 'b1 ',iti1,b1(:,iti1)
2405 ! if (energy_dec) write (iout,*) 'mu ',i,iti1,mu(:,i-2)
2406 !d write (iout,*) 'mu1',mu1(:,i-2)
2407 !d write (iout,*) 'mu2',mu2(:,i-2)
2408 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.wcorr6.gt.0.0d0) &
2410 call matmat2(CC(1,1,iti1),Ugder(1,1,i-2),CUgder(1,1,i-2))
2411 call matmat2(DD(1,1,iti),Ugder(1,1,i-2),DUgder(1,1,i-2))
2412 call matmat2(Dtilde(1,1,iti),Ug2der(1,1,i-2),DtUg2der(1,1,i-2))
2413 call matvec2(Ctilde(1,1,iti1),obrot_der(1,i-2),Ctobrder(1,i-2))
2414 call matvec2(Dtilde(1,1,iti),obrot2_der(1,i-2),Dtobr2der(1,i-2))
2415 ! Vectors and matrices dependent on a single virtual-bond dihedral.
2416 call matvec2(DD(1,1,iti),b1tilde(1,iti1),auxvec(1))
2417 call matvec2(Ug2(1,1,i-2),auxvec(1),Ug2Db1t(1,i-2))
2418 call matvec2(Ug2der(1,1,i-2),auxvec(1),Ug2Db1tder(1,i-2))
2419 call matvec2(CC(1,1,iti1),Ub2(1,i-2),CUgb2(1,i-2))
2420 call matvec2(CC(1,1,iti1),Ub2der(1,i-2),CUgb2der(1,i-2))
2421 call matmat2(EUg(1,1,i-2),CC(1,1,iti1),EUgC(1,1,i-2))
2422 call matmat2(EUgder(1,1,i-2),CC(1,1,iti1),EUgCder(1,1,i-2))
2423 call matmat2(EUg(1,1,i-2),DD(1,1,iti1),EUgD(1,1,i-2))
2424 call matmat2(EUgder(1,1,i-2),DD(1,1,iti1),EUgDder(1,1,i-2))
2427 ! Matrices dependent on two consecutive virtual-bond dihedrals.
2428 ! The order of matrices is from left to right.
2429 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.wcorr6.gt.0.0d0) &
2431 ! do i=max0(ivec_start,2),ivec_end
2433 call matmat2(DtUg2(1,1,i-1),EUg(1,1,i),DtUg2EUg(1,1,i))
2434 call matmat2(DtUg2der(1,1,i-1),EUg(1,1,i),DtUg2EUgder(1,1,1,i))
2435 call matmat2(DtUg2(1,1,i-1),EUgder(1,1,i),DtUg2EUgder(1,1,2,i))
2436 call transpose2(DtUg2(1,1,i-1),auxmat(1,1))
2437 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUg(1,1,i))
2438 call matmat2(auxmat(1,1),EUgder(1,1,i),Ug2DtEUgder(1,1,2,i))
2439 call transpose2(DtUg2der(1,1,i-1),auxmat(1,1))
2440 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUgder(1,1,1,i))
2443 #if defined(MPI) && defined(PARMAT)
2445 ! if (fg_rank.eq.0) then
2446 write (iout,*) "Arrays UG and UGDER before GATHER"
2448 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2449 ((ug(l,k,i),l=1,2),k=1,2),&
2450 ((ugder(l,k,i),l=1,2),k=1,2)
2452 write (iout,*) "Arrays UG2 and UG2DER"
2454 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2455 ((ug2(l,k,i),l=1,2),k=1,2),&
2456 ((ug2der(l,k,i),l=1,2),k=1,2)
2458 write (iout,*) "Arrays OBROT OBROT2 OBROTDER and OBROT2DER"
2460 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2461 (obrot(k,i),k=1,2),(obrot2(k,i),k=1,2),&
2462 (obrot_der(k,i),k=1,2),(obrot2_der(k,i),k=1,2)
2464 write (iout,*) "Arrays COSTAB SINTAB COSTAB2 and SINTAB2"
2466 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2467 costab(i),sintab(i),costab2(i),sintab2(i)
2469 write (iout,*) "Array MUDER"
2471 write (iout,'(i5,2f10.5)') i,muder(1,i),muder(2,i)
2475 if (nfgtasks.gt.1) then
2477 ! write(iout,*)"Processor",fg_rank,kolor," ivec_start",ivec_start,
2478 ! & " ivec_displ",(ivec_displ(i),i=0,nfgtasks-1),
2479 ! & " ivec_count",(ivec_count(i),i=0,nfgtasks-1)
2481 call MPI_Allgatherv(Ub2(1,ivec_start),ivec_count(fg_rank1),&
2482 MPI_MU,Ub2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2484 call MPI_Allgatherv(Ub2der(1,ivec_start),ivec_count(fg_rank1),&
2485 MPI_MU,Ub2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2487 call MPI_Allgatherv(mu(1,ivec_start),ivec_count(fg_rank1),&
2488 MPI_MU,mu(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2490 call MPI_Allgatherv(muder(1,ivec_start),ivec_count(fg_rank1),&
2491 MPI_MU,muder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2493 call MPI_Allgatherv(Eug(1,1,ivec_start),ivec_count(fg_rank1),&
2494 MPI_MAT1,Eug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2496 call MPI_Allgatherv(Eugder(1,1,ivec_start),ivec_count(fg_rank1),&
2497 MPI_MAT1,Eugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2499 call MPI_Allgatherv(costab(ivec_start),ivec_count(fg_rank1),&
2500 MPI_DOUBLE_PRECISION,costab(1),ivec_count(0),ivec_displ(0),&
2501 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
2502 call MPI_Allgatherv(sintab(ivec_start),ivec_count(fg_rank1),&
2503 MPI_DOUBLE_PRECISION,sintab(1),ivec_count(0),ivec_displ(0),&
2504 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
2505 call MPI_Allgatherv(costab2(ivec_start),ivec_count(fg_rank1),&
2506 MPI_DOUBLE_PRECISION,costab2(1),ivec_count(0),ivec_displ(0),&
2507 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
2508 call MPI_Allgatherv(sintab2(ivec_start),ivec_count(fg_rank1),&
2509 MPI_DOUBLE_PRECISION,sintab2(1),ivec_count(0),ivec_displ(0),&
2510 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
2511 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) &
2513 call MPI_Allgatherv(Ctobr(1,ivec_start),ivec_count(fg_rank1),&
2514 MPI_MU,Ctobr(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2516 call MPI_Allgatherv(Ctobrder(1,ivec_start),ivec_count(fg_rank1),&
2517 MPI_MU,Ctobrder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2519 call MPI_Allgatherv(Dtobr2(1,ivec_start),ivec_count(fg_rank1),&
2520 MPI_MU,Dtobr2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2522 call MPI_Allgatherv(Dtobr2der(1,ivec_start),ivec_count(fg_rank1),&
2523 MPI_MU,Dtobr2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2525 call MPI_Allgatherv(Ug2Db1t(1,ivec_start),ivec_count(fg_rank1),&
2526 MPI_MU,Ug2Db1t(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2528 call MPI_Allgatherv(Ug2Db1tder(1,ivec_start),&
2529 ivec_count(fg_rank1),&
2530 MPI_MU,Ug2Db1tder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2532 call MPI_Allgatherv(CUgb2(1,ivec_start),ivec_count(fg_rank1),&
2533 MPI_MU,CUgb2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2535 call MPI_Allgatherv(CUgb2der(1,ivec_start),ivec_count(fg_rank1),&
2536 MPI_MU,CUgb2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2538 call MPI_Allgatherv(Cug(1,1,ivec_start),ivec_count(fg_rank1),&
2539 MPI_MAT1,Cug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2541 call MPI_Allgatherv(Cugder(1,1,ivec_start),ivec_count(fg_rank1),&
2542 MPI_MAT1,Cugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2544 call MPI_Allgatherv(Dug(1,1,ivec_start),ivec_count(fg_rank1),&
2545 MPI_MAT1,Dug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2547 call MPI_Allgatherv(Dugder(1,1,ivec_start),ivec_count(fg_rank1),&
2548 MPI_MAT1,Dugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2550 call MPI_Allgatherv(Dtug2(1,1,ivec_start),ivec_count(fg_rank1),&
2551 MPI_MAT1,Dtug2(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2553 call MPI_Allgatherv(Dtug2der(1,1,ivec_start),&
2554 ivec_count(fg_rank1),&
2555 MPI_MAT1,Dtug2der(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2557 call MPI_Allgatherv(EugC(1,1,ivec_start),ivec_count(fg_rank1),&
2558 MPI_MAT1,EugC(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2560 call MPI_Allgatherv(EugCder(1,1,ivec_start),ivec_count(fg_rank1),&
2561 MPI_MAT1,EugCder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2563 call MPI_Allgatherv(EugD(1,1,ivec_start),ivec_count(fg_rank1),&
2564 MPI_MAT1,EugD(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2566 call MPI_Allgatherv(EugDder(1,1,ivec_start),ivec_count(fg_rank1),&
2567 MPI_MAT1,EugDder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2569 call MPI_Allgatherv(DtUg2EUg(1,1,ivec_start),&
2570 ivec_count(fg_rank1),&
2571 MPI_MAT1,DtUg2EUg(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2573 call MPI_Allgatherv(Ug2DtEUg(1,1,ivec_start),&
2574 ivec_count(fg_rank1),&
2575 MPI_MAT1,Ug2DtEUg(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2577 call MPI_Allgatherv(DtUg2EUgder(1,1,1,ivec_start),&
2578 ivec_count(fg_rank1),&
2579 MPI_MAT2,DtUg2EUgder(1,1,1,1),ivec_count(0),ivec_displ(0),&
2580 MPI_MAT2,FG_COMM1,IERR)
2581 call MPI_Allgatherv(Ug2DtEUgder(1,1,1,ivec_start),&
2582 ivec_count(fg_rank1),&
2583 MPI_MAT2,Ug2DtEUgder(1,1,1,1),ivec_count(0),ivec_displ(0),&
2584 MPI_MAT2,FG_COMM1,IERR)
2587 ! Passes matrix info through the ring
2590 if (irecv.lt.0) irecv=nfgtasks1-1
2593 if (inext.ge.nfgtasks1) inext=0
2595 ! write (iout,*) "isend",isend," irecv",irecv
2597 lensend=lentyp(isend)
2598 lenrecv=lentyp(irecv)
2599 ! write (iout,*) "lensend",lensend," lenrecv",lenrecv
2600 ! call MPI_SENDRECV(ug(1,1,ivec_displ(isend)+1),1,
2601 ! & MPI_ROTAT1(lensend),inext,2200+isend,
2602 ! & ug(1,1,ivec_displ(irecv)+1),1,MPI_ROTAT1(lenrecv),
2603 ! & iprev,2200+irecv,FG_COMM,status,IERR)
2604 ! write (iout,*) "Gather ROTAT1"
2606 ! call MPI_SENDRECV(obrot(1,ivec_displ(isend)+1),1,
2607 ! & MPI_ROTAT2(lensend),inext,3300+isend,
2608 ! & obrot(1,ivec_displ(irecv)+1),1,MPI_ROTAT2(lenrecv),
2609 ! & iprev,3300+irecv,FG_COMM,status,IERR)
2610 ! write (iout,*) "Gather ROTAT2"
2612 call MPI_SENDRECV(costab(ivec_displ(isend)+1),1,&
2613 MPI_ROTAT_OLD(lensend),inext,4400+isend,&
2614 costab(ivec_displ(irecv)+1),1,MPI_ROTAT_OLD(lenrecv),&
2615 iprev,4400+irecv,FG_COMM,status,IERR)
2616 ! write (iout,*) "Gather ROTAT_OLD"
2618 call MPI_SENDRECV(mu(1,ivec_displ(isend)+1),1,&
2619 MPI_PRECOMP11(lensend),inext,5500+isend,&
2620 mu(1,ivec_displ(irecv)+1),1,MPI_PRECOMP11(lenrecv),&
2621 iprev,5500+irecv,FG_COMM,status,IERR)
2622 ! write (iout,*) "Gather PRECOMP11"
2624 call MPI_SENDRECV(Eug(1,1,ivec_displ(isend)+1),1,&
2625 MPI_PRECOMP12(lensend),inext,6600+isend,&
2626 Eug(1,1,ivec_displ(irecv)+1),1,MPI_PRECOMP12(lenrecv),&
2627 iprev,6600+irecv,FG_COMM,status,IERR)
2628 ! write (iout,*) "Gather PRECOMP12"
2630 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) &
2632 call MPI_SENDRECV(ug2db1t(1,ivec_displ(isend)+1),1,&
2633 MPI_ROTAT2(lensend),inext,7700+isend,&
2634 ug2db1t(1,ivec_displ(irecv)+1),1,MPI_ROTAT2(lenrecv),&
2635 iprev,7700+irecv,FG_COMM,status,IERR)
2636 ! write (iout,*) "Gather PRECOMP21"
2638 call MPI_SENDRECV(EUgC(1,1,ivec_displ(isend)+1),1,&
2639 MPI_PRECOMP22(lensend),inext,8800+isend,&
2640 EUgC(1,1,ivec_displ(irecv)+1),1,MPI_PRECOMP22(lenrecv),&
2641 iprev,8800+irecv,FG_COMM,status,IERR)
2642 ! write (iout,*) "Gather PRECOMP22"
2644 call MPI_SENDRECV(Ug2DtEUgder(1,1,1,ivec_displ(isend)+1),1,&
2645 MPI_PRECOMP23(lensend),inext,9900+isend,&
2646 Ug2DtEUgder(1,1,1,ivec_displ(irecv)+1),1,&
2647 MPI_PRECOMP23(lenrecv),&
2648 iprev,9900+irecv,FG_COMM,status,IERR)
2649 ! write (iout,*) "Gather PRECOMP23"
2654 if (irecv.lt.0) irecv=nfgtasks1-1
2657 time_gather=time_gather+MPI_Wtime()-time00
2660 ! if (fg_rank.eq.0) then
2661 write (iout,*) "Arrays UG and UGDER"
2663 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2664 ((ug(l,k,i),l=1,2),k=1,2),&
2665 ((ugder(l,k,i),l=1,2),k=1,2)
2667 write (iout,*) "Arrays UG2 and UG2DER"
2669 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2670 ((ug2(l,k,i),l=1,2),k=1,2),&
2671 ((ug2der(l,k,i),l=1,2),k=1,2)
2673 write (iout,*) "Arrays OBROT OBROT2 OBROTDER and OBROT2DER"
2675 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2676 (obrot(k,i),k=1,2),(obrot2(k,i),k=1,2),&
2677 (obrot_der(k,i),k=1,2),(obrot2_der(k,i),k=1,2)
2679 write (iout,*) "Arrays COSTAB SINTAB COSTAB2 and SINTAB2"
2681 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2682 costab(i),sintab(i),costab2(i),sintab2(i)
2684 write (iout,*) "Array MUDER"
2686 write (iout,'(i5,2f10.5)') i,muder(1,i),muder(2,i)
2692 !d iti = itortyp(itype(i,1))
2695 !d write (iout,'(2f10.5,5x,2f10.5,5x,2f10.5)')
2696 !d & (EE(j,k,iti),k=1,2),(Ug(j,k,i),k=1,2),(EUg(j,k,i),k=1,2)
2700 end subroutine set_matrices
2701 !-----------------------------------------------------------------------------
2702 subroutine eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
2704 ! This subroutine calculates the average interaction energy and its gradient
2705 ! in the virtual-bond vectors between non-adjacent peptide groups, based on
2706 ! the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
2707 ! The potential depends both on the distance of peptide-group centers and on
2708 ! the orientation of the CA-CA virtual bonds.
2711 ! implicit real*8 (a-h,o-z)
2715 ! include 'DIMENSIONS'
2716 ! include 'COMMON.CONTROL'
2717 ! include 'COMMON.SETUP'
2718 ! include 'COMMON.IOUNITS'
2719 ! include 'COMMON.GEO'
2720 ! include 'COMMON.VAR'
2721 ! include 'COMMON.LOCAL'
2722 ! include 'COMMON.CHAIN'
2723 ! include 'COMMON.DERIV'
2724 ! include 'COMMON.INTERACT'
2725 ! include 'COMMON.CONTACTS'
2726 ! include 'COMMON.TORSION'
2727 ! include 'COMMON.VECTORS'
2728 ! include 'COMMON.FFIELD'
2729 ! include 'COMMON.TIME1'
2730 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg
2731 real(kind=8),dimension(3,3) :: erder,uryg,urzg,vryg,vrzg
2732 real(kind=8),dimension(2,2) :: acipa !el,a_temp
2733 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
2734 real(kind=8),dimension(4) :: muij
2735 !el integer :: num_conti,j1,j2
2736 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
2737 !el dz_normi,xmedi,ymedi,zmedi
2739 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
2740 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
2743 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
2745 real(kind=8) :: scal_el=1.0d0
2747 real(kind=8) :: scal_el=0.5d0
2750 ! 13-go grudnia roku pamietnego...
2751 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
2753 0.0d0,0.0d0,1.0d0/),shape(unmat))
2756 real(kind=8) :: ees,evdw1,eel_loc,eello_turn3,eello_turn4
2757 real(kind=8) :: fac,t_eelecij,fracinbuf
2760 !d write(iout,*) 'In EELEC'
2761 ! print *,"IN EELEC"
2763 !d write(iout,*) 'Type',i
2764 !d write(iout,*) 'B1',B1(:,i)
2765 !d write(iout,*) 'B2',B2(:,i)
2766 !d write(iout,*) 'CC',CC(:,:,i)
2767 !d write(iout,*) 'DD',DD(:,:,i)
2768 !d write(iout,*) 'EE',EE(:,:,i)
2770 !d call check_vecgrad
2785 if (icheckgrad.eq.1) then
2788 ! dc_norm(1,i)=0.0d0
2789 ! dc_norm(2,i)=0.0d0
2790 ! dc_norm(3,i)=0.0d0
2793 fac=1.0d0/dsqrt(scalar(dc(1,i),dc(1,i)))
2795 dc_norm(k,i)=dc(k,i)*fac
2797 ! write (iout,*) 'i',i,' fac',fac
2800 ! print *,wel_loc,"wel_loc",wcorr4,wcorr5,wcorr6,wturn3,wturn4, &
2802 if (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
2803 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 .or. &
2804 wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) then
2805 ! call vec_and_deriv
2809 ! print *, "before set matrices"
2811 ! print *, "after set matrices"
2814 time_mat=time_mat+MPI_Wtime()-time01
2817 ! print *, "after set matrices"
2819 !d write (iout,*) 'i=',i
2821 !d write (iout,'(i5,2f10.5)') k,uy(k,i),uz(k,i)
2824 !d write (iout,'(f10.5,2x,3f10.5,2x,3f10.5)')
2825 !d & uz(k,i),(uzgrad(k,l,1,i),l=1,3),(uzgrad(k,l,2,i),l=1,3)
2838 !d print '(a)','Enter EELEC'
2839 !d write (iout,*) 'iatel_s=',iatel_s,' iatel_e=',iatel_e
2840 ! if (.not.allocated(gel_loc_loc)) allocate(gel_loc_loc(nres)) !(maxvar)(maxvar=6*maxres)
2841 ! if (.not.allocated(gcorr_loc)) allocate(gcorr_loc(nres)) !(maxvar)(maxvar=6*maxres)
2843 gel_loc_loc(i)=0.0d0
2848 ! 9/27/08 AL Split the interaction loop to ensure load balancing of turn terms
2850 ! Loop over i,i+2 and i,i+3 pairs of the peptide groups
2854 ! print *,"before iturn3 loop"
2855 do i=iturn3_start,iturn3_end
2856 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1 &
2857 .or. itype(i+2,1).eq.ntyp1 .or. itype(i+3,1).eq.ntyp1) cycle
2861 dx_normi=dc_norm(1,i)
2862 dy_normi=dc_norm(2,i)
2863 dz_normi=dc_norm(3,i)
2864 xmedi=c(1,i)+0.5d0*dxi
2865 ymedi=c(2,i)+0.5d0*dyi
2866 zmedi=c(3,i)+0.5d0*dzi
2867 xmedi=dmod(xmedi,boxxsize)
2868 if (xmedi.lt.0) xmedi=xmedi+boxxsize
2869 ymedi=dmod(ymedi,boxysize)
2870 if (ymedi.lt.0) ymedi=ymedi+boxysize
2871 zmedi=dmod(zmedi,boxzsize)
2872 if (zmedi.lt.0) zmedi=zmedi+boxzsize
2874 if ((zmedi.gt.bordlipbot) &
2875 .and.(zmedi.lt.bordliptop)) then
2876 !C the energy transfer exist
2877 if (zmedi.lt.buflipbot) then
2878 !C what fraction I am in
2880 ((zmedi-bordlipbot)/lipbufthick)
2881 !C lipbufthick is thickenes of lipid buffore
2882 sslipi=sscalelip(fracinbuf)
2883 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
2884 elseif (zmedi.gt.bufliptop) then
2885 fracinbuf=1.0d0-((bordliptop-zmedi)/lipbufthick)
2886 sslipi=sscalelip(fracinbuf)
2887 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
2896 ! print *,i,sslipi,ssgradlipi
2897 call eelecij(i,i+2,ees,evdw1,eel_loc)
2898 if (wturn3.gt.0.0d0) call eturn3(i,eello_turn3)
2899 num_cont_hb(i)=num_conti
2901 do i=iturn4_start,iturn4_end
2902 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1 &
2903 .or. itype(i+3,1).eq.ntyp1 &
2904 .or. itype(i+4,1).eq.ntyp1) cycle
2908 dx_normi=dc_norm(1,i)
2909 dy_normi=dc_norm(2,i)
2910 dz_normi=dc_norm(3,i)
2911 xmedi=c(1,i)+0.5d0*dxi
2912 ymedi=c(2,i)+0.5d0*dyi
2913 zmedi=c(3,i)+0.5d0*dzi
2914 xmedi=dmod(xmedi,boxxsize)
2915 if (xmedi.lt.0) xmedi=xmedi+boxxsize
2916 ymedi=dmod(ymedi,boxysize)
2917 if (ymedi.lt.0) ymedi=ymedi+boxysize
2918 zmedi=dmod(zmedi,boxzsize)
2919 if (zmedi.lt.0) zmedi=zmedi+boxzsize
2920 if ((zmedi.gt.bordlipbot) &
2921 .and.(zmedi.lt.bordliptop)) then
2922 !C the energy transfer exist
2923 if (zmedi.lt.buflipbot) then
2924 !C what fraction I am in
2926 ((zmedi-bordlipbot)/lipbufthick)
2927 !C lipbufthick is thickenes of lipid buffore
2928 sslipi=sscalelip(fracinbuf)
2929 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
2930 elseif (zmedi.gt.bufliptop) then
2931 fracinbuf=1.0d0-((bordliptop-zmedi)/lipbufthick)
2932 sslipi=sscalelip(fracinbuf)
2933 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
2943 num_conti=num_cont_hb(i)
2944 call eelecij(i,i+3,ees,evdw1,eel_loc)
2945 if (wturn4.gt.0.0d0 .and. itype(i+2,1).ne.ntyp1) &
2946 call eturn4(i,eello_turn4)
2947 num_cont_hb(i)=num_conti
2950 ! Loop over all pairs of interacting peptide groups except i,i+2 and i,i+3
2952 do i=iatel_s,iatel_e
2953 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
2957 dx_normi=dc_norm(1,i)
2958 dy_normi=dc_norm(2,i)
2959 dz_normi=dc_norm(3,i)
2960 xmedi=c(1,i)+0.5d0*dxi
2961 ymedi=c(2,i)+0.5d0*dyi
2962 zmedi=c(3,i)+0.5d0*dzi
2963 xmedi=dmod(xmedi,boxxsize)
2964 if (xmedi.lt.0) xmedi=xmedi+boxxsize
2965 ymedi=dmod(ymedi,boxysize)
2966 if (ymedi.lt.0) ymedi=ymedi+boxysize
2967 zmedi=dmod(zmedi,boxzsize)
2968 if (zmedi.lt.0) zmedi=zmedi+boxzsize
2969 if ((zmedi.gt.bordlipbot) &
2970 .and.(zmedi.lt.bordliptop)) then
2971 !C the energy transfer exist
2972 if (zmedi.lt.buflipbot) then
2973 !C what fraction I am in
2975 ((zmedi-bordlipbot)/lipbufthick)
2976 !C lipbufthick is thickenes of lipid buffore
2977 sslipi=sscalelip(fracinbuf)
2978 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
2979 elseif (zmedi.gt.bufliptop) then
2980 fracinbuf=1.0d0-((bordliptop-zmedi)/lipbufthick)
2981 sslipi=sscalelip(fracinbuf)
2982 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
2992 ! write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
2993 num_conti=num_cont_hb(i)
2994 do j=ielstart(i),ielend(i)
2995 ! write (iout,*) i,j,itype(i,1),itype(j,1)
2996 if (itype(j,1).eq.ntyp1.or. itype(j+1,1).eq.ntyp1) cycle
2997 call eelecij(i,j,ees,evdw1,eel_loc)
2999 num_cont_hb(i)=num_conti
3001 ! write (iout,*) "Number of loop steps in EELEC:",ind
3003 !d write (iout,'(i3,3f10.5,5x,3f10.5)')
3004 !d & i,(gel_loc(k,i),k=1,3),gel_loc_loc(i)
3006 ! 12/7/99 Adam eello_turn3 will be considered as a separate energy term
3007 !cc eel_loc=eel_loc+eello_turn3
3008 !d print *,"Processor",fg_rank," t_eelecij",t_eelecij
3010 end subroutine eelec
3011 !-----------------------------------------------------------------------------
3012 subroutine eelecij(i,j,ees,evdw1,eel_loc)
3015 ! implicit real*8 (a-h,o-z)
3016 ! include 'DIMENSIONS'
3020 ! include 'COMMON.CONTROL'
3021 ! include 'COMMON.IOUNITS'
3022 ! include 'COMMON.GEO'
3023 ! include 'COMMON.VAR'
3024 ! include 'COMMON.LOCAL'
3025 ! include 'COMMON.CHAIN'
3026 ! include 'COMMON.DERIV'
3027 ! include 'COMMON.INTERACT'
3028 ! include 'COMMON.CONTACTS'
3029 ! include 'COMMON.TORSION'
3030 ! include 'COMMON.VECTORS'
3031 ! include 'COMMON.FFIELD'
3032 ! include 'COMMON.TIME1'
3033 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg,xtemp
3034 real(kind=8),dimension(3,3) :: erder,uryg,urzg,vryg,vrzg
3035 real(kind=8),dimension(2,2) :: acipa !el,a_temp
3036 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
3037 real(kind=8),dimension(4) :: muij
3038 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
3039 dist_temp, dist_init,rlocshield,fracinbuf
3040 integer xshift,yshift,zshift,ilist,iresshield
3041 !el integer :: num_conti,j1,j2
3042 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
3043 !el dz_normi,xmedi,ymedi,zmedi
3045 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
3046 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
3049 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
3051 real(kind=8) :: scal_el=1.0d0
3053 real(kind=8) :: scal_el=0.5d0
3056 ! 13-go grudnia roku pamietnego...
3057 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
3059 0.0d0,0.0d0,1.0d0/),shape(unmat))
3060 ! integer :: maxconts=nres/4
3062 integer :: k,i,j,iteli,itelj,kkk,l,kkll,m,isubchap
3063 real(kind=8) :: ael6i,rrmij,rmij,r0ij,fcont,fprimcont,ees0tmp
3064 real(kind=8) :: ees,evdw1,eel_loc,aaa,bbb,ael3i
3065 real(kind=8) :: dxj,dyj,dzj,dx_normj,dy_normj,dz_normj,xj,yj,zj,&
3066 rij,r3ij,r6ij,cosa,cosb,cosg,fac,ev1,ev2,fac3,fac4,&
3067 evdwij,el1,el2,eesij,ees0ij,facvdw,facel,fac1,ecosa,&
3068 ecosb,ecosg,ury,urz,vry,vrz,facr,a22der,a23der,a32der,&
3069 a33der,eel_loc_ij,cosa4,wij,cosbg1,cosbg2,ees0pij,&
3070 ees0pij1,ees0mij,ees0mij1,fac3p,ees0mijp,ees0pijp,&
3071 ecosa1,ecosb1,ecosg1,ecosa2,ecosb2,ecosg2,ecosap,ecosbp,&
3072 ecosgp,ecosam,ecosbm,ecosgm,ghalf
3074 ! allocate(a_chuj(2,2,maxconts,nres)) !(2,2,maxconts,maxres)
3075 ! allocate(a_chuj_der(2,2,3,5,maxconts,nres)) !(2,2,3,5,maxconts,maxres)
3077 ! time00=MPI_Wtime()
3078 !d write (iout,*) "eelecij",i,j
3082 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
3083 aaa=app(iteli,itelj)
3084 bbb=bpp(iteli,itelj)
3085 ael6i=ael6(iteli,itelj)
3086 ael3i=ael3(iteli,itelj)
3090 dx_normj=dc_norm(1,j)
3091 dy_normj=dc_norm(2,j)
3092 dz_normj=dc_norm(3,j)
3093 ! xj=c(1,j)+0.5D0*dxj-xmedi
3094 ! yj=c(2,j)+0.5D0*dyj-ymedi
3095 ! zj=c(3,j)+0.5D0*dzj-zmedi
3100 if (xj.lt.0) xj=xj+boxxsize
3102 if (yj.lt.0) yj=yj+boxysize
3104 if (zj.lt.0) zj=zj+boxzsize
3105 if ((zj.gt.bordlipbot) &
3106 .and.(zj.lt.bordliptop)) then
3107 !C the energy transfer exist
3108 if (zj.lt.buflipbot) then
3109 !C what fraction I am in
3111 ((zj-bordlipbot)/lipbufthick)
3112 !C lipbufthick is thickenes of lipid buffore
3113 sslipj=sscalelip(fracinbuf)
3114 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
3115 elseif (zj.gt.bufliptop) then
3116 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
3117 sslipj=sscalelip(fracinbuf)
3118 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
3129 dist_init=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
3136 xj=xj_safe+xshift*boxxsize
3137 yj=yj_safe+yshift*boxysize
3138 zj=zj_safe+zshift*boxzsize
3139 dist_temp=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
3140 if(dist_temp.lt.dist_init) then
3150 if (isubchap.eq.1) then
3161 rij=xj*xj+yj*yj+zj*zj
3164 !C print *,xmedi,ymedi,zmedi,xj,yj,zj,boxxsize,rij
3165 sss_ele_cut=sscale_ele(rij)
3166 sss_ele_grad=sscagrad_ele(rij)
3168 ! sss_ele_grad=0.0d0
3169 ! print *,sss_ele_cut,sss_ele_grad,&
3170 ! (rij),r_cut_ele,rlamb_ele
3171 ! if (sss_ele_cut.le.0.0) go to 128
3176 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
3177 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
3178 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
3179 fac=cosa-3.0D0*cosb*cosg
3181 ! 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
3182 if (j.eq.i+2) ev1=scal_el*ev1
3187 el1=fac3*(4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg))
3190 if (shield_mode.gt.0) then
3191 !C fac_shield(i)=0.4
3192 !C fac_shield(j)=0.6
3193 el1=el1*fac_shield(i)**2*fac_shield(j)**2
3194 el2=el2*fac_shield(i)**2*fac_shield(j)**2
3196 ees=ees+eesij*sss_ele_cut
3197 !C FOR NOW SHIELD IS NOT USED WITH LIPSCALE
3198 !C & *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3204 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)*sss_ele_cut
3205 !C print *,"TUCC",(sslipi+sslipj)/2.0d0*lipscale**2+1.0d0
3208 ! 12/26/95 - for the evaluation of multi-body H-bonding interactions
3209 ees0ij=4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg)
3210 ! ees=ees+eesij*sss_ele_cut
3211 evdw1=evdw1+evdwij*sss_ele_cut &
3212 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3213 !d write(iout,'(2(2i3,2x),7(1pd12.4)/2(3(1pd12.4),5x)/)')
3214 !d & iteli,i,itelj,j,aaa,bbb,ael6i,ael3i,
3215 !d & 1.0D0/dsqrt(rrmij),evdwij,eesij,
3216 !d & xmedi,ymedi,zmedi,xj,yj,zj
3218 if (energy_dec) then
3219 ! write (iout,'(a6,2i5,0pf7.3,2i5,2e11.3)') &
3220 ! 'evdw1',i,j,evdwij,&
3221 ! iteli,itelj,aaa,evdw1
3222 write (iout,'(a6,2i5,0pf7.3)') 'evdw1',i,j,evdwij
3223 write (iout,'(a6,2i5,0pf7.3)') 'ees',i,j,eesij
3226 ! Calculate contributions to the Cartesian gradient.
3229 facvdw=-6*rrmij*(ev1+evdwij)*sss_ele_cut &
3230 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3231 facel=-3*rrmij*(el1+eesij)*sss_ele_cut &
3232 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3238 ! Radial derivatives. First process both termini of the fragment (i,j)
3240 ggg(1)=facel*xj+sss_ele_grad*rmij*eesij*xj* &
3241 ((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3242 ggg(2)=facel*yj+sss_ele_grad*rmij*eesij*yj* &
3243 ((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3244 ggg(3)=facel*zj+sss_ele_grad*rmij*eesij*zj* &
3245 ((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3247 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
3248 (shield_mode.gt.0)) then
3250 do ilist=1,ishield_list(i)
3251 iresshield=shield_list(ilist,i)
3253 rlocshield=grad_shield_side(k,ilist,i)*eesij/fac_shield(i)&
3255 gshieldx(k,iresshield)=gshieldx(k,iresshield)+ &
3257 +grad_shield_loc(k,ilist,i)*eesij/fac_shield(i)*2.0 &
3259 gshieldc(k,iresshield-1)=gshieldc(k,iresshield-1)+rlocshield
3262 do ilist=1,ishield_list(j)
3263 iresshield=shield_list(ilist,j)
3265 rlocshield=grad_shield_side(k,ilist,j)*eesij/fac_shield(j) &
3267 gshieldx(k,iresshield)=gshieldx(k,iresshield)+ &
3269 +grad_shield_loc(k,ilist,j)*eesij/fac_shield(j)*2.0 &
3271 gshieldc(k,iresshield-1)=gshieldc(k,iresshield-1)+rlocshield
3275 gshieldc(k,i)=gshieldc(k,i)+ &
3276 grad_shield(k,i)*eesij/fac_shield(i)*2.0 &
3279 gshieldc(k,j)=gshieldc(k,j)+ &
3280 grad_shield(k,j)*eesij/fac_shield(j)*2.0 &
3283 gshieldc(k,i-1)=gshieldc(k,i-1)+ &
3284 grad_shield(k,i)*eesij/fac_shield(i)*2.0 &
3287 gshieldc(k,j-1)=gshieldc(k,j-1)+ &
3288 grad_shield(k,j)*eesij/fac_shield(j)*2.0 &
3296 ! ghalf=0.5D0*ggg(k)
3297 ! gelc(k,i)=gelc(k,i)+ghalf
3298 ! gelc(k,j)=gelc(k,j)+ghalf
3300 ! 9/28/08 AL Gradient compotents will be summed only at the end
3302 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
3303 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
3305 gelc_long(3,j)=gelc_long(3,j)+ &
3306 ssgradlipj*eesij/2.0d0*lipscale**2&
3309 gelc_long(3,i)=gelc_long(3,i)+ &
3310 ssgradlipi*eesij/2.0d0*lipscale**2&
3315 ! Loop over residues i+1 thru j-1.
3319 !grad gelc(l,k)=gelc(l,k)+ggg(l)
3322 ggg(1)=facvdw*xj+sss_ele_grad*rmij*evdwij*xj &
3323 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3324 ggg(2)=facvdw*yj+sss_ele_grad*rmij*evdwij*yj &
3325 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3326 ggg(3)=facvdw*zj+sss_ele_grad*rmij*evdwij*zj &
3327 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3330 ! ghalf=0.5D0*ggg(k)
3331 ! gvdwpp(k,i)=gvdwpp(k,i)+ghalf
3332 ! gvdwpp(k,j)=gvdwpp(k,j)+ghalf
3334 ! 9/28/08 AL Gradient compotents will be summed only at the end
3336 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
3337 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
3340 !C Lipidic part for scaling weight
3341 gvdwpp(3,j)=gvdwpp(3,j)+ &
3342 sss_ele_cut*ssgradlipj*evdwij/2.0d0*lipscale**2
3343 gvdwpp(3,i)=gvdwpp(3,i)+ &
3344 sss_ele_cut*ssgradlipi*evdwij/2.0d0*lipscale**2
3345 !! Loop over residues i+1 thru j-1.
3349 !grad gvdwpp(l,k)=gvdwpp(l,k)+ggg(l)
3353 facvdw=(ev1+evdwij)*sss_ele_cut &
3354 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3356 facel=(el1+eesij)*sss_ele_cut
3358 fac=-3*rrmij*(facvdw+facvdw+facel)
3363 ! Radial derivatives. First process both termini of the fragment (i,j)
3365 ggg(1)=fac*xj+sss_ele_grad*rmij*(eesij+evdwij)*xj
3366 ggg(2)=fac*yj+sss_ele_grad*rmij*(eesij+evdwij)*yj
3367 ggg(3)=fac*zj+sss_ele_grad*rmij*(eesij+evdwij)*zj
3369 ! ghalf=0.5D0*ggg(k)
3370 ! gelc(k,i)=gelc(k,i)+ghalf
3371 ! gelc(k,j)=gelc(k,j)+ghalf
3373 ! 9/28/08 AL Gradient compotents will be summed only at the end
3375 gelc_long(k,j)=gelc(k,j)+ggg(k)
3376 gelc_long(k,i)=gelc(k,i)-ggg(k)
3379 ! Loop over residues i+1 thru j-1.
3383 !grad gelc(l,k)=gelc(l,k)+ggg(l)
3386 ! 9/28/08 AL Gradient compotents will be summed only at the end
3388 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3390 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3392 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3395 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
3396 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
3398 gvdwpp(3,j)=gvdwpp(3,j)+ &
3399 sss_ele_cut*ssgradlipj*evdwij/2.0d0*lipscale**2
3400 gvdwpp(3,i)=gvdwpp(3,i)+ &
3401 sss_ele_cut*ssgradlipi*evdwij/2.0d0*lipscale**2
3407 ecosa=2.0D0*fac3*fac1+fac4
3410 ecosb=(fac3*(fac1*cosg+cosb)+cosg*fac4)
3411 ecosg=(fac3*(fac1*cosb+cosg)+cosb*fac4)
3413 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
3414 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
3416 !d print '(2i3,2(3(1pd14.5),3x))',i,j,(dcosb(k),k=1,3),
3417 !d & (dcosg(k),k=1,3)
3419 ggg(k)=(ecosb*dcosb(k)+ecosg*dcosg(k))*sss_ele_cut &
3420 *fac_shield(i)**2*fac_shield(j)**2 &
3421 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3425 ! ghalf=0.5D0*ggg(k)
3426 ! gelc(k,i)=gelc(k,i)+ghalf
3427 ! & +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
3428 ! & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
3429 ! gelc(k,j)=gelc(k,j)+ghalf
3430 ! & +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
3431 ! & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
3435 !grad gelc(l,k)=gelc(l,k)+ggg(l)
3439 gelc(k,i)=gelc(k,i) &
3440 +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
3441 + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)&
3443 *fac_shield(i)**2*fac_shield(j)**2 &
3444 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3446 gelc(k,j)=gelc(k,j) &
3447 +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
3448 + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
3450 *fac_shield(i)**2*fac_shield(j)**2 &
3451 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3453 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
3454 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
3457 IF (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
3458 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 &
3459 .or. wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
3461 ! 9/25/99 Mixed third-order local-electrostatic terms. The local-interaction
3462 ! energy of a peptide unit is assumed in the form of a second-order
3463 ! Fourier series in the angles lambda1 and lambda2 (see Nishikawa et al.
3464 ! Macromolecules, 1974, 7, 797-806 for definition). This correlation terms
3465 ! are computed for EVERY pair of non-contiguous peptide groups.
3467 if (j.lt.nres-1) then
3478 muij(kkk)=mu(k,i)*mu(l,j)
3481 !d write (iout,*) 'EELEC: i',i,' j',j
3482 !d write (iout,*) 'j',j,' j1',j1,' j2',j2
3483 !d write(iout,*) 'muij',muij
3484 ury=scalar(uy(1,i),erij)
3485 urz=scalar(uz(1,i),erij)
3486 vry=scalar(uy(1,j),erij)
3487 vrz=scalar(uz(1,j),erij)
3488 a22=scalar(uy(1,i),uy(1,j))-3*ury*vry
3489 a23=scalar(uy(1,i),uz(1,j))-3*ury*vrz
3490 a32=scalar(uz(1,i),uy(1,j))-3*urz*vry
3491 a33=scalar(uz(1,i),uz(1,j))-3*urz*vrz
3492 fac=dsqrt(-ael6i)*r3ij
3497 !d write (iout,'(4i5,4f10.5)')
3498 !d & i,itortyp(itype(i,1)),j,itortyp(itype(j,1)),a22,a23,a32,a33
3499 !d write (iout,'(6f10.5)') (muij(k),k=1,4),fac,eel_loc_ij
3500 !d write (iout,'(2(3f10.5,5x)/2(3f10.5,5x))') uy(:,i),uz(:,i),
3501 !d & uy(:,j),uz(:,j)
3502 !d write (iout,'(4f10.5)')
3503 !d & scalar(uy(1,i),uy(1,j)),scalar(uy(1,i),uz(1,j)),
3504 !d & scalar(uz(1,i),uy(1,j)),scalar(uz(1,i),uz(1,j))
3505 !d write (iout,'(4f10.5)') ury,urz,vry,vrz
3506 !d write (iout,'(9f10.5/)')
3507 !d & fac22,a22,fac23,a23,fac32,a32,fac33,a33,eel_loc_ij
3508 ! Derivatives of the elements of A in virtual-bond vectors
3509 call unormderiv(erij(1),unmat(1,1),rmij,erder(1,1))
3511 uryg(k,1)=scalar(erder(1,k),uy(1,i))
3512 uryg(k,2)=scalar(uygrad(1,k,1,i),erij(1))
3513 uryg(k,3)=scalar(uygrad(1,k,2,i),erij(1))
3514 urzg(k,1)=scalar(erder(1,k),uz(1,i))
3515 urzg(k,2)=scalar(uzgrad(1,k,1,i),erij(1))
3516 urzg(k,3)=scalar(uzgrad(1,k,2,i),erij(1))
3517 vryg(k,1)=scalar(erder(1,k),uy(1,j))
3518 vryg(k,2)=scalar(uygrad(1,k,1,j),erij(1))
3519 vryg(k,3)=scalar(uygrad(1,k,2,j),erij(1))
3520 vrzg(k,1)=scalar(erder(1,k),uz(1,j))
3521 vrzg(k,2)=scalar(uzgrad(1,k,1,j),erij(1))
3522 vrzg(k,3)=scalar(uzgrad(1,k,2,j),erij(1))
3524 ! Compute radial contributions to the gradient
3542 ! Add the contributions coming from er
3545 agg(k,1)=agg(k,1)+fac3*(uryg(k,1)*vry+vryg(k,1)*ury)
3546 agg(k,2)=agg(k,2)+fac3*(uryg(k,1)*vrz+vrzg(k,1)*ury)
3547 agg(k,3)=agg(k,3)+fac3*(urzg(k,1)*vry+vryg(k,1)*urz)
3548 agg(k,4)=agg(k,4)+fac3*(urzg(k,1)*vrz+vrzg(k,1)*urz)
3551 ! Derivatives in DC(i)
3552 !grad ghalf1=0.5d0*agg(k,1)
3553 !grad ghalf2=0.5d0*agg(k,2)
3554 !grad ghalf3=0.5d0*agg(k,3)
3555 !grad ghalf4=0.5d0*agg(k,4)
3556 aggi(k,1)=fac*(scalar(uygrad(1,k,1,i),uy(1,j)) &
3557 -3.0d0*uryg(k,2)*vry)!+ghalf1
3558 aggi(k,2)=fac*(scalar(uygrad(1,k,1,i),uz(1,j)) &
3559 -3.0d0*uryg(k,2)*vrz)!+ghalf2
3560 aggi(k,3)=fac*(scalar(uzgrad(1,k,1,i),uy(1,j)) &
3561 -3.0d0*urzg(k,2)*vry)!+ghalf3
3562 aggi(k,4)=fac*(scalar(uzgrad(1,k,1,i),uz(1,j)) &
3563 -3.0d0*urzg(k,2)*vrz)!+ghalf4
3564 ! Derivatives in DC(i+1)
3565 aggi1(k,1)=fac*(scalar(uygrad(1,k,2,i),uy(1,j)) &
3566 -3.0d0*uryg(k,3)*vry)!+agg(k,1)
3567 aggi1(k,2)=fac*(scalar(uygrad(1,k,2,i),uz(1,j)) &
3568 -3.0d0*uryg(k,3)*vrz)!+agg(k,2)
3569 aggi1(k,3)=fac*(scalar(uzgrad(1,k,2,i),uy(1,j)) &
3570 -3.0d0*urzg(k,3)*vry)!+agg(k,3)
3571 aggi1(k,4)=fac*(scalar(uzgrad(1,k,2,i),uz(1,j)) &
3572 -3.0d0*urzg(k,3)*vrz)!+agg(k,4)
3573 ! Derivatives in DC(j)
3574 aggj(k,1)=fac*(scalar(uygrad(1,k,1,j),uy(1,i)) &
3575 -3.0d0*vryg(k,2)*ury)!+ghalf1
3576 aggj(k,2)=fac*(scalar(uzgrad(1,k,1,j),uy(1,i)) &
3577 -3.0d0*vrzg(k,2)*ury)!+ghalf2
3578 aggj(k,3)=fac*(scalar(uygrad(1,k,1,j),uz(1,i)) &
3579 -3.0d0*vryg(k,2)*urz)!+ghalf3
3580 aggj(k,4)=fac*(scalar(uzgrad(1,k,1,j),uz(1,i)) &
3581 -3.0d0*vrzg(k,2)*urz)!+ghalf4
3582 ! Derivatives in DC(j+1) or DC(nres-1)
3583 aggj1(k,1)=fac*(scalar(uygrad(1,k,2,j),uy(1,i)) &
3584 -3.0d0*vryg(k,3)*ury)
3585 aggj1(k,2)=fac*(scalar(uzgrad(1,k,2,j),uy(1,i)) &
3586 -3.0d0*vrzg(k,3)*ury)
3587 aggj1(k,3)=fac*(scalar(uygrad(1,k,2,j),uz(1,i)) &
3588 -3.0d0*vryg(k,3)*urz)
3589 aggj1(k,4)=fac*(scalar(uzgrad(1,k,2,j),uz(1,i)) &
3590 -3.0d0*vrzg(k,3)*urz)
3591 !grad if (j.eq.nres-1 .and. i.lt.j-2) then
3593 !grad aggj1(k,l)=aggj1(k,l)+agg(k,l)
3606 aggi(k,l)=-aggi(k,l)
3607 aggi1(k,l)=-aggi1(k,l)
3608 aggj(k,l)=-aggj(k,l)
3609 aggj1(k,l)=-aggj1(k,l)
3612 if (j.lt.nres-1) then
3618 aggi(k,l)=-aggi(k,l)
3619 aggi1(k,l)=-aggi1(k,l)
3620 aggj(k,l)=-aggj(k,l)
3621 aggj1(k,l)=-aggj1(k,l)
3632 aggi(k,l)=-aggi(k,l)
3633 aggi1(k,l)=-aggi1(k,l)
3634 aggj(k,l)=-aggj(k,l)
3635 aggj1(k,l)=-aggj1(k,l)
3640 IF (wel_loc.gt.0.0d0) THEN
3641 ! Contribution to the local-electrostatic energy coming from the i-j pair
3642 eel_loc_ij=a22*muij(1)+a23*muij(2)+a32*muij(3) &
3644 if (shield_mode.eq.0) then
3648 eel_loc_ij=eel_loc_ij &
3649 *fac_shield(i)*fac_shield(j) &
3650 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
3651 !C Now derivative over eel_loc
3652 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
3653 (shield_mode.gt.0)) then
3656 do ilist=1,ishield_list(i)
3657 iresshield=shield_list(ilist,i)
3659 rlocshield=grad_shield_side(k,ilist,i)*eel_loc_ij &
3662 gshieldx_ll(k,iresshield)=gshieldx_ll(k,iresshield)+ &
3664 +grad_shield_loc(k,ilist,i)*eel_loc_ij/fac_shield(i) &
3667 gshieldc_ll(k,iresshield-1)=gshieldc_ll(k,iresshield-1)&
3671 do ilist=1,ishield_list(j)
3672 iresshield=shield_list(ilist,j)
3674 rlocshield=grad_shield_side(k,ilist,j)*eel_loc_ij &
3677 gshieldx_ll(k,iresshield)=gshieldx_ll(k,iresshield)+ &
3679 +grad_shield_loc(k,ilist,j)*eel_loc_ij/fac_shield(j) &
3682 gshieldc_ll(k,iresshield-1)=gshieldc_ll(k,iresshield-1)&
3689 gshieldc_ll(k,i)=gshieldc_ll(k,i)+ &
3690 grad_shield(k,i)*eel_loc_ij/fac_shield(i) &
3692 gshieldc_ll(k,j)=gshieldc_ll(k,j)+ &
3693 grad_shield(k,j)*eel_loc_ij/fac_shield(j) &
3695 gshieldc_ll(k,i-1)=gshieldc_ll(k,i-1)+ &
3696 grad_shield(k,i)*eel_loc_ij/fac_shield(i) &
3698 gshieldc_ll(k,j-1)=gshieldc_ll(k,j-1)+ &
3699 grad_shield(k,j)*eel_loc_ij/fac_shield(j) &
3706 ! write (iout,*) 'i',i,' j',j,' eel_loc_ij',eel_loc_ij
3708 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
3709 'eelloc',i,j,eel_loc_ij
3710 ! if (energy_dec) write (iout,*) "a22",a22," a23",a23," a32",a32," a33",a33
3711 ! if (energy_dec) write (iout,*) "muij",muij
3712 ! write (iout,*) a22,muij(1),a23,muij(2),a32,muij(3)
3714 eel_loc=eel_loc+eel_loc_ij*sss_ele_cut
3715 ! Partial derivatives in virtual-bond dihedral angles gamma
3717 gel_loc_loc(i-1)=gel_loc_loc(i-1)+ &
3718 (a22*muder(1,i)*mu(1,j)+a23*muder(1,i)*mu(2,j) &
3719 +a32*muder(2,i)*mu(1,j)+a33*muder(2,i)*mu(2,j)) &
3721 *fac_shield(i)*fac_shield(j) &
3722 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
3724 gel_loc_loc(j-1)=gel_loc_loc(j-1)+ &
3725 (a22*mu(1,i)*muder(1,j)+a23*mu(1,i)*muder(2,j) &
3726 +a32*mu(2,i)*muder(1,j)+a33*mu(2,i)*muder(2,j)) &
3728 *fac_shield(i)*fac_shield(j) &
3729 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
3730 ! Derivatives of eello in DC(i+1) thru DC(j-1) or DC(nres-2)
3732 ! ggg(1)=(agg(1,1)*muij(1)+ &
3733 ! agg(1,2)*muij(2)+agg(1,3)*muij(3)+agg(1,4)*muij(4)) &
3735 ! +eel_loc_ij*sss_ele_grad*rmij*xj
3736 ! ggg(2)=(agg(2,1)*muij(1)+ &
3737 ! agg(2,2)*muij(2)+agg(2,3)*muij(3)+agg(2,4)*muij(4)) &
3739 ! +eel_loc_ij*sss_ele_grad*rmij*yj
3740 ! ggg(3)=(agg(3,1)*muij(1)+ &
3741 ! agg(3,2)*muij(2)+agg(3,3)*muij(3)+agg(3,4)*muij(4)) &
3743 ! +eel_loc_ij*sss_ele_grad*rmij*zj
3749 ggg(l)=(agg(l,1)*muij(1)+ &
3750 agg(l,2)*muij(2)+agg(l,3)*muij(3)+agg(l,4)*muij(4))&
3752 *fac_shield(i)*fac_shield(j) &
3753 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0) &
3754 +eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
3757 gel_loc_long(l,j)=gel_loc_long(l,j)+ggg(l)
3758 gel_loc_long(l,i)=gel_loc_long(l,i)-ggg(l)
3759 !grad ghalf=0.5d0*ggg(l)
3760 !grad gel_loc(l,i)=gel_loc(l,i)+ghalf
3761 !grad gel_loc(l,j)=gel_loc(l,j)+ghalf
3763 gel_loc_long(3,j)=gel_loc_long(3,j)+ &
3764 ssgradlipj*eel_loc_ij/2.0d0*lipscale/ &
3765 ((sslipi+sslipj)/2.0d0*lipscale+1.0d0)*sss_ele_cut
3767 gel_loc_long(3,i)=gel_loc_long(3,i)+ &
3768 ssgradlipi*eel_loc_ij/2.0d0*lipscale/ &
3769 ((sslipi+sslipj)/2.0d0*lipscale+1.0d0)*sss_ele_cut
3773 !grad gel_loc(l,k)=gel_loc(l,k)+ggg(l)
3776 ! Remaining derivatives of eello
3778 gel_loc(l,i)=gel_loc(l,i)+(aggi(l,1)*muij(1)+ &
3779 aggi(l,2)*muij(2)+aggi(l,3)*muij(3)+aggi(l,4)*muij(4))&
3781 *fac_shield(i)*fac_shield(j) &
3782 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
3784 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
3785 gel_loc(l,i+1)=gel_loc(l,i+1)+(aggi1(l,1)*muij(1)+ &
3786 aggi1(l,2)*muij(2)+aggi1(l,3)*muij(3) &
3787 +aggi1(l,4)*muij(4))&
3789 *fac_shield(i)*fac_shield(j) &
3790 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
3792 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
3793 gel_loc(l,j)=gel_loc(l,j)+(aggj(l,1)*muij(1)+ &
3794 aggj(l,2)*muij(2)+aggj(l,3)*muij(3)+aggj(l,4)*muij(4))&
3796 *fac_shield(i)*fac_shield(j) &
3797 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
3799 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
3800 gel_loc(l,j1)=gel_loc(l,j1)+(aggj1(l,1)*muij(1)+ &
3801 aggj1(l,2)*muij(2)+aggj1(l,3)*muij(3) &
3802 +aggj1(l,4)*muij(4))&
3804 *fac_shield(i)*fac_shield(j) &
3805 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
3807 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
3810 ! Change 12/26/95 to calculate four-body contributions to H-bonding energy
3811 ! if (j.gt.i+1 .and. num_conti.le.maxconts) then
3812 if (wcorr+wcorr4+wcorr5+wcorr6.gt.0.0d0 &
3813 .and. num_conti.le.maxconts) then
3814 ! write (iout,*) i,j," entered corr"
3816 ! Calculate the contact function. The ith column of the array JCONT will
3817 ! contain the numbers of atoms that make contacts with the atom I (of numbers
3818 ! greater than I). The arrays FACONT and GACONT will contain the values of
3819 ! the contact function and its derivative.
3820 ! r0ij=1.02D0*rpp(iteli,itelj)
3821 ! r0ij=1.11D0*rpp(iteli,itelj)
3822 r0ij=2.20D0*rpp(iteli,itelj)
3823 ! r0ij=1.55D0*rpp(iteli,itelj)
3824 call gcont(rij,r0ij,1.0D0,0.2d0*r0ij,fcont,fprimcont)
3825 !elwrite(iout,*) "num_conti",num_conti, "maxconts",maxconts
3826 if (fcont.gt.0.0D0) then
3827 num_conti=num_conti+1
3828 if (num_conti.gt.maxconts) then
3829 !el write (iout,*) "esrgresgdsrgdfsrgdswrgaresfgaerwgae"
3830 !el write (iout,*) "num_conti",num_conti, "maxconts",maxconts
3831 write (iout,*) 'WARNING - max. # of contacts exceeded;',&
3832 ' will skip next contacts for this conf.', num_conti
3834 jcont_hb(num_conti,i)=j
3835 !d write (iout,*) "i",i," j",j," num_conti",num_conti,
3836 !d & " jcont_hb",jcont_hb(num_conti,i)
3837 IF (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. &
3838 wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
3839 ! 9/30/99 (AL) - store components necessary to evaluate higher-order loc-el
3841 d_cont(num_conti,i)=rij
3842 !d write (2,'(3e15.5)') rij,r0ij+0.2d0*r0ij,rij
3843 ! --- Electrostatic-interaction matrix ---
3844 a_chuj(1,1,num_conti,i)=a22
3845 a_chuj(1,2,num_conti,i)=a23
3846 a_chuj(2,1,num_conti,i)=a32
3847 a_chuj(2,2,num_conti,i)=a33
3848 ! --- Gradient of rij
3850 grij_hb_cont(kkk,num_conti,i)=erij(kkk)
3857 a_chuj_der(k,l,m,1,num_conti,i)=agg(m,kkll)
3858 a_chuj_der(k,l,m,2,num_conti,i)=aggi(m,kkll)
3859 a_chuj_der(k,l,m,3,num_conti,i)=aggi1(m,kkll)
3860 a_chuj_der(k,l,m,4,num_conti,i)=aggj(m,kkll)
3861 a_chuj_der(k,l,m,5,num_conti,i)=aggj1(m,kkll)
3866 IF (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) THEN
3867 ! Calculate contact energies
3869 wij=cosa-3.0D0*cosb*cosg
3872 ! fac3=dsqrt(-ael6i)/r0ij**3
3873 fac3=dsqrt(-ael6i)*r3ij
3874 ! ees0pij=dsqrt(4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1)
3875 ees0tmp=4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1
3876 if (ees0tmp.gt.0) then
3877 ees0pij=dsqrt(ees0tmp)
3881 if (shield_mode.eq.0) then
3885 ees0plist(num_conti,i)=j
3887 ! ees0mij=dsqrt(4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2)
3888 ees0tmp=4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2
3889 if (ees0tmp.gt.0) then
3890 ees0mij=dsqrt(ees0tmp)
3895 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij) &
3897 *fac_shield(i)*fac_shield(j)
3899 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij) &
3901 *fac_shield(i)*fac_shield(j)
3903 ! Diagnostics. Comment out or remove after debugging!
3904 ! ees0p(num_conti,i)=0.5D0*fac3*ees0pij
3905 ! ees0m(num_conti,i)=0.5D0*fac3*ees0mij
3906 ! ees0m(num_conti,i)=0.0D0
3908 ! write (iout,*) 'i=',i,' j=',j,' rij=',rij,' r0ij=',r0ij,
3909 ! & ' ees0ij=',ees0p(num_conti,i),ees0m(num_conti,i),' fcont=',fcont
3910 ! Angular derivatives of the contact function
3911 ees0pij1=fac3/ees0pij
3912 ees0mij1=fac3/ees0mij
3913 fac3p=-3.0D0*fac3*rrmij
3914 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
3915 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
3917 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
3918 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
3919 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
3920 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
3921 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
3922 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
3923 ecosap=ecosa1+ecosa2
3924 ecosbp=ecosb1+ecosb2
3925 ecosgp=ecosg1+ecosg2
3926 ecosam=ecosa1-ecosa2
3927 ecosbm=ecosb1-ecosb2
3928 ecosgm=ecosg1-ecosg2
3937 facont_hb(num_conti,i)=fcont
3938 fprimcont=fprimcont/rij
3939 !d facont_hb(num_conti,i)=1.0D0
3940 ! Following line is for diagnostics.
3943 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
3944 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
3947 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
3948 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
3950 gggp(1)=gggp(1)+ees0pijp*xj &
3951 +ees0p(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
3952 gggp(2)=gggp(2)+ees0pijp*yj &
3953 +ees0p(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
3954 gggp(3)=gggp(3)+ees0pijp*zj &
3955 +ees0p(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
3957 gggm(1)=gggm(1)+ees0mijp*xj &
3958 +ees0m(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
3960 gggm(2)=gggm(2)+ees0mijp*yj &
3961 +ees0m(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
3963 gggm(3)=gggm(3)+ees0mijp*zj &
3964 +ees0m(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
3966 ! Derivatives due to the contact function
3967 gacont_hbr(1,num_conti,i)=fprimcont*xj
3968 gacont_hbr(2,num_conti,i)=fprimcont*yj
3969 gacont_hbr(3,num_conti,i)=fprimcont*zj
3972 ! 10/24/08 cgrad and ! comments indicate the parts of the code removed
3973 ! following the change of gradient-summation algorithm.
3975 !grad ghalfp=0.5D0*gggp(k)
3976 !grad ghalfm=0.5D0*gggm(k)
3977 gacontp_hb1(k,num_conti,i)= & !ghalfp+
3978 (ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
3979 + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
3980 *sss_ele_cut*fac_shield(i)*fac_shield(j)
3982 gacontp_hb2(k,num_conti,i)= & !ghalfp+
3983 (ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
3984 + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
3985 *sss_ele_cut*fac_shield(i)*fac_shield(j)
3987 gacontp_hb3(k,num_conti,i)=gggp(k) &
3988 *sss_ele_cut*fac_shield(i)*fac_shield(j)
3990 gacontm_hb1(k,num_conti,i)= & !ghalfm+
3991 (ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
3992 + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
3993 *sss_ele_cut*fac_shield(i)*fac_shield(j)
3995 gacontm_hb2(k,num_conti,i)= & !ghalfm+
3996 (ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
3997 + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1) &
3998 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4000 gacontm_hb3(k,num_conti,i)=gggm(k) &
4001 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4004 ! Diagnostics. Comment out or remove after debugging!
4006 !diag gacontp_hb1(k,num_conti,i)=0.0D0
4007 !diag gacontp_hb2(k,num_conti,i)=0.0D0
4008 !diag gacontp_hb3(k,num_conti,i)=0.0D0
4009 !diag gacontm_hb1(k,num_conti,i)=0.0D0
4010 !diag gacontm_hb2(k,num_conti,i)=0.0D0
4011 !diag gacontm_hb3(k,num_conti,i)=0.0D0
4014 endif ! num_conti.le.maxconts
4017 if (wturn3.gt.0.0d0 .or. wturn4.gt.0.0d0) then
4020 ghalf=0.5d0*agg(l,k)
4021 aggi(l,k)=aggi(l,k)+ghalf
4022 aggi1(l,k)=aggi1(l,k)+agg(l,k)
4023 aggj(l,k)=aggj(l,k)+ghalf
4026 if (j.eq.nres-1 .and. i.lt.j-2) then
4029 aggj1(l,k)=aggj1(l,k)+agg(l,k)
4035 ! t_eelecij=t_eelecij+MPI_Wtime()-time00
4037 end subroutine eelecij
4038 !-----------------------------------------------------------------------------
4039 subroutine eturn3(i,eello_turn3)
4040 ! Third- and fourth-order contributions from turns
4043 ! implicit real*8 (a-h,o-z)
4044 ! include 'DIMENSIONS'
4045 ! include 'COMMON.IOUNITS'
4046 ! include 'COMMON.GEO'
4047 ! include 'COMMON.VAR'
4048 ! include 'COMMON.LOCAL'
4049 ! include 'COMMON.CHAIN'
4050 ! include 'COMMON.DERIV'
4051 ! include 'COMMON.INTERACT'
4052 ! include 'COMMON.CONTACTS'
4053 ! include 'COMMON.TORSION'
4054 ! include 'COMMON.VECTORS'
4055 ! include 'COMMON.FFIELD'
4056 ! include 'COMMON.CONTROL'
4057 real(kind=8),dimension(3) :: ggg
4058 real(kind=8),dimension(2,2) :: auxmat,auxmat1,auxmat2,pizda,&
4059 e1t,e2t,e3t,e1tder,e2tder,e3tder,e1a,ae3,ae3e2
4060 real(kind=8),dimension(2) :: auxvec,auxvec1
4061 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
4062 real(kind=8),dimension(2,2) :: auxmat3 !el, a_temp
4063 !el integer :: num_conti,j1,j2
4064 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
4065 !el dz_normi,xmedi,ymedi,zmedi
4067 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
4068 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
4071 integer :: i,j,l,k,ilist,iresshield
4072 real(kind=8) :: eello_turn3,zj,fracinbuf,eello_t3, rlocshield
4075 ! write (iout,*) "eturn3",i,j,j1,j2
4076 zj=(c(3,j)+c(3,j+1))/2.0d0
4078 if (zj.lt.0) zj=zj+boxzsize
4079 if ((zj.lt.0)) write (*,*) "CHUJ"
4080 if ((zj.gt.bordlipbot) &
4081 .and.(zj.lt.bordliptop)) then
4082 !C the energy transfer exist
4083 if (zj.lt.buflipbot) then
4084 !C what fraction I am in
4086 ((zj-bordlipbot)/lipbufthick)
4087 !C lipbufthick is thickenes of lipid buffore
4088 sslipj=sscalelip(fracinbuf)
4089 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
4090 elseif (zj.gt.bufliptop) then
4091 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
4092 sslipj=sscalelip(fracinbuf)
4093 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
4107 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4109 ! Third-order contributions
4116 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4117 !d call checkint_turn3(i,a_temp,eello_turn3_num)
4118 call matmat2(EUg(1,1,i+1),EUg(1,1,i+2),auxmat(1,1))
4119 call transpose2(auxmat(1,1),auxmat1(1,1))
4120 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4121 if (shield_mode.eq.0) then
4126 eello_turn3=eello_turn3+0.5d0*(pizda(1,1)+pizda(2,2)) &
4127 *fac_shield(i)*fac_shield(j) &
4128 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4130 0.5d0*(pizda(1,1)+pizda(2,2)) &
4131 *fac_shield(i)*fac_shield(j)
4133 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
4134 'eturn3',i,j,0.5d0*(pizda(1,1)+pizda(2,2))
4135 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
4136 (shield_mode.gt.0)) then
4139 do ilist=1,ishield_list(i)
4140 iresshield=shield_list(ilist,i)
4142 rlocshield=grad_shield_side(k,ilist,i)*eello_t3/fac_shield(i)
4143 gshieldx_t3(k,iresshield)=gshieldx_t3(k,iresshield)+ &
4145 +grad_shield_loc(k,ilist,i)*eello_t3/fac_shield(i)
4146 gshieldc_t3(k,iresshield-1)=gshieldc_t3(k,iresshield-1) &
4150 do ilist=1,ishield_list(j)
4151 iresshield=shield_list(ilist,j)
4153 rlocshield=grad_shield_side(k,ilist,j)*eello_t3/fac_shield(j)
4154 gshieldx_t3(k,iresshield)=gshieldx_t3(k,iresshield)+ &
4156 +grad_shield_loc(k,ilist,j)*eello_t3/fac_shield(j)
4157 gshieldc_t3(k,iresshield-1)=gshieldc_t3(k,iresshield-1) &
4164 gshieldc_t3(k,i)=gshieldc_t3(k,i)+ &
4165 grad_shield(k,i)*eello_t3/fac_shield(i)
4166 gshieldc_t3(k,j)=gshieldc_t3(k,j)+ &
4167 grad_shield(k,j)*eello_t3/fac_shield(j)
4168 gshieldc_t3(k,i-1)=gshieldc_t3(k,i-1)+ &
4169 grad_shield(k,i)*eello_t3/fac_shield(i)
4170 gshieldc_t3(k,j-1)=gshieldc_t3(k,j-1)+ &
4171 grad_shield(k,j)*eello_t3/fac_shield(j)
4175 !d write (2,*) 'i,',i,' j',j,'eello_turn3',
4176 !d & 0.5d0*(pizda(1,1)+pizda(2,2)),
4177 !d & ' eello_turn3_num',4*eello_turn3_num
4178 ! Derivatives in gamma(i)
4179 call matmat2(EUgder(1,1,i+1),EUg(1,1,i+2),auxmat2(1,1))
4180 call transpose2(auxmat2(1,1),auxmat3(1,1))
4181 call matmat2(a_temp(1,1),auxmat3(1,1),pizda(1,1))
4182 gel_loc_turn3(i)=gel_loc_turn3(i)+0.5d0*(pizda(1,1)+pizda(2,2))&
4183 *fac_shield(i)*fac_shield(j) &
4184 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4185 ! Derivatives in gamma(i+1)
4186 call matmat2(EUg(1,1,i+1),EUgder(1,1,i+2),auxmat2(1,1))
4187 call transpose2(auxmat2(1,1),auxmat3(1,1))
4188 call matmat2(a_temp(1,1),auxmat3(1,1),pizda(1,1))
4189 gel_loc_turn3(i+1)=gel_loc_turn3(i+1) &
4190 +0.5d0*(pizda(1,1)+pizda(2,2)) &
4191 *fac_shield(i)*fac_shield(j) &
4192 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4194 ! Cartesian derivatives
4196 ! ghalf1=0.5d0*agg(l,1)
4197 ! ghalf2=0.5d0*agg(l,2)
4198 ! ghalf3=0.5d0*agg(l,3)
4199 ! ghalf4=0.5d0*agg(l,4)
4200 a_temp(1,1)=aggi(l,1)!+ghalf1
4201 a_temp(1,2)=aggi(l,2)!+ghalf2
4202 a_temp(2,1)=aggi(l,3)!+ghalf3
4203 a_temp(2,2)=aggi(l,4)!+ghalf4
4204 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4205 gcorr3_turn(l,i)=gcorr3_turn(l,i) &
4206 +0.5d0*(pizda(1,1)+pizda(2,2)) &
4207 *fac_shield(i)*fac_shield(j) &
4208 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4210 a_temp(1,1)=aggi1(l,1)!+agg(l,1)
4211 a_temp(1,2)=aggi1(l,2)!+agg(l,2)
4212 a_temp(2,1)=aggi1(l,3)!+agg(l,3)
4213 a_temp(2,2)=aggi1(l,4)!+agg(l,4)
4214 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4215 gcorr3_turn(l,i+1)=gcorr3_turn(l,i+1) &
4216 +0.5d0*(pizda(1,1)+pizda(2,2)) &
4217 *fac_shield(i)*fac_shield(j) &
4218 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4220 a_temp(1,1)=aggj(l,1)!+ghalf1
4221 a_temp(1,2)=aggj(l,2)!+ghalf2
4222 a_temp(2,1)=aggj(l,3)!+ghalf3
4223 a_temp(2,2)=aggj(l,4)!+ghalf4
4224 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4225 gcorr3_turn(l,j)=gcorr3_turn(l,j) &
4226 +0.5d0*(pizda(1,1)+pizda(2,2)) &
4227 *fac_shield(i)*fac_shield(j) &
4228 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4230 a_temp(1,1)=aggj1(l,1)
4231 a_temp(1,2)=aggj1(l,2)
4232 a_temp(2,1)=aggj1(l,3)
4233 a_temp(2,2)=aggj1(l,4)
4234 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4235 gcorr3_turn(l,j1)=gcorr3_turn(l,j1) &
4236 +0.5d0*(pizda(1,1)+pizda(2,2)) &
4237 *fac_shield(i)*fac_shield(j) &
4238 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4240 gshieldc_t3(3,i)=gshieldc_t3(3,i)+ &
4241 ssgradlipi*eello_t3/4.0d0*lipscale
4242 gshieldc_t3(3,j)=gshieldc_t3(3,j)+ &
4243 ssgradlipj*eello_t3/4.0d0*lipscale
4244 gshieldc_t3(3,i-1)=gshieldc_t3(3,i-1)+ &
4245 ssgradlipi*eello_t3/4.0d0*lipscale
4246 gshieldc_t3(3,j-1)=gshieldc_t3(3,j-1)+ &
4247 ssgradlipj*eello_t3/4.0d0*lipscale
4250 end subroutine eturn3
4251 !-----------------------------------------------------------------------------
4252 subroutine eturn4(i,eello_turn4)
4253 ! Third- and fourth-order contributions from turns
4256 ! implicit real*8 (a-h,o-z)
4257 ! include 'DIMENSIONS'
4258 ! include 'COMMON.IOUNITS'
4259 ! include 'COMMON.GEO'
4260 ! include 'COMMON.VAR'
4261 ! include 'COMMON.LOCAL'
4262 ! include 'COMMON.CHAIN'
4263 ! include 'COMMON.DERIV'
4264 ! include 'COMMON.INTERACT'
4265 ! include 'COMMON.CONTACTS'
4266 ! include 'COMMON.TORSION'
4267 ! include 'COMMON.VECTORS'
4268 ! include 'COMMON.FFIELD'
4269 ! include 'COMMON.CONTROL'
4270 real(kind=8),dimension(3) :: ggg
4271 real(kind=8),dimension(2,2) :: auxmat,auxmat1,auxmat2,pizda,&
4272 e1t,e2t,e3t,e1tder,e2tder,e3tder,e1a,ae3,ae3e2
4273 real(kind=8),dimension(2) :: auxvec,auxvec1
4274 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
4275 real(kind=8),dimension(2,2) :: auxmat3 !el a_temp
4276 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
4277 !el dz_normi,xmedi,ymedi,zmedi
4278 !el integer :: num_conti,j1,j2
4279 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
4280 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
4283 integer :: i,j,iti1,iti2,iti3,l,k,ilist,iresshield
4284 real(kind=8) :: eello_turn4,s1,s2,s3,zj,fracinbuf,eello_t4,&
4288 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4290 ! Fourth-order contributions
4298 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4299 !d call checkint_turn4(i,a_temp,eello_turn4_num)
4300 ! write (iout,*) "eturn4 i",i," j",j," j1",j1," j2",j2
4301 zj=(c(3,j)+c(3,j+1))/2.0d0
4303 if (zj.lt.0) zj=zj+boxzsize
4304 if ((zj.gt.bordlipbot) &
4305 .and.(zj.lt.bordliptop)) then
4306 !C the energy transfer exist
4307 if (zj.lt.buflipbot) then
4308 !C what fraction I am in
4310 ((zj-bordlipbot)/lipbufthick)
4311 !C lipbufthick is thickenes of lipid buffore
4312 sslipj=sscalelip(fracinbuf)
4313 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
4314 elseif (zj.gt.bufliptop) then
4315 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
4316 sslipj=sscalelip(fracinbuf)
4317 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
4331 iti1=itortyp(itype(i+1,1))
4332 iti2=itortyp(itype(i+2,1))
4333 iti3=itortyp(itype(i+3,1))
4334 ! write(iout,*) "iti1",iti1," iti2",iti2," iti3",iti3
4335 call transpose2(EUg(1,1,i+1),e1t(1,1))
4336 call transpose2(Eug(1,1,i+2),e2t(1,1))
4337 call transpose2(Eug(1,1,i+3),e3t(1,1))
4338 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4339 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4340 s1=scalar2(b1(1,iti2),auxvec(1))
4341 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4342 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4343 s2=scalar2(b1(1,iti1),auxvec(1))
4344 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4345 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4346 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4347 if (shield_mode.eq.0) then
4352 eello_turn4=eello_turn4-(s1+s2+s3) &
4353 *fac_shield(i)*fac_shield(j) &
4354 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4355 eello_t4=-(s1+s2+s3) &
4356 *fac_shield(i)*fac_shield(j)
4357 !C Now derivative over shield:
4358 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
4359 (shield_mode.gt.0)) then
4362 do ilist=1,ishield_list(i)
4363 iresshield=shield_list(ilist,i)
4365 rlocshield=grad_shield_side(k,ilist,i)*eello_t4/fac_shield(i)
4366 gshieldx_t4(k,iresshield)=gshieldx_t4(k,iresshield)+ &
4368 +grad_shield_loc(k,ilist,i)*eello_t4/fac_shield(i)
4369 gshieldc_t4(k,iresshield-1)=gshieldc_t4(k,iresshield-1) &
4373 do ilist=1,ishield_list(j)
4374 iresshield=shield_list(ilist,j)
4376 rlocshield=grad_shield_side(k,ilist,j)*eello_t4/fac_shield(j)
4377 gshieldx_t4(k,iresshield)=gshieldx_t4(k,iresshield)+ &
4379 +grad_shield_loc(k,ilist,j)*eello_t4/fac_shield(j)
4380 gshieldc_t4(k,iresshield-1)=gshieldc_t4(k,iresshield-1) &
4387 gshieldc_t4(k,i)=gshieldc_t4(k,i)+ &
4388 grad_shield(k,i)*eello_t4/fac_shield(i)
4389 gshieldc_t4(k,j)=gshieldc_t4(k,j)+ &
4390 grad_shield(k,j)*eello_t4/fac_shield(j)
4391 gshieldc_t4(k,i-1)=gshieldc_t4(k,i-1)+ &
4392 grad_shield(k,i)*eello_t4/fac_shield(i)
4393 gshieldc_t4(k,j-1)=gshieldc_t4(k,j-1)+ &
4394 grad_shield(k,j)*eello_t4/fac_shield(j)
4398 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
4399 'eturn4',i,j,-(s1+s2+s3)
4400 !d write (2,*) 'i,',i,' j',j,'eello_turn4',-(s1+s2+s3),
4401 !d & ' eello_turn4_num',8*eello_turn4_num
4402 ! Derivatives in gamma(i)
4403 call transpose2(EUgder(1,1,i+1),e1tder(1,1))
4404 call matmat2(e1tder(1,1),a_temp(1,1),auxmat(1,1))
4405 call matvec2(auxmat(1,1),Ub2(1,i+3),auxvec(1))
4406 s1=scalar2(b1(1,iti2),auxvec(1))
4407 call matmat2(ae3e2(1,1),e1tder(1,1),pizda(1,1))
4408 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4409 gel_loc_turn4(i)=gel_loc_turn4(i)-(s1+s3) &
4410 *fac_shield(i)*fac_shield(j) &
4411 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4413 ! Derivatives in gamma(i+1)
4414 call transpose2(EUgder(1,1,i+2),e2tder(1,1))
4415 call matvec2(ae3(1,1),Ub2der(1,i+2),auxvec(1))
4416 s2=scalar2(b1(1,iti1),auxvec(1))
4417 call matmat2(ae3(1,1),e2tder(1,1),auxmat(1,1))
4418 call matmat2(auxmat(1,1),e1t(1,1),pizda(1,1))
4419 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4420 gel_loc_turn4(i+1)=gel_loc_turn4(i+1)-(s2+s3) &
4421 *fac_shield(i)*fac_shield(j) &
4422 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4424 ! Derivatives in gamma(i+2)
4425 call transpose2(EUgder(1,1,i+3),e3tder(1,1))
4426 call matvec2(e1a(1,1),Ub2der(1,i+3),auxvec(1))
4427 s1=scalar2(b1(1,iti2),auxvec(1))
4428 call matmat2(a_temp(1,1),e3tder(1,1),auxmat(1,1))
4429 call matvec2(auxmat(1,1),Ub2(1,i+2),auxvec(1))
4430 s2=scalar2(b1(1,iti1),auxvec(1))
4431 call matmat2(auxmat(1,1),e2t(1,1),auxmat3(1,1))
4432 call matmat2(auxmat3(1,1),e1t(1,1),pizda(1,1))
4433 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4434 gel_loc_turn4(i+2)=gel_loc_turn4(i+2)-(s1+s2+s3) &
4435 *fac_shield(i)*fac_shield(j) &
4436 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4438 ! Cartesian derivatives
4439 ! Derivatives of this turn contributions in DC(i+2)
4440 if (j.lt.nres-1) then
4442 a_temp(1,1)=agg(l,1)
4443 a_temp(1,2)=agg(l,2)
4444 a_temp(2,1)=agg(l,3)
4445 a_temp(2,2)=agg(l,4)
4446 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4447 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4448 s1=scalar2(b1(1,iti2),auxvec(1))
4449 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4450 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4451 s2=scalar2(b1(1,iti1),auxvec(1))
4452 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4453 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4454 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4456 gcorr4_turn(l,i+2)=gcorr4_turn(l,i+2)-(s1+s2+s3)&
4457 *fac_shield(i)*fac_shield(j) &
4458 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4462 ! Remaining derivatives of this turn contribution
4464 a_temp(1,1)=aggi(l,1)
4465 a_temp(1,2)=aggi(l,2)
4466 a_temp(2,1)=aggi(l,3)
4467 a_temp(2,2)=aggi(l,4)
4468 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4469 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4470 s1=scalar2(b1(1,iti2),auxvec(1))
4471 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4472 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4473 s2=scalar2(b1(1,iti1),auxvec(1))
4474 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4475 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4476 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4477 gcorr4_turn(l,i)=gcorr4_turn(l,i)-(s1+s2+s3) &
4478 *fac_shield(i)*fac_shield(j) &
4479 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4482 a_temp(1,1)=aggi1(l,1)
4483 a_temp(1,2)=aggi1(l,2)
4484 a_temp(2,1)=aggi1(l,3)
4485 a_temp(2,2)=aggi1(l,4)
4486 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4487 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4488 s1=scalar2(b1(1,iti2),auxvec(1))
4489 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4490 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4491 s2=scalar2(b1(1,iti1),auxvec(1))
4492 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4493 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4494 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4495 gcorr4_turn(l,i+1)=gcorr4_turn(l,i+1)-(s1+s2+s3) &
4496 *fac_shield(i)*fac_shield(j) &
4497 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4500 a_temp(1,1)=aggj(l,1)
4501 a_temp(1,2)=aggj(l,2)
4502 a_temp(2,1)=aggj(l,3)
4503 a_temp(2,2)=aggj(l,4)
4504 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4505 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4506 s1=scalar2(b1(1,iti2),auxvec(1))
4507 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4508 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4509 s2=scalar2(b1(1,iti1),auxvec(1))
4510 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4511 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4512 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4513 gcorr4_turn(l,j)=gcorr4_turn(l,j)-(s1+s2+s3) &
4514 *fac_shield(i)*fac_shield(j) &
4515 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4518 a_temp(1,1)=aggj1(l,1)
4519 a_temp(1,2)=aggj1(l,2)
4520 a_temp(2,1)=aggj1(l,3)
4521 a_temp(2,2)=aggj1(l,4)
4522 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4523 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4524 s1=scalar2(b1(1,iti2),auxvec(1))
4525 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4526 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4527 s2=scalar2(b1(1,iti1),auxvec(1))
4528 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4529 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4530 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4531 ! write (iout,*) "s1",s1," s2",s2," s3",s3," s1+s2+s3",s1+s2+s3
4532 gcorr4_turn(l,j1)=gcorr4_turn(l,j1)-(s1+s2+s3) &
4533 *fac_shield(i)*fac_shield(j) &
4534 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4537 gshieldc_t4(3,i)=gshieldc_t4(3,i)+ &
4538 ssgradlipi*eello_t4/4.0d0*lipscale
4539 gshieldc_t4(3,j)=gshieldc_t4(3,j)+ &
4540 ssgradlipj*eello_t4/4.0d0*lipscale
4541 gshieldc_t4(3,i-1)=gshieldc_t4(3,i-1)+ &
4542 ssgradlipi*eello_t4/4.0d0*lipscale
4543 gshieldc_t4(3,j-1)=gshieldc_t4(3,j-1)+ &
4544 ssgradlipj*eello_t4/4.0d0*lipscale
4547 end subroutine eturn4
4548 !-----------------------------------------------------------------------------
4549 subroutine unormderiv(u,ugrad,unorm,ungrad)
4550 ! This subroutine computes the derivatives of a normalized vector u, given
4551 ! the derivatives computed without normalization conditions, ugrad. Returns
4554 real(kind=8),dimension(3) :: u,vec
4555 real(kind=8),dimension(3,3) ::ugrad,ungrad
4556 real(kind=8) :: unorm !,scalar
4558 ! write (2,*) 'ugrad',ugrad
4561 vec(i)=scalar(ugrad(1,i),u(1))
4563 ! write (2,*) 'vec',vec
4566 ungrad(j,i)=(ugrad(j,i)-u(j)*vec(i))*unorm
4569 ! write (2,*) 'ungrad',ungrad
4571 end subroutine unormderiv
4572 !-----------------------------------------------------------------------------
4573 subroutine escp_soft_sphere(evdw2,evdw2_14)
4575 ! This subroutine calculates the excluded-volume interaction energy between
4576 ! peptide-group centers and side chains and its gradient in virtual-bond and
4577 ! side-chain vectors.
4579 ! implicit real*8 (a-h,o-z)
4580 ! include 'DIMENSIONS'
4581 ! include 'COMMON.GEO'
4582 ! include 'COMMON.VAR'
4583 ! include 'COMMON.LOCAL'
4584 ! include 'COMMON.CHAIN'
4585 ! include 'COMMON.DERIV'
4586 ! include 'COMMON.INTERACT'
4587 ! include 'COMMON.FFIELD'
4588 ! include 'COMMON.IOUNITS'
4589 ! include 'COMMON.CONTROL'
4590 real(kind=8),dimension(3) :: ggg
4592 integer :: i,iint,j,k,iteli,itypj
4593 real(kind=8) :: evdw2,evdw2_14,r0_scp,xi,yi,zi,xj,yj,zj,&
4594 fac,rij,r0ij,r0ijsq,evdwij,e1,e2
4599 !d print '(a)','Enter ESCP'
4600 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
4601 do i=iatscp_s,iatscp_e
4602 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
4604 xi=0.5D0*(c(1,i)+c(1,i+1))
4605 yi=0.5D0*(c(2,i)+c(2,i+1))
4606 zi=0.5D0*(c(3,i)+c(3,i+1))
4608 do iint=1,nscp_gr(i)
4610 do j=iscpstart(i,iint),iscpend(i,iint)
4611 if (itype(j,1).eq.ntyp1) cycle
4612 itypj=iabs(itype(j,1))
4613 ! Uncomment following three lines for SC-p interactions
4617 ! Uncomment following three lines for Ca-p interactions
4621 rij=xj*xj+yj*yj+zj*zj
4624 if (rij.lt.r0ijsq) then
4625 evdwij=0.25d0*(rij-r0ijsq)**2
4633 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
4638 !grad if (j.lt.i) then
4639 !d write (iout,*) 'j<i'
4640 ! Uncomment following three lines for SC-p interactions
4642 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
4645 !d write (iout,*) 'j>i'
4647 !grad ggg(k)=-ggg(k)
4648 ! Uncomment following line for SC-p interactions
4649 ! gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
4653 !grad gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
4655 !grad kstart=min0(i+1,j)
4656 !grad kend=max0(i-1,j-1)
4657 !d write (iout,*) 'i=',i,' j=',j,' kstart=',kstart,' kend=',kend
4658 !d write (iout,*) ggg(1),ggg(2),ggg(3)
4659 !grad do k=kstart,kend
4661 !grad gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
4665 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
4666 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
4673 end subroutine escp_soft_sphere
4674 !-----------------------------------------------------------------------------
4675 subroutine escp(evdw2,evdw2_14)
4677 ! This subroutine calculates the excluded-volume interaction energy between
4678 ! peptide-group centers and side chains and its gradient in virtual-bond and
4679 ! side-chain vectors.
4681 ! implicit real*8 (a-h,o-z)
4682 ! include 'DIMENSIONS'
4683 ! include 'COMMON.GEO'
4684 ! include 'COMMON.VAR'
4685 ! include 'COMMON.LOCAL'
4686 ! include 'COMMON.CHAIN'
4687 ! include 'COMMON.DERIV'
4688 ! include 'COMMON.INTERACT'
4689 ! include 'COMMON.FFIELD'
4690 ! include 'COMMON.IOUNITS'
4691 ! include 'COMMON.CONTROL'
4692 real(kind=8),dimension(3) :: ggg
4694 integer :: i,iint,j,k,iteli,itypj,subchap
4695 real(kind=8) :: evdw2,evdw2_14,xi,yi,zi,xj,yj,zj,rrij,fac,&
4697 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
4698 dist_temp, dist_init
4699 integer xshift,yshift,zshift
4703 !d print '(a)','Enter ESCP'
4704 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
4705 do i=iatscp_s,iatscp_e
4706 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
4708 xi=0.5D0*(c(1,i)+c(1,i+1))
4709 yi=0.5D0*(c(2,i)+c(2,i+1))
4710 zi=0.5D0*(c(3,i)+c(3,i+1))
4712 if (xi.lt.0) xi=xi+boxxsize
4714 if (yi.lt.0) yi=yi+boxysize
4716 if (zi.lt.0) zi=zi+boxzsize
4718 do iint=1,nscp_gr(i)
4720 do j=iscpstart(i,iint),iscpend(i,iint)
4721 itypj=iabs(itype(j,1))
4722 if (itypj.eq.ntyp1) cycle
4723 ! Uncomment following three lines for SC-p interactions
4727 ! Uncomment following three lines for Ca-p interactions
4735 if (xj.lt.0) xj=xj+boxxsize
4737 if (yj.lt.0) yj=yj+boxysize
4739 if (zj.lt.0) zj=zj+boxzsize
4740 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
4748 xj=xj_safe+xshift*boxxsize
4749 yj=yj_safe+yshift*boxysize
4750 zj=zj_safe+zshift*boxzsize
4751 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
4752 if(dist_temp.lt.dist_init) then
4762 if (subchap.eq.1) then
4772 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
4773 rij=dsqrt(1.0d0/rrij)
4774 sss_ele_cut=sscale_ele(rij)
4775 sss_ele_grad=sscagrad_ele(rij)
4776 ! print *,sss_ele_cut,sss_ele_grad,&
4777 ! (rij),r_cut_ele,rlamb_ele
4778 if (sss_ele_cut.le.0.0) cycle
4780 e1=fac*fac*aad(itypj,iteli)
4781 e2=fac*bad(itypj,iteli)
4782 if (iabs(j-i) .le. 2) then
4785 evdw2_14=evdw2_14+(e1+e2)*sss_ele_cut
4788 evdw2=evdw2+evdwij*sss_ele_cut
4789 ! if (energy_dec) write (iout,'(a6,2i5,0pf7.3,2i3,3e11.3)') &
4790 ! 'evdw2',i,j,evdwij,iteli,itypj,fac,aad(itypj,iteli),&
4791 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
4794 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
4796 fac=-(evdwij+e1)*rrij*sss_ele_cut
4797 fac=fac+evdwij*sss_ele_grad/rij/expon
4801 !grad if (j.lt.i) then
4802 !d write (iout,*) 'j<i'
4803 ! Uncomment following three lines for SC-p interactions
4805 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
4808 !d write (iout,*) 'j>i'
4810 !grad ggg(k)=-ggg(k)
4811 ! Uncomment following line for SC-p interactions
4812 !cgrad gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
4813 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
4817 !grad gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
4819 !grad kstart=min0(i+1,j)
4820 !grad kend=max0(i-1,j-1)
4821 !d write (iout,*) 'i=',i,' j=',j,' kstart=',kstart,' kend=',kend
4822 !d write (iout,*) ggg(1),ggg(2),ggg(3)
4823 !grad do k=kstart,kend
4825 !grad gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
4829 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
4830 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
4838 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
4839 gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
4840 gradx_scp(j,i)=expon*gradx_scp(j,i)
4843 !******************************************************************************
4847 ! To save time the factor EXPON has been extracted from ALL components
4848 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
4851 !******************************************************************************
4854 !-----------------------------------------------------------------------------
4855 subroutine edis(ehpb)
4857 ! Evaluate bridge-strain energy and its gradient in virtual-bond and SC vectors.
4859 ! implicit real*8 (a-h,o-z)
4860 ! include 'DIMENSIONS'
4861 ! include 'COMMON.SBRIDGE'
4862 ! include 'COMMON.CHAIN'
4863 ! include 'COMMON.DERIV'
4864 ! include 'COMMON.VAR'
4865 ! include 'COMMON.INTERACT'
4866 ! include 'COMMON.IOUNITS'
4867 real(kind=8),dimension(3) :: ggg
4869 integer :: i,j,ii,jj,iii,jjj,k
4870 real(kind=8) :: fac,eij,rdis,ehpb,dd,waga
4873 !d write(iout,*)'edis: nhpb=',nhpb,' fbr=',fbr
4874 !d write(iout,*)'link_start=',link_start,' link_end=',link_end
4875 if (link_end.eq.0) return
4876 do i=link_start,link_end
4877 ! If ihpb(i) and jhpb(i) > NRES, this is a SC-SC distance, otherwise a
4878 ! CA-CA distance used in regularization of structure.
4881 ! iii and jjj point to the residues for which the distance is assigned.
4882 if (ii.gt.nres) then
4889 ! write (iout,*) "i",i," ii",ii," iii",iii," jj",jj," jjj",jjj,
4890 ! & dhpb(i),dhpb1(i),forcon(i)
4891 ! 24/11/03 AL: SS bridges handled separately because of introducing a specific
4892 ! distance and angle dependent SS bond potential.
4893 !mc if (ii.gt.nres .and. itype(iii).eq.1 .and. itype(jjj).eq.1) then
4894 ! 18/07/06 MC: Use the convention that the first nss pairs are SS bonds
4895 if (.not.dyn_ss .and. i.le.nss) then
4896 ! 15/02/13 CC dynamic SSbond - additional check
4897 if (ii.gt.nres .and. iabs(itype(iii,1)).eq.1 .and. &
4898 iabs(itype(jjj,1)).eq.1) then
4899 call ssbond_ene(iii,jjj,eij)
4901 !d write (iout,*) "eij",eij
4903 else if (ii.gt.nres .and. jj.gt.nres) then
4904 !c Restraints from contact prediction
4906 if (constr_dist.eq.11) then
4907 ehpb=ehpb+fordepth(i)**4.0d0 &
4908 *rlornmr1(dd,dhpb(i),dhpb1(i),forcon(i))
4909 fac=fordepth(i)**4.0d0 &
4910 *rlornmr1prim(dd,dhpb(i),dhpb1(i),forcon(i))/dd
4911 if (energy_dec) write (iout,'(a6,2i5,3f8.3)') "edisl",ii,jj, &
4914 if (dhpb1(i).gt.0.0d0) then
4915 ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
4916 fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
4917 !c write (iout,*) "beta nmr",
4918 !c & dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
4922 !C Get the force constant corresponding to this distance.
4924 !C Calculate the contribution to energy.
4925 ehpb=ehpb+waga*rdis*rdis
4926 !c write (iout,*) "beta reg",dd,waga*rdis*rdis
4928 !C Evaluate gradient.
4934 ggg(j)=fac*(c(j,jj)-c(j,ii))
4937 ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
4938 ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
4941 ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
4942 ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
4946 if (constr_dist.eq.11) then
4947 ehpb=ehpb+fordepth(i)**4.0d0 &
4948 *rlornmr1(dd,dhpb(i),dhpb1(i),forcon(i))
4949 fac=fordepth(i)**4.0d0 &
4950 *rlornmr1prim(dd,dhpb(i),dhpb1(i),forcon(i))/dd
4951 if (energy_dec) write (iout,'(a6,2i5,3f8.3)') "edisl",ii,jj, &
4954 if (dhpb1(i).gt.0.0d0) then
4955 ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
4956 fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
4957 !c write (iout,*) "alph nmr",
4958 !c & dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
4961 !C Get the force constant corresponding to this distance.
4963 !C Calculate the contribution to energy.
4964 ehpb=ehpb+waga*rdis*rdis
4965 !c write (iout,*) "alpha reg",dd,waga*rdis*rdis
4967 !C Evaluate gradient.
4974 ggg(j)=fac*(c(j,jj)-c(j,ii))
4976 !cd print '(i3,3(1pe14.5))',i,(ggg(j),j=1,3)
4977 !C If this is a SC-SC distance, we need to calculate the contributions to the
4978 !C Cartesian gradient in the SC vectors (ghpbx).
4981 ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
4982 ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
4985 !cgrad do j=iii,jjj-1
4987 !cgrad ghpbc(k,j)=ghpbc(k,j)+ggg(k)
4991 ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
4992 ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
4996 if (constr_dist.ne.11) ehpb=0.5D0*ehpb
5000 !-----------------------------------------------------------------------------
5001 subroutine ssbond_ene(i,j,eij)
5003 ! Calculate the distance and angle dependent SS-bond potential energy
5004 ! using a free-energy function derived based on RHF/6-31G** ab initio
5005 ! calculations of diethyl disulfide.
5007 ! A. Liwo and U. Kozlowska, 11/24/03
5009 ! implicit real*8 (a-h,o-z)
5010 ! include 'DIMENSIONS'
5011 ! include 'COMMON.SBRIDGE'
5012 ! include 'COMMON.CHAIN'
5013 ! include 'COMMON.DERIV'
5014 ! include 'COMMON.LOCAL'
5015 ! include 'COMMON.INTERACT'
5016 ! include 'COMMON.VAR'
5017 ! include 'COMMON.IOUNITS'
5018 real(kind=8),dimension(3) :: erij,dcosom1,dcosom2,gg
5020 integer :: i,j,itypi,itypj,k
5021 real(kind=8) :: eij,rij,rrij,xi,yi,zi,dxi,dyi,dzi,dsci_inv,&
5022 xj,yj,zj,dxj,dyj,dzj,om1,om2,om12,deltad,dscj_inv,&
5023 deltat1,deltat2,deltat12,ed,pom1,pom2,eom1,eom2,eom12,&
5026 itypi=iabs(itype(i,1))
5030 dxi=dc_norm(1,nres+i)
5031 dyi=dc_norm(2,nres+i)
5032 dzi=dc_norm(3,nres+i)
5033 ! dsci_inv=dsc_inv(itypi)
5034 dsci_inv=vbld_inv(nres+i)
5035 itypj=iabs(itype(j,1))
5036 ! dscj_inv=dsc_inv(itypj)
5037 dscj_inv=vbld_inv(nres+j)
5041 dxj=dc_norm(1,nres+j)
5042 dyj=dc_norm(2,nres+j)
5043 dzj=dc_norm(3,nres+j)
5044 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
5049 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
5050 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
5051 om12=dxi*dxj+dyi*dyj+dzi*dzj
5053 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
5054 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
5060 deltat12=om2-om1+2.0d0
5062 eij=akcm*deltad*deltad+akth*(deltat1*deltat1+deltat2*deltat2) &
5063 +akct*deltad*deltat12 &
5064 +v1ss*cosphi+v2ss*cosphi*cosphi+v3ss*cosphi*cosphi*cosphi+ebr
5065 ! write(iout,*) i,j,"rij",rij,"d0cm",d0cm," akcm",akcm," akth",akth,
5066 ! & " akct",akct," deltad",deltad," deltat",deltat1,deltat2,
5067 ! & " deltat12",deltat12," eij",eij
5068 ed=2*akcm*deltad+akct*deltat12
5070 pom2=v1ss+2*v2ss*cosphi+3*v3ss*cosphi*cosphi
5071 eom1=-2*akth*deltat1-pom1-om2*pom2
5072 eom2= 2*akth*deltat2+pom1-om1*pom2
5075 ggk=ed*erij(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
5076 ghpbx(k,i)=ghpbx(k,i)-ggk &
5077 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
5078 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
5079 ghpbx(k,j)=ghpbx(k,j)+ggk &
5080 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
5081 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
5082 ghpbc(k,i)=ghpbc(k,i)-ggk
5083 ghpbc(k,j)=ghpbc(k,j)+ggk
5086 ! Calculate the components of the gradient in DC and X
5090 !grad ghpbc(l,k)=ghpbc(l,k)+gg(l)
5094 end subroutine ssbond_ene
5095 !-----------------------------------------------------------------------------
5096 subroutine ebond(estr)
5098 ! Evaluate the energy of stretching of the CA-CA and CA-SC virtual bonds
5100 ! implicit real*8 (a-h,o-z)
5101 ! include 'DIMENSIONS'
5102 ! include 'COMMON.LOCAL'
5103 ! include 'COMMON.GEO'
5104 ! include 'COMMON.INTERACT'
5105 ! include 'COMMON.DERIV'
5106 ! include 'COMMON.VAR'
5107 ! include 'COMMON.CHAIN'
5108 ! include 'COMMON.IOUNITS'
5109 ! include 'COMMON.NAMES'
5110 ! include 'COMMON.FFIELD'
5111 ! include 'COMMON.CONTROL'
5112 ! include 'COMMON.SETUP'
5113 real(kind=8),dimension(3) :: u,ud
5115 integer :: i,j,iti,nbi,k
5116 real(kind=8) :: estr,estr1,diff,uprod,usum,usumsqder,&
5121 ! if (.not.allocated(gradb)) allocate(gradb(3,nres)) !(3,maxres)
5122 ! if (.not.allocated(gradbx)) allocate(gradbx(3,nres)) !(3,maxres)
5124 do i=ibondp_start,ibondp_end
5125 if (itype(i-1,1).eq.ntyp1 .and. itype(i,1).eq.ntyp1) cycle
5126 if (itype(i-1,1).eq.ntyp1 .or. itype(i,1).eq.ntyp1) then
5127 !C estr1=estr1+gnmr1(vbld(i),-1.0d0,distchainmax)
5129 !C gradb(j,i-1)=gnmr1prim(vbld(i),-1.0d0,distchainmax) &
5130 !C *dc(j,i-1)/vbld(i)
5132 !C if (energy_dec) write(iout,*) &
5133 !C "estr1",i,gnmr1(vbld(i),-1.0d0,distchainmax)
5134 diff = vbld(i)-vbldpDUM
5136 diff = vbld(i)-vbldp0
5138 if (energy_dec) write (iout,'(a7,i5,4f7.3)') &
5139 "estr bb",i,vbld(i),vbldp0,diff,AKP*diff*diff
5142 gradb(j,i-1)=AKP*diff*dc(j,i-1)/vbld(i)
5144 ! write (iout,'(i5,3f10.5)') i,(gradb(j,i-1),j=1,3)
5147 estr=0.5d0*AKP*estr+estr1
5148 print *,"estr_bb",estr,AKP
5150 ! 09/18/07 AL: multimodal bond potential based on AM1 CA-SC PMF's included
5152 do i=ibond_start,ibond_end
5153 iti=iabs(itype(i,1))
5154 if (iti.eq.0) print *,"WARNING WRONG SETTTING",i
5155 if (iti.ne.10 .and. iti.ne.ntyp1) then
5158 diff=vbld(i+nres)-vbldsc0(1,iti)
5159 if (energy_dec) write (iout,*) &
5160 "estr sc",i,iti,vbld(i+nres),vbldsc0(1,iti),diff,&
5161 AKSC(1,iti),AKSC(1,iti)*diff*diff
5162 estr=estr+0.5d0*AKSC(1,iti)*diff*diff
5163 print *,"estr_sc",estr
5165 gradbx(j,i)=AKSC(1,iti)*diff*dc(j,i+nres)/vbld(i+nres)
5169 diff=vbld(i+nres)-vbldsc0(j,iti)
5170 ud(j)=aksc(j,iti)*diff
5171 u(j)=abond0(j,iti)+0.5d0*ud(j)*diff
5185 uprod2=uprod2*u(k)*u(k)
5189 usumsqder=usumsqder+ud(j)*uprod2
5191 estr=estr+uprod/usum
5192 print *,"estr_sc",estr,i
5194 if (energy_dec) write (iout,*) &
5195 "estr sc",i,iti,vbld(i+nres),vbldsc0(1,iti),diff,&
5196 AKSC(1,iti),AKSC(1,iti)*diff*diff
5198 gradbx(j,i)=usumsqder/(usum*usum)*dc(j,i+nres)/vbld(i+nres)
5204 end subroutine ebond
5206 !-----------------------------------------------------------------------------
5207 subroutine ebend(etheta)
5209 ! Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
5210 ! angles gamma and its derivatives in consecutive thetas and gammas.
5213 ! implicit real*8 (a-h,o-z)
5214 ! include 'DIMENSIONS'
5215 ! include 'COMMON.LOCAL'
5216 ! include 'COMMON.GEO'
5217 ! include 'COMMON.INTERACT'
5218 ! include 'COMMON.DERIV'
5219 ! include 'COMMON.VAR'
5220 ! include 'COMMON.CHAIN'
5221 ! include 'COMMON.IOUNITS'
5222 ! include 'COMMON.NAMES'
5223 ! include 'COMMON.FFIELD'
5224 ! include 'COMMON.CONTROL'
5225 !el real(kind=8) :: term1,term2,termm,diffak,ratak,&
5226 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
5227 !el delthe0,sig0inv,sigtc,sigsqtc,delthec
5229 !el common /calcthet/ term1,term2,termm,diffak,ratak,&
5230 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
5231 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,it
5233 integer :: i,k,ichir1,ichir2,itype1,ichir11,ichir12,itype2,&
5235 real(kind=8) :: etheta,delta,ss,ssd,phii,phii1,thet_pred_mean,&
5236 athetk,bthetk,dthett,dthetg1,dthetg2,f0,fprim0,E_tc0,fprim_tc0,&
5237 f1,fprim1,E_tc1,ethetai,E_theta,E_tc
5238 real(kind=8),dimension(2) :: y,z
5241 ! time11=dexp(-2*time)
5244 ! write (*,'(a,i2)') 'EBEND ICG=',icg
5245 do i=ithet_start,ithet_end
5246 if (itype(i-1,1).eq.ntyp1) cycle
5247 ! Zero the energy function and its derivative at 0 or pi.
5248 call splinthet(theta(i),0.5d0*delta,ss,ssd)
5250 ichir1=isign(1,itype(i-2,1))
5251 ichir2=isign(1,itype(i,1))
5252 if (itype(i-2,1).eq.10) ichir1=isign(1,itype(i-1,1))
5253 if (itype(i,1).eq.10) ichir2=isign(1,itype(i-1,1))
5254 if (itype(i-1,1).eq.10) then
5255 itype1=isign(10,itype(i-2,1))
5256 ichir11=isign(1,itype(i-2,1))
5257 ichir12=isign(1,itype(i-2,1))
5258 itype2=isign(10,itype(i,1))
5259 ichir21=isign(1,itype(i,1))
5260 ichir22=isign(1,itype(i,1))
5263 if (i.gt.3 .and. itype(i-2,1).ne.ntyp1) then
5266 if (phii.ne.phii) phii=150.0
5276 if (i.lt.nres .and. itype(i,1).ne.ntyp1) then
5279 if (phii1.ne.phii1) phii1=150.0
5291 ! Calculate the "mean" value of theta from the part of the distribution
5292 ! dependent on the adjacent virtual-bond-valence angles (gamma1 & gamma2).
5293 ! In following comments this theta will be referred to as t_c.
5294 thet_pred_mean=0.0d0
5296 athetk=athet(k,it,ichir1,ichir2)
5297 bthetk=bthet(k,it,ichir1,ichir2)
5299 athetk=athet(k,itype1,ichir11,ichir12)
5300 bthetk=bthet(k,itype2,ichir21,ichir22)
5302 thet_pred_mean=thet_pred_mean+athetk*y(k)+bthetk*z(k)
5304 dthett=thet_pred_mean*ssd
5305 thet_pred_mean=thet_pred_mean*ss+a0thet(it)
5306 ! Derivatives of the "mean" values in gamma1 and gamma2.
5307 dthetg1=(-athet(1,it,ichir1,ichir2)*y(2) &
5308 +athet(2,it,ichir1,ichir2)*y(1))*ss
5309 dthetg2=(-bthet(1,it,ichir1,ichir2)*z(2) &
5310 +bthet(2,it,ichir1,ichir2)*z(1))*ss
5312 dthetg1=(-athet(1,itype1,ichir11,ichir12)*y(2) &
5313 +athet(2,itype1,ichir11,ichir12)*y(1))*ss
5314 dthetg2=(-bthet(1,itype2,ichir21,ichir22)*z(2) &
5315 +bthet(2,itype2,ichir21,ichir22)*z(1))*ss
5317 if (theta(i).gt.pi-delta) then
5318 call theteng(pi-delta,thet_pred_mean,theta0(it),f0,fprim0,&
5320 call mixder(pi-delta,thet_pred_mean,theta0(it),fprim_tc0)
5321 call theteng(pi,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
5322 call spline1(theta(i),pi-delta,delta,f0,f1,fprim0,ethetai,&
5324 call spline2(theta(i),pi-delta,delta,E_tc0,E_tc1,fprim_tc0,&
5326 else if (theta(i).lt.delta) then
5327 call theteng(delta,thet_pred_mean,theta0(it),f0,fprim0,E_tc0)
5328 call theteng(0.0d0,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
5329 call spline1(theta(i),delta,-delta,f0,f1,fprim0,ethetai,&
5331 call mixder(delta,thet_pred_mean,theta0(it),fprim_tc0)
5332 call spline2(theta(i),delta,-delta,E_tc0,E_tc1,fprim_tc0,&
5335 call theteng(theta(i),thet_pred_mean,theta0(it),ethetai,&
5338 etheta=etheta+ethetai
5339 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
5341 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*E_tc*dthetg1
5342 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*E_tc*dthetg2
5343 gloc(nphi+i-2,icg)=wang*(E_theta+E_tc*dthett)
5345 ! Ufff.... We've done all this!!!
5347 end subroutine ebend
5348 !-----------------------------------------------------------------------------
5349 subroutine theteng(thetai,thet_pred_mean,theta0i,ethetai,E_theta,E_tc)
5352 ! implicit real*8 (a-h,o-z)
5353 ! include 'DIMENSIONS'
5354 ! include 'COMMON.LOCAL'
5355 ! include 'COMMON.IOUNITS'
5356 !el real(kind=8) :: term1,term2,termm,diffak,ratak,&
5357 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
5358 !el delthe0,sig0inv,sigtc,sigsqtc,delthec
5360 real(kind=8) :: thetai,thet_pred_mean,theta0i,ethetai,E_theta,E_tc
5362 !el common /calcthet/ term1,term2,termm,diffak,ratak,&
5363 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
5364 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,it
5366 real(kind=8) :: sig,fac,escloci0,escloci1,esclocbi0,dersc12,&
5367 esclocbi1,chuju,esclocbi,dersc02,dersc01,ss,ssd
5369 ! Calculate the contributions to both Gaussian lobes.
5370 ! 6/6/97 - Deform the Gaussians using the factor of 1/(1+time)
5371 ! The "polynomial part" of the "standard deviation" of this part of
5375 sig=sig*thet_pred_mean+polthet(j,it)
5377 ! Derivative of the "interior part" of the "standard deviation of the"
5378 ! gamma-dependent Gaussian lobe in t_c.
5379 sigtc=3*polthet(3,it)
5381 sigtc=sigtc*thet_pred_mean+j*polthet(j,it)
5384 ! Set the parameters of both Gaussian lobes of the distribution.
5385 ! "Standard deviation" of the gamma-dependent Gaussian lobe (sigtc)
5386 fac=sig*sig+sigc0(it)
5389 ! Following variable (sigsqtc) is -(1/2)d[sigma(t_c)**(-2))]/dt_c
5390 sigsqtc=-4.0D0*sigcsq*sigtc
5391 ! print *,i,sig,sigtc,sigsqtc
5392 ! Following variable (sigtc) is d[sigma(t_c)]/dt_c
5393 sigtc=-sigtc/(fac*fac)
5394 ! Following variable is sigma(t_c)**(-2)
5395 sigcsq=sigcsq*sigcsq
5397 sig0inv=1.0D0/sig0i**2
5398 delthec=thetai-thet_pred_mean
5399 delthe0=thetai-theta0i
5400 term1=-0.5D0*sigcsq*delthec*delthec
5401 term2=-0.5D0*sig0inv*delthe0*delthe0
5402 ! Following fuzzy logic is to avoid underflows in dexp and subsequent INFs and
5403 ! NaNs in taking the logarithm. We extract the largest exponent which is added
5404 ! to the energy (this being the log of the distribution) at the end of energy
5405 ! term evaluation for this virtual-bond angle.
5406 if (term1.gt.term2) then
5408 term2=dexp(term2-termm)
5412 term1=dexp(term1-termm)
5415 ! The ratio between the gamma-independent and gamma-dependent lobes of
5416 ! the distribution is a Gaussian function of thet_pred_mean too.
5417 diffak=gthet(2,it)-thet_pred_mean
5418 ratak=diffak/gthet(3,it)**2
5419 ak=dexp(gthet(1,it)-0.5D0*diffak*ratak)
5420 ! Let's differentiate it in thet_pred_mean NOW.
5422 ! Now put together the distribution terms to make complete distribution.
5423 termexp=term1+ak*term2
5424 termpre=sigc+ak*sig0i
5425 ! Contribution of the bending energy from this theta is just the -log of
5426 ! the sum of the contributions from the two lobes and the pre-exponential
5427 ! factor. Simple enough, isn't it?
5428 ethetai=(-dlog(termexp)-termm+dlog(termpre))
5429 ! NOW the derivatives!!!
5430 ! 6/6/97 Take into account the deformation.
5431 E_theta=(delthec*sigcsq*term1 &
5432 +ak*delthe0*sig0inv*term2)/termexp
5433 E_tc=((sigtc+aktc*sig0i)/termpre &
5434 -((delthec*sigcsq+delthec*delthec*sigsqtc)*term1+ &
5435 aktc*term2)/termexp)
5437 end subroutine theteng
5439 !-----------------------------------------------------------------------------
5440 subroutine ebend(etheta,ethetacnstr)
5442 ! Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
5443 ! angles gamma and its derivatives in consecutive thetas and gammas.
5444 ! ab initio-derived potentials from
5445 ! Kozlowska et al., J. Phys.: Condens. Matter 19 (2007) 285203
5447 ! implicit real*8 (a-h,o-z)
5448 ! include 'DIMENSIONS'
5449 ! include 'COMMON.LOCAL'
5450 ! include 'COMMON.GEO'
5451 ! include 'COMMON.INTERACT'
5452 ! include 'COMMON.DERIV'
5453 ! include 'COMMON.VAR'
5454 ! include 'COMMON.CHAIN'
5455 ! include 'COMMON.IOUNITS'
5456 ! include 'COMMON.NAMES'
5457 ! include 'COMMON.FFIELD'
5458 ! include 'COMMON.CONTROL'
5459 real(kind=8),dimension(nntheterm) :: coskt,sinkt !mmaxtheterm
5460 real(kind=8),dimension(nsingle) :: cosph1,sinph1,cosph2,sinph2 !maxsingle
5461 real(kind=8),dimension(ndouble,ndouble) :: cosph1ph2,sinph1ph2 !maxdouble,maxdouble
5462 logical :: lprn=.false., lprn1=.false.
5464 integer :: i,k,iblock,ityp1,ityp2,ityp3,l,m
5465 real(kind=8) :: dethetai,dephii,dephii1,theti2,phii,phii1,ethetai
5466 real(kind=8) :: aux,etheta,ccl,ssl,scl,csl,ethetacnstr
5467 ! local variables for constrains
5468 real(kind=8) :: difi,thetiii
5472 do i=ithet_start,ithet_end
5473 if (itype(i-1,1).eq.ntyp1) cycle
5474 if (itype(i-2,1).eq.ntyp1.or.itype(i,1).eq.ntyp1) cycle
5475 if (iabs(itype(i+1,1)).eq.20) iblock=2
5476 if (iabs(itype(i+1,1)).ne.20) iblock=1
5480 theti2=0.5d0*theta(i)
5481 ityp2=ithetyp((itype(i-1,1)))
5483 coskt(k)=dcos(k*theti2)
5484 sinkt(k)=dsin(k*theti2)
5486 if (i.gt.3 .and. itype(max0(i-3,1),1).ne.ntyp1) then
5489 if (phii.ne.phii) phii=150.0
5493 ityp1=ithetyp((itype(i-2,1)))
5494 ! propagation of chirality for glycine type
5496 cosph1(k)=dcos(k*phii)
5497 sinph1(k)=dsin(k*phii)
5501 ityp1=ithetyp(itype(i-2,1))
5507 if (i.lt.nres .and. itype(i+1,1).ne.ntyp1) then
5510 if (phii1.ne.phii1) phii1=150.0
5515 ityp3=ithetyp((itype(i,1)))
5517 cosph2(k)=dcos(k*phii1)
5518 sinph2(k)=dsin(k*phii1)
5522 ityp3=ithetyp(itype(i,1))
5528 ethetai=aa0thet(ityp1,ityp2,ityp3,iblock)
5531 ccl=cosph1(l)*cosph2(k-l)
5532 ssl=sinph1(l)*sinph2(k-l)
5533 scl=sinph1(l)*cosph2(k-l)
5534 csl=cosph1(l)*sinph2(k-l)
5535 cosph1ph2(l,k)=ccl-ssl
5536 cosph1ph2(k,l)=ccl+ssl
5537 sinph1ph2(l,k)=scl+csl
5538 sinph1ph2(k,l)=scl-csl
5542 write (iout,*) "i",i," ityp1",ityp1," ityp2",ityp2,&
5543 " ityp3",ityp3," theti2",theti2," phii",phii," phii1",phii1
5544 write (iout,*) "coskt and sinkt"
5546 write (iout,*) k,coskt(k),sinkt(k)
5550 ethetai=ethetai+aathet(k,ityp1,ityp2,ityp3,iblock)*sinkt(k)
5551 dethetai=dethetai+0.5d0*k*aathet(k,ityp1,ityp2,ityp3,iblock) &
5554 write (iout,*) "k",k,&
5555 "aathet",aathet(k,ityp1,ityp2,ityp3,iblock),&
5559 write (iout,*) "cosph and sinph"
5561 write (iout,*) k,cosph1(k),sinph1(k),cosph2(k),sinph2(k)
5563 write (iout,*) "cosph1ph2 and sinph2ph2"
5566 write (iout,*) l,k,cosph1ph2(l,k),cosph1ph2(k,l),&
5567 sinph1ph2(l,k),sinph1ph2(k,l)
5570 write(iout,*) "ethetai",ethetai
5574 aux=bbthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph1(k) &
5575 +ccthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph1(k) &
5576 +ddthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph2(k) &
5577 +eethet(k,m,ityp1,ityp2,ityp3,iblock)*sinph2(k)
5578 ethetai=ethetai+sinkt(m)*aux
5579 dethetai=dethetai+0.5d0*m*aux*coskt(m)
5580 dephii=dephii+k*sinkt(m)* &
5581 (ccthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph1(k)- &
5582 bbthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph1(k))
5583 dephii1=dephii1+k*sinkt(m)* &
5584 (eethet(k,m,ityp1,ityp2,ityp3,iblock)*cosph2(k)- &
5585 ddthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph2(k))
5587 write (iout,*) "m",m," k",k," bbthet", &
5588 bbthet(k,m,ityp1,ityp2,ityp3,iblock)," ccthet", &
5589 ccthet(k,m,ityp1,ityp2,ityp3,iblock)," ddthet", &
5590 ddthet(k,m,ityp1,ityp2,ityp3,iblock)," eethet", &
5591 eethet(k,m,ityp1,ityp2,ityp3,iblock)," ethetai",ethetai
5595 write(iout,*) "ethetai",ethetai
5599 aux=ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)+ &
5600 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l)+ &
5601 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)+ &
5602 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)
5603 ethetai=ethetai+sinkt(m)*aux
5604 dethetai=dethetai+0.5d0*m*coskt(m)*aux
5605 dephii=dephii+l*sinkt(m)* &
5606 (-ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)- &
5607 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)+ &
5608 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)+ &
5609 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l))
5610 dephii1=dephii1+(k-l)*sinkt(m)* &
5611 (-ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)+ &
5612 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)+ &
5613 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)- &
5614 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l))
5616 write (iout,*) "m",m," k",k," l",l," ffthet",&
5617 ffthet(l,k,m,ityp1,ityp2,ityp3,iblock),&
5618 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)," ggthet",&
5619 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock),&
5620 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock),&
5622 write (iout,*) cosph1ph2(l,k)*sinkt(m),&
5623 cosph1ph2(k,l)*sinkt(m),&
5624 sinph1ph2(l,k)*sinkt(m),sinph1ph2(k,l)*sinkt(m)
5632 write (iout,'(i2,3f8.1,9h ethetai ,f10.5)') &
5633 i,theta(i)*rad2deg,phii*rad2deg,&
5634 phii1*rad2deg,ethetai
5636 etheta=etheta+ethetai
5637 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
5639 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*dephii
5640 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*dephii1
5641 gloc(nphi+i-2,icg)=wang*dethetai
5643 !-----------thete constrains
5644 ! if (tor_mode.ne.2) then
5646 !C print *,ithetaconstr_start,ithetaconstr_end,"TU"
5647 do i=ithetaconstr_start,ithetaconstr_end
5648 itheta=itheta_constr(i)
5649 thetiii=theta(itheta)
5650 difi=pinorm(thetiii-theta_constr0(i))
5651 if (difi.gt.theta_drange(i)) then
5652 difi=difi-theta_drange(i)
5653 ethetacnstr=ethetacnstr+0.25d0*for_thet_constr(i)*difi**4
5654 gloc(itheta+nphi-2,icg)=gloc(itheta+nphi-2,icg) &
5655 +for_thet_constr(i)*difi**3
5656 else if (difi.lt.-drange(i)) then
5658 ethetacnstr=ethetacnstr+0.25d0*for_thet_constr(i)*difi**4
5659 gloc(itheta+nphi-2,icg)=gloc(itheta+nphi-2,icg) &
5660 +for_thet_constr(i)*difi**3
5664 if (energy_dec) then
5665 write (iout,'(a6,2i5,4f8.3,2e14.5)') "ethetc", &
5666 i,itheta,rad2deg*thetiii, &
5667 rad2deg*theta_constr0(i), rad2deg*theta_drange(i), &
5668 rad2deg*difi,0.25d0*for_thet_constr(i)*difi**4, &
5669 gloc(itheta+nphi-2,icg)
5675 end subroutine ebend
5678 !-----------------------------------------------------------------------------
5679 subroutine esc(escloc)
5680 ! Calculate the local energy of a side chain and its derivatives in the
5681 ! corresponding virtual-bond valence angles THETA and the spherical angles
5685 ! implicit real*8 (a-h,o-z)
5686 ! include 'DIMENSIONS'
5687 ! include 'COMMON.GEO'
5688 ! include 'COMMON.LOCAL'
5689 ! include 'COMMON.VAR'
5690 ! include 'COMMON.INTERACT'
5691 ! include 'COMMON.DERIV'
5692 ! include 'COMMON.CHAIN'
5693 ! include 'COMMON.IOUNITS'
5694 ! include 'COMMON.NAMES'
5695 ! include 'COMMON.FFIELD'
5696 ! include 'COMMON.CONTROL'
5697 real(kind=8),dimension(3) :: x,dersc,xemp,dersc0,dersc1,&
5698 ddersc0,ddummy,xtemp,temp
5699 !el real(kind=8) :: time11,time12,time112,theti
5700 real(kind=8) :: escloc,delta
5701 !el integer :: it,nlobit
5702 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
5705 real(kind=8) :: escloci0,escloci1,escloci,esclocbi0,&
5706 dersc12,esclocbi1,chuju,esclocbi,dersc02,dersc01,ss,ssd
5709 ! write (iout,'(a)') 'ESC'
5710 do i=loc_start,loc_end
5712 if (it.eq.ntyp1) cycle
5713 if (it.eq.10) goto 1
5714 nlobit=nlob(iabs(it))
5715 ! print *,'i=',i,' it=',it,' nlobit=',nlobit
5716 ! write (iout,*) 'i=',i,' ssa=',ssa,' ssad=',ssad
5717 theti=theta(i+1)-pipol
5722 if (x(2).gt.pi-delta) then
5726 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
5728 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
5729 call spline1(x(2),pi-delta,delta,escloci0,escloci1,dersc0(2),&
5731 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),&
5732 ddersc0(1),dersc(1))
5733 call spline2(x(2),pi-delta,delta,dersc0(3),dersc1(3),&
5734 ddersc0(3),dersc(3))
5736 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
5738 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
5739 call spline1(x(2),pi-delta,delta,esclocbi0,esclocbi1,&
5740 dersc0(2),esclocbi,dersc02)
5741 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),&
5743 call splinthet(x(2),0.5d0*delta,ss,ssd)
5748 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
5750 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
5751 ! write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
5753 escloci=ss*escloci+(1.0d0-ss)*esclocbi
5755 ! write (iout,*) escloci
5756 else if (x(2).lt.delta) then
5760 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
5762 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
5763 call spline1(x(2),delta,-delta,escloci0,escloci1,dersc0(2),&
5765 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),&
5766 ddersc0(1),dersc(1))
5767 call spline2(x(2),delta,-delta,dersc0(3),dersc1(3),&
5768 ddersc0(3),dersc(3))
5770 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
5772 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
5773 call spline1(x(2),delta,-delta,esclocbi0,esclocbi1,&
5774 dersc0(2),esclocbi,dersc02)
5775 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),&
5780 call splinthet(x(2),0.5d0*delta,ss,ssd)
5782 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
5784 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
5785 ! write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
5787 escloci=ss*escloci+(1.0d0-ss)*esclocbi
5788 ! write (iout,*) escloci
5790 call enesc(x,escloci,dersc,ddummy,.false.)
5793 escloc=escloc+escloci
5794 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
5796 ! write (iout,*) 'i=',i,' escloci=',escloci,' dersc=',dersc
5798 gloc(nphi+i-1,icg)=gloc(nphi+i-1,icg)+ &
5800 gloc(ialph(i,1),icg)=wscloc*dersc(2)
5801 gloc(ialph(i,1)+nside,icg)=wscloc*dersc(3)
5806 !-----------------------------------------------------------------------------
5807 subroutine enesc(x,escloci,dersc,ddersc,mixed)
5810 ! implicit real*8 (a-h,o-z)
5811 ! include 'DIMENSIONS'
5812 ! include 'COMMON.GEO'
5813 ! include 'COMMON.LOCAL'
5814 ! include 'COMMON.IOUNITS'
5815 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
5816 real(kind=8),dimension(3) :: x,z,dersc,ddersc
5817 real(kind=8),dimension(3,nlobit,-1:1) :: Ax !(3,maxlob,-1:1)
5818 real(kind=8),dimension(nlobit,-1:1) :: contr !(maxlob,-1:1)
5819 real(kind=8) :: escloci
5822 integer :: j,iii,l,k !el,it,nlobit
5823 real(kind=8) :: escloc_i,x3,Axk,expfac,emin !el,theti,&
5824 !el time11,time12,time112
5825 ! write (iout,*) 'it=',it,' nlobit=',nlobit
5829 if (mixed) ddersc(j)=0.0d0
5833 ! Because of periodicity of the dependence of the SC energy in omega we have
5834 ! to add up the contributions from x(3)-2*pi, x(3), and x(3+2*pi).
5835 ! To avoid underflows, first compute & store the exponents.
5843 z(k)=x(k)-censc(k,j,it)
5848 Axk=Axk+gaussc(l,k,j,it)*z(l)
5854 expfac=expfac+Ax(k,j,iii)*z(k)
5862 ! As in the case of ebend, we want to avoid underflows in exponentiation and
5863 ! subsequent NaNs and INFs in energy calculation.
5864 ! Find the largest exponent
5868 if (emin.gt.contr(j,iii)) emin=contr(j,iii)
5872 !d print *,'it=',it,' emin=',emin
5874 ! Compute the contribution to SC energy and derivatives
5879 adexp=bsc(j,iabs(it))-0.5D0*contr(j,iii)+emin
5880 if(adexp.ne.adexp) adexp=1.0
5883 expfac=dexp(bsc(j,iabs(it))-0.5D0*contr(j,iii)+emin)
5885 !d print *,'j=',j,' expfac=',expfac
5886 escloc_i=escloc_i+expfac
5888 dersc(k)=dersc(k)+Ax(k,j,iii)*expfac
5892 ddersc(k)=ddersc(k)+(-Ax(2,j,iii)*Ax(k,j,iii) &
5893 +gaussc(k,2,j,it))*expfac
5900 dersc(1)=dersc(1)/cos(theti)**2
5901 ddersc(1)=ddersc(1)/cos(theti)**2
5904 escloci=-(dlog(escloc_i)-emin)
5906 dersc(j)=dersc(j)/escloc_i
5910 ddersc(j)=(ddersc(j)/escloc_i+dersc(2)*dersc(j))
5914 end subroutine enesc
5915 !-----------------------------------------------------------------------------
5916 subroutine enesc_bound(x,escloci,dersc,dersc12,mixed)
5919 ! implicit real*8 (a-h,o-z)
5920 ! include 'DIMENSIONS'
5921 ! include 'COMMON.GEO'
5922 ! include 'COMMON.LOCAL'
5923 ! include 'COMMON.IOUNITS'
5924 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
5925 real(kind=8),dimension(3) :: x,z,dersc
5926 real(kind=8),dimension(3,nlobit) :: Ax !(3,maxlob)
5927 real(kind=8),dimension(nlobit) :: contr !(maxlob)
5928 real(kind=8) :: escloci,dersc12,emin
5931 integer :: j,k,l !el,it,nlobit
5932 real(kind=8) :: escloc_i,Axk,expfac !el,time11,time12,time112,theti
5942 z(k)=x(k)-censc(k,j,it)
5948 Axk=Axk+gaussc(l,k,j,it)*z(l)
5954 expfac=expfac+Ax(k,j)*z(k)
5959 ! As in the case of ebend, we want to avoid underflows in exponentiation and
5960 ! subsequent NaNs and INFs in energy calculation.
5961 ! Find the largest exponent
5964 if (emin.gt.contr(j)) emin=contr(j)
5968 ! Compute the contribution to SC energy and derivatives
5972 expfac=dexp(bsc(j,iabs(it))-0.5D0*contr(j)+emin)
5973 escloc_i=escloc_i+expfac
5975 dersc(k)=dersc(k)+Ax(k,j)*expfac
5977 if (mixed) dersc12=dersc12+(-Ax(2,j)*Ax(1,j) &
5978 +gaussc(1,2,j,it))*expfac
5982 dersc(1)=dersc(1)/cos(theti)**2
5983 dersc12=dersc12/cos(theti)**2
5984 escloci=-(dlog(escloc_i)-emin)
5986 dersc(j)=dersc(j)/escloc_i
5988 if (mixed) dersc12=(dersc12/escloc_i+dersc(2)*dersc(1))
5990 end subroutine enesc_bound
5992 !-----------------------------------------------------------------------------
5993 subroutine esc(escloc)
5994 ! Calculate the local energy of a side chain and its derivatives in the
5995 ! corresponding virtual-bond valence angles THETA and the spherical angles
5996 ! ALPHA and OMEGA derived from AM1 all-atom calculations.
5997 ! added by Urszula Kozlowska. 07/11/2007
6000 ! implicit real*8 (a-h,o-z)
6001 ! include 'DIMENSIONS'
6002 ! include 'COMMON.GEO'
6003 ! include 'COMMON.LOCAL'
6004 ! include 'COMMON.VAR'
6005 ! include 'COMMON.SCROT'
6006 ! include 'COMMON.INTERACT'
6007 ! include 'COMMON.DERIV'
6008 ! include 'COMMON.CHAIN'
6009 ! include 'COMMON.IOUNITS'
6010 ! include 'COMMON.NAMES'
6011 ! include 'COMMON.FFIELD'
6012 ! include 'COMMON.CONTROL'
6013 ! include 'COMMON.VECTORS'
6014 real(kind=8),dimension(3) :: x_prime,y_prime,z_prime
6015 real(kind=8),dimension(65) :: x
6016 real(kind=8) :: sumene,dsc_i,dp2_i,xx,yy,zz,sumene1,sumene2,sumene3,&
6017 sumene4,s1,s1_6,s2,s2_6,de_dxx,de_dyy,de_dzz,de_dt
6018 real(kind=8) :: s1_t,s1_6_t,s2_t,s2_6_t
6019 real(kind=8),dimension(3) :: dXX_Ci1,dYY_Ci1,dZZ_Ci1,dXX_Ci,dYY_Ci,&
6020 dZZ_Ci,dXX_XYZ,dYY_XYZ,dZZ_XYZ,dt_dCi,dt_dCi1
6022 integer :: i,j,k !el,it,nlobit
6023 real(kind=8) :: cosfac2,sinfac2,cosfac,sinfac,escloc,delta
6024 !el real(kind=8) :: time11,time12,time112,theti
6025 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
6026 real(kind=8) :: dscp1,dscp2,pom_s1,pom_s16,pom_s2,pom_s26,&
6027 pom,pom_dx,pom_dy,pom_dt1,pom_dt2,pom1,pom2,&
6028 sumene1x,sumene2x,sumene3x,sumene4x,&
6029 sumene1y,sumene2y,sumene3y,sumene4y,cossc,cossc1,&
6032 real(kind=8) :: aincr,xxsave,sumenep,de_dxx_num,yysave,&
6033 de_dyy_num,zzsave,de_dzz_num,costsave,sintsave,&
6036 ! if (.not.allocated(gsclocx)) allocate(gsclocx(3,nres)) !(3,maxres)
6040 do i=loc_start,loc_end
6041 if (itype(i,1).eq.ntyp1) cycle
6042 costtab(i+1) =dcos(theta(i+1))
6043 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
6044 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
6045 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
6046 cosfac2=0.5d0/(1.0d0+costtab(i+1))
6047 cosfac=dsqrt(cosfac2)
6048 sinfac2=0.5d0/(1.0d0-costtab(i+1))
6049 sinfac=dsqrt(sinfac2)
6051 if (it.eq.10) goto 1
6053 ! Compute the axes of tghe local cartesian coordinates system; store in
6054 ! x_prime, y_prime and z_prime
6061 ! write(2,*) "dc_norm", dc_norm(1,i+nres),dc_norm(2,i+nres),
6062 ! & dc_norm(3,i+nres)
6064 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
6065 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
6068 z_prime(j) = -uz(j,i-1)*dsign(1.0d0,dfloat(itype(i,1)))
6071 ! write (2,*) "x_prime",(x_prime(j),j=1,3)
6072 ! write (2,*) "y_prime",(y_prime(j),j=1,3)
6073 ! write (2,*) "z_prime",(z_prime(j),j=1,3)
6074 ! write (2,*) "xx",scalar(x_prime(1),x_prime(1)),
6075 ! & " xy",scalar(x_prime(1),y_prime(1)),
6076 ! & " xz",scalar(x_prime(1),z_prime(1)),
6077 ! & " yy",scalar(y_prime(1),y_prime(1)),
6078 ! & " yz",scalar(y_prime(1),z_prime(1)),
6079 ! & " zz",scalar(z_prime(1),z_prime(1))
6081 ! Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
6082 ! to local coordinate system. Store in xx, yy, zz.
6088 xx = xx + x_prime(j)*dc_norm(j,i+nres)
6089 yy = yy + y_prime(j)*dc_norm(j,i+nres)
6090 zz = zz + z_prime(j)*dc_norm(j,i+nres)
6097 ! Compute the energy of the ith side cbain
6099 ! write (2,*) "xx",xx," yy",yy," zz",zz
6102 x(j) = sc_parmin(j,it)
6105 !c diagnostics - remove later
6107 yy1 = dsin(alph(2))*dcos(omeg(2))
6108 zz1 = -dsign(1.0,dfloat(itype(i,1)))*dsin(alph(2))*dsin(omeg(2))
6109 write(2,'(3f8.1,3f9.3,1x,3f9.3)') &
6110 alph(2)*rad2deg,omeg(2)*rad2deg,theta(3)*rad2deg,xx,yy,zz,&
6112 !," --- ", xx_w,yy_w,zz_w
6115 sumene1= x(1)+ x(2)*xx+ x(3)*yy+ x(4)*zz+ x(5)*xx**2 &
6116 + x(6)*yy**2+ x(7)*zz**2+ x(8)*xx*zz+ x(9)*xx*yy &
6118 sumene2= x(11) + x(12)*xx + x(13)*yy + x(14)*zz + x(15)*xx**2 &
6119 + x(16)*yy**2 + x(17)*zz**2 + x(18)*xx*zz + x(19)*xx*yy &
6121 sumene3= x(21) +x(22)*xx +x(23)*yy +x(24)*zz +x(25)*xx**2 &
6122 +x(26)*yy**2 +x(27)*zz**2 +x(28)*xx*zz +x(29)*xx*yy &
6123 +x(30)*yy*zz +x(31)*xx**3 +x(32)*yy**3 +x(33)*zz**3 &
6124 +x(34)*(xx**2)*yy +x(35)*(xx**2)*zz +x(36)*(yy**2)*xx &
6125 +x(37)*(yy**2)*zz +x(38)*(zz**2)*xx +x(39)*(zz**2)*yy &
6127 sumene4= x(41) +x(42)*xx +x(43)*yy +x(44)*zz +x(45)*xx**2 &
6128 +x(46)*yy**2 +x(47)*zz**2 +x(48)*xx*zz +x(49)*xx*yy &
6129 +x(50)*yy*zz +x(51)*xx**3 +x(52)*yy**3 +x(53)*zz**3 &
6130 +x(54)*(xx**2)*yy +x(55)*(xx**2)*zz +x(56)*(yy**2)*xx &
6131 +x(57)*(yy**2)*zz +x(58)*(zz**2)*xx +x(59)*(zz**2)*yy &
6133 dsc_i = 0.743d0+x(61)
6135 dscp1=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
6136 *(xx*cost2tab(i+1)+yy*sint2tab(i+1)))
6137 dscp2=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
6138 *(xx*cost2tab(i+1)-yy*sint2tab(i+1)))
6139 s1=(1+x(63))/(0.1d0 + dscp1)
6140 s1_6=(1+x(64))/(0.1d0 + dscp1**6)
6141 s2=(1+x(65))/(0.1d0 + dscp2)
6142 s2_6=(1+x(65))/(0.1d0 + dscp2**6)
6143 sumene = ( sumene3*sint2tab(i+1) + sumene1)*(s1+s1_6) &
6144 + (sumene4*cost2tab(i+1) +sumene2)*(s2+s2_6)
6145 ! write(2,'(i2," sumene",7f9.3)') i,sumene1,sumene2,sumene3,
6147 ! & dscp1,dscp2,sumene
6148 ! sumene = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6149 escloc = escloc + sumene
6150 ! write (2,*) "i",i," escloc",sumene,escloc,it,itype(i,1)
6155 ! This section to check the numerical derivatives of the energy of ith side
6156 ! chain in xx, yy, zz, and theta. Use the -DDEBUG compiler option or insert
6157 ! #define DEBUG in the code to turn it on.
6159 write (2,*) "sumene =",sumene
6163 write (2,*) xx,yy,zz
6164 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6165 de_dxx_num=(sumenep-sumene)/aincr
6167 write (2,*) "xx+ sumene from enesc=",sumenep
6170 write (2,*) xx,yy,zz
6171 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6172 de_dyy_num=(sumenep-sumene)/aincr
6174 write (2,*) "yy+ sumene from enesc=",sumenep
6177 write (2,*) xx,yy,zz
6178 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6179 de_dzz_num=(sumenep-sumene)/aincr
6181 write (2,*) "zz+ sumene from enesc=",sumenep
6182 costsave=cost2tab(i+1)
6183 sintsave=sint2tab(i+1)
6184 cost2tab(i+1)=dcos(0.5d0*(theta(i+1)+aincr))
6185 sint2tab(i+1)=dsin(0.5d0*(theta(i+1)+aincr))
6186 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6187 de_dt_num=(sumenep-sumene)/aincr
6188 write (2,*) " t+ sumene from enesc=",sumenep
6189 cost2tab(i+1)=costsave
6190 sint2tab(i+1)=sintsave
6191 ! End of diagnostics section.
6194 ! Compute the gradient of esc
6196 ! zz=zz*dsign(1.0,dfloat(itype(i,1)))
6197 pom_s1=(1.0d0+x(63))/(0.1d0 + dscp1)**2
6198 pom_s16=6*(1.0d0+x(64))/(0.1d0 + dscp1**6)**2
6199 pom_s2=(1.0d0+x(65))/(0.1d0 + dscp2)**2
6200 pom_s26=6*(1.0d0+x(65))/(0.1d0 + dscp2**6)**2
6201 pom_dx=dsc_i*dp2_i*cost2tab(i+1)
6202 pom_dy=dsc_i*dp2_i*sint2tab(i+1)
6203 pom_dt1=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)-yy*cost2tab(i+1))
6204 pom_dt2=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)+yy*cost2tab(i+1))
6205 pom1=(sumene3*sint2tab(i+1)+sumene1) &
6206 *(pom_s1/dscp1+pom_s16*dscp1**4)
6207 pom2=(sumene4*cost2tab(i+1)+sumene2) &
6208 *(pom_s2/dscp2+pom_s26*dscp2**4)
6209 sumene1x=x(2)+2*x(5)*xx+x(8)*zz+ x(9)*yy
6210 sumene3x=x(22)+2*x(25)*xx+x(28)*zz+x(29)*yy+3*x(31)*xx**2 &
6211 +2*x(34)*xx*yy +2*x(35)*xx*zz +x(36)*(yy**2) +x(38)*(zz**2) &
6213 sumene2x=x(12)+2*x(15)*xx+x(18)*zz+ x(19)*yy
6214 sumene4x=x(42)+2*x(45)*xx +x(48)*zz +x(49)*yy +3*x(51)*xx**2 &
6215 +2*x(54)*xx*yy+2*x(55)*xx*zz+x(56)*(yy**2)+x(58)*(zz**2) &
6217 de_dxx =(sumene1x+sumene3x*sint2tab(i+1))*(s1+s1_6) &
6218 +(sumene2x+sumene4x*cost2tab(i+1))*(s2+s2_6) &
6221 write(2,*), "de_dxx = ", de_dxx,de_dxx_num,itype(i,1)
6224 sumene1y=x(3) + 2*x(6)*yy + x(9)*xx + x(10)*zz
6225 sumene3y=x(23) +2*x(26)*yy +x(29)*xx +x(30)*zz +3*x(32)*yy**2 &
6226 +x(34)*(xx**2) +2*x(36)*yy*xx +2*x(37)*yy*zz +x(39)*(zz**2) &
6228 sumene2y=x(13) + 2*x(16)*yy + x(19)*xx + x(20)*zz
6229 sumene4y=x(43)+2*x(46)*yy+x(49)*xx +x(50)*zz &
6230 +3*x(52)*yy**2+x(54)*xx**2+2*x(56)*yy*xx +2*x(57)*yy*zz &
6231 +x(59)*zz**2 +x(60)*xx*zz
6232 de_dyy =(sumene1y+sumene3y*sint2tab(i+1))*(s1+s1_6) &
6233 +(sumene2y+sumene4y*cost2tab(i+1))*(s2+s2_6) &
6236 write(2,*), "de_dyy = ", de_dyy,de_dyy_num,itype(i,1)
6239 de_dzz =(x(24) +2*x(27)*zz +x(28)*xx +x(30)*yy &
6240 +3*x(33)*zz**2 +x(35)*xx**2 +x(37)*yy**2 +2*x(38)*zz*xx &
6241 +2*x(39)*zz*yy +x(40)*xx*yy)*sint2tab(i+1)*(s1+s1_6) &
6242 +(x(4) + 2*x(7)*zz+ x(8)*xx + x(10)*yy)*(s1+s1_6) &
6243 +(x(44)+2*x(47)*zz +x(48)*xx +x(50)*yy +3*x(53)*zz**2 &
6244 +x(55)*xx**2 +x(57)*(yy**2)+2*x(58)*zz*xx +2*x(59)*zz*yy &
6245 +x(60)*xx*yy)*cost2tab(i+1)*(s2+s2_6) &
6246 + ( x(14) + 2*x(17)*zz+ x(18)*xx + x(20)*yy)*(s2+s2_6)
6248 write(2,*), "de_dzz = ", de_dzz,de_dzz_num,itype(i,1)
6251 de_dt = 0.5d0*sumene3*cost2tab(i+1)*(s1+s1_6) &
6252 -0.5d0*sumene4*sint2tab(i+1)*(s2+s2_6) &
6253 +pom1*pom_dt1+pom2*pom_dt2
6255 write(2,*), "de_dt = ", de_dt,de_dt_num,itype(i,1)
6259 cossc=scalar(dc_norm(1,i),dc_norm(1,i+nres))
6260 cossc1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
6261 cosfac2xx=cosfac2*xx
6262 sinfac2yy=sinfac2*yy
6264 dt_dCi(k) = -(dc_norm(k,i-1)+costtab(i+1)*dc_norm(k,i))* &
6266 dt_dCi1(k)= -(dc_norm(k,i)+costtab(i+1)*dc_norm(k,i-1))* &
6268 pom=(dC_norm(k,i+nres)-cossc*dC_norm(k,i))*vbld_inv(i+1)
6269 pom1=(dC_norm(k,i+nres)-cossc1*dC_norm(k,i-1))*vbld_inv(i)
6270 ! write (iout,*) "i",i," k",k," pom",pom," pom1",pom1,
6271 ! & " dt_dCi",dt_dCi(k)," dt_dCi1",dt_dCi1(k)
6272 ! write (iout,*) "dC_norm",(dC_norm(j,i),j=1,3),
6273 ! & (dC_norm(j,i-1),j=1,3)," vbld_inv",vbld_inv(i+1),vbld_inv(i)
6274 dXX_Ci(k)=pom*cosfac-dt_dCi(k)*cosfac2xx
6275 dXX_Ci1(k)=-pom1*cosfac-dt_dCi1(k)*cosfac2xx
6276 dYY_Ci(k)=pom*sinfac+dt_dCi(k)*sinfac2yy
6277 dYY_Ci1(k)=pom1*sinfac+dt_dCi1(k)*sinfac2yy
6281 dZZ_Ci(k)=dZZ_Ci(k)-uzgrad(j,k,2,i-1) &
6282 *dsign(1.0d0,dfloat(itype(i,1)))*dC_norm(j,i+nres)
6283 dZZ_Ci1(k)=dZZ_Ci1(k)-uzgrad(j,k,1,i-1) &
6284 *dsign(1.0d0,dfloat(itype(i,1)))*dC_norm(j,i+nres)
6287 dXX_XYZ(k)=vbld_inv(i+nres)*(x_prime(k)-xx*dC_norm(k,i+nres))
6288 dYY_XYZ(k)=vbld_inv(i+nres)*(y_prime(k)-yy*dC_norm(k,i+nres))
6289 dZZ_XYZ(k)=vbld_inv(i+nres)* &
6290 (z_prime(k)-zz*dC_norm(k,i+nres))
6292 dt_dCi(k) = -dt_dCi(k)/sinttab(i+1)
6293 dt_dCi1(k)= -dt_dCi1(k)/sinttab(i+1)
6297 dXX_Ctab(k,i)=dXX_Ci(k)
6298 dXX_C1tab(k,i)=dXX_Ci1(k)
6299 dYY_Ctab(k,i)=dYY_Ci(k)
6300 dYY_C1tab(k,i)=dYY_Ci1(k)
6301 dZZ_Ctab(k,i)=dZZ_Ci(k)
6302 dZZ_C1tab(k,i)=dZZ_Ci1(k)
6303 dXX_XYZtab(k,i)=dXX_XYZ(k)
6304 dYY_XYZtab(k,i)=dYY_XYZ(k)
6305 dZZ_XYZtab(k,i)=dZZ_XYZ(k)
6309 ! write (iout,*) "k",k," dxx_ci1",dxx_ci1(k)," dyy_ci1",
6310 ! & dyy_ci1(k)," dzz_ci1",dzz_ci1(k)
6311 ! write (iout,*) "k",k," dxx_ci",dxx_ci(k)," dyy_ci",
6312 ! & dyy_ci(k)," dzz_ci",dzz_ci(k)
6313 ! write (iout,*) "k",k," dt_dci",dt_dci(k)," dt_dci",
6315 ! write (iout,*) "k",k," dxx_XYZ",dxx_XYZ(k)," dyy_XYZ",
6316 ! & dyy_XYZ(k)," dzz_XYZ",dzz_XYZ(k)
6317 gscloc(k,i-1)=gscloc(k,i-1)+de_dxx*dxx_ci1(k) &
6318 +de_dyy*dyy_ci1(k)+de_dzz*dzz_ci1(k)+de_dt*dt_dCi1(k)
6319 gscloc(k,i)=gscloc(k,i)+de_dxx*dxx_Ci(k) &
6320 +de_dyy*dyy_Ci(k)+de_dzz*dzz_Ci(k)+de_dt*dt_dCi(k)
6321 gsclocx(k,i)= de_dxx*dxx_XYZ(k) &
6322 +de_dyy*dyy_XYZ(k)+de_dzz*dzz_XYZ(k)
6324 ! write(iout,*) "ENERGY GRAD = ", (gscloc(k,i-1),k=1,3),
6325 ! & (gscloc(k,i),k=1,3),(gsclocx(k,i),k=1,3)
6327 ! to check gradient call subroutine check_grad
6333 !-----------------------------------------------------------------------------
6334 real(kind=8) function enesc(x,xx,yy,zz,cost2,sint2)
6336 real(kind=8),dimension(65) :: x
6337 real(kind=8) :: xx,yy,zz,cost2,sint2,sumene1,sumene2,sumene3,&
6338 sumene4,sumene,dsc_i,dp2_i,dscp1,dscp2,s1,s1_6,s2,s2_6
6340 sumene1= x(1)+ x(2)*xx+ x(3)*yy+ x(4)*zz+ x(5)*xx**2 &
6341 + x(6)*yy**2+ x(7)*zz**2+ x(8)*xx*zz+ x(9)*xx*yy &
6343 sumene2= x(11) + x(12)*xx + x(13)*yy + x(14)*zz + x(15)*xx**2 &
6344 + x(16)*yy**2 + x(17)*zz**2 + x(18)*xx*zz + x(19)*xx*yy &
6346 sumene3= x(21) +x(22)*xx +x(23)*yy +x(24)*zz +x(25)*xx**2 &
6347 +x(26)*yy**2 +x(27)*zz**2 +x(28)*xx*zz +x(29)*xx*yy &
6348 +x(30)*yy*zz +x(31)*xx**3 +x(32)*yy**3 +x(33)*zz**3 &
6349 +x(34)*(xx**2)*yy +x(35)*(xx**2)*zz +x(36)*(yy**2)*xx &
6350 +x(37)*(yy**2)*zz +x(38)*(zz**2)*xx +x(39)*(zz**2)*yy &
6352 sumene4= x(41) +x(42)*xx +x(43)*yy +x(44)*zz +x(45)*xx**2 &
6353 +x(46)*yy**2 +x(47)*zz**2 +x(48)*xx*zz +x(49)*xx*yy &
6354 +x(50)*yy*zz +x(51)*xx**3 +x(52)*yy**3 +x(53)*zz**3 &
6355 +x(54)*(xx**2)*yy +x(55)*(xx**2)*zz +x(56)*(yy**2)*xx &
6356 +x(57)*(yy**2)*zz +x(58)*(zz**2)*xx +x(59)*(zz**2)*yy &
6358 dsc_i = 0.743d0+x(61)
6360 dscp1=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
6361 *(xx*cost2+yy*sint2))
6362 dscp2=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
6363 *(xx*cost2-yy*sint2))
6364 s1=(1+x(63))/(0.1d0 + dscp1)
6365 s1_6=(1+x(64))/(0.1d0 + dscp1**6)
6366 s2=(1+x(65))/(0.1d0 + dscp2)
6367 s2_6=(1+x(65))/(0.1d0 + dscp2**6)
6368 sumene = ( sumene3*sint2 + sumene1)*(s1+s1_6) &
6369 + (sumene4*cost2 +sumene2)*(s2+s2_6)
6374 !-----------------------------------------------------------------------------
6375 subroutine gcont(rij,r0ij,eps0ij,delta,fcont,fprimcont)
6377 ! This procedure calculates two-body contact function g(rij) and its derivative:
6380 ! g(rij) = esp0ij*(-0.9375*x+0.625*x**3-0.1875*x**5) ! -1 =< x =< 1
6383 ! where x=(rij-r0ij)/delta
6385 ! rij - interbody distance, r0ij - contact distance, eps0ij - contact energy
6388 real(kind=8) :: rij,r0ij,eps0ij,fcont,fprimcont
6389 real(kind=8) :: x,x2,x4,delta
6393 if (x.lt.-1.0D0) then
6396 else if (x.le.1.0D0) then
6399 fcont=eps0ij*(x*(-0.9375D0+0.6250D0*x2-0.1875D0*x4)+0.5D0)
6400 fprimcont=eps0ij * (-0.9375D0+1.8750D0*x2-0.9375D0*x4)/delta
6406 end subroutine gcont
6407 !-----------------------------------------------------------------------------
6408 subroutine splinthet(theti,delta,ss,ssder)
6409 ! implicit real*8 (a-h,o-z)
6410 ! include 'DIMENSIONS'
6411 ! include 'COMMON.VAR'
6412 ! include 'COMMON.GEO'
6413 real(kind=8) :: theti,delta,ss,ssder
6414 real(kind=8) :: thetup,thetlow
6417 if (theti.gt.pipol) then
6418 call gcont(theti,thetup,1.0d0,delta,ss,ssder)
6420 call gcont(-theti,-thetlow,1.0d0,delta,ss,ssder)
6424 end subroutine splinthet
6425 !-----------------------------------------------------------------------------
6426 subroutine spline1(x,x0,delta,f0,f1,fprim0,f,fprim)
6428 real(kind=8) :: x,x0,delta,f0,f1,fprim0,f,fprim
6429 real(kind=8) :: ksi,ksi2,ksi3,a1,a2,a3
6430 a1=fprim0*delta/(f1-f0)
6436 f=f0+(f1-f0)*ksi*(a1+ksi*(a2+a3*ksi))
6437 fprim=(f1-f0)/delta*(a1+ksi*(2*a2+3*ksi*a3))
6439 end subroutine spline1
6440 !-----------------------------------------------------------------------------
6441 subroutine spline2(x,x0,delta,f0x,f1x,fprim0x,fx)
6443 real(kind=8) :: x,x0,delta,f0x,f1x,fprim0x,fx
6444 real(kind=8) :: ksi,ksi2,ksi3,a1,a2,a3
6449 a2=3*(f1x-f0x)-2*fprim0x*delta
6450 a3=fprim0x*delta-2*(f1x-f0x)
6451 fx=f0x+a1*ksi+a2*ksi2+a3*ksi3
6453 end subroutine spline2
6454 !-----------------------------------------------------------------------------
6456 !-----------------------------------------------------------------------------
6457 subroutine etor(etors,edihcnstr)
6458 ! implicit real*8 (a-h,o-z)
6459 ! include 'DIMENSIONS'
6460 ! include 'COMMON.VAR'
6461 ! include 'COMMON.GEO'
6462 ! include 'COMMON.LOCAL'
6463 ! include 'COMMON.TORSION'
6464 ! include 'COMMON.INTERACT'
6465 ! include 'COMMON.DERIV'
6466 ! include 'COMMON.CHAIN'
6467 ! include 'COMMON.NAMES'
6468 ! include 'COMMON.IOUNITS'
6469 ! include 'COMMON.FFIELD'
6470 ! include 'COMMON.TORCNSTR'
6471 ! include 'COMMON.CONTROL'
6472 real(kind=8) :: etors,edihcnstr
6476 real(kind=8) :: phii,fac,etors_ii
6478 ! Set lprn=.true. for debugging
6482 do i=iphi_start,iphi_end
6484 if (itype(i-2,1).eq.ntyp1.or. itype(i-1,1).eq.ntyp1 &
6485 .or. itype(i,1).eq.ntyp1) cycle
6486 itori=itortyp(itype(i-2,1))
6487 itori1=itortyp(itype(i-1,1))
6490 ! Proline-Proline pair is a special case...
6491 if (itori.eq.3 .and. itori1.eq.3) then
6492 if (phii.gt.-dwapi3) then
6494 fac=1.0D0/(1.0D0-cosphi)
6495 etorsi=v1(1,3,3)*fac
6496 etorsi=etorsi+etorsi
6497 etors=etors+etorsi-v1(1,3,3)
6498 if (energy_dec) etors_ii=etors_ii+etorsi-v1(1,3,3)
6499 gloci=gloci-3*fac*etorsi*dsin(3*phii)
6502 v1ij=v1(j+1,itori,itori1)
6503 v2ij=v2(j+1,itori,itori1)
6506 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
6507 if (energy_dec) etors_ii=etors_ii+ &
6508 v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
6509 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
6513 v1ij=v1(j,itori,itori1)
6514 v2ij=v2(j,itori,itori1)
6517 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
6518 if (energy_dec) etors_ii=etors_ii+ &
6519 v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
6520 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
6523 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
6526 write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)') &
6527 restyp(itype(i-2,1),1),i-2,restyp(itype(i-1,1),1),i-1,itori,itori1,&
6528 (v1(j,itori,itori1),j=1,6),(v2(j,itori,itori1),j=1,6)
6529 gloc(i-3,icg)=gloc(i-3,icg)+wtor*gloci
6530 ! write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
6532 ! 6/20/98 - dihedral angle constraints
6535 itori=idih_constr(i)
6538 if (difi.gt.drange(i)) then
6540 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
6541 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
6542 else if (difi.lt.-drange(i)) then
6544 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
6545 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
6547 ! write (iout,'(2i5,2f8.3,2e14.5)') i,itori,rad2deg*phii,
6548 ! & rad2deg*difi,0.25d0*ftors*difi**4,gloc(itori-3,icg)
6550 ! write (iout,*) 'edihcnstr',edihcnstr
6553 !-----------------------------------------------------------------------------
6554 subroutine etor_d(etors_d)
6555 real(kind=8) :: etors_d
6558 end subroutine etor_d
6560 !-----------------------------------------------------------------------------
6561 subroutine etor(etors,edihcnstr)
6562 ! implicit real*8 (a-h,o-z)
6563 ! include 'DIMENSIONS'
6564 ! include 'COMMON.VAR'
6565 ! include 'COMMON.GEO'
6566 ! include 'COMMON.LOCAL'
6567 ! include 'COMMON.TORSION'
6568 ! include 'COMMON.INTERACT'
6569 ! include 'COMMON.DERIV'
6570 ! include 'COMMON.CHAIN'
6571 ! include 'COMMON.NAMES'
6572 ! include 'COMMON.IOUNITS'
6573 ! include 'COMMON.FFIELD'
6574 ! include 'COMMON.TORCNSTR'
6575 ! include 'COMMON.CONTROL'
6576 real(kind=8) :: etors,edihcnstr
6579 integer :: i,j,iblock,itori,itori1
6580 real(kind=8) :: phii,gloci,v1ij,v2ij,cosphi,sinphi,&
6581 vl1ij,vl2ij,vl3ij,pom1,difi,etors_ii,pom
6582 ! Set lprn=.true. for debugging
6586 do i=iphi_start,iphi_end
6587 if (itype(i-2,1).eq.ntyp1 .or. itype(i-1,1).eq.ntyp1 &
6588 .or. itype(i-3,1).eq.ntyp1 &
6589 .or. itype(i,1).eq.ntyp1) cycle
6591 if (iabs(itype(i,1)).eq.20) then
6596 itori=itortyp(itype(i-2,1))
6597 itori1=itortyp(itype(i-1,1))
6600 ! Regular cosine and sine terms
6601 do j=1,nterm(itori,itori1,iblock)
6602 v1ij=v1(j,itori,itori1,iblock)
6603 v2ij=v2(j,itori,itori1,iblock)
6606 etors=etors+v1ij*cosphi+v2ij*sinphi
6607 if (energy_dec) etors_ii=etors_ii+ &
6608 v1ij*cosphi+v2ij*sinphi
6609 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
6613 ! E = SUM ----------------------------------- - v1
6614 ! [v2 cos(phi/2)+v3 sin(phi/2)]^2 + 1
6616 cosphi=dcos(0.5d0*phii)
6617 sinphi=dsin(0.5d0*phii)
6618 do j=1,nlor(itori,itori1,iblock)
6619 vl1ij=vlor1(j,itori,itori1)
6620 vl2ij=vlor2(j,itori,itori1)
6621 vl3ij=vlor3(j,itori,itori1)
6622 pom=vl2ij*cosphi+vl3ij*sinphi
6623 pom1=1.0d0/(pom*pom+1.0d0)
6624 etors=etors+vl1ij*pom1
6625 if (energy_dec) etors_ii=etors_ii+ &
6628 gloci=gloci+vl1ij*(vl3ij*cosphi-vl2ij*sinphi)*pom
6630 ! Subtract the constant term
6631 etors=etors-v0(itori,itori1,iblock)
6632 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
6633 'etor',i,etors_ii-v0(itori,itori1,iblock)
6635 write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)') &
6636 restyp(itype(i-2,1),1),i-2,restyp(itype(i-1,1),1),i-1,itori,itori1,&
6637 (v1(j,itori,itori1,iblock),j=1,6),&
6638 (v2(j,itori,itori1,iblock),j=1,6)
6639 gloc(i-3,icg)=gloc(i-3,icg)+wtor*gloci
6640 ! write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
6642 ! 6/20/98 - dihedral angle constraints
6644 ! do i=1,ndih_constr
6645 do i=idihconstr_start,idihconstr_end
6646 itori=idih_constr(i)
6648 difi=pinorm(phii-phi0(i))
6649 if (difi.gt.drange(i)) then
6651 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
6652 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
6653 else if (difi.lt.-drange(i)) then
6655 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
6656 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
6660 !d write (iout,'(2i5,4f8.3,2e14.5)') i,itori,rad2deg*phii,
6661 !d & rad2deg*phi0(i), rad2deg*drange(i),
6662 !d & rad2deg*difi,0.25d0*ftors*difi**4,gloc(itori-3,icg)
6664 !d write (iout,*) 'edihcnstr',edihcnstr
6667 !-----------------------------------------------------------------------------
6668 subroutine etor_d(etors_d)
6669 ! 6/23/01 Compute double torsional energy
6670 ! implicit real*8 (a-h,o-z)
6671 ! include 'DIMENSIONS'
6672 ! include 'COMMON.VAR'
6673 ! include 'COMMON.GEO'
6674 ! include 'COMMON.LOCAL'
6675 ! include 'COMMON.TORSION'
6676 ! include 'COMMON.INTERACT'
6677 ! include 'COMMON.DERIV'
6678 ! include 'COMMON.CHAIN'
6679 ! include 'COMMON.NAMES'
6680 ! include 'COMMON.IOUNITS'
6681 ! include 'COMMON.FFIELD'
6682 ! include 'COMMON.TORCNSTR'
6683 real(kind=8) :: etors_d,etors_d_ii
6686 integer :: i,j,k,l,itori,itori1,itori2,iblock
6687 real(kind=8) :: phii,phii1,gloci1,gloci2,&
6688 v1cij,v1sij,v2cij,v2sij,cosphi1,sinphi1,&
6689 sinphi2,cosphi2,v1cdij,v2cdij,v1sdij,v2sdij,&
6690 cosphi1p2,cosphi1m2,sinphi1p2,sinphi1m2
6691 ! Set lprn=.true. for debugging
6695 ! write(iout,*) "a tu??"
6696 do i=iphid_start,iphid_end
6698 if (itype(i-2,1).eq.ntyp1 .or. itype(i-1,1).eq.ntyp1 &
6699 .or. itype(i-3,1).eq.ntyp1 &
6700 .or. itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
6701 itori=itortyp(itype(i-2,1))
6702 itori1=itortyp(itype(i-1,1))
6703 itori2=itortyp(itype(i,1))
6709 if (iabs(itype(i+1,1)).eq.20) iblock=2
6711 ! Regular cosine and sine terms
6712 do j=1,ntermd_1(itori,itori1,itori2,iblock)
6713 v1cij=v1c(1,j,itori,itori1,itori2,iblock)
6714 v1sij=v1s(1,j,itori,itori1,itori2,iblock)
6715 v2cij=v1c(2,j,itori,itori1,itori2,iblock)
6716 v2sij=v1s(2,j,itori,itori1,itori2,iblock)
6717 cosphi1=dcos(j*phii)
6718 sinphi1=dsin(j*phii)
6719 cosphi2=dcos(j*phii1)
6720 sinphi2=dsin(j*phii1)
6721 etors_d=etors_d+v1cij*cosphi1+v1sij*sinphi1+ &
6722 v2cij*cosphi2+v2sij*sinphi2
6723 if (energy_dec) etors_d_ii=etors_d_ii+ &
6724 v1cij*cosphi1+v1sij*sinphi1+v2cij*cosphi2+v2sij*sinphi2
6725 gloci1=gloci1+j*(v1sij*cosphi1-v1cij*sinphi1)
6726 gloci2=gloci2+j*(v2sij*cosphi2-v2cij*sinphi2)
6728 do k=2,ntermd_2(itori,itori1,itori2,iblock)
6730 v1cdij = v2c(k,l,itori,itori1,itori2,iblock)
6731 v2cdij = v2c(l,k,itori,itori1,itori2,iblock)
6732 v1sdij = v2s(k,l,itori,itori1,itori2,iblock)
6733 v2sdij = v2s(l,k,itori,itori1,itori2,iblock)
6734 cosphi1p2=dcos(l*phii+(k-l)*phii1)
6735 cosphi1m2=dcos(l*phii-(k-l)*phii1)
6736 sinphi1p2=dsin(l*phii+(k-l)*phii1)
6737 sinphi1m2=dsin(l*phii-(k-l)*phii1)
6738 etors_d=etors_d+v1cdij*cosphi1p2+v2cdij*cosphi1m2+ &
6739 v1sdij*sinphi1p2+v2sdij*sinphi1m2
6740 if (energy_dec) etors_d_ii=etors_d_ii+ &
6741 v1cdij*cosphi1p2+v2cdij*cosphi1m2+ &
6742 v1sdij*sinphi1p2+v2sdij*sinphi1m2
6743 gloci1=gloci1+l*(v1sdij*cosphi1p2+v2sdij*cosphi1m2 &
6744 -v1cdij*sinphi1p2-v2cdij*sinphi1m2)
6745 gloci2=gloci2+(k-l)*(v1sdij*cosphi1p2-v2sdij*cosphi1m2 &
6746 -v1cdij*sinphi1p2+v2cdij*sinphi1m2)
6749 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
6750 'etor_d',i,etors_d_ii
6751 gloc(i-3,icg)=gloc(i-3,icg)+wtor_d*gloci1
6752 gloc(i-2,icg)=gloc(i-2,icg)+wtor_d*gloci2
6755 end subroutine etor_d
6757 !-----------------------------------------------------------------------------
6758 subroutine eback_sc_corr(esccor)
6759 ! 7/21/2007 Correlations between the backbone-local and side-chain-local
6760 ! conformational states; temporarily implemented as differences
6761 ! between UNRES torsional potentials (dependent on three types of
6762 ! residues) and the torsional potentials dependent on all 20 types
6763 ! of residues computed from AM1 energy surfaces of terminally-blocked
6764 ! amino-acid residues.
6765 ! implicit real*8 (a-h,o-z)
6766 ! include 'DIMENSIONS'
6767 ! include 'COMMON.VAR'
6768 ! include 'COMMON.GEO'
6769 ! include 'COMMON.LOCAL'
6770 ! include 'COMMON.TORSION'
6771 ! include 'COMMON.SCCOR'
6772 ! include 'COMMON.INTERACT'
6773 ! include 'COMMON.DERIV'
6774 ! include 'COMMON.CHAIN'
6775 ! include 'COMMON.NAMES'
6776 ! include 'COMMON.IOUNITS'
6777 ! include 'COMMON.FFIELD'
6778 ! include 'COMMON.CONTROL'
6779 real(kind=8) :: esccor,esccor_ii,phii,gloci,v1ij,v2ij,&
6782 integer :: i,interty,j,isccori,isccori1,intertyp
6783 ! Set lprn=.true. for debugging
6786 ! write (iout,*) "EBACK_SC_COR",itau_start,itau_end
6788 do i=itau_start,itau_end
6789 if ((itype(i-2,1).eq.ntyp1).or.(itype(i-1,1).eq.ntyp1)) cycle
6791 isccori=isccortyp(itype(i-2,1))
6792 isccori1=isccortyp(itype(i-1,1))
6794 ! write (iout,*) "EBACK_SC_COR",i,nterm_sccor(isccori,isccori1)
6796 do intertyp=1,3 !intertyp
6798 !c Added 09 May 2012 (Adasko)
6799 !c Intertyp means interaction type of backbone mainchain correlation:
6800 ! 1 = SC...Ca...Ca...Ca
6801 ! 2 = Ca...Ca...Ca...SC
6802 ! 3 = SC...Ca...Ca...SCi
6804 if (((intertyp.eq.3).and.((itype(i-2,1).eq.10).or. &
6805 (itype(i-1,1).eq.10).or.(itype(i-2,1).eq.ntyp1).or. &
6806 (itype(i-1,1).eq.ntyp1))) &
6807 .or. ((intertyp.eq.1).and.((itype(i-2,1).eq.10) &
6808 .or.(itype(i-2,1).eq.ntyp1).or.(itype(i-1,1).eq.ntyp1) &
6809 .or.(itype(i,1).eq.ntyp1))) &
6810 .or.((intertyp.eq.2).and.((itype(i-1,1).eq.10).or. &
6811 (itype(i-1,1).eq.ntyp1).or.(itype(i-2,1).eq.ntyp1).or. &
6812 (itype(i-3,1).eq.ntyp1)))) cycle
6813 if ((intertyp.eq.2).and.(i.eq.4).and.(itype(1,1).eq.ntyp1)) cycle
6814 if ((intertyp.eq.1).and.(i.eq.nres).and.(itype(nres,1).eq.ntyp1)) &
6816 do j=1,nterm_sccor(isccori,isccori1)
6817 v1ij=v1sccor(j,intertyp,isccori,isccori1)
6818 v2ij=v2sccor(j,intertyp,isccori,isccori1)
6819 cosphi=dcos(j*tauangle(intertyp,i))
6820 sinphi=dsin(j*tauangle(intertyp,i))
6821 if (energy_dec) esccor_ii=esccor_ii+v1ij*cosphi+v2ij*sinphi
6822 esccor=esccor+v1ij*cosphi+v2ij*sinphi
6823 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
6825 if (energy_dec) write (iout,'(a6,i5,i2,0pf7.3)') &
6826 'esccor',i,intertyp,esccor_ii
6827 ! write (iout,*) "EBACK_SC_COR",i,v1ij*cosphi+v2ij*sinphi,intertyp
6828 gloc_sc(intertyp,i-3,icg)=gloc_sc(intertyp,i-3,icg)+wsccor*gloci
6830 write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)') &
6831 restyp(itype(i-2,1),1),i-2,restyp(itype(i-1,1),1),i-1,isccori,isccori1,&
6832 (v1sccor(j,intertyp,isccori,isccori1),j=1,6),&
6833 (v2sccor(j,intertyp,isccori,isccori1),j=1,6)
6834 gsccor_loc(i-3)=gsccor_loc(i-3)+gloci
6839 end subroutine eback_sc_corr
6840 !-----------------------------------------------------------------------------
6841 subroutine multibody(ecorr)
6842 ! This subroutine calculates multi-body contributions to energy following
6843 ! the idea of Skolnick et al. If side chains I and J make a contact and
6844 ! at the same time side chains I+1 and J+1 make a contact, an extra
6845 ! contribution equal to sqrt(eps(i,j)*eps(i+1,j+1)) is added.
6846 ! implicit real*8 (a-h,o-z)
6847 ! include 'DIMENSIONS'
6848 ! include 'COMMON.IOUNITS'
6849 ! include 'COMMON.DERIV'
6850 ! include 'COMMON.INTERACT'
6851 ! include 'COMMON.CONTACTS'
6852 real(kind=8),dimension(3) :: gx,gx1
6854 real(kind=8) :: ecorr
6855 integer :: i,j,ishift,i1,num_conti,num_conti1,j1,jj,kk
6856 ! Set lprn=.true. for debugging
6860 write (iout,'(a)') 'Contact function values:'
6862 write (iout,'(i2,20(1x,i2,f10.5))') &
6863 i,(jcont(j,i),facont(j,i),j=1,num_cont(i))
6868 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres))
6869 ! if (.not.allocated(gradxorr)) allocate(gradxorr(3,nres))
6881 num_conti=num_cont(i)
6882 num_conti1=num_cont(i1)
6887 if (j1.eq.j+ishift .or. j1.eq.j-ishift) then
6888 !d write(iout,*)'i=',i,' j=',j,' i1=',i1,' j1=',j1,
6889 !d & ' ishift=',ishift
6890 ! Contacts I--J and I+ISHIFT--J+-ISHIFT1 occur simultaneously.
6891 ! The system gains extra energy.
6892 ecorr=ecorr+esccorr(i,j,i1,j1,jj,kk)
6893 endif ! j1==j+-ishift
6901 end subroutine multibody
6902 !-----------------------------------------------------------------------------
6903 real(kind=8) function esccorr(i,j,k,l,jj,kk)
6904 ! implicit real*8 (a-h,o-z)
6905 ! include 'DIMENSIONS'
6906 ! include 'COMMON.IOUNITS'
6907 ! include 'COMMON.DERIV'
6908 ! include 'COMMON.INTERACT'
6909 ! include 'COMMON.CONTACTS'
6910 real(kind=8),dimension(3) :: gx,gx1
6912 integer :: i,j,k,l,jj,kk,m,ll
6913 real(kind=8) :: eij,ekl
6917 !d write (iout,'(4i5,3f10.5)') i,j,k,l,eij,ekl,-eij*ekl
6918 ! Calculate the multi-body contribution to energy.
6919 ! Calculate multi-body contributions to the gradient.
6920 !d write (iout,'(2(2i3,3f10.5))')i,j,(gacont(m,jj,i),m=1,3),
6921 !d & k,l,(gacont(m,kk,k),m=1,3)
6923 gx(m) =ekl*gacont(m,jj,i)
6924 gx1(m)=eij*gacont(m,kk,k)
6925 gradxorr(m,i)=gradxorr(m,i)-gx(m)
6926 gradxorr(m,j)=gradxorr(m,j)+gx(m)
6927 gradxorr(m,k)=gradxorr(m,k)-gx1(m)
6928 gradxorr(m,l)=gradxorr(m,l)+gx1(m)
6932 gradcorr(ll,m)=gradcorr(ll,m)+gx(ll)
6937 gradcorr(ll,m)=gradcorr(ll,m)+gx1(ll)
6942 end function esccorr
6943 !-----------------------------------------------------------------------------
6944 subroutine multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
6945 ! This subroutine calculates multi-body contributions to hydrogen-bonding
6946 ! implicit real*8 (a-h,o-z)
6947 ! include 'DIMENSIONS'
6948 ! include 'COMMON.IOUNITS'
6951 ! integer :: maxconts !max_cont=maxconts =nres/4
6952 integer,parameter :: max_dim=26
6953 integer :: source,CorrelType,CorrelID,CorrelType1,CorrelID1,Error
6954 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
6955 !el real(kind=8) :: zapas(max_dim,maxconts,nfgtasks)
6956 !el common /przechowalnia/ zapas
6957 integer :: status(MPI_STATUS_SIZE)
6958 integer,dimension((nres/4)*2) :: req !maxconts*2
6959 integer :: status_array(MPI_STATUS_SIZE,(nres/4)*2),nn,ireq,ierr
6961 ! include 'COMMON.SETUP'
6962 ! include 'COMMON.FFIELD'
6963 ! include 'COMMON.DERIV'
6964 ! include 'COMMON.INTERACT'
6965 ! include 'COMMON.CONTACTS'
6966 ! include 'COMMON.CONTROL'
6967 ! include 'COMMON.LOCAL'
6968 real(kind=8),dimension(3) :: gx,gx1
6969 real(kind=8) :: time00,ecorr,ecorr5,ecorr6
6970 logical :: lprn,ldone
6972 integer :: i,j,ii,k,n_corr,n_corr1,i1,num_conti,num_conti1,&
6973 jj,jp,kk,j1,jp1,jjc,iii,nnn,iproc
6975 ! Set lprn=.true. for debugging
6979 if(.not.allocated(zapas)) allocate(zapas(max_dim,maxconts,nfgtasks))
6982 if (nfgtasks.le.1) goto 30
6984 write (iout,'(a)') 'Contact function values before RECEIVE:'
6986 write (iout,'(2i3,50(1x,i2,f5.2))') &
6987 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
6992 do i=1,ntask_cont_from
6995 do i=1,ntask_cont_to
6998 ! write (iout,*) "ntask_cont_from",ntask_cont_from," ntask_cont_to",
7000 ! Make the list of contacts to send to send to other procesors
7001 ! write (iout,*) "limits",max0(iturn4_end-1,iatel_s),iturn3_end
7003 do i=iturn3_start,iturn3_end
7004 ! write (iout,*) "make contact list turn3",i," num_cont",
7006 call add_hb_contact(i,i+2,iturn3_sent_local(1,i))
7008 do i=iturn4_start,iturn4_end
7009 ! write (iout,*) "make contact list turn4",i," num_cont",
7011 call add_hb_contact(i,i+3,iturn4_sent_local(1,i))
7015 ! write (iout,*) "make contact list longrange",i,ii," num_cont",
7017 do j=1,num_cont_hb(i)
7020 iproc=iint_sent_local(k,jjc,ii)
7021 ! write (iout,*) "i",i," j",j," k",k," jjc",jjc," iproc",iproc
7022 if (iproc.gt.0) then
7023 ncont_sent(iproc)=ncont_sent(iproc)+1
7024 nn=ncont_sent(iproc)
7026 zapas(2,nn,iproc)=jjc
7027 zapas(3,nn,iproc)=facont_hb(j,i)
7028 zapas(4,nn,iproc)=ees0p(j,i)
7029 zapas(5,nn,iproc)=ees0m(j,i)
7030 zapas(6,nn,iproc)=gacont_hbr(1,j,i)
7031 zapas(7,nn,iproc)=gacont_hbr(2,j,i)
7032 zapas(8,nn,iproc)=gacont_hbr(3,j,i)
7033 zapas(9,nn,iproc)=gacontm_hb1(1,j,i)
7034 zapas(10,nn,iproc)=gacontm_hb1(2,j,i)
7035 zapas(11,nn,iproc)=gacontm_hb1(3,j,i)
7036 zapas(12,nn,iproc)=gacontp_hb1(1,j,i)
7037 zapas(13,nn,iproc)=gacontp_hb1(2,j,i)
7038 zapas(14,nn,iproc)=gacontp_hb1(3,j,i)
7039 zapas(15,nn,iproc)=gacontm_hb2(1,j,i)
7040 zapas(16,nn,iproc)=gacontm_hb2(2,j,i)
7041 zapas(17,nn,iproc)=gacontm_hb2(3,j,i)
7042 zapas(18,nn,iproc)=gacontp_hb2(1,j,i)
7043 zapas(19,nn,iproc)=gacontp_hb2(2,j,i)
7044 zapas(20,nn,iproc)=gacontp_hb2(3,j,i)
7045 zapas(21,nn,iproc)=gacontm_hb3(1,j,i)
7046 zapas(22,nn,iproc)=gacontm_hb3(2,j,i)
7047 zapas(23,nn,iproc)=gacontm_hb3(3,j,i)
7048 zapas(24,nn,iproc)=gacontp_hb3(1,j,i)
7049 zapas(25,nn,iproc)=gacontp_hb3(2,j,i)
7050 zapas(26,nn,iproc)=gacontp_hb3(3,j,i)
7057 "Numbers of contacts to be sent to other processors",&
7058 (ncont_sent(i),i=1,ntask_cont_to)
7059 write (iout,*) "Contacts sent"
7060 do ii=1,ntask_cont_to
7062 iproc=itask_cont_to(ii)
7063 write (iout,*) nn," contacts to processor",iproc,&
7064 " of CONT_TO_COMM group"
7066 write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
7074 CorrelID1=nfgtasks+fg_rank+1
7076 ! Receive the numbers of needed contacts from other processors
7077 do ii=1,ntask_cont_from
7078 iproc=itask_cont_from(ii)
7080 call MPI_Irecv(ncont_recv(ii),1,MPI_INTEGER,iproc,CorrelType,&
7081 FG_COMM,req(ireq),IERR)
7083 ! write (iout,*) "IRECV ended"
7085 ! Send the number of contacts needed by other processors
7086 do ii=1,ntask_cont_to
7087 iproc=itask_cont_to(ii)
7089 call MPI_Isend(ncont_sent(ii),1,MPI_INTEGER,iproc,CorrelType,&
7090 FG_COMM,req(ireq),IERR)
7092 ! write (iout,*) "ISEND ended"
7093 ! write (iout,*) "number of requests (nn)",ireq
7096 call MPI_Waitall(ireq,req,status_array,ierr)
7098 ! & "Numbers of contacts to be received from other processors",
7099 ! & (ncont_recv(i),i=1,ntask_cont_from)
7103 do ii=1,ntask_cont_from
7104 iproc=itask_cont_from(ii)
7106 ! write (iout,*) "Receiving",nn," contacts from processor",iproc,
7107 ! & " of CONT_TO_COMM group"
7111 call MPI_Irecv(zapas_recv(1,1,ii),nn*max_dim,&
7112 MPI_DOUBLE_PRECISION,iproc,CorrelType1,FG_COMM,req(ireq),IERR)
7113 ! write (iout,*) "ireq,req",ireq,req(ireq)
7116 ! Send the contacts to processors that need them
7117 do ii=1,ntask_cont_to
7118 iproc=itask_cont_to(ii)
7120 ! write (iout,*) nn," contacts to processor",iproc,
7121 ! & " of CONT_TO_COMM group"
7124 call MPI_Isend(zapas(1,1,ii),nn*max_dim,MPI_DOUBLE_PRECISION,&
7125 iproc,CorrelType1,FG_COMM,req(ireq),IERR)
7126 ! write (iout,*) "ireq,req",ireq,req(ireq)
7128 ! write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
7132 ! write (iout,*) "number of requests (contacts)",ireq
7133 ! write (iout,*) "req",(req(i),i=1,4)
7136 call MPI_Waitall(ireq,req,status_array,ierr)
7137 do iii=1,ntask_cont_from
7138 iproc=itask_cont_from(iii)
7141 write (iout,*) "Received",nn," contacts from processor",iproc,&
7142 " of CONT_FROM_COMM group"
7145 write(iout,'(2f5.0,4f10.5)')(zapas_recv(j,i,iii),j=1,5)
7150 ii=zapas_recv(1,i,iii)
7151 ! Flag the received contacts to prevent double-counting
7152 jj=-zapas_recv(2,i,iii)
7153 ! write (iout,*) "iii",iii," i",i," ii",ii," jj",jj
7155 nnn=num_cont_hb(ii)+1
7158 facont_hb(nnn,ii)=zapas_recv(3,i,iii)
7159 ees0p(nnn,ii)=zapas_recv(4,i,iii)
7160 ees0m(nnn,ii)=zapas_recv(5,i,iii)
7161 gacont_hbr(1,nnn,ii)=zapas_recv(6,i,iii)
7162 gacont_hbr(2,nnn,ii)=zapas_recv(7,i,iii)
7163 gacont_hbr(3,nnn,ii)=zapas_recv(8,i,iii)
7164 gacontm_hb1(1,nnn,ii)=zapas_recv(9,i,iii)
7165 gacontm_hb1(2,nnn,ii)=zapas_recv(10,i,iii)
7166 gacontm_hb1(3,nnn,ii)=zapas_recv(11,i,iii)
7167 gacontp_hb1(1,nnn,ii)=zapas_recv(12,i,iii)
7168 gacontp_hb1(2,nnn,ii)=zapas_recv(13,i,iii)
7169 gacontp_hb1(3,nnn,ii)=zapas_recv(14,i,iii)
7170 gacontm_hb2(1,nnn,ii)=zapas_recv(15,i,iii)
7171 gacontm_hb2(2,nnn,ii)=zapas_recv(16,i,iii)
7172 gacontm_hb2(3,nnn,ii)=zapas_recv(17,i,iii)
7173 gacontp_hb2(1,nnn,ii)=zapas_recv(18,i,iii)
7174 gacontp_hb2(2,nnn,ii)=zapas_recv(19,i,iii)
7175 gacontp_hb2(3,nnn,ii)=zapas_recv(20,i,iii)
7176 gacontm_hb3(1,nnn,ii)=zapas_recv(21,i,iii)
7177 gacontm_hb3(2,nnn,ii)=zapas_recv(22,i,iii)
7178 gacontm_hb3(3,nnn,ii)=zapas_recv(23,i,iii)
7179 gacontp_hb3(1,nnn,ii)=zapas_recv(24,i,iii)
7180 gacontp_hb3(2,nnn,ii)=zapas_recv(25,i,iii)
7181 gacontp_hb3(3,nnn,ii)=zapas_recv(26,i,iii)
7186 write (iout,'(a)') 'Contact function values after receive:'
7188 write (iout,'(2i3,50(1x,i3,f5.2))') &
7189 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
7197 write (iout,'(a)') 'Contact function values:'
7199 write (iout,'(2i3,50(1x,i3,f5.2))') &
7200 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
7206 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres))
7207 ! if (.not.allocated(gradxorr)) allocate(gradxorr(3,nres))
7208 ! Remove the loop below after debugging !!!
7215 ! Calculate the local-electrostatic correlation terms
7216 do i=min0(iatel_s,iturn4_start),max0(iatel_e,iturn3_end)
7218 num_conti=num_cont_hb(i)
7219 num_conti1=num_cont_hb(i+1)
7226 ! write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,&
7227 ! ' jj=',jj,' kk=',kk,"jp=",jp,"jp1",jp1
7228 if ((j.gt.0 .and. j1.gt.0 .or. j.gt.0 .and. j1.lt.0 &
7229 .or. j.lt.0 .and. j1.gt.0) .and. &
7230 (jp1.eq.jp+1 .or. jp1.eq.jp-1)) then
7231 ! Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
7232 ! The system gains extra energy.
7233 ecorr=ecorr+ehbcorr(i,jp,i+1,jp1,jj,kk,0.72D0,0.32D0)
7234 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
7235 'ecorrh',i,j,ehbcorr(i,jp,i+1,jp1,jj,kk,0.72D0,0.32D0)
7237 else if (j1.eq.j) then
7238 ! Contacts I-J and I-(J+1) occur simultaneously.
7239 ! The system loses extra energy.
7240 ! ecorr=ecorr+ehbcorr(i,j,i+1,j,jj,kk,0.60D0,-0.40D0)
7245 ! write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
7246 ! & ' jj=',jj,' kk=',kk
7248 ! Contacts I-J and (I+1)-J occur simultaneously.
7249 ! The system loses extra energy.
7250 ! ecorr=ecorr+ehbcorr(i,j,i,j+1,jj,kk,0.60D0,-0.40D0)
7256 end subroutine multibody_hb
7257 !-----------------------------------------------------------------------------
7258 subroutine add_hb_contact(ii,jj,itask)
7259 ! implicit real*8 (a-h,o-z)
7260 ! include "DIMENSIONS"
7261 ! include "COMMON.IOUNITS"
7262 ! include "COMMON.CONTACTS"
7263 ! integer,parameter :: maxconts=nres/4
7264 integer,parameter :: max_dim=26
7265 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
7266 ! real(kind=8) :: zapas(max_dim,maxconts,nfgtasks)
7267 ! common /przechowalnia/ zapas
7268 integer :: i,j,ii,jj,iproc,nn,jjc
7269 integer,dimension(4) :: itask
7270 ! write (iout,*) "itask",itask
7273 if (iproc.gt.0) then
7274 do j=1,num_cont_hb(ii)
7276 ! write (iout,*) "i",ii," j",jj," jjc",jjc
7278 ncont_sent(iproc)=ncont_sent(iproc)+1
7279 nn=ncont_sent(iproc)
7280 zapas(1,nn,iproc)=ii
7281 zapas(2,nn,iproc)=jjc
7282 zapas(3,nn,iproc)=facont_hb(j,ii)
7283 zapas(4,nn,iproc)=ees0p(j,ii)
7284 zapas(5,nn,iproc)=ees0m(j,ii)
7285 zapas(6,nn,iproc)=gacont_hbr(1,j,ii)
7286 zapas(7,nn,iproc)=gacont_hbr(2,j,ii)
7287 zapas(8,nn,iproc)=gacont_hbr(3,j,ii)
7288 zapas(9,nn,iproc)=gacontm_hb1(1,j,ii)
7289 zapas(10,nn,iproc)=gacontm_hb1(2,j,ii)
7290 zapas(11,nn,iproc)=gacontm_hb1(3,j,ii)
7291 zapas(12,nn,iproc)=gacontp_hb1(1,j,ii)
7292 zapas(13,nn,iproc)=gacontp_hb1(2,j,ii)
7293 zapas(14,nn,iproc)=gacontp_hb1(3,j,ii)
7294 zapas(15,nn,iproc)=gacontm_hb2(1,j,ii)
7295 zapas(16,nn,iproc)=gacontm_hb2(2,j,ii)
7296 zapas(17,nn,iproc)=gacontm_hb2(3,j,ii)
7297 zapas(18,nn,iproc)=gacontp_hb2(1,j,ii)
7298 zapas(19,nn,iproc)=gacontp_hb2(2,j,ii)
7299 zapas(20,nn,iproc)=gacontp_hb2(3,j,ii)
7300 zapas(21,nn,iproc)=gacontm_hb3(1,j,ii)
7301 zapas(22,nn,iproc)=gacontm_hb3(2,j,ii)
7302 zapas(23,nn,iproc)=gacontm_hb3(3,j,ii)
7303 zapas(24,nn,iproc)=gacontp_hb3(1,j,ii)
7304 zapas(25,nn,iproc)=gacontp_hb3(2,j,ii)
7305 zapas(26,nn,iproc)=gacontp_hb3(3,j,ii)
7312 end subroutine add_hb_contact
7313 !-----------------------------------------------------------------------------
7314 subroutine multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
7315 ! This subroutine calculates multi-body contributions to hydrogen-bonding
7316 ! implicit real*8 (a-h,o-z)
7317 ! include 'DIMENSIONS'
7318 ! include 'COMMON.IOUNITS'
7319 integer,parameter :: max_dim=70
7322 ! integer :: maxconts !max_cont=maxconts=nres/4
7323 integer :: source,CorrelType,CorrelID,CorrelType1,CorrelID1,Error
7324 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks)
7325 ! real(kind=8) :: zapas(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
7326 ! common /przechowalnia/ zapas
7327 integer :: status(MPI_STATUS_SIZE),req((nres/4)*2),&
7328 status_array(MPI_STATUS_SIZE,(nres/4)*2),jjc,iproc,ireq,nn,ind,&
7331 ! include 'COMMON.SETUP'
7332 ! include 'COMMON.FFIELD'
7333 ! include 'COMMON.DERIV'
7334 ! include 'COMMON.LOCAL'
7335 ! include 'COMMON.INTERACT'
7336 ! include 'COMMON.CONTACTS'
7337 ! include 'COMMON.CHAIN'
7338 ! include 'COMMON.CONTROL'
7339 real(kind=8),dimension(3) :: gx,gx1
7340 integer,dimension(nres) :: num_cont_hb_old
7341 logical :: lprn,ldone
7342 !EL double precision eello4,eello5,eelo6,eello_turn6
7343 !EL external eello4,eello5,eello6,eello_turn6
7345 integer :: i,ii,j,k,l,jj,kk,ll,mm,n_corr,n_corr1,num_conti,jp,&
7346 j1,jp1,i1,num_conti1
7347 real(kind=8) :: sqd1,sqd2,sred_geom,fac_prim1,fac_prim2,fprimcont
7348 real(kind=8) :: ecorr,ecorr5,ecorr6,eturn6
7350 ! Set lprn=.true. for debugging
7355 if(.not.allocated(zapas)) allocate(zapas(max_dim,maxconts,nfgtasks))
7357 num_cont_hb_old(i)=num_cont_hb(i)
7361 if (nfgtasks.le.1) goto 30
7363 write (iout,'(a)') 'Contact function values before RECEIVE:'
7365 write (iout,'(2i3,50(1x,i2,f5.2))') &
7366 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
7371 do i=1,ntask_cont_from
7374 do i=1,ntask_cont_to
7377 ! write (iout,*) "ntask_cont_from",ntask_cont_from," ntask_cont_to",
7379 ! Make the list of contacts to send to send to other procesors
7380 do i=iturn3_start,iturn3_end
7381 ! write (iout,*) "make contact list turn3",i," num_cont",
7383 call add_hb_contact_eello(i,i+2,iturn3_sent_local(1,i))
7385 do i=iturn4_start,iturn4_end
7386 ! write (iout,*) "make contact list turn4",i," num_cont",
7388 call add_hb_contact_eello(i,i+3,iturn4_sent_local(1,i))
7392 ! write (iout,*) "make contact list longrange",i,ii," num_cont",
7394 do j=1,num_cont_hb(i)
7397 iproc=iint_sent_local(k,jjc,ii)
7398 ! write (iout,*) "i",i," j",j," k",k," jjc",jjc," iproc",iproc
7399 if (iproc.ne.0) then
7400 ncont_sent(iproc)=ncont_sent(iproc)+1
7401 nn=ncont_sent(iproc)
7403 zapas(2,nn,iproc)=jjc
7404 zapas(3,nn,iproc)=d_cont(j,i)
7408 zapas(ind,nn,iproc)=grij_hb_cont(kk,j,i)
7413 zapas(ind,nn,iproc)=a_chuj(ll,kk,j,i)
7421 zapas(ind,nn,iproc)=a_chuj_der(mm,ll,kk,jj,j,i)
7432 "Numbers of contacts to be sent to other processors",&
7433 (ncont_sent(i),i=1,ntask_cont_to)
7434 write (iout,*) "Contacts sent"
7435 do ii=1,ntask_cont_to
7437 iproc=itask_cont_to(ii)
7438 write (iout,*) nn," contacts to processor",iproc,&
7439 " of CONT_TO_COMM group"
7441 write(iout,'(2f5.0,10f10.5)')(zapas(j,i,ii),j=1,10)
7449 CorrelID1=nfgtasks+fg_rank+1
7451 ! Receive the numbers of needed contacts from other processors
7452 do ii=1,ntask_cont_from
7453 iproc=itask_cont_from(ii)
7455 call MPI_Irecv(ncont_recv(ii),1,MPI_INTEGER,iproc,CorrelType,&
7456 FG_COMM,req(ireq),IERR)
7458 ! write (iout,*) "IRECV ended"
7460 ! Send the number of contacts needed by other processors
7461 do ii=1,ntask_cont_to
7462 iproc=itask_cont_to(ii)
7464 call MPI_Isend(ncont_sent(ii),1,MPI_INTEGER,iproc,CorrelType,&
7465 FG_COMM,req(ireq),IERR)
7467 ! write (iout,*) "ISEND ended"
7468 ! write (iout,*) "number of requests (nn)",ireq
7471 call MPI_Waitall(ireq,req,status_array,ierr)
7473 ! & "Numbers of contacts to be received from other processors",
7474 ! & (ncont_recv(i),i=1,ntask_cont_from)
7478 do ii=1,ntask_cont_from
7479 iproc=itask_cont_from(ii)
7481 ! write (iout,*) "Receiving",nn," contacts from processor",iproc,
7482 ! & " of CONT_TO_COMM group"
7486 call MPI_Irecv(zapas_recv(1,1,ii),nn*max_dim,&
7487 MPI_DOUBLE_PRECISION,iproc,CorrelType1,FG_COMM,req(ireq),IERR)
7488 ! write (iout,*) "ireq,req",ireq,req(ireq)
7491 ! Send the contacts to processors that need them
7492 do ii=1,ntask_cont_to
7493 iproc=itask_cont_to(ii)
7495 ! write (iout,*) nn," contacts to processor",iproc,
7496 ! & " of CONT_TO_COMM group"
7499 call MPI_Isend(zapas(1,1,ii),nn*max_dim,MPI_DOUBLE_PRECISION,&
7500 iproc,CorrelType1,FG_COMM,req(ireq),IERR)
7501 ! write (iout,*) "ireq,req",ireq,req(ireq)
7503 ! write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
7507 ! write (iout,*) "number of requests (contacts)",ireq
7508 ! write (iout,*) "req",(req(i),i=1,4)
7511 call MPI_Waitall(ireq,req,status_array,ierr)
7512 do iii=1,ntask_cont_from
7513 iproc=itask_cont_from(iii)
7516 write (iout,*) "Received",nn," contacts from processor",iproc,&
7517 " of CONT_FROM_COMM group"
7520 write(iout,'(2f5.0,10f10.5)')(zapas_recv(j,i,iii),j=1,10)
7525 ii=zapas_recv(1,i,iii)
7526 ! Flag the received contacts to prevent double-counting
7527 jj=-zapas_recv(2,i,iii)
7528 ! write (iout,*) "iii",iii," i",i," ii",ii," jj",jj
7530 nnn=num_cont_hb(ii)+1
7533 d_cont(nnn,ii)=zapas_recv(3,i,iii)
7537 grij_hb_cont(kk,nnn,ii)=zapas_recv(ind,i,iii)
7542 a_chuj(ll,kk,nnn,ii)=zapas_recv(ind,i,iii)
7550 a_chuj_der(mm,ll,kk,jj,nnn,ii)=zapas_recv(ind,i,iii)
7559 write (iout,'(a)') 'Contact function values after receive:'
7561 write (iout,'(2i3,50(1x,i3,5f6.3))') &
7562 i,num_cont_hb(i),(jcont_hb(j,i),d_cont(j,i),&
7563 ((a_chuj(ll,kk,j,i),ll=1,2),kk=1,2),j=1,num_cont_hb(i))
7570 write (iout,'(a)') 'Contact function values:'
7572 write (iout,'(2i3,50(1x,i2,5f6.3))') &
7573 i,num_cont_hb(i),(jcont_hb(j,i),d_cont(j,i),&
7574 ((a_chuj(ll,kk,j,i),ll=1,2),kk=1,2),j=1,num_cont_hb(i))
7581 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres))
7582 ! if (.not.allocated(gradxorr)) allocate(gradxorr(3,nres))
7583 ! Remove the loop below after debugging !!!
7590 ! Calculate the dipole-dipole interaction energies
7591 if (wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) then
7592 do i=iatel_s,iatel_e+1
7593 num_conti=num_cont_hb(i)
7602 ! Calculate the local-electrostatic correlation terms
7603 ! write (iout,*) "gradcorr5 in eello5 before loop"
7605 ! write (iout,'(i5,3f10.5)')
7606 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
7608 do i=min0(iatel_s,iturn4_start),max0(iatel_e+1,iturn3_end+1)
7609 ! write (iout,*) "corr loop i",i
7611 num_conti=num_cont_hb(i)
7612 num_conti1=num_cont_hb(i+1)
7619 ! write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
7620 ! & ' jj=',jj,' kk=',kk
7621 ! if (j1.eq.j+1 .or. j1.eq.j-1) then
7622 if ((j.gt.0 .and. j1.gt.0 .or. j.gt.0 .and. j1.lt.0 &
7623 .or. j.lt.0 .and. j1.gt.0) .and. &
7624 (jp1.eq.jp+1 .or. jp1.eq.jp-1)) then
7625 ! Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
7626 ! The system gains extra energy.
7628 sqd1=dsqrt(d_cont(jj,i))
7629 sqd2=dsqrt(d_cont(kk,i1))
7630 sred_geom = sqd1*sqd2
7631 IF (sred_geom.lt.cutoff_corr) THEN
7632 call gcont(sred_geom,r0_corr,1.0D0,delt_corr,&
7634 !d write (iout,*) 'i=',i,' j=',jp,' i1=',i1,' j1=',jp1,
7635 !d & ' jj=',jj,' kk=',kk
7636 fac_prim1=0.5d0*sqd2/sqd1*fprimcont
7637 fac_prim2=0.5d0*sqd1/sqd2*fprimcont
7639 g_contij(l,1)=fac_prim1*grij_hb_cont(l,jj,i)
7640 g_contij(l,2)=fac_prim2*grij_hb_cont(l,kk,i1)
7643 !d write (iout,*) 'sred_geom=',sred_geom,
7644 !d & ' ekont=',ekont,' fprim=',fprimcont,
7645 !d & ' fac_prim1',fac_prim1,' fac_prim2',fac_prim2
7646 !d write (iout,*) "g_contij",g_contij
7647 !d write (iout,*) "grij_hb_cont i",grij_hb_cont(:,jj,i)
7648 !d write (iout,*) "grij_hb_cont i1",grij_hb_cont(:,jj,i1)
7649 call calc_eello(i,jp,i+1,jp1,jj,kk)
7650 if (wcorr4.gt.0.0d0) &
7651 ecorr=ecorr+eello4(i,jp,i+1,jp1,jj,kk)
7652 if (energy_dec.and.wcorr4.gt.0.0d0) &
7653 write (iout,'(a6,4i5,0pf7.3)') &
7654 'ecorr4',i,j,i+1,j1,eello4(i,jp,i+1,jp1,jj,kk)
7655 ! write (iout,*) "gradcorr5 before eello5"
7657 ! write (iout,'(i5,3f10.5)')
7658 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
7660 if (wcorr5.gt.0.0d0) &
7661 ecorr5=ecorr5+eello5(i,jp,i+1,jp1,jj,kk)
7662 ! write (iout,*) "gradcorr5 after eello5"
7664 ! write (iout,'(i5,3f10.5)')
7665 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
7667 if (energy_dec.and.wcorr5.gt.0.0d0) &
7668 write (iout,'(a6,4i5,0pf7.3)') &
7669 'ecorr5',i,j,i+1,j1,eello5(i,jp,i+1,jp1,jj,kk)
7670 !d write(2,*)'wcorr6',wcorr6,' wturn6',wturn6
7671 !d write(2,*)'ijkl',i,jp,i+1,jp1
7672 if (wcorr6.gt.0.0d0 .and. (jp.ne.i+4 .or. jp1.ne.i+3 &
7673 .or. wturn6.eq.0.0d0))then
7674 !d write (iout,*) '******ecorr6: i,j,i+1,j1',i,j,i+1,j1
7675 ecorr6=ecorr6+eello6(i,jp,i+1,jp1,jj,kk)
7676 if (energy_dec) write (iout,'(a6,4i5,0pf7.3)') &
7677 'ecorr6',i,j,i+1,j1,eello6(i,jp,i+1,jp1,jj,kk)
7678 !d write (iout,*) 'ecorr',ecorr,' ecorr5=',ecorr5,
7679 !d & 'ecorr6=',ecorr6
7680 !d write (iout,'(4e15.5)') sred_geom,
7681 !d & dabs(eello4(i,jp,i+1,jp1,jj,kk)),
7682 !d & dabs(eello5(i,jp,i+1,jp1,jj,kk)),
7683 !d & dabs(eello6(i,jp,i+1,jp1,jj,kk))
7684 else if (wturn6.gt.0.0d0 &
7685 .and. (jp.eq.i+4 .and. jp1.eq.i+3)) then
7686 !d write (iout,*) '******eturn6: i,j,i+1,j1',i,jip,i+1,jp1
7687 eturn6=eturn6+eello_turn6(i,jj,kk)
7688 if (energy_dec) write (iout,'(a6,4i5,0pf7.3)') &
7689 'eturn6',i,j,i+1,j1,eello_turn6(i,jj,kk)
7690 !d write (2,*) 'multibody_eello:eturn6',eturn6
7699 num_cont_hb(i)=num_cont_hb_old(i)
7701 ! write (iout,*) "gradcorr5 in eello5"
7703 ! write (iout,'(i5,3f10.5)')
7704 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
7707 end subroutine multibody_eello
7708 !-----------------------------------------------------------------------------
7709 subroutine add_hb_contact_eello(ii,jj,itask)
7710 ! implicit real*8 (a-h,o-z)
7711 ! include "DIMENSIONS"
7712 ! include "COMMON.IOUNITS"
7713 ! include "COMMON.CONTACTS"
7714 ! integer,parameter :: maxconts=nres/4
7715 integer,parameter :: max_dim=70
7716 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks)
7717 ! real(kind=8) :: zapas(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
7718 ! common /przechowalnia/ zapas
7720 integer :: i,j,ii,jj,iproc,nn,ind,jjc,kk,ll,mm
7721 integer,dimension(4) ::itask
7722 ! write (iout,*) "itask",itask
7725 if (iproc.gt.0) then
7726 do j=1,num_cont_hb(ii)
7728 ! write (iout,*) "send turns i",ii," j",jj," jjc",jjc
7730 ncont_sent(iproc)=ncont_sent(iproc)+1
7731 nn=ncont_sent(iproc)
7732 zapas(1,nn,iproc)=ii
7733 zapas(2,nn,iproc)=jjc
7734 zapas(3,nn,iproc)=d_cont(j,ii)
7738 zapas(ind,nn,iproc)=grij_hb_cont(kk,j,ii)
7743 zapas(ind,nn,iproc)=a_chuj(ll,kk,j,ii)
7751 zapas(ind,nn,iproc)=a_chuj_der(mm,ll,kk,jj,j,ii)
7762 end subroutine add_hb_contact_eello
7763 !-----------------------------------------------------------------------------
7764 real(kind=8) function ehbcorr(i,j,k,l,jj,kk,coeffp,coeffm)
7765 ! implicit real*8 (a-h,o-z)
7766 ! include 'DIMENSIONS'
7767 ! include 'COMMON.IOUNITS'
7768 ! include 'COMMON.DERIV'
7769 ! include 'COMMON.INTERACT'
7770 ! include 'COMMON.CONTACTS'
7771 real(kind=8),dimension(3) :: gx,gx1
7774 integer :: i,j,k,l,jj,kk,ll,ilist,m, iresshield
7775 real(kind=8) :: coeffp,coeffm,eij,ekl,ees0pij,ees0pkl,ees0mij,&
7776 ees0mkl,ees,coeffpees0pij,coeffmees0mij,&
7777 coeffpees0pkl,coeffmees0mkl,gradlongij,gradlongkl, &
7788 ees=-(coeffp*ees0pij*ees0pkl+coeffm*ees0mij*ees0mkl)
7789 !d ees=-(coeffp*ees0pkl+coeffm*ees0mkl)
7790 ! Following 4 lines for diagnostics.
7795 ! write (iout,'(2(a,2i3,a,f10.5,a,2f10.5),a,f10.5,a,$)')
7796 ! & 'Contacts ',i,j,
7797 ! & ' eij',eij,' eesij',ees0pij,ees0mij,' and ',k,l
7798 ! & ,' fcont ',ekl,' eeskl',ees0pkl,ees0mkl,' energy=',ekont*ees,
7800 ! Calculate the multi-body contribution to energy.
7801 ! ecorr=ecorr+ekont*ees
7802 ! Calculate multi-body contributions to the gradient.
7803 coeffpees0pij=coeffp*ees0pij
7804 coeffmees0mij=coeffm*ees0mij
7805 coeffpees0pkl=coeffp*ees0pkl
7806 coeffmees0mkl=coeffm*ees0mkl
7808 !grad ghalfi=ees*ekl*gacont_hbr(ll,jj,i)
7809 gradcorr(ll,i)=gradcorr(ll,i) & !+0.5d0*ghalfi
7810 -ekont*(coeffpees0pkl*gacontp_hb1(ll,jj,i)+ &
7811 coeffmees0mkl*gacontm_hb1(ll,jj,i))
7812 gradcorr(ll,j)=gradcorr(ll,j) & !+0.5d0*ghalfi
7813 -ekont*(coeffpees0pkl*gacontp_hb2(ll,jj,i)+ &
7814 coeffmees0mkl*gacontm_hb2(ll,jj,i))
7815 !grad ghalfk=ees*eij*gacont_hbr(ll,kk,k)
7816 gradcorr(ll,k)=gradcorr(ll,k) & !+0.5d0*ghalfk
7817 -ekont*(coeffpees0pij*gacontp_hb1(ll,kk,k)+&
7818 coeffmees0mij*gacontm_hb1(ll,kk,k))
7819 gradcorr(ll,l)=gradcorr(ll,l) & !+0.5d0*ghalfk
7820 -ekont*(coeffpees0pij*gacontp_hb2(ll,kk,k)+ &
7821 coeffmees0mij*gacontm_hb2(ll,kk,k))
7822 gradlongij=ees*ekl*gacont_hbr(ll,jj,i)- &
7823 ekont*(coeffpees0pkl*gacontp_hb3(ll,jj,i)+ &
7824 coeffmees0mkl*gacontm_hb3(ll,jj,i))
7825 gradcorr_long(ll,j)=gradcorr_long(ll,j)+gradlongij
7826 gradcorr_long(ll,i)=gradcorr_long(ll,i)-gradlongij
7827 gradlongkl=ees*eij*gacont_hbr(ll,kk,k)- &
7828 ekont*(coeffpees0pij*gacontp_hb3(ll,kk,k)+ &
7829 coeffmees0mij*gacontm_hb3(ll,kk,k))
7830 gradcorr_long(ll,l)=gradcorr_long(ll,l)+gradlongkl
7831 gradcorr_long(ll,k)=gradcorr_long(ll,k)-gradlongkl
7832 ! write (iout,'(2f10.5,2x,$)') gradlongij,gradlongkl
7837 !grad gradcorr(ll,m)=gradcorr(ll,m)+
7838 !grad & ees*ekl*gacont_hbr(ll,jj,i)-
7839 !grad & ekont*(coeffp*ees0pkl*gacontp_hb3(ll,jj,i)+
7840 !grad & coeffm*ees0mkl*gacontm_hb3(ll,jj,i))
7845 !grad gradcorr(ll,m)=gradcorr(ll,m)+
7846 !grad & ees*eij*gacont_hbr(ll,kk,k)-
7847 !grad & ekont*(coeffp*ees0pij*gacontp_hb3(ll,kk,k)+
7848 !grad & coeffm*ees0mij*gacontm_hb3(ll,kk,k))
7851 ! write (iout,*) "ehbcorr",ekont*ees
7853 if (shield_mode.gt.0) then
7856 !C print *,i,j,fac_shield(i),fac_shield(j),
7857 !C &fac_shield(k),fac_shield(l)
7858 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
7859 (fac_shield(k).gt.0).and.(fac_shield(l).gt.0)) then
7860 do ilist=1,ishield_list(i)
7861 iresshield=shield_list(ilist,i)
7863 rlocshield=grad_shield_side(m,ilist,i)*ehbcorr/fac_shield(i)
7864 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+ &
7866 +grad_shield_loc(m,ilist,i)*ehbcorr/fac_shield(i)
7867 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1) &
7871 do ilist=1,ishield_list(j)
7872 iresshield=shield_list(ilist,j)
7874 rlocshield=grad_shield_side(m,ilist,j)*ehbcorr/fac_shield(j)
7875 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+ &
7877 +grad_shield_loc(m,ilist,j)*ehbcorr/fac_shield(j)
7878 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1) &
7883 do ilist=1,ishield_list(k)
7884 iresshield=shield_list(ilist,k)
7886 rlocshield=grad_shield_side(m,ilist,k)*ehbcorr/fac_shield(k)
7887 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+ &
7889 +grad_shield_loc(m,ilist,k)*ehbcorr/fac_shield(k)
7890 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1) &
7894 do ilist=1,ishield_list(l)
7895 iresshield=shield_list(ilist,l)
7897 rlocshield=grad_shield_side(m,ilist,l)*ehbcorr/fac_shield(l)
7898 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+ &
7900 +grad_shield_loc(m,ilist,l)*ehbcorr/fac_shield(l)
7901 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1) &
7906 gshieldc_ec(m,i)=gshieldc_ec(m,i)+ &
7907 grad_shield(m,i)*ehbcorr/fac_shield(i)
7908 gshieldc_ec(m,j)=gshieldc_ec(m,j)+ &
7909 grad_shield(m,j)*ehbcorr/fac_shield(j)
7910 gshieldc_ec(m,i-1)=gshieldc_ec(m,i-1)+ &
7911 grad_shield(m,i)*ehbcorr/fac_shield(i)
7912 gshieldc_ec(m,j-1)=gshieldc_ec(m,j-1)+ &
7913 grad_shield(m,j)*ehbcorr/fac_shield(j)
7915 gshieldc_ec(m,k)=gshieldc_ec(m,k)+ &
7916 grad_shield(m,k)*ehbcorr/fac_shield(k)
7917 gshieldc_ec(m,l)=gshieldc_ec(m,l)+ &
7918 grad_shield(m,l)*ehbcorr/fac_shield(l)
7919 gshieldc_ec(m,k-1)=gshieldc_ec(m,k-1)+ &
7920 grad_shield(m,k)*ehbcorr/fac_shield(k)
7921 gshieldc_ec(m,l-1)=gshieldc_ec(m,l-1)+ &
7922 grad_shield(m,l)*ehbcorr/fac_shield(l)
7928 end function ehbcorr
7930 !-----------------------------------------------------------------------------
7931 subroutine dipole(i,j,jj)
7932 ! implicit real*8 (a-h,o-z)
7933 ! include 'DIMENSIONS'
7934 ! include 'COMMON.IOUNITS'
7935 ! include 'COMMON.CHAIN'
7936 ! include 'COMMON.FFIELD'
7937 ! include 'COMMON.DERIV'
7938 ! include 'COMMON.INTERACT'
7939 ! include 'COMMON.CONTACTS'
7940 ! include 'COMMON.TORSION'
7941 ! include 'COMMON.VAR'
7942 ! include 'COMMON.GEO'
7943 real(kind=8),dimension(2,2) :: dipi,dipj,auxmat
7944 real(kind=8),dimension(2) :: dipderi,dipderj,auxvec
7945 integer :: i,j,jj,iii,jjj,kkk,lll,iti1,itj1
7947 allocate(dip(4,maxconts,nres),dipderg(4,maxconts,nres))
7948 allocate(dipderx(3,5,4,maxconts,nres))
7951 iti1 = itortyp(itype(i+1,1))
7952 if (j.lt.nres-1) then
7953 itj1 = itortyp(itype(j+1,1))
7958 dipi(iii,1)=Ub2(iii,i)
7959 dipderi(iii)=Ub2der(iii,i)
7960 dipi(iii,2)=b1(iii,iti1)
7961 dipj(iii,1)=Ub2(iii,j)
7962 dipderj(iii)=Ub2der(iii,j)
7963 dipj(iii,2)=b1(iii,itj1)
7967 call matvec2(a_chuj(1,1,jj,i),dipj(1,iii),auxvec(1))
7970 dip(kkk,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
7977 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),dipj(1,iii),&
7981 dipderx(lll,kkk,mmm,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
7986 call transpose2(a_chuj(1,1,jj,i),auxmat(1,1))
7987 call matvec2(auxmat(1,1),dipderi(1),auxvec(1))
7989 dipderg(iii,jj,i)=scalar2(auxvec(1),dipj(1,iii))
7991 call matvec2(a_chuj(1,1,jj,i),dipderj(1),auxvec(1))
7993 dipderg(iii+2,jj,i)=scalar2(auxvec(1),dipi(1,iii))
7996 end subroutine dipole
7998 !-----------------------------------------------------------------------------
7999 subroutine calc_eello(i,j,k,l,jj,kk)
8001 ! This subroutine computes matrices and vectors needed to calculate
8002 ! the fourth-, fifth-, and sixth-order local-electrostatic terms.
8005 ! implicit real*8 (a-h,o-z)
8006 ! include 'DIMENSIONS'
8007 ! include 'COMMON.IOUNITS'
8008 ! include 'COMMON.CHAIN'
8009 ! include 'COMMON.DERIV'
8010 ! include 'COMMON.INTERACT'
8011 ! include 'COMMON.CONTACTS'
8012 ! include 'COMMON.TORSION'
8013 ! include 'COMMON.VAR'
8014 ! include 'COMMON.GEO'
8015 ! include 'COMMON.FFIELD'
8016 real(kind=8),dimension(2,2) :: aa1,aa2,aa1t,aa2t,auxmat
8017 real(kind=8),dimension(2,2,3,5) :: aa1tder,aa2tder
8018 integer :: i,j,k,l,jj,kk,iii,jjj,kkk,lll,iti,itk1,itj,itl,itl1,&
8021 !el common /kutas/ lprn
8022 !d write (iout,*) 'calc_eello: i=',i,' j=',j,' k=',k,' l=',l,
8023 !d & ' jj=',jj,' kk=',kk
8024 !d if (i.ne.2 .or. j.ne.4 .or. k.ne.3 .or. l.ne.5) return
8025 !d write (iout,*) "a_chujij",((a_chuj(iii,jjj,jj,i),iii=1,2),jjj=1,2)
8026 !d write (iout,*) "a_chujkl",((a_chuj(iii,jjj,kk,k),iii=1,2),jjj=1,2)
8029 aa1(iii,jjj)=a_chuj(iii,jjj,jj,i)
8030 aa2(iii,jjj)=a_chuj(iii,jjj,kk,k)
8033 call transpose2(aa1(1,1),aa1t(1,1))
8034 call transpose2(aa2(1,1),aa2t(1,1))
8037 call transpose2(a_chuj_der(1,1,lll,kkk,jj,i),&
8038 aa1tder(1,1,lll,kkk))
8039 call transpose2(a_chuj_der(1,1,lll,kkk,kk,k),&
8040 aa2tder(1,1,lll,kkk))
8044 ! parallel orientation of the two CA-CA-CA frames.
8046 iti=itortyp(itype(i,1))
8050 itk1=itortyp(itype(k+1,1))
8051 itj=itortyp(itype(j,1))
8052 if (l.lt.nres-1) then
8053 itl1=itortyp(itype(l+1,1))
8057 ! A1 kernel(j+1) A2T
8059 !d write (iout,'(3f10.5,5x,3f10.5)')
8060 !d & (EUg(iii,jjj,k),jjj=1,2),(EUg(iii,jjj,l),jjj=1,2)
8062 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8063 aa2tder(1,1,1,1),1,.false.,EUg(1,1,l),EUgder(1,1,l),&
8064 AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
8065 ! Following matrices are needed only for 6-th order cumulants
8066 IF (wcorr6.gt.0.0d0) THEN
8067 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8068 aa2tder(1,1,1,1),1,.false.,EUgC(1,1,l),EUgCder(1,1,l),&
8069 AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
8070 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8071 aa2tder(1,1,1,1),2,.false.,Ug2DtEUg(1,1,l),&
8072 Ug2DtEUgder(1,1,1,l),ADtEA(1,1,1),ADtEAderg(1,1,1,1),&
8073 ADtEAderx(1,1,1,1,1,1))
8075 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8076 aa2tder(1,1,1,1),2,.false.,DtUg2EUg(1,1,l),&
8077 DtUg2EUgder(1,1,1,l),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),&
8078 ADtEA1derx(1,1,1,1,1,1))
8080 ! End 6-th order cumulants
8083 !d write (2,*) 'In calc_eello6'
8085 !d write (2,*) 'iii=',iii
8087 !d write (2,*) 'kkk=',kkk
8089 !d write (2,'(3(2f10.5),5x)')
8090 !d & ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
8095 call transpose2(EUgder(1,1,k),auxmat(1,1))
8096 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
8097 call transpose2(EUg(1,1,k),auxmat(1,1))
8098 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
8099 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
8103 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),&
8104 EAEAderx(1,1,lll,kkk,iii,1))
8108 ! A1T kernel(i+1) A2
8109 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
8110 a_chuj_der(1,1,1,1,kk,k),1,.false.,EUg(1,1,k),EUgder(1,1,k),&
8111 AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
8112 ! Following matrices are needed only for 6-th order cumulants
8113 IF (wcorr6.gt.0.0d0) THEN
8114 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
8115 a_chuj_der(1,1,1,1,kk,k),1,.false.,EUgC(1,1,k),EUgCder(1,1,k),&
8116 AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
8117 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
8118 a_chuj_der(1,1,1,1,kk,k),2,.false.,Ug2DtEUg(1,1,k),&
8119 Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),&
8120 ADtEAderx(1,1,1,1,1,2))
8121 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
8122 a_chuj_der(1,1,1,1,kk,k),2,.false.,DtUg2EUg(1,1,k),&
8123 DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),&
8124 ADtEA1derx(1,1,1,1,1,2))
8126 ! End 6-th order cumulants
8127 call transpose2(EUgder(1,1,l),auxmat(1,1))
8128 call matmat2(auxmat(1,1),AEA(1,1,2),EAEAderg(1,1,1,2))
8129 call transpose2(EUg(1,1,l),auxmat(1,1))
8130 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
8131 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
8135 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
8136 EAEAderx(1,1,lll,kkk,iii,2))
8141 ! Calculate the vectors and their derivatives in virtual-bond dihedral angles.
8142 ! They are needed only when the fifth- or the sixth-order cumulants are
8144 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) THEN
8145 call transpose2(AEA(1,1,1),auxmat(1,1))
8146 call matvec2(auxmat(1,1),b1(1,iti),AEAb1(1,1,1))
8147 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
8148 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
8149 call transpose2(AEAderg(1,1,1),auxmat(1,1))
8150 call matvec2(auxmat(1,1),b1(1,iti),AEAb1derg(1,1,1))
8151 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
8152 call matvec2(AEA(1,1,1),b1(1,itk1),AEAb1(1,2,1))
8153 call matvec2(AEAderg(1,1,1),b1(1,itk1),AEAb1derg(1,2,1))
8154 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
8155 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
8156 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
8157 call transpose2(AEA(1,1,2),auxmat(1,1))
8158 call matvec2(auxmat(1,1),b1(1,itj),AEAb1(1,1,2))
8159 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2(1,1,2))
8160 call matvec2(auxmat(1,1),Ub2der(1,j),AEAb2derg(1,2,1,2))
8161 call transpose2(AEAderg(1,1,2),auxmat(1,1))
8162 call matvec2(auxmat(1,1),b1(1,itj),AEAb1derg(1,1,2))
8163 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2derg(1,1,1,2))
8164 call matvec2(AEA(1,1,2),b1(1,itl1),AEAb1(1,2,2))
8165 call matvec2(AEAderg(1,1,2),b1(1,itl1),AEAb1derg(1,2,2))
8166 call matvec2(AEA(1,1,2),Ub2(1,l+1),AEAb2(1,2,2))
8167 call matvec2(AEAderg(1,1,2),Ub2(1,l+1),AEAb2derg(1,1,2,2))
8168 call matvec2(AEA(1,1,2),Ub2der(1,l+1),AEAb2derg(1,2,2,2))
8169 ! Calculate the Cartesian derivatives of the vectors.
8173 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
8174 call matvec2(auxmat(1,1),b1(1,iti),&
8175 AEAb1derx(1,lll,kkk,iii,1,1))
8176 call matvec2(auxmat(1,1),Ub2(1,i),&
8177 AEAb2derx(1,lll,kkk,iii,1,1))
8178 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,itk1),&
8179 AEAb1derx(1,lll,kkk,iii,2,1))
8180 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),&
8181 AEAb2derx(1,lll,kkk,iii,2,1))
8182 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
8183 call matvec2(auxmat(1,1),b1(1,itj),&
8184 AEAb1derx(1,lll,kkk,iii,1,2))
8185 call matvec2(auxmat(1,1),Ub2(1,j),&
8186 AEAb2derx(1,lll,kkk,iii,1,2))
8187 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,itl1),&
8188 AEAb1derx(1,lll,kkk,iii,2,2))
8189 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,l+1),&
8190 AEAb2derx(1,lll,kkk,iii,2,2))
8197 ! Antiparallel orientation of the two CA-CA-CA frames.
8199 iti=itortyp(itype(i,1))
8203 itk1=itortyp(itype(k+1,1))
8204 itl=itortyp(itype(l,1))
8205 itj=itortyp(itype(j,1))
8206 if (j.lt.nres-1) then
8207 itj1=itortyp(itype(j+1,1))
8211 ! A2 kernel(j-1)T A1T
8212 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8213 aa2tder(1,1,1,1),1,.true.,EUg(1,1,j),EUgder(1,1,j),&
8214 AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
8215 ! Following matrices are needed only for 6-th order cumulants
8216 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and. &
8217 j.eq.i+4 .and. l.eq.i+3)) THEN
8218 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8219 aa2tder(1,1,1,1),1,.true.,EUgC(1,1,j),EUgCder(1,1,j),&
8220 AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
8221 call kernel(aa2(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8222 aa2tder(1,1,1,1),2,.true.,Ug2DtEUg(1,1,j),&
8223 Ug2DtEUgder(1,1,1,j),ADtEA(1,1,1),ADtEAderg(1,1,1,1),&
8224 ADtEAderx(1,1,1,1,1,1))
8225 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8226 aa2tder(1,1,1,1),2,.true.,DtUg2EUg(1,1,j),&
8227 DtUg2EUgder(1,1,1,j),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),&
8228 ADtEA1derx(1,1,1,1,1,1))
8230 ! End 6-th order cumulants
8231 call transpose2(EUgder(1,1,k),auxmat(1,1))
8232 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
8233 call transpose2(EUg(1,1,k),auxmat(1,1))
8234 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
8235 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
8239 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),&
8240 EAEAderx(1,1,lll,kkk,iii,1))
8244 ! A2T kernel(i+1)T A1
8245 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
8246 a_chuj_der(1,1,1,1,jj,i),1,.true.,EUg(1,1,k),EUgder(1,1,k),&
8247 AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
8248 ! Following matrices are needed only for 6-th order cumulants
8249 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and. &
8250 j.eq.i+4 .and. l.eq.i+3)) THEN
8251 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
8252 a_chuj_der(1,1,1,1,jj,i),1,.true.,EUgC(1,1,k),EUgCder(1,1,k),&
8253 AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
8254 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
8255 a_chuj_der(1,1,1,1,jj,i),2,.true.,Ug2DtEUg(1,1,k),&
8256 Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),&
8257 ADtEAderx(1,1,1,1,1,2))
8258 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
8259 a_chuj_der(1,1,1,1,jj,i),2,.true.,DtUg2EUg(1,1,k),&
8260 DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),&
8261 ADtEA1derx(1,1,1,1,1,2))
8263 ! End 6-th order cumulants
8264 call transpose2(EUgder(1,1,j),auxmat(1,1))
8265 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,2,2))
8266 call transpose2(EUg(1,1,j),auxmat(1,1))
8267 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
8268 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
8272 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
8273 EAEAderx(1,1,lll,kkk,iii,2))
8278 ! Calculate the vectors and their derivatives in virtual-bond dihedral angles.
8279 ! They are needed only when the fifth- or the sixth-order cumulants are
8281 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 .or. &
8282 (wturn6.gt.0.0d0 .and. j.eq.i+4 .and. l.eq.i+3)) THEN
8283 call transpose2(AEA(1,1,1),auxmat(1,1))
8284 call matvec2(auxmat(1,1),b1(1,iti),AEAb1(1,1,1))
8285 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
8286 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
8287 call transpose2(AEAderg(1,1,1),auxmat(1,1))
8288 call matvec2(auxmat(1,1),b1(1,iti),AEAb1derg(1,1,1))
8289 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
8290 call matvec2(AEA(1,1,1),b1(1,itk1),AEAb1(1,2,1))
8291 call matvec2(AEAderg(1,1,1),b1(1,itk1),AEAb1derg(1,2,1))
8292 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
8293 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
8294 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
8295 call transpose2(AEA(1,1,2),auxmat(1,1))
8296 call matvec2(auxmat(1,1),b1(1,itj1),AEAb1(1,1,2))
8297 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2(1,1,2))
8298 call matvec2(auxmat(1,1),Ub2der(1,l),AEAb2derg(1,2,1,2))
8299 call transpose2(AEAderg(1,1,2),auxmat(1,1))
8300 call matvec2(auxmat(1,1),b1(1,itl),AEAb1(1,1,2))
8301 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2derg(1,1,1,2))
8302 call matvec2(AEA(1,1,2),b1(1,itj1),AEAb1(1,2,2))
8303 call matvec2(AEAderg(1,1,2),b1(1,itj1),AEAb1derg(1,2,2))
8304 call matvec2(AEA(1,1,2),Ub2(1,j),AEAb2(1,2,2))
8305 call matvec2(AEAderg(1,1,2),Ub2(1,j),AEAb2derg(1,1,2,2))
8306 call matvec2(AEA(1,1,2),Ub2der(1,j),AEAb2derg(1,2,2,2))
8307 ! Calculate the Cartesian derivatives of the vectors.
8311 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
8312 call matvec2(auxmat(1,1),b1(1,iti),&
8313 AEAb1derx(1,lll,kkk,iii,1,1))
8314 call matvec2(auxmat(1,1),Ub2(1,i),&
8315 AEAb2derx(1,lll,kkk,iii,1,1))
8316 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,itk1),&
8317 AEAb1derx(1,lll,kkk,iii,2,1))
8318 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),&
8319 AEAb2derx(1,lll,kkk,iii,2,1))
8320 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
8321 call matvec2(auxmat(1,1),b1(1,itl),&
8322 AEAb1derx(1,lll,kkk,iii,1,2))
8323 call matvec2(auxmat(1,1),Ub2(1,l),&
8324 AEAb2derx(1,lll,kkk,iii,1,2))
8325 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,itj1),&
8326 AEAb1derx(1,lll,kkk,iii,2,2))
8327 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,j),&
8328 AEAb2derx(1,lll,kkk,iii,2,2))
8336 end subroutine calc_eello
8337 !-----------------------------------------------------------------------------
8338 subroutine kernel(aa1,aa2t,aa1derx,aa2tderx,nderg,transp,KK,KKderg,AKA,AKAderg,AKAderx)
8343 real(kind=8),dimension(2,2) :: aa1,aa2t,KK,AKA
8344 real(kind=8),dimension(2,2,3,5) :: aa1derx,aa2tderx
8345 real(kind=8),dimension(2,2,3,5,2) :: AKAderx
8346 real(kind=8),dimension(2,2,nderg) :: KKderg,AKAderg
8347 integer :: iii,kkk,lll
8350 !el common /kutas/ lprn
8351 call prodmat3(aa1(1,1),aa2t(1,1),KK(1,1),transp,AKA(1,1))
8353 call prodmat3(aa1(1,1),aa2t(1,1),KKderg(1,1,iii),transp,&
8356 !d if (lprn) write (2,*) 'In kernel'
8358 !d if (lprn) write (2,*) 'kkk=',kkk
8360 call prodmat3(aa1derx(1,1,lll,kkk),aa2t(1,1),&
8361 KK(1,1),transp,AKAderx(1,1,lll,kkk,1))
8363 !d write (2,*) 'lll=',lll
8364 !d write (2,*) 'iii=1'
8366 !d write (2,'(3(2f10.5),5x)')
8367 !d & (AKAderx(jjj,mmm,lll,kkk,1),mmm=1,2)
8370 call prodmat3(aa1(1,1),aa2tderx(1,1,lll,kkk),&
8371 KK(1,1),transp,AKAderx(1,1,lll,kkk,2))
8373 !d write (2,*) 'lll=',lll
8374 !d write (2,*) 'iii=2'
8376 !d write (2,'(3(2f10.5),5x)')
8377 !d & (AKAderx(jjj,mmm,lll,kkk,2),mmm=1,2)
8383 end subroutine kernel
8384 !-----------------------------------------------------------------------------
8385 real(kind=8) function eello4(i,j,k,l,jj,kk)
8386 ! implicit real*8 (a-h,o-z)
8387 ! include 'DIMENSIONS'
8388 ! include 'COMMON.IOUNITS'
8389 ! include 'COMMON.CHAIN'
8390 ! include 'COMMON.DERIV'
8391 ! include 'COMMON.INTERACT'
8392 ! include 'COMMON.CONTACTS'
8393 ! include 'COMMON.TORSION'
8394 ! include 'COMMON.VAR'
8395 ! include 'COMMON.GEO'
8396 real(kind=8),dimension(2,2) :: pizda
8397 real(kind=8),dimension(3) :: ggg1,ggg2
8398 real(kind=8) :: eel4,glongij,glongkl
8399 integer :: i,j,k,l,jj,kk,iii,kkk,lll,j1,j2,l1,l2,ll
8400 !d if (i.ne.1 .or. j.ne.5 .or. k.ne.2 .or.l.ne.4) then
8404 !d print *,'eello4:',i,j,k,l,jj,kk
8405 !d write (2,*) 'i',i,' j',j,' k',k,' l',l
8406 !d call checkint4(i,j,k,l,jj,kk,eel4_num)
8407 !old eij=facont_hb(jj,i)
8408 !old ekl=facont_hb(kk,k)
8410 eel4=-EAEA(1,1,1)-EAEA(2,2,1)
8411 !d eel41=-EAEA(1,1,2)-EAEA(2,2,2)
8412 gcorr_loc(k-1)=gcorr_loc(k-1) &
8413 -ekont*(EAEAderg(1,1,1,1)+EAEAderg(2,2,1,1))
8415 gcorr_loc(l-1)=gcorr_loc(l-1) &
8416 -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
8418 gcorr_loc(j-1)=gcorr_loc(j-1) &
8419 -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
8424 derx(lll,kkk,iii)=-EAEAderx(1,1,lll,kkk,iii,1) &
8425 -EAEAderx(2,2,lll,kkk,iii,1)
8426 !d derx(lll,kkk,iii)=0.0d0
8430 !d gcorr_loc(l-1)=0.0d0
8431 !d gcorr_loc(j-1)=0.0d0
8432 !d gcorr_loc(k-1)=0.0d0
8434 !d write (iout,*)'Contacts have occurred for peptide groups',
8435 !d & i,j,' fcont:',eij,' eij',' and ',k,l,
8436 !d & ' fcont ',ekl,' eel4=',eel4,' eel4_num',16*eel4_num
8437 if (j.lt.nres-1) then
8444 if (l.lt.nres-1) then
8452 !grad ggg1(ll)=eel4*g_contij(ll,1)
8453 !grad ggg2(ll)=eel4*g_contij(ll,2)
8454 glongij=eel4*g_contij(ll,1)+ekont*derx(ll,1,1)
8455 glongkl=eel4*g_contij(ll,2)+ekont*derx(ll,1,2)
8456 !grad ghalf=0.5d0*ggg1(ll)
8457 gradcorr(ll,i)=gradcorr(ll,i)+ekont*derx(ll,2,1)
8458 gradcorr(ll,i+1)=gradcorr(ll,i+1)+ekont*derx(ll,3,1)
8459 gradcorr(ll,j)=gradcorr(ll,j)+ekont*derx(ll,4,1)
8460 gradcorr(ll,j1)=gradcorr(ll,j1)+ekont*derx(ll,5,1)
8461 gradcorr_long(ll,j)=gradcorr_long(ll,j)+glongij
8462 gradcorr_long(ll,i)=gradcorr_long(ll,i)-glongij
8463 !grad ghalf=0.5d0*ggg2(ll)
8464 gradcorr(ll,k)=gradcorr(ll,k)+ekont*derx(ll,2,2)
8465 gradcorr(ll,k+1)=gradcorr(ll,k+1)+ekont*derx(ll,3,2)
8466 gradcorr(ll,l)=gradcorr(ll,l)+ekont*derx(ll,4,2)
8467 gradcorr(ll,l1)=gradcorr(ll,l1)+ekont*derx(ll,5,2)
8468 gradcorr_long(ll,l)=gradcorr_long(ll,l)+glongkl
8469 gradcorr_long(ll,k)=gradcorr_long(ll,k)-glongkl
8473 !grad gradcorr(ll,m)=gradcorr(ll,m)+ggg1(ll)
8478 !grad gradcorr(ll,m)=gradcorr(ll,m)+ggg2(ll)
8483 !grad gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,1)
8488 !grad gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,2)
8492 !d write (2,*) iii,gcorr_loc(iii)
8495 !d write (2,*) 'ekont',ekont
8496 !d write (iout,*) 'eello4',ekont*eel4
8499 !-----------------------------------------------------------------------------
8500 real(kind=8) function eello5(i,j,k,l,jj,kk)
8501 ! implicit real*8 (a-h,o-z)
8502 ! include 'DIMENSIONS'
8503 ! include 'COMMON.IOUNITS'
8504 ! include 'COMMON.CHAIN'
8505 ! include 'COMMON.DERIV'
8506 ! include 'COMMON.INTERACT'
8507 ! include 'COMMON.CONTACTS'
8508 ! include 'COMMON.TORSION'
8509 ! include 'COMMON.VAR'
8510 ! include 'COMMON.GEO'
8511 real(kind=8),dimension(2,2) :: pizda,auxmat,auxmat1
8512 real(kind=8),dimension(2) :: vv
8513 real(kind=8),dimension(3) :: ggg1,ggg2
8514 real(kind=8) :: eello5_1,eello5_2,eello5_3,eello5_4,eel5
8515 real(kind=8) :: gradcorr5ij,gradcorr5kl,ghalf
8516 integer :: i,j,k,l,jj,kk,itk,itl,itj,iii,kkk,lll,j1,j2,l1,l2,ll
8517 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8522 ! /l\ / \ \ / \ / \ / C
8523 ! / \ / \ \ / \ / \ / C
8524 ! j| o |l1 | o | o| o | | o |o C
8525 ! \ |/k\| |/ \| / |/ \| |/ \| C
8526 ! \i/ \ / \ / / \ / \ C
8528 ! (I) (II) (III) (IV) C
8530 ! eello5_1 eello5_2 eello5_3 eello5_4 C
8532 ! Antiparallel chains C
8535 ! /j\ / \ \ / \ / \ / C
8536 ! / \ / \ \ / \ / \ / C
8537 ! j1| o |l | o | o| o | | o |o C
8538 ! \ |/k\| |/ \| / |/ \| |/ \| C
8539 ! \i/ \ / \ / / \ / \ C
8541 ! (I) (II) (III) (IV) C
8543 ! eello5_1 eello5_2 eello5_3 eello5_4 C
8545 ! o denotes a local interaction, vertical lines an electrostatic interaction. C
8547 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8548 !d if (i.ne.2 .or. j.ne.6 .or. k.ne.3 .or. l.ne.5) then
8553 !d & 'EELLO5: Contacts have occurred for peptide groups',i,j,
8555 itk=itortyp(itype(k,1))
8556 itl=itortyp(itype(l,1))
8557 itj=itortyp(itype(j,1))
8562 !d call checkint5(i,j,k,l,jj,kk,eel5_1_num,eel5_2_num,
8563 !d & eel5_3_num,eel5_4_num)
8567 derx(lll,kkk,iii)=0.0d0
8571 !d eij=facont_hb(jj,i)
8572 !d ekl=facont_hb(kk,k)
8574 !d write (iout,*)'Contacts have occurred for peptide groups',
8575 !d & i,j,' fcont:',eij,' eij',' and ',k,l
8577 ! Contribution from the graph I.
8578 !d write (2,*) 'AEA ',AEA(1,1,1),AEA(2,1,1),AEA(1,2,1),AEA(2,2,1)
8579 !d write (2,*) 'AEAb2',AEAb2(1,1,1),AEAb2(2,1,1)
8580 call transpose2(EUg(1,1,k),auxmat(1,1))
8581 call matmat2(AEA(1,1,1),auxmat(1,1),pizda(1,1))
8582 vv(1)=pizda(1,1)-pizda(2,2)
8583 vv(2)=pizda(1,2)+pizda(2,1)
8584 eello5_1=scalar2(AEAb2(1,1,1),Ub2(1,k)) &
8585 +0.5d0*scalar2(vv(1),Dtobr2(1,i))
8586 ! Explicit gradient in virtual-dihedral angles.
8587 if (i.gt.1) g_corr5_loc(i-1)=g_corr5_loc(i-1) &
8588 +ekont*(scalar2(AEAb2derg(1,2,1,1),Ub2(1,k)) &
8589 +0.5d0*scalar2(vv(1),Dtobr2der(1,i)))
8590 call transpose2(EUgder(1,1,k),auxmat1(1,1))
8591 call matmat2(AEA(1,1,1),auxmat1(1,1),pizda(1,1))
8592 vv(1)=pizda(1,1)-pizda(2,2)
8593 vv(2)=pizda(1,2)+pizda(2,1)
8594 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
8595 +ekont*(scalar2(AEAb2(1,1,1),Ub2der(1,k)) &
8596 +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
8597 call matmat2(AEAderg(1,1,1),auxmat(1,1),pizda(1,1))
8598 vv(1)=pizda(1,1)-pizda(2,2)
8599 vv(2)=pizda(1,2)+pizda(2,1)
8601 if (l.lt.nres-1) g_corr5_loc(l-1)=g_corr5_loc(l-1) &
8602 +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k)) &
8603 +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
8605 if (j.lt.nres-1) g_corr5_loc(j-1)=g_corr5_loc(j-1) &
8606 +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k)) &
8607 +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
8609 ! Cartesian gradient
8613 call matmat2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1),&
8615 vv(1)=pizda(1,1)-pizda(2,2)
8616 vv(2)=pizda(1,2)+pizda(2,1)
8617 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
8618 +scalar2(AEAb2derx(1,lll,kkk,iii,1,1),Ub2(1,k)) &
8619 +0.5d0*scalar2(vv(1),Dtobr2(1,i))
8625 ! Contribution from graph II
8626 call transpose2(EE(1,1,itk),auxmat(1,1))
8627 call matmat2(auxmat(1,1),AEA(1,1,1),pizda(1,1))
8628 vv(1)=pizda(1,1)+pizda(2,2)
8629 vv(2)=pizda(2,1)-pizda(1,2)
8630 eello5_2=scalar2(AEAb1(1,2,1),b1(1,itk)) &
8631 -0.5d0*scalar2(vv(1),Ctobr(1,k))
8632 ! Explicit gradient in virtual-dihedral angles.
8633 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
8634 -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,k))
8635 call matmat2(auxmat(1,1),AEAderg(1,1,1),pizda(1,1))
8636 vv(1)=pizda(1,1)+pizda(2,2)
8637 vv(2)=pizda(2,1)-pizda(1,2)
8639 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
8640 +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,itk)) &
8641 -0.5d0*scalar2(vv(1),Ctobr(1,k)))
8643 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
8644 +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,itk)) &
8645 -0.5d0*scalar2(vv(1),Ctobr(1,k)))
8647 ! Cartesian gradient
8651 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),&
8653 vv(1)=pizda(1,1)+pizda(2,2)
8654 vv(2)=pizda(2,1)-pizda(1,2)
8655 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
8656 +scalar2(AEAb1derx(1,lll,kkk,iii,2,1),b1(1,itk)) &
8657 -0.5d0*scalar2(vv(1),Ctobr(1,k))
8665 ! Parallel orientation
8666 ! Contribution from graph III
8667 call transpose2(EUg(1,1,l),auxmat(1,1))
8668 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
8669 vv(1)=pizda(1,1)-pizda(2,2)
8670 vv(2)=pizda(1,2)+pizda(2,1)
8671 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,l)) &
8672 +0.5d0*scalar2(vv(1),Dtobr2(1,j))
8673 ! Explicit gradient in virtual-dihedral angles.
8674 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
8675 +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,l)) &
8676 +0.5d0*scalar2(vv(1),Dtobr2der(1,j)))
8677 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
8678 vv(1)=pizda(1,1)-pizda(2,2)
8679 vv(2)=pizda(1,2)+pizda(2,1)
8680 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
8681 +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,l)) &
8682 +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
8683 call transpose2(EUgder(1,1,l),auxmat1(1,1))
8684 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
8685 vv(1)=pizda(1,1)-pizda(2,2)
8686 vv(2)=pizda(1,2)+pizda(2,1)
8687 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
8688 +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,l)) &
8689 +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
8690 ! Cartesian gradient
8694 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),&
8696 vv(1)=pizda(1,1)-pizda(2,2)
8697 vv(2)=pizda(1,2)+pizda(2,1)
8698 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
8699 +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,l)) &
8700 +0.5d0*scalar2(vv(1),Dtobr2(1,j))
8705 ! Contribution from graph IV
8707 call transpose2(EE(1,1,itl),auxmat(1,1))
8708 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
8709 vv(1)=pizda(1,1)+pizda(2,2)
8710 vv(2)=pizda(2,1)-pizda(1,2)
8711 eello5_4=scalar2(AEAb1(1,2,2),b1(1,itl)) &
8712 -0.5d0*scalar2(vv(1),Ctobr(1,l))
8713 ! Explicit gradient in virtual-dihedral angles.
8714 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
8715 -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,l))
8716 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
8717 vv(1)=pizda(1,1)+pizda(2,2)
8718 vv(2)=pizda(2,1)-pizda(1,2)
8719 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
8720 +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,itl)) &
8721 -0.5d0*scalar2(vv(1),Ctobr(1,l)))
8722 ! Cartesian gradient
8726 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
8728 vv(1)=pizda(1,1)+pizda(2,2)
8729 vv(2)=pizda(2,1)-pizda(1,2)
8730 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
8731 +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,itl)) &
8732 -0.5d0*scalar2(vv(1),Ctobr(1,l))
8737 ! Antiparallel orientation
8738 ! Contribution from graph III
8740 call transpose2(EUg(1,1,j),auxmat(1,1))
8741 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
8742 vv(1)=pizda(1,1)-pizda(2,2)
8743 vv(2)=pizda(1,2)+pizda(2,1)
8744 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,j)) &
8745 +0.5d0*scalar2(vv(1),Dtobr2(1,l))
8746 ! Explicit gradient in virtual-dihedral angles.
8747 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
8748 +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,j)) &
8749 +0.5d0*scalar2(vv(1),Dtobr2der(1,l)))
8750 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
8751 vv(1)=pizda(1,1)-pizda(2,2)
8752 vv(2)=pizda(1,2)+pizda(2,1)
8753 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
8754 +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,j)) &
8755 +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
8756 call transpose2(EUgder(1,1,j),auxmat1(1,1))
8757 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
8758 vv(1)=pizda(1,1)-pizda(2,2)
8759 vv(2)=pizda(1,2)+pizda(2,1)
8760 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
8761 +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,j)) &
8762 +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
8763 ! Cartesian gradient
8767 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),&
8769 vv(1)=pizda(1,1)-pizda(2,2)
8770 vv(2)=pizda(1,2)+pizda(2,1)
8771 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii) &
8772 +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,j)) &
8773 +0.5d0*scalar2(vv(1),Dtobr2(1,l))
8778 ! Contribution from graph IV
8780 call transpose2(EE(1,1,itj),auxmat(1,1))
8781 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
8782 vv(1)=pizda(1,1)+pizda(2,2)
8783 vv(2)=pizda(2,1)-pizda(1,2)
8784 eello5_4=scalar2(AEAb1(1,2,2),b1(1,itj)) &
8785 -0.5d0*scalar2(vv(1),Ctobr(1,j))
8786 ! Explicit gradient in virtual-dihedral angles.
8787 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
8788 -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,j))
8789 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
8790 vv(1)=pizda(1,1)+pizda(2,2)
8791 vv(2)=pizda(2,1)-pizda(1,2)
8792 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
8793 +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,itj)) &
8794 -0.5d0*scalar2(vv(1),Ctobr(1,j)))
8795 ! Cartesian gradient
8799 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
8801 vv(1)=pizda(1,1)+pizda(2,2)
8802 vv(2)=pizda(2,1)-pizda(1,2)
8803 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii) &
8804 +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,itj)) &
8805 -0.5d0*scalar2(vv(1),Ctobr(1,j))
8811 eel5=eello5_1+eello5_2+eello5_3+eello5_4
8812 !d if (i.eq.2 .and. j.eq.8 .and. k.eq.3 .and. l.eq.7) then
8813 !d write (2,*) 'ijkl',i,j,k,l
8814 !d write (2,*) 'eello5_1',eello5_1,' eello5_2',eello5_2,
8815 !d & ' eello5_3',eello5_3,' eello5_4',eello5_4
8817 !d write(iout,*) 'eello5_1',eello5_1,' eel5_1_num',16*eel5_1_num
8818 !d write(iout,*) 'eello5_2',eello5_2,' eel5_2_num',16*eel5_2_num
8819 !d write(iout,*) 'eello5_3',eello5_3,' eel5_3_num',16*eel5_3_num
8820 !d write(iout,*) 'eello5_4',eello5_4,' eel5_4_num',16*eel5_4_num
8821 if (j.lt.nres-1) then
8828 if (l.lt.nres-1) then
8838 !d write (2,*) 'eij',eij,' ekl',ekl,' ekont',ekont
8839 ! 2/11/08 AL Gradients over DC's connecting interacting sites will be
8840 ! summed up outside the subrouine as for the other subroutines
8841 ! handling long-range interactions. The old code is commented out
8842 ! with "cgrad" to keep track of changes.
8844 !grad ggg1(ll)=eel5*g_contij(ll,1)
8845 !grad ggg2(ll)=eel5*g_contij(ll,2)
8846 gradcorr5ij=eel5*g_contij(ll,1)+ekont*derx(ll,1,1)
8847 gradcorr5kl=eel5*g_contij(ll,2)+ekont*derx(ll,1,2)
8848 ! write (iout,'(a,3i3,a,5f8.3,2i3,a,5f8.3,a,f8.3)')
8849 ! & "ecorr5",ll,i,j," derx",derx(ll,2,1),derx(ll,3,1),derx(ll,4,1),
8850 ! & derx(ll,5,1),k,l," derx",derx(ll,2,2),derx(ll,3,2),
8851 ! & derx(ll,4,2),derx(ll,5,2)," ekont",ekont
8852 ! write (iout,'(a,3i3,a,3f8.3,2i3,a,3f8.3)')
8853 ! & "ecorr5",ll,i,j," gradcorr5",g_contij(ll,1),derx(ll,1,1),
8855 ! & k,l," gradcorr5",g_contij(ll,2),derx(ll,1,2),gradcorr5kl
8856 !old ghalf=0.5d0*eel5*ekl*gacont_hbr(ll,jj,i)
8857 !grad ghalf=0.5d0*ggg1(ll)
8859 gradcorr5(ll,i)=gradcorr5(ll,i)+ekont*derx(ll,2,1)
8860 gradcorr5(ll,i+1)=gradcorr5(ll,i+1)+ekont*derx(ll,3,1)
8861 gradcorr5(ll,j)=gradcorr5(ll,j)+ekont*derx(ll,4,1)
8862 gradcorr5(ll,j1)=gradcorr5(ll,j1)+ekont*derx(ll,5,1)
8863 gradcorr5_long(ll,j)=gradcorr5_long(ll,j)+gradcorr5ij
8864 gradcorr5_long(ll,i)=gradcorr5_long(ll,i)-gradcorr5ij
8865 !old ghalf=0.5d0*eel5*eij*gacont_hbr(ll,kk,k)
8866 !grad ghalf=0.5d0*ggg2(ll)
8868 gradcorr5(ll,k)=gradcorr5(ll,k)+ghalf+ekont*derx(ll,2,2)
8869 gradcorr5(ll,k+1)=gradcorr5(ll,k+1)+ekont*derx(ll,3,2)
8870 gradcorr5(ll,l)=gradcorr5(ll,l)+ghalf+ekont*derx(ll,4,2)
8871 gradcorr5(ll,l1)=gradcorr5(ll,l1)+ekont*derx(ll,5,2)
8872 gradcorr5_long(ll,l)=gradcorr5_long(ll,l)+gradcorr5kl
8873 gradcorr5_long(ll,k)=gradcorr5_long(ll,k)-gradcorr5kl
8878 !old gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*ekl*gacont_hbr(ll,jj,i)
8879 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ggg1(ll)
8884 !old gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*eij*gacont_hbr(ll,kk,k)
8885 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ggg2(ll)
8891 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,1)
8896 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,2)
8900 !d write (2,*) iii,g_corr5_loc(iii)
8903 !d write (2,*) 'ekont',ekont
8904 !d write (iout,*) 'eello5',ekont*eel5
8907 !-----------------------------------------------------------------------------
8908 real(kind=8) function eello6(i,j,k,l,jj,kk)
8909 ! implicit real*8 (a-h,o-z)
8910 ! include 'DIMENSIONS'
8911 ! include 'COMMON.IOUNITS'
8912 ! include 'COMMON.CHAIN'
8913 ! include 'COMMON.DERIV'
8914 ! include 'COMMON.INTERACT'
8915 ! include 'COMMON.CONTACTS'
8916 ! include 'COMMON.TORSION'
8917 ! include 'COMMON.VAR'
8918 ! include 'COMMON.GEO'
8919 ! include 'COMMON.FFIELD'
8920 real(kind=8),dimension(3) :: ggg1,ggg2
8921 real(kind=8) :: eello6_1,eello6_2,eello6_3,eello6_4,eello6_5,&
8923 real(kind=8) :: gradcorr6ij,gradcorr6kl
8924 integer :: i,j,k,l,jj,kk,iii,kkk,lll,j1,j2,l1,l2,ll
8925 !d if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
8930 !d & 'EELLO6: Contacts have occurred for peptide groups',i,j,
8938 !d call checkint6(i,j,k,l,jj,kk,eel6_1_num,eel6_2_num,
8939 !d & eel6_3_num,eel6_4_num,eel6_5_num,eel6_6_num)
8943 derx(lll,kkk,iii)=0.0d0
8947 !d eij=facont_hb(jj,i)
8948 !d ekl=facont_hb(kk,k)
8954 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
8955 eello6_2=eello6_graph1(j,i,l,k,2,.false.)
8956 eello6_3=eello6_graph2(i,j,k,l,jj,kk,.false.)
8957 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
8958 eello6_5=eello6_graph4(j,i,l,k,jj,kk,2,.false.)
8959 eello6_6=eello6_graph3(i,j,k,l,jj,kk,.false.)
8961 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
8962 eello6_2=eello6_graph1(l,k,j,i,2,.true.)
8963 eello6_3=eello6_graph2(i,l,k,j,jj,kk,.true.)
8964 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
8965 if (wturn6.eq.0.0d0 .or. j.ne.i+4) then
8966 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
8970 eello6_6=eello6_graph3(i,l,k,j,jj,kk,.true.)
8972 ! If turn contributions are considered, they will be handled separately.
8973 eel6=eello6_1+eello6_2+eello6_3+eello6_4+eello6_5+eello6_6
8974 !d write(iout,*) 'eello6_1',eello6_1!,' eel6_1_num',16*eel6_1_num
8975 !d write(iout,*) 'eello6_2',eello6_2!,' eel6_2_num',16*eel6_2_num
8976 !d write(iout,*) 'eello6_3',eello6_3!,' eel6_3_num',16*eel6_3_num
8977 !d write(iout,*) 'eello6_4',eello6_4!,' eel6_4_num',16*eel6_4_num
8978 !d write(iout,*) 'eello6_5',eello6_5!,' eel6_5_num',16*eel6_5_num
8979 !d write(iout,*) 'eello6_6',eello6_6!,' eel6_6_num',16*eel6_6_num
8981 if (j.lt.nres-1) then
8988 if (l.lt.nres-1) then
8996 !grad ggg1(ll)=eel6*g_contij(ll,1)
8997 !grad ggg2(ll)=eel6*g_contij(ll,2)
8998 !old ghalf=0.5d0*eel6*ekl*gacont_hbr(ll,jj,i)
8999 !grad ghalf=0.5d0*ggg1(ll)
9001 gradcorr6ij=eel6*g_contij(ll,1)+ekont*derx(ll,1,1)
9002 gradcorr6kl=eel6*g_contij(ll,2)+ekont*derx(ll,1,2)
9003 gradcorr6(ll,i)=gradcorr6(ll,i)+ekont*derx(ll,2,1)
9004 gradcorr6(ll,i+1)=gradcorr6(ll,i+1)+ekont*derx(ll,3,1)
9005 gradcorr6(ll,j)=gradcorr6(ll,j)+ekont*derx(ll,4,1)
9006 gradcorr6(ll,j1)=gradcorr6(ll,j1)+ekont*derx(ll,5,1)
9007 gradcorr6_long(ll,j)=gradcorr6_long(ll,j)+gradcorr6ij
9008 gradcorr6_long(ll,i)=gradcorr6_long(ll,i)-gradcorr6ij
9009 !grad ghalf=0.5d0*ggg2(ll)
9010 !old ghalf=0.5d0*eel6*eij*gacont_hbr(ll,kk,k)
9012 gradcorr6(ll,k)=gradcorr6(ll,k)+ekont*derx(ll,2,2)
9013 gradcorr6(ll,k+1)=gradcorr6(ll,k+1)+ekont*derx(ll,3,2)
9014 gradcorr6(ll,l)=gradcorr6(ll,l)+ekont*derx(ll,4,2)
9015 gradcorr6(ll,l1)=gradcorr6(ll,l1)+ekont*derx(ll,5,2)
9016 gradcorr6_long(ll,l)=gradcorr6_long(ll,l)+gradcorr6kl
9017 gradcorr6_long(ll,k)=gradcorr6_long(ll,k)-gradcorr6kl
9022 !old gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*ekl*gacont_hbr(ll,jj,i)
9023 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ggg1(ll)
9028 !old gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*eij*gacont_hbr(ll,kk,k)
9029 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ggg2(ll)
9035 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,1)
9040 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,2)
9044 !d write (2,*) iii,g_corr6_loc(iii)
9047 !d write (2,*) 'ekont',ekont
9048 !d write (iout,*) 'eello6',ekont*eel6
9051 !-----------------------------------------------------------------------------
9052 real(kind=8) function eello6_graph1(i,j,k,l,imat,swap)
9054 ! implicit real*8 (a-h,o-z)
9055 ! include 'DIMENSIONS'
9056 ! include 'COMMON.IOUNITS'
9057 ! include 'COMMON.CHAIN'
9058 ! include 'COMMON.DERIV'
9059 ! include 'COMMON.INTERACT'
9060 ! include 'COMMON.CONTACTS'
9061 ! include 'COMMON.TORSION'
9062 ! include 'COMMON.VAR'
9063 ! include 'COMMON.GEO'
9064 real(kind=8),dimension(2) :: vv,vv1
9065 real(kind=8),dimension(2,2) :: pizda,auxmat,pizda1
9068 !el common /kutas/ lprn
9069 integer :: i,j,k,l,imat,itk,iii,kkk,lll,ind
9070 real(kind=8) :: s1,s2,s3,s4,s5
9071 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9073 ! Parallel Antiparallel C
9079 ! \ j|/k\| / \ |/k\|l / C
9084 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9085 itk=itortyp(itype(k,1))
9086 s1= scalar2(AEAb1(1,2,imat),CUgb2(1,i))
9087 s2=-scalar2(AEAb2(1,1,imat),Ug2Db1t(1,k))
9088 s3= scalar2(AEAb2(1,1,imat),CUgb2(1,k))
9089 call transpose2(EUgC(1,1,k),auxmat(1,1))
9090 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
9091 vv1(1)=pizda1(1,1)-pizda1(2,2)
9092 vv1(2)=pizda1(1,2)+pizda1(2,1)
9093 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
9094 vv(1)=AEAb1(1,2,imat)*b1(1,itk)-AEAb1(2,2,imat)*b1(2,itk)
9095 vv(2)=AEAb1(1,2,imat)*b1(2,itk)+AEAb1(2,2,imat)*b1(1,itk)
9096 s5=scalar2(vv(1),Dtobr2(1,i))
9097 !d write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4', s4,' s5',s5
9098 eello6_graph1=-0.5d0*(s1+s2+s3+s4+s5)
9099 if (i.gt.1) g_corr6_loc(i-1)=g_corr6_loc(i-1) &
9100 -0.5d0*ekont*(scalar2(AEAb1(1,2,imat),CUgb2der(1,i)) &
9101 -scalar2(AEAb2derg(1,2,1,imat),Ug2Db1t(1,k)) &
9102 +scalar2(AEAb2derg(1,2,1,imat),CUgb2(1,k)) &
9103 +0.5d0*scalar2(vv1(1),Dtobr2der(1,i)) &
9104 +scalar2(vv(1),Dtobr2der(1,i)))
9105 call matmat2(AEAderg(1,1,imat),auxmat(1,1),pizda1(1,1))
9106 vv1(1)=pizda1(1,1)-pizda1(2,2)
9107 vv1(2)=pizda1(1,2)+pizda1(2,1)
9108 vv(1)=AEAb1derg(1,2,imat)*b1(1,itk)-AEAb1derg(2,2,imat)*b1(2,itk)
9109 vv(2)=AEAb1derg(1,2,imat)*b1(2,itk)+AEAb1derg(2,2,imat)*b1(1,itk)
9111 g_corr6_loc(l-1)=g_corr6_loc(l-1) &
9112 +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i)) &
9113 -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k)) &
9114 +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k)) &
9115 +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
9117 g_corr6_loc(j-1)=g_corr6_loc(j-1) &
9118 +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i)) &
9119 -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k)) &
9120 +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k)) &
9121 +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
9123 call transpose2(EUgCder(1,1,k),auxmat(1,1))
9124 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
9125 vv1(1)=pizda1(1,1)-pizda1(2,2)
9126 vv1(2)=pizda1(1,2)+pizda1(2,1)
9127 if (k.gt.1) g_corr6_loc(k-1)=g_corr6_loc(k-1) &
9128 +ekont*(-0.5d0*(-scalar2(AEAb2(1,1,imat),Ug2Db1tder(1,k)) &
9129 +scalar2(AEAb2(1,1,imat),CUgb2der(1,k)) &
9130 +0.5d0*scalar2(vv1(1),Dtobr2(1,i))))
9139 s1= scalar2(AEAb1derx(1,lll,kkk,iii,2,imat),CUgb2(1,i))
9140 s2=-scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),Ug2Db1t(1,k))
9141 s3= scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),CUgb2(1,k))
9142 call transpose2(EUgC(1,1,k),auxmat(1,1))
9143 call matmat2(AEAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),&
9145 vv1(1)=pizda1(1,1)-pizda1(2,2)
9146 vv1(2)=pizda1(1,2)+pizda1(2,1)
9147 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
9148 vv(1)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(1,itk) &
9149 -AEAb1derx(2,lll,kkk,iii,2,imat)*b1(2,itk)
9150 vv(2)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(2,itk) &
9151 +AEAb1derx(2,lll,kkk,iii,2,imat)*b1(1,itk)
9152 s5=scalar2(vv(1),Dtobr2(1,i))
9153 derx(lll,kkk,ind)=derx(lll,kkk,ind)-0.5d0*(s1+s2+s3+s4+s5)
9158 end function eello6_graph1
9159 !-----------------------------------------------------------------------------
9160 real(kind=8) function eello6_graph2(i,j,k,l,jj,kk,swap)
9162 ! implicit real*8 (a-h,o-z)
9163 ! include 'DIMENSIONS'
9164 ! include 'COMMON.IOUNITS'
9165 ! include 'COMMON.CHAIN'
9166 ! include 'COMMON.DERIV'
9167 ! include 'COMMON.INTERACT'
9168 ! include 'COMMON.CONTACTS'
9169 ! include 'COMMON.TORSION'
9170 ! include 'COMMON.VAR'
9171 ! include 'COMMON.GEO'
9173 real(kind=8),dimension(2) :: vv,auxvec,auxvec1,auxvec2
9174 real(kind=8),dimension(2,2) :: pizda,auxmat,auxmat1
9176 !el common /kutas/ lprn
9177 integer :: i,j,k,l,jj,kk,iii,kkk,lll,jjj,mmm
9178 real(kind=8) :: s2,s3,s4
9179 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9181 ! Parallel Antiparallel C
9187 ! \ j|/k\| \ |/k\|l C
9192 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9193 !d write (2,*) 'eello6_graph2: i,',i,' j',j,' k',k,' l',l
9194 ! AL 7/4/01 s1 would occur in the sixth-order moment,
9195 ! but not in a cluster cumulant
9197 s1=dip(1,jj,i)*dip(1,kk,k)
9199 call matvec2(ADtEA1(1,1,1),Ub2(1,k),auxvec(1))
9200 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
9201 call matvec2(ADtEA(1,1,2),Ub2(1,l),auxvec1(1))
9202 s3=-0.5d0*scalar2(Ub2(1,j),auxvec1(1))
9203 call transpose2(EUg(1,1,k),auxmat(1,1))
9204 call matmat2(ADtEA1(1,1,1),auxmat(1,1),pizda(1,1))
9205 vv(1)=pizda(1,1)-pizda(2,2)
9206 vv(2)=pizda(1,2)+pizda(2,1)
9207 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9208 !d write (2,*) 'eello6_graph2:','s1',s1,' s2',s2,' s3',s3,' s4',s4
9210 eello6_graph2=-(s1+s2+s3+s4)
9212 eello6_graph2=-(s2+s3+s4)
9215 ! Derivatives in gamma(i-1)
9218 s1=dipderg(1,jj,i)*dip(1,kk,k)
9220 s2=-0.5d0*scalar2(Ub2der(1,i),auxvec(1))
9221 call matvec2(ADtEAderg(1,1,1,2),Ub2(1,l),auxvec2(1))
9222 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
9223 s4=-0.25d0*scalar2(vv(1),Dtobr2der(1,i))
9225 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
9227 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
9229 ! g_corr6_loc(i-1)=g_corr6_loc(i-1)-s3
9231 ! Derivatives in gamma(k-1)
9233 s1=dip(1,jj,i)*dipderg(1,kk,k)
9235 call matvec2(ADtEA1(1,1,1),Ub2der(1,k),auxvec2(1))
9236 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
9237 call matvec2(ADtEAderg(1,1,2,2),Ub2(1,l),auxvec2(1))
9238 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
9239 call transpose2(EUgder(1,1,k),auxmat1(1,1))
9240 call matmat2(ADtEA1(1,1,1),auxmat1(1,1),pizda(1,1))
9241 vv(1)=pizda(1,1)-pizda(2,2)
9242 vv(2)=pizda(1,2)+pizda(2,1)
9243 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9245 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
9247 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
9249 ! g_corr6_loc(k-1)=g_corr6_loc(k-1)-s3
9250 ! Derivatives in gamma(j-1) or gamma(l-1)
9253 s1=dipderg(3,jj,i)*dip(1,kk,k)
9255 call matvec2(ADtEA1derg(1,1,1,1),Ub2(1,k),auxvec2(1))
9256 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
9257 s3=-0.5d0*scalar2(Ub2der(1,j),auxvec1(1))
9258 call matmat2(ADtEA1derg(1,1,1,1),auxmat(1,1),pizda(1,1))
9259 vv(1)=pizda(1,1)-pizda(2,2)
9260 vv(2)=pizda(1,2)+pizda(2,1)
9261 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9264 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
9266 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
9269 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s3+s4)
9270 ! g_corr6_loc(j-1)=g_corr6_loc(j-1)-s3
9272 ! Derivatives in gamma(l-1) or gamma(j-1)
9275 s1=dip(1,jj,i)*dipderg(3,kk,k)
9277 call matvec2(ADtEA1derg(1,1,2,1),Ub2(1,k),auxvec2(1))
9278 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
9279 call matvec2(ADtEA(1,1,2),Ub2der(1,l),auxvec2(1))
9280 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
9281 call matmat2(ADtEA1derg(1,1,2,1),auxmat(1,1),pizda(1,1))
9282 vv(1)=pizda(1,1)-pizda(2,2)
9283 vv(2)=pizda(1,2)+pizda(2,1)
9284 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9287 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
9289 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
9292 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s3+s4)
9293 ! g_corr6_loc(l-1)=g_corr6_loc(l-1)-s3
9295 ! Cartesian derivatives.
9297 write (2,*) 'In eello6_graph2'
9299 write (2,*) 'iii=',iii
9301 write (2,*) 'kkk=',kkk
9303 write (2,'(3(2f10.5),5x)') &
9304 ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
9314 s1=dipderx(lll,kkk,1,jj,i)*dip(1,kk,k)
9316 s1=dip(1,jj,i)*dipderx(lll,kkk,1,kk,k)
9319 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,1),Ub2(1,k),&
9321 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
9322 call matvec2(ADtEAderx(1,1,lll,kkk,iii,2),Ub2(1,l),&
9324 s3=-0.5d0*scalar2(Ub2(1,j),auxvec(1))
9325 call transpose2(EUg(1,1,k),auxmat(1,1))
9326 call matmat2(ADtEA1derx(1,1,lll,kkk,iii,1),auxmat(1,1),&
9328 vv(1)=pizda(1,1)-pizda(2,2)
9329 vv(2)=pizda(1,2)+pizda(2,1)
9330 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9331 !d write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4',s4
9333 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
9335 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
9338 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
9340 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
9346 end function eello6_graph2
9347 !-----------------------------------------------------------------------------
9348 real(kind=8) function eello6_graph3(i,j,k,l,jj,kk,swap)
9349 ! implicit real*8 (a-h,o-z)
9350 ! include 'DIMENSIONS'
9351 ! include 'COMMON.IOUNITS'
9352 ! include 'COMMON.CHAIN'
9353 ! include 'COMMON.DERIV'
9354 ! include 'COMMON.INTERACT'
9355 ! include 'COMMON.CONTACTS'
9356 ! include 'COMMON.TORSION'
9357 ! include 'COMMON.VAR'
9358 ! include 'COMMON.GEO'
9359 real(kind=8),dimension(2) :: vv,auxvec
9360 real(kind=8),dimension(2,2) :: pizda,auxmat
9362 integer :: i,j,k,l,jj,kk,iti,itj1,itk,itk1,iii,lll,kkk,itl1
9363 real(kind=8) :: s1,s2,s3,s4
9364 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9366 ! Parallel Antiparallel C
9372 ! j|/k\| / |/k\|l / C
9377 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9379 ! 4/7/01 AL Component s1 was removed, because it pertains to the respective
9380 ! energy moment and not to the cluster cumulant.
9381 iti=itortyp(itype(i,1))
9382 if (j.lt.nres-1) then
9383 itj1=itortyp(itype(j+1,1))
9387 itk=itortyp(itype(k,1))
9388 itk1=itortyp(itype(k+1,1))
9389 if (l.lt.nres-1) then
9390 itl1=itortyp(itype(l+1,1))
9395 s1=dip(4,jj,i)*dip(4,kk,k)
9397 call matvec2(AECA(1,1,1),b1(1,itk1),auxvec(1))
9398 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
9399 call matvec2(AECA(1,1,2),b1(1,itl1),auxvec(1))
9400 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
9401 call transpose2(EE(1,1,itk),auxmat(1,1))
9402 call matmat2(auxmat(1,1),AECA(1,1,1),pizda(1,1))
9403 vv(1)=pizda(1,1)+pizda(2,2)
9404 vv(2)=pizda(2,1)-pizda(1,2)
9405 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
9406 !d write (2,*) 'eello6_graph3:','s1',s1,' s2',s2,' s3',s3,' s4',s4,
9407 !d & "sum",-(s2+s3+s4)
9409 eello6_graph3=-(s1+s2+s3+s4)
9411 eello6_graph3=-(s2+s3+s4)
9414 ! Derivatives in gamma(k-1)
9415 call matvec2(AECAderg(1,1,2),b1(1,itl1),auxvec(1))
9416 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
9417 s4=-0.25d0*scalar2(vv(1),Ctobrder(1,k))
9418 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s3+s4)
9419 ! Derivatives in gamma(l-1)
9420 call matvec2(AECAderg(1,1,1),b1(1,itk1),auxvec(1))
9421 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
9422 call matmat2(auxmat(1,1),AECAderg(1,1,1),pizda(1,1))
9423 vv(1)=pizda(1,1)+pizda(2,2)
9424 vv(2)=pizda(2,1)-pizda(1,2)
9425 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
9426 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
9427 ! Cartesian derivatives.
9433 s1=dipderx(lll,kkk,4,jj,i)*dip(4,kk,k)
9435 s1=dip(4,jj,i)*dipderx(lll,kkk,4,kk,k)
9438 call matvec2(AECAderx(1,1,lll,kkk,iii,1),b1(1,itk1),&
9440 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
9441 call matvec2(AECAderx(1,1,lll,kkk,iii,2),b1(1,itl1),&
9443 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
9444 call matmat2(auxmat(1,1),AECAderx(1,1,lll,kkk,iii,1),&
9446 vv(1)=pizda(1,1)+pizda(2,2)
9447 vv(2)=pizda(2,1)-pizda(1,2)
9448 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
9450 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
9452 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
9455 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
9457 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
9459 ! derx(lll,kkk,iii)=derx(lll,kkk,iii)-s4
9464 end function eello6_graph3
9465 !-----------------------------------------------------------------------------
9466 real(kind=8) function eello6_graph4(i,j,k,l,jj,kk,imat,swap)
9467 ! implicit real*8 (a-h,o-z)
9468 ! include 'DIMENSIONS'
9469 ! include 'COMMON.IOUNITS'
9470 ! include 'COMMON.CHAIN'
9471 ! include 'COMMON.DERIV'
9472 ! include 'COMMON.INTERACT'
9473 ! include 'COMMON.CONTACTS'
9474 ! include 'COMMON.TORSION'
9475 ! include 'COMMON.VAR'
9476 ! include 'COMMON.GEO'
9477 ! include 'COMMON.FFIELD'
9478 real(kind=8),dimension(2) :: vv,auxvec,auxvec1
9479 real(kind=8),dimension(2,2) :: pizda,auxmat,auxmat1
9481 integer :: i,j,k,l,jj,kk,imat,iti,itj,itj1,itk,itk1,itl,itl1,&
9483 real(kind=8) :: s1,s2,s3,s4
9484 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9486 ! Parallel Antiparallel C
9492 ! \ j|/k\| \ |/k\|l C
9497 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9499 ! 4/7/01 AL Component s1 was removed, because it pertains to the respective
9500 ! energy moment and not to the cluster cumulant.
9501 !d write (2,*) 'eello_graph4: wturn6',wturn6
9502 iti=itortyp(itype(i,1))
9503 itj=itortyp(itype(j,1))
9504 if (j.lt.nres-1) then
9505 itj1=itortyp(itype(j+1,1))
9509 itk=itortyp(itype(k,1))
9510 if (k.lt.nres-1) then
9511 itk1=itortyp(itype(k+1,1))
9515 itl=itortyp(itype(l,1))
9516 if (l.lt.nres-1) then
9517 itl1=itortyp(itype(l+1,1))
9521 !d write (2,*) 'eello6_graph4:','i',i,' j',j,' k',k,' l',l
9522 !d write (2,*) 'iti',iti,' itj',itj,' itj1',itj1,' itk',itk,
9523 !d & ' itl',itl,' itl1',itl1
9526 s1=dip(3,jj,i)*dip(3,kk,k)
9528 s1=dip(2,jj,j)*dip(2,kk,l)
9531 call matvec2(AECA(1,1,imat),Ub2(1,k),auxvec(1))
9532 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
9534 call matvec2(ADtEA1(1,1,3-imat),b1(1,itj1),auxvec1(1))
9535 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
9537 call matvec2(ADtEA1(1,1,3-imat),b1(1,itl1),auxvec1(1))
9538 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
9540 call transpose2(EUg(1,1,k),auxmat(1,1))
9541 call matmat2(AECA(1,1,imat),auxmat(1,1),pizda(1,1))
9542 vv(1)=pizda(1,1)-pizda(2,2)
9543 vv(2)=pizda(2,1)+pizda(1,2)
9544 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
9545 !d write (2,*) 'eello6_graph4:','s1',s1,' s2',s2,' s3',s3,' s4',s4
9547 eello6_graph4=-(s1+s2+s3+s4)
9549 eello6_graph4=-(s2+s3+s4)
9551 ! Derivatives in gamma(i-1)
9555 s1=dipderg(2,jj,i)*dip(3,kk,k)
9557 s1=dipderg(4,jj,j)*dip(2,kk,l)
9560 s2=0.5d0*scalar2(Ub2der(1,i),auxvec(1))
9562 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,itj1),auxvec1(1))
9563 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
9565 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,itl1),auxvec1(1))
9566 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
9568 s4=0.25d0*scalar2(vv(1),Dtobr2der(1,i))
9569 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
9570 !d write (2,*) 'turn6 derivatives'
9572 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s1+s2+s3+s4)
9574 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s2+s3+s4)
9578 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
9580 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
9584 ! Derivatives in gamma(k-1)
9587 s1=dip(3,jj,i)*dipderg(2,kk,k)
9589 s1=dip(2,jj,j)*dipderg(4,kk,l)
9592 call matvec2(AECA(1,1,imat),Ub2der(1,k),auxvec1(1))
9593 s2=0.5d0*scalar2(Ub2(1,i),auxvec1(1))
9595 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,itj1),auxvec1(1))
9596 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
9598 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,itl1),auxvec1(1))
9599 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
9601 call transpose2(EUgder(1,1,k),auxmat1(1,1))
9602 call matmat2(AECA(1,1,imat),auxmat1(1,1),pizda(1,1))
9603 vv(1)=pizda(1,1)-pizda(2,2)
9604 vv(2)=pizda(2,1)+pizda(1,2)
9605 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
9606 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
9608 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s1+s2+s3+s4)
9610 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s2+s3+s4)
9614 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
9616 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
9619 ! Derivatives in gamma(j-1) or gamma(l-1)
9620 if (l.eq.j+1 .and. l.gt.1) then
9621 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
9622 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
9623 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
9624 vv(1)=pizda(1,1)-pizda(2,2)
9625 vv(2)=pizda(2,1)+pizda(1,2)
9626 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
9627 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
9628 else if (j.gt.1) then
9629 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
9630 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
9631 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
9632 vv(1)=pizda(1,1)-pizda(2,2)
9633 vv(2)=pizda(2,1)+pizda(1,2)
9634 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
9635 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
9636 gel_loc_turn6(j-1)=gel_loc_turn6(j-1)-ekont*(s2+s4)
9638 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s4)
9641 ! Cartesian derivatives.
9648 s1=dipderx(lll,kkk,3,jj,i)*dip(3,kk,k)
9650 s1=dipderx(lll,kkk,2,jj,j)*dip(2,kk,l)
9654 s1=dip(3,jj,i)*dipderx(lll,kkk,3,kk,k)
9656 s1=dip(2,jj,j)*dipderx(lll,kkk,2,kk,l)
9660 call matvec2(AECAderx(1,1,lll,kkk,iii,imat),Ub2(1,k),&
9662 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
9664 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),&
9665 b1(1,itj1),auxvec(1))
9666 s3=-0.5d0*scalar2(b1(1,itj),auxvec(1))
9668 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),&
9669 b1(1,itl1),auxvec(1))
9670 s3=-0.5d0*scalar2(b1(1,itl),auxvec(1))
9672 call matmat2(AECAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),&
9674 vv(1)=pizda(1,1)-pizda(2,2)
9675 vv(2)=pizda(2,1)+pizda(1,2)
9676 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
9678 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
9680 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii) &
9683 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii) &
9686 derx_turn(lll,kkk,iii)=derx_turn(lll,kkk,iii)-s3
9689 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s1+s2+s4)
9691 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s2+s4)
9693 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
9697 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
9699 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
9702 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
9704 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
9711 end function eello6_graph4
9712 !-----------------------------------------------------------------------------
9713 real(kind=8) function eello_turn6(i,jj,kk)
9714 ! implicit real*8 (a-h,o-z)
9715 ! include 'DIMENSIONS'
9716 ! include 'COMMON.IOUNITS'
9717 ! include 'COMMON.CHAIN'
9718 ! include 'COMMON.DERIV'
9719 ! include 'COMMON.INTERACT'
9720 ! include 'COMMON.CONTACTS'
9721 ! include 'COMMON.TORSION'
9722 ! include 'COMMON.VAR'
9723 ! include 'COMMON.GEO'
9724 real(kind=8),dimension(2) :: vtemp1,vtemp2,vtemp3,vtemp4,gvec
9725 real(kind=8),dimension(2,2) :: atemp,auxmat,achuj_temp,gtemp
9726 real(kind=8),dimension(3) :: ggg1,ggg2
9727 real(kind=8),dimension(2) :: vtemp1d,vtemp2d,vtemp3d,vtemp4d,gvecd
9728 real(kind=8),dimension(2,2) :: atempd,auxmatd,achuj_tempd,gtempd
9729 ! 4/7/01 AL Components s1, s8, and s13 were removed, because they pertain to
9730 ! the respective energy moment and not to the cluster cumulant.
9732 integer :: i,jj,kk,j,k,l,iti,itk,itk1,itl,itj,iii,kkk,lll
9733 integer :: j1,j2,l1,l2,ll
9734 real(kind=8) :: s1,s2,s8,s13,s12,eello6_5,eel_turn6
9735 real(kind=8) :: s1d,s8d,s12d,s2d,gturn6ij,gturn6kl
9744 iti=itortyp(itype(i,1))
9745 itk=itortyp(itype(k,1))
9746 itk1=itortyp(itype(k+1,1))
9747 itl=itortyp(itype(l,1))
9748 itj=itortyp(itype(j,1))
9749 !d write (2,*) 'itk',itk,' itk1',itk1,' itl',itl,' itj',itj
9750 !d write (2,*) 'i',i,' k',k,' j',j,' l',l
9751 !d if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
9756 !d & 'EELLO6: Contacts have occurred for peptide groups',i,j,
9758 !d call checkint_turn6(i,jj,kk,eel_turn6_num)
9762 derx_turn(lll,kkk,iii)=0.0d0
9769 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
9771 !d write (2,*) 'eello6_5',eello6_5
9773 call transpose2(AEA(1,1,1),auxmat(1,1))
9774 call matmat2(EUg(1,1,i+1),auxmat(1,1),auxmat(1,1))
9775 ss1=scalar2(Ub2(1,i+2),b1(1,itl))
9776 s1 = (auxmat(1,1)+auxmat(2,2))*ss1
9778 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1(1))
9779 call matvec2(AEA(1,1,1),vtemp1(1),vtemp1(1))
9780 s2 = scalar2(b1(1,itk),vtemp1(1))
9782 call transpose2(AEA(1,1,2),atemp(1,1))
9783 call matmat2(atemp(1,1),EUg(1,1,i+4),atemp(1,1))
9784 call matvec2(Ug2(1,1,i+2),dd(1,1,itk1),vtemp2(1))
9785 s8 = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
9787 call matmat2(EUg(1,1,i+3),AEA(1,1,2),auxmat(1,1))
9788 call matvec2(auxmat(1,1),Ub2(1,i+4),vtemp3(1))
9789 s12 = scalar2(Ub2(1,i+2),vtemp3(1))
9791 call transpose2(a_chuj(1,1,kk,i+1),achuj_temp(1,1))
9792 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtemp(1,1))
9793 call matmat2(gtemp(1,1),EUg(1,1,i+3),gtemp(1,1))
9794 call matvec2(a_chuj(1,1,jj,i),Ub2(1,i+4),vtemp4(1))
9795 ss13 = scalar2(b1(1,itk),vtemp4(1))
9796 s13 = (gtemp(1,1)+gtemp(2,2))*ss13
9798 ! write (2,*) 's1,s2,s8,s12,s13',s1,s2,s8,s12,s13
9804 eel_turn6 = eello6_5 - 0.5d0*(s1+s2+s12+s8+s13)
9805 ! Derivatives in gamma(i+2)
9809 call transpose2(AEA(1,1,1),auxmatd(1,1))
9810 call matmat2(EUgder(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
9811 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
9812 call transpose2(AEAderg(1,1,2),atempd(1,1))
9813 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
9814 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
9816 call matmat2(EUg(1,1,i+3),AEAderg(1,1,2),auxmatd(1,1))
9817 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
9818 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
9824 gel_loc_turn6(i)=gel_loc_turn6(i)-0.5d0*ekont*(s1d+s8d+s12d)
9825 ! Derivatives in gamma(i+3)
9827 call transpose2(AEA(1,1,1),auxmatd(1,1))
9828 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
9829 ss1d=scalar2(Ub2der(1,i+2),b1(1,itl))
9830 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1d
9832 call matvec2(EUgder(1,1,i+2),b1(1,itl),vtemp1d(1))
9833 call matvec2(AEA(1,1,1),vtemp1d(1),vtemp1d(1))
9834 s2d = scalar2(b1(1,itk),vtemp1d(1))
9836 call matvec2(Ug2der(1,1,i+2),dd(1,1,itk1),vtemp2d(1))
9837 s8d = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,itl),vtemp2d(1))
9839 s12d = scalar2(Ub2der(1,i+2),vtemp3(1))
9841 call matmat2(achuj_temp(1,1),EUgder(1,1,i+2),gtempd(1,1))
9842 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
9843 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
9851 gel_loc_turn6(i+1)=gel_loc_turn6(i+1) &
9852 -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
9854 gel_loc_turn6(i+1)=gel_loc_turn6(i+1) &
9855 -0.5d0*ekont*(s2d+s12d)
9857 ! Derivatives in gamma(i+4)
9858 call matmat2(EUgder(1,1,i+3),AEA(1,1,2),auxmatd(1,1))
9859 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
9860 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
9862 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtempd(1,1))
9863 call matmat2(gtempd(1,1),EUgder(1,1,i+3),gtempd(1,1))
9864 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
9872 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d+s13d)
9874 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d)
9876 ! Derivatives in gamma(i+5)
9878 call transpose2(AEAderg(1,1,1),auxmatd(1,1))
9879 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
9880 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
9882 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1d(1))
9883 call matvec2(AEAderg(1,1,1),vtemp1d(1),vtemp1d(1))
9884 s2d = scalar2(b1(1,itk),vtemp1d(1))
9886 call transpose2(AEA(1,1,2),atempd(1,1))
9887 call matmat2(atempd(1,1),EUgder(1,1,i+4),atempd(1,1))
9888 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
9890 call matvec2(auxmat(1,1),Ub2der(1,i+4),vtemp3d(1))
9891 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
9893 call matvec2(a_chuj(1,1,jj,i),Ub2der(1,i+4),vtemp4d(1))
9894 ss13d = scalar2(b1(1,itk),vtemp4d(1))
9895 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
9903 gel_loc_turn6(i+3)=gel_loc_turn6(i+3) &
9904 -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
9906 gel_loc_turn6(i+3)=gel_loc_turn6(i+3) &
9907 -0.5d0*ekont*(s2d+s12d)
9909 ! Cartesian derivatives
9914 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmatd(1,1))
9915 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
9916 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
9918 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1(1))
9919 call matvec2(AEAderx(1,1,lll,kkk,iii,1),vtemp1(1),&
9921 s2d = scalar2(b1(1,itk),vtemp1d(1))
9923 call transpose2(AEAderx(1,1,lll,kkk,iii,2),atempd(1,1))
9924 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
9925 s8d = -(atempd(1,1)+atempd(2,2))* &
9926 scalar2(cc(1,1,itl),vtemp2(1))
9928 call matmat2(EUg(1,1,i+3),AEAderx(1,1,lll,kkk,iii,2),&
9930 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
9931 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
9938 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii) &
9941 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii) &
9945 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii) &
9948 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii) &
9957 call transpose2(a_chuj_der(1,1,lll,kkk,kk,i+1),&
9959 call matmat2(achuj_tempd(1,1),EUg(1,1,i+2),gtempd(1,1))
9960 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
9961 s13d=(gtempd(1,1)+gtempd(2,2))*ss13
9962 derx_turn(lll,kkk,2) = derx_turn(lll,kkk,2)-0.5d0*s13d
9963 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),Ub2(1,i+4),&
9965 ss13d = scalar2(b1(1,itk),vtemp4d(1))
9966 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
9967 derx_turn(lll,kkk,1) = derx_turn(lll,kkk,1)-0.5d0*s13d
9971 !d write(iout,*) 'eel6_turn6',eel_turn6,' eel_turn6_num',
9972 !d & 16*eel_turn6_num
9974 if (j.lt.nres-1) then
9981 if (l.lt.nres-1) then
9989 !grad ggg1(ll)=eel_turn6*g_contij(ll,1)
9990 !grad ggg2(ll)=eel_turn6*g_contij(ll,2)
9991 !grad ghalf=0.5d0*ggg1(ll)
9993 gturn6ij=eel_turn6*g_contij(ll,1)+ekont*derx_turn(ll,1,1)
9994 gturn6kl=eel_turn6*g_contij(ll,2)+ekont*derx_turn(ll,1,2)
9995 gcorr6_turn(ll,i)=gcorr6_turn(ll,i) & !+ghalf
9996 +ekont*derx_turn(ll,2,1)
9997 gcorr6_turn(ll,i+1)=gcorr6_turn(ll,i+1)+ekont*derx_turn(ll,3,1)
9998 gcorr6_turn(ll,j)=gcorr6_turn(ll,j) & !+ghalf
9999 +ekont*derx_turn(ll,4,1)
10000 gcorr6_turn(ll,j1)=gcorr6_turn(ll,j1)+ekont*derx_turn(ll,5,1)
10001 gcorr6_turn_long(ll,j)=gcorr6_turn_long(ll,j)+gturn6ij
10002 gcorr6_turn_long(ll,i)=gcorr6_turn_long(ll,i)-gturn6ij
10003 !grad ghalf=0.5d0*ggg2(ll)
10005 gcorr6_turn(ll,k)=gcorr6_turn(ll,k) & !+ghalf
10006 +ekont*derx_turn(ll,2,2)
10007 gcorr6_turn(ll,k+1)=gcorr6_turn(ll,k+1)+ekont*derx_turn(ll,3,2)
10008 gcorr6_turn(ll,l)=gcorr6_turn(ll,l) & !+ghalf
10009 +ekont*derx_turn(ll,4,2)
10010 gcorr6_turn(ll,l1)=gcorr6_turn(ll,l1)+ekont*derx_turn(ll,5,2)
10011 gcorr6_turn_long(ll,l)=gcorr6_turn_long(ll,l)+gturn6kl
10012 gcorr6_turn_long(ll,k)=gcorr6_turn_long(ll,k)-gturn6kl
10017 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg1(ll)
10022 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg2(ll)
10028 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,1)
10033 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,2)
10037 !d write (2,*) iii,g_corr6_loc(iii)
10039 eello_turn6=ekont*eel_turn6
10040 !d write (2,*) 'ekont',ekont
10041 !d write (2,*) 'eel_turn6',ekont*eel_turn6
10043 end function eello_turn6
10044 !-----------------------------------------------------------------------------
10045 subroutine MATVEC2(A1,V1,V2)
10046 !DIR$ INLINEALWAYS MATVEC2
10048 !DEC$ ATTRIBUTES FORCEINLINE::MATVEC2
10050 ! implicit real*8 (a-h,o-z)
10051 ! include 'DIMENSIONS'
10052 real(kind=8),dimension(2) :: V1,V2
10053 real(kind=8),dimension(2,2) :: A1
10054 real(kind=8) :: vaux1,vaux2
10058 ! 3 VI=VI+A1(I,K)*V1(K)
10062 vaux1=a1(1,1)*v1(1)+a1(1,2)*v1(2)
10063 vaux2=a1(2,1)*v1(1)+a1(2,2)*v1(2)
10067 end subroutine MATVEC2
10068 !-----------------------------------------------------------------------------
10069 subroutine MATMAT2(A1,A2,A3)
10071 !DEC$ ATTRIBUTES FORCEINLINE::MATMAT2
10073 ! implicit real*8 (a-h,o-z)
10074 ! include 'DIMENSIONS'
10075 real(kind=8),dimension(2,2) :: A1,A2,A3
10076 real(kind=8) :: ai3_11,ai3_12,ai3_21,ai3_22
10077 ! DIMENSION AI3(2,2)
10081 ! A3IJ=A3IJ+A1(I,K)*A2(K,J)
10087 ai3_11=a1(1,1)*a2(1,1)+a1(1,2)*a2(2,1)
10088 ai3_12=a1(1,1)*a2(1,2)+a1(1,2)*a2(2,2)
10089 ai3_21=a1(2,1)*a2(1,1)+a1(2,2)*a2(2,1)
10090 ai3_22=a1(2,1)*a2(1,2)+a1(2,2)*a2(2,2)
10096 end subroutine MATMAT2
10097 !-----------------------------------------------------------------------------
10098 real(kind=8) function scalar2(u,v)
10099 !DIR$ INLINEALWAYS scalar2
10101 real(kind=8),dimension(2) :: u,v
10104 scalar2=u(1)*v(1)+u(2)*v(2)
10106 end function scalar2
10107 !-----------------------------------------------------------------------------
10108 subroutine transpose2(a,at)
10109 !DIR$ INLINEALWAYS transpose2
10111 !DEC$ ATTRIBUTES FORCEINLINE::transpose2
10114 real(kind=8),dimension(2,2) :: a,at
10120 end subroutine transpose2
10121 !-----------------------------------------------------------------------------
10122 subroutine transpose(n,a,at)
10125 real(kind=8),dimension(n,n) :: a,at
10132 end subroutine transpose
10133 !-----------------------------------------------------------------------------
10134 subroutine prodmat3(a1,a2,kk,transp,prod)
10135 !DIR$ INLINEALWAYS prodmat3
10137 !DEC$ ATTRIBUTES FORCEINLINE::prodmat3
10141 real(kind=8),dimension(2,2) :: a1,a2,a2t,kk,prod
10143 !rc double precision auxmat(2,2),prod_(2,2)
10146 !rc call transpose2(kk(1,1),auxmat(1,1))
10147 !rc call matmat2(a1(1,1),auxmat(1,1),auxmat(1,1))
10148 !rc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
10150 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,1) &
10151 +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,1)
10152 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,2) &
10153 +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,2)
10154 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,1) &
10155 +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,1)
10156 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,2) &
10157 +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,2)
10160 !rc call matmat2(a1(1,1),kk(1,1),auxmat(1,1))
10161 !rc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
10163 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,1) &
10164 +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,1)
10165 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,2) &
10166 +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,2)
10167 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,1) &
10168 +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,1)
10169 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,2) &
10170 +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,2)
10173 ! call transpose2(a2(1,1),a2t(1,1))
10176 !rc print *,((prod_(i,j),i=1,2),j=1,2)
10177 !rc print *,((prod(i,j),i=1,2),j=1,2)
10180 end subroutine prodmat3
10181 !-----------------------------------------------------------------------------
10182 ! energy_p_new_barrier.F
10183 !-----------------------------------------------------------------------------
10184 subroutine sum_gradient
10185 ! implicit real*8 (a-h,o-z)
10186 use io_base, only: pdbout
10187 ! include 'DIMENSIONS'
10191 !MS$ATTRIBUTES C :: proc_proc
10197 real(kind=8),dimension(3,-1:nres) :: gradbufc,gradbufx,gradbufc_sum,&
10198 gloc_scbuf !(3,maxres)
10200 real(kind=8),dimension(4*nres) :: glocbuf !(4*maxres)
10202 !el local variables
10203 integer :: i,j,k,ierror,ierr
10204 real(kind=8) :: gvdwc_norm,gvdwc_scp_norm,gelc_norm,gvdwpp_norm,&
10205 gradb_norm,ghpbc_norm,gradcorr_norm,gel_loc_norm,&
10206 gcorr3_turn_norm,gcorr4_turn_norm,gradcorr5_norm,&
10207 gradcorr6_norm,gcorr6_turn_norm,gsccorr_norm,&
10208 gscloc_norm,gvdwx_norm,gradx_scp_norm,ghpbx_norm,&
10209 gradxorr_norm,gsccorrx_norm,gsclocx_norm,gcorr6_max,&
10210 gsccorr_max,gsccorrx_max,time00
10212 ! include 'COMMON.SETUP'
10213 ! include 'COMMON.IOUNITS'
10214 ! include 'COMMON.FFIELD'
10215 ! include 'COMMON.DERIV'
10216 ! include 'COMMON.INTERACT'
10217 ! include 'COMMON.SBRIDGE'
10218 ! include 'COMMON.CHAIN'
10219 ! include 'COMMON.VAR'
10220 ! include 'COMMON.CONTROL'
10221 ! include 'COMMON.TIME1'
10222 ! include 'COMMON.MAXGRAD'
10223 ! include 'COMMON.SCCOR'
10228 write (iout,*) "sum_gradient gvdwc, gvdwx"
10230 write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)') &
10231 i,(gvdwx(j,i),j=1,3),(gvdwc(j,i),j=1,3)
10241 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
10242 if (nfgtasks.gt.1 .and. fg_rank.eq.0) &
10243 call MPI_Bcast(1,1,MPI_INTEGER,king,FG_COMM,IERROR)
10246 ! 9/29/08 AL Transform parts of gradients in site coordinates to the gradient
10247 ! in virtual-bond-vector coordinates
10250 ! write (iout,*) "gel_loc gel_loc_long and gel_loc_loc"
10252 ! write (iout,'(i5,3f10.5,2x,3f10.5,2x,f10.5)')
10253 ! & i,(gel_loc(j,i),j=1,3),(gel_loc_long(j,i),j=1,3),gel_loc_loc(i)
10255 ! write (iout,*) "gel_loc_tur3 gel_loc_turn4"
10257 ! write (iout,'(i5,3f10.5,2x,f10.5)')
10258 ! & i,(gcorr4_turn(j,i),j=1,3),gel_loc_turn4(i)
10260 write (iout,*) "gvdwc gvdwc_scp gvdwc_scpp"
10262 write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)') &
10263 i,(gvdwc(j,i),j=1,3),(gvdwc_scp(j,i),j=1,3),&
10264 (gvdwc_scpp(j,i),j=1,3)
10266 write (iout,*) "gelc_long gvdwpp gel_loc_long"
10268 write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)') &
10269 i,(gelc_long(j,i),j=1,3),(gvdwpp(j,i),j=1,3),&
10270 (gelc_loc_long(j,i),j=1,3)
10277 gradbufc(j,i)=wsc*gvdwc(j,i)+ &
10278 wscp*(gvdwc_scp(j,i)+gvdwc_scpp(j,i))+ &
10279 welec*gelc_long(j,i)+wvdwpp*gvdwpp(j,i)+ &
10280 wel_loc*gel_loc_long(j,i)+ &
10281 wcorr*gradcorr_long(j,i)+ &
10282 wcorr5*gradcorr5_long(j,i)+ &
10283 wcorr6*gradcorr6_long(j,i)+ &
10284 wturn6*gcorr6_turn_long(j,i)+ &
10285 wstrain*ghpbc(j,i) &
10286 +wliptran*gliptranc(j,i) &
10288 +welec*gshieldc(j,i) &
10289 +wcorr*gshieldc_ec(j,i) &
10290 +wturn3*gshieldc_t3(j,i)&
10291 +wturn4*gshieldc_t4(j,i)&
10292 +wel_loc*gshieldc_ll(j,i)&
10293 +wtube*gg_tube(j,i)
10302 gradbufc(j,i)=wsc*gvdwc(j,i)+ &
10303 wscp*(gvdwc_scp(j,i)+gvdwc_scpp(j,i))+ &
10304 welec*gelc_long(j,i)+ &
10305 wbond*gradb(j,i)+ &
10306 wel_loc*gel_loc_long(j,i)+ &
10307 wcorr*gradcorr_long(j,i)+ &
10308 wcorr5*gradcorr5_long(j,i)+ &
10309 wcorr6*gradcorr6_long(j,i)+ &
10310 wturn6*gcorr6_turn_long(j,i)+ &
10311 wstrain*ghpbc(j,i) &
10312 +wliptran*gliptranc(j,i) &
10314 +welec*gshieldc(j,i)&
10315 +wcorr*gshieldc_ec(j,i) &
10316 +wturn4*gshieldc_t4(j,i) &
10317 +wel_loc*gshieldc_ll(j,i)&
10318 +wtube*gg_tube(j,i)
10326 if (nfgtasks.gt.1) then
10329 write (iout,*) "gradbufc before allreduce"
10331 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
10337 gradbufc_sum(j,i)=gradbufc(j,i)
10340 ! call MPI_AllReduce(gradbufc(1,1),gradbufc_sum(1,1),3*nres,
10341 ! & MPI_DOUBLE_PRECISION,MPI_SUM,FG_COMM,IERR)
10342 ! time_reduce=time_reduce+MPI_Wtime()-time00
10344 ! write (iout,*) "gradbufc_sum after allreduce"
10346 ! write (iout,'(i3,3f10.5)') i,(gradbufc_sum(j,i),j=1,3)
10351 ! time_allreduce=time_allreduce+MPI_Wtime()-time00
10355 gradbufc(k,i)=0.0d0
10359 write (iout,*) "igrad_start",igrad_start," igrad_end",igrad_end
10360 write (iout,*) (i," jgrad_start",jgrad_start(i),&
10361 " jgrad_end ",jgrad_end(i),&
10362 i=igrad_start,igrad_end)
10365 ! Obsolete and inefficient code; we can make the effort O(n) and, therefore,
10366 ! do not parallelize this part.
10368 ! do i=igrad_start,igrad_end
10369 ! do j=jgrad_start(i),jgrad_end(i)
10371 ! gradbufc(k,i)=gradbufc(k,i)+gradbufc_sum(k,j)
10376 gradbufc(j,nres-1)=gradbufc_sum(j,nres)
10380 gradbufc(j,i)=gradbufc(j,i+1)+gradbufc_sum(j,i+1)
10384 write (iout,*) "gradbufc after summing"
10386 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
10394 write (iout,*) "gradbufc"
10396 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
10403 gradbufc_sum(j,i)=gradbufc(j,i)
10404 gradbufc(j,i)=0.0d0
10408 gradbufc(j,nres-1)=gradbufc_sum(j,nres)
10412 gradbufc(j,i)=gradbufc(j,i+1)+gradbufc_sum(j,i+1)
10417 ! gradbufc(k,i)=0.0d0
10421 ! gradbufc(k,i)=gradbufc(k,i)+gradbufc(k,j)
10427 write (iout,*) "gradbufc after summing"
10429 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
10438 gradbufc(k,nres)=0.0d0
10440 !el----------------
10441 !el if (.not.allocated(gradx)) allocate(gradx(3,nres,2)) !(3,maxres,2)
10442 !el if (.not.allocated(gradc)) allocate(gradc(3,nres,2)) !(3,maxres,2)
10443 !el-----------------
10447 gradc(j,i,icg)=gradbufc(j,i)+welec*gelc(j,i)+ &
10448 wel_loc*gel_loc(j,i)+ &
10449 0.5d0*(wscp*gvdwc_scpp(j,i)+ &
10450 welec*gelc_long(j,i)+wvdwpp*gvdwpp(j,i)+ &
10451 wel_loc*gel_loc_long(j,i)+ &
10452 wcorr*gradcorr_long(j,i)+ &
10453 wcorr5*gradcorr5_long(j,i)+ &
10454 wcorr6*gradcorr6_long(j,i)+ &
10455 wturn6*gcorr6_turn_long(j,i))+ &
10456 wbond*gradb(j,i)+ &
10457 wcorr*gradcorr(j,i)+ &
10458 wturn3*gcorr3_turn(j,i)+ &
10459 wturn4*gcorr4_turn(j,i)+ &
10460 wcorr5*gradcorr5(j,i)+ &
10461 wcorr6*gradcorr6(j,i)+ &
10462 wturn6*gcorr6_turn(j,i)+ &
10463 wsccor*gsccorc(j,i) &
10464 +wscloc*gscloc(j,i) &
10465 +wliptran*gliptranc(j,i) &
10467 +welec*gshieldc(j,i) &
10468 +welec*gshieldc_loc(j,i) &
10469 +wcorr*gshieldc_ec(j,i) &
10470 +wcorr*gshieldc_loc_ec(j,i) &
10471 +wturn3*gshieldc_t3(j,i) &
10472 +wturn3*gshieldc_loc_t3(j,i) &
10473 +wturn4*gshieldc_t4(j,i) &
10474 +wturn4*gshieldc_loc_t4(j,i) &
10475 +wel_loc*gshieldc_ll(j,i) &
10476 +wel_loc*gshieldc_loc_ll(j,i) &
10477 +wtube*gg_tube(j,i)
10481 gradc(j,i,icg)=gradbufc(j,i)+welec*gelc(j,i)+ &
10482 wel_loc*gel_loc(j,i)+ &
10483 0.5d0*(wscp*gvdwc_scpp(j,i)+ &
10484 welec*gelc_long(j,i)+ &
10485 wel_loc*gel_loc_long(j,i)+ &
10486 !el wcorr*gcorr_long(j,i)+ & !el gcorr_long- brak deklaracji
10487 wcorr5*gradcorr5_long(j,i)+ &
10488 wcorr6*gradcorr6_long(j,i)+ &
10489 wturn6*gcorr6_turn_long(j,i))+ &
10490 wbond*gradb(j,i)+ &
10491 wcorr*gradcorr(j,i)+ &
10492 wturn3*gcorr3_turn(j,i)+ &
10493 wturn4*gcorr4_turn(j,i)+ &
10494 wcorr5*gradcorr5(j,i)+ &
10495 wcorr6*gradcorr6(j,i)+ &
10496 wturn6*gcorr6_turn(j,i)+ &
10497 wsccor*gsccorc(j,i) &
10498 +wscloc*gscloc(j,i) &
10500 +wliptran*gliptranc(j,i) &
10501 +welec*gshieldc(j,i) &
10502 +welec*gshieldc_loc(j,) &
10503 +wcorr*gshieldc_ec(j,i) &
10504 +wcorr*gshieldc_loc_ec(j,i) &
10505 +wturn3*gshieldc_t3(j,i) &
10506 +wturn3*gshieldc_loc_t3(j,i) &
10507 +wturn4*gshieldc_t4(j,i) &
10508 +wturn4*gshieldc_loc_t4(j,i) &
10509 +wel_loc*gshieldc_ll(j,i) &
10510 +wel_loc*gshieldc_loc_ll(j,i) &
10511 +wtube*gg_tube(j,i)
10516 gradx(j,i,icg)=wsc*gvdwx(j,i)+wscp*gradx_scp(j,i)+ &
10517 wbond*gradbx(j,i)+ &
10518 wstrain*ghpbx(j,i)+wcorr*gradxorr(j,i)+ &
10519 wsccor*gsccorx(j,i) &
10520 +wscloc*gsclocx(j,i) &
10521 +wliptran*gliptranx(j,i) &
10522 +welec*gshieldx(j,i) &
10523 +wcorr*gshieldx_ec(j,i) &
10524 +wturn3*gshieldx_t3(j,i) &
10525 +wturn4*gshieldx_t4(j,i) &
10526 +wel_loc*gshieldx_ll(j,i)&
10527 +wtube*gg_tube_sc(j,i)
10533 write (iout,*) "gloc before adding corr"
10535 write (iout,*) i,gloc(i,icg)
10539 gloc(i,icg)=gloc(i,icg)+wcorr*gcorr_loc(i) &
10540 +wcorr5*g_corr5_loc(i) &
10541 +wcorr6*g_corr6_loc(i) &
10542 +wturn4*gel_loc_turn4(i) &
10543 +wturn3*gel_loc_turn3(i) &
10544 +wturn6*gel_loc_turn6(i) &
10545 +wel_loc*gel_loc_loc(i)
10548 write (iout,*) "gloc after adding corr"
10550 write (iout,*) i,gloc(i,icg)
10554 if (nfgtasks.gt.1) then
10557 gradbufc(j,i)=gradc(j,i,icg)
10558 gradbufx(j,i)=gradx(j,i,icg)
10562 glocbuf(i)=gloc(i,icg)
10566 write (iout,*) "gloc_sc before reduce"
10569 write (iout,*) i,j,gloc_sc(j,i,icg)
10576 gloc_scbuf(j,i)=gloc_sc(j,i,icg)
10580 call MPI_Barrier(FG_COMM,IERR)
10581 time_barrier_g=time_barrier_g+MPI_Wtime()-time00
10583 call MPI_Reduce(gradbufc(1,0),gradc(1,0,icg),3*nres+3,&
10584 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
10585 call MPI_Reduce(gradbufx(1,1),gradx(1,1,icg),3*nres,&
10586 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
10587 call MPI_Reduce(glocbuf(1),gloc(1,icg),4*nres,&
10588 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
10589 time_reduce=time_reduce+MPI_Wtime()-time00
10590 call MPI_Reduce(gloc_scbuf(1,1),gloc_sc(1,1,icg),3*nres,&
10591 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
10592 time_reduce=time_reduce+MPI_Wtime()-time00
10595 write (iout,*) "gloc_sc after reduce"
10598 write (iout,*) i,j,gloc_sc(j,i,icg)
10604 write (iout,*) "gloc after reduce"
10606 write (iout,*) i,gloc(i,icg)
10611 if (gnorm_check) then
10613 ! Compute the maximum elements of the gradient
10616 gvdwc_scp_max=0.0d0
10623 gcorr3_turn_max=0.0d0
10624 gcorr4_turn_max=0.0d0
10625 gradcorr5_max=0.0d0
10626 gradcorr6_max=0.0d0
10627 gcorr6_turn_max=0.0d0
10631 gradx_scp_max=0.0d0
10637 gvdwc_norm=dsqrt(scalar(gvdwc(1,i),gvdwc(1,i)))
10638 if (gvdwc_norm.gt.gvdwc_max) gvdwc_max=gvdwc_norm
10639 gvdwc_scp_norm=dsqrt(scalar(gvdwc_scp(1,i),gvdwc_scp(1,i)))
10640 if (gvdwc_scp_norm.gt.gvdwc_scp_max) &
10641 gvdwc_scp_max=gvdwc_scp_norm
10642 gelc_norm=dsqrt(scalar(gelc(1,i),gelc(1,i)))
10643 if (gelc_norm.gt.gelc_max) gelc_max=gelc_norm
10644 gvdwpp_norm=dsqrt(scalar(gvdwpp(1,i),gvdwpp(1,i)))
10645 if (gvdwpp_norm.gt.gvdwpp_max) gvdwpp_max=gvdwpp_norm
10646 gradb_norm=dsqrt(scalar(gradb(1,i),gradb(1,i)))
10647 if (gradb_norm.gt.gradb_max) gradb_max=gradb_norm
10648 ghpbc_norm=dsqrt(scalar(ghpbc(1,i),ghpbc(1,i)))
10649 if (ghpbc_norm.gt.ghpbc_max) ghpbc_max=ghpbc_norm
10650 gradcorr_norm=dsqrt(scalar(gradcorr(1,i),gradcorr(1,i)))
10651 if (gradcorr_norm.gt.gradcorr_max) gradcorr_max=gradcorr_norm
10652 gel_loc_norm=dsqrt(scalar(gel_loc(1,i),gel_loc(1,i)))
10653 if (gel_loc_norm.gt.gel_loc_max) gel_loc_max=gel_loc_norm
10654 gcorr3_turn_norm=dsqrt(scalar(gcorr3_turn(1,i),&
10656 if (gcorr3_turn_norm.gt.gcorr3_turn_max) &
10657 gcorr3_turn_max=gcorr3_turn_norm
10658 gcorr4_turn_norm=dsqrt(scalar(gcorr4_turn(1,i),&
10660 if (gcorr4_turn_norm.gt.gcorr4_turn_max) &
10661 gcorr4_turn_max=gcorr4_turn_norm
10662 gradcorr5_norm=dsqrt(scalar(gradcorr5(1,i),gradcorr5(1,i)))
10663 if (gradcorr5_norm.gt.gradcorr5_max) &
10664 gradcorr5_max=gradcorr5_norm
10665 gradcorr6_norm=dsqrt(scalar(gradcorr6(1,i),gradcorr6(1,i)))
10666 if (gradcorr6_norm.gt.gradcorr6_max) gcorr6_max=gradcorr6_norm
10667 gcorr6_turn_norm=dsqrt(scalar(gcorr6_turn(1,i),&
10669 if (gcorr6_turn_norm.gt.gcorr6_turn_max) &
10670 gcorr6_turn_max=gcorr6_turn_norm
10671 gsccorr_norm=dsqrt(scalar(gsccorc(1,i),gsccorc(1,i)))
10672 if (gsccorr_norm.gt.gsccorr_max) gsccorr_max=gsccorr_norm
10673 gscloc_norm=dsqrt(scalar(gscloc(1,i),gscloc(1,i)))
10674 if (gscloc_norm.gt.gscloc_max) gscloc_max=gscloc_norm
10675 gvdwx_norm=dsqrt(scalar(gvdwx(1,i),gvdwx(1,i)))
10676 if (gvdwx_norm.gt.gvdwx_max) gvdwx_max=gvdwx_norm
10677 gradx_scp_norm=dsqrt(scalar(gradx_scp(1,i),gradx_scp(1,i)))
10678 if (gradx_scp_norm.gt.gradx_scp_max) &
10679 gradx_scp_max=gradx_scp_norm
10680 ghpbx_norm=dsqrt(scalar(ghpbx(1,i),ghpbx(1,i)))
10681 if (ghpbx_norm.gt.ghpbx_max) ghpbx_max=ghpbx_norm
10682 gradxorr_norm=dsqrt(scalar(gradxorr(1,i),gradxorr(1,i)))
10683 if (gradxorr_norm.gt.gradxorr_max) gradxorr_max=gradxorr_norm
10684 gsccorrx_norm=dsqrt(scalar(gsccorx(1,i),gsccorx(1,i)))
10685 if (gsccorrx_norm.gt.gsccorrx_max) gsccorrx_max=gsccorrx_norm
10686 gsclocx_norm=dsqrt(scalar(gsclocx(1,i),gsclocx(1,i)))
10687 if (gsclocx_norm.gt.gsclocx_max) gsclocx_max=gsclocx_norm
10691 open(istat,file=statname,position="append")
10693 open(istat,file=statname,access="append")
10695 write (istat,'(1h#,21f10.2)') gvdwc_max,gvdwc_scp_max,&
10696 gelc_max,gvdwpp_max,gradb_max,ghpbc_max,&
10697 gradcorr_max,gel_loc_max,gcorr3_turn_max,gcorr4_turn_max,&
10698 gradcorr5_max,gradcorr6_max,gcorr6_turn_max,gsccorc_max,&
10699 gscloc_max,gvdwx_max,gradx_scp_max,ghpbx_max,gradxorr_max,&
10700 gsccorx_max,gsclocx_max
10702 if (gvdwc_max.gt.1.0d4) then
10703 write (iout,*) "gvdwc gvdwx gradb gradbx"
10705 write(iout,'(i5,4(3f10.2,5x))') i,(gvdwc(j,i),gvdwx(j,i),&
10706 gradb(j,i),gradbx(j,i),j=1,3)
10708 call pdbout(0.0d0,'cipiszcze',iout)
10715 write (iout,*) "gradc gradx gloc"
10717 write (iout,'(i5,3f10.5,5x,3f10.5,5x,f10.5)') &
10718 i,(gradc(j,i,icg),j=1,3),(gradx(j,i,icg),j=1,3),gloc(i,icg)
10723 time_sumgradient=time_sumgradient+MPI_Wtime()-time01
10726 end subroutine sum_gradient
10727 !-----------------------------------------------------------------------------
10729 ! implicit real*8 (a-h,o-z)
10731 ! include 'DIMENSIONS'
10732 ! include 'COMMON.CHAIN'
10733 ! include 'COMMON.DERIV'
10734 ! include 'COMMON.CALC'
10735 ! include 'COMMON.IOUNITS'
10736 real(kind=8), dimension(3) :: dcosom1,dcosom2
10738 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
10739 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
10740 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12 &
10741 -2.0D0*alf12*eps3der+sigder*sigsq_om12
10745 ! eom12=evdwij*eps1_om12
10747 ! write (iout,*) "eps2der",eps2der," eps3der",eps3der,&
10749 ! write (iout,*) "eps1_om12",eps1_om12," eps2rt_om12",eps2rt_om12
10750 ! write (iout,*) "eom1",eom1," eom2",eom2," eom12",eom12
10751 !C print *,sss_ele_cut,'in sc_grad'
10753 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
10754 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
10757 gg(k)=(gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k))*sss_ele_cut
10758 !C print *,'gg',k,gg(k)
10760 ! print *,i,j,gg_lipi(3),gg_lipj(3),sss_ele_cut
10761 ! write (iout,*) "gg",(gg(k),k=1,3)
10763 gvdwx(k,i)=gvdwx(k,i)-gg(k) +gg_lipi(k)&
10764 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
10765 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv &
10768 gvdwx(k,j)=gvdwx(k,j)+gg(k)+gg_lipj(k)&
10769 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
10770 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv &
10773 ! write (iout,*)(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
10774 ! +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
10775 ! write (iout,*)(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
10776 ! +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
10779 ! Calculate the components of the gradient in DC and X
10783 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
10787 gvdwc(l,i)=gvdwc(l,i)-gg(l)+gg_lipi(l)
10788 gvdwc(l,j)=gvdwc(l,j)+gg(l)+gg_lipj(l)
10791 end subroutine sc_grad
10793 !-----------------------------------------------------------------------------
10794 subroutine mixder(thetai,thet_pred_mean,theta0i,E_tc_t)
10797 ! implicit real*8 (a-h,o-z)
10798 ! include 'DIMENSIONS'
10799 ! include 'COMMON.LOCAL'
10800 ! include 'COMMON.IOUNITS'
10801 !el real(kind=8) :: term1,term2,termm,diffak,ratak,&
10802 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
10803 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,
10804 real(kind=8) :: thetai,thet_pred_mean,theta0i,E_tc_t
10805 real(kind=8) :: t3,t6,t9,t12,t14,t16,t21,t23,t26,t27,t32,t40
10807 !el common /calcthet/ term1,term2,termm,diffak,ratak,&
10808 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
10809 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,it
10810 !el local variables
10812 delthec=thetai-thet_pred_mean
10813 delthe0=thetai-theta0i
10814 ! "Thank you" to MAPLE (probably spared one day of hand-differentiation).
10815 t3 = thetai-thet_pred_mean
10819 t14 = t12+t6*sigsqtc
10821 t21 = thetai-theta0i
10827 E_tc_t = -((sigcsq+2.D0*t3*sigsqtc)*t9-t14*sigcsq*t3*t16*t9 &
10828 -aktc*sig0inv*t27)/t32+(t14*t9+aktc*t26)/t40 &
10829 *(-t12*t9-ak*sig0inv*t27)
10831 end subroutine mixder
10833 !-----------------------------------------------------------------------------
10835 !-----------------------------------------------------------------------------
10837 !-----------------------------------------------------------------------------
10838 ! This subroutine calculates the derivatives of the consecutive virtual
10839 ! bond vectors and the SC vectors in the virtual-bond angles theta and
10840 ! virtual-torsional angles phi, as well as the derivatives of SC vectors
10841 ! in the angles alpha and omega, describing the location of a side chain
10842 ! in its local coordinate system.
10844 ! The derivatives are stored in the following arrays:
10846 ! DDCDV - the derivatives of virtual-bond vectors DC in theta and phi.
10847 ! The structure is as follows:
10849 ! dDC(x,2)/dT(3),...,dDC(z,2)/dT(3),0, 0, 0
10850 ! 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)
10851 ! . . . . . . . . . . . . . . . . . .
10852 ! 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)
10856 ! 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)
10858 ! DXDV - the derivatives of the side-chain vectors in theta and phi.
10859 ! The structure is same as above.
10861 ! DCDS - the derivatives of the side chain vectors in the local spherical
10862 ! andgles alph and omega:
10864 ! 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)
10865 ! 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)
10869 ! 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)
10871 ! Version of March '95, based on an early version of November '91.
10873 !**********************************************************************
10874 ! implicit real*8 (a-h,o-z)
10875 ! include 'DIMENSIONS'
10876 ! include 'COMMON.VAR'
10877 ! include 'COMMON.CHAIN'
10878 ! include 'COMMON.DERIV'
10879 ! include 'COMMON.GEO'
10880 ! include 'COMMON.LOCAL'
10881 ! include 'COMMON.INTERACT'
10882 real(kind=8),dimension(3,3,nres) :: drt,rdt,prordt,prodrt !(3,3,maxres)
10883 real(kind=8),dimension(3,3) :: dp,temp
10884 !el real(kind=8) :: fromto(3,3,maxdim) !(3,3,maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
10885 real(kind=8),dimension(3) :: xx,xx1
10886 !el local variables
10887 integer :: i,k,l,j,m,ind,ind1,jjj
10888 real(kind=8) :: alphi,omegi,theta2,dpkl,dpjk,xj,rj,dxoijk,dxoiij,&
10889 tempkl,dsci,cosalphi,sinalphi,cosomegi,sinomegi,cost2,&
10890 sint2,xp,yp,xxp,yyp,zzp,dj
10892 ! common /przechowalnia/ fromto
10893 if(.not. allocated(fromto)) allocate(fromto(3,3,maxdim))
10894 ! get the position of the jth ijth fragment of the chain coordinate system
10895 ! in the fromto array.
10896 ! indmat(i,j)=((2*(nres-2)-i)*(i-1))/2+j-1
10898 ! maxdim=(nres-1)*(nres-2)/2
10899 ! allocate(dcdv(6,maxdim),dxds(6,nres))
10900 ! calculate the derivatives of transformation matrix elements in theta
10903 !el call flush(iout) !el
10905 rdt(1,1,i)=-rt(1,2,i)
10906 rdt(1,2,i)= rt(1,1,i)
10908 rdt(2,1,i)=-rt(2,2,i)
10909 rdt(2,2,i)= rt(2,1,i)
10911 rdt(3,1,i)=-rt(3,2,i)
10912 rdt(3,2,i)= rt(3,1,i)
10916 ! derivatives in phi
10922 drt(2,1,i)= rt(3,1,i)
10923 drt(2,2,i)= rt(3,2,i)
10924 drt(2,3,i)= rt(3,3,i)
10925 drt(3,1,i)=-rt(2,1,i)
10926 drt(3,2,i)=-rt(2,2,i)
10927 drt(3,3,i)=-rt(2,3,i)
10930 ! generate the matrix products of type r(i)t(i)...r(j)t(j)
10936 temp(k,l)=rt(k,l,i)
10941 fromto(k,l,ind)=temp(k,l)
10950 dpkl=dpkl+temp(k,m)*rt(m,l,j)
10953 fromto(k,l,ind)=dpkl
10964 ! Calculate derivatives.
10970 ! Derivatives of DC(i+1) in theta(i+2)
10976 dpjk=dpjk+prod(j,l,i)*rdt(l,k,i)
10979 prordt(j,k,i)=dp(j,k)
10982 dcdv(j,ind1)=vbld(i+1)*dp(j,1)
10985 ! Derivatives of SC(i+1) in theta(i+2)
10987 xx1(1)=-0.5D0*xloc(2,i+1)
10988 xx1(2)= 0.5D0*xloc(1,i+1)
10992 xj=xj+r(j,k,i)*xx1(k)
10999 rj=rj+prod(j,k,i)*xx(k)
11004 ! Derivatives of SC(i+1) in theta(i+3). The have to be handled differently
11005 ! than the other off-diagonal derivatives.
11010 dxoiij=dxoiij+dp(j,k)*xrot(k,i+2)
11012 dxdv(j,ind1+1)=dxoiij
11014 !d print *,ind1+1,(dxdv(j,ind1+1),j=1,3)
11016 ! Derivatives of DC(i+1) in phi(i+2)
11022 dpjk=dpjk+prod(j,l,i)*drt(l,k,i)
11025 prodrt(j,k,i)=dp(j,k)
11027 dcdv(j+3,ind1)=vbld(i+1)*dp(j,1)
11030 ! Derivatives of SC(i+1) in phi(i+2)
11033 xx(3)= xloc(2,i+1)*r(2,2,i)+xloc(3,i+1)*r(2,3,i)
11034 xx(2)=-xloc(2,i+1)*r(3,2,i)-xloc(3,i+1)*r(3,3,i)
11038 rj=rj+prod(j,k,i)*xx(k)
11043 ! Derivatives of SC(i+1) in phi(i+3).
11048 dxoiij=dxoiij+dp(j,k)*xrot(k,i+2)
11050 dxdv(j+3,ind1+1)=dxoiij
11053 ! Calculate the derivatives of DC(i+1) and SC(i+1) in theta(i+3) thru
11054 ! theta(nres) and phi(i+3) thru phi(nres).
11058 ind=indmat(i+1,j+1)
11059 !d print *,'i=',i,' j=',j,' ind=',ind,' ind1=',ind1
11064 tempkl=tempkl+prordt(k,m,i)*fromto(m,l,ind)
11069 !d print '(9f8.3)',((fromto(k,l,ind),l=1,3),k=1,3)
11070 !d print '(9f8.3)',((prod(k,l,i),l=1,3),k=1,3)
11071 !d print '(9f8.3)',((temp(k,l),l=1,3),k=1,3)
11072 ! Derivatives of virtual-bond vectors in theta
11074 dcdv(k,ind1)=vbld(i+1)*temp(k,1)
11076 !d print '(3f8.3)',(dcdv(k,ind1),k=1,3)
11077 ! Derivatives of SC vectors in theta
11081 dxoijk=dxoijk+temp(k,l)*xrot(l,j+2)
11083 dxdv(k,ind1+1)=dxoijk
11086 !--- Calculate the derivatives in phi
11092 tempkl=tempkl+prodrt(k,m,i)*fromto(m,l,ind)
11098 dcdv(k+3,ind1)=vbld(i+1)*temp(k,1)
11103 dxoijk=dxoijk+temp(k,l)*xrot(l,j+2)
11105 dxdv(k+3,ind1+1)=dxoijk
11110 ! Derivatives in alpha and omega:
11113 ! dsci=dsc(itype(i,1))
11118 if(alphi.ne.alphi) alphi=100.0
11119 if(omegi.ne.omegi) omegi=-100.0
11124 !d print *,'i=',i,' dsci=',dsci,' alphi=',alphi,' omegi=',omegi
11125 cosalphi=dcos(alphi)
11126 sinalphi=dsin(alphi)
11127 cosomegi=dcos(omegi)
11128 sinomegi=dsin(omegi)
11129 temp(1,1)=-dsci*sinalphi
11130 temp(2,1)= dsci*cosalphi*cosomegi
11131 temp(3,1)=-dsci*cosalphi*sinomegi
11133 temp(2,2)=-dsci*sinalphi*sinomegi
11134 temp(3,2)=-dsci*sinalphi*cosomegi
11135 theta2=pi-0.5D0*theta(i+1)
11139 !d print *,((temp(l,k),l=1,3),k=1,2)
11143 xxp= xp*cost2+yp*sint2
11144 yyp=-xp*sint2+yp*cost2
11147 xx(2)=yyp*r(2,2,i-1)+zzp*r(2,3,i-1)
11148 xx(3)=yyp*r(3,2,i-1)+zzp*r(3,3,i-1)
11152 dj=dj+prod(k,l,i-1)*xx(l)
11160 end subroutine cartder
11161 !-----------------------------------------------------------------------------
11163 !-----------------------------------------------------------------------------
11164 subroutine check_cartgrad
11165 ! Check the gradient of Cartesian coordinates in internal coordinates.
11166 ! implicit real*8 (a-h,o-z)
11167 ! include 'DIMENSIONS'
11168 ! include 'COMMON.IOUNITS'
11169 ! include 'COMMON.VAR'
11170 ! include 'COMMON.CHAIN'
11171 ! include 'COMMON.GEO'
11172 ! include 'COMMON.LOCAL'
11173 ! include 'COMMON.DERIV'
11174 real(kind=8),dimension(6,nres) :: temp
11175 real(kind=8),dimension(3) :: xx,gg
11176 integer :: i,k,j,ii
11177 real(kind=8) :: aincr,aincr2,alphi,omegi,theti,thet,phii
11178 ! indmat(i,j)=((2*(nres-2)-i)*(i-1))/2+j-1
11180 ! Check the gradient of the virtual-bond and SC vectors in the internal
11186 write (iout,'(a)') '**************** dx/dalpha'
11190 alph(i)=alph(i)+aincr
11192 temp(k,i)=dc(k,nres+i)
11196 gg(k)=(dc(k,nres+i)-temp(k,i))/aincr
11197 xx(k)=dabs((gg(k)-dxds(k,i))/(aincr*dabs(dxds(k,i))+aincr))
11199 write (iout,'(i4,3e15.6/4x,3e15.6,3f9.3)') &
11200 i,(gg(k),k=1,3),(dxds(k,i),k=1,3),(xx(k),k=1,3)
11206 write (iout,'(a)') '**************** dx/domega'
11210 omeg(i)=omeg(i)+aincr
11212 temp(k,i)=dc(k,nres+i)
11216 gg(k)=(dc(k,nres+i)-temp(k,i))/aincr
11217 xx(k)=dabs((gg(k)-dxds(k+3,i))/ &
11218 (aincr*dabs(dxds(k+3,i))+aincr))
11220 write (iout,'(i4,3e15.6/4x,3e15.6,3f9.3)') &
11221 i,(gg(k),k=1,3),(dxds(k+3,i),k=1,3),(xx(k),k=1,3)
11227 write (iout,'(a)') '**************** dx/dtheta'
11231 theta(i)=theta(i)+aincr
11234 temp(k,j)=dc(k,nres+j)
11240 ! print *,'i=',i-2,' j=',j-1,' ii=',ii
11242 gg(k)=(dc(k,nres+j)-temp(k,j))/aincr
11243 xx(k)=dabs((gg(k)-dxdv(k,ii))/ &
11244 (aincr*dabs(dxdv(k,ii))+aincr))
11246 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
11247 i,j,(gg(k),k=1,3),(dxdv(k,ii),k=1,3),(xx(k),k=1,3)
11254 write (iout,'(a)') '***************** dx/dphi'
11257 phi(i)=phi(i)+aincr
11260 temp(k,j)=dc(k,nres+j)
11268 gg(k)=(dc(k,nres+j)-temp(k,j))/aincr
11269 xx(k)=dabs((gg(k)-dxdv(k+3,ii))/ &
11270 (aincr*dabs(dxdv(k+3,ii))+aincr))
11272 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
11273 i,j,(gg(k),k=1,3),(dxdv(k+3,ii),k=1,3),(xx(k),k=1,3)
11276 phi(i)=phi(i)-aincr
11279 write (iout,'(a)') '****************** ddc/dtheta'
11282 theta(i+2)=thet+aincr
11293 gg(k)=(dc(k,j)-temp(k,j))/aincr
11294 xx(k)=dabs((gg(k)-dcdv(k,ii))/ &
11295 (aincr*dabs(dcdv(k,ii))+aincr))
11297 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
11298 i,j,(gg(k),k=1,3),(dcdv(k,ii),k=1,3),(xx(k),k=1,3)
11308 write (iout,'(a)') '******************* ddc/dphi'
11311 phi(i+3)=phii+aincr
11322 gg(k)=(dc(k,j)-temp(k,j))/aincr
11323 xx(k)=dabs((gg(k)-dcdv(k+3,ii))/ &
11324 (aincr*dabs(dcdv(k+3,ii))+aincr))
11326 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
11327 i,j,(gg(k),k=1,3),(dcdv(k+3,ii),k=1,3),(xx(k),k=1,3)
11338 end subroutine check_cartgrad
11339 !-----------------------------------------------------------------------------
11340 subroutine check_ecart
11341 ! Check the gradient of the energy in Cartesian coordinates.
11342 ! implicit real*8 (a-h,o-z)
11343 ! include 'DIMENSIONS'
11344 ! include 'COMMON.CHAIN'
11345 ! include 'COMMON.DERIV'
11346 ! include 'COMMON.IOUNITS'
11347 ! include 'COMMON.VAR'
11348 ! include 'COMMON.CONTACTS'
11350 !el integer :: icall
11351 !el common /srutu/ icall
11352 real(kind=8),dimension(6) :: ggg
11353 real(kind=8),dimension(3) :: cc,xx,ddc,ddx
11354 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
11355 real(kind=8),dimension(6,nres) :: grad_s
11356 real(kind=8),dimension(0:n_ene) :: energia,energia1
11357 integer :: uiparm(1)
11358 real(kind=8) :: urparm(1)
11360 integer :: nf,i,j,k
11361 real(kind=8) :: aincr,etot,etot1
11367 print '(a)','CG processor',me,' calling CHECK_CART.',aincr
11370 call geom_to_var(nvar,x)
11371 call etotal(energia)
11373 !el call enerprint(energia)
11374 call gradient(nvar,x,nf,g,uiparm,urparm,fdum)
11377 write (iout,'(i5,3f10.5)') i,(gradxorr(j,i),j=1,3)
11381 grad_s(j,i)=gradc(j,i,icg)
11382 grad_s(j+3,i)=gradx(j,i,icg)
11386 write (iout,'(/a/)') 'Gradient in virtual-bond and SC vectors'
11391 ddx(j)=dc(j,i+nres)
11394 dc(j,i)=dc(j,i)+aincr
11396 c(j,k)=c(j,k)+aincr
11397 c(j,k+nres)=c(j,k+nres)+aincr
11399 call etotal(energia1)
11401 ggg(j)=(etot1-etot)/aincr
11404 c(j,k)=c(j,k)-aincr
11405 c(j,k+nres)=c(j,k+nres)-aincr
11409 c(j,i+nres)=c(j,i+nres)+aincr
11410 dc(j,i+nres)=dc(j,i+nres)+aincr
11411 call etotal(energia1)
11413 ggg(j+3)=(etot1-etot)/aincr
11415 dc(j,i+nres)=ddx(j)
11417 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/)') &
11418 i,(ggg(k),k=1,6),(grad_s(k,i),k=1,6)
11421 end subroutine check_ecart
11423 !-----------------------------------------------------------------------------
11424 subroutine check_ecartint
11425 ! Check the gradient of the energy in Cartesian coordinates.
11426 use io_base, only: intout
11427 ! implicit real*8 (a-h,o-z)
11428 ! include 'DIMENSIONS'
11429 ! include 'COMMON.CONTROL'
11430 ! include 'COMMON.CHAIN'
11431 ! include 'COMMON.DERIV'
11432 ! include 'COMMON.IOUNITS'
11433 ! include 'COMMON.VAR'
11434 ! include 'COMMON.CONTACTS'
11435 ! include 'COMMON.MD'
11436 ! include 'COMMON.LOCAL'
11437 ! include 'COMMON.SPLITELE'
11439 !el integer :: icall
11440 !el common /srutu/ icall
11441 real(kind=8),dimension(6) :: ggg,ggg1
11442 real(kind=8),dimension(3) :: cc,xx,ddc,ddx,ddc1,ddcn
11443 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
11444 real(kind=8),dimension(3) :: dcnorm_safe1,dcnorm_safe2,dxnorm_safe
11445 real(kind=8),dimension(6,0:nres) :: grad_s,grad_s1 !(6,0:maxres)
11446 real(kind=8),dimension(nres) :: phi_temp,theta_temp,alph_temp,omeg_temp !(maxres)
11447 real(kind=8),dimension(0:n_ene) :: energia,energia1
11448 integer :: uiparm(1)
11449 real(kind=8) :: urparm(1)
11451 integer :: i,j,k,nf
11452 real(kind=8) :: rlambd,aincr,etot,etot1,etot11,etot12,etot2,&
11460 ! call intcartderiv
11461 ! call checkintcartgrad
11464 write(iout,*) 'Calling CHECK_ECARTINT.'
11467 write (iout,*) "Before geom_to_var"
11468 call geom_to_var(nvar,x)
11469 write (iout,*) "after geom_to_var"
11470 write (iout,*) "split_ene ",split_ene
11472 if (.not.split_ene) then
11473 write(iout,*) 'Calling CHECK_ECARTINT if'
11474 call etotal(energia)
11475 !elwrite(iout,*) 'Calling CHECK_ECARTINT if'
11477 write (iout,*) "etot",etot
11479 !el call enerprint(energia)
11480 !elwrite(iout,*) 'Calling CHECK_ECARTINT if'
11482 write (iout,*) "enter cartgrad"
11485 !elwrite(iout,*) 'Calling CHECK_ECARTINT if'
11486 write (iout,*) "exit cartgrad"
11490 write (iout,'(i5,3f10.5)') i,(gradxorr(j,i),j=1,3)
11493 grad_s(j,0)=gcart(j,0)
11495 !elwrite(iout,*) 'Calling CHECK_ECARTINT if'
11498 grad_s(j,i)=gcart(j,i)
11499 grad_s(j+3,i)=gxcart(j,i)
11503 write(iout,*) 'Calling CHECK_ECARTIN else.'
11504 !- split gradient check
11506 call etotal_long(energia)
11507 !el call enerprint(energia)
11509 write (iout,*) "enter cartgrad"
11512 write (iout,*) "exit cartgrad"
11515 write (iout,*) "longrange grad"
11517 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
11518 (gxcart(j,i),j=1,3)
11521 grad_s(j,0)=gcart(j,0)
11525 grad_s(j,i)=gcart(j,i)
11526 grad_s(j+3,i)=gxcart(j,i)
11530 call etotal_short(energia)
11531 !el call enerprint(energia)
11533 write (iout,*) "enter cartgrad"
11536 write (iout,*) "exit cartgrad"
11539 write (iout,*) "shortrange grad"
11541 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
11542 (gxcart(j,i),j=1,3)
11545 grad_s1(j,0)=gcart(j,0)
11549 grad_s1(j,i)=gcart(j,i)
11550 grad_s1(j+3,i)=gxcart(j,i)
11554 write (iout,'(/a/)') 'Gradient in virtual-bond and SC vectors'
11558 if (nnt.gt.1 .and. i.eq.nnt) ddc1(j)=c(j,1)
11559 if (nct.lt.nres .and. i.eq.nct) ddcn(j)=c(j,nres)
11562 dcnorm_safe1(j)=dc_norm(j,i-1)
11563 dcnorm_safe2(j)=dc_norm(j,i)
11564 dxnorm_safe(j)=dc_norm(j,i+nres)
11567 c(j,i)=ddc(j)+aincr
11568 if (nnt.gt.1 .and. i.eq.nnt) c(j,1)=c(j,1)+aincr
11569 if (nct.lt.nres .and. i.eq.nct) c(j,nres)=c(j,nres)+aincr
11570 if (i.gt.1) dc(j,i-1)=c(j,i)-c(j,i-1)
11571 dc(j,i)=c(j,i+1)-c(j,i)
11572 dc(j,i+nres)=c(j,i+nres)-c(j,i)
11573 call int_from_cart1(.false.)
11574 if (.not.split_ene) then
11575 call etotal(energia1)
11577 write (iout,*) "ij",i,j," etot1",etot1
11580 call etotal_long(energia1)
11582 call etotal_short(energia1)
11585 !- end split gradient
11586 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot1",etot1
11587 c(j,i)=ddc(j)-aincr
11588 if (nnt.gt.1 .and. i.eq.nnt) c(j,1)=ddc1(j)-aincr
11589 if (nct.lt.nres .and. i.eq.nct) c(j,nres)=ddcn(j)-aincr
11590 if (i.gt.1) dc(j,i-1)=c(j,i)-c(j,i-1)
11591 dc(j,i)=c(j,i+1)-c(j,i)
11592 dc(j,i+nres)=c(j,i+nres)-c(j,i)
11593 call int_from_cart1(.false.)
11594 if (.not.split_ene) then
11595 call etotal(energia1)
11597 write (iout,*) "ij",i,j," etot2",etot2
11598 ggg(j)=(etot1-etot2)/(2*aincr)
11601 call etotal_long(energia1)
11603 ggg(j)=(etot11-etot21)/(2*aincr)
11604 call etotal_short(energia1)
11606 ggg1(j)=(etot12-etot22)/(2*aincr)
11607 !- end split gradient
11608 ! write (iout,*) "etot21",etot21," etot22",etot22
11610 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
11612 if (nnt.gt.1 .and. i.eq.nnt) c(j,1)=ddc1(j)
11613 if (nct.lt.nres .and. i.eq.nct) c(j,nres)=ddcn(j)
11614 if (i.gt.1) dc(j,i-1)=c(j,i)-c(j,i-1)
11615 dc(j,i)=c(j,i+1)-c(j,i)
11616 dc(j,i+nres)=c(j,i+nres)-c(j,i)
11617 dc_norm(j,i-1)=dcnorm_safe1(j)
11618 dc_norm(j,i)=dcnorm_safe2(j)
11619 dc_norm(j,i+nres)=dxnorm_safe(j)
11622 c(j,i+nres)=ddx(j)+aincr
11623 dc(j,i+nres)=c(j,i+nres)-c(j,i)
11624 call int_from_cart1(.false.)
11625 if (.not.split_ene) then
11626 call etotal(energia1)
11630 call etotal_long(energia1)
11632 call etotal_short(energia1)
11635 !- end split gradient
11636 c(j,i+nres)=ddx(j)-aincr
11637 dc(j,i+nres)=c(j,i+nres)-c(j,i)
11638 call int_from_cart1(.false.)
11639 if (.not.split_ene) then
11640 call etotal(energia1)
11642 ggg(j+3)=(etot1-etot2)/(2*aincr)
11645 call etotal_long(energia1)
11647 ggg(j+3)=(etot11-etot21)/(2*aincr)
11648 call etotal_short(energia1)
11650 ggg1(j+3)=(etot12-etot22)/(2*aincr)
11651 !- end split gradient
11653 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
11655 dc(j,i+nres)=c(j,i+nres)-c(j,i)
11656 dc_norm(j,i+nres)=dxnorm_safe(j)
11657 call int_from_cart1(.false.)
11659 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
11660 i,(ggg(k),k=1,6),(grad_s(k,i),k=1,6),(ggg(k)/grad_s(k,i),k=1,6)
11661 if (split_ene) then
11662 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
11663 i,(ggg1(k),k=1,6),(grad_s1(k,i),k=1,6),(ggg1(k)/grad_s1(k,i),&
11665 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
11666 i,(ggg(k)+ggg1(k),k=1,6),(grad_s(k,i)+grad_s1(k,i),k=1,6),&
11667 ((ggg(k)+ggg1(k))/(grad_s(k,i)+grad_s1(k,i)),k=1,6)
11671 end subroutine check_ecartint
11673 !-----------------------------------------------------------------------------
11674 subroutine check_ecartint
11675 ! Check the gradient of the energy in Cartesian coordinates.
11676 use io_base, only: intout
11677 ! implicit real*8 (a-h,o-z)
11678 ! include 'DIMENSIONS'
11679 ! include 'COMMON.CONTROL'
11680 ! include 'COMMON.CHAIN'
11681 ! include 'COMMON.DERIV'
11682 ! include 'COMMON.IOUNITS'
11683 ! include 'COMMON.VAR'
11684 ! include 'COMMON.CONTACTS'
11685 ! include 'COMMON.MD'
11686 ! include 'COMMON.LOCAL'
11687 ! include 'COMMON.SPLITELE'
11689 !el integer :: icall
11690 !el common /srutu/ icall
11691 real(kind=8),dimension(6) :: ggg,ggg1
11692 real(kind=8),dimension(3) :: cc,xx,ddc,ddx
11693 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
11694 real(kind=8),dimension(3) :: dcnorm_safe,dxnorm_safe
11695 real(kind=8),dimension(6,0:nres) :: grad_s,grad_s1 !(6,0:maxres)
11696 real(kind=8),dimension(nres) :: phi_temp,theta_temp,alph_temp,omeg_temp !(maxres)
11697 real(kind=8),dimension(0:n_ene) :: energia,energia1
11698 integer :: uiparm(1)
11699 real(kind=8) :: urparm(1)
11701 integer :: i,j,k,nf
11702 real(kind=8) :: rlambd,aincr,etot,etot1,etot11,etot12,etot2,&
11710 ! call intcartderiv
11711 ! call checkintcartgrad
11714 write(iout,*) 'Calling CHECK_ECARTINT.',aincr
11717 call geom_to_var(nvar,x)
11718 if (.not.split_ene) then
11719 call etotal(energia)
11721 !el call enerprint(energia)
11723 write (iout,*) "enter cartgrad"
11726 write (iout,*) "exit cartgrad"
11730 write (iout,'(i5,3f10.5)') i,(gradxorr(j,i),j=1,3)
11733 grad_s(j,0)=gcart(j,0)
11737 grad_s(j,i)=gcart(j,i)
11738 grad_s(j+3,i)=gxcart(j,i)
11742 !- split gradient check
11744 call etotal_long(energia)
11745 !el call enerprint(energia)
11747 write (iout,*) "enter cartgrad"
11750 write (iout,*) "exit cartgrad"
11753 write (iout,*) "longrange grad"
11755 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
11756 (gxcart(j,i),j=1,3)
11759 grad_s(j,0)=gcart(j,0)
11763 grad_s(j,i)=gcart(j,i)
11764 grad_s(j+3,i)=gxcart(j,i)
11768 call etotal_short(energia)
11769 !el call enerprint(energia)
11771 write (iout,*) "enter cartgrad"
11774 write (iout,*) "exit cartgrad"
11777 write (iout,*) "shortrange grad"
11779 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
11780 (gxcart(j,i),j=1,3)
11783 grad_s1(j,0)=gcart(j,0)
11787 grad_s1(j,i)=gcart(j,i)
11788 grad_s1(j+3,i)=gxcart(j,i)
11792 write (iout,'(/a/)') 'Gradient in virtual-bond and SC vectors'
11797 ddx(j)=dc(j,i+nres)
11799 dcnorm_safe(k)=dc_norm(k,i)
11800 dxnorm_safe(k)=dc_norm(k,i+nres)
11804 dc(j,i)=ddc(j)+aincr
11805 call chainbuild_cart
11807 ! Broadcast the order to compute internal coordinates to the slaves.
11808 ! if (nfgtasks.gt.1)
11809 ! & call MPI_Bcast(6,1,MPI_INTEGER,king,FG_COMM,IERROR)
11811 ! call int_from_cart1(.false.)
11812 if (.not.split_ene) then
11813 call etotal(energia1)
11817 call etotal_long(energia1)
11819 call etotal_short(energia1)
11821 ! write (iout,*) "etot11",etot11," etot12",etot12
11823 !- end split gradient
11824 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot1",etot1
11825 dc(j,i)=ddc(j)-aincr
11826 call chainbuild_cart
11827 ! call int_from_cart1(.false.)
11828 if (.not.split_ene) then
11829 call etotal(energia1)
11831 ggg(j)=(etot1-etot2)/(2*aincr)
11834 call etotal_long(energia1)
11836 ggg(j)=(etot11-etot21)/(2*aincr)
11837 call etotal_short(energia1)
11839 ggg1(j)=(etot12-etot22)/(2*aincr)
11840 !- end split gradient
11841 ! write (iout,*) "etot21",etot21," etot22",etot22
11843 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
11845 call chainbuild_cart
11848 dc(j,i+nres)=ddx(j)+aincr
11849 call chainbuild_cart
11850 ! write (iout,*) "i",i," j",j," dxnorm+ and dxnorm"
11851 ! write (iout,'(3f15.10)') (dc_norm(k,i+nres),k=1,3)
11852 ! write (iout,'(3f15.10)') (dxnorm_safe(k),k=1,3)
11853 ! write (iout,*) "dxnormnorm",dsqrt(
11854 ! & dc_norm(1,i+nres)**2+dc_norm(2,i+nres)**2+dc_norm(3,i+nres)**2)
11855 ! write (iout,*) "dxnormnormsafe",dsqrt(
11856 ! & dxnorm_safe(1)**2+dxnorm_safe(2)**2+dxnorm_safe(3)**2)
11858 if (.not.split_ene) then
11859 call etotal(energia1)
11863 call etotal_long(energia1)
11865 call etotal_short(energia1)
11868 !- end split gradient
11869 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot1",etot1
11870 dc(j,i+nres)=ddx(j)-aincr
11871 call chainbuild_cart
11872 ! write (iout,*) "i",i," j",j," dxnorm- and dxnorm"
11873 ! write (iout,'(3f15.10)') (dc_norm(k,i+nres),k=1,3)
11874 ! write (iout,'(3f15.10)') (dxnorm_safe(k),k=1,3)
11876 ! write (iout,*) "dxnormnorm",dsqrt(
11877 ! & dc_norm(1,i+nres)**2+dc_norm(2,i+nres)**2+dc_norm(3,i+nres)**2)
11878 ! write (iout,*) "dxnormnormsafe",dsqrt(
11879 ! & dxnorm_safe(1)**2+dxnorm_safe(2)**2+dxnorm_safe(3)**2)
11880 if (.not.split_ene) then
11881 call etotal(energia1)
11883 ggg(j+3)=(etot1-etot2)/(2*aincr)
11886 call etotal_long(energia1)
11888 ggg(j+3)=(etot11-etot21)/(2*aincr)
11889 call etotal_short(energia1)
11891 ggg1(j+3)=(etot12-etot22)/(2*aincr)
11892 !- end split gradient
11894 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
11895 dc(j,i+nres)=ddx(j)
11896 call chainbuild_cart
11898 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
11899 i,(ggg(k),k=1,6),(grad_s(k,i),k=1,6),(ggg(k)/grad_s(k,i),k=1,6)
11900 if (split_ene) then
11901 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
11902 i,(ggg1(k),k=1,6),(grad_s1(k,i),k=1,6),(ggg1(k)/grad_s1(k,i),&
11904 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
11905 i,(ggg(k)+ggg1(k),k=1,6),(grad_s(k,i)+grad_s1(k,i),k=1,6),&
11906 ((ggg(k)+ggg1(k))/(grad_s(k,i)+grad_s1(k,i)),k=1,6)
11910 end subroutine check_ecartint
11912 !-----------------------------------------------------------------------------
11913 subroutine check_eint
11914 ! Check the gradient of energy in internal coordinates.
11915 ! implicit real*8 (a-h,o-z)
11916 ! include 'DIMENSIONS'
11917 ! include 'COMMON.CHAIN'
11918 ! include 'COMMON.DERIV'
11919 ! include 'COMMON.IOUNITS'
11920 ! include 'COMMON.VAR'
11921 ! include 'COMMON.GEO'
11923 !el integer :: icall
11924 !el common /srutu/ icall
11925 real(kind=8),dimension(6*nres) :: x,gana,gg !(maxvar) (maxvar=6*maxres)
11926 integer :: uiparm(1)
11927 real(kind=8) :: urparm(1)
11928 real(kind=8),dimension(0:n_ene) :: energia,energia1,energia2
11929 character(len=6) :: key
11932 real(kind=8) :: xi,aincr,etot,etot1,etot2
11935 print '(a)','Calling CHECK_INT.'
11939 call geom_to_var(nvar,x)
11940 call var_to_geom(nvar,x)
11944 call etotal(energia)
11946 !el call enerprint(energia)
11949 if (MyID.ne.BossID) then
11950 call mp_bcast(x(1),8*(nvar+3),BossID,fgGroupID)
11958 !d write (iout,'(10f8.3)') (rad2deg*x(i),i=1,nvar)
11959 call gradient(nvar,x,nf,gana,uiparm,urparm,fdum)
11960 !d write (iout,'(i3,1pe14.4)') (i,gana(i),i=1,nvar+20) !sp
11964 x(i)=xi-0.5D0*aincr
11965 call var_to_geom(nvar,x)
11967 call etotal(energia1)
11969 x(i)=xi+0.5D0*aincr
11970 call var_to_geom(nvar,x)
11972 call etotal(energia2)
11974 gg(i)=(etot2-etot1)/aincr
11975 write (iout,*) i,etot1,etot2
11978 write (iout,'(/2a)')' Variable Numerical Analytical',&
11981 if (i.le.nphi) then
11984 else if (i.le.nphi+ntheta) then
11987 else if (i.le.nphi+ntheta+nside) then
11991 ii=i-(nphi+ntheta+nside)
11994 write (iout,'(i3,a,i3,3(1pd16.6))') &
11995 i,key,ii,gg(i),gana(i),&
11996 100.0D0*dabs(gg(i)-gana(i))/(dabs(gana(i))+aincr)
11999 end subroutine check_eint
12000 !-----------------------------------------------------------------------------
12002 !-----------------------------------------------------------------------------
12003 subroutine Econstr_back
12004 ! MD with umbrella_sampling using Wolyne's distance measure as a constraint
12005 ! implicit real*8 (a-h,o-z)
12006 ! include 'DIMENSIONS'
12007 ! include 'COMMON.CONTROL'
12008 ! include 'COMMON.VAR'
12009 ! include 'COMMON.MD'
12012 ! include 'COMMON.LANGEVIN'
12014 ! include 'COMMON.LANGEVIN.lang0'
12016 ! include 'COMMON.CHAIN'
12017 ! include 'COMMON.DERIV'
12018 ! include 'COMMON.GEO'
12019 ! include 'COMMON.LOCAL'
12020 ! include 'COMMON.INTERACT'
12021 ! include 'COMMON.IOUNITS'
12022 ! include 'COMMON.NAMES'
12023 ! include 'COMMON.TIME1'
12024 integer :: i,j,ii,k
12025 real(kind=8) :: utheta_i,dtheta_i,ugamma_i,dgamma_i,dxx,dyy,dzz
12027 if(.not.allocated(utheta)) allocate(utheta(nfrag_back))
12028 if(.not.allocated(ugamma)) allocate(ugamma(nfrag_back))
12029 if(.not.allocated(uscdiff)) allocate(uscdiff(nfrag_back))
12036 duscdiff(j,i)=0.0d0
12037 duscdiffx(j,i)=0.0d0
12041 ii = ifrag_back(2,i,iset)-ifrag_back(1,i,iset)
12043 ! Deviations from theta angles
12046 do j=ifrag_back(1,i,iset)+2,ifrag_back(2,i,iset)
12047 dtheta_i=theta(j)-thetaref(j)
12048 utheta_i=utheta_i+0.5d0*dtheta_i*dtheta_i
12049 dutheta(j-2)=dutheta(j-2)+wfrag_back(1,i,iset)*dtheta_i/(ii-1)
12051 utheta(i)=utheta_i/(ii-1)
12053 ! Deviations from gamma angles
12056 do j=ifrag_back(1,i,iset)+3,ifrag_back(2,i,iset)
12057 dgamma_i=pinorm(phi(j)-phiref(j))
12058 ! write (iout,*) j,phi(j),phi(j)-phiref(j)
12059 ugamma_i=ugamma_i+0.5d0*dgamma_i*dgamma_i
12060 dugamma(j-3)=dugamma(j-3)+wfrag_back(2,i,iset)*dgamma_i/(ii-2)
12061 ! write (iout,*) i,j,dgamma_i,wfrag_back(2,i,iset),dugamma(j-3)
12063 ugamma(i)=ugamma_i/(ii-2)
12065 ! Deviations from local SC geometry
12068 do j=ifrag_back(1,i,iset)+1,ifrag_back(2,i,iset)-1
12069 dxx=xxtab(j)-xxref(j)
12070 dyy=yytab(j)-yyref(j)
12071 dzz=zztab(j)-zzref(j)
12072 uscdiff(i)=uscdiff(i)+dxx*dxx+dyy*dyy+dzz*dzz
12074 duscdiff(k,j-1)=duscdiff(k,j-1)+wfrag_back(3,i,iset)* &
12075 (dXX_C1tab(k,j)*dxx+dYY_C1tab(k,j)*dyy+dZZ_C1tab(k,j)*dzz)/ &
12077 duscdiff(k,j)=duscdiff(k,j)+wfrag_back(3,i,iset)* &
12078 (dXX_Ctab(k,j)*dxx+dYY_Ctab(k,j)*dyy+dZZ_Ctab(k,j)*dzz)/ &
12080 duscdiffx(k,j)=duscdiffx(k,j)+wfrag_back(3,i,iset)* &
12081 (dXX_XYZtab(k,j)*dxx+dYY_XYZtab(k,j)*dyy+dZZ_XYZtab(k,j)*dzz) &
12084 ! write (iout,'(i5,6f10.5)') j,xxtab(j),yytab(j),zztab(j),
12085 ! & xxref(j),yyref(j),zzref(j)
12087 uscdiff(i)=0.5d0*uscdiff(i)/(ii-1)
12088 ! write (iout,*) i," uscdiff",uscdiff(i)
12090 ! Put together deviations from local geometry
12092 Uconst_back=Uconst_back+wfrag_back(1,i,iset)*utheta(i)+ &
12093 wfrag_back(2,i,iset)*ugamma(i)+wfrag_back(3,i,iset)*uscdiff(i)
12094 ! write(iout,*) "i",i," utheta",utheta(i)," ugamma",ugamma(i),
12095 ! & " uconst_back",uconst_back
12096 utheta(i)=dsqrt(utheta(i))
12097 ugamma(i)=dsqrt(ugamma(i))
12098 uscdiff(i)=dsqrt(uscdiff(i))
12101 end subroutine Econstr_back
12102 !-----------------------------------------------------------------------------
12103 ! energy_p_new-sep_barrier.F
12104 !-----------------------------------------------------------------------------
12105 real(kind=8) function sscale(r)
12106 ! include "COMMON.SPLITELE"
12107 real(kind=8) :: r,gamm
12108 if(r.lt.r_cut-rlamb) then
12110 else if(r.le.r_cut.and.r.ge.r_cut-rlamb) then
12111 gamm=(r-(r_cut-rlamb))/rlamb
12112 sscale=1.0d0+gamm*gamm*(2*gamm-3.0d0)
12117 end function sscale
12118 real(kind=8) function sscale_grad(r)
12119 ! include "COMMON.SPLITELE"
12120 real(kind=8) :: r,gamm
12121 if(r.lt.r_cut-rlamb) then
12123 else if(r.le.r_cut.and.r.ge.r_cut-rlamb) then
12124 gamm=(r-(r_cut-rlamb))/rlamb
12125 sscale_grad=gamm*(6*gamm-6.0d0)/rlamb
12130 end function sscale_grad
12132 !!!!!!!!!! PBCSCALE
12133 real(kind=8) function sscale_ele(r)
12134 ! include "COMMON.SPLITELE"
12135 real(kind=8) :: r,gamm
12136 if(r.lt.r_cut_ele-rlamb_ele) then
12138 else if(r.le.r_cut_ele.and.r.ge.r_cut_ele-rlamb_ele) then
12139 gamm=(r-(r_cut_ele-rlamb_ele))/rlamb_ele
12140 sscale_ele=1.0d0+gamm*gamm*(2*gamm-3.0d0)
12145 end function sscale_ele
12147 real(kind=8) function sscagrad_ele(r)
12148 real(kind=8) :: r,gamm
12149 ! include "COMMON.SPLITELE"
12150 if(r.lt.r_cut_ele-rlamb_ele) then
12152 else if(r.le.r_cut_ele.and.r.ge.r_cut_ele-rlamb_ele) then
12153 gamm=(r-(r_cut_ele-rlamb_ele))/rlamb_ele
12154 sscagrad_ele=gamm*(6*gamm-6.0d0)/rlamb_ele
12159 end function sscagrad_ele
12160 real(kind=8) function sscalelip(r)
12161 real(kind=8) r,gamm
12162 sscalelip=1.0d0+r*r*(2.0d0*r-3.0d0)
12164 end function sscalelip
12165 !C-----------------------------------------------------------------------
12166 real(kind=8) function sscagradlip(r)
12167 real(kind=8) r,gamm
12168 sscagradlip=r*(6.0d0*r-6.0d0)
12170 end function sscagradlip
12173 !-----------------------------------------------------------------------------
12174 subroutine elj_long(evdw)
12176 ! This subroutine calculates the interaction energy of nonbonded side chains
12177 ! assuming the LJ potential of interaction.
12179 ! implicit real*8 (a-h,o-z)
12180 ! include 'DIMENSIONS'
12181 ! include 'COMMON.GEO'
12182 ! include 'COMMON.VAR'
12183 ! include 'COMMON.LOCAL'
12184 ! include 'COMMON.CHAIN'
12185 ! include 'COMMON.DERIV'
12186 ! include 'COMMON.INTERACT'
12187 ! include 'COMMON.TORSION'
12188 ! include 'COMMON.SBRIDGE'
12189 ! include 'COMMON.NAMES'
12190 ! include 'COMMON.IOUNITS'
12191 ! include 'COMMON.CONTACTS'
12192 real(kind=8),parameter :: accur=1.0d-10
12193 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
12194 !el local variables
12195 integer :: i,iint,j,k,itypi,itypi1,itypj
12196 real(kind=8) :: xi,yi,zi,xj,yj,zj,rij,sss,rrij,fac,eps0ij
12197 real(kind=8) :: e1,e2,evdwij,evdw
12198 ! write(iout,*)'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
12200 do i=iatsc_s,iatsc_e
12202 if (itypi.eq.ntyp1) cycle
12203 itypi1=itype(i+1,1)
12208 ! Calculate SC interaction energy.
12210 do iint=1,nint_gr(i)
12211 !d write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
12212 !d & 'iend=',iend(i,iint)
12213 do j=istart(i,iint),iend(i,iint)
12215 if (itypj.eq.ntyp1) cycle
12219 rij=xj*xj+yj*yj+zj*zj
12220 sss=sscale(dsqrt(rij)/sigma(itypi,itypj))
12221 if (sss.lt.1.0d0) then
12223 eps0ij=eps(itypi,itypj)
12225 e1=fac*fac*aa_aq(itypi,itypj)
12226 e2=fac*bb_aq(itypi,itypj)
12228 evdw=evdw+(1.0d0-sss)*evdwij
12230 ! Calculate the components of the gradient in DC and X
12232 fac=-rrij*(e1+evdwij)*(1.0d0-sss)
12237 gvdwx(k,i)=gvdwx(k,i)-gg(k)
12238 gvdwx(k,j)=gvdwx(k,j)+gg(k)
12239 gvdwc(k,i)=gvdwc(k,i)-gg(k)
12240 gvdwc(k,j)=gvdwc(k,j)+gg(k)
12248 gvdwc(j,i)=expon*gvdwc(j,i)
12249 gvdwx(j,i)=expon*gvdwx(j,i)
12252 !******************************************************************************
12256 ! To save time, the factor of EXPON has been extracted from ALL components
12257 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
12260 !******************************************************************************
12262 end subroutine elj_long
12263 !-----------------------------------------------------------------------------
12264 subroutine elj_short(evdw)
12266 ! This subroutine calculates the interaction energy of nonbonded side chains
12267 ! assuming the LJ potential of interaction.
12269 ! implicit real*8 (a-h,o-z)
12270 ! include 'DIMENSIONS'
12271 ! include 'COMMON.GEO'
12272 ! include 'COMMON.VAR'
12273 ! include 'COMMON.LOCAL'
12274 ! include 'COMMON.CHAIN'
12275 ! include 'COMMON.DERIV'
12276 ! include 'COMMON.INTERACT'
12277 ! include 'COMMON.TORSION'
12278 ! include 'COMMON.SBRIDGE'
12279 ! include 'COMMON.NAMES'
12280 ! include 'COMMON.IOUNITS'
12281 ! include 'COMMON.CONTACTS'
12282 real(kind=8),parameter :: accur=1.0d-10
12283 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
12284 !el local variables
12285 integer :: i,iint,j,k,itypi,itypi1,itypj,num_conti
12286 real(kind=8) :: xi,yi,zi,xj,yj,zj,rij,sss,rrij,fac,eps0ij
12287 real(kind=8) :: e1,e2,evdwij,evdw
12288 ! write(iout,*)'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
12290 do i=iatsc_s,iatsc_e
12292 if (itypi.eq.ntyp1) cycle
12293 itypi1=itype(i+1,1)
12300 ! Calculate SC interaction energy.
12302 do iint=1,nint_gr(i)
12303 !d write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
12304 !d & 'iend=',iend(i,iint)
12305 do j=istart(i,iint),iend(i,iint)
12307 if (itypj.eq.ntyp1) cycle
12311 ! Change 12/1/95 to calculate four-body interactions
12312 rij=xj*xj+yj*yj+zj*zj
12313 sss=sscale(dsqrt(rij)/sigma(itypi,itypj))
12314 if (sss.gt.0.0d0) then
12316 eps0ij=eps(itypi,itypj)
12318 e1=fac*fac*aa_aq(itypi,itypj)
12319 e2=fac*bb_aq(itypi,itypj)
12321 evdw=evdw+sss*evdwij
12323 ! Calculate the components of the gradient in DC and X
12325 fac=-rrij*(e1+evdwij)*sss
12330 gvdwx(k,i)=gvdwx(k,i)-gg(k)
12331 gvdwx(k,j)=gvdwx(k,j)+gg(k)
12332 gvdwc(k,i)=gvdwc(k,i)-gg(k)
12333 gvdwc(k,j)=gvdwc(k,j)+gg(k)
12341 gvdwc(j,i)=expon*gvdwc(j,i)
12342 gvdwx(j,i)=expon*gvdwx(j,i)
12345 !******************************************************************************
12349 ! To save time, the factor of EXPON has been extracted from ALL components
12350 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
12353 !******************************************************************************
12355 end subroutine elj_short
12356 !-----------------------------------------------------------------------------
12357 subroutine eljk_long(evdw)
12359 ! This subroutine calculates the interaction energy of nonbonded side chains
12360 ! assuming the LJK potential of interaction.
12362 ! implicit real*8 (a-h,o-z)
12363 ! include 'DIMENSIONS'
12364 ! include 'COMMON.GEO'
12365 ! include 'COMMON.VAR'
12366 ! include 'COMMON.LOCAL'
12367 ! include 'COMMON.CHAIN'
12368 ! include 'COMMON.DERIV'
12369 ! include 'COMMON.INTERACT'
12370 ! include 'COMMON.IOUNITS'
12371 ! include 'COMMON.NAMES'
12372 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
12374 !el local variables
12375 integer :: i,iint,j,k,itypi,itypi1,itypj
12376 real(kind=8) :: rrij,r_inv_ij,xj,yj,zj,xi,yi,zi,fac,evdw,&
12377 fac_augm,e_augm,rij,sss,r_shift_inv,e1,e2,evdwij
12378 ! print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
12380 do i=iatsc_s,iatsc_e
12382 if (itypi.eq.ntyp1) cycle
12383 itypi1=itype(i+1,1)
12388 ! Calculate SC interaction energy.
12390 do iint=1,nint_gr(i)
12391 do j=istart(i,iint),iend(i,iint)
12393 if (itypj.eq.ntyp1) cycle
12397 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
12398 fac_augm=rrij**expon
12399 e_augm=augm(itypi,itypj)*fac_augm
12400 r_inv_ij=dsqrt(rrij)
12402 sss=sscale(rij/sigma(itypi,itypj))
12403 if (sss.lt.1.0d0) then
12404 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
12405 fac=r_shift_inv**expon
12406 e1=fac*fac*aa_aq(itypi,itypj)
12407 e2=fac*bb_aq(itypi,itypj)
12408 evdwij=e_augm+e1+e2
12409 !d sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
12410 !d epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
12411 !d write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
12412 !d & restyp(itypi,1),i,restyp(itypj,1),j,aa(itypi,itypj),
12413 !d & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
12414 !d & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
12415 !d & (c(k,i),k=1,3),(c(k,j),k=1,3)
12416 evdw=evdw+(1.0d0-sss)*evdwij
12418 ! Calculate the components of the gradient in DC and X
12420 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
12421 fac=fac*(1.0d0-sss)
12426 gvdwx(k,i)=gvdwx(k,i)-gg(k)
12427 gvdwx(k,j)=gvdwx(k,j)+gg(k)
12428 gvdwc(k,i)=gvdwc(k,i)-gg(k)
12429 gvdwc(k,j)=gvdwc(k,j)+gg(k)
12437 gvdwc(j,i)=expon*gvdwc(j,i)
12438 gvdwx(j,i)=expon*gvdwx(j,i)
12442 end subroutine eljk_long
12443 !-----------------------------------------------------------------------------
12444 subroutine eljk_short(evdw)
12446 ! This subroutine calculates the interaction energy of nonbonded side chains
12447 ! assuming the LJK potential of interaction.
12449 ! implicit real*8 (a-h,o-z)
12450 ! include 'DIMENSIONS'
12451 ! include 'COMMON.GEO'
12452 ! include 'COMMON.VAR'
12453 ! include 'COMMON.LOCAL'
12454 ! include 'COMMON.CHAIN'
12455 ! include 'COMMON.DERIV'
12456 ! include 'COMMON.INTERACT'
12457 ! include 'COMMON.IOUNITS'
12458 ! include 'COMMON.NAMES'
12459 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
12461 !el local variables
12462 integer :: i,iint,j,k,itypi,itypi1,itypj
12463 real(kind=8) :: rrij,r_inv_ij,xj,yj,zj,xi,yi,zi,fac,evdw,&
12464 fac_augm,e_augm,rij,sss,r_shift_inv,e1,e2,evdwij
12465 ! print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
12467 do i=iatsc_s,iatsc_e
12469 if (itypi.eq.ntyp1) cycle
12470 itypi1=itype(i+1,1)
12475 ! Calculate SC interaction energy.
12477 do iint=1,nint_gr(i)
12478 do j=istart(i,iint),iend(i,iint)
12480 if (itypj.eq.ntyp1) cycle
12484 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
12485 fac_augm=rrij**expon
12486 e_augm=augm(itypi,itypj)*fac_augm
12487 r_inv_ij=dsqrt(rrij)
12489 sss=sscale(rij/sigma(itypi,itypj))
12490 if (sss.gt.0.0d0) then
12491 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
12492 fac=r_shift_inv**expon
12493 e1=fac*fac*aa_aq(itypi,itypj)
12494 e2=fac*bb_aq(itypi,itypj)
12495 evdwij=e_augm+e1+e2
12496 !d sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
12497 !d epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
12498 !d write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
12499 !d & restyp(itypi,1),i,restyp(itypj,1),j,aa(itypi,itypj),
12500 !d & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
12501 !d & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
12502 !d & (c(k,i),k=1,3),(c(k,j),k=1,3)
12503 evdw=evdw+sss*evdwij
12505 ! Calculate the components of the gradient in DC and X
12507 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
12513 gvdwx(k,i)=gvdwx(k,i)-gg(k)
12514 gvdwx(k,j)=gvdwx(k,j)+gg(k)
12515 gvdwc(k,i)=gvdwc(k,i)-gg(k)
12516 gvdwc(k,j)=gvdwc(k,j)+gg(k)
12524 gvdwc(j,i)=expon*gvdwc(j,i)
12525 gvdwx(j,i)=expon*gvdwx(j,i)
12529 end subroutine eljk_short
12530 !-----------------------------------------------------------------------------
12531 subroutine ebp_long(evdw)
12533 ! This subroutine calculates the interaction energy of nonbonded side chains
12534 ! assuming the Berne-Pechukas potential of interaction.
12537 ! implicit real*8 (a-h,o-z)
12538 ! include 'DIMENSIONS'
12539 ! include 'COMMON.GEO'
12540 ! include 'COMMON.VAR'
12541 ! include 'COMMON.LOCAL'
12542 ! include 'COMMON.CHAIN'
12543 ! include 'COMMON.DERIV'
12544 ! include 'COMMON.NAMES'
12545 ! include 'COMMON.INTERACT'
12546 ! include 'COMMON.IOUNITS'
12547 ! include 'COMMON.CALC'
12549 !el integer :: icall
12550 !el common /srutu/ icall
12551 ! double precision rrsave(maxdim)
12553 !el local variables
12554 integer :: iint,itypi,itypi1,itypj
12555 real(kind=8) :: rrij,xi,yi,zi,fac
12556 real(kind=8) :: sss,e1,e2,evdw,sigm,epsi
12558 ! print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
12560 ! if (icall.eq.0) then
12566 do i=iatsc_s,iatsc_e
12568 if (itypi.eq.ntyp1) cycle
12569 itypi1=itype(i+1,1)
12573 dxi=dc_norm(1,nres+i)
12574 dyi=dc_norm(2,nres+i)
12575 dzi=dc_norm(3,nres+i)
12576 ! dsci_inv=dsc_inv(itypi)
12577 dsci_inv=vbld_inv(i+nres)
12579 ! Calculate SC interaction energy.
12581 do iint=1,nint_gr(i)
12582 do j=istart(i,iint),iend(i,iint)
12585 if (itypj.eq.ntyp1) cycle
12586 ! dscj_inv=dsc_inv(itypj)
12587 dscj_inv=vbld_inv(j+nres)
12588 chi1=chi(itypi,itypj)
12589 chi2=chi(itypj,itypi)
12596 alf12=0.5D0*(alf1+alf2)
12600 dxj=dc_norm(1,nres+j)
12601 dyj=dc_norm(2,nres+j)
12602 dzj=dc_norm(3,nres+j)
12603 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
12605 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
12607 if (sss.lt.1.0d0) then
12609 ! Calculate the angle-dependent terms of energy & contributions to derivatives.
12611 ! Calculate whole angle-dependent part of epsilon and contributions
12612 ! to its derivatives
12613 fac=(rrij*sigsq)**expon2
12614 e1=fac*fac*aa_aq(itypi,itypj)
12615 e2=fac*bb_aq(itypi,itypj)
12616 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
12617 eps2der=evdwij*eps3rt
12618 eps3der=evdwij*eps2rt
12619 evdwij=evdwij*eps2rt*eps3rt
12620 evdw=evdw+evdwij*(1.0d0-sss)
12622 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
12623 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
12624 !d write (iout,'(2(a3,i3,2x),15(0pf7.3))')
12625 !d & restyp(itypi,1),i,restyp(itypj,1),j,
12626 !d & epsi,sigm,chi1,chi2,chip1,chip2,
12627 !d & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
12628 !d & om1,om2,om12,1.0D0/dsqrt(rrij),
12631 ! Calculate gradient components.
12632 e1=e1*eps1*eps2rt**2*eps3rt**2
12633 fac=-expon*(e1+evdwij)
12636 ! Calculate radial part of the gradient
12640 ! Calculate the angular part of the gradient and sum add the contributions
12641 ! to the appropriate components of the Cartesian gradient.
12642 call sc_grad_scale(1.0d0-sss)
12649 end subroutine ebp_long
12650 !-----------------------------------------------------------------------------
12651 subroutine ebp_short(evdw)
12653 ! This subroutine calculates the interaction energy of nonbonded side chains
12654 ! assuming the Berne-Pechukas potential of interaction.
12657 ! implicit real*8 (a-h,o-z)
12658 ! include 'DIMENSIONS'
12659 ! include 'COMMON.GEO'
12660 ! include 'COMMON.VAR'
12661 ! include 'COMMON.LOCAL'
12662 ! include 'COMMON.CHAIN'
12663 ! include 'COMMON.DERIV'
12664 ! include 'COMMON.NAMES'
12665 ! include 'COMMON.INTERACT'
12666 ! include 'COMMON.IOUNITS'
12667 ! include 'COMMON.CALC'
12669 !el integer :: icall
12670 !el common /srutu/ icall
12671 ! double precision rrsave(maxdim)
12673 !el local variables
12674 integer :: iint,itypi,itypi1,itypj
12675 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi
12676 real(kind=8) :: sss,e1,e2,evdw
12678 ! print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
12680 ! if (icall.eq.0) then
12686 do i=iatsc_s,iatsc_e
12688 if (itypi.eq.ntyp1) cycle
12689 itypi1=itype(i+1,1)
12693 dxi=dc_norm(1,nres+i)
12694 dyi=dc_norm(2,nres+i)
12695 dzi=dc_norm(3,nres+i)
12696 ! dsci_inv=dsc_inv(itypi)
12697 dsci_inv=vbld_inv(i+nres)
12699 ! Calculate SC interaction energy.
12701 do iint=1,nint_gr(i)
12702 do j=istart(i,iint),iend(i,iint)
12705 if (itypj.eq.ntyp1) cycle
12706 ! dscj_inv=dsc_inv(itypj)
12707 dscj_inv=vbld_inv(j+nres)
12708 chi1=chi(itypi,itypj)
12709 chi2=chi(itypj,itypi)
12716 alf12=0.5D0*(alf1+alf2)
12720 dxj=dc_norm(1,nres+j)
12721 dyj=dc_norm(2,nres+j)
12722 dzj=dc_norm(3,nres+j)
12723 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
12725 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
12727 if (sss.gt.0.0d0) then
12729 ! Calculate the angle-dependent terms of energy & contributions to derivatives.
12731 ! Calculate whole angle-dependent part of epsilon and contributions
12732 ! to its derivatives
12733 fac=(rrij*sigsq)**expon2
12734 e1=fac*fac*aa_aq(itypi,itypj)
12735 e2=fac*bb_aq(itypi,itypj)
12736 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
12737 eps2der=evdwij*eps3rt
12738 eps3der=evdwij*eps2rt
12739 evdwij=evdwij*eps2rt*eps3rt
12740 evdw=evdw+evdwij*sss
12742 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
12743 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
12744 !d write (iout,'(2(a3,i3,2x),15(0pf7.3))')
12745 !d & restyp(itypi,1),i,restyp(itypj,1),j,
12746 !d & epsi,sigm,chi1,chi2,chip1,chip2,
12747 !d & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
12748 !d & om1,om2,om12,1.0D0/dsqrt(rrij),
12751 ! Calculate gradient components.
12752 e1=e1*eps1*eps2rt**2*eps3rt**2
12753 fac=-expon*(e1+evdwij)
12756 ! Calculate radial part of the gradient
12760 ! Calculate the angular part of the gradient and sum add the contributions
12761 ! to the appropriate components of the Cartesian gradient.
12762 call sc_grad_scale(sss)
12769 end subroutine ebp_short
12770 !-----------------------------------------------------------------------------
12771 subroutine egb_long(evdw)
12773 ! This subroutine calculates the interaction energy of nonbonded side chains
12774 ! assuming the Gay-Berne potential of interaction.
12777 ! implicit real*8 (a-h,o-z)
12778 ! include 'DIMENSIONS'
12779 ! include 'COMMON.GEO'
12780 ! include 'COMMON.VAR'
12781 ! include 'COMMON.LOCAL'
12782 ! include 'COMMON.CHAIN'
12783 ! include 'COMMON.DERIV'
12784 ! include 'COMMON.NAMES'
12785 ! include 'COMMON.INTERACT'
12786 ! include 'COMMON.IOUNITS'
12787 ! include 'COMMON.CALC'
12788 ! include 'COMMON.CONTROL'
12790 !el local variables
12791 integer :: iint,itypi,itypi1,itypj,subchap
12792 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,sig,sig0ij,rij_shift
12793 real(kind=8) :: sss,e1,e2,evdw,sss_grad
12794 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
12795 dist_temp, dist_init,aa,bb,fracinbuf,sslipi,sslipj,&
12796 ssgradlipi,ssgradlipj
12800 !cccc energy_dec=.false.
12801 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
12804 ! if (icall.eq.0) lprn=.false.
12806 do i=iatsc_s,iatsc_e
12808 if (itypi.eq.ntyp1) cycle
12809 itypi1=itype(i+1,1)
12813 xi=mod(xi,boxxsize)
12814 if (xi.lt.0) xi=xi+boxxsize
12815 yi=mod(yi,boxysize)
12816 if (yi.lt.0) yi=yi+boxysize
12817 zi=mod(zi,boxzsize)
12818 if (zi.lt.0) zi=zi+boxzsize
12819 if ((zi.gt.bordlipbot) &
12820 .and.(zi.lt.bordliptop)) then
12821 !C the energy transfer exist
12822 if (zi.lt.buflipbot) then
12823 !C what fraction I am in
12825 ((zi-bordlipbot)/lipbufthick)
12826 !C lipbufthick is thickenes of lipid buffore
12827 sslipi=sscalelip(fracinbuf)
12828 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
12829 elseif (zi.gt.bufliptop) then
12830 fracinbuf=1.0d0-((bordliptop-zi)/lipbufthick)
12831 sslipi=sscalelip(fracinbuf)
12832 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
12842 dxi=dc_norm(1,nres+i)
12843 dyi=dc_norm(2,nres+i)
12844 dzi=dc_norm(3,nres+i)
12845 ! dsci_inv=dsc_inv(itypi)
12846 dsci_inv=vbld_inv(i+nres)
12847 ! write (iout,*) "i",i,dsc_inv(itypi),dsci_inv,1.0d0/vbld(i+nres)
12848 ! write (iout,*) "dcnori",dxi*dxi+dyi*dyi+dzi*dzi
12850 ! Calculate SC interaction energy.
12852 do iint=1,nint_gr(i)
12853 do j=istart(i,iint),iend(i,iint)
12854 IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
12855 ! call dyn_ssbond_ene(i,j,evdwij)
12857 ! if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
12858 ! 'evdw',i,j,evdwij,' ss'
12859 ! if (energy_dec) write (iout,*) &
12860 ! 'evdw',i,j,evdwij,' ss'
12861 ! do k=j+1,iend(i,iint)
12862 !C search over all next residues
12863 ! if (dyn_ss_mask(k)) then
12864 !C check if they are cysteins
12865 !C write(iout,*) 'k=',k
12867 !c write(iout,*) "PRZED TRI", evdwij
12868 ! evdwij_przed_tri=evdwij
12869 ! call triple_ssbond_ene(i,j,k,evdwij)
12870 !c if(evdwij_przed_tri.ne.evdwij) then
12871 !c write (iout,*) "TRI:", evdwij, evdwij_przed_tri
12874 !c write(iout,*) "PO TRI", evdwij
12875 !C call the energy function that removes the artifical triple disulfide
12876 !C bond the soubroutine is located in ssMD.F
12878 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
12879 'evdw',i,j,evdwij,'tss'
12880 ! endif!dyn_ss_mask(k)
12886 if (itypj.eq.ntyp1) cycle
12887 ! dscj_inv=dsc_inv(itypj)
12888 dscj_inv=vbld_inv(j+nres)
12889 ! write (iout,*) "j",j,dsc_inv(itypj),dscj_inv,
12890 ! & 1.0d0/vbld(j+nres)
12891 ! write (iout,*) "i",i," j", j," itype",itype(i,1),itype(j,1)
12892 sig0ij=sigma(itypi,itypj)
12893 chi1=chi(itypi,itypj)
12894 chi2=chi(itypj,itypi)
12901 alf12=0.5D0*(alf1+alf2)
12905 ! Searching for nearest neighbour
12906 xj=mod(xj,boxxsize)
12907 if (xj.lt.0) xj=xj+boxxsize
12908 yj=mod(yj,boxysize)
12909 if (yj.lt.0) yj=yj+boxysize
12910 zj=mod(zj,boxzsize)
12911 if (zj.lt.0) zj=zj+boxzsize
12912 if ((zj.gt.bordlipbot) &
12913 .and.(zj.lt.bordliptop)) then
12914 !C the energy transfer exist
12915 if (zj.lt.buflipbot) then
12916 !C what fraction I am in
12918 ((zj-bordlipbot)/lipbufthick)
12919 !C lipbufthick is thickenes of lipid buffore
12920 sslipj=sscalelip(fracinbuf)
12921 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
12922 elseif (zj.gt.bufliptop) then
12923 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
12924 sslipj=sscalelip(fracinbuf)
12925 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
12934 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
12935 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
12936 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
12937 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
12939 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
12947 xj=xj_safe+xshift*boxxsize
12948 yj=yj_safe+yshift*boxysize
12949 zj=zj_safe+zshift*boxzsize
12950 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
12951 if(dist_temp.lt.dist_init) then
12952 dist_init=dist_temp
12961 if (subchap.eq.1) then
12971 dxj=dc_norm(1,nres+j)
12972 dyj=dc_norm(2,nres+j)
12973 dzj=dc_norm(3,nres+j)
12974 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
12976 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
12977 sss_ele_cut=sscale_ele(1.0d0/(rij*sigma(itypi,itypj)))
12978 sss_ele_grad=sscagrad_ele(1.0d0/(rij*sigma(itypi,itypj)))
12979 sss_grad=sscale_grad(1.0d0/(rij*sigmaii(itypi,itypj)))
12980 if (sss_ele_cut.le.0.0) cycle
12981 if (sss.lt.1.0d0) then
12983 ! Calculate angle-dependent terms of energy and contributions to their
12987 sig=sig0ij*dsqrt(sigsq)
12988 rij_shift=1.0D0/rij-sig+sig0ij
12989 ! for diagnostics; uncomment
12990 ! rij_shift=1.2*sig0ij
12991 ! I hate to put IF's in the loops, but here don't have another choice!!!!
12992 if (rij_shift.le.0.0D0) then
12994 !d write (iout,'(2(a3,i3,2x),17(0pf7.3))')
12995 !d & restyp(itypi,1),i,restyp(itypj,1),j,
12996 !d & rij_shift,1.0D0/rij,sig,sig0ij,sigsq,1-dsqrt(sigsq)
13000 !---------------------------------------------------------------
13001 rij_shift=1.0D0/rij_shift
13002 fac=rij_shift**expon
13005 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
13006 eps2der=evdwij*eps3rt
13007 eps3der=evdwij*eps2rt
13008 ! write (iout,*) "sigsq",sigsq," sig",sig," eps2rt",eps2rt,
13009 ! & " eps3rt",eps3rt," eps1",eps1," e1",e1," e2",e2
13010 evdwij=evdwij*eps2rt*eps3rt
13011 evdw=evdw+evdwij*(1.0d0-sss)*sss_ele_cut
13013 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
13014 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
13015 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
13016 restyp(itypi,1),i,restyp(itypj,1),j,&
13017 epsi,sigm,chi1,chi2,chip1,chip2,&
13018 eps1,eps2rt**2,eps3rt**2,sig,sig0ij,&
13019 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
13023 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
13025 ! if (energy_dec) write (iout,*) &
13026 ! 'evdw',i,j,evdwij,"egb_long"
13028 ! Calculate gradient components.
13029 e1=e1*eps1*eps2rt**2*eps3rt**2
13030 fac=-expon*(e1+evdwij)*rij_shift
13033 fac=fac+evdwij*(sss_ele_grad/sss_ele_cut&
13034 /sigma(itypi,itypj)*rij-sss_grad/(1.0-sss)*rij &
13035 /sigmaii(itypi,itypj))
13037 ! Calculate the radial part of the gradient
13041 ! Calculate angular part of the gradient.
13042 call sc_grad_scale(1.0d0-sss)
13048 ! write (iout,*) "Number of loop steps in EGB:",ind
13049 !ccc energy_dec=.false.
13051 end subroutine egb_long
13052 !-----------------------------------------------------------------------------
13053 subroutine egb_short(evdw)
13055 ! This subroutine calculates the interaction energy of nonbonded side chains
13056 ! assuming the Gay-Berne potential of interaction.
13059 ! implicit real*8 (a-h,o-z)
13060 ! include 'DIMENSIONS'
13061 ! include 'COMMON.GEO'
13062 ! include 'COMMON.VAR'
13063 ! include 'COMMON.LOCAL'
13064 ! include 'COMMON.CHAIN'
13065 ! include 'COMMON.DERIV'
13066 ! include 'COMMON.NAMES'
13067 ! include 'COMMON.INTERACT'
13068 ! include 'COMMON.IOUNITS'
13069 ! include 'COMMON.CALC'
13070 ! include 'COMMON.CONTROL'
13072 !el local variables
13073 integer :: iint,itypi,itypi1,itypj,subchap
13074 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,sig0ij,sig
13075 real(kind=8) :: sss,e1,e2,evdw,rij_shift,sss_grad
13076 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
13077 dist_temp, dist_init,aa,bb,fracinbuf,sslipi,sslipj,&
13078 ssgradlipi,ssgradlipj
13080 !cccc energy_dec=.false.
13081 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
13084 ! if (icall.eq.0) lprn=.false.
13086 do i=iatsc_s,iatsc_e
13088 if (itypi.eq.ntyp1) cycle
13089 itypi1=itype(i+1,1)
13093 xi=mod(xi,boxxsize)
13094 if (xi.lt.0) xi=xi+boxxsize
13095 yi=mod(yi,boxysize)
13096 if (yi.lt.0) yi=yi+boxysize
13097 zi=mod(zi,boxzsize)
13098 if (zi.lt.0) zi=zi+boxzsize
13099 if ((zi.gt.bordlipbot) &
13100 .and.(zi.lt.bordliptop)) then
13101 !C the energy transfer exist
13102 if (zi.lt.buflipbot) then
13103 !C what fraction I am in
13105 ((zi-bordlipbot)/lipbufthick)
13106 !C lipbufthick is thickenes of lipid buffore
13107 sslipi=sscalelip(fracinbuf)
13108 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
13109 elseif (zi.gt.bufliptop) then
13110 fracinbuf=1.0d0-((bordliptop-zi)/lipbufthick)
13111 sslipi=sscalelip(fracinbuf)
13112 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
13122 dxi=dc_norm(1,nres+i)
13123 dyi=dc_norm(2,nres+i)
13124 dzi=dc_norm(3,nres+i)
13125 ! dsci_inv=dsc_inv(itypi)
13126 dsci_inv=vbld_inv(i+nres)
13128 dxi=dc_norm(1,nres+i)
13129 dyi=dc_norm(2,nres+i)
13130 dzi=dc_norm(3,nres+i)
13131 ! dsci_inv=dsc_inv(itypi)
13132 dsci_inv=vbld_inv(i+nres)
13133 ! write (iout,*) "i",i,dsc_inv(itypi),dsci_inv,1.0d0/vbld(i+nres)
13134 ! write (iout,*) "dcnori",dxi*dxi+dyi*dyi+dzi*dzi
13136 ! Calculate SC interaction energy.
13138 do iint=1,nint_gr(i)
13139 do j=istart(i,iint),iend(i,iint)
13140 IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
13141 call dyn_ssbond_ene(i,j,evdwij)
13143 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
13144 'evdw',i,j,evdwij,' ss'
13145 do k=j+1,iend(i,iint)
13146 !C search over all next residues
13147 if (dyn_ss_mask(k)) then
13148 !C check if they are cysteins
13149 !C write(iout,*) 'k=',k
13151 !c write(iout,*) "PRZED TRI", evdwij
13152 ! evdwij_przed_tri=evdwij
13153 call triple_ssbond_ene(i,j,k,evdwij)
13154 !c if(evdwij_przed_tri.ne.evdwij) then
13155 !c write (iout,*) "TRI:", evdwij, evdwij_przed_tri
13158 !c write(iout,*) "PO TRI", evdwij
13159 !C call the energy function that removes the artifical triple disulfide
13160 !C bond the soubroutine is located in ssMD.F
13162 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
13163 'evdw',i,j,evdwij,'tss'
13164 endif!dyn_ss_mask(k)
13167 ! if (energy_dec) write (iout,*) &
13168 ! 'evdw',i,j,evdwij,' ss'
13172 if (itypj.eq.ntyp1) cycle
13173 ! dscj_inv=dsc_inv(itypj)
13174 dscj_inv=vbld_inv(j+nres)
13175 ! write (iout,*) "j",j,dsc_inv(itypj),dscj_inv,
13176 ! & 1.0d0/vbld(j+nres)
13177 ! write (iout,*) "i",i," j", j," itype",itype(i,1),itype(j,1)
13178 sig0ij=sigma(itypi,itypj)
13179 chi1=chi(itypi,itypj)
13180 chi2=chi(itypj,itypi)
13187 alf12=0.5D0*(alf1+alf2)
13188 ! xj=c(1,nres+j)-xi
13189 ! yj=c(2,nres+j)-yi
13190 ! zj=c(3,nres+j)-zi
13194 ! Searching for nearest neighbour
13195 xj=mod(xj,boxxsize)
13196 if (xj.lt.0) xj=xj+boxxsize
13197 yj=mod(yj,boxysize)
13198 if (yj.lt.0) yj=yj+boxysize
13199 zj=mod(zj,boxzsize)
13200 if (zj.lt.0) zj=zj+boxzsize
13201 if ((zj.gt.bordlipbot) &
13202 .and.(zj.lt.bordliptop)) then
13203 !C the energy transfer exist
13204 if (zj.lt.buflipbot) then
13205 !C what fraction I am in
13207 ((zj-bordlipbot)/lipbufthick)
13208 !C lipbufthick is thickenes of lipid buffore
13209 sslipj=sscalelip(fracinbuf)
13210 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
13211 elseif (zj.gt.bufliptop) then
13212 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
13213 sslipj=sscalelip(fracinbuf)
13214 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
13223 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
13224 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
13225 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
13226 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
13228 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
13237 xj=xj_safe+xshift*boxxsize
13238 yj=yj_safe+yshift*boxysize
13239 zj=zj_safe+zshift*boxzsize
13240 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
13241 if(dist_temp.lt.dist_init) then
13242 dist_init=dist_temp
13251 if (subchap.eq.1) then
13261 dxj=dc_norm(1,nres+j)
13262 dyj=dc_norm(2,nres+j)
13263 dzj=dc_norm(3,nres+j)
13264 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
13266 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
13267 sss_grad=sscale_grad(1.0d0/(rij*sigmaii(itypi,itypj)))
13268 sss_ele_cut=sscale_ele(1.0d0/(rij*sigma(itypi,itypj)))
13269 sss_ele_grad=sscagrad_ele(1.0d0/(rij*sigma(itypi,itypj)))
13270 if (sss_ele_cut.le.0.0) cycle
13272 if (sss.gt.0.0d0) then
13274 ! Calculate angle-dependent terms of energy and contributions to their
13278 sig=sig0ij*dsqrt(sigsq)
13279 rij_shift=1.0D0/rij-sig+sig0ij
13280 ! for diagnostics; uncomment
13281 ! rij_shift=1.2*sig0ij
13282 ! I hate to put IF's in the loops, but here don't have another choice!!!!
13283 if (rij_shift.le.0.0D0) then
13285 !d write (iout,'(2(a3,i3,2x),17(0pf7.3))')
13286 !d & restyp(itypi,1),i,restyp(itypj,1),j,
13287 !d & rij_shift,1.0D0/rij,sig,sig0ij,sigsq,1-dsqrt(sigsq)
13291 !---------------------------------------------------------------
13292 rij_shift=1.0D0/rij_shift
13293 fac=rij_shift**expon
13296 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
13297 eps2der=evdwij*eps3rt
13298 eps3der=evdwij*eps2rt
13299 ! write (iout,*) "sigsq",sigsq," sig",sig," eps2rt",eps2rt,
13300 ! & " eps3rt",eps3rt," eps1",eps1," e1",e1," e2",e2
13301 evdwij=evdwij*eps2rt*eps3rt
13302 evdw=evdw+evdwij*sss*sss_ele_cut
13304 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
13305 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
13306 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
13307 restyp(itypi,1),i,restyp(itypj,1),j,&
13308 epsi,sigm,chi1,chi2,chip1,chip2,&
13309 eps1,eps2rt**2,eps3rt**2,sig,sig0ij,&
13310 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
13314 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
13316 ! if (energy_dec) write (iout,*) &
13317 ! 'evdw',i,j,evdwij,"egb_short"
13319 ! Calculate gradient components.
13320 e1=e1*eps1*eps2rt**2*eps3rt**2
13321 fac=-expon*(e1+evdwij)*rij_shift
13324 fac=fac+evdwij*(sss_ele_grad/sss_ele_cut&
13325 /sigma(itypi,itypj)*rij+sss_grad/sss*rij &
13326 /sigmaii(itypi,itypj))
13329 ! Calculate the radial part of the gradient
13333 ! Calculate angular part of the gradient.
13334 call sc_grad_scale(sss)
13340 ! write (iout,*) "Number of loop steps in EGB:",ind
13341 !ccc energy_dec=.false.
13343 end subroutine egb_short
13344 !-----------------------------------------------------------------------------
13345 subroutine egbv_long(evdw)
13347 ! This subroutine calculates the interaction energy of nonbonded side chains
13348 ! assuming the Gay-Berne-Vorobjev potential of interaction.
13351 ! implicit real*8 (a-h,o-z)
13352 ! include 'DIMENSIONS'
13353 ! include 'COMMON.GEO'
13354 ! include 'COMMON.VAR'
13355 ! include 'COMMON.LOCAL'
13356 ! include 'COMMON.CHAIN'
13357 ! include 'COMMON.DERIV'
13358 ! include 'COMMON.NAMES'
13359 ! include 'COMMON.INTERACT'
13360 ! include 'COMMON.IOUNITS'
13361 ! include 'COMMON.CALC'
13363 !el integer :: icall
13364 !el common /srutu/ icall
13366 !el local variables
13367 integer :: iint,itypi,itypi1,itypj
13368 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,r0ij,sig,sig0ij
13369 real(kind=8) :: sss,e1,e2,evdw,fac_augm,e_augm,rij_shift
13371 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
13374 ! if (icall.eq.0) lprn=.true.
13376 do i=iatsc_s,iatsc_e
13378 if (itypi.eq.ntyp1) cycle
13379 itypi1=itype(i+1,1)
13383 dxi=dc_norm(1,nres+i)
13384 dyi=dc_norm(2,nres+i)
13385 dzi=dc_norm(3,nres+i)
13386 ! dsci_inv=dsc_inv(itypi)
13387 dsci_inv=vbld_inv(i+nres)
13389 ! Calculate SC interaction energy.
13391 do iint=1,nint_gr(i)
13392 do j=istart(i,iint),iend(i,iint)
13395 if (itypj.eq.ntyp1) cycle
13396 ! dscj_inv=dsc_inv(itypj)
13397 dscj_inv=vbld_inv(j+nres)
13398 sig0ij=sigma(itypi,itypj)
13399 r0ij=r0(itypi,itypj)
13400 chi1=chi(itypi,itypj)
13401 chi2=chi(itypj,itypi)
13408 alf12=0.5D0*(alf1+alf2)
13412 dxj=dc_norm(1,nres+j)
13413 dyj=dc_norm(2,nres+j)
13414 dzj=dc_norm(3,nres+j)
13415 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
13418 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
13420 if (sss.lt.1.0d0) then
13422 ! Calculate angle-dependent terms of energy and contributions to their
13426 sig=sig0ij*dsqrt(sigsq)
13427 rij_shift=1.0D0/rij-sig+r0ij
13428 ! I hate to put IF's in the loops, but here don't have another choice!!!!
13429 if (rij_shift.le.0.0D0) then
13434 !---------------------------------------------------------------
13435 rij_shift=1.0D0/rij_shift
13436 fac=rij_shift**expon
13437 e1=fac*fac*aa_aq(itypi,itypj)
13438 e2=fac*bb_aq(itypi,itypj)
13439 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
13440 eps2der=evdwij*eps3rt
13441 eps3der=evdwij*eps2rt
13442 fac_augm=rrij**expon
13443 e_augm=augm(itypi,itypj)*fac_augm
13444 evdwij=evdwij*eps2rt*eps3rt
13445 evdw=evdw+(evdwij+e_augm)*(1.0d0-sss)
13447 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
13448 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
13449 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
13450 restyp(itypi,1),i,restyp(itypj,1),j,&
13451 epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),&
13452 chi1,chi2,chip1,chip2,&
13453 eps1,eps2rt**2,eps3rt**2,&
13454 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
13457 ! Calculate gradient components.
13458 e1=e1*eps1*eps2rt**2*eps3rt**2
13459 fac=-expon*(e1+evdwij)*rij_shift
13461 fac=rij*fac-2*expon*rrij*e_augm
13462 ! Calculate the radial part of the gradient
13466 ! Calculate angular part of the gradient.
13467 call sc_grad_scale(1.0d0-sss)
13472 end subroutine egbv_long
13473 !-----------------------------------------------------------------------------
13474 subroutine egbv_short(evdw)
13476 ! This subroutine calculates the interaction energy of nonbonded side chains
13477 ! assuming the Gay-Berne-Vorobjev potential of interaction.
13480 ! implicit real*8 (a-h,o-z)
13481 ! include 'DIMENSIONS'
13482 ! include 'COMMON.GEO'
13483 ! include 'COMMON.VAR'
13484 ! include 'COMMON.LOCAL'
13485 ! include 'COMMON.CHAIN'
13486 ! include 'COMMON.DERIV'
13487 ! include 'COMMON.NAMES'
13488 ! include 'COMMON.INTERACT'
13489 ! include 'COMMON.IOUNITS'
13490 ! include 'COMMON.CALC'
13492 !el integer :: icall
13493 !el common /srutu/ icall
13495 !el local variables
13496 integer :: iint,itypi,itypi1,itypj
13497 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,rij_shift
13498 real(kind=8) :: sss,e1,e2,evdw,r0ij,sig,sig0ij,fac_augm,e_augm
13500 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
13503 ! if (icall.eq.0) lprn=.true.
13505 do i=iatsc_s,iatsc_e
13507 if (itypi.eq.ntyp1) cycle
13508 itypi1=itype(i+1,1)
13512 dxi=dc_norm(1,nres+i)
13513 dyi=dc_norm(2,nres+i)
13514 dzi=dc_norm(3,nres+i)
13515 ! dsci_inv=dsc_inv(itypi)
13516 dsci_inv=vbld_inv(i+nres)
13518 ! Calculate SC interaction energy.
13520 do iint=1,nint_gr(i)
13521 do j=istart(i,iint),iend(i,iint)
13524 if (itypj.eq.ntyp1) cycle
13525 ! dscj_inv=dsc_inv(itypj)
13526 dscj_inv=vbld_inv(j+nres)
13527 sig0ij=sigma(itypi,itypj)
13528 r0ij=r0(itypi,itypj)
13529 chi1=chi(itypi,itypj)
13530 chi2=chi(itypj,itypi)
13537 alf12=0.5D0*(alf1+alf2)
13541 dxj=dc_norm(1,nres+j)
13542 dyj=dc_norm(2,nres+j)
13543 dzj=dc_norm(3,nres+j)
13544 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
13547 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
13549 if (sss.gt.0.0d0) then
13551 ! Calculate angle-dependent terms of energy and contributions to their
13555 sig=sig0ij*dsqrt(sigsq)
13556 rij_shift=1.0D0/rij-sig+r0ij
13557 ! I hate to put IF's in the loops, but here don't have another choice!!!!
13558 if (rij_shift.le.0.0D0) then
13563 !---------------------------------------------------------------
13564 rij_shift=1.0D0/rij_shift
13565 fac=rij_shift**expon
13566 e1=fac*fac*aa_aq(itypi,itypj)
13567 e2=fac*bb_aq(itypi,itypj)
13568 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
13569 eps2der=evdwij*eps3rt
13570 eps3der=evdwij*eps2rt
13571 fac_augm=rrij**expon
13572 e_augm=augm(itypi,itypj)*fac_augm
13573 evdwij=evdwij*eps2rt*eps3rt
13574 evdw=evdw+(evdwij+e_augm)*sss
13576 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
13577 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
13578 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
13579 restyp(itypi,1),i,restyp(itypj,1),j,&
13580 epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),&
13581 chi1,chi2,chip1,chip2,&
13582 eps1,eps2rt**2,eps3rt**2,&
13583 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
13586 ! Calculate gradient components.
13587 e1=e1*eps1*eps2rt**2*eps3rt**2
13588 fac=-expon*(e1+evdwij)*rij_shift
13590 fac=rij*fac-2*expon*rrij*e_augm
13591 ! Calculate the radial part of the gradient
13595 ! Calculate angular part of the gradient.
13596 call sc_grad_scale(sss)
13601 end subroutine egbv_short
13602 !-----------------------------------------------------------------------------
13603 subroutine eelec_scale(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
13605 ! This subroutine calculates the average interaction energy and its gradient
13606 ! in the virtual-bond vectors between non-adjacent peptide groups, based on
13607 ! the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
13608 ! The potential depends both on the distance of peptide-group centers and on
13609 ! the orientation of the CA-CA virtual bonds.
13611 ! implicit real*8 (a-h,o-z)
13617 ! include 'DIMENSIONS'
13618 ! include 'COMMON.CONTROL'
13619 ! include 'COMMON.SETUP'
13620 ! include 'COMMON.IOUNITS'
13621 ! include 'COMMON.GEO'
13622 ! include 'COMMON.VAR'
13623 ! include 'COMMON.LOCAL'
13624 ! include 'COMMON.CHAIN'
13625 ! include 'COMMON.DERIV'
13626 ! include 'COMMON.INTERACT'
13627 ! include 'COMMON.CONTACTS'
13628 ! include 'COMMON.TORSION'
13629 ! include 'COMMON.VECTORS'
13630 ! include 'COMMON.FFIELD'
13631 ! include 'COMMON.TIME1'
13632 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg
13633 real(kind=8),dimension(3,3) ::erder,uryg,urzg,vryg,vrzg
13634 real(kind=8),dimension(2,2) :: acipa !el,a_temp
13635 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
13636 real(kind=8),dimension(4) :: muij
13637 !el integer :: num_conti,j1,j2
13638 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
13639 !el dz_normi,xmedi,ymedi,zmedi
13640 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
13641 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
13642 !el num_conti,j1,j2
13643 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
13645 real(kind=8) :: scal_el=1.0d0
13647 real(kind=8) :: scal_el=0.5d0
13650 ! 13-go grudnia roku pamietnego...
13651 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
13652 0.0d0,1.0d0,0.0d0,&
13653 0.0d0,0.0d0,1.0d0/),shape(unmat))
13654 !el local variables
13656 real(kind=8) :: fac
13657 real(kind=8) :: dxj,dyj,dzj
13658 real(kind=8) :: ees,evdw1,eel_loc,eello_turn3,eello_turn4
13660 ! allocate(num_cont_hb(nres)) !(maxres)
13661 !d write(iout,*) 'In EELEC'
13663 !d write(iout,*) 'Type',i
13664 !d write(iout,*) 'B1',B1(:,i)
13665 !d write(iout,*) 'B2',B2(:,i)
13666 !d write(iout,*) 'CC',CC(:,:,i)
13667 !d write(iout,*) 'DD',DD(:,:,i)
13668 !d write(iout,*) 'EE',EE(:,:,i)
13670 !d call check_vecgrad
13672 if (icheckgrad.eq.1) then
13674 fac=1.0d0/dsqrt(scalar(dc(1,i),dc(1,i)))
13676 dc_norm(k,i)=dc(k,i)*fac
13678 ! write (iout,*) 'i',i,' fac',fac
13681 if (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
13682 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 .or. &
13683 wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) then
13684 ! call vec_and_deriv
13688 ! print *, "before set matrices"
13690 ! print *,"after set martices"
13692 time_mat=time_mat+MPI_Wtime()-time01
13696 !d write (iout,*) 'i=',i
13698 !d write (iout,'(i5,2f10.5)') k,uy(k,i),uz(k,i)
13701 !d write (iout,'(f10.5,2x,3f10.5,2x,3f10.5)')
13702 !d & uz(k,i),(uzgrad(k,l,1,i),l=1,3),(uzgrad(k,l,2,i),l=1,3)
13715 !d print '(a)','Enter EELEC'
13716 !d write (iout,*) 'iatel_s=',iatel_s,' iatel_e=',iatel_e
13717 ! if (.not.allocated(gel_loc_loc)) allocate(gel_loc_loc(nres)) !(maxvar)(maxvar=6*maxres)
13718 ! if (.not.allocated(gcorr_loc)) allocate(gcorr_loc(nres)) !(maxvar)(maxvar=6*maxres)
13720 gel_loc_loc(i)=0.0d0
13725 ! 9/27/08 AL Split the interaction loop to ensure load balancing of turn terms
13727 ! Loop over i,i+2 and i,i+3 pairs of the peptide groups
13729 do i=iturn3_start,iturn3_end
13730 if (itype(i,1).eq.ntyp1.or. itype(i+1,1).eq.ntyp1 &
13731 .or. itype(i+2,1).eq.ntyp1 .or. itype(i+3,1).eq.ntyp1) cycle
13735 dx_normi=dc_norm(1,i)
13736 dy_normi=dc_norm(2,i)
13737 dz_normi=dc_norm(3,i)
13738 xmedi=c(1,i)+0.5d0*dxi
13739 ymedi=c(2,i)+0.5d0*dyi
13740 zmedi=c(3,i)+0.5d0*dzi
13741 xmedi=dmod(xmedi,boxxsize)
13742 if (xmedi.lt.0) xmedi=xmedi+boxxsize
13743 ymedi=dmod(ymedi,boxysize)
13744 if (ymedi.lt.0) ymedi=ymedi+boxysize
13745 zmedi=dmod(zmedi,boxzsize)
13746 if (zmedi.lt.0) zmedi=zmedi+boxzsize
13748 call eelecij_scale(i,i+2,ees,evdw1,eel_loc)
13749 if (wturn3.gt.0.0d0) call eturn3(i,eello_turn3)
13750 num_cont_hb(i)=num_conti
13752 do i=iturn4_start,iturn4_end
13753 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1 &
13754 .or. itype(i+3,1).eq.ntyp1 &
13755 .or. itype(i+4,1).eq.ntyp1) cycle
13759 dx_normi=dc_norm(1,i)
13760 dy_normi=dc_norm(2,i)
13761 dz_normi=dc_norm(3,i)
13762 xmedi=c(1,i)+0.5d0*dxi
13763 ymedi=c(2,i)+0.5d0*dyi
13764 zmedi=c(3,i)+0.5d0*dzi
13765 xmedi=dmod(xmedi,boxxsize)
13766 if (xmedi.lt.0) xmedi=xmedi+boxxsize
13767 ymedi=dmod(ymedi,boxysize)
13768 if (ymedi.lt.0) ymedi=ymedi+boxysize
13769 zmedi=dmod(zmedi,boxzsize)
13770 if (zmedi.lt.0) zmedi=zmedi+boxzsize
13771 num_conti=num_cont_hb(i)
13772 call eelecij_scale(i,i+3,ees,evdw1,eel_loc)
13773 if (wturn4.gt.0.0d0 .and. itype(i+2,1).ne.ntyp1) &
13774 call eturn4(i,eello_turn4)
13775 num_cont_hb(i)=num_conti
13778 ! Loop over all pairs of interacting peptide groups except i,i+2 and i,i+3
13780 do i=iatel_s,iatel_e
13781 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
13785 dx_normi=dc_norm(1,i)
13786 dy_normi=dc_norm(2,i)
13787 dz_normi=dc_norm(3,i)
13788 xmedi=c(1,i)+0.5d0*dxi
13789 ymedi=c(2,i)+0.5d0*dyi
13790 zmedi=c(3,i)+0.5d0*dzi
13791 xmedi=dmod(xmedi,boxxsize)
13792 if (xmedi.lt.0) xmedi=xmedi+boxxsize
13793 ymedi=dmod(ymedi,boxysize)
13794 if (ymedi.lt.0) ymedi=ymedi+boxysize
13795 zmedi=dmod(zmedi,boxzsize)
13796 if (zmedi.lt.0) zmedi=zmedi+boxzsize
13797 ! write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
13798 num_conti=num_cont_hb(i)
13799 do j=ielstart(i),ielend(i)
13800 if (itype(j,1).eq.ntyp1 .or. itype(j+1,1).eq.ntyp1) cycle
13801 call eelecij_scale(i,j,ees,evdw1,eel_loc)
13803 num_cont_hb(i)=num_conti
13805 ! write (iout,*) "Number of loop steps in EELEC:",ind
13807 !d write (iout,'(i3,3f10.5,5x,3f10.5)')
13808 !d & i,(gel_loc(k,i),k=1,3),gel_loc_loc(i)
13810 ! 12/7/99 Adam eello_turn3 will be considered as a separate energy term
13811 !cc eel_loc=eel_loc+eello_turn3
13812 !d print *,"Processor",fg_rank," t_eelecij",t_eelecij
13814 end subroutine eelec_scale
13815 !-----------------------------------------------------------------------------
13816 subroutine eelecij_scale(i,j,ees,evdw1,eel_loc)
13817 ! implicit real*8 (a-h,o-z)
13820 ! include 'DIMENSIONS'
13824 ! include 'COMMON.CONTROL'
13825 ! include 'COMMON.IOUNITS'
13826 ! include 'COMMON.GEO'
13827 ! include 'COMMON.VAR'
13828 ! include 'COMMON.LOCAL'
13829 ! include 'COMMON.CHAIN'
13830 ! include 'COMMON.DERIV'
13831 ! include 'COMMON.INTERACT'
13832 ! include 'COMMON.CONTACTS'
13833 ! include 'COMMON.TORSION'
13834 ! include 'COMMON.VECTORS'
13835 ! include 'COMMON.FFIELD'
13836 ! include 'COMMON.TIME1'
13837 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg,xtemp
13838 real(kind=8),dimension(3,3) :: erder,uryg,urzg,vryg,vrzg
13839 real(kind=8),dimension(2,2) :: acipa !el,a_temp
13840 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
13841 real(kind=8),dimension(4) :: muij
13842 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
13843 dist_temp, dist_init,sss_grad
13844 integer xshift,yshift,zshift
13846 !el integer :: num_conti,j1,j2
13847 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
13848 !el dz_normi,xmedi,ymedi,zmedi
13849 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
13850 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
13851 !el num_conti,j1,j2
13852 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
13854 real(kind=8) :: scal_el=1.0d0
13856 real(kind=8) :: scal_el=0.5d0
13859 ! 13-go grudnia roku pamietnego...
13860 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
13861 0.0d0,1.0d0,0.0d0,&
13862 0.0d0,0.0d0,1.0d0/),shape(unmat))
13863 !el local variables
13864 integer :: i,j,k,l,iteli,itelj,kkk,kkll,m,isubchap
13865 real(kind=8) :: aaa,bbb,ael6i,ael3i,dxj,dyj,dzj
13866 real(kind=8) :: xj,yj,zj,rij,rrmij,rmij,sss,r3ij,r6ij,fac
13867 real(kind=8) :: cosa,cosb,cosg,ev1,ev2,fac3,fac4,evdwij
13868 real(kind=8) :: el1,el2,eesij,ees0ij,r0ij,fcont,fprimcont
13869 real(kind=8) :: ees0tmp,ees0pij1,ees0mij1,ees0pijp,ees0mijp
13870 real(kind=8) :: ees,evdw1,eel_loc,eel_loc_ij,dx_normj,dy_normj,&
13871 dz_normj,facvdw,facel,fac1,facr,ecosa,ecosb,ecosg,&
13872 ury,urz,vry,vrz,a22der,a23der,a32der,a33der,cosa4,&
13873 wij,cosbg1,cosbg2,ees0pij,ees0mij,fac3p,ecosa1,ecosb1,&
13874 ecosg1,ecosa2,ecosb2,ecosg2,ecosap,ecosbp,ecosgp,&
13875 ecosam,ecosbm,ecosgm,ghalf,time00
13876 ! integer :: maxconts
13877 ! maxconts = nres/4
13878 ! allocate(gacontp_hb1(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
13879 ! allocate(gacontp_hb2(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
13880 ! allocate(gacontp_hb3(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
13881 ! allocate(gacontm_hb1(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
13882 ! allocate(gacontm_hb2(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
13883 ! allocate(gacontm_hb3(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
13884 ! allocate(gacont_hbr(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
13885 ! allocate(grij_hb_cont(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
13886 ! allocate(facont_hb(maxconts,nres)) !(maxconts,maxres)
13887 ! allocate(ees0p(maxconts,nres)) !(maxconts,maxres)
13888 ! allocate(ees0m(maxconts,nres)) !(maxconts,maxres)
13889 ! allocate(d_cont(maxconts,nres)) !(maxconts,maxres)
13890 ! allocate(jcont_hb(maxconts,nres)) !(maxconts,maxres)
13892 ! allocate(a_chuj(2,2,maxconts,nres)) !(2,2,maxconts,maxres)
13893 ! allocate(a_chuj_der(2,2,3,5,maxconts,nres)) !(2,2,3,5,maxconts,maxres)
13898 !d write (iout,*) "eelecij",i,j
13902 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
13903 aaa=app(iteli,itelj)
13904 bbb=bpp(iteli,itelj)
13905 ael6i=ael6(iteli,itelj)
13906 ael3i=ael3(iteli,itelj)
13910 dx_normj=dc_norm(1,j)
13911 dy_normj=dc_norm(2,j)
13912 dz_normj=dc_norm(3,j)
13913 ! xj=c(1,j)+0.5D0*dxj-xmedi
13914 ! yj=c(2,j)+0.5D0*dyj-ymedi
13915 ! zj=c(3,j)+0.5D0*dzj-zmedi
13916 xj=c(1,j)+0.5D0*dxj
13917 yj=c(2,j)+0.5D0*dyj
13918 zj=c(3,j)+0.5D0*dzj
13919 xj=mod(xj,boxxsize)
13920 if (xj.lt.0) xj=xj+boxxsize
13921 yj=mod(yj,boxysize)
13922 if (yj.lt.0) yj=yj+boxysize
13923 zj=mod(zj,boxzsize)
13924 if (zj.lt.0) zj=zj+boxzsize
13926 dist_init=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
13933 xj=xj_safe+xshift*boxxsize
13934 yj=yj_safe+yshift*boxysize
13935 zj=zj_safe+zshift*boxzsize
13936 dist_temp=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
13937 if(dist_temp.lt.dist_init) then
13938 dist_init=dist_temp
13947 if (isubchap.eq.1) then
13958 rij=xj*xj+yj*yj+zj*zj
13962 ! For extracting the short-range part of Evdwpp
13963 sss=sscale(rij/rpp(iteli,itelj))
13964 sss_ele_cut=sscale_ele(rij)
13965 sss_ele_grad=sscagrad_ele(rij)
13966 sss_grad=sscale_grad((rij/rpp(iteli,itelj)))
13967 ! sss_ele_cut=1.0d0
13968 ! sss_ele_grad=0.0d0
13969 if (sss_ele_cut.le.0.0) go to 128
13973 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
13974 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
13975 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
13976 fac=cosa-3.0D0*cosb*cosg
13978 ! 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
13979 if (j.eq.i+2) ev1=scal_el*ev1
13984 el1=fac3*(4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg))
13987 ! 12/26/95 - for the evaluation of multi-body H-bonding interactions
13988 ees0ij=4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg)
13989 ees=ees+eesij*sss_ele_cut
13990 evdw1=evdw1+evdwij*(1.0d0-sss)*sss_ele_cut
13991 !d write(iout,'(2(2i3,2x),7(1pd12.4)/2(3(1pd12.4),5x)/)')
13992 !d & iteli,i,itelj,j,aaa,bbb,ael6i,ael3i,
13993 !d & 1.0D0/dsqrt(rrmij),evdwij,eesij,
13994 !d & xmedi,ymedi,zmedi,xj,yj,zj
13996 if (energy_dec) then
13997 write (iout,'(a6,2i5,0pf7.3,f7.3)') 'evdw1',i,j,evdwij,sss
13998 write (iout,'(a6,2i5,0pf7.3)') 'ees',i,j,eesij
14002 ! Calculate contributions to the Cartesian gradient.
14005 facvdw=-6*rrmij*(ev1+evdwij)*(1.0d0-sss)*sss_ele_cut
14006 facel=-3*rrmij*(el1+eesij)*sss_ele_cut
14012 ! Radial derivatives. First process both termini of the fragment (i,j)
14014 ggg(1)=facel*xj+sss_ele_grad*rmij*eesij*xj
14015 ggg(2)=facel*yj+sss_ele_grad*rmij*eesij*yj
14016 ggg(3)=facel*zj+sss_ele_grad*rmij*eesij*zj
14018 ! ghalf=0.5D0*ggg(k)
14019 ! gelc(k,i)=gelc(k,i)+ghalf
14020 ! gelc(k,j)=gelc(k,j)+ghalf
14022 ! 9/28/08 AL Gradient compotents will be summed only at the end
14024 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
14025 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
14028 ! Loop over residues i+1 thru j-1.
14032 !grad gelc(l,k)=gelc(l,k)+ggg(l)
14035 ggg(1)=facvdw*xj+sss_ele_grad*rmij*evdwij*xj*(1.0d0-sss) &
14036 -evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*xj
14037 ggg(2)=facvdw*yj+sss_ele_grad*rmij*evdwij*yj*(1.0d0-sss) &
14038 -evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*yj
14039 ggg(3)=facvdw*zj+sss_ele_grad*rmij*evdwij*zj*(1.0d0-sss) &
14040 -evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*zj
14042 ! ghalf=0.5D0*ggg(k)
14043 ! gvdwpp(k,i)=gvdwpp(k,i)+ghalf
14044 ! gvdwpp(k,j)=gvdwpp(k,j)+ghalf
14046 ! 9/28/08 AL Gradient compotents will be summed only at the end
14048 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
14049 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
14052 ! Loop over residues i+1 thru j-1.
14056 !grad gvdwpp(l,k)=gvdwpp(l,k)+ggg(l)
14060 facvdw=(ev1+evdwij)*(1.0d0-sss)*sss_ele_cut
14061 facel=(el1+eesij)*sss_ele_cut
14063 fac=-3*rrmij*(facvdw+facvdw+facel)
14068 ! Radial derivatives. First process both termini of the fragment (i,j)
14074 ! ghalf=0.5D0*ggg(k)
14075 ! gelc(k,i)=gelc(k,i)+ghalf
14076 ! gelc(k,j)=gelc(k,j)+ghalf
14078 ! 9/28/08 AL Gradient compotents will be summed only at the end
14080 gelc_long(k,j)=gelc(k,j)+ggg(k)
14081 gelc_long(k,i)=gelc(k,i)-ggg(k)
14084 ! Loop over residues i+1 thru j-1.
14088 !grad gelc(l,k)=gelc(l,k)+ggg(l)
14091 ! 9/28/08 AL Gradient compotents will be summed only at the end
14096 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
14097 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
14103 ecosa=2.0D0*fac3*fac1+fac4
14106 ecosb=(fac3*(fac1*cosg+cosb)+cosg*fac4)
14107 ecosg=(fac3*(fac1*cosb+cosg)+cosb*fac4)
14109 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
14110 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
14112 !d print '(2i3,2(3(1pd14.5),3x))',i,j,(dcosb(k),k=1,3),
14113 !d & (dcosg(k),k=1,3)
14115 ggg(k)=(ecosb*dcosb(k)+ecosg*dcosg(k) )*sss_ele_cut
14118 ! ghalf=0.5D0*ggg(k)
14119 ! gelc(k,i)=gelc(k,i)+ghalf
14120 ! & +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
14121 ! & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
14122 ! gelc(k,j)=gelc(k,j)+ghalf
14123 ! & +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
14124 ! & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
14128 !grad gelc(l,k)=gelc(l,k)+ggg(l)
14132 gelc(k,i)=gelc(k,i) &
14133 +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
14134 + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)&
14136 gelc(k,j)=gelc(k,j) &
14137 +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
14138 + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
14140 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
14141 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
14143 IF (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
14144 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 &
14145 .or. wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
14147 ! 9/25/99 Mixed third-order local-electrostatic terms. The local-interaction
14148 ! energy of a peptide unit is assumed in the form of a second-order
14149 ! Fourier series in the angles lambda1 and lambda2 (see Nishikawa et al.
14150 ! Macromolecules, 1974, 7, 797-806 for definition). This correlation terms
14151 ! are computed for EVERY pair of non-contiguous peptide groups.
14153 if (j.lt.nres-1) then
14164 muij(kkk)=mu(k,i)*mu(l,j)
14167 !d write (iout,*) 'EELEC: i',i,' j',j
14168 !d write (iout,*) 'j',j,' j1',j1,' j2',j2
14169 !d write(iout,*) 'muij',muij
14170 ury=scalar(uy(1,i),erij)
14171 urz=scalar(uz(1,i),erij)
14172 vry=scalar(uy(1,j),erij)
14173 vrz=scalar(uz(1,j),erij)
14174 a22=scalar(uy(1,i),uy(1,j))-3*ury*vry
14175 a23=scalar(uy(1,i),uz(1,j))-3*ury*vrz
14176 a32=scalar(uz(1,i),uy(1,j))-3*urz*vry
14177 a33=scalar(uz(1,i),uz(1,j))-3*urz*vrz
14178 fac=dsqrt(-ael6i)*r3ij
14183 !d write (iout,'(4i5,4f10.5)')
14184 !d & i,itortyp(itype(i,1)),j,itortyp(itype(j,1)),a22,a23,a32,a33
14185 !d write (iout,'(6f10.5)') (muij(k),k=1,4),fac,eel_loc_ij
14186 !d write (iout,'(2(3f10.5,5x)/2(3f10.5,5x))') uy(:,i),uz(:,i),
14187 !d & uy(:,j),uz(:,j)
14188 !d write (iout,'(4f10.5)')
14189 !d & scalar(uy(1,i),uy(1,j)),scalar(uy(1,i),uz(1,j)),
14190 !d & scalar(uz(1,i),uy(1,j)),scalar(uz(1,i),uz(1,j))
14191 !d write (iout,'(4f10.5)') ury,urz,vry,vrz
14192 !d write (iout,'(9f10.5/)')
14193 !d & fac22,a22,fac23,a23,fac32,a32,fac33,a33,eel_loc_ij
14194 ! Derivatives of the elements of A in virtual-bond vectors
14195 call unormderiv(erij(1),unmat(1,1),rmij,erder(1,1))
14197 uryg(k,1)=scalar(erder(1,k),uy(1,i))
14198 uryg(k,2)=scalar(uygrad(1,k,1,i),erij(1))
14199 uryg(k,3)=scalar(uygrad(1,k,2,i),erij(1))
14200 urzg(k,1)=scalar(erder(1,k),uz(1,i))
14201 urzg(k,2)=scalar(uzgrad(1,k,1,i),erij(1))
14202 urzg(k,3)=scalar(uzgrad(1,k,2,i),erij(1))
14203 vryg(k,1)=scalar(erder(1,k),uy(1,j))
14204 vryg(k,2)=scalar(uygrad(1,k,1,j),erij(1))
14205 vryg(k,3)=scalar(uygrad(1,k,2,j),erij(1))
14206 vrzg(k,1)=scalar(erder(1,k),uz(1,j))
14207 vrzg(k,2)=scalar(uzgrad(1,k,1,j),erij(1))
14208 vrzg(k,3)=scalar(uzgrad(1,k,2,j),erij(1))
14210 ! Compute radial contributions to the gradient
14228 ! Add the contributions coming from er
14231 agg(k,1)=agg(k,1)+fac3*(uryg(k,1)*vry+vryg(k,1)*ury)
14232 agg(k,2)=agg(k,2)+fac3*(uryg(k,1)*vrz+vrzg(k,1)*ury)
14233 agg(k,3)=agg(k,3)+fac3*(urzg(k,1)*vry+vryg(k,1)*urz)
14234 agg(k,4)=agg(k,4)+fac3*(urzg(k,1)*vrz+vrzg(k,1)*urz)
14237 ! Derivatives in DC(i)
14238 !grad ghalf1=0.5d0*agg(k,1)
14239 !grad ghalf2=0.5d0*agg(k,2)
14240 !grad ghalf3=0.5d0*agg(k,3)
14241 !grad ghalf4=0.5d0*agg(k,4)
14242 aggi(k,1)=fac*(scalar(uygrad(1,k,1,i),uy(1,j)) &
14243 -3.0d0*uryg(k,2)*vry)!+ghalf1
14244 aggi(k,2)=fac*(scalar(uygrad(1,k,1,i),uz(1,j)) &
14245 -3.0d0*uryg(k,2)*vrz)!+ghalf2
14246 aggi(k,3)=fac*(scalar(uzgrad(1,k,1,i),uy(1,j)) &
14247 -3.0d0*urzg(k,2)*vry)!+ghalf3
14248 aggi(k,4)=fac*(scalar(uzgrad(1,k,1,i),uz(1,j)) &
14249 -3.0d0*urzg(k,2)*vrz)!+ghalf4
14250 ! Derivatives in DC(i+1)
14251 aggi1(k,1)=fac*(scalar(uygrad(1,k,2,i),uy(1,j)) &
14252 -3.0d0*uryg(k,3)*vry)!+agg(k,1)
14253 aggi1(k,2)=fac*(scalar(uygrad(1,k,2,i),uz(1,j)) &
14254 -3.0d0*uryg(k,3)*vrz)!+agg(k,2)
14255 aggi1(k,3)=fac*(scalar(uzgrad(1,k,2,i),uy(1,j)) &
14256 -3.0d0*urzg(k,3)*vry)!+agg(k,3)
14257 aggi1(k,4)=fac*(scalar(uzgrad(1,k,2,i),uz(1,j)) &
14258 -3.0d0*urzg(k,3)*vrz)!+agg(k,4)
14259 ! Derivatives in DC(j)
14260 aggj(k,1)=fac*(scalar(uygrad(1,k,1,j),uy(1,i)) &
14261 -3.0d0*vryg(k,2)*ury)!+ghalf1
14262 aggj(k,2)=fac*(scalar(uzgrad(1,k,1,j),uy(1,i)) &
14263 -3.0d0*vrzg(k,2)*ury)!+ghalf2
14264 aggj(k,3)=fac*(scalar(uygrad(1,k,1,j),uz(1,i)) &
14265 -3.0d0*vryg(k,2)*urz)!+ghalf3
14266 aggj(k,4)=fac*(scalar(uzgrad(1,k,1,j),uz(1,i)) &
14267 -3.0d0*vrzg(k,2)*urz)!+ghalf4
14268 ! Derivatives in DC(j+1) or DC(nres-1)
14269 aggj1(k,1)=fac*(scalar(uygrad(1,k,2,j),uy(1,i)) &
14270 -3.0d0*vryg(k,3)*ury)
14271 aggj1(k,2)=fac*(scalar(uzgrad(1,k,2,j),uy(1,i)) &
14272 -3.0d0*vrzg(k,3)*ury)
14273 aggj1(k,3)=fac*(scalar(uygrad(1,k,2,j),uz(1,i)) &
14274 -3.0d0*vryg(k,3)*urz)
14275 aggj1(k,4)=fac*(scalar(uzgrad(1,k,2,j),uz(1,i)) &
14276 -3.0d0*vrzg(k,3)*urz)
14277 !grad if (j.eq.nres-1 .and. i.lt.j-2) then
14279 !grad aggj1(k,l)=aggj1(k,l)+agg(k,l)
14292 aggi(k,l)=-aggi(k,l)
14293 aggi1(k,l)=-aggi1(k,l)
14294 aggj(k,l)=-aggj(k,l)
14295 aggj1(k,l)=-aggj1(k,l)
14298 if (j.lt.nres-1) then
14304 aggi(k,l)=-aggi(k,l)
14305 aggi1(k,l)=-aggi1(k,l)
14306 aggj(k,l)=-aggj(k,l)
14307 aggj1(k,l)=-aggj1(k,l)
14318 aggi(k,l)=-aggi(k,l)
14319 aggi1(k,l)=-aggi1(k,l)
14320 aggj(k,l)=-aggj(k,l)
14321 aggj1(k,l)=-aggj1(k,l)
14326 IF (wel_loc.gt.0.0d0) THEN
14327 ! Contribution to the local-electrostatic energy coming from the i-j pair
14328 eel_loc_ij=a22*muij(1)+a23*muij(2)+a32*muij(3) &
14330 ! write (iout,*) 'i',i,' j',j,' eel_loc_ij',eel_loc_ij
14332 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
14333 'eelloc',i,j,eel_loc_ij
14334 ! write (iout,*) a22,muij(1),a23,muij(2),a32,muij(3) !d
14336 eel_loc=eel_loc+eel_loc_ij*sss_ele_cut
14337 ! Partial derivatives in virtual-bond dihedral angles gamma
14339 gel_loc_loc(i-1)=gel_loc_loc(i-1)+ &
14340 (a22*muder(1,i)*mu(1,j)+a23*muder(1,i)*mu(2,j) &
14341 +a32*muder(2,i)*mu(1,j)+a33*muder(2,i)*mu(2,j)) &
14343 gel_loc_loc(j-1)=gel_loc_loc(j-1)+ &
14344 (a22*mu(1,i)*muder(1,j)+a23*mu(1,i)*muder(2,j) &
14345 +a32*mu(2,i)*muder(1,j)+a33*mu(2,i)*muder(2,j)) &
14351 ! Derivatives of eello in DC(i+1) thru DC(j-1) or DC(nres-2)
14353 ggg(l)=(agg(l,1)*muij(1)+ &
14354 agg(l,2)*muij(2)+agg(l,3)*muij(3)+agg(l,4)*muij(4))&
14356 +eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
14358 gel_loc_long(l,j)=gel_loc_long(l,j)+ggg(l)
14359 gel_loc_long(l,i)=gel_loc_long(l,i)-ggg(l)
14360 !grad ghalf=0.5d0*ggg(l)
14361 !grad gel_loc(l,i)=gel_loc(l,i)+ghalf
14362 !grad gel_loc(l,j)=gel_loc(l,j)+ghalf
14366 !grad gel_loc(l,k)=gel_loc(l,k)+ggg(l)
14369 ! Remaining derivatives of eello
14371 gel_loc(l,i)=gel_loc(l,i)+(aggi(l,1)*muij(1)+ &
14372 aggi(l,2)*muij(2)+aggi(l,3)*muij(3)+aggi(l,4)*muij(4))&
14375 gel_loc(l,i+1)=gel_loc(l,i+1)+(aggi1(l,1)*muij(1)+ &
14376 aggi1(l,2)*muij(2)+aggi1(l,3)*muij(3)+aggi1(l,4)*muij(4))&
14379 gel_loc(l,j)=gel_loc(l,j)+(aggj(l,1)*muij(1)+ &
14380 aggj(l,2)*muij(2)+aggj(l,3)*muij(3)+aggj(l,4)*muij(4))&
14383 gel_loc(l,j1)=gel_loc(l,j1)+(aggj1(l,1)*muij(1)+ &
14384 aggj1(l,2)*muij(2)+aggj1(l,3)*muij(3)+aggj1(l,4)*muij(4))&
14389 ! Change 12/26/95 to calculate four-body contributions to H-bonding energy
14390 ! if (j.gt.i+1 .and. num_conti.le.maxconts) then
14391 if (wcorr+wcorr4+wcorr5+wcorr6.gt.0.0d0 &
14392 .and. num_conti.le.maxconts) then
14393 ! write (iout,*) i,j," entered corr"
14395 ! Calculate the contact function. The ith column of the array JCONT will
14396 ! contain the numbers of atoms that make contacts with the atom I (of numbers
14397 ! greater than I). The arrays FACONT and GACONT will contain the values of
14398 ! the contact function and its derivative.
14399 ! r0ij=1.02D0*rpp(iteli,itelj)
14400 ! r0ij=1.11D0*rpp(iteli,itelj)
14401 r0ij=2.20D0*rpp(iteli,itelj)
14402 ! r0ij=1.55D0*rpp(iteli,itelj)
14403 call gcont(rij,r0ij,1.0D0,0.2d0*r0ij,fcont,fprimcont)
14404 !elwrite(iout,*) "num_conti",num_conti, "maxconts",maxconts
14405 if (fcont.gt.0.0D0) then
14406 num_conti=num_conti+1
14407 if (num_conti.gt.maxconts) then
14408 !elwrite(iout,*) "num_conti",num_conti, "maxconts",maxconts
14409 write (iout,*) 'WARNING - max. # of contacts exceeded;',&
14410 ' will skip next contacts for this conf.',num_conti
14412 jcont_hb(num_conti,i)=j
14413 !d write (iout,*) "i",i," j",j," num_conti",num_conti,
14414 !d & " jcont_hb",jcont_hb(num_conti,i)
14415 IF (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. &
14416 wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
14417 ! 9/30/99 (AL) - store components necessary to evaluate higher-order loc-el
14419 d_cont(num_conti,i)=rij
14420 !d write (2,'(3e15.5)') rij,r0ij+0.2d0*r0ij,rij
14421 ! --- Electrostatic-interaction matrix ---
14422 a_chuj(1,1,num_conti,i)=a22
14423 a_chuj(1,2,num_conti,i)=a23
14424 a_chuj(2,1,num_conti,i)=a32
14425 a_chuj(2,2,num_conti,i)=a33
14426 ! --- Gradient of rij
14428 grij_hb_cont(kkk,num_conti,i)=erij(kkk)
14435 a_chuj_der(k,l,m,1,num_conti,i)=agg(m,kkll)
14436 a_chuj_der(k,l,m,2,num_conti,i)=aggi(m,kkll)
14437 a_chuj_der(k,l,m,3,num_conti,i)=aggi1(m,kkll)
14438 a_chuj_der(k,l,m,4,num_conti,i)=aggj(m,kkll)
14439 a_chuj_der(k,l,m,5,num_conti,i)=aggj1(m,kkll)
14444 IF (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) THEN
14445 ! Calculate contact energies
14447 wij=cosa-3.0D0*cosb*cosg
14450 ! fac3=dsqrt(-ael6i)/r0ij**3
14451 fac3=dsqrt(-ael6i)*r3ij
14452 ! ees0pij=dsqrt(4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1)
14453 ees0tmp=4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1
14454 if (ees0tmp.gt.0) then
14455 ees0pij=dsqrt(ees0tmp)
14459 ! ees0mij=dsqrt(4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2)
14460 ees0tmp=4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2
14461 if (ees0tmp.gt.0) then
14462 ees0mij=dsqrt(ees0tmp)
14467 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij) &
14470 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij) &
14473 ! Diagnostics. Comment out or remove after debugging!
14474 ! ees0p(num_conti,i)=0.5D0*fac3*ees0pij
14475 ! ees0m(num_conti,i)=0.5D0*fac3*ees0mij
14476 ! ees0m(num_conti,i)=0.0D0
14478 ! write (iout,*) 'i=',i,' j=',j,' rij=',rij,' r0ij=',r0ij,
14479 ! & ' ees0ij=',ees0p(num_conti,i),ees0m(num_conti,i),' fcont=',fcont
14480 ! Angular derivatives of the contact function
14481 ees0pij1=fac3/ees0pij
14482 ees0mij1=fac3/ees0mij
14483 fac3p=-3.0D0*fac3*rrmij
14484 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
14485 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
14487 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
14488 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
14489 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
14490 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
14491 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
14492 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
14493 ecosap=ecosa1+ecosa2
14494 ecosbp=ecosb1+ecosb2
14495 ecosgp=ecosg1+ecosg2
14496 ecosam=ecosa1-ecosa2
14497 ecosbm=ecosb1-ecosb2
14498 ecosgm=ecosg1-ecosg2
14507 facont_hb(num_conti,i)=fcont
14508 fprimcont=fprimcont/rij
14509 !d facont_hb(num_conti,i)=1.0D0
14510 ! Following line is for diagnostics.
14513 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
14514 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
14517 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
14518 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
14520 ! gggp(1)=gggp(1)+ees0pijp*xj
14521 ! gggp(2)=gggp(2)+ees0pijp*yj
14522 ! gggp(3)=gggp(3)+ees0pijp*zj
14523 ! gggm(1)=gggm(1)+ees0mijp*xj
14524 ! gggm(2)=gggm(2)+ees0mijp*yj
14525 ! gggm(3)=gggm(3)+ees0mijp*zj
14526 gggp(1)=gggp(1)+ees0pijp*xj &
14527 +ees0p(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
14528 gggp(2)=gggp(2)+ees0pijp*yj &
14529 +ees0p(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
14530 gggp(3)=gggp(3)+ees0pijp*zj &
14531 +ees0p(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
14533 gggm(1)=gggm(1)+ees0mijp*xj &
14534 +ees0m(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
14536 gggm(2)=gggm(2)+ees0mijp*yj &
14537 +ees0m(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
14539 gggm(3)=gggm(3)+ees0mijp*zj &
14540 +ees0m(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
14542 ! Derivatives due to the contact function
14543 gacont_hbr(1,num_conti,i)=fprimcont*xj
14544 gacont_hbr(2,num_conti,i)=fprimcont*yj
14545 gacont_hbr(3,num_conti,i)=fprimcont*zj
14548 ! 10/24/08 cgrad and ! comments indicate the parts of the code removed
14549 ! following the change of gradient-summation algorithm.
14551 !grad ghalfp=0.5D0*gggp(k)
14552 !grad ghalfm=0.5D0*gggm(k)
14553 ! gacontp_hb1(k,num_conti,i)= & !ghalfp
14554 ! +(ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
14555 ! + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
14556 ! gacontp_hb2(k,num_conti,i)= & !ghalfp
14557 ! +(ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
14558 ! + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
14559 ! gacontp_hb3(k,num_conti,i)=gggp(k)
14560 ! gacontm_hb1(k,num_conti,i)= &!ghalfm
14561 ! +(ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
14562 ! + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
14563 ! gacontm_hb2(k,num_conti,i)= & !ghalfm
14564 ! +(ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
14565 ! + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
14566 ! gacontm_hb3(k,num_conti,i)=gggm(k)
14567 gacontp_hb1(k,num_conti,i)= & !ghalfp+
14568 (ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
14569 + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
14572 gacontp_hb2(k,num_conti,i)= & !ghalfp+
14573 (ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
14574 + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
14577 gacontp_hb3(k,num_conti,i)=gggp(k) &
14580 gacontm_hb1(k,num_conti,i)= & !ghalfm+
14581 (ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
14582 + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
14585 gacontm_hb2(k,num_conti,i)= & !ghalfm+
14586 (ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
14587 + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1) &
14590 gacontm_hb3(k,num_conti,i)=gggm(k) &
14595 endif ! num_conti.le.maxconts
14598 if (wturn3.gt.0.0d0 .or. wturn4.gt.0.0d0) then
14601 ghalf=0.5d0*agg(l,k)
14602 aggi(l,k)=aggi(l,k)+ghalf
14603 aggi1(l,k)=aggi1(l,k)+agg(l,k)
14604 aggj(l,k)=aggj(l,k)+ghalf
14607 if (j.eq.nres-1 .and. i.lt.j-2) then
14610 aggj1(l,k)=aggj1(l,k)+agg(l,k)
14616 ! t_eelecij=t_eelecij+MPI_Wtime()-time00
14618 end subroutine eelecij_scale
14619 !-----------------------------------------------------------------------------
14620 subroutine evdwpp_short(evdw1)
14624 ! implicit real*8 (a-h,o-z)
14625 ! include 'DIMENSIONS'
14626 ! include 'COMMON.CONTROL'
14627 ! include 'COMMON.IOUNITS'
14628 ! include 'COMMON.GEO'
14629 ! include 'COMMON.VAR'
14630 ! include 'COMMON.LOCAL'
14631 ! include 'COMMON.CHAIN'
14632 ! include 'COMMON.DERIV'
14633 ! include 'COMMON.INTERACT'
14634 ! include 'COMMON.CONTACTS'
14635 ! include 'COMMON.TORSION'
14636 ! include 'COMMON.VECTORS'
14637 ! include 'COMMON.FFIELD'
14638 real(kind=8),dimension(3) :: ggg
14639 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
14641 real(kind=8) :: scal_el=1.0d0
14643 real(kind=8) :: scal_el=0.5d0
14645 !el local variables
14646 integer :: i,j,k,iteli,itelj,num_conti,isubchap
14647 real(kind=8) :: dxi,dyi,dzi,dxj,dyj,dzj,aaa,bbb
14648 real(kind=8) :: xj,yj,zj,rij,rrmij,sss,r3ij,r6ij,evdw1,&
14649 dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
14650 dx_normj,dy_normj,dz_normj,rmij,ev1,ev2,evdwij,facvdw
14651 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
14652 dist_temp, dist_init,sss_grad
14653 integer xshift,yshift,zshift
14657 ! write (iout,*) "iatel_s_vdw",iatel_s_vdw,
14658 ! & " iatel_e_vdw",iatel_e_vdw
14660 do i=iatel_s_vdw,iatel_e_vdw
14661 if (itype(i,1).eq.ntyp1.or. itype(i+1,1).eq.ntyp1) cycle
14665 dx_normi=dc_norm(1,i)
14666 dy_normi=dc_norm(2,i)
14667 dz_normi=dc_norm(3,i)
14668 xmedi=c(1,i)+0.5d0*dxi
14669 ymedi=c(2,i)+0.5d0*dyi
14670 zmedi=c(3,i)+0.5d0*dzi
14671 xmedi=dmod(xmedi,boxxsize)
14672 if (xmedi.lt.0) xmedi=xmedi+boxxsize
14673 ymedi=dmod(ymedi,boxysize)
14674 if (ymedi.lt.0) ymedi=ymedi+boxysize
14675 zmedi=dmod(zmedi,boxzsize)
14676 if (zmedi.lt.0) zmedi=zmedi+boxzsize
14678 ! write (iout,*) 'i',i,' ielstart',ielstart_vdw(i),
14679 ! & ' ielend',ielend_vdw(i)
14681 do j=ielstart_vdw(i),ielend_vdw(i)
14682 if (itype(j,1).eq.ntyp1 .or. itype(j+1,1).eq.ntyp1) cycle
14686 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
14687 aaa=app(iteli,itelj)
14688 bbb=bpp(iteli,itelj)
14692 dx_normj=dc_norm(1,j)
14693 dy_normj=dc_norm(2,j)
14694 dz_normj=dc_norm(3,j)
14695 ! xj=c(1,j)+0.5D0*dxj-xmedi
14696 ! yj=c(2,j)+0.5D0*dyj-ymedi
14697 ! zj=c(3,j)+0.5D0*dzj-zmedi
14698 xj=c(1,j)+0.5D0*dxj
14699 yj=c(2,j)+0.5D0*dyj
14700 zj=c(3,j)+0.5D0*dzj
14701 xj=mod(xj,boxxsize)
14702 if (xj.lt.0) xj=xj+boxxsize
14703 yj=mod(yj,boxysize)
14704 if (yj.lt.0) yj=yj+boxysize
14705 zj=mod(zj,boxzsize)
14706 if (zj.lt.0) zj=zj+boxzsize
14708 dist_init=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
14715 xj=xj_safe+xshift*boxxsize
14716 yj=yj_safe+yshift*boxysize
14717 zj=zj_safe+zshift*boxzsize
14718 dist_temp=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
14719 if(dist_temp.lt.dist_init) then
14720 dist_init=dist_temp
14729 if (isubchap.eq.1) then
14740 rij=xj*xj+yj*yj+zj*zj
14743 sss=sscale(rij/rpp(iteli,itelj))
14744 sss_ele_cut=sscale_ele(rij)
14745 sss_ele_grad=sscagrad_ele(rij)
14746 sss_grad=sscale_grad((rij/rpp(iteli,itelj)))
14747 if (sss_ele_cut.le.0.0) cycle
14748 if (sss.gt.0.0d0) then
14753 ! 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
14754 if (j.eq.i+2) ev1=scal_el*ev1
14757 if (energy_dec) then
14758 write (iout,'(a6,2i5,0pf7.3,f7.3)') 'evdw1',i,j,evdwij,sss
14760 evdw1=evdw1+evdwij*sss*sss_ele_cut
14762 ! Calculate contributions to the Cartesian gradient.
14764 facvdw=-6*rrmij*(ev1+evdwij)*sss*sss_ele_cut
14768 ggg(1)=facvdw*xj+sss_ele_grad*rmij*evdwij*xj*sss &
14769 +evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*xj
14770 ggg(2)=facvdw*yj+sss_ele_grad*rmij*evdwij*yj*sss &
14771 +evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*yj
14772 ggg(3)=facvdw*zj+sss_ele_grad*rmij*evdwij*zj*sss &
14773 +evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*zj
14776 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
14777 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
14783 end subroutine evdwpp_short
14784 !-----------------------------------------------------------------------------
14785 subroutine escp_long(evdw2,evdw2_14)
14787 ! This subroutine calculates the excluded-volume interaction energy between
14788 ! peptide-group centers and side chains and its gradient in virtual-bond and
14789 ! side-chain vectors.
14791 ! implicit real*8 (a-h,o-z)
14792 ! include 'DIMENSIONS'
14793 ! include 'COMMON.GEO'
14794 ! include 'COMMON.VAR'
14795 ! include 'COMMON.LOCAL'
14796 ! include 'COMMON.CHAIN'
14797 ! include 'COMMON.DERIV'
14798 ! include 'COMMON.INTERACT'
14799 ! include 'COMMON.FFIELD'
14800 ! include 'COMMON.IOUNITS'
14801 ! include 'COMMON.CONTROL'
14802 real(kind=8),dimension(3) :: ggg
14803 !el local variables
14804 integer :: i,iint,j,k,iteli,itypj,subchap
14805 real(kind=8) :: xi,yi,zi,xj,yj,zj,rrij,sss,fac,e1,e2,sss_grad,rij
14806 real(kind=8) :: evdw2,evdw2_14,evdwij
14807 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
14808 dist_temp, dist_init
14812 !d print '(a)','Enter ESCP'
14813 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
14814 do i=iatscp_s,iatscp_e
14815 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
14817 xi=0.5D0*(c(1,i)+c(1,i+1))
14818 yi=0.5D0*(c(2,i)+c(2,i+1))
14819 zi=0.5D0*(c(3,i)+c(3,i+1))
14820 xi=mod(xi,boxxsize)
14821 if (xi.lt.0) xi=xi+boxxsize
14822 yi=mod(yi,boxysize)
14823 if (yi.lt.0) yi=yi+boxysize
14824 zi=mod(zi,boxzsize)
14825 if (zi.lt.0) zi=zi+boxzsize
14827 do iint=1,nscp_gr(i)
14829 do j=iscpstart(i,iint),iscpend(i,iint)
14831 if (itypj.eq.ntyp1) cycle
14832 ! Uncomment following three lines for SC-p interactions
14833 ! xj=c(1,nres+j)-xi
14834 ! yj=c(2,nres+j)-yi
14835 ! zj=c(3,nres+j)-zi
14836 ! Uncomment following three lines for Ca-p interactions
14840 xj=mod(xj,boxxsize)
14841 if (xj.lt.0) xj=xj+boxxsize
14842 yj=mod(yj,boxysize)
14843 if (yj.lt.0) yj=yj+boxysize
14844 zj=mod(zj,boxzsize)
14845 if (zj.lt.0) zj=zj+boxzsize
14846 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
14854 xj=xj_safe+xshift*boxxsize
14855 yj=yj_safe+yshift*boxysize
14856 zj=zj_safe+zshift*boxzsize
14857 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
14858 if(dist_temp.lt.dist_init) then
14859 dist_init=dist_temp
14868 if (subchap.eq.1) then
14877 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
14879 rij=dsqrt(1.0d0/rrij)
14880 sss_ele_cut=sscale_ele(rij)
14881 sss_ele_grad=sscagrad_ele(rij)
14882 ! print *,sss_ele_cut,sss_ele_grad,&
14883 ! (rij),r_cut_ele,rlamb_ele
14884 if (sss_ele_cut.le.0.0) cycle
14885 sss=sscale((rij/rscp(itypj,iteli)))
14886 sss_grad=sscale_grad(rij/rscp(itypj,iteli))
14887 if (sss.lt.1.0d0) then
14890 e1=fac*fac*aad(itypj,iteli)
14891 e2=fac*bad(itypj,iteli)
14892 if (iabs(j-i) .le. 2) then
14895 evdw2_14=evdw2_14+(e1+e2)*(1.0d0-sss)*sss_ele_cut
14898 evdw2=evdw2+evdwij*(1.0d0-sss)*sss_ele_cut
14899 if (energy_dec) write (iout,'(a6,2i5,2(0pf7.3))') &
14900 'evdw2',i,j,sss,evdwij
14902 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
14904 fac=-(evdwij+e1)*rrij*(1.0d0-sss)*sss_ele_cut
14905 fac=fac+evdwij*sss_ele_grad/rij/expon*(1.0d0-sss)&
14906 -evdwij*sss_ele_cut/rij/expon*sss_grad/rscp(itypj,iteli)
14910 ! Uncomment following three lines for SC-p interactions
14912 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
14914 ! Uncomment following line for SC-p interactions
14915 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
14917 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
14918 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
14927 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
14928 gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
14929 gradx_scp(j,i)=expon*gradx_scp(j,i)
14932 !******************************************************************************
14936 ! To save time the factor EXPON has been extracted from ALL components
14937 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
14940 !******************************************************************************
14942 end subroutine escp_long
14943 !-----------------------------------------------------------------------------
14944 subroutine escp_short(evdw2,evdw2_14)
14946 ! This subroutine calculates the excluded-volume interaction energy between
14947 ! peptide-group centers and side chains and its gradient in virtual-bond and
14948 ! side-chain vectors.
14950 ! implicit real*8 (a-h,o-z)
14951 ! include 'DIMENSIONS'
14952 ! include 'COMMON.GEO'
14953 ! include 'COMMON.VAR'
14954 ! include 'COMMON.LOCAL'
14955 ! include 'COMMON.CHAIN'
14956 ! include 'COMMON.DERIV'
14957 ! include 'COMMON.INTERACT'
14958 ! include 'COMMON.FFIELD'
14959 ! include 'COMMON.IOUNITS'
14960 ! include 'COMMON.CONTROL'
14961 real(kind=8),dimension(3) :: ggg
14962 !el local variables
14963 integer :: i,iint,j,k,iteli,itypj,subchap
14964 real(kind=8) :: xi,yi,zi,xj,yj,zj,rrij,sss,fac,e1,e2,sss_grad,rij
14965 real(kind=8) :: evdw2,evdw2_14,evdwij
14966 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
14967 dist_temp, dist_init
14971 !d print '(a)','Enter ESCP'
14972 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
14973 do i=iatscp_s,iatscp_e
14974 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
14976 xi=0.5D0*(c(1,i)+c(1,i+1))
14977 yi=0.5D0*(c(2,i)+c(2,i+1))
14978 zi=0.5D0*(c(3,i)+c(3,i+1))
14979 xi=mod(xi,boxxsize)
14980 if (xi.lt.0) xi=xi+boxxsize
14981 yi=mod(yi,boxysize)
14982 if (yi.lt.0) yi=yi+boxysize
14983 zi=mod(zi,boxzsize)
14984 if (zi.lt.0) zi=zi+boxzsize
14986 do iint=1,nscp_gr(i)
14988 do j=iscpstart(i,iint),iscpend(i,iint)
14990 if (itypj.eq.ntyp1) cycle
14991 ! Uncomment following three lines for SC-p interactions
14992 ! xj=c(1,nres+j)-xi
14993 ! yj=c(2,nres+j)-yi
14994 ! zj=c(3,nres+j)-zi
14995 ! Uncomment following three lines for Ca-p interactions
15002 xj=mod(xj,boxxsize)
15003 if (xj.lt.0) xj=xj+boxxsize
15004 yj=mod(yj,boxysize)
15005 if (yj.lt.0) yj=yj+boxysize
15006 zj=mod(zj,boxzsize)
15007 if (zj.lt.0) zj=zj+boxzsize
15008 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
15016 xj=xj_safe+xshift*boxxsize
15017 yj=yj_safe+yshift*boxysize
15018 zj=zj_safe+zshift*boxzsize
15019 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
15020 if(dist_temp.lt.dist_init) then
15021 dist_init=dist_temp
15030 if (subchap.eq.1) then
15040 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
15041 rij=dsqrt(1.0d0/rrij)
15042 sss_ele_cut=sscale_ele(rij)
15043 sss_ele_grad=sscagrad_ele(rij)
15044 ! print *,sss_ele_cut,sss_ele_grad,&
15045 ! (rij),r_cut_ele,rlamb_ele
15046 if (sss_ele_cut.le.0.0) cycle
15047 sss=sscale(rij/rscp(itypj,iteli))
15048 sss_grad=sscale_grad(rij/rscp(itypj,iteli))
15049 if (sss.gt.0.0d0) then
15052 e1=fac*fac*aad(itypj,iteli)
15053 e2=fac*bad(itypj,iteli)
15054 if (iabs(j-i) .le. 2) then
15057 evdw2_14=evdw2_14+(e1+e2)*sss*sss_ele_cut
15060 evdw2=evdw2+evdwij*sss*sss_ele_cut
15061 if (energy_dec) write (iout,'(a6,2i5,2(0pf7.3))') &
15062 'evdw2',i,j,sss,evdwij
15064 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
15066 fac=-(evdwij+e1)*rrij*sss*sss_ele_cut
15067 fac=fac+evdwij*sss_ele_grad/rij/expon*sss &
15068 +evdwij*sss_ele_cut/rij/expon*sss_grad/rscp(itypj,iteli)
15073 ! Uncomment following three lines for SC-p interactions
15075 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
15077 ! Uncomment following line for SC-p interactions
15078 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
15080 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
15081 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
15090 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
15091 gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
15092 gradx_scp(j,i)=expon*gradx_scp(j,i)
15095 !******************************************************************************
15099 ! To save time the factor EXPON has been extracted from ALL components
15100 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
15103 !******************************************************************************
15105 end subroutine escp_short
15106 !-----------------------------------------------------------------------------
15107 ! energy_p_new-sep_barrier.F
15108 !-----------------------------------------------------------------------------
15109 subroutine sc_grad_scale(scalfac)
15110 ! implicit real*8 (a-h,o-z)
15112 ! include 'DIMENSIONS'
15113 ! include 'COMMON.CHAIN'
15114 ! include 'COMMON.DERIV'
15115 ! include 'COMMON.CALC'
15116 ! include 'COMMON.IOUNITS'
15117 real(kind=8),dimension(3) :: dcosom1,dcosom2
15118 real(kind=8) :: scalfac
15119 !el local variables
15120 ! integer :: i,j,k,l
15122 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
15123 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
15124 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12 &
15125 -2.0D0*alf12*eps3der+sigder*sigsq_om12
15129 ! eom12=evdwij*eps1_om12
15131 ! write (iout,*) "eps2der",eps2der," eps3der",eps3der,
15132 ! & " sigder",sigder
15133 ! write (iout,*) "eps1_om12",eps1_om12," eps2rt_om12",eps2rt_om12
15134 ! write (iout,*) "eom1",eom1," eom2",eom2," eom12",eom12
15136 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
15137 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
15140 gg(k)=(gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k))*scalfac&
15143 ! write (iout,*) "gg",(gg(k),k=1,3)
15145 gvdwx(k,i)=gvdwx(k,i)-gg(k) &
15146 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
15147 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv*scalfac&
15149 gvdwx(k,j)=gvdwx(k,j)+gg(k) &
15150 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
15151 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv*scalfac&
15153 ! write (iout,*)(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))
15154 ! & +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
15155 ! write (iout,*)(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))
15156 ! & +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
15159 ! Calculate the components of the gradient in DC and X
15162 gvdwc(l,i)=gvdwc(l,i)-gg(l)
15163 gvdwc(l,j)=gvdwc(l,j)+gg(l)
15166 end subroutine sc_grad_scale
15167 !-----------------------------------------------------------------------------
15168 ! energy_split-sep.F
15169 !-----------------------------------------------------------------------------
15170 subroutine etotal_long(energia)
15172 ! Compute the long-range slow-varying contributions to the energy
15174 ! implicit real*8 (a-h,o-z)
15175 ! include 'DIMENSIONS'
15176 use MD_data, only: totT,usampl,eq_time
15180 !MS$ATTRIBUTES C :: proc_proc
15185 real(kind=8),dimension(n_ene) :: weights_!,time_Bcast,time_Bcastw
15187 ! include 'COMMON.SETUP'
15188 ! include 'COMMON.IOUNITS'
15189 ! include 'COMMON.FFIELD'
15190 ! include 'COMMON.DERIV'
15191 ! include 'COMMON.INTERACT'
15192 ! include 'COMMON.SBRIDGE'
15193 ! include 'COMMON.CHAIN'
15194 ! include 'COMMON.VAR'
15195 ! include 'COMMON.LOCAL'
15196 ! include 'COMMON.MD'
15197 real(kind=8),dimension(0:n_ene) :: energia
15198 !el local variables
15199 integer :: i,n_corr,n_corr1,ierror,ierr
15200 real(kind=8) :: evdw2,evdw2_14,ehpb,etors,edihcnstr,etors_d,esccor,&
15201 evdw,ees,evdw1,eel_loc,eello_turn3,eello_turn4,&
15202 ecorr,ecorr5,ecorr6,eturn6,time00
15203 ! write(iout,'(a,i2)')'Calling etotal_long ipot=',ipot
15204 !elwrite(iout,*)"in etotal long"
15206 if (modecalc.eq.12.or.modecalc.eq.14) then
15208 ! if (fg_rank.eq.0) call int_from_cart1(.false.)
15210 call int_from_cart1(.false.)
15213 !elwrite(iout,*)"in etotal long"
15216 ! write(iout,*) "ETOTAL_LONG Processor",fg_rank,
15217 ! & " absolute rank",myrank," nfgtasks",nfgtasks
15219 if (nfgtasks.gt.1) then
15221 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
15222 if (fg_rank.eq.0) then
15223 call MPI_Bcast(3,1,MPI_INTEGER,king,FG_COMM,IERROR)
15224 ! write (iout,*) "Processor",myrank," BROADCAST iorder"
15226 ! FG master sets up the WEIGHTS_ array which will be broadcast to the
15227 ! FG slaves as WEIGHTS array.
15234 weights_(7)=wel_loc
15237 weights_(10)=wturn6
15239 weights_(12)=wscloc
15241 weights_(14)=wtor_d
15242 weights_(15)=wstrain
15243 weights_(16)=wvdwpp
15245 weights_(18)=scal14
15246 weights_(21)=wsccor
15247 ! FG Master broadcasts the WEIGHTS_ array
15248 call MPI_Bcast(weights_(1),n_ene,&
15249 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
15251 ! FG slaves receive the WEIGHTS array
15252 call MPI_Bcast(weights(1),n_ene,&
15253 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
15268 wstrain=weights(15)
15274 call MPI_Bcast(dc(1,1),6*nres,MPI_DOUBLE_PRECISION,&
15276 time_Bcast=time_Bcast+MPI_Wtime()-time00
15277 time_Bcastw=time_Bcastw+MPI_Wtime()-time00
15278 ! call chainbuild_cart
15279 ! call int_from_cart1(.false.)
15281 ! write (iout,*) 'Processor',myrank,
15282 ! & ' calling etotal_short ipot=',ipot
15284 ! print *,'Processor',myrank,' nnt=',nnt,' nct=',nct
15286 !d print *,'nnt=',nnt,' nct=',nct
15288 !elwrite(iout,*)"in etotal long"
15289 ! Compute the side-chain and electrostatic interaction energy
15291 goto (101,102,103,104,105,106) ipot
15292 ! Lennard-Jones potential.
15293 101 call elj_long(evdw)
15294 !d print '(a)','Exit ELJ'
15296 ! Lennard-Jones-Kihara potential (shifted).
15297 102 call eljk_long(evdw)
15299 ! Berne-Pechukas potential (dilated LJ, angular dependence).
15300 103 call ebp_long(evdw)
15302 ! Gay-Berne potential (shifted LJ, angular dependence).
15303 104 call egb_long(evdw)
15305 ! Gay-Berne-Vorobjev potential (shifted LJ, angular dependence).
15306 105 call egbv_long(evdw)
15308 ! Soft-sphere potential
15309 106 call e_softsphere(evdw)
15311 ! Calculate electrostatic (H-bonding) energy of the main chain.
15315 if (ipot.lt.6) then
15317 if (welec.gt.0d0.or.wvdwpp.gt.0d0.or.wel_loc.gt.0d0.or. &
15318 wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0 &
15319 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
15320 .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
15322 if (welec.gt.0d0.or.wel_loc.gt.0d0.or. &
15323 wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0 &
15324 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
15325 .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
15327 call eelec_scale(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
15336 ! write (iout,*) "Soft-spheer ELEC potential"
15337 call eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,&
15341 ! Calculate excluded-volume interaction energy between peptide groups
15344 if (ipot.lt.6) then
15345 if(wscp.gt.0d0) then
15346 call escp_long(evdw2,evdw2_14)
15352 call escp_soft_sphere(evdw2,evdw2_14)
15355 ! 12/1/95 Multi-body terms
15359 if ((wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 &
15360 .or. wturn6.gt.0.0d0) .and. ipot.lt.6) then
15361 call multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
15362 ! write (2,*) 'n_corr=',n_corr,' n_corr1=',n_corr1,
15363 ! &" ecorr",ecorr," ecorr5",ecorr5," ecorr6",ecorr6," eturn6",eturn6
15370 if ((wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) .and. ipot.lt.6) then
15371 call multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
15374 ! If performing constraint dynamics, call the constraint energy
15375 ! after the equilibration time
15376 if(usampl.and.totT.gt.eq_time) then
15391 energia(2)=evdw2-evdw2_14
15392 energia(18)=evdw2_14
15401 energia(3)=ees+evdw1
15408 energia(8)=eello_turn3
15409 energia(9)=eello_turn4
15411 energia(20)=Uconst+Uconst_back
15412 call sum_energy(energia,.true.)
15413 ! write (iout,*) "Exit ETOTAL_LONG"
15416 end subroutine etotal_long
15417 !-----------------------------------------------------------------------------
15418 subroutine etotal_short(energia)
15420 ! Compute the short-range fast-varying contributions to the energy
15422 ! implicit real*8 (a-h,o-z)
15423 ! include 'DIMENSIONS'
15427 !MS$ATTRIBUTES C :: proc_proc
15432 integer :: ierror,ierr
15433 real(kind=8),dimension(n_ene) :: weights_
15434 real(kind=8) :: time00
15436 ! include 'COMMON.SETUP'
15437 ! include 'COMMON.IOUNITS'
15438 ! include 'COMMON.FFIELD'
15439 ! include 'COMMON.DERIV'
15440 ! include 'COMMON.INTERACT'
15441 ! include 'COMMON.SBRIDGE'
15442 ! include 'COMMON.CHAIN'
15443 ! include 'COMMON.VAR'
15444 ! include 'COMMON.LOCAL'
15445 real(kind=8),dimension(0:n_ene) :: energia
15446 !el local variables
15448 real(kind=8) :: evdw,evdw1,evdw2,evdw2_14,esccor,etors_d,etors
15449 real(kind=8) :: ehpb,escloc,estr,ebe,edihcnstr,ethetacnstr
15452 ! write(iout,'(a,i2)')'Calling etotal_short ipot=',ipot
15454 if (modecalc.eq.12.or.modecalc.eq.14) then
15456 if (fg_rank.eq.0) call int_from_cart1(.false.)
15458 call int_from_cart1(.false.)
15462 ! write(iout,*) "ETOTAL_SHORT Processor",fg_rank,
15463 ! & " absolute rank",myrank," nfgtasks",nfgtasks
15465 if (nfgtasks.gt.1) then
15467 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
15468 if (fg_rank.eq.0) then
15469 call MPI_Bcast(2,1,MPI_INTEGER,king,FG_COMM,IERROR)
15470 ! write (iout,*) "Processor",myrank," BROADCAST iorder"
15472 ! FG master sets up the WEIGHTS_ array which will be broadcast to the
15473 ! FG slaves as WEIGHTS array.
15480 weights_(7)=wel_loc
15483 weights_(10)=wturn6
15485 weights_(12)=wscloc
15487 weights_(14)=wtor_d
15488 weights_(15)=wstrain
15489 weights_(16)=wvdwpp
15491 weights_(18)=scal14
15492 weights_(21)=wsccor
15493 ! FG Master broadcasts the WEIGHTS_ array
15494 call MPI_Bcast(weights_(1),n_ene,&
15495 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
15497 ! FG slaves receive the WEIGHTS array
15498 call MPI_Bcast(weights(1),n_ene,&
15499 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
15514 wstrain=weights(15)
15520 ! write (iout,*),"Processor",myrank," BROADCAST weights"
15521 call MPI_Bcast(c(1,1),nres6,MPI_DOUBLE_PRECISION,&
15523 ! write (iout,*) "Processor",myrank," BROADCAST c"
15524 call MPI_Bcast(dc(1,1),nres6,MPI_DOUBLE_PRECISION,&
15526 ! write (iout,*) "Processor",myrank," BROADCAST dc"
15527 call MPI_Bcast(dc_norm(1,1),nres6,MPI_DOUBLE_PRECISION,&
15529 ! write (iout,*) "Processor",myrank," BROADCAST dc_norm"
15530 call MPI_Bcast(theta(1),nres,MPI_DOUBLE_PRECISION,&
15532 ! write (iout,*) "Processor",myrank," BROADCAST theta"
15533 call MPI_Bcast(phi(1),nres,MPI_DOUBLE_PRECISION,&
15535 ! write (iout,*) "Processor",myrank," BROADCAST phi"
15536 call MPI_Bcast(alph(1),nres,MPI_DOUBLE_PRECISION,&
15538 ! write (iout,*) "Processor",myrank," BROADCAST alph"
15539 call MPI_Bcast(omeg(1),nres,MPI_DOUBLE_PRECISION,&
15541 ! write (iout,*) "Processor",myrank," BROADCAST omeg"
15542 call MPI_Bcast(vbld(1),2*nres,MPI_DOUBLE_PRECISION,&
15544 ! write (iout,*) "Processor",myrank," BROADCAST vbld"
15545 call MPI_Bcast(vbld_inv(1),2*nres,MPI_DOUBLE_PRECISION,&
15547 time_Bcast=time_Bcast+MPI_Wtime()-time00
15548 ! write (iout,*) "Processor",myrank," BROADCAST vbld_inv"
15550 ! write (iout,*) 'Processor',myrank,
15551 ! & ' calling etotal_short ipot=',ipot
15553 ! print *,'Processor',myrank,' nnt=',nnt,' nct=',nct
15555 ! call int_from_cart1(.false.)
15557 ! Compute the side-chain and electrostatic interaction energy
15559 goto (101,102,103,104,105,106) ipot
15560 ! Lennard-Jones potential.
15561 101 call elj_short(evdw)
15562 !d print '(a)','Exit ELJ'
15564 ! Lennard-Jones-Kihara potential (shifted).
15565 102 call eljk_short(evdw)
15567 ! Berne-Pechukas potential (dilated LJ, angular dependence).
15568 103 call ebp_short(evdw)
15570 ! Gay-Berne potential (shifted LJ, angular dependence).
15571 104 call egb_short(evdw)
15573 ! Gay-Berne-Vorobjev potential (shifted LJ, angular dependence).
15574 105 call egbv_short(evdw)
15576 ! Soft-sphere potential - already dealt with in the long-range part
15578 ! 106 call e_softsphere_short(evdw)
15580 ! Calculate electrostatic (H-bonding) energy of the main chain.
15584 ! Calculate the short-range part of Evdwpp
15586 call evdwpp_short(evdw1)
15588 ! Calculate the short-range part of ESCp
15590 if (ipot.lt.6) then
15591 call escp_short(evdw2,evdw2_14)
15594 ! Calculate the bond-stretching energy
15598 ! Calculate the disulfide-bridge and other energy and the contributions
15599 ! from other distance constraints.
15602 ! Calculate the virtual-bond-angle energy.
15604 call ebend(ebe,ethetacnstr)
15606 ! Calculate the SC local energy.
15611 ! Calculate the virtual-bond torsional energy.
15613 call etor(etors,edihcnstr)
15615 ! 6/23/01 Calculate double-torsional energy
15617 call etor_d(etors_d)
15619 ! 21/5/07 Calculate local sicdechain correlation energy
15621 if (wsccor.gt.0.0d0) then
15622 call eback_sc_corr(esccor)
15627 ! Put energy components into an array
15634 energia(2)=evdw2-evdw2_14
15635 energia(18)=evdw2_14
15648 energia(14)=etors_d
15651 energia(19)=edihcnstr
15653 ! write (iout,*) "ETOTAL_SHORT before SUM_ENERGY"
15655 call sum_energy(energia,.true.)
15656 ! write (iout,*) "Exit ETOTAL_SHORT"
15659 end subroutine etotal_short
15660 !-----------------------------------------------------------------------------
15662 !-----------------------------------------------------------------------------
15663 real(kind=8) function gnmr1(y,ymin,ymax)
15665 real(kind=8) :: y,ymin,ymax
15666 real(kind=8) :: wykl=4.0d0
15667 if (y.lt.ymin) then
15668 gnmr1=(ymin-y)**wykl/wykl
15669 else if (y.gt.ymax) then
15670 gnmr1=(y-ymax)**wykl/wykl
15676 !-----------------------------------------------------------------------------
15677 real(kind=8) function gnmr1prim(y,ymin,ymax)
15679 real(kind=8) :: y,ymin,ymax
15680 real(kind=8) :: wykl=4.0d0
15681 if (y.lt.ymin) then
15682 gnmr1prim=-(ymin-y)**(wykl-1)
15683 else if (y.gt.ymax) then
15684 gnmr1prim=(y-ymax)**(wykl-1)
15689 end function gnmr1prim
15690 !----------------------------------------------------------------------------
15691 real(kind=8) function rlornmr1(y,ymin,ymax,sigma)
15692 real(kind=8) y,ymin,ymax,sigma
15693 real(kind=8) wykl /4.0d0/
15694 if (y.lt.ymin) then
15695 rlornmr1=(ymin-y)**wykl/((ymin-y)**wykl+sigma**wykl)
15696 else if (y.gt.ymax) then
15697 rlornmr1=(y-ymax)**wykl/((y-ymax)**wykl+sigma**wykl)
15702 end function rlornmr1
15703 !------------------------------------------------------------------------------
15704 real(kind=8) function rlornmr1prim(y,ymin,ymax,sigma)
15705 real(kind=8) y,ymin,ymax,sigma
15706 real(kind=8) wykl /4.0d0/
15707 if (y.lt.ymin) then
15708 rlornmr1prim=-(ymin-y)**(wykl-1)*sigma**wykl*wykl/ &
15709 ((ymin-y)**wykl+sigma**wykl)**2
15710 else if (y.gt.ymax) then
15711 rlornmr1prim=(y-ymax)**(wykl-1)*sigma**wykl*wykl/ &
15712 ((y-ymax)**wykl+sigma**wykl)**2
15717 end function rlornmr1prim
15719 real(kind=8) function harmonic(y,ymax)
15721 real(kind=8) :: y,ymax
15722 real(kind=8) :: wykl=2.0d0
15723 harmonic=(y-ymax)**wykl
15725 end function harmonic
15726 !-----------------------------------------------------------------------------
15727 real(kind=8) function harmonicprim(y,ymax)
15728 real(kind=8) :: y,ymin,ymax
15729 real(kind=8) :: wykl=2.0d0
15730 harmonicprim=(y-ymax)*wykl
15732 end function harmonicprim
15733 !-----------------------------------------------------------------------------
15735 !-----------------------------------------------------------------------------
15736 subroutine gradient(n,x,nf,g,uiparm,urparm,ufparm)
15738 use io_base, only:intout,briefout
15739 ! implicit real*8 (a-h,o-z)
15740 ! include 'DIMENSIONS'
15741 ! include 'COMMON.CHAIN'
15742 ! include 'COMMON.DERIV'
15743 ! include 'COMMON.VAR'
15744 ! include 'COMMON.INTERACT'
15745 ! include 'COMMON.FFIELD'
15746 ! include 'COMMON.MD'
15747 ! include 'COMMON.IOUNITS'
15748 real(kind=8),external :: ufparm
15749 integer :: uiparm(1)
15750 real(kind=8) :: urparm(1)
15751 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
15752 real(kind=8) :: f,gthetai,gphii,galphai,gomegai
15753 integer :: n,nf,ind,ind1,i,k,j
15755 ! This subroutine calculates total internal coordinate gradient.
15756 ! Depending on the number of function evaluations, either whole energy
15757 ! is evaluated beforehand, Cartesian coordinates and their derivatives in
15758 ! internal coordinates are reevaluated or only the cartesian-in-internal
15759 ! coordinate derivatives are evaluated. The subroutine was designed to work
15765 !d print *,'grad',nf,icg
15766 if (nf-nfl+1) 20,30,40
15767 20 call func(n,x,nf,f,uiparm,urparm,ufparm)
15768 ! write (iout,*) 'grad 20'
15769 if (nf.eq.0) return
15771 30 call var_to_geom(n,x)
15773 ! write (iout,*) 'grad 30'
15775 ! Evaluate the derivatives of virtual bond lengths and SC vectors in variables.
15778 ! write (iout,*) 'grad 40'
15779 ! print *,'GRADIENT: nnt=',nnt,' nct=',nct,' expon=',expon
15781 ! Convert the Cartesian gradient into internal-coordinate gradient.
15791 ! print *,'GRAD: i=',i,' jc=',j,' ind=',ind
15793 gthetai=gthetai+dcdv(k,ind)*gradc(k,j,icg)
15796 gphii=gphii+dcdv(k+3,ind)*gradc(k,j,icg)
15802 ! print *,'GRAD: i=',i,' jx=',j,' ind1=',ind1
15804 gthetai=gthetai+dxdv(k,ind1)*gradx(k,j,icg)
15805 gphii=gphii+dxdv(k+3,ind1)*gradx(k,j,icg)
15808 if (i.gt.1) g(i-1)=gphii
15809 if (n.gt.nphi) g(nphi+i)=gthetai
15811 if (n.le.nphi+ntheta) goto 10
15813 if (itype(i,1).ne.10) then
15817 galphai=galphai+dxds(k,i)*gradx(k,i,icg)
15820 gomegai=gomegai+dxds(k+3,i)*gradx(k,i,icg)
15822 g(ialph(i,1))=galphai
15823 g(ialph(i,1)+nside)=gomegai
15827 ! Add the components corresponding to local energy terms.
15831 !d write (iout,*) 'i=',i,'g=',g(i),' gloc=',gloc(i,icg)
15832 g(i)=g(i)+gloc(i,icg)
15834 ! Uncomment following three lines for diagnostics.
15836 !elwrite(iout,*) "in gradient after calling intout"
15837 !d call briefout(0,0.0d0)
15838 !d write (iout,'(i3,1pe15.5)') (k,g(k),k=1,n)
15840 end subroutine gradient
15841 !-----------------------------------------------------------------------------
15842 subroutine func(n,x,nf,f,uiparm,urparm,ufparm) !from minimize_p.F
15845 ! implicit real*8 (a-h,o-z)
15846 ! include 'DIMENSIONS'
15847 ! include 'COMMON.DERIV'
15848 ! include 'COMMON.IOUNITS'
15849 ! include 'COMMON.GEO'
15852 !el common /chuju/ jjj
15853 real(kind=8) :: energia(0:n_ene)
15854 integer :: uiparm(1)
15855 real(kind=8) :: urparm(1)
15857 real(kind=8),external :: ufparm
15858 real(kind=8),dimension(6*nres) :: x !(maxvar) (maxvar=6*maxres)
15859 ! if (jjj.gt.0) then
15860 ! write (iout,'(10f8.3)') (rad2deg*x(i),i=1,n)
15864 !d print *,'func',nf,nfl,icg
15865 call var_to_geom(n,x)
15868 !d write (iout,*) 'ETOTAL called from FUNC'
15869 call etotal(energia)
15872 ! if (jjj.gt.0) then
15873 ! write (iout,'(10f8.3)') (rad2deg*x(i),i=1,n)
15874 ! write (iout,*) 'f=',etot
15878 end subroutine func
15879 !-----------------------------------------------------------------------------
15880 subroutine cartgrad
15881 ! implicit real*8 (a-h,o-z)
15882 ! include 'DIMENSIONS'
15884 use MD_data, only: totT,usampl,eq_time
15888 ! include 'COMMON.CHAIN'
15889 ! include 'COMMON.DERIV'
15890 ! include 'COMMON.VAR'
15891 ! include 'COMMON.INTERACT'
15892 ! include 'COMMON.FFIELD'
15893 ! include 'COMMON.MD'
15894 ! include 'COMMON.IOUNITS'
15895 ! include 'COMMON.TIME1'
15899 ! This subrouting calculates total Cartesian coordinate gradient.
15900 ! The subroutine chainbuild_cart and energy MUST be called beforehand.
15910 !el write (iout,*) "After sum_gradient"
15912 !el write (iout,*) "After sum_gradient"
15914 write (iout,*) i," gradc ",(gradc(j,i,icg),j=1,3)
15915 write (iout,*) i," gradx ",(gradx(j,i,icg),j=1,3)
15918 ! If performing constraint dynamics, add the gradients of the constraint energy
15919 if(usampl.and.totT.gt.eq_time) then
15922 gradc(j,i,icg)=gradc(j,i,icg)+dudconst(j,i)+duscdiff(j,i)
15923 gradx(j,i,icg)=gradx(j,i,icg)+dudxconst(j,i)+duscdiffx(j,i)
15927 gloc(i,icg)=gloc(i,icg)+dugamma(i)
15930 gloc(nphi+i,icg)=gloc(nphi+i,icg)+dutheta(i)
15933 !elwrite (iout,*) "After sum_gradient"
15938 !elwrite (iout,*) "After sum_gradient"
15940 time_intcartderiv=time_intcartderiv+MPI_Wtime()-time01
15942 ! call checkintcartgrad
15943 ! write(iout,*) 'calling int_to_cart'
15945 write (iout,*) "gcart, gxcart, gloc before int_to_cart"
15949 gcart(j,i)=gradc(j,i,icg)
15950 gxcart(j,i)=gradx(j,i,icg)
15953 write (iout,'(i5,2(3f10.5,5x),f10.5)') i,(gcart(j,i),j=1,3),&
15954 (gxcart(j,i),j=1,3),gloc(i,icg)
15962 time_inttocart=time_inttocart+MPI_Wtime()-time01
15965 write (iout,*) "gcart and gxcart after int_to_cart"
15967 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
15968 (gxcart(j,i),j=1,3)
15973 write (iout,*) "CARGRAD"
15977 gcart(j,i)=-gcart(j,i)+gcart(j,i-1)-gxcart(j,i)
15978 ! gcart_new(j,i)=-gcart(j,i)+gcart(j,i-1)-gxcart(j,i)
15980 ! write (iout,'(i5,3f10.5,5x,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3), &
15981 ! (gcart_new(j,i),j=1,3),(gxcart(j,i),j=1,3)
15983 ! Correction: dummy residues
15986 ! gcart_new(j,nnt)=gcart_new(j,nnt)+gcart_new(j,1)
15987 gcart(j,nnt)=gcart(j,nnt)+gcart(j,1)
15990 if (nct.lt.nres) then
15992 ! gcart_new(j,nct)=gcart_new(j,nct)+gcart_new(j,nres)
15993 gcart(j,nct)=gcart(j,nct)+gcart(j,nres)
15998 time_cartgrad=time_cartgrad+MPI_Wtime()-time00
16002 end subroutine cartgrad
16003 !-----------------------------------------------------------------------------
16004 subroutine zerograd
16005 ! implicit real*8 (a-h,o-z)
16006 ! include 'DIMENSIONS'
16007 ! include 'COMMON.DERIV'
16008 ! include 'COMMON.CHAIN'
16009 ! include 'COMMON.VAR'
16010 ! include 'COMMON.MD'
16011 ! include 'COMMON.SCCOR'
16013 !el local variables
16014 integer :: i,j,intertyp,k
16015 ! Initialize Cartesian-coordinate gradient
16017 ! if (.not.allocated(gradx)) allocate(gradx(3,nres,2)) !(3,maxres,2)
16018 ! if (.not.allocated(gradc)) allocate(gradc(3,nres,2)) !(3,maxres,2)
16020 ! allocate(gvdwx(3,nres),gvdwc(3,nres),gelc(3,nres),gelc_long(3,nres))
16021 ! allocate(gvdwpp(3,nres),gvdwc_scpp(3,nres),gradx_scp(3,nres))
16022 ! allocate(gvdwc_scp(3,nres),ghpbx(3,nres),ghpbc(3,nres))
16023 ! allocate(gradcorr_long(3,nres))
16024 ! allocate(gradcorr5_long(3,nres),gradcorr6_long(3,nres))
16025 ! allocate(gcorr6_turn_long(3,nres))
16026 ! allocate(gradcorr5(3,nres),gradcorr6(3,nres)) !(3,maxres)
16028 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres)) !(3,maxres)
16030 ! allocate(gel_loc(3,nres),gel_loc_long(3,nres),gcorr3_turn(3,nres))
16031 ! allocate(gcorr4_turn(3,nres),gcorr6_turn(3,nres))
16033 ! if (.not.allocated(gradb)) allocate(gradb(3,nres)) !(3,maxres)
16034 ! if (.not.allocated(gradbx)) allocate(gradbx(3,nres)) !(3,maxres)
16036 ! allocate(gsccorc(3,nres),gsccorx(3,nres)) !(3,maxres)
16037 ! allocate(gscloc(3,nres)) !(3,maxres)
16038 ! if (.not.allocated(gsclocx)) allocate(gsclocx(3,nres)) !(3,maxres)
16042 ! common /deriv_scloc/
16043 ! allocate(dXX_C1tab(3,nres),dYY_C1tab(3,nres),dZZ_C1tab(3,nres))
16044 ! allocate(dXX_Ctab(3,nres),dYY_Ctab(3,nres),dZZ_Ctab(3,nres))
16045 ! allocate(dXX_XYZtab(3,nres),dYY_XYZtab(3,nres),dZZ_XYZtab(3,nres)) !(3,maxres)
16047 ! allocate(jgrad_start(nres),jgrad_end(nres)) !(maxres)
16051 ! gradc(j,i,icg)=0.0d0
16052 ! gradx(j,i,icg)=0.0d0
16054 ! allocate(gloc_sc(3,nres,10)) !(3,0:maxres2,10)maxres2=2*maxres
16055 !elwrite(iout,*) "icg",icg
16059 gradx_scp(j,i)=0.0D0
16061 gvdwc_scp(j,i)=0.0D0
16062 gvdwc_scpp(j,i)=0.0d0
16064 gelc_long(j,i)=0.0D0
16069 gel_loc_long(j,i)=0.0d0
16072 gcorr3_turn(j,i)=0.0d0
16073 gcorr4_turn(j,i)=0.0d0
16074 gradcorr(j,i)=0.0d0
16075 gradcorr_long(j,i)=0.0d0
16076 gradcorr5_long(j,i)=0.0d0
16077 gradcorr6_long(j,i)=0.0d0
16078 gcorr6_turn_long(j,i)=0.0d0
16079 gradcorr5(j,i)=0.0d0
16080 gradcorr6(j,i)=0.0d0
16081 gcorr6_turn(j,i)=0.0d0
16084 gradc(j,i,icg)=0.0d0
16085 gradx(j,i,icg)=0.0d0
16088 gliptran(j,i)=0.0d0
16089 gliptranx(j,i)=0.0d0
16090 gliptranc(j,i)=0.0d0
16091 gshieldx(j,i)=0.0d0
16092 gshieldc(j,i)=0.0d0
16093 gshieldc_loc(j,i)=0.0d0
16094 gshieldx_ec(j,i)=0.0d0
16095 gshieldc_ec(j,i)=0.0d0
16096 gshieldc_loc_ec(j,i)=0.0d0
16097 gshieldx_t3(j,i)=0.0d0
16098 gshieldc_t3(j,i)=0.0d0
16099 gshieldc_loc_t3(j,i)=0.0d0
16100 gshieldx_t4(j,i)=0.0d0
16101 gshieldc_t4(j,i)=0.0d0
16102 gshieldc_loc_t4(j,i)=0.0d0
16103 gshieldx_ll(j,i)=0.0d0
16104 gshieldc_ll(j,i)=0.0d0
16105 gshieldc_loc_ll(j,i)=0.0d0
16107 gg_tube_sc(j,i)=0.0d0
16110 gloc_sc(intertyp,i,icg)=0.0d0
16119 grad_shield_side(k,j,i)=0.0d0
16120 grad_shield_loc(k,j,i)=0.0d0
16127 ! Initialize the gradient of local energy terms.
16129 ! allocate(gloc(4*nres,2)) !!(maxvar,2)(maxvar=6*maxres)
16130 ! if (.not.allocated(gel_loc_loc)) allocate(gel_loc_loc(nres)) !(maxvar)(maxvar=6*maxres)
16131 ! if (.not.allocated(gcorr_loc)) allocate(gcorr_loc(nres)) !(maxvar)(maxvar=6*maxres)
16132 ! allocate(g_corr5_loc(nres),g_corr6_loc(nres)) !(maxvar)(maxvar=6*maxres)
16133 ! allocate(gel_loc_turn3(nres))
16134 ! allocate(gel_loc_turn4(nres),gel_loc_turn6(nres)) !(maxvar)(maxvar=6*maxres)
16135 ! allocate(gsccor_loc(nres)) !(maxres)
16141 gel_loc_loc(i)=0.0d0
16143 g_corr5_loc(i)=0.0d0
16144 g_corr6_loc(i)=0.0d0
16145 gel_loc_turn3(i)=0.0d0
16146 gel_loc_turn4(i)=0.0d0
16147 gel_loc_turn6(i)=0.0d0
16148 gsccor_loc(i)=0.0d0
16150 ! initialize gcart and gxcart
16151 ! allocate(gcart(3,0:nres),gxcart(3,0:nres)) !(3,0:MAXRES)
16159 end subroutine zerograd
16160 !-----------------------------------------------------------------------------
16161 real(kind=8) function fdum()
16165 !-----------------------------------------------------------------------------
16167 !-----------------------------------------------------------------------------
16168 subroutine intcartderiv
16169 ! implicit real*8 (a-h,o-z)
16170 ! include 'DIMENSIONS'
16174 ! include 'COMMON.SETUP'
16175 ! include 'COMMON.CHAIN'
16176 ! include 'COMMON.VAR'
16177 ! include 'COMMON.GEO'
16178 ! include 'COMMON.INTERACT'
16179 ! include 'COMMON.DERIV'
16180 ! include 'COMMON.IOUNITS'
16181 ! include 'COMMON.LOCAL'
16182 ! include 'COMMON.SCCOR'
16183 real(kind=8) :: pi4,pi34
16184 real(kind=8),dimension(3,2,nres) :: dcostheta ! (3,2,maxres)
16185 real(kind=8),dimension(3,3,nres) :: dcosphi,dsinphi,dcosalpha,&
16186 dcosomega,dsinomega !(3,3,maxres)
16187 real(kind=8),dimension(3) :: vo1,vo2,vo3,dummy,vp1,vp2,vp3,vpp1,n
16190 real(kind=8) :: cost,sint,cost1,sint1,cost2,sint2,sing,cosg,scalp,&
16191 fac0,fac1,fac2,fac3,fac4,fac5,fac6,ctgt,ctgt1,cosg_inv,&
16192 fac7,fac8,fac9,scala1,scala2,cosa,sina,sino,fac15,fac16,&
16193 fac17,coso_inv,fac10,fac11,fac12,fac13,fac14
16197 !el from module energy-------------
16198 !el allocate(dcostau(3,3,3,itau_start:itau_end)) !(3,3,3,maxres2)maxres2=2*maxres
16199 !el allocate(dsintau(3,3,3,itau_start:itau_end))
16200 !el allocate(dtauangle(3,3,3,itau_start:itau_end))
16202 !el allocate(dcostau(3,3,3,0:nres2)) !(3,3,3,maxres2)maxres2=2*maxres
16203 !el allocate(dsintau(3,3,3,0:nres2))
16204 !el allocate(dtauangle(3,3,3,0:nres2))
16205 !el allocate(domicron(3,2,2,0:nres2))
16206 !el allocate(dcosomicron(3,2,2,0:nres2))
16210 #if defined(MPI) && defined(PARINTDER)
16211 if (nfgtasks.gt.1 .and. me.eq.king) &
16212 call MPI_Bcast(8,1,MPI_INTEGER,king,FG_COMM,IERROR)
16217 ! allocate(dtheta(3,2,nres)) !(3,2,maxres)
16218 ! allocate(dphi(3,3,nres),dalpha(3,3,nres),domega(3,3,nres)) !(3,3,maxres)
16220 ! write (iout,*) "iphi1_start",iphi1_start," iphi1_end",iphi1_end
16223 dtheta(j,1,i)=0.0d0
16224 dtheta(j,2,i)=0.0d0
16230 ! Derivatives of theta's
16231 #if defined(MPI) && defined(PARINTDER)
16232 ! We need dtheta(:,:,i-1) to compute dphi(:,:,i)
16233 do i=max0(ithet_start-1,3),ithet_end
16237 cost=dcos(theta(i))
16238 sint=sqrt(1-cost*cost)
16240 dcostheta(j,1,i)=-(dc_norm(j,i-1)+cost*dc_norm(j,i-2))/&
16242 if (itype(i-1,1).ne.ntyp1) dtheta(j,1,i)=-dcostheta(j,1,i)/sint
16243 dcostheta(j,2,i)=-(dc_norm(j,i-2)+cost*dc_norm(j,i-1))/&
16245 if (itype(i-1,1).ne.ntyp1) dtheta(j,2,i)=-dcostheta(j,2,i)/sint
16248 #if defined(MPI) && defined(PARINTDER)
16249 ! We need dtheta(:,:,i-1) to compute dphi(:,:,i)
16250 do i=max0(ithet_start-1,3),ithet_end
16254 if ((itype(i-1,1).ne.10).and.(itype(i-1,1).ne.ntyp1)) then
16255 cost1=dcos(omicron(1,i))
16256 sint1=sqrt(1-cost1*cost1)
16257 cost2=dcos(omicron(2,i))
16258 sint2=sqrt(1-cost2*cost2)
16260 !C Calculate derivative over first omicron (Cai-2,Cai-1,SCi-1)
16261 dcosomicron(j,1,1,i)=-(dc_norm(j,i-1+nres)+ &
16262 cost1*dc_norm(j,i-2))/ &
16264 domicron(j,1,1,i)=-1/sint1*dcosomicron(j,1,1,i)
16265 dcosomicron(j,1,2,i)=-(dc_norm(j,i-2) &
16266 +cost1*(dc_norm(j,i-1+nres)))/ &
16268 domicron(j,1,2,i)=-1/sint1*dcosomicron(j,1,2,i)
16269 !C Calculate derivative over second omicron Sci-1,Cai-1 Cai
16270 !C Looks messy but better than if in loop
16271 dcosomicron(j,2,1,i)=-(-dc_norm(j,i-1+nres) &
16272 +cost2*dc_norm(j,i-1))/ &
16274 domicron(j,2,1,i)=-1/sint2*dcosomicron(j,2,1,i)
16275 dcosomicron(j,2,2,i)=-(dc_norm(j,i-1) &
16276 +cost2*(-dc_norm(j,i-1+nres)))/ &
16278 ! write(iout,*) "vbld", i,itype(i,1),vbld(i-1+nres)
16279 domicron(j,2,2,i)=-1/sint2*dcosomicron(j,2,2,i)
16283 !elwrite(iout,*) "after vbld write"
16284 ! Derivatives of phi:
16285 ! If phi is 0 or 180 degrees, then the formulas
16286 ! have to be derived by power series expansion of the
16287 ! conventional formulas around 0 and 180.
16289 do i=iphi1_start,iphi1_end
16293 ! if (itype(i-1,1).eq.21 .or. itype(i-2,1).eq.21 ) cycle
16294 ! the conventional case
16295 sint=dsin(theta(i))
16296 sint1=dsin(theta(i-1))
16298 cost=dcos(theta(i))
16299 cost1=dcos(theta(i-1))
16301 scalp=scalar(dc_norm(1,i-3),dc_norm(1,i-1))
16302 fac0=1.0d0/(sint1*sint)
16305 fac3=cosg*cost1/(sint1*sint1)
16306 fac4=cosg*cost/(sint*sint)
16307 ! Obtaining the gamma derivatives from sine derivative
16308 if (phi(i).gt.-pi4.and.phi(i).le.pi4.or. &
16309 phi(i).gt.pi34.and.phi(i).le.pi.or. &
16310 phi(i).ge.-pi.and.phi(i).le.-pi34) then
16311 call vecpr(dc_norm(1,i-1),dc_norm(1,i-2),vp1)
16312 call vecpr(dc_norm(1,i-3),dc_norm(1,i-1),vp2)
16313 call vecpr(dc_norm(1,i-3),dc_norm(1,i-2),vp3)
16317 cosg_inv=1.0d0/cosg
16318 if (itype(i-1,1).ne.ntyp1 .and. itype(i-2,1).ne.ntyp1) then
16319 dsinphi(j,1,i)=-sing*ctgt1*dtheta(j,1,i-1) &
16320 -(fac0*vp1(j)+sing*dc_norm(j,i-3))*vbld_inv(i-2)
16321 dphi(j,1,i)=cosg_inv*dsinphi(j,1,i)
16323 -sing*(ctgt1*dtheta(j,2,i-1)+ctgt*dtheta(j,1,i)) &
16324 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
16325 dphi(j,2,i)=cosg_inv*dsinphi(j,2,i)
16326 dsinphi(j,3,i)=-sing*ctgt*dtheta(j,2,i) &
16327 +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i)
16328 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
16329 dphi(j,3,i)=cosg_inv*dsinphi(j,3,i)
16331 ! Bug fixed 3/24/05 (AL)
16333 ! Obtaining the gamma derivatives from cosine derivative
16336 if (itype(i-1,1).ne.ntyp1 .and. itype(i-2,1).ne.ntyp1) then
16337 dcosphi(j,1,i)=fac1*dcostheta(j,1,i-1)+fac3* &
16338 dcostheta(j,1,i-1)-fac0*(dc_norm(j,i-1)-scalp* &
16339 dc_norm(j,i-3))/vbld(i-2)
16340 dphi(j,1,i)=-1/sing*dcosphi(j,1,i)
16341 dcosphi(j,2,i)=fac1*dcostheta(j,2,i-1)+fac2* &
16342 dcostheta(j,1,i)+fac3*dcostheta(j,2,i-1)+fac4* &
16344 dphi(j,2,i)=-1/sing*dcosphi(j,2,i)
16345 dcosphi(j,3,i)=fac2*dcostheta(j,2,i)+fac4* &
16346 dcostheta(j,2,i)-fac0*(dc_norm(j,i-3)-scalp* &
16347 dc_norm(j,i-1))/vbld(i)
16348 dphi(j,3,i)=-1/sing*dcosphi(j,3,i)
16353 !alculate derivative of Tauangle
16355 do i=itau_start,itau_end
16358 !elwrite(iout,*) " vecpr",i,nres
16360 if ((itype(i-2,1).eq.ntyp1).or.(itype(i-2,1).eq.10)) cycle
16361 ! if ((itype(i-2,1).eq.ntyp1).or.(itype(i-2,1).eq.10).or.
16362 ! & (itype(i-1,1).eq.ntyp1).or.(itype(i,1).eq.ntyp1)) cycle
16363 !c dtauangle(j,intertyp,dervityp,residue number)
16364 !c INTERTYP=1 SC...Ca...Ca..Ca
16365 ! the conventional case
16366 sint=dsin(theta(i))
16367 sint1=dsin(omicron(2,i-1))
16368 sing=dsin(tauangle(1,i))
16369 cost=dcos(theta(i))
16370 cost1=dcos(omicron(2,i-1))
16371 cosg=dcos(tauangle(1,i))
16372 !elwrite(iout,*) " vecpr5",i,nres
16374 !elwrite(iout,*) " vecpreee",i,nres,j,i-2+nres
16375 !elwrite(iout,*) " vecpr5",dc_norm2(1,1)
16376 dc_norm2(j,i-2+nres)=-dc_norm(j,i-2+nres)
16377 ! write(iout,*) dc_norm2(j,i-2+nres),"dcnorm"
16379 scalp=scalar(dc_norm2(1,i-2+nres),dc_norm(1,i-1))
16380 fac0=1.0d0/(sint1*sint)
16383 fac3=cosg*cost1/(sint1*sint1)
16384 fac4=cosg*cost/(sint*sint)
16385 ! write(iout,*) "faki",fac0,fac1,fac2,fac3,fac4
16386 ! Obtaining the gamma derivatives from sine derivative
16387 if (tauangle(1,i).gt.-pi4.and.tauangle(1,i).le.pi4.or. &
16388 tauangle(1,i).gt.pi34.and.tauangle(1,i).le.pi.or. &
16389 tauangle(1,i).gt.-pi.and.tauangle(1,i).le.-pi34) then
16390 call vecpr(dc_norm(1,i-1),dc_norm(1,i-2),vp1)
16391 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-1),vp2)
16392 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-2),vp3)
16396 cosg_inv=1.0d0/cosg
16397 dsintau(j,1,1,i)=-sing*ctgt1*domicron(j,2,2,i-1) &
16398 -(fac0*vp1(j)+sing*(dc_norm2(j,i-2+nres))) &
16399 *vbld_inv(i-2+nres)
16400 dtauangle(j,1,1,i)=cosg_inv*dsintau(j,1,1,i)
16401 dsintau(j,1,2,i)= &
16402 -sing*(ctgt1*domicron(j,2,1,i-1)+ctgt*dtheta(j,1,i)) &
16403 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
16404 ! write(iout,*) "dsintau", dsintau(j,1,2,i)
16405 dtauangle(j,1,2,i)=cosg_inv*dsintau(j,1,2,i)
16406 ! Bug fixed 3/24/05 (AL)
16407 dsintau(j,1,3,i)=-sing*ctgt*dtheta(j,2,i) &
16408 +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i)
16409 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
16410 dtauangle(j,1,3,i)=cosg_inv*dsintau(j,1,3,i)
16412 ! Obtaining the gamma derivatives from cosine derivative
16415 dcostau(j,1,1,i)=fac1*dcosomicron(j,2,2,i-1)+fac3* &
16416 dcosomicron(j,2,2,i-1)-fac0*(dc_norm(j,i-1)-scalp* &
16417 (dc_norm2(j,i-2+nres)))/vbld(i-2+nres)
16418 dtauangle(j,1,1,i)=-1/sing*dcostau(j,1,1,i)
16419 dcostau(j,1,2,i)=fac1*dcosomicron(j,2,1,i-1)+fac2* &
16420 dcostheta(j,1,i)+fac3*dcosomicron(j,2,1,i-1)+fac4* &
16422 dtauangle(j,1,2,i)=-1/sing*dcostau(j,1,2,i)
16423 dcostau(j,1,3,i)=fac2*dcostheta(j,2,i)+fac4* &
16424 dcostheta(j,2,i)-fac0*(-dc_norm(j,i-2+nres)-scalp* &
16425 dc_norm(j,i-1))/vbld(i)
16426 dtauangle(j,1,3,i)=-1/sing*dcostau(j,1,3,i)
16427 ! write (iout,*) "else",i
16431 ! write(iout,*) "tu",i,k,(dtauangle(j,1,k,i),j=1,3)
16434 !C Second case Ca...Ca...Ca...SC
16436 do i=itau_start,itau_end
16440 if ((itype(i-1,1).eq.ntyp1).or.(itype(i-1,1).eq.10).or. &
16441 (itype(i-2,1).eq.ntyp1).or.(itype(i-3,1).eq.ntyp1)) cycle
16442 ! the conventional case
16443 sint=dsin(omicron(1,i))
16444 sint1=dsin(theta(i-1))
16445 sing=dsin(tauangle(2,i))
16446 cost=dcos(omicron(1,i))
16447 cost1=dcos(theta(i-1))
16448 cosg=dcos(tauangle(2,i))
16450 ! dc_norm2(j,i-1+nres)=-dc_norm(j,i-1+nres)
16452 scalp=scalar(dc_norm(1,i-3),dc_norm(1,i-1+nres))
16453 fac0=1.0d0/(sint1*sint)
16456 fac3=cosg*cost1/(sint1*sint1)
16457 fac4=cosg*cost/(sint*sint)
16458 ! Obtaining the gamma derivatives from sine derivative
16459 if (tauangle(2,i).gt.-pi4.and.tauangle(2,i).le.pi4.or. &
16460 tauangle(2,i).gt.pi34.and.tauangle(2,i).le.pi.or. &
16461 tauangle(2,i).gt.-pi.and.tauangle(2,i).le.-pi34) then
16462 call vecpr(dc_norm2(1,i-1+nres),dc_norm(1,i-2),vp1)
16463 call vecpr(dc_norm(1,i-3),dc_norm(1,i-1+nres),vp2)
16464 call vecpr(dc_norm(1,i-3),dc_norm(1,i-2),vp3)
16468 cosg_inv=1.0d0/cosg
16469 dsintau(j,2,1,i)=-sing*ctgt1*dtheta(j,1,i-1) &
16470 +(fac0*vp1(j)-sing*dc_norm(j,i-3))*vbld_inv(i-2)
16471 ! write(iout,*) i,j,dsintau(j,2,1,i),sing*ctgt1*dtheta(j,1,i-1),
16472 ! &fac0*vp1(j),sing*dc_norm(j,i-3),vbld_inv(i-2),"dsintau(2,1)"
16473 dtauangle(j,2,1,i)=cosg_inv*dsintau(j,2,1,i)
16474 dsintau(j,2,2,i)= &
16475 -sing*(ctgt1*dtheta(j,2,i-1)+ctgt*domicron(j,1,1,i)) &
16476 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
16477 ! write(iout,*) "sprawdzenie",i,j,sing*ctgt1*dtheta(j,2,i-1),
16478 ! & sing*ctgt*domicron(j,1,2,i),
16479 ! & (fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
16480 dtauangle(j,2,2,i)=cosg_inv*dsintau(j,2,2,i)
16481 ! Bug fixed 3/24/05 (AL)
16482 dsintau(j,2,3,i)=-sing*ctgt*domicron(j,1,2,i) &
16483 +(fac0*vp3(j)-sing*dc_norm(j,i-1+nres))*vbld_inv(i-1+nres)
16484 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
16485 dtauangle(j,2,3,i)=cosg_inv*dsintau(j,2,3,i)
16487 ! Obtaining the gamma derivatives from cosine derivative
16490 dcostau(j,2,1,i)=fac1*dcostheta(j,1,i-1)+fac3* &
16491 dcostheta(j,1,i-1)-fac0*(dc_norm(j,i-1+nres)-scalp* &
16492 dc_norm(j,i-3))/vbld(i-2)
16493 dtauangle(j,2,1,i)=-1/sing*dcostau(j,2,1,i)
16494 dcostau(j,2,2,i)=fac1*dcostheta(j,2,i-1)+fac2* &
16495 dcosomicron(j,1,1,i)+fac3*dcostheta(j,2,i-1)+fac4* &
16496 dcosomicron(j,1,1,i)
16497 dtauangle(j,2,2,i)=-1/sing*dcostau(j,2,2,i)
16498 dcostau(j,2,3,i)=fac2*dcosomicron(j,1,2,i)+fac4* &
16499 dcosomicron(j,1,2,i)-fac0*(dc_norm(j,i-3)-scalp* &
16500 dc_norm(j,i-1+nres))/vbld(i-1+nres)
16501 dtauangle(j,2,3,i)=-1/sing*dcostau(j,2,3,i)
16502 ! write(iout,*) i,j,"else", dtauangle(j,2,3,i)
16507 !CC third case SC...Ca...Ca...SC
16510 do i=itau_start,itau_end
16514 ! the conventional case
16515 if ((itype(i-1,1).eq.ntyp1).or.(itype(i-1,1).eq.10).or. &
16516 (itype(i-2,1).eq.ntyp1).or.(itype(i-2,1).eq.10)) cycle
16517 sint=dsin(omicron(1,i))
16518 sint1=dsin(omicron(2,i-1))
16519 sing=dsin(tauangle(3,i))
16520 cost=dcos(omicron(1,i))
16521 cost1=dcos(omicron(2,i-1))
16522 cosg=dcos(tauangle(3,i))
16524 dc_norm2(j,i-2+nres)=-dc_norm(j,i-2+nres)
16525 ! dc_norm2(j,i-1+nres)=-dc_norm(j,i-1+nres)
16527 scalp=scalar(dc_norm2(1,i-2+nres),dc_norm(1,i-1+nres))
16528 fac0=1.0d0/(sint1*sint)
16531 fac3=cosg*cost1/(sint1*sint1)
16532 fac4=cosg*cost/(sint*sint)
16533 ! Obtaining the gamma derivatives from sine derivative
16534 if (tauangle(3,i).gt.-pi4.and.tauangle(3,i).le.pi4.or. &
16535 tauangle(3,i).gt.pi34.and.tauangle(3,i).le.pi.or. &
16536 tauangle(3,i).gt.-pi.and.tauangle(3,i).le.-pi34) then
16537 call vecpr(dc_norm(1,i-1+nres),dc_norm(1,i-2),vp1)
16538 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-1+nres),vp2)
16539 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-2),vp3)
16543 cosg_inv=1.0d0/cosg
16544 dsintau(j,3,1,i)=-sing*ctgt1*domicron(j,2,2,i-1) &
16545 -(fac0*vp1(j)-sing*dc_norm(j,i-2+nres)) &
16546 *vbld_inv(i-2+nres)
16547 dtauangle(j,3,1,i)=cosg_inv*dsintau(j,3,1,i)
16548 dsintau(j,3,2,i)= &
16549 -sing*(ctgt1*domicron(j,2,1,i-1)+ctgt*domicron(j,1,1,i)) &
16550 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
16551 dtauangle(j,3,2,i)=cosg_inv*dsintau(j,3,2,i)
16552 ! Bug fixed 3/24/05 (AL)
16553 dsintau(j,3,3,i)=-sing*ctgt*domicron(j,1,2,i) &
16554 +(fac0*vp3(j)-sing*dc_norm(j,i-1+nres)) &
16555 *vbld_inv(i-1+nres)
16556 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
16557 dtauangle(j,3,3,i)=cosg_inv*dsintau(j,3,3,i)
16559 ! Obtaining the gamma derivatives from cosine derivative
16562 dcostau(j,3,1,i)=fac1*dcosomicron(j,2,2,i-1)+fac3* &
16563 dcosomicron(j,2,2,i-1)-fac0*(dc_norm(j,i-1+nres)-scalp* &
16564 dc_norm2(j,i-2+nres))/vbld(i-2+nres)
16565 dtauangle(j,3,1,i)=-1/sing*dcostau(j,3,1,i)
16566 dcostau(j,3,2,i)=fac1*dcosomicron(j,2,1,i-1)+fac2* &
16567 dcosomicron(j,1,1,i)+fac3*dcosomicron(j,2,1,i-1)+fac4* &
16568 dcosomicron(j,1,1,i)
16569 dtauangle(j,3,2,i)=-1/sing*dcostau(j,3,2,i)
16570 dcostau(j,3,3,i)=fac2*dcosomicron(j,1,2,i)+fac4* &
16571 dcosomicron(j,1,2,i)-fac0*(dc_norm2(j,i-2+nres)-scalp* &
16572 dc_norm(j,i-1+nres))/vbld(i-1+nres)
16573 dtauangle(j,3,3,i)=-1/sing*dcostau(j,3,3,i)
16574 ! write(iout,*) "else",i
16580 ! Derivatives of side-chain angles alpha and omega
16581 #if defined(MPI) && defined(PARINTDER)
16582 do i=ibond_start,ibond_end
16586 if(itype(i,1).ne.10 .and. itype(i,1).ne.ntyp1) then
16587 fac5=1.0d0/dsqrt(2*(1+dcos(theta(i+1))))
16590 fac8=fac5/vbld(i+1)
16591 fac9=fac5/vbld(i+nres)
16592 scala1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
16593 scala2=scalar(dc_norm(1,i),dc_norm(1,i+nres))
16594 cosa=dsqrt(0.5d0/(1.0d0+dcos(theta(i+1))))* &
16595 (scalar(dC_norm(1,i),dC_norm(1,i+nres)) &
16596 -scalar(dC_norm(1,i-1),dC_norm(1,i+nres)))
16597 sina=sqrt(1-cosa*cosa)
16599 ! write (iout,*) "i",i," cosa",cosa," sina",sina," sino",sino
16601 dcosalpha(j,1,i)=fac6*(scala1*dc_norm(j,i-1)- &
16602 dc_norm(j,i+nres))-cosa*fac7*dcostheta(j,1,i+1)
16603 dalpha(j,1,i)=-1/sina*dcosalpha(j,1,i)
16604 dcosalpha(j,2,i)=fac8*(dc_norm(j,i+nres)- &
16605 scala2*dc_norm(j,i))-cosa*fac7*dcostheta(j,2,i+1)
16606 dalpha(j,2,i)=-1/sina*dcosalpha(j,2,i)
16607 dcosalpha(j,3,i)=(fac9*(dc_norm(j,i)- &
16608 dc_norm(j,i-1))-(cosa*dc_norm(j,i+nres))/ &
16610 dalpha(j,3,i)=-1/sina*dcosalpha(j,3,i)
16612 ! obtaining the derivatives of omega from sines
16613 if(omeg(i).gt.-pi4.and.omeg(i).le.pi4.or. &
16614 omeg(i).gt.pi34.and.omeg(i).le.pi.or. &
16615 omeg(i).gt.-pi.and.omeg(i).le.-pi34) then
16616 fac15=dcos(theta(i+1))/(dsin(theta(i+1))* &
16618 fac16=dcos(alph(i))/(dsin(alph(i))*dsin(alph(i)))
16619 fac17=1.0d0/(dsin(theta(i+1))*dsin(alph(i)))
16620 call vecpr(dc_norm(1,i+nres),dc_norm(1,i),vo1)
16621 call vecpr(dc_norm(1,i+nres),dc_norm(1,i-1),vo2)
16622 call vecpr(dc_norm(1,i),dc_norm(1,i-1),vo3)
16623 coso_inv=1.0d0/dcos(omeg(i))
16625 dsinomega(j,1,i)=sino*(fac15*dcostheta(j,1,i+1) &
16626 +fac16*dcosalpha(j,1,i))-fac17/vbld(i)*vo1(j)- &
16627 (sino*dc_norm(j,i-1))/vbld(i)
16628 domega(j,1,i)=coso_inv*dsinomega(j,1,i)
16629 dsinomega(j,2,i)=sino*(fac15*dcostheta(j,2,i+1) &
16630 +fac16*dcosalpha(j,2,i))+fac17/vbld(i+1)*vo2(j) &
16631 -sino*dc_norm(j,i)/vbld(i+1)
16632 domega(j,2,i)=coso_inv*dsinomega(j,2,i)
16633 dsinomega(j,3,i)=sino*fac16*dcosalpha(j,3,i)- &
16634 fac17/vbld(i+nres)*vo3(j)-sino*dc_norm(j,i+nres)/ &
16636 domega(j,3,i)=coso_inv*dsinomega(j,3,i)
16639 ! obtaining the derivatives of omega from cosines
16640 fac10=sqrt(0.5d0*(1-dcos(theta(i+1))))
16641 fac11=sqrt(0.5d0*(1+dcos(theta(i+1))))
16646 dcosomega(j,1,i)=(-(0.25d0*cosa/fac11* &
16647 dcostheta(j,1,i+1)+fac11*dcosalpha(j,1,i))*fac12+ &
16648 (0.25d0/fac10*sina*dcostheta(j,1,i+1)+cosa/sina* &
16649 fac10*dcosalpha(j,1,i))*(scala2-fac11*cosa))/fac13
16650 domega(j,1,i)=-1/sino*dcosomega(j,1,i)
16651 dcosomega(j,2,i)=(((dc_norm(j,i+nres)-scala2* &
16652 dc_norm(j,i))/vbld(i+1)-0.25d0*cosa/fac11* &
16653 dcostheta(j,2,i+1)-fac11*dcosalpha(j,2,i))*fac12+ &
16654 (scala2-fac11*cosa)*(0.25d0*sina/fac10* &
16655 dcostheta(j,2,i+1)+fac10*cosa/sina*dcosalpha(j,2,i)))/fac13
16656 domega(j,2,i)=-1/sino*dcosomega(j,2,i)
16657 dcosomega(j,3,i)=1/fac10*((1/vbld(i+nres)*(dc_norm(j,i)- &
16658 scala2*dc_norm(j,i+nres))-fac11*dcosalpha(j,3,i))*sina+ &
16659 (scala2-fac11*cosa)*(cosa/sina*dcosalpha(j,3,i)))/fac14
16660 domega(j,3,i)=-1/sino*dcosomega(j,3,i)
16666 dalpha(k,j,i)=0.0d0
16667 domega(k,j,i)=0.0d0
16673 #if defined(MPI) && defined(PARINTDER)
16674 if (nfgtasks.gt.1) then
16676 !d write (iout,*) "Gather dtheta"
16677 !d call flush(iout)
16678 write (iout,*) "dtheta before gather"
16680 write (iout,'(i3,3(3f8.5,3x))') i,((dtheta(j,k,i),k=1,3),j=1,2)
16683 call MPI_Gatherv(dtheta(1,1,ithet_start),ithet_count(fg_rank),&
16684 MPI_THET,dtheta(1,1,1),ithet_count(0),ithet_displ(0),MPI_THET,&
16685 king,FG_COMM,IERROR)
16687 !d write (iout,*) "Gather dphi"
16688 !d call flush(iout)
16689 write (iout,*) "dphi before gather"
16691 write (iout,'(i3,3(3f8.5,3x))') i,((dphi(j,k,i),k=1,3),j=1,3)
16694 call MPI_Gatherv(dphi(1,1,iphi1_start),iphi1_count(fg_rank),&
16695 MPI_GAM,dphi(1,1,1),iphi1_count(0),iphi1_displ(0),MPI_GAM,&
16696 king,FG_COMM,IERROR)
16697 !d write (iout,*) "Gather dalpha"
16698 !d call flush(iout)
16700 call MPI_Gatherv(dalpha(1,1,ibond_start),ibond_count(fg_rank),&
16701 MPI_GAM,dalpha(1,1,1),ibond_count(0),ibond_displ(0),MPI_GAM,&
16702 king,FG_COMM,IERROR)
16703 !d write (iout,*) "Gather domega"
16704 !d call flush(iout)
16705 call MPI_Gatherv(domega(1,1,ibond_start),ibond_count(fg_rank),&
16706 MPI_GAM,domega(1,1,1),ibond_count(0),ibond_displ(0),MPI_GAM,&
16707 king,FG_COMM,IERROR)
16712 write (iout,*) "dtheta after gather"
16714 write (iout,'(i3,3(3f8.5,3x))') i,((dtheta(j,k,i),j=1,3),k=1,2)
16716 write (iout,*) "dphi after gather"
16718 write (iout,'(i3,3(3f8.5,3x))') i,((dphi(j,k,i),j=1,3),k=1,3)
16720 write (iout,*) "dalpha after gather"
16722 write (iout,'(i3,3(3f8.5,3x))') i,((dalpha(j,k,i),j=1,3),k=1,3)
16724 write (iout,*) "domega after gather"
16726 write (iout,'(i3,3(3f8.5,3x))') i,((domega(j,k,i),j=1,3),k=1,3)
16730 end subroutine intcartderiv
16731 !-----------------------------------------------------------------------------
16732 subroutine checkintcartgrad
16733 ! implicit real*8 (a-h,o-z)
16734 ! include 'DIMENSIONS'
16738 ! include 'COMMON.CHAIN'
16739 ! include 'COMMON.VAR'
16740 ! include 'COMMON.GEO'
16741 ! include 'COMMON.INTERACT'
16742 ! include 'COMMON.DERIV'
16743 ! include 'COMMON.IOUNITS'
16744 ! include 'COMMON.SETUP'
16745 real(kind=8),dimension(3,2,nres) :: dthetanum !(3,2,maxres)
16746 real(kind=8),dimension(3,3,nres) :: dphinum,dalphanum,domeganum !(3,3,maxres)
16747 real(kind=8),dimension(nres) :: theta_s,phi_s,alph_s,omeg_s !(maxres)
16748 real(kind=8),dimension(3) :: dc_norm_s
16749 real(kind=8) :: aincr=1.0d-5
16751 real(kind=8) :: dcji
16754 theta_s(i)=theta(i)
16758 ! Check theta gradient
16760 "Analytical (upper) and numerical (lower) gradient of theta"
16765 dc(j,i-2)=dcji+aincr
16766 call chainbuild_cart
16767 call int_from_cart1(.false.)
16768 dthetanum(j,1,i)=(theta(i)-theta_s(i))/aincr
16771 dc(j,i-1)=dc(j,i-1)+aincr
16772 call chainbuild_cart
16773 dthetanum(j,2,i)=(theta(i)-theta_s(i))/aincr
16776 !el write (iout,'(i5,3f10.5,5x,3f10.5)') i,(dtheta(j,1,i),j=1,3),&
16777 !el (dtheta(j,2,i),j=1,3)
16778 !el write (iout,'(5x,3f10.5,5x,3f10.5)') (dthetanum(j,1,i),j=1,3),&
16779 !el (dthetanum(j,2,i),j=1,3)
16780 !el write (iout,'(5x,3f10.5,5x,3f10.5)') &
16781 !el (dthetanum(j,1,i)/dtheta(j,1,i),j=1,3),&
16782 !el (dthetanum(j,2,i)/dtheta(j,2,i),j=1,3)
16785 ! Check gamma gradient
16787 "Analytical (upper) and numerical (lower) gradient of gamma"
16791 dc(j,i-3)=dcji+aincr
16792 call chainbuild_cart
16793 dphinum(j,1,i)=(phi(i)-phi_s(i))/aincr
16796 dc(j,i-2)=dcji+aincr
16797 call chainbuild_cart
16798 dphinum(j,2,i)=(phi(i)-phi_s(i))/aincr
16801 dc(j,i-1)=dc(j,i-1)+aincr
16802 call chainbuild_cart
16803 dphinum(j,3,i)=(phi(i)-phi_s(i))/aincr
16806 !el write (iout,'(i5,3(3f10.5,5x))') i,(dphi(j,1,i),j=1,3),&
16807 !el (dphi(j,2,i),j=1,3),(dphi(j,3,i),j=1,3)
16808 !el write (iout,'(5x,3(3f10.5,5x))') (dphinum(j,1,i),j=1,3),&
16809 !el (dphinum(j,2,i),j=1,3),(dphinum(j,3,i),j=1,3)
16810 !el write (iout,'(5x,3(3f10.5,5x))') &
16811 !el (dphinum(j,1,i)/dphi(j,1,i),j=1,3),&
16812 !el (dphinum(j,2,i)/dphi(j,2,i),j=1,3),&
16813 !el (dphinum(j,3,i)/dphi(j,3,i),j=1,3)
16816 ! Check alpha gradient
16818 "Analytical (upper) and numerical (lower) gradient of alpha"
16820 if(itype(i,1).ne.10) then
16823 dc(j,i-1)=dcji+aincr
16824 call chainbuild_cart
16825 dalphanum(j,1,i)=(alph(i)-alph_s(i)) &
16830 call chainbuild_cart
16831 dalphanum(j,2,i)=(alph(i)-alph_s(i)) &
16835 dc(j,i+nres)=dc(j,i+nres)+aincr
16836 call chainbuild_cart
16837 dalphanum(j,3,i)=(alph(i)-alph_s(i)) &
16842 !el write (iout,'(i5,3(3f10.5,5x))') i,(dalpha(j,1,i),j=1,3),&
16843 !el (dalpha(j,2,i),j=1,3),(dalpha(j,3,i),j=1,3)
16844 !el write (iout,'(5x,3(3f10.5,5x))') (dalphanum(j,1,i),j=1,3),&
16845 !el (dalphanum(j,2,i),j=1,3),(dalphanum(j,3,i),j=1,3)
16846 !el write (iout,'(5x,3(3f10.5,5x))') &
16847 !el (dalphanum(j,1,i)/dalpha(j,1,i),j=1,3),&
16848 !el (dalphanum(j,2,i)/dalpha(j,2,i),j=1,3),&
16849 !el (dalphanum(j,3,i)/dalpha(j,3,i),j=1,3)
16852 ! Check omega gradient
16854 "Analytical (upper) and numerical (lower) gradient of omega"
16856 if(itype(i,1).ne.10) then
16859 dc(j,i-1)=dcji+aincr
16860 call chainbuild_cart
16861 domeganum(j,1,i)=(omeg(i)-omeg_s(i)) &
16866 call chainbuild_cart
16867 domeganum(j,2,i)=(omeg(i)-omeg_s(i)) &
16871 dc(j,i+nres)=dc(j,i+nres)+aincr
16872 call chainbuild_cart
16873 domeganum(j,3,i)=(omeg(i)-omeg_s(i)) &
16878 !el write (iout,'(i5,3(3f10.5,5x))') i,(domega(j,1,i),j=1,3),&
16879 !el (domega(j,2,i),j=1,3),(domega(j,3,i),j=1,3)
16880 !el write (iout,'(5x,3(3f10.5,5x))') (domeganum(j,1,i),j=1,3),&
16881 !el (domeganum(j,2,i),j=1,3),(domeganum(j,3,i),j=1,3)
16882 !el write (iout,'(5x,3(3f10.5,5x))') &
16883 !el (domeganum(j,1,i)/domega(j,1,i),j=1,3),&
16884 !el (domeganum(j,2,i)/domega(j,2,i),j=1,3),&
16885 !el (domeganum(j,3,i)/domega(j,3,i),j=1,3)
16889 end subroutine checkintcartgrad
16890 !-----------------------------------------------------------------------------
16892 !-----------------------------------------------------------------------------
16893 real(kind=8) function qwolynes(seg1,seg2,flag,seg3,seg4)
16894 ! implicit real*8 (a-h,o-z)
16895 ! include 'DIMENSIONS'
16896 ! include 'COMMON.IOUNITS'
16897 ! include 'COMMON.CHAIN'
16898 ! include 'COMMON.INTERACT'
16899 ! include 'COMMON.VAR'
16900 integer :: i,j,jl,k,l,il,kl,nl,np,ip,kp,seg1,seg2,seg3,seg4,secseg
16901 integer :: kkk,nsep=3
16902 real(kind=8) :: qm !dist,
16903 real(kind=8) :: qq,qqij,qqijCM,dij,d0ij,dijCM,d0ijCM,qqmax
16904 logical :: lprn=.false.
16906 ! real(kind=8) :: sigm,x
16908 !el sigm(x)=0.25d0*x ! local function
16914 do il=seg1+nsep,seg2
16917 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2 + &
16918 (cref(2,jl,kkk)-cref(2,il,kkk))**2 + &
16919 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
16921 qqij = dexp(-0.5d0*((dij-d0ij)/(sigm(d0ij)))**2)
16922 if (itype(il,1).ne.10 .or. itype(jl,1).ne.10) then
16925 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
16926 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
16927 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
16928 dijCM=dist(il+nres,jl+nres)
16929 qqijCM = dexp(-0.5d0*((dijCM-d0ijCM)/(sigm(d0ijCM)))**2)
16931 qq = qq+qqij+qqijCM
16937 if((seg3-il).lt.3) then
16944 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2+ &
16945 (cref(2,jl,kkk)-cref(2,il,kkk))**2+ &
16946 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
16948 qqij = dexp(-0.5d0*((dij-d0ij)/(sigm(d0ij)))**2)
16949 if (itype(il,1).ne.10 .or. itype(jl,1).ne.10) then
16952 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
16953 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
16954 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
16955 dijCM=dist(il+nres,jl+nres)
16956 qqijCM = dexp(-0.5d0*((dijCM-d0ijCM)/(sigm(d0ijCM)))**2)
16958 qq = qq+qqij+qqijCM
16963 if (qqmax.le.qq) qqmax=qq
16965 qwolynes=1.0d0-qqmax
16967 end function qwolynes
16968 !-----------------------------------------------------------------------------
16969 subroutine qwolynes_prim(seg1,seg2,flag,seg3,seg4)
16970 ! implicit real*8 (a-h,o-z)
16971 ! include 'DIMENSIONS'
16972 ! include 'COMMON.IOUNITS'
16973 ! include 'COMMON.CHAIN'
16974 ! include 'COMMON.INTERACT'
16975 ! include 'COMMON.VAR'
16976 ! include 'COMMON.MD'
16977 integer :: i,j,jl,k,l,il,nl,seg1,seg2,seg3,seg4,secseg
16978 integer :: nsep=3, kkk
16979 !el real(kind=8) :: dist
16980 real(kind=8) :: dij,d0ij,dijCM,d0ijCM
16981 logical :: lprn=.false.
16983 real(kind=8) :: sim,dd0,fac,ddqij
16984 !el sigm(x)=0.25d0*x ! local function
16994 do il=seg1+nsep,seg2
16997 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2+ &
16998 (cref(2,jl,kkk)-cref(2,il,kkk))**2+ &
16999 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
17001 sim = 1.0d0/sigm(d0ij)
17004 fac = dd0*sim/dij*dexp(-0.5d0*dd0*dd0*sim)
17006 ddqij = (c(k,il)-c(k,jl))*fac
17007 dqwol(k,il)=dqwol(k,il)+ddqij
17008 dqwol(k,jl)=dqwol(k,jl)-ddqij
17011 if (itype(il,1).ne.10 .or. itype(jl,1).ne.10) then
17014 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
17015 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
17016 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
17017 dijCM=dist(il+nres,jl+nres)
17018 sim = 1.0d0/sigm(d0ijCM)
17021 fac=dd0*sim/dijCM*dexp(-0.5d0*dd0*dd0*sim)
17023 ddqij = (c(k,il+nres)-c(k,jl+nres))*fac
17024 dxqwol(k,il)=dxqwol(k,il)+ddqij
17025 dxqwol(k,jl)=dxqwol(k,jl)-ddqij
17032 if((seg3-il).lt.3) then
17039 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2+ &
17040 (cref(2,jl,kkk)-cref(2,il,kkk))**2+ &
17041 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
17043 sim = 1.0d0/sigm(d0ij)
17046 fac = dd0*sim/dij*dexp(-0.5d0*dd0*dd0*sim)
17048 ddqij = (c(k,il)-c(k,jl))*fac
17049 dqwol(k,il)=dqwol(k,il)+ddqij
17050 dqwol(k,jl)=dqwol(k,jl)-ddqij
17052 if (itype(il,1).ne.10 .or. itype(jl,1).ne.10) then
17055 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
17056 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
17057 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
17058 dijCM=dist(il+nres,jl+nres)
17059 sim = 1.0d0/sigm(d0ijCM)
17062 fac = dd0*sim/dijCM*dexp(-0.5d0*dd0*dd0*sim)
17064 ddqij = (c(k,il+nres)-c(k,jl+nres))*fac
17065 dxqwol(k,il)=dxqwol(k,il)+ddqij
17066 dxqwol(k,jl)=dxqwol(k,jl)-ddqij
17075 dqwol(j,i)=dqwol(j,i)/nl
17076 dxqwol(j,i)=dxqwol(j,i)/nl
17080 end subroutine qwolynes_prim
17081 !-----------------------------------------------------------------------------
17082 subroutine qwol_num(seg1,seg2,flag,seg3,seg4)
17083 ! implicit real*8 (a-h,o-z)
17084 ! include 'DIMENSIONS'
17085 ! include 'COMMON.IOUNITS'
17086 ! include 'COMMON.CHAIN'
17087 ! include 'COMMON.INTERACT'
17088 ! include 'COMMON.VAR'
17089 integer :: seg1,seg2,seg3,seg4
17091 real(kind=8),dimension(3,0:nres) :: qwolan,qwolxan
17092 real(kind=8),dimension(3,0:2*nres) :: cdummy
17093 real(kind=8) :: q1,q2
17094 real(kind=8) :: delta=1.0d-10
17099 q1=qwolynes(seg1,seg2,flag,seg3,seg4)
17101 c(j,i)=c(j,i)+delta
17102 q2=qwolynes(seg1,seg2,flag,seg3,seg4)
17103 qwolan(j,i)=(q2-q1)/delta
17109 q1=qwolynes(seg1,seg2,flag,seg3,seg4)
17110 cdummy(j,i+nres)=c(j,i+nres)
17111 c(j,i+nres)=c(j,i+nres)+delta
17112 q2=qwolynes(seg1,seg2,flag,seg3,seg4)
17113 qwolxan(j,i)=(q2-q1)/delta
17114 c(j,i+nres)=cdummy(j,i+nres)
17117 ! write(iout,*) "Numerical Q carteisan gradients backbone: "
17119 ! write(iout,'(i5,3e15.5)') i, (qwolan(j,i),j=1,3)
17121 ! write(iout,*) "Numerical Q carteisan gradients side-chain: "
17123 ! write(iout,'(i5,3e15.5)') i, (qwolxan(j,i),j=1,3)
17126 end subroutine qwol_num
17127 !-----------------------------------------------------------------------------
17128 subroutine EconstrQ
17129 ! MD with umbrella_sampling using Wolyne's distance measure as a constraint
17130 ! implicit real*8 (a-h,o-z)
17131 ! include 'DIMENSIONS'
17132 ! include 'COMMON.CONTROL'
17133 ! include 'COMMON.VAR'
17134 ! include 'COMMON.MD'
17137 ! include 'COMMON.LANGEVIN'
17139 ! include 'COMMON.LANGEVIN.lang0'
17141 ! include 'COMMON.CHAIN'
17142 ! include 'COMMON.DERIV'
17143 ! include 'COMMON.GEO'
17144 ! include 'COMMON.LOCAL'
17145 ! include 'COMMON.INTERACT'
17146 ! include 'COMMON.IOUNITS'
17147 ! include 'COMMON.NAMES'
17148 ! include 'COMMON.TIME1'
17149 real(kind=8) :: uzap1,uzap2,hm1,hm2,hmnum,ucdelan
17150 real(kind=8),dimension(3,0:nres) :: dUcartan,dUxcartan,cdummy,&
17152 integer :: kstart,kend,lstart,lend,idummy
17153 real(kind=8) :: delta=1.0d-7
17154 integer :: i,j,k,ii
17158 dudconst(j,i)=0.0d0
17159 duxconst(j,i)=0.0d0
17160 dudxconst(j,i)=0.0d0
17165 qfrag(i)=qwolynes(ifrag(1,i,iset),ifrag(2,i,iset),.true.,&
17167 Uconst=Uconst+wfrag(i,iset)*harmonic(qfrag(i),qinfrag(i,iset))
17168 ! Calculating the derivatives of Constraint energy with respect to Q
17169 Ucdfrag=wfrag(i,iset)*harmonicprim(qfrag(i),&
17171 ! hm1=harmonic(qfrag(i,iset),qinfrag(i,iset))
17172 ! hm2=harmonic(qfrag(i,iset)+delta,qinfrag(i,iset))
17173 ! hmnum=(hm2-hm1)/delta
17174 ! write(iout,*) "harmonicprim frag",harmonicprim(qfrag(i,iset),
17175 ! & qinfrag(i,iset))
17176 ! write(iout,*) "harmonicnum frag", hmnum
17177 ! Calculating the derivatives of Q with respect to cartesian coordinates
17178 call qwolynes_prim(ifrag(1,i,iset),ifrag(2,i,iset),.true.,&
17180 ! write(iout,*) "dqwol "
17182 ! write(iout,'(i5,3e15.5)') ii,(dqwol(j,ii),j=1,3)
17184 ! write(iout,*) "dxqwol "
17186 ! write(iout,'(i5,3e15.5)') ii,(dxqwol(j,ii),j=1,3)
17188 ! Calculating numerical gradients of dU/dQi and dQi/dxi
17189 ! call qwol_num(ifrag(1,i,iset),ifrag(2,i,iset),.true.
17190 ! & ,idummy,idummy)
17191 ! The gradients of Uconst in Cs
17194 duconst(j,ii)=dUconst(j,ii)+ucdfrag*dqwol(j,ii)
17195 dUxconst(j,ii)=dUxconst(j,ii)+ucdfrag*dxqwol(j,ii)
17200 kstart=ifrag(1,ipair(1,i,iset),iset)
17201 kend=ifrag(2,ipair(1,i,iset),iset)
17202 lstart=ifrag(1,ipair(2,i,iset),iset)
17203 lend=ifrag(2,ipair(2,i,iset),iset)
17204 qpair(i)=qwolynes(kstart,kend,.false.,lstart,lend)
17205 Uconst=Uconst+wpair(i,iset)*harmonic(qpair(i),qinpair(i,iset))
17206 ! Calculating dU/dQ
17207 Ucdpair=wpair(i,iset)*harmonicprim(qpair(i),qinpair(i,iset))
17208 ! hm1=harmonic(qpair(i),qinpair(i,iset))
17209 ! hm2=harmonic(qpair(i)+delta,qinpair(i,iset))
17210 ! hmnum=(hm2-hm1)/delta
17211 ! write(iout,*) "harmonicprim pair ",harmonicprim(qpair(i),
17212 ! & qinpair(i,iset))
17213 ! write(iout,*) "harmonicnum pair ", hmnum
17214 ! Calculating dQ/dXi
17215 call qwolynes_prim(kstart,kend,.false.,&
17217 ! write(iout,*) "dqwol "
17219 ! write(iout,'(i5,3e15.5)') ii,(dqwol(j,ii),j=1,3)
17221 ! write(iout,*) "dxqwol "
17223 ! write(iout,'(i5,3e15.5)') ii,(dxqwol(j,ii),j=1,3)
17225 ! Calculating numerical gradients
17226 ! call qwol_num(kstart,kend,.false.
17228 ! The gradients of Uconst in Cs
17231 duconst(j,ii)=dUconst(j,ii)+ucdpair*dqwol(j,ii)
17232 dUxconst(j,ii)=dUxconst(j,ii)+ucdpair*dxqwol(j,ii)
17236 ! write(iout,*) "Uconst inside subroutine ", Uconst
17237 ! Transforming the gradients from Cs to dCs for the backbone
17241 dudconst(k,i)=dudconst(k,i)+duconst(k,j)+duxconst(k,j)
17245 ! Transforming the gradients from Cs to dCs for the side chains
17248 dudxconst(j,i)=duxconst(j,i)
17251 ! write(iout,*) "dU/ddc backbone "
17253 ! write(iout,'(i5,3e15.5)') ii, (dudconst(j,ii),j=1,3)
17255 ! write(iout,*) "dU/ddX side chain "
17257 ! write(iout,'(i5,3e15.5)') ii,(duxconst(j,ii),j=1,3)
17259 ! Calculating numerical gradients of dUconst/ddc and dUconst/ddx
17260 ! call dEconstrQ_num
17262 end subroutine EconstrQ
17263 !-----------------------------------------------------------------------------
17264 subroutine dEconstrQ_num
17265 ! Calculating numerical dUconst/ddc and dUconst/ddx
17266 ! implicit real*8 (a-h,o-z)
17267 ! include 'DIMENSIONS'
17268 ! include 'COMMON.CONTROL'
17269 ! include 'COMMON.VAR'
17270 ! include 'COMMON.MD'
17273 ! include 'COMMON.LANGEVIN'
17275 ! include 'COMMON.LANGEVIN.lang0'
17277 ! include 'COMMON.CHAIN'
17278 ! include 'COMMON.DERIV'
17279 ! include 'COMMON.GEO'
17280 ! include 'COMMON.LOCAL'
17281 ! include 'COMMON.INTERACT'
17282 ! include 'COMMON.IOUNITS'
17283 ! include 'COMMON.NAMES'
17284 ! include 'COMMON.TIME1'
17285 real(kind=8) :: uzap1,uzap2
17286 real(kind=8),dimension(3,0:nres) :: dUcartan,dUxcartan,cdummy
17287 integer :: kstart,kend,lstart,lend,idummy
17288 real(kind=8) :: delta=1.0d-7
17289 !el local variables
17295 dUcartan(j,i)=0.0d0
17296 cdummy(j,i)=dc(j,i)
17297 dc(j,i)=dc(j,i)+delta
17298 call chainbuild_cart
17301 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),.true.,&
17303 uzap2=uzap2+wfrag(ii,iset)*harmonic(qfrag(ii),&
17307 kstart=ifrag(1,ipair(1,ii,iset),iset)
17308 kend=ifrag(2,ipair(1,ii,iset),iset)
17309 lstart=ifrag(1,ipair(2,ii,iset),iset)
17310 lend=ifrag(2,ipair(2,ii,iset),iset)
17311 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
17312 uzap2=uzap2+wpair(ii,iset)*harmonic(qpair(ii),&
17315 dc(j,i)=cdummy(j,i)
17316 call chainbuild_cart
17319 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),.true.,&
17321 uzap1=uzap1+wfrag(ii,iset)*harmonic(qfrag(ii),&
17325 kstart=ifrag(1,ipair(1,ii,iset),iset)
17326 kend=ifrag(2,ipair(1,ii,iset),iset)
17327 lstart=ifrag(1,ipair(2,ii,iset),iset)
17328 lend=ifrag(2,ipair(2,ii,iset),iset)
17329 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
17330 uzap1=uzap1+wpair(ii,iset)*harmonic(qpair(ii),&
17333 ducartan(j,i)=(uzap2-uzap1)/(delta)
17336 ! Calculating numerical gradients for dU/ddx
17338 duxcartan(j,i)=0.0d0
17340 cdummy(j,i)=dc(j,i+nres)
17341 dc(j,i+nres)=dc(j,i+nres)+delta
17342 call chainbuild_cart
17345 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),.true.,&
17347 uzap2=uzap2+wfrag(ii,iset)*harmonic(qfrag(ii),&
17351 kstart=ifrag(1,ipair(1,ii,iset),iset)
17352 kend=ifrag(2,ipair(1,ii,iset),iset)
17353 lstart=ifrag(1,ipair(2,ii,iset),iset)
17354 lend=ifrag(2,ipair(2,ii,iset),iset)
17355 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
17356 uzap2=uzap2+wpair(ii,iset)*harmonic(qpair(ii),&
17359 dc(j,i+nres)=cdummy(j,i)
17360 call chainbuild_cart
17363 qfrag(ii)=qwolynes(ifrag(1,ii,iset),&
17364 ifrag(2,ii,iset),.true.,idummy,idummy)
17365 uzap1=uzap1+wfrag(ii,iset)*harmonic(qfrag(ii),&
17369 kstart=ifrag(1,ipair(1,ii,iset),iset)
17370 kend=ifrag(2,ipair(1,ii,iset),iset)
17371 lstart=ifrag(1,ipair(2,ii,iset),iset)
17372 lend=ifrag(2,ipair(2,ii,iset),iset)
17373 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
17374 uzap1=uzap1+wpair(ii,iset)*harmonic(qpair(ii),&
17377 duxcartan(j,i)=(uzap2-uzap1)/(delta)
17380 write(iout,*) "Numerical dUconst/ddc backbone "
17382 write(iout,'(i5,3e15.5)') ii,(dUcartan(j,ii),j=1,3)
17384 ! write(iout,*) "Numerical dUconst/ddx side-chain "
17386 ! write(iout,'(i5,3e15.5)') ii,(dUxcartan(j,ii),j=1,3)
17389 end subroutine dEconstrQ_num
17390 !-----------------------------------------------------------------------------
17392 !-----------------------------------------------------------------------------
17393 subroutine check_energies
17395 ! use random, only: ran_number
17399 ! include 'DIMENSIONS'
17400 ! include 'COMMON.CHAIN'
17401 ! include 'COMMON.VAR'
17402 ! include 'COMMON.IOUNITS'
17403 ! include 'COMMON.SBRIDGE'
17404 ! include 'COMMON.LOCAL'
17405 ! include 'COMMON.GEO'
17407 ! External functions
17408 !EL double precision ran_number
17409 !EL external ran_number
17412 integer :: i,j,k,l,lmax,p,pmax
17413 real(kind=8) :: rmin,rmax
17414 real(kind=8) :: eij
17417 real(kind=8) :: wi,rij,tj,pj
17439 !t wi=ran_number(0.0D0,pi)
17440 ! wi=ran_number(0.0D0,pi/6.0D0)
17442 !t tj=ran_number(0.0D0,pi)
17443 !t pj=ran_number(0.0D0,pi)
17444 ! pj=ran_number(0.0D0,pi/6.0D0)
17448 !t rij=ran_number(rmin,rmax)
17450 c(1,j)=d*sin(pj)*cos(tj)
17451 c(2,j)=d*sin(pj)*sin(tj)
17457 c(3,i)=-rij-d*cos(wi)
17460 dc(k,nres+i)=c(k,nres+i)-c(k,i)
17461 dc_norm(k,nres+i)=dc(k,nres+i)/d
17462 dc(k,nres+j)=c(k,nres+j)-c(k,j)
17463 dc_norm(k,nres+j)=dc(k,nres+j)/d
17466 call dyn_ssbond_ene(i,j,eij)
17471 end subroutine check_energies
17472 !-----------------------------------------------------------------------------
17473 subroutine dyn_ssbond_ene(resi,resj,eij)
17478 ! include 'DIMENSIONS'
17479 ! include 'COMMON.SBRIDGE'
17480 ! include 'COMMON.CHAIN'
17481 ! include 'COMMON.DERIV'
17482 ! include 'COMMON.LOCAL'
17483 ! include 'COMMON.INTERACT'
17484 ! include 'COMMON.VAR'
17485 ! include 'COMMON.IOUNITS'
17486 ! include 'COMMON.CALC'
17490 ! include 'COMMON.MD'
17491 ! use MD, only: totT,t_bath
17494 ! External functions
17495 !EL double precision h_base
17496 !EL external h_base
17499 integer :: resi,resj
17502 real(kind=8) :: eij
17505 logical :: havebond
17506 integer itypi,itypj
17507 real(kind=8) :: rrij,ssd,deltat1,deltat2,deltat12,cosphi
17508 real(kind=8) :: sig0ij,ljd,sig,fac,e1,e2
17509 real(kind=8),dimension(3) :: dcosom1,dcosom2
17511 real(kind=8) :: pom1,pom2
17512 real(kind=8) :: ljA,ljB,ljXs
17513 real(kind=8),dimension(1:3) :: d_ljB
17514 real(kind=8) :: ssA,ssB,ssC,ssXs
17515 real(kind=8) :: ssxm,ljxm,ssm,ljm
17516 real(kind=8),dimension(1:3) :: d_ssxm,d_ljxm,d_ssm,d_ljm
17517 real(kind=8) :: f1,f2,h1,h2,hd1,hd2
17518 real(kind=8) :: omega,delta_inv,deltasq_inv,fac1,fac2
17519 !-------FIRST METHOD
17521 real(kind=8),dimension(1:3) :: d_xm
17522 !-------END FIRST METHOD
17523 !-------SECOND METHOD
17524 !$$$ double precision ss,d_ss(0:3),ljf,d_ljf(0:3)
17525 !-------END SECOND METHOD
17527 !-------TESTING CODE
17528 !el logical :: checkstop,transgrad
17529 !el common /sschecks/ checkstop,transgrad
17531 integer :: icheck,nicheck,jcheck,njcheck
17532 real(kind=8),dimension(-1:1) :: echeck
17533 real(kind=8) :: deps,ssx0,ljx0
17534 !-------END TESTING CODE
17540 !el allocate(dyn_ssbond_ij(iatsc_s:iatsc_e,nres))
17541 !el allocate(dyn_ssbond_ij(0:nres+4,nres))
17544 dxi=dc_norm(1,nres+i)
17545 dyi=dc_norm(2,nres+i)
17546 dzi=dc_norm(3,nres+i)
17547 dsci_inv=vbld_inv(i+nres)
17550 xj=c(1,nres+j)-c(1,nres+i)
17551 yj=c(2,nres+j)-c(2,nres+i)
17552 zj=c(3,nres+j)-c(3,nres+i)
17553 dxj=dc_norm(1,nres+j)
17554 dyj=dc_norm(2,nres+j)
17555 dzj=dc_norm(3,nres+j)
17556 dscj_inv=vbld_inv(j+nres)
17558 chi1=chi(itypi,itypj)
17559 chi2=chi(itypj,itypi)
17566 alf12=0.5D0*(alf1+alf2)
17568 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
17569 rij=dsqrt(rrij) ! sc_angular needs rij to really be the inverse
17570 ! The following are set in sc_angular
17574 ! om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
17575 ! om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
17576 ! om12=dxi*dxj+dyi*dyj+dzi*dzj
17578 rij=1.0D0/rij ! Reset this so it makes sense
17580 sig0ij=sigma(itypi,itypj)
17581 sig=sig0ij*dsqrt(1.0D0/sigsq)
17584 ljA=eps1*eps2rt**2*eps3rt**2
17585 ljB=ljA*bb_aq(itypi,itypj)
17586 ljA=ljA*aa_aq(itypi,itypj)
17587 ljxm=ljXs+(-2.0D0*aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
17592 deltat12=om2-om1+2.0d0
17593 cosphi=om12-om1*om2
17597 +akth*(deltat1*deltat1+deltat2*deltat2) &
17598 +v1ss*cosphi+v2ss*cosphi*cosphi+v3ss*cosphi*cosphi*cosphi
17599 ssxm=ssXs-0.5D0*ssB/ssA
17601 !-------TESTING CODE
17602 !$$$c Some extra output
17603 !$$$ ssm=ssC-0.25D0*ssB*ssB/ssA
17604 !$$$ ljm=-0.25D0*ljB*bb(itypi,itypj)/aa(itypi,itypj)
17605 !$$$ ssx0=ssB*ssB-4.0d0*ssA*ssC
17606 !$$$ if (ssx0.gt.0.0d0) then
17607 !$$$ ssx0=ssXs+0.5d0*(-ssB+sqrt(ssx0))/ssA
17611 !$$$ ljx0=ljXs+(-aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
17612 !$$$ write(iout,'(a,4f8.2,2f15.2,3f6.2)')"SSENERGIES ",
17613 !$$$ & ssxm,ljxm,ssx0,ljx0,ssm,ljm,om1,om2,om12
17615 !-------END TESTING CODE
17617 !-------TESTING CODE
17618 ! Stop and plot energy and derivative as a function of distance
17619 if (checkstop) then
17620 ssm=ssC-0.25D0*ssB*ssB/ssA
17621 ljm=-0.25D0*ljB*bb_aq(itypi,itypj)/aa_aq(itypi,itypj)
17622 if (ssm.lt.ljm .and. &
17623 dabs(rij-0.5d0*(ssxm+ljxm)).lt.0.35d0*(ljxm-ssxm)) then
17631 if (.not.checkstop) then
17636 do icheck=0,nicheck
17637 do jcheck=-1,njcheck
17638 if (checkstop) rij=(ssxm-1.0d0)+ &
17639 ((ljxm-ssxm+2.0d0)*icheck)/nicheck+jcheck*deps
17640 !-------END TESTING CODE
17642 if (rij.gt.ljxm) then
17645 fac=(1.0D0/ljd)**expon
17646 e1=fac*fac*aa_aq(itypi,itypj)
17647 e2=fac*bb_aq(itypi,itypj)
17648 eij=eps1*eps2rt*eps3rt*(e1+e2)
17651 eij=eij*eps2rt*eps3rt
17654 e1=e1*eps1*eps2rt**2*eps3rt**2
17655 ed=-expon*(e1+eij)/ljd
17657 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
17658 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
17659 eom12=eij*eps1_om12+eps2der*eps2rt_om12 &
17660 -2.0D0*alf12*eps3der+sigder*sigsq_om12
17661 else if (rij.lt.ssxm) then
17664 eij=ssA*ssd*ssd+ssB*ssd+ssC
17666 ed=2*akcm*ssd+akct*deltat12
17668 pom2=v1ss+2*v2ss*cosphi+3*v3ss*cosphi*cosphi
17669 eom1=-2*akth*deltat1-pom1-om2*pom2
17670 eom2= 2*akth*deltat2+pom1-om1*pom2
17673 omega=v1ss+2.0d0*v2ss*cosphi+3.0d0*v3ss*cosphi*cosphi
17675 d_ssxm(1)=0.5D0*akct/ssA
17676 d_ssxm(2)=-d_ssxm(1)
17679 d_ljxm(1)=sig0ij/sqrt(sigsq**3)
17680 d_ljxm(2)=d_ljxm(1)*sigsq_om2
17681 d_ljxm(3)=d_ljxm(1)*sigsq_om12
17682 d_ljxm(1)=d_ljxm(1)*sigsq_om1
17684 !-------FIRST METHOD, DISCONTINUOUS SECOND DERIVATIVE
17685 xm=0.5d0*(ssxm+ljxm)
17687 d_xm(k)=0.5d0*(d_ssxm(k)+d_ljxm(k))
17689 if (rij.lt.xm) then
17691 ssm=ssC-0.25D0*ssB*ssB/ssA
17692 d_ssm(1)=0.5D0*akct*ssB/ssA
17693 d_ssm(2)=2.0D0*akth*deltat2-om1*omega-d_ssm(1)
17694 d_ssm(1)=-2.0D0*akth*deltat1-om2*omega+d_ssm(1)
17696 f1=(rij-xm)/(ssxm-xm)
17697 f2=(rij-ssxm)/(xm-ssxm)
17701 delta_inv=1.0d0/(xm-ssxm)
17702 deltasq_inv=delta_inv*delta_inv
17704 fac1=deltasq_inv*fac*(xm-rij)
17705 fac2=deltasq_inv*fac*(rij-ssxm)
17706 ed=delta_inv*(Ht*hd2-ssm*hd1)
17707 eom1=fac1*d_ssxm(1)+fac2*d_xm(1)+h1*d_ssm(1)
17708 eom2=fac1*d_ssxm(2)+fac2*d_xm(2)+h1*d_ssm(2)
17709 eom12=fac1*d_ssxm(3)+fac2*d_xm(3)+h1*d_ssm(3)
17712 ljm=-0.25D0*ljB*bb_aq(itypi,itypj)/aa_aq(itypi,itypj)
17713 d_ljm(1)=-0.5D0*bb_aq(itypi,itypj)/aa_aq(itypi,itypj)*ljB
17714 d_ljm(2)=d_ljm(1)*(0.5D0*eps2rt_om2/eps2rt+alf2/eps3rt)
17715 d_ljm(3)=d_ljm(1)*(0.5D0*eps1_om12+0.5D0*eps2rt_om12/eps2rt- &
17717 d_ljm(1)=d_ljm(1)*(0.5D0*eps2rt_om1/eps2rt-alf1/eps3rt)
17718 f1=(rij-ljxm)/(xm-ljxm)
17719 f2=(rij-xm)/(ljxm-xm)
17723 delta_inv=1.0d0/(ljxm-xm)
17724 deltasq_inv=delta_inv*delta_inv
17726 fac1=deltasq_inv*fac*(ljxm-rij)
17727 fac2=deltasq_inv*fac*(rij-xm)
17728 ed=delta_inv*(ljm*hd2-Ht*hd1)
17729 eom1=fac1*d_xm(1)+fac2*d_ljxm(1)+h2*d_ljm(1)
17730 eom2=fac1*d_xm(2)+fac2*d_ljxm(2)+h2*d_ljm(2)
17731 eom12=fac1*d_xm(3)+fac2*d_ljxm(3)+h2*d_ljm(3)
17733 !-------END FIRST METHOD, DISCONTINUOUS SECOND DERIVATIVE
17735 !-------SECOND METHOD, CONTINUOUS SECOND DERIVATIVE
17741 !$$$ d_ljB(1)=ljB*(eps2rt_om1/eps2rt-2.0d0*alf1/eps3rt)
17742 !$$$ d_ljB(2)=ljB*(eps2rt_om2/eps2rt+2.0d0*alf2/eps3rt)
17743 !$$$ d_ljB(3)=ljB*(eps1_om12+eps2rt_om12/eps2rt-2.0d0*alf12/eps3rt)
17745 !$$$ ssm=ssC-0.25D0*ssB*ssB/ssA
17746 !$$$ d_ssm(1)=0.5D0*akct*ssB/ssA
17747 !$$$ d_ssm(2)=2.0D0*akth*deltat2-om1*omega-d_ssm(1)
17748 !$$$ d_ssm(1)=-2.0D0*akth*deltat1-om2*omega+d_ssm(1)
17749 !$$$ d_ssm(3)=omega
17751 !$$$ ljm=-0.25D0*bb(itypi,itypj)/aa(itypi,itypj)
17753 !$$$ d_ljm(k)=ljm*d_ljB(k)
17757 !$$$ ss=ssA*ssd*ssd+ssB*ssd+ssC
17758 !$$$ d_ss(0)=2.0d0*ssA*ssd+ssB
17759 !$$$ d_ss(2)=akct*ssd
17760 !$$$ d_ss(1)=-d_ss(2)-2.0d0*akth*deltat1-om2*omega
17761 !$$$ d_ss(2)=d_ss(2)+2.0d0*akth*deltat2-om1*omega
17764 !$$$ ljf=bb(itypi,itypj)/aa(itypi,itypj)
17765 !$$$ ljf=9.0d0*ljf*(-0.5d0*ljf)**(1.0d0/3.0d0)
17766 !$$$ d_ljf(0)=ljf*2.0d0*ljB*fac1
17768 !$$$ d_ljf(k)=d_ljm(k)+ljf*(d_ljB(k)*fac1*fac1-
17769 !$$$ & 2.0d0*ljB*fac1*d_ljxm(k))
17771 !$$$ ljf=ljm+ljf*ljB*fac1*fac1
17773 !$$$ f1=(rij-ljxm)/(ssxm-ljxm)
17774 !$$$ f2=(rij-ssxm)/(ljxm-ssxm)
17775 !$$$ h1=h_base(f1,hd1)
17776 !$$$ h2=h_base(f2,hd2)
17777 !$$$ eij=ss*h1+ljf*h2
17778 !$$$ delta_inv=1.0d0/(ljxm-ssxm)
17779 !$$$ deltasq_inv=delta_inv*delta_inv
17780 !$$$ fac=ljf*hd2-ss*hd1
17781 !$$$ ed=d_ss(0)*h1+d_ljf(0)*h2+delta_inv*fac
17782 !$$$ eom1=d_ss(1)*h1+d_ljf(1)*h2+deltasq_inv*fac*
17783 !$$$ & (fac1*d_ssxm(1)-fac2*(d_ljxm(1)))
17784 !$$$ eom2=d_ss(2)*h1+d_ljf(2)*h2+deltasq_inv*fac*
17785 !$$$ & (fac1*d_ssxm(2)-fac2*(d_ljxm(2)))
17786 !$$$ eom12=d_ss(3)*h1+d_ljf(3)*h2+deltasq_inv*fac*
17787 !$$$ & (fac1*d_ssxm(3)-fac2*(d_ljxm(3)))
17789 !$$$ havebond=.false.
17790 !$$$ if (ed.gt.0.0d0) havebond=.true.
17791 !-------END SECOND METHOD, CONTINUOUS SECOND DERIVATIVE
17798 ! if (dyn_ssbond_ij(i,j).eq.1.0d300) then
17799 ! write(iout,'(a15,f12.2,f8.1,2i5)')
17800 ! & "SSBOND_E_FORM",totT,t_bath,i,j
17804 dyn_ssbond_ij(i,j)=eij
17805 else if (.not.havebond .and. dyn_ssbond_ij(i,j).lt.1.0d300) then
17806 dyn_ssbond_ij(i,j)=1.0d300
17809 ! write(iout,'(a15,f12.2,f8.1,2i5)')
17810 ! & "SSBOND_E_BREAK",totT,t_bath,i,j
17815 !-------TESTING CODE
17816 !el if (checkstop) then
17817 if (jcheck.eq.0) write(iout,'(a,3f15.8,$)') &
17818 "CHECKSTOP",rij,eij,ed
17822 if (checkstop) then
17823 write(iout,'(f15.8)')(echeck(1)-echeck(-1))*0.5d0/deps
17826 if (checkstop) then
17830 !-------END TESTING CODE
17833 dcosom1(k)=(dc_norm(k,nres+i)-om1*erij(k))/rij
17834 dcosom2(k)=(dc_norm(k,nres+j)-om2*erij(k))/rij
17837 gg(k)=ed*erij(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
17840 gvdwx(k,i)=gvdwx(k,i)-gg(k) &
17841 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
17842 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
17843 gvdwx(k,j)=gvdwx(k,j)+gg(k) &
17844 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
17845 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
17849 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
17854 gvdwc(l,i)=gvdwc(l,i)-gg(l)
17855 gvdwc(l,j)=gvdwc(l,j)+gg(l)
17859 end subroutine dyn_ssbond_ene
17860 !--------------------------------------------------------------------------
17861 subroutine triple_ssbond_ene(resi,resj,resk,eij)
17866 ! include 'DIMENSIONS'
17867 ! include 'COMMON.SBRIDGE'
17868 ! include 'COMMON.CHAIN'
17869 ! include 'COMMON.DERIV'
17870 ! include 'COMMON.LOCAL'
17871 ! include 'COMMON.INTERACT'
17872 ! include 'COMMON.VAR'
17873 ! include 'COMMON.IOUNITS'
17874 ! include 'COMMON.CALC'
17878 ! include 'COMMON.MD'
17879 ! use MD, only: totT,t_bath
17882 double precision h_base
17886 integer resi,resj,resk,m,itypi,itypj,itypk
17888 !c Output arguments
17889 double precision eij,eij1,eij2,eij3
17893 !c integer itypi,itypj,k,l
17894 double precision rrij,ssd,deltat1,deltat2,deltat12,cosphi
17895 double precision rrik,rrjk,rik,rjk,xi,xk,yi,yk,zi,zk,xij,yij,zij
17896 double precision xik,yik,zik,xjk,yjk,zjk,dxk,dyk,dzk
17897 double precision sig0ij,ljd,sig,fac,e1,e2
17898 double precision dcosom1(3),dcosom2(3),ed
17899 double precision pom1,pom2
17900 double precision ljA,ljB,ljXs
17901 double precision d_ljB(1:3)
17902 double precision ssA,ssB,ssC,ssXs
17903 double precision ssxm,ljxm,ssm,ljm
17904 double precision d_ssxm(1:3),d_ljxm(1:3),d_ssm(1:3),d_ljm(1:3)
17906 if (dtriss.eq.0) return
17910 !C write(iout,*) resi,resj,resk
17912 dxi=dc_norm(1,nres+i)
17913 dyi=dc_norm(2,nres+i)
17914 dzi=dc_norm(3,nres+i)
17915 dsci_inv=vbld_inv(i+nres)
17924 dxj=dc_norm(1,nres+j)
17925 dyj=dc_norm(2,nres+j)
17926 dzj=dc_norm(3,nres+j)
17927 dscj_inv=vbld_inv(j+nres)
17933 dxk=dc_norm(1,nres+k)
17934 dyk=dc_norm(2,nres+k)
17935 dzk=dc_norm(3,nres+k)
17936 dscj_inv=vbld_inv(k+nres)
17946 rrij=(xij*xij+yij*yij+zij*zij)
17947 rij=dsqrt(rrij) ! sc_angular needs rij to really be the inverse
17948 rrik=(xik*xik+yik*yik+zik*zik)
17950 rrjk=(xjk*xjk+yjk*yjk+zjk*zjk)
17952 !C there are three combination of distances for each trisulfide bonds
17953 !C The first case the ith atom is the center
17954 !C Energy function is E=d/(a*(x-y)**2+b*(x+y)**2+c) where x is first
17955 !C distance y is second distance the a,b,c,d are parameters derived for
17956 !C this problem d parameter was set as a penalty currenlty set to 1.
17957 if ((iabs(j-i).le.2).or.(iabs(i-k).le.2)) then
17960 eij1=dtriss/(atriss*(rij-rik)**2+btriss*(rij+rik)**6+ctriss)
17962 !C second case jth atom is center
17963 if ((iabs(j-i).le.2).or.(iabs(j-k).le.2)) then
17966 eij2=dtriss/(atriss*(rij-rjk)**2+btriss*(rij+rjk)**6+ctriss)
17968 !C the third case kth atom is the center
17969 if ((iabs(i-k).le.2).or.(iabs(j-k).le.2)) then
17972 eij3=dtriss/(atriss*(rik-rjk)**2+btriss*(rik+rjk)**6+ctriss)
17978 !C write(iout,*)i,j,k,eij
17979 !C The energy penalty calculated now time for the gradient part
17980 !C derivative over rij
17981 fac=-eij1**2/dtriss*(2.0*atriss*(rij-rik)+6.0*btriss*(rij+rik)**5) &
17982 -eij2**2/dtriss*(2.0*atriss*(rij-rjk)+6.0*btriss*(rij+rjk)**5)
17987 gvdwx(m,i)=gvdwx(m,i)-gg(m)
17988 gvdwx(m,j)=gvdwx(m,j)+gg(m)
17992 gvdwc(l,i)=gvdwc(l,i)-gg(l)
17993 gvdwc(l,j)=gvdwc(l,j)+gg(l)
17995 !C now derivative over rik
17996 fac=-eij1**2/dtriss* &
17997 (-2.0*atriss*(rij-rik)+6.0*btriss*(rij+rik)**5) &
17998 -eij3**2/dtriss*(2.0*atriss*(rik-rjk)+6.0*btriss*(rik+rjk)**5)
18003 gvdwx(m,i)=gvdwx(m,i)-gg(m)
18004 gvdwx(m,k)=gvdwx(m,k)+gg(m)
18007 gvdwc(l,i)=gvdwc(l,i)-gg(l)
18008 gvdwc(l,k)=gvdwc(l,k)+gg(l)
18010 !C now derivative over rjk
18011 fac=-eij2**2/dtriss* &
18012 (-2.0*atriss*(rij-rjk)+6.0*btriss*(rij+rjk)**5)- &
18013 eij3**2/dtriss*(-2.0*atriss*(rik-rjk)+6.0*btriss*(rik+rjk)**5)
18018 gvdwx(m,j)=gvdwx(m,j)-gg(m)
18019 gvdwx(m,k)=gvdwx(m,k)+gg(m)
18022 gvdwc(l,j)=gvdwc(l,j)-gg(l)
18023 gvdwc(l,k)=gvdwc(l,k)+gg(l)
18026 end subroutine triple_ssbond_ene
18030 !-----------------------------------------------------------------------------
18031 real(kind=8) function h_base(x,deriv)
18032 ! A smooth function going 0->1 in range [0,1]
18033 ! It should NOT be called outside range [0,1], it will not work there.
18040 real(kind=8) :: deriv
18043 real(kind=8) :: xsq
18046 ! Two parabolas put together. First derivative zero at extrema
18047 !$$$ if (x.lt.0.5D0) then
18048 !$$$ h_base=2.0D0*x*x
18052 !$$$ h_base=1.0D0-2.0D0*deriv*deriv
18053 !$$$ deriv=4.0D0*deriv
18056 ! Third degree polynomial. First derivative zero at extrema
18057 h_base=x*x*(3.0d0-2.0d0*x)
18058 deriv=6.0d0*x*(1.0d0-x)
18060 ! Fifth degree polynomial. First and second derivatives zero at extrema
18062 !$$$ h_base=x*xsq*(6.0d0*xsq-15.0d0*x+10.0d0)
18064 !$$$ deriv=deriv*deriv
18065 !$$$ deriv=30.0d0*xsq*deriv
18068 end function h_base
18069 !-----------------------------------------------------------------------------
18070 subroutine dyn_set_nss
18071 ! Adjust nss and other relevant variables based on dyn_ssbond_ij
18073 use MD_data, only: totT,t_bath
18075 ! include 'DIMENSIONS'
18079 ! include 'COMMON.SBRIDGE'
18080 ! include 'COMMON.CHAIN'
18081 ! include 'COMMON.IOUNITS'
18082 ! include 'COMMON.SETUP'
18083 ! include 'COMMON.MD'
18085 real(kind=8) :: emin
18086 integer :: i,j,imin,ierr
18087 integer :: diff,allnss,newnss
18088 integer,dimension(maxdim) :: allflag,allihpb,alljhpb,& !(maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
18091 integer,dimension(0:nfgtasks) :: i_newnss
18092 integer,dimension(0:nfgtasks) :: displ
18093 integer,dimension(maxdim) :: g_newihpb,g_newjhpb !(maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
18094 integer :: g_newnss
18099 if (dyn_ssbond_ij(i,j).lt.1.0d300) then
18108 !mc write(iout,*)"ALLNSS ",allnss,(allihpb(i),alljhpb(i),i=1,allnss)
18112 if (allflag(i).eq.0 .and. &
18113 dyn_ssbond_ij(allihpb(i),alljhpb(i)).lt.emin) then
18114 emin=dyn_ssbond_ij(allihpb(i),alljhpb(i))
18118 if (emin.lt.1.0d300) then
18121 if (allflag(i).eq.0 .and. &
18122 (allihpb(i).eq.allihpb(imin) .or. &
18123 alljhpb(i).eq.allihpb(imin) .or. &
18124 allihpb(i).eq.alljhpb(imin) .or. &
18125 alljhpb(i).eq.alljhpb(imin))) then
18132 !mc write(iout,*)"ALLNSS ",allnss,(allihpb(i),alljhpb(i),i=1,allnss)
18136 if (allflag(i).eq.1) then
18138 newihpb(newnss)=allihpb(i)
18139 newjhpb(newnss)=alljhpb(i)
18144 if (nfgtasks.gt.1)then
18146 call MPI_Reduce(newnss,g_newnss,1,&
18147 MPI_INTEGER,MPI_SUM,king,FG_COMM,IERR)
18148 call MPI_Gather(newnss,1,MPI_INTEGER,&
18149 i_newnss,1,MPI_INTEGER,king,FG_COMM,IERR)
18151 do i=1,nfgtasks-1,1
18152 displ(i)=i_newnss(i-1)+displ(i-1)
18154 call MPI_Gatherv(newihpb,newnss,MPI_INTEGER,&
18155 g_newihpb,i_newnss,displ,MPI_INTEGER,&
18157 call MPI_Gatherv(newjhpb,newnss,MPI_INTEGER,&
18158 g_newjhpb,i_newnss,displ,MPI_INTEGER,&
18160 if(fg_rank.eq.0) then
18161 ! print *,'g_newnss',g_newnss
18162 ! print *,'g_newihpb',(g_newihpb(i),i=1,g_newnss)
18163 ! print *,'g_newjhpb',(g_newjhpb(i),i=1,g_newnss)
18166 newihpb(i)=g_newihpb(i)
18167 newjhpb(i)=g_newjhpb(i)
18175 !mc write(iout,*)"NEWNSS ",newnss,(newihpb(i),newjhpb(i),i=1,newnss)
18176 ! print *,newnss,nss,maxdim
18182 if (idssb(i).eq.newihpb(j) .and. &
18183 jdssb(i).eq.newjhpb(j)) found=.true.
18187 ! write(iout,*) "found",found,i,j
18188 if (.not.found.and.fg_rank.eq.0) &
18189 write(iout,'(a15,f12.2,f8.1,2i5)') &
18190 "SSBOND_BREAK",totT,t_bath,idssb(i),jdssb(i)
18199 if (newihpb(i).eq.idssb(j) .and. &
18200 newjhpb(i).eq.jdssb(j)) found=.true.
18204 ! write(iout,*) "found",found,i,j
18205 if (.not.found.and.fg_rank.eq.0) &
18206 write(iout,'(a15,f12.2,f8.1,2i5)') &
18207 "SSBOND_FORM",totT,t_bath,newihpb(i),newjhpb(i)
18214 idssb(i)=newihpb(i)
18215 jdssb(i)=newjhpb(i)
18219 end subroutine dyn_set_nss
18220 ! Lipid transfer energy function
18221 subroutine Eliptransfer(eliptran)
18222 !C this is done by Adasko
18223 !C print *,"wchodze"
18224 !C structure of box:
18226 !C--bordliptop-- buffore starts
18227 !C--bufliptop--- here true lipid starts
18229 !C--buflipbot--- lipid ends buffore starts
18230 !C--bordlipbot--buffore ends
18231 real(kind=8) :: fracinbuf,eliptran,sslip,positi,ssgradlip
18234 ! print *, "I am in eliptran"
18235 do i=ilip_start,ilip_end
18237 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1).or.(i.eq.nres))&
18240 positi=(mod(((c(3,i)+c(3,i+1))/2.0d0),boxzsize))
18241 if (positi.le.0.0) positi=positi+boxzsize
18243 !C first for peptide groups
18244 !c for each residue check if it is in lipid or lipid water border area
18245 if ((positi.gt.bordlipbot) &
18246 .and.(positi.lt.bordliptop)) then
18247 !C the energy transfer exist
18248 if (positi.lt.buflipbot) then
18249 !C what fraction I am in
18251 ((positi-bordlipbot)/lipbufthick)
18252 !C lipbufthick is thickenes of lipid buffore
18253 sslip=sscalelip(fracinbuf)
18254 ssgradlip=-sscagradlip(fracinbuf)/lipbufthick
18255 eliptran=eliptran+sslip*pepliptran
18256 gliptranc(3,i)=gliptranc(3,i)+ssgradlip*pepliptran/2.0d0
18257 gliptranc(3,i-1)=gliptranc(3,i-1)+ssgradlip*pepliptran/2.0d0
18258 !C gliptranc(3,i-2)=gliptranc(3,i)+ssgradlip*pepliptran
18260 !C print *,"doing sccale for lower part"
18261 !C print *,i,sslip,fracinbuf,ssgradlip
18262 elseif (positi.gt.bufliptop) then
18263 fracinbuf=1.0d0-((bordliptop-positi)/lipbufthick)
18264 sslip=sscalelip(fracinbuf)
18265 ssgradlip=sscagradlip(fracinbuf)/lipbufthick
18266 eliptran=eliptran+sslip*pepliptran
18267 gliptranc(3,i)=gliptranc(3,i)+ssgradlip*pepliptran/2.0d0
18268 gliptranc(3,i-1)=gliptranc(3,i-1)+ssgradlip*pepliptran/2.0d0
18269 !C gliptranc(3,i-2)=gliptranc(3,i)+ssgradlip*pepliptran
18270 !C print *, "doing sscalefor top part"
18271 !C print *,i,sslip,fracinbuf,ssgradlip
18273 eliptran=eliptran+pepliptran
18274 !C print *,"I am in true lipid"
18277 !C eliptran=elpitran+0.0 ! I am in water
18279 if (energy_dec) write(iout,*) i,"eliptran=",eliptran,positi,sslip
18281 ! here starts the side chain transfer
18282 do i=ilip_start,ilip_end
18283 if (itype(i,1).eq.ntyp1) cycle
18284 positi=(mod(c(3,i+nres),boxzsize))
18285 if (positi.le.0) positi=positi+boxzsize
18286 !C print *,mod(c(3,i+nres),boxzsize),bordlipbot,bordliptop
18287 !c for each residue check if it is in lipid or lipid water border area
18288 !C respos=mod(c(3,i+nres),boxzsize)
18289 !C print *,positi,bordlipbot,buflipbot
18290 if ((positi.gt.bordlipbot) &
18291 .and.(positi.lt.bordliptop)) then
18292 !C the energy transfer exist
18293 if (positi.lt.buflipbot) then
18295 ((positi-bordlipbot)/lipbufthick)
18296 !C lipbufthick is thickenes of lipid buffore
18297 sslip=sscalelip(fracinbuf)
18298 ssgradlip=-sscagradlip(fracinbuf)/lipbufthick
18299 eliptran=eliptran+sslip*liptranene(itype(i,1))
18300 gliptranx(3,i)=gliptranx(3,i) &
18301 +ssgradlip*liptranene(itype(i,1))
18302 gliptranc(3,i-1)= gliptranc(3,i-1) &
18303 +ssgradlip*liptranene(itype(i,1))
18304 !C print *,"doing sccale for lower part"
18305 elseif (positi.gt.bufliptop) then
18307 ((bordliptop-positi)/lipbufthick)
18308 sslip=sscalelip(fracinbuf)
18309 ssgradlip=sscagradlip(fracinbuf)/lipbufthick
18310 eliptran=eliptran+sslip*liptranene(itype(i,1))
18311 gliptranx(3,i)=gliptranx(3,i) &
18312 +ssgradlip*liptranene(itype(i,1))
18313 gliptranc(3,i-1)= gliptranc(3,i-1) &
18314 +ssgradlip*liptranene(itype(i,1))
18315 !C print *, "doing sscalefor top part",sslip,fracinbuf
18317 eliptran=eliptran+liptranene(itype(i,1))
18318 !C print *,"I am in true lipid"
18320 endif ! if in lipid or buffor
18322 !C eliptran=elpitran+0.0 ! I am in water
18323 if (energy_dec) write(iout,*) i,"eliptran=",eliptran
18326 end subroutine Eliptransfer
18327 !----------------------------------NANO FUNCTIONS
18328 !C-----------------------------------------------------------------------
18329 !C-----------------------------------------------------------
18330 !C This subroutine is to mimic the histone like structure but as well can be
18331 !C utilizet to nanostructures (infinit) small modification has to be used to
18332 !C make it finite (z gradient at the ends has to be changes as well as the x,y
18333 !C gradient has to be modified at the ends
18334 !C The energy function is Kihara potential
18335 !C E=4esp*((sigma/(r-r0))^12 - (sigma/(r-r0))^6)
18336 !C 4eps is depth of well sigma is r_minimum r is distance from center of tube
18337 !C and r0 is the excluded size of nanotube (can be set to 0 if we want just a
18338 !C simple Kihara potential
18339 subroutine calctube(Etube)
18340 real(kind=8),dimension(3) :: vectube
18341 real(kind=8) :: Etube,xtemp,xminact,yminact,&
18342 ytemp,xmin,ymin,tub_r,rdiff,rdiff6,fac,positi, &
18343 sc_aa_tube,sc_bb_tube
18346 do i=itube_start,itube_end
18348 enetube(i+nres)=0.0d0
18350 !C first we calculate the distance from tube center
18352 do i=itube_start,itube_end
18353 !C lets ommit dummy atoms for now
18354 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1)) cycle
18355 !C now calculate distance from center of tube and direction vectors
18358 ! Find minimum distance in periodic box
18360 vectube(1)=mod((c(1,i)+c(1,i+1))/2.0d0,boxxsize)
18361 vectube(1)=vectube(1)+boxxsize*j
18362 vectube(2)=mod((c(2,i)+c(2,i+1))/2.0d0,boxysize)
18363 vectube(2)=vectube(2)+boxysize*j
18364 xminact=abs(vectube(1)-tubecenter(1))
18365 yminact=abs(vectube(2)-tubecenter(2))
18366 if (xmin.gt.xminact) then
18370 if (ymin.gt.yminact) then
18377 vectube(1)=vectube(1)-tubecenter(1)
18378 vectube(2)=vectube(2)-tubecenter(2)
18380 !C print *,"x",(c(1,i)+c(1,i+1))/2.0d0,tubecenter(1)
18381 !C print *,"y",(c(2,i)+c(2,i+1))/2.0d0,tubecenter(2)
18383 !C as the tube is infinity we do not calculate the Z-vector use of Z
18386 !C now calculte the distance
18387 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
18388 !C now normalize vector
18389 vectube(1)=vectube(1)/tub_r
18390 vectube(2)=vectube(2)/tub_r
18391 !C calculte rdiffrence between r and r0
18394 rdiff6=rdiff**6.0d0
18395 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
18396 enetube(i)=pep_aa_tube/rdiff6**2.0d0+pep_bb_tube/rdiff6
18397 !C write(iout,*) "TU13",i,rdiff6,enetube(i)
18398 !C print *,rdiff,rdiff6,pep_aa_tube
18399 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
18400 !C now we calculate gradient
18401 fac=(-12.0d0*pep_aa_tube/rdiff6- &
18402 6.0d0*pep_bb_tube)/rdiff6/rdiff
18403 !C write(iout,'(a5,i4,f12.1,3f12.5)') "TU13",i,rdiff6,enetube(i),
18405 !C now direction of gg_tube vector
18407 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac/2.0d0
18408 gg_tube(j,i)=gg_tube(j,i)+vectube(j)*fac/2.0d0
18411 !C basically thats all code now we split for side-chains (REMEMBER to sum up at the END)
18412 !C print *,gg_tube(1,0),"TU"
18415 do i=itube_start,itube_end
18416 !C Lets not jump over memory as we use many times iti
18418 !C lets ommit dummy atoms for now
18419 if ((iti.eq.ntyp1) &
18420 !C in UNRES uncomment the line below as GLY has no side-chain...
18426 vectube(1)=mod((c(1,i+nres)),boxxsize)
18427 vectube(1)=vectube(1)+boxxsize*j
18428 vectube(2)=mod((c(2,i+nres)),boxysize)
18429 vectube(2)=vectube(2)+boxysize*j
18431 xminact=abs(vectube(1)-tubecenter(1))
18432 yminact=abs(vectube(2)-tubecenter(2))
18433 if (xmin.gt.xminact) then
18437 if (ymin.gt.yminact) then
18444 !C write(iout,*), "tututu", vectube(1),tubecenter(1),vectube(2),
18446 vectube(1)=vectube(1)-tubecenter(1)
18447 vectube(2)=vectube(2)-tubecenter(2)
18449 !C as the tube is infinity we do not calculate the Z-vector use of Z
18452 !C now calculte the distance
18453 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
18454 !C now normalize vector
18455 vectube(1)=vectube(1)/tub_r
18456 vectube(2)=vectube(2)/tub_r
18458 !C calculte rdiffrence between r and r0
18461 rdiff6=rdiff**6.0d0
18462 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
18463 sc_aa_tube=sc_aa_tube_par(iti)
18464 sc_bb_tube=sc_bb_tube_par(iti)
18465 enetube(i+nres)=sc_aa_tube/rdiff6**2.0d0+sc_bb_tube/rdiff6
18466 fac=-12.0d0*sc_aa_tube/rdiff6**2.0d0/rdiff- &
18467 6.0d0*sc_bb_tube/rdiff6/rdiff
18468 !C now direction of gg_tube vector
18470 gg_tube_SC(j,i)=gg_tube_SC(j,i)+vectube(j)*fac
18471 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac
18474 do i=itube_start,itube_end
18475 Etube=Etube+enetube(i)+enetube(i+nres)
18477 !C print *,"ETUBE", etube
18479 end subroutine calctube
18480 !C TO DO 1) add to total energy
18481 !C 2) add to gradient summation
18482 !C 3) add reading parameters (AND of course oppening of PARAM file)
18483 !C 4) add reading the center of tube
18485 !C 6) add to zerograd
18486 !C 7) allocate matrices
18489 !C-----------------------------------------------------------------------
18490 !C-----------------------------------------------------------
18491 !C This subroutine is to mimic the histone like structure but as well can be
18492 !C utilizet to nanostructures (infinit) small modification has to be used to
18493 !C make it finite (z gradient at the ends has to be changes as well as the x,y
18494 !C gradient has to be modified at the ends
18495 !C The energy function is Kihara potential
18496 !C E=4esp*((sigma/(r-r0))^12 - (sigma/(r-r0))^6)
18497 !C 4eps is depth of well sigma is r_minimum r is distance from center of tube
18498 !C and r0 is the excluded size of nanotube (can be set to 0 if we want just a
18499 !C simple Kihara potential
18500 subroutine calctube2(Etube)
18501 real(kind=8),dimension(3) :: vectube
18502 real(kind=8) :: Etube,xtemp,xminact,yminact,&
18503 ytemp,xmin,ymin,tub_r,rdiff,rdiff6,fac,positi,fracinbuf,&
18504 sstube,ssgradtube,sc_aa_tube,sc_bb_tube
18507 do i=itube_start,itube_end
18509 enetube(i+nres)=0.0d0
18511 !C first we calculate the distance from tube center
18512 !C first sugare-phosphate group for NARES this would be peptide group
18514 do i=itube_start,itube_end
18515 !C lets ommit dummy atoms for now
18517 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1)) cycle
18518 !C now calculate distance from center of tube and direction vectors
18519 !C vectube(1)=mod((c(1,i)+c(1,i+1))/2.0d0,boxxsize)
18520 !C if (vectube(1).lt.0) vectube(1)=vectube(1)+boxxsize
18521 !C vectube(2)=mod((c(2,i)+c(2,i+1))/2.0d0,boxysize)
18522 !C if (vectube(2).lt.0) vectube(2)=vectube(2)+boxysize
18526 vectube(1)=mod((c(1,i)+c(1,i+1))/2.0d0,boxxsize)
18527 vectube(1)=vectube(1)+boxxsize*j
18528 vectube(2)=mod((c(2,i)+c(2,i+1))/2.0d0,boxysize)
18529 vectube(2)=vectube(2)+boxysize*j
18531 xminact=abs(vectube(1)-tubecenter(1))
18532 yminact=abs(vectube(2)-tubecenter(2))
18533 if (xmin.gt.xminact) then
18537 if (ymin.gt.yminact) then
18544 vectube(1)=vectube(1)-tubecenter(1)
18545 vectube(2)=vectube(2)-tubecenter(2)
18547 !C print *,"x",(c(1,i)+c(1,i+1))/2.0d0,tubecenter(1)
18548 !C print *,"y",(c(2,i)+c(2,i+1))/2.0d0,tubecenter(2)
18550 !C as the tube is infinity we do not calculate the Z-vector use of Z
18553 !C now calculte the distance
18554 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
18555 !C now normalize vector
18556 vectube(1)=vectube(1)/tub_r
18557 vectube(2)=vectube(2)/tub_r
18558 !C calculte rdiffrence between r and r0
18561 rdiff6=rdiff**6.0d0
18562 !C THIS FRAGMENT MAKES TUBE FINITE
18563 positi=mod((c(3,i)+c(3,i+1))/2.0d0,boxzsize)
18564 if (positi.le.0) positi=positi+boxzsize
18565 !C print *,mod(c(3,i+nres),boxzsize),bordlipbot,bordliptop
18566 !c for each residue check if it is in lipid or lipid water border area
18567 !C respos=mod(c(3,i+nres),boxzsize)
18568 !C print *,positi,bordtubebot,buftubebot,bordtubetop
18569 if ((positi.gt.bordtubebot) &
18570 .and.(positi.lt.bordtubetop)) then
18571 !C the energy transfer exist
18572 if (positi.lt.buftubebot) then
18574 ((positi-bordtubebot)/tubebufthick)
18575 !C lipbufthick is thickenes of lipid buffore
18576 sstube=sscalelip(fracinbuf)
18577 ssgradtube=-sscagradlip(fracinbuf)/tubebufthick
18578 !C print *,ssgradtube, sstube,tubetranene(itype(i,1))
18579 enetube(i)=enetube(i)+sstube*tubetranenepep
18580 !C gg_tube_SC(3,i)=gg_tube_SC(3,i)
18581 !C &+ssgradtube*tubetranene(itype(i,1))
18582 !C gg_tube(3,i-1)= gg_tube(3,i-1)
18583 !C &+ssgradtube*tubetranene(itype(i,1))
18584 !C print *,"doing sccale for lower part"
18585 elseif (positi.gt.buftubetop) then
18587 ((bordtubetop-positi)/tubebufthick)
18588 sstube=sscalelip(fracinbuf)
18589 ssgradtube=sscagradlip(fracinbuf)/tubebufthick
18590 enetube(i)=enetube(i)+sstube*tubetranenepep
18591 !C gg_tube_SC(3,i)=gg_tube_SC(3,i)
18592 !C &+ssgradtube*tubetranene(itype(i,1))
18593 !C gg_tube(3,i-1)= gg_tube(3,i-1)
18594 !C &+ssgradtube*tubetranene(itype(i,1))
18595 !C print *, "doing sscalefor top part",sslip,fracinbuf
18599 enetube(i)=enetube(i)+sstube*tubetranenepep
18600 !C print *,"I am in true lipid"
18604 !C ssgradtube=0.0d0
18606 endif ! if in lipid or buffor
18608 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
18609 enetube(i)=enetube(i)+sstube* &
18610 (pep_aa_tube/rdiff6**2.0d0+pep_bb_tube/rdiff6)
18611 !C write(iout,*) "TU13",i,rdiff6,enetube(i)
18612 !C print *,rdiff,rdiff6,pep_aa_tube
18613 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
18614 !C now we calculate gradient
18615 fac=(-12.0d0*pep_aa_tube/rdiff6- &
18616 6.0d0*pep_bb_tube)/rdiff6/rdiff*sstube
18617 !C write(iout,'(a5,i4,f12.1,3f12.5)') "TU13",i,rdiff6,enetube(i),
18620 !C now direction of gg_tube vector
18622 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac/2.0d0
18623 gg_tube(j,i)=gg_tube(j,i)+vectube(j)*fac/2.0d0
18625 gg_tube(3,i)=gg_tube(3,i) &
18626 +ssgradtube*enetube(i)/sstube/2.0d0
18627 gg_tube(3,i-1)= gg_tube(3,i-1) &
18628 +ssgradtube*enetube(i)/sstube/2.0d0
18631 !C basically thats all code now we split for side-chains (REMEMBER to sum up at the END)
18632 !C print *,gg_tube(1,0),"TU"
18633 do i=itube_start,itube_end
18634 !C Lets not jump over memory as we use many times iti
18636 !C lets ommit dummy atoms for now
18637 if ((iti.eq.ntyp1) &
18638 !!C in UNRES uncomment the line below as GLY has no side-chain...
18641 vectube(1)=c(1,i+nres)
18642 vectube(1)=mod(vectube(1),boxxsize)
18643 if (vectube(1).lt.0) vectube(1)=vectube(1)+boxxsize
18644 vectube(2)=c(2,i+nres)
18645 vectube(2)=mod(vectube(2),boxysize)
18646 if (vectube(2).lt.0) vectube(2)=vectube(2)+boxysize
18648 vectube(1)=vectube(1)-tubecenter(1)
18649 vectube(2)=vectube(2)-tubecenter(2)
18650 !C THIS FRAGMENT MAKES TUBE FINITE
18651 positi=(mod(c(3,i+nres),boxzsize))
18652 if (positi.le.0) positi=positi+boxzsize
18653 !C print *,mod(c(3,i+nres),boxzsize),bordlipbot,bordliptop
18654 !c for each residue check if it is in lipid or lipid water border area
18655 !C respos=mod(c(3,i+nres),boxzsize)
18656 !C print *,positi,bordtubebot,buftubebot,bordtubetop
18658 if ((positi.gt.bordtubebot) &
18659 .and.(positi.lt.bordtubetop)) then
18660 !C the energy transfer exist
18661 if (positi.lt.buftubebot) then
18663 ((positi-bordtubebot)/tubebufthick)
18664 !C lipbufthick is thickenes of lipid buffore
18665 sstube=sscalelip(fracinbuf)
18666 ssgradtube=-sscagradlip(fracinbuf)/tubebufthick
18667 !C print *,ssgradtube, sstube,tubetranene(itype(i,1))
18668 enetube(i+nres)=enetube(i+nres)+sstube*tubetranene(itype(i,1))
18669 !C gg_tube_SC(3,i)=gg_tube_SC(3,i)
18670 !C &+ssgradtube*tubetranene(itype(i,1))
18671 !C gg_tube(3,i-1)= gg_tube(3,i-1)
18672 !C &+ssgradtube*tubetranene(itype(i,1))
18673 !C print *,"doing sccale for lower part"
18674 elseif (positi.gt.buftubetop) then
18676 ((bordtubetop-positi)/tubebufthick)
18678 sstube=sscalelip(fracinbuf)
18679 ssgradtube=sscagradlip(fracinbuf)/tubebufthick
18680 enetube(i+nres)=enetube(i+nres)+sstube*tubetranene(itype(i,1))
18681 !C gg_tube_SC(3,i)=gg_tube_SC(3,i)
18682 !C &+ssgradtube*tubetranene(itype(i,1))
18683 !C gg_tube(3,i-1)= gg_tube(3,i-1)
18684 !C &+ssgradtube*tubetranene(itype(i,1))
18685 !C print *, "doing sscalefor top part",sslip,fracinbuf
18689 enetube(i+nres)=enetube(i+nres)+sstube*tubetranene(itype(i,1))
18690 !C print *,"I am in true lipid"
18694 !C ssgradtube=0.0d0
18696 endif ! if in lipid or buffor
18697 !CEND OF FINITE FRAGMENT
18698 !C as the tube is infinity we do not calculate the Z-vector use of Z
18701 !C now calculte the distance
18702 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
18703 !C now normalize vector
18704 vectube(1)=vectube(1)/tub_r
18705 vectube(2)=vectube(2)/tub_r
18706 !C calculte rdiffrence between r and r0
18709 rdiff6=rdiff**6.0d0
18710 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
18711 sc_aa_tube=sc_aa_tube_par(iti)
18712 sc_bb_tube=sc_bb_tube_par(iti)
18713 enetube(i+nres)=(sc_aa_tube/rdiff6**2.0d0+sc_bb_tube/rdiff6)&
18714 *sstube+enetube(i+nres)
18715 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
18716 !C now we calculate gradient
18717 fac=(-12.0d0*sc_aa_tube/rdiff6**2.0d0/rdiff-&
18718 6.0d0*sc_bb_tube/rdiff6/rdiff)*sstube
18719 !C now direction of gg_tube vector
18721 gg_tube_SC(j,i)=gg_tube_SC(j,i)+vectube(j)*fac
18722 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac
18724 gg_tube_SC(3,i)=gg_tube_SC(3,i) &
18725 +ssgradtube*enetube(i+nres)/sstube
18726 gg_tube(3,i-1)= gg_tube(3,i-1) &
18727 +ssgradtube*enetube(i+nres)/sstube
18730 do i=itube_start,itube_end
18731 Etube=Etube+enetube(i)+enetube(i+nres)
18733 !C print *,"ETUBE", etube
18735 end subroutine calctube2
18736 !=====================================================================================================================================
18737 subroutine calcnano(Etube)
18738 real(kind=8),dimension(3) :: vectube
18740 real(kind=8) :: Etube,xtemp,xminact,yminact,&
18741 ytemp,xmin,ymin,tub_r,rdiff,rdiff6,fac,denominator,faccav,&
18742 sc_aa_tube,sc_bb_tube,zmin,ztemp,zminact
18746 ! print *,itube_start,itube_end,"poczatek"
18747 do i=itube_start,itube_end
18749 enetube(i+nres)=0.0d0
18751 !C first we calculate the distance from tube center
18752 !C first sugare-phosphate group for NARES this would be peptide group
18754 do i=itube_start,itube_end
18755 !C lets ommit dummy atoms for now
18756 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1)) cycle
18757 !C now calculate distance from center of tube and direction vectors
18763 vectube(1)=dmod((c(1,i)+c(1,i+1))/2.0d0,boxxsize)
18764 vectube(1)=vectube(1)+boxxsize*j
18765 vectube(2)=dmod((c(2,i)+c(2,i+1))/2.0d0,boxysize)
18766 vectube(2)=vectube(2)+boxysize*j
18767 vectube(3)=dmod((c(3,i)+c(3,i+1))/2.0d0,boxzsize)
18768 vectube(3)=vectube(3)+boxzsize*j
18771 xminact=dabs(vectube(1)-tubecenter(1))
18772 yminact=dabs(vectube(2)-tubecenter(2))
18773 zminact=dabs(vectube(3)-tubecenter(3))
18775 if (xmin.gt.xminact) then
18779 if (ymin.gt.yminact) then
18783 if (zmin.gt.zminact) then
18792 vectube(1)=vectube(1)-tubecenter(1)
18793 vectube(2)=vectube(2)-tubecenter(2)
18794 vectube(3)=vectube(3)-tubecenter(3)
18796 !C print *,"x",(c(1,i)+c(1,i+1))/2.0d0,tubecenter(1)
18797 !C print *,"y",(c(2,i)+c(2,i+1))/2.0d0,tubecenter(2)
18798 !C as the tube is infinity we do not calculate the Z-vector use of Z
18800 !C vectube(3)=0.0d0
18801 !C now calculte the distance
18802 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
18803 !C now normalize vector
18804 vectube(1)=vectube(1)/tub_r
18805 vectube(2)=vectube(2)/tub_r
18806 vectube(3)=vectube(3)/tub_r
18807 !C calculte rdiffrence between r and r0
18810 rdiff6=rdiff**6.0d0
18811 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
18812 enetube(i)=pep_aa_tube/rdiff6**2.0d0+pep_bb_tube/rdiff6
18813 !C write(iout,*) "TU13",i,rdiff6,enetube(i)
18814 !C print *,rdiff,rdiff6,pep_aa_tube
18815 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
18816 !C now we calculate gradient
18817 fac=(-12.0d0*pep_aa_tube/rdiff6- &
18818 6.0d0*pep_bb_tube)/rdiff6/rdiff
18819 !C write(iout,'(a5,i4,f12.1,3f12.5)') "TU13",i,rdiff6,enetube(i),
18821 if (acavtubpep.eq.0.0d0) then
18826 denominator=(1.0d0+dcavtubpep*rdiff6*rdiff6)
18828 (bcavtubpep*rdiff+acavtubpep*dsqrt(rdiff)+ccavtubpep) &
18831 faccav=((bcavtubpep*1.0d0+acavtubpep/2.0d0/dsqrt(rdiff)) &
18832 *denominator-(bcavtubpep*rdiff+acavtubpep*dsqrt(rdiff) &
18833 +ccavtubpep)*rdiff6**2.0d0/rdiff*dcavtubpep*12.0d0) &
18834 /denominator**2.0d0
18839 if (energy_dec) write(iout,*),i,rdiff,enetube(i),enecavtube(i)
18841 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac/2.0d0
18842 gg_tube(j,i)=gg_tube(j,i)+vectube(j)*fac/2.0d0
18846 do i=itube_start,itube_end
18847 enecavtube(i)=0.0d0
18848 !C Lets not jump over memory as we use many times iti
18850 !C lets ommit dummy atoms for now
18851 if ((iti.eq.ntyp1) &
18852 !C in UNRES uncomment the line below as GLY has no side-chain...
18859 vectube(1)=dmod((c(1,i+nres)),boxxsize)
18860 vectube(1)=vectube(1)+boxxsize*j
18861 vectube(2)=dmod((c(2,i+nres)),boxysize)
18862 vectube(2)=vectube(2)+boxysize*j
18863 vectube(3)=dmod((c(3,i+nres)),boxzsize)
18864 vectube(3)=vectube(3)+boxzsize*j
18867 xminact=dabs(vectube(1)-tubecenter(1))
18868 yminact=dabs(vectube(2)-tubecenter(2))
18869 zminact=dabs(vectube(3)-tubecenter(3))
18871 if (xmin.gt.xminact) then
18875 if (ymin.gt.yminact) then
18879 if (zmin.gt.zminact) then
18888 !C write(iout,*), "tututu", vectube(1),tubecenter(1),vectube(2),
18890 vectube(1)=vectube(1)-tubecenter(1)
18891 vectube(2)=vectube(2)-tubecenter(2)
18892 vectube(3)=vectube(3)-tubecenter(3)
18893 !C now calculte the distance
18894 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
18895 !C now normalize vector
18896 vectube(1)=vectube(1)/tub_r
18897 vectube(2)=vectube(2)/tub_r
18898 vectube(3)=vectube(3)/tub_r
18900 !C calculte rdiffrence between r and r0
18903 rdiff6=rdiff**6.0d0
18904 sc_aa_tube=sc_aa_tube_par(iti)
18905 sc_bb_tube=sc_bb_tube_par(iti)
18906 enetube(i+nres)=sc_aa_tube/rdiff6**2.0d0+sc_bb_tube/rdiff6
18907 !C enetube(i+nres)=0.0d0
18908 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
18909 !C now we calculate gradient
18910 fac=-12.0d0*sc_aa_tube/rdiff6**2.0d0/rdiff- &
18911 6.0d0*sc_bb_tube/rdiff6/rdiff
18913 !C now direction of gg_tube vector
18914 !C Now cavity term E=a(x+bsqrt(x)+c)/(1+dx^12)
18915 if (acavtub(iti).eq.0.0d0) then
18917 enecavtube(i+nres)=0.0d0
18920 denominator=(1.0d0+dcavtub(iti)*rdiff6*rdiff6)
18921 enecavtube(i+nres)= &
18922 (bcavtub(iti)*rdiff+acavtub(iti)*dsqrt(rdiff)+ccavtub(iti)) &
18924 !C enecavtube(i)=0.0
18925 faccav=((bcavtub(iti)*1.0d0+acavtub(iti)/2.0d0/dsqrt(rdiff)) &
18926 *denominator-(bcavtub(iti)*rdiff+acavtub(iti)*dsqrt(rdiff) &
18927 +ccavtub(iti))*rdiff6**2.0d0/rdiff*dcavtub(iti)*12.0d0) &
18928 /denominator**2.0d0
18933 !C print *,"TUT",i,iti,rdiff,rdiff6,acavtub(iti),denominator,
18934 !C & enecavtube(i),faccav
18935 !C print *,"licz=",
18936 !C & (bcavtub(iti)*rdiff+acavtub(iti)*sqrt(rdiff)+ccavtub(iti))
18937 !C print *,"finene=",enetube(i+nres)+enecavtube(i)
18939 gg_tube_SC(j,i)=gg_tube_SC(j,i)+vectube(j)*fac
18940 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac
18942 if (energy_dec) write(iout,*),i,rdiff,enetube(i+nres),enecavtube(i+nres)
18947 do i=itube_start,itube_end
18948 Etube=Etube+enetube(i)+enetube(i+nres)+enecavtube(i) &
18949 +enecavtube(i+nres)
18951 !C print *,"ETUBE", etube
18953 end subroutine calcnano
18955 !===============================================
18956 !--------------------------------------------------------------------------------
18957 !C first for shielding is setting of function of side-chains
18959 subroutine set_shield_fac2
18960 real(kind=8) :: div77_81=0.974996043d0, &
18961 div4_81=0.2222222222d0
18962 real (kind=8) :: dist_pep_side,dist_side_calf,dist_pept_group, &
18963 scale_fac_dist,fac_help_scale,VofOverlap,VolumeTotal,costhet,&
18964 short,long,sinthet,costhet_fac,sh_frac_dist,rkprim,cosphi, &
18965 sinphi,cosphi_fac,pep_side0pept_group,cosalfa,fac_alfa_sin
18966 !C the vector between center of side_chain and peptide group
18967 real(kind=8),dimension(3) :: pep_side_long,side_calf, &
18968 pept_group,costhet_grad,cosphi_grad_long, &
18969 cosphi_grad_loc,pep_side_norm,side_calf_norm, &
18970 sh_frac_dist_grad,pep_side
18972 !C write(2,*) "ivec",ivec_start,ivec_end
18974 fac_shield(i)=0.0d0
18976 grad_shield(j,i)=0.0d0
18979 do i=ivec_start,ivec_end
18981 !C if ((itype(i,1).eq.ntyp1).and.itype(i+1,1).eq.ntyp1) cycle
18983 if ((itype(i,1).eq.ntyp1).and.itype(i+1,1).eq.ntyp1) cycle
18984 !Cif there two consequtive dummy atoms there is no peptide group between them
18985 !C the line below has to be changed for FGPROC>1
18988 if ((itype(k,1).eq.ntyp1).or.(itype(k,1).eq.10)) cycle
18992 !C first lets set vector conecting the ithe side-chain with kth side-chain
18993 pep_side(j)=c(j,k+nres)-(c(j,i)+c(j,i+1))/2.0d0
18994 !C pep_side(j)=2.0d0
18995 !C and vector conecting the side-chain with its proper calfa
18996 side_calf(j)=c(j,k+nres)-c(j,k)
18997 !C side_calf(j)=2.0d0
18998 pept_group(j)=c(j,i)-c(j,i+1)
18999 !C lets have their lenght
19000 dist_pep_side=pep_side(j)**2+dist_pep_side
19001 dist_side_calf=dist_side_calf+side_calf(j)**2
19002 dist_pept_group=dist_pept_group+pept_group(j)**2
19004 dist_pep_side=sqrt(dist_pep_side)
19005 dist_pept_group=sqrt(dist_pept_group)
19006 dist_side_calf=sqrt(dist_side_calf)
19008 pep_side_norm(j)=pep_side(j)/dist_pep_side
19009 side_calf_norm(j)=dist_side_calf
19011 !C now sscale fraction
19012 sh_frac_dist=-(dist_pep_side-rpp(1,1)-buff_shield)/buff_shield
19013 !C print *,buff_shield,"buff"
19015 if (sh_frac_dist.le.0.0) cycle
19016 !C print *,ishield_list(i),i
19017 !C If we reach here it means that this side chain reaches the shielding sphere
19018 !C Lets add him to the list for gradient
19019 ishield_list(i)=ishield_list(i)+1
19020 !C ishield_list is a list of non 0 side-chain that contribute to factor gradient
19021 !C this list is essential otherwise problem would be O3
19022 shield_list(ishield_list(i),i)=k
19023 !C Lets have the sscale value
19024 if (sh_frac_dist.gt.1.0) then
19025 scale_fac_dist=1.0d0
19027 sh_frac_dist_grad(j)=0.0d0
19030 scale_fac_dist=-sh_frac_dist*sh_frac_dist &
19031 *(2.0d0*sh_frac_dist-3.0d0)
19032 fac_help_scale=6.0d0*(sh_frac_dist-sh_frac_dist**2) &
19033 /dist_pep_side/buff_shield*0.5d0
19035 sh_frac_dist_grad(j)=fac_help_scale*pep_side(j)
19036 !C sh_frac_dist_grad(j)=0.0d0
19037 !C scale_fac_dist=1.0d0
19038 !C print *,"jestem",scale_fac_dist,fac_help_scale,
19039 !C & sh_frac_dist_grad(j)
19042 !C this is what is now we have the distance scaling now volume...
19043 short=short_r_sidechain(itype(k,1))
19044 long=long_r_sidechain(itype(k,1))
19045 costhet=1.0d0/dsqrt(1.0d0+short**2/dist_pep_side**2)
19046 sinthet=short/dist_pep_side*costhet
19047 !C now costhet_grad
19050 costhet_fac=costhet**3*short**2*(-0.5d0)/dist_pep_side**4
19051 !C sinthet_fac=costhet**2*0.5d0*(short**3/dist_pep_side**4*costhet
19052 !C & -short/dist_pep_side**2/costhet)
19053 !C costhet_fac=0.0d0
19055 costhet_grad(j)=costhet_fac*pep_side(j)
19057 !C remember for the final gradient multiply costhet_grad(j)
19058 !C for side_chain by factor -2 !
19059 !C fac alfa is angle between CB_k,CA_k, CA_i,CA_i+1
19060 !C pep_side0pept_group is vector multiplication
19061 pep_side0pept_group=0.0d0
19063 pep_side0pept_group=pep_side0pept_group+pep_side(j)*side_calf(j)
19065 cosalfa=(pep_side0pept_group/ &
19066 (dist_pep_side*dist_side_calf))
19067 fac_alfa_sin=1.0d0-cosalfa**2
19068 fac_alfa_sin=dsqrt(fac_alfa_sin)
19069 rkprim=fac_alfa_sin*(long-short)+short
19072 !C now costhet_grad
19073 cosphi=1.0d0/dsqrt(1.0d0+rkprim**2/dist_pep_side**2)
19075 cosphi_fac=cosphi**3*rkprim**2*(-0.5d0)/dist_pep_side**4
19076 sinphi=rkprim/dist_pep_side/dsqrt(1.0d0+rkprim**2/ &
19080 cosphi_grad_long(j)=cosphi_fac*pep_side(j) &
19081 +cosphi**3*0.5d0/dist_pep_side**2*(-rkprim) &
19082 *(long-short)/fac_alfa_sin*cosalfa/ &
19083 ((dist_pep_side*dist_side_calf))* &
19084 ((side_calf(j))-cosalfa* &
19085 ((pep_side(j)/dist_pep_side)*dist_side_calf))
19086 !C cosphi_grad_long(j)=0.0d0
19087 cosphi_grad_loc(j)=cosphi**3*0.5d0/dist_pep_side**2*(-rkprim) &
19088 *(long-short)/fac_alfa_sin*cosalfa &
19089 /((dist_pep_side*dist_side_calf))* &
19091 cosalfa*side_calf(j)/dist_side_calf*dist_pep_side)
19092 !C cosphi_grad_loc(j)=0.0d0
19094 !C print *,sinphi,sinthet
19095 VofOverlap=VSolvSphere/2.0d0*(1.0d0-dsqrt(1.0d0-sinphi*sinthet)) &
19098 !C now the gradient...
19100 grad_shield(j,i)=grad_shield(j,i) &
19101 !C gradient po skalowaniu
19102 +(sh_frac_dist_grad(j)*VofOverlap &
19103 !C gradient po costhet
19104 +scale_fac_dist*VSolvSphere/VSolvSphere_div/4.0d0* &
19105 (1.0d0/(-dsqrt(1.0d0-sinphi*sinthet))*( &
19106 sinphi/sinthet*costhet*costhet_grad(j) &
19107 +sinthet/sinphi*cosphi*cosphi_grad_long(j))) &
19109 !C grad_shield_side is Cbeta sidechain gradient
19110 grad_shield_side(j,ishield_list(i),i)=&
19111 (sh_frac_dist_grad(j)*-2.0d0&
19113 -scale_fac_dist*VSolvSphere/VSolvSphere_div/2.0d0*&
19114 (1.0d0/(-dsqrt(1.0d0-sinphi*sinthet))*(&
19115 sinphi/sinthet*costhet*costhet_grad(j)&
19116 +sinthet/sinphi*cosphi*cosphi_grad_long(j))) &
19119 grad_shield_loc(j,ishield_list(i),i)= &
19120 scale_fac_dist*VSolvSphere/VSolvSphere_div/2.0d0*&
19121 (1.0d0/(dsqrt(1.0d0-sinphi*sinthet))*(&
19122 sinthet/sinphi*cosphi*cosphi_grad_loc(j)&
19126 VolumeTotal=VolumeTotal+VofOverlap*scale_fac_dist
19128 fac_shield(i)=VolumeTotal*wshield+(1.0d0-wshield)
19130 !C write(2,*) "TOTAL VOLUME",i,itype(i,1),fac_shield(i)
19133 end subroutine set_shield_fac2
19134 !----------------------------------------------------------------------------
19135 ! SOUBROUTINE FOR AFM
19136 subroutine AFMvel(Eafmforce)
19137 use MD_data, only:totTafm
19138 real(kind=8),dimension(3) :: diffafm
19139 real(kind=8) :: afmdist,Eafmforce
19141 !C Only for check grad COMMENT if not used for checkgrad
19143 !C--------------------------------------------------------
19144 !C print *,"wchodze"
19148 diffafm(i)=c(i,afmend)-c(i,afmbeg)
19149 afmdist=afmdist+diffafm(i)**2
19151 afmdist=dsqrt(afmdist)
19153 Eafmforce=0.5d0*forceAFMconst &
19154 *(distafminit+totTafm*velAFMconst-afmdist)**2
19155 !C Eafmforce=-forceAFMconst*(dist-distafminit)
19157 gradafm(i,afmend-1)=-forceAFMconst* &
19158 (distafminit+totTafm*velAFMconst-afmdist) &
19159 *diffafm(i)/afmdist
19160 gradafm(i,afmbeg-1)=forceAFMconst* &
19161 (distafminit+totTafm*velAFMconst-afmdist) &
19162 *diffafm(i)/afmdist
19164 ! print *,'AFM',Eafmforce,totTafm*velAFMconst,afmdist
19166 end subroutine AFMvel
19167 !---------------------------------------------------------
19168 subroutine AFMforce(Eafmforce)
19170 real(kind=8),dimension(3) :: diffafm
19171 ! real(kind=8) ::afmdist
19172 real(kind=8) :: afmdist,Eafmforce
19177 diffafm(i)=c(i,afmend)-c(i,afmbeg)
19178 afmdist=afmdist+diffafm(i)**2
19180 afmdist=dsqrt(afmdist)
19181 ! print *,afmdist,distafminit
19182 Eafmforce=-forceAFMconst*(afmdist-distafminit)
19184 gradafm(i,afmend-1)=-forceAFMconst*diffafm(i)/afmdist
19185 gradafm(i,afmbeg-1)=forceAFMconst*diffafm(i)/afmdist
19187 !C print *,'AFM',Eafmforce
19189 end subroutine AFMforce
19191 !-----------------------------------------------------------------------------
19193 subroutine read_ssHist
19196 ! include 'DIMENSIONS'
19197 ! include "DIMENSIONS.FREE"
19198 ! include 'COMMON.FREE'
19201 character(len=80) :: controlcard
19204 call card_concat(controlcard,.true.)
19205 read(controlcard,*) &
19206 dyn_ssHist(i,0),(dyn_ssHist(i,j),j=1,2*dyn_ssHist(i,0))
19210 end subroutine read_ssHist
19212 !-----------------------------------------------------------------------------
19213 integer function indmat(i,j)
19215 ! get the position of the jth ijth fragment of the chain coordinate system
19216 ! in the fromto array.
19219 indmat=((2*(nres-2)-i)*(i-1))/2+j-1
19221 end function indmat
19222 !-----------------------------------------------------------------------------
19223 real(kind=8) function sigm(x)
19229 !-----------------------------------------------------------------------------
19230 !-----------------------------------------------------------------------------
19231 subroutine alloc_ener_arrays
19232 !EL Allocation of arrays used by module energy
19233 use MD_data, only: mset
19234 !el local variables
19237 if(nres.lt.100) then
19239 elseif(nres.lt.200) then
19240 maxconts=0.8*nres ! Max. number of contacts per residue
19242 maxconts=0.6*nres ! (maxconts=maxres/4)
19244 maxcont=12*nres ! Max. number of SC contacts
19245 maxvar=6*nres ! Max. number of variables
19246 !el maxdim=(nres-1)*(nres-2)/2 ! Max. number of derivatives of virtual-bond
19247 maxdim=nres*(nres-2)/2 ! Max. number of derivatives of virtual-bond
19248 !----------------------
19249 ! arrays in subroutine init_int_table
19251 !el allocate(itask_cont_from(0:nfgtasks-1)) !(0:max_fg_procs-1)
19252 !el allocate(itask_cont_to(0:nfgtasks-1)) !(0:max_fg_procs-1)
19254 allocate(nint_gr(nres))
19255 allocate(nscp_gr(nres))
19256 allocate(ielstart(nres))
19257 allocate(ielend(nres))
19259 allocate(istart(nres,maxint_gr))
19260 allocate(iend(nres,maxint_gr))
19261 !(maxres,maxint_gr)
19262 allocate(iscpstart(nres,maxint_gr))
19263 allocate(iscpend(nres,maxint_gr))
19264 !(maxres,maxint_gr)
19265 allocate(ielstart_vdw(nres))
19266 allocate(ielend_vdw(nres))
19269 allocate(lentyp(0:nfgtasks-1))
19271 !----------------------
19273 ! common /contacts/
19274 if(.not.allocated(icont_ref)) allocate(icont_ref(2,maxcont))
19275 allocate(icont(2,maxcont))
19277 ! common /contacts1/
19278 allocate(num_cont(0:nres+4))
19280 allocate(jcont(maxconts,nres))
19282 allocate(facont(maxconts,nres))
19284 allocate(gacont(3,maxconts,nres))
19285 !(3,maxconts,maxres)
19286 ! common /contacts_hb/
19287 allocate(gacontp_hb1(3,maxconts,nres))
19288 allocate(gacontp_hb2(3,maxconts,nres))
19289 allocate(gacontp_hb3(3,maxconts,nres))
19290 allocate(gacontm_hb1(3,maxconts,nres))
19291 allocate(gacontm_hb2(3,maxconts,nres))
19292 allocate(gacontm_hb3(3,maxconts,nres))
19293 allocate(gacont_hbr(3,maxconts,nres))
19294 allocate(grij_hb_cont(3,maxconts,nres))
19295 !(3,maxconts,maxres)
19296 allocate(facont_hb(maxconts,nres))
19298 allocate(ees0p(maxconts,nres))
19299 allocate(ees0m(maxconts,nres))
19300 allocate(d_cont(maxconts,nres))
19301 allocate(ees0plist(maxconts,nres))
19304 allocate(num_cont_hb(nres))
19306 allocate(jcont_hb(maxconts,nres))
19309 allocate(Ug(2,2,nres))
19310 allocate(Ugder(2,2,nres))
19311 allocate(Ug2(2,2,nres))
19312 allocate(Ug2der(2,2,nres))
19314 allocate(obrot(2,nres))
19315 allocate(obrot2(2,nres))
19316 allocate(obrot_der(2,nres))
19317 allocate(obrot2_der(2,nres))
19319 ! common /precomp1/
19320 allocate(mu(2,nres))
19321 allocate(muder(2,nres))
19322 allocate(Ub2(2,nres))
19325 allocate(Ub2der(2,nres))
19326 allocate(Ctobr(2,nres))
19327 allocate(Ctobrder(2,nres))
19328 allocate(Dtobr2(2,nres))
19329 allocate(Dtobr2der(2,nres))
19331 allocate(EUg(2,2,nres))
19332 allocate(EUgder(2,2,nres))
19333 allocate(CUg(2,2,nres))
19334 allocate(CUgder(2,2,nres))
19335 allocate(DUg(2,2,nres))
19336 allocate(Dugder(2,2,nres))
19337 allocate(DtUg2(2,2,nres))
19338 allocate(DtUg2der(2,2,nres))
19340 ! common /precomp2/
19341 allocate(Ug2Db1t(2,nres))
19342 allocate(Ug2Db1tder(2,nres))
19343 allocate(CUgb2(2,nres))
19344 allocate(CUgb2der(2,nres))
19346 allocate(EUgC(2,2,nres))
19347 allocate(EUgCder(2,2,nres))
19348 allocate(EUgD(2,2,nres))
19349 allocate(EUgDder(2,2,nres))
19350 allocate(DtUg2EUg(2,2,nres))
19351 allocate(Ug2DtEUg(2,2,nres))
19353 allocate(Ug2DtEUgder(2,2,2,nres))
19354 allocate(DtUg2EUgder(2,2,2,nres))
19356 ! common /rotat_old/
19357 allocate(costab(nres))
19358 allocate(sintab(nres))
19359 allocate(costab2(nres))
19360 allocate(sintab2(nres))
19363 allocate(a_chuj(2,2,maxconts,nres))
19364 !(2,2,maxconts,maxres)(maxconts=maxres/4)
19365 allocate(a_chuj_der(2,2,3,5,maxconts,nres))
19366 !(2,2,3,5,maxconts,maxres)(maxconts=maxres/4)
19367 ! common /contdistrib/
19368 allocate(ncont_sent(nres))
19369 allocate(ncont_recv(nres))
19371 allocate(iat_sent(nres))
19373 allocate(iint_sent(4,nres,nres))
19374 allocate(iint_sent_local(4,nres,nres))
19376 allocate(iturn3_sent(4,0:nres+4))
19377 allocate(iturn4_sent(4,0:nres+4))
19378 allocate(iturn3_sent_local(4,nres))
19379 allocate(iturn4_sent_local(4,nres))
19381 allocate(itask_cont_from(0:nfgtasks-1))
19382 allocate(itask_cont_to(0:nfgtasks-1))
19383 !(0:max_fg_procs-1)
19387 !----------------------
19390 allocate(dcdv(6,maxdim))
19391 allocate(dxdv(6,maxdim))
19393 allocate(dxds(6,nres))
19395 allocate(gradx(3,-1:nres,0:2))
19396 allocate(gradc(3,-1:nres,0:2))
19398 allocate(gvdwx(3,-1:nres))
19399 allocate(gvdwc(3,-1:nres))
19400 allocate(gelc(3,-1:nres))
19401 allocate(gelc_long(3,-1:nres))
19402 allocate(gvdwpp(3,-1:nres))
19403 allocate(gvdwc_scpp(3,-1:nres))
19404 allocate(gradx_scp(3,-1:nres))
19405 allocate(gvdwc_scp(3,-1:nres))
19406 allocate(ghpbx(3,-1:nres))
19407 allocate(ghpbc(3,-1:nres))
19408 allocate(gradcorr(3,-1:nres))
19409 allocate(gradcorr_long(3,-1:nres))
19410 allocate(gradcorr5_long(3,-1:nres))
19411 allocate(gradcorr6_long(3,-1:nres))
19412 allocate(gcorr6_turn_long(3,-1:nres))
19413 allocate(gradxorr(3,-1:nres))
19414 allocate(gradcorr5(3,-1:nres))
19415 allocate(gradcorr6(3,-1:nres))
19416 allocate(gliptran(3,-1:nres))
19417 allocate(gliptranc(3,-1:nres))
19418 allocate(gliptranx(3,-1:nres))
19419 allocate(gshieldx(3,-1:nres))
19420 allocate(gshieldc(3,-1:nres))
19421 allocate(gshieldc_loc(3,-1:nres))
19422 allocate(gshieldx_ec(3,-1:nres))
19423 allocate(gshieldc_ec(3,-1:nres))
19424 allocate(gshieldc_loc_ec(3,-1:nres))
19425 allocate(gshieldx_t3(3,-1:nres))
19426 allocate(gshieldc_t3(3,-1:nres))
19427 allocate(gshieldc_loc_t3(3,-1:nres))
19428 allocate(gshieldx_t4(3,-1:nres))
19429 allocate(gshieldc_t4(3,-1:nres))
19430 allocate(gshieldc_loc_t4(3,-1:nres))
19431 allocate(gshieldx_ll(3,-1:nres))
19432 allocate(gshieldc_ll(3,-1:nres))
19433 allocate(gshieldc_loc_ll(3,-1:nres))
19434 allocate(grad_shield(3,-1:nres))
19435 allocate(gg_tube_sc(3,-1:nres))
19436 allocate(gg_tube(3,-1:nres))
19437 allocate(gradafm(3,-1:nres))
19439 allocate(grad_shield_side(3,50,nres))
19440 allocate(grad_shield_loc(3,50,nres))
19441 ! grad for shielding surroing
19442 allocate(gloc(0:maxvar,0:2))
19443 allocate(gloc_x(0:maxvar,2))
19445 allocate(gel_loc(3,-1:nres))
19446 allocate(gel_loc_long(3,-1:nres))
19447 allocate(gcorr3_turn(3,-1:nres))
19448 allocate(gcorr4_turn(3,-1:nres))
19449 allocate(gcorr6_turn(3,-1:nres))
19450 allocate(gradb(3,-1:nres))
19451 allocate(gradbx(3,-1:nres))
19453 allocate(gel_loc_loc(maxvar))
19454 allocate(gel_loc_turn3(maxvar))
19455 allocate(gel_loc_turn4(maxvar))
19456 allocate(gel_loc_turn6(maxvar))
19457 allocate(gcorr_loc(maxvar))
19458 allocate(g_corr5_loc(maxvar))
19459 allocate(g_corr6_loc(maxvar))
19461 allocate(gsccorc(3,-1:nres))
19462 allocate(gsccorx(3,-1:nres))
19464 allocate(gsccor_loc(-1:nres))
19466 allocate(dtheta(3,2,-1:nres))
19468 allocate(gscloc(3,-1:nres))
19469 allocate(gsclocx(3,-1:nres))
19471 allocate(dphi(3,3,-1:nres))
19472 allocate(dalpha(3,3,-1:nres))
19473 allocate(domega(3,3,-1:nres))
19475 ! common /deriv_scloc/
19476 allocate(dXX_C1tab(3,nres))
19477 allocate(dYY_C1tab(3,nres))
19478 allocate(dZZ_C1tab(3,nres))
19479 allocate(dXX_Ctab(3,nres))
19480 allocate(dYY_Ctab(3,nres))
19481 allocate(dZZ_Ctab(3,nres))
19482 allocate(dXX_XYZtab(3,nres))
19483 allocate(dYY_XYZtab(3,nres))
19484 allocate(dZZ_XYZtab(3,nres))
19487 allocate(jgrad_start(nres))
19488 allocate(jgrad_end(nres))
19490 !----------------------
19493 allocate(ibond_displ(0:nfgtasks-1))
19494 allocate(ibond_count(0:nfgtasks-1))
19495 allocate(ithet_displ(0:nfgtasks-1))
19496 allocate(ithet_count(0:nfgtasks-1))
19497 allocate(iphi_displ(0:nfgtasks-1))
19498 allocate(iphi_count(0:nfgtasks-1))
19499 allocate(iphi1_displ(0:nfgtasks-1))
19500 allocate(iphi1_count(0:nfgtasks-1))
19501 allocate(ivec_displ(0:nfgtasks-1))
19502 allocate(ivec_count(0:nfgtasks-1))
19503 allocate(iset_displ(0:nfgtasks-1))
19504 allocate(iset_count(0:nfgtasks-1))
19505 allocate(iint_count(0:nfgtasks-1))
19506 allocate(iint_displ(0:nfgtasks-1))
19507 !(0:max_fg_procs-1)
19508 !----------------------
19511 allocate(gcart(3,-1:nres))
19512 allocate(gxcart(3,-1:nres))
19514 allocate(gradcag(3,-1:nres))
19515 allocate(gradxag(3,-1:nres))
19517 ! common /back_constr/
19518 !el in energy:Econstr_back allocate((:),allocatable :: utheta,ugamma,uscdiff !(maxfrag_back)
19519 allocate(dutheta(nres))
19520 allocate(dugamma(nres))
19522 allocate(duscdiff(3,nres))
19523 allocate(duscdiffx(3,nres))
19525 !el i io:read_fragments
19526 ! allocate((:,:,:),allocatable :: wfrag_back !(3,maxfrag_back,maxprocs/20)
19527 ! allocate((:,:,:),allocatable :: ifrag_back !(3,maxfrag_back,maxprocs/20)
19529 ! allocate(qinfrag(50,nprocs/20),wfrag(50,nprocs/20)) !(50,maxprocs/20)
19530 ! allocate(qinpair(100,nprocs/20),wpair(100,nprocs/20)) !(100,maxprocs/20)
19531 allocate(mset(0:nprocs)) !(maxprocs/20)
19533 ! allocate(ifrag(2,50,nprocs/20)) !(2,50,maxprocs/20)
19534 ! allocate(ipair(2,100,nprocs/20)) !(2,100,maxprocs/20)
19535 allocate(dUdconst(3,0:nres))
19536 allocate(dUdxconst(3,0:nres))
19537 allocate(dqwol(3,0:nres))
19538 allocate(dxqwol(3,0:nres))
19540 !----------------------
19542 ! common /sbridge/ in io_common: read_bridge
19543 !el allocate((:),allocatable :: iss !(maxss)
19544 ! common /links/ in io_common: read_bridge
19545 !el real(kind=8),dimension(:),allocatable :: dhpb,forcon,dhpb1 !(maxdim) !el dhpb1 !!! nie używane
19546 !el integer,dimension(:),allocatable :: ihpb,jhpb,ibecarb !(maxdim) !el ibecarb !!! nie używane
19547 ! common /dyn_ssbond/
19548 ! and side-chain vectors in theta or phi.
19549 allocate(dyn_ssbond_ij(0:nres+4,0:nres+4))
19553 dyn_ssbond_ij(:,:)=1.0d300
19557 ! if (nss.gt.0) then
19558 allocate(idssb(maxdim),jdssb(maxdim))
19559 ! allocate(newihpb(nss),newjhpb(nss))
19562 allocate(ishield_list(nres))
19563 allocate(shield_list(50,nres))
19564 allocate(dyn_ss_mask(nres))
19565 allocate(fac_shield(nres))
19566 allocate(enetube(nres*2))
19567 allocate(enecavtube(nres*2))
19570 dyn_ss_mask(:)=.false.
19571 !----------------------
19573 ! Parameters of the SCCOR term
19575 !el in io_conf: parmread
19576 ! allocate(v1sccor(maxterm_sccor,3,-ntyp:ntyp,-ntyp:ntyp))
19577 ! allocate(v2sccor(maxterm_sccor,3,-ntyp:ntyp,-ntyp:ntyp)) !(maxterm_sccor,3,-ntyp:ntyp,-ntyp:ntyp)
19578 ! allocate(v0sccor(maxterm_sccor,-ntyp:ntyp,-ntyp:ntyp)) !(maxterm_sccor,-ntyp:ntyp,-ntyp:ntyp)
19579 ! allocate(isccortyp(-ntyp:ntyp)) !(-ntyp:ntyp)
19580 ! allocate(nterm_sccor(-ntyp:ntyp,-ntyp:ntyp))
19581 ! allocate(nlor_sccor(-ntyp:ntyp,-ntyp:ntyp)) !(-ntyp:ntyp,-ntyp:ntyp)
19582 ! allocate(vlor1sccor(maxterm_sccor,20,20))
19583 ! allocate(vlor2sccor(maxterm_sccor,20,20))
19584 ! allocate(vlor3sccor(maxterm_sccor,20,20)) !(maxterm_sccor,20,20)
19586 allocate(gloc_sc(3,0:2*nres,0:10))
19587 !(3,0:maxres2,10)maxres2=2*maxres
19588 allocate(dcostau(3,3,3,2*nres))
19589 allocate(dsintau(3,3,3,2*nres))
19590 allocate(dtauangle(3,3,3,2*nres))
19591 allocate(dcosomicron(3,3,3,2*nres))
19592 allocate(domicron(3,3,3,2*nres))
19593 !(3,3,3,maxres2)maxres2=2*maxres
19594 !----------------------
19597 allocate(varall(maxvar))
19598 !(maxvar)(maxvar=6*maxres)
19599 allocate(mask_theta(nres))
19600 allocate(mask_phi(nres))
19601 allocate(mask_side(nres))
19603 !----------------------
19606 allocate(uy(3,nres))
19607 allocate(uz(3,nres))
19609 allocate(uygrad(3,3,2,nres))
19610 allocate(uzgrad(3,3,2,nres))
19614 end subroutine alloc_ener_arrays
19615 !-----------------------------------------------------------------------------
19616 !-----------------------------------------------------------------------------