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 if (itype(i-2,1).eq.0) then
2577 iti = itortyp(itype(i-2,1))
2582 ! if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
2583 if (i.gt. nnt+1 .and. i.lt.nct+1) then
2584 if (itype(i-1,1).eq.0) then
2587 iti1 = itortyp(itype(i-1,1))
2592 ! print *,iti,i,"iti",iti1,itype(i-1,1),itype(i-2,1)
2593 !d write (iout,*) '*******i',i,' iti1',iti
2594 !d write (iout,*) 'b1',b1(:,iti)
2595 !d write (iout,*) 'b2',b2(:,iti)
2596 !d write (iout,*) 'Ug',Ug(:,:,i-2)
2597 ! if (i .gt. iatel_s+2) then
2598 if (i .gt. nnt+2) then
2599 call matvec2(Ug(1,1,i-2),b2(1,iti),Ub2(1,i-2))
2600 call matmat2(EE(1,1,iti),Ug(1,1,i-2),EUg(1,1,i-2))
2601 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) &
2603 call matmat2(CC(1,1,iti),Ug(1,1,i-2),CUg(1,1,i-2))
2604 call matmat2(DD(1,1,iti),Ug(1,1,i-2),DUg(1,1,i-2))
2605 call matmat2(Dtilde(1,1,iti),Ug2(1,1,i-2),DtUg2(1,1,i-2))
2606 call matvec2(Ctilde(1,1,iti1),obrot(1,i-2),Ctobr(1,i-2))
2607 call matvec2(Dtilde(1,1,iti),obrot2(1,i-2),Dtobr2(1,i-2))
2618 DtUg2(l,k,i-2)=0.0d0
2622 call matvec2(Ugder(1,1,i-2),b2(1,iti),Ub2der(1,i-2))
2623 call matmat2(EE(1,1,iti),Ugder(1,1,i-2),EUgder(1,1,i-2))
2625 muder(k,i-2)=Ub2der(k,i-2)
2627 ! if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
2628 if (i.gt. nnt+1 .and. i.lt.nct+1) then
2629 if (itype(i-1,1).eq.0) then
2631 elseif (itype(i-1,1).le.ntyp) then
2632 iti1 = itortyp(itype(i-1,1))
2640 mu(k,i-2)=Ub2(k,i-2)+b1(k,iti1)
2642 ! if (energy_dec) write (iout,*) 'Ub2 ',i,Ub2(:,i-2)
2643 ! if (energy_dec) write (iout,*) 'b1 ',iti1,b1(:,iti1)
2644 ! if (energy_dec) write (iout,*) 'mu ',i,iti1,mu(:,i-2)
2645 !d write (iout,*) 'mu1',mu1(:,i-2)
2646 !d write (iout,*) 'mu2',mu2(:,i-2)
2647 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.wcorr6.gt.0.0d0) &
2649 call matmat2(CC(1,1,iti1),Ugder(1,1,i-2),CUgder(1,1,i-2))
2650 call matmat2(DD(1,1,iti),Ugder(1,1,i-2),DUgder(1,1,i-2))
2651 call matmat2(Dtilde(1,1,iti),Ug2der(1,1,i-2),DtUg2der(1,1,i-2))
2652 call matvec2(Ctilde(1,1,iti1),obrot_der(1,i-2),Ctobrder(1,i-2))
2653 call matvec2(Dtilde(1,1,iti),obrot2_der(1,i-2),Dtobr2der(1,i-2))
2654 ! Vectors and matrices dependent on a single virtual-bond dihedral.
2655 call matvec2(DD(1,1,iti),b1tilde(1,iti1),auxvec(1))
2656 call matvec2(Ug2(1,1,i-2),auxvec(1),Ug2Db1t(1,i-2))
2657 call matvec2(Ug2der(1,1,i-2),auxvec(1),Ug2Db1tder(1,i-2))
2658 call matvec2(CC(1,1,iti1),Ub2(1,i-2),CUgb2(1,i-2))
2659 call matvec2(CC(1,1,iti1),Ub2der(1,i-2),CUgb2der(1,i-2))
2660 call matmat2(EUg(1,1,i-2),CC(1,1,iti1),EUgC(1,1,i-2))
2661 call matmat2(EUgder(1,1,i-2),CC(1,1,iti1),EUgCder(1,1,i-2))
2662 call matmat2(EUg(1,1,i-2),DD(1,1,iti1),EUgD(1,1,i-2))
2663 call matmat2(EUgder(1,1,i-2),DD(1,1,iti1),EUgDder(1,1,i-2))
2666 ! Matrices dependent on two consecutive virtual-bond dihedrals.
2667 ! The order of matrices is from left to right.
2668 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.wcorr6.gt.0.0d0) &
2670 ! do i=max0(ivec_start,2),ivec_end
2672 call matmat2(DtUg2(1,1,i-1),EUg(1,1,i),DtUg2EUg(1,1,i))
2673 call matmat2(DtUg2der(1,1,i-1),EUg(1,1,i),DtUg2EUgder(1,1,1,i))
2674 call matmat2(DtUg2(1,1,i-1),EUgder(1,1,i),DtUg2EUgder(1,1,2,i))
2675 call transpose2(DtUg2(1,1,i-1),auxmat(1,1))
2676 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUg(1,1,i))
2677 call matmat2(auxmat(1,1),EUgder(1,1,i),Ug2DtEUgder(1,1,2,i))
2678 call transpose2(DtUg2der(1,1,i-1),auxmat(1,1))
2679 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUgder(1,1,1,i))
2682 #if defined(MPI) && defined(PARMAT)
2684 ! if (fg_rank.eq.0) then
2685 write (iout,*) "Arrays UG and UGDER before GATHER"
2687 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2688 ((ug(l,k,i),l=1,2),k=1,2),&
2689 ((ugder(l,k,i),l=1,2),k=1,2)
2691 write (iout,*) "Arrays UG2 and UG2DER"
2693 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2694 ((ug2(l,k,i),l=1,2),k=1,2),&
2695 ((ug2der(l,k,i),l=1,2),k=1,2)
2697 write (iout,*) "Arrays OBROT OBROT2 OBROTDER and OBROT2DER"
2699 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2700 (obrot(k,i),k=1,2),(obrot2(k,i),k=1,2),&
2701 (obrot_der(k,i),k=1,2),(obrot2_der(k,i),k=1,2)
2703 write (iout,*) "Arrays COSTAB SINTAB COSTAB2 and SINTAB2"
2705 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2706 costab(i),sintab(i),costab2(i),sintab2(i)
2708 write (iout,*) "Array MUDER"
2710 write (iout,'(i5,2f10.5)') i,muder(1,i),muder(2,i)
2714 if (nfgtasks.gt.1) then
2716 ! write(iout,*)"Processor",fg_rank,kolor," ivec_start",ivec_start,
2717 ! & " ivec_displ",(ivec_displ(i),i=0,nfgtasks-1),
2718 ! & " ivec_count",(ivec_count(i),i=0,nfgtasks-1)
2720 call MPI_Allgatherv(Ub2(1,ivec_start),ivec_count(fg_rank1),&
2721 MPI_MU,Ub2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2723 call MPI_Allgatherv(Ub2der(1,ivec_start),ivec_count(fg_rank1),&
2724 MPI_MU,Ub2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2726 call MPI_Allgatherv(mu(1,ivec_start),ivec_count(fg_rank1),&
2727 MPI_MU,mu(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2729 call MPI_Allgatherv(muder(1,ivec_start),ivec_count(fg_rank1),&
2730 MPI_MU,muder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2732 call MPI_Allgatherv(Eug(1,1,ivec_start),ivec_count(fg_rank1),&
2733 MPI_MAT1,Eug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2735 call MPI_Allgatherv(Eugder(1,1,ivec_start),ivec_count(fg_rank1),&
2736 MPI_MAT1,Eugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2738 call MPI_Allgatherv(costab(ivec_start),ivec_count(fg_rank1),&
2739 MPI_DOUBLE_PRECISION,costab(1),ivec_count(0),ivec_displ(0),&
2740 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
2741 call MPI_Allgatherv(sintab(ivec_start),ivec_count(fg_rank1),&
2742 MPI_DOUBLE_PRECISION,sintab(1),ivec_count(0),ivec_displ(0),&
2743 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
2744 call MPI_Allgatherv(costab2(ivec_start),ivec_count(fg_rank1),&
2745 MPI_DOUBLE_PRECISION,costab2(1),ivec_count(0),ivec_displ(0),&
2746 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
2747 call MPI_Allgatherv(sintab2(ivec_start),ivec_count(fg_rank1),&
2748 MPI_DOUBLE_PRECISION,sintab2(1),ivec_count(0),ivec_displ(0),&
2749 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
2750 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) &
2752 call MPI_Allgatherv(Ctobr(1,ivec_start),ivec_count(fg_rank1),&
2753 MPI_MU,Ctobr(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2755 call MPI_Allgatherv(Ctobrder(1,ivec_start),ivec_count(fg_rank1),&
2756 MPI_MU,Ctobrder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2758 call MPI_Allgatherv(Dtobr2(1,ivec_start),ivec_count(fg_rank1),&
2759 MPI_MU,Dtobr2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2761 call MPI_Allgatherv(Dtobr2der(1,ivec_start),ivec_count(fg_rank1),&
2762 MPI_MU,Dtobr2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2764 call MPI_Allgatherv(Ug2Db1t(1,ivec_start),ivec_count(fg_rank1),&
2765 MPI_MU,Ug2Db1t(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2767 call MPI_Allgatherv(Ug2Db1tder(1,ivec_start),&
2768 ivec_count(fg_rank1),&
2769 MPI_MU,Ug2Db1tder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2771 call MPI_Allgatherv(CUgb2(1,ivec_start),ivec_count(fg_rank1),&
2772 MPI_MU,CUgb2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2774 call MPI_Allgatherv(CUgb2der(1,ivec_start),ivec_count(fg_rank1),&
2775 MPI_MU,CUgb2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2777 call MPI_Allgatherv(Cug(1,1,ivec_start),ivec_count(fg_rank1),&
2778 MPI_MAT1,Cug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2780 call MPI_Allgatherv(Cugder(1,1,ivec_start),ivec_count(fg_rank1),&
2781 MPI_MAT1,Cugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2783 call MPI_Allgatherv(Dug(1,1,ivec_start),ivec_count(fg_rank1),&
2784 MPI_MAT1,Dug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2786 call MPI_Allgatherv(Dugder(1,1,ivec_start),ivec_count(fg_rank1),&
2787 MPI_MAT1,Dugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2789 call MPI_Allgatherv(Dtug2(1,1,ivec_start),ivec_count(fg_rank1),&
2790 MPI_MAT1,Dtug2(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2792 call MPI_Allgatherv(Dtug2der(1,1,ivec_start),&
2793 ivec_count(fg_rank1),&
2794 MPI_MAT1,Dtug2der(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2796 call MPI_Allgatherv(EugC(1,1,ivec_start),ivec_count(fg_rank1),&
2797 MPI_MAT1,EugC(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2799 call MPI_Allgatherv(EugCder(1,1,ivec_start),ivec_count(fg_rank1),&
2800 MPI_MAT1,EugCder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2802 call MPI_Allgatherv(EugD(1,1,ivec_start),ivec_count(fg_rank1),&
2803 MPI_MAT1,EugD(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2805 call MPI_Allgatherv(EugDder(1,1,ivec_start),ivec_count(fg_rank1),&
2806 MPI_MAT1,EugDder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2808 call MPI_Allgatherv(DtUg2EUg(1,1,ivec_start),&
2809 ivec_count(fg_rank1),&
2810 MPI_MAT1,DtUg2EUg(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2812 call MPI_Allgatherv(Ug2DtEUg(1,1,ivec_start),&
2813 ivec_count(fg_rank1),&
2814 MPI_MAT1,Ug2DtEUg(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2816 call MPI_Allgatherv(DtUg2EUgder(1,1,1,ivec_start),&
2817 ivec_count(fg_rank1),&
2818 MPI_MAT2,DtUg2EUgder(1,1,1,1),ivec_count(0),ivec_displ(0),&
2819 MPI_MAT2,FG_COMM1,IERR)
2820 call MPI_Allgatherv(Ug2DtEUgder(1,1,1,ivec_start),&
2821 ivec_count(fg_rank1),&
2822 MPI_MAT2,Ug2DtEUgder(1,1,1,1),ivec_count(0),ivec_displ(0),&
2823 MPI_MAT2,FG_COMM1,IERR)
2826 ! Passes matrix info through the ring
2829 if (irecv.lt.0) irecv=nfgtasks1-1
2832 if (inext.ge.nfgtasks1) inext=0
2834 ! write (iout,*) "isend",isend," irecv",irecv
2836 lensend=lentyp(isend)
2837 lenrecv=lentyp(irecv)
2838 ! write (iout,*) "lensend",lensend," lenrecv",lenrecv
2839 ! call MPI_SENDRECV(ug(1,1,ivec_displ(isend)+1),1,
2840 ! & MPI_ROTAT1(lensend),inext,2200+isend,
2841 ! & ug(1,1,ivec_displ(irecv)+1),1,MPI_ROTAT1(lenrecv),
2842 ! & iprev,2200+irecv,FG_COMM,status,IERR)
2843 ! write (iout,*) "Gather ROTAT1"
2845 ! call MPI_SENDRECV(obrot(1,ivec_displ(isend)+1),1,
2846 ! & MPI_ROTAT2(lensend),inext,3300+isend,
2847 ! & obrot(1,ivec_displ(irecv)+1),1,MPI_ROTAT2(lenrecv),
2848 ! & iprev,3300+irecv,FG_COMM,status,IERR)
2849 ! write (iout,*) "Gather ROTAT2"
2851 call MPI_SENDRECV(costab(ivec_displ(isend)+1),1,&
2852 MPI_ROTAT_OLD(lensend),inext,4400+isend,&
2853 costab(ivec_displ(irecv)+1),1,MPI_ROTAT_OLD(lenrecv),&
2854 iprev,4400+irecv,FG_COMM,status,IERR)
2855 ! write (iout,*) "Gather ROTAT_OLD"
2857 call MPI_SENDRECV(mu(1,ivec_displ(isend)+1),1,&
2858 MPI_PRECOMP11(lensend),inext,5500+isend,&
2859 mu(1,ivec_displ(irecv)+1),1,MPI_PRECOMP11(lenrecv),&
2860 iprev,5500+irecv,FG_COMM,status,IERR)
2861 ! write (iout,*) "Gather PRECOMP11"
2863 call MPI_SENDRECV(Eug(1,1,ivec_displ(isend)+1),1,&
2864 MPI_PRECOMP12(lensend),inext,6600+isend,&
2865 Eug(1,1,ivec_displ(irecv)+1),1,MPI_PRECOMP12(lenrecv),&
2866 iprev,6600+irecv,FG_COMM,status,IERR)
2867 ! write (iout,*) "Gather PRECOMP12"
2869 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) &
2871 call MPI_SENDRECV(ug2db1t(1,ivec_displ(isend)+1),1,&
2872 MPI_ROTAT2(lensend),inext,7700+isend,&
2873 ug2db1t(1,ivec_displ(irecv)+1),1,MPI_ROTAT2(lenrecv),&
2874 iprev,7700+irecv,FG_COMM,status,IERR)
2875 ! write (iout,*) "Gather PRECOMP21"
2877 call MPI_SENDRECV(EUgC(1,1,ivec_displ(isend)+1),1,&
2878 MPI_PRECOMP22(lensend),inext,8800+isend,&
2879 EUgC(1,1,ivec_displ(irecv)+1),1,MPI_PRECOMP22(lenrecv),&
2880 iprev,8800+irecv,FG_COMM,status,IERR)
2881 ! write (iout,*) "Gather PRECOMP22"
2883 call MPI_SENDRECV(Ug2DtEUgder(1,1,1,ivec_displ(isend)+1),1,&
2884 MPI_PRECOMP23(lensend),inext,9900+isend,&
2885 Ug2DtEUgder(1,1,1,ivec_displ(irecv)+1),1,&
2886 MPI_PRECOMP23(lenrecv),&
2887 iprev,9900+irecv,FG_COMM,status,IERR)
2888 ! write (iout,*) "Gather PRECOMP23"
2893 if (irecv.lt.0) irecv=nfgtasks1-1
2896 time_gather=time_gather+MPI_Wtime()-time00
2899 ! if (fg_rank.eq.0) then
2900 write (iout,*) "Arrays UG and UGDER"
2902 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2903 ((ug(l,k,i),l=1,2),k=1,2),&
2904 ((ugder(l,k,i),l=1,2),k=1,2)
2906 write (iout,*) "Arrays UG2 and UG2DER"
2908 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2909 ((ug2(l,k,i),l=1,2),k=1,2),&
2910 ((ug2der(l,k,i),l=1,2),k=1,2)
2912 write (iout,*) "Arrays OBROT OBROT2 OBROTDER and OBROT2DER"
2914 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2915 (obrot(k,i),k=1,2),(obrot2(k,i),k=1,2),&
2916 (obrot_der(k,i),k=1,2),(obrot2_der(k,i),k=1,2)
2918 write (iout,*) "Arrays COSTAB SINTAB COSTAB2 and SINTAB2"
2920 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2921 costab(i),sintab(i),costab2(i),sintab2(i)
2923 write (iout,*) "Array MUDER"
2925 write (iout,'(i5,2f10.5)') i,muder(1,i),muder(2,i)
2931 !d iti = itortyp(itype(i,1))
2934 !d write (iout,'(2f10.5,5x,2f10.5,5x,2f10.5)')
2935 !d & (EE(j,k,iti),k=1,2),(Ug(j,k,i),k=1,2),(EUg(j,k,i),k=1,2)
2939 end subroutine set_matrices
2940 !-----------------------------------------------------------------------------
2941 subroutine eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
2943 ! This subroutine calculates the average interaction energy and its gradient
2944 ! in the virtual-bond vectors between non-adjacent peptide groups, based on
2945 ! the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
2946 ! The potential depends both on the distance of peptide-group centers and on
2947 ! the orientation of the CA-CA virtual bonds.
2950 ! implicit real*8 (a-h,o-z)
2954 ! include 'DIMENSIONS'
2955 ! include 'COMMON.CONTROL'
2956 ! include 'COMMON.SETUP'
2957 ! include 'COMMON.IOUNITS'
2958 ! include 'COMMON.GEO'
2959 ! include 'COMMON.VAR'
2960 ! include 'COMMON.LOCAL'
2961 ! include 'COMMON.CHAIN'
2962 ! include 'COMMON.DERIV'
2963 ! include 'COMMON.INTERACT'
2964 ! include 'COMMON.CONTACTS'
2965 ! include 'COMMON.TORSION'
2966 ! include 'COMMON.VECTORS'
2967 ! include 'COMMON.FFIELD'
2968 ! include 'COMMON.TIME1'
2969 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg
2970 real(kind=8),dimension(3,3) :: erder,uryg,urzg,vryg,vrzg
2971 real(kind=8),dimension(2,2) :: acipa !el,a_temp
2972 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
2973 real(kind=8),dimension(4) :: muij
2974 !el integer :: num_conti,j1,j2
2975 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
2976 !el dz_normi,xmedi,ymedi,zmedi
2978 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
2979 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
2982 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
2984 real(kind=8) :: scal_el=1.0d0
2986 real(kind=8) :: scal_el=0.5d0
2989 ! 13-go grudnia roku pamietnego...
2990 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
2992 0.0d0,0.0d0,1.0d0/),shape(unmat))
2995 real(kind=8) :: ees,evdw1,eel_loc,eello_turn3,eello_turn4
2996 real(kind=8) :: fac,t_eelecij,fracinbuf
2999 !d write(iout,*) 'In EELEC'
3000 ! print *,"IN EELEC"
3002 !d write(iout,*) 'Type',i
3003 !d write(iout,*) 'B1',B1(:,i)
3004 !d write(iout,*) 'B2',B2(:,i)
3005 !d write(iout,*) 'CC',CC(:,:,i)
3006 !d write(iout,*) 'DD',DD(:,:,i)
3007 !d write(iout,*) 'EE',EE(:,:,i)
3009 !d call check_vecgrad
3024 if (icheckgrad.eq.1) then
3027 ! dc_norm(1,i)=0.0d0
3028 ! dc_norm(2,i)=0.0d0
3029 ! dc_norm(3,i)=0.0d0
3032 fac=1.0d0/dsqrt(scalar(dc(1,i),dc(1,i)))
3034 dc_norm(k,i)=dc(k,i)*fac
3036 ! write (iout,*) 'i',i,' fac',fac
3039 ! print *,wel_loc,"wel_loc",wcorr4,wcorr5,wcorr6,wturn3,wturn4, &
3041 if (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
3042 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 .or. &
3043 wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) then
3044 ! call vec_and_deriv
3048 ! print *, "before set matrices"
3050 ! print *, "after set matrices"
3053 time_mat=time_mat+MPI_Wtime()-time01
3056 ! print *, "after set matrices"
3058 !d write (iout,*) 'i=',i
3060 !d write (iout,'(i5,2f10.5)') k,uy(k,i),uz(k,i)
3063 !d write (iout,'(f10.5,2x,3f10.5,2x,3f10.5)')
3064 !d & uz(k,i),(uzgrad(k,l,1,i),l=1,3),(uzgrad(k,l,2,i),l=1,3)
3077 !d print '(a)','Enter EELEC'
3078 !d write (iout,*) 'iatel_s=',iatel_s,' iatel_e=',iatel_e
3079 ! if (.not.allocated(gel_loc_loc)) allocate(gel_loc_loc(nres)) !(maxvar)(maxvar=6*maxres)
3080 ! if (.not.allocated(gcorr_loc)) allocate(gcorr_loc(nres)) !(maxvar)(maxvar=6*maxres)
3082 gel_loc_loc(i)=0.0d0
3087 ! 9/27/08 AL Split the interaction loop to ensure load balancing of turn terms
3089 ! Loop over i,i+2 and i,i+3 pairs of the peptide groups
3093 ! print *,"before iturn3 loop"
3094 do i=iturn3_start,iturn3_end
3095 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1 &
3096 .or. itype(i+2,1).eq.ntyp1 .or. itype(i+3,1).eq.ntyp1) cycle
3100 dx_normi=dc_norm(1,i)
3101 dy_normi=dc_norm(2,i)
3102 dz_normi=dc_norm(3,i)
3103 xmedi=c(1,i)+0.5d0*dxi
3104 ymedi=c(2,i)+0.5d0*dyi
3105 zmedi=c(3,i)+0.5d0*dzi
3106 xmedi=dmod(xmedi,boxxsize)
3107 if (xmedi.lt.0) xmedi=xmedi+boxxsize
3108 ymedi=dmod(ymedi,boxysize)
3109 if (ymedi.lt.0) ymedi=ymedi+boxysize
3110 zmedi=dmod(zmedi,boxzsize)
3111 if (zmedi.lt.0) zmedi=zmedi+boxzsize
3113 if ((zmedi.gt.bordlipbot) &
3114 .and.(zmedi.lt.bordliptop)) then
3115 !C the energy transfer exist
3116 if (zmedi.lt.buflipbot) then
3117 !C what fraction I am in
3119 ((zmedi-bordlipbot)/lipbufthick)
3120 !C lipbufthick is thickenes of lipid buffore
3121 sslipi=sscalelip(fracinbuf)
3122 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
3123 elseif (zmedi.gt.bufliptop) then
3124 fracinbuf=1.0d0-((bordliptop-zmedi)/lipbufthick)
3125 sslipi=sscalelip(fracinbuf)
3126 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
3135 ! print *,i,sslipi,ssgradlipi
3136 call eelecij(i,i+2,ees,evdw1,eel_loc)
3137 if (wturn3.gt.0.0d0) call eturn3(i,eello_turn3)
3138 num_cont_hb(i)=num_conti
3140 do i=iturn4_start,iturn4_end
3141 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1 &
3142 .or. itype(i+3,1).eq.ntyp1 &
3143 .or. itype(i+4,1).eq.ntyp1) cycle
3147 dx_normi=dc_norm(1,i)
3148 dy_normi=dc_norm(2,i)
3149 dz_normi=dc_norm(3,i)
3150 xmedi=c(1,i)+0.5d0*dxi
3151 ymedi=c(2,i)+0.5d0*dyi
3152 zmedi=c(3,i)+0.5d0*dzi
3153 xmedi=dmod(xmedi,boxxsize)
3154 if (xmedi.lt.0) xmedi=xmedi+boxxsize
3155 ymedi=dmod(ymedi,boxysize)
3156 if (ymedi.lt.0) ymedi=ymedi+boxysize
3157 zmedi=dmod(zmedi,boxzsize)
3158 if (zmedi.lt.0) zmedi=zmedi+boxzsize
3159 if ((zmedi.gt.bordlipbot) &
3160 .and.(zmedi.lt.bordliptop)) then
3161 !C the energy transfer exist
3162 if (zmedi.lt.buflipbot) then
3163 !C what fraction I am in
3165 ((zmedi-bordlipbot)/lipbufthick)
3166 !C lipbufthick is thickenes of lipid buffore
3167 sslipi=sscalelip(fracinbuf)
3168 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
3169 elseif (zmedi.gt.bufliptop) then
3170 fracinbuf=1.0d0-((bordliptop-zmedi)/lipbufthick)
3171 sslipi=sscalelip(fracinbuf)
3172 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
3182 num_conti=num_cont_hb(i)
3183 call eelecij(i,i+3,ees,evdw1,eel_loc)
3184 if (wturn4.gt.0.0d0 .and. itype(i+2,1).ne.ntyp1) &
3185 call eturn4(i,eello_turn4)
3186 num_cont_hb(i)=num_conti
3189 ! Loop over all pairs of interacting peptide groups except i,i+2 and i,i+3
3191 ! print *,"iatel_s,iatel_e,",iatel_s,iatel_e
3192 do i=iatel_s,iatel_e
3193 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
3197 dx_normi=dc_norm(1,i)
3198 dy_normi=dc_norm(2,i)
3199 dz_normi=dc_norm(3,i)
3200 xmedi=c(1,i)+0.5d0*dxi
3201 ymedi=c(2,i)+0.5d0*dyi
3202 zmedi=c(3,i)+0.5d0*dzi
3203 xmedi=dmod(xmedi,boxxsize)
3204 if (xmedi.lt.0) xmedi=xmedi+boxxsize
3205 ymedi=dmod(ymedi,boxysize)
3206 if (ymedi.lt.0) ymedi=ymedi+boxysize
3207 zmedi=dmod(zmedi,boxzsize)
3208 if (zmedi.lt.0) zmedi=zmedi+boxzsize
3209 if ((zmedi.gt.bordlipbot) &
3210 .and.(zmedi.lt.bordliptop)) then
3211 !C the energy transfer exist
3212 if (zmedi.lt.buflipbot) then
3213 !C what fraction I am in
3215 ((zmedi-bordlipbot)/lipbufthick)
3216 !C lipbufthick is thickenes of lipid buffore
3217 sslipi=sscalelip(fracinbuf)
3218 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
3219 elseif (zmedi.gt.bufliptop) then
3220 fracinbuf=1.0d0-((bordliptop-zmedi)/lipbufthick)
3221 sslipi=sscalelip(fracinbuf)
3222 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
3232 ! write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
3233 num_conti=num_cont_hb(i)
3234 do j=ielstart(i),ielend(i)
3235 ! write (iout,*) i,j,itype(i,1),itype(j,1)
3236 if (itype(j,1).eq.ntyp1.or. itype(j+1,1).eq.ntyp1) cycle
3237 call eelecij(i,j,ees,evdw1,eel_loc)
3239 num_cont_hb(i)=num_conti
3241 ! write (iout,*) "Number of loop steps in EELEC:",ind
3243 !d write (iout,'(i3,3f10.5,5x,3f10.5)')
3244 !d & i,(gel_loc(k,i),k=1,3),gel_loc_loc(i)
3246 ! 12/7/99 Adam eello_turn3 will be considered as a separate energy term
3247 !cc eel_loc=eel_loc+eello_turn3
3248 !d print *,"Processor",fg_rank," t_eelecij",t_eelecij
3250 end subroutine eelec
3251 !-----------------------------------------------------------------------------
3252 subroutine eelecij(i,j,ees,evdw1,eel_loc)
3255 ! implicit real*8 (a-h,o-z)
3256 ! include 'DIMENSIONS'
3260 ! include 'COMMON.CONTROL'
3261 ! include 'COMMON.IOUNITS'
3262 ! include 'COMMON.GEO'
3263 ! include 'COMMON.VAR'
3264 ! include 'COMMON.LOCAL'
3265 ! include 'COMMON.CHAIN'
3266 ! include 'COMMON.DERIV'
3267 ! include 'COMMON.INTERACT'
3268 ! include 'COMMON.CONTACTS'
3269 ! include 'COMMON.TORSION'
3270 ! include 'COMMON.VECTORS'
3271 ! include 'COMMON.FFIELD'
3272 ! include 'COMMON.TIME1'
3273 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg,xtemp
3274 real(kind=8),dimension(3,3) :: erder,uryg,urzg,vryg,vrzg
3275 real(kind=8),dimension(2,2) :: acipa !el,a_temp
3276 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
3277 real(kind=8),dimension(4) :: muij
3278 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
3279 dist_temp, dist_init,rlocshield,fracinbuf
3280 integer xshift,yshift,zshift,ilist,iresshield
3281 !el integer :: num_conti,j1,j2
3282 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
3283 !el dz_normi,xmedi,ymedi,zmedi
3285 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
3286 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
3289 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
3291 real(kind=8) :: scal_el=1.0d0
3293 real(kind=8) :: scal_el=0.5d0
3296 ! 13-go grudnia roku pamietnego...
3297 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
3299 0.0d0,0.0d0,1.0d0/),shape(unmat))
3300 ! integer :: maxconts=nres/4
3302 integer :: k,i,j,iteli,itelj,kkk,l,kkll,m,isubchap
3303 real(kind=8) :: ael6i,rrmij,rmij,r0ij,fcont,fprimcont,ees0tmp
3304 real(kind=8) :: ees,evdw1,eel_loc,aaa,bbb,ael3i
3305 real(kind=8) :: dxj,dyj,dzj,dx_normj,dy_normj,dz_normj,xj,yj,zj,&
3306 rij,r3ij,r6ij,cosa,cosb,cosg,fac,ev1,ev2,fac3,fac4,&
3307 evdwij,el1,el2,eesij,ees0ij,facvdw,facel,fac1,ecosa,&
3308 ecosb,ecosg,ury,urz,vry,vrz,facr,a22der,a23der,a32der,&
3309 a33der,eel_loc_ij,cosa4,wij,cosbg1,cosbg2,ees0pij,&
3310 ees0pij1,ees0mij,ees0mij1,fac3p,ees0mijp,ees0pijp,&
3311 ecosa1,ecosb1,ecosg1,ecosa2,ecosb2,ecosg2,ecosap,ecosbp,&
3312 ecosgp,ecosam,ecosbm,ecosgm,ghalf
3314 ! allocate(a_chuj(2,2,maxconts,nres)) !(2,2,maxconts,maxres)
3315 ! allocate(a_chuj_der(2,2,3,5,maxconts,nres)) !(2,2,3,5,maxconts,maxres)
3317 ! time00=MPI_Wtime()
3318 !d write (iout,*) "eelecij",i,j
3322 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
3323 aaa=app(iteli,itelj)
3324 bbb=bpp(iteli,itelj)
3325 ael6i=ael6(iteli,itelj)
3326 ael3i=ael3(iteli,itelj)
3330 dx_normj=dc_norm(1,j)
3331 dy_normj=dc_norm(2,j)
3332 dz_normj=dc_norm(3,j)
3333 ! xj=c(1,j)+0.5D0*dxj-xmedi
3334 ! yj=c(2,j)+0.5D0*dyj-ymedi
3335 ! zj=c(3,j)+0.5D0*dzj-zmedi
3340 if (xj.lt.0) xj=xj+boxxsize
3342 if (yj.lt.0) yj=yj+boxysize
3344 if (zj.lt.0) zj=zj+boxzsize
3345 if ((zj.gt.bordlipbot) &
3346 .and.(zj.lt.bordliptop)) then
3347 !C the energy transfer exist
3348 if (zj.lt.buflipbot) then
3349 !C what fraction I am in
3351 ((zj-bordlipbot)/lipbufthick)
3352 !C lipbufthick is thickenes of lipid buffore
3353 sslipj=sscalelip(fracinbuf)
3354 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
3355 elseif (zj.gt.bufliptop) then
3356 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
3357 sslipj=sscalelip(fracinbuf)
3358 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
3369 dist_init=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
3376 xj=xj_safe+xshift*boxxsize
3377 yj=yj_safe+yshift*boxysize
3378 zj=zj_safe+zshift*boxzsize
3379 dist_temp=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
3380 if(dist_temp.lt.dist_init) then
3390 if (isubchap.eq.1) then
3401 rij=xj*xj+yj*yj+zj*zj
3404 !C print *,xmedi,ymedi,zmedi,xj,yj,zj,boxxsize,rij
3405 sss_ele_cut=sscale_ele(rij)
3406 sss_ele_grad=sscagrad_ele(rij)
3408 ! sss_ele_grad=0.0d0
3409 ! print *,sss_ele_cut,sss_ele_grad,&
3410 ! (rij),r_cut_ele,rlamb_ele
3411 ! if (sss_ele_cut.le.0.0) go to 128
3416 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
3417 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
3418 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
3419 fac=cosa-3.0D0*cosb*cosg
3421 ! 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
3422 if (j.eq.i+2) ev1=scal_el*ev1
3427 el1=fac3*(4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg))
3430 if (shield_mode.gt.0) then
3431 !C fac_shield(i)=0.4
3432 !C fac_shield(j)=0.6
3433 el1=el1*fac_shield(i)**2*fac_shield(j)**2
3434 el2=el2*fac_shield(i)**2*fac_shield(j)**2
3436 ees=ees+eesij*sss_ele_cut
3437 !C FOR NOW SHIELD IS NOT USED WITH LIPSCALE
3438 !C & *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3444 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)*sss_ele_cut
3445 !C print *,"TUCC",(sslipi+sslipj)/2.0d0*lipscale**2+1.0d0
3448 ! 12/26/95 - for the evaluation of multi-body H-bonding interactions
3449 ees0ij=4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg)
3450 ! ees=ees+eesij*sss_ele_cut
3451 evdw1=evdw1+evdwij*sss_ele_cut &
3452 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3453 !d write(iout,'(2(2i3,2x),7(1pd12.4)/2(3(1pd12.4),5x)/)')
3454 !d & iteli,i,itelj,j,aaa,bbb,ael6i,ael3i,
3455 !d & 1.0D0/dsqrt(rrmij),evdwij,eesij,
3456 !d & xmedi,ymedi,zmedi,xj,yj,zj
3458 if (energy_dec) then
3459 ! write (iout,'(a6,2i5,0pf7.3,2i5,2e11.3)') &
3460 ! 'evdw1',i,j,evdwij,&
3461 ! iteli,itelj,aaa,evdw1
3462 write (iout,'(a6,2i5,0pf7.3)') 'evdw1',i,j,evdwij
3463 write (iout,'(a6,2i5,0pf7.3)') 'ees',i,j,eesij
3466 ! Calculate contributions to the Cartesian gradient.
3469 facvdw=-6*rrmij*(ev1+evdwij)*sss_ele_cut &
3470 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3471 facel=-3*rrmij*(el1+eesij)*sss_ele_cut &
3472 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3478 ! Radial derivatives. First process both termini of the fragment (i,j)
3480 ggg(1)=facel*xj+sss_ele_grad*rmij*eesij*xj* &
3481 ((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3482 ggg(2)=facel*yj+sss_ele_grad*rmij*eesij*yj* &
3483 ((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3484 ggg(3)=facel*zj+sss_ele_grad*rmij*eesij*zj* &
3485 ((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3487 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
3488 (shield_mode.gt.0)) then
3490 do ilist=1,ishield_list(i)
3491 iresshield=shield_list(ilist,i)
3493 rlocshield=grad_shield_side(k,ilist,i)*eesij/fac_shield(i)&
3495 gshieldx(k,iresshield)=gshieldx(k,iresshield)+ &
3497 +grad_shield_loc(k,ilist,i)*eesij/fac_shield(i)*2.0 &
3499 gshieldc(k,iresshield-1)=gshieldc(k,iresshield-1)+rlocshield
3502 do ilist=1,ishield_list(j)
3503 iresshield=shield_list(ilist,j)
3505 rlocshield=grad_shield_side(k,ilist,j)*eesij/fac_shield(j) &
3507 gshieldx(k,iresshield)=gshieldx(k,iresshield)+ &
3509 +grad_shield_loc(k,ilist,j)*eesij/fac_shield(j)*2.0 &
3511 gshieldc(k,iresshield-1)=gshieldc(k,iresshield-1)+rlocshield
3515 gshieldc(k,i)=gshieldc(k,i)+ &
3516 grad_shield(k,i)*eesij/fac_shield(i)*2.0 &
3519 gshieldc(k,j)=gshieldc(k,j)+ &
3520 grad_shield(k,j)*eesij/fac_shield(j)*2.0 &
3523 gshieldc(k,i-1)=gshieldc(k,i-1)+ &
3524 grad_shield(k,i)*eesij/fac_shield(i)*2.0 &
3527 gshieldc(k,j-1)=gshieldc(k,j-1)+ &
3528 grad_shield(k,j)*eesij/fac_shield(j)*2.0 &
3536 ! ghalf=0.5D0*ggg(k)
3537 ! gelc(k,i)=gelc(k,i)+ghalf
3538 ! gelc(k,j)=gelc(k,j)+ghalf
3540 ! 9/28/08 AL Gradient compotents will be summed only at the end
3542 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
3543 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
3545 gelc_long(3,j)=gelc_long(3,j)+ &
3546 ssgradlipj*eesij/2.0d0*lipscale**2&
3549 gelc_long(3,i)=gelc_long(3,i)+ &
3550 ssgradlipi*eesij/2.0d0*lipscale**2&
3555 ! Loop over residues i+1 thru j-1.
3559 !grad gelc(l,k)=gelc(l,k)+ggg(l)
3562 ggg(1)=facvdw*xj+sss_ele_grad*rmij*evdwij*xj &
3563 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3564 ggg(2)=facvdw*yj+sss_ele_grad*rmij*evdwij*yj &
3565 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3566 ggg(3)=facvdw*zj+sss_ele_grad*rmij*evdwij*zj &
3567 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3570 ! ghalf=0.5D0*ggg(k)
3571 ! gvdwpp(k,i)=gvdwpp(k,i)+ghalf
3572 ! gvdwpp(k,j)=gvdwpp(k,j)+ghalf
3574 ! 9/28/08 AL Gradient compotents will be summed only at the end
3576 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
3577 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
3580 !C Lipidic part for scaling weight
3581 gvdwpp(3,j)=gvdwpp(3,j)+ &
3582 sss_ele_cut*ssgradlipj*evdwij/2.0d0*lipscale**2
3583 gvdwpp(3,i)=gvdwpp(3,i)+ &
3584 sss_ele_cut*ssgradlipi*evdwij/2.0d0*lipscale**2
3585 !! Loop over residues i+1 thru j-1.
3589 !grad gvdwpp(l,k)=gvdwpp(l,k)+ggg(l)
3593 facvdw=(ev1+evdwij)*sss_ele_cut &
3594 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3596 facel=(el1+eesij)*sss_ele_cut
3598 fac=-3*rrmij*(facvdw+facvdw+facel)
3603 ! Radial derivatives. First process both termini of the fragment (i,j)
3605 ggg(1)=fac*xj+sss_ele_grad*rmij*(eesij+evdwij)*xj
3606 ggg(2)=fac*yj+sss_ele_grad*rmij*(eesij+evdwij)*yj
3607 ggg(3)=fac*zj+sss_ele_grad*rmij*(eesij+evdwij)*zj
3609 ! ghalf=0.5D0*ggg(k)
3610 ! gelc(k,i)=gelc(k,i)+ghalf
3611 ! gelc(k,j)=gelc(k,j)+ghalf
3613 ! 9/28/08 AL Gradient compotents will be summed only at the end
3615 gelc_long(k,j)=gelc(k,j)+ggg(k)
3616 gelc_long(k,i)=gelc(k,i)-ggg(k)
3619 ! Loop over residues i+1 thru j-1.
3623 !grad gelc(l,k)=gelc(l,k)+ggg(l)
3626 ! 9/28/08 AL Gradient compotents will be summed only at the end
3628 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3630 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3632 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3635 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
3636 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
3638 gvdwpp(3,j)=gvdwpp(3,j)+ &
3639 sss_ele_cut*ssgradlipj*evdwij/2.0d0*lipscale**2
3640 gvdwpp(3,i)=gvdwpp(3,i)+ &
3641 sss_ele_cut*ssgradlipi*evdwij/2.0d0*lipscale**2
3647 ecosa=2.0D0*fac3*fac1+fac4
3650 ecosb=(fac3*(fac1*cosg+cosb)+cosg*fac4)
3651 ecosg=(fac3*(fac1*cosb+cosg)+cosb*fac4)
3653 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
3654 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
3656 !d print '(2i3,2(3(1pd14.5),3x))',i,j,(dcosb(k),k=1,3),
3657 !d & (dcosg(k),k=1,3)
3659 ggg(k)=(ecosb*dcosb(k)+ecosg*dcosg(k))*sss_ele_cut &
3660 *fac_shield(i)**2*fac_shield(j)**2 &
3661 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3665 ! ghalf=0.5D0*ggg(k)
3666 ! gelc(k,i)=gelc(k,i)+ghalf
3667 ! & +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
3668 ! & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
3669 ! gelc(k,j)=gelc(k,j)+ghalf
3670 ! & +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
3671 ! & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
3675 !grad gelc(l,k)=gelc(l,k)+ggg(l)
3679 gelc(k,i)=gelc(k,i) &
3680 +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
3681 + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)&
3683 *fac_shield(i)**2*fac_shield(j)**2 &
3684 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3686 gelc(k,j)=gelc(k,j) &
3687 +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
3688 + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
3690 *fac_shield(i)**2*fac_shield(j)**2 &
3691 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3693 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
3694 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
3697 IF (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
3698 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 &
3699 .or. wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
3701 ! 9/25/99 Mixed third-order local-electrostatic terms. The local-interaction
3702 ! energy of a peptide unit is assumed in the form of a second-order
3703 ! Fourier series in the angles lambda1 and lambda2 (see Nishikawa et al.
3704 ! Macromolecules, 1974, 7, 797-806 for definition). This correlation terms
3705 ! are computed for EVERY pair of non-contiguous peptide groups.
3707 if (j.lt.nres-1) then
3718 muij(kkk)=mu(k,i)*mu(l,j)
3721 !d write (iout,*) 'EELEC: i',i,' j',j
3722 !d write (iout,*) 'j',j,' j1',j1,' j2',j2
3723 !d write(iout,*) 'muij',muij
3724 ury=scalar(uy(1,i),erij)
3725 urz=scalar(uz(1,i),erij)
3726 vry=scalar(uy(1,j),erij)
3727 vrz=scalar(uz(1,j),erij)
3728 a22=scalar(uy(1,i),uy(1,j))-3*ury*vry
3729 a23=scalar(uy(1,i),uz(1,j))-3*ury*vrz
3730 a32=scalar(uz(1,i),uy(1,j))-3*urz*vry
3731 a33=scalar(uz(1,i),uz(1,j))-3*urz*vrz
3732 fac=dsqrt(-ael6i)*r3ij
3737 !d write (iout,'(4i5,4f10.5)')
3738 !d & i,itortyp(itype(i,1)),j,itortyp(itype(j,1)),a22,a23,a32,a33
3739 !d write (iout,'(6f10.5)') (muij(k),k=1,4),fac,eel_loc_ij
3740 !d write (iout,'(2(3f10.5,5x)/2(3f10.5,5x))') uy(:,i),uz(:,i),
3741 !d & uy(:,j),uz(:,j)
3742 !d write (iout,'(4f10.5)')
3743 !d & scalar(uy(1,i),uy(1,j)),scalar(uy(1,i),uz(1,j)),
3744 !d & scalar(uz(1,i),uy(1,j)),scalar(uz(1,i),uz(1,j))
3745 !d write (iout,'(4f10.5)') ury,urz,vry,vrz
3746 !d write (iout,'(9f10.5/)')
3747 !d & fac22,a22,fac23,a23,fac32,a32,fac33,a33,eel_loc_ij
3748 ! Derivatives of the elements of A in virtual-bond vectors
3749 call unormderiv(erij(1),unmat(1,1),rmij,erder(1,1))
3751 uryg(k,1)=scalar(erder(1,k),uy(1,i))
3752 uryg(k,2)=scalar(uygrad(1,k,1,i),erij(1))
3753 uryg(k,3)=scalar(uygrad(1,k,2,i),erij(1))
3754 urzg(k,1)=scalar(erder(1,k),uz(1,i))
3755 urzg(k,2)=scalar(uzgrad(1,k,1,i),erij(1))
3756 urzg(k,3)=scalar(uzgrad(1,k,2,i),erij(1))
3757 vryg(k,1)=scalar(erder(1,k),uy(1,j))
3758 vryg(k,2)=scalar(uygrad(1,k,1,j),erij(1))
3759 vryg(k,3)=scalar(uygrad(1,k,2,j),erij(1))
3760 vrzg(k,1)=scalar(erder(1,k),uz(1,j))
3761 vrzg(k,2)=scalar(uzgrad(1,k,1,j),erij(1))
3762 vrzg(k,3)=scalar(uzgrad(1,k,2,j),erij(1))
3764 ! Compute radial contributions to the gradient
3782 ! Add the contributions coming from er
3785 agg(k,1)=agg(k,1)+fac3*(uryg(k,1)*vry+vryg(k,1)*ury)
3786 agg(k,2)=agg(k,2)+fac3*(uryg(k,1)*vrz+vrzg(k,1)*ury)
3787 agg(k,3)=agg(k,3)+fac3*(urzg(k,1)*vry+vryg(k,1)*urz)
3788 agg(k,4)=agg(k,4)+fac3*(urzg(k,1)*vrz+vrzg(k,1)*urz)
3791 ! Derivatives in DC(i)
3792 !grad ghalf1=0.5d0*agg(k,1)
3793 !grad ghalf2=0.5d0*agg(k,2)
3794 !grad ghalf3=0.5d0*agg(k,3)
3795 !grad ghalf4=0.5d0*agg(k,4)
3796 aggi(k,1)=fac*(scalar(uygrad(1,k,1,i),uy(1,j)) &
3797 -3.0d0*uryg(k,2)*vry)!+ghalf1
3798 aggi(k,2)=fac*(scalar(uygrad(1,k,1,i),uz(1,j)) &
3799 -3.0d0*uryg(k,2)*vrz)!+ghalf2
3800 aggi(k,3)=fac*(scalar(uzgrad(1,k,1,i),uy(1,j)) &
3801 -3.0d0*urzg(k,2)*vry)!+ghalf3
3802 aggi(k,4)=fac*(scalar(uzgrad(1,k,1,i),uz(1,j)) &
3803 -3.0d0*urzg(k,2)*vrz)!+ghalf4
3804 ! Derivatives in DC(i+1)
3805 aggi1(k,1)=fac*(scalar(uygrad(1,k,2,i),uy(1,j)) &
3806 -3.0d0*uryg(k,3)*vry)!+agg(k,1)
3807 aggi1(k,2)=fac*(scalar(uygrad(1,k,2,i),uz(1,j)) &
3808 -3.0d0*uryg(k,3)*vrz)!+agg(k,2)
3809 aggi1(k,3)=fac*(scalar(uzgrad(1,k,2,i),uy(1,j)) &
3810 -3.0d0*urzg(k,3)*vry)!+agg(k,3)
3811 aggi1(k,4)=fac*(scalar(uzgrad(1,k,2,i),uz(1,j)) &
3812 -3.0d0*urzg(k,3)*vrz)!+agg(k,4)
3813 ! Derivatives in DC(j)
3814 aggj(k,1)=fac*(scalar(uygrad(1,k,1,j),uy(1,i)) &
3815 -3.0d0*vryg(k,2)*ury)!+ghalf1
3816 aggj(k,2)=fac*(scalar(uzgrad(1,k,1,j),uy(1,i)) &
3817 -3.0d0*vrzg(k,2)*ury)!+ghalf2
3818 aggj(k,3)=fac*(scalar(uygrad(1,k,1,j),uz(1,i)) &
3819 -3.0d0*vryg(k,2)*urz)!+ghalf3
3820 aggj(k,4)=fac*(scalar(uzgrad(1,k,1,j),uz(1,i)) &
3821 -3.0d0*vrzg(k,2)*urz)!+ghalf4
3822 ! Derivatives in DC(j+1) or DC(nres-1)
3823 aggj1(k,1)=fac*(scalar(uygrad(1,k,2,j),uy(1,i)) &
3824 -3.0d0*vryg(k,3)*ury)
3825 aggj1(k,2)=fac*(scalar(uzgrad(1,k,2,j),uy(1,i)) &
3826 -3.0d0*vrzg(k,3)*ury)
3827 aggj1(k,3)=fac*(scalar(uygrad(1,k,2,j),uz(1,i)) &
3828 -3.0d0*vryg(k,3)*urz)
3829 aggj1(k,4)=fac*(scalar(uzgrad(1,k,2,j),uz(1,i)) &
3830 -3.0d0*vrzg(k,3)*urz)
3831 !grad if (j.eq.nres-1 .and. i.lt.j-2) then
3833 !grad aggj1(k,l)=aggj1(k,l)+agg(k,l)
3846 aggi(k,l)=-aggi(k,l)
3847 aggi1(k,l)=-aggi1(k,l)
3848 aggj(k,l)=-aggj(k,l)
3849 aggj1(k,l)=-aggj1(k,l)
3852 if (j.lt.nres-1) then
3858 aggi(k,l)=-aggi(k,l)
3859 aggi1(k,l)=-aggi1(k,l)
3860 aggj(k,l)=-aggj(k,l)
3861 aggj1(k,l)=-aggj1(k,l)
3872 aggi(k,l)=-aggi(k,l)
3873 aggi1(k,l)=-aggi1(k,l)
3874 aggj(k,l)=-aggj(k,l)
3875 aggj1(k,l)=-aggj1(k,l)
3880 IF (wel_loc.gt.0.0d0) THEN
3881 ! Contribution to the local-electrostatic energy coming from the i-j pair
3882 eel_loc_ij=a22*muij(1)+a23*muij(2)+a32*muij(3) &
3884 if (shield_mode.eq.0) then
3888 eel_loc_ij=eel_loc_ij &
3889 *fac_shield(i)*fac_shield(j) &
3890 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
3891 !C Now derivative over eel_loc
3892 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
3893 (shield_mode.gt.0)) then
3896 do ilist=1,ishield_list(i)
3897 iresshield=shield_list(ilist,i)
3899 rlocshield=grad_shield_side(k,ilist,i)*eel_loc_ij &
3902 gshieldx_ll(k,iresshield)=gshieldx_ll(k,iresshield)+ &
3904 +grad_shield_loc(k,ilist,i)*eel_loc_ij/fac_shield(i) &
3907 gshieldc_ll(k,iresshield-1)=gshieldc_ll(k,iresshield-1)&
3911 do ilist=1,ishield_list(j)
3912 iresshield=shield_list(ilist,j)
3914 rlocshield=grad_shield_side(k,ilist,j)*eel_loc_ij &
3917 gshieldx_ll(k,iresshield)=gshieldx_ll(k,iresshield)+ &
3919 +grad_shield_loc(k,ilist,j)*eel_loc_ij/fac_shield(j) &
3922 gshieldc_ll(k,iresshield-1)=gshieldc_ll(k,iresshield-1)&
3929 gshieldc_ll(k,i)=gshieldc_ll(k,i)+ &
3930 grad_shield(k,i)*eel_loc_ij/fac_shield(i) &
3932 gshieldc_ll(k,j)=gshieldc_ll(k,j)+ &
3933 grad_shield(k,j)*eel_loc_ij/fac_shield(j) &
3935 gshieldc_ll(k,i-1)=gshieldc_ll(k,i-1)+ &
3936 grad_shield(k,i)*eel_loc_ij/fac_shield(i) &
3938 gshieldc_ll(k,j-1)=gshieldc_ll(k,j-1)+ &
3939 grad_shield(k,j)*eel_loc_ij/fac_shield(j) &
3946 ! write (iout,*) 'i',i,' j',j,' eel_loc_ij',eel_loc_ij
3948 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
3949 'eelloc',i,j,eel_loc_ij
3950 ! if (energy_dec) write (iout,*) "a22",a22," a23",a23," a32",a32," a33",a33
3951 ! if (energy_dec) write (iout,*) "muij",muij
3952 ! write (iout,*) a22,muij(1),a23,muij(2),a32,muij(3)
3954 eel_loc=eel_loc+eel_loc_ij*sss_ele_cut
3955 ! Partial derivatives in virtual-bond dihedral angles gamma
3957 gel_loc_loc(i-1)=gel_loc_loc(i-1)+ &
3958 (a22*muder(1,i)*mu(1,j)+a23*muder(1,i)*mu(2,j) &
3959 +a32*muder(2,i)*mu(1,j)+a33*muder(2,i)*mu(2,j)) &
3961 *fac_shield(i)*fac_shield(j) &
3962 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
3964 gel_loc_loc(j-1)=gel_loc_loc(j-1)+ &
3965 (a22*mu(1,i)*muder(1,j)+a23*mu(1,i)*muder(2,j) &
3966 +a32*mu(2,i)*muder(1,j)+a33*mu(2,i)*muder(2,j)) &
3968 *fac_shield(i)*fac_shield(j) &
3969 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
3970 ! Derivatives of eello in DC(i+1) thru DC(j-1) or DC(nres-2)
3972 ! ggg(1)=(agg(1,1)*muij(1)+ &
3973 ! agg(1,2)*muij(2)+agg(1,3)*muij(3)+agg(1,4)*muij(4)) &
3975 ! +eel_loc_ij*sss_ele_grad*rmij*xj
3976 ! ggg(2)=(agg(2,1)*muij(1)+ &
3977 ! agg(2,2)*muij(2)+agg(2,3)*muij(3)+agg(2,4)*muij(4)) &
3979 ! +eel_loc_ij*sss_ele_grad*rmij*yj
3980 ! ggg(3)=(agg(3,1)*muij(1)+ &
3981 ! agg(3,2)*muij(2)+agg(3,3)*muij(3)+agg(3,4)*muij(4)) &
3983 ! +eel_loc_ij*sss_ele_grad*rmij*zj
3989 ggg(l)=(agg(l,1)*muij(1)+ &
3990 agg(l,2)*muij(2)+agg(l,3)*muij(3)+agg(l,4)*muij(4))&
3992 *fac_shield(i)*fac_shield(j) &
3993 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0) &
3994 +eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
3997 gel_loc_long(l,j)=gel_loc_long(l,j)+ggg(l)
3998 gel_loc_long(l,i)=gel_loc_long(l,i)-ggg(l)
3999 !grad ghalf=0.5d0*ggg(l)
4000 !grad gel_loc(l,i)=gel_loc(l,i)+ghalf
4001 !grad gel_loc(l,j)=gel_loc(l,j)+ghalf
4003 gel_loc_long(3,j)=gel_loc_long(3,j)+ &
4004 ssgradlipj*eel_loc_ij/2.0d0*lipscale/ &
4005 ((sslipi+sslipj)/2.0d0*lipscale+1.0d0)*sss_ele_cut
4007 gel_loc_long(3,i)=gel_loc_long(3,i)+ &
4008 ssgradlipi*eel_loc_ij/2.0d0*lipscale/ &
4009 ((sslipi+sslipj)/2.0d0*lipscale+1.0d0)*sss_ele_cut
4013 !grad gel_loc(l,k)=gel_loc(l,k)+ggg(l)
4016 ! Remaining derivatives of eello
4018 gel_loc(l,i)=gel_loc(l,i)+(aggi(l,1)*muij(1)+ &
4019 aggi(l,2)*muij(2)+aggi(l,3)*muij(3)+aggi(l,4)*muij(4))&
4021 *fac_shield(i)*fac_shield(j) &
4022 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4024 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
4025 gel_loc(l,i+1)=gel_loc(l,i+1)+(aggi1(l,1)*muij(1)+ &
4026 aggi1(l,2)*muij(2)+aggi1(l,3)*muij(3) &
4027 +aggi1(l,4)*muij(4))&
4029 *fac_shield(i)*fac_shield(j) &
4030 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4032 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
4033 gel_loc(l,j)=gel_loc(l,j)+(aggj(l,1)*muij(1)+ &
4034 aggj(l,2)*muij(2)+aggj(l,3)*muij(3)+aggj(l,4)*muij(4))&
4036 *fac_shield(i)*fac_shield(j) &
4037 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4039 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
4040 gel_loc(l,j1)=gel_loc(l,j1)+(aggj1(l,1)*muij(1)+ &
4041 aggj1(l,2)*muij(2)+aggj1(l,3)*muij(3) &
4042 +aggj1(l,4)*muij(4))&
4044 *fac_shield(i)*fac_shield(j) &
4045 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4047 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
4050 ! Change 12/26/95 to calculate four-body contributions to H-bonding energy
4051 ! if (j.gt.i+1 .and. num_conti.le.maxconts) then
4052 if (wcorr+wcorr4+wcorr5+wcorr6.gt.0.0d0 &
4053 .and. num_conti.le.maxconts) then
4054 ! write (iout,*) i,j," entered corr"
4056 ! Calculate the contact function. The ith column of the array JCONT will
4057 ! contain the numbers of atoms that make contacts with the atom I (of numbers
4058 ! greater than I). The arrays FACONT and GACONT will contain the values of
4059 ! the contact function and its derivative.
4060 ! r0ij=1.02D0*rpp(iteli,itelj)
4061 ! r0ij=1.11D0*rpp(iteli,itelj)
4062 r0ij=2.20D0*rpp(iteli,itelj)
4063 ! r0ij=1.55D0*rpp(iteli,itelj)
4064 call gcont(rij,r0ij,1.0D0,0.2d0*r0ij,fcont,fprimcont)
4065 !elwrite(iout,*) "num_conti",num_conti, "maxconts",maxconts
4066 if (fcont.gt.0.0D0) then
4067 num_conti=num_conti+1
4068 if (num_conti.gt.maxconts) then
4069 !el write (iout,*) "esrgresgdsrgdfsrgdswrgaresfgaerwgae"
4070 !el write (iout,*) "num_conti",num_conti, "maxconts",maxconts
4071 write (iout,*) 'WARNING - max. # of contacts exceeded;',&
4072 ' will skip next contacts for this conf.', num_conti
4074 jcont_hb(num_conti,i)=j
4075 !d write (iout,*) "i",i," j",j," num_conti",num_conti,
4076 !d & " jcont_hb",jcont_hb(num_conti,i)
4077 IF (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. &
4078 wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
4079 ! 9/30/99 (AL) - store components necessary to evaluate higher-order loc-el
4081 d_cont(num_conti,i)=rij
4082 !d write (2,'(3e15.5)') rij,r0ij+0.2d0*r0ij,rij
4083 ! --- Electrostatic-interaction matrix ---
4084 a_chuj(1,1,num_conti,i)=a22
4085 a_chuj(1,2,num_conti,i)=a23
4086 a_chuj(2,1,num_conti,i)=a32
4087 a_chuj(2,2,num_conti,i)=a33
4088 ! --- Gradient of rij
4090 grij_hb_cont(kkk,num_conti,i)=erij(kkk)
4097 a_chuj_der(k,l,m,1,num_conti,i)=agg(m,kkll)
4098 a_chuj_der(k,l,m,2,num_conti,i)=aggi(m,kkll)
4099 a_chuj_der(k,l,m,3,num_conti,i)=aggi1(m,kkll)
4100 a_chuj_der(k,l,m,4,num_conti,i)=aggj(m,kkll)
4101 a_chuj_der(k,l,m,5,num_conti,i)=aggj1(m,kkll)
4106 IF (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) THEN
4107 ! Calculate contact energies
4109 wij=cosa-3.0D0*cosb*cosg
4112 ! fac3=dsqrt(-ael6i)/r0ij**3
4113 fac3=dsqrt(-ael6i)*r3ij
4114 ! ees0pij=dsqrt(4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1)
4115 ees0tmp=4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1
4116 if (ees0tmp.gt.0) then
4117 ees0pij=dsqrt(ees0tmp)
4121 if (shield_mode.eq.0) then
4125 ees0plist(num_conti,i)=j
4127 ! ees0mij=dsqrt(4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2)
4128 ees0tmp=4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2
4129 if (ees0tmp.gt.0) then
4130 ees0mij=dsqrt(ees0tmp)
4135 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij) &
4137 *fac_shield(i)*fac_shield(j)
4139 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij) &
4141 *fac_shield(i)*fac_shield(j)
4143 ! Diagnostics. Comment out or remove after debugging!
4144 ! ees0p(num_conti,i)=0.5D0*fac3*ees0pij
4145 ! ees0m(num_conti,i)=0.5D0*fac3*ees0mij
4146 ! ees0m(num_conti,i)=0.0D0
4148 ! write (iout,*) 'i=',i,' j=',j,' rij=',rij,' r0ij=',r0ij,
4149 ! & ' ees0ij=',ees0p(num_conti,i),ees0m(num_conti,i),' fcont=',fcont
4150 ! Angular derivatives of the contact function
4151 ees0pij1=fac3/ees0pij
4152 ees0mij1=fac3/ees0mij
4153 fac3p=-3.0D0*fac3*rrmij
4154 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
4155 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
4157 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
4158 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
4159 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
4160 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
4161 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
4162 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
4163 ecosap=ecosa1+ecosa2
4164 ecosbp=ecosb1+ecosb2
4165 ecosgp=ecosg1+ecosg2
4166 ecosam=ecosa1-ecosa2
4167 ecosbm=ecosb1-ecosb2
4168 ecosgm=ecosg1-ecosg2
4177 facont_hb(num_conti,i)=fcont
4178 fprimcont=fprimcont/rij
4179 !d facont_hb(num_conti,i)=1.0D0
4180 ! Following line is for diagnostics.
4183 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
4184 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
4187 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
4188 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
4190 gggp(1)=gggp(1)+ees0pijp*xj &
4191 +ees0p(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
4192 gggp(2)=gggp(2)+ees0pijp*yj &
4193 +ees0p(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
4194 gggp(3)=gggp(3)+ees0pijp*zj &
4195 +ees0p(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
4197 gggm(1)=gggm(1)+ees0mijp*xj &
4198 +ees0m(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
4200 gggm(2)=gggm(2)+ees0mijp*yj &
4201 +ees0m(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
4203 gggm(3)=gggm(3)+ees0mijp*zj &
4204 +ees0m(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
4206 ! Derivatives due to the contact function
4207 gacont_hbr(1,num_conti,i)=fprimcont*xj
4208 gacont_hbr(2,num_conti,i)=fprimcont*yj
4209 gacont_hbr(3,num_conti,i)=fprimcont*zj
4212 ! 10/24/08 cgrad and ! comments indicate the parts of the code removed
4213 ! following the change of gradient-summation algorithm.
4215 !grad ghalfp=0.5D0*gggp(k)
4216 !grad ghalfm=0.5D0*gggm(k)
4217 gacontp_hb1(k,num_conti,i)= & !ghalfp+
4218 (ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
4219 + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
4220 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4222 gacontp_hb2(k,num_conti,i)= & !ghalfp+
4223 (ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
4224 + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
4225 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4227 gacontp_hb3(k,num_conti,i)=gggp(k) &
4228 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4230 gacontm_hb1(k,num_conti,i)= & !ghalfm+
4231 (ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
4232 + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
4233 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4235 gacontm_hb2(k,num_conti,i)= & !ghalfm+
4236 (ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
4237 + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1) &
4238 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4240 gacontm_hb3(k,num_conti,i)=gggm(k) &
4241 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4244 ! Diagnostics. Comment out or remove after debugging!
4246 !diag gacontp_hb1(k,num_conti,i)=0.0D0
4247 !diag gacontp_hb2(k,num_conti,i)=0.0D0
4248 !diag gacontp_hb3(k,num_conti,i)=0.0D0
4249 !diag gacontm_hb1(k,num_conti,i)=0.0D0
4250 !diag gacontm_hb2(k,num_conti,i)=0.0D0
4251 !diag gacontm_hb3(k,num_conti,i)=0.0D0
4254 endif ! num_conti.le.maxconts
4257 if (wturn3.gt.0.0d0 .or. wturn4.gt.0.0d0) then
4260 ghalf=0.5d0*agg(l,k)
4261 aggi(l,k)=aggi(l,k)+ghalf
4262 aggi1(l,k)=aggi1(l,k)+agg(l,k)
4263 aggj(l,k)=aggj(l,k)+ghalf
4266 if (j.eq.nres-1 .and. i.lt.j-2) then
4269 aggj1(l,k)=aggj1(l,k)+agg(l,k)
4275 ! t_eelecij=t_eelecij+MPI_Wtime()-time00
4277 end subroutine eelecij
4278 !-----------------------------------------------------------------------------
4279 subroutine eturn3(i,eello_turn3)
4280 ! Third- and fourth-order contributions from turns
4283 ! implicit real*8 (a-h,o-z)
4284 ! include 'DIMENSIONS'
4285 ! include 'COMMON.IOUNITS'
4286 ! include 'COMMON.GEO'
4287 ! include 'COMMON.VAR'
4288 ! include 'COMMON.LOCAL'
4289 ! include 'COMMON.CHAIN'
4290 ! include 'COMMON.DERIV'
4291 ! include 'COMMON.INTERACT'
4292 ! include 'COMMON.CONTACTS'
4293 ! include 'COMMON.TORSION'
4294 ! include 'COMMON.VECTORS'
4295 ! include 'COMMON.FFIELD'
4296 ! include 'COMMON.CONTROL'
4297 real(kind=8),dimension(3) :: ggg
4298 real(kind=8),dimension(2,2) :: auxmat,auxmat1,auxmat2,pizda,&
4299 e1t,e2t,e3t,e1tder,e2tder,e3tder,e1a,ae3,ae3e2
4300 real(kind=8),dimension(2) :: auxvec,auxvec1
4301 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
4302 real(kind=8),dimension(2,2) :: auxmat3 !el, a_temp
4303 !el integer :: num_conti,j1,j2
4304 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
4305 !el dz_normi,xmedi,ymedi,zmedi
4307 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
4308 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
4311 integer :: i,j,l,k,ilist,iresshield
4312 real(kind=8) :: eello_turn3,zj,fracinbuf,eello_t3, rlocshield
4315 ! write (iout,*) "eturn3",i,j,j1,j2
4316 zj=(c(3,j)+c(3,j+1))/2.0d0
4318 if (zj.lt.0) zj=zj+boxzsize
4319 if ((zj.lt.0)) write (*,*) "CHUJ"
4320 if ((zj.gt.bordlipbot) &
4321 .and.(zj.lt.bordliptop)) then
4322 !C the energy transfer exist
4323 if (zj.lt.buflipbot) then
4324 !C what fraction I am in
4326 ((zj-bordlipbot)/lipbufthick)
4327 !C lipbufthick is thickenes of lipid buffore
4328 sslipj=sscalelip(fracinbuf)
4329 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
4330 elseif (zj.gt.bufliptop) then
4331 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
4332 sslipj=sscalelip(fracinbuf)
4333 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
4347 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4349 ! Third-order contributions
4356 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4357 !d call checkint_turn3(i,a_temp,eello_turn3_num)
4358 call matmat2(EUg(1,1,i+1),EUg(1,1,i+2),auxmat(1,1))
4359 call transpose2(auxmat(1,1),auxmat1(1,1))
4360 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4361 if (shield_mode.eq.0) then
4366 eello_turn3=eello_turn3+0.5d0*(pizda(1,1)+pizda(2,2)) &
4367 *fac_shield(i)*fac_shield(j) &
4368 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4370 0.5d0*(pizda(1,1)+pizda(2,2)) &
4371 *fac_shield(i)*fac_shield(j)
4373 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
4374 'eturn3',i,j,0.5d0*(pizda(1,1)+pizda(2,2))
4375 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
4376 (shield_mode.gt.0)) then
4379 do ilist=1,ishield_list(i)
4380 iresshield=shield_list(ilist,i)
4382 rlocshield=grad_shield_side(k,ilist,i)*eello_t3/fac_shield(i)
4383 gshieldx_t3(k,iresshield)=gshieldx_t3(k,iresshield)+ &
4385 +grad_shield_loc(k,ilist,i)*eello_t3/fac_shield(i)
4386 gshieldc_t3(k,iresshield-1)=gshieldc_t3(k,iresshield-1) &
4390 do ilist=1,ishield_list(j)
4391 iresshield=shield_list(ilist,j)
4393 rlocshield=grad_shield_side(k,ilist,j)*eello_t3/fac_shield(j)
4394 gshieldx_t3(k,iresshield)=gshieldx_t3(k,iresshield)+ &
4396 +grad_shield_loc(k,ilist,j)*eello_t3/fac_shield(j)
4397 gshieldc_t3(k,iresshield-1)=gshieldc_t3(k,iresshield-1) &
4404 gshieldc_t3(k,i)=gshieldc_t3(k,i)+ &
4405 grad_shield(k,i)*eello_t3/fac_shield(i)
4406 gshieldc_t3(k,j)=gshieldc_t3(k,j)+ &
4407 grad_shield(k,j)*eello_t3/fac_shield(j)
4408 gshieldc_t3(k,i-1)=gshieldc_t3(k,i-1)+ &
4409 grad_shield(k,i)*eello_t3/fac_shield(i)
4410 gshieldc_t3(k,j-1)=gshieldc_t3(k,j-1)+ &
4411 grad_shield(k,j)*eello_t3/fac_shield(j)
4415 !d write (2,*) 'i,',i,' j',j,'eello_turn3',
4416 !d & 0.5d0*(pizda(1,1)+pizda(2,2)),
4417 !d & ' eello_turn3_num',4*eello_turn3_num
4418 ! Derivatives in gamma(i)
4419 call matmat2(EUgder(1,1,i+1),EUg(1,1,i+2),auxmat2(1,1))
4420 call transpose2(auxmat2(1,1),auxmat3(1,1))
4421 call matmat2(a_temp(1,1),auxmat3(1,1),pizda(1,1))
4422 gel_loc_turn3(i)=gel_loc_turn3(i)+0.5d0*(pizda(1,1)+pizda(2,2))&
4423 *fac_shield(i)*fac_shield(j) &
4424 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4425 ! Derivatives in gamma(i+1)
4426 call matmat2(EUg(1,1,i+1),EUgder(1,1,i+2),auxmat2(1,1))
4427 call transpose2(auxmat2(1,1),auxmat3(1,1))
4428 call matmat2(a_temp(1,1),auxmat3(1,1),pizda(1,1))
4429 gel_loc_turn3(i+1)=gel_loc_turn3(i+1) &
4430 +0.5d0*(pizda(1,1)+pizda(2,2)) &
4431 *fac_shield(i)*fac_shield(j) &
4432 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4434 ! Cartesian derivatives
4436 ! ghalf1=0.5d0*agg(l,1)
4437 ! ghalf2=0.5d0*agg(l,2)
4438 ! ghalf3=0.5d0*agg(l,3)
4439 ! ghalf4=0.5d0*agg(l,4)
4440 a_temp(1,1)=aggi(l,1)!+ghalf1
4441 a_temp(1,2)=aggi(l,2)!+ghalf2
4442 a_temp(2,1)=aggi(l,3)!+ghalf3
4443 a_temp(2,2)=aggi(l,4)!+ghalf4
4444 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4445 gcorr3_turn(l,i)=gcorr3_turn(l,i) &
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)=aggi1(l,1)!+agg(l,1)
4451 a_temp(1,2)=aggi1(l,2)!+agg(l,2)
4452 a_temp(2,1)=aggi1(l,3)!+agg(l,3)
4453 a_temp(2,2)=aggi1(l,4)!+agg(l,4)
4454 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4455 gcorr3_turn(l,i+1)=gcorr3_turn(l,i+1) &
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)=aggj(l,1)!+ghalf1
4461 a_temp(1,2)=aggj(l,2)!+ghalf2
4462 a_temp(2,1)=aggj(l,3)!+ghalf3
4463 a_temp(2,2)=aggj(l,4)!+ghalf4
4464 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4465 gcorr3_turn(l,j)=gcorr3_turn(l,j) &
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 a_temp(1,1)=aggj1(l,1)
4471 a_temp(1,2)=aggj1(l,2)
4472 a_temp(2,1)=aggj1(l,3)
4473 a_temp(2,2)=aggj1(l,4)
4474 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4475 gcorr3_turn(l,j1)=gcorr3_turn(l,j1) &
4476 +0.5d0*(pizda(1,1)+pizda(2,2)) &
4477 *fac_shield(i)*fac_shield(j) &
4478 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4480 gshieldc_t3(3,i)=gshieldc_t3(3,i)+ &
4481 ssgradlipi*eello_t3/4.0d0*lipscale
4482 gshieldc_t3(3,j)=gshieldc_t3(3,j)+ &
4483 ssgradlipj*eello_t3/4.0d0*lipscale
4484 gshieldc_t3(3,i-1)=gshieldc_t3(3,i-1)+ &
4485 ssgradlipi*eello_t3/4.0d0*lipscale
4486 gshieldc_t3(3,j-1)=gshieldc_t3(3,j-1)+ &
4487 ssgradlipj*eello_t3/4.0d0*lipscale
4490 end subroutine eturn3
4491 !-----------------------------------------------------------------------------
4492 subroutine eturn4(i,eello_turn4)
4493 ! Third- and fourth-order contributions from turns
4496 ! implicit real*8 (a-h,o-z)
4497 ! include 'DIMENSIONS'
4498 ! include 'COMMON.IOUNITS'
4499 ! include 'COMMON.GEO'
4500 ! include 'COMMON.VAR'
4501 ! include 'COMMON.LOCAL'
4502 ! include 'COMMON.CHAIN'
4503 ! include 'COMMON.DERIV'
4504 ! include 'COMMON.INTERACT'
4505 ! include 'COMMON.CONTACTS'
4506 ! include 'COMMON.TORSION'
4507 ! include 'COMMON.VECTORS'
4508 ! include 'COMMON.FFIELD'
4509 ! include 'COMMON.CONTROL'
4510 real(kind=8),dimension(3) :: ggg
4511 real(kind=8),dimension(2,2) :: auxmat,auxmat1,auxmat2,pizda,&
4512 e1t,e2t,e3t,e1tder,e2tder,e3tder,e1a,ae3,ae3e2
4513 real(kind=8),dimension(2) :: auxvec,auxvec1
4514 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
4515 real(kind=8),dimension(2,2) :: auxmat3 !el a_temp
4516 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
4517 !el dz_normi,xmedi,ymedi,zmedi
4518 !el integer :: num_conti,j1,j2
4519 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
4520 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
4523 integer :: i,j,iti1,iti2,iti3,l,k,ilist,iresshield
4524 real(kind=8) :: eello_turn4,s1,s2,s3,zj,fracinbuf,eello_t4,&
4528 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4530 ! Fourth-order contributions
4538 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4539 !d call checkint_turn4(i,a_temp,eello_turn4_num)
4540 ! write (iout,*) "eturn4 i",i," j",j," j1",j1," j2",j2
4541 zj=(c(3,j)+c(3,j+1))/2.0d0
4543 if (zj.lt.0) zj=zj+boxzsize
4544 if ((zj.gt.bordlipbot) &
4545 .and.(zj.lt.bordliptop)) then
4546 !C the energy transfer exist
4547 if (zj.lt.buflipbot) then
4548 !C what fraction I am in
4550 ((zj-bordlipbot)/lipbufthick)
4551 !C lipbufthick is thickenes of lipid buffore
4552 sslipj=sscalelip(fracinbuf)
4553 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
4554 elseif (zj.gt.bufliptop) then
4555 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
4556 sslipj=sscalelip(fracinbuf)
4557 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
4571 iti1=itortyp(itype(i+1,1))
4572 iti2=itortyp(itype(i+2,1))
4573 iti3=itortyp(itype(i+3,1))
4574 ! write(iout,*) "iti1",iti1," iti2",iti2," iti3",iti3
4575 call transpose2(EUg(1,1,i+1),e1t(1,1))
4576 call transpose2(Eug(1,1,i+2),e2t(1,1))
4577 call transpose2(Eug(1,1,i+3),e3t(1,1))
4578 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4579 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4580 s1=scalar2(b1(1,iti2),auxvec(1))
4581 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4582 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4583 s2=scalar2(b1(1,iti1),auxvec(1))
4584 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4585 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4586 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4587 if (shield_mode.eq.0) then
4592 eello_turn4=eello_turn4-(s1+s2+s3) &
4593 *fac_shield(i)*fac_shield(j) &
4594 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4595 eello_t4=-(s1+s2+s3) &
4596 *fac_shield(i)*fac_shield(j)
4597 !C Now derivative over shield:
4598 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
4599 (shield_mode.gt.0)) then
4602 do ilist=1,ishield_list(i)
4603 iresshield=shield_list(ilist,i)
4605 rlocshield=grad_shield_side(k,ilist,i)*eello_t4/fac_shield(i)
4606 gshieldx_t4(k,iresshield)=gshieldx_t4(k,iresshield)+ &
4608 +grad_shield_loc(k,ilist,i)*eello_t4/fac_shield(i)
4609 gshieldc_t4(k,iresshield-1)=gshieldc_t4(k,iresshield-1) &
4613 do ilist=1,ishield_list(j)
4614 iresshield=shield_list(ilist,j)
4616 rlocshield=grad_shield_side(k,ilist,j)*eello_t4/fac_shield(j)
4617 gshieldx_t4(k,iresshield)=gshieldx_t4(k,iresshield)+ &
4619 +grad_shield_loc(k,ilist,j)*eello_t4/fac_shield(j)
4620 gshieldc_t4(k,iresshield-1)=gshieldc_t4(k,iresshield-1) &
4627 gshieldc_t4(k,i)=gshieldc_t4(k,i)+ &
4628 grad_shield(k,i)*eello_t4/fac_shield(i)
4629 gshieldc_t4(k,j)=gshieldc_t4(k,j)+ &
4630 grad_shield(k,j)*eello_t4/fac_shield(j)
4631 gshieldc_t4(k,i-1)=gshieldc_t4(k,i-1)+ &
4632 grad_shield(k,i)*eello_t4/fac_shield(i)
4633 gshieldc_t4(k,j-1)=gshieldc_t4(k,j-1)+ &
4634 grad_shield(k,j)*eello_t4/fac_shield(j)
4638 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
4639 'eturn4',i,j,-(s1+s2+s3)
4640 !d write (2,*) 'i,',i,' j',j,'eello_turn4',-(s1+s2+s3),
4641 !d & ' eello_turn4_num',8*eello_turn4_num
4642 ! Derivatives in gamma(i)
4643 call transpose2(EUgder(1,1,i+1),e1tder(1,1))
4644 call matmat2(e1tder(1,1),a_temp(1,1),auxmat(1,1))
4645 call matvec2(auxmat(1,1),Ub2(1,i+3),auxvec(1))
4646 s1=scalar2(b1(1,iti2),auxvec(1))
4647 call matmat2(ae3e2(1,1),e1tder(1,1),pizda(1,1))
4648 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4649 gel_loc_turn4(i)=gel_loc_turn4(i)-(s1+s3) &
4650 *fac_shield(i)*fac_shield(j) &
4651 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4653 ! Derivatives in gamma(i+1)
4654 call transpose2(EUgder(1,1,i+2),e2tder(1,1))
4655 call matvec2(ae3(1,1),Ub2der(1,i+2),auxvec(1))
4656 s2=scalar2(b1(1,iti1),auxvec(1))
4657 call matmat2(ae3(1,1),e2tder(1,1),auxmat(1,1))
4658 call matmat2(auxmat(1,1),e1t(1,1),pizda(1,1))
4659 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4660 gel_loc_turn4(i+1)=gel_loc_turn4(i+1)-(s2+s3) &
4661 *fac_shield(i)*fac_shield(j) &
4662 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4664 ! Derivatives in gamma(i+2)
4665 call transpose2(EUgder(1,1,i+3),e3tder(1,1))
4666 call matvec2(e1a(1,1),Ub2der(1,i+3),auxvec(1))
4667 s1=scalar2(b1(1,iti2),auxvec(1))
4668 call matmat2(a_temp(1,1),e3tder(1,1),auxmat(1,1))
4669 call matvec2(auxmat(1,1),Ub2(1,i+2),auxvec(1))
4670 s2=scalar2(b1(1,iti1),auxvec(1))
4671 call matmat2(auxmat(1,1),e2t(1,1),auxmat3(1,1))
4672 call matmat2(auxmat3(1,1),e1t(1,1),pizda(1,1))
4673 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4674 gel_loc_turn4(i+2)=gel_loc_turn4(i+2)-(s1+s2+s3) &
4675 *fac_shield(i)*fac_shield(j) &
4676 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4678 ! Cartesian derivatives
4679 ! Derivatives of this turn contributions in DC(i+2)
4680 if (j.lt.nres-1) then
4682 a_temp(1,1)=agg(l,1)
4683 a_temp(1,2)=agg(l,2)
4684 a_temp(2,1)=agg(l,3)
4685 a_temp(2,2)=agg(l,4)
4686 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4687 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4688 s1=scalar2(b1(1,iti2),auxvec(1))
4689 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4690 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4691 s2=scalar2(b1(1,iti1),auxvec(1))
4692 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4693 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4694 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4696 gcorr4_turn(l,i+2)=gcorr4_turn(l,i+2)-(s1+s2+s3)&
4697 *fac_shield(i)*fac_shield(j) &
4698 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4702 ! Remaining derivatives of this turn contribution
4704 a_temp(1,1)=aggi(l,1)
4705 a_temp(1,2)=aggi(l,2)
4706 a_temp(2,1)=aggi(l,3)
4707 a_temp(2,2)=aggi(l,4)
4708 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4709 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4710 s1=scalar2(b1(1,iti2),auxvec(1))
4711 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4712 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4713 s2=scalar2(b1(1,iti1),auxvec(1))
4714 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4715 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4716 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4717 gcorr4_turn(l,i)=gcorr4_turn(l,i)-(s1+s2+s3) &
4718 *fac_shield(i)*fac_shield(j) &
4719 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4722 a_temp(1,1)=aggi1(l,1)
4723 a_temp(1,2)=aggi1(l,2)
4724 a_temp(2,1)=aggi1(l,3)
4725 a_temp(2,2)=aggi1(l,4)
4726 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4727 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4728 s1=scalar2(b1(1,iti2),auxvec(1))
4729 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4730 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4731 s2=scalar2(b1(1,iti1),auxvec(1))
4732 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4733 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4734 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4735 gcorr4_turn(l,i+1)=gcorr4_turn(l,i+1)-(s1+s2+s3) &
4736 *fac_shield(i)*fac_shield(j) &
4737 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4740 a_temp(1,1)=aggj(l,1)
4741 a_temp(1,2)=aggj(l,2)
4742 a_temp(2,1)=aggj(l,3)
4743 a_temp(2,2)=aggj(l,4)
4744 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4745 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4746 s1=scalar2(b1(1,iti2),auxvec(1))
4747 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4748 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4749 s2=scalar2(b1(1,iti1),auxvec(1))
4750 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4751 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4752 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4753 gcorr4_turn(l,j)=gcorr4_turn(l,j)-(s1+s2+s3) &
4754 *fac_shield(i)*fac_shield(j) &
4755 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4758 a_temp(1,1)=aggj1(l,1)
4759 a_temp(1,2)=aggj1(l,2)
4760 a_temp(2,1)=aggj1(l,3)
4761 a_temp(2,2)=aggj1(l,4)
4762 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4763 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4764 s1=scalar2(b1(1,iti2),auxvec(1))
4765 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4766 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4767 s2=scalar2(b1(1,iti1),auxvec(1))
4768 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4769 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4770 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4771 ! write (iout,*) "s1",s1," s2",s2," s3",s3," s1+s2+s3",s1+s2+s3
4772 gcorr4_turn(l,j1)=gcorr4_turn(l,j1)-(s1+s2+s3) &
4773 *fac_shield(i)*fac_shield(j) &
4774 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4777 gshieldc_t4(3,i)=gshieldc_t4(3,i)+ &
4778 ssgradlipi*eello_t4/4.0d0*lipscale
4779 gshieldc_t4(3,j)=gshieldc_t4(3,j)+ &
4780 ssgradlipj*eello_t4/4.0d0*lipscale
4781 gshieldc_t4(3,i-1)=gshieldc_t4(3,i-1)+ &
4782 ssgradlipi*eello_t4/4.0d0*lipscale
4783 gshieldc_t4(3,j-1)=gshieldc_t4(3,j-1)+ &
4784 ssgradlipj*eello_t4/4.0d0*lipscale
4787 end subroutine eturn4
4788 !-----------------------------------------------------------------------------
4789 subroutine unormderiv(u,ugrad,unorm,ungrad)
4790 ! This subroutine computes the derivatives of a normalized vector u, given
4791 ! the derivatives computed without normalization conditions, ugrad. Returns
4794 real(kind=8),dimension(3) :: u,vec
4795 real(kind=8),dimension(3,3) ::ugrad,ungrad
4796 real(kind=8) :: unorm !,scalar
4798 ! write (2,*) 'ugrad',ugrad
4801 vec(i)=scalar(ugrad(1,i),u(1))
4803 ! write (2,*) 'vec',vec
4806 ungrad(j,i)=(ugrad(j,i)-u(j)*vec(i))*unorm
4809 ! write (2,*) 'ungrad',ungrad
4811 end subroutine unormderiv
4812 !-----------------------------------------------------------------------------
4813 subroutine escp_soft_sphere(evdw2,evdw2_14)
4815 ! This subroutine calculates the excluded-volume interaction energy between
4816 ! peptide-group centers and side chains and its gradient in virtual-bond and
4817 ! side-chain vectors.
4819 ! implicit real*8 (a-h,o-z)
4820 ! include 'DIMENSIONS'
4821 ! include 'COMMON.GEO'
4822 ! include 'COMMON.VAR'
4823 ! include 'COMMON.LOCAL'
4824 ! include 'COMMON.CHAIN'
4825 ! include 'COMMON.DERIV'
4826 ! include 'COMMON.INTERACT'
4827 ! include 'COMMON.FFIELD'
4828 ! include 'COMMON.IOUNITS'
4829 ! include 'COMMON.CONTROL'
4830 real(kind=8),dimension(3) :: ggg
4832 integer :: i,iint,j,k,iteli,itypj
4833 real(kind=8) :: evdw2,evdw2_14,r0_scp,xi,yi,zi,xj,yj,zj,&
4834 fac,rij,r0ij,r0ijsq,evdwij,e1,e2
4839 !d print '(a)','Enter ESCP'
4840 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
4841 do i=iatscp_s,iatscp_e
4842 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
4844 xi=0.5D0*(c(1,i)+c(1,i+1))
4845 yi=0.5D0*(c(2,i)+c(2,i+1))
4846 zi=0.5D0*(c(3,i)+c(3,i+1))
4848 do iint=1,nscp_gr(i)
4850 do j=iscpstart(i,iint),iscpend(i,iint)
4851 if (itype(j,1).eq.ntyp1) cycle
4852 itypj=iabs(itype(j,1))
4853 ! Uncomment following three lines for SC-p interactions
4857 ! Uncomment following three lines for Ca-p interactions
4861 rij=xj*xj+yj*yj+zj*zj
4864 if (rij.lt.r0ijsq) then
4865 evdwij=0.25d0*(rij-r0ijsq)**2
4873 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
4878 !grad if (j.lt.i) then
4879 !d write (iout,*) 'j<i'
4880 ! Uncomment following three lines for SC-p interactions
4882 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
4885 !d write (iout,*) 'j>i'
4887 !grad ggg(k)=-ggg(k)
4888 ! Uncomment following line for SC-p interactions
4889 ! gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
4893 !grad gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
4895 !grad kstart=min0(i+1,j)
4896 !grad kend=max0(i-1,j-1)
4897 !d write (iout,*) 'i=',i,' j=',j,' kstart=',kstart,' kend=',kend
4898 !d write (iout,*) ggg(1),ggg(2),ggg(3)
4899 !grad do k=kstart,kend
4901 !grad gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
4905 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
4906 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
4913 end subroutine escp_soft_sphere
4914 !-----------------------------------------------------------------------------
4915 subroutine escp(evdw2,evdw2_14)
4917 ! This subroutine calculates the excluded-volume interaction energy between
4918 ! peptide-group centers and side chains and its gradient in virtual-bond and
4919 ! side-chain vectors.
4921 ! implicit real*8 (a-h,o-z)
4922 ! include 'DIMENSIONS'
4923 ! include 'COMMON.GEO'
4924 ! include 'COMMON.VAR'
4925 ! include 'COMMON.LOCAL'
4926 ! include 'COMMON.CHAIN'
4927 ! include 'COMMON.DERIV'
4928 ! include 'COMMON.INTERACT'
4929 ! include 'COMMON.FFIELD'
4930 ! include 'COMMON.IOUNITS'
4931 ! include 'COMMON.CONTROL'
4932 real(kind=8),dimension(3) :: ggg
4934 integer :: i,iint,j,k,iteli,itypj,subchap
4935 real(kind=8) :: evdw2,evdw2_14,xi,yi,zi,xj,yj,zj,rrij,fac,&
4937 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
4938 dist_temp, dist_init
4939 integer xshift,yshift,zshift
4943 !d print '(a)','Enter ESCP'
4944 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
4945 do i=iatscp_s,iatscp_e
4946 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
4948 xi=0.5D0*(c(1,i)+c(1,i+1))
4949 yi=0.5D0*(c(2,i)+c(2,i+1))
4950 zi=0.5D0*(c(3,i)+c(3,i+1))
4952 if (xi.lt.0) xi=xi+boxxsize
4954 if (yi.lt.0) yi=yi+boxysize
4956 if (zi.lt.0) zi=zi+boxzsize
4958 do iint=1,nscp_gr(i)
4960 do j=iscpstart(i,iint),iscpend(i,iint)
4961 itypj=iabs(itype(j,1))
4962 if (itypj.eq.ntyp1) cycle
4963 ! Uncomment following three lines for SC-p interactions
4967 ! Uncomment following three lines for Ca-p interactions
4975 if (xj.lt.0) xj=xj+boxxsize
4977 if (yj.lt.0) yj=yj+boxysize
4979 if (zj.lt.0) zj=zj+boxzsize
4980 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
4988 xj=xj_safe+xshift*boxxsize
4989 yj=yj_safe+yshift*boxysize
4990 zj=zj_safe+zshift*boxzsize
4991 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
4992 if(dist_temp.lt.dist_init) then
5002 if (subchap.eq.1) then
5012 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
5013 rij=dsqrt(1.0d0/rrij)
5014 sss_ele_cut=sscale_ele(rij)
5015 sss_ele_grad=sscagrad_ele(rij)
5016 ! print *,sss_ele_cut,sss_ele_grad,&
5017 ! (rij),r_cut_ele,rlamb_ele
5018 if (sss_ele_cut.le.0.0) cycle
5020 e1=fac*fac*aad(itypj,iteli)
5021 e2=fac*bad(itypj,iteli)
5022 if (iabs(j-i) .le. 2) then
5025 evdw2_14=evdw2_14+(e1+e2)*sss_ele_cut
5028 evdw2=evdw2+evdwij*sss_ele_cut
5029 ! if (energy_dec) write (iout,'(a6,2i5,0pf7.3,2i3,3e11.3)') &
5030 ! 'evdw2',i,j,evdwij,iteli,itypj,fac,aad(itypj,iteli),&
5031 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
5034 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
5036 fac=-(evdwij+e1)*rrij*sss_ele_cut
5037 fac=fac+evdwij*sss_ele_grad/rij/expon
5041 !grad if (j.lt.i) then
5042 !d write (iout,*) 'j<i'
5043 ! Uncomment following three lines for SC-p interactions
5045 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
5048 !d write (iout,*) 'j>i'
5050 !grad ggg(k)=-ggg(k)
5051 ! Uncomment following line for SC-p interactions
5052 !cgrad gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
5053 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
5057 !grad gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
5059 !grad kstart=min0(i+1,j)
5060 !grad kend=max0(i-1,j-1)
5061 !d write (iout,*) 'i=',i,' j=',j,' kstart=',kstart,' kend=',kend
5062 !d write (iout,*) ggg(1),ggg(2),ggg(3)
5063 !grad do k=kstart,kend
5065 !grad gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
5069 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
5070 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
5078 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
5079 gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
5080 gradx_scp(j,i)=expon*gradx_scp(j,i)
5083 !******************************************************************************
5087 ! To save time the factor EXPON has been extracted from ALL components
5088 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
5091 !******************************************************************************
5094 !-----------------------------------------------------------------------------
5095 subroutine edis(ehpb)
5097 ! Evaluate bridge-strain energy and its gradient in virtual-bond and SC vectors.
5099 ! implicit real*8 (a-h,o-z)
5100 ! include 'DIMENSIONS'
5101 ! include 'COMMON.SBRIDGE'
5102 ! include 'COMMON.CHAIN'
5103 ! include 'COMMON.DERIV'
5104 ! include 'COMMON.VAR'
5105 ! include 'COMMON.INTERACT'
5106 ! include 'COMMON.IOUNITS'
5107 real(kind=8),dimension(3) :: ggg
5109 integer :: i,j,ii,jj,iii,jjj,k
5110 real(kind=8) :: fac,eij,rdis,ehpb,dd,waga
5113 !d write(iout,*)'edis: nhpb=',nhpb,' fbr=',fbr
5114 !d write(iout,*)'link_start=',link_start,' link_end=',link_end
5115 if (link_end.eq.0) return
5116 do i=link_start,link_end
5117 ! If ihpb(i) and jhpb(i) > NRES, this is a SC-SC distance, otherwise a
5118 ! CA-CA distance used in regularization of structure.
5121 ! iii and jjj point to the residues for which the distance is assigned.
5122 if (ii.gt.nres) then
5129 ! write (iout,*) "i",i," ii",ii," iii",iii," jj",jj," jjj",jjj,
5130 ! & dhpb(i),dhpb1(i),forcon(i)
5131 ! 24/11/03 AL: SS bridges handled separately because of introducing a specific
5132 ! distance and angle dependent SS bond potential.
5133 !mc if (ii.gt.nres .and. itype(iii).eq.1 .and. itype(jjj).eq.1) then
5134 ! 18/07/06 MC: Use the convention that the first nss pairs are SS bonds
5135 if (.not.dyn_ss .and. i.le.nss) then
5136 ! 15/02/13 CC dynamic SSbond - additional check
5137 if (ii.gt.nres .and. iabs(itype(iii,1)).eq.1 .and. &
5138 iabs(itype(jjj,1)).eq.1) then
5139 call ssbond_ene(iii,jjj,eij)
5141 !d write (iout,*) "eij",eij
5143 else if (ii.gt.nres .and. jj.gt.nres) then
5144 !c Restraints from contact prediction
5146 if (constr_dist.eq.11) then
5147 ehpb=ehpb+fordepth(i)**4.0d0 &
5148 *rlornmr1(dd,dhpb(i),dhpb1(i),forcon(i))
5149 fac=fordepth(i)**4.0d0 &
5150 *rlornmr1prim(dd,dhpb(i),dhpb1(i),forcon(i))/dd
5151 if (energy_dec) write (iout,'(a6,2i5,3f8.3)') "edisl",ii,jj, &
5154 if (dhpb1(i).gt.0.0d0) then
5155 ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5156 fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
5157 !c write (iout,*) "beta nmr",
5158 !c & dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5162 !C Get the force constant corresponding to this distance.
5164 !C Calculate the contribution to energy.
5165 ehpb=ehpb+waga*rdis*rdis
5166 !c write (iout,*) "beta reg",dd,waga*rdis*rdis
5168 !C Evaluate gradient.
5174 ggg(j)=fac*(c(j,jj)-c(j,ii))
5177 ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
5178 ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
5181 ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
5182 ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
5186 if (constr_dist.eq.11) then
5187 ehpb=ehpb+fordepth(i)**4.0d0 &
5188 *rlornmr1(dd,dhpb(i),dhpb1(i),forcon(i))
5189 fac=fordepth(i)**4.0d0 &
5190 *rlornmr1prim(dd,dhpb(i),dhpb1(i),forcon(i))/dd
5191 if (energy_dec) write (iout,'(a6,2i5,3f8.3)') "edisl",ii,jj, &
5194 if (dhpb1(i).gt.0.0d0) then
5195 ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5196 fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
5197 !c write (iout,*) "alph nmr",
5198 !c & dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5201 !C Get the force constant corresponding to this distance.
5203 !C Calculate the contribution to energy.
5204 ehpb=ehpb+waga*rdis*rdis
5205 !c write (iout,*) "alpha reg",dd,waga*rdis*rdis
5207 !C Evaluate gradient.
5214 ggg(j)=fac*(c(j,jj)-c(j,ii))
5216 !cd print '(i3,3(1pe14.5))',i,(ggg(j),j=1,3)
5217 !C If this is a SC-SC distance, we need to calculate the contributions to the
5218 !C Cartesian gradient in the SC vectors (ghpbx).
5221 ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
5222 ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
5225 !cgrad do j=iii,jjj-1
5227 !cgrad ghpbc(k,j)=ghpbc(k,j)+ggg(k)
5231 ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
5232 ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
5236 if (constr_dist.ne.11) ehpb=0.5D0*ehpb
5240 !-----------------------------------------------------------------------------
5241 subroutine ssbond_ene(i,j,eij)
5243 ! Calculate the distance and angle dependent SS-bond potential energy
5244 ! using a free-energy function derived based on RHF/6-31G** ab initio
5245 ! calculations of diethyl disulfide.
5247 ! A. Liwo and U. Kozlowska, 11/24/03
5249 ! implicit real*8 (a-h,o-z)
5250 ! include 'DIMENSIONS'
5251 ! include 'COMMON.SBRIDGE'
5252 ! include 'COMMON.CHAIN'
5253 ! include 'COMMON.DERIV'
5254 ! include 'COMMON.LOCAL'
5255 ! include 'COMMON.INTERACT'
5256 ! include 'COMMON.VAR'
5257 ! include 'COMMON.IOUNITS'
5258 real(kind=8),dimension(3) :: erij,dcosom1,dcosom2,gg
5260 integer :: i,j,itypi,itypj,k
5261 real(kind=8) :: eij,rij,rrij,xi,yi,zi,dxi,dyi,dzi,dsci_inv,&
5262 xj,yj,zj,dxj,dyj,dzj,om1,om2,om12,deltad,dscj_inv,&
5263 deltat1,deltat2,deltat12,ed,pom1,pom2,eom1,eom2,eom12,&
5266 itypi=iabs(itype(i,1))
5270 dxi=dc_norm(1,nres+i)
5271 dyi=dc_norm(2,nres+i)
5272 dzi=dc_norm(3,nres+i)
5273 ! dsci_inv=dsc_inv(itypi)
5274 dsci_inv=vbld_inv(nres+i)
5275 itypj=iabs(itype(j,1))
5276 ! dscj_inv=dsc_inv(itypj)
5277 dscj_inv=vbld_inv(nres+j)
5281 dxj=dc_norm(1,nres+j)
5282 dyj=dc_norm(2,nres+j)
5283 dzj=dc_norm(3,nres+j)
5284 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
5289 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
5290 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
5291 om12=dxi*dxj+dyi*dyj+dzi*dzj
5293 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
5294 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
5300 deltat12=om2-om1+2.0d0
5302 eij=akcm*deltad*deltad+akth*(deltat1*deltat1+deltat2*deltat2) &
5303 +akct*deltad*deltat12 &
5304 +v1ss*cosphi+v2ss*cosphi*cosphi+v3ss*cosphi*cosphi*cosphi+ebr
5305 ! write(iout,*) i,j,"rij",rij,"d0cm",d0cm," akcm",akcm," akth",akth,
5306 ! & " akct",akct," deltad",deltad," deltat",deltat1,deltat2,
5307 ! & " deltat12",deltat12," eij",eij
5308 ed=2*akcm*deltad+akct*deltat12
5310 pom2=v1ss+2*v2ss*cosphi+3*v3ss*cosphi*cosphi
5311 eom1=-2*akth*deltat1-pom1-om2*pom2
5312 eom2= 2*akth*deltat2+pom1-om1*pom2
5315 ggk=ed*erij(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
5316 ghpbx(k,i)=ghpbx(k,i)-ggk &
5317 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
5318 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
5319 ghpbx(k,j)=ghpbx(k,j)+ggk &
5320 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
5321 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
5322 ghpbc(k,i)=ghpbc(k,i)-ggk
5323 ghpbc(k,j)=ghpbc(k,j)+ggk
5326 ! Calculate the components of the gradient in DC and X
5330 !grad ghpbc(l,k)=ghpbc(l,k)+gg(l)
5334 end subroutine ssbond_ene
5335 !-----------------------------------------------------------------------------
5336 subroutine ebond(estr)
5338 ! Evaluate the energy of stretching of the CA-CA and CA-SC virtual bonds
5340 ! implicit real*8 (a-h,o-z)
5341 ! include 'DIMENSIONS'
5342 ! include 'COMMON.LOCAL'
5343 ! include 'COMMON.GEO'
5344 ! include 'COMMON.INTERACT'
5345 ! include 'COMMON.DERIV'
5346 ! include 'COMMON.VAR'
5347 ! include 'COMMON.CHAIN'
5348 ! include 'COMMON.IOUNITS'
5349 ! include 'COMMON.NAMES'
5350 ! include 'COMMON.FFIELD'
5351 ! include 'COMMON.CONTROL'
5352 ! include 'COMMON.SETUP'
5353 real(kind=8),dimension(3) :: u,ud
5355 integer :: i,j,iti,nbi,k
5356 real(kind=8) :: estr,estr1,diff,uprod,usum,usumsqder,&
5361 ! if (.not.allocated(gradb)) allocate(gradb(3,nres)) !(3,maxres)
5362 ! if (.not.allocated(gradbx)) allocate(gradbx(3,nres)) !(3,maxres)
5364 do i=ibondp_start,ibondp_end
5365 if (itype(i-1,1).eq.ntyp1 .and. itype(i,1).eq.ntyp1) cycle
5366 if (itype(i-1,1).eq.ntyp1 .or. itype(i,1).eq.ntyp1) then
5367 !C estr1=estr1+gnmr1(vbld(i),-1.0d0,distchainmax)
5369 !C gradb(j,i-1)=gnmr1prim(vbld(i),-1.0d0,distchainmax) &
5370 !C *dc(j,i-1)/vbld(i)
5372 !C if (energy_dec) write(iout,*) &
5373 !C "estr1",i,gnmr1(vbld(i),-1.0d0,distchainmax)
5374 diff = vbld(i)-vbldpDUM
5376 diff = vbld(i)-vbldp0
5378 if (energy_dec) write (iout,'(a7,i5,4f7.3)') &
5379 "estr bb",i,vbld(i),vbldp0,diff,AKP*diff*diff
5382 gradb(j,i-1)=AKP*diff*dc(j,i-1)/vbld(i)
5384 ! write (iout,'(i5,3f10.5)') i,(gradb(j,i-1),j=1,3)
5387 estr=0.5d0*AKP*estr+estr1
5388 ! print *,"estr_bb",estr,AKP
5390 ! 09/18/07 AL: multimodal bond potential based on AM1 CA-SC PMF's included
5392 do i=ibond_start,ibond_end
5393 iti=iabs(itype(i,1))
5394 if (iti.eq.0) print *,"WARNING WRONG SETTTING",i
5395 if (iti.ne.10 .and. iti.ne.ntyp1) then
5398 diff=vbld(i+nres)-vbldsc0(1,iti)
5399 if (energy_dec) write (iout,*) &
5400 "estr sc",i,iti,vbld(i+nres),vbldsc0(1,iti),diff,&
5401 AKSC(1,iti),AKSC(1,iti)*diff*diff
5402 estr=estr+0.5d0*AKSC(1,iti)*diff*diff
5403 ! print *,"estr_sc",estr
5405 gradbx(j,i)=AKSC(1,iti)*diff*dc(j,i+nres)/vbld(i+nres)
5409 diff=vbld(i+nres)-vbldsc0(j,iti)
5410 ud(j)=aksc(j,iti)*diff
5411 u(j)=abond0(j,iti)+0.5d0*ud(j)*diff
5425 uprod2=uprod2*u(k)*u(k)
5429 usumsqder=usumsqder+ud(j)*uprod2
5431 estr=estr+uprod/usum
5432 ! print *,"estr_sc",estr,i
5434 if (energy_dec) write (iout,*) &
5435 "estr sc",i,iti,vbld(i+nres),vbldsc0(1,iti),diff,&
5436 AKSC(1,iti),uprod/usum
5438 gradbx(j,i)=usumsqder/(usum*usum)*dc(j,i+nres)/vbld(i+nres)
5444 end subroutine ebond
5446 !-----------------------------------------------------------------------------
5447 subroutine ebend(etheta)
5449 ! Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
5450 ! angles gamma and its derivatives in consecutive thetas and gammas.
5453 ! implicit real*8 (a-h,o-z)
5454 ! include 'DIMENSIONS'
5455 ! include 'COMMON.LOCAL'
5456 ! include 'COMMON.GEO'
5457 ! include 'COMMON.INTERACT'
5458 ! include 'COMMON.DERIV'
5459 ! include 'COMMON.VAR'
5460 ! include 'COMMON.CHAIN'
5461 ! include 'COMMON.IOUNITS'
5462 ! include 'COMMON.NAMES'
5463 ! include 'COMMON.FFIELD'
5464 ! include 'COMMON.CONTROL'
5465 !el real(kind=8) :: term1,term2,termm,diffak,ratak,&
5466 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
5467 !el delthe0,sig0inv,sigtc,sigsqtc,delthec
5469 !el common /calcthet/ term1,term2,termm,diffak,ratak,&
5470 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
5471 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,it
5473 integer :: i,k,ichir1,ichir2,itype1,ichir11,ichir12,itype2,&
5475 real(kind=8) :: etheta,delta,ss,ssd,phii,phii1,thet_pred_mean,&
5476 athetk,bthetk,dthett,dthetg1,dthetg2,f0,fprim0,E_tc0,fprim_tc0,&
5477 f1,fprim1,E_tc1,ethetai,E_theta,E_tc
5478 real(kind=8),dimension(2) :: y,z
5481 ! time11=dexp(-2*time)
5484 ! write (*,'(a,i2)') 'EBEND ICG=',icg
5485 do i=ithet_start,ithet_end
5486 if (itype(i-1,1).eq.ntyp1) cycle
5487 ! Zero the energy function and its derivative at 0 or pi.
5488 call splinthet(theta(i),0.5d0*delta,ss,ssd)
5490 ichir1=isign(1,itype(i-2,1))
5491 ichir2=isign(1,itype(i,1))
5492 if (itype(i-2,1).eq.10) ichir1=isign(1,itype(i-1,1))
5493 if (itype(i,1).eq.10) ichir2=isign(1,itype(i-1,1))
5494 if (itype(i-1,1).eq.10) then
5495 itype1=isign(10,itype(i-2,1))
5496 ichir11=isign(1,itype(i-2,1))
5497 ichir12=isign(1,itype(i-2,1))
5498 itype2=isign(10,itype(i,1))
5499 ichir21=isign(1,itype(i,1))
5500 ichir22=isign(1,itype(i,1))
5503 if (i.gt.3 .and. itype(i-2,1).ne.ntyp1) then
5506 if (phii.ne.phii) phii=150.0
5516 if (i.lt.nres .and. itype(i,1).ne.ntyp1) then
5519 if (phii1.ne.phii1) phii1=150.0
5531 ! Calculate the "mean" value of theta from the part of the distribution
5532 ! dependent on the adjacent virtual-bond-valence angles (gamma1 & gamma2).
5533 ! In following comments this theta will be referred to as t_c.
5534 thet_pred_mean=0.0d0
5536 athetk=athet(k,it,ichir1,ichir2)
5537 bthetk=bthet(k,it,ichir1,ichir2)
5539 athetk=athet(k,itype1,ichir11,ichir12)
5540 bthetk=bthet(k,itype2,ichir21,ichir22)
5542 thet_pred_mean=thet_pred_mean+athetk*y(k)+bthetk*z(k)
5544 dthett=thet_pred_mean*ssd
5545 thet_pred_mean=thet_pred_mean*ss+a0thet(it)
5546 ! Derivatives of the "mean" values in gamma1 and gamma2.
5547 dthetg1=(-athet(1,it,ichir1,ichir2)*y(2) &
5548 +athet(2,it,ichir1,ichir2)*y(1))*ss
5549 dthetg2=(-bthet(1,it,ichir1,ichir2)*z(2) &
5550 +bthet(2,it,ichir1,ichir2)*z(1))*ss
5552 dthetg1=(-athet(1,itype1,ichir11,ichir12)*y(2) &
5553 +athet(2,itype1,ichir11,ichir12)*y(1))*ss
5554 dthetg2=(-bthet(1,itype2,ichir21,ichir22)*z(2) &
5555 +bthet(2,itype2,ichir21,ichir22)*z(1))*ss
5557 if (theta(i).gt.pi-delta) then
5558 call theteng(pi-delta,thet_pred_mean,theta0(it),f0,fprim0,&
5560 call mixder(pi-delta,thet_pred_mean,theta0(it),fprim_tc0)
5561 call theteng(pi,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
5562 call spline1(theta(i),pi-delta,delta,f0,f1,fprim0,ethetai,&
5564 call spline2(theta(i),pi-delta,delta,E_tc0,E_tc1,fprim_tc0,&
5566 else if (theta(i).lt.delta) then
5567 call theteng(delta,thet_pred_mean,theta0(it),f0,fprim0,E_tc0)
5568 call theteng(0.0d0,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
5569 call spline1(theta(i),delta,-delta,f0,f1,fprim0,ethetai,&
5571 call mixder(delta,thet_pred_mean,theta0(it),fprim_tc0)
5572 call spline2(theta(i),delta,-delta,E_tc0,E_tc1,fprim_tc0,&
5575 call theteng(theta(i),thet_pred_mean,theta0(it),ethetai,&
5578 etheta=etheta+ethetai
5579 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
5581 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*E_tc*dthetg1
5582 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*E_tc*dthetg2
5583 gloc(nphi+i-2,icg)=wang*(E_theta+E_tc*dthett)
5585 ! print *,ithetaconstr_start,ithetaconstr_end,"TU"
5587 ! Ufff.... We've done all this!!!
5589 end subroutine ebend
5590 !-----------------------------------------------------------------------------
5591 subroutine theteng(thetai,thet_pred_mean,theta0i,ethetai,E_theta,E_tc)
5594 ! implicit real*8 (a-h,o-z)
5595 ! include 'DIMENSIONS'
5596 ! include 'COMMON.LOCAL'
5597 ! include 'COMMON.IOUNITS'
5598 !el real(kind=8) :: term1,term2,termm,diffak,ratak,&
5599 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
5600 !el delthe0,sig0inv,sigtc,sigsqtc,delthec
5602 real(kind=8) :: thetai,thet_pred_mean,theta0i,ethetai,E_theta,E_tc
5604 !el common /calcthet/ term1,term2,termm,diffak,ratak,&
5605 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
5606 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,it
5608 real(kind=8) :: sig,fac,escloci0,escloci1,esclocbi0,dersc12,&
5609 esclocbi1,chuju,esclocbi,dersc02,dersc01,ss,ssd
5611 ! Calculate the contributions to both Gaussian lobes.
5612 ! 6/6/97 - Deform the Gaussians using the factor of 1/(1+time)
5613 ! The "polynomial part" of the "standard deviation" of this part of
5617 sig=sig*thet_pred_mean+polthet(j,it)
5619 ! Derivative of the "interior part" of the "standard deviation of the"
5620 ! gamma-dependent Gaussian lobe in t_c.
5621 sigtc=3*polthet(3,it)
5623 sigtc=sigtc*thet_pred_mean+j*polthet(j,it)
5626 ! Set the parameters of both Gaussian lobes of the distribution.
5627 ! "Standard deviation" of the gamma-dependent Gaussian lobe (sigtc)
5628 fac=sig*sig+sigc0(it)
5631 ! Following variable (sigsqtc) is -(1/2)d[sigma(t_c)**(-2))]/dt_c
5632 sigsqtc=-4.0D0*sigcsq*sigtc
5633 ! print *,i,sig,sigtc,sigsqtc
5634 ! Following variable (sigtc) is d[sigma(t_c)]/dt_c
5635 sigtc=-sigtc/(fac*fac)
5636 ! Following variable is sigma(t_c)**(-2)
5637 sigcsq=sigcsq*sigcsq
5639 sig0inv=1.0D0/sig0i**2
5640 delthec=thetai-thet_pred_mean
5641 delthe0=thetai-theta0i
5642 term1=-0.5D0*sigcsq*delthec*delthec
5643 term2=-0.5D0*sig0inv*delthe0*delthe0
5644 ! Following fuzzy logic is to avoid underflows in dexp and subsequent INFs and
5645 ! NaNs in taking the logarithm. We extract the largest exponent which is added
5646 ! to the energy (this being the log of the distribution) at the end of energy
5647 ! term evaluation for this virtual-bond angle.
5648 if (term1.gt.term2) then
5650 term2=dexp(term2-termm)
5654 term1=dexp(term1-termm)
5657 ! The ratio between the gamma-independent and gamma-dependent lobes of
5658 ! the distribution is a Gaussian function of thet_pred_mean too.
5659 diffak=gthet(2,it)-thet_pred_mean
5660 ratak=diffak/gthet(3,it)**2
5661 ak=dexp(gthet(1,it)-0.5D0*diffak*ratak)
5662 ! Let's differentiate it in thet_pred_mean NOW.
5664 ! Now put together the distribution terms to make complete distribution.
5665 termexp=term1+ak*term2
5666 termpre=sigc+ak*sig0i
5667 ! Contribution of the bending energy from this theta is just the -log of
5668 ! the sum of the contributions from the two lobes and the pre-exponential
5669 ! factor. Simple enough, isn't it?
5670 ethetai=(-dlog(termexp)-termm+dlog(termpre))
5671 ! NOW the derivatives!!!
5672 ! 6/6/97 Take into account the deformation.
5673 E_theta=(delthec*sigcsq*term1 &
5674 +ak*delthe0*sig0inv*term2)/termexp
5675 E_tc=((sigtc+aktc*sig0i)/termpre &
5676 -((delthec*sigcsq+delthec*delthec*sigsqtc)*term1+ &
5677 aktc*term2)/termexp)
5679 end subroutine theteng
5681 !-----------------------------------------------------------------------------
5682 subroutine ebend(etheta,ethetacnstr)
5684 ! Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
5685 ! angles gamma and its derivatives in consecutive thetas and gammas.
5686 ! ab initio-derived potentials from
5687 ! Kozlowska et al., J. Phys.: Condens. Matter 19 (2007) 285203
5689 ! implicit real*8 (a-h,o-z)
5690 ! include 'DIMENSIONS'
5691 ! include 'COMMON.LOCAL'
5692 ! include 'COMMON.GEO'
5693 ! include 'COMMON.INTERACT'
5694 ! include 'COMMON.DERIV'
5695 ! include 'COMMON.VAR'
5696 ! include 'COMMON.CHAIN'
5697 ! include 'COMMON.IOUNITS'
5698 ! include 'COMMON.NAMES'
5699 ! include 'COMMON.FFIELD'
5700 ! include 'COMMON.CONTROL'
5701 real(kind=8),dimension(nntheterm) :: coskt,sinkt !mmaxtheterm
5702 real(kind=8),dimension(nsingle) :: cosph1,sinph1,cosph2,sinph2 !maxsingle
5703 real(kind=8),dimension(ndouble,ndouble) :: cosph1ph2,sinph1ph2 !maxdouble,maxdouble
5704 logical :: lprn=.false., lprn1=.false.
5706 integer :: i,k,iblock,ityp1,ityp2,ityp3,l,m
5707 real(kind=8) :: dethetai,dephii,dephii1,theti2,phii,phii1,ethetai
5708 real(kind=8) :: aux,etheta,ccl,ssl,scl,csl,ethetacnstr
5709 ! local variables for constrains
5710 real(kind=8) :: difi,thetiii
5714 do i=ithet_start,ithet_end
5715 if (itype(i-1,1).eq.ntyp1) cycle
5716 if (itype(i-2,1).eq.ntyp1.or.itype(i,1).eq.ntyp1) cycle
5717 if (iabs(itype(i+1,1)).eq.20) iblock=2
5718 if (iabs(itype(i+1,1)).ne.20) iblock=1
5722 theti2=0.5d0*theta(i)
5723 ityp2=ithetyp((itype(i-1,1)))
5725 coskt(k)=dcos(k*theti2)
5726 sinkt(k)=dsin(k*theti2)
5728 if (i.gt.3 .and. itype(max0(i-3,1),1).ne.ntyp1) then
5731 if (phii.ne.phii) phii=150.0
5735 ityp1=ithetyp((itype(i-2,1)))
5736 ! propagation of chirality for glycine type
5738 cosph1(k)=dcos(k*phii)
5739 sinph1(k)=dsin(k*phii)
5743 ityp1=ithetyp(itype(i-2,1))
5749 if (i.lt.nres .and. itype(i+1,1).ne.ntyp1) then
5752 if (phii1.ne.phii1) phii1=150.0
5757 ityp3=ithetyp((itype(i,1)))
5759 cosph2(k)=dcos(k*phii1)
5760 sinph2(k)=dsin(k*phii1)
5764 ityp3=ithetyp(itype(i,1))
5770 ethetai=aa0thet(ityp1,ityp2,ityp3,iblock)
5773 ccl=cosph1(l)*cosph2(k-l)
5774 ssl=sinph1(l)*sinph2(k-l)
5775 scl=sinph1(l)*cosph2(k-l)
5776 csl=cosph1(l)*sinph2(k-l)
5777 cosph1ph2(l,k)=ccl-ssl
5778 cosph1ph2(k,l)=ccl+ssl
5779 sinph1ph2(l,k)=scl+csl
5780 sinph1ph2(k,l)=scl-csl
5784 write (iout,*) "i",i," ityp1",ityp1," ityp2",ityp2,&
5785 " ityp3",ityp3," theti2",theti2," phii",phii," phii1",phii1
5786 write (iout,*) "coskt and sinkt"
5788 write (iout,*) k,coskt(k),sinkt(k)
5792 ethetai=ethetai+aathet(k,ityp1,ityp2,ityp3,iblock)*sinkt(k)
5793 dethetai=dethetai+0.5d0*k*aathet(k,ityp1,ityp2,ityp3,iblock) &
5796 write (iout,*) "k",k,&
5797 "aathet",aathet(k,ityp1,ityp2,ityp3,iblock),&
5801 write (iout,*) "cosph and sinph"
5803 write (iout,*) k,cosph1(k),sinph1(k),cosph2(k),sinph2(k)
5805 write (iout,*) "cosph1ph2 and sinph2ph2"
5808 write (iout,*) l,k,cosph1ph2(l,k),cosph1ph2(k,l),&
5809 sinph1ph2(l,k),sinph1ph2(k,l)
5812 write(iout,*) "ethetai",ethetai
5816 aux=bbthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph1(k) &
5817 +ccthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph1(k) &
5818 +ddthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph2(k) &
5819 +eethet(k,m,ityp1,ityp2,ityp3,iblock)*sinph2(k)
5820 ethetai=ethetai+sinkt(m)*aux
5821 dethetai=dethetai+0.5d0*m*aux*coskt(m)
5822 dephii=dephii+k*sinkt(m)* &
5823 (ccthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph1(k)- &
5824 bbthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph1(k))
5825 dephii1=dephii1+k*sinkt(m)* &
5826 (eethet(k,m,ityp1,ityp2,ityp3,iblock)*cosph2(k)- &
5827 ddthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph2(k))
5829 write (iout,*) "m",m," k",k," bbthet", &
5830 bbthet(k,m,ityp1,ityp2,ityp3,iblock)," ccthet", &
5831 ccthet(k,m,ityp1,ityp2,ityp3,iblock)," ddthet", &
5832 ddthet(k,m,ityp1,ityp2,ityp3,iblock)," eethet", &
5833 eethet(k,m,ityp1,ityp2,ityp3,iblock)," ethetai",ethetai
5837 write(iout,*) "ethetai",ethetai
5841 aux=ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)+ &
5842 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l)+ &
5843 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)+ &
5844 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)
5845 ethetai=ethetai+sinkt(m)*aux
5846 dethetai=dethetai+0.5d0*m*coskt(m)*aux
5847 dephii=dephii+l*sinkt(m)* &
5848 (-ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)- &
5849 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)+ &
5850 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)+ &
5851 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l))
5852 dephii1=dephii1+(k-l)*sinkt(m)* &
5853 (-ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)+ &
5854 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)+ &
5855 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)- &
5856 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l))
5858 write (iout,*) "m",m," k",k," l",l," ffthet",&
5859 ffthet(l,k,m,ityp1,ityp2,ityp3,iblock),&
5860 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)," ggthet",&
5861 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock),&
5862 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock),&
5864 write (iout,*) cosph1ph2(l,k)*sinkt(m),&
5865 cosph1ph2(k,l)*sinkt(m),&
5866 sinph1ph2(l,k)*sinkt(m),sinph1ph2(k,l)*sinkt(m)
5874 write (iout,'(i2,3f8.1,9h ethetai ,f10.5)') &
5875 i,theta(i)*rad2deg,phii*rad2deg,&
5876 phii1*rad2deg,ethetai
5878 etheta=etheta+ethetai
5879 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
5881 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*dephii
5882 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*dephii1
5883 gloc(nphi+i-2,icg)=wang*dethetai
5885 !-----------thete constrains
5886 ! if (tor_mode.ne.2) then
5888 ! print *,ithetaconstr_start,ithetaconstr_end,"TU"
5889 do i=ithetaconstr_start,ithetaconstr_end
5890 itheta=itheta_constr(i)
5891 thetiii=theta(itheta)
5892 difi=pinorm(thetiii-theta_constr0(i))
5893 if (difi.gt.theta_drange(i)) then
5894 difi=difi-theta_drange(i)
5895 ethetacnstr=ethetacnstr+0.25d0*for_thet_constr(i)*difi**4
5896 gloc(itheta+nphi-2,icg)=gloc(itheta+nphi-2,icg) &
5897 +for_thet_constr(i)*difi**3
5898 else if (difi.lt.-drange(i)) then
5900 ethetacnstr=ethetacnstr+0.25d0*for_thet_constr(i)*difi**4
5901 gloc(itheta+nphi-2,icg)=gloc(itheta+nphi-2,icg) &
5902 +for_thet_constr(i)*difi**3
5906 if (energy_dec) then
5907 write (iout,'(a6,2i5,4f8.3,2e14.5)') "ethetc", &
5908 i,itheta,rad2deg*thetiii, &
5909 rad2deg*theta_constr0(i), rad2deg*theta_drange(i), &
5910 rad2deg*difi,0.25d0*for_thet_constr(i)*difi**4, &
5911 gloc(itheta+nphi-2,icg)
5917 end subroutine ebend
5920 !-----------------------------------------------------------------------------
5921 subroutine esc(escloc)
5922 ! Calculate the local energy of a side chain and its derivatives in the
5923 ! corresponding virtual-bond valence angles THETA and the spherical angles
5927 ! implicit real*8 (a-h,o-z)
5928 ! include 'DIMENSIONS'
5929 ! include 'COMMON.GEO'
5930 ! include 'COMMON.LOCAL'
5931 ! include 'COMMON.VAR'
5932 ! include 'COMMON.INTERACT'
5933 ! include 'COMMON.DERIV'
5934 ! include 'COMMON.CHAIN'
5935 ! include 'COMMON.IOUNITS'
5936 ! include 'COMMON.NAMES'
5937 ! include 'COMMON.FFIELD'
5938 ! include 'COMMON.CONTROL'
5939 real(kind=8),dimension(3) :: x,dersc,xemp,dersc0,dersc1,&
5940 ddersc0,ddummy,xtemp,temp
5941 !el real(kind=8) :: time11,time12,time112,theti
5942 real(kind=8) :: escloc,delta
5943 !el integer :: it,nlobit
5944 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
5947 real(kind=8) :: escloci0,escloci1,escloci,esclocbi0,&
5948 dersc12,esclocbi1,chuju,esclocbi,dersc02,dersc01,ss,ssd
5951 ! write (iout,'(a)') 'ESC'
5952 do i=loc_start,loc_end
5954 if (it.eq.ntyp1) cycle
5955 if (it.eq.10) goto 1
5956 nlobit=nlob(iabs(it))
5957 ! print *,'i=',i,' it=',it,' nlobit=',nlobit
5958 ! write (iout,*) 'i=',i,' ssa=',ssa,' ssad=',ssad
5959 theti=theta(i+1)-pipol
5964 if (x(2).gt.pi-delta) then
5968 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
5970 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
5971 call spline1(x(2),pi-delta,delta,escloci0,escloci1,dersc0(2),&
5973 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),&
5974 ddersc0(1),dersc(1))
5975 call spline2(x(2),pi-delta,delta,dersc0(3),dersc1(3),&
5976 ddersc0(3),dersc(3))
5978 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
5980 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
5981 call spline1(x(2),pi-delta,delta,esclocbi0,esclocbi1,&
5982 dersc0(2),esclocbi,dersc02)
5983 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),&
5985 call splinthet(x(2),0.5d0*delta,ss,ssd)
5990 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
5992 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
5993 ! write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
5995 escloci=ss*escloci+(1.0d0-ss)*esclocbi
5997 ! write (iout,*) escloci
5998 else if (x(2).lt.delta) then
6002 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
6004 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
6005 call spline1(x(2),delta,-delta,escloci0,escloci1,dersc0(2),&
6007 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),&
6008 ddersc0(1),dersc(1))
6009 call spline2(x(2),delta,-delta,dersc0(3),dersc1(3),&
6010 ddersc0(3),dersc(3))
6012 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
6014 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
6015 call spline1(x(2),delta,-delta,esclocbi0,esclocbi1,&
6016 dersc0(2),esclocbi,dersc02)
6017 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),&
6022 call splinthet(x(2),0.5d0*delta,ss,ssd)
6024 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
6026 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
6027 ! write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
6029 escloci=ss*escloci+(1.0d0-ss)*esclocbi
6030 ! write (iout,*) escloci
6032 call enesc(x,escloci,dersc,ddummy,.false.)
6035 escloc=escloc+escloci
6036 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
6038 ! write (iout,*) 'i=',i,' escloci=',escloci,' dersc=',dersc
6040 gloc(nphi+i-1,icg)=gloc(nphi+i-1,icg)+ &
6042 gloc(ialph(i,1),icg)=wscloc*dersc(2)
6043 gloc(ialph(i,1)+nside,icg)=wscloc*dersc(3)
6048 !-----------------------------------------------------------------------------
6049 subroutine enesc(x,escloci,dersc,ddersc,mixed)
6052 ! implicit real*8 (a-h,o-z)
6053 ! include 'DIMENSIONS'
6054 ! include 'COMMON.GEO'
6055 ! include 'COMMON.LOCAL'
6056 ! include 'COMMON.IOUNITS'
6057 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
6058 real(kind=8),dimension(3) :: x,z,dersc,ddersc
6059 real(kind=8),dimension(3,nlobit,-1:1) :: Ax !(3,maxlob,-1:1)
6060 real(kind=8),dimension(nlobit,-1:1) :: contr !(maxlob,-1:1)
6061 real(kind=8) :: escloci
6064 integer :: j,iii,l,k !el,it,nlobit
6065 real(kind=8) :: escloc_i,x3,Axk,expfac,emin !el,theti,&
6066 !el time11,time12,time112
6067 ! write (iout,*) 'it=',it,' nlobit=',nlobit
6071 if (mixed) ddersc(j)=0.0d0
6075 ! Because of periodicity of the dependence of the SC energy in omega we have
6076 ! to add up the contributions from x(3)-2*pi, x(3), and x(3+2*pi).
6077 ! To avoid underflows, first compute & store the exponents.
6085 z(k)=x(k)-censc(k,j,it)
6090 Axk=Axk+gaussc(l,k,j,it)*z(l)
6096 expfac=expfac+Ax(k,j,iii)*z(k)
6104 ! As in the case of ebend, we want to avoid underflows in exponentiation and
6105 ! subsequent NaNs and INFs in energy calculation.
6106 ! Find the largest exponent
6110 if (emin.gt.contr(j,iii)) emin=contr(j,iii)
6114 !d print *,'it=',it,' emin=',emin
6116 ! Compute the contribution to SC energy and derivatives
6121 adexp=bsc(j,iabs(it))-0.5D0*contr(j,iii)+emin
6122 if(adexp.ne.adexp) adexp=1.0
6125 expfac=dexp(bsc(j,iabs(it))-0.5D0*contr(j,iii)+emin)
6127 !d print *,'j=',j,' expfac=',expfac
6128 escloc_i=escloc_i+expfac
6130 dersc(k)=dersc(k)+Ax(k,j,iii)*expfac
6134 ddersc(k)=ddersc(k)+(-Ax(2,j,iii)*Ax(k,j,iii) &
6135 +gaussc(k,2,j,it))*expfac
6142 dersc(1)=dersc(1)/cos(theti)**2
6143 ddersc(1)=ddersc(1)/cos(theti)**2
6146 escloci=-(dlog(escloc_i)-emin)
6148 dersc(j)=dersc(j)/escloc_i
6152 ddersc(j)=(ddersc(j)/escloc_i+dersc(2)*dersc(j))
6156 end subroutine enesc
6157 !-----------------------------------------------------------------------------
6158 subroutine enesc_bound(x,escloci,dersc,dersc12,mixed)
6161 ! implicit real*8 (a-h,o-z)
6162 ! include 'DIMENSIONS'
6163 ! include 'COMMON.GEO'
6164 ! include 'COMMON.LOCAL'
6165 ! include 'COMMON.IOUNITS'
6166 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
6167 real(kind=8),dimension(3) :: x,z,dersc
6168 real(kind=8),dimension(3,nlobit) :: Ax !(3,maxlob)
6169 real(kind=8),dimension(nlobit) :: contr !(maxlob)
6170 real(kind=8) :: escloci,dersc12,emin
6173 integer :: j,k,l !el,it,nlobit
6174 real(kind=8) :: escloc_i,Axk,expfac !el,time11,time12,time112,theti
6184 z(k)=x(k)-censc(k,j,it)
6190 Axk=Axk+gaussc(l,k,j,it)*z(l)
6196 expfac=expfac+Ax(k,j)*z(k)
6201 ! As in the case of ebend, we want to avoid underflows in exponentiation and
6202 ! subsequent NaNs and INFs in energy calculation.
6203 ! Find the largest exponent
6206 if (emin.gt.contr(j)) emin=contr(j)
6210 ! Compute the contribution to SC energy and derivatives
6214 expfac=dexp(bsc(j,iabs(it))-0.5D0*contr(j)+emin)
6215 escloc_i=escloc_i+expfac
6217 dersc(k)=dersc(k)+Ax(k,j)*expfac
6219 if (mixed) dersc12=dersc12+(-Ax(2,j)*Ax(1,j) &
6220 +gaussc(1,2,j,it))*expfac
6224 dersc(1)=dersc(1)/cos(theti)**2
6225 dersc12=dersc12/cos(theti)**2
6226 escloci=-(dlog(escloc_i)-emin)
6228 dersc(j)=dersc(j)/escloc_i
6230 if (mixed) dersc12=(dersc12/escloc_i+dersc(2)*dersc(1))
6232 end subroutine enesc_bound
6234 !-----------------------------------------------------------------------------
6235 subroutine esc(escloc)
6236 ! Calculate the local energy of a side chain and its derivatives in the
6237 ! corresponding virtual-bond valence angles THETA and the spherical angles
6238 ! ALPHA and OMEGA derived from AM1 all-atom calculations.
6239 ! added by Urszula Kozlowska. 07/11/2007
6242 ! implicit real*8 (a-h,o-z)
6243 ! include 'DIMENSIONS'
6244 ! include 'COMMON.GEO'
6245 ! include 'COMMON.LOCAL'
6246 ! include 'COMMON.VAR'
6247 ! include 'COMMON.SCROT'
6248 ! include 'COMMON.INTERACT'
6249 ! include 'COMMON.DERIV'
6250 ! include 'COMMON.CHAIN'
6251 ! include 'COMMON.IOUNITS'
6252 ! include 'COMMON.NAMES'
6253 ! include 'COMMON.FFIELD'
6254 ! include 'COMMON.CONTROL'
6255 ! include 'COMMON.VECTORS'
6256 real(kind=8),dimension(3) :: x_prime,y_prime,z_prime
6257 real(kind=8),dimension(65) :: x
6258 real(kind=8) :: sumene,dsc_i,dp2_i,xx,yy,zz,sumene1,sumene2,sumene3,&
6259 sumene4,s1,s1_6,s2,s2_6,de_dxx,de_dyy,de_dzz,de_dt
6260 real(kind=8) :: s1_t,s1_6_t,s2_t,s2_6_t
6261 real(kind=8),dimension(3) :: dXX_Ci1,dYY_Ci1,dZZ_Ci1,dXX_Ci,dYY_Ci,&
6262 dZZ_Ci,dXX_XYZ,dYY_XYZ,dZZ_XYZ,dt_dCi,dt_dCi1
6264 integer :: i,j,k !el,it,nlobit
6265 real(kind=8) :: cosfac2,sinfac2,cosfac,sinfac,escloc,delta
6266 !el real(kind=8) :: time11,time12,time112,theti
6267 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
6268 real(kind=8) :: dscp1,dscp2,pom_s1,pom_s16,pom_s2,pom_s26,&
6269 pom,pom_dx,pom_dy,pom_dt1,pom_dt2,pom1,pom2,&
6270 sumene1x,sumene2x,sumene3x,sumene4x,&
6271 sumene1y,sumene2y,sumene3y,sumene4y,cossc,cossc1,&
6274 real(kind=8) :: aincr,xxsave,sumenep,de_dxx_num,yysave,&
6275 de_dyy_num,zzsave,de_dzz_num,costsave,sintsave,&
6278 ! if (.not.allocated(gsclocx)) allocate(gsclocx(3,nres)) !(3,maxres)
6282 do i=loc_start,loc_end
6283 if (itype(i,1).eq.ntyp1) cycle
6284 costtab(i+1) =dcos(theta(i+1))
6285 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
6286 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
6287 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
6288 cosfac2=0.5d0/(1.0d0+costtab(i+1))
6289 cosfac=dsqrt(cosfac2)
6290 sinfac2=0.5d0/(1.0d0-costtab(i+1))
6291 sinfac=dsqrt(sinfac2)
6293 if (it.eq.10) goto 1
6295 ! Compute the axes of tghe local cartesian coordinates system; store in
6296 ! x_prime, y_prime and z_prime
6303 ! write(2,*) "dc_norm", dc_norm(1,i+nres),dc_norm(2,i+nres),
6304 ! & dc_norm(3,i+nres)
6306 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
6307 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
6310 z_prime(j) = -uz(j,i-1)*dsign(1.0d0,dfloat(itype(i,1)))
6313 ! write (2,*) "x_prime",(x_prime(j),j=1,3)
6314 ! write (2,*) "y_prime",(y_prime(j),j=1,3)
6315 ! write (2,*) "z_prime",(z_prime(j),j=1,3)
6316 ! write (2,*) "xx",scalar(x_prime(1),x_prime(1)),
6317 ! & " xy",scalar(x_prime(1),y_prime(1)),
6318 ! & " xz",scalar(x_prime(1),z_prime(1)),
6319 ! & " yy",scalar(y_prime(1),y_prime(1)),
6320 ! & " yz",scalar(y_prime(1),z_prime(1)),
6321 ! & " zz",scalar(z_prime(1),z_prime(1))
6323 ! Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
6324 ! to local coordinate system. Store in xx, yy, zz.
6330 xx = xx + x_prime(j)*dc_norm(j,i+nres)
6331 yy = yy + y_prime(j)*dc_norm(j,i+nres)
6332 zz = zz + z_prime(j)*dc_norm(j,i+nres)
6339 ! Compute the energy of the ith side cbain
6341 ! write (2,*) "xx",xx," yy",yy," zz",zz
6344 x(j) = sc_parmin(j,it)
6347 !c diagnostics - remove later
6349 yy1 = dsin(alph(2))*dcos(omeg(2))
6350 zz1 = -dsign(1.0,dfloat(itype(i,1)))*dsin(alph(2))*dsin(omeg(2))
6351 write(2,'(3f8.1,3f9.3,1x,3f9.3)') &
6352 alph(2)*rad2deg,omeg(2)*rad2deg,theta(3)*rad2deg,xx,yy,zz,&
6354 !," --- ", xx_w,yy_w,zz_w
6357 sumene1= x(1)+ x(2)*xx+ x(3)*yy+ x(4)*zz+ x(5)*xx**2 &
6358 + x(6)*yy**2+ x(7)*zz**2+ x(8)*xx*zz+ x(9)*xx*yy &
6360 sumene2= x(11) + x(12)*xx + x(13)*yy + x(14)*zz + x(15)*xx**2 &
6361 + x(16)*yy**2 + x(17)*zz**2 + x(18)*xx*zz + x(19)*xx*yy &
6363 sumene3= x(21) +x(22)*xx +x(23)*yy +x(24)*zz +x(25)*xx**2 &
6364 +x(26)*yy**2 +x(27)*zz**2 +x(28)*xx*zz +x(29)*xx*yy &
6365 +x(30)*yy*zz +x(31)*xx**3 +x(32)*yy**3 +x(33)*zz**3 &
6366 +x(34)*(xx**2)*yy +x(35)*(xx**2)*zz +x(36)*(yy**2)*xx &
6367 +x(37)*(yy**2)*zz +x(38)*(zz**2)*xx +x(39)*(zz**2)*yy &
6369 sumene4= x(41) +x(42)*xx +x(43)*yy +x(44)*zz +x(45)*xx**2 &
6370 +x(46)*yy**2 +x(47)*zz**2 +x(48)*xx*zz +x(49)*xx*yy &
6371 +x(50)*yy*zz +x(51)*xx**3 +x(52)*yy**3 +x(53)*zz**3 &
6372 +x(54)*(xx**2)*yy +x(55)*(xx**2)*zz +x(56)*(yy**2)*xx &
6373 +x(57)*(yy**2)*zz +x(58)*(zz**2)*xx +x(59)*(zz**2)*yy &
6375 dsc_i = 0.743d0+x(61)
6377 dscp1=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
6378 *(xx*cost2tab(i+1)+yy*sint2tab(i+1)))
6379 dscp2=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
6380 *(xx*cost2tab(i+1)-yy*sint2tab(i+1)))
6381 s1=(1+x(63))/(0.1d0 + dscp1)
6382 s1_6=(1+x(64))/(0.1d0 + dscp1**6)
6383 s2=(1+x(65))/(0.1d0 + dscp2)
6384 s2_6=(1+x(65))/(0.1d0 + dscp2**6)
6385 sumene = ( sumene3*sint2tab(i+1) + sumene1)*(s1+s1_6) &
6386 + (sumene4*cost2tab(i+1) +sumene2)*(s2+s2_6)
6387 ! write(2,'(i2," sumene",7f9.3)') i,sumene1,sumene2,sumene3,
6389 ! & dscp1,dscp2,sumene
6390 ! sumene = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6391 escloc = escloc + sumene
6392 ! write (2,*) "i",i," escloc",sumene,escloc,it,itype(i,1)
6397 ! This section to check the numerical derivatives of the energy of ith side
6398 ! chain in xx, yy, zz, and theta. Use the -DDEBUG compiler option or insert
6399 ! #define DEBUG in the code to turn it on.
6401 write (2,*) "sumene =",sumene
6405 write (2,*) xx,yy,zz
6406 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6407 de_dxx_num=(sumenep-sumene)/aincr
6409 write (2,*) "xx+ sumene from enesc=",sumenep
6412 write (2,*) xx,yy,zz
6413 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6414 de_dyy_num=(sumenep-sumene)/aincr
6416 write (2,*) "yy+ sumene from enesc=",sumenep
6419 write (2,*) xx,yy,zz
6420 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6421 de_dzz_num=(sumenep-sumene)/aincr
6423 write (2,*) "zz+ sumene from enesc=",sumenep
6424 costsave=cost2tab(i+1)
6425 sintsave=sint2tab(i+1)
6426 cost2tab(i+1)=dcos(0.5d0*(theta(i+1)+aincr))
6427 sint2tab(i+1)=dsin(0.5d0*(theta(i+1)+aincr))
6428 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6429 de_dt_num=(sumenep-sumene)/aincr
6430 write (2,*) " t+ sumene from enesc=",sumenep
6431 cost2tab(i+1)=costsave
6432 sint2tab(i+1)=sintsave
6433 ! End of diagnostics section.
6436 ! Compute the gradient of esc
6438 ! zz=zz*dsign(1.0,dfloat(itype(i,1)))
6439 pom_s1=(1.0d0+x(63))/(0.1d0 + dscp1)**2
6440 pom_s16=6*(1.0d0+x(64))/(0.1d0 + dscp1**6)**2
6441 pom_s2=(1.0d0+x(65))/(0.1d0 + dscp2)**2
6442 pom_s26=6*(1.0d0+x(65))/(0.1d0 + dscp2**6)**2
6443 pom_dx=dsc_i*dp2_i*cost2tab(i+1)
6444 pom_dy=dsc_i*dp2_i*sint2tab(i+1)
6445 pom_dt1=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)-yy*cost2tab(i+1))
6446 pom_dt2=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)+yy*cost2tab(i+1))
6447 pom1=(sumene3*sint2tab(i+1)+sumene1) &
6448 *(pom_s1/dscp1+pom_s16*dscp1**4)
6449 pom2=(sumene4*cost2tab(i+1)+sumene2) &
6450 *(pom_s2/dscp2+pom_s26*dscp2**4)
6451 sumene1x=x(2)+2*x(5)*xx+x(8)*zz+ x(9)*yy
6452 sumene3x=x(22)+2*x(25)*xx+x(28)*zz+x(29)*yy+3*x(31)*xx**2 &
6453 +2*x(34)*xx*yy +2*x(35)*xx*zz +x(36)*(yy**2) +x(38)*(zz**2) &
6455 sumene2x=x(12)+2*x(15)*xx+x(18)*zz+ x(19)*yy
6456 sumene4x=x(42)+2*x(45)*xx +x(48)*zz +x(49)*yy +3*x(51)*xx**2 &
6457 +2*x(54)*xx*yy+2*x(55)*xx*zz+x(56)*(yy**2)+x(58)*(zz**2) &
6459 de_dxx =(sumene1x+sumene3x*sint2tab(i+1))*(s1+s1_6) &
6460 +(sumene2x+sumene4x*cost2tab(i+1))*(s2+s2_6) &
6463 write(2,*), "de_dxx = ", de_dxx,de_dxx_num,itype(i,1)
6466 sumene1y=x(3) + 2*x(6)*yy + x(9)*xx + x(10)*zz
6467 sumene3y=x(23) +2*x(26)*yy +x(29)*xx +x(30)*zz +3*x(32)*yy**2 &
6468 +x(34)*(xx**2) +2*x(36)*yy*xx +2*x(37)*yy*zz +x(39)*(zz**2) &
6470 sumene2y=x(13) + 2*x(16)*yy + x(19)*xx + x(20)*zz
6471 sumene4y=x(43)+2*x(46)*yy+x(49)*xx +x(50)*zz &
6472 +3*x(52)*yy**2+x(54)*xx**2+2*x(56)*yy*xx +2*x(57)*yy*zz &
6473 +x(59)*zz**2 +x(60)*xx*zz
6474 de_dyy =(sumene1y+sumene3y*sint2tab(i+1))*(s1+s1_6) &
6475 +(sumene2y+sumene4y*cost2tab(i+1))*(s2+s2_6) &
6478 write(2,*), "de_dyy = ", de_dyy,de_dyy_num,itype(i,1)
6481 de_dzz =(x(24) +2*x(27)*zz +x(28)*xx +x(30)*yy &
6482 +3*x(33)*zz**2 +x(35)*xx**2 +x(37)*yy**2 +2*x(38)*zz*xx &
6483 +2*x(39)*zz*yy +x(40)*xx*yy)*sint2tab(i+1)*(s1+s1_6) &
6484 +(x(4) + 2*x(7)*zz+ x(8)*xx + x(10)*yy)*(s1+s1_6) &
6485 +(x(44)+2*x(47)*zz +x(48)*xx +x(50)*yy +3*x(53)*zz**2 &
6486 +x(55)*xx**2 +x(57)*(yy**2)+2*x(58)*zz*xx +2*x(59)*zz*yy &
6487 +x(60)*xx*yy)*cost2tab(i+1)*(s2+s2_6) &
6488 + ( x(14) + 2*x(17)*zz+ x(18)*xx + x(20)*yy)*(s2+s2_6)
6490 write(2,*), "de_dzz = ", de_dzz,de_dzz_num,itype(i,1)
6493 de_dt = 0.5d0*sumene3*cost2tab(i+1)*(s1+s1_6) &
6494 -0.5d0*sumene4*sint2tab(i+1)*(s2+s2_6) &
6495 +pom1*pom_dt1+pom2*pom_dt2
6497 write(2,*), "de_dt = ", de_dt,de_dt_num,itype(i,1)
6501 cossc=scalar(dc_norm(1,i),dc_norm(1,i+nres))
6502 cossc1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
6503 cosfac2xx=cosfac2*xx
6504 sinfac2yy=sinfac2*yy
6506 dt_dCi(k) = -(dc_norm(k,i-1)+costtab(i+1)*dc_norm(k,i))* &
6508 dt_dCi1(k)= -(dc_norm(k,i)+costtab(i+1)*dc_norm(k,i-1))* &
6510 pom=(dC_norm(k,i+nres)-cossc*dC_norm(k,i))*vbld_inv(i+1)
6511 pom1=(dC_norm(k,i+nres)-cossc1*dC_norm(k,i-1))*vbld_inv(i)
6512 ! write (iout,*) "i",i," k",k," pom",pom," pom1",pom1,
6513 ! & " dt_dCi",dt_dCi(k)," dt_dCi1",dt_dCi1(k)
6514 ! write (iout,*) "dC_norm",(dC_norm(j,i),j=1,3),
6515 ! & (dC_norm(j,i-1),j=1,3)," vbld_inv",vbld_inv(i+1),vbld_inv(i)
6516 dXX_Ci(k)=pom*cosfac-dt_dCi(k)*cosfac2xx
6517 dXX_Ci1(k)=-pom1*cosfac-dt_dCi1(k)*cosfac2xx
6518 dYY_Ci(k)=pom*sinfac+dt_dCi(k)*sinfac2yy
6519 dYY_Ci1(k)=pom1*sinfac+dt_dCi1(k)*sinfac2yy
6523 dZZ_Ci(k)=dZZ_Ci(k)-uzgrad(j,k,2,i-1) &
6524 *dsign(1.0d0,dfloat(itype(i,1)))*dC_norm(j,i+nres)
6525 dZZ_Ci1(k)=dZZ_Ci1(k)-uzgrad(j,k,1,i-1) &
6526 *dsign(1.0d0,dfloat(itype(i,1)))*dC_norm(j,i+nres)
6529 dXX_XYZ(k)=vbld_inv(i+nres)*(x_prime(k)-xx*dC_norm(k,i+nres))
6530 dYY_XYZ(k)=vbld_inv(i+nres)*(y_prime(k)-yy*dC_norm(k,i+nres))
6531 dZZ_XYZ(k)=vbld_inv(i+nres)* &
6532 (z_prime(k)-zz*dC_norm(k,i+nres))
6534 dt_dCi(k) = -dt_dCi(k)/sinttab(i+1)
6535 dt_dCi1(k)= -dt_dCi1(k)/sinttab(i+1)
6539 dXX_Ctab(k,i)=dXX_Ci(k)
6540 dXX_C1tab(k,i)=dXX_Ci1(k)
6541 dYY_Ctab(k,i)=dYY_Ci(k)
6542 dYY_C1tab(k,i)=dYY_Ci1(k)
6543 dZZ_Ctab(k,i)=dZZ_Ci(k)
6544 dZZ_C1tab(k,i)=dZZ_Ci1(k)
6545 dXX_XYZtab(k,i)=dXX_XYZ(k)
6546 dYY_XYZtab(k,i)=dYY_XYZ(k)
6547 dZZ_XYZtab(k,i)=dZZ_XYZ(k)
6551 ! write (iout,*) "k",k," dxx_ci1",dxx_ci1(k)," dyy_ci1",
6552 ! & dyy_ci1(k)," dzz_ci1",dzz_ci1(k)
6553 ! write (iout,*) "k",k," dxx_ci",dxx_ci(k)," dyy_ci",
6554 ! & dyy_ci(k)," dzz_ci",dzz_ci(k)
6555 ! write (iout,*) "k",k," dt_dci",dt_dci(k)," dt_dci",
6557 ! write (iout,*) "k",k," dxx_XYZ",dxx_XYZ(k)," dyy_XYZ",
6558 ! & dyy_XYZ(k)," dzz_XYZ",dzz_XYZ(k)
6559 gscloc(k,i-1)=gscloc(k,i-1)+de_dxx*dxx_ci1(k) &
6560 +de_dyy*dyy_ci1(k)+de_dzz*dzz_ci1(k)+de_dt*dt_dCi1(k)
6561 gscloc(k,i)=gscloc(k,i)+de_dxx*dxx_Ci(k) &
6562 +de_dyy*dyy_Ci(k)+de_dzz*dzz_Ci(k)+de_dt*dt_dCi(k)
6563 gsclocx(k,i)= de_dxx*dxx_XYZ(k) &
6564 +de_dyy*dyy_XYZ(k)+de_dzz*dzz_XYZ(k)
6566 ! write(iout,*) "ENERGY GRAD = ", (gscloc(k,i-1),k=1,3),
6567 ! & (gscloc(k,i),k=1,3),(gsclocx(k,i),k=1,3)
6569 ! to check gradient call subroutine check_grad
6575 !-----------------------------------------------------------------------------
6576 real(kind=8) function enesc(x,xx,yy,zz,cost2,sint2)
6578 real(kind=8),dimension(65) :: x
6579 real(kind=8) :: xx,yy,zz,cost2,sint2,sumene1,sumene2,sumene3,&
6580 sumene4,sumene,dsc_i,dp2_i,dscp1,dscp2,s1,s1_6,s2,s2_6
6582 sumene1= x(1)+ x(2)*xx+ x(3)*yy+ x(4)*zz+ x(5)*xx**2 &
6583 + x(6)*yy**2+ x(7)*zz**2+ x(8)*xx*zz+ x(9)*xx*yy &
6585 sumene2= x(11) + x(12)*xx + x(13)*yy + x(14)*zz + x(15)*xx**2 &
6586 + x(16)*yy**2 + x(17)*zz**2 + x(18)*xx*zz + x(19)*xx*yy &
6588 sumene3= x(21) +x(22)*xx +x(23)*yy +x(24)*zz +x(25)*xx**2 &
6589 +x(26)*yy**2 +x(27)*zz**2 +x(28)*xx*zz +x(29)*xx*yy &
6590 +x(30)*yy*zz +x(31)*xx**3 +x(32)*yy**3 +x(33)*zz**3 &
6591 +x(34)*(xx**2)*yy +x(35)*(xx**2)*zz +x(36)*(yy**2)*xx &
6592 +x(37)*(yy**2)*zz +x(38)*(zz**2)*xx +x(39)*(zz**2)*yy &
6594 sumene4= x(41) +x(42)*xx +x(43)*yy +x(44)*zz +x(45)*xx**2 &
6595 +x(46)*yy**2 +x(47)*zz**2 +x(48)*xx*zz +x(49)*xx*yy &
6596 +x(50)*yy*zz +x(51)*xx**3 +x(52)*yy**3 +x(53)*zz**3 &
6597 +x(54)*(xx**2)*yy +x(55)*(xx**2)*zz +x(56)*(yy**2)*xx &
6598 +x(57)*(yy**2)*zz +x(58)*(zz**2)*xx +x(59)*(zz**2)*yy &
6600 dsc_i = 0.743d0+x(61)
6602 dscp1=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
6603 *(xx*cost2+yy*sint2))
6604 dscp2=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
6605 *(xx*cost2-yy*sint2))
6606 s1=(1+x(63))/(0.1d0 + dscp1)
6607 s1_6=(1+x(64))/(0.1d0 + dscp1**6)
6608 s2=(1+x(65))/(0.1d0 + dscp2)
6609 s2_6=(1+x(65))/(0.1d0 + dscp2**6)
6610 sumene = ( sumene3*sint2 + sumene1)*(s1+s1_6) &
6611 + (sumene4*cost2 +sumene2)*(s2+s2_6)
6616 !-----------------------------------------------------------------------------
6617 subroutine gcont(rij,r0ij,eps0ij,delta,fcont,fprimcont)
6619 ! This procedure calculates two-body contact function g(rij) and its derivative:
6622 ! g(rij) = esp0ij*(-0.9375*x+0.625*x**3-0.1875*x**5) ! -1 =< x =< 1
6625 ! where x=(rij-r0ij)/delta
6627 ! rij - interbody distance, r0ij - contact distance, eps0ij - contact energy
6630 real(kind=8) :: rij,r0ij,eps0ij,fcont,fprimcont
6631 real(kind=8) :: x,x2,x4,delta
6635 if (x.lt.-1.0D0) then
6638 else if (x.le.1.0D0) then
6641 fcont=eps0ij*(x*(-0.9375D0+0.6250D0*x2-0.1875D0*x4)+0.5D0)
6642 fprimcont=eps0ij * (-0.9375D0+1.8750D0*x2-0.9375D0*x4)/delta
6648 end subroutine gcont
6649 !-----------------------------------------------------------------------------
6650 subroutine splinthet(theti,delta,ss,ssder)
6651 ! implicit real*8 (a-h,o-z)
6652 ! include 'DIMENSIONS'
6653 ! include 'COMMON.VAR'
6654 ! include 'COMMON.GEO'
6655 real(kind=8) :: theti,delta,ss,ssder
6656 real(kind=8) :: thetup,thetlow
6659 if (theti.gt.pipol) then
6660 call gcont(theti,thetup,1.0d0,delta,ss,ssder)
6662 call gcont(-theti,-thetlow,1.0d0,delta,ss,ssder)
6666 end subroutine splinthet
6667 !-----------------------------------------------------------------------------
6668 subroutine spline1(x,x0,delta,f0,f1,fprim0,f,fprim)
6670 real(kind=8) :: x,x0,delta,f0,f1,fprim0,f,fprim
6671 real(kind=8) :: ksi,ksi2,ksi3,a1,a2,a3
6672 a1=fprim0*delta/(f1-f0)
6678 f=f0+(f1-f0)*ksi*(a1+ksi*(a2+a3*ksi))
6679 fprim=(f1-f0)/delta*(a1+ksi*(2*a2+3*ksi*a3))
6681 end subroutine spline1
6682 !-----------------------------------------------------------------------------
6683 subroutine spline2(x,x0,delta,f0x,f1x,fprim0x,fx)
6685 real(kind=8) :: x,x0,delta,f0x,f1x,fprim0x,fx
6686 real(kind=8) :: ksi,ksi2,ksi3,a1,a2,a3
6691 a2=3*(f1x-f0x)-2*fprim0x*delta
6692 a3=fprim0x*delta-2*(f1x-f0x)
6693 fx=f0x+a1*ksi+a2*ksi2+a3*ksi3
6695 end subroutine spline2
6696 !-----------------------------------------------------------------------------
6698 !-----------------------------------------------------------------------------
6699 subroutine etor(etors,edihcnstr)
6700 ! implicit real*8 (a-h,o-z)
6701 ! include 'DIMENSIONS'
6702 ! include 'COMMON.VAR'
6703 ! include 'COMMON.GEO'
6704 ! include 'COMMON.LOCAL'
6705 ! include 'COMMON.TORSION'
6706 ! include 'COMMON.INTERACT'
6707 ! include 'COMMON.DERIV'
6708 ! include 'COMMON.CHAIN'
6709 ! include 'COMMON.NAMES'
6710 ! include 'COMMON.IOUNITS'
6711 ! include 'COMMON.FFIELD'
6712 ! include 'COMMON.TORCNSTR'
6713 ! include 'COMMON.CONTROL'
6714 real(kind=8) :: etors,edihcnstr
6718 real(kind=8) :: phii,fac,etors_ii
6720 ! Set lprn=.true. for debugging
6724 do i=iphi_start,iphi_end
6726 if (itype(i-2,1).eq.ntyp1.or. itype(i-1,1).eq.ntyp1 &
6727 .or. itype(i,1).eq.ntyp1) cycle
6728 itori=itortyp(itype(i-2,1))
6729 itori1=itortyp(itype(i-1,1))
6732 ! Proline-Proline pair is a special case...
6733 if (itori.eq.3 .and. itori1.eq.3) then
6734 if (phii.gt.-dwapi3) then
6736 fac=1.0D0/(1.0D0-cosphi)
6737 etorsi=v1(1,3,3)*fac
6738 etorsi=etorsi+etorsi
6739 etors=etors+etorsi-v1(1,3,3)
6740 if (energy_dec) etors_ii=etors_ii+etorsi-v1(1,3,3)
6741 gloci=gloci-3*fac*etorsi*dsin(3*phii)
6744 v1ij=v1(j+1,itori,itori1)
6745 v2ij=v2(j+1,itori,itori1)
6748 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
6749 if (energy_dec) etors_ii=etors_ii+ &
6750 v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
6751 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
6755 v1ij=v1(j,itori,itori1)
6756 v2ij=v2(j,itori,itori1)
6759 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
6760 if (energy_dec) etors_ii=etors_ii+ &
6761 v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
6762 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
6765 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
6768 write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)') &
6769 restyp(itype(i-2,1),1),i-2,restyp(itype(i-1,1),1),i-1,itori,itori1,&
6770 (v1(j,itori,itori1),j=1,6),(v2(j,itori,itori1),j=1,6)
6771 gloc(i-3,icg)=gloc(i-3,icg)+wtor*gloci
6772 ! write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
6774 ! 6/20/98 - dihedral angle constraints
6777 itori=idih_constr(i)
6780 if (difi.gt.drange(i)) then
6782 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
6783 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
6784 else if (difi.lt.-drange(i)) then
6786 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
6787 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
6789 ! write (iout,'(2i5,2f8.3,2e14.5)') i,itori,rad2deg*phii,
6790 ! & rad2deg*difi,0.25d0*ftors*difi**4,gloc(itori-3,icg)
6792 ! write (iout,*) 'edihcnstr',edihcnstr
6795 !-----------------------------------------------------------------------------
6796 subroutine etor_d(etors_d)
6797 real(kind=8) :: etors_d
6800 end subroutine etor_d
6802 !-----------------------------------------------------------------------------
6803 subroutine etor(etors,edihcnstr)
6804 ! implicit real*8 (a-h,o-z)
6805 ! include 'DIMENSIONS'
6806 ! include 'COMMON.VAR'
6807 ! include 'COMMON.GEO'
6808 ! include 'COMMON.LOCAL'
6809 ! include 'COMMON.TORSION'
6810 ! include 'COMMON.INTERACT'
6811 ! include 'COMMON.DERIV'
6812 ! include 'COMMON.CHAIN'
6813 ! include 'COMMON.NAMES'
6814 ! include 'COMMON.IOUNITS'
6815 ! include 'COMMON.FFIELD'
6816 ! include 'COMMON.TORCNSTR'
6817 ! include 'COMMON.CONTROL'
6818 real(kind=8) :: etors,edihcnstr
6821 integer :: i,j,iblock,itori,itori1
6822 real(kind=8) :: phii,gloci,v1ij,v2ij,cosphi,sinphi,&
6823 vl1ij,vl2ij,vl3ij,pom1,difi,etors_ii,pom
6824 ! Set lprn=.true. for debugging
6828 do i=iphi_start,iphi_end
6829 if (itype(i-2,1).eq.ntyp1 .or. itype(i-1,1).eq.ntyp1 &
6830 .or. itype(i-3,1).eq.ntyp1 &
6831 .or. itype(i,1).eq.ntyp1) cycle
6833 if (iabs(itype(i,1)).eq.20) then
6838 itori=itortyp(itype(i-2,1))
6839 itori1=itortyp(itype(i-1,1))
6842 ! Regular cosine and sine terms
6843 do j=1,nterm(itori,itori1,iblock)
6844 v1ij=v1(j,itori,itori1,iblock)
6845 v2ij=v2(j,itori,itori1,iblock)
6848 etors=etors+v1ij*cosphi+v2ij*sinphi
6849 if (energy_dec) etors_ii=etors_ii+ &
6850 v1ij*cosphi+v2ij*sinphi
6851 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
6855 ! E = SUM ----------------------------------- - v1
6856 ! [v2 cos(phi/2)+v3 sin(phi/2)]^2 + 1
6858 cosphi=dcos(0.5d0*phii)
6859 sinphi=dsin(0.5d0*phii)
6860 do j=1,nlor(itori,itori1,iblock)
6861 vl1ij=vlor1(j,itori,itori1)
6862 vl2ij=vlor2(j,itori,itori1)
6863 vl3ij=vlor3(j,itori,itori1)
6864 pom=vl2ij*cosphi+vl3ij*sinphi
6865 pom1=1.0d0/(pom*pom+1.0d0)
6866 etors=etors+vl1ij*pom1
6867 if (energy_dec) etors_ii=etors_ii+ &
6870 gloci=gloci+vl1ij*(vl3ij*cosphi-vl2ij*sinphi)*pom
6872 ! Subtract the constant term
6873 etors=etors-v0(itori,itori1,iblock)
6874 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
6875 'etor',i,etors_ii-v0(itori,itori1,iblock)
6877 write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)') &
6878 restyp(itype(i-2,1),1),i-2,restyp(itype(i-1,1),1),i-1,itori,itori1,&
6879 (v1(j,itori,itori1,iblock),j=1,6),&
6880 (v2(j,itori,itori1,iblock),j=1,6)
6881 gloc(i-3,icg)=gloc(i-3,icg)+wtor*gloci
6882 ! write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
6884 ! 6/20/98 - dihedral angle constraints
6886 ! do i=1,ndih_constr
6887 do i=idihconstr_start,idihconstr_end
6888 itori=idih_constr(i)
6890 difi=pinorm(phii-phi0(i))
6891 if (difi.gt.drange(i)) then
6893 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
6894 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
6895 else if (difi.lt.-drange(i)) then
6897 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
6898 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
6902 !d write (iout,'(2i5,4f8.3,2e14.5)') i,itori,rad2deg*phii,
6903 !d & rad2deg*phi0(i), rad2deg*drange(i),
6904 !d & rad2deg*difi,0.25d0*ftors*difi**4,gloc(itori-3,icg)
6906 !d write (iout,*) 'edihcnstr',edihcnstr
6909 !-----------------------------------------------------------------------------
6910 subroutine etor_d(etors_d)
6911 ! 6/23/01 Compute double torsional energy
6912 ! implicit real*8 (a-h,o-z)
6913 ! include 'DIMENSIONS'
6914 ! include 'COMMON.VAR'
6915 ! include 'COMMON.GEO'
6916 ! include 'COMMON.LOCAL'
6917 ! include 'COMMON.TORSION'
6918 ! include 'COMMON.INTERACT'
6919 ! include 'COMMON.DERIV'
6920 ! include 'COMMON.CHAIN'
6921 ! include 'COMMON.NAMES'
6922 ! include 'COMMON.IOUNITS'
6923 ! include 'COMMON.FFIELD'
6924 ! include 'COMMON.TORCNSTR'
6925 real(kind=8) :: etors_d,etors_d_ii
6928 integer :: i,j,k,l,itori,itori1,itori2,iblock
6929 real(kind=8) :: phii,phii1,gloci1,gloci2,&
6930 v1cij,v1sij,v2cij,v2sij,cosphi1,sinphi1,&
6931 sinphi2,cosphi2,v1cdij,v2cdij,v1sdij,v2sdij,&
6932 cosphi1p2,cosphi1m2,sinphi1p2,sinphi1m2
6933 ! Set lprn=.true. for debugging
6937 ! write(iout,*) "a tu??"
6938 do i=iphid_start,iphid_end
6940 if (itype(i-2,1).eq.ntyp1 .or. itype(i-1,1).eq.ntyp1 &
6941 .or. itype(i-3,1).eq.ntyp1 &
6942 .or. itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
6943 itori=itortyp(itype(i-2,1))
6944 itori1=itortyp(itype(i-1,1))
6945 itori2=itortyp(itype(i,1))
6951 if (iabs(itype(i+1,1)).eq.20) iblock=2
6953 ! Regular cosine and sine terms
6954 do j=1,ntermd_1(itori,itori1,itori2,iblock)
6955 v1cij=v1c(1,j,itori,itori1,itori2,iblock)
6956 v1sij=v1s(1,j,itori,itori1,itori2,iblock)
6957 v2cij=v1c(2,j,itori,itori1,itori2,iblock)
6958 v2sij=v1s(2,j,itori,itori1,itori2,iblock)
6959 cosphi1=dcos(j*phii)
6960 sinphi1=dsin(j*phii)
6961 cosphi2=dcos(j*phii1)
6962 sinphi2=dsin(j*phii1)
6963 etors_d=etors_d+v1cij*cosphi1+v1sij*sinphi1+ &
6964 v2cij*cosphi2+v2sij*sinphi2
6965 if (energy_dec) etors_d_ii=etors_d_ii+ &
6966 v1cij*cosphi1+v1sij*sinphi1+v2cij*cosphi2+v2sij*sinphi2
6967 gloci1=gloci1+j*(v1sij*cosphi1-v1cij*sinphi1)
6968 gloci2=gloci2+j*(v2sij*cosphi2-v2cij*sinphi2)
6970 do k=2,ntermd_2(itori,itori1,itori2,iblock)
6972 v1cdij = v2c(k,l,itori,itori1,itori2,iblock)
6973 v2cdij = v2c(l,k,itori,itori1,itori2,iblock)
6974 v1sdij = v2s(k,l,itori,itori1,itori2,iblock)
6975 v2sdij = v2s(l,k,itori,itori1,itori2,iblock)
6976 cosphi1p2=dcos(l*phii+(k-l)*phii1)
6977 cosphi1m2=dcos(l*phii-(k-l)*phii1)
6978 sinphi1p2=dsin(l*phii+(k-l)*phii1)
6979 sinphi1m2=dsin(l*phii-(k-l)*phii1)
6980 etors_d=etors_d+v1cdij*cosphi1p2+v2cdij*cosphi1m2+ &
6981 v1sdij*sinphi1p2+v2sdij*sinphi1m2
6982 if (energy_dec) etors_d_ii=etors_d_ii+ &
6983 v1cdij*cosphi1p2+v2cdij*cosphi1m2+ &
6984 v1sdij*sinphi1p2+v2sdij*sinphi1m2
6985 gloci1=gloci1+l*(v1sdij*cosphi1p2+v2sdij*cosphi1m2 &
6986 -v1cdij*sinphi1p2-v2cdij*sinphi1m2)
6987 gloci2=gloci2+(k-l)*(v1sdij*cosphi1p2-v2sdij*cosphi1m2 &
6988 -v1cdij*sinphi1p2+v2cdij*sinphi1m2)
6991 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
6992 'etor_d',i,etors_d_ii
6993 gloc(i-3,icg)=gloc(i-3,icg)+wtor_d*gloci1
6994 gloc(i-2,icg)=gloc(i-2,icg)+wtor_d*gloci2
6997 end subroutine etor_d
6999 !-----------------------------------------------------------------------------
7000 subroutine eback_sc_corr(esccor)
7001 ! 7/21/2007 Correlations between the backbone-local and side-chain-local
7002 ! conformational states; temporarily implemented as differences
7003 ! between UNRES torsional potentials (dependent on three types of
7004 ! residues) and the torsional potentials dependent on all 20 types
7005 ! of residues computed from AM1 energy surfaces of terminally-blocked
7006 ! amino-acid residues.
7007 ! implicit real*8 (a-h,o-z)
7008 ! include 'DIMENSIONS'
7009 ! include 'COMMON.VAR'
7010 ! include 'COMMON.GEO'
7011 ! include 'COMMON.LOCAL'
7012 ! include 'COMMON.TORSION'
7013 ! include 'COMMON.SCCOR'
7014 ! include 'COMMON.INTERACT'
7015 ! include 'COMMON.DERIV'
7016 ! include 'COMMON.CHAIN'
7017 ! include 'COMMON.NAMES'
7018 ! include 'COMMON.IOUNITS'
7019 ! include 'COMMON.FFIELD'
7020 ! include 'COMMON.CONTROL'
7021 real(kind=8) :: esccor,esccor_ii,phii,gloci,v1ij,v2ij,&
7024 integer :: i,interty,j,isccori,isccori1,intertyp
7025 ! Set lprn=.true. for debugging
7028 ! write (iout,*) "EBACK_SC_COR",itau_start,itau_end
7030 do i=itau_start,itau_end
7031 if ((itype(i-2,1).eq.ntyp1).or.(itype(i-1,1).eq.ntyp1)) cycle
7033 isccori=isccortyp(itype(i-2,1))
7034 isccori1=isccortyp(itype(i-1,1))
7036 ! write (iout,*) "EBACK_SC_COR",i,nterm_sccor(isccori,isccori1)
7038 do intertyp=1,3 !intertyp
7040 !c Added 09 May 2012 (Adasko)
7041 !c Intertyp means interaction type of backbone mainchain correlation:
7042 ! 1 = SC...Ca...Ca...Ca
7043 ! 2 = Ca...Ca...Ca...SC
7044 ! 3 = SC...Ca...Ca...SCi
7046 if (((intertyp.eq.3).and.((itype(i-2,1).eq.10).or. &
7047 (itype(i-1,1).eq.10).or.(itype(i-2,1).eq.ntyp1).or. &
7048 (itype(i-1,1).eq.ntyp1))) &
7049 .or. ((intertyp.eq.1).and.((itype(i-2,1).eq.10) &
7050 .or.(itype(i-2,1).eq.ntyp1).or.(itype(i-1,1).eq.ntyp1) &
7051 .or.(itype(i,1).eq.ntyp1))) &
7052 .or.((intertyp.eq.2).and.((itype(i-1,1).eq.10).or. &
7053 (itype(i-1,1).eq.ntyp1).or.(itype(i-2,1).eq.ntyp1).or. &
7054 (itype(i-3,1).eq.ntyp1)))) cycle
7055 if ((intertyp.eq.2).and.(i.eq.4).and.(itype(1,1).eq.ntyp1)) cycle
7056 if ((intertyp.eq.1).and.(i.eq.nres).and.(itype(nres,1).eq.ntyp1)) &
7058 do j=1,nterm_sccor(isccori,isccori1)
7059 v1ij=v1sccor(j,intertyp,isccori,isccori1)
7060 v2ij=v2sccor(j,intertyp,isccori,isccori1)
7061 cosphi=dcos(j*tauangle(intertyp,i))
7062 sinphi=dsin(j*tauangle(intertyp,i))
7063 if (energy_dec) esccor_ii=esccor_ii+v1ij*cosphi+v2ij*sinphi
7064 esccor=esccor+v1ij*cosphi+v2ij*sinphi
7065 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
7067 if (energy_dec) write (iout,'(a6,i5,i2,0pf7.3)') &
7068 'esccor',i,intertyp,esccor_ii
7069 ! write (iout,*) "EBACK_SC_COR",i,v1ij*cosphi+v2ij*sinphi,intertyp
7070 gloc_sc(intertyp,i-3,icg)=gloc_sc(intertyp,i-3,icg)+wsccor*gloci
7072 write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)') &
7073 restyp(itype(i-2,1),1),i-2,restyp(itype(i-1,1),1),i-1,isccori,isccori1,&
7074 (v1sccor(j,intertyp,isccori,isccori1),j=1,6),&
7075 (v2sccor(j,intertyp,isccori,isccori1),j=1,6)
7076 gsccor_loc(i-3)=gsccor_loc(i-3)+gloci
7081 end subroutine eback_sc_corr
7082 !-----------------------------------------------------------------------------
7083 subroutine multibody(ecorr)
7084 ! This subroutine calculates multi-body contributions to energy following
7085 ! the idea of Skolnick et al. If side chains I and J make a contact and
7086 ! at the same time side chains I+1 and J+1 make a contact, an extra
7087 ! contribution equal to sqrt(eps(i,j)*eps(i+1,j+1)) is added.
7088 ! implicit real*8 (a-h,o-z)
7089 ! include 'DIMENSIONS'
7090 ! include 'COMMON.IOUNITS'
7091 ! include 'COMMON.DERIV'
7092 ! include 'COMMON.INTERACT'
7093 ! include 'COMMON.CONTACTS'
7094 real(kind=8),dimension(3) :: gx,gx1
7096 real(kind=8) :: ecorr
7097 integer :: i,j,ishift,i1,num_conti,num_conti1,j1,jj,kk
7098 ! Set lprn=.true. for debugging
7102 write (iout,'(a)') 'Contact function values:'
7104 write (iout,'(i2,20(1x,i2,f10.5))') &
7105 i,(jcont(j,i),facont(j,i),j=1,num_cont(i))
7110 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres))
7111 ! if (.not.allocated(gradxorr)) allocate(gradxorr(3,nres))
7123 num_conti=num_cont(i)
7124 num_conti1=num_cont(i1)
7129 if (j1.eq.j+ishift .or. j1.eq.j-ishift) then
7130 !d write(iout,*)'i=',i,' j=',j,' i1=',i1,' j1=',j1,
7131 !d & ' ishift=',ishift
7132 ! Contacts I--J and I+ISHIFT--J+-ISHIFT1 occur simultaneously.
7133 ! The system gains extra energy.
7134 ecorr=ecorr+esccorr(i,j,i1,j1,jj,kk)
7135 endif ! j1==j+-ishift
7143 end subroutine multibody
7144 !-----------------------------------------------------------------------------
7145 real(kind=8) function esccorr(i,j,k,l,jj,kk)
7146 ! implicit real*8 (a-h,o-z)
7147 ! include 'DIMENSIONS'
7148 ! include 'COMMON.IOUNITS'
7149 ! include 'COMMON.DERIV'
7150 ! include 'COMMON.INTERACT'
7151 ! include 'COMMON.CONTACTS'
7152 real(kind=8),dimension(3) :: gx,gx1
7154 integer :: i,j,k,l,jj,kk,m,ll
7155 real(kind=8) :: eij,ekl
7159 !d write (iout,'(4i5,3f10.5)') i,j,k,l,eij,ekl,-eij*ekl
7160 ! Calculate the multi-body contribution to energy.
7161 ! Calculate multi-body contributions to the gradient.
7162 !d write (iout,'(2(2i3,3f10.5))')i,j,(gacont(m,jj,i),m=1,3),
7163 !d & k,l,(gacont(m,kk,k),m=1,3)
7165 gx(m) =ekl*gacont(m,jj,i)
7166 gx1(m)=eij*gacont(m,kk,k)
7167 gradxorr(m,i)=gradxorr(m,i)-gx(m)
7168 gradxorr(m,j)=gradxorr(m,j)+gx(m)
7169 gradxorr(m,k)=gradxorr(m,k)-gx1(m)
7170 gradxorr(m,l)=gradxorr(m,l)+gx1(m)
7174 gradcorr(ll,m)=gradcorr(ll,m)+gx(ll)
7179 gradcorr(ll,m)=gradcorr(ll,m)+gx1(ll)
7184 end function esccorr
7185 !-----------------------------------------------------------------------------
7186 subroutine multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
7187 ! This subroutine calculates multi-body contributions to hydrogen-bonding
7188 ! implicit real*8 (a-h,o-z)
7189 ! include 'DIMENSIONS'
7190 ! include 'COMMON.IOUNITS'
7193 ! integer :: maxconts !max_cont=maxconts =nres/4
7194 integer,parameter :: max_dim=26
7195 integer :: source,CorrelType,CorrelID,CorrelType1,CorrelID1,Error
7196 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
7197 !el real(kind=8) :: zapas(max_dim,maxconts,nfgtasks)
7198 !el common /przechowalnia/ zapas
7199 integer :: status(MPI_STATUS_SIZE)
7200 integer,dimension((nres/4)*2) :: req !maxconts*2
7201 integer :: status_array(MPI_STATUS_SIZE,(nres/4)*2),nn,ireq,ierr
7203 ! include 'COMMON.SETUP'
7204 ! include 'COMMON.FFIELD'
7205 ! include 'COMMON.DERIV'
7206 ! include 'COMMON.INTERACT'
7207 ! include 'COMMON.CONTACTS'
7208 ! include 'COMMON.CONTROL'
7209 ! include 'COMMON.LOCAL'
7210 real(kind=8),dimension(3) :: gx,gx1
7211 real(kind=8) :: time00,ecorr,ecorr5,ecorr6
7212 logical :: lprn,ldone
7214 integer :: i,j,ii,k,n_corr,n_corr1,i1,num_conti,num_conti1,&
7215 jj,jp,kk,j1,jp1,jjc,iii,nnn,iproc
7217 ! Set lprn=.true. for debugging
7221 if(.not.allocated(zapas)) allocate(zapas(max_dim,maxconts,nfgtasks))
7224 if (nfgtasks.le.1) goto 30
7226 write (iout,'(a)') 'Contact function values before RECEIVE:'
7228 write (iout,'(2i3,50(1x,i2,f5.2))') &
7229 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
7234 do i=1,ntask_cont_from
7237 do i=1,ntask_cont_to
7240 ! write (iout,*) "ntask_cont_from",ntask_cont_from," ntask_cont_to",
7242 ! Make the list of contacts to send to send to other procesors
7243 ! write (iout,*) "limits",max0(iturn4_end-1,iatel_s),iturn3_end
7245 do i=iturn3_start,iturn3_end
7246 ! write (iout,*) "make contact list turn3",i," num_cont",
7248 call add_hb_contact(i,i+2,iturn3_sent_local(1,i))
7250 do i=iturn4_start,iturn4_end
7251 ! write (iout,*) "make contact list turn4",i," num_cont",
7253 call add_hb_contact(i,i+3,iturn4_sent_local(1,i))
7257 ! write (iout,*) "make contact list longrange",i,ii," num_cont",
7259 do j=1,num_cont_hb(i)
7262 iproc=iint_sent_local(k,jjc,ii)
7263 ! write (iout,*) "i",i," j",j," k",k," jjc",jjc," iproc",iproc
7264 if (iproc.gt.0) then
7265 ncont_sent(iproc)=ncont_sent(iproc)+1
7266 nn=ncont_sent(iproc)
7268 zapas(2,nn,iproc)=jjc
7269 zapas(3,nn,iproc)=facont_hb(j,i)
7270 zapas(4,nn,iproc)=ees0p(j,i)
7271 zapas(5,nn,iproc)=ees0m(j,i)
7272 zapas(6,nn,iproc)=gacont_hbr(1,j,i)
7273 zapas(7,nn,iproc)=gacont_hbr(2,j,i)
7274 zapas(8,nn,iproc)=gacont_hbr(3,j,i)
7275 zapas(9,nn,iproc)=gacontm_hb1(1,j,i)
7276 zapas(10,nn,iproc)=gacontm_hb1(2,j,i)
7277 zapas(11,nn,iproc)=gacontm_hb1(3,j,i)
7278 zapas(12,nn,iproc)=gacontp_hb1(1,j,i)
7279 zapas(13,nn,iproc)=gacontp_hb1(2,j,i)
7280 zapas(14,nn,iproc)=gacontp_hb1(3,j,i)
7281 zapas(15,nn,iproc)=gacontm_hb2(1,j,i)
7282 zapas(16,nn,iproc)=gacontm_hb2(2,j,i)
7283 zapas(17,nn,iproc)=gacontm_hb2(3,j,i)
7284 zapas(18,nn,iproc)=gacontp_hb2(1,j,i)
7285 zapas(19,nn,iproc)=gacontp_hb2(2,j,i)
7286 zapas(20,nn,iproc)=gacontp_hb2(3,j,i)
7287 zapas(21,nn,iproc)=gacontm_hb3(1,j,i)
7288 zapas(22,nn,iproc)=gacontm_hb3(2,j,i)
7289 zapas(23,nn,iproc)=gacontm_hb3(3,j,i)
7290 zapas(24,nn,iproc)=gacontp_hb3(1,j,i)
7291 zapas(25,nn,iproc)=gacontp_hb3(2,j,i)
7292 zapas(26,nn,iproc)=gacontp_hb3(3,j,i)
7299 "Numbers of contacts to be sent to other processors",&
7300 (ncont_sent(i),i=1,ntask_cont_to)
7301 write (iout,*) "Contacts sent"
7302 do ii=1,ntask_cont_to
7304 iproc=itask_cont_to(ii)
7305 write (iout,*) nn," contacts to processor",iproc,&
7306 " of CONT_TO_COMM group"
7308 write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
7316 CorrelID1=nfgtasks+fg_rank+1
7318 ! Receive the numbers of needed contacts from other processors
7319 do ii=1,ntask_cont_from
7320 iproc=itask_cont_from(ii)
7322 call MPI_Irecv(ncont_recv(ii),1,MPI_INTEGER,iproc,CorrelType,&
7323 FG_COMM,req(ireq),IERR)
7325 ! write (iout,*) "IRECV ended"
7327 ! Send the number of contacts needed by other processors
7328 do ii=1,ntask_cont_to
7329 iproc=itask_cont_to(ii)
7331 call MPI_Isend(ncont_sent(ii),1,MPI_INTEGER,iproc,CorrelType,&
7332 FG_COMM,req(ireq),IERR)
7334 ! write (iout,*) "ISEND ended"
7335 ! write (iout,*) "number of requests (nn)",ireq
7338 call MPI_Waitall(ireq,req,status_array,ierr)
7340 ! & "Numbers of contacts to be received from other processors",
7341 ! & (ncont_recv(i),i=1,ntask_cont_from)
7345 do ii=1,ntask_cont_from
7346 iproc=itask_cont_from(ii)
7348 ! write (iout,*) "Receiving",nn," contacts from processor",iproc,
7349 ! & " of CONT_TO_COMM group"
7353 call MPI_Irecv(zapas_recv(1,1,ii),nn*max_dim,&
7354 MPI_DOUBLE_PRECISION,iproc,CorrelType1,FG_COMM,req(ireq),IERR)
7355 ! write (iout,*) "ireq,req",ireq,req(ireq)
7358 ! Send the contacts to processors that need them
7359 do ii=1,ntask_cont_to
7360 iproc=itask_cont_to(ii)
7362 ! write (iout,*) nn," contacts to processor",iproc,
7363 ! & " of CONT_TO_COMM group"
7366 call MPI_Isend(zapas(1,1,ii),nn*max_dim,MPI_DOUBLE_PRECISION,&
7367 iproc,CorrelType1,FG_COMM,req(ireq),IERR)
7368 ! write (iout,*) "ireq,req",ireq,req(ireq)
7370 ! write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
7374 ! write (iout,*) "number of requests (contacts)",ireq
7375 ! write (iout,*) "req",(req(i),i=1,4)
7378 call MPI_Waitall(ireq,req,status_array,ierr)
7379 do iii=1,ntask_cont_from
7380 iproc=itask_cont_from(iii)
7383 write (iout,*) "Received",nn," contacts from processor",iproc,&
7384 " of CONT_FROM_COMM group"
7387 write(iout,'(2f5.0,4f10.5)')(zapas_recv(j,i,iii),j=1,5)
7392 ii=zapas_recv(1,i,iii)
7393 ! Flag the received contacts to prevent double-counting
7394 jj=-zapas_recv(2,i,iii)
7395 ! write (iout,*) "iii",iii," i",i," ii",ii," jj",jj
7397 nnn=num_cont_hb(ii)+1
7400 facont_hb(nnn,ii)=zapas_recv(3,i,iii)
7401 ees0p(nnn,ii)=zapas_recv(4,i,iii)
7402 ees0m(nnn,ii)=zapas_recv(5,i,iii)
7403 gacont_hbr(1,nnn,ii)=zapas_recv(6,i,iii)
7404 gacont_hbr(2,nnn,ii)=zapas_recv(7,i,iii)
7405 gacont_hbr(3,nnn,ii)=zapas_recv(8,i,iii)
7406 gacontm_hb1(1,nnn,ii)=zapas_recv(9,i,iii)
7407 gacontm_hb1(2,nnn,ii)=zapas_recv(10,i,iii)
7408 gacontm_hb1(3,nnn,ii)=zapas_recv(11,i,iii)
7409 gacontp_hb1(1,nnn,ii)=zapas_recv(12,i,iii)
7410 gacontp_hb1(2,nnn,ii)=zapas_recv(13,i,iii)
7411 gacontp_hb1(3,nnn,ii)=zapas_recv(14,i,iii)
7412 gacontm_hb2(1,nnn,ii)=zapas_recv(15,i,iii)
7413 gacontm_hb2(2,nnn,ii)=zapas_recv(16,i,iii)
7414 gacontm_hb2(3,nnn,ii)=zapas_recv(17,i,iii)
7415 gacontp_hb2(1,nnn,ii)=zapas_recv(18,i,iii)
7416 gacontp_hb2(2,nnn,ii)=zapas_recv(19,i,iii)
7417 gacontp_hb2(3,nnn,ii)=zapas_recv(20,i,iii)
7418 gacontm_hb3(1,nnn,ii)=zapas_recv(21,i,iii)
7419 gacontm_hb3(2,nnn,ii)=zapas_recv(22,i,iii)
7420 gacontm_hb3(3,nnn,ii)=zapas_recv(23,i,iii)
7421 gacontp_hb3(1,nnn,ii)=zapas_recv(24,i,iii)
7422 gacontp_hb3(2,nnn,ii)=zapas_recv(25,i,iii)
7423 gacontp_hb3(3,nnn,ii)=zapas_recv(26,i,iii)
7428 write (iout,'(a)') 'Contact function values after receive:'
7430 write (iout,'(2i3,50(1x,i3,f5.2))') &
7431 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
7439 write (iout,'(a)') 'Contact function values:'
7441 write (iout,'(2i3,50(1x,i3,f5.2))') &
7442 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
7448 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres))
7449 ! if (.not.allocated(gradxorr)) allocate(gradxorr(3,nres))
7450 ! Remove the loop below after debugging !!!
7457 ! Calculate the local-electrostatic correlation terms
7458 do i=min0(iatel_s,iturn4_start),max0(iatel_e,iturn3_end)
7460 num_conti=num_cont_hb(i)
7461 num_conti1=num_cont_hb(i+1)
7468 ! write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,&
7469 ! ' jj=',jj,' kk=',kk,"jp=",jp,"jp1",jp1
7470 if ((j.gt.0 .and. j1.gt.0 .or. j.gt.0 .and. j1.lt.0 &
7471 .or. j.lt.0 .and. j1.gt.0) .and. &
7472 (jp1.eq.jp+1 .or. jp1.eq.jp-1)) then
7473 ! Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
7474 ! The system gains extra energy.
7475 ecorr=ecorr+ehbcorr(i,jp,i+1,jp1,jj,kk,0.72D0,0.32D0)
7476 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
7477 'ecorrh',i,j,ehbcorr(i,jp,i+1,jp1,jj,kk,0.72D0,0.32D0)
7479 else if (j1.eq.j) then
7480 ! Contacts I-J and I-(J+1) occur simultaneously.
7481 ! The system loses extra energy.
7482 ! ecorr=ecorr+ehbcorr(i,j,i+1,j,jj,kk,0.60D0,-0.40D0)
7487 ! write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
7488 ! & ' jj=',jj,' kk=',kk
7490 ! Contacts I-J and (I+1)-J occur simultaneously.
7491 ! The system loses extra energy.
7492 ! ecorr=ecorr+ehbcorr(i,j,i,j+1,jj,kk,0.60D0,-0.40D0)
7498 end subroutine multibody_hb
7499 !-----------------------------------------------------------------------------
7500 subroutine add_hb_contact(ii,jj,itask)
7501 ! implicit real*8 (a-h,o-z)
7502 ! include "DIMENSIONS"
7503 ! include "COMMON.IOUNITS"
7504 ! include "COMMON.CONTACTS"
7505 ! integer,parameter :: maxconts=nres/4
7506 integer,parameter :: max_dim=26
7507 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
7508 ! real(kind=8) :: zapas(max_dim,maxconts,nfgtasks)
7509 ! common /przechowalnia/ zapas
7510 integer :: i,j,ii,jj,iproc,nn,jjc
7511 integer,dimension(4) :: itask
7512 ! write (iout,*) "itask",itask
7515 if (iproc.gt.0) then
7516 do j=1,num_cont_hb(ii)
7518 ! write (iout,*) "i",ii," j",jj," jjc",jjc
7520 ncont_sent(iproc)=ncont_sent(iproc)+1
7521 nn=ncont_sent(iproc)
7522 zapas(1,nn,iproc)=ii
7523 zapas(2,nn,iproc)=jjc
7524 zapas(3,nn,iproc)=facont_hb(j,ii)
7525 zapas(4,nn,iproc)=ees0p(j,ii)
7526 zapas(5,nn,iproc)=ees0m(j,ii)
7527 zapas(6,nn,iproc)=gacont_hbr(1,j,ii)
7528 zapas(7,nn,iproc)=gacont_hbr(2,j,ii)
7529 zapas(8,nn,iproc)=gacont_hbr(3,j,ii)
7530 zapas(9,nn,iproc)=gacontm_hb1(1,j,ii)
7531 zapas(10,nn,iproc)=gacontm_hb1(2,j,ii)
7532 zapas(11,nn,iproc)=gacontm_hb1(3,j,ii)
7533 zapas(12,nn,iproc)=gacontp_hb1(1,j,ii)
7534 zapas(13,nn,iproc)=gacontp_hb1(2,j,ii)
7535 zapas(14,nn,iproc)=gacontp_hb1(3,j,ii)
7536 zapas(15,nn,iproc)=gacontm_hb2(1,j,ii)
7537 zapas(16,nn,iproc)=gacontm_hb2(2,j,ii)
7538 zapas(17,nn,iproc)=gacontm_hb2(3,j,ii)
7539 zapas(18,nn,iproc)=gacontp_hb2(1,j,ii)
7540 zapas(19,nn,iproc)=gacontp_hb2(2,j,ii)
7541 zapas(20,nn,iproc)=gacontp_hb2(3,j,ii)
7542 zapas(21,nn,iproc)=gacontm_hb3(1,j,ii)
7543 zapas(22,nn,iproc)=gacontm_hb3(2,j,ii)
7544 zapas(23,nn,iproc)=gacontm_hb3(3,j,ii)
7545 zapas(24,nn,iproc)=gacontp_hb3(1,j,ii)
7546 zapas(25,nn,iproc)=gacontp_hb3(2,j,ii)
7547 zapas(26,nn,iproc)=gacontp_hb3(3,j,ii)
7554 end subroutine add_hb_contact
7555 !-----------------------------------------------------------------------------
7556 subroutine multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
7557 ! This subroutine calculates multi-body contributions to hydrogen-bonding
7558 ! implicit real*8 (a-h,o-z)
7559 ! include 'DIMENSIONS'
7560 ! include 'COMMON.IOUNITS'
7561 integer,parameter :: max_dim=70
7564 ! integer :: maxconts !max_cont=maxconts=nres/4
7565 integer :: source,CorrelType,CorrelID,CorrelType1,CorrelID1,Error
7566 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks)
7567 ! real(kind=8) :: zapas(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
7568 ! common /przechowalnia/ zapas
7569 integer :: status(MPI_STATUS_SIZE),req((nres/4)*2),&
7570 status_array(MPI_STATUS_SIZE,(nres/4)*2),jjc,iproc,ireq,nn,ind,&
7573 ! include 'COMMON.SETUP'
7574 ! include 'COMMON.FFIELD'
7575 ! include 'COMMON.DERIV'
7576 ! include 'COMMON.LOCAL'
7577 ! include 'COMMON.INTERACT'
7578 ! include 'COMMON.CONTACTS'
7579 ! include 'COMMON.CHAIN'
7580 ! include 'COMMON.CONTROL'
7581 real(kind=8),dimension(3) :: gx,gx1
7582 integer,dimension(nres) :: num_cont_hb_old
7583 logical :: lprn,ldone
7584 !EL double precision eello4,eello5,eelo6,eello_turn6
7585 !EL external eello4,eello5,eello6,eello_turn6
7587 integer :: i,ii,j,k,l,jj,kk,ll,mm,n_corr,n_corr1,num_conti,jp,&
7588 j1,jp1,i1,num_conti1
7589 real(kind=8) :: sqd1,sqd2,sred_geom,fac_prim1,fac_prim2,fprimcont
7590 real(kind=8) :: ecorr,ecorr5,ecorr6,eturn6
7592 ! Set lprn=.true. for debugging
7597 if(.not.allocated(zapas)) allocate(zapas(max_dim,maxconts,nfgtasks))
7599 num_cont_hb_old(i)=num_cont_hb(i)
7603 if (nfgtasks.le.1) goto 30
7605 write (iout,'(a)') 'Contact function values before RECEIVE:'
7607 write (iout,'(2i3,50(1x,i2,f5.2))') &
7608 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
7613 do i=1,ntask_cont_from
7616 do i=1,ntask_cont_to
7619 ! write (iout,*) "ntask_cont_from",ntask_cont_from," ntask_cont_to",
7621 ! Make the list of contacts to send to send to other procesors
7622 do i=iturn3_start,iturn3_end
7623 ! write (iout,*) "make contact list turn3",i," num_cont",
7625 call add_hb_contact_eello(i,i+2,iturn3_sent_local(1,i))
7627 do i=iturn4_start,iturn4_end
7628 ! write (iout,*) "make contact list turn4",i," num_cont",
7630 call add_hb_contact_eello(i,i+3,iturn4_sent_local(1,i))
7634 ! write (iout,*) "make contact list longrange",i,ii," num_cont",
7636 do j=1,num_cont_hb(i)
7639 iproc=iint_sent_local(k,jjc,ii)
7640 ! write (iout,*) "i",i," j",j," k",k," jjc",jjc," iproc",iproc
7641 if (iproc.ne.0) then
7642 ncont_sent(iproc)=ncont_sent(iproc)+1
7643 nn=ncont_sent(iproc)
7645 zapas(2,nn,iproc)=jjc
7646 zapas(3,nn,iproc)=d_cont(j,i)
7650 zapas(ind,nn,iproc)=grij_hb_cont(kk,j,i)
7655 zapas(ind,nn,iproc)=a_chuj(ll,kk,j,i)
7663 zapas(ind,nn,iproc)=a_chuj_der(mm,ll,kk,jj,j,i)
7674 "Numbers of contacts to be sent to other processors",&
7675 (ncont_sent(i),i=1,ntask_cont_to)
7676 write (iout,*) "Contacts sent"
7677 do ii=1,ntask_cont_to
7679 iproc=itask_cont_to(ii)
7680 write (iout,*) nn," contacts to processor",iproc,&
7681 " of CONT_TO_COMM group"
7683 write(iout,'(2f5.0,10f10.5)')(zapas(j,i,ii),j=1,10)
7691 CorrelID1=nfgtasks+fg_rank+1
7693 ! Receive the numbers of needed contacts from other processors
7694 do ii=1,ntask_cont_from
7695 iproc=itask_cont_from(ii)
7697 call MPI_Irecv(ncont_recv(ii),1,MPI_INTEGER,iproc,CorrelType,&
7698 FG_COMM,req(ireq),IERR)
7700 ! write (iout,*) "IRECV ended"
7702 ! Send the number of contacts needed by other processors
7703 do ii=1,ntask_cont_to
7704 iproc=itask_cont_to(ii)
7706 call MPI_Isend(ncont_sent(ii),1,MPI_INTEGER,iproc,CorrelType,&
7707 FG_COMM,req(ireq),IERR)
7709 ! write (iout,*) "ISEND ended"
7710 ! write (iout,*) "number of requests (nn)",ireq
7713 call MPI_Waitall(ireq,req,status_array,ierr)
7715 ! & "Numbers of contacts to be received from other processors",
7716 ! & (ncont_recv(i),i=1,ntask_cont_from)
7720 do ii=1,ntask_cont_from
7721 iproc=itask_cont_from(ii)
7723 ! write (iout,*) "Receiving",nn," contacts from processor",iproc,
7724 ! & " of CONT_TO_COMM group"
7728 call MPI_Irecv(zapas_recv(1,1,ii),nn*max_dim,&
7729 MPI_DOUBLE_PRECISION,iproc,CorrelType1,FG_COMM,req(ireq),IERR)
7730 ! write (iout,*) "ireq,req",ireq,req(ireq)
7733 ! Send the contacts to processors that need them
7734 do ii=1,ntask_cont_to
7735 iproc=itask_cont_to(ii)
7737 ! write (iout,*) nn," contacts to processor",iproc,
7738 ! & " of CONT_TO_COMM group"
7741 call MPI_Isend(zapas(1,1,ii),nn*max_dim,MPI_DOUBLE_PRECISION,&
7742 iproc,CorrelType1,FG_COMM,req(ireq),IERR)
7743 ! write (iout,*) "ireq,req",ireq,req(ireq)
7745 ! write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
7749 ! write (iout,*) "number of requests (contacts)",ireq
7750 ! write (iout,*) "req",(req(i),i=1,4)
7753 call MPI_Waitall(ireq,req,status_array,ierr)
7754 do iii=1,ntask_cont_from
7755 iproc=itask_cont_from(iii)
7758 write (iout,*) "Received",nn," contacts from processor",iproc,&
7759 " of CONT_FROM_COMM group"
7762 write(iout,'(2f5.0,10f10.5)')(zapas_recv(j,i,iii),j=1,10)
7767 ii=zapas_recv(1,i,iii)
7768 ! Flag the received contacts to prevent double-counting
7769 jj=-zapas_recv(2,i,iii)
7770 ! write (iout,*) "iii",iii," i",i," ii",ii," jj",jj
7772 nnn=num_cont_hb(ii)+1
7775 d_cont(nnn,ii)=zapas_recv(3,i,iii)
7779 grij_hb_cont(kk,nnn,ii)=zapas_recv(ind,i,iii)
7784 a_chuj(ll,kk,nnn,ii)=zapas_recv(ind,i,iii)
7792 a_chuj_der(mm,ll,kk,jj,nnn,ii)=zapas_recv(ind,i,iii)
7801 write (iout,'(a)') 'Contact function values after receive:'
7803 write (iout,'(2i3,50(1x,i3,5f6.3))') &
7804 i,num_cont_hb(i),(jcont_hb(j,i),d_cont(j,i),&
7805 ((a_chuj(ll,kk,j,i),ll=1,2),kk=1,2),j=1,num_cont_hb(i))
7812 write (iout,'(a)') 'Contact function values:'
7814 write (iout,'(2i3,50(1x,i2,5f6.3))') &
7815 i,num_cont_hb(i),(jcont_hb(j,i),d_cont(j,i),&
7816 ((a_chuj(ll,kk,j,i),ll=1,2),kk=1,2),j=1,num_cont_hb(i))
7823 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres))
7824 ! if (.not.allocated(gradxorr)) allocate(gradxorr(3,nres))
7825 ! Remove the loop below after debugging !!!
7832 ! Calculate the dipole-dipole interaction energies
7833 if (wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) then
7834 do i=iatel_s,iatel_e+1
7835 num_conti=num_cont_hb(i)
7844 ! Calculate the local-electrostatic correlation terms
7845 ! write (iout,*) "gradcorr5 in eello5 before loop"
7847 ! write (iout,'(i5,3f10.5)')
7848 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
7850 do i=min0(iatel_s,iturn4_start),max0(iatel_e+1,iturn3_end+1)
7851 ! write (iout,*) "corr loop i",i
7853 num_conti=num_cont_hb(i)
7854 num_conti1=num_cont_hb(i+1)
7861 ! write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
7862 ! & ' jj=',jj,' kk=',kk
7863 ! if (j1.eq.j+1 .or. j1.eq.j-1) then
7864 if ((j.gt.0 .and. j1.gt.0 .or. j.gt.0 .and. j1.lt.0 &
7865 .or. j.lt.0 .and. j1.gt.0) .and. &
7866 (jp1.eq.jp+1 .or. jp1.eq.jp-1)) then
7867 ! Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
7868 ! The system gains extra energy.
7870 sqd1=dsqrt(d_cont(jj,i))
7871 sqd2=dsqrt(d_cont(kk,i1))
7872 sred_geom = sqd1*sqd2
7873 IF (sred_geom.lt.cutoff_corr) THEN
7874 call gcont(sred_geom,r0_corr,1.0D0,delt_corr,&
7876 !d write (iout,*) 'i=',i,' j=',jp,' i1=',i1,' j1=',jp1,
7877 !d & ' jj=',jj,' kk=',kk
7878 fac_prim1=0.5d0*sqd2/sqd1*fprimcont
7879 fac_prim2=0.5d0*sqd1/sqd2*fprimcont
7881 g_contij(l,1)=fac_prim1*grij_hb_cont(l,jj,i)
7882 g_contij(l,2)=fac_prim2*grij_hb_cont(l,kk,i1)
7885 !d write (iout,*) 'sred_geom=',sred_geom,
7886 !d & ' ekont=',ekont,' fprim=',fprimcont,
7887 !d & ' fac_prim1',fac_prim1,' fac_prim2',fac_prim2
7888 !d write (iout,*) "g_contij",g_contij
7889 !d write (iout,*) "grij_hb_cont i",grij_hb_cont(:,jj,i)
7890 !d write (iout,*) "grij_hb_cont i1",grij_hb_cont(:,jj,i1)
7891 call calc_eello(i,jp,i+1,jp1,jj,kk)
7892 if (wcorr4.gt.0.0d0) &
7893 ecorr=ecorr+eello4(i,jp,i+1,jp1,jj,kk)
7894 if (energy_dec.and.wcorr4.gt.0.0d0) &
7895 write (iout,'(a6,4i5,0pf7.3)') &
7896 'ecorr4',i,j,i+1,j1,eello4(i,jp,i+1,jp1,jj,kk)
7897 ! write (iout,*) "gradcorr5 before eello5"
7899 ! write (iout,'(i5,3f10.5)')
7900 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
7902 if (wcorr5.gt.0.0d0) &
7903 ecorr5=ecorr5+eello5(i,jp,i+1,jp1,jj,kk)
7904 ! write (iout,*) "gradcorr5 after eello5"
7906 ! write (iout,'(i5,3f10.5)')
7907 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
7909 if (energy_dec.and.wcorr5.gt.0.0d0) &
7910 write (iout,'(a6,4i5,0pf7.3)') &
7911 'ecorr5',i,j,i+1,j1,eello5(i,jp,i+1,jp1,jj,kk)
7912 !d write(2,*)'wcorr6',wcorr6,' wturn6',wturn6
7913 !d write(2,*)'ijkl',i,jp,i+1,jp1
7914 if (wcorr6.gt.0.0d0 .and. (jp.ne.i+4 .or. jp1.ne.i+3 &
7915 .or. wturn6.eq.0.0d0))then
7916 !d write (iout,*) '******ecorr6: i,j,i+1,j1',i,j,i+1,j1
7917 ecorr6=ecorr6+eello6(i,jp,i+1,jp1,jj,kk)
7918 if (energy_dec) write (iout,'(a6,4i5,0pf7.3)') &
7919 'ecorr6',i,j,i+1,j1,eello6(i,jp,i+1,jp1,jj,kk)
7920 !d write (iout,*) 'ecorr',ecorr,' ecorr5=',ecorr5,
7921 !d & 'ecorr6=',ecorr6
7922 !d write (iout,'(4e15.5)') sred_geom,
7923 !d & dabs(eello4(i,jp,i+1,jp1,jj,kk)),
7924 !d & dabs(eello5(i,jp,i+1,jp1,jj,kk)),
7925 !d & dabs(eello6(i,jp,i+1,jp1,jj,kk))
7926 else if (wturn6.gt.0.0d0 &
7927 .and. (jp.eq.i+4 .and. jp1.eq.i+3)) then
7928 !d write (iout,*) '******eturn6: i,j,i+1,j1',i,jip,i+1,jp1
7929 eturn6=eturn6+eello_turn6(i,jj,kk)
7930 if (energy_dec) write (iout,'(a6,4i5,0pf7.3)') &
7931 'eturn6',i,j,i+1,j1,eello_turn6(i,jj,kk)
7932 !d write (2,*) 'multibody_eello:eturn6',eturn6
7941 num_cont_hb(i)=num_cont_hb_old(i)
7943 ! write (iout,*) "gradcorr5 in eello5"
7945 ! write (iout,'(i5,3f10.5)')
7946 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
7949 end subroutine multibody_eello
7950 !-----------------------------------------------------------------------------
7951 subroutine add_hb_contact_eello(ii,jj,itask)
7952 ! implicit real*8 (a-h,o-z)
7953 ! include "DIMENSIONS"
7954 ! include "COMMON.IOUNITS"
7955 ! include "COMMON.CONTACTS"
7956 ! integer,parameter :: maxconts=nres/4
7957 integer,parameter :: max_dim=70
7958 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks)
7959 ! real(kind=8) :: zapas(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
7960 ! common /przechowalnia/ zapas
7962 integer :: i,j,ii,jj,iproc,nn,ind,jjc,kk,ll,mm
7963 integer,dimension(4) ::itask
7964 ! write (iout,*) "itask",itask
7967 if (iproc.gt.0) then
7968 do j=1,num_cont_hb(ii)
7970 ! write (iout,*) "send turns i",ii," j",jj," jjc",jjc
7972 ncont_sent(iproc)=ncont_sent(iproc)+1
7973 nn=ncont_sent(iproc)
7974 zapas(1,nn,iproc)=ii
7975 zapas(2,nn,iproc)=jjc
7976 zapas(3,nn,iproc)=d_cont(j,ii)
7980 zapas(ind,nn,iproc)=grij_hb_cont(kk,j,ii)
7985 zapas(ind,nn,iproc)=a_chuj(ll,kk,j,ii)
7993 zapas(ind,nn,iproc)=a_chuj_der(mm,ll,kk,jj,j,ii)
8004 end subroutine add_hb_contact_eello
8005 !-----------------------------------------------------------------------------
8006 real(kind=8) function ehbcorr(i,j,k,l,jj,kk,coeffp,coeffm)
8007 ! implicit real*8 (a-h,o-z)
8008 ! include 'DIMENSIONS'
8009 ! include 'COMMON.IOUNITS'
8010 ! include 'COMMON.DERIV'
8011 ! include 'COMMON.INTERACT'
8012 ! include 'COMMON.CONTACTS'
8013 real(kind=8),dimension(3) :: gx,gx1
8016 integer :: i,j,k,l,jj,kk,ll,ilist,m, iresshield
8017 real(kind=8) :: coeffp,coeffm,eij,ekl,ees0pij,ees0pkl,ees0mij,&
8018 ees0mkl,ees,coeffpees0pij,coeffmees0mij,&
8019 coeffpees0pkl,coeffmees0mkl,gradlongij,gradlongkl, &
8030 ees=-(coeffp*ees0pij*ees0pkl+coeffm*ees0mij*ees0mkl)
8031 !d ees=-(coeffp*ees0pkl+coeffm*ees0mkl)
8032 ! Following 4 lines for diagnostics.
8037 ! write (iout,'(2(a,2i3,a,f10.5,a,2f10.5),a,f10.5,a,$)')
8038 ! & 'Contacts ',i,j,
8039 ! & ' eij',eij,' eesij',ees0pij,ees0mij,' and ',k,l
8040 ! & ,' fcont ',ekl,' eeskl',ees0pkl,ees0mkl,' energy=',ekont*ees,
8042 ! Calculate the multi-body contribution to energy.
8043 ! ecorr=ecorr+ekont*ees
8044 ! Calculate multi-body contributions to the gradient.
8045 coeffpees0pij=coeffp*ees0pij
8046 coeffmees0mij=coeffm*ees0mij
8047 coeffpees0pkl=coeffp*ees0pkl
8048 coeffmees0mkl=coeffm*ees0mkl
8050 !grad ghalfi=ees*ekl*gacont_hbr(ll,jj,i)
8051 gradcorr(ll,i)=gradcorr(ll,i) & !+0.5d0*ghalfi
8052 -ekont*(coeffpees0pkl*gacontp_hb1(ll,jj,i)+ &
8053 coeffmees0mkl*gacontm_hb1(ll,jj,i))
8054 gradcorr(ll,j)=gradcorr(ll,j) & !+0.5d0*ghalfi
8055 -ekont*(coeffpees0pkl*gacontp_hb2(ll,jj,i)+ &
8056 coeffmees0mkl*gacontm_hb2(ll,jj,i))
8057 !grad ghalfk=ees*eij*gacont_hbr(ll,kk,k)
8058 gradcorr(ll,k)=gradcorr(ll,k) & !+0.5d0*ghalfk
8059 -ekont*(coeffpees0pij*gacontp_hb1(ll,kk,k)+&
8060 coeffmees0mij*gacontm_hb1(ll,kk,k))
8061 gradcorr(ll,l)=gradcorr(ll,l) & !+0.5d0*ghalfk
8062 -ekont*(coeffpees0pij*gacontp_hb2(ll,kk,k)+ &
8063 coeffmees0mij*gacontm_hb2(ll,kk,k))
8064 gradlongij=ees*ekl*gacont_hbr(ll,jj,i)- &
8065 ekont*(coeffpees0pkl*gacontp_hb3(ll,jj,i)+ &
8066 coeffmees0mkl*gacontm_hb3(ll,jj,i))
8067 gradcorr_long(ll,j)=gradcorr_long(ll,j)+gradlongij
8068 gradcorr_long(ll,i)=gradcorr_long(ll,i)-gradlongij
8069 gradlongkl=ees*eij*gacont_hbr(ll,kk,k)- &
8070 ekont*(coeffpees0pij*gacontp_hb3(ll,kk,k)+ &
8071 coeffmees0mij*gacontm_hb3(ll,kk,k))
8072 gradcorr_long(ll,l)=gradcorr_long(ll,l)+gradlongkl
8073 gradcorr_long(ll,k)=gradcorr_long(ll,k)-gradlongkl
8074 ! write (iout,'(2f10.5,2x,$)') gradlongij,gradlongkl
8079 !grad gradcorr(ll,m)=gradcorr(ll,m)+
8080 !grad & ees*ekl*gacont_hbr(ll,jj,i)-
8081 !grad & ekont*(coeffp*ees0pkl*gacontp_hb3(ll,jj,i)+
8082 !grad & coeffm*ees0mkl*gacontm_hb3(ll,jj,i))
8087 !grad gradcorr(ll,m)=gradcorr(ll,m)+
8088 !grad & ees*eij*gacont_hbr(ll,kk,k)-
8089 !grad & ekont*(coeffp*ees0pij*gacontp_hb3(ll,kk,k)+
8090 !grad & coeffm*ees0mij*gacontm_hb3(ll,kk,k))
8093 ! write (iout,*) "ehbcorr",ekont*ees
8095 if (shield_mode.gt.0) then
8098 !C print *,i,j,fac_shield(i),fac_shield(j),
8099 !C &fac_shield(k),fac_shield(l)
8100 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
8101 (fac_shield(k).gt.0).and.(fac_shield(l).gt.0)) then
8102 do ilist=1,ishield_list(i)
8103 iresshield=shield_list(ilist,i)
8105 rlocshield=grad_shield_side(m,ilist,i)*ehbcorr/fac_shield(i)
8106 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+ &
8108 +grad_shield_loc(m,ilist,i)*ehbcorr/fac_shield(i)
8109 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1) &
8113 do ilist=1,ishield_list(j)
8114 iresshield=shield_list(ilist,j)
8116 rlocshield=grad_shield_side(m,ilist,j)*ehbcorr/fac_shield(j)
8117 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+ &
8119 +grad_shield_loc(m,ilist,j)*ehbcorr/fac_shield(j)
8120 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1) &
8125 do ilist=1,ishield_list(k)
8126 iresshield=shield_list(ilist,k)
8128 rlocshield=grad_shield_side(m,ilist,k)*ehbcorr/fac_shield(k)
8129 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+ &
8131 +grad_shield_loc(m,ilist,k)*ehbcorr/fac_shield(k)
8132 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1) &
8136 do ilist=1,ishield_list(l)
8137 iresshield=shield_list(ilist,l)
8139 rlocshield=grad_shield_side(m,ilist,l)*ehbcorr/fac_shield(l)
8140 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+ &
8142 +grad_shield_loc(m,ilist,l)*ehbcorr/fac_shield(l)
8143 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1) &
8148 gshieldc_ec(m,i)=gshieldc_ec(m,i)+ &
8149 grad_shield(m,i)*ehbcorr/fac_shield(i)
8150 gshieldc_ec(m,j)=gshieldc_ec(m,j)+ &
8151 grad_shield(m,j)*ehbcorr/fac_shield(j)
8152 gshieldc_ec(m,i-1)=gshieldc_ec(m,i-1)+ &
8153 grad_shield(m,i)*ehbcorr/fac_shield(i)
8154 gshieldc_ec(m,j-1)=gshieldc_ec(m,j-1)+ &
8155 grad_shield(m,j)*ehbcorr/fac_shield(j)
8157 gshieldc_ec(m,k)=gshieldc_ec(m,k)+ &
8158 grad_shield(m,k)*ehbcorr/fac_shield(k)
8159 gshieldc_ec(m,l)=gshieldc_ec(m,l)+ &
8160 grad_shield(m,l)*ehbcorr/fac_shield(l)
8161 gshieldc_ec(m,k-1)=gshieldc_ec(m,k-1)+ &
8162 grad_shield(m,k)*ehbcorr/fac_shield(k)
8163 gshieldc_ec(m,l-1)=gshieldc_ec(m,l-1)+ &
8164 grad_shield(m,l)*ehbcorr/fac_shield(l)
8170 end function ehbcorr
8172 !-----------------------------------------------------------------------------
8173 subroutine dipole(i,j,jj)
8174 ! implicit real*8 (a-h,o-z)
8175 ! include 'DIMENSIONS'
8176 ! include 'COMMON.IOUNITS'
8177 ! include 'COMMON.CHAIN'
8178 ! include 'COMMON.FFIELD'
8179 ! include 'COMMON.DERIV'
8180 ! include 'COMMON.INTERACT'
8181 ! include 'COMMON.CONTACTS'
8182 ! include 'COMMON.TORSION'
8183 ! include 'COMMON.VAR'
8184 ! include 'COMMON.GEO'
8185 real(kind=8),dimension(2,2) :: dipi,dipj,auxmat
8186 real(kind=8),dimension(2) :: dipderi,dipderj,auxvec
8187 integer :: i,j,jj,iii,jjj,kkk,lll,iti1,itj1
8189 allocate(dip(4,maxconts,nres),dipderg(4,maxconts,nres))
8190 allocate(dipderx(3,5,4,maxconts,nres))
8193 iti1 = itortyp(itype(i+1,1))
8194 if (j.lt.nres-1) then
8195 itj1 = itortyp(itype(j+1,1))
8200 dipi(iii,1)=Ub2(iii,i)
8201 dipderi(iii)=Ub2der(iii,i)
8202 dipi(iii,2)=b1(iii,iti1)
8203 dipj(iii,1)=Ub2(iii,j)
8204 dipderj(iii)=Ub2der(iii,j)
8205 dipj(iii,2)=b1(iii,itj1)
8209 call matvec2(a_chuj(1,1,jj,i),dipj(1,iii),auxvec(1))
8212 dip(kkk,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
8219 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),dipj(1,iii),&
8223 dipderx(lll,kkk,mmm,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
8228 call transpose2(a_chuj(1,1,jj,i),auxmat(1,1))
8229 call matvec2(auxmat(1,1),dipderi(1),auxvec(1))
8231 dipderg(iii,jj,i)=scalar2(auxvec(1),dipj(1,iii))
8233 call matvec2(a_chuj(1,1,jj,i),dipderj(1),auxvec(1))
8235 dipderg(iii+2,jj,i)=scalar2(auxvec(1),dipi(1,iii))
8238 end subroutine dipole
8240 !-----------------------------------------------------------------------------
8241 subroutine calc_eello(i,j,k,l,jj,kk)
8243 ! This subroutine computes matrices and vectors needed to calculate
8244 ! the fourth-, fifth-, and sixth-order local-electrostatic terms.
8247 ! implicit real*8 (a-h,o-z)
8248 ! include 'DIMENSIONS'
8249 ! include 'COMMON.IOUNITS'
8250 ! include 'COMMON.CHAIN'
8251 ! include 'COMMON.DERIV'
8252 ! include 'COMMON.INTERACT'
8253 ! include 'COMMON.CONTACTS'
8254 ! include 'COMMON.TORSION'
8255 ! include 'COMMON.VAR'
8256 ! include 'COMMON.GEO'
8257 ! include 'COMMON.FFIELD'
8258 real(kind=8),dimension(2,2) :: aa1,aa2,aa1t,aa2t,auxmat
8259 real(kind=8),dimension(2,2,3,5) :: aa1tder,aa2tder
8260 integer :: i,j,k,l,jj,kk,iii,jjj,kkk,lll,iti,itk1,itj,itl,itl1,&
8263 !el common /kutas/ lprn
8264 !d write (iout,*) 'calc_eello: i=',i,' j=',j,' k=',k,' l=',l,
8265 !d & ' jj=',jj,' kk=',kk
8266 !d if (i.ne.2 .or. j.ne.4 .or. k.ne.3 .or. l.ne.5) return
8267 !d write (iout,*) "a_chujij",((a_chuj(iii,jjj,jj,i),iii=1,2),jjj=1,2)
8268 !d write (iout,*) "a_chujkl",((a_chuj(iii,jjj,kk,k),iii=1,2),jjj=1,2)
8271 aa1(iii,jjj)=a_chuj(iii,jjj,jj,i)
8272 aa2(iii,jjj)=a_chuj(iii,jjj,kk,k)
8275 call transpose2(aa1(1,1),aa1t(1,1))
8276 call transpose2(aa2(1,1),aa2t(1,1))
8279 call transpose2(a_chuj_der(1,1,lll,kkk,jj,i),&
8280 aa1tder(1,1,lll,kkk))
8281 call transpose2(a_chuj_der(1,1,lll,kkk,kk,k),&
8282 aa2tder(1,1,lll,kkk))
8286 ! parallel orientation of the two CA-CA-CA frames.
8288 iti=itortyp(itype(i,1))
8292 itk1=itortyp(itype(k+1,1))
8293 itj=itortyp(itype(j,1))
8294 if (l.lt.nres-1) then
8295 itl1=itortyp(itype(l+1,1))
8299 ! A1 kernel(j+1) A2T
8301 !d write (iout,'(3f10.5,5x,3f10.5)')
8302 !d & (EUg(iii,jjj,k),jjj=1,2),(EUg(iii,jjj,l),jjj=1,2)
8304 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8305 aa2tder(1,1,1,1),1,.false.,EUg(1,1,l),EUgder(1,1,l),&
8306 AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
8307 ! Following matrices are needed only for 6-th order cumulants
8308 IF (wcorr6.gt.0.0d0) THEN
8309 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8310 aa2tder(1,1,1,1),1,.false.,EUgC(1,1,l),EUgCder(1,1,l),&
8311 AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
8312 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8313 aa2tder(1,1,1,1),2,.false.,Ug2DtEUg(1,1,l),&
8314 Ug2DtEUgder(1,1,1,l),ADtEA(1,1,1),ADtEAderg(1,1,1,1),&
8315 ADtEAderx(1,1,1,1,1,1))
8317 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8318 aa2tder(1,1,1,1),2,.false.,DtUg2EUg(1,1,l),&
8319 DtUg2EUgder(1,1,1,l),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),&
8320 ADtEA1derx(1,1,1,1,1,1))
8322 ! End 6-th order cumulants
8325 !d write (2,*) 'In calc_eello6'
8327 !d write (2,*) 'iii=',iii
8329 !d write (2,*) 'kkk=',kkk
8331 !d write (2,'(3(2f10.5),5x)')
8332 !d & ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
8337 call transpose2(EUgder(1,1,k),auxmat(1,1))
8338 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
8339 call transpose2(EUg(1,1,k),auxmat(1,1))
8340 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
8341 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
8345 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),&
8346 EAEAderx(1,1,lll,kkk,iii,1))
8350 ! A1T kernel(i+1) A2
8351 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
8352 a_chuj_der(1,1,1,1,kk,k),1,.false.,EUg(1,1,k),EUgder(1,1,k),&
8353 AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
8354 ! Following matrices are needed only for 6-th order cumulants
8355 IF (wcorr6.gt.0.0d0) THEN
8356 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
8357 a_chuj_der(1,1,1,1,kk,k),1,.false.,EUgC(1,1,k),EUgCder(1,1,k),&
8358 AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
8359 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
8360 a_chuj_der(1,1,1,1,kk,k),2,.false.,Ug2DtEUg(1,1,k),&
8361 Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),&
8362 ADtEAderx(1,1,1,1,1,2))
8363 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
8364 a_chuj_der(1,1,1,1,kk,k),2,.false.,DtUg2EUg(1,1,k),&
8365 DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),&
8366 ADtEA1derx(1,1,1,1,1,2))
8368 ! End 6-th order cumulants
8369 call transpose2(EUgder(1,1,l),auxmat(1,1))
8370 call matmat2(auxmat(1,1),AEA(1,1,2),EAEAderg(1,1,1,2))
8371 call transpose2(EUg(1,1,l),auxmat(1,1))
8372 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
8373 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
8377 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
8378 EAEAderx(1,1,lll,kkk,iii,2))
8383 ! Calculate the vectors and their derivatives in virtual-bond dihedral angles.
8384 ! They are needed only when the fifth- or the sixth-order cumulants are
8386 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) THEN
8387 call transpose2(AEA(1,1,1),auxmat(1,1))
8388 call matvec2(auxmat(1,1),b1(1,iti),AEAb1(1,1,1))
8389 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
8390 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
8391 call transpose2(AEAderg(1,1,1),auxmat(1,1))
8392 call matvec2(auxmat(1,1),b1(1,iti),AEAb1derg(1,1,1))
8393 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
8394 call matvec2(AEA(1,1,1),b1(1,itk1),AEAb1(1,2,1))
8395 call matvec2(AEAderg(1,1,1),b1(1,itk1),AEAb1derg(1,2,1))
8396 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
8397 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
8398 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
8399 call transpose2(AEA(1,1,2),auxmat(1,1))
8400 call matvec2(auxmat(1,1),b1(1,itj),AEAb1(1,1,2))
8401 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2(1,1,2))
8402 call matvec2(auxmat(1,1),Ub2der(1,j),AEAb2derg(1,2,1,2))
8403 call transpose2(AEAderg(1,1,2),auxmat(1,1))
8404 call matvec2(auxmat(1,1),b1(1,itj),AEAb1derg(1,1,2))
8405 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2derg(1,1,1,2))
8406 call matvec2(AEA(1,1,2),b1(1,itl1),AEAb1(1,2,2))
8407 call matvec2(AEAderg(1,1,2),b1(1,itl1),AEAb1derg(1,2,2))
8408 call matvec2(AEA(1,1,2),Ub2(1,l+1),AEAb2(1,2,2))
8409 call matvec2(AEAderg(1,1,2),Ub2(1,l+1),AEAb2derg(1,1,2,2))
8410 call matvec2(AEA(1,1,2),Ub2der(1,l+1),AEAb2derg(1,2,2,2))
8411 ! Calculate the Cartesian derivatives of the vectors.
8415 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
8416 call matvec2(auxmat(1,1),b1(1,iti),&
8417 AEAb1derx(1,lll,kkk,iii,1,1))
8418 call matvec2(auxmat(1,1),Ub2(1,i),&
8419 AEAb2derx(1,lll,kkk,iii,1,1))
8420 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,itk1),&
8421 AEAb1derx(1,lll,kkk,iii,2,1))
8422 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),&
8423 AEAb2derx(1,lll,kkk,iii,2,1))
8424 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
8425 call matvec2(auxmat(1,1),b1(1,itj),&
8426 AEAb1derx(1,lll,kkk,iii,1,2))
8427 call matvec2(auxmat(1,1),Ub2(1,j),&
8428 AEAb2derx(1,lll,kkk,iii,1,2))
8429 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,itl1),&
8430 AEAb1derx(1,lll,kkk,iii,2,2))
8431 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,l+1),&
8432 AEAb2derx(1,lll,kkk,iii,2,2))
8439 ! Antiparallel orientation of the two CA-CA-CA frames.
8441 iti=itortyp(itype(i,1))
8445 itk1=itortyp(itype(k+1,1))
8446 itl=itortyp(itype(l,1))
8447 itj=itortyp(itype(j,1))
8448 if (j.lt.nres-1) then
8449 itj1=itortyp(itype(j+1,1))
8453 ! A2 kernel(j-1)T A1T
8454 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8455 aa2tder(1,1,1,1),1,.true.,EUg(1,1,j),EUgder(1,1,j),&
8456 AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
8457 ! Following matrices are needed only for 6-th order cumulants
8458 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and. &
8459 j.eq.i+4 .and. l.eq.i+3)) THEN
8460 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8461 aa2tder(1,1,1,1),1,.true.,EUgC(1,1,j),EUgCder(1,1,j),&
8462 AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
8463 call kernel(aa2(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8464 aa2tder(1,1,1,1),2,.true.,Ug2DtEUg(1,1,j),&
8465 Ug2DtEUgder(1,1,1,j),ADtEA(1,1,1),ADtEAderg(1,1,1,1),&
8466 ADtEAderx(1,1,1,1,1,1))
8467 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8468 aa2tder(1,1,1,1),2,.true.,DtUg2EUg(1,1,j),&
8469 DtUg2EUgder(1,1,1,j),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),&
8470 ADtEA1derx(1,1,1,1,1,1))
8472 ! End 6-th order cumulants
8473 call transpose2(EUgder(1,1,k),auxmat(1,1))
8474 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
8475 call transpose2(EUg(1,1,k),auxmat(1,1))
8476 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
8477 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
8481 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),&
8482 EAEAderx(1,1,lll,kkk,iii,1))
8486 ! A2T kernel(i+1)T A1
8487 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
8488 a_chuj_der(1,1,1,1,jj,i),1,.true.,EUg(1,1,k),EUgder(1,1,k),&
8489 AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
8490 ! Following matrices are needed only for 6-th order cumulants
8491 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and. &
8492 j.eq.i+4 .and. l.eq.i+3)) THEN
8493 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
8494 a_chuj_der(1,1,1,1,jj,i),1,.true.,EUgC(1,1,k),EUgCder(1,1,k),&
8495 AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
8496 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
8497 a_chuj_der(1,1,1,1,jj,i),2,.true.,Ug2DtEUg(1,1,k),&
8498 Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),&
8499 ADtEAderx(1,1,1,1,1,2))
8500 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
8501 a_chuj_der(1,1,1,1,jj,i),2,.true.,DtUg2EUg(1,1,k),&
8502 DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),&
8503 ADtEA1derx(1,1,1,1,1,2))
8505 ! End 6-th order cumulants
8506 call transpose2(EUgder(1,1,j),auxmat(1,1))
8507 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,2,2))
8508 call transpose2(EUg(1,1,j),auxmat(1,1))
8509 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
8510 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
8514 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
8515 EAEAderx(1,1,lll,kkk,iii,2))
8520 ! Calculate the vectors and their derivatives in virtual-bond dihedral angles.
8521 ! They are needed only when the fifth- or the sixth-order cumulants are
8523 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 .or. &
8524 (wturn6.gt.0.0d0 .and. j.eq.i+4 .and. l.eq.i+3)) THEN
8525 call transpose2(AEA(1,1,1),auxmat(1,1))
8526 call matvec2(auxmat(1,1),b1(1,iti),AEAb1(1,1,1))
8527 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
8528 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
8529 call transpose2(AEAderg(1,1,1),auxmat(1,1))
8530 call matvec2(auxmat(1,1),b1(1,iti),AEAb1derg(1,1,1))
8531 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
8532 call matvec2(AEA(1,1,1),b1(1,itk1),AEAb1(1,2,1))
8533 call matvec2(AEAderg(1,1,1),b1(1,itk1),AEAb1derg(1,2,1))
8534 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
8535 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
8536 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
8537 call transpose2(AEA(1,1,2),auxmat(1,1))
8538 call matvec2(auxmat(1,1),b1(1,itj1),AEAb1(1,1,2))
8539 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2(1,1,2))
8540 call matvec2(auxmat(1,1),Ub2der(1,l),AEAb2derg(1,2,1,2))
8541 call transpose2(AEAderg(1,1,2),auxmat(1,1))
8542 call matvec2(auxmat(1,1),b1(1,itl),AEAb1(1,1,2))
8543 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2derg(1,1,1,2))
8544 call matvec2(AEA(1,1,2),b1(1,itj1),AEAb1(1,2,2))
8545 call matvec2(AEAderg(1,1,2),b1(1,itj1),AEAb1derg(1,2,2))
8546 call matvec2(AEA(1,1,2),Ub2(1,j),AEAb2(1,2,2))
8547 call matvec2(AEAderg(1,1,2),Ub2(1,j),AEAb2derg(1,1,2,2))
8548 call matvec2(AEA(1,1,2),Ub2der(1,j),AEAb2derg(1,2,2,2))
8549 ! Calculate the Cartesian derivatives of the vectors.
8553 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
8554 call matvec2(auxmat(1,1),b1(1,iti),&
8555 AEAb1derx(1,lll,kkk,iii,1,1))
8556 call matvec2(auxmat(1,1),Ub2(1,i),&
8557 AEAb2derx(1,lll,kkk,iii,1,1))
8558 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,itk1),&
8559 AEAb1derx(1,lll,kkk,iii,2,1))
8560 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),&
8561 AEAb2derx(1,lll,kkk,iii,2,1))
8562 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
8563 call matvec2(auxmat(1,1),b1(1,itl),&
8564 AEAb1derx(1,lll,kkk,iii,1,2))
8565 call matvec2(auxmat(1,1),Ub2(1,l),&
8566 AEAb2derx(1,lll,kkk,iii,1,2))
8567 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,itj1),&
8568 AEAb1derx(1,lll,kkk,iii,2,2))
8569 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,j),&
8570 AEAb2derx(1,lll,kkk,iii,2,2))
8578 end subroutine calc_eello
8579 !-----------------------------------------------------------------------------
8580 subroutine kernel(aa1,aa2t,aa1derx,aa2tderx,nderg,transp,KK,KKderg,AKA,AKAderg,AKAderx)
8585 real(kind=8),dimension(2,2) :: aa1,aa2t,KK,AKA
8586 real(kind=8),dimension(2,2,3,5) :: aa1derx,aa2tderx
8587 real(kind=8),dimension(2,2,3,5,2) :: AKAderx
8588 real(kind=8),dimension(2,2,nderg) :: KKderg,AKAderg
8589 integer :: iii,kkk,lll
8592 !el common /kutas/ lprn
8593 call prodmat3(aa1(1,1),aa2t(1,1),KK(1,1),transp,AKA(1,1))
8595 call prodmat3(aa1(1,1),aa2t(1,1),KKderg(1,1,iii),transp,&
8598 !d if (lprn) write (2,*) 'In kernel'
8600 !d if (lprn) write (2,*) 'kkk=',kkk
8602 call prodmat3(aa1derx(1,1,lll,kkk),aa2t(1,1),&
8603 KK(1,1),transp,AKAderx(1,1,lll,kkk,1))
8605 !d write (2,*) 'lll=',lll
8606 !d write (2,*) 'iii=1'
8608 !d write (2,'(3(2f10.5),5x)')
8609 !d & (AKAderx(jjj,mmm,lll,kkk,1),mmm=1,2)
8612 call prodmat3(aa1(1,1),aa2tderx(1,1,lll,kkk),&
8613 KK(1,1),transp,AKAderx(1,1,lll,kkk,2))
8615 !d write (2,*) 'lll=',lll
8616 !d write (2,*) 'iii=2'
8618 !d write (2,'(3(2f10.5),5x)')
8619 !d & (AKAderx(jjj,mmm,lll,kkk,2),mmm=1,2)
8625 end subroutine kernel
8626 !-----------------------------------------------------------------------------
8627 real(kind=8) function eello4(i,j,k,l,jj,kk)
8628 ! implicit real*8 (a-h,o-z)
8629 ! include 'DIMENSIONS'
8630 ! include 'COMMON.IOUNITS'
8631 ! include 'COMMON.CHAIN'
8632 ! include 'COMMON.DERIV'
8633 ! include 'COMMON.INTERACT'
8634 ! include 'COMMON.CONTACTS'
8635 ! include 'COMMON.TORSION'
8636 ! include 'COMMON.VAR'
8637 ! include 'COMMON.GEO'
8638 real(kind=8),dimension(2,2) :: pizda
8639 real(kind=8),dimension(3) :: ggg1,ggg2
8640 real(kind=8) :: eel4,glongij,glongkl
8641 integer :: i,j,k,l,jj,kk,iii,kkk,lll,j1,j2,l1,l2,ll
8642 !d if (i.ne.1 .or. j.ne.5 .or. k.ne.2 .or.l.ne.4) then
8646 !d print *,'eello4:',i,j,k,l,jj,kk
8647 !d write (2,*) 'i',i,' j',j,' k',k,' l',l
8648 !d call checkint4(i,j,k,l,jj,kk,eel4_num)
8649 !old eij=facont_hb(jj,i)
8650 !old ekl=facont_hb(kk,k)
8652 eel4=-EAEA(1,1,1)-EAEA(2,2,1)
8653 !d eel41=-EAEA(1,1,2)-EAEA(2,2,2)
8654 gcorr_loc(k-1)=gcorr_loc(k-1) &
8655 -ekont*(EAEAderg(1,1,1,1)+EAEAderg(2,2,1,1))
8657 gcorr_loc(l-1)=gcorr_loc(l-1) &
8658 -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
8660 gcorr_loc(j-1)=gcorr_loc(j-1) &
8661 -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
8666 derx(lll,kkk,iii)=-EAEAderx(1,1,lll,kkk,iii,1) &
8667 -EAEAderx(2,2,lll,kkk,iii,1)
8668 !d derx(lll,kkk,iii)=0.0d0
8672 !d gcorr_loc(l-1)=0.0d0
8673 !d gcorr_loc(j-1)=0.0d0
8674 !d gcorr_loc(k-1)=0.0d0
8676 !d write (iout,*)'Contacts have occurred for peptide groups',
8677 !d & i,j,' fcont:',eij,' eij',' and ',k,l,
8678 !d & ' fcont ',ekl,' eel4=',eel4,' eel4_num',16*eel4_num
8679 if (j.lt.nres-1) then
8686 if (l.lt.nres-1) then
8694 !grad ggg1(ll)=eel4*g_contij(ll,1)
8695 !grad ggg2(ll)=eel4*g_contij(ll,2)
8696 glongij=eel4*g_contij(ll,1)+ekont*derx(ll,1,1)
8697 glongkl=eel4*g_contij(ll,2)+ekont*derx(ll,1,2)
8698 !grad ghalf=0.5d0*ggg1(ll)
8699 gradcorr(ll,i)=gradcorr(ll,i)+ekont*derx(ll,2,1)
8700 gradcorr(ll,i+1)=gradcorr(ll,i+1)+ekont*derx(ll,3,1)
8701 gradcorr(ll,j)=gradcorr(ll,j)+ekont*derx(ll,4,1)
8702 gradcorr(ll,j1)=gradcorr(ll,j1)+ekont*derx(ll,5,1)
8703 gradcorr_long(ll,j)=gradcorr_long(ll,j)+glongij
8704 gradcorr_long(ll,i)=gradcorr_long(ll,i)-glongij
8705 !grad ghalf=0.5d0*ggg2(ll)
8706 gradcorr(ll,k)=gradcorr(ll,k)+ekont*derx(ll,2,2)
8707 gradcorr(ll,k+1)=gradcorr(ll,k+1)+ekont*derx(ll,3,2)
8708 gradcorr(ll,l)=gradcorr(ll,l)+ekont*derx(ll,4,2)
8709 gradcorr(ll,l1)=gradcorr(ll,l1)+ekont*derx(ll,5,2)
8710 gradcorr_long(ll,l)=gradcorr_long(ll,l)+glongkl
8711 gradcorr_long(ll,k)=gradcorr_long(ll,k)-glongkl
8715 !grad gradcorr(ll,m)=gradcorr(ll,m)+ggg1(ll)
8720 !grad gradcorr(ll,m)=gradcorr(ll,m)+ggg2(ll)
8725 !grad gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,1)
8730 !grad gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,2)
8734 !d write (2,*) iii,gcorr_loc(iii)
8737 !d write (2,*) 'ekont',ekont
8738 !d write (iout,*) 'eello4',ekont*eel4
8741 !-----------------------------------------------------------------------------
8742 real(kind=8) function eello5(i,j,k,l,jj,kk)
8743 ! implicit real*8 (a-h,o-z)
8744 ! include 'DIMENSIONS'
8745 ! include 'COMMON.IOUNITS'
8746 ! include 'COMMON.CHAIN'
8747 ! include 'COMMON.DERIV'
8748 ! include 'COMMON.INTERACT'
8749 ! include 'COMMON.CONTACTS'
8750 ! include 'COMMON.TORSION'
8751 ! include 'COMMON.VAR'
8752 ! include 'COMMON.GEO'
8753 real(kind=8),dimension(2,2) :: pizda,auxmat,auxmat1
8754 real(kind=8),dimension(2) :: vv
8755 real(kind=8),dimension(3) :: ggg1,ggg2
8756 real(kind=8) :: eello5_1,eello5_2,eello5_3,eello5_4,eel5
8757 real(kind=8) :: gradcorr5ij,gradcorr5kl,ghalf
8758 integer :: i,j,k,l,jj,kk,itk,itl,itj,iii,kkk,lll,j1,j2,l1,l2,ll
8759 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8764 ! /l\ / \ \ / \ / \ / C
8765 ! / \ / \ \ / \ / \ / C
8766 ! j| o |l1 | o | o| o | | o |o C
8767 ! \ |/k\| |/ \| / |/ \| |/ \| C
8768 ! \i/ \ / \ / / \ / \ C
8770 ! (I) (II) (III) (IV) C
8772 ! eello5_1 eello5_2 eello5_3 eello5_4 C
8774 ! Antiparallel chains C
8777 ! /j\ / \ \ / \ / \ / C
8778 ! / \ / \ \ / \ / \ / C
8779 ! j1| o |l | o | o| o | | o |o C
8780 ! \ |/k\| |/ \| / |/ \| |/ \| C
8781 ! \i/ \ / \ / / \ / \ C
8783 ! (I) (II) (III) (IV) C
8785 ! eello5_1 eello5_2 eello5_3 eello5_4 C
8787 ! o denotes a local interaction, vertical lines an electrostatic interaction. C
8789 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8790 !d if (i.ne.2 .or. j.ne.6 .or. k.ne.3 .or. l.ne.5) then
8795 !d & 'EELLO5: Contacts have occurred for peptide groups',i,j,
8797 itk=itortyp(itype(k,1))
8798 itl=itortyp(itype(l,1))
8799 itj=itortyp(itype(j,1))
8804 !d call checkint5(i,j,k,l,jj,kk,eel5_1_num,eel5_2_num,
8805 !d & eel5_3_num,eel5_4_num)
8809 derx(lll,kkk,iii)=0.0d0
8813 !d eij=facont_hb(jj,i)
8814 !d ekl=facont_hb(kk,k)
8816 !d write (iout,*)'Contacts have occurred for peptide groups',
8817 !d & i,j,' fcont:',eij,' eij',' and ',k,l
8819 ! Contribution from the graph I.
8820 !d write (2,*) 'AEA ',AEA(1,1,1),AEA(2,1,1),AEA(1,2,1),AEA(2,2,1)
8821 !d write (2,*) 'AEAb2',AEAb2(1,1,1),AEAb2(2,1,1)
8822 call transpose2(EUg(1,1,k),auxmat(1,1))
8823 call matmat2(AEA(1,1,1),auxmat(1,1),pizda(1,1))
8824 vv(1)=pizda(1,1)-pizda(2,2)
8825 vv(2)=pizda(1,2)+pizda(2,1)
8826 eello5_1=scalar2(AEAb2(1,1,1),Ub2(1,k)) &
8827 +0.5d0*scalar2(vv(1),Dtobr2(1,i))
8828 ! Explicit gradient in virtual-dihedral angles.
8829 if (i.gt.1) g_corr5_loc(i-1)=g_corr5_loc(i-1) &
8830 +ekont*(scalar2(AEAb2derg(1,2,1,1),Ub2(1,k)) &
8831 +0.5d0*scalar2(vv(1),Dtobr2der(1,i)))
8832 call transpose2(EUgder(1,1,k),auxmat1(1,1))
8833 call matmat2(AEA(1,1,1),auxmat1(1,1),pizda(1,1))
8834 vv(1)=pizda(1,1)-pizda(2,2)
8835 vv(2)=pizda(1,2)+pizda(2,1)
8836 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
8837 +ekont*(scalar2(AEAb2(1,1,1),Ub2der(1,k)) &
8838 +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
8839 call matmat2(AEAderg(1,1,1),auxmat(1,1),pizda(1,1))
8840 vv(1)=pizda(1,1)-pizda(2,2)
8841 vv(2)=pizda(1,2)+pizda(2,1)
8843 if (l.lt.nres-1) g_corr5_loc(l-1)=g_corr5_loc(l-1) &
8844 +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k)) &
8845 +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
8847 if (j.lt.nres-1) g_corr5_loc(j-1)=g_corr5_loc(j-1) &
8848 +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k)) &
8849 +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
8851 ! Cartesian gradient
8855 call matmat2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1),&
8857 vv(1)=pizda(1,1)-pizda(2,2)
8858 vv(2)=pizda(1,2)+pizda(2,1)
8859 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
8860 +scalar2(AEAb2derx(1,lll,kkk,iii,1,1),Ub2(1,k)) &
8861 +0.5d0*scalar2(vv(1),Dtobr2(1,i))
8867 ! Contribution from graph II
8868 call transpose2(EE(1,1,itk),auxmat(1,1))
8869 call matmat2(auxmat(1,1),AEA(1,1,1),pizda(1,1))
8870 vv(1)=pizda(1,1)+pizda(2,2)
8871 vv(2)=pizda(2,1)-pizda(1,2)
8872 eello5_2=scalar2(AEAb1(1,2,1),b1(1,itk)) &
8873 -0.5d0*scalar2(vv(1),Ctobr(1,k))
8874 ! Explicit gradient in virtual-dihedral angles.
8875 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
8876 -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,k))
8877 call matmat2(auxmat(1,1),AEAderg(1,1,1),pizda(1,1))
8878 vv(1)=pizda(1,1)+pizda(2,2)
8879 vv(2)=pizda(2,1)-pizda(1,2)
8881 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
8882 +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,itk)) &
8883 -0.5d0*scalar2(vv(1),Ctobr(1,k)))
8885 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
8886 +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,itk)) &
8887 -0.5d0*scalar2(vv(1),Ctobr(1,k)))
8889 ! Cartesian gradient
8893 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),&
8895 vv(1)=pizda(1,1)+pizda(2,2)
8896 vv(2)=pizda(2,1)-pizda(1,2)
8897 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
8898 +scalar2(AEAb1derx(1,lll,kkk,iii,2,1),b1(1,itk)) &
8899 -0.5d0*scalar2(vv(1),Ctobr(1,k))
8907 ! Parallel orientation
8908 ! Contribution from graph III
8909 call transpose2(EUg(1,1,l),auxmat(1,1))
8910 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
8911 vv(1)=pizda(1,1)-pizda(2,2)
8912 vv(2)=pizda(1,2)+pizda(2,1)
8913 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,l)) &
8914 +0.5d0*scalar2(vv(1),Dtobr2(1,j))
8915 ! Explicit gradient in virtual-dihedral angles.
8916 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
8917 +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,l)) &
8918 +0.5d0*scalar2(vv(1),Dtobr2der(1,j)))
8919 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
8920 vv(1)=pizda(1,1)-pizda(2,2)
8921 vv(2)=pizda(1,2)+pizda(2,1)
8922 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
8923 +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,l)) &
8924 +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
8925 call transpose2(EUgder(1,1,l),auxmat1(1,1))
8926 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
8927 vv(1)=pizda(1,1)-pizda(2,2)
8928 vv(2)=pizda(1,2)+pizda(2,1)
8929 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
8930 +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,l)) &
8931 +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
8932 ! Cartesian gradient
8936 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),&
8938 vv(1)=pizda(1,1)-pizda(2,2)
8939 vv(2)=pizda(1,2)+pizda(2,1)
8940 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
8941 +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,l)) &
8942 +0.5d0*scalar2(vv(1),Dtobr2(1,j))
8947 ! Contribution from graph IV
8949 call transpose2(EE(1,1,itl),auxmat(1,1))
8950 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
8951 vv(1)=pizda(1,1)+pizda(2,2)
8952 vv(2)=pizda(2,1)-pizda(1,2)
8953 eello5_4=scalar2(AEAb1(1,2,2),b1(1,itl)) &
8954 -0.5d0*scalar2(vv(1),Ctobr(1,l))
8955 ! Explicit gradient in virtual-dihedral angles.
8956 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
8957 -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,l))
8958 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
8959 vv(1)=pizda(1,1)+pizda(2,2)
8960 vv(2)=pizda(2,1)-pizda(1,2)
8961 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
8962 +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,itl)) &
8963 -0.5d0*scalar2(vv(1),Ctobr(1,l)))
8964 ! Cartesian gradient
8968 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
8970 vv(1)=pizda(1,1)+pizda(2,2)
8971 vv(2)=pizda(2,1)-pizda(1,2)
8972 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
8973 +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,itl)) &
8974 -0.5d0*scalar2(vv(1),Ctobr(1,l))
8979 ! Antiparallel orientation
8980 ! Contribution from graph III
8982 call transpose2(EUg(1,1,j),auxmat(1,1))
8983 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
8984 vv(1)=pizda(1,1)-pizda(2,2)
8985 vv(2)=pizda(1,2)+pizda(2,1)
8986 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,j)) &
8987 +0.5d0*scalar2(vv(1),Dtobr2(1,l))
8988 ! Explicit gradient in virtual-dihedral angles.
8989 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
8990 +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,j)) &
8991 +0.5d0*scalar2(vv(1),Dtobr2der(1,l)))
8992 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
8993 vv(1)=pizda(1,1)-pizda(2,2)
8994 vv(2)=pizda(1,2)+pizda(2,1)
8995 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
8996 +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,j)) &
8997 +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
8998 call transpose2(EUgder(1,1,j),auxmat1(1,1))
8999 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
9000 vv(1)=pizda(1,1)-pizda(2,2)
9001 vv(2)=pizda(1,2)+pizda(2,1)
9002 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
9003 +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,j)) &
9004 +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
9005 ! Cartesian gradient
9009 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),&
9011 vv(1)=pizda(1,1)-pizda(2,2)
9012 vv(2)=pizda(1,2)+pizda(2,1)
9013 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii) &
9014 +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,j)) &
9015 +0.5d0*scalar2(vv(1),Dtobr2(1,l))
9020 ! Contribution from graph IV
9022 call transpose2(EE(1,1,itj),auxmat(1,1))
9023 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
9024 vv(1)=pizda(1,1)+pizda(2,2)
9025 vv(2)=pizda(2,1)-pizda(1,2)
9026 eello5_4=scalar2(AEAb1(1,2,2),b1(1,itj)) &
9027 -0.5d0*scalar2(vv(1),Ctobr(1,j))
9028 ! Explicit gradient in virtual-dihedral angles.
9029 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
9030 -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,j))
9031 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
9032 vv(1)=pizda(1,1)+pizda(2,2)
9033 vv(2)=pizda(2,1)-pizda(1,2)
9034 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
9035 +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,itj)) &
9036 -0.5d0*scalar2(vv(1),Ctobr(1,j)))
9037 ! Cartesian gradient
9041 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
9043 vv(1)=pizda(1,1)+pizda(2,2)
9044 vv(2)=pizda(2,1)-pizda(1,2)
9045 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii) &
9046 +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,itj)) &
9047 -0.5d0*scalar2(vv(1),Ctobr(1,j))
9053 eel5=eello5_1+eello5_2+eello5_3+eello5_4
9054 !d if (i.eq.2 .and. j.eq.8 .and. k.eq.3 .and. l.eq.7) then
9055 !d write (2,*) 'ijkl',i,j,k,l
9056 !d write (2,*) 'eello5_1',eello5_1,' eello5_2',eello5_2,
9057 !d & ' eello5_3',eello5_3,' eello5_4',eello5_4
9059 !d write(iout,*) 'eello5_1',eello5_1,' eel5_1_num',16*eel5_1_num
9060 !d write(iout,*) 'eello5_2',eello5_2,' eel5_2_num',16*eel5_2_num
9061 !d write(iout,*) 'eello5_3',eello5_3,' eel5_3_num',16*eel5_3_num
9062 !d write(iout,*) 'eello5_4',eello5_4,' eel5_4_num',16*eel5_4_num
9063 if (j.lt.nres-1) then
9070 if (l.lt.nres-1) then
9080 !d write (2,*) 'eij',eij,' ekl',ekl,' ekont',ekont
9081 ! 2/11/08 AL Gradients over DC's connecting interacting sites will be
9082 ! summed up outside the subrouine as for the other subroutines
9083 ! handling long-range interactions. The old code is commented out
9084 ! with "cgrad" to keep track of changes.
9086 !grad ggg1(ll)=eel5*g_contij(ll,1)
9087 !grad ggg2(ll)=eel5*g_contij(ll,2)
9088 gradcorr5ij=eel5*g_contij(ll,1)+ekont*derx(ll,1,1)
9089 gradcorr5kl=eel5*g_contij(ll,2)+ekont*derx(ll,1,2)
9090 ! write (iout,'(a,3i3,a,5f8.3,2i3,a,5f8.3,a,f8.3)')
9091 ! & "ecorr5",ll,i,j," derx",derx(ll,2,1),derx(ll,3,1),derx(ll,4,1),
9092 ! & derx(ll,5,1),k,l," derx",derx(ll,2,2),derx(ll,3,2),
9093 ! & derx(ll,4,2),derx(ll,5,2)," ekont",ekont
9094 ! write (iout,'(a,3i3,a,3f8.3,2i3,a,3f8.3)')
9095 ! & "ecorr5",ll,i,j," gradcorr5",g_contij(ll,1),derx(ll,1,1),
9097 ! & k,l," gradcorr5",g_contij(ll,2),derx(ll,1,2),gradcorr5kl
9098 !old ghalf=0.5d0*eel5*ekl*gacont_hbr(ll,jj,i)
9099 !grad ghalf=0.5d0*ggg1(ll)
9101 gradcorr5(ll,i)=gradcorr5(ll,i)+ekont*derx(ll,2,1)
9102 gradcorr5(ll,i+1)=gradcorr5(ll,i+1)+ekont*derx(ll,3,1)
9103 gradcorr5(ll,j)=gradcorr5(ll,j)+ekont*derx(ll,4,1)
9104 gradcorr5(ll,j1)=gradcorr5(ll,j1)+ekont*derx(ll,5,1)
9105 gradcorr5_long(ll,j)=gradcorr5_long(ll,j)+gradcorr5ij
9106 gradcorr5_long(ll,i)=gradcorr5_long(ll,i)-gradcorr5ij
9107 !old ghalf=0.5d0*eel5*eij*gacont_hbr(ll,kk,k)
9108 !grad ghalf=0.5d0*ggg2(ll)
9110 gradcorr5(ll,k)=gradcorr5(ll,k)+ghalf+ekont*derx(ll,2,2)
9111 gradcorr5(ll,k+1)=gradcorr5(ll,k+1)+ekont*derx(ll,3,2)
9112 gradcorr5(ll,l)=gradcorr5(ll,l)+ghalf+ekont*derx(ll,4,2)
9113 gradcorr5(ll,l1)=gradcorr5(ll,l1)+ekont*derx(ll,5,2)
9114 gradcorr5_long(ll,l)=gradcorr5_long(ll,l)+gradcorr5kl
9115 gradcorr5_long(ll,k)=gradcorr5_long(ll,k)-gradcorr5kl
9120 !old gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*ekl*gacont_hbr(ll,jj,i)
9121 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ggg1(ll)
9126 !old gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*eij*gacont_hbr(ll,kk,k)
9127 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ggg2(ll)
9133 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,1)
9138 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,2)
9142 !d write (2,*) iii,g_corr5_loc(iii)
9145 !d write (2,*) 'ekont',ekont
9146 !d write (iout,*) 'eello5',ekont*eel5
9149 !-----------------------------------------------------------------------------
9150 real(kind=8) function eello6(i,j,k,l,jj,kk)
9151 ! implicit real*8 (a-h,o-z)
9152 ! include 'DIMENSIONS'
9153 ! include 'COMMON.IOUNITS'
9154 ! include 'COMMON.CHAIN'
9155 ! include 'COMMON.DERIV'
9156 ! include 'COMMON.INTERACT'
9157 ! include 'COMMON.CONTACTS'
9158 ! include 'COMMON.TORSION'
9159 ! include 'COMMON.VAR'
9160 ! include 'COMMON.GEO'
9161 ! include 'COMMON.FFIELD'
9162 real(kind=8),dimension(3) :: ggg1,ggg2
9163 real(kind=8) :: eello6_1,eello6_2,eello6_3,eello6_4,eello6_5,&
9165 real(kind=8) :: gradcorr6ij,gradcorr6kl
9166 integer :: i,j,k,l,jj,kk,iii,kkk,lll,j1,j2,l1,l2,ll
9167 !d if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
9172 !d & 'EELLO6: Contacts have occurred for peptide groups',i,j,
9180 !d call checkint6(i,j,k,l,jj,kk,eel6_1_num,eel6_2_num,
9181 !d & eel6_3_num,eel6_4_num,eel6_5_num,eel6_6_num)
9185 derx(lll,kkk,iii)=0.0d0
9189 !d eij=facont_hb(jj,i)
9190 !d ekl=facont_hb(kk,k)
9196 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
9197 eello6_2=eello6_graph1(j,i,l,k,2,.false.)
9198 eello6_3=eello6_graph2(i,j,k,l,jj,kk,.false.)
9199 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
9200 eello6_5=eello6_graph4(j,i,l,k,jj,kk,2,.false.)
9201 eello6_6=eello6_graph3(i,j,k,l,jj,kk,.false.)
9203 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
9204 eello6_2=eello6_graph1(l,k,j,i,2,.true.)
9205 eello6_3=eello6_graph2(i,l,k,j,jj,kk,.true.)
9206 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
9207 if (wturn6.eq.0.0d0 .or. j.ne.i+4) then
9208 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
9212 eello6_6=eello6_graph3(i,l,k,j,jj,kk,.true.)
9214 ! If turn contributions are considered, they will be handled separately.
9215 eel6=eello6_1+eello6_2+eello6_3+eello6_4+eello6_5+eello6_6
9216 !d write(iout,*) 'eello6_1',eello6_1!,' eel6_1_num',16*eel6_1_num
9217 !d write(iout,*) 'eello6_2',eello6_2!,' eel6_2_num',16*eel6_2_num
9218 !d write(iout,*) 'eello6_3',eello6_3!,' eel6_3_num',16*eel6_3_num
9219 !d write(iout,*) 'eello6_4',eello6_4!,' eel6_4_num',16*eel6_4_num
9220 !d write(iout,*) 'eello6_5',eello6_5!,' eel6_5_num',16*eel6_5_num
9221 !d write(iout,*) 'eello6_6',eello6_6!,' eel6_6_num',16*eel6_6_num
9223 if (j.lt.nres-1) then
9230 if (l.lt.nres-1) then
9238 !grad ggg1(ll)=eel6*g_contij(ll,1)
9239 !grad ggg2(ll)=eel6*g_contij(ll,2)
9240 !old ghalf=0.5d0*eel6*ekl*gacont_hbr(ll,jj,i)
9241 !grad ghalf=0.5d0*ggg1(ll)
9243 gradcorr6ij=eel6*g_contij(ll,1)+ekont*derx(ll,1,1)
9244 gradcorr6kl=eel6*g_contij(ll,2)+ekont*derx(ll,1,2)
9245 gradcorr6(ll,i)=gradcorr6(ll,i)+ekont*derx(ll,2,1)
9246 gradcorr6(ll,i+1)=gradcorr6(ll,i+1)+ekont*derx(ll,3,1)
9247 gradcorr6(ll,j)=gradcorr6(ll,j)+ekont*derx(ll,4,1)
9248 gradcorr6(ll,j1)=gradcorr6(ll,j1)+ekont*derx(ll,5,1)
9249 gradcorr6_long(ll,j)=gradcorr6_long(ll,j)+gradcorr6ij
9250 gradcorr6_long(ll,i)=gradcorr6_long(ll,i)-gradcorr6ij
9251 !grad ghalf=0.5d0*ggg2(ll)
9252 !old ghalf=0.5d0*eel6*eij*gacont_hbr(ll,kk,k)
9254 gradcorr6(ll,k)=gradcorr6(ll,k)+ekont*derx(ll,2,2)
9255 gradcorr6(ll,k+1)=gradcorr6(ll,k+1)+ekont*derx(ll,3,2)
9256 gradcorr6(ll,l)=gradcorr6(ll,l)+ekont*derx(ll,4,2)
9257 gradcorr6(ll,l1)=gradcorr6(ll,l1)+ekont*derx(ll,5,2)
9258 gradcorr6_long(ll,l)=gradcorr6_long(ll,l)+gradcorr6kl
9259 gradcorr6_long(ll,k)=gradcorr6_long(ll,k)-gradcorr6kl
9264 !old gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*ekl*gacont_hbr(ll,jj,i)
9265 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ggg1(ll)
9270 !old gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*eij*gacont_hbr(ll,kk,k)
9271 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ggg2(ll)
9277 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,1)
9282 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,2)
9286 !d write (2,*) iii,g_corr6_loc(iii)
9289 !d write (2,*) 'ekont',ekont
9290 !d write (iout,*) 'eello6',ekont*eel6
9293 !-----------------------------------------------------------------------------
9294 real(kind=8) function eello6_graph1(i,j,k,l,imat,swap)
9296 ! implicit real*8 (a-h,o-z)
9297 ! include 'DIMENSIONS'
9298 ! include 'COMMON.IOUNITS'
9299 ! include 'COMMON.CHAIN'
9300 ! include 'COMMON.DERIV'
9301 ! include 'COMMON.INTERACT'
9302 ! include 'COMMON.CONTACTS'
9303 ! include 'COMMON.TORSION'
9304 ! include 'COMMON.VAR'
9305 ! include 'COMMON.GEO'
9306 real(kind=8),dimension(2) :: vv,vv1
9307 real(kind=8),dimension(2,2) :: pizda,auxmat,pizda1
9310 !el common /kutas/ lprn
9311 integer :: i,j,k,l,imat,itk,iii,kkk,lll,ind
9312 real(kind=8) :: s1,s2,s3,s4,s5
9313 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9315 ! Parallel Antiparallel C
9321 ! \ j|/k\| / \ |/k\|l / C
9326 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9327 itk=itortyp(itype(k,1))
9328 s1= scalar2(AEAb1(1,2,imat),CUgb2(1,i))
9329 s2=-scalar2(AEAb2(1,1,imat),Ug2Db1t(1,k))
9330 s3= scalar2(AEAb2(1,1,imat),CUgb2(1,k))
9331 call transpose2(EUgC(1,1,k),auxmat(1,1))
9332 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
9333 vv1(1)=pizda1(1,1)-pizda1(2,2)
9334 vv1(2)=pizda1(1,2)+pizda1(2,1)
9335 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
9336 vv(1)=AEAb1(1,2,imat)*b1(1,itk)-AEAb1(2,2,imat)*b1(2,itk)
9337 vv(2)=AEAb1(1,2,imat)*b1(2,itk)+AEAb1(2,2,imat)*b1(1,itk)
9338 s5=scalar2(vv(1),Dtobr2(1,i))
9339 !d write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4', s4,' s5',s5
9340 eello6_graph1=-0.5d0*(s1+s2+s3+s4+s5)
9341 if (i.gt.1) g_corr6_loc(i-1)=g_corr6_loc(i-1) &
9342 -0.5d0*ekont*(scalar2(AEAb1(1,2,imat),CUgb2der(1,i)) &
9343 -scalar2(AEAb2derg(1,2,1,imat),Ug2Db1t(1,k)) &
9344 +scalar2(AEAb2derg(1,2,1,imat),CUgb2(1,k)) &
9345 +0.5d0*scalar2(vv1(1),Dtobr2der(1,i)) &
9346 +scalar2(vv(1),Dtobr2der(1,i)))
9347 call matmat2(AEAderg(1,1,imat),auxmat(1,1),pizda1(1,1))
9348 vv1(1)=pizda1(1,1)-pizda1(2,2)
9349 vv1(2)=pizda1(1,2)+pizda1(2,1)
9350 vv(1)=AEAb1derg(1,2,imat)*b1(1,itk)-AEAb1derg(2,2,imat)*b1(2,itk)
9351 vv(2)=AEAb1derg(1,2,imat)*b1(2,itk)+AEAb1derg(2,2,imat)*b1(1,itk)
9353 g_corr6_loc(l-1)=g_corr6_loc(l-1) &
9354 +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i)) &
9355 -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k)) &
9356 +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k)) &
9357 +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
9359 g_corr6_loc(j-1)=g_corr6_loc(j-1) &
9360 +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i)) &
9361 -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k)) &
9362 +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k)) &
9363 +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
9365 call transpose2(EUgCder(1,1,k),auxmat(1,1))
9366 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
9367 vv1(1)=pizda1(1,1)-pizda1(2,2)
9368 vv1(2)=pizda1(1,2)+pizda1(2,1)
9369 if (k.gt.1) g_corr6_loc(k-1)=g_corr6_loc(k-1) &
9370 +ekont*(-0.5d0*(-scalar2(AEAb2(1,1,imat),Ug2Db1tder(1,k)) &
9371 +scalar2(AEAb2(1,1,imat),CUgb2der(1,k)) &
9372 +0.5d0*scalar2(vv1(1),Dtobr2(1,i))))
9381 s1= scalar2(AEAb1derx(1,lll,kkk,iii,2,imat),CUgb2(1,i))
9382 s2=-scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),Ug2Db1t(1,k))
9383 s3= scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),CUgb2(1,k))
9384 call transpose2(EUgC(1,1,k),auxmat(1,1))
9385 call matmat2(AEAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),&
9387 vv1(1)=pizda1(1,1)-pizda1(2,2)
9388 vv1(2)=pizda1(1,2)+pizda1(2,1)
9389 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
9390 vv(1)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(1,itk) &
9391 -AEAb1derx(2,lll,kkk,iii,2,imat)*b1(2,itk)
9392 vv(2)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(2,itk) &
9393 +AEAb1derx(2,lll,kkk,iii,2,imat)*b1(1,itk)
9394 s5=scalar2(vv(1),Dtobr2(1,i))
9395 derx(lll,kkk,ind)=derx(lll,kkk,ind)-0.5d0*(s1+s2+s3+s4+s5)
9400 end function eello6_graph1
9401 !-----------------------------------------------------------------------------
9402 real(kind=8) function eello6_graph2(i,j,k,l,jj,kk,swap)
9404 ! implicit real*8 (a-h,o-z)
9405 ! include 'DIMENSIONS'
9406 ! include 'COMMON.IOUNITS'
9407 ! include 'COMMON.CHAIN'
9408 ! include 'COMMON.DERIV'
9409 ! include 'COMMON.INTERACT'
9410 ! include 'COMMON.CONTACTS'
9411 ! include 'COMMON.TORSION'
9412 ! include 'COMMON.VAR'
9413 ! include 'COMMON.GEO'
9415 real(kind=8),dimension(2) :: vv,auxvec,auxvec1,auxvec2
9416 real(kind=8),dimension(2,2) :: pizda,auxmat,auxmat1
9418 !el common /kutas/ lprn
9419 integer :: i,j,k,l,jj,kk,iii,kkk,lll,jjj,mmm
9420 real(kind=8) :: s2,s3,s4
9421 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9423 ! Parallel Antiparallel C
9429 ! \ j|/k\| \ |/k\|l C
9434 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9435 !d write (2,*) 'eello6_graph2: i,',i,' j',j,' k',k,' l',l
9436 ! AL 7/4/01 s1 would occur in the sixth-order moment,
9437 ! but not in a cluster cumulant
9439 s1=dip(1,jj,i)*dip(1,kk,k)
9441 call matvec2(ADtEA1(1,1,1),Ub2(1,k),auxvec(1))
9442 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
9443 call matvec2(ADtEA(1,1,2),Ub2(1,l),auxvec1(1))
9444 s3=-0.5d0*scalar2(Ub2(1,j),auxvec1(1))
9445 call transpose2(EUg(1,1,k),auxmat(1,1))
9446 call matmat2(ADtEA1(1,1,1),auxmat(1,1),pizda(1,1))
9447 vv(1)=pizda(1,1)-pizda(2,2)
9448 vv(2)=pizda(1,2)+pizda(2,1)
9449 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9450 !d write (2,*) 'eello6_graph2:','s1',s1,' s2',s2,' s3',s3,' s4',s4
9452 eello6_graph2=-(s1+s2+s3+s4)
9454 eello6_graph2=-(s2+s3+s4)
9457 ! Derivatives in gamma(i-1)
9460 s1=dipderg(1,jj,i)*dip(1,kk,k)
9462 s2=-0.5d0*scalar2(Ub2der(1,i),auxvec(1))
9463 call matvec2(ADtEAderg(1,1,1,2),Ub2(1,l),auxvec2(1))
9464 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
9465 s4=-0.25d0*scalar2(vv(1),Dtobr2der(1,i))
9467 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
9469 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
9471 ! g_corr6_loc(i-1)=g_corr6_loc(i-1)-s3
9473 ! Derivatives in gamma(k-1)
9475 s1=dip(1,jj,i)*dipderg(1,kk,k)
9477 call matvec2(ADtEA1(1,1,1),Ub2der(1,k),auxvec2(1))
9478 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
9479 call matvec2(ADtEAderg(1,1,2,2),Ub2(1,l),auxvec2(1))
9480 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
9481 call transpose2(EUgder(1,1,k),auxmat1(1,1))
9482 call matmat2(ADtEA1(1,1,1),auxmat1(1,1),pizda(1,1))
9483 vv(1)=pizda(1,1)-pizda(2,2)
9484 vv(2)=pizda(1,2)+pizda(2,1)
9485 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9487 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
9489 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
9491 ! g_corr6_loc(k-1)=g_corr6_loc(k-1)-s3
9492 ! Derivatives in gamma(j-1) or gamma(l-1)
9495 s1=dipderg(3,jj,i)*dip(1,kk,k)
9497 call matvec2(ADtEA1derg(1,1,1,1),Ub2(1,k),auxvec2(1))
9498 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
9499 s3=-0.5d0*scalar2(Ub2der(1,j),auxvec1(1))
9500 call matmat2(ADtEA1derg(1,1,1,1),auxmat(1,1),pizda(1,1))
9501 vv(1)=pizda(1,1)-pizda(2,2)
9502 vv(2)=pizda(1,2)+pizda(2,1)
9503 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9506 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
9508 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
9511 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s3+s4)
9512 ! g_corr6_loc(j-1)=g_corr6_loc(j-1)-s3
9514 ! Derivatives in gamma(l-1) or gamma(j-1)
9517 s1=dip(1,jj,i)*dipderg(3,kk,k)
9519 call matvec2(ADtEA1derg(1,1,2,1),Ub2(1,k),auxvec2(1))
9520 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
9521 call matvec2(ADtEA(1,1,2),Ub2der(1,l),auxvec2(1))
9522 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
9523 call matmat2(ADtEA1derg(1,1,2,1),auxmat(1,1),pizda(1,1))
9524 vv(1)=pizda(1,1)-pizda(2,2)
9525 vv(2)=pizda(1,2)+pizda(2,1)
9526 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9529 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
9531 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
9534 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s3+s4)
9535 ! g_corr6_loc(l-1)=g_corr6_loc(l-1)-s3
9537 ! Cartesian derivatives.
9539 write (2,*) 'In eello6_graph2'
9541 write (2,*) 'iii=',iii
9543 write (2,*) 'kkk=',kkk
9545 write (2,'(3(2f10.5),5x)') &
9546 ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
9556 s1=dipderx(lll,kkk,1,jj,i)*dip(1,kk,k)
9558 s1=dip(1,jj,i)*dipderx(lll,kkk,1,kk,k)
9561 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,1),Ub2(1,k),&
9563 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
9564 call matvec2(ADtEAderx(1,1,lll,kkk,iii,2),Ub2(1,l),&
9566 s3=-0.5d0*scalar2(Ub2(1,j),auxvec(1))
9567 call transpose2(EUg(1,1,k),auxmat(1,1))
9568 call matmat2(ADtEA1derx(1,1,lll,kkk,iii,1),auxmat(1,1),&
9570 vv(1)=pizda(1,1)-pizda(2,2)
9571 vv(2)=pizda(1,2)+pizda(2,1)
9572 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9573 !d write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4',s4
9575 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
9577 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
9580 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
9582 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
9588 end function eello6_graph2
9589 !-----------------------------------------------------------------------------
9590 real(kind=8) function eello6_graph3(i,j,k,l,jj,kk,swap)
9591 ! implicit real*8 (a-h,o-z)
9592 ! include 'DIMENSIONS'
9593 ! include 'COMMON.IOUNITS'
9594 ! include 'COMMON.CHAIN'
9595 ! include 'COMMON.DERIV'
9596 ! include 'COMMON.INTERACT'
9597 ! include 'COMMON.CONTACTS'
9598 ! include 'COMMON.TORSION'
9599 ! include 'COMMON.VAR'
9600 ! include 'COMMON.GEO'
9601 real(kind=8),dimension(2) :: vv,auxvec
9602 real(kind=8),dimension(2,2) :: pizda,auxmat
9604 integer :: i,j,k,l,jj,kk,iti,itj1,itk,itk1,iii,lll,kkk,itl1
9605 real(kind=8) :: s1,s2,s3,s4
9606 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9608 ! Parallel Antiparallel C
9614 ! j|/k\| / |/k\|l / C
9619 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9621 ! 4/7/01 AL Component s1 was removed, because it pertains to the respective
9622 ! energy moment and not to the cluster cumulant.
9623 iti=itortyp(itype(i,1))
9624 if (j.lt.nres-1) then
9625 itj1=itortyp(itype(j+1,1))
9629 itk=itortyp(itype(k,1))
9630 itk1=itortyp(itype(k+1,1))
9631 if (l.lt.nres-1) then
9632 itl1=itortyp(itype(l+1,1))
9637 s1=dip(4,jj,i)*dip(4,kk,k)
9639 call matvec2(AECA(1,1,1),b1(1,itk1),auxvec(1))
9640 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
9641 call matvec2(AECA(1,1,2),b1(1,itl1),auxvec(1))
9642 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
9643 call transpose2(EE(1,1,itk),auxmat(1,1))
9644 call matmat2(auxmat(1,1),AECA(1,1,1),pizda(1,1))
9645 vv(1)=pizda(1,1)+pizda(2,2)
9646 vv(2)=pizda(2,1)-pizda(1,2)
9647 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
9648 !d write (2,*) 'eello6_graph3:','s1',s1,' s2',s2,' s3',s3,' s4',s4,
9649 !d & "sum",-(s2+s3+s4)
9651 eello6_graph3=-(s1+s2+s3+s4)
9653 eello6_graph3=-(s2+s3+s4)
9656 ! Derivatives in gamma(k-1)
9657 call matvec2(AECAderg(1,1,2),b1(1,itl1),auxvec(1))
9658 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
9659 s4=-0.25d0*scalar2(vv(1),Ctobrder(1,k))
9660 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s3+s4)
9661 ! Derivatives in gamma(l-1)
9662 call matvec2(AECAderg(1,1,1),b1(1,itk1),auxvec(1))
9663 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
9664 call matmat2(auxmat(1,1),AECAderg(1,1,1),pizda(1,1))
9665 vv(1)=pizda(1,1)+pizda(2,2)
9666 vv(2)=pizda(2,1)-pizda(1,2)
9667 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
9668 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
9669 ! Cartesian derivatives.
9675 s1=dipderx(lll,kkk,4,jj,i)*dip(4,kk,k)
9677 s1=dip(4,jj,i)*dipderx(lll,kkk,4,kk,k)
9680 call matvec2(AECAderx(1,1,lll,kkk,iii,1),b1(1,itk1),&
9682 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
9683 call matvec2(AECAderx(1,1,lll,kkk,iii,2),b1(1,itl1),&
9685 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
9686 call matmat2(auxmat(1,1),AECAderx(1,1,lll,kkk,iii,1),&
9688 vv(1)=pizda(1,1)+pizda(2,2)
9689 vv(2)=pizda(2,1)-pizda(1,2)
9690 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
9692 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
9694 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
9697 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
9699 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
9701 ! derx(lll,kkk,iii)=derx(lll,kkk,iii)-s4
9706 end function eello6_graph3
9707 !-----------------------------------------------------------------------------
9708 real(kind=8) function eello6_graph4(i,j,k,l,jj,kk,imat,swap)
9709 ! implicit real*8 (a-h,o-z)
9710 ! include 'DIMENSIONS'
9711 ! include 'COMMON.IOUNITS'
9712 ! include 'COMMON.CHAIN'
9713 ! include 'COMMON.DERIV'
9714 ! include 'COMMON.INTERACT'
9715 ! include 'COMMON.CONTACTS'
9716 ! include 'COMMON.TORSION'
9717 ! include 'COMMON.VAR'
9718 ! include 'COMMON.GEO'
9719 ! include 'COMMON.FFIELD'
9720 real(kind=8),dimension(2) :: vv,auxvec,auxvec1
9721 real(kind=8),dimension(2,2) :: pizda,auxmat,auxmat1
9723 integer :: i,j,k,l,jj,kk,imat,iti,itj,itj1,itk,itk1,itl,itl1,&
9725 real(kind=8) :: s1,s2,s3,s4
9726 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9728 ! Parallel Antiparallel C
9734 ! \ j|/k\| \ |/k\|l C
9739 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9741 ! 4/7/01 AL Component s1 was removed, because it pertains to the respective
9742 ! energy moment and not to the cluster cumulant.
9743 !d write (2,*) 'eello_graph4: wturn6',wturn6
9744 iti=itortyp(itype(i,1))
9745 itj=itortyp(itype(j,1))
9746 if (j.lt.nres-1) then
9747 itj1=itortyp(itype(j+1,1))
9751 itk=itortyp(itype(k,1))
9752 if (k.lt.nres-1) then
9753 itk1=itortyp(itype(k+1,1))
9757 itl=itortyp(itype(l,1))
9758 if (l.lt.nres-1) then
9759 itl1=itortyp(itype(l+1,1))
9763 !d write (2,*) 'eello6_graph4:','i',i,' j',j,' k',k,' l',l
9764 !d write (2,*) 'iti',iti,' itj',itj,' itj1',itj1,' itk',itk,
9765 !d & ' itl',itl,' itl1',itl1
9768 s1=dip(3,jj,i)*dip(3,kk,k)
9770 s1=dip(2,jj,j)*dip(2,kk,l)
9773 call matvec2(AECA(1,1,imat),Ub2(1,k),auxvec(1))
9774 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
9776 call matvec2(ADtEA1(1,1,3-imat),b1(1,itj1),auxvec1(1))
9777 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
9779 call matvec2(ADtEA1(1,1,3-imat),b1(1,itl1),auxvec1(1))
9780 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
9782 call transpose2(EUg(1,1,k),auxmat(1,1))
9783 call matmat2(AECA(1,1,imat),auxmat(1,1),pizda(1,1))
9784 vv(1)=pizda(1,1)-pizda(2,2)
9785 vv(2)=pizda(2,1)+pizda(1,2)
9786 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
9787 !d write (2,*) 'eello6_graph4:','s1',s1,' s2',s2,' s3',s3,' s4',s4
9789 eello6_graph4=-(s1+s2+s3+s4)
9791 eello6_graph4=-(s2+s3+s4)
9793 ! Derivatives in gamma(i-1)
9797 s1=dipderg(2,jj,i)*dip(3,kk,k)
9799 s1=dipderg(4,jj,j)*dip(2,kk,l)
9802 s2=0.5d0*scalar2(Ub2der(1,i),auxvec(1))
9804 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,itj1),auxvec1(1))
9805 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
9807 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,itl1),auxvec1(1))
9808 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
9810 s4=0.25d0*scalar2(vv(1),Dtobr2der(1,i))
9811 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
9812 !d write (2,*) 'turn6 derivatives'
9814 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s1+s2+s3+s4)
9816 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s2+s3+s4)
9820 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
9822 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
9826 ! Derivatives in gamma(k-1)
9829 s1=dip(3,jj,i)*dipderg(2,kk,k)
9831 s1=dip(2,jj,j)*dipderg(4,kk,l)
9834 call matvec2(AECA(1,1,imat),Ub2der(1,k),auxvec1(1))
9835 s2=0.5d0*scalar2(Ub2(1,i),auxvec1(1))
9837 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,itj1),auxvec1(1))
9838 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
9840 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,itl1),auxvec1(1))
9841 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
9843 call transpose2(EUgder(1,1,k),auxmat1(1,1))
9844 call matmat2(AECA(1,1,imat),auxmat1(1,1),pizda(1,1))
9845 vv(1)=pizda(1,1)-pizda(2,2)
9846 vv(2)=pizda(2,1)+pizda(1,2)
9847 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
9848 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
9850 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s1+s2+s3+s4)
9852 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s2+s3+s4)
9856 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
9858 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
9861 ! Derivatives in gamma(j-1) or gamma(l-1)
9862 if (l.eq.j+1 .and. l.gt.1) then
9863 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
9864 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
9865 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
9866 vv(1)=pizda(1,1)-pizda(2,2)
9867 vv(2)=pizda(2,1)+pizda(1,2)
9868 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
9869 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
9870 else if (j.gt.1) then
9871 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
9872 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
9873 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
9874 vv(1)=pizda(1,1)-pizda(2,2)
9875 vv(2)=pizda(2,1)+pizda(1,2)
9876 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
9877 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
9878 gel_loc_turn6(j-1)=gel_loc_turn6(j-1)-ekont*(s2+s4)
9880 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s4)
9883 ! Cartesian derivatives.
9890 s1=dipderx(lll,kkk,3,jj,i)*dip(3,kk,k)
9892 s1=dipderx(lll,kkk,2,jj,j)*dip(2,kk,l)
9896 s1=dip(3,jj,i)*dipderx(lll,kkk,3,kk,k)
9898 s1=dip(2,jj,j)*dipderx(lll,kkk,2,kk,l)
9902 call matvec2(AECAderx(1,1,lll,kkk,iii,imat),Ub2(1,k),&
9904 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
9906 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),&
9907 b1(1,itj1),auxvec(1))
9908 s3=-0.5d0*scalar2(b1(1,itj),auxvec(1))
9910 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),&
9911 b1(1,itl1),auxvec(1))
9912 s3=-0.5d0*scalar2(b1(1,itl),auxvec(1))
9914 call matmat2(AECAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),&
9916 vv(1)=pizda(1,1)-pizda(2,2)
9917 vv(2)=pizda(2,1)+pizda(1,2)
9918 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
9920 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
9922 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii) &
9925 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii) &
9928 derx_turn(lll,kkk,iii)=derx_turn(lll,kkk,iii)-s3
9931 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s1+s2+s4)
9933 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s2+s4)
9935 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
9939 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
9941 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
9944 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
9946 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
9953 end function eello6_graph4
9954 !-----------------------------------------------------------------------------
9955 real(kind=8) function eello_turn6(i,jj,kk)
9956 ! implicit real*8 (a-h,o-z)
9957 ! include 'DIMENSIONS'
9958 ! include 'COMMON.IOUNITS'
9959 ! include 'COMMON.CHAIN'
9960 ! include 'COMMON.DERIV'
9961 ! include 'COMMON.INTERACT'
9962 ! include 'COMMON.CONTACTS'
9963 ! include 'COMMON.TORSION'
9964 ! include 'COMMON.VAR'
9965 ! include 'COMMON.GEO'
9966 real(kind=8),dimension(2) :: vtemp1,vtemp2,vtemp3,vtemp4,gvec
9967 real(kind=8),dimension(2,2) :: atemp,auxmat,achuj_temp,gtemp
9968 real(kind=8),dimension(3) :: ggg1,ggg2
9969 real(kind=8),dimension(2) :: vtemp1d,vtemp2d,vtemp3d,vtemp4d,gvecd
9970 real(kind=8),dimension(2,2) :: atempd,auxmatd,achuj_tempd,gtempd
9971 ! 4/7/01 AL Components s1, s8, and s13 were removed, because they pertain to
9972 ! the respective energy moment and not to the cluster cumulant.
9974 integer :: i,jj,kk,j,k,l,iti,itk,itk1,itl,itj,iii,kkk,lll
9975 integer :: j1,j2,l1,l2,ll
9976 real(kind=8) :: s1,s2,s8,s13,s12,eello6_5,eel_turn6
9977 real(kind=8) :: s1d,s8d,s12d,s2d,gturn6ij,gturn6kl
9986 iti=itortyp(itype(i,1))
9987 itk=itortyp(itype(k,1))
9988 itk1=itortyp(itype(k+1,1))
9989 itl=itortyp(itype(l,1))
9990 itj=itortyp(itype(j,1))
9991 !d write (2,*) 'itk',itk,' itk1',itk1,' itl',itl,' itj',itj
9992 !d write (2,*) 'i',i,' k',k,' j',j,' l',l
9993 !d if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
9998 !d & 'EELLO6: Contacts have occurred for peptide groups',i,j,
10000 !d call checkint_turn6(i,jj,kk,eel_turn6_num)
10004 derx_turn(lll,kkk,iii)=0.0d0
10011 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
10013 !d write (2,*) 'eello6_5',eello6_5
10015 call transpose2(AEA(1,1,1),auxmat(1,1))
10016 call matmat2(EUg(1,1,i+1),auxmat(1,1),auxmat(1,1))
10017 ss1=scalar2(Ub2(1,i+2),b1(1,itl))
10018 s1 = (auxmat(1,1)+auxmat(2,2))*ss1
10020 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1(1))
10021 call matvec2(AEA(1,1,1),vtemp1(1),vtemp1(1))
10022 s2 = scalar2(b1(1,itk),vtemp1(1))
10024 call transpose2(AEA(1,1,2),atemp(1,1))
10025 call matmat2(atemp(1,1),EUg(1,1,i+4),atemp(1,1))
10026 call matvec2(Ug2(1,1,i+2),dd(1,1,itk1),vtemp2(1))
10027 s8 = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
10029 call matmat2(EUg(1,1,i+3),AEA(1,1,2),auxmat(1,1))
10030 call matvec2(auxmat(1,1),Ub2(1,i+4),vtemp3(1))
10031 s12 = scalar2(Ub2(1,i+2),vtemp3(1))
10033 call transpose2(a_chuj(1,1,kk,i+1),achuj_temp(1,1))
10034 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtemp(1,1))
10035 call matmat2(gtemp(1,1),EUg(1,1,i+3),gtemp(1,1))
10036 call matvec2(a_chuj(1,1,jj,i),Ub2(1,i+4),vtemp4(1))
10037 ss13 = scalar2(b1(1,itk),vtemp4(1))
10038 s13 = (gtemp(1,1)+gtemp(2,2))*ss13
10040 ! write (2,*) 's1,s2,s8,s12,s13',s1,s2,s8,s12,s13
10046 eel_turn6 = eello6_5 - 0.5d0*(s1+s2+s12+s8+s13)
10047 ! Derivatives in gamma(i+2)
10051 call transpose2(AEA(1,1,1),auxmatd(1,1))
10052 call matmat2(EUgder(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
10053 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
10054 call transpose2(AEAderg(1,1,2),atempd(1,1))
10055 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
10056 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
10058 call matmat2(EUg(1,1,i+3),AEAderg(1,1,2),auxmatd(1,1))
10059 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
10060 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
10066 gel_loc_turn6(i)=gel_loc_turn6(i)-0.5d0*ekont*(s1d+s8d+s12d)
10067 ! Derivatives in gamma(i+3)
10069 call transpose2(AEA(1,1,1),auxmatd(1,1))
10070 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
10071 ss1d=scalar2(Ub2der(1,i+2),b1(1,itl))
10072 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1d
10074 call matvec2(EUgder(1,1,i+2),b1(1,itl),vtemp1d(1))
10075 call matvec2(AEA(1,1,1),vtemp1d(1),vtemp1d(1))
10076 s2d = scalar2(b1(1,itk),vtemp1d(1))
10078 call matvec2(Ug2der(1,1,i+2),dd(1,1,itk1),vtemp2d(1))
10079 s8d = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,itl),vtemp2d(1))
10081 s12d = scalar2(Ub2der(1,i+2),vtemp3(1))
10083 call matmat2(achuj_temp(1,1),EUgder(1,1,i+2),gtempd(1,1))
10084 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
10085 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
10093 gel_loc_turn6(i+1)=gel_loc_turn6(i+1) &
10094 -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
10096 gel_loc_turn6(i+1)=gel_loc_turn6(i+1) &
10097 -0.5d0*ekont*(s2d+s12d)
10099 ! Derivatives in gamma(i+4)
10100 call matmat2(EUgder(1,1,i+3),AEA(1,1,2),auxmatd(1,1))
10101 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
10102 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
10104 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtempd(1,1))
10105 call matmat2(gtempd(1,1),EUgder(1,1,i+3),gtempd(1,1))
10106 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
10114 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d+s13d)
10116 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d)
10118 ! Derivatives in gamma(i+5)
10120 call transpose2(AEAderg(1,1,1),auxmatd(1,1))
10121 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
10122 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
10124 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1d(1))
10125 call matvec2(AEAderg(1,1,1),vtemp1d(1),vtemp1d(1))
10126 s2d = scalar2(b1(1,itk),vtemp1d(1))
10128 call transpose2(AEA(1,1,2),atempd(1,1))
10129 call matmat2(atempd(1,1),EUgder(1,1,i+4),atempd(1,1))
10130 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
10132 call matvec2(auxmat(1,1),Ub2der(1,i+4),vtemp3d(1))
10133 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
10135 call matvec2(a_chuj(1,1,jj,i),Ub2der(1,i+4),vtemp4d(1))
10136 ss13d = scalar2(b1(1,itk),vtemp4d(1))
10137 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
10145 gel_loc_turn6(i+3)=gel_loc_turn6(i+3) &
10146 -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
10148 gel_loc_turn6(i+3)=gel_loc_turn6(i+3) &
10149 -0.5d0*ekont*(s2d+s12d)
10151 ! Cartesian derivatives
10156 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmatd(1,1))
10157 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
10158 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
10160 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1(1))
10161 call matvec2(AEAderx(1,1,lll,kkk,iii,1),vtemp1(1),&
10163 s2d = scalar2(b1(1,itk),vtemp1d(1))
10165 call transpose2(AEAderx(1,1,lll,kkk,iii,2),atempd(1,1))
10166 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
10167 s8d = -(atempd(1,1)+atempd(2,2))* &
10168 scalar2(cc(1,1,itl),vtemp2(1))
10170 call matmat2(EUg(1,1,i+3),AEAderx(1,1,lll,kkk,iii,2),&
10172 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
10173 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
10180 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii) &
10183 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii) &
10187 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii) &
10190 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii) &
10199 call transpose2(a_chuj_der(1,1,lll,kkk,kk,i+1),&
10201 call matmat2(achuj_tempd(1,1),EUg(1,1,i+2),gtempd(1,1))
10202 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
10203 s13d=(gtempd(1,1)+gtempd(2,2))*ss13
10204 derx_turn(lll,kkk,2) = derx_turn(lll,kkk,2)-0.5d0*s13d
10205 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),Ub2(1,i+4),&
10207 ss13d = scalar2(b1(1,itk),vtemp4d(1))
10208 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
10209 derx_turn(lll,kkk,1) = derx_turn(lll,kkk,1)-0.5d0*s13d
10213 !d write(iout,*) 'eel6_turn6',eel_turn6,' eel_turn6_num',
10214 !d & 16*eel_turn6_num
10216 if (j.lt.nres-1) then
10223 if (l.lt.nres-1) then
10231 !grad ggg1(ll)=eel_turn6*g_contij(ll,1)
10232 !grad ggg2(ll)=eel_turn6*g_contij(ll,2)
10233 !grad ghalf=0.5d0*ggg1(ll)
10235 gturn6ij=eel_turn6*g_contij(ll,1)+ekont*derx_turn(ll,1,1)
10236 gturn6kl=eel_turn6*g_contij(ll,2)+ekont*derx_turn(ll,1,2)
10237 gcorr6_turn(ll,i)=gcorr6_turn(ll,i) & !+ghalf
10238 +ekont*derx_turn(ll,2,1)
10239 gcorr6_turn(ll,i+1)=gcorr6_turn(ll,i+1)+ekont*derx_turn(ll,3,1)
10240 gcorr6_turn(ll,j)=gcorr6_turn(ll,j) & !+ghalf
10241 +ekont*derx_turn(ll,4,1)
10242 gcorr6_turn(ll,j1)=gcorr6_turn(ll,j1)+ekont*derx_turn(ll,5,1)
10243 gcorr6_turn_long(ll,j)=gcorr6_turn_long(ll,j)+gturn6ij
10244 gcorr6_turn_long(ll,i)=gcorr6_turn_long(ll,i)-gturn6ij
10245 !grad ghalf=0.5d0*ggg2(ll)
10247 gcorr6_turn(ll,k)=gcorr6_turn(ll,k) & !+ghalf
10248 +ekont*derx_turn(ll,2,2)
10249 gcorr6_turn(ll,k+1)=gcorr6_turn(ll,k+1)+ekont*derx_turn(ll,3,2)
10250 gcorr6_turn(ll,l)=gcorr6_turn(ll,l) & !+ghalf
10251 +ekont*derx_turn(ll,4,2)
10252 gcorr6_turn(ll,l1)=gcorr6_turn(ll,l1)+ekont*derx_turn(ll,5,2)
10253 gcorr6_turn_long(ll,l)=gcorr6_turn_long(ll,l)+gturn6kl
10254 gcorr6_turn_long(ll,k)=gcorr6_turn_long(ll,k)-gturn6kl
10259 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg1(ll)
10264 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg2(ll)
10270 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,1)
10275 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,2)
10279 !d write (2,*) iii,g_corr6_loc(iii)
10281 eello_turn6=ekont*eel_turn6
10282 !d write (2,*) 'ekont',ekont
10283 !d write (2,*) 'eel_turn6',ekont*eel_turn6
10285 end function eello_turn6
10286 !-----------------------------------------------------------------------------
10287 subroutine MATVEC2(A1,V1,V2)
10288 !DIR$ INLINEALWAYS MATVEC2
10290 !DEC$ ATTRIBUTES FORCEINLINE::MATVEC2
10292 ! implicit real*8 (a-h,o-z)
10293 ! include 'DIMENSIONS'
10294 real(kind=8),dimension(2) :: V1,V2
10295 real(kind=8),dimension(2,2) :: A1
10296 real(kind=8) :: vaux1,vaux2
10300 ! 3 VI=VI+A1(I,K)*V1(K)
10304 vaux1=a1(1,1)*v1(1)+a1(1,2)*v1(2)
10305 vaux2=a1(2,1)*v1(1)+a1(2,2)*v1(2)
10309 end subroutine MATVEC2
10310 !-----------------------------------------------------------------------------
10311 subroutine MATMAT2(A1,A2,A3)
10313 !DEC$ ATTRIBUTES FORCEINLINE::MATMAT2
10315 ! implicit real*8 (a-h,o-z)
10316 ! include 'DIMENSIONS'
10317 real(kind=8),dimension(2,2) :: A1,A2,A3
10318 real(kind=8) :: ai3_11,ai3_12,ai3_21,ai3_22
10319 ! DIMENSION AI3(2,2)
10323 ! A3IJ=A3IJ+A1(I,K)*A2(K,J)
10329 ai3_11=a1(1,1)*a2(1,1)+a1(1,2)*a2(2,1)
10330 ai3_12=a1(1,1)*a2(1,2)+a1(1,2)*a2(2,2)
10331 ai3_21=a1(2,1)*a2(1,1)+a1(2,2)*a2(2,1)
10332 ai3_22=a1(2,1)*a2(1,2)+a1(2,2)*a2(2,2)
10338 end subroutine MATMAT2
10339 !-----------------------------------------------------------------------------
10340 real(kind=8) function scalar2(u,v)
10341 !DIR$ INLINEALWAYS scalar2
10343 real(kind=8),dimension(2) :: u,v
10346 scalar2=u(1)*v(1)+u(2)*v(2)
10348 end function scalar2
10349 !-----------------------------------------------------------------------------
10350 subroutine transpose2(a,at)
10351 !DIR$ INLINEALWAYS transpose2
10353 !DEC$ ATTRIBUTES FORCEINLINE::transpose2
10356 real(kind=8),dimension(2,2) :: a,at
10362 end subroutine transpose2
10363 !-----------------------------------------------------------------------------
10364 subroutine transpose(n,a,at)
10367 real(kind=8),dimension(n,n) :: a,at
10374 end subroutine transpose
10375 !-----------------------------------------------------------------------------
10376 subroutine prodmat3(a1,a2,kk,transp,prod)
10377 !DIR$ INLINEALWAYS prodmat3
10379 !DEC$ ATTRIBUTES FORCEINLINE::prodmat3
10383 real(kind=8),dimension(2,2) :: a1,a2,a2t,kk,prod
10385 !rc double precision auxmat(2,2),prod_(2,2)
10388 !rc call transpose2(kk(1,1),auxmat(1,1))
10389 !rc call matmat2(a1(1,1),auxmat(1,1),auxmat(1,1))
10390 !rc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
10392 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,1) &
10393 +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,1)
10394 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,2) &
10395 +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,2)
10396 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,1) &
10397 +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,1)
10398 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,2) &
10399 +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,2)
10402 !rc call matmat2(a1(1,1),kk(1,1),auxmat(1,1))
10403 !rc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
10405 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,1) &
10406 +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,1)
10407 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,2) &
10408 +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,2)
10409 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,1) &
10410 +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,1)
10411 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,2) &
10412 +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,2)
10415 ! call transpose2(a2(1,1),a2t(1,1))
10418 !rc print *,((prod_(i,j),i=1,2),j=1,2)
10419 !rc print *,((prod(i,j),i=1,2),j=1,2)
10422 end subroutine prodmat3
10423 !-----------------------------------------------------------------------------
10424 ! energy_p_new_barrier.F
10425 !-----------------------------------------------------------------------------
10426 subroutine sum_gradient
10427 ! implicit real*8 (a-h,o-z)
10428 use io_base, only: pdbout
10429 ! include 'DIMENSIONS'
10433 !MS$ATTRIBUTES C :: proc_proc
10439 real(kind=8),dimension(3,-1:nres) :: gradbufc,gradbufx,gradbufc_sum,&
10440 gloc_scbuf !(3,maxres)
10442 real(kind=8),dimension(4*nres) :: glocbuf !(4*maxres)
10444 !el local variables
10445 integer :: i,j,k,ierror,ierr
10446 real(kind=8) :: gvdwc_norm,gvdwc_scp_norm,gelc_norm,gvdwpp_norm,&
10447 gradb_norm,ghpbc_norm,gradcorr_norm,gel_loc_norm,&
10448 gcorr3_turn_norm,gcorr4_turn_norm,gradcorr5_norm,&
10449 gradcorr6_norm,gcorr6_turn_norm,gsccorr_norm,&
10450 gscloc_norm,gvdwx_norm,gradx_scp_norm,ghpbx_norm,&
10451 gradxorr_norm,gsccorrx_norm,gsclocx_norm,gcorr6_max,&
10452 gsccorr_max,gsccorrx_max,time00
10454 ! include 'COMMON.SETUP'
10455 ! include 'COMMON.IOUNITS'
10456 ! include 'COMMON.FFIELD'
10457 ! include 'COMMON.DERIV'
10458 ! include 'COMMON.INTERACT'
10459 ! include 'COMMON.SBRIDGE'
10460 ! include 'COMMON.CHAIN'
10461 ! include 'COMMON.VAR'
10462 ! include 'COMMON.CONTROL'
10463 ! include 'COMMON.TIME1'
10464 ! include 'COMMON.MAXGRAD'
10465 ! include 'COMMON.SCCOR'
10470 write (iout,*) "sum_gradient gvdwc, gvdwx"
10472 write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)') &
10473 i,(gvdwx(j,i),j=1,3),(gvdwc(j,i),j=1,3)
10483 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
10484 if (nfgtasks.gt.1 .and. fg_rank.eq.0) &
10485 call MPI_Bcast(1,1,MPI_INTEGER,king,FG_COMM,IERROR)
10488 ! 9/29/08 AL Transform parts of gradients in site coordinates to the gradient
10489 ! in virtual-bond-vector coordinates
10492 ! write (iout,*) "gel_loc gel_loc_long and gel_loc_loc"
10494 ! write (iout,'(i5,3f10.5,2x,3f10.5,2x,f10.5)')
10495 ! & i,(gel_loc(j,i),j=1,3),(gel_loc_long(j,i),j=1,3),gel_loc_loc(i)
10497 ! write (iout,*) "gel_loc_tur3 gel_loc_turn4"
10499 ! write (iout,'(i5,3f10.5,2x,f10.5)')
10500 ! & i,(gcorr4_turn(j,i),j=1,3),gel_loc_turn4(i)
10502 write (iout,*) "gvdwc gvdwc_scp gvdwc_scpp"
10504 write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)') &
10505 i,(gvdwc(j,i),j=1,3),(gvdwc_scp(j,i),j=1,3),&
10506 (gvdwc_scpp(j,i),j=1,3)
10508 write (iout,*) "gelc_long gvdwpp gel_loc_long"
10510 write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)') &
10511 i,(gelc_long(j,i),j=1,3),(gvdwpp(j,i),j=1,3),&
10512 (gelc_loc_long(j,i),j=1,3)
10519 gradbufc(j,i)=wsc*gvdwc(j,i)+ &
10520 wscp*(gvdwc_scp(j,i)+gvdwc_scpp(j,i))+ &
10521 welec*gelc_long(j,i)+wvdwpp*gvdwpp(j,i)+ &
10522 wel_loc*gel_loc_long(j,i)+ &
10523 wcorr*gradcorr_long(j,i)+ &
10524 wcorr5*gradcorr5_long(j,i)+ &
10525 wcorr6*gradcorr6_long(j,i)+ &
10526 wturn6*gcorr6_turn_long(j,i)+ &
10527 wstrain*ghpbc(j,i) &
10528 +wliptran*gliptranc(j,i) &
10530 +welec*gshieldc(j,i) &
10531 +wcorr*gshieldc_ec(j,i) &
10532 +wturn3*gshieldc_t3(j,i)&
10533 +wturn4*gshieldc_t4(j,i)&
10534 +wel_loc*gshieldc_ll(j,i)&
10535 +wtube*gg_tube(j,i) &
10536 +wvdwpp_nucl*gvdwpp_nucl(j,i)+welpp*gelpp(j,i)+ &
10537 wvdwpsb*(gvdwpsb(j,i)+gvdwpsb1(j,i))+ &
10538 wvdwsb*gvdwsbc(j,i)+welsb*gelsbc(j,i)+ &
10539 wcorr_nucl*gradcorr_nucl(j,i)&
10540 +wcorr3_nucl*gradcorr3_nucl(j,i)+&
10541 wcatprot* gradpepcat(j,i)+ &
10542 wcatcat*gradcatcat(j,i)+ &
10543 wscbase*gvdwc_scbase(j,i)+ &
10544 wpepbase*gvdwc_pepbase(j,i)+&
10545 wscpho*gvdwc_scpho(j,i)+ &
10546 wpeppho*gvdwc_peppho(j,i)
10557 gradbufc(j,i)=wsc*gvdwc(j,i)+ &
10558 wscp*(gvdwc_scp(j,i)+gvdwc_scpp(j,i))+ &
10559 welec*gelc_long(j,i)+ &
10560 wbond*gradb(j,i)+ &
10561 wel_loc*gel_loc_long(j,i)+ &
10562 wcorr*gradcorr_long(j,i)+ &
10563 wcorr5*gradcorr5_long(j,i)+ &
10564 wcorr6*gradcorr6_long(j,i)+ &
10565 wturn6*gcorr6_turn_long(j,i)+ &
10566 wstrain*ghpbc(j,i) &
10567 +wliptran*gliptranc(j,i) &
10569 +welec*gshieldc(j,i)&
10570 +wcorr*gshieldc_ec(j,i) &
10571 +wturn4*gshieldc_t4(j,i) &
10572 +wel_loc*gshieldc_ll(j,i)&
10573 +wtube*gg_tube(j,i) &
10574 +wvdwpp_nucl*gvdwpp_nucl(j,i)+welpp*gelpp(j,i)+ &
10575 wvdwpsb*(gvdwpsb(j,i)+gvdwpsb1(j,i))+ &
10576 wvdwsb*gvdwsbc(j,i)+welsb*gelsbc(j,i)+ &
10577 wcorr_nucl*gradcorr_nucl(j,i) &
10578 +wcorr3_nucl*gradcorr3_nucl(j,i) +&
10579 wcatprot* gradpepcat(j,i)+ &
10580 wcatcat*gradcatcat(j,i)+ &
10581 wscbase*gvdwc_scbase(j,i) &
10582 wpepbase*gvdwc_pepbase(j,i)+&
10583 wscpho*gvdwc_scpho(j,i)+&
10584 wpeppho*gvdwc_peppho(j,i)
10591 if (nfgtasks.gt.1) then
10594 write (iout,*) "gradbufc before allreduce"
10596 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
10602 gradbufc_sum(j,i)=gradbufc(j,i)
10605 ! call MPI_AllReduce(gradbufc(1,1),gradbufc_sum(1,1),3*nres,
10606 ! & MPI_DOUBLE_PRECISION,MPI_SUM,FG_COMM,IERR)
10607 ! time_reduce=time_reduce+MPI_Wtime()-time00
10609 ! write (iout,*) "gradbufc_sum after allreduce"
10611 ! write (iout,'(i3,3f10.5)') i,(gradbufc_sum(j,i),j=1,3)
10616 ! time_allreduce=time_allreduce+MPI_Wtime()-time00
10620 gradbufc(k,i)=0.0d0
10624 write (iout,*) "igrad_start",igrad_start," igrad_end",igrad_end
10625 write (iout,*) (i," jgrad_start",jgrad_start(i),&
10626 " jgrad_end ",jgrad_end(i),&
10627 i=igrad_start,igrad_end)
10630 ! Obsolete and inefficient code; we can make the effort O(n) and, therefore,
10631 ! do not parallelize this part.
10633 ! do i=igrad_start,igrad_end
10634 ! do j=jgrad_start(i),jgrad_end(i)
10636 ! gradbufc(k,i)=gradbufc(k,i)+gradbufc_sum(k,j)
10641 gradbufc(j,nres-1)=gradbufc_sum(j,nres)
10645 gradbufc(j,i)=gradbufc(j,i+1)+gradbufc_sum(j,i+1)
10649 write (iout,*) "gradbufc after summing"
10651 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
10659 write (iout,*) "gradbufc"
10661 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
10668 gradbufc_sum(j,i)=gradbufc(j,i)
10669 gradbufc(j,i)=0.0d0
10673 gradbufc(j,nres-1)=gradbufc_sum(j,nres)
10677 gradbufc(j,i)=gradbufc(j,i+1)+gradbufc_sum(j,i+1)
10682 ! gradbufc(k,i)=0.0d0
10686 ! gradbufc(k,i)=gradbufc(k,i)+gradbufc(k,j)
10692 write (iout,*) "gradbufc after summing"
10694 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
10703 gradbufc(k,nres)=0.0d0
10705 !el----------------
10706 !el if (.not.allocated(gradx)) allocate(gradx(3,nres,2)) !(3,maxres,2)
10707 !el if (.not.allocated(gradc)) allocate(gradc(3,nres,2)) !(3,maxres,2)
10708 !el-----------------
10712 gradc(j,i,icg)=gradbufc(j,i)+welec*gelc(j,i)+ &
10713 wel_loc*gel_loc(j,i)+ &
10714 0.5d0*(wscp*gvdwc_scpp(j,i)+ &
10715 welec*gelc_long(j,i)+wvdwpp*gvdwpp(j,i)+ &
10716 wel_loc*gel_loc_long(j,i)+ &
10717 wcorr*gradcorr_long(j,i)+ &
10718 wcorr5*gradcorr5_long(j,i)+ &
10719 wcorr6*gradcorr6_long(j,i)+ &
10720 wturn6*gcorr6_turn_long(j,i))+ &
10721 wbond*gradb(j,i)+ &
10722 wcorr*gradcorr(j,i)+ &
10723 wturn3*gcorr3_turn(j,i)+ &
10724 wturn4*gcorr4_turn(j,i)+ &
10725 wcorr5*gradcorr5(j,i)+ &
10726 wcorr6*gradcorr6(j,i)+ &
10727 wturn6*gcorr6_turn(j,i)+ &
10728 wsccor*gsccorc(j,i) &
10729 +wscloc*gscloc(j,i) &
10730 +wliptran*gliptranc(j,i) &
10732 +welec*gshieldc(j,i) &
10733 +welec*gshieldc_loc(j,i) &
10734 +wcorr*gshieldc_ec(j,i) &
10735 +wcorr*gshieldc_loc_ec(j,i) &
10736 +wturn3*gshieldc_t3(j,i) &
10737 +wturn3*gshieldc_loc_t3(j,i) &
10738 +wturn4*gshieldc_t4(j,i) &
10739 +wturn4*gshieldc_loc_t4(j,i) &
10740 +wel_loc*gshieldc_ll(j,i) &
10741 +wel_loc*gshieldc_loc_ll(j,i) &
10742 +wtube*gg_tube(j,i) &
10743 +0.5d0*(wvdwpp_nucl*gvdwpp_nucl(j,i)+welpp*gelpp(j,i)&
10744 +wvdwpsb*gvdwpsb1(j,i))&
10745 +wbond_nucl*gradb_nucl(j,i)+wsbloc*gsbloc(j,i)
10747 ! if ((i.le.2).and.(i.ge.1))
10748 ! print *,gradc(j,i,icg),&
10749 ! gradbufc(j,i),welec*gelc(j,i), &
10750 ! wel_loc*gel_loc(j,i), &
10751 ! wscp*gvdwc_scpp(j,i), &
10752 ! welec*gelc_long(j,i),wvdwpp*gvdwpp(j,i), &
10753 ! wel_loc*gel_loc_long(j,i), &
10754 ! wcorr*gradcorr_long(j,i), &
10755 ! wcorr5*gradcorr5_long(j,i), &
10756 ! wcorr6*gradcorr6_long(j,i), &
10757 ! wturn6*gcorr6_turn_long(j,i), &
10758 ! wbond*gradb(j,i), &
10759 ! wcorr*gradcorr(j,i), &
10760 ! wturn3*gcorr3_turn(j,i), &
10761 ! wturn4*gcorr4_turn(j,i), &
10762 ! wcorr5*gradcorr5(j,i), &
10763 ! wcorr6*gradcorr6(j,i), &
10764 ! wturn6*gcorr6_turn(j,i), &
10765 ! wsccor*gsccorc(j,i) &
10766 ! ,wscloc*gscloc(j,i) &
10767 ! ,wliptran*gliptranc(j,i) &
10769 ! ,welec*gshieldc(j,i) &
10770 ! ,welec*gshieldc_loc(j,i) &
10771 ! ,wcorr*gshieldc_ec(j,i) &
10772 ! ,wcorr*gshieldc_loc_ec(j,i) &
10773 ! ,wturn3*gshieldc_t3(j,i) &
10774 ! ,wturn3*gshieldc_loc_t3(j,i) &
10775 ! ,wturn4*gshieldc_t4(j,i) &
10776 ! ,wturn4*gshieldc_loc_t4(j,i) &
10777 ! ,wel_loc*gshieldc_ll(j,i) &
10778 ! ,wel_loc*gshieldc_loc_ll(j,i) &
10779 ! ,wtube*gg_tube(j,i) &
10780 ! ,wbond_nucl*gradb_nucl(j,i) &
10781 ! ,wvdwpp_nucl*gvdwpp_nucl(j,i),welpp*gelpp(j,i),&
10782 ! wvdwpsb*gvdwpsb1(j,i)&
10783 ! ,wbond_nucl*gradb_nucl(j,i),wsbloc*gsbloc(j,i)
10787 gradc(j,i,icg)=gradbufc(j,i)+welec*gelc(j,i)+ &
10788 wel_loc*gel_loc(j,i)+ &
10789 0.5d0*(wscp*gvdwc_scpp(j,i)+ &
10790 welec*gelc_long(j,i)+ &
10791 wel_loc*gel_loc_long(j,i)+ &
10792 !el wcorr*gcorr_long(j,i)+ & !el gcorr_long- brak deklaracji
10793 wcorr5*gradcorr5_long(j,i)+ &
10794 wcorr6*gradcorr6_long(j,i)+ &
10795 wturn6*gcorr6_turn_long(j,i))+ &
10796 wbond*gradb(j,i)+ &
10797 wcorr*gradcorr(j,i)+ &
10798 wturn3*gcorr3_turn(j,i)+ &
10799 wturn4*gcorr4_turn(j,i)+ &
10800 wcorr5*gradcorr5(j,i)+ &
10801 wcorr6*gradcorr6(j,i)+ &
10802 wturn6*gcorr6_turn(j,i)+ &
10803 wsccor*gsccorc(j,i) &
10804 +wscloc*gscloc(j,i) &
10806 +wliptran*gliptranc(j,i) &
10807 +welec*gshieldc(j,i) &
10808 +welec*gshieldc_loc(j,) &
10809 +wcorr*gshieldc_ec(j,i) &
10810 +wcorr*gshieldc_loc_ec(j,i) &
10811 +wturn3*gshieldc_t3(j,i) &
10812 +wturn3*gshieldc_loc_t3(j,i) &
10813 +wturn4*gshieldc_t4(j,i) &
10814 +wturn4*gshieldc_loc_t4(j,i) &
10815 +wel_loc*gshieldc_ll(j,i) &
10816 +wel_loc*gshieldc_loc_ll(j,i) &
10817 +wtube*gg_tube(j,i) &
10818 +wbond_nucl*gradb_nucl(j,i) &
10819 +0.5d0*(wvdwpp_nucl*gvdwpp_nucl(j,i)+welpp*gelpp(j,i)&
10820 +wvdwpsb*gvdwpsb1(j,i))&
10821 +wsbloc*gsbloc(j,i)
10827 gradx(j,i,icg)=wsc*gvdwx(j,i)+wscp*gradx_scp(j,i)+ &
10828 wbond*gradbx(j,i)+ &
10829 wstrain*ghpbx(j,i)+wcorr*gradxorr(j,i)+ &
10830 wsccor*gsccorx(j,i) &
10831 +wscloc*gsclocx(j,i) &
10832 +wliptran*gliptranx(j,i) &
10833 +welec*gshieldx(j,i) &
10834 +wcorr*gshieldx_ec(j,i) &
10835 +wturn3*gshieldx_t3(j,i) &
10836 +wturn4*gshieldx_t4(j,i) &
10837 +wel_loc*gshieldx_ll(j,i)&
10838 +wtube*gg_tube_sc(j,i) &
10839 +wbond_nucl*gradbx_nucl(j,i) &
10840 +wvdwsb*gvdwsbx(j,i) &
10841 +welsb*gelsbx(j,i) &
10842 +wcorr_nucl*gradxorr_nucl(j,i)&
10843 +wcorr3_nucl*gradxorr3_nucl(j,i) &
10844 +wsbloc*gsblocx(j,i) &
10845 +wcatprot* gradpepcatx(j,i)&
10846 +wscbase*gvdwx_scbase(j,i) &
10847 +wpepbase*gvdwx_pepbase(j,i)&
10848 +wscpho*gvdwx_scpho(j,i)
10849 ! if (i.eq.3) print *,"tu?", wscpho,gvdwx_scpho(j,i)
10854 write (iout,*) "gloc before adding corr"
10856 write (iout,*) i,gloc(i,icg)
10860 gloc(i,icg)=gloc(i,icg)+wcorr*gcorr_loc(i) &
10861 +wcorr5*g_corr5_loc(i) &
10862 +wcorr6*g_corr6_loc(i) &
10863 +wturn4*gel_loc_turn4(i) &
10864 +wturn3*gel_loc_turn3(i) &
10865 +wturn6*gel_loc_turn6(i) &
10866 +wel_loc*gel_loc_loc(i)
10869 write (iout,*) "gloc after adding corr"
10871 write (iout,*) i,gloc(i,icg)
10875 if (nfgtasks.gt.1) then
10878 gradbufc(j,i)=gradc(j,i,icg)
10879 gradbufx(j,i)=gradx(j,i,icg)
10883 glocbuf(i)=gloc(i,icg)
10887 write (iout,*) "gloc_sc before reduce"
10890 write (iout,*) i,j,gloc_sc(j,i,icg)
10897 gloc_scbuf(j,i)=gloc_sc(j,i,icg)
10901 call MPI_Barrier(FG_COMM,IERR)
10902 time_barrier_g=time_barrier_g+MPI_Wtime()-time00
10904 call MPI_Reduce(gradbufc(1,0),gradc(1,0,icg),3*nres+3,&
10905 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
10906 call MPI_Reduce(gradbufx(1,0),gradx(1,0,icg),3*nres+3,&
10907 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
10908 call MPI_Reduce(glocbuf(1),gloc(1,icg),4*nres,&
10909 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
10910 time_reduce=time_reduce+MPI_Wtime()-time00
10911 call MPI_Reduce(gloc_scbuf(1,1),gloc_sc(1,1,icg),3*nres,&
10912 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
10913 time_reduce=time_reduce+MPI_Wtime()-time00
10915 ! print *,"gradbuf",gradbufc(1,1),gradc(1,1,icg)
10917 write (iout,*) "gloc_sc after reduce"
10920 write (iout,*) i,j,gloc_sc(j,i,icg)
10926 write (iout,*) "gloc after reduce"
10928 write (iout,*) i,gloc(i,icg)
10933 if (gnorm_check) then
10935 ! Compute the maximum elements of the gradient
10938 gvdwc_scp_max=0.0d0
10945 gcorr3_turn_max=0.0d0
10946 gcorr4_turn_max=0.0d0
10947 gradcorr5_max=0.0d0
10948 gradcorr6_max=0.0d0
10949 gcorr6_turn_max=0.0d0
10953 gradx_scp_max=0.0d0
10959 gvdwc_norm=dsqrt(scalar(gvdwc(1,i),gvdwc(1,i)))
10960 if (gvdwc_norm.gt.gvdwc_max) gvdwc_max=gvdwc_norm
10961 gvdwc_scp_norm=dsqrt(scalar(gvdwc_scp(1,i),gvdwc_scp(1,i)))
10962 if (gvdwc_scp_norm.gt.gvdwc_scp_max) &
10963 gvdwc_scp_max=gvdwc_scp_norm
10964 gelc_norm=dsqrt(scalar(gelc(1,i),gelc(1,i)))
10965 if (gelc_norm.gt.gelc_max) gelc_max=gelc_norm
10966 gvdwpp_norm=dsqrt(scalar(gvdwpp(1,i),gvdwpp(1,i)))
10967 if (gvdwpp_norm.gt.gvdwpp_max) gvdwpp_max=gvdwpp_norm
10968 gradb_norm=dsqrt(scalar(gradb(1,i),gradb(1,i)))
10969 if (gradb_norm.gt.gradb_max) gradb_max=gradb_norm
10970 ghpbc_norm=dsqrt(scalar(ghpbc(1,i),ghpbc(1,i)))
10971 if (ghpbc_norm.gt.ghpbc_max) ghpbc_max=ghpbc_norm
10972 gradcorr_norm=dsqrt(scalar(gradcorr(1,i),gradcorr(1,i)))
10973 if (gradcorr_norm.gt.gradcorr_max) gradcorr_max=gradcorr_norm
10974 gel_loc_norm=dsqrt(scalar(gel_loc(1,i),gel_loc(1,i)))
10975 if (gel_loc_norm.gt.gel_loc_max) gel_loc_max=gel_loc_norm
10976 gcorr3_turn_norm=dsqrt(scalar(gcorr3_turn(1,i),&
10978 if (gcorr3_turn_norm.gt.gcorr3_turn_max) &
10979 gcorr3_turn_max=gcorr3_turn_norm
10980 gcorr4_turn_norm=dsqrt(scalar(gcorr4_turn(1,i),&
10982 if (gcorr4_turn_norm.gt.gcorr4_turn_max) &
10983 gcorr4_turn_max=gcorr4_turn_norm
10984 gradcorr5_norm=dsqrt(scalar(gradcorr5(1,i),gradcorr5(1,i)))
10985 if (gradcorr5_norm.gt.gradcorr5_max) &
10986 gradcorr5_max=gradcorr5_norm
10987 gradcorr6_norm=dsqrt(scalar(gradcorr6(1,i),gradcorr6(1,i)))
10988 if (gradcorr6_norm.gt.gradcorr6_max) gcorr6_max=gradcorr6_norm
10989 gcorr6_turn_norm=dsqrt(scalar(gcorr6_turn(1,i),&
10991 if (gcorr6_turn_norm.gt.gcorr6_turn_max) &
10992 gcorr6_turn_max=gcorr6_turn_norm
10993 gsccorr_norm=dsqrt(scalar(gsccorc(1,i),gsccorc(1,i)))
10994 if (gsccorr_norm.gt.gsccorr_max) gsccorr_max=gsccorr_norm
10995 gscloc_norm=dsqrt(scalar(gscloc(1,i),gscloc(1,i)))
10996 if (gscloc_norm.gt.gscloc_max) gscloc_max=gscloc_norm
10997 gvdwx_norm=dsqrt(scalar(gvdwx(1,i),gvdwx(1,i)))
10998 if (gvdwx_norm.gt.gvdwx_max) gvdwx_max=gvdwx_norm
10999 gradx_scp_norm=dsqrt(scalar(gradx_scp(1,i),gradx_scp(1,i)))
11000 if (gradx_scp_norm.gt.gradx_scp_max) &
11001 gradx_scp_max=gradx_scp_norm
11002 ghpbx_norm=dsqrt(scalar(ghpbx(1,i),ghpbx(1,i)))
11003 if (ghpbx_norm.gt.ghpbx_max) ghpbx_max=ghpbx_norm
11004 gradxorr_norm=dsqrt(scalar(gradxorr(1,i),gradxorr(1,i)))
11005 if (gradxorr_norm.gt.gradxorr_max) gradxorr_max=gradxorr_norm
11006 gsccorrx_norm=dsqrt(scalar(gsccorx(1,i),gsccorx(1,i)))
11007 if (gsccorrx_norm.gt.gsccorrx_max) gsccorrx_max=gsccorrx_norm
11008 gsclocx_norm=dsqrt(scalar(gsclocx(1,i),gsclocx(1,i)))
11009 if (gsclocx_norm.gt.gsclocx_max) gsclocx_max=gsclocx_norm
11013 open(istat,file=statname,position="append")
11015 open(istat,file=statname,access="append")
11017 write (istat,'(1h#,21f10.2)') gvdwc_max,gvdwc_scp_max,&
11018 gelc_max,gvdwpp_max,gradb_max,ghpbc_max,&
11019 gradcorr_max,gel_loc_max,gcorr3_turn_max,gcorr4_turn_max,&
11020 gradcorr5_max,gradcorr6_max,gcorr6_turn_max,gsccorc_max,&
11021 gscloc_max,gvdwx_max,gradx_scp_max,ghpbx_max,gradxorr_max,&
11022 gsccorx_max,gsclocx_max
11024 if (gvdwc_max.gt.1.0d4) then
11025 write (iout,*) "gvdwc gvdwx gradb gradbx"
11027 write(iout,'(i5,4(3f10.2,5x))') i,(gvdwc(j,i),gvdwx(j,i),&
11028 gradb(j,i),gradbx(j,i),j=1,3)
11030 call pdbout(0.0d0,'cipiszcze',iout)
11037 write (iout,*) "gradc gradx gloc"
11039 write (iout,'(i5,3f10.5,5x,3f10.5,5x,f10.5)') &
11040 i,(gradc(j,i,icg),j=1,3),(gradx(j,i,icg),j=1,3),gloc(i,icg)
11045 time_sumgradient=time_sumgradient+MPI_Wtime()-time01
11048 end subroutine sum_gradient
11049 !-----------------------------------------------------------------------------
11051 ! implicit real*8 (a-h,o-z)
11053 ! include 'DIMENSIONS'
11054 ! include 'COMMON.CHAIN'
11055 ! include 'COMMON.DERIV'
11056 ! include 'COMMON.CALC'
11057 ! include 'COMMON.IOUNITS'
11058 real(kind=8), dimension(3) :: dcosom1,dcosom2
11059 ! print *,"wchodze"
11060 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
11061 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
11062 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12 &
11063 -2.0D0*alf12*eps3der+sigder*sigsq_om12
11067 ! eom12=evdwij*eps1_om12
11069 ! write (iout,*) "eps2der",eps2der," eps3der",eps3der,&
11071 ! write (iout,*) "eps1_om12",eps1_om12," eps2rt_om12",eps2rt_om12
11072 ! write (iout,*) "eom1",eom1," eom2",eom2," eom12",eom12
11073 !C print *,sss_ele_cut,'in sc_grad'
11075 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
11076 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
11079 gg(k)=(gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k))*sss_ele_cut
11080 !C print *,'gg',k,gg(k)
11082 ! print *,i,j,gg_lipi(3),gg_lipj(3),sss_ele_cut
11083 ! write (iout,*) "gg",(gg(k),k=1,3)
11085 gvdwx(k,i)=gvdwx(k,i)-gg(k) +gg_lipi(k)&
11086 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
11087 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv &
11090 gvdwx(k,j)=gvdwx(k,j)+gg(k)+gg_lipj(k)&
11091 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
11092 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv &
11095 ! write (iout,*)(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
11096 ! +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
11097 ! write (iout,*)(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
11098 ! +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
11101 ! Calculate the components of the gradient in DC and X
11105 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
11109 gvdwc(l,i)=gvdwc(l,i)-gg(l)+gg_lipi(l)
11110 gvdwc(l,j)=gvdwc(l,j)+gg(l)+gg_lipj(l)
11113 end subroutine sc_grad
11115 !-----------------------------------------------------------------------------
11116 subroutine mixder(thetai,thet_pred_mean,theta0i,E_tc_t)
11119 ! implicit real*8 (a-h,o-z)
11120 ! include 'DIMENSIONS'
11121 ! include 'COMMON.LOCAL'
11122 ! include 'COMMON.IOUNITS'
11123 !el real(kind=8) :: term1,term2,termm,diffak,ratak,&
11124 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
11125 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,
11126 real(kind=8) :: thetai,thet_pred_mean,theta0i,E_tc_t
11127 real(kind=8) :: t3,t6,t9,t12,t14,t16,t21,t23,t26,t27,t32,t40
11129 !el common /calcthet/ term1,term2,termm,diffak,ratak,&
11130 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
11131 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,it
11132 !el local variables
11134 delthec=thetai-thet_pred_mean
11135 delthe0=thetai-theta0i
11136 ! "Thank you" to MAPLE (probably spared one day of hand-differentiation).
11137 t3 = thetai-thet_pred_mean
11141 t14 = t12+t6*sigsqtc
11143 t21 = thetai-theta0i
11149 E_tc_t = -((sigcsq+2.D0*t3*sigsqtc)*t9-t14*sigcsq*t3*t16*t9 &
11150 -aktc*sig0inv*t27)/t32+(t14*t9+aktc*t26)/t40 &
11151 *(-t12*t9-ak*sig0inv*t27)
11153 end subroutine mixder
11155 !-----------------------------------------------------------------------------
11157 !-----------------------------------------------------------------------------
11159 !-----------------------------------------------------------------------------
11160 ! This subroutine calculates the derivatives of the consecutive virtual
11161 ! bond vectors and the SC vectors in the virtual-bond angles theta and
11162 ! virtual-torsional angles phi, as well as the derivatives of SC vectors
11163 ! in the angles alpha and omega, describing the location of a side chain
11164 ! in its local coordinate system.
11166 ! The derivatives are stored in the following arrays:
11168 ! DDCDV - the derivatives of virtual-bond vectors DC in theta and phi.
11169 ! The structure is as follows:
11171 ! dDC(x,2)/dT(3),...,dDC(z,2)/dT(3),0, 0, 0
11172 ! 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)
11173 ! . . . . . . . . . . . . . . . . . .
11174 ! 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)
11178 ! 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)
11180 ! DXDV - the derivatives of the side-chain vectors in theta and phi.
11181 ! The structure is same as above.
11183 ! DCDS - the derivatives of the side chain vectors in the local spherical
11184 ! andgles alph and omega:
11186 ! 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)
11187 ! 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)
11191 ! 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)
11193 ! Version of March '95, based on an early version of November '91.
11195 !**********************************************************************
11196 ! implicit real*8 (a-h,o-z)
11197 ! include 'DIMENSIONS'
11198 ! include 'COMMON.VAR'
11199 ! include 'COMMON.CHAIN'
11200 ! include 'COMMON.DERIV'
11201 ! include 'COMMON.GEO'
11202 ! include 'COMMON.LOCAL'
11203 ! include 'COMMON.INTERACT'
11204 real(kind=8),dimension(3,3,nres) :: drt,rdt,prordt,prodrt !(3,3,maxres)
11205 real(kind=8),dimension(3,3) :: dp,temp
11206 !el real(kind=8) :: fromto(3,3,maxdim) !(3,3,maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
11207 real(kind=8),dimension(3) :: xx,xx1
11208 !el local variables
11209 integer :: i,k,l,j,m,ind,ind1,jjj
11210 real(kind=8) :: alphi,omegi,theta2,dpkl,dpjk,xj,rj,dxoijk,dxoiij,&
11211 tempkl,dsci,cosalphi,sinalphi,cosomegi,sinomegi,cost2,&
11212 sint2,xp,yp,xxp,yyp,zzp,dj
11214 ! common /przechowalnia/ fromto
11215 if(.not. allocated(fromto)) allocate(fromto(3,3,maxdim))
11216 ! get the position of the jth ijth fragment of the chain coordinate system
11217 ! in the fromto array.
11218 ! indmat(i,j)=((2*(nres-2)-i)*(i-1))/2+j-1
11220 ! maxdim=(nres-1)*(nres-2)/2
11221 ! allocate(dcdv(6,maxdim),dxds(6,nres))
11222 ! calculate the derivatives of transformation matrix elements in theta
11225 !el call flush(iout) !el
11227 rdt(1,1,i)=-rt(1,2,i)
11228 rdt(1,2,i)= rt(1,1,i)
11230 rdt(2,1,i)=-rt(2,2,i)
11231 rdt(2,2,i)= rt(2,1,i)
11233 rdt(3,1,i)=-rt(3,2,i)
11234 rdt(3,2,i)= rt(3,1,i)
11238 ! derivatives in phi
11244 drt(2,1,i)= rt(3,1,i)
11245 drt(2,2,i)= rt(3,2,i)
11246 drt(2,3,i)= rt(3,3,i)
11247 drt(3,1,i)=-rt(2,1,i)
11248 drt(3,2,i)=-rt(2,2,i)
11249 drt(3,3,i)=-rt(2,3,i)
11252 ! generate the matrix products of type r(i)t(i)...r(j)t(j)
11258 temp(k,l)=rt(k,l,i)
11263 fromto(k,l,ind)=temp(k,l)
11272 dpkl=dpkl+temp(k,m)*rt(m,l,j)
11275 fromto(k,l,ind)=dpkl
11286 ! Calculate derivatives.
11292 ! Derivatives of DC(i+1) in theta(i+2)
11298 dpjk=dpjk+prod(j,l,i)*rdt(l,k,i)
11301 prordt(j,k,i)=dp(j,k)
11304 dcdv(j,ind1)=vbld(i+1)*dp(j,1)
11307 ! Derivatives of SC(i+1) in theta(i+2)
11309 xx1(1)=-0.5D0*xloc(2,i+1)
11310 xx1(2)= 0.5D0*xloc(1,i+1)
11314 xj=xj+r(j,k,i)*xx1(k)
11321 rj=rj+prod(j,k,i)*xx(k)
11326 ! Derivatives of SC(i+1) in theta(i+3). The have to be handled differently
11327 ! than the other off-diagonal derivatives.
11332 dxoiij=dxoiij+dp(j,k)*xrot(k,i+2)
11334 dxdv(j,ind1+1)=dxoiij
11336 !d print *,ind1+1,(dxdv(j,ind1+1),j=1,3)
11338 ! Derivatives of DC(i+1) in phi(i+2)
11344 dpjk=dpjk+prod(j,l,i)*drt(l,k,i)
11347 prodrt(j,k,i)=dp(j,k)
11349 dcdv(j+3,ind1)=vbld(i+1)*dp(j,1)
11352 ! Derivatives of SC(i+1) in phi(i+2)
11355 xx(3)= xloc(2,i+1)*r(2,2,i)+xloc(3,i+1)*r(2,3,i)
11356 xx(2)=-xloc(2,i+1)*r(3,2,i)-xloc(3,i+1)*r(3,3,i)
11360 rj=rj+prod(j,k,i)*xx(k)
11365 ! Derivatives of SC(i+1) in phi(i+3).
11370 dxoiij=dxoiij+dp(j,k)*xrot(k,i+2)
11372 dxdv(j+3,ind1+1)=dxoiij
11375 ! Calculate the derivatives of DC(i+1) and SC(i+1) in theta(i+3) thru
11376 ! theta(nres) and phi(i+3) thru phi(nres).
11380 ind=indmat(i+1,j+1)
11381 !d print *,'i=',i,' j=',j,' ind=',ind,' ind1=',ind1
11386 tempkl=tempkl+prordt(k,m,i)*fromto(m,l,ind)
11391 !d print '(9f8.3)',((fromto(k,l,ind),l=1,3),k=1,3)
11392 !d print '(9f8.3)',((prod(k,l,i),l=1,3),k=1,3)
11393 !d print '(9f8.3)',((temp(k,l),l=1,3),k=1,3)
11394 ! Derivatives of virtual-bond vectors in theta
11396 dcdv(k,ind1)=vbld(i+1)*temp(k,1)
11398 !d print '(3f8.3)',(dcdv(k,ind1),k=1,3)
11399 ! Derivatives of SC vectors in theta
11403 dxoijk=dxoijk+temp(k,l)*xrot(l,j+2)
11405 dxdv(k,ind1+1)=dxoijk
11408 !--- Calculate the derivatives in phi
11414 tempkl=tempkl+prodrt(k,m,i)*fromto(m,l,ind)
11420 dcdv(k+3,ind1)=vbld(i+1)*temp(k,1)
11425 dxoijk=dxoijk+temp(k,l)*xrot(l,j+2)
11427 dxdv(k+3,ind1+1)=dxoijk
11432 ! Derivatives in alpha and omega:
11435 ! dsci=dsc(itype(i,1))
11440 if(alphi.ne.alphi) alphi=100.0
11441 if(omegi.ne.omegi) omegi=-100.0
11446 !d print *,'i=',i,' dsci=',dsci,' alphi=',alphi,' omegi=',omegi
11447 cosalphi=dcos(alphi)
11448 sinalphi=dsin(alphi)
11449 cosomegi=dcos(omegi)
11450 sinomegi=dsin(omegi)
11451 temp(1,1)=-dsci*sinalphi
11452 temp(2,1)= dsci*cosalphi*cosomegi
11453 temp(3,1)=-dsci*cosalphi*sinomegi
11455 temp(2,2)=-dsci*sinalphi*sinomegi
11456 temp(3,2)=-dsci*sinalphi*cosomegi
11457 theta2=pi-0.5D0*theta(i+1)
11461 !d print *,((temp(l,k),l=1,3),k=1,2)
11465 xxp= xp*cost2+yp*sint2
11466 yyp=-xp*sint2+yp*cost2
11469 xx(2)=yyp*r(2,2,i-1)+zzp*r(2,3,i-1)
11470 xx(3)=yyp*r(3,2,i-1)+zzp*r(3,3,i-1)
11474 dj=dj+prod(k,l,i-1)*xx(l)
11482 end subroutine cartder
11483 !-----------------------------------------------------------------------------
11485 !-----------------------------------------------------------------------------
11486 subroutine check_cartgrad
11487 ! Check the gradient of Cartesian coordinates in internal coordinates.
11488 ! implicit real*8 (a-h,o-z)
11489 ! include 'DIMENSIONS'
11490 ! include 'COMMON.IOUNITS'
11491 ! include 'COMMON.VAR'
11492 ! include 'COMMON.CHAIN'
11493 ! include 'COMMON.GEO'
11494 ! include 'COMMON.LOCAL'
11495 ! include 'COMMON.DERIV'
11496 real(kind=8),dimension(6,nres) :: temp
11497 real(kind=8),dimension(3) :: xx,gg
11498 integer :: i,k,j,ii
11499 real(kind=8) :: aincr,aincr2,alphi,omegi,theti,thet,phii
11500 ! indmat(i,j)=((2*(nres-2)-i)*(i-1))/2+j-1
11502 ! Check the gradient of the virtual-bond and SC vectors in the internal
11508 write (iout,'(a)') '**************** dx/dalpha'
11512 alph(i)=alph(i)+aincr
11514 temp(k,i)=dc(k,nres+i)
11518 gg(k)=(dc(k,nres+i)-temp(k,i))/aincr
11519 xx(k)=dabs((gg(k)-dxds(k,i))/(aincr*dabs(dxds(k,i))+aincr))
11521 write (iout,'(i4,3e15.6/4x,3e15.6,3f9.3)') &
11522 i,(gg(k),k=1,3),(dxds(k,i),k=1,3),(xx(k),k=1,3)
11528 write (iout,'(a)') '**************** dx/domega'
11532 omeg(i)=omeg(i)+aincr
11534 temp(k,i)=dc(k,nres+i)
11538 gg(k)=(dc(k,nres+i)-temp(k,i))/aincr
11539 xx(k)=dabs((gg(k)-dxds(k+3,i))/ &
11540 (aincr*dabs(dxds(k+3,i))+aincr))
11542 write (iout,'(i4,3e15.6/4x,3e15.6,3f9.3)') &
11543 i,(gg(k),k=1,3),(dxds(k+3,i),k=1,3),(xx(k),k=1,3)
11549 write (iout,'(a)') '**************** dx/dtheta'
11553 theta(i)=theta(i)+aincr
11556 temp(k,j)=dc(k,nres+j)
11562 ! print *,'i=',i-2,' j=',j-1,' ii=',ii
11564 gg(k)=(dc(k,nres+j)-temp(k,j))/aincr
11565 xx(k)=dabs((gg(k)-dxdv(k,ii))/ &
11566 (aincr*dabs(dxdv(k,ii))+aincr))
11568 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
11569 i,j,(gg(k),k=1,3),(dxdv(k,ii),k=1,3),(xx(k),k=1,3)
11576 write (iout,'(a)') '***************** dx/dphi'
11579 phi(i)=phi(i)+aincr
11582 temp(k,j)=dc(k,nres+j)
11590 gg(k)=(dc(k,nres+j)-temp(k,j))/aincr
11591 xx(k)=dabs((gg(k)-dxdv(k+3,ii))/ &
11592 (aincr*dabs(dxdv(k+3,ii))+aincr))
11594 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
11595 i,j,(gg(k),k=1,3),(dxdv(k+3,ii),k=1,3),(xx(k),k=1,3)
11598 phi(i)=phi(i)-aincr
11601 write (iout,'(a)') '****************** ddc/dtheta'
11604 theta(i+2)=thet+aincr
11615 gg(k)=(dc(k,j)-temp(k,j))/aincr
11616 xx(k)=dabs((gg(k)-dcdv(k,ii))/ &
11617 (aincr*dabs(dcdv(k,ii))+aincr))
11619 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
11620 i,j,(gg(k),k=1,3),(dcdv(k,ii),k=1,3),(xx(k),k=1,3)
11630 write (iout,'(a)') '******************* ddc/dphi'
11633 phi(i+3)=phii+aincr
11644 gg(k)=(dc(k,j)-temp(k,j))/aincr
11645 xx(k)=dabs((gg(k)-dcdv(k+3,ii))/ &
11646 (aincr*dabs(dcdv(k+3,ii))+aincr))
11648 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
11649 i,j,(gg(k),k=1,3),(dcdv(k+3,ii),k=1,3),(xx(k),k=1,3)
11660 end subroutine check_cartgrad
11661 !-----------------------------------------------------------------------------
11662 subroutine check_ecart
11663 ! Check the gradient of the energy in Cartesian coordinates.
11664 ! implicit real*8 (a-h,o-z)
11665 ! include 'DIMENSIONS'
11666 ! include 'COMMON.CHAIN'
11667 ! include 'COMMON.DERIV'
11668 ! include 'COMMON.IOUNITS'
11669 ! include 'COMMON.VAR'
11670 ! include 'COMMON.CONTACTS'
11672 !el integer :: icall
11673 !el common /srutu/ icall
11674 real(kind=8),dimension(6) :: ggg
11675 real(kind=8),dimension(3) :: cc,xx,ddc,ddx
11676 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
11677 real(kind=8),dimension(6,nres) :: grad_s
11678 real(kind=8),dimension(0:n_ene) :: energia,energia1
11679 integer :: uiparm(1)
11680 real(kind=8) :: urparm(1)
11682 integer :: nf,i,j,k
11683 real(kind=8) :: aincr,etot,etot1
11689 print '(a)','CG processor',me,' calling CHECK_CART.',aincr
11692 call geom_to_var(nvar,x)
11693 call etotal(energia)
11695 !el call enerprint(energia)
11696 call gradient(nvar,x,nf,g,uiparm,urparm,fdum)
11699 write (iout,'(i5,3f10.5)') i,(gradxorr(j,i),j=1,3)
11703 grad_s(j,i)=gradc(j,i,icg)
11704 grad_s(j+3,i)=gradx(j,i,icg)
11708 write (iout,'(/a/)') 'Gradient in virtual-bond and SC vectors'
11713 ddx(j)=dc(j,i+nres)
11716 dc(j,i)=dc(j,i)+aincr
11718 c(j,k)=c(j,k)+aincr
11719 c(j,k+nres)=c(j,k+nres)+aincr
11721 call etotal(energia1)
11723 ggg(j)=(etot1-etot)/aincr
11726 c(j,k)=c(j,k)-aincr
11727 c(j,k+nres)=c(j,k+nres)-aincr
11731 c(j,i+nres)=c(j,i+nres)+aincr
11732 dc(j,i+nres)=dc(j,i+nres)+aincr
11733 call etotal(energia1)
11735 ggg(j+3)=(etot1-etot)/aincr
11737 dc(j,i+nres)=ddx(j)
11739 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/)') &
11740 i,(ggg(k),k=1,6),(grad_s(k,i),k=1,6)
11743 end subroutine check_ecart
11745 !-----------------------------------------------------------------------------
11746 subroutine check_ecartint
11747 ! Check the gradient of the energy in Cartesian coordinates.
11748 use io_base, only: intout
11749 ! implicit real*8 (a-h,o-z)
11750 ! include 'DIMENSIONS'
11751 ! include 'COMMON.CONTROL'
11752 ! include 'COMMON.CHAIN'
11753 ! include 'COMMON.DERIV'
11754 ! include 'COMMON.IOUNITS'
11755 ! include 'COMMON.VAR'
11756 ! include 'COMMON.CONTACTS'
11757 ! include 'COMMON.MD'
11758 ! include 'COMMON.LOCAL'
11759 ! include 'COMMON.SPLITELE'
11761 !el integer :: icall
11762 !el common /srutu/ icall
11763 real(kind=8),dimension(6) :: ggg,ggg1
11764 real(kind=8),dimension(3) :: cc,xx,ddc,ddx,ddc1,ddcn
11765 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
11766 real(kind=8),dimension(3) :: dcnorm_safe1,dcnorm_safe2,dxnorm_safe
11767 real(kind=8),dimension(6,0:nres) :: grad_s,grad_s1 !(6,0:maxres)
11768 real(kind=8),dimension(nres) :: phi_temp,theta_temp,alph_temp,omeg_temp !(maxres)
11769 real(kind=8),dimension(0:n_ene) :: energia,energia1
11770 integer :: uiparm(1)
11771 real(kind=8) :: urparm(1)
11773 integer :: i,j,k,nf
11774 real(kind=8) :: rlambd,aincr,etot,etot1,etot11,etot12,etot2,&
11782 ! call intcartderiv
11783 ! call checkintcartgrad
11786 write(iout,*) 'Calling CHECK_ECARTINT.'
11789 write (iout,*) "Before geom_to_var"
11790 call geom_to_var(nvar,x)
11791 write (iout,*) "after geom_to_var"
11792 write (iout,*) "split_ene ",split_ene
11794 if (.not.split_ene) then
11795 write(iout,*) 'Calling CHECK_ECARTINT if'
11796 call etotal(energia)
11797 !elwrite(iout,*) 'Calling CHECK_ECARTINT if'
11799 write (iout,*) "etot",etot
11801 !el call enerprint(energia)
11802 !elwrite(iout,*) 'Calling CHECK_ECARTINT if'
11804 write (iout,*) "enter cartgrad"
11807 !elwrite(iout,*) 'Calling CHECK_ECARTINT if'
11808 write (iout,*) "exit cartgrad"
11812 write (iout,'(i5,3f10.5)') i,(gradxorr(j,i),j=1,3)
11815 grad_s(j,0)=gcart(j,0)
11817 !elwrite(iout,*) 'Calling CHECK_ECARTINT if'
11820 grad_s(j,i)=gcart(j,i)
11821 grad_s(j+3,i)=gxcart(j,i)
11825 write(iout,*) 'Calling CHECK_ECARTIN else.'
11826 !- split gradient check
11828 call etotal_long(energia)
11829 !el call enerprint(energia)
11831 write (iout,*) "enter cartgrad"
11834 write (iout,*) "exit cartgrad"
11837 write (iout,*) "longrange grad"
11839 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
11840 (gxcart(j,i),j=1,3)
11843 grad_s(j,0)=gcart(j,0)
11847 grad_s(j,i)=gcart(j,i)
11848 grad_s(j+3,i)=gxcart(j,i)
11852 call etotal_short(energia)
11853 call enerprint(energia)
11855 write (iout,*) "enter cartgrad"
11858 write (iout,*) "exit cartgrad"
11861 write (iout,*) "shortrange grad"
11863 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
11864 (gxcart(j,i),j=1,3)
11867 grad_s1(j,0)=gcart(j,0)
11871 grad_s1(j,i)=gcart(j,i)
11872 grad_s1(j+3,i)=gxcart(j,i)
11876 write (iout,'(/a/)') 'Gradient in virtual-bond and SC vectors'
11880 if (nnt.gt.1 .and. i.eq.nnt) ddc1(j)=c(j,1)
11881 if (nct.lt.nres .and. i.eq.nct) ddcn(j)=c(j,nres)
11884 dcnorm_safe1(j)=dc_norm(j,i-1)
11885 dcnorm_safe2(j)=dc_norm(j,i)
11886 dxnorm_safe(j)=dc_norm(j,i+nres)
11889 c(j,i)=ddc(j)+aincr
11890 if (nnt.gt.1 .and. i.eq.nnt) c(j,1)=c(j,1)+aincr
11891 if (nct.lt.nres .and. i.eq.nct) c(j,nres)=c(j,nres)+aincr
11892 if (i.gt.1) dc(j,i-1)=c(j,i)-c(j,i-1)
11893 dc(j,i)=c(j,i+1)-c(j,i)
11894 dc(j,i+nres)=c(j,i+nres)-c(j,i)
11895 call int_from_cart1(.false.)
11896 if (.not.split_ene) then
11897 call etotal(energia1)
11899 write (iout,*) "ij",i,j," etot1",etot1
11902 call etotal_long(energia1)
11904 call etotal_short(energia1)
11907 !- end split gradient
11908 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot1",etot1
11909 c(j,i)=ddc(j)-aincr
11910 if (nnt.gt.1 .and. i.eq.nnt) c(j,1)=ddc1(j)-aincr
11911 if (nct.lt.nres .and. i.eq.nct) c(j,nres)=ddcn(j)-aincr
11912 if (i.gt.1) dc(j,i-1)=c(j,i)-c(j,i-1)
11913 dc(j,i)=c(j,i+1)-c(j,i)
11914 dc(j,i+nres)=c(j,i+nres)-c(j,i)
11915 call int_from_cart1(.false.)
11916 if (.not.split_ene) then
11917 call etotal(energia1)
11919 write (iout,*) "ij",i,j," etot2",etot2
11920 ggg(j)=(etot1-etot2)/(2*aincr)
11923 call etotal_long(energia1)
11925 ggg(j)=(etot11-etot21)/(2*aincr)
11926 call etotal_short(energia1)
11928 ggg1(j)=(etot12-etot22)/(2*aincr)
11929 !- end split gradient
11930 ! write (iout,*) "etot21",etot21," etot22",etot22
11932 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
11934 if (nnt.gt.1 .and. i.eq.nnt) c(j,1)=ddc1(j)
11935 if (nct.lt.nres .and. i.eq.nct) c(j,nres)=ddcn(j)
11936 if (i.gt.1) dc(j,i-1)=c(j,i)-c(j,i-1)
11937 dc(j,i)=c(j,i+1)-c(j,i)
11938 dc(j,i+nres)=c(j,i+nres)-c(j,i)
11939 dc_norm(j,i-1)=dcnorm_safe1(j)
11940 dc_norm(j,i)=dcnorm_safe2(j)
11941 dc_norm(j,i+nres)=dxnorm_safe(j)
11944 c(j,i+nres)=ddx(j)+aincr
11945 dc(j,i+nres)=c(j,i+nres)-c(j,i)
11946 call int_from_cart1(.false.)
11947 if (.not.split_ene) then
11948 call etotal(energia1)
11952 call etotal_long(energia1)
11954 call etotal_short(energia1)
11957 !- end split gradient
11958 c(j,i+nres)=ddx(j)-aincr
11959 dc(j,i+nres)=c(j,i+nres)-c(j,i)
11960 call int_from_cart1(.false.)
11961 if (.not.split_ene) then
11962 call etotal(energia1)
11964 ggg(j+3)=(etot1-etot2)/(2*aincr)
11967 call etotal_long(energia1)
11969 ggg(j+3)=(etot11-etot21)/(2*aincr)
11970 call etotal_short(energia1)
11972 ggg1(j+3)=(etot12-etot22)/(2*aincr)
11973 !- end split gradient
11975 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
11977 dc(j,i+nres)=c(j,i+nres)-c(j,i)
11978 dc_norm(j,i+nres)=dxnorm_safe(j)
11979 call int_from_cart1(.false.)
11981 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
11982 i,(ggg(k),k=1,6),(grad_s(k,i),k=1,6),(ggg(k)/grad_s(k,i),k=1,6)
11983 if (split_ene) then
11984 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
11985 i,(ggg1(k),k=1,6),(grad_s1(k,i),k=1,6),(ggg1(k)/grad_s1(k,i),&
11987 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
11988 i,(ggg(k)+ggg1(k),k=1,6),(grad_s(k,i)+grad_s1(k,i),k=1,6),&
11989 ((ggg(k)+ggg1(k))/(grad_s(k,i)+grad_s1(k,i)),k=1,6)
11993 end subroutine check_ecartint
11995 !-----------------------------------------------------------------------------
11996 subroutine check_ecartint
11997 ! Check the gradient of the energy in Cartesian coordinates.
11998 use io_base, only: intout
11999 ! implicit real*8 (a-h,o-z)
12000 ! include 'DIMENSIONS'
12001 ! include 'COMMON.CONTROL'
12002 ! include 'COMMON.CHAIN'
12003 ! include 'COMMON.DERIV'
12004 ! include 'COMMON.IOUNITS'
12005 ! include 'COMMON.VAR'
12006 ! include 'COMMON.CONTACTS'
12007 ! include 'COMMON.MD'
12008 ! include 'COMMON.LOCAL'
12009 ! include 'COMMON.SPLITELE'
12011 !el integer :: icall
12012 !el common /srutu/ icall
12013 real(kind=8),dimension(6) :: ggg,ggg1
12014 real(kind=8),dimension(3) :: cc,xx,ddc,ddx
12015 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
12016 real(kind=8),dimension(3) :: dcnorm_safe,dxnorm_safe
12017 real(kind=8),dimension(6,0:nres) :: grad_s,grad_s1 !(6,0:maxres)
12018 real(kind=8),dimension(nres) :: phi_temp,theta_temp,alph_temp,omeg_temp !(maxres)
12019 real(kind=8),dimension(0:n_ene) :: energia,energia1
12020 integer :: uiparm(1)
12021 real(kind=8) :: urparm(1)
12023 integer :: i,j,k,nf
12024 real(kind=8) :: rlambd,aincr,etot,etot1,etot11,etot12,etot2,&
12032 ! call intcartderiv
12033 ! call checkintcartgrad
12036 write(iout,*) 'Calling CHECK_ECARTINT.',aincr
12039 call geom_to_var(nvar,x)
12040 if (.not.split_ene) then
12041 call etotal(energia)
12043 !el call enerprint(energia)
12045 write (iout,*) "enter cartgrad"
12048 write (iout,*) "exit cartgrad"
12052 write (iout,'(i5,3f10.5)') i,(gradxorr(j,i),j=1,3)
12055 grad_s(j,0)=gcart(j,0)
12059 grad_s(j,i)=gcart(j,i)
12060 ! if (i.le.2) print *,"tu?!",gcart(j,i),grad_s(j,i),gxcart(j,i)
12061 grad_s(j+3,i)=gxcart(j,i)
12065 !- split gradient check
12067 call etotal_long(energia)
12068 !el call enerprint(energia)
12070 write (iout,*) "enter cartgrad"
12073 write (iout,*) "exit cartgrad"
12076 write (iout,*) "longrange grad"
12078 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
12079 (gxcart(j,i),j=1,3)
12082 grad_s(j,0)=gcart(j,0)
12086 grad_s(j,i)=gcart(j,i)
12087 grad_s(j+3,i)=gxcart(j,i)
12091 call etotal_short(energia)
12092 !el call enerprint(energia)
12094 write (iout,*) "enter cartgrad"
12097 write (iout,*) "exit cartgrad"
12100 write (iout,*) "shortrange grad"
12102 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
12103 (gxcart(j,i),j=1,3)
12106 grad_s1(j,0)=gcart(j,0)
12110 grad_s1(j,i)=gcart(j,i)
12111 grad_s1(j+3,i)=gxcart(j,i)
12115 write (iout,'(/a/)') 'Gradient in virtual-bond and SC vectors'
12120 ddx(j)=dc(j,i+nres)
12122 dcnorm_safe(k)=dc_norm(k,i)
12123 dxnorm_safe(k)=dc_norm(k,i+nres)
12127 dc(j,i)=ddc(j)+aincr
12128 call chainbuild_cart
12130 ! Broadcast the order to compute internal coordinates to the slaves.
12131 ! if (nfgtasks.gt.1)
12132 ! & call MPI_Bcast(6,1,MPI_INTEGER,king,FG_COMM,IERROR)
12134 ! call int_from_cart1(.false.)
12135 if (.not.split_ene) then
12136 call etotal(energia1)
12138 ! call enerprint(energia1)
12141 call etotal_long(energia1)
12143 call etotal_short(energia1)
12145 ! write (iout,*) "etot11",etot11," etot12",etot12
12147 !- end split gradient
12148 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot1",etot1
12149 dc(j,i)=ddc(j)-aincr
12150 call chainbuild_cart
12151 ! call int_from_cart1(.false.)
12152 if (.not.split_ene) then
12153 call etotal(energia1)
12155 ggg(j)=(etot1-etot2)/(2*aincr)
12158 call etotal_long(energia1)
12160 ggg(j)=(etot11-etot21)/(2*aincr)
12161 call etotal_short(energia1)
12163 ggg1(j)=(etot12-etot22)/(2*aincr)
12164 !- end split gradient
12165 ! write (iout,*) "etot21",etot21," etot22",etot22
12167 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
12169 call chainbuild_cart
12172 dc(j,i+nres)=ddx(j)+aincr
12173 call chainbuild_cart
12174 ! write (iout,*) "i",i," j",j," dxnorm+ and dxnorm"
12175 ! write (iout,'(3f15.10)') (dc_norm(k,i+nres),k=1,3)
12176 ! write (iout,'(3f15.10)') (dxnorm_safe(k),k=1,3)
12177 ! write (iout,*) "dxnormnorm",dsqrt(
12178 ! & dc_norm(1,i+nres)**2+dc_norm(2,i+nres)**2+dc_norm(3,i+nres)**2)
12179 ! write (iout,*) "dxnormnormsafe",dsqrt(
12180 ! & dxnorm_safe(1)**2+dxnorm_safe(2)**2+dxnorm_safe(3)**2)
12182 if (.not.split_ene) then
12183 call etotal(energia1)
12187 call etotal_long(energia1)
12189 call etotal_short(energia1)
12192 !- end split gradient
12193 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot1",etot1
12194 dc(j,i+nres)=ddx(j)-aincr
12195 call chainbuild_cart
12196 ! write (iout,*) "i",i," j",j," dxnorm- and dxnorm"
12197 ! write (iout,'(3f15.10)') (dc_norm(k,i+nres),k=1,3)
12198 ! write (iout,'(3f15.10)') (dxnorm_safe(k),k=1,3)
12200 ! write (iout,*) "dxnormnorm",dsqrt(
12201 ! & dc_norm(1,i+nres)**2+dc_norm(2,i+nres)**2+dc_norm(3,i+nres)**2)
12202 ! write (iout,*) "dxnormnormsafe",dsqrt(
12203 ! & dxnorm_safe(1)**2+dxnorm_safe(2)**2+dxnorm_safe(3)**2)
12204 if (.not.split_ene) then
12205 call etotal(energia1)
12207 ggg(j+3)=(etot1-etot2)/(2*aincr)
12210 call etotal_long(energia1)
12212 ggg(j+3)=(etot11-etot21)/(2*aincr)
12213 call etotal_short(energia1)
12215 ggg1(j+3)=(etot12-etot22)/(2*aincr)
12216 !- end split gradient
12218 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
12219 dc(j,i+nres)=ddx(j)
12220 call chainbuild_cart
12222 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
12223 i,(ggg(k),k=1,6),(grad_s(k,i),k=1,6),(ggg(k)/grad_s(k,i),k=1,6)
12224 if (split_ene) then
12225 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
12226 i,(ggg1(k),k=1,6),(grad_s1(k,i),k=1,6),(ggg1(k)/grad_s1(k,i),&
12228 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
12229 i,(ggg(k)+ggg1(k),k=1,6),(grad_s(k,i)+grad_s1(k,i),k=1,6),&
12230 ((ggg(k)+ggg1(k))/(grad_s(k,i)+grad_s1(k,i)),k=1,6)
12234 end subroutine check_ecartint
12236 !-----------------------------------------------------------------------------
12237 subroutine check_eint
12238 ! Check the gradient of energy in internal coordinates.
12239 ! implicit real*8 (a-h,o-z)
12240 ! include 'DIMENSIONS'
12241 ! include 'COMMON.CHAIN'
12242 ! include 'COMMON.DERIV'
12243 ! include 'COMMON.IOUNITS'
12244 ! include 'COMMON.VAR'
12245 ! include 'COMMON.GEO'
12247 !el integer :: icall
12248 !el common /srutu/ icall
12249 real(kind=8),dimension(6*nres) :: x,gana,gg !(maxvar) (maxvar=6*maxres)
12250 integer :: uiparm(1)
12251 real(kind=8) :: urparm(1)
12252 real(kind=8),dimension(0:n_ene) :: energia,energia1,energia2
12253 character(len=6) :: key
12256 real(kind=8) :: xi,aincr,etot,etot1,etot2
12259 print '(a)','Calling CHECK_INT.'
12263 call geom_to_var(nvar,x)
12264 call var_to_geom(nvar,x)
12267 ! print *,'ICG=',ICG
12268 call etotal(energia)
12270 !el call enerprint(energia)
12271 ! print *,'ICG=',ICG
12273 if (MyID.ne.BossID) then
12274 call mp_bcast(x(1),8*(nvar+3),BossID,fgGroupID)
12282 !d write (iout,'(10f8.3)') (rad2deg*x(i),i=1,nvar)
12283 call gradient(nvar,x,nf,gana,uiparm,urparm,fdum)
12284 !d write (iout,'(i3,1pe14.4)') (i,gana(i),i=1,nvar+20) !sp
12288 x(i)=xi-0.5D0*aincr
12289 call var_to_geom(nvar,x)
12291 call etotal(energia1)
12293 x(i)=xi+0.5D0*aincr
12294 call var_to_geom(nvar,x)
12296 call etotal(energia2)
12298 gg(i)=(etot2-etot1)/aincr
12299 write (iout,*) i,etot1,etot2
12302 write (iout,'(/2a)')' Variable Numerical Analytical',&
12305 if (i.le.nphi) then
12308 else if (i.le.nphi+ntheta) then
12311 else if (i.le.nphi+ntheta+nside) then
12315 ii=i-(nphi+ntheta+nside)
12318 write (iout,'(i3,a,i3,3(1pd16.6))') &
12319 i,key,ii,gg(i),gana(i),&
12320 100.0D0*dabs(gg(i)-gana(i))/(dabs(gana(i))+aincr)
12323 end subroutine check_eint
12324 !-----------------------------------------------------------------------------
12326 !-----------------------------------------------------------------------------
12327 subroutine Econstr_back
12328 ! MD with umbrella_sampling using Wolyne's distance measure as a constraint
12329 ! implicit real*8 (a-h,o-z)
12330 ! include 'DIMENSIONS'
12331 ! include 'COMMON.CONTROL'
12332 ! include 'COMMON.VAR'
12333 ! include 'COMMON.MD'
12336 ! include 'COMMON.LANGEVIN'
12338 ! include 'COMMON.LANGEVIN.lang0'
12340 ! include 'COMMON.CHAIN'
12341 ! include 'COMMON.DERIV'
12342 ! include 'COMMON.GEO'
12343 ! include 'COMMON.LOCAL'
12344 ! include 'COMMON.INTERACT'
12345 ! include 'COMMON.IOUNITS'
12346 ! include 'COMMON.NAMES'
12347 ! include 'COMMON.TIME1'
12348 integer :: i,j,ii,k
12349 real(kind=8) :: utheta_i,dtheta_i,ugamma_i,dgamma_i,dxx,dyy,dzz
12351 if(.not.allocated(utheta)) allocate(utheta(nfrag_back))
12352 if(.not.allocated(ugamma)) allocate(ugamma(nfrag_back))
12353 if(.not.allocated(uscdiff)) allocate(uscdiff(nfrag_back))
12360 duscdiff(j,i)=0.0d0
12361 duscdiffx(j,i)=0.0d0
12365 ii = ifrag_back(2,i,iset)-ifrag_back(1,i,iset)
12367 ! Deviations from theta angles
12370 do j=ifrag_back(1,i,iset)+2,ifrag_back(2,i,iset)
12371 dtheta_i=theta(j)-thetaref(j)
12372 utheta_i=utheta_i+0.5d0*dtheta_i*dtheta_i
12373 dutheta(j-2)=dutheta(j-2)+wfrag_back(1,i,iset)*dtheta_i/(ii-1)
12375 utheta(i)=utheta_i/(ii-1)
12377 ! Deviations from gamma angles
12380 do j=ifrag_back(1,i,iset)+3,ifrag_back(2,i,iset)
12381 dgamma_i=pinorm(phi(j)-phiref(j))
12382 ! write (iout,*) j,phi(j),phi(j)-phiref(j)
12383 ugamma_i=ugamma_i+0.5d0*dgamma_i*dgamma_i
12384 dugamma(j-3)=dugamma(j-3)+wfrag_back(2,i,iset)*dgamma_i/(ii-2)
12385 ! write (iout,*) i,j,dgamma_i,wfrag_back(2,i,iset),dugamma(j-3)
12387 ugamma(i)=ugamma_i/(ii-2)
12389 ! Deviations from local SC geometry
12392 do j=ifrag_back(1,i,iset)+1,ifrag_back(2,i,iset)-1
12393 dxx=xxtab(j)-xxref(j)
12394 dyy=yytab(j)-yyref(j)
12395 dzz=zztab(j)-zzref(j)
12396 uscdiff(i)=uscdiff(i)+dxx*dxx+dyy*dyy+dzz*dzz
12398 duscdiff(k,j-1)=duscdiff(k,j-1)+wfrag_back(3,i,iset)* &
12399 (dXX_C1tab(k,j)*dxx+dYY_C1tab(k,j)*dyy+dZZ_C1tab(k,j)*dzz)/ &
12401 duscdiff(k,j)=duscdiff(k,j)+wfrag_back(3,i,iset)* &
12402 (dXX_Ctab(k,j)*dxx+dYY_Ctab(k,j)*dyy+dZZ_Ctab(k,j)*dzz)/ &
12404 duscdiffx(k,j)=duscdiffx(k,j)+wfrag_back(3,i,iset)* &
12405 (dXX_XYZtab(k,j)*dxx+dYY_XYZtab(k,j)*dyy+dZZ_XYZtab(k,j)*dzz) &
12408 ! write (iout,'(i5,6f10.5)') j,xxtab(j),yytab(j),zztab(j),
12409 ! & xxref(j),yyref(j),zzref(j)
12411 uscdiff(i)=0.5d0*uscdiff(i)/(ii-1)
12412 ! write (iout,*) i," uscdiff",uscdiff(i)
12414 ! Put together deviations from local geometry
12416 Uconst_back=Uconst_back+wfrag_back(1,i,iset)*utheta(i)+ &
12417 wfrag_back(2,i,iset)*ugamma(i)+wfrag_back(3,i,iset)*uscdiff(i)
12418 ! write(iout,*) "i",i," utheta",utheta(i)," ugamma",ugamma(i),
12419 ! & " uconst_back",uconst_back
12420 utheta(i)=dsqrt(utheta(i))
12421 ugamma(i)=dsqrt(ugamma(i))
12422 uscdiff(i)=dsqrt(uscdiff(i))
12425 end subroutine Econstr_back
12426 !-----------------------------------------------------------------------------
12427 ! energy_p_new-sep_barrier.F
12428 !-----------------------------------------------------------------------------
12429 real(kind=8) function sscale(r)
12430 ! include "COMMON.SPLITELE"
12431 real(kind=8) :: r,gamm
12432 if(r.lt.r_cut-rlamb) then
12434 else if(r.le.r_cut.and.r.ge.r_cut-rlamb) then
12435 gamm=(r-(r_cut-rlamb))/rlamb
12436 sscale=1.0d0+gamm*gamm*(2*gamm-3.0d0)
12441 end function sscale
12442 real(kind=8) function sscale_grad(r)
12443 ! include "COMMON.SPLITELE"
12444 real(kind=8) :: r,gamm
12445 if(r.lt.r_cut-rlamb) then
12447 else if(r.le.r_cut.and.r.ge.r_cut-rlamb) then
12448 gamm=(r-(r_cut-rlamb))/rlamb
12449 sscale_grad=gamm*(6*gamm-6.0d0)/rlamb
12454 end function sscale_grad
12456 !!!!!!!!!! PBCSCALE
12457 real(kind=8) function sscale_ele(r)
12458 ! include "COMMON.SPLITELE"
12459 real(kind=8) :: r,gamm
12460 if(r.lt.r_cut_ele-rlamb_ele) then
12462 else if(r.le.r_cut_ele.and.r.ge.r_cut_ele-rlamb_ele) then
12463 gamm=(r-(r_cut_ele-rlamb_ele))/rlamb_ele
12464 sscale_ele=1.0d0+gamm*gamm*(2*gamm-3.0d0)
12469 end function sscale_ele
12471 real(kind=8) function sscagrad_ele(r)
12472 real(kind=8) :: r,gamm
12473 ! include "COMMON.SPLITELE"
12474 if(r.lt.r_cut_ele-rlamb_ele) then
12476 else if(r.le.r_cut_ele.and.r.ge.r_cut_ele-rlamb_ele) then
12477 gamm=(r-(r_cut_ele-rlamb_ele))/rlamb_ele
12478 sscagrad_ele=gamm*(6*gamm-6.0d0)/rlamb_ele
12483 end function sscagrad_ele
12484 real(kind=8) function sscalelip(r)
12485 real(kind=8) r,gamm
12486 sscalelip=1.0d0+r*r*(2.0d0*r-3.0d0)
12488 end function sscalelip
12489 !C-----------------------------------------------------------------------
12490 real(kind=8) function sscagradlip(r)
12491 real(kind=8) r,gamm
12492 sscagradlip=r*(6.0d0*r-6.0d0)
12494 end function sscagradlip
12497 !-----------------------------------------------------------------------------
12498 subroutine elj_long(evdw)
12500 ! This subroutine calculates the interaction energy of nonbonded side chains
12501 ! assuming the LJ potential of interaction.
12503 ! implicit real*8 (a-h,o-z)
12504 ! include 'DIMENSIONS'
12505 ! include 'COMMON.GEO'
12506 ! include 'COMMON.VAR'
12507 ! include 'COMMON.LOCAL'
12508 ! include 'COMMON.CHAIN'
12509 ! include 'COMMON.DERIV'
12510 ! include 'COMMON.INTERACT'
12511 ! include 'COMMON.TORSION'
12512 ! include 'COMMON.SBRIDGE'
12513 ! include 'COMMON.NAMES'
12514 ! include 'COMMON.IOUNITS'
12515 ! include 'COMMON.CONTACTS'
12516 real(kind=8),parameter :: accur=1.0d-10
12517 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
12518 !el local variables
12519 integer :: i,iint,j,k,itypi,itypi1,itypj
12520 real(kind=8) :: xi,yi,zi,xj,yj,zj,rij,sss,rrij,fac,eps0ij
12521 real(kind=8) :: e1,e2,evdwij,evdw
12522 ! write(iout,*)'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
12524 do i=iatsc_s,iatsc_e
12526 if (itypi.eq.ntyp1) cycle
12527 itypi1=itype(i+1,1)
12532 ! Calculate SC interaction energy.
12534 do iint=1,nint_gr(i)
12535 !d write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
12536 !d & 'iend=',iend(i,iint)
12537 do j=istart(i,iint),iend(i,iint)
12539 if (itypj.eq.ntyp1) cycle
12543 rij=xj*xj+yj*yj+zj*zj
12544 sss=sscale(dsqrt(rij)/sigma(itypi,itypj))
12545 if (sss.lt.1.0d0) then
12547 eps0ij=eps(itypi,itypj)
12549 e1=fac*fac*aa_aq(itypi,itypj)
12550 e2=fac*bb_aq(itypi,itypj)
12552 evdw=evdw+(1.0d0-sss)*evdwij
12554 ! Calculate the components of the gradient in DC and X
12556 fac=-rrij*(e1+evdwij)*(1.0d0-sss)
12561 gvdwx(k,i)=gvdwx(k,i)-gg(k)
12562 gvdwx(k,j)=gvdwx(k,j)+gg(k)
12563 gvdwc(k,i)=gvdwc(k,i)-gg(k)
12564 gvdwc(k,j)=gvdwc(k,j)+gg(k)
12572 gvdwc(j,i)=expon*gvdwc(j,i)
12573 gvdwx(j,i)=expon*gvdwx(j,i)
12576 !******************************************************************************
12580 ! To save time, the factor of EXPON has been extracted from ALL components
12581 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
12584 !******************************************************************************
12586 end subroutine elj_long
12587 !-----------------------------------------------------------------------------
12588 subroutine elj_short(evdw)
12590 ! This subroutine calculates the interaction energy of nonbonded side chains
12591 ! assuming the LJ potential of interaction.
12593 ! implicit real*8 (a-h,o-z)
12594 ! include 'DIMENSIONS'
12595 ! include 'COMMON.GEO'
12596 ! include 'COMMON.VAR'
12597 ! include 'COMMON.LOCAL'
12598 ! include 'COMMON.CHAIN'
12599 ! include 'COMMON.DERIV'
12600 ! include 'COMMON.INTERACT'
12601 ! include 'COMMON.TORSION'
12602 ! include 'COMMON.SBRIDGE'
12603 ! include 'COMMON.NAMES'
12604 ! include 'COMMON.IOUNITS'
12605 ! include 'COMMON.CONTACTS'
12606 real(kind=8),parameter :: accur=1.0d-10
12607 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
12608 !el local variables
12609 integer :: i,iint,j,k,itypi,itypi1,itypj,num_conti
12610 real(kind=8) :: xi,yi,zi,xj,yj,zj,rij,sss,rrij,fac,eps0ij
12611 real(kind=8) :: e1,e2,evdwij,evdw
12612 ! write(iout,*)'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
12614 do i=iatsc_s,iatsc_e
12616 if (itypi.eq.ntyp1) cycle
12617 itypi1=itype(i+1,1)
12624 ! Calculate SC interaction energy.
12626 do iint=1,nint_gr(i)
12627 !d write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
12628 !d & 'iend=',iend(i,iint)
12629 do j=istart(i,iint),iend(i,iint)
12631 if (itypj.eq.ntyp1) cycle
12635 ! Change 12/1/95 to calculate four-body interactions
12636 rij=xj*xj+yj*yj+zj*zj
12637 sss=sscale(dsqrt(rij)/sigma(itypi,itypj))
12638 if (sss.gt.0.0d0) then
12640 eps0ij=eps(itypi,itypj)
12642 e1=fac*fac*aa_aq(itypi,itypj)
12643 e2=fac*bb_aq(itypi,itypj)
12645 evdw=evdw+sss*evdwij
12647 ! Calculate the components of the gradient in DC and X
12649 fac=-rrij*(e1+evdwij)*sss
12654 gvdwx(k,i)=gvdwx(k,i)-gg(k)
12655 gvdwx(k,j)=gvdwx(k,j)+gg(k)
12656 gvdwc(k,i)=gvdwc(k,i)-gg(k)
12657 gvdwc(k,j)=gvdwc(k,j)+gg(k)
12665 gvdwc(j,i)=expon*gvdwc(j,i)
12666 gvdwx(j,i)=expon*gvdwx(j,i)
12669 !******************************************************************************
12673 ! To save time, the factor of EXPON has been extracted from ALL components
12674 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
12677 !******************************************************************************
12679 end subroutine elj_short
12680 !-----------------------------------------------------------------------------
12681 subroutine eljk_long(evdw)
12683 ! This subroutine calculates the interaction energy of nonbonded side chains
12684 ! assuming the LJK potential of interaction.
12686 ! implicit real*8 (a-h,o-z)
12687 ! include 'DIMENSIONS'
12688 ! include 'COMMON.GEO'
12689 ! include 'COMMON.VAR'
12690 ! include 'COMMON.LOCAL'
12691 ! include 'COMMON.CHAIN'
12692 ! include 'COMMON.DERIV'
12693 ! include 'COMMON.INTERACT'
12694 ! include 'COMMON.IOUNITS'
12695 ! include 'COMMON.NAMES'
12696 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
12698 !el local variables
12699 integer :: i,iint,j,k,itypi,itypi1,itypj
12700 real(kind=8) :: rrij,r_inv_ij,xj,yj,zj,xi,yi,zi,fac,evdw,&
12701 fac_augm,e_augm,rij,sss,r_shift_inv,e1,e2,evdwij
12702 ! print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
12704 do i=iatsc_s,iatsc_e
12706 if (itypi.eq.ntyp1) cycle
12707 itypi1=itype(i+1,1)
12712 ! Calculate SC interaction energy.
12714 do iint=1,nint_gr(i)
12715 do j=istart(i,iint),iend(i,iint)
12717 if (itypj.eq.ntyp1) cycle
12721 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
12722 fac_augm=rrij**expon
12723 e_augm=augm(itypi,itypj)*fac_augm
12724 r_inv_ij=dsqrt(rrij)
12726 sss=sscale(rij/sigma(itypi,itypj))
12727 if (sss.lt.1.0d0) then
12728 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
12729 fac=r_shift_inv**expon
12730 e1=fac*fac*aa_aq(itypi,itypj)
12731 e2=fac*bb_aq(itypi,itypj)
12732 evdwij=e_augm+e1+e2
12733 !d sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
12734 !d epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
12735 !d write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
12736 !d & restyp(itypi,1),i,restyp(itypj,1),j,aa(itypi,itypj),
12737 !d & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
12738 !d & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
12739 !d & (c(k,i),k=1,3),(c(k,j),k=1,3)
12740 evdw=evdw+(1.0d0-sss)*evdwij
12742 ! Calculate the components of the gradient in DC and X
12744 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
12745 fac=fac*(1.0d0-sss)
12750 gvdwx(k,i)=gvdwx(k,i)-gg(k)
12751 gvdwx(k,j)=gvdwx(k,j)+gg(k)
12752 gvdwc(k,i)=gvdwc(k,i)-gg(k)
12753 gvdwc(k,j)=gvdwc(k,j)+gg(k)
12761 gvdwc(j,i)=expon*gvdwc(j,i)
12762 gvdwx(j,i)=expon*gvdwx(j,i)
12766 end subroutine eljk_long
12767 !-----------------------------------------------------------------------------
12768 subroutine eljk_short(evdw)
12770 ! This subroutine calculates the interaction energy of nonbonded side chains
12771 ! assuming the LJK potential of interaction.
12773 ! implicit real*8 (a-h,o-z)
12774 ! include 'DIMENSIONS'
12775 ! include 'COMMON.GEO'
12776 ! include 'COMMON.VAR'
12777 ! include 'COMMON.LOCAL'
12778 ! include 'COMMON.CHAIN'
12779 ! include 'COMMON.DERIV'
12780 ! include 'COMMON.INTERACT'
12781 ! include 'COMMON.IOUNITS'
12782 ! include 'COMMON.NAMES'
12783 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
12785 !el local variables
12786 integer :: i,iint,j,k,itypi,itypi1,itypj
12787 real(kind=8) :: rrij,r_inv_ij,xj,yj,zj,xi,yi,zi,fac,evdw,&
12788 fac_augm,e_augm,rij,sss,r_shift_inv,e1,e2,evdwij
12789 ! print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
12791 do i=iatsc_s,iatsc_e
12793 if (itypi.eq.ntyp1) cycle
12794 itypi1=itype(i+1,1)
12799 ! Calculate SC interaction energy.
12801 do iint=1,nint_gr(i)
12802 do j=istart(i,iint),iend(i,iint)
12804 if (itypj.eq.ntyp1) cycle
12808 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
12809 fac_augm=rrij**expon
12810 e_augm=augm(itypi,itypj)*fac_augm
12811 r_inv_ij=dsqrt(rrij)
12813 sss=sscale(rij/sigma(itypi,itypj))
12814 if (sss.gt.0.0d0) then
12815 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
12816 fac=r_shift_inv**expon
12817 e1=fac*fac*aa_aq(itypi,itypj)
12818 e2=fac*bb_aq(itypi,itypj)
12819 evdwij=e_augm+e1+e2
12820 !d sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
12821 !d epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
12822 !d write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
12823 !d & restyp(itypi,1),i,restyp(itypj,1),j,aa(itypi,itypj),
12824 !d & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
12825 !d & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
12826 !d & (c(k,i),k=1,3),(c(k,j),k=1,3)
12827 evdw=evdw+sss*evdwij
12829 ! Calculate the components of the gradient in DC and X
12831 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
12837 gvdwx(k,i)=gvdwx(k,i)-gg(k)
12838 gvdwx(k,j)=gvdwx(k,j)+gg(k)
12839 gvdwc(k,i)=gvdwc(k,i)-gg(k)
12840 gvdwc(k,j)=gvdwc(k,j)+gg(k)
12848 gvdwc(j,i)=expon*gvdwc(j,i)
12849 gvdwx(j,i)=expon*gvdwx(j,i)
12853 end subroutine eljk_short
12854 !-----------------------------------------------------------------------------
12855 subroutine ebp_long(evdw)
12857 ! This subroutine calculates the interaction energy of nonbonded side chains
12858 ! assuming the Berne-Pechukas potential of interaction.
12861 ! implicit real*8 (a-h,o-z)
12862 ! include 'DIMENSIONS'
12863 ! include 'COMMON.GEO'
12864 ! include 'COMMON.VAR'
12865 ! include 'COMMON.LOCAL'
12866 ! include 'COMMON.CHAIN'
12867 ! include 'COMMON.DERIV'
12868 ! include 'COMMON.NAMES'
12869 ! include 'COMMON.INTERACT'
12870 ! include 'COMMON.IOUNITS'
12871 ! include 'COMMON.CALC'
12873 !el integer :: icall
12874 !el common /srutu/ icall
12875 ! double precision rrsave(maxdim)
12877 !el local variables
12878 integer :: iint,itypi,itypi1,itypj
12879 real(kind=8) :: rrij,xi,yi,zi,fac
12880 real(kind=8) :: sss,e1,e2,evdw,sigm,epsi
12882 ! print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
12884 ! if (icall.eq.0) then
12890 do i=iatsc_s,iatsc_e
12892 if (itypi.eq.ntyp1) cycle
12893 itypi1=itype(i+1,1)
12897 dxi=dc_norm(1,nres+i)
12898 dyi=dc_norm(2,nres+i)
12899 dzi=dc_norm(3,nres+i)
12900 ! dsci_inv=dsc_inv(itypi)
12901 dsci_inv=vbld_inv(i+nres)
12903 ! Calculate SC interaction energy.
12905 do iint=1,nint_gr(i)
12906 do j=istart(i,iint),iend(i,iint)
12909 if (itypj.eq.ntyp1) cycle
12910 ! dscj_inv=dsc_inv(itypj)
12911 dscj_inv=vbld_inv(j+nres)
12912 chi1=chi(itypi,itypj)
12913 chi2=chi(itypj,itypi)
12920 alf12=0.5D0*(alf1+alf2)
12924 dxj=dc_norm(1,nres+j)
12925 dyj=dc_norm(2,nres+j)
12926 dzj=dc_norm(3,nres+j)
12927 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
12929 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
12931 if (sss.lt.1.0d0) then
12933 ! Calculate the angle-dependent terms of energy & contributions to derivatives.
12935 ! Calculate whole angle-dependent part of epsilon and contributions
12936 ! to its derivatives
12937 fac=(rrij*sigsq)**expon2
12938 e1=fac*fac*aa_aq(itypi,itypj)
12939 e2=fac*bb_aq(itypi,itypj)
12940 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
12941 eps2der=evdwij*eps3rt
12942 eps3der=evdwij*eps2rt
12943 evdwij=evdwij*eps2rt*eps3rt
12944 evdw=evdw+evdwij*(1.0d0-sss)
12946 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
12947 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
12948 !d write (iout,'(2(a3,i3,2x),15(0pf7.3))')
12949 !d & restyp(itypi,1),i,restyp(itypj,1),j,
12950 !d & epsi,sigm,chi1,chi2,chip1,chip2,
12951 !d & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
12952 !d & om1,om2,om12,1.0D0/dsqrt(rrij),
12955 ! Calculate gradient components.
12956 e1=e1*eps1*eps2rt**2*eps3rt**2
12957 fac=-expon*(e1+evdwij)
12960 ! Calculate radial part of the gradient
12964 ! Calculate the angular part of the gradient and sum add the contributions
12965 ! to the appropriate components of the Cartesian gradient.
12966 call sc_grad_scale(1.0d0-sss)
12973 end subroutine ebp_long
12974 !-----------------------------------------------------------------------------
12975 subroutine ebp_short(evdw)
12977 ! This subroutine calculates the interaction energy of nonbonded side chains
12978 ! assuming the Berne-Pechukas potential of interaction.
12981 ! implicit real*8 (a-h,o-z)
12982 ! include 'DIMENSIONS'
12983 ! include 'COMMON.GEO'
12984 ! include 'COMMON.VAR'
12985 ! include 'COMMON.LOCAL'
12986 ! include 'COMMON.CHAIN'
12987 ! include 'COMMON.DERIV'
12988 ! include 'COMMON.NAMES'
12989 ! include 'COMMON.INTERACT'
12990 ! include 'COMMON.IOUNITS'
12991 ! include 'COMMON.CALC'
12993 !el integer :: icall
12994 !el common /srutu/ icall
12995 ! double precision rrsave(maxdim)
12997 !el local variables
12998 integer :: iint,itypi,itypi1,itypj
12999 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi
13000 real(kind=8) :: sss,e1,e2,evdw
13002 ! print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
13004 ! if (icall.eq.0) then
13010 do i=iatsc_s,iatsc_e
13012 if (itypi.eq.ntyp1) cycle
13013 itypi1=itype(i+1,1)
13017 dxi=dc_norm(1,nres+i)
13018 dyi=dc_norm(2,nres+i)
13019 dzi=dc_norm(3,nres+i)
13020 ! dsci_inv=dsc_inv(itypi)
13021 dsci_inv=vbld_inv(i+nres)
13023 ! Calculate SC interaction energy.
13025 do iint=1,nint_gr(i)
13026 do j=istart(i,iint),iend(i,iint)
13029 if (itypj.eq.ntyp1) cycle
13030 ! dscj_inv=dsc_inv(itypj)
13031 dscj_inv=vbld_inv(j+nres)
13032 chi1=chi(itypi,itypj)
13033 chi2=chi(itypj,itypi)
13040 alf12=0.5D0*(alf1+alf2)
13044 dxj=dc_norm(1,nres+j)
13045 dyj=dc_norm(2,nres+j)
13046 dzj=dc_norm(3,nres+j)
13047 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
13049 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
13051 if (sss.gt.0.0d0) then
13053 ! Calculate the angle-dependent terms of energy & contributions to derivatives.
13055 ! Calculate whole angle-dependent part of epsilon and contributions
13056 ! to its derivatives
13057 fac=(rrij*sigsq)**expon2
13058 e1=fac*fac*aa_aq(itypi,itypj)
13059 e2=fac*bb_aq(itypi,itypj)
13060 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
13061 eps2der=evdwij*eps3rt
13062 eps3der=evdwij*eps2rt
13063 evdwij=evdwij*eps2rt*eps3rt
13064 evdw=evdw+evdwij*sss
13066 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
13067 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
13068 !d write (iout,'(2(a3,i3,2x),15(0pf7.3))')
13069 !d & restyp(itypi,1),i,restyp(itypj,1),j,
13070 !d & epsi,sigm,chi1,chi2,chip1,chip2,
13071 !d & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
13072 !d & om1,om2,om12,1.0D0/dsqrt(rrij),
13075 ! Calculate gradient components.
13076 e1=e1*eps1*eps2rt**2*eps3rt**2
13077 fac=-expon*(e1+evdwij)
13080 ! Calculate radial part of the gradient
13084 ! Calculate the angular part of the gradient and sum add the contributions
13085 ! to the appropriate components of the Cartesian gradient.
13086 call sc_grad_scale(sss)
13093 end subroutine ebp_short
13094 !-----------------------------------------------------------------------------
13095 subroutine egb_long(evdw)
13097 ! This subroutine calculates the interaction energy of nonbonded side chains
13098 ! assuming the Gay-Berne potential of interaction.
13101 ! implicit real*8 (a-h,o-z)
13102 ! include 'DIMENSIONS'
13103 ! include 'COMMON.GEO'
13104 ! include 'COMMON.VAR'
13105 ! include 'COMMON.LOCAL'
13106 ! include 'COMMON.CHAIN'
13107 ! include 'COMMON.DERIV'
13108 ! include 'COMMON.NAMES'
13109 ! include 'COMMON.INTERACT'
13110 ! include 'COMMON.IOUNITS'
13111 ! include 'COMMON.CALC'
13112 ! include 'COMMON.CONTROL'
13114 !el local variables
13115 integer :: iint,itypi,itypi1,itypj,subchap
13116 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,sig,sig0ij,rij_shift
13117 real(kind=8) :: sss,e1,e2,evdw,sss_grad
13118 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
13119 dist_temp, dist_init,aa,bb,fracinbuf,sslipi,sslipj,&
13120 ssgradlipi,ssgradlipj
13124 !cccc energy_dec=.false.
13125 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
13128 ! if (icall.eq.0) lprn=.false.
13130 do i=iatsc_s,iatsc_e
13132 if (itypi.eq.ntyp1) cycle
13133 itypi1=itype(i+1,1)
13137 xi=mod(xi,boxxsize)
13138 if (xi.lt.0) xi=xi+boxxsize
13139 yi=mod(yi,boxysize)
13140 if (yi.lt.0) yi=yi+boxysize
13141 zi=mod(zi,boxzsize)
13142 if (zi.lt.0) zi=zi+boxzsize
13143 if ((zi.gt.bordlipbot) &
13144 .and.(zi.lt.bordliptop)) then
13145 !C the energy transfer exist
13146 if (zi.lt.buflipbot) then
13147 !C what fraction I am in
13149 ((zi-bordlipbot)/lipbufthick)
13150 !C lipbufthick is thickenes of lipid buffore
13151 sslipi=sscalelip(fracinbuf)
13152 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
13153 elseif (zi.gt.bufliptop) then
13154 fracinbuf=1.0d0-((bordliptop-zi)/lipbufthick)
13155 sslipi=sscalelip(fracinbuf)
13156 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
13166 dxi=dc_norm(1,nres+i)
13167 dyi=dc_norm(2,nres+i)
13168 dzi=dc_norm(3,nres+i)
13169 ! dsci_inv=dsc_inv(itypi)
13170 dsci_inv=vbld_inv(i+nres)
13171 ! write (iout,*) "i",i,dsc_inv(itypi),dsci_inv,1.0d0/vbld(i+nres)
13172 ! write (iout,*) "dcnori",dxi*dxi+dyi*dyi+dzi*dzi
13174 ! Calculate SC interaction energy.
13176 do iint=1,nint_gr(i)
13177 do j=istart(i,iint),iend(i,iint)
13178 IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
13179 ! call dyn_ssbond_ene(i,j,evdwij)
13181 ! if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
13182 ! 'evdw',i,j,evdwij,' ss'
13183 ! if (energy_dec) write (iout,*) &
13184 ! 'evdw',i,j,evdwij,' ss'
13185 ! do k=j+1,iend(i,iint)
13186 !C search over all next residues
13187 ! if (dyn_ss_mask(k)) then
13188 !C check if they are cysteins
13189 !C write(iout,*) 'k=',k
13191 !c write(iout,*) "PRZED TRI", evdwij
13192 ! evdwij_przed_tri=evdwij
13193 ! call triple_ssbond_ene(i,j,k,evdwij)
13194 !c if(evdwij_przed_tri.ne.evdwij) then
13195 !c write (iout,*) "TRI:", evdwij, evdwij_przed_tri
13198 !c write(iout,*) "PO TRI", evdwij
13199 !C call the energy function that removes the artifical triple disulfide
13200 !C bond the soubroutine is located in ssMD.F
13202 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
13203 'evdw',i,j,evdwij,'tss'
13204 ! endif!dyn_ss_mask(k)
13210 if (itypj.eq.ntyp1) cycle
13211 ! dscj_inv=dsc_inv(itypj)
13212 dscj_inv=vbld_inv(j+nres)
13213 ! write (iout,*) "j",j,dsc_inv(itypj),dscj_inv,
13214 ! & 1.0d0/vbld(j+nres)
13215 ! write (iout,*) "i",i," j", j," itype",itype(i,1),itype(j,1)
13216 sig0ij=sigma(itypi,itypj)
13217 chi1=chi(itypi,itypj)
13218 chi2=chi(itypj,itypi)
13225 alf12=0.5D0*(alf1+alf2)
13229 ! Searching for nearest neighbour
13230 xj=mod(xj,boxxsize)
13231 if (xj.lt.0) xj=xj+boxxsize
13232 yj=mod(yj,boxysize)
13233 if (yj.lt.0) yj=yj+boxysize
13234 zj=mod(zj,boxzsize)
13235 if (zj.lt.0) zj=zj+boxzsize
13236 if ((zj.gt.bordlipbot) &
13237 .and.(zj.lt.bordliptop)) then
13238 !C the energy transfer exist
13239 if (zj.lt.buflipbot) then
13240 !C what fraction I am in
13242 ((zj-bordlipbot)/lipbufthick)
13243 !C lipbufthick is thickenes of lipid buffore
13244 sslipj=sscalelip(fracinbuf)
13245 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
13246 elseif (zj.gt.bufliptop) then
13247 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
13248 sslipj=sscalelip(fracinbuf)
13249 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
13258 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
13259 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
13260 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
13261 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
13263 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
13271 xj=xj_safe+xshift*boxxsize
13272 yj=yj_safe+yshift*boxysize
13273 zj=zj_safe+zshift*boxzsize
13274 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
13275 if(dist_temp.lt.dist_init) then
13276 dist_init=dist_temp
13285 if (subchap.eq.1) then
13295 dxj=dc_norm(1,nres+j)
13296 dyj=dc_norm(2,nres+j)
13297 dzj=dc_norm(3,nres+j)
13298 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
13300 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
13301 sss_ele_cut=sscale_ele(1.0d0/(rij*sigma(itypi,itypj)))
13302 sss_ele_grad=sscagrad_ele(1.0d0/(rij*sigma(itypi,itypj)))
13303 sss_grad=sscale_grad(1.0d0/(rij*sigmaii(itypi,itypj)))
13304 if (sss_ele_cut.le.0.0) cycle
13305 if (sss.lt.1.0d0) then
13307 ! Calculate angle-dependent terms of energy and contributions to their
13311 sig=sig0ij*dsqrt(sigsq)
13312 rij_shift=1.0D0/rij-sig+sig0ij
13313 ! for diagnostics; uncomment
13314 ! rij_shift=1.2*sig0ij
13315 ! I hate to put IF's in the loops, but here don't have another choice!!!!
13316 if (rij_shift.le.0.0D0) then
13318 !d write (iout,'(2(a3,i3,2x),17(0pf7.3))')
13319 !d & restyp(itypi,1),i,restyp(itypj,1),j,
13320 !d & rij_shift,1.0D0/rij,sig,sig0ij,sigsq,1-dsqrt(sigsq)
13324 !---------------------------------------------------------------
13325 rij_shift=1.0D0/rij_shift
13326 fac=rij_shift**expon
13329 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
13330 eps2der=evdwij*eps3rt
13331 eps3der=evdwij*eps2rt
13332 ! write (iout,*) "sigsq",sigsq," sig",sig," eps2rt",eps2rt,
13333 ! & " eps3rt",eps3rt," eps1",eps1," e1",e1," e2",e2
13334 evdwij=evdwij*eps2rt*eps3rt
13335 evdw=evdw+evdwij*(1.0d0-sss)*sss_ele_cut
13337 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
13338 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
13339 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
13340 restyp(itypi,1),i,restyp(itypj,1),j,&
13341 epsi,sigm,chi1,chi2,chip1,chip2,&
13342 eps1,eps2rt**2,eps3rt**2,sig,sig0ij,&
13343 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
13347 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
13349 ! if (energy_dec) write (iout,*) &
13350 ! 'evdw',i,j,evdwij,"egb_long"
13352 ! Calculate gradient components.
13353 e1=e1*eps1*eps2rt**2*eps3rt**2
13354 fac=-expon*(e1+evdwij)*rij_shift
13357 fac=fac+evdwij*(sss_ele_grad/sss_ele_cut&
13358 /sigma(itypi,itypj)*rij-sss_grad/(1.0-sss)*rij &
13359 /sigmaii(itypi,itypj))
13361 ! Calculate the radial part of the gradient
13365 ! Calculate angular part of the gradient.
13366 call sc_grad_scale(1.0d0-sss)
13372 ! write (iout,*) "Number of loop steps in EGB:",ind
13373 !ccc energy_dec=.false.
13375 end subroutine egb_long
13376 !-----------------------------------------------------------------------------
13377 subroutine egb_short(evdw)
13379 ! This subroutine calculates the interaction energy of nonbonded side chains
13380 ! assuming the Gay-Berne potential of interaction.
13383 ! implicit real*8 (a-h,o-z)
13384 ! include 'DIMENSIONS'
13385 ! include 'COMMON.GEO'
13386 ! include 'COMMON.VAR'
13387 ! include 'COMMON.LOCAL'
13388 ! include 'COMMON.CHAIN'
13389 ! include 'COMMON.DERIV'
13390 ! include 'COMMON.NAMES'
13391 ! include 'COMMON.INTERACT'
13392 ! include 'COMMON.IOUNITS'
13393 ! include 'COMMON.CALC'
13394 ! include 'COMMON.CONTROL'
13396 !el local variables
13397 integer :: iint,itypi,itypi1,itypj,subchap
13398 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,sig0ij,sig
13399 real(kind=8) :: sss,e1,e2,evdw,rij_shift,sss_grad
13400 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
13401 dist_temp, dist_init,aa,bb,fracinbuf,sslipi,sslipj,&
13402 ssgradlipi,ssgradlipj
13404 !cccc energy_dec=.false.
13405 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
13408 ! if (icall.eq.0) lprn=.false.
13410 do i=iatsc_s,iatsc_e
13412 if (itypi.eq.ntyp1) cycle
13413 itypi1=itype(i+1,1)
13417 xi=mod(xi,boxxsize)
13418 if (xi.lt.0) xi=xi+boxxsize
13419 yi=mod(yi,boxysize)
13420 if (yi.lt.0) yi=yi+boxysize
13421 zi=mod(zi,boxzsize)
13422 if (zi.lt.0) zi=zi+boxzsize
13423 if ((zi.gt.bordlipbot) &
13424 .and.(zi.lt.bordliptop)) then
13425 !C the energy transfer exist
13426 if (zi.lt.buflipbot) then
13427 !C what fraction I am in
13429 ((zi-bordlipbot)/lipbufthick)
13430 !C lipbufthick is thickenes of lipid buffore
13431 sslipi=sscalelip(fracinbuf)
13432 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
13433 elseif (zi.gt.bufliptop) then
13434 fracinbuf=1.0d0-((bordliptop-zi)/lipbufthick)
13435 sslipi=sscalelip(fracinbuf)
13436 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
13446 dxi=dc_norm(1,nres+i)
13447 dyi=dc_norm(2,nres+i)
13448 dzi=dc_norm(3,nres+i)
13449 ! dsci_inv=dsc_inv(itypi)
13450 dsci_inv=vbld_inv(i+nres)
13452 dxi=dc_norm(1,nres+i)
13453 dyi=dc_norm(2,nres+i)
13454 dzi=dc_norm(3,nres+i)
13455 ! dsci_inv=dsc_inv(itypi)
13456 dsci_inv=vbld_inv(i+nres)
13457 ! write (iout,*) "i",i,dsc_inv(itypi),dsci_inv,1.0d0/vbld(i+nres)
13458 ! write (iout,*) "dcnori",dxi*dxi+dyi*dyi+dzi*dzi
13460 ! Calculate SC interaction energy.
13462 do iint=1,nint_gr(i)
13463 do j=istart(i,iint),iend(i,iint)
13464 IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
13465 call dyn_ssbond_ene(i,j,evdwij)
13467 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
13468 'evdw',i,j,evdwij,' ss'
13469 do k=j+1,iend(i,iint)
13470 !C search over all next residues
13471 if (dyn_ss_mask(k)) then
13472 !C check if they are cysteins
13473 !C write(iout,*) 'k=',k
13475 !c write(iout,*) "PRZED TRI", evdwij
13476 ! evdwij_przed_tri=evdwij
13477 call triple_ssbond_ene(i,j,k,evdwij)
13478 !c if(evdwij_przed_tri.ne.evdwij) then
13479 !c write (iout,*) "TRI:", evdwij, evdwij_przed_tri
13482 !c write(iout,*) "PO TRI", evdwij
13483 !C call the energy function that removes the artifical triple disulfide
13484 !C bond the soubroutine is located in ssMD.F
13486 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
13487 'evdw',i,j,evdwij,'tss'
13488 endif!dyn_ss_mask(k)
13491 ! if (energy_dec) write (iout,*) &
13492 ! 'evdw',i,j,evdwij,' ss'
13496 if (itypj.eq.ntyp1) cycle
13497 ! dscj_inv=dsc_inv(itypj)
13498 dscj_inv=vbld_inv(j+nres)
13499 ! write (iout,*) "j",j,dsc_inv(itypj),dscj_inv,
13500 ! & 1.0d0/vbld(j+nres)
13501 ! write (iout,*) "i",i," j", j," itype",itype(i,1),itype(j,1)
13502 sig0ij=sigma(itypi,itypj)
13503 chi1=chi(itypi,itypj)
13504 chi2=chi(itypj,itypi)
13511 alf12=0.5D0*(alf1+alf2)
13512 ! xj=c(1,nres+j)-xi
13513 ! yj=c(2,nres+j)-yi
13514 ! zj=c(3,nres+j)-zi
13518 ! Searching for nearest neighbour
13519 xj=mod(xj,boxxsize)
13520 if (xj.lt.0) xj=xj+boxxsize
13521 yj=mod(yj,boxysize)
13522 if (yj.lt.0) yj=yj+boxysize
13523 zj=mod(zj,boxzsize)
13524 if (zj.lt.0) zj=zj+boxzsize
13525 if ((zj.gt.bordlipbot) &
13526 .and.(zj.lt.bordliptop)) then
13527 !C the energy transfer exist
13528 if (zj.lt.buflipbot) then
13529 !C what fraction I am in
13531 ((zj-bordlipbot)/lipbufthick)
13532 !C lipbufthick is thickenes of lipid buffore
13533 sslipj=sscalelip(fracinbuf)
13534 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
13535 elseif (zj.gt.bufliptop) then
13536 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
13537 sslipj=sscalelip(fracinbuf)
13538 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
13547 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
13548 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
13549 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
13550 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
13552 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
13561 xj=xj_safe+xshift*boxxsize
13562 yj=yj_safe+yshift*boxysize
13563 zj=zj_safe+zshift*boxzsize
13564 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
13565 if(dist_temp.lt.dist_init) then
13566 dist_init=dist_temp
13575 if (subchap.eq.1) then
13585 dxj=dc_norm(1,nres+j)
13586 dyj=dc_norm(2,nres+j)
13587 dzj=dc_norm(3,nres+j)
13588 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
13590 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
13591 sss_grad=sscale_grad(1.0d0/(rij*sigmaii(itypi,itypj)))
13592 sss_ele_cut=sscale_ele(1.0d0/(rij*sigma(itypi,itypj)))
13593 sss_ele_grad=sscagrad_ele(1.0d0/(rij*sigma(itypi,itypj)))
13594 if (sss_ele_cut.le.0.0) cycle
13596 if (sss.gt.0.0d0) then
13598 ! Calculate angle-dependent terms of energy and contributions to their
13602 sig=sig0ij*dsqrt(sigsq)
13603 rij_shift=1.0D0/rij-sig+sig0ij
13604 ! for diagnostics; uncomment
13605 ! rij_shift=1.2*sig0ij
13606 ! I hate to put IF's in the loops, but here don't have another choice!!!!
13607 if (rij_shift.le.0.0D0) then
13609 !d write (iout,'(2(a3,i3,2x),17(0pf7.3))')
13610 !d & restyp(itypi,1),i,restyp(itypj,1),j,
13611 !d & rij_shift,1.0D0/rij,sig,sig0ij,sigsq,1-dsqrt(sigsq)
13615 !---------------------------------------------------------------
13616 rij_shift=1.0D0/rij_shift
13617 fac=rij_shift**expon
13620 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
13621 eps2der=evdwij*eps3rt
13622 eps3der=evdwij*eps2rt
13623 ! write (iout,*) "sigsq",sigsq," sig",sig," eps2rt",eps2rt,
13624 ! & " eps3rt",eps3rt," eps1",eps1," e1",e1," e2",e2
13625 evdwij=evdwij*eps2rt*eps3rt
13626 evdw=evdw+evdwij*sss*sss_ele_cut
13628 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
13629 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
13630 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
13631 restyp(itypi,1),i,restyp(itypj,1),j,&
13632 epsi,sigm,chi1,chi2,chip1,chip2,&
13633 eps1,eps2rt**2,eps3rt**2,sig,sig0ij,&
13634 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
13638 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
13640 ! if (energy_dec) write (iout,*) &
13641 ! 'evdw',i,j,evdwij,"egb_short"
13643 ! Calculate gradient components.
13644 e1=e1*eps1*eps2rt**2*eps3rt**2
13645 fac=-expon*(e1+evdwij)*rij_shift
13648 fac=fac+evdwij*(sss_ele_grad/sss_ele_cut&
13649 /sigma(itypi,itypj)*rij+sss_grad/sss*rij &
13650 /sigmaii(itypi,itypj))
13653 ! Calculate the radial part of the gradient
13657 ! Calculate angular part of the gradient.
13658 call sc_grad_scale(sss)
13664 ! write (iout,*) "Number of loop steps in EGB:",ind
13665 !ccc energy_dec=.false.
13667 end subroutine egb_short
13668 !-----------------------------------------------------------------------------
13669 subroutine egbv_long(evdw)
13671 ! This subroutine calculates the interaction energy of nonbonded side chains
13672 ! assuming the Gay-Berne-Vorobjev potential of interaction.
13675 ! implicit real*8 (a-h,o-z)
13676 ! include 'DIMENSIONS'
13677 ! include 'COMMON.GEO'
13678 ! include 'COMMON.VAR'
13679 ! include 'COMMON.LOCAL'
13680 ! include 'COMMON.CHAIN'
13681 ! include 'COMMON.DERIV'
13682 ! include 'COMMON.NAMES'
13683 ! include 'COMMON.INTERACT'
13684 ! include 'COMMON.IOUNITS'
13685 ! include 'COMMON.CALC'
13687 !el integer :: icall
13688 !el common /srutu/ icall
13690 !el local variables
13691 integer :: iint,itypi,itypi1,itypj
13692 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,r0ij,sig,sig0ij
13693 real(kind=8) :: sss,e1,e2,evdw,fac_augm,e_augm,rij_shift
13695 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
13698 ! if (icall.eq.0) lprn=.true.
13700 do i=iatsc_s,iatsc_e
13702 if (itypi.eq.ntyp1) cycle
13703 itypi1=itype(i+1,1)
13707 dxi=dc_norm(1,nres+i)
13708 dyi=dc_norm(2,nres+i)
13709 dzi=dc_norm(3,nres+i)
13710 ! dsci_inv=dsc_inv(itypi)
13711 dsci_inv=vbld_inv(i+nres)
13713 ! Calculate SC interaction energy.
13715 do iint=1,nint_gr(i)
13716 do j=istart(i,iint),iend(i,iint)
13719 if (itypj.eq.ntyp1) cycle
13720 ! dscj_inv=dsc_inv(itypj)
13721 dscj_inv=vbld_inv(j+nres)
13722 sig0ij=sigma(itypi,itypj)
13723 r0ij=r0(itypi,itypj)
13724 chi1=chi(itypi,itypj)
13725 chi2=chi(itypj,itypi)
13732 alf12=0.5D0*(alf1+alf2)
13736 dxj=dc_norm(1,nres+j)
13737 dyj=dc_norm(2,nres+j)
13738 dzj=dc_norm(3,nres+j)
13739 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
13742 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
13744 if (sss.lt.1.0d0) then
13746 ! Calculate angle-dependent terms of energy and contributions to their
13750 sig=sig0ij*dsqrt(sigsq)
13751 rij_shift=1.0D0/rij-sig+r0ij
13752 ! I hate to put IF's in the loops, but here don't have another choice!!!!
13753 if (rij_shift.le.0.0D0) then
13758 !---------------------------------------------------------------
13759 rij_shift=1.0D0/rij_shift
13760 fac=rij_shift**expon
13761 e1=fac*fac*aa_aq(itypi,itypj)
13762 e2=fac*bb_aq(itypi,itypj)
13763 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
13764 eps2der=evdwij*eps3rt
13765 eps3der=evdwij*eps2rt
13766 fac_augm=rrij**expon
13767 e_augm=augm(itypi,itypj)*fac_augm
13768 evdwij=evdwij*eps2rt*eps3rt
13769 evdw=evdw+(evdwij+e_augm)*(1.0d0-sss)
13771 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
13772 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
13773 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
13774 restyp(itypi,1),i,restyp(itypj,1),j,&
13775 epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),&
13776 chi1,chi2,chip1,chip2,&
13777 eps1,eps2rt**2,eps3rt**2,&
13778 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
13781 ! Calculate gradient components.
13782 e1=e1*eps1*eps2rt**2*eps3rt**2
13783 fac=-expon*(e1+evdwij)*rij_shift
13785 fac=rij*fac-2*expon*rrij*e_augm
13786 ! Calculate the radial part of the gradient
13790 ! Calculate angular part of the gradient.
13791 call sc_grad_scale(1.0d0-sss)
13796 end subroutine egbv_long
13797 !-----------------------------------------------------------------------------
13798 subroutine egbv_short(evdw)
13800 ! This subroutine calculates the interaction energy of nonbonded side chains
13801 ! assuming the Gay-Berne-Vorobjev potential of interaction.
13804 ! implicit real*8 (a-h,o-z)
13805 ! include 'DIMENSIONS'
13806 ! include 'COMMON.GEO'
13807 ! include 'COMMON.VAR'
13808 ! include 'COMMON.LOCAL'
13809 ! include 'COMMON.CHAIN'
13810 ! include 'COMMON.DERIV'
13811 ! include 'COMMON.NAMES'
13812 ! include 'COMMON.INTERACT'
13813 ! include 'COMMON.IOUNITS'
13814 ! include 'COMMON.CALC'
13816 !el integer :: icall
13817 !el common /srutu/ icall
13819 !el local variables
13820 integer :: iint,itypi,itypi1,itypj
13821 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,rij_shift
13822 real(kind=8) :: sss,e1,e2,evdw,r0ij,sig,sig0ij,fac_augm,e_augm
13824 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
13827 ! if (icall.eq.0) lprn=.true.
13829 do i=iatsc_s,iatsc_e
13831 if (itypi.eq.ntyp1) cycle
13832 itypi1=itype(i+1,1)
13836 dxi=dc_norm(1,nres+i)
13837 dyi=dc_norm(2,nres+i)
13838 dzi=dc_norm(3,nres+i)
13839 ! dsci_inv=dsc_inv(itypi)
13840 dsci_inv=vbld_inv(i+nres)
13842 ! Calculate SC interaction energy.
13844 do iint=1,nint_gr(i)
13845 do j=istart(i,iint),iend(i,iint)
13848 if (itypj.eq.ntyp1) cycle
13849 ! dscj_inv=dsc_inv(itypj)
13850 dscj_inv=vbld_inv(j+nres)
13851 sig0ij=sigma(itypi,itypj)
13852 r0ij=r0(itypi,itypj)
13853 chi1=chi(itypi,itypj)
13854 chi2=chi(itypj,itypi)
13861 alf12=0.5D0*(alf1+alf2)
13865 dxj=dc_norm(1,nres+j)
13866 dyj=dc_norm(2,nres+j)
13867 dzj=dc_norm(3,nres+j)
13868 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
13871 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
13873 if (sss.gt.0.0d0) then
13875 ! Calculate angle-dependent terms of energy and contributions to their
13879 sig=sig0ij*dsqrt(sigsq)
13880 rij_shift=1.0D0/rij-sig+r0ij
13881 ! I hate to put IF's in the loops, but here don't have another choice!!!!
13882 if (rij_shift.le.0.0D0) then
13887 !---------------------------------------------------------------
13888 rij_shift=1.0D0/rij_shift
13889 fac=rij_shift**expon
13890 e1=fac*fac*aa_aq(itypi,itypj)
13891 e2=fac*bb_aq(itypi,itypj)
13892 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
13893 eps2der=evdwij*eps3rt
13894 eps3der=evdwij*eps2rt
13895 fac_augm=rrij**expon
13896 e_augm=augm(itypi,itypj)*fac_augm
13897 evdwij=evdwij*eps2rt*eps3rt
13898 evdw=evdw+(evdwij+e_augm)*sss
13900 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
13901 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
13902 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
13903 restyp(itypi,1),i,restyp(itypj,1),j,&
13904 epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),&
13905 chi1,chi2,chip1,chip2,&
13906 eps1,eps2rt**2,eps3rt**2,&
13907 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
13910 ! Calculate gradient components.
13911 e1=e1*eps1*eps2rt**2*eps3rt**2
13912 fac=-expon*(e1+evdwij)*rij_shift
13914 fac=rij*fac-2*expon*rrij*e_augm
13915 ! Calculate the radial part of the gradient
13919 ! Calculate angular part of the gradient.
13920 call sc_grad_scale(sss)
13925 end subroutine egbv_short
13926 !-----------------------------------------------------------------------------
13927 subroutine eelec_scale(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
13929 ! This subroutine calculates the average interaction energy and its gradient
13930 ! in the virtual-bond vectors between non-adjacent peptide groups, based on
13931 ! the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
13932 ! The potential depends both on the distance of peptide-group centers and on
13933 ! the orientation of the CA-CA virtual bonds.
13935 ! implicit real*8 (a-h,o-z)
13941 ! include 'DIMENSIONS'
13942 ! include 'COMMON.CONTROL'
13943 ! include 'COMMON.SETUP'
13944 ! include 'COMMON.IOUNITS'
13945 ! include 'COMMON.GEO'
13946 ! include 'COMMON.VAR'
13947 ! include 'COMMON.LOCAL'
13948 ! include 'COMMON.CHAIN'
13949 ! include 'COMMON.DERIV'
13950 ! include 'COMMON.INTERACT'
13951 ! include 'COMMON.CONTACTS'
13952 ! include 'COMMON.TORSION'
13953 ! include 'COMMON.VECTORS'
13954 ! include 'COMMON.FFIELD'
13955 ! include 'COMMON.TIME1'
13956 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg
13957 real(kind=8),dimension(3,3) ::erder,uryg,urzg,vryg,vrzg
13958 real(kind=8),dimension(2,2) :: acipa !el,a_temp
13959 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
13960 real(kind=8),dimension(4) :: muij
13961 !el integer :: num_conti,j1,j2
13962 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
13963 !el dz_normi,xmedi,ymedi,zmedi
13964 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
13965 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
13966 !el num_conti,j1,j2
13967 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
13969 real(kind=8) :: scal_el=1.0d0
13971 real(kind=8) :: scal_el=0.5d0
13974 ! 13-go grudnia roku pamietnego...
13975 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
13976 0.0d0,1.0d0,0.0d0,&
13977 0.0d0,0.0d0,1.0d0/),shape(unmat))
13978 !el local variables
13980 real(kind=8) :: fac
13981 real(kind=8) :: dxj,dyj,dzj
13982 real(kind=8) :: ees,evdw1,eel_loc,eello_turn3,eello_turn4
13984 ! allocate(num_cont_hb(nres)) !(maxres)
13985 !d write(iout,*) 'In EELEC'
13987 !d write(iout,*) 'Type',i
13988 !d write(iout,*) 'B1',B1(:,i)
13989 !d write(iout,*) 'B2',B2(:,i)
13990 !d write(iout,*) 'CC',CC(:,:,i)
13991 !d write(iout,*) 'DD',DD(:,:,i)
13992 !d write(iout,*) 'EE',EE(:,:,i)
13994 !d call check_vecgrad
13996 if (icheckgrad.eq.1) then
13998 fac=1.0d0/dsqrt(scalar(dc(1,i),dc(1,i)))
14000 dc_norm(k,i)=dc(k,i)*fac
14002 ! write (iout,*) 'i',i,' fac',fac
14005 if (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
14006 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 .or. &
14007 wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) then
14008 ! call vec_and_deriv
14012 ! print *, "before set matrices"
14014 ! print *,"after set martices"
14016 time_mat=time_mat+MPI_Wtime()-time01
14020 !d write (iout,*) 'i=',i
14022 !d write (iout,'(i5,2f10.5)') k,uy(k,i),uz(k,i)
14025 !d write (iout,'(f10.5,2x,3f10.5,2x,3f10.5)')
14026 !d & uz(k,i),(uzgrad(k,l,1,i),l=1,3),(uzgrad(k,l,2,i),l=1,3)
14039 !d print '(a)','Enter EELEC'
14040 !d write (iout,*) 'iatel_s=',iatel_s,' iatel_e=',iatel_e
14041 ! if (.not.allocated(gel_loc_loc)) allocate(gel_loc_loc(nres)) !(maxvar)(maxvar=6*maxres)
14042 ! if (.not.allocated(gcorr_loc)) allocate(gcorr_loc(nres)) !(maxvar)(maxvar=6*maxres)
14044 gel_loc_loc(i)=0.0d0
14049 ! 9/27/08 AL Split the interaction loop to ensure load balancing of turn terms
14051 ! Loop over i,i+2 and i,i+3 pairs of the peptide groups
14053 do i=iturn3_start,iturn3_end
14054 if (itype(i,1).eq.ntyp1.or. itype(i+1,1).eq.ntyp1 &
14055 .or. itype(i+2,1).eq.ntyp1 .or. itype(i+3,1).eq.ntyp1) cycle
14059 dx_normi=dc_norm(1,i)
14060 dy_normi=dc_norm(2,i)
14061 dz_normi=dc_norm(3,i)
14062 xmedi=c(1,i)+0.5d0*dxi
14063 ymedi=c(2,i)+0.5d0*dyi
14064 zmedi=c(3,i)+0.5d0*dzi
14065 xmedi=dmod(xmedi,boxxsize)
14066 if (xmedi.lt.0) xmedi=xmedi+boxxsize
14067 ymedi=dmod(ymedi,boxysize)
14068 if (ymedi.lt.0) ymedi=ymedi+boxysize
14069 zmedi=dmod(zmedi,boxzsize)
14070 if (zmedi.lt.0) zmedi=zmedi+boxzsize
14072 call eelecij_scale(i,i+2,ees,evdw1,eel_loc)
14073 if (wturn3.gt.0.0d0) call eturn3(i,eello_turn3)
14074 num_cont_hb(i)=num_conti
14076 do i=iturn4_start,iturn4_end
14077 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1 &
14078 .or. itype(i+3,1).eq.ntyp1 &
14079 .or. itype(i+4,1).eq.ntyp1) cycle
14083 dx_normi=dc_norm(1,i)
14084 dy_normi=dc_norm(2,i)
14085 dz_normi=dc_norm(3,i)
14086 xmedi=c(1,i)+0.5d0*dxi
14087 ymedi=c(2,i)+0.5d0*dyi
14088 zmedi=c(3,i)+0.5d0*dzi
14089 xmedi=dmod(xmedi,boxxsize)
14090 if (xmedi.lt.0) xmedi=xmedi+boxxsize
14091 ymedi=dmod(ymedi,boxysize)
14092 if (ymedi.lt.0) ymedi=ymedi+boxysize
14093 zmedi=dmod(zmedi,boxzsize)
14094 if (zmedi.lt.0) zmedi=zmedi+boxzsize
14095 num_conti=num_cont_hb(i)
14096 call eelecij_scale(i,i+3,ees,evdw1,eel_loc)
14097 if (wturn4.gt.0.0d0 .and. itype(i+2,1).ne.ntyp1) &
14098 call eturn4(i,eello_turn4)
14099 num_cont_hb(i)=num_conti
14102 ! Loop over all pairs of interacting peptide groups except i,i+2 and i,i+3
14104 do i=iatel_s,iatel_e
14105 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
14109 dx_normi=dc_norm(1,i)
14110 dy_normi=dc_norm(2,i)
14111 dz_normi=dc_norm(3,i)
14112 xmedi=c(1,i)+0.5d0*dxi
14113 ymedi=c(2,i)+0.5d0*dyi
14114 zmedi=c(3,i)+0.5d0*dzi
14115 xmedi=dmod(xmedi,boxxsize)
14116 if (xmedi.lt.0) xmedi=xmedi+boxxsize
14117 ymedi=dmod(ymedi,boxysize)
14118 if (ymedi.lt.0) ymedi=ymedi+boxysize
14119 zmedi=dmod(zmedi,boxzsize)
14120 if (zmedi.lt.0) zmedi=zmedi+boxzsize
14121 ! write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
14122 num_conti=num_cont_hb(i)
14123 do j=ielstart(i),ielend(i)
14124 if (itype(j,1).eq.ntyp1 .or. itype(j+1,1).eq.ntyp1) cycle
14125 call eelecij_scale(i,j,ees,evdw1,eel_loc)
14127 num_cont_hb(i)=num_conti
14129 ! write (iout,*) "Number of loop steps in EELEC:",ind
14131 !d write (iout,'(i3,3f10.5,5x,3f10.5)')
14132 !d & i,(gel_loc(k,i),k=1,3),gel_loc_loc(i)
14134 ! 12/7/99 Adam eello_turn3 will be considered as a separate energy term
14135 !cc eel_loc=eel_loc+eello_turn3
14136 !d print *,"Processor",fg_rank," t_eelecij",t_eelecij
14138 end subroutine eelec_scale
14139 !-----------------------------------------------------------------------------
14140 subroutine eelecij_scale(i,j,ees,evdw1,eel_loc)
14141 ! implicit real*8 (a-h,o-z)
14144 ! include 'DIMENSIONS'
14148 ! include 'COMMON.CONTROL'
14149 ! include 'COMMON.IOUNITS'
14150 ! include 'COMMON.GEO'
14151 ! include 'COMMON.VAR'
14152 ! include 'COMMON.LOCAL'
14153 ! include 'COMMON.CHAIN'
14154 ! include 'COMMON.DERIV'
14155 ! include 'COMMON.INTERACT'
14156 ! include 'COMMON.CONTACTS'
14157 ! include 'COMMON.TORSION'
14158 ! include 'COMMON.VECTORS'
14159 ! include 'COMMON.FFIELD'
14160 ! include 'COMMON.TIME1'
14161 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg,xtemp
14162 real(kind=8),dimension(3,3) :: erder,uryg,urzg,vryg,vrzg
14163 real(kind=8),dimension(2,2) :: acipa !el,a_temp
14164 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
14165 real(kind=8),dimension(4) :: muij
14166 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
14167 dist_temp, dist_init,sss_grad
14168 integer xshift,yshift,zshift
14170 !el integer :: num_conti,j1,j2
14171 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
14172 !el dz_normi,xmedi,ymedi,zmedi
14173 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
14174 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
14175 !el num_conti,j1,j2
14176 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
14178 real(kind=8) :: scal_el=1.0d0
14180 real(kind=8) :: scal_el=0.5d0
14183 ! 13-go grudnia roku pamietnego...
14184 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
14185 0.0d0,1.0d0,0.0d0,&
14186 0.0d0,0.0d0,1.0d0/),shape(unmat))
14187 !el local variables
14188 integer :: i,j,k,l,iteli,itelj,kkk,kkll,m,isubchap
14189 real(kind=8) :: aaa,bbb,ael6i,ael3i,dxj,dyj,dzj
14190 real(kind=8) :: xj,yj,zj,rij,rrmij,rmij,sss,r3ij,r6ij,fac
14191 real(kind=8) :: cosa,cosb,cosg,ev1,ev2,fac3,fac4,evdwij
14192 real(kind=8) :: el1,el2,eesij,ees0ij,r0ij,fcont,fprimcont
14193 real(kind=8) :: ees0tmp,ees0pij1,ees0mij1,ees0pijp,ees0mijp
14194 real(kind=8) :: ees,evdw1,eel_loc,eel_loc_ij,dx_normj,dy_normj,&
14195 dz_normj,facvdw,facel,fac1,facr,ecosa,ecosb,ecosg,&
14196 ury,urz,vry,vrz,a22der,a23der,a32der,a33der,cosa4,&
14197 wij,cosbg1,cosbg2,ees0pij,ees0mij,fac3p,ecosa1,ecosb1,&
14198 ecosg1,ecosa2,ecosb2,ecosg2,ecosap,ecosbp,ecosgp,&
14199 ecosam,ecosbm,ecosgm,ghalf,time00
14200 ! integer :: maxconts
14201 ! maxconts = nres/4
14202 ! allocate(gacontp_hb1(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
14203 ! allocate(gacontp_hb2(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
14204 ! allocate(gacontp_hb3(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
14205 ! allocate(gacontm_hb1(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
14206 ! allocate(gacontm_hb2(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
14207 ! allocate(gacontm_hb3(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
14208 ! allocate(gacont_hbr(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
14209 ! allocate(grij_hb_cont(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
14210 ! allocate(facont_hb(maxconts,nres)) !(maxconts,maxres)
14211 ! allocate(ees0p(maxconts,nres)) !(maxconts,maxres)
14212 ! allocate(ees0m(maxconts,nres)) !(maxconts,maxres)
14213 ! allocate(d_cont(maxconts,nres)) !(maxconts,maxres)
14214 ! allocate(jcont_hb(maxconts,nres)) !(maxconts,maxres)
14216 ! allocate(a_chuj(2,2,maxconts,nres)) !(2,2,maxconts,maxres)
14217 ! allocate(a_chuj_der(2,2,3,5,maxconts,nres)) !(2,2,3,5,maxconts,maxres)
14222 !d write (iout,*) "eelecij",i,j
14226 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
14227 aaa=app(iteli,itelj)
14228 bbb=bpp(iteli,itelj)
14229 ael6i=ael6(iteli,itelj)
14230 ael3i=ael3(iteli,itelj)
14234 dx_normj=dc_norm(1,j)
14235 dy_normj=dc_norm(2,j)
14236 dz_normj=dc_norm(3,j)
14237 ! xj=c(1,j)+0.5D0*dxj-xmedi
14238 ! yj=c(2,j)+0.5D0*dyj-ymedi
14239 ! zj=c(3,j)+0.5D0*dzj-zmedi
14240 xj=c(1,j)+0.5D0*dxj
14241 yj=c(2,j)+0.5D0*dyj
14242 zj=c(3,j)+0.5D0*dzj
14243 xj=mod(xj,boxxsize)
14244 if (xj.lt.0) xj=xj+boxxsize
14245 yj=mod(yj,boxysize)
14246 if (yj.lt.0) yj=yj+boxysize
14247 zj=mod(zj,boxzsize)
14248 if (zj.lt.0) zj=zj+boxzsize
14250 dist_init=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
14257 xj=xj_safe+xshift*boxxsize
14258 yj=yj_safe+yshift*boxysize
14259 zj=zj_safe+zshift*boxzsize
14260 dist_temp=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
14261 if(dist_temp.lt.dist_init) then
14262 dist_init=dist_temp
14271 if (isubchap.eq.1) then
14282 rij=xj*xj+yj*yj+zj*zj
14286 ! For extracting the short-range part of Evdwpp
14287 sss=sscale(rij/rpp(iteli,itelj))
14288 sss_ele_cut=sscale_ele(rij)
14289 sss_ele_grad=sscagrad_ele(rij)
14290 sss_grad=sscale_grad((rij/rpp(iteli,itelj)))
14291 ! sss_ele_cut=1.0d0
14292 ! sss_ele_grad=0.0d0
14293 if (sss_ele_cut.le.0.0) go to 128
14297 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
14298 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
14299 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
14300 fac=cosa-3.0D0*cosb*cosg
14302 ! 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
14303 if (j.eq.i+2) ev1=scal_el*ev1
14308 el1=fac3*(4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg))
14311 ! 12/26/95 - for the evaluation of multi-body H-bonding interactions
14312 ees0ij=4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg)
14313 ees=ees+eesij*sss_ele_cut
14314 evdw1=evdw1+evdwij*(1.0d0-sss)*sss_ele_cut
14315 !d write(iout,'(2(2i3,2x),7(1pd12.4)/2(3(1pd12.4),5x)/)')
14316 !d & iteli,i,itelj,j,aaa,bbb,ael6i,ael3i,
14317 !d & 1.0D0/dsqrt(rrmij),evdwij,eesij,
14318 !d & xmedi,ymedi,zmedi,xj,yj,zj
14320 if (energy_dec) then
14321 write (iout,'(a6,2i5,0pf7.3,f7.3)') 'evdw1',i,j,evdwij,sss
14322 write (iout,'(a6,2i5,0pf7.3)') 'ees',i,j,eesij
14326 ! Calculate contributions to the Cartesian gradient.
14329 facvdw=-6*rrmij*(ev1+evdwij)*(1.0d0-sss)*sss_ele_cut
14330 facel=-3*rrmij*(el1+eesij)*sss_ele_cut
14336 ! Radial derivatives. First process both termini of the fragment (i,j)
14338 ggg(1)=facel*xj+sss_ele_grad*rmij*eesij*xj
14339 ggg(2)=facel*yj+sss_ele_grad*rmij*eesij*yj
14340 ggg(3)=facel*zj+sss_ele_grad*rmij*eesij*zj
14342 ! ghalf=0.5D0*ggg(k)
14343 ! gelc(k,i)=gelc(k,i)+ghalf
14344 ! gelc(k,j)=gelc(k,j)+ghalf
14346 ! 9/28/08 AL Gradient compotents will be summed only at the end
14348 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
14349 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
14352 ! Loop over residues i+1 thru j-1.
14356 !grad gelc(l,k)=gelc(l,k)+ggg(l)
14359 ggg(1)=facvdw*xj+sss_ele_grad*rmij*evdwij*xj*(1.0d0-sss) &
14360 -evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*xj
14361 ggg(2)=facvdw*yj+sss_ele_grad*rmij*evdwij*yj*(1.0d0-sss) &
14362 -evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*yj
14363 ggg(3)=facvdw*zj+sss_ele_grad*rmij*evdwij*zj*(1.0d0-sss) &
14364 -evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*zj
14366 ! ghalf=0.5D0*ggg(k)
14367 ! gvdwpp(k,i)=gvdwpp(k,i)+ghalf
14368 ! gvdwpp(k,j)=gvdwpp(k,j)+ghalf
14370 ! 9/28/08 AL Gradient compotents will be summed only at the end
14372 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
14373 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
14376 ! Loop over residues i+1 thru j-1.
14380 !grad gvdwpp(l,k)=gvdwpp(l,k)+ggg(l)
14384 facvdw=(ev1+evdwij)*(1.0d0-sss)*sss_ele_cut
14385 facel=(el1+eesij)*sss_ele_cut
14387 fac=-3*rrmij*(facvdw+facvdw+facel)
14392 ! Radial derivatives. First process both termini of the fragment (i,j)
14398 ! ghalf=0.5D0*ggg(k)
14399 ! gelc(k,i)=gelc(k,i)+ghalf
14400 ! gelc(k,j)=gelc(k,j)+ghalf
14402 ! 9/28/08 AL Gradient compotents will be summed only at the end
14404 gelc_long(k,j)=gelc(k,j)+ggg(k)
14405 gelc_long(k,i)=gelc(k,i)-ggg(k)
14408 ! Loop over residues i+1 thru j-1.
14412 !grad gelc(l,k)=gelc(l,k)+ggg(l)
14415 ! 9/28/08 AL Gradient compotents will be summed only at the end
14420 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
14421 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
14427 ecosa=2.0D0*fac3*fac1+fac4
14430 ecosb=(fac3*(fac1*cosg+cosb)+cosg*fac4)
14431 ecosg=(fac3*(fac1*cosb+cosg)+cosb*fac4)
14433 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
14434 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
14436 !d print '(2i3,2(3(1pd14.5),3x))',i,j,(dcosb(k),k=1,3),
14437 !d & (dcosg(k),k=1,3)
14439 ggg(k)=(ecosb*dcosb(k)+ecosg*dcosg(k) )*sss_ele_cut
14442 ! ghalf=0.5D0*ggg(k)
14443 ! gelc(k,i)=gelc(k,i)+ghalf
14444 ! & +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
14445 ! & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
14446 ! gelc(k,j)=gelc(k,j)+ghalf
14447 ! & +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
14448 ! & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
14452 !grad gelc(l,k)=gelc(l,k)+ggg(l)
14456 gelc(k,i)=gelc(k,i) &
14457 +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
14458 + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)&
14460 gelc(k,j)=gelc(k,j) &
14461 +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
14462 + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
14464 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
14465 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
14467 IF (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
14468 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 &
14469 .or. wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
14471 ! 9/25/99 Mixed third-order local-electrostatic terms. The local-interaction
14472 ! energy of a peptide unit is assumed in the form of a second-order
14473 ! Fourier series in the angles lambda1 and lambda2 (see Nishikawa et al.
14474 ! Macromolecules, 1974, 7, 797-806 for definition). This correlation terms
14475 ! are computed for EVERY pair of non-contiguous peptide groups.
14477 if (j.lt.nres-1) then
14488 muij(kkk)=mu(k,i)*mu(l,j)
14491 !d write (iout,*) 'EELEC: i',i,' j',j
14492 !d write (iout,*) 'j',j,' j1',j1,' j2',j2
14493 !d write(iout,*) 'muij',muij
14494 ury=scalar(uy(1,i),erij)
14495 urz=scalar(uz(1,i),erij)
14496 vry=scalar(uy(1,j),erij)
14497 vrz=scalar(uz(1,j),erij)
14498 a22=scalar(uy(1,i),uy(1,j))-3*ury*vry
14499 a23=scalar(uy(1,i),uz(1,j))-3*ury*vrz
14500 a32=scalar(uz(1,i),uy(1,j))-3*urz*vry
14501 a33=scalar(uz(1,i),uz(1,j))-3*urz*vrz
14502 fac=dsqrt(-ael6i)*r3ij
14507 !d write (iout,'(4i5,4f10.5)')
14508 !d & i,itortyp(itype(i,1)),j,itortyp(itype(j,1)),a22,a23,a32,a33
14509 !d write (iout,'(6f10.5)') (muij(k),k=1,4),fac,eel_loc_ij
14510 !d write (iout,'(2(3f10.5,5x)/2(3f10.5,5x))') uy(:,i),uz(:,i),
14511 !d & uy(:,j),uz(:,j)
14512 !d write (iout,'(4f10.5)')
14513 !d & scalar(uy(1,i),uy(1,j)),scalar(uy(1,i),uz(1,j)),
14514 !d & scalar(uz(1,i),uy(1,j)),scalar(uz(1,i),uz(1,j))
14515 !d write (iout,'(4f10.5)') ury,urz,vry,vrz
14516 !d write (iout,'(9f10.5/)')
14517 !d & fac22,a22,fac23,a23,fac32,a32,fac33,a33,eel_loc_ij
14518 ! Derivatives of the elements of A in virtual-bond vectors
14519 call unormderiv(erij(1),unmat(1,1),rmij,erder(1,1))
14521 uryg(k,1)=scalar(erder(1,k),uy(1,i))
14522 uryg(k,2)=scalar(uygrad(1,k,1,i),erij(1))
14523 uryg(k,3)=scalar(uygrad(1,k,2,i),erij(1))
14524 urzg(k,1)=scalar(erder(1,k),uz(1,i))
14525 urzg(k,2)=scalar(uzgrad(1,k,1,i),erij(1))
14526 urzg(k,3)=scalar(uzgrad(1,k,2,i),erij(1))
14527 vryg(k,1)=scalar(erder(1,k),uy(1,j))
14528 vryg(k,2)=scalar(uygrad(1,k,1,j),erij(1))
14529 vryg(k,3)=scalar(uygrad(1,k,2,j),erij(1))
14530 vrzg(k,1)=scalar(erder(1,k),uz(1,j))
14531 vrzg(k,2)=scalar(uzgrad(1,k,1,j),erij(1))
14532 vrzg(k,3)=scalar(uzgrad(1,k,2,j),erij(1))
14534 ! Compute radial contributions to the gradient
14552 ! Add the contributions coming from er
14555 agg(k,1)=agg(k,1)+fac3*(uryg(k,1)*vry+vryg(k,1)*ury)
14556 agg(k,2)=agg(k,2)+fac3*(uryg(k,1)*vrz+vrzg(k,1)*ury)
14557 agg(k,3)=agg(k,3)+fac3*(urzg(k,1)*vry+vryg(k,1)*urz)
14558 agg(k,4)=agg(k,4)+fac3*(urzg(k,1)*vrz+vrzg(k,1)*urz)
14561 ! Derivatives in DC(i)
14562 !grad ghalf1=0.5d0*agg(k,1)
14563 !grad ghalf2=0.5d0*agg(k,2)
14564 !grad ghalf3=0.5d0*agg(k,3)
14565 !grad ghalf4=0.5d0*agg(k,4)
14566 aggi(k,1)=fac*(scalar(uygrad(1,k,1,i),uy(1,j)) &
14567 -3.0d0*uryg(k,2)*vry)!+ghalf1
14568 aggi(k,2)=fac*(scalar(uygrad(1,k,1,i),uz(1,j)) &
14569 -3.0d0*uryg(k,2)*vrz)!+ghalf2
14570 aggi(k,3)=fac*(scalar(uzgrad(1,k,1,i),uy(1,j)) &
14571 -3.0d0*urzg(k,2)*vry)!+ghalf3
14572 aggi(k,4)=fac*(scalar(uzgrad(1,k,1,i),uz(1,j)) &
14573 -3.0d0*urzg(k,2)*vrz)!+ghalf4
14574 ! Derivatives in DC(i+1)
14575 aggi1(k,1)=fac*(scalar(uygrad(1,k,2,i),uy(1,j)) &
14576 -3.0d0*uryg(k,3)*vry)!+agg(k,1)
14577 aggi1(k,2)=fac*(scalar(uygrad(1,k,2,i),uz(1,j)) &
14578 -3.0d0*uryg(k,3)*vrz)!+agg(k,2)
14579 aggi1(k,3)=fac*(scalar(uzgrad(1,k,2,i),uy(1,j)) &
14580 -3.0d0*urzg(k,3)*vry)!+agg(k,3)
14581 aggi1(k,4)=fac*(scalar(uzgrad(1,k,2,i),uz(1,j)) &
14582 -3.0d0*urzg(k,3)*vrz)!+agg(k,4)
14583 ! Derivatives in DC(j)
14584 aggj(k,1)=fac*(scalar(uygrad(1,k,1,j),uy(1,i)) &
14585 -3.0d0*vryg(k,2)*ury)!+ghalf1
14586 aggj(k,2)=fac*(scalar(uzgrad(1,k,1,j),uy(1,i)) &
14587 -3.0d0*vrzg(k,2)*ury)!+ghalf2
14588 aggj(k,3)=fac*(scalar(uygrad(1,k,1,j),uz(1,i)) &
14589 -3.0d0*vryg(k,2)*urz)!+ghalf3
14590 aggj(k,4)=fac*(scalar(uzgrad(1,k,1,j),uz(1,i)) &
14591 -3.0d0*vrzg(k,2)*urz)!+ghalf4
14592 ! Derivatives in DC(j+1) or DC(nres-1)
14593 aggj1(k,1)=fac*(scalar(uygrad(1,k,2,j),uy(1,i)) &
14594 -3.0d0*vryg(k,3)*ury)
14595 aggj1(k,2)=fac*(scalar(uzgrad(1,k,2,j),uy(1,i)) &
14596 -3.0d0*vrzg(k,3)*ury)
14597 aggj1(k,3)=fac*(scalar(uygrad(1,k,2,j),uz(1,i)) &
14598 -3.0d0*vryg(k,3)*urz)
14599 aggj1(k,4)=fac*(scalar(uzgrad(1,k,2,j),uz(1,i)) &
14600 -3.0d0*vrzg(k,3)*urz)
14601 !grad if (j.eq.nres-1 .and. i.lt.j-2) then
14603 !grad aggj1(k,l)=aggj1(k,l)+agg(k,l)
14616 aggi(k,l)=-aggi(k,l)
14617 aggi1(k,l)=-aggi1(k,l)
14618 aggj(k,l)=-aggj(k,l)
14619 aggj1(k,l)=-aggj1(k,l)
14622 if (j.lt.nres-1) then
14628 aggi(k,l)=-aggi(k,l)
14629 aggi1(k,l)=-aggi1(k,l)
14630 aggj(k,l)=-aggj(k,l)
14631 aggj1(k,l)=-aggj1(k,l)
14642 aggi(k,l)=-aggi(k,l)
14643 aggi1(k,l)=-aggi1(k,l)
14644 aggj(k,l)=-aggj(k,l)
14645 aggj1(k,l)=-aggj1(k,l)
14650 IF (wel_loc.gt.0.0d0) THEN
14651 ! Contribution to the local-electrostatic energy coming from the i-j pair
14652 eel_loc_ij=a22*muij(1)+a23*muij(2)+a32*muij(3) &
14654 ! write (iout,*) 'i',i,' j',j,' eel_loc_ij',eel_loc_ij
14656 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
14657 'eelloc',i,j,eel_loc_ij
14658 ! write (iout,*) a22,muij(1),a23,muij(2),a32,muij(3) !d
14660 eel_loc=eel_loc+eel_loc_ij*sss_ele_cut
14661 ! Partial derivatives in virtual-bond dihedral angles gamma
14663 gel_loc_loc(i-1)=gel_loc_loc(i-1)+ &
14664 (a22*muder(1,i)*mu(1,j)+a23*muder(1,i)*mu(2,j) &
14665 +a32*muder(2,i)*mu(1,j)+a33*muder(2,i)*mu(2,j)) &
14667 gel_loc_loc(j-1)=gel_loc_loc(j-1)+ &
14668 (a22*mu(1,i)*muder(1,j)+a23*mu(1,i)*muder(2,j) &
14669 +a32*mu(2,i)*muder(1,j)+a33*mu(2,i)*muder(2,j)) &
14675 ! Derivatives of eello in DC(i+1) thru DC(j-1) or DC(nres-2)
14677 ggg(l)=(agg(l,1)*muij(1)+ &
14678 agg(l,2)*muij(2)+agg(l,3)*muij(3)+agg(l,4)*muij(4))&
14680 +eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
14682 gel_loc_long(l,j)=gel_loc_long(l,j)+ggg(l)
14683 gel_loc_long(l,i)=gel_loc_long(l,i)-ggg(l)
14684 !grad ghalf=0.5d0*ggg(l)
14685 !grad gel_loc(l,i)=gel_loc(l,i)+ghalf
14686 !grad gel_loc(l,j)=gel_loc(l,j)+ghalf
14690 !grad gel_loc(l,k)=gel_loc(l,k)+ggg(l)
14693 ! Remaining derivatives of eello
14695 gel_loc(l,i)=gel_loc(l,i)+(aggi(l,1)*muij(1)+ &
14696 aggi(l,2)*muij(2)+aggi(l,3)*muij(3)+aggi(l,4)*muij(4))&
14699 gel_loc(l,i+1)=gel_loc(l,i+1)+(aggi1(l,1)*muij(1)+ &
14700 aggi1(l,2)*muij(2)+aggi1(l,3)*muij(3)+aggi1(l,4)*muij(4))&
14703 gel_loc(l,j)=gel_loc(l,j)+(aggj(l,1)*muij(1)+ &
14704 aggj(l,2)*muij(2)+aggj(l,3)*muij(3)+aggj(l,4)*muij(4))&
14707 gel_loc(l,j1)=gel_loc(l,j1)+(aggj1(l,1)*muij(1)+ &
14708 aggj1(l,2)*muij(2)+aggj1(l,3)*muij(3)+aggj1(l,4)*muij(4))&
14713 ! Change 12/26/95 to calculate four-body contributions to H-bonding energy
14714 ! if (j.gt.i+1 .and. num_conti.le.maxconts) then
14715 if (wcorr+wcorr4+wcorr5+wcorr6.gt.0.0d0 &
14716 .and. num_conti.le.maxconts) then
14717 ! write (iout,*) i,j," entered corr"
14719 ! Calculate the contact function. The ith column of the array JCONT will
14720 ! contain the numbers of atoms that make contacts with the atom I (of numbers
14721 ! greater than I). The arrays FACONT and GACONT will contain the values of
14722 ! the contact function and its derivative.
14723 ! r0ij=1.02D0*rpp(iteli,itelj)
14724 ! r0ij=1.11D0*rpp(iteli,itelj)
14725 r0ij=2.20D0*rpp(iteli,itelj)
14726 ! r0ij=1.55D0*rpp(iteli,itelj)
14727 call gcont(rij,r0ij,1.0D0,0.2d0*r0ij,fcont,fprimcont)
14728 !elwrite(iout,*) "num_conti",num_conti, "maxconts",maxconts
14729 if (fcont.gt.0.0D0) then
14730 num_conti=num_conti+1
14731 if (num_conti.gt.maxconts) then
14732 !elwrite(iout,*) "num_conti",num_conti, "maxconts",maxconts
14733 write (iout,*) 'WARNING - max. # of contacts exceeded;',&
14734 ' will skip next contacts for this conf.',num_conti
14736 jcont_hb(num_conti,i)=j
14737 !d write (iout,*) "i",i," j",j," num_conti",num_conti,
14738 !d & " jcont_hb",jcont_hb(num_conti,i)
14739 IF (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. &
14740 wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
14741 ! 9/30/99 (AL) - store components necessary to evaluate higher-order loc-el
14743 d_cont(num_conti,i)=rij
14744 !d write (2,'(3e15.5)') rij,r0ij+0.2d0*r0ij,rij
14745 ! --- Electrostatic-interaction matrix ---
14746 a_chuj(1,1,num_conti,i)=a22
14747 a_chuj(1,2,num_conti,i)=a23
14748 a_chuj(2,1,num_conti,i)=a32
14749 a_chuj(2,2,num_conti,i)=a33
14750 ! --- Gradient of rij
14752 grij_hb_cont(kkk,num_conti,i)=erij(kkk)
14759 a_chuj_der(k,l,m,1,num_conti,i)=agg(m,kkll)
14760 a_chuj_der(k,l,m,2,num_conti,i)=aggi(m,kkll)
14761 a_chuj_der(k,l,m,3,num_conti,i)=aggi1(m,kkll)
14762 a_chuj_der(k,l,m,4,num_conti,i)=aggj(m,kkll)
14763 a_chuj_der(k,l,m,5,num_conti,i)=aggj1(m,kkll)
14768 IF (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) THEN
14769 ! Calculate contact energies
14771 wij=cosa-3.0D0*cosb*cosg
14774 ! fac3=dsqrt(-ael6i)/r0ij**3
14775 fac3=dsqrt(-ael6i)*r3ij
14776 ! ees0pij=dsqrt(4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1)
14777 ees0tmp=4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1
14778 if (ees0tmp.gt.0) then
14779 ees0pij=dsqrt(ees0tmp)
14783 ! ees0mij=dsqrt(4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2)
14784 ees0tmp=4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2
14785 if (ees0tmp.gt.0) then
14786 ees0mij=dsqrt(ees0tmp)
14791 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij) &
14794 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij) &
14797 ! Diagnostics. Comment out or remove after debugging!
14798 ! ees0p(num_conti,i)=0.5D0*fac3*ees0pij
14799 ! ees0m(num_conti,i)=0.5D0*fac3*ees0mij
14800 ! ees0m(num_conti,i)=0.0D0
14802 ! write (iout,*) 'i=',i,' j=',j,' rij=',rij,' r0ij=',r0ij,
14803 ! & ' ees0ij=',ees0p(num_conti,i),ees0m(num_conti,i),' fcont=',fcont
14804 ! Angular derivatives of the contact function
14805 ees0pij1=fac3/ees0pij
14806 ees0mij1=fac3/ees0mij
14807 fac3p=-3.0D0*fac3*rrmij
14808 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
14809 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
14811 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
14812 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
14813 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
14814 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
14815 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
14816 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
14817 ecosap=ecosa1+ecosa2
14818 ecosbp=ecosb1+ecosb2
14819 ecosgp=ecosg1+ecosg2
14820 ecosam=ecosa1-ecosa2
14821 ecosbm=ecosb1-ecosb2
14822 ecosgm=ecosg1-ecosg2
14831 facont_hb(num_conti,i)=fcont
14832 fprimcont=fprimcont/rij
14833 !d facont_hb(num_conti,i)=1.0D0
14834 ! Following line is for diagnostics.
14837 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
14838 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
14841 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
14842 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
14844 ! gggp(1)=gggp(1)+ees0pijp*xj
14845 ! gggp(2)=gggp(2)+ees0pijp*yj
14846 ! gggp(3)=gggp(3)+ees0pijp*zj
14847 ! gggm(1)=gggm(1)+ees0mijp*xj
14848 ! gggm(2)=gggm(2)+ees0mijp*yj
14849 ! gggm(3)=gggm(3)+ees0mijp*zj
14850 gggp(1)=gggp(1)+ees0pijp*xj &
14851 +ees0p(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
14852 gggp(2)=gggp(2)+ees0pijp*yj &
14853 +ees0p(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
14854 gggp(3)=gggp(3)+ees0pijp*zj &
14855 +ees0p(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
14857 gggm(1)=gggm(1)+ees0mijp*xj &
14858 +ees0m(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
14860 gggm(2)=gggm(2)+ees0mijp*yj &
14861 +ees0m(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
14863 gggm(3)=gggm(3)+ees0mijp*zj &
14864 +ees0m(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
14866 ! Derivatives due to the contact function
14867 gacont_hbr(1,num_conti,i)=fprimcont*xj
14868 gacont_hbr(2,num_conti,i)=fprimcont*yj
14869 gacont_hbr(3,num_conti,i)=fprimcont*zj
14872 ! 10/24/08 cgrad and ! comments indicate the parts of the code removed
14873 ! following the change of gradient-summation algorithm.
14875 !grad ghalfp=0.5D0*gggp(k)
14876 !grad ghalfm=0.5D0*gggm(k)
14877 ! gacontp_hb1(k,num_conti,i)= & !ghalfp
14878 ! +(ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
14879 ! + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
14880 ! gacontp_hb2(k,num_conti,i)= & !ghalfp
14881 ! +(ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
14882 ! + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
14883 ! gacontp_hb3(k,num_conti,i)=gggp(k)
14884 ! gacontm_hb1(k,num_conti,i)= &!ghalfm
14885 ! +(ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
14886 ! + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
14887 ! gacontm_hb2(k,num_conti,i)= & !ghalfm
14888 ! +(ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
14889 ! + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
14890 ! gacontm_hb3(k,num_conti,i)=gggm(k)
14891 gacontp_hb1(k,num_conti,i)= & !ghalfp+
14892 (ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
14893 + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
14896 gacontp_hb2(k,num_conti,i)= & !ghalfp+
14897 (ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
14898 + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
14901 gacontp_hb3(k,num_conti,i)=gggp(k) &
14904 gacontm_hb1(k,num_conti,i)= & !ghalfm+
14905 (ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
14906 + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
14909 gacontm_hb2(k,num_conti,i)= & !ghalfm+
14910 (ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
14911 + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1) &
14914 gacontm_hb3(k,num_conti,i)=gggm(k) &
14919 endif ! num_conti.le.maxconts
14922 if (wturn3.gt.0.0d0 .or. wturn4.gt.0.0d0) then
14925 ghalf=0.5d0*agg(l,k)
14926 aggi(l,k)=aggi(l,k)+ghalf
14927 aggi1(l,k)=aggi1(l,k)+agg(l,k)
14928 aggj(l,k)=aggj(l,k)+ghalf
14931 if (j.eq.nres-1 .and. i.lt.j-2) then
14934 aggj1(l,k)=aggj1(l,k)+agg(l,k)
14940 ! t_eelecij=t_eelecij+MPI_Wtime()-time00
14942 end subroutine eelecij_scale
14943 !-----------------------------------------------------------------------------
14944 subroutine evdwpp_short(evdw1)
14948 ! implicit real*8 (a-h,o-z)
14949 ! include 'DIMENSIONS'
14950 ! include 'COMMON.CONTROL'
14951 ! include 'COMMON.IOUNITS'
14952 ! include 'COMMON.GEO'
14953 ! include 'COMMON.VAR'
14954 ! include 'COMMON.LOCAL'
14955 ! include 'COMMON.CHAIN'
14956 ! include 'COMMON.DERIV'
14957 ! include 'COMMON.INTERACT'
14958 ! include 'COMMON.CONTACTS'
14959 ! include 'COMMON.TORSION'
14960 ! include 'COMMON.VECTORS'
14961 ! include 'COMMON.FFIELD'
14962 real(kind=8),dimension(3) :: ggg
14963 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
14965 real(kind=8) :: scal_el=1.0d0
14967 real(kind=8) :: scal_el=0.5d0
14969 !el local variables
14970 integer :: i,j,k,iteli,itelj,num_conti,isubchap
14971 real(kind=8) :: dxi,dyi,dzi,dxj,dyj,dzj,aaa,bbb
14972 real(kind=8) :: xj,yj,zj,rij,rrmij,sss,r3ij,r6ij,evdw1,&
14973 dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
14974 dx_normj,dy_normj,dz_normj,rmij,ev1,ev2,evdwij,facvdw
14975 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
14976 dist_temp, dist_init,sss_grad
14977 integer xshift,yshift,zshift
14981 ! write (iout,*) "iatel_s_vdw",iatel_s_vdw,
14982 ! & " iatel_e_vdw",iatel_e_vdw
14984 do i=iatel_s_vdw,iatel_e_vdw
14985 if (itype(i,1).eq.ntyp1.or. itype(i+1,1).eq.ntyp1) cycle
14989 dx_normi=dc_norm(1,i)
14990 dy_normi=dc_norm(2,i)
14991 dz_normi=dc_norm(3,i)
14992 xmedi=c(1,i)+0.5d0*dxi
14993 ymedi=c(2,i)+0.5d0*dyi
14994 zmedi=c(3,i)+0.5d0*dzi
14995 xmedi=dmod(xmedi,boxxsize)
14996 if (xmedi.lt.0) xmedi=xmedi+boxxsize
14997 ymedi=dmod(ymedi,boxysize)
14998 if (ymedi.lt.0) ymedi=ymedi+boxysize
14999 zmedi=dmod(zmedi,boxzsize)
15000 if (zmedi.lt.0) zmedi=zmedi+boxzsize
15002 ! write (iout,*) 'i',i,' ielstart',ielstart_vdw(i),
15003 ! & ' ielend',ielend_vdw(i)
15005 do j=ielstart_vdw(i),ielend_vdw(i)
15006 if (itype(j,1).eq.ntyp1 .or. itype(j+1,1).eq.ntyp1) cycle
15010 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
15011 aaa=app(iteli,itelj)
15012 bbb=bpp(iteli,itelj)
15016 dx_normj=dc_norm(1,j)
15017 dy_normj=dc_norm(2,j)
15018 dz_normj=dc_norm(3,j)
15019 ! xj=c(1,j)+0.5D0*dxj-xmedi
15020 ! yj=c(2,j)+0.5D0*dyj-ymedi
15021 ! zj=c(3,j)+0.5D0*dzj-zmedi
15022 xj=c(1,j)+0.5D0*dxj
15023 yj=c(2,j)+0.5D0*dyj
15024 zj=c(3,j)+0.5D0*dzj
15025 xj=mod(xj,boxxsize)
15026 if (xj.lt.0) xj=xj+boxxsize
15027 yj=mod(yj,boxysize)
15028 if (yj.lt.0) yj=yj+boxysize
15029 zj=mod(zj,boxzsize)
15030 if (zj.lt.0) zj=zj+boxzsize
15032 dist_init=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
15039 xj=xj_safe+xshift*boxxsize
15040 yj=yj_safe+yshift*boxysize
15041 zj=zj_safe+zshift*boxzsize
15042 dist_temp=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
15043 if(dist_temp.lt.dist_init) then
15044 dist_init=dist_temp
15053 if (isubchap.eq.1) then
15064 rij=xj*xj+yj*yj+zj*zj
15067 sss=sscale(rij/rpp(iteli,itelj))
15068 sss_ele_cut=sscale_ele(rij)
15069 sss_ele_grad=sscagrad_ele(rij)
15070 sss_grad=sscale_grad((rij/rpp(iteli,itelj)))
15071 if (sss_ele_cut.le.0.0) cycle
15072 if (sss.gt.0.0d0) then
15077 ! 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
15078 if (j.eq.i+2) ev1=scal_el*ev1
15081 if (energy_dec) then
15082 write (iout,'(a6,2i5,0pf7.3,f7.3)') 'evdw1',i,j,evdwij,sss
15084 evdw1=evdw1+evdwij*sss*sss_ele_cut
15086 ! Calculate contributions to the Cartesian gradient.
15088 facvdw=-6*rrmij*(ev1+evdwij)*sss*sss_ele_cut
15092 ggg(1)=facvdw*xj+sss_ele_grad*rmij*evdwij*xj*sss &
15093 +evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*xj
15094 ggg(2)=facvdw*yj+sss_ele_grad*rmij*evdwij*yj*sss &
15095 +evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*yj
15096 ggg(3)=facvdw*zj+sss_ele_grad*rmij*evdwij*zj*sss &
15097 +evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*zj
15100 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
15101 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
15107 end subroutine evdwpp_short
15108 !-----------------------------------------------------------------------------
15109 subroutine escp_long(evdw2,evdw2_14)
15111 ! This subroutine calculates the excluded-volume interaction energy between
15112 ! peptide-group centers and side chains and its gradient in virtual-bond and
15113 ! side-chain vectors.
15115 ! implicit real*8 (a-h,o-z)
15116 ! include 'DIMENSIONS'
15117 ! include 'COMMON.GEO'
15118 ! include 'COMMON.VAR'
15119 ! include 'COMMON.LOCAL'
15120 ! include 'COMMON.CHAIN'
15121 ! include 'COMMON.DERIV'
15122 ! include 'COMMON.INTERACT'
15123 ! include 'COMMON.FFIELD'
15124 ! include 'COMMON.IOUNITS'
15125 ! include 'COMMON.CONTROL'
15126 real(kind=8),dimension(3) :: ggg
15127 !el local variables
15128 integer :: i,iint,j,k,iteli,itypj,subchap
15129 real(kind=8) :: xi,yi,zi,xj,yj,zj,rrij,sss,fac,e1,e2,sss_grad,rij
15130 real(kind=8) :: evdw2,evdw2_14,evdwij
15131 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
15132 dist_temp, dist_init
15136 !d print '(a)','Enter ESCP'
15137 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
15138 do i=iatscp_s,iatscp_e
15139 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
15141 xi=0.5D0*(c(1,i)+c(1,i+1))
15142 yi=0.5D0*(c(2,i)+c(2,i+1))
15143 zi=0.5D0*(c(3,i)+c(3,i+1))
15144 xi=mod(xi,boxxsize)
15145 if (xi.lt.0) xi=xi+boxxsize
15146 yi=mod(yi,boxysize)
15147 if (yi.lt.0) yi=yi+boxysize
15148 zi=mod(zi,boxzsize)
15149 if (zi.lt.0) zi=zi+boxzsize
15151 do iint=1,nscp_gr(i)
15153 do j=iscpstart(i,iint),iscpend(i,iint)
15155 if (itypj.eq.ntyp1) cycle
15156 ! Uncomment following three lines for SC-p interactions
15157 ! xj=c(1,nres+j)-xi
15158 ! yj=c(2,nres+j)-yi
15159 ! zj=c(3,nres+j)-zi
15160 ! Uncomment following three lines for Ca-p interactions
15164 xj=mod(xj,boxxsize)
15165 if (xj.lt.0) xj=xj+boxxsize
15166 yj=mod(yj,boxysize)
15167 if (yj.lt.0) yj=yj+boxysize
15168 zj=mod(zj,boxzsize)
15169 if (zj.lt.0) zj=zj+boxzsize
15170 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
15178 xj=xj_safe+xshift*boxxsize
15179 yj=yj_safe+yshift*boxysize
15180 zj=zj_safe+zshift*boxzsize
15181 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
15182 if(dist_temp.lt.dist_init) then
15183 dist_init=dist_temp
15192 if (subchap.eq.1) then
15201 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
15203 rij=dsqrt(1.0d0/rrij)
15204 sss_ele_cut=sscale_ele(rij)
15205 sss_ele_grad=sscagrad_ele(rij)
15206 ! print *,sss_ele_cut,sss_ele_grad,&
15207 ! (rij),r_cut_ele,rlamb_ele
15208 if (sss_ele_cut.le.0.0) cycle
15209 sss=sscale((rij/rscp(itypj,iteli)))
15210 sss_grad=sscale_grad(rij/rscp(itypj,iteli))
15211 if (sss.lt.1.0d0) then
15214 e1=fac*fac*aad(itypj,iteli)
15215 e2=fac*bad(itypj,iteli)
15216 if (iabs(j-i) .le. 2) then
15219 evdw2_14=evdw2_14+(e1+e2)*(1.0d0-sss)*sss_ele_cut
15222 evdw2=evdw2+evdwij*(1.0d0-sss)*sss_ele_cut
15223 if (energy_dec) write (iout,'(a6,2i5,2(0pf7.3))') &
15224 'evdw2',i,j,sss,evdwij
15226 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
15228 fac=-(evdwij+e1)*rrij*(1.0d0-sss)*sss_ele_cut
15229 fac=fac+evdwij*sss_ele_grad/rij/expon*(1.0d0-sss)&
15230 -evdwij*sss_ele_cut/rij/expon*sss_grad/rscp(itypj,iteli)
15234 ! Uncomment following three lines for SC-p interactions
15236 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
15238 ! Uncomment following line for SC-p interactions
15239 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
15241 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
15242 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
15251 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
15252 gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
15253 gradx_scp(j,i)=expon*gradx_scp(j,i)
15256 !******************************************************************************
15260 ! To save time the factor EXPON has been extracted from ALL components
15261 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
15264 !******************************************************************************
15266 end subroutine escp_long
15267 !-----------------------------------------------------------------------------
15268 subroutine escp_short(evdw2,evdw2_14)
15270 ! This subroutine calculates the excluded-volume interaction energy between
15271 ! peptide-group centers and side chains and its gradient in virtual-bond and
15272 ! side-chain vectors.
15274 ! implicit real*8 (a-h,o-z)
15275 ! include 'DIMENSIONS'
15276 ! include 'COMMON.GEO'
15277 ! include 'COMMON.VAR'
15278 ! include 'COMMON.LOCAL'
15279 ! include 'COMMON.CHAIN'
15280 ! include 'COMMON.DERIV'
15281 ! include 'COMMON.INTERACT'
15282 ! include 'COMMON.FFIELD'
15283 ! include 'COMMON.IOUNITS'
15284 ! include 'COMMON.CONTROL'
15285 real(kind=8),dimension(3) :: ggg
15286 !el local variables
15287 integer :: i,iint,j,k,iteli,itypj,subchap
15288 real(kind=8) :: xi,yi,zi,xj,yj,zj,rrij,sss,fac,e1,e2,sss_grad,rij
15289 real(kind=8) :: evdw2,evdw2_14,evdwij
15290 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
15291 dist_temp, dist_init
15295 !d print '(a)','Enter ESCP'
15296 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
15297 do i=iatscp_s,iatscp_e
15298 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
15300 xi=0.5D0*(c(1,i)+c(1,i+1))
15301 yi=0.5D0*(c(2,i)+c(2,i+1))
15302 zi=0.5D0*(c(3,i)+c(3,i+1))
15303 xi=mod(xi,boxxsize)
15304 if (xi.lt.0) xi=xi+boxxsize
15305 yi=mod(yi,boxysize)
15306 if (yi.lt.0) yi=yi+boxysize
15307 zi=mod(zi,boxzsize)
15308 if (zi.lt.0) zi=zi+boxzsize
15310 do iint=1,nscp_gr(i)
15312 do j=iscpstart(i,iint),iscpend(i,iint)
15314 if (itypj.eq.ntyp1) cycle
15315 ! Uncomment following three lines for SC-p interactions
15316 ! xj=c(1,nres+j)-xi
15317 ! yj=c(2,nres+j)-yi
15318 ! zj=c(3,nres+j)-zi
15319 ! Uncomment following three lines for Ca-p interactions
15326 xj=mod(xj,boxxsize)
15327 if (xj.lt.0) xj=xj+boxxsize
15328 yj=mod(yj,boxysize)
15329 if (yj.lt.0) yj=yj+boxysize
15330 zj=mod(zj,boxzsize)
15331 if (zj.lt.0) zj=zj+boxzsize
15332 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
15340 xj=xj_safe+xshift*boxxsize
15341 yj=yj_safe+yshift*boxysize
15342 zj=zj_safe+zshift*boxzsize
15343 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
15344 if(dist_temp.lt.dist_init) then
15345 dist_init=dist_temp
15354 if (subchap.eq.1) then
15364 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
15365 rij=dsqrt(1.0d0/rrij)
15366 sss_ele_cut=sscale_ele(rij)
15367 sss_ele_grad=sscagrad_ele(rij)
15368 ! print *,sss_ele_cut,sss_ele_grad,&
15369 ! (rij),r_cut_ele,rlamb_ele
15370 if (sss_ele_cut.le.0.0) cycle
15371 sss=sscale(rij/rscp(itypj,iteli))
15372 sss_grad=sscale_grad(rij/rscp(itypj,iteli))
15373 if (sss.gt.0.0d0) then
15376 e1=fac*fac*aad(itypj,iteli)
15377 e2=fac*bad(itypj,iteli)
15378 if (iabs(j-i) .le. 2) then
15381 evdw2_14=evdw2_14+(e1+e2)*sss*sss_ele_cut
15384 evdw2=evdw2+evdwij*sss*sss_ele_cut
15385 if (energy_dec) write (iout,'(a6,2i5,2(0pf7.3))') &
15386 'evdw2',i,j,sss,evdwij
15388 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
15390 fac=-(evdwij+e1)*rrij*sss*sss_ele_cut
15391 fac=fac+evdwij*sss_ele_grad/rij/expon*sss &
15392 +evdwij*sss_ele_cut/rij/expon*sss_grad/rscp(itypj,iteli)
15397 ! Uncomment following three lines for SC-p interactions
15399 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
15401 ! Uncomment following line for SC-p interactions
15402 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
15404 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
15405 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
15414 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
15415 gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
15416 gradx_scp(j,i)=expon*gradx_scp(j,i)
15419 !******************************************************************************
15423 ! To save time the factor EXPON has been extracted from ALL components
15424 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
15427 !******************************************************************************
15429 end subroutine escp_short
15430 !-----------------------------------------------------------------------------
15431 ! energy_p_new-sep_barrier.F
15432 !-----------------------------------------------------------------------------
15433 subroutine sc_grad_scale(scalfac)
15434 ! implicit real*8 (a-h,o-z)
15436 ! include 'DIMENSIONS'
15437 ! include 'COMMON.CHAIN'
15438 ! include 'COMMON.DERIV'
15439 ! include 'COMMON.CALC'
15440 ! include 'COMMON.IOUNITS'
15441 real(kind=8),dimension(3) :: dcosom1,dcosom2
15442 real(kind=8) :: scalfac
15443 !el local variables
15444 ! integer :: i,j,k,l
15446 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
15447 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
15448 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12 &
15449 -2.0D0*alf12*eps3der+sigder*sigsq_om12
15453 ! eom12=evdwij*eps1_om12
15455 ! write (iout,*) "eps2der",eps2der," eps3der",eps3der,
15456 ! & " sigder",sigder
15457 ! write (iout,*) "eps1_om12",eps1_om12," eps2rt_om12",eps2rt_om12
15458 ! write (iout,*) "eom1",eom1," eom2",eom2," eom12",eom12
15460 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
15461 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
15464 gg(k)=(gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k))*scalfac&
15467 ! write (iout,*) "gg",(gg(k),k=1,3)
15469 gvdwx(k,i)=gvdwx(k,i)-gg(k) &
15470 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
15471 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv*scalfac&
15473 gvdwx(k,j)=gvdwx(k,j)+gg(k) &
15474 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
15475 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv*scalfac&
15477 ! write (iout,*)(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))
15478 ! & +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
15479 ! write (iout,*)(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))
15480 ! & +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
15483 ! Calculate the components of the gradient in DC and X
15486 gvdwc(l,i)=gvdwc(l,i)-gg(l)
15487 gvdwc(l,j)=gvdwc(l,j)+gg(l)
15490 end subroutine sc_grad_scale
15491 !-----------------------------------------------------------------------------
15492 ! energy_split-sep.F
15493 !-----------------------------------------------------------------------------
15494 subroutine etotal_long(energia)
15496 ! Compute the long-range slow-varying contributions to the energy
15498 ! implicit real*8 (a-h,o-z)
15499 ! include 'DIMENSIONS'
15500 use MD_data, only: totT,usampl,eq_time
15504 !MS$ATTRIBUTES C :: proc_proc
15509 real(kind=8),dimension(n_ene) :: weights_!,time_Bcast,time_Bcastw
15511 ! include 'COMMON.SETUP'
15512 ! include 'COMMON.IOUNITS'
15513 ! include 'COMMON.FFIELD'
15514 ! include 'COMMON.DERIV'
15515 ! include 'COMMON.INTERACT'
15516 ! include 'COMMON.SBRIDGE'
15517 ! include 'COMMON.CHAIN'
15518 ! include 'COMMON.VAR'
15519 ! include 'COMMON.LOCAL'
15520 ! include 'COMMON.MD'
15521 real(kind=8),dimension(0:n_ene) :: energia
15522 !el local variables
15523 integer :: i,n_corr,n_corr1,ierror,ierr
15524 real(kind=8) :: evdw2,evdw2_14,ehpb,etors,edihcnstr,etors_d,esccor,&
15525 evdw,ees,evdw1,eel_loc,eello_turn3,eello_turn4,&
15526 ecorr,ecorr5,ecorr6,eturn6,time00
15527 ! write(iout,'(a,i2)')'Calling etotal_long ipot=',ipot
15528 !elwrite(iout,*)"in etotal long"
15530 if (modecalc.eq.12.or.modecalc.eq.14) then
15532 ! if (fg_rank.eq.0) call int_from_cart1(.false.)
15534 call int_from_cart1(.false.)
15537 !elwrite(iout,*)"in etotal long"
15540 ! write(iout,*) "ETOTAL_LONG Processor",fg_rank,
15541 ! & " absolute rank",myrank," nfgtasks",nfgtasks
15543 if (nfgtasks.gt.1) then
15545 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
15546 if (fg_rank.eq.0) then
15547 call MPI_Bcast(3,1,MPI_INTEGER,king,FG_COMM,IERROR)
15548 ! write (iout,*) "Processor",myrank," BROADCAST iorder"
15550 ! FG master sets up the WEIGHTS_ array which will be broadcast to the
15551 ! FG slaves as WEIGHTS array.
15558 weights_(7)=wel_loc
15561 weights_(10)=wturn6
15563 weights_(12)=wscloc
15565 weights_(14)=wtor_d
15566 weights_(15)=wstrain
15567 weights_(16)=wvdwpp
15569 weights_(18)=scal14
15570 weights_(21)=wsccor
15571 ! FG Master broadcasts the WEIGHTS_ array
15572 call MPI_Bcast(weights_(1),n_ene,&
15573 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
15575 ! FG slaves receive the WEIGHTS array
15576 call MPI_Bcast(weights(1),n_ene,&
15577 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
15592 wstrain=weights(15)
15598 call MPI_Bcast(dc(1,1),6*nres,MPI_DOUBLE_PRECISION,&
15600 time_Bcast=time_Bcast+MPI_Wtime()-time00
15601 time_Bcastw=time_Bcastw+MPI_Wtime()-time00
15602 ! call chainbuild_cart
15603 ! call int_from_cart1(.false.)
15605 ! write (iout,*) 'Processor',myrank,
15606 ! & ' calling etotal_short ipot=',ipot
15608 ! print *,'Processor',myrank,' nnt=',nnt,' nct=',nct
15610 !d print *,'nnt=',nnt,' nct=',nct
15612 !elwrite(iout,*)"in etotal long"
15613 ! Compute the side-chain and electrostatic interaction energy
15615 goto (101,102,103,104,105,106) ipot
15616 ! Lennard-Jones potential.
15617 101 call elj_long(evdw)
15618 !d print '(a)','Exit ELJ'
15620 ! Lennard-Jones-Kihara potential (shifted).
15621 102 call eljk_long(evdw)
15623 ! Berne-Pechukas potential (dilated LJ, angular dependence).
15624 103 call ebp_long(evdw)
15626 ! Gay-Berne potential (shifted LJ, angular dependence).
15627 104 call egb_long(evdw)
15629 ! Gay-Berne-Vorobjev potential (shifted LJ, angular dependence).
15630 105 call egbv_long(evdw)
15632 ! Soft-sphere potential
15633 106 call e_softsphere(evdw)
15635 ! Calculate electrostatic (H-bonding) energy of the main chain.
15639 if (ipot.lt.6) then
15641 if (welec.gt.0d0.or.wvdwpp.gt.0d0.or.wel_loc.gt.0d0.or. &
15642 wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0 &
15643 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
15644 .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
15646 if (welec.gt.0d0.or.wel_loc.gt.0d0.or. &
15647 wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0 &
15648 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
15649 .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
15651 call eelec_scale(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
15660 ! write (iout,*) "Soft-spheer ELEC potential"
15661 call eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,&
15665 ! Calculate excluded-volume interaction energy between peptide groups
15668 if (ipot.lt.6) then
15669 if(wscp.gt.0d0) then
15670 call escp_long(evdw2,evdw2_14)
15676 call escp_soft_sphere(evdw2,evdw2_14)
15679 ! 12/1/95 Multi-body terms
15683 if ((wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 &
15684 .or. wturn6.gt.0.0d0) .and. ipot.lt.6) then
15685 call multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
15686 ! write (2,*) 'n_corr=',n_corr,' n_corr1=',n_corr1,
15687 ! &" ecorr",ecorr," ecorr5",ecorr5," ecorr6",ecorr6," eturn6",eturn6
15694 if ((wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) .and. ipot.lt.6) then
15695 call multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
15698 ! If performing constraint dynamics, call the constraint energy
15699 ! after the equilibration time
15700 if(usampl.and.totT.gt.eq_time) then
15715 energia(2)=evdw2-evdw2_14
15716 energia(18)=evdw2_14
15725 energia(3)=ees+evdw1
15732 energia(8)=eello_turn3
15733 energia(9)=eello_turn4
15735 energia(20)=Uconst+Uconst_back
15736 call sum_energy(energia,.true.)
15737 ! write (iout,*) "Exit ETOTAL_LONG"
15740 end subroutine etotal_long
15741 !-----------------------------------------------------------------------------
15742 subroutine etotal_short(energia)
15744 ! Compute the short-range fast-varying contributions to the energy
15746 ! implicit real*8 (a-h,o-z)
15747 ! include 'DIMENSIONS'
15751 !MS$ATTRIBUTES C :: proc_proc
15756 integer :: ierror,ierr
15757 real(kind=8),dimension(n_ene) :: weights_
15758 real(kind=8) :: time00
15760 ! include 'COMMON.SETUP'
15761 ! include 'COMMON.IOUNITS'
15762 ! include 'COMMON.FFIELD'
15763 ! include 'COMMON.DERIV'
15764 ! include 'COMMON.INTERACT'
15765 ! include 'COMMON.SBRIDGE'
15766 ! include 'COMMON.CHAIN'
15767 ! include 'COMMON.VAR'
15768 ! include 'COMMON.LOCAL'
15769 real(kind=8),dimension(0:n_ene) :: energia
15770 !el local variables
15772 real(kind=8) :: evdw,evdw1,evdw2,evdw2_14,esccor,etors_d,etors
15773 real(kind=8) :: ehpb,escloc,estr,ebe,edihcnstr,ethetacnstr
15776 ! write(iout,'(a,i2)')'Calling etotal_short ipot=',ipot
15778 if (modecalc.eq.12.or.modecalc.eq.14) then
15780 if (fg_rank.eq.0) call int_from_cart1(.false.)
15782 call int_from_cart1(.false.)
15786 ! write(iout,*) "ETOTAL_SHORT Processor",fg_rank,
15787 ! & " absolute rank",myrank," nfgtasks",nfgtasks
15789 if (nfgtasks.gt.1) then
15791 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
15792 if (fg_rank.eq.0) then
15793 call MPI_Bcast(2,1,MPI_INTEGER,king,FG_COMM,IERROR)
15794 ! write (iout,*) "Processor",myrank," BROADCAST iorder"
15796 ! FG master sets up the WEIGHTS_ array which will be broadcast to the
15797 ! FG slaves as WEIGHTS array.
15804 weights_(7)=wel_loc
15807 weights_(10)=wturn6
15809 weights_(12)=wscloc
15811 weights_(14)=wtor_d
15812 weights_(15)=wstrain
15813 weights_(16)=wvdwpp
15815 weights_(18)=scal14
15816 weights_(21)=wsccor
15817 ! FG Master broadcasts the WEIGHTS_ array
15818 call MPI_Bcast(weights_(1),n_ene,&
15819 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
15821 ! FG slaves receive the WEIGHTS array
15822 call MPI_Bcast(weights(1),n_ene,&
15823 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
15838 wstrain=weights(15)
15844 ! write (iout,*),"Processor",myrank," BROADCAST weights"
15845 call MPI_Bcast(c(1,1),nres6,MPI_DOUBLE_PRECISION,&
15847 ! write (iout,*) "Processor",myrank," BROADCAST c"
15848 call MPI_Bcast(dc(1,1),nres6,MPI_DOUBLE_PRECISION,&
15850 ! write (iout,*) "Processor",myrank," BROADCAST dc"
15851 call MPI_Bcast(dc_norm(1,1),nres6,MPI_DOUBLE_PRECISION,&
15853 ! write (iout,*) "Processor",myrank," BROADCAST dc_norm"
15854 call MPI_Bcast(theta(1),nres,MPI_DOUBLE_PRECISION,&
15856 ! write (iout,*) "Processor",myrank," BROADCAST theta"
15857 call MPI_Bcast(phi(1),nres,MPI_DOUBLE_PRECISION,&
15859 ! write (iout,*) "Processor",myrank," BROADCAST phi"
15860 call MPI_Bcast(alph(1),nres,MPI_DOUBLE_PRECISION,&
15862 ! write (iout,*) "Processor",myrank," BROADCAST alph"
15863 call MPI_Bcast(omeg(1),nres,MPI_DOUBLE_PRECISION,&
15865 ! write (iout,*) "Processor",myrank," BROADCAST omeg"
15866 call MPI_Bcast(vbld(1),2*nres,MPI_DOUBLE_PRECISION,&
15868 ! write (iout,*) "Processor",myrank," BROADCAST vbld"
15869 call MPI_Bcast(vbld_inv(1),2*nres,MPI_DOUBLE_PRECISION,&
15871 time_Bcast=time_Bcast+MPI_Wtime()-time00
15872 ! write (iout,*) "Processor",myrank," BROADCAST vbld_inv"
15874 ! write (iout,*) 'Processor',myrank,
15875 ! & ' calling etotal_short ipot=',ipot
15877 ! print *,'Processor',myrank,' nnt=',nnt,' nct=',nct
15879 ! call int_from_cart1(.false.)
15881 ! Compute the side-chain and electrostatic interaction energy
15883 goto (101,102,103,104,105,106) ipot
15884 ! Lennard-Jones potential.
15885 101 call elj_short(evdw)
15886 !d print '(a)','Exit ELJ'
15888 ! Lennard-Jones-Kihara potential (shifted).
15889 102 call eljk_short(evdw)
15891 ! Berne-Pechukas potential (dilated LJ, angular dependence).
15892 103 call ebp_short(evdw)
15894 ! Gay-Berne potential (shifted LJ, angular dependence).
15895 104 call egb_short(evdw)
15897 ! Gay-Berne-Vorobjev potential (shifted LJ, angular dependence).
15898 105 call egbv_short(evdw)
15900 ! Soft-sphere potential - already dealt with in the long-range part
15902 ! 106 call e_softsphere_short(evdw)
15904 ! Calculate electrostatic (H-bonding) energy of the main chain.
15908 ! Calculate the short-range part of Evdwpp
15910 call evdwpp_short(evdw1)
15912 ! Calculate the short-range part of ESCp
15914 if (ipot.lt.6) then
15915 call escp_short(evdw2,evdw2_14)
15918 ! Calculate the bond-stretching energy
15922 ! Calculate the disulfide-bridge and other energy and the contributions
15923 ! from other distance constraints.
15926 ! Calculate the virtual-bond-angle energy.
15928 call ebend(ebe,ethetacnstr)
15930 ! Calculate the SC local energy.
15935 ! Calculate the virtual-bond torsional energy.
15937 call etor(etors,edihcnstr)
15939 ! 6/23/01 Calculate double-torsional energy
15941 call etor_d(etors_d)
15943 ! 21/5/07 Calculate local sicdechain correlation energy
15945 if (wsccor.gt.0.0d0) then
15946 call eback_sc_corr(esccor)
15951 ! Put energy components into an array
15958 energia(2)=evdw2-evdw2_14
15959 energia(18)=evdw2_14
15972 energia(14)=etors_d
15975 energia(19)=edihcnstr
15977 ! write (iout,*) "ETOTAL_SHORT before SUM_ENERGY"
15979 call sum_energy(energia,.true.)
15980 ! write (iout,*) "Exit ETOTAL_SHORT"
15983 end subroutine etotal_short
15984 !-----------------------------------------------------------------------------
15986 !-----------------------------------------------------------------------------
15987 real(kind=8) function gnmr1(y,ymin,ymax)
15989 real(kind=8) :: y,ymin,ymax
15990 real(kind=8) :: wykl=4.0d0
15991 if (y.lt.ymin) then
15992 gnmr1=(ymin-y)**wykl/wykl
15993 else if (y.gt.ymax) then
15994 gnmr1=(y-ymax)**wykl/wykl
16000 !-----------------------------------------------------------------------------
16001 real(kind=8) function gnmr1prim(y,ymin,ymax)
16003 real(kind=8) :: y,ymin,ymax
16004 real(kind=8) :: wykl=4.0d0
16005 if (y.lt.ymin) then
16006 gnmr1prim=-(ymin-y)**(wykl-1)
16007 else if (y.gt.ymax) then
16008 gnmr1prim=(y-ymax)**(wykl-1)
16013 end function gnmr1prim
16014 !----------------------------------------------------------------------------
16015 real(kind=8) function rlornmr1(y,ymin,ymax,sigma)
16016 real(kind=8) y,ymin,ymax,sigma
16017 real(kind=8) wykl /4.0d0/
16018 if (y.lt.ymin) then
16019 rlornmr1=(ymin-y)**wykl/((ymin-y)**wykl+sigma**wykl)
16020 else if (y.gt.ymax) then
16021 rlornmr1=(y-ymax)**wykl/((y-ymax)**wykl+sigma**wykl)
16026 end function rlornmr1
16027 !------------------------------------------------------------------------------
16028 real(kind=8) function rlornmr1prim(y,ymin,ymax,sigma)
16029 real(kind=8) y,ymin,ymax,sigma
16030 real(kind=8) wykl /4.0d0/
16031 if (y.lt.ymin) then
16032 rlornmr1prim=-(ymin-y)**(wykl-1)*sigma**wykl*wykl/ &
16033 ((ymin-y)**wykl+sigma**wykl)**2
16034 else if (y.gt.ymax) then
16035 rlornmr1prim=(y-ymax)**(wykl-1)*sigma**wykl*wykl/ &
16036 ((y-ymax)**wykl+sigma**wykl)**2
16041 end function rlornmr1prim
16043 real(kind=8) function harmonic(y,ymax)
16045 real(kind=8) :: y,ymax
16046 real(kind=8) :: wykl=2.0d0
16047 harmonic=(y-ymax)**wykl
16049 end function harmonic
16050 !-----------------------------------------------------------------------------
16051 real(kind=8) function harmonicprim(y,ymax)
16052 real(kind=8) :: y,ymin,ymax
16053 real(kind=8) :: wykl=2.0d0
16054 harmonicprim=(y-ymax)*wykl
16056 end function harmonicprim
16057 !-----------------------------------------------------------------------------
16059 !-----------------------------------------------------------------------------
16060 subroutine gradient(n,x,nf,g,uiparm,urparm,ufparm)
16062 use io_base, only:intout,briefout
16063 ! implicit real*8 (a-h,o-z)
16064 ! include 'DIMENSIONS'
16065 ! include 'COMMON.CHAIN'
16066 ! include 'COMMON.DERIV'
16067 ! include 'COMMON.VAR'
16068 ! include 'COMMON.INTERACT'
16069 ! include 'COMMON.FFIELD'
16070 ! include 'COMMON.MD'
16071 ! include 'COMMON.IOUNITS'
16072 real(kind=8),external :: ufparm
16073 integer :: uiparm(1)
16074 real(kind=8) :: urparm(1)
16075 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
16076 real(kind=8) :: f,gthetai,gphii,galphai,gomegai
16077 integer :: n,nf,ind,ind1,i,k,j
16079 ! This subroutine calculates total internal coordinate gradient.
16080 ! Depending on the number of function evaluations, either whole energy
16081 ! is evaluated beforehand, Cartesian coordinates and their derivatives in
16082 ! internal coordinates are reevaluated or only the cartesian-in-internal
16083 ! coordinate derivatives are evaluated. The subroutine was designed to work
16089 !d print *,'grad',nf,icg
16090 if (nf-nfl+1) 20,30,40
16091 20 call func(n,x,nf,f,uiparm,urparm,ufparm)
16092 ! write (iout,*) 'grad 20'
16093 if (nf.eq.0) return
16095 30 call var_to_geom(n,x)
16097 ! write (iout,*) 'grad 30'
16099 ! Evaluate the derivatives of virtual bond lengths and SC vectors in variables.
16102 ! write (iout,*) 'grad 40'
16103 ! print *,'GRADIENT: nnt=',nnt,' nct=',nct,' expon=',expon
16105 ! Convert the Cartesian gradient into internal-coordinate gradient.
16115 ! print *,'GRAD: i=',i,' jc=',j,' ind=',ind
16117 gthetai=gthetai+dcdv(k,ind)*gradc(k,j,icg)
16120 gphii=gphii+dcdv(k+3,ind)*gradc(k,j,icg)
16126 ! print *,'GRAD: i=',i,' jx=',j,' ind1=',ind1
16128 gthetai=gthetai+dxdv(k,ind1)*gradx(k,j,icg)
16129 gphii=gphii+dxdv(k+3,ind1)*gradx(k,j,icg)
16132 if (i.gt.1) g(i-1)=gphii
16133 if (n.gt.nphi) g(nphi+i)=gthetai
16135 if (n.le.nphi+ntheta) goto 10
16137 if (itype(i,1).ne.10) then
16141 galphai=galphai+dxds(k,i)*gradx(k,i,icg)
16144 gomegai=gomegai+dxds(k+3,i)*gradx(k,i,icg)
16146 g(ialph(i,1))=galphai
16147 g(ialph(i,1)+nside)=gomegai
16151 ! Add the components corresponding to local energy terms.
16155 !d write (iout,*) 'i=',i,'g=',g(i),' gloc=',gloc(i,icg)
16156 g(i)=g(i)+gloc(i,icg)
16158 ! Uncomment following three lines for diagnostics.
16160 !elwrite(iout,*) "in gradient after calling intout"
16161 !d call briefout(0,0.0d0)
16162 !d write (iout,'(i3,1pe15.5)') (k,g(k),k=1,n)
16164 end subroutine gradient
16165 !-----------------------------------------------------------------------------
16166 subroutine func(n,x,nf,f,uiparm,urparm,ufparm) !from minimize_p.F
16169 ! implicit real*8 (a-h,o-z)
16170 ! include 'DIMENSIONS'
16171 ! include 'COMMON.DERIV'
16172 ! include 'COMMON.IOUNITS'
16173 ! include 'COMMON.GEO'
16176 !el common /chuju/ jjj
16177 real(kind=8) :: energia(0:n_ene)
16178 integer :: uiparm(1)
16179 real(kind=8) :: urparm(1)
16181 real(kind=8),external :: ufparm
16182 real(kind=8),dimension(6*nres) :: x !(maxvar) (maxvar=6*maxres)
16183 ! if (jjj.gt.0) then
16184 ! write (iout,'(10f8.3)') (rad2deg*x(i),i=1,n)
16188 !d print *,'func',nf,nfl,icg
16189 call var_to_geom(n,x)
16192 !d write (iout,*) 'ETOTAL called from FUNC'
16193 call etotal(energia)
16196 ! if (jjj.gt.0) then
16197 ! write (iout,'(10f8.3)') (rad2deg*x(i),i=1,n)
16198 ! write (iout,*) 'f=',etot
16202 end subroutine func
16203 !-----------------------------------------------------------------------------
16204 subroutine cartgrad
16205 ! implicit real*8 (a-h,o-z)
16206 ! include 'DIMENSIONS'
16208 use MD_data, only: totT,usampl,eq_time
16212 ! include 'COMMON.CHAIN'
16213 ! include 'COMMON.DERIV'
16214 ! include 'COMMON.VAR'
16215 ! include 'COMMON.INTERACT'
16216 ! include 'COMMON.FFIELD'
16217 ! include 'COMMON.MD'
16218 ! include 'COMMON.IOUNITS'
16219 ! include 'COMMON.TIME1'
16223 ! This subrouting calculates total Cartesian coordinate gradient.
16224 ! The subroutine chainbuild_cart and energy MUST be called beforehand.
16234 !el write (iout,*) "After sum_gradient"
16236 !el write (iout,*) "After sum_gradient"
16238 write (iout,*) i," gradc ",(gradc(j,i,icg),j=1,3)
16239 write (iout,*) i," gradx ",(gradx(j,i,icg),j=1,3)
16242 ! If performing constraint dynamics, add the gradients of the constraint energy
16243 if(usampl.and.totT.gt.eq_time) then
16246 gradc(j,i,icg)=gradc(j,i,icg)+dudconst(j,i)+duscdiff(j,i)
16247 gradx(j,i,icg)=gradx(j,i,icg)+dudxconst(j,i)+duscdiffx(j,i)
16251 gloc(i,icg)=gloc(i,icg)+dugamma(i)
16254 gloc(nphi+i,icg)=gloc(nphi+i,icg)+dutheta(i)
16257 !elwrite (iout,*) "After sum_gradient"
16262 !elwrite (iout,*) "After sum_gradient"
16264 time_intcartderiv=time_intcartderiv+MPI_Wtime()-time01
16266 ! call checkintcartgrad
16267 ! write(iout,*) 'calling int_to_cart'
16269 write (iout,*) "gcart, gxcart, gloc before int_to_cart"
16273 gcart(j,i)=gradc(j,i,icg)
16274 gxcart(j,i)=gradx(j,i,icg)
16275 ! if (i.le.2) print *,"gcart_one",gcart(j,i),gradc(j,i,icg)
16278 write (iout,'(i5,2(3f10.5,5x),f10.5)') i,(gcart(j,i),j=1,3),&
16279 (gxcart(j,i),j=1,3),gloc(i,icg)
16285 ! print *,"gcart_two",gxcart(2,2),gradx(2,2,icg)
16287 ! print *,"gcart_two",gxcart(2,2),gradx(2,2,icg)
16290 time_inttocart=time_inttocart+MPI_Wtime()-time01
16293 write (iout,*) "gcart and gxcart after int_to_cart"
16295 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
16296 (gxcart(j,i),j=1,3)
16301 write (iout,*) "CARGRAD"
16305 gcart(j,i)=-gcart(j,i)+gcart(j,i-1)-gxcart(j,i)
16306 ! gcart_new(j,i)=-gcart(j,i)+gcart(j,i-1)-gxcart(j,i)
16308 ! write (iout,'(i5,3f10.5,5x,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3), &
16309 ! (gcart_new(j,i),j=1,3),(gxcart(j,i),j=1,3)
16311 ! Correction: dummy residues
16314 ! gcart_new(j,nnt)=gcart_new(j,nnt)+gcart_new(j,1)
16315 gcart(j,nnt)=gcart(j,nnt)+gcart(j,1)
16318 if (nct.lt.nres) then
16320 ! gcart_new(j,nct)=gcart_new(j,nct)+gcart_new(j,nres)
16321 gcart(j,nct)=gcart(j,nct)+gcart(j,nres)
16326 time_cartgrad=time_cartgrad+MPI_Wtime()-time00
16330 end subroutine cartgrad
16331 !-----------------------------------------------------------------------------
16332 subroutine zerograd
16333 ! implicit real*8 (a-h,o-z)
16334 ! include 'DIMENSIONS'
16335 ! include 'COMMON.DERIV'
16336 ! include 'COMMON.CHAIN'
16337 ! include 'COMMON.VAR'
16338 ! include 'COMMON.MD'
16339 ! include 'COMMON.SCCOR'
16341 !el local variables
16342 integer :: i,j,intertyp,k
16343 ! Initialize Cartesian-coordinate gradient
16345 ! if (.not.allocated(gradx)) allocate(gradx(3,nres,2)) !(3,maxres,2)
16346 ! if (.not.allocated(gradc)) allocate(gradc(3,nres,2)) !(3,maxres,2)
16348 ! allocate(gvdwx(3,nres),gvdwc(3,nres),gelc(3,nres),gelc_long(3,nres))
16349 ! allocate(gvdwpp(3,nres),gvdwc_scpp(3,nres),gradx_scp(3,nres))
16350 ! allocate(gvdwc_scp(3,nres),ghpbx(3,nres),ghpbc(3,nres))
16351 ! allocate(gradcorr_long(3,nres))
16352 ! allocate(gradcorr5_long(3,nres),gradcorr6_long(3,nres))
16353 ! allocate(gcorr6_turn_long(3,nres))
16354 ! allocate(gradcorr5(3,nres),gradcorr6(3,nres)) !(3,maxres)
16356 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres)) !(3,maxres)
16358 ! allocate(gel_loc(3,nres),gel_loc_long(3,nres),gcorr3_turn(3,nres))
16359 ! allocate(gcorr4_turn(3,nres),gcorr6_turn(3,nres))
16361 ! if (.not.allocated(gradb)) allocate(gradb(3,nres)) !(3,maxres)
16362 ! if (.not.allocated(gradbx)) allocate(gradbx(3,nres)) !(3,maxres)
16364 ! allocate(gsccorc(3,nres),gsccorx(3,nres)) !(3,maxres)
16365 ! allocate(gscloc(3,nres)) !(3,maxres)
16366 ! if (.not.allocated(gsclocx)) allocate(gsclocx(3,nres)) !(3,maxres)
16370 ! common /deriv_scloc/
16371 ! allocate(dXX_C1tab(3,nres),dYY_C1tab(3,nres),dZZ_C1tab(3,nres))
16372 ! allocate(dXX_Ctab(3,nres),dYY_Ctab(3,nres),dZZ_Ctab(3,nres))
16373 ! allocate(dXX_XYZtab(3,nres),dYY_XYZtab(3,nres),dZZ_XYZtab(3,nres)) !(3,maxres)
16375 ! allocate(jgrad_start(nres),jgrad_end(nres)) !(maxres)
16379 ! gradc(j,i,icg)=0.0d0
16380 ! gradx(j,i,icg)=0.0d0
16382 ! allocate(gloc_sc(3,nres,10)) !(3,0:maxres2,10)maxres2=2*maxres
16383 !elwrite(iout,*) "icg",icg
16387 gradx_scp(j,i)=0.0D0
16389 gvdwc_scp(j,i)=0.0D0
16390 gvdwc_scpp(j,i)=0.0d0
16392 gelc_long(j,i)=0.0D0
16397 gel_loc_long(j,i)=0.0d0
16400 gcorr3_turn(j,i)=0.0d0
16401 gcorr4_turn(j,i)=0.0d0
16402 gradcorr(j,i)=0.0d0
16403 gradcorr_long(j,i)=0.0d0
16404 gradcorr5_long(j,i)=0.0d0
16405 gradcorr6_long(j,i)=0.0d0
16406 gcorr6_turn_long(j,i)=0.0d0
16407 gradcorr5(j,i)=0.0d0
16408 gradcorr6(j,i)=0.0d0
16409 gcorr6_turn(j,i)=0.0d0
16412 gradc(j,i,icg)=0.0d0
16413 gradx(j,i,icg)=0.0d0
16416 gliptran(j,i)=0.0d0
16417 gliptranx(j,i)=0.0d0
16418 gliptranc(j,i)=0.0d0
16419 gshieldx(j,i)=0.0d0
16420 gshieldc(j,i)=0.0d0
16421 gshieldc_loc(j,i)=0.0d0
16422 gshieldx_ec(j,i)=0.0d0
16423 gshieldc_ec(j,i)=0.0d0
16424 gshieldc_loc_ec(j,i)=0.0d0
16425 gshieldx_t3(j,i)=0.0d0
16426 gshieldc_t3(j,i)=0.0d0
16427 gshieldc_loc_t3(j,i)=0.0d0
16428 gshieldx_t4(j,i)=0.0d0
16429 gshieldc_t4(j,i)=0.0d0
16430 gshieldc_loc_t4(j,i)=0.0d0
16431 gshieldx_ll(j,i)=0.0d0
16432 gshieldc_ll(j,i)=0.0d0
16433 gshieldc_loc_ll(j,i)=0.0d0
16435 gg_tube_sc(j,i)=0.0d0
16437 gradb_nucl(j,i)=0.0d0
16438 gradbx_nucl(j,i)=0.0d0
16439 gvdwpp_nucl(j,i)=0.0d0
16443 gvdwpsb1(j,i)=0.0d0
16447 gradcorr_nucl(j,i)=0.0d0
16448 gradcorr3_nucl(j,i)=0.0d0
16449 gradxorr_nucl(j,i)=0.0d0
16450 gradxorr3_nucl(j,i)=0.0d0
16454 gradpepcat(j,i)=0.0d0
16455 gradpepcatx(j,i)=0.0d0
16456 gradcatcat(j,i)=0.0d0
16457 gvdwx_scbase(j,i)=0.0d0
16458 gvdwc_scbase(j,i)=0.0d0
16459 gvdwx_pepbase(j,i)=0.0d0
16460 gvdwc_pepbase(j,i)=0.0d0
16461 gvdwx_scpho(j,i)=0.0d0
16462 gvdwc_scpho(j,i)=0.0d0
16463 gvdwc_peppho(j,i)=0.0d0
16469 gloc_sc(intertyp,i,icg)=0.0d0
16478 grad_shield_side(k,j,i)=0.0d0
16479 grad_shield_loc(k,j,i)=0.0d0
16486 ! Initialize the gradient of local energy terms.
16488 ! allocate(gloc(4*nres,2)) !!(maxvar,2)(maxvar=6*maxres)
16489 ! if (.not.allocated(gel_loc_loc)) allocate(gel_loc_loc(nres)) !(maxvar)(maxvar=6*maxres)
16490 ! if (.not.allocated(gcorr_loc)) allocate(gcorr_loc(nres)) !(maxvar)(maxvar=6*maxres)
16491 ! allocate(g_corr5_loc(nres),g_corr6_loc(nres)) !(maxvar)(maxvar=6*maxres)
16492 ! allocate(gel_loc_turn3(nres))
16493 ! allocate(gel_loc_turn4(nres),gel_loc_turn6(nres)) !(maxvar)(maxvar=6*maxres)
16494 ! allocate(gsccor_loc(nres)) !(maxres)
16500 gel_loc_loc(i)=0.0d0
16502 g_corr5_loc(i)=0.0d0
16503 g_corr6_loc(i)=0.0d0
16504 gel_loc_turn3(i)=0.0d0
16505 gel_loc_turn4(i)=0.0d0
16506 gel_loc_turn6(i)=0.0d0
16507 gsccor_loc(i)=0.0d0
16509 ! initialize gcart and gxcart
16510 ! allocate(gcart(3,0:nres),gxcart(3,0:nres)) !(3,0:MAXRES)
16518 end subroutine zerograd
16519 !-----------------------------------------------------------------------------
16520 real(kind=8) function fdum()
16524 !-----------------------------------------------------------------------------
16526 !-----------------------------------------------------------------------------
16527 subroutine intcartderiv
16528 ! implicit real*8 (a-h,o-z)
16529 ! include 'DIMENSIONS'
16533 ! include 'COMMON.SETUP'
16534 ! include 'COMMON.CHAIN'
16535 ! include 'COMMON.VAR'
16536 ! include 'COMMON.GEO'
16537 ! include 'COMMON.INTERACT'
16538 ! include 'COMMON.DERIV'
16539 ! include 'COMMON.IOUNITS'
16540 ! include 'COMMON.LOCAL'
16541 ! include 'COMMON.SCCOR'
16542 real(kind=8) :: pi4,pi34
16543 real(kind=8),dimension(3,2,nres) :: dcostheta ! (3,2,maxres)
16544 real(kind=8),dimension(3,3,nres) :: dcosphi,dsinphi,dcosalpha,&
16545 dcosomega,dsinomega !(3,3,maxres)
16546 real(kind=8),dimension(3) :: vo1,vo2,vo3,dummy,vp1,vp2,vp3,vpp1,n
16549 real(kind=8) :: cost,sint,cost1,sint1,cost2,sint2,sing,cosg,scalp,&
16550 fac0,fac1,fac2,fac3,fac4,fac5,fac6,ctgt,ctgt1,cosg_inv,&
16551 fac7,fac8,fac9,scala1,scala2,cosa,sina,sino,fac15,fac16,&
16552 fac17,coso_inv,fac10,fac11,fac12,fac13,fac14
16556 !el from module energy-------------
16557 !el allocate(dcostau(3,3,3,itau_start:itau_end)) !(3,3,3,maxres2)maxres2=2*maxres
16558 !el allocate(dsintau(3,3,3,itau_start:itau_end))
16559 !el allocate(dtauangle(3,3,3,itau_start:itau_end))
16561 !el allocate(dcostau(3,3,3,0:nres2)) !(3,3,3,maxres2)maxres2=2*maxres
16562 !el allocate(dsintau(3,3,3,0:nres2))
16563 !el allocate(dtauangle(3,3,3,0:nres2))
16564 !el allocate(domicron(3,2,2,0:nres2))
16565 !el allocate(dcosomicron(3,2,2,0:nres2))
16569 #if defined(MPI) && defined(PARINTDER)
16570 if (nfgtasks.gt.1 .and. me.eq.king) &
16571 call MPI_Bcast(8,1,MPI_INTEGER,king,FG_COMM,IERROR)
16576 ! allocate(dtheta(3,2,nres)) !(3,2,maxres)
16577 ! allocate(dphi(3,3,nres),dalpha(3,3,nres),domega(3,3,nres)) !(3,3,maxres)
16579 ! write (iout,*) "iphi1_start",iphi1_start," iphi1_end",iphi1_end
16582 dtheta(j,1,i)=0.0d0
16583 dtheta(j,2,i)=0.0d0
16589 ! Derivatives of theta's
16590 #if defined(MPI) && defined(PARINTDER)
16591 ! We need dtheta(:,:,i-1) to compute dphi(:,:,i)
16592 do i=max0(ithet_start-1,3),ithet_end
16596 cost=dcos(theta(i))
16597 sint=sqrt(1-cost*cost)
16599 dcostheta(j,1,i)=-(dc_norm(j,i-1)+cost*dc_norm(j,i-2))/&
16601 if (itype(i-1,1).ne.ntyp1) dtheta(j,1,i)=-dcostheta(j,1,i)/sint
16602 dcostheta(j,2,i)=-(dc_norm(j,i-2)+cost*dc_norm(j,i-1))/&
16604 if (itype(i-1,1).ne.ntyp1) dtheta(j,2,i)=-dcostheta(j,2,i)/sint
16607 #if defined(MPI) && defined(PARINTDER)
16608 ! We need dtheta(:,:,i-1) to compute dphi(:,:,i)
16609 do i=max0(ithet_start-1,3),ithet_end
16613 if ((itype(i-1,1).ne.10).and.(itype(i-1,1).ne.ntyp1)) then
16614 cost1=dcos(omicron(1,i))
16615 sint1=sqrt(1-cost1*cost1)
16616 cost2=dcos(omicron(2,i))
16617 sint2=sqrt(1-cost2*cost2)
16619 !C Calculate derivative over first omicron (Cai-2,Cai-1,SCi-1)
16620 dcosomicron(j,1,1,i)=-(dc_norm(j,i-1+nres)+ &
16621 cost1*dc_norm(j,i-2))/ &
16623 domicron(j,1,1,i)=-1/sint1*dcosomicron(j,1,1,i)
16624 dcosomicron(j,1,2,i)=-(dc_norm(j,i-2) &
16625 +cost1*(dc_norm(j,i-1+nres)))/ &
16627 domicron(j,1,2,i)=-1/sint1*dcosomicron(j,1,2,i)
16628 !C Calculate derivative over second omicron Sci-1,Cai-1 Cai
16629 !C Looks messy but better than if in loop
16630 dcosomicron(j,2,1,i)=-(-dc_norm(j,i-1+nres) &
16631 +cost2*dc_norm(j,i-1))/ &
16633 domicron(j,2,1,i)=-1/sint2*dcosomicron(j,2,1,i)
16634 dcosomicron(j,2,2,i)=-(dc_norm(j,i-1) &
16635 +cost2*(-dc_norm(j,i-1+nres)))/ &
16637 ! write(iout,*) "vbld", i,itype(i,1),vbld(i-1+nres)
16638 domicron(j,2,2,i)=-1/sint2*dcosomicron(j,2,2,i)
16642 !elwrite(iout,*) "after vbld write"
16643 ! Derivatives of phi:
16644 ! If phi is 0 or 180 degrees, then the formulas
16645 ! have to be derived by power series expansion of the
16646 ! conventional formulas around 0 and 180.
16648 do i=iphi1_start,iphi1_end
16652 ! if (itype(i-1,1).eq.21 .or. itype(i-2,1).eq.21 ) cycle
16653 ! the conventional case
16654 sint=dsin(theta(i))
16655 sint1=dsin(theta(i-1))
16657 cost=dcos(theta(i))
16658 cost1=dcos(theta(i-1))
16660 scalp=scalar(dc_norm(1,i-3),dc_norm(1,i-1))
16661 fac0=1.0d0/(sint1*sint)
16664 fac3=cosg*cost1/(sint1*sint1)
16665 fac4=cosg*cost/(sint*sint)
16666 ! Obtaining the gamma derivatives from sine derivative
16667 if (phi(i).gt.-pi4.and.phi(i).le.pi4.or. &
16668 phi(i).gt.pi34.and.phi(i).le.pi.or. &
16669 phi(i).ge.-pi.and.phi(i).le.-pi34) then
16670 call vecpr(dc_norm(1,i-1),dc_norm(1,i-2),vp1)
16671 call vecpr(dc_norm(1,i-3),dc_norm(1,i-1),vp2)
16672 call vecpr(dc_norm(1,i-3),dc_norm(1,i-2),vp3)
16676 cosg_inv=1.0d0/cosg
16677 if (itype(i-1,1).ne.ntyp1 .and. itype(i-2,1).ne.ntyp1) then
16678 dsinphi(j,1,i)=-sing*ctgt1*dtheta(j,1,i-1) &
16679 -(fac0*vp1(j)+sing*dc_norm(j,i-3))*vbld_inv(i-2)
16680 dphi(j,1,i)=cosg_inv*dsinphi(j,1,i)
16682 -sing*(ctgt1*dtheta(j,2,i-1)+ctgt*dtheta(j,1,i)) &
16683 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
16684 dphi(j,2,i)=cosg_inv*dsinphi(j,2,i)
16685 dsinphi(j,3,i)=-sing*ctgt*dtheta(j,2,i) &
16686 +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i)
16687 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
16688 dphi(j,3,i)=cosg_inv*dsinphi(j,3,i)
16690 ! Bug fixed 3/24/05 (AL)
16692 ! Obtaining the gamma derivatives from cosine derivative
16695 if (itype(i-1,1).ne.ntyp1 .and. itype(i-2,1).ne.ntyp1) then
16696 dcosphi(j,1,i)=fac1*dcostheta(j,1,i-1)+fac3* &
16697 dcostheta(j,1,i-1)-fac0*(dc_norm(j,i-1)-scalp* &
16698 dc_norm(j,i-3))/vbld(i-2)
16699 dphi(j,1,i)=-1/sing*dcosphi(j,1,i)
16700 dcosphi(j,2,i)=fac1*dcostheta(j,2,i-1)+fac2* &
16701 dcostheta(j,1,i)+fac3*dcostheta(j,2,i-1)+fac4* &
16703 dphi(j,2,i)=-1/sing*dcosphi(j,2,i)
16704 dcosphi(j,3,i)=fac2*dcostheta(j,2,i)+fac4* &
16705 dcostheta(j,2,i)-fac0*(dc_norm(j,i-3)-scalp* &
16706 dc_norm(j,i-1))/vbld(i)
16707 dphi(j,3,i)=-1/sing*dcosphi(j,3,i)
16712 !alculate derivative of Tauangle
16714 do i=itau_start,itau_end
16717 !elwrite(iout,*) " vecpr",i,nres
16719 if ((itype(i-2,1).eq.ntyp1).or.(itype(i-2,1).eq.10)) cycle
16720 ! if ((itype(i-2,1).eq.ntyp1).or.(itype(i-2,1).eq.10).or.
16721 ! & (itype(i-1,1).eq.ntyp1).or.(itype(i,1).eq.ntyp1)) cycle
16722 !c dtauangle(j,intertyp,dervityp,residue number)
16723 !c INTERTYP=1 SC...Ca...Ca..Ca
16724 ! the conventional case
16725 sint=dsin(theta(i))
16726 sint1=dsin(omicron(2,i-1))
16727 sing=dsin(tauangle(1,i))
16728 cost=dcos(theta(i))
16729 cost1=dcos(omicron(2,i-1))
16730 cosg=dcos(tauangle(1,i))
16731 !elwrite(iout,*) " vecpr5",i,nres
16733 !elwrite(iout,*) " vecpreee",i,nres,j,i-2+nres
16734 !elwrite(iout,*) " vecpr5",dc_norm2(1,1)
16735 dc_norm2(j,i-2+nres)=-dc_norm(j,i-2+nres)
16736 ! write(iout,*) dc_norm2(j,i-2+nres),"dcnorm"
16738 scalp=scalar(dc_norm2(1,i-2+nres),dc_norm(1,i-1))
16739 fac0=1.0d0/(sint1*sint)
16742 fac3=cosg*cost1/(sint1*sint1)
16743 fac4=cosg*cost/(sint*sint)
16744 ! write(iout,*) "faki",fac0,fac1,fac2,fac3,fac4
16745 ! Obtaining the gamma derivatives from sine derivative
16746 if (tauangle(1,i).gt.-pi4.and.tauangle(1,i).le.pi4.or. &
16747 tauangle(1,i).gt.pi34.and.tauangle(1,i).le.pi.or. &
16748 tauangle(1,i).gt.-pi.and.tauangle(1,i).le.-pi34) then
16749 call vecpr(dc_norm(1,i-1),dc_norm(1,i-2),vp1)
16750 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-1),vp2)
16751 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-2),vp3)
16755 cosg_inv=1.0d0/cosg
16756 dsintau(j,1,1,i)=-sing*ctgt1*domicron(j,2,2,i-1) &
16757 -(fac0*vp1(j)+sing*(dc_norm2(j,i-2+nres))) &
16758 *vbld_inv(i-2+nres)
16759 dtauangle(j,1,1,i)=cosg_inv*dsintau(j,1,1,i)
16760 dsintau(j,1,2,i)= &
16761 -sing*(ctgt1*domicron(j,2,1,i-1)+ctgt*dtheta(j,1,i)) &
16762 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
16763 ! write(iout,*) "dsintau", dsintau(j,1,2,i)
16764 dtauangle(j,1,2,i)=cosg_inv*dsintau(j,1,2,i)
16765 ! Bug fixed 3/24/05 (AL)
16766 dsintau(j,1,3,i)=-sing*ctgt*dtheta(j,2,i) &
16767 +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i)
16768 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
16769 dtauangle(j,1,3,i)=cosg_inv*dsintau(j,1,3,i)
16771 ! Obtaining the gamma derivatives from cosine derivative
16774 dcostau(j,1,1,i)=fac1*dcosomicron(j,2,2,i-1)+fac3* &
16775 dcosomicron(j,2,2,i-1)-fac0*(dc_norm(j,i-1)-scalp* &
16776 (dc_norm2(j,i-2+nres)))/vbld(i-2+nres)
16777 dtauangle(j,1,1,i)=-1/sing*dcostau(j,1,1,i)
16778 dcostau(j,1,2,i)=fac1*dcosomicron(j,2,1,i-1)+fac2* &
16779 dcostheta(j,1,i)+fac3*dcosomicron(j,2,1,i-1)+fac4* &
16781 dtauangle(j,1,2,i)=-1/sing*dcostau(j,1,2,i)
16782 dcostau(j,1,3,i)=fac2*dcostheta(j,2,i)+fac4* &
16783 dcostheta(j,2,i)-fac0*(-dc_norm(j,i-2+nres)-scalp* &
16784 dc_norm(j,i-1))/vbld(i)
16785 dtauangle(j,1,3,i)=-1/sing*dcostau(j,1,3,i)
16786 ! write (iout,*) "else",i
16790 ! write(iout,*) "tu",i,k,(dtauangle(j,1,k,i),j=1,3)
16793 !C Second case Ca...Ca...Ca...SC
16795 do i=itau_start,itau_end
16799 if ((itype(i-1,1).eq.ntyp1).or.(itype(i-1,1).eq.10).or. &
16800 (itype(i-2,1).eq.ntyp1).or.(itype(i-3,1).eq.ntyp1)) cycle
16801 ! the conventional case
16802 sint=dsin(omicron(1,i))
16803 sint1=dsin(theta(i-1))
16804 sing=dsin(tauangle(2,i))
16805 cost=dcos(omicron(1,i))
16806 cost1=dcos(theta(i-1))
16807 cosg=dcos(tauangle(2,i))
16809 ! dc_norm2(j,i-1+nres)=-dc_norm(j,i-1+nres)
16811 scalp=scalar(dc_norm(1,i-3),dc_norm(1,i-1+nres))
16812 fac0=1.0d0/(sint1*sint)
16815 fac3=cosg*cost1/(sint1*sint1)
16816 fac4=cosg*cost/(sint*sint)
16817 ! Obtaining the gamma derivatives from sine derivative
16818 if (tauangle(2,i).gt.-pi4.and.tauangle(2,i).le.pi4.or. &
16819 tauangle(2,i).gt.pi34.and.tauangle(2,i).le.pi.or. &
16820 tauangle(2,i).gt.-pi.and.tauangle(2,i).le.-pi34) then
16821 call vecpr(dc_norm2(1,i-1+nres),dc_norm(1,i-2),vp1)
16822 call vecpr(dc_norm(1,i-3),dc_norm(1,i-1+nres),vp2)
16823 call vecpr(dc_norm(1,i-3),dc_norm(1,i-2),vp3)
16827 cosg_inv=1.0d0/cosg
16828 dsintau(j,2,1,i)=-sing*ctgt1*dtheta(j,1,i-1) &
16829 +(fac0*vp1(j)-sing*dc_norm(j,i-3))*vbld_inv(i-2)
16830 ! write(iout,*) i,j,dsintau(j,2,1,i),sing*ctgt1*dtheta(j,1,i-1),
16831 ! &fac0*vp1(j),sing*dc_norm(j,i-3),vbld_inv(i-2),"dsintau(2,1)"
16832 dtauangle(j,2,1,i)=cosg_inv*dsintau(j,2,1,i)
16833 dsintau(j,2,2,i)= &
16834 -sing*(ctgt1*dtheta(j,2,i-1)+ctgt*domicron(j,1,1,i)) &
16835 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
16836 ! write(iout,*) "sprawdzenie",i,j,sing*ctgt1*dtheta(j,2,i-1),
16837 ! & sing*ctgt*domicron(j,1,2,i),
16838 ! & (fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
16839 dtauangle(j,2,2,i)=cosg_inv*dsintau(j,2,2,i)
16840 ! Bug fixed 3/24/05 (AL)
16841 dsintau(j,2,3,i)=-sing*ctgt*domicron(j,1,2,i) &
16842 +(fac0*vp3(j)-sing*dc_norm(j,i-1+nres))*vbld_inv(i-1+nres)
16843 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
16844 dtauangle(j,2,3,i)=cosg_inv*dsintau(j,2,3,i)
16846 ! Obtaining the gamma derivatives from cosine derivative
16849 dcostau(j,2,1,i)=fac1*dcostheta(j,1,i-1)+fac3* &
16850 dcostheta(j,1,i-1)-fac0*(dc_norm(j,i-1+nres)-scalp* &
16851 dc_norm(j,i-3))/vbld(i-2)
16852 dtauangle(j,2,1,i)=-1/sing*dcostau(j,2,1,i)
16853 dcostau(j,2,2,i)=fac1*dcostheta(j,2,i-1)+fac2* &
16854 dcosomicron(j,1,1,i)+fac3*dcostheta(j,2,i-1)+fac4* &
16855 dcosomicron(j,1,1,i)
16856 dtauangle(j,2,2,i)=-1/sing*dcostau(j,2,2,i)
16857 dcostau(j,2,3,i)=fac2*dcosomicron(j,1,2,i)+fac4* &
16858 dcosomicron(j,1,2,i)-fac0*(dc_norm(j,i-3)-scalp* &
16859 dc_norm(j,i-1+nres))/vbld(i-1+nres)
16860 dtauangle(j,2,3,i)=-1/sing*dcostau(j,2,3,i)
16861 ! write(iout,*) i,j,"else", dtauangle(j,2,3,i)
16866 !CC third case SC...Ca...Ca...SC
16869 do i=itau_start,itau_end
16873 ! the conventional case
16874 if ((itype(i-1,1).eq.ntyp1).or.(itype(i-1,1).eq.10).or. &
16875 (itype(i-2,1).eq.ntyp1).or.(itype(i-2,1).eq.10)) cycle
16876 sint=dsin(omicron(1,i))
16877 sint1=dsin(omicron(2,i-1))
16878 sing=dsin(tauangle(3,i))
16879 cost=dcos(omicron(1,i))
16880 cost1=dcos(omicron(2,i-1))
16881 cosg=dcos(tauangle(3,i))
16883 dc_norm2(j,i-2+nres)=-dc_norm(j,i-2+nres)
16884 ! dc_norm2(j,i-1+nres)=-dc_norm(j,i-1+nres)
16886 scalp=scalar(dc_norm2(1,i-2+nres),dc_norm(1,i-1+nres))
16887 fac0=1.0d0/(sint1*sint)
16890 fac3=cosg*cost1/(sint1*sint1)
16891 fac4=cosg*cost/(sint*sint)
16892 ! Obtaining the gamma derivatives from sine derivative
16893 if (tauangle(3,i).gt.-pi4.and.tauangle(3,i).le.pi4.or. &
16894 tauangle(3,i).gt.pi34.and.tauangle(3,i).le.pi.or. &
16895 tauangle(3,i).gt.-pi.and.tauangle(3,i).le.-pi34) then
16896 call vecpr(dc_norm(1,i-1+nres),dc_norm(1,i-2),vp1)
16897 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-1+nres),vp2)
16898 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-2),vp3)
16902 cosg_inv=1.0d0/cosg
16903 dsintau(j,3,1,i)=-sing*ctgt1*domicron(j,2,2,i-1) &
16904 -(fac0*vp1(j)-sing*dc_norm(j,i-2+nres)) &
16905 *vbld_inv(i-2+nres)
16906 dtauangle(j,3,1,i)=cosg_inv*dsintau(j,3,1,i)
16907 dsintau(j,3,2,i)= &
16908 -sing*(ctgt1*domicron(j,2,1,i-1)+ctgt*domicron(j,1,1,i)) &
16909 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
16910 dtauangle(j,3,2,i)=cosg_inv*dsintau(j,3,2,i)
16911 ! Bug fixed 3/24/05 (AL)
16912 dsintau(j,3,3,i)=-sing*ctgt*domicron(j,1,2,i) &
16913 +(fac0*vp3(j)-sing*dc_norm(j,i-1+nres)) &
16914 *vbld_inv(i-1+nres)
16915 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
16916 dtauangle(j,3,3,i)=cosg_inv*dsintau(j,3,3,i)
16918 ! Obtaining the gamma derivatives from cosine derivative
16921 dcostau(j,3,1,i)=fac1*dcosomicron(j,2,2,i-1)+fac3* &
16922 dcosomicron(j,2,2,i-1)-fac0*(dc_norm(j,i-1+nres)-scalp* &
16923 dc_norm2(j,i-2+nres))/vbld(i-2+nres)
16924 dtauangle(j,3,1,i)=-1/sing*dcostau(j,3,1,i)
16925 dcostau(j,3,2,i)=fac1*dcosomicron(j,2,1,i-1)+fac2* &
16926 dcosomicron(j,1,1,i)+fac3*dcosomicron(j,2,1,i-1)+fac4* &
16927 dcosomicron(j,1,1,i)
16928 dtauangle(j,3,2,i)=-1/sing*dcostau(j,3,2,i)
16929 dcostau(j,3,3,i)=fac2*dcosomicron(j,1,2,i)+fac4* &
16930 dcosomicron(j,1,2,i)-fac0*(dc_norm2(j,i-2+nres)-scalp* &
16931 dc_norm(j,i-1+nres))/vbld(i-1+nres)
16932 dtauangle(j,3,3,i)=-1/sing*dcostau(j,3,3,i)
16933 ! write(iout,*) "else",i
16939 ! Derivatives of side-chain angles alpha and omega
16940 #if defined(MPI) && defined(PARINTDER)
16941 do i=ibond_start,ibond_end
16945 if(itype(i,1).ne.10 .and. itype(i,1).ne.ntyp1) then
16946 fac5=1.0d0/dsqrt(2*(1+dcos(theta(i+1))))
16949 fac8=fac5/vbld(i+1)
16950 fac9=fac5/vbld(i+nres)
16951 scala1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
16952 scala2=scalar(dc_norm(1,i),dc_norm(1,i+nres))
16953 cosa=dsqrt(0.5d0/(1.0d0+dcos(theta(i+1))))* &
16954 (scalar(dC_norm(1,i),dC_norm(1,i+nres)) &
16955 -scalar(dC_norm(1,i-1),dC_norm(1,i+nres)))
16956 sina=sqrt(1-cosa*cosa)
16958 ! write (iout,*) "i",i," cosa",cosa," sina",sina," sino",sino
16960 dcosalpha(j,1,i)=fac6*(scala1*dc_norm(j,i-1)- &
16961 dc_norm(j,i+nres))-cosa*fac7*dcostheta(j,1,i+1)
16962 dalpha(j,1,i)=-1/sina*dcosalpha(j,1,i)
16963 dcosalpha(j,2,i)=fac8*(dc_norm(j,i+nres)- &
16964 scala2*dc_norm(j,i))-cosa*fac7*dcostheta(j,2,i+1)
16965 dalpha(j,2,i)=-1/sina*dcosalpha(j,2,i)
16966 dcosalpha(j,3,i)=(fac9*(dc_norm(j,i)- &
16967 dc_norm(j,i-1))-(cosa*dc_norm(j,i+nres))/ &
16969 dalpha(j,3,i)=-1/sina*dcosalpha(j,3,i)
16971 ! obtaining the derivatives of omega from sines
16972 if(omeg(i).gt.-pi4.and.omeg(i).le.pi4.or. &
16973 omeg(i).gt.pi34.and.omeg(i).le.pi.or. &
16974 omeg(i).gt.-pi.and.omeg(i).le.-pi34) then
16975 fac15=dcos(theta(i+1))/(dsin(theta(i+1))* &
16977 fac16=dcos(alph(i))/(dsin(alph(i))*dsin(alph(i)))
16978 fac17=1.0d0/(dsin(theta(i+1))*dsin(alph(i)))
16979 call vecpr(dc_norm(1,i+nres),dc_norm(1,i),vo1)
16980 call vecpr(dc_norm(1,i+nres),dc_norm(1,i-1),vo2)
16981 call vecpr(dc_norm(1,i),dc_norm(1,i-1),vo3)
16982 coso_inv=1.0d0/dcos(omeg(i))
16984 dsinomega(j,1,i)=sino*(fac15*dcostheta(j,1,i+1) &
16985 +fac16*dcosalpha(j,1,i))-fac17/vbld(i)*vo1(j)- &
16986 (sino*dc_norm(j,i-1))/vbld(i)
16987 domega(j,1,i)=coso_inv*dsinomega(j,1,i)
16988 dsinomega(j,2,i)=sino*(fac15*dcostheta(j,2,i+1) &
16989 +fac16*dcosalpha(j,2,i))+fac17/vbld(i+1)*vo2(j) &
16990 -sino*dc_norm(j,i)/vbld(i+1)
16991 domega(j,2,i)=coso_inv*dsinomega(j,2,i)
16992 dsinomega(j,3,i)=sino*fac16*dcosalpha(j,3,i)- &
16993 fac17/vbld(i+nres)*vo3(j)-sino*dc_norm(j,i+nres)/ &
16995 domega(j,3,i)=coso_inv*dsinomega(j,3,i)
16998 ! obtaining the derivatives of omega from cosines
16999 fac10=sqrt(0.5d0*(1-dcos(theta(i+1))))
17000 fac11=sqrt(0.5d0*(1+dcos(theta(i+1))))
17005 dcosomega(j,1,i)=(-(0.25d0*cosa/fac11* &
17006 dcostheta(j,1,i+1)+fac11*dcosalpha(j,1,i))*fac12+ &
17007 (0.25d0/fac10*sina*dcostheta(j,1,i+1)+cosa/sina* &
17008 fac10*dcosalpha(j,1,i))*(scala2-fac11*cosa))/fac13
17009 domega(j,1,i)=-1/sino*dcosomega(j,1,i)
17010 dcosomega(j,2,i)=(((dc_norm(j,i+nres)-scala2* &
17011 dc_norm(j,i))/vbld(i+1)-0.25d0*cosa/fac11* &
17012 dcostheta(j,2,i+1)-fac11*dcosalpha(j,2,i))*fac12+ &
17013 (scala2-fac11*cosa)*(0.25d0*sina/fac10* &
17014 dcostheta(j,2,i+1)+fac10*cosa/sina*dcosalpha(j,2,i)))/fac13
17015 domega(j,2,i)=-1/sino*dcosomega(j,2,i)
17016 dcosomega(j,3,i)=1/fac10*((1/vbld(i+nres)*(dc_norm(j,i)- &
17017 scala2*dc_norm(j,i+nres))-fac11*dcosalpha(j,3,i))*sina+ &
17018 (scala2-fac11*cosa)*(cosa/sina*dcosalpha(j,3,i)))/fac14
17019 domega(j,3,i)=-1/sino*dcosomega(j,3,i)
17025 dalpha(k,j,i)=0.0d0
17026 domega(k,j,i)=0.0d0
17032 #if defined(MPI) && defined(PARINTDER)
17033 if (nfgtasks.gt.1) then
17035 !d write (iout,*) "Gather dtheta"
17036 !d call flush(iout)
17037 write (iout,*) "dtheta before gather"
17039 write (iout,'(i3,3(3f8.5,3x))') i,((dtheta(j,k,i),k=1,3),j=1,2)
17042 call MPI_Gatherv(dtheta(1,1,ithet_start),ithet_count(fg_rank),&
17043 MPI_THET,dtheta(1,1,1),ithet_count(0),ithet_displ(0),MPI_THET,&
17044 king,FG_COMM,IERROR)
17046 !d write (iout,*) "Gather dphi"
17047 !d call flush(iout)
17048 write (iout,*) "dphi before gather"
17050 write (iout,'(i3,3(3f8.5,3x))') i,((dphi(j,k,i),k=1,3),j=1,3)
17053 call MPI_Gatherv(dphi(1,1,iphi1_start),iphi1_count(fg_rank),&
17054 MPI_GAM,dphi(1,1,1),iphi1_count(0),iphi1_displ(0),MPI_GAM,&
17055 king,FG_COMM,IERROR)
17056 !d write (iout,*) "Gather dalpha"
17057 !d call flush(iout)
17059 call MPI_Gatherv(dalpha(1,1,ibond_start),ibond_count(fg_rank),&
17060 MPI_GAM,dalpha(1,1,1),ibond_count(0),ibond_displ(0),MPI_GAM,&
17061 king,FG_COMM,IERROR)
17062 !d write (iout,*) "Gather domega"
17063 !d call flush(iout)
17064 call MPI_Gatherv(domega(1,1,ibond_start),ibond_count(fg_rank),&
17065 MPI_GAM,domega(1,1,1),ibond_count(0),ibond_displ(0),MPI_GAM,&
17066 king,FG_COMM,IERROR)
17071 write (iout,*) "dtheta after gather"
17073 write (iout,'(i3,3(3f8.5,3x))') i,((dtheta(j,k,i),j=1,3),k=1,2)
17075 write (iout,*) "dphi after gather"
17077 write (iout,'(i3,3(3f8.5,3x))') i,((dphi(j,k,i),j=1,3),k=1,3)
17079 write (iout,*) "dalpha after gather"
17081 write (iout,'(i3,3(3f8.5,3x))') i,((dalpha(j,k,i),j=1,3),k=1,3)
17083 write (iout,*) "domega after gather"
17085 write (iout,'(i3,3(3f8.5,3x))') i,((domega(j,k,i),j=1,3),k=1,3)
17089 end subroutine intcartderiv
17090 !-----------------------------------------------------------------------------
17091 subroutine checkintcartgrad
17092 ! implicit real*8 (a-h,o-z)
17093 ! include 'DIMENSIONS'
17097 ! include 'COMMON.CHAIN'
17098 ! include 'COMMON.VAR'
17099 ! include 'COMMON.GEO'
17100 ! include 'COMMON.INTERACT'
17101 ! include 'COMMON.DERIV'
17102 ! include 'COMMON.IOUNITS'
17103 ! include 'COMMON.SETUP'
17104 real(kind=8),dimension(3,2,nres) :: dthetanum !(3,2,maxres)
17105 real(kind=8),dimension(3,3,nres) :: dphinum,dalphanum,domeganum !(3,3,maxres)
17106 real(kind=8),dimension(nres) :: theta_s,phi_s,alph_s,omeg_s !(maxres)
17107 real(kind=8),dimension(3) :: dc_norm_s
17108 real(kind=8) :: aincr=1.0d-5
17110 real(kind=8) :: dcji
17113 theta_s(i)=theta(i)
17117 ! Check theta gradient
17119 "Analytical (upper) and numerical (lower) gradient of theta"
17124 dc(j,i-2)=dcji+aincr
17125 call chainbuild_cart
17126 call int_from_cart1(.false.)
17127 dthetanum(j,1,i)=(theta(i)-theta_s(i))/aincr
17130 dc(j,i-1)=dc(j,i-1)+aincr
17131 call chainbuild_cart
17132 dthetanum(j,2,i)=(theta(i)-theta_s(i))/aincr
17135 !el write (iout,'(i5,3f10.5,5x,3f10.5)') i,(dtheta(j,1,i),j=1,3),&
17136 !el (dtheta(j,2,i),j=1,3)
17137 !el write (iout,'(5x,3f10.5,5x,3f10.5)') (dthetanum(j,1,i),j=1,3),&
17138 !el (dthetanum(j,2,i),j=1,3)
17139 !el write (iout,'(5x,3f10.5,5x,3f10.5)') &
17140 !el (dthetanum(j,1,i)/dtheta(j,1,i),j=1,3),&
17141 !el (dthetanum(j,2,i)/dtheta(j,2,i),j=1,3)
17144 ! Check gamma gradient
17146 "Analytical (upper) and numerical (lower) gradient of gamma"
17150 dc(j,i-3)=dcji+aincr
17151 call chainbuild_cart
17152 dphinum(j,1,i)=(phi(i)-phi_s(i))/aincr
17155 dc(j,i-2)=dcji+aincr
17156 call chainbuild_cart
17157 dphinum(j,2,i)=(phi(i)-phi_s(i))/aincr
17160 dc(j,i-1)=dc(j,i-1)+aincr
17161 call chainbuild_cart
17162 dphinum(j,3,i)=(phi(i)-phi_s(i))/aincr
17165 !el write (iout,'(i5,3(3f10.5,5x))') i,(dphi(j,1,i),j=1,3),&
17166 !el (dphi(j,2,i),j=1,3),(dphi(j,3,i),j=1,3)
17167 !el write (iout,'(5x,3(3f10.5,5x))') (dphinum(j,1,i),j=1,3),&
17168 !el (dphinum(j,2,i),j=1,3),(dphinum(j,3,i),j=1,3)
17169 !el write (iout,'(5x,3(3f10.5,5x))') &
17170 !el (dphinum(j,1,i)/dphi(j,1,i),j=1,3),&
17171 !el (dphinum(j,2,i)/dphi(j,2,i),j=1,3),&
17172 !el (dphinum(j,3,i)/dphi(j,3,i),j=1,3)
17175 ! Check alpha gradient
17177 "Analytical (upper) and numerical (lower) gradient of alpha"
17179 if(itype(i,1).ne.10) then
17182 dc(j,i-1)=dcji+aincr
17183 call chainbuild_cart
17184 dalphanum(j,1,i)=(alph(i)-alph_s(i)) &
17189 call chainbuild_cart
17190 dalphanum(j,2,i)=(alph(i)-alph_s(i)) &
17194 dc(j,i+nres)=dc(j,i+nres)+aincr
17195 call chainbuild_cart
17196 dalphanum(j,3,i)=(alph(i)-alph_s(i)) &
17201 !el write (iout,'(i5,3(3f10.5,5x))') i,(dalpha(j,1,i),j=1,3),&
17202 !el (dalpha(j,2,i),j=1,3),(dalpha(j,3,i),j=1,3)
17203 !el write (iout,'(5x,3(3f10.5,5x))') (dalphanum(j,1,i),j=1,3),&
17204 !el (dalphanum(j,2,i),j=1,3),(dalphanum(j,3,i),j=1,3)
17205 !el write (iout,'(5x,3(3f10.5,5x))') &
17206 !el (dalphanum(j,1,i)/dalpha(j,1,i),j=1,3),&
17207 !el (dalphanum(j,2,i)/dalpha(j,2,i),j=1,3),&
17208 !el (dalphanum(j,3,i)/dalpha(j,3,i),j=1,3)
17211 ! Check omega gradient
17213 "Analytical (upper) and numerical (lower) gradient of omega"
17215 if(itype(i,1).ne.10) then
17218 dc(j,i-1)=dcji+aincr
17219 call chainbuild_cart
17220 domeganum(j,1,i)=(omeg(i)-omeg_s(i)) &
17225 call chainbuild_cart
17226 domeganum(j,2,i)=(omeg(i)-omeg_s(i)) &
17230 dc(j,i+nres)=dc(j,i+nres)+aincr
17231 call chainbuild_cart
17232 domeganum(j,3,i)=(omeg(i)-omeg_s(i)) &
17237 !el write (iout,'(i5,3(3f10.5,5x))') i,(domega(j,1,i),j=1,3),&
17238 !el (domega(j,2,i),j=1,3),(domega(j,3,i),j=1,3)
17239 !el write (iout,'(5x,3(3f10.5,5x))') (domeganum(j,1,i),j=1,3),&
17240 !el (domeganum(j,2,i),j=1,3),(domeganum(j,3,i),j=1,3)
17241 !el write (iout,'(5x,3(3f10.5,5x))') &
17242 !el (domeganum(j,1,i)/domega(j,1,i),j=1,3),&
17243 !el (domeganum(j,2,i)/domega(j,2,i),j=1,3),&
17244 !el (domeganum(j,3,i)/domega(j,3,i),j=1,3)
17248 end subroutine checkintcartgrad
17249 !-----------------------------------------------------------------------------
17251 !-----------------------------------------------------------------------------
17252 real(kind=8) function qwolynes(seg1,seg2,flag,seg3,seg4)
17253 ! implicit real*8 (a-h,o-z)
17254 ! include 'DIMENSIONS'
17255 ! include 'COMMON.IOUNITS'
17256 ! include 'COMMON.CHAIN'
17257 ! include 'COMMON.INTERACT'
17258 ! include 'COMMON.VAR'
17259 integer :: i,j,jl,k,l,il,kl,nl,np,ip,kp,seg1,seg2,seg3,seg4,secseg
17260 integer :: kkk,nsep=3
17261 real(kind=8) :: qm !dist,
17262 real(kind=8) :: qq,qqij,qqijCM,dij,d0ij,dijCM,d0ijCM,qqmax
17263 logical :: lprn=.false.
17265 ! real(kind=8) :: sigm,x
17267 !el sigm(x)=0.25d0*x ! local function
17273 do il=seg1+nsep,seg2
17276 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2 + &
17277 (cref(2,jl,kkk)-cref(2,il,kkk))**2 + &
17278 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
17280 qqij = dexp(-0.5d0*((dij-d0ij)/(sigm(d0ij)))**2)
17281 if (itype(il,1).ne.10 .or. itype(jl,1).ne.10) then
17284 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
17285 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
17286 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
17287 dijCM=dist(il+nres,jl+nres)
17288 qqijCM = dexp(-0.5d0*((dijCM-d0ijCM)/(sigm(d0ijCM)))**2)
17290 qq = qq+qqij+qqijCM
17296 if((seg3-il).lt.3) then
17303 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2+ &
17304 (cref(2,jl,kkk)-cref(2,il,kkk))**2+ &
17305 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
17307 qqij = dexp(-0.5d0*((dij-d0ij)/(sigm(d0ij)))**2)
17308 if (itype(il,1).ne.10 .or. itype(jl,1).ne.10) then
17311 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
17312 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
17313 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
17314 dijCM=dist(il+nres,jl+nres)
17315 qqijCM = dexp(-0.5d0*((dijCM-d0ijCM)/(sigm(d0ijCM)))**2)
17317 qq = qq+qqij+qqijCM
17322 if (qqmax.le.qq) qqmax=qq
17324 qwolynes=1.0d0-qqmax
17326 end function qwolynes
17327 !-----------------------------------------------------------------------------
17328 subroutine qwolynes_prim(seg1,seg2,flag,seg3,seg4)
17329 ! implicit real*8 (a-h,o-z)
17330 ! include 'DIMENSIONS'
17331 ! include 'COMMON.IOUNITS'
17332 ! include 'COMMON.CHAIN'
17333 ! include 'COMMON.INTERACT'
17334 ! include 'COMMON.VAR'
17335 ! include 'COMMON.MD'
17336 integer :: i,j,jl,k,l,il,nl,seg1,seg2,seg3,seg4,secseg
17337 integer :: nsep=3, kkk
17338 !el real(kind=8) :: dist
17339 real(kind=8) :: dij,d0ij,dijCM,d0ijCM
17340 logical :: lprn=.false.
17342 real(kind=8) :: sim,dd0,fac,ddqij
17343 !el sigm(x)=0.25d0*x ! local function
17353 do il=seg1+nsep,seg2
17356 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2+ &
17357 (cref(2,jl,kkk)-cref(2,il,kkk))**2+ &
17358 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
17360 sim = 1.0d0/sigm(d0ij)
17363 fac = dd0*sim/dij*dexp(-0.5d0*dd0*dd0*sim)
17365 ddqij = (c(k,il)-c(k,jl))*fac
17366 dqwol(k,il)=dqwol(k,il)+ddqij
17367 dqwol(k,jl)=dqwol(k,jl)-ddqij
17370 if (itype(il,1).ne.10 .or. itype(jl,1).ne.10) then
17373 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
17374 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
17375 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
17376 dijCM=dist(il+nres,jl+nres)
17377 sim = 1.0d0/sigm(d0ijCM)
17380 fac=dd0*sim/dijCM*dexp(-0.5d0*dd0*dd0*sim)
17382 ddqij = (c(k,il+nres)-c(k,jl+nres))*fac
17383 dxqwol(k,il)=dxqwol(k,il)+ddqij
17384 dxqwol(k,jl)=dxqwol(k,jl)-ddqij
17391 if((seg3-il).lt.3) then
17398 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2+ &
17399 (cref(2,jl,kkk)-cref(2,il,kkk))**2+ &
17400 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
17402 sim = 1.0d0/sigm(d0ij)
17405 fac = dd0*sim/dij*dexp(-0.5d0*dd0*dd0*sim)
17407 ddqij = (c(k,il)-c(k,jl))*fac
17408 dqwol(k,il)=dqwol(k,il)+ddqij
17409 dqwol(k,jl)=dqwol(k,jl)-ddqij
17411 if (itype(il,1).ne.10 .or. itype(jl,1).ne.10) then
17414 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
17415 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
17416 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
17417 dijCM=dist(il+nres,jl+nres)
17418 sim = 1.0d0/sigm(d0ijCM)
17421 fac = dd0*sim/dijCM*dexp(-0.5d0*dd0*dd0*sim)
17423 ddqij = (c(k,il+nres)-c(k,jl+nres))*fac
17424 dxqwol(k,il)=dxqwol(k,il)+ddqij
17425 dxqwol(k,jl)=dxqwol(k,jl)-ddqij
17434 dqwol(j,i)=dqwol(j,i)/nl
17435 dxqwol(j,i)=dxqwol(j,i)/nl
17439 end subroutine qwolynes_prim
17440 !-----------------------------------------------------------------------------
17441 subroutine qwol_num(seg1,seg2,flag,seg3,seg4)
17442 ! implicit real*8 (a-h,o-z)
17443 ! include 'DIMENSIONS'
17444 ! include 'COMMON.IOUNITS'
17445 ! include 'COMMON.CHAIN'
17446 ! include 'COMMON.INTERACT'
17447 ! include 'COMMON.VAR'
17448 integer :: seg1,seg2,seg3,seg4
17450 real(kind=8),dimension(3,0:nres) :: qwolan,qwolxan
17451 real(kind=8),dimension(3,0:2*nres) :: cdummy
17452 real(kind=8) :: q1,q2
17453 real(kind=8) :: delta=1.0d-10
17458 q1=qwolynes(seg1,seg2,flag,seg3,seg4)
17460 c(j,i)=c(j,i)+delta
17461 q2=qwolynes(seg1,seg2,flag,seg3,seg4)
17462 qwolan(j,i)=(q2-q1)/delta
17468 q1=qwolynes(seg1,seg2,flag,seg3,seg4)
17469 cdummy(j,i+nres)=c(j,i+nres)
17470 c(j,i+nres)=c(j,i+nres)+delta
17471 q2=qwolynes(seg1,seg2,flag,seg3,seg4)
17472 qwolxan(j,i)=(q2-q1)/delta
17473 c(j,i+nres)=cdummy(j,i+nres)
17476 ! write(iout,*) "Numerical Q carteisan gradients backbone: "
17478 ! write(iout,'(i5,3e15.5)') i, (qwolan(j,i),j=1,3)
17480 ! write(iout,*) "Numerical Q carteisan gradients side-chain: "
17482 ! write(iout,'(i5,3e15.5)') i, (qwolxan(j,i),j=1,3)
17485 end subroutine qwol_num
17486 !-----------------------------------------------------------------------------
17487 subroutine EconstrQ
17488 ! MD with umbrella_sampling using Wolyne's distance measure as a constraint
17489 ! implicit real*8 (a-h,o-z)
17490 ! include 'DIMENSIONS'
17491 ! include 'COMMON.CONTROL'
17492 ! include 'COMMON.VAR'
17493 ! include 'COMMON.MD'
17496 ! include 'COMMON.LANGEVIN'
17498 ! include 'COMMON.LANGEVIN.lang0'
17500 ! include 'COMMON.CHAIN'
17501 ! include 'COMMON.DERIV'
17502 ! include 'COMMON.GEO'
17503 ! include 'COMMON.LOCAL'
17504 ! include 'COMMON.INTERACT'
17505 ! include 'COMMON.IOUNITS'
17506 ! include 'COMMON.NAMES'
17507 ! include 'COMMON.TIME1'
17508 real(kind=8) :: uzap1,uzap2,hm1,hm2,hmnum,ucdelan
17509 real(kind=8),dimension(3,0:nres) :: dUcartan,dUxcartan,cdummy,&
17511 integer :: kstart,kend,lstart,lend,idummy
17512 real(kind=8) :: delta=1.0d-7
17513 integer :: i,j,k,ii
17517 dudconst(j,i)=0.0d0
17518 duxconst(j,i)=0.0d0
17519 dudxconst(j,i)=0.0d0
17524 qfrag(i)=qwolynes(ifrag(1,i,iset),ifrag(2,i,iset),.true.,&
17526 Uconst=Uconst+wfrag(i,iset)*harmonic(qfrag(i),qinfrag(i,iset))
17527 ! Calculating the derivatives of Constraint energy with respect to Q
17528 Ucdfrag=wfrag(i,iset)*harmonicprim(qfrag(i),&
17530 ! hm1=harmonic(qfrag(i,iset),qinfrag(i,iset))
17531 ! hm2=harmonic(qfrag(i,iset)+delta,qinfrag(i,iset))
17532 ! hmnum=(hm2-hm1)/delta
17533 ! write(iout,*) "harmonicprim frag",harmonicprim(qfrag(i,iset),
17534 ! & qinfrag(i,iset))
17535 ! write(iout,*) "harmonicnum frag", hmnum
17536 ! Calculating the derivatives of Q with respect to cartesian coordinates
17537 call qwolynes_prim(ifrag(1,i,iset),ifrag(2,i,iset),.true.,&
17539 ! write(iout,*) "dqwol "
17541 ! write(iout,'(i5,3e15.5)') ii,(dqwol(j,ii),j=1,3)
17543 ! write(iout,*) "dxqwol "
17545 ! write(iout,'(i5,3e15.5)') ii,(dxqwol(j,ii),j=1,3)
17547 ! Calculating numerical gradients of dU/dQi and dQi/dxi
17548 ! call qwol_num(ifrag(1,i,iset),ifrag(2,i,iset),.true.
17549 ! & ,idummy,idummy)
17550 ! The gradients of Uconst in Cs
17553 duconst(j,ii)=dUconst(j,ii)+ucdfrag*dqwol(j,ii)
17554 dUxconst(j,ii)=dUxconst(j,ii)+ucdfrag*dxqwol(j,ii)
17559 kstart=ifrag(1,ipair(1,i,iset),iset)
17560 kend=ifrag(2,ipair(1,i,iset),iset)
17561 lstart=ifrag(1,ipair(2,i,iset),iset)
17562 lend=ifrag(2,ipair(2,i,iset),iset)
17563 qpair(i)=qwolynes(kstart,kend,.false.,lstart,lend)
17564 Uconst=Uconst+wpair(i,iset)*harmonic(qpair(i),qinpair(i,iset))
17565 ! Calculating dU/dQ
17566 Ucdpair=wpair(i,iset)*harmonicprim(qpair(i),qinpair(i,iset))
17567 ! hm1=harmonic(qpair(i),qinpair(i,iset))
17568 ! hm2=harmonic(qpair(i)+delta,qinpair(i,iset))
17569 ! hmnum=(hm2-hm1)/delta
17570 ! write(iout,*) "harmonicprim pair ",harmonicprim(qpair(i),
17571 ! & qinpair(i,iset))
17572 ! write(iout,*) "harmonicnum pair ", hmnum
17573 ! Calculating dQ/dXi
17574 call qwolynes_prim(kstart,kend,.false.,&
17576 ! write(iout,*) "dqwol "
17578 ! write(iout,'(i5,3e15.5)') ii,(dqwol(j,ii),j=1,3)
17580 ! write(iout,*) "dxqwol "
17582 ! write(iout,'(i5,3e15.5)') ii,(dxqwol(j,ii),j=1,3)
17584 ! Calculating numerical gradients
17585 ! call qwol_num(kstart,kend,.false.
17587 ! The gradients of Uconst in Cs
17590 duconst(j,ii)=dUconst(j,ii)+ucdpair*dqwol(j,ii)
17591 dUxconst(j,ii)=dUxconst(j,ii)+ucdpair*dxqwol(j,ii)
17595 ! write(iout,*) "Uconst inside subroutine ", Uconst
17596 ! Transforming the gradients from Cs to dCs for the backbone
17600 dudconst(k,i)=dudconst(k,i)+duconst(k,j)+duxconst(k,j)
17604 ! Transforming the gradients from Cs to dCs for the side chains
17607 dudxconst(j,i)=duxconst(j,i)
17610 ! write(iout,*) "dU/ddc backbone "
17612 ! write(iout,'(i5,3e15.5)') ii, (dudconst(j,ii),j=1,3)
17614 ! write(iout,*) "dU/ddX side chain "
17616 ! write(iout,'(i5,3e15.5)') ii,(duxconst(j,ii),j=1,3)
17618 ! Calculating numerical gradients of dUconst/ddc and dUconst/ddx
17619 ! call dEconstrQ_num
17621 end subroutine EconstrQ
17622 !-----------------------------------------------------------------------------
17623 subroutine dEconstrQ_num
17624 ! Calculating numerical dUconst/ddc and dUconst/ddx
17625 ! implicit real*8 (a-h,o-z)
17626 ! include 'DIMENSIONS'
17627 ! include 'COMMON.CONTROL'
17628 ! include 'COMMON.VAR'
17629 ! include 'COMMON.MD'
17632 ! include 'COMMON.LANGEVIN'
17634 ! include 'COMMON.LANGEVIN.lang0'
17636 ! include 'COMMON.CHAIN'
17637 ! include 'COMMON.DERIV'
17638 ! include 'COMMON.GEO'
17639 ! include 'COMMON.LOCAL'
17640 ! include 'COMMON.INTERACT'
17641 ! include 'COMMON.IOUNITS'
17642 ! include 'COMMON.NAMES'
17643 ! include 'COMMON.TIME1'
17644 real(kind=8) :: uzap1,uzap2
17645 real(kind=8),dimension(3,0:nres) :: dUcartan,dUxcartan,cdummy
17646 integer :: kstart,kend,lstart,lend,idummy
17647 real(kind=8) :: delta=1.0d-7
17648 !el local variables
17654 dUcartan(j,i)=0.0d0
17655 cdummy(j,i)=dc(j,i)
17656 dc(j,i)=dc(j,i)+delta
17657 call chainbuild_cart
17660 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),.true.,&
17662 uzap2=uzap2+wfrag(ii,iset)*harmonic(qfrag(ii),&
17666 kstart=ifrag(1,ipair(1,ii,iset),iset)
17667 kend=ifrag(2,ipair(1,ii,iset),iset)
17668 lstart=ifrag(1,ipair(2,ii,iset),iset)
17669 lend=ifrag(2,ipair(2,ii,iset),iset)
17670 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
17671 uzap2=uzap2+wpair(ii,iset)*harmonic(qpair(ii),&
17674 dc(j,i)=cdummy(j,i)
17675 call chainbuild_cart
17678 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),.true.,&
17680 uzap1=uzap1+wfrag(ii,iset)*harmonic(qfrag(ii),&
17684 kstart=ifrag(1,ipair(1,ii,iset),iset)
17685 kend=ifrag(2,ipair(1,ii,iset),iset)
17686 lstart=ifrag(1,ipair(2,ii,iset),iset)
17687 lend=ifrag(2,ipair(2,ii,iset),iset)
17688 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
17689 uzap1=uzap1+wpair(ii,iset)*harmonic(qpair(ii),&
17692 ducartan(j,i)=(uzap2-uzap1)/(delta)
17695 ! Calculating numerical gradients for dU/ddx
17697 duxcartan(j,i)=0.0d0
17699 cdummy(j,i)=dc(j,i+nres)
17700 dc(j,i+nres)=dc(j,i+nres)+delta
17701 call chainbuild_cart
17704 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),.true.,&
17706 uzap2=uzap2+wfrag(ii,iset)*harmonic(qfrag(ii),&
17710 kstart=ifrag(1,ipair(1,ii,iset),iset)
17711 kend=ifrag(2,ipair(1,ii,iset),iset)
17712 lstart=ifrag(1,ipair(2,ii,iset),iset)
17713 lend=ifrag(2,ipair(2,ii,iset),iset)
17714 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
17715 uzap2=uzap2+wpair(ii,iset)*harmonic(qpair(ii),&
17718 dc(j,i+nres)=cdummy(j,i)
17719 call chainbuild_cart
17722 qfrag(ii)=qwolynes(ifrag(1,ii,iset),&
17723 ifrag(2,ii,iset),.true.,idummy,idummy)
17724 uzap1=uzap1+wfrag(ii,iset)*harmonic(qfrag(ii),&
17728 kstart=ifrag(1,ipair(1,ii,iset),iset)
17729 kend=ifrag(2,ipair(1,ii,iset),iset)
17730 lstart=ifrag(1,ipair(2,ii,iset),iset)
17731 lend=ifrag(2,ipair(2,ii,iset),iset)
17732 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
17733 uzap1=uzap1+wpair(ii,iset)*harmonic(qpair(ii),&
17736 duxcartan(j,i)=(uzap2-uzap1)/(delta)
17739 write(iout,*) "Numerical dUconst/ddc backbone "
17741 write(iout,'(i5,3e15.5)') ii,(dUcartan(j,ii),j=1,3)
17743 ! write(iout,*) "Numerical dUconst/ddx side-chain "
17745 ! write(iout,'(i5,3e15.5)') ii,(dUxcartan(j,ii),j=1,3)
17748 end subroutine dEconstrQ_num
17749 !-----------------------------------------------------------------------------
17751 !-----------------------------------------------------------------------------
17752 subroutine check_energies
17754 ! use random, only: ran_number
17758 ! include 'DIMENSIONS'
17759 ! include 'COMMON.CHAIN'
17760 ! include 'COMMON.VAR'
17761 ! include 'COMMON.IOUNITS'
17762 ! include 'COMMON.SBRIDGE'
17763 ! include 'COMMON.LOCAL'
17764 ! include 'COMMON.GEO'
17766 ! External functions
17767 !EL double precision ran_number
17768 !EL external ran_number
17771 integer :: i,j,k,l,lmax,p,pmax
17772 real(kind=8) :: rmin,rmax
17773 real(kind=8) :: eij
17776 real(kind=8) :: wi,rij,tj,pj
17798 !t wi=ran_number(0.0D0,pi)
17799 ! wi=ran_number(0.0D0,pi/6.0D0)
17801 !t tj=ran_number(0.0D0,pi)
17802 !t pj=ran_number(0.0D0,pi)
17803 ! pj=ran_number(0.0D0,pi/6.0D0)
17807 !t rij=ran_number(rmin,rmax)
17809 c(1,j)=d*sin(pj)*cos(tj)
17810 c(2,j)=d*sin(pj)*sin(tj)
17816 c(3,i)=-rij-d*cos(wi)
17819 dc(k,nres+i)=c(k,nres+i)-c(k,i)
17820 dc_norm(k,nres+i)=dc(k,nres+i)/d
17821 dc(k,nres+j)=c(k,nres+j)-c(k,j)
17822 dc_norm(k,nres+j)=dc(k,nres+j)/d
17825 call dyn_ssbond_ene(i,j,eij)
17830 end subroutine check_energies
17831 !-----------------------------------------------------------------------------
17832 subroutine dyn_ssbond_ene(resi,resj,eij)
17837 ! include 'DIMENSIONS'
17838 ! include 'COMMON.SBRIDGE'
17839 ! include 'COMMON.CHAIN'
17840 ! include 'COMMON.DERIV'
17841 ! include 'COMMON.LOCAL'
17842 ! include 'COMMON.INTERACT'
17843 ! include 'COMMON.VAR'
17844 ! include 'COMMON.IOUNITS'
17845 ! include 'COMMON.CALC'
17849 ! include 'COMMON.MD'
17850 ! use MD, only: totT,t_bath
17853 ! External functions
17854 !EL double precision h_base
17855 !EL external h_base
17858 integer :: resi,resj
17861 real(kind=8) :: eij
17864 logical :: havebond
17865 integer itypi,itypj
17866 real(kind=8) :: rrij,ssd,deltat1,deltat2,deltat12,cosphi
17867 real(kind=8) :: sig0ij,ljd,sig,fac,e1,e2
17868 real(kind=8),dimension(3) :: dcosom1,dcosom2
17870 real(kind=8) :: pom1,pom2
17871 real(kind=8) :: ljA,ljB,ljXs
17872 real(kind=8),dimension(1:3) :: d_ljB
17873 real(kind=8) :: ssA,ssB,ssC,ssXs
17874 real(kind=8) :: ssxm,ljxm,ssm,ljm
17875 real(kind=8),dimension(1:3) :: d_ssxm,d_ljxm,d_ssm,d_ljm
17876 real(kind=8) :: f1,f2,h1,h2,hd1,hd2
17877 real(kind=8) :: omega,delta_inv,deltasq_inv,fac1,fac2
17878 !-------FIRST METHOD
17880 real(kind=8),dimension(1:3) :: d_xm
17881 !-------END FIRST METHOD
17882 !-------SECOND METHOD
17883 !$$$ double precision ss,d_ss(0:3),ljf,d_ljf(0:3)
17884 !-------END SECOND METHOD
17886 !-------TESTING CODE
17887 !el logical :: checkstop,transgrad
17888 !el common /sschecks/ checkstop,transgrad
17890 integer :: icheck,nicheck,jcheck,njcheck
17891 real(kind=8),dimension(-1:1) :: echeck
17892 real(kind=8) :: deps,ssx0,ljx0
17893 !-------END TESTING CODE
17899 !el allocate(dyn_ssbond_ij(iatsc_s:iatsc_e,nres))
17900 !el allocate(dyn_ssbond_ij(0:nres+4,nres))
17903 dxi=dc_norm(1,nres+i)
17904 dyi=dc_norm(2,nres+i)
17905 dzi=dc_norm(3,nres+i)
17906 dsci_inv=vbld_inv(i+nres)
17909 xj=c(1,nres+j)-c(1,nres+i)
17910 yj=c(2,nres+j)-c(2,nres+i)
17911 zj=c(3,nres+j)-c(3,nres+i)
17912 dxj=dc_norm(1,nres+j)
17913 dyj=dc_norm(2,nres+j)
17914 dzj=dc_norm(3,nres+j)
17915 dscj_inv=vbld_inv(j+nres)
17917 chi1=chi(itypi,itypj)
17918 chi2=chi(itypj,itypi)
17925 alf12=0.5D0*(alf1+alf2)
17927 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
17928 rij=dsqrt(rrij) ! sc_angular needs rij to really be the inverse
17929 ! The following are set in sc_angular
17933 ! om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
17934 ! om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
17935 ! om12=dxi*dxj+dyi*dyj+dzi*dzj
17937 rij=1.0D0/rij ! Reset this so it makes sense
17939 sig0ij=sigma(itypi,itypj)
17940 sig=sig0ij*dsqrt(1.0D0/sigsq)
17943 ljA=eps1*eps2rt**2*eps3rt**2
17944 ljB=ljA*bb_aq(itypi,itypj)
17945 ljA=ljA*aa_aq(itypi,itypj)
17946 ljxm=ljXs+(-2.0D0*aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
17951 deltat12=om2-om1+2.0d0
17952 cosphi=om12-om1*om2
17956 +akth*(deltat1*deltat1+deltat2*deltat2) &
17957 +v1ss*cosphi+v2ss*cosphi*cosphi+v3ss*cosphi*cosphi*cosphi
17958 ssxm=ssXs-0.5D0*ssB/ssA
17960 !-------TESTING CODE
17961 !$$$c Some extra output
17962 !$$$ ssm=ssC-0.25D0*ssB*ssB/ssA
17963 !$$$ ljm=-0.25D0*ljB*bb(itypi,itypj)/aa(itypi,itypj)
17964 !$$$ ssx0=ssB*ssB-4.0d0*ssA*ssC
17965 !$$$ if (ssx0.gt.0.0d0) then
17966 !$$$ ssx0=ssXs+0.5d0*(-ssB+sqrt(ssx0))/ssA
17970 !$$$ ljx0=ljXs+(-aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
17971 !$$$ write(iout,'(a,4f8.2,2f15.2,3f6.2)')"SSENERGIES ",
17972 !$$$ & ssxm,ljxm,ssx0,ljx0,ssm,ljm,om1,om2,om12
17974 !-------END TESTING CODE
17976 !-------TESTING CODE
17977 ! Stop and plot energy and derivative as a function of distance
17978 if (checkstop) then
17979 ssm=ssC-0.25D0*ssB*ssB/ssA
17980 ljm=-0.25D0*ljB*bb_aq(itypi,itypj)/aa_aq(itypi,itypj)
17981 if (ssm.lt.ljm .and. &
17982 dabs(rij-0.5d0*(ssxm+ljxm)).lt.0.35d0*(ljxm-ssxm)) then
17990 if (.not.checkstop) then
17995 do icheck=0,nicheck
17996 do jcheck=-1,njcheck
17997 if (checkstop) rij=(ssxm-1.0d0)+ &
17998 ((ljxm-ssxm+2.0d0)*icheck)/nicheck+jcheck*deps
17999 !-------END TESTING CODE
18001 if (rij.gt.ljxm) then
18004 fac=(1.0D0/ljd)**expon
18005 e1=fac*fac*aa_aq(itypi,itypj)
18006 e2=fac*bb_aq(itypi,itypj)
18007 eij=eps1*eps2rt*eps3rt*(e1+e2)
18010 eij=eij*eps2rt*eps3rt
18013 e1=e1*eps1*eps2rt**2*eps3rt**2
18014 ed=-expon*(e1+eij)/ljd
18016 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
18017 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
18018 eom12=eij*eps1_om12+eps2der*eps2rt_om12 &
18019 -2.0D0*alf12*eps3der+sigder*sigsq_om12
18020 else if (rij.lt.ssxm) then
18023 eij=ssA*ssd*ssd+ssB*ssd+ssC
18025 ed=2*akcm*ssd+akct*deltat12
18027 pom2=v1ss+2*v2ss*cosphi+3*v3ss*cosphi*cosphi
18028 eom1=-2*akth*deltat1-pom1-om2*pom2
18029 eom2= 2*akth*deltat2+pom1-om1*pom2
18032 omega=v1ss+2.0d0*v2ss*cosphi+3.0d0*v3ss*cosphi*cosphi
18034 d_ssxm(1)=0.5D0*akct/ssA
18035 d_ssxm(2)=-d_ssxm(1)
18038 d_ljxm(1)=sig0ij/sqrt(sigsq**3)
18039 d_ljxm(2)=d_ljxm(1)*sigsq_om2
18040 d_ljxm(3)=d_ljxm(1)*sigsq_om12
18041 d_ljxm(1)=d_ljxm(1)*sigsq_om1
18043 !-------FIRST METHOD, DISCONTINUOUS SECOND DERIVATIVE
18044 xm=0.5d0*(ssxm+ljxm)
18046 d_xm(k)=0.5d0*(d_ssxm(k)+d_ljxm(k))
18048 if (rij.lt.xm) then
18050 ssm=ssC-0.25D0*ssB*ssB/ssA
18051 d_ssm(1)=0.5D0*akct*ssB/ssA
18052 d_ssm(2)=2.0D0*akth*deltat2-om1*omega-d_ssm(1)
18053 d_ssm(1)=-2.0D0*akth*deltat1-om2*omega+d_ssm(1)
18055 f1=(rij-xm)/(ssxm-xm)
18056 f2=(rij-ssxm)/(xm-ssxm)
18060 delta_inv=1.0d0/(xm-ssxm)
18061 deltasq_inv=delta_inv*delta_inv
18063 fac1=deltasq_inv*fac*(xm-rij)
18064 fac2=deltasq_inv*fac*(rij-ssxm)
18065 ed=delta_inv*(Ht*hd2-ssm*hd1)
18066 eom1=fac1*d_ssxm(1)+fac2*d_xm(1)+h1*d_ssm(1)
18067 eom2=fac1*d_ssxm(2)+fac2*d_xm(2)+h1*d_ssm(2)
18068 eom12=fac1*d_ssxm(3)+fac2*d_xm(3)+h1*d_ssm(3)
18071 ljm=-0.25D0*ljB*bb_aq(itypi,itypj)/aa_aq(itypi,itypj)
18072 d_ljm(1)=-0.5D0*bb_aq(itypi,itypj)/aa_aq(itypi,itypj)*ljB
18073 d_ljm(2)=d_ljm(1)*(0.5D0*eps2rt_om2/eps2rt+alf2/eps3rt)
18074 d_ljm(3)=d_ljm(1)*(0.5D0*eps1_om12+0.5D0*eps2rt_om12/eps2rt- &
18076 d_ljm(1)=d_ljm(1)*(0.5D0*eps2rt_om1/eps2rt-alf1/eps3rt)
18077 f1=(rij-ljxm)/(xm-ljxm)
18078 f2=(rij-xm)/(ljxm-xm)
18082 delta_inv=1.0d0/(ljxm-xm)
18083 deltasq_inv=delta_inv*delta_inv
18085 fac1=deltasq_inv*fac*(ljxm-rij)
18086 fac2=deltasq_inv*fac*(rij-xm)
18087 ed=delta_inv*(ljm*hd2-Ht*hd1)
18088 eom1=fac1*d_xm(1)+fac2*d_ljxm(1)+h2*d_ljm(1)
18089 eom2=fac1*d_xm(2)+fac2*d_ljxm(2)+h2*d_ljm(2)
18090 eom12=fac1*d_xm(3)+fac2*d_ljxm(3)+h2*d_ljm(3)
18092 !-------END FIRST METHOD, DISCONTINUOUS SECOND DERIVATIVE
18094 !-------SECOND METHOD, CONTINUOUS SECOND DERIVATIVE
18100 !$$$ d_ljB(1)=ljB*(eps2rt_om1/eps2rt-2.0d0*alf1/eps3rt)
18101 !$$$ d_ljB(2)=ljB*(eps2rt_om2/eps2rt+2.0d0*alf2/eps3rt)
18102 !$$$ d_ljB(3)=ljB*(eps1_om12+eps2rt_om12/eps2rt-2.0d0*alf12/eps3rt)
18104 !$$$ ssm=ssC-0.25D0*ssB*ssB/ssA
18105 !$$$ d_ssm(1)=0.5D0*akct*ssB/ssA
18106 !$$$ d_ssm(2)=2.0D0*akth*deltat2-om1*omega-d_ssm(1)
18107 !$$$ d_ssm(1)=-2.0D0*akth*deltat1-om2*omega+d_ssm(1)
18108 !$$$ d_ssm(3)=omega
18110 !$$$ ljm=-0.25D0*bb(itypi,itypj)/aa(itypi,itypj)
18112 !$$$ d_ljm(k)=ljm*d_ljB(k)
18116 !$$$ ss=ssA*ssd*ssd+ssB*ssd+ssC
18117 !$$$ d_ss(0)=2.0d0*ssA*ssd+ssB
18118 !$$$ d_ss(2)=akct*ssd
18119 !$$$ d_ss(1)=-d_ss(2)-2.0d0*akth*deltat1-om2*omega
18120 !$$$ d_ss(2)=d_ss(2)+2.0d0*akth*deltat2-om1*omega
18123 !$$$ ljf=bb(itypi,itypj)/aa(itypi,itypj)
18124 !$$$ ljf=9.0d0*ljf*(-0.5d0*ljf)**(1.0d0/3.0d0)
18125 !$$$ d_ljf(0)=ljf*2.0d0*ljB*fac1
18127 !$$$ d_ljf(k)=d_ljm(k)+ljf*(d_ljB(k)*fac1*fac1-
18128 !$$$ & 2.0d0*ljB*fac1*d_ljxm(k))
18130 !$$$ ljf=ljm+ljf*ljB*fac1*fac1
18132 !$$$ f1=(rij-ljxm)/(ssxm-ljxm)
18133 !$$$ f2=(rij-ssxm)/(ljxm-ssxm)
18134 !$$$ h1=h_base(f1,hd1)
18135 !$$$ h2=h_base(f2,hd2)
18136 !$$$ eij=ss*h1+ljf*h2
18137 !$$$ delta_inv=1.0d0/(ljxm-ssxm)
18138 !$$$ deltasq_inv=delta_inv*delta_inv
18139 !$$$ fac=ljf*hd2-ss*hd1
18140 !$$$ ed=d_ss(0)*h1+d_ljf(0)*h2+delta_inv*fac
18141 !$$$ eom1=d_ss(1)*h1+d_ljf(1)*h2+deltasq_inv*fac*
18142 !$$$ & (fac1*d_ssxm(1)-fac2*(d_ljxm(1)))
18143 !$$$ eom2=d_ss(2)*h1+d_ljf(2)*h2+deltasq_inv*fac*
18144 !$$$ & (fac1*d_ssxm(2)-fac2*(d_ljxm(2)))
18145 !$$$ eom12=d_ss(3)*h1+d_ljf(3)*h2+deltasq_inv*fac*
18146 !$$$ & (fac1*d_ssxm(3)-fac2*(d_ljxm(3)))
18148 !$$$ havebond=.false.
18149 !$$$ if (ed.gt.0.0d0) havebond=.true.
18150 !-------END SECOND METHOD, CONTINUOUS SECOND DERIVATIVE
18157 ! if (dyn_ssbond_ij(i,j).eq.1.0d300) then
18158 ! write(iout,'(a15,f12.2,f8.1,2i5)')
18159 ! & "SSBOND_E_FORM",totT,t_bath,i,j
18163 dyn_ssbond_ij(i,j)=eij
18164 else if (.not.havebond .and. dyn_ssbond_ij(i,j).lt.1.0d300) then
18165 dyn_ssbond_ij(i,j)=1.0d300
18168 ! write(iout,'(a15,f12.2,f8.1,2i5)')
18169 ! & "SSBOND_E_BREAK",totT,t_bath,i,j
18174 !-------TESTING CODE
18175 !el if (checkstop) then
18176 if (jcheck.eq.0) write(iout,'(a,3f15.8,$)') &
18177 "CHECKSTOP",rij,eij,ed
18181 if (checkstop) then
18182 write(iout,'(f15.8)')(echeck(1)-echeck(-1))*0.5d0/deps
18185 if (checkstop) then
18189 !-------END TESTING CODE
18192 dcosom1(k)=(dc_norm(k,nres+i)-om1*erij(k))/rij
18193 dcosom2(k)=(dc_norm(k,nres+j)-om2*erij(k))/rij
18196 gg(k)=ed*erij(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
18199 gvdwx(k,i)=gvdwx(k,i)-gg(k) &
18200 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
18201 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
18202 gvdwx(k,j)=gvdwx(k,j)+gg(k) &
18203 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
18204 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
18208 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
18213 gvdwc(l,i)=gvdwc(l,i)-gg(l)
18214 gvdwc(l,j)=gvdwc(l,j)+gg(l)
18218 end subroutine dyn_ssbond_ene
18219 !--------------------------------------------------------------------------
18220 subroutine triple_ssbond_ene(resi,resj,resk,eij)
18225 ! include 'DIMENSIONS'
18226 ! include 'COMMON.SBRIDGE'
18227 ! include 'COMMON.CHAIN'
18228 ! include 'COMMON.DERIV'
18229 ! include 'COMMON.LOCAL'
18230 ! include 'COMMON.INTERACT'
18231 ! include 'COMMON.VAR'
18232 ! include 'COMMON.IOUNITS'
18233 ! include 'COMMON.CALC'
18237 ! include 'COMMON.MD'
18238 ! use MD, only: totT,t_bath
18241 double precision h_base
18245 integer resi,resj,resk,m,itypi,itypj,itypk
18247 !c Output arguments
18248 double precision eij,eij1,eij2,eij3
18252 !c integer itypi,itypj,k,l
18253 double precision rrij,ssd,deltat1,deltat2,deltat12,cosphi
18254 double precision rrik,rrjk,rik,rjk,xi,xk,yi,yk,zi,zk,xij,yij,zij
18255 double precision xik,yik,zik,xjk,yjk,zjk,dxk,dyk,dzk
18256 double precision sig0ij,ljd,sig,fac,e1,e2
18257 double precision dcosom1(3),dcosom2(3),ed
18258 double precision pom1,pom2
18259 double precision ljA,ljB,ljXs
18260 double precision d_ljB(1:3)
18261 double precision ssA,ssB,ssC,ssXs
18262 double precision ssxm,ljxm,ssm,ljm
18263 double precision d_ssxm(1:3),d_ljxm(1:3),d_ssm(1:3),d_ljm(1:3)
18265 if (dtriss.eq.0) return
18269 !C write(iout,*) resi,resj,resk
18271 dxi=dc_norm(1,nres+i)
18272 dyi=dc_norm(2,nres+i)
18273 dzi=dc_norm(3,nres+i)
18274 dsci_inv=vbld_inv(i+nres)
18283 dxj=dc_norm(1,nres+j)
18284 dyj=dc_norm(2,nres+j)
18285 dzj=dc_norm(3,nres+j)
18286 dscj_inv=vbld_inv(j+nres)
18292 dxk=dc_norm(1,nres+k)
18293 dyk=dc_norm(2,nres+k)
18294 dzk=dc_norm(3,nres+k)
18295 dscj_inv=vbld_inv(k+nres)
18305 rrij=(xij*xij+yij*yij+zij*zij)
18306 rij=dsqrt(rrij) ! sc_angular needs rij to really be the inverse
18307 rrik=(xik*xik+yik*yik+zik*zik)
18309 rrjk=(xjk*xjk+yjk*yjk+zjk*zjk)
18311 !C there are three combination of distances for each trisulfide bonds
18312 !C The first case the ith atom is the center
18313 !C Energy function is E=d/(a*(x-y)**2+b*(x+y)**2+c) where x is first
18314 !C distance y is second distance the a,b,c,d are parameters derived for
18315 !C this problem d parameter was set as a penalty currenlty set to 1.
18316 if ((iabs(j-i).le.2).or.(iabs(i-k).le.2)) then
18319 eij1=dtriss/(atriss*(rij-rik)**2+btriss*(rij+rik)**6+ctriss)
18321 !C second case jth atom is center
18322 if ((iabs(j-i).le.2).or.(iabs(j-k).le.2)) then
18325 eij2=dtriss/(atriss*(rij-rjk)**2+btriss*(rij+rjk)**6+ctriss)
18327 !C the third case kth atom is the center
18328 if ((iabs(i-k).le.2).or.(iabs(j-k).le.2)) then
18331 eij3=dtriss/(atriss*(rik-rjk)**2+btriss*(rik+rjk)**6+ctriss)
18337 !C write(iout,*)i,j,k,eij
18338 !C The energy penalty calculated now time for the gradient part
18339 !C derivative over rij
18340 fac=-eij1**2/dtriss*(2.0*atriss*(rij-rik)+6.0*btriss*(rij+rik)**5) &
18341 -eij2**2/dtriss*(2.0*atriss*(rij-rjk)+6.0*btriss*(rij+rjk)**5)
18346 gvdwx(m,i)=gvdwx(m,i)-gg(m)
18347 gvdwx(m,j)=gvdwx(m,j)+gg(m)
18351 gvdwc(l,i)=gvdwc(l,i)-gg(l)
18352 gvdwc(l,j)=gvdwc(l,j)+gg(l)
18354 !C now derivative over rik
18355 fac=-eij1**2/dtriss* &
18356 (-2.0*atriss*(rij-rik)+6.0*btriss*(rij+rik)**5) &
18357 -eij3**2/dtriss*(2.0*atriss*(rik-rjk)+6.0*btriss*(rik+rjk)**5)
18362 gvdwx(m,i)=gvdwx(m,i)-gg(m)
18363 gvdwx(m,k)=gvdwx(m,k)+gg(m)
18366 gvdwc(l,i)=gvdwc(l,i)-gg(l)
18367 gvdwc(l,k)=gvdwc(l,k)+gg(l)
18369 !C now derivative over rjk
18370 fac=-eij2**2/dtriss* &
18371 (-2.0*atriss*(rij-rjk)+6.0*btriss*(rij+rjk)**5)- &
18372 eij3**2/dtriss*(-2.0*atriss*(rik-rjk)+6.0*btriss*(rik+rjk)**5)
18377 gvdwx(m,j)=gvdwx(m,j)-gg(m)
18378 gvdwx(m,k)=gvdwx(m,k)+gg(m)
18381 gvdwc(l,j)=gvdwc(l,j)-gg(l)
18382 gvdwc(l,k)=gvdwc(l,k)+gg(l)
18385 end subroutine triple_ssbond_ene
18389 !-----------------------------------------------------------------------------
18390 real(kind=8) function h_base(x,deriv)
18391 ! A smooth function going 0->1 in range [0,1]
18392 ! It should NOT be called outside range [0,1], it will not work there.
18399 real(kind=8) :: deriv
18402 real(kind=8) :: xsq
18405 ! Two parabolas put together. First derivative zero at extrema
18406 !$$$ if (x.lt.0.5D0) then
18407 !$$$ h_base=2.0D0*x*x
18411 !$$$ h_base=1.0D0-2.0D0*deriv*deriv
18412 !$$$ deriv=4.0D0*deriv
18415 ! Third degree polynomial. First derivative zero at extrema
18416 h_base=x*x*(3.0d0-2.0d0*x)
18417 deriv=6.0d0*x*(1.0d0-x)
18419 ! Fifth degree polynomial. First and second derivatives zero at extrema
18421 !$$$ h_base=x*xsq*(6.0d0*xsq-15.0d0*x+10.0d0)
18423 !$$$ deriv=deriv*deriv
18424 !$$$ deriv=30.0d0*xsq*deriv
18427 end function h_base
18428 !-----------------------------------------------------------------------------
18429 subroutine dyn_set_nss
18430 ! Adjust nss and other relevant variables based on dyn_ssbond_ij
18432 use MD_data, only: totT,t_bath
18434 ! include 'DIMENSIONS'
18438 ! include 'COMMON.SBRIDGE'
18439 ! include 'COMMON.CHAIN'
18440 ! include 'COMMON.IOUNITS'
18441 ! include 'COMMON.SETUP'
18442 ! include 'COMMON.MD'
18444 real(kind=8) :: emin
18445 integer :: i,j,imin,ierr
18446 integer :: diff,allnss,newnss
18447 integer,dimension(maxdim) :: allflag,allihpb,alljhpb,& !(maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
18450 integer,dimension(0:nfgtasks) :: i_newnss
18451 integer,dimension(0:nfgtasks) :: displ
18452 integer,dimension(maxdim) :: g_newihpb,g_newjhpb !(maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
18453 integer :: g_newnss
18458 if (dyn_ssbond_ij(i,j).lt.1.0d300) then
18467 !mc write(iout,*)"ALLNSS ",allnss,(allihpb(i),alljhpb(i),i=1,allnss)
18471 if (allflag(i).eq.0 .and. &
18472 dyn_ssbond_ij(allihpb(i),alljhpb(i)).lt.emin) then
18473 emin=dyn_ssbond_ij(allihpb(i),alljhpb(i))
18477 if (emin.lt.1.0d300) then
18480 if (allflag(i).eq.0 .and. &
18481 (allihpb(i).eq.allihpb(imin) .or. &
18482 alljhpb(i).eq.allihpb(imin) .or. &
18483 allihpb(i).eq.alljhpb(imin) .or. &
18484 alljhpb(i).eq.alljhpb(imin))) then
18491 !mc write(iout,*)"ALLNSS ",allnss,(allihpb(i),alljhpb(i),i=1,allnss)
18495 if (allflag(i).eq.1) then
18497 newihpb(newnss)=allihpb(i)
18498 newjhpb(newnss)=alljhpb(i)
18503 if (nfgtasks.gt.1)then
18505 call MPI_Reduce(newnss,g_newnss,1,&
18506 MPI_INTEGER,MPI_SUM,king,FG_COMM,IERR)
18507 call MPI_Gather(newnss,1,MPI_INTEGER,&
18508 i_newnss,1,MPI_INTEGER,king,FG_COMM,IERR)
18510 do i=1,nfgtasks-1,1
18511 displ(i)=i_newnss(i-1)+displ(i-1)
18513 call MPI_Gatherv(newihpb,newnss,MPI_INTEGER,&
18514 g_newihpb,i_newnss,displ,MPI_INTEGER,&
18516 call MPI_Gatherv(newjhpb,newnss,MPI_INTEGER,&
18517 g_newjhpb,i_newnss,displ,MPI_INTEGER,&
18519 if(fg_rank.eq.0) then
18520 ! print *,'g_newnss',g_newnss
18521 ! print *,'g_newihpb',(g_newihpb(i),i=1,g_newnss)
18522 ! print *,'g_newjhpb',(g_newjhpb(i),i=1,g_newnss)
18525 newihpb(i)=g_newihpb(i)
18526 newjhpb(i)=g_newjhpb(i)
18534 !mc write(iout,*)"NEWNSS ",newnss,(newihpb(i),newjhpb(i),i=1,newnss)
18535 ! print *,newnss,nss,maxdim
18541 if (idssb(i).eq.newihpb(j) .and. &
18542 jdssb(i).eq.newjhpb(j)) found=.true.
18546 ! write(iout,*) "found",found,i,j
18547 if (.not.found.and.fg_rank.eq.0) &
18548 write(iout,'(a15,f12.2,f8.1,2i5)') &
18549 "SSBOND_BREAK",totT,t_bath,idssb(i),jdssb(i)
18558 if (newihpb(i).eq.idssb(j) .and. &
18559 newjhpb(i).eq.jdssb(j)) found=.true.
18563 ! write(iout,*) "found",found,i,j
18564 if (.not.found.and.fg_rank.eq.0) &
18565 write(iout,'(a15,f12.2,f8.1,2i5)') &
18566 "SSBOND_FORM",totT,t_bath,newihpb(i),newjhpb(i)
18573 idssb(i)=newihpb(i)
18574 jdssb(i)=newjhpb(i)
18578 end subroutine dyn_set_nss
18579 ! Lipid transfer energy function
18580 subroutine Eliptransfer(eliptran)
18581 !C this is done by Adasko
18582 !C print *,"wchodze"
18583 !C structure of box:
18585 !C--bordliptop-- buffore starts
18586 !C--bufliptop--- here true lipid starts
18588 !C--buflipbot--- lipid ends buffore starts
18589 !C--bordlipbot--buffore ends
18590 real(kind=8) :: fracinbuf,eliptran,sslip,positi,ssgradlip
18593 ! print *, "I am in eliptran"
18594 do i=ilip_start,ilip_end
18596 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1).or.(i.eq.nres))&
18599 positi=(mod(((c(3,i)+c(3,i+1))/2.0d0),boxzsize))
18600 if (positi.le.0.0) positi=positi+boxzsize
18602 !C first for peptide groups
18603 !c for each residue check if it is in lipid or lipid water border area
18604 if ((positi.gt.bordlipbot) &
18605 .and.(positi.lt.bordliptop)) then
18606 !C the energy transfer exist
18607 if (positi.lt.buflipbot) then
18608 !C what fraction I am in
18610 ((positi-bordlipbot)/lipbufthick)
18611 !C lipbufthick is thickenes of lipid buffore
18612 sslip=sscalelip(fracinbuf)
18613 ssgradlip=-sscagradlip(fracinbuf)/lipbufthick
18614 eliptran=eliptran+sslip*pepliptran
18615 gliptranc(3,i)=gliptranc(3,i)+ssgradlip*pepliptran/2.0d0
18616 gliptranc(3,i-1)=gliptranc(3,i-1)+ssgradlip*pepliptran/2.0d0
18617 !C gliptranc(3,i-2)=gliptranc(3,i)+ssgradlip*pepliptran
18619 !C print *,"doing sccale for lower part"
18620 !C print *,i,sslip,fracinbuf,ssgradlip
18621 elseif (positi.gt.bufliptop) then
18622 fracinbuf=1.0d0-((bordliptop-positi)/lipbufthick)
18623 sslip=sscalelip(fracinbuf)
18624 ssgradlip=sscagradlip(fracinbuf)/lipbufthick
18625 eliptran=eliptran+sslip*pepliptran
18626 gliptranc(3,i)=gliptranc(3,i)+ssgradlip*pepliptran/2.0d0
18627 gliptranc(3,i-1)=gliptranc(3,i-1)+ssgradlip*pepliptran/2.0d0
18628 !C gliptranc(3,i-2)=gliptranc(3,i)+ssgradlip*pepliptran
18629 !C print *, "doing sscalefor top part"
18630 !C print *,i,sslip,fracinbuf,ssgradlip
18632 eliptran=eliptran+pepliptran
18633 !C print *,"I am in true lipid"
18636 !C eliptran=elpitran+0.0 ! I am in water
18638 if (energy_dec) write(iout,*) i,"eliptran=",eliptran,positi,sslip
18640 ! here starts the side chain transfer
18641 do i=ilip_start,ilip_end
18642 if (itype(i,1).eq.ntyp1) cycle
18643 positi=(mod(c(3,i+nres),boxzsize))
18644 if (positi.le.0) positi=positi+boxzsize
18645 !C print *,mod(c(3,i+nres),boxzsize),bordlipbot,bordliptop
18646 !c for each residue check if it is in lipid or lipid water border area
18647 !C respos=mod(c(3,i+nres),boxzsize)
18648 !C print *,positi,bordlipbot,buflipbot
18649 if ((positi.gt.bordlipbot) &
18650 .and.(positi.lt.bordliptop)) then
18651 !C the energy transfer exist
18652 if (positi.lt.buflipbot) then
18654 ((positi-bordlipbot)/lipbufthick)
18655 !C lipbufthick is thickenes of lipid buffore
18656 sslip=sscalelip(fracinbuf)
18657 ssgradlip=-sscagradlip(fracinbuf)/lipbufthick
18658 eliptran=eliptran+sslip*liptranene(itype(i,1))
18659 gliptranx(3,i)=gliptranx(3,i) &
18660 +ssgradlip*liptranene(itype(i,1))
18661 gliptranc(3,i-1)= gliptranc(3,i-1) &
18662 +ssgradlip*liptranene(itype(i,1))
18663 !C print *,"doing sccale for lower part"
18664 elseif (positi.gt.bufliptop) then
18666 ((bordliptop-positi)/lipbufthick)
18667 sslip=sscalelip(fracinbuf)
18668 ssgradlip=sscagradlip(fracinbuf)/lipbufthick
18669 eliptran=eliptran+sslip*liptranene(itype(i,1))
18670 gliptranx(3,i)=gliptranx(3,i) &
18671 +ssgradlip*liptranene(itype(i,1))
18672 gliptranc(3,i-1)= gliptranc(3,i-1) &
18673 +ssgradlip*liptranene(itype(i,1))
18674 !C print *, "doing sscalefor top part",sslip,fracinbuf
18676 eliptran=eliptran+liptranene(itype(i,1))
18677 !C print *,"I am in true lipid"
18679 endif ! if in lipid or buffor
18681 !C eliptran=elpitran+0.0 ! I am in water
18682 if (energy_dec) write(iout,*) i,"eliptran=",eliptran
18685 end subroutine Eliptransfer
18686 !----------------------------------NANO FUNCTIONS
18687 !C-----------------------------------------------------------------------
18688 !C-----------------------------------------------------------
18689 !C This subroutine is to mimic the histone like structure but as well can be
18690 !C utilizet to nanostructures (infinit) small modification has to be used to
18691 !C make it finite (z gradient at the ends has to be changes as well as the x,y
18692 !C gradient has to be modified at the ends
18693 !C The energy function is Kihara potential
18694 !C E=4esp*((sigma/(r-r0))^12 - (sigma/(r-r0))^6)
18695 !C 4eps is depth of well sigma is r_minimum r is distance from center of tube
18696 !C and r0 is the excluded size of nanotube (can be set to 0 if we want just a
18697 !C simple Kihara potential
18698 subroutine calctube(Etube)
18699 real(kind=8),dimension(3) :: vectube
18700 real(kind=8) :: Etube,xtemp,xminact,yminact,&
18701 ytemp,xmin,ymin,tub_r,rdiff,rdiff6,fac,positi, &
18702 sc_aa_tube,sc_bb_tube
18705 do i=itube_start,itube_end
18707 enetube(i+nres)=0.0d0
18709 !C first we calculate the distance from tube center
18711 do i=itube_start,itube_end
18712 !C lets ommit dummy atoms for now
18713 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1)) cycle
18714 !C now calculate distance from center of tube and direction vectors
18717 ! Find minimum distance in periodic box
18719 vectube(1)=mod((c(1,i)+c(1,i+1))/2.0d0,boxxsize)
18720 vectube(1)=vectube(1)+boxxsize*j
18721 vectube(2)=mod((c(2,i)+c(2,i+1))/2.0d0,boxysize)
18722 vectube(2)=vectube(2)+boxysize*j
18723 xminact=abs(vectube(1)-tubecenter(1))
18724 yminact=abs(vectube(2)-tubecenter(2))
18725 if (xmin.gt.xminact) then
18729 if (ymin.gt.yminact) then
18736 vectube(1)=vectube(1)-tubecenter(1)
18737 vectube(2)=vectube(2)-tubecenter(2)
18739 !C print *,"x",(c(1,i)+c(1,i+1))/2.0d0,tubecenter(1)
18740 !C print *,"y",(c(2,i)+c(2,i+1))/2.0d0,tubecenter(2)
18742 !C as the tube is infinity we do not calculate the Z-vector use of Z
18745 !C now calculte the distance
18746 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
18747 !C now normalize vector
18748 vectube(1)=vectube(1)/tub_r
18749 vectube(2)=vectube(2)/tub_r
18750 !C calculte rdiffrence between r and r0
18753 rdiff6=rdiff**6.0d0
18754 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
18755 enetube(i)=pep_aa_tube/rdiff6**2.0d0+pep_bb_tube/rdiff6
18756 !C write(iout,*) "TU13",i,rdiff6,enetube(i)
18757 !C print *,rdiff,rdiff6,pep_aa_tube
18758 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
18759 !C now we calculate gradient
18760 fac=(-12.0d0*pep_aa_tube/rdiff6- &
18761 6.0d0*pep_bb_tube)/rdiff6/rdiff
18762 !C write(iout,'(a5,i4,f12.1,3f12.5)') "TU13",i,rdiff6,enetube(i),
18764 !C now direction of gg_tube vector
18766 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac/2.0d0
18767 gg_tube(j,i)=gg_tube(j,i)+vectube(j)*fac/2.0d0
18770 !C basically thats all code now we split for side-chains (REMEMBER to sum up at the END)
18771 !C print *,gg_tube(1,0),"TU"
18774 do i=itube_start,itube_end
18775 !C Lets not jump over memory as we use many times iti
18777 !C lets ommit dummy atoms for now
18778 if ((iti.eq.ntyp1) &
18779 !C in UNRES uncomment the line below as GLY has no side-chain...
18785 vectube(1)=mod((c(1,i+nres)),boxxsize)
18786 vectube(1)=vectube(1)+boxxsize*j
18787 vectube(2)=mod((c(2,i+nres)),boxysize)
18788 vectube(2)=vectube(2)+boxysize*j
18790 xminact=abs(vectube(1)-tubecenter(1))
18791 yminact=abs(vectube(2)-tubecenter(2))
18792 if (xmin.gt.xminact) then
18796 if (ymin.gt.yminact) then
18803 !C write(iout,*), "tututu", vectube(1),tubecenter(1),vectube(2),
18805 vectube(1)=vectube(1)-tubecenter(1)
18806 vectube(2)=vectube(2)-tubecenter(2)
18808 !C as the tube is infinity we do not calculate the Z-vector use of Z
18811 !C now calculte the distance
18812 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
18813 !C now normalize vector
18814 vectube(1)=vectube(1)/tub_r
18815 vectube(2)=vectube(2)/tub_r
18817 !C calculte rdiffrence between r and r0
18820 rdiff6=rdiff**6.0d0
18821 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
18822 sc_aa_tube=sc_aa_tube_par(iti)
18823 sc_bb_tube=sc_bb_tube_par(iti)
18824 enetube(i+nres)=sc_aa_tube/rdiff6**2.0d0+sc_bb_tube/rdiff6
18825 fac=-12.0d0*sc_aa_tube/rdiff6**2.0d0/rdiff- &
18826 6.0d0*sc_bb_tube/rdiff6/rdiff
18827 !C now direction of gg_tube vector
18829 gg_tube_SC(j,i)=gg_tube_SC(j,i)+vectube(j)*fac
18830 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac
18833 do i=itube_start,itube_end
18834 Etube=Etube+enetube(i)+enetube(i+nres)
18836 !C print *,"ETUBE", etube
18838 end subroutine calctube
18839 !C TO DO 1) add to total energy
18840 !C 2) add to gradient summation
18841 !C 3) add reading parameters (AND of course oppening of PARAM file)
18842 !C 4) add reading the center of tube
18844 !C 6) add to zerograd
18845 !C 7) allocate matrices
18848 !C-----------------------------------------------------------------------
18849 !C-----------------------------------------------------------
18850 !C This subroutine is to mimic the histone like structure but as well can be
18851 !C utilizet to nanostructures (infinit) small modification has to be used to
18852 !C make it finite (z gradient at the ends has to be changes as well as the x,y
18853 !C gradient has to be modified at the ends
18854 !C The energy function is Kihara potential
18855 !C E=4esp*((sigma/(r-r0))^12 - (sigma/(r-r0))^6)
18856 !C 4eps is depth of well sigma is r_minimum r is distance from center of tube
18857 !C and r0 is the excluded size of nanotube (can be set to 0 if we want just a
18858 !C simple Kihara potential
18859 subroutine calctube2(Etube)
18860 real(kind=8),dimension(3) :: vectube
18861 real(kind=8) :: Etube,xtemp,xminact,yminact,&
18862 ytemp,xmin,ymin,tub_r,rdiff,rdiff6,fac,positi,fracinbuf,&
18863 sstube,ssgradtube,sc_aa_tube,sc_bb_tube
18866 do i=itube_start,itube_end
18868 enetube(i+nres)=0.0d0
18870 !C first we calculate the distance from tube center
18871 !C first sugare-phosphate group for NARES this would be peptide group
18873 do i=itube_start,itube_end
18874 !C lets ommit dummy atoms for now
18876 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1)) cycle
18877 !C now calculate distance from center of tube and direction vectors
18878 !C vectube(1)=mod((c(1,i)+c(1,i+1))/2.0d0,boxxsize)
18879 !C if (vectube(1).lt.0) vectube(1)=vectube(1)+boxxsize
18880 !C vectube(2)=mod((c(2,i)+c(2,i+1))/2.0d0,boxysize)
18881 !C if (vectube(2).lt.0) vectube(2)=vectube(2)+boxysize
18885 vectube(1)=mod((c(1,i)+c(1,i+1))/2.0d0,boxxsize)
18886 vectube(1)=vectube(1)+boxxsize*j
18887 vectube(2)=mod((c(2,i)+c(2,i+1))/2.0d0,boxysize)
18888 vectube(2)=vectube(2)+boxysize*j
18890 xminact=abs(vectube(1)-tubecenter(1))
18891 yminact=abs(vectube(2)-tubecenter(2))
18892 if (xmin.gt.xminact) then
18896 if (ymin.gt.yminact) then
18903 vectube(1)=vectube(1)-tubecenter(1)
18904 vectube(2)=vectube(2)-tubecenter(2)
18906 !C print *,"x",(c(1,i)+c(1,i+1))/2.0d0,tubecenter(1)
18907 !C print *,"y",(c(2,i)+c(2,i+1))/2.0d0,tubecenter(2)
18909 !C as the tube is infinity we do not calculate the Z-vector use of Z
18912 !C now calculte the distance
18913 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
18914 !C now normalize vector
18915 vectube(1)=vectube(1)/tub_r
18916 vectube(2)=vectube(2)/tub_r
18917 !C calculte rdiffrence between r and r0
18920 rdiff6=rdiff**6.0d0
18921 !C THIS FRAGMENT MAKES TUBE FINITE
18922 positi=mod((c(3,i)+c(3,i+1))/2.0d0,boxzsize)
18923 if (positi.le.0) positi=positi+boxzsize
18924 !C print *,mod(c(3,i+nres),boxzsize),bordlipbot,bordliptop
18925 !c for each residue check if it is in lipid or lipid water border area
18926 !C respos=mod(c(3,i+nres),boxzsize)
18927 !C print *,positi,bordtubebot,buftubebot,bordtubetop
18928 if ((positi.gt.bordtubebot) &
18929 .and.(positi.lt.bordtubetop)) then
18930 !C the energy transfer exist
18931 if (positi.lt.buftubebot) then
18933 ((positi-bordtubebot)/tubebufthick)
18934 !C lipbufthick is thickenes of lipid buffore
18935 sstube=sscalelip(fracinbuf)
18936 ssgradtube=-sscagradlip(fracinbuf)/tubebufthick
18937 !C print *,ssgradtube, sstube,tubetranene(itype(i,1))
18938 enetube(i)=enetube(i)+sstube*tubetranenepep
18939 !C gg_tube_SC(3,i)=gg_tube_SC(3,i)
18940 !C &+ssgradtube*tubetranene(itype(i,1))
18941 !C gg_tube(3,i-1)= gg_tube(3,i-1)
18942 !C &+ssgradtube*tubetranene(itype(i,1))
18943 !C print *,"doing sccale for lower part"
18944 elseif (positi.gt.buftubetop) then
18946 ((bordtubetop-positi)/tubebufthick)
18947 sstube=sscalelip(fracinbuf)
18948 ssgradtube=sscagradlip(fracinbuf)/tubebufthick
18949 enetube(i)=enetube(i)+sstube*tubetranenepep
18950 !C gg_tube_SC(3,i)=gg_tube_SC(3,i)
18951 !C &+ssgradtube*tubetranene(itype(i,1))
18952 !C gg_tube(3,i-1)= gg_tube(3,i-1)
18953 !C &+ssgradtube*tubetranene(itype(i,1))
18954 !C print *, "doing sscalefor top part",sslip,fracinbuf
18958 enetube(i)=enetube(i)+sstube*tubetranenepep
18959 !C print *,"I am in true lipid"
18963 !C ssgradtube=0.0d0
18965 endif ! if in lipid or buffor
18967 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
18968 enetube(i)=enetube(i)+sstube* &
18969 (pep_aa_tube/rdiff6**2.0d0+pep_bb_tube/rdiff6)
18970 !C write(iout,*) "TU13",i,rdiff6,enetube(i)
18971 !C print *,rdiff,rdiff6,pep_aa_tube
18972 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
18973 !C now we calculate gradient
18974 fac=(-12.0d0*pep_aa_tube/rdiff6- &
18975 6.0d0*pep_bb_tube)/rdiff6/rdiff*sstube
18976 !C write(iout,'(a5,i4,f12.1,3f12.5)') "TU13",i,rdiff6,enetube(i),
18979 !C now direction of gg_tube vector
18981 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac/2.0d0
18982 gg_tube(j,i)=gg_tube(j,i)+vectube(j)*fac/2.0d0
18984 gg_tube(3,i)=gg_tube(3,i) &
18985 +ssgradtube*enetube(i)/sstube/2.0d0
18986 gg_tube(3,i-1)= gg_tube(3,i-1) &
18987 +ssgradtube*enetube(i)/sstube/2.0d0
18990 !C basically thats all code now we split for side-chains (REMEMBER to sum up at the END)
18991 !C print *,gg_tube(1,0),"TU"
18992 do i=itube_start,itube_end
18993 !C Lets not jump over memory as we use many times iti
18995 !C lets ommit dummy atoms for now
18996 if ((iti.eq.ntyp1) &
18997 !!C in UNRES uncomment the line below as GLY has no side-chain...
19000 vectube(1)=c(1,i+nres)
19001 vectube(1)=mod(vectube(1),boxxsize)
19002 if (vectube(1).lt.0) vectube(1)=vectube(1)+boxxsize
19003 vectube(2)=c(2,i+nres)
19004 vectube(2)=mod(vectube(2),boxysize)
19005 if (vectube(2).lt.0) vectube(2)=vectube(2)+boxysize
19007 vectube(1)=vectube(1)-tubecenter(1)
19008 vectube(2)=vectube(2)-tubecenter(2)
19009 !C THIS FRAGMENT MAKES TUBE FINITE
19010 positi=(mod(c(3,i+nres),boxzsize))
19011 if (positi.le.0) positi=positi+boxzsize
19012 !C print *,mod(c(3,i+nres),boxzsize),bordlipbot,bordliptop
19013 !c for each residue check if it is in lipid or lipid water border area
19014 !C respos=mod(c(3,i+nres),boxzsize)
19015 !C print *,positi,bordtubebot,buftubebot,bordtubetop
19017 if ((positi.gt.bordtubebot) &
19018 .and.(positi.lt.bordtubetop)) then
19019 !C the energy transfer exist
19020 if (positi.lt.buftubebot) then
19022 ((positi-bordtubebot)/tubebufthick)
19023 !C lipbufthick is thickenes of lipid buffore
19024 sstube=sscalelip(fracinbuf)
19025 ssgradtube=-sscagradlip(fracinbuf)/tubebufthick
19026 !C print *,ssgradtube, sstube,tubetranene(itype(i,1))
19027 enetube(i+nres)=enetube(i+nres)+sstube*tubetranene(itype(i,1))
19028 !C gg_tube_SC(3,i)=gg_tube_SC(3,i)
19029 !C &+ssgradtube*tubetranene(itype(i,1))
19030 !C gg_tube(3,i-1)= gg_tube(3,i-1)
19031 !C &+ssgradtube*tubetranene(itype(i,1))
19032 !C print *,"doing sccale for lower part"
19033 elseif (positi.gt.buftubetop) then
19035 ((bordtubetop-positi)/tubebufthick)
19037 sstube=sscalelip(fracinbuf)
19038 ssgradtube=sscagradlip(fracinbuf)/tubebufthick
19039 enetube(i+nres)=enetube(i+nres)+sstube*tubetranene(itype(i,1))
19040 !C gg_tube_SC(3,i)=gg_tube_SC(3,i)
19041 !C &+ssgradtube*tubetranene(itype(i,1))
19042 !C gg_tube(3,i-1)= gg_tube(3,i-1)
19043 !C &+ssgradtube*tubetranene(itype(i,1))
19044 !C print *, "doing sscalefor top part",sslip,fracinbuf
19048 enetube(i+nres)=enetube(i+nres)+sstube*tubetranene(itype(i,1))
19049 !C print *,"I am in true lipid"
19053 !C ssgradtube=0.0d0
19055 endif ! if in lipid or buffor
19056 !CEND OF FINITE FRAGMENT
19057 !C as the tube is infinity we do not calculate the Z-vector use of Z
19060 !C now calculte the distance
19061 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
19062 !C now normalize vector
19063 vectube(1)=vectube(1)/tub_r
19064 vectube(2)=vectube(2)/tub_r
19065 !C calculte rdiffrence between r and r0
19068 rdiff6=rdiff**6.0d0
19069 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
19070 sc_aa_tube=sc_aa_tube_par(iti)
19071 sc_bb_tube=sc_bb_tube_par(iti)
19072 enetube(i+nres)=(sc_aa_tube/rdiff6**2.0d0+sc_bb_tube/rdiff6)&
19073 *sstube+enetube(i+nres)
19074 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
19075 !C now we calculate gradient
19076 fac=(-12.0d0*sc_aa_tube/rdiff6**2.0d0/rdiff-&
19077 6.0d0*sc_bb_tube/rdiff6/rdiff)*sstube
19078 !C now direction of gg_tube vector
19080 gg_tube_SC(j,i)=gg_tube_SC(j,i)+vectube(j)*fac
19081 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac
19083 gg_tube_SC(3,i)=gg_tube_SC(3,i) &
19084 +ssgradtube*enetube(i+nres)/sstube
19085 gg_tube(3,i-1)= gg_tube(3,i-1) &
19086 +ssgradtube*enetube(i+nres)/sstube
19089 do i=itube_start,itube_end
19090 Etube=Etube+enetube(i)+enetube(i+nres)
19092 !C print *,"ETUBE", etube
19094 end subroutine calctube2
19095 !=====================================================================================================================================
19096 subroutine calcnano(Etube)
19097 real(kind=8),dimension(3) :: vectube
19099 real(kind=8) :: Etube,xtemp,xminact,yminact,&
19100 ytemp,xmin,ymin,tub_r,rdiff,rdiff6,fac,denominator,faccav,&
19101 sc_aa_tube,sc_bb_tube,zmin,ztemp,zminact
19102 integer:: i,j,iti,r
19105 ! print *,itube_start,itube_end,"poczatek"
19106 do i=itube_start,itube_end
19108 enetube(i+nres)=0.0d0
19110 !C first we calculate the distance from tube center
19111 !C first sugare-phosphate group for NARES this would be peptide group
19113 do i=itube_start,itube_end
19114 !C lets ommit dummy atoms for now
19115 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1)) cycle
19116 !C now calculate distance from center of tube and direction vectors
19122 vectube(1)=dmod((c(1,i)+c(1,i+1))/2.0d0,boxxsize)
19123 vectube(1)=vectube(1)+boxxsize*j
19124 vectube(2)=dmod((c(2,i)+c(2,i+1))/2.0d0,boxysize)
19125 vectube(2)=vectube(2)+boxysize*j
19126 vectube(3)=dmod((c(3,i)+c(3,i+1))/2.0d0,boxzsize)
19127 vectube(3)=vectube(3)+boxzsize*j
19130 xminact=dabs(vectube(1)-tubecenter(1))
19131 yminact=dabs(vectube(2)-tubecenter(2))
19132 zminact=dabs(vectube(3)-tubecenter(3))
19134 if (xmin.gt.xminact) then
19138 if (ymin.gt.yminact) then
19142 if (zmin.gt.zminact) then
19151 vectube(1)=vectube(1)-tubecenter(1)
19152 vectube(2)=vectube(2)-tubecenter(2)
19153 vectube(3)=vectube(3)-tubecenter(3)
19155 !C print *,"x",(c(1,i)+c(1,i+1))/2.0d0,tubecenter(1)
19156 !C print *,"y",(c(2,i)+c(2,i+1))/2.0d0,tubecenter(2)
19157 !C as the tube is infinity we do not calculate the Z-vector use of Z
19159 !C vectube(3)=0.0d0
19160 !C now calculte the distance
19161 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
19162 !C now normalize vector
19163 vectube(1)=vectube(1)/tub_r
19164 vectube(2)=vectube(2)/tub_r
19165 vectube(3)=vectube(3)/tub_r
19166 !C calculte rdiffrence between r and r0
19169 rdiff6=rdiff**6.0d0
19170 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
19171 enetube(i)=pep_aa_tube/rdiff6**2.0d0+pep_bb_tube/rdiff6
19172 !C write(iout,*) "TU13",i,rdiff6,enetube(i)
19173 !C print *,rdiff,rdiff6,pep_aa_tube
19174 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
19175 !C now we calculate gradient
19176 fac=(-12.0d0*pep_aa_tube/rdiff6- &
19177 6.0d0*pep_bb_tube)/rdiff6/rdiff
19178 !C write(iout,'(a5,i4,f12.1,3f12.5)') "TU13",i,rdiff6,enetube(i),
19180 if (acavtubpep.eq.0.0d0) then
19185 denominator=(1.0d0+dcavtubpep*rdiff6*rdiff6)
19187 (bcavtubpep*rdiff+acavtubpep*dsqrt(rdiff)+ccavtubpep) &
19190 faccav=((bcavtubpep*1.0d0+acavtubpep/2.0d0/dsqrt(rdiff)) &
19191 *denominator-(bcavtubpep*rdiff+acavtubpep*dsqrt(rdiff) &
19192 +ccavtubpep)*rdiff6**2.0d0/rdiff*dcavtubpep*12.0d0) &
19193 /denominator**2.0d0
19198 if (energy_dec) write(iout,*),i,rdiff,enetube(i),enecavtube(i)
19200 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac/2.0d0
19201 gg_tube(j,i)=gg_tube(j,i)+vectube(j)*fac/2.0d0
19205 do i=itube_start,itube_end
19206 enecavtube(i)=0.0d0
19207 !C Lets not jump over memory as we use many times iti
19209 !C lets ommit dummy atoms for now
19210 if ((iti.eq.ntyp1) &
19211 !C in UNRES uncomment the line below as GLY has no side-chain...
19218 vectube(1)=dmod((c(1,i+nres)),boxxsize)
19219 vectube(1)=vectube(1)+boxxsize*j
19220 vectube(2)=dmod((c(2,i+nres)),boxysize)
19221 vectube(2)=vectube(2)+boxysize*j
19222 vectube(3)=dmod((c(3,i+nres)),boxzsize)
19223 vectube(3)=vectube(3)+boxzsize*j
19226 xminact=dabs(vectube(1)-tubecenter(1))
19227 yminact=dabs(vectube(2)-tubecenter(2))
19228 zminact=dabs(vectube(3)-tubecenter(3))
19230 if (xmin.gt.xminact) then
19234 if (ymin.gt.yminact) then
19238 if (zmin.gt.zminact) then
19247 !C write(iout,*), "tututu", vectube(1),tubecenter(1),vectube(2),
19249 vectube(1)=vectube(1)-tubecenter(1)
19250 vectube(2)=vectube(2)-tubecenter(2)
19251 vectube(3)=vectube(3)-tubecenter(3)
19252 !C now calculte the distance
19253 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
19254 !C now normalize vector
19255 vectube(1)=vectube(1)/tub_r
19256 vectube(2)=vectube(2)/tub_r
19257 vectube(3)=vectube(3)/tub_r
19259 !C calculte rdiffrence between r and r0
19262 rdiff6=rdiff**6.0d0
19263 sc_aa_tube=sc_aa_tube_par(iti)
19264 sc_bb_tube=sc_bb_tube_par(iti)
19265 enetube(i+nres)=sc_aa_tube/rdiff6**2.0d0+sc_bb_tube/rdiff6
19266 !C enetube(i+nres)=0.0d0
19267 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
19268 !C now we calculate gradient
19269 fac=-12.0d0*sc_aa_tube/rdiff6**2.0d0/rdiff- &
19270 6.0d0*sc_bb_tube/rdiff6/rdiff
19272 !C now direction of gg_tube vector
19273 !C Now cavity term E=a(x+bsqrt(x)+c)/(1+dx^12)
19274 if (acavtub(iti).eq.0.0d0) then
19276 enecavtube(i+nres)=0.0d0
19279 denominator=(1.0d0+dcavtub(iti)*rdiff6*rdiff6)
19280 enecavtube(i+nres)= &
19281 (bcavtub(iti)*rdiff+acavtub(iti)*dsqrt(rdiff)+ccavtub(iti)) &
19283 !C enecavtube(i)=0.0
19284 faccav=((bcavtub(iti)*1.0d0+acavtub(iti)/2.0d0/dsqrt(rdiff)) &
19285 *denominator-(bcavtub(iti)*rdiff+acavtub(iti)*dsqrt(rdiff) &
19286 +ccavtub(iti))*rdiff6**2.0d0/rdiff*dcavtub(iti)*12.0d0) &
19287 /denominator**2.0d0
19292 !C print *,"TUT",i,iti,rdiff,rdiff6,acavtub(iti),denominator,
19293 !C & enecavtube(i),faccav
19294 !C print *,"licz=",
19295 !C & (bcavtub(iti)*rdiff+acavtub(iti)*sqrt(rdiff)+ccavtub(iti))
19296 !C print *,"finene=",enetube(i+nres)+enecavtube(i)
19298 gg_tube_SC(j,i)=gg_tube_SC(j,i)+vectube(j)*fac
19299 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac
19301 if (energy_dec) write(iout,*),i,rdiff,enetube(i+nres),enecavtube(i+nres)
19306 do i=itube_start,itube_end
19307 Etube=Etube+enetube(i)+enetube(i+nres)+enecavtube(i) &
19308 +enecavtube(i+nres)
19311 ! print *,"begin", i,"a"
19314 ! rdiff6=rdiff**6.0d0
19315 ! sc_aa_tube=sc_aa_tube_par(i)
19316 ! sc_bb_tube=sc_bb_tube_par(i)
19317 ! enetube(i)=sc_aa_tube/rdiff6**2.0d0+sc_bb_tube/rdiff6
19318 ! denominator=(1.0d0+dcavtub(i)*rdiff6*rdiff6)
19320 ! (bcavtub(i)*rdiff+acavtub(i)*dsqrt(rdiff)+ccavtub(i)) &
19323 ! print '(5(f10.3,1x))',rdiff,enetube(i),enecavtube(i),enecavtube(i)+enetube(i)
19325 ! print *,"end",i,"a"
19327 !C print *,"ETUBE", etube
19329 end subroutine calcnano
19331 !===============================================
19332 !--------------------------------------------------------------------------------
19333 !C first for shielding is setting of function of side-chains
19335 subroutine set_shield_fac2
19336 real(kind=8) :: div77_81=0.974996043d0, &
19337 div4_81=0.2222222222d0
19338 real (kind=8) :: dist_pep_side,dist_side_calf,dist_pept_group, &
19339 scale_fac_dist,fac_help_scale,VofOverlap,VolumeTotal,costhet,&
19340 short,long,sinthet,costhet_fac,sh_frac_dist,rkprim,cosphi, &
19341 sinphi,cosphi_fac,pep_side0pept_group,cosalfa,fac_alfa_sin
19342 !C the vector between center of side_chain and peptide group
19343 real(kind=8),dimension(3) :: pep_side_long,side_calf, &
19344 pept_group,costhet_grad,cosphi_grad_long, &
19345 cosphi_grad_loc,pep_side_norm,side_calf_norm, &
19346 sh_frac_dist_grad,pep_side
19348 !C write(2,*) "ivec",ivec_start,ivec_end
19350 fac_shield(i)=0.0d0
19352 grad_shield(j,i)=0.0d0
19355 do i=ivec_start,ivec_end
19357 !C if ((itype(i,1).eq.ntyp1).and.itype(i+1,1).eq.ntyp1) cycle
19359 if ((itype(i,1).eq.ntyp1).and.itype(i+1,1).eq.ntyp1) cycle
19360 !Cif there two consequtive dummy atoms there is no peptide group between them
19361 !C the line below has to be changed for FGPROC>1
19364 if ((itype(k,1).eq.ntyp1).or.(itype(k,1).eq.10)) cycle
19368 !C first lets set vector conecting the ithe side-chain with kth side-chain
19369 pep_side(j)=c(j,k+nres)-(c(j,i)+c(j,i+1))/2.0d0
19370 !C pep_side(j)=2.0d0
19371 !C and vector conecting the side-chain with its proper calfa
19372 side_calf(j)=c(j,k+nres)-c(j,k)
19373 !C side_calf(j)=2.0d0
19374 pept_group(j)=c(j,i)-c(j,i+1)
19375 !C lets have their lenght
19376 dist_pep_side=pep_side(j)**2+dist_pep_side
19377 dist_side_calf=dist_side_calf+side_calf(j)**2
19378 dist_pept_group=dist_pept_group+pept_group(j)**2
19380 dist_pep_side=sqrt(dist_pep_side)
19381 dist_pept_group=sqrt(dist_pept_group)
19382 dist_side_calf=sqrt(dist_side_calf)
19384 pep_side_norm(j)=pep_side(j)/dist_pep_side
19385 side_calf_norm(j)=dist_side_calf
19387 !C now sscale fraction
19388 sh_frac_dist=-(dist_pep_side-rpp(1,1)-buff_shield)/buff_shield
19389 !C print *,buff_shield,"buff"
19391 if (sh_frac_dist.le.0.0) cycle
19392 !C print *,ishield_list(i),i
19393 !C If we reach here it means that this side chain reaches the shielding sphere
19394 !C Lets add him to the list for gradient
19395 ishield_list(i)=ishield_list(i)+1
19396 !C ishield_list is a list of non 0 side-chain that contribute to factor gradient
19397 !C this list is essential otherwise problem would be O3
19398 shield_list(ishield_list(i),i)=k
19399 !C Lets have the sscale value
19400 if (sh_frac_dist.gt.1.0) then
19401 scale_fac_dist=1.0d0
19403 sh_frac_dist_grad(j)=0.0d0
19406 scale_fac_dist=-sh_frac_dist*sh_frac_dist &
19407 *(2.0d0*sh_frac_dist-3.0d0)
19408 fac_help_scale=6.0d0*(sh_frac_dist-sh_frac_dist**2) &
19409 /dist_pep_side/buff_shield*0.5d0
19411 sh_frac_dist_grad(j)=fac_help_scale*pep_side(j)
19412 !C sh_frac_dist_grad(j)=0.0d0
19413 !C scale_fac_dist=1.0d0
19414 !C print *,"jestem",scale_fac_dist,fac_help_scale,
19415 !C & sh_frac_dist_grad(j)
19418 !C this is what is now we have the distance scaling now volume...
19419 short=short_r_sidechain(itype(k,1))
19420 long=long_r_sidechain(itype(k,1))
19421 costhet=1.0d0/dsqrt(1.0d0+short**2/dist_pep_side**2)
19422 sinthet=short/dist_pep_side*costhet
19423 !C now costhet_grad
19426 costhet_fac=costhet**3*short**2*(-0.5d0)/dist_pep_side**4
19427 !C sinthet_fac=costhet**2*0.5d0*(short**3/dist_pep_side**4*costhet
19428 !C & -short/dist_pep_side**2/costhet)
19429 !C costhet_fac=0.0d0
19431 costhet_grad(j)=costhet_fac*pep_side(j)
19433 !C remember for the final gradient multiply costhet_grad(j)
19434 !C for side_chain by factor -2 !
19435 !C fac alfa is angle between CB_k,CA_k, CA_i,CA_i+1
19436 !C pep_side0pept_group is vector multiplication
19437 pep_side0pept_group=0.0d0
19439 pep_side0pept_group=pep_side0pept_group+pep_side(j)*side_calf(j)
19441 cosalfa=(pep_side0pept_group/ &
19442 (dist_pep_side*dist_side_calf))
19443 fac_alfa_sin=1.0d0-cosalfa**2
19444 fac_alfa_sin=dsqrt(fac_alfa_sin)
19445 rkprim=fac_alfa_sin*(long-short)+short
19448 !C now costhet_grad
19449 cosphi=1.0d0/dsqrt(1.0d0+rkprim**2/dist_pep_side**2)
19451 cosphi_fac=cosphi**3*rkprim**2*(-0.5d0)/dist_pep_side**4
19452 sinphi=rkprim/dist_pep_side/dsqrt(1.0d0+rkprim**2/ &
19456 cosphi_grad_long(j)=cosphi_fac*pep_side(j) &
19457 +cosphi**3*0.5d0/dist_pep_side**2*(-rkprim) &
19458 *(long-short)/fac_alfa_sin*cosalfa/ &
19459 ((dist_pep_side*dist_side_calf))* &
19460 ((side_calf(j))-cosalfa* &
19461 ((pep_side(j)/dist_pep_side)*dist_side_calf))
19462 !C cosphi_grad_long(j)=0.0d0
19463 cosphi_grad_loc(j)=cosphi**3*0.5d0/dist_pep_side**2*(-rkprim) &
19464 *(long-short)/fac_alfa_sin*cosalfa &
19465 /((dist_pep_side*dist_side_calf))* &
19467 cosalfa*side_calf(j)/dist_side_calf*dist_pep_side)
19468 !C cosphi_grad_loc(j)=0.0d0
19470 !C print *,sinphi,sinthet
19471 VofOverlap=VSolvSphere/2.0d0*(1.0d0-dsqrt(1.0d0-sinphi*sinthet)) &
19474 !C now the gradient...
19476 grad_shield(j,i)=grad_shield(j,i) &
19477 !C gradient po skalowaniu
19478 +(sh_frac_dist_grad(j)*VofOverlap &
19479 !C gradient po costhet
19480 +scale_fac_dist*VSolvSphere/VSolvSphere_div/4.0d0* &
19481 (1.0d0/(-dsqrt(1.0d0-sinphi*sinthet))*( &
19482 sinphi/sinthet*costhet*costhet_grad(j) &
19483 +sinthet/sinphi*cosphi*cosphi_grad_long(j))) &
19485 !C grad_shield_side is Cbeta sidechain gradient
19486 grad_shield_side(j,ishield_list(i),i)=&
19487 (sh_frac_dist_grad(j)*-2.0d0&
19489 -scale_fac_dist*VSolvSphere/VSolvSphere_div/2.0d0*&
19490 (1.0d0/(-dsqrt(1.0d0-sinphi*sinthet))*(&
19491 sinphi/sinthet*costhet*costhet_grad(j)&
19492 +sinthet/sinphi*cosphi*cosphi_grad_long(j))) &
19495 grad_shield_loc(j,ishield_list(i),i)= &
19496 scale_fac_dist*VSolvSphere/VSolvSphere_div/2.0d0*&
19497 (1.0d0/(dsqrt(1.0d0-sinphi*sinthet))*(&
19498 sinthet/sinphi*cosphi*cosphi_grad_loc(j)&
19502 VolumeTotal=VolumeTotal+VofOverlap*scale_fac_dist
19504 fac_shield(i)=VolumeTotal*wshield+(1.0d0-wshield)
19506 !C write(2,*) "TOTAL VOLUME",i,itype(i,1),fac_shield(i)
19509 end subroutine set_shield_fac2
19510 !----------------------------------------------------------------------------
19511 ! SOUBROUTINE FOR AFM
19512 subroutine AFMvel(Eafmforce)
19513 use MD_data, only:totTafm
19514 real(kind=8),dimension(3) :: diffafm
19515 real(kind=8) :: afmdist,Eafmforce
19517 !C Only for check grad COMMENT if not used for checkgrad
19519 !C--------------------------------------------------------
19520 !C print *,"wchodze"
19524 diffafm(i)=c(i,afmend)-c(i,afmbeg)
19525 afmdist=afmdist+diffafm(i)**2
19527 afmdist=dsqrt(afmdist)
19529 Eafmforce=0.5d0*forceAFMconst &
19530 *(distafminit+totTafm*velAFMconst-afmdist)**2
19531 !C Eafmforce=-forceAFMconst*(dist-distafminit)
19533 gradafm(i,afmend-1)=-forceAFMconst* &
19534 (distafminit+totTafm*velAFMconst-afmdist) &
19535 *diffafm(i)/afmdist
19536 gradafm(i,afmbeg-1)=forceAFMconst* &
19537 (distafminit+totTafm*velAFMconst-afmdist) &
19538 *diffafm(i)/afmdist
19540 ! print *,'AFM',Eafmforce,totTafm*velAFMconst,afmdist
19542 end subroutine AFMvel
19543 !---------------------------------------------------------
19544 subroutine AFMforce(Eafmforce)
19546 real(kind=8),dimension(3) :: diffafm
19547 ! real(kind=8) ::afmdist
19548 real(kind=8) :: afmdist,Eafmforce
19553 diffafm(i)=c(i,afmend)-c(i,afmbeg)
19554 afmdist=afmdist+diffafm(i)**2
19556 afmdist=dsqrt(afmdist)
19557 ! print *,afmdist,distafminit
19558 Eafmforce=-forceAFMconst*(afmdist-distafminit)
19560 gradafm(i,afmend-1)=-forceAFMconst*diffafm(i)/afmdist
19561 gradafm(i,afmbeg-1)=forceAFMconst*diffafm(i)/afmdist
19563 !C print *,'AFM',Eafmforce
19565 end subroutine AFMforce
19567 !-----------------------------------------------------------------------------
19569 subroutine read_ssHist
19572 ! include 'DIMENSIONS'
19573 ! include "DIMENSIONS.FREE"
19574 ! include 'COMMON.FREE'
19577 character(len=80) :: controlcard
19580 call card_concat(controlcard,.true.)
19581 read(controlcard,*) &
19582 dyn_ssHist(i,0),(dyn_ssHist(i,j),j=1,2*dyn_ssHist(i,0))
19586 end subroutine read_ssHist
19588 !-----------------------------------------------------------------------------
19589 integer function indmat(i,j)
19591 ! get the position of the jth ijth fragment of the chain coordinate system
19592 ! in the fromto array.
19595 indmat=((2*(nres-2)-i)*(i-1))/2+j-1
19597 end function indmat
19598 !-----------------------------------------------------------------------------
19599 real(kind=8) function sigm(x)
19605 !-----------------------------------------------------------------------------
19606 !-----------------------------------------------------------------------------
19607 subroutine alloc_ener_arrays
19608 !EL Allocation of arrays used by module energy
19609 use MD_data, only: mset
19610 !el local variables
19613 if(nres.lt.100) then
19615 elseif(nres.lt.200) then
19616 maxconts=0.8*nres ! Max. number of contacts per residue
19618 maxconts=0.6*nres ! (maxconts=maxres/4)
19620 maxcont=12*nres ! Max. number of SC contacts
19621 maxvar=6*nres ! Max. number of variables
19622 !el maxdim=(nres-1)*(nres-2)/2 ! Max. number of derivatives of virtual-bond
19623 maxdim=nres*(nres-2)/2 ! Max. number of derivatives of virtual-bond
19624 !----------------------
19625 ! arrays in subroutine init_int_table
19627 !el allocate(itask_cont_from(0:nfgtasks-1)) !(0:max_fg_procs-1)
19628 !el allocate(itask_cont_to(0:nfgtasks-1)) !(0:max_fg_procs-1)
19630 allocate(nint_gr(nres))
19631 allocate(nscp_gr(nres))
19632 allocate(ielstart(nres))
19633 allocate(ielend(nres))
19635 allocate(istart(nres,maxint_gr))
19636 allocate(iend(nres,maxint_gr))
19637 !(maxres,maxint_gr)
19638 allocate(iscpstart(nres,maxint_gr))
19639 allocate(iscpend(nres,maxint_gr))
19640 !(maxres,maxint_gr)
19641 allocate(ielstart_vdw(nres))
19642 allocate(ielend_vdw(nres))
19644 allocate(nint_gr_nucl(nres))
19645 allocate(nscp_gr_nucl(nres))
19646 allocate(ielstart_nucl(nres))
19647 allocate(ielend_nucl(nres))
19649 allocate(istart_nucl(nres,maxint_gr))
19650 allocate(iend_nucl(nres,maxint_gr))
19651 !(maxres,maxint_gr)
19652 allocate(iscpstart_nucl(nres,maxint_gr))
19653 allocate(iscpend_nucl(nres,maxint_gr))
19654 !(maxres,maxint_gr)
19655 allocate(ielstart_vdw_nucl(nres))
19656 allocate(ielend_vdw_nucl(nres))
19658 allocate(lentyp(0:nfgtasks-1))
19660 !----------------------
19662 ! common /contacts/
19663 if(.not.allocated(icont_ref)) allocate(icont_ref(2,maxcont))
19664 allocate(icont(2,maxcont))
19666 ! common /contacts1/
19667 allocate(num_cont(0:nres+4))
19669 allocate(jcont(maxconts,nres))
19671 allocate(facont(maxconts,nres))
19673 allocate(gacont(3,maxconts,nres))
19674 !(3,maxconts,maxres)
19675 ! common /contacts_hb/
19676 allocate(gacontp_hb1(3,maxconts,nres))
19677 allocate(gacontp_hb2(3,maxconts,nres))
19678 allocate(gacontp_hb3(3,maxconts,nres))
19679 allocate(gacontm_hb1(3,maxconts,nres))
19680 allocate(gacontm_hb2(3,maxconts,nres))
19681 allocate(gacontm_hb3(3,maxconts,nres))
19682 allocate(gacont_hbr(3,maxconts,nres))
19683 allocate(grij_hb_cont(3,maxconts,nres))
19684 !(3,maxconts,maxres)
19685 allocate(facont_hb(maxconts,nres))
19687 allocate(ees0p(maxconts,nres))
19688 allocate(ees0m(maxconts,nres))
19689 allocate(d_cont(maxconts,nres))
19690 allocate(ees0plist(maxconts,nres))
19693 allocate(num_cont_hb(nres))
19695 allocate(jcont_hb(maxconts,nres))
19698 allocate(Ug(2,2,nres))
19699 allocate(Ugder(2,2,nres))
19700 allocate(Ug2(2,2,nres))
19701 allocate(Ug2der(2,2,nres))
19703 allocate(obrot(2,nres))
19704 allocate(obrot2(2,nres))
19705 allocate(obrot_der(2,nres))
19706 allocate(obrot2_der(2,nres))
19708 ! common /precomp1/
19709 allocate(mu(2,nres))
19710 allocate(muder(2,nres))
19711 allocate(Ub2(2,nres))
19714 allocate(Ub2der(2,nres))
19715 allocate(Ctobr(2,nres))
19716 allocate(Ctobrder(2,nres))
19717 allocate(Dtobr2(2,nres))
19718 allocate(Dtobr2der(2,nres))
19720 allocate(EUg(2,2,nres))
19721 allocate(EUgder(2,2,nres))
19722 allocate(CUg(2,2,nres))
19723 allocate(CUgder(2,2,nres))
19724 allocate(DUg(2,2,nres))
19725 allocate(Dugder(2,2,nres))
19726 allocate(DtUg2(2,2,nres))
19727 allocate(DtUg2der(2,2,nres))
19729 ! common /precomp2/
19730 allocate(Ug2Db1t(2,nres))
19731 allocate(Ug2Db1tder(2,nres))
19732 allocate(CUgb2(2,nres))
19733 allocate(CUgb2der(2,nres))
19735 allocate(EUgC(2,2,nres))
19736 allocate(EUgCder(2,2,nres))
19737 allocate(EUgD(2,2,nres))
19738 allocate(EUgDder(2,2,nres))
19739 allocate(DtUg2EUg(2,2,nres))
19740 allocate(Ug2DtEUg(2,2,nres))
19742 allocate(Ug2DtEUgder(2,2,2,nres))
19743 allocate(DtUg2EUgder(2,2,2,nres))
19745 ! common /rotat_old/
19746 allocate(costab(nres))
19747 allocate(sintab(nres))
19748 allocate(costab2(nres))
19749 allocate(sintab2(nres))
19752 allocate(a_chuj(2,2,maxconts,nres))
19753 !(2,2,maxconts,maxres)(maxconts=maxres/4)
19754 allocate(a_chuj_der(2,2,3,5,maxconts,nres))
19755 !(2,2,3,5,maxconts,maxres)(maxconts=maxres/4)
19756 ! common /contdistrib/
19757 allocate(ncont_sent(nres))
19758 allocate(ncont_recv(nres))
19760 allocate(iat_sent(nres))
19762 allocate(iint_sent(4,nres,nres))
19763 allocate(iint_sent_local(4,nres,nres))
19765 allocate(iturn3_sent(4,0:nres+4))
19766 allocate(iturn4_sent(4,0:nres+4))
19767 allocate(iturn3_sent_local(4,nres))
19768 allocate(iturn4_sent_local(4,nres))
19770 allocate(itask_cont_from(0:nfgtasks-1))
19771 allocate(itask_cont_to(0:nfgtasks-1))
19772 !(0:max_fg_procs-1)
19776 !----------------------
19779 allocate(dcdv(6,maxdim))
19780 allocate(dxdv(6,maxdim))
19782 allocate(dxds(6,nres))
19784 allocate(gradx(3,-1:nres,0:2))
19785 allocate(gradc(3,-1:nres,0:2))
19787 allocate(gvdwx(3,-1:nres))
19788 allocate(gvdwc(3,-1:nres))
19789 allocate(gelc(3,-1:nres))
19790 allocate(gelc_long(3,-1:nres))
19791 allocate(gvdwpp(3,-1:nres))
19792 allocate(gvdwc_scpp(3,-1:nres))
19793 allocate(gradx_scp(3,-1:nres))
19794 allocate(gvdwc_scp(3,-1:nres))
19795 allocate(ghpbx(3,-1:nres))
19796 allocate(ghpbc(3,-1:nres))
19797 allocate(gradcorr(3,-1:nres))
19798 allocate(gradcorr_long(3,-1:nres))
19799 allocate(gradcorr5_long(3,-1:nres))
19800 allocate(gradcorr6_long(3,-1:nres))
19801 allocate(gcorr6_turn_long(3,-1:nres))
19802 allocate(gradxorr(3,-1:nres))
19803 allocate(gradcorr5(3,-1:nres))
19804 allocate(gradcorr6(3,-1:nres))
19805 allocate(gliptran(3,-1:nres))
19806 allocate(gliptranc(3,-1:nres))
19807 allocate(gliptranx(3,-1:nres))
19808 allocate(gshieldx(3,-1:nres))
19809 allocate(gshieldc(3,-1:nres))
19810 allocate(gshieldc_loc(3,-1:nres))
19811 allocate(gshieldx_ec(3,-1:nres))
19812 allocate(gshieldc_ec(3,-1:nres))
19813 allocate(gshieldc_loc_ec(3,-1:nres))
19814 allocate(gshieldx_t3(3,-1:nres))
19815 allocate(gshieldc_t3(3,-1:nres))
19816 allocate(gshieldc_loc_t3(3,-1:nres))
19817 allocate(gshieldx_t4(3,-1:nres))
19818 allocate(gshieldc_t4(3,-1:nres))
19819 allocate(gshieldc_loc_t4(3,-1:nres))
19820 allocate(gshieldx_ll(3,-1:nres))
19821 allocate(gshieldc_ll(3,-1:nres))
19822 allocate(gshieldc_loc_ll(3,-1:nres))
19823 allocate(grad_shield(3,-1:nres))
19824 allocate(gg_tube_sc(3,-1:nres))
19825 allocate(gg_tube(3,-1:nres))
19826 allocate(gradafm(3,-1:nres))
19827 allocate(gradb_nucl(3,-1:nres))
19828 allocate(gradbx_nucl(3,-1:nres))
19829 allocate(gvdwpsb1(3,-1:nres))
19830 allocate(gelpp(3,-1:nres))
19831 allocate(gvdwpsb(3,-1:nres))
19832 allocate(gelsbc(3,-1:nres))
19833 allocate(gelsbx(3,-1:nres))
19834 allocate(gvdwsbx(3,-1:nres))
19835 allocate(gvdwsbc(3,-1:nres))
19836 allocate(gsbloc(3,-1:nres))
19837 allocate(gsblocx(3,-1:nres))
19838 allocate(gradcorr_nucl(3,-1:nres))
19839 allocate(gradxorr_nucl(3,-1:nres))
19840 allocate(gradcorr3_nucl(3,-1:nres))
19841 allocate(gradxorr3_nucl(3,-1:nres))
19842 allocate(gvdwpp_nucl(3,-1:nres))
19843 allocate(gradpepcat(3,-1:nres))
19844 allocate(gradpepcatx(3,-1:nres))
19845 allocate(gradcatcat(3,-1:nres))
19847 allocate(grad_shield_side(3,50,nres))
19848 allocate(grad_shield_loc(3,50,nres))
19849 ! grad for shielding surroing
19850 allocate(gloc(0:maxvar,0:2))
19851 allocate(gloc_x(0:maxvar,2))
19853 allocate(gel_loc(3,-1:nres))
19854 allocate(gel_loc_long(3,-1:nres))
19855 allocate(gcorr3_turn(3,-1:nres))
19856 allocate(gcorr4_turn(3,-1:nres))
19857 allocate(gcorr6_turn(3,-1:nres))
19858 allocate(gradb(3,-1:nres))
19859 allocate(gradbx(3,-1:nres))
19861 allocate(gel_loc_loc(maxvar))
19862 allocate(gel_loc_turn3(maxvar))
19863 allocate(gel_loc_turn4(maxvar))
19864 allocate(gel_loc_turn6(maxvar))
19865 allocate(gcorr_loc(maxvar))
19866 allocate(g_corr5_loc(maxvar))
19867 allocate(g_corr6_loc(maxvar))
19869 allocate(gsccorc(3,-1:nres))
19870 allocate(gsccorx(3,-1:nres))
19872 allocate(gsccor_loc(-1:nres))
19874 allocate(gvdwx_scbase(3,-1:nres))
19875 allocate(gvdwc_scbase(3,-1:nres))
19876 allocate(gvdwx_pepbase(3,-1:nres))
19877 allocate(gvdwc_pepbase(3,-1:nres))
19878 allocate(gvdwx_scpho(3,-1:nres))
19879 allocate(gvdwc_scpho(3,-1:nres))
19880 allocate(gvdwc_peppho(3,-1:nres))
19882 allocate(dtheta(3,2,-1:nres))
19884 allocate(gscloc(3,-1:nres))
19885 allocate(gsclocx(3,-1:nres))
19887 allocate(dphi(3,3,-1:nres))
19888 allocate(dalpha(3,3,-1:nres))
19889 allocate(domega(3,3,-1:nres))
19891 ! common /deriv_scloc/
19892 allocate(dXX_C1tab(3,nres))
19893 allocate(dYY_C1tab(3,nres))
19894 allocate(dZZ_C1tab(3,nres))
19895 allocate(dXX_Ctab(3,nres))
19896 allocate(dYY_Ctab(3,nres))
19897 allocate(dZZ_Ctab(3,nres))
19898 allocate(dXX_XYZtab(3,nres))
19899 allocate(dYY_XYZtab(3,nres))
19900 allocate(dZZ_XYZtab(3,nres))
19903 allocate(jgrad_start(nres))
19904 allocate(jgrad_end(nres))
19906 !----------------------
19909 allocate(ibond_displ(0:nfgtasks-1))
19910 allocate(ibond_count(0:nfgtasks-1))
19911 allocate(ithet_displ(0:nfgtasks-1))
19912 allocate(ithet_count(0:nfgtasks-1))
19913 allocate(iphi_displ(0:nfgtasks-1))
19914 allocate(iphi_count(0:nfgtasks-1))
19915 allocate(iphi1_displ(0:nfgtasks-1))
19916 allocate(iphi1_count(0:nfgtasks-1))
19917 allocate(ivec_displ(0:nfgtasks-1))
19918 allocate(ivec_count(0:nfgtasks-1))
19919 allocate(iset_displ(0:nfgtasks-1))
19920 allocate(iset_count(0:nfgtasks-1))
19921 allocate(iint_count(0:nfgtasks-1))
19922 allocate(iint_displ(0:nfgtasks-1))
19923 !(0:max_fg_procs-1)
19924 !----------------------
19927 allocate(gcart(3,-1:nres))
19928 allocate(gxcart(3,-1:nres))
19930 allocate(gradcag(3,-1:nres))
19931 allocate(gradxag(3,-1:nres))
19933 ! common /back_constr/
19934 !el in energy:Econstr_back allocate((:),allocatable :: utheta,ugamma,uscdiff !(maxfrag_back)
19935 allocate(dutheta(nres))
19936 allocate(dugamma(nres))
19938 allocate(duscdiff(3,nres))
19939 allocate(duscdiffx(3,nres))
19941 !el i io:read_fragments
19942 ! allocate((:,:,:),allocatable :: wfrag_back !(3,maxfrag_back,maxprocs/20)
19943 ! allocate((:,:,:),allocatable :: ifrag_back !(3,maxfrag_back,maxprocs/20)
19945 ! allocate(qinfrag(50,nprocs/20),wfrag(50,nprocs/20)) !(50,maxprocs/20)
19946 ! allocate(qinpair(100,nprocs/20),wpair(100,nprocs/20)) !(100,maxprocs/20)
19947 allocate(mset(0:nprocs)) !(maxprocs/20)
19949 ! allocate(ifrag(2,50,nprocs/20)) !(2,50,maxprocs/20)
19950 ! allocate(ipair(2,100,nprocs/20)) !(2,100,maxprocs/20)
19951 allocate(dUdconst(3,0:nres))
19952 allocate(dUdxconst(3,0:nres))
19953 allocate(dqwol(3,0:nres))
19954 allocate(dxqwol(3,0:nres))
19956 !----------------------
19958 ! common /sbridge/ in io_common: read_bridge
19959 !el allocate((:),allocatable :: iss !(maxss)
19960 ! common /links/ in io_common: read_bridge
19961 !el real(kind=8),dimension(:),allocatable :: dhpb,forcon,dhpb1 !(maxdim) !el dhpb1 !!! nie używane
19962 !el integer,dimension(:),allocatable :: ihpb,jhpb,ibecarb !(maxdim) !el ibecarb !!! nie używane
19963 ! common /dyn_ssbond/
19964 ! and side-chain vectors in theta or phi.
19965 allocate(dyn_ssbond_ij(0:nres+4,0:nres+4))
19969 dyn_ssbond_ij(:,:)=1.0d300
19973 ! if (nss.gt.0) then
19974 allocate(idssb(maxdim),jdssb(maxdim))
19975 ! allocate(newihpb(nss),newjhpb(nss))
19978 allocate(ishield_list(nres))
19979 allocate(shield_list(50,nres))
19980 allocate(dyn_ss_mask(nres))
19981 allocate(fac_shield(nres))
19982 allocate(enetube(nres*2))
19983 allocate(enecavtube(nres*2))
19986 dyn_ss_mask(:)=.false.
19987 !----------------------
19989 ! Parameters of the SCCOR term
19991 !el in io_conf: parmread
19992 ! allocate(v1sccor(maxterm_sccor,3,-ntyp:ntyp,-ntyp:ntyp))
19993 ! allocate(v2sccor(maxterm_sccor,3,-ntyp:ntyp,-ntyp:ntyp)) !(maxterm_sccor,3,-ntyp:ntyp,-ntyp:ntyp)
19994 ! allocate(v0sccor(maxterm_sccor,-ntyp:ntyp,-ntyp:ntyp)) !(maxterm_sccor,-ntyp:ntyp,-ntyp:ntyp)
19995 ! allocate(isccortyp(-ntyp:ntyp)) !(-ntyp:ntyp)
19996 ! allocate(nterm_sccor(-ntyp:ntyp,-ntyp:ntyp))
19997 ! allocate(nlor_sccor(-ntyp:ntyp,-ntyp:ntyp)) !(-ntyp:ntyp,-ntyp:ntyp)
19998 ! allocate(vlor1sccor(maxterm_sccor,20,20))
19999 ! allocate(vlor2sccor(maxterm_sccor,20,20))
20000 ! allocate(vlor3sccor(maxterm_sccor,20,20)) !(maxterm_sccor,20,20)
20002 allocate(gloc_sc(3,0:2*nres,0:10))
20003 !(3,0:maxres2,10)maxres2=2*maxres
20004 allocate(dcostau(3,3,3,2*nres))
20005 allocate(dsintau(3,3,3,2*nres))
20006 allocate(dtauangle(3,3,3,2*nres))
20007 allocate(dcosomicron(3,3,3,2*nres))
20008 allocate(domicron(3,3,3,2*nres))
20009 !(3,3,3,maxres2)maxres2=2*maxres
20010 !----------------------
20013 allocate(varall(maxvar))
20014 !(maxvar)(maxvar=6*maxres)
20015 allocate(mask_theta(nres))
20016 allocate(mask_phi(nres))
20017 allocate(mask_side(nres))
20019 !----------------------
20022 allocate(uy(3,nres))
20023 allocate(uz(3,nres))
20025 allocate(uygrad(3,3,2,nres))
20026 allocate(uzgrad(3,3,2,nres))
20030 end subroutine alloc_ener_arrays
20031 !-----------------------------------------------------------------
20032 subroutine ebond_nucl(estr_nucl)
20034 !c Evaluate the energy of stretching of the CA-CA and CA-SC virtual bonds
20037 real(kind=8),dimension(3) :: u,ud
20038 real(kind=8) :: usum,uprod,uprod1,uprod2,usumsqder
20039 real(kind=8) :: estr_nucl,diff
20040 integer :: iti,i,j,k,nbi
20042 !C print *,"I enter ebond"
20044 write (iout,*) "ibondp_start,ibondp_end",&
20045 ibondp_nucl_start,ibondp_nucl_end
20046 do i=ibondp_nucl_start,ibondp_nucl_end
20047 if (itype(i-1,2).eq.ntyp1_molec(2) .or. &
20048 itype(i,2).eq.ntyp1_molec(2)) cycle
20049 ! estr1=estr1+gnmr1(vbld(i),-1.0d0,distchainmax)
20051 ! gradb(j,i-1)=gnmr1prim(vbld(i),-1.0d0,distchainmax)
20052 ! & *dc(j,i-1)/vbld(i)
20054 ! if (energy_dec) write(iout,*)
20055 ! & "estr1",i,vbld(i),distchainmax,
20056 ! & gnmr1(vbld(i),-1.0d0,distchainmax)
20058 diff = vbld(i)-vbldp0_nucl
20059 if(energy_dec)write(iout,*) "estr_nucl_bb" , i,vbld(i),&
20060 vbldp0_nucl,diff,AKP_nucl*diff*diff
20061 estr_nucl=estr_nucl+diff*diff
20062 ! print *,estr_nucl
20064 gradb_nucl(j,i-1)=AKP_nucl*diff*dc(j,i-1)/vbld(i)
20066 !c write (iout,'(i5,3f10.5)') i,(gradb(j,i-1),j=1,3)
20068 estr_nucl=0.5d0*AKP_nucl*estr_nucl
20069 ! print *,"partial sum", estr_nucl,AKP_nucl
20072 write (iout,*) "ibondp_start,ibondp_end",&
20073 ibond_nucl_start,ibond_nucl_end
20075 do i=ibond_nucl_start,ibond_nucl_end
20076 !C print *, "I am stuck",i
20078 if (iti.eq.ntyp1_molec(2)) cycle
20079 nbi=nbondterm_nucl(iti)
20082 diff=vbld(i+nres)-vbldsc0_nucl(1,iti)
20085 write (iout,*) "estr_nucl_sc", i,iti,vbld(i+nres),vbldsc0_nucl(1,iti),diff, &
20086 AKSC_nucl(1,iti),AKSC_nucl(1,iti)*diff*diff
20087 estr_nucl=estr_nucl+0.5d0*AKSC_nucl(1,iti)*diff*diff
20088 ! print *,estr_nucl
20090 gradbx_nucl(j,i)=AKSC_nucl(1,iti)*diff*dc(j,i+nres)/vbld(i+nres)
20094 diff=vbld(i+nres)-vbldsc0_nucl(j,iti)
20095 ud(j)=aksc_nucl(j,iti)*diff
20096 u(j)=abond0_nucl(j,iti)+0.5d0*ud(j)*diff
20110 uprod2=uprod2*u(k)*u(k)
20114 usumsqder=usumsqder+ud(j)*uprod2
20116 estr_nucl=estr_nucl+uprod/usum
20118 gradbx_nucl(j,i)=usumsqder/(usum*usum)*dc(j,i+nres)/vbld(i+nres)
20122 !C print *,"I am about to leave ebond"
20124 end subroutine ebond_nucl
20126 !-----------------------------------------------------------------------------
20127 subroutine ebend_nucl(etheta_nucl)
20128 real(kind=8),dimension(nntheterm_nucl+1) :: coskt,sinkt !mmaxtheterm
20129 real(kind=8),dimension(nsingle_nucl+1) :: cosph1,sinph1,cosph2,sinph2 !maxsingle
20130 real(kind=8),dimension(ndouble_nucl+1,ndouble_nucl+1) :: cosph1ph2,sinph1ph2 !maxdouble,maxdouble
20131 logical :: lprn=.false., lprn1=.false.
20132 !el local variables
20133 integer :: i,k,iblock,ityp1,ityp2,ityp3,l,m
20134 real(kind=8) :: dethetai,dephii,dephii1,theti2,phii,phii1,ethetai
20135 real(kind=8) :: aux,etheta_nucl,ccl,ssl,scl,csl,ethetacnstr
20136 ! local variables for constrains
20137 real(kind=8) :: difi,thetiii
20140 ! print *,"ithet_start",ithet_nucl_start," ithet_end",ithet_nucl_end,nres
20141 do i=ithet_nucl_start,ithet_nucl_end
20142 if ((itype(i-1,2).eq.ntyp1_molec(2)).or.&
20143 (itype(i-2,2).eq.ntyp1_molec(2)).or. &
20144 (itype(i,2).eq.ntyp1_molec(2))) cycle
20148 theti2=0.5d0*theta(i)
20149 ityp2=ithetyp_nucl(itype(i-1,2))
20150 do k=1,nntheterm_nucl
20151 coskt(k)=dcos(k*theti2)
20152 sinkt(k)=dsin(k*theti2)
20154 if (i.gt.3 .and. itype(i-2,2).ne.ntyp1_molec(2)) then
20157 if (phii.ne.phii) phii=150.0
20161 ityp1=ithetyp_nucl(itype(i-2,2))
20162 do k=1,nsingle_nucl
20163 cosph1(k)=dcos(k*phii)
20164 sinph1(k)=dsin(k*phii)
20168 ityp1=nthetyp_nucl+1
20169 do k=1,nsingle_nucl
20175 if (i.lt.nres .and. itype(i,2).ne.ntyp1_molec(2)) then
20178 if (phii1.ne.phii1) phii1=150.0
20179 phii1=pinorm(phii1)
20183 ityp3=ithetyp_nucl(itype(i,2))
20184 do k=1,nsingle_nucl
20185 cosph2(k)=dcos(k*phii1)
20186 sinph2(k)=dsin(k*phii1)
20190 ityp3=nthetyp_nucl+1
20191 do k=1,nsingle_nucl
20196 ethetai=aa0thet_nucl(ityp1,ityp2,ityp3)
20197 do k=1,ndouble_nucl
20199 ccl=cosph1(l)*cosph2(k-l)
20200 ssl=sinph1(l)*sinph2(k-l)
20201 scl=sinph1(l)*cosph2(k-l)
20202 csl=cosph1(l)*sinph2(k-l)
20203 cosph1ph2(l,k)=ccl-ssl
20204 cosph1ph2(k,l)=ccl+ssl
20205 sinph1ph2(l,k)=scl+csl
20206 sinph1ph2(k,l)=scl-csl
20210 write (iout,*) "i",i," ityp1",ityp1," ityp2",ityp2,&
20211 " ityp3",ityp3," theti2",theti2," phii",phii," phii1",phii1
20212 write (iout,*) "coskt and sinkt",nntheterm_nucl
20213 do k=1,nntheterm_nucl
20214 write (iout,*) k,coskt(k),sinkt(k)
20217 do k=1,ntheterm_nucl
20218 ethetai=ethetai+aathet_nucl(k,ityp1,ityp2,ityp3)*sinkt(k)
20219 dethetai=dethetai+0.5d0*k*aathet_nucl(k,ityp1,ityp2,ityp3)&
20222 write (iout,*) "k",k," aathet",aathet_nucl(k,ityp1,ityp2,ityp3),&
20226 write (iout,*) "cosph and sinph"
20227 do k=1,nsingle_nucl
20228 write (iout,*) k,cosph1(k),sinph1(k),cosph2(k),sinph2(k)
20230 write (iout,*) "cosph1ph2 and sinph2ph2"
20231 do k=2,ndouble_nucl
20233 write (iout,*) l,k,cosph1ph2(l,k),cosph1ph2(k,l),&
20234 sinph1ph2(l,k),sinph1ph2(k,l)
20237 write(iout,*) "ethetai",ethetai
20239 do m=1,ntheterm2_nucl
20240 do k=1,nsingle_nucl
20241 aux=bbthet_nucl(k,m,ityp1,ityp2,ityp3)*cosph1(k)&
20242 +ccthet_nucl(k,m,ityp1,ityp2,ityp3)*sinph1(k)&
20243 +ddthet_nucl(k,m,ityp1,ityp2,ityp3)*cosph2(k)&
20244 +eethet_nucl(k,m,ityp1,ityp2,ityp3)*sinph2(k)
20245 ethetai=ethetai+sinkt(m)*aux
20246 dethetai=dethetai+0.5d0*m*aux*coskt(m)
20247 dephii=dephii+k*sinkt(m)*(&
20248 ccthet_nucl(k,m,ityp1,ityp2,ityp3)*cosph1(k)-&
20249 bbthet_nucl(k,m,ityp1,ityp2,ityp3)*sinph1(k))
20250 dephii1=dephii1+k*sinkt(m)*(&
20251 eethet_nucl(k,m,ityp1,ityp2,ityp3)*cosph2(k)-&
20252 ddthet_nucl(k,m,ityp1,ityp2,ityp3)*sinph2(k))
20254 write (iout,*) "m",m," k",k," bbthet",&
20255 bbthet_nucl(k,m,ityp1,ityp2,ityp3)," ccthet",&
20256 ccthet_nucl(k,m,ityp1,ityp2,ityp3)," ddthet",&
20257 ddthet_nucl(k,m,ityp1,ityp2,ityp3)," eethet",&
20258 eethet_nucl(k,m,ityp1,ityp2,ityp3)," ethetai",ethetai
20262 write(iout,*) "ethetai",ethetai
20263 do m=1,ntheterm3_nucl
20264 do k=2,ndouble_nucl
20266 aux=ffthet_nucl(l,k,m,ityp1,ityp2,ityp3)*cosph1ph2(l,k)+&
20267 ffthet_nucl(k,l,m,ityp1,ityp2,ityp3)*cosph1ph2(k,l)+&
20268 ggthet_nucl(l,k,m,ityp1,ityp2,ityp3)*sinph1ph2(l,k)+&
20269 ggthet_nucl(k,l,m,ityp1,ityp2,ityp3)*sinph1ph2(k,l)
20270 ethetai=ethetai+sinkt(m)*aux
20271 dethetai=dethetai+0.5d0*m*coskt(m)*aux
20272 dephii=dephii+l*sinkt(m)*(&
20273 -ffthet_nucl(l,k,m,ityp1,ityp2,ityp3)*sinph1ph2(l,k)-&
20274 ffthet_nucl(k,l,m,ityp1,ityp2,ityp3)*sinph1ph2(k,l)+&
20275 ggthet_nucl(l,k,m,ityp1,ityp2,ityp3)*cosph1ph2(l,k)+&
20276 ggthet_nucl(k,l,m,ityp1,ityp2,ityp3)*cosph1ph2(k,l))
20277 dephii1=dephii1+(k-l)*sinkt(m)*( &
20278 -ffthet_nucl(l,k,m,ityp1,ityp2,ityp3)*sinph1ph2(l,k)+&
20279 ffthet_nucl(k,l,m,ityp1,ityp2,ityp3)*sinph1ph2(k,l)+&
20280 ggthet_nucl(l,k,m,ityp1,ityp2,ityp3)*cosph1ph2(l,k)-&
20281 ggthet_nucl(k,l,m,ityp1,ityp2,ityp3)*cosph1ph2(k,l))
20283 write (iout,*) "m",m," k",k," l",l," ffthet", &
20284 ffthet_nucl(l,k,m,ityp1,ityp2,ityp3), &
20285 ffthet_nucl(k,l,m,ityp1,ityp2,ityp3)," ggthet",&
20286 ggthet_nucl(l,k,m,ityp1,ityp2,ityp3),&
20287 ggthet_nucl(k,l,m,ityp1,ityp2,ityp3)," ethetai",ethetai
20288 write (iout,*) cosph1ph2(l,k)*sinkt(m), &
20289 cosph1ph2(k,l)*sinkt(m),&
20290 sinph1ph2(l,k)*sinkt(m),sinph1ph2(k,l)*sinkt(m)
20296 if (lprn1) write (iout,'(i2,3f8.1,9h ethetai ,f10.5)') &
20297 i,theta(i)*rad2deg,phii*rad2deg, &
20298 phii1*rad2deg,ethetai
20299 etheta_nucl=etheta_nucl+ethetai
20300 ! print *,i,"partial sum",etheta_nucl
20301 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang_nucl*dephii
20302 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang_nucl*dephii1
20303 gloc(nphi+i-2,icg)=wang_nucl*dethetai
20306 end subroutine ebend_nucl
20307 !----------------------------------------------------
20308 subroutine etor_nucl(etors_nucl)
20309 ! implicit real*8 (a-h,o-z)
20310 ! include 'DIMENSIONS'
20311 ! include 'COMMON.VAR'
20312 ! include 'COMMON.GEO'
20313 ! include 'COMMON.LOCAL'
20314 ! include 'COMMON.TORSION'
20315 ! include 'COMMON.INTERACT'
20316 ! include 'COMMON.DERIV'
20317 ! include 'COMMON.CHAIN'
20318 ! include 'COMMON.NAMES'
20319 ! include 'COMMON.IOUNITS'
20320 ! include 'COMMON.FFIELD'
20321 ! include 'COMMON.TORCNSTR'
20322 ! include 'COMMON.CONTROL'
20323 real(kind=8) :: etors_nucl,edihcnstr
20325 !el local variables
20326 integer :: i,j,iblock,itori,itori1
20327 real(kind=8) :: phii,gloci,v1ij,v2ij,cosphi,sinphi,&
20328 vl1ij,vl2ij,vl3ij,pom1,difi,etors_ii,pom
20329 ! Set lprn=.true. for debugging
20333 ! print *,"iphi_nucl_start/end", iphi_nucl_start,iphi_nucl_end
20334 do i=iphi_nucl_start,iphi_nucl_end
20335 if (itype(i-2,2).eq.ntyp1_molec(2) .or. itype(i-1,2).eq.ntyp1_molec(2) &
20336 .or. itype(i-3,2).eq.ntyp1_molec(2) &
20337 .or. itype(i,2).eq.ntyp1_molec(2)) cycle
20339 itori=itortyp_nucl(itype(i-2,2))
20340 itori1=itortyp_nucl(itype(i-1,2))
20342 ! print *,i,itori,itori1
20344 !C Regular cosine and sine terms
20345 do j=1,nterm_nucl(itori,itori1)
20346 v1ij=v1_nucl(j,itori,itori1)
20347 v2ij=v2_nucl(j,itori,itori1)
20348 cosphi=dcos(j*phii)
20349 sinphi=dsin(j*phii)
20350 etors_nucl=etors_nucl+v1ij*cosphi+v2ij*sinphi
20351 if (energy_dec) etors_ii=etors_ii+&
20352 v1ij*cosphi+v2ij*sinphi
20353 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
20357 !C E = SUM ----------------------------------- - v1
20358 !C [v2 cos(phi/2)+v3 sin(phi/2)]^2 + 1
20360 cosphi=dcos(0.5d0*phii)
20361 sinphi=dsin(0.5d0*phii)
20362 do j=1,nlor_nucl(itori,itori1)
20363 vl1ij=vlor1_nucl(j,itori,itori1)
20364 vl2ij=vlor2_nucl(j,itori,itori1)
20365 vl3ij=vlor3_nucl(j,itori,itori1)
20366 pom=vl2ij*cosphi+vl3ij*sinphi
20367 pom1=1.0d0/(pom*pom+1.0d0)
20368 etors_nucl=etors_nucl+vl1ij*pom1
20369 if (energy_dec) etors_ii=etors_ii+ &
20372 gloci=gloci+vl1ij*(vl3ij*cosphi-vl2ij*sinphi)*pom
20374 !C Subtract the constant term
20375 etors_nucl=etors_nucl-v0_nucl(itori,itori1)
20376 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
20377 'etor',i,etors_ii-v0_nucl(itori,itori1)
20379 write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)') &
20380 restyp(itype(i-2,2),2),i-2,restyp(itype(i-1,2),2),i-1,itori,itori1, &
20381 (v1_nucl(j,itori,itori1),j=1,6),(v2_nucl(j,itori,itori1),j=1,6)
20382 gloc(i-3,icg)=gloc(i-3,icg)+wtor_nucl*gloci
20383 !c write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
20386 end subroutine etor_nucl
20387 !------------------------------------------------------------
20388 subroutine epp_nucl_sub(evdw1,ees)
20390 !C This subroutine calculates the average interaction energy and its gradient
20391 !C in the virtual-bond vectors between non-adjacent peptide groups, based on
20392 !C the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
20393 !C The potential depends both on the distance of peptide-group centers and on
20394 !C the orientation of the CA-CA virtual bonds.
20396 integer :: i,j,k,iteli,itelj,num_conti,isubchap,ind
20397 real(kind=8) :: dxi,dyi,dzi,dxj,dyj,dzj,aaa,bbb
20398 real(kind=8) :: xj,yj,zj,rij,rrmij,sss,r3ij,r6ij,evdw1,&
20399 dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
20400 dx_normj,dy_normj,dz_normj,rmij,ev1,ev2,evdwij,facvdw
20401 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
20402 dist_temp, dist_init,sss_grad,fac,evdw1ij
20403 integer xshift,yshift,zshift
20404 real(kind=8),dimension(3):: ggg,gggp,gggm,erij
20405 real(kind=8) :: ees,eesij
20406 !c 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
20407 real(kind=8) scal_el /0.5d0/
20413 !c Loop over all pairs of interacting peptide groups except i,i+2 and i,i+3
20415 ! print *,"iatel_s_nucl,iatel_e_nucl",iatel_s_nucl,iatel_e_nucl
20416 do i=iatel_s_nucl,iatel_e_nucl
20417 if (itype(i,2).eq.ntyp1_molec(2) .or. itype(i+1,2).eq.ntyp1_molec(2)) cycle
20421 dx_normi=dc_norm(1,i)
20422 dy_normi=dc_norm(2,i)
20423 dz_normi=dc_norm(3,i)
20424 xmedi=c(1,i)+0.5d0*dxi
20425 ymedi=c(2,i)+0.5d0*dyi
20426 zmedi=c(3,i)+0.5d0*dzi
20427 xmedi=dmod(xmedi,boxxsize)
20428 if (xmedi.lt.0) xmedi=xmedi+boxxsize
20429 ymedi=dmod(ymedi,boxysize)
20430 if (ymedi.lt.0) ymedi=ymedi+boxysize
20431 zmedi=dmod(zmedi,boxzsize)
20432 if (zmedi.lt.0) zmedi=zmedi+boxzsize
20434 do j=ielstart_nucl(i),ielend_nucl(i)
20435 if (itype(j,2).eq.ntyp1_molec(2) .or. itype(j+1,2).eq.ntyp1_molec(2)) cycle
20440 ! xj=c(1,j)+0.5D0*dxj-xmedi
20441 ! yj=c(2,j)+0.5D0*dyj-ymedi
20442 ! zj=c(3,j)+0.5D0*dzj-zmedi
20443 xj=c(1,j)+0.5D0*dxj
20444 yj=c(2,j)+0.5D0*dyj
20445 zj=c(3,j)+0.5D0*dzj
20446 xj=mod(xj,boxxsize)
20447 if (xj.lt.0) xj=xj+boxxsize
20448 yj=mod(yj,boxysize)
20449 if (yj.lt.0) yj=yj+boxysize
20450 zj=mod(zj,boxzsize)
20451 if (zj.lt.0) zj=zj+boxzsize
20453 dist_init=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
20460 xj=xj_safe+xshift*boxxsize
20461 yj=yj_safe+yshift*boxysize
20462 zj=zj_safe+zshift*boxzsize
20463 dist_temp=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
20464 if(dist_temp.lt.dist_init) then
20465 dist_init=dist_temp
20474 if (isubchap.eq.1) then
20485 rij=xj*xj+yj*yj+zj*zj
20486 !c write (2,*)"ij",i,j," r0pp",r0pp," rij",rij," epspp",epspp
20487 fac=(r0pp**2/rij)**3
20491 fac=(-ev1-evdw1ij)/rij
20492 ! write (2,*)"fac",fac," ev1",ev1," ev2",ev2," evdw1ij",evdw1ij
20493 if (energy_dec) write(iout,'(2i5,a9,f10.4)') i,j,"evdw1ij",evdw1ij
20494 evdw1=evdw1+evdw1ij
20496 !C Calculate contributions to the Cartesian gradient.
20502 gvdwpp_nucl(k,i)=gvdwpp_nucl(k,i)-ggg(k)
20503 gvdwpp_nucl(k,j)=gvdwpp_nucl(k,j)+ggg(k)
20505 !c phoshate-phosphate electrostatic interactions
20508 eesij=dexp(-BEES*rij)*fac
20509 ! write (2,*)"fac",fac," eesijpp",eesij
20510 if (energy_dec) write(iout,'(2i5,a9,f10.4)') i,j,"eesijpp",eesij
20513 fac=-(fac+BEES)*eesij*fac
20517 !c write(2,*) "ggg",i,j,ggg(1),ggg(2),ggg(3)
20518 !c write(2,*) "gelpp",i,(gelpp(k,i),k=1,3)
20519 !c write(2,*) "gelpp",j,(gelpp(k,j),k=1,3)
20521 gelpp(k,i)=gelpp(k,i)-ggg(k)
20522 gelpp(k,j)=gelpp(k,j)+ggg(k)
20529 !c write (2,*) "i",i," gelpp",(gelpp(k,i),k=1,3)
20531 gvdwpp_nucl(k,i)=6*gvdwpp_nucl(k,i)
20532 !c gelpp(k,i)=332.0d0*gelpp(k,i)
20533 gelpp(k,i)=AEES*gelpp(k,i)
20535 !c write (2,*) "i",i," gelpp",(gelpp(k,i),k=1,3)
20537 !c write (2,*) "total EES",ees
20539 end subroutine epp_nucl_sub
20540 !---------------------------------------------------------------------
20541 subroutine epsb(evdwpsb,eelpsb)
20544 !C This subroutine calculates the excluded-volume interaction energy between
20545 !C peptide-group centers and side chains and its gradient in virtual-bond and
20546 !C side-chain vectors.
20548 real(kind=8),dimension(3):: ggg
20549 integer :: i,iint,j,k,iteli,itypj,subchap
20550 real(kind=8) :: evdw2,evdw2_14,xi,yi,zi,xj,yj,zj,rrij,fac,&
20551 e1,e2,evdwij,rij,evdwpsb,eelpsb
20552 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
20553 dist_temp, dist_init
20554 integer xshift,yshift,zshift
20556 !cd print '(a)','Enter ESCP'
20557 !cd write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
20560 ! print *,"iatscp_s_nucl,iatscp_e_nucl",iatscp_s_nucl,iatscp_e_nucl
20561 do i=iatscp_s_nucl,iatscp_e_nucl
20562 if (itype(i,2).eq.ntyp1_molec(2) &
20563 .or. itype(i+1,2).eq.ntyp1_molec(2)) cycle
20564 xi=0.5D0*(c(1,i)+c(1,i+1))
20565 yi=0.5D0*(c(2,i)+c(2,i+1))
20566 zi=0.5D0*(c(3,i)+c(3,i+1))
20567 xi=mod(xi,boxxsize)
20568 if (xi.lt.0) xi=xi+boxxsize
20569 yi=mod(yi,boxysize)
20570 if (yi.lt.0) yi=yi+boxysize
20571 zi=mod(zi,boxzsize)
20572 if (zi.lt.0) zi=zi+boxzsize
20574 do iint=1,nscp_gr_nucl(i)
20576 do j=iscpstart_nucl(i,iint),iscpend_nucl(i,iint)
20578 if (itypj.eq.ntyp1_molec(2)) cycle
20579 !C Uncomment following three lines for SC-p interactions
20580 !c xj=c(1,nres+j)-xi
20581 !c yj=c(2,nres+j)-yi
20582 !c zj=c(3,nres+j)-zi
20583 !C Uncomment following three lines for Ca-p interactions
20590 xj=mod(xj,boxxsize)
20591 if (xj.lt.0) xj=xj+boxxsize
20592 yj=mod(yj,boxysize)
20593 if (yj.lt.0) yj=yj+boxysize
20594 zj=mod(zj,boxzsize)
20595 if (zj.lt.0) zj=zj+boxzsize
20596 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
20604 xj=xj_safe+xshift*boxxsize
20605 yj=yj_safe+yshift*boxysize
20606 zj=zj_safe+zshift*boxzsize
20607 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
20608 if(dist_temp.lt.dist_init) then
20609 dist_init=dist_temp
20618 if (subchap.eq.1) then
20628 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
20630 e1=fac*fac*aad_nucl(itypj)
20631 e2=fac*bad_nucl(itypj)
20632 if (iabs(j-i) .le. 2) then
20637 evdwpsb=evdwpsb+evdwij
20638 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a4)') &
20639 'evdw2',i,j,evdwij,"tu4"
20641 !C Calculate contributions to the gradient in the virtual-bond and SC vectors.
20643 fac=-(evdwij+e1)*rrij
20648 gvdwpsb1(k,i)=gvdwpsb1(k,i)-ggg(k)
20649 gvdwpsb(k,j)=gvdwpsb(k,j)+ggg(k)
20657 gvdwpsb(j,i)=expon*gvdwpsb(j,i)
20658 gvdwpsb1(j,i)=expon*gvdwpsb1(j,i)
20662 end subroutine epsb
20664 !------------------------------------------------------
20665 subroutine esb_gb(evdwsb,eelsb)
20668 integer :: iint,itypi,itypi1,itypj,subchap,num_conti2
20669 real(kind=8) :: xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
20670 real(kind=8) :: evdw,sig0iji,evdwsb,eelsb,ecorr,eelij
20671 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
20672 dist_temp, dist_init,aa,bb,faclip,sig0ij
20681 ! print *,"iastsc_nucl",iatsc_s_nucl,iatsc_e_nucl
20682 do i=iatsc_s_nucl,iatsc_e_nucl
20686 ! PRINT *,"I=",i,itypi
20687 if (itypi.eq.ntyp1_molec(2)) cycle
20688 itypi1=itype(i+1,2)
20692 xi=dmod(xi,boxxsize)
20693 if (xi.lt.0) xi=xi+boxxsize
20694 yi=dmod(yi,boxysize)
20695 if (yi.lt.0) yi=yi+boxysize
20696 zi=dmod(zi,boxzsize)
20697 if (zi.lt.0) zi=zi+boxzsize
20699 dxi=dc_norm(1,nres+i)
20700 dyi=dc_norm(2,nres+i)
20701 dzi=dc_norm(3,nres+i)
20702 dsci_inv=vbld_inv(i+nres)
20704 !C Calculate SC interaction energy.
20706 do iint=1,nint_gr_nucl(i)
20707 ! print *,"tu?",i,istart_nucl(i,iint),iend_nucl(i,iint)
20708 do j=istart_nucl(i,iint),iend_nucl(i,iint)
20712 if (itypj.eq.ntyp1_molec(2)) cycle
20713 dscj_inv=vbld_inv(j+nres)
20714 sig0ij=sigma_nucl(itypi,itypj)
20715 chi1=chi_nucl(itypi,itypj)
20716 chi2=chi_nucl(itypj,itypi)
20718 chip1=chip_nucl(itypi,itypj)
20719 chip2=chip_nucl(itypj,itypi)
20721 ! xj=c(1,nres+j)-xi
20722 ! yj=c(2,nres+j)-yi
20723 ! zj=c(3,nres+j)-zi
20727 xj=dmod(xj,boxxsize)
20728 if (xj.lt.0) xj=xj+boxxsize
20729 yj=dmod(yj,boxysize)
20730 if (yj.lt.0) yj=yj+boxysize
20731 zj=dmod(zj,boxzsize)
20732 if (zj.lt.0) zj=zj+boxzsize
20733 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
20741 xj=xj_safe+xshift*boxxsize
20742 yj=yj_safe+yshift*boxysize
20743 zj=zj_safe+zshift*boxzsize
20744 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
20745 if(dist_temp.lt.dist_init) then
20746 dist_init=dist_temp
20755 if (subchap.eq.1) then
20765 dxj=dc_norm(1,nres+j)
20766 dyj=dc_norm(2,nres+j)
20767 dzj=dc_norm(3,nres+j)
20768 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
20770 !C Calculate angle-dependent terms of energy and contributions to their
20775 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
20776 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
20777 om12=dxi*dxj+dyi*dyj+dzi*dzj
20778 call sc_angular_nucl
20780 sig=sig0ij*dsqrt(sigsq)
20781 rij_shift=1.0D0/rij-sig+sig0ij
20782 ! print *,rij_shift,"rij_shift"
20783 !c write (2,*) " rij",1.0D0/rij," sig",sig," sig0ij",sig0ij,
20784 !c & " rij_shift",rij_shift
20785 if (rij_shift.le.0.0D0) then
20790 !c---------------------------------------------------------------
20791 rij_shift=1.0D0/rij_shift
20792 fac=rij_shift**expon
20793 e1=fac*fac*aa_nucl(itypi,itypj)
20794 e2=fac*bb_nucl(itypi,itypj)
20795 evdwij=eps1*eps2rt*(e1+e2)
20796 !c write (2,*) "eps1",eps1," eps2rt",eps2rt,
20797 !c & " e1",e1," e2",e2," evdwij",evdwij
20799 evdwij=evdwij*eps2rt
20800 evdwsb=evdwsb+evdwij
20802 sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
20803 epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
20804 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
20805 restyp(itypi,2),i,restyp(itypj,2),j, &
20806 epsi,sigm,chi1,chi2,chip1,chip2, &
20807 eps1,eps2rt**2,sig,sig0ij, &
20808 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
20810 write (iout,*) "aa",aa_nucl(itypi,itypj)," bb",bb_nucl(itypi,itypj)
20813 if (energy_dec) write (iout,'(a6,2i5,e15.3,a4)') &
20814 'evdw',i,j,evdwij,"tu3"
20817 !C Calculate gradient components.
20818 e1=e1*eps1*eps2rt**2
20819 fac=-expon*(e1+evdwij)*rij_shift
20823 !C Calculate the radial part of the gradient
20827 !C Calculate angular part of the gradient.
20829 call eelsbij(eelij,num_conti2)
20830 if (energy_dec .and. &
20831 (j.eq.i+1.or.j.eq.nres-i+1.or.j.eq.nres-i.or.j.eq.nres-i+2)) &
20832 write (istat,'(e14.5)') evdwij
20836 num_cont_hb(i)=num_conti2
20838 !c write (iout,*) "Number of loop steps in EGB:",ind
20839 !cccc energy_dec=.false.
20841 end subroutine esb_gb
20842 !-------------------------------------------------------------------------------
20843 subroutine eelsbij(eesij,num_conti2)
20846 real(kind=8),dimension(3) :: ggg,gggp,gggm,dcosb,dcosg
20847 real(kind=8),dimension(3,3) :: erder,uryg,urzg,vryg,vrzg
20848 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
20849 dist_temp, dist_init,rlocshield,fracinbuf
20850 integer xshift,yshift,zshift,ilist,iresshield,num_conti2
20852 !c 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
20853 real(kind=8) scal_el /0.5d0/
20854 integer :: iteli,itelj,kkk,kkll,m,isubchap
20855 real(kind=8) :: ael6i,rrmij,rmij,r0ij,fcont,fprimcont,ees0tmp,facfac
20856 real(kind=8) :: ees,evdw1,eel_loc,aaa,bbb,ael3i,ael63i,ael32i
20857 real(kind=8) :: dx_normj,dy_normj,dz_normj,&
20858 r3ij,r6ij,cosa,cosb,cosg,fac,ev1,ev2,fac3,fac4,fac5,fac6,&
20859 el1,el2,el3,el4,eesij,ees0ij,facvdw,facel,fac1,ecosa,&
20860 ecosb,ecosg,ury,urz,vry,vrz,facr,a22der,a23der,a32der,&
20861 a33der,eel_loc_ij,cosa4,wij,cosbg1,cosbg2,ees0pij,&
20862 ees0pij1,ees0mij,ees0mij1,fac3p,ees0mijp,ees0pijp,&
20863 ecosa1,ecosb1,ecosg1,ecosa2,ecosb2,ecosg2,ecosap,ecosbp,&
20864 ecosgp,ecosam,ecosbm,ecosgm,ghalf,itypi,itypj
20868 ! print *,i,j,itypi,itypj,istype(i),istype(j),"????"
20869 ael6i=ael6_nucl(itypi,itypj)
20870 ael3i=ael3_nucl(itypi,itypj)
20871 ael63i=ael63_nucl(itypi,itypj)
20872 ael32i=ael32_nucl(itypi,itypj)
20873 !c write (iout,*) "eelecij",i,j,itype(i),itype(j),
20874 !c & ael6i,ael3i,ael63i,al32i,rij,rrij
20878 dx_normi=dc_norm(1,i+nres)
20879 dy_normi=dc_norm(2,i+nres)
20880 dz_normi=dc_norm(3,i+nres)
20881 dx_normj=dc_norm(1,j+nres)
20882 dy_normj=dc_norm(2,j+nres)
20883 dz_normj=dc_norm(3,j+nres)
20884 !c xj=c(1,j)+0.5D0*dxj-xmedi
20885 !c yj=c(2,j)+0.5D0*dyj-ymedi
20886 !c zj=c(3,j)+0.5D0*dzj-zmedi
20887 if (ipot_nucl.ne.2) then
20888 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
20889 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
20890 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
20898 fac=cosa-3.0D0*cosb*cosg
20900 fac1=3.0d0*(cosb*cosb+cosg*cosg)
20905 !c write (iout,*) "r3ij",r3ij," r6ij",r6ij," fac",fac," fac1",fac1,
20906 !c & " fac2",fac2," fac3",fac3," fac4",fac4," fac5",fac5," fac6",fac6
20907 el1=fac3*(4.0D0+facfac-fac1)
20909 el3=fac5*(2.0d0-2.0d0*facfac+fac1)
20911 eesij=el1+el2+el3+el4
20912 !C 12/26/95 - for the evaluation of multi-body H-bonding interactions
20913 ees0ij=4.0D0+facfac-fac1
20915 if (energy_dec) then
20916 if(j.eq.i+1.or.j.eq.nres-i+1.or.j.eq.nres-i.or.j.eq.nres-i+2) &
20917 write (istat,'(2a1,i4,1x,2a1,i4,4f10.5,3e12.5,$)') &
20918 sugartyp(istype(i)),restyp(itypi,2),i,sugartyp(istype(j)),&
20919 restyp(itypj,2),j,1.0d0/rij,cosa,cosb,cosg,fac*r3ij, &
20920 (4.0D0+facfac-fac1)*r6ij,(2.0d0-2.0d0*facfac+fac1)*r6ij
20921 write (iout,'(a6,2i5,e15.3)') 'ees',i,j,eesij
20925 !C Calculate contributions to the Cartesian gradient.
20927 facel=-3.0d0*rrij*(eesij+el1+el3+el4)
20933 !* Radial derivatives. First process both termini of the fragment (i,j)
20939 gelsbc(k,j)=gelsbc(k,j)+ggg(k)
20940 gelsbc(k,i)=gelsbc(k,i)-ggg(k)
20941 gelsbx(k,j)=gelsbx(k,j)+ggg(k)
20942 gelsbx(k,i)=gelsbx(k,i)-ggg(k)
20947 ecosa=2.0D0*fac3*fac1+fac4+(-4.0d0*fac5+2.0d0*fac6)*fac1
20952 ecosb=fac3*(fac1*cosg+cosb)+cosg*fac4+(cosb+2*fac1*cosg)*fac5+&
20954 ecosg=fac3*(fac1*cosb+cosg)+cosb*fac4+(cosg+2*fac1*cosb)*fac5+&
20957 dcosb(k)=rij*(dc_norm(k,i+nres)-erij(k)*cosb)
20958 dcosg(k)=rij*(dc_norm(k,j+nres)-erij(k)*cosg)
20961 ggg(k)=ecosb*dcosb(k)+ecosg*dcosg(k)
20964 gelsbx(k,i)=gelsbx(k,i)-ggg(k) &
20965 +(ecosa*(dc_norm(k,j+nres)-cosa*dc_norm(k,i+nres))&
20966 + ecosb*(erij(k)-cosb*dc_norm(k,i+nres)))*vbld_inv(i+nres)
20967 gelsbx(k,j)=gelsbx(k,j)+ggg(k) &
20968 +(ecosa*(dc_norm(k,i+nres)-cosa*dc_norm(k,j+nres))&
20969 + ecosg*(erij(k)-cosg*dc_norm(k,j+nres)))*vbld_inv(j+nres)
20970 gelsbc(k,j)=gelsbc(k,j)+ggg(k)
20971 gelsbc(k,i)=gelsbc(k,i)-ggg(k)
20973 ! IF ( (wcorr_nucl.gt.0.0d0.or.wcorr3_nucl.gt.0.0d0) .and.
20974 IF ( j.gt.i+1 .and.&
20975 num_conti.le.maxconts) THEN
20977 !C Calculate the contact function. The ith column of the array JCONT will
20978 !C contain the numbers of atoms that make contacts with the atom I (of numbers
20979 !C greater than I). The arrays FACONT and GACONT will contain the values of
20980 !C the contact function and its derivative.
20981 r0ij=2.20D0*sigma(itypi,itypj)
20982 !c write (2,*) "ij",i,j," rij",1.0d0/rij," r0ij",r0ij
20983 call gcont(rij,r0ij,1.0D0,0.2d0/r0ij,fcont,fprimcont)
20984 !c write (2,*) "fcont",fcont
20985 if (fcont.gt.0.0D0) then
20986 num_conti=num_conti+1
20987 num_conti2=num_conti2+1
20989 if (num_conti.gt.maxconts) then
20990 write (iout,*) 'WARNING - max. # of contacts exceeded;',&
20991 ' will skip next contacts for this conf.'
20993 jcont_hb(num_conti,i)=j
20994 !c write (iout,*) "num_conti",num_conti,
20995 !c & " jcont_hb",jcont_hb(num_conti,i)
20996 !C Calculate contact energies
20998 wij=cosa-3.0D0*cosb*cosg
21001 fac3=dsqrt(-ael6i)*r3ij
21002 !c write (2,*) "ael6i",ael6i," r3ij",r3ij," fac3",fac3
21003 ees0tmp=4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1
21004 if (ees0tmp.gt.0) then
21005 ees0pij=dsqrt(ees0tmp)
21009 ees0tmp=4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2
21010 if (ees0tmp.gt.0) then
21011 ees0mij=dsqrt(ees0tmp)
21015 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij)
21016 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij)
21017 !c write (iout,*) "i",i," j",j,
21018 !c & " ees0m",ees0m(num_conti,i)," ees0p",ees0p(num_conti,i)
21019 ees0pij1=fac3/ees0pij
21020 ees0mij1=fac3/ees0mij
21021 fac3p=-3.0D0*fac3*rrij
21022 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
21023 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
21024 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
21025 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
21026 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
21027 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
21028 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
21029 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
21030 ecosap=ecosa1+ecosa2
21031 ecosbp=ecosb1+ecosb2
21032 ecosgp=ecosg1+ecosg2
21033 ecosam=ecosa1-ecosa2
21034 ecosbm=ecosb1-ecosb2
21035 ecosgm=ecosg1-ecosg2
21037 facont_hb(num_conti,i)=fcont
21038 fprimcont=fprimcont/rij
21040 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
21041 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
21043 gggp(1)=gggp(1)+ees0pijp*xj
21044 gggp(2)=gggp(2)+ees0pijp*yj
21045 gggp(3)=gggp(3)+ees0pijp*zj
21046 gggm(1)=gggm(1)+ees0mijp*xj
21047 gggm(2)=gggm(2)+ees0mijp*yj
21048 gggm(3)=gggm(3)+ees0mijp*zj
21049 !C Derivatives due to the contact function
21050 gacont_hbr(1,num_conti,i)=fprimcont*xj
21051 gacont_hbr(2,num_conti,i)=fprimcont*yj
21052 gacont_hbr(3,num_conti,i)=fprimcont*zj
21055 !c Gradient of the correlation terms
21057 gacontp_hb1(k,num_conti,i)= &
21058 (ecosap*(dc_norm(k,j+nres)-cosa*dc_norm(k,i+nres)) &
21059 + ecosbp*(erij(k)-cosb*dc_norm(k,i+nres)))*vbld_inv(i+nres)
21060 gacontp_hb2(k,num_conti,i)= &
21061 (ecosap*(dc_norm(k,i+nres)-cosa*dc_norm(k,j+nres)) &
21062 + ecosgp*(erij(k)-cosg*dc_norm(k,j+nres)))*vbld_inv(j+nres)
21063 gacontp_hb3(k,num_conti,i)=gggp(k)
21064 gacontm_hb1(k,num_conti,i)= &
21065 (ecosam*(dc_norm(k,j+nres)-cosa*dc_norm(k,i+nres)) &
21066 + ecosbm*(erij(k)-cosb*dc_norm(k,i+nres)))*vbld_inv(i+nres)
21067 gacontm_hb2(k,num_conti,i)= &
21068 (ecosam*(dc_norm(k,i+nres)-cosa*dc_norm(k,j+nres))&
21069 + ecosgm*(erij(k)-cosg*dc_norm(k,j+nres)))*vbld_inv(j+nres)
21070 gacontm_hb3(k,num_conti,i)=gggm(k)
21076 end subroutine eelsbij
21077 !------------------------------------------------------------------
21078 subroutine sc_grad_nucl
21081 real(kind=8),dimension(3) :: dcosom1,dcosom2
21082 eom1=eps2der*eps2rt_om1+sigder*sigsq_om1
21083 eom2=eps2der*eps2rt_om2+sigder*sigsq_om2
21084 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12+sigder*sigsq_om12
21086 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
21087 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
21090 gg(k)=gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
21093 gvdwsbx(k,i)=gvdwsbx(k,i)-gg(k) &
21094 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))&
21095 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
21096 gvdwsbx(k,j)=gvdwsbx(k,j)+gg(k) &
21097 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
21098 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
21101 !C Calculate the components of the gradient in DC and X
21104 gvdwsbc(l,i)=gvdwsbc(l,i)-gg(l)
21105 gvdwsbc(l,j)=gvdwsbc(l,j)+gg(l)
21108 end subroutine sc_grad_nucl
21109 !-----------------------------------------------------------------------
21110 subroutine esb(esbloc)
21111 !C Calculate the local energy of a side chain and its derivatives in the
21112 !C corresponding virtual-bond valence angles THETA and the spherical angles
21113 !C ALPHA and OMEGA derived from AM1 all-atom calculations.
21114 !C added by Urszula Kozlowska. 07/11/2007
21116 real(kind=8),dimension(3):: x_prime,y_prime,z_prime
21117 real(kind=8),dimension(9):: x
21118 real(kind=8) :: sumene,dsc_i,dp2_i,xx,yy,zz,sumene1, &
21119 sumene2,sumene3,sumene4,s1,s1_6,s2,s2_6,&
21120 de_dxx,de_dyy,de_dzz,de_dt,s1_t,s1_6_t,s2_t,s2_6_t
21121 real(kind=8),dimension(3):: dXX_Ci1,dYY_Ci1,dZZ_Ci1,dXX_Ci,&
21122 dYY_Ci,dZZ_Ci,dXX_XYZ,dYY_XYZ,dZZ_XYZ,dt_dCi,dt_dCi1
21123 real(kind=8) :: esbloc,delta,cosfac2,cosfac,sinfac2,sinfac,de_dtt,&
21124 cossc,cossc1,cosfac2xx,sinfac2yy,pom1,pom
21125 integer::it,nlobit,i,j,k
21126 ! common /sccalc/ time11,time12,time112,theti,it,nlobit
21129 do i=loc_start_nucl,loc_end_nucl
21130 if (itype(i,2).eq.ntyp1_molec(2)) cycle
21131 costtab(i+1) =dcos(theta(i+1))
21132 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
21133 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
21134 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
21135 cosfac2=0.5d0/(1.0d0+costtab(i+1))
21136 cosfac=dsqrt(cosfac2)
21137 sinfac2=0.5d0/(1.0d0-costtab(i+1))
21138 sinfac=dsqrt(sinfac2)
21140 if (it.eq.10) goto 1
21143 !C Compute the axes of tghe local cartesian coordinates system; store in
21144 !c x_prime, y_prime and z_prime
21151 !C write(2,*) "dc_norm", dc_norm(1,i+nres),dc_norm(2,i+nres),
21152 !C & dc_norm(3,i+nres)
21154 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
21155 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
21158 z_prime(j) = -uz(j,i-1)
21166 xx = xx + x_prime(j)*dc_norm(j,i+nres)
21167 yy = yy + y_prime(j)*dc_norm(j,i+nres)
21168 zz = zz + z_prime(j)*dc_norm(j,i+nres)
21176 x(j) = sc_parmin_nucl(j,it)
21179 !Cc diagnostics - remove later
21180 xx1 = dcos(alph(2))
21181 yy1 = dsin(alph(2))*dcos(omeg(2))
21182 zz1 = -dsin(alph(2))*dsin(omeg(2))
21183 write(2,'(3f8.1,3f9.3,1x,3f9.3)') &
21184 alph(2)*rad2deg,omeg(2)*rad2deg,theta(3)*rad2deg,xx,yy,zz,&
21186 !C," --- ", xx_w,yy_w,zz_w
21189 sumene = enesc_nucl(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
21190 esbloc = esbloc + sumene
21191 sumene2= enesc_nucl(x,xx,yy,0.0d0,cost2tab(i+1),sint2tab(i+1))
21192 ! print *,"enecomp",sumene,sumene2
21193 ! if (energy_dec) write(iout,*) "i",i," esbloc",sumene,esbloc,xx,yy,zz
21194 ! if (energy_dec) write(iout,*) "x",(x(k),k=1,9)
21196 write (2,*) "x",(x(k),k=1,9)
21198 !C This section to check the numerical derivatives of the energy of ith side
21199 !C chain in xx, yy, zz, and theta. Use the -DDEBUG compiler option or insert
21200 !C #define DEBUG in the code to turn it on.
21202 write (2,*) "sumene =",sumene
21206 write (2,*) xx,yy,zz
21207 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
21208 de_dxx_num=(sumenep-sumene)/aincr
21210 write (2,*) "xx+ sumene from enesc=",sumenep,sumene
21213 write (2,*) xx,yy,zz
21214 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
21215 de_dyy_num=(sumenep-sumene)/aincr
21217 write (2,*) "yy+ sumene from enesc=",sumenep,sumene
21220 write (2,*) xx,yy,zz
21221 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
21222 de_dzz_num=(sumenep-sumene)/aincr
21224 write (2,*) "zz+ sumene from enesc=",sumenep,sumene
21225 costsave=cost2tab(i+1)
21226 sintsave=sint2tab(i+1)
21227 cost2tab(i+1)=dcos(0.5d0*(theta(i+1)+aincr))
21228 sint2tab(i+1)=dsin(0.5d0*(theta(i+1)+aincr))
21229 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
21230 de_dt_num=(sumenep-sumene)/aincr
21231 write (2,*) " t+ sumene from enesc=",sumenep,sumene
21232 cost2tab(i+1)=costsave
21233 sint2tab(i+1)=sintsave
21234 !C End of diagnostics section.
21237 !C Compute the gradient of esc
21239 de_dxx=x(1)+2*x(4)*xx+x(7)*zz+x(8)*yy
21240 de_dyy=x(2)+2*x(5)*yy+x(8)*xx+x(9)*zz
21241 de_dzz=x(3)+2*x(6)*zz+x(7)*xx+x(9)*yy
21244 write (2,*) "x",(x(k),k=1,9)
21245 write (2,*) "xx",xx," yy",yy," zz",zz
21246 write (2,*) "de_xx ",de_xx," de_yy ",de_yy,&
21247 " de_zz ",de_zz," de_tt ",de_tt
21248 write (2,*) "de_xx_num",de_dxx_num," de_yy_num",de_dyy_num,&
21249 " de_zz_num",de_dzz_num," de_dt_num",de_dt_num
21252 cossc=scalar(dc_norm(1,i),dc_norm(1,i+nres))
21253 cossc1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
21254 cosfac2xx=cosfac2*xx
21255 sinfac2yy=sinfac2*yy
21257 dt_dCi(k) = -(dc_norm(k,i-1)+costtab(i+1)*dc_norm(k,i))*&
21259 dt_dCi1(k)= -(dc_norm(k,i)+costtab(i+1)*dc_norm(k,i-1))*&
21261 pom=(dC_norm(k,i+nres)-cossc*dC_norm(k,i))*vbld_inv(i+1)
21262 pom1=(dC_norm(k,i+nres)-cossc1*dC_norm(k,i-1))*vbld_inv(i)
21263 !c write (iout,*) "i",i," k",k," pom",pom," pom1",pom1,
21264 !c & " dt_dCi",dt_dCi(k)," dt_dCi1",dt_dCi1(k)
21265 !c write (iout,*) "dC_norm",(dC_norm(j,i),j=1,3),
21266 !c & (dC_norm(j,i-1),j=1,3)," vbld_inv",vbld_inv(i+1),vbld_inv(i)
21267 dXX_Ci(k)=pom*cosfac-dt_dCi(k)*cosfac2xx
21268 dXX_Ci1(k)=-pom1*cosfac-dt_dCi1(k)*cosfac2xx
21269 dYY_Ci(k)=pom*sinfac+dt_dCi(k)*sinfac2yy
21270 dYY_Ci1(k)=pom1*sinfac+dt_dCi1(k)*sinfac2yy
21274 dZZ_Ci(k)=dZZ_Ci(k)-uzgrad(j,k,2,i-1)*dC_norm(j,i+nres)
21275 dZZ_Ci1(k)=dZZ_Ci1(k)-uzgrad(j,k,1,i-1)*dC_norm(j,i+nres)
21278 dXX_XYZ(k)=vbld_inv(i+nres)*(x_prime(k)-xx*dC_norm(k,i+nres))
21279 dYY_XYZ(k)=vbld_inv(i+nres)*(y_prime(k)-yy*dC_norm(k,i+nres))
21280 dZZ_XYZ(k)=vbld_inv(i+nres)*(z_prime(k)-zz*dC_norm(k,i+nres))
21282 dt_dCi(k) = -dt_dCi(k)/sinttab(i+1)
21283 dt_dCi1(k)= -dt_dCi1(k)/sinttab(i+1)
21287 dXX_Ctab(k,i)=dXX_Ci(k)
21288 dXX_C1tab(k,i)=dXX_Ci1(k)
21289 dYY_Ctab(k,i)=dYY_Ci(k)
21290 dYY_C1tab(k,i)=dYY_Ci1(k)
21291 dZZ_Ctab(k,i)=dZZ_Ci(k)
21292 dZZ_C1tab(k,i)=dZZ_Ci1(k)
21293 dXX_XYZtab(k,i)=dXX_XYZ(k)
21294 dYY_XYZtab(k,i)=dYY_XYZ(k)
21295 dZZ_XYZtab(k,i)=dZZ_XYZ(k)
21298 !c write (iout,*) "k",k," dxx_ci1",dxx_ci1(k)," dyy_ci1",
21299 !c & dyy_ci1(k)," dzz_ci1",dzz_ci1(k)
21300 !c write (iout,*) "k",k," dxx_ci",dxx_ci(k)," dyy_ci",
21301 !c & dyy_ci(k)," dzz_ci",dzz_ci(k)
21302 !c write (iout,*) "k",k," dt_dci",dt_dci(k)," dt_dci",
21304 !c write (iout,*) "k",k," dxx_XYZ",dxx_XYZ(k)," dyy_XYZ",
21305 !c & dyy_XYZ(k)," dzz_XYZ",dzz_XYZ(k)
21306 gsbloc(k,i-1)=gsbloc(k,i-1)+(de_dxx*dxx_ci1(k) &
21307 +de_dyy*dyy_ci1(k)+de_dzz*dzz_ci1(k)+de_dt*dt_dCi1(k))
21308 gsbloc(k,i)=gsbloc(k,i)+(de_dxx*dxx_Ci(k) &
21309 +de_dyy*dyy_Ci(k)+de_dzz*dzz_Ci(k)+de_dt*dt_dCi(k))
21310 gsblocx(k,i)= de_dxx*dxx_XYZ(k)&
21311 +de_dyy*dyy_XYZ(k)+de_dzz*dzz_XYZ(k)
21312 ! print *,i,de_dxx*dxx_ci1(k)+de_dyy*dyy_ci1(k),de_dzz*dzz_ci1(k)*2
21314 !c write(iout,*) "ENERGY GRAD = ", (gsbloc(k,i-1),k=1,3),
21315 !c & (gsbloc(k,i),k=1,3),(gsblocx(k,i),k=1,3)
21317 !C to check gradient call subroutine check_grad
21323 !=-------------------------------------------------------
21324 real(kind=8) function enesc_nucl(x,xx,yy,zz,cost2,sint2)
21326 real(kind=8),dimension(9):: x(9)
21327 real(kind=8) :: xx,yy,zz,cost2,sint2,sumene1,sumene2, &
21328 sumene3,sumene4,sumene,dsc_i,dp2_i,dscp1,dscp2,s1,s1_6,s2,s2_6
21330 !c write (2,*) "enesc"
21331 !c write (2,*) "x",(x(i),i=1,9)
21332 !c write(2,*)"xx",xx," yy",yy," zz",zz," cost2",cost2," sint2",sint2
21333 sumene=x(1)*xx+x(2)*yy+x(3)*zz+x(4)*xx**2 &
21334 + x(5)*yy**2+x(6)*zz**2+x(7)*xx*zz+x(8)*xx*yy &
21338 end function enesc_nucl
21339 !-----------------------------------------------------------------------------
21340 subroutine multibody_hb_nucl(ecorr,ecorr3,n_corr,n_corr1)
21343 integer,parameter :: max_cont=2000
21344 integer,parameter:: max_dim=2*(8*3+6)
21345 integer, parameter :: msglen1=max_cont*max_dim
21346 integer,parameter :: msglen2=2*msglen1
21347 integer source,CorrelType,CorrelID,Error
21348 real(kind=8) :: buffer(max_cont,max_dim)
21349 integer status(MPI_STATUS_SIZE)
21350 integer :: ierror,nbytes
21352 real(kind=8),dimension(3):: gx(3),gx1(3)
21353 real(kind=8) :: time00
21355 integer i,j,i1,j1,jj,kk,num_conti,num_conti1,nn
21356 real(kind=8) ecorr,ecorr3
21357 integer :: n_corr,n_corr1,mm,msglen
21358 !C Set lprn=.true. for debugging
21363 if(.not.allocated(zapas2)) allocate(zapas2(3,maxconts,nres,8))
21365 if (nfgtasks.le.1) goto 30
21367 write (iout,'(a)') 'Contact function values:'
21369 write (iout,'(2i3,50(1x,i2,f5.2))') &
21370 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i), &
21371 j=1,num_cont_hb(i))
21374 !C Caution! Following code assumes that electrostatic interactions concerning
21375 !C a given atom are split among at most two processors!
21385 !c write (*,*) 'MyRank',MyRank,' mm',mm
21388 !c write (*,*) 'Sending: MyRank',MyRank,' mm',mm,' ldone',ldone
21389 if (fg_rank.gt.0) then
21390 !C Send correlation contributions to the preceding processor
21392 nn=num_cont_hb(iatel_s_nucl)
21393 call pack_buffer(max_cont,max_dim,iatel_s,0,buffer)
21394 !c write (*,*) 'The BUFFER array:'
21396 !c write (*,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,30)
21398 if (ielstart_nucl(iatel_s_nucl).gt.iatel_s_nucl+ispp) then
21400 call pack_buffer(max_cont,max_dim,iatel_s+1,30,buffer)
21401 !C Clear the contacts of the atom passed to the neighboring processor
21402 nn=num_cont_hb(iatel_s_nucl+1)
21404 !c write (*,'(i2,9(3f8.3,2x))') i,(buffer(i,j+30),j=1,30)
21406 num_cont_hb(iatel_s_nucl)=0
21408 !cd write (iout,*) 'Processor ',fg_rank,MyRank,
21409 !cd & ' is sending correlation contribution to processor',fg_rank-1,
21410 !cd & ' msglen=',msglen
21411 !c write (*,*) 'Processor ',fg_rank,MyRank,
21412 !c & ' is sending correlation contribution to processor',fg_rank-1,
21413 !c & ' msglen=',msglen,' CorrelType=',CorrelType
21415 call MPI_Send(buffer,msglen,MPI_DOUBLE_PRECISION,fg_rank-1, &
21416 CorrelType,FG_COMM,IERROR)
21417 time_sendrecv=time_sendrecv+MPI_Wtime()-time00
21418 !cd write (iout,*) 'Processor ',fg_rank,
21419 !cd & ' has sent correlation contribution to processor',fg_rank-1,
21420 !cd & ' msglen=',msglen,' CorrelID=',CorrelID
21421 !c write (*,*) 'Processor ',fg_rank,
21422 !c & ' has sent correlation contribution to processor',fg_rank-1,
21423 !c & ' msglen=',msglen,' CorrelID=',CorrelID
21425 endif ! (fg_rank.gt.0)
21429 !c write (*,*) 'Receiving: MyRank',MyRank,' mm',mm,' ldone',ldone
21430 if (fg_rank.lt.nfgtasks-1) then
21431 !C Receive correlation contributions from the next processor
21433 if (ielend_nucl(iatel_e_nucl).lt.nct_molec(2)-1) msglen=msglen2
21434 !cd write (iout,*) 'Processor',fg_rank,
21435 !cd & ' is receiving correlation contribution from processor',fg_rank+1,
21436 !cd & ' msglen=',msglen,' CorrelType=',CorrelType
21437 !c write (*,*) 'Processor',fg_rank,
21438 !c &' is receiving correlation contribution from processor',fg_rank+1,
21439 !c & ' msglen=',msglen,' CorrelType=',CorrelType
21442 do while (nbytes.le.0)
21443 call MPI_Probe(fg_rank+1,CorrelType,FG_COMM,status,IERROR)
21444 call MPI_Get_count(status,MPI_DOUBLE_PRECISION,nbytes,IERROR)
21446 !c print *,'Processor',myrank,' msglen',msglen,' nbytes',nbytes
21447 call MPI_Recv(buffer,nbytes,MPI_DOUBLE_PRECISION, &
21448 fg_rank+1,CorrelType,FG_COMM,status,IERROR)
21449 time_sendrecv=time_sendrecv+MPI_Wtime()-time00
21450 !c write (*,*) 'Processor',fg_rank,
21451 !c &' has received correlation contribution from processor',fg_rank+1,
21452 !c & ' msglen=',msglen,' nbytes=',nbytes
21453 !c write (*,*) 'The received BUFFER array:'
21455 !c write (*,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,60)
21457 if (msglen.eq.msglen1) then
21458 call unpack_buffer(max_cont,max_dim,iatel_e_nucl+1,0,buffer)
21459 else if (msglen.eq.msglen2) then
21460 call unpack_buffer(max_cont,max_dim,iatel_e_nucl,0,buffer)
21461 call unpack_buffer(max_cont,max_dim,iatel_e_nucl+1,30,buffer)
21464 'ERROR!!!! message length changed while processing correlations.'
21466 'ERROR!!!! message length changed while processing correlations.'
21467 call MPI_Abort(MPI_COMM_WORLD,Error,IERROR)
21468 endif ! msglen.eq.msglen1
21469 endif ! fg_rank.lt.nfgtasks-1
21476 write (iout,'(a)') 'Contact function values:'
21477 do i=nnt_molec(2),nct_molec(2)-1
21478 write (iout,'(2i3,50(1x,i2,f5.2))') &
21479 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i), &
21480 j=1,num_cont_hb(i))
21485 !C Remove the loop below after debugging !!!
21486 ! do i=nnt_molec(2),nct_molec(2)
21488 ! gradcorr_nucl(j,i)=0.0D0
21489 ! gradxorr_nucl(j,i)=0.0D0
21490 ! gradcorr3_nucl(j,i)=0.0D0
21491 ! gradxorr3_nucl(j,i)=0.0D0
21494 ! print *,"iatsc_s_nucl,iatsc_e_nucl",iatsc_s_nucl,iatsc_e_nucl
21495 !C Calculate the local-electrostatic correlation terms
21496 do i=iatsc_s_nucl,iatsc_e_nucl
21498 num_conti=num_cont_hb(i)
21499 num_conti1=num_cont_hb(i+1)
21500 ! print *,i,num_conti,num_conti1
21505 !c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
21506 !c & ' jj=',jj,' kk=',kk
21507 if (j1.eq.j+1 .or. j1.eq.j-1) then
21509 !C Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
21510 !C The system gains extra energy.
21511 !C Tentative expression & coefficients; assumed d(stacking)=4.5 A,
21512 !C parallel dipoles of stacknig bases and sin(mui)sin(muj)/eps/d^3=0.7
21513 !C Need to implement full formulas 34 and 35 from Liwo et al., 1998.
21515 ecorr=ecorr+ehbcorr_nucl(i,j,i+1,j1,jj,kk,0.528D0,0.132D0)
21516 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
21517 'ecorrh',i,j,ehbcorr_nucl(i,j,i+1,j1,jj,kk,0.528D0,0.132D0)
21519 else if (j1.eq.j) then
21521 !C Contacts I-J and I-(J+1) occur simultaneously.
21522 !C The system loses extra energy.
21523 !C Tentative expression & c?oefficients; assumed d(stacking)=4.5 A,
21524 !C parallel dipoles of stacknig bases and sin(mui)sin(muj)/eps/d^3=0.7
21525 !C Need to implement full formulas 32 from Liwo et al., 1998.
21527 !c write (iout,*) 'ecorr3: i=',i,' j=',j,' i1=',i1,' j1=',j1,
21528 !c & ' jj=',jj,' kk=',kk
21529 ecorr3=ecorr3+ehbcorr3_nucl(i,j,i+1,j,jj,kk,0.310D0,-0.155D0)
21534 !c write (iout,*) 'ecorr3: i=',i,' j=',j,' i1=',i1,' j1=',j1,
21535 !c & ' jj=',jj,' kk=',kk
21536 if (j1.eq.j+1) then
21537 !C Contacts I-J and (I+1)-J occur simultaneously.
21538 !C The system loses extra energy.
21539 ecorr3=ecorr3+ehbcorr3_nucl(i,j,i,j+1,jj,kk,0.310D0,-0.155D0)
21545 end subroutine multibody_hb_nucl
21546 !-----------------------------------------------------------
21547 real(kind=8) function ehbcorr_nucl(i,j,k,l,jj,kk,coeffp,coeffm)
21548 ! implicit real*8 (a-h,o-z)
21549 ! include 'DIMENSIONS'
21550 ! include 'COMMON.IOUNITS'
21551 ! include 'COMMON.DERIV'
21552 ! include 'COMMON.INTERACT'
21553 ! include 'COMMON.CONTACTS'
21554 real(kind=8),dimension(3) :: gx,gx1
21556 !el local variables
21557 integer :: i,j,k,l,jj,kk,ll,ilist,m, iresshield
21558 real(kind=8) :: coeffp,coeffm,eij,ekl,ees0pij,ees0pkl,ees0mij,&
21559 ees0mkl,ees,coeffpees0pij,coeffmees0mij,&
21560 coeffpees0pkl,coeffmees0mkl,gradlongij,gradlongkl, &
21564 eij=facont_hb(jj,i)
21565 ekl=facont_hb(kk,k)
21566 ees0pij=ees0p(jj,i)
21567 ees0pkl=ees0p(kk,k)
21568 ees0mij=ees0m(jj,i)
21569 ees0mkl=ees0m(kk,k)
21571 ees=-(coeffp*ees0pij*ees0pkl+coeffm*ees0mij*ees0mkl)
21572 ! print *,"ehbcorr_nucl",ekont,ees
21573 !cd ees=-(coeffp*ees0pkl+coeffm*ees0mkl)
21574 !C Following 4 lines for diagnostics.
21579 !cd write (iout,*)'Contacts have occurred for nucleic bases',
21580 !cd & i,j,' fcont:',eij,' eij',' eesij',ees0pij,ees0mij,' and ',k,l
21581 !cd & ,' fcont ',ekl,' eeskl',ees0pkl,ees0mkl,' ees=',ees
21582 !C Calculate the multi-body contribution to energy.
21583 ! ecorr_nucl=ecorr_nucl+ekont*ees
21584 !C Calculate multi-body contributions to the gradient.
21585 coeffpees0pij=coeffp*ees0pij
21586 coeffmees0mij=coeffm*ees0mij
21587 coeffpees0pkl=coeffp*ees0pkl
21588 coeffmees0mkl=coeffm*ees0mkl
21590 gradxorr_nucl(ll,i)=gradxorr_nucl(ll,i) &
21591 -ekont*(coeffpees0pkl*gacontp_hb1(ll,jj,i)+&
21592 coeffmees0mkl*gacontm_hb1(ll,jj,i))
21593 gradxorr_nucl(ll,j)=gradxorr_nucl(ll,j) &
21594 -ekont*(coeffpees0pkl*gacontp_hb2(ll,jj,i)+&
21595 coeffmees0mkl*gacontm_hb2(ll,jj,i))
21596 gradxorr_nucl(ll,k)=gradxorr_nucl(ll,k) &
21597 -ekont*(coeffpees0pij*gacontp_hb1(ll,kk,k)+&
21598 coeffmees0mij*gacontm_hb1(ll,kk,k))
21599 gradxorr_nucl(ll,l)=gradxorr_nucl(ll,l) &
21600 -ekont*(coeffpees0pij*gacontp_hb2(ll,kk,k)+ &
21601 coeffmees0mij*gacontm_hb2(ll,kk,k))
21602 gradlongij=ees*ekl*gacont_hbr(ll,jj,i)- &
21603 ekont*(coeffpees0pkl*gacontp_hb3(ll,jj,i)+ &
21604 coeffmees0mkl*gacontm_hb3(ll,jj,i))
21605 gradcorr_nucl(ll,j)=gradcorr_nucl(ll,j)+gradlongij
21606 gradcorr_nucl(ll,i)=gradcorr_nucl(ll,i)-gradlongij
21607 gradlongkl=ees*eij*gacont_hbr(ll,kk,k)- &
21608 ekont*(coeffpees0pij*gacontp_hb3(ll,kk,k)+ &
21609 coeffmees0mij*gacontm_hb3(ll,kk,k))
21610 gradcorr_nucl(ll,l)=gradcorr_nucl(ll,l)+gradlongkl
21611 gradcorr_nucl(ll,k)=gradcorr_nucl(ll,k)-gradlongkl
21612 gradxorr_nucl(ll,i)=gradxorr_nucl(ll,i)-gradlongij
21613 gradxorr_nucl(ll,j)=gradxorr_nucl(ll,j)+gradlongij
21614 gradxorr_nucl(ll,k)=gradxorr_nucl(ll,k)-gradlongkl
21615 gradxorr_nucl(ll,l)=gradxorr_nucl(ll,l)+gradlongkl
21617 ehbcorr_nucl=ekont*ees
21619 end function ehbcorr_nucl
21620 !-------------------------------------------------------------------------
21622 real(kind=8) function ehbcorr3_nucl(i,j,k,l,jj,kk,coeffp,coeffm)
21623 ! implicit real*8 (a-h,o-z)
21624 ! include 'DIMENSIONS'
21625 ! include 'COMMON.IOUNITS'
21626 ! include 'COMMON.DERIV'
21627 ! include 'COMMON.INTERACT'
21628 ! include 'COMMON.CONTACTS'
21629 real(kind=8),dimension(3) :: gx,gx1
21631 !el local variables
21632 integer :: i,j,k,l,jj,kk,ll,ilist,m, iresshield
21633 real(kind=8) :: coeffp,coeffm,eij,ekl,ees0pij,ees0pkl,ees0mij,&
21634 ees0mkl,ees,coeffpees0pij,coeffmees0mij,&
21635 coeffpees0pkl,coeffmees0mkl,gradlongij,gradlongkl, &
21639 eij=facont_hb(jj,i)
21640 ekl=facont_hb(kk,k)
21641 ees0pij=ees0p(jj,i)
21642 ees0pkl=ees0p(kk,k)
21643 ees0mij=ees0m(jj,i)
21644 ees0mkl=ees0m(kk,k)
21646 ees=-(coeffp*ees0pij*ees0pkl+coeffm*ees0mij*ees0mkl)
21647 !cd ees=-(coeffp*ees0pkl+coeffm*ees0mkl)
21648 !C Following 4 lines for diagnostics.
21653 !cd write (iout,*)'Contacts have occurred for nucleic bases',
21654 !cd & i,j,' fcont:',eij,' eij',' eesij',ees0pij,ees0mij,' and ',k,l
21655 !cd & ,' fcont ',ekl,' eeskl',ees0pkl,ees0mkl,' ees=',ees
21656 !C Calculate the multi-body contribution to energy.
21657 ! ecorr=ecorr+ekont*ees
21658 !C Calculate multi-body contributions to the gradient.
21659 coeffpees0pij=coeffp*ees0pij
21660 coeffmees0mij=coeffm*ees0mij
21661 coeffpees0pkl=coeffp*ees0pkl
21662 coeffmees0mkl=coeffm*ees0mkl
21664 gradxorr3_nucl(ll,i)=gradxorr3_nucl(ll,i) &
21665 -ekont*(coeffpees0pkl*gacontp_hb1(ll,jj,i)+&
21666 coeffmees0mkl*gacontm_hb1(ll,jj,i))
21667 gradxorr3_nucl(ll,j)=gradxorr3_nucl(ll,j) &
21668 -ekont*(coeffpees0pkl*gacontp_hb2(ll,jj,i)+ &
21669 coeffmees0mkl*gacontm_hb2(ll,jj,i))
21670 gradxorr3_nucl(ll,k)=gradxorr3_nucl(ll,k) &
21671 -ekont*(coeffpees0pij*gacontp_hb1(ll,kk,k)+ &
21672 coeffmees0mij*gacontm_hb1(ll,kk,k))
21673 gradxorr3_nucl(ll,l)=gradxorr3_nucl(ll,l) &
21674 -ekont*(coeffpees0pij*gacontp_hb2(ll,kk,k)+ &
21675 coeffmees0mij*gacontm_hb2(ll,kk,k))
21676 gradlongij=ees*ekl*gacont_hbr(ll,jj,i)- &
21677 ekont*(coeffpees0pkl*gacontp_hb3(ll,jj,i)+ &
21678 coeffmees0mkl*gacontm_hb3(ll,jj,i))
21679 gradcorr3_nucl(ll,j)=gradcorr3_nucl(ll,j)+gradlongij
21680 gradcorr3_nucl(ll,i)=gradcorr3_nucl(ll,i)-gradlongij
21681 gradlongkl=ees*eij*gacont_hbr(ll,kk,k)- &
21682 ekont*(coeffpees0pij*gacontp_hb3(ll,kk,k)+ &
21683 coeffmees0mij*gacontm_hb3(ll,kk,k))
21684 gradcorr3_nucl(ll,l)=gradcorr3_nucl(ll,l)+gradlongkl
21685 gradcorr3_nucl(ll,k)=gradcorr3_nucl(ll,k)-gradlongkl
21686 gradxorr3_nucl(ll,i)=gradxorr3_nucl(ll,i)-gradlongij
21687 gradxorr3_nucl(ll,j)=gradxorr3_nucl(ll,j)+gradlongij
21688 gradxorr3_nucl(ll,k)=gradxorr3_nucl(ll,k)-gradlongkl
21689 gradxorr3_nucl(ll,l)=gradxorr3_nucl(ll,l)+gradlongkl
21691 ehbcorr3_nucl=ekont*ees
21693 end function ehbcorr3_nucl
21695 subroutine pack_buffer(dimen1,dimen2,atom,indx,buffer)
21696 integer dimen1,dimen2,atom,indx,numcont,i,ii,k,j,num_kont,num_kont_old
21697 real(kind=8):: buffer(dimen1,dimen2)
21698 num_kont=num_cont_hb(atom)
21702 buffer(i,indx+(k-1)*3+j)=zapas2(j,i,atom,k)
21705 buffer(i,indx+25)=facont_hb(i,atom)
21706 buffer(i,indx+26)=ees0p(i,atom)
21707 buffer(i,indx+27)=ees0m(i,atom)
21708 buffer(i,indx+28)=d_cont(i,atom)
21709 buffer(i,indx+29)=dfloat(jcont_hb(i,atom))
21711 buffer(1,indx+30)=dfloat(num_kont)
21713 end subroutine pack_buffer
21714 !c------------------------------------------------------------------------------
21715 subroutine unpack_buffer(dimen1,dimen2,atom,indx,buffer)
21716 integer dimen1,dimen2,atom,indx,numcont,i,ii,k,j,num_kont,num_kont_old
21717 real(kind=8):: buffer(dimen1,dimen2)
21718 ! double precision zapas
21719 ! common /contacts_hb/ zapas(3,maxconts,maxres,8),
21720 ! & facont_hb(maxconts,maxres),ees0p(maxconts,maxres),
21721 ! & ees0m(maxconts,maxres),d_cont(maxconts,maxres),
21722 ! & num_cont_hb(maxres),jcont_hb(maxconts,maxres)
21723 num_kont=buffer(1,indx+30)
21724 num_kont_old=num_cont_hb(atom)
21725 num_cont_hb(atom)=num_kont+num_kont_old
21730 zapas2(j,ii,atom,k)=buffer(i,indx+(k-1)*3+j)
21733 facont_hb(ii,atom)=buffer(i,indx+25)
21734 ees0p(ii,atom)=buffer(i,indx+26)
21735 ees0m(ii,atom)=buffer(i,indx+27)
21736 d_cont(i,atom)=buffer(i,indx+28)
21737 jcont_hb(ii,atom)=buffer(i,indx+29)
21740 end subroutine unpack_buffer
21741 !c------------------------------------------------------------------------------
21743 subroutine ecatcat(ecationcation)
21744 integer :: i,j,itmp,xshift,yshift,zshift,subchap,k
21745 real(kind=8) :: xi,yi,zi,xj,yj,zj,ract,rcat0,epscalc,r06,r012,&
21746 r7,r4,ecationcation,k0,rcal
21747 real(kind=8) xj_temp,yj_temp,zj_temp,xj_safe,yj_safe,zj_safe, &
21748 dist_init,dist_temp,Evan1cat,Evan2cat,Eeleccat
21749 real(kind=8),dimension(3) ::dEvan1Cmcat,dEvan2Cmcat,dEeleccat,&
21752 ecationcation=0.0d0
21753 if (nres_molec(5).eq.0) return
21758 k0 = 332.0*(2.0*2.0)/80.0
21761 itmp=itmp+nres_molec(i)
21763 do i=itmp+1,itmp+nres_molec(5)-1
21768 xi=mod(xi,boxxsize)
21769 if (xi.lt.0) xi=xi+boxxsize
21770 yi=mod(yi,boxysize)
21771 if (yi.lt.0) yi=yi+boxysize
21772 zi=mod(zi,boxzsize)
21773 if (zi.lt.0) zi=zi+boxzsize
21775 do j=i+1,itmp+nres_molec(5)
21776 ! print *,i,j,'catcat'
21780 xj=dmod(xj,boxxsize)
21781 if (xj.lt.0) xj=xj+boxxsize
21782 yj=dmod(yj,boxysize)
21783 if (yj.lt.0) yj=yj+boxysize
21784 zj=dmod(zj,boxzsize)
21785 if (zj.lt.0) zj=zj+boxzsize
21786 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
21794 xj=xj_safe+xshift*boxxsize
21795 yj=yj_safe+yshift*boxysize
21796 zj=zj_safe+zshift*boxzsize
21797 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
21798 if(dist_temp.lt.dist_init) then
21799 dist_init=dist_temp
21808 if (subchap.eq.1) then
21817 rcal =xj**2+yj**2+zj**2
21823 ! k0 = 332*(2*2)/80
21824 Evan1cat=epscalc*(r012/rcal**6)
21825 Evan2cat=epscalc*2*(r06/rcal**3)
21833 dEvan1Cmcat(k)=-12*r(k)*epscalc*r012/r7
21834 dEvan2Cmcat(k)=-12*r(k)*epscalc*r06/r4
21835 dEeleccat(k)=-k0*r(k)/ract**3
21838 gg(k) = dEvan1Cmcat(k)+dEvan2Cmcat(k)+dEeleccat(k)
21839 gradcatcat(k,i)=gradcatcat(k,i)-gg(k)
21840 gradcatcat(k,j)=gradcatcat(k,j)+gg(k)
21843 ecationcation=ecationcation+Evan1cat+Evan2cat+Eeleccat
21847 end subroutine ecatcat
21848 !---------------------------------------------------------------------------
21849 subroutine ecat_prot(ecation_prot)
21850 integer i,j,k,subchap,itmp,inum
21851 real(kind=8) :: xi,yi,zi,xj,yj,zj,ract,rcat0,epscalc,r06,r012,&
21852 r7,r4,ecationcation
21853 real(kind=8) xj_temp,yj_temp,zj_temp,xj_safe,yj_safe,zj_safe, &
21854 dist_init,dist_temp,ecation_prot,rcal,rocal, &
21855 Evan1,Evan2,EC,cm1mag,DASGL,delta,r0p,Epepcat, &
21856 catl,cml,calpl, Etotal_p, Etotal_m,rtab,wdip,wmodquad,wquad1, &
21857 wquad2,wvan1,E1,E2,wconst,wvan2,rcpm,dcmag,sin2thet,sinthet, &
21858 costhet,v1m,v2m,wh2o,wc,rsecp,Ir,Irsecp,Irthrp,Irfourp,Irfiftp,&
21859 Irsistp,Irseven,Irtwelv,Irthir,dE1dr,dE2dr,dEdcos,wquad2p,opt, &
21860 rs,rthrp,rfourp,rsixp,reight,Irsixp,Ireight,Irtw,Irfourt, &
21861 opt1,opt2,opt3,opt4,opt5,opt6,opt7,opt8,opt9,opt10,opt11,opt12,&
21862 opt13,opt14,opt15,opt16,opt17,opt18,opt19, &
21863 Equad1,Equad2,dscmag,v1dpv2,dscmag3,constA,constB,Edip
21864 real(kind=8),dimension(3) ::dEvan1Cmcat,dEvan2Cmcat,dEeleccat,&
21865 gg,r,EtotalCat,dEtotalCm,dEtotalCalp,dEvan1Cm,dEvan2Cm, &
21866 dEtotalpep,dEtotalcat_num,dEddci,dEtotalcm_num,dEtotalcalp_num, &
21867 tab1,tab2,tab3,diff,cm1,sc,p,tcat,talp,cm,drcp,drcp_norm,vcat, &
21868 v1,v2,v3,myd_norm,dx,vcm,valpha,drdpep,dcosdpep,dcosddci,dEdpep,&
21869 dEcCat,dEdipCm,dEdipCalp,dEquad1Cat,dEquad1Cm,dEquad1Calp, &
21870 dEquad2Cat,dEquad2Cm,dEquad2Calpd,Evan1Cat,dEvan1Calp,dEvan2Cat,&
21871 dEvan2Calp,dEtotalCat,dscvec,dEcCm,dEcCalp,dEdipCat,dEquad2Calp,&
21873 real(kind=8),dimension(6) :: vcatprm
21875 ! first lets calculate interaction with peptide groups
21876 if (nres_molec(5).eq.0) return
21878 wdip =1.092777950857032D2
21880 wmodquad=-2.174122713004870D4
21881 wmodquad=wmodquad/wconst
21882 wquad1 = 3.901232068562804D1
21883 wquad1=wquad1/wconst
21885 wquad2=wquad2/wconst
21890 itmp=itmp+nres_molec(i)
21892 ! do i=1,nres_molec(1)-1 ! loop over all peptide groups needs parralelization
21893 do i=ibond_start,ibond_end
21895 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1)) cycle ! leave dummy atoms
21896 xi=0.5d0*(c(1,i)+c(1,i+1))
21897 yi=0.5d0*(c(2,i)+c(2,i+1))
21898 zi=0.5d0*(c(3,i)+c(3,i+1))
21899 xi=mod(xi,boxxsize)
21900 if (xi.lt.0) xi=xi+boxxsize
21901 yi=mod(yi,boxysize)
21902 if (yi.lt.0) yi=yi+boxysize
21903 zi=mod(zi,boxzsize)
21904 if (zi.lt.0) zi=zi+boxzsize
21906 do j=itmp+1,itmp+nres_molec(5)
21910 xj=dmod(xj,boxxsize)
21911 if (xj.lt.0) xj=xj+boxxsize
21912 yj=dmod(yj,boxysize)
21913 if (yj.lt.0) yj=yj+boxysize
21914 zj=dmod(zj,boxzsize)
21915 if (zj.lt.0) zj=zj+boxzsize
21916 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
21924 xj=xj_safe+xshift*boxxsize
21925 yj=yj_safe+yshift*boxysize
21926 zj=zj_safe+zshift*boxzsize
21927 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
21928 if(dist_temp.lt.dist_init) then
21929 dist_init=dist_temp
21938 if (subchap.eq.1) then
21949 rcpm = sqrt(xj**2+yj**2+zj**2)
21950 drcp_norm(1)=xj/rcpm
21951 drcp_norm(2)=yj/rcpm
21952 drcp_norm(3)=zj/rcpm
21955 dcmag=dcmag+dc(k,i)**2
21959 myd_norm(k)=dc(k,i)/dcmag
21961 costhet=drcp_norm(1)*myd_norm(1)+drcp_norm(2)*myd_norm(2)+&
21962 drcp_norm(3)*myd_norm(3)
21965 Irsecp = 1.0d0/rsecp
21966 Irthrp = Irsecp/rcpm
21967 Irfourp = Irthrp/rcpm
21968 Irfiftp = Irfourp/rcpm
21969 Irsistp=Irfiftp/rcpm
21970 Irseven=Irsistp/rcpm
21971 Irtwelv=Irsistp*Irsistp
21972 Irthir=Irtwelv/rcpm
21973 sin2thet = (1-costhet*costhet)
21974 sinthet=sqrt(sin2thet)
21975 E1 = wdip*Irsecp*costhet+(wmodquad*Irfourp+wquad1*Irthrp)&
21977 E2 = -wquad1*Irthrp*wquad2+wvan1*(wvan2**12*Irtwelv-&
21978 2*wvan2**6*Irsistp)
21979 ecation_prot = ecation_prot+E1+E2
21980 dE1dr = -2*costhet*wdip*Irthrp-&
21981 (4*wmodquad*Irfiftp+3*wquad1*Irfourp)*sin2thet
21982 dE2dr = 3*wquad1*wquad2*Irfourp- &
21983 12*wvan1*wvan2**6*(wvan2**6*Irthir-Irseven)
21984 dEdcos = wdip*Irsecp-2*(wmodquad*Irfourp+wquad1*Irthrp)*costhet
21986 drdpep(k) = -drcp_norm(k)
21987 dcosdpep(k) = Ir*(costhet*drcp_norm(k)-myd_norm(k))
21988 dcosddci(k) = drcp_norm(k)/dcmag-costhet*myd_norm(k)/dcmag
21989 dEdpep(k) = (dE1dr+dE2dr)*drdpep(k)+dEdcos*dcosdpep(k)
21990 dEddci(k) = dEdcos*dcosddci(k)
21993 gradpepcat(k,i)=gradpepcat(k,i)+0.5D0*dEdpep(k)-dEddci(k)
21994 gradpepcat(k,i+1)=gradpepcat(k,i+1)+0.5D0*dEdpep(k)+dEddci(k)
21995 gradpepcat(k,j)=gradpepcat(k,j)-dEdpep(k)
21999 !------------------------------------------sidechains
22000 ! do i=1,nres_molec(1)
22001 do i=ibond_start,ibond_end
22002 if ((itype(i,1).eq.ntyp1)) cycle ! leave dummy atoms
22004 ! print *,i,ecation_prot
22008 xi=mod(xi,boxxsize)
22009 if (xi.lt.0) xi=xi+boxxsize
22010 yi=mod(yi,boxysize)
22011 if (yi.lt.0) yi=yi+boxysize
22012 zi=mod(zi,boxzsize)
22013 if (zi.lt.0) zi=zi+boxzsize
22015 cm1(k)=dc(k,i+nres)
22017 cm1mag=sqrt(cm1(1)**2+cm1(2)**2+cm1(3)**2)
22018 do j=itmp+1,itmp+nres_molec(5)
22022 xj=dmod(xj,boxxsize)
22023 if (xj.lt.0) xj=xj+boxxsize
22024 yj=dmod(yj,boxysize)
22025 if (yj.lt.0) yj=yj+boxysize
22026 zj=dmod(zj,boxzsize)
22027 if (zj.lt.0) zj=zj+boxzsize
22028 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
22036 xj=xj_safe+xshift*boxxsize
22037 yj=yj_safe+yshift*boxysize
22038 zj=zj_safe+zshift*boxzsize
22039 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
22040 if(dist_temp.lt.dist_init) then
22041 dist_init=dist_temp
22050 if (subchap.eq.1) then
22061 if(itype(i,1).eq.15.or.itype(i,1).eq.16) then
22062 if(itype(i,1).eq.16) then
22068 vcatprm(k)=catprm(k,inum)
22070 dASGL=catprm(7,inum)
22072 vcm(k)=(cm1(k)/cm1mag)*dASGL+c(k,i+nres)
22077 dx(k) = vcat(k)-vcm(k)
22080 v1(k)=(vcm(k)-valpha(k))
22081 v2(k)=(vcat(k)-valpha(k))
22083 v1m = sqrt(v1(1)**2+v1(2)**2+v1(3)**2)
22084 v2m = sqrt(v2(1)**2+v2(2)**2+v2(3)**2)
22085 v1dpv2 = v1(1)*v2(1)+v1(2)*v2(2)+v1(3)*v2(3)
22087 ! The weights of the energy function calculated from
22088 !The quantum mechanical GAMESS simulations of calcium with ASP/GLU
22096 wquad2 = vcatprm(4)
22101 opt = dx(1)**2+dx(2)**2
22102 rsecp = opt+dx(3)**2
22106 rsixp = rfourp*rsecp
22111 Irfourp = Irthrp/rs
22117 opt1 = (4*rs*dx(3)*wdip)
22118 opt2 = 6*rsecp*wquad1*opt
22119 opt3 = wquad1*wquad2p*Irsixp
22120 opt4 = (wvan1*wvan2**12)
22121 opt5 = opt4*12*Irfourt
22122 opt6 = 2*wvan1*wvan2**6
22123 opt7 = 6*opt6*Ireight
22126 opt11 = (rsecp*v2m)**2
22127 opt12 = (rsecp*v1m)**2
22128 opt14 = (v1m*v2m*rsecp)**2
22129 opt15 = -wquad1/v2m**2
22130 opt16 = (rthrp*(v1m*v2m)**2)**2
22131 opt17 = (v1m**2*rthrp)**2
22132 opt18 = -wquad1/rthrp
22133 opt19 = (v1m**2*v2m**2)**2
22136 dEcCat(k) = -(dx(k)*wc)*Irthrp
22137 dEcCm(k)=(dx(k)*wc)*Irthrp
22140 Edip=opt8*(v1dpv2)/(rsecp*v2m)
22142 dEdipCat(k)=opt8*(v1(k)*rsecp*v2m-((v2(k)/v2m &
22143 *rsecp+2*dx(k)*v2m)*v1dpv2))/opt11
22144 dEdipCm(k)=opt10*(v2(k)*rsecp*v1m-((v1(k)/v1m &
22145 *rsecp-2*dx(k)*v1m)*v1dpv2))/opt12
22146 dEdipCalp(k)=wdip*((-v1(k)-v2(k))*rsecp*v1m &
22147 *v2m-(-v1(k)/v1m*v2m*rsecp-v2(k)/v2m*v1m*rsecp) &
22150 Equad1=-wquad1*v1dpv2**2/(rthrp*(v1m*v2m)**2)
22152 dEquad1Cat(k)=-wquad1*(2*v1(k)*v1dpv2*(rthrp* &
22153 (v1m*v2m)**2)-(3*dx(k)*rs*(v1m*v2m)**2+2*v1m*2* &
22154 v2(k)*1/2*1/v2m*v1m*v2m*rthrp)*v1dpv2**2)/opt16
22155 dEquad1Cm(k)=-wquad1*(2*v2(k)*v1dpv2*(rthrp* &
22156 (v1m*v2m)**2)-(-3*dx(k)*rs*(v1m*v2m)**2+2*v2m*2* &
22157 v1(k)*1/2*1/v1m*v2m*v1m*rthrp)*v1dpv2**2)/opt16
22158 dEquad1Calp(k)=opt18*(2*(-v1(k)-v2(k))*v1dpv2* &
22159 v1m**2*v2m**2-(-2*v1(k)*v2m**2-2*v2(k)*v1m**2)* &
22162 Equad2=wquad1*wquad2p*Irthrp
22164 dEquad2Cat(k)=-3*dx(k)*rs*opt3
22165 dEquad2Cm(k)=3*dx(k)*rs*opt3
22166 dEquad2Calp(k)=0.0d0
22170 dEvan1Cat(k)=-dx(k)*opt5
22171 dEvan1Cm(k)=dx(k)*opt5
22172 dEvan1Calp(k)=0.0d0
22176 dEvan2Cat(k)=dx(k)*opt7
22177 dEvan2Cm(k)=-dx(k)*opt7
22178 dEvan2Calp(k)=0.0d0
22180 ecation_prot=ecation_prot+Ec+Edip+Equad1+Equad2+Evan1+Evan2
22181 ! print *,ecation_prot,Ec+Edip+Equad1+Equad2+Evan1+Evan2
22184 dEtotalCat(k)=dEcCat(k)+dEdipCat(k)+dEquad1Cat(k)+ &
22185 dEquad2Cat(k)+dEvan1Cat(k)+dEvan2Cat(k)
22186 !c write(*,*) 'dEtotalCat inside', (dEtotalCat(l),l=1,3)
22187 dEtotalCm(k)=dEcCm(k)+dEdipCm(k)+dEquad1Cm(k)+ &
22188 dEquad2Cm(k)+dEvan1Cm(k)+dEvan2Cm(k)
22189 dEtotalCalp(k)=dEcCalp(k)+dEdipCalp(k)+dEquad1Calp(k) &
22190 +dEquad2Calp(k)+dEvan1Calp(k)+dEvan2Calp(k)
22194 dscvec(k) = dc(k,i+nres)
22195 dscmag = dscmag+dscvec(k)*dscvec(k)
22198 dscmag = sqrt(dscmag)
22199 dscmag3 = dscmag3*dscmag
22200 constA = 1.0d0+dASGL/dscmag
22203 constB = constB+dscvec(k)*dEtotalCm(k)
22205 constB = constB*dASGL/dscmag3
22207 gg(k) = dEtotalCm(k)+dEtotalCalp(k)
22208 gradpepcatx(k,i)=gradpepcatx(k,i)+ &
22209 constA*dEtotalCm(k)-constB*dscvec(k)
22210 ! print *,j,constA,dEtotalCm(k),constB,dscvec(k)
22211 gradpepcat(k,i)=gradpepcat(k,i)+gg(k)
22212 gradpepcat(k,j)=gradpepcat(k,j)+dEtotalCat(k)
22214 else if (itype(i,1).eq.13.or.itype(i,1).eq.14) then
22215 if(itype(i,1).eq.14) then
22221 vcatprm(k)=catprm(k,inum)
22223 dASGL=catprm(7,inum)
22225 vcm(k)=(cm1(k)/cm1mag)*dASGL+c(k,i+nres)
22231 dx(k) = vcat(k)-vcm(k)
22234 v1(k)=(vcm(k)-valpha(k))
22235 v2(k)=(vcat(k)-valpha(k))
22237 v1m = sqrt(v1(1)**2+v1(2)**2+v1(3)**2)
22238 v2m = sqrt(v2(1)**2+v2(2)**2+v2(3)**2)
22239 v1dpv2 = v1(1)*v2(1)+v1(2)*v2(2)+v1(3)*v2(3)
22240 ! The weights of the energy function calculated from
22241 !The quantum mechanical GAMESS simulations of ASN/GLN with calcium
22247 wquad2 = vcatprm(4)
22252 opt = dx(1)**2+dx(2)**2
22253 rsecp = opt+dx(3)**2
22257 rsixp = rfourp*rsecp
22262 Irfourp = Irthrp/rs
22268 opt1 = (4*rs*dx(3)*wdip)
22269 opt2 = 6*rsecp*wquad1*opt
22270 opt3 = wquad1*wquad2p*Irsixp
22271 opt4 = (wvan1*wvan2**12)
22272 opt5 = opt4*12*Irfourt
22273 opt6 = 2*wvan1*wvan2**6
22274 opt7 = 6*opt6*Ireight
22277 opt11 = (rsecp*v2m)**2
22278 opt12 = (rsecp*v1m)**2
22279 opt14 = (v1m*v2m*rsecp)**2
22280 opt15 = -wquad1/v2m**2
22281 opt16 = (rthrp*(v1m*v2m)**2)**2
22282 opt17 = (v1m**2*rthrp)**2
22283 opt18 = -wquad1/rthrp
22284 opt19 = (v1m**2*v2m**2)**2
22285 Edip=opt8*(v1dpv2)/(rsecp*v2m)
22287 dEdipCat(k)=opt8*(v1(k)*rsecp*v2m-((v2(k)/v2m&
22288 *rsecp+2*dx(k)*v2m)*v1dpv2))/opt11
22289 dEdipCm(k)=opt10*(v2(k)*rsecp*v1m-((v1(k)/v1m&
22290 *rsecp-2*dx(k)*v1m)*v1dpv2))/opt12
22291 dEdipCalp(k)=wdip*((-v1(k)-v2(k))*rsecp*v1m&
22292 *v2m-(-v1(k)/v1m*v2m*rsecp-v2(k)/v2m*v1m*rsecp)&
22295 Equad1=-wquad1*v1dpv2**2/(rthrp*(v1m*v2m)**2)
22297 dEquad1Cat(k)=-wquad1*(2*v1(k)*v1dpv2*(rthrp*&
22298 (v1m*v2m)**2)-(3*dx(k)*rs*(v1m*v2m)**2+2*v1m*2*&
22299 v2(k)*1/2*1/v2m*v1m*v2m*rthrp)*v1dpv2**2)/opt16
22300 dEquad1Cm(k)=-wquad1*(2*v2(k)*v1dpv2*(rthrp*&
22301 (v1m*v2m)**2)-(-3*dx(k)*rs*(v1m*v2m)**2+2*v2m*2*&
22302 v1(k)*1/2*1/v1m*v2m*v1m*rthrp)*v1dpv2**2)/opt16
22303 dEquad1Calp(k)=opt18*(2*(-v1(k)-v2(k))*v1dpv2* &
22304 v1m**2*v2m**2-(-2*v1(k)*v2m**2-2*v2(k)*v1m**2)*&
22307 Equad2=wquad1*wquad2p*Irthrp
22309 dEquad2Cat(k)=-3*dx(k)*rs*opt3
22310 dEquad2Cm(k)=3*dx(k)*rs*opt3
22311 dEquad2Calp(k)=0.0d0
22315 dEvan1Cat(k)=-dx(k)*opt5
22316 dEvan1Cm(k)=dx(k)*opt5
22317 dEvan1Calp(k)=0.0d0
22321 dEvan2Cat(k)=dx(k)*opt7
22322 dEvan2Cm(k)=-dx(k)*opt7
22323 dEvan2Calp(k)=0.0d0
22325 ecation_prot = ecation_prot+Edip+Equad1+Equad2+Evan1+Evan2
22327 dEtotalCat(k)=dEdipCat(k)+dEquad1Cat(k)+ &
22328 dEquad2Cat(k)+dEvan1Cat(k)+dEvan2Cat(k)
22329 dEtotalCm(k)=dEdipCm(k)+dEquad1Cm(k)+ &
22330 dEquad2Cm(k)+dEvan1Cm(k)+dEvan2Cm(k)
22331 dEtotalCalp(k)=dEdipCalp(k)+dEquad1Calp(k) &
22332 +dEquad2Calp(k)+dEvan1Calp(k)+dEvan2Calp(k)
22336 dscvec(k) = c(k,i+nres)-c(k,i)
22337 dscmag = dscmag+dscvec(k)*dscvec(k)
22340 dscmag = sqrt(dscmag)
22341 dscmag3 = dscmag3*dscmag
22342 constA = 1+dASGL/dscmag
22345 constB = constB+dscvec(k)*dEtotalCm(k)
22347 constB = constB*dASGL/dscmag3
22349 gg(k) = dEtotalCm(k)+dEtotalCalp(k)
22350 gradpepcatx(k,i)=gradpepcatx(k,i)+ &
22351 constA*dEtotalCm(k)-constB*dscvec(k)
22352 gradpepcat(k,i)=gradpepcat(k,i)+gg(k)
22353 gradpepcat(k,j)=gradpepcat(k,j)+dEtotalCat(k)
22358 r(k) = c(k,j)-c(k,i+nres)
22359 rcal = rcal+r(k)*r(k)
22364 r0p=0.5*(rocal+sig0(itype(i,1)))
22367 Evan1=epscalc*(r012/rcal**6)
22368 Evan2=epscalc*2*(r06/rcal**3)
22372 dEvan1Cm(k) = 12*r(k)*epscalc*r012/r7
22373 dEvan2Cm(k) = 12*r(k)*epscalc*r06/r4
22376 dEtotalCm(k)=dEvan1Cm(k)+dEvan2Cm(k)
22378 ecation_prot = ecation_prot+ Evan1+Evan2
22380 gradpepcatx(k,i)=gradpepcatx(k,i)+ &
22382 gradpepcat(k,i)=gradpepcat(k,i)+dEtotalCm(k)
22383 gradpepcat(k,j)=gradpepcat(k,j)-dEtotalCm(k)
22385 endif ! 13-16 residues
22389 end subroutine ecat_prot
22391 !----------------------------------------------------------------------------
22392 !-----------------------------------------------------------------------------
22393 !-----------------------------------------------------------------------------
22394 subroutine eprot_sc_base(escbase)
22396 ! implicit real*8 (a-h,o-z)
22397 ! include 'DIMENSIONS'
22398 ! include 'COMMON.GEO'
22399 ! include 'COMMON.VAR'
22400 ! include 'COMMON.LOCAL'
22401 ! include 'COMMON.CHAIN'
22402 ! include 'COMMON.DERIV'
22403 ! include 'COMMON.NAMES'
22404 ! include 'COMMON.INTERACT'
22405 ! include 'COMMON.IOUNITS'
22406 ! include 'COMMON.CALC'
22407 ! include 'COMMON.CONTROL'
22408 ! include 'COMMON.SBRIDGE'
22410 !el local variables
22411 integer :: iint,itypi,itypi1,itypj,subchap
22412 real(kind=8) :: rrij,xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
22413 real(kind=8) :: evdw,sig0ij
22414 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
22415 dist_temp, dist_init,aa,bb,ssgradlipi,ssgradlipj, &
22416 sslipi,sslipj,faclip
22418 real(kind=8) :: fracinbuf
22419 real (kind=8) :: escbase
22420 real (kind=8),dimension(4):: ener
22421 real(kind=8) :: b1,b2,b3,b4,egb,eps_in,eps_inout_fac,eps_out
22422 real(kind=8) :: ECL,Elj,Equad,Epol,eheadtail,rhead,dGCLOM2,&
22423 sqom1,sqom2,sqom12,c1,c2,c3,pom,Lambf,sparrow,&
22424 Chif,ChiLambf,bat,eagle,top,bot,botsq,Fcav,dtop,dFdR,dFdOM1,&
22425 dFdOM2,w1,w2,w3,dGCLdR,dFdL,dFdOM12,dbot ,&
22426 r1,eps_head,alphapol1,pis,facd2,d2,facd1,d1,erdxj,erdxi,federmaus,&
22427 dPOLdR1,dFGBdOM2,dFGBdR1,dPOLdFGB1,RR1,MomoFac1,hawk,d1i,d1j,&
22428 sig1,sig2,chis12,chis2,ee1,fgb1,a12sq,chis1
22429 real(kind=8),dimension(3,2)::chead,erhead_tail
22430 real(kind=8),dimension(3) :: Rhead_distance,ertail,erhead
22434 ! do i=1,nres_molec(1)
22435 do i=ibond_start,ibond_end
22436 if (itype(i,1).eq.ntyp1_molec(1)) cycle
22438 dxi = dc_norm(1,nres+i)
22439 dyi = dc_norm(2,nres+i)
22440 dzi = dc_norm(3,nres+i)
22441 dsci_inv = vbld_inv(i+nres)
22445 xi=mod(xi,boxxsize)
22446 if (xi.lt.0) xi=xi+boxxsize
22447 yi=mod(yi,boxysize)
22448 if (yi.lt.0) yi=yi+boxysize
22449 zi=mod(zi,boxzsize)
22450 if (zi.lt.0) zi=zi+boxzsize
22451 do j=nres_molec(1)+1,nres_molec(2)+nres_molec(1)
22453 if (itype(j,2).eq.ntyp1_molec(2))cycle
22457 xj=dmod(xj,boxxsize)
22458 if (xj.lt.0) xj=xj+boxxsize
22459 yj=dmod(yj,boxysize)
22460 if (yj.lt.0) yj=yj+boxysize
22461 zj=dmod(zj,boxzsize)
22462 if (zj.lt.0) zj=zj+boxzsize
22463 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
22472 xj=xj_safe+xshift*boxxsize
22473 yj=yj_safe+yshift*boxysize
22474 zj=zj_safe+zshift*boxzsize
22475 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
22476 if(dist_temp.lt.dist_init) then
22477 dist_init=dist_temp
22486 if (subchap.eq.1) then
22495 dxj = dc_norm( 1, nres+j )
22496 dyj = dc_norm( 2, nres+j )
22497 dzj = dc_norm( 3, nres+j )
22498 ! print *,i,j,itypi,itypj
22499 d1i = dhead_scbasei(itypi,itypj) !this is shift of dipole/charge
22500 d1j = dhead_scbasej(itypi,itypj) !this is shift of dipole/charge
22503 ! BetaT = 1.0d0 / (298.0d0 * Rb)
22505 sig0ij = sigma_scbase( itypi,itypj )
22506 chi1 = chi_scbase( itypi, itypj,1 )
22507 chi2 = chi_scbase( itypi, itypj,2 )
22510 chi12 = chi1 * chi2
22511 chip1 = chipp_scbase( itypi, itypj,1 )
22512 chip2 = chipp_scbase( itypi, itypj,2 )
22515 chip12 = chip1 * chip2
22516 ! not used by momo potential, but needed by sc_angular which is shared
22517 ! by all energy_potential subroutines
22521 a12sq = rborn_scbasei(itypi,itypj) * rborn_scbasej(itypi,itypj)
22522 ! a12sq = a12sq * a12sq
22523 ! charge of amino acid itypi is...
22524 chis1 = chis_scbase(itypi,itypj,1)
22525 chis2 = chis_scbase(itypi,itypj,2)
22526 chis12 = chis1 * chis2
22527 sig1 = sigmap1_scbase(itypi,itypj)
22528 sig2 = sigmap2_scbase(itypi,itypj)
22529 ! write (*,*) "sig1 = ", sig1
22530 ! write (*,*) "sig2 = ", sig2
22531 ! alpha factors from Fcav/Gcav
22532 b1 = alphasur_scbase(1,itypi,itypj)
22534 b2 = alphasur_scbase(2,itypi,itypj)
22535 b3 = alphasur_scbase(3,itypi,itypj)
22536 b4 = alphasur_scbase(4,itypi,itypj)
22537 ! used to determine whether we want to do quadrupole calculations
22539 eps_in = epsintab_scbase(itypi,itypj)
22540 if (eps_in.eq.0.0) eps_in=1.0
22541 eps_inout_fac = ( (1.0d0/eps_in) - (1.0d0/eps_out))
22542 ! write (*,*) "eps_inout_fac = ", eps_inout_fac
22543 !-------------------------------------------------------------------
22544 ! tail location and distance calculations
22546 ! location of polar head is computed by taking hydrophobic centre
22547 ! and moving by a d1 * dc_norm vector
22548 ! see unres publications for very informative images
22549 chead(k,1) = c(k, i+nres) + d1i * dc_norm(k, i+nres)
22550 chead(k,2) = c(k, j+nres) + d1j * dc_norm(k, j+nres)
22552 ! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
22553 ! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
22554 Rhead_distance(k) = chead(k,2) - chead(k,1)
22556 ! pitagoras (root of sum of squares)
22558 (Rhead_distance(1)*Rhead_distance(1)) &
22559 + (Rhead_distance(2)*Rhead_distance(2)) &
22560 + (Rhead_distance(3)*Rhead_distance(3)))
22561 !-------------------------------------------------------------------
22562 ! zero everything that should be zero'ed
22580 dscj_inv = vbld_inv(j+nres)
22581 ! print *,i,j,dscj_inv,dsci_inv
22582 ! rij holds 1/(distance of Calpha atoms)
22583 rrij = 1.0D0 / ( xj*xj + yj*yj + zj*zj)
22585 !----------------------------
22587 ! this should be in elgrad_init but om's are calculated by sc_angular
22588 ! which in turn is used by older potentials
22589 ! om = omega, sqom = om^2
22592 sqom12 = om12 * om12
22594 ! now we calculate EGB - Gey-Berne
22595 ! It will be summed up in evdwij and saved in evdw
22596 sigsq = 1.0D0 / sigsq
22597 sig = sig0ij * dsqrt(sigsq)
22598 ! rij_shift = 1.0D0 / rij - sig + sig0ij
22599 rij_shift = 1.0/rij - sig + sig0ij
22600 IF (rij_shift.le.0.0D0) THEN
22604 sigder = -sig * sigsq
22605 rij_shift = 1.0D0 / rij_shift
22606 fac = rij_shift**expon
22607 c1 = fac * fac * aa_scbase(itypi,itypj)
22609 c2 = fac * bb_scbase(itypi,itypj)
22611 evdwij = eps1 * eps2rt * eps3rt * ( c1 + c2 )
22612 eps2der = eps3rt * evdwij
22613 eps3der = eps2rt * evdwij
22614 ! evdwij = 4.0d0 * eps2rt * eps3rt * evdwij
22615 evdwij = eps2rt * eps3rt * evdwij
22616 c1 = c1 * eps1 * eps2rt**2 * eps3rt**2
22617 fac = -expon * (c1 + evdwij) * rij_shift
22618 sigder = fac * sigder
22620 ! Calculate distance derivative
22624 ! if (b2.gt.0.0) then
22625 fac = chis1 * sqom1 + chis2 * sqom2 &
22626 - 2.0d0 * chis12 * om1 * om2 * om12
22627 ! we will use pom later in Gcav, so dont mess with it!
22628 pom = 1.0d0 - chis1 * chis2 * sqom12
22629 Lambf = (1.0d0 - (fac / pom))
22630 Lambf = dsqrt(Lambf)
22631 sparrow = 1.0d0 / dsqrt(sig1**2.0d0 + sig2**2.0d0)
22632 ! write (*,*) "sparrow = ", sparrow
22633 Chif = 1.0d0/rij * sparrow
22634 ChiLambf = Chif * Lambf
22635 eagle = dsqrt(ChiLambf)
22636 bat = ChiLambf ** 11.0d0
22637 top = b1 * ( eagle + b2 * ChiLambf - b3 )
22638 bot = 1.0d0 + b4 * (ChiLambf ** 12.0d0)
22642 dtop = b1 * ((Lambf / (2.0d0 * eagle)) + (b2 * Lambf))
22643 dbot = 12.0d0 * b4 * bat * Lambf
22644 dFdR = ((dtop * bot - top * dbot) / botsq) * sparrow
22646 ! write (*,*) "dFcav/dR = ", dFdR
22647 dtop = b1 * ((Chif / (2.0d0 * eagle)) + (b2 * Chif))
22648 dbot = 12.0d0 * b4 * bat * Chif
22649 eagle = Lambf * pom
22650 dFdOM1 = -(chis1 * om1 - chis12 * om2 * om12) / (eagle)
22651 dFdOM2 = -(chis2 * om2 - chis12 * om1 * om12) / (eagle)
22652 dFdOM12 = chis12 * (chis1 * om1 * om12 - om2) &
22653 * (chis2 * om2 * om12 - om1) / (eagle * pom)
22655 dFdL = ((dtop * bot - top * dbot) / botsq)
22657 dCAVdOM1 = dFdL * ( dFdOM1 )
22658 dCAVdOM2 = dFdL * ( dFdOM2 )
22659 dCAVdOM12 = dFdL * ( dFdOM12 )
22664 ! eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
22665 ! eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
22666 ! eom12=evdwij*eps1_om12+eps2der*eps2rt_om12 &
22667 ! -2.0D0*alf12*eps3der+sigder*sigsq_om12
22668 ! print *,"EOMY",eom1,eom2,eom12
22669 ! erdxi = scalar( ertail(1), dC_norm(1,i+nres) )
22670 ! erdxj = scalar( ertail(1), dC_norm(1,j+nres) )
22672 ! facd1 = dtail(1,itypi,itypj) * vbld_inv(i+nres)
22673 ! facd2 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
22675 ! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
22676 ! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
22678 !-facd1*(ertail(k)-erdxi*dC_norm(k,i+nres))
22679 gvdwx_scbase(k,i) = gvdwx_scbase(k,i) &
22680 - (( dFdR + gg(k) ) * pom)
22681 ! +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
22682 ! +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
22683 ! & - ( dFdR * pom )
22685 !-facd2*(ertail(k)-erdxj*dC_norm(k,j+nres))
22686 gvdwx_scbase(k,j) = gvdwx_scbase(k,j) &
22687 + (( dFdR + gg(k) ) * pom)
22688 ! +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
22689 ! +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
22690 !c! & + ( dFdR * pom )
22692 gvdwc_scbase(k,i) = gvdwc_scbase(k,i) &
22693 - (( dFdR + gg(k) ) * ertail(k))
22694 !c! & - ( dFdR * ertail(k))
22696 gvdwc_scbase(k,j) = gvdwc_scbase(k,j) &
22697 + (( dFdR + gg(k) ) * ertail(k))
22698 !c! & + ( dFdR * ertail(k))
22701 !c! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
22702 !c! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
22709 if (wdipdip_scbase(2,itypi,itypj).gt.0.0d0) then
22710 w1 = wdipdip_scbase(1,itypi,itypj)
22711 w2 = -wdipdip_scbase(3,itypi,itypj)/2.0
22712 w3 = wdipdip_scbase(2,itypi,itypj)
22713 !c!-------------------------------------------------------------------
22715 fac = (om12 - 3.0d0 * om1 * om2)
22716 c1 = (w1 / (Rhead**3.0d0)) * fac
22717 c2 = (w2 / Rhead ** 6.0d0) &
22718 * (4.0d0 + fac * fac -3.0d0 * (sqom1 + sqom2))
22719 c3= (w3/ Rhead ** 6.0d0) &
22720 * (2.0d0 - 2.0d0*fac*fac +3.0d0*(sqom1 + sqom2))
22722 !c! write (*,*) "w1 = ", w1
22723 !c! write (*,*) "w2 = ", w2
22724 !c! write (*,*) "om1 = ", om1
22725 !c! write (*,*) "om2 = ", om2
22726 !c! write (*,*) "om12 = ", om12
22727 !c! write (*,*) "fac = ", fac
22728 !c! write (*,*) "c1 = ", c1
22729 !c! write (*,*) "c2 = ", c2
22730 !c! write (*,*) "Ecl = ", Ecl
22731 !c! write (*,*) "c2_1 = ", (w2 / Rhead ** 6.0d0)
22732 !c! write (*,*) "c2_2 = ",
22733 !c! & (4.0d0 + fac * fac -3.0d0 * (sqom1 + sqom2))
22734 !c!-------------------------------------------------------------------
22735 !c! dervative of ECL is GCL...
22737 c1 = (-3.0d0 * w1 * fac) / (Rhead ** 4.0d0)
22738 c2 = (-6.0d0 * w2) / (Rhead ** 7.0d0) &
22739 * (4.0d0 + fac * fac - 3.0d0 * (sqom1 + sqom2))
22740 c3= (-6.0d0 * w3) / (Rhead ** 7.0d0) &
22741 * (2.0d0 - 2.0d0*fac*fac +3.0d0*(sqom1 + sqom2))
22742 dGCLdR = c1 - c2 + c3
22744 c1 = (-3.0d0 * w1 * om2 ) / (Rhead**3.0d0)
22745 c2 = (-6.0d0 * w2) / (Rhead**6.0d0) &
22746 * ( om2 * om12 - 3.0d0 * om1 * sqom2 + om1 )
22747 c3 =(6.0d0*w3/ Rhead ** 6.0d0)*(om1-2.0d0*(fac)*(-om2))
22748 dGCLdOM1 = c1 - c2 + c3
22750 c1 = (-3.0d0 * w1 * om1 ) / (Rhead**3.0d0)
22751 c2 = (-6.0d0 * w2) / (Rhead**6.0d0) &
22752 * ( om1 * om12 - 3.0d0 * sqom1 * om2 + om2 )
22753 c3 =(6.0d0*w3/ Rhead ** 6.0d0)*(om2-2.0d0*(fac)*(-om1))
22754 dGCLdOM2 = c1 - c2 + c3
22756 c1 = w1 / (Rhead ** 3.0d0)
22757 c2 = ( 2.0d0 * w2 * fac ) / Rhead ** 6.0d0
22758 c3 = (w3/ Rhead ** 6.0d0)*(-4.0d0*fac)
22759 dGCLdOM12 = c1 - c2 + c3
22761 erhead(k) = Rhead_distance(k)/Rhead
22763 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
22764 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
22765 facd1 = d1i * vbld_inv(i+nres)
22766 facd2 = d1j * vbld_inv(j+nres)
22769 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
22770 gvdwx_scbase(k,i) = gvdwx_scbase(k,i) &
22772 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
22773 gvdwx_scbase(k,j) = gvdwx_scbase(k,j) &
22776 gvdwc_scbase(k,i) = gvdwc_scbase(k,i) &
22777 - dGCLdR * erhead(k)
22778 gvdwc_scbase(k,j) = gvdwc_scbase(k,j) &
22779 + dGCLdR * erhead(k)
22782 !now charge with dipole eg. ARG-dG
22783 if (wqdip_scbase(2,itypi,itypj).gt.0.0d0) then
22784 alphapol1 = alphapol_scbase(itypi,itypj)
22785 w1 = wqdip_scbase(1,itypi,itypj)
22786 w2 = wqdip_scbase(2,itypi,itypj)
22789 ! pis = sig0head_scbase(itypi,itypj)
22790 ! eps_head = epshead_scbase(itypi,itypj)
22791 !c!-------------------------------------------------------------------
22792 !c! R1 - distance between head of ith side chain and tail of jth sidechain
22795 !c! Calculate head-to-tail distances tail is center of side-chain
22796 R1=R1+(c(k,j+nres)-chead(k,1))**2
22801 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
22802 !c! & +dhead(1,1,itypi,itypj))**2))
22803 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
22804 !c! & +dhead(2,1,itypi,itypj))**2))
22806 !c!-------------------------------------------------------------------
22809 hawk = w2 * (1.0d0 - sqom2)
22810 Ecl = sparrow / Rhead**2.0d0 &
22811 - hawk / Rhead**4.0d0
22812 !c!-------------------------------------------------------------------
22813 !c! derivative of ecl is Gcl
22815 dGCLdR = - 2.0d0 * sparrow / Rhead**3.0d0 &
22816 + 4.0d0 * hawk / Rhead**5.0d0
22818 dGCLdOM1 = (w1) / (Rhead**2.0d0)
22820 dGCLdOM2 = (2.0d0 * w2 * om2) / (Rhead ** 4.0d0)
22821 !c--------------------------------------------------------------------
22822 !c Polarization energy
22824 MomoFac1 = (1.0d0 - chi1 * sqom2)
22825 RR1 = R1 * R1 / MomoFac1
22826 ee1 = exp(-( RR1 / (4.0d0 * a12sq) ))
22827 fgb1 = sqrt( RR1 + a12sq * ee1)
22828 ! eps_inout_fac=0.0d0
22829 epol = 332.0d0 * eps_inout_fac * (( alphapol1 / fgb1 )**4.0d0)
22830 ! derivative of Epol is Gpol...
22831 dPOLdFGB1 = -(1328.0d0 * eps_inout_fac * alphapol1 ** 4.0d0) &
22833 dFGBdR1 = ( (R1 / MomoFac1) &
22834 * ( 2.0d0 - (0.5d0 * ee1) ) ) &
22836 dFGBdOM2 = (((R1 * R1 * chi1 * om2) / (MomoFac1 * MomoFac1)) &
22837 * (2.0d0 - 0.5d0 * ee1) ) &
22839 dPOLdR1 = dPOLdFGB1 * dFGBdR1
22842 dPOLdOM2 = dPOLdFGB1 * dFGBdOM2
22844 erhead(k) = Rhead_distance(k)/Rhead
22845 erhead_tail(k,1) = ((c(k,j+nres)-chead(k,1))/R1)
22848 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
22849 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
22850 bat = scalar( erhead_tail(1,1), dC_norm(1,i+nres) )
22852 federmaus = scalar(erhead_tail(1,1),dC_norm(1,j+nres))
22853 facd1 = d1i * vbld_inv(i+nres)
22854 facd2 = d1j * vbld_inv(j+nres)
22855 ! facd4 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
22858 hawk = (erhead_tail(k,1) + &
22859 facd1 * (erhead_tail(k,1) - bat * dC_norm(k,i+nres)))
22862 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
22863 gvdwx_scbase(k,i) = gvdwx_scbase(k,i) &
22865 - dPOLdR1 * (erhead_tail(k,1))
22868 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
22869 gvdwx_scbase(k,j) = gvdwx_scbase(k,j) &
22871 + dPOLdR1 * (erhead_tail(k,1))
22875 gvdwc_scbase(k,i) = gvdwc_scbase(k,i) &
22876 - dGCLdR * erhead(k) &
22877 - dPOLdR1 * erhead_tail(k,1)
22878 ! & - dGLJdR * erhead(k)
22880 gvdwc_scbase(k,j) = gvdwc_scbase(k,j) &
22881 + dGCLdR * erhead(k) &
22882 + dPOLdR1 * erhead_tail(k,1)
22883 ! & + dGLJdR * erhead(k)
22887 ! print *,i,j,evdwij,epol,Fcav,ECL
22888 escbase=escbase+evdwij+epol+Fcav+ECL
22889 call sc_grad_scbase
22894 end subroutine eprot_sc_base
22895 SUBROUTINE sc_grad_scbase
22898 real (kind=8) :: dcosom1(3),dcosom2(3)
22900 eps2der * eps2rt_om1 &
22901 - 2.0D0 * alf1 * eps3der &
22902 + sigder * sigsq_om1 &
22908 eps2der * eps2rt_om2 &
22909 + 2.0D0 * alf2 * eps3der &
22910 + sigder * sigsq_om2 &
22916 evdwij * eps1_om12 &
22917 + eps2der * eps2rt_om12 &
22918 - 2.0D0 * alf12 * eps3der &
22919 + sigder *sigsq_om12 &
22923 ! print *,eom1,eom2,eom12,i,j,"eom1,2,12",erij(1),erij(2),erij(3)
22924 ! print *,dsci_inv,dscj_inv,dc_norm(2,nres+j),dc_norm(2,nres+i),&
22925 ! gg(1),gg(2),"rozne"
22927 dcosom1(k) = rij * (dc_norm(k,nres+i) - om1 * erij(k))
22928 dcosom2(k) = rij * (dc_norm(k,nres+j) - om2 * erij(k))
22929 gg(k) = gg(k) + eom1 * dcosom1(k) + eom2 * dcosom2(k)
22930 gvdwx_scbase(k,i)= gvdwx_scbase(k,i) - gg(k) &
22931 + (eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
22932 + eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
22933 gvdwx_scbase(k,j)= gvdwx_scbase(k,j) + gg(k) &
22934 + (eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
22935 + eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
22936 gvdwc_scbase(k,i)=gvdwc_scbase(k,i)-gg(k)
22937 gvdwc_scbase(k,j)=gvdwc_scbase(k,j)+gg(k)
22940 END SUBROUTINE sc_grad_scbase
22943 subroutine epep_sc_base(epepbase)
22946 !el local variables
22947 integer :: iint,itypi,itypi1,itypj,subchap
22948 real(kind=8) :: rrij,xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
22949 real(kind=8) :: evdw,sig0ij
22950 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
22951 dist_temp, dist_init,aa,bb,ssgradlipi,ssgradlipj, &
22952 sslipi,sslipj,faclip
22954 real(kind=8) :: fracinbuf
22955 real (kind=8) :: epepbase
22956 real (kind=8),dimension(4):: ener
22957 real(kind=8) :: b1,b2,b3,b4,egb,eps_in,eps_inout_fac,eps_out
22958 real(kind=8) :: ECL,Elj,Equad,Epol,eheadtail,rhead,dGCLOM2,&
22959 sqom1,sqom2,sqom12,c1,c2,c3,pom,Lambf,sparrow,&
22960 Chif,ChiLambf,bat,eagle,top,bot,botsq,Fcav,dtop,dFdR,dFdOM1,&
22961 dFdOM2,w1,w2,w3,dGCLdR,dFdL,dFdOM12,dbot ,&
22962 r1,eps_head,alphapol1,pis,facd2,d2,facd1,d1,erdxj,erdxi,federmaus,&
22963 dPOLdR1,dFGBdOM2,dFGBdR1,dPOLdFGB1,RR1,MomoFac1,hawk,d1i,d1j,&
22964 sig1,sig2,chis12,chis2,ee1,fgb1,a12sq,chis1
22965 real(kind=8),dimension(3,2)::chead,erhead_tail
22966 real(kind=8),dimension(3) :: Rhead_distance,ertail,erhead
22970 ! do i=1,nres_molec(1)-1
22971 do i=ibond_start,ibond_end
22972 if (itype(i,1).eq.ntyp1_molec(1).or.itype(i+1,1).eq.ntyp1_molec(1)) cycle
22973 !C itypi = itype(i,1)
22977 ! print *,dxi,(-c(1,i)+c(1,i+1))*vbld_inv(i+1)
22978 dsci_inv = vbld_inv(i+1)/2.0
22979 xi=(c(1,i)+c(1,i+1))/2.0
22980 yi=(c(2,i)+c(2,i+1))/2.0
22981 zi=(c(3,i)+c(3,i+1))/2.0
22982 xi=mod(xi,boxxsize)
22983 if (xi.lt.0) xi=xi+boxxsize
22984 yi=mod(yi,boxysize)
22985 if (yi.lt.0) yi=yi+boxysize
22986 zi=mod(zi,boxzsize)
22987 if (zi.lt.0) zi=zi+boxzsize
22988 do j=nres_molec(1)+1,nres_molec(2)+nres_molec(1)
22990 if (itype(j,2).eq.ntyp1_molec(2))cycle
22994 xj=dmod(xj,boxxsize)
22995 if (xj.lt.0) xj=xj+boxxsize
22996 yj=dmod(yj,boxysize)
22997 if (yj.lt.0) yj=yj+boxysize
22998 zj=dmod(zj,boxzsize)
22999 if (zj.lt.0) zj=zj+boxzsize
23000 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
23009 xj=xj_safe+xshift*boxxsize
23010 yj=yj_safe+yshift*boxysize
23011 zj=zj_safe+zshift*boxzsize
23012 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
23013 if(dist_temp.lt.dist_init) then
23014 dist_init=dist_temp
23023 if (subchap.eq.1) then
23032 dxj = dc_norm( 1, nres+j )
23033 dyj = dc_norm( 2, nres+j )
23034 dzj = dc_norm( 3, nres+j )
23035 ! d1i = dhead_scbasei(itypi) !this is shift of dipole/charge
23036 ! d1j = dhead_scbasej(itypi) !this is shift of dipole/charge
23039 sig0ij = sigma_pepbase(itypj )
23040 chi1 = chi_pepbase(itypj,1 )
23041 chi2 = chi_pepbase(itypj,2 )
23044 chi12 = chi1 * chi2
23045 chip1 = chipp_pepbase(itypj,1 )
23046 chip2 = chipp_pepbase(itypj,2 )
23049 chip12 = chip1 * chip2
23050 chis1 = chis_pepbase(itypj,1)
23051 chis2 = chis_pepbase(itypj,2)
23052 chis12 = chis1 * chis2
23053 sig1 = sigmap1_pepbase(itypj)
23054 sig2 = sigmap2_pepbase(itypj)
23055 ! write (*,*) "sig1 = ", sig1
23056 ! write (*,*) "sig2 = ", sig2
23058 ! location of polar head is computed by taking hydrophobic centre
23059 ! and moving by a d1 * dc_norm vector
23060 ! see unres publications for very informative images
23061 chead(k,1) = (c(k,i)+c(k,i+1))/2.0
23062 ! + d1i * dc_norm(k, i+nres)
23063 chead(k,2) = c(k, j+nres)
23064 ! + d1j * dc_norm(k, j+nres)
23066 ! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
23067 ! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
23068 Rhead_distance(k) = chead(k,2) - chead(k,1)
23069 ! print *,gvdwc_pepbase(k,i)
23073 (Rhead_distance(1)*Rhead_distance(1)) &
23074 + (Rhead_distance(2)*Rhead_distance(2)) &
23075 + (Rhead_distance(3)*Rhead_distance(3)))
23077 ! alpha factors from Fcav/Gcav
23078 b1 = alphasur_pepbase(1,itypj)
23080 b2 = alphasur_pepbase(2,itypj)
23081 b3 = alphasur_pepbase(3,itypj)
23082 b4 = alphasur_pepbase(4,itypj)
23086 rrij = 1.0D0 / ( xj*xj + yj*yj + zj*zj)
23089 !----------------------------
23107 dscj_inv = vbld_inv(j+nres)
23109 ! this should be in elgrad_init but om's are calculated by sc_angular
23110 ! which in turn is used by older potentials
23111 ! om = omega, sqom = om^2
23114 sqom12 = om12 * om12
23116 ! now we calculate EGB - Gey-Berne
23117 ! It will be summed up in evdwij and saved in evdw
23118 sigsq = 1.0D0 / sigsq
23119 sig = sig0ij * dsqrt(sigsq)
23120 rij_shift = 1.0/rij - sig + sig0ij
23121 IF (rij_shift.le.0.0D0) THEN
23125 sigder = -sig * sigsq
23126 rij_shift = 1.0D0 / rij_shift
23127 fac = rij_shift**expon
23128 c1 = fac * fac * aa_pepbase(itypj)
23130 c2 = fac * bb_pepbase(itypj)
23132 evdwij = eps1 * eps2rt * eps3rt * ( c1 + c2 )
23133 eps2der = eps3rt * evdwij
23134 eps3der = eps2rt * evdwij
23135 ! evdwij = 4.0d0 * eps2rt * eps3rt * evdwij
23136 evdwij = eps2rt * eps3rt * evdwij
23137 c1 = c1 * eps1 * eps2rt**2 * eps3rt**2
23138 fac = -expon * (c1 + evdwij) * rij_shift
23139 sigder = fac * sigder
23141 ! Calculate distance derivative
23145 fac = chis1 * sqom1 + chis2 * sqom2 &
23146 - 2.0d0 * chis12 * om1 * om2 * om12
23147 ! we will use pom later in Gcav, so dont mess with it!
23148 pom = 1.0d0 - chis1 * chis2 * sqom12
23149 Lambf = (1.0d0 - (fac / pom))
23150 Lambf = dsqrt(Lambf)
23151 sparrow = 1.0d0 / dsqrt(sig1**2.0d0 + sig2**2.0d0)
23152 ! write (*,*) "sparrow = ", sparrow
23153 Chif = 1.0d0/rij * sparrow
23154 ChiLambf = Chif * Lambf
23155 eagle = dsqrt(ChiLambf)
23156 bat = ChiLambf ** 11.0d0
23157 top = b1 * ( eagle + b2 * ChiLambf - b3 )
23158 bot = 1.0d0 + b4 * (ChiLambf ** 12.0d0)
23162 dtop = b1 * ((Lambf / (2.0d0 * eagle)) + (b2 * Lambf))
23163 dbot = 12.0d0 * b4 * bat * Lambf
23164 dFdR = ((dtop * bot - top * dbot) / botsq) * sparrow
23166 ! write (*,*) "dFcav/dR = ", dFdR
23167 dtop = b1 * ((Chif / (2.0d0 * eagle)) + (b2 * Chif))
23168 dbot = 12.0d0 * b4 * bat * Chif
23169 eagle = Lambf * pom
23170 dFdOM1 = -(chis1 * om1 - chis12 * om2 * om12) / (eagle)
23171 dFdOM2 = -(chis2 * om2 - chis12 * om1 * om12) / (eagle)
23172 dFdOM12 = chis12 * (chis1 * om1 * om12 - om2) &
23173 * (chis2 * om2 * om12 - om1) / (eagle * pom)
23175 dFdL = ((dtop * bot - top * dbot) / botsq)
23177 dCAVdOM1 = dFdL * ( dFdOM1 )
23178 dCAVdOM2 = dFdL * ( dFdOM2 )
23179 dCAVdOM12 = dFdL * ( dFdOM12 )
23185 ! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
23186 ! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
23188 !-facd1*(ertail(k)-erdxi*dC_norm(k,i+nres))
23189 gvdwc_pepbase(k,i) = gvdwc_pepbase(k,i) &
23190 - (( dFdR + gg(k) ) * pom)/2.0
23191 ! print *,gvdwc_pepbase(k,i),i,(( dFdR + gg(k) ) * pom)/2.0
23192 ! +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
23193 ! +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
23194 ! & - ( dFdR * pom )
23196 !-facd2*(ertail(k)-erdxj*dC_norm(k,j+nres))
23197 gvdwx_pepbase(k,j) = gvdwx_pepbase(k,j) &
23198 + (( dFdR + gg(k) ) * pom)
23199 ! +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
23200 ! +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
23201 !c! & + ( dFdR * pom )
23203 gvdwc_pepbase(k,i+1) = gvdwc_pepbase(k,i+1) &
23204 - (( dFdR + gg(k) ) * ertail(k))/2.0
23205 ! print *,gvdwc_pepbase(k,i+1),i+1,(( dFdR + gg(k) ) * pom)/2.0
23207 !c! & - ( dFdR * ertail(k))
23209 gvdwc_pepbase(k,j) = gvdwc_pepbase(k,j) &
23210 + (( dFdR + gg(k) ) * ertail(k))
23211 !c! & + ( dFdR * ertail(k))
23214 !c! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
23215 !c! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
23219 w1 = wdipdip_pepbase(1,itypj)
23220 w2 = -wdipdip_pepbase(3,itypj)/2.0
23221 w3 = wdipdip_pepbase(2,itypj)
23224 !c!-------------------------------------------------------------------
23227 fac = (om12 - 3.0d0 * om1 * om2)
23228 c1 = (w1 / (Rhead**3.0d0)) * fac
23229 c2 = (w2 / Rhead ** 6.0d0) &
23230 * (4.0d0 + fac * fac -3.0d0 * (sqom1 + sqom2))
23231 c3= (w3/ Rhead ** 6.0d0) &
23232 * (2.0d0 - 2.0d0*fac*fac +3.0d0*(sqom1 + sqom2))
23236 c1 = (-3.0d0 * w1 * fac) / (Rhead ** 4.0d0)
23237 c2 = (-6.0d0 * w2) / (Rhead ** 7.0d0) &
23238 * (4.0d0 + fac * fac - 3.0d0 * (sqom1 + sqom2))
23239 c3= (-6.0d0 * w3) / (Rhead ** 7.0d0) &
23240 * (2.0d0 - 2.0d0*fac*fac +3.0d0*(sqom1 + sqom2))
23242 dGCLdR = c1 - c2 + c3
23244 c1 = (-3.0d0 * w1 * om2 ) / (Rhead**3.0d0)
23245 c2 = (-6.0d0 * w2) / (Rhead**6.0d0) &
23246 * ( om2 * om12 - 3.0d0 * om1 * sqom2 + om1 )
23247 c3 =(6.0d0*w3/ Rhead ** 6.0d0)*(om1-2.0d0*(fac)*(-om2))
23248 dGCLdOM1 = c1 - c2 + c3
23250 c1 = (-3.0d0 * w1 * om1 ) / (Rhead**3.0d0)
23251 c2 = (-6.0d0 * w2) / (Rhead**6.0d0) &
23252 * ( om1 * om12 - 3.0d0 * sqom1 * om2 + om2 )
23253 c3 =(6.0d0*w3/ Rhead ** 6.0d0)*(om2-2.0d0*(fac)*(-om1))
23255 dGCLdOM2 = c1 - c2 + c3
23257 c1 = w1 / (Rhead ** 3.0d0)
23258 c2 = ( 2.0d0 * w2 * fac ) / Rhead ** 6.0d0
23259 c3 = (w3/ Rhead ** 6.0d0)*(-4.0d0*fac)
23260 dGCLdOM12 = c1 - c2 + c3
23262 erhead(k) = Rhead_distance(k)/Rhead
23264 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
23265 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
23266 ! facd1 = d1 * vbld_inv(i+nres)
23267 ! facd2 = d2 * vbld_inv(j+nres)
23271 !+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
23272 ! gvdwx_pepbase(k,i) = gvdwx_scbase(k,i) &
23275 !+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
23276 gvdwx_pepbase(k,j) = gvdwx_pepbase(k,j) &
23279 gvdwc_pepbase(k,i) = gvdwc_pepbase(k,i) &
23280 - dGCLdR * erhead(k)/2.0d0
23281 ! print *,gvdwc_pepbase(k,i+1),i+1,- dGCLdR * erhead(k)/2.0d0
23282 gvdwc_pepbase(k,i+1) = gvdwc_pepbase(k,i+1) &
23283 - dGCLdR * erhead(k)/2.0d0
23284 ! print *,gvdwc_pepbase(k,i+1),i+1,- dGCLdR * erhead(k)/2.0d0
23285 gvdwc_pepbase(k,j) = gvdwc_pepbase(k,j) &
23286 + dGCLdR * erhead(k)
23288 ! print *,i,j,evdwij,Fcav,ECL,"vdw,cav,ecl"
23289 epepbase=epepbase+evdwij+Fcav+ECL
23290 call sc_grad_pepbase
23293 END SUBROUTINE epep_sc_base
23294 SUBROUTINE sc_grad_pepbase
23297 real (kind=8) :: dcosom1(3),dcosom2(3)
23299 eps2der * eps2rt_om1 &
23300 - 2.0D0 * alf1 * eps3der &
23301 + sigder * sigsq_om1 &
23307 eps2der * eps2rt_om2 &
23308 + 2.0D0 * alf2 * eps3der &
23309 + sigder * sigsq_om2 &
23315 evdwij * eps1_om12 &
23316 + eps2der * eps2rt_om12 &
23317 - 2.0D0 * alf12 * eps3der &
23318 + sigder *sigsq_om12 &
23323 ! print *,eom1,eom2,eom12,om12,i,j,"eom1,2,12",erij(1),erij(2),erij(3)
23324 ! if (i.eq.30) print *,gvdwc_pepbase(k,i),- gg(k),&
23325 ! (-eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,i)))&
23327 ! print *,dsci_inv,dscj_inv,dc_norm(2,nres+j),dc_norm(2,nres+i),&
23328 ! gg(1),gg(2),"rozne"
23330 dcosom1(k) = rij * (dc_norm(k,i) - om1 * erij(k))
23331 dcosom2(k) = rij * (dc_norm(k,nres+j) - om2 * erij(k))
23332 gg(k) = gg(k) + eom1 * dcosom1(k) + eom2 * dcosom2(k)
23333 gvdwc_pepbase(k,i)= gvdwc_pepbase(k,i) +0.5*(- gg(k)) &
23334 + (-eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,i)))&
23336 - (eom1*(erij(k)-om1*dc_norm(k,i)))*dsci_inv*2.0
23337 gvdwc_pepbase(k,i+1)= gvdwc_pepbase(k,i+1) +0.5*(- gg(k)) &
23338 - (-eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,i))) &
23340 + (eom1*(erij(k)-om1*dc_norm(k,i)))*dsci_inv*2.0
23341 ! print *,eom12,eom2,om12,om2
23342 !eom12*(-dc_norm(k,i)/2.0-om12*dc_norm(k,nres+j)),&
23343 ! (eom2*(erij(k)-om2*dc_norm(k,nres+j)))
23344 gvdwx_pepbase(k,j)= gvdwx_pepbase(k,j) + gg(k) &
23345 + (eom12*(dc_norm(k,i)-om12*dc_norm(k,nres+j))&
23346 + eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
23347 gvdwc_pepbase(k,j)=gvdwc_pepbase(k,j)+gg(k)
23350 END SUBROUTINE sc_grad_pepbase
23351 subroutine eprot_sc_phosphate(escpho)
23353 ! implicit real*8 (a-h,o-z)
23354 ! include 'DIMENSIONS'
23355 ! include 'COMMON.GEO'
23356 ! include 'COMMON.VAR'
23357 ! include 'COMMON.LOCAL'
23358 ! include 'COMMON.CHAIN'
23359 ! include 'COMMON.DERIV'
23360 ! include 'COMMON.NAMES'
23361 ! include 'COMMON.INTERACT'
23362 ! include 'COMMON.IOUNITS'
23363 ! include 'COMMON.CALC'
23364 ! include 'COMMON.CONTROL'
23365 ! include 'COMMON.SBRIDGE'
23367 !el local variables
23368 integer :: iint,itypi,itypi1,itypj,subchap
23369 real(kind=8) :: rrij,xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
23370 real(kind=8) :: evdw,sig0ij
23371 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
23372 dist_temp, dist_init,aa,bb,ssgradlipi,ssgradlipj, &
23373 sslipi,sslipj,faclip
23375 real(kind=8) :: fracinbuf
23376 real (kind=8) :: escpho
23377 real (kind=8),dimension(4):: ener
23378 real(kind=8) :: b1,b2,b3,b4,egb,eps_in,eps_inout_fac,eps_out
23379 real(kind=8) :: ECL,Elj,Equad,Epol,eheadtail,rhead,dGCLOM2,&
23380 sqom1,sqom2,sqom12,c1,c2,pom,Lambf,sparrow,&
23381 Chif,ChiLambf,bat,eagle,top,bot,botsq,Fcav,dtop,dFdR,dFdOM1,&
23382 dFdOM2,w1,w2,dGCLdR,dFdL,dFdOM12,dbot ,&
23383 r1,eps_head,alphapol1,pis,facd2,d2,facd1,d1,erdxj,erdxi,federmaus,&
23384 dPOLdR1,dFGBdOM2,dFGBdR1,dPOLdFGB1,RR1,MomoFac1,hawk,d1i,d1j,&
23385 sig1,sig2,chis12,chis2,ee1,fgb1,a12sq,chis1,Rhead_sq,Qij,dFGBdOM1
23386 real(kind=8),dimension(3,2)::chead,erhead_tail
23387 real(kind=8),dimension(3) :: Rhead_distance,ertail,erhead
23391 ! do i=1,nres_molec(1)
23392 do i=ibond_start,ibond_end
23393 if (itype(i,1).eq.ntyp1_molec(1)) cycle
23395 dxi = dc_norm(1,nres+i)
23396 dyi = dc_norm(2,nres+i)
23397 dzi = dc_norm(3,nres+i)
23398 dsci_inv = vbld_inv(i+nres)
23402 xi=mod(xi,boxxsize)
23403 if (xi.lt.0) xi=xi+boxxsize
23404 yi=mod(yi,boxysize)
23405 if (yi.lt.0) yi=yi+boxysize
23406 zi=mod(zi,boxzsize)
23407 if (zi.lt.0) zi=zi+boxzsize
23408 do j=nres_molec(1)+1,nres_molec(2)+nres_molec(1)-1
23410 if ((itype(j,2).eq.ntyp1_molec(2)).or.&
23411 (itype(j+1,2).eq.ntyp1_molec(2))) cycle
23412 xj=(c(1,j)+c(1,j+1))/2.0
23413 yj=(c(2,j)+c(2,j+1))/2.0
23414 zj=(c(3,j)+c(3,j+1))/2.0
23415 xj=dmod(xj,boxxsize)
23416 if (xj.lt.0) xj=xj+boxxsize
23417 yj=dmod(yj,boxysize)
23418 if (yj.lt.0) yj=yj+boxysize
23419 zj=dmod(zj,boxzsize)
23420 if (zj.lt.0) zj=zj+boxzsize
23421 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
23429 yj=yj_safe+yshift*boxysize
23430 zj=zj_safe+zshift*boxzsize
23431 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
23432 if(dist_temp.lt.dist_init) then
23433 dist_init=dist_temp
23442 if (subchap.eq.1) then
23451 dxj = dc_norm( 1,j )
23452 dyj = dc_norm( 2,j )
23453 dzj = dc_norm( 3,j )
23454 dscj_inv = vbld_inv(j+1)
23457 sig0ij = sigma_scpho(itypi )
23458 chi1 = chi_scpho(itypi,1 )
23459 chi2 = chi_scpho(itypi,2 )
23462 chi12 = chi1 * chi2
23463 chip1 = chipp_scpho(itypi,1 )
23464 chip2 = chipp_scpho(itypi,2 )
23467 chip12 = chip1 * chip2
23468 chis1 = chis_scpho(itypi,1)
23469 chis2 = chis_scpho(itypi,2)
23470 chis12 = chis1 * chis2
23471 sig1 = sigmap1_scpho(itypi)
23472 sig2 = sigmap2_scpho(itypi)
23473 ! write (*,*) "sig1 = ", sig1
23474 ! write (*,*) "sig1 = ", sig1
23475 ! write (*,*) "sig2 = ", sig2
23476 ! alpha factors from Fcav/Gcav
23480 a12sq = rborn_scphoi(itypi) * rborn_scphoj(itypi)
23482 b1 = alphasur_scpho(1,itypi)
23484 b2 = alphasur_scpho(2,itypi)
23485 b3 = alphasur_scpho(3,itypi)
23486 b4 = alphasur_scpho(4,itypi)
23487 ! used to determine whether we want to do quadrupole calculations
23489 eps_in = epsintab_scpho(itypi)
23490 if (eps_in.eq.0.0) eps_in=1.0
23491 eps_inout_fac = ( (1.0d0/eps_in) - (1.0d0/eps_out))
23492 ! write (*,*) "eps_inout_fac = ", eps_inout_fac
23493 !-------------------------------------------------------------------
23494 ! tail location and distance calculations
23495 d1i = dhead_scphoi(itypi) !this is shift of dipole/charge
23498 ! location of polar head is computed by taking hydrophobic centre
23499 ! and moving by a d1 * dc_norm vector
23500 ! see unres publications for very informative images
23501 chead(k,1) = c(k, i+nres) + d1i * dc_norm(k, i+nres)
23502 chead(k,2) = (c(k, j) + c(k, j+1))/2.0
23504 ! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
23505 ! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
23506 Rhead_distance(k) = chead(k,2) - chead(k,1)
23508 ! pitagoras (root of sum of squares)
23510 (Rhead_distance(1)*Rhead_distance(1)) &
23511 + (Rhead_distance(2)*Rhead_distance(2)) &
23512 + (Rhead_distance(3)*Rhead_distance(3)))
23513 Rhead_sq=Rhead**2.0
23514 !-------------------------------------------------------------------
23515 ! zero everything that should be zero'ed
23534 dscj_inv = vbld_inv(j+1)/2.0
23535 !dhead_scbasej(itypi,itypj)
23536 ! print *,i,j,dscj_inv,dsci_inv
23537 ! rij holds 1/(distance of Calpha atoms)
23538 rrij = 1.0D0 / ( xj*xj + yj*yj + zj*zj)
23540 !----------------------------
23542 ! this should be in elgrad_init but om's are calculated by sc_angular
23543 ! which in turn is used by older potentials
23544 ! om = omega, sqom = om^2
23547 sqom12 = om12 * om12
23549 ! now we calculate EGB - Gey-Berne
23550 ! It will be summed up in evdwij and saved in evdw
23551 sigsq = 1.0D0 / sigsq
23552 sig = sig0ij * dsqrt(sigsq)
23553 ! rij_shift = 1.0D0 / rij - sig + sig0ij
23554 rij_shift = 1.0/rij - sig + sig0ij
23555 IF (rij_shift.le.0.0D0) THEN
23559 sigder = -sig * sigsq
23560 rij_shift = 1.0D0 / rij_shift
23561 fac = rij_shift**expon
23562 c1 = fac * fac * aa_scpho(itypi)
23564 c2 = fac * bb_scpho(itypi)
23566 evdwij = eps1 * eps2rt * eps3rt * ( c1 + c2 )
23567 eps2der = eps3rt * evdwij
23568 eps3der = eps2rt * evdwij
23569 ! evdwij = 4.0d0 * eps2rt * eps3rt * evdwij
23570 evdwij = eps2rt * eps3rt * evdwij
23571 c1 = c1 * eps1 * eps2rt**2 * eps3rt**2
23572 fac = -expon * (c1 + evdwij) * rij_shift
23573 sigder = fac * sigder
23575 ! Calculate distance derivative
23579 fac = chis1 * sqom1 + chis2 * sqom2 &
23580 - 2.0d0 * chis12 * om1 * om2 * om12
23581 ! we will use pom later in Gcav, so dont mess with it!
23582 pom = 1.0d0 - chis1 * chis2 * sqom12
23583 Lambf = (1.0d0 - (fac / pom))
23584 Lambf = dsqrt(Lambf)
23585 sparrow = 1.0d0 / dsqrt(sig1**2.0d0 + sig2**2.0d0)
23586 ! write (*,*) "sparrow = ", sparrow
23587 Chif = 1.0d0/rij * sparrow
23588 ChiLambf = Chif * Lambf
23589 eagle = dsqrt(ChiLambf)
23590 bat = ChiLambf ** 11.0d0
23591 top = b1 * ( eagle + b2 * ChiLambf - b3 )
23592 bot = 1.0d0 + b4 * (ChiLambf ** 12.0d0)
23595 dtop = b1 * ((Lambf / (2.0d0 * eagle)) + (b2 * Lambf))
23596 dbot = 12.0d0 * b4 * bat * Lambf
23597 dFdR = ((dtop * bot - top * dbot) / botsq) * sparrow
23599 ! write (*,*) "dFcav/dR = ", dFdR
23600 dtop = b1 * ((Chif / (2.0d0 * eagle)) + (b2 * Chif))
23601 dbot = 12.0d0 * b4 * bat * Chif
23602 eagle = Lambf * pom
23603 dFdOM1 = -(chis1 * om1 - chis12 * om2 * om12) / (eagle)
23604 dFdOM2 = -(chis2 * om2 - chis12 * om1 * om12) / (eagle)
23605 dFdOM12 = chis12 * (chis1 * om1 * om12 - om2) &
23606 * (chis2 * om2 * om12 - om1) / (eagle * pom)
23608 dFdL = ((dtop * bot - top * dbot) / botsq)
23610 dCAVdOM1 = dFdL * ( dFdOM1 )
23611 dCAVdOM2 = dFdL * ( dFdOM2 )
23612 dCAVdOM12 = dFdL * ( dFdOM12 )
23618 ! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
23619 ! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
23620 ! if (i.eq.3) print *,'decl0',gvdwx_scpho(k,i),i
23623 ! print *,pom,gg(k),dFdR
23624 !-facd1*(ertail(k)-erdxi*dC_norm(k,i+nres))
23625 gvdwx_scpho(k,i) = gvdwx_scpho(k,i) &
23626 - (( dFdR + gg(k) ) * pom)
23627 ! +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
23628 ! +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
23629 ! & - ( dFdR * pom )
23631 !-facd2*(ertail(k)-erdxj*dC_norm(k,j+nres))
23632 ! gvdwx_scpho(k,j) = gvdwx_scpho(k,j) &
23633 ! + (( dFdR + gg(k) ) * pom)
23634 ! +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
23635 ! +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
23636 !c! & + ( dFdR * pom )
23638 gvdwc_scpho(k,i) = gvdwc_scpho(k,i) &
23639 - (( dFdR + gg(k) ) * ertail(k))
23640 !c! & - ( dFdR * ertail(k))
23642 gvdwc_scpho(k,j) = gvdwc_scpho(k,j) &
23643 + (( dFdR + gg(k) ) * ertail(k))/2.0
23645 gvdwc_scpho(k,j+1) = gvdwc_scpho(k,j+1) &
23646 + (( dFdR + gg(k) ) * ertail(k))/2.0
23648 !c! & + ( dFdR * ertail(k))
23652 !c! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
23653 !c! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
23654 ! alphapol1 = alphapol_scpho(itypi)
23655 if (wqq_scpho(itypi).gt.0.0) then
23656 Qij=wqq_scpho(itypi)/eps_in
23658 Ecl = (332.0d0 * Qij) / Rhead
23659 !c! derivative of Ecl is Gcl...
23660 dGCLdR = (-332.0d0 * Qij ) / Rhead_sq
23661 else if (wqdip_scpho(2,itypi).gt.0.0d0) then
23662 w1 = wqdip_scpho(1,itypi)
23663 w2 = wqdip_scpho(2,itypi)
23666 ! pis = sig0head_scbase(itypi,itypj)
23667 ! eps_head = epshead_scbase(itypi,itypj)
23668 !c!-------------------------------------------------------------------
23670 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
23671 !c! & +dhead(1,1,itypi,itypj))**2))
23672 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
23673 !c! & +dhead(2,1,itypi,itypj))**2))
23675 !c!-------------------------------------------------------------------
23678 hawk = w2 * (1.0d0 - sqom2)
23679 Ecl = sparrow / Rhead**2.0d0 &
23680 - hawk / Rhead**4.0d0
23681 !c!-------------------------------------------------------------------
23682 !c! derivative of ecl is Gcl
23684 dGCLdR = - 2.0d0 * sparrow / Rhead**3.0d0 &
23685 + 4.0d0 * hawk / Rhead**5.0d0
23687 dGCLdOM1 = (w1) / (Rhead**2.0d0)
23689 dGCLdOM2 = (2.0d0 * w2 * om2) / (Rhead ** 4.0d0)
23692 !c--------------------------------------------------------------------
23693 !c Polarization energy
23697 !c! Calculate head-to-tail distances tail is center of side-chain
23698 R1=R1+((c(k,j)+c(k,j+1))/2.0-chead(k,1))**2
23703 alphapol1 = alphapol_scpho(itypi)
23705 MomoFac1 = (1.0d0 - chi2 * sqom1)
23706 RR1 = R1 * R1 / MomoFac1
23707 ee1 = exp(-( RR1 / (4.0d0 * a12sq) ))
23708 ! print *,"ee1",ee1,a12sq,alphapol1,eps_inout_fac
23709 fgb1 = sqrt( RR1 + a12sq * ee1)
23710 ! eps_inout_fac=0.0d0
23711 epol = 332.0d0 * eps_inout_fac * (( alphapol1 / fgb1 )**4.0d0)
23712 ! derivative of Epol is Gpol...
23713 dPOLdFGB1 = -(1328.0d0 * eps_inout_fac * alphapol1 ** 4.0d0) &
23715 dFGBdR1 = ( (R1 / MomoFac1) &
23716 * ( 2.0d0 - (0.5d0 * ee1) ) ) &
23718 dFGBdOM2 = (((R1 * R1 * chi1 * om2) / (MomoFac1 * MomoFac1)) &
23719 * (2.0d0 - 0.5d0 * ee1) ) &
23721 dPOLdR1 = dPOLdFGB1 * dFGBdR1
23724 dFGBdOM1 = (((R1 * R1 * chi2 * om1) / (MomoFac1 * MomoFac1)) &
23725 * (2.0d0 - 0.5d0 * ee1) ) &
23728 dPOLdOM1 = dPOLdFGB1 * dFGBdOM1
23731 erhead(k) = Rhead_distance(k)/Rhead
23732 erhead_tail(k,1) = (((c(k,j)+c(k,j+1))/2.0-chead(k,1))/R1)
23735 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
23736 erdxj = scalar( erhead(1), dC_norm(1,j) )
23737 bat = scalar( erhead_tail(1,1), dC_norm(1,i+nres) )
23739 federmaus = scalar(erhead_tail(1,1),dC_norm(1,j))
23740 facd1 = d1i * vbld_inv(i+nres)
23741 facd2 = d1j * vbld_inv(j)
23742 ! facd4 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
23745 hawk = (erhead_tail(k,1) + &
23746 facd1 * (erhead_tail(k,1) - bat * dC_norm(k,i+nres)))
23749 ! if (i.eq.3) print *,'decl1',dGCLdR,dPOLdR1,gvdwc_scpho(k,i),i,&
23750 ! pom,(erhead_tail(k,1))
23752 ! print *,'decl',dGCLdR,dPOLdR1,gvdwc_scpho(k,i)
23753 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
23754 gvdwx_scpho(k,i) = gvdwx_scpho(k,i) &
23756 - dPOLdR1 * (erhead_tail(k,1))
23759 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j))
23760 ! gvdwx_scpho(k,j) = gvdwx_scpho(k,j) &
23762 ! + dPOLdR1 * (erhead_tail(k,1))
23766 gvdwc_scpho(k,i) = gvdwc_scpho(k,i) &
23767 - dGCLdR * erhead(k) &
23768 - dPOLdR1 * erhead_tail(k,1)
23769 ! & - dGLJdR * erhead(k)
23771 gvdwc_scpho(k,j) = gvdwc_scpho(k,j) &
23772 + (dGCLdR * erhead(k) &
23773 + dPOLdR1 * erhead_tail(k,1))/2.0
23774 gvdwc_scpho(k,j+1) = gvdwc_scpho(k,j+1) &
23775 + (dGCLdR * erhead(k) &
23776 + dPOLdR1 * erhead_tail(k,1))/2.0
23778 ! & + dGLJdR * erhead(k)
23779 ! if (i.eq.3) print *,'decl2',dGCLdR,dPOLdR1,gvdwc_scpho(k,i),i
23782 ! if (i.eq.3) print *,i,j,evdwij,epol,Fcav,ECL
23783 escpho=escpho+evdwij+epol+Fcav+ECL
23790 end subroutine eprot_sc_phosphate
23791 SUBROUTINE sc_grad_scpho
23794 real (kind=8) :: dcosom1(3),dcosom2(3)
23796 eps2der * eps2rt_om1 &
23797 - 2.0D0 * alf1 * eps3der &
23798 + sigder * sigsq_om1 &
23804 eps2der * eps2rt_om2 &
23805 + 2.0D0 * alf2 * eps3der &
23806 + sigder * sigsq_om2 &
23812 evdwij * eps1_om12 &
23813 + eps2der * eps2rt_om12 &
23814 - 2.0D0 * alf12 * eps3der &
23815 + sigder *sigsq_om12 &
23820 ! print *,eom1,eom2,eom12,om12,i,j,"eom1,2,12",erij(1),erij(2),erij(3)
23821 ! if (i.eq.30) print *,gvdwc_scpho(k,i),- gg(k),&
23822 ! (-eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,i)))&
23824 ! print *,dsci_inv,dscj_inv,dc_norm(2,nres+j),dc_norm(2,nres+i),&
23825 ! gg(1),gg(2),"rozne"
23827 dcosom1(k) = rij * (dc_norm(k,nres+i) - om1 * erij(k))
23828 dcosom2(k) = rij * (dc_norm(k,j) - om2 * erij(k))
23829 gg(k) = gg(k) + eom1 * dcosom1(k) + eom2 * dcosom2(k)
23830 gvdwc_scpho(k,j)= gvdwc_scpho(k,j) +0.5*( gg(k)) &
23831 + (-eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,j)))&
23833 - (eom2*(erij(k)-om2*dc_norm(k,j)))*dscj_inv*2.0
23834 gvdwc_scpho(k,j+1)= gvdwc_scpho(k,j+1) +0.5*( gg(k)) &
23835 - (-eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,j))) &
23837 + (eom2*(erij(k)-om2*dc_norm(k,j)))*dscj_inv*2.0
23838 gvdwx_scpho(k,i)= gvdwx_scpho(k,i) - gg(k) &
23839 + (eom12*(dc_norm(k,j)-om12*dc_norm(k,nres+i)) &
23840 + eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
23842 ! print *,eom12,eom2,om12,om2
23843 !eom12*(-dc_norm(k,i)/2.0-om12*dc_norm(k,nres+j)),&
23844 ! (eom2*(erij(k)-om2*dc_norm(k,nres+j)))
23845 ! gvdwx_scpho(k,j)= gvdwx_scpho(k,j) + gg(k) &
23846 ! + (eom12*(dc_norm(k,i)-om12*dc_norm(k,nres+j))&
23847 ! + eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
23848 gvdwc_scpho(k,i)=gvdwc_scpho(k,i)-gg(k)
23851 END SUBROUTINE sc_grad_scpho
23852 subroutine eprot_pep_phosphate(epeppho)
23854 ! implicit real*8 (a-h,o-z)
23855 ! include 'DIMENSIONS'
23856 ! include 'COMMON.GEO'
23857 ! include 'COMMON.VAR'
23858 ! include 'COMMON.LOCAL'
23859 ! include 'COMMON.CHAIN'
23860 ! include 'COMMON.DERIV'
23861 ! include 'COMMON.NAMES'
23862 ! include 'COMMON.INTERACT'
23863 ! include 'COMMON.IOUNITS'
23864 ! include 'COMMON.CALC'
23865 ! include 'COMMON.CONTROL'
23866 ! include 'COMMON.SBRIDGE'
23868 !el local variables
23869 integer :: iint,itypi,itypi1,itypj,subchap
23870 real(kind=8) :: rrij,xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
23871 real(kind=8) :: evdw,sig0ij
23872 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
23873 dist_temp, dist_init,aa,bb,ssgradlipi,ssgradlipj, &
23874 sslipi,sslipj,faclip
23876 real(kind=8) :: fracinbuf
23877 real (kind=8) :: epeppho
23878 real (kind=8),dimension(4):: ener
23879 real(kind=8) :: b1,b2,b3,b4,egb,eps_in,eps_inout_fac,eps_out
23880 real(kind=8) :: ECL,Elj,Equad,Epol,eheadtail,rhead,dGCLOM2,&
23881 sqom1,sqom2,sqom12,c1,c2,pom,Lambf,sparrow,&
23882 Chif,ChiLambf,bat,eagle,top,bot,botsq,Fcav,dtop,dFdR,dFdOM1,&
23883 dFdOM2,w1,w2,dGCLdR,dFdL,dFdOM12,dbot ,&
23884 r1,eps_head,alphapol1,pis,facd2,d2,facd1,d1,erdxj,erdxi,federmaus,&
23885 dPOLdR1,dFGBdOM2,dFGBdR1,dPOLdFGB1,RR1,MomoFac1,hawk,d1i,d1j,&
23886 sig1,sig2,chis12,chis2,ee1,fgb1,a12sq,chis1,Rhead_sq,Qij,dFGBdOM1
23887 real(kind=8),dimension(3,2)::chead,erhead_tail
23888 real(kind=8),dimension(3) :: Rhead_distance,ertail,erhead
23890 real (kind=8) :: dcosom1(3),dcosom2(3)
23892 ! do i=1,nres_molec(1)
23893 do i=ibond_start,ibond_end
23894 if (itype(i,1).eq.ntyp1_molec(1)) cycle
23896 dsci_inv = vbld_inv(i+1)/2.0
23900 xi=(c(1,i)+c(1,i+1))/2.0
23901 yi=(c(2,i)+c(2,i+1))/2.0
23902 zi=(c(3,i)+c(3,i+1))/2.0
23903 xi=mod(xi,boxxsize)
23904 if (xi.lt.0) xi=xi+boxxsize
23905 yi=mod(yi,boxysize)
23906 if (yi.lt.0) yi=yi+boxysize
23907 zi=mod(zi,boxzsize)
23908 if (zi.lt.0) zi=zi+boxzsize
23909 do j=nres_molec(1)+1,nres_molec(2)+nres_molec(1)-1
23911 if ((itype(j,2).eq.ntyp1_molec(2)).or.&
23912 (itype(j+1,2).eq.ntyp1_molec(2))) cycle
23913 xj=(c(1,j)+c(1,j+1))/2.0
23914 yj=(c(2,j)+c(2,j+1))/2.0
23915 zj=(c(3,j)+c(3,j+1))/2.0
23916 xj=dmod(xj,boxxsize)
23917 if (xj.lt.0) xj=xj+boxxsize
23918 yj=dmod(yj,boxysize)
23919 if (yj.lt.0) yj=yj+boxysize
23920 zj=dmod(zj,boxzsize)
23921 if (zj.lt.0) zj=zj+boxzsize
23922 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
23930 yj=yj_safe+yshift*boxysize
23931 zj=zj_safe+zshift*boxzsize
23932 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
23933 if(dist_temp.lt.dist_init) then
23934 dist_init=dist_temp
23943 if (subchap.eq.1) then
23952 rrij = 1.0D0 / ( xj*xj + yj*yj + zj*zj)
23954 dxj = dc_norm( 1,j )
23955 dyj = dc_norm( 2,j )
23956 dzj = dc_norm( 3,j )
23957 dscj_inv = vbld_inv(j+1)/2.0
23959 sig0ij = sigma_peppho
23962 chi12 = chi1 * chi2
23965 chip12 = chip1 * chip2
23968 chis12 = chis1 * chis2
23969 sig1 = sigmap1_peppho
23970 sig2 = sigmap2_peppho
23971 ! write (*,*) "sig1 = ", sig1
23972 ! write (*,*) "sig1 = ", sig1
23973 ! write (*,*) "sig2 = ", sig2
23974 ! alpha factors from Fcav/Gcav
23978 b1 = alphasur_peppho(1)
23980 b2 = alphasur_peppho(2)
23981 b3 = alphasur_peppho(3)
23982 b4 = alphasur_peppho(4)
24004 fac = rij_shift**expon
24005 c1 = fac * fac * aa_peppho
24007 c2 = fac * bb_peppho
24010 ! Now cavity....................
24011 eagle = dsqrt(1.0/rij_shift)
24012 top = b1 * ( eagle + b2 * 1.0/rij_shift - b3 )
24013 bot = 1.0d0 + b4 * (1.0/rij_shift ** 12.0d0)
24016 dtop = b1 * ((1.0/ (2.0d0 * eagle)) + (b2))
24017 dbot = 12.0d0 * b4 * (1.0/rij_shift) ** 11.0d0
24018 dFdR = ((dtop * bot - top * dbot) / botsq)
24019 w1 = wqdip_peppho(1)
24020 w2 = wqdip_peppho(2)
24023 ! pis = sig0head_scbase(itypi,itypj)
24024 ! eps_head = epshead_scbase(itypi,itypj)
24025 !c!-------------------------------------------------------------------
24027 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
24028 !c! & +dhead(1,1,itypi,itypj))**2))
24029 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
24030 !c! & +dhead(2,1,itypi,itypj))**2))
24032 !c!-------------------------------------------------------------------
24035 hawk = w2 * (1.0d0 - sqom1)
24036 Ecl = sparrow * rij_shift**2.0d0 &
24037 - hawk * rij_shift**4.0d0
24038 !c!-------------------------------------------------------------------
24039 !c! derivative of ecl is Gcl
24042 dGCLdR = - 2.0d0 * sparrow * rij_shift**3.0d0 &
24043 + 4.0d0 * hawk * rij_shift**5.0d0
24045 dGCLdOM1 = (w1) * (rij_shift**2.0d0)
24047 dGCLdOM2 = (2.0d0 * w2 * om1) * (rij_shift ** 4.0d0)
24048 eom1 = dGCLdOM1+dGCLdOM2
24051 fac = -expon * (c1 + evdwij) * rij_shift+dFdR+dGCLdR
24057 gvdwc_peppho(k,j) = gvdwc_peppho(k,j) +gg(k)/2.0
24058 gvdwc_peppho(k,j+1) = gvdwc_peppho(k,j+1) +gg(k)/2.0
24059 gvdwc_peppho(k,i) = gvdwc_peppho(k,i) -gg(k)/2.0
24060 gvdwc_peppho(k,i+1) = gvdwc_peppho(k,i+1) -gg(k)/2.0
24065 dcosom1(k) = rij* (dc_norm(k,i) - om1 * erij(k))
24066 dcosom2(k) = rij* (dc_norm(k,j) - om2 * erij(k))
24067 gg(k) = gg(k) + eom1 * dcosom1(k)! + eom2 * dcosom2(k)
24068 gvdwc_peppho(k,j)= gvdwc_peppho(k,j) +0.5*( gg(k)) !&
24069 ! - (eom2*(erij(k)-om2*dc_norm(k,j)))*dscj_inv*2.0
24070 gvdwc_peppho(k,j+1)= gvdwc_peppho(k,j+1) +0.5*( gg(k)) !&
24071 ! + (eom2*(erij(k)-om2*dc_norm(k,j)))*dscj_inv*2.0
24072 gvdwc_peppho(k,i)= gvdwc_peppho(k,i) -0.5*( gg(k)) &
24073 - (eom1*(erij(k)-om1*dc_norm(k,i)))*dsci_inv*2.0
24074 gvdwc_peppho(k,i+1)= gvdwc_peppho(k,i+1) - 0.5*( gg(k)) &
24075 + (eom1*(erij(k)-om1*dc_norm(k,i)))*dsci_inv*2.0
24077 epeppho=epeppho+evdwij+Fcav+ECL
24078 ! print *,i,j,evdwij,Fcav,ECL,rij_shift
24081 end subroutine eprot_pep_phosphate