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 !-----------------------------NUCLEIC GRADIENT
129 real(kind=8),dimension(:,:),allocatable ::gradb_nucl,gradbx_nucl, &
130 gvdwpsb1,gelpp,gvdwpsb,gelsbc,gelsbx,gvdwsbx,gvdwsbc,gsbloc,&
131 gsblocx,gradcorr_nucl,gradxorr_nucl,gradcorr3_nucl,gradxorr3_nucl,&
133 !-----------------------------NUCLEIC-PROTEIN GRADIENT
134 real(kind=8),dimension(:,:),allocatable :: gvdwx_scbase,gvdwc_scbase,&
135 gvdwx_pepbase,gvdwc_pepbase,gvdwx_scpho,gvdwc_scpho,&
137 !------------------------------IONS GRADIENT
138 real(kind=8),dimension(:,:),allocatable :: gradcatcat, &
139 gradpepcat,gradpepcatx
140 ! real(kind=8),dimension(:,:),allocatable :: gloc,gloc_x !(maxvar,2)
143 real(kind=8),dimension(:,:),allocatable :: gel_loc,gel_loc_long,&
144 gcorr3_turn,gcorr4_turn,gcorr6_turn,gradb,gradbx !(3,maxres)
145 real(kind=8),dimension(:),allocatable :: gel_loc_loc,&
146 gel_loc_turn3,gel_loc_turn4,gel_loc_turn6,gcorr_loc,g_corr5_loc,&
147 g_corr6_loc !(maxvar)
148 real(kind=8),dimension(:,:),allocatable :: gsccorc,gsccorx !(3,maxres)
149 real(kind=8),dimension(:),allocatable :: gsccor_loc !(maxres)
150 ! real(kind=8),dimension(:,:,:),allocatable :: dtheta !(3,2,maxres)
151 real(kind=8),dimension(:,:),allocatable :: gscloc,gsclocx !(3,maxres)
152 ! real(kind=8),dimension(:,:,:),allocatable :: dphi,dalpha,domega !(3,3,maxres)
153 real(kind=8),dimension(:,:,:),allocatable :: grad_shield_side, &
154 grad_shield_loc ! (3,maxcontsshileding,maxnres)
157 real(kind=8), dimension(:),allocatable :: fac_shield
158 real(kind=8),dimension(3,5,2) :: derx,derx_turn
159 ! common /deriv_scloc/
160 real(kind=8),dimension(:,:),allocatable :: dXX_C1tab,dYY_C1tab,&
161 dZZ_C1tab,dXX_Ctab,dYY_Ctab,dZZ_Ctab,dXX_XYZtab,dYY_XYZtab,&
162 dZZ_XYZtab !(3,maxres)
163 !-----------------------------------------------------------------------------
166 real(kind=8) :: gvdwc_max,gvdwc_scp_max,gelc_max,gvdwpp_max,&
167 gradb_max,ghpbc_max,&
168 gradcorr_max,gel_loc_max,gcorr3_turn_max,gcorr4_turn_max,&
169 gradcorr5_max,gradcorr6_max,gcorr6_turn_max,gsccorc_max,&
170 gscloc_max,gvdwx_max,gradx_scp_max,ghpbx_max,gradxorr_max,&
171 gsccorx_max,gsclocx_max
172 !-----------------------------------------------------------------------------
174 ! common /back_constr/
175 real(kind=8),dimension(:),allocatable :: dutheta,dugamma !(maxres)
176 real(kind=8),dimension(:,:),allocatable :: duscdiff,duscdiffx !(3,maxres)
178 real(kind=8) :: Ucdfrag,Ucdpair
179 real(kind=8),dimension(:,:),allocatable :: dUdconst,dUdxconst,&
180 dqwol,dxqwol !(3,0:MAXRES)
181 !-----------------------------------------------------------------------------
183 ! common /dyn_ssbond/
184 real(kind=8),dimension(:,:),allocatable :: dyn_ssbond_ij !(maxres,maxres)
185 !-----------------------------------------------------------------------------
187 ! Parameters of the SCCOR term
189 real(kind=8),dimension(:,:,:,:),allocatable :: dcostau,dsintau,&
190 dcosomicron,domicron !(3,3,3,maxres2)
191 !-----------------------------------------------------------------------------
194 real(kind=8),dimension(:,:),allocatable :: uy,uz !(3,maxres)
195 real(kind=8),dimension(:,:,:,:),allocatable :: uygrad,uzgrad !(3,3,2,maxres)
196 !-----------------------------------------------------------------------------
197 ! common /przechowalnia/
198 real(kind=8),dimension(:,:,:),allocatable :: zapas
199 real(kind=8),dimension(:,:,:,:),allocatable ::zapas2 !(max_dim,maxconts,max_fg_procs)
200 real(kind=8),dimension(:,:,:),allocatable :: fromto !(3,3,maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
201 !-----------------------------------------------------------------------------
202 !-----------------------------------------------------------------------------
205 !-----------------------------------------------------------------------------
207 !-----------------------------------------------------------------------------
208 ! energy_p_new_barrier.F
209 !-----------------------------------------------------------------------------
210 subroutine etotal(energia)
211 ! implicit real*8 (a-h,o-z)
212 ! include 'DIMENSIONS'
217 !MS$ATTRIBUTES C :: proc_proc
223 ! include 'COMMON.SETUP'
224 ! include 'COMMON.IOUNITS'
225 real(kind=8),dimension(0:n_ene) :: energia
226 ! include 'COMMON.LOCAL'
227 ! include 'COMMON.FFIELD'
228 ! include 'COMMON.DERIV'
229 ! include 'COMMON.INTERACT'
230 ! include 'COMMON.SBRIDGE'
231 ! include 'COMMON.CHAIN'
232 ! include 'COMMON.VAR'
233 ! include 'COMMON.MD'
234 ! include 'COMMON.CONTROL'
235 ! include 'COMMON.TIME1'
236 real(kind=8) :: time00
238 integer :: n_corr,n_corr1,ierror
239 real(kind=8) :: etors,edihcnstr,etors_d,esccor,ehpb
240 real(kind=8) :: evdw,evdw1,evdw2,evdw2_14,escloc,ees,eel_loc
241 real(kind=8) :: eello_turn3,eello_turn4,estr,ebe,eliptran,etube, &
242 Eafmforce,ethetacnstr
243 real(kind=8) :: ecorr,ecorr5,ecorr6,eturn6
244 ! now energies for nulceic alone parameters
245 real(kind=8) :: evdwpp,eespp,evdwpsb,eelpsb,evdwsb,eelsb,estr_nucl,&
246 ebe_nucl,esbloc,etors_nucl,etors_d_nucl,ecorr_nucl,&
249 real(kind=8) :: ecation_prot,ecationcation
250 ! energies for protein nucleic acid interaction
251 real(kind=8) :: escbase,epepbase,escpho,epeppho
254 real(kind=8) :: weights_(n_ene) !,time_Bcast,time_Bcastw
255 ! shielding effect varibles for MPI
256 ! real(kind=8) fac_shieldbuf(maxres),
257 ! & grad_shield_locbuf(3,maxcontsshi,-1:maxres),
258 ! & grad_shield_sidebuf(3,maxcontsshi,-1:maxres),
259 ! & grad_shieldbuf(3,-1:maxres)
260 ! integer ishield_listbuf(maxres),
261 ! &shield_listbuf(maxcontsshi,maxres)
263 ! print*,"ETOTAL Processor",fg_rank," absolute rank",myrank,
264 ! & " nfgtasks",nfgtasks
265 if (nfgtasks.gt.1) then
267 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
268 if (fg_rank.eq.0) then
269 call MPI_Bcast(0,1,MPI_INTEGER,king,FG_COMM,IERROR)
270 ! print *,"Processor",myrank," BROADCAST iorder"
271 ! FG master sets up the WEIGHTS_ array which will be broadcast to the
272 ! FG slaves as WEIGHTS array.
292 weights_(26)=wvdwpp_nucl
298 weights_(32)=wbond_nucl
299 weights_(33)=wang_nucl
301 weights_(35)=wtor_nucl
302 weights_(36)=wtor_d_nucl
303 weights_(37)=wcorr_nucl
304 weights_(38)=wcorr3_nucl
306 weights_(42)=wcatprot
310 ! wcatcat= weights(41)
311 ! wcatprot=weights(42)
313 ! FG Master broadcasts the WEIGHTS_ array
314 call MPI_Bcast(weights_(1),n_ene,&
315 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
317 ! FG slaves receive the WEIGHTS array
318 call MPI_Bcast(weights(1),n_ene,&
319 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
339 wvdwpp_nucl =weights(26)
345 wbond_nucl =weights(32)
346 wang_nucl =weights(33)
348 wtor_nucl =weights(35)
349 wtor_d_nucl =weights(36)
350 wcorr_nucl =weights(37)
351 wcorr3_nucl =weights(38)
358 time_Bcast=time_Bcast+MPI_Wtime()-time00
359 time_Bcastw=time_Bcastw+MPI_Wtime()-time00
360 ! call chainbuild_cart
362 ! print *,'Processor',myrank,' calling etotal ipot=',ipot
363 ! print *,'Processor',myrank,' nnt=',nnt,' nct=',nct
365 ! if (modecalc.eq.12.or.modecalc.eq.14) then
366 ! call int_from_cart1(.false.)
373 ! Compute the side-chain and electrostatic interaction energy
374 ! print *, "Before EVDW"
375 ! goto (101,102,103,104,105,106) ipot
377 ! Lennard-Jones potential.
381 !d print '(a)','Exit ELJcall el'
383 ! Lennard-Jones-Kihara potential (shifted).
384 ! 102 call eljk(evdw)
388 ! Berne-Pechukas potential (dilated LJ, angular dependence).
393 ! Gay-Berne potential (shifted LJ, angular dependence).
398 ! Gay-Berne-Vorobjev potential (shifted LJ, angular dependence).
399 ! 105 call egbv(evdw)
403 ! Soft-sphere potential
404 ! 106 call e_softsphere(evdw)
406 call e_softsphere(evdw)
408 ! Calculate electrostatic (H-bonding) energy of the main chain.
412 write(iout,*)"Wrong ipot"
417 ! print *,"after EGB"
419 if (shield_mode.eq.2) then
422 ! print *,"AFTER EGB",ipot,evdw
424 !mc Sep-06: egb takes care of dynamic ss bonds too
426 ! if (dyn_ss) call dyn_set_nss
427 ! print *,"Processor",myrank," computed USCSC"
433 time_vec=time_vec+MPI_Wtime()-time01
435 ! print *,"Processor",myrank," left VEC_AND_DERIV"
438 ! print *,"after ipot if", ipot
439 if (welec.gt.0d0.or.wvdwpp.gt.0d0.or.wel_loc.gt.0d0.or. &
440 wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0 &
441 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
442 .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
444 if (welec.gt.0d0.or.wel_loc.gt.0d0.or. &
445 wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0 &
446 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
447 .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
449 ! print *,"just befor eelec call"
450 call eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
451 ! write (iout,*) "ELEC calc"
460 ! write (iout,*) "Soft-spheer ELEC potential"
461 call eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,&
464 ! print *,"Processor",myrank," computed UELEC"
466 ! Calculate excluded-volume interaction energy between peptide groups
469 !elwrite(iout,*) "in etotal calc exc;luded",ipot
473 call escp(evdw2,evdw2_14)
479 ! write (iout,*) "Soft-sphere SCP potential"
480 call escp_soft_sphere(evdw2,evdw2_14)
482 ! write(iout,*) "in etotal before ebond",ipot
485 ! Calculate the bond-stretching energy
488 ! print *,"EBOND",estr
489 ! write(iout,*) "in etotal afer ebond",ipot
492 ! Calculate the disulfide-bridge and other energy and the contributions
493 ! from other distance constraints.
494 ! print *,'Calling EHPB'
496 !elwrite(iout,*) "in etotal afer edis",ipot
497 ! print *,'EHPB exitted succesfully.'
499 ! Calculate the virtual-bond-angle energy.
501 if (wang.gt.0d0) then
502 call ebend(ebe,ethetacnstr)
507 ! print *,"Processor",myrank," computed UB"
509 ! Calculate the SC local energy.
512 !elwrite(iout,*) "in etotal afer esc",ipot
513 ! print *,"Processor",myrank," computed USC"
515 ! Calculate the virtual-bond torsional energy.
517 !d print *,'nterm=',nterm
519 call etor(etors,edihcnstr)
524 ! print *,"Processor",myrank," computed Utor"
526 ! 6/23/01 Calculate double-torsional energy
528 !elwrite(iout,*) "in etotal",ipot
529 if (wtor_d.gt.0) then
534 ! print *,"Processor",myrank," computed Utord"
536 ! 21/5/07 Calculate local sicdechain correlation energy
538 if (wsccor.gt.0.0d0) then
539 call eback_sc_corr(esccor)
543 ! print *,"Processor",myrank," computed Usccorr"
545 ! 12/1/95 Multi-body terms
549 if ((wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 &
550 .or. wturn6.gt.0.0d0) .and. ipot.lt.6) then
551 call multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
552 !d write(2,*)'multibody_eello n_corr=',n_corr,' n_corr1=',n_corr1,
553 !d &" ecorr",ecorr," ecorr5",ecorr5," ecorr6",ecorr6," eturn6",eturn6
560 !elwrite(iout,*) "in etotal",ipot
561 if ((wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) .and. ipot.lt.6) then
562 call multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
563 !d write (iout,*) "multibody_hb ecorr",ecorr
565 !elwrite(iout,*) "afeter multibody hb"
567 ! print *,"Processor",myrank," computed Ucorr"
569 ! If performing constraint dynamics, call the constraint energy
570 ! after the equilibration time
571 if(usampl.and.totT.gt.eq_time) then
572 !elwrite(iout,*) "afeter multibody hb"
574 !elwrite(iout,*) "afeter multibody hb"
576 !elwrite(iout,*) "afeter multibody hb"
582 ! write(iout,*) "after Econstr"
584 if (wliptran.gt.0) then
585 ! print *,"PRZED WYWOLANIEM"
586 call Eliptransfer(eliptran)
590 if (fg_rank.eq.0) then
591 if (AFMlog.gt.0) then
592 call AFMforce(Eafmforce)
593 else if (selfguide.gt.0) then
594 call AFMvel(Eafmforce)
597 if (tubemode.eq.1) then
599 else if (tubemode.eq.2) then
600 call calctube2(etube)
601 elseif (tubemode.eq.3) then
606 !--------------------------------------------------------
607 ! print *,"before",ees,evdw1,ecorr
608 if (nres_molec(2).gt.0) then
609 call ebond_nucl(estr_nucl)
610 call ebend_nucl(ebe_nucl)
611 call etor_nucl(etors_nucl)
612 call esb_gb(evdwsb,eelsb)
613 call epp_nucl_sub(evdwpp,eespp)
614 call epsb(evdwpsb,eelpsb)
616 call multibody_hb_nucl(ecorr_nucl,ecorr3_nucl,n_corr,n_corr1)
618 if (nfgtasks.gt.1) then
619 if (fg_rank.eq.0) then
620 call ecatcat(ecationcation)
623 call ecatcat(ecationcation)
625 call ecat_prot(ecation_prot)
626 if (nres_molec(2).gt.0) then
627 call eprot_sc_base(escbase)
628 call epep_sc_base(epepbase)
629 call eprot_sc_phosphate(escpho)
630 call eprot_pep_phosphate(epeppho)
632 ! call ecatcat(ecationcation)
633 ! print *,"after ebend", ebe_nucl
635 time_enecalc=time_enecalc+MPI_Wtime()-time00
637 ! print *,"Processor",myrank," computed Uconstr"
646 energia(2)=evdw2-evdw2_14
663 energia(8)=eello_turn3
664 energia(9)=eello_turn4
671 energia(19)=edihcnstr
673 energia(20)=Uconst+Uconst_back
676 energia(23)=Eafmforce
677 energia(24)=ethetacnstr
679 !---------------------------------------------------------------
686 energia(32)=estr_nucl
689 energia(35)=etors_nucl
690 energia(36)=etors_d_nucl
691 energia(37)=ecorr_nucl
692 energia(38)=ecorr3_nucl
693 !----------------------------------------------------------------------
694 ! Here are the energies showed per procesor if the are more processors
695 ! per molecule then we sum it up in sum_energy subroutine
696 ! print *," Processor",myrank," calls SUM_ENERGY"
697 energia(41)=ecation_prot
698 energia(42)=ecationcation
703 call sum_energy(energia,.true.)
704 if (dyn_ss) call dyn_set_nss
705 ! print *," Processor",myrank," left SUM_ENERGY"
707 time_sumene=time_sumene+MPI_Wtime()-time00
709 !el call enerprint(energia)
710 !elwrite(iout,*)"finish etotal"
712 end subroutine etotal
713 !-----------------------------------------------------------------------------
714 subroutine sum_energy(energia,reduce)
715 ! implicit real*8 (a-h,o-z)
716 ! include 'DIMENSIONS'
720 !MS$ATTRIBUTES C :: proc_proc
726 ! include 'COMMON.SETUP'
727 ! include 'COMMON.IOUNITS'
728 real(kind=8) :: energia(0:n_ene),enebuff(0:n_ene+1)
729 ! include 'COMMON.FFIELD'
730 ! include 'COMMON.DERIV'
731 ! include 'COMMON.INTERACT'
732 ! include 'COMMON.SBRIDGE'
733 ! include 'COMMON.CHAIN'
734 ! include 'COMMON.VAR'
735 ! include 'COMMON.CONTROL'
736 ! include 'COMMON.TIME1'
738 real(kind=8) :: evdw,evdw2,evdw2_14,ees,evdw1,ecorr,ecorr5,ecorr6
739 real(kind=8) :: eel_loc,eello_turn3,eello_turn4,eturn6,ebe,escloc
740 real(kind=8) :: etors,etors_d,ehpb,edihcnstr,estr,esccor,etot, &
741 eliptran,etube, Eafmforce,ethetacnstr
742 real(kind=8) :: evdwpp,eespp,evdwpsb,eelpsb,evdwsb,eelsb,estr_nucl,&
743 ebe_nucl,esbloc,etors_nucl,etors_d_nucl,ecorr_nucl,&
745 real(kind=8) :: ecation_prot,ecationcation
746 real(kind=8) :: escbase,epepbase,escpho,epeppho
750 real(kind=8) :: time00
751 if (nfgtasks.gt.1 .and. reduce) then
754 write (iout,*) "energies before REDUCE"
755 call enerprint(energia)
759 enebuff(i)=energia(i)
762 call MPI_Barrier(FG_COMM,IERR)
763 time_barrier_e=time_barrier_e+MPI_Wtime()-time00
765 call MPI_Reduce(enebuff(0),energia(0),n_ene+1,&
766 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
768 write (iout,*) "energies after REDUCE"
769 call enerprint(energia)
772 time_Reduce=time_Reduce+MPI_Wtime()-time00
774 if (fg_rank.eq.0) then
778 evdw2=energia(2)+energia(18)
794 eello_turn3=energia(8)
795 eello_turn4=energia(9)
802 edihcnstr=energia(19)
807 Eafmforce=energia(23)
808 ethetacnstr=energia(24)
816 estr_nucl=energia(32)
819 etors_nucl=energia(35)
820 etors_d_nucl=energia(36)
821 ecorr_nucl=energia(37)
822 ecorr3_nucl=energia(38)
823 ecation_prot=energia(41)
824 ecationcation=energia(42)
829 ! energia(41)=ecation_prot
830 ! energia(42)=ecationcation
834 etot=wsc*evdw+wscp*evdw2+welec*ees+wvdwpp*evdw1 &
835 +wang*ebe+wtor*etors+wscloc*escloc &
836 +wstrain*ehpb+wcorr*ecorr+wcorr5*ecorr5 &
837 +wcorr6*ecorr6+wturn4*eello_turn4+wturn3*eello_turn3 &
838 +wturn6*eturn6+wel_loc*eel_loc+edihcnstr+wtor_d*etors_d &
839 +wbond*estr+Uconst+wsccor*esccor+wliptran*eliptran+wtube*etube&
840 +Eafmforce+ethetacnstr &
841 +wbond_nucl*estr_nucl+wang_nucl*ebe_nucl&
842 +wvdwpp_nucl*evdwpp+welpp*eespp+wvdwpsb*evdwpsb+welpsb*eelpsb&
843 +wvdwsb*evdwsb+welsb*eelsb+wsbloc*esbloc+wtor_nucl*etors_nucl&
844 +wtor_d_nucl*etors_d_nucl+wcorr_nucl*ecorr_nucl+wcorr3_nucl*ecorr3_nucl&
845 +wcatprot*ecation_prot+wcatcat*ecationcation+wscbase*escbase&
846 +wpepbase*epepbase+wscpho*escpho+wpeppho*epeppho
848 etot=wsc*evdw+wscp*evdw2+welec*(ees+evdw1) &
849 +wang*ebe+wtor*etors+wscloc*escloc &
850 +wstrain*ehpb+wcorr*ecorr+wcorr5*ecorr5 &
851 +wcorr6*ecorr6+wturn4*eello_turn4+wturn3*eello_turn3 &
852 +wturn6*eturn6+wel_loc*eel_loc+edihcnstr+wtor_d*etors_d &
853 +wbond*estr+Uconst+wsccor*esccor+wliptran*eliptran+wtube*etube&
854 +Eafmforce+ethetacnstr &
855 +wbond_nucl*estr_nucl+wang_nucl*ebe_nucl&
856 +wvdwpp_nucl*evdwpp+welpp*eespp+wvdwpsb*evdwpsb+welpsb*eelpsb&
857 +wvdwsb*evdwsb+welsb*eelsb+wsbloc*esbloc+wtor_nucl*etors_nucl&
858 +wtor_d_nucl*etors_d_nucl+wcorr_nucl*ecorr_nucl+wcorr3_nucl*ecorr3_nucl&
859 +wcatprot*ecation_prot+wcatcat*ecationcation+wscbase*escbase&
860 +wpepbase*epepbase+wscpho*escpho+wpeppho*epeppho
866 if (isnan(etot).ne.0) energia(0)=1.0d+99
868 if (isnan(etot)) energia(0)=1.0d+99
873 idumm=proc_proc(etot,i)
875 call proc_proc(etot,i)
877 if(i.eq.1)energia(0)=1.0d+99
882 ! call enerprint(energia)
885 end subroutine sum_energy
886 !-----------------------------------------------------------------------------
887 subroutine rescale_weights(t_bath)
888 ! implicit real*8 (a-h,o-z)
892 ! include 'DIMENSIONS'
893 ! include 'COMMON.IOUNITS'
894 ! include 'COMMON.FFIELD'
895 ! include 'COMMON.SBRIDGE'
896 real(kind=8) :: kfac=2.4d0
897 real(kind=8) :: x,x2,x3,x4,x5,licznik=1.12692801104297249644
899 real(kind=8) :: t_bath,facT(6) !,facT2,facT3,facT4,facT5,facT6
900 real(kind=8) :: T0=3.0d2
903 ! facT=2*temp0/(t_bath+temp0)
904 if (rescale_mode.eq.0) then
911 else if (rescale_mode.eq.1) then
912 facT(1)=kfac/(kfac-1.0d0+t_bath/temp0)
913 facT(2)=kfac**2/(kfac**2-1.0d0+(t_bath/temp0)**2)
914 facT(3)=kfac**3/(kfac**3-1.0d0+(t_bath/temp0)**3)
915 facT(4)=kfac**4/(kfac**4-1.0d0+(t_bath/temp0)**4)
916 facT(5)=kfac**5/(kfac**5-1.0d0+(t_bath/temp0)**5)
918 !#if defined(WHAM_RUN) || defined(CLUSTER)
920 ! tt = 1.0d0/(beta_h(ib,ipar)*1.987D-3)
921 facT(6)=(320.0+80.0*dtanh((t_bath-320.0)/80.0))/320.0
928 else if (rescale_mode.eq.2) then
934 facT(1)=licznik/dlog(dexp(x)+dexp(-x))
935 facT(2)=licznik/dlog(dexp(x2)+dexp(-x2))
936 facT(3)=licznik/dlog(dexp(x3)+dexp(-x3))
937 facT(4)=licznik/dlog(dexp(x4)+dexp(-x4))
938 facT(5)=licznik/dlog(dexp(x5)+dexp(-x5))
940 !#if defined(WHAM_RUN) || defined(CLUSTER)
942 facT(6)=(320.0+80.0*dtanh((t_bath-320.0)/80.0))/320.0
950 write (iout,*) "Wrong RESCALE_MODE",rescale_mode
951 write (*,*) "Wrong RESCALE_MODE",rescale_mode
953 call MPI_Finalize(MPI_COMM_WORLD,IERROR)
957 welec=weights(3)*fact(1)
958 wcorr=weights(4)*fact(3)
959 wcorr5=weights(5)*fact(4)
960 wcorr6=weights(6)*fact(5)
961 wel_loc=weights(7)*fact(2)
962 wturn3=weights(8)*fact(2)
963 wturn4=weights(9)*fact(3)
964 wturn6=weights(10)*fact(5)
965 wtor=weights(13)*fact(1)
966 wtor_d=weights(14)*fact(2)
967 wsccor=weights(21)*fact(1)
970 end subroutine rescale_weights
971 !-----------------------------------------------------------------------------
972 subroutine enerprint(energia)
973 ! implicit real*8 (a-h,o-z)
974 ! include 'DIMENSIONS'
975 ! include 'COMMON.IOUNITS'
976 ! include 'COMMON.FFIELD'
977 ! include 'COMMON.SBRIDGE'
978 ! include 'COMMON.MD'
979 real(kind=8) :: energia(0:n_ene)
981 real(kind=8) :: etot,evdw,evdw2,ees,evdw1,ecorr,ecorr5,ecorr6,eel_loc
982 real(kind=8) :: eello_turn6,eello_turn3,eello_turn4,ebe,escloc
983 real(kind=8) :: etors,etors_d,ehpb,edihcnstr,estr,Uconst,esccor,eliptran,&
984 etube,ethetacnstr,Eafmforce
985 real(kind=8) :: evdwpp,eespp,evdwpsb,eelpsb,evdwsb,eelsb,estr_nucl,&
986 ebe_nucl,esbloc,etors_nucl,etors_d_nucl,ecorr_nucl,&
988 real(kind=8) :: ecation_prot,ecationcation
989 real(kind=8) :: escbase,epepbase,escpho,epeppho
995 evdw2=energia(2)+energia(18)
1007 eello_turn3=energia(8)
1008 eello_turn4=energia(9)
1009 eello_turn6=energia(10)
1015 edihcnstr=energia(19)
1019 eliptran=energia(22)
1020 Eafmforce=energia(23)
1021 ethetacnstr=energia(24)
1029 estr_nucl=energia(32)
1030 ebe_nucl=energia(33)
1032 etors_nucl=energia(35)
1033 etors_d_nucl=energia(36)
1034 ecorr_nucl=energia(37)
1035 ecorr3_nucl=energia(38)
1036 ecation_prot=energia(41)
1037 ecationcation=energia(42)
1039 epepbase=energia(47)
1043 write (iout,10) evdw,wsc,evdw2,wscp,ees,welec,evdw1,wvdwpp,&
1044 estr,wbond,ebe,wang,&
1045 escloc,wscloc,etors,wtor,etors_d,wtor_d,ehpb,wstrain,&
1047 ecorr5,wcorr5,ecorr6,wcorr6,eel_loc,wel_loc,eello_turn3,wturn3,&
1048 eello_turn4,wturn4,eello_turn6,wturn6,esccor,wsccor,&
1049 edihcnstr,ethetacnstr,ebr*nss,&
1050 Uconst,eliptran,wliptran,Eafmforce,etube,wtube, & ! till now protein
1051 estr_nucl,wbond_nucl,ebe_nucl,wang_nucl, &
1052 evdwpp,wvdwpp_nucl,eespp,welpp,evdwpsb,wvdwpsb,eelpsb,welpsb,&
1053 evdwsb,wvdwsb,eelsb,welsb,esbloc,wsbloc,etors_nucl,wtor_nucl,&
1054 etors_d_nucl,wtor_d_nucl,ecorr_nucl,wcorr_nucl,&
1055 ecorr3_nucl,wcorr3_nucl,ecation_prot,wcatprot,ecationcation,wcatcat, &
1056 escbase,wscbase,epepbase,wpepbase,escpho,wscpho,epeppho,wpeppho,&
1058 10 format (/'Virtual-chain energies:'// &
1059 'EVDW= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-SC)'/ &
1060 'EVDW2= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-p)'/ &
1061 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p)'/ &
1062 'EVDWPP=',1pE16.6,' WEIGHT=',1pD16.6,' (p-p VDW)'/ &
1063 'ESTR= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching)'/ &
1064 'EBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (bending)'/ &
1065 'ESC= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/ &
1066 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/ &
1067 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/ &
1068 'EHBP= ',1pE16.6,' WEIGHT=',1pD16.6, &
1069 ' (SS bridges & dist. cnstr.)'/ &
1070 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
1071 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
1072 'ECORR6=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
1073 'EELLO= ',1pE16.6,' WEIGHT=',1pD16.6,' (electrostatic-local)'/ &
1074 'ETURN3=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 3rd order)'/ &
1075 'ETURN4=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 4th order)'/ &
1076 'ETURN6=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 6th order)'/ &
1077 'ESCCOR=',1pE16.6,' WEIGHT=',1pD16.6,' (backbone-rotamer corr)'/ &
1078 'EDIHC= ',1pE16.6,' (dihedral angle constraints)'/ &
1079 'ETHETC= ',1pE16.6,' (valence angle constraints)'/ &
1080 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/ &
1081 'UCONST= ',1pE16.6,' (Constraint energy)'/ &
1082 'ELT=',1pE16.6, ' WEIGHT=',1pD16.6,' (Lipid transfer energy)'/&
1083 'EAFM= ',1pE16.6,' (atomic-force microscopy)'/ &
1084 'ETUBE=',1pE16.6, ' WEIGHT=',1pD16.6,' (cylindrical energy)'/ &
1085 'ESTR_nucl=',1pE16.6,' WEIGHT=',1pD16.6,' (stretching for nucleic)'/ &
1086 'EBE_nucl=',1pE16.6,' WEIGHT=',1pD16.6,' (bending for nucleic)'/ &
1087 'EVDW_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-phosphate VDW)'/ &
1088 'EESPP_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-phosphate elec)'/ &
1089 'EVDWPSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-sugarbase VDW)'/ &
1090 'EESPSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-sugarbase elec)'/ &
1091 'EVDWSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(sugarbase-sugarbase VDW)'/ &
1092 'EESSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(sugarbase-sugarbase elec)'/ &
1093 'ESBLOC_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(sugarbase rotamer)'/ &
1094 'ETORS_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(torsional)'/ &
1095 'ETORSD_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(double torsional)'/ &
1096 'ECORR_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(multibody 4th order)'/ &
1097 'ECORR3_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(multibody 3th order)'/ &
1098 'ECATPROT=',1pE16.6,' WEIGHT=',1pD16.6,'(cation prot)'/ &
1099 'ECATCAT=',1pE16.6,' WEIGHT=',1pD16.6,'(cation cation)'/ &
1100 'ESCBASE=',1pE16.6,' WEIGHT=',1pD16.6,'(sc-prot nucl-base)'/ &
1101 'EPEPBASE=',1pE16.6,' WEIGHT=',1pD16.6,'(pep-prot nucl-base)'/ &
1102 'ESCPHO=',1pE16.6,' WEIGHT=',1pD16.6,'(sc-prot nucl-phosphate)'/&
1103 'EPEPPHO=',1pE16.6,' WEIGHT=',1pD16.6,'(pep-prot nucl-phosphate)'/&
1104 'ETOT= ',1pE16.6,' (total)')
1106 write (iout,10) evdw,wsc,evdw2,wscp,ees,welec,&
1107 estr,wbond,ebe,wang,&
1108 escloc,wscloc,etors,wtor,etors_d,wtor_d,ehpb,wstrain,&
1110 ecorr5,wcorr5,ecorr6,wcorr6,eel_loc,wel_loc,eello_turn3,wturn3,&
1111 eello_turn4,wturn4,eello_turn6,wturn6,esccor,wsccor,edihcnstr,&
1112 ethetacnstr,ebr*nss,Uconst,eliptran,wliptran,Eafmforc, &
1114 estr_nucl,wbond_nucl, ebe_nucl,wang_nucl,&
1115 evdwpp,wvdwpp_nucl,eespp,welpp,evdwpsb,wvdwpsb,eelpsb,welpsb&
1116 evdwsb,wvdwsb,eelsb,welsb,esbloc,wsbloc,etors_nucl,wtor_nucl&
1117 etors_d_nucl,wtor_d_nucl,ecorr_nucl,wcorr_nucl,&
1118 ecorr3_nucl,wcorr3_nucl,ecation_prot,wcatprot,ecationcation,wcatcat, &
1119 escbase,wscbase,epepbase,wpepbase,escpho,wscpho,epeppho,wpeppho,&
1121 10 format (/'Virtual-chain energies:'// &
1122 'EVDW= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-SC)'/ &
1123 'EVDW2= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-p)'/ &
1124 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p)'/ &
1125 'ESTR= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching)'/ &
1126 'EBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (bending)'/ &
1127 'ESC= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/ &
1128 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/ &
1129 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/ &
1130 'EHBP= ',1pE16.6,' WEIGHT=',1pD16.6, &
1131 ' (SS bridges & dist. cnstr.)'/ &
1132 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
1133 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
1134 'ECORR6=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
1135 'EELLO= ',1pE16.6,' WEIGHT=',1pD16.6,' (electrostatic-local)'/ &
1136 'ETURN3=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 3rd order)'/ &
1137 'ETURN4=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 4th order)'/ &
1138 'ETURN6=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 6th order)'/ &
1139 'ESCCOR=',1pE16.6,' WEIGHT=',1pD16.6,' (backbone-rotamer corr)'/ &
1140 'EDIHC= ',1pE16.6,' (dihedral angle constraints)'/ &
1141 'ETHETC= ',1pE16.6,' (valence angle constraints)'/ &
1142 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/ &
1143 'UCONST=',1pE16.6,' (Constraint energy)'/ &
1144 'ELT=',1pE16.6, ' WEIGHT=',1pD16.6,' (Lipid transfer energy)'/ &
1145 'EAFM= ',1pE16.6,' (atomic-force microscopy)'/ &
1146 'ETUBE=',1pE16.6, ' WEIGHT=',1pD16.6,' (cylindrical energy)'/ &
1147 'ESTR_nucl= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching for nucleic)'/ &
1148 'EBE_nucl=',1pE16.6,' WEIGHT=',1pD16.6,' (bending for nucleic)'/ &
1149 'EVDW_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-phosphate VDW)'/ &
1150 'EESPP_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-phosphate elec)'/ &
1151 'EVDWPSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-sugarbase VDW)'/ &
1152 'EESPSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-sugarbase elec)'/ &
1153 'EVDWSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(sugarbase-sugarbase VDW)'/ &
1154 'EESSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(sugarbase-sugarbase elec)'/ &
1155 'ESBLOC_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(sugarbase rotamer)'/ &
1156 'ETORS_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(torsional)'/ &
1157 'ETORSD_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(double torsional)'/ &
1158 'ECORR_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(multibody 4th order)'/ &
1159 'ECORR3_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(multibody 3th order)'/ &
1160 'ECATPROT=',1pE16.6,' WEIGHT=',1pD16.6,'(cation prot)'/ &
1161 'ECATCAT=',1pE16.6,' WEIGHT=',1pD16.6,'(cation cation)'/ &
1162 'ESCBASE=',1pE16.6,' WEIGHT=',1pD16.6,'(sc-prot nucl-base)'/ &
1163 'EPEPBASE=',1pE16.6,' WEIGHT=',1pD16.6,'(pep-prot nucl-base)'/ &
1164 'ESCPHO=',1pE16.6,' WEIGHT=',1pD16.6,'(sc-prot nucl-phosphate)'/&
1165 'EPEPPHO=',1pE16.6,' WEIGHT=',1pD16.6,'(pep-prot nucl-phosphate)'/&
1166 'ETOT= ',1pE16.6,' (total)')
1169 end subroutine enerprint
1170 !-----------------------------------------------------------------------------
1171 subroutine elj(evdw)
1173 ! This subroutine calculates the interaction energy of nonbonded side chains
1174 ! assuming the LJ potential of interaction.
1176 ! implicit real*8 (a-h,o-z)
1177 ! include 'DIMENSIONS'
1178 real(kind=8),parameter :: accur=1.0d-10
1179 ! include 'COMMON.GEO'
1180 ! include 'COMMON.VAR'
1181 ! include 'COMMON.LOCAL'
1182 ! include 'COMMON.CHAIN'
1183 ! include 'COMMON.DERIV'
1184 ! include 'COMMON.INTERACT'
1185 ! include 'COMMON.TORSION'
1186 ! include 'COMMON.SBRIDGE'
1187 ! include 'COMMON.NAMES'
1188 ! include 'COMMON.IOUNITS'
1189 ! include 'COMMON.CONTACTS'
1190 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
1191 integer :: num_conti
1193 integer :: i,itypi,iint,j,itypi1,itypj,k
1194 real(kind=8) :: rij,rcut,fcont,fprimcont,rrij
1195 real(kind=8) :: evdw,xi,yi,zi,xj,yj,zj
1196 real(kind=8) :: eps0ij,fac,e1,e2,evdwij,sigij,r0ij
1198 ! write(iout,*)'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
1200 ! allocate(num_cont(iatsc_s:iatsc_e)) !(maxres) nnt,nct-2
1201 ! allocate(jcont(nres/4,iatsc_s:iatsc_e)) !(maxconts,maxres) (maxconts=maxres/4)
1202 ! allocate(facont(nres/4,iatsc_s:iatsc_e)) !(maxconts,maxres)
1203 ! allocate(gacont(3,nres/4,iatsc_s:iatsc_e)) !(3,maxconts,maxres)
1205 do i=iatsc_s,iatsc_e
1206 itypi=iabs(itype(i,1))
1207 if (itypi.eq.ntyp1) cycle
1208 itypi1=iabs(itype(i+1,1))
1215 ! Calculate SC interaction energy.
1217 do iint=1,nint_gr(i)
1218 !d write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
1219 !d & 'iend=',iend(i,iint)
1220 do j=istart(i,iint),iend(i,iint)
1221 itypj=iabs(itype(j,1))
1222 if (itypj.eq.ntyp1) cycle
1226 ! Change 12/1/95 to calculate four-body interactions
1227 rij=xj*xj+yj*yj+zj*zj
1229 ! write (iout,*)'i=',i,' j=',j,' itypi=',itypi,' itypj=',itypj
1230 eps0ij=eps(itypi,itypj)
1232 e1=fac*fac*aa_aq(itypi,itypj)
1233 e2=fac*bb_aq(itypi,itypj)
1235 !d sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1236 !d epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1237 !d write (iout,'(2(a3,i3,2x),6(1pd12.4)/2(3(1pd12.4),5x)/)')
1238 !d & restyp(itypi,1),i,restyp(itypj,1),j,aa(itypi,itypj),
1239 !d & bb(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,epsi,sigm,
1240 !d & (c(k,i),k=1,3),(c(k,j),k=1,3)
1243 ! Calculate the components of the gradient in DC and X
1245 fac=-rrij*(e1+evdwij)
1250 gvdwx(k,i)=gvdwx(k,i)-gg(k)
1251 gvdwx(k,j)=gvdwx(k,j)+gg(k)
1252 gvdwc(k,i)=gvdwc(k,i)-gg(k)
1253 gvdwc(k,j)=gvdwc(k,j)+gg(k)
1257 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
1261 ! 12/1/95, revised on 5/20/97
1263 ! Calculate the contact function. The ith column of the array JCONT will
1264 ! contain the numbers of atoms that make contacts with the atom I (of numbers
1265 ! greater than I). The arrays FACONT and GACONT will contain the values of
1266 ! the contact function and its derivative.
1268 ! Uncomment next line, if the correlation interactions include EVDW explicitly.
1269 ! if (j.gt.i+1 .and. evdwij.le.0.0D0) then
1270 ! Uncomment next line, if the correlation interactions are contact function only
1271 if (j.gt.i+1.and. eps0ij.gt.0.0D0) then
1273 sigij=sigma(itypi,itypj)
1274 r0ij=rs0(itypi,itypj)
1276 ! Check whether the SC's are not too far to make a contact.
1279 call gcont(rij,rcut,1.0d0,0.2d0*rcut,fcont,fprimcont)
1280 ! Add a new contact, if the SC's are close enough, but not too close (r<sigma).
1282 if (fcont.gt.0.0D0) then
1283 ! If the SC-SC distance if close to sigma, apply spline.
1284 !Adam call gcont(-rij,-1.03d0*sigij,2.0d0*sigij,1.0d0,
1285 !Adam & fcont1,fprimcont1)
1286 !Adam fcont1=1.0d0-fcont1
1287 !Adam if (fcont1.gt.0.0d0) then
1288 !Adam fprimcont=fprimcont*fcont1+fcont*fprimcont1
1289 !Adam fcont=fcont*fcont1
1291 ! Uncomment following 4 lines to have the geometric average of the epsilon0's
1292 !ga eps0ij=1.0d0/dsqrt(eps0ij)
1294 !ga gg(k)=gg(k)*eps0ij
1296 !ga eps0ij=-evdwij*eps0ij
1297 ! Uncomment for AL's type of SC correlation interactions.
1298 !adam eps0ij=-evdwij
1299 num_conti=num_conti+1
1300 jcont(num_conti,i)=j
1301 facont(num_conti,i)=fcont*eps0ij
1302 fprimcont=eps0ij*fprimcont/rij
1304 !Adam gacont(1,num_conti,i)=-fprimcont*xj+fcont*gg(1)
1305 !Adam gacont(2,num_conti,i)=-fprimcont*yj+fcont*gg(2)
1306 !Adam gacont(3,num_conti,i)=-fprimcont*zj+fcont*gg(3)
1307 ! Uncomment following 3 lines for Skolnick's type of SC correlation.
1308 gacont(1,num_conti,i)=-fprimcont*xj
1309 gacont(2,num_conti,i)=-fprimcont*yj
1310 gacont(3,num_conti,i)=-fprimcont*zj
1311 !d write (iout,'(2i5,2f10.5)') i,j,rij,facont(num_conti,i)
1312 !d write (iout,'(2i3,3f10.5)')
1313 !d & i,j,(gacont(kk,num_conti,i),kk=1,3)
1319 num_cont(i)=num_conti
1323 gvdwc(j,i)=expon*gvdwc(j,i)
1324 gvdwx(j,i)=expon*gvdwx(j,i)
1327 !******************************************************************************
1331 ! To save time, the factor of EXPON has been extracted from ALL components
1332 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
1335 !******************************************************************************
1338 !-----------------------------------------------------------------------------
1339 subroutine eljk(evdw)
1341 ! This subroutine calculates the interaction energy of nonbonded side chains
1342 ! assuming the LJK potential of interaction.
1344 ! implicit real*8 (a-h,o-z)
1345 ! include 'DIMENSIONS'
1346 ! include 'COMMON.GEO'
1347 ! include 'COMMON.VAR'
1348 ! include 'COMMON.LOCAL'
1349 ! include 'COMMON.CHAIN'
1350 ! include 'COMMON.DERIV'
1351 ! include 'COMMON.INTERACT'
1352 ! include 'COMMON.IOUNITS'
1353 ! include 'COMMON.NAMES'
1354 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
1357 integer :: i,iint,j,itypi,itypi1,k,itypj
1358 real(kind=8) :: rrij,xi,yi,zi,xj,yj,zj,fac_augm,e_augm,r_inv_ij
1359 real(kind=8) :: evdw,rij,r_shift_inv,fac,e1,e2,evdwij
1361 ! print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
1363 do i=iatsc_s,iatsc_e
1364 itypi=iabs(itype(i,1))
1365 if (itypi.eq.ntyp1) cycle
1366 itypi1=iabs(itype(i+1,1))
1371 ! Calculate SC interaction energy.
1373 do iint=1,nint_gr(i)
1374 do j=istart(i,iint),iend(i,iint)
1375 itypj=iabs(itype(j,1))
1376 if (itypj.eq.ntyp1) cycle
1380 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1381 fac_augm=rrij**expon
1382 e_augm=augm(itypi,itypj)*fac_augm
1383 r_inv_ij=dsqrt(rrij)
1385 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
1386 fac=r_shift_inv**expon
1387 e1=fac*fac*aa_aq(itypi,itypj)
1388 e2=fac*bb_aq(itypi,itypj)
1390 !d sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1391 !d epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1392 !d write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
1393 !d & restyp(itypi,1),i,restyp(itypj,1),j,aa(itypi,itypj),
1394 !d & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
1395 !d & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
1396 !d & (c(k,i),k=1,3),(c(k,j),k=1,3)
1399 ! Calculate the components of the gradient in DC and X
1401 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
1406 gvdwx(k,i)=gvdwx(k,i)-gg(k)
1407 gvdwx(k,j)=gvdwx(k,j)+gg(k)
1408 gvdwc(k,i)=gvdwc(k,i)-gg(k)
1409 gvdwc(k,j)=gvdwc(k,j)+gg(k)
1413 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
1421 gvdwc(j,i)=expon*gvdwc(j,i)
1422 gvdwx(j,i)=expon*gvdwx(j,i)
1427 !-----------------------------------------------------------------------------
1428 subroutine ebp(evdw)
1430 ! This subroutine calculates the interaction energy of nonbonded side chains
1431 ! assuming the Berne-Pechukas potential of interaction.
1435 ! implicit real*8 (a-h,o-z)
1436 ! include 'DIMENSIONS'
1437 ! include 'COMMON.GEO'
1438 ! include 'COMMON.VAR'
1439 ! include 'COMMON.LOCAL'
1440 ! include 'COMMON.CHAIN'
1441 ! include 'COMMON.DERIV'
1442 ! include 'COMMON.NAMES'
1443 ! include 'COMMON.INTERACT'
1444 ! include 'COMMON.IOUNITS'
1445 ! include 'COMMON.CALC'
1447 !el integer :: icall
1448 !el common /srutu/ icall
1449 ! double precision rrsave(maxdim)
1452 integer :: iint,itypi,itypi1,itypj
1453 real(kind=8) :: rrij,xi,yi,zi
1454 real(kind=8) :: evdw,fac,e1,e2,sigm,epsi
1456 ! print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
1458 ! if (icall.eq.0) then
1464 do i=iatsc_s,iatsc_e
1465 itypi=iabs(itype(i,1))
1466 if (itypi.eq.ntyp1) cycle
1467 itypi1=iabs(itype(i+1,1))
1471 dxi=dc_norm(1,nres+i)
1472 dyi=dc_norm(2,nres+i)
1473 dzi=dc_norm(3,nres+i)
1474 ! dsci_inv=dsc_inv(itypi)
1475 dsci_inv=vbld_inv(i+nres)
1477 ! Calculate SC interaction energy.
1479 do iint=1,nint_gr(i)
1480 do j=istart(i,iint),iend(i,iint)
1482 itypj=iabs(itype(j,1))
1483 if (itypj.eq.ntyp1) cycle
1484 ! dscj_inv=dsc_inv(itypj)
1485 dscj_inv=vbld_inv(j+nres)
1486 chi1=chi(itypi,itypj)
1487 chi2=chi(itypj,itypi)
1494 alf12=0.5D0*(alf1+alf2)
1495 ! For diagnostics only!!!
1508 dxj=dc_norm(1,nres+j)
1509 dyj=dc_norm(2,nres+j)
1510 dzj=dc_norm(3,nres+j)
1511 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1512 !d if (icall.eq.0) then
1518 ! Calculate the angle-dependent terms of energy & contributions to derivatives.
1520 ! Calculate whole angle-dependent part of epsilon and contributions
1521 ! to its derivatives
1522 fac=(rrij*sigsq)**expon2
1523 e1=fac*fac*aa_aq(itypi,itypj)
1524 e2=fac*bb_aq(itypi,itypj)
1525 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
1526 eps2der=evdwij*eps3rt
1527 eps3der=evdwij*eps2rt
1528 evdwij=evdwij*eps2rt*eps3rt
1531 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
1532 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
1533 !d write (iout,'(2(a3,i3,2x),15(0pf7.3))')
1534 !d & restyp(itypi,1),i,restyp(itypj,1),j,
1535 !d & epsi,sigm,chi1,chi2,chip1,chip2,
1536 !d & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
1537 !d & om1,om2,om12,1.0D0/dsqrt(rrij),
1540 ! Calculate gradient components.
1541 e1=e1*eps1*eps2rt**2*eps3rt**2
1542 fac=-expon*(e1+evdwij)
1545 ! Calculate radial part of the gradient
1549 ! Calculate the angular part of the gradient and sum add the contributions
1550 ! to the appropriate components of the Cartesian gradient.
1558 !-----------------------------------------------------------------------------
1559 subroutine egb(evdw)
1561 ! This subroutine calculates the interaction energy of nonbonded side chains
1562 ! assuming the Gay-Berne potential of interaction.
1565 ! implicit real*8 (a-h,o-z)
1566 ! include 'DIMENSIONS'
1567 ! include 'COMMON.GEO'
1568 ! include 'COMMON.VAR'
1569 ! include 'COMMON.LOCAL'
1570 ! include 'COMMON.CHAIN'
1571 ! include 'COMMON.DERIV'
1572 ! include 'COMMON.NAMES'
1573 ! include 'COMMON.INTERACT'
1574 ! include 'COMMON.IOUNITS'
1575 ! include 'COMMON.CALC'
1576 ! include 'COMMON.CONTROL'
1577 ! include 'COMMON.SBRIDGE'
1580 integer :: iint,itypi,itypi1,itypj,subchap
1581 real(kind=8) :: rrij,xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
1582 real(kind=8) :: evdw,sig0ij
1583 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
1584 dist_temp, dist_init,aa,bb,ssgradlipi,ssgradlipj, &
1585 sslipi,sslipj,faclip
1587 real(kind=8) :: fracinbuf
1589 !cccc energy_dec=.false.
1590 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
1593 ! if (icall.eq.0) lprn=.false.
1595 do i=iatsc_s,iatsc_e
1596 !C print *,"I am in EVDW",i
1597 itypi=iabs(itype(i,1))
1598 ! if (i.ne.47) cycle
1599 if (itypi.eq.ntyp1) cycle
1600 itypi1=iabs(itype(i+1,1))
1604 xi=dmod(xi,boxxsize)
1605 if (xi.lt.0) xi=xi+boxxsize
1606 yi=dmod(yi,boxysize)
1607 if (yi.lt.0) yi=yi+boxysize
1608 zi=dmod(zi,boxzsize)
1609 if (zi.lt.0) zi=zi+boxzsize
1611 if ((zi.gt.bordlipbot) &
1612 .and.(zi.lt.bordliptop)) then
1613 !C the energy transfer exist
1614 if (zi.lt.buflipbot) then
1615 !C what fraction I am in
1617 ((zi-bordlipbot)/lipbufthick)
1618 !C lipbufthick is thickenes of lipid buffore
1619 sslipi=sscalelip(fracinbuf)
1620 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
1621 elseif (zi.gt.bufliptop) then
1622 fracinbuf=1.0d0-((bordliptop-zi)/lipbufthick)
1623 sslipi=sscalelip(fracinbuf)
1624 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
1633 ! print *, sslipi,ssgradlipi
1634 dxi=dc_norm(1,nres+i)
1635 dyi=dc_norm(2,nres+i)
1636 dzi=dc_norm(3,nres+i)
1637 ! dsci_inv=dsc_inv(itypi)
1638 dsci_inv=vbld_inv(i+nres)
1639 ! write (iout,*) "i",i,dsc_inv(itypi),dsci_inv,1.0d0/vbld(i+nres)
1640 ! write (iout,*) "dcnori",dxi*dxi+dyi*dyi+dzi*dzi
1642 ! Calculate SC interaction energy.
1644 do iint=1,nint_gr(i)
1645 do j=istart(i,iint),iend(i,iint)
1646 IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
1647 call dyn_ssbond_ene(i,j,evdwij)
1649 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
1650 'evdw',i,j,evdwij,' ss'
1651 ! if (energy_dec) write (iout,*) &
1652 ! 'evdw',i,j,evdwij,' ss'
1653 do k=j+1,iend(i,iint)
1654 !C search over all next residues
1655 if (dyn_ss_mask(k)) then
1656 !C check if they are cysteins
1657 !C write(iout,*) 'k=',k
1659 !c write(iout,*) "PRZED TRI", evdwij
1660 ! evdwij_przed_tri=evdwij
1661 call triple_ssbond_ene(i,j,k,evdwij)
1662 !c if(evdwij_przed_tri.ne.evdwij) then
1663 !c write (iout,*) "TRI:", evdwij, evdwij_przed_tri
1666 !c write(iout,*) "PO TRI", evdwij
1667 !C call the energy function that removes the artifical triple disulfide
1668 !C bond the soubroutine is located in ssMD.F
1670 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
1671 'evdw',i,j,evdwij,'tss'
1672 endif!dyn_ss_mask(k)
1676 itypj=iabs(itype(j,1))
1677 if (itypj.eq.ntyp1) cycle
1678 ! if (j.ne.78) cycle
1679 ! dscj_inv=dsc_inv(itypj)
1680 dscj_inv=vbld_inv(j+nres)
1681 ! write (iout,*) "j",j,dsc_inv(itypj),dscj_inv,&
1682 ! 1.0d0/vbld(j+nres) !d
1683 ! write (iout,*) "i",i," j", j," itype",itype(i,1),itype(j,1)
1684 sig0ij=sigma(itypi,itypj)
1685 chi1=chi(itypi,itypj)
1686 chi2=chi(itypj,itypi)
1693 alf12=0.5D0*(alf1+alf2)
1694 ! For diagnostics only!!!
1707 xj=dmod(xj,boxxsize)
1708 if (xj.lt.0) xj=xj+boxxsize
1709 yj=dmod(yj,boxysize)
1710 if (yj.lt.0) yj=yj+boxysize
1711 zj=dmod(zj,boxzsize)
1712 if (zj.lt.0) zj=zj+boxzsize
1713 ! print *,"tu",xi,yi,zi,xj,yj,zj
1714 ! print *,"tu2",j,j+nres,c(1,j),c(1,j+nres)
1715 ! this fragment set correct epsilon for lipid phase
1716 if ((zj.gt.bordlipbot) &
1717 .and.(zj.lt.bordliptop)) then
1718 !C the energy transfer exist
1719 if (zj.lt.buflipbot) then
1720 !C what fraction I am in
1722 ((zj-bordlipbot)/lipbufthick)
1723 !C lipbufthick is thickenes of lipid buffore
1724 sslipj=sscalelip(fracinbuf)
1725 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
1726 elseif (zj.gt.bufliptop) then
1727 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
1728 sslipj=sscalelip(fracinbuf)
1729 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
1738 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
1739 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
1740 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
1741 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
1742 !------------------------------------------------
1743 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
1751 xj=xj_safe+xshift*boxxsize
1752 yj=yj_safe+yshift*boxysize
1753 zj=zj_safe+zshift*boxzsize
1754 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
1755 if(dist_temp.lt.dist_init) then
1765 if (subchap.eq.1) then
1774 dxj=dc_norm(1,nres+j)
1775 dyj=dc_norm(2,nres+j)
1776 dzj=dc_norm(3,nres+j)
1777 ! write (iout,*) "dcnorj",dxi*dxi+dyi*dyi+dzi*dzi
1778 ! write (iout,*) "j",j," dc_norm",& !d
1779 ! dc_norm(1,nres+j),dc_norm(2,nres+j),dc_norm(3,nres+j)
1780 ! write(iout,*)"rrij ",rrij
1781 ! write(iout,*)"xj yj zj ", xj, yj, zj
1782 ! write(iout,*)"xi yi zi ", xi, yi, zi
1783 ! write(iout,*)"c ", c(1,:), c(2,:), c(3,:)
1784 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1786 sss_ele_cut=sscale_ele(1.0d0/(rij*sigma(itypi,itypj)))
1787 sss_ele_grad=sscagrad_ele(1.0d0/(rij*sigma(itypi,itypj)))
1788 ! print *,sss_ele_cut,sss_ele_grad,&
1789 ! 1.0d0/(rij),r_cut_ele,rlamb_ele
1790 if (sss_ele_cut.le.0.0) cycle
1791 ! Calculate angle-dependent terms of energy and contributions to their
1795 sig=sig0ij*dsqrt(sigsq)
1796 rij_shift=1.0D0/rij-sig+sig0ij
1797 ! write(iout,*)" rij_shift",rij_shift," rij",rij," sig",sig,&
1799 ! for diagnostics; uncomment
1800 ! rij_shift=1.2*sig0ij
1801 ! I hate to put IF's in the loops, but here don't have another choice!!!!
1802 if (rij_shift.le.0.0D0) then
1804 !d write (iout,'(2(a3,i3,2x),17(0pf7.3))')
1805 !d & restyp(itypi,1),i,restyp(itypj,1),j,
1806 !d & rij_shift,1.0D0/rij,sig,sig0ij,sigsq,1-dsqrt(sigsq)
1810 !---------------------------------------------------------------
1811 rij_shift=1.0D0/rij_shift
1812 fac=rij_shift**expon
1814 e1=fac*fac*aa!(itypi,itypj)
1815 e2=fac*bb!(itypi,itypj)
1816 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
1817 eps2der=evdwij*eps3rt
1818 eps3der=evdwij*eps2rt
1819 ! write(iout,*)"aa, bb ",aa(:,:),bb(:,:)
1820 ! write (iout,*) "sigsq",sigsq," sig",sig," eps2rt",eps2rt,& !d
1821 ! " eps3rt",eps3rt," eps1",eps1," e1",e1," e2",e2," fac",fac !d
1822 evdwij=evdwij*eps2rt*eps3rt
1823 evdw=evdw+evdwij*sss_ele_cut
1825 sigm=dabs(aa/bb)**(1.0D0/6.0D0)
1826 epsi=bb**2/aa!(itypi,itypj)
1827 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
1828 restyp(itypi,1),i,restyp(itypj,1),j, &
1829 epsi,sigm,chi1,chi2,chip1,chip2, &
1830 eps1,eps2rt**2,eps3rt**2,sig,sig0ij, &
1831 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift, &
1835 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,2e10.2,e11.3)')&
1836 'evdw',i,j,evdwij,xi,xj,rij !,"egb"
1837 !C print *,i,j,c(1,i),c(1,j),c(2,i),c(2,j),c(3,i),c(3,j)
1838 ! if (energy_dec) write (iout,*) &
1840 ! print *,"ZALAMKA", evdw
1842 ! Calculate gradient components.
1843 e1=e1*eps1*eps2rt**2*eps3rt**2
1844 fac=-expon*(e1+evdwij)*rij_shift
1847 ! print *,'before fac',fac,rij,evdwij
1848 fac=fac+evdwij*sss_ele_grad/sss_ele_cut&
1849 /sigma(itypi,itypj)*rij
1850 ! print *,'grad part scale',fac, &
1851 ! evdwij*sss_ele_grad/sss_ele_cut &
1852 ! /sigma(itypi,itypj)*rij
1854 ! Calculate the radial part of the gradient
1858 !C Calculate the radial part of the gradient
1859 gg_lipi(3)=eps1*(eps2rt*eps2rt)&
1860 *(eps3rt*eps3rt)*sss_ele_cut/2.0d0*(faclip*faclip*&
1861 (aa_lip(itypi,itypj)-aa_aq(itypi,itypj))&
1862 +faclip*(bb_lip(itypi,itypj)-bb_aq(itypi,itypj)))
1863 gg_lipj(3)=ssgradlipj*gg_lipi(3)
1864 gg_lipi(3)=gg_lipi(3)*ssgradlipi
1866 ! print *,'before sc_grad', gg(1),gg(2),gg(3)
1867 ! Calculate angular part of the gradient.
1873 ! print *,"ZALAMKA", evdw
1874 ! write (iout,*) "Number of loop steps in EGB:",ind
1875 !ccc energy_dec=.false.
1878 !-----------------------------------------------------------------------------
1879 subroutine egbv(evdw)
1881 ! This subroutine calculates the interaction energy of nonbonded side chains
1882 ! assuming the Gay-Berne-Vorobjev potential of interaction.
1886 ! implicit real*8 (a-h,o-z)
1887 ! include 'DIMENSIONS'
1888 ! include 'COMMON.GEO'
1889 ! include 'COMMON.VAR'
1890 ! include 'COMMON.LOCAL'
1891 ! include 'COMMON.CHAIN'
1892 ! include 'COMMON.DERIV'
1893 ! include 'COMMON.NAMES'
1894 ! include 'COMMON.INTERACT'
1895 ! include 'COMMON.IOUNITS'
1896 ! include 'COMMON.CALC'
1898 !el integer :: icall
1899 !el common /srutu/ icall
1902 integer :: iint,itypi,itypi1,itypj
1903 real(kind=8) :: rrij,xi,yi,zi,r0ij,fac_augm,e_augm,fac,e1,e2,sigm
1904 real(kind=8) :: evdw,sig0ij,sig,rij_shift,epsi
1906 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
1909 ! if (icall.eq.0) lprn=.true.
1911 do i=iatsc_s,iatsc_e
1912 itypi=iabs(itype(i,1))
1913 if (itypi.eq.ntyp1) cycle
1914 itypi1=iabs(itype(i+1,1))
1918 dxi=dc_norm(1,nres+i)
1919 dyi=dc_norm(2,nres+i)
1920 dzi=dc_norm(3,nres+i)
1921 ! dsci_inv=dsc_inv(itypi)
1922 dsci_inv=vbld_inv(i+nres)
1924 ! Calculate SC interaction energy.
1926 do iint=1,nint_gr(i)
1927 do j=istart(i,iint),iend(i,iint)
1929 itypj=iabs(itype(j,1))
1930 if (itypj.eq.ntyp1) cycle
1931 ! dscj_inv=dsc_inv(itypj)
1932 dscj_inv=vbld_inv(j+nres)
1933 sig0ij=sigma(itypi,itypj)
1934 r0ij=r0(itypi,itypj)
1935 chi1=chi(itypi,itypj)
1936 chi2=chi(itypj,itypi)
1943 alf12=0.5D0*(alf1+alf2)
1944 ! For diagnostics only!!!
1957 dxj=dc_norm(1,nres+j)
1958 dyj=dc_norm(2,nres+j)
1959 dzj=dc_norm(3,nres+j)
1960 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1962 ! Calculate angle-dependent terms of energy and contributions to their
1966 sig=sig0ij*dsqrt(sigsq)
1967 rij_shift=1.0D0/rij-sig+r0ij
1968 ! I hate to put IF's in the loops, but here don't have another choice!!!!
1969 if (rij_shift.le.0.0D0) then
1974 !---------------------------------------------------------------
1975 rij_shift=1.0D0/rij_shift
1976 fac=rij_shift**expon
1977 e1=fac*fac*aa_aq(itypi,itypj)
1978 e2=fac*bb_aq(itypi,itypj)
1979 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
1980 eps2der=evdwij*eps3rt
1981 eps3der=evdwij*eps2rt
1982 fac_augm=rrij**expon
1983 e_augm=augm(itypi,itypj)*fac_augm
1984 evdwij=evdwij*eps2rt*eps3rt
1985 evdw=evdw+evdwij+e_augm
1987 sigm=dabs(aa_aq(itypi,itypj)/&
1988 bb_aq(itypi,itypj))**(1.0D0/6.0D0)
1989 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
1990 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
1991 restyp(itypi,1),i,restyp(itypj,1),j,&
1992 epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),&
1993 chi1,chi2,chip1,chip2,&
1994 eps1,eps2rt**2,eps3rt**2,&
1995 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
1998 ! Calculate gradient components.
1999 e1=e1*eps1*eps2rt**2*eps3rt**2
2000 fac=-expon*(e1+evdwij)*rij_shift
2002 fac=rij*fac-2*expon*rrij*e_augm
2003 ! Calculate the radial part of the gradient
2007 ! Calculate angular part of the gradient.
2013 !-----------------------------------------------------------------------------
2014 !el subroutine sc_angular in module geometry
2015 !-----------------------------------------------------------------------------
2016 subroutine e_softsphere(evdw)
2018 ! This subroutine calculates the interaction energy of nonbonded side chains
2019 ! assuming the LJ potential of interaction.
2021 ! implicit real*8 (a-h,o-z)
2022 ! include 'DIMENSIONS'
2023 real(kind=8),parameter :: accur=1.0d-10
2024 ! include 'COMMON.GEO'
2025 ! include 'COMMON.VAR'
2026 ! include 'COMMON.LOCAL'
2027 ! include 'COMMON.CHAIN'
2028 ! include 'COMMON.DERIV'
2029 ! include 'COMMON.INTERACT'
2030 ! include 'COMMON.TORSION'
2031 ! include 'COMMON.SBRIDGE'
2032 ! include 'COMMON.NAMES'
2033 ! include 'COMMON.IOUNITS'
2034 ! include 'COMMON.CONTACTS'
2035 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
2036 !d print *,'Entering Esoft_sphere nnt=',nnt,' nct=',nct
2038 integer :: i,iint,j,itypi,itypi1,itypj,k
2039 real(kind=8) :: evdw,xj,yj,zj,xi,yi,zi,rij,r0ij,r0ijsq,evdwij
2043 do i=iatsc_s,iatsc_e
2044 itypi=iabs(itype(i,1))
2045 if (itypi.eq.ntyp1) cycle
2046 itypi1=iabs(itype(i+1,1))
2051 ! Calculate SC interaction energy.
2053 do iint=1,nint_gr(i)
2054 !d write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
2055 !d & 'iend=',iend(i,iint)
2056 do j=istart(i,iint),iend(i,iint)
2057 itypj=iabs(itype(j,1))
2058 if (itypj.eq.ntyp1) cycle
2062 rij=xj*xj+yj*yj+zj*zj
2063 ! write (iout,*)'i=',i,' j=',j,' itypi=',itypi,' itypj=',itypj
2064 r0ij=r0(itypi,itypj)
2066 ! print *,i,j,r0ij,dsqrt(rij)
2067 if (rij.lt.r0ijsq) then
2068 evdwij=0.25d0*(rij-r0ijsq)**2
2076 ! Calculate the components of the gradient in DC and X
2082 gvdwx(k,i)=gvdwx(k,i)-gg(k)
2083 gvdwx(k,j)=gvdwx(k,j)+gg(k)
2084 gvdwc(k,i)=gvdwc(k,i)-gg(k)
2085 gvdwc(k,j)=gvdwc(k,j)+gg(k)
2089 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
2096 end subroutine e_softsphere
2097 !-----------------------------------------------------------------------------
2098 subroutine eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
2100 ! Soft-sphere potential of p-p interaction
2102 ! implicit real*8 (a-h,o-z)
2103 ! include 'DIMENSIONS'
2104 ! include 'COMMON.CONTROL'
2105 ! include 'COMMON.IOUNITS'
2106 ! include 'COMMON.GEO'
2107 ! include 'COMMON.VAR'
2108 ! include 'COMMON.LOCAL'
2109 ! include 'COMMON.CHAIN'
2110 ! include 'COMMON.DERIV'
2111 ! include 'COMMON.INTERACT'
2112 ! include 'COMMON.CONTACTS'
2113 ! include 'COMMON.TORSION'
2114 ! include 'COMMON.VECTORS'
2115 ! include 'COMMON.FFIELD'
2116 real(kind=8),dimension(3) :: ggg
2117 !d write(iout,*) 'In EELEC_soft_sphere'
2119 integer :: i,j,k,num_conti,iteli,itelj
2120 real(kind=8) :: ees,evdw1,eel_loc,eello_turn3,eello_turn4
2121 real(kind=8) :: dxi,dyi,dzi,xmedi,ymedi,zmedi,r0ij,r0ijsq
2122 real(kind=8) :: dxj,dyj,dzj,xj,yj,zj,rij,evdw1ij,fac
2130 do i=iatel_s,iatel_e
2131 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
2135 xmedi=c(1,i)+0.5d0*dxi
2136 ymedi=c(2,i)+0.5d0*dyi
2137 zmedi=c(3,i)+0.5d0*dzi
2139 ! write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
2140 do j=ielstart(i),ielend(i)
2141 if (itype(j,1).eq.ntyp1 .or. itype(j+1,1).eq.ntyp1) cycle
2145 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
2146 r0ij=rpp(iteli,itelj)
2151 xj=c(1,j)+0.5D0*dxj-xmedi
2152 yj=c(2,j)+0.5D0*dyj-ymedi
2153 zj=c(3,j)+0.5D0*dzj-zmedi
2154 rij=xj*xj+yj*yj+zj*zj
2155 if (rij.lt.r0ijsq) then
2156 evdw1ij=0.25d0*(rij-r0ijsq)**2
2164 ! Calculate contributions to the Cartesian gradient.
2170 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
2171 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
2174 ! Loop over residues i+1 thru j-1.
2178 !grad gelc(l,k)=gelc(l,k)+ggg(l)
2183 !grad do i=nnt,nct-1
2185 !grad gelc(k,i)=gelc(k,i)+0.5d0*gelc(k,i)
2187 !grad do j=i+1,nct-1
2189 !grad gelc(k,i)=gelc(k,i)+gelc(k,j)
2194 end subroutine eelec_soft_sphere
2195 !-----------------------------------------------------------------------------
2196 subroutine vec_and_deriv
2197 ! implicit real*8 (a-h,o-z)
2198 ! include 'DIMENSIONS'
2202 ! include 'COMMON.IOUNITS'
2203 ! include 'COMMON.GEO'
2204 ! include 'COMMON.VAR'
2205 ! include 'COMMON.LOCAL'
2206 ! include 'COMMON.CHAIN'
2207 ! include 'COMMON.VECTORS'
2208 ! include 'COMMON.SETUP'
2209 ! include 'COMMON.TIME1'
2210 real(kind=8),dimension(3,3,2) :: uyder,uzder
2211 real(kind=8),dimension(2) :: vbld_inv_temp
2212 ! Compute the local reference systems. For reference system (i), the
2213 ! X-axis points from CA(i) to CA(i+1), the Y axis is in the
2214 ! CA(i)-CA(i+1)-CA(i+2) plane, and the Z axis is perpendicular to this plane.
2217 real(kind=8) :: facy,fac,costh
2220 do i=ivec_start,ivec_end
2224 if (i.eq.nres-1) then
2225 ! Case of the last full residue
2226 ! Compute the Z-axis
2227 call vecpr(dc_norm(1,i),dc_norm(1,i-1),uz(1,i))
2228 costh=dcos(pi-theta(nres))
2229 fac=1.0d0/dsqrt(1.0d0-costh*costh)
2233 ! Compute the derivatives of uz
2235 uzder(2,1,1)=-dc_norm(3,i-1)
2236 uzder(3,1,1)= dc_norm(2,i-1)
2237 uzder(1,2,1)= dc_norm(3,i-1)
2239 uzder(3,2,1)=-dc_norm(1,i-1)
2240 uzder(1,3,1)=-dc_norm(2,i-1)
2241 uzder(2,3,1)= dc_norm(1,i-1)
2244 uzder(2,1,2)= dc_norm(3,i)
2245 uzder(3,1,2)=-dc_norm(2,i)
2246 uzder(1,2,2)=-dc_norm(3,i)
2248 uzder(3,2,2)= dc_norm(1,i)
2249 uzder(1,3,2)= dc_norm(2,i)
2250 uzder(2,3,2)=-dc_norm(1,i)
2252 ! Compute the Y-axis
2255 uy(k,i)=fac*(dc_norm(k,i-1)-costh*dc_norm(k,i))
2257 ! Compute the derivatives of uy
2260 uyder(k,j,1)=2*dc_norm(k,i-1)*dc_norm(j,i) &
2261 -dc_norm(k,i)*dc_norm(j,i-1)
2262 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
2264 uyder(j,j,1)=uyder(j,j,1)-costh
2265 uyder(j,j,2)=1.0d0+uyder(j,j,2)
2270 uygrad(l,k,j,i)=uyder(l,k,j)
2271 uzgrad(l,k,j,i)=uzder(l,k,j)
2275 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
2276 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
2277 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
2278 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
2281 ! Compute the Z-axis
2282 call vecpr(dc_norm(1,i),dc_norm(1,i+1),uz(1,i))
2283 costh=dcos(pi-theta(i+2))
2284 fac=1.0d0/dsqrt(1.0d0-costh*costh)
2288 ! Compute the derivatives of uz
2290 uzder(2,1,1)=-dc_norm(3,i+1)
2291 uzder(3,1,1)= dc_norm(2,i+1)
2292 uzder(1,2,1)= dc_norm(3,i+1)
2294 uzder(3,2,1)=-dc_norm(1,i+1)
2295 uzder(1,3,1)=-dc_norm(2,i+1)
2296 uzder(2,3,1)= dc_norm(1,i+1)
2299 uzder(2,1,2)= dc_norm(3,i)
2300 uzder(3,1,2)=-dc_norm(2,i)
2301 uzder(1,2,2)=-dc_norm(3,i)
2303 uzder(3,2,2)= dc_norm(1,i)
2304 uzder(1,3,2)= dc_norm(2,i)
2305 uzder(2,3,2)=-dc_norm(1,i)
2307 ! Compute the Y-axis
2310 uy(k,i)=facy*(dc_norm(k,i+1)-costh*dc_norm(k,i))
2312 ! Compute the derivatives of uy
2315 uyder(k,j,1)=2*dc_norm(k,i+1)*dc_norm(j,i) &
2316 -dc_norm(k,i)*dc_norm(j,i+1)
2317 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
2319 uyder(j,j,1)=uyder(j,j,1)-costh
2320 uyder(j,j,2)=1.0d0+uyder(j,j,2)
2325 uygrad(l,k,j,i)=uyder(l,k,j)
2326 uzgrad(l,k,j,i)=uzder(l,k,j)
2330 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
2331 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
2332 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
2333 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
2337 vbld_inv_temp(1)=vbld_inv(i+1)
2338 if (i.lt.nres-1) then
2339 vbld_inv_temp(2)=vbld_inv(i+2)
2341 vbld_inv_temp(2)=vbld_inv(i)
2346 uygrad(l,k,j,i)=vbld_inv_temp(j)*uygrad(l,k,j,i)
2347 uzgrad(l,k,j,i)=vbld_inv_temp(j)*uzgrad(l,k,j,i)
2352 #if defined(PARVEC) && defined(MPI)
2353 if (nfgtasks1.gt.1) then
2355 ! print *,"Processor",fg_rank1,kolor1," ivec_start",ivec_start,
2356 ! & " ivec_displ",(ivec_displ(i),i=0,nfgtasks1-1),
2357 ! & " ivec_count",(ivec_count(i),i=0,nfgtasks1-1)
2358 call MPI_Allgatherv(uy(1,ivec_start),ivec_count(fg_rank1),&
2359 MPI_UYZ,uy(1,1),ivec_count(0),ivec_displ(0),MPI_UYZ,&
2361 call MPI_Allgatherv(uz(1,ivec_start),ivec_count(fg_rank1),&
2362 MPI_UYZ,uz(1,1),ivec_count(0),ivec_displ(0),MPI_UYZ,&
2364 call MPI_Allgatherv(uygrad(1,1,1,ivec_start),&
2365 ivec_count(fg_rank1),MPI_UYZGRAD,uygrad(1,1,1,1),ivec_count(0),&
2366 ivec_displ(0),MPI_UYZGRAD,FG_COMM1,IERR)
2367 call MPI_Allgatherv(uzgrad(1,1,1,ivec_start),&
2368 ivec_count(fg_rank1),MPI_UYZGRAD,uzgrad(1,1,1,1),ivec_count(0),&
2369 ivec_displ(0),MPI_UYZGRAD,FG_COMM1,IERR)
2370 time_gather=time_gather+MPI_Wtime()-time00
2372 ! if (fg_rank.eq.0) then
2373 ! write (iout,*) "Arrays UY and UZ"
2375 ! write (iout,'(i5,3f10.5,5x,3f10.5)') i,(uy(k,i),k=1,3),
2381 end subroutine vec_and_deriv
2382 !-----------------------------------------------------------------------------
2383 subroutine check_vecgrad
2384 ! implicit real*8 (a-h,o-z)
2385 ! include 'DIMENSIONS'
2386 ! include 'COMMON.IOUNITS'
2387 ! include 'COMMON.GEO'
2388 ! include 'COMMON.VAR'
2389 ! include 'COMMON.LOCAL'
2390 ! include 'COMMON.CHAIN'
2391 ! include 'COMMON.VECTORS'
2392 real(kind=8),dimension(3,3,2,nres) :: uygradt,uzgradt !(3,3,2,maxres)
2393 real(kind=8),dimension(3,nres) :: uyt,uzt !(3,maxres)
2394 real(kind=8),dimension(3,3,2) :: uygradn,uzgradn
2395 real(kind=8),dimension(3) :: erij
2396 real(kind=8) :: delta=1.0d-7
2402 !rc write(iout,'(2i5,2(3f10.5,5x))') i,1,dc_norm(:,i)
2403 !rc write(iout,'(2i5,2(3f10.5,5x))') i,2,uy(:,i)
2404 !rc write(iout,'(2i5,2(3f10.5,5x)/)')i,3,uz(:,i)
2405 !d write(iout,'(2i5,2(3f10.5,5x))') i,1,
2406 !d & (dc_norm(if90,i),if90=1,3)
2407 !d write(iout,'(2i5,2(3f10.5,5x))') i,2,(uy(if90,i),if90=1,3)
2408 !d write(iout,'(2i5,2(3f10.5,5x)/)')i,3,(uz(if90,i),if90=1,3)
2409 !d write(iout,'(a)')
2415 uygradt(l,k,j,i)=uygrad(l,k,j,i)
2416 uzgradt(l,k,j,i)=uzgrad(l,k,j,i)
2429 !d write (iout,*) 'i=',i
2431 erij(k)=dc_norm(k,i)
2435 dc_norm(k,i)=erij(k)
2437 dc_norm(j,i)=dc_norm(j,i)+delta
2438 ! fac=dsqrt(scalar(dc_norm(1,i),dc_norm(1,i)))
2440 ! dc_norm(k,i)=dc_norm(k,i)/fac
2442 ! write (iout,*) (dc_norm(k,i),k=1,3)
2443 ! write (iout,*) (erij(k),k=1,3)
2446 uygradn(k,j,1)=(uy(k,i)-uyt(k,i))/delta
2447 uygradn(k,j,2)=(uy(k,i-1)-uyt(k,i-1))/delta
2448 uzgradn(k,j,1)=(uz(k,i)-uzt(k,i))/delta
2449 uzgradn(k,j,2)=(uz(k,i-1)-uzt(k,i-1))/delta
2451 ! write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2452 ! & j,(uzgradt(k,j,1,i),k=1,3),(uzgradn(k,j,1),k=1,3),
2453 ! & (uzgradt(k,j,2,i-1),k=1,3),(uzgradn(k,j,2),k=1,3)
2456 dc_norm(k,i)=erij(k)
2459 !d write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2460 !d & k,(uygradt(k,l,1,i),l=1,3),(uygradn(k,l,1),l=1,3),
2461 !d & (uygradt(k,l,2,i-1),l=1,3),(uygradn(k,l,2),l=1,3)
2462 !d write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2463 !d & k,(uzgradt(k,l,1,i),l=1,3),(uzgradn(k,l,1),l=1,3),
2464 !d & (uzgradt(k,l,2,i-1),l=1,3),(uzgradn(k,l,2),l=1,3)
2465 !d write (iout,'(a)')
2469 end subroutine check_vecgrad
2470 !-----------------------------------------------------------------------------
2471 subroutine set_matrices
2472 ! implicit real*8 (a-h,o-z)
2473 ! include 'DIMENSIONS'
2476 ! include "COMMON.SETUP"
2478 integer :: status(MPI_STATUS_SIZE)
2480 ! include 'COMMON.IOUNITS'
2481 ! include 'COMMON.GEO'
2482 ! include 'COMMON.VAR'
2483 ! include 'COMMON.LOCAL'
2484 ! include 'COMMON.CHAIN'
2485 ! include 'COMMON.DERIV'
2486 ! include 'COMMON.INTERACT'
2487 ! include 'COMMON.CONTACTS'
2488 ! include 'COMMON.TORSION'
2489 ! include 'COMMON.VECTORS'
2490 ! include 'COMMON.FFIELD'
2491 real(kind=8) :: auxvec(2),auxmat(2,2)
2492 integer :: i,iti1,iti,k,l
2493 real(kind=8) :: sin1,cos1,sin2,cos2,dwacos2,dwasin2
2494 ! print *,"in set matrices"
2496 ! Compute the virtual-bond-torsional-angle dependent quantities needed
2497 ! to calculate the el-loc multibody terms of various order.
2501 do i=ivec_start+2,ivec_end+2
2506 if (i .lt. nres+1) then
2543 if (i .gt. 3 .and. i .lt. nres+1) then
2544 obrot_der(1,i-2)=-sin1
2545 obrot_der(2,i-2)= cos1
2546 Ugder(1,1,i-2)= sin1
2547 Ugder(1,2,i-2)=-cos1
2548 Ugder(2,1,i-2)=-cos1
2549 Ugder(2,2,i-2)=-sin1
2552 obrot2_der(1,i-2)=-dwasin2
2553 obrot2_der(2,i-2)= dwacos2
2554 Ug2der(1,1,i-2)= dwasin2
2555 Ug2der(1,2,i-2)=-dwacos2
2556 Ug2der(2,1,i-2)=-dwacos2
2557 Ug2der(2,2,i-2)=-dwasin2
2559 obrot_der(1,i-2)=0.0d0
2560 obrot_der(2,i-2)=0.0d0
2561 Ugder(1,1,i-2)=0.0d0
2562 Ugder(1,2,i-2)=0.0d0
2563 Ugder(2,1,i-2)=0.0d0
2564 Ugder(2,2,i-2)=0.0d0
2565 obrot2_der(1,i-2)=0.0d0
2566 obrot2_der(2,i-2)=0.0d0
2567 Ug2der(1,1,i-2)=0.0d0
2568 Ug2der(1,2,i-2)=0.0d0
2569 Ug2der(2,1,i-2)=0.0d0
2570 Ug2der(2,2,i-2)=0.0d0
2572 ! if (i.gt. iatel_s+2 .and. i.lt.iatel_e+5) then
2573 if (i.gt. nnt+2 .and. i.lt.nct+2) then
2574 iti = itortyp(itype(i-2,1))
2578 ! if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
2579 if (i.gt. nnt+1 .and. i.lt.nct+1) then
2580 iti1 = itortyp(itype(i-1,1))
2584 ! print *,iti,i,"iti",iti1,itype(i-1,1),itype(i-2,1)
2585 !d write (iout,*) '*******i',i,' iti1',iti
2586 !d write (iout,*) 'b1',b1(:,iti)
2587 !d write (iout,*) 'b2',b2(:,iti)
2588 !d write (iout,*) 'Ug',Ug(:,:,i-2)
2589 ! if (i .gt. iatel_s+2) then
2590 if (i .gt. nnt+2) then
2591 call matvec2(Ug(1,1,i-2),b2(1,iti),Ub2(1,i-2))
2592 call matmat2(EE(1,1,iti),Ug(1,1,i-2),EUg(1,1,i-2))
2593 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) &
2595 call matmat2(CC(1,1,iti),Ug(1,1,i-2),CUg(1,1,i-2))
2596 call matmat2(DD(1,1,iti),Ug(1,1,i-2),DUg(1,1,i-2))
2597 call matmat2(Dtilde(1,1,iti),Ug2(1,1,i-2),DtUg2(1,1,i-2))
2598 call matvec2(Ctilde(1,1,iti1),obrot(1,i-2),Ctobr(1,i-2))
2599 call matvec2(Dtilde(1,1,iti),obrot2(1,i-2),Dtobr2(1,i-2))
2610 DtUg2(l,k,i-2)=0.0d0
2614 call matvec2(Ugder(1,1,i-2),b2(1,iti),Ub2der(1,i-2))
2615 call matmat2(EE(1,1,iti),Ugder(1,1,i-2),EUgder(1,1,i-2))
2617 muder(k,i-2)=Ub2der(k,i-2)
2619 ! if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
2620 if (i.gt. nnt+1 .and. i.lt.nct+1) then
2621 if (itype(i-1,1).le.ntyp) then
2622 iti1 = itortyp(itype(i-1,1))
2630 mu(k,i-2)=Ub2(k,i-2)+b1(k,iti1)
2632 ! if (energy_dec) write (iout,*) 'Ub2 ',i,Ub2(:,i-2)
2633 ! if (energy_dec) write (iout,*) 'b1 ',iti1,b1(:,iti1)
2634 ! if (energy_dec) write (iout,*) 'mu ',i,iti1,mu(:,i-2)
2635 !d write (iout,*) 'mu1',mu1(:,i-2)
2636 !d write (iout,*) 'mu2',mu2(:,i-2)
2637 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.wcorr6.gt.0.0d0) &
2639 call matmat2(CC(1,1,iti1),Ugder(1,1,i-2),CUgder(1,1,i-2))
2640 call matmat2(DD(1,1,iti),Ugder(1,1,i-2),DUgder(1,1,i-2))
2641 call matmat2(Dtilde(1,1,iti),Ug2der(1,1,i-2),DtUg2der(1,1,i-2))
2642 call matvec2(Ctilde(1,1,iti1),obrot_der(1,i-2),Ctobrder(1,i-2))
2643 call matvec2(Dtilde(1,1,iti),obrot2_der(1,i-2),Dtobr2der(1,i-2))
2644 ! Vectors and matrices dependent on a single virtual-bond dihedral.
2645 call matvec2(DD(1,1,iti),b1tilde(1,iti1),auxvec(1))
2646 call matvec2(Ug2(1,1,i-2),auxvec(1),Ug2Db1t(1,i-2))
2647 call matvec2(Ug2der(1,1,i-2),auxvec(1),Ug2Db1tder(1,i-2))
2648 call matvec2(CC(1,1,iti1),Ub2(1,i-2),CUgb2(1,i-2))
2649 call matvec2(CC(1,1,iti1),Ub2der(1,i-2),CUgb2der(1,i-2))
2650 call matmat2(EUg(1,1,i-2),CC(1,1,iti1),EUgC(1,1,i-2))
2651 call matmat2(EUgder(1,1,i-2),CC(1,1,iti1),EUgCder(1,1,i-2))
2652 call matmat2(EUg(1,1,i-2),DD(1,1,iti1),EUgD(1,1,i-2))
2653 call matmat2(EUgder(1,1,i-2),DD(1,1,iti1),EUgDder(1,1,i-2))
2656 ! Matrices dependent on two consecutive virtual-bond dihedrals.
2657 ! The order of matrices is from left to right.
2658 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.wcorr6.gt.0.0d0) &
2660 ! do i=max0(ivec_start,2),ivec_end
2662 call matmat2(DtUg2(1,1,i-1),EUg(1,1,i),DtUg2EUg(1,1,i))
2663 call matmat2(DtUg2der(1,1,i-1),EUg(1,1,i),DtUg2EUgder(1,1,1,i))
2664 call matmat2(DtUg2(1,1,i-1),EUgder(1,1,i),DtUg2EUgder(1,1,2,i))
2665 call transpose2(DtUg2(1,1,i-1),auxmat(1,1))
2666 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUg(1,1,i))
2667 call matmat2(auxmat(1,1),EUgder(1,1,i),Ug2DtEUgder(1,1,2,i))
2668 call transpose2(DtUg2der(1,1,i-1),auxmat(1,1))
2669 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUgder(1,1,1,i))
2672 #if defined(MPI) && defined(PARMAT)
2674 ! if (fg_rank.eq.0) then
2675 write (iout,*) "Arrays UG and UGDER before GATHER"
2677 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2678 ((ug(l,k,i),l=1,2),k=1,2),&
2679 ((ugder(l,k,i),l=1,2),k=1,2)
2681 write (iout,*) "Arrays UG2 and UG2DER"
2683 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2684 ((ug2(l,k,i),l=1,2),k=1,2),&
2685 ((ug2der(l,k,i),l=1,2),k=1,2)
2687 write (iout,*) "Arrays OBROT OBROT2 OBROTDER and OBROT2DER"
2689 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2690 (obrot(k,i),k=1,2),(obrot2(k,i),k=1,2),&
2691 (obrot_der(k,i),k=1,2),(obrot2_der(k,i),k=1,2)
2693 write (iout,*) "Arrays COSTAB SINTAB COSTAB2 and SINTAB2"
2695 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2696 costab(i),sintab(i),costab2(i),sintab2(i)
2698 write (iout,*) "Array MUDER"
2700 write (iout,'(i5,2f10.5)') i,muder(1,i),muder(2,i)
2704 if (nfgtasks.gt.1) then
2706 ! write(iout,*)"Processor",fg_rank,kolor," ivec_start",ivec_start,
2707 ! & " ivec_displ",(ivec_displ(i),i=0,nfgtasks-1),
2708 ! & " ivec_count",(ivec_count(i),i=0,nfgtasks-1)
2710 call MPI_Allgatherv(Ub2(1,ivec_start),ivec_count(fg_rank1),&
2711 MPI_MU,Ub2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2713 call MPI_Allgatherv(Ub2der(1,ivec_start),ivec_count(fg_rank1),&
2714 MPI_MU,Ub2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2716 call MPI_Allgatherv(mu(1,ivec_start),ivec_count(fg_rank1),&
2717 MPI_MU,mu(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2719 call MPI_Allgatherv(muder(1,ivec_start),ivec_count(fg_rank1),&
2720 MPI_MU,muder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2722 call MPI_Allgatherv(Eug(1,1,ivec_start),ivec_count(fg_rank1),&
2723 MPI_MAT1,Eug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2725 call MPI_Allgatherv(Eugder(1,1,ivec_start),ivec_count(fg_rank1),&
2726 MPI_MAT1,Eugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2728 call MPI_Allgatherv(costab(ivec_start),ivec_count(fg_rank1),&
2729 MPI_DOUBLE_PRECISION,costab(1),ivec_count(0),ivec_displ(0),&
2730 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
2731 call MPI_Allgatherv(sintab(ivec_start),ivec_count(fg_rank1),&
2732 MPI_DOUBLE_PRECISION,sintab(1),ivec_count(0),ivec_displ(0),&
2733 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
2734 call MPI_Allgatherv(costab2(ivec_start),ivec_count(fg_rank1),&
2735 MPI_DOUBLE_PRECISION,costab2(1),ivec_count(0),ivec_displ(0),&
2736 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
2737 call MPI_Allgatherv(sintab2(ivec_start),ivec_count(fg_rank1),&
2738 MPI_DOUBLE_PRECISION,sintab2(1),ivec_count(0),ivec_displ(0),&
2739 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
2740 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) &
2742 call MPI_Allgatherv(Ctobr(1,ivec_start),ivec_count(fg_rank1),&
2743 MPI_MU,Ctobr(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2745 call MPI_Allgatherv(Ctobrder(1,ivec_start),ivec_count(fg_rank1),&
2746 MPI_MU,Ctobrder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2748 call MPI_Allgatherv(Dtobr2(1,ivec_start),ivec_count(fg_rank1),&
2749 MPI_MU,Dtobr2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2751 call MPI_Allgatherv(Dtobr2der(1,ivec_start),ivec_count(fg_rank1),&
2752 MPI_MU,Dtobr2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2754 call MPI_Allgatherv(Ug2Db1t(1,ivec_start),ivec_count(fg_rank1),&
2755 MPI_MU,Ug2Db1t(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2757 call MPI_Allgatherv(Ug2Db1tder(1,ivec_start),&
2758 ivec_count(fg_rank1),&
2759 MPI_MU,Ug2Db1tder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2761 call MPI_Allgatherv(CUgb2(1,ivec_start),ivec_count(fg_rank1),&
2762 MPI_MU,CUgb2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2764 call MPI_Allgatherv(CUgb2der(1,ivec_start),ivec_count(fg_rank1),&
2765 MPI_MU,CUgb2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2767 call MPI_Allgatherv(Cug(1,1,ivec_start),ivec_count(fg_rank1),&
2768 MPI_MAT1,Cug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2770 call MPI_Allgatherv(Cugder(1,1,ivec_start),ivec_count(fg_rank1),&
2771 MPI_MAT1,Cugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2773 call MPI_Allgatherv(Dug(1,1,ivec_start),ivec_count(fg_rank1),&
2774 MPI_MAT1,Dug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2776 call MPI_Allgatherv(Dugder(1,1,ivec_start),ivec_count(fg_rank1),&
2777 MPI_MAT1,Dugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2779 call MPI_Allgatherv(Dtug2(1,1,ivec_start),ivec_count(fg_rank1),&
2780 MPI_MAT1,Dtug2(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2782 call MPI_Allgatherv(Dtug2der(1,1,ivec_start),&
2783 ivec_count(fg_rank1),&
2784 MPI_MAT1,Dtug2der(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2786 call MPI_Allgatherv(EugC(1,1,ivec_start),ivec_count(fg_rank1),&
2787 MPI_MAT1,EugC(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2789 call MPI_Allgatherv(EugCder(1,1,ivec_start),ivec_count(fg_rank1),&
2790 MPI_MAT1,EugCder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2792 call MPI_Allgatherv(EugD(1,1,ivec_start),ivec_count(fg_rank1),&
2793 MPI_MAT1,EugD(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2795 call MPI_Allgatherv(EugDder(1,1,ivec_start),ivec_count(fg_rank1),&
2796 MPI_MAT1,EugDder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2798 call MPI_Allgatherv(DtUg2EUg(1,1,ivec_start),&
2799 ivec_count(fg_rank1),&
2800 MPI_MAT1,DtUg2EUg(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2802 call MPI_Allgatherv(Ug2DtEUg(1,1,ivec_start),&
2803 ivec_count(fg_rank1),&
2804 MPI_MAT1,Ug2DtEUg(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2806 call MPI_Allgatherv(DtUg2EUgder(1,1,1,ivec_start),&
2807 ivec_count(fg_rank1),&
2808 MPI_MAT2,DtUg2EUgder(1,1,1,1),ivec_count(0),ivec_displ(0),&
2809 MPI_MAT2,FG_COMM1,IERR)
2810 call MPI_Allgatherv(Ug2DtEUgder(1,1,1,ivec_start),&
2811 ivec_count(fg_rank1),&
2812 MPI_MAT2,Ug2DtEUgder(1,1,1,1),ivec_count(0),ivec_displ(0),&
2813 MPI_MAT2,FG_COMM1,IERR)
2816 ! Passes matrix info through the ring
2819 if (irecv.lt.0) irecv=nfgtasks1-1
2822 if (inext.ge.nfgtasks1) inext=0
2824 ! write (iout,*) "isend",isend," irecv",irecv
2826 lensend=lentyp(isend)
2827 lenrecv=lentyp(irecv)
2828 ! write (iout,*) "lensend",lensend," lenrecv",lenrecv
2829 ! call MPI_SENDRECV(ug(1,1,ivec_displ(isend)+1),1,
2830 ! & MPI_ROTAT1(lensend),inext,2200+isend,
2831 ! & ug(1,1,ivec_displ(irecv)+1),1,MPI_ROTAT1(lenrecv),
2832 ! & iprev,2200+irecv,FG_COMM,status,IERR)
2833 ! write (iout,*) "Gather ROTAT1"
2835 ! call MPI_SENDRECV(obrot(1,ivec_displ(isend)+1),1,
2836 ! & MPI_ROTAT2(lensend),inext,3300+isend,
2837 ! & obrot(1,ivec_displ(irecv)+1),1,MPI_ROTAT2(lenrecv),
2838 ! & iprev,3300+irecv,FG_COMM,status,IERR)
2839 ! write (iout,*) "Gather ROTAT2"
2841 call MPI_SENDRECV(costab(ivec_displ(isend)+1),1,&
2842 MPI_ROTAT_OLD(lensend),inext,4400+isend,&
2843 costab(ivec_displ(irecv)+1),1,MPI_ROTAT_OLD(lenrecv),&
2844 iprev,4400+irecv,FG_COMM,status,IERR)
2845 ! write (iout,*) "Gather ROTAT_OLD"
2847 call MPI_SENDRECV(mu(1,ivec_displ(isend)+1),1,&
2848 MPI_PRECOMP11(lensend),inext,5500+isend,&
2849 mu(1,ivec_displ(irecv)+1),1,MPI_PRECOMP11(lenrecv),&
2850 iprev,5500+irecv,FG_COMM,status,IERR)
2851 ! write (iout,*) "Gather PRECOMP11"
2853 call MPI_SENDRECV(Eug(1,1,ivec_displ(isend)+1),1,&
2854 MPI_PRECOMP12(lensend),inext,6600+isend,&
2855 Eug(1,1,ivec_displ(irecv)+1),1,MPI_PRECOMP12(lenrecv),&
2856 iprev,6600+irecv,FG_COMM,status,IERR)
2857 ! write (iout,*) "Gather PRECOMP12"
2859 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) &
2861 call MPI_SENDRECV(ug2db1t(1,ivec_displ(isend)+1),1,&
2862 MPI_ROTAT2(lensend),inext,7700+isend,&
2863 ug2db1t(1,ivec_displ(irecv)+1),1,MPI_ROTAT2(lenrecv),&
2864 iprev,7700+irecv,FG_COMM,status,IERR)
2865 ! write (iout,*) "Gather PRECOMP21"
2867 call MPI_SENDRECV(EUgC(1,1,ivec_displ(isend)+1),1,&
2868 MPI_PRECOMP22(lensend),inext,8800+isend,&
2869 EUgC(1,1,ivec_displ(irecv)+1),1,MPI_PRECOMP22(lenrecv),&
2870 iprev,8800+irecv,FG_COMM,status,IERR)
2871 ! write (iout,*) "Gather PRECOMP22"
2873 call MPI_SENDRECV(Ug2DtEUgder(1,1,1,ivec_displ(isend)+1),1,&
2874 MPI_PRECOMP23(lensend),inext,9900+isend,&
2875 Ug2DtEUgder(1,1,1,ivec_displ(irecv)+1),1,&
2876 MPI_PRECOMP23(lenrecv),&
2877 iprev,9900+irecv,FG_COMM,status,IERR)
2878 ! write (iout,*) "Gather PRECOMP23"
2883 if (irecv.lt.0) irecv=nfgtasks1-1
2886 time_gather=time_gather+MPI_Wtime()-time00
2889 ! if (fg_rank.eq.0) then
2890 write (iout,*) "Arrays UG and UGDER"
2892 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2893 ((ug(l,k,i),l=1,2),k=1,2),&
2894 ((ugder(l,k,i),l=1,2),k=1,2)
2896 write (iout,*) "Arrays UG2 and UG2DER"
2898 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2899 ((ug2(l,k,i),l=1,2),k=1,2),&
2900 ((ug2der(l,k,i),l=1,2),k=1,2)
2902 write (iout,*) "Arrays OBROT OBROT2 OBROTDER and OBROT2DER"
2904 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2905 (obrot(k,i),k=1,2),(obrot2(k,i),k=1,2),&
2906 (obrot_der(k,i),k=1,2),(obrot2_der(k,i),k=1,2)
2908 write (iout,*) "Arrays COSTAB SINTAB COSTAB2 and SINTAB2"
2910 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2911 costab(i),sintab(i),costab2(i),sintab2(i)
2913 write (iout,*) "Array MUDER"
2915 write (iout,'(i5,2f10.5)') i,muder(1,i),muder(2,i)
2921 !d iti = itortyp(itype(i,1))
2924 !d write (iout,'(2f10.5,5x,2f10.5,5x,2f10.5)')
2925 !d & (EE(j,k,iti),k=1,2),(Ug(j,k,i),k=1,2),(EUg(j,k,i),k=1,2)
2929 end subroutine set_matrices
2930 !-----------------------------------------------------------------------------
2931 subroutine eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
2933 ! This subroutine calculates the average interaction energy and its gradient
2934 ! in the virtual-bond vectors between non-adjacent peptide groups, based on
2935 ! the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
2936 ! The potential depends both on the distance of peptide-group centers and on
2937 ! the orientation of the CA-CA virtual bonds.
2940 ! implicit real*8 (a-h,o-z)
2944 ! include 'DIMENSIONS'
2945 ! include 'COMMON.CONTROL'
2946 ! include 'COMMON.SETUP'
2947 ! include 'COMMON.IOUNITS'
2948 ! include 'COMMON.GEO'
2949 ! include 'COMMON.VAR'
2950 ! include 'COMMON.LOCAL'
2951 ! include 'COMMON.CHAIN'
2952 ! include 'COMMON.DERIV'
2953 ! include 'COMMON.INTERACT'
2954 ! include 'COMMON.CONTACTS'
2955 ! include 'COMMON.TORSION'
2956 ! include 'COMMON.VECTORS'
2957 ! include 'COMMON.FFIELD'
2958 ! include 'COMMON.TIME1'
2959 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg
2960 real(kind=8),dimension(3,3) :: erder,uryg,urzg,vryg,vrzg
2961 real(kind=8),dimension(2,2) :: acipa !el,a_temp
2962 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
2963 real(kind=8),dimension(4) :: muij
2964 !el integer :: num_conti,j1,j2
2965 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
2966 !el dz_normi,xmedi,ymedi,zmedi
2968 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
2969 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
2972 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
2974 real(kind=8) :: scal_el=1.0d0
2976 real(kind=8) :: scal_el=0.5d0
2979 ! 13-go grudnia roku pamietnego...
2980 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
2982 0.0d0,0.0d0,1.0d0/),shape(unmat))
2985 real(kind=8) :: ees,evdw1,eel_loc,eello_turn3,eello_turn4
2986 real(kind=8) :: fac,t_eelecij,fracinbuf
2989 !d write(iout,*) 'In EELEC'
2990 ! print *,"IN EELEC"
2992 !d write(iout,*) 'Type',i
2993 !d write(iout,*) 'B1',B1(:,i)
2994 !d write(iout,*) 'B2',B2(:,i)
2995 !d write(iout,*) 'CC',CC(:,:,i)
2996 !d write(iout,*) 'DD',DD(:,:,i)
2997 !d write(iout,*) 'EE',EE(:,:,i)
2999 !d call check_vecgrad
3014 if (icheckgrad.eq.1) then
3017 ! dc_norm(1,i)=0.0d0
3018 ! dc_norm(2,i)=0.0d0
3019 ! dc_norm(3,i)=0.0d0
3022 fac=1.0d0/dsqrt(scalar(dc(1,i),dc(1,i)))
3024 dc_norm(k,i)=dc(k,i)*fac
3026 ! write (iout,*) 'i',i,' fac',fac
3029 ! print *,wel_loc,"wel_loc",wcorr4,wcorr5,wcorr6,wturn3,wturn4, &
3031 if (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
3032 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 .or. &
3033 wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) then
3034 ! call vec_and_deriv
3038 ! print *, "before set matrices"
3040 ! print *, "after set matrices"
3043 time_mat=time_mat+MPI_Wtime()-time01
3046 ! print *, "after set matrices"
3048 !d write (iout,*) 'i=',i
3050 !d write (iout,'(i5,2f10.5)') k,uy(k,i),uz(k,i)
3053 !d write (iout,'(f10.5,2x,3f10.5,2x,3f10.5)')
3054 !d & uz(k,i),(uzgrad(k,l,1,i),l=1,3),(uzgrad(k,l,2,i),l=1,3)
3067 !d print '(a)','Enter EELEC'
3068 !d write (iout,*) 'iatel_s=',iatel_s,' iatel_e=',iatel_e
3069 ! if (.not.allocated(gel_loc_loc)) allocate(gel_loc_loc(nres)) !(maxvar)(maxvar=6*maxres)
3070 ! if (.not.allocated(gcorr_loc)) allocate(gcorr_loc(nres)) !(maxvar)(maxvar=6*maxres)
3072 gel_loc_loc(i)=0.0d0
3077 ! 9/27/08 AL Split the interaction loop to ensure load balancing of turn terms
3079 ! Loop over i,i+2 and i,i+3 pairs of the peptide groups
3083 ! print *,"before iturn3 loop"
3084 do i=iturn3_start,iturn3_end
3085 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1 &
3086 .or. itype(i+2,1).eq.ntyp1 .or. itype(i+3,1).eq.ntyp1) cycle
3090 dx_normi=dc_norm(1,i)
3091 dy_normi=dc_norm(2,i)
3092 dz_normi=dc_norm(3,i)
3093 xmedi=c(1,i)+0.5d0*dxi
3094 ymedi=c(2,i)+0.5d0*dyi
3095 zmedi=c(3,i)+0.5d0*dzi
3096 xmedi=dmod(xmedi,boxxsize)
3097 if (xmedi.lt.0) xmedi=xmedi+boxxsize
3098 ymedi=dmod(ymedi,boxysize)
3099 if (ymedi.lt.0) ymedi=ymedi+boxysize
3100 zmedi=dmod(zmedi,boxzsize)
3101 if (zmedi.lt.0) zmedi=zmedi+boxzsize
3103 if ((zmedi.gt.bordlipbot) &
3104 .and.(zmedi.lt.bordliptop)) then
3105 !C the energy transfer exist
3106 if (zmedi.lt.buflipbot) then
3107 !C what fraction I am in
3109 ((zmedi-bordlipbot)/lipbufthick)
3110 !C lipbufthick is thickenes of lipid buffore
3111 sslipi=sscalelip(fracinbuf)
3112 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
3113 elseif (zmedi.gt.bufliptop) then
3114 fracinbuf=1.0d0-((bordliptop-zmedi)/lipbufthick)
3115 sslipi=sscalelip(fracinbuf)
3116 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
3125 ! print *,i,sslipi,ssgradlipi
3126 call eelecij(i,i+2,ees,evdw1,eel_loc)
3127 if (wturn3.gt.0.0d0) call eturn3(i,eello_turn3)
3128 num_cont_hb(i)=num_conti
3130 do i=iturn4_start,iturn4_end
3131 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1 &
3132 .or. itype(i+3,1).eq.ntyp1 &
3133 .or. itype(i+4,1).eq.ntyp1) cycle
3137 dx_normi=dc_norm(1,i)
3138 dy_normi=dc_norm(2,i)
3139 dz_normi=dc_norm(3,i)
3140 xmedi=c(1,i)+0.5d0*dxi
3141 ymedi=c(2,i)+0.5d0*dyi
3142 zmedi=c(3,i)+0.5d0*dzi
3143 xmedi=dmod(xmedi,boxxsize)
3144 if (xmedi.lt.0) xmedi=xmedi+boxxsize
3145 ymedi=dmod(ymedi,boxysize)
3146 if (ymedi.lt.0) ymedi=ymedi+boxysize
3147 zmedi=dmod(zmedi,boxzsize)
3148 if (zmedi.lt.0) zmedi=zmedi+boxzsize
3149 if ((zmedi.gt.bordlipbot) &
3150 .and.(zmedi.lt.bordliptop)) then
3151 !C the energy transfer exist
3152 if (zmedi.lt.buflipbot) then
3153 !C what fraction I am in
3155 ((zmedi-bordlipbot)/lipbufthick)
3156 !C lipbufthick is thickenes of lipid buffore
3157 sslipi=sscalelip(fracinbuf)
3158 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
3159 elseif (zmedi.gt.bufliptop) then
3160 fracinbuf=1.0d0-((bordliptop-zmedi)/lipbufthick)
3161 sslipi=sscalelip(fracinbuf)
3162 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
3172 num_conti=num_cont_hb(i)
3173 call eelecij(i,i+3,ees,evdw1,eel_loc)
3174 if (wturn4.gt.0.0d0 .and. itype(i+2,1).ne.ntyp1) &
3175 call eturn4(i,eello_turn4)
3176 num_cont_hb(i)=num_conti
3179 ! Loop over all pairs of interacting peptide groups except i,i+2 and i,i+3
3181 ! print *,"iatel_s,iatel_e,",iatel_s,iatel_e
3182 do i=iatel_s,iatel_e
3183 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
3187 dx_normi=dc_norm(1,i)
3188 dy_normi=dc_norm(2,i)
3189 dz_normi=dc_norm(3,i)
3190 xmedi=c(1,i)+0.5d0*dxi
3191 ymedi=c(2,i)+0.5d0*dyi
3192 zmedi=c(3,i)+0.5d0*dzi
3193 xmedi=dmod(xmedi,boxxsize)
3194 if (xmedi.lt.0) xmedi=xmedi+boxxsize
3195 ymedi=dmod(ymedi,boxysize)
3196 if (ymedi.lt.0) ymedi=ymedi+boxysize
3197 zmedi=dmod(zmedi,boxzsize)
3198 if (zmedi.lt.0) zmedi=zmedi+boxzsize
3199 if ((zmedi.gt.bordlipbot) &
3200 .and.(zmedi.lt.bordliptop)) then
3201 !C the energy transfer exist
3202 if (zmedi.lt.buflipbot) then
3203 !C what fraction I am in
3205 ((zmedi-bordlipbot)/lipbufthick)
3206 !C lipbufthick is thickenes of lipid buffore
3207 sslipi=sscalelip(fracinbuf)
3208 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
3209 elseif (zmedi.gt.bufliptop) then
3210 fracinbuf=1.0d0-((bordliptop-zmedi)/lipbufthick)
3211 sslipi=sscalelip(fracinbuf)
3212 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
3222 ! write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
3223 num_conti=num_cont_hb(i)
3224 do j=ielstart(i),ielend(i)
3225 ! write (iout,*) i,j,itype(i,1),itype(j,1)
3226 if (itype(j,1).eq.ntyp1.or. itype(j+1,1).eq.ntyp1) cycle
3227 call eelecij(i,j,ees,evdw1,eel_loc)
3229 num_cont_hb(i)=num_conti
3231 ! write (iout,*) "Number of loop steps in EELEC:",ind
3233 !d write (iout,'(i3,3f10.5,5x,3f10.5)')
3234 !d & i,(gel_loc(k,i),k=1,3),gel_loc_loc(i)
3236 ! 12/7/99 Adam eello_turn3 will be considered as a separate energy term
3237 !cc eel_loc=eel_loc+eello_turn3
3238 !d print *,"Processor",fg_rank," t_eelecij",t_eelecij
3240 end subroutine eelec
3241 !-----------------------------------------------------------------------------
3242 subroutine eelecij(i,j,ees,evdw1,eel_loc)
3245 ! implicit real*8 (a-h,o-z)
3246 ! include 'DIMENSIONS'
3250 ! include 'COMMON.CONTROL'
3251 ! include 'COMMON.IOUNITS'
3252 ! include 'COMMON.GEO'
3253 ! include 'COMMON.VAR'
3254 ! include 'COMMON.LOCAL'
3255 ! include 'COMMON.CHAIN'
3256 ! include 'COMMON.DERIV'
3257 ! include 'COMMON.INTERACT'
3258 ! include 'COMMON.CONTACTS'
3259 ! include 'COMMON.TORSION'
3260 ! include 'COMMON.VECTORS'
3261 ! include 'COMMON.FFIELD'
3262 ! include 'COMMON.TIME1'
3263 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg,xtemp
3264 real(kind=8),dimension(3,3) :: erder,uryg,urzg,vryg,vrzg
3265 real(kind=8),dimension(2,2) :: acipa !el,a_temp
3266 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
3267 real(kind=8),dimension(4) :: muij
3268 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
3269 dist_temp, dist_init,rlocshield,fracinbuf
3270 integer xshift,yshift,zshift,ilist,iresshield
3271 !el integer :: num_conti,j1,j2
3272 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
3273 !el dz_normi,xmedi,ymedi,zmedi
3275 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
3276 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
3279 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
3281 real(kind=8) :: scal_el=1.0d0
3283 real(kind=8) :: scal_el=0.5d0
3286 ! 13-go grudnia roku pamietnego...
3287 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
3289 0.0d0,0.0d0,1.0d0/),shape(unmat))
3290 ! integer :: maxconts=nres/4
3292 integer :: k,i,j,iteli,itelj,kkk,l,kkll,m,isubchap
3293 real(kind=8) :: ael6i,rrmij,rmij,r0ij,fcont,fprimcont,ees0tmp
3294 real(kind=8) :: ees,evdw1,eel_loc,aaa,bbb,ael3i
3295 real(kind=8) :: dxj,dyj,dzj,dx_normj,dy_normj,dz_normj,xj,yj,zj,&
3296 rij,r3ij,r6ij,cosa,cosb,cosg,fac,ev1,ev2,fac3,fac4,&
3297 evdwij,el1,el2,eesij,ees0ij,facvdw,facel,fac1,ecosa,&
3298 ecosb,ecosg,ury,urz,vry,vrz,facr,a22der,a23der,a32der,&
3299 a33der,eel_loc_ij,cosa4,wij,cosbg1,cosbg2,ees0pij,&
3300 ees0pij1,ees0mij,ees0mij1,fac3p,ees0mijp,ees0pijp,&
3301 ecosa1,ecosb1,ecosg1,ecosa2,ecosb2,ecosg2,ecosap,ecosbp,&
3302 ecosgp,ecosam,ecosbm,ecosgm,ghalf
3304 ! allocate(a_chuj(2,2,maxconts,nres)) !(2,2,maxconts,maxres)
3305 ! allocate(a_chuj_der(2,2,3,5,maxconts,nres)) !(2,2,3,5,maxconts,maxres)
3307 ! time00=MPI_Wtime()
3308 !d write (iout,*) "eelecij",i,j
3312 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
3313 aaa=app(iteli,itelj)
3314 bbb=bpp(iteli,itelj)
3315 ael6i=ael6(iteli,itelj)
3316 ael3i=ael3(iteli,itelj)
3320 dx_normj=dc_norm(1,j)
3321 dy_normj=dc_norm(2,j)
3322 dz_normj=dc_norm(3,j)
3323 ! xj=c(1,j)+0.5D0*dxj-xmedi
3324 ! yj=c(2,j)+0.5D0*dyj-ymedi
3325 ! zj=c(3,j)+0.5D0*dzj-zmedi
3330 if (xj.lt.0) xj=xj+boxxsize
3332 if (yj.lt.0) yj=yj+boxysize
3334 if (zj.lt.0) zj=zj+boxzsize
3335 if ((zj.gt.bordlipbot) &
3336 .and.(zj.lt.bordliptop)) then
3337 !C the energy transfer exist
3338 if (zj.lt.buflipbot) then
3339 !C what fraction I am in
3341 ((zj-bordlipbot)/lipbufthick)
3342 !C lipbufthick is thickenes of lipid buffore
3343 sslipj=sscalelip(fracinbuf)
3344 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
3345 elseif (zj.gt.bufliptop) then
3346 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
3347 sslipj=sscalelip(fracinbuf)
3348 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
3359 dist_init=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
3366 xj=xj_safe+xshift*boxxsize
3367 yj=yj_safe+yshift*boxysize
3368 zj=zj_safe+zshift*boxzsize
3369 dist_temp=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
3370 if(dist_temp.lt.dist_init) then
3380 if (isubchap.eq.1) then
3391 rij=xj*xj+yj*yj+zj*zj
3394 !C print *,xmedi,ymedi,zmedi,xj,yj,zj,boxxsize,rij
3395 sss_ele_cut=sscale_ele(rij)
3396 sss_ele_grad=sscagrad_ele(rij)
3398 ! sss_ele_grad=0.0d0
3399 ! print *,sss_ele_cut,sss_ele_grad,&
3400 ! (rij),r_cut_ele,rlamb_ele
3401 ! if (sss_ele_cut.le.0.0) go to 128
3406 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
3407 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
3408 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
3409 fac=cosa-3.0D0*cosb*cosg
3411 ! 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
3412 if (j.eq.i+2) ev1=scal_el*ev1
3417 el1=fac3*(4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg))
3420 if (shield_mode.gt.0) then
3421 !C fac_shield(i)=0.4
3422 !C fac_shield(j)=0.6
3423 el1=el1*fac_shield(i)**2*fac_shield(j)**2
3424 el2=el2*fac_shield(i)**2*fac_shield(j)**2
3426 ees=ees+eesij*sss_ele_cut
3427 !C FOR NOW SHIELD IS NOT USED WITH LIPSCALE
3428 !C & *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3434 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)*sss_ele_cut
3435 !C print *,"TUCC",(sslipi+sslipj)/2.0d0*lipscale**2+1.0d0
3438 ! 12/26/95 - for the evaluation of multi-body H-bonding interactions
3439 ees0ij=4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg)
3440 ! ees=ees+eesij*sss_ele_cut
3441 evdw1=evdw1+evdwij*sss_ele_cut &
3442 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3443 !d write(iout,'(2(2i3,2x),7(1pd12.4)/2(3(1pd12.4),5x)/)')
3444 !d & iteli,i,itelj,j,aaa,bbb,ael6i,ael3i,
3445 !d & 1.0D0/dsqrt(rrmij),evdwij,eesij,
3446 !d & xmedi,ymedi,zmedi,xj,yj,zj
3448 if (energy_dec) then
3449 ! write (iout,'(a6,2i5,0pf7.3,2i5,2e11.3)') &
3450 ! 'evdw1',i,j,evdwij,&
3451 ! iteli,itelj,aaa,evdw1
3452 write (iout,'(a6,2i5,0pf7.3)') 'evdw1',i,j,evdwij
3453 write (iout,'(a6,2i5,0pf7.3)') 'ees',i,j,eesij
3456 ! Calculate contributions to the Cartesian gradient.
3459 facvdw=-6*rrmij*(ev1+evdwij)*sss_ele_cut &
3460 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3461 facel=-3*rrmij*(el1+eesij)*sss_ele_cut &
3462 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3468 ! Radial derivatives. First process both termini of the fragment (i,j)
3470 ggg(1)=facel*xj+sss_ele_grad*rmij*eesij*xj* &
3471 ((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3472 ggg(2)=facel*yj+sss_ele_grad*rmij*eesij*yj* &
3473 ((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3474 ggg(3)=facel*zj+sss_ele_grad*rmij*eesij*zj* &
3475 ((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3477 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
3478 (shield_mode.gt.0)) then
3480 do ilist=1,ishield_list(i)
3481 iresshield=shield_list(ilist,i)
3483 rlocshield=grad_shield_side(k,ilist,i)*eesij/fac_shield(i)&
3485 gshieldx(k,iresshield)=gshieldx(k,iresshield)+ &
3487 +grad_shield_loc(k,ilist,i)*eesij/fac_shield(i)*2.0 &
3489 gshieldc(k,iresshield-1)=gshieldc(k,iresshield-1)+rlocshield
3492 do ilist=1,ishield_list(j)
3493 iresshield=shield_list(ilist,j)
3495 rlocshield=grad_shield_side(k,ilist,j)*eesij/fac_shield(j) &
3497 gshieldx(k,iresshield)=gshieldx(k,iresshield)+ &
3499 +grad_shield_loc(k,ilist,j)*eesij/fac_shield(j)*2.0 &
3501 gshieldc(k,iresshield-1)=gshieldc(k,iresshield-1)+rlocshield
3505 gshieldc(k,i)=gshieldc(k,i)+ &
3506 grad_shield(k,i)*eesij/fac_shield(i)*2.0 &
3509 gshieldc(k,j)=gshieldc(k,j)+ &
3510 grad_shield(k,j)*eesij/fac_shield(j)*2.0 &
3513 gshieldc(k,i-1)=gshieldc(k,i-1)+ &
3514 grad_shield(k,i)*eesij/fac_shield(i)*2.0 &
3517 gshieldc(k,j-1)=gshieldc(k,j-1)+ &
3518 grad_shield(k,j)*eesij/fac_shield(j)*2.0 &
3526 ! ghalf=0.5D0*ggg(k)
3527 ! gelc(k,i)=gelc(k,i)+ghalf
3528 ! gelc(k,j)=gelc(k,j)+ghalf
3530 ! 9/28/08 AL Gradient compotents will be summed only at the end
3532 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
3533 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
3535 gelc_long(3,j)=gelc_long(3,j)+ &
3536 ssgradlipj*eesij/2.0d0*lipscale**2&
3539 gelc_long(3,i)=gelc_long(3,i)+ &
3540 ssgradlipi*eesij/2.0d0*lipscale**2&
3545 ! Loop over residues i+1 thru j-1.
3549 !grad gelc(l,k)=gelc(l,k)+ggg(l)
3552 ggg(1)=facvdw*xj+sss_ele_grad*rmij*evdwij*xj &
3553 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3554 ggg(2)=facvdw*yj+sss_ele_grad*rmij*evdwij*yj &
3555 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3556 ggg(3)=facvdw*zj+sss_ele_grad*rmij*evdwij*zj &
3557 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3560 ! ghalf=0.5D0*ggg(k)
3561 ! gvdwpp(k,i)=gvdwpp(k,i)+ghalf
3562 ! gvdwpp(k,j)=gvdwpp(k,j)+ghalf
3564 ! 9/28/08 AL Gradient compotents will be summed only at the end
3566 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
3567 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
3570 !C Lipidic part for scaling weight
3571 gvdwpp(3,j)=gvdwpp(3,j)+ &
3572 sss_ele_cut*ssgradlipj*evdwij/2.0d0*lipscale**2
3573 gvdwpp(3,i)=gvdwpp(3,i)+ &
3574 sss_ele_cut*ssgradlipi*evdwij/2.0d0*lipscale**2
3575 !! Loop over residues i+1 thru j-1.
3579 !grad gvdwpp(l,k)=gvdwpp(l,k)+ggg(l)
3583 facvdw=(ev1+evdwij)*sss_ele_cut &
3584 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3586 facel=(el1+eesij)*sss_ele_cut
3588 fac=-3*rrmij*(facvdw+facvdw+facel)
3593 ! Radial derivatives. First process both termini of the fragment (i,j)
3595 ggg(1)=fac*xj+sss_ele_grad*rmij*(eesij+evdwij)*xj
3596 ggg(2)=fac*yj+sss_ele_grad*rmij*(eesij+evdwij)*yj
3597 ggg(3)=fac*zj+sss_ele_grad*rmij*(eesij+evdwij)*zj
3599 ! ghalf=0.5D0*ggg(k)
3600 ! gelc(k,i)=gelc(k,i)+ghalf
3601 ! gelc(k,j)=gelc(k,j)+ghalf
3603 ! 9/28/08 AL Gradient compotents will be summed only at the end
3605 gelc_long(k,j)=gelc(k,j)+ggg(k)
3606 gelc_long(k,i)=gelc(k,i)-ggg(k)
3609 ! Loop over residues i+1 thru j-1.
3613 !grad gelc(l,k)=gelc(l,k)+ggg(l)
3616 ! 9/28/08 AL Gradient compotents will be summed only at the end
3618 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3620 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3622 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3625 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
3626 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
3628 gvdwpp(3,j)=gvdwpp(3,j)+ &
3629 sss_ele_cut*ssgradlipj*evdwij/2.0d0*lipscale**2
3630 gvdwpp(3,i)=gvdwpp(3,i)+ &
3631 sss_ele_cut*ssgradlipi*evdwij/2.0d0*lipscale**2
3637 ecosa=2.0D0*fac3*fac1+fac4
3640 ecosb=(fac3*(fac1*cosg+cosb)+cosg*fac4)
3641 ecosg=(fac3*(fac1*cosb+cosg)+cosb*fac4)
3643 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
3644 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
3646 !d print '(2i3,2(3(1pd14.5),3x))',i,j,(dcosb(k),k=1,3),
3647 !d & (dcosg(k),k=1,3)
3649 ggg(k)=(ecosb*dcosb(k)+ecosg*dcosg(k))*sss_ele_cut &
3650 *fac_shield(i)**2*fac_shield(j)**2 &
3651 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3655 ! ghalf=0.5D0*ggg(k)
3656 ! gelc(k,i)=gelc(k,i)+ghalf
3657 ! & +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
3658 ! & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
3659 ! gelc(k,j)=gelc(k,j)+ghalf
3660 ! & +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
3661 ! & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
3665 !grad gelc(l,k)=gelc(l,k)+ggg(l)
3669 gelc(k,i)=gelc(k,i) &
3670 +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
3671 + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)&
3673 *fac_shield(i)**2*fac_shield(j)**2 &
3674 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3676 gelc(k,j)=gelc(k,j) &
3677 +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
3678 + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
3680 *fac_shield(i)**2*fac_shield(j)**2 &
3681 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3683 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
3684 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
3687 IF (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
3688 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 &
3689 .or. wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
3691 ! 9/25/99 Mixed third-order local-electrostatic terms. The local-interaction
3692 ! energy of a peptide unit is assumed in the form of a second-order
3693 ! Fourier series in the angles lambda1 and lambda2 (see Nishikawa et al.
3694 ! Macromolecules, 1974, 7, 797-806 for definition). This correlation terms
3695 ! are computed for EVERY pair of non-contiguous peptide groups.
3697 if (j.lt.nres-1) then
3708 muij(kkk)=mu(k,i)*mu(l,j)
3711 !d write (iout,*) 'EELEC: i',i,' j',j
3712 !d write (iout,*) 'j',j,' j1',j1,' j2',j2
3713 !d write(iout,*) 'muij',muij
3714 ury=scalar(uy(1,i),erij)
3715 urz=scalar(uz(1,i),erij)
3716 vry=scalar(uy(1,j),erij)
3717 vrz=scalar(uz(1,j),erij)
3718 a22=scalar(uy(1,i),uy(1,j))-3*ury*vry
3719 a23=scalar(uy(1,i),uz(1,j))-3*ury*vrz
3720 a32=scalar(uz(1,i),uy(1,j))-3*urz*vry
3721 a33=scalar(uz(1,i),uz(1,j))-3*urz*vrz
3722 fac=dsqrt(-ael6i)*r3ij
3727 !d write (iout,'(4i5,4f10.5)')
3728 !d & i,itortyp(itype(i,1)),j,itortyp(itype(j,1)),a22,a23,a32,a33
3729 !d write (iout,'(6f10.5)') (muij(k),k=1,4),fac,eel_loc_ij
3730 !d write (iout,'(2(3f10.5,5x)/2(3f10.5,5x))') uy(:,i),uz(:,i),
3731 !d & uy(:,j),uz(:,j)
3732 !d write (iout,'(4f10.5)')
3733 !d & scalar(uy(1,i),uy(1,j)),scalar(uy(1,i),uz(1,j)),
3734 !d & scalar(uz(1,i),uy(1,j)),scalar(uz(1,i),uz(1,j))
3735 !d write (iout,'(4f10.5)') ury,urz,vry,vrz
3736 !d write (iout,'(9f10.5/)')
3737 !d & fac22,a22,fac23,a23,fac32,a32,fac33,a33,eel_loc_ij
3738 ! Derivatives of the elements of A in virtual-bond vectors
3739 call unormderiv(erij(1),unmat(1,1),rmij,erder(1,1))
3741 uryg(k,1)=scalar(erder(1,k),uy(1,i))
3742 uryg(k,2)=scalar(uygrad(1,k,1,i),erij(1))
3743 uryg(k,3)=scalar(uygrad(1,k,2,i),erij(1))
3744 urzg(k,1)=scalar(erder(1,k),uz(1,i))
3745 urzg(k,2)=scalar(uzgrad(1,k,1,i),erij(1))
3746 urzg(k,3)=scalar(uzgrad(1,k,2,i),erij(1))
3747 vryg(k,1)=scalar(erder(1,k),uy(1,j))
3748 vryg(k,2)=scalar(uygrad(1,k,1,j),erij(1))
3749 vryg(k,3)=scalar(uygrad(1,k,2,j),erij(1))
3750 vrzg(k,1)=scalar(erder(1,k),uz(1,j))
3751 vrzg(k,2)=scalar(uzgrad(1,k,1,j),erij(1))
3752 vrzg(k,3)=scalar(uzgrad(1,k,2,j),erij(1))
3754 ! Compute radial contributions to the gradient
3772 ! Add the contributions coming from er
3775 agg(k,1)=agg(k,1)+fac3*(uryg(k,1)*vry+vryg(k,1)*ury)
3776 agg(k,2)=agg(k,2)+fac3*(uryg(k,1)*vrz+vrzg(k,1)*ury)
3777 agg(k,3)=agg(k,3)+fac3*(urzg(k,1)*vry+vryg(k,1)*urz)
3778 agg(k,4)=agg(k,4)+fac3*(urzg(k,1)*vrz+vrzg(k,1)*urz)
3781 ! Derivatives in DC(i)
3782 !grad ghalf1=0.5d0*agg(k,1)
3783 !grad ghalf2=0.5d0*agg(k,2)
3784 !grad ghalf3=0.5d0*agg(k,3)
3785 !grad ghalf4=0.5d0*agg(k,4)
3786 aggi(k,1)=fac*(scalar(uygrad(1,k,1,i),uy(1,j)) &
3787 -3.0d0*uryg(k,2)*vry)!+ghalf1
3788 aggi(k,2)=fac*(scalar(uygrad(1,k,1,i),uz(1,j)) &
3789 -3.0d0*uryg(k,2)*vrz)!+ghalf2
3790 aggi(k,3)=fac*(scalar(uzgrad(1,k,1,i),uy(1,j)) &
3791 -3.0d0*urzg(k,2)*vry)!+ghalf3
3792 aggi(k,4)=fac*(scalar(uzgrad(1,k,1,i),uz(1,j)) &
3793 -3.0d0*urzg(k,2)*vrz)!+ghalf4
3794 ! Derivatives in DC(i+1)
3795 aggi1(k,1)=fac*(scalar(uygrad(1,k,2,i),uy(1,j)) &
3796 -3.0d0*uryg(k,3)*vry)!+agg(k,1)
3797 aggi1(k,2)=fac*(scalar(uygrad(1,k,2,i),uz(1,j)) &
3798 -3.0d0*uryg(k,3)*vrz)!+agg(k,2)
3799 aggi1(k,3)=fac*(scalar(uzgrad(1,k,2,i),uy(1,j)) &
3800 -3.0d0*urzg(k,3)*vry)!+agg(k,3)
3801 aggi1(k,4)=fac*(scalar(uzgrad(1,k,2,i),uz(1,j)) &
3802 -3.0d0*urzg(k,3)*vrz)!+agg(k,4)
3803 ! Derivatives in DC(j)
3804 aggj(k,1)=fac*(scalar(uygrad(1,k,1,j),uy(1,i)) &
3805 -3.0d0*vryg(k,2)*ury)!+ghalf1
3806 aggj(k,2)=fac*(scalar(uzgrad(1,k,1,j),uy(1,i)) &
3807 -3.0d0*vrzg(k,2)*ury)!+ghalf2
3808 aggj(k,3)=fac*(scalar(uygrad(1,k,1,j),uz(1,i)) &
3809 -3.0d0*vryg(k,2)*urz)!+ghalf3
3810 aggj(k,4)=fac*(scalar(uzgrad(1,k,1,j),uz(1,i)) &
3811 -3.0d0*vrzg(k,2)*urz)!+ghalf4
3812 ! Derivatives in DC(j+1) or DC(nres-1)
3813 aggj1(k,1)=fac*(scalar(uygrad(1,k,2,j),uy(1,i)) &
3814 -3.0d0*vryg(k,3)*ury)
3815 aggj1(k,2)=fac*(scalar(uzgrad(1,k,2,j),uy(1,i)) &
3816 -3.0d0*vrzg(k,3)*ury)
3817 aggj1(k,3)=fac*(scalar(uygrad(1,k,2,j),uz(1,i)) &
3818 -3.0d0*vryg(k,3)*urz)
3819 aggj1(k,4)=fac*(scalar(uzgrad(1,k,2,j),uz(1,i)) &
3820 -3.0d0*vrzg(k,3)*urz)
3821 !grad if (j.eq.nres-1 .and. i.lt.j-2) then
3823 !grad aggj1(k,l)=aggj1(k,l)+agg(k,l)
3836 aggi(k,l)=-aggi(k,l)
3837 aggi1(k,l)=-aggi1(k,l)
3838 aggj(k,l)=-aggj(k,l)
3839 aggj1(k,l)=-aggj1(k,l)
3842 if (j.lt.nres-1) then
3848 aggi(k,l)=-aggi(k,l)
3849 aggi1(k,l)=-aggi1(k,l)
3850 aggj(k,l)=-aggj(k,l)
3851 aggj1(k,l)=-aggj1(k,l)
3862 aggi(k,l)=-aggi(k,l)
3863 aggi1(k,l)=-aggi1(k,l)
3864 aggj(k,l)=-aggj(k,l)
3865 aggj1(k,l)=-aggj1(k,l)
3870 IF (wel_loc.gt.0.0d0) THEN
3871 ! Contribution to the local-electrostatic energy coming from the i-j pair
3872 eel_loc_ij=a22*muij(1)+a23*muij(2)+a32*muij(3) &
3874 if (shield_mode.eq.0) then
3878 eel_loc_ij=eel_loc_ij &
3879 *fac_shield(i)*fac_shield(j) &
3880 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
3881 !C Now derivative over eel_loc
3882 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
3883 (shield_mode.gt.0)) then
3886 do ilist=1,ishield_list(i)
3887 iresshield=shield_list(ilist,i)
3889 rlocshield=grad_shield_side(k,ilist,i)*eel_loc_ij &
3892 gshieldx_ll(k,iresshield)=gshieldx_ll(k,iresshield)+ &
3894 +grad_shield_loc(k,ilist,i)*eel_loc_ij/fac_shield(i) &
3897 gshieldc_ll(k,iresshield-1)=gshieldc_ll(k,iresshield-1)&
3901 do ilist=1,ishield_list(j)
3902 iresshield=shield_list(ilist,j)
3904 rlocshield=grad_shield_side(k,ilist,j)*eel_loc_ij &
3907 gshieldx_ll(k,iresshield)=gshieldx_ll(k,iresshield)+ &
3909 +grad_shield_loc(k,ilist,j)*eel_loc_ij/fac_shield(j) &
3912 gshieldc_ll(k,iresshield-1)=gshieldc_ll(k,iresshield-1)&
3919 gshieldc_ll(k,i)=gshieldc_ll(k,i)+ &
3920 grad_shield(k,i)*eel_loc_ij/fac_shield(i) &
3922 gshieldc_ll(k,j)=gshieldc_ll(k,j)+ &
3923 grad_shield(k,j)*eel_loc_ij/fac_shield(j) &
3925 gshieldc_ll(k,i-1)=gshieldc_ll(k,i-1)+ &
3926 grad_shield(k,i)*eel_loc_ij/fac_shield(i) &
3928 gshieldc_ll(k,j-1)=gshieldc_ll(k,j-1)+ &
3929 grad_shield(k,j)*eel_loc_ij/fac_shield(j) &
3936 ! write (iout,*) 'i',i,' j',j,' eel_loc_ij',eel_loc_ij
3938 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
3939 'eelloc',i,j,eel_loc_ij
3940 ! if (energy_dec) write (iout,*) "a22",a22," a23",a23," a32",a32," a33",a33
3941 ! if (energy_dec) write (iout,*) "muij",muij
3942 ! write (iout,*) a22,muij(1),a23,muij(2),a32,muij(3)
3944 eel_loc=eel_loc+eel_loc_ij*sss_ele_cut
3945 ! Partial derivatives in virtual-bond dihedral angles gamma
3947 gel_loc_loc(i-1)=gel_loc_loc(i-1)+ &
3948 (a22*muder(1,i)*mu(1,j)+a23*muder(1,i)*mu(2,j) &
3949 +a32*muder(2,i)*mu(1,j)+a33*muder(2,i)*mu(2,j)) &
3951 *fac_shield(i)*fac_shield(j) &
3952 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
3954 gel_loc_loc(j-1)=gel_loc_loc(j-1)+ &
3955 (a22*mu(1,i)*muder(1,j)+a23*mu(1,i)*muder(2,j) &
3956 +a32*mu(2,i)*muder(1,j)+a33*mu(2,i)*muder(2,j)) &
3958 *fac_shield(i)*fac_shield(j) &
3959 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
3960 ! Derivatives of eello in DC(i+1) thru DC(j-1) or DC(nres-2)
3962 ! ggg(1)=(agg(1,1)*muij(1)+ &
3963 ! agg(1,2)*muij(2)+agg(1,3)*muij(3)+agg(1,4)*muij(4)) &
3965 ! +eel_loc_ij*sss_ele_grad*rmij*xj
3966 ! ggg(2)=(agg(2,1)*muij(1)+ &
3967 ! agg(2,2)*muij(2)+agg(2,3)*muij(3)+agg(2,4)*muij(4)) &
3969 ! +eel_loc_ij*sss_ele_grad*rmij*yj
3970 ! ggg(3)=(agg(3,1)*muij(1)+ &
3971 ! agg(3,2)*muij(2)+agg(3,3)*muij(3)+agg(3,4)*muij(4)) &
3973 ! +eel_loc_ij*sss_ele_grad*rmij*zj
3979 ggg(l)=(agg(l,1)*muij(1)+ &
3980 agg(l,2)*muij(2)+agg(l,3)*muij(3)+agg(l,4)*muij(4))&
3982 *fac_shield(i)*fac_shield(j) &
3983 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0) &
3984 +eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
3987 gel_loc_long(l,j)=gel_loc_long(l,j)+ggg(l)
3988 gel_loc_long(l,i)=gel_loc_long(l,i)-ggg(l)
3989 !grad ghalf=0.5d0*ggg(l)
3990 !grad gel_loc(l,i)=gel_loc(l,i)+ghalf
3991 !grad gel_loc(l,j)=gel_loc(l,j)+ghalf
3993 gel_loc_long(3,j)=gel_loc_long(3,j)+ &
3994 ssgradlipj*eel_loc_ij/2.0d0*lipscale/ &
3995 ((sslipi+sslipj)/2.0d0*lipscale+1.0d0)*sss_ele_cut
3997 gel_loc_long(3,i)=gel_loc_long(3,i)+ &
3998 ssgradlipi*eel_loc_ij/2.0d0*lipscale/ &
3999 ((sslipi+sslipj)/2.0d0*lipscale+1.0d0)*sss_ele_cut
4003 !grad gel_loc(l,k)=gel_loc(l,k)+ggg(l)
4006 ! Remaining derivatives of eello
4008 gel_loc(l,i)=gel_loc(l,i)+(aggi(l,1)*muij(1)+ &
4009 aggi(l,2)*muij(2)+aggi(l,3)*muij(3)+aggi(l,4)*muij(4))&
4011 *fac_shield(i)*fac_shield(j) &
4012 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4014 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
4015 gel_loc(l,i+1)=gel_loc(l,i+1)+(aggi1(l,1)*muij(1)+ &
4016 aggi1(l,2)*muij(2)+aggi1(l,3)*muij(3) &
4017 +aggi1(l,4)*muij(4))&
4019 *fac_shield(i)*fac_shield(j) &
4020 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4022 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
4023 gel_loc(l,j)=gel_loc(l,j)+(aggj(l,1)*muij(1)+ &
4024 aggj(l,2)*muij(2)+aggj(l,3)*muij(3)+aggj(l,4)*muij(4))&
4026 *fac_shield(i)*fac_shield(j) &
4027 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4029 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
4030 gel_loc(l,j1)=gel_loc(l,j1)+(aggj1(l,1)*muij(1)+ &
4031 aggj1(l,2)*muij(2)+aggj1(l,3)*muij(3) &
4032 +aggj1(l,4)*muij(4))&
4034 *fac_shield(i)*fac_shield(j) &
4035 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4037 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
4040 ! Change 12/26/95 to calculate four-body contributions to H-bonding energy
4041 ! if (j.gt.i+1 .and. num_conti.le.maxconts) then
4042 if (wcorr+wcorr4+wcorr5+wcorr6.gt.0.0d0 &
4043 .and. num_conti.le.maxconts) then
4044 ! write (iout,*) i,j," entered corr"
4046 ! Calculate the contact function. The ith column of the array JCONT will
4047 ! contain the numbers of atoms that make contacts with the atom I (of numbers
4048 ! greater than I). The arrays FACONT and GACONT will contain the values of
4049 ! the contact function and its derivative.
4050 ! r0ij=1.02D0*rpp(iteli,itelj)
4051 ! r0ij=1.11D0*rpp(iteli,itelj)
4052 r0ij=2.20D0*rpp(iteli,itelj)
4053 ! r0ij=1.55D0*rpp(iteli,itelj)
4054 call gcont(rij,r0ij,1.0D0,0.2d0*r0ij,fcont,fprimcont)
4055 !elwrite(iout,*) "num_conti",num_conti, "maxconts",maxconts
4056 if (fcont.gt.0.0D0) then
4057 num_conti=num_conti+1
4058 if (num_conti.gt.maxconts) then
4059 !el write (iout,*) "esrgresgdsrgdfsrgdswrgaresfgaerwgae"
4060 !el write (iout,*) "num_conti",num_conti, "maxconts",maxconts
4061 write (iout,*) 'WARNING - max. # of contacts exceeded;',&
4062 ' will skip next contacts for this conf.', num_conti
4064 jcont_hb(num_conti,i)=j
4065 !d write (iout,*) "i",i," j",j," num_conti",num_conti,
4066 !d & " jcont_hb",jcont_hb(num_conti,i)
4067 IF (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. &
4068 wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
4069 ! 9/30/99 (AL) - store components necessary to evaluate higher-order loc-el
4071 d_cont(num_conti,i)=rij
4072 !d write (2,'(3e15.5)') rij,r0ij+0.2d0*r0ij,rij
4073 ! --- Electrostatic-interaction matrix ---
4074 a_chuj(1,1,num_conti,i)=a22
4075 a_chuj(1,2,num_conti,i)=a23
4076 a_chuj(2,1,num_conti,i)=a32
4077 a_chuj(2,2,num_conti,i)=a33
4078 ! --- Gradient of rij
4080 grij_hb_cont(kkk,num_conti,i)=erij(kkk)
4087 a_chuj_der(k,l,m,1,num_conti,i)=agg(m,kkll)
4088 a_chuj_der(k,l,m,2,num_conti,i)=aggi(m,kkll)
4089 a_chuj_der(k,l,m,3,num_conti,i)=aggi1(m,kkll)
4090 a_chuj_der(k,l,m,4,num_conti,i)=aggj(m,kkll)
4091 a_chuj_der(k,l,m,5,num_conti,i)=aggj1(m,kkll)
4096 IF (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) THEN
4097 ! Calculate contact energies
4099 wij=cosa-3.0D0*cosb*cosg
4102 ! fac3=dsqrt(-ael6i)/r0ij**3
4103 fac3=dsqrt(-ael6i)*r3ij
4104 ! ees0pij=dsqrt(4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1)
4105 ees0tmp=4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1
4106 if (ees0tmp.gt.0) then
4107 ees0pij=dsqrt(ees0tmp)
4111 if (shield_mode.eq.0) then
4115 ees0plist(num_conti,i)=j
4117 ! ees0mij=dsqrt(4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2)
4118 ees0tmp=4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2
4119 if (ees0tmp.gt.0) then
4120 ees0mij=dsqrt(ees0tmp)
4125 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij) &
4127 *fac_shield(i)*fac_shield(j)
4129 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij) &
4131 *fac_shield(i)*fac_shield(j)
4133 ! Diagnostics. Comment out or remove after debugging!
4134 ! ees0p(num_conti,i)=0.5D0*fac3*ees0pij
4135 ! ees0m(num_conti,i)=0.5D0*fac3*ees0mij
4136 ! ees0m(num_conti,i)=0.0D0
4138 ! write (iout,*) 'i=',i,' j=',j,' rij=',rij,' r0ij=',r0ij,
4139 ! & ' ees0ij=',ees0p(num_conti,i),ees0m(num_conti,i),' fcont=',fcont
4140 ! Angular derivatives of the contact function
4141 ees0pij1=fac3/ees0pij
4142 ees0mij1=fac3/ees0mij
4143 fac3p=-3.0D0*fac3*rrmij
4144 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
4145 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
4147 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
4148 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
4149 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
4150 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
4151 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
4152 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
4153 ecosap=ecosa1+ecosa2
4154 ecosbp=ecosb1+ecosb2
4155 ecosgp=ecosg1+ecosg2
4156 ecosam=ecosa1-ecosa2
4157 ecosbm=ecosb1-ecosb2
4158 ecosgm=ecosg1-ecosg2
4167 facont_hb(num_conti,i)=fcont
4168 fprimcont=fprimcont/rij
4169 !d facont_hb(num_conti,i)=1.0D0
4170 ! Following line is for diagnostics.
4173 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
4174 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
4177 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
4178 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
4180 gggp(1)=gggp(1)+ees0pijp*xj &
4181 +ees0p(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
4182 gggp(2)=gggp(2)+ees0pijp*yj &
4183 +ees0p(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
4184 gggp(3)=gggp(3)+ees0pijp*zj &
4185 +ees0p(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
4187 gggm(1)=gggm(1)+ees0mijp*xj &
4188 +ees0m(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
4190 gggm(2)=gggm(2)+ees0mijp*yj &
4191 +ees0m(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
4193 gggm(3)=gggm(3)+ees0mijp*zj &
4194 +ees0m(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
4196 ! Derivatives due to the contact function
4197 gacont_hbr(1,num_conti,i)=fprimcont*xj
4198 gacont_hbr(2,num_conti,i)=fprimcont*yj
4199 gacont_hbr(3,num_conti,i)=fprimcont*zj
4202 ! 10/24/08 cgrad and ! comments indicate the parts of the code removed
4203 ! following the change of gradient-summation algorithm.
4205 !grad ghalfp=0.5D0*gggp(k)
4206 !grad ghalfm=0.5D0*gggm(k)
4207 gacontp_hb1(k,num_conti,i)= & !ghalfp+
4208 (ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
4209 + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
4210 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4212 gacontp_hb2(k,num_conti,i)= & !ghalfp+
4213 (ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
4214 + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
4215 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4217 gacontp_hb3(k,num_conti,i)=gggp(k) &
4218 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4220 gacontm_hb1(k,num_conti,i)= & !ghalfm+
4221 (ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
4222 + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
4223 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4225 gacontm_hb2(k,num_conti,i)= & !ghalfm+
4226 (ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
4227 + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1) &
4228 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4230 gacontm_hb3(k,num_conti,i)=gggm(k) &
4231 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4234 ! Diagnostics. Comment out or remove after debugging!
4236 !diag gacontp_hb1(k,num_conti,i)=0.0D0
4237 !diag gacontp_hb2(k,num_conti,i)=0.0D0
4238 !diag gacontp_hb3(k,num_conti,i)=0.0D0
4239 !diag gacontm_hb1(k,num_conti,i)=0.0D0
4240 !diag gacontm_hb2(k,num_conti,i)=0.0D0
4241 !diag gacontm_hb3(k,num_conti,i)=0.0D0
4244 endif ! num_conti.le.maxconts
4247 if (wturn3.gt.0.0d0 .or. wturn4.gt.0.0d0) then
4250 ghalf=0.5d0*agg(l,k)
4251 aggi(l,k)=aggi(l,k)+ghalf
4252 aggi1(l,k)=aggi1(l,k)+agg(l,k)
4253 aggj(l,k)=aggj(l,k)+ghalf
4256 if (j.eq.nres-1 .and. i.lt.j-2) then
4259 aggj1(l,k)=aggj1(l,k)+agg(l,k)
4265 ! t_eelecij=t_eelecij+MPI_Wtime()-time00
4267 end subroutine eelecij
4268 !-----------------------------------------------------------------------------
4269 subroutine eturn3(i,eello_turn3)
4270 ! Third- and fourth-order contributions from turns
4273 ! implicit real*8 (a-h,o-z)
4274 ! include 'DIMENSIONS'
4275 ! include 'COMMON.IOUNITS'
4276 ! include 'COMMON.GEO'
4277 ! include 'COMMON.VAR'
4278 ! include 'COMMON.LOCAL'
4279 ! include 'COMMON.CHAIN'
4280 ! include 'COMMON.DERIV'
4281 ! include 'COMMON.INTERACT'
4282 ! include 'COMMON.CONTACTS'
4283 ! include 'COMMON.TORSION'
4284 ! include 'COMMON.VECTORS'
4285 ! include 'COMMON.FFIELD'
4286 ! include 'COMMON.CONTROL'
4287 real(kind=8),dimension(3) :: ggg
4288 real(kind=8),dimension(2,2) :: auxmat,auxmat1,auxmat2,pizda,&
4289 e1t,e2t,e3t,e1tder,e2tder,e3tder,e1a,ae3,ae3e2
4290 real(kind=8),dimension(2) :: auxvec,auxvec1
4291 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
4292 real(kind=8),dimension(2,2) :: auxmat3 !el, a_temp
4293 !el integer :: num_conti,j1,j2
4294 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
4295 !el dz_normi,xmedi,ymedi,zmedi
4297 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
4298 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
4301 integer :: i,j,l,k,ilist,iresshield
4302 real(kind=8) :: eello_turn3,zj,fracinbuf,eello_t3, rlocshield
4305 ! write (iout,*) "eturn3",i,j,j1,j2
4306 zj=(c(3,j)+c(3,j+1))/2.0d0
4308 if (zj.lt.0) zj=zj+boxzsize
4309 if ((zj.lt.0)) write (*,*) "CHUJ"
4310 if ((zj.gt.bordlipbot) &
4311 .and.(zj.lt.bordliptop)) then
4312 !C the energy transfer exist
4313 if (zj.lt.buflipbot) then
4314 !C what fraction I am in
4316 ((zj-bordlipbot)/lipbufthick)
4317 !C lipbufthick is thickenes of lipid buffore
4318 sslipj=sscalelip(fracinbuf)
4319 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
4320 elseif (zj.gt.bufliptop) then
4321 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
4322 sslipj=sscalelip(fracinbuf)
4323 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
4337 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4339 ! Third-order contributions
4346 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4347 !d call checkint_turn3(i,a_temp,eello_turn3_num)
4348 call matmat2(EUg(1,1,i+1),EUg(1,1,i+2),auxmat(1,1))
4349 call transpose2(auxmat(1,1),auxmat1(1,1))
4350 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4351 if (shield_mode.eq.0) then
4356 eello_turn3=eello_turn3+0.5d0*(pizda(1,1)+pizda(2,2)) &
4357 *fac_shield(i)*fac_shield(j) &
4358 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4360 0.5d0*(pizda(1,1)+pizda(2,2)) &
4361 *fac_shield(i)*fac_shield(j)
4363 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
4364 'eturn3',i,j,0.5d0*(pizda(1,1)+pizda(2,2))
4365 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
4366 (shield_mode.gt.0)) then
4369 do ilist=1,ishield_list(i)
4370 iresshield=shield_list(ilist,i)
4372 rlocshield=grad_shield_side(k,ilist,i)*eello_t3/fac_shield(i)
4373 gshieldx_t3(k,iresshield)=gshieldx_t3(k,iresshield)+ &
4375 +grad_shield_loc(k,ilist,i)*eello_t3/fac_shield(i)
4376 gshieldc_t3(k,iresshield-1)=gshieldc_t3(k,iresshield-1) &
4380 do ilist=1,ishield_list(j)
4381 iresshield=shield_list(ilist,j)
4383 rlocshield=grad_shield_side(k,ilist,j)*eello_t3/fac_shield(j)
4384 gshieldx_t3(k,iresshield)=gshieldx_t3(k,iresshield)+ &
4386 +grad_shield_loc(k,ilist,j)*eello_t3/fac_shield(j)
4387 gshieldc_t3(k,iresshield-1)=gshieldc_t3(k,iresshield-1) &
4394 gshieldc_t3(k,i)=gshieldc_t3(k,i)+ &
4395 grad_shield(k,i)*eello_t3/fac_shield(i)
4396 gshieldc_t3(k,j)=gshieldc_t3(k,j)+ &
4397 grad_shield(k,j)*eello_t3/fac_shield(j)
4398 gshieldc_t3(k,i-1)=gshieldc_t3(k,i-1)+ &
4399 grad_shield(k,i)*eello_t3/fac_shield(i)
4400 gshieldc_t3(k,j-1)=gshieldc_t3(k,j-1)+ &
4401 grad_shield(k,j)*eello_t3/fac_shield(j)
4405 !d write (2,*) 'i,',i,' j',j,'eello_turn3',
4406 !d & 0.5d0*(pizda(1,1)+pizda(2,2)),
4407 !d & ' eello_turn3_num',4*eello_turn3_num
4408 ! Derivatives in gamma(i)
4409 call matmat2(EUgder(1,1,i+1),EUg(1,1,i+2),auxmat2(1,1))
4410 call transpose2(auxmat2(1,1),auxmat3(1,1))
4411 call matmat2(a_temp(1,1),auxmat3(1,1),pizda(1,1))
4412 gel_loc_turn3(i)=gel_loc_turn3(i)+0.5d0*(pizda(1,1)+pizda(2,2))&
4413 *fac_shield(i)*fac_shield(j) &
4414 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4415 ! Derivatives in gamma(i+1)
4416 call matmat2(EUg(1,1,i+1),EUgder(1,1,i+2),auxmat2(1,1))
4417 call transpose2(auxmat2(1,1),auxmat3(1,1))
4418 call matmat2(a_temp(1,1),auxmat3(1,1),pizda(1,1))
4419 gel_loc_turn3(i+1)=gel_loc_turn3(i+1) &
4420 +0.5d0*(pizda(1,1)+pizda(2,2)) &
4421 *fac_shield(i)*fac_shield(j) &
4422 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4424 ! Cartesian derivatives
4426 ! ghalf1=0.5d0*agg(l,1)
4427 ! ghalf2=0.5d0*agg(l,2)
4428 ! ghalf3=0.5d0*agg(l,3)
4429 ! ghalf4=0.5d0*agg(l,4)
4430 a_temp(1,1)=aggi(l,1)!+ghalf1
4431 a_temp(1,2)=aggi(l,2)!+ghalf2
4432 a_temp(2,1)=aggi(l,3)!+ghalf3
4433 a_temp(2,2)=aggi(l,4)!+ghalf4
4434 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4435 gcorr3_turn(l,i)=gcorr3_turn(l,i) &
4436 +0.5d0*(pizda(1,1)+pizda(2,2)) &
4437 *fac_shield(i)*fac_shield(j) &
4438 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4440 a_temp(1,1)=aggi1(l,1)!+agg(l,1)
4441 a_temp(1,2)=aggi1(l,2)!+agg(l,2)
4442 a_temp(2,1)=aggi1(l,3)!+agg(l,3)
4443 a_temp(2,2)=aggi1(l,4)!+agg(l,4)
4444 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4445 gcorr3_turn(l,i+1)=gcorr3_turn(l,i+1) &
4446 +0.5d0*(pizda(1,1)+pizda(2,2)) &
4447 *fac_shield(i)*fac_shield(j) &
4448 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4450 a_temp(1,1)=aggj(l,1)!+ghalf1
4451 a_temp(1,2)=aggj(l,2)!+ghalf2
4452 a_temp(2,1)=aggj(l,3)!+ghalf3
4453 a_temp(2,2)=aggj(l,4)!+ghalf4
4454 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4455 gcorr3_turn(l,j)=gcorr3_turn(l,j) &
4456 +0.5d0*(pizda(1,1)+pizda(2,2)) &
4457 *fac_shield(i)*fac_shield(j) &
4458 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4460 a_temp(1,1)=aggj1(l,1)
4461 a_temp(1,2)=aggj1(l,2)
4462 a_temp(2,1)=aggj1(l,3)
4463 a_temp(2,2)=aggj1(l,4)
4464 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4465 gcorr3_turn(l,j1)=gcorr3_turn(l,j1) &
4466 +0.5d0*(pizda(1,1)+pizda(2,2)) &
4467 *fac_shield(i)*fac_shield(j) &
4468 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4470 gshieldc_t3(3,i)=gshieldc_t3(3,i)+ &
4471 ssgradlipi*eello_t3/4.0d0*lipscale
4472 gshieldc_t3(3,j)=gshieldc_t3(3,j)+ &
4473 ssgradlipj*eello_t3/4.0d0*lipscale
4474 gshieldc_t3(3,i-1)=gshieldc_t3(3,i-1)+ &
4475 ssgradlipi*eello_t3/4.0d0*lipscale
4476 gshieldc_t3(3,j-1)=gshieldc_t3(3,j-1)+ &
4477 ssgradlipj*eello_t3/4.0d0*lipscale
4480 end subroutine eturn3
4481 !-----------------------------------------------------------------------------
4482 subroutine eturn4(i,eello_turn4)
4483 ! Third- and fourth-order contributions from turns
4486 ! implicit real*8 (a-h,o-z)
4487 ! include 'DIMENSIONS'
4488 ! include 'COMMON.IOUNITS'
4489 ! include 'COMMON.GEO'
4490 ! include 'COMMON.VAR'
4491 ! include 'COMMON.LOCAL'
4492 ! include 'COMMON.CHAIN'
4493 ! include 'COMMON.DERIV'
4494 ! include 'COMMON.INTERACT'
4495 ! include 'COMMON.CONTACTS'
4496 ! include 'COMMON.TORSION'
4497 ! include 'COMMON.VECTORS'
4498 ! include 'COMMON.FFIELD'
4499 ! include 'COMMON.CONTROL'
4500 real(kind=8),dimension(3) :: ggg
4501 real(kind=8),dimension(2,2) :: auxmat,auxmat1,auxmat2,pizda,&
4502 e1t,e2t,e3t,e1tder,e2tder,e3tder,e1a,ae3,ae3e2
4503 real(kind=8),dimension(2) :: auxvec,auxvec1
4504 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
4505 real(kind=8),dimension(2,2) :: auxmat3 !el a_temp
4506 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
4507 !el dz_normi,xmedi,ymedi,zmedi
4508 !el integer :: num_conti,j1,j2
4509 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
4510 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
4513 integer :: i,j,iti1,iti2,iti3,l,k,ilist,iresshield
4514 real(kind=8) :: eello_turn4,s1,s2,s3,zj,fracinbuf,eello_t4,&
4518 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4520 ! Fourth-order contributions
4528 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4529 !d call checkint_turn4(i,a_temp,eello_turn4_num)
4530 ! write (iout,*) "eturn4 i",i," j",j," j1",j1," j2",j2
4531 zj=(c(3,j)+c(3,j+1))/2.0d0
4533 if (zj.lt.0) zj=zj+boxzsize
4534 if ((zj.gt.bordlipbot) &
4535 .and.(zj.lt.bordliptop)) then
4536 !C the energy transfer exist
4537 if (zj.lt.buflipbot) then
4538 !C what fraction I am in
4540 ((zj-bordlipbot)/lipbufthick)
4541 !C lipbufthick is thickenes of lipid buffore
4542 sslipj=sscalelip(fracinbuf)
4543 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
4544 elseif (zj.gt.bufliptop) then
4545 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
4546 sslipj=sscalelip(fracinbuf)
4547 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
4561 iti1=itortyp(itype(i+1,1))
4562 iti2=itortyp(itype(i+2,1))
4563 iti3=itortyp(itype(i+3,1))
4564 ! write(iout,*) "iti1",iti1," iti2",iti2," iti3",iti3
4565 call transpose2(EUg(1,1,i+1),e1t(1,1))
4566 call transpose2(Eug(1,1,i+2),e2t(1,1))
4567 call transpose2(Eug(1,1,i+3),e3t(1,1))
4568 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4569 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4570 s1=scalar2(b1(1,iti2),auxvec(1))
4571 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4572 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4573 s2=scalar2(b1(1,iti1),auxvec(1))
4574 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4575 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4576 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4577 if (shield_mode.eq.0) then
4582 eello_turn4=eello_turn4-(s1+s2+s3) &
4583 *fac_shield(i)*fac_shield(j) &
4584 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4585 eello_t4=-(s1+s2+s3) &
4586 *fac_shield(i)*fac_shield(j)
4587 !C Now derivative over shield:
4588 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
4589 (shield_mode.gt.0)) then
4592 do ilist=1,ishield_list(i)
4593 iresshield=shield_list(ilist,i)
4595 rlocshield=grad_shield_side(k,ilist,i)*eello_t4/fac_shield(i)
4596 gshieldx_t4(k,iresshield)=gshieldx_t4(k,iresshield)+ &
4598 +grad_shield_loc(k,ilist,i)*eello_t4/fac_shield(i)
4599 gshieldc_t4(k,iresshield-1)=gshieldc_t4(k,iresshield-1) &
4603 do ilist=1,ishield_list(j)
4604 iresshield=shield_list(ilist,j)
4606 rlocshield=grad_shield_side(k,ilist,j)*eello_t4/fac_shield(j)
4607 gshieldx_t4(k,iresshield)=gshieldx_t4(k,iresshield)+ &
4609 +grad_shield_loc(k,ilist,j)*eello_t4/fac_shield(j)
4610 gshieldc_t4(k,iresshield-1)=gshieldc_t4(k,iresshield-1) &
4617 gshieldc_t4(k,i)=gshieldc_t4(k,i)+ &
4618 grad_shield(k,i)*eello_t4/fac_shield(i)
4619 gshieldc_t4(k,j)=gshieldc_t4(k,j)+ &
4620 grad_shield(k,j)*eello_t4/fac_shield(j)
4621 gshieldc_t4(k,i-1)=gshieldc_t4(k,i-1)+ &
4622 grad_shield(k,i)*eello_t4/fac_shield(i)
4623 gshieldc_t4(k,j-1)=gshieldc_t4(k,j-1)+ &
4624 grad_shield(k,j)*eello_t4/fac_shield(j)
4628 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
4629 'eturn4',i,j,-(s1+s2+s3)
4630 !d write (2,*) 'i,',i,' j',j,'eello_turn4',-(s1+s2+s3),
4631 !d & ' eello_turn4_num',8*eello_turn4_num
4632 ! Derivatives in gamma(i)
4633 call transpose2(EUgder(1,1,i+1),e1tder(1,1))
4634 call matmat2(e1tder(1,1),a_temp(1,1),auxmat(1,1))
4635 call matvec2(auxmat(1,1),Ub2(1,i+3),auxvec(1))
4636 s1=scalar2(b1(1,iti2),auxvec(1))
4637 call matmat2(ae3e2(1,1),e1tder(1,1),pizda(1,1))
4638 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4639 gel_loc_turn4(i)=gel_loc_turn4(i)-(s1+s3) &
4640 *fac_shield(i)*fac_shield(j) &
4641 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4643 ! Derivatives in gamma(i+1)
4644 call transpose2(EUgder(1,1,i+2),e2tder(1,1))
4645 call matvec2(ae3(1,1),Ub2der(1,i+2),auxvec(1))
4646 s2=scalar2(b1(1,iti1),auxvec(1))
4647 call matmat2(ae3(1,1),e2tder(1,1),auxmat(1,1))
4648 call matmat2(auxmat(1,1),e1t(1,1),pizda(1,1))
4649 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4650 gel_loc_turn4(i+1)=gel_loc_turn4(i+1)-(s2+s3) &
4651 *fac_shield(i)*fac_shield(j) &
4652 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4654 ! Derivatives in gamma(i+2)
4655 call transpose2(EUgder(1,1,i+3),e3tder(1,1))
4656 call matvec2(e1a(1,1),Ub2der(1,i+3),auxvec(1))
4657 s1=scalar2(b1(1,iti2),auxvec(1))
4658 call matmat2(a_temp(1,1),e3tder(1,1),auxmat(1,1))
4659 call matvec2(auxmat(1,1),Ub2(1,i+2),auxvec(1))
4660 s2=scalar2(b1(1,iti1),auxvec(1))
4661 call matmat2(auxmat(1,1),e2t(1,1),auxmat3(1,1))
4662 call matmat2(auxmat3(1,1),e1t(1,1),pizda(1,1))
4663 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4664 gel_loc_turn4(i+2)=gel_loc_turn4(i+2)-(s1+s2+s3) &
4665 *fac_shield(i)*fac_shield(j) &
4666 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4668 ! Cartesian derivatives
4669 ! Derivatives of this turn contributions in DC(i+2)
4670 if (j.lt.nres-1) then
4672 a_temp(1,1)=agg(l,1)
4673 a_temp(1,2)=agg(l,2)
4674 a_temp(2,1)=agg(l,3)
4675 a_temp(2,2)=agg(l,4)
4676 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4677 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4678 s1=scalar2(b1(1,iti2),auxvec(1))
4679 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4680 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4681 s2=scalar2(b1(1,iti1),auxvec(1))
4682 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4683 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4684 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4686 gcorr4_turn(l,i+2)=gcorr4_turn(l,i+2)-(s1+s2+s3)&
4687 *fac_shield(i)*fac_shield(j) &
4688 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4692 ! Remaining derivatives of this turn contribution
4694 a_temp(1,1)=aggi(l,1)
4695 a_temp(1,2)=aggi(l,2)
4696 a_temp(2,1)=aggi(l,3)
4697 a_temp(2,2)=aggi(l,4)
4698 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4699 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4700 s1=scalar2(b1(1,iti2),auxvec(1))
4701 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4702 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4703 s2=scalar2(b1(1,iti1),auxvec(1))
4704 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4705 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4706 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4707 gcorr4_turn(l,i)=gcorr4_turn(l,i)-(s1+s2+s3) &
4708 *fac_shield(i)*fac_shield(j) &
4709 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4712 a_temp(1,1)=aggi1(l,1)
4713 a_temp(1,2)=aggi1(l,2)
4714 a_temp(2,1)=aggi1(l,3)
4715 a_temp(2,2)=aggi1(l,4)
4716 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4717 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4718 s1=scalar2(b1(1,iti2),auxvec(1))
4719 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4720 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4721 s2=scalar2(b1(1,iti1),auxvec(1))
4722 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4723 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4724 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4725 gcorr4_turn(l,i+1)=gcorr4_turn(l,i+1)-(s1+s2+s3) &
4726 *fac_shield(i)*fac_shield(j) &
4727 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4730 a_temp(1,1)=aggj(l,1)
4731 a_temp(1,2)=aggj(l,2)
4732 a_temp(2,1)=aggj(l,3)
4733 a_temp(2,2)=aggj(l,4)
4734 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4735 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4736 s1=scalar2(b1(1,iti2),auxvec(1))
4737 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4738 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4739 s2=scalar2(b1(1,iti1),auxvec(1))
4740 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4741 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4742 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4743 gcorr4_turn(l,j)=gcorr4_turn(l,j)-(s1+s2+s3) &
4744 *fac_shield(i)*fac_shield(j) &
4745 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4748 a_temp(1,1)=aggj1(l,1)
4749 a_temp(1,2)=aggj1(l,2)
4750 a_temp(2,1)=aggj1(l,3)
4751 a_temp(2,2)=aggj1(l,4)
4752 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4753 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4754 s1=scalar2(b1(1,iti2),auxvec(1))
4755 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4756 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4757 s2=scalar2(b1(1,iti1),auxvec(1))
4758 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4759 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4760 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4761 ! write (iout,*) "s1",s1," s2",s2," s3",s3," s1+s2+s3",s1+s2+s3
4762 gcorr4_turn(l,j1)=gcorr4_turn(l,j1)-(s1+s2+s3) &
4763 *fac_shield(i)*fac_shield(j) &
4764 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4767 gshieldc_t4(3,i)=gshieldc_t4(3,i)+ &
4768 ssgradlipi*eello_t4/4.0d0*lipscale
4769 gshieldc_t4(3,j)=gshieldc_t4(3,j)+ &
4770 ssgradlipj*eello_t4/4.0d0*lipscale
4771 gshieldc_t4(3,i-1)=gshieldc_t4(3,i-1)+ &
4772 ssgradlipi*eello_t4/4.0d0*lipscale
4773 gshieldc_t4(3,j-1)=gshieldc_t4(3,j-1)+ &
4774 ssgradlipj*eello_t4/4.0d0*lipscale
4777 end subroutine eturn4
4778 !-----------------------------------------------------------------------------
4779 subroutine unormderiv(u,ugrad,unorm,ungrad)
4780 ! This subroutine computes the derivatives of a normalized vector u, given
4781 ! the derivatives computed without normalization conditions, ugrad. Returns
4784 real(kind=8),dimension(3) :: u,vec
4785 real(kind=8),dimension(3,3) ::ugrad,ungrad
4786 real(kind=8) :: unorm !,scalar
4788 ! write (2,*) 'ugrad',ugrad
4791 vec(i)=scalar(ugrad(1,i),u(1))
4793 ! write (2,*) 'vec',vec
4796 ungrad(j,i)=(ugrad(j,i)-u(j)*vec(i))*unorm
4799 ! write (2,*) 'ungrad',ungrad
4801 end subroutine unormderiv
4802 !-----------------------------------------------------------------------------
4803 subroutine escp_soft_sphere(evdw2,evdw2_14)
4805 ! This subroutine calculates the excluded-volume interaction energy between
4806 ! peptide-group centers and side chains and its gradient in virtual-bond and
4807 ! side-chain vectors.
4809 ! implicit real*8 (a-h,o-z)
4810 ! include 'DIMENSIONS'
4811 ! include 'COMMON.GEO'
4812 ! include 'COMMON.VAR'
4813 ! include 'COMMON.LOCAL'
4814 ! include 'COMMON.CHAIN'
4815 ! include 'COMMON.DERIV'
4816 ! include 'COMMON.INTERACT'
4817 ! include 'COMMON.FFIELD'
4818 ! include 'COMMON.IOUNITS'
4819 ! include 'COMMON.CONTROL'
4820 real(kind=8),dimension(3) :: ggg
4822 integer :: i,iint,j,k,iteli,itypj
4823 real(kind=8) :: evdw2,evdw2_14,r0_scp,xi,yi,zi,xj,yj,zj,&
4824 fac,rij,r0ij,r0ijsq,evdwij,e1,e2
4829 !d print '(a)','Enter ESCP'
4830 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
4831 do i=iatscp_s,iatscp_e
4832 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
4834 xi=0.5D0*(c(1,i)+c(1,i+1))
4835 yi=0.5D0*(c(2,i)+c(2,i+1))
4836 zi=0.5D0*(c(3,i)+c(3,i+1))
4838 do iint=1,nscp_gr(i)
4840 do j=iscpstart(i,iint),iscpend(i,iint)
4841 if (itype(j,1).eq.ntyp1) cycle
4842 itypj=iabs(itype(j,1))
4843 ! Uncomment following three lines for SC-p interactions
4847 ! Uncomment following three lines for Ca-p interactions
4851 rij=xj*xj+yj*yj+zj*zj
4854 if (rij.lt.r0ijsq) then
4855 evdwij=0.25d0*(rij-r0ijsq)**2
4863 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
4868 !grad if (j.lt.i) then
4869 !d write (iout,*) 'j<i'
4870 ! Uncomment following three lines for SC-p interactions
4872 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
4875 !d write (iout,*) 'j>i'
4877 !grad ggg(k)=-ggg(k)
4878 ! Uncomment following line for SC-p interactions
4879 ! gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
4883 !grad gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
4885 !grad kstart=min0(i+1,j)
4886 !grad kend=max0(i-1,j-1)
4887 !d write (iout,*) 'i=',i,' j=',j,' kstart=',kstart,' kend=',kend
4888 !d write (iout,*) ggg(1),ggg(2),ggg(3)
4889 !grad do k=kstart,kend
4891 !grad gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
4895 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
4896 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
4903 end subroutine escp_soft_sphere
4904 !-----------------------------------------------------------------------------
4905 subroutine escp(evdw2,evdw2_14)
4907 ! This subroutine calculates the excluded-volume interaction energy between
4908 ! peptide-group centers and side chains and its gradient in virtual-bond and
4909 ! side-chain vectors.
4911 ! implicit real*8 (a-h,o-z)
4912 ! include 'DIMENSIONS'
4913 ! include 'COMMON.GEO'
4914 ! include 'COMMON.VAR'
4915 ! include 'COMMON.LOCAL'
4916 ! include 'COMMON.CHAIN'
4917 ! include 'COMMON.DERIV'
4918 ! include 'COMMON.INTERACT'
4919 ! include 'COMMON.FFIELD'
4920 ! include 'COMMON.IOUNITS'
4921 ! include 'COMMON.CONTROL'
4922 real(kind=8),dimension(3) :: ggg
4924 integer :: i,iint,j,k,iteli,itypj,subchap
4925 real(kind=8) :: evdw2,evdw2_14,xi,yi,zi,xj,yj,zj,rrij,fac,&
4927 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
4928 dist_temp, dist_init
4929 integer xshift,yshift,zshift
4933 !d print '(a)','Enter ESCP'
4934 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
4935 do i=iatscp_s,iatscp_e
4936 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
4938 xi=0.5D0*(c(1,i)+c(1,i+1))
4939 yi=0.5D0*(c(2,i)+c(2,i+1))
4940 zi=0.5D0*(c(3,i)+c(3,i+1))
4942 if (xi.lt.0) xi=xi+boxxsize
4944 if (yi.lt.0) yi=yi+boxysize
4946 if (zi.lt.0) zi=zi+boxzsize
4948 do iint=1,nscp_gr(i)
4950 do j=iscpstart(i,iint),iscpend(i,iint)
4951 itypj=iabs(itype(j,1))
4952 if (itypj.eq.ntyp1) cycle
4953 ! Uncomment following three lines for SC-p interactions
4957 ! Uncomment following three lines for Ca-p interactions
4965 if (xj.lt.0) xj=xj+boxxsize
4967 if (yj.lt.0) yj=yj+boxysize
4969 if (zj.lt.0) zj=zj+boxzsize
4970 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
4978 xj=xj_safe+xshift*boxxsize
4979 yj=yj_safe+yshift*boxysize
4980 zj=zj_safe+zshift*boxzsize
4981 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
4982 if(dist_temp.lt.dist_init) then
4992 if (subchap.eq.1) then
5002 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
5003 rij=dsqrt(1.0d0/rrij)
5004 sss_ele_cut=sscale_ele(rij)
5005 sss_ele_grad=sscagrad_ele(rij)
5006 ! print *,sss_ele_cut,sss_ele_grad,&
5007 ! (rij),r_cut_ele,rlamb_ele
5008 if (sss_ele_cut.le.0.0) cycle
5010 e1=fac*fac*aad(itypj,iteli)
5011 e2=fac*bad(itypj,iteli)
5012 if (iabs(j-i) .le. 2) then
5015 evdw2_14=evdw2_14+(e1+e2)*sss_ele_cut
5018 evdw2=evdw2+evdwij*sss_ele_cut
5019 ! if (energy_dec) write (iout,'(a6,2i5,0pf7.3,2i3,3e11.3)') &
5020 ! 'evdw2',i,j,evdwij,iteli,itypj,fac,aad(itypj,iteli),&
5021 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
5024 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
5026 fac=-(evdwij+e1)*rrij*sss_ele_cut
5027 fac=fac+evdwij*sss_ele_grad/rij/expon
5031 !grad if (j.lt.i) then
5032 !d write (iout,*) 'j<i'
5033 ! Uncomment following three lines for SC-p interactions
5035 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
5038 !d write (iout,*) 'j>i'
5040 !grad ggg(k)=-ggg(k)
5041 ! Uncomment following line for SC-p interactions
5042 !cgrad gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
5043 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
5047 !grad gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
5049 !grad kstart=min0(i+1,j)
5050 !grad kend=max0(i-1,j-1)
5051 !d write (iout,*) 'i=',i,' j=',j,' kstart=',kstart,' kend=',kend
5052 !d write (iout,*) ggg(1),ggg(2),ggg(3)
5053 !grad do k=kstart,kend
5055 !grad gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
5059 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
5060 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
5068 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
5069 gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
5070 gradx_scp(j,i)=expon*gradx_scp(j,i)
5073 !******************************************************************************
5077 ! To save time the factor EXPON has been extracted from ALL components
5078 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
5081 !******************************************************************************
5084 !-----------------------------------------------------------------------------
5085 subroutine edis(ehpb)
5087 ! Evaluate bridge-strain energy and its gradient in virtual-bond and SC vectors.
5089 ! implicit real*8 (a-h,o-z)
5090 ! include 'DIMENSIONS'
5091 ! include 'COMMON.SBRIDGE'
5092 ! include 'COMMON.CHAIN'
5093 ! include 'COMMON.DERIV'
5094 ! include 'COMMON.VAR'
5095 ! include 'COMMON.INTERACT'
5096 ! include 'COMMON.IOUNITS'
5097 real(kind=8),dimension(3) :: ggg
5099 integer :: i,j,ii,jj,iii,jjj,k
5100 real(kind=8) :: fac,eij,rdis,ehpb,dd,waga
5103 !d write(iout,*)'edis: nhpb=',nhpb,' fbr=',fbr
5104 !d write(iout,*)'link_start=',link_start,' link_end=',link_end
5105 if (link_end.eq.0) return
5106 do i=link_start,link_end
5107 ! If ihpb(i) and jhpb(i) > NRES, this is a SC-SC distance, otherwise a
5108 ! CA-CA distance used in regularization of structure.
5111 ! iii and jjj point to the residues for which the distance is assigned.
5112 if (ii.gt.nres) then
5119 ! write (iout,*) "i",i," ii",ii," iii",iii," jj",jj," jjj",jjj,
5120 ! & dhpb(i),dhpb1(i),forcon(i)
5121 ! 24/11/03 AL: SS bridges handled separately because of introducing a specific
5122 ! distance and angle dependent SS bond potential.
5123 !mc if (ii.gt.nres .and. itype(iii).eq.1 .and. itype(jjj).eq.1) then
5124 ! 18/07/06 MC: Use the convention that the first nss pairs are SS bonds
5125 if (.not.dyn_ss .and. i.le.nss) then
5126 ! 15/02/13 CC dynamic SSbond - additional check
5127 if (ii.gt.nres .and. iabs(itype(iii,1)).eq.1 .and. &
5128 iabs(itype(jjj,1)).eq.1) then
5129 call ssbond_ene(iii,jjj,eij)
5131 !d write (iout,*) "eij",eij
5133 else if (ii.gt.nres .and. jj.gt.nres) then
5134 !c Restraints from contact prediction
5136 if (constr_dist.eq.11) then
5137 ehpb=ehpb+fordepth(i)**4.0d0 &
5138 *rlornmr1(dd,dhpb(i),dhpb1(i),forcon(i))
5139 fac=fordepth(i)**4.0d0 &
5140 *rlornmr1prim(dd,dhpb(i),dhpb1(i),forcon(i))/dd
5141 if (energy_dec) write (iout,'(a6,2i5,3f8.3)') "edisl",ii,jj, &
5144 if (dhpb1(i).gt.0.0d0) then
5145 ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5146 fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
5147 !c write (iout,*) "beta nmr",
5148 !c & dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5152 !C Get the force constant corresponding to this distance.
5154 !C Calculate the contribution to energy.
5155 ehpb=ehpb+waga*rdis*rdis
5156 !c write (iout,*) "beta reg",dd,waga*rdis*rdis
5158 !C Evaluate gradient.
5164 ggg(j)=fac*(c(j,jj)-c(j,ii))
5167 ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
5168 ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
5171 ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
5172 ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
5176 if (constr_dist.eq.11) then
5177 ehpb=ehpb+fordepth(i)**4.0d0 &
5178 *rlornmr1(dd,dhpb(i),dhpb1(i),forcon(i))
5179 fac=fordepth(i)**4.0d0 &
5180 *rlornmr1prim(dd,dhpb(i),dhpb1(i),forcon(i))/dd
5181 if (energy_dec) write (iout,'(a6,2i5,3f8.3)') "edisl",ii,jj, &
5184 if (dhpb1(i).gt.0.0d0) then
5185 ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5186 fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
5187 !c write (iout,*) "alph nmr",
5188 !c & dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5191 !C Get the force constant corresponding to this distance.
5193 !C Calculate the contribution to energy.
5194 ehpb=ehpb+waga*rdis*rdis
5195 !c write (iout,*) "alpha reg",dd,waga*rdis*rdis
5197 !C Evaluate gradient.
5204 ggg(j)=fac*(c(j,jj)-c(j,ii))
5206 !cd print '(i3,3(1pe14.5))',i,(ggg(j),j=1,3)
5207 !C If this is a SC-SC distance, we need to calculate the contributions to the
5208 !C Cartesian gradient in the SC vectors (ghpbx).
5211 ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
5212 ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
5215 !cgrad do j=iii,jjj-1
5217 !cgrad ghpbc(k,j)=ghpbc(k,j)+ggg(k)
5221 ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
5222 ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
5226 if (constr_dist.ne.11) ehpb=0.5D0*ehpb
5230 !-----------------------------------------------------------------------------
5231 subroutine ssbond_ene(i,j,eij)
5233 ! Calculate the distance and angle dependent SS-bond potential energy
5234 ! using a free-energy function derived based on RHF/6-31G** ab initio
5235 ! calculations of diethyl disulfide.
5237 ! A. Liwo and U. Kozlowska, 11/24/03
5239 ! implicit real*8 (a-h,o-z)
5240 ! include 'DIMENSIONS'
5241 ! include 'COMMON.SBRIDGE'
5242 ! include 'COMMON.CHAIN'
5243 ! include 'COMMON.DERIV'
5244 ! include 'COMMON.LOCAL'
5245 ! include 'COMMON.INTERACT'
5246 ! include 'COMMON.VAR'
5247 ! include 'COMMON.IOUNITS'
5248 real(kind=8),dimension(3) :: erij,dcosom1,dcosom2,gg
5250 integer :: i,j,itypi,itypj,k
5251 real(kind=8) :: eij,rij,rrij,xi,yi,zi,dxi,dyi,dzi,dsci_inv,&
5252 xj,yj,zj,dxj,dyj,dzj,om1,om2,om12,deltad,dscj_inv,&
5253 deltat1,deltat2,deltat12,ed,pom1,pom2,eom1,eom2,eom12,&
5256 itypi=iabs(itype(i,1))
5260 dxi=dc_norm(1,nres+i)
5261 dyi=dc_norm(2,nres+i)
5262 dzi=dc_norm(3,nres+i)
5263 ! dsci_inv=dsc_inv(itypi)
5264 dsci_inv=vbld_inv(nres+i)
5265 itypj=iabs(itype(j,1))
5266 ! dscj_inv=dsc_inv(itypj)
5267 dscj_inv=vbld_inv(nres+j)
5271 dxj=dc_norm(1,nres+j)
5272 dyj=dc_norm(2,nres+j)
5273 dzj=dc_norm(3,nres+j)
5274 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
5279 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
5280 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
5281 om12=dxi*dxj+dyi*dyj+dzi*dzj
5283 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
5284 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
5290 deltat12=om2-om1+2.0d0
5292 eij=akcm*deltad*deltad+akth*(deltat1*deltat1+deltat2*deltat2) &
5293 +akct*deltad*deltat12 &
5294 +v1ss*cosphi+v2ss*cosphi*cosphi+v3ss*cosphi*cosphi*cosphi+ebr
5295 ! write(iout,*) i,j,"rij",rij,"d0cm",d0cm," akcm",akcm," akth",akth,
5296 ! & " akct",akct," deltad",deltad," deltat",deltat1,deltat2,
5297 ! & " deltat12",deltat12," eij",eij
5298 ed=2*akcm*deltad+akct*deltat12
5300 pom2=v1ss+2*v2ss*cosphi+3*v3ss*cosphi*cosphi
5301 eom1=-2*akth*deltat1-pom1-om2*pom2
5302 eom2= 2*akth*deltat2+pom1-om1*pom2
5305 ggk=ed*erij(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
5306 ghpbx(k,i)=ghpbx(k,i)-ggk &
5307 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
5308 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
5309 ghpbx(k,j)=ghpbx(k,j)+ggk &
5310 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
5311 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
5312 ghpbc(k,i)=ghpbc(k,i)-ggk
5313 ghpbc(k,j)=ghpbc(k,j)+ggk
5316 ! Calculate the components of the gradient in DC and X
5320 !grad ghpbc(l,k)=ghpbc(l,k)+gg(l)
5324 end subroutine ssbond_ene
5325 !-----------------------------------------------------------------------------
5326 subroutine ebond(estr)
5328 ! Evaluate the energy of stretching of the CA-CA and CA-SC virtual bonds
5330 ! implicit real*8 (a-h,o-z)
5331 ! include 'DIMENSIONS'
5332 ! include 'COMMON.LOCAL'
5333 ! include 'COMMON.GEO'
5334 ! include 'COMMON.INTERACT'
5335 ! include 'COMMON.DERIV'
5336 ! include 'COMMON.VAR'
5337 ! include 'COMMON.CHAIN'
5338 ! include 'COMMON.IOUNITS'
5339 ! include 'COMMON.NAMES'
5340 ! include 'COMMON.FFIELD'
5341 ! include 'COMMON.CONTROL'
5342 ! include 'COMMON.SETUP'
5343 real(kind=8),dimension(3) :: u,ud
5345 integer :: i,j,iti,nbi,k
5346 real(kind=8) :: estr,estr1,diff,uprod,usum,usumsqder,&
5351 ! if (.not.allocated(gradb)) allocate(gradb(3,nres)) !(3,maxres)
5352 ! if (.not.allocated(gradbx)) allocate(gradbx(3,nres)) !(3,maxres)
5354 do i=ibondp_start,ibondp_end
5355 if (itype(i-1,1).eq.ntyp1 .and. itype(i,1).eq.ntyp1) cycle
5356 if (itype(i-1,1).eq.ntyp1 .or. itype(i,1).eq.ntyp1) then
5357 !C estr1=estr1+gnmr1(vbld(i),-1.0d0,distchainmax)
5359 !C gradb(j,i-1)=gnmr1prim(vbld(i),-1.0d0,distchainmax) &
5360 !C *dc(j,i-1)/vbld(i)
5362 !C if (energy_dec) write(iout,*) &
5363 !C "estr1",i,gnmr1(vbld(i),-1.0d0,distchainmax)
5364 diff = vbld(i)-vbldpDUM
5366 diff = vbld(i)-vbldp0
5368 if (energy_dec) write (iout,'(a7,i5,4f7.3)') &
5369 "estr bb",i,vbld(i),vbldp0,diff,AKP*diff*diff
5372 gradb(j,i-1)=AKP*diff*dc(j,i-1)/vbld(i)
5374 ! write (iout,'(i5,3f10.5)') i,(gradb(j,i-1),j=1,3)
5377 estr=0.5d0*AKP*estr+estr1
5378 ! print *,"estr_bb",estr,AKP
5380 ! 09/18/07 AL: multimodal bond potential based on AM1 CA-SC PMF's included
5382 do i=ibond_start,ibond_end
5383 iti=iabs(itype(i,1))
5384 if (iti.eq.0) print *,"WARNING WRONG SETTTING",i
5385 if (iti.ne.10 .and. iti.ne.ntyp1) then
5388 diff=vbld(i+nres)-vbldsc0(1,iti)
5389 if (energy_dec) write (iout,*) &
5390 "estr sc",i,iti,vbld(i+nres),vbldsc0(1,iti),diff,&
5391 AKSC(1,iti),AKSC(1,iti)*diff*diff
5392 estr=estr+0.5d0*AKSC(1,iti)*diff*diff
5393 ! print *,"estr_sc",estr
5395 gradbx(j,i)=AKSC(1,iti)*diff*dc(j,i+nres)/vbld(i+nres)
5399 diff=vbld(i+nres)-vbldsc0(j,iti)
5400 ud(j)=aksc(j,iti)*diff
5401 u(j)=abond0(j,iti)+0.5d0*ud(j)*diff
5415 uprod2=uprod2*u(k)*u(k)
5419 usumsqder=usumsqder+ud(j)*uprod2
5421 estr=estr+uprod/usum
5422 ! print *,"estr_sc",estr,i
5424 if (energy_dec) write (iout,*) &
5425 "estr sc",i,iti,vbld(i+nres),vbldsc0(1,iti),diff,&
5426 AKSC(1,iti),uprod/usum
5428 gradbx(j,i)=usumsqder/(usum*usum)*dc(j,i+nres)/vbld(i+nres)
5434 end subroutine ebond
5436 !-----------------------------------------------------------------------------
5437 subroutine ebend(etheta)
5439 ! Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
5440 ! angles gamma and its derivatives in consecutive thetas and gammas.
5443 ! implicit real*8 (a-h,o-z)
5444 ! include 'DIMENSIONS'
5445 ! include 'COMMON.LOCAL'
5446 ! include 'COMMON.GEO'
5447 ! include 'COMMON.INTERACT'
5448 ! include 'COMMON.DERIV'
5449 ! include 'COMMON.VAR'
5450 ! include 'COMMON.CHAIN'
5451 ! include 'COMMON.IOUNITS'
5452 ! include 'COMMON.NAMES'
5453 ! include 'COMMON.FFIELD'
5454 ! include 'COMMON.CONTROL'
5455 !el real(kind=8) :: term1,term2,termm,diffak,ratak,&
5456 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
5457 !el delthe0,sig0inv,sigtc,sigsqtc,delthec
5459 !el common /calcthet/ term1,term2,termm,diffak,ratak,&
5460 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
5461 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,it
5463 integer :: i,k,ichir1,ichir2,itype1,ichir11,ichir12,itype2,&
5465 real(kind=8) :: etheta,delta,ss,ssd,phii,phii1,thet_pred_mean,&
5466 athetk,bthetk,dthett,dthetg1,dthetg2,f0,fprim0,E_tc0,fprim_tc0,&
5467 f1,fprim1,E_tc1,ethetai,E_theta,E_tc
5468 real(kind=8),dimension(2) :: y,z
5471 ! time11=dexp(-2*time)
5474 ! write (*,'(a,i2)') 'EBEND ICG=',icg
5475 do i=ithet_start,ithet_end
5476 if (itype(i-1,1).eq.ntyp1) cycle
5477 ! Zero the energy function and its derivative at 0 or pi.
5478 call splinthet(theta(i),0.5d0*delta,ss,ssd)
5480 ichir1=isign(1,itype(i-2,1))
5481 ichir2=isign(1,itype(i,1))
5482 if (itype(i-2,1).eq.10) ichir1=isign(1,itype(i-1,1))
5483 if (itype(i,1).eq.10) ichir2=isign(1,itype(i-1,1))
5484 if (itype(i-1,1).eq.10) then
5485 itype1=isign(10,itype(i-2,1))
5486 ichir11=isign(1,itype(i-2,1))
5487 ichir12=isign(1,itype(i-2,1))
5488 itype2=isign(10,itype(i,1))
5489 ichir21=isign(1,itype(i,1))
5490 ichir22=isign(1,itype(i,1))
5493 if (i.gt.3 .and. itype(i-2,1).ne.ntyp1) then
5496 if (phii.ne.phii) phii=150.0
5506 if (i.lt.nres .and. itype(i,1).ne.ntyp1) then
5509 if (phii1.ne.phii1) phii1=150.0
5521 ! Calculate the "mean" value of theta from the part of the distribution
5522 ! dependent on the adjacent virtual-bond-valence angles (gamma1 & gamma2).
5523 ! In following comments this theta will be referred to as t_c.
5524 thet_pred_mean=0.0d0
5526 athetk=athet(k,it,ichir1,ichir2)
5527 bthetk=bthet(k,it,ichir1,ichir2)
5529 athetk=athet(k,itype1,ichir11,ichir12)
5530 bthetk=bthet(k,itype2,ichir21,ichir22)
5532 thet_pred_mean=thet_pred_mean+athetk*y(k)+bthetk*z(k)
5534 dthett=thet_pred_mean*ssd
5535 thet_pred_mean=thet_pred_mean*ss+a0thet(it)
5536 ! Derivatives of the "mean" values in gamma1 and gamma2.
5537 dthetg1=(-athet(1,it,ichir1,ichir2)*y(2) &
5538 +athet(2,it,ichir1,ichir2)*y(1))*ss
5539 dthetg2=(-bthet(1,it,ichir1,ichir2)*z(2) &
5540 +bthet(2,it,ichir1,ichir2)*z(1))*ss
5542 dthetg1=(-athet(1,itype1,ichir11,ichir12)*y(2) &
5543 +athet(2,itype1,ichir11,ichir12)*y(1))*ss
5544 dthetg2=(-bthet(1,itype2,ichir21,ichir22)*z(2) &
5545 +bthet(2,itype2,ichir21,ichir22)*z(1))*ss
5547 if (theta(i).gt.pi-delta) then
5548 call theteng(pi-delta,thet_pred_mean,theta0(it),f0,fprim0,&
5550 call mixder(pi-delta,thet_pred_mean,theta0(it),fprim_tc0)
5551 call theteng(pi,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
5552 call spline1(theta(i),pi-delta,delta,f0,f1,fprim0,ethetai,&
5554 call spline2(theta(i),pi-delta,delta,E_tc0,E_tc1,fprim_tc0,&
5556 else if (theta(i).lt.delta) then
5557 call theteng(delta,thet_pred_mean,theta0(it),f0,fprim0,E_tc0)
5558 call theteng(0.0d0,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
5559 call spline1(theta(i),delta,-delta,f0,f1,fprim0,ethetai,&
5561 call mixder(delta,thet_pred_mean,theta0(it),fprim_tc0)
5562 call spline2(theta(i),delta,-delta,E_tc0,E_tc1,fprim_tc0,&
5565 call theteng(theta(i),thet_pred_mean,theta0(it),ethetai,&
5568 etheta=etheta+ethetai
5569 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
5571 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*E_tc*dthetg1
5572 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*E_tc*dthetg2
5573 gloc(nphi+i-2,icg)=wang*(E_theta+E_tc*dthett)
5575 ! print *,ithetaconstr_start,ithetaconstr_end,"TU"
5577 ! Ufff.... We've done all this!!!
5579 end subroutine ebend
5580 !-----------------------------------------------------------------------------
5581 subroutine theteng(thetai,thet_pred_mean,theta0i,ethetai,E_theta,E_tc)
5584 ! implicit real*8 (a-h,o-z)
5585 ! include 'DIMENSIONS'
5586 ! include 'COMMON.LOCAL'
5587 ! include 'COMMON.IOUNITS'
5588 !el real(kind=8) :: term1,term2,termm,diffak,ratak,&
5589 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
5590 !el delthe0,sig0inv,sigtc,sigsqtc,delthec
5592 real(kind=8) :: thetai,thet_pred_mean,theta0i,ethetai,E_theta,E_tc
5594 !el common /calcthet/ term1,term2,termm,diffak,ratak,&
5595 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
5596 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,it
5598 real(kind=8) :: sig,fac,escloci0,escloci1,esclocbi0,dersc12,&
5599 esclocbi1,chuju,esclocbi,dersc02,dersc01,ss,ssd
5601 ! Calculate the contributions to both Gaussian lobes.
5602 ! 6/6/97 - Deform the Gaussians using the factor of 1/(1+time)
5603 ! The "polynomial part" of the "standard deviation" of this part of
5607 sig=sig*thet_pred_mean+polthet(j,it)
5609 ! Derivative of the "interior part" of the "standard deviation of the"
5610 ! gamma-dependent Gaussian lobe in t_c.
5611 sigtc=3*polthet(3,it)
5613 sigtc=sigtc*thet_pred_mean+j*polthet(j,it)
5616 ! Set the parameters of both Gaussian lobes of the distribution.
5617 ! "Standard deviation" of the gamma-dependent Gaussian lobe (sigtc)
5618 fac=sig*sig+sigc0(it)
5621 ! Following variable (sigsqtc) is -(1/2)d[sigma(t_c)**(-2))]/dt_c
5622 sigsqtc=-4.0D0*sigcsq*sigtc
5623 ! print *,i,sig,sigtc,sigsqtc
5624 ! Following variable (sigtc) is d[sigma(t_c)]/dt_c
5625 sigtc=-sigtc/(fac*fac)
5626 ! Following variable is sigma(t_c)**(-2)
5627 sigcsq=sigcsq*sigcsq
5629 sig0inv=1.0D0/sig0i**2
5630 delthec=thetai-thet_pred_mean
5631 delthe0=thetai-theta0i
5632 term1=-0.5D0*sigcsq*delthec*delthec
5633 term2=-0.5D0*sig0inv*delthe0*delthe0
5634 ! Following fuzzy logic is to avoid underflows in dexp and subsequent INFs and
5635 ! NaNs in taking the logarithm. We extract the largest exponent which is added
5636 ! to the energy (this being the log of the distribution) at the end of energy
5637 ! term evaluation for this virtual-bond angle.
5638 if (term1.gt.term2) then
5640 term2=dexp(term2-termm)
5644 term1=dexp(term1-termm)
5647 ! The ratio between the gamma-independent and gamma-dependent lobes of
5648 ! the distribution is a Gaussian function of thet_pred_mean too.
5649 diffak=gthet(2,it)-thet_pred_mean
5650 ratak=diffak/gthet(3,it)**2
5651 ak=dexp(gthet(1,it)-0.5D0*diffak*ratak)
5652 ! Let's differentiate it in thet_pred_mean NOW.
5654 ! Now put together the distribution terms to make complete distribution.
5655 termexp=term1+ak*term2
5656 termpre=sigc+ak*sig0i
5657 ! Contribution of the bending energy from this theta is just the -log of
5658 ! the sum of the contributions from the two lobes and the pre-exponential
5659 ! factor. Simple enough, isn't it?
5660 ethetai=(-dlog(termexp)-termm+dlog(termpre))
5661 ! NOW the derivatives!!!
5662 ! 6/6/97 Take into account the deformation.
5663 E_theta=(delthec*sigcsq*term1 &
5664 +ak*delthe0*sig0inv*term2)/termexp
5665 E_tc=((sigtc+aktc*sig0i)/termpre &
5666 -((delthec*sigcsq+delthec*delthec*sigsqtc)*term1+ &
5667 aktc*term2)/termexp)
5669 end subroutine theteng
5671 !-----------------------------------------------------------------------------
5672 subroutine ebend(etheta,ethetacnstr)
5674 ! Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
5675 ! angles gamma and its derivatives in consecutive thetas and gammas.
5676 ! ab initio-derived potentials from
5677 ! Kozlowska et al., J. Phys.: Condens. Matter 19 (2007) 285203
5679 ! implicit real*8 (a-h,o-z)
5680 ! include 'DIMENSIONS'
5681 ! include 'COMMON.LOCAL'
5682 ! include 'COMMON.GEO'
5683 ! include 'COMMON.INTERACT'
5684 ! include 'COMMON.DERIV'
5685 ! include 'COMMON.VAR'
5686 ! include 'COMMON.CHAIN'
5687 ! include 'COMMON.IOUNITS'
5688 ! include 'COMMON.NAMES'
5689 ! include 'COMMON.FFIELD'
5690 ! include 'COMMON.CONTROL'
5691 real(kind=8),dimension(nntheterm) :: coskt,sinkt !mmaxtheterm
5692 real(kind=8),dimension(nsingle) :: cosph1,sinph1,cosph2,sinph2 !maxsingle
5693 real(kind=8),dimension(ndouble,ndouble) :: cosph1ph2,sinph1ph2 !maxdouble,maxdouble
5694 logical :: lprn=.false., lprn1=.false.
5696 integer :: i,k,iblock,ityp1,ityp2,ityp3,l,m
5697 real(kind=8) :: dethetai,dephii,dephii1,theti2,phii,phii1,ethetai
5698 real(kind=8) :: aux,etheta,ccl,ssl,scl,csl,ethetacnstr
5699 ! local variables for constrains
5700 real(kind=8) :: difi,thetiii
5704 do i=ithet_start,ithet_end
5705 if (itype(i-1,1).eq.ntyp1) cycle
5706 if (itype(i-2,1).eq.ntyp1.or.itype(i,1).eq.ntyp1) cycle
5707 if (iabs(itype(i+1,1)).eq.20) iblock=2
5708 if (iabs(itype(i+1,1)).ne.20) iblock=1
5712 theti2=0.5d0*theta(i)
5713 ityp2=ithetyp((itype(i-1,1)))
5715 coskt(k)=dcos(k*theti2)
5716 sinkt(k)=dsin(k*theti2)
5718 if (i.gt.3 .and. itype(max0(i-3,1),1).ne.ntyp1) then
5721 if (phii.ne.phii) phii=150.0
5725 ityp1=ithetyp((itype(i-2,1)))
5726 ! propagation of chirality for glycine type
5728 cosph1(k)=dcos(k*phii)
5729 sinph1(k)=dsin(k*phii)
5733 ityp1=ithetyp(itype(i-2,1))
5739 if (i.lt.nres .and. itype(i+1,1).ne.ntyp1) then
5742 if (phii1.ne.phii1) phii1=150.0
5747 ityp3=ithetyp((itype(i,1)))
5749 cosph2(k)=dcos(k*phii1)
5750 sinph2(k)=dsin(k*phii1)
5754 ityp3=ithetyp(itype(i,1))
5760 ethetai=aa0thet(ityp1,ityp2,ityp3,iblock)
5763 ccl=cosph1(l)*cosph2(k-l)
5764 ssl=sinph1(l)*sinph2(k-l)
5765 scl=sinph1(l)*cosph2(k-l)
5766 csl=cosph1(l)*sinph2(k-l)
5767 cosph1ph2(l,k)=ccl-ssl
5768 cosph1ph2(k,l)=ccl+ssl
5769 sinph1ph2(l,k)=scl+csl
5770 sinph1ph2(k,l)=scl-csl
5774 write (iout,*) "i",i," ityp1",ityp1," ityp2",ityp2,&
5775 " ityp3",ityp3," theti2",theti2," phii",phii," phii1",phii1
5776 write (iout,*) "coskt and sinkt"
5778 write (iout,*) k,coskt(k),sinkt(k)
5782 ethetai=ethetai+aathet(k,ityp1,ityp2,ityp3,iblock)*sinkt(k)
5783 dethetai=dethetai+0.5d0*k*aathet(k,ityp1,ityp2,ityp3,iblock) &
5786 write (iout,*) "k",k,&
5787 "aathet",aathet(k,ityp1,ityp2,ityp3,iblock),&
5791 write (iout,*) "cosph and sinph"
5793 write (iout,*) k,cosph1(k),sinph1(k),cosph2(k),sinph2(k)
5795 write (iout,*) "cosph1ph2 and sinph2ph2"
5798 write (iout,*) l,k,cosph1ph2(l,k),cosph1ph2(k,l),&
5799 sinph1ph2(l,k),sinph1ph2(k,l)
5802 write(iout,*) "ethetai",ethetai
5806 aux=bbthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph1(k) &
5807 +ccthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph1(k) &
5808 +ddthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph2(k) &
5809 +eethet(k,m,ityp1,ityp2,ityp3,iblock)*sinph2(k)
5810 ethetai=ethetai+sinkt(m)*aux
5811 dethetai=dethetai+0.5d0*m*aux*coskt(m)
5812 dephii=dephii+k*sinkt(m)* &
5813 (ccthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph1(k)- &
5814 bbthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph1(k))
5815 dephii1=dephii1+k*sinkt(m)* &
5816 (eethet(k,m,ityp1,ityp2,ityp3,iblock)*cosph2(k)- &
5817 ddthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph2(k))
5819 write (iout,*) "m",m," k",k," bbthet", &
5820 bbthet(k,m,ityp1,ityp2,ityp3,iblock)," ccthet", &
5821 ccthet(k,m,ityp1,ityp2,ityp3,iblock)," ddthet", &
5822 ddthet(k,m,ityp1,ityp2,ityp3,iblock)," eethet", &
5823 eethet(k,m,ityp1,ityp2,ityp3,iblock)," ethetai",ethetai
5827 write(iout,*) "ethetai",ethetai
5831 aux=ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)+ &
5832 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l)+ &
5833 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)+ &
5834 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)
5835 ethetai=ethetai+sinkt(m)*aux
5836 dethetai=dethetai+0.5d0*m*coskt(m)*aux
5837 dephii=dephii+l*sinkt(m)* &
5838 (-ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)- &
5839 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)+ &
5840 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)+ &
5841 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l))
5842 dephii1=dephii1+(k-l)*sinkt(m)* &
5843 (-ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)+ &
5844 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)+ &
5845 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)- &
5846 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l))
5848 write (iout,*) "m",m," k",k," l",l," ffthet",&
5849 ffthet(l,k,m,ityp1,ityp2,ityp3,iblock),&
5850 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)," ggthet",&
5851 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock),&
5852 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock),&
5854 write (iout,*) cosph1ph2(l,k)*sinkt(m),&
5855 cosph1ph2(k,l)*sinkt(m),&
5856 sinph1ph2(l,k)*sinkt(m),sinph1ph2(k,l)*sinkt(m)
5864 write (iout,'(i2,3f8.1,9h ethetai ,f10.5)') &
5865 i,theta(i)*rad2deg,phii*rad2deg,&
5866 phii1*rad2deg,ethetai
5868 etheta=etheta+ethetai
5869 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
5871 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*dephii
5872 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*dephii1
5873 gloc(nphi+i-2,icg)=wang*dethetai
5875 !-----------thete constrains
5876 ! if (tor_mode.ne.2) then
5878 ! print *,ithetaconstr_start,ithetaconstr_end,"TU"
5879 do i=ithetaconstr_start,ithetaconstr_end
5880 itheta=itheta_constr(i)
5881 thetiii=theta(itheta)
5882 difi=pinorm(thetiii-theta_constr0(i))
5883 if (difi.gt.theta_drange(i)) then
5884 difi=difi-theta_drange(i)
5885 ethetacnstr=ethetacnstr+0.25d0*for_thet_constr(i)*difi**4
5886 gloc(itheta+nphi-2,icg)=gloc(itheta+nphi-2,icg) &
5887 +for_thet_constr(i)*difi**3
5888 else if (difi.lt.-drange(i)) then
5890 ethetacnstr=ethetacnstr+0.25d0*for_thet_constr(i)*difi**4
5891 gloc(itheta+nphi-2,icg)=gloc(itheta+nphi-2,icg) &
5892 +for_thet_constr(i)*difi**3
5896 if (energy_dec) then
5897 write (iout,'(a6,2i5,4f8.3,2e14.5)') "ethetc", &
5898 i,itheta,rad2deg*thetiii, &
5899 rad2deg*theta_constr0(i), rad2deg*theta_drange(i), &
5900 rad2deg*difi,0.25d0*for_thet_constr(i)*difi**4, &
5901 gloc(itheta+nphi-2,icg)
5907 end subroutine ebend
5910 !-----------------------------------------------------------------------------
5911 subroutine esc(escloc)
5912 ! Calculate the local energy of a side chain and its derivatives in the
5913 ! corresponding virtual-bond valence angles THETA and the spherical angles
5917 ! implicit real*8 (a-h,o-z)
5918 ! include 'DIMENSIONS'
5919 ! include 'COMMON.GEO'
5920 ! include 'COMMON.LOCAL'
5921 ! include 'COMMON.VAR'
5922 ! include 'COMMON.INTERACT'
5923 ! include 'COMMON.DERIV'
5924 ! include 'COMMON.CHAIN'
5925 ! include 'COMMON.IOUNITS'
5926 ! include 'COMMON.NAMES'
5927 ! include 'COMMON.FFIELD'
5928 ! include 'COMMON.CONTROL'
5929 real(kind=8),dimension(3) :: x,dersc,xemp,dersc0,dersc1,&
5930 ddersc0,ddummy,xtemp,temp
5931 !el real(kind=8) :: time11,time12,time112,theti
5932 real(kind=8) :: escloc,delta
5933 !el integer :: it,nlobit
5934 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
5937 real(kind=8) :: escloci0,escloci1,escloci,esclocbi0,&
5938 dersc12,esclocbi1,chuju,esclocbi,dersc02,dersc01,ss,ssd
5941 ! write (iout,'(a)') 'ESC'
5942 do i=loc_start,loc_end
5944 if (it.eq.ntyp1) cycle
5945 if (it.eq.10) goto 1
5946 nlobit=nlob(iabs(it))
5947 ! print *,'i=',i,' it=',it,' nlobit=',nlobit
5948 ! write (iout,*) 'i=',i,' ssa=',ssa,' ssad=',ssad
5949 theti=theta(i+1)-pipol
5954 if (x(2).gt.pi-delta) then
5958 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
5960 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
5961 call spline1(x(2),pi-delta,delta,escloci0,escloci1,dersc0(2),&
5963 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),&
5964 ddersc0(1),dersc(1))
5965 call spline2(x(2),pi-delta,delta,dersc0(3),dersc1(3),&
5966 ddersc0(3),dersc(3))
5968 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
5970 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
5971 call spline1(x(2),pi-delta,delta,esclocbi0,esclocbi1,&
5972 dersc0(2),esclocbi,dersc02)
5973 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),&
5975 call splinthet(x(2),0.5d0*delta,ss,ssd)
5980 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
5982 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
5983 ! write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
5985 escloci=ss*escloci+(1.0d0-ss)*esclocbi
5987 ! write (iout,*) escloci
5988 else if (x(2).lt.delta) then
5992 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
5994 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
5995 call spline1(x(2),delta,-delta,escloci0,escloci1,dersc0(2),&
5997 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),&
5998 ddersc0(1),dersc(1))
5999 call spline2(x(2),delta,-delta,dersc0(3),dersc1(3),&
6000 ddersc0(3),dersc(3))
6002 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
6004 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
6005 call spline1(x(2),delta,-delta,esclocbi0,esclocbi1,&
6006 dersc0(2),esclocbi,dersc02)
6007 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),&
6012 call splinthet(x(2),0.5d0*delta,ss,ssd)
6014 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
6016 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
6017 ! write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
6019 escloci=ss*escloci+(1.0d0-ss)*esclocbi
6020 ! write (iout,*) escloci
6022 call enesc(x,escloci,dersc,ddummy,.false.)
6025 escloc=escloc+escloci
6026 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
6028 ! write (iout,*) 'i=',i,' escloci=',escloci,' dersc=',dersc
6030 gloc(nphi+i-1,icg)=gloc(nphi+i-1,icg)+ &
6032 gloc(ialph(i,1),icg)=wscloc*dersc(2)
6033 gloc(ialph(i,1)+nside,icg)=wscloc*dersc(3)
6038 !-----------------------------------------------------------------------------
6039 subroutine enesc(x,escloci,dersc,ddersc,mixed)
6042 ! implicit real*8 (a-h,o-z)
6043 ! include 'DIMENSIONS'
6044 ! include 'COMMON.GEO'
6045 ! include 'COMMON.LOCAL'
6046 ! include 'COMMON.IOUNITS'
6047 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
6048 real(kind=8),dimension(3) :: x,z,dersc,ddersc
6049 real(kind=8),dimension(3,nlobit,-1:1) :: Ax !(3,maxlob,-1:1)
6050 real(kind=8),dimension(nlobit,-1:1) :: contr !(maxlob,-1:1)
6051 real(kind=8) :: escloci
6054 integer :: j,iii,l,k !el,it,nlobit
6055 real(kind=8) :: escloc_i,x3,Axk,expfac,emin !el,theti,&
6056 !el time11,time12,time112
6057 ! write (iout,*) 'it=',it,' nlobit=',nlobit
6061 if (mixed) ddersc(j)=0.0d0
6065 ! Because of periodicity of the dependence of the SC energy in omega we have
6066 ! to add up the contributions from x(3)-2*pi, x(3), and x(3+2*pi).
6067 ! To avoid underflows, first compute & store the exponents.
6075 z(k)=x(k)-censc(k,j,it)
6080 Axk=Axk+gaussc(l,k,j,it)*z(l)
6086 expfac=expfac+Ax(k,j,iii)*z(k)
6094 ! As in the case of ebend, we want to avoid underflows in exponentiation and
6095 ! subsequent NaNs and INFs in energy calculation.
6096 ! Find the largest exponent
6100 if (emin.gt.contr(j,iii)) emin=contr(j,iii)
6104 !d print *,'it=',it,' emin=',emin
6106 ! Compute the contribution to SC energy and derivatives
6111 adexp=bsc(j,iabs(it))-0.5D0*contr(j,iii)+emin
6112 if(adexp.ne.adexp) adexp=1.0
6115 expfac=dexp(bsc(j,iabs(it))-0.5D0*contr(j,iii)+emin)
6117 !d print *,'j=',j,' expfac=',expfac
6118 escloc_i=escloc_i+expfac
6120 dersc(k)=dersc(k)+Ax(k,j,iii)*expfac
6124 ddersc(k)=ddersc(k)+(-Ax(2,j,iii)*Ax(k,j,iii) &
6125 +gaussc(k,2,j,it))*expfac
6132 dersc(1)=dersc(1)/cos(theti)**2
6133 ddersc(1)=ddersc(1)/cos(theti)**2
6136 escloci=-(dlog(escloc_i)-emin)
6138 dersc(j)=dersc(j)/escloc_i
6142 ddersc(j)=(ddersc(j)/escloc_i+dersc(2)*dersc(j))
6146 end subroutine enesc
6147 !-----------------------------------------------------------------------------
6148 subroutine enesc_bound(x,escloci,dersc,dersc12,mixed)
6151 ! implicit real*8 (a-h,o-z)
6152 ! include 'DIMENSIONS'
6153 ! include 'COMMON.GEO'
6154 ! include 'COMMON.LOCAL'
6155 ! include 'COMMON.IOUNITS'
6156 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
6157 real(kind=8),dimension(3) :: x,z,dersc
6158 real(kind=8),dimension(3,nlobit) :: Ax !(3,maxlob)
6159 real(kind=8),dimension(nlobit) :: contr !(maxlob)
6160 real(kind=8) :: escloci,dersc12,emin
6163 integer :: j,k,l !el,it,nlobit
6164 real(kind=8) :: escloc_i,Axk,expfac !el,time11,time12,time112,theti
6174 z(k)=x(k)-censc(k,j,it)
6180 Axk=Axk+gaussc(l,k,j,it)*z(l)
6186 expfac=expfac+Ax(k,j)*z(k)
6191 ! As in the case of ebend, we want to avoid underflows in exponentiation and
6192 ! subsequent NaNs and INFs in energy calculation.
6193 ! Find the largest exponent
6196 if (emin.gt.contr(j)) emin=contr(j)
6200 ! Compute the contribution to SC energy and derivatives
6204 expfac=dexp(bsc(j,iabs(it))-0.5D0*contr(j)+emin)
6205 escloc_i=escloc_i+expfac
6207 dersc(k)=dersc(k)+Ax(k,j)*expfac
6209 if (mixed) dersc12=dersc12+(-Ax(2,j)*Ax(1,j) &
6210 +gaussc(1,2,j,it))*expfac
6214 dersc(1)=dersc(1)/cos(theti)**2
6215 dersc12=dersc12/cos(theti)**2
6216 escloci=-(dlog(escloc_i)-emin)
6218 dersc(j)=dersc(j)/escloc_i
6220 if (mixed) dersc12=(dersc12/escloc_i+dersc(2)*dersc(1))
6222 end subroutine enesc_bound
6224 !-----------------------------------------------------------------------------
6225 subroutine esc(escloc)
6226 ! Calculate the local energy of a side chain and its derivatives in the
6227 ! corresponding virtual-bond valence angles THETA and the spherical angles
6228 ! ALPHA and OMEGA derived from AM1 all-atom calculations.
6229 ! added by Urszula Kozlowska. 07/11/2007
6232 ! implicit real*8 (a-h,o-z)
6233 ! include 'DIMENSIONS'
6234 ! include 'COMMON.GEO'
6235 ! include 'COMMON.LOCAL'
6236 ! include 'COMMON.VAR'
6237 ! include 'COMMON.SCROT'
6238 ! include 'COMMON.INTERACT'
6239 ! include 'COMMON.DERIV'
6240 ! include 'COMMON.CHAIN'
6241 ! include 'COMMON.IOUNITS'
6242 ! include 'COMMON.NAMES'
6243 ! include 'COMMON.FFIELD'
6244 ! include 'COMMON.CONTROL'
6245 ! include 'COMMON.VECTORS'
6246 real(kind=8),dimension(3) :: x_prime,y_prime,z_prime
6247 real(kind=8),dimension(65) :: x
6248 real(kind=8) :: sumene,dsc_i,dp2_i,xx,yy,zz,sumene1,sumene2,sumene3,&
6249 sumene4,s1,s1_6,s2,s2_6,de_dxx,de_dyy,de_dzz,de_dt
6250 real(kind=8) :: s1_t,s1_6_t,s2_t,s2_6_t
6251 real(kind=8),dimension(3) :: dXX_Ci1,dYY_Ci1,dZZ_Ci1,dXX_Ci,dYY_Ci,&
6252 dZZ_Ci,dXX_XYZ,dYY_XYZ,dZZ_XYZ,dt_dCi,dt_dCi1
6254 integer :: i,j,k !el,it,nlobit
6255 real(kind=8) :: cosfac2,sinfac2,cosfac,sinfac,escloc,delta
6256 !el real(kind=8) :: time11,time12,time112,theti
6257 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
6258 real(kind=8) :: dscp1,dscp2,pom_s1,pom_s16,pom_s2,pom_s26,&
6259 pom,pom_dx,pom_dy,pom_dt1,pom_dt2,pom1,pom2,&
6260 sumene1x,sumene2x,sumene3x,sumene4x,&
6261 sumene1y,sumene2y,sumene3y,sumene4y,cossc,cossc1,&
6264 real(kind=8) :: aincr,xxsave,sumenep,de_dxx_num,yysave,&
6265 de_dyy_num,zzsave,de_dzz_num,costsave,sintsave,&
6268 ! if (.not.allocated(gsclocx)) allocate(gsclocx(3,nres)) !(3,maxres)
6272 do i=loc_start,loc_end
6273 if (itype(i,1).eq.ntyp1) cycle
6274 costtab(i+1) =dcos(theta(i+1))
6275 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
6276 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
6277 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
6278 cosfac2=0.5d0/(1.0d0+costtab(i+1))
6279 cosfac=dsqrt(cosfac2)
6280 sinfac2=0.5d0/(1.0d0-costtab(i+1))
6281 sinfac=dsqrt(sinfac2)
6283 if (it.eq.10) goto 1
6285 ! Compute the axes of tghe local cartesian coordinates system; store in
6286 ! x_prime, y_prime and z_prime
6293 ! write(2,*) "dc_norm", dc_norm(1,i+nres),dc_norm(2,i+nres),
6294 ! & dc_norm(3,i+nres)
6296 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
6297 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
6300 z_prime(j) = -uz(j,i-1)*dsign(1.0d0,dfloat(itype(i,1)))
6303 ! write (2,*) "x_prime",(x_prime(j),j=1,3)
6304 ! write (2,*) "y_prime",(y_prime(j),j=1,3)
6305 ! write (2,*) "z_prime",(z_prime(j),j=1,3)
6306 ! write (2,*) "xx",scalar(x_prime(1),x_prime(1)),
6307 ! & " xy",scalar(x_prime(1),y_prime(1)),
6308 ! & " xz",scalar(x_prime(1),z_prime(1)),
6309 ! & " yy",scalar(y_prime(1),y_prime(1)),
6310 ! & " yz",scalar(y_prime(1),z_prime(1)),
6311 ! & " zz",scalar(z_prime(1),z_prime(1))
6313 ! Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
6314 ! to local coordinate system. Store in xx, yy, zz.
6320 xx = xx + x_prime(j)*dc_norm(j,i+nres)
6321 yy = yy + y_prime(j)*dc_norm(j,i+nres)
6322 zz = zz + z_prime(j)*dc_norm(j,i+nres)
6329 ! Compute the energy of the ith side cbain
6331 ! write (2,*) "xx",xx," yy",yy," zz",zz
6334 x(j) = sc_parmin(j,it)
6337 !c diagnostics - remove later
6339 yy1 = dsin(alph(2))*dcos(omeg(2))
6340 zz1 = -dsign(1.0,dfloat(itype(i,1)))*dsin(alph(2))*dsin(omeg(2))
6341 write(2,'(3f8.1,3f9.3,1x,3f9.3)') &
6342 alph(2)*rad2deg,omeg(2)*rad2deg,theta(3)*rad2deg,xx,yy,zz,&
6344 !," --- ", xx_w,yy_w,zz_w
6347 sumene1= x(1)+ x(2)*xx+ x(3)*yy+ x(4)*zz+ x(5)*xx**2 &
6348 + x(6)*yy**2+ x(7)*zz**2+ x(8)*xx*zz+ x(9)*xx*yy &
6350 sumene2= x(11) + x(12)*xx + x(13)*yy + x(14)*zz + x(15)*xx**2 &
6351 + x(16)*yy**2 + x(17)*zz**2 + x(18)*xx*zz + x(19)*xx*yy &
6353 sumene3= x(21) +x(22)*xx +x(23)*yy +x(24)*zz +x(25)*xx**2 &
6354 +x(26)*yy**2 +x(27)*zz**2 +x(28)*xx*zz +x(29)*xx*yy &
6355 +x(30)*yy*zz +x(31)*xx**3 +x(32)*yy**3 +x(33)*zz**3 &
6356 +x(34)*(xx**2)*yy +x(35)*(xx**2)*zz +x(36)*(yy**2)*xx &
6357 +x(37)*(yy**2)*zz +x(38)*(zz**2)*xx +x(39)*(zz**2)*yy &
6359 sumene4= x(41) +x(42)*xx +x(43)*yy +x(44)*zz +x(45)*xx**2 &
6360 +x(46)*yy**2 +x(47)*zz**2 +x(48)*xx*zz +x(49)*xx*yy &
6361 +x(50)*yy*zz +x(51)*xx**3 +x(52)*yy**3 +x(53)*zz**3 &
6362 +x(54)*(xx**2)*yy +x(55)*(xx**2)*zz +x(56)*(yy**2)*xx &
6363 +x(57)*(yy**2)*zz +x(58)*(zz**2)*xx +x(59)*(zz**2)*yy &
6365 dsc_i = 0.743d0+x(61)
6367 dscp1=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
6368 *(xx*cost2tab(i+1)+yy*sint2tab(i+1)))
6369 dscp2=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
6370 *(xx*cost2tab(i+1)-yy*sint2tab(i+1)))
6371 s1=(1+x(63))/(0.1d0 + dscp1)
6372 s1_6=(1+x(64))/(0.1d0 + dscp1**6)
6373 s2=(1+x(65))/(0.1d0 + dscp2)
6374 s2_6=(1+x(65))/(0.1d0 + dscp2**6)
6375 sumene = ( sumene3*sint2tab(i+1) + sumene1)*(s1+s1_6) &
6376 + (sumene4*cost2tab(i+1) +sumene2)*(s2+s2_6)
6377 ! write(2,'(i2," sumene",7f9.3)') i,sumene1,sumene2,sumene3,
6379 ! & dscp1,dscp2,sumene
6380 ! sumene = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6381 escloc = escloc + sumene
6382 ! write (2,*) "i",i," escloc",sumene,escloc,it,itype(i,1)
6387 ! This section to check the numerical derivatives of the energy of ith side
6388 ! chain in xx, yy, zz, and theta. Use the -DDEBUG compiler option or insert
6389 ! #define DEBUG in the code to turn it on.
6391 write (2,*) "sumene =",sumene
6395 write (2,*) xx,yy,zz
6396 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6397 de_dxx_num=(sumenep-sumene)/aincr
6399 write (2,*) "xx+ sumene from enesc=",sumenep
6402 write (2,*) xx,yy,zz
6403 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6404 de_dyy_num=(sumenep-sumene)/aincr
6406 write (2,*) "yy+ sumene from enesc=",sumenep
6409 write (2,*) xx,yy,zz
6410 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6411 de_dzz_num=(sumenep-sumene)/aincr
6413 write (2,*) "zz+ sumene from enesc=",sumenep
6414 costsave=cost2tab(i+1)
6415 sintsave=sint2tab(i+1)
6416 cost2tab(i+1)=dcos(0.5d0*(theta(i+1)+aincr))
6417 sint2tab(i+1)=dsin(0.5d0*(theta(i+1)+aincr))
6418 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6419 de_dt_num=(sumenep-sumene)/aincr
6420 write (2,*) " t+ sumene from enesc=",sumenep
6421 cost2tab(i+1)=costsave
6422 sint2tab(i+1)=sintsave
6423 ! End of diagnostics section.
6426 ! Compute the gradient of esc
6428 ! zz=zz*dsign(1.0,dfloat(itype(i,1)))
6429 pom_s1=(1.0d0+x(63))/(0.1d0 + dscp1)**2
6430 pom_s16=6*(1.0d0+x(64))/(0.1d0 + dscp1**6)**2
6431 pom_s2=(1.0d0+x(65))/(0.1d0 + dscp2)**2
6432 pom_s26=6*(1.0d0+x(65))/(0.1d0 + dscp2**6)**2
6433 pom_dx=dsc_i*dp2_i*cost2tab(i+1)
6434 pom_dy=dsc_i*dp2_i*sint2tab(i+1)
6435 pom_dt1=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)-yy*cost2tab(i+1))
6436 pom_dt2=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)+yy*cost2tab(i+1))
6437 pom1=(sumene3*sint2tab(i+1)+sumene1) &
6438 *(pom_s1/dscp1+pom_s16*dscp1**4)
6439 pom2=(sumene4*cost2tab(i+1)+sumene2) &
6440 *(pom_s2/dscp2+pom_s26*dscp2**4)
6441 sumene1x=x(2)+2*x(5)*xx+x(8)*zz+ x(9)*yy
6442 sumene3x=x(22)+2*x(25)*xx+x(28)*zz+x(29)*yy+3*x(31)*xx**2 &
6443 +2*x(34)*xx*yy +2*x(35)*xx*zz +x(36)*(yy**2) +x(38)*(zz**2) &
6445 sumene2x=x(12)+2*x(15)*xx+x(18)*zz+ x(19)*yy
6446 sumene4x=x(42)+2*x(45)*xx +x(48)*zz +x(49)*yy +3*x(51)*xx**2 &
6447 +2*x(54)*xx*yy+2*x(55)*xx*zz+x(56)*(yy**2)+x(58)*(zz**2) &
6449 de_dxx =(sumene1x+sumene3x*sint2tab(i+1))*(s1+s1_6) &
6450 +(sumene2x+sumene4x*cost2tab(i+1))*(s2+s2_6) &
6453 write(2,*), "de_dxx = ", de_dxx,de_dxx_num,itype(i,1)
6456 sumene1y=x(3) + 2*x(6)*yy + x(9)*xx + x(10)*zz
6457 sumene3y=x(23) +2*x(26)*yy +x(29)*xx +x(30)*zz +3*x(32)*yy**2 &
6458 +x(34)*(xx**2) +2*x(36)*yy*xx +2*x(37)*yy*zz +x(39)*(zz**2) &
6460 sumene2y=x(13) + 2*x(16)*yy + x(19)*xx + x(20)*zz
6461 sumene4y=x(43)+2*x(46)*yy+x(49)*xx +x(50)*zz &
6462 +3*x(52)*yy**2+x(54)*xx**2+2*x(56)*yy*xx +2*x(57)*yy*zz &
6463 +x(59)*zz**2 +x(60)*xx*zz
6464 de_dyy =(sumene1y+sumene3y*sint2tab(i+1))*(s1+s1_6) &
6465 +(sumene2y+sumene4y*cost2tab(i+1))*(s2+s2_6) &
6468 write(2,*), "de_dyy = ", de_dyy,de_dyy_num,itype(i,1)
6471 de_dzz =(x(24) +2*x(27)*zz +x(28)*xx +x(30)*yy &
6472 +3*x(33)*zz**2 +x(35)*xx**2 +x(37)*yy**2 +2*x(38)*zz*xx &
6473 +2*x(39)*zz*yy +x(40)*xx*yy)*sint2tab(i+1)*(s1+s1_6) &
6474 +(x(4) + 2*x(7)*zz+ x(8)*xx + x(10)*yy)*(s1+s1_6) &
6475 +(x(44)+2*x(47)*zz +x(48)*xx +x(50)*yy +3*x(53)*zz**2 &
6476 +x(55)*xx**2 +x(57)*(yy**2)+2*x(58)*zz*xx +2*x(59)*zz*yy &
6477 +x(60)*xx*yy)*cost2tab(i+1)*(s2+s2_6) &
6478 + ( x(14) + 2*x(17)*zz+ x(18)*xx + x(20)*yy)*(s2+s2_6)
6480 write(2,*), "de_dzz = ", de_dzz,de_dzz_num,itype(i,1)
6483 de_dt = 0.5d0*sumene3*cost2tab(i+1)*(s1+s1_6) &
6484 -0.5d0*sumene4*sint2tab(i+1)*(s2+s2_6) &
6485 +pom1*pom_dt1+pom2*pom_dt2
6487 write(2,*), "de_dt = ", de_dt,de_dt_num,itype(i,1)
6491 cossc=scalar(dc_norm(1,i),dc_norm(1,i+nres))
6492 cossc1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
6493 cosfac2xx=cosfac2*xx
6494 sinfac2yy=sinfac2*yy
6496 dt_dCi(k) = -(dc_norm(k,i-1)+costtab(i+1)*dc_norm(k,i))* &
6498 dt_dCi1(k)= -(dc_norm(k,i)+costtab(i+1)*dc_norm(k,i-1))* &
6500 pom=(dC_norm(k,i+nres)-cossc*dC_norm(k,i))*vbld_inv(i+1)
6501 pom1=(dC_norm(k,i+nres)-cossc1*dC_norm(k,i-1))*vbld_inv(i)
6502 ! write (iout,*) "i",i," k",k," pom",pom," pom1",pom1,
6503 ! & " dt_dCi",dt_dCi(k)," dt_dCi1",dt_dCi1(k)
6504 ! write (iout,*) "dC_norm",(dC_norm(j,i),j=1,3),
6505 ! & (dC_norm(j,i-1),j=1,3)," vbld_inv",vbld_inv(i+1),vbld_inv(i)
6506 dXX_Ci(k)=pom*cosfac-dt_dCi(k)*cosfac2xx
6507 dXX_Ci1(k)=-pom1*cosfac-dt_dCi1(k)*cosfac2xx
6508 dYY_Ci(k)=pom*sinfac+dt_dCi(k)*sinfac2yy
6509 dYY_Ci1(k)=pom1*sinfac+dt_dCi1(k)*sinfac2yy
6513 dZZ_Ci(k)=dZZ_Ci(k)-uzgrad(j,k,2,i-1) &
6514 *dsign(1.0d0,dfloat(itype(i,1)))*dC_norm(j,i+nres)
6515 dZZ_Ci1(k)=dZZ_Ci1(k)-uzgrad(j,k,1,i-1) &
6516 *dsign(1.0d0,dfloat(itype(i,1)))*dC_norm(j,i+nres)
6519 dXX_XYZ(k)=vbld_inv(i+nres)*(x_prime(k)-xx*dC_norm(k,i+nres))
6520 dYY_XYZ(k)=vbld_inv(i+nres)*(y_prime(k)-yy*dC_norm(k,i+nres))
6521 dZZ_XYZ(k)=vbld_inv(i+nres)* &
6522 (z_prime(k)-zz*dC_norm(k,i+nres))
6524 dt_dCi(k) = -dt_dCi(k)/sinttab(i+1)
6525 dt_dCi1(k)= -dt_dCi1(k)/sinttab(i+1)
6529 dXX_Ctab(k,i)=dXX_Ci(k)
6530 dXX_C1tab(k,i)=dXX_Ci1(k)
6531 dYY_Ctab(k,i)=dYY_Ci(k)
6532 dYY_C1tab(k,i)=dYY_Ci1(k)
6533 dZZ_Ctab(k,i)=dZZ_Ci(k)
6534 dZZ_C1tab(k,i)=dZZ_Ci1(k)
6535 dXX_XYZtab(k,i)=dXX_XYZ(k)
6536 dYY_XYZtab(k,i)=dYY_XYZ(k)
6537 dZZ_XYZtab(k,i)=dZZ_XYZ(k)
6541 ! write (iout,*) "k",k," dxx_ci1",dxx_ci1(k)," dyy_ci1",
6542 ! & dyy_ci1(k)," dzz_ci1",dzz_ci1(k)
6543 ! write (iout,*) "k",k," dxx_ci",dxx_ci(k)," dyy_ci",
6544 ! & dyy_ci(k)," dzz_ci",dzz_ci(k)
6545 ! write (iout,*) "k",k," dt_dci",dt_dci(k)," dt_dci",
6547 ! write (iout,*) "k",k," dxx_XYZ",dxx_XYZ(k)," dyy_XYZ",
6548 ! & dyy_XYZ(k)," dzz_XYZ",dzz_XYZ(k)
6549 gscloc(k,i-1)=gscloc(k,i-1)+de_dxx*dxx_ci1(k) &
6550 +de_dyy*dyy_ci1(k)+de_dzz*dzz_ci1(k)+de_dt*dt_dCi1(k)
6551 gscloc(k,i)=gscloc(k,i)+de_dxx*dxx_Ci(k) &
6552 +de_dyy*dyy_Ci(k)+de_dzz*dzz_Ci(k)+de_dt*dt_dCi(k)
6553 gsclocx(k,i)= de_dxx*dxx_XYZ(k) &
6554 +de_dyy*dyy_XYZ(k)+de_dzz*dzz_XYZ(k)
6556 ! write(iout,*) "ENERGY GRAD = ", (gscloc(k,i-1),k=1,3),
6557 ! & (gscloc(k,i),k=1,3),(gsclocx(k,i),k=1,3)
6559 ! to check gradient call subroutine check_grad
6565 !-----------------------------------------------------------------------------
6566 real(kind=8) function enesc(x,xx,yy,zz,cost2,sint2)
6568 real(kind=8),dimension(65) :: x
6569 real(kind=8) :: xx,yy,zz,cost2,sint2,sumene1,sumene2,sumene3,&
6570 sumene4,sumene,dsc_i,dp2_i,dscp1,dscp2,s1,s1_6,s2,s2_6
6572 sumene1= x(1)+ x(2)*xx+ x(3)*yy+ x(4)*zz+ x(5)*xx**2 &
6573 + x(6)*yy**2+ x(7)*zz**2+ x(8)*xx*zz+ x(9)*xx*yy &
6575 sumene2= x(11) + x(12)*xx + x(13)*yy + x(14)*zz + x(15)*xx**2 &
6576 + x(16)*yy**2 + x(17)*zz**2 + x(18)*xx*zz + x(19)*xx*yy &
6578 sumene3= x(21) +x(22)*xx +x(23)*yy +x(24)*zz +x(25)*xx**2 &
6579 +x(26)*yy**2 +x(27)*zz**2 +x(28)*xx*zz +x(29)*xx*yy &
6580 +x(30)*yy*zz +x(31)*xx**3 +x(32)*yy**3 +x(33)*zz**3 &
6581 +x(34)*(xx**2)*yy +x(35)*(xx**2)*zz +x(36)*(yy**2)*xx &
6582 +x(37)*(yy**2)*zz +x(38)*(zz**2)*xx +x(39)*(zz**2)*yy &
6584 sumene4= x(41) +x(42)*xx +x(43)*yy +x(44)*zz +x(45)*xx**2 &
6585 +x(46)*yy**2 +x(47)*zz**2 +x(48)*xx*zz +x(49)*xx*yy &
6586 +x(50)*yy*zz +x(51)*xx**3 +x(52)*yy**3 +x(53)*zz**3 &
6587 +x(54)*(xx**2)*yy +x(55)*(xx**2)*zz +x(56)*(yy**2)*xx &
6588 +x(57)*(yy**2)*zz +x(58)*(zz**2)*xx +x(59)*(zz**2)*yy &
6590 dsc_i = 0.743d0+x(61)
6592 dscp1=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
6593 *(xx*cost2+yy*sint2))
6594 dscp2=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
6595 *(xx*cost2-yy*sint2))
6596 s1=(1+x(63))/(0.1d0 + dscp1)
6597 s1_6=(1+x(64))/(0.1d0 + dscp1**6)
6598 s2=(1+x(65))/(0.1d0 + dscp2)
6599 s2_6=(1+x(65))/(0.1d0 + dscp2**6)
6600 sumene = ( sumene3*sint2 + sumene1)*(s1+s1_6) &
6601 + (sumene4*cost2 +sumene2)*(s2+s2_6)
6606 !-----------------------------------------------------------------------------
6607 subroutine gcont(rij,r0ij,eps0ij,delta,fcont,fprimcont)
6609 ! This procedure calculates two-body contact function g(rij) and its derivative:
6612 ! g(rij) = esp0ij*(-0.9375*x+0.625*x**3-0.1875*x**5) ! -1 =< x =< 1
6615 ! where x=(rij-r0ij)/delta
6617 ! rij - interbody distance, r0ij - contact distance, eps0ij - contact energy
6620 real(kind=8) :: rij,r0ij,eps0ij,fcont,fprimcont
6621 real(kind=8) :: x,x2,x4,delta
6625 if (x.lt.-1.0D0) then
6628 else if (x.le.1.0D0) then
6631 fcont=eps0ij*(x*(-0.9375D0+0.6250D0*x2-0.1875D0*x4)+0.5D0)
6632 fprimcont=eps0ij * (-0.9375D0+1.8750D0*x2-0.9375D0*x4)/delta
6638 end subroutine gcont
6639 !-----------------------------------------------------------------------------
6640 subroutine splinthet(theti,delta,ss,ssder)
6641 ! implicit real*8 (a-h,o-z)
6642 ! include 'DIMENSIONS'
6643 ! include 'COMMON.VAR'
6644 ! include 'COMMON.GEO'
6645 real(kind=8) :: theti,delta,ss,ssder
6646 real(kind=8) :: thetup,thetlow
6649 if (theti.gt.pipol) then
6650 call gcont(theti,thetup,1.0d0,delta,ss,ssder)
6652 call gcont(-theti,-thetlow,1.0d0,delta,ss,ssder)
6656 end subroutine splinthet
6657 !-----------------------------------------------------------------------------
6658 subroutine spline1(x,x0,delta,f0,f1,fprim0,f,fprim)
6660 real(kind=8) :: x,x0,delta,f0,f1,fprim0,f,fprim
6661 real(kind=8) :: ksi,ksi2,ksi3,a1,a2,a3
6662 a1=fprim0*delta/(f1-f0)
6668 f=f0+(f1-f0)*ksi*(a1+ksi*(a2+a3*ksi))
6669 fprim=(f1-f0)/delta*(a1+ksi*(2*a2+3*ksi*a3))
6671 end subroutine spline1
6672 !-----------------------------------------------------------------------------
6673 subroutine spline2(x,x0,delta,f0x,f1x,fprim0x,fx)
6675 real(kind=8) :: x,x0,delta,f0x,f1x,fprim0x,fx
6676 real(kind=8) :: ksi,ksi2,ksi3,a1,a2,a3
6681 a2=3*(f1x-f0x)-2*fprim0x*delta
6682 a3=fprim0x*delta-2*(f1x-f0x)
6683 fx=f0x+a1*ksi+a2*ksi2+a3*ksi3
6685 end subroutine spline2
6686 !-----------------------------------------------------------------------------
6688 !-----------------------------------------------------------------------------
6689 subroutine etor(etors,edihcnstr)
6690 ! implicit real*8 (a-h,o-z)
6691 ! include 'DIMENSIONS'
6692 ! include 'COMMON.VAR'
6693 ! include 'COMMON.GEO'
6694 ! include 'COMMON.LOCAL'
6695 ! include 'COMMON.TORSION'
6696 ! include 'COMMON.INTERACT'
6697 ! include 'COMMON.DERIV'
6698 ! include 'COMMON.CHAIN'
6699 ! include 'COMMON.NAMES'
6700 ! include 'COMMON.IOUNITS'
6701 ! include 'COMMON.FFIELD'
6702 ! include 'COMMON.TORCNSTR'
6703 ! include 'COMMON.CONTROL'
6704 real(kind=8) :: etors,edihcnstr
6708 real(kind=8) :: phii,fac,etors_ii
6710 ! Set lprn=.true. for debugging
6714 do i=iphi_start,iphi_end
6716 if (itype(i-2,1).eq.ntyp1.or. itype(i-1,1).eq.ntyp1 &
6717 .or. itype(i,1).eq.ntyp1) cycle
6718 itori=itortyp(itype(i-2,1))
6719 itori1=itortyp(itype(i-1,1))
6722 ! Proline-Proline pair is a special case...
6723 if (itori.eq.3 .and. itori1.eq.3) then
6724 if (phii.gt.-dwapi3) then
6726 fac=1.0D0/(1.0D0-cosphi)
6727 etorsi=v1(1,3,3)*fac
6728 etorsi=etorsi+etorsi
6729 etors=etors+etorsi-v1(1,3,3)
6730 if (energy_dec) etors_ii=etors_ii+etorsi-v1(1,3,3)
6731 gloci=gloci-3*fac*etorsi*dsin(3*phii)
6734 v1ij=v1(j+1,itori,itori1)
6735 v2ij=v2(j+1,itori,itori1)
6738 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
6739 if (energy_dec) etors_ii=etors_ii+ &
6740 v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
6741 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
6745 v1ij=v1(j,itori,itori1)
6746 v2ij=v2(j,itori,itori1)
6749 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
6750 if (energy_dec) etors_ii=etors_ii+ &
6751 v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
6752 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
6755 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
6758 write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)') &
6759 restyp(itype(i-2,1),1),i-2,restyp(itype(i-1,1),1),i-1,itori,itori1,&
6760 (v1(j,itori,itori1),j=1,6),(v2(j,itori,itori1),j=1,6)
6761 gloc(i-3,icg)=gloc(i-3,icg)+wtor*gloci
6762 ! write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
6764 ! 6/20/98 - dihedral angle constraints
6767 itori=idih_constr(i)
6770 if (difi.gt.drange(i)) then
6772 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
6773 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
6774 else if (difi.lt.-drange(i)) then
6776 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
6777 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
6779 ! write (iout,'(2i5,2f8.3,2e14.5)') i,itori,rad2deg*phii,
6780 ! & rad2deg*difi,0.25d0*ftors*difi**4,gloc(itori-3,icg)
6782 ! write (iout,*) 'edihcnstr',edihcnstr
6785 !-----------------------------------------------------------------------------
6786 subroutine etor_d(etors_d)
6787 real(kind=8) :: etors_d
6790 end subroutine etor_d
6792 !-----------------------------------------------------------------------------
6793 subroutine etor(etors,edihcnstr)
6794 ! implicit real*8 (a-h,o-z)
6795 ! include 'DIMENSIONS'
6796 ! include 'COMMON.VAR'
6797 ! include 'COMMON.GEO'
6798 ! include 'COMMON.LOCAL'
6799 ! include 'COMMON.TORSION'
6800 ! include 'COMMON.INTERACT'
6801 ! include 'COMMON.DERIV'
6802 ! include 'COMMON.CHAIN'
6803 ! include 'COMMON.NAMES'
6804 ! include 'COMMON.IOUNITS'
6805 ! include 'COMMON.FFIELD'
6806 ! include 'COMMON.TORCNSTR'
6807 ! include 'COMMON.CONTROL'
6808 real(kind=8) :: etors,edihcnstr
6811 integer :: i,j,iblock,itori,itori1
6812 real(kind=8) :: phii,gloci,v1ij,v2ij,cosphi,sinphi,&
6813 vl1ij,vl2ij,vl3ij,pom1,difi,etors_ii,pom
6814 ! Set lprn=.true. for debugging
6818 do i=iphi_start,iphi_end
6819 if (itype(i-2,1).eq.ntyp1 .or. itype(i-1,1).eq.ntyp1 &
6820 .or. itype(i-3,1).eq.ntyp1 &
6821 .or. itype(i,1).eq.ntyp1) cycle
6823 if (iabs(itype(i,1)).eq.20) then
6828 itori=itortyp(itype(i-2,1))
6829 itori1=itortyp(itype(i-1,1))
6832 ! Regular cosine and sine terms
6833 do j=1,nterm(itori,itori1,iblock)
6834 v1ij=v1(j,itori,itori1,iblock)
6835 v2ij=v2(j,itori,itori1,iblock)
6838 etors=etors+v1ij*cosphi+v2ij*sinphi
6839 if (energy_dec) etors_ii=etors_ii+ &
6840 v1ij*cosphi+v2ij*sinphi
6841 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
6845 ! E = SUM ----------------------------------- - v1
6846 ! [v2 cos(phi/2)+v3 sin(phi/2)]^2 + 1
6848 cosphi=dcos(0.5d0*phii)
6849 sinphi=dsin(0.5d0*phii)
6850 do j=1,nlor(itori,itori1,iblock)
6851 vl1ij=vlor1(j,itori,itori1)
6852 vl2ij=vlor2(j,itori,itori1)
6853 vl3ij=vlor3(j,itori,itori1)
6854 pom=vl2ij*cosphi+vl3ij*sinphi
6855 pom1=1.0d0/(pom*pom+1.0d0)
6856 etors=etors+vl1ij*pom1
6857 if (energy_dec) etors_ii=etors_ii+ &
6860 gloci=gloci+vl1ij*(vl3ij*cosphi-vl2ij*sinphi)*pom
6862 ! Subtract the constant term
6863 etors=etors-v0(itori,itori1,iblock)
6864 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
6865 'etor',i,etors_ii-v0(itori,itori1,iblock)
6867 write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)') &
6868 restyp(itype(i-2,1),1),i-2,restyp(itype(i-1,1),1),i-1,itori,itori1,&
6869 (v1(j,itori,itori1,iblock),j=1,6),&
6870 (v2(j,itori,itori1,iblock),j=1,6)
6871 gloc(i-3,icg)=gloc(i-3,icg)+wtor*gloci
6872 ! write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
6874 ! 6/20/98 - dihedral angle constraints
6876 ! do i=1,ndih_constr
6877 do i=idihconstr_start,idihconstr_end
6878 itori=idih_constr(i)
6880 difi=pinorm(phii-phi0(i))
6881 if (difi.gt.drange(i)) then
6883 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
6884 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
6885 else if (difi.lt.-drange(i)) then
6887 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
6888 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
6892 !d write (iout,'(2i5,4f8.3,2e14.5)') i,itori,rad2deg*phii,
6893 !d & rad2deg*phi0(i), rad2deg*drange(i),
6894 !d & rad2deg*difi,0.25d0*ftors*difi**4,gloc(itori-3,icg)
6896 !d write (iout,*) 'edihcnstr',edihcnstr
6899 !-----------------------------------------------------------------------------
6900 subroutine etor_d(etors_d)
6901 ! 6/23/01 Compute double torsional energy
6902 ! implicit real*8 (a-h,o-z)
6903 ! include 'DIMENSIONS'
6904 ! include 'COMMON.VAR'
6905 ! include 'COMMON.GEO'
6906 ! include 'COMMON.LOCAL'
6907 ! include 'COMMON.TORSION'
6908 ! include 'COMMON.INTERACT'
6909 ! include 'COMMON.DERIV'
6910 ! include 'COMMON.CHAIN'
6911 ! include 'COMMON.NAMES'
6912 ! include 'COMMON.IOUNITS'
6913 ! include 'COMMON.FFIELD'
6914 ! include 'COMMON.TORCNSTR'
6915 real(kind=8) :: etors_d,etors_d_ii
6918 integer :: i,j,k,l,itori,itori1,itori2,iblock
6919 real(kind=8) :: phii,phii1,gloci1,gloci2,&
6920 v1cij,v1sij,v2cij,v2sij,cosphi1,sinphi1,&
6921 sinphi2,cosphi2,v1cdij,v2cdij,v1sdij,v2sdij,&
6922 cosphi1p2,cosphi1m2,sinphi1p2,sinphi1m2
6923 ! Set lprn=.true. for debugging
6927 ! write(iout,*) "a tu??"
6928 do i=iphid_start,iphid_end
6930 if (itype(i-2,1).eq.ntyp1 .or. itype(i-1,1).eq.ntyp1 &
6931 .or. itype(i-3,1).eq.ntyp1 &
6932 .or. itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
6933 itori=itortyp(itype(i-2,1))
6934 itori1=itortyp(itype(i-1,1))
6935 itori2=itortyp(itype(i,1))
6941 if (iabs(itype(i+1,1)).eq.20) iblock=2
6943 ! Regular cosine and sine terms
6944 do j=1,ntermd_1(itori,itori1,itori2,iblock)
6945 v1cij=v1c(1,j,itori,itori1,itori2,iblock)
6946 v1sij=v1s(1,j,itori,itori1,itori2,iblock)
6947 v2cij=v1c(2,j,itori,itori1,itori2,iblock)
6948 v2sij=v1s(2,j,itori,itori1,itori2,iblock)
6949 cosphi1=dcos(j*phii)
6950 sinphi1=dsin(j*phii)
6951 cosphi2=dcos(j*phii1)
6952 sinphi2=dsin(j*phii1)
6953 etors_d=etors_d+v1cij*cosphi1+v1sij*sinphi1+ &
6954 v2cij*cosphi2+v2sij*sinphi2
6955 if (energy_dec) etors_d_ii=etors_d_ii+ &
6956 v1cij*cosphi1+v1sij*sinphi1+v2cij*cosphi2+v2sij*sinphi2
6957 gloci1=gloci1+j*(v1sij*cosphi1-v1cij*sinphi1)
6958 gloci2=gloci2+j*(v2sij*cosphi2-v2cij*sinphi2)
6960 do k=2,ntermd_2(itori,itori1,itori2,iblock)
6962 v1cdij = v2c(k,l,itori,itori1,itori2,iblock)
6963 v2cdij = v2c(l,k,itori,itori1,itori2,iblock)
6964 v1sdij = v2s(k,l,itori,itori1,itori2,iblock)
6965 v2sdij = v2s(l,k,itori,itori1,itori2,iblock)
6966 cosphi1p2=dcos(l*phii+(k-l)*phii1)
6967 cosphi1m2=dcos(l*phii-(k-l)*phii1)
6968 sinphi1p2=dsin(l*phii+(k-l)*phii1)
6969 sinphi1m2=dsin(l*phii-(k-l)*phii1)
6970 etors_d=etors_d+v1cdij*cosphi1p2+v2cdij*cosphi1m2+ &
6971 v1sdij*sinphi1p2+v2sdij*sinphi1m2
6972 if (energy_dec) etors_d_ii=etors_d_ii+ &
6973 v1cdij*cosphi1p2+v2cdij*cosphi1m2+ &
6974 v1sdij*sinphi1p2+v2sdij*sinphi1m2
6975 gloci1=gloci1+l*(v1sdij*cosphi1p2+v2sdij*cosphi1m2 &
6976 -v1cdij*sinphi1p2-v2cdij*sinphi1m2)
6977 gloci2=gloci2+(k-l)*(v1sdij*cosphi1p2-v2sdij*cosphi1m2 &
6978 -v1cdij*sinphi1p2+v2cdij*sinphi1m2)
6981 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
6982 'etor_d',i,etors_d_ii
6983 gloc(i-3,icg)=gloc(i-3,icg)+wtor_d*gloci1
6984 gloc(i-2,icg)=gloc(i-2,icg)+wtor_d*gloci2
6987 end subroutine etor_d
6989 !-----------------------------------------------------------------------------
6990 subroutine eback_sc_corr(esccor)
6991 ! 7/21/2007 Correlations between the backbone-local and side-chain-local
6992 ! conformational states; temporarily implemented as differences
6993 ! between UNRES torsional potentials (dependent on three types of
6994 ! residues) and the torsional potentials dependent on all 20 types
6995 ! of residues computed from AM1 energy surfaces of terminally-blocked
6996 ! amino-acid residues.
6997 ! implicit real*8 (a-h,o-z)
6998 ! include 'DIMENSIONS'
6999 ! include 'COMMON.VAR'
7000 ! include 'COMMON.GEO'
7001 ! include 'COMMON.LOCAL'
7002 ! include 'COMMON.TORSION'
7003 ! include 'COMMON.SCCOR'
7004 ! include 'COMMON.INTERACT'
7005 ! include 'COMMON.DERIV'
7006 ! include 'COMMON.CHAIN'
7007 ! include 'COMMON.NAMES'
7008 ! include 'COMMON.IOUNITS'
7009 ! include 'COMMON.FFIELD'
7010 ! include 'COMMON.CONTROL'
7011 real(kind=8) :: esccor,esccor_ii,phii,gloci,v1ij,v2ij,&
7014 integer :: i,interty,j,isccori,isccori1,intertyp
7015 ! Set lprn=.true. for debugging
7018 ! write (iout,*) "EBACK_SC_COR",itau_start,itau_end
7020 do i=itau_start,itau_end
7021 if ((itype(i-2,1).eq.ntyp1).or.(itype(i-1,1).eq.ntyp1)) cycle
7023 isccori=isccortyp(itype(i-2,1))
7024 isccori1=isccortyp(itype(i-1,1))
7026 ! write (iout,*) "EBACK_SC_COR",i,nterm_sccor(isccori,isccori1)
7028 do intertyp=1,3 !intertyp
7030 !c Added 09 May 2012 (Adasko)
7031 !c Intertyp means interaction type of backbone mainchain correlation:
7032 ! 1 = SC...Ca...Ca...Ca
7033 ! 2 = Ca...Ca...Ca...SC
7034 ! 3 = SC...Ca...Ca...SCi
7036 if (((intertyp.eq.3).and.((itype(i-2,1).eq.10).or. &
7037 (itype(i-1,1).eq.10).or.(itype(i-2,1).eq.ntyp1).or. &
7038 (itype(i-1,1).eq.ntyp1))) &
7039 .or. ((intertyp.eq.1).and.((itype(i-2,1).eq.10) &
7040 .or.(itype(i-2,1).eq.ntyp1).or.(itype(i-1,1).eq.ntyp1) &
7041 .or.(itype(i,1).eq.ntyp1))) &
7042 .or.((intertyp.eq.2).and.((itype(i-1,1).eq.10).or. &
7043 (itype(i-1,1).eq.ntyp1).or.(itype(i-2,1).eq.ntyp1).or. &
7044 (itype(i-3,1).eq.ntyp1)))) cycle
7045 if ((intertyp.eq.2).and.(i.eq.4).and.(itype(1,1).eq.ntyp1)) cycle
7046 if ((intertyp.eq.1).and.(i.eq.nres).and.(itype(nres,1).eq.ntyp1)) &
7048 do j=1,nterm_sccor(isccori,isccori1)
7049 v1ij=v1sccor(j,intertyp,isccori,isccori1)
7050 v2ij=v2sccor(j,intertyp,isccori,isccori1)
7051 cosphi=dcos(j*tauangle(intertyp,i))
7052 sinphi=dsin(j*tauangle(intertyp,i))
7053 if (energy_dec) esccor_ii=esccor_ii+v1ij*cosphi+v2ij*sinphi
7054 esccor=esccor+v1ij*cosphi+v2ij*sinphi
7055 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
7057 if (energy_dec) write (iout,'(a6,i5,i2,0pf7.3)') &
7058 'esccor',i,intertyp,esccor_ii
7059 ! write (iout,*) "EBACK_SC_COR",i,v1ij*cosphi+v2ij*sinphi,intertyp
7060 gloc_sc(intertyp,i-3,icg)=gloc_sc(intertyp,i-3,icg)+wsccor*gloci
7062 write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)') &
7063 restyp(itype(i-2,1),1),i-2,restyp(itype(i-1,1),1),i-1,isccori,isccori1,&
7064 (v1sccor(j,intertyp,isccori,isccori1),j=1,6),&
7065 (v2sccor(j,intertyp,isccori,isccori1),j=1,6)
7066 gsccor_loc(i-3)=gsccor_loc(i-3)+gloci
7071 end subroutine eback_sc_corr
7072 !-----------------------------------------------------------------------------
7073 subroutine multibody(ecorr)
7074 ! This subroutine calculates multi-body contributions to energy following
7075 ! the idea of Skolnick et al. If side chains I and J make a contact and
7076 ! at the same time side chains I+1 and J+1 make a contact, an extra
7077 ! contribution equal to sqrt(eps(i,j)*eps(i+1,j+1)) is added.
7078 ! implicit real*8 (a-h,o-z)
7079 ! include 'DIMENSIONS'
7080 ! include 'COMMON.IOUNITS'
7081 ! include 'COMMON.DERIV'
7082 ! include 'COMMON.INTERACT'
7083 ! include 'COMMON.CONTACTS'
7084 real(kind=8),dimension(3) :: gx,gx1
7086 real(kind=8) :: ecorr
7087 integer :: i,j,ishift,i1,num_conti,num_conti1,j1,jj,kk
7088 ! Set lprn=.true. for debugging
7092 write (iout,'(a)') 'Contact function values:'
7094 write (iout,'(i2,20(1x,i2,f10.5))') &
7095 i,(jcont(j,i),facont(j,i),j=1,num_cont(i))
7100 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres))
7101 ! if (.not.allocated(gradxorr)) allocate(gradxorr(3,nres))
7113 num_conti=num_cont(i)
7114 num_conti1=num_cont(i1)
7119 if (j1.eq.j+ishift .or. j1.eq.j-ishift) then
7120 !d write(iout,*)'i=',i,' j=',j,' i1=',i1,' j1=',j1,
7121 !d & ' ishift=',ishift
7122 ! Contacts I--J and I+ISHIFT--J+-ISHIFT1 occur simultaneously.
7123 ! The system gains extra energy.
7124 ecorr=ecorr+esccorr(i,j,i1,j1,jj,kk)
7125 endif ! j1==j+-ishift
7133 end subroutine multibody
7134 !-----------------------------------------------------------------------------
7135 real(kind=8) function esccorr(i,j,k,l,jj,kk)
7136 ! implicit real*8 (a-h,o-z)
7137 ! include 'DIMENSIONS'
7138 ! include 'COMMON.IOUNITS'
7139 ! include 'COMMON.DERIV'
7140 ! include 'COMMON.INTERACT'
7141 ! include 'COMMON.CONTACTS'
7142 real(kind=8),dimension(3) :: gx,gx1
7144 integer :: i,j,k,l,jj,kk,m,ll
7145 real(kind=8) :: eij,ekl
7149 !d write (iout,'(4i5,3f10.5)') i,j,k,l,eij,ekl,-eij*ekl
7150 ! Calculate the multi-body contribution to energy.
7151 ! Calculate multi-body contributions to the gradient.
7152 !d write (iout,'(2(2i3,3f10.5))')i,j,(gacont(m,jj,i),m=1,3),
7153 !d & k,l,(gacont(m,kk,k),m=1,3)
7155 gx(m) =ekl*gacont(m,jj,i)
7156 gx1(m)=eij*gacont(m,kk,k)
7157 gradxorr(m,i)=gradxorr(m,i)-gx(m)
7158 gradxorr(m,j)=gradxorr(m,j)+gx(m)
7159 gradxorr(m,k)=gradxorr(m,k)-gx1(m)
7160 gradxorr(m,l)=gradxorr(m,l)+gx1(m)
7164 gradcorr(ll,m)=gradcorr(ll,m)+gx(ll)
7169 gradcorr(ll,m)=gradcorr(ll,m)+gx1(ll)
7174 end function esccorr
7175 !-----------------------------------------------------------------------------
7176 subroutine multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
7177 ! This subroutine calculates multi-body contributions to hydrogen-bonding
7178 ! implicit real*8 (a-h,o-z)
7179 ! include 'DIMENSIONS'
7180 ! include 'COMMON.IOUNITS'
7183 ! integer :: maxconts !max_cont=maxconts =nres/4
7184 integer,parameter :: max_dim=26
7185 integer :: source,CorrelType,CorrelID,CorrelType1,CorrelID1,Error
7186 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
7187 !el real(kind=8) :: zapas(max_dim,maxconts,nfgtasks)
7188 !el common /przechowalnia/ zapas
7189 integer :: status(MPI_STATUS_SIZE)
7190 integer,dimension((nres/4)*2) :: req !maxconts*2
7191 integer :: status_array(MPI_STATUS_SIZE,(nres/4)*2),nn,ireq,ierr
7193 ! include 'COMMON.SETUP'
7194 ! include 'COMMON.FFIELD'
7195 ! include 'COMMON.DERIV'
7196 ! include 'COMMON.INTERACT'
7197 ! include 'COMMON.CONTACTS'
7198 ! include 'COMMON.CONTROL'
7199 ! include 'COMMON.LOCAL'
7200 real(kind=8),dimension(3) :: gx,gx1
7201 real(kind=8) :: time00,ecorr,ecorr5,ecorr6
7202 logical :: lprn,ldone
7204 integer :: i,j,ii,k,n_corr,n_corr1,i1,num_conti,num_conti1,&
7205 jj,jp,kk,j1,jp1,jjc,iii,nnn,iproc
7207 ! Set lprn=.true. for debugging
7211 if(.not.allocated(zapas)) allocate(zapas(max_dim,maxconts,nfgtasks))
7214 if (nfgtasks.le.1) goto 30
7216 write (iout,'(a)') 'Contact function values before RECEIVE:'
7218 write (iout,'(2i3,50(1x,i2,f5.2))') &
7219 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
7224 do i=1,ntask_cont_from
7227 do i=1,ntask_cont_to
7230 ! write (iout,*) "ntask_cont_from",ntask_cont_from," ntask_cont_to",
7232 ! Make the list of contacts to send to send to other procesors
7233 ! write (iout,*) "limits",max0(iturn4_end-1,iatel_s),iturn3_end
7235 do i=iturn3_start,iturn3_end
7236 ! write (iout,*) "make contact list turn3",i," num_cont",
7238 call add_hb_contact(i,i+2,iturn3_sent_local(1,i))
7240 do i=iturn4_start,iturn4_end
7241 ! write (iout,*) "make contact list turn4",i," num_cont",
7243 call add_hb_contact(i,i+3,iturn4_sent_local(1,i))
7247 ! write (iout,*) "make contact list longrange",i,ii," num_cont",
7249 do j=1,num_cont_hb(i)
7252 iproc=iint_sent_local(k,jjc,ii)
7253 ! write (iout,*) "i",i," j",j," k",k," jjc",jjc," iproc",iproc
7254 if (iproc.gt.0) then
7255 ncont_sent(iproc)=ncont_sent(iproc)+1
7256 nn=ncont_sent(iproc)
7258 zapas(2,nn,iproc)=jjc
7259 zapas(3,nn,iproc)=facont_hb(j,i)
7260 zapas(4,nn,iproc)=ees0p(j,i)
7261 zapas(5,nn,iproc)=ees0m(j,i)
7262 zapas(6,nn,iproc)=gacont_hbr(1,j,i)
7263 zapas(7,nn,iproc)=gacont_hbr(2,j,i)
7264 zapas(8,nn,iproc)=gacont_hbr(3,j,i)
7265 zapas(9,nn,iproc)=gacontm_hb1(1,j,i)
7266 zapas(10,nn,iproc)=gacontm_hb1(2,j,i)
7267 zapas(11,nn,iproc)=gacontm_hb1(3,j,i)
7268 zapas(12,nn,iproc)=gacontp_hb1(1,j,i)
7269 zapas(13,nn,iproc)=gacontp_hb1(2,j,i)
7270 zapas(14,nn,iproc)=gacontp_hb1(3,j,i)
7271 zapas(15,nn,iproc)=gacontm_hb2(1,j,i)
7272 zapas(16,nn,iproc)=gacontm_hb2(2,j,i)
7273 zapas(17,nn,iproc)=gacontm_hb2(3,j,i)
7274 zapas(18,nn,iproc)=gacontp_hb2(1,j,i)
7275 zapas(19,nn,iproc)=gacontp_hb2(2,j,i)
7276 zapas(20,nn,iproc)=gacontp_hb2(3,j,i)
7277 zapas(21,nn,iproc)=gacontm_hb3(1,j,i)
7278 zapas(22,nn,iproc)=gacontm_hb3(2,j,i)
7279 zapas(23,nn,iproc)=gacontm_hb3(3,j,i)
7280 zapas(24,nn,iproc)=gacontp_hb3(1,j,i)
7281 zapas(25,nn,iproc)=gacontp_hb3(2,j,i)
7282 zapas(26,nn,iproc)=gacontp_hb3(3,j,i)
7289 "Numbers of contacts to be sent to other processors",&
7290 (ncont_sent(i),i=1,ntask_cont_to)
7291 write (iout,*) "Contacts sent"
7292 do ii=1,ntask_cont_to
7294 iproc=itask_cont_to(ii)
7295 write (iout,*) nn," contacts to processor",iproc,&
7296 " of CONT_TO_COMM group"
7298 write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
7306 CorrelID1=nfgtasks+fg_rank+1
7308 ! Receive the numbers of needed contacts from other processors
7309 do ii=1,ntask_cont_from
7310 iproc=itask_cont_from(ii)
7312 call MPI_Irecv(ncont_recv(ii),1,MPI_INTEGER,iproc,CorrelType,&
7313 FG_COMM,req(ireq),IERR)
7315 ! write (iout,*) "IRECV ended"
7317 ! Send the number of contacts needed by other processors
7318 do ii=1,ntask_cont_to
7319 iproc=itask_cont_to(ii)
7321 call MPI_Isend(ncont_sent(ii),1,MPI_INTEGER,iproc,CorrelType,&
7322 FG_COMM,req(ireq),IERR)
7324 ! write (iout,*) "ISEND ended"
7325 ! write (iout,*) "number of requests (nn)",ireq
7328 call MPI_Waitall(ireq,req,status_array,ierr)
7330 ! & "Numbers of contacts to be received from other processors",
7331 ! & (ncont_recv(i),i=1,ntask_cont_from)
7335 do ii=1,ntask_cont_from
7336 iproc=itask_cont_from(ii)
7338 ! write (iout,*) "Receiving",nn," contacts from processor",iproc,
7339 ! & " of CONT_TO_COMM group"
7343 call MPI_Irecv(zapas_recv(1,1,ii),nn*max_dim,&
7344 MPI_DOUBLE_PRECISION,iproc,CorrelType1,FG_COMM,req(ireq),IERR)
7345 ! write (iout,*) "ireq,req",ireq,req(ireq)
7348 ! Send the contacts to processors that need them
7349 do ii=1,ntask_cont_to
7350 iproc=itask_cont_to(ii)
7352 ! write (iout,*) nn," contacts to processor",iproc,
7353 ! & " of CONT_TO_COMM group"
7356 call MPI_Isend(zapas(1,1,ii),nn*max_dim,MPI_DOUBLE_PRECISION,&
7357 iproc,CorrelType1,FG_COMM,req(ireq),IERR)
7358 ! write (iout,*) "ireq,req",ireq,req(ireq)
7360 ! write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
7364 ! write (iout,*) "number of requests (contacts)",ireq
7365 ! write (iout,*) "req",(req(i),i=1,4)
7368 call MPI_Waitall(ireq,req,status_array,ierr)
7369 do iii=1,ntask_cont_from
7370 iproc=itask_cont_from(iii)
7373 write (iout,*) "Received",nn," contacts from processor",iproc,&
7374 " of CONT_FROM_COMM group"
7377 write(iout,'(2f5.0,4f10.5)')(zapas_recv(j,i,iii),j=1,5)
7382 ii=zapas_recv(1,i,iii)
7383 ! Flag the received contacts to prevent double-counting
7384 jj=-zapas_recv(2,i,iii)
7385 ! write (iout,*) "iii",iii," i",i," ii",ii," jj",jj
7387 nnn=num_cont_hb(ii)+1
7390 facont_hb(nnn,ii)=zapas_recv(3,i,iii)
7391 ees0p(nnn,ii)=zapas_recv(4,i,iii)
7392 ees0m(nnn,ii)=zapas_recv(5,i,iii)
7393 gacont_hbr(1,nnn,ii)=zapas_recv(6,i,iii)
7394 gacont_hbr(2,nnn,ii)=zapas_recv(7,i,iii)
7395 gacont_hbr(3,nnn,ii)=zapas_recv(8,i,iii)
7396 gacontm_hb1(1,nnn,ii)=zapas_recv(9,i,iii)
7397 gacontm_hb1(2,nnn,ii)=zapas_recv(10,i,iii)
7398 gacontm_hb1(3,nnn,ii)=zapas_recv(11,i,iii)
7399 gacontp_hb1(1,nnn,ii)=zapas_recv(12,i,iii)
7400 gacontp_hb1(2,nnn,ii)=zapas_recv(13,i,iii)
7401 gacontp_hb1(3,nnn,ii)=zapas_recv(14,i,iii)
7402 gacontm_hb2(1,nnn,ii)=zapas_recv(15,i,iii)
7403 gacontm_hb2(2,nnn,ii)=zapas_recv(16,i,iii)
7404 gacontm_hb2(3,nnn,ii)=zapas_recv(17,i,iii)
7405 gacontp_hb2(1,nnn,ii)=zapas_recv(18,i,iii)
7406 gacontp_hb2(2,nnn,ii)=zapas_recv(19,i,iii)
7407 gacontp_hb2(3,nnn,ii)=zapas_recv(20,i,iii)
7408 gacontm_hb3(1,nnn,ii)=zapas_recv(21,i,iii)
7409 gacontm_hb3(2,nnn,ii)=zapas_recv(22,i,iii)
7410 gacontm_hb3(3,nnn,ii)=zapas_recv(23,i,iii)
7411 gacontp_hb3(1,nnn,ii)=zapas_recv(24,i,iii)
7412 gacontp_hb3(2,nnn,ii)=zapas_recv(25,i,iii)
7413 gacontp_hb3(3,nnn,ii)=zapas_recv(26,i,iii)
7418 write (iout,'(a)') 'Contact function values after receive:'
7420 write (iout,'(2i3,50(1x,i3,f5.2))') &
7421 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
7429 write (iout,'(a)') 'Contact function values:'
7431 write (iout,'(2i3,50(1x,i3,f5.2))') &
7432 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
7438 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres))
7439 ! if (.not.allocated(gradxorr)) allocate(gradxorr(3,nres))
7440 ! Remove the loop below after debugging !!!
7447 ! Calculate the local-electrostatic correlation terms
7448 do i=min0(iatel_s,iturn4_start),max0(iatel_e,iturn3_end)
7450 num_conti=num_cont_hb(i)
7451 num_conti1=num_cont_hb(i+1)
7458 ! write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,&
7459 ! ' jj=',jj,' kk=',kk,"jp=",jp,"jp1",jp1
7460 if ((j.gt.0 .and. j1.gt.0 .or. j.gt.0 .and. j1.lt.0 &
7461 .or. j.lt.0 .and. j1.gt.0) .and. &
7462 (jp1.eq.jp+1 .or. jp1.eq.jp-1)) then
7463 ! Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
7464 ! The system gains extra energy.
7465 ecorr=ecorr+ehbcorr(i,jp,i+1,jp1,jj,kk,0.72D0,0.32D0)
7466 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
7467 'ecorrh',i,j,ehbcorr(i,jp,i+1,jp1,jj,kk,0.72D0,0.32D0)
7469 else if (j1.eq.j) then
7470 ! Contacts I-J and I-(J+1) occur simultaneously.
7471 ! The system loses extra energy.
7472 ! ecorr=ecorr+ehbcorr(i,j,i+1,j,jj,kk,0.60D0,-0.40D0)
7477 ! write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
7478 ! & ' jj=',jj,' kk=',kk
7480 ! Contacts I-J and (I+1)-J occur simultaneously.
7481 ! The system loses extra energy.
7482 ! ecorr=ecorr+ehbcorr(i,j,i,j+1,jj,kk,0.60D0,-0.40D0)
7488 end subroutine multibody_hb
7489 !-----------------------------------------------------------------------------
7490 subroutine add_hb_contact(ii,jj,itask)
7491 ! implicit real*8 (a-h,o-z)
7492 ! include "DIMENSIONS"
7493 ! include "COMMON.IOUNITS"
7494 ! include "COMMON.CONTACTS"
7495 ! integer,parameter :: maxconts=nres/4
7496 integer,parameter :: max_dim=26
7497 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
7498 ! real(kind=8) :: zapas(max_dim,maxconts,nfgtasks)
7499 ! common /przechowalnia/ zapas
7500 integer :: i,j,ii,jj,iproc,nn,jjc
7501 integer,dimension(4) :: itask
7502 ! write (iout,*) "itask",itask
7505 if (iproc.gt.0) then
7506 do j=1,num_cont_hb(ii)
7508 ! write (iout,*) "i",ii," j",jj," jjc",jjc
7510 ncont_sent(iproc)=ncont_sent(iproc)+1
7511 nn=ncont_sent(iproc)
7512 zapas(1,nn,iproc)=ii
7513 zapas(2,nn,iproc)=jjc
7514 zapas(3,nn,iproc)=facont_hb(j,ii)
7515 zapas(4,nn,iproc)=ees0p(j,ii)
7516 zapas(5,nn,iproc)=ees0m(j,ii)
7517 zapas(6,nn,iproc)=gacont_hbr(1,j,ii)
7518 zapas(7,nn,iproc)=gacont_hbr(2,j,ii)
7519 zapas(8,nn,iproc)=gacont_hbr(3,j,ii)
7520 zapas(9,nn,iproc)=gacontm_hb1(1,j,ii)
7521 zapas(10,nn,iproc)=gacontm_hb1(2,j,ii)
7522 zapas(11,nn,iproc)=gacontm_hb1(3,j,ii)
7523 zapas(12,nn,iproc)=gacontp_hb1(1,j,ii)
7524 zapas(13,nn,iproc)=gacontp_hb1(2,j,ii)
7525 zapas(14,nn,iproc)=gacontp_hb1(3,j,ii)
7526 zapas(15,nn,iproc)=gacontm_hb2(1,j,ii)
7527 zapas(16,nn,iproc)=gacontm_hb2(2,j,ii)
7528 zapas(17,nn,iproc)=gacontm_hb2(3,j,ii)
7529 zapas(18,nn,iproc)=gacontp_hb2(1,j,ii)
7530 zapas(19,nn,iproc)=gacontp_hb2(2,j,ii)
7531 zapas(20,nn,iproc)=gacontp_hb2(3,j,ii)
7532 zapas(21,nn,iproc)=gacontm_hb3(1,j,ii)
7533 zapas(22,nn,iproc)=gacontm_hb3(2,j,ii)
7534 zapas(23,nn,iproc)=gacontm_hb3(3,j,ii)
7535 zapas(24,nn,iproc)=gacontp_hb3(1,j,ii)
7536 zapas(25,nn,iproc)=gacontp_hb3(2,j,ii)
7537 zapas(26,nn,iproc)=gacontp_hb3(3,j,ii)
7544 end subroutine add_hb_contact
7545 !-----------------------------------------------------------------------------
7546 subroutine multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
7547 ! This subroutine calculates multi-body contributions to hydrogen-bonding
7548 ! implicit real*8 (a-h,o-z)
7549 ! include 'DIMENSIONS'
7550 ! include 'COMMON.IOUNITS'
7551 integer,parameter :: max_dim=70
7554 ! integer :: maxconts !max_cont=maxconts=nres/4
7555 integer :: source,CorrelType,CorrelID,CorrelType1,CorrelID1,Error
7556 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks)
7557 ! real(kind=8) :: zapas(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
7558 ! common /przechowalnia/ zapas
7559 integer :: status(MPI_STATUS_SIZE),req((nres/4)*2),&
7560 status_array(MPI_STATUS_SIZE,(nres/4)*2),jjc,iproc,ireq,nn,ind,&
7563 ! include 'COMMON.SETUP'
7564 ! include 'COMMON.FFIELD'
7565 ! include 'COMMON.DERIV'
7566 ! include 'COMMON.LOCAL'
7567 ! include 'COMMON.INTERACT'
7568 ! include 'COMMON.CONTACTS'
7569 ! include 'COMMON.CHAIN'
7570 ! include 'COMMON.CONTROL'
7571 real(kind=8),dimension(3) :: gx,gx1
7572 integer,dimension(nres) :: num_cont_hb_old
7573 logical :: lprn,ldone
7574 !EL double precision eello4,eello5,eelo6,eello_turn6
7575 !EL external eello4,eello5,eello6,eello_turn6
7577 integer :: i,ii,j,k,l,jj,kk,ll,mm,n_corr,n_corr1,num_conti,jp,&
7578 j1,jp1,i1,num_conti1
7579 real(kind=8) :: sqd1,sqd2,sred_geom,fac_prim1,fac_prim2,fprimcont
7580 real(kind=8) :: ecorr,ecorr5,ecorr6,eturn6
7582 ! Set lprn=.true. for debugging
7587 if(.not.allocated(zapas)) allocate(zapas(max_dim,maxconts,nfgtasks))
7589 num_cont_hb_old(i)=num_cont_hb(i)
7593 if (nfgtasks.le.1) goto 30
7595 write (iout,'(a)') 'Contact function values before RECEIVE:'
7597 write (iout,'(2i3,50(1x,i2,f5.2))') &
7598 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
7603 do i=1,ntask_cont_from
7606 do i=1,ntask_cont_to
7609 ! write (iout,*) "ntask_cont_from",ntask_cont_from," ntask_cont_to",
7611 ! Make the list of contacts to send to send to other procesors
7612 do i=iturn3_start,iturn3_end
7613 ! write (iout,*) "make contact list turn3",i," num_cont",
7615 call add_hb_contact_eello(i,i+2,iturn3_sent_local(1,i))
7617 do i=iturn4_start,iturn4_end
7618 ! write (iout,*) "make contact list turn4",i," num_cont",
7620 call add_hb_contact_eello(i,i+3,iturn4_sent_local(1,i))
7624 ! write (iout,*) "make contact list longrange",i,ii," num_cont",
7626 do j=1,num_cont_hb(i)
7629 iproc=iint_sent_local(k,jjc,ii)
7630 ! write (iout,*) "i",i," j",j," k",k," jjc",jjc," iproc",iproc
7631 if (iproc.ne.0) then
7632 ncont_sent(iproc)=ncont_sent(iproc)+1
7633 nn=ncont_sent(iproc)
7635 zapas(2,nn,iproc)=jjc
7636 zapas(3,nn,iproc)=d_cont(j,i)
7640 zapas(ind,nn,iproc)=grij_hb_cont(kk,j,i)
7645 zapas(ind,nn,iproc)=a_chuj(ll,kk,j,i)
7653 zapas(ind,nn,iproc)=a_chuj_der(mm,ll,kk,jj,j,i)
7664 "Numbers of contacts to be sent to other processors",&
7665 (ncont_sent(i),i=1,ntask_cont_to)
7666 write (iout,*) "Contacts sent"
7667 do ii=1,ntask_cont_to
7669 iproc=itask_cont_to(ii)
7670 write (iout,*) nn," contacts to processor",iproc,&
7671 " of CONT_TO_COMM group"
7673 write(iout,'(2f5.0,10f10.5)')(zapas(j,i,ii),j=1,10)
7681 CorrelID1=nfgtasks+fg_rank+1
7683 ! Receive the numbers of needed contacts from other processors
7684 do ii=1,ntask_cont_from
7685 iproc=itask_cont_from(ii)
7687 call MPI_Irecv(ncont_recv(ii),1,MPI_INTEGER,iproc,CorrelType,&
7688 FG_COMM,req(ireq),IERR)
7690 ! write (iout,*) "IRECV ended"
7692 ! Send the number of contacts needed by other processors
7693 do ii=1,ntask_cont_to
7694 iproc=itask_cont_to(ii)
7696 call MPI_Isend(ncont_sent(ii),1,MPI_INTEGER,iproc,CorrelType,&
7697 FG_COMM,req(ireq),IERR)
7699 ! write (iout,*) "ISEND ended"
7700 ! write (iout,*) "number of requests (nn)",ireq
7703 call MPI_Waitall(ireq,req,status_array,ierr)
7705 ! & "Numbers of contacts to be received from other processors",
7706 ! & (ncont_recv(i),i=1,ntask_cont_from)
7710 do ii=1,ntask_cont_from
7711 iproc=itask_cont_from(ii)
7713 ! write (iout,*) "Receiving",nn," contacts from processor",iproc,
7714 ! & " of CONT_TO_COMM group"
7718 call MPI_Irecv(zapas_recv(1,1,ii),nn*max_dim,&
7719 MPI_DOUBLE_PRECISION,iproc,CorrelType1,FG_COMM,req(ireq),IERR)
7720 ! write (iout,*) "ireq,req",ireq,req(ireq)
7723 ! Send the contacts to processors that need them
7724 do ii=1,ntask_cont_to
7725 iproc=itask_cont_to(ii)
7727 ! write (iout,*) nn," contacts to processor",iproc,
7728 ! & " of CONT_TO_COMM group"
7731 call MPI_Isend(zapas(1,1,ii),nn*max_dim,MPI_DOUBLE_PRECISION,&
7732 iproc,CorrelType1,FG_COMM,req(ireq),IERR)
7733 ! write (iout,*) "ireq,req",ireq,req(ireq)
7735 ! write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
7739 ! write (iout,*) "number of requests (contacts)",ireq
7740 ! write (iout,*) "req",(req(i),i=1,4)
7743 call MPI_Waitall(ireq,req,status_array,ierr)
7744 do iii=1,ntask_cont_from
7745 iproc=itask_cont_from(iii)
7748 write (iout,*) "Received",nn," contacts from processor",iproc,&
7749 " of CONT_FROM_COMM group"
7752 write(iout,'(2f5.0,10f10.5)')(zapas_recv(j,i,iii),j=1,10)
7757 ii=zapas_recv(1,i,iii)
7758 ! Flag the received contacts to prevent double-counting
7759 jj=-zapas_recv(2,i,iii)
7760 ! write (iout,*) "iii",iii," i",i," ii",ii," jj",jj
7762 nnn=num_cont_hb(ii)+1
7765 d_cont(nnn,ii)=zapas_recv(3,i,iii)
7769 grij_hb_cont(kk,nnn,ii)=zapas_recv(ind,i,iii)
7774 a_chuj(ll,kk,nnn,ii)=zapas_recv(ind,i,iii)
7782 a_chuj_der(mm,ll,kk,jj,nnn,ii)=zapas_recv(ind,i,iii)
7791 write (iout,'(a)') 'Contact function values after receive:'
7793 write (iout,'(2i3,50(1x,i3,5f6.3))') &
7794 i,num_cont_hb(i),(jcont_hb(j,i),d_cont(j,i),&
7795 ((a_chuj(ll,kk,j,i),ll=1,2),kk=1,2),j=1,num_cont_hb(i))
7802 write (iout,'(a)') 'Contact function values:'
7804 write (iout,'(2i3,50(1x,i2,5f6.3))') &
7805 i,num_cont_hb(i),(jcont_hb(j,i),d_cont(j,i),&
7806 ((a_chuj(ll,kk,j,i),ll=1,2),kk=1,2),j=1,num_cont_hb(i))
7813 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres))
7814 ! if (.not.allocated(gradxorr)) allocate(gradxorr(3,nres))
7815 ! Remove the loop below after debugging !!!
7822 ! Calculate the dipole-dipole interaction energies
7823 if (wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) then
7824 do i=iatel_s,iatel_e+1
7825 num_conti=num_cont_hb(i)
7834 ! Calculate the local-electrostatic correlation terms
7835 ! write (iout,*) "gradcorr5 in eello5 before loop"
7837 ! write (iout,'(i5,3f10.5)')
7838 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
7840 do i=min0(iatel_s,iturn4_start),max0(iatel_e+1,iturn3_end+1)
7841 ! write (iout,*) "corr loop i",i
7843 num_conti=num_cont_hb(i)
7844 num_conti1=num_cont_hb(i+1)
7851 ! write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
7852 ! & ' jj=',jj,' kk=',kk
7853 ! if (j1.eq.j+1 .or. j1.eq.j-1) then
7854 if ((j.gt.0 .and. j1.gt.0 .or. j.gt.0 .and. j1.lt.0 &
7855 .or. j.lt.0 .and. j1.gt.0) .and. &
7856 (jp1.eq.jp+1 .or. jp1.eq.jp-1)) then
7857 ! Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
7858 ! The system gains extra energy.
7860 sqd1=dsqrt(d_cont(jj,i))
7861 sqd2=dsqrt(d_cont(kk,i1))
7862 sred_geom = sqd1*sqd2
7863 IF (sred_geom.lt.cutoff_corr) THEN
7864 call gcont(sred_geom,r0_corr,1.0D0,delt_corr,&
7866 !d write (iout,*) 'i=',i,' j=',jp,' i1=',i1,' j1=',jp1,
7867 !d & ' jj=',jj,' kk=',kk
7868 fac_prim1=0.5d0*sqd2/sqd1*fprimcont
7869 fac_prim2=0.5d0*sqd1/sqd2*fprimcont
7871 g_contij(l,1)=fac_prim1*grij_hb_cont(l,jj,i)
7872 g_contij(l,2)=fac_prim2*grij_hb_cont(l,kk,i1)
7875 !d write (iout,*) 'sred_geom=',sred_geom,
7876 !d & ' ekont=',ekont,' fprim=',fprimcont,
7877 !d & ' fac_prim1',fac_prim1,' fac_prim2',fac_prim2
7878 !d write (iout,*) "g_contij",g_contij
7879 !d write (iout,*) "grij_hb_cont i",grij_hb_cont(:,jj,i)
7880 !d write (iout,*) "grij_hb_cont i1",grij_hb_cont(:,jj,i1)
7881 call calc_eello(i,jp,i+1,jp1,jj,kk)
7882 if (wcorr4.gt.0.0d0) &
7883 ecorr=ecorr+eello4(i,jp,i+1,jp1,jj,kk)
7884 if (energy_dec.and.wcorr4.gt.0.0d0) &
7885 write (iout,'(a6,4i5,0pf7.3)') &
7886 'ecorr4',i,j,i+1,j1,eello4(i,jp,i+1,jp1,jj,kk)
7887 ! write (iout,*) "gradcorr5 before eello5"
7889 ! write (iout,'(i5,3f10.5)')
7890 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
7892 if (wcorr5.gt.0.0d0) &
7893 ecorr5=ecorr5+eello5(i,jp,i+1,jp1,jj,kk)
7894 ! write (iout,*) "gradcorr5 after eello5"
7896 ! write (iout,'(i5,3f10.5)')
7897 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
7899 if (energy_dec.and.wcorr5.gt.0.0d0) &
7900 write (iout,'(a6,4i5,0pf7.3)') &
7901 'ecorr5',i,j,i+1,j1,eello5(i,jp,i+1,jp1,jj,kk)
7902 !d write(2,*)'wcorr6',wcorr6,' wturn6',wturn6
7903 !d write(2,*)'ijkl',i,jp,i+1,jp1
7904 if (wcorr6.gt.0.0d0 .and. (jp.ne.i+4 .or. jp1.ne.i+3 &
7905 .or. wturn6.eq.0.0d0))then
7906 !d write (iout,*) '******ecorr6: i,j,i+1,j1',i,j,i+1,j1
7907 ecorr6=ecorr6+eello6(i,jp,i+1,jp1,jj,kk)
7908 if (energy_dec) write (iout,'(a6,4i5,0pf7.3)') &
7909 'ecorr6',i,j,i+1,j1,eello6(i,jp,i+1,jp1,jj,kk)
7910 !d write (iout,*) 'ecorr',ecorr,' ecorr5=',ecorr5,
7911 !d & 'ecorr6=',ecorr6
7912 !d write (iout,'(4e15.5)') sred_geom,
7913 !d & dabs(eello4(i,jp,i+1,jp1,jj,kk)),
7914 !d & dabs(eello5(i,jp,i+1,jp1,jj,kk)),
7915 !d & dabs(eello6(i,jp,i+1,jp1,jj,kk))
7916 else if (wturn6.gt.0.0d0 &
7917 .and. (jp.eq.i+4 .and. jp1.eq.i+3)) then
7918 !d write (iout,*) '******eturn6: i,j,i+1,j1',i,jip,i+1,jp1
7919 eturn6=eturn6+eello_turn6(i,jj,kk)
7920 if (energy_dec) write (iout,'(a6,4i5,0pf7.3)') &
7921 'eturn6',i,j,i+1,j1,eello_turn6(i,jj,kk)
7922 !d write (2,*) 'multibody_eello:eturn6',eturn6
7931 num_cont_hb(i)=num_cont_hb_old(i)
7933 ! write (iout,*) "gradcorr5 in eello5"
7935 ! write (iout,'(i5,3f10.5)')
7936 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
7939 end subroutine multibody_eello
7940 !-----------------------------------------------------------------------------
7941 subroutine add_hb_contact_eello(ii,jj,itask)
7942 ! implicit real*8 (a-h,o-z)
7943 ! include "DIMENSIONS"
7944 ! include "COMMON.IOUNITS"
7945 ! include "COMMON.CONTACTS"
7946 ! integer,parameter :: maxconts=nres/4
7947 integer,parameter :: max_dim=70
7948 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks)
7949 ! real(kind=8) :: zapas(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
7950 ! common /przechowalnia/ zapas
7952 integer :: i,j,ii,jj,iproc,nn,ind,jjc,kk,ll,mm
7953 integer,dimension(4) ::itask
7954 ! write (iout,*) "itask",itask
7957 if (iproc.gt.0) then
7958 do j=1,num_cont_hb(ii)
7960 ! write (iout,*) "send turns i",ii," j",jj," jjc",jjc
7962 ncont_sent(iproc)=ncont_sent(iproc)+1
7963 nn=ncont_sent(iproc)
7964 zapas(1,nn,iproc)=ii
7965 zapas(2,nn,iproc)=jjc
7966 zapas(3,nn,iproc)=d_cont(j,ii)
7970 zapas(ind,nn,iproc)=grij_hb_cont(kk,j,ii)
7975 zapas(ind,nn,iproc)=a_chuj(ll,kk,j,ii)
7983 zapas(ind,nn,iproc)=a_chuj_der(mm,ll,kk,jj,j,ii)
7994 end subroutine add_hb_contact_eello
7995 !-----------------------------------------------------------------------------
7996 real(kind=8) function ehbcorr(i,j,k,l,jj,kk,coeffp,coeffm)
7997 ! implicit real*8 (a-h,o-z)
7998 ! include 'DIMENSIONS'
7999 ! include 'COMMON.IOUNITS'
8000 ! include 'COMMON.DERIV'
8001 ! include 'COMMON.INTERACT'
8002 ! include 'COMMON.CONTACTS'
8003 real(kind=8),dimension(3) :: gx,gx1
8006 integer :: i,j,k,l,jj,kk,ll,ilist,m, iresshield
8007 real(kind=8) :: coeffp,coeffm,eij,ekl,ees0pij,ees0pkl,ees0mij,&
8008 ees0mkl,ees,coeffpees0pij,coeffmees0mij,&
8009 coeffpees0pkl,coeffmees0mkl,gradlongij,gradlongkl, &
8020 ees=-(coeffp*ees0pij*ees0pkl+coeffm*ees0mij*ees0mkl)
8021 !d ees=-(coeffp*ees0pkl+coeffm*ees0mkl)
8022 ! Following 4 lines for diagnostics.
8027 ! write (iout,'(2(a,2i3,a,f10.5,a,2f10.5),a,f10.5,a,$)')
8028 ! & 'Contacts ',i,j,
8029 ! & ' eij',eij,' eesij',ees0pij,ees0mij,' and ',k,l
8030 ! & ,' fcont ',ekl,' eeskl',ees0pkl,ees0mkl,' energy=',ekont*ees,
8032 ! Calculate the multi-body contribution to energy.
8033 ! ecorr=ecorr+ekont*ees
8034 ! Calculate multi-body contributions to the gradient.
8035 coeffpees0pij=coeffp*ees0pij
8036 coeffmees0mij=coeffm*ees0mij
8037 coeffpees0pkl=coeffp*ees0pkl
8038 coeffmees0mkl=coeffm*ees0mkl
8040 !grad ghalfi=ees*ekl*gacont_hbr(ll,jj,i)
8041 gradcorr(ll,i)=gradcorr(ll,i) & !+0.5d0*ghalfi
8042 -ekont*(coeffpees0pkl*gacontp_hb1(ll,jj,i)+ &
8043 coeffmees0mkl*gacontm_hb1(ll,jj,i))
8044 gradcorr(ll,j)=gradcorr(ll,j) & !+0.5d0*ghalfi
8045 -ekont*(coeffpees0pkl*gacontp_hb2(ll,jj,i)+ &
8046 coeffmees0mkl*gacontm_hb2(ll,jj,i))
8047 !grad ghalfk=ees*eij*gacont_hbr(ll,kk,k)
8048 gradcorr(ll,k)=gradcorr(ll,k) & !+0.5d0*ghalfk
8049 -ekont*(coeffpees0pij*gacontp_hb1(ll,kk,k)+&
8050 coeffmees0mij*gacontm_hb1(ll,kk,k))
8051 gradcorr(ll,l)=gradcorr(ll,l) & !+0.5d0*ghalfk
8052 -ekont*(coeffpees0pij*gacontp_hb2(ll,kk,k)+ &
8053 coeffmees0mij*gacontm_hb2(ll,kk,k))
8054 gradlongij=ees*ekl*gacont_hbr(ll,jj,i)- &
8055 ekont*(coeffpees0pkl*gacontp_hb3(ll,jj,i)+ &
8056 coeffmees0mkl*gacontm_hb3(ll,jj,i))
8057 gradcorr_long(ll,j)=gradcorr_long(ll,j)+gradlongij
8058 gradcorr_long(ll,i)=gradcorr_long(ll,i)-gradlongij
8059 gradlongkl=ees*eij*gacont_hbr(ll,kk,k)- &
8060 ekont*(coeffpees0pij*gacontp_hb3(ll,kk,k)+ &
8061 coeffmees0mij*gacontm_hb3(ll,kk,k))
8062 gradcorr_long(ll,l)=gradcorr_long(ll,l)+gradlongkl
8063 gradcorr_long(ll,k)=gradcorr_long(ll,k)-gradlongkl
8064 ! write (iout,'(2f10.5,2x,$)') gradlongij,gradlongkl
8069 !grad gradcorr(ll,m)=gradcorr(ll,m)+
8070 !grad & ees*ekl*gacont_hbr(ll,jj,i)-
8071 !grad & ekont*(coeffp*ees0pkl*gacontp_hb3(ll,jj,i)+
8072 !grad & coeffm*ees0mkl*gacontm_hb3(ll,jj,i))
8077 !grad gradcorr(ll,m)=gradcorr(ll,m)+
8078 !grad & ees*eij*gacont_hbr(ll,kk,k)-
8079 !grad & ekont*(coeffp*ees0pij*gacontp_hb3(ll,kk,k)+
8080 !grad & coeffm*ees0mij*gacontm_hb3(ll,kk,k))
8083 ! write (iout,*) "ehbcorr",ekont*ees
8085 if (shield_mode.gt.0) then
8088 !C print *,i,j,fac_shield(i),fac_shield(j),
8089 !C &fac_shield(k),fac_shield(l)
8090 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
8091 (fac_shield(k).gt.0).and.(fac_shield(l).gt.0)) then
8092 do ilist=1,ishield_list(i)
8093 iresshield=shield_list(ilist,i)
8095 rlocshield=grad_shield_side(m,ilist,i)*ehbcorr/fac_shield(i)
8096 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+ &
8098 +grad_shield_loc(m,ilist,i)*ehbcorr/fac_shield(i)
8099 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1) &
8103 do ilist=1,ishield_list(j)
8104 iresshield=shield_list(ilist,j)
8106 rlocshield=grad_shield_side(m,ilist,j)*ehbcorr/fac_shield(j)
8107 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+ &
8109 +grad_shield_loc(m,ilist,j)*ehbcorr/fac_shield(j)
8110 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1) &
8115 do ilist=1,ishield_list(k)
8116 iresshield=shield_list(ilist,k)
8118 rlocshield=grad_shield_side(m,ilist,k)*ehbcorr/fac_shield(k)
8119 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+ &
8121 +grad_shield_loc(m,ilist,k)*ehbcorr/fac_shield(k)
8122 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1) &
8126 do ilist=1,ishield_list(l)
8127 iresshield=shield_list(ilist,l)
8129 rlocshield=grad_shield_side(m,ilist,l)*ehbcorr/fac_shield(l)
8130 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+ &
8132 +grad_shield_loc(m,ilist,l)*ehbcorr/fac_shield(l)
8133 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1) &
8138 gshieldc_ec(m,i)=gshieldc_ec(m,i)+ &
8139 grad_shield(m,i)*ehbcorr/fac_shield(i)
8140 gshieldc_ec(m,j)=gshieldc_ec(m,j)+ &
8141 grad_shield(m,j)*ehbcorr/fac_shield(j)
8142 gshieldc_ec(m,i-1)=gshieldc_ec(m,i-1)+ &
8143 grad_shield(m,i)*ehbcorr/fac_shield(i)
8144 gshieldc_ec(m,j-1)=gshieldc_ec(m,j-1)+ &
8145 grad_shield(m,j)*ehbcorr/fac_shield(j)
8147 gshieldc_ec(m,k)=gshieldc_ec(m,k)+ &
8148 grad_shield(m,k)*ehbcorr/fac_shield(k)
8149 gshieldc_ec(m,l)=gshieldc_ec(m,l)+ &
8150 grad_shield(m,l)*ehbcorr/fac_shield(l)
8151 gshieldc_ec(m,k-1)=gshieldc_ec(m,k-1)+ &
8152 grad_shield(m,k)*ehbcorr/fac_shield(k)
8153 gshieldc_ec(m,l-1)=gshieldc_ec(m,l-1)+ &
8154 grad_shield(m,l)*ehbcorr/fac_shield(l)
8160 end function ehbcorr
8162 !-----------------------------------------------------------------------------
8163 subroutine dipole(i,j,jj)
8164 ! implicit real*8 (a-h,o-z)
8165 ! include 'DIMENSIONS'
8166 ! include 'COMMON.IOUNITS'
8167 ! include 'COMMON.CHAIN'
8168 ! include 'COMMON.FFIELD'
8169 ! include 'COMMON.DERIV'
8170 ! include 'COMMON.INTERACT'
8171 ! include 'COMMON.CONTACTS'
8172 ! include 'COMMON.TORSION'
8173 ! include 'COMMON.VAR'
8174 ! include 'COMMON.GEO'
8175 real(kind=8),dimension(2,2) :: dipi,dipj,auxmat
8176 real(kind=8),dimension(2) :: dipderi,dipderj,auxvec
8177 integer :: i,j,jj,iii,jjj,kkk,lll,iti1,itj1
8179 allocate(dip(4,maxconts,nres),dipderg(4,maxconts,nres))
8180 allocate(dipderx(3,5,4,maxconts,nres))
8183 iti1 = itortyp(itype(i+1,1))
8184 if (j.lt.nres-1) then
8185 itj1 = itortyp(itype(j+1,1))
8190 dipi(iii,1)=Ub2(iii,i)
8191 dipderi(iii)=Ub2der(iii,i)
8192 dipi(iii,2)=b1(iii,iti1)
8193 dipj(iii,1)=Ub2(iii,j)
8194 dipderj(iii)=Ub2der(iii,j)
8195 dipj(iii,2)=b1(iii,itj1)
8199 call matvec2(a_chuj(1,1,jj,i),dipj(1,iii),auxvec(1))
8202 dip(kkk,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
8209 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),dipj(1,iii),&
8213 dipderx(lll,kkk,mmm,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
8218 call transpose2(a_chuj(1,1,jj,i),auxmat(1,1))
8219 call matvec2(auxmat(1,1),dipderi(1),auxvec(1))
8221 dipderg(iii,jj,i)=scalar2(auxvec(1),dipj(1,iii))
8223 call matvec2(a_chuj(1,1,jj,i),dipderj(1),auxvec(1))
8225 dipderg(iii+2,jj,i)=scalar2(auxvec(1),dipi(1,iii))
8228 end subroutine dipole
8230 !-----------------------------------------------------------------------------
8231 subroutine calc_eello(i,j,k,l,jj,kk)
8233 ! This subroutine computes matrices and vectors needed to calculate
8234 ! the fourth-, fifth-, and sixth-order local-electrostatic terms.
8237 ! implicit real*8 (a-h,o-z)
8238 ! include 'DIMENSIONS'
8239 ! include 'COMMON.IOUNITS'
8240 ! include 'COMMON.CHAIN'
8241 ! include 'COMMON.DERIV'
8242 ! include 'COMMON.INTERACT'
8243 ! include 'COMMON.CONTACTS'
8244 ! include 'COMMON.TORSION'
8245 ! include 'COMMON.VAR'
8246 ! include 'COMMON.GEO'
8247 ! include 'COMMON.FFIELD'
8248 real(kind=8),dimension(2,2) :: aa1,aa2,aa1t,aa2t,auxmat
8249 real(kind=8),dimension(2,2,3,5) :: aa1tder,aa2tder
8250 integer :: i,j,k,l,jj,kk,iii,jjj,kkk,lll,iti,itk1,itj,itl,itl1,&
8253 !el common /kutas/ lprn
8254 !d write (iout,*) 'calc_eello: i=',i,' j=',j,' k=',k,' l=',l,
8255 !d & ' jj=',jj,' kk=',kk
8256 !d if (i.ne.2 .or. j.ne.4 .or. k.ne.3 .or. l.ne.5) return
8257 !d write (iout,*) "a_chujij",((a_chuj(iii,jjj,jj,i),iii=1,2),jjj=1,2)
8258 !d write (iout,*) "a_chujkl",((a_chuj(iii,jjj,kk,k),iii=1,2),jjj=1,2)
8261 aa1(iii,jjj)=a_chuj(iii,jjj,jj,i)
8262 aa2(iii,jjj)=a_chuj(iii,jjj,kk,k)
8265 call transpose2(aa1(1,1),aa1t(1,1))
8266 call transpose2(aa2(1,1),aa2t(1,1))
8269 call transpose2(a_chuj_der(1,1,lll,kkk,jj,i),&
8270 aa1tder(1,1,lll,kkk))
8271 call transpose2(a_chuj_der(1,1,lll,kkk,kk,k),&
8272 aa2tder(1,1,lll,kkk))
8276 ! parallel orientation of the two CA-CA-CA frames.
8278 iti=itortyp(itype(i,1))
8282 itk1=itortyp(itype(k+1,1))
8283 itj=itortyp(itype(j,1))
8284 if (l.lt.nres-1) then
8285 itl1=itortyp(itype(l+1,1))
8289 ! A1 kernel(j+1) A2T
8291 !d write (iout,'(3f10.5,5x,3f10.5)')
8292 !d & (EUg(iii,jjj,k),jjj=1,2),(EUg(iii,jjj,l),jjj=1,2)
8294 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8295 aa2tder(1,1,1,1),1,.false.,EUg(1,1,l),EUgder(1,1,l),&
8296 AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
8297 ! Following matrices are needed only for 6-th order cumulants
8298 IF (wcorr6.gt.0.0d0) THEN
8299 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8300 aa2tder(1,1,1,1),1,.false.,EUgC(1,1,l),EUgCder(1,1,l),&
8301 AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
8302 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8303 aa2tder(1,1,1,1),2,.false.,Ug2DtEUg(1,1,l),&
8304 Ug2DtEUgder(1,1,1,l),ADtEA(1,1,1),ADtEAderg(1,1,1,1),&
8305 ADtEAderx(1,1,1,1,1,1))
8307 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8308 aa2tder(1,1,1,1),2,.false.,DtUg2EUg(1,1,l),&
8309 DtUg2EUgder(1,1,1,l),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),&
8310 ADtEA1derx(1,1,1,1,1,1))
8312 ! End 6-th order cumulants
8315 !d write (2,*) 'In calc_eello6'
8317 !d write (2,*) 'iii=',iii
8319 !d write (2,*) 'kkk=',kkk
8321 !d write (2,'(3(2f10.5),5x)')
8322 !d & ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
8327 call transpose2(EUgder(1,1,k),auxmat(1,1))
8328 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
8329 call transpose2(EUg(1,1,k),auxmat(1,1))
8330 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
8331 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
8335 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),&
8336 EAEAderx(1,1,lll,kkk,iii,1))
8340 ! A1T kernel(i+1) A2
8341 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
8342 a_chuj_der(1,1,1,1,kk,k),1,.false.,EUg(1,1,k),EUgder(1,1,k),&
8343 AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
8344 ! Following matrices are needed only for 6-th order cumulants
8345 IF (wcorr6.gt.0.0d0) THEN
8346 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
8347 a_chuj_der(1,1,1,1,kk,k),1,.false.,EUgC(1,1,k),EUgCder(1,1,k),&
8348 AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
8349 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
8350 a_chuj_der(1,1,1,1,kk,k),2,.false.,Ug2DtEUg(1,1,k),&
8351 Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),&
8352 ADtEAderx(1,1,1,1,1,2))
8353 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
8354 a_chuj_der(1,1,1,1,kk,k),2,.false.,DtUg2EUg(1,1,k),&
8355 DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),&
8356 ADtEA1derx(1,1,1,1,1,2))
8358 ! End 6-th order cumulants
8359 call transpose2(EUgder(1,1,l),auxmat(1,1))
8360 call matmat2(auxmat(1,1),AEA(1,1,2),EAEAderg(1,1,1,2))
8361 call transpose2(EUg(1,1,l),auxmat(1,1))
8362 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
8363 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
8367 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
8368 EAEAderx(1,1,lll,kkk,iii,2))
8373 ! Calculate the vectors and their derivatives in virtual-bond dihedral angles.
8374 ! They are needed only when the fifth- or the sixth-order cumulants are
8376 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) THEN
8377 call transpose2(AEA(1,1,1),auxmat(1,1))
8378 call matvec2(auxmat(1,1),b1(1,iti),AEAb1(1,1,1))
8379 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
8380 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
8381 call transpose2(AEAderg(1,1,1),auxmat(1,1))
8382 call matvec2(auxmat(1,1),b1(1,iti),AEAb1derg(1,1,1))
8383 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
8384 call matvec2(AEA(1,1,1),b1(1,itk1),AEAb1(1,2,1))
8385 call matvec2(AEAderg(1,1,1),b1(1,itk1),AEAb1derg(1,2,1))
8386 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
8387 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
8388 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
8389 call transpose2(AEA(1,1,2),auxmat(1,1))
8390 call matvec2(auxmat(1,1),b1(1,itj),AEAb1(1,1,2))
8391 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2(1,1,2))
8392 call matvec2(auxmat(1,1),Ub2der(1,j),AEAb2derg(1,2,1,2))
8393 call transpose2(AEAderg(1,1,2),auxmat(1,1))
8394 call matvec2(auxmat(1,1),b1(1,itj),AEAb1derg(1,1,2))
8395 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2derg(1,1,1,2))
8396 call matvec2(AEA(1,1,2),b1(1,itl1),AEAb1(1,2,2))
8397 call matvec2(AEAderg(1,1,2),b1(1,itl1),AEAb1derg(1,2,2))
8398 call matvec2(AEA(1,1,2),Ub2(1,l+1),AEAb2(1,2,2))
8399 call matvec2(AEAderg(1,1,2),Ub2(1,l+1),AEAb2derg(1,1,2,2))
8400 call matvec2(AEA(1,1,2),Ub2der(1,l+1),AEAb2derg(1,2,2,2))
8401 ! Calculate the Cartesian derivatives of the vectors.
8405 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
8406 call matvec2(auxmat(1,1),b1(1,iti),&
8407 AEAb1derx(1,lll,kkk,iii,1,1))
8408 call matvec2(auxmat(1,1),Ub2(1,i),&
8409 AEAb2derx(1,lll,kkk,iii,1,1))
8410 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,itk1),&
8411 AEAb1derx(1,lll,kkk,iii,2,1))
8412 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),&
8413 AEAb2derx(1,lll,kkk,iii,2,1))
8414 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
8415 call matvec2(auxmat(1,1),b1(1,itj),&
8416 AEAb1derx(1,lll,kkk,iii,1,2))
8417 call matvec2(auxmat(1,1),Ub2(1,j),&
8418 AEAb2derx(1,lll,kkk,iii,1,2))
8419 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,itl1),&
8420 AEAb1derx(1,lll,kkk,iii,2,2))
8421 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,l+1),&
8422 AEAb2derx(1,lll,kkk,iii,2,2))
8429 ! Antiparallel orientation of the two CA-CA-CA frames.
8431 iti=itortyp(itype(i,1))
8435 itk1=itortyp(itype(k+1,1))
8436 itl=itortyp(itype(l,1))
8437 itj=itortyp(itype(j,1))
8438 if (j.lt.nres-1) then
8439 itj1=itortyp(itype(j+1,1))
8443 ! A2 kernel(j-1)T A1T
8444 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8445 aa2tder(1,1,1,1),1,.true.,EUg(1,1,j),EUgder(1,1,j),&
8446 AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
8447 ! Following matrices are needed only for 6-th order cumulants
8448 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and. &
8449 j.eq.i+4 .and. l.eq.i+3)) THEN
8450 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8451 aa2tder(1,1,1,1),1,.true.,EUgC(1,1,j),EUgCder(1,1,j),&
8452 AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
8453 call kernel(aa2(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8454 aa2tder(1,1,1,1),2,.true.,Ug2DtEUg(1,1,j),&
8455 Ug2DtEUgder(1,1,1,j),ADtEA(1,1,1),ADtEAderg(1,1,1,1),&
8456 ADtEAderx(1,1,1,1,1,1))
8457 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8458 aa2tder(1,1,1,1),2,.true.,DtUg2EUg(1,1,j),&
8459 DtUg2EUgder(1,1,1,j),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),&
8460 ADtEA1derx(1,1,1,1,1,1))
8462 ! End 6-th order cumulants
8463 call transpose2(EUgder(1,1,k),auxmat(1,1))
8464 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
8465 call transpose2(EUg(1,1,k),auxmat(1,1))
8466 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
8467 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
8471 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),&
8472 EAEAderx(1,1,lll,kkk,iii,1))
8476 ! A2T kernel(i+1)T A1
8477 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
8478 a_chuj_der(1,1,1,1,jj,i),1,.true.,EUg(1,1,k),EUgder(1,1,k),&
8479 AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
8480 ! Following matrices are needed only for 6-th order cumulants
8481 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and. &
8482 j.eq.i+4 .and. l.eq.i+3)) THEN
8483 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
8484 a_chuj_der(1,1,1,1,jj,i),1,.true.,EUgC(1,1,k),EUgCder(1,1,k),&
8485 AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
8486 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
8487 a_chuj_der(1,1,1,1,jj,i),2,.true.,Ug2DtEUg(1,1,k),&
8488 Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),&
8489 ADtEAderx(1,1,1,1,1,2))
8490 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
8491 a_chuj_der(1,1,1,1,jj,i),2,.true.,DtUg2EUg(1,1,k),&
8492 DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),&
8493 ADtEA1derx(1,1,1,1,1,2))
8495 ! End 6-th order cumulants
8496 call transpose2(EUgder(1,1,j),auxmat(1,1))
8497 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,2,2))
8498 call transpose2(EUg(1,1,j),auxmat(1,1))
8499 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
8500 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
8504 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
8505 EAEAderx(1,1,lll,kkk,iii,2))
8510 ! Calculate the vectors and their derivatives in virtual-bond dihedral angles.
8511 ! They are needed only when the fifth- or the sixth-order cumulants are
8513 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 .or. &
8514 (wturn6.gt.0.0d0 .and. j.eq.i+4 .and. l.eq.i+3)) THEN
8515 call transpose2(AEA(1,1,1),auxmat(1,1))
8516 call matvec2(auxmat(1,1),b1(1,iti),AEAb1(1,1,1))
8517 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
8518 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
8519 call transpose2(AEAderg(1,1,1),auxmat(1,1))
8520 call matvec2(auxmat(1,1),b1(1,iti),AEAb1derg(1,1,1))
8521 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
8522 call matvec2(AEA(1,1,1),b1(1,itk1),AEAb1(1,2,1))
8523 call matvec2(AEAderg(1,1,1),b1(1,itk1),AEAb1derg(1,2,1))
8524 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
8525 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
8526 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
8527 call transpose2(AEA(1,1,2),auxmat(1,1))
8528 call matvec2(auxmat(1,1),b1(1,itj1),AEAb1(1,1,2))
8529 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2(1,1,2))
8530 call matvec2(auxmat(1,1),Ub2der(1,l),AEAb2derg(1,2,1,2))
8531 call transpose2(AEAderg(1,1,2),auxmat(1,1))
8532 call matvec2(auxmat(1,1),b1(1,itl),AEAb1(1,1,2))
8533 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2derg(1,1,1,2))
8534 call matvec2(AEA(1,1,2),b1(1,itj1),AEAb1(1,2,2))
8535 call matvec2(AEAderg(1,1,2),b1(1,itj1),AEAb1derg(1,2,2))
8536 call matvec2(AEA(1,1,2),Ub2(1,j),AEAb2(1,2,2))
8537 call matvec2(AEAderg(1,1,2),Ub2(1,j),AEAb2derg(1,1,2,2))
8538 call matvec2(AEA(1,1,2),Ub2der(1,j),AEAb2derg(1,2,2,2))
8539 ! Calculate the Cartesian derivatives of the vectors.
8543 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
8544 call matvec2(auxmat(1,1),b1(1,iti),&
8545 AEAb1derx(1,lll,kkk,iii,1,1))
8546 call matvec2(auxmat(1,1),Ub2(1,i),&
8547 AEAb2derx(1,lll,kkk,iii,1,1))
8548 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,itk1),&
8549 AEAb1derx(1,lll,kkk,iii,2,1))
8550 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),&
8551 AEAb2derx(1,lll,kkk,iii,2,1))
8552 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
8553 call matvec2(auxmat(1,1),b1(1,itl),&
8554 AEAb1derx(1,lll,kkk,iii,1,2))
8555 call matvec2(auxmat(1,1),Ub2(1,l),&
8556 AEAb2derx(1,lll,kkk,iii,1,2))
8557 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,itj1),&
8558 AEAb1derx(1,lll,kkk,iii,2,2))
8559 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,j),&
8560 AEAb2derx(1,lll,kkk,iii,2,2))
8568 end subroutine calc_eello
8569 !-----------------------------------------------------------------------------
8570 subroutine kernel(aa1,aa2t,aa1derx,aa2tderx,nderg,transp,KK,KKderg,AKA,AKAderg,AKAderx)
8575 real(kind=8),dimension(2,2) :: aa1,aa2t,KK,AKA
8576 real(kind=8),dimension(2,2,3,5) :: aa1derx,aa2tderx
8577 real(kind=8),dimension(2,2,3,5,2) :: AKAderx
8578 real(kind=8),dimension(2,2,nderg) :: KKderg,AKAderg
8579 integer :: iii,kkk,lll
8582 !el common /kutas/ lprn
8583 call prodmat3(aa1(1,1),aa2t(1,1),KK(1,1),transp,AKA(1,1))
8585 call prodmat3(aa1(1,1),aa2t(1,1),KKderg(1,1,iii),transp,&
8588 !d if (lprn) write (2,*) 'In kernel'
8590 !d if (lprn) write (2,*) 'kkk=',kkk
8592 call prodmat3(aa1derx(1,1,lll,kkk),aa2t(1,1),&
8593 KK(1,1),transp,AKAderx(1,1,lll,kkk,1))
8595 !d write (2,*) 'lll=',lll
8596 !d write (2,*) 'iii=1'
8598 !d write (2,'(3(2f10.5),5x)')
8599 !d & (AKAderx(jjj,mmm,lll,kkk,1),mmm=1,2)
8602 call prodmat3(aa1(1,1),aa2tderx(1,1,lll,kkk),&
8603 KK(1,1),transp,AKAderx(1,1,lll,kkk,2))
8605 !d write (2,*) 'lll=',lll
8606 !d write (2,*) 'iii=2'
8608 !d write (2,'(3(2f10.5),5x)')
8609 !d & (AKAderx(jjj,mmm,lll,kkk,2),mmm=1,2)
8615 end subroutine kernel
8616 !-----------------------------------------------------------------------------
8617 real(kind=8) function eello4(i,j,k,l,jj,kk)
8618 ! implicit real*8 (a-h,o-z)
8619 ! include 'DIMENSIONS'
8620 ! include 'COMMON.IOUNITS'
8621 ! include 'COMMON.CHAIN'
8622 ! include 'COMMON.DERIV'
8623 ! include 'COMMON.INTERACT'
8624 ! include 'COMMON.CONTACTS'
8625 ! include 'COMMON.TORSION'
8626 ! include 'COMMON.VAR'
8627 ! include 'COMMON.GEO'
8628 real(kind=8),dimension(2,2) :: pizda
8629 real(kind=8),dimension(3) :: ggg1,ggg2
8630 real(kind=8) :: eel4,glongij,glongkl
8631 integer :: i,j,k,l,jj,kk,iii,kkk,lll,j1,j2,l1,l2,ll
8632 !d if (i.ne.1 .or. j.ne.5 .or. k.ne.2 .or.l.ne.4) then
8636 !d print *,'eello4:',i,j,k,l,jj,kk
8637 !d write (2,*) 'i',i,' j',j,' k',k,' l',l
8638 !d call checkint4(i,j,k,l,jj,kk,eel4_num)
8639 !old eij=facont_hb(jj,i)
8640 !old ekl=facont_hb(kk,k)
8642 eel4=-EAEA(1,1,1)-EAEA(2,2,1)
8643 !d eel41=-EAEA(1,1,2)-EAEA(2,2,2)
8644 gcorr_loc(k-1)=gcorr_loc(k-1) &
8645 -ekont*(EAEAderg(1,1,1,1)+EAEAderg(2,2,1,1))
8647 gcorr_loc(l-1)=gcorr_loc(l-1) &
8648 -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
8650 gcorr_loc(j-1)=gcorr_loc(j-1) &
8651 -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
8656 derx(lll,kkk,iii)=-EAEAderx(1,1,lll,kkk,iii,1) &
8657 -EAEAderx(2,2,lll,kkk,iii,1)
8658 !d derx(lll,kkk,iii)=0.0d0
8662 !d gcorr_loc(l-1)=0.0d0
8663 !d gcorr_loc(j-1)=0.0d0
8664 !d gcorr_loc(k-1)=0.0d0
8666 !d write (iout,*)'Contacts have occurred for peptide groups',
8667 !d & i,j,' fcont:',eij,' eij',' and ',k,l,
8668 !d & ' fcont ',ekl,' eel4=',eel4,' eel4_num',16*eel4_num
8669 if (j.lt.nres-1) then
8676 if (l.lt.nres-1) then
8684 !grad ggg1(ll)=eel4*g_contij(ll,1)
8685 !grad ggg2(ll)=eel4*g_contij(ll,2)
8686 glongij=eel4*g_contij(ll,1)+ekont*derx(ll,1,1)
8687 glongkl=eel4*g_contij(ll,2)+ekont*derx(ll,1,2)
8688 !grad ghalf=0.5d0*ggg1(ll)
8689 gradcorr(ll,i)=gradcorr(ll,i)+ekont*derx(ll,2,1)
8690 gradcorr(ll,i+1)=gradcorr(ll,i+1)+ekont*derx(ll,3,1)
8691 gradcorr(ll,j)=gradcorr(ll,j)+ekont*derx(ll,4,1)
8692 gradcorr(ll,j1)=gradcorr(ll,j1)+ekont*derx(ll,5,1)
8693 gradcorr_long(ll,j)=gradcorr_long(ll,j)+glongij
8694 gradcorr_long(ll,i)=gradcorr_long(ll,i)-glongij
8695 !grad ghalf=0.5d0*ggg2(ll)
8696 gradcorr(ll,k)=gradcorr(ll,k)+ekont*derx(ll,2,2)
8697 gradcorr(ll,k+1)=gradcorr(ll,k+1)+ekont*derx(ll,3,2)
8698 gradcorr(ll,l)=gradcorr(ll,l)+ekont*derx(ll,4,2)
8699 gradcorr(ll,l1)=gradcorr(ll,l1)+ekont*derx(ll,5,2)
8700 gradcorr_long(ll,l)=gradcorr_long(ll,l)+glongkl
8701 gradcorr_long(ll,k)=gradcorr_long(ll,k)-glongkl
8705 !grad gradcorr(ll,m)=gradcorr(ll,m)+ggg1(ll)
8710 !grad gradcorr(ll,m)=gradcorr(ll,m)+ggg2(ll)
8715 !grad gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,1)
8720 !grad gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,2)
8724 !d write (2,*) iii,gcorr_loc(iii)
8727 !d write (2,*) 'ekont',ekont
8728 !d write (iout,*) 'eello4',ekont*eel4
8731 !-----------------------------------------------------------------------------
8732 real(kind=8) function eello5(i,j,k,l,jj,kk)
8733 ! implicit real*8 (a-h,o-z)
8734 ! include 'DIMENSIONS'
8735 ! include 'COMMON.IOUNITS'
8736 ! include 'COMMON.CHAIN'
8737 ! include 'COMMON.DERIV'
8738 ! include 'COMMON.INTERACT'
8739 ! include 'COMMON.CONTACTS'
8740 ! include 'COMMON.TORSION'
8741 ! include 'COMMON.VAR'
8742 ! include 'COMMON.GEO'
8743 real(kind=8),dimension(2,2) :: pizda,auxmat,auxmat1
8744 real(kind=8),dimension(2) :: vv
8745 real(kind=8),dimension(3) :: ggg1,ggg2
8746 real(kind=8) :: eello5_1,eello5_2,eello5_3,eello5_4,eel5
8747 real(kind=8) :: gradcorr5ij,gradcorr5kl,ghalf
8748 integer :: i,j,k,l,jj,kk,itk,itl,itj,iii,kkk,lll,j1,j2,l1,l2,ll
8749 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8754 ! /l\ / \ \ / \ / \ / C
8755 ! / \ / \ \ / \ / \ / C
8756 ! j| o |l1 | o | o| o | | o |o C
8757 ! \ |/k\| |/ \| / |/ \| |/ \| C
8758 ! \i/ \ / \ / / \ / \ C
8760 ! (I) (II) (III) (IV) C
8762 ! eello5_1 eello5_2 eello5_3 eello5_4 C
8764 ! Antiparallel chains C
8767 ! /j\ / \ \ / \ / \ / C
8768 ! / \ / \ \ / \ / \ / C
8769 ! j1| o |l | o | o| o | | o |o C
8770 ! \ |/k\| |/ \| / |/ \| |/ \| C
8771 ! \i/ \ / \ / / \ / \ C
8773 ! (I) (II) (III) (IV) C
8775 ! eello5_1 eello5_2 eello5_3 eello5_4 C
8777 ! o denotes a local interaction, vertical lines an electrostatic interaction. C
8779 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8780 !d if (i.ne.2 .or. j.ne.6 .or. k.ne.3 .or. l.ne.5) then
8785 !d & 'EELLO5: Contacts have occurred for peptide groups',i,j,
8787 itk=itortyp(itype(k,1))
8788 itl=itortyp(itype(l,1))
8789 itj=itortyp(itype(j,1))
8794 !d call checkint5(i,j,k,l,jj,kk,eel5_1_num,eel5_2_num,
8795 !d & eel5_3_num,eel5_4_num)
8799 derx(lll,kkk,iii)=0.0d0
8803 !d eij=facont_hb(jj,i)
8804 !d ekl=facont_hb(kk,k)
8806 !d write (iout,*)'Contacts have occurred for peptide groups',
8807 !d & i,j,' fcont:',eij,' eij',' and ',k,l
8809 ! Contribution from the graph I.
8810 !d write (2,*) 'AEA ',AEA(1,1,1),AEA(2,1,1),AEA(1,2,1),AEA(2,2,1)
8811 !d write (2,*) 'AEAb2',AEAb2(1,1,1),AEAb2(2,1,1)
8812 call transpose2(EUg(1,1,k),auxmat(1,1))
8813 call matmat2(AEA(1,1,1),auxmat(1,1),pizda(1,1))
8814 vv(1)=pizda(1,1)-pizda(2,2)
8815 vv(2)=pizda(1,2)+pizda(2,1)
8816 eello5_1=scalar2(AEAb2(1,1,1),Ub2(1,k)) &
8817 +0.5d0*scalar2(vv(1),Dtobr2(1,i))
8818 ! Explicit gradient in virtual-dihedral angles.
8819 if (i.gt.1) g_corr5_loc(i-1)=g_corr5_loc(i-1) &
8820 +ekont*(scalar2(AEAb2derg(1,2,1,1),Ub2(1,k)) &
8821 +0.5d0*scalar2(vv(1),Dtobr2der(1,i)))
8822 call transpose2(EUgder(1,1,k),auxmat1(1,1))
8823 call matmat2(AEA(1,1,1),auxmat1(1,1),pizda(1,1))
8824 vv(1)=pizda(1,1)-pizda(2,2)
8825 vv(2)=pizda(1,2)+pizda(2,1)
8826 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
8827 +ekont*(scalar2(AEAb2(1,1,1),Ub2der(1,k)) &
8828 +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
8829 call matmat2(AEAderg(1,1,1),auxmat(1,1),pizda(1,1))
8830 vv(1)=pizda(1,1)-pizda(2,2)
8831 vv(2)=pizda(1,2)+pizda(2,1)
8833 if (l.lt.nres-1) g_corr5_loc(l-1)=g_corr5_loc(l-1) &
8834 +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k)) &
8835 +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
8837 if (j.lt.nres-1) g_corr5_loc(j-1)=g_corr5_loc(j-1) &
8838 +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k)) &
8839 +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
8841 ! Cartesian gradient
8845 call matmat2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1),&
8847 vv(1)=pizda(1,1)-pizda(2,2)
8848 vv(2)=pizda(1,2)+pizda(2,1)
8849 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
8850 +scalar2(AEAb2derx(1,lll,kkk,iii,1,1),Ub2(1,k)) &
8851 +0.5d0*scalar2(vv(1),Dtobr2(1,i))
8857 ! Contribution from graph II
8858 call transpose2(EE(1,1,itk),auxmat(1,1))
8859 call matmat2(auxmat(1,1),AEA(1,1,1),pizda(1,1))
8860 vv(1)=pizda(1,1)+pizda(2,2)
8861 vv(2)=pizda(2,1)-pizda(1,2)
8862 eello5_2=scalar2(AEAb1(1,2,1),b1(1,itk)) &
8863 -0.5d0*scalar2(vv(1),Ctobr(1,k))
8864 ! Explicit gradient in virtual-dihedral angles.
8865 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
8866 -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,k))
8867 call matmat2(auxmat(1,1),AEAderg(1,1,1),pizda(1,1))
8868 vv(1)=pizda(1,1)+pizda(2,2)
8869 vv(2)=pizda(2,1)-pizda(1,2)
8871 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
8872 +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,itk)) &
8873 -0.5d0*scalar2(vv(1),Ctobr(1,k)))
8875 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
8876 +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,itk)) &
8877 -0.5d0*scalar2(vv(1),Ctobr(1,k)))
8879 ! Cartesian gradient
8883 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),&
8885 vv(1)=pizda(1,1)+pizda(2,2)
8886 vv(2)=pizda(2,1)-pizda(1,2)
8887 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
8888 +scalar2(AEAb1derx(1,lll,kkk,iii,2,1),b1(1,itk)) &
8889 -0.5d0*scalar2(vv(1),Ctobr(1,k))
8897 ! Parallel orientation
8898 ! Contribution from graph III
8899 call transpose2(EUg(1,1,l),auxmat(1,1))
8900 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
8901 vv(1)=pizda(1,1)-pizda(2,2)
8902 vv(2)=pizda(1,2)+pizda(2,1)
8903 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,l)) &
8904 +0.5d0*scalar2(vv(1),Dtobr2(1,j))
8905 ! Explicit gradient in virtual-dihedral angles.
8906 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
8907 +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,l)) &
8908 +0.5d0*scalar2(vv(1),Dtobr2der(1,j)))
8909 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
8910 vv(1)=pizda(1,1)-pizda(2,2)
8911 vv(2)=pizda(1,2)+pizda(2,1)
8912 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
8913 +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,l)) &
8914 +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
8915 call transpose2(EUgder(1,1,l),auxmat1(1,1))
8916 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
8917 vv(1)=pizda(1,1)-pizda(2,2)
8918 vv(2)=pizda(1,2)+pizda(2,1)
8919 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
8920 +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,l)) &
8921 +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
8922 ! Cartesian gradient
8926 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),&
8928 vv(1)=pizda(1,1)-pizda(2,2)
8929 vv(2)=pizda(1,2)+pizda(2,1)
8930 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
8931 +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,l)) &
8932 +0.5d0*scalar2(vv(1),Dtobr2(1,j))
8937 ! Contribution from graph IV
8939 call transpose2(EE(1,1,itl),auxmat(1,1))
8940 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
8941 vv(1)=pizda(1,1)+pizda(2,2)
8942 vv(2)=pizda(2,1)-pizda(1,2)
8943 eello5_4=scalar2(AEAb1(1,2,2),b1(1,itl)) &
8944 -0.5d0*scalar2(vv(1),Ctobr(1,l))
8945 ! Explicit gradient in virtual-dihedral angles.
8946 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
8947 -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,l))
8948 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
8949 vv(1)=pizda(1,1)+pizda(2,2)
8950 vv(2)=pizda(2,1)-pizda(1,2)
8951 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
8952 +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,itl)) &
8953 -0.5d0*scalar2(vv(1),Ctobr(1,l)))
8954 ! Cartesian gradient
8958 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
8960 vv(1)=pizda(1,1)+pizda(2,2)
8961 vv(2)=pizda(2,1)-pizda(1,2)
8962 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
8963 +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,itl)) &
8964 -0.5d0*scalar2(vv(1),Ctobr(1,l))
8969 ! Antiparallel orientation
8970 ! Contribution from graph III
8972 call transpose2(EUg(1,1,j),auxmat(1,1))
8973 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
8974 vv(1)=pizda(1,1)-pizda(2,2)
8975 vv(2)=pizda(1,2)+pizda(2,1)
8976 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,j)) &
8977 +0.5d0*scalar2(vv(1),Dtobr2(1,l))
8978 ! Explicit gradient in virtual-dihedral angles.
8979 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
8980 +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,j)) &
8981 +0.5d0*scalar2(vv(1),Dtobr2der(1,l)))
8982 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
8983 vv(1)=pizda(1,1)-pizda(2,2)
8984 vv(2)=pizda(1,2)+pizda(2,1)
8985 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
8986 +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,j)) &
8987 +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
8988 call transpose2(EUgder(1,1,j),auxmat1(1,1))
8989 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
8990 vv(1)=pizda(1,1)-pizda(2,2)
8991 vv(2)=pizda(1,2)+pizda(2,1)
8992 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
8993 +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,j)) &
8994 +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
8995 ! Cartesian gradient
8999 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),&
9001 vv(1)=pizda(1,1)-pizda(2,2)
9002 vv(2)=pizda(1,2)+pizda(2,1)
9003 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii) &
9004 +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,j)) &
9005 +0.5d0*scalar2(vv(1),Dtobr2(1,l))
9010 ! Contribution from graph IV
9012 call transpose2(EE(1,1,itj),auxmat(1,1))
9013 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
9014 vv(1)=pizda(1,1)+pizda(2,2)
9015 vv(2)=pizda(2,1)-pizda(1,2)
9016 eello5_4=scalar2(AEAb1(1,2,2),b1(1,itj)) &
9017 -0.5d0*scalar2(vv(1),Ctobr(1,j))
9018 ! Explicit gradient in virtual-dihedral angles.
9019 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
9020 -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,j))
9021 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
9022 vv(1)=pizda(1,1)+pizda(2,2)
9023 vv(2)=pizda(2,1)-pizda(1,2)
9024 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
9025 +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,itj)) &
9026 -0.5d0*scalar2(vv(1),Ctobr(1,j)))
9027 ! Cartesian gradient
9031 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
9033 vv(1)=pizda(1,1)+pizda(2,2)
9034 vv(2)=pizda(2,1)-pizda(1,2)
9035 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii) &
9036 +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,itj)) &
9037 -0.5d0*scalar2(vv(1),Ctobr(1,j))
9043 eel5=eello5_1+eello5_2+eello5_3+eello5_4
9044 !d if (i.eq.2 .and. j.eq.8 .and. k.eq.3 .and. l.eq.7) then
9045 !d write (2,*) 'ijkl',i,j,k,l
9046 !d write (2,*) 'eello5_1',eello5_1,' eello5_2',eello5_2,
9047 !d & ' eello5_3',eello5_3,' eello5_4',eello5_4
9049 !d write(iout,*) 'eello5_1',eello5_1,' eel5_1_num',16*eel5_1_num
9050 !d write(iout,*) 'eello5_2',eello5_2,' eel5_2_num',16*eel5_2_num
9051 !d write(iout,*) 'eello5_3',eello5_3,' eel5_3_num',16*eel5_3_num
9052 !d write(iout,*) 'eello5_4',eello5_4,' eel5_4_num',16*eel5_4_num
9053 if (j.lt.nres-1) then
9060 if (l.lt.nres-1) then
9070 !d write (2,*) 'eij',eij,' ekl',ekl,' ekont',ekont
9071 ! 2/11/08 AL Gradients over DC's connecting interacting sites will be
9072 ! summed up outside the subrouine as for the other subroutines
9073 ! handling long-range interactions. The old code is commented out
9074 ! with "cgrad" to keep track of changes.
9076 !grad ggg1(ll)=eel5*g_contij(ll,1)
9077 !grad ggg2(ll)=eel5*g_contij(ll,2)
9078 gradcorr5ij=eel5*g_contij(ll,1)+ekont*derx(ll,1,1)
9079 gradcorr5kl=eel5*g_contij(ll,2)+ekont*derx(ll,1,2)
9080 ! write (iout,'(a,3i3,a,5f8.3,2i3,a,5f8.3,a,f8.3)')
9081 ! & "ecorr5",ll,i,j," derx",derx(ll,2,1),derx(ll,3,1),derx(ll,4,1),
9082 ! & derx(ll,5,1),k,l," derx",derx(ll,2,2),derx(ll,3,2),
9083 ! & derx(ll,4,2),derx(ll,5,2)," ekont",ekont
9084 ! write (iout,'(a,3i3,a,3f8.3,2i3,a,3f8.3)')
9085 ! & "ecorr5",ll,i,j," gradcorr5",g_contij(ll,1),derx(ll,1,1),
9087 ! & k,l," gradcorr5",g_contij(ll,2),derx(ll,1,2),gradcorr5kl
9088 !old ghalf=0.5d0*eel5*ekl*gacont_hbr(ll,jj,i)
9089 !grad ghalf=0.5d0*ggg1(ll)
9091 gradcorr5(ll,i)=gradcorr5(ll,i)+ekont*derx(ll,2,1)
9092 gradcorr5(ll,i+1)=gradcorr5(ll,i+1)+ekont*derx(ll,3,1)
9093 gradcorr5(ll,j)=gradcorr5(ll,j)+ekont*derx(ll,4,1)
9094 gradcorr5(ll,j1)=gradcorr5(ll,j1)+ekont*derx(ll,5,1)
9095 gradcorr5_long(ll,j)=gradcorr5_long(ll,j)+gradcorr5ij
9096 gradcorr5_long(ll,i)=gradcorr5_long(ll,i)-gradcorr5ij
9097 !old ghalf=0.5d0*eel5*eij*gacont_hbr(ll,kk,k)
9098 !grad ghalf=0.5d0*ggg2(ll)
9100 gradcorr5(ll,k)=gradcorr5(ll,k)+ghalf+ekont*derx(ll,2,2)
9101 gradcorr5(ll,k+1)=gradcorr5(ll,k+1)+ekont*derx(ll,3,2)
9102 gradcorr5(ll,l)=gradcorr5(ll,l)+ghalf+ekont*derx(ll,4,2)
9103 gradcorr5(ll,l1)=gradcorr5(ll,l1)+ekont*derx(ll,5,2)
9104 gradcorr5_long(ll,l)=gradcorr5_long(ll,l)+gradcorr5kl
9105 gradcorr5_long(ll,k)=gradcorr5_long(ll,k)-gradcorr5kl
9110 !old gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*ekl*gacont_hbr(ll,jj,i)
9111 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ggg1(ll)
9116 !old gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*eij*gacont_hbr(ll,kk,k)
9117 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ggg2(ll)
9123 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,1)
9128 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,2)
9132 !d write (2,*) iii,g_corr5_loc(iii)
9135 !d write (2,*) 'ekont',ekont
9136 !d write (iout,*) 'eello5',ekont*eel5
9139 !-----------------------------------------------------------------------------
9140 real(kind=8) function eello6(i,j,k,l,jj,kk)
9141 ! implicit real*8 (a-h,o-z)
9142 ! include 'DIMENSIONS'
9143 ! include 'COMMON.IOUNITS'
9144 ! include 'COMMON.CHAIN'
9145 ! include 'COMMON.DERIV'
9146 ! include 'COMMON.INTERACT'
9147 ! include 'COMMON.CONTACTS'
9148 ! include 'COMMON.TORSION'
9149 ! include 'COMMON.VAR'
9150 ! include 'COMMON.GEO'
9151 ! include 'COMMON.FFIELD'
9152 real(kind=8),dimension(3) :: ggg1,ggg2
9153 real(kind=8) :: eello6_1,eello6_2,eello6_3,eello6_4,eello6_5,&
9155 real(kind=8) :: gradcorr6ij,gradcorr6kl
9156 integer :: i,j,k,l,jj,kk,iii,kkk,lll,j1,j2,l1,l2,ll
9157 !d if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
9162 !d & 'EELLO6: Contacts have occurred for peptide groups',i,j,
9170 !d call checkint6(i,j,k,l,jj,kk,eel6_1_num,eel6_2_num,
9171 !d & eel6_3_num,eel6_4_num,eel6_5_num,eel6_6_num)
9175 derx(lll,kkk,iii)=0.0d0
9179 !d eij=facont_hb(jj,i)
9180 !d ekl=facont_hb(kk,k)
9186 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
9187 eello6_2=eello6_graph1(j,i,l,k,2,.false.)
9188 eello6_3=eello6_graph2(i,j,k,l,jj,kk,.false.)
9189 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
9190 eello6_5=eello6_graph4(j,i,l,k,jj,kk,2,.false.)
9191 eello6_6=eello6_graph3(i,j,k,l,jj,kk,.false.)
9193 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
9194 eello6_2=eello6_graph1(l,k,j,i,2,.true.)
9195 eello6_3=eello6_graph2(i,l,k,j,jj,kk,.true.)
9196 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
9197 if (wturn6.eq.0.0d0 .or. j.ne.i+4) then
9198 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
9202 eello6_6=eello6_graph3(i,l,k,j,jj,kk,.true.)
9204 ! If turn contributions are considered, they will be handled separately.
9205 eel6=eello6_1+eello6_2+eello6_3+eello6_4+eello6_5+eello6_6
9206 !d write(iout,*) 'eello6_1',eello6_1!,' eel6_1_num',16*eel6_1_num
9207 !d write(iout,*) 'eello6_2',eello6_2!,' eel6_2_num',16*eel6_2_num
9208 !d write(iout,*) 'eello6_3',eello6_3!,' eel6_3_num',16*eel6_3_num
9209 !d write(iout,*) 'eello6_4',eello6_4!,' eel6_4_num',16*eel6_4_num
9210 !d write(iout,*) 'eello6_5',eello6_5!,' eel6_5_num',16*eel6_5_num
9211 !d write(iout,*) 'eello6_6',eello6_6!,' eel6_6_num',16*eel6_6_num
9213 if (j.lt.nres-1) then
9220 if (l.lt.nres-1) then
9228 !grad ggg1(ll)=eel6*g_contij(ll,1)
9229 !grad ggg2(ll)=eel6*g_contij(ll,2)
9230 !old ghalf=0.5d0*eel6*ekl*gacont_hbr(ll,jj,i)
9231 !grad ghalf=0.5d0*ggg1(ll)
9233 gradcorr6ij=eel6*g_contij(ll,1)+ekont*derx(ll,1,1)
9234 gradcorr6kl=eel6*g_contij(ll,2)+ekont*derx(ll,1,2)
9235 gradcorr6(ll,i)=gradcorr6(ll,i)+ekont*derx(ll,2,1)
9236 gradcorr6(ll,i+1)=gradcorr6(ll,i+1)+ekont*derx(ll,3,1)
9237 gradcorr6(ll,j)=gradcorr6(ll,j)+ekont*derx(ll,4,1)
9238 gradcorr6(ll,j1)=gradcorr6(ll,j1)+ekont*derx(ll,5,1)
9239 gradcorr6_long(ll,j)=gradcorr6_long(ll,j)+gradcorr6ij
9240 gradcorr6_long(ll,i)=gradcorr6_long(ll,i)-gradcorr6ij
9241 !grad ghalf=0.5d0*ggg2(ll)
9242 !old ghalf=0.5d0*eel6*eij*gacont_hbr(ll,kk,k)
9244 gradcorr6(ll,k)=gradcorr6(ll,k)+ekont*derx(ll,2,2)
9245 gradcorr6(ll,k+1)=gradcorr6(ll,k+1)+ekont*derx(ll,3,2)
9246 gradcorr6(ll,l)=gradcorr6(ll,l)+ekont*derx(ll,4,2)
9247 gradcorr6(ll,l1)=gradcorr6(ll,l1)+ekont*derx(ll,5,2)
9248 gradcorr6_long(ll,l)=gradcorr6_long(ll,l)+gradcorr6kl
9249 gradcorr6_long(ll,k)=gradcorr6_long(ll,k)-gradcorr6kl
9254 !old gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*ekl*gacont_hbr(ll,jj,i)
9255 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ggg1(ll)
9260 !old gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*eij*gacont_hbr(ll,kk,k)
9261 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ggg2(ll)
9267 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,1)
9272 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,2)
9276 !d write (2,*) iii,g_corr6_loc(iii)
9279 !d write (2,*) 'ekont',ekont
9280 !d write (iout,*) 'eello6',ekont*eel6
9283 !-----------------------------------------------------------------------------
9284 real(kind=8) function eello6_graph1(i,j,k,l,imat,swap)
9286 ! implicit real*8 (a-h,o-z)
9287 ! include 'DIMENSIONS'
9288 ! include 'COMMON.IOUNITS'
9289 ! include 'COMMON.CHAIN'
9290 ! include 'COMMON.DERIV'
9291 ! include 'COMMON.INTERACT'
9292 ! include 'COMMON.CONTACTS'
9293 ! include 'COMMON.TORSION'
9294 ! include 'COMMON.VAR'
9295 ! include 'COMMON.GEO'
9296 real(kind=8),dimension(2) :: vv,vv1
9297 real(kind=8),dimension(2,2) :: pizda,auxmat,pizda1
9300 !el common /kutas/ lprn
9301 integer :: i,j,k,l,imat,itk,iii,kkk,lll,ind
9302 real(kind=8) :: s1,s2,s3,s4,s5
9303 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9305 ! Parallel Antiparallel C
9311 ! \ j|/k\| / \ |/k\|l / C
9316 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9317 itk=itortyp(itype(k,1))
9318 s1= scalar2(AEAb1(1,2,imat),CUgb2(1,i))
9319 s2=-scalar2(AEAb2(1,1,imat),Ug2Db1t(1,k))
9320 s3= scalar2(AEAb2(1,1,imat),CUgb2(1,k))
9321 call transpose2(EUgC(1,1,k),auxmat(1,1))
9322 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
9323 vv1(1)=pizda1(1,1)-pizda1(2,2)
9324 vv1(2)=pizda1(1,2)+pizda1(2,1)
9325 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
9326 vv(1)=AEAb1(1,2,imat)*b1(1,itk)-AEAb1(2,2,imat)*b1(2,itk)
9327 vv(2)=AEAb1(1,2,imat)*b1(2,itk)+AEAb1(2,2,imat)*b1(1,itk)
9328 s5=scalar2(vv(1),Dtobr2(1,i))
9329 !d write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4', s4,' s5',s5
9330 eello6_graph1=-0.5d0*(s1+s2+s3+s4+s5)
9331 if (i.gt.1) g_corr6_loc(i-1)=g_corr6_loc(i-1) &
9332 -0.5d0*ekont*(scalar2(AEAb1(1,2,imat),CUgb2der(1,i)) &
9333 -scalar2(AEAb2derg(1,2,1,imat),Ug2Db1t(1,k)) &
9334 +scalar2(AEAb2derg(1,2,1,imat),CUgb2(1,k)) &
9335 +0.5d0*scalar2(vv1(1),Dtobr2der(1,i)) &
9336 +scalar2(vv(1),Dtobr2der(1,i)))
9337 call matmat2(AEAderg(1,1,imat),auxmat(1,1),pizda1(1,1))
9338 vv1(1)=pizda1(1,1)-pizda1(2,2)
9339 vv1(2)=pizda1(1,2)+pizda1(2,1)
9340 vv(1)=AEAb1derg(1,2,imat)*b1(1,itk)-AEAb1derg(2,2,imat)*b1(2,itk)
9341 vv(2)=AEAb1derg(1,2,imat)*b1(2,itk)+AEAb1derg(2,2,imat)*b1(1,itk)
9343 g_corr6_loc(l-1)=g_corr6_loc(l-1) &
9344 +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i)) &
9345 -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k)) &
9346 +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k)) &
9347 +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
9349 g_corr6_loc(j-1)=g_corr6_loc(j-1) &
9350 +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i)) &
9351 -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k)) &
9352 +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k)) &
9353 +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
9355 call transpose2(EUgCder(1,1,k),auxmat(1,1))
9356 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
9357 vv1(1)=pizda1(1,1)-pizda1(2,2)
9358 vv1(2)=pizda1(1,2)+pizda1(2,1)
9359 if (k.gt.1) g_corr6_loc(k-1)=g_corr6_loc(k-1) &
9360 +ekont*(-0.5d0*(-scalar2(AEAb2(1,1,imat),Ug2Db1tder(1,k)) &
9361 +scalar2(AEAb2(1,1,imat),CUgb2der(1,k)) &
9362 +0.5d0*scalar2(vv1(1),Dtobr2(1,i))))
9371 s1= scalar2(AEAb1derx(1,lll,kkk,iii,2,imat),CUgb2(1,i))
9372 s2=-scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),Ug2Db1t(1,k))
9373 s3= scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),CUgb2(1,k))
9374 call transpose2(EUgC(1,1,k),auxmat(1,1))
9375 call matmat2(AEAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),&
9377 vv1(1)=pizda1(1,1)-pizda1(2,2)
9378 vv1(2)=pizda1(1,2)+pizda1(2,1)
9379 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
9380 vv(1)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(1,itk) &
9381 -AEAb1derx(2,lll,kkk,iii,2,imat)*b1(2,itk)
9382 vv(2)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(2,itk) &
9383 +AEAb1derx(2,lll,kkk,iii,2,imat)*b1(1,itk)
9384 s5=scalar2(vv(1),Dtobr2(1,i))
9385 derx(lll,kkk,ind)=derx(lll,kkk,ind)-0.5d0*(s1+s2+s3+s4+s5)
9390 end function eello6_graph1
9391 !-----------------------------------------------------------------------------
9392 real(kind=8) function eello6_graph2(i,j,k,l,jj,kk,swap)
9394 ! implicit real*8 (a-h,o-z)
9395 ! include 'DIMENSIONS'
9396 ! include 'COMMON.IOUNITS'
9397 ! include 'COMMON.CHAIN'
9398 ! include 'COMMON.DERIV'
9399 ! include 'COMMON.INTERACT'
9400 ! include 'COMMON.CONTACTS'
9401 ! include 'COMMON.TORSION'
9402 ! include 'COMMON.VAR'
9403 ! include 'COMMON.GEO'
9405 real(kind=8),dimension(2) :: vv,auxvec,auxvec1,auxvec2
9406 real(kind=8),dimension(2,2) :: pizda,auxmat,auxmat1
9408 !el common /kutas/ lprn
9409 integer :: i,j,k,l,jj,kk,iii,kkk,lll,jjj,mmm
9410 real(kind=8) :: s2,s3,s4
9411 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9413 ! Parallel Antiparallel C
9419 ! \ j|/k\| \ |/k\|l C
9424 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9425 !d write (2,*) 'eello6_graph2: i,',i,' j',j,' k',k,' l',l
9426 ! AL 7/4/01 s1 would occur in the sixth-order moment,
9427 ! but not in a cluster cumulant
9429 s1=dip(1,jj,i)*dip(1,kk,k)
9431 call matvec2(ADtEA1(1,1,1),Ub2(1,k),auxvec(1))
9432 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
9433 call matvec2(ADtEA(1,1,2),Ub2(1,l),auxvec1(1))
9434 s3=-0.5d0*scalar2(Ub2(1,j),auxvec1(1))
9435 call transpose2(EUg(1,1,k),auxmat(1,1))
9436 call matmat2(ADtEA1(1,1,1),auxmat(1,1),pizda(1,1))
9437 vv(1)=pizda(1,1)-pizda(2,2)
9438 vv(2)=pizda(1,2)+pizda(2,1)
9439 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9440 !d write (2,*) 'eello6_graph2:','s1',s1,' s2',s2,' s3',s3,' s4',s4
9442 eello6_graph2=-(s1+s2+s3+s4)
9444 eello6_graph2=-(s2+s3+s4)
9447 ! Derivatives in gamma(i-1)
9450 s1=dipderg(1,jj,i)*dip(1,kk,k)
9452 s2=-0.5d0*scalar2(Ub2der(1,i),auxvec(1))
9453 call matvec2(ADtEAderg(1,1,1,2),Ub2(1,l),auxvec2(1))
9454 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
9455 s4=-0.25d0*scalar2(vv(1),Dtobr2der(1,i))
9457 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
9459 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
9461 ! g_corr6_loc(i-1)=g_corr6_loc(i-1)-s3
9463 ! Derivatives in gamma(k-1)
9465 s1=dip(1,jj,i)*dipderg(1,kk,k)
9467 call matvec2(ADtEA1(1,1,1),Ub2der(1,k),auxvec2(1))
9468 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
9469 call matvec2(ADtEAderg(1,1,2,2),Ub2(1,l),auxvec2(1))
9470 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
9471 call transpose2(EUgder(1,1,k),auxmat1(1,1))
9472 call matmat2(ADtEA1(1,1,1),auxmat1(1,1),pizda(1,1))
9473 vv(1)=pizda(1,1)-pizda(2,2)
9474 vv(2)=pizda(1,2)+pizda(2,1)
9475 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9477 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
9479 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
9481 ! g_corr6_loc(k-1)=g_corr6_loc(k-1)-s3
9482 ! Derivatives in gamma(j-1) or gamma(l-1)
9485 s1=dipderg(3,jj,i)*dip(1,kk,k)
9487 call matvec2(ADtEA1derg(1,1,1,1),Ub2(1,k),auxvec2(1))
9488 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
9489 s3=-0.5d0*scalar2(Ub2der(1,j),auxvec1(1))
9490 call matmat2(ADtEA1derg(1,1,1,1),auxmat(1,1),pizda(1,1))
9491 vv(1)=pizda(1,1)-pizda(2,2)
9492 vv(2)=pizda(1,2)+pizda(2,1)
9493 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9496 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
9498 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
9501 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s3+s4)
9502 ! g_corr6_loc(j-1)=g_corr6_loc(j-1)-s3
9504 ! Derivatives in gamma(l-1) or gamma(j-1)
9507 s1=dip(1,jj,i)*dipderg(3,kk,k)
9509 call matvec2(ADtEA1derg(1,1,2,1),Ub2(1,k),auxvec2(1))
9510 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
9511 call matvec2(ADtEA(1,1,2),Ub2der(1,l),auxvec2(1))
9512 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
9513 call matmat2(ADtEA1derg(1,1,2,1),auxmat(1,1),pizda(1,1))
9514 vv(1)=pizda(1,1)-pizda(2,2)
9515 vv(2)=pizda(1,2)+pizda(2,1)
9516 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9519 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
9521 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
9524 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s3+s4)
9525 ! g_corr6_loc(l-1)=g_corr6_loc(l-1)-s3
9527 ! Cartesian derivatives.
9529 write (2,*) 'In eello6_graph2'
9531 write (2,*) 'iii=',iii
9533 write (2,*) 'kkk=',kkk
9535 write (2,'(3(2f10.5),5x)') &
9536 ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
9546 s1=dipderx(lll,kkk,1,jj,i)*dip(1,kk,k)
9548 s1=dip(1,jj,i)*dipderx(lll,kkk,1,kk,k)
9551 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,1),Ub2(1,k),&
9553 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
9554 call matvec2(ADtEAderx(1,1,lll,kkk,iii,2),Ub2(1,l),&
9556 s3=-0.5d0*scalar2(Ub2(1,j),auxvec(1))
9557 call transpose2(EUg(1,1,k),auxmat(1,1))
9558 call matmat2(ADtEA1derx(1,1,lll,kkk,iii,1),auxmat(1,1),&
9560 vv(1)=pizda(1,1)-pizda(2,2)
9561 vv(2)=pizda(1,2)+pizda(2,1)
9562 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9563 !d write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4',s4
9565 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
9567 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
9570 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
9572 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
9578 end function eello6_graph2
9579 !-----------------------------------------------------------------------------
9580 real(kind=8) function eello6_graph3(i,j,k,l,jj,kk,swap)
9581 ! implicit real*8 (a-h,o-z)
9582 ! include 'DIMENSIONS'
9583 ! include 'COMMON.IOUNITS'
9584 ! include 'COMMON.CHAIN'
9585 ! include 'COMMON.DERIV'
9586 ! include 'COMMON.INTERACT'
9587 ! include 'COMMON.CONTACTS'
9588 ! include 'COMMON.TORSION'
9589 ! include 'COMMON.VAR'
9590 ! include 'COMMON.GEO'
9591 real(kind=8),dimension(2) :: vv,auxvec
9592 real(kind=8),dimension(2,2) :: pizda,auxmat
9594 integer :: i,j,k,l,jj,kk,iti,itj1,itk,itk1,iii,lll,kkk,itl1
9595 real(kind=8) :: s1,s2,s3,s4
9596 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9598 ! Parallel Antiparallel C
9604 ! j|/k\| / |/k\|l / C
9609 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9611 ! 4/7/01 AL Component s1 was removed, because it pertains to the respective
9612 ! energy moment and not to the cluster cumulant.
9613 iti=itortyp(itype(i,1))
9614 if (j.lt.nres-1) then
9615 itj1=itortyp(itype(j+1,1))
9619 itk=itortyp(itype(k,1))
9620 itk1=itortyp(itype(k+1,1))
9621 if (l.lt.nres-1) then
9622 itl1=itortyp(itype(l+1,1))
9627 s1=dip(4,jj,i)*dip(4,kk,k)
9629 call matvec2(AECA(1,1,1),b1(1,itk1),auxvec(1))
9630 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
9631 call matvec2(AECA(1,1,2),b1(1,itl1),auxvec(1))
9632 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
9633 call transpose2(EE(1,1,itk),auxmat(1,1))
9634 call matmat2(auxmat(1,1),AECA(1,1,1),pizda(1,1))
9635 vv(1)=pizda(1,1)+pizda(2,2)
9636 vv(2)=pizda(2,1)-pizda(1,2)
9637 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
9638 !d write (2,*) 'eello6_graph3:','s1',s1,' s2',s2,' s3',s3,' s4',s4,
9639 !d & "sum",-(s2+s3+s4)
9641 eello6_graph3=-(s1+s2+s3+s4)
9643 eello6_graph3=-(s2+s3+s4)
9646 ! Derivatives in gamma(k-1)
9647 call matvec2(AECAderg(1,1,2),b1(1,itl1),auxvec(1))
9648 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
9649 s4=-0.25d0*scalar2(vv(1),Ctobrder(1,k))
9650 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s3+s4)
9651 ! Derivatives in gamma(l-1)
9652 call matvec2(AECAderg(1,1,1),b1(1,itk1),auxvec(1))
9653 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
9654 call matmat2(auxmat(1,1),AECAderg(1,1,1),pizda(1,1))
9655 vv(1)=pizda(1,1)+pizda(2,2)
9656 vv(2)=pizda(2,1)-pizda(1,2)
9657 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
9658 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
9659 ! Cartesian derivatives.
9665 s1=dipderx(lll,kkk,4,jj,i)*dip(4,kk,k)
9667 s1=dip(4,jj,i)*dipderx(lll,kkk,4,kk,k)
9670 call matvec2(AECAderx(1,1,lll,kkk,iii,1),b1(1,itk1),&
9672 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
9673 call matvec2(AECAderx(1,1,lll,kkk,iii,2),b1(1,itl1),&
9675 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
9676 call matmat2(auxmat(1,1),AECAderx(1,1,lll,kkk,iii,1),&
9678 vv(1)=pizda(1,1)+pizda(2,2)
9679 vv(2)=pizda(2,1)-pizda(1,2)
9680 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
9682 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
9684 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
9687 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
9689 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
9691 ! derx(lll,kkk,iii)=derx(lll,kkk,iii)-s4
9696 end function eello6_graph3
9697 !-----------------------------------------------------------------------------
9698 real(kind=8) function eello6_graph4(i,j,k,l,jj,kk,imat,swap)
9699 ! implicit real*8 (a-h,o-z)
9700 ! include 'DIMENSIONS'
9701 ! include 'COMMON.IOUNITS'
9702 ! include 'COMMON.CHAIN'
9703 ! include 'COMMON.DERIV'
9704 ! include 'COMMON.INTERACT'
9705 ! include 'COMMON.CONTACTS'
9706 ! include 'COMMON.TORSION'
9707 ! include 'COMMON.VAR'
9708 ! include 'COMMON.GEO'
9709 ! include 'COMMON.FFIELD'
9710 real(kind=8),dimension(2) :: vv,auxvec,auxvec1
9711 real(kind=8),dimension(2,2) :: pizda,auxmat,auxmat1
9713 integer :: i,j,k,l,jj,kk,imat,iti,itj,itj1,itk,itk1,itl,itl1,&
9715 real(kind=8) :: s1,s2,s3,s4
9716 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9718 ! Parallel Antiparallel C
9724 ! \ j|/k\| \ |/k\|l C
9729 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9731 ! 4/7/01 AL Component s1 was removed, because it pertains to the respective
9732 ! energy moment and not to the cluster cumulant.
9733 !d write (2,*) 'eello_graph4: wturn6',wturn6
9734 iti=itortyp(itype(i,1))
9735 itj=itortyp(itype(j,1))
9736 if (j.lt.nres-1) then
9737 itj1=itortyp(itype(j+1,1))
9741 itk=itortyp(itype(k,1))
9742 if (k.lt.nres-1) then
9743 itk1=itortyp(itype(k+1,1))
9747 itl=itortyp(itype(l,1))
9748 if (l.lt.nres-1) then
9749 itl1=itortyp(itype(l+1,1))
9753 !d write (2,*) 'eello6_graph4:','i',i,' j',j,' k',k,' l',l
9754 !d write (2,*) 'iti',iti,' itj',itj,' itj1',itj1,' itk',itk,
9755 !d & ' itl',itl,' itl1',itl1
9758 s1=dip(3,jj,i)*dip(3,kk,k)
9760 s1=dip(2,jj,j)*dip(2,kk,l)
9763 call matvec2(AECA(1,1,imat),Ub2(1,k),auxvec(1))
9764 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
9766 call matvec2(ADtEA1(1,1,3-imat),b1(1,itj1),auxvec1(1))
9767 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
9769 call matvec2(ADtEA1(1,1,3-imat),b1(1,itl1),auxvec1(1))
9770 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
9772 call transpose2(EUg(1,1,k),auxmat(1,1))
9773 call matmat2(AECA(1,1,imat),auxmat(1,1),pizda(1,1))
9774 vv(1)=pizda(1,1)-pizda(2,2)
9775 vv(2)=pizda(2,1)+pizda(1,2)
9776 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
9777 !d write (2,*) 'eello6_graph4:','s1',s1,' s2',s2,' s3',s3,' s4',s4
9779 eello6_graph4=-(s1+s2+s3+s4)
9781 eello6_graph4=-(s2+s3+s4)
9783 ! Derivatives in gamma(i-1)
9787 s1=dipderg(2,jj,i)*dip(3,kk,k)
9789 s1=dipderg(4,jj,j)*dip(2,kk,l)
9792 s2=0.5d0*scalar2(Ub2der(1,i),auxvec(1))
9794 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,itj1),auxvec1(1))
9795 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
9797 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,itl1),auxvec1(1))
9798 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
9800 s4=0.25d0*scalar2(vv(1),Dtobr2der(1,i))
9801 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
9802 !d write (2,*) 'turn6 derivatives'
9804 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s1+s2+s3+s4)
9806 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s2+s3+s4)
9810 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
9812 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
9816 ! Derivatives in gamma(k-1)
9819 s1=dip(3,jj,i)*dipderg(2,kk,k)
9821 s1=dip(2,jj,j)*dipderg(4,kk,l)
9824 call matvec2(AECA(1,1,imat),Ub2der(1,k),auxvec1(1))
9825 s2=0.5d0*scalar2(Ub2(1,i),auxvec1(1))
9827 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,itj1),auxvec1(1))
9828 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
9830 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,itl1),auxvec1(1))
9831 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
9833 call transpose2(EUgder(1,1,k),auxmat1(1,1))
9834 call matmat2(AECA(1,1,imat),auxmat1(1,1),pizda(1,1))
9835 vv(1)=pizda(1,1)-pizda(2,2)
9836 vv(2)=pizda(2,1)+pizda(1,2)
9837 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
9838 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
9840 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s1+s2+s3+s4)
9842 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s2+s3+s4)
9846 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
9848 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
9851 ! Derivatives in gamma(j-1) or gamma(l-1)
9852 if (l.eq.j+1 .and. l.gt.1) then
9853 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
9854 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
9855 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
9856 vv(1)=pizda(1,1)-pizda(2,2)
9857 vv(2)=pizda(2,1)+pizda(1,2)
9858 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
9859 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
9860 else if (j.gt.1) then
9861 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
9862 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
9863 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
9864 vv(1)=pizda(1,1)-pizda(2,2)
9865 vv(2)=pizda(2,1)+pizda(1,2)
9866 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
9867 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
9868 gel_loc_turn6(j-1)=gel_loc_turn6(j-1)-ekont*(s2+s4)
9870 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s4)
9873 ! Cartesian derivatives.
9880 s1=dipderx(lll,kkk,3,jj,i)*dip(3,kk,k)
9882 s1=dipderx(lll,kkk,2,jj,j)*dip(2,kk,l)
9886 s1=dip(3,jj,i)*dipderx(lll,kkk,3,kk,k)
9888 s1=dip(2,jj,j)*dipderx(lll,kkk,2,kk,l)
9892 call matvec2(AECAderx(1,1,lll,kkk,iii,imat),Ub2(1,k),&
9894 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
9896 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),&
9897 b1(1,itj1),auxvec(1))
9898 s3=-0.5d0*scalar2(b1(1,itj),auxvec(1))
9900 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),&
9901 b1(1,itl1),auxvec(1))
9902 s3=-0.5d0*scalar2(b1(1,itl),auxvec(1))
9904 call matmat2(AECAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),&
9906 vv(1)=pizda(1,1)-pizda(2,2)
9907 vv(2)=pizda(2,1)+pizda(1,2)
9908 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
9910 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
9912 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii) &
9915 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii) &
9918 derx_turn(lll,kkk,iii)=derx_turn(lll,kkk,iii)-s3
9921 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s1+s2+s4)
9923 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s2+s4)
9925 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
9929 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
9931 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
9934 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
9936 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
9943 end function eello6_graph4
9944 !-----------------------------------------------------------------------------
9945 real(kind=8) function eello_turn6(i,jj,kk)
9946 ! implicit real*8 (a-h,o-z)
9947 ! include 'DIMENSIONS'
9948 ! include 'COMMON.IOUNITS'
9949 ! include 'COMMON.CHAIN'
9950 ! include 'COMMON.DERIV'
9951 ! include 'COMMON.INTERACT'
9952 ! include 'COMMON.CONTACTS'
9953 ! include 'COMMON.TORSION'
9954 ! include 'COMMON.VAR'
9955 ! include 'COMMON.GEO'
9956 real(kind=8),dimension(2) :: vtemp1,vtemp2,vtemp3,vtemp4,gvec
9957 real(kind=8),dimension(2,2) :: atemp,auxmat,achuj_temp,gtemp
9958 real(kind=8),dimension(3) :: ggg1,ggg2
9959 real(kind=8),dimension(2) :: vtemp1d,vtemp2d,vtemp3d,vtemp4d,gvecd
9960 real(kind=8),dimension(2,2) :: atempd,auxmatd,achuj_tempd,gtempd
9961 ! 4/7/01 AL Components s1, s8, and s13 were removed, because they pertain to
9962 ! the respective energy moment and not to the cluster cumulant.
9964 integer :: i,jj,kk,j,k,l,iti,itk,itk1,itl,itj,iii,kkk,lll
9965 integer :: j1,j2,l1,l2,ll
9966 real(kind=8) :: s1,s2,s8,s13,s12,eello6_5,eel_turn6
9967 real(kind=8) :: s1d,s8d,s12d,s2d,gturn6ij,gturn6kl
9976 iti=itortyp(itype(i,1))
9977 itk=itortyp(itype(k,1))
9978 itk1=itortyp(itype(k+1,1))
9979 itl=itortyp(itype(l,1))
9980 itj=itortyp(itype(j,1))
9981 !d write (2,*) 'itk',itk,' itk1',itk1,' itl',itl,' itj',itj
9982 !d write (2,*) 'i',i,' k',k,' j',j,' l',l
9983 !d if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
9988 !d & 'EELLO6: Contacts have occurred for peptide groups',i,j,
9990 !d call checkint_turn6(i,jj,kk,eel_turn6_num)
9994 derx_turn(lll,kkk,iii)=0.0d0
10001 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
10003 !d write (2,*) 'eello6_5',eello6_5
10005 call transpose2(AEA(1,1,1),auxmat(1,1))
10006 call matmat2(EUg(1,1,i+1),auxmat(1,1),auxmat(1,1))
10007 ss1=scalar2(Ub2(1,i+2),b1(1,itl))
10008 s1 = (auxmat(1,1)+auxmat(2,2))*ss1
10010 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1(1))
10011 call matvec2(AEA(1,1,1),vtemp1(1),vtemp1(1))
10012 s2 = scalar2(b1(1,itk),vtemp1(1))
10014 call transpose2(AEA(1,1,2),atemp(1,1))
10015 call matmat2(atemp(1,1),EUg(1,1,i+4),atemp(1,1))
10016 call matvec2(Ug2(1,1,i+2),dd(1,1,itk1),vtemp2(1))
10017 s8 = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
10019 call matmat2(EUg(1,1,i+3),AEA(1,1,2),auxmat(1,1))
10020 call matvec2(auxmat(1,1),Ub2(1,i+4),vtemp3(1))
10021 s12 = scalar2(Ub2(1,i+2),vtemp3(1))
10023 call transpose2(a_chuj(1,1,kk,i+1),achuj_temp(1,1))
10024 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtemp(1,1))
10025 call matmat2(gtemp(1,1),EUg(1,1,i+3),gtemp(1,1))
10026 call matvec2(a_chuj(1,1,jj,i),Ub2(1,i+4),vtemp4(1))
10027 ss13 = scalar2(b1(1,itk),vtemp4(1))
10028 s13 = (gtemp(1,1)+gtemp(2,2))*ss13
10030 ! write (2,*) 's1,s2,s8,s12,s13',s1,s2,s8,s12,s13
10036 eel_turn6 = eello6_5 - 0.5d0*(s1+s2+s12+s8+s13)
10037 ! Derivatives in gamma(i+2)
10041 call transpose2(AEA(1,1,1),auxmatd(1,1))
10042 call matmat2(EUgder(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
10043 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
10044 call transpose2(AEAderg(1,1,2),atempd(1,1))
10045 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
10046 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
10048 call matmat2(EUg(1,1,i+3),AEAderg(1,1,2),auxmatd(1,1))
10049 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
10050 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
10056 gel_loc_turn6(i)=gel_loc_turn6(i)-0.5d0*ekont*(s1d+s8d+s12d)
10057 ! Derivatives in gamma(i+3)
10059 call transpose2(AEA(1,1,1),auxmatd(1,1))
10060 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
10061 ss1d=scalar2(Ub2der(1,i+2),b1(1,itl))
10062 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1d
10064 call matvec2(EUgder(1,1,i+2),b1(1,itl),vtemp1d(1))
10065 call matvec2(AEA(1,1,1),vtemp1d(1),vtemp1d(1))
10066 s2d = scalar2(b1(1,itk),vtemp1d(1))
10068 call matvec2(Ug2der(1,1,i+2),dd(1,1,itk1),vtemp2d(1))
10069 s8d = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,itl),vtemp2d(1))
10071 s12d = scalar2(Ub2der(1,i+2),vtemp3(1))
10073 call matmat2(achuj_temp(1,1),EUgder(1,1,i+2),gtempd(1,1))
10074 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
10075 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
10083 gel_loc_turn6(i+1)=gel_loc_turn6(i+1) &
10084 -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
10086 gel_loc_turn6(i+1)=gel_loc_turn6(i+1) &
10087 -0.5d0*ekont*(s2d+s12d)
10089 ! Derivatives in gamma(i+4)
10090 call matmat2(EUgder(1,1,i+3),AEA(1,1,2),auxmatd(1,1))
10091 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
10092 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
10094 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtempd(1,1))
10095 call matmat2(gtempd(1,1),EUgder(1,1,i+3),gtempd(1,1))
10096 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
10104 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d+s13d)
10106 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d)
10108 ! Derivatives in gamma(i+5)
10110 call transpose2(AEAderg(1,1,1),auxmatd(1,1))
10111 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
10112 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
10114 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1d(1))
10115 call matvec2(AEAderg(1,1,1),vtemp1d(1),vtemp1d(1))
10116 s2d = scalar2(b1(1,itk),vtemp1d(1))
10118 call transpose2(AEA(1,1,2),atempd(1,1))
10119 call matmat2(atempd(1,1),EUgder(1,1,i+4),atempd(1,1))
10120 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
10122 call matvec2(auxmat(1,1),Ub2der(1,i+4),vtemp3d(1))
10123 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
10125 call matvec2(a_chuj(1,1,jj,i),Ub2der(1,i+4),vtemp4d(1))
10126 ss13d = scalar2(b1(1,itk),vtemp4d(1))
10127 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
10135 gel_loc_turn6(i+3)=gel_loc_turn6(i+3) &
10136 -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
10138 gel_loc_turn6(i+3)=gel_loc_turn6(i+3) &
10139 -0.5d0*ekont*(s2d+s12d)
10141 ! Cartesian derivatives
10146 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmatd(1,1))
10147 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
10148 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
10150 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1(1))
10151 call matvec2(AEAderx(1,1,lll,kkk,iii,1),vtemp1(1),&
10153 s2d = scalar2(b1(1,itk),vtemp1d(1))
10155 call transpose2(AEAderx(1,1,lll,kkk,iii,2),atempd(1,1))
10156 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
10157 s8d = -(atempd(1,1)+atempd(2,2))* &
10158 scalar2(cc(1,1,itl),vtemp2(1))
10160 call matmat2(EUg(1,1,i+3),AEAderx(1,1,lll,kkk,iii,2),&
10162 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
10163 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
10170 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii) &
10173 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii) &
10177 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii) &
10180 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii) &
10189 call transpose2(a_chuj_der(1,1,lll,kkk,kk,i+1),&
10191 call matmat2(achuj_tempd(1,1),EUg(1,1,i+2),gtempd(1,1))
10192 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
10193 s13d=(gtempd(1,1)+gtempd(2,2))*ss13
10194 derx_turn(lll,kkk,2) = derx_turn(lll,kkk,2)-0.5d0*s13d
10195 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),Ub2(1,i+4),&
10197 ss13d = scalar2(b1(1,itk),vtemp4d(1))
10198 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
10199 derx_turn(lll,kkk,1) = derx_turn(lll,kkk,1)-0.5d0*s13d
10203 !d write(iout,*) 'eel6_turn6',eel_turn6,' eel_turn6_num',
10204 !d & 16*eel_turn6_num
10206 if (j.lt.nres-1) then
10213 if (l.lt.nres-1) then
10221 !grad ggg1(ll)=eel_turn6*g_contij(ll,1)
10222 !grad ggg2(ll)=eel_turn6*g_contij(ll,2)
10223 !grad ghalf=0.5d0*ggg1(ll)
10225 gturn6ij=eel_turn6*g_contij(ll,1)+ekont*derx_turn(ll,1,1)
10226 gturn6kl=eel_turn6*g_contij(ll,2)+ekont*derx_turn(ll,1,2)
10227 gcorr6_turn(ll,i)=gcorr6_turn(ll,i) & !+ghalf
10228 +ekont*derx_turn(ll,2,1)
10229 gcorr6_turn(ll,i+1)=gcorr6_turn(ll,i+1)+ekont*derx_turn(ll,3,1)
10230 gcorr6_turn(ll,j)=gcorr6_turn(ll,j) & !+ghalf
10231 +ekont*derx_turn(ll,4,1)
10232 gcorr6_turn(ll,j1)=gcorr6_turn(ll,j1)+ekont*derx_turn(ll,5,1)
10233 gcorr6_turn_long(ll,j)=gcorr6_turn_long(ll,j)+gturn6ij
10234 gcorr6_turn_long(ll,i)=gcorr6_turn_long(ll,i)-gturn6ij
10235 !grad ghalf=0.5d0*ggg2(ll)
10237 gcorr6_turn(ll,k)=gcorr6_turn(ll,k) & !+ghalf
10238 +ekont*derx_turn(ll,2,2)
10239 gcorr6_turn(ll,k+1)=gcorr6_turn(ll,k+1)+ekont*derx_turn(ll,3,2)
10240 gcorr6_turn(ll,l)=gcorr6_turn(ll,l) & !+ghalf
10241 +ekont*derx_turn(ll,4,2)
10242 gcorr6_turn(ll,l1)=gcorr6_turn(ll,l1)+ekont*derx_turn(ll,5,2)
10243 gcorr6_turn_long(ll,l)=gcorr6_turn_long(ll,l)+gturn6kl
10244 gcorr6_turn_long(ll,k)=gcorr6_turn_long(ll,k)-gturn6kl
10249 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg1(ll)
10254 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg2(ll)
10260 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,1)
10265 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,2)
10269 !d write (2,*) iii,g_corr6_loc(iii)
10271 eello_turn6=ekont*eel_turn6
10272 !d write (2,*) 'ekont',ekont
10273 !d write (2,*) 'eel_turn6',ekont*eel_turn6
10275 end function eello_turn6
10276 !-----------------------------------------------------------------------------
10277 subroutine MATVEC2(A1,V1,V2)
10278 !DIR$ INLINEALWAYS MATVEC2
10280 !DEC$ ATTRIBUTES FORCEINLINE::MATVEC2
10282 ! implicit real*8 (a-h,o-z)
10283 ! include 'DIMENSIONS'
10284 real(kind=8),dimension(2) :: V1,V2
10285 real(kind=8),dimension(2,2) :: A1
10286 real(kind=8) :: vaux1,vaux2
10290 ! 3 VI=VI+A1(I,K)*V1(K)
10294 vaux1=a1(1,1)*v1(1)+a1(1,2)*v1(2)
10295 vaux2=a1(2,1)*v1(1)+a1(2,2)*v1(2)
10299 end subroutine MATVEC2
10300 !-----------------------------------------------------------------------------
10301 subroutine MATMAT2(A1,A2,A3)
10303 !DEC$ ATTRIBUTES FORCEINLINE::MATMAT2
10305 ! implicit real*8 (a-h,o-z)
10306 ! include 'DIMENSIONS'
10307 real(kind=8),dimension(2,2) :: A1,A2,A3
10308 real(kind=8) :: ai3_11,ai3_12,ai3_21,ai3_22
10309 ! DIMENSION AI3(2,2)
10313 ! A3IJ=A3IJ+A1(I,K)*A2(K,J)
10319 ai3_11=a1(1,1)*a2(1,1)+a1(1,2)*a2(2,1)
10320 ai3_12=a1(1,1)*a2(1,2)+a1(1,2)*a2(2,2)
10321 ai3_21=a1(2,1)*a2(1,1)+a1(2,2)*a2(2,1)
10322 ai3_22=a1(2,1)*a2(1,2)+a1(2,2)*a2(2,2)
10328 end subroutine MATMAT2
10329 !-----------------------------------------------------------------------------
10330 real(kind=8) function scalar2(u,v)
10331 !DIR$ INLINEALWAYS scalar2
10333 real(kind=8),dimension(2) :: u,v
10336 scalar2=u(1)*v(1)+u(2)*v(2)
10338 end function scalar2
10339 !-----------------------------------------------------------------------------
10340 subroutine transpose2(a,at)
10341 !DIR$ INLINEALWAYS transpose2
10343 !DEC$ ATTRIBUTES FORCEINLINE::transpose2
10346 real(kind=8),dimension(2,2) :: a,at
10352 end subroutine transpose2
10353 !-----------------------------------------------------------------------------
10354 subroutine transpose(n,a,at)
10357 real(kind=8),dimension(n,n) :: a,at
10364 end subroutine transpose
10365 !-----------------------------------------------------------------------------
10366 subroutine prodmat3(a1,a2,kk,transp,prod)
10367 !DIR$ INLINEALWAYS prodmat3
10369 !DEC$ ATTRIBUTES FORCEINLINE::prodmat3
10373 real(kind=8),dimension(2,2) :: a1,a2,a2t,kk,prod
10375 !rc double precision auxmat(2,2),prod_(2,2)
10378 !rc call transpose2(kk(1,1),auxmat(1,1))
10379 !rc call matmat2(a1(1,1),auxmat(1,1),auxmat(1,1))
10380 !rc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
10382 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,1) &
10383 +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,1)
10384 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,2) &
10385 +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,2)
10386 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,1) &
10387 +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,1)
10388 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,2) &
10389 +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,2)
10392 !rc call matmat2(a1(1,1),kk(1,1),auxmat(1,1))
10393 !rc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
10395 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,1) &
10396 +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,1)
10397 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,2) &
10398 +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,2)
10399 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,1) &
10400 +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,1)
10401 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,2) &
10402 +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,2)
10405 ! call transpose2(a2(1,1),a2t(1,1))
10408 !rc print *,((prod_(i,j),i=1,2),j=1,2)
10409 !rc print *,((prod(i,j),i=1,2),j=1,2)
10412 end subroutine prodmat3
10413 !-----------------------------------------------------------------------------
10414 ! energy_p_new_barrier.F
10415 !-----------------------------------------------------------------------------
10416 subroutine sum_gradient
10417 ! implicit real*8 (a-h,o-z)
10418 use io_base, only: pdbout
10419 ! include 'DIMENSIONS'
10423 !MS$ATTRIBUTES C :: proc_proc
10429 real(kind=8),dimension(3,-1:nres) :: gradbufc,gradbufx,gradbufc_sum,&
10430 gloc_scbuf !(3,maxres)
10432 real(kind=8),dimension(4*nres) :: glocbuf !(4*maxres)
10434 !el local variables
10435 integer :: i,j,k,ierror,ierr
10436 real(kind=8) :: gvdwc_norm,gvdwc_scp_norm,gelc_norm,gvdwpp_norm,&
10437 gradb_norm,ghpbc_norm,gradcorr_norm,gel_loc_norm,&
10438 gcorr3_turn_norm,gcorr4_turn_norm,gradcorr5_norm,&
10439 gradcorr6_norm,gcorr6_turn_norm,gsccorr_norm,&
10440 gscloc_norm,gvdwx_norm,gradx_scp_norm,ghpbx_norm,&
10441 gradxorr_norm,gsccorrx_norm,gsclocx_norm,gcorr6_max,&
10442 gsccorr_max,gsccorrx_max,time00
10444 ! include 'COMMON.SETUP'
10445 ! include 'COMMON.IOUNITS'
10446 ! include 'COMMON.FFIELD'
10447 ! include 'COMMON.DERIV'
10448 ! include 'COMMON.INTERACT'
10449 ! include 'COMMON.SBRIDGE'
10450 ! include 'COMMON.CHAIN'
10451 ! include 'COMMON.VAR'
10452 ! include 'COMMON.CONTROL'
10453 ! include 'COMMON.TIME1'
10454 ! include 'COMMON.MAXGRAD'
10455 ! include 'COMMON.SCCOR'
10460 write (iout,*) "sum_gradient gvdwc, gvdwx"
10462 write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)') &
10463 i,(gvdwx(j,i),j=1,3),(gvdwc(j,i),j=1,3)
10473 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
10474 if (nfgtasks.gt.1 .and. fg_rank.eq.0) &
10475 call MPI_Bcast(1,1,MPI_INTEGER,king,FG_COMM,IERROR)
10478 ! 9/29/08 AL Transform parts of gradients in site coordinates to the gradient
10479 ! in virtual-bond-vector coordinates
10482 ! write (iout,*) "gel_loc gel_loc_long and gel_loc_loc"
10484 ! write (iout,'(i5,3f10.5,2x,3f10.5,2x,f10.5)')
10485 ! & i,(gel_loc(j,i),j=1,3),(gel_loc_long(j,i),j=1,3),gel_loc_loc(i)
10487 ! write (iout,*) "gel_loc_tur3 gel_loc_turn4"
10489 ! write (iout,'(i5,3f10.5,2x,f10.5)')
10490 ! & i,(gcorr4_turn(j,i),j=1,3),gel_loc_turn4(i)
10492 write (iout,*) "gvdwc gvdwc_scp gvdwc_scpp"
10494 write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)') &
10495 i,(gvdwc(j,i),j=1,3),(gvdwc_scp(j,i),j=1,3),&
10496 (gvdwc_scpp(j,i),j=1,3)
10498 write (iout,*) "gelc_long gvdwpp gel_loc_long"
10500 write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)') &
10501 i,(gelc_long(j,i),j=1,3),(gvdwpp(j,i),j=1,3),&
10502 (gelc_loc_long(j,i),j=1,3)
10509 gradbufc(j,i)=wsc*gvdwc(j,i)+ &
10510 wscp*(gvdwc_scp(j,i)+gvdwc_scpp(j,i))+ &
10511 welec*gelc_long(j,i)+wvdwpp*gvdwpp(j,i)+ &
10512 wel_loc*gel_loc_long(j,i)+ &
10513 wcorr*gradcorr_long(j,i)+ &
10514 wcorr5*gradcorr5_long(j,i)+ &
10515 wcorr6*gradcorr6_long(j,i)+ &
10516 wturn6*gcorr6_turn_long(j,i)+ &
10517 wstrain*ghpbc(j,i) &
10518 +wliptran*gliptranc(j,i) &
10520 +welec*gshieldc(j,i) &
10521 +wcorr*gshieldc_ec(j,i) &
10522 +wturn3*gshieldc_t3(j,i)&
10523 +wturn4*gshieldc_t4(j,i)&
10524 +wel_loc*gshieldc_ll(j,i)&
10525 +wtube*gg_tube(j,i) &
10526 +wvdwpp_nucl*gvdwpp_nucl(j,i)+welpp*gelpp(j,i)+ &
10527 wvdwpsb*(gvdwpsb(j,i)+gvdwpsb1(j,i))+ &
10528 wvdwsb*gvdwsbc(j,i)+welsb*gelsbc(j,i)+ &
10529 wcorr_nucl*gradcorr_nucl(j,i)&
10530 +wcorr3_nucl*gradcorr3_nucl(j,i)+&
10531 wcatprot* gradpepcat(j,i)+ &
10532 wcatcat*gradcatcat(j,i)+ &
10533 wscbase*gvdwc_scbase(j,i)+ &
10534 wpepbase*gvdwc_pepbase(j,i)+&
10535 wscpho*gvdwc_scpho(j,i)+ &
10536 wpeppho*gvdwc_peppho(j,i)
10547 gradbufc(j,i)=wsc*gvdwc(j,i)+ &
10548 wscp*(gvdwc_scp(j,i)+gvdwc_scpp(j,i))+ &
10549 welec*gelc_long(j,i)+ &
10550 wbond*gradb(j,i)+ &
10551 wel_loc*gel_loc_long(j,i)+ &
10552 wcorr*gradcorr_long(j,i)+ &
10553 wcorr5*gradcorr5_long(j,i)+ &
10554 wcorr6*gradcorr6_long(j,i)+ &
10555 wturn6*gcorr6_turn_long(j,i)+ &
10556 wstrain*ghpbc(j,i) &
10557 +wliptran*gliptranc(j,i) &
10559 +welec*gshieldc(j,i)&
10560 +wcorr*gshieldc_ec(j,i) &
10561 +wturn4*gshieldc_t4(j,i) &
10562 +wel_loc*gshieldc_ll(j,i)&
10563 +wtube*gg_tube(j,i) &
10564 +wvdwpp_nucl*gvdwpp_nucl(j,i)+welpp*gelpp(j,i)+ &
10565 wvdwpsb*(gvdwpsb(j,i)+gvdwpsb1(j,i))+ &
10566 wvdwsb*gvdwsbc(j,i)+welsb*gelsbc(j,i)+ &
10567 wcorr_nucl*gradcorr_nucl(j,i) &
10568 +wcorr3_nucl*gradcorr3_nucl(j,i) +&
10569 wcatprot* gradpepcat(j,i)+ &
10570 wcatcat*gradcatcat(j,i)+ &
10571 wscbase*gvdwc_scbase(j,i) &
10572 wpepbase*gvdwc_pepbase(j,i)+&
10573 wscpho*gvdwc_scpho(j,i)+&
10574 wpeppho*gvdwc_peppho(j,i)
10581 if (nfgtasks.gt.1) then
10584 write (iout,*) "gradbufc before allreduce"
10586 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
10592 gradbufc_sum(j,i)=gradbufc(j,i)
10595 ! call MPI_AllReduce(gradbufc(1,1),gradbufc_sum(1,1),3*nres,
10596 ! & MPI_DOUBLE_PRECISION,MPI_SUM,FG_COMM,IERR)
10597 ! time_reduce=time_reduce+MPI_Wtime()-time00
10599 ! write (iout,*) "gradbufc_sum after allreduce"
10601 ! write (iout,'(i3,3f10.5)') i,(gradbufc_sum(j,i),j=1,3)
10606 ! time_allreduce=time_allreduce+MPI_Wtime()-time00
10610 gradbufc(k,i)=0.0d0
10614 write (iout,*) "igrad_start",igrad_start," igrad_end",igrad_end
10615 write (iout,*) (i," jgrad_start",jgrad_start(i),&
10616 " jgrad_end ",jgrad_end(i),&
10617 i=igrad_start,igrad_end)
10620 ! Obsolete and inefficient code; we can make the effort O(n) and, therefore,
10621 ! do not parallelize this part.
10623 ! do i=igrad_start,igrad_end
10624 ! do j=jgrad_start(i),jgrad_end(i)
10626 ! gradbufc(k,i)=gradbufc(k,i)+gradbufc_sum(k,j)
10631 gradbufc(j,nres-1)=gradbufc_sum(j,nres)
10635 gradbufc(j,i)=gradbufc(j,i+1)+gradbufc_sum(j,i+1)
10639 write (iout,*) "gradbufc after summing"
10641 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
10649 write (iout,*) "gradbufc"
10651 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
10658 gradbufc_sum(j,i)=gradbufc(j,i)
10659 gradbufc(j,i)=0.0d0
10663 gradbufc(j,nres-1)=gradbufc_sum(j,nres)
10667 gradbufc(j,i)=gradbufc(j,i+1)+gradbufc_sum(j,i+1)
10672 ! gradbufc(k,i)=0.0d0
10676 ! gradbufc(k,i)=gradbufc(k,i)+gradbufc(k,j)
10682 write (iout,*) "gradbufc after summing"
10684 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
10693 gradbufc(k,nres)=0.0d0
10695 !el----------------
10696 !el if (.not.allocated(gradx)) allocate(gradx(3,nres,2)) !(3,maxres,2)
10697 !el if (.not.allocated(gradc)) allocate(gradc(3,nres,2)) !(3,maxres,2)
10698 !el-----------------
10702 gradc(j,i,icg)=gradbufc(j,i)+welec*gelc(j,i)+ &
10703 wel_loc*gel_loc(j,i)+ &
10704 0.5d0*(wscp*gvdwc_scpp(j,i)+ &
10705 welec*gelc_long(j,i)+wvdwpp*gvdwpp(j,i)+ &
10706 wel_loc*gel_loc_long(j,i)+ &
10707 wcorr*gradcorr_long(j,i)+ &
10708 wcorr5*gradcorr5_long(j,i)+ &
10709 wcorr6*gradcorr6_long(j,i)+ &
10710 wturn6*gcorr6_turn_long(j,i))+ &
10711 wbond*gradb(j,i)+ &
10712 wcorr*gradcorr(j,i)+ &
10713 wturn3*gcorr3_turn(j,i)+ &
10714 wturn4*gcorr4_turn(j,i)+ &
10715 wcorr5*gradcorr5(j,i)+ &
10716 wcorr6*gradcorr6(j,i)+ &
10717 wturn6*gcorr6_turn(j,i)+ &
10718 wsccor*gsccorc(j,i) &
10719 +wscloc*gscloc(j,i) &
10720 +wliptran*gliptranc(j,i) &
10722 +welec*gshieldc(j,i) &
10723 +welec*gshieldc_loc(j,i) &
10724 +wcorr*gshieldc_ec(j,i) &
10725 +wcorr*gshieldc_loc_ec(j,i) &
10726 +wturn3*gshieldc_t3(j,i) &
10727 +wturn3*gshieldc_loc_t3(j,i) &
10728 +wturn4*gshieldc_t4(j,i) &
10729 +wturn4*gshieldc_loc_t4(j,i) &
10730 +wel_loc*gshieldc_ll(j,i) &
10731 +wel_loc*gshieldc_loc_ll(j,i) &
10732 +wtube*gg_tube(j,i) &
10733 +0.5d0*(wvdwpp_nucl*gvdwpp_nucl(j,i)+welpp*gelpp(j,i)&
10734 +wvdwpsb*gvdwpsb1(j,i))&
10735 +wbond_nucl*gradb_nucl(j,i)+wsbloc*gsbloc(j,i)
10737 ! if ((i.le.2).and.(i.ge.1))
10738 ! print *,gradc(j,i,icg),&
10739 ! gradbufc(j,i),welec*gelc(j,i), &
10740 ! wel_loc*gel_loc(j,i), &
10741 ! wscp*gvdwc_scpp(j,i), &
10742 ! welec*gelc_long(j,i),wvdwpp*gvdwpp(j,i), &
10743 ! wel_loc*gel_loc_long(j,i), &
10744 ! wcorr*gradcorr_long(j,i), &
10745 ! wcorr5*gradcorr5_long(j,i), &
10746 ! wcorr6*gradcorr6_long(j,i), &
10747 ! wturn6*gcorr6_turn_long(j,i), &
10748 ! wbond*gradb(j,i), &
10749 ! wcorr*gradcorr(j,i), &
10750 ! wturn3*gcorr3_turn(j,i), &
10751 ! wturn4*gcorr4_turn(j,i), &
10752 ! wcorr5*gradcorr5(j,i), &
10753 ! wcorr6*gradcorr6(j,i), &
10754 ! wturn6*gcorr6_turn(j,i), &
10755 ! wsccor*gsccorc(j,i) &
10756 ! ,wscloc*gscloc(j,i) &
10757 ! ,wliptran*gliptranc(j,i) &
10759 ! ,welec*gshieldc(j,i) &
10760 ! ,welec*gshieldc_loc(j,i) &
10761 ! ,wcorr*gshieldc_ec(j,i) &
10762 ! ,wcorr*gshieldc_loc_ec(j,i) &
10763 ! ,wturn3*gshieldc_t3(j,i) &
10764 ! ,wturn3*gshieldc_loc_t3(j,i) &
10765 ! ,wturn4*gshieldc_t4(j,i) &
10766 ! ,wturn4*gshieldc_loc_t4(j,i) &
10767 ! ,wel_loc*gshieldc_ll(j,i) &
10768 ! ,wel_loc*gshieldc_loc_ll(j,i) &
10769 ! ,wtube*gg_tube(j,i) &
10770 ! ,wbond_nucl*gradb_nucl(j,i) &
10771 ! ,wvdwpp_nucl*gvdwpp_nucl(j,i),welpp*gelpp(j,i),&
10772 ! wvdwpsb*gvdwpsb1(j,i)&
10773 ! ,wbond_nucl*gradb_nucl(j,i),wsbloc*gsbloc(j,i)
10777 gradc(j,i,icg)=gradbufc(j,i)+welec*gelc(j,i)+ &
10778 wel_loc*gel_loc(j,i)+ &
10779 0.5d0*(wscp*gvdwc_scpp(j,i)+ &
10780 welec*gelc_long(j,i)+ &
10781 wel_loc*gel_loc_long(j,i)+ &
10782 !el wcorr*gcorr_long(j,i)+ & !el gcorr_long- brak deklaracji
10783 wcorr5*gradcorr5_long(j,i)+ &
10784 wcorr6*gradcorr6_long(j,i)+ &
10785 wturn6*gcorr6_turn_long(j,i))+ &
10786 wbond*gradb(j,i)+ &
10787 wcorr*gradcorr(j,i)+ &
10788 wturn3*gcorr3_turn(j,i)+ &
10789 wturn4*gcorr4_turn(j,i)+ &
10790 wcorr5*gradcorr5(j,i)+ &
10791 wcorr6*gradcorr6(j,i)+ &
10792 wturn6*gcorr6_turn(j,i)+ &
10793 wsccor*gsccorc(j,i) &
10794 +wscloc*gscloc(j,i) &
10796 +wliptran*gliptranc(j,i) &
10797 +welec*gshieldc(j,i) &
10798 +welec*gshieldc_loc(j,) &
10799 +wcorr*gshieldc_ec(j,i) &
10800 +wcorr*gshieldc_loc_ec(j,i) &
10801 +wturn3*gshieldc_t3(j,i) &
10802 +wturn3*gshieldc_loc_t3(j,i) &
10803 +wturn4*gshieldc_t4(j,i) &
10804 +wturn4*gshieldc_loc_t4(j,i) &
10805 +wel_loc*gshieldc_ll(j,i) &
10806 +wel_loc*gshieldc_loc_ll(j,i) &
10807 +wtube*gg_tube(j,i) &
10808 +wbond_nucl*gradb_nucl(j,i) &
10809 +0.5d0*(wvdwpp_nucl*gvdwpp_nucl(j,i)+welpp*gelpp(j,i)&
10810 +wvdwpsb*gvdwpsb1(j,i))&
10811 +wsbloc*gsbloc(j,i)
10817 gradx(j,i,icg)=wsc*gvdwx(j,i)+wscp*gradx_scp(j,i)+ &
10818 wbond*gradbx(j,i)+ &
10819 wstrain*ghpbx(j,i)+wcorr*gradxorr(j,i)+ &
10820 wsccor*gsccorx(j,i) &
10821 +wscloc*gsclocx(j,i) &
10822 +wliptran*gliptranx(j,i) &
10823 +welec*gshieldx(j,i) &
10824 +wcorr*gshieldx_ec(j,i) &
10825 +wturn3*gshieldx_t3(j,i) &
10826 +wturn4*gshieldx_t4(j,i) &
10827 +wel_loc*gshieldx_ll(j,i)&
10828 +wtube*gg_tube_sc(j,i) &
10829 +wbond_nucl*gradbx_nucl(j,i) &
10830 +wvdwsb*gvdwsbx(j,i) &
10831 +welsb*gelsbx(j,i) &
10832 +wcorr_nucl*gradxorr_nucl(j,i)&
10833 +wcorr3_nucl*gradxorr3_nucl(j,i) &
10834 +wsbloc*gsblocx(j,i) &
10835 +wcatprot* gradpepcatx(j,i)&
10836 +wscbase*gvdwx_scbase(j,i) &
10837 +wpepbase*gvdwx_pepbase(j,i)&
10838 +wscpho*gvdwx_scpho(j,i)
10839 ! if (i.eq.3) print *,"tu?", wscpho,gvdwx_scpho(j,i)
10844 write (iout,*) "gloc before adding corr"
10846 write (iout,*) i,gloc(i,icg)
10850 gloc(i,icg)=gloc(i,icg)+wcorr*gcorr_loc(i) &
10851 +wcorr5*g_corr5_loc(i) &
10852 +wcorr6*g_corr6_loc(i) &
10853 +wturn4*gel_loc_turn4(i) &
10854 +wturn3*gel_loc_turn3(i) &
10855 +wturn6*gel_loc_turn6(i) &
10856 +wel_loc*gel_loc_loc(i)
10859 write (iout,*) "gloc after adding corr"
10861 write (iout,*) i,gloc(i,icg)
10865 if (nfgtasks.gt.1) then
10868 gradbufc(j,i)=gradc(j,i,icg)
10869 gradbufx(j,i)=gradx(j,i,icg)
10873 glocbuf(i)=gloc(i,icg)
10877 write (iout,*) "gloc_sc before reduce"
10880 write (iout,*) i,j,gloc_sc(j,i,icg)
10887 gloc_scbuf(j,i)=gloc_sc(j,i,icg)
10891 call MPI_Barrier(FG_COMM,IERR)
10892 time_barrier_g=time_barrier_g+MPI_Wtime()-time00
10894 call MPI_Reduce(gradbufc(1,0),gradc(1,0,icg),3*nres+3,&
10895 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
10896 call MPI_Reduce(gradbufx(1,0),gradx(1,0,icg),3*nres+3,&
10897 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
10898 call MPI_Reduce(glocbuf(1),gloc(1,icg),4*nres,&
10899 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
10900 time_reduce=time_reduce+MPI_Wtime()-time00
10901 call MPI_Reduce(gloc_scbuf(1,1),gloc_sc(1,1,icg),3*nres,&
10902 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
10903 time_reduce=time_reduce+MPI_Wtime()-time00
10905 ! print *,"gradbuf",gradbufc(1,1),gradc(1,1,icg)
10907 write (iout,*) "gloc_sc after reduce"
10910 write (iout,*) i,j,gloc_sc(j,i,icg)
10916 write (iout,*) "gloc after reduce"
10918 write (iout,*) i,gloc(i,icg)
10923 if (gnorm_check) then
10925 ! Compute the maximum elements of the gradient
10928 gvdwc_scp_max=0.0d0
10935 gcorr3_turn_max=0.0d0
10936 gcorr4_turn_max=0.0d0
10937 gradcorr5_max=0.0d0
10938 gradcorr6_max=0.0d0
10939 gcorr6_turn_max=0.0d0
10943 gradx_scp_max=0.0d0
10949 gvdwc_norm=dsqrt(scalar(gvdwc(1,i),gvdwc(1,i)))
10950 if (gvdwc_norm.gt.gvdwc_max) gvdwc_max=gvdwc_norm
10951 gvdwc_scp_norm=dsqrt(scalar(gvdwc_scp(1,i),gvdwc_scp(1,i)))
10952 if (gvdwc_scp_norm.gt.gvdwc_scp_max) &
10953 gvdwc_scp_max=gvdwc_scp_norm
10954 gelc_norm=dsqrt(scalar(gelc(1,i),gelc(1,i)))
10955 if (gelc_norm.gt.gelc_max) gelc_max=gelc_norm
10956 gvdwpp_norm=dsqrt(scalar(gvdwpp(1,i),gvdwpp(1,i)))
10957 if (gvdwpp_norm.gt.gvdwpp_max) gvdwpp_max=gvdwpp_norm
10958 gradb_norm=dsqrt(scalar(gradb(1,i),gradb(1,i)))
10959 if (gradb_norm.gt.gradb_max) gradb_max=gradb_norm
10960 ghpbc_norm=dsqrt(scalar(ghpbc(1,i),ghpbc(1,i)))
10961 if (ghpbc_norm.gt.ghpbc_max) ghpbc_max=ghpbc_norm
10962 gradcorr_norm=dsqrt(scalar(gradcorr(1,i),gradcorr(1,i)))
10963 if (gradcorr_norm.gt.gradcorr_max) gradcorr_max=gradcorr_norm
10964 gel_loc_norm=dsqrt(scalar(gel_loc(1,i),gel_loc(1,i)))
10965 if (gel_loc_norm.gt.gel_loc_max) gel_loc_max=gel_loc_norm
10966 gcorr3_turn_norm=dsqrt(scalar(gcorr3_turn(1,i),&
10968 if (gcorr3_turn_norm.gt.gcorr3_turn_max) &
10969 gcorr3_turn_max=gcorr3_turn_norm
10970 gcorr4_turn_norm=dsqrt(scalar(gcorr4_turn(1,i),&
10972 if (gcorr4_turn_norm.gt.gcorr4_turn_max) &
10973 gcorr4_turn_max=gcorr4_turn_norm
10974 gradcorr5_norm=dsqrt(scalar(gradcorr5(1,i),gradcorr5(1,i)))
10975 if (gradcorr5_norm.gt.gradcorr5_max) &
10976 gradcorr5_max=gradcorr5_norm
10977 gradcorr6_norm=dsqrt(scalar(gradcorr6(1,i),gradcorr6(1,i)))
10978 if (gradcorr6_norm.gt.gradcorr6_max) gcorr6_max=gradcorr6_norm
10979 gcorr6_turn_norm=dsqrt(scalar(gcorr6_turn(1,i),&
10981 if (gcorr6_turn_norm.gt.gcorr6_turn_max) &
10982 gcorr6_turn_max=gcorr6_turn_norm
10983 gsccorr_norm=dsqrt(scalar(gsccorc(1,i),gsccorc(1,i)))
10984 if (gsccorr_norm.gt.gsccorr_max) gsccorr_max=gsccorr_norm
10985 gscloc_norm=dsqrt(scalar(gscloc(1,i),gscloc(1,i)))
10986 if (gscloc_norm.gt.gscloc_max) gscloc_max=gscloc_norm
10987 gvdwx_norm=dsqrt(scalar(gvdwx(1,i),gvdwx(1,i)))
10988 if (gvdwx_norm.gt.gvdwx_max) gvdwx_max=gvdwx_norm
10989 gradx_scp_norm=dsqrt(scalar(gradx_scp(1,i),gradx_scp(1,i)))
10990 if (gradx_scp_norm.gt.gradx_scp_max) &
10991 gradx_scp_max=gradx_scp_norm
10992 ghpbx_norm=dsqrt(scalar(ghpbx(1,i),ghpbx(1,i)))
10993 if (ghpbx_norm.gt.ghpbx_max) ghpbx_max=ghpbx_norm
10994 gradxorr_norm=dsqrt(scalar(gradxorr(1,i),gradxorr(1,i)))
10995 if (gradxorr_norm.gt.gradxorr_max) gradxorr_max=gradxorr_norm
10996 gsccorrx_norm=dsqrt(scalar(gsccorx(1,i),gsccorx(1,i)))
10997 if (gsccorrx_norm.gt.gsccorrx_max) gsccorrx_max=gsccorrx_norm
10998 gsclocx_norm=dsqrt(scalar(gsclocx(1,i),gsclocx(1,i)))
10999 if (gsclocx_norm.gt.gsclocx_max) gsclocx_max=gsclocx_norm
11003 open(istat,file=statname,position="append")
11005 open(istat,file=statname,access="append")
11007 write (istat,'(1h#,21f10.2)') gvdwc_max,gvdwc_scp_max,&
11008 gelc_max,gvdwpp_max,gradb_max,ghpbc_max,&
11009 gradcorr_max,gel_loc_max,gcorr3_turn_max,gcorr4_turn_max,&
11010 gradcorr5_max,gradcorr6_max,gcorr6_turn_max,gsccorc_max,&
11011 gscloc_max,gvdwx_max,gradx_scp_max,ghpbx_max,gradxorr_max,&
11012 gsccorx_max,gsclocx_max
11014 if (gvdwc_max.gt.1.0d4) then
11015 write (iout,*) "gvdwc gvdwx gradb gradbx"
11017 write(iout,'(i5,4(3f10.2,5x))') i,(gvdwc(j,i),gvdwx(j,i),&
11018 gradb(j,i),gradbx(j,i),j=1,3)
11020 call pdbout(0.0d0,'cipiszcze',iout)
11027 write (iout,*) "gradc gradx gloc"
11029 write (iout,'(i5,3f10.5,5x,3f10.5,5x,f10.5)') &
11030 i,(gradc(j,i,icg),j=1,3),(gradx(j,i,icg),j=1,3),gloc(i,icg)
11035 time_sumgradient=time_sumgradient+MPI_Wtime()-time01
11038 end subroutine sum_gradient
11039 !-----------------------------------------------------------------------------
11041 ! implicit real*8 (a-h,o-z)
11043 ! include 'DIMENSIONS'
11044 ! include 'COMMON.CHAIN'
11045 ! include 'COMMON.DERIV'
11046 ! include 'COMMON.CALC'
11047 ! include 'COMMON.IOUNITS'
11048 real(kind=8), dimension(3) :: dcosom1,dcosom2
11049 ! print *,"wchodze"
11050 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
11051 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
11052 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12 &
11053 -2.0D0*alf12*eps3der+sigder*sigsq_om12
11057 ! eom12=evdwij*eps1_om12
11059 ! write (iout,*) "eps2der",eps2der," eps3der",eps3der,&
11061 ! write (iout,*) "eps1_om12",eps1_om12," eps2rt_om12",eps2rt_om12
11062 ! write (iout,*) "eom1",eom1," eom2",eom2," eom12",eom12
11063 !C print *,sss_ele_cut,'in sc_grad'
11065 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
11066 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
11069 gg(k)=(gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k))*sss_ele_cut
11070 !C print *,'gg',k,gg(k)
11072 ! print *,i,j,gg_lipi(3),gg_lipj(3),sss_ele_cut
11073 ! write (iout,*) "gg",(gg(k),k=1,3)
11075 gvdwx(k,i)=gvdwx(k,i)-gg(k) +gg_lipi(k)&
11076 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
11077 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv &
11080 gvdwx(k,j)=gvdwx(k,j)+gg(k)+gg_lipj(k)&
11081 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
11082 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv &
11085 ! write (iout,*)(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
11086 ! +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
11087 ! write (iout,*)(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
11088 ! +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
11091 ! Calculate the components of the gradient in DC and X
11095 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
11099 gvdwc(l,i)=gvdwc(l,i)-gg(l)+gg_lipi(l)
11100 gvdwc(l,j)=gvdwc(l,j)+gg(l)+gg_lipj(l)
11103 end subroutine sc_grad
11105 !-----------------------------------------------------------------------------
11106 subroutine mixder(thetai,thet_pred_mean,theta0i,E_tc_t)
11109 ! implicit real*8 (a-h,o-z)
11110 ! include 'DIMENSIONS'
11111 ! include 'COMMON.LOCAL'
11112 ! include 'COMMON.IOUNITS'
11113 !el real(kind=8) :: term1,term2,termm,diffak,ratak,&
11114 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
11115 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,
11116 real(kind=8) :: thetai,thet_pred_mean,theta0i,E_tc_t
11117 real(kind=8) :: t3,t6,t9,t12,t14,t16,t21,t23,t26,t27,t32,t40
11119 !el common /calcthet/ term1,term2,termm,diffak,ratak,&
11120 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
11121 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,it
11122 !el local variables
11124 delthec=thetai-thet_pred_mean
11125 delthe0=thetai-theta0i
11126 ! "Thank you" to MAPLE (probably spared one day of hand-differentiation).
11127 t3 = thetai-thet_pred_mean
11131 t14 = t12+t6*sigsqtc
11133 t21 = thetai-theta0i
11139 E_tc_t = -((sigcsq+2.D0*t3*sigsqtc)*t9-t14*sigcsq*t3*t16*t9 &
11140 -aktc*sig0inv*t27)/t32+(t14*t9+aktc*t26)/t40 &
11141 *(-t12*t9-ak*sig0inv*t27)
11143 end subroutine mixder
11145 !-----------------------------------------------------------------------------
11147 !-----------------------------------------------------------------------------
11149 !-----------------------------------------------------------------------------
11150 ! This subroutine calculates the derivatives of the consecutive virtual
11151 ! bond vectors and the SC vectors in the virtual-bond angles theta and
11152 ! virtual-torsional angles phi, as well as the derivatives of SC vectors
11153 ! in the angles alpha and omega, describing the location of a side chain
11154 ! in its local coordinate system.
11156 ! The derivatives are stored in the following arrays:
11158 ! DDCDV - the derivatives of virtual-bond vectors DC in theta and phi.
11159 ! The structure is as follows:
11161 ! dDC(x,2)/dT(3),...,dDC(z,2)/dT(3),0, 0, 0
11162 ! 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)
11163 ! . . . . . . . . . . . . . . . . . .
11164 ! 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)
11168 ! 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)
11170 ! DXDV - the derivatives of the side-chain vectors in theta and phi.
11171 ! The structure is same as above.
11173 ! DCDS - the derivatives of the side chain vectors in the local spherical
11174 ! andgles alph and omega:
11176 ! 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)
11177 ! 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)
11181 ! 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)
11183 ! Version of March '95, based on an early version of November '91.
11185 !**********************************************************************
11186 ! implicit real*8 (a-h,o-z)
11187 ! include 'DIMENSIONS'
11188 ! include 'COMMON.VAR'
11189 ! include 'COMMON.CHAIN'
11190 ! include 'COMMON.DERIV'
11191 ! include 'COMMON.GEO'
11192 ! include 'COMMON.LOCAL'
11193 ! include 'COMMON.INTERACT'
11194 real(kind=8),dimension(3,3,nres) :: drt,rdt,prordt,prodrt !(3,3,maxres)
11195 real(kind=8),dimension(3,3) :: dp,temp
11196 !el real(kind=8) :: fromto(3,3,maxdim) !(3,3,maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
11197 real(kind=8),dimension(3) :: xx,xx1
11198 !el local variables
11199 integer :: i,k,l,j,m,ind,ind1,jjj
11200 real(kind=8) :: alphi,omegi,theta2,dpkl,dpjk,xj,rj,dxoijk,dxoiij,&
11201 tempkl,dsci,cosalphi,sinalphi,cosomegi,sinomegi,cost2,&
11202 sint2,xp,yp,xxp,yyp,zzp,dj
11204 ! common /przechowalnia/ fromto
11205 if(.not. allocated(fromto)) allocate(fromto(3,3,maxdim))
11206 ! get the position of the jth ijth fragment of the chain coordinate system
11207 ! in the fromto array.
11208 ! indmat(i,j)=((2*(nres-2)-i)*(i-1))/2+j-1
11210 ! maxdim=(nres-1)*(nres-2)/2
11211 ! allocate(dcdv(6,maxdim),dxds(6,nres))
11212 ! calculate the derivatives of transformation matrix elements in theta
11215 !el call flush(iout) !el
11217 rdt(1,1,i)=-rt(1,2,i)
11218 rdt(1,2,i)= rt(1,1,i)
11220 rdt(2,1,i)=-rt(2,2,i)
11221 rdt(2,2,i)= rt(2,1,i)
11223 rdt(3,1,i)=-rt(3,2,i)
11224 rdt(3,2,i)= rt(3,1,i)
11228 ! derivatives in phi
11234 drt(2,1,i)= rt(3,1,i)
11235 drt(2,2,i)= rt(3,2,i)
11236 drt(2,3,i)= rt(3,3,i)
11237 drt(3,1,i)=-rt(2,1,i)
11238 drt(3,2,i)=-rt(2,2,i)
11239 drt(3,3,i)=-rt(2,3,i)
11242 ! generate the matrix products of type r(i)t(i)...r(j)t(j)
11248 temp(k,l)=rt(k,l,i)
11253 fromto(k,l,ind)=temp(k,l)
11262 dpkl=dpkl+temp(k,m)*rt(m,l,j)
11265 fromto(k,l,ind)=dpkl
11276 ! Calculate derivatives.
11282 ! Derivatives of DC(i+1) in theta(i+2)
11288 dpjk=dpjk+prod(j,l,i)*rdt(l,k,i)
11291 prordt(j,k,i)=dp(j,k)
11294 dcdv(j,ind1)=vbld(i+1)*dp(j,1)
11297 ! Derivatives of SC(i+1) in theta(i+2)
11299 xx1(1)=-0.5D0*xloc(2,i+1)
11300 xx1(2)= 0.5D0*xloc(1,i+1)
11304 xj=xj+r(j,k,i)*xx1(k)
11311 rj=rj+prod(j,k,i)*xx(k)
11316 ! Derivatives of SC(i+1) in theta(i+3). The have to be handled differently
11317 ! than the other off-diagonal derivatives.
11322 dxoiij=dxoiij+dp(j,k)*xrot(k,i+2)
11324 dxdv(j,ind1+1)=dxoiij
11326 !d print *,ind1+1,(dxdv(j,ind1+1),j=1,3)
11328 ! Derivatives of DC(i+1) in phi(i+2)
11334 dpjk=dpjk+prod(j,l,i)*drt(l,k,i)
11337 prodrt(j,k,i)=dp(j,k)
11339 dcdv(j+3,ind1)=vbld(i+1)*dp(j,1)
11342 ! Derivatives of SC(i+1) in phi(i+2)
11345 xx(3)= xloc(2,i+1)*r(2,2,i)+xloc(3,i+1)*r(2,3,i)
11346 xx(2)=-xloc(2,i+1)*r(3,2,i)-xloc(3,i+1)*r(3,3,i)
11350 rj=rj+prod(j,k,i)*xx(k)
11355 ! Derivatives of SC(i+1) in phi(i+3).
11360 dxoiij=dxoiij+dp(j,k)*xrot(k,i+2)
11362 dxdv(j+3,ind1+1)=dxoiij
11365 ! Calculate the derivatives of DC(i+1) and SC(i+1) in theta(i+3) thru
11366 ! theta(nres) and phi(i+3) thru phi(nres).
11370 ind=indmat(i+1,j+1)
11371 !d print *,'i=',i,' j=',j,' ind=',ind,' ind1=',ind1
11376 tempkl=tempkl+prordt(k,m,i)*fromto(m,l,ind)
11381 !d print '(9f8.3)',((fromto(k,l,ind),l=1,3),k=1,3)
11382 !d print '(9f8.3)',((prod(k,l,i),l=1,3),k=1,3)
11383 !d print '(9f8.3)',((temp(k,l),l=1,3),k=1,3)
11384 ! Derivatives of virtual-bond vectors in theta
11386 dcdv(k,ind1)=vbld(i+1)*temp(k,1)
11388 !d print '(3f8.3)',(dcdv(k,ind1),k=1,3)
11389 ! Derivatives of SC vectors in theta
11393 dxoijk=dxoijk+temp(k,l)*xrot(l,j+2)
11395 dxdv(k,ind1+1)=dxoijk
11398 !--- Calculate the derivatives in phi
11404 tempkl=tempkl+prodrt(k,m,i)*fromto(m,l,ind)
11410 dcdv(k+3,ind1)=vbld(i+1)*temp(k,1)
11415 dxoijk=dxoijk+temp(k,l)*xrot(l,j+2)
11417 dxdv(k+3,ind1+1)=dxoijk
11422 ! Derivatives in alpha and omega:
11425 ! dsci=dsc(itype(i,1))
11430 if(alphi.ne.alphi) alphi=100.0
11431 if(omegi.ne.omegi) omegi=-100.0
11436 !d print *,'i=',i,' dsci=',dsci,' alphi=',alphi,' omegi=',omegi
11437 cosalphi=dcos(alphi)
11438 sinalphi=dsin(alphi)
11439 cosomegi=dcos(omegi)
11440 sinomegi=dsin(omegi)
11441 temp(1,1)=-dsci*sinalphi
11442 temp(2,1)= dsci*cosalphi*cosomegi
11443 temp(3,1)=-dsci*cosalphi*sinomegi
11445 temp(2,2)=-dsci*sinalphi*sinomegi
11446 temp(3,2)=-dsci*sinalphi*cosomegi
11447 theta2=pi-0.5D0*theta(i+1)
11451 !d print *,((temp(l,k),l=1,3),k=1,2)
11455 xxp= xp*cost2+yp*sint2
11456 yyp=-xp*sint2+yp*cost2
11459 xx(2)=yyp*r(2,2,i-1)+zzp*r(2,3,i-1)
11460 xx(3)=yyp*r(3,2,i-1)+zzp*r(3,3,i-1)
11464 dj=dj+prod(k,l,i-1)*xx(l)
11472 end subroutine cartder
11473 !-----------------------------------------------------------------------------
11475 !-----------------------------------------------------------------------------
11476 subroutine check_cartgrad
11477 ! Check the gradient of Cartesian coordinates in internal coordinates.
11478 ! implicit real*8 (a-h,o-z)
11479 ! include 'DIMENSIONS'
11480 ! include 'COMMON.IOUNITS'
11481 ! include 'COMMON.VAR'
11482 ! include 'COMMON.CHAIN'
11483 ! include 'COMMON.GEO'
11484 ! include 'COMMON.LOCAL'
11485 ! include 'COMMON.DERIV'
11486 real(kind=8),dimension(6,nres) :: temp
11487 real(kind=8),dimension(3) :: xx,gg
11488 integer :: i,k,j,ii
11489 real(kind=8) :: aincr,aincr2,alphi,omegi,theti,thet,phii
11490 ! indmat(i,j)=((2*(nres-2)-i)*(i-1))/2+j-1
11492 ! Check the gradient of the virtual-bond and SC vectors in the internal
11498 write (iout,'(a)') '**************** dx/dalpha'
11502 alph(i)=alph(i)+aincr
11504 temp(k,i)=dc(k,nres+i)
11508 gg(k)=(dc(k,nres+i)-temp(k,i))/aincr
11509 xx(k)=dabs((gg(k)-dxds(k,i))/(aincr*dabs(dxds(k,i))+aincr))
11511 write (iout,'(i4,3e15.6/4x,3e15.6,3f9.3)') &
11512 i,(gg(k),k=1,3),(dxds(k,i),k=1,3),(xx(k),k=1,3)
11518 write (iout,'(a)') '**************** dx/domega'
11522 omeg(i)=omeg(i)+aincr
11524 temp(k,i)=dc(k,nres+i)
11528 gg(k)=(dc(k,nres+i)-temp(k,i))/aincr
11529 xx(k)=dabs((gg(k)-dxds(k+3,i))/ &
11530 (aincr*dabs(dxds(k+3,i))+aincr))
11532 write (iout,'(i4,3e15.6/4x,3e15.6,3f9.3)') &
11533 i,(gg(k),k=1,3),(dxds(k+3,i),k=1,3),(xx(k),k=1,3)
11539 write (iout,'(a)') '**************** dx/dtheta'
11543 theta(i)=theta(i)+aincr
11546 temp(k,j)=dc(k,nres+j)
11552 ! print *,'i=',i-2,' j=',j-1,' ii=',ii
11554 gg(k)=(dc(k,nres+j)-temp(k,j))/aincr
11555 xx(k)=dabs((gg(k)-dxdv(k,ii))/ &
11556 (aincr*dabs(dxdv(k,ii))+aincr))
11558 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
11559 i,j,(gg(k),k=1,3),(dxdv(k,ii),k=1,3),(xx(k),k=1,3)
11566 write (iout,'(a)') '***************** dx/dphi'
11569 phi(i)=phi(i)+aincr
11572 temp(k,j)=dc(k,nres+j)
11580 gg(k)=(dc(k,nres+j)-temp(k,j))/aincr
11581 xx(k)=dabs((gg(k)-dxdv(k+3,ii))/ &
11582 (aincr*dabs(dxdv(k+3,ii))+aincr))
11584 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
11585 i,j,(gg(k),k=1,3),(dxdv(k+3,ii),k=1,3),(xx(k),k=1,3)
11588 phi(i)=phi(i)-aincr
11591 write (iout,'(a)') '****************** ddc/dtheta'
11594 theta(i+2)=thet+aincr
11605 gg(k)=(dc(k,j)-temp(k,j))/aincr
11606 xx(k)=dabs((gg(k)-dcdv(k,ii))/ &
11607 (aincr*dabs(dcdv(k,ii))+aincr))
11609 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
11610 i,j,(gg(k),k=1,3),(dcdv(k,ii),k=1,3),(xx(k),k=1,3)
11620 write (iout,'(a)') '******************* ddc/dphi'
11623 phi(i+3)=phii+aincr
11634 gg(k)=(dc(k,j)-temp(k,j))/aincr
11635 xx(k)=dabs((gg(k)-dcdv(k+3,ii))/ &
11636 (aincr*dabs(dcdv(k+3,ii))+aincr))
11638 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
11639 i,j,(gg(k),k=1,3),(dcdv(k+3,ii),k=1,3),(xx(k),k=1,3)
11650 end subroutine check_cartgrad
11651 !-----------------------------------------------------------------------------
11652 subroutine check_ecart
11653 ! Check the gradient of the energy in Cartesian coordinates.
11654 ! implicit real*8 (a-h,o-z)
11655 ! include 'DIMENSIONS'
11656 ! include 'COMMON.CHAIN'
11657 ! include 'COMMON.DERIV'
11658 ! include 'COMMON.IOUNITS'
11659 ! include 'COMMON.VAR'
11660 ! include 'COMMON.CONTACTS'
11662 !el integer :: icall
11663 !el common /srutu/ icall
11664 real(kind=8),dimension(6) :: ggg
11665 real(kind=8),dimension(3) :: cc,xx,ddc,ddx
11666 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
11667 real(kind=8),dimension(6,nres) :: grad_s
11668 real(kind=8),dimension(0:n_ene) :: energia,energia1
11669 integer :: uiparm(1)
11670 real(kind=8) :: urparm(1)
11672 integer :: nf,i,j,k
11673 real(kind=8) :: aincr,etot,etot1
11679 print '(a)','CG processor',me,' calling CHECK_CART.',aincr
11682 call geom_to_var(nvar,x)
11683 call etotal(energia)
11685 !el call enerprint(energia)
11686 call gradient(nvar,x,nf,g,uiparm,urparm,fdum)
11689 write (iout,'(i5,3f10.5)') i,(gradxorr(j,i),j=1,3)
11693 grad_s(j,i)=gradc(j,i,icg)
11694 grad_s(j+3,i)=gradx(j,i,icg)
11698 write (iout,'(/a/)') 'Gradient in virtual-bond and SC vectors'
11703 ddx(j)=dc(j,i+nres)
11706 dc(j,i)=dc(j,i)+aincr
11708 c(j,k)=c(j,k)+aincr
11709 c(j,k+nres)=c(j,k+nres)+aincr
11711 call etotal(energia1)
11713 ggg(j)=(etot1-etot)/aincr
11716 c(j,k)=c(j,k)-aincr
11717 c(j,k+nres)=c(j,k+nres)-aincr
11721 c(j,i+nres)=c(j,i+nres)+aincr
11722 dc(j,i+nres)=dc(j,i+nres)+aincr
11723 call etotal(energia1)
11725 ggg(j+3)=(etot1-etot)/aincr
11727 dc(j,i+nres)=ddx(j)
11729 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/)') &
11730 i,(ggg(k),k=1,6),(grad_s(k,i),k=1,6)
11733 end subroutine check_ecart
11735 !-----------------------------------------------------------------------------
11736 subroutine check_ecartint
11737 ! Check the gradient of the energy in Cartesian coordinates.
11738 use io_base, only: intout
11739 ! implicit real*8 (a-h,o-z)
11740 ! include 'DIMENSIONS'
11741 ! include 'COMMON.CONTROL'
11742 ! include 'COMMON.CHAIN'
11743 ! include 'COMMON.DERIV'
11744 ! include 'COMMON.IOUNITS'
11745 ! include 'COMMON.VAR'
11746 ! include 'COMMON.CONTACTS'
11747 ! include 'COMMON.MD'
11748 ! include 'COMMON.LOCAL'
11749 ! include 'COMMON.SPLITELE'
11751 !el integer :: icall
11752 !el common /srutu/ icall
11753 real(kind=8),dimension(6) :: ggg,ggg1
11754 real(kind=8),dimension(3) :: cc,xx,ddc,ddx,ddc1,ddcn
11755 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
11756 real(kind=8),dimension(3) :: dcnorm_safe1,dcnorm_safe2,dxnorm_safe
11757 real(kind=8),dimension(6,0:nres) :: grad_s,grad_s1 !(6,0:maxres)
11758 real(kind=8),dimension(nres) :: phi_temp,theta_temp,alph_temp,omeg_temp !(maxres)
11759 real(kind=8),dimension(0:n_ene) :: energia,energia1
11760 integer :: uiparm(1)
11761 real(kind=8) :: urparm(1)
11763 integer :: i,j,k,nf
11764 real(kind=8) :: rlambd,aincr,etot,etot1,etot11,etot12,etot2,&
11772 ! call intcartderiv
11773 ! call checkintcartgrad
11776 write(iout,*) 'Calling CHECK_ECARTINT.'
11779 write (iout,*) "Before geom_to_var"
11780 call geom_to_var(nvar,x)
11781 write (iout,*) "after geom_to_var"
11782 write (iout,*) "split_ene ",split_ene
11784 if (.not.split_ene) then
11785 write(iout,*) 'Calling CHECK_ECARTINT if'
11786 call etotal(energia)
11787 !elwrite(iout,*) 'Calling CHECK_ECARTINT if'
11789 write (iout,*) "etot",etot
11791 !el call enerprint(energia)
11792 !elwrite(iout,*) 'Calling CHECK_ECARTINT if'
11794 write (iout,*) "enter cartgrad"
11797 !elwrite(iout,*) 'Calling CHECK_ECARTINT if'
11798 write (iout,*) "exit cartgrad"
11802 write (iout,'(i5,3f10.5)') i,(gradxorr(j,i),j=1,3)
11805 grad_s(j,0)=gcart(j,0)
11807 !elwrite(iout,*) 'Calling CHECK_ECARTINT if'
11810 grad_s(j,i)=gcart(j,i)
11811 grad_s(j+3,i)=gxcart(j,i)
11815 write(iout,*) 'Calling CHECK_ECARTIN else.'
11816 !- split gradient check
11818 call etotal_long(energia)
11819 !el call enerprint(energia)
11821 write (iout,*) "enter cartgrad"
11824 write (iout,*) "exit cartgrad"
11827 write (iout,*) "longrange grad"
11829 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
11830 (gxcart(j,i),j=1,3)
11833 grad_s(j,0)=gcart(j,0)
11837 grad_s(j,i)=gcart(j,i)
11838 grad_s(j+3,i)=gxcart(j,i)
11842 call etotal_short(energia)
11843 call enerprint(energia)
11845 write (iout,*) "enter cartgrad"
11848 write (iout,*) "exit cartgrad"
11851 write (iout,*) "shortrange grad"
11853 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
11854 (gxcart(j,i),j=1,3)
11857 grad_s1(j,0)=gcart(j,0)
11861 grad_s1(j,i)=gcart(j,i)
11862 grad_s1(j+3,i)=gxcart(j,i)
11866 write (iout,'(/a/)') 'Gradient in virtual-bond and SC vectors'
11870 if (nnt.gt.1 .and. i.eq.nnt) ddc1(j)=c(j,1)
11871 if (nct.lt.nres .and. i.eq.nct) ddcn(j)=c(j,nres)
11874 dcnorm_safe1(j)=dc_norm(j,i-1)
11875 dcnorm_safe2(j)=dc_norm(j,i)
11876 dxnorm_safe(j)=dc_norm(j,i+nres)
11879 c(j,i)=ddc(j)+aincr
11880 if (nnt.gt.1 .and. i.eq.nnt) c(j,1)=c(j,1)+aincr
11881 if (nct.lt.nres .and. i.eq.nct) c(j,nres)=c(j,nres)+aincr
11882 if (i.gt.1) dc(j,i-1)=c(j,i)-c(j,i-1)
11883 dc(j,i)=c(j,i+1)-c(j,i)
11884 dc(j,i+nres)=c(j,i+nres)-c(j,i)
11885 call int_from_cart1(.false.)
11886 if (.not.split_ene) then
11887 call etotal(energia1)
11889 write (iout,*) "ij",i,j," etot1",etot1
11892 call etotal_long(energia1)
11894 call etotal_short(energia1)
11897 !- end split gradient
11898 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot1",etot1
11899 c(j,i)=ddc(j)-aincr
11900 if (nnt.gt.1 .and. i.eq.nnt) c(j,1)=ddc1(j)-aincr
11901 if (nct.lt.nres .and. i.eq.nct) c(j,nres)=ddcn(j)-aincr
11902 if (i.gt.1) dc(j,i-1)=c(j,i)-c(j,i-1)
11903 dc(j,i)=c(j,i+1)-c(j,i)
11904 dc(j,i+nres)=c(j,i+nres)-c(j,i)
11905 call int_from_cart1(.false.)
11906 if (.not.split_ene) then
11907 call etotal(energia1)
11909 write (iout,*) "ij",i,j," etot2",etot2
11910 ggg(j)=(etot1-etot2)/(2*aincr)
11913 call etotal_long(energia1)
11915 ggg(j)=(etot11-etot21)/(2*aincr)
11916 call etotal_short(energia1)
11918 ggg1(j)=(etot12-etot22)/(2*aincr)
11919 !- end split gradient
11920 ! write (iout,*) "etot21",etot21," etot22",etot22
11922 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
11924 if (nnt.gt.1 .and. i.eq.nnt) c(j,1)=ddc1(j)
11925 if (nct.lt.nres .and. i.eq.nct) c(j,nres)=ddcn(j)
11926 if (i.gt.1) dc(j,i-1)=c(j,i)-c(j,i-1)
11927 dc(j,i)=c(j,i+1)-c(j,i)
11928 dc(j,i+nres)=c(j,i+nres)-c(j,i)
11929 dc_norm(j,i-1)=dcnorm_safe1(j)
11930 dc_norm(j,i)=dcnorm_safe2(j)
11931 dc_norm(j,i+nres)=dxnorm_safe(j)
11934 c(j,i+nres)=ddx(j)+aincr
11935 dc(j,i+nres)=c(j,i+nres)-c(j,i)
11936 call int_from_cart1(.false.)
11937 if (.not.split_ene) then
11938 call etotal(energia1)
11942 call etotal_long(energia1)
11944 call etotal_short(energia1)
11947 !- end split gradient
11948 c(j,i+nres)=ddx(j)-aincr
11949 dc(j,i+nres)=c(j,i+nres)-c(j,i)
11950 call int_from_cart1(.false.)
11951 if (.not.split_ene) then
11952 call etotal(energia1)
11954 ggg(j+3)=(etot1-etot2)/(2*aincr)
11957 call etotal_long(energia1)
11959 ggg(j+3)=(etot11-etot21)/(2*aincr)
11960 call etotal_short(energia1)
11962 ggg1(j+3)=(etot12-etot22)/(2*aincr)
11963 !- end split gradient
11965 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
11967 dc(j,i+nres)=c(j,i+nres)-c(j,i)
11968 dc_norm(j,i+nres)=dxnorm_safe(j)
11969 call int_from_cart1(.false.)
11971 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
11972 i,(ggg(k),k=1,6),(grad_s(k,i),k=1,6),(ggg(k)/grad_s(k,i),k=1,6)
11973 if (split_ene) then
11974 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
11975 i,(ggg1(k),k=1,6),(grad_s1(k,i),k=1,6),(ggg1(k)/grad_s1(k,i),&
11977 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
11978 i,(ggg(k)+ggg1(k),k=1,6),(grad_s(k,i)+grad_s1(k,i),k=1,6),&
11979 ((ggg(k)+ggg1(k))/(grad_s(k,i)+grad_s1(k,i)),k=1,6)
11983 end subroutine check_ecartint
11985 !-----------------------------------------------------------------------------
11986 subroutine check_ecartint
11987 ! Check the gradient of the energy in Cartesian coordinates.
11988 use io_base, only: intout
11989 ! implicit real*8 (a-h,o-z)
11990 ! include 'DIMENSIONS'
11991 ! include 'COMMON.CONTROL'
11992 ! include 'COMMON.CHAIN'
11993 ! include 'COMMON.DERIV'
11994 ! include 'COMMON.IOUNITS'
11995 ! include 'COMMON.VAR'
11996 ! include 'COMMON.CONTACTS'
11997 ! include 'COMMON.MD'
11998 ! include 'COMMON.LOCAL'
11999 ! include 'COMMON.SPLITELE'
12001 !el integer :: icall
12002 !el common /srutu/ icall
12003 real(kind=8),dimension(6) :: ggg,ggg1
12004 real(kind=8),dimension(3) :: cc,xx,ddc,ddx
12005 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
12006 real(kind=8),dimension(3) :: dcnorm_safe,dxnorm_safe
12007 real(kind=8),dimension(6,0:nres) :: grad_s,grad_s1 !(6,0:maxres)
12008 real(kind=8),dimension(nres) :: phi_temp,theta_temp,alph_temp,omeg_temp !(maxres)
12009 real(kind=8),dimension(0:n_ene) :: energia,energia1
12010 integer :: uiparm(1)
12011 real(kind=8) :: urparm(1)
12013 integer :: i,j,k,nf
12014 real(kind=8) :: rlambd,aincr,etot,etot1,etot11,etot12,etot2,&
12022 ! call intcartderiv
12023 ! call checkintcartgrad
12026 write(iout,*) 'Calling CHECK_ECARTINT.',aincr
12029 call geom_to_var(nvar,x)
12030 if (.not.split_ene) then
12031 call etotal(energia)
12033 !el call enerprint(energia)
12035 write (iout,*) "enter cartgrad"
12038 write (iout,*) "exit cartgrad"
12042 write (iout,'(i5,3f10.5)') i,(gradxorr(j,i),j=1,3)
12045 grad_s(j,0)=gcart(j,0)
12049 grad_s(j,i)=gcart(j,i)
12050 ! if (i.le.2) print *,"tu?!",gcart(j,i),grad_s(j,i),gxcart(j,i)
12051 grad_s(j+3,i)=gxcart(j,i)
12055 !- split gradient check
12057 call etotal_long(energia)
12058 !el call enerprint(energia)
12060 write (iout,*) "enter cartgrad"
12063 write (iout,*) "exit cartgrad"
12066 write (iout,*) "longrange grad"
12068 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
12069 (gxcart(j,i),j=1,3)
12072 grad_s(j,0)=gcart(j,0)
12076 grad_s(j,i)=gcart(j,i)
12077 grad_s(j+3,i)=gxcart(j,i)
12081 call etotal_short(energia)
12082 !el call enerprint(energia)
12084 write (iout,*) "enter cartgrad"
12087 write (iout,*) "exit cartgrad"
12090 write (iout,*) "shortrange grad"
12092 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
12093 (gxcart(j,i),j=1,3)
12096 grad_s1(j,0)=gcart(j,0)
12100 grad_s1(j,i)=gcart(j,i)
12101 grad_s1(j+3,i)=gxcart(j,i)
12105 write (iout,'(/a/)') 'Gradient in virtual-bond and SC vectors'
12110 ddx(j)=dc(j,i+nres)
12112 dcnorm_safe(k)=dc_norm(k,i)
12113 dxnorm_safe(k)=dc_norm(k,i+nres)
12117 dc(j,i)=ddc(j)+aincr
12118 call chainbuild_cart
12120 ! Broadcast the order to compute internal coordinates to the slaves.
12121 ! if (nfgtasks.gt.1)
12122 ! & call MPI_Bcast(6,1,MPI_INTEGER,king,FG_COMM,IERROR)
12124 ! call int_from_cart1(.false.)
12125 if (.not.split_ene) then
12126 call etotal(energia1)
12128 ! call enerprint(energia1)
12131 call etotal_long(energia1)
12133 call etotal_short(energia1)
12135 ! write (iout,*) "etot11",etot11," etot12",etot12
12137 !- end split gradient
12138 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot1",etot1
12139 dc(j,i)=ddc(j)-aincr
12140 call chainbuild_cart
12141 ! call int_from_cart1(.false.)
12142 if (.not.split_ene) then
12143 call etotal(energia1)
12145 ggg(j)=(etot1-etot2)/(2*aincr)
12148 call etotal_long(energia1)
12150 ggg(j)=(etot11-etot21)/(2*aincr)
12151 call etotal_short(energia1)
12153 ggg1(j)=(etot12-etot22)/(2*aincr)
12154 !- end split gradient
12155 ! write (iout,*) "etot21",etot21," etot22",etot22
12157 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
12159 call chainbuild_cart
12162 dc(j,i+nres)=ddx(j)+aincr
12163 call chainbuild_cart
12164 ! write (iout,*) "i",i," j",j," dxnorm+ and dxnorm"
12165 ! write (iout,'(3f15.10)') (dc_norm(k,i+nres),k=1,3)
12166 ! write (iout,'(3f15.10)') (dxnorm_safe(k),k=1,3)
12167 ! write (iout,*) "dxnormnorm",dsqrt(
12168 ! & dc_norm(1,i+nres)**2+dc_norm(2,i+nres)**2+dc_norm(3,i+nres)**2)
12169 ! write (iout,*) "dxnormnormsafe",dsqrt(
12170 ! & dxnorm_safe(1)**2+dxnorm_safe(2)**2+dxnorm_safe(3)**2)
12172 if (.not.split_ene) then
12173 call etotal(energia1)
12177 call etotal_long(energia1)
12179 call etotal_short(energia1)
12182 !- end split gradient
12183 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot1",etot1
12184 dc(j,i+nres)=ddx(j)-aincr
12185 call chainbuild_cart
12186 ! write (iout,*) "i",i," j",j," dxnorm- and dxnorm"
12187 ! write (iout,'(3f15.10)') (dc_norm(k,i+nres),k=1,3)
12188 ! write (iout,'(3f15.10)') (dxnorm_safe(k),k=1,3)
12190 ! write (iout,*) "dxnormnorm",dsqrt(
12191 ! & dc_norm(1,i+nres)**2+dc_norm(2,i+nres)**2+dc_norm(3,i+nres)**2)
12192 ! write (iout,*) "dxnormnormsafe",dsqrt(
12193 ! & dxnorm_safe(1)**2+dxnorm_safe(2)**2+dxnorm_safe(3)**2)
12194 if (.not.split_ene) then
12195 call etotal(energia1)
12197 ggg(j+3)=(etot1-etot2)/(2*aincr)
12200 call etotal_long(energia1)
12202 ggg(j+3)=(etot11-etot21)/(2*aincr)
12203 call etotal_short(energia1)
12205 ggg1(j+3)=(etot12-etot22)/(2*aincr)
12206 !- end split gradient
12208 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
12209 dc(j,i+nres)=ddx(j)
12210 call chainbuild_cart
12212 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
12213 i,(ggg(k),k=1,6),(grad_s(k,i),k=1,6),(ggg(k)/grad_s(k,i),k=1,6)
12214 if (split_ene) then
12215 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
12216 i,(ggg1(k),k=1,6),(grad_s1(k,i),k=1,6),(ggg1(k)/grad_s1(k,i),&
12218 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
12219 i,(ggg(k)+ggg1(k),k=1,6),(grad_s(k,i)+grad_s1(k,i),k=1,6),&
12220 ((ggg(k)+ggg1(k))/(grad_s(k,i)+grad_s1(k,i)),k=1,6)
12224 end subroutine check_ecartint
12226 !-----------------------------------------------------------------------------
12227 subroutine check_eint
12228 ! Check the gradient of energy in internal coordinates.
12229 ! implicit real*8 (a-h,o-z)
12230 ! include 'DIMENSIONS'
12231 ! include 'COMMON.CHAIN'
12232 ! include 'COMMON.DERIV'
12233 ! include 'COMMON.IOUNITS'
12234 ! include 'COMMON.VAR'
12235 ! include 'COMMON.GEO'
12237 !el integer :: icall
12238 !el common /srutu/ icall
12239 real(kind=8),dimension(6*nres) :: x,gana,gg !(maxvar) (maxvar=6*maxres)
12240 integer :: uiparm(1)
12241 real(kind=8) :: urparm(1)
12242 real(kind=8),dimension(0:n_ene) :: energia,energia1,energia2
12243 character(len=6) :: key
12246 real(kind=8) :: xi,aincr,etot,etot1,etot2
12249 print '(a)','Calling CHECK_INT.'
12253 call geom_to_var(nvar,x)
12254 call var_to_geom(nvar,x)
12257 ! print *,'ICG=',ICG
12258 call etotal(energia)
12260 !el call enerprint(energia)
12261 ! print *,'ICG=',ICG
12263 if (MyID.ne.BossID) then
12264 call mp_bcast(x(1),8*(nvar+3),BossID,fgGroupID)
12272 !d write (iout,'(10f8.3)') (rad2deg*x(i),i=1,nvar)
12273 call gradient(nvar,x,nf,gana,uiparm,urparm,fdum)
12274 !d write (iout,'(i3,1pe14.4)') (i,gana(i),i=1,nvar+20) !sp
12278 x(i)=xi-0.5D0*aincr
12279 call var_to_geom(nvar,x)
12281 call etotal(energia1)
12283 x(i)=xi+0.5D0*aincr
12284 call var_to_geom(nvar,x)
12286 call etotal(energia2)
12288 gg(i)=(etot2-etot1)/aincr
12289 write (iout,*) i,etot1,etot2
12292 write (iout,'(/2a)')' Variable Numerical Analytical',&
12295 if (i.le.nphi) then
12298 else if (i.le.nphi+ntheta) then
12301 else if (i.le.nphi+ntheta+nside) then
12305 ii=i-(nphi+ntheta+nside)
12308 write (iout,'(i3,a,i3,3(1pd16.6))') &
12309 i,key,ii,gg(i),gana(i),&
12310 100.0D0*dabs(gg(i)-gana(i))/(dabs(gana(i))+aincr)
12313 end subroutine check_eint
12314 !-----------------------------------------------------------------------------
12316 !-----------------------------------------------------------------------------
12317 subroutine Econstr_back
12318 ! MD with umbrella_sampling using Wolyne's distance measure as a constraint
12319 ! implicit real*8 (a-h,o-z)
12320 ! include 'DIMENSIONS'
12321 ! include 'COMMON.CONTROL'
12322 ! include 'COMMON.VAR'
12323 ! include 'COMMON.MD'
12326 ! include 'COMMON.LANGEVIN'
12328 ! include 'COMMON.LANGEVIN.lang0'
12330 ! include 'COMMON.CHAIN'
12331 ! include 'COMMON.DERIV'
12332 ! include 'COMMON.GEO'
12333 ! include 'COMMON.LOCAL'
12334 ! include 'COMMON.INTERACT'
12335 ! include 'COMMON.IOUNITS'
12336 ! include 'COMMON.NAMES'
12337 ! include 'COMMON.TIME1'
12338 integer :: i,j,ii,k
12339 real(kind=8) :: utheta_i,dtheta_i,ugamma_i,dgamma_i,dxx,dyy,dzz
12341 if(.not.allocated(utheta)) allocate(utheta(nfrag_back))
12342 if(.not.allocated(ugamma)) allocate(ugamma(nfrag_back))
12343 if(.not.allocated(uscdiff)) allocate(uscdiff(nfrag_back))
12350 duscdiff(j,i)=0.0d0
12351 duscdiffx(j,i)=0.0d0
12355 ii = ifrag_back(2,i,iset)-ifrag_back(1,i,iset)
12357 ! Deviations from theta angles
12360 do j=ifrag_back(1,i,iset)+2,ifrag_back(2,i,iset)
12361 dtheta_i=theta(j)-thetaref(j)
12362 utheta_i=utheta_i+0.5d0*dtheta_i*dtheta_i
12363 dutheta(j-2)=dutheta(j-2)+wfrag_back(1,i,iset)*dtheta_i/(ii-1)
12365 utheta(i)=utheta_i/(ii-1)
12367 ! Deviations from gamma angles
12370 do j=ifrag_back(1,i,iset)+3,ifrag_back(2,i,iset)
12371 dgamma_i=pinorm(phi(j)-phiref(j))
12372 ! write (iout,*) j,phi(j),phi(j)-phiref(j)
12373 ugamma_i=ugamma_i+0.5d0*dgamma_i*dgamma_i
12374 dugamma(j-3)=dugamma(j-3)+wfrag_back(2,i,iset)*dgamma_i/(ii-2)
12375 ! write (iout,*) i,j,dgamma_i,wfrag_back(2,i,iset),dugamma(j-3)
12377 ugamma(i)=ugamma_i/(ii-2)
12379 ! Deviations from local SC geometry
12382 do j=ifrag_back(1,i,iset)+1,ifrag_back(2,i,iset)-1
12383 dxx=xxtab(j)-xxref(j)
12384 dyy=yytab(j)-yyref(j)
12385 dzz=zztab(j)-zzref(j)
12386 uscdiff(i)=uscdiff(i)+dxx*dxx+dyy*dyy+dzz*dzz
12388 duscdiff(k,j-1)=duscdiff(k,j-1)+wfrag_back(3,i,iset)* &
12389 (dXX_C1tab(k,j)*dxx+dYY_C1tab(k,j)*dyy+dZZ_C1tab(k,j)*dzz)/ &
12391 duscdiff(k,j)=duscdiff(k,j)+wfrag_back(3,i,iset)* &
12392 (dXX_Ctab(k,j)*dxx+dYY_Ctab(k,j)*dyy+dZZ_Ctab(k,j)*dzz)/ &
12394 duscdiffx(k,j)=duscdiffx(k,j)+wfrag_back(3,i,iset)* &
12395 (dXX_XYZtab(k,j)*dxx+dYY_XYZtab(k,j)*dyy+dZZ_XYZtab(k,j)*dzz) &
12398 ! write (iout,'(i5,6f10.5)') j,xxtab(j),yytab(j),zztab(j),
12399 ! & xxref(j),yyref(j),zzref(j)
12401 uscdiff(i)=0.5d0*uscdiff(i)/(ii-1)
12402 ! write (iout,*) i," uscdiff",uscdiff(i)
12404 ! Put together deviations from local geometry
12406 Uconst_back=Uconst_back+wfrag_back(1,i,iset)*utheta(i)+ &
12407 wfrag_back(2,i,iset)*ugamma(i)+wfrag_back(3,i,iset)*uscdiff(i)
12408 ! write(iout,*) "i",i," utheta",utheta(i)," ugamma",ugamma(i),
12409 ! & " uconst_back",uconst_back
12410 utheta(i)=dsqrt(utheta(i))
12411 ugamma(i)=dsqrt(ugamma(i))
12412 uscdiff(i)=dsqrt(uscdiff(i))
12415 end subroutine Econstr_back
12416 !-----------------------------------------------------------------------------
12417 ! energy_p_new-sep_barrier.F
12418 !-----------------------------------------------------------------------------
12419 real(kind=8) function sscale(r)
12420 ! include "COMMON.SPLITELE"
12421 real(kind=8) :: r,gamm
12422 if(r.lt.r_cut-rlamb) then
12424 else if(r.le.r_cut.and.r.ge.r_cut-rlamb) then
12425 gamm=(r-(r_cut-rlamb))/rlamb
12426 sscale=1.0d0+gamm*gamm*(2*gamm-3.0d0)
12431 end function sscale
12432 real(kind=8) function sscale_grad(r)
12433 ! include "COMMON.SPLITELE"
12434 real(kind=8) :: r,gamm
12435 if(r.lt.r_cut-rlamb) then
12437 else if(r.le.r_cut.and.r.ge.r_cut-rlamb) then
12438 gamm=(r-(r_cut-rlamb))/rlamb
12439 sscale_grad=gamm*(6*gamm-6.0d0)/rlamb
12444 end function sscale_grad
12446 !!!!!!!!!! PBCSCALE
12447 real(kind=8) function sscale_ele(r)
12448 ! include "COMMON.SPLITELE"
12449 real(kind=8) :: r,gamm
12450 if(r.lt.r_cut_ele-rlamb_ele) then
12452 else if(r.le.r_cut_ele.and.r.ge.r_cut_ele-rlamb_ele) then
12453 gamm=(r-(r_cut_ele-rlamb_ele))/rlamb_ele
12454 sscale_ele=1.0d0+gamm*gamm*(2*gamm-3.0d0)
12459 end function sscale_ele
12461 real(kind=8) function sscagrad_ele(r)
12462 real(kind=8) :: r,gamm
12463 ! include "COMMON.SPLITELE"
12464 if(r.lt.r_cut_ele-rlamb_ele) then
12466 else if(r.le.r_cut_ele.and.r.ge.r_cut_ele-rlamb_ele) then
12467 gamm=(r-(r_cut_ele-rlamb_ele))/rlamb_ele
12468 sscagrad_ele=gamm*(6*gamm-6.0d0)/rlamb_ele
12473 end function sscagrad_ele
12474 real(kind=8) function sscalelip(r)
12475 real(kind=8) r,gamm
12476 sscalelip=1.0d0+r*r*(2.0d0*r-3.0d0)
12478 end function sscalelip
12479 !C-----------------------------------------------------------------------
12480 real(kind=8) function sscagradlip(r)
12481 real(kind=8) r,gamm
12482 sscagradlip=r*(6.0d0*r-6.0d0)
12484 end function sscagradlip
12487 !-----------------------------------------------------------------------------
12488 subroutine elj_long(evdw)
12490 ! This subroutine calculates the interaction energy of nonbonded side chains
12491 ! assuming the LJ potential of interaction.
12493 ! implicit real*8 (a-h,o-z)
12494 ! include 'DIMENSIONS'
12495 ! include 'COMMON.GEO'
12496 ! include 'COMMON.VAR'
12497 ! include 'COMMON.LOCAL'
12498 ! include 'COMMON.CHAIN'
12499 ! include 'COMMON.DERIV'
12500 ! include 'COMMON.INTERACT'
12501 ! include 'COMMON.TORSION'
12502 ! include 'COMMON.SBRIDGE'
12503 ! include 'COMMON.NAMES'
12504 ! include 'COMMON.IOUNITS'
12505 ! include 'COMMON.CONTACTS'
12506 real(kind=8),parameter :: accur=1.0d-10
12507 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
12508 !el local variables
12509 integer :: i,iint,j,k,itypi,itypi1,itypj
12510 real(kind=8) :: xi,yi,zi,xj,yj,zj,rij,sss,rrij,fac,eps0ij
12511 real(kind=8) :: e1,e2,evdwij,evdw
12512 ! write(iout,*)'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
12514 do i=iatsc_s,iatsc_e
12516 if (itypi.eq.ntyp1) cycle
12517 itypi1=itype(i+1,1)
12522 ! Calculate SC interaction energy.
12524 do iint=1,nint_gr(i)
12525 !d write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
12526 !d & 'iend=',iend(i,iint)
12527 do j=istart(i,iint),iend(i,iint)
12529 if (itypj.eq.ntyp1) cycle
12533 rij=xj*xj+yj*yj+zj*zj
12534 sss=sscale(dsqrt(rij)/sigma(itypi,itypj))
12535 if (sss.lt.1.0d0) then
12537 eps0ij=eps(itypi,itypj)
12539 e1=fac*fac*aa_aq(itypi,itypj)
12540 e2=fac*bb_aq(itypi,itypj)
12542 evdw=evdw+(1.0d0-sss)*evdwij
12544 ! Calculate the components of the gradient in DC and X
12546 fac=-rrij*(e1+evdwij)*(1.0d0-sss)
12551 gvdwx(k,i)=gvdwx(k,i)-gg(k)
12552 gvdwx(k,j)=gvdwx(k,j)+gg(k)
12553 gvdwc(k,i)=gvdwc(k,i)-gg(k)
12554 gvdwc(k,j)=gvdwc(k,j)+gg(k)
12562 gvdwc(j,i)=expon*gvdwc(j,i)
12563 gvdwx(j,i)=expon*gvdwx(j,i)
12566 !******************************************************************************
12570 ! To save time, the factor of EXPON has been extracted from ALL components
12571 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
12574 !******************************************************************************
12576 end subroutine elj_long
12577 !-----------------------------------------------------------------------------
12578 subroutine elj_short(evdw)
12580 ! This subroutine calculates the interaction energy of nonbonded side chains
12581 ! assuming the LJ potential of interaction.
12583 ! implicit real*8 (a-h,o-z)
12584 ! include 'DIMENSIONS'
12585 ! include 'COMMON.GEO'
12586 ! include 'COMMON.VAR'
12587 ! include 'COMMON.LOCAL'
12588 ! include 'COMMON.CHAIN'
12589 ! include 'COMMON.DERIV'
12590 ! include 'COMMON.INTERACT'
12591 ! include 'COMMON.TORSION'
12592 ! include 'COMMON.SBRIDGE'
12593 ! include 'COMMON.NAMES'
12594 ! include 'COMMON.IOUNITS'
12595 ! include 'COMMON.CONTACTS'
12596 real(kind=8),parameter :: accur=1.0d-10
12597 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
12598 !el local variables
12599 integer :: i,iint,j,k,itypi,itypi1,itypj,num_conti
12600 real(kind=8) :: xi,yi,zi,xj,yj,zj,rij,sss,rrij,fac,eps0ij
12601 real(kind=8) :: e1,e2,evdwij,evdw
12602 ! write(iout,*)'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
12604 do i=iatsc_s,iatsc_e
12606 if (itypi.eq.ntyp1) cycle
12607 itypi1=itype(i+1,1)
12614 ! Calculate SC interaction energy.
12616 do iint=1,nint_gr(i)
12617 !d write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
12618 !d & 'iend=',iend(i,iint)
12619 do j=istart(i,iint),iend(i,iint)
12621 if (itypj.eq.ntyp1) cycle
12625 ! Change 12/1/95 to calculate four-body interactions
12626 rij=xj*xj+yj*yj+zj*zj
12627 sss=sscale(dsqrt(rij)/sigma(itypi,itypj))
12628 if (sss.gt.0.0d0) then
12630 eps0ij=eps(itypi,itypj)
12632 e1=fac*fac*aa_aq(itypi,itypj)
12633 e2=fac*bb_aq(itypi,itypj)
12635 evdw=evdw+sss*evdwij
12637 ! Calculate the components of the gradient in DC and X
12639 fac=-rrij*(e1+evdwij)*sss
12644 gvdwx(k,i)=gvdwx(k,i)-gg(k)
12645 gvdwx(k,j)=gvdwx(k,j)+gg(k)
12646 gvdwc(k,i)=gvdwc(k,i)-gg(k)
12647 gvdwc(k,j)=gvdwc(k,j)+gg(k)
12655 gvdwc(j,i)=expon*gvdwc(j,i)
12656 gvdwx(j,i)=expon*gvdwx(j,i)
12659 !******************************************************************************
12663 ! To save time, the factor of EXPON has been extracted from ALL components
12664 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
12667 !******************************************************************************
12669 end subroutine elj_short
12670 !-----------------------------------------------------------------------------
12671 subroutine eljk_long(evdw)
12673 ! This subroutine calculates the interaction energy of nonbonded side chains
12674 ! assuming the LJK potential of interaction.
12676 ! implicit real*8 (a-h,o-z)
12677 ! include 'DIMENSIONS'
12678 ! include 'COMMON.GEO'
12679 ! include 'COMMON.VAR'
12680 ! include 'COMMON.LOCAL'
12681 ! include 'COMMON.CHAIN'
12682 ! include 'COMMON.DERIV'
12683 ! include 'COMMON.INTERACT'
12684 ! include 'COMMON.IOUNITS'
12685 ! include 'COMMON.NAMES'
12686 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
12688 !el local variables
12689 integer :: i,iint,j,k,itypi,itypi1,itypj
12690 real(kind=8) :: rrij,r_inv_ij,xj,yj,zj,xi,yi,zi,fac,evdw,&
12691 fac_augm,e_augm,rij,sss,r_shift_inv,e1,e2,evdwij
12692 ! print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
12694 do i=iatsc_s,iatsc_e
12696 if (itypi.eq.ntyp1) cycle
12697 itypi1=itype(i+1,1)
12702 ! Calculate SC interaction energy.
12704 do iint=1,nint_gr(i)
12705 do j=istart(i,iint),iend(i,iint)
12707 if (itypj.eq.ntyp1) cycle
12711 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
12712 fac_augm=rrij**expon
12713 e_augm=augm(itypi,itypj)*fac_augm
12714 r_inv_ij=dsqrt(rrij)
12716 sss=sscale(rij/sigma(itypi,itypj))
12717 if (sss.lt.1.0d0) then
12718 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
12719 fac=r_shift_inv**expon
12720 e1=fac*fac*aa_aq(itypi,itypj)
12721 e2=fac*bb_aq(itypi,itypj)
12722 evdwij=e_augm+e1+e2
12723 !d sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
12724 !d epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
12725 !d write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
12726 !d & restyp(itypi,1),i,restyp(itypj,1),j,aa(itypi,itypj),
12727 !d & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
12728 !d & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
12729 !d & (c(k,i),k=1,3),(c(k,j),k=1,3)
12730 evdw=evdw+(1.0d0-sss)*evdwij
12732 ! Calculate the components of the gradient in DC and X
12734 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
12735 fac=fac*(1.0d0-sss)
12740 gvdwx(k,i)=gvdwx(k,i)-gg(k)
12741 gvdwx(k,j)=gvdwx(k,j)+gg(k)
12742 gvdwc(k,i)=gvdwc(k,i)-gg(k)
12743 gvdwc(k,j)=gvdwc(k,j)+gg(k)
12751 gvdwc(j,i)=expon*gvdwc(j,i)
12752 gvdwx(j,i)=expon*gvdwx(j,i)
12756 end subroutine eljk_long
12757 !-----------------------------------------------------------------------------
12758 subroutine eljk_short(evdw)
12760 ! This subroutine calculates the interaction energy of nonbonded side chains
12761 ! assuming the LJK potential of interaction.
12763 ! implicit real*8 (a-h,o-z)
12764 ! include 'DIMENSIONS'
12765 ! include 'COMMON.GEO'
12766 ! include 'COMMON.VAR'
12767 ! include 'COMMON.LOCAL'
12768 ! include 'COMMON.CHAIN'
12769 ! include 'COMMON.DERIV'
12770 ! include 'COMMON.INTERACT'
12771 ! include 'COMMON.IOUNITS'
12772 ! include 'COMMON.NAMES'
12773 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
12775 !el local variables
12776 integer :: i,iint,j,k,itypi,itypi1,itypj
12777 real(kind=8) :: rrij,r_inv_ij,xj,yj,zj,xi,yi,zi,fac,evdw,&
12778 fac_augm,e_augm,rij,sss,r_shift_inv,e1,e2,evdwij
12779 ! print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
12781 do i=iatsc_s,iatsc_e
12783 if (itypi.eq.ntyp1) cycle
12784 itypi1=itype(i+1,1)
12789 ! Calculate SC interaction energy.
12791 do iint=1,nint_gr(i)
12792 do j=istart(i,iint),iend(i,iint)
12794 if (itypj.eq.ntyp1) cycle
12798 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
12799 fac_augm=rrij**expon
12800 e_augm=augm(itypi,itypj)*fac_augm
12801 r_inv_ij=dsqrt(rrij)
12803 sss=sscale(rij/sigma(itypi,itypj))
12804 if (sss.gt.0.0d0) then
12805 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
12806 fac=r_shift_inv**expon
12807 e1=fac*fac*aa_aq(itypi,itypj)
12808 e2=fac*bb_aq(itypi,itypj)
12809 evdwij=e_augm+e1+e2
12810 !d sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
12811 !d epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
12812 !d write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
12813 !d & restyp(itypi,1),i,restyp(itypj,1),j,aa(itypi,itypj),
12814 !d & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
12815 !d & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
12816 !d & (c(k,i),k=1,3),(c(k,j),k=1,3)
12817 evdw=evdw+sss*evdwij
12819 ! Calculate the components of the gradient in DC and X
12821 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
12827 gvdwx(k,i)=gvdwx(k,i)-gg(k)
12828 gvdwx(k,j)=gvdwx(k,j)+gg(k)
12829 gvdwc(k,i)=gvdwc(k,i)-gg(k)
12830 gvdwc(k,j)=gvdwc(k,j)+gg(k)
12838 gvdwc(j,i)=expon*gvdwc(j,i)
12839 gvdwx(j,i)=expon*gvdwx(j,i)
12843 end subroutine eljk_short
12844 !-----------------------------------------------------------------------------
12845 subroutine ebp_long(evdw)
12847 ! This subroutine calculates the interaction energy of nonbonded side chains
12848 ! assuming the Berne-Pechukas potential of interaction.
12851 ! implicit real*8 (a-h,o-z)
12852 ! include 'DIMENSIONS'
12853 ! include 'COMMON.GEO'
12854 ! include 'COMMON.VAR'
12855 ! include 'COMMON.LOCAL'
12856 ! include 'COMMON.CHAIN'
12857 ! include 'COMMON.DERIV'
12858 ! include 'COMMON.NAMES'
12859 ! include 'COMMON.INTERACT'
12860 ! include 'COMMON.IOUNITS'
12861 ! include 'COMMON.CALC'
12863 !el integer :: icall
12864 !el common /srutu/ icall
12865 ! double precision rrsave(maxdim)
12867 !el local variables
12868 integer :: iint,itypi,itypi1,itypj
12869 real(kind=8) :: rrij,xi,yi,zi,fac
12870 real(kind=8) :: sss,e1,e2,evdw,sigm,epsi
12872 ! print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
12874 ! if (icall.eq.0) then
12880 do i=iatsc_s,iatsc_e
12882 if (itypi.eq.ntyp1) cycle
12883 itypi1=itype(i+1,1)
12887 dxi=dc_norm(1,nres+i)
12888 dyi=dc_norm(2,nres+i)
12889 dzi=dc_norm(3,nres+i)
12890 ! dsci_inv=dsc_inv(itypi)
12891 dsci_inv=vbld_inv(i+nres)
12893 ! Calculate SC interaction energy.
12895 do iint=1,nint_gr(i)
12896 do j=istart(i,iint),iend(i,iint)
12899 if (itypj.eq.ntyp1) cycle
12900 ! dscj_inv=dsc_inv(itypj)
12901 dscj_inv=vbld_inv(j+nres)
12902 chi1=chi(itypi,itypj)
12903 chi2=chi(itypj,itypi)
12910 alf12=0.5D0*(alf1+alf2)
12914 dxj=dc_norm(1,nres+j)
12915 dyj=dc_norm(2,nres+j)
12916 dzj=dc_norm(3,nres+j)
12917 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
12919 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
12921 if (sss.lt.1.0d0) then
12923 ! Calculate the angle-dependent terms of energy & contributions to derivatives.
12925 ! Calculate whole angle-dependent part of epsilon and contributions
12926 ! to its derivatives
12927 fac=(rrij*sigsq)**expon2
12928 e1=fac*fac*aa_aq(itypi,itypj)
12929 e2=fac*bb_aq(itypi,itypj)
12930 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
12931 eps2der=evdwij*eps3rt
12932 eps3der=evdwij*eps2rt
12933 evdwij=evdwij*eps2rt*eps3rt
12934 evdw=evdw+evdwij*(1.0d0-sss)
12936 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
12937 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
12938 !d write (iout,'(2(a3,i3,2x),15(0pf7.3))')
12939 !d & restyp(itypi,1),i,restyp(itypj,1),j,
12940 !d & epsi,sigm,chi1,chi2,chip1,chip2,
12941 !d & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
12942 !d & om1,om2,om12,1.0D0/dsqrt(rrij),
12945 ! Calculate gradient components.
12946 e1=e1*eps1*eps2rt**2*eps3rt**2
12947 fac=-expon*(e1+evdwij)
12950 ! Calculate radial part of the gradient
12954 ! Calculate the angular part of the gradient and sum add the contributions
12955 ! to the appropriate components of the Cartesian gradient.
12956 call sc_grad_scale(1.0d0-sss)
12963 end subroutine ebp_long
12964 !-----------------------------------------------------------------------------
12965 subroutine ebp_short(evdw)
12967 ! This subroutine calculates the interaction energy of nonbonded side chains
12968 ! assuming the Berne-Pechukas potential of interaction.
12971 ! implicit real*8 (a-h,o-z)
12972 ! include 'DIMENSIONS'
12973 ! include 'COMMON.GEO'
12974 ! include 'COMMON.VAR'
12975 ! include 'COMMON.LOCAL'
12976 ! include 'COMMON.CHAIN'
12977 ! include 'COMMON.DERIV'
12978 ! include 'COMMON.NAMES'
12979 ! include 'COMMON.INTERACT'
12980 ! include 'COMMON.IOUNITS'
12981 ! include 'COMMON.CALC'
12983 !el integer :: icall
12984 !el common /srutu/ icall
12985 ! double precision rrsave(maxdim)
12987 !el local variables
12988 integer :: iint,itypi,itypi1,itypj
12989 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi
12990 real(kind=8) :: sss,e1,e2,evdw
12992 ! print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
12994 ! if (icall.eq.0) then
13000 do i=iatsc_s,iatsc_e
13002 if (itypi.eq.ntyp1) cycle
13003 itypi1=itype(i+1,1)
13007 dxi=dc_norm(1,nres+i)
13008 dyi=dc_norm(2,nres+i)
13009 dzi=dc_norm(3,nres+i)
13010 ! dsci_inv=dsc_inv(itypi)
13011 dsci_inv=vbld_inv(i+nres)
13013 ! Calculate SC interaction energy.
13015 do iint=1,nint_gr(i)
13016 do j=istart(i,iint),iend(i,iint)
13019 if (itypj.eq.ntyp1) cycle
13020 ! dscj_inv=dsc_inv(itypj)
13021 dscj_inv=vbld_inv(j+nres)
13022 chi1=chi(itypi,itypj)
13023 chi2=chi(itypj,itypi)
13030 alf12=0.5D0*(alf1+alf2)
13034 dxj=dc_norm(1,nres+j)
13035 dyj=dc_norm(2,nres+j)
13036 dzj=dc_norm(3,nres+j)
13037 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
13039 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
13041 if (sss.gt.0.0d0) then
13043 ! Calculate the angle-dependent terms of energy & contributions to derivatives.
13045 ! Calculate whole angle-dependent part of epsilon and contributions
13046 ! to its derivatives
13047 fac=(rrij*sigsq)**expon2
13048 e1=fac*fac*aa_aq(itypi,itypj)
13049 e2=fac*bb_aq(itypi,itypj)
13050 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
13051 eps2der=evdwij*eps3rt
13052 eps3der=evdwij*eps2rt
13053 evdwij=evdwij*eps2rt*eps3rt
13054 evdw=evdw+evdwij*sss
13056 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
13057 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
13058 !d write (iout,'(2(a3,i3,2x),15(0pf7.3))')
13059 !d & restyp(itypi,1),i,restyp(itypj,1),j,
13060 !d & epsi,sigm,chi1,chi2,chip1,chip2,
13061 !d & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
13062 !d & om1,om2,om12,1.0D0/dsqrt(rrij),
13065 ! Calculate gradient components.
13066 e1=e1*eps1*eps2rt**2*eps3rt**2
13067 fac=-expon*(e1+evdwij)
13070 ! Calculate radial part of the gradient
13074 ! Calculate the angular part of the gradient and sum add the contributions
13075 ! to the appropriate components of the Cartesian gradient.
13076 call sc_grad_scale(sss)
13083 end subroutine ebp_short
13084 !-----------------------------------------------------------------------------
13085 subroutine egb_long(evdw)
13087 ! This subroutine calculates the interaction energy of nonbonded side chains
13088 ! assuming the Gay-Berne potential of interaction.
13091 ! implicit real*8 (a-h,o-z)
13092 ! include 'DIMENSIONS'
13093 ! include 'COMMON.GEO'
13094 ! include 'COMMON.VAR'
13095 ! include 'COMMON.LOCAL'
13096 ! include 'COMMON.CHAIN'
13097 ! include 'COMMON.DERIV'
13098 ! include 'COMMON.NAMES'
13099 ! include 'COMMON.INTERACT'
13100 ! include 'COMMON.IOUNITS'
13101 ! include 'COMMON.CALC'
13102 ! include 'COMMON.CONTROL'
13104 !el local variables
13105 integer :: iint,itypi,itypi1,itypj,subchap
13106 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,sig,sig0ij,rij_shift
13107 real(kind=8) :: sss,e1,e2,evdw,sss_grad
13108 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
13109 dist_temp, dist_init,aa,bb,fracinbuf,sslipi,sslipj,&
13110 ssgradlipi,ssgradlipj
13114 !cccc energy_dec=.false.
13115 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
13118 ! if (icall.eq.0) lprn=.false.
13120 do i=iatsc_s,iatsc_e
13122 if (itypi.eq.ntyp1) cycle
13123 itypi1=itype(i+1,1)
13127 xi=mod(xi,boxxsize)
13128 if (xi.lt.0) xi=xi+boxxsize
13129 yi=mod(yi,boxysize)
13130 if (yi.lt.0) yi=yi+boxysize
13131 zi=mod(zi,boxzsize)
13132 if (zi.lt.0) zi=zi+boxzsize
13133 if ((zi.gt.bordlipbot) &
13134 .and.(zi.lt.bordliptop)) then
13135 !C the energy transfer exist
13136 if (zi.lt.buflipbot) then
13137 !C what fraction I am in
13139 ((zi-bordlipbot)/lipbufthick)
13140 !C lipbufthick is thickenes of lipid buffore
13141 sslipi=sscalelip(fracinbuf)
13142 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
13143 elseif (zi.gt.bufliptop) then
13144 fracinbuf=1.0d0-((bordliptop-zi)/lipbufthick)
13145 sslipi=sscalelip(fracinbuf)
13146 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
13156 dxi=dc_norm(1,nres+i)
13157 dyi=dc_norm(2,nres+i)
13158 dzi=dc_norm(3,nres+i)
13159 ! dsci_inv=dsc_inv(itypi)
13160 dsci_inv=vbld_inv(i+nres)
13161 ! write (iout,*) "i",i,dsc_inv(itypi),dsci_inv,1.0d0/vbld(i+nres)
13162 ! write (iout,*) "dcnori",dxi*dxi+dyi*dyi+dzi*dzi
13164 ! Calculate SC interaction energy.
13166 do iint=1,nint_gr(i)
13167 do j=istart(i,iint),iend(i,iint)
13168 IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
13169 ! call dyn_ssbond_ene(i,j,evdwij)
13171 ! if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
13172 ! 'evdw',i,j,evdwij,' ss'
13173 ! if (energy_dec) write (iout,*) &
13174 ! 'evdw',i,j,evdwij,' ss'
13175 ! do k=j+1,iend(i,iint)
13176 !C search over all next residues
13177 ! if (dyn_ss_mask(k)) then
13178 !C check if they are cysteins
13179 !C write(iout,*) 'k=',k
13181 !c write(iout,*) "PRZED TRI", evdwij
13182 ! evdwij_przed_tri=evdwij
13183 ! call triple_ssbond_ene(i,j,k,evdwij)
13184 !c if(evdwij_przed_tri.ne.evdwij) then
13185 !c write (iout,*) "TRI:", evdwij, evdwij_przed_tri
13188 !c write(iout,*) "PO TRI", evdwij
13189 !C call the energy function that removes the artifical triple disulfide
13190 !C bond the soubroutine is located in ssMD.F
13192 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
13193 'evdw',i,j,evdwij,'tss'
13194 ! endif!dyn_ss_mask(k)
13200 if (itypj.eq.ntyp1) cycle
13201 ! dscj_inv=dsc_inv(itypj)
13202 dscj_inv=vbld_inv(j+nres)
13203 ! write (iout,*) "j",j,dsc_inv(itypj),dscj_inv,
13204 ! & 1.0d0/vbld(j+nres)
13205 ! write (iout,*) "i",i," j", j," itype",itype(i,1),itype(j,1)
13206 sig0ij=sigma(itypi,itypj)
13207 chi1=chi(itypi,itypj)
13208 chi2=chi(itypj,itypi)
13215 alf12=0.5D0*(alf1+alf2)
13219 ! Searching for nearest neighbour
13220 xj=mod(xj,boxxsize)
13221 if (xj.lt.0) xj=xj+boxxsize
13222 yj=mod(yj,boxysize)
13223 if (yj.lt.0) yj=yj+boxysize
13224 zj=mod(zj,boxzsize)
13225 if (zj.lt.0) zj=zj+boxzsize
13226 if ((zj.gt.bordlipbot) &
13227 .and.(zj.lt.bordliptop)) then
13228 !C the energy transfer exist
13229 if (zj.lt.buflipbot) then
13230 !C what fraction I am in
13232 ((zj-bordlipbot)/lipbufthick)
13233 !C lipbufthick is thickenes of lipid buffore
13234 sslipj=sscalelip(fracinbuf)
13235 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
13236 elseif (zj.gt.bufliptop) then
13237 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
13238 sslipj=sscalelip(fracinbuf)
13239 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
13248 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
13249 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
13250 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
13251 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
13253 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
13261 xj=xj_safe+xshift*boxxsize
13262 yj=yj_safe+yshift*boxysize
13263 zj=zj_safe+zshift*boxzsize
13264 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
13265 if(dist_temp.lt.dist_init) then
13266 dist_init=dist_temp
13275 if (subchap.eq.1) then
13285 dxj=dc_norm(1,nres+j)
13286 dyj=dc_norm(2,nres+j)
13287 dzj=dc_norm(3,nres+j)
13288 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
13290 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
13291 sss_ele_cut=sscale_ele(1.0d0/(rij*sigma(itypi,itypj)))
13292 sss_ele_grad=sscagrad_ele(1.0d0/(rij*sigma(itypi,itypj)))
13293 sss_grad=sscale_grad(1.0d0/(rij*sigmaii(itypi,itypj)))
13294 if (sss_ele_cut.le.0.0) cycle
13295 if (sss.lt.1.0d0) then
13297 ! Calculate angle-dependent terms of energy and contributions to their
13301 sig=sig0ij*dsqrt(sigsq)
13302 rij_shift=1.0D0/rij-sig+sig0ij
13303 ! for diagnostics; uncomment
13304 ! rij_shift=1.2*sig0ij
13305 ! I hate to put IF's in the loops, but here don't have another choice!!!!
13306 if (rij_shift.le.0.0D0) then
13308 !d write (iout,'(2(a3,i3,2x),17(0pf7.3))')
13309 !d & restyp(itypi,1),i,restyp(itypj,1),j,
13310 !d & rij_shift,1.0D0/rij,sig,sig0ij,sigsq,1-dsqrt(sigsq)
13314 !---------------------------------------------------------------
13315 rij_shift=1.0D0/rij_shift
13316 fac=rij_shift**expon
13319 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
13320 eps2der=evdwij*eps3rt
13321 eps3der=evdwij*eps2rt
13322 ! write (iout,*) "sigsq",sigsq," sig",sig," eps2rt",eps2rt,
13323 ! & " eps3rt",eps3rt," eps1",eps1," e1",e1," e2",e2
13324 evdwij=evdwij*eps2rt*eps3rt
13325 evdw=evdw+evdwij*(1.0d0-sss)*sss_ele_cut
13327 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
13328 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
13329 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
13330 restyp(itypi,1),i,restyp(itypj,1),j,&
13331 epsi,sigm,chi1,chi2,chip1,chip2,&
13332 eps1,eps2rt**2,eps3rt**2,sig,sig0ij,&
13333 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
13337 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
13339 ! if (energy_dec) write (iout,*) &
13340 ! 'evdw',i,j,evdwij,"egb_long"
13342 ! Calculate gradient components.
13343 e1=e1*eps1*eps2rt**2*eps3rt**2
13344 fac=-expon*(e1+evdwij)*rij_shift
13347 fac=fac+evdwij*(sss_ele_grad/sss_ele_cut&
13348 /sigma(itypi,itypj)*rij-sss_grad/(1.0-sss)*rij &
13349 /sigmaii(itypi,itypj))
13351 ! Calculate the radial part of the gradient
13355 ! Calculate angular part of the gradient.
13356 call sc_grad_scale(1.0d0-sss)
13362 ! write (iout,*) "Number of loop steps in EGB:",ind
13363 !ccc energy_dec=.false.
13365 end subroutine egb_long
13366 !-----------------------------------------------------------------------------
13367 subroutine egb_short(evdw)
13369 ! This subroutine calculates the interaction energy of nonbonded side chains
13370 ! assuming the Gay-Berne potential of interaction.
13373 ! implicit real*8 (a-h,o-z)
13374 ! include 'DIMENSIONS'
13375 ! include 'COMMON.GEO'
13376 ! include 'COMMON.VAR'
13377 ! include 'COMMON.LOCAL'
13378 ! include 'COMMON.CHAIN'
13379 ! include 'COMMON.DERIV'
13380 ! include 'COMMON.NAMES'
13381 ! include 'COMMON.INTERACT'
13382 ! include 'COMMON.IOUNITS'
13383 ! include 'COMMON.CALC'
13384 ! include 'COMMON.CONTROL'
13386 !el local variables
13387 integer :: iint,itypi,itypi1,itypj,subchap
13388 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,sig0ij,sig
13389 real(kind=8) :: sss,e1,e2,evdw,rij_shift,sss_grad
13390 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
13391 dist_temp, dist_init,aa,bb,fracinbuf,sslipi,sslipj,&
13392 ssgradlipi,ssgradlipj
13394 !cccc energy_dec=.false.
13395 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
13398 ! if (icall.eq.0) lprn=.false.
13400 do i=iatsc_s,iatsc_e
13402 if (itypi.eq.ntyp1) cycle
13403 itypi1=itype(i+1,1)
13407 xi=mod(xi,boxxsize)
13408 if (xi.lt.0) xi=xi+boxxsize
13409 yi=mod(yi,boxysize)
13410 if (yi.lt.0) yi=yi+boxysize
13411 zi=mod(zi,boxzsize)
13412 if (zi.lt.0) zi=zi+boxzsize
13413 if ((zi.gt.bordlipbot) &
13414 .and.(zi.lt.bordliptop)) then
13415 !C the energy transfer exist
13416 if (zi.lt.buflipbot) then
13417 !C what fraction I am in
13419 ((zi-bordlipbot)/lipbufthick)
13420 !C lipbufthick is thickenes of lipid buffore
13421 sslipi=sscalelip(fracinbuf)
13422 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
13423 elseif (zi.gt.bufliptop) then
13424 fracinbuf=1.0d0-((bordliptop-zi)/lipbufthick)
13425 sslipi=sscalelip(fracinbuf)
13426 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
13436 dxi=dc_norm(1,nres+i)
13437 dyi=dc_norm(2,nres+i)
13438 dzi=dc_norm(3,nres+i)
13439 ! dsci_inv=dsc_inv(itypi)
13440 dsci_inv=vbld_inv(i+nres)
13442 dxi=dc_norm(1,nres+i)
13443 dyi=dc_norm(2,nres+i)
13444 dzi=dc_norm(3,nres+i)
13445 ! dsci_inv=dsc_inv(itypi)
13446 dsci_inv=vbld_inv(i+nres)
13447 ! write (iout,*) "i",i,dsc_inv(itypi),dsci_inv,1.0d0/vbld(i+nres)
13448 ! write (iout,*) "dcnori",dxi*dxi+dyi*dyi+dzi*dzi
13450 ! Calculate SC interaction energy.
13452 do iint=1,nint_gr(i)
13453 do j=istart(i,iint),iend(i,iint)
13454 IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
13455 call dyn_ssbond_ene(i,j,evdwij)
13457 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
13458 'evdw',i,j,evdwij,' ss'
13459 do k=j+1,iend(i,iint)
13460 !C search over all next residues
13461 if (dyn_ss_mask(k)) then
13462 !C check if they are cysteins
13463 !C write(iout,*) 'k=',k
13465 !c write(iout,*) "PRZED TRI", evdwij
13466 ! evdwij_przed_tri=evdwij
13467 call triple_ssbond_ene(i,j,k,evdwij)
13468 !c if(evdwij_przed_tri.ne.evdwij) then
13469 !c write (iout,*) "TRI:", evdwij, evdwij_przed_tri
13472 !c write(iout,*) "PO TRI", evdwij
13473 !C call the energy function that removes the artifical triple disulfide
13474 !C bond the soubroutine is located in ssMD.F
13476 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
13477 'evdw',i,j,evdwij,'tss'
13478 endif!dyn_ss_mask(k)
13481 ! if (energy_dec) write (iout,*) &
13482 ! 'evdw',i,j,evdwij,' ss'
13486 if (itypj.eq.ntyp1) cycle
13487 ! dscj_inv=dsc_inv(itypj)
13488 dscj_inv=vbld_inv(j+nres)
13489 ! write (iout,*) "j",j,dsc_inv(itypj),dscj_inv,
13490 ! & 1.0d0/vbld(j+nres)
13491 ! write (iout,*) "i",i," j", j," itype",itype(i,1),itype(j,1)
13492 sig0ij=sigma(itypi,itypj)
13493 chi1=chi(itypi,itypj)
13494 chi2=chi(itypj,itypi)
13501 alf12=0.5D0*(alf1+alf2)
13502 ! xj=c(1,nres+j)-xi
13503 ! yj=c(2,nres+j)-yi
13504 ! zj=c(3,nres+j)-zi
13508 ! Searching for nearest neighbour
13509 xj=mod(xj,boxxsize)
13510 if (xj.lt.0) xj=xj+boxxsize
13511 yj=mod(yj,boxysize)
13512 if (yj.lt.0) yj=yj+boxysize
13513 zj=mod(zj,boxzsize)
13514 if (zj.lt.0) zj=zj+boxzsize
13515 if ((zj.gt.bordlipbot) &
13516 .and.(zj.lt.bordliptop)) then
13517 !C the energy transfer exist
13518 if (zj.lt.buflipbot) then
13519 !C what fraction I am in
13521 ((zj-bordlipbot)/lipbufthick)
13522 !C lipbufthick is thickenes of lipid buffore
13523 sslipj=sscalelip(fracinbuf)
13524 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
13525 elseif (zj.gt.bufliptop) then
13526 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
13527 sslipj=sscalelip(fracinbuf)
13528 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
13537 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
13538 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
13539 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
13540 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
13542 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
13551 xj=xj_safe+xshift*boxxsize
13552 yj=yj_safe+yshift*boxysize
13553 zj=zj_safe+zshift*boxzsize
13554 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
13555 if(dist_temp.lt.dist_init) then
13556 dist_init=dist_temp
13565 if (subchap.eq.1) then
13575 dxj=dc_norm(1,nres+j)
13576 dyj=dc_norm(2,nres+j)
13577 dzj=dc_norm(3,nres+j)
13578 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
13580 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
13581 sss_grad=sscale_grad(1.0d0/(rij*sigmaii(itypi,itypj)))
13582 sss_ele_cut=sscale_ele(1.0d0/(rij*sigma(itypi,itypj)))
13583 sss_ele_grad=sscagrad_ele(1.0d0/(rij*sigma(itypi,itypj)))
13584 if (sss_ele_cut.le.0.0) cycle
13586 if (sss.gt.0.0d0) then
13588 ! Calculate angle-dependent terms of energy and contributions to their
13592 sig=sig0ij*dsqrt(sigsq)
13593 rij_shift=1.0D0/rij-sig+sig0ij
13594 ! for diagnostics; uncomment
13595 ! rij_shift=1.2*sig0ij
13596 ! I hate to put IF's in the loops, but here don't have another choice!!!!
13597 if (rij_shift.le.0.0D0) then
13599 !d write (iout,'(2(a3,i3,2x),17(0pf7.3))')
13600 !d & restyp(itypi,1),i,restyp(itypj,1),j,
13601 !d & rij_shift,1.0D0/rij,sig,sig0ij,sigsq,1-dsqrt(sigsq)
13605 !---------------------------------------------------------------
13606 rij_shift=1.0D0/rij_shift
13607 fac=rij_shift**expon
13610 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
13611 eps2der=evdwij*eps3rt
13612 eps3der=evdwij*eps2rt
13613 ! write (iout,*) "sigsq",sigsq," sig",sig," eps2rt",eps2rt,
13614 ! & " eps3rt",eps3rt," eps1",eps1," e1",e1," e2",e2
13615 evdwij=evdwij*eps2rt*eps3rt
13616 evdw=evdw+evdwij*sss*sss_ele_cut
13618 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
13619 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
13620 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
13621 restyp(itypi,1),i,restyp(itypj,1),j,&
13622 epsi,sigm,chi1,chi2,chip1,chip2,&
13623 eps1,eps2rt**2,eps3rt**2,sig,sig0ij,&
13624 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
13628 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
13630 ! if (energy_dec) write (iout,*) &
13631 ! 'evdw',i,j,evdwij,"egb_short"
13633 ! Calculate gradient components.
13634 e1=e1*eps1*eps2rt**2*eps3rt**2
13635 fac=-expon*(e1+evdwij)*rij_shift
13638 fac=fac+evdwij*(sss_ele_grad/sss_ele_cut&
13639 /sigma(itypi,itypj)*rij+sss_grad/sss*rij &
13640 /sigmaii(itypi,itypj))
13643 ! Calculate the radial part of the gradient
13647 ! Calculate angular part of the gradient.
13648 call sc_grad_scale(sss)
13654 ! write (iout,*) "Number of loop steps in EGB:",ind
13655 !ccc energy_dec=.false.
13657 end subroutine egb_short
13658 !-----------------------------------------------------------------------------
13659 subroutine egbv_long(evdw)
13661 ! This subroutine calculates the interaction energy of nonbonded side chains
13662 ! assuming the Gay-Berne-Vorobjev potential of interaction.
13665 ! implicit real*8 (a-h,o-z)
13666 ! include 'DIMENSIONS'
13667 ! include 'COMMON.GEO'
13668 ! include 'COMMON.VAR'
13669 ! include 'COMMON.LOCAL'
13670 ! include 'COMMON.CHAIN'
13671 ! include 'COMMON.DERIV'
13672 ! include 'COMMON.NAMES'
13673 ! include 'COMMON.INTERACT'
13674 ! include 'COMMON.IOUNITS'
13675 ! include 'COMMON.CALC'
13677 !el integer :: icall
13678 !el common /srutu/ icall
13680 !el local variables
13681 integer :: iint,itypi,itypi1,itypj
13682 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,r0ij,sig,sig0ij
13683 real(kind=8) :: sss,e1,e2,evdw,fac_augm,e_augm,rij_shift
13685 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
13688 ! if (icall.eq.0) lprn=.true.
13690 do i=iatsc_s,iatsc_e
13692 if (itypi.eq.ntyp1) cycle
13693 itypi1=itype(i+1,1)
13697 dxi=dc_norm(1,nres+i)
13698 dyi=dc_norm(2,nres+i)
13699 dzi=dc_norm(3,nres+i)
13700 ! dsci_inv=dsc_inv(itypi)
13701 dsci_inv=vbld_inv(i+nres)
13703 ! Calculate SC interaction energy.
13705 do iint=1,nint_gr(i)
13706 do j=istart(i,iint),iend(i,iint)
13709 if (itypj.eq.ntyp1) cycle
13710 ! dscj_inv=dsc_inv(itypj)
13711 dscj_inv=vbld_inv(j+nres)
13712 sig0ij=sigma(itypi,itypj)
13713 r0ij=r0(itypi,itypj)
13714 chi1=chi(itypi,itypj)
13715 chi2=chi(itypj,itypi)
13722 alf12=0.5D0*(alf1+alf2)
13726 dxj=dc_norm(1,nres+j)
13727 dyj=dc_norm(2,nres+j)
13728 dzj=dc_norm(3,nres+j)
13729 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
13732 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
13734 if (sss.lt.1.0d0) then
13736 ! Calculate angle-dependent terms of energy and contributions to their
13740 sig=sig0ij*dsqrt(sigsq)
13741 rij_shift=1.0D0/rij-sig+r0ij
13742 ! I hate to put IF's in the loops, but here don't have another choice!!!!
13743 if (rij_shift.le.0.0D0) then
13748 !---------------------------------------------------------------
13749 rij_shift=1.0D0/rij_shift
13750 fac=rij_shift**expon
13751 e1=fac*fac*aa_aq(itypi,itypj)
13752 e2=fac*bb_aq(itypi,itypj)
13753 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
13754 eps2der=evdwij*eps3rt
13755 eps3der=evdwij*eps2rt
13756 fac_augm=rrij**expon
13757 e_augm=augm(itypi,itypj)*fac_augm
13758 evdwij=evdwij*eps2rt*eps3rt
13759 evdw=evdw+(evdwij+e_augm)*(1.0d0-sss)
13761 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
13762 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
13763 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
13764 restyp(itypi,1),i,restyp(itypj,1),j,&
13765 epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),&
13766 chi1,chi2,chip1,chip2,&
13767 eps1,eps2rt**2,eps3rt**2,&
13768 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
13771 ! Calculate gradient components.
13772 e1=e1*eps1*eps2rt**2*eps3rt**2
13773 fac=-expon*(e1+evdwij)*rij_shift
13775 fac=rij*fac-2*expon*rrij*e_augm
13776 ! Calculate the radial part of the gradient
13780 ! Calculate angular part of the gradient.
13781 call sc_grad_scale(1.0d0-sss)
13786 end subroutine egbv_long
13787 !-----------------------------------------------------------------------------
13788 subroutine egbv_short(evdw)
13790 ! This subroutine calculates the interaction energy of nonbonded side chains
13791 ! assuming the Gay-Berne-Vorobjev potential of interaction.
13794 ! implicit real*8 (a-h,o-z)
13795 ! include 'DIMENSIONS'
13796 ! include 'COMMON.GEO'
13797 ! include 'COMMON.VAR'
13798 ! include 'COMMON.LOCAL'
13799 ! include 'COMMON.CHAIN'
13800 ! include 'COMMON.DERIV'
13801 ! include 'COMMON.NAMES'
13802 ! include 'COMMON.INTERACT'
13803 ! include 'COMMON.IOUNITS'
13804 ! include 'COMMON.CALC'
13806 !el integer :: icall
13807 !el common /srutu/ icall
13809 !el local variables
13810 integer :: iint,itypi,itypi1,itypj
13811 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,rij_shift
13812 real(kind=8) :: sss,e1,e2,evdw,r0ij,sig,sig0ij,fac_augm,e_augm
13814 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
13817 ! if (icall.eq.0) lprn=.true.
13819 do i=iatsc_s,iatsc_e
13821 if (itypi.eq.ntyp1) cycle
13822 itypi1=itype(i+1,1)
13826 dxi=dc_norm(1,nres+i)
13827 dyi=dc_norm(2,nres+i)
13828 dzi=dc_norm(3,nres+i)
13829 ! dsci_inv=dsc_inv(itypi)
13830 dsci_inv=vbld_inv(i+nres)
13832 ! Calculate SC interaction energy.
13834 do iint=1,nint_gr(i)
13835 do j=istart(i,iint),iend(i,iint)
13838 if (itypj.eq.ntyp1) cycle
13839 ! dscj_inv=dsc_inv(itypj)
13840 dscj_inv=vbld_inv(j+nres)
13841 sig0ij=sigma(itypi,itypj)
13842 r0ij=r0(itypi,itypj)
13843 chi1=chi(itypi,itypj)
13844 chi2=chi(itypj,itypi)
13851 alf12=0.5D0*(alf1+alf2)
13855 dxj=dc_norm(1,nres+j)
13856 dyj=dc_norm(2,nres+j)
13857 dzj=dc_norm(3,nres+j)
13858 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
13861 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
13863 if (sss.gt.0.0d0) then
13865 ! Calculate angle-dependent terms of energy and contributions to their
13869 sig=sig0ij*dsqrt(sigsq)
13870 rij_shift=1.0D0/rij-sig+r0ij
13871 ! I hate to put IF's in the loops, but here don't have another choice!!!!
13872 if (rij_shift.le.0.0D0) then
13877 !---------------------------------------------------------------
13878 rij_shift=1.0D0/rij_shift
13879 fac=rij_shift**expon
13880 e1=fac*fac*aa_aq(itypi,itypj)
13881 e2=fac*bb_aq(itypi,itypj)
13882 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
13883 eps2der=evdwij*eps3rt
13884 eps3der=evdwij*eps2rt
13885 fac_augm=rrij**expon
13886 e_augm=augm(itypi,itypj)*fac_augm
13887 evdwij=evdwij*eps2rt*eps3rt
13888 evdw=evdw+(evdwij+e_augm)*sss
13890 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
13891 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
13892 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
13893 restyp(itypi,1),i,restyp(itypj,1),j,&
13894 epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),&
13895 chi1,chi2,chip1,chip2,&
13896 eps1,eps2rt**2,eps3rt**2,&
13897 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
13900 ! Calculate gradient components.
13901 e1=e1*eps1*eps2rt**2*eps3rt**2
13902 fac=-expon*(e1+evdwij)*rij_shift
13904 fac=rij*fac-2*expon*rrij*e_augm
13905 ! Calculate the radial part of the gradient
13909 ! Calculate angular part of the gradient.
13910 call sc_grad_scale(sss)
13915 end subroutine egbv_short
13916 !-----------------------------------------------------------------------------
13917 subroutine eelec_scale(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
13919 ! This subroutine calculates the average interaction energy and its gradient
13920 ! in the virtual-bond vectors between non-adjacent peptide groups, based on
13921 ! the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
13922 ! The potential depends both on the distance of peptide-group centers and on
13923 ! the orientation of the CA-CA virtual bonds.
13925 ! implicit real*8 (a-h,o-z)
13931 ! include 'DIMENSIONS'
13932 ! include 'COMMON.CONTROL'
13933 ! include 'COMMON.SETUP'
13934 ! include 'COMMON.IOUNITS'
13935 ! include 'COMMON.GEO'
13936 ! include 'COMMON.VAR'
13937 ! include 'COMMON.LOCAL'
13938 ! include 'COMMON.CHAIN'
13939 ! include 'COMMON.DERIV'
13940 ! include 'COMMON.INTERACT'
13941 ! include 'COMMON.CONTACTS'
13942 ! include 'COMMON.TORSION'
13943 ! include 'COMMON.VECTORS'
13944 ! include 'COMMON.FFIELD'
13945 ! include 'COMMON.TIME1'
13946 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg
13947 real(kind=8),dimension(3,3) ::erder,uryg,urzg,vryg,vrzg
13948 real(kind=8),dimension(2,2) :: acipa !el,a_temp
13949 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
13950 real(kind=8),dimension(4) :: muij
13951 !el integer :: num_conti,j1,j2
13952 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
13953 !el dz_normi,xmedi,ymedi,zmedi
13954 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
13955 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
13956 !el num_conti,j1,j2
13957 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
13959 real(kind=8) :: scal_el=1.0d0
13961 real(kind=8) :: scal_el=0.5d0
13964 ! 13-go grudnia roku pamietnego...
13965 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
13966 0.0d0,1.0d0,0.0d0,&
13967 0.0d0,0.0d0,1.0d0/),shape(unmat))
13968 !el local variables
13970 real(kind=8) :: fac
13971 real(kind=8) :: dxj,dyj,dzj
13972 real(kind=8) :: ees,evdw1,eel_loc,eello_turn3,eello_turn4
13974 ! allocate(num_cont_hb(nres)) !(maxres)
13975 !d write(iout,*) 'In EELEC'
13977 !d write(iout,*) 'Type',i
13978 !d write(iout,*) 'B1',B1(:,i)
13979 !d write(iout,*) 'B2',B2(:,i)
13980 !d write(iout,*) 'CC',CC(:,:,i)
13981 !d write(iout,*) 'DD',DD(:,:,i)
13982 !d write(iout,*) 'EE',EE(:,:,i)
13984 !d call check_vecgrad
13986 if (icheckgrad.eq.1) then
13988 fac=1.0d0/dsqrt(scalar(dc(1,i),dc(1,i)))
13990 dc_norm(k,i)=dc(k,i)*fac
13992 ! write (iout,*) 'i',i,' fac',fac
13995 if (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
13996 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 .or. &
13997 wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) then
13998 ! call vec_and_deriv
14002 ! print *, "before set matrices"
14004 ! print *,"after set martices"
14006 time_mat=time_mat+MPI_Wtime()-time01
14010 !d write (iout,*) 'i=',i
14012 !d write (iout,'(i5,2f10.5)') k,uy(k,i),uz(k,i)
14015 !d write (iout,'(f10.5,2x,3f10.5,2x,3f10.5)')
14016 !d & uz(k,i),(uzgrad(k,l,1,i),l=1,3),(uzgrad(k,l,2,i),l=1,3)
14029 !d print '(a)','Enter EELEC'
14030 !d write (iout,*) 'iatel_s=',iatel_s,' iatel_e=',iatel_e
14031 ! if (.not.allocated(gel_loc_loc)) allocate(gel_loc_loc(nres)) !(maxvar)(maxvar=6*maxres)
14032 ! if (.not.allocated(gcorr_loc)) allocate(gcorr_loc(nres)) !(maxvar)(maxvar=6*maxres)
14034 gel_loc_loc(i)=0.0d0
14039 ! 9/27/08 AL Split the interaction loop to ensure load balancing of turn terms
14041 ! Loop over i,i+2 and i,i+3 pairs of the peptide groups
14043 do i=iturn3_start,iturn3_end
14044 if (itype(i,1).eq.ntyp1.or. itype(i+1,1).eq.ntyp1 &
14045 .or. itype(i+2,1).eq.ntyp1 .or. itype(i+3,1).eq.ntyp1) cycle
14049 dx_normi=dc_norm(1,i)
14050 dy_normi=dc_norm(2,i)
14051 dz_normi=dc_norm(3,i)
14052 xmedi=c(1,i)+0.5d0*dxi
14053 ymedi=c(2,i)+0.5d0*dyi
14054 zmedi=c(3,i)+0.5d0*dzi
14055 xmedi=dmod(xmedi,boxxsize)
14056 if (xmedi.lt.0) xmedi=xmedi+boxxsize
14057 ymedi=dmod(ymedi,boxysize)
14058 if (ymedi.lt.0) ymedi=ymedi+boxysize
14059 zmedi=dmod(zmedi,boxzsize)
14060 if (zmedi.lt.0) zmedi=zmedi+boxzsize
14062 call eelecij_scale(i,i+2,ees,evdw1,eel_loc)
14063 if (wturn3.gt.0.0d0) call eturn3(i,eello_turn3)
14064 num_cont_hb(i)=num_conti
14066 do i=iturn4_start,iturn4_end
14067 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1 &
14068 .or. itype(i+3,1).eq.ntyp1 &
14069 .or. itype(i+4,1).eq.ntyp1) cycle
14073 dx_normi=dc_norm(1,i)
14074 dy_normi=dc_norm(2,i)
14075 dz_normi=dc_norm(3,i)
14076 xmedi=c(1,i)+0.5d0*dxi
14077 ymedi=c(2,i)+0.5d0*dyi
14078 zmedi=c(3,i)+0.5d0*dzi
14079 xmedi=dmod(xmedi,boxxsize)
14080 if (xmedi.lt.0) xmedi=xmedi+boxxsize
14081 ymedi=dmod(ymedi,boxysize)
14082 if (ymedi.lt.0) ymedi=ymedi+boxysize
14083 zmedi=dmod(zmedi,boxzsize)
14084 if (zmedi.lt.0) zmedi=zmedi+boxzsize
14085 num_conti=num_cont_hb(i)
14086 call eelecij_scale(i,i+3,ees,evdw1,eel_loc)
14087 if (wturn4.gt.0.0d0 .and. itype(i+2,1).ne.ntyp1) &
14088 call eturn4(i,eello_turn4)
14089 num_cont_hb(i)=num_conti
14092 ! Loop over all pairs of interacting peptide groups except i,i+2 and i,i+3
14094 do i=iatel_s,iatel_e
14095 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
14099 dx_normi=dc_norm(1,i)
14100 dy_normi=dc_norm(2,i)
14101 dz_normi=dc_norm(3,i)
14102 xmedi=c(1,i)+0.5d0*dxi
14103 ymedi=c(2,i)+0.5d0*dyi
14104 zmedi=c(3,i)+0.5d0*dzi
14105 xmedi=dmod(xmedi,boxxsize)
14106 if (xmedi.lt.0) xmedi=xmedi+boxxsize
14107 ymedi=dmod(ymedi,boxysize)
14108 if (ymedi.lt.0) ymedi=ymedi+boxysize
14109 zmedi=dmod(zmedi,boxzsize)
14110 if (zmedi.lt.0) zmedi=zmedi+boxzsize
14111 ! write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
14112 num_conti=num_cont_hb(i)
14113 do j=ielstart(i),ielend(i)
14114 if (itype(j,1).eq.ntyp1 .or. itype(j+1,1).eq.ntyp1) cycle
14115 call eelecij_scale(i,j,ees,evdw1,eel_loc)
14117 num_cont_hb(i)=num_conti
14119 ! write (iout,*) "Number of loop steps in EELEC:",ind
14121 !d write (iout,'(i3,3f10.5,5x,3f10.5)')
14122 !d & i,(gel_loc(k,i),k=1,3),gel_loc_loc(i)
14124 ! 12/7/99 Adam eello_turn3 will be considered as a separate energy term
14125 !cc eel_loc=eel_loc+eello_turn3
14126 !d print *,"Processor",fg_rank," t_eelecij",t_eelecij
14128 end subroutine eelec_scale
14129 !-----------------------------------------------------------------------------
14130 subroutine eelecij_scale(i,j,ees,evdw1,eel_loc)
14131 ! implicit real*8 (a-h,o-z)
14134 ! include 'DIMENSIONS'
14138 ! include 'COMMON.CONTROL'
14139 ! include 'COMMON.IOUNITS'
14140 ! include 'COMMON.GEO'
14141 ! include 'COMMON.VAR'
14142 ! include 'COMMON.LOCAL'
14143 ! include 'COMMON.CHAIN'
14144 ! include 'COMMON.DERIV'
14145 ! include 'COMMON.INTERACT'
14146 ! include 'COMMON.CONTACTS'
14147 ! include 'COMMON.TORSION'
14148 ! include 'COMMON.VECTORS'
14149 ! include 'COMMON.FFIELD'
14150 ! include 'COMMON.TIME1'
14151 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg,xtemp
14152 real(kind=8),dimension(3,3) :: erder,uryg,urzg,vryg,vrzg
14153 real(kind=8),dimension(2,2) :: acipa !el,a_temp
14154 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
14155 real(kind=8),dimension(4) :: muij
14156 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
14157 dist_temp, dist_init,sss_grad
14158 integer xshift,yshift,zshift
14160 !el integer :: num_conti,j1,j2
14161 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
14162 !el dz_normi,xmedi,ymedi,zmedi
14163 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
14164 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
14165 !el num_conti,j1,j2
14166 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
14168 real(kind=8) :: scal_el=1.0d0
14170 real(kind=8) :: scal_el=0.5d0
14173 ! 13-go grudnia roku pamietnego...
14174 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
14175 0.0d0,1.0d0,0.0d0,&
14176 0.0d0,0.0d0,1.0d0/),shape(unmat))
14177 !el local variables
14178 integer :: i,j,k,l,iteli,itelj,kkk,kkll,m,isubchap
14179 real(kind=8) :: aaa,bbb,ael6i,ael3i,dxj,dyj,dzj
14180 real(kind=8) :: xj,yj,zj,rij,rrmij,rmij,sss,r3ij,r6ij,fac
14181 real(kind=8) :: cosa,cosb,cosg,ev1,ev2,fac3,fac4,evdwij
14182 real(kind=8) :: el1,el2,eesij,ees0ij,r0ij,fcont,fprimcont
14183 real(kind=8) :: ees0tmp,ees0pij1,ees0mij1,ees0pijp,ees0mijp
14184 real(kind=8) :: ees,evdw1,eel_loc,eel_loc_ij,dx_normj,dy_normj,&
14185 dz_normj,facvdw,facel,fac1,facr,ecosa,ecosb,ecosg,&
14186 ury,urz,vry,vrz,a22der,a23der,a32der,a33der,cosa4,&
14187 wij,cosbg1,cosbg2,ees0pij,ees0mij,fac3p,ecosa1,ecosb1,&
14188 ecosg1,ecosa2,ecosb2,ecosg2,ecosap,ecosbp,ecosgp,&
14189 ecosam,ecosbm,ecosgm,ghalf,time00
14190 ! integer :: maxconts
14191 ! maxconts = nres/4
14192 ! allocate(gacontp_hb1(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
14193 ! allocate(gacontp_hb2(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
14194 ! allocate(gacontp_hb3(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
14195 ! allocate(gacontm_hb1(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
14196 ! allocate(gacontm_hb2(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
14197 ! allocate(gacontm_hb3(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
14198 ! allocate(gacont_hbr(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
14199 ! allocate(grij_hb_cont(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
14200 ! allocate(facont_hb(maxconts,nres)) !(maxconts,maxres)
14201 ! allocate(ees0p(maxconts,nres)) !(maxconts,maxres)
14202 ! allocate(ees0m(maxconts,nres)) !(maxconts,maxres)
14203 ! allocate(d_cont(maxconts,nres)) !(maxconts,maxres)
14204 ! allocate(jcont_hb(maxconts,nres)) !(maxconts,maxres)
14206 ! allocate(a_chuj(2,2,maxconts,nres)) !(2,2,maxconts,maxres)
14207 ! allocate(a_chuj_der(2,2,3,5,maxconts,nres)) !(2,2,3,5,maxconts,maxres)
14212 !d write (iout,*) "eelecij",i,j
14216 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
14217 aaa=app(iteli,itelj)
14218 bbb=bpp(iteli,itelj)
14219 ael6i=ael6(iteli,itelj)
14220 ael3i=ael3(iteli,itelj)
14224 dx_normj=dc_norm(1,j)
14225 dy_normj=dc_norm(2,j)
14226 dz_normj=dc_norm(3,j)
14227 ! xj=c(1,j)+0.5D0*dxj-xmedi
14228 ! yj=c(2,j)+0.5D0*dyj-ymedi
14229 ! zj=c(3,j)+0.5D0*dzj-zmedi
14230 xj=c(1,j)+0.5D0*dxj
14231 yj=c(2,j)+0.5D0*dyj
14232 zj=c(3,j)+0.5D0*dzj
14233 xj=mod(xj,boxxsize)
14234 if (xj.lt.0) xj=xj+boxxsize
14235 yj=mod(yj,boxysize)
14236 if (yj.lt.0) yj=yj+boxysize
14237 zj=mod(zj,boxzsize)
14238 if (zj.lt.0) zj=zj+boxzsize
14240 dist_init=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
14247 xj=xj_safe+xshift*boxxsize
14248 yj=yj_safe+yshift*boxysize
14249 zj=zj_safe+zshift*boxzsize
14250 dist_temp=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
14251 if(dist_temp.lt.dist_init) then
14252 dist_init=dist_temp
14261 if (isubchap.eq.1) then
14272 rij=xj*xj+yj*yj+zj*zj
14276 ! For extracting the short-range part of Evdwpp
14277 sss=sscale(rij/rpp(iteli,itelj))
14278 sss_ele_cut=sscale_ele(rij)
14279 sss_ele_grad=sscagrad_ele(rij)
14280 sss_grad=sscale_grad((rij/rpp(iteli,itelj)))
14281 ! sss_ele_cut=1.0d0
14282 ! sss_ele_grad=0.0d0
14283 if (sss_ele_cut.le.0.0) go to 128
14287 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
14288 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
14289 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
14290 fac=cosa-3.0D0*cosb*cosg
14292 ! 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
14293 if (j.eq.i+2) ev1=scal_el*ev1
14298 el1=fac3*(4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg))
14301 ! 12/26/95 - for the evaluation of multi-body H-bonding interactions
14302 ees0ij=4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg)
14303 ees=ees+eesij*sss_ele_cut
14304 evdw1=evdw1+evdwij*(1.0d0-sss)*sss_ele_cut
14305 !d write(iout,'(2(2i3,2x),7(1pd12.4)/2(3(1pd12.4),5x)/)')
14306 !d & iteli,i,itelj,j,aaa,bbb,ael6i,ael3i,
14307 !d & 1.0D0/dsqrt(rrmij),evdwij,eesij,
14308 !d & xmedi,ymedi,zmedi,xj,yj,zj
14310 if (energy_dec) then
14311 write (iout,'(a6,2i5,0pf7.3,f7.3)') 'evdw1',i,j,evdwij,sss
14312 write (iout,'(a6,2i5,0pf7.3)') 'ees',i,j,eesij
14316 ! Calculate contributions to the Cartesian gradient.
14319 facvdw=-6*rrmij*(ev1+evdwij)*(1.0d0-sss)*sss_ele_cut
14320 facel=-3*rrmij*(el1+eesij)*sss_ele_cut
14326 ! Radial derivatives. First process both termini of the fragment (i,j)
14328 ggg(1)=facel*xj+sss_ele_grad*rmij*eesij*xj
14329 ggg(2)=facel*yj+sss_ele_grad*rmij*eesij*yj
14330 ggg(3)=facel*zj+sss_ele_grad*rmij*eesij*zj
14332 ! ghalf=0.5D0*ggg(k)
14333 ! gelc(k,i)=gelc(k,i)+ghalf
14334 ! gelc(k,j)=gelc(k,j)+ghalf
14336 ! 9/28/08 AL Gradient compotents will be summed only at the end
14338 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
14339 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
14342 ! Loop over residues i+1 thru j-1.
14346 !grad gelc(l,k)=gelc(l,k)+ggg(l)
14349 ggg(1)=facvdw*xj+sss_ele_grad*rmij*evdwij*xj*(1.0d0-sss) &
14350 -evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*xj
14351 ggg(2)=facvdw*yj+sss_ele_grad*rmij*evdwij*yj*(1.0d0-sss) &
14352 -evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*yj
14353 ggg(3)=facvdw*zj+sss_ele_grad*rmij*evdwij*zj*(1.0d0-sss) &
14354 -evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*zj
14356 ! ghalf=0.5D0*ggg(k)
14357 ! gvdwpp(k,i)=gvdwpp(k,i)+ghalf
14358 ! gvdwpp(k,j)=gvdwpp(k,j)+ghalf
14360 ! 9/28/08 AL Gradient compotents will be summed only at the end
14362 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
14363 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
14366 ! Loop over residues i+1 thru j-1.
14370 !grad gvdwpp(l,k)=gvdwpp(l,k)+ggg(l)
14374 facvdw=(ev1+evdwij)*(1.0d0-sss)*sss_ele_cut
14375 facel=(el1+eesij)*sss_ele_cut
14377 fac=-3*rrmij*(facvdw+facvdw+facel)
14382 ! Radial derivatives. First process both termini of the fragment (i,j)
14388 ! ghalf=0.5D0*ggg(k)
14389 ! gelc(k,i)=gelc(k,i)+ghalf
14390 ! gelc(k,j)=gelc(k,j)+ghalf
14392 ! 9/28/08 AL Gradient compotents will be summed only at the end
14394 gelc_long(k,j)=gelc(k,j)+ggg(k)
14395 gelc_long(k,i)=gelc(k,i)-ggg(k)
14398 ! Loop over residues i+1 thru j-1.
14402 !grad gelc(l,k)=gelc(l,k)+ggg(l)
14405 ! 9/28/08 AL Gradient compotents will be summed only at the end
14410 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
14411 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
14417 ecosa=2.0D0*fac3*fac1+fac4
14420 ecosb=(fac3*(fac1*cosg+cosb)+cosg*fac4)
14421 ecosg=(fac3*(fac1*cosb+cosg)+cosb*fac4)
14423 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
14424 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
14426 !d print '(2i3,2(3(1pd14.5),3x))',i,j,(dcosb(k),k=1,3),
14427 !d & (dcosg(k),k=1,3)
14429 ggg(k)=(ecosb*dcosb(k)+ecosg*dcosg(k) )*sss_ele_cut
14432 ! ghalf=0.5D0*ggg(k)
14433 ! gelc(k,i)=gelc(k,i)+ghalf
14434 ! & +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
14435 ! & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
14436 ! gelc(k,j)=gelc(k,j)+ghalf
14437 ! & +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
14438 ! & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
14442 !grad gelc(l,k)=gelc(l,k)+ggg(l)
14446 gelc(k,i)=gelc(k,i) &
14447 +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
14448 + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)&
14450 gelc(k,j)=gelc(k,j) &
14451 +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
14452 + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
14454 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
14455 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
14457 IF (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
14458 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 &
14459 .or. wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
14461 ! 9/25/99 Mixed third-order local-electrostatic terms. The local-interaction
14462 ! energy of a peptide unit is assumed in the form of a second-order
14463 ! Fourier series in the angles lambda1 and lambda2 (see Nishikawa et al.
14464 ! Macromolecules, 1974, 7, 797-806 for definition). This correlation terms
14465 ! are computed for EVERY pair of non-contiguous peptide groups.
14467 if (j.lt.nres-1) then
14478 muij(kkk)=mu(k,i)*mu(l,j)
14481 !d write (iout,*) 'EELEC: i',i,' j',j
14482 !d write (iout,*) 'j',j,' j1',j1,' j2',j2
14483 !d write(iout,*) 'muij',muij
14484 ury=scalar(uy(1,i),erij)
14485 urz=scalar(uz(1,i),erij)
14486 vry=scalar(uy(1,j),erij)
14487 vrz=scalar(uz(1,j),erij)
14488 a22=scalar(uy(1,i),uy(1,j))-3*ury*vry
14489 a23=scalar(uy(1,i),uz(1,j))-3*ury*vrz
14490 a32=scalar(uz(1,i),uy(1,j))-3*urz*vry
14491 a33=scalar(uz(1,i),uz(1,j))-3*urz*vrz
14492 fac=dsqrt(-ael6i)*r3ij
14497 !d write (iout,'(4i5,4f10.5)')
14498 !d & i,itortyp(itype(i,1)),j,itortyp(itype(j,1)),a22,a23,a32,a33
14499 !d write (iout,'(6f10.5)') (muij(k),k=1,4),fac,eel_loc_ij
14500 !d write (iout,'(2(3f10.5,5x)/2(3f10.5,5x))') uy(:,i),uz(:,i),
14501 !d & uy(:,j),uz(:,j)
14502 !d write (iout,'(4f10.5)')
14503 !d & scalar(uy(1,i),uy(1,j)),scalar(uy(1,i),uz(1,j)),
14504 !d & scalar(uz(1,i),uy(1,j)),scalar(uz(1,i),uz(1,j))
14505 !d write (iout,'(4f10.5)') ury,urz,vry,vrz
14506 !d write (iout,'(9f10.5/)')
14507 !d & fac22,a22,fac23,a23,fac32,a32,fac33,a33,eel_loc_ij
14508 ! Derivatives of the elements of A in virtual-bond vectors
14509 call unormderiv(erij(1),unmat(1,1),rmij,erder(1,1))
14511 uryg(k,1)=scalar(erder(1,k),uy(1,i))
14512 uryg(k,2)=scalar(uygrad(1,k,1,i),erij(1))
14513 uryg(k,3)=scalar(uygrad(1,k,2,i),erij(1))
14514 urzg(k,1)=scalar(erder(1,k),uz(1,i))
14515 urzg(k,2)=scalar(uzgrad(1,k,1,i),erij(1))
14516 urzg(k,3)=scalar(uzgrad(1,k,2,i),erij(1))
14517 vryg(k,1)=scalar(erder(1,k),uy(1,j))
14518 vryg(k,2)=scalar(uygrad(1,k,1,j),erij(1))
14519 vryg(k,3)=scalar(uygrad(1,k,2,j),erij(1))
14520 vrzg(k,1)=scalar(erder(1,k),uz(1,j))
14521 vrzg(k,2)=scalar(uzgrad(1,k,1,j),erij(1))
14522 vrzg(k,3)=scalar(uzgrad(1,k,2,j),erij(1))
14524 ! Compute radial contributions to the gradient
14542 ! Add the contributions coming from er
14545 agg(k,1)=agg(k,1)+fac3*(uryg(k,1)*vry+vryg(k,1)*ury)
14546 agg(k,2)=agg(k,2)+fac3*(uryg(k,1)*vrz+vrzg(k,1)*ury)
14547 agg(k,3)=agg(k,3)+fac3*(urzg(k,1)*vry+vryg(k,1)*urz)
14548 agg(k,4)=agg(k,4)+fac3*(urzg(k,1)*vrz+vrzg(k,1)*urz)
14551 ! Derivatives in DC(i)
14552 !grad ghalf1=0.5d0*agg(k,1)
14553 !grad ghalf2=0.5d0*agg(k,2)
14554 !grad ghalf3=0.5d0*agg(k,3)
14555 !grad ghalf4=0.5d0*agg(k,4)
14556 aggi(k,1)=fac*(scalar(uygrad(1,k,1,i),uy(1,j)) &
14557 -3.0d0*uryg(k,2)*vry)!+ghalf1
14558 aggi(k,2)=fac*(scalar(uygrad(1,k,1,i),uz(1,j)) &
14559 -3.0d0*uryg(k,2)*vrz)!+ghalf2
14560 aggi(k,3)=fac*(scalar(uzgrad(1,k,1,i),uy(1,j)) &
14561 -3.0d0*urzg(k,2)*vry)!+ghalf3
14562 aggi(k,4)=fac*(scalar(uzgrad(1,k,1,i),uz(1,j)) &
14563 -3.0d0*urzg(k,2)*vrz)!+ghalf4
14564 ! Derivatives in DC(i+1)
14565 aggi1(k,1)=fac*(scalar(uygrad(1,k,2,i),uy(1,j)) &
14566 -3.0d0*uryg(k,3)*vry)!+agg(k,1)
14567 aggi1(k,2)=fac*(scalar(uygrad(1,k,2,i),uz(1,j)) &
14568 -3.0d0*uryg(k,3)*vrz)!+agg(k,2)
14569 aggi1(k,3)=fac*(scalar(uzgrad(1,k,2,i),uy(1,j)) &
14570 -3.0d0*urzg(k,3)*vry)!+agg(k,3)
14571 aggi1(k,4)=fac*(scalar(uzgrad(1,k,2,i),uz(1,j)) &
14572 -3.0d0*urzg(k,3)*vrz)!+agg(k,4)
14573 ! Derivatives in DC(j)
14574 aggj(k,1)=fac*(scalar(uygrad(1,k,1,j),uy(1,i)) &
14575 -3.0d0*vryg(k,2)*ury)!+ghalf1
14576 aggj(k,2)=fac*(scalar(uzgrad(1,k,1,j),uy(1,i)) &
14577 -3.0d0*vrzg(k,2)*ury)!+ghalf2
14578 aggj(k,3)=fac*(scalar(uygrad(1,k,1,j),uz(1,i)) &
14579 -3.0d0*vryg(k,2)*urz)!+ghalf3
14580 aggj(k,4)=fac*(scalar(uzgrad(1,k,1,j),uz(1,i)) &
14581 -3.0d0*vrzg(k,2)*urz)!+ghalf4
14582 ! Derivatives in DC(j+1) or DC(nres-1)
14583 aggj1(k,1)=fac*(scalar(uygrad(1,k,2,j),uy(1,i)) &
14584 -3.0d0*vryg(k,3)*ury)
14585 aggj1(k,2)=fac*(scalar(uzgrad(1,k,2,j),uy(1,i)) &
14586 -3.0d0*vrzg(k,3)*ury)
14587 aggj1(k,3)=fac*(scalar(uygrad(1,k,2,j),uz(1,i)) &
14588 -3.0d0*vryg(k,3)*urz)
14589 aggj1(k,4)=fac*(scalar(uzgrad(1,k,2,j),uz(1,i)) &
14590 -3.0d0*vrzg(k,3)*urz)
14591 !grad if (j.eq.nres-1 .and. i.lt.j-2) then
14593 !grad aggj1(k,l)=aggj1(k,l)+agg(k,l)
14606 aggi(k,l)=-aggi(k,l)
14607 aggi1(k,l)=-aggi1(k,l)
14608 aggj(k,l)=-aggj(k,l)
14609 aggj1(k,l)=-aggj1(k,l)
14612 if (j.lt.nres-1) then
14618 aggi(k,l)=-aggi(k,l)
14619 aggi1(k,l)=-aggi1(k,l)
14620 aggj(k,l)=-aggj(k,l)
14621 aggj1(k,l)=-aggj1(k,l)
14632 aggi(k,l)=-aggi(k,l)
14633 aggi1(k,l)=-aggi1(k,l)
14634 aggj(k,l)=-aggj(k,l)
14635 aggj1(k,l)=-aggj1(k,l)
14640 IF (wel_loc.gt.0.0d0) THEN
14641 ! Contribution to the local-electrostatic energy coming from the i-j pair
14642 eel_loc_ij=a22*muij(1)+a23*muij(2)+a32*muij(3) &
14644 ! write (iout,*) 'i',i,' j',j,' eel_loc_ij',eel_loc_ij
14646 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
14647 'eelloc',i,j,eel_loc_ij
14648 ! write (iout,*) a22,muij(1),a23,muij(2),a32,muij(3) !d
14650 eel_loc=eel_loc+eel_loc_ij*sss_ele_cut
14651 ! Partial derivatives in virtual-bond dihedral angles gamma
14653 gel_loc_loc(i-1)=gel_loc_loc(i-1)+ &
14654 (a22*muder(1,i)*mu(1,j)+a23*muder(1,i)*mu(2,j) &
14655 +a32*muder(2,i)*mu(1,j)+a33*muder(2,i)*mu(2,j)) &
14657 gel_loc_loc(j-1)=gel_loc_loc(j-1)+ &
14658 (a22*mu(1,i)*muder(1,j)+a23*mu(1,i)*muder(2,j) &
14659 +a32*mu(2,i)*muder(1,j)+a33*mu(2,i)*muder(2,j)) &
14665 ! Derivatives of eello in DC(i+1) thru DC(j-1) or DC(nres-2)
14667 ggg(l)=(agg(l,1)*muij(1)+ &
14668 agg(l,2)*muij(2)+agg(l,3)*muij(3)+agg(l,4)*muij(4))&
14670 +eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
14672 gel_loc_long(l,j)=gel_loc_long(l,j)+ggg(l)
14673 gel_loc_long(l,i)=gel_loc_long(l,i)-ggg(l)
14674 !grad ghalf=0.5d0*ggg(l)
14675 !grad gel_loc(l,i)=gel_loc(l,i)+ghalf
14676 !grad gel_loc(l,j)=gel_loc(l,j)+ghalf
14680 !grad gel_loc(l,k)=gel_loc(l,k)+ggg(l)
14683 ! Remaining derivatives of eello
14685 gel_loc(l,i)=gel_loc(l,i)+(aggi(l,1)*muij(1)+ &
14686 aggi(l,2)*muij(2)+aggi(l,3)*muij(3)+aggi(l,4)*muij(4))&
14689 gel_loc(l,i+1)=gel_loc(l,i+1)+(aggi1(l,1)*muij(1)+ &
14690 aggi1(l,2)*muij(2)+aggi1(l,3)*muij(3)+aggi1(l,4)*muij(4))&
14693 gel_loc(l,j)=gel_loc(l,j)+(aggj(l,1)*muij(1)+ &
14694 aggj(l,2)*muij(2)+aggj(l,3)*muij(3)+aggj(l,4)*muij(4))&
14697 gel_loc(l,j1)=gel_loc(l,j1)+(aggj1(l,1)*muij(1)+ &
14698 aggj1(l,2)*muij(2)+aggj1(l,3)*muij(3)+aggj1(l,4)*muij(4))&
14703 ! Change 12/26/95 to calculate four-body contributions to H-bonding energy
14704 ! if (j.gt.i+1 .and. num_conti.le.maxconts) then
14705 if (wcorr+wcorr4+wcorr5+wcorr6.gt.0.0d0 &
14706 .and. num_conti.le.maxconts) then
14707 ! write (iout,*) i,j," entered corr"
14709 ! Calculate the contact function. The ith column of the array JCONT will
14710 ! contain the numbers of atoms that make contacts with the atom I (of numbers
14711 ! greater than I). The arrays FACONT and GACONT will contain the values of
14712 ! the contact function and its derivative.
14713 ! r0ij=1.02D0*rpp(iteli,itelj)
14714 ! r0ij=1.11D0*rpp(iteli,itelj)
14715 r0ij=2.20D0*rpp(iteli,itelj)
14716 ! r0ij=1.55D0*rpp(iteli,itelj)
14717 call gcont(rij,r0ij,1.0D0,0.2d0*r0ij,fcont,fprimcont)
14718 !elwrite(iout,*) "num_conti",num_conti, "maxconts",maxconts
14719 if (fcont.gt.0.0D0) then
14720 num_conti=num_conti+1
14721 if (num_conti.gt.maxconts) then
14722 !elwrite(iout,*) "num_conti",num_conti, "maxconts",maxconts
14723 write (iout,*) 'WARNING - max. # of contacts exceeded;',&
14724 ' will skip next contacts for this conf.',num_conti
14726 jcont_hb(num_conti,i)=j
14727 !d write (iout,*) "i",i," j",j," num_conti",num_conti,
14728 !d & " jcont_hb",jcont_hb(num_conti,i)
14729 IF (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. &
14730 wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
14731 ! 9/30/99 (AL) - store components necessary to evaluate higher-order loc-el
14733 d_cont(num_conti,i)=rij
14734 !d write (2,'(3e15.5)') rij,r0ij+0.2d0*r0ij,rij
14735 ! --- Electrostatic-interaction matrix ---
14736 a_chuj(1,1,num_conti,i)=a22
14737 a_chuj(1,2,num_conti,i)=a23
14738 a_chuj(2,1,num_conti,i)=a32
14739 a_chuj(2,2,num_conti,i)=a33
14740 ! --- Gradient of rij
14742 grij_hb_cont(kkk,num_conti,i)=erij(kkk)
14749 a_chuj_der(k,l,m,1,num_conti,i)=agg(m,kkll)
14750 a_chuj_der(k,l,m,2,num_conti,i)=aggi(m,kkll)
14751 a_chuj_der(k,l,m,3,num_conti,i)=aggi1(m,kkll)
14752 a_chuj_der(k,l,m,4,num_conti,i)=aggj(m,kkll)
14753 a_chuj_der(k,l,m,5,num_conti,i)=aggj1(m,kkll)
14758 IF (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) THEN
14759 ! Calculate contact energies
14761 wij=cosa-3.0D0*cosb*cosg
14764 ! fac3=dsqrt(-ael6i)/r0ij**3
14765 fac3=dsqrt(-ael6i)*r3ij
14766 ! ees0pij=dsqrt(4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1)
14767 ees0tmp=4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1
14768 if (ees0tmp.gt.0) then
14769 ees0pij=dsqrt(ees0tmp)
14773 ! ees0mij=dsqrt(4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2)
14774 ees0tmp=4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2
14775 if (ees0tmp.gt.0) then
14776 ees0mij=dsqrt(ees0tmp)
14781 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij) &
14784 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij) &
14787 ! Diagnostics. Comment out or remove after debugging!
14788 ! ees0p(num_conti,i)=0.5D0*fac3*ees0pij
14789 ! ees0m(num_conti,i)=0.5D0*fac3*ees0mij
14790 ! ees0m(num_conti,i)=0.0D0
14792 ! write (iout,*) 'i=',i,' j=',j,' rij=',rij,' r0ij=',r0ij,
14793 ! & ' ees0ij=',ees0p(num_conti,i),ees0m(num_conti,i),' fcont=',fcont
14794 ! Angular derivatives of the contact function
14795 ees0pij1=fac3/ees0pij
14796 ees0mij1=fac3/ees0mij
14797 fac3p=-3.0D0*fac3*rrmij
14798 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
14799 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
14801 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
14802 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
14803 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
14804 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
14805 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
14806 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
14807 ecosap=ecosa1+ecosa2
14808 ecosbp=ecosb1+ecosb2
14809 ecosgp=ecosg1+ecosg2
14810 ecosam=ecosa1-ecosa2
14811 ecosbm=ecosb1-ecosb2
14812 ecosgm=ecosg1-ecosg2
14821 facont_hb(num_conti,i)=fcont
14822 fprimcont=fprimcont/rij
14823 !d facont_hb(num_conti,i)=1.0D0
14824 ! Following line is for diagnostics.
14827 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
14828 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
14831 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
14832 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
14834 ! gggp(1)=gggp(1)+ees0pijp*xj
14835 ! gggp(2)=gggp(2)+ees0pijp*yj
14836 ! gggp(3)=gggp(3)+ees0pijp*zj
14837 ! gggm(1)=gggm(1)+ees0mijp*xj
14838 ! gggm(2)=gggm(2)+ees0mijp*yj
14839 ! gggm(3)=gggm(3)+ees0mijp*zj
14840 gggp(1)=gggp(1)+ees0pijp*xj &
14841 +ees0p(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
14842 gggp(2)=gggp(2)+ees0pijp*yj &
14843 +ees0p(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
14844 gggp(3)=gggp(3)+ees0pijp*zj &
14845 +ees0p(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
14847 gggm(1)=gggm(1)+ees0mijp*xj &
14848 +ees0m(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
14850 gggm(2)=gggm(2)+ees0mijp*yj &
14851 +ees0m(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
14853 gggm(3)=gggm(3)+ees0mijp*zj &
14854 +ees0m(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
14856 ! Derivatives due to the contact function
14857 gacont_hbr(1,num_conti,i)=fprimcont*xj
14858 gacont_hbr(2,num_conti,i)=fprimcont*yj
14859 gacont_hbr(3,num_conti,i)=fprimcont*zj
14862 ! 10/24/08 cgrad and ! comments indicate the parts of the code removed
14863 ! following the change of gradient-summation algorithm.
14865 !grad ghalfp=0.5D0*gggp(k)
14866 !grad ghalfm=0.5D0*gggm(k)
14867 ! gacontp_hb1(k,num_conti,i)= & !ghalfp
14868 ! +(ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
14869 ! + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
14870 ! gacontp_hb2(k,num_conti,i)= & !ghalfp
14871 ! +(ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
14872 ! + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
14873 ! gacontp_hb3(k,num_conti,i)=gggp(k)
14874 ! gacontm_hb1(k,num_conti,i)= &!ghalfm
14875 ! +(ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
14876 ! + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
14877 ! gacontm_hb2(k,num_conti,i)= & !ghalfm
14878 ! +(ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
14879 ! + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
14880 ! gacontm_hb3(k,num_conti,i)=gggm(k)
14881 gacontp_hb1(k,num_conti,i)= & !ghalfp+
14882 (ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
14883 + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
14886 gacontp_hb2(k,num_conti,i)= & !ghalfp+
14887 (ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
14888 + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
14891 gacontp_hb3(k,num_conti,i)=gggp(k) &
14894 gacontm_hb1(k,num_conti,i)= & !ghalfm+
14895 (ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
14896 + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
14899 gacontm_hb2(k,num_conti,i)= & !ghalfm+
14900 (ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
14901 + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1) &
14904 gacontm_hb3(k,num_conti,i)=gggm(k) &
14909 endif ! num_conti.le.maxconts
14912 if (wturn3.gt.0.0d0 .or. wturn4.gt.0.0d0) then
14915 ghalf=0.5d0*agg(l,k)
14916 aggi(l,k)=aggi(l,k)+ghalf
14917 aggi1(l,k)=aggi1(l,k)+agg(l,k)
14918 aggj(l,k)=aggj(l,k)+ghalf
14921 if (j.eq.nres-1 .and. i.lt.j-2) then
14924 aggj1(l,k)=aggj1(l,k)+agg(l,k)
14930 ! t_eelecij=t_eelecij+MPI_Wtime()-time00
14932 end subroutine eelecij_scale
14933 !-----------------------------------------------------------------------------
14934 subroutine evdwpp_short(evdw1)
14938 ! implicit real*8 (a-h,o-z)
14939 ! include 'DIMENSIONS'
14940 ! include 'COMMON.CONTROL'
14941 ! include 'COMMON.IOUNITS'
14942 ! include 'COMMON.GEO'
14943 ! include 'COMMON.VAR'
14944 ! include 'COMMON.LOCAL'
14945 ! include 'COMMON.CHAIN'
14946 ! include 'COMMON.DERIV'
14947 ! include 'COMMON.INTERACT'
14948 ! include 'COMMON.CONTACTS'
14949 ! include 'COMMON.TORSION'
14950 ! include 'COMMON.VECTORS'
14951 ! include 'COMMON.FFIELD'
14952 real(kind=8),dimension(3) :: ggg
14953 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
14955 real(kind=8) :: scal_el=1.0d0
14957 real(kind=8) :: scal_el=0.5d0
14959 !el local variables
14960 integer :: i,j,k,iteli,itelj,num_conti,isubchap
14961 real(kind=8) :: dxi,dyi,dzi,dxj,dyj,dzj,aaa,bbb
14962 real(kind=8) :: xj,yj,zj,rij,rrmij,sss,r3ij,r6ij,evdw1,&
14963 dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
14964 dx_normj,dy_normj,dz_normj,rmij,ev1,ev2,evdwij,facvdw
14965 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
14966 dist_temp, dist_init,sss_grad
14967 integer xshift,yshift,zshift
14971 ! write (iout,*) "iatel_s_vdw",iatel_s_vdw,
14972 ! & " iatel_e_vdw",iatel_e_vdw
14974 do i=iatel_s_vdw,iatel_e_vdw
14975 if (itype(i,1).eq.ntyp1.or. itype(i+1,1).eq.ntyp1) cycle
14979 dx_normi=dc_norm(1,i)
14980 dy_normi=dc_norm(2,i)
14981 dz_normi=dc_norm(3,i)
14982 xmedi=c(1,i)+0.5d0*dxi
14983 ymedi=c(2,i)+0.5d0*dyi
14984 zmedi=c(3,i)+0.5d0*dzi
14985 xmedi=dmod(xmedi,boxxsize)
14986 if (xmedi.lt.0) xmedi=xmedi+boxxsize
14987 ymedi=dmod(ymedi,boxysize)
14988 if (ymedi.lt.0) ymedi=ymedi+boxysize
14989 zmedi=dmod(zmedi,boxzsize)
14990 if (zmedi.lt.0) zmedi=zmedi+boxzsize
14992 ! write (iout,*) 'i',i,' ielstart',ielstart_vdw(i),
14993 ! & ' ielend',ielend_vdw(i)
14995 do j=ielstart_vdw(i),ielend_vdw(i)
14996 if (itype(j,1).eq.ntyp1 .or. itype(j+1,1).eq.ntyp1) cycle
15000 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
15001 aaa=app(iteli,itelj)
15002 bbb=bpp(iteli,itelj)
15006 dx_normj=dc_norm(1,j)
15007 dy_normj=dc_norm(2,j)
15008 dz_normj=dc_norm(3,j)
15009 ! xj=c(1,j)+0.5D0*dxj-xmedi
15010 ! yj=c(2,j)+0.5D0*dyj-ymedi
15011 ! zj=c(3,j)+0.5D0*dzj-zmedi
15012 xj=c(1,j)+0.5D0*dxj
15013 yj=c(2,j)+0.5D0*dyj
15014 zj=c(3,j)+0.5D0*dzj
15015 xj=mod(xj,boxxsize)
15016 if (xj.lt.0) xj=xj+boxxsize
15017 yj=mod(yj,boxysize)
15018 if (yj.lt.0) yj=yj+boxysize
15019 zj=mod(zj,boxzsize)
15020 if (zj.lt.0) zj=zj+boxzsize
15022 dist_init=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
15029 xj=xj_safe+xshift*boxxsize
15030 yj=yj_safe+yshift*boxysize
15031 zj=zj_safe+zshift*boxzsize
15032 dist_temp=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
15033 if(dist_temp.lt.dist_init) then
15034 dist_init=dist_temp
15043 if (isubchap.eq.1) then
15054 rij=xj*xj+yj*yj+zj*zj
15057 sss=sscale(rij/rpp(iteli,itelj))
15058 sss_ele_cut=sscale_ele(rij)
15059 sss_ele_grad=sscagrad_ele(rij)
15060 sss_grad=sscale_grad((rij/rpp(iteli,itelj)))
15061 if (sss_ele_cut.le.0.0) cycle
15062 if (sss.gt.0.0d0) then
15067 ! 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
15068 if (j.eq.i+2) ev1=scal_el*ev1
15071 if (energy_dec) then
15072 write (iout,'(a6,2i5,0pf7.3,f7.3)') 'evdw1',i,j,evdwij,sss
15074 evdw1=evdw1+evdwij*sss*sss_ele_cut
15076 ! Calculate contributions to the Cartesian gradient.
15078 facvdw=-6*rrmij*(ev1+evdwij)*sss*sss_ele_cut
15082 ggg(1)=facvdw*xj+sss_ele_grad*rmij*evdwij*xj*sss &
15083 +evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*xj
15084 ggg(2)=facvdw*yj+sss_ele_grad*rmij*evdwij*yj*sss &
15085 +evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*yj
15086 ggg(3)=facvdw*zj+sss_ele_grad*rmij*evdwij*zj*sss &
15087 +evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*zj
15090 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
15091 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
15097 end subroutine evdwpp_short
15098 !-----------------------------------------------------------------------------
15099 subroutine escp_long(evdw2,evdw2_14)
15101 ! This subroutine calculates the excluded-volume interaction energy between
15102 ! peptide-group centers and side chains and its gradient in virtual-bond and
15103 ! side-chain vectors.
15105 ! implicit real*8 (a-h,o-z)
15106 ! include 'DIMENSIONS'
15107 ! include 'COMMON.GEO'
15108 ! include 'COMMON.VAR'
15109 ! include 'COMMON.LOCAL'
15110 ! include 'COMMON.CHAIN'
15111 ! include 'COMMON.DERIV'
15112 ! include 'COMMON.INTERACT'
15113 ! include 'COMMON.FFIELD'
15114 ! include 'COMMON.IOUNITS'
15115 ! include 'COMMON.CONTROL'
15116 real(kind=8),dimension(3) :: ggg
15117 !el local variables
15118 integer :: i,iint,j,k,iteli,itypj,subchap
15119 real(kind=8) :: xi,yi,zi,xj,yj,zj,rrij,sss,fac,e1,e2,sss_grad,rij
15120 real(kind=8) :: evdw2,evdw2_14,evdwij
15121 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
15122 dist_temp, dist_init
15126 !d print '(a)','Enter ESCP'
15127 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
15128 do i=iatscp_s,iatscp_e
15129 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
15131 xi=0.5D0*(c(1,i)+c(1,i+1))
15132 yi=0.5D0*(c(2,i)+c(2,i+1))
15133 zi=0.5D0*(c(3,i)+c(3,i+1))
15134 xi=mod(xi,boxxsize)
15135 if (xi.lt.0) xi=xi+boxxsize
15136 yi=mod(yi,boxysize)
15137 if (yi.lt.0) yi=yi+boxysize
15138 zi=mod(zi,boxzsize)
15139 if (zi.lt.0) zi=zi+boxzsize
15141 do iint=1,nscp_gr(i)
15143 do j=iscpstart(i,iint),iscpend(i,iint)
15145 if (itypj.eq.ntyp1) cycle
15146 ! Uncomment following three lines for SC-p interactions
15147 ! xj=c(1,nres+j)-xi
15148 ! yj=c(2,nres+j)-yi
15149 ! zj=c(3,nres+j)-zi
15150 ! Uncomment following three lines for Ca-p interactions
15154 xj=mod(xj,boxxsize)
15155 if (xj.lt.0) xj=xj+boxxsize
15156 yj=mod(yj,boxysize)
15157 if (yj.lt.0) yj=yj+boxysize
15158 zj=mod(zj,boxzsize)
15159 if (zj.lt.0) zj=zj+boxzsize
15160 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
15168 xj=xj_safe+xshift*boxxsize
15169 yj=yj_safe+yshift*boxysize
15170 zj=zj_safe+zshift*boxzsize
15171 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
15172 if(dist_temp.lt.dist_init) then
15173 dist_init=dist_temp
15182 if (subchap.eq.1) then
15191 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
15193 rij=dsqrt(1.0d0/rrij)
15194 sss_ele_cut=sscale_ele(rij)
15195 sss_ele_grad=sscagrad_ele(rij)
15196 ! print *,sss_ele_cut,sss_ele_grad,&
15197 ! (rij),r_cut_ele,rlamb_ele
15198 if (sss_ele_cut.le.0.0) cycle
15199 sss=sscale((rij/rscp(itypj,iteli)))
15200 sss_grad=sscale_grad(rij/rscp(itypj,iteli))
15201 if (sss.lt.1.0d0) then
15204 e1=fac*fac*aad(itypj,iteli)
15205 e2=fac*bad(itypj,iteli)
15206 if (iabs(j-i) .le. 2) then
15209 evdw2_14=evdw2_14+(e1+e2)*(1.0d0-sss)*sss_ele_cut
15212 evdw2=evdw2+evdwij*(1.0d0-sss)*sss_ele_cut
15213 if (energy_dec) write (iout,'(a6,2i5,2(0pf7.3))') &
15214 'evdw2',i,j,sss,evdwij
15216 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
15218 fac=-(evdwij+e1)*rrij*(1.0d0-sss)*sss_ele_cut
15219 fac=fac+evdwij*sss_ele_grad/rij/expon*(1.0d0-sss)&
15220 -evdwij*sss_ele_cut/rij/expon*sss_grad/rscp(itypj,iteli)
15224 ! Uncomment following three lines for SC-p interactions
15226 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
15228 ! Uncomment following line for SC-p interactions
15229 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
15231 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
15232 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
15241 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
15242 gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
15243 gradx_scp(j,i)=expon*gradx_scp(j,i)
15246 !******************************************************************************
15250 ! To save time the factor EXPON has been extracted from ALL components
15251 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
15254 !******************************************************************************
15256 end subroutine escp_long
15257 !-----------------------------------------------------------------------------
15258 subroutine escp_short(evdw2,evdw2_14)
15260 ! This subroutine calculates the excluded-volume interaction energy between
15261 ! peptide-group centers and side chains and its gradient in virtual-bond and
15262 ! side-chain vectors.
15264 ! implicit real*8 (a-h,o-z)
15265 ! include 'DIMENSIONS'
15266 ! include 'COMMON.GEO'
15267 ! include 'COMMON.VAR'
15268 ! include 'COMMON.LOCAL'
15269 ! include 'COMMON.CHAIN'
15270 ! include 'COMMON.DERIV'
15271 ! include 'COMMON.INTERACT'
15272 ! include 'COMMON.FFIELD'
15273 ! include 'COMMON.IOUNITS'
15274 ! include 'COMMON.CONTROL'
15275 real(kind=8),dimension(3) :: ggg
15276 !el local variables
15277 integer :: i,iint,j,k,iteli,itypj,subchap
15278 real(kind=8) :: xi,yi,zi,xj,yj,zj,rrij,sss,fac,e1,e2,sss_grad,rij
15279 real(kind=8) :: evdw2,evdw2_14,evdwij
15280 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
15281 dist_temp, dist_init
15285 !d print '(a)','Enter ESCP'
15286 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
15287 do i=iatscp_s,iatscp_e
15288 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
15290 xi=0.5D0*(c(1,i)+c(1,i+1))
15291 yi=0.5D0*(c(2,i)+c(2,i+1))
15292 zi=0.5D0*(c(3,i)+c(3,i+1))
15293 xi=mod(xi,boxxsize)
15294 if (xi.lt.0) xi=xi+boxxsize
15295 yi=mod(yi,boxysize)
15296 if (yi.lt.0) yi=yi+boxysize
15297 zi=mod(zi,boxzsize)
15298 if (zi.lt.0) zi=zi+boxzsize
15300 do iint=1,nscp_gr(i)
15302 do j=iscpstart(i,iint),iscpend(i,iint)
15304 if (itypj.eq.ntyp1) cycle
15305 ! Uncomment following three lines for SC-p interactions
15306 ! xj=c(1,nres+j)-xi
15307 ! yj=c(2,nres+j)-yi
15308 ! zj=c(3,nres+j)-zi
15309 ! Uncomment following three lines for Ca-p interactions
15316 xj=mod(xj,boxxsize)
15317 if (xj.lt.0) xj=xj+boxxsize
15318 yj=mod(yj,boxysize)
15319 if (yj.lt.0) yj=yj+boxysize
15320 zj=mod(zj,boxzsize)
15321 if (zj.lt.0) zj=zj+boxzsize
15322 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
15330 xj=xj_safe+xshift*boxxsize
15331 yj=yj_safe+yshift*boxysize
15332 zj=zj_safe+zshift*boxzsize
15333 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
15334 if(dist_temp.lt.dist_init) then
15335 dist_init=dist_temp
15344 if (subchap.eq.1) then
15354 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
15355 rij=dsqrt(1.0d0/rrij)
15356 sss_ele_cut=sscale_ele(rij)
15357 sss_ele_grad=sscagrad_ele(rij)
15358 ! print *,sss_ele_cut,sss_ele_grad,&
15359 ! (rij),r_cut_ele,rlamb_ele
15360 if (sss_ele_cut.le.0.0) cycle
15361 sss=sscale(rij/rscp(itypj,iteli))
15362 sss_grad=sscale_grad(rij/rscp(itypj,iteli))
15363 if (sss.gt.0.0d0) then
15366 e1=fac*fac*aad(itypj,iteli)
15367 e2=fac*bad(itypj,iteli)
15368 if (iabs(j-i) .le. 2) then
15371 evdw2_14=evdw2_14+(e1+e2)*sss*sss_ele_cut
15374 evdw2=evdw2+evdwij*sss*sss_ele_cut
15375 if (energy_dec) write (iout,'(a6,2i5,2(0pf7.3))') &
15376 'evdw2',i,j,sss,evdwij
15378 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
15380 fac=-(evdwij+e1)*rrij*sss*sss_ele_cut
15381 fac=fac+evdwij*sss_ele_grad/rij/expon*sss &
15382 +evdwij*sss_ele_cut/rij/expon*sss_grad/rscp(itypj,iteli)
15387 ! Uncomment following three lines for SC-p interactions
15389 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
15391 ! Uncomment following line for SC-p interactions
15392 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
15394 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
15395 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
15404 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
15405 gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
15406 gradx_scp(j,i)=expon*gradx_scp(j,i)
15409 !******************************************************************************
15413 ! To save time the factor EXPON has been extracted from ALL components
15414 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
15417 !******************************************************************************
15419 end subroutine escp_short
15420 !-----------------------------------------------------------------------------
15421 ! energy_p_new-sep_barrier.F
15422 !-----------------------------------------------------------------------------
15423 subroutine sc_grad_scale(scalfac)
15424 ! implicit real*8 (a-h,o-z)
15426 ! include 'DIMENSIONS'
15427 ! include 'COMMON.CHAIN'
15428 ! include 'COMMON.DERIV'
15429 ! include 'COMMON.CALC'
15430 ! include 'COMMON.IOUNITS'
15431 real(kind=8),dimension(3) :: dcosom1,dcosom2
15432 real(kind=8) :: scalfac
15433 !el local variables
15434 ! integer :: i,j,k,l
15436 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
15437 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
15438 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12 &
15439 -2.0D0*alf12*eps3der+sigder*sigsq_om12
15443 ! eom12=evdwij*eps1_om12
15445 ! write (iout,*) "eps2der",eps2der," eps3der",eps3der,
15446 ! & " sigder",sigder
15447 ! write (iout,*) "eps1_om12",eps1_om12," eps2rt_om12",eps2rt_om12
15448 ! write (iout,*) "eom1",eom1," eom2",eom2," eom12",eom12
15450 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
15451 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
15454 gg(k)=(gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k))*scalfac&
15457 ! write (iout,*) "gg",(gg(k),k=1,3)
15459 gvdwx(k,i)=gvdwx(k,i)-gg(k) &
15460 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
15461 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv*scalfac&
15463 gvdwx(k,j)=gvdwx(k,j)+gg(k) &
15464 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
15465 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv*scalfac&
15467 ! write (iout,*)(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))
15468 ! & +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
15469 ! write (iout,*)(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))
15470 ! & +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
15473 ! Calculate the components of the gradient in DC and X
15476 gvdwc(l,i)=gvdwc(l,i)-gg(l)
15477 gvdwc(l,j)=gvdwc(l,j)+gg(l)
15480 end subroutine sc_grad_scale
15481 !-----------------------------------------------------------------------------
15482 ! energy_split-sep.F
15483 !-----------------------------------------------------------------------------
15484 subroutine etotal_long(energia)
15486 ! Compute the long-range slow-varying contributions to the energy
15488 ! implicit real*8 (a-h,o-z)
15489 ! include 'DIMENSIONS'
15490 use MD_data, only: totT,usampl,eq_time
15494 !MS$ATTRIBUTES C :: proc_proc
15499 real(kind=8),dimension(n_ene) :: weights_!,time_Bcast,time_Bcastw
15501 ! include 'COMMON.SETUP'
15502 ! include 'COMMON.IOUNITS'
15503 ! include 'COMMON.FFIELD'
15504 ! include 'COMMON.DERIV'
15505 ! include 'COMMON.INTERACT'
15506 ! include 'COMMON.SBRIDGE'
15507 ! include 'COMMON.CHAIN'
15508 ! include 'COMMON.VAR'
15509 ! include 'COMMON.LOCAL'
15510 ! include 'COMMON.MD'
15511 real(kind=8),dimension(0:n_ene) :: energia
15512 !el local variables
15513 integer :: i,n_corr,n_corr1,ierror,ierr
15514 real(kind=8) :: evdw2,evdw2_14,ehpb,etors,edihcnstr,etors_d,esccor,&
15515 evdw,ees,evdw1,eel_loc,eello_turn3,eello_turn4,&
15516 ecorr,ecorr5,ecorr6,eturn6,time00
15517 ! write(iout,'(a,i2)')'Calling etotal_long ipot=',ipot
15518 !elwrite(iout,*)"in etotal long"
15520 if (modecalc.eq.12.or.modecalc.eq.14) then
15522 ! if (fg_rank.eq.0) call int_from_cart1(.false.)
15524 call int_from_cart1(.false.)
15527 !elwrite(iout,*)"in etotal long"
15530 ! write(iout,*) "ETOTAL_LONG Processor",fg_rank,
15531 ! & " absolute rank",myrank," nfgtasks",nfgtasks
15533 if (nfgtasks.gt.1) then
15535 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
15536 if (fg_rank.eq.0) then
15537 call MPI_Bcast(3,1,MPI_INTEGER,king,FG_COMM,IERROR)
15538 ! write (iout,*) "Processor",myrank," BROADCAST iorder"
15540 ! FG master sets up the WEIGHTS_ array which will be broadcast to the
15541 ! FG slaves as WEIGHTS array.
15548 weights_(7)=wel_loc
15551 weights_(10)=wturn6
15553 weights_(12)=wscloc
15555 weights_(14)=wtor_d
15556 weights_(15)=wstrain
15557 weights_(16)=wvdwpp
15559 weights_(18)=scal14
15560 weights_(21)=wsccor
15561 ! FG Master broadcasts the WEIGHTS_ array
15562 call MPI_Bcast(weights_(1),n_ene,&
15563 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
15565 ! FG slaves receive the WEIGHTS array
15566 call MPI_Bcast(weights(1),n_ene,&
15567 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
15582 wstrain=weights(15)
15588 call MPI_Bcast(dc(1,1),6*nres,MPI_DOUBLE_PRECISION,&
15590 time_Bcast=time_Bcast+MPI_Wtime()-time00
15591 time_Bcastw=time_Bcastw+MPI_Wtime()-time00
15592 ! call chainbuild_cart
15593 ! call int_from_cart1(.false.)
15595 ! write (iout,*) 'Processor',myrank,
15596 ! & ' calling etotal_short ipot=',ipot
15598 ! print *,'Processor',myrank,' nnt=',nnt,' nct=',nct
15600 !d print *,'nnt=',nnt,' nct=',nct
15602 !elwrite(iout,*)"in etotal long"
15603 ! Compute the side-chain and electrostatic interaction energy
15605 goto (101,102,103,104,105,106) ipot
15606 ! Lennard-Jones potential.
15607 101 call elj_long(evdw)
15608 !d print '(a)','Exit ELJ'
15610 ! Lennard-Jones-Kihara potential (shifted).
15611 102 call eljk_long(evdw)
15613 ! Berne-Pechukas potential (dilated LJ, angular dependence).
15614 103 call ebp_long(evdw)
15616 ! Gay-Berne potential (shifted LJ, angular dependence).
15617 104 call egb_long(evdw)
15619 ! Gay-Berne-Vorobjev potential (shifted LJ, angular dependence).
15620 105 call egbv_long(evdw)
15622 ! Soft-sphere potential
15623 106 call e_softsphere(evdw)
15625 ! Calculate electrostatic (H-bonding) energy of the main chain.
15629 if (ipot.lt.6) then
15631 if (welec.gt.0d0.or.wvdwpp.gt.0d0.or.wel_loc.gt.0d0.or. &
15632 wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0 &
15633 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
15634 .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
15636 if (welec.gt.0d0.or.wel_loc.gt.0d0.or. &
15637 wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0 &
15638 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
15639 .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
15641 call eelec_scale(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
15650 ! write (iout,*) "Soft-spheer ELEC potential"
15651 call eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,&
15655 ! Calculate excluded-volume interaction energy between peptide groups
15658 if (ipot.lt.6) then
15659 if(wscp.gt.0d0) then
15660 call escp_long(evdw2,evdw2_14)
15666 call escp_soft_sphere(evdw2,evdw2_14)
15669 ! 12/1/95 Multi-body terms
15673 if ((wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 &
15674 .or. wturn6.gt.0.0d0) .and. ipot.lt.6) then
15675 call multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
15676 ! write (2,*) 'n_corr=',n_corr,' n_corr1=',n_corr1,
15677 ! &" ecorr",ecorr," ecorr5",ecorr5," ecorr6",ecorr6," eturn6",eturn6
15684 if ((wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) .and. ipot.lt.6) then
15685 call multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
15688 ! If performing constraint dynamics, call the constraint energy
15689 ! after the equilibration time
15690 if(usampl.and.totT.gt.eq_time) then
15705 energia(2)=evdw2-evdw2_14
15706 energia(18)=evdw2_14
15715 energia(3)=ees+evdw1
15722 energia(8)=eello_turn3
15723 energia(9)=eello_turn4
15725 energia(20)=Uconst+Uconst_back
15726 call sum_energy(energia,.true.)
15727 ! write (iout,*) "Exit ETOTAL_LONG"
15730 end subroutine etotal_long
15731 !-----------------------------------------------------------------------------
15732 subroutine etotal_short(energia)
15734 ! Compute the short-range fast-varying contributions to the energy
15736 ! implicit real*8 (a-h,o-z)
15737 ! include 'DIMENSIONS'
15741 !MS$ATTRIBUTES C :: proc_proc
15746 integer :: ierror,ierr
15747 real(kind=8),dimension(n_ene) :: weights_
15748 real(kind=8) :: time00
15750 ! include 'COMMON.SETUP'
15751 ! include 'COMMON.IOUNITS'
15752 ! include 'COMMON.FFIELD'
15753 ! include 'COMMON.DERIV'
15754 ! include 'COMMON.INTERACT'
15755 ! include 'COMMON.SBRIDGE'
15756 ! include 'COMMON.CHAIN'
15757 ! include 'COMMON.VAR'
15758 ! include 'COMMON.LOCAL'
15759 real(kind=8),dimension(0:n_ene) :: energia
15760 !el local variables
15762 real(kind=8) :: evdw,evdw1,evdw2,evdw2_14,esccor,etors_d,etors
15763 real(kind=8) :: ehpb,escloc,estr,ebe,edihcnstr,ethetacnstr
15766 ! write(iout,'(a,i2)')'Calling etotal_short ipot=',ipot
15768 if (modecalc.eq.12.or.modecalc.eq.14) then
15770 if (fg_rank.eq.0) call int_from_cart1(.false.)
15772 call int_from_cart1(.false.)
15776 ! write(iout,*) "ETOTAL_SHORT Processor",fg_rank,
15777 ! & " absolute rank",myrank," nfgtasks",nfgtasks
15779 if (nfgtasks.gt.1) then
15781 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
15782 if (fg_rank.eq.0) then
15783 call MPI_Bcast(2,1,MPI_INTEGER,king,FG_COMM,IERROR)
15784 ! write (iout,*) "Processor",myrank," BROADCAST iorder"
15786 ! FG master sets up the WEIGHTS_ array which will be broadcast to the
15787 ! FG slaves as WEIGHTS array.
15794 weights_(7)=wel_loc
15797 weights_(10)=wturn6
15799 weights_(12)=wscloc
15801 weights_(14)=wtor_d
15802 weights_(15)=wstrain
15803 weights_(16)=wvdwpp
15805 weights_(18)=scal14
15806 weights_(21)=wsccor
15807 ! FG Master broadcasts the WEIGHTS_ array
15808 call MPI_Bcast(weights_(1),n_ene,&
15809 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
15811 ! FG slaves receive the WEIGHTS array
15812 call MPI_Bcast(weights(1),n_ene,&
15813 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
15828 wstrain=weights(15)
15834 ! write (iout,*),"Processor",myrank," BROADCAST weights"
15835 call MPI_Bcast(c(1,1),nres6,MPI_DOUBLE_PRECISION,&
15837 ! write (iout,*) "Processor",myrank," BROADCAST c"
15838 call MPI_Bcast(dc(1,1),nres6,MPI_DOUBLE_PRECISION,&
15840 ! write (iout,*) "Processor",myrank," BROADCAST dc"
15841 call MPI_Bcast(dc_norm(1,1),nres6,MPI_DOUBLE_PRECISION,&
15843 ! write (iout,*) "Processor",myrank," BROADCAST dc_norm"
15844 call MPI_Bcast(theta(1),nres,MPI_DOUBLE_PRECISION,&
15846 ! write (iout,*) "Processor",myrank," BROADCAST theta"
15847 call MPI_Bcast(phi(1),nres,MPI_DOUBLE_PRECISION,&
15849 ! write (iout,*) "Processor",myrank," BROADCAST phi"
15850 call MPI_Bcast(alph(1),nres,MPI_DOUBLE_PRECISION,&
15852 ! write (iout,*) "Processor",myrank," BROADCAST alph"
15853 call MPI_Bcast(omeg(1),nres,MPI_DOUBLE_PRECISION,&
15855 ! write (iout,*) "Processor",myrank," BROADCAST omeg"
15856 call MPI_Bcast(vbld(1),2*nres,MPI_DOUBLE_PRECISION,&
15858 ! write (iout,*) "Processor",myrank," BROADCAST vbld"
15859 call MPI_Bcast(vbld_inv(1),2*nres,MPI_DOUBLE_PRECISION,&
15861 time_Bcast=time_Bcast+MPI_Wtime()-time00
15862 ! write (iout,*) "Processor",myrank," BROADCAST vbld_inv"
15864 ! write (iout,*) 'Processor',myrank,
15865 ! & ' calling etotal_short ipot=',ipot
15867 ! print *,'Processor',myrank,' nnt=',nnt,' nct=',nct
15869 ! call int_from_cart1(.false.)
15871 ! Compute the side-chain and electrostatic interaction energy
15873 goto (101,102,103,104,105,106) ipot
15874 ! Lennard-Jones potential.
15875 101 call elj_short(evdw)
15876 !d print '(a)','Exit ELJ'
15878 ! Lennard-Jones-Kihara potential (shifted).
15879 102 call eljk_short(evdw)
15881 ! Berne-Pechukas potential (dilated LJ, angular dependence).
15882 103 call ebp_short(evdw)
15884 ! Gay-Berne potential (shifted LJ, angular dependence).
15885 104 call egb_short(evdw)
15887 ! Gay-Berne-Vorobjev potential (shifted LJ, angular dependence).
15888 105 call egbv_short(evdw)
15890 ! Soft-sphere potential - already dealt with in the long-range part
15892 ! 106 call e_softsphere_short(evdw)
15894 ! Calculate electrostatic (H-bonding) energy of the main chain.
15898 ! Calculate the short-range part of Evdwpp
15900 call evdwpp_short(evdw1)
15902 ! Calculate the short-range part of ESCp
15904 if (ipot.lt.6) then
15905 call escp_short(evdw2,evdw2_14)
15908 ! Calculate the bond-stretching energy
15912 ! Calculate the disulfide-bridge and other energy and the contributions
15913 ! from other distance constraints.
15916 ! Calculate the virtual-bond-angle energy.
15918 call ebend(ebe,ethetacnstr)
15920 ! Calculate the SC local energy.
15925 ! Calculate the virtual-bond torsional energy.
15927 call etor(etors,edihcnstr)
15929 ! 6/23/01 Calculate double-torsional energy
15931 call etor_d(etors_d)
15933 ! 21/5/07 Calculate local sicdechain correlation energy
15935 if (wsccor.gt.0.0d0) then
15936 call eback_sc_corr(esccor)
15941 ! Put energy components into an array
15948 energia(2)=evdw2-evdw2_14
15949 energia(18)=evdw2_14
15962 energia(14)=etors_d
15965 energia(19)=edihcnstr
15967 ! write (iout,*) "ETOTAL_SHORT before SUM_ENERGY"
15969 call sum_energy(energia,.true.)
15970 ! write (iout,*) "Exit ETOTAL_SHORT"
15973 end subroutine etotal_short
15974 !-----------------------------------------------------------------------------
15976 !-----------------------------------------------------------------------------
15977 real(kind=8) function gnmr1(y,ymin,ymax)
15979 real(kind=8) :: y,ymin,ymax
15980 real(kind=8) :: wykl=4.0d0
15981 if (y.lt.ymin) then
15982 gnmr1=(ymin-y)**wykl/wykl
15983 else if (y.gt.ymax) then
15984 gnmr1=(y-ymax)**wykl/wykl
15990 !-----------------------------------------------------------------------------
15991 real(kind=8) function gnmr1prim(y,ymin,ymax)
15993 real(kind=8) :: y,ymin,ymax
15994 real(kind=8) :: wykl=4.0d0
15995 if (y.lt.ymin) then
15996 gnmr1prim=-(ymin-y)**(wykl-1)
15997 else if (y.gt.ymax) then
15998 gnmr1prim=(y-ymax)**(wykl-1)
16003 end function gnmr1prim
16004 !----------------------------------------------------------------------------
16005 real(kind=8) function rlornmr1(y,ymin,ymax,sigma)
16006 real(kind=8) y,ymin,ymax,sigma
16007 real(kind=8) wykl /4.0d0/
16008 if (y.lt.ymin) then
16009 rlornmr1=(ymin-y)**wykl/((ymin-y)**wykl+sigma**wykl)
16010 else if (y.gt.ymax) then
16011 rlornmr1=(y-ymax)**wykl/((y-ymax)**wykl+sigma**wykl)
16016 end function rlornmr1
16017 !------------------------------------------------------------------------------
16018 real(kind=8) function rlornmr1prim(y,ymin,ymax,sigma)
16019 real(kind=8) y,ymin,ymax,sigma
16020 real(kind=8) wykl /4.0d0/
16021 if (y.lt.ymin) then
16022 rlornmr1prim=-(ymin-y)**(wykl-1)*sigma**wykl*wykl/ &
16023 ((ymin-y)**wykl+sigma**wykl)**2
16024 else if (y.gt.ymax) then
16025 rlornmr1prim=(y-ymax)**(wykl-1)*sigma**wykl*wykl/ &
16026 ((y-ymax)**wykl+sigma**wykl)**2
16031 end function rlornmr1prim
16033 real(kind=8) function harmonic(y,ymax)
16035 real(kind=8) :: y,ymax
16036 real(kind=8) :: wykl=2.0d0
16037 harmonic=(y-ymax)**wykl
16039 end function harmonic
16040 !-----------------------------------------------------------------------------
16041 real(kind=8) function harmonicprim(y,ymax)
16042 real(kind=8) :: y,ymin,ymax
16043 real(kind=8) :: wykl=2.0d0
16044 harmonicprim=(y-ymax)*wykl
16046 end function harmonicprim
16047 !-----------------------------------------------------------------------------
16049 !-----------------------------------------------------------------------------
16050 subroutine gradient(n,x,nf,g,uiparm,urparm,ufparm)
16052 use io_base, only:intout,briefout
16053 ! implicit real*8 (a-h,o-z)
16054 ! include 'DIMENSIONS'
16055 ! include 'COMMON.CHAIN'
16056 ! include 'COMMON.DERIV'
16057 ! include 'COMMON.VAR'
16058 ! include 'COMMON.INTERACT'
16059 ! include 'COMMON.FFIELD'
16060 ! include 'COMMON.MD'
16061 ! include 'COMMON.IOUNITS'
16062 real(kind=8),external :: ufparm
16063 integer :: uiparm(1)
16064 real(kind=8) :: urparm(1)
16065 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
16066 real(kind=8) :: f,gthetai,gphii,galphai,gomegai
16067 integer :: n,nf,ind,ind1,i,k,j
16069 ! This subroutine calculates total internal coordinate gradient.
16070 ! Depending on the number of function evaluations, either whole energy
16071 ! is evaluated beforehand, Cartesian coordinates and their derivatives in
16072 ! internal coordinates are reevaluated or only the cartesian-in-internal
16073 ! coordinate derivatives are evaluated. The subroutine was designed to work
16079 !d print *,'grad',nf,icg
16080 if (nf-nfl+1) 20,30,40
16081 20 call func(n,x,nf,f,uiparm,urparm,ufparm)
16082 ! write (iout,*) 'grad 20'
16083 if (nf.eq.0) return
16085 30 call var_to_geom(n,x)
16087 ! write (iout,*) 'grad 30'
16089 ! Evaluate the derivatives of virtual bond lengths and SC vectors in variables.
16092 ! write (iout,*) 'grad 40'
16093 ! print *,'GRADIENT: nnt=',nnt,' nct=',nct,' expon=',expon
16095 ! Convert the Cartesian gradient into internal-coordinate gradient.
16105 ! print *,'GRAD: i=',i,' jc=',j,' ind=',ind
16107 gthetai=gthetai+dcdv(k,ind)*gradc(k,j,icg)
16110 gphii=gphii+dcdv(k+3,ind)*gradc(k,j,icg)
16116 ! print *,'GRAD: i=',i,' jx=',j,' ind1=',ind1
16118 gthetai=gthetai+dxdv(k,ind1)*gradx(k,j,icg)
16119 gphii=gphii+dxdv(k+3,ind1)*gradx(k,j,icg)
16122 if (i.gt.1) g(i-1)=gphii
16123 if (n.gt.nphi) g(nphi+i)=gthetai
16125 if (n.le.nphi+ntheta) goto 10
16127 if (itype(i,1).ne.10) then
16131 galphai=galphai+dxds(k,i)*gradx(k,i,icg)
16134 gomegai=gomegai+dxds(k+3,i)*gradx(k,i,icg)
16136 g(ialph(i,1))=galphai
16137 g(ialph(i,1)+nside)=gomegai
16141 ! Add the components corresponding to local energy terms.
16145 !d write (iout,*) 'i=',i,'g=',g(i),' gloc=',gloc(i,icg)
16146 g(i)=g(i)+gloc(i,icg)
16148 ! Uncomment following three lines for diagnostics.
16150 !elwrite(iout,*) "in gradient after calling intout"
16151 !d call briefout(0,0.0d0)
16152 !d write (iout,'(i3,1pe15.5)') (k,g(k),k=1,n)
16154 end subroutine gradient
16155 !-----------------------------------------------------------------------------
16156 subroutine func(n,x,nf,f,uiparm,urparm,ufparm) !from minimize_p.F
16159 ! implicit real*8 (a-h,o-z)
16160 ! include 'DIMENSIONS'
16161 ! include 'COMMON.DERIV'
16162 ! include 'COMMON.IOUNITS'
16163 ! include 'COMMON.GEO'
16166 !el common /chuju/ jjj
16167 real(kind=8) :: energia(0:n_ene)
16168 integer :: uiparm(1)
16169 real(kind=8) :: urparm(1)
16171 real(kind=8),external :: ufparm
16172 real(kind=8),dimension(6*nres) :: x !(maxvar) (maxvar=6*maxres)
16173 ! if (jjj.gt.0) then
16174 ! write (iout,'(10f8.3)') (rad2deg*x(i),i=1,n)
16178 !d print *,'func',nf,nfl,icg
16179 call var_to_geom(n,x)
16182 !d write (iout,*) 'ETOTAL called from FUNC'
16183 call etotal(energia)
16186 ! if (jjj.gt.0) then
16187 ! write (iout,'(10f8.3)') (rad2deg*x(i),i=1,n)
16188 ! write (iout,*) 'f=',etot
16192 end subroutine func
16193 !-----------------------------------------------------------------------------
16194 subroutine cartgrad
16195 ! implicit real*8 (a-h,o-z)
16196 ! include 'DIMENSIONS'
16198 use MD_data, only: totT,usampl,eq_time
16202 ! include 'COMMON.CHAIN'
16203 ! include 'COMMON.DERIV'
16204 ! include 'COMMON.VAR'
16205 ! include 'COMMON.INTERACT'
16206 ! include 'COMMON.FFIELD'
16207 ! include 'COMMON.MD'
16208 ! include 'COMMON.IOUNITS'
16209 ! include 'COMMON.TIME1'
16213 ! This subrouting calculates total Cartesian coordinate gradient.
16214 ! The subroutine chainbuild_cart and energy MUST be called beforehand.
16224 !el write (iout,*) "After sum_gradient"
16226 !el write (iout,*) "After sum_gradient"
16228 write (iout,*) i," gradc ",(gradc(j,i,icg),j=1,3)
16229 write (iout,*) i," gradx ",(gradx(j,i,icg),j=1,3)
16232 ! If performing constraint dynamics, add the gradients of the constraint energy
16233 if(usampl.and.totT.gt.eq_time) then
16236 gradc(j,i,icg)=gradc(j,i,icg)+dudconst(j,i)+duscdiff(j,i)
16237 gradx(j,i,icg)=gradx(j,i,icg)+dudxconst(j,i)+duscdiffx(j,i)
16241 gloc(i,icg)=gloc(i,icg)+dugamma(i)
16244 gloc(nphi+i,icg)=gloc(nphi+i,icg)+dutheta(i)
16247 !elwrite (iout,*) "After sum_gradient"
16252 !elwrite (iout,*) "After sum_gradient"
16254 time_intcartderiv=time_intcartderiv+MPI_Wtime()-time01
16256 ! call checkintcartgrad
16257 ! write(iout,*) 'calling int_to_cart'
16259 write (iout,*) "gcart, gxcart, gloc before int_to_cart"
16263 gcart(j,i)=gradc(j,i,icg)
16264 gxcart(j,i)=gradx(j,i,icg)
16265 ! if (i.le.2) print *,"gcart_one",gcart(j,i),gradc(j,i,icg)
16268 write (iout,'(i5,2(3f10.5,5x),f10.5)') i,(gcart(j,i),j=1,3),&
16269 (gxcart(j,i),j=1,3),gloc(i,icg)
16275 ! print *,"gcart_two",gxcart(2,2),gradx(2,2,icg)
16277 ! print *,"gcart_two",gxcart(2,2),gradx(2,2,icg)
16280 time_inttocart=time_inttocart+MPI_Wtime()-time01
16283 write (iout,*) "gcart and gxcart after int_to_cart"
16285 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
16286 (gxcart(j,i),j=1,3)
16291 write (iout,*) "CARGRAD"
16295 gcart(j,i)=-gcart(j,i)+gcart(j,i-1)-gxcart(j,i)
16296 ! gcart_new(j,i)=-gcart(j,i)+gcart(j,i-1)-gxcart(j,i)
16298 ! write (iout,'(i5,3f10.5,5x,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3), &
16299 ! (gcart_new(j,i),j=1,3),(gxcart(j,i),j=1,3)
16301 ! Correction: dummy residues
16304 ! gcart_new(j,nnt)=gcart_new(j,nnt)+gcart_new(j,1)
16305 gcart(j,nnt)=gcart(j,nnt)+gcart(j,1)
16308 if (nct.lt.nres) then
16310 ! gcart_new(j,nct)=gcart_new(j,nct)+gcart_new(j,nres)
16311 gcart(j,nct)=gcart(j,nct)+gcart(j,nres)
16316 time_cartgrad=time_cartgrad+MPI_Wtime()-time00
16320 end subroutine cartgrad
16321 !-----------------------------------------------------------------------------
16322 subroutine zerograd
16323 ! implicit real*8 (a-h,o-z)
16324 ! include 'DIMENSIONS'
16325 ! include 'COMMON.DERIV'
16326 ! include 'COMMON.CHAIN'
16327 ! include 'COMMON.VAR'
16328 ! include 'COMMON.MD'
16329 ! include 'COMMON.SCCOR'
16331 !el local variables
16332 integer :: i,j,intertyp,k
16333 ! Initialize Cartesian-coordinate gradient
16335 ! if (.not.allocated(gradx)) allocate(gradx(3,nres,2)) !(3,maxres,2)
16336 ! if (.not.allocated(gradc)) allocate(gradc(3,nres,2)) !(3,maxres,2)
16338 ! allocate(gvdwx(3,nres),gvdwc(3,nres),gelc(3,nres),gelc_long(3,nres))
16339 ! allocate(gvdwpp(3,nres),gvdwc_scpp(3,nres),gradx_scp(3,nres))
16340 ! allocate(gvdwc_scp(3,nres),ghpbx(3,nres),ghpbc(3,nres))
16341 ! allocate(gradcorr_long(3,nres))
16342 ! allocate(gradcorr5_long(3,nres),gradcorr6_long(3,nres))
16343 ! allocate(gcorr6_turn_long(3,nres))
16344 ! allocate(gradcorr5(3,nres),gradcorr6(3,nres)) !(3,maxres)
16346 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres)) !(3,maxres)
16348 ! allocate(gel_loc(3,nres),gel_loc_long(3,nres),gcorr3_turn(3,nres))
16349 ! allocate(gcorr4_turn(3,nres),gcorr6_turn(3,nres))
16351 ! if (.not.allocated(gradb)) allocate(gradb(3,nres)) !(3,maxres)
16352 ! if (.not.allocated(gradbx)) allocate(gradbx(3,nres)) !(3,maxres)
16354 ! allocate(gsccorc(3,nres),gsccorx(3,nres)) !(3,maxres)
16355 ! allocate(gscloc(3,nres)) !(3,maxres)
16356 ! if (.not.allocated(gsclocx)) allocate(gsclocx(3,nres)) !(3,maxres)
16360 ! common /deriv_scloc/
16361 ! allocate(dXX_C1tab(3,nres),dYY_C1tab(3,nres),dZZ_C1tab(3,nres))
16362 ! allocate(dXX_Ctab(3,nres),dYY_Ctab(3,nres),dZZ_Ctab(3,nres))
16363 ! allocate(dXX_XYZtab(3,nres),dYY_XYZtab(3,nres),dZZ_XYZtab(3,nres)) !(3,maxres)
16365 ! allocate(jgrad_start(nres),jgrad_end(nres)) !(maxres)
16369 ! gradc(j,i,icg)=0.0d0
16370 ! gradx(j,i,icg)=0.0d0
16372 ! allocate(gloc_sc(3,nres,10)) !(3,0:maxres2,10)maxres2=2*maxres
16373 !elwrite(iout,*) "icg",icg
16377 gradx_scp(j,i)=0.0D0
16379 gvdwc_scp(j,i)=0.0D0
16380 gvdwc_scpp(j,i)=0.0d0
16382 gelc_long(j,i)=0.0D0
16387 gel_loc_long(j,i)=0.0d0
16390 gcorr3_turn(j,i)=0.0d0
16391 gcorr4_turn(j,i)=0.0d0
16392 gradcorr(j,i)=0.0d0
16393 gradcorr_long(j,i)=0.0d0
16394 gradcorr5_long(j,i)=0.0d0
16395 gradcorr6_long(j,i)=0.0d0
16396 gcorr6_turn_long(j,i)=0.0d0
16397 gradcorr5(j,i)=0.0d0
16398 gradcorr6(j,i)=0.0d0
16399 gcorr6_turn(j,i)=0.0d0
16402 gradc(j,i,icg)=0.0d0
16403 gradx(j,i,icg)=0.0d0
16406 gliptran(j,i)=0.0d0
16407 gliptranx(j,i)=0.0d0
16408 gliptranc(j,i)=0.0d0
16409 gshieldx(j,i)=0.0d0
16410 gshieldc(j,i)=0.0d0
16411 gshieldc_loc(j,i)=0.0d0
16412 gshieldx_ec(j,i)=0.0d0
16413 gshieldc_ec(j,i)=0.0d0
16414 gshieldc_loc_ec(j,i)=0.0d0
16415 gshieldx_t3(j,i)=0.0d0
16416 gshieldc_t3(j,i)=0.0d0
16417 gshieldc_loc_t3(j,i)=0.0d0
16418 gshieldx_t4(j,i)=0.0d0
16419 gshieldc_t4(j,i)=0.0d0
16420 gshieldc_loc_t4(j,i)=0.0d0
16421 gshieldx_ll(j,i)=0.0d0
16422 gshieldc_ll(j,i)=0.0d0
16423 gshieldc_loc_ll(j,i)=0.0d0
16425 gg_tube_sc(j,i)=0.0d0
16427 gradb_nucl(j,i)=0.0d0
16428 gradbx_nucl(j,i)=0.0d0
16429 gvdwpp_nucl(j,i)=0.0d0
16433 gvdwpsb1(j,i)=0.0d0
16437 gradcorr_nucl(j,i)=0.0d0
16438 gradcorr3_nucl(j,i)=0.0d0
16439 gradxorr_nucl(j,i)=0.0d0
16440 gradxorr3_nucl(j,i)=0.0d0
16444 gradpepcat(j,i)=0.0d0
16445 gradpepcatx(j,i)=0.0d0
16446 gradcatcat(j,i)=0.0d0
16447 gvdwx_scbase(j,i)=0.0d0
16448 gvdwc_scbase(j,i)=0.0d0
16449 gvdwx_pepbase(j,i)=0.0d0
16450 gvdwc_pepbase(j,i)=0.0d0
16451 gvdwx_scpho(j,i)=0.0d0
16452 gvdwc_scpho(j,i)=0.0d0
16453 gvdwc_peppho(j,i)=0.0d0
16459 gloc_sc(intertyp,i,icg)=0.0d0
16468 grad_shield_side(k,j,i)=0.0d0
16469 grad_shield_loc(k,j,i)=0.0d0
16476 ! Initialize the gradient of local energy terms.
16478 ! allocate(gloc(4*nres,2)) !!(maxvar,2)(maxvar=6*maxres)
16479 ! if (.not.allocated(gel_loc_loc)) allocate(gel_loc_loc(nres)) !(maxvar)(maxvar=6*maxres)
16480 ! if (.not.allocated(gcorr_loc)) allocate(gcorr_loc(nres)) !(maxvar)(maxvar=6*maxres)
16481 ! allocate(g_corr5_loc(nres),g_corr6_loc(nres)) !(maxvar)(maxvar=6*maxres)
16482 ! allocate(gel_loc_turn3(nres))
16483 ! allocate(gel_loc_turn4(nres),gel_loc_turn6(nres)) !(maxvar)(maxvar=6*maxres)
16484 ! allocate(gsccor_loc(nres)) !(maxres)
16490 gel_loc_loc(i)=0.0d0
16492 g_corr5_loc(i)=0.0d0
16493 g_corr6_loc(i)=0.0d0
16494 gel_loc_turn3(i)=0.0d0
16495 gel_loc_turn4(i)=0.0d0
16496 gel_loc_turn6(i)=0.0d0
16497 gsccor_loc(i)=0.0d0
16499 ! initialize gcart and gxcart
16500 ! allocate(gcart(3,0:nres),gxcart(3,0:nres)) !(3,0:MAXRES)
16508 end subroutine zerograd
16509 !-----------------------------------------------------------------------------
16510 real(kind=8) function fdum()
16514 !-----------------------------------------------------------------------------
16516 !-----------------------------------------------------------------------------
16517 subroutine intcartderiv
16518 ! implicit real*8 (a-h,o-z)
16519 ! include 'DIMENSIONS'
16523 ! include 'COMMON.SETUP'
16524 ! include 'COMMON.CHAIN'
16525 ! include 'COMMON.VAR'
16526 ! include 'COMMON.GEO'
16527 ! include 'COMMON.INTERACT'
16528 ! include 'COMMON.DERIV'
16529 ! include 'COMMON.IOUNITS'
16530 ! include 'COMMON.LOCAL'
16531 ! include 'COMMON.SCCOR'
16532 real(kind=8) :: pi4,pi34
16533 real(kind=8),dimension(3,2,nres) :: dcostheta ! (3,2,maxres)
16534 real(kind=8),dimension(3,3,nres) :: dcosphi,dsinphi,dcosalpha,&
16535 dcosomega,dsinomega !(3,3,maxres)
16536 real(kind=8),dimension(3) :: vo1,vo2,vo3,dummy,vp1,vp2,vp3,vpp1,n
16539 real(kind=8) :: cost,sint,cost1,sint1,cost2,sint2,sing,cosg,scalp,&
16540 fac0,fac1,fac2,fac3,fac4,fac5,fac6,ctgt,ctgt1,cosg_inv,&
16541 fac7,fac8,fac9,scala1,scala2,cosa,sina,sino,fac15,fac16,&
16542 fac17,coso_inv,fac10,fac11,fac12,fac13,fac14
16546 !el from module energy-------------
16547 !el allocate(dcostau(3,3,3,itau_start:itau_end)) !(3,3,3,maxres2)maxres2=2*maxres
16548 !el allocate(dsintau(3,3,3,itau_start:itau_end))
16549 !el allocate(dtauangle(3,3,3,itau_start:itau_end))
16551 !el allocate(dcostau(3,3,3,0:nres2)) !(3,3,3,maxres2)maxres2=2*maxres
16552 !el allocate(dsintau(3,3,3,0:nres2))
16553 !el allocate(dtauangle(3,3,3,0:nres2))
16554 !el allocate(domicron(3,2,2,0:nres2))
16555 !el allocate(dcosomicron(3,2,2,0:nres2))
16559 #if defined(MPI) && defined(PARINTDER)
16560 if (nfgtasks.gt.1 .and. me.eq.king) &
16561 call MPI_Bcast(8,1,MPI_INTEGER,king,FG_COMM,IERROR)
16566 ! allocate(dtheta(3,2,nres)) !(3,2,maxres)
16567 ! allocate(dphi(3,3,nres),dalpha(3,3,nres),domega(3,3,nres)) !(3,3,maxres)
16569 ! write (iout,*) "iphi1_start",iphi1_start," iphi1_end",iphi1_end
16572 dtheta(j,1,i)=0.0d0
16573 dtheta(j,2,i)=0.0d0
16579 ! Derivatives of theta's
16580 #if defined(MPI) && defined(PARINTDER)
16581 ! We need dtheta(:,:,i-1) to compute dphi(:,:,i)
16582 do i=max0(ithet_start-1,3),ithet_end
16586 cost=dcos(theta(i))
16587 sint=sqrt(1-cost*cost)
16589 dcostheta(j,1,i)=-(dc_norm(j,i-1)+cost*dc_norm(j,i-2))/&
16591 if (itype(i-1,1).ne.ntyp1) dtheta(j,1,i)=-dcostheta(j,1,i)/sint
16592 dcostheta(j,2,i)=-(dc_norm(j,i-2)+cost*dc_norm(j,i-1))/&
16594 if (itype(i-1,1).ne.ntyp1) dtheta(j,2,i)=-dcostheta(j,2,i)/sint
16597 #if defined(MPI) && defined(PARINTDER)
16598 ! We need dtheta(:,:,i-1) to compute dphi(:,:,i)
16599 do i=max0(ithet_start-1,3),ithet_end
16603 if ((itype(i-1,1).ne.10).and.(itype(i-1,1).ne.ntyp1)) then
16604 cost1=dcos(omicron(1,i))
16605 sint1=sqrt(1-cost1*cost1)
16606 cost2=dcos(omicron(2,i))
16607 sint2=sqrt(1-cost2*cost2)
16609 !C Calculate derivative over first omicron (Cai-2,Cai-1,SCi-1)
16610 dcosomicron(j,1,1,i)=-(dc_norm(j,i-1+nres)+ &
16611 cost1*dc_norm(j,i-2))/ &
16613 domicron(j,1,1,i)=-1/sint1*dcosomicron(j,1,1,i)
16614 dcosomicron(j,1,2,i)=-(dc_norm(j,i-2) &
16615 +cost1*(dc_norm(j,i-1+nres)))/ &
16617 domicron(j,1,2,i)=-1/sint1*dcosomicron(j,1,2,i)
16618 !C Calculate derivative over second omicron Sci-1,Cai-1 Cai
16619 !C Looks messy but better than if in loop
16620 dcosomicron(j,2,1,i)=-(-dc_norm(j,i-1+nres) &
16621 +cost2*dc_norm(j,i-1))/ &
16623 domicron(j,2,1,i)=-1/sint2*dcosomicron(j,2,1,i)
16624 dcosomicron(j,2,2,i)=-(dc_norm(j,i-1) &
16625 +cost2*(-dc_norm(j,i-1+nres)))/ &
16627 ! write(iout,*) "vbld", i,itype(i,1),vbld(i-1+nres)
16628 domicron(j,2,2,i)=-1/sint2*dcosomicron(j,2,2,i)
16632 !elwrite(iout,*) "after vbld write"
16633 ! Derivatives of phi:
16634 ! If phi is 0 or 180 degrees, then the formulas
16635 ! have to be derived by power series expansion of the
16636 ! conventional formulas around 0 and 180.
16638 do i=iphi1_start,iphi1_end
16642 ! if (itype(i-1,1).eq.21 .or. itype(i-2,1).eq.21 ) cycle
16643 ! the conventional case
16644 sint=dsin(theta(i))
16645 sint1=dsin(theta(i-1))
16647 cost=dcos(theta(i))
16648 cost1=dcos(theta(i-1))
16650 scalp=scalar(dc_norm(1,i-3),dc_norm(1,i-1))
16651 fac0=1.0d0/(sint1*sint)
16654 fac3=cosg*cost1/(sint1*sint1)
16655 fac4=cosg*cost/(sint*sint)
16656 ! Obtaining the gamma derivatives from sine derivative
16657 if (phi(i).gt.-pi4.and.phi(i).le.pi4.or. &
16658 phi(i).gt.pi34.and.phi(i).le.pi.or. &
16659 phi(i).ge.-pi.and.phi(i).le.-pi34) then
16660 call vecpr(dc_norm(1,i-1),dc_norm(1,i-2),vp1)
16661 call vecpr(dc_norm(1,i-3),dc_norm(1,i-1),vp2)
16662 call vecpr(dc_norm(1,i-3),dc_norm(1,i-2),vp3)
16666 cosg_inv=1.0d0/cosg
16667 if (itype(i-1,1).ne.ntyp1 .and. itype(i-2,1).ne.ntyp1) then
16668 dsinphi(j,1,i)=-sing*ctgt1*dtheta(j,1,i-1) &
16669 -(fac0*vp1(j)+sing*dc_norm(j,i-3))*vbld_inv(i-2)
16670 dphi(j,1,i)=cosg_inv*dsinphi(j,1,i)
16672 -sing*(ctgt1*dtheta(j,2,i-1)+ctgt*dtheta(j,1,i)) &
16673 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
16674 dphi(j,2,i)=cosg_inv*dsinphi(j,2,i)
16675 dsinphi(j,3,i)=-sing*ctgt*dtheta(j,2,i) &
16676 +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i)
16677 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
16678 dphi(j,3,i)=cosg_inv*dsinphi(j,3,i)
16680 ! Bug fixed 3/24/05 (AL)
16682 ! Obtaining the gamma derivatives from cosine derivative
16685 if (itype(i-1,1).ne.ntyp1 .and. itype(i-2,1).ne.ntyp1) then
16686 dcosphi(j,1,i)=fac1*dcostheta(j,1,i-1)+fac3* &
16687 dcostheta(j,1,i-1)-fac0*(dc_norm(j,i-1)-scalp* &
16688 dc_norm(j,i-3))/vbld(i-2)
16689 dphi(j,1,i)=-1/sing*dcosphi(j,1,i)
16690 dcosphi(j,2,i)=fac1*dcostheta(j,2,i-1)+fac2* &
16691 dcostheta(j,1,i)+fac3*dcostheta(j,2,i-1)+fac4* &
16693 dphi(j,2,i)=-1/sing*dcosphi(j,2,i)
16694 dcosphi(j,3,i)=fac2*dcostheta(j,2,i)+fac4* &
16695 dcostheta(j,2,i)-fac0*(dc_norm(j,i-3)-scalp* &
16696 dc_norm(j,i-1))/vbld(i)
16697 dphi(j,3,i)=-1/sing*dcosphi(j,3,i)
16702 !alculate derivative of Tauangle
16704 do i=itau_start,itau_end
16707 !elwrite(iout,*) " vecpr",i,nres
16709 if ((itype(i-2,1).eq.ntyp1).or.(itype(i-2,1).eq.10)) cycle
16710 ! if ((itype(i-2,1).eq.ntyp1).or.(itype(i-2,1).eq.10).or.
16711 ! & (itype(i-1,1).eq.ntyp1).or.(itype(i,1).eq.ntyp1)) cycle
16712 !c dtauangle(j,intertyp,dervityp,residue number)
16713 !c INTERTYP=1 SC...Ca...Ca..Ca
16714 ! the conventional case
16715 sint=dsin(theta(i))
16716 sint1=dsin(omicron(2,i-1))
16717 sing=dsin(tauangle(1,i))
16718 cost=dcos(theta(i))
16719 cost1=dcos(omicron(2,i-1))
16720 cosg=dcos(tauangle(1,i))
16721 !elwrite(iout,*) " vecpr5",i,nres
16723 !elwrite(iout,*) " vecpreee",i,nres,j,i-2+nres
16724 !elwrite(iout,*) " vecpr5",dc_norm2(1,1)
16725 dc_norm2(j,i-2+nres)=-dc_norm(j,i-2+nres)
16726 ! write(iout,*) dc_norm2(j,i-2+nres),"dcnorm"
16728 scalp=scalar(dc_norm2(1,i-2+nres),dc_norm(1,i-1))
16729 fac0=1.0d0/(sint1*sint)
16732 fac3=cosg*cost1/(sint1*sint1)
16733 fac4=cosg*cost/(sint*sint)
16734 ! write(iout,*) "faki",fac0,fac1,fac2,fac3,fac4
16735 ! Obtaining the gamma derivatives from sine derivative
16736 if (tauangle(1,i).gt.-pi4.and.tauangle(1,i).le.pi4.or. &
16737 tauangle(1,i).gt.pi34.and.tauangle(1,i).le.pi.or. &
16738 tauangle(1,i).gt.-pi.and.tauangle(1,i).le.-pi34) then
16739 call vecpr(dc_norm(1,i-1),dc_norm(1,i-2),vp1)
16740 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-1),vp2)
16741 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-2),vp3)
16745 cosg_inv=1.0d0/cosg
16746 dsintau(j,1,1,i)=-sing*ctgt1*domicron(j,2,2,i-1) &
16747 -(fac0*vp1(j)+sing*(dc_norm2(j,i-2+nres))) &
16748 *vbld_inv(i-2+nres)
16749 dtauangle(j,1,1,i)=cosg_inv*dsintau(j,1,1,i)
16750 dsintau(j,1,2,i)= &
16751 -sing*(ctgt1*domicron(j,2,1,i-1)+ctgt*dtheta(j,1,i)) &
16752 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
16753 ! write(iout,*) "dsintau", dsintau(j,1,2,i)
16754 dtauangle(j,1,2,i)=cosg_inv*dsintau(j,1,2,i)
16755 ! Bug fixed 3/24/05 (AL)
16756 dsintau(j,1,3,i)=-sing*ctgt*dtheta(j,2,i) &
16757 +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i)
16758 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
16759 dtauangle(j,1,3,i)=cosg_inv*dsintau(j,1,3,i)
16761 ! Obtaining the gamma derivatives from cosine derivative
16764 dcostau(j,1,1,i)=fac1*dcosomicron(j,2,2,i-1)+fac3* &
16765 dcosomicron(j,2,2,i-1)-fac0*(dc_norm(j,i-1)-scalp* &
16766 (dc_norm2(j,i-2+nres)))/vbld(i-2+nres)
16767 dtauangle(j,1,1,i)=-1/sing*dcostau(j,1,1,i)
16768 dcostau(j,1,2,i)=fac1*dcosomicron(j,2,1,i-1)+fac2* &
16769 dcostheta(j,1,i)+fac3*dcosomicron(j,2,1,i-1)+fac4* &
16771 dtauangle(j,1,2,i)=-1/sing*dcostau(j,1,2,i)
16772 dcostau(j,1,3,i)=fac2*dcostheta(j,2,i)+fac4* &
16773 dcostheta(j,2,i)-fac0*(-dc_norm(j,i-2+nres)-scalp* &
16774 dc_norm(j,i-1))/vbld(i)
16775 dtauangle(j,1,3,i)=-1/sing*dcostau(j,1,3,i)
16776 ! write (iout,*) "else",i
16780 ! write(iout,*) "tu",i,k,(dtauangle(j,1,k,i),j=1,3)
16783 !C Second case Ca...Ca...Ca...SC
16785 do i=itau_start,itau_end
16789 if ((itype(i-1,1).eq.ntyp1).or.(itype(i-1,1).eq.10).or. &
16790 (itype(i-2,1).eq.ntyp1).or.(itype(i-3,1).eq.ntyp1)) cycle
16791 ! the conventional case
16792 sint=dsin(omicron(1,i))
16793 sint1=dsin(theta(i-1))
16794 sing=dsin(tauangle(2,i))
16795 cost=dcos(omicron(1,i))
16796 cost1=dcos(theta(i-1))
16797 cosg=dcos(tauangle(2,i))
16799 ! dc_norm2(j,i-1+nres)=-dc_norm(j,i-1+nres)
16801 scalp=scalar(dc_norm(1,i-3),dc_norm(1,i-1+nres))
16802 fac0=1.0d0/(sint1*sint)
16805 fac3=cosg*cost1/(sint1*sint1)
16806 fac4=cosg*cost/(sint*sint)
16807 ! Obtaining the gamma derivatives from sine derivative
16808 if (tauangle(2,i).gt.-pi4.and.tauangle(2,i).le.pi4.or. &
16809 tauangle(2,i).gt.pi34.and.tauangle(2,i).le.pi.or. &
16810 tauangle(2,i).gt.-pi.and.tauangle(2,i).le.-pi34) then
16811 call vecpr(dc_norm2(1,i-1+nres),dc_norm(1,i-2),vp1)
16812 call vecpr(dc_norm(1,i-3),dc_norm(1,i-1+nres),vp2)
16813 call vecpr(dc_norm(1,i-3),dc_norm(1,i-2),vp3)
16817 cosg_inv=1.0d0/cosg
16818 dsintau(j,2,1,i)=-sing*ctgt1*dtheta(j,1,i-1) &
16819 +(fac0*vp1(j)-sing*dc_norm(j,i-3))*vbld_inv(i-2)
16820 ! write(iout,*) i,j,dsintau(j,2,1,i),sing*ctgt1*dtheta(j,1,i-1),
16821 ! &fac0*vp1(j),sing*dc_norm(j,i-3),vbld_inv(i-2),"dsintau(2,1)"
16822 dtauangle(j,2,1,i)=cosg_inv*dsintau(j,2,1,i)
16823 dsintau(j,2,2,i)= &
16824 -sing*(ctgt1*dtheta(j,2,i-1)+ctgt*domicron(j,1,1,i)) &
16825 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
16826 ! write(iout,*) "sprawdzenie",i,j,sing*ctgt1*dtheta(j,2,i-1),
16827 ! & sing*ctgt*domicron(j,1,2,i),
16828 ! & (fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
16829 dtauangle(j,2,2,i)=cosg_inv*dsintau(j,2,2,i)
16830 ! Bug fixed 3/24/05 (AL)
16831 dsintau(j,2,3,i)=-sing*ctgt*domicron(j,1,2,i) &
16832 +(fac0*vp3(j)-sing*dc_norm(j,i-1+nres))*vbld_inv(i-1+nres)
16833 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
16834 dtauangle(j,2,3,i)=cosg_inv*dsintau(j,2,3,i)
16836 ! Obtaining the gamma derivatives from cosine derivative
16839 dcostau(j,2,1,i)=fac1*dcostheta(j,1,i-1)+fac3* &
16840 dcostheta(j,1,i-1)-fac0*(dc_norm(j,i-1+nres)-scalp* &
16841 dc_norm(j,i-3))/vbld(i-2)
16842 dtauangle(j,2,1,i)=-1/sing*dcostau(j,2,1,i)
16843 dcostau(j,2,2,i)=fac1*dcostheta(j,2,i-1)+fac2* &
16844 dcosomicron(j,1,1,i)+fac3*dcostheta(j,2,i-1)+fac4* &
16845 dcosomicron(j,1,1,i)
16846 dtauangle(j,2,2,i)=-1/sing*dcostau(j,2,2,i)
16847 dcostau(j,2,3,i)=fac2*dcosomicron(j,1,2,i)+fac4* &
16848 dcosomicron(j,1,2,i)-fac0*(dc_norm(j,i-3)-scalp* &
16849 dc_norm(j,i-1+nres))/vbld(i-1+nres)
16850 dtauangle(j,2,3,i)=-1/sing*dcostau(j,2,3,i)
16851 ! write(iout,*) i,j,"else", dtauangle(j,2,3,i)
16856 !CC third case SC...Ca...Ca...SC
16859 do i=itau_start,itau_end
16863 ! the conventional case
16864 if ((itype(i-1,1).eq.ntyp1).or.(itype(i-1,1).eq.10).or. &
16865 (itype(i-2,1).eq.ntyp1).or.(itype(i-2,1).eq.10)) cycle
16866 sint=dsin(omicron(1,i))
16867 sint1=dsin(omicron(2,i-1))
16868 sing=dsin(tauangle(3,i))
16869 cost=dcos(omicron(1,i))
16870 cost1=dcos(omicron(2,i-1))
16871 cosg=dcos(tauangle(3,i))
16873 dc_norm2(j,i-2+nres)=-dc_norm(j,i-2+nres)
16874 ! dc_norm2(j,i-1+nres)=-dc_norm(j,i-1+nres)
16876 scalp=scalar(dc_norm2(1,i-2+nres),dc_norm(1,i-1+nres))
16877 fac0=1.0d0/(sint1*sint)
16880 fac3=cosg*cost1/(sint1*sint1)
16881 fac4=cosg*cost/(sint*sint)
16882 ! Obtaining the gamma derivatives from sine derivative
16883 if (tauangle(3,i).gt.-pi4.and.tauangle(3,i).le.pi4.or. &
16884 tauangle(3,i).gt.pi34.and.tauangle(3,i).le.pi.or. &
16885 tauangle(3,i).gt.-pi.and.tauangle(3,i).le.-pi34) then
16886 call vecpr(dc_norm(1,i-1+nres),dc_norm(1,i-2),vp1)
16887 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-1+nres),vp2)
16888 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-2),vp3)
16892 cosg_inv=1.0d0/cosg
16893 dsintau(j,3,1,i)=-sing*ctgt1*domicron(j,2,2,i-1) &
16894 -(fac0*vp1(j)-sing*dc_norm(j,i-2+nres)) &
16895 *vbld_inv(i-2+nres)
16896 dtauangle(j,3,1,i)=cosg_inv*dsintau(j,3,1,i)
16897 dsintau(j,3,2,i)= &
16898 -sing*(ctgt1*domicron(j,2,1,i-1)+ctgt*domicron(j,1,1,i)) &
16899 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
16900 dtauangle(j,3,2,i)=cosg_inv*dsintau(j,3,2,i)
16901 ! Bug fixed 3/24/05 (AL)
16902 dsintau(j,3,3,i)=-sing*ctgt*domicron(j,1,2,i) &
16903 +(fac0*vp3(j)-sing*dc_norm(j,i-1+nres)) &
16904 *vbld_inv(i-1+nres)
16905 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
16906 dtauangle(j,3,3,i)=cosg_inv*dsintau(j,3,3,i)
16908 ! Obtaining the gamma derivatives from cosine derivative
16911 dcostau(j,3,1,i)=fac1*dcosomicron(j,2,2,i-1)+fac3* &
16912 dcosomicron(j,2,2,i-1)-fac0*(dc_norm(j,i-1+nres)-scalp* &
16913 dc_norm2(j,i-2+nres))/vbld(i-2+nres)
16914 dtauangle(j,3,1,i)=-1/sing*dcostau(j,3,1,i)
16915 dcostau(j,3,2,i)=fac1*dcosomicron(j,2,1,i-1)+fac2* &
16916 dcosomicron(j,1,1,i)+fac3*dcosomicron(j,2,1,i-1)+fac4* &
16917 dcosomicron(j,1,1,i)
16918 dtauangle(j,3,2,i)=-1/sing*dcostau(j,3,2,i)
16919 dcostau(j,3,3,i)=fac2*dcosomicron(j,1,2,i)+fac4* &
16920 dcosomicron(j,1,2,i)-fac0*(dc_norm2(j,i-2+nres)-scalp* &
16921 dc_norm(j,i-1+nres))/vbld(i-1+nres)
16922 dtauangle(j,3,3,i)=-1/sing*dcostau(j,3,3,i)
16923 ! write(iout,*) "else",i
16929 ! Derivatives of side-chain angles alpha and omega
16930 #if defined(MPI) && defined(PARINTDER)
16931 do i=ibond_start,ibond_end
16935 if(itype(i,1).ne.10 .and. itype(i,1).ne.ntyp1) then
16936 fac5=1.0d0/dsqrt(2*(1+dcos(theta(i+1))))
16939 fac8=fac5/vbld(i+1)
16940 fac9=fac5/vbld(i+nres)
16941 scala1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
16942 scala2=scalar(dc_norm(1,i),dc_norm(1,i+nres))
16943 cosa=dsqrt(0.5d0/(1.0d0+dcos(theta(i+1))))* &
16944 (scalar(dC_norm(1,i),dC_norm(1,i+nres)) &
16945 -scalar(dC_norm(1,i-1),dC_norm(1,i+nres)))
16946 sina=sqrt(1-cosa*cosa)
16948 ! write (iout,*) "i",i," cosa",cosa," sina",sina," sino",sino
16950 dcosalpha(j,1,i)=fac6*(scala1*dc_norm(j,i-1)- &
16951 dc_norm(j,i+nres))-cosa*fac7*dcostheta(j,1,i+1)
16952 dalpha(j,1,i)=-1/sina*dcosalpha(j,1,i)
16953 dcosalpha(j,2,i)=fac8*(dc_norm(j,i+nres)- &
16954 scala2*dc_norm(j,i))-cosa*fac7*dcostheta(j,2,i+1)
16955 dalpha(j,2,i)=-1/sina*dcosalpha(j,2,i)
16956 dcosalpha(j,3,i)=(fac9*(dc_norm(j,i)- &
16957 dc_norm(j,i-1))-(cosa*dc_norm(j,i+nres))/ &
16959 dalpha(j,3,i)=-1/sina*dcosalpha(j,3,i)
16961 ! obtaining the derivatives of omega from sines
16962 if(omeg(i).gt.-pi4.and.omeg(i).le.pi4.or. &
16963 omeg(i).gt.pi34.and.omeg(i).le.pi.or. &
16964 omeg(i).gt.-pi.and.omeg(i).le.-pi34) then
16965 fac15=dcos(theta(i+1))/(dsin(theta(i+1))* &
16967 fac16=dcos(alph(i))/(dsin(alph(i))*dsin(alph(i)))
16968 fac17=1.0d0/(dsin(theta(i+1))*dsin(alph(i)))
16969 call vecpr(dc_norm(1,i+nres),dc_norm(1,i),vo1)
16970 call vecpr(dc_norm(1,i+nres),dc_norm(1,i-1),vo2)
16971 call vecpr(dc_norm(1,i),dc_norm(1,i-1),vo3)
16972 coso_inv=1.0d0/dcos(omeg(i))
16974 dsinomega(j,1,i)=sino*(fac15*dcostheta(j,1,i+1) &
16975 +fac16*dcosalpha(j,1,i))-fac17/vbld(i)*vo1(j)- &
16976 (sino*dc_norm(j,i-1))/vbld(i)
16977 domega(j,1,i)=coso_inv*dsinomega(j,1,i)
16978 dsinomega(j,2,i)=sino*(fac15*dcostheta(j,2,i+1) &
16979 +fac16*dcosalpha(j,2,i))+fac17/vbld(i+1)*vo2(j) &
16980 -sino*dc_norm(j,i)/vbld(i+1)
16981 domega(j,2,i)=coso_inv*dsinomega(j,2,i)
16982 dsinomega(j,3,i)=sino*fac16*dcosalpha(j,3,i)- &
16983 fac17/vbld(i+nres)*vo3(j)-sino*dc_norm(j,i+nres)/ &
16985 domega(j,3,i)=coso_inv*dsinomega(j,3,i)
16988 ! obtaining the derivatives of omega from cosines
16989 fac10=sqrt(0.5d0*(1-dcos(theta(i+1))))
16990 fac11=sqrt(0.5d0*(1+dcos(theta(i+1))))
16995 dcosomega(j,1,i)=(-(0.25d0*cosa/fac11* &
16996 dcostheta(j,1,i+1)+fac11*dcosalpha(j,1,i))*fac12+ &
16997 (0.25d0/fac10*sina*dcostheta(j,1,i+1)+cosa/sina* &
16998 fac10*dcosalpha(j,1,i))*(scala2-fac11*cosa))/fac13
16999 domega(j,1,i)=-1/sino*dcosomega(j,1,i)
17000 dcosomega(j,2,i)=(((dc_norm(j,i+nres)-scala2* &
17001 dc_norm(j,i))/vbld(i+1)-0.25d0*cosa/fac11* &
17002 dcostheta(j,2,i+1)-fac11*dcosalpha(j,2,i))*fac12+ &
17003 (scala2-fac11*cosa)*(0.25d0*sina/fac10* &
17004 dcostheta(j,2,i+1)+fac10*cosa/sina*dcosalpha(j,2,i)))/fac13
17005 domega(j,2,i)=-1/sino*dcosomega(j,2,i)
17006 dcosomega(j,3,i)=1/fac10*((1/vbld(i+nres)*(dc_norm(j,i)- &
17007 scala2*dc_norm(j,i+nres))-fac11*dcosalpha(j,3,i))*sina+ &
17008 (scala2-fac11*cosa)*(cosa/sina*dcosalpha(j,3,i)))/fac14
17009 domega(j,3,i)=-1/sino*dcosomega(j,3,i)
17015 dalpha(k,j,i)=0.0d0
17016 domega(k,j,i)=0.0d0
17022 #if defined(MPI) && defined(PARINTDER)
17023 if (nfgtasks.gt.1) then
17025 !d write (iout,*) "Gather dtheta"
17026 !d call flush(iout)
17027 write (iout,*) "dtheta before gather"
17029 write (iout,'(i3,3(3f8.5,3x))') i,((dtheta(j,k,i),k=1,3),j=1,2)
17032 call MPI_Gatherv(dtheta(1,1,ithet_start),ithet_count(fg_rank),&
17033 MPI_THET,dtheta(1,1,1),ithet_count(0),ithet_displ(0),MPI_THET,&
17034 king,FG_COMM,IERROR)
17036 !d write (iout,*) "Gather dphi"
17037 !d call flush(iout)
17038 write (iout,*) "dphi before gather"
17040 write (iout,'(i3,3(3f8.5,3x))') i,((dphi(j,k,i),k=1,3),j=1,3)
17043 call MPI_Gatherv(dphi(1,1,iphi1_start),iphi1_count(fg_rank),&
17044 MPI_GAM,dphi(1,1,1),iphi1_count(0),iphi1_displ(0),MPI_GAM,&
17045 king,FG_COMM,IERROR)
17046 !d write (iout,*) "Gather dalpha"
17047 !d call flush(iout)
17049 call MPI_Gatherv(dalpha(1,1,ibond_start),ibond_count(fg_rank),&
17050 MPI_GAM,dalpha(1,1,1),ibond_count(0),ibond_displ(0),MPI_GAM,&
17051 king,FG_COMM,IERROR)
17052 !d write (iout,*) "Gather domega"
17053 !d call flush(iout)
17054 call MPI_Gatherv(domega(1,1,ibond_start),ibond_count(fg_rank),&
17055 MPI_GAM,domega(1,1,1),ibond_count(0),ibond_displ(0),MPI_GAM,&
17056 king,FG_COMM,IERROR)
17061 write (iout,*) "dtheta after gather"
17063 write (iout,'(i3,3(3f8.5,3x))') i,((dtheta(j,k,i),j=1,3),k=1,2)
17065 write (iout,*) "dphi after gather"
17067 write (iout,'(i3,3(3f8.5,3x))') i,((dphi(j,k,i),j=1,3),k=1,3)
17069 write (iout,*) "dalpha after gather"
17071 write (iout,'(i3,3(3f8.5,3x))') i,((dalpha(j,k,i),j=1,3),k=1,3)
17073 write (iout,*) "domega after gather"
17075 write (iout,'(i3,3(3f8.5,3x))') i,((domega(j,k,i),j=1,3),k=1,3)
17079 end subroutine intcartderiv
17080 !-----------------------------------------------------------------------------
17081 subroutine checkintcartgrad
17082 ! implicit real*8 (a-h,o-z)
17083 ! include 'DIMENSIONS'
17087 ! include 'COMMON.CHAIN'
17088 ! include 'COMMON.VAR'
17089 ! include 'COMMON.GEO'
17090 ! include 'COMMON.INTERACT'
17091 ! include 'COMMON.DERIV'
17092 ! include 'COMMON.IOUNITS'
17093 ! include 'COMMON.SETUP'
17094 real(kind=8),dimension(3,2,nres) :: dthetanum !(3,2,maxres)
17095 real(kind=8),dimension(3,3,nres) :: dphinum,dalphanum,domeganum !(3,3,maxres)
17096 real(kind=8),dimension(nres) :: theta_s,phi_s,alph_s,omeg_s !(maxres)
17097 real(kind=8),dimension(3) :: dc_norm_s
17098 real(kind=8) :: aincr=1.0d-5
17100 real(kind=8) :: dcji
17103 theta_s(i)=theta(i)
17107 ! Check theta gradient
17109 "Analytical (upper) and numerical (lower) gradient of theta"
17114 dc(j,i-2)=dcji+aincr
17115 call chainbuild_cart
17116 call int_from_cart1(.false.)
17117 dthetanum(j,1,i)=(theta(i)-theta_s(i))/aincr
17120 dc(j,i-1)=dc(j,i-1)+aincr
17121 call chainbuild_cart
17122 dthetanum(j,2,i)=(theta(i)-theta_s(i))/aincr
17125 !el write (iout,'(i5,3f10.5,5x,3f10.5)') i,(dtheta(j,1,i),j=1,3),&
17126 !el (dtheta(j,2,i),j=1,3)
17127 !el write (iout,'(5x,3f10.5,5x,3f10.5)') (dthetanum(j,1,i),j=1,3),&
17128 !el (dthetanum(j,2,i),j=1,3)
17129 !el write (iout,'(5x,3f10.5,5x,3f10.5)') &
17130 !el (dthetanum(j,1,i)/dtheta(j,1,i),j=1,3),&
17131 !el (dthetanum(j,2,i)/dtheta(j,2,i),j=1,3)
17134 ! Check gamma gradient
17136 "Analytical (upper) and numerical (lower) gradient of gamma"
17140 dc(j,i-3)=dcji+aincr
17141 call chainbuild_cart
17142 dphinum(j,1,i)=(phi(i)-phi_s(i))/aincr
17145 dc(j,i-2)=dcji+aincr
17146 call chainbuild_cart
17147 dphinum(j,2,i)=(phi(i)-phi_s(i))/aincr
17150 dc(j,i-1)=dc(j,i-1)+aincr
17151 call chainbuild_cart
17152 dphinum(j,3,i)=(phi(i)-phi_s(i))/aincr
17155 !el write (iout,'(i5,3(3f10.5,5x))') i,(dphi(j,1,i),j=1,3),&
17156 !el (dphi(j,2,i),j=1,3),(dphi(j,3,i),j=1,3)
17157 !el write (iout,'(5x,3(3f10.5,5x))') (dphinum(j,1,i),j=1,3),&
17158 !el (dphinum(j,2,i),j=1,3),(dphinum(j,3,i),j=1,3)
17159 !el write (iout,'(5x,3(3f10.5,5x))') &
17160 !el (dphinum(j,1,i)/dphi(j,1,i),j=1,3),&
17161 !el (dphinum(j,2,i)/dphi(j,2,i),j=1,3),&
17162 !el (dphinum(j,3,i)/dphi(j,3,i),j=1,3)
17165 ! Check alpha gradient
17167 "Analytical (upper) and numerical (lower) gradient of alpha"
17169 if(itype(i,1).ne.10) then
17172 dc(j,i-1)=dcji+aincr
17173 call chainbuild_cart
17174 dalphanum(j,1,i)=(alph(i)-alph_s(i)) &
17179 call chainbuild_cart
17180 dalphanum(j,2,i)=(alph(i)-alph_s(i)) &
17184 dc(j,i+nres)=dc(j,i+nres)+aincr
17185 call chainbuild_cart
17186 dalphanum(j,3,i)=(alph(i)-alph_s(i)) &
17191 !el write (iout,'(i5,3(3f10.5,5x))') i,(dalpha(j,1,i),j=1,3),&
17192 !el (dalpha(j,2,i),j=1,3),(dalpha(j,3,i),j=1,3)
17193 !el write (iout,'(5x,3(3f10.5,5x))') (dalphanum(j,1,i),j=1,3),&
17194 !el (dalphanum(j,2,i),j=1,3),(dalphanum(j,3,i),j=1,3)
17195 !el write (iout,'(5x,3(3f10.5,5x))') &
17196 !el (dalphanum(j,1,i)/dalpha(j,1,i),j=1,3),&
17197 !el (dalphanum(j,2,i)/dalpha(j,2,i),j=1,3),&
17198 !el (dalphanum(j,3,i)/dalpha(j,3,i),j=1,3)
17201 ! Check omega gradient
17203 "Analytical (upper) and numerical (lower) gradient of omega"
17205 if(itype(i,1).ne.10) then
17208 dc(j,i-1)=dcji+aincr
17209 call chainbuild_cart
17210 domeganum(j,1,i)=(omeg(i)-omeg_s(i)) &
17215 call chainbuild_cart
17216 domeganum(j,2,i)=(omeg(i)-omeg_s(i)) &
17220 dc(j,i+nres)=dc(j,i+nres)+aincr
17221 call chainbuild_cart
17222 domeganum(j,3,i)=(omeg(i)-omeg_s(i)) &
17227 !el write (iout,'(i5,3(3f10.5,5x))') i,(domega(j,1,i),j=1,3),&
17228 !el (domega(j,2,i),j=1,3),(domega(j,3,i),j=1,3)
17229 !el write (iout,'(5x,3(3f10.5,5x))') (domeganum(j,1,i),j=1,3),&
17230 !el (domeganum(j,2,i),j=1,3),(domeganum(j,3,i),j=1,3)
17231 !el write (iout,'(5x,3(3f10.5,5x))') &
17232 !el (domeganum(j,1,i)/domega(j,1,i),j=1,3),&
17233 !el (domeganum(j,2,i)/domega(j,2,i),j=1,3),&
17234 !el (domeganum(j,3,i)/domega(j,3,i),j=1,3)
17238 end subroutine checkintcartgrad
17239 !-----------------------------------------------------------------------------
17241 !-----------------------------------------------------------------------------
17242 real(kind=8) function qwolynes(seg1,seg2,flag,seg3,seg4)
17243 ! implicit real*8 (a-h,o-z)
17244 ! include 'DIMENSIONS'
17245 ! include 'COMMON.IOUNITS'
17246 ! include 'COMMON.CHAIN'
17247 ! include 'COMMON.INTERACT'
17248 ! include 'COMMON.VAR'
17249 integer :: i,j,jl,k,l,il,kl,nl,np,ip,kp,seg1,seg2,seg3,seg4,secseg
17250 integer :: kkk,nsep=3
17251 real(kind=8) :: qm !dist,
17252 real(kind=8) :: qq,qqij,qqijCM,dij,d0ij,dijCM,d0ijCM,qqmax
17253 logical :: lprn=.false.
17255 ! real(kind=8) :: sigm,x
17257 !el sigm(x)=0.25d0*x ! local function
17263 do il=seg1+nsep,seg2
17266 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2 + &
17267 (cref(2,jl,kkk)-cref(2,il,kkk))**2 + &
17268 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
17270 qqij = dexp(-0.5d0*((dij-d0ij)/(sigm(d0ij)))**2)
17271 if (itype(il,1).ne.10 .or. itype(jl,1).ne.10) then
17274 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
17275 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
17276 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
17277 dijCM=dist(il+nres,jl+nres)
17278 qqijCM = dexp(-0.5d0*((dijCM-d0ijCM)/(sigm(d0ijCM)))**2)
17280 qq = qq+qqij+qqijCM
17286 if((seg3-il).lt.3) then
17293 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2+ &
17294 (cref(2,jl,kkk)-cref(2,il,kkk))**2+ &
17295 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
17297 qqij = dexp(-0.5d0*((dij-d0ij)/(sigm(d0ij)))**2)
17298 if (itype(il,1).ne.10 .or. itype(jl,1).ne.10) then
17301 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
17302 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
17303 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
17304 dijCM=dist(il+nres,jl+nres)
17305 qqijCM = dexp(-0.5d0*((dijCM-d0ijCM)/(sigm(d0ijCM)))**2)
17307 qq = qq+qqij+qqijCM
17312 if (qqmax.le.qq) qqmax=qq
17314 qwolynes=1.0d0-qqmax
17316 end function qwolynes
17317 !-----------------------------------------------------------------------------
17318 subroutine qwolynes_prim(seg1,seg2,flag,seg3,seg4)
17319 ! implicit real*8 (a-h,o-z)
17320 ! include 'DIMENSIONS'
17321 ! include 'COMMON.IOUNITS'
17322 ! include 'COMMON.CHAIN'
17323 ! include 'COMMON.INTERACT'
17324 ! include 'COMMON.VAR'
17325 ! include 'COMMON.MD'
17326 integer :: i,j,jl,k,l,il,nl,seg1,seg2,seg3,seg4,secseg
17327 integer :: nsep=3, kkk
17328 !el real(kind=8) :: dist
17329 real(kind=8) :: dij,d0ij,dijCM,d0ijCM
17330 logical :: lprn=.false.
17332 real(kind=8) :: sim,dd0,fac,ddqij
17333 !el sigm(x)=0.25d0*x ! local function
17343 do il=seg1+nsep,seg2
17346 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2+ &
17347 (cref(2,jl,kkk)-cref(2,il,kkk))**2+ &
17348 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
17350 sim = 1.0d0/sigm(d0ij)
17353 fac = dd0*sim/dij*dexp(-0.5d0*dd0*dd0*sim)
17355 ddqij = (c(k,il)-c(k,jl))*fac
17356 dqwol(k,il)=dqwol(k,il)+ddqij
17357 dqwol(k,jl)=dqwol(k,jl)-ddqij
17360 if (itype(il,1).ne.10 .or. itype(jl,1).ne.10) then
17363 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
17364 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
17365 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
17366 dijCM=dist(il+nres,jl+nres)
17367 sim = 1.0d0/sigm(d0ijCM)
17370 fac=dd0*sim/dijCM*dexp(-0.5d0*dd0*dd0*sim)
17372 ddqij = (c(k,il+nres)-c(k,jl+nres))*fac
17373 dxqwol(k,il)=dxqwol(k,il)+ddqij
17374 dxqwol(k,jl)=dxqwol(k,jl)-ddqij
17381 if((seg3-il).lt.3) then
17388 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2+ &
17389 (cref(2,jl,kkk)-cref(2,il,kkk))**2+ &
17390 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
17392 sim = 1.0d0/sigm(d0ij)
17395 fac = dd0*sim/dij*dexp(-0.5d0*dd0*dd0*sim)
17397 ddqij = (c(k,il)-c(k,jl))*fac
17398 dqwol(k,il)=dqwol(k,il)+ddqij
17399 dqwol(k,jl)=dqwol(k,jl)-ddqij
17401 if (itype(il,1).ne.10 .or. itype(jl,1).ne.10) then
17404 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
17405 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
17406 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
17407 dijCM=dist(il+nres,jl+nres)
17408 sim = 1.0d0/sigm(d0ijCM)
17411 fac = dd0*sim/dijCM*dexp(-0.5d0*dd0*dd0*sim)
17413 ddqij = (c(k,il+nres)-c(k,jl+nres))*fac
17414 dxqwol(k,il)=dxqwol(k,il)+ddqij
17415 dxqwol(k,jl)=dxqwol(k,jl)-ddqij
17424 dqwol(j,i)=dqwol(j,i)/nl
17425 dxqwol(j,i)=dxqwol(j,i)/nl
17429 end subroutine qwolynes_prim
17430 !-----------------------------------------------------------------------------
17431 subroutine qwol_num(seg1,seg2,flag,seg3,seg4)
17432 ! implicit real*8 (a-h,o-z)
17433 ! include 'DIMENSIONS'
17434 ! include 'COMMON.IOUNITS'
17435 ! include 'COMMON.CHAIN'
17436 ! include 'COMMON.INTERACT'
17437 ! include 'COMMON.VAR'
17438 integer :: seg1,seg2,seg3,seg4
17440 real(kind=8),dimension(3,0:nres) :: qwolan,qwolxan
17441 real(kind=8),dimension(3,0:2*nres) :: cdummy
17442 real(kind=8) :: q1,q2
17443 real(kind=8) :: delta=1.0d-10
17448 q1=qwolynes(seg1,seg2,flag,seg3,seg4)
17450 c(j,i)=c(j,i)+delta
17451 q2=qwolynes(seg1,seg2,flag,seg3,seg4)
17452 qwolan(j,i)=(q2-q1)/delta
17458 q1=qwolynes(seg1,seg2,flag,seg3,seg4)
17459 cdummy(j,i+nres)=c(j,i+nres)
17460 c(j,i+nres)=c(j,i+nres)+delta
17461 q2=qwolynes(seg1,seg2,flag,seg3,seg4)
17462 qwolxan(j,i)=(q2-q1)/delta
17463 c(j,i+nres)=cdummy(j,i+nres)
17466 ! write(iout,*) "Numerical Q carteisan gradients backbone: "
17468 ! write(iout,'(i5,3e15.5)') i, (qwolan(j,i),j=1,3)
17470 ! write(iout,*) "Numerical Q carteisan gradients side-chain: "
17472 ! write(iout,'(i5,3e15.5)') i, (qwolxan(j,i),j=1,3)
17475 end subroutine qwol_num
17476 !-----------------------------------------------------------------------------
17477 subroutine EconstrQ
17478 ! MD with umbrella_sampling using Wolyne's distance measure as a constraint
17479 ! implicit real*8 (a-h,o-z)
17480 ! include 'DIMENSIONS'
17481 ! include 'COMMON.CONTROL'
17482 ! include 'COMMON.VAR'
17483 ! include 'COMMON.MD'
17486 ! include 'COMMON.LANGEVIN'
17488 ! include 'COMMON.LANGEVIN.lang0'
17490 ! include 'COMMON.CHAIN'
17491 ! include 'COMMON.DERIV'
17492 ! include 'COMMON.GEO'
17493 ! include 'COMMON.LOCAL'
17494 ! include 'COMMON.INTERACT'
17495 ! include 'COMMON.IOUNITS'
17496 ! include 'COMMON.NAMES'
17497 ! include 'COMMON.TIME1'
17498 real(kind=8) :: uzap1,uzap2,hm1,hm2,hmnum,ucdelan
17499 real(kind=8),dimension(3,0:nres) :: dUcartan,dUxcartan,cdummy,&
17501 integer :: kstart,kend,lstart,lend,idummy
17502 real(kind=8) :: delta=1.0d-7
17503 integer :: i,j,k,ii
17507 dudconst(j,i)=0.0d0
17508 duxconst(j,i)=0.0d0
17509 dudxconst(j,i)=0.0d0
17514 qfrag(i)=qwolynes(ifrag(1,i,iset),ifrag(2,i,iset),.true.,&
17516 Uconst=Uconst+wfrag(i,iset)*harmonic(qfrag(i),qinfrag(i,iset))
17517 ! Calculating the derivatives of Constraint energy with respect to Q
17518 Ucdfrag=wfrag(i,iset)*harmonicprim(qfrag(i),&
17520 ! hm1=harmonic(qfrag(i,iset),qinfrag(i,iset))
17521 ! hm2=harmonic(qfrag(i,iset)+delta,qinfrag(i,iset))
17522 ! hmnum=(hm2-hm1)/delta
17523 ! write(iout,*) "harmonicprim frag",harmonicprim(qfrag(i,iset),
17524 ! & qinfrag(i,iset))
17525 ! write(iout,*) "harmonicnum frag", hmnum
17526 ! Calculating the derivatives of Q with respect to cartesian coordinates
17527 call qwolynes_prim(ifrag(1,i,iset),ifrag(2,i,iset),.true.,&
17529 ! write(iout,*) "dqwol "
17531 ! write(iout,'(i5,3e15.5)') ii,(dqwol(j,ii),j=1,3)
17533 ! write(iout,*) "dxqwol "
17535 ! write(iout,'(i5,3e15.5)') ii,(dxqwol(j,ii),j=1,3)
17537 ! Calculating numerical gradients of dU/dQi and dQi/dxi
17538 ! call qwol_num(ifrag(1,i,iset),ifrag(2,i,iset),.true.
17539 ! & ,idummy,idummy)
17540 ! The gradients of Uconst in Cs
17543 duconst(j,ii)=dUconst(j,ii)+ucdfrag*dqwol(j,ii)
17544 dUxconst(j,ii)=dUxconst(j,ii)+ucdfrag*dxqwol(j,ii)
17549 kstart=ifrag(1,ipair(1,i,iset),iset)
17550 kend=ifrag(2,ipair(1,i,iset),iset)
17551 lstart=ifrag(1,ipair(2,i,iset),iset)
17552 lend=ifrag(2,ipair(2,i,iset),iset)
17553 qpair(i)=qwolynes(kstart,kend,.false.,lstart,lend)
17554 Uconst=Uconst+wpair(i,iset)*harmonic(qpair(i),qinpair(i,iset))
17555 ! Calculating dU/dQ
17556 Ucdpair=wpair(i,iset)*harmonicprim(qpair(i),qinpair(i,iset))
17557 ! hm1=harmonic(qpair(i),qinpair(i,iset))
17558 ! hm2=harmonic(qpair(i)+delta,qinpair(i,iset))
17559 ! hmnum=(hm2-hm1)/delta
17560 ! write(iout,*) "harmonicprim pair ",harmonicprim(qpair(i),
17561 ! & qinpair(i,iset))
17562 ! write(iout,*) "harmonicnum pair ", hmnum
17563 ! Calculating dQ/dXi
17564 call qwolynes_prim(kstart,kend,.false.,&
17566 ! write(iout,*) "dqwol "
17568 ! write(iout,'(i5,3e15.5)') ii,(dqwol(j,ii),j=1,3)
17570 ! write(iout,*) "dxqwol "
17572 ! write(iout,'(i5,3e15.5)') ii,(dxqwol(j,ii),j=1,3)
17574 ! Calculating numerical gradients
17575 ! call qwol_num(kstart,kend,.false.
17577 ! The gradients of Uconst in Cs
17580 duconst(j,ii)=dUconst(j,ii)+ucdpair*dqwol(j,ii)
17581 dUxconst(j,ii)=dUxconst(j,ii)+ucdpair*dxqwol(j,ii)
17585 ! write(iout,*) "Uconst inside subroutine ", Uconst
17586 ! Transforming the gradients from Cs to dCs for the backbone
17590 dudconst(k,i)=dudconst(k,i)+duconst(k,j)+duxconst(k,j)
17594 ! Transforming the gradients from Cs to dCs for the side chains
17597 dudxconst(j,i)=duxconst(j,i)
17600 ! write(iout,*) "dU/ddc backbone "
17602 ! write(iout,'(i5,3e15.5)') ii, (dudconst(j,ii),j=1,3)
17604 ! write(iout,*) "dU/ddX side chain "
17606 ! write(iout,'(i5,3e15.5)') ii,(duxconst(j,ii),j=1,3)
17608 ! Calculating numerical gradients of dUconst/ddc and dUconst/ddx
17609 ! call dEconstrQ_num
17611 end subroutine EconstrQ
17612 !-----------------------------------------------------------------------------
17613 subroutine dEconstrQ_num
17614 ! Calculating numerical dUconst/ddc and dUconst/ddx
17615 ! implicit real*8 (a-h,o-z)
17616 ! include 'DIMENSIONS'
17617 ! include 'COMMON.CONTROL'
17618 ! include 'COMMON.VAR'
17619 ! include 'COMMON.MD'
17622 ! include 'COMMON.LANGEVIN'
17624 ! include 'COMMON.LANGEVIN.lang0'
17626 ! include 'COMMON.CHAIN'
17627 ! include 'COMMON.DERIV'
17628 ! include 'COMMON.GEO'
17629 ! include 'COMMON.LOCAL'
17630 ! include 'COMMON.INTERACT'
17631 ! include 'COMMON.IOUNITS'
17632 ! include 'COMMON.NAMES'
17633 ! include 'COMMON.TIME1'
17634 real(kind=8) :: uzap1,uzap2
17635 real(kind=8),dimension(3,0:nres) :: dUcartan,dUxcartan,cdummy
17636 integer :: kstart,kend,lstart,lend,idummy
17637 real(kind=8) :: delta=1.0d-7
17638 !el local variables
17644 dUcartan(j,i)=0.0d0
17645 cdummy(j,i)=dc(j,i)
17646 dc(j,i)=dc(j,i)+delta
17647 call chainbuild_cart
17650 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),.true.,&
17652 uzap2=uzap2+wfrag(ii,iset)*harmonic(qfrag(ii),&
17656 kstart=ifrag(1,ipair(1,ii,iset),iset)
17657 kend=ifrag(2,ipair(1,ii,iset),iset)
17658 lstart=ifrag(1,ipair(2,ii,iset),iset)
17659 lend=ifrag(2,ipair(2,ii,iset),iset)
17660 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
17661 uzap2=uzap2+wpair(ii,iset)*harmonic(qpair(ii),&
17664 dc(j,i)=cdummy(j,i)
17665 call chainbuild_cart
17668 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),.true.,&
17670 uzap1=uzap1+wfrag(ii,iset)*harmonic(qfrag(ii),&
17674 kstart=ifrag(1,ipair(1,ii,iset),iset)
17675 kend=ifrag(2,ipair(1,ii,iset),iset)
17676 lstart=ifrag(1,ipair(2,ii,iset),iset)
17677 lend=ifrag(2,ipair(2,ii,iset),iset)
17678 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
17679 uzap1=uzap1+wpair(ii,iset)*harmonic(qpair(ii),&
17682 ducartan(j,i)=(uzap2-uzap1)/(delta)
17685 ! Calculating numerical gradients for dU/ddx
17687 duxcartan(j,i)=0.0d0
17689 cdummy(j,i)=dc(j,i+nres)
17690 dc(j,i+nres)=dc(j,i+nres)+delta
17691 call chainbuild_cart
17694 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),.true.,&
17696 uzap2=uzap2+wfrag(ii,iset)*harmonic(qfrag(ii),&
17700 kstart=ifrag(1,ipair(1,ii,iset),iset)
17701 kend=ifrag(2,ipair(1,ii,iset),iset)
17702 lstart=ifrag(1,ipair(2,ii,iset),iset)
17703 lend=ifrag(2,ipair(2,ii,iset),iset)
17704 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
17705 uzap2=uzap2+wpair(ii,iset)*harmonic(qpair(ii),&
17708 dc(j,i+nres)=cdummy(j,i)
17709 call chainbuild_cart
17712 qfrag(ii)=qwolynes(ifrag(1,ii,iset),&
17713 ifrag(2,ii,iset),.true.,idummy,idummy)
17714 uzap1=uzap1+wfrag(ii,iset)*harmonic(qfrag(ii),&
17718 kstart=ifrag(1,ipair(1,ii,iset),iset)
17719 kend=ifrag(2,ipair(1,ii,iset),iset)
17720 lstart=ifrag(1,ipair(2,ii,iset),iset)
17721 lend=ifrag(2,ipair(2,ii,iset),iset)
17722 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
17723 uzap1=uzap1+wpair(ii,iset)*harmonic(qpair(ii),&
17726 duxcartan(j,i)=(uzap2-uzap1)/(delta)
17729 write(iout,*) "Numerical dUconst/ddc backbone "
17731 write(iout,'(i5,3e15.5)') ii,(dUcartan(j,ii),j=1,3)
17733 ! write(iout,*) "Numerical dUconst/ddx side-chain "
17735 ! write(iout,'(i5,3e15.5)') ii,(dUxcartan(j,ii),j=1,3)
17738 end subroutine dEconstrQ_num
17739 !-----------------------------------------------------------------------------
17741 !-----------------------------------------------------------------------------
17742 subroutine check_energies
17744 ! use random, only: ran_number
17748 ! include 'DIMENSIONS'
17749 ! include 'COMMON.CHAIN'
17750 ! include 'COMMON.VAR'
17751 ! include 'COMMON.IOUNITS'
17752 ! include 'COMMON.SBRIDGE'
17753 ! include 'COMMON.LOCAL'
17754 ! include 'COMMON.GEO'
17756 ! External functions
17757 !EL double precision ran_number
17758 !EL external ran_number
17761 integer :: i,j,k,l,lmax,p,pmax
17762 real(kind=8) :: rmin,rmax
17763 real(kind=8) :: eij
17766 real(kind=8) :: wi,rij,tj,pj
17788 !t wi=ran_number(0.0D0,pi)
17789 ! wi=ran_number(0.0D0,pi/6.0D0)
17791 !t tj=ran_number(0.0D0,pi)
17792 !t pj=ran_number(0.0D0,pi)
17793 ! pj=ran_number(0.0D0,pi/6.0D0)
17797 !t rij=ran_number(rmin,rmax)
17799 c(1,j)=d*sin(pj)*cos(tj)
17800 c(2,j)=d*sin(pj)*sin(tj)
17806 c(3,i)=-rij-d*cos(wi)
17809 dc(k,nres+i)=c(k,nres+i)-c(k,i)
17810 dc_norm(k,nres+i)=dc(k,nres+i)/d
17811 dc(k,nres+j)=c(k,nres+j)-c(k,j)
17812 dc_norm(k,nres+j)=dc(k,nres+j)/d
17815 call dyn_ssbond_ene(i,j,eij)
17820 end subroutine check_energies
17821 !-----------------------------------------------------------------------------
17822 subroutine dyn_ssbond_ene(resi,resj,eij)
17827 ! include 'DIMENSIONS'
17828 ! include 'COMMON.SBRIDGE'
17829 ! include 'COMMON.CHAIN'
17830 ! include 'COMMON.DERIV'
17831 ! include 'COMMON.LOCAL'
17832 ! include 'COMMON.INTERACT'
17833 ! include 'COMMON.VAR'
17834 ! include 'COMMON.IOUNITS'
17835 ! include 'COMMON.CALC'
17839 ! include 'COMMON.MD'
17840 ! use MD, only: totT,t_bath
17843 ! External functions
17844 !EL double precision h_base
17845 !EL external h_base
17848 integer :: resi,resj
17851 real(kind=8) :: eij
17854 logical :: havebond
17855 integer itypi,itypj
17856 real(kind=8) :: rrij,ssd,deltat1,deltat2,deltat12,cosphi
17857 real(kind=8) :: sig0ij,ljd,sig,fac,e1,e2
17858 real(kind=8),dimension(3) :: dcosom1,dcosom2
17860 real(kind=8) :: pom1,pom2
17861 real(kind=8) :: ljA,ljB,ljXs
17862 real(kind=8),dimension(1:3) :: d_ljB
17863 real(kind=8) :: ssA,ssB,ssC,ssXs
17864 real(kind=8) :: ssxm,ljxm,ssm,ljm
17865 real(kind=8),dimension(1:3) :: d_ssxm,d_ljxm,d_ssm,d_ljm
17866 real(kind=8) :: f1,f2,h1,h2,hd1,hd2
17867 real(kind=8) :: omega,delta_inv,deltasq_inv,fac1,fac2
17868 !-------FIRST METHOD
17870 real(kind=8),dimension(1:3) :: d_xm
17871 !-------END FIRST METHOD
17872 !-------SECOND METHOD
17873 !$$$ double precision ss,d_ss(0:3),ljf,d_ljf(0:3)
17874 !-------END SECOND METHOD
17876 !-------TESTING CODE
17877 !el logical :: checkstop,transgrad
17878 !el common /sschecks/ checkstop,transgrad
17880 integer :: icheck,nicheck,jcheck,njcheck
17881 real(kind=8),dimension(-1:1) :: echeck
17882 real(kind=8) :: deps,ssx0,ljx0
17883 !-------END TESTING CODE
17889 !el allocate(dyn_ssbond_ij(iatsc_s:iatsc_e,nres))
17890 !el allocate(dyn_ssbond_ij(0:nres+4,nres))
17893 dxi=dc_norm(1,nres+i)
17894 dyi=dc_norm(2,nres+i)
17895 dzi=dc_norm(3,nres+i)
17896 dsci_inv=vbld_inv(i+nres)
17899 xj=c(1,nres+j)-c(1,nres+i)
17900 yj=c(2,nres+j)-c(2,nres+i)
17901 zj=c(3,nres+j)-c(3,nres+i)
17902 dxj=dc_norm(1,nres+j)
17903 dyj=dc_norm(2,nres+j)
17904 dzj=dc_norm(3,nres+j)
17905 dscj_inv=vbld_inv(j+nres)
17907 chi1=chi(itypi,itypj)
17908 chi2=chi(itypj,itypi)
17915 alf12=0.5D0*(alf1+alf2)
17917 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
17918 rij=dsqrt(rrij) ! sc_angular needs rij to really be the inverse
17919 ! The following are set in sc_angular
17923 ! om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
17924 ! om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
17925 ! om12=dxi*dxj+dyi*dyj+dzi*dzj
17927 rij=1.0D0/rij ! Reset this so it makes sense
17929 sig0ij=sigma(itypi,itypj)
17930 sig=sig0ij*dsqrt(1.0D0/sigsq)
17933 ljA=eps1*eps2rt**2*eps3rt**2
17934 ljB=ljA*bb_aq(itypi,itypj)
17935 ljA=ljA*aa_aq(itypi,itypj)
17936 ljxm=ljXs+(-2.0D0*aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
17941 deltat12=om2-om1+2.0d0
17942 cosphi=om12-om1*om2
17946 +akth*(deltat1*deltat1+deltat2*deltat2) &
17947 +v1ss*cosphi+v2ss*cosphi*cosphi+v3ss*cosphi*cosphi*cosphi
17948 ssxm=ssXs-0.5D0*ssB/ssA
17950 !-------TESTING CODE
17951 !$$$c Some extra output
17952 !$$$ ssm=ssC-0.25D0*ssB*ssB/ssA
17953 !$$$ ljm=-0.25D0*ljB*bb(itypi,itypj)/aa(itypi,itypj)
17954 !$$$ ssx0=ssB*ssB-4.0d0*ssA*ssC
17955 !$$$ if (ssx0.gt.0.0d0) then
17956 !$$$ ssx0=ssXs+0.5d0*(-ssB+sqrt(ssx0))/ssA
17960 !$$$ ljx0=ljXs+(-aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
17961 !$$$ write(iout,'(a,4f8.2,2f15.2,3f6.2)')"SSENERGIES ",
17962 !$$$ & ssxm,ljxm,ssx0,ljx0,ssm,ljm,om1,om2,om12
17964 !-------END TESTING CODE
17966 !-------TESTING CODE
17967 ! Stop and plot energy and derivative as a function of distance
17968 if (checkstop) then
17969 ssm=ssC-0.25D0*ssB*ssB/ssA
17970 ljm=-0.25D0*ljB*bb_aq(itypi,itypj)/aa_aq(itypi,itypj)
17971 if (ssm.lt.ljm .and. &
17972 dabs(rij-0.5d0*(ssxm+ljxm)).lt.0.35d0*(ljxm-ssxm)) then
17980 if (.not.checkstop) then
17985 do icheck=0,nicheck
17986 do jcheck=-1,njcheck
17987 if (checkstop) rij=(ssxm-1.0d0)+ &
17988 ((ljxm-ssxm+2.0d0)*icheck)/nicheck+jcheck*deps
17989 !-------END TESTING CODE
17991 if (rij.gt.ljxm) then
17994 fac=(1.0D0/ljd)**expon
17995 e1=fac*fac*aa_aq(itypi,itypj)
17996 e2=fac*bb_aq(itypi,itypj)
17997 eij=eps1*eps2rt*eps3rt*(e1+e2)
18000 eij=eij*eps2rt*eps3rt
18003 e1=e1*eps1*eps2rt**2*eps3rt**2
18004 ed=-expon*(e1+eij)/ljd
18006 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
18007 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
18008 eom12=eij*eps1_om12+eps2der*eps2rt_om12 &
18009 -2.0D0*alf12*eps3der+sigder*sigsq_om12
18010 else if (rij.lt.ssxm) then
18013 eij=ssA*ssd*ssd+ssB*ssd+ssC
18015 ed=2*akcm*ssd+akct*deltat12
18017 pom2=v1ss+2*v2ss*cosphi+3*v3ss*cosphi*cosphi
18018 eom1=-2*akth*deltat1-pom1-om2*pom2
18019 eom2= 2*akth*deltat2+pom1-om1*pom2
18022 omega=v1ss+2.0d0*v2ss*cosphi+3.0d0*v3ss*cosphi*cosphi
18024 d_ssxm(1)=0.5D0*akct/ssA
18025 d_ssxm(2)=-d_ssxm(1)
18028 d_ljxm(1)=sig0ij/sqrt(sigsq**3)
18029 d_ljxm(2)=d_ljxm(1)*sigsq_om2
18030 d_ljxm(3)=d_ljxm(1)*sigsq_om12
18031 d_ljxm(1)=d_ljxm(1)*sigsq_om1
18033 !-------FIRST METHOD, DISCONTINUOUS SECOND DERIVATIVE
18034 xm=0.5d0*(ssxm+ljxm)
18036 d_xm(k)=0.5d0*(d_ssxm(k)+d_ljxm(k))
18038 if (rij.lt.xm) then
18040 ssm=ssC-0.25D0*ssB*ssB/ssA
18041 d_ssm(1)=0.5D0*akct*ssB/ssA
18042 d_ssm(2)=2.0D0*akth*deltat2-om1*omega-d_ssm(1)
18043 d_ssm(1)=-2.0D0*akth*deltat1-om2*omega+d_ssm(1)
18045 f1=(rij-xm)/(ssxm-xm)
18046 f2=(rij-ssxm)/(xm-ssxm)
18050 delta_inv=1.0d0/(xm-ssxm)
18051 deltasq_inv=delta_inv*delta_inv
18053 fac1=deltasq_inv*fac*(xm-rij)
18054 fac2=deltasq_inv*fac*(rij-ssxm)
18055 ed=delta_inv*(Ht*hd2-ssm*hd1)
18056 eom1=fac1*d_ssxm(1)+fac2*d_xm(1)+h1*d_ssm(1)
18057 eom2=fac1*d_ssxm(2)+fac2*d_xm(2)+h1*d_ssm(2)
18058 eom12=fac1*d_ssxm(3)+fac2*d_xm(3)+h1*d_ssm(3)
18061 ljm=-0.25D0*ljB*bb_aq(itypi,itypj)/aa_aq(itypi,itypj)
18062 d_ljm(1)=-0.5D0*bb_aq(itypi,itypj)/aa_aq(itypi,itypj)*ljB
18063 d_ljm(2)=d_ljm(1)*(0.5D0*eps2rt_om2/eps2rt+alf2/eps3rt)
18064 d_ljm(3)=d_ljm(1)*(0.5D0*eps1_om12+0.5D0*eps2rt_om12/eps2rt- &
18066 d_ljm(1)=d_ljm(1)*(0.5D0*eps2rt_om1/eps2rt-alf1/eps3rt)
18067 f1=(rij-ljxm)/(xm-ljxm)
18068 f2=(rij-xm)/(ljxm-xm)
18072 delta_inv=1.0d0/(ljxm-xm)
18073 deltasq_inv=delta_inv*delta_inv
18075 fac1=deltasq_inv*fac*(ljxm-rij)
18076 fac2=deltasq_inv*fac*(rij-xm)
18077 ed=delta_inv*(ljm*hd2-Ht*hd1)
18078 eom1=fac1*d_xm(1)+fac2*d_ljxm(1)+h2*d_ljm(1)
18079 eom2=fac1*d_xm(2)+fac2*d_ljxm(2)+h2*d_ljm(2)
18080 eom12=fac1*d_xm(3)+fac2*d_ljxm(3)+h2*d_ljm(3)
18082 !-------END FIRST METHOD, DISCONTINUOUS SECOND DERIVATIVE
18084 !-------SECOND METHOD, CONTINUOUS SECOND DERIVATIVE
18090 !$$$ d_ljB(1)=ljB*(eps2rt_om1/eps2rt-2.0d0*alf1/eps3rt)
18091 !$$$ d_ljB(2)=ljB*(eps2rt_om2/eps2rt+2.0d0*alf2/eps3rt)
18092 !$$$ d_ljB(3)=ljB*(eps1_om12+eps2rt_om12/eps2rt-2.0d0*alf12/eps3rt)
18094 !$$$ ssm=ssC-0.25D0*ssB*ssB/ssA
18095 !$$$ d_ssm(1)=0.5D0*akct*ssB/ssA
18096 !$$$ d_ssm(2)=2.0D0*akth*deltat2-om1*omega-d_ssm(1)
18097 !$$$ d_ssm(1)=-2.0D0*akth*deltat1-om2*omega+d_ssm(1)
18098 !$$$ d_ssm(3)=omega
18100 !$$$ ljm=-0.25D0*bb(itypi,itypj)/aa(itypi,itypj)
18102 !$$$ d_ljm(k)=ljm*d_ljB(k)
18106 !$$$ ss=ssA*ssd*ssd+ssB*ssd+ssC
18107 !$$$ d_ss(0)=2.0d0*ssA*ssd+ssB
18108 !$$$ d_ss(2)=akct*ssd
18109 !$$$ d_ss(1)=-d_ss(2)-2.0d0*akth*deltat1-om2*omega
18110 !$$$ d_ss(2)=d_ss(2)+2.0d0*akth*deltat2-om1*omega
18113 !$$$ ljf=bb(itypi,itypj)/aa(itypi,itypj)
18114 !$$$ ljf=9.0d0*ljf*(-0.5d0*ljf)**(1.0d0/3.0d0)
18115 !$$$ d_ljf(0)=ljf*2.0d0*ljB*fac1
18117 !$$$ d_ljf(k)=d_ljm(k)+ljf*(d_ljB(k)*fac1*fac1-
18118 !$$$ & 2.0d0*ljB*fac1*d_ljxm(k))
18120 !$$$ ljf=ljm+ljf*ljB*fac1*fac1
18122 !$$$ f1=(rij-ljxm)/(ssxm-ljxm)
18123 !$$$ f2=(rij-ssxm)/(ljxm-ssxm)
18124 !$$$ h1=h_base(f1,hd1)
18125 !$$$ h2=h_base(f2,hd2)
18126 !$$$ eij=ss*h1+ljf*h2
18127 !$$$ delta_inv=1.0d0/(ljxm-ssxm)
18128 !$$$ deltasq_inv=delta_inv*delta_inv
18129 !$$$ fac=ljf*hd2-ss*hd1
18130 !$$$ ed=d_ss(0)*h1+d_ljf(0)*h2+delta_inv*fac
18131 !$$$ eom1=d_ss(1)*h1+d_ljf(1)*h2+deltasq_inv*fac*
18132 !$$$ & (fac1*d_ssxm(1)-fac2*(d_ljxm(1)))
18133 !$$$ eom2=d_ss(2)*h1+d_ljf(2)*h2+deltasq_inv*fac*
18134 !$$$ & (fac1*d_ssxm(2)-fac2*(d_ljxm(2)))
18135 !$$$ eom12=d_ss(3)*h1+d_ljf(3)*h2+deltasq_inv*fac*
18136 !$$$ & (fac1*d_ssxm(3)-fac2*(d_ljxm(3)))
18138 !$$$ havebond=.false.
18139 !$$$ if (ed.gt.0.0d0) havebond=.true.
18140 !-------END SECOND METHOD, CONTINUOUS SECOND DERIVATIVE
18147 ! if (dyn_ssbond_ij(i,j).eq.1.0d300) then
18148 ! write(iout,'(a15,f12.2,f8.1,2i5)')
18149 ! & "SSBOND_E_FORM",totT,t_bath,i,j
18153 dyn_ssbond_ij(i,j)=eij
18154 else if (.not.havebond .and. dyn_ssbond_ij(i,j).lt.1.0d300) then
18155 dyn_ssbond_ij(i,j)=1.0d300
18158 ! write(iout,'(a15,f12.2,f8.1,2i5)')
18159 ! & "SSBOND_E_BREAK",totT,t_bath,i,j
18164 !-------TESTING CODE
18165 !el if (checkstop) then
18166 if (jcheck.eq.0) write(iout,'(a,3f15.8,$)') &
18167 "CHECKSTOP",rij,eij,ed
18171 if (checkstop) then
18172 write(iout,'(f15.8)')(echeck(1)-echeck(-1))*0.5d0/deps
18175 if (checkstop) then
18179 !-------END TESTING CODE
18182 dcosom1(k)=(dc_norm(k,nres+i)-om1*erij(k))/rij
18183 dcosom2(k)=(dc_norm(k,nres+j)-om2*erij(k))/rij
18186 gg(k)=ed*erij(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
18189 gvdwx(k,i)=gvdwx(k,i)-gg(k) &
18190 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
18191 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
18192 gvdwx(k,j)=gvdwx(k,j)+gg(k) &
18193 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
18194 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
18198 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
18203 gvdwc(l,i)=gvdwc(l,i)-gg(l)
18204 gvdwc(l,j)=gvdwc(l,j)+gg(l)
18208 end subroutine dyn_ssbond_ene
18209 !--------------------------------------------------------------------------
18210 subroutine triple_ssbond_ene(resi,resj,resk,eij)
18215 ! include 'DIMENSIONS'
18216 ! include 'COMMON.SBRIDGE'
18217 ! include 'COMMON.CHAIN'
18218 ! include 'COMMON.DERIV'
18219 ! include 'COMMON.LOCAL'
18220 ! include 'COMMON.INTERACT'
18221 ! include 'COMMON.VAR'
18222 ! include 'COMMON.IOUNITS'
18223 ! include 'COMMON.CALC'
18227 ! include 'COMMON.MD'
18228 ! use MD, only: totT,t_bath
18231 double precision h_base
18235 integer resi,resj,resk,m,itypi,itypj,itypk
18237 !c Output arguments
18238 double precision eij,eij1,eij2,eij3
18242 !c integer itypi,itypj,k,l
18243 double precision rrij,ssd,deltat1,deltat2,deltat12,cosphi
18244 double precision rrik,rrjk,rik,rjk,xi,xk,yi,yk,zi,zk,xij,yij,zij
18245 double precision xik,yik,zik,xjk,yjk,zjk,dxk,dyk,dzk
18246 double precision sig0ij,ljd,sig,fac,e1,e2
18247 double precision dcosom1(3),dcosom2(3),ed
18248 double precision pom1,pom2
18249 double precision ljA,ljB,ljXs
18250 double precision d_ljB(1:3)
18251 double precision ssA,ssB,ssC,ssXs
18252 double precision ssxm,ljxm,ssm,ljm
18253 double precision d_ssxm(1:3),d_ljxm(1:3),d_ssm(1:3),d_ljm(1:3)
18255 if (dtriss.eq.0) return
18259 !C write(iout,*) resi,resj,resk
18261 dxi=dc_norm(1,nres+i)
18262 dyi=dc_norm(2,nres+i)
18263 dzi=dc_norm(3,nres+i)
18264 dsci_inv=vbld_inv(i+nres)
18273 dxj=dc_norm(1,nres+j)
18274 dyj=dc_norm(2,nres+j)
18275 dzj=dc_norm(3,nres+j)
18276 dscj_inv=vbld_inv(j+nres)
18282 dxk=dc_norm(1,nres+k)
18283 dyk=dc_norm(2,nres+k)
18284 dzk=dc_norm(3,nres+k)
18285 dscj_inv=vbld_inv(k+nres)
18295 rrij=(xij*xij+yij*yij+zij*zij)
18296 rij=dsqrt(rrij) ! sc_angular needs rij to really be the inverse
18297 rrik=(xik*xik+yik*yik+zik*zik)
18299 rrjk=(xjk*xjk+yjk*yjk+zjk*zjk)
18301 !C there are three combination of distances for each trisulfide bonds
18302 !C The first case the ith atom is the center
18303 !C Energy function is E=d/(a*(x-y)**2+b*(x+y)**2+c) where x is first
18304 !C distance y is second distance the a,b,c,d are parameters derived for
18305 !C this problem d parameter was set as a penalty currenlty set to 1.
18306 if ((iabs(j-i).le.2).or.(iabs(i-k).le.2)) then
18309 eij1=dtriss/(atriss*(rij-rik)**2+btriss*(rij+rik)**6+ctriss)
18311 !C second case jth atom is center
18312 if ((iabs(j-i).le.2).or.(iabs(j-k).le.2)) then
18315 eij2=dtriss/(atriss*(rij-rjk)**2+btriss*(rij+rjk)**6+ctriss)
18317 !C the third case kth atom is the center
18318 if ((iabs(i-k).le.2).or.(iabs(j-k).le.2)) then
18321 eij3=dtriss/(atriss*(rik-rjk)**2+btriss*(rik+rjk)**6+ctriss)
18327 !C write(iout,*)i,j,k,eij
18328 !C The energy penalty calculated now time for the gradient part
18329 !C derivative over rij
18330 fac=-eij1**2/dtriss*(2.0*atriss*(rij-rik)+6.0*btriss*(rij+rik)**5) &
18331 -eij2**2/dtriss*(2.0*atriss*(rij-rjk)+6.0*btriss*(rij+rjk)**5)
18336 gvdwx(m,i)=gvdwx(m,i)-gg(m)
18337 gvdwx(m,j)=gvdwx(m,j)+gg(m)
18341 gvdwc(l,i)=gvdwc(l,i)-gg(l)
18342 gvdwc(l,j)=gvdwc(l,j)+gg(l)
18344 !C now derivative over rik
18345 fac=-eij1**2/dtriss* &
18346 (-2.0*atriss*(rij-rik)+6.0*btriss*(rij+rik)**5) &
18347 -eij3**2/dtriss*(2.0*atriss*(rik-rjk)+6.0*btriss*(rik+rjk)**5)
18352 gvdwx(m,i)=gvdwx(m,i)-gg(m)
18353 gvdwx(m,k)=gvdwx(m,k)+gg(m)
18356 gvdwc(l,i)=gvdwc(l,i)-gg(l)
18357 gvdwc(l,k)=gvdwc(l,k)+gg(l)
18359 !C now derivative over rjk
18360 fac=-eij2**2/dtriss* &
18361 (-2.0*atriss*(rij-rjk)+6.0*btriss*(rij+rjk)**5)- &
18362 eij3**2/dtriss*(-2.0*atriss*(rik-rjk)+6.0*btriss*(rik+rjk)**5)
18367 gvdwx(m,j)=gvdwx(m,j)-gg(m)
18368 gvdwx(m,k)=gvdwx(m,k)+gg(m)
18371 gvdwc(l,j)=gvdwc(l,j)-gg(l)
18372 gvdwc(l,k)=gvdwc(l,k)+gg(l)
18375 end subroutine triple_ssbond_ene
18379 !-----------------------------------------------------------------------------
18380 real(kind=8) function h_base(x,deriv)
18381 ! A smooth function going 0->1 in range [0,1]
18382 ! It should NOT be called outside range [0,1], it will not work there.
18389 real(kind=8) :: deriv
18392 real(kind=8) :: xsq
18395 ! Two parabolas put together. First derivative zero at extrema
18396 !$$$ if (x.lt.0.5D0) then
18397 !$$$ h_base=2.0D0*x*x
18401 !$$$ h_base=1.0D0-2.0D0*deriv*deriv
18402 !$$$ deriv=4.0D0*deriv
18405 ! Third degree polynomial. First derivative zero at extrema
18406 h_base=x*x*(3.0d0-2.0d0*x)
18407 deriv=6.0d0*x*(1.0d0-x)
18409 ! Fifth degree polynomial. First and second derivatives zero at extrema
18411 !$$$ h_base=x*xsq*(6.0d0*xsq-15.0d0*x+10.0d0)
18413 !$$$ deriv=deriv*deriv
18414 !$$$ deriv=30.0d0*xsq*deriv
18417 end function h_base
18418 !-----------------------------------------------------------------------------
18419 subroutine dyn_set_nss
18420 ! Adjust nss and other relevant variables based on dyn_ssbond_ij
18422 use MD_data, only: totT,t_bath
18424 ! include 'DIMENSIONS'
18428 ! include 'COMMON.SBRIDGE'
18429 ! include 'COMMON.CHAIN'
18430 ! include 'COMMON.IOUNITS'
18431 ! include 'COMMON.SETUP'
18432 ! include 'COMMON.MD'
18434 real(kind=8) :: emin
18435 integer :: i,j,imin,ierr
18436 integer :: diff,allnss,newnss
18437 integer,dimension(maxdim) :: allflag,allihpb,alljhpb,& !(maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
18440 integer,dimension(0:nfgtasks) :: i_newnss
18441 integer,dimension(0:nfgtasks) :: displ
18442 integer,dimension(maxdim) :: g_newihpb,g_newjhpb !(maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
18443 integer :: g_newnss
18448 if (dyn_ssbond_ij(i,j).lt.1.0d300) then
18457 !mc write(iout,*)"ALLNSS ",allnss,(allihpb(i),alljhpb(i),i=1,allnss)
18461 if (allflag(i).eq.0 .and. &
18462 dyn_ssbond_ij(allihpb(i),alljhpb(i)).lt.emin) then
18463 emin=dyn_ssbond_ij(allihpb(i),alljhpb(i))
18467 if (emin.lt.1.0d300) then
18470 if (allflag(i).eq.0 .and. &
18471 (allihpb(i).eq.allihpb(imin) .or. &
18472 alljhpb(i).eq.allihpb(imin) .or. &
18473 allihpb(i).eq.alljhpb(imin) .or. &
18474 alljhpb(i).eq.alljhpb(imin))) then
18481 !mc write(iout,*)"ALLNSS ",allnss,(allihpb(i),alljhpb(i),i=1,allnss)
18485 if (allflag(i).eq.1) then
18487 newihpb(newnss)=allihpb(i)
18488 newjhpb(newnss)=alljhpb(i)
18493 if (nfgtasks.gt.1)then
18495 call MPI_Reduce(newnss,g_newnss,1,&
18496 MPI_INTEGER,MPI_SUM,king,FG_COMM,IERR)
18497 call MPI_Gather(newnss,1,MPI_INTEGER,&
18498 i_newnss,1,MPI_INTEGER,king,FG_COMM,IERR)
18500 do i=1,nfgtasks-1,1
18501 displ(i)=i_newnss(i-1)+displ(i-1)
18503 call MPI_Gatherv(newihpb,newnss,MPI_INTEGER,&
18504 g_newihpb,i_newnss,displ,MPI_INTEGER,&
18506 call MPI_Gatherv(newjhpb,newnss,MPI_INTEGER,&
18507 g_newjhpb,i_newnss,displ,MPI_INTEGER,&
18509 if(fg_rank.eq.0) then
18510 ! print *,'g_newnss',g_newnss
18511 ! print *,'g_newihpb',(g_newihpb(i),i=1,g_newnss)
18512 ! print *,'g_newjhpb',(g_newjhpb(i),i=1,g_newnss)
18515 newihpb(i)=g_newihpb(i)
18516 newjhpb(i)=g_newjhpb(i)
18524 !mc write(iout,*)"NEWNSS ",newnss,(newihpb(i),newjhpb(i),i=1,newnss)
18525 ! print *,newnss,nss,maxdim
18531 if (idssb(i).eq.newihpb(j) .and. &
18532 jdssb(i).eq.newjhpb(j)) found=.true.
18536 ! write(iout,*) "found",found,i,j
18537 if (.not.found.and.fg_rank.eq.0) &
18538 write(iout,'(a15,f12.2,f8.1,2i5)') &
18539 "SSBOND_BREAK",totT,t_bath,idssb(i),jdssb(i)
18548 if (newihpb(i).eq.idssb(j) .and. &
18549 newjhpb(i).eq.jdssb(j)) found=.true.
18553 ! write(iout,*) "found",found,i,j
18554 if (.not.found.and.fg_rank.eq.0) &
18555 write(iout,'(a15,f12.2,f8.1,2i5)') &
18556 "SSBOND_FORM",totT,t_bath,newihpb(i),newjhpb(i)
18563 idssb(i)=newihpb(i)
18564 jdssb(i)=newjhpb(i)
18568 end subroutine dyn_set_nss
18569 ! Lipid transfer energy function
18570 subroutine Eliptransfer(eliptran)
18571 !C this is done by Adasko
18572 !C print *,"wchodze"
18573 !C structure of box:
18575 !C--bordliptop-- buffore starts
18576 !C--bufliptop--- here true lipid starts
18578 !C--buflipbot--- lipid ends buffore starts
18579 !C--bordlipbot--buffore ends
18580 real(kind=8) :: fracinbuf,eliptran,sslip,positi,ssgradlip
18583 ! print *, "I am in eliptran"
18584 do i=ilip_start,ilip_end
18586 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1).or.(i.eq.nres))&
18589 positi=(mod(((c(3,i)+c(3,i+1))/2.0d0),boxzsize))
18590 if (positi.le.0.0) positi=positi+boxzsize
18592 !C first for peptide groups
18593 !c for each residue check if it is in lipid or lipid water border area
18594 if ((positi.gt.bordlipbot) &
18595 .and.(positi.lt.bordliptop)) then
18596 !C the energy transfer exist
18597 if (positi.lt.buflipbot) then
18598 !C what fraction I am in
18600 ((positi-bordlipbot)/lipbufthick)
18601 !C lipbufthick is thickenes of lipid buffore
18602 sslip=sscalelip(fracinbuf)
18603 ssgradlip=-sscagradlip(fracinbuf)/lipbufthick
18604 eliptran=eliptran+sslip*pepliptran
18605 gliptranc(3,i)=gliptranc(3,i)+ssgradlip*pepliptran/2.0d0
18606 gliptranc(3,i-1)=gliptranc(3,i-1)+ssgradlip*pepliptran/2.0d0
18607 !C gliptranc(3,i-2)=gliptranc(3,i)+ssgradlip*pepliptran
18609 !C print *,"doing sccale for lower part"
18610 !C print *,i,sslip,fracinbuf,ssgradlip
18611 elseif (positi.gt.bufliptop) then
18612 fracinbuf=1.0d0-((bordliptop-positi)/lipbufthick)
18613 sslip=sscalelip(fracinbuf)
18614 ssgradlip=sscagradlip(fracinbuf)/lipbufthick
18615 eliptran=eliptran+sslip*pepliptran
18616 gliptranc(3,i)=gliptranc(3,i)+ssgradlip*pepliptran/2.0d0
18617 gliptranc(3,i-1)=gliptranc(3,i-1)+ssgradlip*pepliptran/2.0d0
18618 !C gliptranc(3,i-2)=gliptranc(3,i)+ssgradlip*pepliptran
18619 !C print *, "doing sscalefor top part"
18620 !C print *,i,sslip,fracinbuf,ssgradlip
18622 eliptran=eliptran+pepliptran
18623 !C print *,"I am in true lipid"
18626 !C eliptran=elpitran+0.0 ! I am in water
18628 if (energy_dec) write(iout,*) i,"eliptran=",eliptran,positi,sslip
18630 ! here starts the side chain transfer
18631 do i=ilip_start,ilip_end
18632 if (itype(i,1).eq.ntyp1) cycle
18633 positi=(mod(c(3,i+nres),boxzsize))
18634 if (positi.le.0) positi=positi+boxzsize
18635 !C print *,mod(c(3,i+nres),boxzsize),bordlipbot,bordliptop
18636 !c for each residue check if it is in lipid or lipid water border area
18637 !C respos=mod(c(3,i+nres),boxzsize)
18638 !C print *,positi,bordlipbot,buflipbot
18639 if ((positi.gt.bordlipbot) &
18640 .and.(positi.lt.bordliptop)) then
18641 !C the energy transfer exist
18642 if (positi.lt.buflipbot) then
18644 ((positi-bordlipbot)/lipbufthick)
18645 !C lipbufthick is thickenes of lipid buffore
18646 sslip=sscalelip(fracinbuf)
18647 ssgradlip=-sscagradlip(fracinbuf)/lipbufthick
18648 eliptran=eliptran+sslip*liptranene(itype(i,1))
18649 gliptranx(3,i)=gliptranx(3,i) &
18650 +ssgradlip*liptranene(itype(i,1))
18651 gliptranc(3,i-1)= gliptranc(3,i-1) &
18652 +ssgradlip*liptranene(itype(i,1))
18653 !C print *,"doing sccale for lower part"
18654 elseif (positi.gt.bufliptop) then
18656 ((bordliptop-positi)/lipbufthick)
18657 sslip=sscalelip(fracinbuf)
18658 ssgradlip=sscagradlip(fracinbuf)/lipbufthick
18659 eliptran=eliptran+sslip*liptranene(itype(i,1))
18660 gliptranx(3,i)=gliptranx(3,i) &
18661 +ssgradlip*liptranene(itype(i,1))
18662 gliptranc(3,i-1)= gliptranc(3,i-1) &
18663 +ssgradlip*liptranene(itype(i,1))
18664 !C print *, "doing sscalefor top part",sslip,fracinbuf
18666 eliptran=eliptran+liptranene(itype(i,1))
18667 !C print *,"I am in true lipid"
18669 endif ! if in lipid or buffor
18671 !C eliptran=elpitran+0.0 ! I am in water
18672 if (energy_dec) write(iout,*) i,"eliptran=",eliptran
18675 end subroutine Eliptransfer
18676 !----------------------------------NANO FUNCTIONS
18677 !C-----------------------------------------------------------------------
18678 !C-----------------------------------------------------------
18679 !C This subroutine is to mimic the histone like structure but as well can be
18680 !C utilizet to nanostructures (infinit) small modification has to be used to
18681 !C make it finite (z gradient at the ends has to be changes as well as the x,y
18682 !C gradient has to be modified at the ends
18683 !C The energy function is Kihara potential
18684 !C E=4esp*((sigma/(r-r0))^12 - (sigma/(r-r0))^6)
18685 !C 4eps is depth of well sigma is r_minimum r is distance from center of tube
18686 !C and r0 is the excluded size of nanotube (can be set to 0 if we want just a
18687 !C simple Kihara potential
18688 subroutine calctube(Etube)
18689 real(kind=8),dimension(3) :: vectube
18690 real(kind=8) :: Etube,xtemp,xminact,yminact,&
18691 ytemp,xmin,ymin,tub_r,rdiff,rdiff6,fac,positi, &
18692 sc_aa_tube,sc_bb_tube
18695 do i=itube_start,itube_end
18697 enetube(i+nres)=0.0d0
18699 !C first we calculate the distance from tube center
18701 do i=itube_start,itube_end
18702 !C lets ommit dummy atoms for now
18703 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1)) cycle
18704 !C now calculate distance from center of tube and direction vectors
18707 ! Find minimum distance in periodic box
18709 vectube(1)=mod((c(1,i)+c(1,i+1))/2.0d0,boxxsize)
18710 vectube(1)=vectube(1)+boxxsize*j
18711 vectube(2)=mod((c(2,i)+c(2,i+1))/2.0d0,boxysize)
18712 vectube(2)=vectube(2)+boxysize*j
18713 xminact=abs(vectube(1)-tubecenter(1))
18714 yminact=abs(vectube(2)-tubecenter(2))
18715 if (xmin.gt.xminact) then
18719 if (ymin.gt.yminact) then
18726 vectube(1)=vectube(1)-tubecenter(1)
18727 vectube(2)=vectube(2)-tubecenter(2)
18729 !C print *,"x",(c(1,i)+c(1,i+1))/2.0d0,tubecenter(1)
18730 !C print *,"y",(c(2,i)+c(2,i+1))/2.0d0,tubecenter(2)
18732 !C as the tube is infinity we do not calculate the Z-vector use of Z
18735 !C now calculte the distance
18736 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
18737 !C now normalize vector
18738 vectube(1)=vectube(1)/tub_r
18739 vectube(2)=vectube(2)/tub_r
18740 !C calculte rdiffrence between r and r0
18743 rdiff6=rdiff**6.0d0
18744 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
18745 enetube(i)=pep_aa_tube/rdiff6**2.0d0+pep_bb_tube/rdiff6
18746 !C write(iout,*) "TU13",i,rdiff6,enetube(i)
18747 !C print *,rdiff,rdiff6,pep_aa_tube
18748 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
18749 !C now we calculate gradient
18750 fac=(-12.0d0*pep_aa_tube/rdiff6- &
18751 6.0d0*pep_bb_tube)/rdiff6/rdiff
18752 !C write(iout,'(a5,i4,f12.1,3f12.5)') "TU13",i,rdiff6,enetube(i),
18754 !C now direction of gg_tube vector
18756 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac/2.0d0
18757 gg_tube(j,i)=gg_tube(j,i)+vectube(j)*fac/2.0d0
18760 !C basically thats all code now we split for side-chains (REMEMBER to sum up at the END)
18761 !C print *,gg_tube(1,0),"TU"
18764 do i=itube_start,itube_end
18765 !C Lets not jump over memory as we use many times iti
18767 !C lets ommit dummy atoms for now
18768 if ((iti.eq.ntyp1) &
18769 !C in UNRES uncomment the line below as GLY has no side-chain...
18775 vectube(1)=mod((c(1,i+nres)),boxxsize)
18776 vectube(1)=vectube(1)+boxxsize*j
18777 vectube(2)=mod((c(2,i+nres)),boxysize)
18778 vectube(2)=vectube(2)+boxysize*j
18780 xminact=abs(vectube(1)-tubecenter(1))
18781 yminact=abs(vectube(2)-tubecenter(2))
18782 if (xmin.gt.xminact) then
18786 if (ymin.gt.yminact) then
18793 !C write(iout,*), "tututu", vectube(1),tubecenter(1),vectube(2),
18795 vectube(1)=vectube(1)-tubecenter(1)
18796 vectube(2)=vectube(2)-tubecenter(2)
18798 !C as the tube is infinity we do not calculate the Z-vector use of Z
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
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 sc_aa_tube=sc_aa_tube_par(iti)
18813 sc_bb_tube=sc_bb_tube_par(iti)
18814 enetube(i+nres)=sc_aa_tube/rdiff6**2.0d0+sc_bb_tube/rdiff6
18815 fac=-12.0d0*sc_aa_tube/rdiff6**2.0d0/rdiff- &
18816 6.0d0*sc_bb_tube/rdiff6/rdiff
18817 !C now direction of gg_tube vector
18819 gg_tube_SC(j,i)=gg_tube_SC(j,i)+vectube(j)*fac
18820 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac
18823 do i=itube_start,itube_end
18824 Etube=Etube+enetube(i)+enetube(i+nres)
18826 !C print *,"ETUBE", etube
18828 end subroutine calctube
18829 !C TO DO 1) add to total energy
18830 !C 2) add to gradient summation
18831 !C 3) add reading parameters (AND of course oppening of PARAM file)
18832 !C 4) add reading the center of tube
18834 !C 6) add to zerograd
18835 !C 7) allocate matrices
18838 !C-----------------------------------------------------------------------
18839 !C-----------------------------------------------------------
18840 !C This subroutine is to mimic the histone like structure but as well can be
18841 !C utilizet to nanostructures (infinit) small modification has to be used to
18842 !C make it finite (z gradient at the ends has to be changes as well as the x,y
18843 !C gradient has to be modified at the ends
18844 !C The energy function is Kihara potential
18845 !C E=4esp*((sigma/(r-r0))^12 - (sigma/(r-r0))^6)
18846 !C 4eps is depth of well sigma is r_minimum r is distance from center of tube
18847 !C and r0 is the excluded size of nanotube (can be set to 0 if we want just a
18848 !C simple Kihara potential
18849 subroutine calctube2(Etube)
18850 real(kind=8),dimension(3) :: vectube
18851 real(kind=8) :: Etube,xtemp,xminact,yminact,&
18852 ytemp,xmin,ymin,tub_r,rdiff,rdiff6,fac,positi,fracinbuf,&
18853 sstube,ssgradtube,sc_aa_tube,sc_bb_tube
18856 do i=itube_start,itube_end
18858 enetube(i+nres)=0.0d0
18860 !C first we calculate the distance from tube center
18861 !C first sugare-phosphate group for NARES this would be peptide group
18863 do i=itube_start,itube_end
18864 !C lets ommit dummy atoms for now
18866 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1)) cycle
18867 !C now calculate distance from center of tube and direction vectors
18868 !C vectube(1)=mod((c(1,i)+c(1,i+1))/2.0d0,boxxsize)
18869 !C if (vectube(1).lt.0) vectube(1)=vectube(1)+boxxsize
18870 !C vectube(2)=mod((c(2,i)+c(2,i+1))/2.0d0,boxysize)
18871 !C if (vectube(2).lt.0) vectube(2)=vectube(2)+boxysize
18875 vectube(1)=mod((c(1,i)+c(1,i+1))/2.0d0,boxxsize)
18876 vectube(1)=vectube(1)+boxxsize*j
18877 vectube(2)=mod((c(2,i)+c(2,i+1))/2.0d0,boxysize)
18878 vectube(2)=vectube(2)+boxysize*j
18880 xminact=abs(vectube(1)-tubecenter(1))
18881 yminact=abs(vectube(2)-tubecenter(2))
18882 if (xmin.gt.xminact) then
18886 if (ymin.gt.yminact) then
18893 vectube(1)=vectube(1)-tubecenter(1)
18894 vectube(2)=vectube(2)-tubecenter(2)
18896 !C print *,"x",(c(1,i)+c(1,i+1))/2.0d0,tubecenter(1)
18897 !C print *,"y",(c(2,i)+c(2,i+1))/2.0d0,tubecenter(2)
18899 !C as the tube is infinity we do not calculate the Z-vector use of Z
18902 !C now calculte the distance
18903 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
18904 !C now normalize vector
18905 vectube(1)=vectube(1)/tub_r
18906 vectube(2)=vectube(2)/tub_r
18907 !C calculte rdiffrence between r and r0
18910 rdiff6=rdiff**6.0d0
18911 !C THIS FRAGMENT MAKES TUBE FINITE
18912 positi=mod((c(3,i)+c(3,i+1))/2.0d0,boxzsize)
18913 if (positi.le.0) positi=positi+boxzsize
18914 !C print *,mod(c(3,i+nres),boxzsize),bordlipbot,bordliptop
18915 !c for each residue check if it is in lipid or lipid water border area
18916 !C respos=mod(c(3,i+nres),boxzsize)
18917 !C print *,positi,bordtubebot,buftubebot,bordtubetop
18918 if ((positi.gt.bordtubebot) &
18919 .and.(positi.lt.bordtubetop)) then
18920 !C the energy transfer exist
18921 if (positi.lt.buftubebot) then
18923 ((positi-bordtubebot)/tubebufthick)
18924 !C lipbufthick is thickenes of lipid buffore
18925 sstube=sscalelip(fracinbuf)
18926 ssgradtube=-sscagradlip(fracinbuf)/tubebufthick
18927 !C print *,ssgradtube, sstube,tubetranene(itype(i,1))
18928 enetube(i)=enetube(i)+sstube*tubetranenepep
18929 !C gg_tube_SC(3,i)=gg_tube_SC(3,i)
18930 !C &+ssgradtube*tubetranene(itype(i,1))
18931 !C gg_tube(3,i-1)= gg_tube(3,i-1)
18932 !C &+ssgradtube*tubetranene(itype(i,1))
18933 !C print *,"doing sccale for lower part"
18934 elseif (positi.gt.buftubetop) then
18936 ((bordtubetop-positi)/tubebufthick)
18937 sstube=sscalelip(fracinbuf)
18938 ssgradtube=sscagradlip(fracinbuf)/tubebufthick
18939 enetube(i)=enetube(i)+sstube*tubetranenepep
18940 !C gg_tube_SC(3,i)=gg_tube_SC(3,i)
18941 !C &+ssgradtube*tubetranene(itype(i,1))
18942 !C gg_tube(3,i-1)= gg_tube(3,i-1)
18943 !C &+ssgradtube*tubetranene(itype(i,1))
18944 !C print *, "doing sscalefor top part",sslip,fracinbuf
18948 enetube(i)=enetube(i)+sstube*tubetranenepep
18949 !C print *,"I am in true lipid"
18953 !C ssgradtube=0.0d0
18955 endif ! if in lipid or buffor
18957 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
18958 enetube(i)=enetube(i)+sstube* &
18959 (pep_aa_tube/rdiff6**2.0d0+pep_bb_tube/rdiff6)
18960 !C write(iout,*) "TU13",i,rdiff6,enetube(i)
18961 !C print *,rdiff,rdiff6,pep_aa_tube
18962 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
18963 !C now we calculate gradient
18964 fac=(-12.0d0*pep_aa_tube/rdiff6- &
18965 6.0d0*pep_bb_tube)/rdiff6/rdiff*sstube
18966 !C write(iout,'(a5,i4,f12.1,3f12.5)') "TU13",i,rdiff6,enetube(i),
18969 !C now direction of gg_tube vector
18971 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac/2.0d0
18972 gg_tube(j,i)=gg_tube(j,i)+vectube(j)*fac/2.0d0
18974 gg_tube(3,i)=gg_tube(3,i) &
18975 +ssgradtube*enetube(i)/sstube/2.0d0
18976 gg_tube(3,i-1)= gg_tube(3,i-1) &
18977 +ssgradtube*enetube(i)/sstube/2.0d0
18980 !C basically thats all code now we split for side-chains (REMEMBER to sum up at the END)
18981 !C print *,gg_tube(1,0),"TU"
18982 do i=itube_start,itube_end
18983 !C Lets not jump over memory as we use many times iti
18985 !C lets ommit dummy atoms for now
18986 if ((iti.eq.ntyp1) &
18987 !!C in UNRES uncomment the line below as GLY has no side-chain...
18990 vectube(1)=c(1,i+nres)
18991 vectube(1)=mod(vectube(1),boxxsize)
18992 if (vectube(1).lt.0) vectube(1)=vectube(1)+boxxsize
18993 vectube(2)=c(2,i+nres)
18994 vectube(2)=mod(vectube(2),boxysize)
18995 if (vectube(2).lt.0) vectube(2)=vectube(2)+boxysize
18997 vectube(1)=vectube(1)-tubecenter(1)
18998 vectube(2)=vectube(2)-tubecenter(2)
18999 !C THIS FRAGMENT MAKES TUBE FINITE
19000 positi=(mod(c(3,i+nres),boxzsize))
19001 if (positi.le.0) positi=positi+boxzsize
19002 !C print *,mod(c(3,i+nres),boxzsize),bordlipbot,bordliptop
19003 !c for each residue check if it is in lipid or lipid water border area
19004 !C respos=mod(c(3,i+nres),boxzsize)
19005 !C print *,positi,bordtubebot,buftubebot,bordtubetop
19007 if ((positi.gt.bordtubebot) &
19008 .and.(positi.lt.bordtubetop)) then
19009 !C the energy transfer exist
19010 if (positi.lt.buftubebot) then
19012 ((positi-bordtubebot)/tubebufthick)
19013 !C lipbufthick is thickenes of lipid buffore
19014 sstube=sscalelip(fracinbuf)
19015 ssgradtube=-sscagradlip(fracinbuf)/tubebufthick
19016 !C print *,ssgradtube, sstube,tubetranene(itype(i,1))
19017 enetube(i+nres)=enetube(i+nres)+sstube*tubetranene(itype(i,1))
19018 !C gg_tube_SC(3,i)=gg_tube_SC(3,i)
19019 !C &+ssgradtube*tubetranene(itype(i,1))
19020 !C gg_tube(3,i-1)= gg_tube(3,i-1)
19021 !C &+ssgradtube*tubetranene(itype(i,1))
19022 !C print *,"doing sccale for lower part"
19023 elseif (positi.gt.buftubetop) then
19025 ((bordtubetop-positi)/tubebufthick)
19027 sstube=sscalelip(fracinbuf)
19028 ssgradtube=sscagradlip(fracinbuf)/tubebufthick
19029 enetube(i+nres)=enetube(i+nres)+sstube*tubetranene(itype(i,1))
19030 !C gg_tube_SC(3,i)=gg_tube_SC(3,i)
19031 !C &+ssgradtube*tubetranene(itype(i,1))
19032 !C gg_tube(3,i-1)= gg_tube(3,i-1)
19033 !C &+ssgradtube*tubetranene(itype(i,1))
19034 !C print *, "doing sscalefor top part",sslip,fracinbuf
19038 enetube(i+nres)=enetube(i+nres)+sstube*tubetranene(itype(i,1))
19039 !C print *,"I am in true lipid"
19043 !C ssgradtube=0.0d0
19045 endif ! if in lipid or buffor
19046 !CEND OF FINITE FRAGMENT
19047 !C as the tube is infinity we do not calculate the Z-vector use of Z
19050 !C now calculte the distance
19051 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
19052 !C now normalize vector
19053 vectube(1)=vectube(1)/tub_r
19054 vectube(2)=vectube(2)/tub_r
19055 !C calculte rdiffrence between r and r0
19058 rdiff6=rdiff**6.0d0
19059 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
19060 sc_aa_tube=sc_aa_tube_par(iti)
19061 sc_bb_tube=sc_bb_tube_par(iti)
19062 enetube(i+nres)=(sc_aa_tube/rdiff6**2.0d0+sc_bb_tube/rdiff6)&
19063 *sstube+enetube(i+nres)
19064 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
19065 !C now we calculate gradient
19066 fac=(-12.0d0*sc_aa_tube/rdiff6**2.0d0/rdiff-&
19067 6.0d0*sc_bb_tube/rdiff6/rdiff)*sstube
19068 !C now direction of gg_tube vector
19070 gg_tube_SC(j,i)=gg_tube_SC(j,i)+vectube(j)*fac
19071 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac
19073 gg_tube_SC(3,i)=gg_tube_SC(3,i) &
19074 +ssgradtube*enetube(i+nres)/sstube
19075 gg_tube(3,i-1)= gg_tube(3,i-1) &
19076 +ssgradtube*enetube(i+nres)/sstube
19079 do i=itube_start,itube_end
19080 Etube=Etube+enetube(i)+enetube(i+nres)
19082 !C print *,"ETUBE", etube
19084 end subroutine calctube2
19085 !=====================================================================================================================================
19086 subroutine calcnano(Etube)
19087 real(kind=8),dimension(3) :: vectube
19089 real(kind=8) :: Etube,xtemp,xminact,yminact,&
19090 ytemp,xmin,ymin,tub_r,rdiff,rdiff6,fac,denominator,faccav,&
19091 sc_aa_tube,sc_bb_tube,zmin,ztemp,zminact
19092 integer:: i,j,iti,r
19095 ! print *,itube_start,itube_end,"poczatek"
19096 do i=itube_start,itube_end
19098 enetube(i+nres)=0.0d0
19100 !C first we calculate the distance from tube center
19101 !C first sugare-phosphate group for NARES this would be peptide group
19103 do i=itube_start,itube_end
19104 !C lets ommit dummy atoms for now
19105 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1)) cycle
19106 !C now calculate distance from center of tube and direction vectors
19112 vectube(1)=dmod((c(1,i)+c(1,i+1))/2.0d0,boxxsize)
19113 vectube(1)=vectube(1)+boxxsize*j
19114 vectube(2)=dmod((c(2,i)+c(2,i+1))/2.0d0,boxysize)
19115 vectube(2)=vectube(2)+boxysize*j
19116 vectube(3)=dmod((c(3,i)+c(3,i+1))/2.0d0,boxzsize)
19117 vectube(3)=vectube(3)+boxzsize*j
19120 xminact=dabs(vectube(1)-tubecenter(1))
19121 yminact=dabs(vectube(2)-tubecenter(2))
19122 zminact=dabs(vectube(3)-tubecenter(3))
19124 if (xmin.gt.xminact) then
19128 if (ymin.gt.yminact) then
19132 if (zmin.gt.zminact) then
19141 vectube(1)=vectube(1)-tubecenter(1)
19142 vectube(2)=vectube(2)-tubecenter(2)
19143 vectube(3)=vectube(3)-tubecenter(3)
19145 !C print *,"x",(c(1,i)+c(1,i+1))/2.0d0,tubecenter(1)
19146 !C print *,"y",(c(2,i)+c(2,i+1))/2.0d0,tubecenter(2)
19147 !C as the tube is infinity we do not calculate the Z-vector use of Z
19149 !C vectube(3)=0.0d0
19150 !C now calculte the distance
19151 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
19152 !C now normalize vector
19153 vectube(1)=vectube(1)/tub_r
19154 vectube(2)=vectube(2)/tub_r
19155 vectube(3)=vectube(3)/tub_r
19156 !C calculte rdiffrence between r and r0
19159 rdiff6=rdiff**6.0d0
19160 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
19161 enetube(i)=pep_aa_tube/rdiff6**2.0d0+pep_bb_tube/rdiff6
19162 !C write(iout,*) "TU13",i,rdiff6,enetube(i)
19163 !C print *,rdiff,rdiff6,pep_aa_tube
19164 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
19165 !C now we calculate gradient
19166 fac=(-12.0d0*pep_aa_tube/rdiff6- &
19167 6.0d0*pep_bb_tube)/rdiff6/rdiff
19168 !C write(iout,'(a5,i4,f12.1,3f12.5)') "TU13",i,rdiff6,enetube(i),
19170 if (acavtubpep.eq.0.0d0) then
19175 denominator=(1.0d0+dcavtubpep*rdiff6*rdiff6)
19177 (bcavtubpep*rdiff+acavtubpep*dsqrt(rdiff)+ccavtubpep) &
19180 faccav=((bcavtubpep*1.0d0+acavtubpep/2.0d0/dsqrt(rdiff)) &
19181 *denominator-(bcavtubpep*rdiff+acavtubpep*dsqrt(rdiff) &
19182 +ccavtubpep)*rdiff6**2.0d0/rdiff*dcavtubpep*12.0d0) &
19183 /denominator**2.0d0
19188 if (energy_dec) write(iout,*),i,rdiff,enetube(i),enecavtube(i)
19190 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac/2.0d0
19191 gg_tube(j,i)=gg_tube(j,i)+vectube(j)*fac/2.0d0
19195 do i=itube_start,itube_end
19196 enecavtube(i)=0.0d0
19197 !C Lets not jump over memory as we use many times iti
19199 !C lets ommit dummy atoms for now
19200 if ((iti.eq.ntyp1) &
19201 !C in UNRES uncomment the line below as GLY has no side-chain...
19208 vectube(1)=dmod((c(1,i+nres)),boxxsize)
19209 vectube(1)=vectube(1)+boxxsize*j
19210 vectube(2)=dmod((c(2,i+nres)),boxysize)
19211 vectube(2)=vectube(2)+boxysize*j
19212 vectube(3)=dmod((c(3,i+nres)),boxzsize)
19213 vectube(3)=vectube(3)+boxzsize*j
19216 xminact=dabs(vectube(1)-tubecenter(1))
19217 yminact=dabs(vectube(2)-tubecenter(2))
19218 zminact=dabs(vectube(3)-tubecenter(3))
19220 if (xmin.gt.xminact) then
19224 if (ymin.gt.yminact) then
19228 if (zmin.gt.zminact) then
19237 !C write(iout,*), "tututu", vectube(1),tubecenter(1),vectube(2),
19239 vectube(1)=vectube(1)-tubecenter(1)
19240 vectube(2)=vectube(2)-tubecenter(2)
19241 vectube(3)=vectube(3)-tubecenter(3)
19242 !C now calculte the distance
19243 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
19244 !C now normalize vector
19245 vectube(1)=vectube(1)/tub_r
19246 vectube(2)=vectube(2)/tub_r
19247 vectube(3)=vectube(3)/tub_r
19249 !C calculte rdiffrence between r and r0
19252 rdiff6=rdiff**6.0d0
19253 sc_aa_tube=sc_aa_tube_par(iti)
19254 sc_bb_tube=sc_bb_tube_par(iti)
19255 enetube(i+nres)=sc_aa_tube/rdiff6**2.0d0+sc_bb_tube/rdiff6
19256 !C enetube(i+nres)=0.0d0
19257 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
19258 !C now we calculate gradient
19259 fac=-12.0d0*sc_aa_tube/rdiff6**2.0d0/rdiff- &
19260 6.0d0*sc_bb_tube/rdiff6/rdiff
19262 !C now direction of gg_tube vector
19263 !C Now cavity term E=a(x+bsqrt(x)+c)/(1+dx^12)
19264 if (acavtub(iti).eq.0.0d0) then
19266 enecavtube(i+nres)=0.0d0
19269 denominator=(1.0d0+dcavtub(iti)*rdiff6*rdiff6)
19270 enecavtube(i+nres)= &
19271 (bcavtub(iti)*rdiff+acavtub(iti)*dsqrt(rdiff)+ccavtub(iti)) &
19273 !C enecavtube(i)=0.0
19274 faccav=((bcavtub(iti)*1.0d0+acavtub(iti)/2.0d0/dsqrt(rdiff)) &
19275 *denominator-(bcavtub(iti)*rdiff+acavtub(iti)*dsqrt(rdiff) &
19276 +ccavtub(iti))*rdiff6**2.0d0/rdiff*dcavtub(iti)*12.0d0) &
19277 /denominator**2.0d0
19282 !C print *,"TUT",i,iti,rdiff,rdiff6,acavtub(iti),denominator,
19283 !C & enecavtube(i),faccav
19284 !C print *,"licz=",
19285 !C & (bcavtub(iti)*rdiff+acavtub(iti)*sqrt(rdiff)+ccavtub(iti))
19286 !C print *,"finene=",enetube(i+nres)+enecavtube(i)
19288 gg_tube_SC(j,i)=gg_tube_SC(j,i)+vectube(j)*fac
19289 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac
19291 if (energy_dec) write(iout,*),i,rdiff,enetube(i+nres),enecavtube(i+nres)
19296 do i=itube_start,itube_end
19297 Etube=Etube+enetube(i)+enetube(i+nres)+enecavtube(i) &
19298 +enecavtube(i+nres)
19301 ! print *,"begin", i,"a"
19304 ! rdiff6=rdiff**6.0d0
19305 ! sc_aa_tube=sc_aa_tube_par(i)
19306 ! sc_bb_tube=sc_bb_tube_par(i)
19307 ! enetube(i)=sc_aa_tube/rdiff6**2.0d0+sc_bb_tube/rdiff6
19308 ! denominator=(1.0d0+dcavtub(i)*rdiff6*rdiff6)
19310 ! (bcavtub(i)*rdiff+acavtub(i)*dsqrt(rdiff)+ccavtub(i)) &
19313 ! print '(5(f10.3,1x))',rdiff,enetube(i),enecavtube(i),enecavtube(i)+enetube(i)
19315 ! print *,"end",i,"a"
19317 !C print *,"ETUBE", etube
19319 end subroutine calcnano
19321 !===============================================
19322 !--------------------------------------------------------------------------------
19323 !C first for shielding is setting of function of side-chains
19325 subroutine set_shield_fac2
19326 real(kind=8) :: div77_81=0.974996043d0, &
19327 div4_81=0.2222222222d0
19328 real (kind=8) :: dist_pep_side,dist_side_calf,dist_pept_group, &
19329 scale_fac_dist,fac_help_scale,VofOverlap,VolumeTotal,costhet,&
19330 short,long,sinthet,costhet_fac,sh_frac_dist,rkprim,cosphi, &
19331 sinphi,cosphi_fac,pep_side0pept_group,cosalfa,fac_alfa_sin
19332 !C the vector between center of side_chain and peptide group
19333 real(kind=8),dimension(3) :: pep_side_long,side_calf, &
19334 pept_group,costhet_grad,cosphi_grad_long, &
19335 cosphi_grad_loc,pep_side_norm,side_calf_norm, &
19336 sh_frac_dist_grad,pep_side
19338 !C write(2,*) "ivec",ivec_start,ivec_end
19340 fac_shield(i)=0.0d0
19342 grad_shield(j,i)=0.0d0
19345 do i=ivec_start,ivec_end
19347 !C if ((itype(i,1).eq.ntyp1).and.itype(i+1,1).eq.ntyp1) cycle
19349 if ((itype(i,1).eq.ntyp1).and.itype(i+1,1).eq.ntyp1) cycle
19350 !Cif there two consequtive dummy atoms there is no peptide group between them
19351 !C the line below has to be changed for FGPROC>1
19354 if ((itype(k,1).eq.ntyp1).or.(itype(k,1).eq.10)) cycle
19358 !C first lets set vector conecting the ithe side-chain with kth side-chain
19359 pep_side(j)=c(j,k+nres)-(c(j,i)+c(j,i+1))/2.0d0
19360 !C pep_side(j)=2.0d0
19361 !C and vector conecting the side-chain with its proper calfa
19362 side_calf(j)=c(j,k+nres)-c(j,k)
19363 !C side_calf(j)=2.0d0
19364 pept_group(j)=c(j,i)-c(j,i+1)
19365 !C lets have their lenght
19366 dist_pep_side=pep_side(j)**2+dist_pep_side
19367 dist_side_calf=dist_side_calf+side_calf(j)**2
19368 dist_pept_group=dist_pept_group+pept_group(j)**2
19370 dist_pep_side=sqrt(dist_pep_side)
19371 dist_pept_group=sqrt(dist_pept_group)
19372 dist_side_calf=sqrt(dist_side_calf)
19374 pep_side_norm(j)=pep_side(j)/dist_pep_side
19375 side_calf_norm(j)=dist_side_calf
19377 !C now sscale fraction
19378 sh_frac_dist=-(dist_pep_side-rpp(1,1)-buff_shield)/buff_shield
19379 !C print *,buff_shield,"buff"
19381 if (sh_frac_dist.le.0.0) cycle
19382 !C print *,ishield_list(i),i
19383 !C If we reach here it means that this side chain reaches the shielding sphere
19384 !C Lets add him to the list for gradient
19385 ishield_list(i)=ishield_list(i)+1
19386 !C ishield_list is a list of non 0 side-chain that contribute to factor gradient
19387 !C this list is essential otherwise problem would be O3
19388 shield_list(ishield_list(i),i)=k
19389 !C Lets have the sscale value
19390 if (sh_frac_dist.gt.1.0) then
19391 scale_fac_dist=1.0d0
19393 sh_frac_dist_grad(j)=0.0d0
19396 scale_fac_dist=-sh_frac_dist*sh_frac_dist &
19397 *(2.0d0*sh_frac_dist-3.0d0)
19398 fac_help_scale=6.0d0*(sh_frac_dist-sh_frac_dist**2) &
19399 /dist_pep_side/buff_shield*0.5d0
19401 sh_frac_dist_grad(j)=fac_help_scale*pep_side(j)
19402 !C sh_frac_dist_grad(j)=0.0d0
19403 !C scale_fac_dist=1.0d0
19404 !C print *,"jestem",scale_fac_dist,fac_help_scale,
19405 !C & sh_frac_dist_grad(j)
19408 !C this is what is now we have the distance scaling now volume...
19409 short=short_r_sidechain(itype(k,1))
19410 long=long_r_sidechain(itype(k,1))
19411 costhet=1.0d0/dsqrt(1.0d0+short**2/dist_pep_side**2)
19412 sinthet=short/dist_pep_side*costhet
19413 !C now costhet_grad
19416 costhet_fac=costhet**3*short**2*(-0.5d0)/dist_pep_side**4
19417 !C sinthet_fac=costhet**2*0.5d0*(short**3/dist_pep_side**4*costhet
19418 !C & -short/dist_pep_side**2/costhet)
19419 !C costhet_fac=0.0d0
19421 costhet_grad(j)=costhet_fac*pep_side(j)
19423 !C remember for the final gradient multiply costhet_grad(j)
19424 !C for side_chain by factor -2 !
19425 !C fac alfa is angle between CB_k,CA_k, CA_i,CA_i+1
19426 !C pep_side0pept_group is vector multiplication
19427 pep_side0pept_group=0.0d0
19429 pep_side0pept_group=pep_side0pept_group+pep_side(j)*side_calf(j)
19431 cosalfa=(pep_side0pept_group/ &
19432 (dist_pep_side*dist_side_calf))
19433 fac_alfa_sin=1.0d0-cosalfa**2
19434 fac_alfa_sin=dsqrt(fac_alfa_sin)
19435 rkprim=fac_alfa_sin*(long-short)+short
19438 !C now costhet_grad
19439 cosphi=1.0d0/dsqrt(1.0d0+rkprim**2/dist_pep_side**2)
19441 cosphi_fac=cosphi**3*rkprim**2*(-0.5d0)/dist_pep_side**4
19442 sinphi=rkprim/dist_pep_side/dsqrt(1.0d0+rkprim**2/ &
19446 cosphi_grad_long(j)=cosphi_fac*pep_side(j) &
19447 +cosphi**3*0.5d0/dist_pep_side**2*(-rkprim) &
19448 *(long-short)/fac_alfa_sin*cosalfa/ &
19449 ((dist_pep_side*dist_side_calf))* &
19450 ((side_calf(j))-cosalfa* &
19451 ((pep_side(j)/dist_pep_side)*dist_side_calf))
19452 !C cosphi_grad_long(j)=0.0d0
19453 cosphi_grad_loc(j)=cosphi**3*0.5d0/dist_pep_side**2*(-rkprim) &
19454 *(long-short)/fac_alfa_sin*cosalfa &
19455 /((dist_pep_side*dist_side_calf))* &
19457 cosalfa*side_calf(j)/dist_side_calf*dist_pep_side)
19458 !C cosphi_grad_loc(j)=0.0d0
19460 !C print *,sinphi,sinthet
19461 VofOverlap=VSolvSphere/2.0d0*(1.0d0-dsqrt(1.0d0-sinphi*sinthet)) &
19464 !C now the gradient...
19466 grad_shield(j,i)=grad_shield(j,i) &
19467 !C gradient po skalowaniu
19468 +(sh_frac_dist_grad(j)*VofOverlap &
19469 !C gradient po costhet
19470 +scale_fac_dist*VSolvSphere/VSolvSphere_div/4.0d0* &
19471 (1.0d0/(-dsqrt(1.0d0-sinphi*sinthet))*( &
19472 sinphi/sinthet*costhet*costhet_grad(j) &
19473 +sinthet/sinphi*cosphi*cosphi_grad_long(j))) &
19475 !C grad_shield_side is Cbeta sidechain gradient
19476 grad_shield_side(j,ishield_list(i),i)=&
19477 (sh_frac_dist_grad(j)*-2.0d0&
19479 -scale_fac_dist*VSolvSphere/VSolvSphere_div/2.0d0*&
19480 (1.0d0/(-dsqrt(1.0d0-sinphi*sinthet))*(&
19481 sinphi/sinthet*costhet*costhet_grad(j)&
19482 +sinthet/sinphi*cosphi*cosphi_grad_long(j))) &
19485 grad_shield_loc(j,ishield_list(i),i)= &
19486 scale_fac_dist*VSolvSphere/VSolvSphere_div/2.0d0*&
19487 (1.0d0/(dsqrt(1.0d0-sinphi*sinthet))*(&
19488 sinthet/sinphi*cosphi*cosphi_grad_loc(j)&
19492 VolumeTotal=VolumeTotal+VofOverlap*scale_fac_dist
19494 fac_shield(i)=VolumeTotal*wshield+(1.0d0-wshield)
19496 !C write(2,*) "TOTAL VOLUME",i,itype(i,1),fac_shield(i)
19499 end subroutine set_shield_fac2
19500 !----------------------------------------------------------------------------
19501 ! SOUBROUTINE FOR AFM
19502 subroutine AFMvel(Eafmforce)
19503 use MD_data, only:totTafm
19504 real(kind=8),dimension(3) :: diffafm
19505 real(kind=8) :: afmdist,Eafmforce
19507 !C Only for check grad COMMENT if not used for checkgrad
19509 !C--------------------------------------------------------
19510 !C print *,"wchodze"
19514 diffafm(i)=c(i,afmend)-c(i,afmbeg)
19515 afmdist=afmdist+diffafm(i)**2
19517 afmdist=dsqrt(afmdist)
19519 Eafmforce=0.5d0*forceAFMconst &
19520 *(distafminit+totTafm*velAFMconst-afmdist)**2
19521 !C Eafmforce=-forceAFMconst*(dist-distafminit)
19523 gradafm(i,afmend-1)=-forceAFMconst* &
19524 (distafminit+totTafm*velAFMconst-afmdist) &
19525 *diffafm(i)/afmdist
19526 gradafm(i,afmbeg-1)=forceAFMconst* &
19527 (distafminit+totTafm*velAFMconst-afmdist) &
19528 *diffafm(i)/afmdist
19530 ! print *,'AFM',Eafmforce,totTafm*velAFMconst,afmdist
19532 end subroutine AFMvel
19533 !---------------------------------------------------------
19534 subroutine AFMforce(Eafmforce)
19536 real(kind=8),dimension(3) :: diffafm
19537 ! real(kind=8) ::afmdist
19538 real(kind=8) :: afmdist,Eafmforce
19543 diffafm(i)=c(i,afmend)-c(i,afmbeg)
19544 afmdist=afmdist+diffafm(i)**2
19546 afmdist=dsqrt(afmdist)
19547 ! print *,afmdist,distafminit
19548 Eafmforce=-forceAFMconst*(afmdist-distafminit)
19550 gradafm(i,afmend-1)=-forceAFMconst*diffafm(i)/afmdist
19551 gradafm(i,afmbeg-1)=forceAFMconst*diffafm(i)/afmdist
19553 !C print *,'AFM',Eafmforce
19555 end subroutine AFMforce
19557 !-----------------------------------------------------------------------------
19559 subroutine read_ssHist
19562 ! include 'DIMENSIONS'
19563 ! include "DIMENSIONS.FREE"
19564 ! include 'COMMON.FREE'
19567 character(len=80) :: controlcard
19570 call card_concat(controlcard,.true.)
19571 read(controlcard,*) &
19572 dyn_ssHist(i,0),(dyn_ssHist(i,j),j=1,2*dyn_ssHist(i,0))
19576 end subroutine read_ssHist
19578 !-----------------------------------------------------------------------------
19579 integer function indmat(i,j)
19581 ! get the position of the jth ijth fragment of the chain coordinate system
19582 ! in the fromto array.
19585 indmat=((2*(nres-2)-i)*(i-1))/2+j-1
19587 end function indmat
19588 !-----------------------------------------------------------------------------
19589 real(kind=8) function sigm(x)
19595 !-----------------------------------------------------------------------------
19596 !-----------------------------------------------------------------------------
19597 subroutine alloc_ener_arrays
19598 !EL Allocation of arrays used by module energy
19599 use MD_data, only: mset
19600 !el local variables
19603 if(nres.lt.100) then
19605 elseif(nres.lt.200) then
19606 maxconts=0.8*nres ! Max. number of contacts per residue
19608 maxconts=0.6*nres ! (maxconts=maxres/4)
19610 maxcont=12*nres ! Max. number of SC contacts
19611 maxvar=6*nres ! Max. number of variables
19612 !el maxdim=(nres-1)*(nres-2)/2 ! Max. number of derivatives of virtual-bond
19613 maxdim=nres*(nres-2)/2 ! Max. number of derivatives of virtual-bond
19614 !----------------------
19615 ! arrays in subroutine init_int_table
19617 !el allocate(itask_cont_from(0:nfgtasks-1)) !(0:max_fg_procs-1)
19618 !el allocate(itask_cont_to(0:nfgtasks-1)) !(0:max_fg_procs-1)
19620 allocate(nint_gr(nres))
19621 allocate(nscp_gr(nres))
19622 allocate(ielstart(nres))
19623 allocate(ielend(nres))
19625 allocate(istart(nres,maxint_gr))
19626 allocate(iend(nres,maxint_gr))
19627 !(maxres,maxint_gr)
19628 allocate(iscpstart(nres,maxint_gr))
19629 allocate(iscpend(nres,maxint_gr))
19630 !(maxres,maxint_gr)
19631 allocate(ielstart_vdw(nres))
19632 allocate(ielend_vdw(nres))
19634 allocate(nint_gr_nucl(nres))
19635 allocate(nscp_gr_nucl(nres))
19636 allocate(ielstart_nucl(nres))
19637 allocate(ielend_nucl(nres))
19639 allocate(istart_nucl(nres,maxint_gr))
19640 allocate(iend_nucl(nres,maxint_gr))
19641 !(maxres,maxint_gr)
19642 allocate(iscpstart_nucl(nres,maxint_gr))
19643 allocate(iscpend_nucl(nres,maxint_gr))
19644 !(maxres,maxint_gr)
19645 allocate(ielstart_vdw_nucl(nres))
19646 allocate(ielend_vdw_nucl(nres))
19648 allocate(lentyp(0:nfgtasks-1))
19650 !----------------------
19652 ! common /contacts/
19653 if(.not.allocated(icont_ref)) allocate(icont_ref(2,maxcont))
19654 allocate(icont(2,maxcont))
19656 ! common /contacts1/
19657 allocate(num_cont(0:nres+4))
19659 allocate(jcont(maxconts,nres))
19661 allocate(facont(maxconts,nres))
19663 allocate(gacont(3,maxconts,nres))
19664 !(3,maxconts,maxres)
19665 ! common /contacts_hb/
19666 allocate(gacontp_hb1(3,maxconts,nres))
19667 allocate(gacontp_hb2(3,maxconts,nres))
19668 allocate(gacontp_hb3(3,maxconts,nres))
19669 allocate(gacontm_hb1(3,maxconts,nres))
19670 allocate(gacontm_hb2(3,maxconts,nres))
19671 allocate(gacontm_hb3(3,maxconts,nres))
19672 allocate(gacont_hbr(3,maxconts,nres))
19673 allocate(grij_hb_cont(3,maxconts,nres))
19674 !(3,maxconts,maxres)
19675 allocate(facont_hb(maxconts,nres))
19677 allocate(ees0p(maxconts,nres))
19678 allocate(ees0m(maxconts,nres))
19679 allocate(d_cont(maxconts,nres))
19680 allocate(ees0plist(maxconts,nres))
19683 allocate(num_cont_hb(nres))
19685 allocate(jcont_hb(maxconts,nres))
19688 allocate(Ug(2,2,nres))
19689 allocate(Ugder(2,2,nres))
19690 allocate(Ug2(2,2,nres))
19691 allocate(Ug2der(2,2,nres))
19693 allocate(obrot(2,nres))
19694 allocate(obrot2(2,nres))
19695 allocate(obrot_der(2,nres))
19696 allocate(obrot2_der(2,nres))
19698 ! common /precomp1/
19699 allocate(mu(2,nres))
19700 allocate(muder(2,nres))
19701 allocate(Ub2(2,nres))
19704 allocate(Ub2der(2,nres))
19705 allocate(Ctobr(2,nres))
19706 allocate(Ctobrder(2,nres))
19707 allocate(Dtobr2(2,nres))
19708 allocate(Dtobr2der(2,nres))
19710 allocate(EUg(2,2,nres))
19711 allocate(EUgder(2,2,nres))
19712 allocate(CUg(2,2,nres))
19713 allocate(CUgder(2,2,nres))
19714 allocate(DUg(2,2,nres))
19715 allocate(Dugder(2,2,nres))
19716 allocate(DtUg2(2,2,nres))
19717 allocate(DtUg2der(2,2,nres))
19719 ! common /precomp2/
19720 allocate(Ug2Db1t(2,nres))
19721 allocate(Ug2Db1tder(2,nres))
19722 allocate(CUgb2(2,nres))
19723 allocate(CUgb2der(2,nres))
19725 allocate(EUgC(2,2,nres))
19726 allocate(EUgCder(2,2,nres))
19727 allocate(EUgD(2,2,nres))
19728 allocate(EUgDder(2,2,nres))
19729 allocate(DtUg2EUg(2,2,nres))
19730 allocate(Ug2DtEUg(2,2,nres))
19732 allocate(Ug2DtEUgder(2,2,2,nres))
19733 allocate(DtUg2EUgder(2,2,2,nres))
19735 ! common /rotat_old/
19736 allocate(costab(nres))
19737 allocate(sintab(nres))
19738 allocate(costab2(nres))
19739 allocate(sintab2(nres))
19742 allocate(a_chuj(2,2,maxconts,nres))
19743 !(2,2,maxconts,maxres)(maxconts=maxres/4)
19744 allocate(a_chuj_der(2,2,3,5,maxconts,nres))
19745 !(2,2,3,5,maxconts,maxres)(maxconts=maxres/4)
19746 ! common /contdistrib/
19747 allocate(ncont_sent(nres))
19748 allocate(ncont_recv(nres))
19750 allocate(iat_sent(nres))
19752 allocate(iint_sent(4,nres,nres))
19753 allocate(iint_sent_local(4,nres,nres))
19755 allocate(iturn3_sent(4,0:nres+4))
19756 allocate(iturn4_sent(4,0:nres+4))
19757 allocate(iturn3_sent_local(4,nres))
19758 allocate(iturn4_sent_local(4,nres))
19760 allocate(itask_cont_from(0:nfgtasks-1))
19761 allocate(itask_cont_to(0:nfgtasks-1))
19762 !(0:max_fg_procs-1)
19766 !----------------------
19769 allocate(dcdv(6,maxdim))
19770 allocate(dxdv(6,maxdim))
19772 allocate(dxds(6,nres))
19774 allocate(gradx(3,-1:nres,0:2))
19775 allocate(gradc(3,-1:nres,0:2))
19777 allocate(gvdwx(3,-1:nres))
19778 allocate(gvdwc(3,-1:nres))
19779 allocate(gelc(3,-1:nres))
19780 allocate(gelc_long(3,-1:nres))
19781 allocate(gvdwpp(3,-1:nres))
19782 allocate(gvdwc_scpp(3,-1:nres))
19783 allocate(gradx_scp(3,-1:nres))
19784 allocate(gvdwc_scp(3,-1:nres))
19785 allocate(ghpbx(3,-1:nres))
19786 allocate(ghpbc(3,-1:nres))
19787 allocate(gradcorr(3,-1:nres))
19788 allocate(gradcorr_long(3,-1:nres))
19789 allocate(gradcorr5_long(3,-1:nres))
19790 allocate(gradcorr6_long(3,-1:nres))
19791 allocate(gcorr6_turn_long(3,-1:nres))
19792 allocate(gradxorr(3,-1:nres))
19793 allocate(gradcorr5(3,-1:nres))
19794 allocate(gradcorr6(3,-1:nres))
19795 allocate(gliptran(3,-1:nres))
19796 allocate(gliptranc(3,-1:nres))
19797 allocate(gliptranx(3,-1:nres))
19798 allocate(gshieldx(3,-1:nres))
19799 allocate(gshieldc(3,-1:nres))
19800 allocate(gshieldc_loc(3,-1:nres))
19801 allocate(gshieldx_ec(3,-1:nres))
19802 allocate(gshieldc_ec(3,-1:nres))
19803 allocate(gshieldc_loc_ec(3,-1:nres))
19804 allocate(gshieldx_t3(3,-1:nres))
19805 allocate(gshieldc_t3(3,-1:nres))
19806 allocate(gshieldc_loc_t3(3,-1:nres))
19807 allocate(gshieldx_t4(3,-1:nres))
19808 allocate(gshieldc_t4(3,-1:nres))
19809 allocate(gshieldc_loc_t4(3,-1:nres))
19810 allocate(gshieldx_ll(3,-1:nres))
19811 allocate(gshieldc_ll(3,-1:nres))
19812 allocate(gshieldc_loc_ll(3,-1:nres))
19813 allocate(grad_shield(3,-1:nres))
19814 allocate(gg_tube_sc(3,-1:nres))
19815 allocate(gg_tube(3,-1:nres))
19816 allocate(gradafm(3,-1:nres))
19817 allocate(gradb_nucl(3,-1:nres))
19818 allocate(gradbx_nucl(3,-1:nres))
19819 allocate(gvdwpsb1(3,-1:nres))
19820 allocate(gelpp(3,-1:nres))
19821 allocate(gvdwpsb(3,-1:nres))
19822 allocate(gelsbc(3,-1:nres))
19823 allocate(gelsbx(3,-1:nres))
19824 allocate(gvdwsbx(3,-1:nres))
19825 allocate(gvdwsbc(3,-1:nres))
19826 allocate(gsbloc(3,-1:nres))
19827 allocate(gsblocx(3,-1:nres))
19828 allocate(gradcorr_nucl(3,-1:nres))
19829 allocate(gradxorr_nucl(3,-1:nres))
19830 allocate(gradcorr3_nucl(3,-1:nres))
19831 allocate(gradxorr3_nucl(3,-1:nres))
19832 allocate(gvdwpp_nucl(3,-1:nres))
19833 allocate(gradpepcat(3,-1:nres))
19834 allocate(gradpepcatx(3,-1:nres))
19835 allocate(gradcatcat(3,-1:nres))
19837 allocate(grad_shield_side(3,50,nres))
19838 allocate(grad_shield_loc(3,50,nres))
19839 ! grad for shielding surroing
19840 allocate(gloc(0:maxvar,0:2))
19841 allocate(gloc_x(0:maxvar,2))
19843 allocate(gel_loc(3,-1:nres))
19844 allocate(gel_loc_long(3,-1:nres))
19845 allocate(gcorr3_turn(3,-1:nres))
19846 allocate(gcorr4_turn(3,-1:nres))
19847 allocate(gcorr6_turn(3,-1:nres))
19848 allocate(gradb(3,-1:nres))
19849 allocate(gradbx(3,-1:nres))
19851 allocate(gel_loc_loc(maxvar))
19852 allocate(gel_loc_turn3(maxvar))
19853 allocate(gel_loc_turn4(maxvar))
19854 allocate(gel_loc_turn6(maxvar))
19855 allocate(gcorr_loc(maxvar))
19856 allocate(g_corr5_loc(maxvar))
19857 allocate(g_corr6_loc(maxvar))
19859 allocate(gsccorc(3,-1:nres))
19860 allocate(gsccorx(3,-1:nres))
19862 allocate(gsccor_loc(-1:nres))
19864 allocate(gvdwx_scbase(3,-1:nres))
19865 allocate(gvdwc_scbase(3,-1:nres))
19866 allocate(gvdwx_pepbase(3,-1:nres))
19867 allocate(gvdwc_pepbase(3,-1:nres))
19868 allocate(gvdwx_scpho(3,-1:nres))
19869 allocate(gvdwc_scpho(3,-1:nres))
19870 allocate(gvdwc_peppho(3,-1:nres))
19872 allocate(dtheta(3,2,-1:nres))
19874 allocate(gscloc(3,-1:nres))
19875 allocate(gsclocx(3,-1:nres))
19877 allocate(dphi(3,3,-1:nres))
19878 allocate(dalpha(3,3,-1:nres))
19879 allocate(domega(3,3,-1:nres))
19881 ! common /deriv_scloc/
19882 allocate(dXX_C1tab(3,nres))
19883 allocate(dYY_C1tab(3,nres))
19884 allocate(dZZ_C1tab(3,nres))
19885 allocate(dXX_Ctab(3,nres))
19886 allocate(dYY_Ctab(3,nres))
19887 allocate(dZZ_Ctab(3,nres))
19888 allocate(dXX_XYZtab(3,nres))
19889 allocate(dYY_XYZtab(3,nres))
19890 allocate(dZZ_XYZtab(3,nres))
19893 allocate(jgrad_start(nres))
19894 allocate(jgrad_end(nres))
19896 !----------------------
19899 allocate(ibond_displ(0:nfgtasks-1))
19900 allocate(ibond_count(0:nfgtasks-1))
19901 allocate(ithet_displ(0:nfgtasks-1))
19902 allocate(ithet_count(0:nfgtasks-1))
19903 allocate(iphi_displ(0:nfgtasks-1))
19904 allocate(iphi_count(0:nfgtasks-1))
19905 allocate(iphi1_displ(0:nfgtasks-1))
19906 allocate(iphi1_count(0:nfgtasks-1))
19907 allocate(ivec_displ(0:nfgtasks-1))
19908 allocate(ivec_count(0:nfgtasks-1))
19909 allocate(iset_displ(0:nfgtasks-1))
19910 allocate(iset_count(0:nfgtasks-1))
19911 allocate(iint_count(0:nfgtasks-1))
19912 allocate(iint_displ(0:nfgtasks-1))
19913 !(0:max_fg_procs-1)
19914 !----------------------
19917 allocate(gcart(3,-1:nres))
19918 allocate(gxcart(3,-1:nres))
19920 allocate(gradcag(3,-1:nres))
19921 allocate(gradxag(3,-1:nres))
19923 ! common /back_constr/
19924 !el in energy:Econstr_back allocate((:),allocatable :: utheta,ugamma,uscdiff !(maxfrag_back)
19925 allocate(dutheta(nres))
19926 allocate(dugamma(nres))
19928 allocate(duscdiff(3,nres))
19929 allocate(duscdiffx(3,nres))
19931 !el i io:read_fragments
19932 ! allocate((:,:,:),allocatable :: wfrag_back !(3,maxfrag_back,maxprocs/20)
19933 ! allocate((:,:,:),allocatable :: ifrag_back !(3,maxfrag_back,maxprocs/20)
19935 ! allocate(qinfrag(50,nprocs/20),wfrag(50,nprocs/20)) !(50,maxprocs/20)
19936 ! allocate(qinpair(100,nprocs/20),wpair(100,nprocs/20)) !(100,maxprocs/20)
19937 allocate(mset(0:nprocs)) !(maxprocs/20)
19939 ! allocate(ifrag(2,50,nprocs/20)) !(2,50,maxprocs/20)
19940 ! allocate(ipair(2,100,nprocs/20)) !(2,100,maxprocs/20)
19941 allocate(dUdconst(3,0:nres))
19942 allocate(dUdxconst(3,0:nres))
19943 allocate(dqwol(3,0:nres))
19944 allocate(dxqwol(3,0:nres))
19946 !----------------------
19948 ! common /sbridge/ in io_common: read_bridge
19949 !el allocate((:),allocatable :: iss !(maxss)
19950 ! common /links/ in io_common: read_bridge
19951 !el real(kind=8),dimension(:),allocatable :: dhpb,forcon,dhpb1 !(maxdim) !el dhpb1 !!! nie używane
19952 !el integer,dimension(:),allocatable :: ihpb,jhpb,ibecarb !(maxdim) !el ibecarb !!! nie używane
19953 ! common /dyn_ssbond/
19954 ! and side-chain vectors in theta or phi.
19955 allocate(dyn_ssbond_ij(0:nres+4,0:nres+4))
19959 dyn_ssbond_ij(:,:)=1.0d300
19963 ! if (nss.gt.0) then
19964 allocate(idssb(maxdim),jdssb(maxdim))
19965 ! allocate(newihpb(nss),newjhpb(nss))
19968 allocate(ishield_list(nres))
19969 allocate(shield_list(50,nres))
19970 allocate(dyn_ss_mask(nres))
19971 allocate(fac_shield(nres))
19972 allocate(enetube(nres*2))
19973 allocate(enecavtube(nres*2))
19976 dyn_ss_mask(:)=.false.
19977 !----------------------
19979 ! Parameters of the SCCOR term
19981 !el in io_conf: parmread
19982 ! allocate(v1sccor(maxterm_sccor,3,-ntyp:ntyp,-ntyp:ntyp))
19983 ! allocate(v2sccor(maxterm_sccor,3,-ntyp:ntyp,-ntyp:ntyp)) !(maxterm_sccor,3,-ntyp:ntyp,-ntyp:ntyp)
19984 ! allocate(v0sccor(maxterm_sccor,-ntyp:ntyp,-ntyp:ntyp)) !(maxterm_sccor,-ntyp:ntyp,-ntyp:ntyp)
19985 ! allocate(isccortyp(-ntyp:ntyp)) !(-ntyp:ntyp)
19986 ! allocate(nterm_sccor(-ntyp:ntyp,-ntyp:ntyp))
19987 ! allocate(nlor_sccor(-ntyp:ntyp,-ntyp:ntyp)) !(-ntyp:ntyp,-ntyp:ntyp)
19988 ! allocate(vlor1sccor(maxterm_sccor,20,20))
19989 ! allocate(vlor2sccor(maxterm_sccor,20,20))
19990 ! allocate(vlor3sccor(maxterm_sccor,20,20)) !(maxterm_sccor,20,20)
19992 allocate(gloc_sc(3,0:2*nres,0:10))
19993 !(3,0:maxres2,10)maxres2=2*maxres
19994 allocate(dcostau(3,3,3,2*nres))
19995 allocate(dsintau(3,3,3,2*nres))
19996 allocate(dtauangle(3,3,3,2*nres))
19997 allocate(dcosomicron(3,3,3,2*nres))
19998 allocate(domicron(3,3,3,2*nres))
19999 !(3,3,3,maxres2)maxres2=2*maxres
20000 !----------------------
20003 allocate(varall(maxvar))
20004 !(maxvar)(maxvar=6*maxres)
20005 allocate(mask_theta(nres))
20006 allocate(mask_phi(nres))
20007 allocate(mask_side(nres))
20009 !----------------------
20012 allocate(uy(3,nres))
20013 allocate(uz(3,nres))
20015 allocate(uygrad(3,3,2,nres))
20016 allocate(uzgrad(3,3,2,nres))
20020 end subroutine alloc_ener_arrays
20021 !-----------------------------------------------------------------
20022 subroutine ebond_nucl(estr_nucl)
20024 !c Evaluate the energy of stretching of the CA-CA and CA-SC virtual bonds
20027 real(kind=8),dimension(3) :: u,ud
20028 real(kind=8) :: usum,uprod,uprod1,uprod2,usumsqder
20029 real(kind=8) :: estr_nucl,diff
20030 integer :: iti,i,j,k,nbi
20032 !C print *,"I enter ebond"
20034 write (iout,*) "ibondp_start,ibondp_end",&
20035 ibondp_nucl_start,ibondp_nucl_end
20036 do i=ibondp_nucl_start,ibondp_nucl_end
20037 if (itype(i-1,2).eq.ntyp1_molec(2) .or. &
20038 itype(i,2).eq.ntyp1_molec(2)) cycle
20039 ! estr1=estr1+gnmr1(vbld(i),-1.0d0,distchainmax)
20041 ! gradb(j,i-1)=gnmr1prim(vbld(i),-1.0d0,distchainmax)
20042 ! & *dc(j,i-1)/vbld(i)
20044 ! if (energy_dec) write(iout,*)
20045 ! & "estr1",i,vbld(i),distchainmax,
20046 ! & gnmr1(vbld(i),-1.0d0,distchainmax)
20048 diff = vbld(i)-vbldp0_nucl
20049 if(energy_dec)write(iout,*) "estr_nucl_bb" , i,vbld(i),&
20050 vbldp0_nucl,diff,AKP_nucl*diff*diff
20051 estr_nucl=estr_nucl+diff*diff
20052 ! print *,estr_nucl
20054 gradb_nucl(j,i-1)=AKP_nucl*diff*dc(j,i-1)/vbld(i)
20056 !c write (iout,'(i5,3f10.5)') i,(gradb(j,i-1),j=1,3)
20058 estr_nucl=0.5d0*AKP_nucl*estr_nucl
20059 ! print *,"partial sum", estr_nucl,AKP_nucl
20062 write (iout,*) "ibondp_start,ibondp_end",&
20063 ibond_nucl_start,ibond_nucl_end
20065 do i=ibond_nucl_start,ibond_nucl_end
20066 !C print *, "I am stuck",i
20068 if (iti.eq.ntyp1_molec(2)) cycle
20069 nbi=nbondterm_nucl(iti)
20072 diff=vbld(i+nres)-vbldsc0_nucl(1,iti)
20075 write (iout,*) "estr_nucl_sc", i,iti,vbld(i+nres),vbldsc0_nucl(1,iti),diff, &
20076 AKSC_nucl(1,iti),AKSC_nucl(1,iti)*diff*diff
20077 estr_nucl=estr_nucl+0.5d0*AKSC_nucl(1,iti)*diff*diff
20078 ! print *,estr_nucl
20080 gradbx_nucl(j,i)=AKSC_nucl(1,iti)*diff*dc(j,i+nres)/vbld(i+nres)
20084 diff=vbld(i+nres)-vbldsc0_nucl(j,iti)
20085 ud(j)=aksc_nucl(j,iti)*diff
20086 u(j)=abond0_nucl(j,iti)+0.5d0*ud(j)*diff
20100 uprod2=uprod2*u(k)*u(k)
20104 usumsqder=usumsqder+ud(j)*uprod2
20106 estr_nucl=estr_nucl+uprod/usum
20108 gradbx_nucl(j,i)=usumsqder/(usum*usum)*dc(j,i+nres)/vbld(i+nres)
20112 !C print *,"I am about to leave ebond"
20114 end subroutine ebond_nucl
20116 !-----------------------------------------------------------------------------
20117 subroutine ebend_nucl(etheta_nucl)
20118 real(kind=8),dimension(nntheterm_nucl+1) :: coskt,sinkt !mmaxtheterm
20119 real(kind=8),dimension(nsingle_nucl+1) :: cosph1,sinph1,cosph2,sinph2 !maxsingle
20120 real(kind=8),dimension(ndouble_nucl+1,ndouble_nucl+1) :: cosph1ph2,sinph1ph2 !maxdouble,maxdouble
20121 logical :: lprn=.false., lprn1=.false.
20122 !el local variables
20123 integer :: i,k,iblock,ityp1,ityp2,ityp3,l,m
20124 real(kind=8) :: dethetai,dephii,dephii1,theti2,phii,phii1,ethetai
20125 real(kind=8) :: aux,etheta_nucl,ccl,ssl,scl,csl,ethetacnstr
20126 ! local variables for constrains
20127 real(kind=8) :: difi,thetiii
20130 ! print *,"ithet_start",ithet_nucl_start," ithet_end",ithet_nucl_end,nres
20131 do i=ithet_nucl_start,ithet_nucl_end
20132 if ((itype(i-1,2).eq.ntyp1_molec(2)).or.&
20133 (itype(i-2,2).eq.ntyp1_molec(2)).or. &
20134 (itype(i,2).eq.ntyp1_molec(2))) cycle
20138 theti2=0.5d0*theta(i)
20139 ityp2=ithetyp_nucl(itype(i-1,2))
20140 do k=1,nntheterm_nucl
20141 coskt(k)=dcos(k*theti2)
20142 sinkt(k)=dsin(k*theti2)
20144 if (i.gt.3 .and. itype(i-2,2).ne.ntyp1_molec(2)) then
20147 if (phii.ne.phii) phii=150.0
20151 ityp1=ithetyp_nucl(itype(i-2,2))
20152 do k=1,nsingle_nucl
20153 cosph1(k)=dcos(k*phii)
20154 sinph1(k)=dsin(k*phii)
20158 ityp1=nthetyp_nucl+1
20159 do k=1,nsingle_nucl
20165 if (i.lt.nres .and. itype(i,2).ne.ntyp1_molec(2)) then
20168 if (phii1.ne.phii1) phii1=150.0
20169 phii1=pinorm(phii1)
20173 ityp3=ithetyp_nucl(itype(i,2))
20174 do k=1,nsingle_nucl
20175 cosph2(k)=dcos(k*phii1)
20176 sinph2(k)=dsin(k*phii1)
20180 ityp3=nthetyp_nucl+1
20181 do k=1,nsingle_nucl
20186 ethetai=aa0thet_nucl(ityp1,ityp2,ityp3)
20187 do k=1,ndouble_nucl
20189 ccl=cosph1(l)*cosph2(k-l)
20190 ssl=sinph1(l)*sinph2(k-l)
20191 scl=sinph1(l)*cosph2(k-l)
20192 csl=cosph1(l)*sinph2(k-l)
20193 cosph1ph2(l,k)=ccl-ssl
20194 cosph1ph2(k,l)=ccl+ssl
20195 sinph1ph2(l,k)=scl+csl
20196 sinph1ph2(k,l)=scl-csl
20200 write (iout,*) "i",i," ityp1",ityp1," ityp2",ityp2,&
20201 " ityp3",ityp3," theti2",theti2," phii",phii," phii1",phii1
20202 write (iout,*) "coskt and sinkt",nntheterm_nucl
20203 do k=1,nntheterm_nucl
20204 write (iout,*) k,coskt(k),sinkt(k)
20207 do k=1,ntheterm_nucl
20208 ethetai=ethetai+aathet_nucl(k,ityp1,ityp2,ityp3)*sinkt(k)
20209 dethetai=dethetai+0.5d0*k*aathet_nucl(k,ityp1,ityp2,ityp3)&
20212 write (iout,*) "k",k," aathet",aathet_nucl(k,ityp1,ityp2,ityp3),&
20216 write (iout,*) "cosph and sinph"
20217 do k=1,nsingle_nucl
20218 write (iout,*) k,cosph1(k),sinph1(k),cosph2(k),sinph2(k)
20220 write (iout,*) "cosph1ph2 and sinph2ph2"
20221 do k=2,ndouble_nucl
20223 write (iout,*) l,k,cosph1ph2(l,k),cosph1ph2(k,l),&
20224 sinph1ph2(l,k),sinph1ph2(k,l)
20227 write(iout,*) "ethetai",ethetai
20229 do m=1,ntheterm2_nucl
20230 do k=1,nsingle_nucl
20231 aux=bbthet_nucl(k,m,ityp1,ityp2,ityp3)*cosph1(k)&
20232 +ccthet_nucl(k,m,ityp1,ityp2,ityp3)*sinph1(k)&
20233 +ddthet_nucl(k,m,ityp1,ityp2,ityp3)*cosph2(k)&
20234 +eethet_nucl(k,m,ityp1,ityp2,ityp3)*sinph2(k)
20235 ethetai=ethetai+sinkt(m)*aux
20236 dethetai=dethetai+0.5d0*m*aux*coskt(m)
20237 dephii=dephii+k*sinkt(m)*(&
20238 ccthet_nucl(k,m,ityp1,ityp2,ityp3)*cosph1(k)-&
20239 bbthet_nucl(k,m,ityp1,ityp2,ityp3)*sinph1(k))
20240 dephii1=dephii1+k*sinkt(m)*(&
20241 eethet_nucl(k,m,ityp1,ityp2,ityp3)*cosph2(k)-&
20242 ddthet_nucl(k,m,ityp1,ityp2,ityp3)*sinph2(k))
20244 write (iout,*) "m",m," k",k," bbthet",&
20245 bbthet_nucl(k,m,ityp1,ityp2,ityp3)," ccthet",&
20246 ccthet_nucl(k,m,ityp1,ityp2,ityp3)," ddthet",&
20247 ddthet_nucl(k,m,ityp1,ityp2,ityp3)," eethet",&
20248 eethet_nucl(k,m,ityp1,ityp2,ityp3)," ethetai",ethetai
20252 write(iout,*) "ethetai",ethetai
20253 do m=1,ntheterm3_nucl
20254 do k=2,ndouble_nucl
20256 aux=ffthet_nucl(l,k,m,ityp1,ityp2,ityp3)*cosph1ph2(l,k)+&
20257 ffthet_nucl(k,l,m,ityp1,ityp2,ityp3)*cosph1ph2(k,l)+&
20258 ggthet_nucl(l,k,m,ityp1,ityp2,ityp3)*sinph1ph2(l,k)+&
20259 ggthet_nucl(k,l,m,ityp1,ityp2,ityp3)*sinph1ph2(k,l)
20260 ethetai=ethetai+sinkt(m)*aux
20261 dethetai=dethetai+0.5d0*m*coskt(m)*aux
20262 dephii=dephii+l*sinkt(m)*(&
20263 -ffthet_nucl(l,k,m,ityp1,ityp2,ityp3)*sinph1ph2(l,k)-&
20264 ffthet_nucl(k,l,m,ityp1,ityp2,ityp3)*sinph1ph2(k,l)+&
20265 ggthet_nucl(l,k,m,ityp1,ityp2,ityp3)*cosph1ph2(l,k)+&
20266 ggthet_nucl(k,l,m,ityp1,ityp2,ityp3)*cosph1ph2(k,l))
20267 dephii1=dephii1+(k-l)*sinkt(m)*( &
20268 -ffthet_nucl(l,k,m,ityp1,ityp2,ityp3)*sinph1ph2(l,k)+&
20269 ffthet_nucl(k,l,m,ityp1,ityp2,ityp3)*sinph1ph2(k,l)+&
20270 ggthet_nucl(l,k,m,ityp1,ityp2,ityp3)*cosph1ph2(l,k)-&
20271 ggthet_nucl(k,l,m,ityp1,ityp2,ityp3)*cosph1ph2(k,l))
20273 write (iout,*) "m",m," k",k," l",l," ffthet", &
20274 ffthet_nucl(l,k,m,ityp1,ityp2,ityp3), &
20275 ffthet_nucl(k,l,m,ityp1,ityp2,ityp3)," ggthet",&
20276 ggthet_nucl(l,k,m,ityp1,ityp2,ityp3),&
20277 ggthet_nucl(k,l,m,ityp1,ityp2,ityp3)," ethetai",ethetai
20278 write (iout,*) cosph1ph2(l,k)*sinkt(m), &
20279 cosph1ph2(k,l)*sinkt(m),&
20280 sinph1ph2(l,k)*sinkt(m),sinph1ph2(k,l)*sinkt(m)
20286 if (lprn1) write (iout,'(i2,3f8.1,9h ethetai ,f10.5)') &
20287 i,theta(i)*rad2deg,phii*rad2deg, &
20288 phii1*rad2deg,ethetai
20289 etheta_nucl=etheta_nucl+ethetai
20290 ! print *,i,"partial sum",etheta_nucl
20291 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang_nucl*dephii
20292 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang_nucl*dephii1
20293 gloc(nphi+i-2,icg)=wang_nucl*dethetai
20296 end subroutine ebend_nucl
20297 !----------------------------------------------------
20298 subroutine etor_nucl(etors_nucl)
20299 ! implicit real*8 (a-h,o-z)
20300 ! include 'DIMENSIONS'
20301 ! include 'COMMON.VAR'
20302 ! include 'COMMON.GEO'
20303 ! include 'COMMON.LOCAL'
20304 ! include 'COMMON.TORSION'
20305 ! include 'COMMON.INTERACT'
20306 ! include 'COMMON.DERIV'
20307 ! include 'COMMON.CHAIN'
20308 ! include 'COMMON.NAMES'
20309 ! include 'COMMON.IOUNITS'
20310 ! include 'COMMON.FFIELD'
20311 ! include 'COMMON.TORCNSTR'
20312 ! include 'COMMON.CONTROL'
20313 real(kind=8) :: etors_nucl,edihcnstr
20315 !el local variables
20316 integer :: i,j,iblock,itori,itori1
20317 real(kind=8) :: phii,gloci,v1ij,v2ij,cosphi,sinphi,&
20318 vl1ij,vl2ij,vl3ij,pom1,difi,etors_ii,pom
20319 ! Set lprn=.true. for debugging
20323 ! print *,"iphi_nucl_start/end", iphi_nucl_start,iphi_nucl_end
20324 do i=iphi_nucl_start,iphi_nucl_end
20325 if (itype(i-2,2).eq.ntyp1_molec(2) .or. itype(i-1,2).eq.ntyp1_molec(2) &
20326 .or. itype(i-3,2).eq.ntyp1_molec(2) &
20327 .or. itype(i,2).eq.ntyp1_molec(2)) cycle
20329 itori=itortyp_nucl(itype(i-2,2))
20330 itori1=itortyp_nucl(itype(i-1,2))
20332 ! print *,i,itori,itori1
20334 !C Regular cosine and sine terms
20335 do j=1,nterm_nucl(itori,itori1)
20336 v1ij=v1_nucl(j,itori,itori1)
20337 v2ij=v2_nucl(j,itori,itori1)
20338 cosphi=dcos(j*phii)
20339 sinphi=dsin(j*phii)
20340 etors_nucl=etors_nucl+v1ij*cosphi+v2ij*sinphi
20341 if (energy_dec) etors_ii=etors_ii+&
20342 v1ij*cosphi+v2ij*sinphi
20343 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
20347 !C E = SUM ----------------------------------- - v1
20348 !C [v2 cos(phi/2)+v3 sin(phi/2)]^2 + 1
20350 cosphi=dcos(0.5d0*phii)
20351 sinphi=dsin(0.5d0*phii)
20352 do j=1,nlor_nucl(itori,itori1)
20353 vl1ij=vlor1_nucl(j,itori,itori1)
20354 vl2ij=vlor2_nucl(j,itori,itori1)
20355 vl3ij=vlor3_nucl(j,itori,itori1)
20356 pom=vl2ij*cosphi+vl3ij*sinphi
20357 pom1=1.0d0/(pom*pom+1.0d0)
20358 etors_nucl=etors_nucl+vl1ij*pom1
20359 if (energy_dec) etors_ii=etors_ii+ &
20362 gloci=gloci+vl1ij*(vl3ij*cosphi-vl2ij*sinphi)*pom
20364 !C Subtract the constant term
20365 etors_nucl=etors_nucl-v0_nucl(itori,itori1)
20366 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
20367 'etor',i,etors_ii-v0_nucl(itori,itori1)
20369 write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)') &
20370 restyp(itype(i-2,2),2),i-2,restyp(itype(i-1,2),2),i-1,itori,itori1, &
20371 (v1_nucl(j,itori,itori1),j=1,6),(v2_nucl(j,itori,itori1),j=1,6)
20372 gloc(i-3,icg)=gloc(i-3,icg)+wtor_nucl*gloci
20373 !c write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
20376 end subroutine etor_nucl
20377 !------------------------------------------------------------
20378 subroutine epp_nucl_sub(evdw1,ees)
20380 !C This subroutine calculates the average interaction energy and its gradient
20381 !C in the virtual-bond vectors between non-adjacent peptide groups, based on
20382 !C the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
20383 !C The potential depends both on the distance of peptide-group centers and on
20384 !C the orientation of the CA-CA virtual bonds.
20386 integer :: i,j,k,iteli,itelj,num_conti,isubchap,ind
20387 real(kind=8) :: dxi,dyi,dzi,dxj,dyj,dzj,aaa,bbb
20388 real(kind=8) :: xj,yj,zj,rij,rrmij,sss,r3ij,r6ij,evdw1,&
20389 dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
20390 dx_normj,dy_normj,dz_normj,rmij,ev1,ev2,evdwij,facvdw
20391 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
20392 dist_temp, dist_init,sss_grad,fac,evdw1ij
20393 integer xshift,yshift,zshift
20394 real(kind=8),dimension(3):: ggg,gggp,gggm,erij
20395 real(kind=8) :: ees,eesij
20396 !c 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
20397 real(kind=8) scal_el /0.5d0/
20403 !c Loop over all pairs of interacting peptide groups except i,i+2 and i,i+3
20405 ! print *,"iatel_s_nucl,iatel_e_nucl",iatel_s_nucl,iatel_e_nucl
20406 do i=iatel_s_nucl,iatel_e_nucl
20407 if (itype(i,2).eq.ntyp1_molec(2) .or. itype(i+1,2).eq.ntyp1_molec(2)) cycle
20411 dx_normi=dc_norm(1,i)
20412 dy_normi=dc_norm(2,i)
20413 dz_normi=dc_norm(3,i)
20414 xmedi=c(1,i)+0.5d0*dxi
20415 ymedi=c(2,i)+0.5d0*dyi
20416 zmedi=c(3,i)+0.5d0*dzi
20417 xmedi=dmod(xmedi,boxxsize)
20418 if (xmedi.lt.0) xmedi=xmedi+boxxsize
20419 ymedi=dmod(ymedi,boxysize)
20420 if (ymedi.lt.0) ymedi=ymedi+boxysize
20421 zmedi=dmod(zmedi,boxzsize)
20422 if (zmedi.lt.0) zmedi=zmedi+boxzsize
20424 do j=ielstart_nucl(i),ielend_nucl(i)
20425 if (itype(j,2).eq.ntyp1_molec(2) .or. itype(j+1,2).eq.ntyp1_molec(2)) cycle
20430 ! xj=c(1,j)+0.5D0*dxj-xmedi
20431 ! yj=c(2,j)+0.5D0*dyj-ymedi
20432 ! zj=c(3,j)+0.5D0*dzj-zmedi
20433 xj=c(1,j)+0.5D0*dxj
20434 yj=c(2,j)+0.5D0*dyj
20435 zj=c(3,j)+0.5D0*dzj
20436 xj=mod(xj,boxxsize)
20437 if (xj.lt.0) xj=xj+boxxsize
20438 yj=mod(yj,boxysize)
20439 if (yj.lt.0) yj=yj+boxysize
20440 zj=mod(zj,boxzsize)
20441 if (zj.lt.0) zj=zj+boxzsize
20443 dist_init=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
20450 xj=xj_safe+xshift*boxxsize
20451 yj=yj_safe+yshift*boxysize
20452 zj=zj_safe+zshift*boxzsize
20453 dist_temp=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
20454 if(dist_temp.lt.dist_init) then
20455 dist_init=dist_temp
20464 if (isubchap.eq.1) then
20475 rij=xj*xj+yj*yj+zj*zj
20476 !c write (2,*)"ij",i,j," r0pp",r0pp," rij",rij," epspp",epspp
20477 fac=(r0pp**2/rij)**3
20481 fac=(-ev1-evdw1ij)/rij
20482 ! write (2,*)"fac",fac," ev1",ev1," ev2",ev2," evdw1ij",evdw1ij
20483 if (energy_dec) write(iout,'(2i5,a9,f10.4)') i,j,"evdw1ij",evdw1ij
20484 evdw1=evdw1+evdw1ij
20486 !C Calculate contributions to the Cartesian gradient.
20492 gvdwpp_nucl(k,i)=gvdwpp_nucl(k,i)-ggg(k)
20493 gvdwpp_nucl(k,j)=gvdwpp_nucl(k,j)+ggg(k)
20495 !c phoshate-phosphate electrostatic interactions
20498 eesij=dexp(-BEES*rij)*fac
20499 ! write (2,*)"fac",fac," eesijpp",eesij
20500 if (energy_dec) write(iout,'(2i5,a9,f10.4)') i,j,"eesijpp",eesij
20503 fac=-(fac+BEES)*eesij*fac
20507 !c write(2,*) "ggg",i,j,ggg(1),ggg(2),ggg(3)
20508 !c write(2,*) "gelpp",i,(gelpp(k,i),k=1,3)
20509 !c write(2,*) "gelpp",j,(gelpp(k,j),k=1,3)
20511 gelpp(k,i)=gelpp(k,i)-ggg(k)
20512 gelpp(k,j)=gelpp(k,j)+ggg(k)
20519 !c write (2,*) "i",i," gelpp",(gelpp(k,i),k=1,3)
20521 gvdwpp_nucl(k,i)=6*gvdwpp_nucl(k,i)
20522 !c gelpp(k,i)=332.0d0*gelpp(k,i)
20523 gelpp(k,i)=AEES*gelpp(k,i)
20525 !c write (2,*) "i",i," gelpp",(gelpp(k,i),k=1,3)
20527 !c write (2,*) "total EES",ees
20529 end subroutine epp_nucl_sub
20530 !---------------------------------------------------------------------
20531 subroutine epsb(evdwpsb,eelpsb)
20534 !C This subroutine calculates the excluded-volume interaction energy between
20535 !C peptide-group centers and side chains and its gradient in virtual-bond and
20536 !C side-chain vectors.
20538 real(kind=8),dimension(3):: ggg
20539 integer :: i,iint,j,k,iteli,itypj,subchap
20540 real(kind=8) :: evdw2,evdw2_14,xi,yi,zi,xj,yj,zj,rrij,fac,&
20541 e1,e2,evdwij,rij,evdwpsb,eelpsb
20542 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
20543 dist_temp, dist_init
20544 integer xshift,yshift,zshift
20546 !cd print '(a)','Enter ESCP'
20547 !cd write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
20550 ! print *,"iatscp_s_nucl,iatscp_e_nucl",iatscp_s_nucl,iatscp_e_nucl
20551 do i=iatscp_s_nucl,iatscp_e_nucl
20552 if (itype(i,2).eq.ntyp1_molec(2) &
20553 .or. itype(i+1,2).eq.ntyp1_molec(2)) cycle
20554 xi=0.5D0*(c(1,i)+c(1,i+1))
20555 yi=0.5D0*(c(2,i)+c(2,i+1))
20556 zi=0.5D0*(c(3,i)+c(3,i+1))
20557 xi=mod(xi,boxxsize)
20558 if (xi.lt.0) xi=xi+boxxsize
20559 yi=mod(yi,boxysize)
20560 if (yi.lt.0) yi=yi+boxysize
20561 zi=mod(zi,boxzsize)
20562 if (zi.lt.0) zi=zi+boxzsize
20564 do iint=1,nscp_gr_nucl(i)
20566 do j=iscpstart_nucl(i,iint),iscpend_nucl(i,iint)
20568 if (itypj.eq.ntyp1_molec(2)) cycle
20569 !C Uncomment following three lines for SC-p interactions
20570 !c xj=c(1,nres+j)-xi
20571 !c yj=c(2,nres+j)-yi
20572 !c zj=c(3,nres+j)-zi
20573 !C Uncomment following three lines for Ca-p interactions
20580 xj=mod(xj,boxxsize)
20581 if (xj.lt.0) xj=xj+boxxsize
20582 yj=mod(yj,boxysize)
20583 if (yj.lt.0) yj=yj+boxysize
20584 zj=mod(zj,boxzsize)
20585 if (zj.lt.0) zj=zj+boxzsize
20586 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
20594 xj=xj_safe+xshift*boxxsize
20595 yj=yj_safe+yshift*boxysize
20596 zj=zj_safe+zshift*boxzsize
20597 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
20598 if(dist_temp.lt.dist_init) then
20599 dist_init=dist_temp
20608 if (subchap.eq.1) then
20618 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
20620 e1=fac*fac*aad_nucl(itypj)
20621 e2=fac*bad_nucl(itypj)
20622 if (iabs(j-i) .le. 2) then
20627 evdwpsb=evdwpsb+evdwij
20628 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a4)') &
20629 'evdw2',i,j,evdwij,"tu4"
20631 !C Calculate contributions to the gradient in the virtual-bond and SC vectors.
20633 fac=-(evdwij+e1)*rrij
20638 gvdwpsb1(k,i)=gvdwpsb1(k,i)-ggg(k)
20639 gvdwpsb(k,j)=gvdwpsb(k,j)+ggg(k)
20647 gvdwpsb(j,i)=expon*gvdwpsb(j,i)
20648 gvdwpsb1(j,i)=expon*gvdwpsb1(j,i)
20652 end subroutine epsb
20654 !------------------------------------------------------
20655 subroutine esb_gb(evdwsb,eelsb)
20658 integer :: iint,itypi,itypi1,itypj,subchap,num_conti2
20659 real(kind=8) :: xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
20660 real(kind=8) :: evdw,sig0iji,evdwsb,eelsb,ecorr,eelij
20661 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
20662 dist_temp, dist_init,aa,bb,faclip,sig0ij
20671 ! print *,"iastsc_nucl",iatsc_s_nucl,iatsc_e_nucl
20672 do i=iatsc_s_nucl,iatsc_e_nucl
20676 ! PRINT *,"I=",i,itypi
20677 if (itypi.eq.ntyp1_molec(2)) cycle
20678 itypi1=itype(i+1,2)
20682 xi=dmod(xi,boxxsize)
20683 if (xi.lt.0) xi=xi+boxxsize
20684 yi=dmod(yi,boxysize)
20685 if (yi.lt.0) yi=yi+boxysize
20686 zi=dmod(zi,boxzsize)
20687 if (zi.lt.0) zi=zi+boxzsize
20689 dxi=dc_norm(1,nres+i)
20690 dyi=dc_norm(2,nres+i)
20691 dzi=dc_norm(3,nres+i)
20692 dsci_inv=vbld_inv(i+nres)
20694 !C Calculate SC interaction energy.
20696 do iint=1,nint_gr_nucl(i)
20697 ! print *,"tu?",i,istart_nucl(i,iint),iend_nucl(i,iint)
20698 do j=istart_nucl(i,iint),iend_nucl(i,iint)
20702 if (itypj.eq.ntyp1_molec(2)) cycle
20703 dscj_inv=vbld_inv(j+nres)
20704 sig0ij=sigma_nucl(itypi,itypj)
20705 chi1=chi_nucl(itypi,itypj)
20706 chi2=chi_nucl(itypj,itypi)
20708 chip1=chip_nucl(itypi,itypj)
20709 chip2=chip_nucl(itypj,itypi)
20711 ! xj=c(1,nres+j)-xi
20712 ! yj=c(2,nres+j)-yi
20713 ! zj=c(3,nres+j)-zi
20717 xj=dmod(xj,boxxsize)
20718 if (xj.lt.0) xj=xj+boxxsize
20719 yj=dmod(yj,boxysize)
20720 if (yj.lt.0) yj=yj+boxysize
20721 zj=dmod(zj,boxzsize)
20722 if (zj.lt.0) zj=zj+boxzsize
20723 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
20731 xj=xj_safe+xshift*boxxsize
20732 yj=yj_safe+yshift*boxysize
20733 zj=zj_safe+zshift*boxzsize
20734 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
20735 if(dist_temp.lt.dist_init) then
20736 dist_init=dist_temp
20745 if (subchap.eq.1) then
20755 dxj=dc_norm(1,nres+j)
20756 dyj=dc_norm(2,nres+j)
20757 dzj=dc_norm(3,nres+j)
20758 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
20760 !C Calculate angle-dependent terms of energy and contributions to their
20765 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
20766 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
20767 om12=dxi*dxj+dyi*dyj+dzi*dzj
20768 call sc_angular_nucl
20770 sig=sig0ij*dsqrt(sigsq)
20771 rij_shift=1.0D0/rij-sig+sig0ij
20772 ! print *,rij_shift,"rij_shift"
20773 !c write (2,*) " rij",1.0D0/rij," sig",sig," sig0ij",sig0ij,
20774 !c & " rij_shift",rij_shift
20775 if (rij_shift.le.0.0D0) then
20780 !c---------------------------------------------------------------
20781 rij_shift=1.0D0/rij_shift
20782 fac=rij_shift**expon
20783 e1=fac*fac*aa_nucl(itypi,itypj)
20784 e2=fac*bb_nucl(itypi,itypj)
20785 evdwij=eps1*eps2rt*(e1+e2)
20786 !c write (2,*) "eps1",eps1," eps2rt",eps2rt,
20787 !c & " e1",e1," e2",e2," evdwij",evdwij
20789 evdwij=evdwij*eps2rt
20790 evdwsb=evdwsb+evdwij
20792 sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
20793 epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
20794 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
20795 restyp(itypi,2),i,restyp(itypj,2),j, &
20796 epsi,sigm,chi1,chi2,chip1,chip2, &
20797 eps1,eps2rt**2,sig,sig0ij, &
20798 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
20800 write (iout,*) "aa",aa_nucl(itypi,itypj)," bb",bb_nucl(itypi,itypj)
20803 if (energy_dec) write (iout,'(a6,2i5,e15.3,a4)') &
20804 'evdw',i,j,evdwij,"tu3"
20807 !C Calculate gradient components.
20808 e1=e1*eps1*eps2rt**2
20809 fac=-expon*(e1+evdwij)*rij_shift
20813 !C Calculate the radial part of the gradient
20817 !C Calculate angular part of the gradient.
20819 call eelsbij(eelij,num_conti2)
20820 if (energy_dec .and. &
20821 (j.eq.i+1.or.j.eq.nres-i+1.or.j.eq.nres-i.or.j.eq.nres-i+2)) &
20822 write (istat,'(e14.5)') evdwij
20826 num_cont_hb(i)=num_conti2
20828 !c write (iout,*) "Number of loop steps in EGB:",ind
20829 !cccc energy_dec=.false.
20831 end subroutine esb_gb
20832 !-------------------------------------------------------------------------------
20833 subroutine eelsbij(eesij,num_conti2)
20836 real(kind=8),dimension(3) :: ggg,gggp,gggm,dcosb,dcosg
20837 real(kind=8),dimension(3,3) :: erder,uryg,urzg,vryg,vrzg
20838 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
20839 dist_temp, dist_init,rlocshield,fracinbuf
20840 integer xshift,yshift,zshift,ilist,iresshield,num_conti2
20842 !c 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
20843 real(kind=8) scal_el /0.5d0/
20844 integer :: iteli,itelj,kkk,kkll,m,isubchap
20845 real(kind=8) :: ael6i,rrmij,rmij,r0ij,fcont,fprimcont,ees0tmp,facfac
20846 real(kind=8) :: ees,evdw1,eel_loc,aaa,bbb,ael3i,ael63i,ael32i
20847 real(kind=8) :: dx_normj,dy_normj,dz_normj,&
20848 r3ij,r6ij,cosa,cosb,cosg,fac,ev1,ev2,fac3,fac4,fac5,fac6,&
20849 el1,el2,el3,el4,eesij,ees0ij,facvdw,facel,fac1,ecosa,&
20850 ecosb,ecosg,ury,urz,vry,vrz,facr,a22der,a23der,a32der,&
20851 a33der,eel_loc_ij,cosa4,wij,cosbg1,cosbg2,ees0pij,&
20852 ees0pij1,ees0mij,ees0mij1,fac3p,ees0mijp,ees0pijp,&
20853 ecosa1,ecosb1,ecosg1,ecosa2,ecosb2,ecosg2,ecosap,ecosbp,&
20854 ecosgp,ecosam,ecosbm,ecosgm,ghalf,itypi,itypj
20858 ! print *,i,j,itypi,itypj,istype(i),istype(j),"????"
20859 ael6i=ael6_nucl(itypi,itypj)
20860 ael3i=ael3_nucl(itypi,itypj)
20861 ael63i=ael63_nucl(itypi,itypj)
20862 ael32i=ael32_nucl(itypi,itypj)
20863 !c write (iout,*) "eelecij",i,j,itype(i),itype(j),
20864 !c & ael6i,ael3i,ael63i,al32i,rij,rrij
20868 dx_normi=dc_norm(1,i+nres)
20869 dy_normi=dc_norm(2,i+nres)
20870 dz_normi=dc_norm(3,i+nres)
20871 dx_normj=dc_norm(1,j+nres)
20872 dy_normj=dc_norm(2,j+nres)
20873 dz_normj=dc_norm(3,j+nres)
20874 !c xj=c(1,j)+0.5D0*dxj-xmedi
20875 !c yj=c(2,j)+0.5D0*dyj-ymedi
20876 !c zj=c(3,j)+0.5D0*dzj-zmedi
20877 if (ipot_nucl.ne.2) then
20878 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
20879 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
20880 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
20888 fac=cosa-3.0D0*cosb*cosg
20890 fac1=3.0d0*(cosb*cosb+cosg*cosg)
20895 !c write (iout,*) "r3ij",r3ij," r6ij",r6ij," fac",fac," fac1",fac1,
20896 !c & " fac2",fac2," fac3",fac3," fac4",fac4," fac5",fac5," fac6",fac6
20897 el1=fac3*(4.0D0+facfac-fac1)
20899 el3=fac5*(2.0d0-2.0d0*facfac+fac1)
20901 eesij=el1+el2+el3+el4
20902 !C 12/26/95 - for the evaluation of multi-body H-bonding interactions
20903 ees0ij=4.0D0+facfac-fac1
20905 if (energy_dec) then
20906 if(j.eq.i+1.or.j.eq.nres-i+1.or.j.eq.nres-i.or.j.eq.nres-i+2) &
20907 write (istat,'(2a1,i4,1x,2a1,i4,4f10.5,3e12.5,$)') &
20908 sugartyp(istype(i)),restyp(itypi,2),i,sugartyp(istype(j)),&
20909 restyp(itypj,2),j,1.0d0/rij,cosa,cosb,cosg,fac*r3ij, &
20910 (4.0D0+facfac-fac1)*r6ij,(2.0d0-2.0d0*facfac+fac1)*r6ij
20911 write (iout,'(a6,2i5,e15.3)') 'ees',i,j,eesij
20915 !C Calculate contributions to the Cartesian gradient.
20917 facel=-3.0d0*rrij*(eesij+el1+el3+el4)
20923 !* Radial derivatives. First process both termini of the fragment (i,j)
20929 gelsbc(k,j)=gelsbc(k,j)+ggg(k)
20930 gelsbc(k,i)=gelsbc(k,i)-ggg(k)
20931 gelsbx(k,j)=gelsbx(k,j)+ggg(k)
20932 gelsbx(k,i)=gelsbx(k,i)-ggg(k)
20937 ecosa=2.0D0*fac3*fac1+fac4+(-4.0d0*fac5+2.0d0*fac6)*fac1
20942 ecosb=fac3*(fac1*cosg+cosb)+cosg*fac4+(cosb+2*fac1*cosg)*fac5+&
20944 ecosg=fac3*(fac1*cosb+cosg)+cosb*fac4+(cosg+2*fac1*cosb)*fac5+&
20947 dcosb(k)=rij*(dc_norm(k,i+nres)-erij(k)*cosb)
20948 dcosg(k)=rij*(dc_norm(k,j+nres)-erij(k)*cosg)
20951 ggg(k)=ecosb*dcosb(k)+ecosg*dcosg(k)
20954 gelsbx(k,i)=gelsbx(k,i)-ggg(k) &
20955 +(ecosa*(dc_norm(k,j+nres)-cosa*dc_norm(k,i+nres))&
20956 + ecosb*(erij(k)-cosb*dc_norm(k,i+nres)))*vbld_inv(i+nres)
20957 gelsbx(k,j)=gelsbx(k,j)+ggg(k) &
20958 +(ecosa*(dc_norm(k,i+nres)-cosa*dc_norm(k,j+nres))&
20959 + ecosg*(erij(k)-cosg*dc_norm(k,j+nres)))*vbld_inv(j+nres)
20960 gelsbc(k,j)=gelsbc(k,j)+ggg(k)
20961 gelsbc(k,i)=gelsbc(k,i)-ggg(k)
20963 ! IF ( (wcorr_nucl.gt.0.0d0.or.wcorr3_nucl.gt.0.0d0) .and.
20964 IF ( j.gt.i+1 .and.&
20965 num_conti.le.maxconts) THEN
20967 !C Calculate the contact function. The ith column of the array JCONT will
20968 !C contain the numbers of atoms that make contacts with the atom I (of numbers
20969 !C greater than I). The arrays FACONT and GACONT will contain the values of
20970 !C the contact function and its derivative.
20971 r0ij=2.20D0*sigma(itypi,itypj)
20972 !c write (2,*) "ij",i,j," rij",1.0d0/rij," r0ij",r0ij
20973 call gcont(rij,r0ij,1.0D0,0.2d0/r0ij,fcont,fprimcont)
20974 !c write (2,*) "fcont",fcont
20975 if (fcont.gt.0.0D0) then
20976 num_conti=num_conti+1
20977 num_conti2=num_conti2+1
20979 if (num_conti.gt.maxconts) then
20980 write (iout,*) 'WARNING - max. # of contacts exceeded;',&
20981 ' will skip next contacts for this conf.'
20983 jcont_hb(num_conti,i)=j
20984 !c write (iout,*) "num_conti",num_conti,
20985 !c & " jcont_hb",jcont_hb(num_conti,i)
20986 !C Calculate contact energies
20988 wij=cosa-3.0D0*cosb*cosg
20991 fac3=dsqrt(-ael6i)*r3ij
20992 !c write (2,*) "ael6i",ael6i," r3ij",r3ij," fac3",fac3
20993 ees0tmp=4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1
20994 if (ees0tmp.gt.0) then
20995 ees0pij=dsqrt(ees0tmp)
20999 ees0tmp=4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2
21000 if (ees0tmp.gt.0) then
21001 ees0mij=dsqrt(ees0tmp)
21005 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij)
21006 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij)
21007 !c write (iout,*) "i",i," j",j,
21008 !c & " ees0m",ees0m(num_conti,i)," ees0p",ees0p(num_conti,i)
21009 ees0pij1=fac3/ees0pij
21010 ees0mij1=fac3/ees0mij
21011 fac3p=-3.0D0*fac3*rrij
21012 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
21013 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
21014 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
21015 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
21016 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
21017 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
21018 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
21019 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
21020 ecosap=ecosa1+ecosa2
21021 ecosbp=ecosb1+ecosb2
21022 ecosgp=ecosg1+ecosg2
21023 ecosam=ecosa1-ecosa2
21024 ecosbm=ecosb1-ecosb2
21025 ecosgm=ecosg1-ecosg2
21027 facont_hb(num_conti,i)=fcont
21028 fprimcont=fprimcont/rij
21030 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
21031 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
21033 gggp(1)=gggp(1)+ees0pijp*xj
21034 gggp(2)=gggp(2)+ees0pijp*yj
21035 gggp(3)=gggp(3)+ees0pijp*zj
21036 gggm(1)=gggm(1)+ees0mijp*xj
21037 gggm(2)=gggm(2)+ees0mijp*yj
21038 gggm(3)=gggm(3)+ees0mijp*zj
21039 !C Derivatives due to the contact function
21040 gacont_hbr(1,num_conti,i)=fprimcont*xj
21041 gacont_hbr(2,num_conti,i)=fprimcont*yj
21042 gacont_hbr(3,num_conti,i)=fprimcont*zj
21045 !c Gradient of the correlation terms
21047 gacontp_hb1(k,num_conti,i)= &
21048 (ecosap*(dc_norm(k,j+nres)-cosa*dc_norm(k,i+nres)) &
21049 + ecosbp*(erij(k)-cosb*dc_norm(k,i+nres)))*vbld_inv(i+nres)
21050 gacontp_hb2(k,num_conti,i)= &
21051 (ecosap*(dc_norm(k,i+nres)-cosa*dc_norm(k,j+nres)) &
21052 + ecosgp*(erij(k)-cosg*dc_norm(k,j+nres)))*vbld_inv(j+nres)
21053 gacontp_hb3(k,num_conti,i)=gggp(k)
21054 gacontm_hb1(k,num_conti,i)= &
21055 (ecosam*(dc_norm(k,j+nres)-cosa*dc_norm(k,i+nres)) &
21056 + ecosbm*(erij(k)-cosb*dc_norm(k,i+nres)))*vbld_inv(i+nres)
21057 gacontm_hb2(k,num_conti,i)= &
21058 (ecosam*(dc_norm(k,i+nres)-cosa*dc_norm(k,j+nres))&
21059 + ecosgm*(erij(k)-cosg*dc_norm(k,j+nres)))*vbld_inv(j+nres)
21060 gacontm_hb3(k,num_conti,i)=gggm(k)
21066 end subroutine eelsbij
21067 !------------------------------------------------------------------
21068 subroutine sc_grad_nucl
21071 real(kind=8),dimension(3) :: dcosom1,dcosom2
21072 eom1=eps2der*eps2rt_om1+sigder*sigsq_om1
21073 eom2=eps2der*eps2rt_om2+sigder*sigsq_om2
21074 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12+sigder*sigsq_om12
21076 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
21077 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
21080 gg(k)=gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
21083 gvdwsbx(k,i)=gvdwsbx(k,i)-gg(k) &
21084 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))&
21085 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
21086 gvdwsbx(k,j)=gvdwsbx(k,j)+gg(k) &
21087 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
21088 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
21091 !C Calculate the components of the gradient in DC and X
21094 gvdwsbc(l,i)=gvdwsbc(l,i)-gg(l)
21095 gvdwsbc(l,j)=gvdwsbc(l,j)+gg(l)
21098 end subroutine sc_grad_nucl
21099 !-----------------------------------------------------------------------
21100 subroutine esb(esbloc)
21101 !C Calculate the local energy of a side chain and its derivatives in the
21102 !C corresponding virtual-bond valence angles THETA and the spherical angles
21103 !C ALPHA and OMEGA derived from AM1 all-atom calculations.
21104 !C added by Urszula Kozlowska. 07/11/2007
21106 real(kind=8),dimension(3):: x_prime,y_prime,z_prime
21107 real(kind=8),dimension(9):: x
21108 real(kind=8) :: sumene,dsc_i,dp2_i,xx,yy,zz,sumene1, &
21109 sumene2,sumene3,sumene4,s1,s1_6,s2,s2_6,&
21110 de_dxx,de_dyy,de_dzz,de_dt,s1_t,s1_6_t,s2_t,s2_6_t
21111 real(kind=8),dimension(3):: dXX_Ci1,dYY_Ci1,dZZ_Ci1,dXX_Ci,&
21112 dYY_Ci,dZZ_Ci,dXX_XYZ,dYY_XYZ,dZZ_XYZ,dt_dCi,dt_dCi1
21113 real(kind=8) :: esbloc,delta,cosfac2,cosfac,sinfac2,sinfac,de_dtt,&
21114 cossc,cossc1,cosfac2xx,sinfac2yy,pom1,pom
21115 integer::it,nlobit,i,j,k
21116 ! common /sccalc/ time11,time12,time112,theti,it,nlobit
21119 do i=loc_start_nucl,loc_end_nucl
21120 if (itype(i,2).eq.ntyp1_molec(2)) cycle
21121 costtab(i+1) =dcos(theta(i+1))
21122 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
21123 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
21124 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
21125 cosfac2=0.5d0/(1.0d0+costtab(i+1))
21126 cosfac=dsqrt(cosfac2)
21127 sinfac2=0.5d0/(1.0d0-costtab(i+1))
21128 sinfac=dsqrt(sinfac2)
21130 if (it.eq.10) goto 1
21133 !C Compute the axes of tghe local cartesian coordinates system; store in
21134 !c x_prime, y_prime and z_prime
21141 !C write(2,*) "dc_norm", dc_norm(1,i+nres),dc_norm(2,i+nres),
21142 !C & dc_norm(3,i+nres)
21144 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
21145 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
21148 z_prime(j) = -uz(j,i-1)
21156 xx = xx + x_prime(j)*dc_norm(j,i+nres)
21157 yy = yy + y_prime(j)*dc_norm(j,i+nres)
21158 zz = zz + z_prime(j)*dc_norm(j,i+nres)
21166 x(j) = sc_parmin_nucl(j,it)
21169 !Cc diagnostics - remove later
21170 xx1 = dcos(alph(2))
21171 yy1 = dsin(alph(2))*dcos(omeg(2))
21172 zz1 = -dsin(alph(2))*dsin(omeg(2))
21173 write(2,'(3f8.1,3f9.3,1x,3f9.3)') &
21174 alph(2)*rad2deg,omeg(2)*rad2deg,theta(3)*rad2deg,xx,yy,zz,&
21176 !C," --- ", xx_w,yy_w,zz_w
21179 sumene = enesc_nucl(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
21180 esbloc = esbloc + sumene
21181 sumene2= enesc_nucl(x,xx,yy,0.0d0,cost2tab(i+1),sint2tab(i+1))
21182 ! print *,"enecomp",sumene,sumene2
21183 ! if (energy_dec) write(iout,*) "i",i," esbloc",sumene,esbloc,xx,yy,zz
21184 ! if (energy_dec) write(iout,*) "x",(x(k),k=1,9)
21186 write (2,*) "x",(x(k),k=1,9)
21188 !C This section to check the numerical derivatives of the energy of ith side
21189 !C chain in xx, yy, zz, and theta. Use the -DDEBUG compiler option or insert
21190 !C #define DEBUG in the code to turn it on.
21192 write (2,*) "sumene =",sumene
21196 write (2,*) xx,yy,zz
21197 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
21198 de_dxx_num=(sumenep-sumene)/aincr
21200 write (2,*) "xx+ sumene from enesc=",sumenep,sumene
21203 write (2,*) xx,yy,zz
21204 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
21205 de_dyy_num=(sumenep-sumene)/aincr
21207 write (2,*) "yy+ sumene from enesc=",sumenep,sumene
21210 write (2,*) xx,yy,zz
21211 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
21212 de_dzz_num=(sumenep-sumene)/aincr
21214 write (2,*) "zz+ sumene from enesc=",sumenep,sumene
21215 costsave=cost2tab(i+1)
21216 sintsave=sint2tab(i+1)
21217 cost2tab(i+1)=dcos(0.5d0*(theta(i+1)+aincr))
21218 sint2tab(i+1)=dsin(0.5d0*(theta(i+1)+aincr))
21219 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
21220 de_dt_num=(sumenep-sumene)/aincr
21221 write (2,*) " t+ sumene from enesc=",sumenep,sumene
21222 cost2tab(i+1)=costsave
21223 sint2tab(i+1)=sintsave
21224 !C End of diagnostics section.
21227 !C Compute the gradient of esc
21229 de_dxx=x(1)+2*x(4)*xx+x(7)*zz+x(8)*yy
21230 de_dyy=x(2)+2*x(5)*yy+x(8)*xx+x(9)*zz
21231 de_dzz=x(3)+2*x(6)*zz+x(7)*xx+x(9)*yy
21234 write (2,*) "x",(x(k),k=1,9)
21235 write (2,*) "xx",xx," yy",yy," zz",zz
21236 write (2,*) "de_xx ",de_xx," de_yy ",de_yy,&
21237 " de_zz ",de_zz," de_tt ",de_tt
21238 write (2,*) "de_xx_num",de_dxx_num," de_yy_num",de_dyy_num,&
21239 " de_zz_num",de_dzz_num," de_dt_num",de_dt_num
21242 cossc=scalar(dc_norm(1,i),dc_norm(1,i+nres))
21243 cossc1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
21244 cosfac2xx=cosfac2*xx
21245 sinfac2yy=sinfac2*yy
21247 dt_dCi(k) = -(dc_norm(k,i-1)+costtab(i+1)*dc_norm(k,i))*&
21249 dt_dCi1(k)= -(dc_norm(k,i)+costtab(i+1)*dc_norm(k,i-1))*&
21251 pom=(dC_norm(k,i+nres)-cossc*dC_norm(k,i))*vbld_inv(i+1)
21252 pom1=(dC_norm(k,i+nres)-cossc1*dC_norm(k,i-1))*vbld_inv(i)
21253 !c write (iout,*) "i",i," k",k," pom",pom," pom1",pom1,
21254 !c & " dt_dCi",dt_dCi(k)," dt_dCi1",dt_dCi1(k)
21255 !c write (iout,*) "dC_norm",(dC_norm(j,i),j=1,3),
21256 !c & (dC_norm(j,i-1),j=1,3)," vbld_inv",vbld_inv(i+1),vbld_inv(i)
21257 dXX_Ci(k)=pom*cosfac-dt_dCi(k)*cosfac2xx
21258 dXX_Ci1(k)=-pom1*cosfac-dt_dCi1(k)*cosfac2xx
21259 dYY_Ci(k)=pom*sinfac+dt_dCi(k)*sinfac2yy
21260 dYY_Ci1(k)=pom1*sinfac+dt_dCi1(k)*sinfac2yy
21264 dZZ_Ci(k)=dZZ_Ci(k)-uzgrad(j,k,2,i-1)*dC_norm(j,i+nres)
21265 dZZ_Ci1(k)=dZZ_Ci1(k)-uzgrad(j,k,1,i-1)*dC_norm(j,i+nres)
21268 dXX_XYZ(k)=vbld_inv(i+nres)*(x_prime(k)-xx*dC_norm(k,i+nres))
21269 dYY_XYZ(k)=vbld_inv(i+nres)*(y_prime(k)-yy*dC_norm(k,i+nres))
21270 dZZ_XYZ(k)=vbld_inv(i+nres)*(z_prime(k)-zz*dC_norm(k,i+nres))
21272 dt_dCi(k) = -dt_dCi(k)/sinttab(i+1)
21273 dt_dCi1(k)= -dt_dCi1(k)/sinttab(i+1)
21277 dXX_Ctab(k,i)=dXX_Ci(k)
21278 dXX_C1tab(k,i)=dXX_Ci1(k)
21279 dYY_Ctab(k,i)=dYY_Ci(k)
21280 dYY_C1tab(k,i)=dYY_Ci1(k)
21281 dZZ_Ctab(k,i)=dZZ_Ci(k)
21282 dZZ_C1tab(k,i)=dZZ_Ci1(k)
21283 dXX_XYZtab(k,i)=dXX_XYZ(k)
21284 dYY_XYZtab(k,i)=dYY_XYZ(k)
21285 dZZ_XYZtab(k,i)=dZZ_XYZ(k)
21288 !c write (iout,*) "k",k," dxx_ci1",dxx_ci1(k)," dyy_ci1",
21289 !c & dyy_ci1(k)," dzz_ci1",dzz_ci1(k)
21290 !c write (iout,*) "k",k," dxx_ci",dxx_ci(k)," dyy_ci",
21291 !c & dyy_ci(k)," dzz_ci",dzz_ci(k)
21292 !c write (iout,*) "k",k," dt_dci",dt_dci(k)," dt_dci",
21294 !c write (iout,*) "k",k," dxx_XYZ",dxx_XYZ(k)," dyy_XYZ",
21295 !c & dyy_XYZ(k)," dzz_XYZ",dzz_XYZ(k)
21296 gsbloc(k,i-1)=gsbloc(k,i-1)+(de_dxx*dxx_ci1(k) &
21297 +de_dyy*dyy_ci1(k)+de_dzz*dzz_ci1(k)+de_dt*dt_dCi1(k))
21298 gsbloc(k,i)=gsbloc(k,i)+(de_dxx*dxx_Ci(k) &
21299 +de_dyy*dyy_Ci(k)+de_dzz*dzz_Ci(k)+de_dt*dt_dCi(k))
21300 gsblocx(k,i)= de_dxx*dxx_XYZ(k)&
21301 +de_dyy*dyy_XYZ(k)+de_dzz*dzz_XYZ(k)
21302 ! print *,i,de_dxx*dxx_ci1(k)+de_dyy*dyy_ci1(k),de_dzz*dzz_ci1(k)*2
21304 !c write(iout,*) "ENERGY GRAD = ", (gsbloc(k,i-1),k=1,3),
21305 !c & (gsbloc(k,i),k=1,3),(gsblocx(k,i),k=1,3)
21307 !C to check gradient call subroutine check_grad
21313 !=-------------------------------------------------------
21314 real(kind=8) function enesc_nucl(x,xx,yy,zz,cost2,sint2)
21316 real(kind=8),dimension(9):: x(9)
21317 real(kind=8) :: xx,yy,zz,cost2,sint2,sumene1,sumene2, &
21318 sumene3,sumene4,sumene,dsc_i,dp2_i,dscp1,dscp2,s1,s1_6,s2,s2_6
21320 !c write (2,*) "enesc"
21321 !c write (2,*) "x",(x(i),i=1,9)
21322 !c write(2,*)"xx",xx," yy",yy," zz",zz," cost2",cost2," sint2",sint2
21323 sumene=x(1)*xx+x(2)*yy+x(3)*zz+x(4)*xx**2 &
21324 + x(5)*yy**2+x(6)*zz**2+x(7)*xx*zz+x(8)*xx*yy &
21328 end function enesc_nucl
21329 !-----------------------------------------------------------------------------
21330 subroutine multibody_hb_nucl(ecorr,ecorr3,n_corr,n_corr1)
21333 integer,parameter :: max_cont=2000
21334 integer,parameter:: max_dim=2*(8*3+6)
21335 integer, parameter :: msglen1=max_cont*max_dim
21336 integer,parameter :: msglen2=2*msglen1
21337 integer source,CorrelType,CorrelID,Error
21338 real(kind=8) :: buffer(max_cont,max_dim)
21339 integer status(MPI_STATUS_SIZE)
21340 integer :: ierror,nbytes
21342 real(kind=8),dimension(3):: gx(3),gx1(3)
21343 real(kind=8) :: time00
21345 integer i,j,i1,j1,jj,kk,num_conti,num_conti1,nn
21346 real(kind=8) ecorr,ecorr3
21347 integer :: n_corr,n_corr1,mm,msglen
21348 !C Set lprn=.true. for debugging
21353 if(.not.allocated(zapas2)) allocate(zapas2(3,maxconts,nres,8))
21355 if (nfgtasks.le.1) goto 30
21357 write (iout,'(a)') 'Contact function values:'
21359 write (iout,'(2i3,50(1x,i2,f5.2))') &
21360 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i), &
21361 j=1,num_cont_hb(i))
21364 !C Caution! Following code assumes that electrostatic interactions concerning
21365 !C a given atom are split among at most two processors!
21375 !c write (*,*) 'MyRank',MyRank,' mm',mm
21378 !c write (*,*) 'Sending: MyRank',MyRank,' mm',mm,' ldone',ldone
21379 if (fg_rank.gt.0) then
21380 !C Send correlation contributions to the preceding processor
21382 nn=num_cont_hb(iatel_s_nucl)
21383 call pack_buffer(max_cont,max_dim,iatel_s,0,buffer)
21384 !c write (*,*) 'The BUFFER array:'
21386 !c write (*,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,30)
21388 if (ielstart_nucl(iatel_s_nucl).gt.iatel_s_nucl+ispp) then
21390 call pack_buffer(max_cont,max_dim,iatel_s+1,30,buffer)
21391 !C Clear the contacts of the atom passed to the neighboring processor
21392 nn=num_cont_hb(iatel_s_nucl+1)
21394 !c write (*,'(i2,9(3f8.3,2x))') i,(buffer(i,j+30),j=1,30)
21396 num_cont_hb(iatel_s_nucl)=0
21398 !cd write (iout,*) 'Processor ',fg_rank,MyRank,
21399 !cd & ' is sending correlation contribution to processor',fg_rank-1,
21400 !cd & ' msglen=',msglen
21401 !c write (*,*) 'Processor ',fg_rank,MyRank,
21402 !c & ' is sending correlation contribution to processor',fg_rank-1,
21403 !c & ' msglen=',msglen,' CorrelType=',CorrelType
21405 call MPI_Send(buffer,msglen,MPI_DOUBLE_PRECISION,fg_rank-1, &
21406 CorrelType,FG_COMM,IERROR)
21407 time_sendrecv=time_sendrecv+MPI_Wtime()-time00
21408 !cd write (iout,*) 'Processor ',fg_rank,
21409 !cd & ' has sent correlation contribution to processor',fg_rank-1,
21410 !cd & ' msglen=',msglen,' CorrelID=',CorrelID
21411 !c write (*,*) 'Processor ',fg_rank,
21412 !c & ' has sent correlation contribution to processor',fg_rank-1,
21413 !c & ' msglen=',msglen,' CorrelID=',CorrelID
21415 endif ! (fg_rank.gt.0)
21419 !c write (*,*) 'Receiving: MyRank',MyRank,' mm',mm,' ldone',ldone
21420 if (fg_rank.lt.nfgtasks-1) then
21421 !C Receive correlation contributions from the next processor
21423 if (ielend_nucl(iatel_e_nucl).lt.nct_molec(2)-1) msglen=msglen2
21424 !cd write (iout,*) 'Processor',fg_rank,
21425 !cd & ' is receiving correlation contribution from processor',fg_rank+1,
21426 !cd & ' msglen=',msglen,' CorrelType=',CorrelType
21427 !c write (*,*) 'Processor',fg_rank,
21428 !c &' is receiving correlation contribution from processor',fg_rank+1,
21429 !c & ' msglen=',msglen,' CorrelType=',CorrelType
21432 do while (nbytes.le.0)
21433 call MPI_Probe(fg_rank+1,CorrelType,FG_COMM,status,IERROR)
21434 call MPI_Get_count(status,MPI_DOUBLE_PRECISION,nbytes,IERROR)
21436 !c print *,'Processor',myrank,' msglen',msglen,' nbytes',nbytes
21437 call MPI_Recv(buffer,nbytes,MPI_DOUBLE_PRECISION, &
21438 fg_rank+1,CorrelType,FG_COMM,status,IERROR)
21439 time_sendrecv=time_sendrecv+MPI_Wtime()-time00
21440 !c write (*,*) 'Processor',fg_rank,
21441 !c &' has received correlation contribution from processor',fg_rank+1,
21442 !c & ' msglen=',msglen,' nbytes=',nbytes
21443 !c write (*,*) 'The received BUFFER array:'
21445 !c write (*,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,60)
21447 if (msglen.eq.msglen1) then
21448 call unpack_buffer(max_cont,max_dim,iatel_e_nucl+1,0,buffer)
21449 else if (msglen.eq.msglen2) then
21450 call unpack_buffer(max_cont,max_dim,iatel_e_nucl,0,buffer)
21451 call unpack_buffer(max_cont,max_dim,iatel_e_nucl+1,30,buffer)
21454 'ERROR!!!! message length changed while processing correlations.'
21456 'ERROR!!!! message length changed while processing correlations.'
21457 call MPI_Abort(MPI_COMM_WORLD,Error,IERROR)
21458 endif ! msglen.eq.msglen1
21459 endif ! fg_rank.lt.nfgtasks-1
21466 write (iout,'(a)') 'Contact function values:'
21467 do i=nnt_molec(2),nct_molec(2)-1
21468 write (iout,'(2i3,50(1x,i2,f5.2))') &
21469 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i), &
21470 j=1,num_cont_hb(i))
21475 !C Remove the loop below after debugging !!!
21476 ! do i=nnt_molec(2),nct_molec(2)
21478 ! gradcorr_nucl(j,i)=0.0D0
21479 ! gradxorr_nucl(j,i)=0.0D0
21480 ! gradcorr3_nucl(j,i)=0.0D0
21481 ! gradxorr3_nucl(j,i)=0.0D0
21484 ! print *,"iatsc_s_nucl,iatsc_e_nucl",iatsc_s_nucl,iatsc_e_nucl
21485 !C Calculate the local-electrostatic correlation terms
21486 do i=iatsc_s_nucl,iatsc_e_nucl
21488 num_conti=num_cont_hb(i)
21489 num_conti1=num_cont_hb(i+1)
21490 ! print *,i,num_conti,num_conti1
21495 !c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
21496 !c & ' jj=',jj,' kk=',kk
21497 if (j1.eq.j+1 .or. j1.eq.j-1) then
21499 !C Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
21500 !C The system gains extra energy.
21501 !C Tentative expression & coefficients; assumed d(stacking)=4.5 A,
21502 !C parallel dipoles of stacknig bases and sin(mui)sin(muj)/eps/d^3=0.7
21503 !C Need to implement full formulas 34 and 35 from Liwo et al., 1998.
21505 ecorr=ecorr+ehbcorr_nucl(i,j,i+1,j1,jj,kk,0.528D0,0.132D0)
21506 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
21507 'ecorrh',i,j,ehbcorr_nucl(i,j,i+1,j1,jj,kk,0.528D0,0.132D0)
21509 else if (j1.eq.j) then
21511 !C Contacts I-J and I-(J+1) occur simultaneously.
21512 !C The system loses extra energy.
21513 !C Tentative expression & c?oefficients; assumed d(stacking)=4.5 A,
21514 !C parallel dipoles of stacknig bases and sin(mui)sin(muj)/eps/d^3=0.7
21515 !C Need to implement full formulas 32 from Liwo et al., 1998.
21517 !c write (iout,*) 'ecorr3: i=',i,' j=',j,' i1=',i1,' j1=',j1,
21518 !c & ' jj=',jj,' kk=',kk
21519 ecorr3=ecorr3+ehbcorr3_nucl(i,j,i+1,j,jj,kk,0.310D0,-0.155D0)
21524 !c write (iout,*) 'ecorr3: i=',i,' j=',j,' i1=',i1,' j1=',j1,
21525 !c & ' jj=',jj,' kk=',kk
21526 if (j1.eq.j+1) then
21527 !C Contacts I-J and (I+1)-J occur simultaneously.
21528 !C The system loses extra energy.
21529 ecorr3=ecorr3+ehbcorr3_nucl(i,j,i,j+1,jj,kk,0.310D0,-0.155D0)
21535 end subroutine multibody_hb_nucl
21536 !-----------------------------------------------------------
21537 real(kind=8) function ehbcorr_nucl(i,j,k,l,jj,kk,coeffp,coeffm)
21538 ! implicit real*8 (a-h,o-z)
21539 ! include 'DIMENSIONS'
21540 ! include 'COMMON.IOUNITS'
21541 ! include 'COMMON.DERIV'
21542 ! include 'COMMON.INTERACT'
21543 ! include 'COMMON.CONTACTS'
21544 real(kind=8),dimension(3) :: gx,gx1
21546 !el local variables
21547 integer :: i,j,k,l,jj,kk,ll,ilist,m, iresshield
21548 real(kind=8) :: coeffp,coeffm,eij,ekl,ees0pij,ees0pkl,ees0mij,&
21549 ees0mkl,ees,coeffpees0pij,coeffmees0mij,&
21550 coeffpees0pkl,coeffmees0mkl,gradlongij,gradlongkl, &
21554 eij=facont_hb(jj,i)
21555 ekl=facont_hb(kk,k)
21556 ees0pij=ees0p(jj,i)
21557 ees0pkl=ees0p(kk,k)
21558 ees0mij=ees0m(jj,i)
21559 ees0mkl=ees0m(kk,k)
21561 ees=-(coeffp*ees0pij*ees0pkl+coeffm*ees0mij*ees0mkl)
21562 ! print *,"ehbcorr_nucl",ekont,ees
21563 !cd ees=-(coeffp*ees0pkl+coeffm*ees0mkl)
21564 !C Following 4 lines for diagnostics.
21569 !cd write (iout,*)'Contacts have occurred for nucleic bases',
21570 !cd & i,j,' fcont:',eij,' eij',' eesij',ees0pij,ees0mij,' and ',k,l
21571 !cd & ,' fcont ',ekl,' eeskl',ees0pkl,ees0mkl,' ees=',ees
21572 !C Calculate the multi-body contribution to energy.
21573 ! ecorr_nucl=ecorr_nucl+ekont*ees
21574 !C Calculate multi-body contributions to the gradient.
21575 coeffpees0pij=coeffp*ees0pij
21576 coeffmees0mij=coeffm*ees0mij
21577 coeffpees0pkl=coeffp*ees0pkl
21578 coeffmees0mkl=coeffm*ees0mkl
21580 gradxorr_nucl(ll,i)=gradxorr_nucl(ll,i) &
21581 -ekont*(coeffpees0pkl*gacontp_hb1(ll,jj,i)+&
21582 coeffmees0mkl*gacontm_hb1(ll,jj,i))
21583 gradxorr_nucl(ll,j)=gradxorr_nucl(ll,j) &
21584 -ekont*(coeffpees0pkl*gacontp_hb2(ll,jj,i)+&
21585 coeffmees0mkl*gacontm_hb2(ll,jj,i))
21586 gradxorr_nucl(ll,k)=gradxorr_nucl(ll,k) &
21587 -ekont*(coeffpees0pij*gacontp_hb1(ll,kk,k)+&
21588 coeffmees0mij*gacontm_hb1(ll,kk,k))
21589 gradxorr_nucl(ll,l)=gradxorr_nucl(ll,l) &
21590 -ekont*(coeffpees0pij*gacontp_hb2(ll,kk,k)+ &
21591 coeffmees0mij*gacontm_hb2(ll,kk,k))
21592 gradlongij=ees*ekl*gacont_hbr(ll,jj,i)- &
21593 ekont*(coeffpees0pkl*gacontp_hb3(ll,jj,i)+ &
21594 coeffmees0mkl*gacontm_hb3(ll,jj,i))
21595 gradcorr_nucl(ll,j)=gradcorr_nucl(ll,j)+gradlongij
21596 gradcorr_nucl(ll,i)=gradcorr_nucl(ll,i)-gradlongij
21597 gradlongkl=ees*eij*gacont_hbr(ll,kk,k)- &
21598 ekont*(coeffpees0pij*gacontp_hb3(ll,kk,k)+ &
21599 coeffmees0mij*gacontm_hb3(ll,kk,k))
21600 gradcorr_nucl(ll,l)=gradcorr_nucl(ll,l)+gradlongkl
21601 gradcorr_nucl(ll,k)=gradcorr_nucl(ll,k)-gradlongkl
21602 gradxorr_nucl(ll,i)=gradxorr_nucl(ll,i)-gradlongij
21603 gradxorr_nucl(ll,j)=gradxorr_nucl(ll,j)+gradlongij
21604 gradxorr_nucl(ll,k)=gradxorr_nucl(ll,k)-gradlongkl
21605 gradxorr_nucl(ll,l)=gradxorr_nucl(ll,l)+gradlongkl
21607 ehbcorr_nucl=ekont*ees
21609 end function ehbcorr_nucl
21610 !-------------------------------------------------------------------------
21612 real(kind=8) function ehbcorr3_nucl(i,j,k,l,jj,kk,coeffp,coeffm)
21613 ! implicit real*8 (a-h,o-z)
21614 ! include 'DIMENSIONS'
21615 ! include 'COMMON.IOUNITS'
21616 ! include 'COMMON.DERIV'
21617 ! include 'COMMON.INTERACT'
21618 ! include 'COMMON.CONTACTS'
21619 real(kind=8),dimension(3) :: gx,gx1
21621 !el local variables
21622 integer :: i,j,k,l,jj,kk,ll,ilist,m, iresshield
21623 real(kind=8) :: coeffp,coeffm,eij,ekl,ees0pij,ees0pkl,ees0mij,&
21624 ees0mkl,ees,coeffpees0pij,coeffmees0mij,&
21625 coeffpees0pkl,coeffmees0mkl,gradlongij,gradlongkl, &
21629 eij=facont_hb(jj,i)
21630 ekl=facont_hb(kk,k)
21631 ees0pij=ees0p(jj,i)
21632 ees0pkl=ees0p(kk,k)
21633 ees0mij=ees0m(jj,i)
21634 ees0mkl=ees0m(kk,k)
21636 ees=-(coeffp*ees0pij*ees0pkl+coeffm*ees0mij*ees0mkl)
21637 !cd ees=-(coeffp*ees0pkl+coeffm*ees0mkl)
21638 !C Following 4 lines for diagnostics.
21643 !cd write (iout,*)'Contacts have occurred for nucleic bases',
21644 !cd & i,j,' fcont:',eij,' eij',' eesij',ees0pij,ees0mij,' and ',k,l
21645 !cd & ,' fcont ',ekl,' eeskl',ees0pkl,ees0mkl,' ees=',ees
21646 !C Calculate the multi-body contribution to energy.
21647 ! ecorr=ecorr+ekont*ees
21648 !C Calculate multi-body contributions to the gradient.
21649 coeffpees0pij=coeffp*ees0pij
21650 coeffmees0mij=coeffm*ees0mij
21651 coeffpees0pkl=coeffp*ees0pkl
21652 coeffmees0mkl=coeffm*ees0mkl
21654 gradxorr3_nucl(ll,i)=gradxorr3_nucl(ll,i) &
21655 -ekont*(coeffpees0pkl*gacontp_hb1(ll,jj,i)+&
21656 coeffmees0mkl*gacontm_hb1(ll,jj,i))
21657 gradxorr3_nucl(ll,j)=gradxorr3_nucl(ll,j) &
21658 -ekont*(coeffpees0pkl*gacontp_hb2(ll,jj,i)+ &
21659 coeffmees0mkl*gacontm_hb2(ll,jj,i))
21660 gradxorr3_nucl(ll,k)=gradxorr3_nucl(ll,k) &
21661 -ekont*(coeffpees0pij*gacontp_hb1(ll,kk,k)+ &
21662 coeffmees0mij*gacontm_hb1(ll,kk,k))
21663 gradxorr3_nucl(ll,l)=gradxorr3_nucl(ll,l) &
21664 -ekont*(coeffpees0pij*gacontp_hb2(ll,kk,k)+ &
21665 coeffmees0mij*gacontm_hb2(ll,kk,k))
21666 gradlongij=ees*ekl*gacont_hbr(ll,jj,i)- &
21667 ekont*(coeffpees0pkl*gacontp_hb3(ll,jj,i)+ &
21668 coeffmees0mkl*gacontm_hb3(ll,jj,i))
21669 gradcorr3_nucl(ll,j)=gradcorr3_nucl(ll,j)+gradlongij
21670 gradcorr3_nucl(ll,i)=gradcorr3_nucl(ll,i)-gradlongij
21671 gradlongkl=ees*eij*gacont_hbr(ll,kk,k)- &
21672 ekont*(coeffpees0pij*gacontp_hb3(ll,kk,k)+ &
21673 coeffmees0mij*gacontm_hb3(ll,kk,k))
21674 gradcorr3_nucl(ll,l)=gradcorr3_nucl(ll,l)+gradlongkl
21675 gradcorr3_nucl(ll,k)=gradcorr3_nucl(ll,k)-gradlongkl
21676 gradxorr3_nucl(ll,i)=gradxorr3_nucl(ll,i)-gradlongij
21677 gradxorr3_nucl(ll,j)=gradxorr3_nucl(ll,j)+gradlongij
21678 gradxorr3_nucl(ll,k)=gradxorr3_nucl(ll,k)-gradlongkl
21679 gradxorr3_nucl(ll,l)=gradxorr3_nucl(ll,l)+gradlongkl
21681 ehbcorr3_nucl=ekont*ees
21683 end function ehbcorr3_nucl
21685 subroutine pack_buffer(dimen1,dimen2,atom,indx,buffer)
21686 integer dimen1,dimen2,atom,indx,numcont,i,ii,k,j,num_kont,num_kont_old
21687 real(kind=8):: buffer(dimen1,dimen2)
21688 num_kont=num_cont_hb(atom)
21692 buffer(i,indx+(k-1)*3+j)=zapas2(j,i,atom,k)
21695 buffer(i,indx+25)=facont_hb(i,atom)
21696 buffer(i,indx+26)=ees0p(i,atom)
21697 buffer(i,indx+27)=ees0m(i,atom)
21698 buffer(i,indx+28)=d_cont(i,atom)
21699 buffer(i,indx+29)=dfloat(jcont_hb(i,atom))
21701 buffer(1,indx+30)=dfloat(num_kont)
21703 end subroutine pack_buffer
21704 !c------------------------------------------------------------------------------
21705 subroutine unpack_buffer(dimen1,dimen2,atom,indx,buffer)
21706 integer dimen1,dimen2,atom,indx,numcont,i,ii,k,j,num_kont,num_kont_old
21707 real(kind=8):: buffer(dimen1,dimen2)
21708 ! double precision zapas
21709 ! common /contacts_hb/ zapas(3,maxconts,maxres,8),
21710 ! & facont_hb(maxconts,maxres),ees0p(maxconts,maxres),
21711 ! & ees0m(maxconts,maxres),d_cont(maxconts,maxres),
21712 ! & num_cont_hb(maxres),jcont_hb(maxconts,maxres)
21713 num_kont=buffer(1,indx+30)
21714 num_kont_old=num_cont_hb(atom)
21715 num_cont_hb(atom)=num_kont+num_kont_old
21720 zapas2(j,ii,atom,k)=buffer(i,indx+(k-1)*3+j)
21723 facont_hb(ii,atom)=buffer(i,indx+25)
21724 ees0p(ii,atom)=buffer(i,indx+26)
21725 ees0m(ii,atom)=buffer(i,indx+27)
21726 d_cont(i,atom)=buffer(i,indx+28)
21727 jcont_hb(ii,atom)=buffer(i,indx+29)
21730 end subroutine unpack_buffer
21731 !c------------------------------------------------------------------------------
21733 subroutine ecatcat(ecationcation)
21734 integer :: i,j,itmp,xshift,yshift,zshift,subchap,k
21735 real(kind=8) :: xi,yi,zi,xj,yj,zj,ract,rcat0,epscalc,r06,r012,&
21736 r7,r4,ecationcation,k0,rcal
21737 real(kind=8) xj_temp,yj_temp,zj_temp,xj_safe,yj_safe,zj_safe, &
21738 dist_init,dist_temp,Evan1cat,Evan2cat,Eeleccat
21739 real(kind=8),dimension(3) ::dEvan1Cmcat,dEvan2Cmcat,dEeleccat,&
21742 ecationcation=0.0d0
21743 if (nres_molec(5).eq.0) return
21748 k0 = 332.0*(2.0*2.0)/80.0
21751 itmp=itmp+nres_molec(i)
21753 do i=itmp+1,itmp+nres_molec(5)-1
21758 xi=mod(xi,boxxsize)
21759 if (xi.lt.0) xi=xi+boxxsize
21760 yi=mod(yi,boxysize)
21761 if (yi.lt.0) yi=yi+boxysize
21762 zi=mod(zi,boxzsize)
21763 if (zi.lt.0) zi=zi+boxzsize
21765 do j=i+1,itmp+nres_molec(5)
21766 ! print *,i,j,'catcat'
21770 xj=dmod(xj,boxxsize)
21771 if (xj.lt.0) xj=xj+boxxsize
21772 yj=dmod(yj,boxysize)
21773 if (yj.lt.0) yj=yj+boxysize
21774 zj=dmod(zj,boxzsize)
21775 if (zj.lt.0) zj=zj+boxzsize
21776 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
21784 xj=xj_safe+xshift*boxxsize
21785 yj=yj_safe+yshift*boxysize
21786 zj=zj_safe+zshift*boxzsize
21787 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
21788 if(dist_temp.lt.dist_init) then
21789 dist_init=dist_temp
21798 if (subchap.eq.1) then
21807 rcal =xj**2+yj**2+zj**2
21813 ! k0 = 332*(2*2)/80
21814 Evan1cat=epscalc*(r012/rcal**6)
21815 Evan2cat=epscalc*2*(r06/rcal**3)
21823 dEvan1Cmcat(k)=-12*r(k)*epscalc*r012/r7
21824 dEvan2Cmcat(k)=-12*r(k)*epscalc*r06/r4
21825 dEeleccat(k)=-k0*r(k)/ract**3
21828 gg(k) = dEvan1Cmcat(k)+dEvan2Cmcat(k)+dEeleccat(k)
21829 gradcatcat(k,i)=gradcatcat(k,i)-gg(k)
21830 gradcatcat(k,j)=gradcatcat(k,j)+gg(k)
21833 ecationcation=ecationcation+Evan1cat+Evan2cat+Eeleccat
21837 end subroutine ecatcat
21838 !---------------------------------------------------------------------------
21839 subroutine ecat_prot(ecation_prot)
21840 integer i,j,k,subchap,itmp,inum
21841 real(kind=8) :: xi,yi,zi,xj,yj,zj,ract,rcat0,epscalc,r06,r012,&
21842 r7,r4,ecationcation
21843 real(kind=8) xj_temp,yj_temp,zj_temp,xj_safe,yj_safe,zj_safe, &
21844 dist_init,dist_temp,ecation_prot,rcal,rocal, &
21845 Evan1,Evan2,EC,cm1mag,DASGL,delta,r0p,Epepcat, &
21846 catl,cml,calpl, Etotal_p, Etotal_m,rtab,wdip,wmodquad,wquad1, &
21847 wquad2,wvan1,E1,E2,wconst,wvan2,rcpm,dcmag,sin2thet,sinthet, &
21848 costhet,v1m,v2m,wh2o,wc,rsecp,Ir,Irsecp,Irthrp,Irfourp,Irfiftp,&
21849 Irsistp,Irseven,Irtwelv,Irthir,dE1dr,dE2dr,dEdcos,wquad2p,opt, &
21850 rs,rthrp,rfourp,rsixp,reight,Irsixp,Ireight,Irtw,Irfourt, &
21851 opt1,opt2,opt3,opt4,opt5,opt6,opt7,opt8,opt9,opt10,opt11,opt12,&
21852 opt13,opt14,opt15,opt16,opt17,opt18,opt19, &
21853 Equad1,Equad2,dscmag,v1dpv2,dscmag3,constA,constB,Edip
21854 real(kind=8),dimension(3) ::dEvan1Cmcat,dEvan2Cmcat,dEeleccat,&
21855 gg,r,EtotalCat,dEtotalCm,dEtotalCalp,dEvan1Cm,dEvan2Cm, &
21856 dEtotalpep,dEtotalcat_num,dEddci,dEtotalcm_num,dEtotalcalp_num, &
21857 tab1,tab2,tab3,diff,cm1,sc,p,tcat,talp,cm,drcp,drcp_norm,vcat, &
21858 v1,v2,v3,myd_norm,dx,vcm,valpha,drdpep,dcosdpep,dcosddci,dEdpep,&
21859 dEcCat,dEdipCm,dEdipCalp,dEquad1Cat,dEquad1Cm,dEquad1Calp, &
21860 dEquad2Cat,dEquad2Cm,dEquad2Calpd,Evan1Cat,dEvan1Calp,dEvan2Cat,&
21861 dEvan2Calp,dEtotalCat,dscvec,dEcCm,dEcCalp,dEdipCat,dEquad2Calp,&
21863 real(kind=8),dimension(6) :: vcatprm
21865 ! first lets calculate interaction with peptide groups
21866 if (nres_molec(5).eq.0) return
21868 wdip =1.092777950857032D2
21870 wmodquad=-2.174122713004870D4
21871 wmodquad=wmodquad/wconst
21872 wquad1 = 3.901232068562804D1
21873 wquad1=wquad1/wconst
21875 wquad2=wquad2/wconst
21880 itmp=itmp+nres_molec(i)
21882 ! do i=1,nres_molec(1)-1 ! loop over all peptide groups needs parralelization
21883 do i=ibond_start,ibond_end
21885 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1)) cycle ! leave dummy atoms
21886 xi=0.5d0*(c(1,i)+c(1,i+1))
21887 yi=0.5d0*(c(2,i)+c(2,i+1))
21888 zi=0.5d0*(c(3,i)+c(3,i+1))
21889 xi=mod(xi,boxxsize)
21890 if (xi.lt.0) xi=xi+boxxsize
21891 yi=mod(yi,boxysize)
21892 if (yi.lt.0) yi=yi+boxysize
21893 zi=mod(zi,boxzsize)
21894 if (zi.lt.0) zi=zi+boxzsize
21896 do j=itmp+1,itmp+nres_molec(5)
21900 xj=dmod(xj,boxxsize)
21901 if (xj.lt.0) xj=xj+boxxsize
21902 yj=dmod(yj,boxysize)
21903 if (yj.lt.0) yj=yj+boxysize
21904 zj=dmod(zj,boxzsize)
21905 if (zj.lt.0) zj=zj+boxzsize
21906 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
21914 xj=xj_safe+xshift*boxxsize
21915 yj=yj_safe+yshift*boxysize
21916 zj=zj_safe+zshift*boxzsize
21917 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
21918 if(dist_temp.lt.dist_init) then
21919 dist_init=dist_temp
21928 if (subchap.eq.1) then
21939 rcpm = sqrt(xj**2+yj**2+zj**2)
21940 drcp_norm(1)=xj/rcpm
21941 drcp_norm(2)=yj/rcpm
21942 drcp_norm(3)=zj/rcpm
21945 dcmag=dcmag+dc(k,i)**2
21949 myd_norm(k)=dc(k,i)/dcmag
21951 costhet=drcp_norm(1)*myd_norm(1)+drcp_norm(2)*myd_norm(2)+&
21952 drcp_norm(3)*myd_norm(3)
21955 Irsecp = 1.0d0/rsecp
21956 Irthrp = Irsecp/rcpm
21957 Irfourp = Irthrp/rcpm
21958 Irfiftp = Irfourp/rcpm
21959 Irsistp=Irfiftp/rcpm
21960 Irseven=Irsistp/rcpm
21961 Irtwelv=Irsistp*Irsistp
21962 Irthir=Irtwelv/rcpm
21963 sin2thet = (1-costhet*costhet)
21964 sinthet=sqrt(sin2thet)
21965 E1 = wdip*Irsecp*costhet+(wmodquad*Irfourp+wquad1*Irthrp)&
21967 E2 = -wquad1*Irthrp*wquad2+wvan1*(wvan2**12*Irtwelv-&
21968 2*wvan2**6*Irsistp)
21969 ecation_prot = ecation_prot+E1+E2
21970 dE1dr = -2*costhet*wdip*Irthrp-&
21971 (4*wmodquad*Irfiftp+3*wquad1*Irfourp)*sin2thet
21972 dE2dr = 3*wquad1*wquad2*Irfourp- &
21973 12*wvan1*wvan2**6*(wvan2**6*Irthir-Irseven)
21974 dEdcos = wdip*Irsecp-2*(wmodquad*Irfourp+wquad1*Irthrp)*costhet
21976 drdpep(k) = -drcp_norm(k)
21977 dcosdpep(k) = Ir*(costhet*drcp_norm(k)-myd_norm(k))
21978 dcosddci(k) = drcp_norm(k)/dcmag-costhet*myd_norm(k)/dcmag
21979 dEdpep(k) = (dE1dr+dE2dr)*drdpep(k)+dEdcos*dcosdpep(k)
21980 dEddci(k) = dEdcos*dcosddci(k)
21983 gradpepcat(k,i)=gradpepcat(k,i)+0.5D0*dEdpep(k)-dEddci(k)
21984 gradpepcat(k,i+1)=gradpepcat(k,i+1)+0.5D0*dEdpep(k)+dEddci(k)
21985 gradpepcat(k,j)=gradpepcat(k,j)-dEdpep(k)
21989 !------------------------------------------sidechains
21990 ! do i=1,nres_molec(1)
21991 do i=ibond_start,ibond_end
21992 if ((itype(i,1).eq.ntyp1)) cycle ! leave dummy atoms
21994 ! print *,i,ecation_prot
21998 xi=mod(xi,boxxsize)
21999 if (xi.lt.0) xi=xi+boxxsize
22000 yi=mod(yi,boxysize)
22001 if (yi.lt.0) yi=yi+boxysize
22002 zi=mod(zi,boxzsize)
22003 if (zi.lt.0) zi=zi+boxzsize
22005 cm1(k)=dc(k,i+nres)
22007 cm1mag=sqrt(cm1(1)**2+cm1(2)**2+cm1(3)**2)
22008 do j=itmp+1,itmp+nres_molec(5)
22012 xj=dmod(xj,boxxsize)
22013 if (xj.lt.0) xj=xj+boxxsize
22014 yj=dmod(yj,boxysize)
22015 if (yj.lt.0) yj=yj+boxysize
22016 zj=dmod(zj,boxzsize)
22017 if (zj.lt.0) zj=zj+boxzsize
22018 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
22026 xj=xj_safe+xshift*boxxsize
22027 yj=yj_safe+yshift*boxysize
22028 zj=zj_safe+zshift*boxzsize
22029 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
22030 if(dist_temp.lt.dist_init) then
22031 dist_init=dist_temp
22040 if (subchap.eq.1) then
22051 if(itype(i,1).eq.15.or.itype(i,1).eq.16) then
22052 if(itype(i,1).eq.16) then
22058 vcatprm(k)=catprm(k,inum)
22060 dASGL=catprm(7,inum)
22062 vcm(k)=(cm1(k)/cm1mag)*dASGL+c(k,i+nres)
22067 dx(k) = vcat(k)-vcm(k)
22070 v1(k)=(vcm(k)-valpha(k))
22071 v2(k)=(vcat(k)-valpha(k))
22073 v1m = sqrt(v1(1)**2+v1(2)**2+v1(3)**2)
22074 v2m = sqrt(v2(1)**2+v2(2)**2+v2(3)**2)
22075 v1dpv2 = v1(1)*v2(1)+v1(2)*v2(2)+v1(3)*v2(3)
22077 ! The weights of the energy function calculated from
22078 !The quantum mechanical GAMESS simulations of calcium with ASP/GLU
22086 wquad2 = vcatprm(4)
22091 opt = dx(1)**2+dx(2)**2
22092 rsecp = opt+dx(3)**2
22096 rsixp = rfourp*rsecp
22101 Irfourp = Irthrp/rs
22107 opt1 = (4*rs*dx(3)*wdip)
22108 opt2 = 6*rsecp*wquad1*opt
22109 opt3 = wquad1*wquad2p*Irsixp
22110 opt4 = (wvan1*wvan2**12)
22111 opt5 = opt4*12*Irfourt
22112 opt6 = 2*wvan1*wvan2**6
22113 opt7 = 6*opt6*Ireight
22116 opt11 = (rsecp*v2m)**2
22117 opt12 = (rsecp*v1m)**2
22118 opt14 = (v1m*v2m*rsecp)**2
22119 opt15 = -wquad1/v2m**2
22120 opt16 = (rthrp*(v1m*v2m)**2)**2
22121 opt17 = (v1m**2*rthrp)**2
22122 opt18 = -wquad1/rthrp
22123 opt19 = (v1m**2*v2m**2)**2
22126 dEcCat(k) = -(dx(k)*wc)*Irthrp
22127 dEcCm(k)=(dx(k)*wc)*Irthrp
22130 Edip=opt8*(v1dpv2)/(rsecp*v2m)
22132 dEdipCat(k)=opt8*(v1(k)*rsecp*v2m-((v2(k)/v2m &
22133 *rsecp+2*dx(k)*v2m)*v1dpv2))/opt11
22134 dEdipCm(k)=opt10*(v2(k)*rsecp*v1m-((v1(k)/v1m &
22135 *rsecp-2*dx(k)*v1m)*v1dpv2))/opt12
22136 dEdipCalp(k)=wdip*((-v1(k)-v2(k))*rsecp*v1m &
22137 *v2m-(-v1(k)/v1m*v2m*rsecp-v2(k)/v2m*v1m*rsecp) &
22140 Equad1=-wquad1*v1dpv2**2/(rthrp*(v1m*v2m)**2)
22142 dEquad1Cat(k)=-wquad1*(2*v1(k)*v1dpv2*(rthrp* &
22143 (v1m*v2m)**2)-(3*dx(k)*rs*(v1m*v2m)**2+2*v1m*2* &
22144 v2(k)*1/2*1/v2m*v1m*v2m*rthrp)*v1dpv2**2)/opt16
22145 dEquad1Cm(k)=-wquad1*(2*v2(k)*v1dpv2*(rthrp* &
22146 (v1m*v2m)**2)-(-3*dx(k)*rs*(v1m*v2m)**2+2*v2m*2* &
22147 v1(k)*1/2*1/v1m*v2m*v1m*rthrp)*v1dpv2**2)/opt16
22148 dEquad1Calp(k)=opt18*(2*(-v1(k)-v2(k))*v1dpv2* &
22149 v1m**2*v2m**2-(-2*v1(k)*v2m**2-2*v2(k)*v1m**2)* &
22152 Equad2=wquad1*wquad2p*Irthrp
22154 dEquad2Cat(k)=-3*dx(k)*rs*opt3
22155 dEquad2Cm(k)=3*dx(k)*rs*opt3
22156 dEquad2Calp(k)=0.0d0
22160 dEvan1Cat(k)=-dx(k)*opt5
22161 dEvan1Cm(k)=dx(k)*opt5
22162 dEvan1Calp(k)=0.0d0
22166 dEvan2Cat(k)=dx(k)*opt7
22167 dEvan2Cm(k)=-dx(k)*opt7
22168 dEvan2Calp(k)=0.0d0
22170 ecation_prot=ecation_prot+Ec+Edip+Equad1+Equad2+Evan1+Evan2
22171 ! print *,ecation_prot,Ec+Edip+Equad1+Equad2+Evan1+Evan2
22174 dEtotalCat(k)=dEcCat(k)+dEdipCat(k)+dEquad1Cat(k)+ &
22175 dEquad2Cat(k)+dEvan1Cat(k)+dEvan2Cat(k)
22176 !c write(*,*) 'dEtotalCat inside', (dEtotalCat(l),l=1,3)
22177 dEtotalCm(k)=dEcCm(k)+dEdipCm(k)+dEquad1Cm(k)+ &
22178 dEquad2Cm(k)+dEvan1Cm(k)+dEvan2Cm(k)
22179 dEtotalCalp(k)=dEcCalp(k)+dEdipCalp(k)+dEquad1Calp(k) &
22180 +dEquad2Calp(k)+dEvan1Calp(k)+dEvan2Calp(k)
22184 dscvec(k) = dc(k,i+nres)
22185 dscmag = dscmag+dscvec(k)*dscvec(k)
22188 dscmag = sqrt(dscmag)
22189 dscmag3 = dscmag3*dscmag
22190 constA = 1.0d0+dASGL/dscmag
22193 constB = constB+dscvec(k)*dEtotalCm(k)
22195 constB = constB*dASGL/dscmag3
22197 gg(k) = dEtotalCm(k)+dEtotalCalp(k)
22198 gradpepcatx(k,i)=gradpepcatx(k,i)+ &
22199 constA*dEtotalCm(k)-constB*dscvec(k)
22200 ! print *,j,constA,dEtotalCm(k),constB,dscvec(k)
22201 gradpepcat(k,i)=gradpepcat(k,i)+gg(k)
22202 gradpepcat(k,j)=gradpepcat(k,j)+dEtotalCat(k)
22204 else if (itype(i,1).eq.13.or.itype(i,1).eq.14) then
22205 if(itype(i,1).eq.14) then
22211 vcatprm(k)=catprm(k,inum)
22213 dASGL=catprm(7,inum)
22215 vcm(k)=(cm1(k)/cm1mag)*dASGL+c(k,i+nres)
22221 dx(k) = vcat(k)-vcm(k)
22224 v1(k)=(vcm(k)-valpha(k))
22225 v2(k)=(vcat(k)-valpha(k))
22227 v1m = sqrt(v1(1)**2+v1(2)**2+v1(3)**2)
22228 v2m = sqrt(v2(1)**2+v2(2)**2+v2(3)**2)
22229 v1dpv2 = v1(1)*v2(1)+v1(2)*v2(2)+v1(3)*v2(3)
22230 ! The weights of the energy function calculated from
22231 !The quantum mechanical GAMESS simulations of ASN/GLN with calcium
22237 wquad2 = vcatprm(4)
22242 opt = dx(1)**2+dx(2)**2
22243 rsecp = opt+dx(3)**2
22247 rsixp = rfourp*rsecp
22252 Irfourp = Irthrp/rs
22258 opt1 = (4*rs*dx(3)*wdip)
22259 opt2 = 6*rsecp*wquad1*opt
22260 opt3 = wquad1*wquad2p*Irsixp
22261 opt4 = (wvan1*wvan2**12)
22262 opt5 = opt4*12*Irfourt
22263 opt6 = 2*wvan1*wvan2**6
22264 opt7 = 6*opt6*Ireight
22267 opt11 = (rsecp*v2m)**2
22268 opt12 = (rsecp*v1m)**2
22269 opt14 = (v1m*v2m*rsecp)**2
22270 opt15 = -wquad1/v2m**2
22271 opt16 = (rthrp*(v1m*v2m)**2)**2
22272 opt17 = (v1m**2*rthrp)**2
22273 opt18 = -wquad1/rthrp
22274 opt19 = (v1m**2*v2m**2)**2
22275 Edip=opt8*(v1dpv2)/(rsecp*v2m)
22277 dEdipCat(k)=opt8*(v1(k)*rsecp*v2m-((v2(k)/v2m&
22278 *rsecp+2*dx(k)*v2m)*v1dpv2))/opt11
22279 dEdipCm(k)=opt10*(v2(k)*rsecp*v1m-((v1(k)/v1m&
22280 *rsecp-2*dx(k)*v1m)*v1dpv2))/opt12
22281 dEdipCalp(k)=wdip*((-v1(k)-v2(k))*rsecp*v1m&
22282 *v2m-(-v1(k)/v1m*v2m*rsecp-v2(k)/v2m*v1m*rsecp)&
22285 Equad1=-wquad1*v1dpv2**2/(rthrp*(v1m*v2m)**2)
22287 dEquad1Cat(k)=-wquad1*(2*v1(k)*v1dpv2*(rthrp*&
22288 (v1m*v2m)**2)-(3*dx(k)*rs*(v1m*v2m)**2+2*v1m*2*&
22289 v2(k)*1/2*1/v2m*v1m*v2m*rthrp)*v1dpv2**2)/opt16
22290 dEquad1Cm(k)=-wquad1*(2*v2(k)*v1dpv2*(rthrp*&
22291 (v1m*v2m)**2)-(-3*dx(k)*rs*(v1m*v2m)**2+2*v2m*2*&
22292 v1(k)*1/2*1/v1m*v2m*v1m*rthrp)*v1dpv2**2)/opt16
22293 dEquad1Calp(k)=opt18*(2*(-v1(k)-v2(k))*v1dpv2* &
22294 v1m**2*v2m**2-(-2*v1(k)*v2m**2-2*v2(k)*v1m**2)*&
22297 Equad2=wquad1*wquad2p*Irthrp
22299 dEquad2Cat(k)=-3*dx(k)*rs*opt3
22300 dEquad2Cm(k)=3*dx(k)*rs*opt3
22301 dEquad2Calp(k)=0.0d0
22305 dEvan1Cat(k)=-dx(k)*opt5
22306 dEvan1Cm(k)=dx(k)*opt5
22307 dEvan1Calp(k)=0.0d0
22311 dEvan2Cat(k)=dx(k)*opt7
22312 dEvan2Cm(k)=-dx(k)*opt7
22313 dEvan2Calp(k)=0.0d0
22315 ecation_prot = ecation_prot+Edip+Equad1+Equad2+Evan1+Evan2
22317 dEtotalCat(k)=dEdipCat(k)+dEquad1Cat(k)+ &
22318 dEquad2Cat(k)+dEvan1Cat(k)+dEvan2Cat(k)
22319 dEtotalCm(k)=dEdipCm(k)+dEquad1Cm(k)+ &
22320 dEquad2Cm(k)+dEvan1Cm(k)+dEvan2Cm(k)
22321 dEtotalCalp(k)=dEdipCalp(k)+dEquad1Calp(k) &
22322 +dEquad2Calp(k)+dEvan1Calp(k)+dEvan2Calp(k)
22326 dscvec(k) = c(k,i+nres)-c(k,i)
22327 dscmag = dscmag+dscvec(k)*dscvec(k)
22330 dscmag = sqrt(dscmag)
22331 dscmag3 = dscmag3*dscmag
22332 constA = 1+dASGL/dscmag
22335 constB = constB+dscvec(k)*dEtotalCm(k)
22337 constB = constB*dASGL/dscmag3
22339 gg(k) = dEtotalCm(k)+dEtotalCalp(k)
22340 gradpepcatx(k,i)=gradpepcatx(k,i)+ &
22341 constA*dEtotalCm(k)-constB*dscvec(k)
22342 gradpepcat(k,i)=gradpepcat(k,i)+gg(k)
22343 gradpepcat(k,j)=gradpepcat(k,j)+dEtotalCat(k)
22348 r(k) = c(k,j)-c(k,i+nres)
22349 rcal = rcal+r(k)*r(k)
22354 r0p=0.5*(rocal+sig0(itype(i,1)))
22357 Evan1=epscalc*(r012/rcal**6)
22358 Evan2=epscalc*2*(r06/rcal**3)
22362 dEvan1Cm(k) = 12*r(k)*epscalc*r012/r7
22363 dEvan2Cm(k) = 12*r(k)*epscalc*r06/r4
22366 dEtotalCm(k)=dEvan1Cm(k)+dEvan2Cm(k)
22368 ecation_prot = ecation_prot+ Evan1+Evan2
22370 gradpepcatx(k,i)=gradpepcatx(k,i)+ &
22372 gradpepcat(k,i)=gradpepcat(k,i)+dEtotalCm(k)
22373 gradpepcat(k,j)=gradpepcat(k,j)-dEtotalCm(k)
22375 endif ! 13-16 residues
22379 end subroutine ecat_prot
22381 !----------------------------------------------------------------------------
22382 !-----------------------------------------------------------------------------
22383 !-----------------------------------------------------------------------------
22384 subroutine eprot_sc_base(escbase)
22386 ! implicit real*8 (a-h,o-z)
22387 ! include 'DIMENSIONS'
22388 ! include 'COMMON.GEO'
22389 ! include 'COMMON.VAR'
22390 ! include 'COMMON.LOCAL'
22391 ! include 'COMMON.CHAIN'
22392 ! include 'COMMON.DERIV'
22393 ! include 'COMMON.NAMES'
22394 ! include 'COMMON.INTERACT'
22395 ! include 'COMMON.IOUNITS'
22396 ! include 'COMMON.CALC'
22397 ! include 'COMMON.CONTROL'
22398 ! include 'COMMON.SBRIDGE'
22400 !el local variables
22401 integer :: iint,itypi,itypi1,itypj,subchap
22402 real(kind=8) :: rrij,xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
22403 real(kind=8) :: evdw,sig0ij
22404 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
22405 dist_temp, dist_init,aa,bb,ssgradlipi,ssgradlipj, &
22406 sslipi,sslipj,faclip
22408 real(kind=8) :: fracinbuf
22409 real (kind=8) :: escbase
22410 real (kind=8),dimension(4):: ener
22411 real(kind=8) :: b1,b2,b3,b4,egb,eps_in,eps_inout_fac,eps_out
22412 real(kind=8) :: ECL,Elj,Equad,Epol,eheadtail,rhead,dGCLOM2,&
22413 sqom1,sqom2,sqom12,c1,c2,c3,pom,Lambf,sparrow,&
22414 Chif,ChiLambf,bat,eagle,top,bot,botsq,Fcav,dtop,dFdR,dFdOM1,&
22415 dFdOM2,w1,w2,w3,dGCLdR,dFdL,dFdOM12,dbot ,&
22416 r1,eps_head,alphapol1,pis,facd2,d2,facd1,d1,erdxj,erdxi,federmaus,&
22417 dPOLdR1,dFGBdOM2,dFGBdR1,dPOLdFGB1,RR1,MomoFac1,hawk,d1i,d1j,&
22418 sig1,sig2,chis12,chis2,ee1,fgb1,a12sq,chis1
22419 real(kind=8),dimension(3,2)::chead,erhead_tail
22420 real(kind=8),dimension(3) :: Rhead_distance,ertail,erhead
22424 ! do i=1,nres_molec(1)
22425 do i=ibond_start,ibond_end
22426 if (itype(i,1).eq.ntyp1_molec(1)) cycle
22428 dxi = dc_norm(1,nres+i)
22429 dyi = dc_norm(2,nres+i)
22430 dzi = dc_norm(3,nres+i)
22431 dsci_inv = vbld_inv(i+nres)
22435 xi=mod(xi,boxxsize)
22436 if (xi.lt.0) xi=xi+boxxsize
22437 yi=mod(yi,boxysize)
22438 if (yi.lt.0) yi=yi+boxysize
22439 zi=mod(zi,boxzsize)
22440 if (zi.lt.0) zi=zi+boxzsize
22441 do j=nres_molec(1)+1,nres_molec(2)+nres_molec(1)
22443 if (itype(j,2).eq.ntyp1_molec(2))cycle
22447 xj=dmod(xj,boxxsize)
22448 if (xj.lt.0) xj=xj+boxxsize
22449 yj=dmod(yj,boxysize)
22450 if (yj.lt.0) yj=yj+boxysize
22451 zj=dmod(zj,boxzsize)
22452 if (zj.lt.0) zj=zj+boxzsize
22453 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
22462 xj=xj_safe+xshift*boxxsize
22463 yj=yj_safe+yshift*boxysize
22464 zj=zj_safe+zshift*boxzsize
22465 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
22466 if(dist_temp.lt.dist_init) then
22467 dist_init=dist_temp
22476 if (subchap.eq.1) then
22485 dxj = dc_norm( 1, nres+j )
22486 dyj = dc_norm( 2, nres+j )
22487 dzj = dc_norm( 3, nres+j )
22488 ! print *,i,j,itypi,itypj
22489 d1i = dhead_scbasei(itypi,itypj) !this is shift of dipole/charge
22490 d1j = dhead_scbasej(itypi,itypj) !this is shift of dipole/charge
22493 ! BetaT = 1.0d0 / (298.0d0 * Rb)
22495 sig0ij = sigma_scbase( itypi,itypj )
22496 chi1 = chi_scbase( itypi, itypj,1 )
22497 chi2 = chi_scbase( itypi, itypj,2 )
22500 chi12 = chi1 * chi2
22501 chip1 = chipp_scbase( itypi, itypj,1 )
22502 chip2 = chipp_scbase( itypi, itypj,2 )
22505 chip12 = chip1 * chip2
22506 ! not used by momo potential, but needed by sc_angular which is shared
22507 ! by all energy_potential subroutines
22511 a12sq = rborn_scbasei(itypi,itypj) * rborn_scbasej(itypi,itypj)
22512 ! a12sq = a12sq * a12sq
22513 ! charge of amino acid itypi is...
22514 chis1 = chis_scbase(itypi,itypj,1)
22515 chis2 = chis_scbase(itypi,itypj,2)
22516 chis12 = chis1 * chis2
22517 sig1 = sigmap1_scbase(itypi,itypj)
22518 sig2 = sigmap2_scbase(itypi,itypj)
22519 ! write (*,*) "sig1 = ", sig1
22520 ! write (*,*) "sig2 = ", sig2
22521 ! alpha factors from Fcav/Gcav
22522 b1 = alphasur_scbase(1,itypi,itypj)
22524 b2 = alphasur_scbase(2,itypi,itypj)
22525 b3 = alphasur_scbase(3,itypi,itypj)
22526 b4 = alphasur_scbase(4,itypi,itypj)
22527 ! used to determine whether we want to do quadrupole calculations
22529 eps_in = epsintab_scbase(itypi,itypj)
22530 if (eps_in.eq.0.0) eps_in=1.0
22531 eps_inout_fac = ( (1.0d0/eps_in) - (1.0d0/eps_out))
22532 ! write (*,*) "eps_inout_fac = ", eps_inout_fac
22533 !-------------------------------------------------------------------
22534 ! tail location and distance calculations
22536 ! location of polar head is computed by taking hydrophobic centre
22537 ! and moving by a d1 * dc_norm vector
22538 ! see unres publications for very informative images
22539 chead(k,1) = c(k, i+nres) + d1i * dc_norm(k, i+nres)
22540 chead(k,2) = c(k, j+nres) + d1j * dc_norm(k, j+nres)
22542 ! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
22543 ! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
22544 Rhead_distance(k) = chead(k,2) - chead(k,1)
22546 ! pitagoras (root of sum of squares)
22548 (Rhead_distance(1)*Rhead_distance(1)) &
22549 + (Rhead_distance(2)*Rhead_distance(2)) &
22550 + (Rhead_distance(3)*Rhead_distance(3)))
22551 !-------------------------------------------------------------------
22552 ! zero everything that should be zero'ed
22570 dscj_inv = vbld_inv(j+nres)
22571 ! print *,i,j,dscj_inv,dsci_inv
22572 ! rij holds 1/(distance of Calpha atoms)
22573 rrij = 1.0D0 / ( xj*xj + yj*yj + zj*zj)
22575 !----------------------------
22577 ! this should be in elgrad_init but om's are calculated by sc_angular
22578 ! which in turn is used by older potentials
22579 ! om = omega, sqom = om^2
22582 sqom12 = om12 * om12
22584 ! now we calculate EGB - Gey-Berne
22585 ! It will be summed up in evdwij and saved in evdw
22586 sigsq = 1.0D0 / sigsq
22587 sig = sig0ij * dsqrt(sigsq)
22588 ! rij_shift = 1.0D0 / rij - sig + sig0ij
22589 rij_shift = 1.0/rij - sig + sig0ij
22590 IF (rij_shift.le.0.0D0) THEN
22594 sigder = -sig * sigsq
22595 rij_shift = 1.0D0 / rij_shift
22596 fac = rij_shift**expon
22597 c1 = fac * fac * aa_scbase(itypi,itypj)
22599 c2 = fac * bb_scbase(itypi,itypj)
22601 evdwij = eps1 * eps2rt * eps3rt * ( c1 + c2 )
22602 eps2der = eps3rt * evdwij
22603 eps3der = eps2rt * evdwij
22604 ! evdwij = 4.0d0 * eps2rt * eps3rt * evdwij
22605 evdwij = eps2rt * eps3rt * evdwij
22606 c1 = c1 * eps1 * eps2rt**2 * eps3rt**2
22607 fac = -expon * (c1 + evdwij) * rij_shift
22608 sigder = fac * sigder
22610 ! Calculate distance derivative
22614 ! if (b2.gt.0.0) then
22615 fac = chis1 * sqom1 + chis2 * sqom2 &
22616 - 2.0d0 * chis12 * om1 * om2 * om12
22617 ! we will use pom later in Gcav, so dont mess with it!
22618 pom = 1.0d0 - chis1 * chis2 * sqom12
22619 Lambf = (1.0d0 - (fac / pom))
22620 Lambf = dsqrt(Lambf)
22621 sparrow = 1.0d0 / dsqrt(sig1**2.0d0 + sig2**2.0d0)
22622 ! write (*,*) "sparrow = ", sparrow
22623 Chif = 1.0d0/rij * sparrow
22624 ChiLambf = Chif * Lambf
22625 eagle = dsqrt(ChiLambf)
22626 bat = ChiLambf ** 11.0d0
22627 top = b1 * ( eagle + b2 * ChiLambf - b3 )
22628 bot = 1.0d0 + b4 * (ChiLambf ** 12.0d0)
22632 dtop = b1 * ((Lambf / (2.0d0 * eagle)) + (b2 * Lambf))
22633 dbot = 12.0d0 * b4 * bat * Lambf
22634 dFdR = ((dtop * bot - top * dbot) / botsq) * sparrow
22636 ! write (*,*) "dFcav/dR = ", dFdR
22637 dtop = b1 * ((Chif / (2.0d0 * eagle)) + (b2 * Chif))
22638 dbot = 12.0d0 * b4 * bat * Chif
22639 eagle = Lambf * pom
22640 dFdOM1 = -(chis1 * om1 - chis12 * om2 * om12) / (eagle)
22641 dFdOM2 = -(chis2 * om2 - chis12 * om1 * om12) / (eagle)
22642 dFdOM12 = chis12 * (chis1 * om1 * om12 - om2) &
22643 * (chis2 * om2 * om12 - om1) / (eagle * pom)
22645 dFdL = ((dtop * bot - top * dbot) / botsq)
22647 dCAVdOM1 = dFdL * ( dFdOM1 )
22648 dCAVdOM2 = dFdL * ( dFdOM2 )
22649 dCAVdOM12 = dFdL * ( dFdOM12 )
22654 ! eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
22655 ! eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
22656 ! eom12=evdwij*eps1_om12+eps2der*eps2rt_om12 &
22657 ! -2.0D0*alf12*eps3der+sigder*sigsq_om12
22658 ! print *,"EOMY",eom1,eom2,eom12
22659 ! erdxi = scalar( ertail(1), dC_norm(1,i+nres) )
22660 ! erdxj = scalar( ertail(1), dC_norm(1,j+nres) )
22662 ! facd1 = dtail(1,itypi,itypj) * vbld_inv(i+nres)
22663 ! facd2 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
22665 ! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
22666 ! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
22668 !-facd1*(ertail(k)-erdxi*dC_norm(k,i+nres))
22669 gvdwx_scbase(k,i) = gvdwx_scbase(k,i) &
22670 - (( dFdR + gg(k) ) * pom)
22671 ! +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
22672 ! +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
22673 ! & - ( dFdR * pom )
22675 !-facd2*(ertail(k)-erdxj*dC_norm(k,j+nres))
22676 gvdwx_scbase(k,j) = gvdwx_scbase(k,j) &
22677 + (( dFdR + gg(k) ) * pom)
22678 ! +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
22679 ! +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
22680 !c! & + ( dFdR * pom )
22682 gvdwc_scbase(k,i) = gvdwc_scbase(k,i) &
22683 - (( dFdR + gg(k) ) * ertail(k))
22684 !c! & - ( dFdR * ertail(k))
22686 gvdwc_scbase(k,j) = gvdwc_scbase(k,j) &
22687 + (( dFdR + gg(k) ) * ertail(k))
22688 !c! & + ( dFdR * ertail(k))
22691 !c! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
22692 !c! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
22699 if (wdipdip_scbase(2,itypi,itypj).gt.0.0d0) then
22700 w1 = wdipdip_scbase(1,itypi,itypj)
22701 w2 = -wdipdip_scbase(3,itypi,itypj)/2.0
22702 w3 = wdipdip_scbase(2,itypi,itypj)
22703 !c!-------------------------------------------------------------------
22705 fac = (om12 - 3.0d0 * om1 * om2)
22706 c1 = (w1 / (Rhead**3.0d0)) * fac
22707 c2 = (w2 / Rhead ** 6.0d0) &
22708 * (4.0d0 + fac * fac -3.0d0 * (sqom1 + sqom2))
22709 c3= (w3/ Rhead ** 6.0d0) &
22710 * (2.0d0 - 2.0d0*fac*fac +3.0d0*(sqom1 + sqom2))
22712 !c! write (*,*) "w1 = ", w1
22713 !c! write (*,*) "w2 = ", w2
22714 !c! write (*,*) "om1 = ", om1
22715 !c! write (*,*) "om2 = ", om2
22716 !c! write (*,*) "om12 = ", om12
22717 !c! write (*,*) "fac = ", fac
22718 !c! write (*,*) "c1 = ", c1
22719 !c! write (*,*) "c2 = ", c2
22720 !c! write (*,*) "Ecl = ", Ecl
22721 !c! write (*,*) "c2_1 = ", (w2 / Rhead ** 6.0d0)
22722 !c! write (*,*) "c2_2 = ",
22723 !c! & (4.0d0 + fac * fac -3.0d0 * (sqom1 + sqom2))
22724 !c!-------------------------------------------------------------------
22725 !c! dervative of ECL is GCL...
22727 c1 = (-3.0d0 * w1 * fac) / (Rhead ** 4.0d0)
22728 c2 = (-6.0d0 * w2) / (Rhead ** 7.0d0) &
22729 * (4.0d0 + fac * fac - 3.0d0 * (sqom1 + sqom2))
22730 c3= (-6.0d0 * w3) / (Rhead ** 7.0d0) &
22731 * (2.0d0 - 2.0d0*fac*fac +3.0d0*(sqom1 + sqom2))
22732 dGCLdR = c1 - c2 + c3
22734 c1 = (-3.0d0 * w1 * om2 ) / (Rhead**3.0d0)
22735 c2 = (-6.0d0 * w2) / (Rhead**6.0d0) &
22736 * ( om2 * om12 - 3.0d0 * om1 * sqom2 + om1 )
22737 c3 =(6.0d0*w3/ Rhead ** 6.0d0)*(om1-2.0d0*(fac)*(-om2))
22738 dGCLdOM1 = c1 - c2 + c3
22740 c1 = (-3.0d0 * w1 * om1 ) / (Rhead**3.0d0)
22741 c2 = (-6.0d0 * w2) / (Rhead**6.0d0) &
22742 * ( om1 * om12 - 3.0d0 * sqom1 * om2 + om2 )
22743 c3 =(6.0d0*w3/ Rhead ** 6.0d0)*(om2-2.0d0*(fac)*(-om1))
22744 dGCLdOM2 = c1 - c2 + c3
22746 c1 = w1 / (Rhead ** 3.0d0)
22747 c2 = ( 2.0d0 * w2 * fac ) / Rhead ** 6.0d0
22748 c3 = (w3/ Rhead ** 6.0d0)*(-4.0d0*fac)
22749 dGCLdOM12 = c1 - c2 + c3
22751 erhead(k) = Rhead_distance(k)/Rhead
22753 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
22754 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
22755 facd1 = d1i * vbld_inv(i+nres)
22756 facd2 = d1j * vbld_inv(j+nres)
22759 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
22760 gvdwx_scbase(k,i) = gvdwx_scbase(k,i) &
22762 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
22763 gvdwx_scbase(k,j) = gvdwx_scbase(k,j) &
22766 gvdwc_scbase(k,i) = gvdwc_scbase(k,i) &
22767 - dGCLdR * erhead(k)
22768 gvdwc_scbase(k,j) = gvdwc_scbase(k,j) &
22769 + dGCLdR * erhead(k)
22772 !now charge with dipole eg. ARG-dG
22773 if (wqdip_scbase(2,itypi,itypj).gt.0.0d0) then
22774 alphapol1 = alphapol_scbase(itypi,itypj)
22775 w1 = wqdip_scbase(1,itypi,itypj)
22776 w2 = wqdip_scbase(2,itypi,itypj)
22779 ! pis = sig0head_scbase(itypi,itypj)
22780 ! eps_head = epshead_scbase(itypi,itypj)
22781 !c!-------------------------------------------------------------------
22782 !c! R1 - distance between head of ith side chain and tail of jth sidechain
22785 !c! Calculate head-to-tail distances tail is center of side-chain
22786 R1=R1+(c(k,j+nres)-chead(k,1))**2
22791 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
22792 !c! & +dhead(1,1,itypi,itypj))**2))
22793 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
22794 !c! & +dhead(2,1,itypi,itypj))**2))
22796 !c!-------------------------------------------------------------------
22799 hawk = w2 * (1.0d0 - sqom2)
22800 Ecl = sparrow / Rhead**2.0d0 &
22801 - hawk / Rhead**4.0d0
22802 !c!-------------------------------------------------------------------
22803 !c! derivative of ecl is Gcl
22805 dGCLdR = - 2.0d0 * sparrow / Rhead**3.0d0 &
22806 + 4.0d0 * hawk / Rhead**5.0d0
22808 dGCLdOM1 = (w1) / (Rhead**2.0d0)
22810 dGCLdOM2 = (2.0d0 * w2 * om2) / (Rhead ** 4.0d0)
22811 !c--------------------------------------------------------------------
22812 !c Polarization energy
22814 MomoFac1 = (1.0d0 - chi1 * sqom2)
22815 RR1 = R1 * R1 / MomoFac1
22816 ee1 = exp(-( RR1 / (4.0d0 * a12sq) ))
22817 fgb1 = sqrt( RR1 + a12sq * ee1)
22818 ! eps_inout_fac=0.0d0
22819 epol = 332.0d0 * eps_inout_fac * (( alphapol1 / fgb1 )**4.0d0)
22820 ! derivative of Epol is Gpol...
22821 dPOLdFGB1 = -(1328.0d0 * eps_inout_fac * alphapol1 ** 4.0d0) &
22823 dFGBdR1 = ( (R1 / MomoFac1) &
22824 * ( 2.0d0 - (0.5d0 * ee1) ) ) &
22826 dFGBdOM2 = (((R1 * R1 * chi1 * om2) / (MomoFac1 * MomoFac1)) &
22827 * (2.0d0 - 0.5d0 * ee1) ) &
22829 dPOLdR1 = dPOLdFGB1 * dFGBdR1
22832 dPOLdOM2 = dPOLdFGB1 * dFGBdOM2
22834 erhead(k) = Rhead_distance(k)/Rhead
22835 erhead_tail(k,1) = ((c(k,j+nres)-chead(k,1))/R1)
22838 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
22839 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
22840 bat = scalar( erhead_tail(1,1), dC_norm(1,i+nres) )
22842 federmaus = scalar(erhead_tail(1,1),dC_norm(1,j+nres))
22843 facd1 = d1i * vbld_inv(i+nres)
22844 facd2 = d1j * vbld_inv(j+nres)
22845 ! facd4 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
22848 hawk = (erhead_tail(k,1) + &
22849 facd1 * (erhead_tail(k,1) - bat * dC_norm(k,i+nres)))
22852 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
22853 gvdwx_scbase(k,i) = gvdwx_scbase(k,i) &
22855 - dPOLdR1 * (erhead_tail(k,1))
22858 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
22859 gvdwx_scbase(k,j) = gvdwx_scbase(k,j) &
22861 + dPOLdR1 * (erhead_tail(k,1))
22865 gvdwc_scbase(k,i) = gvdwc_scbase(k,i) &
22866 - dGCLdR * erhead(k) &
22867 - dPOLdR1 * erhead_tail(k,1)
22868 ! & - dGLJdR * erhead(k)
22870 gvdwc_scbase(k,j) = gvdwc_scbase(k,j) &
22871 + dGCLdR * erhead(k) &
22872 + dPOLdR1 * erhead_tail(k,1)
22873 ! & + dGLJdR * erhead(k)
22877 ! print *,i,j,evdwij,epol,Fcav,ECL
22878 escbase=escbase+evdwij+epol+Fcav+ECL
22879 call sc_grad_scbase
22884 end subroutine eprot_sc_base
22885 SUBROUTINE sc_grad_scbase
22888 real (kind=8) :: dcosom1(3),dcosom2(3)
22890 eps2der * eps2rt_om1 &
22891 - 2.0D0 * alf1 * eps3der &
22892 + sigder * sigsq_om1 &
22898 eps2der * eps2rt_om2 &
22899 + 2.0D0 * alf2 * eps3der &
22900 + sigder * sigsq_om2 &
22906 evdwij * eps1_om12 &
22907 + eps2der * eps2rt_om12 &
22908 - 2.0D0 * alf12 * eps3der &
22909 + sigder *sigsq_om12 &
22913 ! print *,eom1,eom2,eom12,i,j,"eom1,2,12",erij(1),erij(2),erij(3)
22914 ! print *,dsci_inv,dscj_inv,dc_norm(2,nres+j),dc_norm(2,nres+i),&
22915 ! gg(1),gg(2),"rozne"
22917 dcosom1(k) = rij * (dc_norm(k,nres+i) - om1 * erij(k))
22918 dcosom2(k) = rij * (dc_norm(k,nres+j) - om2 * erij(k))
22919 gg(k) = gg(k) + eom1 * dcosom1(k) + eom2 * dcosom2(k)
22920 gvdwx_scbase(k,i)= gvdwx_scbase(k,i) - gg(k) &
22921 + (eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
22922 + eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
22923 gvdwx_scbase(k,j)= gvdwx_scbase(k,j) + gg(k) &
22924 + (eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
22925 + eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
22926 gvdwc_scbase(k,i)=gvdwc_scbase(k,i)-gg(k)
22927 gvdwc_scbase(k,j)=gvdwc_scbase(k,j)+gg(k)
22930 END SUBROUTINE sc_grad_scbase
22933 subroutine epep_sc_base(epepbase)
22936 !el local variables
22937 integer :: iint,itypi,itypi1,itypj,subchap
22938 real(kind=8) :: rrij,xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
22939 real(kind=8) :: evdw,sig0ij
22940 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
22941 dist_temp, dist_init,aa,bb,ssgradlipi,ssgradlipj, &
22942 sslipi,sslipj,faclip
22944 real(kind=8) :: fracinbuf
22945 real (kind=8) :: epepbase
22946 real (kind=8),dimension(4):: ener
22947 real(kind=8) :: b1,b2,b3,b4,egb,eps_in,eps_inout_fac,eps_out
22948 real(kind=8) :: ECL,Elj,Equad,Epol,eheadtail,rhead,dGCLOM2,&
22949 sqom1,sqom2,sqom12,c1,c2,c3,pom,Lambf,sparrow,&
22950 Chif,ChiLambf,bat,eagle,top,bot,botsq,Fcav,dtop,dFdR,dFdOM1,&
22951 dFdOM2,w1,w2,w3,dGCLdR,dFdL,dFdOM12,dbot ,&
22952 r1,eps_head,alphapol1,pis,facd2,d2,facd1,d1,erdxj,erdxi,federmaus,&
22953 dPOLdR1,dFGBdOM2,dFGBdR1,dPOLdFGB1,RR1,MomoFac1,hawk,d1i,d1j,&
22954 sig1,sig2,chis12,chis2,ee1,fgb1,a12sq,chis1
22955 real(kind=8),dimension(3,2)::chead,erhead_tail
22956 real(kind=8),dimension(3) :: Rhead_distance,ertail,erhead
22960 ! do i=1,nres_molec(1)-1
22961 do i=ibond_start,ibond_end
22962 if (itype(i,1).eq.ntyp1_molec(1).or.itype(i+1,1).eq.ntyp1_molec(1)) cycle
22963 !C itypi = itype(i,1)
22967 ! print *,dxi,(-c(1,i)+c(1,i+1))*vbld_inv(i+1)
22968 dsci_inv = vbld_inv(i+1)/2.0
22969 xi=(c(1,i)+c(1,i+1))/2.0
22970 yi=(c(2,i)+c(2,i+1))/2.0
22971 zi=(c(3,i)+c(3,i+1))/2.0
22972 xi=mod(xi,boxxsize)
22973 if (xi.lt.0) xi=xi+boxxsize
22974 yi=mod(yi,boxysize)
22975 if (yi.lt.0) yi=yi+boxysize
22976 zi=mod(zi,boxzsize)
22977 if (zi.lt.0) zi=zi+boxzsize
22978 do j=nres_molec(1)+1,nres_molec(2)+nres_molec(1)
22980 if (itype(j,2).eq.ntyp1_molec(2))cycle
22984 xj=dmod(xj,boxxsize)
22985 if (xj.lt.0) xj=xj+boxxsize
22986 yj=dmod(yj,boxysize)
22987 if (yj.lt.0) yj=yj+boxysize
22988 zj=dmod(zj,boxzsize)
22989 if (zj.lt.0) zj=zj+boxzsize
22990 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
22999 xj=xj_safe+xshift*boxxsize
23000 yj=yj_safe+yshift*boxysize
23001 zj=zj_safe+zshift*boxzsize
23002 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
23003 if(dist_temp.lt.dist_init) then
23004 dist_init=dist_temp
23013 if (subchap.eq.1) then
23022 dxj = dc_norm( 1, nres+j )
23023 dyj = dc_norm( 2, nres+j )
23024 dzj = dc_norm( 3, nres+j )
23025 ! d1i = dhead_scbasei(itypi) !this is shift of dipole/charge
23026 ! d1j = dhead_scbasej(itypi) !this is shift of dipole/charge
23029 sig0ij = sigma_pepbase(itypj )
23030 chi1 = chi_pepbase(itypj,1 )
23031 chi2 = chi_pepbase(itypj,2 )
23034 chi12 = chi1 * chi2
23035 chip1 = chipp_pepbase(itypj,1 )
23036 chip2 = chipp_pepbase(itypj,2 )
23039 chip12 = chip1 * chip2
23040 chis1 = chis_pepbase(itypj,1)
23041 chis2 = chis_pepbase(itypj,2)
23042 chis12 = chis1 * chis2
23043 sig1 = sigmap1_pepbase(itypj)
23044 sig2 = sigmap2_pepbase(itypj)
23045 ! write (*,*) "sig1 = ", sig1
23046 ! write (*,*) "sig2 = ", sig2
23048 ! location of polar head is computed by taking hydrophobic centre
23049 ! and moving by a d1 * dc_norm vector
23050 ! see unres publications for very informative images
23051 chead(k,1) = (c(k,i)+c(k,i+1))/2.0
23052 ! + d1i * dc_norm(k, i+nres)
23053 chead(k,2) = c(k, j+nres)
23054 ! + d1j * dc_norm(k, j+nres)
23056 ! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
23057 ! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
23058 Rhead_distance(k) = chead(k,2) - chead(k,1)
23059 ! print *,gvdwc_pepbase(k,i)
23063 (Rhead_distance(1)*Rhead_distance(1)) &
23064 + (Rhead_distance(2)*Rhead_distance(2)) &
23065 + (Rhead_distance(3)*Rhead_distance(3)))
23067 ! alpha factors from Fcav/Gcav
23068 b1 = alphasur_pepbase(1,itypj)
23070 b2 = alphasur_pepbase(2,itypj)
23071 b3 = alphasur_pepbase(3,itypj)
23072 b4 = alphasur_pepbase(4,itypj)
23076 rrij = 1.0D0 / ( xj*xj + yj*yj + zj*zj)
23079 !----------------------------
23097 dscj_inv = vbld_inv(j+nres)
23099 ! this should be in elgrad_init but om's are calculated by sc_angular
23100 ! which in turn is used by older potentials
23101 ! om = omega, sqom = om^2
23104 sqom12 = om12 * om12
23106 ! now we calculate EGB - Gey-Berne
23107 ! It will be summed up in evdwij and saved in evdw
23108 sigsq = 1.0D0 / sigsq
23109 sig = sig0ij * dsqrt(sigsq)
23110 rij_shift = 1.0/rij - sig + sig0ij
23111 IF (rij_shift.le.0.0D0) THEN
23115 sigder = -sig * sigsq
23116 rij_shift = 1.0D0 / rij_shift
23117 fac = rij_shift**expon
23118 c1 = fac * fac * aa_pepbase(itypj)
23120 c2 = fac * bb_pepbase(itypj)
23122 evdwij = eps1 * eps2rt * eps3rt * ( c1 + c2 )
23123 eps2der = eps3rt * evdwij
23124 eps3der = eps2rt * evdwij
23125 ! evdwij = 4.0d0 * eps2rt * eps3rt * evdwij
23126 evdwij = eps2rt * eps3rt * evdwij
23127 c1 = c1 * eps1 * eps2rt**2 * eps3rt**2
23128 fac = -expon * (c1 + evdwij) * rij_shift
23129 sigder = fac * sigder
23131 ! Calculate distance derivative
23135 fac = chis1 * sqom1 + chis2 * sqom2 &
23136 - 2.0d0 * chis12 * om1 * om2 * om12
23137 ! we will use pom later in Gcav, so dont mess with it!
23138 pom = 1.0d0 - chis1 * chis2 * sqom12
23139 Lambf = (1.0d0 - (fac / pom))
23140 Lambf = dsqrt(Lambf)
23141 sparrow = 1.0d0 / dsqrt(sig1**2.0d0 + sig2**2.0d0)
23142 ! write (*,*) "sparrow = ", sparrow
23143 Chif = 1.0d0/rij * sparrow
23144 ChiLambf = Chif * Lambf
23145 eagle = dsqrt(ChiLambf)
23146 bat = ChiLambf ** 11.0d0
23147 top = b1 * ( eagle + b2 * ChiLambf - b3 )
23148 bot = 1.0d0 + b4 * (ChiLambf ** 12.0d0)
23152 dtop = b1 * ((Lambf / (2.0d0 * eagle)) + (b2 * Lambf))
23153 dbot = 12.0d0 * b4 * bat * Lambf
23154 dFdR = ((dtop * bot - top * dbot) / botsq) * sparrow
23156 ! write (*,*) "dFcav/dR = ", dFdR
23157 dtop = b1 * ((Chif / (2.0d0 * eagle)) + (b2 * Chif))
23158 dbot = 12.0d0 * b4 * bat * Chif
23159 eagle = Lambf * pom
23160 dFdOM1 = -(chis1 * om1 - chis12 * om2 * om12) / (eagle)
23161 dFdOM2 = -(chis2 * om2 - chis12 * om1 * om12) / (eagle)
23162 dFdOM12 = chis12 * (chis1 * om1 * om12 - om2) &
23163 * (chis2 * om2 * om12 - om1) / (eagle * pom)
23165 dFdL = ((dtop * bot - top * dbot) / botsq)
23167 dCAVdOM1 = dFdL * ( dFdOM1 )
23168 dCAVdOM2 = dFdL * ( dFdOM2 )
23169 dCAVdOM12 = dFdL * ( dFdOM12 )
23175 ! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
23176 ! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
23178 !-facd1*(ertail(k)-erdxi*dC_norm(k,i+nres))
23179 gvdwc_pepbase(k,i) = gvdwc_pepbase(k,i) &
23180 - (( dFdR + gg(k) ) * pom)/2.0
23181 ! print *,gvdwc_pepbase(k,i),i,(( dFdR + gg(k) ) * pom)/2.0
23182 ! +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
23183 ! +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
23184 ! & - ( dFdR * pom )
23186 !-facd2*(ertail(k)-erdxj*dC_norm(k,j+nres))
23187 gvdwx_pepbase(k,j) = gvdwx_pepbase(k,j) &
23188 + (( dFdR + gg(k) ) * pom)
23189 ! +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
23190 ! +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
23191 !c! & + ( dFdR * pom )
23193 gvdwc_pepbase(k,i+1) = gvdwc_pepbase(k,i+1) &
23194 - (( dFdR + gg(k) ) * ertail(k))/2.0
23195 ! print *,gvdwc_pepbase(k,i+1),i+1,(( dFdR + gg(k) ) * pom)/2.0
23197 !c! & - ( dFdR * ertail(k))
23199 gvdwc_pepbase(k,j) = gvdwc_pepbase(k,j) &
23200 + (( dFdR + gg(k) ) * ertail(k))
23201 !c! & + ( dFdR * ertail(k))
23204 !c! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
23205 !c! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
23209 w1 = wdipdip_pepbase(1,itypj)
23210 w2 = -wdipdip_pepbase(3,itypj)/2.0
23211 w3 = wdipdip_pepbase(2,itypj)
23214 !c!-------------------------------------------------------------------
23217 fac = (om12 - 3.0d0 * om1 * om2)
23218 c1 = (w1 / (Rhead**3.0d0)) * fac
23219 c2 = (w2 / Rhead ** 6.0d0) &
23220 * (4.0d0 + fac * fac -3.0d0 * (sqom1 + sqom2))
23221 c3= (w3/ Rhead ** 6.0d0) &
23222 * (2.0d0 - 2.0d0*fac*fac +3.0d0*(sqom1 + sqom2))
23226 c1 = (-3.0d0 * w1 * fac) / (Rhead ** 4.0d0)
23227 c2 = (-6.0d0 * w2) / (Rhead ** 7.0d0) &
23228 * (4.0d0 + fac * fac - 3.0d0 * (sqom1 + sqom2))
23229 c3= (-6.0d0 * w3) / (Rhead ** 7.0d0) &
23230 * (2.0d0 - 2.0d0*fac*fac +3.0d0*(sqom1 + sqom2))
23232 dGCLdR = c1 - c2 + c3
23234 c1 = (-3.0d0 * w1 * om2 ) / (Rhead**3.0d0)
23235 c2 = (-6.0d0 * w2) / (Rhead**6.0d0) &
23236 * ( om2 * om12 - 3.0d0 * om1 * sqom2 + om1 )
23237 c3 =(6.0d0*w3/ Rhead ** 6.0d0)*(om1-2.0d0*(fac)*(-om2))
23238 dGCLdOM1 = c1 - c2 + c3
23240 c1 = (-3.0d0 * w1 * om1 ) / (Rhead**3.0d0)
23241 c2 = (-6.0d0 * w2) / (Rhead**6.0d0) &
23242 * ( om1 * om12 - 3.0d0 * sqom1 * om2 + om2 )
23243 c3 =(6.0d0*w3/ Rhead ** 6.0d0)*(om2-2.0d0*(fac)*(-om1))
23245 dGCLdOM2 = c1 - c2 + c3
23247 c1 = w1 / (Rhead ** 3.0d0)
23248 c2 = ( 2.0d0 * w2 * fac ) / Rhead ** 6.0d0
23249 c3 = (w3/ Rhead ** 6.0d0)*(-4.0d0*fac)
23250 dGCLdOM12 = c1 - c2 + c3
23252 erhead(k) = Rhead_distance(k)/Rhead
23254 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
23255 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
23256 ! facd1 = d1 * vbld_inv(i+nres)
23257 ! facd2 = d2 * vbld_inv(j+nres)
23261 !+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
23262 ! gvdwx_pepbase(k,i) = gvdwx_scbase(k,i) &
23265 !+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
23266 gvdwx_pepbase(k,j) = gvdwx_pepbase(k,j) &
23269 gvdwc_pepbase(k,i) = gvdwc_pepbase(k,i) &
23270 - dGCLdR * erhead(k)/2.0d0
23271 ! print *,gvdwc_pepbase(k,i+1),i+1,- dGCLdR * erhead(k)/2.0d0
23272 gvdwc_pepbase(k,i+1) = gvdwc_pepbase(k,i+1) &
23273 - dGCLdR * erhead(k)/2.0d0
23274 ! print *,gvdwc_pepbase(k,i+1),i+1,- dGCLdR * erhead(k)/2.0d0
23275 gvdwc_pepbase(k,j) = gvdwc_pepbase(k,j) &
23276 + dGCLdR * erhead(k)
23278 ! print *,i,j,evdwij,Fcav,ECL,"vdw,cav,ecl"
23279 epepbase=epepbase+evdwij+Fcav+ECL
23280 call sc_grad_pepbase
23283 END SUBROUTINE epep_sc_base
23284 SUBROUTINE sc_grad_pepbase
23287 real (kind=8) :: dcosom1(3),dcosom2(3)
23289 eps2der * eps2rt_om1 &
23290 - 2.0D0 * alf1 * eps3der &
23291 + sigder * sigsq_om1 &
23297 eps2der * eps2rt_om2 &
23298 + 2.0D0 * alf2 * eps3der &
23299 + sigder * sigsq_om2 &
23305 evdwij * eps1_om12 &
23306 + eps2der * eps2rt_om12 &
23307 - 2.0D0 * alf12 * eps3der &
23308 + sigder *sigsq_om12 &
23313 ! print *,eom1,eom2,eom12,om12,i,j,"eom1,2,12",erij(1),erij(2),erij(3)
23314 ! if (i.eq.30) print *,gvdwc_pepbase(k,i),- gg(k),&
23315 ! (-eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,i)))&
23317 ! print *,dsci_inv,dscj_inv,dc_norm(2,nres+j),dc_norm(2,nres+i),&
23318 ! gg(1),gg(2),"rozne"
23320 dcosom1(k) = rij * (dc_norm(k,i) - om1 * erij(k))
23321 dcosom2(k) = rij * (dc_norm(k,nres+j) - om2 * erij(k))
23322 gg(k) = gg(k) + eom1 * dcosom1(k) + eom2 * dcosom2(k)
23323 gvdwc_pepbase(k,i)= gvdwc_pepbase(k,i) +0.5*(- gg(k)) &
23324 + (-eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,i)))&
23326 - (eom1*(erij(k)-om1*dc_norm(k,i)))*dsci_inv*2.0
23327 gvdwc_pepbase(k,i+1)= gvdwc_pepbase(k,i+1) +0.5*(- gg(k)) &
23328 - (-eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,i))) &
23330 + (eom1*(erij(k)-om1*dc_norm(k,i)))*dsci_inv*2.0
23331 ! print *,eom12,eom2,om12,om2
23332 !eom12*(-dc_norm(k,i)/2.0-om12*dc_norm(k,nres+j)),&
23333 ! (eom2*(erij(k)-om2*dc_norm(k,nres+j)))
23334 gvdwx_pepbase(k,j)= gvdwx_pepbase(k,j) + gg(k) &
23335 + (eom12*(dc_norm(k,i)-om12*dc_norm(k,nres+j))&
23336 + eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
23337 gvdwc_pepbase(k,j)=gvdwc_pepbase(k,j)+gg(k)
23340 END SUBROUTINE sc_grad_pepbase
23341 subroutine eprot_sc_phosphate(escpho)
23343 ! implicit real*8 (a-h,o-z)
23344 ! include 'DIMENSIONS'
23345 ! include 'COMMON.GEO'
23346 ! include 'COMMON.VAR'
23347 ! include 'COMMON.LOCAL'
23348 ! include 'COMMON.CHAIN'
23349 ! include 'COMMON.DERIV'
23350 ! include 'COMMON.NAMES'
23351 ! include 'COMMON.INTERACT'
23352 ! include 'COMMON.IOUNITS'
23353 ! include 'COMMON.CALC'
23354 ! include 'COMMON.CONTROL'
23355 ! include 'COMMON.SBRIDGE'
23357 !el local variables
23358 integer :: iint,itypi,itypi1,itypj,subchap
23359 real(kind=8) :: rrij,xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
23360 real(kind=8) :: evdw,sig0ij
23361 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
23362 dist_temp, dist_init,aa,bb,ssgradlipi,ssgradlipj, &
23363 sslipi,sslipj,faclip
23365 real(kind=8) :: fracinbuf
23366 real (kind=8) :: escpho
23367 real (kind=8),dimension(4):: ener
23368 real(kind=8) :: b1,b2,b3,b4,egb,eps_in,eps_inout_fac,eps_out
23369 real(kind=8) :: ECL,Elj,Equad,Epol,eheadtail,rhead,dGCLOM2,&
23370 sqom1,sqom2,sqom12,c1,c2,pom,Lambf,sparrow,&
23371 Chif,ChiLambf,bat,eagle,top,bot,botsq,Fcav,dtop,dFdR,dFdOM1,&
23372 dFdOM2,w1,w2,dGCLdR,dFdL,dFdOM12,dbot ,&
23373 r1,eps_head,alphapol1,pis,facd2,d2,facd1,d1,erdxj,erdxi,federmaus,&
23374 dPOLdR1,dFGBdOM2,dFGBdR1,dPOLdFGB1,RR1,MomoFac1,hawk,d1i,d1j,&
23375 sig1,sig2,chis12,chis2,ee1,fgb1,a12sq,chis1,Rhead_sq,Qij,dFGBdOM1
23376 real(kind=8),dimension(3,2)::chead,erhead_tail
23377 real(kind=8),dimension(3) :: Rhead_distance,ertail,erhead
23381 ! do i=1,nres_molec(1)
23382 do i=ibond_start,ibond_end
23383 if (itype(i,1).eq.ntyp1_molec(1)) cycle
23385 dxi = dc_norm(1,nres+i)
23386 dyi = dc_norm(2,nres+i)
23387 dzi = dc_norm(3,nres+i)
23388 dsci_inv = vbld_inv(i+nres)
23392 xi=mod(xi,boxxsize)
23393 if (xi.lt.0) xi=xi+boxxsize
23394 yi=mod(yi,boxysize)
23395 if (yi.lt.0) yi=yi+boxysize
23396 zi=mod(zi,boxzsize)
23397 if (zi.lt.0) zi=zi+boxzsize
23398 do j=nres_molec(1)+1,nres_molec(2)+nres_molec(1)-1
23400 if ((itype(j,2).eq.ntyp1_molec(2)).or.&
23401 (itype(j+1,2).eq.ntyp1_molec(2))) cycle
23402 xj=(c(1,j)+c(1,j+1))/2.0
23403 yj=(c(2,j)+c(2,j+1))/2.0
23404 zj=(c(3,j)+c(3,j+1))/2.0
23405 xj=dmod(xj,boxxsize)
23406 if (xj.lt.0) xj=xj+boxxsize
23407 yj=dmod(yj,boxysize)
23408 if (yj.lt.0) yj=yj+boxysize
23409 zj=dmod(zj,boxzsize)
23410 if (zj.lt.0) zj=zj+boxzsize
23411 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
23419 yj=yj_safe+yshift*boxysize
23420 zj=zj_safe+zshift*boxzsize
23421 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
23422 if(dist_temp.lt.dist_init) then
23423 dist_init=dist_temp
23432 if (subchap.eq.1) then
23441 dxj = dc_norm( 1,j )
23442 dyj = dc_norm( 2,j )
23443 dzj = dc_norm( 3,j )
23444 dscj_inv = vbld_inv(j+1)
23447 sig0ij = sigma_scpho(itypi )
23448 chi1 = chi_scpho(itypi,1 )
23449 chi2 = chi_scpho(itypi,2 )
23452 chi12 = chi1 * chi2
23453 chip1 = chipp_scpho(itypi,1 )
23454 chip2 = chipp_scpho(itypi,2 )
23457 chip12 = chip1 * chip2
23458 chis1 = chis_scpho(itypi,1)
23459 chis2 = chis_scpho(itypi,2)
23460 chis12 = chis1 * chis2
23461 sig1 = sigmap1_scpho(itypi)
23462 sig2 = sigmap2_scpho(itypi)
23463 ! write (*,*) "sig1 = ", sig1
23464 ! write (*,*) "sig1 = ", sig1
23465 ! write (*,*) "sig2 = ", sig2
23466 ! alpha factors from Fcav/Gcav
23470 a12sq = rborn_scphoi(itypi) * rborn_scphoj(itypi)
23472 b1 = alphasur_scpho(1,itypi)
23474 b2 = alphasur_scpho(2,itypi)
23475 b3 = alphasur_scpho(3,itypi)
23476 b4 = alphasur_scpho(4,itypi)
23477 ! used to determine whether we want to do quadrupole calculations
23479 eps_in = epsintab_scpho(itypi)
23480 if (eps_in.eq.0.0) eps_in=1.0
23481 eps_inout_fac = ( (1.0d0/eps_in) - (1.0d0/eps_out))
23482 ! write (*,*) "eps_inout_fac = ", eps_inout_fac
23483 !-------------------------------------------------------------------
23484 ! tail location and distance calculations
23485 d1i = dhead_scphoi(itypi) !this is shift of dipole/charge
23488 ! location of polar head is computed by taking hydrophobic centre
23489 ! and moving by a d1 * dc_norm vector
23490 ! see unres publications for very informative images
23491 chead(k,1) = c(k, i+nres) + d1i * dc_norm(k, i+nres)
23492 chead(k,2) = (c(k, j) + c(k, j+1))/2.0
23494 ! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
23495 ! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
23496 Rhead_distance(k) = chead(k,2) - chead(k,1)
23498 ! pitagoras (root of sum of squares)
23500 (Rhead_distance(1)*Rhead_distance(1)) &
23501 + (Rhead_distance(2)*Rhead_distance(2)) &
23502 + (Rhead_distance(3)*Rhead_distance(3)))
23503 Rhead_sq=Rhead**2.0
23504 !-------------------------------------------------------------------
23505 ! zero everything that should be zero'ed
23524 dscj_inv = vbld_inv(j+1)/2.0
23525 !dhead_scbasej(itypi,itypj)
23526 ! print *,i,j,dscj_inv,dsci_inv
23527 ! rij holds 1/(distance of Calpha atoms)
23528 rrij = 1.0D0 / ( xj*xj + yj*yj + zj*zj)
23530 !----------------------------
23532 ! this should be in elgrad_init but om's are calculated by sc_angular
23533 ! which in turn is used by older potentials
23534 ! om = omega, sqom = om^2
23537 sqom12 = om12 * om12
23539 ! now we calculate EGB - Gey-Berne
23540 ! It will be summed up in evdwij and saved in evdw
23541 sigsq = 1.0D0 / sigsq
23542 sig = sig0ij * dsqrt(sigsq)
23543 ! rij_shift = 1.0D0 / rij - sig + sig0ij
23544 rij_shift = 1.0/rij - sig + sig0ij
23545 IF (rij_shift.le.0.0D0) THEN
23549 sigder = -sig * sigsq
23550 rij_shift = 1.0D0 / rij_shift
23551 fac = rij_shift**expon
23552 c1 = fac * fac * aa_scpho(itypi)
23554 c2 = fac * bb_scpho(itypi)
23556 evdwij = eps1 * eps2rt * eps3rt * ( c1 + c2 )
23557 eps2der = eps3rt * evdwij
23558 eps3der = eps2rt * evdwij
23559 ! evdwij = 4.0d0 * eps2rt * eps3rt * evdwij
23560 evdwij = eps2rt * eps3rt * evdwij
23561 c1 = c1 * eps1 * eps2rt**2 * eps3rt**2
23562 fac = -expon * (c1 + evdwij) * rij_shift
23563 sigder = fac * sigder
23565 ! Calculate distance derivative
23569 fac = chis1 * sqom1 + chis2 * sqom2 &
23570 - 2.0d0 * chis12 * om1 * om2 * om12
23571 ! we will use pom later in Gcav, so dont mess with it!
23572 pom = 1.0d0 - chis1 * chis2 * sqom12
23573 Lambf = (1.0d0 - (fac / pom))
23574 Lambf = dsqrt(Lambf)
23575 sparrow = 1.0d0 / dsqrt(sig1**2.0d0 + sig2**2.0d0)
23576 ! write (*,*) "sparrow = ", sparrow
23577 Chif = 1.0d0/rij * sparrow
23578 ChiLambf = Chif * Lambf
23579 eagle = dsqrt(ChiLambf)
23580 bat = ChiLambf ** 11.0d0
23581 top = b1 * ( eagle + b2 * ChiLambf - b3 )
23582 bot = 1.0d0 + b4 * (ChiLambf ** 12.0d0)
23585 dtop = b1 * ((Lambf / (2.0d0 * eagle)) + (b2 * Lambf))
23586 dbot = 12.0d0 * b4 * bat * Lambf
23587 dFdR = ((dtop * bot - top * dbot) / botsq) * sparrow
23589 ! write (*,*) "dFcav/dR = ", dFdR
23590 dtop = b1 * ((Chif / (2.0d0 * eagle)) + (b2 * Chif))
23591 dbot = 12.0d0 * b4 * bat * Chif
23592 eagle = Lambf * pom
23593 dFdOM1 = -(chis1 * om1 - chis12 * om2 * om12) / (eagle)
23594 dFdOM2 = -(chis2 * om2 - chis12 * om1 * om12) / (eagle)
23595 dFdOM12 = chis12 * (chis1 * om1 * om12 - om2) &
23596 * (chis2 * om2 * om12 - om1) / (eagle * pom)
23598 dFdL = ((dtop * bot - top * dbot) / botsq)
23600 dCAVdOM1 = dFdL * ( dFdOM1 )
23601 dCAVdOM2 = dFdL * ( dFdOM2 )
23602 dCAVdOM12 = dFdL * ( dFdOM12 )
23608 ! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
23609 ! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
23610 ! if (i.eq.3) print *,'decl0',gvdwx_scpho(k,i),i
23613 ! print *,pom,gg(k),dFdR
23614 !-facd1*(ertail(k)-erdxi*dC_norm(k,i+nres))
23615 gvdwx_scpho(k,i) = gvdwx_scpho(k,i) &
23616 - (( dFdR + gg(k) ) * pom)
23617 ! +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
23618 ! +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
23619 ! & - ( dFdR * pom )
23621 !-facd2*(ertail(k)-erdxj*dC_norm(k,j+nres))
23622 ! gvdwx_scpho(k,j) = gvdwx_scpho(k,j) &
23623 ! + (( dFdR + gg(k) ) * pom)
23624 ! +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
23625 ! +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
23626 !c! & + ( dFdR * pom )
23628 gvdwc_scpho(k,i) = gvdwc_scpho(k,i) &
23629 - (( dFdR + gg(k) ) * ertail(k))
23630 !c! & - ( dFdR * ertail(k))
23632 gvdwc_scpho(k,j) = gvdwc_scpho(k,j) &
23633 + (( dFdR + gg(k) ) * ertail(k))/2.0
23635 gvdwc_scpho(k,j+1) = gvdwc_scpho(k,j+1) &
23636 + (( dFdR + gg(k) ) * ertail(k))/2.0
23638 !c! & + ( dFdR * ertail(k))
23642 !c! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
23643 !c! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
23644 ! alphapol1 = alphapol_scpho(itypi)
23645 if (wqq_scpho(itypi).gt.0.0) then
23646 Qij=wqq_scpho(itypi)/eps_in
23648 Ecl = (332.0d0 * Qij) / Rhead
23649 !c! derivative of Ecl is Gcl...
23650 dGCLdR = (-332.0d0 * Qij ) / Rhead_sq
23651 else if (wqdip_scpho(2,itypi).gt.0.0d0) then
23652 w1 = wqdip_scpho(1,itypi)
23653 w2 = wqdip_scpho(2,itypi)
23656 ! pis = sig0head_scbase(itypi,itypj)
23657 ! eps_head = epshead_scbase(itypi,itypj)
23658 !c!-------------------------------------------------------------------
23660 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
23661 !c! & +dhead(1,1,itypi,itypj))**2))
23662 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
23663 !c! & +dhead(2,1,itypi,itypj))**2))
23665 !c!-------------------------------------------------------------------
23668 hawk = w2 * (1.0d0 - sqom2)
23669 Ecl = sparrow / Rhead**2.0d0 &
23670 - hawk / Rhead**4.0d0
23671 !c!-------------------------------------------------------------------
23672 !c! derivative of ecl is Gcl
23674 dGCLdR = - 2.0d0 * sparrow / Rhead**3.0d0 &
23675 + 4.0d0 * hawk / Rhead**5.0d0
23677 dGCLdOM1 = (w1) / (Rhead**2.0d0)
23679 dGCLdOM2 = (2.0d0 * w2 * om2) / (Rhead ** 4.0d0)
23682 !c--------------------------------------------------------------------
23683 !c Polarization energy
23687 !c! Calculate head-to-tail distances tail is center of side-chain
23688 R1=R1+((c(k,j)+c(k,j+1))/2.0-chead(k,1))**2
23693 alphapol1 = alphapol_scpho(itypi)
23695 MomoFac1 = (1.0d0 - chi2 * sqom1)
23696 RR1 = R1 * R1 / MomoFac1
23697 ee1 = exp(-( RR1 / (4.0d0 * a12sq) ))
23698 ! print *,"ee1",ee1,a12sq,alphapol1,eps_inout_fac
23699 fgb1 = sqrt( RR1 + a12sq * ee1)
23700 ! eps_inout_fac=0.0d0
23701 epol = 332.0d0 * eps_inout_fac * (( alphapol1 / fgb1 )**4.0d0)
23702 ! derivative of Epol is Gpol...
23703 dPOLdFGB1 = -(1328.0d0 * eps_inout_fac * alphapol1 ** 4.0d0) &
23705 dFGBdR1 = ( (R1 / MomoFac1) &
23706 * ( 2.0d0 - (0.5d0 * ee1) ) ) &
23708 dFGBdOM2 = (((R1 * R1 * chi1 * om2) / (MomoFac1 * MomoFac1)) &
23709 * (2.0d0 - 0.5d0 * ee1) ) &
23711 dPOLdR1 = dPOLdFGB1 * dFGBdR1
23714 dFGBdOM1 = (((R1 * R1 * chi2 * om1) / (MomoFac1 * MomoFac1)) &
23715 * (2.0d0 - 0.5d0 * ee1) ) &
23718 dPOLdOM1 = dPOLdFGB1 * dFGBdOM1
23721 erhead(k) = Rhead_distance(k)/Rhead
23722 erhead_tail(k,1) = (((c(k,j)+c(k,j+1))/2.0-chead(k,1))/R1)
23725 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
23726 erdxj = scalar( erhead(1), dC_norm(1,j) )
23727 bat = scalar( erhead_tail(1,1), dC_norm(1,i+nres) )
23729 federmaus = scalar(erhead_tail(1,1),dC_norm(1,j))
23730 facd1 = d1i * vbld_inv(i+nres)
23731 facd2 = d1j * vbld_inv(j)
23732 ! facd4 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
23735 hawk = (erhead_tail(k,1) + &
23736 facd1 * (erhead_tail(k,1) - bat * dC_norm(k,i+nres)))
23739 ! if (i.eq.3) print *,'decl1',dGCLdR,dPOLdR1,gvdwc_scpho(k,i),i,&
23740 ! pom,(erhead_tail(k,1))
23742 ! print *,'decl',dGCLdR,dPOLdR1,gvdwc_scpho(k,i)
23743 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
23744 gvdwx_scpho(k,i) = gvdwx_scpho(k,i) &
23746 - dPOLdR1 * (erhead_tail(k,1))
23749 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j))
23750 ! gvdwx_scpho(k,j) = gvdwx_scpho(k,j) &
23752 ! + dPOLdR1 * (erhead_tail(k,1))
23756 gvdwc_scpho(k,i) = gvdwc_scpho(k,i) &
23757 - dGCLdR * erhead(k) &
23758 - dPOLdR1 * erhead_tail(k,1)
23759 ! & - dGLJdR * erhead(k)
23761 gvdwc_scpho(k,j) = gvdwc_scpho(k,j) &
23762 + (dGCLdR * erhead(k) &
23763 + dPOLdR1 * erhead_tail(k,1))/2.0
23764 gvdwc_scpho(k,j+1) = gvdwc_scpho(k,j+1) &
23765 + (dGCLdR * erhead(k) &
23766 + dPOLdR1 * erhead_tail(k,1))/2.0
23768 ! & + dGLJdR * erhead(k)
23769 ! if (i.eq.3) print *,'decl2',dGCLdR,dPOLdR1,gvdwc_scpho(k,i),i
23772 ! if (i.eq.3) print *,i,j,evdwij,epol,Fcav,ECL
23773 escpho=escpho+evdwij+epol+Fcav+ECL
23780 end subroutine eprot_sc_phosphate
23781 SUBROUTINE sc_grad_scpho
23784 real (kind=8) :: dcosom1(3),dcosom2(3)
23786 eps2der * eps2rt_om1 &
23787 - 2.0D0 * alf1 * eps3der &
23788 + sigder * sigsq_om1 &
23794 eps2der * eps2rt_om2 &
23795 + 2.0D0 * alf2 * eps3der &
23796 + sigder * sigsq_om2 &
23802 evdwij * eps1_om12 &
23803 + eps2der * eps2rt_om12 &
23804 - 2.0D0 * alf12 * eps3der &
23805 + sigder *sigsq_om12 &
23810 ! print *,eom1,eom2,eom12,om12,i,j,"eom1,2,12",erij(1),erij(2),erij(3)
23811 ! if (i.eq.30) print *,gvdwc_scpho(k,i),- gg(k),&
23812 ! (-eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,i)))&
23814 ! print *,dsci_inv,dscj_inv,dc_norm(2,nres+j),dc_norm(2,nres+i),&
23815 ! gg(1),gg(2),"rozne"
23817 dcosom1(k) = rij * (dc_norm(k,nres+i) - om1 * erij(k))
23818 dcosom2(k) = rij * (dc_norm(k,j) - om2 * erij(k))
23819 gg(k) = gg(k) + eom1 * dcosom1(k) + eom2 * dcosom2(k)
23820 gvdwc_scpho(k,j)= gvdwc_scpho(k,j) +0.5*( gg(k)) &
23821 + (-eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,j)))&
23823 - (eom2*(erij(k)-om2*dc_norm(k,j)))*dscj_inv*2.0
23824 gvdwc_scpho(k,j+1)= gvdwc_scpho(k,j+1) +0.5*( gg(k)) &
23825 - (-eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,j))) &
23827 + (eom2*(erij(k)-om2*dc_norm(k,j)))*dscj_inv*2.0
23828 gvdwx_scpho(k,i)= gvdwx_scpho(k,i) - gg(k) &
23829 + (eom12*(dc_norm(k,j)-om12*dc_norm(k,nres+i)) &
23830 + eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
23832 ! print *,eom12,eom2,om12,om2
23833 !eom12*(-dc_norm(k,i)/2.0-om12*dc_norm(k,nres+j)),&
23834 ! (eom2*(erij(k)-om2*dc_norm(k,nres+j)))
23835 ! gvdwx_scpho(k,j)= gvdwx_scpho(k,j) + gg(k) &
23836 ! + (eom12*(dc_norm(k,i)-om12*dc_norm(k,nres+j))&
23837 ! + eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
23838 gvdwc_scpho(k,i)=gvdwc_scpho(k,i)-gg(k)
23841 END SUBROUTINE sc_grad_scpho
23842 subroutine eprot_pep_phosphate(epeppho)
23844 ! implicit real*8 (a-h,o-z)
23845 ! include 'DIMENSIONS'
23846 ! include 'COMMON.GEO'
23847 ! include 'COMMON.VAR'
23848 ! include 'COMMON.LOCAL'
23849 ! include 'COMMON.CHAIN'
23850 ! include 'COMMON.DERIV'
23851 ! include 'COMMON.NAMES'
23852 ! include 'COMMON.INTERACT'
23853 ! include 'COMMON.IOUNITS'
23854 ! include 'COMMON.CALC'
23855 ! include 'COMMON.CONTROL'
23856 ! include 'COMMON.SBRIDGE'
23858 !el local variables
23859 integer :: iint,itypi,itypi1,itypj,subchap
23860 real(kind=8) :: rrij,xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
23861 real(kind=8) :: evdw,sig0ij
23862 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
23863 dist_temp, dist_init,aa,bb,ssgradlipi,ssgradlipj, &
23864 sslipi,sslipj,faclip
23866 real(kind=8) :: fracinbuf
23867 real (kind=8) :: epeppho
23868 real (kind=8),dimension(4):: ener
23869 real(kind=8) :: b1,b2,b3,b4,egb,eps_in,eps_inout_fac,eps_out
23870 real(kind=8) :: ECL,Elj,Equad,Epol,eheadtail,rhead,dGCLOM2,&
23871 sqom1,sqom2,sqom12,c1,c2,pom,Lambf,sparrow,&
23872 Chif,ChiLambf,bat,eagle,top,bot,botsq,Fcav,dtop,dFdR,dFdOM1,&
23873 dFdOM2,w1,w2,dGCLdR,dFdL,dFdOM12,dbot ,&
23874 r1,eps_head,alphapol1,pis,facd2,d2,facd1,d1,erdxj,erdxi,federmaus,&
23875 dPOLdR1,dFGBdOM2,dFGBdR1,dPOLdFGB1,RR1,MomoFac1,hawk,d1i,d1j,&
23876 sig1,sig2,chis12,chis2,ee1,fgb1,a12sq,chis1,Rhead_sq,Qij,dFGBdOM1
23877 real(kind=8),dimension(3,2)::chead,erhead_tail
23878 real(kind=8),dimension(3) :: Rhead_distance,ertail,erhead
23880 real (kind=8) :: dcosom1(3),dcosom2(3)
23882 ! do i=1,nres_molec(1)
23883 do i=ibond_start,ibond_end
23884 if (itype(i,1).eq.ntyp1_molec(1)) cycle
23886 dsci_inv = vbld_inv(i+1)/2.0
23890 xi=(c(1,i)+c(1,i+1))/2.0
23891 yi=(c(2,i)+c(2,i+1))/2.0
23892 zi=(c(3,i)+c(3,i+1))/2.0
23893 xi=mod(xi,boxxsize)
23894 if (xi.lt.0) xi=xi+boxxsize
23895 yi=mod(yi,boxysize)
23896 if (yi.lt.0) yi=yi+boxysize
23897 zi=mod(zi,boxzsize)
23898 if (zi.lt.0) zi=zi+boxzsize
23899 do j=nres_molec(1)+1,nres_molec(2)+nres_molec(1)-1
23901 if ((itype(j,2).eq.ntyp1_molec(2)).or.&
23902 (itype(j+1,2).eq.ntyp1_molec(2))) cycle
23903 xj=(c(1,j)+c(1,j+1))/2.0
23904 yj=(c(2,j)+c(2,j+1))/2.0
23905 zj=(c(3,j)+c(3,j+1))/2.0
23906 xj=dmod(xj,boxxsize)
23907 if (xj.lt.0) xj=xj+boxxsize
23908 yj=dmod(yj,boxysize)
23909 if (yj.lt.0) yj=yj+boxysize
23910 zj=dmod(zj,boxzsize)
23911 if (zj.lt.0) zj=zj+boxzsize
23912 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
23920 yj=yj_safe+yshift*boxysize
23921 zj=zj_safe+zshift*boxzsize
23922 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
23923 if(dist_temp.lt.dist_init) then
23924 dist_init=dist_temp
23933 if (subchap.eq.1) then
23942 rrij = 1.0D0 / ( xj*xj + yj*yj + zj*zj)
23944 dxj = dc_norm( 1,j )
23945 dyj = dc_norm( 2,j )
23946 dzj = dc_norm( 3,j )
23947 dscj_inv = vbld_inv(j+1)/2.0
23949 sig0ij = sigma_peppho
23952 chi12 = chi1 * chi2
23955 chip12 = chip1 * chip2
23958 chis12 = chis1 * chis2
23959 sig1 = sigmap1_peppho
23960 sig2 = sigmap2_peppho
23961 ! write (*,*) "sig1 = ", sig1
23962 ! write (*,*) "sig1 = ", sig1
23963 ! write (*,*) "sig2 = ", sig2
23964 ! alpha factors from Fcav/Gcav
23968 b1 = alphasur_peppho(1)
23970 b2 = alphasur_peppho(2)
23971 b3 = alphasur_peppho(3)
23972 b4 = alphasur_peppho(4)
23994 fac = rij_shift**expon
23995 c1 = fac * fac * aa_peppho
23997 c2 = fac * bb_peppho
24000 ! Now cavity....................
24001 eagle = dsqrt(1.0/rij_shift)
24002 top = b1 * ( eagle + b2 * 1.0/rij_shift - b3 )
24003 bot = 1.0d0 + b4 * (1.0/rij_shift ** 12.0d0)
24006 dtop = b1 * ((1.0/ (2.0d0 * eagle)) + (b2))
24007 dbot = 12.0d0 * b4 * (1.0/rij_shift) ** 11.0d0
24008 dFdR = ((dtop * bot - top * dbot) / botsq)
24009 w1 = wqdip_peppho(1)
24010 w2 = wqdip_peppho(2)
24013 ! pis = sig0head_scbase(itypi,itypj)
24014 ! eps_head = epshead_scbase(itypi,itypj)
24015 !c!-------------------------------------------------------------------
24017 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
24018 !c! & +dhead(1,1,itypi,itypj))**2))
24019 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
24020 !c! & +dhead(2,1,itypi,itypj))**2))
24022 !c!-------------------------------------------------------------------
24025 hawk = w2 * (1.0d0 - sqom1)
24026 Ecl = sparrow * rij_shift**2.0d0 &
24027 - hawk * rij_shift**4.0d0
24028 !c!-------------------------------------------------------------------
24029 !c! derivative of ecl is Gcl
24032 dGCLdR = - 2.0d0 * sparrow * rij_shift**3.0d0 &
24033 + 4.0d0 * hawk * rij_shift**5.0d0
24035 dGCLdOM1 = (w1) * (rij_shift**2.0d0)
24037 dGCLdOM2 = (2.0d0 * w2 * om1) * (rij_shift ** 4.0d0)
24038 eom1 = dGCLdOM1+dGCLdOM2
24041 fac = -expon * (c1 + evdwij) * rij_shift+dFdR+dGCLdR
24047 gvdwc_peppho(k,j) = gvdwc_peppho(k,j) +gg(k)/2.0
24048 gvdwc_peppho(k,j+1) = gvdwc_peppho(k,j+1) +gg(k)/2.0
24049 gvdwc_peppho(k,i) = gvdwc_peppho(k,i) -gg(k)/2.0
24050 gvdwc_peppho(k,i+1) = gvdwc_peppho(k,i+1) -gg(k)/2.0
24055 dcosom1(k) = rij* (dc_norm(k,i) - om1 * erij(k))
24056 dcosom2(k) = rij* (dc_norm(k,j) - om2 * erij(k))
24057 gg(k) = gg(k) + eom1 * dcosom1(k)! + eom2 * dcosom2(k)
24058 gvdwc_peppho(k,j)= gvdwc_peppho(k,j) +0.5*( gg(k)) !&
24059 ! - (eom2*(erij(k)-om2*dc_norm(k,j)))*dscj_inv*2.0
24060 gvdwc_peppho(k,j+1)= gvdwc_peppho(k,j+1) +0.5*( gg(k)) !&
24061 ! + (eom2*(erij(k)-om2*dc_norm(k,j)))*dscj_inv*2.0
24062 gvdwc_peppho(k,i)= gvdwc_peppho(k,i) -0.5*( gg(k)) &
24063 - (eom1*(erij(k)-om1*dc_norm(k,i)))*dsci_inv*2.0
24064 gvdwc_peppho(k,i+1)= gvdwc_peppho(k,i+1) - 0.5*( gg(k)) &
24065 + (eom1*(erij(k)-om1*dc_norm(k,i)))*dsci_inv*2.0
24067 epeppho=epeppho+evdwij+Fcav+ECL
24068 ! print *,i,j,evdwij,Fcav,ECL,rij_shift
24071 end subroutine eprot_pep_phosphate