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 ! real(kind=8),dimension(:,:),allocatable :: gloc,gloc_x !(maxvar,2)
134 real(kind=8),dimension(:,:),allocatable :: gel_loc,gel_loc_long,&
135 gcorr3_turn,gcorr4_turn,gcorr6_turn,gradb,gradbx !(3,maxres)
136 real(kind=8),dimension(:),allocatable :: gel_loc_loc,&
137 gel_loc_turn3,gel_loc_turn4,gel_loc_turn6,gcorr_loc,g_corr5_loc,&
138 g_corr6_loc !(maxvar)
139 real(kind=8),dimension(:,:),allocatable :: gsccorc,gsccorx !(3,maxres)
140 real(kind=8),dimension(:),allocatable :: gsccor_loc !(maxres)
141 ! real(kind=8),dimension(:,:,:),allocatable :: dtheta !(3,2,maxres)
142 real(kind=8),dimension(:,:),allocatable :: gscloc,gsclocx !(3,maxres)
143 ! real(kind=8),dimension(:,:,:),allocatable :: dphi,dalpha,domega !(3,3,maxres)
144 real(kind=8),dimension(:,:,:),allocatable :: grad_shield_side, &
145 grad_shield_loc ! (3,maxcontsshileding,maxnres)
148 real(kind=8), dimension(:),allocatable :: fac_shield
149 real(kind=8),dimension(3,5,2) :: derx,derx_turn
150 ! common /deriv_scloc/
151 real(kind=8),dimension(:,:),allocatable :: dXX_C1tab,dYY_C1tab,&
152 dZZ_C1tab,dXX_Ctab,dYY_Ctab,dZZ_Ctab,dXX_XYZtab,dYY_XYZtab,&
153 dZZ_XYZtab !(3,maxres)
154 !-----------------------------------------------------------------------------
157 real(kind=8) :: gvdwc_max,gvdwc_scp_max,gelc_max,gvdwpp_max,&
158 gradb_max,ghpbc_max,&
159 gradcorr_max,gel_loc_max,gcorr3_turn_max,gcorr4_turn_max,&
160 gradcorr5_max,gradcorr6_max,gcorr6_turn_max,gsccorc_max,&
161 gscloc_max,gvdwx_max,gradx_scp_max,ghpbx_max,gradxorr_max,&
162 gsccorx_max,gsclocx_max
163 !-----------------------------------------------------------------------------
165 ! common /back_constr/
166 real(kind=8),dimension(:),allocatable :: dutheta,dugamma !(maxres)
167 real(kind=8),dimension(:,:),allocatable :: duscdiff,duscdiffx !(3,maxres)
169 real(kind=8) :: Ucdfrag,Ucdpair
170 real(kind=8),dimension(:,:),allocatable :: dUdconst,dUdxconst,&
171 dqwol,dxqwol !(3,0:MAXRES)
172 !-----------------------------------------------------------------------------
174 ! common /dyn_ssbond/
175 real(kind=8),dimension(:,:),allocatable :: dyn_ssbond_ij !(maxres,maxres)
176 !-----------------------------------------------------------------------------
178 ! Parameters of the SCCOR term
180 real(kind=8),dimension(:,:,:,:),allocatable :: dcostau,dsintau,&
181 dcosomicron,domicron !(3,3,3,maxres2)
182 !-----------------------------------------------------------------------------
185 real(kind=8),dimension(:,:),allocatable :: uy,uz !(3,maxres)
186 real(kind=8),dimension(:,:,:,:),allocatable :: uygrad,uzgrad !(3,3,2,maxres)
187 !-----------------------------------------------------------------------------
188 ! common /przechowalnia/
189 real(kind=8),dimension(:,:,:),allocatable :: zapas
190 real(kind=8),dimension(:,:,:,:),allocatable ::zapas2 !(max_dim,maxconts,max_fg_procs)
191 real(kind=8),dimension(:,:,:),allocatable :: fromto !(3,3,maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
192 !-----------------------------------------------------------------------------
193 !-----------------------------------------------------------------------------
196 !-----------------------------------------------------------------------------
198 !-----------------------------------------------------------------------------
199 ! energy_p_new_barrier.F
200 !-----------------------------------------------------------------------------
201 subroutine etotal(energia)
202 ! implicit real*8 (a-h,o-z)
203 ! include 'DIMENSIONS'
208 !MS$ATTRIBUTES C :: proc_proc
214 ! include 'COMMON.SETUP'
215 ! include 'COMMON.IOUNITS'
216 real(kind=8),dimension(0:n_ene) :: energia
217 ! include 'COMMON.LOCAL'
218 ! include 'COMMON.FFIELD'
219 ! include 'COMMON.DERIV'
220 ! include 'COMMON.INTERACT'
221 ! include 'COMMON.SBRIDGE'
222 ! include 'COMMON.CHAIN'
223 ! include 'COMMON.VAR'
224 ! include 'COMMON.MD'
225 ! include 'COMMON.CONTROL'
226 ! include 'COMMON.TIME1'
227 real(kind=8) :: time00
229 integer :: n_corr,n_corr1,ierror
230 real(kind=8) :: etors,edihcnstr,etors_d,esccor,ehpb
231 real(kind=8) :: evdw,evdw1,evdw2,evdw2_14,escloc,ees,eel_loc
232 real(kind=8) :: eello_turn3,eello_turn4,estr,ebe,eliptran,etube, &
233 Eafmforce,ethetacnstr
234 real(kind=8) :: ecorr,ecorr5,ecorr6,eturn6
235 ! now energies for nulceic alone parameters
236 real(kind=8) :: evdwpp,eespp,evdwpsb,eelpsb,evdwsb,eelsb,estr_nucl,&
237 ebe_nucl,esbloc,etors_nucl,etors_d_nucl,ecorr_nucl,&
240 real(kind=8) :: weights_(n_ene) !,time_Bcast,time_Bcastw
241 ! shielding effect varibles for MPI
242 ! real(kind=8) fac_shieldbuf(maxres),
243 ! & grad_shield_locbuf(3,maxcontsshi,-1:maxres),
244 ! & grad_shield_sidebuf(3,maxcontsshi,-1:maxres),
245 ! & grad_shieldbuf(3,-1:maxres)
246 ! integer ishield_listbuf(maxres),
247 ! &shield_listbuf(maxcontsshi,maxres)
249 ! print*,"ETOTAL Processor",fg_rank," absolute rank",myrank,
250 ! & " nfgtasks",nfgtasks
251 if (nfgtasks.gt.1) then
253 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
254 if (fg_rank.eq.0) then
255 call MPI_Bcast(0,1,MPI_INTEGER,king,FG_COMM,IERROR)
256 ! print *,"Processor",myrank," BROADCAST iorder"
257 ! FG master sets up the WEIGHTS_ array which will be broadcast to the
258 ! FG slaves as WEIGHTS array.
278 weights_(26)=wvdwpp_nucl
284 weights_(32)=wbond_nucl
285 weights_(33)=wang_nucl
287 weights_(35)=wtor_nucl
288 weights_(36)=wtor_d_nucl
289 weights_(37)=wcorr_nucl
290 weights_(38)=wcorr3_nucl
292 ! FG Master broadcasts the WEIGHTS_ array
293 call MPI_Bcast(weights_(1),n_ene,&
294 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
296 ! FG slaves receive the WEIGHTS array
297 call MPI_Bcast(weights(1),n_ene,&
298 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
318 wvdwpp_nucl =weights(26)
324 wbond_nucl =weights(32)
325 wang_nucl =weights(33)
327 wtor_nucl =weights(35)
328 wtor_d_nucl =weights(36)
329 wcorr_nucl =weights(37)
330 wcorr3_nucl =weights(38)
333 time_Bcast=time_Bcast+MPI_Wtime()-time00
334 time_Bcastw=time_Bcastw+MPI_Wtime()-time00
335 ! call chainbuild_cart
337 ! print *,'Processor',myrank,' calling etotal ipot=',ipot
338 ! print *,'Processor',myrank,' nnt=',nnt,' nct=',nct
340 ! if (modecalc.eq.12.or.modecalc.eq.14) then
341 ! call int_from_cart1(.false.)
348 ! Compute the side-chain and electrostatic interaction energy
349 ! print *, "Before EVDW"
350 ! goto (101,102,103,104,105,106) ipot
352 ! Lennard-Jones potential.
356 !d print '(a)','Exit ELJcall el'
358 ! Lennard-Jones-Kihara potential (shifted).
359 ! 102 call eljk(evdw)
363 ! Berne-Pechukas potential (dilated LJ, angular dependence).
368 ! Gay-Berne potential (shifted LJ, angular dependence).
373 ! Gay-Berne-Vorobjev potential (shifted LJ, angular dependence).
374 ! 105 call egbv(evdw)
378 ! Soft-sphere potential
379 ! 106 call e_softsphere(evdw)
381 call e_softsphere(evdw)
383 ! Calculate electrostatic (H-bonding) energy of the main chain.
387 write(iout,*)"Wrong ipot"
392 ! print *,"after EGB"
394 if (shield_mode.eq.2) then
397 ! print *,"AFTER EGB",ipot,evdw
399 !mc Sep-06: egb takes care of dynamic ss bonds too
401 ! if (dyn_ss) call dyn_set_nss
402 ! print *,"Processor",myrank," computed USCSC"
408 time_vec=time_vec+MPI_Wtime()-time01
410 ! print *,"Processor",myrank," left VEC_AND_DERIV"
413 ! print *,"after ipot if", ipot
414 if (welec.gt.0d0.or.wvdwpp.gt.0d0.or.wel_loc.gt.0d0.or. &
415 wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0 &
416 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
417 .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
419 if (welec.gt.0d0.or.wel_loc.gt.0d0.or. &
420 wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0 &
421 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
422 .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
424 ! print *,"just befor eelec call"
425 call eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
426 ! write (iout,*) "ELEC calc"
435 ! write (iout,*) "Soft-spheer ELEC potential"
436 call eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,&
439 ! print *,"Processor",myrank," computed UELEC"
441 ! Calculate excluded-volume interaction energy between peptide groups
444 !elwrite(iout,*) "in etotal calc exc;luded",ipot
448 call escp(evdw2,evdw2_14)
454 ! write (iout,*) "Soft-sphere SCP potential"
455 call escp_soft_sphere(evdw2,evdw2_14)
457 ! write(iout,*) "in etotal before ebond",ipot
460 ! Calculate the bond-stretching energy
463 ! print *,"EBOND",estr
464 ! write(iout,*) "in etotal afer ebond",ipot
467 ! Calculate the disulfide-bridge and other energy and the contributions
468 ! from other distance constraints.
469 ! print *,'Calling EHPB'
471 !elwrite(iout,*) "in etotal afer edis",ipot
472 ! print *,'EHPB exitted succesfully.'
474 ! Calculate the virtual-bond-angle energy.
476 if (wang.gt.0d0) then
477 call ebend(ebe,ethetacnstr)
482 ! print *,"Processor",myrank," computed UB"
484 ! Calculate the SC local energy.
487 !elwrite(iout,*) "in etotal afer esc",ipot
488 ! print *,"Processor",myrank," computed USC"
490 ! Calculate the virtual-bond torsional energy.
492 !d print *,'nterm=',nterm
494 call etor(etors,edihcnstr)
499 ! print *,"Processor",myrank," computed Utor"
501 ! 6/23/01 Calculate double-torsional energy
503 !elwrite(iout,*) "in etotal",ipot
504 if (wtor_d.gt.0) then
509 ! print *,"Processor",myrank," computed Utord"
511 ! 21/5/07 Calculate local sicdechain correlation energy
513 if (wsccor.gt.0.0d0) then
514 call eback_sc_corr(esccor)
518 ! print *,"Processor",myrank," computed Usccorr"
520 ! 12/1/95 Multi-body terms
524 if ((wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 &
525 .or. wturn6.gt.0.0d0) .and. ipot.lt.6) then
526 call multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
527 !d write(2,*)'multibody_eello n_corr=',n_corr,' n_corr1=',n_corr1,
528 !d &" ecorr",ecorr," ecorr5",ecorr5," ecorr6",ecorr6," eturn6",eturn6
535 !elwrite(iout,*) "in etotal",ipot
536 if ((wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) .and. ipot.lt.6) then
537 call multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
538 !d write (iout,*) "multibody_hb ecorr",ecorr
540 !elwrite(iout,*) "afeter multibody hb"
542 ! print *,"Processor",myrank," computed Ucorr"
544 ! If performing constraint dynamics, call the constraint energy
545 ! after the equilibration time
546 if(usampl.and.totT.gt.eq_time) then
547 !elwrite(iout,*) "afeter multibody hb"
549 !elwrite(iout,*) "afeter multibody hb"
551 !elwrite(iout,*) "afeter multibody hb"
557 ! write(iout,*) "after Econstr"
559 if (wliptran.gt.0) then
560 ! print *,"PRZED WYWOLANIEM"
561 call Eliptransfer(eliptran)
565 if (fg_rank.eq.0) then
566 if (AFMlog.gt.0) then
567 call AFMforce(Eafmforce)
568 else if (selfguide.gt.0) then
569 call AFMvel(Eafmforce)
572 if (tubemode.eq.1) then
574 else if (tubemode.eq.2) then
575 call calctube2(etube)
576 elseif (tubemode.eq.3) then
581 !--------------------------------------------------------
582 ! print *,"before",ees,evdw1,ecorr
583 call ebond_nucl(estr_nucl)
584 call ebend_nucl(ebe_nucl)
585 call etor_nucl(etors_nucl)
586 call esb_gb(evdwsb,eelsb)
587 call epp_nucl_sub(evdwpp,eespp)
588 call epsb(evdwpsb,eelpsb)
590 call multibody_hb_nucl(ecorr_nucl,ecorr3_nucl,n_corr,n_corr1)
592 ! print *,"after ebend", ebe_nucl
594 time_enecalc=time_enecalc+MPI_Wtime()-time00
596 ! print *,"Processor",myrank," computed Uconstr"
605 energia(2)=evdw2-evdw2_14
622 energia(8)=eello_turn3
623 energia(9)=eello_turn4
630 energia(19)=edihcnstr
632 energia(20)=Uconst+Uconst_back
635 energia(23)=Eafmforce
636 energia(24)=ethetacnstr
638 !---------------------------------------------------------------
645 energia(32)=estr_nucl
648 energia(35)=etors_nucl
649 energia(36)=etors_d_nucl
650 energia(37)=ecorr_nucl
651 energia(38)=ecorr3_nucl
652 !----------------------------------------------------------------------
653 ! Here are the energies showed per procesor if the are more processors
654 ! per molecule then we sum it up in sum_energy subroutine
655 ! print *," Processor",myrank," calls SUM_ENERGY"
656 call sum_energy(energia,.true.)
657 if (dyn_ss) call dyn_set_nss
658 ! print *," Processor",myrank," left SUM_ENERGY"
660 time_sumene=time_sumene+MPI_Wtime()-time00
662 !el call enerprint(energia)
663 !elwrite(iout,*)"finish etotal"
665 end subroutine etotal
666 !-----------------------------------------------------------------------------
667 subroutine sum_energy(energia,reduce)
668 ! implicit real*8 (a-h,o-z)
669 ! include 'DIMENSIONS'
673 !MS$ATTRIBUTES C :: proc_proc
679 ! include 'COMMON.SETUP'
680 ! include 'COMMON.IOUNITS'
681 real(kind=8) :: energia(0:n_ene),enebuff(0:n_ene+1)
682 ! include 'COMMON.FFIELD'
683 ! include 'COMMON.DERIV'
684 ! include 'COMMON.INTERACT'
685 ! include 'COMMON.SBRIDGE'
686 ! include 'COMMON.CHAIN'
687 ! include 'COMMON.VAR'
688 ! include 'COMMON.CONTROL'
689 ! include 'COMMON.TIME1'
691 real(kind=8) :: evdw,evdw2,evdw2_14,ees,evdw1,ecorr,ecorr5,ecorr6
692 real(kind=8) :: eel_loc,eello_turn3,eello_turn4,eturn6,ebe,escloc
693 real(kind=8) :: etors,etors_d,ehpb,edihcnstr,estr,esccor,etot, &
694 eliptran,etube, Eafmforce,ethetacnstr
695 real(kind=8) :: evdwpp,eespp,evdwpsb,eelpsb,evdwsb,eelsb,estr_nucl,&
696 ebe_nucl,esbloc,etors_nucl,etors_d_nucl,ecorr_nucl,&
702 real(kind=8) :: time00
703 if (nfgtasks.gt.1 .and. reduce) then
706 write (iout,*) "energies before REDUCE"
707 call enerprint(energia)
711 enebuff(i)=energia(i)
714 call MPI_Barrier(FG_COMM,IERR)
715 time_barrier_e=time_barrier_e+MPI_Wtime()-time00
717 call MPI_Reduce(enebuff(0),energia(0),n_ene+1,&
718 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
720 write (iout,*) "energies after REDUCE"
721 call enerprint(energia)
724 time_Reduce=time_Reduce+MPI_Wtime()-time00
726 if (fg_rank.eq.0) then
730 evdw2=energia(2)+energia(18)
746 eello_turn3=energia(8)
747 eello_turn4=energia(9)
754 edihcnstr=energia(19)
759 Eafmforce=energia(23)
760 ethetacnstr=energia(24)
768 estr_nucl=energia(32)
771 etors_nucl=energia(35)
772 etors_d_nucl=energia(36)
773 ecorr_nucl=energia(37)
774 ecorr3_nucl=energia(38)
778 etot=wsc*evdw+wscp*evdw2+welec*ees+wvdwpp*evdw1 &
779 +wang*ebe+wtor*etors+wscloc*escloc &
780 +wstrain*ehpb+wcorr*ecorr+wcorr5*ecorr5 &
781 +wcorr6*ecorr6+wturn4*eello_turn4+wturn3*eello_turn3 &
782 +wturn6*eturn6+wel_loc*eel_loc+edihcnstr+wtor_d*etors_d &
783 +wbond*estr+Uconst+wsccor*esccor+wliptran*eliptran+wtube*etube&
784 +Eafmforce+ethetacnstr &
785 +wbond_nucl*estr_nucl+wang_nucl*ebe_nucl&
786 +wvdwpp_nucl*evdwpp+welpp*eespp+wvdwpsb*evdwpsb+welpsb*eelpsb&
787 +wvdwsb*evdwsb+welsb*eelsb+wsbloc*esbloc+wtor_nucl*etors_nucl&
788 +wtor_d_nucl*etors_d_nucl+wcorr_nucl*ecorr_nucl+wcorr3_nucl*ecorr3_nucl
790 etot=wsc*evdw+wscp*evdw2+welec*(ees+evdw1) &
791 +wang*ebe+wtor*etors+wscloc*escloc &
792 +wstrain*ehpb+wcorr*ecorr+wcorr5*ecorr5 &
793 +wcorr6*ecorr6+wturn4*eello_turn4+wturn3*eello_turn3 &
794 +wturn6*eturn6+wel_loc*eel_loc+edihcnstr+wtor_d*etors_d &
795 +wbond*estr+Uconst+wsccor*esccor+wliptran*eliptran+wtube*etube&
796 +Eafmforce+ethetacnstr &
797 +wbond_nucl*estr_nucl+wang_nucl*ebe_nucl&
798 +wvdwpp_nucl*evdwpp+welpp*eespp+wvdwpsb*evdwpsb+welpsb*eelpsb&
799 +wvdwsb*evdwsb+welsb*eelsb+wsbloc*esbloc+wtor_nucl*etors_nucl&
800 +wtor_d_nucl*etors_d_nucl+wcorr_nucl*ecorr_nucl+wcorr3_nucl*ecorr3_nucl
806 if (isnan(etot).ne.0) energia(0)=1.0d+99
808 if (isnan(etot)) energia(0)=1.0d+99
813 idumm=proc_proc(etot,i)
815 call proc_proc(etot,i)
817 if(i.eq.1)energia(0)=1.0d+99
822 ! call enerprint(energia)
825 end subroutine sum_energy
826 !-----------------------------------------------------------------------------
827 subroutine rescale_weights(t_bath)
828 ! implicit real*8 (a-h,o-z)
832 ! include 'DIMENSIONS'
833 ! include 'COMMON.IOUNITS'
834 ! include 'COMMON.FFIELD'
835 ! include 'COMMON.SBRIDGE'
836 real(kind=8) :: kfac=2.4d0
837 real(kind=8) :: x,x2,x3,x4,x5,licznik=1.12692801104297249644
839 real(kind=8) :: t_bath,facT(6) !,facT2,facT3,facT4,facT5,facT6
840 real(kind=8) :: T0=3.0d2
843 ! facT=2*temp0/(t_bath+temp0)
844 if (rescale_mode.eq.0) then
851 else if (rescale_mode.eq.1) then
852 facT(1)=kfac/(kfac-1.0d0+t_bath/temp0)
853 facT(2)=kfac**2/(kfac**2-1.0d0+(t_bath/temp0)**2)
854 facT(3)=kfac**3/(kfac**3-1.0d0+(t_bath/temp0)**3)
855 facT(4)=kfac**4/(kfac**4-1.0d0+(t_bath/temp0)**4)
856 facT(5)=kfac**5/(kfac**5-1.0d0+(t_bath/temp0)**5)
858 !#if defined(WHAM_RUN) || defined(CLUSTER)
860 ! tt = 1.0d0/(beta_h(ib,ipar)*1.987D-3)
861 facT(6)=(320.0+80.0*dtanh((t_bath-320.0)/80.0))/320.0
868 else if (rescale_mode.eq.2) then
874 facT(1)=licznik/dlog(dexp(x)+dexp(-x))
875 facT(2)=licznik/dlog(dexp(x2)+dexp(-x2))
876 facT(3)=licznik/dlog(dexp(x3)+dexp(-x3))
877 facT(4)=licznik/dlog(dexp(x4)+dexp(-x4))
878 facT(5)=licznik/dlog(dexp(x5)+dexp(-x5))
880 !#if defined(WHAM_RUN) || defined(CLUSTER)
882 facT(6)=(320.0+80.0*dtanh((t_bath-320.0)/80.0))/320.0
890 write (iout,*) "Wrong RESCALE_MODE",rescale_mode
891 write (*,*) "Wrong RESCALE_MODE",rescale_mode
893 call MPI_Finalize(MPI_COMM_WORLD,IERROR)
897 welec=weights(3)*fact(1)
898 wcorr=weights(4)*fact(3)
899 wcorr5=weights(5)*fact(4)
900 wcorr6=weights(6)*fact(5)
901 wel_loc=weights(7)*fact(2)
902 wturn3=weights(8)*fact(2)
903 wturn4=weights(9)*fact(3)
904 wturn6=weights(10)*fact(5)
905 wtor=weights(13)*fact(1)
906 wtor_d=weights(14)*fact(2)
907 wsccor=weights(21)*fact(1)
910 end subroutine rescale_weights
911 !-----------------------------------------------------------------------------
912 subroutine enerprint(energia)
913 ! implicit real*8 (a-h,o-z)
914 ! include 'DIMENSIONS'
915 ! include 'COMMON.IOUNITS'
916 ! include 'COMMON.FFIELD'
917 ! include 'COMMON.SBRIDGE'
918 ! include 'COMMON.MD'
919 real(kind=8) :: energia(0:n_ene)
921 real(kind=8) :: etot,evdw,evdw2,ees,evdw1,ecorr,ecorr5,ecorr6,eel_loc
922 real(kind=8) :: eello_turn6,eello_turn3,eello_turn4,ebe,escloc
923 real(kind=8) :: etors,etors_d,ehpb,edihcnstr,estr,Uconst,esccor,eliptran,&
924 etube,ethetacnstr,Eafmforce
925 real(kind=8) :: evdwpp,eespp,evdwpsb,eelpsb,evdwsb,eelsb,estr_nucl,&
926 ebe_nucl,esbloc,etors_nucl,etors_d_nucl,ecorr_nucl,&
933 evdw2=energia(2)+energia(18)
945 eello_turn3=energia(8)
946 eello_turn4=energia(9)
947 eello_turn6=energia(10)
953 edihcnstr=energia(19)
958 Eafmforce=energia(23)
959 ethetacnstr=energia(24)
967 estr_nucl=energia(32)
970 etors_nucl=energia(35)
971 etors_d_nucl=energia(36)
972 ecorr_nucl=energia(37)
973 ecorr3_nucl=energia(38)
976 write (iout,10) evdw,wsc,evdw2,wscp,ees,welec,evdw1,wvdwpp,&
977 estr,wbond,ebe,wang,&
978 escloc,wscloc,etors,wtor,etors_d,wtor_d,ehpb,wstrain,&
980 ecorr5,wcorr5,ecorr6,wcorr6,eel_loc,wel_loc,eello_turn3,wturn3,&
981 eello_turn4,wturn4,eello_turn6,wturn6,esccor,wsccor,&
982 edihcnstr,ethetacnstr,ebr*nss,&
983 Uconst,eliptran,wliptran,Eafmforce,etube,wtube, & ! till now protein
984 estr_nucl,wbond_nucl,ebe_nucl,wang_nucl, &
985 evdwpp,wvdwpp_nucl,eespp,welpp,evdwpsb,wvdwpsb,eelpsb,welpsb,&
986 evdwsb,wvdwsb,eelsb,welsb,esbloc,wsbloc,etors_nucl,wtor_nucl,&
987 etors_d_nucl,wtor_d_nucl,ecorr_nucl,wcorr_nucl,&
988 ecorr3_nucl,wcorr3_nucl, &
990 10 format (/'Virtual-chain energies:'// &
991 'EVDW= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-SC)'/ &
992 'EVDW2= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-p)'/ &
993 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p)'/ &
994 'EVDWPP=',1pE16.6,' WEIGHT=',1pD16.6,' (p-p VDW)'/ &
995 'ESTR= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching)'/ &
996 'EBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (bending)'/ &
997 'ESC= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/ &
998 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/ &
999 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/ &
1000 'EHBP= ',1pE16.6,' WEIGHT=',1pD16.6, &
1001 ' (SS bridges & dist. cnstr.)'/ &
1002 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
1003 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
1004 'ECORR6=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
1005 'EELLO= ',1pE16.6,' WEIGHT=',1pD16.6,' (electrostatic-local)'/ &
1006 'ETURN3=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 3rd order)'/ &
1007 'ETURN4=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 4th order)'/ &
1008 'ETURN6=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 6th order)'/ &
1009 'ESCCOR=',1pE16.6,' WEIGHT=',1pD16.6,' (backbone-rotamer corr)'/ &
1010 'EDIHC= ',1pE16.6,' (dihedral angle constraints)'/ &
1011 'ETHETC= ',1pE16.6,' (valence angle constraints)'/ &
1012 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/ &
1013 'UCONST= ',1pE16.6,' (Constraint energy)'/ &
1014 'ELT=',1pE16.6, ' WEIGHT=',1pD16.6,' (Lipid transfer energy)'/&
1015 'EAFM= ',1pE16.6,' (atomic-force microscopy)'/ &
1016 'ETUBE=',1pE16.6, ' WEIGHT=',1pD16.6,' (cylindrical energy)'/ &
1017 'ESTR_nucl=',1pE16.6,' WEIGHT=',1pD16.6,' (stretching for nucleic)'/ &
1018 'EBE_nucl=',1pE16.6,' WEIGHT=',1pD16.6,' (bending for nucleic)'/ &
1019 'EVDW_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-phosphate VDW)'/ &
1020 'EESPP_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-phosphate elec)'/ &
1021 'EVDWPSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-sugarbase VDW)'/ &
1022 'EESPSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-sugarbase elec)'/ &
1023 'EVDWSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(sugarbase-sugarbase VDW)'/ &
1024 'EESSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(sugarbase-sugarbase elec)'/ &
1025 'ESBLOC_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(sugarbase rotamer)'/ &
1026 'ETORS_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(torsional)'/ &
1027 'ETORSD_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(double torsional)'/ &
1028 'ECORR_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(multibody 4th order)'/ &
1029 'ECORR3_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(multibody 3th order)'/ &
1030 'ETOT= ',1pE16.6,' (total)')
1032 write (iout,10) evdw,wsc,evdw2,wscp,ees,welec,&
1033 estr,wbond,ebe,wang,&
1034 escloc,wscloc,etors,wtor,etors_d,wtor_d,ehpb,wstrain,&
1036 ecorr5,wcorr5,ecorr6,wcorr6,eel_loc,wel_loc,eello_turn3,wturn3,&
1037 eello_turn4,wturn4,eello_turn6,wturn6,esccor,wsccor,edihcnstr,&
1038 ethetacnstr,ebr*nss,Uconst,eliptran,wliptran,Eafmforc, &
1040 estr_nucl,wbond_nucl, ebe_nucl,wang_nucl,&
1041 evdwpp,wvdwpp_nucl,eespp,welpp,evdwpsb,wvdwpsb,eelpsb,welpsb&
1042 evdwsb,wvdwsb,eelsb,welsb,esbloc,wsbloc,etors_nucl,wtor_nucl&
1043 etors_d_nucl,wtor_d_nucl,ecorr_nucl,wcorr_nucl,&
1044 ecorr3_nucl,wcorr3_nucl, &
1046 10 format (/'Virtual-chain energies:'// &
1047 'EVDW= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-SC)'/ &
1048 'EVDW2= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-p)'/ &
1049 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p)'/ &
1050 'ESTR= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching)'/ &
1051 'EBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (bending)'/ &
1052 'ESC= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/ &
1053 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/ &
1054 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/ &
1055 'EHBP= ',1pE16.6,' WEIGHT=',1pD16.6, &
1056 ' (SS bridges & dist. cnstr.)'/ &
1057 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
1058 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
1059 'ECORR6=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
1060 'EELLO= ',1pE16.6,' WEIGHT=',1pD16.6,' (electrostatic-local)'/ &
1061 'ETURN3=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 3rd order)'/ &
1062 'ETURN4=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 4th order)'/ &
1063 'ETURN6=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 6th order)'/ &
1064 'ESCCOR=',1pE16.6,' WEIGHT=',1pD16.6,' (backbone-rotamer corr)'/ &
1065 'EDIHC= ',1pE16.6,' (dihedral angle constraints)'/ &
1066 'ETHETC= ',1pE16.6,' (valence angle constraints)'/ &
1067 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/ &
1068 'UCONST=',1pE16.6,' (Constraint energy)'/ &
1069 'ELT=',1pE16.6, ' WEIGHT=',1pD16.6,' (Lipid transfer energy)'/ &
1070 'EAFM= ',1pE16.6,' (atomic-force microscopy)'/ &
1071 'ETUBE=',1pE16.6, ' WEIGHT=',1pD16.6,' (cylindrical energy)'/ &
1072 'ESTR_nucl= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching for nucleic)'/ &
1073 'EBE_nucl=',1pE16.6,' WEIGHT=',1pD16.6,' (bending for nucleic)'/ &
1074 'EVDW_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-phosphate VDW)'/ &
1075 'EESPP_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-phosphate elec)'/ &
1076 'EVDWPSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-sugarbase VDW)'/ &
1077 'EESPSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-sugarbase elec)'/ &
1078 'EVDWSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(sugarbase-sugarbase VDW)'/ &
1079 'EESSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(sugarbase-sugarbase elec)'/ &
1080 'ESBLOC_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(sugarbase rotamer)'/ &
1081 'ETORS_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(torsional)'/ &
1082 'ETORSD_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(double torsional)'/ &
1083 'ECORR_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(multibody 4th order)'/ &
1084 'ECORR3_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(multibody 3th order)'/ &
1085 'ETOT= ',1pE16.6,' (total)')
1088 end subroutine enerprint
1089 !-----------------------------------------------------------------------------
1090 subroutine elj(evdw)
1092 ! This subroutine calculates the interaction energy of nonbonded side chains
1093 ! assuming the LJ potential of interaction.
1095 ! implicit real*8 (a-h,o-z)
1096 ! include 'DIMENSIONS'
1097 real(kind=8),parameter :: accur=1.0d-10
1098 ! include 'COMMON.GEO'
1099 ! include 'COMMON.VAR'
1100 ! include 'COMMON.LOCAL'
1101 ! include 'COMMON.CHAIN'
1102 ! include 'COMMON.DERIV'
1103 ! include 'COMMON.INTERACT'
1104 ! include 'COMMON.TORSION'
1105 ! include 'COMMON.SBRIDGE'
1106 ! include 'COMMON.NAMES'
1107 ! include 'COMMON.IOUNITS'
1108 ! include 'COMMON.CONTACTS'
1109 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
1110 integer :: num_conti
1112 integer :: i,itypi,iint,j,itypi1,itypj,k
1113 real(kind=8) :: rij,rcut,fcont,fprimcont,rrij
1114 real(kind=8) :: evdw,xi,yi,zi,xj,yj,zj
1115 real(kind=8) :: eps0ij,fac,e1,e2,evdwij,sigij,r0ij
1117 ! write(iout,*)'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
1119 ! allocate(num_cont(iatsc_s:iatsc_e)) !(maxres) nnt,nct-2
1120 ! allocate(jcont(nres/4,iatsc_s:iatsc_e)) !(maxconts,maxres) (maxconts=maxres/4)
1121 ! allocate(facont(nres/4,iatsc_s:iatsc_e)) !(maxconts,maxres)
1122 ! allocate(gacont(3,nres/4,iatsc_s:iatsc_e)) !(3,maxconts,maxres)
1124 do i=iatsc_s,iatsc_e
1125 itypi=iabs(itype(i,1))
1126 if (itypi.eq.ntyp1) cycle
1127 itypi1=iabs(itype(i+1,1))
1134 ! Calculate SC interaction energy.
1136 do iint=1,nint_gr(i)
1137 !d write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
1138 !d & 'iend=',iend(i,iint)
1139 do j=istart(i,iint),iend(i,iint)
1140 itypj=iabs(itype(j,1))
1141 if (itypj.eq.ntyp1) cycle
1145 ! Change 12/1/95 to calculate four-body interactions
1146 rij=xj*xj+yj*yj+zj*zj
1148 ! write (iout,*)'i=',i,' j=',j,' itypi=',itypi,' itypj=',itypj
1149 eps0ij=eps(itypi,itypj)
1151 e1=fac*fac*aa_aq(itypi,itypj)
1152 e2=fac*bb_aq(itypi,itypj)
1154 !d sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1155 !d epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1156 !d write (iout,'(2(a3,i3,2x),6(1pd12.4)/2(3(1pd12.4),5x)/)')
1157 !d & restyp(itypi,1),i,restyp(itypj,1),j,aa(itypi,itypj),
1158 !d & bb(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,epsi,sigm,
1159 !d & (c(k,i),k=1,3),(c(k,j),k=1,3)
1162 ! Calculate the components of the gradient in DC and X
1164 fac=-rrij*(e1+evdwij)
1169 gvdwx(k,i)=gvdwx(k,i)-gg(k)
1170 gvdwx(k,j)=gvdwx(k,j)+gg(k)
1171 gvdwc(k,i)=gvdwc(k,i)-gg(k)
1172 gvdwc(k,j)=gvdwc(k,j)+gg(k)
1176 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
1180 ! 12/1/95, revised on 5/20/97
1182 ! Calculate the contact function. The ith column of the array JCONT will
1183 ! contain the numbers of atoms that make contacts with the atom I (of numbers
1184 ! greater than I). The arrays FACONT and GACONT will contain the values of
1185 ! the contact function and its derivative.
1187 ! Uncomment next line, if the correlation interactions include EVDW explicitly.
1188 ! if (j.gt.i+1 .and. evdwij.le.0.0D0) then
1189 ! Uncomment next line, if the correlation interactions are contact function only
1190 if (j.gt.i+1.and. eps0ij.gt.0.0D0) then
1192 sigij=sigma(itypi,itypj)
1193 r0ij=rs0(itypi,itypj)
1195 ! Check whether the SC's are not too far to make a contact.
1198 call gcont(rij,rcut,1.0d0,0.2d0*rcut,fcont,fprimcont)
1199 ! Add a new contact, if the SC's are close enough, but not too close (r<sigma).
1201 if (fcont.gt.0.0D0) then
1202 ! If the SC-SC distance if close to sigma, apply spline.
1203 !Adam call gcont(-rij,-1.03d0*sigij,2.0d0*sigij,1.0d0,
1204 !Adam & fcont1,fprimcont1)
1205 !Adam fcont1=1.0d0-fcont1
1206 !Adam if (fcont1.gt.0.0d0) then
1207 !Adam fprimcont=fprimcont*fcont1+fcont*fprimcont1
1208 !Adam fcont=fcont*fcont1
1210 ! Uncomment following 4 lines to have the geometric average of the epsilon0's
1211 !ga eps0ij=1.0d0/dsqrt(eps0ij)
1213 !ga gg(k)=gg(k)*eps0ij
1215 !ga eps0ij=-evdwij*eps0ij
1216 ! Uncomment for AL's type of SC correlation interactions.
1217 !adam eps0ij=-evdwij
1218 num_conti=num_conti+1
1219 jcont(num_conti,i)=j
1220 facont(num_conti,i)=fcont*eps0ij
1221 fprimcont=eps0ij*fprimcont/rij
1223 !Adam gacont(1,num_conti,i)=-fprimcont*xj+fcont*gg(1)
1224 !Adam gacont(2,num_conti,i)=-fprimcont*yj+fcont*gg(2)
1225 !Adam gacont(3,num_conti,i)=-fprimcont*zj+fcont*gg(3)
1226 ! Uncomment following 3 lines for Skolnick's type of SC correlation.
1227 gacont(1,num_conti,i)=-fprimcont*xj
1228 gacont(2,num_conti,i)=-fprimcont*yj
1229 gacont(3,num_conti,i)=-fprimcont*zj
1230 !d write (iout,'(2i5,2f10.5)') i,j,rij,facont(num_conti,i)
1231 !d write (iout,'(2i3,3f10.5)')
1232 !d & i,j,(gacont(kk,num_conti,i),kk=1,3)
1238 num_cont(i)=num_conti
1242 gvdwc(j,i)=expon*gvdwc(j,i)
1243 gvdwx(j,i)=expon*gvdwx(j,i)
1246 !******************************************************************************
1250 ! To save time, the factor of EXPON has been extracted from ALL components
1251 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
1254 !******************************************************************************
1257 !-----------------------------------------------------------------------------
1258 subroutine eljk(evdw)
1260 ! This subroutine calculates the interaction energy of nonbonded side chains
1261 ! assuming the LJK potential of interaction.
1263 ! implicit real*8 (a-h,o-z)
1264 ! include 'DIMENSIONS'
1265 ! include 'COMMON.GEO'
1266 ! include 'COMMON.VAR'
1267 ! include 'COMMON.LOCAL'
1268 ! include 'COMMON.CHAIN'
1269 ! include 'COMMON.DERIV'
1270 ! include 'COMMON.INTERACT'
1271 ! include 'COMMON.IOUNITS'
1272 ! include 'COMMON.NAMES'
1273 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
1276 integer :: i,iint,j,itypi,itypi1,k,itypj
1277 real(kind=8) :: rrij,xi,yi,zi,xj,yj,zj,fac_augm,e_augm,r_inv_ij
1278 real(kind=8) :: evdw,rij,r_shift_inv,fac,e1,e2,evdwij
1280 ! print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
1282 do i=iatsc_s,iatsc_e
1283 itypi=iabs(itype(i,1))
1284 if (itypi.eq.ntyp1) cycle
1285 itypi1=iabs(itype(i+1,1))
1290 ! Calculate SC interaction energy.
1292 do iint=1,nint_gr(i)
1293 do j=istart(i,iint),iend(i,iint)
1294 itypj=iabs(itype(j,1))
1295 if (itypj.eq.ntyp1) cycle
1299 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1300 fac_augm=rrij**expon
1301 e_augm=augm(itypi,itypj)*fac_augm
1302 r_inv_ij=dsqrt(rrij)
1304 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
1305 fac=r_shift_inv**expon
1306 e1=fac*fac*aa_aq(itypi,itypj)
1307 e2=fac*bb_aq(itypi,itypj)
1309 !d sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1310 !d epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1311 !d write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
1312 !d & restyp(itypi,1),i,restyp(itypj,1),j,aa(itypi,itypj),
1313 !d & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
1314 !d & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
1315 !d & (c(k,i),k=1,3),(c(k,j),k=1,3)
1318 ! Calculate the components of the gradient in DC and X
1320 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
1325 gvdwx(k,i)=gvdwx(k,i)-gg(k)
1326 gvdwx(k,j)=gvdwx(k,j)+gg(k)
1327 gvdwc(k,i)=gvdwc(k,i)-gg(k)
1328 gvdwc(k,j)=gvdwc(k,j)+gg(k)
1332 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
1340 gvdwc(j,i)=expon*gvdwc(j,i)
1341 gvdwx(j,i)=expon*gvdwx(j,i)
1346 !-----------------------------------------------------------------------------
1347 subroutine ebp(evdw)
1349 ! This subroutine calculates the interaction energy of nonbonded side chains
1350 ! assuming the Berne-Pechukas potential of interaction.
1354 ! implicit real*8 (a-h,o-z)
1355 ! include 'DIMENSIONS'
1356 ! include 'COMMON.GEO'
1357 ! include 'COMMON.VAR'
1358 ! include 'COMMON.LOCAL'
1359 ! include 'COMMON.CHAIN'
1360 ! include 'COMMON.DERIV'
1361 ! include 'COMMON.NAMES'
1362 ! include 'COMMON.INTERACT'
1363 ! include 'COMMON.IOUNITS'
1364 ! include 'COMMON.CALC'
1366 !el integer :: icall
1367 !el common /srutu/ icall
1368 ! double precision rrsave(maxdim)
1371 integer :: iint,itypi,itypi1,itypj
1372 real(kind=8) :: rrij,xi,yi,zi
1373 real(kind=8) :: evdw,fac,e1,e2,sigm,epsi
1375 ! print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
1377 ! if (icall.eq.0) then
1383 do i=iatsc_s,iatsc_e
1384 itypi=iabs(itype(i,1))
1385 if (itypi.eq.ntyp1) cycle
1386 itypi1=iabs(itype(i+1,1))
1390 dxi=dc_norm(1,nres+i)
1391 dyi=dc_norm(2,nres+i)
1392 dzi=dc_norm(3,nres+i)
1393 ! dsci_inv=dsc_inv(itypi)
1394 dsci_inv=vbld_inv(i+nres)
1396 ! Calculate SC interaction energy.
1398 do iint=1,nint_gr(i)
1399 do j=istart(i,iint),iend(i,iint)
1401 itypj=iabs(itype(j,1))
1402 if (itypj.eq.ntyp1) cycle
1403 ! dscj_inv=dsc_inv(itypj)
1404 dscj_inv=vbld_inv(j+nres)
1405 chi1=chi(itypi,itypj)
1406 chi2=chi(itypj,itypi)
1413 alf12=0.5D0*(alf1+alf2)
1414 ! For diagnostics only!!!
1427 dxj=dc_norm(1,nres+j)
1428 dyj=dc_norm(2,nres+j)
1429 dzj=dc_norm(3,nres+j)
1430 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1431 !d if (icall.eq.0) then
1437 ! Calculate the angle-dependent terms of energy & contributions to derivatives.
1439 ! Calculate whole angle-dependent part of epsilon and contributions
1440 ! to its derivatives
1441 fac=(rrij*sigsq)**expon2
1442 e1=fac*fac*aa_aq(itypi,itypj)
1443 e2=fac*bb_aq(itypi,itypj)
1444 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
1445 eps2der=evdwij*eps3rt
1446 eps3der=evdwij*eps2rt
1447 evdwij=evdwij*eps2rt*eps3rt
1450 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
1451 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
1452 !d write (iout,'(2(a3,i3,2x),15(0pf7.3))')
1453 !d & restyp(itypi,1),i,restyp(itypj,1),j,
1454 !d & epsi,sigm,chi1,chi2,chip1,chip2,
1455 !d & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
1456 !d & om1,om2,om12,1.0D0/dsqrt(rrij),
1459 ! Calculate gradient components.
1460 e1=e1*eps1*eps2rt**2*eps3rt**2
1461 fac=-expon*(e1+evdwij)
1464 ! Calculate radial part of the gradient
1468 ! Calculate the angular part of the gradient and sum add the contributions
1469 ! to the appropriate components of the Cartesian gradient.
1477 !-----------------------------------------------------------------------------
1478 subroutine egb(evdw)
1480 ! This subroutine calculates the interaction energy of nonbonded side chains
1481 ! assuming the Gay-Berne potential of interaction.
1484 ! implicit real*8 (a-h,o-z)
1485 ! include 'DIMENSIONS'
1486 ! include 'COMMON.GEO'
1487 ! include 'COMMON.VAR'
1488 ! include 'COMMON.LOCAL'
1489 ! include 'COMMON.CHAIN'
1490 ! include 'COMMON.DERIV'
1491 ! include 'COMMON.NAMES'
1492 ! include 'COMMON.INTERACT'
1493 ! include 'COMMON.IOUNITS'
1494 ! include 'COMMON.CALC'
1495 ! include 'COMMON.CONTROL'
1496 ! include 'COMMON.SBRIDGE'
1499 integer :: iint,itypi,itypi1,itypj,subchap
1500 real(kind=8) :: rrij,xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
1501 real(kind=8) :: evdw,sig0ij
1502 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
1503 dist_temp, dist_init,aa,bb,ssgradlipi,ssgradlipj, &
1504 sslipi,sslipj,faclip
1506 real(kind=8) :: fracinbuf
1508 !cccc energy_dec=.false.
1509 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
1512 ! if (icall.eq.0) lprn=.false.
1514 do i=iatsc_s,iatsc_e
1515 !C print *,"I am in EVDW",i
1516 itypi=iabs(itype(i,1))
1517 ! if (i.ne.47) cycle
1518 if (itypi.eq.ntyp1) cycle
1519 itypi1=iabs(itype(i+1,1))
1523 xi=dmod(xi,boxxsize)
1524 if (xi.lt.0) xi=xi+boxxsize
1525 yi=dmod(yi,boxysize)
1526 if (yi.lt.0) yi=yi+boxysize
1527 zi=dmod(zi,boxzsize)
1528 if (zi.lt.0) zi=zi+boxzsize
1530 if ((zi.gt.bordlipbot) &
1531 .and.(zi.lt.bordliptop)) then
1532 !C the energy transfer exist
1533 if (zi.lt.buflipbot) then
1534 !C what fraction I am in
1536 ((zi-bordlipbot)/lipbufthick)
1537 !C lipbufthick is thickenes of lipid buffore
1538 sslipi=sscalelip(fracinbuf)
1539 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
1540 elseif (zi.gt.bufliptop) then
1541 fracinbuf=1.0d0-((bordliptop-zi)/lipbufthick)
1542 sslipi=sscalelip(fracinbuf)
1543 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
1552 ! print *, sslipi,ssgradlipi
1553 dxi=dc_norm(1,nres+i)
1554 dyi=dc_norm(2,nres+i)
1555 dzi=dc_norm(3,nres+i)
1556 ! dsci_inv=dsc_inv(itypi)
1557 dsci_inv=vbld_inv(i+nres)
1558 ! write (iout,*) "i",i,dsc_inv(itypi),dsci_inv,1.0d0/vbld(i+nres)
1559 ! write (iout,*) "dcnori",dxi*dxi+dyi*dyi+dzi*dzi
1561 ! Calculate SC interaction energy.
1563 do iint=1,nint_gr(i)
1564 do j=istart(i,iint),iend(i,iint)
1565 IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
1566 call dyn_ssbond_ene(i,j,evdwij)
1568 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
1569 'evdw',i,j,evdwij,' ss'
1570 ! if (energy_dec) write (iout,*) &
1571 ! 'evdw',i,j,evdwij,' ss'
1572 do k=j+1,iend(i,iint)
1573 !C search over all next residues
1574 if (dyn_ss_mask(k)) then
1575 !C check if they are cysteins
1576 !C write(iout,*) 'k=',k
1578 !c write(iout,*) "PRZED TRI", evdwij
1579 ! evdwij_przed_tri=evdwij
1580 call triple_ssbond_ene(i,j,k,evdwij)
1581 !c if(evdwij_przed_tri.ne.evdwij) then
1582 !c write (iout,*) "TRI:", evdwij, evdwij_przed_tri
1585 !c write(iout,*) "PO TRI", evdwij
1586 !C call the energy function that removes the artifical triple disulfide
1587 !C bond the soubroutine is located in ssMD.F
1589 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
1590 'evdw',i,j,evdwij,'tss'
1591 endif!dyn_ss_mask(k)
1595 itypj=iabs(itype(j,1))
1596 if (itypj.eq.ntyp1) cycle
1597 ! if (j.ne.78) cycle
1598 ! dscj_inv=dsc_inv(itypj)
1599 dscj_inv=vbld_inv(j+nres)
1600 ! write (iout,*) "j",j,dsc_inv(itypj),dscj_inv,&
1601 ! 1.0d0/vbld(j+nres) !d
1602 ! write (iout,*) "i",i," j", j," itype",itype(i,1),itype(j,1)
1603 sig0ij=sigma(itypi,itypj)
1604 chi1=chi(itypi,itypj)
1605 chi2=chi(itypj,itypi)
1612 alf12=0.5D0*(alf1+alf2)
1613 ! For diagnostics only!!!
1626 xj=dmod(xj,boxxsize)
1627 if (xj.lt.0) xj=xj+boxxsize
1628 yj=dmod(yj,boxysize)
1629 if (yj.lt.0) yj=yj+boxysize
1630 zj=dmod(zj,boxzsize)
1631 if (zj.lt.0) zj=zj+boxzsize
1632 ! print *,"tu",xi,yi,zi,xj,yj,zj
1633 ! print *,"tu2",j,j+nres,c(1,j),c(1,j+nres)
1634 ! this fragment set correct epsilon for lipid phase
1635 if ((zj.gt.bordlipbot) &
1636 .and.(zj.lt.bordliptop)) then
1637 !C the energy transfer exist
1638 if (zj.lt.buflipbot) then
1639 !C what fraction I am in
1641 ((zj-bordlipbot)/lipbufthick)
1642 !C lipbufthick is thickenes of lipid buffore
1643 sslipj=sscalelip(fracinbuf)
1644 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
1645 elseif (zj.gt.bufliptop) then
1646 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
1647 sslipj=sscalelip(fracinbuf)
1648 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
1657 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
1658 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
1659 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
1660 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
1661 !------------------------------------------------
1662 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
1670 xj=xj_safe+xshift*boxxsize
1671 yj=yj_safe+yshift*boxysize
1672 zj=zj_safe+zshift*boxzsize
1673 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
1674 if(dist_temp.lt.dist_init) then
1684 if (subchap.eq.1) then
1693 dxj=dc_norm(1,nres+j)
1694 dyj=dc_norm(2,nres+j)
1695 dzj=dc_norm(3,nres+j)
1696 ! write (iout,*) "dcnorj",dxi*dxi+dyi*dyi+dzi*dzi
1697 ! write (iout,*) "j",j," dc_norm",& !d
1698 ! dc_norm(1,nres+j),dc_norm(2,nres+j),dc_norm(3,nres+j)
1699 ! write(iout,*)"rrij ",rrij
1700 ! write(iout,*)"xj yj zj ", xj, yj, zj
1701 ! write(iout,*)"xi yi zi ", xi, yi, zi
1702 ! write(iout,*)"c ", c(1,:), c(2,:), c(3,:)
1703 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1705 sss_ele_cut=sscale_ele(1.0d0/(rij*sigma(itypi,itypj)))
1706 sss_ele_grad=sscagrad_ele(1.0d0/(rij*sigma(itypi,itypj)))
1707 ! print *,sss_ele_cut,sss_ele_grad,&
1708 ! 1.0d0/(rij),r_cut_ele,rlamb_ele
1709 if (sss_ele_cut.le.0.0) cycle
1710 ! Calculate angle-dependent terms of energy and contributions to their
1714 sig=sig0ij*dsqrt(sigsq)
1715 rij_shift=1.0D0/rij-sig+sig0ij
1716 ! write(iout,*)" rij_shift",rij_shift," rij",rij," sig",sig,&
1718 ! for diagnostics; uncomment
1719 ! rij_shift=1.2*sig0ij
1720 ! I hate to put IF's in the loops, but here don't have another choice!!!!
1721 if (rij_shift.le.0.0D0) then
1723 !d write (iout,'(2(a3,i3,2x),17(0pf7.3))')
1724 !d & restyp(itypi,1),i,restyp(itypj,1),j,
1725 !d & rij_shift,1.0D0/rij,sig,sig0ij,sigsq,1-dsqrt(sigsq)
1729 !---------------------------------------------------------------
1730 rij_shift=1.0D0/rij_shift
1731 fac=rij_shift**expon
1733 e1=fac*fac*aa!(itypi,itypj)
1734 e2=fac*bb!(itypi,itypj)
1735 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
1736 eps2der=evdwij*eps3rt
1737 eps3der=evdwij*eps2rt
1738 ! write(iout,*)"aa, bb ",aa(:,:),bb(:,:)
1739 ! write (iout,*) "sigsq",sigsq," sig",sig," eps2rt",eps2rt,& !d
1740 ! " eps3rt",eps3rt," eps1",eps1," e1",e1," e2",e2," fac",fac !d
1741 evdwij=evdwij*eps2rt*eps3rt
1742 evdw=evdw+evdwij*sss_ele_cut
1744 sigm=dabs(aa/bb)**(1.0D0/6.0D0)
1745 epsi=bb**2/aa!(itypi,itypj)
1746 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
1747 restyp(itypi,1),i,restyp(itypj,1),j, &
1748 epsi,sigm,chi1,chi2,chip1,chip2, &
1749 eps1,eps2rt**2,eps3rt**2,sig,sig0ij, &
1750 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift, &
1754 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,2e10.2,e11.3)')&
1755 'evdw',i,j,evdwij,xi,xj,rij !,"egb"
1756 !C print *,i,j,c(1,i),c(1,j),c(2,i),c(2,j),c(3,i),c(3,j)
1757 ! if (energy_dec) write (iout,*) &
1759 ! print *,"ZALAMKA", evdw
1761 ! Calculate gradient components.
1762 e1=e1*eps1*eps2rt**2*eps3rt**2
1763 fac=-expon*(e1+evdwij)*rij_shift
1766 ! print *,'before fac',fac,rij,evdwij
1767 fac=fac+evdwij*sss_ele_grad/sss_ele_cut&
1768 /sigma(itypi,itypj)*rij
1769 ! print *,'grad part scale',fac, &
1770 ! evdwij*sss_ele_grad/sss_ele_cut &
1771 ! /sigma(itypi,itypj)*rij
1773 ! Calculate the radial part of the gradient
1777 !C Calculate the radial part of the gradient
1778 gg_lipi(3)=eps1*(eps2rt*eps2rt)&
1779 *(eps3rt*eps3rt)*sss_ele_cut/2.0d0*(faclip*faclip*&
1780 (aa_lip(itypi,itypj)-aa_aq(itypi,itypj))&
1781 +faclip*(bb_lip(itypi,itypj)-bb_aq(itypi,itypj)))
1782 gg_lipj(3)=ssgradlipj*gg_lipi(3)
1783 gg_lipi(3)=gg_lipi(3)*ssgradlipi
1785 ! print *,'before sc_grad', gg(1),gg(2),gg(3)
1786 ! Calculate angular part of the gradient.
1792 ! print *,"ZALAMKA", evdw
1793 ! write (iout,*) "Number of loop steps in EGB:",ind
1794 !ccc energy_dec=.false.
1797 !-----------------------------------------------------------------------------
1798 subroutine egbv(evdw)
1800 ! This subroutine calculates the interaction energy of nonbonded side chains
1801 ! assuming the Gay-Berne-Vorobjev potential of interaction.
1805 ! implicit real*8 (a-h,o-z)
1806 ! include 'DIMENSIONS'
1807 ! include 'COMMON.GEO'
1808 ! include 'COMMON.VAR'
1809 ! include 'COMMON.LOCAL'
1810 ! include 'COMMON.CHAIN'
1811 ! include 'COMMON.DERIV'
1812 ! include 'COMMON.NAMES'
1813 ! include 'COMMON.INTERACT'
1814 ! include 'COMMON.IOUNITS'
1815 ! include 'COMMON.CALC'
1817 !el integer :: icall
1818 !el common /srutu/ icall
1821 integer :: iint,itypi,itypi1,itypj
1822 real(kind=8) :: rrij,xi,yi,zi,r0ij,fac_augm,e_augm,fac,e1,e2,sigm
1823 real(kind=8) :: evdw,sig0ij,sig,rij_shift,epsi
1825 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
1828 ! if (icall.eq.0) lprn=.true.
1830 do i=iatsc_s,iatsc_e
1831 itypi=iabs(itype(i,1))
1832 if (itypi.eq.ntyp1) cycle
1833 itypi1=iabs(itype(i+1,1))
1837 dxi=dc_norm(1,nres+i)
1838 dyi=dc_norm(2,nres+i)
1839 dzi=dc_norm(3,nres+i)
1840 ! dsci_inv=dsc_inv(itypi)
1841 dsci_inv=vbld_inv(i+nres)
1843 ! Calculate SC interaction energy.
1845 do iint=1,nint_gr(i)
1846 do j=istart(i,iint),iend(i,iint)
1848 itypj=iabs(itype(j,1))
1849 if (itypj.eq.ntyp1) cycle
1850 ! dscj_inv=dsc_inv(itypj)
1851 dscj_inv=vbld_inv(j+nres)
1852 sig0ij=sigma(itypi,itypj)
1853 r0ij=r0(itypi,itypj)
1854 chi1=chi(itypi,itypj)
1855 chi2=chi(itypj,itypi)
1862 alf12=0.5D0*(alf1+alf2)
1863 ! For diagnostics only!!!
1876 dxj=dc_norm(1,nres+j)
1877 dyj=dc_norm(2,nres+j)
1878 dzj=dc_norm(3,nres+j)
1879 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1881 ! Calculate angle-dependent terms of energy and contributions to their
1885 sig=sig0ij*dsqrt(sigsq)
1886 rij_shift=1.0D0/rij-sig+r0ij
1887 ! I hate to put IF's in the loops, but here don't have another choice!!!!
1888 if (rij_shift.le.0.0D0) then
1893 !---------------------------------------------------------------
1894 rij_shift=1.0D0/rij_shift
1895 fac=rij_shift**expon
1896 e1=fac*fac*aa_aq(itypi,itypj)
1897 e2=fac*bb_aq(itypi,itypj)
1898 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
1899 eps2der=evdwij*eps3rt
1900 eps3der=evdwij*eps2rt
1901 fac_augm=rrij**expon
1902 e_augm=augm(itypi,itypj)*fac_augm
1903 evdwij=evdwij*eps2rt*eps3rt
1904 evdw=evdw+evdwij+e_augm
1906 sigm=dabs(aa_aq(itypi,itypj)/&
1907 bb_aq(itypi,itypj))**(1.0D0/6.0D0)
1908 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
1909 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
1910 restyp(itypi,1),i,restyp(itypj,1),j,&
1911 epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),&
1912 chi1,chi2,chip1,chip2,&
1913 eps1,eps2rt**2,eps3rt**2,&
1914 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
1917 ! Calculate gradient components.
1918 e1=e1*eps1*eps2rt**2*eps3rt**2
1919 fac=-expon*(e1+evdwij)*rij_shift
1921 fac=rij*fac-2*expon*rrij*e_augm
1922 ! Calculate the radial part of the gradient
1926 ! Calculate angular part of the gradient.
1932 !-----------------------------------------------------------------------------
1933 !el subroutine sc_angular in module geometry
1934 !-----------------------------------------------------------------------------
1935 subroutine e_softsphere(evdw)
1937 ! This subroutine calculates the interaction energy of nonbonded side chains
1938 ! assuming the LJ potential of interaction.
1940 ! implicit real*8 (a-h,o-z)
1941 ! include 'DIMENSIONS'
1942 real(kind=8),parameter :: accur=1.0d-10
1943 ! include 'COMMON.GEO'
1944 ! include 'COMMON.VAR'
1945 ! include 'COMMON.LOCAL'
1946 ! include 'COMMON.CHAIN'
1947 ! include 'COMMON.DERIV'
1948 ! include 'COMMON.INTERACT'
1949 ! include 'COMMON.TORSION'
1950 ! include 'COMMON.SBRIDGE'
1951 ! include 'COMMON.NAMES'
1952 ! include 'COMMON.IOUNITS'
1953 ! include 'COMMON.CONTACTS'
1954 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
1955 !d print *,'Entering Esoft_sphere nnt=',nnt,' nct=',nct
1957 integer :: i,iint,j,itypi,itypi1,itypj,k
1958 real(kind=8) :: evdw,xj,yj,zj,xi,yi,zi,rij,r0ij,r0ijsq,evdwij
1962 do i=iatsc_s,iatsc_e
1963 itypi=iabs(itype(i,1))
1964 if (itypi.eq.ntyp1) cycle
1965 itypi1=iabs(itype(i+1,1))
1970 ! Calculate SC interaction energy.
1972 do iint=1,nint_gr(i)
1973 !d write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
1974 !d & 'iend=',iend(i,iint)
1975 do j=istart(i,iint),iend(i,iint)
1976 itypj=iabs(itype(j,1))
1977 if (itypj.eq.ntyp1) cycle
1981 rij=xj*xj+yj*yj+zj*zj
1982 ! write (iout,*)'i=',i,' j=',j,' itypi=',itypi,' itypj=',itypj
1983 r0ij=r0(itypi,itypj)
1985 ! print *,i,j,r0ij,dsqrt(rij)
1986 if (rij.lt.r0ijsq) then
1987 evdwij=0.25d0*(rij-r0ijsq)**2
1995 ! Calculate the components of the gradient in DC and X
2001 gvdwx(k,i)=gvdwx(k,i)-gg(k)
2002 gvdwx(k,j)=gvdwx(k,j)+gg(k)
2003 gvdwc(k,i)=gvdwc(k,i)-gg(k)
2004 gvdwc(k,j)=gvdwc(k,j)+gg(k)
2008 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
2015 end subroutine e_softsphere
2016 !-----------------------------------------------------------------------------
2017 subroutine eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
2019 ! Soft-sphere potential of p-p interaction
2021 ! implicit real*8 (a-h,o-z)
2022 ! include 'DIMENSIONS'
2023 ! include 'COMMON.CONTROL'
2024 ! include 'COMMON.IOUNITS'
2025 ! include 'COMMON.GEO'
2026 ! include 'COMMON.VAR'
2027 ! include 'COMMON.LOCAL'
2028 ! include 'COMMON.CHAIN'
2029 ! include 'COMMON.DERIV'
2030 ! include 'COMMON.INTERACT'
2031 ! include 'COMMON.CONTACTS'
2032 ! include 'COMMON.TORSION'
2033 ! include 'COMMON.VECTORS'
2034 ! include 'COMMON.FFIELD'
2035 real(kind=8),dimension(3) :: ggg
2036 !d write(iout,*) 'In EELEC_soft_sphere'
2038 integer :: i,j,k,num_conti,iteli,itelj
2039 real(kind=8) :: ees,evdw1,eel_loc,eello_turn3,eello_turn4
2040 real(kind=8) :: dxi,dyi,dzi,xmedi,ymedi,zmedi,r0ij,r0ijsq
2041 real(kind=8) :: dxj,dyj,dzj,xj,yj,zj,rij,evdw1ij,fac
2049 do i=iatel_s,iatel_e
2050 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
2054 xmedi=c(1,i)+0.5d0*dxi
2055 ymedi=c(2,i)+0.5d0*dyi
2056 zmedi=c(3,i)+0.5d0*dzi
2058 ! write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
2059 do j=ielstart(i),ielend(i)
2060 if (itype(j,1).eq.ntyp1 .or. itype(j+1,1).eq.ntyp1) cycle
2064 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
2065 r0ij=rpp(iteli,itelj)
2070 xj=c(1,j)+0.5D0*dxj-xmedi
2071 yj=c(2,j)+0.5D0*dyj-ymedi
2072 zj=c(3,j)+0.5D0*dzj-zmedi
2073 rij=xj*xj+yj*yj+zj*zj
2074 if (rij.lt.r0ijsq) then
2075 evdw1ij=0.25d0*(rij-r0ijsq)**2
2083 ! Calculate contributions to the Cartesian gradient.
2089 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
2090 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
2093 ! Loop over residues i+1 thru j-1.
2097 !grad gelc(l,k)=gelc(l,k)+ggg(l)
2102 !grad do i=nnt,nct-1
2104 !grad gelc(k,i)=gelc(k,i)+0.5d0*gelc(k,i)
2106 !grad do j=i+1,nct-1
2108 !grad gelc(k,i)=gelc(k,i)+gelc(k,j)
2113 end subroutine eelec_soft_sphere
2114 !-----------------------------------------------------------------------------
2115 subroutine vec_and_deriv
2116 ! implicit real*8 (a-h,o-z)
2117 ! include 'DIMENSIONS'
2121 ! include 'COMMON.IOUNITS'
2122 ! include 'COMMON.GEO'
2123 ! include 'COMMON.VAR'
2124 ! include 'COMMON.LOCAL'
2125 ! include 'COMMON.CHAIN'
2126 ! include 'COMMON.VECTORS'
2127 ! include 'COMMON.SETUP'
2128 ! include 'COMMON.TIME1'
2129 real(kind=8),dimension(3,3,2) :: uyder,uzder
2130 real(kind=8),dimension(2) :: vbld_inv_temp
2131 ! Compute the local reference systems. For reference system (i), the
2132 ! X-axis points from CA(i) to CA(i+1), the Y axis is in the
2133 ! CA(i)-CA(i+1)-CA(i+2) plane, and the Z axis is perpendicular to this plane.
2136 real(kind=8) :: facy,fac,costh
2139 do i=ivec_start,ivec_end
2143 if (i.eq.nres-1) then
2144 ! Case of the last full residue
2145 ! Compute the Z-axis
2146 call vecpr(dc_norm(1,i),dc_norm(1,i-1),uz(1,i))
2147 costh=dcos(pi-theta(nres))
2148 fac=1.0d0/dsqrt(1.0d0-costh*costh)
2152 ! Compute the derivatives of uz
2154 uzder(2,1,1)=-dc_norm(3,i-1)
2155 uzder(3,1,1)= dc_norm(2,i-1)
2156 uzder(1,2,1)= dc_norm(3,i-1)
2158 uzder(3,2,1)=-dc_norm(1,i-1)
2159 uzder(1,3,1)=-dc_norm(2,i-1)
2160 uzder(2,3,1)= dc_norm(1,i-1)
2163 uzder(2,1,2)= dc_norm(3,i)
2164 uzder(3,1,2)=-dc_norm(2,i)
2165 uzder(1,2,2)=-dc_norm(3,i)
2167 uzder(3,2,2)= dc_norm(1,i)
2168 uzder(1,3,2)= dc_norm(2,i)
2169 uzder(2,3,2)=-dc_norm(1,i)
2171 ! Compute the Y-axis
2174 uy(k,i)=fac*(dc_norm(k,i-1)-costh*dc_norm(k,i))
2176 ! Compute the derivatives of uy
2179 uyder(k,j,1)=2*dc_norm(k,i-1)*dc_norm(j,i) &
2180 -dc_norm(k,i)*dc_norm(j,i-1)
2181 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
2183 uyder(j,j,1)=uyder(j,j,1)-costh
2184 uyder(j,j,2)=1.0d0+uyder(j,j,2)
2189 uygrad(l,k,j,i)=uyder(l,k,j)
2190 uzgrad(l,k,j,i)=uzder(l,k,j)
2194 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
2195 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
2196 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
2197 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
2200 ! Compute the Z-axis
2201 call vecpr(dc_norm(1,i),dc_norm(1,i+1),uz(1,i))
2202 costh=dcos(pi-theta(i+2))
2203 fac=1.0d0/dsqrt(1.0d0-costh*costh)
2207 ! Compute the derivatives of uz
2209 uzder(2,1,1)=-dc_norm(3,i+1)
2210 uzder(3,1,1)= dc_norm(2,i+1)
2211 uzder(1,2,1)= dc_norm(3,i+1)
2213 uzder(3,2,1)=-dc_norm(1,i+1)
2214 uzder(1,3,1)=-dc_norm(2,i+1)
2215 uzder(2,3,1)= dc_norm(1,i+1)
2218 uzder(2,1,2)= dc_norm(3,i)
2219 uzder(3,1,2)=-dc_norm(2,i)
2220 uzder(1,2,2)=-dc_norm(3,i)
2222 uzder(3,2,2)= dc_norm(1,i)
2223 uzder(1,3,2)= dc_norm(2,i)
2224 uzder(2,3,2)=-dc_norm(1,i)
2226 ! Compute the Y-axis
2229 uy(k,i)=facy*(dc_norm(k,i+1)-costh*dc_norm(k,i))
2231 ! Compute the derivatives of uy
2234 uyder(k,j,1)=2*dc_norm(k,i+1)*dc_norm(j,i) &
2235 -dc_norm(k,i)*dc_norm(j,i+1)
2236 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
2238 uyder(j,j,1)=uyder(j,j,1)-costh
2239 uyder(j,j,2)=1.0d0+uyder(j,j,2)
2244 uygrad(l,k,j,i)=uyder(l,k,j)
2245 uzgrad(l,k,j,i)=uzder(l,k,j)
2249 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
2250 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
2251 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
2252 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
2256 vbld_inv_temp(1)=vbld_inv(i+1)
2257 if (i.lt.nres-1) then
2258 vbld_inv_temp(2)=vbld_inv(i+2)
2260 vbld_inv_temp(2)=vbld_inv(i)
2265 uygrad(l,k,j,i)=vbld_inv_temp(j)*uygrad(l,k,j,i)
2266 uzgrad(l,k,j,i)=vbld_inv_temp(j)*uzgrad(l,k,j,i)
2271 #if defined(PARVEC) && defined(MPI)
2272 if (nfgtasks1.gt.1) then
2274 ! print *,"Processor",fg_rank1,kolor1," ivec_start",ivec_start,
2275 ! & " ivec_displ",(ivec_displ(i),i=0,nfgtasks1-1),
2276 ! & " ivec_count",(ivec_count(i),i=0,nfgtasks1-1)
2277 call MPI_Allgatherv(uy(1,ivec_start),ivec_count(fg_rank1),&
2278 MPI_UYZ,uy(1,1),ivec_count(0),ivec_displ(0),MPI_UYZ,&
2280 call MPI_Allgatherv(uz(1,ivec_start),ivec_count(fg_rank1),&
2281 MPI_UYZ,uz(1,1),ivec_count(0),ivec_displ(0),MPI_UYZ,&
2283 call MPI_Allgatherv(uygrad(1,1,1,ivec_start),&
2284 ivec_count(fg_rank1),MPI_UYZGRAD,uygrad(1,1,1,1),ivec_count(0),&
2285 ivec_displ(0),MPI_UYZGRAD,FG_COMM1,IERR)
2286 call MPI_Allgatherv(uzgrad(1,1,1,ivec_start),&
2287 ivec_count(fg_rank1),MPI_UYZGRAD,uzgrad(1,1,1,1),ivec_count(0),&
2288 ivec_displ(0),MPI_UYZGRAD,FG_COMM1,IERR)
2289 time_gather=time_gather+MPI_Wtime()-time00
2291 ! if (fg_rank.eq.0) then
2292 ! write (iout,*) "Arrays UY and UZ"
2294 ! write (iout,'(i5,3f10.5,5x,3f10.5)') i,(uy(k,i),k=1,3),
2300 end subroutine vec_and_deriv
2301 !-----------------------------------------------------------------------------
2302 subroutine check_vecgrad
2303 ! implicit real*8 (a-h,o-z)
2304 ! include 'DIMENSIONS'
2305 ! include 'COMMON.IOUNITS'
2306 ! include 'COMMON.GEO'
2307 ! include 'COMMON.VAR'
2308 ! include 'COMMON.LOCAL'
2309 ! include 'COMMON.CHAIN'
2310 ! include 'COMMON.VECTORS'
2311 real(kind=8),dimension(3,3,2,nres) :: uygradt,uzgradt !(3,3,2,maxres)
2312 real(kind=8),dimension(3,nres) :: uyt,uzt !(3,maxres)
2313 real(kind=8),dimension(3,3,2) :: uygradn,uzgradn
2314 real(kind=8),dimension(3) :: erij
2315 real(kind=8) :: delta=1.0d-7
2321 !rc write(iout,'(2i5,2(3f10.5,5x))') i,1,dc_norm(:,i)
2322 !rc write(iout,'(2i5,2(3f10.5,5x))') i,2,uy(:,i)
2323 !rc write(iout,'(2i5,2(3f10.5,5x)/)')i,3,uz(:,i)
2324 !d write(iout,'(2i5,2(3f10.5,5x))') i,1,
2325 !d & (dc_norm(if90,i),if90=1,3)
2326 !d write(iout,'(2i5,2(3f10.5,5x))') i,2,(uy(if90,i),if90=1,3)
2327 !d write(iout,'(2i5,2(3f10.5,5x)/)')i,3,(uz(if90,i),if90=1,3)
2328 !d write(iout,'(a)')
2334 uygradt(l,k,j,i)=uygrad(l,k,j,i)
2335 uzgradt(l,k,j,i)=uzgrad(l,k,j,i)
2348 !d write (iout,*) 'i=',i
2350 erij(k)=dc_norm(k,i)
2354 dc_norm(k,i)=erij(k)
2356 dc_norm(j,i)=dc_norm(j,i)+delta
2357 ! fac=dsqrt(scalar(dc_norm(1,i),dc_norm(1,i)))
2359 ! dc_norm(k,i)=dc_norm(k,i)/fac
2361 ! write (iout,*) (dc_norm(k,i),k=1,3)
2362 ! write (iout,*) (erij(k),k=1,3)
2365 uygradn(k,j,1)=(uy(k,i)-uyt(k,i))/delta
2366 uygradn(k,j,2)=(uy(k,i-1)-uyt(k,i-1))/delta
2367 uzgradn(k,j,1)=(uz(k,i)-uzt(k,i))/delta
2368 uzgradn(k,j,2)=(uz(k,i-1)-uzt(k,i-1))/delta
2370 ! write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2371 ! & j,(uzgradt(k,j,1,i),k=1,3),(uzgradn(k,j,1),k=1,3),
2372 ! & (uzgradt(k,j,2,i-1),k=1,3),(uzgradn(k,j,2),k=1,3)
2375 dc_norm(k,i)=erij(k)
2378 !d write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2379 !d & k,(uygradt(k,l,1,i),l=1,3),(uygradn(k,l,1),l=1,3),
2380 !d & (uygradt(k,l,2,i-1),l=1,3),(uygradn(k,l,2),l=1,3)
2381 !d write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2382 !d & k,(uzgradt(k,l,1,i),l=1,3),(uzgradn(k,l,1),l=1,3),
2383 !d & (uzgradt(k,l,2,i-1),l=1,3),(uzgradn(k,l,2),l=1,3)
2384 !d write (iout,'(a)')
2388 end subroutine check_vecgrad
2389 !-----------------------------------------------------------------------------
2390 subroutine set_matrices
2391 ! implicit real*8 (a-h,o-z)
2392 ! include 'DIMENSIONS'
2395 ! include "COMMON.SETUP"
2397 integer :: status(MPI_STATUS_SIZE)
2399 ! include 'COMMON.IOUNITS'
2400 ! include 'COMMON.GEO'
2401 ! include 'COMMON.VAR'
2402 ! include 'COMMON.LOCAL'
2403 ! include 'COMMON.CHAIN'
2404 ! include 'COMMON.DERIV'
2405 ! include 'COMMON.INTERACT'
2406 ! include 'COMMON.CONTACTS'
2407 ! include 'COMMON.TORSION'
2408 ! include 'COMMON.VECTORS'
2409 ! include 'COMMON.FFIELD'
2410 real(kind=8) :: auxvec(2),auxmat(2,2)
2411 integer :: i,iti1,iti,k,l
2412 real(kind=8) :: sin1,cos1,sin2,cos2,dwacos2,dwasin2
2413 ! print *,"in set matrices"
2415 ! Compute the virtual-bond-torsional-angle dependent quantities needed
2416 ! to calculate the el-loc multibody terms of various order.
2420 do i=ivec_start+2,ivec_end+2
2425 if (i .lt. nres+1) then
2462 if (i .gt. 3 .and. i .lt. nres+1) then
2463 obrot_der(1,i-2)=-sin1
2464 obrot_der(2,i-2)= cos1
2465 Ugder(1,1,i-2)= sin1
2466 Ugder(1,2,i-2)=-cos1
2467 Ugder(2,1,i-2)=-cos1
2468 Ugder(2,2,i-2)=-sin1
2471 obrot2_der(1,i-2)=-dwasin2
2472 obrot2_der(2,i-2)= dwacos2
2473 Ug2der(1,1,i-2)= dwasin2
2474 Ug2der(1,2,i-2)=-dwacos2
2475 Ug2der(2,1,i-2)=-dwacos2
2476 Ug2der(2,2,i-2)=-dwasin2
2478 obrot_der(1,i-2)=0.0d0
2479 obrot_der(2,i-2)=0.0d0
2480 Ugder(1,1,i-2)=0.0d0
2481 Ugder(1,2,i-2)=0.0d0
2482 Ugder(2,1,i-2)=0.0d0
2483 Ugder(2,2,i-2)=0.0d0
2484 obrot2_der(1,i-2)=0.0d0
2485 obrot2_der(2,i-2)=0.0d0
2486 Ug2der(1,1,i-2)=0.0d0
2487 Ug2der(1,2,i-2)=0.0d0
2488 Ug2der(2,1,i-2)=0.0d0
2489 Ug2der(2,2,i-2)=0.0d0
2491 ! if (i.gt. iatel_s+2 .and. i.lt.iatel_e+5) then
2492 if (i.gt. nnt+2 .and. i.lt.nct+2) then
2493 iti = itortyp(itype(i-2,1))
2497 ! if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
2498 if (i.gt. nnt+1 .and. i.lt.nct+1) then
2499 iti1 = itortyp(itype(i-1,1))
2503 ! print *,iti,i,"iti",iti1,itype(i-1,1),itype(i-2,1)
2504 !d write (iout,*) '*******i',i,' iti1',iti
2505 !d write (iout,*) 'b1',b1(:,iti)
2506 !d write (iout,*) 'b2',b2(:,iti)
2507 !d write (iout,*) 'Ug',Ug(:,:,i-2)
2508 ! if (i .gt. iatel_s+2) then
2509 if (i .gt. nnt+2) then
2510 call matvec2(Ug(1,1,i-2),b2(1,iti),Ub2(1,i-2))
2511 call matmat2(EE(1,1,iti),Ug(1,1,i-2),EUg(1,1,i-2))
2512 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) &
2514 call matmat2(CC(1,1,iti),Ug(1,1,i-2),CUg(1,1,i-2))
2515 call matmat2(DD(1,1,iti),Ug(1,1,i-2),DUg(1,1,i-2))
2516 call matmat2(Dtilde(1,1,iti),Ug2(1,1,i-2),DtUg2(1,1,i-2))
2517 call matvec2(Ctilde(1,1,iti1),obrot(1,i-2),Ctobr(1,i-2))
2518 call matvec2(Dtilde(1,1,iti),obrot2(1,i-2),Dtobr2(1,i-2))
2529 DtUg2(l,k,i-2)=0.0d0
2533 call matvec2(Ugder(1,1,i-2),b2(1,iti),Ub2der(1,i-2))
2534 call matmat2(EE(1,1,iti),Ugder(1,1,i-2),EUgder(1,1,i-2))
2536 muder(k,i-2)=Ub2der(k,i-2)
2538 ! if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
2539 if (i.gt. nnt+1 .and. i.lt.nct+1) then
2540 if (itype(i-1,1).le.ntyp) then
2541 iti1 = itortyp(itype(i-1,1))
2549 mu(k,i-2)=Ub2(k,i-2)+b1(k,iti1)
2551 ! if (energy_dec) write (iout,*) 'Ub2 ',i,Ub2(:,i-2)
2552 ! if (energy_dec) write (iout,*) 'b1 ',iti1,b1(:,iti1)
2553 ! if (energy_dec) write (iout,*) 'mu ',i,iti1,mu(:,i-2)
2554 !d write (iout,*) 'mu1',mu1(:,i-2)
2555 !d write (iout,*) 'mu2',mu2(:,i-2)
2556 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.wcorr6.gt.0.0d0) &
2558 call matmat2(CC(1,1,iti1),Ugder(1,1,i-2),CUgder(1,1,i-2))
2559 call matmat2(DD(1,1,iti),Ugder(1,1,i-2),DUgder(1,1,i-2))
2560 call matmat2(Dtilde(1,1,iti),Ug2der(1,1,i-2),DtUg2der(1,1,i-2))
2561 call matvec2(Ctilde(1,1,iti1),obrot_der(1,i-2),Ctobrder(1,i-2))
2562 call matvec2(Dtilde(1,1,iti),obrot2_der(1,i-2),Dtobr2der(1,i-2))
2563 ! Vectors and matrices dependent on a single virtual-bond dihedral.
2564 call matvec2(DD(1,1,iti),b1tilde(1,iti1),auxvec(1))
2565 call matvec2(Ug2(1,1,i-2),auxvec(1),Ug2Db1t(1,i-2))
2566 call matvec2(Ug2der(1,1,i-2),auxvec(1),Ug2Db1tder(1,i-2))
2567 call matvec2(CC(1,1,iti1),Ub2(1,i-2),CUgb2(1,i-2))
2568 call matvec2(CC(1,1,iti1),Ub2der(1,i-2),CUgb2der(1,i-2))
2569 call matmat2(EUg(1,1,i-2),CC(1,1,iti1),EUgC(1,1,i-2))
2570 call matmat2(EUgder(1,1,i-2),CC(1,1,iti1),EUgCder(1,1,i-2))
2571 call matmat2(EUg(1,1,i-2),DD(1,1,iti1),EUgD(1,1,i-2))
2572 call matmat2(EUgder(1,1,i-2),DD(1,1,iti1),EUgDder(1,1,i-2))
2575 ! Matrices dependent on two consecutive virtual-bond dihedrals.
2576 ! The order of matrices is from left to right.
2577 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.wcorr6.gt.0.0d0) &
2579 ! do i=max0(ivec_start,2),ivec_end
2581 call matmat2(DtUg2(1,1,i-1),EUg(1,1,i),DtUg2EUg(1,1,i))
2582 call matmat2(DtUg2der(1,1,i-1),EUg(1,1,i),DtUg2EUgder(1,1,1,i))
2583 call matmat2(DtUg2(1,1,i-1),EUgder(1,1,i),DtUg2EUgder(1,1,2,i))
2584 call transpose2(DtUg2(1,1,i-1),auxmat(1,1))
2585 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUg(1,1,i))
2586 call matmat2(auxmat(1,1),EUgder(1,1,i),Ug2DtEUgder(1,1,2,i))
2587 call transpose2(DtUg2der(1,1,i-1),auxmat(1,1))
2588 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUgder(1,1,1,i))
2591 #if defined(MPI) && defined(PARMAT)
2593 ! if (fg_rank.eq.0) then
2594 write (iout,*) "Arrays UG and UGDER before GATHER"
2596 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2597 ((ug(l,k,i),l=1,2),k=1,2),&
2598 ((ugder(l,k,i),l=1,2),k=1,2)
2600 write (iout,*) "Arrays UG2 and UG2DER"
2602 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2603 ((ug2(l,k,i),l=1,2),k=1,2),&
2604 ((ug2der(l,k,i),l=1,2),k=1,2)
2606 write (iout,*) "Arrays OBROT OBROT2 OBROTDER and OBROT2DER"
2608 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2609 (obrot(k,i),k=1,2),(obrot2(k,i),k=1,2),&
2610 (obrot_der(k,i),k=1,2),(obrot2_der(k,i),k=1,2)
2612 write (iout,*) "Arrays COSTAB SINTAB COSTAB2 and SINTAB2"
2614 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2615 costab(i),sintab(i),costab2(i),sintab2(i)
2617 write (iout,*) "Array MUDER"
2619 write (iout,'(i5,2f10.5)') i,muder(1,i),muder(2,i)
2623 if (nfgtasks.gt.1) then
2625 ! write(iout,*)"Processor",fg_rank,kolor," ivec_start",ivec_start,
2626 ! & " ivec_displ",(ivec_displ(i),i=0,nfgtasks-1),
2627 ! & " ivec_count",(ivec_count(i),i=0,nfgtasks-1)
2629 call MPI_Allgatherv(Ub2(1,ivec_start),ivec_count(fg_rank1),&
2630 MPI_MU,Ub2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2632 call MPI_Allgatherv(Ub2der(1,ivec_start),ivec_count(fg_rank1),&
2633 MPI_MU,Ub2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2635 call MPI_Allgatherv(mu(1,ivec_start),ivec_count(fg_rank1),&
2636 MPI_MU,mu(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2638 call MPI_Allgatherv(muder(1,ivec_start),ivec_count(fg_rank1),&
2639 MPI_MU,muder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2641 call MPI_Allgatherv(Eug(1,1,ivec_start),ivec_count(fg_rank1),&
2642 MPI_MAT1,Eug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2644 call MPI_Allgatherv(Eugder(1,1,ivec_start),ivec_count(fg_rank1),&
2645 MPI_MAT1,Eugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2647 call MPI_Allgatherv(costab(ivec_start),ivec_count(fg_rank1),&
2648 MPI_DOUBLE_PRECISION,costab(1),ivec_count(0),ivec_displ(0),&
2649 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
2650 call MPI_Allgatherv(sintab(ivec_start),ivec_count(fg_rank1),&
2651 MPI_DOUBLE_PRECISION,sintab(1),ivec_count(0),ivec_displ(0),&
2652 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
2653 call MPI_Allgatherv(costab2(ivec_start),ivec_count(fg_rank1),&
2654 MPI_DOUBLE_PRECISION,costab2(1),ivec_count(0),ivec_displ(0),&
2655 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
2656 call MPI_Allgatherv(sintab2(ivec_start),ivec_count(fg_rank1),&
2657 MPI_DOUBLE_PRECISION,sintab2(1),ivec_count(0),ivec_displ(0),&
2658 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
2659 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) &
2661 call MPI_Allgatherv(Ctobr(1,ivec_start),ivec_count(fg_rank1),&
2662 MPI_MU,Ctobr(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2664 call MPI_Allgatherv(Ctobrder(1,ivec_start),ivec_count(fg_rank1),&
2665 MPI_MU,Ctobrder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2667 call MPI_Allgatherv(Dtobr2(1,ivec_start),ivec_count(fg_rank1),&
2668 MPI_MU,Dtobr2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2670 call MPI_Allgatherv(Dtobr2der(1,ivec_start),ivec_count(fg_rank1),&
2671 MPI_MU,Dtobr2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2673 call MPI_Allgatherv(Ug2Db1t(1,ivec_start),ivec_count(fg_rank1),&
2674 MPI_MU,Ug2Db1t(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2676 call MPI_Allgatherv(Ug2Db1tder(1,ivec_start),&
2677 ivec_count(fg_rank1),&
2678 MPI_MU,Ug2Db1tder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2680 call MPI_Allgatherv(CUgb2(1,ivec_start),ivec_count(fg_rank1),&
2681 MPI_MU,CUgb2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2683 call MPI_Allgatherv(CUgb2der(1,ivec_start),ivec_count(fg_rank1),&
2684 MPI_MU,CUgb2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
2686 call MPI_Allgatherv(Cug(1,1,ivec_start),ivec_count(fg_rank1),&
2687 MPI_MAT1,Cug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2689 call MPI_Allgatherv(Cugder(1,1,ivec_start),ivec_count(fg_rank1),&
2690 MPI_MAT1,Cugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2692 call MPI_Allgatherv(Dug(1,1,ivec_start),ivec_count(fg_rank1),&
2693 MPI_MAT1,Dug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2695 call MPI_Allgatherv(Dugder(1,1,ivec_start),ivec_count(fg_rank1),&
2696 MPI_MAT1,Dugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2698 call MPI_Allgatherv(Dtug2(1,1,ivec_start),ivec_count(fg_rank1),&
2699 MPI_MAT1,Dtug2(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2701 call MPI_Allgatherv(Dtug2der(1,1,ivec_start),&
2702 ivec_count(fg_rank1),&
2703 MPI_MAT1,Dtug2der(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2705 call MPI_Allgatherv(EugC(1,1,ivec_start),ivec_count(fg_rank1),&
2706 MPI_MAT1,EugC(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2708 call MPI_Allgatherv(EugCder(1,1,ivec_start),ivec_count(fg_rank1),&
2709 MPI_MAT1,EugCder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2711 call MPI_Allgatherv(EugD(1,1,ivec_start),ivec_count(fg_rank1),&
2712 MPI_MAT1,EugD(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2714 call MPI_Allgatherv(EugDder(1,1,ivec_start),ivec_count(fg_rank1),&
2715 MPI_MAT1,EugDder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2717 call MPI_Allgatherv(DtUg2EUg(1,1,ivec_start),&
2718 ivec_count(fg_rank1),&
2719 MPI_MAT1,DtUg2EUg(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2721 call MPI_Allgatherv(Ug2DtEUg(1,1,ivec_start),&
2722 ivec_count(fg_rank1),&
2723 MPI_MAT1,Ug2DtEUg(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
2725 call MPI_Allgatherv(DtUg2EUgder(1,1,1,ivec_start),&
2726 ivec_count(fg_rank1),&
2727 MPI_MAT2,DtUg2EUgder(1,1,1,1),ivec_count(0),ivec_displ(0),&
2728 MPI_MAT2,FG_COMM1,IERR)
2729 call MPI_Allgatherv(Ug2DtEUgder(1,1,1,ivec_start),&
2730 ivec_count(fg_rank1),&
2731 MPI_MAT2,Ug2DtEUgder(1,1,1,1),ivec_count(0),ivec_displ(0),&
2732 MPI_MAT2,FG_COMM1,IERR)
2735 ! Passes matrix info through the ring
2738 if (irecv.lt.0) irecv=nfgtasks1-1
2741 if (inext.ge.nfgtasks1) inext=0
2743 ! write (iout,*) "isend",isend," irecv",irecv
2745 lensend=lentyp(isend)
2746 lenrecv=lentyp(irecv)
2747 ! write (iout,*) "lensend",lensend," lenrecv",lenrecv
2748 ! call MPI_SENDRECV(ug(1,1,ivec_displ(isend)+1),1,
2749 ! & MPI_ROTAT1(lensend),inext,2200+isend,
2750 ! & ug(1,1,ivec_displ(irecv)+1),1,MPI_ROTAT1(lenrecv),
2751 ! & iprev,2200+irecv,FG_COMM,status,IERR)
2752 ! write (iout,*) "Gather ROTAT1"
2754 ! call MPI_SENDRECV(obrot(1,ivec_displ(isend)+1),1,
2755 ! & MPI_ROTAT2(lensend),inext,3300+isend,
2756 ! & obrot(1,ivec_displ(irecv)+1),1,MPI_ROTAT2(lenrecv),
2757 ! & iprev,3300+irecv,FG_COMM,status,IERR)
2758 ! write (iout,*) "Gather ROTAT2"
2760 call MPI_SENDRECV(costab(ivec_displ(isend)+1),1,&
2761 MPI_ROTAT_OLD(lensend),inext,4400+isend,&
2762 costab(ivec_displ(irecv)+1),1,MPI_ROTAT_OLD(lenrecv),&
2763 iprev,4400+irecv,FG_COMM,status,IERR)
2764 ! write (iout,*) "Gather ROTAT_OLD"
2766 call MPI_SENDRECV(mu(1,ivec_displ(isend)+1),1,&
2767 MPI_PRECOMP11(lensend),inext,5500+isend,&
2768 mu(1,ivec_displ(irecv)+1),1,MPI_PRECOMP11(lenrecv),&
2769 iprev,5500+irecv,FG_COMM,status,IERR)
2770 ! write (iout,*) "Gather PRECOMP11"
2772 call MPI_SENDRECV(Eug(1,1,ivec_displ(isend)+1),1,&
2773 MPI_PRECOMP12(lensend),inext,6600+isend,&
2774 Eug(1,1,ivec_displ(irecv)+1),1,MPI_PRECOMP12(lenrecv),&
2775 iprev,6600+irecv,FG_COMM,status,IERR)
2776 ! write (iout,*) "Gather PRECOMP12"
2778 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) &
2780 call MPI_SENDRECV(ug2db1t(1,ivec_displ(isend)+1),1,&
2781 MPI_ROTAT2(lensend),inext,7700+isend,&
2782 ug2db1t(1,ivec_displ(irecv)+1),1,MPI_ROTAT2(lenrecv),&
2783 iprev,7700+irecv,FG_COMM,status,IERR)
2784 ! write (iout,*) "Gather PRECOMP21"
2786 call MPI_SENDRECV(EUgC(1,1,ivec_displ(isend)+1),1,&
2787 MPI_PRECOMP22(lensend),inext,8800+isend,&
2788 EUgC(1,1,ivec_displ(irecv)+1),1,MPI_PRECOMP22(lenrecv),&
2789 iprev,8800+irecv,FG_COMM,status,IERR)
2790 ! write (iout,*) "Gather PRECOMP22"
2792 call MPI_SENDRECV(Ug2DtEUgder(1,1,1,ivec_displ(isend)+1),1,&
2793 MPI_PRECOMP23(lensend),inext,9900+isend,&
2794 Ug2DtEUgder(1,1,1,ivec_displ(irecv)+1),1,&
2795 MPI_PRECOMP23(lenrecv),&
2796 iprev,9900+irecv,FG_COMM,status,IERR)
2797 ! write (iout,*) "Gather PRECOMP23"
2802 if (irecv.lt.0) irecv=nfgtasks1-1
2805 time_gather=time_gather+MPI_Wtime()-time00
2808 ! if (fg_rank.eq.0) then
2809 write (iout,*) "Arrays UG and UGDER"
2811 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2812 ((ug(l,k,i),l=1,2),k=1,2),&
2813 ((ugder(l,k,i),l=1,2),k=1,2)
2815 write (iout,*) "Arrays UG2 and UG2DER"
2817 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2818 ((ug2(l,k,i),l=1,2),k=1,2),&
2819 ((ug2der(l,k,i),l=1,2),k=1,2)
2821 write (iout,*) "Arrays OBROT OBROT2 OBROTDER and OBROT2DER"
2823 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2824 (obrot(k,i),k=1,2),(obrot2(k,i),k=1,2),&
2825 (obrot_der(k,i),k=1,2),(obrot2_der(k,i),k=1,2)
2827 write (iout,*) "Arrays COSTAB SINTAB COSTAB2 and SINTAB2"
2829 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
2830 costab(i),sintab(i),costab2(i),sintab2(i)
2832 write (iout,*) "Array MUDER"
2834 write (iout,'(i5,2f10.5)') i,muder(1,i),muder(2,i)
2840 !d iti = itortyp(itype(i,1))
2843 !d write (iout,'(2f10.5,5x,2f10.5,5x,2f10.5)')
2844 !d & (EE(j,k,iti),k=1,2),(Ug(j,k,i),k=1,2),(EUg(j,k,i),k=1,2)
2848 end subroutine set_matrices
2849 !-----------------------------------------------------------------------------
2850 subroutine eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
2852 ! This subroutine calculates the average interaction energy and its gradient
2853 ! in the virtual-bond vectors between non-adjacent peptide groups, based on
2854 ! the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
2855 ! The potential depends both on the distance of peptide-group centers and on
2856 ! the orientation of the CA-CA virtual bonds.
2859 ! implicit real*8 (a-h,o-z)
2863 ! include 'DIMENSIONS'
2864 ! include 'COMMON.CONTROL'
2865 ! include 'COMMON.SETUP'
2866 ! include 'COMMON.IOUNITS'
2867 ! include 'COMMON.GEO'
2868 ! include 'COMMON.VAR'
2869 ! include 'COMMON.LOCAL'
2870 ! include 'COMMON.CHAIN'
2871 ! include 'COMMON.DERIV'
2872 ! include 'COMMON.INTERACT'
2873 ! include 'COMMON.CONTACTS'
2874 ! include 'COMMON.TORSION'
2875 ! include 'COMMON.VECTORS'
2876 ! include 'COMMON.FFIELD'
2877 ! include 'COMMON.TIME1'
2878 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg
2879 real(kind=8),dimension(3,3) :: erder,uryg,urzg,vryg,vrzg
2880 real(kind=8),dimension(2,2) :: acipa !el,a_temp
2881 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
2882 real(kind=8),dimension(4) :: muij
2883 !el integer :: num_conti,j1,j2
2884 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
2885 !el dz_normi,xmedi,ymedi,zmedi
2887 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
2888 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
2891 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
2893 real(kind=8) :: scal_el=1.0d0
2895 real(kind=8) :: scal_el=0.5d0
2898 ! 13-go grudnia roku pamietnego...
2899 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
2901 0.0d0,0.0d0,1.0d0/),shape(unmat))
2904 real(kind=8) :: ees,evdw1,eel_loc,eello_turn3,eello_turn4
2905 real(kind=8) :: fac,t_eelecij,fracinbuf
2908 !d write(iout,*) 'In EELEC'
2909 ! print *,"IN EELEC"
2911 !d write(iout,*) 'Type',i
2912 !d write(iout,*) 'B1',B1(:,i)
2913 !d write(iout,*) 'B2',B2(:,i)
2914 !d write(iout,*) 'CC',CC(:,:,i)
2915 !d write(iout,*) 'DD',DD(:,:,i)
2916 !d write(iout,*) 'EE',EE(:,:,i)
2918 !d call check_vecgrad
2933 if (icheckgrad.eq.1) then
2936 ! dc_norm(1,i)=0.0d0
2937 ! dc_norm(2,i)=0.0d0
2938 ! dc_norm(3,i)=0.0d0
2941 fac=1.0d0/dsqrt(scalar(dc(1,i),dc(1,i)))
2943 dc_norm(k,i)=dc(k,i)*fac
2945 ! write (iout,*) 'i',i,' fac',fac
2948 ! print *,wel_loc,"wel_loc",wcorr4,wcorr5,wcorr6,wturn3,wturn4, &
2950 if (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
2951 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 .or. &
2952 wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) then
2953 ! call vec_and_deriv
2957 ! print *, "before set matrices"
2959 ! print *, "after set matrices"
2962 time_mat=time_mat+MPI_Wtime()-time01
2965 ! print *, "after set matrices"
2967 !d write (iout,*) 'i=',i
2969 !d write (iout,'(i5,2f10.5)') k,uy(k,i),uz(k,i)
2972 !d write (iout,'(f10.5,2x,3f10.5,2x,3f10.5)')
2973 !d & uz(k,i),(uzgrad(k,l,1,i),l=1,3),(uzgrad(k,l,2,i),l=1,3)
2986 !d print '(a)','Enter EELEC'
2987 !d write (iout,*) 'iatel_s=',iatel_s,' iatel_e=',iatel_e
2988 ! if (.not.allocated(gel_loc_loc)) allocate(gel_loc_loc(nres)) !(maxvar)(maxvar=6*maxres)
2989 ! if (.not.allocated(gcorr_loc)) allocate(gcorr_loc(nres)) !(maxvar)(maxvar=6*maxres)
2991 gel_loc_loc(i)=0.0d0
2996 ! 9/27/08 AL Split the interaction loop to ensure load balancing of turn terms
2998 ! Loop over i,i+2 and i,i+3 pairs of the peptide groups
3002 ! print *,"before iturn3 loop"
3003 do i=iturn3_start,iturn3_end
3004 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1 &
3005 .or. itype(i+2,1).eq.ntyp1 .or. itype(i+3,1).eq.ntyp1) cycle
3009 dx_normi=dc_norm(1,i)
3010 dy_normi=dc_norm(2,i)
3011 dz_normi=dc_norm(3,i)
3012 xmedi=c(1,i)+0.5d0*dxi
3013 ymedi=c(2,i)+0.5d0*dyi
3014 zmedi=c(3,i)+0.5d0*dzi
3015 xmedi=dmod(xmedi,boxxsize)
3016 if (xmedi.lt.0) xmedi=xmedi+boxxsize
3017 ymedi=dmod(ymedi,boxysize)
3018 if (ymedi.lt.0) ymedi=ymedi+boxysize
3019 zmedi=dmod(zmedi,boxzsize)
3020 if (zmedi.lt.0) zmedi=zmedi+boxzsize
3022 if ((zmedi.gt.bordlipbot) &
3023 .and.(zmedi.lt.bordliptop)) then
3024 !C the energy transfer exist
3025 if (zmedi.lt.buflipbot) then
3026 !C what fraction I am in
3028 ((zmedi-bordlipbot)/lipbufthick)
3029 !C lipbufthick is thickenes of lipid buffore
3030 sslipi=sscalelip(fracinbuf)
3031 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
3032 elseif (zmedi.gt.bufliptop) then
3033 fracinbuf=1.0d0-((bordliptop-zmedi)/lipbufthick)
3034 sslipi=sscalelip(fracinbuf)
3035 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
3044 ! print *,i,sslipi,ssgradlipi
3045 call eelecij(i,i+2,ees,evdw1,eel_loc)
3046 if (wturn3.gt.0.0d0) call eturn3(i,eello_turn3)
3047 num_cont_hb(i)=num_conti
3049 do i=iturn4_start,iturn4_end
3050 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1 &
3051 .or. itype(i+3,1).eq.ntyp1 &
3052 .or. itype(i+4,1).eq.ntyp1) cycle
3056 dx_normi=dc_norm(1,i)
3057 dy_normi=dc_norm(2,i)
3058 dz_normi=dc_norm(3,i)
3059 xmedi=c(1,i)+0.5d0*dxi
3060 ymedi=c(2,i)+0.5d0*dyi
3061 zmedi=c(3,i)+0.5d0*dzi
3062 xmedi=dmod(xmedi,boxxsize)
3063 if (xmedi.lt.0) xmedi=xmedi+boxxsize
3064 ymedi=dmod(ymedi,boxysize)
3065 if (ymedi.lt.0) ymedi=ymedi+boxysize
3066 zmedi=dmod(zmedi,boxzsize)
3067 if (zmedi.lt.0) zmedi=zmedi+boxzsize
3068 if ((zmedi.gt.bordlipbot) &
3069 .and.(zmedi.lt.bordliptop)) then
3070 !C the energy transfer exist
3071 if (zmedi.lt.buflipbot) then
3072 !C what fraction I am in
3074 ((zmedi-bordlipbot)/lipbufthick)
3075 !C lipbufthick is thickenes of lipid buffore
3076 sslipi=sscalelip(fracinbuf)
3077 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
3078 elseif (zmedi.gt.bufliptop) then
3079 fracinbuf=1.0d0-((bordliptop-zmedi)/lipbufthick)
3080 sslipi=sscalelip(fracinbuf)
3081 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
3091 num_conti=num_cont_hb(i)
3092 call eelecij(i,i+3,ees,evdw1,eel_loc)
3093 if (wturn4.gt.0.0d0 .and. itype(i+2,1).ne.ntyp1) &
3094 call eturn4(i,eello_turn4)
3095 num_cont_hb(i)=num_conti
3098 ! Loop over all pairs of interacting peptide groups except i,i+2 and i,i+3
3100 ! print *,"iatel_s,iatel_e,",iatel_s,iatel_e
3101 do i=iatel_s,iatel_e
3102 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
3106 dx_normi=dc_norm(1,i)
3107 dy_normi=dc_norm(2,i)
3108 dz_normi=dc_norm(3,i)
3109 xmedi=c(1,i)+0.5d0*dxi
3110 ymedi=c(2,i)+0.5d0*dyi
3111 zmedi=c(3,i)+0.5d0*dzi
3112 xmedi=dmod(xmedi,boxxsize)
3113 if (xmedi.lt.0) xmedi=xmedi+boxxsize
3114 ymedi=dmod(ymedi,boxysize)
3115 if (ymedi.lt.0) ymedi=ymedi+boxysize
3116 zmedi=dmod(zmedi,boxzsize)
3117 if (zmedi.lt.0) zmedi=zmedi+boxzsize
3118 if ((zmedi.gt.bordlipbot) &
3119 .and.(zmedi.lt.bordliptop)) then
3120 !C the energy transfer exist
3121 if (zmedi.lt.buflipbot) then
3122 !C what fraction I am in
3124 ((zmedi-bordlipbot)/lipbufthick)
3125 !C lipbufthick is thickenes of lipid buffore
3126 sslipi=sscalelip(fracinbuf)
3127 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
3128 elseif (zmedi.gt.bufliptop) then
3129 fracinbuf=1.0d0-((bordliptop-zmedi)/lipbufthick)
3130 sslipi=sscalelip(fracinbuf)
3131 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
3141 ! write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
3142 num_conti=num_cont_hb(i)
3143 do j=ielstart(i),ielend(i)
3144 ! write (iout,*) i,j,itype(i,1),itype(j,1)
3145 if (itype(j,1).eq.ntyp1.or. itype(j+1,1).eq.ntyp1) cycle
3146 call eelecij(i,j,ees,evdw1,eel_loc)
3148 num_cont_hb(i)=num_conti
3150 ! write (iout,*) "Number of loop steps in EELEC:",ind
3152 !d write (iout,'(i3,3f10.5,5x,3f10.5)')
3153 !d & i,(gel_loc(k,i),k=1,3),gel_loc_loc(i)
3155 ! 12/7/99 Adam eello_turn3 will be considered as a separate energy term
3156 !cc eel_loc=eel_loc+eello_turn3
3157 !d print *,"Processor",fg_rank," t_eelecij",t_eelecij
3159 end subroutine eelec
3160 !-----------------------------------------------------------------------------
3161 subroutine eelecij(i,j,ees,evdw1,eel_loc)
3164 ! implicit real*8 (a-h,o-z)
3165 ! include 'DIMENSIONS'
3169 ! include 'COMMON.CONTROL'
3170 ! include 'COMMON.IOUNITS'
3171 ! include 'COMMON.GEO'
3172 ! include 'COMMON.VAR'
3173 ! include 'COMMON.LOCAL'
3174 ! include 'COMMON.CHAIN'
3175 ! include 'COMMON.DERIV'
3176 ! include 'COMMON.INTERACT'
3177 ! include 'COMMON.CONTACTS'
3178 ! include 'COMMON.TORSION'
3179 ! include 'COMMON.VECTORS'
3180 ! include 'COMMON.FFIELD'
3181 ! include 'COMMON.TIME1'
3182 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg,xtemp
3183 real(kind=8),dimension(3,3) :: erder,uryg,urzg,vryg,vrzg
3184 real(kind=8),dimension(2,2) :: acipa !el,a_temp
3185 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
3186 real(kind=8),dimension(4) :: muij
3187 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
3188 dist_temp, dist_init,rlocshield,fracinbuf
3189 integer xshift,yshift,zshift,ilist,iresshield
3190 !el integer :: num_conti,j1,j2
3191 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
3192 !el dz_normi,xmedi,ymedi,zmedi
3194 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
3195 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
3198 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
3200 real(kind=8) :: scal_el=1.0d0
3202 real(kind=8) :: scal_el=0.5d0
3205 ! 13-go grudnia roku pamietnego...
3206 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
3208 0.0d0,0.0d0,1.0d0/),shape(unmat))
3209 ! integer :: maxconts=nres/4
3211 integer :: k,i,j,iteli,itelj,kkk,l,kkll,m,isubchap
3212 real(kind=8) :: ael6i,rrmij,rmij,r0ij,fcont,fprimcont,ees0tmp
3213 real(kind=8) :: ees,evdw1,eel_loc,aaa,bbb,ael3i
3214 real(kind=8) :: dxj,dyj,dzj,dx_normj,dy_normj,dz_normj,xj,yj,zj,&
3215 rij,r3ij,r6ij,cosa,cosb,cosg,fac,ev1,ev2,fac3,fac4,&
3216 evdwij,el1,el2,eesij,ees0ij,facvdw,facel,fac1,ecosa,&
3217 ecosb,ecosg,ury,urz,vry,vrz,facr,a22der,a23der,a32der,&
3218 a33der,eel_loc_ij,cosa4,wij,cosbg1,cosbg2,ees0pij,&
3219 ees0pij1,ees0mij,ees0mij1,fac3p,ees0mijp,ees0pijp,&
3220 ecosa1,ecosb1,ecosg1,ecosa2,ecosb2,ecosg2,ecosap,ecosbp,&
3221 ecosgp,ecosam,ecosbm,ecosgm,ghalf
3223 ! allocate(a_chuj(2,2,maxconts,nres)) !(2,2,maxconts,maxres)
3224 ! allocate(a_chuj_der(2,2,3,5,maxconts,nres)) !(2,2,3,5,maxconts,maxres)
3226 ! time00=MPI_Wtime()
3227 !d write (iout,*) "eelecij",i,j
3231 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
3232 aaa=app(iteli,itelj)
3233 bbb=bpp(iteli,itelj)
3234 ael6i=ael6(iteli,itelj)
3235 ael3i=ael3(iteli,itelj)
3239 dx_normj=dc_norm(1,j)
3240 dy_normj=dc_norm(2,j)
3241 dz_normj=dc_norm(3,j)
3242 ! xj=c(1,j)+0.5D0*dxj-xmedi
3243 ! yj=c(2,j)+0.5D0*dyj-ymedi
3244 ! zj=c(3,j)+0.5D0*dzj-zmedi
3249 if (xj.lt.0) xj=xj+boxxsize
3251 if (yj.lt.0) yj=yj+boxysize
3253 if (zj.lt.0) zj=zj+boxzsize
3254 if ((zj.gt.bordlipbot) &
3255 .and.(zj.lt.bordliptop)) then
3256 !C the energy transfer exist
3257 if (zj.lt.buflipbot) then
3258 !C what fraction I am in
3260 ((zj-bordlipbot)/lipbufthick)
3261 !C lipbufthick is thickenes of lipid buffore
3262 sslipj=sscalelip(fracinbuf)
3263 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
3264 elseif (zj.gt.bufliptop) then
3265 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
3266 sslipj=sscalelip(fracinbuf)
3267 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
3278 dist_init=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
3285 xj=xj_safe+xshift*boxxsize
3286 yj=yj_safe+yshift*boxysize
3287 zj=zj_safe+zshift*boxzsize
3288 dist_temp=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
3289 if(dist_temp.lt.dist_init) then
3299 if (isubchap.eq.1) then
3310 rij=xj*xj+yj*yj+zj*zj
3313 !C print *,xmedi,ymedi,zmedi,xj,yj,zj,boxxsize,rij
3314 sss_ele_cut=sscale_ele(rij)
3315 sss_ele_grad=sscagrad_ele(rij)
3317 ! sss_ele_grad=0.0d0
3318 ! print *,sss_ele_cut,sss_ele_grad,&
3319 ! (rij),r_cut_ele,rlamb_ele
3320 ! if (sss_ele_cut.le.0.0) go to 128
3325 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
3326 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
3327 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
3328 fac=cosa-3.0D0*cosb*cosg
3330 ! 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
3331 if (j.eq.i+2) ev1=scal_el*ev1
3336 el1=fac3*(4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg))
3339 if (shield_mode.gt.0) then
3340 !C fac_shield(i)=0.4
3341 !C fac_shield(j)=0.6
3342 el1=el1*fac_shield(i)**2*fac_shield(j)**2
3343 el2=el2*fac_shield(i)**2*fac_shield(j)**2
3345 ees=ees+eesij*sss_ele_cut
3346 !C FOR NOW SHIELD IS NOT USED WITH LIPSCALE
3347 !C & *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3353 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)*sss_ele_cut
3354 !C print *,"TUCC",(sslipi+sslipj)/2.0d0*lipscale**2+1.0d0
3357 ! 12/26/95 - for the evaluation of multi-body H-bonding interactions
3358 ees0ij=4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg)
3359 ! ees=ees+eesij*sss_ele_cut
3360 evdw1=evdw1+evdwij*sss_ele_cut &
3361 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3362 !d write(iout,'(2(2i3,2x),7(1pd12.4)/2(3(1pd12.4),5x)/)')
3363 !d & iteli,i,itelj,j,aaa,bbb,ael6i,ael3i,
3364 !d & 1.0D0/dsqrt(rrmij),evdwij,eesij,
3365 !d & xmedi,ymedi,zmedi,xj,yj,zj
3367 if (energy_dec) then
3368 ! write (iout,'(a6,2i5,0pf7.3,2i5,2e11.3)') &
3369 ! 'evdw1',i,j,evdwij,&
3370 ! iteli,itelj,aaa,evdw1
3371 write (iout,'(a6,2i5,0pf7.3)') 'evdw1',i,j,evdwij
3372 write (iout,'(a6,2i5,0pf7.3)') 'ees',i,j,eesij
3375 ! Calculate contributions to the Cartesian gradient.
3378 facvdw=-6*rrmij*(ev1+evdwij)*sss_ele_cut &
3379 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3380 facel=-3*rrmij*(el1+eesij)*sss_ele_cut &
3381 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3387 ! Radial derivatives. First process both termini of the fragment (i,j)
3389 ggg(1)=facel*xj+sss_ele_grad*rmij*eesij*xj* &
3390 ((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3391 ggg(2)=facel*yj+sss_ele_grad*rmij*eesij*yj* &
3392 ((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3393 ggg(3)=facel*zj+sss_ele_grad*rmij*eesij*zj* &
3394 ((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3396 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
3397 (shield_mode.gt.0)) then
3399 do ilist=1,ishield_list(i)
3400 iresshield=shield_list(ilist,i)
3402 rlocshield=grad_shield_side(k,ilist,i)*eesij/fac_shield(i)&
3404 gshieldx(k,iresshield)=gshieldx(k,iresshield)+ &
3406 +grad_shield_loc(k,ilist,i)*eesij/fac_shield(i)*2.0 &
3408 gshieldc(k,iresshield-1)=gshieldc(k,iresshield-1)+rlocshield
3411 do ilist=1,ishield_list(j)
3412 iresshield=shield_list(ilist,j)
3414 rlocshield=grad_shield_side(k,ilist,j)*eesij/fac_shield(j) &
3416 gshieldx(k,iresshield)=gshieldx(k,iresshield)+ &
3418 +grad_shield_loc(k,ilist,j)*eesij/fac_shield(j)*2.0 &
3420 gshieldc(k,iresshield-1)=gshieldc(k,iresshield-1)+rlocshield
3424 gshieldc(k,i)=gshieldc(k,i)+ &
3425 grad_shield(k,i)*eesij/fac_shield(i)*2.0 &
3428 gshieldc(k,j)=gshieldc(k,j)+ &
3429 grad_shield(k,j)*eesij/fac_shield(j)*2.0 &
3432 gshieldc(k,i-1)=gshieldc(k,i-1)+ &
3433 grad_shield(k,i)*eesij/fac_shield(i)*2.0 &
3436 gshieldc(k,j-1)=gshieldc(k,j-1)+ &
3437 grad_shield(k,j)*eesij/fac_shield(j)*2.0 &
3445 ! ghalf=0.5D0*ggg(k)
3446 ! gelc(k,i)=gelc(k,i)+ghalf
3447 ! gelc(k,j)=gelc(k,j)+ghalf
3449 ! 9/28/08 AL Gradient compotents will be summed only at the end
3451 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
3452 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
3454 gelc_long(3,j)=gelc_long(3,j)+ &
3455 ssgradlipj*eesij/2.0d0*lipscale**2&
3458 gelc_long(3,i)=gelc_long(3,i)+ &
3459 ssgradlipi*eesij/2.0d0*lipscale**2&
3464 ! Loop over residues i+1 thru j-1.
3468 !grad gelc(l,k)=gelc(l,k)+ggg(l)
3471 ggg(1)=facvdw*xj+sss_ele_grad*rmij*evdwij*xj &
3472 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3473 ggg(2)=facvdw*yj+sss_ele_grad*rmij*evdwij*yj &
3474 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3475 ggg(3)=facvdw*zj+sss_ele_grad*rmij*evdwij*zj &
3476 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3479 ! ghalf=0.5D0*ggg(k)
3480 ! gvdwpp(k,i)=gvdwpp(k,i)+ghalf
3481 ! gvdwpp(k,j)=gvdwpp(k,j)+ghalf
3483 ! 9/28/08 AL Gradient compotents will be summed only at the end
3485 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
3486 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
3489 !C Lipidic part for scaling weight
3490 gvdwpp(3,j)=gvdwpp(3,j)+ &
3491 sss_ele_cut*ssgradlipj*evdwij/2.0d0*lipscale**2
3492 gvdwpp(3,i)=gvdwpp(3,i)+ &
3493 sss_ele_cut*ssgradlipi*evdwij/2.0d0*lipscale**2
3494 !! Loop over residues i+1 thru j-1.
3498 !grad gvdwpp(l,k)=gvdwpp(l,k)+ggg(l)
3502 facvdw=(ev1+evdwij)*sss_ele_cut &
3503 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3505 facel=(el1+eesij)*sss_ele_cut
3507 fac=-3*rrmij*(facvdw+facvdw+facel)
3512 ! Radial derivatives. First process both termini of the fragment (i,j)
3514 ggg(1)=fac*xj+sss_ele_grad*rmij*(eesij+evdwij)*xj
3515 ggg(2)=fac*yj+sss_ele_grad*rmij*(eesij+evdwij)*yj
3516 ggg(3)=fac*zj+sss_ele_grad*rmij*(eesij+evdwij)*zj
3518 ! ghalf=0.5D0*ggg(k)
3519 ! gelc(k,i)=gelc(k,i)+ghalf
3520 ! gelc(k,j)=gelc(k,j)+ghalf
3522 ! 9/28/08 AL Gradient compotents will be summed only at the end
3524 gelc_long(k,j)=gelc(k,j)+ggg(k)
3525 gelc_long(k,i)=gelc(k,i)-ggg(k)
3528 ! Loop over residues i+1 thru j-1.
3532 !grad gelc(l,k)=gelc(l,k)+ggg(l)
3535 ! 9/28/08 AL Gradient compotents will be summed only at the end
3537 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3539 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3541 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3544 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
3545 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
3547 gvdwpp(3,j)=gvdwpp(3,j)+ &
3548 sss_ele_cut*ssgradlipj*evdwij/2.0d0*lipscale**2
3549 gvdwpp(3,i)=gvdwpp(3,i)+ &
3550 sss_ele_cut*ssgradlipi*evdwij/2.0d0*lipscale**2
3556 ecosa=2.0D0*fac3*fac1+fac4
3559 ecosb=(fac3*(fac1*cosg+cosb)+cosg*fac4)
3560 ecosg=(fac3*(fac1*cosb+cosg)+cosb*fac4)
3562 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
3563 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
3565 !d print '(2i3,2(3(1pd14.5),3x))',i,j,(dcosb(k),k=1,3),
3566 !d & (dcosg(k),k=1,3)
3568 ggg(k)=(ecosb*dcosb(k)+ecosg*dcosg(k))*sss_ele_cut &
3569 *fac_shield(i)**2*fac_shield(j)**2 &
3570 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3574 ! ghalf=0.5D0*ggg(k)
3575 ! gelc(k,i)=gelc(k,i)+ghalf
3576 ! & +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
3577 ! & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
3578 ! gelc(k,j)=gelc(k,j)+ghalf
3579 ! & +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
3580 ! & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
3584 !grad gelc(l,k)=gelc(l,k)+ggg(l)
3588 gelc(k,i)=gelc(k,i) &
3589 +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
3590 + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)&
3592 *fac_shield(i)**2*fac_shield(j)**2 &
3593 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3595 gelc(k,j)=gelc(k,j) &
3596 +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
3597 + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
3599 *fac_shield(i)**2*fac_shield(j)**2 &
3600 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3602 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
3603 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
3606 IF (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
3607 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 &
3608 .or. wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
3610 ! 9/25/99 Mixed third-order local-electrostatic terms. The local-interaction
3611 ! energy of a peptide unit is assumed in the form of a second-order
3612 ! Fourier series in the angles lambda1 and lambda2 (see Nishikawa et al.
3613 ! Macromolecules, 1974, 7, 797-806 for definition). This correlation terms
3614 ! are computed for EVERY pair of non-contiguous peptide groups.
3616 if (j.lt.nres-1) then
3627 muij(kkk)=mu(k,i)*mu(l,j)
3630 !d write (iout,*) 'EELEC: i',i,' j',j
3631 !d write (iout,*) 'j',j,' j1',j1,' j2',j2
3632 !d write(iout,*) 'muij',muij
3633 ury=scalar(uy(1,i),erij)
3634 urz=scalar(uz(1,i),erij)
3635 vry=scalar(uy(1,j),erij)
3636 vrz=scalar(uz(1,j),erij)
3637 a22=scalar(uy(1,i),uy(1,j))-3*ury*vry
3638 a23=scalar(uy(1,i),uz(1,j))-3*ury*vrz
3639 a32=scalar(uz(1,i),uy(1,j))-3*urz*vry
3640 a33=scalar(uz(1,i),uz(1,j))-3*urz*vrz
3641 fac=dsqrt(-ael6i)*r3ij
3646 !d write (iout,'(4i5,4f10.5)')
3647 !d & i,itortyp(itype(i,1)),j,itortyp(itype(j,1)),a22,a23,a32,a33
3648 !d write (iout,'(6f10.5)') (muij(k),k=1,4),fac,eel_loc_ij
3649 !d write (iout,'(2(3f10.5,5x)/2(3f10.5,5x))') uy(:,i),uz(:,i),
3650 !d & uy(:,j),uz(:,j)
3651 !d write (iout,'(4f10.5)')
3652 !d & scalar(uy(1,i),uy(1,j)),scalar(uy(1,i),uz(1,j)),
3653 !d & scalar(uz(1,i),uy(1,j)),scalar(uz(1,i),uz(1,j))
3654 !d write (iout,'(4f10.5)') ury,urz,vry,vrz
3655 !d write (iout,'(9f10.5/)')
3656 !d & fac22,a22,fac23,a23,fac32,a32,fac33,a33,eel_loc_ij
3657 ! Derivatives of the elements of A in virtual-bond vectors
3658 call unormderiv(erij(1),unmat(1,1),rmij,erder(1,1))
3660 uryg(k,1)=scalar(erder(1,k),uy(1,i))
3661 uryg(k,2)=scalar(uygrad(1,k,1,i),erij(1))
3662 uryg(k,3)=scalar(uygrad(1,k,2,i),erij(1))
3663 urzg(k,1)=scalar(erder(1,k),uz(1,i))
3664 urzg(k,2)=scalar(uzgrad(1,k,1,i),erij(1))
3665 urzg(k,3)=scalar(uzgrad(1,k,2,i),erij(1))
3666 vryg(k,1)=scalar(erder(1,k),uy(1,j))
3667 vryg(k,2)=scalar(uygrad(1,k,1,j),erij(1))
3668 vryg(k,3)=scalar(uygrad(1,k,2,j),erij(1))
3669 vrzg(k,1)=scalar(erder(1,k),uz(1,j))
3670 vrzg(k,2)=scalar(uzgrad(1,k,1,j),erij(1))
3671 vrzg(k,3)=scalar(uzgrad(1,k,2,j),erij(1))
3673 ! Compute radial contributions to the gradient
3691 ! Add the contributions coming from er
3694 agg(k,1)=agg(k,1)+fac3*(uryg(k,1)*vry+vryg(k,1)*ury)
3695 agg(k,2)=agg(k,2)+fac3*(uryg(k,1)*vrz+vrzg(k,1)*ury)
3696 agg(k,3)=agg(k,3)+fac3*(urzg(k,1)*vry+vryg(k,1)*urz)
3697 agg(k,4)=agg(k,4)+fac3*(urzg(k,1)*vrz+vrzg(k,1)*urz)
3700 ! Derivatives in DC(i)
3701 !grad ghalf1=0.5d0*agg(k,1)
3702 !grad ghalf2=0.5d0*agg(k,2)
3703 !grad ghalf3=0.5d0*agg(k,3)
3704 !grad ghalf4=0.5d0*agg(k,4)
3705 aggi(k,1)=fac*(scalar(uygrad(1,k,1,i),uy(1,j)) &
3706 -3.0d0*uryg(k,2)*vry)!+ghalf1
3707 aggi(k,2)=fac*(scalar(uygrad(1,k,1,i),uz(1,j)) &
3708 -3.0d0*uryg(k,2)*vrz)!+ghalf2
3709 aggi(k,3)=fac*(scalar(uzgrad(1,k,1,i),uy(1,j)) &
3710 -3.0d0*urzg(k,2)*vry)!+ghalf3
3711 aggi(k,4)=fac*(scalar(uzgrad(1,k,1,i),uz(1,j)) &
3712 -3.0d0*urzg(k,2)*vrz)!+ghalf4
3713 ! Derivatives in DC(i+1)
3714 aggi1(k,1)=fac*(scalar(uygrad(1,k,2,i),uy(1,j)) &
3715 -3.0d0*uryg(k,3)*vry)!+agg(k,1)
3716 aggi1(k,2)=fac*(scalar(uygrad(1,k,2,i),uz(1,j)) &
3717 -3.0d0*uryg(k,3)*vrz)!+agg(k,2)
3718 aggi1(k,3)=fac*(scalar(uzgrad(1,k,2,i),uy(1,j)) &
3719 -3.0d0*urzg(k,3)*vry)!+agg(k,3)
3720 aggi1(k,4)=fac*(scalar(uzgrad(1,k,2,i),uz(1,j)) &
3721 -3.0d0*urzg(k,3)*vrz)!+agg(k,4)
3722 ! Derivatives in DC(j)
3723 aggj(k,1)=fac*(scalar(uygrad(1,k,1,j),uy(1,i)) &
3724 -3.0d0*vryg(k,2)*ury)!+ghalf1
3725 aggj(k,2)=fac*(scalar(uzgrad(1,k,1,j),uy(1,i)) &
3726 -3.0d0*vrzg(k,2)*ury)!+ghalf2
3727 aggj(k,3)=fac*(scalar(uygrad(1,k,1,j),uz(1,i)) &
3728 -3.0d0*vryg(k,2)*urz)!+ghalf3
3729 aggj(k,4)=fac*(scalar(uzgrad(1,k,1,j),uz(1,i)) &
3730 -3.0d0*vrzg(k,2)*urz)!+ghalf4
3731 ! Derivatives in DC(j+1) or DC(nres-1)
3732 aggj1(k,1)=fac*(scalar(uygrad(1,k,2,j),uy(1,i)) &
3733 -3.0d0*vryg(k,3)*ury)
3734 aggj1(k,2)=fac*(scalar(uzgrad(1,k,2,j),uy(1,i)) &
3735 -3.0d0*vrzg(k,3)*ury)
3736 aggj1(k,3)=fac*(scalar(uygrad(1,k,2,j),uz(1,i)) &
3737 -3.0d0*vryg(k,3)*urz)
3738 aggj1(k,4)=fac*(scalar(uzgrad(1,k,2,j),uz(1,i)) &
3739 -3.0d0*vrzg(k,3)*urz)
3740 !grad if (j.eq.nres-1 .and. i.lt.j-2) then
3742 !grad aggj1(k,l)=aggj1(k,l)+agg(k,l)
3755 aggi(k,l)=-aggi(k,l)
3756 aggi1(k,l)=-aggi1(k,l)
3757 aggj(k,l)=-aggj(k,l)
3758 aggj1(k,l)=-aggj1(k,l)
3761 if (j.lt.nres-1) then
3767 aggi(k,l)=-aggi(k,l)
3768 aggi1(k,l)=-aggi1(k,l)
3769 aggj(k,l)=-aggj(k,l)
3770 aggj1(k,l)=-aggj1(k,l)
3781 aggi(k,l)=-aggi(k,l)
3782 aggi1(k,l)=-aggi1(k,l)
3783 aggj(k,l)=-aggj(k,l)
3784 aggj1(k,l)=-aggj1(k,l)
3789 IF (wel_loc.gt.0.0d0) THEN
3790 ! Contribution to the local-electrostatic energy coming from the i-j pair
3791 eel_loc_ij=a22*muij(1)+a23*muij(2)+a32*muij(3) &
3793 if (shield_mode.eq.0) then
3797 eel_loc_ij=eel_loc_ij &
3798 *fac_shield(i)*fac_shield(j) &
3799 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
3800 !C Now derivative over eel_loc
3801 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
3802 (shield_mode.gt.0)) then
3805 do ilist=1,ishield_list(i)
3806 iresshield=shield_list(ilist,i)
3808 rlocshield=grad_shield_side(k,ilist,i)*eel_loc_ij &
3811 gshieldx_ll(k,iresshield)=gshieldx_ll(k,iresshield)+ &
3813 +grad_shield_loc(k,ilist,i)*eel_loc_ij/fac_shield(i) &
3816 gshieldc_ll(k,iresshield-1)=gshieldc_ll(k,iresshield-1)&
3820 do ilist=1,ishield_list(j)
3821 iresshield=shield_list(ilist,j)
3823 rlocshield=grad_shield_side(k,ilist,j)*eel_loc_ij &
3826 gshieldx_ll(k,iresshield)=gshieldx_ll(k,iresshield)+ &
3828 +grad_shield_loc(k,ilist,j)*eel_loc_ij/fac_shield(j) &
3831 gshieldc_ll(k,iresshield-1)=gshieldc_ll(k,iresshield-1)&
3838 gshieldc_ll(k,i)=gshieldc_ll(k,i)+ &
3839 grad_shield(k,i)*eel_loc_ij/fac_shield(i) &
3841 gshieldc_ll(k,j)=gshieldc_ll(k,j)+ &
3842 grad_shield(k,j)*eel_loc_ij/fac_shield(j) &
3844 gshieldc_ll(k,i-1)=gshieldc_ll(k,i-1)+ &
3845 grad_shield(k,i)*eel_loc_ij/fac_shield(i) &
3847 gshieldc_ll(k,j-1)=gshieldc_ll(k,j-1)+ &
3848 grad_shield(k,j)*eel_loc_ij/fac_shield(j) &
3855 ! write (iout,*) 'i',i,' j',j,' eel_loc_ij',eel_loc_ij
3857 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
3858 'eelloc',i,j,eel_loc_ij
3859 ! if (energy_dec) write (iout,*) "a22",a22," a23",a23," a32",a32," a33",a33
3860 ! if (energy_dec) write (iout,*) "muij",muij
3861 ! write (iout,*) a22,muij(1),a23,muij(2),a32,muij(3)
3863 eel_loc=eel_loc+eel_loc_ij*sss_ele_cut
3864 ! Partial derivatives in virtual-bond dihedral angles gamma
3866 gel_loc_loc(i-1)=gel_loc_loc(i-1)+ &
3867 (a22*muder(1,i)*mu(1,j)+a23*muder(1,i)*mu(2,j) &
3868 +a32*muder(2,i)*mu(1,j)+a33*muder(2,i)*mu(2,j)) &
3870 *fac_shield(i)*fac_shield(j) &
3871 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
3873 gel_loc_loc(j-1)=gel_loc_loc(j-1)+ &
3874 (a22*mu(1,i)*muder(1,j)+a23*mu(1,i)*muder(2,j) &
3875 +a32*mu(2,i)*muder(1,j)+a33*mu(2,i)*muder(2,j)) &
3877 *fac_shield(i)*fac_shield(j) &
3878 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
3879 ! Derivatives of eello in DC(i+1) thru DC(j-1) or DC(nres-2)
3881 ! ggg(1)=(agg(1,1)*muij(1)+ &
3882 ! agg(1,2)*muij(2)+agg(1,3)*muij(3)+agg(1,4)*muij(4)) &
3884 ! +eel_loc_ij*sss_ele_grad*rmij*xj
3885 ! ggg(2)=(agg(2,1)*muij(1)+ &
3886 ! agg(2,2)*muij(2)+agg(2,3)*muij(3)+agg(2,4)*muij(4)) &
3888 ! +eel_loc_ij*sss_ele_grad*rmij*yj
3889 ! ggg(3)=(agg(3,1)*muij(1)+ &
3890 ! agg(3,2)*muij(2)+agg(3,3)*muij(3)+agg(3,4)*muij(4)) &
3892 ! +eel_loc_ij*sss_ele_grad*rmij*zj
3898 ggg(l)=(agg(l,1)*muij(1)+ &
3899 agg(l,2)*muij(2)+agg(l,3)*muij(3)+agg(l,4)*muij(4))&
3901 *fac_shield(i)*fac_shield(j) &
3902 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0) &
3903 +eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
3906 gel_loc_long(l,j)=gel_loc_long(l,j)+ggg(l)
3907 gel_loc_long(l,i)=gel_loc_long(l,i)-ggg(l)
3908 !grad ghalf=0.5d0*ggg(l)
3909 !grad gel_loc(l,i)=gel_loc(l,i)+ghalf
3910 !grad gel_loc(l,j)=gel_loc(l,j)+ghalf
3912 gel_loc_long(3,j)=gel_loc_long(3,j)+ &
3913 ssgradlipj*eel_loc_ij/2.0d0*lipscale/ &
3914 ((sslipi+sslipj)/2.0d0*lipscale+1.0d0)*sss_ele_cut
3916 gel_loc_long(3,i)=gel_loc_long(3,i)+ &
3917 ssgradlipi*eel_loc_ij/2.0d0*lipscale/ &
3918 ((sslipi+sslipj)/2.0d0*lipscale+1.0d0)*sss_ele_cut
3922 !grad gel_loc(l,k)=gel_loc(l,k)+ggg(l)
3925 ! Remaining derivatives of eello
3927 gel_loc(l,i)=gel_loc(l,i)+(aggi(l,1)*muij(1)+ &
3928 aggi(l,2)*muij(2)+aggi(l,3)*muij(3)+aggi(l,4)*muij(4))&
3930 *fac_shield(i)*fac_shield(j) &
3931 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
3933 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
3934 gel_loc(l,i+1)=gel_loc(l,i+1)+(aggi1(l,1)*muij(1)+ &
3935 aggi1(l,2)*muij(2)+aggi1(l,3)*muij(3) &
3936 +aggi1(l,4)*muij(4))&
3938 *fac_shield(i)*fac_shield(j) &
3939 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
3941 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
3942 gel_loc(l,j)=gel_loc(l,j)+(aggj(l,1)*muij(1)+ &
3943 aggj(l,2)*muij(2)+aggj(l,3)*muij(3)+aggj(l,4)*muij(4))&
3945 *fac_shield(i)*fac_shield(j) &
3946 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
3948 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
3949 gel_loc(l,j1)=gel_loc(l,j1)+(aggj1(l,1)*muij(1)+ &
3950 aggj1(l,2)*muij(2)+aggj1(l,3)*muij(3) &
3951 +aggj1(l,4)*muij(4))&
3953 *fac_shield(i)*fac_shield(j) &
3954 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
3956 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
3959 ! Change 12/26/95 to calculate four-body contributions to H-bonding energy
3960 ! if (j.gt.i+1 .and. num_conti.le.maxconts) then
3961 if (wcorr+wcorr4+wcorr5+wcorr6.gt.0.0d0 &
3962 .and. num_conti.le.maxconts) then
3963 ! write (iout,*) i,j," entered corr"
3965 ! Calculate the contact function. The ith column of the array JCONT will
3966 ! contain the numbers of atoms that make contacts with the atom I (of numbers
3967 ! greater than I). The arrays FACONT and GACONT will contain the values of
3968 ! the contact function and its derivative.
3969 ! r0ij=1.02D0*rpp(iteli,itelj)
3970 ! r0ij=1.11D0*rpp(iteli,itelj)
3971 r0ij=2.20D0*rpp(iteli,itelj)
3972 ! r0ij=1.55D0*rpp(iteli,itelj)
3973 call gcont(rij,r0ij,1.0D0,0.2d0*r0ij,fcont,fprimcont)
3974 !elwrite(iout,*) "num_conti",num_conti, "maxconts",maxconts
3975 if (fcont.gt.0.0D0) then
3976 num_conti=num_conti+1
3977 if (num_conti.gt.maxconts) then
3978 !el write (iout,*) "esrgresgdsrgdfsrgdswrgaresfgaerwgae"
3979 !el write (iout,*) "num_conti",num_conti, "maxconts",maxconts
3980 write (iout,*) 'WARNING - max. # of contacts exceeded;',&
3981 ' will skip next contacts for this conf.', num_conti
3983 jcont_hb(num_conti,i)=j
3984 !d write (iout,*) "i",i," j",j," num_conti",num_conti,
3985 !d & " jcont_hb",jcont_hb(num_conti,i)
3986 IF (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. &
3987 wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
3988 ! 9/30/99 (AL) - store components necessary to evaluate higher-order loc-el
3990 d_cont(num_conti,i)=rij
3991 !d write (2,'(3e15.5)') rij,r0ij+0.2d0*r0ij,rij
3992 ! --- Electrostatic-interaction matrix ---
3993 a_chuj(1,1,num_conti,i)=a22
3994 a_chuj(1,2,num_conti,i)=a23
3995 a_chuj(2,1,num_conti,i)=a32
3996 a_chuj(2,2,num_conti,i)=a33
3997 ! --- Gradient of rij
3999 grij_hb_cont(kkk,num_conti,i)=erij(kkk)
4006 a_chuj_der(k,l,m,1,num_conti,i)=agg(m,kkll)
4007 a_chuj_der(k,l,m,2,num_conti,i)=aggi(m,kkll)
4008 a_chuj_der(k,l,m,3,num_conti,i)=aggi1(m,kkll)
4009 a_chuj_der(k,l,m,4,num_conti,i)=aggj(m,kkll)
4010 a_chuj_der(k,l,m,5,num_conti,i)=aggj1(m,kkll)
4015 IF (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) THEN
4016 ! Calculate contact energies
4018 wij=cosa-3.0D0*cosb*cosg
4021 ! fac3=dsqrt(-ael6i)/r0ij**3
4022 fac3=dsqrt(-ael6i)*r3ij
4023 ! ees0pij=dsqrt(4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1)
4024 ees0tmp=4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1
4025 if (ees0tmp.gt.0) then
4026 ees0pij=dsqrt(ees0tmp)
4030 if (shield_mode.eq.0) then
4034 ees0plist(num_conti,i)=j
4036 ! ees0mij=dsqrt(4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2)
4037 ees0tmp=4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2
4038 if (ees0tmp.gt.0) then
4039 ees0mij=dsqrt(ees0tmp)
4044 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij) &
4046 *fac_shield(i)*fac_shield(j)
4048 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij) &
4050 *fac_shield(i)*fac_shield(j)
4052 ! Diagnostics. Comment out or remove after debugging!
4053 ! ees0p(num_conti,i)=0.5D0*fac3*ees0pij
4054 ! ees0m(num_conti,i)=0.5D0*fac3*ees0mij
4055 ! ees0m(num_conti,i)=0.0D0
4057 ! write (iout,*) 'i=',i,' j=',j,' rij=',rij,' r0ij=',r0ij,
4058 ! & ' ees0ij=',ees0p(num_conti,i),ees0m(num_conti,i),' fcont=',fcont
4059 ! Angular derivatives of the contact function
4060 ees0pij1=fac3/ees0pij
4061 ees0mij1=fac3/ees0mij
4062 fac3p=-3.0D0*fac3*rrmij
4063 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
4064 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
4066 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
4067 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
4068 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
4069 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
4070 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
4071 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
4072 ecosap=ecosa1+ecosa2
4073 ecosbp=ecosb1+ecosb2
4074 ecosgp=ecosg1+ecosg2
4075 ecosam=ecosa1-ecosa2
4076 ecosbm=ecosb1-ecosb2
4077 ecosgm=ecosg1-ecosg2
4086 facont_hb(num_conti,i)=fcont
4087 fprimcont=fprimcont/rij
4088 !d facont_hb(num_conti,i)=1.0D0
4089 ! Following line is for diagnostics.
4092 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
4093 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
4096 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
4097 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
4099 gggp(1)=gggp(1)+ees0pijp*xj &
4100 +ees0p(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
4101 gggp(2)=gggp(2)+ees0pijp*yj &
4102 +ees0p(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
4103 gggp(3)=gggp(3)+ees0pijp*zj &
4104 +ees0p(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
4106 gggm(1)=gggm(1)+ees0mijp*xj &
4107 +ees0m(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
4109 gggm(2)=gggm(2)+ees0mijp*yj &
4110 +ees0m(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
4112 gggm(3)=gggm(3)+ees0mijp*zj &
4113 +ees0m(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
4115 ! Derivatives due to the contact function
4116 gacont_hbr(1,num_conti,i)=fprimcont*xj
4117 gacont_hbr(2,num_conti,i)=fprimcont*yj
4118 gacont_hbr(3,num_conti,i)=fprimcont*zj
4121 ! 10/24/08 cgrad and ! comments indicate the parts of the code removed
4122 ! following the change of gradient-summation algorithm.
4124 !grad ghalfp=0.5D0*gggp(k)
4125 !grad ghalfm=0.5D0*gggm(k)
4126 gacontp_hb1(k,num_conti,i)= & !ghalfp+
4127 (ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
4128 + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
4129 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4131 gacontp_hb2(k,num_conti,i)= & !ghalfp+
4132 (ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
4133 + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
4134 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4136 gacontp_hb3(k,num_conti,i)=gggp(k) &
4137 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4139 gacontm_hb1(k,num_conti,i)= & !ghalfm+
4140 (ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
4141 + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
4142 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4144 gacontm_hb2(k,num_conti,i)= & !ghalfm+
4145 (ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
4146 + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1) &
4147 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4149 gacontm_hb3(k,num_conti,i)=gggm(k) &
4150 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4153 ! Diagnostics. Comment out or remove after debugging!
4155 !diag gacontp_hb1(k,num_conti,i)=0.0D0
4156 !diag gacontp_hb2(k,num_conti,i)=0.0D0
4157 !diag gacontp_hb3(k,num_conti,i)=0.0D0
4158 !diag gacontm_hb1(k,num_conti,i)=0.0D0
4159 !diag gacontm_hb2(k,num_conti,i)=0.0D0
4160 !diag gacontm_hb3(k,num_conti,i)=0.0D0
4163 endif ! num_conti.le.maxconts
4166 if (wturn3.gt.0.0d0 .or. wturn4.gt.0.0d0) then
4169 ghalf=0.5d0*agg(l,k)
4170 aggi(l,k)=aggi(l,k)+ghalf
4171 aggi1(l,k)=aggi1(l,k)+agg(l,k)
4172 aggj(l,k)=aggj(l,k)+ghalf
4175 if (j.eq.nres-1 .and. i.lt.j-2) then
4178 aggj1(l,k)=aggj1(l,k)+agg(l,k)
4184 ! t_eelecij=t_eelecij+MPI_Wtime()-time00
4186 end subroutine eelecij
4187 !-----------------------------------------------------------------------------
4188 subroutine eturn3(i,eello_turn3)
4189 ! Third- and fourth-order contributions from turns
4192 ! implicit real*8 (a-h,o-z)
4193 ! include 'DIMENSIONS'
4194 ! include 'COMMON.IOUNITS'
4195 ! include 'COMMON.GEO'
4196 ! include 'COMMON.VAR'
4197 ! include 'COMMON.LOCAL'
4198 ! include 'COMMON.CHAIN'
4199 ! include 'COMMON.DERIV'
4200 ! include 'COMMON.INTERACT'
4201 ! include 'COMMON.CONTACTS'
4202 ! include 'COMMON.TORSION'
4203 ! include 'COMMON.VECTORS'
4204 ! include 'COMMON.FFIELD'
4205 ! include 'COMMON.CONTROL'
4206 real(kind=8),dimension(3) :: ggg
4207 real(kind=8),dimension(2,2) :: auxmat,auxmat1,auxmat2,pizda,&
4208 e1t,e2t,e3t,e1tder,e2tder,e3tder,e1a,ae3,ae3e2
4209 real(kind=8),dimension(2) :: auxvec,auxvec1
4210 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
4211 real(kind=8),dimension(2,2) :: auxmat3 !el, a_temp
4212 !el integer :: num_conti,j1,j2
4213 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
4214 !el dz_normi,xmedi,ymedi,zmedi
4216 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
4217 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
4220 integer :: i,j,l,k,ilist,iresshield
4221 real(kind=8) :: eello_turn3,zj,fracinbuf,eello_t3, rlocshield
4224 ! write (iout,*) "eturn3",i,j,j1,j2
4225 zj=(c(3,j)+c(3,j+1))/2.0d0
4227 if (zj.lt.0) zj=zj+boxzsize
4228 if ((zj.lt.0)) write (*,*) "CHUJ"
4229 if ((zj.gt.bordlipbot) &
4230 .and.(zj.lt.bordliptop)) then
4231 !C the energy transfer exist
4232 if (zj.lt.buflipbot) then
4233 !C what fraction I am in
4235 ((zj-bordlipbot)/lipbufthick)
4236 !C lipbufthick is thickenes of lipid buffore
4237 sslipj=sscalelip(fracinbuf)
4238 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
4239 elseif (zj.gt.bufliptop) then
4240 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
4241 sslipj=sscalelip(fracinbuf)
4242 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
4256 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4258 ! Third-order contributions
4265 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4266 !d call checkint_turn3(i,a_temp,eello_turn3_num)
4267 call matmat2(EUg(1,1,i+1),EUg(1,1,i+2),auxmat(1,1))
4268 call transpose2(auxmat(1,1),auxmat1(1,1))
4269 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4270 if (shield_mode.eq.0) then
4275 eello_turn3=eello_turn3+0.5d0*(pizda(1,1)+pizda(2,2)) &
4276 *fac_shield(i)*fac_shield(j) &
4277 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4279 0.5d0*(pizda(1,1)+pizda(2,2)) &
4280 *fac_shield(i)*fac_shield(j)
4282 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
4283 'eturn3',i,j,0.5d0*(pizda(1,1)+pizda(2,2))
4284 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
4285 (shield_mode.gt.0)) then
4288 do ilist=1,ishield_list(i)
4289 iresshield=shield_list(ilist,i)
4291 rlocshield=grad_shield_side(k,ilist,i)*eello_t3/fac_shield(i)
4292 gshieldx_t3(k,iresshield)=gshieldx_t3(k,iresshield)+ &
4294 +grad_shield_loc(k,ilist,i)*eello_t3/fac_shield(i)
4295 gshieldc_t3(k,iresshield-1)=gshieldc_t3(k,iresshield-1) &
4299 do ilist=1,ishield_list(j)
4300 iresshield=shield_list(ilist,j)
4302 rlocshield=grad_shield_side(k,ilist,j)*eello_t3/fac_shield(j)
4303 gshieldx_t3(k,iresshield)=gshieldx_t3(k,iresshield)+ &
4305 +grad_shield_loc(k,ilist,j)*eello_t3/fac_shield(j)
4306 gshieldc_t3(k,iresshield-1)=gshieldc_t3(k,iresshield-1) &
4313 gshieldc_t3(k,i)=gshieldc_t3(k,i)+ &
4314 grad_shield(k,i)*eello_t3/fac_shield(i)
4315 gshieldc_t3(k,j)=gshieldc_t3(k,j)+ &
4316 grad_shield(k,j)*eello_t3/fac_shield(j)
4317 gshieldc_t3(k,i-1)=gshieldc_t3(k,i-1)+ &
4318 grad_shield(k,i)*eello_t3/fac_shield(i)
4319 gshieldc_t3(k,j-1)=gshieldc_t3(k,j-1)+ &
4320 grad_shield(k,j)*eello_t3/fac_shield(j)
4324 !d write (2,*) 'i,',i,' j',j,'eello_turn3',
4325 !d & 0.5d0*(pizda(1,1)+pizda(2,2)),
4326 !d & ' eello_turn3_num',4*eello_turn3_num
4327 ! Derivatives in gamma(i)
4328 call matmat2(EUgder(1,1,i+1),EUg(1,1,i+2),auxmat2(1,1))
4329 call transpose2(auxmat2(1,1),auxmat3(1,1))
4330 call matmat2(a_temp(1,1),auxmat3(1,1),pizda(1,1))
4331 gel_loc_turn3(i)=gel_loc_turn3(i)+0.5d0*(pizda(1,1)+pizda(2,2))&
4332 *fac_shield(i)*fac_shield(j) &
4333 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4334 ! Derivatives in gamma(i+1)
4335 call matmat2(EUg(1,1,i+1),EUgder(1,1,i+2),auxmat2(1,1))
4336 call transpose2(auxmat2(1,1),auxmat3(1,1))
4337 call matmat2(a_temp(1,1),auxmat3(1,1),pizda(1,1))
4338 gel_loc_turn3(i+1)=gel_loc_turn3(i+1) &
4339 +0.5d0*(pizda(1,1)+pizda(2,2)) &
4340 *fac_shield(i)*fac_shield(j) &
4341 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4343 ! Cartesian derivatives
4345 ! ghalf1=0.5d0*agg(l,1)
4346 ! ghalf2=0.5d0*agg(l,2)
4347 ! ghalf3=0.5d0*agg(l,3)
4348 ! ghalf4=0.5d0*agg(l,4)
4349 a_temp(1,1)=aggi(l,1)!+ghalf1
4350 a_temp(1,2)=aggi(l,2)!+ghalf2
4351 a_temp(2,1)=aggi(l,3)!+ghalf3
4352 a_temp(2,2)=aggi(l,4)!+ghalf4
4353 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4354 gcorr3_turn(l,i)=gcorr3_turn(l,i) &
4355 +0.5d0*(pizda(1,1)+pizda(2,2)) &
4356 *fac_shield(i)*fac_shield(j) &
4357 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4359 a_temp(1,1)=aggi1(l,1)!+agg(l,1)
4360 a_temp(1,2)=aggi1(l,2)!+agg(l,2)
4361 a_temp(2,1)=aggi1(l,3)!+agg(l,3)
4362 a_temp(2,2)=aggi1(l,4)!+agg(l,4)
4363 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4364 gcorr3_turn(l,i+1)=gcorr3_turn(l,i+1) &
4365 +0.5d0*(pizda(1,1)+pizda(2,2)) &
4366 *fac_shield(i)*fac_shield(j) &
4367 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4369 a_temp(1,1)=aggj(l,1)!+ghalf1
4370 a_temp(1,2)=aggj(l,2)!+ghalf2
4371 a_temp(2,1)=aggj(l,3)!+ghalf3
4372 a_temp(2,2)=aggj(l,4)!+ghalf4
4373 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4374 gcorr3_turn(l,j)=gcorr3_turn(l,j) &
4375 +0.5d0*(pizda(1,1)+pizda(2,2)) &
4376 *fac_shield(i)*fac_shield(j) &
4377 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4379 a_temp(1,1)=aggj1(l,1)
4380 a_temp(1,2)=aggj1(l,2)
4381 a_temp(2,1)=aggj1(l,3)
4382 a_temp(2,2)=aggj1(l,4)
4383 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4384 gcorr3_turn(l,j1)=gcorr3_turn(l,j1) &
4385 +0.5d0*(pizda(1,1)+pizda(2,2)) &
4386 *fac_shield(i)*fac_shield(j) &
4387 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4389 gshieldc_t3(3,i)=gshieldc_t3(3,i)+ &
4390 ssgradlipi*eello_t3/4.0d0*lipscale
4391 gshieldc_t3(3,j)=gshieldc_t3(3,j)+ &
4392 ssgradlipj*eello_t3/4.0d0*lipscale
4393 gshieldc_t3(3,i-1)=gshieldc_t3(3,i-1)+ &
4394 ssgradlipi*eello_t3/4.0d0*lipscale
4395 gshieldc_t3(3,j-1)=gshieldc_t3(3,j-1)+ &
4396 ssgradlipj*eello_t3/4.0d0*lipscale
4399 end subroutine eturn3
4400 !-----------------------------------------------------------------------------
4401 subroutine eturn4(i,eello_turn4)
4402 ! Third- and fourth-order contributions from turns
4405 ! implicit real*8 (a-h,o-z)
4406 ! include 'DIMENSIONS'
4407 ! include 'COMMON.IOUNITS'
4408 ! include 'COMMON.GEO'
4409 ! include 'COMMON.VAR'
4410 ! include 'COMMON.LOCAL'
4411 ! include 'COMMON.CHAIN'
4412 ! include 'COMMON.DERIV'
4413 ! include 'COMMON.INTERACT'
4414 ! include 'COMMON.CONTACTS'
4415 ! include 'COMMON.TORSION'
4416 ! include 'COMMON.VECTORS'
4417 ! include 'COMMON.FFIELD'
4418 ! include 'COMMON.CONTROL'
4419 real(kind=8),dimension(3) :: ggg
4420 real(kind=8),dimension(2,2) :: auxmat,auxmat1,auxmat2,pizda,&
4421 e1t,e2t,e3t,e1tder,e2tder,e3tder,e1a,ae3,ae3e2
4422 real(kind=8),dimension(2) :: auxvec,auxvec1
4423 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
4424 real(kind=8),dimension(2,2) :: auxmat3 !el a_temp
4425 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
4426 !el dz_normi,xmedi,ymedi,zmedi
4427 !el integer :: num_conti,j1,j2
4428 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
4429 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
4432 integer :: i,j,iti1,iti2,iti3,l,k,ilist,iresshield
4433 real(kind=8) :: eello_turn4,s1,s2,s3,zj,fracinbuf,eello_t4,&
4437 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4439 ! Fourth-order contributions
4447 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4448 !d call checkint_turn4(i,a_temp,eello_turn4_num)
4449 ! write (iout,*) "eturn4 i",i," j",j," j1",j1," j2",j2
4450 zj=(c(3,j)+c(3,j+1))/2.0d0
4452 if (zj.lt.0) zj=zj+boxzsize
4453 if ((zj.gt.bordlipbot) &
4454 .and.(zj.lt.bordliptop)) then
4455 !C the energy transfer exist
4456 if (zj.lt.buflipbot) then
4457 !C what fraction I am in
4459 ((zj-bordlipbot)/lipbufthick)
4460 !C lipbufthick is thickenes of lipid buffore
4461 sslipj=sscalelip(fracinbuf)
4462 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
4463 elseif (zj.gt.bufliptop) then
4464 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
4465 sslipj=sscalelip(fracinbuf)
4466 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
4480 iti1=itortyp(itype(i+1,1))
4481 iti2=itortyp(itype(i+2,1))
4482 iti3=itortyp(itype(i+3,1))
4483 ! write(iout,*) "iti1",iti1," iti2",iti2," iti3",iti3
4484 call transpose2(EUg(1,1,i+1),e1t(1,1))
4485 call transpose2(Eug(1,1,i+2),e2t(1,1))
4486 call transpose2(Eug(1,1,i+3),e3t(1,1))
4487 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4488 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4489 s1=scalar2(b1(1,iti2),auxvec(1))
4490 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4491 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4492 s2=scalar2(b1(1,iti1),auxvec(1))
4493 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4494 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4495 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4496 if (shield_mode.eq.0) then
4501 eello_turn4=eello_turn4-(s1+s2+s3) &
4502 *fac_shield(i)*fac_shield(j) &
4503 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4504 eello_t4=-(s1+s2+s3) &
4505 *fac_shield(i)*fac_shield(j)
4506 !C Now derivative over shield:
4507 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
4508 (shield_mode.gt.0)) then
4511 do ilist=1,ishield_list(i)
4512 iresshield=shield_list(ilist,i)
4514 rlocshield=grad_shield_side(k,ilist,i)*eello_t4/fac_shield(i)
4515 gshieldx_t4(k,iresshield)=gshieldx_t4(k,iresshield)+ &
4517 +grad_shield_loc(k,ilist,i)*eello_t4/fac_shield(i)
4518 gshieldc_t4(k,iresshield-1)=gshieldc_t4(k,iresshield-1) &
4522 do ilist=1,ishield_list(j)
4523 iresshield=shield_list(ilist,j)
4525 rlocshield=grad_shield_side(k,ilist,j)*eello_t4/fac_shield(j)
4526 gshieldx_t4(k,iresshield)=gshieldx_t4(k,iresshield)+ &
4528 +grad_shield_loc(k,ilist,j)*eello_t4/fac_shield(j)
4529 gshieldc_t4(k,iresshield-1)=gshieldc_t4(k,iresshield-1) &
4536 gshieldc_t4(k,i)=gshieldc_t4(k,i)+ &
4537 grad_shield(k,i)*eello_t4/fac_shield(i)
4538 gshieldc_t4(k,j)=gshieldc_t4(k,j)+ &
4539 grad_shield(k,j)*eello_t4/fac_shield(j)
4540 gshieldc_t4(k,i-1)=gshieldc_t4(k,i-1)+ &
4541 grad_shield(k,i)*eello_t4/fac_shield(i)
4542 gshieldc_t4(k,j-1)=gshieldc_t4(k,j-1)+ &
4543 grad_shield(k,j)*eello_t4/fac_shield(j)
4547 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
4548 'eturn4',i,j,-(s1+s2+s3)
4549 !d write (2,*) 'i,',i,' j',j,'eello_turn4',-(s1+s2+s3),
4550 !d & ' eello_turn4_num',8*eello_turn4_num
4551 ! Derivatives in gamma(i)
4552 call transpose2(EUgder(1,1,i+1),e1tder(1,1))
4553 call matmat2(e1tder(1,1),a_temp(1,1),auxmat(1,1))
4554 call matvec2(auxmat(1,1),Ub2(1,i+3),auxvec(1))
4555 s1=scalar2(b1(1,iti2),auxvec(1))
4556 call matmat2(ae3e2(1,1),e1tder(1,1),pizda(1,1))
4557 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4558 gel_loc_turn4(i)=gel_loc_turn4(i)-(s1+s3) &
4559 *fac_shield(i)*fac_shield(j) &
4560 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4562 ! Derivatives in gamma(i+1)
4563 call transpose2(EUgder(1,1,i+2),e2tder(1,1))
4564 call matvec2(ae3(1,1),Ub2der(1,i+2),auxvec(1))
4565 s2=scalar2(b1(1,iti1),auxvec(1))
4566 call matmat2(ae3(1,1),e2tder(1,1),auxmat(1,1))
4567 call matmat2(auxmat(1,1),e1t(1,1),pizda(1,1))
4568 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4569 gel_loc_turn4(i+1)=gel_loc_turn4(i+1)-(s2+s3) &
4570 *fac_shield(i)*fac_shield(j) &
4571 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4573 ! Derivatives in gamma(i+2)
4574 call transpose2(EUgder(1,1,i+3),e3tder(1,1))
4575 call matvec2(e1a(1,1),Ub2der(1,i+3),auxvec(1))
4576 s1=scalar2(b1(1,iti2),auxvec(1))
4577 call matmat2(a_temp(1,1),e3tder(1,1),auxmat(1,1))
4578 call matvec2(auxmat(1,1),Ub2(1,i+2),auxvec(1))
4579 s2=scalar2(b1(1,iti1),auxvec(1))
4580 call matmat2(auxmat(1,1),e2t(1,1),auxmat3(1,1))
4581 call matmat2(auxmat3(1,1),e1t(1,1),pizda(1,1))
4582 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4583 gel_loc_turn4(i+2)=gel_loc_turn4(i+2)-(s1+s2+s3) &
4584 *fac_shield(i)*fac_shield(j) &
4585 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4587 ! Cartesian derivatives
4588 ! Derivatives of this turn contributions in DC(i+2)
4589 if (j.lt.nres-1) then
4591 a_temp(1,1)=agg(l,1)
4592 a_temp(1,2)=agg(l,2)
4593 a_temp(2,1)=agg(l,3)
4594 a_temp(2,2)=agg(l,4)
4595 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4596 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4597 s1=scalar2(b1(1,iti2),auxvec(1))
4598 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4599 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4600 s2=scalar2(b1(1,iti1),auxvec(1))
4601 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4602 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4603 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4605 gcorr4_turn(l,i+2)=gcorr4_turn(l,i+2)-(s1+s2+s3)&
4606 *fac_shield(i)*fac_shield(j) &
4607 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4611 ! Remaining derivatives of this turn contribution
4613 a_temp(1,1)=aggi(l,1)
4614 a_temp(1,2)=aggi(l,2)
4615 a_temp(2,1)=aggi(l,3)
4616 a_temp(2,2)=aggi(l,4)
4617 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4618 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4619 s1=scalar2(b1(1,iti2),auxvec(1))
4620 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4621 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4622 s2=scalar2(b1(1,iti1),auxvec(1))
4623 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4624 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4625 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4626 gcorr4_turn(l,i)=gcorr4_turn(l,i)-(s1+s2+s3) &
4627 *fac_shield(i)*fac_shield(j) &
4628 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4631 a_temp(1,1)=aggi1(l,1)
4632 a_temp(1,2)=aggi1(l,2)
4633 a_temp(2,1)=aggi1(l,3)
4634 a_temp(2,2)=aggi1(l,4)
4635 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4636 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4637 s1=scalar2(b1(1,iti2),auxvec(1))
4638 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4639 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4640 s2=scalar2(b1(1,iti1),auxvec(1))
4641 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4642 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4643 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4644 gcorr4_turn(l,i+1)=gcorr4_turn(l,i+1)-(s1+s2+s3) &
4645 *fac_shield(i)*fac_shield(j) &
4646 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4649 a_temp(1,1)=aggj(l,1)
4650 a_temp(1,2)=aggj(l,2)
4651 a_temp(2,1)=aggj(l,3)
4652 a_temp(2,2)=aggj(l,4)
4653 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4654 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4655 s1=scalar2(b1(1,iti2),auxvec(1))
4656 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4657 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4658 s2=scalar2(b1(1,iti1),auxvec(1))
4659 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4660 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4661 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4662 gcorr4_turn(l,j)=gcorr4_turn(l,j)-(s1+s2+s3) &
4663 *fac_shield(i)*fac_shield(j) &
4664 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4667 a_temp(1,1)=aggj1(l,1)
4668 a_temp(1,2)=aggj1(l,2)
4669 a_temp(2,1)=aggj1(l,3)
4670 a_temp(2,2)=aggj1(l,4)
4671 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4672 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4673 s1=scalar2(b1(1,iti2),auxvec(1))
4674 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4675 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4676 s2=scalar2(b1(1,iti1),auxvec(1))
4677 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
4678 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
4679 s3=0.5d0*(pizda(1,1)+pizda(2,2))
4680 ! write (iout,*) "s1",s1," s2",s2," s3",s3," s1+s2+s3",s1+s2+s3
4681 gcorr4_turn(l,j1)=gcorr4_turn(l,j1)-(s1+s2+s3) &
4682 *fac_shield(i)*fac_shield(j) &
4683 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4686 gshieldc_t4(3,i)=gshieldc_t4(3,i)+ &
4687 ssgradlipi*eello_t4/4.0d0*lipscale
4688 gshieldc_t4(3,j)=gshieldc_t4(3,j)+ &
4689 ssgradlipj*eello_t4/4.0d0*lipscale
4690 gshieldc_t4(3,i-1)=gshieldc_t4(3,i-1)+ &
4691 ssgradlipi*eello_t4/4.0d0*lipscale
4692 gshieldc_t4(3,j-1)=gshieldc_t4(3,j-1)+ &
4693 ssgradlipj*eello_t4/4.0d0*lipscale
4696 end subroutine eturn4
4697 !-----------------------------------------------------------------------------
4698 subroutine unormderiv(u,ugrad,unorm,ungrad)
4699 ! This subroutine computes the derivatives of a normalized vector u, given
4700 ! the derivatives computed without normalization conditions, ugrad. Returns
4703 real(kind=8),dimension(3) :: u,vec
4704 real(kind=8),dimension(3,3) ::ugrad,ungrad
4705 real(kind=8) :: unorm !,scalar
4707 ! write (2,*) 'ugrad',ugrad
4710 vec(i)=scalar(ugrad(1,i),u(1))
4712 ! write (2,*) 'vec',vec
4715 ungrad(j,i)=(ugrad(j,i)-u(j)*vec(i))*unorm
4718 ! write (2,*) 'ungrad',ungrad
4720 end subroutine unormderiv
4721 !-----------------------------------------------------------------------------
4722 subroutine escp_soft_sphere(evdw2,evdw2_14)
4724 ! This subroutine calculates the excluded-volume interaction energy between
4725 ! peptide-group centers and side chains and its gradient in virtual-bond and
4726 ! side-chain vectors.
4728 ! implicit real*8 (a-h,o-z)
4729 ! include 'DIMENSIONS'
4730 ! include 'COMMON.GEO'
4731 ! include 'COMMON.VAR'
4732 ! include 'COMMON.LOCAL'
4733 ! include 'COMMON.CHAIN'
4734 ! include 'COMMON.DERIV'
4735 ! include 'COMMON.INTERACT'
4736 ! include 'COMMON.FFIELD'
4737 ! include 'COMMON.IOUNITS'
4738 ! include 'COMMON.CONTROL'
4739 real(kind=8),dimension(3) :: ggg
4741 integer :: i,iint,j,k,iteli,itypj
4742 real(kind=8) :: evdw2,evdw2_14,r0_scp,xi,yi,zi,xj,yj,zj,&
4743 fac,rij,r0ij,r0ijsq,evdwij,e1,e2
4748 !d print '(a)','Enter ESCP'
4749 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
4750 do i=iatscp_s,iatscp_e
4751 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
4753 xi=0.5D0*(c(1,i)+c(1,i+1))
4754 yi=0.5D0*(c(2,i)+c(2,i+1))
4755 zi=0.5D0*(c(3,i)+c(3,i+1))
4757 do iint=1,nscp_gr(i)
4759 do j=iscpstart(i,iint),iscpend(i,iint)
4760 if (itype(j,1).eq.ntyp1) cycle
4761 itypj=iabs(itype(j,1))
4762 ! Uncomment following three lines for SC-p interactions
4766 ! Uncomment following three lines for Ca-p interactions
4770 rij=xj*xj+yj*yj+zj*zj
4773 if (rij.lt.r0ijsq) then
4774 evdwij=0.25d0*(rij-r0ijsq)**2
4782 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
4787 !grad if (j.lt.i) then
4788 !d write (iout,*) 'j<i'
4789 ! Uncomment following three lines for SC-p interactions
4791 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
4794 !d write (iout,*) 'j>i'
4796 !grad ggg(k)=-ggg(k)
4797 ! Uncomment following line for SC-p interactions
4798 ! gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
4802 !grad gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
4804 !grad kstart=min0(i+1,j)
4805 !grad kend=max0(i-1,j-1)
4806 !d write (iout,*) 'i=',i,' j=',j,' kstart=',kstart,' kend=',kend
4807 !d write (iout,*) ggg(1),ggg(2),ggg(3)
4808 !grad do k=kstart,kend
4810 !grad gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
4814 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
4815 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
4822 end subroutine escp_soft_sphere
4823 !-----------------------------------------------------------------------------
4824 subroutine escp(evdw2,evdw2_14)
4826 ! This subroutine calculates the excluded-volume interaction energy between
4827 ! peptide-group centers and side chains and its gradient in virtual-bond and
4828 ! side-chain vectors.
4830 ! implicit real*8 (a-h,o-z)
4831 ! include 'DIMENSIONS'
4832 ! include 'COMMON.GEO'
4833 ! include 'COMMON.VAR'
4834 ! include 'COMMON.LOCAL'
4835 ! include 'COMMON.CHAIN'
4836 ! include 'COMMON.DERIV'
4837 ! include 'COMMON.INTERACT'
4838 ! include 'COMMON.FFIELD'
4839 ! include 'COMMON.IOUNITS'
4840 ! include 'COMMON.CONTROL'
4841 real(kind=8),dimension(3) :: ggg
4843 integer :: i,iint,j,k,iteli,itypj,subchap
4844 real(kind=8) :: evdw2,evdw2_14,xi,yi,zi,xj,yj,zj,rrij,fac,&
4846 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
4847 dist_temp, dist_init
4848 integer xshift,yshift,zshift
4852 !d print '(a)','Enter ESCP'
4853 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
4854 do i=iatscp_s,iatscp_e
4855 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
4857 xi=0.5D0*(c(1,i)+c(1,i+1))
4858 yi=0.5D0*(c(2,i)+c(2,i+1))
4859 zi=0.5D0*(c(3,i)+c(3,i+1))
4861 if (xi.lt.0) xi=xi+boxxsize
4863 if (yi.lt.0) yi=yi+boxysize
4865 if (zi.lt.0) zi=zi+boxzsize
4867 do iint=1,nscp_gr(i)
4869 do j=iscpstart(i,iint),iscpend(i,iint)
4870 itypj=iabs(itype(j,1))
4871 if (itypj.eq.ntyp1) cycle
4872 ! Uncomment following three lines for SC-p interactions
4876 ! Uncomment following three lines for Ca-p interactions
4884 if (xj.lt.0) xj=xj+boxxsize
4886 if (yj.lt.0) yj=yj+boxysize
4888 if (zj.lt.0) zj=zj+boxzsize
4889 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
4897 xj=xj_safe+xshift*boxxsize
4898 yj=yj_safe+yshift*boxysize
4899 zj=zj_safe+zshift*boxzsize
4900 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
4901 if(dist_temp.lt.dist_init) then
4911 if (subchap.eq.1) then
4921 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
4922 rij=dsqrt(1.0d0/rrij)
4923 sss_ele_cut=sscale_ele(rij)
4924 sss_ele_grad=sscagrad_ele(rij)
4925 ! print *,sss_ele_cut,sss_ele_grad,&
4926 ! (rij),r_cut_ele,rlamb_ele
4927 if (sss_ele_cut.le.0.0) cycle
4929 e1=fac*fac*aad(itypj,iteli)
4930 e2=fac*bad(itypj,iteli)
4931 if (iabs(j-i) .le. 2) then
4934 evdw2_14=evdw2_14+(e1+e2)*sss_ele_cut
4937 evdw2=evdw2+evdwij*sss_ele_cut
4938 ! if (energy_dec) write (iout,'(a6,2i5,0pf7.3,2i3,3e11.3)') &
4939 ! 'evdw2',i,j,evdwij,iteli,itypj,fac,aad(itypj,iteli),&
4940 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
4943 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
4945 fac=-(evdwij+e1)*rrij*sss_ele_cut
4946 fac=fac+evdwij*sss_ele_grad/rij/expon
4950 !grad if (j.lt.i) then
4951 !d write (iout,*) 'j<i'
4952 ! Uncomment following three lines for SC-p interactions
4954 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
4957 !d write (iout,*) 'j>i'
4959 !grad ggg(k)=-ggg(k)
4960 ! Uncomment following line for SC-p interactions
4961 !cgrad gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
4962 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
4966 !grad gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
4968 !grad kstart=min0(i+1,j)
4969 !grad kend=max0(i-1,j-1)
4970 !d write (iout,*) 'i=',i,' j=',j,' kstart=',kstart,' kend=',kend
4971 !d write (iout,*) ggg(1),ggg(2),ggg(3)
4972 !grad do k=kstart,kend
4974 !grad gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
4978 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
4979 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
4987 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
4988 gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
4989 gradx_scp(j,i)=expon*gradx_scp(j,i)
4992 !******************************************************************************
4996 ! To save time the factor EXPON has been extracted from ALL components
4997 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
5000 !******************************************************************************
5003 !-----------------------------------------------------------------------------
5004 subroutine edis(ehpb)
5006 ! Evaluate bridge-strain energy and its gradient in virtual-bond and SC vectors.
5008 ! implicit real*8 (a-h,o-z)
5009 ! include 'DIMENSIONS'
5010 ! include 'COMMON.SBRIDGE'
5011 ! include 'COMMON.CHAIN'
5012 ! include 'COMMON.DERIV'
5013 ! include 'COMMON.VAR'
5014 ! include 'COMMON.INTERACT'
5015 ! include 'COMMON.IOUNITS'
5016 real(kind=8),dimension(3) :: ggg
5018 integer :: i,j,ii,jj,iii,jjj,k
5019 real(kind=8) :: fac,eij,rdis,ehpb,dd,waga
5022 !d write(iout,*)'edis: nhpb=',nhpb,' fbr=',fbr
5023 !d write(iout,*)'link_start=',link_start,' link_end=',link_end
5024 if (link_end.eq.0) return
5025 do i=link_start,link_end
5026 ! If ihpb(i) and jhpb(i) > NRES, this is a SC-SC distance, otherwise a
5027 ! CA-CA distance used in regularization of structure.
5030 ! iii and jjj point to the residues for which the distance is assigned.
5031 if (ii.gt.nres) then
5038 ! write (iout,*) "i",i," ii",ii," iii",iii," jj",jj," jjj",jjj,
5039 ! & dhpb(i),dhpb1(i),forcon(i)
5040 ! 24/11/03 AL: SS bridges handled separately because of introducing a specific
5041 ! distance and angle dependent SS bond potential.
5042 !mc if (ii.gt.nres .and. itype(iii).eq.1 .and. itype(jjj).eq.1) then
5043 ! 18/07/06 MC: Use the convention that the first nss pairs are SS bonds
5044 if (.not.dyn_ss .and. i.le.nss) then
5045 ! 15/02/13 CC dynamic SSbond - additional check
5046 if (ii.gt.nres .and. iabs(itype(iii,1)).eq.1 .and. &
5047 iabs(itype(jjj,1)).eq.1) then
5048 call ssbond_ene(iii,jjj,eij)
5050 !d write (iout,*) "eij",eij
5052 else if (ii.gt.nres .and. jj.gt.nres) then
5053 !c Restraints from contact prediction
5055 if (constr_dist.eq.11) then
5056 ehpb=ehpb+fordepth(i)**4.0d0 &
5057 *rlornmr1(dd,dhpb(i),dhpb1(i),forcon(i))
5058 fac=fordepth(i)**4.0d0 &
5059 *rlornmr1prim(dd,dhpb(i),dhpb1(i),forcon(i))/dd
5060 if (energy_dec) write (iout,'(a6,2i5,3f8.3)') "edisl",ii,jj, &
5063 if (dhpb1(i).gt.0.0d0) then
5064 ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5065 fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
5066 !c write (iout,*) "beta nmr",
5067 !c & dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5071 !C Get the force constant corresponding to this distance.
5073 !C Calculate the contribution to energy.
5074 ehpb=ehpb+waga*rdis*rdis
5075 !c write (iout,*) "beta reg",dd,waga*rdis*rdis
5077 !C Evaluate gradient.
5083 ggg(j)=fac*(c(j,jj)-c(j,ii))
5086 ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
5087 ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
5090 ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
5091 ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
5095 if (constr_dist.eq.11) then
5096 ehpb=ehpb+fordepth(i)**4.0d0 &
5097 *rlornmr1(dd,dhpb(i),dhpb1(i),forcon(i))
5098 fac=fordepth(i)**4.0d0 &
5099 *rlornmr1prim(dd,dhpb(i),dhpb1(i),forcon(i))/dd
5100 if (energy_dec) write (iout,'(a6,2i5,3f8.3)') "edisl",ii,jj, &
5103 if (dhpb1(i).gt.0.0d0) then
5104 ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5105 fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
5106 !c write (iout,*) "alph nmr",
5107 !c & dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5110 !C Get the force constant corresponding to this distance.
5112 !C Calculate the contribution to energy.
5113 ehpb=ehpb+waga*rdis*rdis
5114 !c write (iout,*) "alpha reg",dd,waga*rdis*rdis
5116 !C Evaluate gradient.
5123 ggg(j)=fac*(c(j,jj)-c(j,ii))
5125 !cd print '(i3,3(1pe14.5))',i,(ggg(j),j=1,3)
5126 !C If this is a SC-SC distance, we need to calculate the contributions to the
5127 !C Cartesian gradient in the SC vectors (ghpbx).
5130 ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
5131 ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
5134 !cgrad do j=iii,jjj-1
5136 !cgrad ghpbc(k,j)=ghpbc(k,j)+ggg(k)
5140 ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
5141 ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
5145 if (constr_dist.ne.11) ehpb=0.5D0*ehpb
5149 !-----------------------------------------------------------------------------
5150 subroutine ssbond_ene(i,j,eij)
5152 ! Calculate the distance and angle dependent SS-bond potential energy
5153 ! using a free-energy function derived based on RHF/6-31G** ab initio
5154 ! calculations of diethyl disulfide.
5156 ! A. Liwo and U. Kozlowska, 11/24/03
5158 ! implicit real*8 (a-h,o-z)
5159 ! include 'DIMENSIONS'
5160 ! include 'COMMON.SBRIDGE'
5161 ! include 'COMMON.CHAIN'
5162 ! include 'COMMON.DERIV'
5163 ! include 'COMMON.LOCAL'
5164 ! include 'COMMON.INTERACT'
5165 ! include 'COMMON.VAR'
5166 ! include 'COMMON.IOUNITS'
5167 real(kind=8),dimension(3) :: erij,dcosom1,dcosom2,gg
5169 integer :: i,j,itypi,itypj,k
5170 real(kind=8) :: eij,rij,rrij,xi,yi,zi,dxi,dyi,dzi,dsci_inv,&
5171 xj,yj,zj,dxj,dyj,dzj,om1,om2,om12,deltad,dscj_inv,&
5172 deltat1,deltat2,deltat12,ed,pom1,pom2,eom1,eom2,eom12,&
5175 itypi=iabs(itype(i,1))
5179 dxi=dc_norm(1,nres+i)
5180 dyi=dc_norm(2,nres+i)
5181 dzi=dc_norm(3,nres+i)
5182 ! dsci_inv=dsc_inv(itypi)
5183 dsci_inv=vbld_inv(nres+i)
5184 itypj=iabs(itype(j,1))
5185 ! dscj_inv=dsc_inv(itypj)
5186 dscj_inv=vbld_inv(nres+j)
5190 dxj=dc_norm(1,nres+j)
5191 dyj=dc_norm(2,nres+j)
5192 dzj=dc_norm(3,nres+j)
5193 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
5198 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
5199 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
5200 om12=dxi*dxj+dyi*dyj+dzi*dzj
5202 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
5203 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
5209 deltat12=om2-om1+2.0d0
5211 eij=akcm*deltad*deltad+akth*(deltat1*deltat1+deltat2*deltat2) &
5212 +akct*deltad*deltat12 &
5213 +v1ss*cosphi+v2ss*cosphi*cosphi+v3ss*cosphi*cosphi*cosphi+ebr
5214 ! write(iout,*) i,j,"rij",rij,"d0cm",d0cm," akcm",akcm," akth",akth,
5215 ! & " akct",akct," deltad",deltad," deltat",deltat1,deltat2,
5216 ! & " deltat12",deltat12," eij",eij
5217 ed=2*akcm*deltad+akct*deltat12
5219 pom2=v1ss+2*v2ss*cosphi+3*v3ss*cosphi*cosphi
5220 eom1=-2*akth*deltat1-pom1-om2*pom2
5221 eom2= 2*akth*deltat2+pom1-om1*pom2
5224 ggk=ed*erij(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
5225 ghpbx(k,i)=ghpbx(k,i)-ggk &
5226 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
5227 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
5228 ghpbx(k,j)=ghpbx(k,j)+ggk &
5229 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
5230 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
5231 ghpbc(k,i)=ghpbc(k,i)-ggk
5232 ghpbc(k,j)=ghpbc(k,j)+ggk
5235 ! Calculate the components of the gradient in DC and X
5239 !grad ghpbc(l,k)=ghpbc(l,k)+gg(l)
5243 end subroutine ssbond_ene
5244 !-----------------------------------------------------------------------------
5245 subroutine ebond(estr)
5247 ! Evaluate the energy of stretching of the CA-CA and CA-SC virtual bonds
5249 ! implicit real*8 (a-h,o-z)
5250 ! include 'DIMENSIONS'
5251 ! include 'COMMON.LOCAL'
5252 ! include 'COMMON.GEO'
5253 ! include 'COMMON.INTERACT'
5254 ! include 'COMMON.DERIV'
5255 ! include 'COMMON.VAR'
5256 ! include 'COMMON.CHAIN'
5257 ! include 'COMMON.IOUNITS'
5258 ! include 'COMMON.NAMES'
5259 ! include 'COMMON.FFIELD'
5260 ! include 'COMMON.CONTROL'
5261 ! include 'COMMON.SETUP'
5262 real(kind=8),dimension(3) :: u,ud
5264 integer :: i,j,iti,nbi,k
5265 real(kind=8) :: estr,estr1,diff,uprod,usum,usumsqder,&
5270 ! if (.not.allocated(gradb)) allocate(gradb(3,nres)) !(3,maxres)
5271 ! if (.not.allocated(gradbx)) allocate(gradbx(3,nres)) !(3,maxres)
5273 do i=ibondp_start,ibondp_end
5274 if (itype(i-1,1).eq.ntyp1 .and. itype(i,1).eq.ntyp1) cycle
5275 if (itype(i-1,1).eq.ntyp1 .or. itype(i,1).eq.ntyp1) then
5276 !C estr1=estr1+gnmr1(vbld(i),-1.0d0,distchainmax)
5278 !C gradb(j,i-1)=gnmr1prim(vbld(i),-1.0d0,distchainmax) &
5279 !C *dc(j,i-1)/vbld(i)
5281 !C if (energy_dec) write(iout,*) &
5282 !C "estr1",i,gnmr1(vbld(i),-1.0d0,distchainmax)
5283 diff = vbld(i)-vbldpDUM
5285 diff = vbld(i)-vbldp0
5287 if (energy_dec) write (iout,'(a7,i5,4f7.3)') &
5288 "estr bb",i,vbld(i),vbldp0,diff,AKP*diff*diff
5291 gradb(j,i-1)=AKP*diff*dc(j,i-1)/vbld(i)
5293 ! write (iout,'(i5,3f10.5)') i,(gradb(j,i-1),j=1,3)
5296 estr=0.5d0*AKP*estr+estr1
5297 ! print *,"estr_bb",estr,AKP
5299 ! 09/18/07 AL: multimodal bond potential based on AM1 CA-SC PMF's included
5301 do i=ibond_start,ibond_end
5302 iti=iabs(itype(i,1))
5303 if (iti.eq.0) print *,"WARNING WRONG SETTTING",i
5304 if (iti.ne.10 .and. iti.ne.ntyp1) then
5307 diff=vbld(i+nres)-vbldsc0(1,iti)
5308 if (energy_dec) write (iout,*) &
5309 "estr sc",i,iti,vbld(i+nres),vbldsc0(1,iti),diff,&
5310 AKSC(1,iti),AKSC(1,iti)*diff*diff
5311 estr=estr+0.5d0*AKSC(1,iti)*diff*diff
5312 ! print *,"estr_sc",estr
5314 gradbx(j,i)=AKSC(1,iti)*diff*dc(j,i+nres)/vbld(i+nres)
5318 diff=vbld(i+nres)-vbldsc0(j,iti)
5319 ud(j)=aksc(j,iti)*diff
5320 u(j)=abond0(j,iti)+0.5d0*ud(j)*diff
5334 uprod2=uprod2*u(k)*u(k)
5338 usumsqder=usumsqder+ud(j)*uprod2
5340 estr=estr+uprod/usum
5341 ! print *,"estr_sc",estr,i
5343 if (energy_dec) write (iout,*) &
5344 "estr sc",i,iti,vbld(i+nres),vbldsc0(1,iti),diff,&
5345 AKSC(1,iti),uprod/usum
5347 gradbx(j,i)=usumsqder/(usum*usum)*dc(j,i+nres)/vbld(i+nres)
5353 end subroutine ebond
5355 !-----------------------------------------------------------------------------
5356 subroutine ebend(etheta)
5358 ! Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
5359 ! angles gamma and its derivatives in consecutive thetas and gammas.
5362 ! implicit real*8 (a-h,o-z)
5363 ! include 'DIMENSIONS'
5364 ! include 'COMMON.LOCAL'
5365 ! include 'COMMON.GEO'
5366 ! include 'COMMON.INTERACT'
5367 ! include 'COMMON.DERIV'
5368 ! include 'COMMON.VAR'
5369 ! include 'COMMON.CHAIN'
5370 ! include 'COMMON.IOUNITS'
5371 ! include 'COMMON.NAMES'
5372 ! include 'COMMON.FFIELD'
5373 ! include 'COMMON.CONTROL'
5374 !el real(kind=8) :: term1,term2,termm,diffak,ratak,&
5375 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
5376 !el delthe0,sig0inv,sigtc,sigsqtc,delthec
5378 !el common /calcthet/ term1,term2,termm,diffak,ratak,&
5379 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
5380 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,it
5382 integer :: i,k,ichir1,ichir2,itype1,ichir11,ichir12,itype2,&
5384 real(kind=8) :: etheta,delta,ss,ssd,phii,phii1,thet_pred_mean,&
5385 athetk,bthetk,dthett,dthetg1,dthetg2,f0,fprim0,E_tc0,fprim_tc0,&
5386 f1,fprim1,E_tc1,ethetai,E_theta,E_tc
5387 real(kind=8),dimension(2) :: y,z
5390 ! time11=dexp(-2*time)
5393 ! write (*,'(a,i2)') 'EBEND ICG=',icg
5394 do i=ithet_start,ithet_end
5395 if (itype(i-1,1).eq.ntyp1) cycle
5396 ! Zero the energy function and its derivative at 0 or pi.
5397 call splinthet(theta(i),0.5d0*delta,ss,ssd)
5399 ichir1=isign(1,itype(i-2,1))
5400 ichir2=isign(1,itype(i,1))
5401 if (itype(i-2,1).eq.10) ichir1=isign(1,itype(i-1,1))
5402 if (itype(i,1).eq.10) ichir2=isign(1,itype(i-1,1))
5403 if (itype(i-1,1).eq.10) then
5404 itype1=isign(10,itype(i-2,1))
5405 ichir11=isign(1,itype(i-2,1))
5406 ichir12=isign(1,itype(i-2,1))
5407 itype2=isign(10,itype(i,1))
5408 ichir21=isign(1,itype(i,1))
5409 ichir22=isign(1,itype(i,1))
5412 if (i.gt.3 .and. itype(i-2,1).ne.ntyp1) then
5415 if (phii.ne.phii) phii=150.0
5425 if (i.lt.nres .and. itype(i,1).ne.ntyp1) then
5428 if (phii1.ne.phii1) phii1=150.0
5440 ! Calculate the "mean" value of theta from the part of the distribution
5441 ! dependent on the adjacent virtual-bond-valence angles (gamma1 & gamma2).
5442 ! In following comments this theta will be referred to as t_c.
5443 thet_pred_mean=0.0d0
5445 athetk=athet(k,it,ichir1,ichir2)
5446 bthetk=bthet(k,it,ichir1,ichir2)
5448 athetk=athet(k,itype1,ichir11,ichir12)
5449 bthetk=bthet(k,itype2,ichir21,ichir22)
5451 thet_pred_mean=thet_pred_mean+athetk*y(k)+bthetk*z(k)
5453 dthett=thet_pred_mean*ssd
5454 thet_pred_mean=thet_pred_mean*ss+a0thet(it)
5455 ! Derivatives of the "mean" values in gamma1 and gamma2.
5456 dthetg1=(-athet(1,it,ichir1,ichir2)*y(2) &
5457 +athet(2,it,ichir1,ichir2)*y(1))*ss
5458 dthetg2=(-bthet(1,it,ichir1,ichir2)*z(2) &
5459 +bthet(2,it,ichir1,ichir2)*z(1))*ss
5461 dthetg1=(-athet(1,itype1,ichir11,ichir12)*y(2) &
5462 +athet(2,itype1,ichir11,ichir12)*y(1))*ss
5463 dthetg2=(-bthet(1,itype2,ichir21,ichir22)*z(2) &
5464 +bthet(2,itype2,ichir21,ichir22)*z(1))*ss
5466 if (theta(i).gt.pi-delta) then
5467 call theteng(pi-delta,thet_pred_mean,theta0(it),f0,fprim0,&
5469 call mixder(pi-delta,thet_pred_mean,theta0(it),fprim_tc0)
5470 call theteng(pi,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
5471 call spline1(theta(i),pi-delta,delta,f0,f1,fprim0,ethetai,&
5473 call spline2(theta(i),pi-delta,delta,E_tc0,E_tc1,fprim_tc0,&
5475 else if (theta(i).lt.delta) then
5476 call theteng(delta,thet_pred_mean,theta0(it),f0,fprim0,E_tc0)
5477 call theteng(0.0d0,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
5478 call spline1(theta(i),delta,-delta,f0,f1,fprim0,ethetai,&
5480 call mixder(delta,thet_pred_mean,theta0(it),fprim_tc0)
5481 call spline2(theta(i),delta,-delta,E_tc0,E_tc1,fprim_tc0,&
5484 call theteng(theta(i),thet_pred_mean,theta0(it),ethetai,&
5487 etheta=etheta+ethetai
5488 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
5490 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*E_tc*dthetg1
5491 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*E_tc*dthetg2
5492 gloc(nphi+i-2,icg)=wang*(E_theta+E_tc*dthett)
5494 ! print *,ithetaconstr_start,ithetaconstr_end,"TU"
5496 ! Ufff.... We've done all this!!!
5498 end subroutine ebend
5499 !-----------------------------------------------------------------------------
5500 subroutine theteng(thetai,thet_pred_mean,theta0i,ethetai,E_theta,E_tc)
5503 ! implicit real*8 (a-h,o-z)
5504 ! include 'DIMENSIONS'
5505 ! include 'COMMON.LOCAL'
5506 ! include 'COMMON.IOUNITS'
5507 !el real(kind=8) :: term1,term2,termm,diffak,ratak,&
5508 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
5509 !el delthe0,sig0inv,sigtc,sigsqtc,delthec
5511 real(kind=8) :: thetai,thet_pred_mean,theta0i,ethetai,E_theta,E_tc
5513 !el common /calcthet/ term1,term2,termm,diffak,ratak,&
5514 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
5515 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,it
5517 real(kind=8) :: sig,fac,escloci0,escloci1,esclocbi0,dersc12,&
5518 esclocbi1,chuju,esclocbi,dersc02,dersc01,ss,ssd
5520 ! Calculate the contributions to both Gaussian lobes.
5521 ! 6/6/97 - Deform the Gaussians using the factor of 1/(1+time)
5522 ! The "polynomial part" of the "standard deviation" of this part of
5526 sig=sig*thet_pred_mean+polthet(j,it)
5528 ! Derivative of the "interior part" of the "standard deviation of the"
5529 ! gamma-dependent Gaussian lobe in t_c.
5530 sigtc=3*polthet(3,it)
5532 sigtc=sigtc*thet_pred_mean+j*polthet(j,it)
5535 ! Set the parameters of both Gaussian lobes of the distribution.
5536 ! "Standard deviation" of the gamma-dependent Gaussian lobe (sigtc)
5537 fac=sig*sig+sigc0(it)
5540 ! Following variable (sigsqtc) is -(1/2)d[sigma(t_c)**(-2))]/dt_c
5541 sigsqtc=-4.0D0*sigcsq*sigtc
5542 ! print *,i,sig,sigtc,sigsqtc
5543 ! Following variable (sigtc) is d[sigma(t_c)]/dt_c
5544 sigtc=-sigtc/(fac*fac)
5545 ! Following variable is sigma(t_c)**(-2)
5546 sigcsq=sigcsq*sigcsq
5548 sig0inv=1.0D0/sig0i**2
5549 delthec=thetai-thet_pred_mean
5550 delthe0=thetai-theta0i
5551 term1=-0.5D0*sigcsq*delthec*delthec
5552 term2=-0.5D0*sig0inv*delthe0*delthe0
5553 ! Following fuzzy logic is to avoid underflows in dexp and subsequent INFs and
5554 ! NaNs in taking the logarithm. We extract the largest exponent which is added
5555 ! to the energy (this being the log of the distribution) at the end of energy
5556 ! term evaluation for this virtual-bond angle.
5557 if (term1.gt.term2) then
5559 term2=dexp(term2-termm)
5563 term1=dexp(term1-termm)
5566 ! The ratio between the gamma-independent and gamma-dependent lobes of
5567 ! the distribution is a Gaussian function of thet_pred_mean too.
5568 diffak=gthet(2,it)-thet_pred_mean
5569 ratak=diffak/gthet(3,it)**2
5570 ak=dexp(gthet(1,it)-0.5D0*diffak*ratak)
5571 ! Let's differentiate it in thet_pred_mean NOW.
5573 ! Now put together the distribution terms to make complete distribution.
5574 termexp=term1+ak*term2
5575 termpre=sigc+ak*sig0i
5576 ! Contribution of the bending energy from this theta is just the -log of
5577 ! the sum of the contributions from the two lobes and the pre-exponential
5578 ! factor. Simple enough, isn't it?
5579 ethetai=(-dlog(termexp)-termm+dlog(termpre))
5580 ! NOW the derivatives!!!
5581 ! 6/6/97 Take into account the deformation.
5582 E_theta=(delthec*sigcsq*term1 &
5583 +ak*delthe0*sig0inv*term2)/termexp
5584 E_tc=((sigtc+aktc*sig0i)/termpre &
5585 -((delthec*sigcsq+delthec*delthec*sigsqtc)*term1+ &
5586 aktc*term2)/termexp)
5588 end subroutine theteng
5590 !-----------------------------------------------------------------------------
5591 subroutine ebend(etheta,ethetacnstr)
5593 ! Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
5594 ! angles gamma and its derivatives in consecutive thetas and gammas.
5595 ! ab initio-derived potentials from
5596 ! Kozlowska et al., J. Phys.: Condens. Matter 19 (2007) 285203
5598 ! implicit real*8 (a-h,o-z)
5599 ! include 'DIMENSIONS'
5600 ! include 'COMMON.LOCAL'
5601 ! include 'COMMON.GEO'
5602 ! include 'COMMON.INTERACT'
5603 ! include 'COMMON.DERIV'
5604 ! include 'COMMON.VAR'
5605 ! include 'COMMON.CHAIN'
5606 ! include 'COMMON.IOUNITS'
5607 ! include 'COMMON.NAMES'
5608 ! include 'COMMON.FFIELD'
5609 ! include 'COMMON.CONTROL'
5610 real(kind=8),dimension(nntheterm) :: coskt,sinkt !mmaxtheterm
5611 real(kind=8),dimension(nsingle) :: cosph1,sinph1,cosph2,sinph2 !maxsingle
5612 real(kind=8),dimension(ndouble,ndouble) :: cosph1ph2,sinph1ph2 !maxdouble,maxdouble
5613 logical :: lprn=.false., lprn1=.false.
5615 integer :: i,k,iblock,ityp1,ityp2,ityp3,l,m
5616 real(kind=8) :: dethetai,dephii,dephii1,theti2,phii,phii1,ethetai
5617 real(kind=8) :: aux,etheta,ccl,ssl,scl,csl,ethetacnstr
5618 ! local variables for constrains
5619 real(kind=8) :: difi,thetiii
5623 do i=ithet_start,ithet_end
5624 if (itype(i-1,1).eq.ntyp1) cycle
5625 if (itype(i-2,1).eq.ntyp1.or.itype(i,1).eq.ntyp1) cycle
5626 if (iabs(itype(i+1,1)).eq.20) iblock=2
5627 if (iabs(itype(i+1,1)).ne.20) iblock=1
5631 theti2=0.5d0*theta(i)
5632 ityp2=ithetyp((itype(i-1,1)))
5634 coskt(k)=dcos(k*theti2)
5635 sinkt(k)=dsin(k*theti2)
5637 if (i.gt.3 .and. itype(max0(i-3,1),1).ne.ntyp1) then
5640 if (phii.ne.phii) phii=150.0
5644 ityp1=ithetyp((itype(i-2,1)))
5645 ! propagation of chirality for glycine type
5647 cosph1(k)=dcos(k*phii)
5648 sinph1(k)=dsin(k*phii)
5652 ityp1=ithetyp(itype(i-2,1))
5658 if (i.lt.nres .and. itype(i+1,1).ne.ntyp1) then
5661 if (phii1.ne.phii1) phii1=150.0
5666 ityp3=ithetyp((itype(i,1)))
5668 cosph2(k)=dcos(k*phii1)
5669 sinph2(k)=dsin(k*phii1)
5673 ityp3=ithetyp(itype(i,1))
5679 ethetai=aa0thet(ityp1,ityp2,ityp3,iblock)
5682 ccl=cosph1(l)*cosph2(k-l)
5683 ssl=sinph1(l)*sinph2(k-l)
5684 scl=sinph1(l)*cosph2(k-l)
5685 csl=cosph1(l)*sinph2(k-l)
5686 cosph1ph2(l,k)=ccl-ssl
5687 cosph1ph2(k,l)=ccl+ssl
5688 sinph1ph2(l,k)=scl+csl
5689 sinph1ph2(k,l)=scl-csl
5693 write (iout,*) "i",i," ityp1",ityp1," ityp2",ityp2,&
5694 " ityp3",ityp3," theti2",theti2," phii",phii," phii1",phii1
5695 write (iout,*) "coskt and sinkt"
5697 write (iout,*) k,coskt(k),sinkt(k)
5701 ethetai=ethetai+aathet(k,ityp1,ityp2,ityp3,iblock)*sinkt(k)
5702 dethetai=dethetai+0.5d0*k*aathet(k,ityp1,ityp2,ityp3,iblock) &
5705 write (iout,*) "k",k,&
5706 "aathet",aathet(k,ityp1,ityp2,ityp3,iblock),&
5710 write (iout,*) "cosph and sinph"
5712 write (iout,*) k,cosph1(k),sinph1(k),cosph2(k),sinph2(k)
5714 write (iout,*) "cosph1ph2 and sinph2ph2"
5717 write (iout,*) l,k,cosph1ph2(l,k),cosph1ph2(k,l),&
5718 sinph1ph2(l,k),sinph1ph2(k,l)
5721 write(iout,*) "ethetai",ethetai
5725 aux=bbthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph1(k) &
5726 +ccthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph1(k) &
5727 +ddthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph2(k) &
5728 +eethet(k,m,ityp1,ityp2,ityp3,iblock)*sinph2(k)
5729 ethetai=ethetai+sinkt(m)*aux
5730 dethetai=dethetai+0.5d0*m*aux*coskt(m)
5731 dephii=dephii+k*sinkt(m)* &
5732 (ccthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph1(k)- &
5733 bbthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph1(k))
5734 dephii1=dephii1+k*sinkt(m)* &
5735 (eethet(k,m,ityp1,ityp2,ityp3,iblock)*cosph2(k)- &
5736 ddthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph2(k))
5738 write (iout,*) "m",m," k",k," bbthet", &
5739 bbthet(k,m,ityp1,ityp2,ityp3,iblock)," ccthet", &
5740 ccthet(k,m,ityp1,ityp2,ityp3,iblock)," ddthet", &
5741 ddthet(k,m,ityp1,ityp2,ityp3,iblock)," eethet", &
5742 eethet(k,m,ityp1,ityp2,ityp3,iblock)," ethetai",ethetai
5746 write(iout,*) "ethetai",ethetai
5750 aux=ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)+ &
5751 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l)+ &
5752 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)+ &
5753 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)
5754 ethetai=ethetai+sinkt(m)*aux
5755 dethetai=dethetai+0.5d0*m*coskt(m)*aux
5756 dephii=dephii+l*sinkt(m)* &
5757 (-ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)- &
5758 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)+ &
5759 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)+ &
5760 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l))
5761 dephii1=dephii1+(k-l)*sinkt(m)* &
5762 (-ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)+ &
5763 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)+ &
5764 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)- &
5765 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l))
5767 write (iout,*) "m",m," k",k," l",l," ffthet",&
5768 ffthet(l,k,m,ityp1,ityp2,ityp3,iblock),&
5769 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)," ggthet",&
5770 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock),&
5771 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock),&
5773 write (iout,*) cosph1ph2(l,k)*sinkt(m),&
5774 cosph1ph2(k,l)*sinkt(m),&
5775 sinph1ph2(l,k)*sinkt(m),sinph1ph2(k,l)*sinkt(m)
5783 write (iout,'(i2,3f8.1,9h ethetai ,f10.5)') &
5784 i,theta(i)*rad2deg,phii*rad2deg,&
5785 phii1*rad2deg,ethetai
5787 etheta=etheta+ethetai
5788 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
5790 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*dephii
5791 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*dephii1
5792 gloc(nphi+i-2,icg)=wang*dethetai
5794 !-----------thete constrains
5795 ! if (tor_mode.ne.2) then
5797 ! print *,ithetaconstr_start,ithetaconstr_end,"TU"
5798 do i=ithetaconstr_start,ithetaconstr_end
5799 itheta=itheta_constr(i)
5800 thetiii=theta(itheta)
5801 difi=pinorm(thetiii-theta_constr0(i))
5802 if (difi.gt.theta_drange(i)) then
5803 difi=difi-theta_drange(i)
5804 ethetacnstr=ethetacnstr+0.25d0*for_thet_constr(i)*difi**4
5805 gloc(itheta+nphi-2,icg)=gloc(itheta+nphi-2,icg) &
5806 +for_thet_constr(i)*difi**3
5807 else if (difi.lt.-drange(i)) then
5809 ethetacnstr=ethetacnstr+0.25d0*for_thet_constr(i)*difi**4
5810 gloc(itheta+nphi-2,icg)=gloc(itheta+nphi-2,icg) &
5811 +for_thet_constr(i)*difi**3
5815 if (energy_dec) then
5816 write (iout,'(a6,2i5,4f8.3,2e14.5)') "ethetc", &
5817 i,itheta,rad2deg*thetiii, &
5818 rad2deg*theta_constr0(i), rad2deg*theta_drange(i), &
5819 rad2deg*difi,0.25d0*for_thet_constr(i)*difi**4, &
5820 gloc(itheta+nphi-2,icg)
5826 end subroutine ebend
5829 !-----------------------------------------------------------------------------
5830 subroutine esc(escloc)
5831 ! Calculate the local energy of a side chain and its derivatives in the
5832 ! corresponding virtual-bond valence angles THETA and the spherical angles
5836 ! implicit real*8 (a-h,o-z)
5837 ! include 'DIMENSIONS'
5838 ! include 'COMMON.GEO'
5839 ! include 'COMMON.LOCAL'
5840 ! include 'COMMON.VAR'
5841 ! include 'COMMON.INTERACT'
5842 ! include 'COMMON.DERIV'
5843 ! include 'COMMON.CHAIN'
5844 ! include 'COMMON.IOUNITS'
5845 ! include 'COMMON.NAMES'
5846 ! include 'COMMON.FFIELD'
5847 ! include 'COMMON.CONTROL'
5848 real(kind=8),dimension(3) :: x,dersc,xemp,dersc0,dersc1,&
5849 ddersc0,ddummy,xtemp,temp
5850 !el real(kind=8) :: time11,time12,time112,theti
5851 real(kind=8) :: escloc,delta
5852 !el integer :: it,nlobit
5853 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
5856 real(kind=8) :: escloci0,escloci1,escloci,esclocbi0,&
5857 dersc12,esclocbi1,chuju,esclocbi,dersc02,dersc01,ss,ssd
5860 ! write (iout,'(a)') 'ESC'
5861 do i=loc_start,loc_end
5863 if (it.eq.ntyp1) cycle
5864 if (it.eq.10) goto 1
5865 nlobit=nlob(iabs(it))
5866 ! print *,'i=',i,' it=',it,' nlobit=',nlobit
5867 ! write (iout,*) 'i=',i,' ssa=',ssa,' ssad=',ssad
5868 theti=theta(i+1)-pipol
5873 if (x(2).gt.pi-delta) then
5877 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
5879 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
5880 call spline1(x(2),pi-delta,delta,escloci0,escloci1,dersc0(2),&
5882 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),&
5883 ddersc0(1),dersc(1))
5884 call spline2(x(2),pi-delta,delta,dersc0(3),dersc1(3),&
5885 ddersc0(3),dersc(3))
5887 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
5889 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
5890 call spline1(x(2),pi-delta,delta,esclocbi0,esclocbi1,&
5891 dersc0(2),esclocbi,dersc02)
5892 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),&
5894 call splinthet(x(2),0.5d0*delta,ss,ssd)
5899 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
5901 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
5902 ! write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
5904 escloci=ss*escloci+(1.0d0-ss)*esclocbi
5906 ! write (iout,*) escloci
5907 else if (x(2).lt.delta) then
5911 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
5913 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
5914 call spline1(x(2),delta,-delta,escloci0,escloci1,dersc0(2),&
5916 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),&
5917 ddersc0(1),dersc(1))
5918 call spline2(x(2),delta,-delta,dersc0(3),dersc1(3),&
5919 ddersc0(3),dersc(3))
5921 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
5923 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
5924 call spline1(x(2),delta,-delta,esclocbi0,esclocbi1,&
5925 dersc0(2),esclocbi,dersc02)
5926 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),&
5931 call splinthet(x(2),0.5d0*delta,ss,ssd)
5933 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
5935 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
5936 ! write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
5938 escloci=ss*escloci+(1.0d0-ss)*esclocbi
5939 ! write (iout,*) escloci
5941 call enesc(x,escloci,dersc,ddummy,.false.)
5944 escloc=escloc+escloci
5945 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
5947 ! write (iout,*) 'i=',i,' escloci=',escloci,' dersc=',dersc
5949 gloc(nphi+i-1,icg)=gloc(nphi+i-1,icg)+ &
5951 gloc(ialph(i,1),icg)=wscloc*dersc(2)
5952 gloc(ialph(i,1)+nside,icg)=wscloc*dersc(3)
5957 !-----------------------------------------------------------------------------
5958 subroutine enesc(x,escloci,dersc,ddersc,mixed)
5961 ! implicit real*8 (a-h,o-z)
5962 ! include 'DIMENSIONS'
5963 ! include 'COMMON.GEO'
5964 ! include 'COMMON.LOCAL'
5965 ! include 'COMMON.IOUNITS'
5966 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
5967 real(kind=8),dimension(3) :: x,z,dersc,ddersc
5968 real(kind=8),dimension(3,nlobit,-1:1) :: Ax !(3,maxlob,-1:1)
5969 real(kind=8),dimension(nlobit,-1:1) :: contr !(maxlob,-1:1)
5970 real(kind=8) :: escloci
5973 integer :: j,iii,l,k !el,it,nlobit
5974 real(kind=8) :: escloc_i,x3,Axk,expfac,emin !el,theti,&
5975 !el time11,time12,time112
5976 ! write (iout,*) 'it=',it,' nlobit=',nlobit
5980 if (mixed) ddersc(j)=0.0d0
5984 ! Because of periodicity of the dependence of the SC energy in omega we have
5985 ! to add up the contributions from x(3)-2*pi, x(3), and x(3+2*pi).
5986 ! To avoid underflows, first compute & store the exponents.
5994 z(k)=x(k)-censc(k,j,it)
5999 Axk=Axk+gaussc(l,k,j,it)*z(l)
6005 expfac=expfac+Ax(k,j,iii)*z(k)
6013 ! As in the case of ebend, we want to avoid underflows in exponentiation and
6014 ! subsequent NaNs and INFs in energy calculation.
6015 ! Find the largest exponent
6019 if (emin.gt.contr(j,iii)) emin=contr(j,iii)
6023 !d print *,'it=',it,' emin=',emin
6025 ! Compute the contribution to SC energy and derivatives
6030 adexp=bsc(j,iabs(it))-0.5D0*contr(j,iii)+emin
6031 if(adexp.ne.adexp) adexp=1.0
6034 expfac=dexp(bsc(j,iabs(it))-0.5D0*contr(j,iii)+emin)
6036 !d print *,'j=',j,' expfac=',expfac
6037 escloc_i=escloc_i+expfac
6039 dersc(k)=dersc(k)+Ax(k,j,iii)*expfac
6043 ddersc(k)=ddersc(k)+(-Ax(2,j,iii)*Ax(k,j,iii) &
6044 +gaussc(k,2,j,it))*expfac
6051 dersc(1)=dersc(1)/cos(theti)**2
6052 ddersc(1)=ddersc(1)/cos(theti)**2
6055 escloci=-(dlog(escloc_i)-emin)
6057 dersc(j)=dersc(j)/escloc_i
6061 ddersc(j)=(ddersc(j)/escloc_i+dersc(2)*dersc(j))
6065 end subroutine enesc
6066 !-----------------------------------------------------------------------------
6067 subroutine enesc_bound(x,escloci,dersc,dersc12,mixed)
6070 ! implicit real*8 (a-h,o-z)
6071 ! include 'DIMENSIONS'
6072 ! include 'COMMON.GEO'
6073 ! include 'COMMON.LOCAL'
6074 ! include 'COMMON.IOUNITS'
6075 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
6076 real(kind=8),dimension(3) :: x,z,dersc
6077 real(kind=8),dimension(3,nlobit) :: Ax !(3,maxlob)
6078 real(kind=8),dimension(nlobit) :: contr !(maxlob)
6079 real(kind=8) :: escloci,dersc12,emin
6082 integer :: j,k,l !el,it,nlobit
6083 real(kind=8) :: escloc_i,Axk,expfac !el,time11,time12,time112,theti
6093 z(k)=x(k)-censc(k,j,it)
6099 Axk=Axk+gaussc(l,k,j,it)*z(l)
6105 expfac=expfac+Ax(k,j)*z(k)
6110 ! As in the case of ebend, we want to avoid underflows in exponentiation and
6111 ! subsequent NaNs and INFs in energy calculation.
6112 ! Find the largest exponent
6115 if (emin.gt.contr(j)) emin=contr(j)
6119 ! Compute the contribution to SC energy and derivatives
6123 expfac=dexp(bsc(j,iabs(it))-0.5D0*contr(j)+emin)
6124 escloc_i=escloc_i+expfac
6126 dersc(k)=dersc(k)+Ax(k,j)*expfac
6128 if (mixed) dersc12=dersc12+(-Ax(2,j)*Ax(1,j) &
6129 +gaussc(1,2,j,it))*expfac
6133 dersc(1)=dersc(1)/cos(theti)**2
6134 dersc12=dersc12/cos(theti)**2
6135 escloci=-(dlog(escloc_i)-emin)
6137 dersc(j)=dersc(j)/escloc_i
6139 if (mixed) dersc12=(dersc12/escloc_i+dersc(2)*dersc(1))
6141 end subroutine enesc_bound
6143 !-----------------------------------------------------------------------------
6144 subroutine esc(escloc)
6145 ! Calculate the local energy of a side chain and its derivatives in the
6146 ! corresponding virtual-bond valence angles THETA and the spherical angles
6147 ! ALPHA and OMEGA derived from AM1 all-atom calculations.
6148 ! added by Urszula Kozlowska. 07/11/2007
6151 ! implicit real*8 (a-h,o-z)
6152 ! include 'DIMENSIONS'
6153 ! include 'COMMON.GEO'
6154 ! include 'COMMON.LOCAL'
6155 ! include 'COMMON.VAR'
6156 ! include 'COMMON.SCROT'
6157 ! include 'COMMON.INTERACT'
6158 ! include 'COMMON.DERIV'
6159 ! include 'COMMON.CHAIN'
6160 ! include 'COMMON.IOUNITS'
6161 ! include 'COMMON.NAMES'
6162 ! include 'COMMON.FFIELD'
6163 ! include 'COMMON.CONTROL'
6164 ! include 'COMMON.VECTORS'
6165 real(kind=8),dimension(3) :: x_prime,y_prime,z_prime
6166 real(kind=8),dimension(65) :: x
6167 real(kind=8) :: sumene,dsc_i,dp2_i,xx,yy,zz,sumene1,sumene2,sumene3,&
6168 sumene4,s1,s1_6,s2,s2_6,de_dxx,de_dyy,de_dzz,de_dt
6169 real(kind=8) :: s1_t,s1_6_t,s2_t,s2_6_t
6170 real(kind=8),dimension(3) :: dXX_Ci1,dYY_Ci1,dZZ_Ci1,dXX_Ci,dYY_Ci,&
6171 dZZ_Ci,dXX_XYZ,dYY_XYZ,dZZ_XYZ,dt_dCi,dt_dCi1
6173 integer :: i,j,k !el,it,nlobit
6174 real(kind=8) :: cosfac2,sinfac2,cosfac,sinfac,escloc,delta
6175 !el real(kind=8) :: time11,time12,time112,theti
6176 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
6177 real(kind=8) :: dscp1,dscp2,pom_s1,pom_s16,pom_s2,pom_s26,&
6178 pom,pom_dx,pom_dy,pom_dt1,pom_dt2,pom1,pom2,&
6179 sumene1x,sumene2x,sumene3x,sumene4x,&
6180 sumene1y,sumene2y,sumene3y,sumene4y,cossc,cossc1,&
6183 real(kind=8) :: aincr,xxsave,sumenep,de_dxx_num,yysave,&
6184 de_dyy_num,zzsave,de_dzz_num,costsave,sintsave,&
6187 ! if (.not.allocated(gsclocx)) allocate(gsclocx(3,nres)) !(3,maxres)
6191 do i=loc_start,loc_end
6192 if (itype(i,1).eq.ntyp1) cycle
6193 costtab(i+1) =dcos(theta(i+1))
6194 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
6195 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
6196 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
6197 cosfac2=0.5d0/(1.0d0+costtab(i+1))
6198 cosfac=dsqrt(cosfac2)
6199 sinfac2=0.5d0/(1.0d0-costtab(i+1))
6200 sinfac=dsqrt(sinfac2)
6202 if (it.eq.10) goto 1
6204 ! Compute the axes of tghe local cartesian coordinates system; store in
6205 ! x_prime, y_prime and z_prime
6212 ! write(2,*) "dc_norm", dc_norm(1,i+nres),dc_norm(2,i+nres),
6213 ! & dc_norm(3,i+nres)
6215 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
6216 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
6219 z_prime(j) = -uz(j,i-1)*dsign(1.0d0,dfloat(itype(i,1)))
6222 ! write (2,*) "x_prime",(x_prime(j),j=1,3)
6223 ! write (2,*) "y_prime",(y_prime(j),j=1,3)
6224 ! write (2,*) "z_prime",(z_prime(j),j=1,3)
6225 ! write (2,*) "xx",scalar(x_prime(1),x_prime(1)),
6226 ! & " xy",scalar(x_prime(1),y_prime(1)),
6227 ! & " xz",scalar(x_prime(1),z_prime(1)),
6228 ! & " yy",scalar(y_prime(1),y_prime(1)),
6229 ! & " yz",scalar(y_prime(1),z_prime(1)),
6230 ! & " zz",scalar(z_prime(1),z_prime(1))
6232 ! Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
6233 ! to local coordinate system. Store in xx, yy, zz.
6239 xx = xx + x_prime(j)*dc_norm(j,i+nres)
6240 yy = yy + y_prime(j)*dc_norm(j,i+nres)
6241 zz = zz + z_prime(j)*dc_norm(j,i+nres)
6248 ! Compute the energy of the ith side cbain
6250 ! write (2,*) "xx",xx," yy",yy," zz",zz
6253 x(j) = sc_parmin(j,it)
6256 !c diagnostics - remove later
6258 yy1 = dsin(alph(2))*dcos(omeg(2))
6259 zz1 = -dsign(1.0,dfloat(itype(i,1)))*dsin(alph(2))*dsin(omeg(2))
6260 write(2,'(3f8.1,3f9.3,1x,3f9.3)') &
6261 alph(2)*rad2deg,omeg(2)*rad2deg,theta(3)*rad2deg,xx,yy,zz,&
6263 !," --- ", xx_w,yy_w,zz_w
6266 sumene1= x(1)+ x(2)*xx+ x(3)*yy+ x(4)*zz+ x(5)*xx**2 &
6267 + x(6)*yy**2+ x(7)*zz**2+ x(8)*xx*zz+ x(9)*xx*yy &
6269 sumene2= x(11) + x(12)*xx + x(13)*yy + x(14)*zz + x(15)*xx**2 &
6270 + x(16)*yy**2 + x(17)*zz**2 + x(18)*xx*zz + x(19)*xx*yy &
6272 sumene3= x(21) +x(22)*xx +x(23)*yy +x(24)*zz +x(25)*xx**2 &
6273 +x(26)*yy**2 +x(27)*zz**2 +x(28)*xx*zz +x(29)*xx*yy &
6274 +x(30)*yy*zz +x(31)*xx**3 +x(32)*yy**3 +x(33)*zz**3 &
6275 +x(34)*(xx**2)*yy +x(35)*(xx**2)*zz +x(36)*(yy**2)*xx &
6276 +x(37)*(yy**2)*zz +x(38)*(zz**2)*xx +x(39)*(zz**2)*yy &
6278 sumene4= x(41) +x(42)*xx +x(43)*yy +x(44)*zz +x(45)*xx**2 &
6279 +x(46)*yy**2 +x(47)*zz**2 +x(48)*xx*zz +x(49)*xx*yy &
6280 +x(50)*yy*zz +x(51)*xx**3 +x(52)*yy**3 +x(53)*zz**3 &
6281 +x(54)*(xx**2)*yy +x(55)*(xx**2)*zz +x(56)*(yy**2)*xx &
6282 +x(57)*(yy**2)*zz +x(58)*(zz**2)*xx +x(59)*(zz**2)*yy &
6284 dsc_i = 0.743d0+x(61)
6286 dscp1=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
6287 *(xx*cost2tab(i+1)+yy*sint2tab(i+1)))
6288 dscp2=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
6289 *(xx*cost2tab(i+1)-yy*sint2tab(i+1)))
6290 s1=(1+x(63))/(0.1d0 + dscp1)
6291 s1_6=(1+x(64))/(0.1d0 + dscp1**6)
6292 s2=(1+x(65))/(0.1d0 + dscp2)
6293 s2_6=(1+x(65))/(0.1d0 + dscp2**6)
6294 sumene = ( sumene3*sint2tab(i+1) + sumene1)*(s1+s1_6) &
6295 + (sumene4*cost2tab(i+1) +sumene2)*(s2+s2_6)
6296 ! write(2,'(i2," sumene",7f9.3)') i,sumene1,sumene2,sumene3,
6298 ! & dscp1,dscp2,sumene
6299 ! sumene = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6300 escloc = escloc + sumene
6301 ! write (2,*) "i",i," escloc",sumene,escloc,it,itype(i,1)
6306 ! This section to check the numerical derivatives of the energy of ith side
6307 ! chain in xx, yy, zz, and theta. Use the -DDEBUG compiler option or insert
6308 ! #define DEBUG in the code to turn it on.
6310 write (2,*) "sumene =",sumene
6314 write (2,*) xx,yy,zz
6315 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6316 de_dxx_num=(sumenep-sumene)/aincr
6318 write (2,*) "xx+ sumene from enesc=",sumenep
6321 write (2,*) xx,yy,zz
6322 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6323 de_dyy_num=(sumenep-sumene)/aincr
6325 write (2,*) "yy+ sumene from enesc=",sumenep
6328 write (2,*) xx,yy,zz
6329 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6330 de_dzz_num=(sumenep-sumene)/aincr
6332 write (2,*) "zz+ sumene from enesc=",sumenep
6333 costsave=cost2tab(i+1)
6334 sintsave=sint2tab(i+1)
6335 cost2tab(i+1)=dcos(0.5d0*(theta(i+1)+aincr))
6336 sint2tab(i+1)=dsin(0.5d0*(theta(i+1)+aincr))
6337 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6338 de_dt_num=(sumenep-sumene)/aincr
6339 write (2,*) " t+ sumene from enesc=",sumenep
6340 cost2tab(i+1)=costsave
6341 sint2tab(i+1)=sintsave
6342 ! End of diagnostics section.
6345 ! Compute the gradient of esc
6347 ! zz=zz*dsign(1.0,dfloat(itype(i,1)))
6348 pom_s1=(1.0d0+x(63))/(0.1d0 + dscp1)**2
6349 pom_s16=6*(1.0d0+x(64))/(0.1d0 + dscp1**6)**2
6350 pom_s2=(1.0d0+x(65))/(0.1d0 + dscp2)**2
6351 pom_s26=6*(1.0d0+x(65))/(0.1d0 + dscp2**6)**2
6352 pom_dx=dsc_i*dp2_i*cost2tab(i+1)
6353 pom_dy=dsc_i*dp2_i*sint2tab(i+1)
6354 pom_dt1=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)-yy*cost2tab(i+1))
6355 pom_dt2=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)+yy*cost2tab(i+1))
6356 pom1=(sumene3*sint2tab(i+1)+sumene1) &
6357 *(pom_s1/dscp1+pom_s16*dscp1**4)
6358 pom2=(sumene4*cost2tab(i+1)+sumene2) &
6359 *(pom_s2/dscp2+pom_s26*dscp2**4)
6360 sumene1x=x(2)+2*x(5)*xx+x(8)*zz+ x(9)*yy
6361 sumene3x=x(22)+2*x(25)*xx+x(28)*zz+x(29)*yy+3*x(31)*xx**2 &
6362 +2*x(34)*xx*yy +2*x(35)*xx*zz +x(36)*(yy**2) +x(38)*(zz**2) &
6364 sumene2x=x(12)+2*x(15)*xx+x(18)*zz+ x(19)*yy
6365 sumene4x=x(42)+2*x(45)*xx +x(48)*zz +x(49)*yy +3*x(51)*xx**2 &
6366 +2*x(54)*xx*yy+2*x(55)*xx*zz+x(56)*(yy**2)+x(58)*(zz**2) &
6368 de_dxx =(sumene1x+sumene3x*sint2tab(i+1))*(s1+s1_6) &
6369 +(sumene2x+sumene4x*cost2tab(i+1))*(s2+s2_6) &
6372 write(2,*), "de_dxx = ", de_dxx,de_dxx_num,itype(i,1)
6375 sumene1y=x(3) + 2*x(6)*yy + x(9)*xx + x(10)*zz
6376 sumene3y=x(23) +2*x(26)*yy +x(29)*xx +x(30)*zz +3*x(32)*yy**2 &
6377 +x(34)*(xx**2) +2*x(36)*yy*xx +2*x(37)*yy*zz +x(39)*(zz**2) &
6379 sumene2y=x(13) + 2*x(16)*yy + x(19)*xx + x(20)*zz
6380 sumene4y=x(43)+2*x(46)*yy+x(49)*xx +x(50)*zz &
6381 +3*x(52)*yy**2+x(54)*xx**2+2*x(56)*yy*xx +2*x(57)*yy*zz &
6382 +x(59)*zz**2 +x(60)*xx*zz
6383 de_dyy =(sumene1y+sumene3y*sint2tab(i+1))*(s1+s1_6) &
6384 +(sumene2y+sumene4y*cost2tab(i+1))*(s2+s2_6) &
6387 write(2,*), "de_dyy = ", de_dyy,de_dyy_num,itype(i,1)
6390 de_dzz =(x(24) +2*x(27)*zz +x(28)*xx +x(30)*yy &
6391 +3*x(33)*zz**2 +x(35)*xx**2 +x(37)*yy**2 +2*x(38)*zz*xx &
6392 +2*x(39)*zz*yy +x(40)*xx*yy)*sint2tab(i+1)*(s1+s1_6) &
6393 +(x(4) + 2*x(7)*zz+ x(8)*xx + x(10)*yy)*(s1+s1_6) &
6394 +(x(44)+2*x(47)*zz +x(48)*xx +x(50)*yy +3*x(53)*zz**2 &
6395 +x(55)*xx**2 +x(57)*(yy**2)+2*x(58)*zz*xx +2*x(59)*zz*yy &
6396 +x(60)*xx*yy)*cost2tab(i+1)*(s2+s2_6) &
6397 + ( x(14) + 2*x(17)*zz+ x(18)*xx + x(20)*yy)*(s2+s2_6)
6399 write(2,*), "de_dzz = ", de_dzz,de_dzz_num,itype(i,1)
6402 de_dt = 0.5d0*sumene3*cost2tab(i+1)*(s1+s1_6) &
6403 -0.5d0*sumene4*sint2tab(i+1)*(s2+s2_6) &
6404 +pom1*pom_dt1+pom2*pom_dt2
6406 write(2,*), "de_dt = ", de_dt,de_dt_num,itype(i,1)
6410 cossc=scalar(dc_norm(1,i),dc_norm(1,i+nres))
6411 cossc1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
6412 cosfac2xx=cosfac2*xx
6413 sinfac2yy=sinfac2*yy
6415 dt_dCi(k) = -(dc_norm(k,i-1)+costtab(i+1)*dc_norm(k,i))* &
6417 dt_dCi1(k)= -(dc_norm(k,i)+costtab(i+1)*dc_norm(k,i-1))* &
6419 pom=(dC_norm(k,i+nres)-cossc*dC_norm(k,i))*vbld_inv(i+1)
6420 pom1=(dC_norm(k,i+nres)-cossc1*dC_norm(k,i-1))*vbld_inv(i)
6421 ! write (iout,*) "i",i," k",k," pom",pom," pom1",pom1,
6422 ! & " dt_dCi",dt_dCi(k)," dt_dCi1",dt_dCi1(k)
6423 ! write (iout,*) "dC_norm",(dC_norm(j,i),j=1,3),
6424 ! & (dC_norm(j,i-1),j=1,3)," vbld_inv",vbld_inv(i+1),vbld_inv(i)
6425 dXX_Ci(k)=pom*cosfac-dt_dCi(k)*cosfac2xx
6426 dXX_Ci1(k)=-pom1*cosfac-dt_dCi1(k)*cosfac2xx
6427 dYY_Ci(k)=pom*sinfac+dt_dCi(k)*sinfac2yy
6428 dYY_Ci1(k)=pom1*sinfac+dt_dCi1(k)*sinfac2yy
6432 dZZ_Ci(k)=dZZ_Ci(k)-uzgrad(j,k,2,i-1) &
6433 *dsign(1.0d0,dfloat(itype(i,1)))*dC_norm(j,i+nres)
6434 dZZ_Ci1(k)=dZZ_Ci1(k)-uzgrad(j,k,1,i-1) &
6435 *dsign(1.0d0,dfloat(itype(i,1)))*dC_norm(j,i+nres)
6438 dXX_XYZ(k)=vbld_inv(i+nres)*(x_prime(k)-xx*dC_norm(k,i+nres))
6439 dYY_XYZ(k)=vbld_inv(i+nres)*(y_prime(k)-yy*dC_norm(k,i+nres))
6440 dZZ_XYZ(k)=vbld_inv(i+nres)* &
6441 (z_prime(k)-zz*dC_norm(k,i+nres))
6443 dt_dCi(k) = -dt_dCi(k)/sinttab(i+1)
6444 dt_dCi1(k)= -dt_dCi1(k)/sinttab(i+1)
6448 dXX_Ctab(k,i)=dXX_Ci(k)
6449 dXX_C1tab(k,i)=dXX_Ci1(k)
6450 dYY_Ctab(k,i)=dYY_Ci(k)
6451 dYY_C1tab(k,i)=dYY_Ci1(k)
6452 dZZ_Ctab(k,i)=dZZ_Ci(k)
6453 dZZ_C1tab(k,i)=dZZ_Ci1(k)
6454 dXX_XYZtab(k,i)=dXX_XYZ(k)
6455 dYY_XYZtab(k,i)=dYY_XYZ(k)
6456 dZZ_XYZtab(k,i)=dZZ_XYZ(k)
6460 ! write (iout,*) "k",k," dxx_ci1",dxx_ci1(k)," dyy_ci1",
6461 ! & dyy_ci1(k)," dzz_ci1",dzz_ci1(k)
6462 ! write (iout,*) "k",k," dxx_ci",dxx_ci(k)," dyy_ci",
6463 ! & dyy_ci(k)," dzz_ci",dzz_ci(k)
6464 ! write (iout,*) "k",k," dt_dci",dt_dci(k)," dt_dci",
6466 ! write (iout,*) "k",k," dxx_XYZ",dxx_XYZ(k)," dyy_XYZ",
6467 ! & dyy_XYZ(k)," dzz_XYZ",dzz_XYZ(k)
6468 gscloc(k,i-1)=gscloc(k,i-1)+de_dxx*dxx_ci1(k) &
6469 +de_dyy*dyy_ci1(k)+de_dzz*dzz_ci1(k)+de_dt*dt_dCi1(k)
6470 gscloc(k,i)=gscloc(k,i)+de_dxx*dxx_Ci(k) &
6471 +de_dyy*dyy_Ci(k)+de_dzz*dzz_Ci(k)+de_dt*dt_dCi(k)
6472 gsclocx(k,i)= de_dxx*dxx_XYZ(k) &
6473 +de_dyy*dyy_XYZ(k)+de_dzz*dzz_XYZ(k)
6475 ! write(iout,*) "ENERGY GRAD = ", (gscloc(k,i-1),k=1,3),
6476 ! & (gscloc(k,i),k=1,3),(gsclocx(k,i),k=1,3)
6478 ! to check gradient call subroutine check_grad
6484 !-----------------------------------------------------------------------------
6485 real(kind=8) function enesc(x,xx,yy,zz,cost2,sint2)
6487 real(kind=8),dimension(65) :: x
6488 real(kind=8) :: xx,yy,zz,cost2,sint2,sumene1,sumene2,sumene3,&
6489 sumene4,sumene,dsc_i,dp2_i,dscp1,dscp2,s1,s1_6,s2,s2_6
6491 sumene1= x(1)+ x(2)*xx+ x(3)*yy+ x(4)*zz+ x(5)*xx**2 &
6492 + x(6)*yy**2+ x(7)*zz**2+ x(8)*xx*zz+ x(9)*xx*yy &
6494 sumene2= x(11) + x(12)*xx + x(13)*yy + x(14)*zz + x(15)*xx**2 &
6495 + x(16)*yy**2 + x(17)*zz**2 + x(18)*xx*zz + x(19)*xx*yy &
6497 sumene3= x(21) +x(22)*xx +x(23)*yy +x(24)*zz +x(25)*xx**2 &
6498 +x(26)*yy**2 +x(27)*zz**2 +x(28)*xx*zz +x(29)*xx*yy &
6499 +x(30)*yy*zz +x(31)*xx**3 +x(32)*yy**3 +x(33)*zz**3 &
6500 +x(34)*(xx**2)*yy +x(35)*(xx**2)*zz +x(36)*(yy**2)*xx &
6501 +x(37)*(yy**2)*zz +x(38)*(zz**2)*xx +x(39)*(zz**2)*yy &
6503 sumene4= x(41) +x(42)*xx +x(43)*yy +x(44)*zz +x(45)*xx**2 &
6504 +x(46)*yy**2 +x(47)*zz**2 +x(48)*xx*zz +x(49)*xx*yy &
6505 +x(50)*yy*zz +x(51)*xx**3 +x(52)*yy**3 +x(53)*zz**3 &
6506 +x(54)*(xx**2)*yy +x(55)*(xx**2)*zz +x(56)*(yy**2)*xx &
6507 +x(57)*(yy**2)*zz +x(58)*(zz**2)*xx +x(59)*(zz**2)*yy &
6509 dsc_i = 0.743d0+x(61)
6511 dscp1=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
6512 *(xx*cost2+yy*sint2))
6513 dscp2=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
6514 *(xx*cost2-yy*sint2))
6515 s1=(1+x(63))/(0.1d0 + dscp1)
6516 s1_6=(1+x(64))/(0.1d0 + dscp1**6)
6517 s2=(1+x(65))/(0.1d0 + dscp2)
6518 s2_6=(1+x(65))/(0.1d0 + dscp2**6)
6519 sumene = ( sumene3*sint2 + sumene1)*(s1+s1_6) &
6520 + (sumene4*cost2 +sumene2)*(s2+s2_6)
6525 !-----------------------------------------------------------------------------
6526 subroutine gcont(rij,r0ij,eps0ij,delta,fcont,fprimcont)
6528 ! This procedure calculates two-body contact function g(rij) and its derivative:
6531 ! g(rij) = esp0ij*(-0.9375*x+0.625*x**3-0.1875*x**5) ! -1 =< x =< 1
6534 ! where x=(rij-r0ij)/delta
6536 ! rij - interbody distance, r0ij - contact distance, eps0ij - contact energy
6539 real(kind=8) :: rij,r0ij,eps0ij,fcont,fprimcont
6540 real(kind=8) :: x,x2,x4,delta
6544 if (x.lt.-1.0D0) then
6547 else if (x.le.1.0D0) then
6550 fcont=eps0ij*(x*(-0.9375D0+0.6250D0*x2-0.1875D0*x4)+0.5D0)
6551 fprimcont=eps0ij * (-0.9375D0+1.8750D0*x2-0.9375D0*x4)/delta
6557 end subroutine gcont
6558 !-----------------------------------------------------------------------------
6559 subroutine splinthet(theti,delta,ss,ssder)
6560 ! implicit real*8 (a-h,o-z)
6561 ! include 'DIMENSIONS'
6562 ! include 'COMMON.VAR'
6563 ! include 'COMMON.GEO'
6564 real(kind=8) :: theti,delta,ss,ssder
6565 real(kind=8) :: thetup,thetlow
6568 if (theti.gt.pipol) then
6569 call gcont(theti,thetup,1.0d0,delta,ss,ssder)
6571 call gcont(-theti,-thetlow,1.0d0,delta,ss,ssder)
6575 end subroutine splinthet
6576 !-----------------------------------------------------------------------------
6577 subroutine spline1(x,x0,delta,f0,f1,fprim0,f,fprim)
6579 real(kind=8) :: x,x0,delta,f0,f1,fprim0,f,fprim
6580 real(kind=8) :: ksi,ksi2,ksi3,a1,a2,a3
6581 a1=fprim0*delta/(f1-f0)
6587 f=f0+(f1-f0)*ksi*(a1+ksi*(a2+a3*ksi))
6588 fprim=(f1-f0)/delta*(a1+ksi*(2*a2+3*ksi*a3))
6590 end subroutine spline1
6591 !-----------------------------------------------------------------------------
6592 subroutine spline2(x,x0,delta,f0x,f1x,fprim0x,fx)
6594 real(kind=8) :: x,x0,delta,f0x,f1x,fprim0x,fx
6595 real(kind=8) :: ksi,ksi2,ksi3,a1,a2,a3
6600 a2=3*(f1x-f0x)-2*fprim0x*delta
6601 a3=fprim0x*delta-2*(f1x-f0x)
6602 fx=f0x+a1*ksi+a2*ksi2+a3*ksi3
6604 end subroutine spline2
6605 !-----------------------------------------------------------------------------
6607 !-----------------------------------------------------------------------------
6608 subroutine etor(etors,edihcnstr)
6609 ! implicit real*8 (a-h,o-z)
6610 ! include 'DIMENSIONS'
6611 ! include 'COMMON.VAR'
6612 ! include 'COMMON.GEO'
6613 ! include 'COMMON.LOCAL'
6614 ! include 'COMMON.TORSION'
6615 ! include 'COMMON.INTERACT'
6616 ! include 'COMMON.DERIV'
6617 ! include 'COMMON.CHAIN'
6618 ! include 'COMMON.NAMES'
6619 ! include 'COMMON.IOUNITS'
6620 ! include 'COMMON.FFIELD'
6621 ! include 'COMMON.TORCNSTR'
6622 ! include 'COMMON.CONTROL'
6623 real(kind=8) :: etors,edihcnstr
6627 real(kind=8) :: phii,fac,etors_ii
6629 ! Set lprn=.true. for debugging
6633 do i=iphi_start,iphi_end
6635 if (itype(i-2,1).eq.ntyp1.or. itype(i-1,1).eq.ntyp1 &
6636 .or. itype(i,1).eq.ntyp1) cycle
6637 itori=itortyp(itype(i-2,1))
6638 itori1=itortyp(itype(i-1,1))
6641 ! Proline-Proline pair is a special case...
6642 if (itori.eq.3 .and. itori1.eq.3) then
6643 if (phii.gt.-dwapi3) then
6645 fac=1.0D0/(1.0D0-cosphi)
6646 etorsi=v1(1,3,3)*fac
6647 etorsi=etorsi+etorsi
6648 etors=etors+etorsi-v1(1,3,3)
6649 if (energy_dec) etors_ii=etors_ii+etorsi-v1(1,3,3)
6650 gloci=gloci-3*fac*etorsi*dsin(3*phii)
6653 v1ij=v1(j+1,itori,itori1)
6654 v2ij=v2(j+1,itori,itori1)
6657 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
6658 if (energy_dec) etors_ii=etors_ii+ &
6659 v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
6660 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
6664 v1ij=v1(j,itori,itori1)
6665 v2ij=v2(j,itori,itori1)
6668 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
6669 if (energy_dec) etors_ii=etors_ii+ &
6670 v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
6671 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
6674 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
6677 write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)') &
6678 restyp(itype(i-2,1),1),i-2,restyp(itype(i-1,1),1),i-1,itori,itori1,&
6679 (v1(j,itori,itori1),j=1,6),(v2(j,itori,itori1),j=1,6)
6680 gloc(i-3,icg)=gloc(i-3,icg)+wtor*gloci
6681 ! write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
6683 ! 6/20/98 - dihedral angle constraints
6686 itori=idih_constr(i)
6689 if (difi.gt.drange(i)) then
6691 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
6692 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
6693 else if (difi.lt.-drange(i)) then
6695 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
6696 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
6698 ! write (iout,'(2i5,2f8.3,2e14.5)') i,itori,rad2deg*phii,
6699 ! & rad2deg*difi,0.25d0*ftors*difi**4,gloc(itori-3,icg)
6701 ! write (iout,*) 'edihcnstr',edihcnstr
6704 !-----------------------------------------------------------------------------
6705 subroutine etor_d(etors_d)
6706 real(kind=8) :: etors_d
6709 end subroutine etor_d
6711 !-----------------------------------------------------------------------------
6712 subroutine etor(etors,edihcnstr)
6713 ! implicit real*8 (a-h,o-z)
6714 ! include 'DIMENSIONS'
6715 ! include 'COMMON.VAR'
6716 ! include 'COMMON.GEO'
6717 ! include 'COMMON.LOCAL'
6718 ! include 'COMMON.TORSION'
6719 ! include 'COMMON.INTERACT'
6720 ! include 'COMMON.DERIV'
6721 ! include 'COMMON.CHAIN'
6722 ! include 'COMMON.NAMES'
6723 ! include 'COMMON.IOUNITS'
6724 ! include 'COMMON.FFIELD'
6725 ! include 'COMMON.TORCNSTR'
6726 ! include 'COMMON.CONTROL'
6727 real(kind=8) :: etors,edihcnstr
6730 integer :: i,j,iblock,itori,itori1
6731 real(kind=8) :: phii,gloci,v1ij,v2ij,cosphi,sinphi,&
6732 vl1ij,vl2ij,vl3ij,pom1,difi,etors_ii,pom
6733 ! Set lprn=.true. for debugging
6737 do i=iphi_start,iphi_end
6738 if (itype(i-2,1).eq.ntyp1 .or. itype(i-1,1).eq.ntyp1 &
6739 .or. itype(i-3,1).eq.ntyp1 &
6740 .or. itype(i,1).eq.ntyp1) cycle
6742 if (iabs(itype(i,1)).eq.20) then
6747 itori=itortyp(itype(i-2,1))
6748 itori1=itortyp(itype(i-1,1))
6751 ! Regular cosine and sine terms
6752 do j=1,nterm(itori,itori1,iblock)
6753 v1ij=v1(j,itori,itori1,iblock)
6754 v2ij=v2(j,itori,itori1,iblock)
6757 etors=etors+v1ij*cosphi+v2ij*sinphi
6758 if (energy_dec) etors_ii=etors_ii+ &
6759 v1ij*cosphi+v2ij*sinphi
6760 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
6764 ! E = SUM ----------------------------------- - v1
6765 ! [v2 cos(phi/2)+v3 sin(phi/2)]^2 + 1
6767 cosphi=dcos(0.5d0*phii)
6768 sinphi=dsin(0.5d0*phii)
6769 do j=1,nlor(itori,itori1,iblock)
6770 vl1ij=vlor1(j,itori,itori1)
6771 vl2ij=vlor2(j,itori,itori1)
6772 vl3ij=vlor3(j,itori,itori1)
6773 pom=vl2ij*cosphi+vl3ij*sinphi
6774 pom1=1.0d0/(pom*pom+1.0d0)
6775 etors=etors+vl1ij*pom1
6776 if (energy_dec) etors_ii=etors_ii+ &
6779 gloci=gloci+vl1ij*(vl3ij*cosphi-vl2ij*sinphi)*pom
6781 ! Subtract the constant term
6782 etors=etors-v0(itori,itori1,iblock)
6783 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
6784 'etor',i,etors_ii-v0(itori,itori1,iblock)
6786 write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)') &
6787 restyp(itype(i-2,1),1),i-2,restyp(itype(i-1,1),1),i-1,itori,itori1,&
6788 (v1(j,itori,itori1,iblock),j=1,6),&
6789 (v2(j,itori,itori1,iblock),j=1,6)
6790 gloc(i-3,icg)=gloc(i-3,icg)+wtor*gloci
6791 ! write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
6793 ! 6/20/98 - dihedral angle constraints
6795 ! do i=1,ndih_constr
6796 do i=idihconstr_start,idihconstr_end
6797 itori=idih_constr(i)
6799 difi=pinorm(phii-phi0(i))
6800 if (difi.gt.drange(i)) then
6802 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
6803 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
6804 else if (difi.lt.-drange(i)) then
6806 edihcnstr=edihcnstr+0.25d0*ftors*difi**4
6807 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
6811 !d write (iout,'(2i5,4f8.3,2e14.5)') i,itori,rad2deg*phii,
6812 !d & rad2deg*phi0(i), rad2deg*drange(i),
6813 !d & rad2deg*difi,0.25d0*ftors*difi**4,gloc(itori-3,icg)
6815 !d write (iout,*) 'edihcnstr',edihcnstr
6818 !-----------------------------------------------------------------------------
6819 subroutine etor_d(etors_d)
6820 ! 6/23/01 Compute double torsional energy
6821 ! implicit real*8 (a-h,o-z)
6822 ! include 'DIMENSIONS'
6823 ! include 'COMMON.VAR'
6824 ! include 'COMMON.GEO'
6825 ! include 'COMMON.LOCAL'
6826 ! include 'COMMON.TORSION'
6827 ! include 'COMMON.INTERACT'
6828 ! include 'COMMON.DERIV'
6829 ! include 'COMMON.CHAIN'
6830 ! include 'COMMON.NAMES'
6831 ! include 'COMMON.IOUNITS'
6832 ! include 'COMMON.FFIELD'
6833 ! include 'COMMON.TORCNSTR'
6834 real(kind=8) :: etors_d,etors_d_ii
6837 integer :: i,j,k,l,itori,itori1,itori2,iblock
6838 real(kind=8) :: phii,phii1,gloci1,gloci2,&
6839 v1cij,v1sij,v2cij,v2sij,cosphi1,sinphi1,&
6840 sinphi2,cosphi2,v1cdij,v2cdij,v1sdij,v2sdij,&
6841 cosphi1p2,cosphi1m2,sinphi1p2,sinphi1m2
6842 ! Set lprn=.true. for debugging
6846 ! write(iout,*) "a tu??"
6847 do i=iphid_start,iphid_end
6849 if (itype(i-2,1).eq.ntyp1 .or. itype(i-1,1).eq.ntyp1 &
6850 .or. itype(i-3,1).eq.ntyp1 &
6851 .or. itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
6852 itori=itortyp(itype(i-2,1))
6853 itori1=itortyp(itype(i-1,1))
6854 itori2=itortyp(itype(i,1))
6860 if (iabs(itype(i+1,1)).eq.20) iblock=2
6862 ! Regular cosine and sine terms
6863 do j=1,ntermd_1(itori,itori1,itori2,iblock)
6864 v1cij=v1c(1,j,itori,itori1,itori2,iblock)
6865 v1sij=v1s(1,j,itori,itori1,itori2,iblock)
6866 v2cij=v1c(2,j,itori,itori1,itori2,iblock)
6867 v2sij=v1s(2,j,itori,itori1,itori2,iblock)
6868 cosphi1=dcos(j*phii)
6869 sinphi1=dsin(j*phii)
6870 cosphi2=dcos(j*phii1)
6871 sinphi2=dsin(j*phii1)
6872 etors_d=etors_d+v1cij*cosphi1+v1sij*sinphi1+ &
6873 v2cij*cosphi2+v2sij*sinphi2
6874 if (energy_dec) etors_d_ii=etors_d_ii+ &
6875 v1cij*cosphi1+v1sij*sinphi1+v2cij*cosphi2+v2sij*sinphi2
6876 gloci1=gloci1+j*(v1sij*cosphi1-v1cij*sinphi1)
6877 gloci2=gloci2+j*(v2sij*cosphi2-v2cij*sinphi2)
6879 do k=2,ntermd_2(itori,itori1,itori2,iblock)
6881 v1cdij = v2c(k,l,itori,itori1,itori2,iblock)
6882 v2cdij = v2c(l,k,itori,itori1,itori2,iblock)
6883 v1sdij = v2s(k,l,itori,itori1,itori2,iblock)
6884 v2sdij = v2s(l,k,itori,itori1,itori2,iblock)
6885 cosphi1p2=dcos(l*phii+(k-l)*phii1)
6886 cosphi1m2=dcos(l*phii-(k-l)*phii1)
6887 sinphi1p2=dsin(l*phii+(k-l)*phii1)
6888 sinphi1m2=dsin(l*phii-(k-l)*phii1)
6889 etors_d=etors_d+v1cdij*cosphi1p2+v2cdij*cosphi1m2+ &
6890 v1sdij*sinphi1p2+v2sdij*sinphi1m2
6891 if (energy_dec) etors_d_ii=etors_d_ii+ &
6892 v1cdij*cosphi1p2+v2cdij*cosphi1m2+ &
6893 v1sdij*sinphi1p2+v2sdij*sinphi1m2
6894 gloci1=gloci1+l*(v1sdij*cosphi1p2+v2sdij*cosphi1m2 &
6895 -v1cdij*sinphi1p2-v2cdij*sinphi1m2)
6896 gloci2=gloci2+(k-l)*(v1sdij*cosphi1p2-v2sdij*cosphi1m2 &
6897 -v1cdij*sinphi1p2+v2cdij*sinphi1m2)
6900 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
6901 'etor_d',i,etors_d_ii
6902 gloc(i-3,icg)=gloc(i-3,icg)+wtor_d*gloci1
6903 gloc(i-2,icg)=gloc(i-2,icg)+wtor_d*gloci2
6906 end subroutine etor_d
6908 !-----------------------------------------------------------------------------
6909 subroutine eback_sc_corr(esccor)
6910 ! 7/21/2007 Correlations between the backbone-local and side-chain-local
6911 ! conformational states; temporarily implemented as differences
6912 ! between UNRES torsional potentials (dependent on three types of
6913 ! residues) and the torsional potentials dependent on all 20 types
6914 ! of residues computed from AM1 energy surfaces of terminally-blocked
6915 ! amino-acid residues.
6916 ! implicit real*8 (a-h,o-z)
6917 ! include 'DIMENSIONS'
6918 ! include 'COMMON.VAR'
6919 ! include 'COMMON.GEO'
6920 ! include 'COMMON.LOCAL'
6921 ! include 'COMMON.TORSION'
6922 ! include 'COMMON.SCCOR'
6923 ! include 'COMMON.INTERACT'
6924 ! include 'COMMON.DERIV'
6925 ! include 'COMMON.CHAIN'
6926 ! include 'COMMON.NAMES'
6927 ! include 'COMMON.IOUNITS'
6928 ! include 'COMMON.FFIELD'
6929 ! include 'COMMON.CONTROL'
6930 real(kind=8) :: esccor,esccor_ii,phii,gloci,v1ij,v2ij,&
6933 integer :: i,interty,j,isccori,isccori1,intertyp
6934 ! Set lprn=.true. for debugging
6937 ! write (iout,*) "EBACK_SC_COR",itau_start,itau_end
6939 do i=itau_start,itau_end
6940 if ((itype(i-2,1).eq.ntyp1).or.(itype(i-1,1).eq.ntyp1)) cycle
6942 isccori=isccortyp(itype(i-2,1))
6943 isccori1=isccortyp(itype(i-1,1))
6945 ! write (iout,*) "EBACK_SC_COR",i,nterm_sccor(isccori,isccori1)
6947 do intertyp=1,3 !intertyp
6949 !c Added 09 May 2012 (Adasko)
6950 !c Intertyp means interaction type of backbone mainchain correlation:
6951 ! 1 = SC...Ca...Ca...Ca
6952 ! 2 = Ca...Ca...Ca...SC
6953 ! 3 = SC...Ca...Ca...SCi
6955 if (((intertyp.eq.3).and.((itype(i-2,1).eq.10).or. &
6956 (itype(i-1,1).eq.10).or.(itype(i-2,1).eq.ntyp1).or. &
6957 (itype(i-1,1).eq.ntyp1))) &
6958 .or. ((intertyp.eq.1).and.((itype(i-2,1).eq.10) &
6959 .or.(itype(i-2,1).eq.ntyp1).or.(itype(i-1,1).eq.ntyp1) &
6960 .or.(itype(i,1).eq.ntyp1))) &
6961 .or.((intertyp.eq.2).and.((itype(i-1,1).eq.10).or. &
6962 (itype(i-1,1).eq.ntyp1).or.(itype(i-2,1).eq.ntyp1).or. &
6963 (itype(i-3,1).eq.ntyp1)))) cycle
6964 if ((intertyp.eq.2).and.(i.eq.4).and.(itype(1,1).eq.ntyp1)) cycle
6965 if ((intertyp.eq.1).and.(i.eq.nres).and.(itype(nres,1).eq.ntyp1)) &
6967 do j=1,nterm_sccor(isccori,isccori1)
6968 v1ij=v1sccor(j,intertyp,isccori,isccori1)
6969 v2ij=v2sccor(j,intertyp,isccori,isccori1)
6970 cosphi=dcos(j*tauangle(intertyp,i))
6971 sinphi=dsin(j*tauangle(intertyp,i))
6972 if (energy_dec) esccor_ii=esccor_ii+v1ij*cosphi+v2ij*sinphi
6973 esccor=esccor+v1ij*cosphi+v2ij*sinphi
6974 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
6976 if (energy_dec) write (iout,'(a6,i5,i2,0pf7.3)') &
6977 'esccor',i,intertyp,esccor_ii
6978 ! write (iout,*) "EBACK_SC_COR",i,v1ij*cosphi+v2ij*sinphi,intertyp
6979 gloc_sc(intertyp,i-3,icg)=gloc_sc(intertyp,i-3,icg)+wsccor*gloci
6981 write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)') &
6982 restyp(itype(i-2,1),1),i-2,restyp(itype(i-1,1),1),i-1,isccori,isccori1,&
6983 (v1sccor(j,intertyp,isccori,isccori1),j=1,6),&
6984 (v2sccor(j,intertyp,isccori,isccori1),j=1,6)
6985 gsccor_loc(i-3)=gsccor_loc(i-3)+gloci
6990 end subroutine eback_sc_corr
6991 !-----------------------------------------------------------------------------
6992 subroutine multibody(ecorr)
6993 ! This subroutine calculates multi-body contributions to energy following
6994 ! the idea of Skolnick et al. If side chains I and J make a contact and
6995 ! at the same time side chains I+1 and J+1 make a contact, an extra
6996 ! contribution equal to sqrt(eps(i,j)*eps(i+1,j+1)) is added.
6997 ! implicit real*8 (a-h,o-z)
6998 ! include 'DIMENSIONS'
6999 ! include 'COMMON.IOUNITS'
7000 ! include 'COMMON.DERIV'
7001 ! include 'COMMON.INTERACT'
7002 ! include 'COMMON.CONTACTS'
7003 real(kind=8),dimension(3) :: gx,gx1
7005 real(kind=8) :: ecorr
7006 integer :: i,j,ishift,i1,num_conti,num_conti1,j1,jj,kk
7007 ! Set lprn=.true. for debugging
7011 write (iout,'(a)') 'Contact function values:'
7013 write (iout,'(i2,20(1x,i2,f10.5))') &
7014 i,(jcont(j,i),facont(j,i),j=1,num_cont(i))
7019 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres))
7020 ! if (.not.allocated(gradxorr)) allocate(gradxorr(3,nres))
7032 num_conti=num_cont(i)
7033 num_conti1=num_cont(i1)
7038 if (j1.eq.j+ishift .or. j1.eq.j-ishift) then
7039 !d write(iout,*)'i=',i,' j=',j,' i1=',i1,' j1=',j1,
7040 !d & ' ishift=',ishift
7041 ! Contacts I--J and I+ISHIFT--J+-ISHIFT1 occur simultaneously.
7042 ! The system gains extra energy.
7043 ecorr=ecorr+esccorr(i,j,i1,j1,jj,kk)
7044 endif ! j1==j+-ishift
7052 end subroutine multibody
7053 !-----------------------------------------------------------------------------
7054 real(kind=8) function esccorr(i,j,k,l,jj,kk)
7055 ! implicit real*8 (a-h,o-z)
7056 ! include 'DIMENSIONS'
7057 ! include 'COMMON.IOUNITS'
7058 ! include 'COMMON.DERIV'
7059 ! include 'COMMON.INTERACT'
7060 ! include 'COMMON.CONTACTS'
7061 real(kind=8),dimension(3) :: gx,gx1
7063 integer :: i,j,k,l,jj,kk,m,ll
7064 real(kind=8) :: eij,ekl
7068 !d write (iout,'(4i5,3f10.5)') i,j,k,l,eij,ekl,-eij*ekl
7069 ! Calculate the multi-body contribution to energy.
7070 ! Calculate multi-body contributions to the gradient.
7071 !d write (iout,'(2(2i3,3f10.5))')i,j,(gacont(m,jj,i),m=1,3),
7072 !d & k,l,(gacont(m,kk,k),m=1,3)
7074 gx(m) =ekl*gacont(m,jj,i)
7075 gx1(m)=eij*gacont(m,kk,k)
7076 gradxorr(m,i)=gradxorr(m,i)-gx(m)
7077 gradxorr(m,j)=gradxorr(m,j)+gx(m)
7078 gradxorr(m,k)=gradxorr(m,k)-gx1(m)
7079 gradxorr(m,l)=gradxorr(m,l)+gx1(m)
7083 gradcorr(ll,m)=gradcorr(ll,m)+gx(ll)
7088 gradcorr(ll,m)=gradcorr(ll,m)+gx1(ll)
7093 end function esccorr
7094 !-----------------------------------------------------------------------------
7095 subroutine multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
7096 ! This subroutine calculates multi-body contributions to hydrogen-bonding
7097 ! implicit real*8 (a-h,o-z)
7098 ! include 'DIMENSIONS'
7099 ! include 'COMMON.IOUNITS'
7102 ! integer :: maxconts !max_cont=maxconts =nres/4
7103 integer,parameter :: max_dim=26
7104 integer :: source,CorrelType,CorrelID,CorrelType1,CorrelID1,Error
7105 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
7106 !el real(kind=8) :: zapas(max_dim,maxconts,nfgtasks)
7107 !el common /przechowalnia/ zapas
7108 integer :: status(MPI_STATUS_SIZE)
7109 integer,dimension((nres/4)*2) :: req !maxconts*2
7110 integer :: status_array(MPI_STATUS_SIZE,(nres/4)*2),nn,ireq,ierr
7112 ! include 'COMMON.SETUP'
7113 ! include 'COMMON.FFIELD'
7114 ! include 'COMMON.DERIV'
7115 ! include 'COMMON.INTERACT'
7116 ! include 'COMMON.CONTACTS'
7117 ! include 'COMMON.CONTROL'
7118 ! include 'COMMON.LOCAL'
7119 real(kind=8),dimension(3) :: gx,gx1
7120 real(kind=8) :: time00,ecorr,ecorr5,ecorr6
7121 logical :: lprn,ldone
7123 integer :: i,j,ii,k,n_corr,n_corr1,i1,num_conti,num_conti1,&
7124 jj,jp,kk,j1,jp1,jjc,iii,nnn,iproc
7126 ! Set lprn=.true. for debugging
7130 if(.not.allocated(zapas)) allocate(zapas(max_dim,maxconts,nfgtasks))
7133 if (nfgtasks.le.1) goto 30
7135 write (iout,'(a)') 'Contact function values before RECEIVE:'
7137 write (iout,'(2i3,50(1x,i2,f5.2))') &
7138 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
7143 do i=1,ntask_cont_from
7146 do i=1,ntask_cont_to
7149 ! write (iout,*) "ntask_cont_from",ntask_cont_from," ntask_cont_to",
7151 ! Make the list of contacts to send to send to other procesors
7152 ! write (iout,*) "limits",max0(iturn4_end-1,iatel_s),iturn3_end
7154 do i=iturn3_start,iturn3_end
7155 ! write (iout,*) "make contact list turn3",i," num_cont",
7157 call add_hb_contact(i,i+2,iturn3_sent_local(1,i))
7159 do i=iturn4_start,iturn4_end
7160 ! write (iout,*) "make contact list turn4",i," num_cont",
7162 call add_hb_contact(i,i+3,iturn4_sent_local(1,i))
7166 ! write (iout,*) "make contact list longrange",i,ii," num_cont",
7168 do j=1,num_cont_hb(i)
7171 iproc=iint_sent_local(k,jjc,ii)
7172 ! write (iout,*) "i",i," j",j," k",k," jjc",jjc," iproc",iproc
7173 if (iproc.gt.0) then
7174 ncont_sent(iproc)=ncont_sent(iproc)+1
7175 nn=ncont_sent(iproc)
7177 zapas(2,nn,iproc)=jjc
7178 zapas(3,nn,iproc)=facont_hb(j,i)
7179 zapas(4,nn,iproc)=ees0p(j,i)
7180 zapas(5,nn,iproc)=ees0m(j,i)
7181 zapas(6,nn,iproc)=gacont_hbr(1,j,i)
7182 zapas(7,nn,iproc)=gacont_hbr(2,j,i)
7183 zapas(8,nn,iproc)=gacont_hbr(3,j,i)
7184 zapas(9,nn,iproc)=gacontm_hb1(1,j,i)
7185 zapas(10,nn,iproc)=gacontm_hb1(2,j,i)
7186 zapas(11,nn,iproc)=gacontm_hb1(3,j,i)
7187 zapas(12,nn,iproc)=gacontp_hb1(1,j,i)
7188 zapas(13,nn,iproc)=gacontp_hb1(2,j,i)
7189 zapas(14,nn,iproc)=gacontp_hb1(3,j,i)
7190 zapas(15,nn,iproc)=gacontm_hb2(1,j,i)
7191 zapas(16,nn,iproc)=gacontm_hb2(2,j,i)
7192 zapas(17,nn,iproc)=gacontm_hb2(3,j,i)
7193 zapas(18,nn,iproc)=gacontp_hb2(1,j,i)
7194 zapas(19,nn,iproc)=gacontp_hb2(2,j,i)
7195 zapas(20,nn,iproc)=gacontp_hb2(3,j,i)
7196 zapas(21,nn,iproc)=gacontm_hb3(1,j,i)
7197 zapas(22,nn,iproc)=gacontm_hb3(2,j,i)
7198 zapas(23,nn,iproc)=gacontm_hb3(3,j,i)
7199 zapas(24,nn,iproc)=gacontp_hb3(1,j,i)
7200 zapas(25,nn,iproc)=gacontp_hb3(2,j,i)
7201 zapas(26,nn,iproc)=gacontp_hb3(3,j,i)
7208 "Numbers of contacts to be sent to other processors",&
7209 (ncont_sent(i),i=1,ntask_cont_to)
7210 write (iout,*) "Contacts sent"
7211 do ii=1,ntask_cont_to
7213 iproc=itask_cont_to(ii)
7214 write (iout,*) nn," contacts to processor",iproc,&
7215 " of CONT_TO_COMM group"
7217 write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
7225 CorrelID1=nfgtasks+fg_rank+1
7227 ! Receive the numbers of needed contacts from other processors
7228 do ii=1,ntask_cont_from
7229 iproc=itask_cont_from(ii)
7231 call MPI_Irecv(ncont_recv(ii),1,MPI_INTEGER,iproc,CorrelType,&
7232 FG_COMM,req(ireq),IERR)
7234 ! write (iout,*) "IRECV ended"
7236 ! Send the number of contacts needed by other processors
7237 do ii=1,ntask_cont_to
7238 iproc=itask_cont_to(ii)
7240 call MPI_Isend(ncont_sent(ii),1,MPI_INTEGER,iproc,CorrelType,&
7241 FG_COMM,req(ireq),IERR)
7243 ! write (iout,*) "ISEND ended"
7244 ! write (iout,*) "number of requests (nn)",ireq
7247 call MPI_Waitall(ireq,req,status_array,ierr)
7249 ! & "Numbers of contacts to be received from other processors",
7250 ! & (ncont_recv(i),i=1,ntask_cont_from)
7254 do ii=1,ntask_cont_from
7255 iproc=itask_cont_from(ii)
7257 ! write (iout,*) "Receiving",nn," contacts from processor",iproc,
7258 ! & " of CONT_TO_COMM group"
7262 call MPI_Irecv(zapas_recv(1,1,ii),nn*max_dim,&
7263 MPI_DOUBLE_PRECISION,iproc,CorrelType1,FG_COMM,req(ireq),IERR)
7264 ! write (iout,*) "ireq,req",ireq,req(ireq)
7267 ! Send the contacts to processors that need them
7268 do ii=1,ntask_cont_to
7269 iproc=itask_cont_to(ii)
7271 ! write (iout,*) nn," contacts to processor",iproc,
7272 ! & " of CONT_TO_COMM group"
7275 call MPI_Isend(zapas(1,1,ii),nn*max_dim,MPI_DOUBLE_PRECISION,&
7276 iproc,CorrelType1,FG_COMM,req(ireq),IERR)
7277 ! write (iout,*) "ireq,req",ireq,req(ireq)
7279 ! write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
7283 ! write (iout,*) "number of requests (contacts)",ireq
7284 ! write (iout,*) "req",(req(i),i=1,4)
7287 call MPI_Waitall(ireq,req,status_array,ierr)
7288 do iii=1,ntask_cont_from
7289 iproc=itask_cont_from(iii)
7292 write (iout,*) "Received",nn," contacts from processor",iproc,&
7293 " of CONT_FROM_COMM group"
7296 write(iout,'(2f5.0,4f10.5)')(zapas_recv(j,i,iii),j=1,5)
7301 ii=zapas_recv(1,i,iii)
7302 ! Flag the received contacts to prevent double-counting
7303 jj=-zapas_recv(2,i,iii)
7304 ! write (iout,*) "iii",iii," i",i," ii",ii," jj",jj
7306 nnn=num_cont_hb(ii)+1
7309 facont_hb(nnn,ii)=zapas_recv(3,i,iii)
7310 ees0p(nnn,ii)=zapas_recv(4,i,iii)
7311 ees0m(nnn,ii)=zapas_recv(5,i,iii)
7312 gacont_hbr(1,nnn,ii)=zapas_recv(6,i,iii)
7313 gacont_hbr(2,nnn,ii)=zapas_recv(7,i,iii)
7314 gacont_hbr(3,nnn,ii)=zapas_recv(8,i,iii)
7315 gacontm_hb1(1,nnn,ii)=zapas_recv(9,i,iii)
7316 gacontm_hb1(2,nnn,ii)=zapas_recv(10,i,iii)
7317 gacontm_hb1(3,nnn,ii)=zapas_recv(11,i,iii)
7318 gacontp_hb1(1,nnn,ii)=zapas_recv(12,i,iii)
7319 gacontp_hb1(2,nnn,ii)=zapas_recv(13,i,iii)
7320 gacontp_hb1(3,nnn,ii)=zapas_recv(14,i,iii)
7321 gacontm_hb2(1,nnn,ii)=zapas_recv(15,i,iii)
7322 gacontm_hb2(2,nnn,ii)=zapas_recv(16,i,iii)
7323 gacontm_hb2(3,nnn,ii)=zapas_recv(17,i,iii)
7324 gacontp_hb2(1,nnn,ii)=zapas_recv(18,i,iii)
7325 gacontp_hb2(2,nnn,ii)=zapas_recv(19,i,iii)
7326 gacontp_hb2(3,nnn,ii)=zapas_recv(20,i,iii)
7327 gacontm_hb3(1,nnn,ii)=zapas_recv(21,i,iii)
7328 gacontm_hb3(2,nnn,ii)=zapas_recv(22,i,iii)
7329 gacontm_hb3(3,nnn,ii)=zapas_recv(23,i,iii)
7330 gacontp_hb3(1,nnn,ii)=zapas_recv(24,i,iii)
7331 gacontp_hb3(2,nnn,ii)=zapas_recv(25,i,iii)
7332 gacontp_hb3(3,nnn,ii)=zapas_recv(26,i,iii)
7337 write (iout,'(a)') 'Contact function values after receive:'
7339 write (iout,'(2i3,50(1x,i3,f5.2))') &
7340 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
7348 write (iout,'(a)') 'Contact function values:'
7350 write (iout,'(2i3,50(1x,i3,f5.2))') &
7351 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
7357 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres))
7358 ! if (.not.allocated(gradxorr)) allocate(gradxorr(3,nres))
7359 ! Remove the loop below after debugging !!!
7366 ! Calculate the local-electrostatic correlation terms
7367 do i=min0(iatel_s,iturn4_start),max0(iatel_e,iturn3_end)
7369 num_conti=num_cont_hb(i)
7370 num_conti1=num_cont_hb(i+1)
7377 ! write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,&
7378 ! ' jj=',jj,' kk=',kk,"jp=",jp,"jp1",jp1
7379 if ((j.gt.0 .and. j1.gt.0 .or. j.gt.0 .and. j1.lt.0 &
7380 .or. j.lt.0 .and. j1.gt.0) .and. &
7381 (jp1.eq.jp+1 .or. jp1.eq.jp-1)) then
7382 ! Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
7383 ! The system gains extra energy.
7384 ecorr=ecorr+ehbcorr(i,jp,i+1,jp1,jj,kk,0.72D0,0.32D0)
7385 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
7386 'ecorrh',i,j,ehbcorr(i,jp,i+1,jp1,jj,kk,0.72D0,0.32D0)
7388 else if (j1.eq.j) then
7389 ! Contacts I-J and I-(J+1) occur simultaneously.
7390 ! The system loses extra energy.
7391 ! ecorr=ecorr+ehbcorr(i,j,i+1,j,jj,kk,0.60D0,-0.40D0)
7396 ! write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
7397 ! & ' jj=',jj,' kk=',kk
7399 ! Contacts I-J and (I+1)-J occur simultaneously.
7400 ! The system loses extra energy.
7401 ! ecorr=ecorr+ehbcorr(i,j,i,j+1,jj,kk,0.60D0,-0.40D0)
7407 end subroutine multibody_hb
7408 !-----------------------------------------------------------------------------
7409 subroutine add_hb_contact(ii,jj,itask)
7410 ! implicit real*8 (a-h,o-z)
7411 ! include "DIMENSIONS"
7412 ! include "COMMON.IOUNITS"
7413 ! include "COMMON.CONTACTS"
7414 ! integer,parameter :: maxconts=nres/4
7415 integer,parameter :: max_dim=26
7416 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
7417 ! real(kind=8) :: zapas(max_dim,maxconts,nfgtasks)
7418 ! common /przechowalnia/ zapas
7419 integer :: i,j,ii,jj,iproc,nn,jjc
7420 integer,dimension(4) :: itask
7421 ! write (iout,*) "itask",itask
7424 if (iproc.gt.0) then
7425 do j=1,num_cont_hb(ii)
7427 ! write (iout,*) "i",ii," j",jj," jjc",jjc
7429 ncont_sent(iproc)=ncont_sent(iproc)+1
7430 nn=ncont_sent(iproc)
7431 zapas(1,nn,iproc)=ii
7432 zapas(2,nn,iproc)=jjc
7433 zapas(3,nn,iproc)=facont_hb(j,ii)
7434 zapas(4,nn,iproc)=ees0p(j,ii)
7435 zapas(5,nn,iproc)=ees0m(j,ii)
7436 zapas(6,nn,iproc)=gacont_hbr(1,j,ii)
7437 zapas(7,nn,iproc)=gacont_hbr(2,j,ii)
7438 zapas(8,nn,iproc)=gacont_hbr(3,j,ii)
7439 zapas(9,nn,iproc)=gacontm_hb1(1,j,ii)
7440 zapas(10,nn,iproc)=gacontm_hb1(2,j,ii)
7441 zapas(11,nn,iproc)=gacontm_hb1(3,j,ii)
7442 zapas(12,nn,iproc)=gacontp_hb1(1,j,ii)
7443 zapas(13,nn,iproc)=gacontp_hb1(2,j,ii)
7444 zapas(14,nn,iproc)=gacontp_hb1(3,j,ii)
7445 zapas(15,nn,iproc)=gacontm_hb2(1,j,ii)
7446 zapas(16,nn,iproc)=gacontm_hb2(2,j,ii)
7447 zapas(17,nn,iproc)=gacontm_hb2(3,j,ii)
7448 zapas(18,nn,iproc)=gacontp_hb2(1,j,ii)
7449 zapas(19,nn,iproc)=gacontp_hb2(2,j,ii)
7450 zapas(20,nn,iproc)=gacontp_hb2(3,j,ii)
7451 zapas(21,nn,iproc)=gacontm_hb3(1,j,ii)
7452 zapas(22,nn,iproc)=gacontm_hb3(2,j,ii)
7453 zapas(23,nn,iproc)=gacontm_hb3(3,j,ii)
7454 zapas(24,nn,iproc)=gacontp_hb3(1,j,ii)
7455 zapas(25,nn,iproc)=gacontp_hb3(2,j,ii)
7456 zapas(26,nn,iproc)=gacontp_hb3(3,j,ii)
7463 end subroutine add_hb_contact
7464 !-----------------------------------------------------------------------------
7465 subroutine multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
7466 ! This subroutine calculates multi-body contributions to hydrogen-bonding
7467 ! implicit real*8 (a-h,o-z)
7468 ! include 'DIMENSIONS'
7469 ! include 'COMMON.IOUNITS'
7470 integer,parameter :: max_dim=70
7473 ! integer :: maxconts !max_cont=maxconts=nres/4
7474 integer :: source,CorrelType,CorrelID,CorrelType1,CorrelID1,Error
7475 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks)
7476 ! real(kind=8) :: zapas(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
7477 ! common /przechowalnia/ zapas
7478 integer :: status(MPI_STATUS_SIZE),req((nres/4)*2),&
7479 status_array(MPI_STATUS_SIZE,(nres/4)*2),jjc,iproc,ireq,nn,ind,&
7482 ! include 'COMMON.SETUP'
7483 ! include 'COMMON.FFIELD'
7484 ! include 'COMMON.DERIV'
7485 ! include 'COMMON.LOCAL'
7486 ! include 'COMMON.INTERACT'
7487 ! include 'COMMON.CONTACTS'
7488 ! include 'COMMON.CHAIN'
7489 ! include 'COMMON.CONTROL'
7490 real(kind=8),dimension(3) :: gx,gx1
7491 integer,dimension(nres) :: num_cont_hb_old
7492 logical :: lprn,ldone
7493 !EL double precision eello4,eello5,eelo6,eello_turn6
7494 !EL external eello4,eello5,eello6,eello_turn6
7496 integer :: i,ii,j,k,l,jj,kk,ll,mm,n_corr,n_corr1,num_conti,jp,&
7497 j1,jp1,i1,num_conti1
7498 real(kind=8) :: sqd1,sqd2,sred_geom,fac_prim1,fac_prim2,fprimcont
7499 real(kind=8) :: ecorr,ecorr5,ecorr6,eturn6
7501 ! Set lprn=.true. for debugging
7506 if(.not.allocated(zapas)) allocate(zapas(max_dim,maxconts,nfgtasks))
7508 num_cont_hb_old(i)=num_cont_hb(i)
7512 if (nfgtasks.le.1) goto 30
7514 write (iout,'(a)') 'Contact function values before RECEIVE:'
7516 write (iout,'(2i3,50(1x,i2,f5.2))') &
7517 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
7522 do i=1,ntask_cont_from
7525 do i=1,ntask_cont_to
7528 ! write (iout,*) "ntask_cont_from",ntask_cont_from," ntask_cont_to",
7530 ! Make the list of contacts to send to send to other procesors
7531 do i=iturn3_start,iturn3_end
7532 ! write (iout,*) "make contact list turn3",i," num_cont",
7534 call add_hb_contact_eello(i,i+2,iturn3_sent_local(1,i))
7536 do i=iturn4_start,iturn4_end
7537 ! write (iout,*) "make contact list turn4",i," num_cont",
7539 call add_hb_contact_eello(i,i+3,iturn4_sent_local(1,i))
7543 ! write (iout,*) "make contact list longrange",i,ii," num_cont",
7545 do j=1,num_cont_hb(i)
7548 iproc=iint_sent_local(k,jjc,ii)
7549 ! write (iout,*) "i",i," j",j," k",k," jjc",jjc," iproc",iproc
7550 if (iproc.ne.0) then
7551 ncont_sent(iproc)=ncont_sent(iproc)+1
7552 nn=ncont_sent(iproc)
7554 zapas(2,nn,iproc)=jjc
7555 zapas(3,nn,iproc)=d_cont(j,i)
7559 zapas(ind,nn,iproc)=grij_hb_cont(kk,j,i)
7564 zapas(ind,nn,iproc)=a_chuj(ll,kk,j,i)
7572 zapas(ind,nn,iproc)=a_chuj_der(mm,ll,kk,jj,j,i)
7583 "Numbers of contacts to be sent to other processors",&
7584 (ncont_sent(i),i=1,ntask_cont_to)
7585 write (iout,*) "Contacts sent"
7586 do ii=1,ntask_cont_to
7588 iproc=itask_cont_to(ii)
7589 write (iout,*) nn," contacts to processor",iproc,&
7590 " of CONT_TO_COMM group"
7592 write(iout,'(2f5.0,10f10.5)')(zapas(j,i,ii),j=1,10)
7600 CorrelID1=nfgtasks+fg_rank+1
7602 ! Receive the numbers of needed contacts from other processors
7603 do ii=1,ntask_cont_from
7604 iproc=itask_cont_from(ii)
7606 call MPI_Irecv(ncont_recv(ii),1,MPI_INTEGER,iproc,CorrelType,&
7607 FG_COMM,req(ireq),IERR)
7609 ! write (iout,*) "IRECV ended"
7611 ! Send the number of contacts needed by other processors
7612 do ii=1,ntask_cont_to
7613 iproc=itask_cont_to(ii)
7615 call MPI_Isend(ncont_sent(ii),1,MPI_INTEGER,iproc,CorrelType,&
7616 FG_COMM,req(ireq),IERR)
7618 ! write (iout,*) "ISEND ended"
7619 ! write (iout,*) "number of requests (nn)",ireq
7622 call MPI_Waitall(ireq,req,status_array,ierr)
7624 ! & "Numbers of contacts to be received from other processors",
7625 ! & (ncont_recv(i),i=1,ntask_cont_from)
7629 do ii=1,ntask_cont_from
7630 iproc=itask_cont_from(ii)
7632 ! write (iout,*) "Receiving",nn," contacts from processor",iproc,
7633 ! & " of CONT_TO_COMM group"
7637 call MPI_Irecv(zapas_recv(1,1,ii),nn*max_dim,&
7638 MPI_DOUBLE_PRECISION,iproc,CorrelType1,FG_COMM,req(ireq),IERR)
7639 ! write (iout,*) "ireq,req",ireq,req(ireq)
7642 ! Send the contacts to processors that need them
7643 do ii=1,ntask_cont_to
7644 iproc=itask_cont_to(ii)
7646 ! write (iout,*) nn," contacts to processor",iproc,
7647 ! & " of CONT_TO_COMM group"
7650 call MPI_Isend(zapas(1,1,ii),nn*max_dim,MPI_DOUBLE_PRECISION,&
7651 iproc,CorrelType1,FG_COMM,req(ireq),IERR)
7652 ! write (iout,*) "ireq,req",ireq,req(ireq)
7654 ! write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
7658 ! write (iout,*) "number of requests (contacts)",ireq
7659 ! write (iout,*) "req",(req(i),i=1,4)
7662 call MPI_Waitall(ireq,req,status_array,ierr)
7663 do iii=1,ntask_cont_from
7664 iproc=itask_cont_from(iii)
7667 write (iout,*) "Received",nn," contacts from processor",iproc,&
7668 " of CONT_FROM_COMM group"
7671 write(iout,'(2f5.0,10f10.5)')(zapas_recv(j,i,iii),j=1,10)
7676 ii=zapas_recv(1,i,iii)
7677 ! Flag the received contacts to prevent double-counting
7678 jj=-zapas_recv(2,i,iii)
7679 ! write (iout,*) "iii",iii," i",i," ii",ii," jj",jj
7681 nnn=num_cont_hb(ii)+1
7684 d_cont(nnn,ii)=zapas_recv(3,i,iii)
7688 grij_hb_cont(kk,nnn,ii)=zapas_recv(ind,i,iii)
7693 a_chuj(ll,kk,nnn,ii)=zapas_recv(ind,i,iii)
7701 a_chuj_der(mm,ll,kk,jj,nnn,ii)=zapas_recv(ind,i,iii)
7710 write (iout,'(a)') 'Contact function values after receive:'
7712 write (iout,'(2i3,50(1x,i3,5f6.3))') &
7713 i,num_cont_hb(i),(jcont_hb(j,i),d_cont(j,i),&
7714 ((a_chuj(ll,kk,j,i),ll=1,2),kk=1,2),j=1,num_cont_hb(i))
7721 write (iout,'(a)') 'Contact function values:'
7723 write (iout,'(2i3,50(1x,i2,5f6.3))') &
7724 i,num_cont_hb(i),(jcont_hb(j,i),d_cont(j,i),&
7725 ((a_chuj(ll,kk,j,i),ll=1,2),kk=1,2),j=1,num_cont_hb(i))
7732 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres))
7733 ! if (.not.allocated(gradxorr)) allocate(gradxorr(3,nres))
7734 ! Remove the loop below after debugging !!!
7741 ! Calculate the dipole-dipole interaction energies
7742 if (wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) then
7743 do i=iatel_s,iatel_e+1
7744 num_conti=num_cont_hb(i)
7753 ! Calculate the local-electrostatic correlation terms
7754 ! write (iout,*) "gradcorr5 in eello5 before loop"
7756 ! write (iout,'(i5,3f10.5)')
7757 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
7759 do i=min0(iatel_s,iturn4_start),max0(iatel_e+1,iturn3_end+1)
7760 ! write (iout,*) "corr loop i",i
7762 num_conti=num_cont_hb(i)
7763 num_conti1=num_cont_hb(i+1)
7770 ! write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
7771 ! & ' jj=',jj,' kk=',kk
7772 ! if (j1.eq.j+1 .or. j1.eq.j-1) then
7773 if ((j.gt.0 .and. j1.gt.0 .or. j.gt.0 .and. j1.lt.0 &
7774 .or. j.lt.0 .and. j1.gt.0) .and. &
7775 (jp1.eq.jp+1 .or. jp1.eq.jp-1)) then
7776 ! Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
7777 ! The system gains extra energy.
7779 sqd1=dsqrt(d_cont(jj,i))
7780 sqd2=dsqrt(d_cont(kk,i1))
7781 sred_geom = sqd1*sqd2
7782 IF (sred_geom.lt.cutoff_corr) THEN
7783 call gcont(sred_geom,r0_corr,1.0D0,delt_corr,&
7785 !d write (iout,*) 'i=',i,' j=',jp,' i1=',i1,' j1=',jp1,
7786 !d & ' jj=',jj,' kk=',kk
7787 fac_prim1=0.5d0*sqd2/sqd1*fprimcont
7788 fac_prim2=0.5d0*sqd1/sqd2*fprimcont
7790 g_contij(l,1)=fac_prim1*grij_hb_cont(l,jj,i)
7791 g_contij(l,2)=fac_prim2*grij_hb_cont(l,kk,i1)
7794 !d write (iout,*) 'sred_geom=',sred_geom,
7795 !d & ' ekont=',ekont,' fprim=',fprimcont,
7796 !d & ' fac_prim1',fac_prim1,' fac_prim2',fac_prim2
7797 !d write (iout,*) "g_contij",g_contij
7798 !d write (iout,*) "grij_hb_cont i",grij_hb_cont(:,jj,i)
7799 !d write (iout,*) "grij_hb_cont i1",grij_hb_cont(:,jj,i1)
7800 call calc_eello(i,jp,i+1,jp1,jj,kk)
7801 if (wcorr4.gt.0.0d0) &
7802 ecorr=ecorr+eello4(i,jp,i+1,jp1,jj,kk)
7803 if (energy_dec.and.wcorr4.gt.0.0d0) &
7804 write (iout,'(a6,4i5,0pf7.3)') &
7805 'ecorr4',i,j,i+1,j1,eello4(i,jp,i+1,jp1,jj,kk)
7806 ! write (iout,*) "gradcorr5 before eello5"
7808 ! write (iout,'(i5,3f10.5)')
7809 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
7811 if (wcorr5.gt.0.0d0) &
7812 ecorr5=ecorr5+eello5(i,jp,i+1,jp1,jj,kk)
7813 ! write (iout,*) "gradcorr5 after eello5"
7815 ! write (iout,'(i5,3f10.5)')
7816 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
7818 if (energy_dec.and.wcorr5.gt.0.0d0) &
7819 write (iout,'(a6,4i5,0pf7.3)') &
7820 'ecorr5',i,j,i+1,j1,eello5(i,jp,i+1,jp1,jj,kk)
7821 !d write(2,*)'wcorr6',wcorr6,' wturn6',wturn6
7822 !d write(2,*)'ijkl',i,jp,i+1,jp1
7823 if (wcorr6.gt.0.0d0 .and. (jp.ne.i+4 .or. jp1.ne.i+3 &
7824 .or. wturn6.eq.0.0d0))then
7825 !d write (iout,*) '******ecorr6: i,j,i+1,j1',i,j,i+1,j1
7826 ecorr6=ecorr6+eello6(i,jp,i+1,jp1,jj,kk)
7827 if (energy_dec) write (iout,'(a6,4i5,0pf7.3)') &
7828 'ecorr6',i,j,i+1,j1,eello6(i,jp,i+1,jp1,jj,kk)
7829 !d write (iout,*) 'ecorr',ecorr,' ecorr5=',ecorr5,
7830 !d & 'ecorr6=',ecorr6
7831 !d write (iout,'(4e15.5)') sred_geom,
7832 !d & dabs(eello4(i,jp,i+1,jp1,jj,kk)),
7833 !d & dabs(eello5(i,jp,i+1,jp1,jj,kk)),
7834 !d & dabs(eello6(i,jp,i+1,jp1,jj,kk))
7835 else if (wturn6.gt.0.0d0 &
7836 .and. (jp.eq.i+4 .and. jp1.eq.i+3)) then
7837 !d write (iout,*) '******eturn6: i,j,i+1,j1',i,jip,i+1,jp1
7838 eturn6=eturn6+eello_turn6(i,jj,kk)
7839 if (energy_dec) write (iout,'(a6,4i5,0pf7.3)') &
7840 'eturn6',i,j,i+1,j1,eello_turn6(i,jj,kk)
7841 !d write (2,*) 'multibody_eello:eturn6',eturn6
7850 num_cont_hb(i)=num_cont_hb_old(i)
7852 ! write (iout,*) "gradcorr5 in eello5"
7854 ! write (iout,'(i5,3f10.5)')
7855 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
7858 end subroutine multibody_eello
7859 !-----------------------------------------------------------------------------
7860 subroutine add_hb_contact_eello(ii,jj,itask)
7861 ! implicit real*8 (a-h,o-z)
7862 ! include "DIMENSIONS"
7863 ! include "COMMON.IOUNITS"
7864 ! include "COMMON.CONTACTS"
7865 ! integer,parameter :: maxconts=nres/4
7866 integer,parameter :: max_dim=70
7867 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks)
7868 ! real(kind=8) :: zapas(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
7869 ! common /przechowalnia/ zapas
7871 integer :: i,j,ii,jj,iproc,nn,ind,jjc,kk,ll,mm
7872 integer,dimension(4) ::itask
7873 ! write (iout,*) "itask",itask
7876 if (iproc.gt.0) then
7877 do j=1,num_cont_hb(ii)
7879 ! write (iout,*) "send turns i",ii," j",jj," jjc",jjc
7881 ncont_sent(iproc)=ncont_sent(iproc)+1
7882 nn=ncont_sent(iproc)
7883 zapas(1,nn,iproc)=ii
7884 zapas(2,nn,iproc)=jjc
7885 zapas(3,nn,iproc)=d_cont(j,ii)
7889 zapas(ind,nn,iproc)=grij_hb_cont(kk,j,ii)
7894 zapas(ind,nn,iproc)=a_chuj(ll,kk,j,ii)
7902 zapas(ind,nn,iproc)=a_chuj_der(mm,ll,kk,jj,j,ii)
7913 end subroutine add_hb_contact_eello
7914 !-----------------------------------------------------------------------------
7915 real(kind=8) function ehbcorr(i,j,k,l,jj,kk,coeffp,coeffm)
7916 ! implicit real*8 (a-h,o-z)
7917 ! include 'DIMENSIONS'
7918 ! include 'COMMON.IOUNITS'
7919 ! include 'COMMON.DERIV'
7920 ! include 'COMMON.INTERACT'
7921 ! include 'COMMON.CONTACTS'
7922 real(kind=8),dimension(3) :: gx,gx1
7925 integer :: i,j,k,l,jj,kk,ll,ilist,m, iresshield
7926 real(kind=8) :: coeffp,coeffm,eij,ekl,ees0pij,ees0pkl,ees0mij,&
7927 ees0mkl,ees,coeffpees0pij,coeffmees0mij,&
7928 coeffpees0pkl,coeffmees0mkl,gradlongij,gradlongkl, &
7939 ees=-(coeffp*ees0pij*ees0pkl+coeffm*ees0mij*ees0mkl)
7940 !d ees=-(coeffp*ees0pkl+coeffm*ees0mkl)
7941 ! Following 4 lines for diagnostics.
7946 ! write (iout,'(2(a,2i3,a,f10.5,a,2f10.5),a,f10.5,a,$)')
7947 ! & 'Contacts ',i,j,
7948 ! & ' eij',eij,' eesij',ees0pij,ees0mij,' and ',k,l
7949 ! & ,' fcont ',ekl,' eeskl',ees0pkl,ees0mkl,' energy=',ekont*ees,
7951 ! Calculate the multi-body contribution to energy.
7952 ! ecorr=ecorr+ekont*ees
7953 ! Calculate multi-body contributions to the gradient.
7954 coeffpees0pij=coeffp*ees0pij
7955 coeffmees0mij=coeffm*ees0mij
7956 coeffpees0pkl=coeffp*ees0pkl
7957 coeffmees0mkl=coeffm*ees0mkl
7959 !grad ghalfi=ees*ekl*gacont_hbr(ll,jj,i)
7960 gradcorr(ll,i)=gradcorr(ll,i) & !+0.5d0*ghalfi
7961 -ekont*(coeffpees0pkl*gacontp_hb1(ll,jj,i)+ &
7962 coeffmees0mkl*gacontm_hb1(ll,jj,i))
7963 gradcorr(ll,j)=gradcorr(ll,j) & !+0.5d0*ghalfi
7964 -ekont*(coeffpees0pkl*gacontp_hb2(ll,jj,i)+ &
7965 coeffmees0mkl*gacontm_hb2(ll,jj,i))
7966 !grad ghalfk=ees*eij*gacont_hbr(ll,kk,k)
7967 gradcorr(ll,k)=gradcorr(ll,k) & !+0.5d0*ghalfk
7968 -ekont*(coeffpees0pij*gacontp_hb1(ll,kk,k)+&
7969 coeffmees0mij*gacontm_hb1(ll,kk,k))
7970 gradcorr(ll,l)=gradcorr(ll,l) & !+0.5d0*ghalfk
7971 -ekont*(coeffpees0pij*gacontp_hb2(ll,kk,k)+ &
7972 coeffmees0mij*gacontm_hb2(ll,kk,k))
7973 gradlongij=ees*ekl*gacont_hbr(ll,jj,i)- &
7974 ekont*(coeffpees0pkl*gacontp_hb3(ll,jj,i)+ &
7975 coeffmees0mkl*gacontm_hb3(ll,jj,i))
7976 gradcorr_long(ll,j)=gradcorr_long(ll,j)+gradlongij
7977 gradcorr_long(ll,i)=gradcorr_long(ll,i)-gradlongij
7978 gradlongkl=ees*eij*gacont_hbr(ll,kk,k)- &
7979 ekont*(coeffpees0pij*gacontp_hb3(ll,kk,k)+ &
7980 coeffmees0mij*gacontm_hb3(ll,kk,k))
7981 gradcorr_long(ll,l)=gradcorr_long(ll,l)+gradlongkl
7982 gradcorr_long(ll,k)=gradcorr_long(ll,k)-gradlongkl
7983 ! write (iout,'(2f10.5,2x,$)') gradlongij,gradlongkl
7988 !grad gradcorr(ll,m)=gradcorr(ll,m)+
7989 !grad & ees*ekl*gacont_hbr(ll,jj,i)-
7990 !grad & ekont*(coeffp*ees0pkl*gacontp_hb3(ll,jj,i)+
7991 !grad & coeffm*ees0mkl*gacontm_hb3(ll,jj,i))
7996 !grad gradcorr(ll,m)=gradcorr(ll,m)+
7997 !grad & ees*eij*gacont_hbr(ll,kk,k)-
7998 !grad & ekont*(coeffp*ees0pij*gacontp_hb3(ll,kk,k)+
7999 !grad & coeffm*ees0mij*gacontm_hb3(ll,kk,k))
8002 ! write (iout,*) "ehbcorr",ekont*ees
8004 if (shield_mode.gt.0) then
8007 !C print *,i,j,fac_shield(i),fac_shield(j),
8008 !C &fac_shield(k),fac_shield(l)
8009 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
8010 (fac_shield(k).gt.0).and.(fac_shield(l).gt.0)) then
8011 do ilist=1,ishield_list(i)
8012 iresshield=shield_list(ilist,i)
8014 rlocshield=grad_shield_side(m,ilist,i)*ehbcorr/fac_shield(i)
8015 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+ &
8017 +grad_shield_loc(m,ilist,i)*ehbcorr/fac_shield(i)
8018 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1) &
8022 do ilist=1,ishield_list(j)
8023 iresshield=shield_list(ilist,j)
8025 rlocshield=grad_shield_side(m,ilist,j)*ehbcorr/fac_shield(j)
8026 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+ &
8028 +grad_shield_loc(m,ilist,j)*ehbcorr/fac_shield(j)
8029 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1) &
8034 do ilist=1,ishield_list(k)
8035 iresshield=shield_list(ilist,k)
8037 rlocshield=grad_shield_side(m,ilist,k)*ehbcorr/fac_shield(k)
8038 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+ &
8040 +grad_shield_loc(m,ilist,k)*ehbcorr/fac_shield(k)
8041 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1) &
8045 do ilist=1,ishield_list(l)
8046 iresshield=shield_list(ilist,l)
8048 rlocshield=grad_shield_side(m,ilist,l)*ehbcorr/fac_shield(l)
8049 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+ &
8051 +grad_shield_loc(m,ilist,l)*ehbcorr/fac_shield(l)
8052 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1) &
8057 gshieldc_ec(m,i)=gshieldc_ec(m,i)+ &
8058 grad_shield(m,i)*ehbcorr/fac_shield(i)
8059 gshieldc_ec(m,j)=gshieldc_ec(m,j)+ &
8060 grad_shield(m,j)*ehbcorr/fac_shield(j)
8061 gshieldc_ec(m,i-1)=gshieldc_ec(m,i-1)+ &
8062 grad_shield(m,i)*ehbcorr/fac_shield(i)
8063 gshieldc_ec(m,j-1)=gshieldc_ec(m,j-1)+ &
8064 grad_shield(m,j)*ehbcorr/fac_shield(j)
8066 gshieldc_ec(m,k)=gshieldc_ec(m,k)+ &
8067 grad_shield(m,k)*ehbcorr/fac_shield(k)
8068 gshieldc_ec(m,l)=gshieldc_ec(m,l)+ &
8069 grad_shield(m,l)*ehbcorr/fac_shield(l)
8070 gshieldc_ec(m,k-1)=gshieldc_ec(m,k-1)+ &
8071 grad_shield(m,k)*ehbcorr/fac_shield(k)
8072 gshieldc_ec(m,l-1)=gshieldc_ec(m,l-1)+ &
8073 grad_shield(m,l)*ehbcorr/fac_shield(l)
8079 end function ehbcorr
8081 !-----------------------------------------------------------------------------
8082 subroutine dipole(i,j,jj)
8083 ! implicit real*8 (a-h,o-z)
8084 ! include 'DIMENSIONS'
8085 ! include 'COMMON.IOUNITS'
8086 ! include 'COMMON.CHAIN'
8087 ! include 'COMMON.FFIELD'
8088 ! include 'COMMON.DERIV'
8089 ! include 'COMMON.INTERACT'
8090 ! include 'COMMON.CONTACTS'
8091 ! include 'COMMON.TORSION'
8092 ! include 'COMMON.VAR'
8093 ! include 'COMMON.GEO'
8094 real(kind=8),dimension(2,2) :: dipi,dipj,auxmat
8095 real(kind=8),dimension(2) :: dipderi,dipderj,auxvec
8096 integer :: i,j,jj,iii,jjj,kkk,lll,iti1,itj1
8098 allocate(dip(4,maxconts,nres),dipderg(4,maxconts,nres))
8099 allocate(dipderx(3,5,4,maxconts,nres))
8102 iti1 = itortyp(itype(i+1,1))
8103 if (j.lt.nres-1) then
8104 itj1 = itortyp(itype(j+1,1))
8109 dipi(iii,1)=Ub2(iii,i)
8110 dipderi(iii)=Ub2der(iii,i)
8111 dipi(iii,2)=b1(iii,iti1)
8112 dipj(iii,1)=Ub2(iii,j)
8113 dipderj(iii)=Ub2der(iii,j)
8114 dipj(iii,2)=b1(iii,itj1)
8118 call matvec2(a_chuj(1,1,jj,i),dipj(1,iii),auxvec(1))
8121 dip(kkk,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
8128 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),dipj(1,iii),&
8132 dipderx(lll,kkk,mmm,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
8137 call transpose2(a_chuj(1,1,jj,i),auxmat(1,1))
8138 call matvec2(auxmat(1,1),dipderi(1),auxvec(1))
8140 dipderg(iii,jj,i)=scalar2(auxvec(1),dipj(1,iii))
8142 call matvec2(a_chuj(1,1,jj,i),dipderj(1),auxvec(1))
8144 dipderg(iii+2,jj,i)=scalar2(auxvec(1),dipi(1,iii))
8147 end subroutine dipole
8149 !-----------------------------------------------------------------------------
8150 subroutine calc_eello(i,j,k,l,jj,kk)
8152 ! This subroutine computes matrices and vectors needed to calculate
8153 ! the fourth-, fifth-, and sixth-order local-electrostatic terms.
8156 ! implicit real*8 (a-h,o-z)
8157 ! include 'DIMENSIONS'
8158 ! include 'COMMON.IOUNITS'
8159 ! include 'COMMON.CHAIN'
8160 ! include 'COMMON.DERIV'
8161 ! include 'COMMON.INTERACT'
8162 ! include 'COMMON.CONTACTS'
8163 ! include 'COMMON.TORSION'
8164 ! include 'COMMON.VAR'
8165 ! include 'COMMON.GEO'
8166 ! include 'COMMON.FFIELD'
8167 real(kind=8),dimension(2,2) :: aa1,aa2,aa1t,aa2t,auxmat
8168 real(kind=8),dimension(2,2,3,5) :: aa1tder,aa2tder
8169 integer :: i,j,k,l,jj,kk,iii,jjj,kkk,lll,iti,itk1,itj,itl,itl1,&
8172 !el common /kutas/ lprn
8173 !d write (iout,*) 'calc_eello: i=',i,' j=',j,' k=',k,' l=',l,
8174 !d & ' jj=',jj,' kk=',kk
8175 !d if (i.ne.2 .or. j.ne.4 .or. k.ne.3 .or. l.ne.5) return
8176 !d write (iout,*) "a_chujij",((a_chuj(iii,jjj,jj,i),iii=1,2),jjj=1,2)
8177 !d write (iout,*) "a_chujkl",((a_chuj(iii,jjj,kk,k),iii=1,2),jjj=1,2)
8180 aa1(iii,jjj)=a_chuj(iii,jjj,jj,i)
8181 aa2(iii,jjj)=a_chuj(iii,jjj,kk,k)
8184 call transpose2(aa1(1,1),aa1t(1,1))
8185 call transpose2(aa2(1,1),aa2t(1,1))
8188 call transpose2(a_chuj_der(1,1,lll,kkk,jj,i),&
8189 aa1tder(1,1,lll,kkk))
8190 call transpose2(a_chuj_der(1,1,lll,kkk,kk,k),&
8191 aa2tder(1,1,lll,kkk))
8195 ! parallel orientation of the two CA-CA-CA frames.
8197 iti=itortyp(itype(i,1))
8201 itk1=itortyp(itype(k+1,1))
8202 itj=itortyp(itype(j,1))
8203 if (l.lt.nres-1) then
8204 itl1=itortyp(itype(l+1,1))
8208 ! A1 kernel(j+1) A2T
8210 !d write (iout,'(3f10.5,5x,3f10.5)')
8211 !d & (EUg(iii,jjj,k),jjj=1,2),(EUg(iii,jjj,l),jjj=1,2)
8213 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8214 aa2tder(1,1,1,1),1,.false.,EUg(1,1,l),EUgder(1,1,l),&
8215 AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
8216 ! Following matrices are needed only for 6-th order cumulants
8217 IF (wcorr6.gt.0.0d0) THEN
8218 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8219 aa2tder(1,1,1,1),1,.false.,EUgC(1,1,l),EUgCder(1,1,l),&
8220 AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
8221 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8222 aa2tder(1,1,1,1),2,.false.,Ug2DtEUg(1,1,l),&
8223 Ug2DtEUgder(1,1,1,l),ADtEA(1,1,1),ADtEAderg(1,1,1,1),&
8224 ADtEAderx(1,1,1,1,1,1))
8226 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8227 aa2tder(1,1,1,1),2,.false.,DtUg2EUg(1,1,l),&
8228 DtUg2EUgder(1,1,1,l),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),&
8229 ADtEA1derx(1,1,1,1,1,1))
8231 ! End 6-th order cumulants
8234 !d write (2,*) 'In calc_eello6'
8236 !d write (2,*) 'iii=',iii
8238 !d write (2,*) 'kkk=',kkk
8240 !d write (2,'(3(2f10.5),5x)')
8241 !d & ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
8246 call transpose2(EUgder(1,1,k),auxmat(1,1))
8247 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
8248 call transpose2(EUg(1,1,k),auxmat(1,1))
8249 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
8250 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
8254 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),&
8255 EAEAderx(1,1,lll,kkk,iii,1))
8259 ! A1T kernel(i+1) A2
8260 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
8261 a_chuj_der(1,1,1,1,kk,k),1,.false.,EUg(1,1,k),EUgder(1,1,k),&
8262 AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
8263 ! Following matrices are needed only for 6-th order cumulants
8264 IF (wcorr6.gt.0.0d0) THEN
8265 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
8266 a_chuj_der(1,1,1,1,kk,k),1,.false.,EUgC(1,1,k),EUgCder(1,1,k),&
8267 AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
8268 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
8269 a_chuj_der(1,1,1,1,kk,k),2,.false.,Ug2DtEUg(1,1,k),&
8270 Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),&
8271 ADtEAderx(1,1,1,1,1,2))
8272 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
8273 a_chuj_der(1,1,1,1,kk,k),2,.false.,DtUg2EUg(1,1,k),&
8274 DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),&
8275 ADtEA1derx(1,1,1,1,1,2))
8277 ! End 6-th order cumulants
8278 call transpose2(EUgder(1,1,l),auxmat(1,1))
8279 call matmat2(auxmat(1,1),AEA(1,1,2),EAEAderg(1,1,1,2))
8280 call transpose2(EUg(1,1,l),auxmat(1,1))
8281 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
8282 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
8286 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
8287 EAEAderx(1,1,lll,kkk,iii,2))
8292 ! Calculate the vectors and their derivatives in virtual-bond dihedral angles.
8293 ! They are needed only when the fifth- or the sixth-order cumulants are
8295 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) THEN
8296 call transpose2(AEA(1,1,1),auxmat(1,1))
8297 call matvec2(auxmat(1,1),b1(1,iti),AEAb1(1,1,1))
8298 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
8299 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
8300 call transpose2(AEAderg(1,1,1),auxmat(1,1))
8301 call matvec2(auxmat(1,1),b1(1,iti),AEAb1derg(1,1,1))
8302 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
8303 call matvec2(AEA(1,1,1),b1(1,itk1),AEAb1(1,2,1))
8304 call matvec2(AEAderg(1,1,1),b1(1,itk1),AEAb1derg(1,2,1))
8305 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
8306 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
8307 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
8308 call transpose2(AEA(1,1,2),auxmat(1,1))
8309 call matvec2(auxmat(1,1),b1(1,itj),AEAb1(1,1,2))
8310 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2(1,1,2))
8311 call matvec2(auxmat(1,1),Ub2der(1,j),AEAb2derg(1,2,1,2))
8312 call transpose2(AEAderg(1,1,2),auxmat(1,1))
8313 call matvec2(auxmat(1,1),b1(1,itj),AEAb1derg(1,1,2))
8314 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2derg(1,1,1,2))
8315 call matvec2(AEA(1,1,2),b1(1,itl1),AEAb1(1,2,2))
8316 call matvec2(AEAderg(1,1,2),b1(1,itl1),AEAb1derg(1,2,2))
8317 call matvec2(AEA(1,1,2),Ub2(1,l+1),AEAb2(1,2,2))
8318 call matvec2(AEAderg(1,1,2),Ub2(1,l+1),AEAb2derg(1,1,2,2))
8319 call matvec2(AEA(1,1,2),Ub2der(1,l+1),AEAb2derg(1,2,2,2))
8320 ! Calculate the Cartesian derivatives of the vectors.
8324 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
8325 call matvec2(auxmat(1,1),b1(1,iti),&
8326 AEAb1derx(1,lll,kkk,iii,1,1))
8327 call matvec2(auxmat(1,1),Ub2(1,i),&
8328 AEAb2derx(1,lll,kkk,iii,1,1))
8329 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,itk1),&
8330 AEAb1derx(1,lll,kkk,iii,2,1))
8331 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),&
8332 AEAb2derx(1,lll,kkk,iii,2,1))
8333 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
8334 call matvec2(auxmat(1,1),b1(1,itj),&
8335 AEAb1derx(1,lll,kkk,iii,1,2))
8336 call matvec2(auxmat(1,1),Ub2(1,j),&
8337 AEAb2derx(1,lll,kkk,iii,1,2))
8338 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,itl1),&
8339 AEAb1derx(1,lll,kkk,iii,2,2))
8340 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,l+1),&
8341 AEAb2derx(1,lll,kkk,iii,2,2))
8348 ! Antiparallel orientation of the two CA-CA-CA frames.
8350 iti=itortyp(itype(i,1))
8354 itk1=itortyp(itype(k+1,1))
8355 itl=itortyp(itype(l,1))
8356 itj=itortyp(itype(j,1))
8357 if (j.lt.nres-1) then
8358 itj1=itortyp(itype(j+1,1))
8362 ! A2 kernel(j-1)T A1T
8363 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8364 aa2tder(1,1,1,1),1,.true.,EUg(1,1,j),EUgder(1,1,j),&
8365 AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
8366 ! Following matrices are needed only for 6-th order cumulants
8367 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and. &
8368 j.eq.i+4 .and. l.eq.i+3)) THEN
8369 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8370 aa2tder(1,1,1,1),1,.true.,EUgC(1,1,j),EUgCder(1,1,j),&
8371 AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
8372 call kernel(aa2(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8373 aa2tder(1,1,1,1),2,.true.,Ug2DtEUg(1,1,j),&
8374 Ug2DtEUgder(1,1,1,j),ADtEA(1,1,1),ADtEAderg(1,1,1,1),&
8375 ADtEAderx(1,1,1,1,1,1))
8376 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
8377 aa2tder(1,1,1,1),2,.true.,DtUg2EUg(1,1,j),&
8378 DtUg2EUgder(1,1,1,j),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),&
8379 ADtEA1derx(1,1,1,1,1,1))
8381 ! End 6-th order cumulants
8382 call transpose2(EUgder(1,1,k),auxmat(1,1))
8383 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
8384 call transpose2(EUg(1,1,k),auxmat(1,1))
8385 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
8386 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
8390 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),&
8391 EAEAderx(1,1,lll,kkk,iii,1))
8395 ! A2T kernel(i+1)T A1
8396 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
8397 a_chuj_der(1,1,1,1,jj,i),1,.true.,EUg(1,1,k),EUgder(1,1,k),&
8398 AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
8399 ! Following matrices are needed only for 6-th order cumulants
8400 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and. &
8401 j.eq.i+4 .and. l.eq.i+3)) THEN
8402 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
8403 a_chuj_der(1,1,1,1,jj,i),1,.true.,EUgC(1,1,k),EUgCder(1,1,k),&
8404 AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
8405 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
8406 a_chuj_der(1,1,1,1,jj,i),2,.true.,Ug2DtEUg(1,1,k),&
8407 Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),&
8408 ADtEAderx(1,1,1,1,1,2))
8409 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
8410 a_chuj_der(1,1,1,1,jj,i),2,.true.,DtUg2EUg(1,1,k),&
8411 DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),&
8412 ADtEA1derx(1,1,1,1,1,2))
8414 ! End 6-th order cumulants
8415 call transpose2(EUgder(1,1,j),auxmat(1,1))
8416 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,2,2))
8417 call transpose2(EUg(1,1,j),auxmat(1,1))
8418 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
8419 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
8423 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
8424 EAEAderx(1,1,lll,kkk,iii,2))
8429 ! Calculate the vectors and their derivatives in virtual-bond dihedral angles.
8430 ! They are needed only when the fifth- or the sixth-order cumulants are
8432 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 .or. &
8433 (wturn6.gt.0.0d0 .and. j.eq.i+4 .and. l.eq.i+3)) THEN
8434 call transpose2(AEA(1,1,1),auxmat(1,1))
8435 call matvec2(auxmat(1,1),b1(1,iti),AEAb1(1,1,1))
8436 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
8437 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
8438 call transpose2(AEAderg(1,1,1),auxmat(1,1))
8439 call matvec2(auxmat(1,1),b1(1,iti),AEAb1derg(1,1,1))
8440 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
8441 call matvec2(AEA(1,1,1),b1(1,itk1),AEAb1(1,2,1))
8442 call matvec2(AEAderg(1,1,1),b1(1,itk1),AEAb1derg(1,2,1))
8443 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
8444 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
8445 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
8446 call transpose2(AEA(1,1,2),auxmat(1,1))
8447 call matvec2(auxmat(1,1),b1(1,itj1),AEAb1(1,1,2))
8448 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2(1,1,2))
8449 call matvec2(auxmat(1,1),Ub2der(1,l),AEAb2derg(1,2,1,2))
8450 call transpose2(AEAderg(1,1,2),auxmat(1,1))
8451 call matvec2(auxmat(1,1),b1(1,itl),AEAb1(1,1,2))
8452 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2derg(1,1,1,2))
8453 call matvec2(AEA(1,1,2),b1(1,itj1),AEAb1(1,2,2))
8454 call matvec2(AEAderg(1,1,2),b1(1,itj1),AEAb1derg(1,2,2))
8455 call matvec2(AEA(1,1,2),Ub2(1,j),AEAb2(1,2,2))
8456 call matvec2(AEAderg(1,1,2),Ub2(1,j),AEAb2derg(1,1,2,2))
8457 call matvec2(AEA(1,1,2),Ub2der(1,j),AEAb2derg(1,2,2,2))
8458 ! Calculate the Cartesian derivatives of the vectors.
8462 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
8463 call matvec2(auxmat(1,1),b1(1,iti),&
8464 AEAb1derx(1,lll,kkk,iii,1,1))
8465 call matvec2(auxmat(1,1),Ub2(1,i),&
8466 AEAb2derx(1,lll,kkk,iii,1,1))
8467 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,itk1),&
8468 AEAb1derx(1,lll,kkk,iii,2,1))
8469 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),&
8470 AEAb2derx(1,lll,kkk,iii,2,1))
8471 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
8472 call matvec2(auxmat(1,1),b1(1,itl),&
8473 AEAb1derx(1,lll,kkk,iii,1,2))
8474 call matvec2(auxmat(1,1),Ub2(1,l),&
8475 AEAb2derx(1,lll,kkk,iii,1,2))
8476 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,itj1),&
8477 AEAb1derx(1,lll,kkk,iii,2,2))
8478 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,j),&
8479 AEAb2derx(1,lll,kkk,iii,2,2))
8487 end subroutine calc_eello
8488 !-----------------------------------------------------------------------------
8489 subroutine kernel(aa1,aa2t,aa1derx,aa2tderx,nderg,transp,KK,KKderg,AKA,AKAderg,AKAderx)
8494 real(kind=8),dimension(2,2) :: aa1,aa2t,KK,AKA
8495 real(kind=8),dimension(2,2,3,5) :: aa1derx,aa2tderx
8496 real(kind=8),dimension(2,2,3,5,2) :: AKAderx
8497 real(kind=8),dimension(2,2,nderg) :: KKderg,AKAderg
8498 integer :: iii,kkk,lll
8501 !el common /kutas/ lprn
8502 call prodmat3(aa1(1,1),aa2t(1,1),KK(1,1),transp,AKA(1,1))
8504 call prodmat3(aa1(1,1),aa2t(1,1),KKderg(1,1,iii),transp,&
8507 !d if (lprn) write (2,*) 'In kernel'
8509 !d if (lprn) write (2,*) 'kkk=',kkk
8511 call prodmat3(aa1derx(1,1,lll,kkk),aa2t(1,1),&
8512 KK(1,1),transp,AKAderx(1,1,lll,kkk,1))
8514 !d write (2,*) 'lll=',lll
8515 !d write (2,*) 'iii=1'
8517 !d write (2,'(3(2f10.5),5x)')
8518 !d & (AKAderx(jjj,mmm,lll,kkk,1),mmm=1,2)
8521 call prodmat3(aa1(1,1),aa2tderx(1,1,lll,kkk),&
8522 KK(1,1),transp,AKAderx(1,1,lll,kkk,2))
8524 !d write (2,*) 'lll=',lll
8525 !d write (2,*) 'iii=2'
8527 !d write (2,'(3(2f10.5),5x)')
8528 !d & (AKAderx(jjj,mmm,lll,kkk,2),mmm=1,2)
8534 end subroutine kernel
8535 !-----------------------------------------------------------------------------
8536 real(kind=8) function eello4(i,j,k,l,jj,kk)
8537 ! implicit real*8 (a-h,o-z)
8538 ! include 'DIMENSIONS'
8539 ! include 'COMMON.IOUNITS'
8540 ! include 'COMMON.CHAIN'
8541 ! include 'COMMON.DERIV'
8542 ! include 'COMMON.INTERACT'
8543 ! include 'COMMON.CONTACTS'
8544 ! include 'COMMON.TORSION'
8545 ! include 'COMMON.VAR'
8546 ! include 'COMMON.GEO'
8547 real(kind=8),dimension(2,2) :: pizda
8548 real(kind=8),dimension(3) :: ggg1,ggg2
8549 real(kind=8) :: eel4,glongij,glongkl
8550 integer :: i,j,k,l,jj,kk,iii,kkk,lll,j1,j2,l1,l2,ll
8551 !d if (i.ne.1 .or. j.ne.5 .or. k.ne.2 .or.l.ne.4) then
8555 !d print *,'eello4:',i,j,k,l,jj,kk
8556 !d write (2,*) 'i',i,' j',j,' k',k,' l',l
8557 !d call checkint4(i,j,k,l,jj,kk,eel4_num)
8558 !old eij=facont_hb(jj,i)
8559 !old ekl=facont_hb(kk,k)
8561 eel4=-EAEA(1,1,1)-EAEA(2,2,1)
8562 !d eel41=-EAEA(1,1,2)-EAEA(2,2,2)
8563 gcorr_loc(k-1)=gcorr_loc(k-1) &
8564 -ekont*(EAEAderg(1,1,1,1)+EAEAderg(2,2,1,1))
8566 gcorr_loc(l-1)=gcorr_loc(l-1) &
8567 -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
8569 gcorr_loc(j-1)=gcorr_loc(j-1) &
8570 -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
8575 derx(lll,kkk,iii)=-EAEAderx(1,1,lll,kkk,iii,1) &
8576 -EAEAderx(2,2,lll,kkk,iii,1)
8577 !d derx(lll,kkk,iii)=0.0d0
8581 !d gcorr_loc(l-1)=0.0d0
8582 !d gcorr_loc(j-1)=0.0d0
8583 !d gcorr_loc(k-1)=0.0d0
8585 !d write (iout,*)'Contacts have occurred for peptide groups',
8586 !d & i,j,' fcont:',eij,' eij',' and ',k,l,
8587 !d & ' fcont ',ekl,' eel4=',eel4,' eel4_num',16*eel4_num
8588 if (j.lt.nres-1) then
8595 if (l.lt.nres-1) then
8603 !grad ggg1(ll)=eel4*g_contij(ll,1)
8604 !grad ggg2(ll)=eel4*g_contij(ll,2)
8605 glongij=eel4*g_contij(ll,1)+ekont*derx(ll,1,1)
8606 glongkl=eel4*g_contij(ll,2)+ekont*derx(ll,1,2)
8607 !grad ghalf=0.5d0*ggg1(ll)
8608 gradcorr(ll,i)=gradcorr(ll,i)+ekont*derx(ll,2,1)
8609 gradcorr(ll,i+1)=gradcorr(ll,i+1)+ekont*derx(ll,3,1)
8610 gradcorr(ll,j)=gradcorr(ll,j)+ekont*derx(ll,4,1)
8611 gradcorr(ll,j1)=gradcorr(ll,j1)+ekont*derx(ll,5,1)
8612 gradcorr_long(ll,j)=gradcorr_long(ll,j)+glongij
8613 gradcorr_long(ll,i)=gradcorr_long(ll,i)-glongij
8614 !grad ghalf=0.5d0*ggg2(ll)
8615 gradcorr(ll,k)=gradcorr(ll,k)+ekont*derx(ll,2,2)
8616 gradcorr(ll,k+1)=gradcorr(ll,k+1)+ekont*derx(ll,3,2)
8617 gradcorr(ll,l)=gradcorr(ll,l)+ekont*derx(ll,4,2)
8618 gradcorr(ll,l1)=gradcorr(ll,l1)+ekont*derx(ll,5,2)
8619 gradcorr_long(ll,l)=gradcorr_long(ll,l)+glongkl
8620 gradcorr_long(ll,k)=gradcorr_long(ll,k)-glongkl
8624 !grad gradcorr(ll,m)=gradcorr(ll,m)+ggg1(ll)
8629 !grad gradcorr(ll,m)=gradcorr(ll,m)+ggg2(ll)
8634 !grad gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,1)
8639 !grad gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,2)
8643 !d write (2,*) iii,gcorr_loc(iii)
8646 !d write (2,*) 'ekont',ekont
8647 !d write (iout,*) 'eello4',ekont*eel4
8650 !-----------------------------------------------------------------------------
8651 real(kind=8) function eello5(i,j,k,l,jj,kk)
8652 ! implicit real*8 (a-h,o-z)
8653 ! include 'DIMENSIONS'
8654 ! include 'COMMON.IOUNITS'
8655 ! include 'COMMON.CHAIN'
8656 ! include 'COMMON.DERIV'
8657 ! include 'COMMON.INTERACT'
8658 ! include 'COMMON.CONTACTS'
8659 ! include 'COMMON.TORSION'
8660 ! include 'COMMON.VAR'
8661 ! include 'COMMON.GEO'
8662 real(kind=8),dimension(2,2) :: pizda,auxmat,auxmat1
8663 real(kind=8),dimension(2) :: vv
8664 real(kind=8),dimension(3) :: ggg1,ggg2
8665 real(kind=8) :: eello5_1,eello5_2,eello5_3,eello5_4,eel5
8666 real(kind=8) :: gradcorr5ij,gradcorr5kl,ghalf
8667 integer :: i,j,k,l,jj,kk,itk,itl,itj,iii,kkk,lll,j1,j2,l1,l2,ll
8668 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8673 ! /l\ / \ \ / \ / \ / C
8674 ! / \ / \ \ / \ / \ / C
8675 ! j| o |l1 | o | o| o | | o |o C
8676 ! \ |/k\| |/ \| / |/ \| |/ \| C
8677 ! \i/ \ / \ / / \ / \ C
8679 ! (I) (II) (III) (IV) C
8681 ! eello5_1 eello5_2 eello5_3 eello5_4 C
8683 ! Antiparallel chains C
8686 ! /j\ / \ \ / \ / \ / C
8687 ! / \ / \ \ / \ / \ / C
8688 ! j1| o |l | o | o| o | | o |o C
8689 ! \ |/k\| |/ \| / |/ \| |/ \| C
8690 ! \i/ \ / \ / / \ / \ C
8692 ! (I) (II) (III) (IV) C
8694 ! eello5_1 eello5_2 eello5_3 eello5_4 C
8696 ! o denotes a local interaction, vertical lines an electrostatic interaction. C
8698 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
8699 !d if (i.ne.2 .or. j.ne.6 .or. k.ne.3 .or. l.ne.5) then
8704 !d & 'EELLO5: Contacts have occurred for peptide groups',i,j,
8706 itk=itortyp(itype(k,1))
8707 itl=itortyp(itype(l,1))
8708 itj=itortyp(itype(j,1))
8713 !d call checkint5(i,j,k,l,jj,kk,eel5_1_num,eel5_2_num,
8714 !d & eel5_3_num,eel5_4_num)
8718 derx(lll,kkk,iii)=0.0d0
8722 !d eij=facont_hb(jj,i)
8723 !d ekl=facont_hb(kk,k)
8725 !d write (iout,*)'Contacts have occurred for peptide groups',
8726 !d & i,j,' fcont:',eij,' eij',' and ',k,l
8728 ! Contribution from the graph I.
8729 !d write (2,*) 'AEA ',AEA(1,1,1),AEA(2,1,1),AEA(1,2,1),AEA(2,2,1)
8730 !d write (2,*) 'AEAb2',AEAb2(1,1,1),AEAb2(2,1,1)
8731 call transpose2(EUg(1,1,k),auxmat(1,1))
8732 call matmat2(AEA(1,1,1),auxmat(1,1),pizda(1,1))
8733 vv(1)=pizda(1,1)-pizda(2,2)
8734 vv(2)=pizda(1,2)+pizda(2,1)
8735 eello5_1=scalar2(AEAb2(1,1,1),Ub2(1,k)) &
8736 +0.5d0*scalar2(vv(1),Dtobr2(1,i))
8737 ! Explicit gradient in virtual-dihedral angles.
8738 if (i.gt.1) g_corr5_loc(i-1)=g_corr5_loc(i-1) &
8739 +ekont*(scalar2(AEAb2derg(1,2,1,1),Ub2(1,k)) &
8740 +0.5d0*scalar2(vv(1),Dtobr2der(1,i)))
8741 call transpose2(EUgder(1,1,k),auxmat1(1,1))
8742 call matmat2(AEA(1,1,1),auxmat1(1,1),pizda(1,1))
8743 vv(1)=pizda(1,1)-pizda(2,2)
8744 vv(2)=pizda(1,2)+pizda(2,1)
8745 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
8746 +ekont*(scalar2(AEAb2(1,1,1),Ub2der(1,k)) &
8747 +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
8748 call matmat2(AEAderg(1,1,1),auxmat(1,1),pizda(1,1))
8749 vv(1)=pizda(1,1)-pizda(2,2)
8750 vv(2)=pizda(1,2)+pizda(2,1)
8752 if (l.lt.nres-1) g_corr5_loc(l-1)=g_corr5_loc(l-1) &
8753 +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k)) &
8754 +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
8756 if (j.lt.nres-1) g_corr5_loc(j-1)=g_corr5_loc(j-1) &
8757 +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k)) &
8758 +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
8760 ! Cartesian gradient
8764 call matmat2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1),&
8766 vv(1)=pizda(1,1)-pizda(2,2)
8767 vv(2)=pizda(1,2)+pizda(2,1)
8768 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
8769 +scalar2(AEAb2derx(1,lll,kkk,iii,1,1),Ub2(1,k)) &
8770 +0.5d0*scalar2(vv(1),Dtobr2(1,i))
8776 ! Contribution from graph II
8777 call transpose2(EE(1,1,itk),auxmat(1,1))
8778 call matmat2(auxmat(1,1),AEA(1,1,1),pizda(1,1))
8779 vv(1)=pizda(1,1)+pizda(2,2)
8780 vv(2)=pizda(2,1)-pizda(1,2)
8781 eello5_2=scalar2(AEAb1(1,2,1),b1(1,itk)) &
8782 -0.5d0*scalar2(vv(1),Ctobr(1,k))
8783 ! Explicit gradient in virtual-dihedral angles.
8784 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
8785 -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,k))
8786 call matmat2(auxmat(1,1),AEAderg(1,1,1),pizda(1,1))
8787 vv(1)=pizda(1,1)+pizda(2,2)
8788 vv(2)=pizda(2,1)-pizda(1,2)
8790 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
8791 +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,itk)) &
8792 -0.5d0*scalar2(vv(1),Ctobr(1,k)))
8794 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
8795 +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,itk)) &
8796 -0.5d0*scalar2(vv(1),Ctobr(1,k)))
8798 ! Cartesian gradient
8802 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),&
8804 vv(1)=pizda(1,1)+pizda(2,2)
8805 vv(2)=pizda(2,1)-pizda(1,2)
8806 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
8807 +scalar2(AEAb1derx(1,lll,kkk,iii,2,1),b1(1,itk)) &
8808 -0.5d0*scalar2(vv(1),Ctobr(1,k))
8816 ! Parallel orientation
8817 ! Contribution from graph III
8818 call transpose2(EUg(1,1,l),auxmat(1,1))
8819 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
8820 vv(1)=pizda(1,1)-pizda(2,2)
8821 vv(2)=pizda(1,2)+pizda(2,1)
8822 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,l)) &
8823 +0.5d0*scalar2(vv(1),Dtobr2(1,j))
8824 ! Explicit gradient in virtual-dihedral angles.
8825 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
8826 +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,l)) &
8827 +0.5d0*scalar2(vv(1),Dtobr2der(1,j)))
8828 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
8829 vv(1)=pizda(1,1)-pizda(2,2)
8830 vv(2)=pizda(1,2)+pizda(2,1)
8831 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
8832 +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,l)) &
8833 +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
8834 call transpose2(EUgder(1,1,l),auxmat1(1,1))
8835 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
8836 vv(1)=pizda(1,1)-pizda(2,2)
8837 vv(2)=pizda(1,2)+pizda(2,1)
8838 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
8839 +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,l)) &
8840 +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
8841 ! Cartesian gradient
8845 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),&
8847 vv(1)=pizda(1,1)-pizda(2,2)
8848 vv(2)=pizda(1,2)+pizda(2,1)
8849 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
8850 +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,l)) &
8851 +0.5d0*scalar2(vv(1),Dtobr2(1,j))
8856 ! Contribution from graph IV
8858 call transpose2(EE(1,1,itl),auxmat(1,1))
8859 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
8860 vv(1)=pizda(1,1)+pizda(2,2)
8861 vv(2)=pizda(2,1)-pizda(1,2)
8862 eello5_4=scalar2(AEAb1(1,2,2),b1(1,itl)) &
8863 -0.5d0*scalar2(vv(1),Ctobr(1,l))
8864 ! Explicit gradient in virtual-dihedral angles.
8865 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
8866 -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,l))
8867 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
8868 vv(1)=pizda(1,1)+pizda(2,2)
8869 vv(2)=pizda(2,1)-pizda(1,2)
8870 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
8871 +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,itl)) &
8872 -0.5d0*scalar2(vv(1),Ctobr(1,l)))
8873 ! Cartesian gradient
8877 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
8879 vv(1)=pizda(1,1)+pizda(2,2)
8880 vv(2)=pizda(2,1)-pizda(1,2)
8881 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
8882 +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,itl)) &
8883 -0.5d0*scalar2(vv(1),Ctobr(1,l))
8888 ! Antiparallel orientation
8889 ! Contribution from graph III
8891 call transpose2(EUg(1,1,j),auxmat(1,1))
8892 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
8893 vv(1)=pizda(1,1)-pizda(2,2)
8894 vv(2)=pizda(1,2)+pizda(2,1)
8895 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,j)) &
8896 +0.5d0*scalar2(vv(1),Dtobr2(1,l))
8897 ! Explicit gradient in virtual-dihedral angles.
8898 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
8899 +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,j)) &
8900 +0.5d0*scalar2(vv(1),Dtobr2der(1,l)))
8901 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
8902 vv(1)=pizda(1,1)-pizda(2,2)
8903 vv(2)=pizda(1,2)+pizda(2,1)
8904 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
8905 +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,j)) &
8906 +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
8907 call transpose2(EUgder(1,1,j),auxmat1(1,1))
8908 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
8909 vv(1)=pizda(1,1)-pizda(2,2)
8910 vv(2)=pizda(1,2)+pizda(2,1)
8911 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
8912 +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,j)) &
8913 +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
8914 ! Cartesian gradient
8918 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),&
8920 vv(1)=pizda(1,1)-pizda(2,2)
8921 vv(2)=pizda(1,2)+pizda(2,1)
8922 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii) &
8923 +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,j)) &
8924 +0.5d0*scalar2(vv(1),Dtobr2(1,l))
8929 ! Contribution from graph IV
8931 call transpose2(EE(1,1,itj),auxmat(1,1))
8932 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
8933 vv(1)=pizda(1,1)+pizda(2,2)
8934 vv(2)=pizda(2,1)-pizda(1,2)
8935 eello5_4=scalar2(AEAb1(1,2,2),b1(1,itj)) &
8936 -0.5d0*scalar2(vv(1),Ctobr(1,j))
8937 ! Explicit gradient in virtual-dihedral angles.
8938 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
8939 -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,j))
8940 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
8941 vv(1)=pizda(1,1)+pizda(2,2)
8942 vv(2)=pizda(2,1)-pizda(1,2)
8943 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
8944 +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,itj)) &
8945 -0.5d0*scalar2(vv(1),Ctobr(1,j)))
8946 ! Cartesian gradient
8950 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
8952 vv(1)=pizda(1,1)+pizda(2,2)
8953 vv(2)=pizda(2,1)-pizda(1,2)
8954 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii) &
8955 +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,itj)) &
8956 -0.5d0*scalar2(vv(1),Ctobr(1,j))
8962 eel5=eello5_1+eello5_2+eello5_3+eello5_4
8963 !d if (i.eq.2 .and. j.eq.8 .and. k.eq.3 .and. l.eq.7) then
8964 !d write (2,*) 'ijkl',i,j,k,l
8965 !d write (2,*) 'eello5_1',eello5_1,' eello5_2',eello5_2,
8966 !d & ' eello5_3',eello5_3,' eello5_4',eello5_4
8968 !d write(iout,*) 'eello5_1',eello5_1,' eel5_1_num',16*eel5_1_num
8969 !d write(iout,*) 'eello5_2',eello5_2,' eel5_2_num',16*eel5_2_num
8970 !d write(iout,*) 'eello5_3',eello5_3,' eel5_3_num',16*eel5_3_num
8971 !d write(iout,*) 'eello5_4',eello5_4,' eel5_4_num',16*eel5_4_num
8972 if (j.lt.nres-1) then
8979 if (l.lt.nres-1) then
8989 !d write (2,*) 'eij',eij,' ekl',ekl,' ekont',ekont
8990 ! 2/11/08 AL Gradients over DC's connecting interacting sites will be
8991 ! summed up outside the subrouine as for the other subroutines
8992 ! handling long-range interactions. The old code is commented out
8993 ! with "cgrad" to keep track of changes.
8995 !grad ggg1(ll)=eel5*g_contij(ll,1)
8996 !grad ggg2(ll)=eel5*g_contij(ll,2)
8997 gradcorr5ij=eel5*g_contij(ll,1)+ekont*derx(ll,1,1)
8998 gradcorr5kl=eel5*g_contij(ll,2)+ekont*derx(ll,1,2)
8999 ! write (iout,'(a,3i3,a,5f8.3,2i3,a,5f8.3,a,f8.3)')
9000 ! & "ecorr5",ll,i,j," derx",derx(ll,2,1),derx(ll,3,1),derx(ll,4,1),
9001 ! & derx(ll,5,1),k,l," derx",derx(ll,2,2),derx(ll,3,2),
9002 ! & derx(ll,4,2),derx(ll,5,2)," ekont",ekont
9003 ! write (iout,'(a,3i3,a,3f8.3,2i3,a,3f8.3)')
9004 ! & "ecorr5",ll,i,j," gradcorr5",g_contij(ll,1),derx(ll,1,1),
9006 ! & k,l," gradcorr5",g_contij(ll,2),derx(ll,1,2),gradcorr5kl
9007 !old ghalf=0.5d0*eel5*ekl*gacont_hbr(ll,jj,i)
9008 !grad ghalf=0.5d0*ggg1(ll)
9010 gradcorr5(ll,i)=gradcorr5(ll,i)+ekont*derx(ll,2,1)
9011 gradcorr5(ll,i+1)=gradcorr5(ll,i+1)+ekont*derx(ll,3,1)
9012 gradcorr5(ll,j)=gradcorr5(ll,j)+ekont*derx(ll,4,1)
9013 gradcorr5(ll,j1)=gradcorr5(ll,j1)+ekont*derx(ll,5,1)
9014 gradcorr5_long(ll,j)=gradcorr5_long(ll,j)+gradcorr5ij
9015 gradcorr5_long(ll,i)=gradcorr5_long(ll,i)-gradcorr5ij
9016 !old ghalf=0.5d0*eel5*eij*gacont_hbr(ll,kk,k)
9017 !grad ghalf=0.5d0*ggg2(ll)
9019 gradcorr5(ll,k)=gradcorr5(ll,k)+ghalf+ekont*derx(ll,2,2)
9020 gradcorr5(ll,k+1)=gradcorr5(ll,k+1)+ekont*derx(ll,3,2)
9021 gradcorr5(ll,l)=gradcorr5(ll,l)+ghalf+ekont*derx(ll,4,2)
9022 gradcorr5(ll,l1)=gradcorr5(ll,l1)+ekont*derx(ll,5,2)
9023 gradcorr5_long(ll,l)=gradcorr5_long(ll,l)+gradcorr5kl
9024 gradcorr5_long(ll,k)=gradcorr5_long(ll,k)-gradcorr5kl
9029 !old gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*ekl*gacont_hbr(ll,jj,i)
9030 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ggg1(ll)
9035 !old gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*eij*gacont_hbr(ll,kk,k)
9036 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ggg2(ll)
9042 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,1)
9047 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,2)
9051 !d write (2,*) iii,g_corr5_loc(iii)
9054 !d write (2,*) 'ekont',ekont
9055 !d write (iout,*) 'eello5',ekont*eel5
9058 !-----------------------------------------------------------------------------
9059 real(kind=8) function eello6(i,j,k,l,jj,kk)
9060 ! implicit real*8 (a-h,o-z)
9061 ! include 'DIMENSIONS'
9062 ! include 'COMMON.IOUNITS'
9063 ! include 'COMMON.CHAIN'
9064 ! include 'COMMON.DERIV'
9065 ! include 'COMMON.INTERACT'
9066 ! include 'COMMON.CONTACTS'
9067 ! include 'COMMON.TORSION'
9068 ! include 'COMMON.VAR'
9069 ! include 'COMMON.GEO'
9070 ! include 'COMMON.FFIELD'
9071 real(kind=8),dimension(3) :: ggg1,ggg2
9072 real(kind=8) :: eello6_1,eello6_2,eello6_3,eello6_4,eello6_5,&
9074 real(kind=8) :: gradcorr6ij,gradcorr6kl
9075 integer :: i,j,k,l,jj,kk,iii,kkk,lll,j1,j2,l1,l2,ll
9076 !d if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
9081 !d & 'EELLO6: Contacts have occurred for peptide groups',i,j,
9089 !d call checkint6(i,j,k,l,jj,kk,eel6_1_num,eel6_2_num,
9090 !d & eel6_3_num,eel6_4_num,eel6_5_num,eel6_6_num)
9094 derx(lll,kkk,iii)=0.0d0
9098 !d eij=facont_hb(jj,i)
9099 !d ekl=facont_hb(kk,k)
9105 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
9106 eello6_2=eello6_graph1(j,i,l,k,2,.false.)
9107 eello6_3=eello6_graph2(i,j,k,l,jj,kk,.false.)
9108 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
9109 eello6_5=eello6_graph4(j,i,l,k,jj,kk,2,.false.)
9110 eello6_6=eello6_graph3(i,j,k,l,jj,kk,.false.)
9112 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
9113 eello6_2=eello6_graph1(l,k,j,i,2,.true.)
9114 eello6_3=eello6_graph2(i,l,k,j,jj,kk,.true.)
9115 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
9116 if (wturn6.eq.0.0d0 .or. j.ne.i+4) then
9117 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
9121 eello6_6=eello6_graph3(i,l,k,j,jj,kk,.true.)
9123 ! If turn contributions are considered, they will be handled separately.
9124 eel6=eello6_1+eello6_2+eello6_3+eello6_4+eello6_5+eello6_6
9125 !d write(iout,*) 'eello6_1',eello6_1!,' eel6_1_num',16*eel6_1_num
9126 !d write(iout,*) 'eello6_2',eello6_2!,' eel6_2_num',16*eel6_2_num
9127 !d write(iout,*) 'eello6_3',eello6_3!,' eel6_3_num',16*eel6_3_num
9128 !d write(iout,*) 'eello6_4',eello6_4!,' eel6_4_num',16*eel6_4_num
9129 !d write(iout,*) 'eello6_5',eello6_5!,' eel6_5_num',16*eel6_5_num
9130 !d write(iout,*) 'eello6_6',eello6_6!,' eel6_6_num',16*eel6_6_num
9132 if (j.lt.nres-1) then
9139 if (l.lt.nres-1) then
9147 !grad ggg1(ll)=eel6*g_contij(ll,1)
9148 !grad ggg2(ll)=eel6*g_contij(ll,2)
9149 !old ghalf=0.5d0*eel6*ekl*gacont_hbr(ll,jj,i)
9150 !grad ghalf=0.5d0*ggg1(ll)
9152 gradcorr6ij=eel6*g_contij(ll,1)+ekont*derx(ll,1,1)
9153 gradcorr6kl=eel6*g_contij(ll,2)+ekont*derx(ll,1,2)
9154 gradcorr6(ll,i)=gradcorr6(ll,i)+ekont*derx(ll,2,1)
9155 gradcorr6(ll,i+1)=gradcorr6(ll,i+1)+ekont*derx(ll,3,1)
9156 gradcorr6(ll,j)=gradcorr6(ll,j)+ekont*derx(ll,4,1)
9157 gradcorr6(ll,j1)=gradcorr6(ll,j1)+ekont*derx(ll,5,1)
9158 gradcorr6_long(ll,j)=gradcorr6_long(ll,j)+gradcorr6ij
9159 gradcorr6_long(ll,i)=gradcorr6_long(ll,i)-gradcorr6ij
9160 !grad ghalf=0.5d0*ggg2(ll)
9161 !old ghalf=0.5d0*eel6*eij*gacont_hbr(ll,kk,k)
9163 gradcorr6(ll,k)=gradcorr6(ll,k)+ekont*derx(ll,2,2)
9164 gradcorr6(ll,k+1)=gradcorr6(ll,k+1)+ekont*derx(ll,3,2)
9165 gradcorr6(ll,l)=gradcorr6(ll,l)+ekont*derx(ll,4,2)
9166 gradcorr6(ll,l1)=gradcorr6(ll,l1)+ekont*derx(ll,5,2)
9167 gradcorr6_long(ll,l)=gradcorr6_long(ll,l)+gradcorr6kl
9168 gradcorr6_long(ll,k)=gradcorr6_long(ll,k)-gradcorr6kl
9173 !old gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*ekl*gacont_hbr(ll,jj,i)
9174 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ggg1(ll)
9179 !old gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*eij*gacont_hbr(ll,kk,k)
9180 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ggg2(ll)
9186 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,1)
9191 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,2)
9195 !d write (2,*) iii,g_corr6_loc(iii)
9198 !d write (2,*) 'ekont',ekont
9199 !d write (iout,*) 'eello6',ekont*eel6
9202 !-----------------------------------------------------------------------------
9203 real(kind=8) function eello6_graph1(i,j,k,l,imat,swap)
9205 ! implicit real*8 (a-h,o-z)
9206 ! include 'DIMENSIONS'
9207 ! include 'COMMON.IOUNITS'
9208 ! include 'COMMON.CHAIN'
9209 ! include 'COMMON.DERIV'
9210 ! include 'COMMON.INTERACT'
9211 ! include 'COMMON.CONTACTS'
9212 ! include 'COMMON.TORSION'
9213 ! include 'COMMON.VAR'
9214 ! include 'COMMON.GEO'
9215 real(kind=8),dimension(2) :: vv,vv1
9216 real(kind=8),dimension(2,2) :: pizda,auxmat,pizda1
9219 !el common /kutas/ lprn
9220 integer :: i,j,k,l,imat,itk,iii,kkk,lll,ind
9221 real(kind=8) :: s1,s2,s3,s4,s5
9222 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9224 ! Parallel Antiparallel C
9230 ! \ j|/k\| / \ |/k\|l / C
9235 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9236 itk=itortyp(itype(k,1))
9237 s1= scalar2(AEAb1(1,2,imat),CUgb2(1,i))
9238 s2=-scalar2(AEAb2(1,1,imat),Ug2Db1t(1,k))
9239 s3= scalar2(AEAb2(1,1,imat),CUgb2(1,k))
9240 call transpose2(EUgC(1,1,k),auxmat(1,1))
9241 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
9242 vv1(1)=pizda1(1,1)-pizda1(2,2)
9243 vv1(2)=pizda1(1,2)+pizda1(2,1)
9244 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
9245 vv(1)=AEAb1(1,2,imat)*b1(1,itk)-AEAb1(2,2,imat)*b1(2,itk)
9246 vv(2)=AEAb1(1,2,imat)*b1(2,itk)+AEAb1(2,2,imat)*b1(1,itk)
9247 s5=scalar2(vv(1),Dtobr2(1,i))
9248 !d write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4', s4,' s5',s5
9249 eello6_graph1=-0.5d0*(s1+s2+s3+s4+s5)
9250 if (i.gt.1) g_corr6_loc(i-1)=g_corr6_loc(i-1) &
9251 -0.5d0*ekont*(scalar2(AEAb1(1,2,imat),CUgb2der(1,i)) &
9252 -scalar2(AEAb2derg(1,2,1,imat),Ug2Db1t(1,k)) &
9253 +scalar2(AEAb2derg(1,2,1,imat),CUgb2(1,k)) &
9254 +0.5d0*scalar2(vv1(1),Dtobr2der(1,i)) &
9255 +scalar2(vv(1),Dtobr2der(1,i)))
9256 call matmat2(AEAderg(1,1,imat),auxmat(1,1),pizda1(1,1))
9257 vv1(1)=pizda1(1,1)-pizda1(2,2)
9258 vv1(2)=pizda1(1,2)+pizda1(2,1)
9259 vv(1)=AEAb1derg(1,2,imat)*b1(1,itk)-AEAb1derg(2,2,imat)*b1(2,itk)
9260 vv(2)=AEAb1derg(1,2,imat)*b1(2,itk)+AEAb1derg(2,2,imat)*b1(1,itk)
9262 g_corr6_loc(l-1)=g_corr6_loc(l-1) &
9263 +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i)) &
9264 -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k)) &
9265 +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k)) &
9266 +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
9268 g_corr6_loc(j-1)=g_corr6_loc(j-1) &
9269 +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i)) &
9270 -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k)) &
9271 +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k)) &
9272 +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
9274 call transpose2(EUgCder(1,1,k),auxmat(1,1))
9275 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
9276 vv1(1)=pizda1(1,1)-pizda1(2,2)
9277 vv1(2)=pizda1(1,2)+pizda1(2,1)
9278 if (k.gt.1) g_corr6_loc(k-1)=g_corr6_loc(k-1) &
9279 +ekont*(-0.5d0*(-scalar2(AEAb2(1,1,imat),Ug2Db1tder(1,k)) &
9280 +scalar2(AEAb2(1,1,imat),CUgb2der(1,k)) &
9281 +0.5d0*scalar2(vv1(1),Dtobr2(1,i))))
9290 s1= scalar2(AEAb1derx(1,lll,kkk,iii,2,imat),CUgb2(1,i))
9291 s2=-scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),Ug2Db1t(1,k))
9292 s3= scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),CUgb2(1,k))
9293 call transpose2(EUgC(1,1,k),auxmat(1,1))
9294 call matmat2(AEAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),&
9296 vv1(1)=pizda1(1,1)-pizda1(2,2)
9297 vv1(2)=pizda1(1,2)+pizda1(2,1)
9298 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
9299 vv(1)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(1,itk) &
9300 -AEAb1derx(2,lll,kkk,iii,2,imat)*b1(2,itk)
9301 vv(2)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(2,itk) &
9302 +AEAb1derx(2,lll,kkk,iii,2,imat)*b1(1,itk)
9303 s5=scalar2(vv(1),Dtobr2(1,i))
9304 derx(lll,kkk,ind)=derx(lll,kkk,ind)-0.5d0*(s1+s2+s3+s4+s5)
9309 end function eello6_graph1
9310 !-----------------------------------------------------------------------------
9311 real(kind=8) function eello6_graph2(i,j,k,l,jj,kk,swap)
9313 ! implicit real*8 (a-h,o-z)
9314 ! include 'DIMENSIONS'
9315 ! include 'COMMON.IOUNITS'
9316 ! include 'COMMON.CHAIN'
9317 ! include 'COMMON.DERIV'
9318 ! include 'COMMON.INTERACT'
9319 ! include 'COMMON.CONTACTS'
9320 ! include 'COMMON.TORSION'
9321 ! include 'COMMON.VAR'
9322 ! include 'COMMON.GEO'
9324 real(kind=8),dimension(2) :: vv,auxvec,auxvec1,auxvec2
9325 real(kind=8),dimension(2,2) :: pizda,auxmat,auxmat1
9327 !el common /kutas/ lprn
9328 integer :: i,j,k,l,jj,kk,iii,kkk,lll,jjj,mmm
9329 real(kind=8) :: s2,s3,s4
9330 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9332 ! Parallel Antiparallel C
9338 ! \ j|/k\| \ |/k\|l C
9343 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9344 !d write (2,*) 'eello6_graph2: i,',i,' j',j,' k',k,' l',l
9345 ! AL 7/4/01 s1 would occur in the sixth-order moment,
9346 ! but not in a cluster cumulant
9348 s1=dip(1,jj,i)*dip(1,kk,k)
9350 call matvec2(ADtEA1(1,1,1),Ub2(1,k),auxvec(1))
9351 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
9352 call matvec2(ADtEA(1,1,2),Ub2(1,l),auxvec1(1))
9353 s3=-0.5d0*scalar2(Ub2(1,j),auxvec1(1))
9354 call transpose2(EUg(1,1,k),auxmat(1,1))
9355 call matmat2(ADtEA1(1,1,1),auxmat(1,1),pizda(1,1))
9356 vv(1)=pizda(1,1)-pizda(2,2)
9357 vv(2)=pizda(1,2)+pizda(2,1)
9358 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9359 !d write (2,*) 'eello6_graph2:','s1',s1,' s2',s2,' s3',s3,' s4',s4
9361 eello6_graph2=-(s1+s2+s3+s4)
9363 eello6_graph2=-(s2+s3+s4)
9366 ! Derivatives in gamma(i-1)
9369 s1=dipderg(1,jj,i)*dip(1,kk,k)
9371 s2=-0.5d0*scalar2(Ub2der(1,i),auxvec(1))
9372 call matvec2(ADtEAderg(1,1,1,2),Ub2(1,l),auxvec2(1))
9373 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
9374 s4=-0.25d0*scalar2(vv(1),Dtobr2der(1,i))
9376 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
9378 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
9380 ! g_corr6_loc(i-1)=g_corr6_loc(i-1)-s3
9382 ! Derivatives in gamma(k-1)
9384 s1=dip(1,jj,i)*dipderg(1,kk,k)
9386 call matvec2(ADtEA1(1,1,1),Ub2der(1,k),auxvec2(1))
9387 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
9388 call matvec2(ADtEAderg(1,1,2,2),Ub2(1,l),auxvec2(1))
9389 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
9390 call transpose2(EUgder(1,1,k),auxmat1(1,1))
9391 call matmat2(ADtEA1(1,1,1),auxmat1(1,1),pizda(1,1))
9392 vv(1)=pizda(1,1)-pizda(2,2)
9393 vv(2)=pizda(1,2)+pizda(2,1)
9394 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9396 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
9398 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
9400 ! g_corr6_loc(k-1)=g_corr6_loc(k-1)-s3
9401 ! Derivatives in gamma(j-1) or gamma(l-1)
9404 s1=dipderg(3,jj,i)*dip(1,kk,k)
9406 call matvec2(ADtEA1derg(1,1,1,1),Ub2(1,k),auxvec2(1))
9407 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
9408 s3=-0.5d0*scalar2(Ub2der(1,j),auxvec1(1))
9409 call matmat2(ADtEA1derg(1,1,1,1),auxmat(1,1),pizda(1,1))
9410 vv(1)=pizda(1,1)-pizda(2,2)
9411 vv(2)=pizda(1,2)+pizda(2,1)
9412 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9415 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
9417 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
9420 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s3+s4)
9421 ! g_corr6_loc(j-1)=g_corr6_loc(j-1)-s3
9423 ! Derivatives in gamma(l-1) or gamma(j-1)
9426 s1=dip(1,jj,i)*dipderg(3,kk,k)
9428 call matvec2(ADtEA1derg(1,1,2,1),Ub2(1,k),auxvec2(1))
9429 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
9430 call matvec2(ADtEA(1,1,2),Ub2der(1,l),auxvec2(1))
9431 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
9432 call matmat2(ADtEA1derg(1,1,2,1),auxmat(1,1),pizda(1,1))
9433 vv(1)=pizda(1,1)-pizda(2,2)
9434 vv(2)=pizda(1,2)+pizda(2,1)
9435 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9438 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
9440 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
9443 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s3+s4)
9444 ! g_corr6_loc(l-1)=g_corr6_loc(l-1)-s3
9446 ! Cartesian derivatives.
9448 write (2,*) 'In eello6_graph2'
9450 write (2,*) 'iii=',iii
9452 write (2,*) 'kkk=',kkk
9454 write (2,'(3(2f10.5),5x)') &
9455 ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
9465 s1=dipderx(lll,kkk,1,jj,i)*dip(1,kk,k)
9467 s1=dip(1,jj,i)*dipderx(lll,kkk,1,kk,k)
9470 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,1),Ub2(1,k),&
9472 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
9473 call matvec2(ADtEAderx(1,1,lll,kkk,iii,2),Ub2(1,l),&
9475 s3=-0.5d0*scalar2(Ub2(1,j),auxvec(1))
9476 call transpose2(EUg(1,1,k),auxmat(1,1))
9477 call matmat2(ADtEA1derx(1,1,lll,kkk,iii,1),auxmat(1,1),&
9479 vv(1)=pizda(1,1)-pizda(2,2)
9480 vv(2)=pizda(1,2)+pizda(2,1)
9481 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
9482 !d write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4',s4
9484 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
9486 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
9489 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
9491 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
9497 end function eello6_graph2
9498 !-----------------------------------------------------------------------------
9499 real(kind=8) function eello6_graph3(i,j,k,l,jj,kk,swap)
9500 ! implicit real*8 (a-h,o-z)
9501 ! include 'DIMENSIONS'
9502 ! include 'COMMON.IOUNITS'
9503 ! include 'COMMON.CHAIN'
9504 ! include 'COMMON.DERIV'
9505 ! include 'COMMON.INTERACT'
9506 ! include 'COMMON.CONTACTS'
9507 ! include 'COMMON.TORSION'
9508 ! include 'COMMON.VAR'
9509 ! include 'COMMON.GEO'
9510 real(kind=8),dimension(2) :: vv,auxvec
9511 real(kind=8),dimension(2,2) :: pizda,auxmat
9513 integer :: i,j,k,l,jj,kk,iti,itj1,itk,itk1,iii,lll,kkk,itl1
9514 real(kind=8) :: s1,s2,s3,s4
9515 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9517 ! Parallel Antiparallel C
9523 ! j|/k\| / |/k\|l / C
9528 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9530 ! 4/7/01 AL Component s1 was removed, because it pertains to the respective
9531 ! energy moment and not to the cluster cumulant.
9532 iti=itortyp(itype(i,1))
9533 if (j.lt.nres-1) then
9534 itj1=itortyp(itype(j+1,1))
9538 itk=itortyp(itype(k,1))
9539 itk1=itortyp(itype(k+1,1))
9540 if (l.lt.nres-1) then
9541 itl1=itortyp(itype(l+1,1))
9546 s1=dip(4,jj,i)*dip(4,kk,k)
9548 call matvec2(AECA(1,1,1),b1(1,itk1),auxvec(1))
9549 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
9550 call matvec2(AECA(1,1,2),b1(1,itl1),auxvec(1))
9551 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
9552 call transpose2(EE(1,1,itk),auxmat(1,1))
9553 call matmat2(auxmat(1,1),AECA(1,1,1),pizda(1,1))
9554 vv(1)=pizda(1,1)+pizda(2,2)
9555 vv(2)=pizda(2,1)-pizda(1,2)
9556 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
9557 !d write (2,*) 'eello6_graph3:','s1',s1,' s2',s2,' s3',s3,' s4',s4,
9558 !d & "sum",-(s2+s3+s4)
9560 eello6_graph3=-(s1+s2+s3+s4)
9562 eello6_graph3=-(s2+s3+s4)
9565 ! Derivatives in gamma(k-1)
9566 call matvec2(AECAderg(1,1,2),b1(1,itl1),auxvec(1))
9567 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
9568 s4=-0.25d0*scalar2(vv(1),Ctobrder(1,k))
9569 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s3+s4)
9570 ! Derivatives in gamma(l-1)
9571 call matvec2(AECAderg(1,1,1),b1(1,itk1),auxvec(1))
9572 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
9573 call matmat2(auxmat(1,1),AECAderg(1,1,1),pizda(1,1))
9574 vv(1)=pizda(1,1)+pizda(2,2)
9575 vv(2)=pizda(2,1)-pizda(1,2)
9576 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
9577 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
9578 ! Cartesian derivatives.
9584 s1=dipderx(lll,kkk,4,jj,i)*dip(4,kk,k)
9586 s1=dip(4,jj,i)*dipderx(lll,kkk,4,kk,k)
9589 call matvec2(AECAderx(1,1,lll,kkk,iii,1),b1(1,itk1),&
9591 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
9592 call matvec2(AECAderx(1,1,lll,kkk,iii,2),b1(1,itl1),&
9594 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
9595 call matmat2(auxmat(1,1),AECAderx(1,1,lll,kkk,iii,1),&
9597 vv(1)=pizda(1,1)+pizda(2,2)
9598 vv(2)=pizda(2,1)-pizda(1,2)
9599 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
9601 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
9603 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
9606 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
9608 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
9610 ! derx(lll,kkk,iii)=derx(lll,kkk,iii)-s4
9615 end function eello6_graph3
9616 !-----------------------------------------------------------------------------
9617 real(kind=8) function eello6_graph4(i,j,k,l,jj,kk,imat,swap)
9618 ! implicit real*8 (a-h,o-z)
9619 ! include 'DIMENSIONS'
9620 ! include 'COMMON.IOUNITS'
9621 ! include 'COMMON.CHAIN'
9622 ! include 'COMMON.DERIV'
9623 ! include 'COMMON.INTERACT'
9624 ! include 'COMMON.CONTACTS'
9625 ! include 'COMMON.TORSION'
9626 ! include 'COMMON.VAR'
9627 ! include 'COMMON.GEO'
9628 ! include 'COMMON.FFIELD'
9629 real(kind=8),dimension(2) :: vv,auxvec,auxvec1
9630 real(kind=8),dimension(2,2) :: pizda,auxmat,auxmat1
9632 integer :: i,j,k,l,jj,kk,imat,iti,itj,itj1,itk,itk1,itl,itl1,&
9634 real(kind=8) :: s1,s2,s3,s4
9635 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9637 ! Parallel Antiparallel C
9643 ! \ j|/k\| \ |/k\|l C
9648 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
9650 ! 4/7/01 AL Component s1 was removed, because it pertains to the respective
9651 ! energy moment and not to the cluster cumulant.
9652 !d write (2,*) 'eello_graph4: wturn6',wturn6
9653 iti=itortyp(itype(i,1))
9654 itj=itortyp(itype(j,1))
9655 if (j.lt.nres-1) then
9656 itj1=itortyp(itype(j+1,1))
9660 itk=itortyp(itype(k,1))
9661 if (k.lt.nres-1) then
9662 itk1=itortyp(itype(k+1,1))
9666 itl=itortyp(itype(l,1))
9667 if (l.lt.nres-1) then
9668 itl1=itortyp(itype(l+1,1))
9672 !d write (2,*) 'eello6_graph4:','i',i,' j',j,' k',k,' l',l
9673 !d write (2,*) 'iti',iti,' itj',itj,' itj1',itj1,' itk',itk,
9674 !d & ' itl',itl,' itl1',itl1
9677 s1=dip(3,jj,i)*dip(3,kk,k)
9679 s1=dip(2,jj,j)*dip(2,kk,l)
9682 call matvec2(AECA(1,1,imat),Ub2(1,k),auxvec(1))
9683 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
9685 call matvec2(ADtEA1(1,1,3-imat),b1(1,itj1),auxvec1(1))
9686 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
9688 call matvec2(ADtEA1(1,1,3-imat),b1(1,itl1),auxvec1(1))
9689 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
9691 call transpose2(EUg(1,1,k),auxmat(1,1))
9692 call matmat2(AECA(1,1,imat),auxmat(1,1),pizda(1,1))
9693 vv(1)=pizda(1,1)-pizda(2,2)
9694 vv(2)=pizda(2,1)+pizda(1,2)
9695 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
9696 !d write (2,*) 'eello6_graph4:','s1',s1,' s2',s2,' s3',s3,' s4',s4
9698 eello6_graph4=-(s1+s2+s3+s4)
9700 eello6_graph4=-(s2+s3+s4)
9702 ! Derivatives in gamma(i-1)
9706 s1=dipderg(2,jj,i)*dip(3,kk,k)
9708 s1=dipderg(4,jj,j)*dip(2,kk,l)
9711 s2=0.5d0*scalar2(Ub2der(1,i),auxvec(1))
9713 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,itj1),auxvec1(1))
9714 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
9716 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,itl1),auxvec1(1))
9717 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
9719 s4=0.25d0*scalar2(vv(1),Dtobr2der(1,i))
9720 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
9721 !d write (2,*) 'turn6 derivatives'
9723 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s1+s2+s3+s4)
9725 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s2+s3+s4)
9729 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
9731 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
9735 ! Derivatives in gamma(k-1)
9738 s1=dip(3,jj,i)*dipderg(2,kk,k)
9740 s1=dip(2,jj,j)*dipderg(4,kk,l)
9743 call matvec2(AECA(1,1,imat),Ub2der(1,k),auxvec1(1))
9744 s2=0.5d0*scalar2(Ub2(1,i),auxvec1(1))
9746 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,itj1),auxvec1(1))
9747 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
9749 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,itl1),auxvec1(1))
9750 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
9752 call transpose2(EUgder(1,1,k),auxmat1(1,1))
9753 call matmat2(AECA(1,1,imat),auxmat1(1,1),pizda(1,1))
9754 vv(1)=pizda(1,1)-pizda(2,2)
9755 vv(2)=pizda(2,1)+pizda(1,2)
9756 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
9757 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
9759 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s1+s2+s3+s4)
9761 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s2+s3+s4)
9765 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
9767 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
9770 ! Derivatives in gamma(j-1) or gamma(l-1)
9771 if (l.eq.j+1 .and. l.gt.1) then
9772 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
9773 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
9774 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
9775 vv(1)=pizda(1,1)-pizda(2,2)
9776 vv(2)=pizda(2,1)+pizda(1,2)
9777 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
9778 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
9779 else if (j.gt.1) then
9780 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
9781 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
9782 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
9783 vv(1)=pizda(1,1)-pizda(2,2)
9784 vv(2)=pizda(2,1)+pizda(1,2)
9785 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
9786 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
9787 gel_loc_turn6(j-1)=gel_loc_turn6(j-1)-ekont*(s2+s4)
9789 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s4)
9792 ! Cartesian derivatives.
9799 s1=dipderx(lll,kkk,3,jj,i)*dip(3,kk,k)
9801 s1=dipderx(lll,kkk,2,jj,j)*dip(2,kk,l)
9805 s1=dip(3,jj,i)*dipderx(lll,kkk,3,kk,k)
9807 s1=dip(2,jj,j)*dipderx(lll,kkk,2,kk,l)
9811 call matvec2(AECAderx(1,1,lll,kkk,iii,imat),Ub2(1,k),&
9813 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
9815 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),&
9816 b1(1,itj1),auxvec(1))
9817 s3=-0.5d0*scalar2(b1(1,itj),auxvec(1))
9819 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),&
9820 b1(1,itl1),auxvec(1))
9821 s3=-0.5d0*scalar2(b1(1,itl),auxvec(1))
9823 call matmat2(AECAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),&
9825 vv(1)=pizda(1,1)-pizda(2,2)
9826 vv(2)=pizda(2,1)+pizda(1,2)
9827 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
9829 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
9831 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii) &
9834 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii) &
9837 derx_turn(lll,kkk,iii)=derx_turn(lll,kkk,iii)-s3
9840 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s1+s2+s4)
9842 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s2+s4)
9844 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
9848 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
9850 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
9853 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
9855 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
9862 end function eello6_graph4
9863 !-----------------------------------------------------------------------------
9864 real(kind=8) function eello_turn6(i,jj,kk)
9865 ! implicit real*8 (a-h,o-z)
9866 ! include 'DIMENSIONS'
9867 ! include 'COMMON.IOUNITS'
9868 ! include 'COMMON.CHAIN'
9869 ! include 'COMMON.DERIV'
9870 ! include 'COMMON.INTERACT'
9871 ! include 'COMMON.CONTACTS'
9872 ! include 'COMMON.TORSION'
9873 ! include 'COMMON.VAR'
9874 ! include 'COMMON.GEO'
9875 real(kind=8),dimension(2) :: vtemp1,vtemp2,vtemp3,vtemp4,gvec
9876 real(kind=8),dimension(2,2) :: atemp,auxmat,achuj_temp,gtemp
9877 real(kind=8),dimension(3) :: ggg1,ggg2
9878 real(kind=8),dimension(2) :: vtemp1d,vtemp2d,vtemp3d,vtemp4d,gvecd
9879 real(kind=8),dimension(2,2) :: atempd,auxmatd,achuj_tempd,gtempd
9880 ! 4/7/01 AL Components s1, s8, and s13 were removed, because they pertain to
9881 ! the respective energy moment and not to the cluster cumulant.
9883 integer :: i,jj,kk,j,k,l,iti,itk,itk1,itl,itj,iii,kkk,lll
9884 integer :: j1,j2,l1,l2,ll
9885 real(kind=8) :: s1,s2,s8,s13,s12,eello6_5,eel_turn6
9886 real(kind=8) :: s1d,s8d,s12d,s2d,gturn6ij,gturn6kl
9895 iti=itortyp(itype(i,1))
9896 itk=itortyp(itype(k,1))
9897 itk1=itortyp(itype(k+1,1))
9898 itl=itortyp(itype(l,1))
9899 itj=itortyp(itype(j,1))
9900 !d write (2,*) 'itk',itk,' itk1',itk1,' itl',itl,' itj',itj
9901 !d write (2,*) 'i',i,' k',k,' j',j,' l',l
9902 !d if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
9907 !d & 'EELLO6: Contacts have occurred for peptide groups',i,j,
9909 !d call checkint_turn6(i,jj,kk,eel_turn6_num)
9913 derx_turn(lll,kkk,iii)=0.0d0
9920 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
9922 !d write (2,*) 'eello6_5',eello6_5
9924 call transpose2(AEA(1,1,1),auxmat(1,1))
9925 call matmat2(EUg(1,1,i+1),auxmat(1,1),auxmat(1,1))
9926 ss1=scalar2(Ub2(1,i+2),b1(1,itl))
9927 s1 = (auxmat(1,1)+auxmat(2,2))*ss1
9929 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1(1))
9930 call matvec2(AEA(1,1,1),vtemp1(1),vtemp1(1))
9931 s2 = scalar2(b1(1,itk),vtemp1(1))
9933 call transpose2(AEA(1,1,2),atemp(1,1))
9934 call matmat2(atemp(1,1),EUg(1,1,i+4),atemp(1,1))
9935 call matvec2(Ug2(1,1,i+2),dd(1,1,itk1),vtemp2(1))
9936 s8 = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
9938 call matmat2(EUg(1,1,i+3),AEA(1,1,2),auxmat(1,1))
9939 call matvec2(auxmat(1,1),Ub2(1,i+4),vtemp3(1))
9940 s12 = scalar2(Ub2(1,i+2),vtemp3(1))
9942 call transpose2(a_chuj(1,1,kk,i+1),achuj_temp(1,1))
9943 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtemp(1,1))
9944 call matmat2(gtemp(1,1),EUg(1,1,i+3),gtemp(1,1))
9945 call matvec2(a_chuj(1,1,jj,i),Ub2(1,i+4),vtemp4(1))
9946 ss13 = scalar2(b1(1,itk),vtemp4(1))
9947 s13 = (gtemp(1,1)+gtemp(2,2))*ss13
9949 ! write (2,*) 's1,s2,s8,s12,s13',s1,s2,s8,s12,s13
9955 eel_turn6 = eello6_5 - 0.5d0*(s1+s2+s12+s8+s13)
9956 ! Derivatives in gamma(i+2)
9960 call transpose2(AEA(1,1,1),auxmatd(1,1))
9961 call matmat2(EUgder(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
9962 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
9963 call transpose2(AEAderg(1,1,2),atempd(1,1))
9964 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
9965 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
9967 call matmat2(EUg(1,1,i+3),AEAderg(1,1,2),auxmatd(1,1))
9968 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
9969 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
9975 gel_loc_turn6(i)=gel_loc_turn6(i)-0.5d0*ekont*(s1d+s8d+s12d)
9976 ! Derivatives in gamma(i+3)
9978 call transpose2(AEA(1,1,1),auxmatd(1,1))
9979 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
9980 ss1d=scalar2(Ub2der(1,i+2),b1(1,itl))
9981 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1d
9983 call matvec2(EUgder(1,1,i+2),b1(1,itl),vtemp1d(1))
9984 call matvec2(AEA(1,1,1),vtemp1d(1),vtemp1d(1))
9985 s2d = scalar2(b1(1,itk),vtemp1d(1))
9987 call matvec2(Ug2der(1,1,i+2),dd(1,1,itk1),vtemp2d(1))
9988 s8d = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,itl),vtemp2d(1))
9990 s12d = scalar2(Ub2der(1,i+2),vtemp3(1))
9992 call matmat2(achuj_temp(1,1),EUgder(1,1,i+2),gtempd(1,1))
9993 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
9994 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
10002 gel_loc_turn6(i+1)=gel_loc_turn6(i+1) &
10003 -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
10005 gel_loc_turn6(i+1)=gel_loc_turn6(i+1) &
10006 -0.5d0*ekont*(s2d+s12d)
10008 ! Derivatives in gamma(i+4)
10009 call matmat2(EUgder(1,1,i+3),AEA(1,1,2),auxmatd(1,1))
10010 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
10011 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
10013 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtempd(1,1))
10014 call matmat2(gtempd(1,1),EUgder(1,1,i+3),gtempd(1,1))
10015 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
10023 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d+s13d)
10025 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d)
10027 ! Derivatives in gamma(i+5)
10029 call transpose2(AEAderg(1,1,1),auxmatd(1,1))
10030 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
10031 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
10033 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1d(1))
10034 call matvec2(AEAderg(1,1,1),vtemp1d(1),vtemp1d(1))
10035 s2d = scalar2(b1(1,itk),vtemp1d(1))
10037 call transpose2(AEA(1,1,2),atempd(1,1))
10038 call matmat2(atempd(1,1),EUgder(1,1,i+4),atempd(1,1))
10039 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
10041 call matvec2(auxmat(1,1),Ub2der(1,i+4),vtemp3d(1))
10042 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
10044 call matvec2(a_chuj(1,1,jj,i),Ub2der(1,i+4),vtemp4d(1))
10045 ss13d = scalar2(b1(1,itk),vtemp4d(1))
10046 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
10054 gel_loc_turn6(i+3)=gel_loc_turn6(i+3) &
10055 -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
10057 gel_loc_turn6(i+3)=gel_loc_turn6(i+3) &
10058 -0.5d0*ekont*(s2d+s12d)
10060 ! Cartesian derivatives
10065 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmatd(1,1))
10066 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
10067 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
10069 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1(1))
10070 call matvec2(AEAderx(1,1,lll,kkk,iii,1),vtemp1(1),&
10072 s2d = scalar2(b1(1,itk),vtemp1d(1))
10074 call transpose2(AEAderx(1,1,lll,kkk,iii,2),atempd(1,1))
10075 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
10076 s8d = -(atempd(1,1)+atempd(2,2))* &
10077 scalar2(cc(1,1,itl),vtemp2(1))
10079 call matmat2(EUg(1,1,i+3),AEAderx(1,1,lll,kkk,iii,2),&
10081 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
10082 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
10089 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii) &
10092 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii) &
10096 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii) &
10099 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii) &
10108 call transpose2(a_chuj_der(1,1,lll,kkk,kk,i+1),&
10110 call matmat2(achuj_tempd(1,1),EUg(1,1,i+2),gtempd(1,1))
10111 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
10112 s13d=(gtempd(1,1)+gtempd(2,2))*ss13
10113 derx_turn(lll,kkk,2) = derx_turn(lll,kkk,2)-0.5d0*s13d
10114 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),Ub2(1,i+4),&
10116 ss13d = scalar2(b1(1,itk),vtemp4d(1))
10117 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
10118 derx_turn(lll,kkk,1) = derx_turn(lll,kkk,1)-0.5d0*s13d
10122 !d write(iout,*) 'eel6_turn6',eel_turn6,' eel_turn6_num',
10123 !d & 16*eel_turn6_num
10125 if (j.lt.nres-1) then
10132 if (l.lt.nres-1) then
10140 !grad ggg1(ll)=eel_turn6*g_contij(ll,1)
10141 !grad ggg2(ll)=eel_turn6*g_contij(ll,2)
10142 !grad ghalf=0.5d0*ggg1(ll)
10144 gturn6ij=eel_turn6*g_contij(ll,1)+ekont*derx_turn(ll,1,1)
10145 gturn6kl=eel_turn6*g_contij(ll,2)+ekont*derx_turn(ll,1,2)
10146 gcorr6_turn(ll,i)=gcorr6_turn(ll,i) & !+ghalf
10147 +ekont*derx_turn(ll,2,1)
10148 gcorr6_turn(ll,i+1)=gcorr6_turn(ll,i+1)+ekont*derx_turn(ll,3,1)
10149 gcorr6_turn(ll,j)=gcorr6_turn(ll,j) & !+ghalf
10150 +ekont*derx_turn(ll,4,1)
10151 gcorr6_turn(ll,j1)=gcorr6_turn(ll,j1)+ekont*derx_turn(ll,5,1)
10152 gcorr6_turn_long(ll,j)=gcorr6_turn_long(ll,j)+gturn6ij
10153 gcorr6_turn_long(ll,i)=gcorr6_turn_long(ll,i)-gturn6ij
10154 !grad ghalf=0.5d0*ggg2(ll)
10156 gcorr6_turn(ll,k)=gcorr6_turn(ll,k) & !+ghalf
10157 +ekont*derx_turn(ll,2,2)
10158 gcorr6_turn(ll,k+1)=gcorr6_turn(ll,k+1)+ekont*derx_turn(ll,3,2)
10159 gcorr6_turn(ll,l)=gcorr6_turn(ll,l) & !+ghalf
10160 +ekont*derx_turn(ll,4,2)
10161 gcorr6_turn(ll,l1)=gcorr6_turn(ll,l1)+ekont*derx_turn(ll,5,2)
10162 gcorr6_turn_long(ll,l)=gcorr6_turn_long(ll,l)+gturn6kl
10163 gcorr6_turn_long(ll,k)=gcorr6_turn_long(ll,k)-gturn6kl
10168 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg1(ll)
10173 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg2(ll)
10179 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,1)
10184 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,2)
10188 !d write (2,*) iii,g_corr6_loc(iii)
10190 eello_turn6=ekont*eel_turn6
10191 !d write (2,*) 'ekont',ekont
10192 !d write (2,*) 'eel_turn6',ekont*eel_turn6
10194 end function eello_turn6
10195 !-----------------------------------------------------------------------------
10196 subroutine MATVEC2(A1,V1,V2)
10197 !DIR$ INLINEALWAYS MATVEC2
10199 !DEC$ ATTRIBUTES FORCEINLINE::MATVEC2
10201 ! implicit real*8 (a-h,o-z)
10202 ! include 'DIMENSIONS'
10203 real(kind=8),dimension(2) :: V1,V2
10204 real(kind=8),dimension(2,2) :: A1
10205 real(kind=8) :: vaux1,vaux2
10209 ! 3 VI=VI+A1(I,K)*V1(K)
10213 vaux1=a1(1,1)*v1(1)+a1(1,2)*v1(2)
10214 vaux2=a1(2,1)*v1(1)+a1(2,2)*v1(2)
10218 end subroutine MATVEC2
10219 !-----------------------------------------------------------------------------
10220 subroutine MATMAT2(A1,A2,A3)
10222 !DEC$ ATTRIBUTES FORCEINLINE::MATMAT2
10224 ! implicit real*8 (a-h,o-z)
10225 ! include 'DIMENSIONS'
10226 real(kind=8),dimension(2,2) :: A1,A2,A3
10227 real(kind=8) :: ai3_11,ai3_12,ai3_21,ai3_22
10228 ! DIMENSION AI3(2,2)
10232 ! A3IJ=A3IJ+A1(I,K)*A2(K,J)
10238 ai3_11=a1(1,1)*a2(1,1)+a1(1,2)*a2(2,1)
10239 ai3_12=a1(1,1)*a2(1,2)+a1(1,2)*a2(2,2)
10240 ai3_21=a1(2,1)*a2(1,1)+a1(2,2)*a2(2,1)
10241 ai3_22=a1(2,1)*a2(1,2)+a1(2,2)*a2(2,2)
10247 end subroutine MATMAT2
10248 !-----------------------------------------------------------------------------
10249 real(kind=8) function scalar2(u,v)
10250 !DIR$ INLINEALWAYS scalar2
10252 real(kind=8),dimension(2) :: u,v
10255 scalar2=u(1)*v(1)+u(2)*v(2)
10257 end function scalar2
10258 !-----------------------------------------------------------------------------
10259 subroutine transpose2(a,at)
10260 !DIR$ INLINEALWAYS transpose2
10262 !DEC$ ATTRIBUTES FORCEINLINE::transpose2
10265 real(kind=8),dimension(2,2) :: a,at
10271 end subroutine transpose2
10272 !-----------------------------------------------------------------------------
10273 subroutine transpose(n,a,at)
10276 real(kind=8),dimension(n,n) :: a,at
10283 end subroutine transpose
10284 !-----------------------------------------------------------------------------
10285 subroutine prodmat3(a1,a2,kk,transp,prod)
10286 !DIR$ INLINEALWAYS prodmat3
10288 !DEC$ ATTRIBUTES FORCEINLINE::prodmat3
10292 real(kind=8),dimension(2,2) :: a1,a2,a2t,kk,prod
10294 !rc double precision auxmat(2,2),prod_(2,2)
10297 !rc call transpose2(kk(1,1),auxmat(1,1))
10298 !rc call matmat2(a1(1,1),auxmat(1,1),auxmat(1,1))
10299 !rc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
10301 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,1) &
10302 +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,1)
10303 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,2) &
10304 +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,2)
10305 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,1) &
10306 +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,1)
10307 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,2) &
10308 +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,2)
10311 !rc call matmat2(a1(1,1),kk(1,1),auxmat(1,1))
10312 !rc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
10314 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,1) &
10315 +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,1)
10316 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,2) &
10317 +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,2)
10318 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,1) &
10319 +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,1)
10320 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,2) &
10321 +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,2)
10324 ! call transpose2(a2(1,1),a2t(1,1))
10327 !rc print *,((prod_(i,j),i=1,2),j=1,2)
10328 !rc print *,((prod(i,j),i=1,2),j=1,2)
10331 end subroutine prodmat3
10332 !-----------------------------------------------------------------------------
10333 ! energy_p_new_barrier.F
10334 !-----------------------------------------------------------------------------
10335 subroutine sum_gradient
10336 ! implicit real*8 (a-h,o-z)
10337 use io_base, only: pdbout
10338 ! include 'DIMENSIONS'
10342 !MS$ATTRIBUTES C :: proc_proc
10348 real(kind=8),dimension(3,-1:nres) :: gradbufc,gradbufx,gradbufc_sum,&
10349 gloc_scbuf !(3,maxres)
10351 real(kind=8),dimension(4*nres) :: glocbuf !(4*maxres)
10353 !el local variables
10354 integer :: i,j,k,ierror,ierr
10355 real(kind=8) :: gvdwc_norm,gvdwc_scp_norm,gelc_norm,gvdwpp_norm,&
10356 gradb_norm,ghpbc_norm,gradcorr_norm,gel_loc_norm,&
10357 gcorr3_turn_norm,gcorr4_turn_norm,gradcorr5_norm,&
10358 gradcorr6_norm,gcorr6_turn_norm,gsccorr_norm,&
10359 gscloc_norm,gvdwx_norm,gradx_scp_norm,ghpbx_norm,&
10360 gradxorr_norm,gsccorrx_norm,gsclocx_norm,gcorr6_max,&
10361 gsccorr_max,gsccorrx_max,time00
10363 ! include 'COMMON.SETUP'
10364 ! include 'COMMON.IOUNITS'
10365 ! include 'COMMON.FFIELD'
10366 ! include 'COMMON.DERIV'
10367 ! include 'COMMON.INTERACT'
10368 ! include 'COMMON.SBRIDGE'
10369 ! include 'COMMON.CHAIN'
10370 ! include 'COMMON.VAR'
10371 ! include 'COMMON.CONTROL'
10372 ! include 'COMMON.TIME1'
10373 ! include 'COMMON.MAXGRAD'
10374 ! include 'COMMON.SCCOR'
10379 write (iout,*) "sum_gradient gvdwc, gvdwx"
10381 write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)') &
10382 i,(gvdwx(j,i),j=1,3),(gvdwc(j,i),j=1,3)
10392 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
10393 if (nfgtasks.gt.1 .and. fg_rank.eq.0) &
10394 call MPI_Bcast(1,1,MPI_INTEGER,king,FG_COMM,IERROR)
10397 ! 9/29/08 AL Transform parts of gradients in site coordinates to the gradient
10398 ! in virtual-bond-vector coordinates
10401 ! write (iout,*) "gel_loc gel_loc_long and gel_loc_loc"
10403 ! write (iout,'(i5,3f10.5,2x,3f10.5,2x,f10.5)')
10404 ! & i,(gel_loc(j,i),j=1,3),(gel_loc_long(j,i),j=1,3),gel_loc_loc(i)
10406 ! write (iout,*) "gel_loc_tur3 gel_loc_turn4"
10408 ! write (iout,'(i5,3f10.5,2x,f10.5)')
10409 ! & i,(gcorr4_turn(j,i),j=1,3),gel_loc_turn4(i)
10411 write (iout,*) "gvdwc gvdwc_scp gvdwc_scpp"
10413 write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)') &
10414 i,(gvdwc(j,i),j=1,3),(gvdwc_scp(j,i),j=1,3),&
10415 (gvdwc_scpp(j,i),j=1,3)
10417 write (iout,*) "gelc_long gvdwpp gel_loc_long"
10419 write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)') &
10420 i,(gelc_long(j,i),j=1,3),(gvdwpp(j,i),j=1,3),&
10421 (gelc_loc_long(j,i),j=1,3)
10428 gradbufc(j,i)=wsc*gvdwc(j,i)+ &
10429 wscp*(gvdwc_scp(j,i)+gvdwc_scpp(j,i))+ &
10430 welec*gelc_long(j,i)+wvdwpp*gvdwpp(j,i)+ &
10431 wel_loc*gel_loc_long(j,i)+ &
10432 wcorr*gradcorr_long(j,i)+ &
10433 wcorr5*gradcorr5_long(j,i)+ &
10434 wcorr6*gradcorr6_long(j,i)+ &
10435 wturn6*gcorr6_turn_long(j,i)+ &
10436 wstrain*ghpbc(j,i) &
10437 +wliptran*gliptranc(j,i) &
10439 +welec*gshieldc(j,i) &
10440 +wcorr*gshieldc_ec(j,i) &
10441 +wturn3*gshieldc_t3(j,i)&
10442 +wturn4*gshieldc_t4(j,i)&
10443 +wel_loc*gshieldc_ll(j,i)&
10444 +wtube*gg_tube(j,i) &
10445 +wvdwpp_nucl*gvdwpp_nucl(j,i)+welpp*gelpp(j,i)+ &
10446 wvdwpsb*(gvdwpsb(j,i)+gvdwpsb1(j,i))+ &
10447 wvdwsb*gvdwsbc(j,i)+welsb*gelsbc(j,i)+ &
10448 wcorr_nucl*gradcorr_nucl(j,i)&
10449 +wcorr3_nucl*gradcorr3_nucl(j,i)
10456 gradbufc(j,i)=wsc*gvdwc(j,i)+ &
10457 wscp*(gvdwc_scp(j,i)+gvdwc_scpp(j,i))+ &
10458 welec*gelc_long(j,i)+ &
10459 wbond*gradb(j,i)+ &
10460 wel_loc*gel_loc_long(j,i)+ &
10461 wcorr*gradcorr_long(j,i)+ &
10462 wcorr5*gradcorr5_long(j,i)+ &
10463 wcorr6*gradcorr6_long(j,i)+ &
10464 wturn6*gcorr6_turn_long(j,i)+ &
10465 wstrain*ghpbc(j,i) &
10466 +wliptran*gliptranc(j,i) &
10468 +welec*gshieldc(j,i)&
10469 +wcorr*gshieldc_ec(j,i) &
10470 +wturn4*gshieldc_t4(j,i) &
10471 +wel_loc*gshieldc_ll(j,i)&
10472 +wtube*gg_tube(j,i) &
10473 +wvdwpp_nucl*gvdwpp_nucl(j,i)+welpp*gelpp(j,i)+ &
10474 wvdwpsb*(gvdwpsb(j,i)+gvdwpsb1(j,i))+ &
10475 wvdwsb*gvdwsbc(j,i)+welsb*gelsbc(j,i)+ &
10476 wcorr_nucl*gradcorr_nucl(j,i)
10477 +wcorr3_nucl*gradcorr3_nucl(j,i)
10482 if (nfgtasks.gt.1) then
10485 write (iout,*) "gradbufc before allreduce"
10487 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
10493 gradbufc_sum(j,i)=gradbufc(j,i)
10496 ! call MPI_AllReduce(gradbufc(1,1),gradbufc_sum(1,1),3*nres,
10497 ! & MPI_DOUBLE_PRECISION,MPI_SUM,FG_COMM,IERR)
10498 ! time_reduce=time_reduce+MPI_Wtime()-time00
10500 ! write (iout,*) "gradbufc_sum after allreduce"
10502 ! write (iout,'(i3,3f10.5)') i,(gradbufc_sum(j,i),j=1,3)
10507 ! time_allreduce=time_allreduce+MPI_Wtime()-time00
10511 gradbufc(k,i)=0.0d0
10515 write (iout,*) "igrad_start",igrad_start," igrad_end",igrad_end
10516 write (iout,*) (i," jgrad_start",jgrad_start(i),&
10517 " jgrad_end ",jgrad_end(i),&
10518 i=igrad_start,igrad_end)
10521 ! Obsolete and inefficient code; we can make the effort O(n) and, therefore,
10522 ! do not parallelize this part.
10524 ! do i=igrad_start,igrad_end
10525 ! do j=jgrad_start(i),jgrad_end(i)
10527 ! gradbufc(k,i)=gradbufc(k,i)+gradbufc_sum(k,j)
10532 gradbufc(j,nres-1)=gradbufc_sum(j,nres)
10536 gradbufc(j,i)=gradbufc(j,i+1)+gradbufc_sum(j,i+1)
10540 write (iout,*) "gradbufc after summing"
10542 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
10550 write (iout,*) "gradbufc"
10552 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
10559 gradbufc_sum(j,i)=gradbufc(j,i)
10560 gradbufc(j,i)=0.0d0
10564 gradbufc(j,nres-1)=gradbufc_sum(j,nres)
10568 gradbufc(j,i)=gradbufc(j,i+1)+gradbufc_sum(j,i+1)
10573 ! gradbufc(k,i)=0.0d0
10577 ! gradbufc(k,i)=gradbufc(k,i)+gradbufc(k,j)
10583 write (iout,*) "gradbufc after summing"
10585 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
10594 gradbufc(k,nres)=0.0d0
10596 !el----------------
10597 !el if (.not.allocated(gradx)) allocate(gradx(3,nres,2)) !(3,maxres,2)
10598 !el if (.not.allocated(gradc)) allocate(gradc(3,nres,2)) !(3,maxres,2)
10599 !el-----------------
10603 gradc(j,i,icg)=gradbufc(j,i)+welec*gelc(j,i)+ &
10604 wel_loc*gel_loc(j,i)+ &
10605 0.5d0*(wscp*gvdwc_scpp(j,i)+ &
10606 welec*gelc_long(j,i)+wvdwpp*gvdwpp(j,i)+ &
10607 wel_loc*gel_loc_long(j,i)+ &
10608 wcorr*gradcorr_long(j,i)+ &
10609 wcorr5*gradcorr5_long(j,i)+ &
10610 wcorr6*gradcorr6_long(j,i)+ &
10611 wturn6*gcorr6_turn_long(j,i))+ &
10612 wbond*gradb(j,i)+ &
10613 wcorr*gradcorr(j,i)+ &
10614 wturn3*gcorr3_turn(j,i)+ &
10615 wturn4*gcorr4_turn(j,i)+ &
10616 wcorr5*gradcorr5(j,i)+ &
10617 wcorr6*gradcorr6(j,i)+ &
10618 wturn6*gcorr6_turn(j,i)+ &
10619 wsccor*gsccorc(j,i) &
10620 +wscloc*gscloc(j,i) &
10621 +wliptran*gliptranc(j,i) &
10623 +welec*gshieldc(j,i) &
10624 +welec*gshieldc_loc(j,i) &
10625 +wcorr*gshieldc_ec(j,i) &
10626 +wcorr*gshieldc_loc_ec(j,i) &
10627 +wturn3*gshieldc_t3(j,i) &
10628 +wturn3*gshieldc_loc_t3(j,i) &
10629 +wturn4*gshieldc_t4(j,i) &
10630 +wturn4*gshieldc_loc_t4(j,i) &
10631 +wel_loc*gshieldc_ll(j,i) &
10632 +wel_loc*gshieldc_loc_ll(j,i) &
10633 +wtube*gg_tube(j,i) &
10634 +0.5d0*(wvdwpp_nucl*gvdwpp_nucl(j,i)+welpp*gelpp(j,i)&
10635 +wvdwpsb*gvdwpsb1(j,i))&
10636 +wbond_nucl*gradb_nucl(j,i)+wsbloc*gsbloc(j,i)
10638 ! if ((i.le.2).and.(i.ge.1)) print *,gradc(j,i,icg),&
10639 ! gradbufc(j,i),welec*gelc(j,i), &
10640 ! wel_loc*gel_loc(j,i), &
10641 ! wscp*gvdwc_scpp(j,i), &
10642 ! welec*gelc_long(j,i),wvdwpp*gvdwpp(j,i), &
10643 ! wel_loc*gel_loc_long(j,i), &
10644 ! wcorr*gradcorr_long(j,i), &
10645 ! wcorr5*gradcorr5_long(j,i), &
10646 ! wcorr6*gradcorr6_long(j,i), &
10647 ! wturn6*gcorr6_turn_long(j,i), &
10648 ! wbond*gradb(j,i), &
10649 ! wcorr*gradcorr(j,i), &
10650 ! wturn3*gcorr3_turn(j,i), &
10651 ! wturn4*gcorr4_turn(j,i), &
10652 ! wcorr5*gradcorr5(j,i), &
10653 ! wcorr6*gradcorr6(j,i), &
10654 ! wturn6*gcorr6_turn(j,i), &
10655 ! wsccor*gsccorc(j,i) &
10656 ! ,wscloc*gscloc(j,i) &
10657 ! ,wliptran*gliptranc(j,i) &
10659 ! ,welec*gshieldc(j,i) &
10660 ! ,welec*gshieldc_loc(j,i) &
10661 ! ,wcorr*gshieldc_ec(j,i) &
10662 ! ,wcorr*gshieldc_loc_ec(j,i) &
10663 ! ,wturn3*gshieldc_t3(j,i) &
10664 ! ,wturn3*gshieldc_loc_t3(j,i) &
10665 ! ,wturn4*gshieldc_t4(j,i) &
10666 ! ,wturn4*gshieldc_loc_t4(j,i) &
10667 ! ,wel_loc*gshieldc_ll(j,i) &
10668 ! ,wel_loc*gshieldc_loc_ll(j,i) &
10669 ! ,wtube*gg_tube(j,i) &
10670 ! ,wbond_nucl*gradb_nucl(j,i) &
10671 ! ,wvdwpp_nucl*gvdwpp_nucl(j,i),welpp*gelpp(j,i),&
10672 ! wvdwpsb*gvdwpsb1(j,i)&
10673 ! ,wbond_nucl*gradb_nucl(j,i),wsbloc*gsbloc(j,i)
10678 gradc(j,i,icg)=gradbufc(j,i)+welec*gelc(j,i)+ &
10679 wel_loc*gel_loc(j,i)+ &
10680 0.5d0*(wscp*gvdwc_scpp(j,i)+ &
10681 welec*gelc_long(j,i)+ &
10682 wel_loc*gel_loc_long(j,i)+ &
10683 !el wcorr*gcorr_long(j,i)+ & !el gcorr_long- brak deklaracji
10684 wcorr5*gradcorr5_long(j,i)+ &
10685 wcorr6*gradcorr6_long(j,i)+ &
10686 wturn6*gcorr6_turn_long(j,i))+ &
10687 wbond*gradb(j,i)+ &
10688 wcorr*gradcorr(j,i)+ &
10689 wturn3*gcorr3_turn(j,i)+ &
10690 wturn4*gcorr4_turn(j,i)+ &
10691 wcorr5*gradcorr5(j,i)+ &
10692 wcorr6*gradcorr6(j,i)+ &
10693 wturn6*gcorr6_turn(j,i)+ &
10694 wsccor*gsccorc(j,i) &
10695 +wscloc*gscloc(j,i) &
10697 +wliptran*gliptranc(j,i) &
10698 +welec*gshieldc(j,i) &
10699 +welec*gshieldc_loc(j,) &
10700 +wcorr*gshieldc_ec(j,i) &
10701 +wcorr*gshieldc_loc_ec(j,i) &
10702 +wturn3*gshieldc_t3(j,i) &
10703 +wturn3*gshieldc_loc_t3(j,i) &
10704 +wturn4*gshieldc_t4(j,i) &
10705 +wturn4*gshieldc_loc_t4(j,i) &
10706 +wel_loc*gshieldc_ll(j,i) &
10707 +wel_loc*gshieldc_loc_ll(j,i) &
10708 +wtube*gg_tube(j,i) &
10709 +wbond_nucl*gradb_nucl(j,i) &
10710 +0.5d0*(wvdwpp_nucl*gvdwpp_nucl(j,i)+welpp*gelpp(j,i)&
10711 +wvdwpsb*gvdwpsb1(j,i))&
10712 +wsbloc*gsbloc(j,i)
10718 gradx(j,i,icg)=wsc*gvdwx(j,i)+wscp*gradx_scp(j,i)+ &
10719 wbond*gradbx(j,i)+ &
10720 wstrain*ghpbx(j,i)+wcorr*gradxorr(j,i)+ &
10721 wsccor*gsccorx(j,i) &
10722 +wscloc*gsclocx(j,i) &
10723 +wliptran*gliptranx(j,i) &
10724 +welec*gshieldx(j,i) &
10725 +wcorr*gshieldx_ec(j,i) &
10726 +wturn3*gshieldx_t3(j,i) &
10727 +wturn4*gshieldx_t4(j,i) &
10728 +wel_loc*gshieldx_ll(j,i)&
10729 +wtube*gg_tube_sc(j,i) &
10730 +wbond_nucl*gradbx_nucl(j,i) &
10731 +wvdwsb*gvdwsbx(j,i) &
10732 +welsb*gelsbx(j,i) &
10733 +wcorr_nucl*gradxorr_nucl(j,i)&
10734 +wcorr3_nucl*gradxorr3_nucl(j,i) &
10735 +wsbloc*gsblocx(j,i)
10739 write (iout,*) "gloc before adding corr"
10741 write (iout,*) i,gloc(i,icg)
10745 gloc(i,icg)=gloc(i,icg)+wcorr*gcorr_loc(i) &
10746 +wcorr5*g_corr5_loc(i) &
10747 +wcorr6*g_corr6_loc(i) &
10748 +wturn4*gel_loc_turn4(i) &
10749 +wturn3*gel_loc_turn3(i) &
10750 +wturn6*gel_loc_turn6(i) &
10751 +wel_loc*gel_loc_loc(i)
10754 write (iout,*) "gloc after adding corr"
10756 write (iout,*) i,gloc(i,icg)
10760 if (nfgtasks.gt.1) then
10763 gradbufc(j,i)=gradc(j,i,icg)
10764 gradbufx(j,i)=gradx(j,i,icg)
10768 glocbuf(i)=gloc(i,icg)
10772 write (iout,*) "gloc_sc before reduce"
10775 write (iout,*) i,j,gloc_sc(j,i,icg)
10782 gloc_scbuf(j,i)=gloc_sc(j,i,icg)
10786 call MPI_Barrier(FG_COMM,IERR)
10787 time_barrier_g=time_barrier_g+MPI_Wtime()-time00
10789 call MPI_Reduce(gradbufc(1,0),gradc(1,0,icg),3*nres+3,&
10790 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
10791 call MPI_Reduce(gradbufx(1,0),gradx(1,0,icg),3*nres+3,&
10792 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
10793 call MPI_Reduce(glocbuf(1),gloc(1,icg),4*nres,&
10794 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
10795 time_reduce=time_reduce+MPI_Wtime()-time00
10796 call MPI_Reduce(gloc_scbuf(1,1),gloc_sc(1,1,icg),3*nres,&
10797 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
10798 time_reduce=time_reduce+MPI_Wtime()-time00
10800 ! print *,"gradbuf",gradbufc(1,1),gradc(1,1,icg)
10802 write (iout,*) "gloc_sc after reduce"
10805 write (iout,*) i,j,gloc_sc(j,i,icg)
10811 write (iout,*) "gloc after reduce"
10813 write (iout,*) i,gloc(i,icg)
10818 if (gnorm_check) then
10820 ! Compute the maximum elements of the gradient
10823 gvdwc_scp_max=0.0d0
10830 gcorr3_turn_max=0.0d0
10831 gcorr4_turn_max=0.0d0
10832 gradcorr5_max=0.0d0
10833 gradcorr6_max=0.0d0
10834 gcorr6_turn_max=0.0d0
10838 gradx_scp_max=0.0d0
10844 gvdwc_norm=dsqrt(scalar(gvdwc(1,i),gvdwc(1,i)))
10845 if (gvdwc_norm.gt.gvdwc_max) gvdwc_max=gvdwc_norm
10846 gvdwc_scp_norm=dsqrt(scalar(gvdwc_scp(1,i),gvdwc_scp(1,i)))
10847 if (gvdwc_scp_norm.gt.gvdwc_scp_max) &
10848 gvdwc_scp_max=gvdwc_scp_norm
10849 gelc_norm=dsqrt(scalar(gelc(1,i),gelc(1,i)))
10850 if (gelc_norm.gt.gelc_max) gelc_max=gelc_norm
10851 gvdwpp_norm=dsqrt(scalar(gvdwpp(1,i),gvdwpp(1,i)))
10852 if (gvdwpp_norm.gt.gvdwpp_max) gvdwpp_max=gvdwpp_norm
10853 gradb_norm=dsqrt(scalar(gradb(1,i),gradb(1,i)))
10854 if (gradb_norm.gt.gradb_max) gradb_max=gradb_norm
10855 ghpbc_norm=dsqrt(scalar(ghpbc(1,i),ghpbc(1,i)))
10856 if (ghpbc_norm.gt.ghpbc_max) ghpbc_max=ghpbc_norm
10857 gradcorr_norm=dsqrt(scalar(gradcorr(1,i),gradcorr(1,i)))
10858 if (gradcorr_norm.gt.gradcorr_max) gradcorr_max=gradcorr_norm
10859 gel_loc_norm=dsqrt(scalar(gel_loc(1,i),gel_loc(1,i)))
10860 if (gel_loc_norm.gt.gel_loc_max) gel_loc_max=gel_loc_norm
10861 gcorr3_turn_norm=dsqrt(scalar(gcorr3_turn(1,i),&
10863 if (gcorr3_turn_norm.gt.gcorr3_turn_max) &
10864 gcorr3_turn_max=gcorr3_turn_norm
10865 gcorr4_turn_norm=dsqrt(scalar(gcorr4_turn(1,i),&
10867 if (gcorr4_turn_norm.gt.gcorr4_turn_max) &
10868 gcorr4_turn_max=gcorr4_turn_norm
10869 gradcorr5_norm=dsqrt(scalar(gradcorr5(1,i),gradcorr5(1,i)))
10870 if (gradcorr5_norm.gt.gradcorr5_max) &
10871 gradcorr5_max=gradcorr5_norm
10872 gradcorr6_norm=dsqrt(scalar(gradcorr6(1,i),gradcorr6(1,i)))
10873 if (gradcorr6_norm.gt.gradcorr6_max) gcorr6_max=gradcorr6_norm
10874 gcorr6_turn_norm=dsqrt(scalar(gcorr6_turn(1,i),&
10876 if (gcorr6_turn_norm.gt.gcorr6_turn_max) &
10877 gcorr6_turn_max=gcorr6_turn_norm
10878 gsccorr_norm=dsqrt(scalar(gsccorc(1,i),gsccorc(1,i)))
10879 if (gsccorr_norm.gt.gsccorr_max) gsccorr_max=gsccorr_norm
10880 gscloc_norm=dsqrt(scalar(gscloc(1,i),gscloc(1,i)))
10881 if (gscloc_norm.gt.gscloc_max) gscloc_max=gscloc_norm
10882 gvdwx_norm=dsqrt(scalar(gvdwx(1,i),gvdwx(1,i)))
10883 if (gvdwx_norm.gt.gvdwx_max) gvdwx_max=gvdwx_norm
10884 gradx_scp_norm=dsqrt(scalar(gradx_scp(1,i),gradx_scp(1,i)))
10885 if (gradx_scp_norm.gt.gradx_scp_max) &
10886 gradx_scp_max=gradx_scp_norm
10887 ghpbx_norm=dsqrt(scalar(ghpbx(1,i),ghpbx(1,i)))
10888 if (ghpbx_norm.gt.ghpbx_max) ghpbx_max=ghpbx_norm
10889 gradxorr_norm=dsqrt(scalar(gradxorr(1,i),gradxorr(1,i)))
10890 if (gradxorr_norm.gt.gradxorr_max) gradxorr_max=gradxorr_norm
10891 gsccorrx_norm=dsqrt(scalar(gsccorx(1,i),gsccorx(1,i)))
10892 if (gsccorrx_norm.gt.gsccorrx_max) gsccorrx_max=gsccorrx_norm
10893 gsclocx_norm=dsqrt(scalar(gsclocx(1,i),gsclocx(1,i)))
10894 if (gsclocx_norm.gt.gsclocx_max) gsclocx_max=gsclocx_norm
10898 open(istat,file=statname,position="append")
10900 open(istat,file=statname,access="append")
10902 write (istat,'(1h#,21f10.2)') gvdwc_max,gvdwc_scp_max,&
10903 gelc_max,gvdwpp_max,gradb_max,ghpbc_max,&
10904 gradcorr_max,gel_loc_max,gcorr3_turn_max,gcorr4_turn_max,&
10905 gradcorr5_max,gradcorr6_max,gcorr6_turn_max,gsccorc_max,&
10906 gscloc_max,gvdwx_max,gradx_scp_max,ghpbx_max,gradxorr_max,&
10907 gsccorx_max,gsclocx_max
10909 if (gvdwc_max.gt.1.0d4) then
10910 write (iout,*) "gvdwc gvdwx gradb gradbx"
10912 write(iout,'(i5,4(3f10.2,5x))') i,(gvdwc(j,i),gvdwx(j,i),&
10913 gradb(j,i),gradbx(j,i),j=1,3)
10915 call pdbout(0.0d0,'cipiszcze',iout)
10922 write (iout,*) "gradc gradx gloc"
10924 write (iout,'(i5,3f10.5,5x,3f10.5,5x,f10.5)') &
10925 i,(gradc(j,i,icg),j=1,3),(gradx(j,i,icg),j=1,3),gloc(i,icg)
10930 time_sumgradient=time_sumgradient+MPI_Wtime()-time01
10933 end subroutine sum_gradient
10934 !-----------------------------------------------------------------------------
10936 ! implicit real*8 (a-h,o-z)
10938 ! include 'DIMENSIONS'
10939 ! include 'COMMON.CHAIN'
10940 ! include 'COMMON.DERIV'
10941 ! include 'COMMON.CALC'
10942 ! include 'COMMON.IOUNITS'
10943 real(kind=8), dimension(3) :: dcosom1,dcosom2
10944 ! print *,"wchodze"
10945 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
10946 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
10947 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12 &
10948 -2.0D0*alf12*eps3der+sigder*sigsq_om12
10952 ! eom12=evdwij*eps1_om12
10954 ! write (iout,*) "eps2der",eps2der," eps3der",eps3der,&
10956 ! write (iout,*) "eps1_om12",eps1_om12," eps2rt_om12",eps2rt_om12
10957 ! write (iout,*) "eom1",eom1," eom2",eom2," eom12",eom12
10958 !C print *,sss_ele_cut,'in sc_grad'
10960 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
10961 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
10964 gg(k)=(gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k))*sss_ele_cut
10965 !C print *,'gg',k,gg(k)
10967 ! print *,i,j,gg_lipi(3),gg_lipj(3),sss_ele_cut
10968 ! write (iout,*) "gg",(gg(k),k=1,3)
10970 gvdwx(k,i)=gvdwx(k,i)-gg(k) +gg_lipi(k)&
10971 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
10972 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv &
10975 gvdwx(k,j)=gvdwx(k,j)+gg(k)+gg_lipj(k)&
10976 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
10977 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv &
10980 ! write (iout,*)(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
10981 ! +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
10982 ! write (iout,*)(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
10983 ! +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
10986 ! Calculate the components of the gradient in DC and X
10990 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
10994 gvdwc(l,i)=gvdwc(l,i)-gg(l)+gg_lipi(l)
10995 gvdwc(l,j)=gvdwc(l,j)+gg(l)+gg_lipj(l)
10998 end subroutine sc_grad
11000 !-----------------------------------------------------------------------------
11001 subroutine mixder(thetai,thet_pred_mean,theta0i,E_tc_t)
11004 ! implicit real*8 (a-h,o-z)
11005 ! include 'DIMENSIONS'
11006 ! include 'COMMON.LOCAL'
11007 ! include 'COMMON.IOUNITS'
11008 !el real(kind=8) :: term1,term2,termm,diffak,ratak,&
11009 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
11010 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,
11011 real(kind=8) :: thetai,thet_pred_mean,theta0i,E_tc_t
11012 real(kind=8) :: t3,t6,t9,t12,t14,t16,t21,t23,t26,t27,t32,t40
11014 !el common /calcthet/ term1,term2,termm,diffak,ratak,&
11015 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
11016 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,it
11017 !el local variables
11019 delthec=thetai-thet_pred_mean
11020 delthe0=thetai-theta0i
11021 ! "Thank you" to MAPLE (probably spared one day of hand-differentiation).
11022 t3 = thetai-thet_pred_mean
11026 t14 = t12+t6*sigsqtc
11028 t21 = thetai-theta0i
11034 E_tc_t = -((sigcsq+2.D0*t3*sigsqtc)*t9-t14*sigcsq*t3*t16*t9 &
11035 -aktc*sig0inv*t27)/t32+(t14*t9+aktc*t26)/t40 &
11036 *(-t12*t9-ak*sig0inv*t27)
11038 end subroutine mixder
11040 !-----------------------------------------------------------------------------
11042 !-----------------------------------------------------------------------------
11044 !-----------------------------------------------------------------------------
11045 ! This subroutine calculates the derivatives of the consecutive virtual
11046 ! bond vectors and the SC vectors in the virtual-bond angles theta and
11047 ! virtual-torsional angles phi, as well as the derivatives of SC vectors
11048 ! in the angles alpha and omega, describing the location of a side chain
11049 ! in its local coordinate system.
11051 ! The derivatives are stored in the following arrays:
11053 ! DDCDV - the derivatives of virtual-bond vectors DC in theta and phi.
11054 ! The structure is as follows:
11056 ! dDC(x,2)/dT(3),...,dDC(z,2)/dT(3),0, 0, 0
11057 ! 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)
11058 ! . . . . . . . . . . . . . . . . . .
11059 ! 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)
11063 ! 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)
11065 ! DXDV - the derivatives of the side-chain vectors in theta and phi.
11066 ! The structure is same as above.
11068 ! DCDS - the derivatives of the side chain vectors in the local spherical
11069 ! andgles alph and omega:
11071 ! 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)
11072 ! 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)
11076 ! 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)
11078 ! Version of March '95, based on an early version of November '91.
11080 !**********************************************************************
11081 ! implicit real*8 (a-h,o-z)
11082 ! include 'DIMENSIONS'
11083 ! include 'COMMON.VAR'
11084 ! include 'COMMON.CHAIN'
11085 ! include 'COMMON.DERIV'
11086 ! include 'COMMON.GEO'
11087 ! include 'COMMON.LOCAL'
11088 ! include 'COMMON.INTERACT'
11089 real(kind=8),dimension(3,3,nres) :: drt,rdt,prordt,prodrt !(3,3,maxres)
11090 real(kind=8),dimension(3,3) :: dp,temp
11091 !el real(kind=8) :: fromto(3,3,maxdim) !(3,3,maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
11092 real(kind=8),dimension(3) :: xx,xx1
11093 !el local variables
11094 integer :: i,k,l,j,m,ind,ind1,jjj
11095 real(kind=8) :: alphi,omegi,theta2,dpkl,dpjk,xj,rj,dxoijk,dxoiij,&
11096 tempkl,dsci,cosalphi,sinalphi,cosomegi,sinomegi,cost2,&
11097 sint2,xp,yp,xxp,yyp,zzp,dj
11099 ! common /przechowalnia/ fromto
11100 if(.not. allocated(fromto)) allocate(fromto(3,3,maxdim))
11101 ! get the position of the jth ijth fragment of the chain coordinate system
11102 ! in the fromto array.
11103 ! indmat(i,j)=((2*(nres-2)-i)*(i-1))/2+j-1
11105 ! maxdim=(nres-1)*(nres-2)/2
11106 ! allocate(dcdv(6,maxdim),dxds(6,nres))
11107 ! calculate the derivatives of transformation matrix elements in theta
11110 !el call flush(iout) !el
11112 rdt(1,1,i)=-rt(1,2,i)
11113 rdt(1,2,i)= rt(1,1,i)
11115 rdt(2,1,i)=-rt(2,2,i)
11116 rdt(2,2,i)= rt(2,1,i)
11118 rdt(3,1,i)=-rt(3,2,i)
11119 rdt(3,2,i)= rt(3,1,i)
11123 ! derivatives in phi
11129 drt(2,1,i)= rt(3,1,i)
11130 drt(2,2,i)= rt(3,2,i)
11131 drt(2,3,i)= rt(3,3,i)
11132 drt(3,1,i)=-rt(2,1,i)
11133 drt(3,2,i)=-rt(2,2,i)
11134 drt(3,3,i)=-rt(2,3,i)
11137 ! generate the matrix products of type r(i)t(i)...r(j)t(j)
11143 temp(k,l)=rt(k,l,i)
11148 fromto(k,l,ind)=temp(k,l)
11157 dpkl=dpkl+temp(k,m)*rt(m,l,j)
11160 fromto(k,l,ind)=dpkl
11171 ! Calculate derivatives.
11177 ! Derivatives of DC(i+1) in theta(i+2)
11183 dpjk=dpjk+prod(j,l,i)*rdt(l,k,i)
11186 prordt(j,k,i)=dp(j,k)
11189 dcdv(j,ind1)=vbld(i+1)*dp(j,1)
11192 ! Derivatives of SC(i+1) in theta(i+2)
11194 xx1(1)=-0.5D0*xloc(2,i+1)
11195 xx1(2)= 0.5D0*xloc(1,i+1)
11199 xj=xj+r(j,k,i)*xx1(k)
11206 rj=rj+prod(j,k,i)*xx(k)
11211 ! Derivatives of SC(i+1) in theta(i+3). The have to be handled differently
11212 ! than the other off-diagonal derivatives.
11217 dxoiij=dxoiij+dp(j,k)*xrot(k,i+2)
11219 dxdv(j,ind1+1)=dxoiij
11221 !d print *,ind1+1,(dxdv(j,ind1+1),j=1,3)
11223 ! Derivatives of DC(i+1) in phi(i+2)
11229 dpjk=dpjk+prod(j,l,i)*drt(l,k,i)
11232 prodrt(j,k,i)=dp(j,k)
11234 dcdv(j+3,ind1)=vbld(i+1)*dp(j,1)
11237 ! Derivatives of SC(i+1) in phi(i+2)
11240 xx(3)= xloc(2,i+1)*r(2,2,i)+xloc(3,i+1)*r(2,3,i)
11241 xx(2)=-xloc(2,i+1)*r(3,2,i)-xloc(3,i+1)*r(3,3,i)
11245 rj=rj+prod(j,k,i)*xx(k)
11250 ! Derivatives of SC(i+1) in phi(i+3).
11255 dxoiij=dxoiij+dp(j,k)*xrot(k,i+2)
11257 dxdv(j+3,ind1+1)=dxoiij
11260 ! Calculate the derivatives of DC(i+1) and SC(i+1) in theta(i+3) thru
11261 ! theta(nres) and phi(i+3) thru phi(nres).
11265 ind=indmat(i+1,j+1)
11266 !d print *,'i=',i,' j=',j,' ind=',ind,' ind1=',ind1
11271 tempkl=tempkl+prordt(k,m,i)*fromto(m,l,ind)
11276 !d print '(9f8.3)',((fromto(k,l,ind),l=1,3),k=1,3)
11277 !d print '(9f8.3)',((prod(k,l,i),l=1,3),k=1,3)
11278 !d print '(9f8.3)',((temp(k,l),l=1,3),k=1,3)
11279 ! Derivatives of virtual-bond vectors in theta
11281 dcdv(k,ind1)=vbld(i+1)*temp(k,1)
11283 !d print '(3f8.3)',(dcdv(k,ind1),k=1,3)
11284 ! Derivatives of SC vectors in theta
11288 dxoijk=dxoijk+temp(k,l)*xrot(l,j+2)
11290 dxdv(k,ind1+1)=dxoijk
11293 !--- Calculate the derivatives in phi
11299 tempkl=tempkl+prodrt(k,m,i)*fromto(m,l,ind)
11305 dcdv(k+3,ind1)=vbld(i+1)*temp(k,1)
11310 dxoijk=dxoijk+temp(k,l)*xrot(l,j+2)
11312 dxdv(k+3,ind1+1)=dxoijk
11317 ! Derivatives in alpha and omega:
11320 ! dsci=dsc(itype(i,1))
11325 if(alphi.ne.alphi) alphi=100.0
11326 if(omegi.ne.omegi) omegi=-100.0
11331 !d print *,'i=',i,' dsci=',dsci,' alphi=',alphi,' omegi=',omegi
11332 cosalphi=dcos(alphi)
11333 sinalphi=dsin(alphi)
11334 cosomegi=dcos(omegi)
11335 sinomegi=dsin(omegi)
11336 temp(1,1)=-dsci*sinalphi
11337 temp(2,1)= dsci*cosalphi*cosomegi
11338 temp(3,1)=-dsci*cosalphi*sinomegi
11340 temp(2,2)=-dsci*sinalphi*sinomegi
11341 temp(3,2)=-dsci*sinalphi*cosomegi
11342 theta2=pi-0.5D0*theta(i+1)
11346 !d print *,((temp(l,k),l=1,3),k=1,2)
11350 xxp= xp*cost2+yp*sint2
11351 yyp=-xp*sint2+yp*cost2
11354 xx(2)=yyp*r(2,2,i-1)+zzp*r(2,3,i-1)
11355 xx(3)=yyp*r(3,2,i-1)+zzp*r(3,3,i-1)
11359 dj=dj+prod(k,l,i-1)*xx(l)
11367 end subroutine cartder
11368 !-----------------------------------------------------------------------------
11370 !-----------------------------------------------------------------------------
11371 subroutine check_cartgrad
11372 ! Check the gradient of Cartesian coordinates in internal coordinates.
11373 ! implicit real*8 (a-h,o-z)
11374 ! include 'DIMENSIONS'
11375 ! include 'COMMON.IOUNITS'
11376 ! include 'COMMON.VAR'
11377 ! include 'COMMON.CHAIN'
11378 ! include 'COMMON.GEO'
11379 ! include 'COMMON.LOCAL'
11380 ! include 'COMMON.DERIV'
11381 real(kind=8),dimension(6,nres) :: temp
11382 real(kind=8),dimension(3) :: xx,gg
11383 integer :: i,k,j,ii
11384 real(kind=8) :: aincr,aincr2,alphi,omegi,theti,thet,phii
11385 ! indmat(i,j)=((2*(nres-2)-i)*(i-1))/2+j-1
11387 ! Check the gradient of the virtual-bond and SC vectors in the internal
11393 write (iout,'(a)') '**************** dx/dalpha'
11397 alph(i)=alph(i)+aincr
11399 temp(k,i)=dc(k,nres+i)
11403 gg(k)=(dc(k,nres+i)-temp(k,i))/aincr
11404 xx(k)=dabs((gg(k)-dxds(k,i))/(aincr*dabs(dxds(k,i))+aincr))
11406 write (iout,'(i4,3e15.6/4x,3e15.6,3f9.3)') &
11407 i,(gg(k),k=1,3),(dxds(k,i),k=1,3),(xx(k),k=1,3)
11413 write (iout,'(a)') '**************** dx/domega'
11417 omeg(i)=omeg(i)+aincr
11419 temp(k,i)=dc(k,nres+i)
11423 gg(k)=(dc(k,nres+i)-temp(k,i))/aincr
11424 xx(k)=dabs((gg(k)-dxds(k+3,i))/ &
11425 (aincr*dabs(dxds(k+3,i))+aincr))
11427 write (iout,'(i4,3e15.6/4x,3e15.6,3f9.3)') &
11428 i,(gg(k),k=1,3),(dxds(k+3,i),k=1,3),(xx(k),k=1,3)
11434 write (iout,'(a)') '**************** dx/dtheta'
11438 theta(i)=theta(i)+aincr
11441 temp(k,j)=dc(k,nres+j)
11447 ! print *,'i=',i-2,' j=',j-1,' ii=',ii
11449 gg(k)=(dc(k,nres+j)-temp(k,j))/aincr
11450 xx(k)=dabs((gg(k)-dxdv(k,ii))/ &
11451 (aincr*dabs(dxdv(k,ii))+aincr))
11453 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
11454 i,j,(gg(k),k=1,3),(dxdv(k,ii),k=1,3),(xx(k),k=1,3)
11461 write (iout,'(a)') '***************** dx/dphi'
11464 phi(i)=phi(i)+aincr
11467 temp(k,j)=dc(k,nres+j)
11475 gg(k)=(dc(k,nres+j)-temp(k,j))/aincr
11476 xx(k)=dabs((gg(k)-dxdv(k+3,ii))/ &
11477 (aincr*dabs(dxdv(k+3,ii))+aincr))
11479 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
11480 i,j,(gg(k),k=1,3),(dxdv(k+3,ii),k=1,3),(xx(k),k=1,3)
11483 phi(i)=phi(i)-aincr
11486 write (iout,'(a)') '****************** ddc/dtheta'
11489 theta(i+2)=thet+aincr
11500 gg(k)=(dc(k,j)-temp(k,j))/aincr
11501 xx(k)=dabs((gg(k)-dcdv(k,ii))/ &
11502 (aincr*dabs(dcdv(k,ii))+aincr))
11504 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
11505 i,j,(gg(k),k=1,3),(dcdv(k,ii),k=1,3),(xx(k),k=1,3)
11515 write (iout,'(a)') '******************* ddc/dphi'
11518 phi(i+3)=phii+aincr
11529 gg(k)=(dc(k,j)-temp(k,j))/aincr
11530 xx(k)=dabs((gg(k)-dcdv(k+3,ii))/ &
11531 (aincr*dabs(dcdv(k+3,ii))+aincr))
11533 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
11534 i,j,(gg(k),k=1,3),(dcdv(k+3,ii),k=1,3),(xx(k),k=1,3)
11545 end subroutine check_cartgrad
11546 !-----------------------------------------------------------------------------
11547 subroutine check_ecart
11548 ! Check the gradient of the energy in Cartesian coordinates.
11549 ! implicit real*8 (a-h,o-z)
11550 ! include 'DIMENSIONS'
11551 ! include 'COMMON.CHAIN'
11552 ! include 'COMMON.DERIV'
11553 ! include 'COMMON.IOUNITS'
11554 ! include 'COMMON.VAR'
11555 ! include 'COMMON.CONTACTS'
11557 !el integer :: icall
11558 !el common /srutu/ icall
11559 real(kind=8),dimension(6) :: ggg
11560 real(kind=8),dimension(3) :: cc,xx,ddc,ddx
11561 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
11562 real(kind=8),dimension(6,nres) :: grad_s
11563 real(kind=8),dimension(0:n_ene) :: energia,energia1
11564 integer :: uiparm(1)
11565 real(kind=8) :: urparm(1)
11567 integer :: nf,i,j,k
11568 real(kind=8) :: aincr,etot,etot1
11574 print '(a)','CG processor',me,' calling CHECK_CART.',aincr
11577 call geom_to_var(nvar,x)
11578 call etotal(energia)
11580 !el call enerprint(energia)
11581 call gradient(nvar,x,nf,g,uiparm,urparm,fdum)
11584 write (iout,'(i5,3f10.5)') i,(gradxorr(j,i),j=1,3)
11588 grad_s(j,i)=gradc(j,i,icg)
11589 grad_s(j+3,i)=gradx(j,i,icg)
11593 write (iout,'(/a/)') 'Gradient in virtual-bond and SC vectors'
11598 ddx(j)=dc(j,i+nres)
11601 dc(j,i)=dc(j,i)+aincr
11603 c(j,k)=c(j,k)+aincr
11604 c(j,k+nres)=c(j,k+nres)+aincr
11606 call etotal(energia1)
11608 ggg(j)=(etot1-etot)/aincr
11611 c(j,k)=c(j,k)-aincr
11612 c(j,k+nres)=c(j,k+nres)-aincr
11616 c(j,i+nres)=c(j,i+nres)+aincr
11617 dc(j,i+nres)=dc(j,i+nres)+aincr
11618 call etotal(energia1)
11620 ggg(j+3)=(etot1-etot)/aincr
11622 dc(j,i+nres)=ddx(j)
11624 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/)') &
11625 i,(ggg(k),k=1,6),(grad_s(k,i),k=1,6)
11628 end subroutine check_ecart
11630 !-----------------------------------------------------------------------------
11631 subroutine check_ecartint
11632 ! Check the gradient of the energy in Cartesian coordinates.
11633 use io_base, only: intout
11634 ! implicit real*8 (a-h,o-z)
11635 ! include 'DIMENSIONS'
11636 ! include 'COMMON.CONTROL'
11637 ! include 'COMMON.CHAIN'
11638 ! include 'COMMON.DERIV'
11639 ! include 'COMMON.IOUNITS'
11640 ! include 'COMMON.VAR'
11641 ! include 'COMMON.CONTACTS'
11642 ! include 'COMMON.MD'
11643 ! include 'COMMON.LOCAL'
11644 ! include 'COMMON.SPLITELE'
11646 !el integer :: icall
11647 !el common /srutu/ icall
11648 real(kind=8),dimension(6) :: ggg,ggg1
11649 real(kind=8),dimension(3) :: cc,xx,ddc,ddx,ddc1,ddcn
11650 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
11651 real(kind=8),dimension(3) :: dcnorm_safe1,dcnorm_safe2,dxnorm_safe
11652 real(kind=8),dimension(6,0:nres) :: grad_s,grad_s1 !(6,0:maxres)
11653 real(kind=8),dimension(nres) :: phi_temp,theta_temp,alph_temp,omeg_temp !(maxres)
11654 real(kind=8),dimension(0:n_ene) :: energia,energia1
11655 integer :: uiparm(1)
11656 real(kind=8) :: urparm(1)
11658 integer :: i,j,k,nf
11659 real(kind=8) :: rlambd,aincr,etot,etot1,etot11,etot12,etot2,&
11667 ! call intcartderiv
11668 ! call checkintcartgrad
11671 write(iout,*) 'Calling CHECK_ECARTINT.'
11674 write (iout,*) "Before geom_to_var"
11675 call geom_to_var(nvar,x)
11676 write (iout,*) "after geom_to_var"
11677 write (iout,*) "split_ene ",split_ene
11679 if (.not.split_ene) then
11680 write(iout,*) 'Calling CHECK_ECARTINT if'
11681 call etotal(energia)
11682 !elwrite(iout,*) 'Calling CHECK_ECARTINT if'
11684 write (iout,*) "etot",etot
11686 !el call enerprint(energia)
11687 !elwrite(iout,*) 'Calling CHECK_ECARTINT if'
11689 write (iout,*) "enter cartgrad"
11692 !elwrite(iout,*) 'Calling CHECK_ECARTINT if'
11693 write (iout,*) "exit cartgrad"
11697 write (iout,'(i5,3f10.5)') i,(gradxorr(j,i),j=1,3)
11700 grad_s(j,0)=gcart(j,0)
11702 !elwrite(iout,*) 'Calling CHECK_ECARTINT if'
11705 grad_s(j,i)=gcart(j,i)
11706 grad_s(j+3,i)=gxcart(j,i)
11710 write(iout,*) 'Calling CHECK_ECARTIN else.'
11711 !- split gradient check
11713 call etotal_long(energia)
11714 !el call enerprint(energia)
11716 write (iout,*) "enter cartgrad"
11719 write (iout,*) "exit cartgrad"
11722 write (iout,*) "longrange grad"
11724 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
11725 (gxcart(j,i),j=1,3)
11728 grad_s(j,0)=gcart(j,0)
11732 grad_s(j,i)=gcart(j,i)
11733 grad_s(j+3,i)=gxcart(j,i)
11737 call etotal_short(energia)
11738 call enerprint(energia)
11740 write (iout,*) "enter cartgrad"
11743 write (iout,*) "exit cartgrad"
11746 write (iout,*) "shortrange grad"
11748 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
11749 (gxcart(j,i),j=1,3)
11752 grad_s1(j,0)=gcart(j,0)
11756 grad_s1(j,i)=gcart(j,i)
11757 grad_s1(j+3,i)=gxcart(j,i)
11761 write (iout,'(/a/)') 'Gradient in virtual-bond and SC vectors'
11765 if (nnt.gt.1 .and. i.eq.nnt) ddc1(j)=c(j,1)
11766 if (nct.lt.nres .and. i.eq.nct) ddcn(j)=c(j,nres)
11769 dcnorm_safe1(j)=dc_norm(j,i-1)
11770 dcnorm_safe2(j)=dc_norm(j,i)
11771 dxnorm_safe(j)=dc_norm(j,i+nres)
11774 c(j,i)=ddc(j)+aincr
11775 if (nnt.gt.1 .and. i.eq.nnt) c(j,1)=c(j,1)+aincr
11776 if (nct.lt.nres .and. i.eq.nct) c(j,nres)=c(j,nres)+aincr
11777 if (i.gt.1) dc(j,i-1)=c(j,i)-c(j,i-1)
11778 dc(j,i)=c(j,i+1)-c(j,i)
11779 dc(j,i+nres)=c(j,i+nres)-c(j,i)
11780 call int_from_cart1(.false.)
11781 if (.not.split_ene) then
11782 call etotal(energia1)
11784 write (iout,*) "ij",i,j," etot1",etot1
11787 call etotal_long(energia1)
11789 call etotal_short(energia1)
11792 !- end split gradient
11793 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot1",etot1
11794 c(j,i)=ddc(j)-aincr
11795 if (nnt.gt.1 .and. i.eq.nnt) c(j,1)=ddc1(j)-aincr
11796 if (nct.lt.nres .and. i.eq.nct) c(j,nres)=ddcn(j)-aincr
11797 if (i.gt.1) dc(j,i-1)=c(j,i)-c(j,i-1)
11798 dc(j,i)=c(j,i+1)-c(j,i)
11799 dc(j,i+nres)=c(j,i+nres)-c(j,i)
11800 call int_from_cart1(.false.)
11801 if (.not.split_ene) then
11802 call etotal(energia1)
11804 write (iout,*) "ij",i,j," etot2",etot2
11805 ggg(j)=(etot1-etot2)/(2*aincr)
11808 call etotal_long(energia1)
11810 ggg(j)=(etot11-etot21)/(2*aincr)
11811 call etotal_short(energia1)
11813 ggg1(j)=(etot12-etot22)/(2*aincr)
11814 !- end split gradient
11815 ! write (iout,*) "etot21",etot21," etot22",etot22
11817 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
11819 if (nnt.gt.1 .and. i.eq.nnt) c(j,1)=ddc1(j)
11820 if (nct.lt.nres .and. i.eq.nct) c(j,nres)=ddcn(j)
11821 if (i.gt.1) dc(j,i-1)=c(j,i)-c(j,i-1)
11822 dc(j,i)=c(j,i+1)-c(j,i)
11823 dc(j,i+nres)=c(j,i+nres)-c(j,i)
11824 dc_norm(j,i-1)=dcnorm_safe1(j)
11825 dc_norm(j,i)=dcnorm_safe2(j)
11826 dc_norm(j,i+nres)=dxnorm_safe(j)
11829 c(j,i+nres)=ddx(j)+aincr
11830 dc(j,i+nres)=c(j,i+nres)-c(j,i)
11831 call int_from_cart1(.false.)
11832 if (.not.split_ene) then
11833 call etotal(energia1)
11837 call etotal_long(energia1)
11839 call etotal_short(energia1)
11842 !- end split gradient
11843 c(j,i+nres)=ddx(j)-aincr
11844 dc(j,i+nres)=c(j,i+nres)-c(j,i)
11845 call int_from_cart1(.false.)
11846 if (.not.split_ene) then
11847 call etotal(energia1)
11849 ggg(j+3)=(etot1-etot2)/(2*aincr)
11852 call etotal_long(energia1)
11854 ggg(j+3)=(etot11-etot21)/(2*aincr)
11855 call etotal_short(energia1)
11857 ggg1(j+3)=(etot12-etot22)/(2*aincr)
11858 !- end split gradient
11860 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
11862 dc(j,i+nres)=c(j,i+nres)-c(j,i)
11863 dc_norm(j,i+nres)=dxnorm_safe(j)
11864 call int_from_cart1(.false.)
11866 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
11867 i,(ggg(k),k=1,6),(grad_s(k,i),k=1,6),(ggg(k)/grad_s(k,i),k=1,6)
11868 if (split_ene) then
11869 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
11870 i,(ggg1(k),k=1,6),(grad_s1(k,i),k=1,6),(ggg1(k)/grad_s1(k,i),&
11872 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
11873 i,(ggg(k)+ggg1(k),k=1,6),(grad_s(k,i)+grad_s1(k,i),k=1,6),&
11874 ((ggg(k)+ggg1(k))/(grad_s(k,i)+grad_s1(k,i)),k=1,6)
11878 end subroutine check_ecartint
11880 !-----------------------------------------------------------------------------
11881 subroutine check_ecartint
11882 ! Check the gradient of the energy in Cartesian coordinates.
11883 use io_base, only: intout
11884 ! implicit real*8 (a-h,o-z)
11885 ! include 'DIMENSIONS'
11886 ! include 'COMMON.CONTROL'
11887 ! include 'COMMON.CHAIN'
11888 ! include 'COMMON.DERIV'
11889 ! include 'COMMON.IOUNITS'
11890 ! include 'COMMON.VAR'
11891 ! include 'COMMON.CONTACTS'
11892 ! include 'COMMON.MD'
11893 ! include 'COMMON.LOCAL'
11894 ! include 'COMMON.SPLITELE'
11896 !el integer :: icall
11897 !el common /srutu/ icall
11898 real(kind=8),dimension(6) :: ggg,ggg1
11899 real(kind=8),dimension(3) :: cc,xx,ddc,ddx
11900 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
11901 real(kind=8),dimension(3) :: dcnorm_safe,dxnorm_safe
11902 real(kind=8),dimension(6,0:nres) :: grad_s,grad_s1 !(6,0:maxres)
11903 real(kind=8),dimension(nres) :: phi_temp,theta_temp,alph_temp,omeg_temp !(maxres)
11904 real(kind=8),dimension(0:n_ene) :: energia,energia1
11905 integer :: uiparm(1)
11906 real(kind=8) :: urparm(1)
11908 integer :: i,j,k,nf
11909 real(kind=8) :: rlambd,aincr,etot,etot1,etot11,etot12,etot2,&
11917 ! call intcartderiv
11918 ! call checkintcartgrad
11921 write(iout,*) 'Calling CHECK_ECARTINT.',aincr
11924 call geom_to_var(nvar,x)
11925 if (.not.split_ene) then
11926 call etotal(energia)
11928 !el call enerprint(energia)
11930 write (iout,*) "enter cartgrad"
11933 write (iout,*) "exit cartgrad"
11937 write (iout,'(i5,3f10.5)') i,(gradxorr(j,i),j=1,3)
11940 grad_s(j,0)=gcart(j,0)
11944 grad_s(j,i)=gcart(j,i)
11945 ! if (i.le.2) print *,"tu?!",gcart(j,i),grad_s(j,i),gxcart(j,i)
11946 grad_s(j+3,i)=gxcart(j,i)
11950 !- split gradient check
11952 call etotal_long(energia)
11953 !el call enerprint(energia)
11955 write (iout,*) "enter cartgrad"
11958 write (iout,*) "exit cartgrad"
11961 write (iout,*) "longrange grad"
11963 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
11964 (gxcart(j,i),j=1,3)
11967 grad_s(j,0)=gcart(j,0)
11971 grad_s(j,i)=gcart(j,i)
11972 grad_s(j+3,i)=gxcart(j,i)
11976 call etotal_short(energia)
11977 !el call enerprint(energia)
11979 write (iout,*) "enter cartgrad"
11982 write (iout,*) "exit cartgrad"
11985 write (iout,*) "shortrange grad"
11987 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
11988 (gxcart(j,i),j=1,3)
11991 grad_s1(j,0)=gcart(j,0)
11995 grad_s1(j,i)=gcart(j,i)
11996 grad_s1(j+3,i)=gxcart(j,i)
12000 write (iout,'(/a/)') 'Gradient in virtual-bond and SC vectors'
12005 ddx(j)=dc(j,i+nres)
12007 dcnorm_safe(k)=dc_norm(k,i)
12008 dxnorm_safe(k)=dc_norm(k,i+nres)
12012 dc(j,i)=ddc(j)+aincr
12013 call chainbuild_cart
12015 ! Broadcast the order to compute internal coordinates to the slaves.
12016 ! if (nfgtasks.gt.1)
12017 ! & call MPI_Bcast(6,1,MPI_INTEGER,king,FG_COMM,IERROR)
12019 ! call int_from_cart1(.false.)
12020 if (.not.split_ene) then
12021 call etotal(energia1)
12023 ! call enerprint(energia1)
12026 call etotal_long(energia1)
12028 call etotal_short(energia1)
12030 ! write (iout,*) "etot11",etot11," etot12",etot12
12032 !- end split gradient
12033 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot1",etot1
12034 dc(j,i)=ddc(j)-aincr
12035 call chainbuild_cart
12036 ! call int_from_cart1(.false.)
12037 if (.not.split_ene) then
12038 call etotal(energia1)
12040 ggg(j)=(etot1-etot2)/(2*aincr)
12043 call etotal_long(energia1)
12045 ggg(j)=(etot11-etot21)/(2*aincr)
12046 call etotal_short(energia1)
12048 ggg1(j)=(etot12-etot22)/(2*aincr)
12049 !- end split gradient
12050 ! write (iout,*) "etot21",etot21," etot22",etot22
12052 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
12054 call chainbuild_cart
12057 dc(j,i+nres)=ddx(j)+aincr
12058 call chainbuild_cart
12059 ! write (iout,*) "i",i," j",j," dxnorm+ and dxnorm"
12060 ! write (iout,'(3f15.10)') (dc_norm(k,i+nres),k=1,3)
12061 ! write (iout,'(3f15.10)') (dxnorm_safe(k),k=1,3)
12062 ! write (iout,*) "dxnormnorm",dsqrt(
12063 ! & dc_norm(1,i+nres)**2+dc_norm(2,i+nres)**2+dc_norm(3,i+nres)**2)
12064 ! write (iout,*) "dxnormnormsafe",dsqrt(
12065 ! & dxnorm_safe(1)**2+dxnorm_safe(2)**2+dxnorm_safe(3)**2)
12067 if (.not.split_ene) then
12068 call etotal(energia1)
12072 call etotal_long(energia1)
12074 call etotal_short(energia1)
12077 !- end split gradient
12078 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot1",etot1
12079 dc(j,i+nres)=ddx(j)-aincr
12080 call chainbuild_cart
12081 ! write (iout,*) "i",i," j",j," dxnorm- and dxnorm"
12082 ! write (iout,'(3f15.10)') (dc_norm(k,i+nres),k=1,3)
12083 ! write (iout,'(3f15.10)') (dxnorm_safe(k),k=1,3)
12085 ! write (iout,*) "dxnormnorm",dsqrt(
12086 ! & dc_norm(1,i+nres)**2+dc_norm(2,i+nres)**2+dc_norm(3,i+nres)**2)
12087 ! write (iout,*) "dxnormnormsafe",dsqrt(
12088 ! & dxnorm_safe(1)**2+dxnorm_safe(2)**2+dxnorm_safe(3)**2)
12089 if (.not.split_ene) then
12090 call etotal(energia1)
12092 ggg(j+3)=(etot1-etot2)/(2*aincr)
12095 call etotal_long(energia1)
12097 ggg(j+3)=(etot11-etot21)/(2*aincr)
12098 call etotal_short(energia1)
12100 ggg1(j+3)=(etot12-etot22)/(2*aincr)
12101 !- end split gradient
12103 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
12104 dc(j,i+nres)=ddx(j)
12105 call chainbuild_cart
12107 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
12108 i,(ggg(k),k=1,6),(grad_s(k,i),k=1,6),(ggg(k)/grad_s(k,i),k=1,6)
12109 if (split_ene) then
12110 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
12111 i,(ggg1(k),k=1,6),(grad_s1(k,i),k=1,6),(ggg1(k)/grad_s1(k,i),&
12113 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
12114 i,(ggg(k)+ggg1(k),k=1,6),(grad_s(k,i)+grad_s1(k,i),k=1,6),&
12115 ((ggg(k)+ggg1(k))/(grad_s(k,i)+grad_s1(k,i)),k=1,6)
12119 end subroutine check_ecartint
12121 !-----------------------------------------------------------------------------
12122 subroutine check_eint
12123 ! Check the gradient of energy in internal coordinates.
12124 ! implicit real*8 (a-h,o-z)
12125 ! include 'DIMENSIONS'
12126 ! include 'COMMON.CHAIN'
12127 ! include 'COMMON.DERIV'
12128 ! include 'COMMON.IOUNITS'
12129 ! include 'COMMON.VAR'
12130 ! include 'COMMON.GEO'
12132 !el integer :: icall
12133 !el common /srutu/ icall
12134 real(kind=8),dimension(6*nres) :: x,gana,gg !(maxvar) (maxvar=6*maxres)
12135 integer :: uiparm(1)
12136 real(kind=8) :: urparm(1)
12137 real(kind=8),dimension(0:n_ene) :: energia,energia1,energia2
12138 character(len=6) :: key
12141 real(kind=8) :: xi,aincr,etot,etot1,etot2
12144 print '(a)','Calling CHECK_INT.'
12148 call geom_to_var(nvar,x)
12149 call var_to_geom(nvar,x)
12152 ! print *,'ICG=',ICG
12153 call etotal(energia)
12155 !el call enerprint(energia)
12156 ! print *,'ICG=',ICG
12158 if (MyID.ne.BossID) then
12159 call mp_bcast(x(1),8*(nvar+3),BossID,fgGroupID)
12167 !d write (iout,'(10f8.3)') (rad2deg*x(i),i=1,nvar)
12168 call gradient(nvar,x,nf,gana,uiparm,urparm,fdum)
12169 !d write (iout,'(i3,1pe14.4)') (i,gana(i),i=1,nvar+20) !sp
12173 x(i)=xi-0.5D0*aincr
12174 call var_to_geom(nvar,x)
12176 call etotal(energia1)
12178 x(i)=xi+0.5D0*aincr
12179 call var_to_geom(nvar,x)
12181 call etotal(energia2)
12183 gg(i)=(etot2-etot1)/aincr
12184 write (iout,*) i,etot1,etot2
12187 write (iout,'(/2a)')' Variable Numerical Analytical',&
12190 if (i.le.nphi) then
12193 else if (i.le.nphi+ntheta) then
12196 else if (i.le.nphi+ntheta+nside) then
12200 ii=i-(nphi+ntheta+nside)
12203 write (iout,'(i3,a,i3,3(1pd16.6))') &
12204 i,key,ii,gg(i),gana(i),&
12205 100.0D0*dabs(gg(i)-gana(i))/(dabs(gana(i))+aincr)
12208 end subroutine check_eint
12209 !-----------------------------------------------------------------------------
12211 !-----------------------------------------------------------------------------
12212 subroutine Econstr_back
12213 ! MD with umbrella_sampling using Wolyne's distance measure as a constraint
12214 ! implicit real*8 (a-h,o-z)
12215 ! include 'DIMENSIONS'
12216 ! include 'COMMON.CONTROL'
12217 ! include 'COMMON.VAR'
12218 ! include 'COMMON.MD'
12221 ! include 'COMMON.LANGEVIN'
12223 ! include 'COMMON.LANGEVIN.lang0'
12225 ! include 'COMMON.CHAIN'
12226 ! include 'COMMON.DERIV'
12227 ! include 'COMMON.GEO'
12228 ! include 'COMMON.LOCAL'
12229 ! include 'COMMON.INTERACT'
12230 ! include 'COMMON.IOUNITS'
12231 ! include 'COMMON.NAMES'
12232 ! include 'COMMON.TIME1'
12233 integer :: i,j,ii,k
12234 real(kind=8) :: utheta_i,dtheta_i,ugamma_i,dgamma_i,dxx,dyy,dzz
12236 if(.not.allocated(utheta)) allocate(utheta(nfrag_back))
12237 if(.not.allocated(ugamma)) allocate(ugamma(nfrag_back))
12238 if(.not.allocated(uscdiff)) allocate(uscdiff(nfrag_back))
12245 duscdiff(j,i)=0.0d0
12246 duscdiffx(j,i)=0.0d0
12250 ii = ifrag_back(2,i,iset)-ifrag_back(1,i,iset)
12252 ! Deviations from theta angles
12255 do j=ifrag_back(1,i,iset)+2,ifrag_back(2,i,iset)
12256 dtheta_i=theta(j)-thetaref(j)
12257 utheta_i=utheta_i+0.5d0*dtheta_i*dtheta_i
12258 dutheta(j-2)=dutheta(j-2)+wfrag_back(1,i,iset)*dtheta_i/(ii-1)
12260 utheta(i)=utheta_i/(ii-1)
12262 ! Deviations from gamma angles
12265 do j=ifrag_back(1,i,iset)+3,ifrag_back(2,i,iset)
12266 dgamma_i=pinorm(phi(j)-phiref(j))
12267 ! write (iout,*) j,phi(j),phi(j)-phiref(j)
12268 ugamma_i=ugamma_i+0.5d0*dgamma_i*dgamma_i
12269 dugamma(j-3)=dugamma(j-3)+wfrag_back(2,i,iset)*dgamma_i/(ii-2)
12270 ! write (iout,*) i,j,dgamma_i,wfrag_back(2,i,iset),dugamma(j-3)
12272 ugamma(i)=ugamma_i/(ii-2)
12274 ! Deviations from local SC geometry
12277 do j=ifrag_back(1,i,iset)+1,ifrag_back(2,i,iset)-1
12278 dxx=xxtab(j)-xxref(j)
12279 dyy=yytab(j)-yyref(j)
12280 dzz=zztab(j)-zzref(j)
12281 uscdiff(i)=uscdiff(i)+dxx*dxx+dyy*dyy+dzz*dzz
12283 duscdiff(k,j-1)=duscdiff(k,j-1)+wfrag_back(3,i,iset)* &
12284 (dXX_C1tab(k,j)*dxx+dYY_C1tab(k,j)*dyy+dZZ_C1tab(k,j)*dzz)/ &
12286 duscdiff(k,j)=duscdiff(k,j)+wfrag_back(3,i,iset)* &
12287 (dXX_Ctab(k,j)*dxx+dYY_Ctab(k,j)*dyy+dZZ_Ctab(k,j)*dzz)/ &
12289 duscdiffx(k,j)=duscdiffx(k,j)+wfrag_back(3,i,iset)* &
12290 (dXX_XYZtab(k,j)*dxx+dYY_XYZtab(k,j)*dyy+dZZ_XYZtab(k,j)*dzz) &
12293 ! write (iout,'(i5,6f10.5)') j,xxtab(j),yytab(j),zztab(j),
12294 ! & xxref(j),yyref(j),zzref(j)
12296 uscdiff(i)=0.5d0*uscdiff(i)/(ii-1)
12297 ! write (iout,*) i," uscdiff",uscdiff(i)
12299 ! Put together deviations from local geometry
12301 Uconst_back=Uconst_back+wfrag_back(1,i,iset)*utheta(i)+ &
12302 wfrag_back(2,i,iset)*ugamma(i)+wfrag_back(3,i,iset)*uscdiff(i)
12303 ! write(iout,*) "i",i," utheta",utheta(i)," ugamma",ugamma(i),
12304 ! & " uconst_back",uconst_back
12305 utheta(i)=dsqrt(utheta(i))
12306 ugamma(i)=dsqrt(ugamma(i))
12307 uscdiff(i)=dsqrt(uscdiff(i))
12310 end subroutine Econstr_back
12311 !-----------------------------------------------------------------------------
12312 ! energy_p_new-sep_barrier.F
12313 !-----------------------------------------------------------------------------
12314 real(kind=8) function sscale(r)
12315 ! include "COMMON.SPLITELE"
12316 real(kind=8) :: r,gamm
12317 if(r.lt.r_cut-rlamb) then
12319 else if(r.le.r_cut.and.r.ge.r_cut-rlamb) then
12320 gamm=(r-(r_cut-rlamb))/rlamb
12321 sscale=1.0d0+gamm*gamm*(2*gamm-3.0d0)
12326 end function sscale
12327 real(kind=8) function sscale_grad(r)
12328 ! include "COMMON.SPLITELE"
12329 real(kind=8) :: r,gamm
12330 if(r.lt.r_cut-rlamb) then
12332 else if(r.le.r_cut.and.r.ge.r_cut-rlamb) then
12333 gamm=(r-(r_cut-rlamb))/rlamb
12334 sscale_grad=gamm*(6*gamm-6.0d0)/rlamb
12339 end function sscale_grad
12341 !!!!!!!!!! PBCSCALE
12342 real(kind=8) function sscale_ele(r)
12343 ! include "COMMON.SPLITELE"
12344 real(kind=8) :: r,gamm
12345 if(r.lt.r_cut_ele-rlamb_ele) then
12347 else if(r.le.r_cut_ele.and.r.ge.r_cut_ele-rlamb_ele) then
12348 gamm=(r-(r_cut_ele-rlamb_ele))/rlamb_ele
12349 sscale_ele=1.0d0+gamm*gamm*(2*gamm-3.0d0)
12354 end function sscale_ele
12356 real(kind=8) function sscagrad_ele(r)
12357 real(kind=8) :: r,gamm
12358 ! include "COMMON.SPLITELE"
12359 if(r.lt.r_cut_ele-rlamb_ele) then
12361 else if(r.le.r_cut_ele.and.r.ge.r_cut_ele-rlamb_ele) then
12362 gamm=(r-(r_cut_ele-rlamb_ele))/rlamb_ele
12363 sscagrad_ele=gamm*(6*gamm-6.0d0)/rlamb_ele
12368 end function sscagrad_ele
12369 real(kind=8) function sscalelip(r)
12370 real(kind=8) r,gamm
12371 sscalelip=1.0d0+r*r*(2.0d0*r-3.0d0)
12373 end function sscalelip
12374 !C-----------------------------------------------------------------------
12375 real(kind=8) function sscagradlip(r)
12376 real(kind=8) r,gamm
12377 sscagradlip=r*(6.0d0*r-6.0d0)
12379 end function sscagradlip
12382 !-----------------------------------------------------------------------------
12383 subroutine elj_long(evdw)
12385 ! This subroutine calculates the interaction energy of nonbonded side chains
12386 ! assuming the LJ potential of interaction.
12388 ! implicit real*8 (a-h,o-z)
12389 ! include 'DIMENSIONS'
12390 ! include 'COMMON.GEO'
12391 ! include 'COMMON.VAR'
12392 ! include 'COMMON.LOCAL'
12393 ! include 'COMMON.CHAIN'
12394 ! include 'COMMON.DERIV'
12395 ! include 'COMMON.INTERACT'
12396 ! include 'COMMON.TORSION'
12397 ! include 'COMMON.SBRIDGE'
12398 ! include 'COMMON.NAMES'
12399 ! include 'COMMON.IOUNITS'
12400 ! include 'COMMON.CONTACTS'
12401 real(kind=8),parameter :: accur=1.0d-10
12402 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
12403 !el local variables
12404 integer :: i,iint,j,k,itypi,itypi1,itypj
12405 real(kind=8) :: xi,yi,zi,xj,yj,zj,rij,sss,rrij,fac,eps0ij
12406 real(kind=8) :: e1,e2,evdwij,evdw
12407 ! write(iout,*)'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
12409 do i=iatsc_s,iatsc_e
12411 if (itypi.eq.ntyp1) cycle
12412 itypi1=itype(i+1,1)
12417 ! Calculate SC interaction energy.
12419 do iint=1,nint_gr(i)
12420 !d write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
12421 !d & 'iend=',iend(i,iint)
12422 do j=istart(i,iint),iend(i,iint)
12424 if (itypj.eq.ntyp1) cycle
12428 rij=xj*xj+yj*yj+zj*zj
12429 sss=sscale(dsqrt(rij)/sigma(itypi,itypj))
12430 if (sss.lt.1.0d0) then
12432 eps0ij=eps(itypi,itypj)
12434 e1=fac*fac*aa_aq(itypi,itypj)
12435 e2=fac*bb_aq(itypi,itypj)
12437 evdw=evdw+(1.0d0-sss)*evdwij
12439 ! Calculate the components of the gradient in DC and X
12441 fac=-rrij*(e1+evdwij)*(1.0d0-sss)
12446 gvdwx(k,i)=gvdwx(k,i)-gg(k)
12447 gvdwx(k,j)=gvdwx(k,j)+gg(k)
12448 gvdwc(k,i)=gvdwc(k,i)-gg(k)
12449 gvdwc(k,j)=gvdwc(k,j)+gg(k)
12457 gvdwc(j,i)=expon*gvdwc(j,i)
12458 gvdwx(j,i)=expon*gvdwx(j,i)
12461 !******************************************************************************
12465 ! To save time, the factor of EXPON has been extracted from ALL components
12466 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
12469 !******************************************************************************
12471 end subroutine elj_long
12472 !-----------------------------------------------------------------------------
12473 subroutine elj_short(evdw)
12475 ! This subroutine calculates the interaction energy of nonbonded side chains
12476 ! assuming the LJ potential of interaction.
12478 ! implicit real*8 (a-h,o-z)
12479 ! include 'DIMENSIONS'
12480 ! include 'COMMON.GEO'
12481 ! include 'COMMON.VAR'
12482 ! include 'COMMON.LOCAL'
12483 ! include 'COMMON.CHAIN'
12484 ! include 'COMMON.DERIV'
12485 ! include 'COMMON.INTERACT'
12486 ! include 'COMMON.TORSION'
12487 ! include 'COMMON.SBRIDGE'
12488 ! include 'COMMON.NAMES'
12489 ! include 'COMMON.IOUNITS'
12490 ! include 'COMMON.CONTACTS'
12491 real(kind=8),parameter :: accur=1.0d-10
12492 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
12493 !el local variables
12494 integer :: i,iint,j,k,itypi,itypi1,itypj,num_conti
12495 real(kind=8) :: xi,yi,zi,xj,yj,zj,rij,sss,rrij,fac,eps0ij
12496 real(kind=8) :: e1,e2,evdwij,evdw
12497 ! write(iout,*)'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
12499 do i=iatsc_s,iatsc_e
12501 if (itypi.eq.ntyp1) cycle
12502 itypi1=itype(i+1,1)
12509 ! Calculate SC interaction energy.
12511 do iint=1,nint_gr(i)
12512 !d write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
12513 !d & 'iend=',iend(i,iint)
12514 do j=istart(i,iint),iend(i,iint)
12516 if (itypj.eq.ntyp1) cycle
12520 ! Change 12/1/95 to calculate four-body interactions
12521 rij=xj*xj+yj*yj+zj*zj
12522 sss=sscale(dsqrt(rij)/sigma(itypi,itypj))
12523 if (sss.gt.0.0d0) then
12525 eps0ij=eps(itypi,itypj)
12527 e1=fac*fac*aa_aq(itypi,itypj)
12528 e2=fac*bb_aq(itypi,itypj)
12530 evdw=evdw+sss*evdwij
12532 ! Calculate the components of the gradient in DC and X
12534 fac=-rrij*(e1+evdwij)*sss
12539 gvdwx(k,i)=gvdwx(k,i)-gg(k)
12540 gvdwx(k,j)=gvdwx(k,j)+gg(k)
12541 gvdwc(k,i)=gvdwc(k,i)-gg(k)
12542 gvdwc(k,j)=gvdwc(k,j)+gg(k)
12550 gvdwc(j,i)=expon*gvdwc(j,i)
12551 gvdwx(j,i)=expon*gvdwx(j,i)
12554 !******************************************************************************
12558 ! To save time, the factor of EXPON has been extracted from ALL components
12559 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
12562 !******************************************************************************
12564 end subroutine elj_short
12565 !-----------------------------------------------------------------------------
12566 subroutine eljk_long(evdw)
12568 ! This subroutine calculates the interaction energy of nonbonded side chains
12569 ! assuming the LJK potential of interaction.
12571 ! implicit real*8 (a-h,o-z)
12572 ! include 'DIMENSIONS'
12573 ! include 'COMMON.GEO'
12574 ! include 'COMMON.VAR'
12575 ! include 'COMMON.LOCAL'
12576 ! include 'COMMON.CHAIN'
12577 ! include 'COMMON.DERIV'
12578 ! include 'COMMON.INTERACT'
12579 ! include 'COMMON.IOUNITS'
12580 ! include 'COMMON.NAMES'
12581 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
12583 !el local variables
12584 integer :: i,iint,j,k,itypi,itypi1,itypj
12585 real(kind=8) :: rrij,r_inv_ij,xj,yj,zj,xi,yi,zi,fac,evdw,&
12586 fac_augm,e_augm,rij,sss,r_shift_inv,e1,e2,evdwij
12587 ! print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
12589 do i=iatsc_s,iatsc_e
12591 if (itypi.eq.ntyp1) cycle
12592 itypi1=itype(i+1,1)
12597 ! Calculate SC interaction energy.
12599 do iint=1,nint_gr(i)
12600 do j=istart(i,iint),iend(i,iint)
12602 if (itypj.eq.ntyp1) cycle
12606 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
12607 fac_augm=rrij**expon
12608 e_augm=augm(itypi,itypj)*fac_augm
12609 r_inv_ij=dsqrt(rrij)
12611 sss=sscale(rij/sigma(itypi,itypj))
12612 if (sss.lt.1.0d0) then
12613 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
12614 fac=r_shift_inv**expon
12615 e1=fac*fac*aa_aq(itypi,itypj)
12616 e2=fac*bb_aq(itypi,itypj)
12617 evdwij=e_augm+e1+e2
12618 !d sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
12619 !d epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
12620 !d write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
12621 !d & restyp(itypi,1),i,restyp(itypj,1),j,aa(itypi,itypj),
12622 !d & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
12623 !d & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
12624 !d & (c(k,i),k=1,3),(c(k,j),k=1,3)
12625 evdw=evdw+(1.0d0-sss)*evdwij
12627 ! Calculate the components of the gradient in DC and X
12629 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
12630 fac=fac*(1.0d0-sss)
12635 gvdwx(k,i)=gvdwx(k,i)-gg(k)
12636 gvdwx(k,j)=gvdwx(k,j)+gg(k)
12637 gvdwc(k,i)=gvdwc(k,i)-gg(k)
12638 gvdwc(k,j)=gvdwc(k,j)+gg(k)
12646 gvdwc(j,i)=expon*gvdwc(j,i)
12647 gvdwx(j,i)=expon*gvdwx(j,i)
12651 end subroutine eljk_long
12652 !-----------------------------------------------------------------------------
12653 subroutine eljk_short(evdw)
12655 ! This subroutine calculates the interaction energy of nonbonded side chains
12656 ! assuming the LJK potential of interaction.
12658 ! implicit real*8 (a-h,o-z)
12659 ! include 'DIMENSIONS'
12660 ! include 'COMMON.GEO'
12661 ! include 'COMMON.VAR'
12662 ! include 'COMMON.LOCAL'
12663 ! include 'COMMON.CHAIN'
12664 ! include 'COMMON.DERIV'
12665 ! include 'COMMON.INTERACT'
12666 ! include 'COMMON.IOUNITS'
12667 ! include 'COMMON.NAMES'
12668 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
12670 !el local variables
12671 integer :: i,iint,j,k,itypi,itypi1,itypj
12672 real(kind=8) :: rrij,r_inv_ij,xj,yj,zj,xi,yi,zi,fac,evdw,&
12673 fac_augm,e_augm,rij,sss,r_shift_inv,e1,e2,evdwij
12674 ! print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
12676 do i=iatsc_s,iatsc_e
12678 if (itypi.eq.ntyp1) cycle
12679 itypi1=itype(i+1,1)
12684 ! Calculate SC interaction energy.
12686 do iint=1,nint_gr(i)
12687 do j=istart(i,iint),iend(i,iint)
12689 if (itypj.eq.ntyp1) cycle
12693 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
12694 fac_augm=rrij**expon
12695 e_augm=augm(itypi,itypj)*fac_augm
12696 r_inv_ij=dsqrt(rrij)
12698 sss=sscale(rij/sigma(itypi,itypj))
12699 if (sss.gt.0.0d0) then
12700 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
12701 fac=r_shift_inv**expon
12702 e1=fac*fac*aa_aq(itypi,itypj)
12703 e2=fac*bb_aq(itypi,itypj)
12704 evdwij=e_augm+e1+e2
12705 !d sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
12706 !d epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
12707 !d write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
12708 !d & restyp(itypi,1),i,restyp(itypj,1),j,aa(itypi,itypj),
12709 !d & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
12710 !d & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
12711 !d & (c(k,i),k=1,3),(c(k,j),k=1,3)
12712 evdw=evdw+sss*evdwij
12714 ! Calculate the components of the gradient in DC and X
12716 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
12722 gvdwx(k,i)=gvdwx(k,i)-gg(k)
12723 gvdwx(k,j)=gvdwx(k,j)+gg(k)
12724 gvdwc(k,i)=gvdwc(k,i)-gg(k)
12725 gvdwc(k,j)=gvdwc(k,j)+gg(k)
12733 gvdwc(j,i)=expon*gvdwc(j,i)
12734 gvdwx(j,i)=expon*gvdwx(j,i)
12738 end subroutine eljk_short
12739 !-----------------------------------------------------------------------------
12740 subroutine ebp_long(evdw)
12742 ! This subroutine calculates the interaction energy of nonbonded side chains
12743 ! assuming the Berne-Pechukas potential of interaction.
12746 ! implicit real*8 (a-h,o-z)
12747 ! include 'DIMENSIONS'
12748 ! include 'COMMON.GEO'
12749 ! include 'COMMON.VAR'
12750 ! include 'COMMON.LOCAL'
12751 ! include 'COMMON.CHAIN'
12752 ! include 'COMMON.DERIV'
12753 ! include 'COMMON.NAMES'
12754 ! include 'COMMON.INTERACT'
12755 ! include 'COMMON.IOUNITS'
12756 ! include 'COMMON.CALC'
12758 !el integer :: icall
12759 !el common /srutu/ icall
12760 ! double precision rrsave(maxdim)
12762 !el local variables
12763 integer :: iint,itypi,itypi1,itypj
12764 real(kind=8) :: rrij,xi,yi,zi,fac
12765 real(kind=8) :: sss,e1,e2,evdw,sigm,epsi
12767 ! print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
12769 ! if (icall.eq.0) then
12775 do i=iatsc_s,iatsc_e
12777 if (itypi.eq.ntyp1) cycle
12778 itypi1=itype(i+1,1)
12782 dxi=dc_norm(1,nres+i)
12783 dyi=dc_norm(2,nres+i)
12784 dzi=dc_norm(3,nres+i)
12785 ! dsci_inv=dsc_inv(itypi)
12786 dsci_inv=vbld_inv(i+nres)
12788 ! Calculate SC interaction energy.
12790 do iint=1,nint_gr(i)
12791 do j=istart(i,iint),iend(i,iint)
12794 if (itypj.eq.ntyp1) cycle
12795 ! dscj_inv=dsc_inv(itypj)
12796 dscj_inv=vbld_inv(j+nres)
12797 chi1=chi(itypi,itypj)
12798 chi2=chi(itypj,itypi)
12805 alf12=0.5D0*(alf1+alf2)
12809 dxj=dc_norm(1,nres+j)
12810 dyj=dc_norm(2,nres+j)
12811 dzj=dc_norm(3,nres+j)
12812 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
12814 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
12816 if (sss.lt.1.0d0) then
12818 ! Calculate the angle-dependent terms of energy & contributions to derivatives.
12820 ! Calculate whole angle-dependent part of epsilon and contributions
12821 ! to its derivatives
12822 fac=(rrij*sigsq)**expon2
12823 e1=fac*fac*aa_aq(itypi,itypj)
12824 e2=fac*bb_aq(itypi,itypj)
12825 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
12826 eps2der=evdwij*eps3rt
12827 eps3der=evdwij*eps2rt
12828 evdwij=evdwij*eps2rt*eps3rt
12829 evdw=evdw+evdwij*(1.0d0-sss)
12831 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
12832 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
12833 !d write (iout,'(2(a3,i3,2x),15(0pf7.3))')
12834 !d & restyp(itypi,1),i,restyp(itypj,1),j,
12835 !d & epsi,sigm,chi1,chi2,chip1,chip2,
12836 !d & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
12837 !d & om1,om2,om12,1.0D0/dsqrt(rrij),
12840 ! Calculate gradient components.
12841 e1=e1*eps1*eps2rt**2*eps3rt**2
12842 fac=-expon*(e1+evdwij)
12845 ! Calculate radial part of the gradient
12849 ! Calculate the angular part of the gradient and sum add the contributions
12850 ! to the appropriate components of the Cartesian gradient.
12851 call sc_grad_scale(1.0d0-sss)
12858 end subroutine ebp_long
12859 !-----------------------------------------------------------------------------
12860 subroutine ebp_short(evdw)
12862 ! This subroutine calculates the interaction energy of nonbonded side chains
12863 ! assuming the Berne-Pechukas potential of interaction.
12866 ! implicit real*8 (a-h,o-z)
12867 ! include 'DIMENSIONS'
12868 ! include 'COMMON.GEO'
12869 ! include 'COMMON.VAR'
12870 ! include 'COMMON.LOCAL'
12871 ! include 'COMMON.CHAIN'
12872 ! include 'COMMON.DERIV'
12873 ! include 'COMMON.NAMES'
12874 ! include 'COMMON.INTERACT'
12875 ! include 'COMMON.IOUNITS'
12876 ! include 'COMMON.CALC'
12878 !el integer :: icall
12879 !el common /srutu/ icall
12880 ! double precision rrsave(maxdim)
12882 !el local variables
12883 integer :: iint,itypi,itypi1,itypj
12884 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi
12885 real(kind=8) :: sss,e1,e2,evdw
12887 ! print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
12889 ! if (icall.eq.0) then
12895 do i=iatsc_s,iatsc_e
12897 if (itypi.eq.ntyp1) cycle
12898 itypi1=itype(i+1,1)
12902 dxi=dc_norm(1,nres+i)
12903 dyi=dc_norm(2,nres+i)
12904 dzi=dc_norm(3,nres+i)
12905 ! dsci_inv=dsc_inv(itypi)
12906 dsci_inv=vbld_inv(i+nres)
12908 ! Calculate SC interaction energy.
12910 do iint=1,nint_gr(i)
12911 do j=istart(i,iint),iend(i,iint)
12914 if (itypj.eq.ntyp1) cycle
12915 ! dscj_inv=dsc_inv(itypj)
12916 dscj_inv=vbld_inv(j+nres)
12917 chi1=chi(itypi,itypj)
12918 chi2=chi(itypj,itypi)
12925 alf12=0.5D0*(alf1+alf2)
12929 dxj=dc_norm(1,nres+j)
12930 dyj=dc_norm(2,nres+j)
12931 dzj=dc_norm(3,nres+j)
12932 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
12934 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
12936 if (sss.gt.0.0d0) then
12938 ! Calculate the angle-dependent terms of energy & contributions to derivatives.
12940 ! Calculate whole angle-dependent part of epsilon and contributions
12941 ! to its derivatives
12942 fac=(rrij*sigsq)**expon2
12943 e1=fac*fac*aa_aq(itypi,itypj)
12944 e2=fac*bb_aq(itypi,itypj)
12945 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
12946 eps2der=evdwij*eps3rt
12947 eps3der=evdwij*eps2rt
12948 evdwij=evdwij*eps2rt*eps3rt
12949 evdw=evdw+evdwij*sss
12951 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
12952 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
12953 !d write (iout,'(2(a3,i3,2x),15(0pf7.3))')
12954 !d & restyp(itypi,1),i,restyp(itypj,1),j,
12955 !d & epsi,sigm,chi1,chi2,chip1,chip2,
12956 !d & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
12957 !d & om1,om2,om12,1.0D0/dsqrt(rrij),
12960 ! Calculate gradient components.
12961 e1=e1*eps1*eps2rt**2*eps3rt**2
12962 fac=-expon*(e1+evdwij)
12965 ! Calculate radial part of the gradient
12969 ! Calculate the angular part of the gradient and sum add the contributions
12970 ! to the appropriate components of the Cartesian gradient.
12971 call sc_grad_scale(sss)
12978 end subroutine ebp_short
12979 !-----------------------------------------------------------------------------
12980 subroutine egb_long(evdw)
12982 ! This subroutine calculates the interaction energy of nonbonded side chains
12983 ! assuming the Gay-Berne potential of interaction.
12986 ! implicit real*8 (a-h,o-z)
12987 ! include 'DIMENSIONS'
12988 ! include 'COMMON.GEO'
12989 ! include 'COMMON.VAR'
12990 ! include 'COMMON.LOCAL'
12991 ! include 'COMMON.CHAIN'
12992 ! include 'COMMON.DERIV'
12993 ! include 'COMMON.NAMES'
12994 ! include 'COMMON.INTERACT'
12995 ! include 'COMMON.IOUNITS'
12996 ! include 'COMMON.CALC'
12997 ! include 'COMMON.CONTROL'
12999 !el local variables
13000 integer :: iint,itypi,itypi1,itypj,subchap
13001 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,sig,sig0ij,rij_shift
13002 real(kind=8) :: sss,e1,e2,evdw,sss_grad
13003 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
13004 dist_temp, dist_init,aa,bb,fracinbuf,sslipi,sslipj,&
13005 ssgradlipi,ssgradlipj
13009 !cccc energy_dec=.false.
13010 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
13013 ! if (icall.eq.0) lprn=.false.
13015 do i=iatsc_s,iatsc_e
13017 if (itypi.eq.ntyp1) cycle
13018 itypi1=itype(i+1,1)
13022 xi=mod(xi,boxxsize)
13023 if (xi.lt.0) xi=xi+boxxsize
13024 yi=mod(yi,boxysize)
13025 if (yi.lt.0) yi=yi+boxysize
13026 zi=mod(zi,boxzsize)
13027 if (zi.lt.0) zi=zi+boxzsize
13028 if ((zi.gt.bordlipbot) &
13029 .and.(zi.lt.bordliptop)) then
13030 !C the energy transfer exist
13031 if (zi.lt.buflipbot) then
13032 !C what fraction I am in
13034 ((zi-bordlipbot)/lipbufthick)
13035 !C lipbufthick is thickenes of lipid buffore
13036 sslipi=sscalelip(fracinbuf)
13037 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
13038 elseif (zi.gt.bufliptop) then
13039 fracinbuf=1.0d0-((bordliptop-zi)/lipbufthick)
13040 sslipi=sscalelip(fracinbuf)
13041 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
13051 dxi=dc_norm(1,nres+i)
13052 dyi=dc_norm(2,nres+i)
13053 dzi=dc_norm(3,nres+i)
13054 ! dsci_inv=dsc_inv(itypi)
13055 dsci_inv=vbld_inv(i+nres)
13056 ! write (iout,*) "i",i,dsc_inv(itypi),dsci_inv,1.0d0/vbld(i+nres)
13057 ! write (iout,*) "dcnori",dxi*dxi+dyi*dyi+dzi*dzi
13059 ! Calculate SC interaction energy.
13061 do iint=1,nint_gr(i)
13062 do j=istart(i,iint),iend(i,iint)
13063 IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
13064 ! call dyn_ssbond_ene(i,j,evdwij)
13066 ! if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
13067 ! 'evdw',i,j,evdwij,' ss'
13068 ! if (energy_dec) write (iout,*) &
13069 ! 'evdw',i,j,evdwij,' ss'
13070 ! do k=j+1,iend(i,iint)
13071 !C search over all next residues
13072 ! if (dyn_ss_mask(k)) then
13073 !C check if they are cysteins
13074 !C write(iout,*) 'k=',k
13076 !c write(iout,*) "PRZED TRI", evdwij
13077 ! evdwij_przed_tri=evdwij
13078 ! call triple_ssbond_ene(i,j,k,evdwij)
13079 !c if(evdwij_przed_tri.ne.evdwij) then
13080 !c write (iout,*) "TRI:", evdwij, evdwij_przed_tri
13083 !c write(iout,*) "PO TRI", evdwij
13084 !C call the energy function that removes the artifical triple disulfide
13085 !C bond the soubroutine is located in ssMD.F
13087 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
13088 'evdw',i,j,evdwij,'tss'
13089 ! endif!dyn_ss_mask(k)
13095 if (itypj.eq.ntyp1) cycle
13096 ! dscj_inv=dsc_inv(itypj)
13097 dscj_inv=vbld_inv(j+nres)
13098 ! write (iout,*) "j",j,dsc_inv(itypj),dscj_inv,
13099 ! & 1.0d0/vbld(j+nres)
13100 ! write (iout,*) "i",i," j", j," itype",itype(i,1),itype(j,1)
13101 sig0ij=sigma(itypi,itypj)
13102 chi1=chi(itypi,itypj)
13103 chi2=chi(itypj,itypi)
13110 alf12=0.5D0*(alf1+alf2)
13114 ! Searching for nearest neighbour
13115 xj=mod(xj,boxxsize)
13116 if (xj.lt.0) xj=xj+boxxsize
13117 yj=mod(yj,boxysize)
13118 if (yj.lt.0) yj=yj+boxysize
13119 zj=mod(zj,boxzsize)
13120 if (zj.lt.0) zj=zj+boxzsize
13121 if ((zj.gt.bordlipbot) &
13122 .and.(zj.lt.bordliptop)) then
13123 !C the energy transfer exist
13124 if (zj.lt.buflipbot) then
13125 !C what fraction I am in
13127 ((zj-bordlipbot)/lipbufthick)
13128 !C lipbufthick is thickenes of lipid buffore
13129 sslipj=sscalelip(fracinbuf)
13130 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
13131 elseif (zj.gt.bufliptop) then
13132 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
13133 sslipj=sscalelip(fracinbuf)
13134 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
13143 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
13144 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
13145 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
13146 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
13148 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
13156 xj=xj_safe+xshift*boxxsize
13157 yj=yj_safe+yshift*boxysize
13158 zj=zj_safe+zshift*boxzsize
13159 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
13160 if(dist_temp.lt.dist_init) then
13161 dist_init=dist_temp
13170 if (subchap.eq.1) then
13180 dxj=dc_norm(1,nres+j)
13181 dyj=dc_norm(2,nres+j)
13182 dzj=dc_norm(3,nres+j)
13183 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
13185 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
13186 sss_ele_cut=sscale_ele(1.0d0/(rij*sigma(itypi,itypj)))
13187 sss_ele_grad=sscagrad_ele(1.0d0/(rij*sigma(itypi,itypj)))
13188 sss_grad=sscale_grad(1.0d0/(rij*sigmaii(itypi,itypj)))
13189 if (sss_ele_cut.le.0.0) cycle
13190 if (sss.lt.1.0d0) then
13192 ! Calculate angle-dependent terms of energy and contributions to their
13196 sig=sig0ij*dsqrt(sigsq)
13197 rij_shift=1.0D0/rij-sig+sig0ij
13198 ! for diagnostics; uncomment
13199 ! rij_shift=1.2*sig0ij
13200 ! I hate to put IF's in the loops, but here don't have another choice!!!!
13201 if (rij_shift.le.0.0D0) then
13203 !d write (iout,'(2(a3,i3,2x),17(0pf7.3))')
13204 !d & restyp(itypi,1),i,restyp(itypj,1),j,
13205 !d & rij_shift,1.0D0/rij,sig,sig0ij,sigsq,1-dsqrt(sigsq)
13209 !---------------------------------------------------------------
13210 rij_shift=1.0D0/rij_shift
13211 fac=rij_shift**expon
13214 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
13215 eps2der=evdwij*eps3rt
13216 eps3der=evdwij*eps2rt
13217 ! write (iout,*) "sigsq",sigsq," sig",sig," eps2rt",eps2rt,
13218 ! & " eps3rt",eps3rt," eps1",eps1," e1",e1," e2",e2
13219 evdwij=evdwij*eps2rt*eps3rt
13220 evdw=evdw+evdwij*(1.0d0-sss)*sss_ele_cut
13222 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
13223 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
13224 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
13225 restyp(itypi,1),i,restyp(itypj,1),j,&
13226 epsi,sigm,chi1,chi2,chip1,chip2,&
13227 eps1,eps2rt**2,eps3rt**2,sig,sig0ij,&
13228 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
13232 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
13234 ! if (energy_dec) write (iout,*) &
13235 ! 'evdw',i,j,evdwij,"egb_long"
13237 ! Calculate gradient components.
13238 e1=e1*eps1*eps2rt**2*eps3rt**2
13239 fac=-expon*(e1+evdwij)*rij_shift
13242 fac=fac+evdwij*(sss_ele_grad/sss_ele_cut&
13243 /sigma(itypi,itypj)*rij-sss_grad/(1.0-sss)*rij &
13244 /sigmaii(itypi,itypj))
13246 ! Calculate the radial part of the gradient
13250 ! Calculate angular part of the gradient.
13251 call sc_grad_scale(1.0d0-sss)
13257 ! write (iout,*) "Number of loop steps in EGB:",ind
13258 !ccc energy_dec=.false.
13260 end subroutine egb_long
13261 !-----------------------------------------------------------------------------
13262 subroutine egb_short(evdw)
13264 ! This subroutine calculates the interaction energy of nonbonded side chains
13265 ! assuming the Gay-Berne potential of interaction.
13268 ! implicit real*8 (a-h,o-z)
13269 ! include 'DIMENSIONS'
13270 ! include 'COMMON.GEO'
13271 ! include 'COMMON.VAR'
13272 ! include 'COMMON.LOCAL'
13273 ! include 'COMMON.CHAIN'
13274 ! include 'COMMON.DERIV'
13275 ! include 'COMMON.NAMES'
13276 ! include 'COMMON.INTERACT'
13277 ! include 'COMMON.IOUNITS'
13278 ! include 'COMMON.CALC'
13279 ! include 'COMMON.CONTROL'
13281 !el local variables
13282 integer :: iint,itypi,itypi1,itypj,subchap
13283 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,sig0ij,sig
13284 real(kind=8) :: sss,e1,e2,evdw,rij_shift,sss_grad
13285 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
13286 dist_temp, dist_init,aa,bb,fracinbuf,sslipi,sslipj,&
13287 ssgradlipi,ssgradlipj
13289 !cccc energy_dec=.false.
13290 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
13293 ! if (icall.eq.0) lprn=.false.
13295 do i=iatsc_s,iatsc_e
13297 if (itypi.eq.ntyp1) cycle
13298 itypi1=itype(i+1,1)
13302 xi=mod(xi,boxxsize)
13303 if (xi.lt.0) xi=xi+boxxsize
13304 yi=mod(yi,boxysize)
13305 if (yi.lt.0) yi=yi+boxysize
13306 zi=mod(zi,boxzsize)
13307 if (zi.lt.0) zi=zi+boxzsize
13308 if ((zi.gt.bordlipbot) &
13309 .and.(zi.lt.bordliptop)) then
13310 !C the energy transfer exist
13311 if (zi.lt.buflipbot) then
13312 !C what fraction I am in
13314 ((zi-bordlipbot)/lipbufthick)
13315 !C lipbufthick is thickenes of lipid buffore
13316 sslipi=sscalelip(fracinbuf)
13317 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
13318 elseif (zi.gt.bufliptop) then
13319 fracinbuf=1.0d0-((bordliptop-zi)/lipbufthick)
13320 sslipi=sscalelip(fracinbuf)
13321 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
13331 dxi=dc_norm(1,nres+i)
13332 dyi=dc_norm(2,nres+i)
13333 dzi=dc_norm(3,nres+i)
13334 ! dsci_inv=dsc_inv(itypi)
13335 dsci_inv=vbld_inv(i+nres)
13337 dxi=dc_norm(1,nres+i)
13338 dyi=dc_norm(2,nres+i)
13339 dzi=dc_norm(3,nres+i)
13340 ! dsci_inv=dsc_inv(itypi)
13341 dsci_inv=vbld_inv(i+nres)
13342 ! write (iout,*) "i",i,dsc_inv(itypi),dsci_inv,1.0d0/vbld(i+nres)
13343 ! write (iout,*) "dcnori",dxi*dxi+dyi*dyi+dzi*dzi
13345 ! Calculate SC interaction energy.
13347 do iint=1,nint_gr(i)
13348 do j=istart(i,iint),iend(i,iint)
13349 IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
13350 call dyn_ssbond_ene(i,j,evdwij)
13352 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
13353 'evdw',i,j,evdwij,' ss'
13354 do k=j+1,iend(i,iint)
13355 !C search over all next residues
13356 if (dyn_ss_mask(k)) then
13357 !C check if they are cysteins
13358 !C write(iout,*) 'k=',k
13360 !c write(iout,*) "PRZED TRI", evdwij
13361 ! evdwij_przed_tri=evdwij
13362 call triple_ssbond_ene(i,j,k,evdwij)
13363 !c if(evdwij_przed_tri.ne.evdwij) then
13364 !c write (iout,*) "TRI:", evdwij, evdwij_przed_tri
13367 !c write(iout,*) "PO TRI", evdwij
13368 !C call the energy function that removes the artifical triple disulfide
13369 !C bond the soubroutine is located in ssMD.F
13371 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
13372 'evdw',i,j,evdwij,'tss'
13373 endif!dyn_ss_mask(k)
13376 ! if (energy_dec) write (iout,*) &
13377 ! 'evdw',i,j,evdwij,' ss'
13381 if (itypj.eq.ntyp1) cycle
13382 ! dscj_inv=dsc_inv(itypj)
13383 dscj_inv=vbld_inv(j+nres)
13384 ! write (iout,*) "j",j,dsc_inv(itypj),dscj_inv,
13385 ! & 1.0d0/vbld(j+nres)
13386 ! write (iout,*) "i",i," j", j," itype",itype(i,1),itype(j,1)
13387 sig0ij=sigma(itypi,itypj)
13388 chi1=chi(itypi,itypj)
13389 chi2=chi(itypj,itypi)
13396 alf12=0.5D0*(alf1+alf2)
13397 ! xj=c(1,nres+j)-xi
13398 ! yj=c(2,nres+j)-yi
13399 ! zj=c(3,nres+j)-zi
13403 ! Searching for nearest neighbour
13404 xj=mod(xj,boxxsize)
13405 if (xj.lt.0) xj=xj+boxxsize
13406 yj=mod(yj,boxysize)
13407 if (yj.lt.0) yj=yj+boxysize
13408 zj=mod(zj,boxzsize)
13409 if (zj.lt.0) zj=zj+boxzsize
13410 if ((zj.gt.bordlipbot) &
13411 .and.(zj.lt.bordliptop)) then
13412 !C the energy transfer exist
13413 if (zj.lt.buflipbot) then
13414 !C what fraction I am in
13416 ((zj-bordlipbot)/lipbufthick)
13417 !C lipbufthick is thickenes of lipid buffore
13418 sslipj=sscalelip(fracinbuf)
13419 ssgradlipj=-sscagradlip(fracinbuf)/lipbufthick
13420 elseif (zj.gt.bufliptop) then
13421 fracinbuf=1.0d0-((bordliptop-zj)/lipbufthick)
13422 sslipj=sscalelip(fracinbuf)
13423 ssgradlipj=sscagradlip(fracinbuf)/lipbufthick
13432 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
13433 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
13434 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
13435 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
13437 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
13446 xj=xj_safe+xshift*boxxsize
13447 yj=yj_safe+yshift*boxysize
13448 zj=zj_safe+zshift*boxzsize
13449 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
13450 if(dist_temp.lt.dist_init) then
13451 dist_init=dist_temp
13460 if (subchap.eq.1) then
13470 dxj=dc_norm(1,nres+j)
13471 dyj=dc_norm(2,nres+j)
13472 dzj=dc_norm(3,nres+j)
13473 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
13475 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
13476 sss_grad=sscale_grad(1.0d0/(rij*sigmaii(itypi,itypj)))
13477 sss_ele_cut=sscale_ele(1.0d0/(rij*sigma(itypi,itypj)))
13478 sss_ele_grad=sscagrad_ele(1.0d0/(rij*sigma(itypi,itypj)))
13479 if (sss_ele_cut.le.0.0) cycle
13481 if (sss.gt.0.0d0) then
13483 ! Calculate angle-dependent terms of energy and contributions to their
13487 sig=sig0ij*dsqrt(sigsq)
13488 rij_shift=1.0D0/rij-sig+sig0ij
13489 ! for diagnostics; uncomment
13490 ! rij_shift=1.2*sig0ij
13491 ! I hate to put IF's in the loops, but here don't have another choice!!!!
13492 if (rij_shift.le.0.0D0) then
13494 !d write (iout,'(2(a3,i3,2x),17(0pf7.3))')
13495 !d & restyp(itypi,1),i,restyp(itypj,1),j,
13496 !d & rij_shift,1.0D0/rij,sig,sig0ij,sigsq,1-dsqrt(sigsq)
13500 !---------------------------------------------------------------
13501 rij_shift=1.0D0/rij_shift
13502 fac=rij_shift**expon
13505 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
13506 eps2der=evdwij*eps3rt
13507 eps3der=evdwij*eps2rt
13508 ! write (iout,*) "sigsq",sigsq," sig",sig," eps2rt",eps2rt,
13509 ! & " eps3rt",eps3rt," eps1",eps1," e1",e1," e2",e2
13510 evdwij=evdwij*eps2rt*eps3rt
13511 evdw=evdw+evdwij*sss*sss_ele_cut
13513 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
13514 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
13515 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
13516 restyp(itypi,1),i,restyp(itypj,1),j,&
13517 epsi,sigm,chi1,chi2,chip1,chip2,&
13518 eps1,eps2rt**2,eps3rt**2,sig,sig0ij,&
13519 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
13523 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
13525 ! if (energy_dec) write (iout,*) &
13526 ! 'evdw',i,j,evdwij,"egb_short"
13528 ! Calculate gradient components.
13529 e1=e1*eps1*eps2rt**2*eps3rt**2
13530 fac=-expon*(e1+evdwij)*rij_shift
13533 fac=fac+evdwij*(sss_ele_grad/sss_ele_cut&
13534 /sigma(itypi,itypj)*rij+sss_grad/sss*rij &
13535 /sigmaii(itypi,itypj))
13538 ! Calculate the radial part of the gradient
13542 ! Calculate angular part of the gradient.
13543 call sc_grad_scale(sss)
13549 ! write (iout,*) "Number of loop steps in EGB:",ind
13550 !ccc energy_dec=.false.
13552 end subroutine egb_short
13553 !-----------------------------------------------------------------------------
13554 subroutine egbv_long(evdw)
13556 ! This subroutine calculates the interaction energy of nonbonded side chains
13557 ! assuming the Gay-Berne-Vorobjev potential of interaction.
13560 ! implicit real*8 (a-h,o-z)
13561 ! include 'DIMENSIONS'
13562 ! include 'COMMON.GEO'
13563 ! include 'COMMON.VAR'
13564 ! include 'COMMON.LOCAL'
13565 ! include 'COMMON.CHAIN'
13566 ! include 'COMMON.DERIV'
13567 ! include 'COMMON.NAMES'
13568 ! include 'COMMON.INTERACT'
13569 ! include 'COMMON.IOUNITS'
13570 ! include 'COMMON.CALC'
13572 !el integer :: icall
13573 !el common /srutu/ icall
13575 !el local variables
13576 integer :: iint,itypi,itypi1,itypj
13577 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,r0ij,sig,sig0ij
13578 real(kind=8) :: sss,e1,e2,evdw,fac_augm,e_augm,rij_shift
13580 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
13583 ! if (icall.eq.0) lprn=.true.
13585 do i=iatsc_s,iatsc_e
13587 if (itypi.eq.ntyp1) cycle
13588 itypi1=itype(i+1,1)
13592 dxi=dc_norm(1,nres+i)
13593 dyi=dc_norm(2,nres+i)
13594 dzi=dc_norm(3,nres+i)
13595 ! dsci_inv=dsc_inv(itypi)
13596 dsci_inv=vbld_inv(i+nres)
13598 ! Calculate SC interaction energy.
13600 do iint=1,nint_gr(i)
13601 do j=istart(i,iint),iend(i,iint)
13604 if (itypj.eq.ntyp1) cycle
13605 ! dscj_inv=dsc_inv(itypj)
13606 dscj_inv=vbld_inv(j+nres)
13607 sig0ij=sigma(itypi,itypj)
13608 r0ij=r0(itypi,itypj)
13609 chi1=chi(itypi,itypj)
13610 chi2=chi(itypj,itypi)
13617 alf12=0.5D0*(alf1+alf2)
13621 dxj=dc_norm(1,nres+j)
13622 dyj=dc_norm(2,nres+j)
13623 dzj=dc_norm(3,nres+j)
13624 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
13627 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
13629 if (sss.lt.1.0d0) then
13631 ! Calculate angle-dependent terms of energy and contributions to their
13635 sig=sig0ij*dsqrt(sigsq)
13636 rij_shift=1.0D0/rij-sig+r0ij
13637 ! I hate to put IF's in the loops, but here don't have another choice!!!!
13638 if (rij_shift.le.0.0D0) then
13643 !---------------------------------------------------------------
13644 rij_shift=1.0D0/rij_shift
13645 fac=rij_shift**expon
13646 e1=fac*fac*aa_aq(itypi,itypj)
13647 e2=fac*bb_aq(itypi,itypj)
13648 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
13649 eps2der=evdwij*eps3rt
13650 eps3der=evdwij*eps2rt
13651 fac_augm=rrij**expon
13652 e_augm=augm(itypi,itypj)*fac_augm
13653 evdwij=evdwij*eps2rt*eps3rt
13654 evdw=evdw+(evdwij+e_augm)*(1.0d0-sss)
13656 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
13657 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
13658 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
13659 restyp(itypi,1),i,restyp(itypj,1),j,&
13660 epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),&
13661 chi1,chi2,chip1,chip2,&
13662 eps1,eps2rt**2,eps3rt**2,&
13663 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
13666 ! Calculate gradient components.
13667 e1=e1*eps1*eps2rt**2*eps3rt**2
13668 fac=-expon*(e1+evdwij)*rij_shift
13670 fac=rij*fac-2*expon*rrij*e_augm
13671 ! Calculate the radial part of the gradient
13675 ! Calculate angular part of the gradient.
13676 call sc_grad_scale(1.0d0-sss)
13681 end subroutine egbv_long
13682 !-----------------------------------------------------------------------------
13683 subroutine egbv_short(evdw)
13685 ! This subroutine calculates the interaction energy of nonbonded side chains
13686 ! assuming the Gay-Berne-Vorobjev potential of interaction.
13689 ! implicit real*8 (a-h,o-z)
13690 ! include 'DIMENSIONS'
13691 ! include 'COMMON.GEO'
13692 ! include 'COMMON.VAR'
13693 ! include 'COMMON.LOCAL'
13694 ! include 'COMMON.CHAIN'
13695 ! include 'COMMON.DERIV'
13696 ! include 'COMMON.NAMES'
13697 ! include 'COMMON.INTERACT'
13698 ! include 'COMMON.IOUNITS'
13699 ! include 'COMMON.CALC'
13701 !el integer :: icall
13702 !el common /srutu/ icall
13704 !el local variables
13705 integer :: iint,itypi,itypi1,itypj
13706 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,rij_shift
13707 real(kind=8) :: sss,e1,e2,evdw,r0ij,sig,sig0ij,fac_augm,e_augm
13709 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
13712 ! if (icall.eq.0) lprn=.true.
13714 do i=iatsc_s,iatsc_e
13716 if (itypi.eq.ntyp1) cycle
13717 itypi1=itype(i+1,1)
13721 dxi=dc_norm(1,nres+i)
13722 dyi=dc_norm(2,nres+i)
13723 dzi=dc_norm(3,nres+i)
13724 ! dsci_inv=dsc_inv(itypi)
13725 dsci_inv=vbld_inv(i+nres)
13727 ! Calculate SC interaction energy.
13729 do iint=1,nint_gr(i)
13730 do j=istart(i,iint),iend(i,iint)
13733 if (itypj.eq.ntyp1) cycle
13734 ! dscj_inv=dsc_inv(itypj)
13735 dscj_inv=vbld_inv(j+nres)
13736 sig0ij=sigma(itypi,itypj)
13737 r0ij=r0(itypi,itypj)
13738 chi1=chi(itypi,itypj)
13739 chi2=chi(itypj,itypi)
13746 alf12=0.5D0*(alf1+alf2)
13750 dxj=dc_norm(1,nres+j)
13751 dyj=dc_norm(2,nres+j)
13752 dzj=dc_norm(3,nres+j)
13753 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
13756 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
13758 if (sss.gt.0.0d0) then
13760 ! Calculate angle-dependent terms of energy and contributions to their
13764 sig=sig0ij*dsqrt(sigsq)
13765 rij_shift=1.0D0/rij-sig+r0ij
13766 ! I hate to put IF's in the loops, but here don't have another choice!!!!
13767 if (rij_shift.le.0.0D0) then
13772 !---------------------------------------------------------------
13773 rij_shift=1.0D0/rij_shift
13774 fac=rij_shift**expon
13775 e1=fac*fac*aa_aq(itypi,itypj)
13776 e2=fac*bb_aq(itypi,itypj)
13777 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
13778 eps2der=evdwij*eps3rt
13779 eps3der=evdwij*eps2rt
13780 fac_augm=rrij**expon
13781 e_augm=augm(itypi,itypj)*fac_augm
13782 evdwij=evdwij*eps2rt*eps3rt
13783 evdw=evdw+(evdwij+e_augm)*sss
13785 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
13786 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
13787 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
13788 restyp(itypi,1),i,restyp(itypj,1),j,&
13789 epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),&
13790 chi1,chi2,chip1,chip2,&
13791 eps1,eps2rt**2,eps3rt**2,&
13792 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
13795 ! Calculate gradient components.
13796 e1=e1*eps1*eps2rt**2*eps3rt**2
13797 fac=-expon*(e1+evdwij)*rij_shift
13799 fac=rij*fac-2*expon*rrij*e_augm
13800 ! Calculate the radial part of the gradient
13804 ! Calculate angular part of the gradient.
13805 call sc_grad_scale(sss)
13810 end subroutine egbv_short
13811 !-----------------------------------------------------------------------------
13812 subroutine eelec_scale(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
13814 ! This subroutine calculates the average interaction energy and its gradient
13815 ! in the virtual-bond vectors between non-adjacent peptide groups, based on
13816 ! the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
13817 ! The potential depends both on the distance of peptide-group centers and on
13818 ! the orientation of the CA-CA virtual bonds.
13820 ! implicit real*8 (a-h,o-z)
13826 ! include 'DIMENSIONS'
13827 ! include 'COMMON.CONTROL'
13828 ! include 'COMMON.SETUP'
13829 ! include 'COMMON.IOUNITS'
13830 ! include 'COMMON.GEO'
13831 ! include 'COMMON.VAR'
13832 ! include 'COMMON.LOCAL'
13833 ! include 'COMMON.CHAIN'
13834 ! include 'COMMON.DERIV'
13835 ! include 'COMMON.INTERACT'
13836 ! include 'COMMON.CONTACTS'
13837 ! include 'COMMON.TORSION'
13838 ! include 'COMMON.VECTORS'
13839 ! include 'COMMON.FFIELD'
13840 ! include 'COMMON.TIME1'
13841 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg
13842 real(kind=8),dimension(3,3) ::erder,uryg,urzg,vryg,vrzg
13843 real(kind=8),dimension(2,2) :: acipa !el,a_temp
13844 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
13845 real(kind=8),dimension(4) :: muij
13846 !el integer :: num_conti,j1,j2
13847 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
13848 !el dz_normi,xmedi,ymedi,zmedi
13849 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
13850 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
13851 !el num_conti,j1,j2
13852 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
13854 real(kind=8) :: scal_el=1.0d0
13856 real(kind=8) :: scal_el=0.5d0
13859 ! 13-go grudnia roku pamietnego...
13860 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
13861 0.0d0,1.0d0,0.0d0,&
13862 0.0d0,0.0d0,1.0d0/),shape(unmat))
13863 !el local variables
13865 real(kind=8) :: fac
13866 real(kind=8) :: dxj,dyj,dzj
13867 real(kind=8) :: ees,evdw1,eel_loc,eello_turn3,eello_turn4
13869 ! allocate(num_cont_hb(nres)) !(maxres)
13870 !d write(iout,*) 'In EELEC'
13872 !d write(iout,*) 'Type',i
13873 !d write(iout,*) 'B1',B1(:,i)
13874 !d write(iout,*) 'B2',B2(:,i)
13875 !d write(iout,*) 'CC',CC(:,:,i)
13876 !d write(iout,*) 'DD',DD(:,:,i)
13877 !d write(iout,*) 'EE',EE(:,:,i)
13879 !d call check_vecgrad
13881 if (icheckgrad.eq.1) then
13883 fac=1.0d0/dsqrt(scalar(dc(1,i),dc(1,i)))
13885 dc_norm(k,i)=dc(k,i)*fac
13887 ! write (iout,*) 'i',i,' fac',fac
13890 if (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
13891 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 .or. &
13892 wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) then
13893 ! call vec_and_deriv
13897 ! print *, "before set matrices"
13899 ! print *,"after set martices"
13901 time_mat=time_mat+MPI_Wtime()-time01
13905 !d write (iout,*) 'i=',i
13907 !d write (iout,'(i5,2f10.5)') k,uy(k,i),uz(k,i)
13910 !d write (iout,'(f10.5,2x,3f10.5,2x,3f10.5)')
13911 !d & uz(k,i),(uzgrad(k,l,1,i),l=1,3),(uzgrad(k,l,2,i),l=1,3)
13924 !d print '(a)','Enter EELEC'
13925 !d write (iout,*) 'iatel_s=',iatel_s,' iatel_e=',iatel_e
13926 ! if (.not.allocated(gel_loc_loc)) allocate(gel_loc_loc(nres)) !(maxvar)(maxvar=6*maxres)
13927 ! if (.not.allocated(gcorr_loc)) allocate(gcorr_loc(nres)) !(maxvar)(maxvar=6*maxres)
13929 gel_loc_loc(i)=0.0d0
13934 ! 9/27/08 AL Split the interaction loop to ensure load balancing of turn terms
13936 ! Loop over i,i+2 and i,i+3 pairs of the peptide groups
13938 do i=iturn3_start,iturn3_end
13939 if (itype(i,1).eq.ntyp1.or. itype(i+1,1).eq.ntyp1 &
13940 .or. itype(i+2,1).eq.ntyp1 .or. itype(i+3,1).eq.ntyp1) cycle
13944 dx_normi=dc_norm(1,i)
13945 dy_normi=dc_norm(2,i)
13946 dz_normi=dc_norm(3,i)
13947 xmedi=c(1,i)+0.5d0*dxi
13948 ymedi=c(2,i)+0.5d0*dyi
13949 zmedi=c(3,i)+0.5d0*dzi
13950 xmedi=dmod(xmedi,boxxsize)
13951 if (xmedi.lt.0) xmedi=xmedi+boxxsize
13952 ymedi=dmod(ymedi,boxysize)
13953 if (ymedi.lt.0) ymedi=ymedi+boxysize
13954 zmedi=dmod(zmedi,boxzsize)
13955 if (zmedi.lt.0) zmedi=zmedi+boxzsize
13957 call eelecij_scale(i,i+2,ees,evdw1,eel_loc)
13958 if (wturn3.gt.0.0d0) call eturn3(i,eello_turn3)
13959 num_cont_hb(i)=num_conti
13961 do i=iturn4_start,iturn4_end
13962 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1 &
13963 .or. itype(i+3,1).eq.ntyp1 &
13964 .or. itype(i+4,1).eq.ntyp1) cycle
13968 dx_normi=dc_norm(1,i)
13969 dy_normi=dc_norm(2,i)
13970 dz_normi=dc_norm(3,i)
13971 xmedi=c(1,i)+0.5d0*dxi
13972 ymedi=c(2,i)+0.5d0*dyi
13973 zmedi=c(3,i)+0.5d0*dzi
13974 xmedi=dmod(xmedi,boxxsize)
13975 if (xmedi.lt.0) xmedi=xmedi+boxxsize
13976 ymedi=dmod(ymedi,boxysize)
13977 if (ymedi.lt.0) ymedi=ymedi+boxysize
13978 zmedi=dmod(zmedi,boxzsize)
13979 if (zmedi.lt.0) zmedi=zmedi+boxzsize
13980 num_conti=num_cont_hb(i)
13981 call eelecij_scale(i,i+3,ees,evdw1,eel_loc)
13982 if (wturn4.gt.0.0d0 .and. itype(i+2,1).ne.ntyp1) &
13983 call eturn4(i,eello_turn4)
13984 num_cont_hb(i)=num_conti
13987 ! Loop over all pairs of interacting peptide groups except i,i+2 and i,i+3
13989 do i=iatel_s,iatel_e
13990 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
13994 dx_normi=dc_norm(1,i)
13995 dy_normi=dc_norm(2,i)
13996 dz_normi=dc_norm(3,i)
13997 xmedi=c(1,i)+0.5d0*dxi
13998 ymedi=c(2,i)+0.5d0*dyi
13999 zmedi=c(3,i)+0.5d0*dzi
14000 xmedi=dmod(xmedi,boxxsize)
14001 if (xmedi.lt.0) xmedi=xmedi+boxxsize
14002 ymedi=dmod(ymedi,boxysize)
14003 if (ymedi.lt.0) ymedi=ymedi+boxysize
14004 zmedi=dmod(zmedi,boxzsize)
14005 if (zmedi.lt.0) zmedi=zmedi+boxzsize
14006 ! write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
14007 num_conti=num_cont_hb(i)
14008 do j=ielstart(i),ielend(i)
14009 if (itype(j,1).eq.ntyp1 .or. itype(j+1,1).eq.ntyp1) cycle
14010 call eelecij_scale(i,j,ees,evdw1,eel_loc)
14012 num_cont_hb(i)=num_conti
14014 ! write (iout,*) "Number of loop steps in EELEC:",ind
14016 !d write (iout,'(i3,3f10.5,5x,3f10.5)')
14017 !d & i,(gel_loc(k,i),k=1,3),gel_loc_loc(i)
14019 ! 12/7/99 Adam eello_turn3 will be considered as a separate energy term
14020 !cc eel_loc=eel_loc+eello_turn3
14021 !d print *,"Processor",fg_rank," t_eelecij",t_eelecij
14023 end subroutine eelec_scale
14024 !-----------------------------------------------------------------------------
14025 subroutine eelecij_scale(i,j,ees,evdw1,eel_loc)
14026 ! implicit real*8 (a-h,o-z)
14029 ! include 'DIMENSIONS'
14033 ! include 'COMMON.CONTROL'
14034 ! include 'COMMON.IOUNITS'
14035 ! include 'COMMON.GEO'
14036 ! include 'COMMON.VAR'
14037 ! include 'COMMON.LOCAL'
14038 ! include 'COMMON.CHAIN'
14039 ! include 'COMMON.DERIV'
14040 ! include 'COMMON.INTERACT'
14041 ! include 'COMMON.CONTACTS'
14042 ! include 'COMMON.TORSION'
14043 ! include 'COMMON.VECTORS'
14044 ! include 'COMMON.FFIELD'
14045 ! include 'COMMON.TIME1'
14046 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg,xtemp
14047 real(kind=8),dimension(3,3) :: erder,uryg,urzg,vryg,vrzg
14048 real(kind=8),dimension(2,2) :: acipa !el,a_temp
14049 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
14050 real(kind=8),dimension(4) :: muij
14051 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
14052 dist_temp, dist_init,sss_grad
14053 integer xshift,yshift,zshift
14055 !el integer :: num_conti,j1,j2
14056 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
14057 !el dz_normi,xmedi,ymedi,zmedi
14058 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
14059 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
14060 !el num_conti,j1,j2
14061 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
14063 real(kind=8) :: scal_el=1.0d0
14065 real(kind=8) :: scal_el=0.5d0
14068 ! 13-go grudnia roku pamietnego...
14069 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
14070 0.0d0,1.0d0,0.0d0,&
14071 0.0d0,0.0d0,1.0d0/),shape(unmat))
14072 !el local variables
14073 integer :: i,j,k,l,iteli,itelj,kkk,kkll,m,isubchap
14074 real(kind=8) :: aaa,bbb,ael6i,ael3i,dxj,dyj,dzj
14075 real(kind=8) :: xj,yj,zj,rij,rrmij,rmij,sss,r3ij,r6ij,fac
14076 real(kind=8) :: cosa,cosb,cosg,ev1,ev2,fac3,fac4,evdwij
14077 real(kind=8) :: el1,el2,eesij,ees0ij,r0ij,fcont,fprimcont
14078 real(kind=8) :: ees0tmp,ees0pij1,ees0mij1,ees0pijp,ees0mijp
14079 real(kind=8) :: ees,evdw1,eel_loc,eel_loc_ij,dx_normj,dy_normj,&
14080 dz_normj,facvdw,facel,fac1,facr,ecosa,ecosb,ecosg,&
14081 ury,urz,vry,vrz,a22der,a23der,a32der,a33der,cosa4,&
14082 wij,cosbg1,cosbg2,ees0pij,ees0mij,fac3p,ecosa1,ecosb1,&
14083 ecosg1,ecosa2,ecosb2,ecosg2,ecosap,ecosbp,ecosgp,&
14084 ecosam,ecosbm,ecosgm,ghalf,time00
14085 ! integer :: maxconts
14086 ! maxconts = nres/4
14087 ! allocate(gacontp_hb1(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
14088 ! allocate(gacontp_hb2(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
14089 ! allocate(gacontp_hb3(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
14090 ! allocate(gacontm_hb1(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
14091 ! allocate(gacontm_hb2(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
14092 ! allocate(gacontm_hb3(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
14093 ! allocate(gacont_hbr(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
14094 ! allocate(grij_hb_cont(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
14095 ! allocate(facont_hb(maxconts,nres)) !(maxconts,maxres)
14096 ! allocate(ees0p(maxconts,nres)) !(maxconts,maxres)
14097 ! allocate(ees0m(maxconts,nres)) !(maxconts,maxres)
14098 ! allocate(d_cont(maxconts,nres)) !(maxconts,maxres)
14099 ! allocate(jcont_hb(maxconts,nres)) !(maxconts,maxres)
14101 ! allocate(a_chuj(2,2,maxconts,nres)) !(2,2,maxconts,maxres)
14102 ! allocate(a_chuj_der(2,2,3,5,maxconts,nres)) !(2,2,3,5,maxconts,maxres)
14107 !d write (iout,*) "eelecij",i,j
14111 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
14112 aaa=app(iteli,itelj)
14113 bbb=bpp(iteli,itelj)
14114 ael6i=ael6(iteli,itelj)
14115 ael3i=ael3(iteli,itelj)
14119 dx_normj=dc_norm(1,j)
14120 dy_normj=dc_norm(2,j)
14121 dz_normj=dc_norm(3,j)
14122 ! xj=c(1,j)+0.5D0*dxj-xmedi
14123 ! yj=c(2,j)+0.5D0*dyj-ymedi
14124 ! zj=c(3,j)+0.5D0*dzj-zmedi
14125 xj=c(1,j)+0.5D0*dxj
14126 yj=c(2,j)+0.5D0*dyj
14127 zj=c(3,j)+0.5D0*dzj
14128 xj=mod(xj,boxxsize)
14129 if (xj.lt.0) xj=xj+boxxsize
14130 yj=mod(yj,boxysize)
14131 if (yj.lt.0) yj=yj+boxysize
14132 zj=mod(zj,boxzsize)
14133 if (zj.lt.0) zj=zj+boxzsize
14135 dist_init=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
14142 xj=xj_safe+xshift*boxxsize
14143 yj=yj_safe+yshift*boxysize
14144 zj=zj_safe+zshift*boxzsize
14145 dist_temp=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
14146 if(dist_temp.lt.dist_init) then
14147 dist_init=dist_temp
14156 if (isubchap.eq.1) then
14167 rij=xj*xj+yj*yj+zj*zj
14171 ! For extracting the short-range part of Evdwpp
14172 sss=sscale(rij/rpp(iteli,itelj))
14173 sss_ele_cut=sscale_ele(rij)
14174 sss_ele_grad=sscagrad_ele(rij)
14175 sss_grad=sscale_grad((rij/rpp(iteli,itelj)))
14176 ! sss_ele_cut=1.0d0
14177 ! sss_ele_grad=0.0d0
14178 if (sss_ele_cut.le.0.0) go to 128
14182 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
14183 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
14184 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
14185 fac=cosa-3.0D0*cosb*cosg
14187 ! 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
14188 if (j.eq.i+2) ev1=scal_el*ev1
14193 el1=fac3*(4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg))
14196 ! 12/26/95 - for the evaluation of multi-body H-bonding interactions
14197 ees0ij=4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg)
14198 ees=ees+eesij*sss_ele_cut
14199 evdw1=evdw1+evdwij*(1.0d0-sss)*sss_ele_cut
14200 !d write(iout,'(2(2i3,2x),7(1pd12.4)/2(3(1pd12.4),5x)/)')
14201 !d & iteli,i,itelj,j,aaa,bbb,ael6i,ael3i,
14202 !d & 1.0D0/dsqrt(rrmij),evdwij,eesij,
14203 !d & xmedi,ymedi,zmedi,xj,yj,zj
14205 if (energy_dec) then
14206 write (iout,'(a6,2i5,0pf7.3,f7.3)') 'evdw1',i,j,evdwij,sss
14207 write (iout,'(a6,2i5,0pf7.3)') 'ees',i,j,eesij
14211 ! Calculate contributions to the Cartesian gradient.
14214 facvdw=-6*rrmij*(ev1+evdwij)*(1.0d0-sss)*sss_ele_cut
14215 facel=-3*rrmij*(el1+eesij)*sss_ele_cut
14221 ! Radial derivatives. First process both termini of the fragment (i,j)
14223 ggg(1)=facel*xj+sss_ele_grad*rmij*eesij*xj
14224 ggg(2)=facel*yj+sss_ele_grad*rmij*eesij*yj
14225 ggg(3)=facel*zj+sss_ele_grad*rmij*eesij*zj
14227 ! ghalf=0.5D0*ggg(k)
14228 ! gelc(k,i)=gelc(k,i)+ghalf
14229 ! gelc(k,j)=gelc(k,j)+ghalf
14231 ! 9/28/08 AL Gradient compotents will be summed only at the end
14233 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
14234 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
14237 ! Loop over residues i+1 thru j-1.
14241 !grad gelc(l,k)=gelc(l,k)+ggg(l)
14244 ggg(1)=facvdw*xj+sss_ele_grad*rmij*evdwij*xj*(1.0d0-sss) &
14245 -evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*xj
14246 ggg(2)=facvdw*yj+sss_ele_grad*rmij*evdwij*yj*(1.0d0-sss) &
14247 -evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*yj
14248 ggg(3)=facvdw*zj+sss_ele_grad*rmij*evdwij*zj*(1.0d0-sss) &
14249 -evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*zj
14251 ! ghalf=0.5D0*ggg(k)
14252 ! gvdwpp(k,i)=gvdwpp(k,i)+ghalf
14253 ! gvdwpp(k,j)=gvdwpp(k,j)+ghalf
14255 ! 9/28/08 AL Gradient compotents will be summed only at the end
14257 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
14258 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
14261 ! Loop over residues i+1 thru j-1.
14265 !grad gvdwpp(l,k)=gvdwpp(l,k)+ggg(l)
14269 facvdw=(ev1+evdwij)*(1.0d0-sss)*sss_ele_cut
14270 facel=(el1+eesij)*sss_ele_cut
14272 fac=-3*rrmij*(facvdw+facvdw+facel)
14277 ! Radial derivatives. First process both termini of the fragment (i,j)
14283 ! ghalf=0.5D0*ggg(k)
14284 ! gelc(k,i)=gelc(k,i)+ghalf
14285 ! gelc(k,j)=gelc(k,j)+ghalf
14287 ! 9/28/08 AL Gradient compotents will be summed only at the end
14289 gelc_long(k,j)=gelc(k,j)+ggg(k)
14290 gelc_long(k,i)=gelc(k,i)-ggg(k)
14293 ! Loop over residues i+1 thru j-1.
14297 !grad gelc(l,k)=gelc(l,k)+ggg(l)
14300 ! 9/28/08 AL Gradient compotents will be summed only at the end
14305 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
14306 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
14312 ecosa=2.0D0*fac3*fac1+fac4
14315 ecosb=(fac3*(fac1*cosg+cosb)+cosg*fac4)
14316 ecosg=(fac3*(fac1*cosb+cosg)+cosb*fac4)
14318 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
14319 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
14321 !d print '(2i3,2(3(1pd14.5),3x))',i,j,(dcosb(k),k=1,3),
14322 !d & (dcosg(k),k=1,3)
14324 ggg(k)=(ecosb*dcosb(k)+ecosg*dcosg(k) )*sss_ele_cut
14327 ! ghalf=0.5D0*ggg(k)
14328 ! gelc(k,i)=gelc(k,i)+ghalf
14329 ! & +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
14330 ! & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
14331 ! gelc(k,j)=gelc(k,j)+ghalf
14332 ! & +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
14333 ! & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
14337 !grad gelc(l,k)=gelc(l,k)+ggg(l)
14341 gelc(k,i)=gelc(k,i) &
14342 +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
14343 + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)&
14345 gelc(k,j)=gelc(k,j) &
14346 +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
14347 + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
14349 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
14350 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
14352 IF (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
14353 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 &
14354 .or. wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
14356 ! 9/25/99 Mixed third-order local-electrostatic terms. The local-interaction
14357 ! energy of a peptide unit is assumed in the form of a second-order
14358 ! Fourier series in the angles lambda1 and lambda2 (see Nishikawa et al.
14359 ! Macromolecules, 1974, 7, 797-806 for definition). This correlation terms
14360 ! are computed for EVERY pair of non-contiguous peptide groups.
14362 if (j.lt.nres-1) then
14373 muij(kkk)=mu(k,i)*mu(l,j)
14376 !d write (iout,*) 'EELEC: i',i,' j',j
14377 !d write (iout,*) 'j',j,' j1',j1,' j2',j2
14378 !d write(iout,*) 'muij',muij
14379 ury=scalar(uy(1,i),erij)
14380 urz=scalar(uz(1,i),erij)
14381 vry=scalar(uy(1,j),erij)
14382 vrz=scalar(uz(1,j),erij)
14383 a22=scalar(uy(1,i),uy(1,j))-3*ury*vry
14384 a23=scalar(uy(1,i),uz(1,j))-3*ury*vrz
14385 a32=scalar(uz(1,i),uy(1,j))-3*urz*vry
14386 a33=scalar(uz(1,i),uz(1,j))-3*urz*vrz
14387 fac=dsqrt(-ael6i)*r3ij
14392 !d write (iout,'(4i5,4f10.5)')
14393 !d & i,itortyp(itype(i,1)),j,itortyp(itype(j,1)),a22,a23,a32,a33
14394 !d write (iout,'(6f10.5)') (muij(k),k=1,4),fac,eel_loc_ij
14395 !d write (iout,'(2(3f10.5,5x)/2(3f10.5,5x))') uy(:,i),uz(:,i),
14396 !d & uy(:,j),uz(:,j)
14397 !d write (iout,'(4f10.5)')
14398 !d & scalar(uy(1,i),uy(1,j)),scalar(uy(1,i),uz(1,j)),
14399 !d & scalar(uz(1,i),uy(1,j)),scalar(uz(1,i),uz(1,j))
14400 !d write (iout,'(4f10.5)') ury,urz,vry,vrz
14401 !d write (iout,'(9f10.5/)')
14402 !d & fac22,a22,fac23,a23,fac32,a32,fac33,a33,eel_loc_ij
14403 ! Derivatives of the elements of A in virtual-bond vectors
14404 call unormderiv(erij(1),unmat(1,1),rmij,erder(1,1))
14406 uryg(k,1)=scalar(erder(1,k),uy(1,i))
14407 uryg(k,2)=scalar(uygrad(1,k,1,i),erij(1))
14408 uryg(k,3)=scalar(uygrad(1,k,2,i),erij(1))
14409 urzg(k,1)=scalar(erder(1,k),uz(1,i))
14410 urzg(k,2)=scalar(uzgrad(1,k,1,i),erij(1))
14411 urzg(k,3)=scalar(uzgrad(1,k,2,i),erij(1))
14412 vryg(k,1)=scalar(erder(1,k),uy(1,j))
14413 vryg(k,2)=scalar(uygrad(1,k,1,j),erij(1))
14414 vryg(k,3)=scalar(uygrad(1,k,2,j),erij(1))
14415 vrzg(k,1)=scalar(erder(1,k),uz(1,j))
14416 vrzg(k,2)=scalar(uzgrad(1,k,1,j),erij(1))
14417 vrzg(k,3)=scalar(uzgrad(1,k,2,j),erij(1))
14419 ! Compute radial contributions to the gradient
14437 ! Add the contributions coming from er
14440 agg(k,1)=agg(k,1)+fac3*(uryg(k,1)*vry+vryg(k,1)*ury)
14441 agg(k,2)=agg(k,2)+fac3*(uryg(k,1)*vrz+vrzg(k,1)*ury)
14442 agg(k,3)=agg(k,3)+fac3*(urzg(k,1)*vry+vryg(k,1)*urz)
14443 agg(k,4)=agg(k,4)+fac3*(urzg(k,1)*vrz+vrzg(k,1)*urz)
14446 ! Derivatives in DC(i)
14447 !grad ghalf1=0.5d0*agg(k,1)
14448 !grad ghalf2=0.5d0*agg(k,2)
14449 !grad ghalf3=0.5d0*agg(k,3)
14450 !grad ghalf4=0.5d0*agg(k,4)
14451 aggi(k,1)=fac*(scalar(uygrad(1,k,1,i),uy(1,j)) &
14452 -3.0d0*uryg(k,2)*vry)!+ghalf1
14453 aggi(k,2)=fac*(scalar(uygrad(1,k,1,i),uz(1,j)) &
14454 -3.0d0*uryg(k,2)*vrz)!+ghalf2
14455 aggi(k,3)=fac*(scalar(uzgrad(1,k,1,i),uy(1,j)) &
14456 -3.0d0*urzg(k,2)*vry)!+ghalf3
14457 aggi(k,4)=fac*(scalar(uzgrad(1,k,1,i),uz(1,j)) &
14458 -3.0d0*urzg(k,2)*vrz)!+ghalf4
14459 ! Derivatives in DC(i+1)
14460 aggi1(k,1)=fac*(scalar(uygrad(1,k,2,i),uy(1,j)) &
14461 -3.0d0*uryg(k,3)*vry)!+agg(k,1)
14462 aggi1(k,2)=fac*(scalar(uygrad(1,k,2,i),uz(1,j)) &
14463 -3.0d0*uryg(k,3)*vrz)!+agg(k,2)
14464 aggi1(k,3)=fac*(scalar(uzgrad(1,k,2,i),uy(1,j)) &
14465 -3.0d0*urzg(k,3)*vry)!+agg(k,3)
14466 aggi1(k,4)=fac*(scalar(uzgrad(1,k,2,i),uz(1,j)) &
14467 -3.0d0*urzg(k,3)*vrz)!+agg(k,4)
14468 ! Derivatives in DC(j)
14469 aggj(k,1)=fac*(scalar(uygrad(1,k,1,j),uy(1,i)) &
14470 -3.0d0*vryg(k,2)*ury)!+ghalf1
14471 aggj(k,2)=fac*(scalar(uzgrad(1,k,1,j),uy(1,i)) &
14472 -3.0d0*vrzg(k,2)*ury)!+ghalf2
14473 aggj(k,3)=fac*(scalar(uygrad(1,k,1,j),uz(1,i)) &
14474 -3.0d0*vryg(k,2)*urz)!+ghalf3
14475 aggj(k,4)=fac*(scalar(uzgrad(1,k,1,j),uz(1,i)) &
14476 -3.0d0*vrzg(k,2)*urz)!+ghalf4
14477 ! Derivatives in DC(j+1) or DC(nres-1)
14478 aggj1(k,1)=fac*(scalar(uygrad(1,k,2,j),uy(1,i)) &
14479 -3.0d0*vryg(k,3)*ury)
14480 aggj1(k,2)=fac*(scalar(uzgrad(1,k,2,j),uy(1,i)) &
14481 -3.0d0*vrzg(k,3)*ury)
14482 aggj1(k,3)=fac*(scalar(uygrad(1,k,2,j),uz(1,i)) &
14483 -3.0d0*vryg(k,3)*urz)
14484 aggj1(k,4)=fac*(scalar(uzgrad(1,k,2,j),uz(1,i)) &
14485 -3.0d0*vrzg(k,3)*urz)
14486 !grad if (j.eq.nres-1 .and. i.lt.j-2) then
14488 !grad aggj1(k,l)=aggj1(k,l)+agg(k,l)
14501 aggi(k,l)=-aggi(k,l)
14502 aggi1(k,l)=-aggi1(k,l)
14503 aggj(k,l)=-aggj(k,l)
14504 aggj1(k,l)=-aggj1(k,l)
14507 if (j.lt.nres-1) then
14513 aggi(k,l)=-aggi(k,l)
14514 aggi1(k,l)=-aggi1(k,l)
14515 aggj(k,l)=-aggj(k,l)
14516 aggj1(k,l)=-aggj1(k,l)
14527 aggi(k,l)=-aggi(k,l)
14528 aggi1(k,l)=-aggi1(k,l)
14529 aggj(k,l)=-aggj(k,l)
14530 aggj1(k,l)=-aggj1(k,l)
14535 IF (wel_loc.gt.0.0d0) THEN
14536 ! Contribution to the local-electrostatic energy coming from the i-j pair
14537 eel_loc_ij=a22*muij(1)+a23*muij(2)+a32*muij(3) &
14539 ! write (iout,*) 'i',i,' j',j,' eel_loc_ij',eel_loc_ij
14541 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
14542 'eelloc',i,j,eel_loc_ij
14543 ! write (iout,*) a22,muij(1),a23,muij(2),a32,muij(3) !d
14545 eel_loc=eel_loc+eel_loc_ij*sss_ele_cut
14546 ! Partial derivatives in virtual-bond dihedral angles gamma
14548 gel_loc_loc(i-1)=gel_loc_loc(i-1)+ &
14549 (a22*muder(1,i)*mu(1,j)+a23*muder(1,i)*mu(2,j) &
14550 +a32*muder(2,i)*mu(1,j)+a33*muder(2,i)*mu(2,j)) &
14552 gel_loc_loc(j-1)=gel_loc_loc(j-1)+ &
14553 (a22*mu(1,i)*muder(1,j)+a23*mu(1,i)*muder(2,j) &
14554 +a32*mu(2,i)*muder(1,j)+a33*mu(2,i)*muder(2,j)) &
14560 ! Derivatives of eello in DC(i+1) thru DC(j-1) or DC(nres-2)
14562 ggg(l)=(agg(l,1)*muij(1)+ &
14563 agg(l,2)*muij(2)+agg(l,3)*muij(3)+agg(l,4)*muij(4))&
14565 +eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
14567 gel_loc_long(l,j)=gel_loc_long(l,j)+ggg(l)
14568 gel_loc_long(l,i)=gel_loc_long(l,i)-ggg(l)
14569 !grad ghalf=0.5d0*ggg(l)
14570 !grad gel_loc(l,i)=gel_loc(l,i)+ghalf
14571 !grad gel_loc(l,j)=gel_loc(l,j)+ghalf
14575 !grad gel_loc(l,k)=gel_loc(l,k)+ggg(l)
14578 ! Remaining derivatives of eello
14580 gel_loc(l,i)=gel_loc(l,i)+(aggi(l,1)*muij(1)+ &
14581 aggi(l,2)*muij(2)+aggi(l,3)*muij(3)+aggi(l,4)*muij(4))&
14584 gel_loc(l,i+1)=gel_loc(l,i+1)+(aggi1(l,1)*muij(1)+ &
14585 aggi1(l,2)*muij(2)+aggi1(l,3)*muij(3)+aggi1(l,4)*muij(4))&
14588 gel_loc(l,j)=gel_loc(l,j)+(aggj(l,1)*muij(1)+ &
14589 aggj(l,2)*muij(2)+aggj(l,3)*muij(3)+aggj(l,4)*muij(4))&
14592 gel_loc(l,j1)=gel_loc(l,j1)+(aggj1(l,1)*muij(1)+ &
14593 aggj1(l,2)*muij(2)+aggj1(l,3)*muij(3)+aggj1(l,4)*muij(4))&
14598 ! Change 12/26/95 to calculate four-body contributions to H-bonding energy
14599 ! if (j.gt.i+1 .and. num_conti.le.maxconts) then
14600 if (wcorr+wcorr4+wcorr5+wcorr6.gt.0.0d0 &
14601 .and. num_conti.le.maxconts) then
14602 ! write (iout,*) i,j," entered corr"
14604 ! Calculate the contact function. The ith column of the array JCONT will
14605 ! contain the numbers of atoms that make contacts with the atom I (of numbers
14606 ! greater than I). The arrays FACONT and GACONT will contain the values of
14607 ! the contact function and its derivative.
14608 ! r0ij=1.02D0*rpp(iteli,itelj)
14609 ! r0ij=1.11D0*rpp(iteli,itelj)
14610 r0ij=2.20D0*rpp(iteli,itelj)
14611 ! r0ij=1.55D0*rpp(iteli,itelj)
14612 call gcont(rij,r0ij,1.0D0,0.2d0*r0ij,fcont,fprimcont)
14613 !elwrite(iout,*) "num_conti",num_conti, "maxconts",maxconts
14614 if (fcont.gt.0.0D0) then
14615 num_conti=num_conti+1
14616 if (num_conti.gt.maxconts) then
14617 !elwrite(iout,*) "num_conti",num_conti, "maxconts",maxconts
14618 write (iout,*) 'WARNING - max. # of contacts exceeded;',&
14619 ' will skip next contacts for this conf.',num_conti
14621 jcont_hb(num_conti,i)=j
14622 !d write (iout,*) "i",i," j",j," num_conti",num_conti,
14623 !d & " jcont_hb",jcont_hb(num_conti,i)
14624 IF (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. &
14625 wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
14626 ! 9/30/99 (AL) - store components necessary to evaluate higher-order loc-el
14628 d_cont(num_conti,i)=rij
14629 !d write (2,'(3e15.5)') rij,r0ij+0.2d0*r0ij,rij
14630 ! --- Electrostatic-interaction matrix ---
14631 a_chuj(1,1,num_conti,i)=a22
14632 a_chuj(1,2,num_conti,i)=a23
14633 a_chuj(2,1,num_conti,i)=a32
14634 a_chuj(2,2,num_conti,i)=a33
14635 ! --- Gradient of rij
14637 grij_hb_cont(kkk,num_conti,i)=erij(kkk)
14644 a_chuj_der(k,l,m,1,num_conti,i)=agg(m,kkll)
14645 a_chuj_der(k,l,m,2,num_conti,i)=aggi(m,kkll)
14646 a_chuj_der(k,l,m,3,num_conti,i)=aggi1(m,kkll)
14647 a_chuj_der(k,l,m,4,num_conti,i)=aggj(m,kkll)
14648 a_chuj_der(k,l,m,5,num_conti,i)=aggj1(m,kkll)
14653 IF (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) THEN
14654 ! Calculate contact energies
14656 wij=cosa-3.0D0*cosb*cosg
14659 ! fac3=dsqrt(-ael6i)/r0ij**3
14660 fac3=dsqrt(-ael6i)*r3ij
14661 ! ees0pij=dsqrt(4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1)
14662 ees0tmp=4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1
14663 if (ees0tmp.gt.0) then
14664 ees0pij=dsqrt(ees0tmp)
14668 ! ees0mij=dsqrt(4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2)
14669 ees0tmp=4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2
14670 if (ees0tmp.gt.0) then
14671 ees0mij=dsqrt(ees0tmp)
14676 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij) &
14679 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij) &
14682 ! Diagnostics. Comment out or remove after debugging!
14683 ! ees0p(num_conti,i)=0.5D0*fac3*ees0pij
14684 ! ees0m(num_conti,i)=0.5D0*fac3*ees0mij
14685 ! ees0m(num_conti,i)=0.0D0
14687 ! write (iout,*) 'i=',i,' j=',j,' rij=',rij,' r0ij=',r0ij,
14688 ! & ' ees0ij=',ees0p(num_conti,i),ees0m(num_conti,i),' fcont=',fcont
14689 ! Angular derivatives of the contact function
14690 ees0pij1=fac3/ees0pij
14691 ees0mij1=fac3/ees0mij
14692 fac3p=-3.0D0*fac3*rrmij
14693 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
14694 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
14696 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
14697 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
14698 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
14699 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
14700 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
14701 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
14702 ecosap=ecosa1+ecosa2
14703 ecosbp=ecosb1+ecosb2
14704 ecosgp=ecosg1+ecosg2
14705 ecosam=ecosa1-ecosa2
14706 ecosbm=ecosb1-ecosb2
14707 ecosgm=ecosg1-ecosg2
14716 facont_hb(num_conti,i)=fcont
14717 fprimcont=fprimcont/rij
14718 !d facont_hb(num_conti,i)=1.0D0
14719 ! Following line is for diagnostics.
14722 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
14723 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
14726 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
14727 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
14729 ! gggp(1)=gggp(1)+ees0pijp*xj
14730 ! gggp(2)=gggp(2)+ees0pijp*yj
14731 ! gggp(3)=gggp(3)+ees0pijp*zj
14732 ! gggm(1)=gggm(1)+ees0mijp*xj
14733 ! gggm(2)=gggm(2)+ees0mijp*yj
14734 ! gggm(3)=gggm(3)+ees0mijp*zj
14735 gggp(1)=gggp(1)+ees0pijp*xj &
14736 +ees0p(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
14737 gggp(2)=gggp(2)+ees0pijp*yj &
14738 +ees0p(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
14739 gggp(3)=gggp(3)+ees0pijp*zj &
14740 +ees0p(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
14742 gggm(1)=gggm(1)+ees0mijp*xj &
14743 +ees0m(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
14745 gggm(2)=gggm(2)+ees0mijp*yj &
14746 +ees0m(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
14748 gggm(3)=gggm(3)+ees0mijp*zj &
14749 +ees0m(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
14751 ! Derivatives due to the contact function
14752 gacont_hbr(1,num_conti,i)=fprimcont*xj
14753 gacont_hbr(2,num_conti,i)=fprimcont*yj
14754 gacont_hbr(3,num_conti,i)=fprimcont*zj
14757 ! 10/24/08 cgrad and ! comments indicate the parts of the code removed
14758 ! following the change of gradient-summation algorithm.
14760 !grad ghalfp=0.5D0*gggp(k)
14761 !grad ghalfm=0.5D0*gggm(k)
14762 ! gacontp_hb1(k,num_conti,i)= & !ghalfp
14763 ! +(ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
14764 ! + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
14765 ! gacontp_hb2(k,num_conti,i)= & !ghalfp
14766 ! +(ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
14767 ! + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
14768 ! gacontp_hb3(k,num_conti,i)=gggp(k)
14769 ! gacontm_hb1(k,num_conti,i)= &!ghalfm
14770 ! +(ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
14771 ! + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
14772 ! gacontm_hb2(k,num_conti,i)= & !ghalfm
14773 ! +(ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
14774 ! + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
14775 ! gacontm_hb3(k,num_conti,i)=gggm(k)
14776 gacontp_hb1(k,num_conti,i)= & !ghalfp+
14777 (ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
14778 + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
14781 gacontp_hb2(k,num_conti,i)= & !ghalfp+
14782 (ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
14783 + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
14786 gacontp_hb3(k,num_conti,i)=gggp(k) &
14789 gacontm_hb1(k,num_conti,i)= & !ghalfm+
14790 (ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
14791 + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
14794 gacontm_hb2(k,num_conti,i)= & !ghalfm+
14795 (ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
14796 + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1) &
14799 gacontm_hb3(k,num_conti,i)=gggm(k) &
14804 endif ! num_conti.le.maxconts
14807 if (wturn3.gt.0.0d0 .or. wturn4.gt.0.0d0) then
14810 ghalf=0.5d0*agg(l,k)
14811 aggi(l,k)=aggi(l,k)+ghalf
14812 aggi1(l,k)=aggi1(l,k)+agg(l,k)
14813 aggj(l,k)=aggj(l,k)+ghalf
14816 if (j.eq.nres-1 .and. i.lt.j-2) then
14819 aggj1(l,k)=aggj1(l,k)+agg(l,k)
14825 ! t_eelecij=t_eelecij+MPI_Wtime()-time00
14827 end subroutine eelecij_scale
14828 !-----------------------------------------------------------------------------
14829 subroutine evdwpp_short(evdw1)
14833 ! implicit real*8 (a-h,o-z)
14834 ! include 'DIMENSIONS'
14835 ! include 'COMMON.CONTROL'
14836 ! include 'COMMON.IOUNITS'
14837 ! include 'COMMON.GEO'
14838 ! include 'COMMON.VAR'
14839 ! include 'COMMON.LOCAL'
14840 ! include 'COMMON.CHAIN'
14841 ! include 'COMMON.DERIV'
14842 ! include 'COMMON.INTERACT'
14843 ! include 'COMMON.CONTACTS'
14844 ! include 'COMMON.TORSION'
14845 ! include 'COMMON.VECTORS'
14846 ! include 'COMMON.FFIELD'
14847 real(kind=8),dimension(3) :: ggg
14848 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
14850 real(kind=8) :: scal_el=1.0d0
14852 real(kind=8) :: scal_el=0.5d0
14854 !el local variables
14855 integer :: i,j,k,iteli,itelj,num_conti,isubchap
14856 real(kind=8) :: dxi,dyi,dzi,dxj,dyj,dzj,aaa,bbb
14857 real(kind=8) :: xj,yj,zj,rij,rrmij,sss,r3ij,r6ij,evdw1,&
14858 dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
14859 dx_normj,dy_normj,dz_normj,rmij,ev1,ev2,evdwij,facvdw
14860 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
14861 dist_temp, dist_init,sss_grad
14862 integer xshift,yshift,zshift
14866 ! write (iout,*) "iatel_s_vdw",iatel_s_vdw,
14867 ! & " iatel_e_vdw",iatel_e_vdw
14869 do i=iatel_s_vdw,iatel_e_vdw
14870 if (itype(i,1).eq.ntyp1.or. itype(i+1,1).eq.ntyp1) cycle
14874 dx_normi=dc_norm(1,i)
14875 dy_normi=dc_norm(2,i)
14876 dz_normi=dc_norm(3,i)
14877 xmedi=c(1,i)+0.5d0*dxi
14878 ymedi=c(2,i)+0.5d0*dyi
14879 zmedi=c(3,i)+0.5d0*dzi
14880 xmedi=dmod(xmedi,boxxsize)
14881 if (xmedi.lt.0) xmedi=xmedi+boxxsize
14882 ymedi=dmod(ymedi,boxysize)
14883 if (ymedi.lt.0) ymedi=ymedi+boxysize
14884 zmedi=dmod(zmedi,boxzsize)
14885 if (zmedi.lt.0) zmedi=zmedi+boxzsize
14887 ! write (iout,*) 'i',i,' ielstart',ielstart_vdw(i),
14888 ! & ' ielend',ielend_vdw(i)
14890 do j=ielstart_vdw(i),ielend_vdw(i)
14891 if (itype(j,1).eq.ntyp1 .or. itype(j+1,1).eq.ntyp1) cycle
14895 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
14896 aaa=app(iteli,itelj)
14897 bbb=bpp(iteli,itelj)
14901 dx_normj=dc_norm(1,j)
14902 dy_normj=dc_norm(2,j)
14903 dz_normj=dc_norm(3,j)
14904 ! xj=c(1,j)+0.5D0*dxj-xmedi
14905 ! yj=c(2,j)+0.5D0*dyj-ymedi
14906 ! zj=c(3,j)+0.5D0*dzj-zmedi
14907 xj=c(1,j)+0.5D0*dxj
14908 yj=c(2,j)+0.5D0*dyj
14909 zj=c(3,j)+0.5D0*dzj
14910 xj=mod(xj,boxxsize)
14911 if (xj.lt.0) xj=xj+boxxsize
14912 yj=mod(yj,boxysize)
14913 if (yj.lt.0) yj=yj+boxysize
14914 zj=mod(zj,boxzsize)
14915 if (zj.lt.0) zj=zj+boxzsize
14917 dist_init=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
14924 xj=xj_safe+xshift*boxxsize
14925 yj=yj_safe+yshift*boxysize
14926 zj=zj_safe+zshift*boxzsize
14927 dist_temp=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
14928 if(dist_temp.lt.dist_init) then
14929 dist_init=dist_temp
14938 if (isubchap.eq.1) then
14949 rij=xj*xj+yj*yj+zj*zj
14952 sss=sscale(rij/rpp(iteli,itelj))
14953 sss_ele_cut=sscale_ele(rij)
14954 sss_ele_grad=sscagrad_ele(rij)
14955 sss_grad=sscale_grad((rij/rpp(iteli,itelj)))
14956 if (sss_ele_cut.le.0.0) cycle
14957 if (sss.gt.0.0d0) then
14962 ! 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
14963 if (j.eq.i+2) ev1=scal_el*ev1
14966 if (energy_dec) then
14967 write (iout,'(a6,2i5,0pf7.3,f7.3)') 'evdw1',i,j,evdwij,sss
14969 evdw1=evdw1+evdwij*sss*sss_ele_cut
14971 ! Calculate contributions to the Cartesian gradient.
14973 facvdw=-6*rrmij*(ev1+evdwij)*sss*sss_ele_cut
14977 ggg(1)=facvdw*xj+sss_ele_grad*rmij*evdwij*xj*sss &
14978 +evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*xj
14979 ggg(2)=facvdw*yj+sss_ele_grad*rmij*evdwij*yj*sss &
14980 +evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*yj
14981 ggg(3)=facvdw*zj+sss_ele_grad*rmij*evdwij*zj*sss &
14982 +evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*zj
14985 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
14986 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
14992 end subroutine evdwpp_short
14993 !-----------------------------------------------------------------------------
14994 subroutine escp_long(evdw2,evdw2_14)
14996 ! This subroutine calculates the excluded-volume interaction energy between
14997 ! peptide-group centers and side chains and its gradient in virtual-bond and
14998 ! side-chain vectors.
15000 ! implicit real*8 (a-h,o-z)
15001 ! include 'DIMENSIONS'
15002 ! include 'COMMON.GEO'
15003 ! include 'COMMON.VAR'
15004 ! include 'COMMON.LOCAL'
15005 ! include 'COMMON.CHAIN'
15006 ! include 'COMMON.DERIV'
15007 ! include 'COMMON.INTERACT'
15008 ! include 'COMMON.FFIELD'
15009 ! include 'COMMON.IOUNITS'
15010 ! include 'COMMON.CONTROL'
15011 real(kind=8),dimension(3) :: ggg
15012 !el local variables
15013 integer :: i,iint,j,k,iteli,itypj,subchap
15014 real(kind=8) :: xi,yi,zi,xj,yj,zj,rrij,sss,fac,e1,e2,sss_grad,rij
15015 real(kind=8) :: evdw2,evdw2_14,evdwij
15016 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
15017 dist_temp, dist_init
15021 !d print '(a)','Enter ESCP'
15022 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
15023 do i=iatscp_s,iatscp_e
15024 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
15026 xi=0.5D0*(c(1,i)+c(1,i+1))
15027 yi=0.5D0*(c(2,i)+c(2,i+1))
15028 zi=0.5D0*(c(3,i)+c(3,i+1))
15029 xi=mod(xi,boxxsize)
15030 if (xi.lt.0) xi=xi+boxxsize
15031 yi=mod(yi,boxysize)
15032 if (yi.lt.0) yi=yi+boxysize
15033 zi=mod(zi,boxzsize)
15034 if (zi.lt.0) zi=zi+boxzsize
15036 do iint=1,nscp_gr(i)
15038 do j=iscpstart(i,iint),iscpend(i,iint)
15040 if (itypj.eq.ntyp1) cycle
15041 ! Uncomment following three lines for SC-p interactions
15042 ! xj=c(1,nres+j)-xi
15043 ! yj=c(2,nres+j)-yi
15044 ! zj=c(3,nres+j)-zi
15045 ! Uncomment following three lines for Ca-p interactions
15049 xj=mod(xj,boxxsize)
15050 if (xj.lt.0) xj=xj+boxxsize
15051 yj=mod(yj,boxysize)
15052 if (yj.lt.0) yj=yj+boxysize
15053 zj=mod(zj,boxzsize)
15054 if (zj.lt.0) zj=zj+boxzsize
15055 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
15063 xj=xj_safe+xshift*boxxsize
15064 yj=yj_safe+yshift*boxysize
15065 zj=zj_safe+zshift*boxzsize
15066 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
15067 if(dist_temp.lt.dist_init) then
15068 dist_init=dist_temp
15077 if (subchap.eq.1) then
15086 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
15088 rij=dsqrt(1.0d0/rrij)
15089 sss_ele_cut=sscale_ele(rij)
15090 sss_ele_grad=sscagrad_ele(rij)
15091 ! print *,sss_ele_cut,sss_ele_grad,&
15092 ! (rij),r_cut_ele,rlamb_ele
15093 if (sss_ele_cut.le.0.0) cycle
15094 sss=sscale((rij/rscp(itypj,iteli)))
15095 sss_grad=sscale_grad(rij/rscp(itypj,iteli))
15096 if (sss.lt.1.0d0) then
15099 e1=fac*fac*aad(itypj,iteli)
15100 e2=fac*bad(itypj,iteli)
15101 if (iabs(j-i) .le. 2) then
15104 evdw2_14=evdw2_14+(e1+e2)*(1.0d0-sss)*sss_ele_cut
15107 evdw2=evdw2+evdwij*(1.0d0-sss)*sss_ele_cut
15108 if (energy_dec) write (iout,'(a6,2i5,2(0pf7.3))') &
15109 'evdw2',i,j,sss,evdwij
15111 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
15113 fac=-(evdwij+e1)*rrij*(1.0d0-sss)*sss_ele_cut
15114 fac=fac+evdwij*sss_ele_grad/rij/expon*(1.0d0-sss)&
15115 -evdwij*sss_ele_cut/rij/expon*sss_grad/rscp(itypj,iteli)
15119 ! Uncomment following three lines for SC-p interactions
15121 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
15123 ! Uncomment following line for SC-p interactions
15124 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
15126 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
15127 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
15136 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
15137 gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
15138 gradx_scp(j,i)=expon*gradx_scp(j,i)
15141 !******************************************************************************
15145 ! To save time the factor EXPON has been extracted from ALL components
15146 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
15149 !******************************************************************************
15151 end subroutine escp_long
15152 !-----------------------------------------------------------------------------
15153 subroutine escp_short(evdw2,evdw2_14)
15155 ! This subroutine calculates the excluded-volume interaction energy between
15156 ! peptide-group centers and side chains and its gradient in virtual-bond and
15157 ! side-chain vectors.
15159 ! implicit real*8 (a-h,o-z)
15160 ! include 'DIMENSIONS'
15161 ! include 'COMMON.GEO'
15162 ! include 'COMMON.VAR'
15163 ! include 'COMMON.LOCAL'
15164 ! include 'COMMON.CHAIN'
15165 ! include 'COMMON.DERIV'
15166 ! include 'COMMON.INTERACT'
15167 ! include 'COMMON.FFIELD'
15168 ! include 'COMMON.IOUNITS'
15169 ! include 'COMMON.CONTROL'
15170 real(kind=8),dimension(3) :: ggg
15171 !el local variables
15172 integer :: i,iint,j,k,iteli,itypj,subchap
15173 real(kind=8) :: xi,yi,zi,xj,yj,zj,rrij,sss,fac,e1,e2,sss_grad,rij
15174 real(kind=8) :: evdw2,evdw2_14,evdwij
15175 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
15176 dist_temp, dist_init
15180 !d print '(a)','Enter ESCP'
15181 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
15182 do i=iatscp_s,iatscp_e
15183 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
15185 xi=0.5D0*(c(1,i)+c(1,i+1))
15186 yi=0.5D0*(c(2,i)+c(2,i+1))
15187 zi=0.5D0*(c(3,i)+c(3,i+1))
15188 xi=mod(xi,boxxsize)
15189 if (xi.lt.0) xi=xi+boxxsize
15190 yi=mod(yi,boxysize)
15191 if (yi.lt.0) yi=yi+boxysize
15192 zi=mod(zi,boxzsize)
15193 if (zi.lt.0) zi=zi+boxzsize
15195 do iint=1,nscp_gr(i)
15197 do j=iscpstart(i,iint),iscpend(i,iint)
15199 if (itypj.eq.ntyp1) cycle
15200 ! Uncomment following three lines for SC-p interactions
15201 ! xj=c(1,nres+j)-xi
15202 ! yj=c(2,nres+j)-yi
15203 ! zj=c(3,nres+j)-zi
15204 ! Uncomment following three lines for Ca-p interactions
15211 xj=mod(xj,boxxsize)
15212 if (xj.lt.0) xj=xj+boxxsize
15213 yj=mod(yj,boxysize)
15214 if (yj.lt.0) yj=yj+boxysize
15215 zj=mod(zj,boxzsize)
15216 if (zj.lt.0) zj=zj+boxzsize
15217 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
15225 xj=xj_safe+xshift*boxxsize
15226 yj=yj_safe+yshift*boxysize
15227 zj=zj_safe+zshift*boxzsize
15228 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
15229 if(dist_temp.lt.dist_init) then
15230 dist_init=dist_temp
15239 if (subchap.eq.1) then
15249 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
15250 rij=dsqrt(1.0d0/rrij)
15251 sss_ele_cut=sscale_ele(rij)
15252 sss_ele_grad=sscagrad_ele(rij)
15253 ! print *,sss_ele_cut,sss_ele_grad,&
15254 ! (rij),r_cut_ele,rlamb_ele
15255 if (sss_ele_cut.le.0.0) cycle
15256 sss=sscale(rij/rscp(itypj,iteli))
15257 sss_grad=sscale_grad(rij/rscp(itypj,iteli))
15258 if (sss.gt.0.0d0) then
15261 e1=fac*fac*aad(itypj,iteli)
15262 e2=fac*bad(itypj,iteli)
15263 if (iabs(j-i) .le. 2) then
15266 evdw2_14=evdw2_14+(e1+e2)*sss*sss_ele_cut
15269 evdw2=evdw2+evdwij*sss*sss_ele_cut
15270 if (energy_dec) write (iout,'(a6,2i5,2(0pf7.3))') &
15271 'evdw2',i,j,sss,evdwij
15273 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
15275 fac=-(evdwij+e1)*rrij*sss*sss_ele_cut
15276 fac=fac+evdwij*sss_ele_grad/rij/expon*sss &
15277 +evdwij*sss_ele_cut/rij/expon*sss_grad/rscp(itypj,iteli)
15282 ! Uncomment following three lines for SC-p interactions
15284 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
15286 ! Uncomment following line for SC-p interactions
15287 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
15289 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
15290 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
15299 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
15300 gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
15301 gradx_scp(j,i)=expon*gradx_scp(j,i)
15304 !******************************************************************************
15308 ! To save time the factor EXPON has been extracted from ALL components
15309 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
15312 !******************************************************************************
15314 end subroutine escp_short
15315 !-----------------------------------------------------------------------------
15316 ! energy_p_new-sep_barrier.F
15317 !-----------------------------------------------------------------------------
15318 subroutine sc_grad_scale(scalfac)
15319 ! implicit real*8 (a-h,o-z)
15321 ! include 'DIMENSIONS'
15322 ! include 'COMMON.CHAIN'
15323 ! include 'COMMON.DERIV'
15324 ! include 'COMMON.CALC'
15325 ! include 'COMMON.IOUNITS'
15326 real(kind=8),dimension(3) :: dcosom1,dcosom2
15327 real(kind=8) :: scalfac
15328 !el local variables
15329 ! integer :: i,j,k,l
15331 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
15332 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
15333 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12 &
15334 -2.0D0*alf12*eps3der+sigder*sigsq_om12
15338 ! eom12=evdwij*eps1_om12
15340 ! write (iout,*) "eps2der",eps2der," eps3der",eps3der,
15341 ! & " sigder",sigder
15342 ! write (iout,*) "eps1_om12",eps1_om12," eps2rt_om12",eps2rt_om12
15343 ! write (iout,*) "eom1",eom1," eom2",eom2," eom12",eom12
15345 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
15346 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
15349 gg(k)=(gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k))*scalfac&
15352 ! write (iout,*) "gg",(gg(k),k=1,3)
15354 gvdwx(k,i)=gvdwx(k,i)-gg(k) &
15355 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
15356 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv*scalfac&
15358 gvdwx(k,j)=gvdwx(k,j)+gg(k) &
15359 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
15360 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv*scalfac&
15362 ! write (iout,*)(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))
15363 ! & +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
15364 ! write (iout,*)(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))
15365 ! & +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
15368 ! Calculate the components of the gradient in DC and X
15371 gvdwc(l,i)=gvdwc(l,i)-gg(l)
15372 gvdwc(l,j)=gvdwc(l,j)+gg(l)
15375 end subroutine sc_grad_scale
15376 !-----------------------------------------------------------------------------
15377 ! energy_split-sep.F
15378 !-----------------------------------------------------------------------------
15379 subroutine etotal_long(energia)
15381 ! Compute the long-range slow-varying contributions to the energy
15383 ! implicit real*8 (a-h,o-z)
15384 ! include 'DIMENSIONS'
15385 use MD_data, only: totT,usampl,eq_time
15389 !MS$ATTRIBUTES C :: proc_proc
15394 real(kind=8),dimension(n_ene) :: weights_!,time_Bcast,time_Bcastw
15396 ! include 'COMMON.SETUP'
15397 ! include 'COMMON.IOUNITS'
15398 ! include 'COMMON.FFIELD'
15399 ! include 'COMMON.DERIV'
15400 ! include 'COMMON.INTERACT'
15401 ! include 'COMMON.SBRIDGE'
15402 ! include 'COMMON.CHAIN'
15403 ! include 'COMMON.VAR'
15404 ! include 'COMMON.LOCAL'
15405 ! include 'COMMON.MD'
15406 real(kind=8),dimension(0:n_ene) :: energia
15407 !el local variables
15408 integer :: i,n_corr,n_corr1,ierror,ierr
15409 real(kind=8) :: evdw2,evdw2_14,ehpb,etors,edihcnstr,etors_d,esccor,&
15410 evdw,ees,evdw1,eel_loc,eello_turn3,eello_turn4,&
15411 ecorr,ecorr5,ecorr6,eturn6,time00
15412 ! write(iout,'(a,i2)')'Calling etotal_long ipot=',ipot
15413 !elwrite(iout,*)"in etotal long"
15415 if (modecalc.eq.12.or.modecalc.eq.14) then
15417 ! if (fg_rank.eq.0) call int_from_cart1(.false.)
15419 call int_from_cart1(.false.)
15422 !elwrite(iout,*)"in etotal long"
15425 ! write(iout,*) "ETOTAL_LONG Processor",fg_rank,
15426 ! & " absolute rank",myrank," nfgtasks",nfgtasks
15428 if (nfgtasks.gt.1) then
15430 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
15431 if (fg_rank.eq.0) then
15432 call MPI_Bcast(3,1,MPI_INTEGER,king,FG_COMM,IERROR)
15433 ! write (iout,*) "Processor",myrank," BROADCAST iorder"
15435 ! FG master sets up the WEIGHTS_ array which will be broadcast to the
15436 ! FG slaves as WEIGHTS array.
15443 weights_(7)=wel_loc
15446 weights_(10)=wturn6
15448 weights_(12)=wscloc
15450 weights_(14)=wtor_d
15451 weights_(15)=wstrain
15452 weights_(16)=wvdwpp
15454 weights_(18)=scal14
15455 weights_(21)=wsccor
15456 ! FG Master broadcasts the WEIGHTS_ array
15457 call MPI_Bcast(weights_(1),n_ene,&
15458 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
15460 ! FG slaves receive the WEIGHTS array
15461 call MPI_Bcast(weights(1),n_ene,&
15462 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
15477 wstrain=weights(15)
15483 call MPI_Bcast(dc(1,1),6*nres,MPI_DOUBLE_PRECISION,&
15485 time_Bcast=time_Bcast+MPI_Wtime()-time00
15486 time_Bcastw=time_Bcastw+MPI_Wtime()-time00
15487 ! call chainbuild_cart
15488 ! call int_from_cart1(.false.)
15490 ! write (iout,*) 'Processor',myrank,
15491 ! & ' calling etotal_short ipot=',ipot
15493 ! print *,'Processor',myrank,' nnt=',nnt,' nct=',nct
15495 !d print *,'nnt=',nnt,' nct=',nct
15497 !elwrite(iout,*)"in etotal long"
15498 ! Compute the side-chain and electrostatic interaction energy
15500 goto (101,102,103,104,105,106) ipot
15501 ! Lennard-Jones potential.
15502 101 call elj_long(evdw)
15503 !d print '(a)','Exit ELJ'
15505 ! Lennard-Jones-Kihara potential (shifted).
15506 102 call eljk_long(evdw)
15508 ! Berne-Pechukas potential (dilated LJ, angular dependence).
15509 103 call ebp_long(evdw)
15511 ! Gay-Berne potential (shifted LJ, angular dependence).
15512 104 call egb_long(evdw)
15514 ! Gay-Berne-Vorobjev potential (shifted LJ, angular dependence).
15515 105 call egbv_long(evdw)
15517 ! Soft-sphere potential
15518 106 call e_softsphere(evdw)
15520 ! Calculate electrostatic (H-bonding) energy of the main chain.
15524 if (ipot.lt.6) then
15526 if (welec.gt.0d0.or.wvdwpp.gt.0d0.or.wel_loc.gt.0d0.or. &
15527 wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0 &
15528 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
15529 .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
15531 if (welec.gt.0d0.or.wel_loc.gt.0d0.or. &
15532 wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0 &
15533 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
15534 .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
15536 call eelec_scale(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
15545 ! write (iout,*) "Soft-spheer ELEC potential"
15546 call eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,&
15550 ! Calculate excluded-volume interaction energy between peptide groups
15553 if (ipot.lt.6) then
15554 if(wscp.gt.0d0) then
15555 call escp_long(evdw2,evdw2_14)
15561 call escp_soft_sphere(evdw2,evdw2_14)
15564 ! 12/1/95 Multi-body terms
15568 if ((wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 &
15569 .or. wturn6.gt.0.0d0) .and. ipot.lt.6) then
15570 call multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
15571 ! write (2,*) 'n_corr=',n_corr,' n_corr1=',n_corr1,
15572 ! &" ecorr",ecorr," ecorr5",ecorr5," ecorr6",ecorr6," eturn6",eturn6
15579 if ((wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) .and. ipot.lt.6) then
15580 call multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
15583 ! If performing constraint dynamics, call the constraint energy
15584 ! after the equilibration time
15585 if(usampl.and.totT.gt.eq_time) then
15600 energia(2)=evdw2-evdw2_14
15601 energia(18)=evdw2_14
15610 energia(3)=ees+evdw1
15617 energia(8)=eello_turn3
15618 energia(9)=eello_turn4
15620 energia(20)=Uconst+Uconst_back
15621 call sum_energy(energia,.true.)
15622 ! write (iout,*) "Exit ETOTAL_LONG"
15625 end subroutine etotal_long
15626 !-----------------------------------------------------------------------------
15627 subroutine etotal_short(energia)
15629 ! Compute the short-range fast-varying contributions to the energy
15631 ! implicit real*8 (a-h,o-z)
15632 ! include 'DIMENSIONS'
15636 !MS$ATTRIBUTES C :: proc_proc
15641 integer :: ierror,ierr
15642 real(kind=8),dimension(n_ene) :: weights_
15643 real(kind=8) :: time00
15645 ! include 'COMMON.SETUP'
15646 ! include 'COMMON.IOUNITS'
15647 ! include 'COMMON.FFIELD'
15648 ! include 'COMMON.DERIV'
15649 ! include 'COMMON.INTERACT'
15650 ! include 'COMMON.SBRIDGE'
15651 ! include 'COMMON.CHAIN'
15652 ! include 'COMMON.VAR'
15653 ! include 'COMMON.LOCAL'
15654 real(kind=8),dimension(0:n_ene) :: energia
15655 !el local variables
15657 real(kind=8) :: evdw,evdw1,evdw2,evdw2_14,esccor,etors_d,etors
15658 real(kind=8) :: ehpb,escloc,estr,ebe,edihcnstr,ethetacnstr
15661 ! write(iout,'(a,i2)')'Calling etotal_short ipot=',ipot
15663 if (modecalc.eq.12.or.modecalc.eq.14) then
15665 if (fg_rank.eq.0) call int_from_cart1(.false.)
15667 call int_from_cart1(.false.)
15671 ! write(iout,*) "ETOTAL_SHORT Processor",fg_rank,
15672 ! & " absolute rank",myrank," nfgtasks",nfgtasks
15674 if (nfgtasks.gt.1) then
15676 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
15677 if (fg_rank.eq.0) then
15678 call MPI_Bcast(2,1,MPI_INTEGER,king,FG_COMM,IERROR)
15679 ! write (iout,*) "Processor",myrank," BROADCAST iorder"
15681 ! FG master sets up the WEIGHTS_ array which will be broadcast to the
15682 ! FG slaves as WEIGHTS array.
15689 weights_(7)=wel_loc
15692 weights_(10)=wturn6
15694 weights_(12)=wscloc
15696 weights_(14)=wtor_d
15697 weights_(15)=wstrain
15698 weights_(16)=wvdwpp
15700 weights_(18)=scal14
15701 weights_(21)=wsccor
15702 ! FG Master broadcasts the WEIGHTS_ array
15703 call MPI_Bcast(weights_(1),n_ene,&
15704 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
15706 ! FG slaves receive the WEIGHTS array
15707 call MPI_Bcast(weights(1),n_ene,&
15708 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
15723 wstrain=weights(15)
15729 ! write (iout,*),"Processor",myrank," BROADCAST weights"
15730 call MPI_Bcast(c(1,1),nres6,MPI_DOUBLE_PRECISION,&
15732 ! write (iout,*) "Processor",myrank," BROADCAST c"
15733 call MPI_Bcast(dc(1,1),nres6,MPI_DOUBLE_PRECISION,&
15735 ! write (iout,*) "Processor",myrank," BROADCAST dc"
15736 call MPI_Bcast(dc_norm(1,1),nres6,MPI_DOUBLE_PRECISION,&
15738 ! write (iout,*) "Processor",myrank," BROADCAST dc_norm"
15739 call MPI_Bcast(theta(1),nres,MPI_DOUBLE_PRECISION,&
15741 ! write (iout,*) "Processor",myrank," BROADCAST theta"
15742 call MPI_Bcast(phi(1),nres,MPI_DOUBLE_PRECISION,&
15744 ! write (iout,*) "Processor",myrank," BROADCAST phi"
15745 call MPI_Bcast(alph(1),nres,MPI_DOUBLE_PRECISION,&
15747 ! write (iout,*) "Processor",myrank," BROADCAST alph"
15748 call MPI_Bcast(omeg(1),nres,MPI_DOUBLE_PRECISION,&
15750 ! write (iout,*) "Processor",myrank," BROADCAST omeg"
15751 call MPI_Bcast(vbld(1),2*nres,MPI_DOUBLE_PRECISION,&
15753 ! write (iout,*) "Processor",myrank," BROADCAST vbld"
15754 call MPI_Bcast(vbld_inv(1),2*nres,MPI_DOUBLE_PRECISION,&
15756 time_Bcast=time_Bcast+MPI_Wtime()-time00
15757 ! write (iout,*) "Processor",myrank," BROADCAST vbld_inv"
15759 ! write (iout,*) 'Processor',myrank,
15760 ! & ' calling etotal_short ipot=',ipot
15762 ! print *,'Processor',myrank,' nnt=',nnt,' nct=',nct
15764 ! call int_from_cart1(.false.)
15766 ! Compute the side-chain and electrostatic interaction energy
15768 goto (101,102,103,104,105,106) ipot
15769 ! Lennard-Jones potential.
15770 101 call elj_short(evdw)
15771 !d print '(a)','Exit ELJ'
15773 ! Lennard-Jones-Kihara potential (shifted).
15774 102 call eljk_short(evdw)
15776 ! Berne-Pechukas potential (dilated LJ, angular dependence).
15777 103 call ebp_short(evdw)
15779 ! Gay-Berne potential (shifted LJ, angular dependence).
15780 104 call egb_short(evdw)
15782 ! Gay-Berne-Vorobjev potential (shifted LJ, angular dependence).
15783 105 call egbv_short(evdw)
15785 ! Soft-sphere potential - already dealt with in the long-range part
15787 ! 106 call e_softsphere_short(evdw)
15789 ! Calculate electrostatic (H-bonding) energy of the main chain.
15793 ! Calculate the short-range part of Evdwpp
15795 call evdwpp_short(evdw1)
15797 ! Calculate the short-range part of ESCp
15799 if (ipot.lt.6) then
15800 call escp_short(evdw2,evdw2_14)
15803 ! Calculate the bond-stretching energy
15807 ! Calculate the disulfide-bridge and other energy and the contributions
15808 ! from other distance constraints.
15811 ! Calculate the virtual-bond-angle energy.
15813 call ebend(ebe,ethetacnstr)
15815 ! Calculate the SC local energy.
15820 ! Calculate the virtual-bond torsional energy.
15822 call etor(etors,edihcnstr)
15824 ! 6/23/01 Calculate double-torsional energy
15826 call etor_d(etors_d)
15828 ! 21/5/07 Calculate local sicdechain correlation energy
15830 if (wsccor.gt.0.0d0) then
15831 call eback_sc_corr(esccor)
15836 ! Put energy components into an array
15843 energia(2)=evdw2-evdw2_14
15844 energia(18)=evdw2_14
15857 energia(14)=etors_d
15860 energia(19)=edihcnstr
15862 ! write (iout,*) "ETOTAL_SHORT before SUM_ENERGY"
15864 call sum_energy(energia,.true.)
15865 ! write (iout,*) "Exit ETOTAL_SHORT"
15868 end subroutine etotal_short
15869 !-----------------------------------------------------------------------------
15871 !-----------------------------------------------------------------------------
15872 real(kind=8) function gnmr1(y,ymin,ymax)
15874 real(kind=8) :: y,ymin,ymax
15875 real(kind=8) :: wykl=4.0d0
15876 if (y.lt.ymin) then
15877 gnmr1=(ymin-y)**wykl/wykl
15878 else if (y.gt.ymax) then
15879 gnmr1=(y-ymax)**wykl/wykl
15885 !-----------------------------------------------------------------------------
15886 real(kind=8) function gnmr1prim(y,ymin,ymax)
15888 real(kind=8) :: y,ymin,ymax
15889 real(kind=8) :: wykl=4.0d0
15890 if (y.lt.ymin) then
15891 gnmr1prim=-(ymin-y)**(wykl-1)
15892 else if (y.gt.ymax) then
15893 gnmr1prim=(y-ymax)**(wykl-1)
15898 end function gnmr1prim
15899 !----------------------------------------------------------------------------
15900 real(kind=8) function rlornmr1(y,ymin,ymax,sigma)
15901 real(kind=8) y,ymin,ymax,sigma
15902 real(kind=8) wykl /4.0d0/
15903 if (y.lt.ymin) then
15904 rlornmr1=(ymin-y)**wykl/((ymin-y)**wykl+sigma**wykl)
15905 else if (y.gt.ymax) then
15906 rlornmr1=(y-ymax)**wykl/((y-ymax)**wykl+sigma**wykl)
15911 end function rlornmr1
15912 !------------------------------------------------------------------------------
15913 real(kind=8) function rlornmr1prim(y,ymin,ymax,sigma)
15914 real(kind=8) y,ymin,ymax,sigma
15915 real(kind=8) wykl /4.0d0/
15916 if (y.lt.ymin) then
15917 rlornmr1prim=-(ymin-y)**(wykl-1)*sigma**wykl*wykl/ &
15918 ((ymin-y)**wykl+sigma**wykl)**2
15919 else if (y.gt.ymax) then
15920 rlornmr1prim=(y-ymax)**(wykl-1)*sigma**wykl*wykl/ &
15921 ((y-ymax)**wykl+sigma**wykl)**2
15926 end function rlornmr1prim
15928 real(kind=8) function harmonic(y,ymax)
15930 real(kind=8) :: y,ymax
15931 real(kind=8) :: wykl=2.0d0
15932 harmonic=(y-ymax)**wykl
15934 end function harmonic
15935 !-----------------------------------------------------------------------------
15936 real(kind=8) function harmonicprim(y,ymax)
15937 real(kind=8) :: y,ymin,ymax
15938 real(kind=8) :: wykl=2.0d0
15939 harmonicprim=(y-ymax)*wykl
15941 end function harmonicprim
15942 !-----------------------------------------------------------------------------
15944 !-----------------------------------------------------------------------------
15945 subroutine gradient(n,x,nf,g,uiparm,urparm,ufparm)
15947 use io_base, only:intout,briefout
15948 ! implicit real*8 (a-h,o-z)
15949 ! include 'DIMENSIONS'
15950 ! include 'COMMON.CHAIN'
15951 ! include 'COMMON.DERIV'
15952 ! include 'COMMON.VAR'
15953 ! include 'COMMON.INTERACT'
15954 ! include 'COMMON.FFIELD'
15955 ! include 'COMMON.MD'
15956 ! include 'COMMON.IOUNITS'
15957 real(kind=8),external :: ufparm
15958 integer :: uiparm(1)
15959 real(kind=8) :: urparm(1)
15960 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
15961 real(kind=8) :: f,gthetai,gphii,galphai,gomegai
15962 integer :: n,nf,ind,ind1,i,k,j
15964 ! This subroutine calculates total internal coordinate gradient.
15965 ! Depending on the number of function evaluations, either whole energy
15966 ! is evaluated beforehand, Cartesian coordinates and their derivatives in
15967 ! internal coordinates are reevaluated or only the cartesian-in-internal
15968 ! coordinate derivatives are evaluated. The subroutine was designed to work
15974 !d print *,'grad',nf,icg
15975 if (nf-nfl+1) 20,30,40
15976 20 call func(n,x,nf,f,uiparm,urparm,ufparm)
15977 ! write (iout,*) 'grad 20'
15978 if (nf.eq.0) return
15980 30 call var_to_geom(n,x)
15982 ! write (iout,*) 'grad 30'
15984 ! Evaluate the derivatives of virtual bond lengths and SC vectors in variables.
15987 ! write (iout,*) 'grad 40'
15988 ! print *,'GRADIENT: nnt=',nnt,' nct=',nct,' expon=',expon
15990 ! Convert the Cartesian gradient into internal-coordinate gradient.
16000 ! print *,'GRAD: i=',i,' jc=',j,' ind=',ind
16002 gthetai=gthetai+dcdv(k,ind)*gradc(k,j,icg)
16005 gphii=gphii+dcdv(k+3,ind)*gradc(k,j,icg)
16011 ! print *,'GRAD: i=',i,' jx=',j,' ind1=',ind1
16013 gthetai=gthetai+dxdv(k,ind1)*gradx(k,j,icg)
16014 gphii=gphii+dxdv(k+3,ind1)*gradx(k,j,icg)
16017 if (i.gt.1) g(i-1)=gphii
16018 if (n.gt.nphi) g(nphi+i)=gthetai
16020 if (n.le.nphi+ntheta) goto 10
16022 if (itype(i,1).ne.10) then
16026 galphai=galphai+dxds(k,i)*gradx(k,i,icg)
16029 gomegai=gomegai+dxds(k+3,i)*gradx(k,i,icg)
16031 g(ialph(i,1))=galphai
16032 g(ialph(i,1)+nside)=gomegai
16036 ! Add the components corresponding to local energy terms.
16040 !d write (iout,*) 'i=',i,'g=',g(i),' gloc=',gloc(i,icg)
16041 g(i)=g(i)+gloc(i,icg)
16043 ! Uncomment following three lines for diagnostics.
16045 !elwrite(iout,*) "in gradient after calling intout"
16046 !d call briefout(0,0.0d0)
16047 !d write (iout,'(i3,1pe15.5)') (k,g(k),k=1,n)
16049 end subroutine gradient
16050 !-----------------------------------------------------------------------------
16051 subroutine func(n,x,nf,f,uiparm,urparm,ufparm) !from minimize_p.F
16054 ! implicit real*8 (a-h,o-z)
16055 ! include 'DIMENSIONS'
16056 ! include 'COMMON.DERIV'
16057 ! include 'COMMON.IOUNITS'
16058 ! include 'COMMON.GEO'
16061 !el common /chuju/ jjj
16062 real(kind=8) :: energia(0:n_ene)
16063 integer :: uiparm(1)
16064 real(kind=8) :: urparm(1)
16066 real(kind=8),external :: ufparm
16067 real(kind=8),dimension(6*nres) :: x !(maxvar) (maxvar=6*maxres)
16068 ! if (jjj.gt.0) then
16069 ! write (iout,'(10f8.3)') (rad2deg*x(i),i=1,n)
16073 !d print *,'func',nf,nfl,icg
16074 call var_to_geom(n,x)
16077 !d write (iout,*) 'ETOTAL called from FUNC'
16078 call etotal(energia)
16081 ! if (jjj.gt.0) then
16082 ! write (iout,'(10f8.3)') (rad2deg*x(i),i=1,n)
16083 ! write (iout,*) 'f=',etot
16087 end subroutine func
16088 !-----------------------------------------------------------------------------
16089 subroutine cartgrad
16090 ! implicit real*8 (a-h,o-z)
16091 ! include 'DIMENSIONS'
16093 use MD_data, only: totT,usampl,eq_time
16097 ! include 'COMMON.CHAIN'
16098 ! include 'COMMON.DERIV'
16099 ! include 'COMMON.VAR'
16100 ! include 'COMMON.INTERACT'
16101 ! include 'COMMON.FFIELD'
16102 ! include 'COMMON.MD'
16103 ! include 'COMMON.IOUNITS'
16104 ! include 'COMMON.TIME1'
16108 ! This subrouting calculates total Cartesian coordinate gradient.
16109 ! The subroutine chainbuild_cart and energy MUST be called beforehand.
16119 !el write (iout,*) "After sum_gradient"
16121 !el write (iout,*) "After sum_gradient"
16123 write (iout,*) i," gradc ",(gradc(j,i,icg),j=1,3)
16124 write (iout,*) i," gradx ",(gradx(j,i,icg),j=1,3)
16127 ! If performing constraint dynamics, add the gradients of the constraint energy
16128 if(usampl.and.totT.gt.eq_time) then
16131 gradc(j,i,icg)=gradc(j,i,icg)+dudconst(j,i)+duscdiff(j,i)
16132 gradx(j,i,icg)=gradx(j,i,icg)+dudxconst(j,i)+duscdiffx(j,i)
16136 gloc(i,icg)=gloc(i,icg)+dugamma(i)
16139 gloc(nphi+i,icg)=gloc(nphi+i,icg)+dutheta(i)
16142 !elwrite (iout,*) "After sum_gradient"
16147 !elwrite (iout,*) "After sum_gradient"
16149 time_intcartderiv=time_intcartderiv+MPI_Wtime()-time01
16151 ! call checkintcartgrad
16152 ! write(iout,*) 'calling int_to_cart'
16154 write (iout,*) "gcart, gxcart, gloc before int_to_cart"
16158 gcart(j,i)=gradc(j,i,icg)
16159 gxcart(j,i)=gradx(j,i,icg)
16160 ! if (i.le.2) print *,"gcart_one",gcart(j,i),gradc(j,i,icg)
16163 write (iout,'(i5,2(3f10.5,5x),f10.5)') i,(gcart(j,i),j=1,3),&
16164 (gxcart(j,i),j=1,3),gloc(i,icg)
16171 ! print *,"gcart_two",gcart(2,2),gradc(2,2,icg)
16174 time_inttocart=time_inttocart+MPI_Wtime()-time01
16177 write (iout,*) "gcart and gxcart after int_to_cart"
16179 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
16180 (gxcart(j,i),j=1,3)
16185 write (iout,*) "CARGRAD"
16189 gcart(j,i)=-gcart(j,i)+gcart(j,i-1)-gxcart(j,i)
16190 ! gcart_new(j,i)=-gcart(j,i)+gcart(j,i-1)-gxcart(j,i)
16192 ! write (iout,'(i5,3f10.5,5x,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3), &
16193 ! (gcart_new(j,i),j=1,3),(gxcart(j,i),j=1,3)
16195 ! Correction: dummy residues
16198 ! gcart_new(j,nnt)=gcart_new(j,nnt)+gcart_new(j,1)
16199 gcart(j,nnt)=gcart(j,nnt)+gcart(j,1)
16202 if (nct.lt.nres) then
16204 ! gcart_new(j,nct)=gcart_new(j,nct)+gcart_new(j,nres)
16205 gcart(j,nct)=gcart(j,nct)+gcart(j,nres)
16210 time_cartgrad=time_cartgrad+MPI_Wtime()-time00
16214 end subroutine cartgrad
16215 !-----------------------------------------------------------------------------
16216 subroutine zerograd
16217 ! implicit real*8 (a-h,o-z)
16218 ! include 'DIMENSIONS'
16219 ! include 'COMMON.DERIV'
16220 ! include 'COMMON.CHAIN'
16221 ! include 'COMMON.VAR'
16222 ! include 'COMMON.MD'
16223 ! include 'COMMON.SCCOR'
16225 !el local variables
16226 integer :: i,j,intertyp,k
16227 ! Initialize Cartesian-coordinate gradient
16229 ! if (.not.allocated(gradx)) allocate(gradx(3,nres,2)) !(3,maxres,2)
16230 ! if (.not.allocated(gradc)) allocate(gradc(3,nres,2)) !(3,maxres,2)
16232 ! allocate(gvdwx(3,nres),gvdwc(3,nres),gelc(3,nres),gelc_long(3,nres))
16233 ! allocate(gvdwpp(3,nres),gvdwc_scpp(3,nres),gradx_scp(3,nres))
16234 ! allocate(gvdwc_scp(3,nres),ghpbx(3,nres),ghpbc(3,nres))
16235 ! allocate(gradcorr_long(3,nres))
16236 ! allocate(gradcorr5_long(3,nres),gradcorr6_long(3,nres))
16237 ! allocate(gcorr6_turn_long(3,nres))
16238 ! allocate(gradcorr5(3,nres),gradcorr6(3,nres)) !(3,maxres)
16240 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres)) !(3,maxres)
16242 ! allocate(gel_loc(3,nres),gel_loc_long(3,nres),gcorr3_turn(3,nres))
16243 ! allocate(gcorr4_turn(3,nres),gcorr6_turn(3,nres))
16245 ! if (.not.allocated(gradb)) allocate(gradb(3,nres)) !(3,maxres)
16246 ! if (.not.allocated(gradbx)) allocate(gradbx(3,nres)) !(3,maxres)
16248 ! allocate(gsccorc(3,nres),gsccorx(3,nres)) !(3,maxres)
16249 ! allocate(gscloc(3,nres)) !(3,maxres)
16250 ! if (.not.allocated(gsclocx)) allocate(gsclocx(3,nres)) !(3,maxres)
16254 ! common /deriv_scloc/
16255 ! allocate(dXX_C1tab(3,nres),dYY_C1tab(3,nres),dZZ_C1tab(3,nres))
16256 ! allocate(dXX_Ctab(3,nres),dYY_Ctab(3,nres),dZZ_Ctab(3,nres))
16257 ! allocate(dXX_XYZtab(3,nres),dYY_XYZtab(3,nres),dZZ_XYZtab(3,nres)) !(3,maxres)
16259 ! allocate(jgrad_start(nres),jgrad_end(nres)) !(maxres)
16263 ! gradc(j,i,icg)=0.0d0
16264 ! gradx(j,i,icg)=0.0d0
16266 ! allocate(gloc_sc(3,nres,10)) !(3,0:maxres2,10)maxres2=2*maxres
16267 !elwrite(iout,*) "icg",icg
16271 gradx_scp(j,i)=0.0D0
16273 gvdwc_scp(j,i)=0.0D0
16274 gvdwc_scpp(j,i)=0.0d0
16276 gelc_long(j,i)=0.0D0
16281 gel_loc_long(j,i)=0.0d0
16284 gcorr3_turn(j,i)=0.0d0
16285 gcorr4_turn(j,i)=0.0d0
16286 gradcorr(j,i)=0.0d0
16287 gradcorr_long(j,i)=0.0d0
16288 gradcorr5_long(j,i)=0.0d0
16289 gradcorr6_long(j,i)=0.0d0
16290 gcorr6_turn_long(j,i)=0.0d0
16291 gradcorr5(j,i)=0.0d0
16292 gradcorr6(j,i)=0.0d0
16293 gcorr6_turn(j,i)=0.0d0
16296 gradc(j,i,icg)=0.0d0
16297 gradx(j,i,icg)=0.0d0
16300 gliptran(j,i)=0.0d0
16301 gliptranx(j,i)=0.0d0
16302 gliptranc(j,i)=0.0d0
16303 gshieldx(j,i)=0.0d0
16304 gshieldc(j,i)=0.0d0
16305 gshieldc_loc(j,i)=0.0d0
16306 gshieldx_ec(j,i)=0.0d0
16307 gshieldc_ec(j,i)=0.0d0
16308 gshieldc_loc_ec(j,i)=0.0d0
16309 gshieldx_t3(j,i)=0.0d0
16310 gshieldc_t3(j,i)=0.0d0
16311 gshieldc_loc_t3(j,i)=0.0d0
16312 gshieldx_t4(j,i)=0.0d0
16313 gshieldc_t4(j,i)=0.0d0
16314 gshieldc_loc_t4(j,i)=0.0d0
16315 gshieldx_ll(j,i)=0.0d0
16316 gshieldc_ll(j,i)=0.0d0
16317 gshieldc_loc_ll(j,i)=0.0d0
16319 gg_tube_sc(j,i)=0.0d0
16321 gradb_nucl(j,i)=0.0d0
16322 gradbx_nucl(j,i)=0.0d0
16323 gvdwpp_nucl(j,i)=0.0d0
16327 gvdwpsb1(j,i)=0.0d0
16331 gradcorr_nucl(j,i)=0.0d0
16332 gradcorr3_nucl(j,i)=0.0d0
16333 gradxorr_nucl(j,i)=0.0d0
16334 gradxorr3_nucl(j,i)=0.0d0
16343 gloc_sc(intertyp,i,icg)=0.0d0
16352 grad_shield_side(k,j,i)=0.0d0
16353 grad_shield_loc(k,j,i)=0.0d0
16360 ! Initialize the gradient of local energy terms.
16362 ! allocate(gloc(4*nres,2)) !!(maxvar,2)(maxvar=6*maxres)
16363 ! if (.not.allocated(gel_loc_loc)) allocate(gel_loc_loc(nres)) !(maxvar)(maxvar=6*maxres)
16364 ! if (.not.allocated(gcorr_loc)) allocate(gcorr_loc(nres)) !(maxvar)(maxvar=6*maxres)
16365 ! allocate(g_corr5_loc(nres),g_corr6_loc(nres)) !(maxvar)(maxvar=6*maxres)
16366 ! allocate(gel_loc_turn3(nres))
16367 ! allocate(gel_loc_turn4(nres),gel_loc_turn6(nres)) !(maxvar)(maxvar=6*maxres)
16368 ! allocate(gsccor_loc(nres)) !(maxres)
16374 gel_loc_loc(i)=0.0d0
16376 g_corr5_loc(i)=0.0d0
16377 g_corr6_loc(i)=0.0d0
16378 gel_loc_turn3(i)=0.0d0
16379 gel_loc_turn4(i)=0.0d0
16380 gel_loc_turn6(i)=0.0d0
16381 gsccor_loc(i)=0.0d0
16383 ! initialize gcart and gxcart
16384 ! allocate(gcart(3,0:nres),gxcart(3,0:nres)) !(3,0:MAXRES)
16392 end subroutine zerograd
16393 !-----------------------------------------------------------------------------
16394 real(kind=8) function fdum()
16398 !-----------------------------------------------------------------------------
16400 !-----------------------------------------------------------------------------
16401 subroutine intcartderiv
16402 ! implicit real*8 (a-h,o-z)
16403 ! include 'DIMENSIONS'
16407 ! include 'COMMON.SETUP'
16408 ! include 'COMMON.CHAIN'
16409 ! include 'COMMON.VAR'
16410 ! include 'COMMON.GEO'
16411 ! include 'COMMON.INTERACT'
16412 ! include 'COMMON.DERIV'
16413 ! include 'COMMON.IOUNITS'
16414 ! include 'COMMON.LOCAL'
16415 ! include 'COMMON.SCCOR'
16416 real(kind=8) :: pi4,pi34
16417 real(kind=8),dimension(3,2,nres) :: dcostheta ! (3,2,maxres)
16418 real(kind=8),dimension(3,3,nres) :: dcosphi,dsinphi,dcosalpha,&
16419 dcosomega,dsinomega !(3,3,maxres)
16420 real(kind=8),dimension(3) :: vo1,vo2,vo3,dummy,vp1,vp2,vp3,vpp1,n
16423 real(kind=8) :: cost,sint,cost1,sint1,cost2,sint2,sing,cosg,scalp,&
16424 fac0,fac1,fac2,fac3,fac4,fac5,fac6,ctgt,ctgt1,cosg_inv,&
16425 fac7,fac8,fac9,scala1,scala2,cosa,sina,sino,fac15,fac16,&
16426 fac17,coso_inv,fac10,fac11,fac12,fac13,fac14
16430 !el from module energy-------------
16431 !el allocate(dcostau(3,3,3,itau_start:itau_end)) !(3,3,3,maxres2)maxres2=2*maxres
16432 !el allocate(dsintau(3,3,3,itau_start:itau_end))
16433 !el allocate(dtauangle(3,3,3,itau_start:itau_end))
16435 !el allocate(dcostau(3,3,3,0:nres2)) !(3,3,3,maxres2)maxres2=2*maxres
16436 !el allocate(dsintau(3,3,3,0:nres2))
16437 !el allocate(dtauangle(3,3,3,0:nres2))
16438 !el allocate(domicron(3,2,2,0:nres2))
16439 !el allocate(dcosomicron(3,2,2,0:nres2))
16443 #if defined(MPI) && defined(PARINTDER)
16444 if (nfgtasks.gt.1 .and. me.eq.king) &
16445 call MPI_Bcast(8,1,MPI_INTEGER,king,FG_COMM,IERROR)
16450 ! allocate(dtheta(3,2,nres)) !(3,2,maxres)
16451 ! allocate(dphi(3,3,nres),dalpha(3,3,nres),domega(3,3,nres)) !(3,3,maxres)
16453 ! write (iout,*) "iphi1_start",iphi1_start," iphi1_end",iphi1_end
16456 dtheta(j,1,i)=0.0d0
16457 dtheta(j,2,i)=0.0d0
16463 ! Derivatives of theta's
16464 #if defined(MPI) && defined(PARINTDER)
16465 ! We need dtheta(:,:,i-1) to compute dphi(:,:,i)
16466 do i=max0(ithet_start-1,3),ithet_end
16470 cost=dcos(theta(i))
16471 sint=sqrt(1-cost*cost)
16473 dcostheta(j,1,i)=-(dc_norm(j,i-1)+cost*dc_norm(j,i-2))/&
16475 if (itype(i-1,1).ne.ntyp1) dtheta(j,1,i)=-dcostheta(j,1,i)/sint
16476 dcostheta(j,2,i)=-(dc_norm(j,i-2)+cost*dc_norm(j,i-1))/&
16478 if (itype(i-1,1).ne.ntyp1) dtheta(j,2,i)=-dcostheta(j,2,i)/sint
16481 #if defined(MPI) && defined(PARINTDER)
16482 ! We need dtheta(:,:,i-1) to compute dphi(:,:,i)
16483 do i=max0(ithet_start-1,3),ithet_end
16487 if ((itype(i-1,1).ne.10).and.(itype(i-1,1).ne.ntyp1)) then
16488 cost1=dcos(omicron(1,i))
16489 sint1=sqrt(1-cost1*cost1)
16490 cost2=dcos(omicron(2,i))
16491 sint2=sqrt(1-cost2*cost2)
16493 !C Calculate derivative over first omicron (Cai-2,Cai-1,SCi-1)
16494 dcosomicron(j,1,1,i)=-(dc_norm(j,i-1+nres)+ &
16495 cost1*dc_norm(j,i-2))/ &
16497 domicron(j,1,1,i)=-1/sint1*dcosomicron(j,1,1,i)
16498 dcosomicron(j,1,2,i)=-(dc_norm(j,i-2) &
16499 +cost1*(dc_norm(j,i-1+nres)))/ &
16501 domicron(j,1,2,i)=-1/sint1*dcosomicron(j,1,2,i)
16502 !C Calculate derivative over second omicron Sci-1,Cai-1 Cai
16503 !C Looks messy but better than if in loop
16504 dcosomicron(j,2,1,i)=-(-dc_norm(j,i-1+nres) &
16505 +cost2*dc_norm(j,i-1))/ &
16507 domicron(j,2,1,i)=-1/sint2*dcosomicron(j,2,1,i)
16508 dcosomicron(j,2,2,i)=-(dc_norm(j,i-1) &
16509 +cost2*(-dc_norm(j,i-1+nres)))/ &
16511 ! write(iout,*) "vbld", i,itype(i,1),vbld(i-1+nres)
16512 domicron(j,2,2,i)=-1/sint2*dcosomicron(j,2,2,i)
16516 !elwrite(iout,*) "after vbld write"
16517 ! Derivatives of phi:
16518 ! If phi is 0 or 180 degrees, then the formulas
16519 ! have to be derived by power series expansion of the
16520 ! conventional formulas around 0 and 180.
16522 do i=iphi1_start,iphi1_end
16526 ! if (itype(i-1,1).eq.21 .or. itype(i-2,1).eq.21 ) cycle
16527 ! the conventional case
16528 sint=dsin(theta(i))
16529 sint1=dsin(theta(i-1))
16531 cost=dcos(theta(i))
16532 cost1=dcos(theta(i-1))
16534 scalp=scalar(dc_norm(1,i-3),dc_norm(1,i-1))
16535 fac0=1.0d0/(sint1*sint)
16538 fac3=cosg*cost1/(sint1*sint1)
16539 fac4=cosg*cost/(sint*sint)
16540 ! Obtaining the gamma derivatives from sine derivative
16541 if (phi(i).gt.-pi4.and.phi(i).le.pi4.or. &
16542 phi(i).gt.pi34.and.phi(i).le.pi.or. &
16543 phi(i).ge.-pi.and.phi(i).le.-pi34) then
16544 call vecpr(dc_norm(1,i-1),dc_norm(1,i-2),vp1)
16545 call vecpr(dc_norm(1,i-3),dc_norm(1,i-1),vp2)
16546 call vecpr(dc_norm(1,i-3),dc_norm(1,i-2),vp3)
16550 cosg_inv=1.0d0/cosg
16551 if (itype(i-1,1).ne.ntyp1 .and. itype(i-2,1).ne.ntyp1) then
16552 dsinphi(j,1,i)=-sing*ctgt1*dtheta(j,1,i-1) &
16553 -(fac0*vp1(j)+sing*dc_norm(j,i-3))*vbld_inv(i-2)
16554 dphi(j,1,i)=cosg_inv*dsinphi(j,1,i)
16556 -sing*(ctgt1*dtheta(j,2,i-1)+ctgt*dtheta(j,1,i)) &
16557 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
16558 dphi(j,2,i)=cosg_inv*dsinphi(j,2,i)
16559 dsinphi(j,3,i)=-sing*ctgt*dtheta(j,2,i) &
16560 +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i)
16561 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
16562 dphi(j,3,i)=cosg_inv*dsinphi(j,3,i)
16564 ! Bug fixed 3/24/05 (AL)
16566 ! Obtaining the gamma derivatives from cosine derivative
16569 if (itype(i-1,1).ne.ntyp1 .and. itype(i-2,1).ne.ntyp1) then
16570 dcosphi(j,1,i)=fac1*dcostheta(j,1,i-1)+fac3* &
16571 dcostheta(j,1,i-1)-fac0*(dc_norm(j,i-1)-scalp* &
16572 dc_norm(j,i-3))/vbld(i-2)
16573 dphi(j,1,i)=-1/sing*dcosphi(j,1,i)
16574 dcosphi(j,2,i)=fac1*dcostheta(j,2,i-1)+fac2* &
16575 dcostheta(j,1,i)+fac3*dcostheta(j,2,i-1)+fac4* &
16577 dphi(j,2,i)=-1/sing*dcosphi(j,2,i)
16578 dcosphi(j,3,i)=fac2*dcostheta(j,2,i)+fac4* &
16579 dcostheta(j,2,i)-fac0*(dc_norm(j,i-3)-scalp* &
16580 dc_norm(j,i-1))/vbld(i)
16581 dphi(j,3,i)=-1/sing*dcosphi(j,3,i)
16586 !alculate derivative of Tauangle
16588 do i=itau_start,itau_end
16591 !elwrite(iout,*) " vecpr",i,nres
16593 if ((itype(i-2,1).eq.ntyp1).or.(itype(i-2,1).eq.10)) cycle
16594 ! if ((itype(i-2,1).eq.ntyp1).or.(itype(i-2,1).eq.10).or.
16595 ! & (itype(i-1,1).eq.ntyp1).or.(itype(i,1).eq.ntyp1)) cycle
16596 !c dtauangle(j,intertyp,dervityp,residue number)
16597 !c INTERTYP=1 SC...Ca...Ca..Ca
16598 ! the conventional case
16599 sint=dsin(theta(i))
16600 sint1=dsin(omicron(2,i-1))
16601 sing=dsin(tauangle(1,i))
16602 cost=dcos(theta(i))
16603 cost1=dcos(omicron(2,i-1))
16604 cosg=dcos(tauangle(1,i))
16605 !elwrite(iout,*) " vecpr5",i,nres
16607 !elwrite(iout,*) " vecpreee",i,nres,j,i-2+nres
16608 !elwrite(iout,*) " vecpr5",dc_norm2(1,1)
16609 dc_norm2(j,i-2+nres)=-dc_norm(j,i-2+nres)
16610 ! write(iout,*) dc_norm2(j,i-2+nres),"dcnorm"
16612 scalp=scalar(dc_norm2(1,i-2+nres),dc_norm(1,i-1))
16613 fac0=1.0d0/(sint1*sint)
16616 fac3=cosg*cost1/(sint1*sint1)
16617 fac4=cosg*cost/(sint*sint)
16618 ! write(iout,*) "faki",fac0,fac1,fac2,fac3,fac4
16619 ! Obtaining the gamma derivatives from sine derivative
16620 if (tauangle(1,i).gt.-pi4.and.tauangle(1,i).le.pi4.or. &
16621 tauangle(1,i).gt.pi34.and.tauangle(1,i).le.pi.or. &
16622 tauangle(1,i).gt.-pi.and.tauangle(1,i).le.-pi34) then
16623 call vecpr(dc_norm(1,i-1),dc_norm(1,i-2),vp1)
16624 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-1),vp2)
16625 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-2),vp3)
16629 cosg_inv=1.0d0/cosg
16630 dsintau(j,1,1,i)=-sing*ctgt1*domicron(j,2,2,i-1) &
16631 -(fac0*vp1(j)+sing*(dc_norm2(j,i-2+nres))) &
16632 *vbld_inv(i-2+nres)
16633 dtauangle(j,1,1,i)=cosg_inv*dsintau(j,1,1,i)
16634 dsintau(j,1,2,i)= &
16635 -sing*(ctgt1*domicron(j,2,1,i-1)+ctgt*dtheta(j,1,i)) &
16636 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
16637 ! write(iout,*) "dsintau", dsintau(j,1,2,i)
16638 dtauangle(j,1,2,i)=cosg_inv*dsintau(j,1,2,i)
16639 ! Bug fixed 3/24/05 (AL)
16640 dsintau(j,1,3,i)=-sing*ctgt*dtheta(j,2,i) &
16641 +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i)
16642 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
16643 dtauangle(j,1,3,i)=cosg_inv*dsintau(j,1,3,i)
16645 ! Obtaining the gamma derivatives from cosine derivative
16648 dcostau(j,1,1,i)=fac1*dcosomicron(j,2,2,i-1)+fac3* &
16649 dcosomicron(j,2,2,i-1)-fac0*(dc_norm(j,i-1)-scalp* &
16650 (dc_norm2(j,i-2+nres)))/vbld(i-2+nres)
16651 dtauangle(j,1,1,i)=-1/sing*dcostau(j,1,1,i)
16652 dcostau(j,1,2,i)=fac1*dcosomicron(j,2,1,i-1)+fac2* &
16653 dcostheta(j,1,i)+fac3*dcosomicron(j,2,1,i-1)+fac4* &
16655 dtauangle(j,1,2,i)=-1/sing*dcostau(j,1,2,i)
16656 dcostau(j,1,3,i)=fac2*dcostheta(j,2,i)+fac4* &
16657 dcostheta(j,2,i)-fac0*(-dc_norm(j,i-2+nres)-scalp* &
16658 dc_norm(j,i-1))/vbld(i)
16659 dtauangle(j,1,3,i)=-1/sing*dcostau(j,1,3,i)
16660 ! write (iout,*) "else",i
16664 ! write(iout,*) "tu",i,k,(dtauangle(j,1,k,i),j=1,3)
16667 !C Second case Ca...Ca...Ca...SC
16669 do i=itau_start,itau_end
16673 if ((itype(i-1,1).eq.ntyp1).or.(itype(i-1,1).eq.10).or. &
16674 (itype(i-2,1).eq.ntyp1).or.(itype(i-3,1).eq.ntyp1)) cycle
16675 ! the conventional case
16676 sint=dsin(omicron(1,i))
16677 sint1=dsin(theta(i-1))
16678 sing=dsin(tauangle(2,i))
16679 cost=dcos(omicron(1,i))
16680 cost1=dcos(theta(i-1))
16681 cosg=dcos(tauangle(2,i))
16683 ! dc_norm2(j,i-1+nres)=-dc_norm(j,i-1+nres)
16685 scalp=scalar(dc_norm(1,i-3),dc_norm(1,i-1+nres))
16686 fac0=1.0d0/(sint1*sint)
16689 fac3=cosg*cost1/(sint1*sint1)
16690 fac4=cosg*cost/(sint*sint)
16691 ! Obtaining the gamma derivatives from sine derivative
16692 if (tauangle(2,i).gt.-pi4.and.tauangle(2,i).le.pi4.or. &
16693 tauangle(2,i).gt.pi34.and.tauangle(2,i).le.pi.or. &
16694 tauangle(2,i).gt.-pi.and.tauangle(2,i).le.-pi34) then
16695 call vecpr(dc_norm2(1,i-1+nres),dc_norm(1,i-2),vp1)
16696 call vecpr(dc_norm(1,i-3),dc_norm(1,i-1+nres),vp2)
16697 call vecpr(dc_norm(1,i-3),dc_norm(1,i-2),vp3)
16701 cosg_inv=1.0d0/cosg
16702 dsintau(j,2,1,i)=-sing*ctgt1*dtheta(j,1,i-1) &
16703 +(fac0*vp1(j)-sing*dc_norm(j,i-3))*vbld_inv(i-2)
16704 ! write(iout,*) i,j,dsintau(j,2,1,i),sing*ctgt1*dtheta(j,1,i-1),
16705 ! &fac0*vp1(j),sing*dc_norm(j,i-3),vbld_inv(i-2),"dsintau(2,1)"
16706 dtauangle(j,2,1,i)=cosg_inv*dsintau(j,2,1,i)
16707 dsintau(j,2,2,i)= &
16708 -sing*(ctgt1*dtheta(j,2,i-1)+ctgt*domicron(j,1,1,i)) &
16709 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
16710 ! write(iout,*) "sprawdzenie",i,j,sing*ctgt1*dtheta(j,2,i-1),
16711 ! & sing*ctgt*domicron(j,1,2,i),
16712 ! & (fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
16713 dtauangle(j,2,2,i)=cosg_inv*dsintau(j,2,2,i)
16714 ! Bug fixed 3/24/05 (AL)
16715 dsintau(j,2,3,i)=-sing*ctgt*domicron(j,1,2,i) &
16716 +(fac0*vp3(j)-sing*dc_norm(j,i-1+nres))*vbld_inv(i-1+nres)
16717 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
16718 dtauangle(j,2,3,i)=cosg_inv*dsintau(j,2,3,i)
16720 ! Obtaining the gamma derivatives from cosine derivative
16723 dcostau(j,2,1,i)=fac1*dcostheta(j,1,i-1)+fac3* &
16724 dcostheta(j,1,i-1)-fac0*(dc_norm(j,i-1+nres)-scalp* &
16725 dc_norm(j,i-3))/vbld(i-2)
16726 dtauangle(j,2,1,i)=-1/sing*dcostau(j,2,1,i)
16727 dcostau(j,2,2,i)=fac1*dcostheta(j,2,i-1)+fac2* &
16728 dcosomicron(j,1,1,i)+fac3*dcostheta(j,2,i-1)+fac4* &
16729 dcosomicron(j,1,1,i)
16730 dtauangle(j,2,2,i)=-1/sing*dcostau(j,2,2,i)
16731 dcostau(j,2,3,i)=fac2*dcosomicron(j,1,2,i)+fac4* &
16732 dcosomicron(j,1,2,i)-fac0*(dc_norm(j,i-3)-scalp* &
16733 dc_norm(j,i-1+nres))/vbld(i-1+nres)
16734 dtauangle(j,2,3,i)=-1/sing*dcostau(j,2,3,i)
16735 ! write(iout,*) i,j,"else", dtauangle(j,2,3,i)
16740 !CC third case SC...Ca...Ca...SC
16743 do i=itau_start,itau_end
16747 ! the conventional case
16748 if ((itype(i-1,1).eq.ntyp1).or.(itype(i-1,1).eq.10).or. &
16749 (itype(i-2,1).eq.ntyp1).or.(itype(i-2,1).eq.10)) cycle
16750 sint=dsin(omicron(1,i))
16751 sint1=dsin(omicron(2,i-1))
16752 sing=dsin(tauangle(3,i))
16753 cost=dcos(omicron(1,i))
16754 cost1=dcos(omicron(2,i-1))
16755 cosg=dcos(tauangle(3,i))
16757 dc_norm2(j,i-2+nres)=-dc_norm(j,i-2+nres)
16758 ! dc_norm2(j,i-1+nres)=-dc_norm(j,i-1+nres)
16760 scalp=scalar(dc_norm2(1,i-2+nres),dc_norm(1,i-1+nres))
16761 fac0=1.0d0/(sint1*sint)
16764 fac3=cosg*cost1/(sint1*sint1)
16765 fac4=cosg*cost/(sint*sint)
16766 ! Obtaining the gamma derivatives from sine derivative
16767 if (tauangle(3,i).gt.-pi4.and.tauangle(3,i).le.pi4.or. &
16768 tauangle(3,i).gt.pi34.and.tauangle(3,i).le.pi.or. &
16769 tauangle(3,i).gt.-pi.and.tauangle(3,i).le.-pi34) then
16770 call vecpr(dc_norm(1,i-1+nres),dc_norm(1,i-2),vp1)
16771 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-1+nres),vp2)
16772 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-2),vp3)
16776 cosg_inv=1.0d0/cosg
16777 dsintau(j,3,1,i)=-sing*ctgt1*domicron(j,2,2,i-1) &
16778 -(fac0*vp1(j)-sing*dc_norm(j,i-2+nres)) &
16779 *vbld_inv(i-2+nres)
16780 dtauangle(j,3,1,i)=cosg_inv*dsintau(j,3,1,i)
16781 dsintau(j,3,2,i)= &
16782 -sing*(ctgt1*domicron(j,2,1,i-1)+ctgt*domicron(j,1,1,i)) &
16783 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
16784 dtauangle(j,3,2,i)=cosg_inv*dsintau(j,3,2,i)
16785 ! Bug fixed 3/24/05 (AL)
16786 dsintau(j,3,3,i)=-sing*ctgt*domicron(j,1,2,i) &
16787 +(fac0*vp3(j)-sing*dc_norm(j,i-1+nres)) &
16788 *vbld_inv(i-1+nres)
16789 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
16790 dtauangle(j,3,3,i)=cosg_inv*dsintau(j,3,3,i)
16792 ! Obtaining the gamma derivatives from cosine derivative
16795 dcostau(j,3,1,i)=fac1*dcosomicron(j,2,2,i-1)+fac3* &
16796 dcosomicron(j,2,2,i-1)-fac0*(dc_norm(j,i-1+nres)-scalp* &
16797 dc_norm2(j,i-2+nres))/vbld(i-2+nres)
16798 dtauangle(j,3,1,i)=-1/sing*dcostau(j,3,1,i)
16799 dcostau(j,3,2,i)=fac1*dcosomicron(j,2,1,i-1)+fac2* &
16800 dcosomicron(j,1,1,i)+fac3*dcosomicron(j,2,1,i-1)+fac4* &
16801 dcosomicron(j,1,1,i)
16802 dtauangle(j,3,2,i)=-1/sing*dcostau(j,3,2,i)
16803 dcostau(j,3,3,i)=fac2*dcosomicron(j,1,2,i)+fac4* &
16804 dcosomicron(j,1,2,i)-fac0*(dc_norm2(j,i-2+nres)-scalp* &
16805 dc_norm(j,i-1+nres))/vbld(i-1+nres)
16806 dtauangle(j,3,3,i)=-1/sing*dcostau(j,3,3,i)
16807 ! write(iout,*) "else",i
16813 ! Derivatives of side-chain angles alpha and omega
16814 #if defined(MPI) && defined(PARINTDER)
16815 do i=ibond_start,ibond_end
16819 if(itype(i,1).ne.10 .and. itype(i,1).ne.ntyp1) then
16820 fac5=1.0d0/dsqrt(2*(1+dcos(theta(i+1))))
16823 fac8=fac5/vbld(i+1)
16824 fac9=fac5/vbld(i+nres)
16825 scala1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
16826 scala2=scalar(dc_norm(1,i),dc_norm(1,i+nres))
16827 cosa=dsqrt(0.5d0/(1.0d0+dcos(theta(i+1))))* &
16828 (scalar(dC_norm(1,i),dC_norm(1,i+nres)) &
16829 -scalar(dC_norm(1,i-1),dC_norm(1,i+nres)))
16830 sina=sqrt(1-cosa*cosa)
16832 ! write (iout,*) "i",i," cosa",cosa," sina",sina," sino",sino
16834 dcosalpha(j,1,i)=fac6*(scala1*dc_norm(j,i-1)- &
16835 dc_norm(j,i+nres))-cosa*fac7*dcostheta(j,1,i+1)
16836 dalpha(j,1,i)=-1/sina*dcosalpha(j,1,i)
16837 dcosalpha(j,2,i)=fac8*(dc_norm(j,i+nres)- &
16838 scala2*dc_norm(j,i))-cosa*fac7*dcostheta(j,2,i+1)
16839 dalpha(j,2,i)=-1/sina*dcosalpha(j,2,i)
16840 dcosalpha(j,3,i)=(fac9*(dc_norm(j,i)- &
16841 dc_norm(j,i-1))-(cosa*dc_norm(j,i+nres))/ &
16843 dalpha(j,3,i)=-1/sina*dcosalpha(j,3,i)
16845 ! obtaining the derivatives of omega from sines
16846 if(omeg(i).gt.-pi4.and.omeg(i).le.pi4.or. &
16847 omeg(i).gt.pi34.and.omeg(i).le.pi.or. &
16848 omeg(i).gt.-pi.and.omeg(i).le.-pi34) then
16849 fac15=dcos(theta(i+1))/(dsin(theta(i+1))* &
16851 fac16=dcos(alph(i))/(dsin(alph(i))*dsin(alph(i)))
16852 fac17=1.0d0/(dsin(theta(i+1))*dsin(alph(i)))
16853 call vecpr(dc_norm(1,i+nres),dc_norm(1,i),vo1)
16854 call vecpr(dc_norm(1,i+nres),dc_norm(1,i-1),vo2)
16855 call vecpr(dc_norm(1,i),dc_norm(1,i-1),vo3)
16856 coso_inv=1.0d0/dcos(omeg(i))
16858 dsinomega(j,1,i)=sino*(fac15*dcostheta(j,1,i+1) &
16859 +fac16*dcosalpha(j,1,i))-fac17/vbld(i)*vo1(j)- &
16860 (sino*dc_norm(j,i-1))/vbld(i)
16861 domega(j,1,i)=coso_inv*dsinomega(j,1,i)
16862 dsinomega(j,2,i)=sino*(fac15*dcostheta(j,2,i+1) &
16863 +fac16*dcosalpha(j,2,i))+fac17/vbld(i+1)*vo2(j) &
16864 -sino*dc_norm(j,i)/vbld(i+1)
16865 domega(j,2,i)=coso_inv*dsinomega(j,2,i)
16866 dsinomega(j,3,i)=sino*fac16*dcosalpha(j,3,i)- &
16867 fac17/vbld(i+nres)*vo3(j)-sino*dc_norm(j,i+nres)/ &
16869 domega(j,3,i)=coso_inv*dsinomega(j,3,i)
16872 ! obtaining the derivatives of omega from cosines
16873 fac10=sqrt(0.5d0*(1-dcos(theta(i+1))))
16874 fac11=sqrt(0.5d0*(1+dcos(theta(i+1))))
16879 dcosomega(j,1,i)=(-(0.25d0*cosa/fac11* &
16880 dcostheta(j,1,i+1)+fac11*dcosalpha(j,1,i))*fac12+ &
16881 (0.25d0/fac10*sina*dcostheta(j,1,i+1)+cosa/sina* &
16882 fac10*dcosalpha(j,1,i))*(scala2-fac11*cosa))/fac13
16883 domega(j,1,i)=-1/sino*dcosomega(j,1,i)
16884 dcosomega(j,2,i)=(((dc_norm(j,i+nres)-scala2* &
16885 dc_norm(j,i))/vbld(i+1)-0.25d0*cosa/fac11* &
16886 dcostheta(j,2,i+1)-fac11*dcosalpha(j,2,i))*fac12+ &
16887 (scala2-fac11*cosa)*(0.25d0*sina/fac10* &
16888 dcostheta(j,2,i+1)+fac10*cosa/sina*dcosalpha(j,2,i)))/fac13
16889 domega(j,2,i)=-1/sino*dcosomega(j,2,i)
16890 dcosomega(j,3,i)=1/fac10*((1/vbld(i+nres)*(dc_norm(j,i)- &
16891 scala2*dc_norm(j,i+nres))-fac11*dcosalpha(j,3,i))*sina+ &
16892 (scala2-fac11*cosa)*(cosa/sina*dcosalpha(j,3,i)))/fac14
16893 domega(j,3,i)=-1/sino*dcosomega(j,3,i)
16899 dalpha(k,j,i)=0.0d0
16900 domega(k,j,i)=0.0d0
16906 #if defined(MPI) && defined(PARINTDER)
16907 if (nfgtasks.gt.1) then
16909 !d write (iout,*) "Gather dtheta"
16910 !d call flush(iout)
16911 write (iout,*) "dtheta before gather"
16913 write (iout,'(i3,3(3f8.5,3x))') i,((dtheta(j,k,i),k=1,3),j=1,2)
16916 call MPI_Gatherv(dtheta(1,1,ithet_start),ithet_count(fg_rank),&
16917 MPI_THET,dtheta(1,1,1),ithet_count(0),ithet_displ(0),MPI_THET,&
16918 king,FG_COMM,IERROR)
16920 !d write (iout,*) "Gather dphi"
16921 !d call flush(iout)
16922 write (iout,*) "dphi before gather"
16924 write (iout,'(i3,3(3f8.5,3x))') i,((dphi(j,k,i),k=1,3),j=1,3)
16927 call MPI_Gatherv(dphi(1,1,iphi1_start),iphi1_count(fg_rank),&
16928 MPI_GAM,dphi(1,1,1),iphi1_count(0),iphi1_displ(0),MPI_GAM,&
16929 king,FG_COMM,IERROR)
16930 !d write (iout,*) "Gather dalpha"
16931 !d call flush(iout)
16933 call MPI_Gatherv(dalpha(1,1,ibond_start),ibond_count(fg_rank),&
16934 MPI_GAM,dalpha(1,1,1),ibond_count(0),ibond_displ(0),MPI_GAM,&
16935 king,FG_COMM,IERROR)
16936 !d write (iout,*) "Gather domega"
16937 !d call flush(iout)
16938 call MPI_Gatherv(domega(1,1,ibond_start),ibond_count(fg_rank),&
16939 MPI_GAM,domega(1,1,1),ibond_count(0),ibond_displ(0),MPI_GAM,&
16940 king,FG_COMM,IERROR)
16945 write (iout,*) "dtheta after gather"
16947 write (iout,'(i3,3(3f8.5,3x))') i,((dtheta(j,k,i),j=1,3),k=1,2)
16949 write (iout,*) "dphi after gather"
16951 write (iout,'(i3,3(3f8.5,3x))') i,((dphi(j,k,i),j=1,3),k=1,3)
16953 write (iout,*) "dalpha after gather"
16955 write (iout,'(i3,3(3f8.5,3x))') i,((dalpha(j,k,i),j=1,3),k=1,3)
16957 write (iout,*) "domega after gather"
16959 write (iout,'(i3,3(3f8.5,3x))') i,((domega(j,k,i),j=1,3),k=1,3)
16963 end subroutine intcartderiv
16964 !-----------------------------------------------------------------------------
16965 subroutine checkintcartgrad
16966 ! implicit real*8 (a-h,o-z)
16967 ! include 'DIMENSIONS'
16971 ! include 'COMMON.CHAIN'
16972 ! include 'COMMON.VAR'
16973 ! include 'COMMON.GEO'
16974 ! include 'COMMON.INTERACT'
16975 ! include 'COMMON.DERIV'
16976 ! include 'COMMON.IOUNITS'
16977 ! include 'COMMON.SETUP'
16978 real(kind=8),dimension(3,2,nres) :: dthetanum !(3,2,maxres)
16979 real(kind=8),dimension(3,3,nres) :: dphinum,dalphanum,domeganum !(3,3,maxres)
16980 real(kind=8),dimension(nres) :: theta_s,phi_s,alph_s,omeg_s !(maxres)
16981 real(kind=8),dimension(3) :: dc_norm_s
16982 real(kind=8) :: aincr=1.0d-5
16984 real(kind=8) :: dcji
16987 theta_s(i)=theta(i)
16991 ! Check theta gradient
16993 "Analytical (upper) and numerical (lower) gradient of theta"
16998 dc(j,i-2)=dcji+aincr
16999 call chainbuild_cart
17000 call int_from_cart1(.false.)
17001 dthetanum(j,1,i)=(theta(i)-theta_s(i))/aincr
17004 dc(j,i-1)=dc(j,i-1)+aincr
17005 call chainbuild_cart
17006 dthetanum(j,2,i)=(theta(i)-theta_s(i))/aincr
17009 !el write (iout,'(i5,3f10.5,5x,3f10.5)') i,(dtheta(j,1,i),j=1,3),&
17010 !el (dtheta(j,2,i),j=1,3)
17011 !el write (iout,'(5x,3f10.5,5x,3f10.5)') (dthetanum(j,1,i),j=1,3),&
17012 !el (dthetanum(j,2,i),j=1,3)
17013 !el write (iout,'(5x,3f10.5,5x,3f10.5)') &
17014 !el (dthetanum(j,1,i)/dtheta(j,1,i),j=1,3),&
17015 !el (dthetanum(j,2,i)/dtheta(j,2,i),j=1,3)
17018 ! Check gamma gradient
17020 "Analytical (upper) and numerical (lower) gradient of gamma"
17024 dc(j,i-3)=dcji+aincr
17025 call chainbuild_cart
17026 dphinum(j,1,i)=(phi(i)-phi_s(i))/aincr
17029 dc(j,i-2)=dcji+aincr
17030 call chainbuild_cart
17031 dphinum(j,2,i)=(phi(i)-phi_s(i))/aincr
17034 dc(j,i-1)=dc(j,i-1)+aincr
17035 call chainbuild_cart
17036 dphinum(j,3,i)=(phi(i)-phi_s(i))/aincr
17039 !el write (iout,'(i5,3(3f10.5,5x))') i,(dphi(j,1,i),j=1,3),&
17040 !el (dphi(j,2,i),j=1,3),(dphi(j,3,i),j=1,3)
17041 !el write (iout,'(5x,3(3f10.5,5x))') (dphinum(j,1,i),j=1,3),&
17042 !el (dphinum(j,2,i),j=1,3),(dphinum(j,3,i),j=1,3)
17043 !el write (iout,'(5x,3(3f10.5,5x))') &
17044 !el (dphinum(j,1,i)/dphi(j,1,i),j=1,3),&
17045 !el (dphinum(j,2,i)/dphi(j,2,i),j=1,3),&
17046 !el (dphinum(j,3,i)/dphi(j,3,i),j=1,3)
17049 ! Check alpha gradient
17051 "Analytical (upper) and numerical (lower) gradient of alpha"
17053 if(itype(i,1).ne.10) then
17056 dc(j,i-1)=dcji+aincr
17057 call chainbuild_cart
17058 dalphanum(j,1,i)=(alph(i)-alph_s(i)) &
17063 call chainbuild_cart
17064 dalphanum(j,2,i)=(alph(i)-alph_s(i)) &
17068 dc(j,i+nres)=dc(j,i+nres)+aincr
17069 call chainbuild_cart
17070 dalphanum(j,3,i)=(alph(i)-alph_s(i)) &
17075 !el write (iout,'(i5,3(3f10.5,5x))') i,(dalpha(j,1,i),j=1,3),&
17076 !el (dalpha(j,2,i),j=1,3),(dalpha(j,3,i),j=1,3)
17077 !el write (iout,'(5x,3(3f10.5,5x))') (dalphanum(j,1,i),j=1,3),&
17078 !el (dalphanum(j,2,i),j=1,3),(dalphanum(j,3,i),j=1,3)
17079 !el write (iout,'(5x,3(3f10.5,5x))') &
17080 !el (dalphanum(j,1,i)/dalpha(j,1,i),j=1,3),&
17081 !el (dalphanum(j,2,i)/dalpha(j,2,i),j=1,3),&
17082 !el (dalphanum(j,3,i)/dalpha(j,3,i),j=1,3)
17085 ! Check omega gradient
17087 "Analytical (upper) and numerical (lower) gradient of omega"
17089 if(itype(i,1).ne.10) then
17092 dc(j,i-1)=dcji+aincr
17093 call chainbuild_cart
17094 domeganum(j,1,i)=(omeg(i)-omeg_s(i)) &
17099 call chainbuild_cart
17100 domeganum(j,2,i)=(omeg(i)-omeg_s(i)) &
17104 dc(j,i+nres)=dc(j,i+nres)+aincr
17105 call chainbuild_cart
17106 domeganum(j,3,i)=(omeg(i)-omeg_s(i)) &
17111 !el write (iout,'(i5,3(3f10.5,5x))') i,(domega(j,1,i),j=1,3),&
17112 !el (domega(j,2,i),j=1,3),(domega(j,3,i),j=1,3)
17113 !el write (iout,'(5x,3(3f10.5,5x))') (domeganum(j,1,i),j=1,3),&
17114 !el (domeganum(j,2,i),j=1,3),(domeganum(j,3,i),j=1,3)
17115 !el write (iout,'(5x,3(3f10.5,5x))') &
17116 !el (domeganum(j,1,i)/domega(j,1,i),j=1,3),&
17117 !el (domeganum(j,2,i)/domega(j,2,i),j=1,3),&
17118 !el (domeganum(j,3,i)/domega(j,3,i),j=1,3)
17122 end subroutine checkintcartgrad
17123 !-----------------------------------------------------------------------------
17125 !-----------------------------------------------------------------------------
17126 real(kind=8) function qwolynes(seg1,seg2,flag,seg3,seg4)
17127 ! implicit real*8 (a-h,o-z)
17128 ! include 'DIMENSIONS'
17129 ! include 'COMMON.IOUNITS'
17130 ! include 'COMMON.CHAIN'
17131 ! include 'COMMON.INTERACT'
17132 ! include 'COMMON.VAR'
17133 integer :: i,j,jl,k,l,il,kl,nl,np,ip,kp,seg1,seg2,seg3,seg4,secseg
17134 integer :: kkk,nsep=3
17135 real(kind=8) :: qm !dist,
17136 real(kind=8) :: qq,qqij,qqijCM,dij,d0ij,dijCM,d0ijCM,qqmax
17137 logical :: lprn=.false.
17139 ! real(kind=8) :: sigm,x
17141 !el sigm(x)=0.25d0*x ! local function
17147 do il=seg1+nsep,seg2
17150 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2 + &
17151 (cref(2,jl,kkk)-cref(2,il,kkk))**2 + &
17152 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
17154 qqij = dexp(-0.5d0*((dij-d0ij)/(sigm(d0ij)))**2)
17155 if (itype(il,1).ne.10 .or. itype(jl,1).ne.10) then
17158 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
17159 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
17160 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
17161 dijCM=dist(il+nres,jl+nres)
17162 qqijCM = dexp(-0.5d0*((dijCM-d0ijCM)/(sigm(d0ijCM)))**2)
17164 qq = qq+qqij+qqijCM
17170 if((seg3-il).lt.3) then
17177 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2+ &
17178 (cref(2,jl,kkk)-cref(2,il,kkk))**2+ &
17179 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
17181 qqij = dexp(-0.5d0*((dij-d0ij)/(sigm(d0ij)))**2)
17182 if (itype(il,1).ne.10 .or. itype(jl,1).ne.10) then
17185 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
17186 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
17187 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
17188 dijCM=dist(il+nres,jl+nres)
17189 qqijCM = dexp(-0.5d0*((dijCM-d0ijCM)/(sigm(d0ijCM)))**2)
17191 qq = qq+qqij+qqijCM
17196 if (qqmax.le.qq) qqmax=qq
17198 qwolynes=1.0d0-qqmax
17200 end function qwolynes
17201 !-----------------------------------------------------------------------------
17202 subroutine qwolynes_prim(seg1,seg2,flag,seg3,seg4)
17203 ! implicit real*8 (a-h,o-z)
17204 ! include 'DIMENSIONS'
17205 ! include 'COMMON.IOUNITS'
17206 ! include 'COMMON.CHAIN'
17207 ! include 'COMMON.INTERACT'
17208 ! include 'COMMON.VAR'
17209 ! include 'COMMON.MD'
17210 integer :: i,j,jl,k,l,il,nl,seg1,seg2,seg3,seg4,secseg
17211 integer :: nsep=3, kkk
17212 !el real(kind=8) :: dist
17213 real(kind=8) :: dij,d0ij,dijCM,d0ijCM
17214 logical :: lprn=.false.
17216 real(kind=8) :: sim,dd0,fac,ddqij
17217 !el sigm(x)=0.25d0*x ! local function
17227 do il=seg1+nsep,seg2
17230 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2+ &
17231 (cref(2,jl,kkk)-cref(2,il,kkk))**2+ &
17232 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
17234 sim = 1.0d0/sigm(d0ij)
17237 fac = dd0*sim/dij*dexp(-0.5d0*dd0*dd0*sim)
17239 ddqij = (c(k,il)-c(k,jl))*fac
17240 dqwol(k,il)=dqwol(k,il)+ddqij
17241 dqwol(k,jl)=dqwol(k,jl)-ddqij
17244 if (itype(il,1).ne.10 .or. itype(jl,1).ne.10) then
17247 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
17248 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
17249 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
17250 dijCM=dist(il+nres,jl+nres)
17251 sim = 1.0d0/sigm(d0ijCM)
17254 fac=dd0*sim/dijCM*dexp(-0.5d0*dd0*dd0*sim)
17256 ddqij = (c(k,il+nres)-c(k,jl+nres))*fac
17257 dxqwol(k,il)=dxqwol(k,il)+ddqij
17258 dxqwol(k,jl)=dxqwol(k,jl)-ddqij
17265 if((seg3-il).lt.3) then
17272 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2+ &
17273 (cref(2,jl,kkk)-cref(2,il,kkk))**2+ &
17274 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
17276 sim = 1.0d0/sigm(d0ij)
17279 fac = dd0*sim/dij*dexp(-0.5d0*dd0*dd0*sim)
17281 ddqij = (c(k,il)-c(k,jl))*fac
17282 dqwol(k,il)=dqwol(k,il)+ddqij
17283 dqwol(k,jl)=dqwol(k,jl)-ddqij
17285 if (itype(il,1).ne.10 .or. itype(jl,1).ne.10) then
17288 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
17289 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
17290 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
17291 dijCM=dist(il+nres,jl+nres)
17292 sim = 1.0d0/sigm(d0ijCM)
17295 fac = dd0*sim/dijCM*dexp(-0.5d0*dd0*dd0*sim)
17297 ddqij = (c(k,il+nres)-c(k,jl+nres))*fac
17298 dxqwol(k,il)=dxqwol(k,il)+ddqij
17299 dxqwol(k,jl)=dxqwol(k,jl)-ddqij
17308 dqwol(j,i)=dqwol(j,i)/nl
17309 dxqwol(j,i)=dxqwol(j,i)/nl
17313 end subroutine qwolynes_prim
17314 !-----------------------------------------------------------------------------
17315 subroutine qwol_num(seg1,seg2,flag,seg3,seg4)
17316 ! implicit real*8 (a-h,o-z)
17317 ! include 'DIMENSIONS'
17318 ! include 'COMMON.IOUNITS'
17319 ! include 'COMMON.CHAIN'
17320 ! include 'COMMON.INTERACT'
17321 ! include 'COMMON.VAR'
17322 integer :: seg1,seg2,seg3,seg4
17324 real(kind=8),dimension(3,0:nres) :: qwolan,qwolxan
17325 real(kind=8),dimension(3,0:2*nres) :: cdummy
17326 real(kind=8) :: q1,q2
17327 real(kind=8) :: delta=1.0d-10
17332 q1=qwolynes(seg1,seg2,flag,seg3,seg4)
17334 c(j,i)=c(j,i)+delta
17335 q2=qwolynes(seg1,seg2,flag,seg3,seg4)
17336 qwolan(j,i)=(q2-q1)/delta
17342 q1=qwolynes(seg1,seg2,flag,seg3,seg4)
17343 cdummy(j,i+nres)=c(j,i+nres)
17344 c(j,i+nres)=c(j,i+nres)+delta
17345 q2=qwolynes(seg1,seg2,flag,seg3,seg4)
17346 qwolxan(j,i)=(q2-q1)/delta
17347 c(j,i+nres)=cdummy(j,i+nres)
17350 ! write(iout,*) "Numerical Q carteisan gradients backbone: "
17352 ! write(iout,'(i5,3e15.5)') i, (qwolan(j,i),j=1,3)
17354 ! write(iout,*) "Numerical Q carteisan gradients side-chain: "
17356 ! write(iout,'(i5,3e15.5)') i, (qwolxan(j,i),j=1,3)
17359 end subroutine qwol_num
17360 !-----------------------------------------------------------------------------
17361 subroutine EconstrQ
17362 ! MD with umbrella_sampling using Wolyne's distance measure as a constraint
17363 ! implicit real*8 (a-h,o-z)
17364 ! include 'DIMENSIONS'
17365 ! include 'COMMON.CONTROL'
17366 ! include 'COMMON.VAR'
17367 ! include 'COMMON.MD'
17370 ! include 'COMMON.LANGEVIN'
17372 ! include 'COMMON.LANGEVIN.lang0'
17374 ! include 'COMMON.CHAIN'
17375 ! include 'COMMON.DERIV'
17376 ! include 'COMMON.GEO'
17377 ! include 'COMMON.LOCAL'
17378 ! include 'COMMON.INTERACT'
17379 ! include 'COMMON.IOUNITS'
17380 ! include 'COMMON.NAMES'
17381 ! include 'COMMON.TIME1'
17382 real(kind=8) :: uzap1,uzap2,hm1,hm2,hmnum,ucdelan
17383 real(kind=8),dimension(3,0:nres) :: dUcartan,dUxcartan,cdummy,&
17385 integer :: kstart,kend,lstart,lend,idummy
17386 real(kind=8) :: delta=1.0d-7
17387 integer :: i,j,k,ii
17391 dudconst(j,i)=0.0d0
17392 duxconst(j,i)=0.0d0
17393 dudxconst(j,i)=0.0d0
17398 qfrag(i)=qwolynes(ifrag(1,i,iset),ifrag(2,i,iset),.true.,&
17400 Uconst=Uconst+wfrag(i,iset)*harmonic(qfrag(i),qinfrag(i,iset))
17401 ! Calculating the derivatives of Constraint energy with respect to Q
17402 Ucdfrag=wfrag(i,iset)*harmonicprim(qfrag(i),&
17404 ! hm1=harmonic(qfrag(i,iset),qinfrag(i,iset))
17405 ! hm2=harmonic(qfrag(i,iset)+delta,qinfrag(i,iset))
17406 ! hmnum=(hm2-hm1)/delta
17407 ! write(iout,*) "harmonicprim frag",harmonicprim(qfrag(i,iset),
17408 ! & qinfrag(i,iset))
17409 ! write(iout,*) "harmonicnum frag", hmnum
17410 ! Calculating the derivatives of Q with respect to cartesian coordinates
17411 call qwolynes_prim(ifrag(1,i,iset),ifrag(2,i,iset),.true.,&
17413 ! write(iout,*) "dqwol "
17415 ! write(iout,'(i5,3e15.5)') ii,(dqwol(j,ii),j=1,3)
17417 ! write(iout,*) "dxqwol "
17419 ! write(iout,'(i5,3e15.5)') ii,(dxqwol(j,ii),j=1,3)
17421 ! Calculating numerical gradients of dU/dQi and dQi/dxi
17422 ! call qwol_num(ifrag(1,i,iset),ifrag(2,i,iset),.true.
17423 ! & ,idummy,idummy)
17424 ! The gradients of Uconst in Cs
17427 duconst(j,ii)=dUconst(j,ii)+ucdfrag*dqwol(j,ii)
17428 dUxconst(j,ii)=dUxconst(j,ii)+ucdfrag*dxqwol(j,ii)
17433 kstart=ifrag(1,ipair(1,i,iset),iset)
17434 kend=ifrag(2,ipair(1,i,iset),iset)
17435 lstart=ifrag(1,ipair(2,i,iset),iset)
17436 lend=ifrag(2,ipair(2,i,iset),iset)
17437 qpair(i)=qwolynes(kstart,kend,.false.,lstart,lend)
17438 Uconst=Uconst+wpair(i,iset)*harmonic(qpair(i),qinpair(i,iset))
17439 ! Calculating dU/dQ
17440 Ucdpair=wpair(i,iset)*harmonicprim(qpair(i),qinpair(i,iset))
17441 ! hm1=harmonic(qpair(i),qinpair(i,iset))
17442 ! hm2=harmonic(qpair(i)+delta,qinpair(i,iset))
17443 ! hmnum=(hm2-hm1)/delta
17444 ! write(iout,*) "harmonicprim pair ",harmonicprim(qpair(i),
17445 ! & qinpair(i,iset))
17446 ! write(iout,*) "harmonicnum pair ", hmnum
17447 ! Calculating dQ/dXi
17448 call qwolynes_prim(kstart,kend,.false.,&
17450 ! write(iout,*) "dqwol "
17452 ! write(iout,'(i5,3e15.5)') ii,(dqwol(j,ii),j=1,3)
17454 ! write(iout,*) "dxqwol "
17456 ! write(iout,'(i5,3e15.5)') ii,(dxqwol(j,ii),j=1,3)
17458 ! Calculating numerical gradients
17459 ! call qwol_num(kstart,kend,.false.
17461 ! The gradients of Uconst in Cs
17464 duconst(j,ii)=dUconst(j,ii)+ucdpair*dqwol(j,ii)
17465 dUxconst(j,ii)=dUxconst(j,ii)+ucdpair*dxqwol(j,ii)
17469 ! write(iout,*) "Uconst inside subroutine ", Uconst
17470 ! Transforming the gradients from Cs to dCs for the backbone
17474 dudconst(k,i)=dudconst(k,i)+duconst(k,j)+duxconst(k,j)
17478 ! Transforming the gradients from Cs to dCs for the side chains
17481 dudxconst(j,i)=duxconst(j,i)
17484 ! write(iout,*) "dU/ddc backbone "
17486 ! write(iout,'(i5,3e15.5)') ii, (dudconst(j,ii),j=1,3)
17488 ! write(iout,*) "dU/ddX side chain "
17490 ! write(iout,'(i5,3e15.5)') ii,(duxconst(j,ii),j=1,3)
17492 ! Calculating numerical gradients of dUconst/ddc and dUconst/ddx
17493 ! call dEconstrQ_num
17495 end subroutine EconstrQ
17496 !-----------------------------------------------------------------------------
17497 subroutine dEconstrQ_num
17498 ! Calculating numerical dUconst/ddc and dUconst/ddx
17499 ! implicit real*8 (a-h,o-z)
17500 ! include 'DIMENSIONS'
17501 ! include 'COMMON.CONTROL'
17502 ! include 'COMMON.VAR'
17503 ! include 'COMMON.MD'
17506 ! include 'COMMON.LANGEVIN'
17508 ! include 'COMMON.LANGEVIN.lang0'
17510 ! include 'COMMON.CHAIN'
17511 ! include 'COMMON.DERIV'
17512 ! include 'COMMON.GEO'
17513 ! include 'COMMON.LOCAL'
17514 ! include 'COMMON.INTERACT'
17515 ! include 'COMMON.IOUNITS'
17516 ! include 'COMMON.NAMES'
17517 ! include 'COMMON.TIME1'
17518 real(kind=8) :: uzap1,uzap2
17519 real(kind=8),dimension(3,0:nres) :: dUcartan,dUxcartan,cdummy
17520 integer :: kstart,kend,lstart,lend,idummy
17521 real(kind=8) :: delta=1.0d-7
17522 !el local variables
17528 dUcartan(j,i)=0.0d0
17529 cdummy(j,i)=dc(j,i)
17530 dc(j,i)=dc(j,i)+delta
17531 call chainbuild_cart
17534 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),.true.,&
17536 uzap2=uzap2+wfrag(ii,iset)*harmonic(qfrag(ii),&
17540 kstart=ifrag(1,ipair(1,ii,iset),iset)
17541 kend=ifrag(2,ipair(1,ii,iset),iset)
17542 lstart=ifrag(1,ipair(2,ii,iset),iset)
17543 lend=ifrag(2,ipair(2,ii,iset),iset)
17544 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
17545 uzap2=uzap2+wpair(ii,iset)*harmonic(qpair(ii),&
17548 dc(j,i)=cdummy(j,i)
17549 call chainbuild_cart
17552 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),.true.,&
17554 uzap1=uzap1+wfrag(ii,iset)*harmonic(qfrag(ii),&
17558 kstart=ifrag(1,ipair(1,ii,iset),iset)
17559 kend=ifrag(2,ipair(1,ii,iset),iset)
17560 lstart=ifrag(1,ipair(2,ii,iset),iset)
17561 lend=ifrag(2,ipair(2,ii,iset),iset)
17562 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
17563 uzap1=uzap1+wpair(ii,iset)*harmonic(qpair(ii),&
17566 ducartan(j,i)=(uzap2-uzap1)/(delta)
17569 ! Calculating numerical gradients for dU/ddx
17571 duxcartan(j,i)=0.0d0
17573 cdummy(j,i)=dc(j,i+nres)
17574 dc(j,i+nres)=dc(j,i+nres)+delta
17575 call chainbuild_cart
17578 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),.true.,&
17580 uzap2=uzap2+wfrag(ii,iset)*harmonic(qfrag(ii),&
17584 kstart=ifrag(1,ipair(1,ii,iset),iset)
17585 kend=ifrag(2,ipair(1,ii,iset),iset)
17586 lstart=ifrag(1,ipair(2,ii,iset),iset)
17587 lend=ifrag(2,ipair(2,ii,iset),iset)
17588 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
17589 uzap2=uzap2+wpair(ii,iset)*harmonic(qpair(ii),&
17592 dc(j,i+nres)=cdummy(j,i)
17593 call chainbuild_cart
17596 qfrag(ii)=qwolynes(ifrag(1,ii,iset),&
17597 ifrag(2,ii,iset),.true.,idummy,idummy)
17598 uzap1=uzap1+wfrag(ii,iset)*harmonic(qfrag(ii),&
17602 kstart=ifrag(1,ipair(1,ii,iset),iset)
17603 kend=ifrag(2,ipair(1,ii,iset),iset)
17604 lstart=ifrag(1,ipair(2,ii,iset),iset)
17605 lend=ifrag(2,ipair(2,ii,iset),iset)
17606 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
17607 uzap1=uzap1+wpair(ii,iset)*harmonic(qpair(ii),&
17610 duxcartan(j,i)=(uzap2-uzap1)/(delta)
17613 write(iout,*) "Numerical dUconst/ddc backbone "
17615 write(iout,'(i5,3e15.5)') ii,(dUcartan(j,ii),j=1,3)
17617 ! write(iout,*) "Numerical dUconst/ddx side-chain "
17619 ! write(iout,'(i5,3e15.5)') ii,(dUxcartan(j,ii),j=1,3)
17622 end subroutine dEconstrQ_num
17623 !-----------------------------------------------------------------------------
17625 !-----------------------------------------------------------------------------
17626 subroutine check_energies
17628 ! use random, only: ran_number
17632 ! include 'DIMENSIONS'
17633 ! include 'COMMON.CHAIN'
17634 ! include 'COMMON.VAR'
17635 ! include 'COMMON.IOUNITS'
17636 ! include 'COMMON.SBRIDGE'
17637 ! include 'COMMON.LOCAL'
17638 ! include 'COMMON.GEO'
17640 ! External functions
17641 !EL double precision ran_number
17642 !EL external ran_number
17645 integer :: i,j,k,l,lmax,p,pmax
17646 real(kind=8) :: rmin,rmax
17647 real(kind=8) :: eij
17650 real(kind=8) :: wi,rij,tj,pj
17672 !t wi=ran_number(0.0D0,pi)
17673 ! wi=ran_number(0.0D0,pi/6.0D0)
17675 !t tj=ran_number(0.0D0,pi)
17676 !t pj=ran_number(0.0D0,pi)
17677 ! pj=ran_number(0.0D0,pi/6.0D0)
17681 !t rij=ran_number(rmin,rmax)
17683 c(1,j)=d*sin(pj)*cos(tj)
17684 c(2,j)=d*sin(pj)*sin(tj)
17690 c(3,i)=-rij-d*cos(wi)
17693 dc(k,nres+i)=c(k,nres+i)-c(k,i)
17694 dc_norm(k,nres+i)=dc(k,nres+i)/d
17695 dc(k,nres+j)=c(k,nres+j)-c(k,j)
17696 dc_norm(k,nres+j)=dc(k,nres+j)/d
17699 call dyn_ssbond_ene(i,j,eij)
17704 end subroutine check_energies
17705 !-----------------------------------------------------------------------------
17706 subroutine dyn_ssbond_ene(resi,resj,eij)
17711 ! include 'DIMENSIONS'
17712 ! include 'COMMON.SBRIDGE'
17713 ! include 'COMMON.CHAIN'
17714 ! include 'COMMON.DERIV'
17715 ! include 'COMMON.LOCAL'
17716 ! include 'COMMON.INTERACT'
17717 ! include 'COMMON.VAR'
17718 ! include 'COMMON.IOUNITS'
17719 ! include 'COMMON.CALC'
17723 ! include 'COMMON.MD'
17724 ! use MD, only: totT,t_bath
17727 ! External functions
17728 !EL double precision h_base
17729 !EL external h_base
17732 integer :: resi,resj
17735 real(kind=8) :: eij
17738 logical :: havebond
17739 integer itypi,itypj
17740 real(kind=8) :: rrij,ssd,deltat1,deltat2,deltat12,cosphi
17741 real(kind=8) :: sig0ij,ljd,sig,fac,e1,e2
17742 real(kind=8),dimension(3) :: dcosom1,dcosom2
17744 real(kind=8) :: pom1,pom2
17745 real(kind=8) :: ljA,ljB,ljXs
17746 real(kind=8),dimension(1:3) :: d_ljB
17747 real(kind=8) :: ssA,ssB,ssC,ssXs
17748 real(kind=8) :: ssxm,ljxm,ssm,ljm
17749 real(kind=8),dimension(1:3) :: d_ssxm,d_ljxm,d_ssm,d_ljm
17750 real(kind=8) :: f1,f2,h1,h2,hd1,hd2
17751 real(kind=8) :: omega,delta_inv,deltasq_inv,fac1,fac2
17752 !-------FIRST METHOD
17754 real(kind=8),dimension(1:3) :: d_xm
17755 !-------END FIRST METHOD
17756 !-------SECOND METHOD
17757 !$$$ double precision ss,d_ss(0:3),ljf,d_ljf(0:3)
17758 !-------END SECOND METHOD
17760 !-------TESTING CODE
17761 !el logical :: checkstop,transgrad
17762 !el common /sschecks/ checkstop,transgrad
17764 integer :: icheck,nicheck,jcheck,njcheck
17765 real(kind=8),dimension(-1:1) :: echeck
17766 real(kind=8) :: deps,ssx0,ljx0
17767 !-------END TESTING CODE
17773 !el allocate(dyn_ssbond_ij(iatsc_s:iatsc_e,nres))
17774 !el allocate(dyn_ssbond_ij(0:nres+4,nres))
17777 dxi=dc_norm(1,nres+i)
17778 dyi=dc_norm(2,nres+i)
17779 dzi=dc_norm(3,nres+i)
17780 dsci_inv=vbld_inv(i+nres)
17783 xj=c(1,nres+j)-c(1,nres+i)
17784 yj=c(2,nres+j)-c(2,nres+i)
17785 zj=c(3,nres+j)-c(3,nres+i)
17786 dxj=dc_norm(1,nres+j)
17787 dyj=dc_norm(2,nres+j)
17788 dzj=dc_norm(3,nres+j)
17789 dscj_inv=vbld_inv(j+nres)
17791 chi1=chi(itypi,itypj)
17792 chi2=chi(itypj,itypi)
17799 alf12=0.5D0*(alf1+alf2)
17801 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
17802 rij=dsqrt(rrij) ! sc_angular needs rij to really be the inverse
17803 ! The following are set in sc_angular
17807 ! om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
17808 ! om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
17809 ! om12=dxi*dxj+dyi*dyj+dzi*dzj
17811 rij=1.0D0/rij ! Reset this so it makes sense
17813 sig0ij=sigma(itypi,itypj)
17814 sig=sig0ij*dsqrt(1.0D0/sigsq)
17817 ljA=eps1*eps2rt**2*eps3rt**2
17818 ljB=ljA*bb_aq(itypi,itypj)
17819 ljA=ljA*aa_aq(itypi,itypj)
17820 ljxm=ljXs+(-2.0D0*aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
17825 deltat12=om2-om1+2.0d0
17826 cosphi=om12-om1*om2
17830 +akth*(deltat1*deltat1+deltat2*deltat2) &
17831 +v1ss*cosphi+v2ss*cosphi*cosphi+v3ss*cosphi*cosphi*cosphi
17832 ssxm=ssXs-0.5D0*ssB/ssA
17834 !-------TESTING CODE
17835 !$$$c Some extra output
17836 !$$$ ssm=ssC-0.25D0*ssB*ssB/ssA
17837 !$$$ ljm=-0.25D0*ljB*bb(itypi,itypj)/aa(itypi,itypj)
17838 !$$$ ssx0=ssB*ssB-4.0d0*ssA*ssC
17839 !$$$ if (ssx0.gt.0.0d0) then
17840 !$$$ ssx0=ssXs+0.5d0*(-ssB+sqrt(ssx0))/ssA
17844 !$$$ ljx0=ljXs+(-aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
17845 !$$$ write(iout,'(a,4f8.2,2f15.2,3f6.2)')"SSENERGIES ",
17846 !$$$ & ssxm,ljxm,ssx0,ljx0,ssm,ljm,om1,om2,om12
17848 !-------END TESTING CODE
17850 !-------TESTING CODE
17851 ! Stop and plot energy and derivative as a function of distance
17852 if (checkstop) then
17853 ssm=ssC-0.25D0*ssB*ssB/ssA
17854 ljm=-0.25D0*ljB*bb_aq(itypi,itypj)/aa_aq(itypi,itypj)
17855 if (ssm.lt.ljm .and. &
17856 dabs(rij-0.5d0*(ssxm+ljxm)).lt.0.35d0*(ljxm-ssxm)) then
17864 if (.not.checkstop) then
17869 do icheck=0,nicheck
17870 do jcheck=-1,njcheck
17871 if (checkstop) rij=(ssxm-1.0d0)+ &
17872 ((ljxm-ssxm+2.0d0)*icheck)/nicheck+jcheck*deps
17873 !-------END TESTING CODE
17875 if (rij.gt.ljxm) then
17878 fac=(1.0D0/ljd)**expon
17879 e1=fac*fac*aa_aq(itypi,itypj)
17880 e2=fac*bb_aq(itypi,itypj)
17881 eij=eps1*eps2rt*eps3rt*(e1+e2)
17884 eij=eij*eps2rt*eps3rt
17887 e1=e1*eps1*eps2rt**2*eps3rt**2
17888 ed=-expon*(e1+eij)/ljd
17890 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
17891 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
17892 eom12=eij*eps1_om12+eps2der*eps2rt_om12 &
17893 -2.0D0*alf12*eps3der+sigder*sigsq_om12
17894 else if (rij.lt.ssxm) then
17897 eij=ssA*ssd*ssd+ssB*ssd+ssC
17899 ed=2*akcm*ssd+akct*deltat12
17901 pom2=v1ss+2*v2ss*cosphi+3*v3ss*cosphi*cosphi
17902 eom1=-2*akth*deltat1-pom1-om2*pom2
17903 eom2= 2*akth*deltat2+pom1-om1*pom2
17906 omega=v1ss+2.0d0*v2ss*cosphi+3.0d0*v3ss*cosphi*cosphi
17908 d_ssxm(1)=0.5D0*akct/ssA
17909 d_ssxm(2)=-d_ssxm(1)
17912 d_ljxm(1)=sig0ij/sqrt(sigsq**3)
17913 d_ljxm(2)=d_ljxm(1)*sigsq_om2
17914 d_ljxm(3)=d_ljxm(1)*sigsq_om12
17915 d_ljxm(1)=d_ljxm(1)*sigsq_om1
17917 !-------FIRST METHOD, DISCONTINUOUS SECOND DERIVATIVE
17918 xm=0.5d0*(ssxm+ljxm)
17920 d_xm(k)=0.5d0*(d_ssxm(k)+d_ljxm(k))
17922 if (rij.lt.xm) then
17924 ssm=ssC-0.25D0*ssB*ssB/ssA
17925 d_ssm(1)=0.5D0*akct*ssB/ssA
17926 d_ssm(2)=2.0D0*akth*deltat2-om1*omega-d_ssm(1)
17927 d_ssm(1)=-2.0D0*akth*deltat1-om2*omega+d_ssm(1)
17929 f1=(rij-xm)/(ssxm-xm)
17930 f2=(rij-ssxm)/(xm-ssxm)
17934 delta_inv=1.0d0/(xm-ssxm)
17935 deltasq_inv=delta_inv*delta_inv
17937 fac1=deltasq_inv*fac*(xm-rij)
17938 fac2=deltasq_inv*fac*(rij-ssxm)
17939 ed=delta_inv*(Ht*hd2-ssm*hd1)
17940 eom1=fac1*d_ssxm(1)+fac2*d_xm(1)+h1*d_ssm(1)
17941 eom2=fac1*d_ssxm(2)+fac2*d_xm(2)+h1*d_ssm(2)
17942 eom12=fac1*d_ssxm(3)+fac2*d_xm(3)+h1*d_ssm(3)
17945 ljm=-0.25D0*ljB*bb_aq(itypi,itypj)/aa_aq(itypi,itypj)
17946 d_ljm(1)=-0.5D0*bb_aq(itypi,itypj)/aa_aq(itypi,itypj)*ljB
17947 d_ljm(2)=d_ljm(1)*(0.5D0*eps2rt_om2/eps2rt+alf2/eps3rt)
17948 d_ljm(3)=d_ljm(1)*(0.5D0*eps1_om12+0.5D0*eps2rt_om12/eps2rt- &
17950 d_ljm(1)=d_ljm(1)*(0.5D0*eps2rt_om1/eps2rt-alf1/eps3rt)
17951 f1=(rij-ljxm)/(xm-ljxm)
17952 f2=(rij-xm)/(ljxm-xm)
17956 delta_inv=1.0d0/(ljxm-xm)
17957 deltasq_inv=delta_inv*delta_inv
17959 fac1=deltasq_inv*fac*(ljxm-rij)
17960 fac2=deltasq_inv*fac*(rij-xm)
17961 ed=delta_inv*(ljm*hd2-Ht*hd1)
17962 eom1=fac1*d_xm(1)+fac2*d_ljxm(1)+h2*d_ljm(1)
17963 eom2=fac1*d_xm(2)+fac2*d_ljxm(2)+h2*d_ljm(2)
17964 eom12=fac1*d_xm(3)+fac2*d_ljxm(3)+h2*d_ljm(3)
17966 !-------END FIRST METHOD, DISCONTINUOUS SECOND DERIVATIVE
17968 !-------SECOND METHOD, CONTINUOUS SECOND DERIVATIVE
17974 !$$$ d_ljB(1)=ljB*(eps2rt_om1/eps2rt-2.0d0*alf1/eps3rt)
17975 !$$$ d_ljB(2)=ljB*(eps2rt_om2/eps2rt+2.0d0*alf2/eps3rt)
17976 !$$$ d_ljB(3)=ljB*(eps1_om12+eps2rt_om12/eps2rt-2.0d0*alf12/eps3rt)
17978 !$$$ ssm=ssC-0.25D0*ssB*ssB/ssA
17979 !$$$ d_ssm(1)=0.5D0*akct*ssB/ssA
17980 !$$$ d_ssm(2)=2.0D0*akth*deltat2-om1*omega-d_ssm(1)
17981 !$$$ d_ssm(1)=-2.0D0*akth*deltat1-om2*omega+d_ssm(1)
17982 !$$$ d_ssm(3)=omega
17984 !$$$ ljm=-0.25D0*bb(itypi,itypj)/aa(itypi,itypj)
17986 !$$$ d_ljm(k)=ljm*d_ljB(k)
17990 !$$$ ss=ssA*ssd*ssd+ssB*ssd+ssC
17991 !$$$ d_ss(0)=2.0d0*ssA*ssd+ssB
17992 !$$$ d_ss(2)=akct*ssd
17993 !$$$ d_ss(1)=-d_ss(2)-2.0d0*akth*deltat1-om2*omega
17994 !$$$ d_ss(2)=d_ss(2)+2.0d0*akth*deltat2-om1*omega
17997 !$$$ ljf=bb(itypi,itypj)/aa(itypi,itypj)
17998 !$$$ ljf=9.0d0*ljf*(-0.5d0*ljf)**(1.0d0/3.0d0)
17999 !$$$ d_ljf(0)=ljf*2.0d0*ljB*fac1
18001 !$$$ d_ljf(k)=d_ljm(k)+ljf*(d_ljB(k)*fac1*fac1-
18002 !$$$ & 2.0d0*ljB*fac1*d_ljxm(k))
18004 !$$$ ljf=ljm+ljf*ljB*fac1*fac1
18006 !$$$ f1=(rij-ljxm)/(ssxm-ljxm)
18007 !$$$ f2=(rij-ssxm)/(ljxm-ssxm)
18008 !$$$ h1=h_base(f1,hd1)
18009 !$$$ h2=h_base(f2,hd2)
18010 !$$$ eij=ss*h1+ljf*h2
18011 !$$$ delta_inv=1.0d0/(ljxm-ssxm)
18012 !$$$ deltasq_inv=delta_inv*delta_inv
18013 !$$$ fac=ljf*hd2-ss*hd1
18014 !$$$ ed=d_ss(0)*h1+d_ljf(0)*h2+delta_inv*fac
18015 !$$$ eom1=d_ss(1)*h1+d_ljf(1)*h2+deltasq_inv*fac*
18016 !$$$ & (fac1*d_ssxm(1)-fac2*(d_ljxm(1)))
18017 !$$$ eom2=d_ss(2)*h1+d_ljf(2)*h2+deltasq_inv*fac*
18018 !$$$ & (fac1*d_ssxm(2)-fac2*(d_ljxm(2)))
18019 !$$$ eom12=d_ss(3)*h1+d_ljf(3)*h2+deltasq_inv*fac*
18020 !$$$ & (fac1*d_ssxm(3)-fac2*(d_ljxm(3)))
18022 !$$$ havebond=.false.
18023 !$$$ if (ed.gt.0.0d0) havebond=.true.
18024 !-------END SECOND METHOD, CONTINUOUS SECOND DERIVATIVE
18031 ! if (dyn_ssbond_ij(i,j).eq.1.0d300) then
18032 ! write(iout,'(a15,f12.2,f8.1,2i5)')
18033 ! & "SSBOND_E_FORM",totT,t_bath,i,j
18037 dyn_ssbond_ij(i,j)=eij
18038 else if (.not.havebond .and. dyn_ssbond_ij(i,j).lt.1.0d300) then
18039 dyn_ssbond_ij(i,j)=1.0d300
18042 ! write(iout,'(a15,f12.2,f8.1,2i5)')
18043 ! & "SSBOND_E_BREAK",totT,t_bath,i,j
18048 !-------TESTING CODE
18049 !el if (checkstop) then
18050 if (jcheck.eq.0) write(iout,'(a,3f15.8,$)') &
18051 "CHECKSTOP",rij,eij,ed
18055 if (checkstop) then
18056 write(iout,'(f15.8)')(echeck(1)-echeck(-1))*0.5d0/deps
18059 if (checkstop) then
18063 !-------END TESTING CODE
18066 dcosom1(k)=(dc_norm(k,nres+i)-om1*erij(k))/rij
18067 dcosom2(k)=(dc_norm(k,nres+j)-om2*erij(k))/rij
18070 gg(k)=ed*erij(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
18073 gvdwx(k,i)=gvdwx(k,i)-gg(k) &
18074 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
18075 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
18076 gvdwx(k,j)=gvdwx(k,j)+gg(k) &
18077 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
18078 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
18082 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
18087 gvdwc(l,i)=gvdwc(l,i)-gg(l)
18088 gvdwc(l,j)=gvdwc(l,j)+gg(l)
18092 end subroutine dyn_ssbond_ene
18093 !--------------------------------------------------------------------------
18094 subroutine triple_ssbond_ene(resi,resj,resk,eij)
18099 ! include 'DIMENSIONS'
18100 ! include 'COMMON.SBRIDGE'
18101 ! include 'COMMON.CHAIN'
18102 ! include 'COMMON.DERIV'
18103 ! include 'COMMON.LOCAL'
18104 ! include 'COMMON.INTERACT'
18105 ! include 'COMMON.VAR'
18106 ! include 'COMMON.IOUNITS'
18107 ! include 'COMMON.CALC'
18111 ! include 'COMMON.MD'
18112 ! use MD, only: totT,t_bath
18115 double precision h_base
18119 integer resi,resj,resk,m,itypi,itypj,itypk
18121 !c Output arguments
18122 double precision eij,eij1,eij2,eij3
18126 !c integer itypi,itypj,k,l
18127 double precision rrij,ssd,deltat1,deltat2,deltat12,cosphi
18128 double precision rrik,rrjk,rik,rjk,xi,xk,yi,yk,zi,zk,xij,yij,zij
18129 double precision xik,yik,zik,xjk,yjk,zjk,dxk,dyk,dzk
18130 double precision sig0ij,ljd,sig,fac,e1,e2
18131 double precision dcosom1(3),dcosom2(3),ed
18132 double precision pom1,pom2
18133 double precision ljA,ljB,ljXs
18134 double precision d_ljB(1:3)
18135 double precision ssA,ssB,ssC,ssXs
18136 double precision ssxm,ljxm,ssm,ljm
18137 double precision d_ssxm(1:3),d_ljxm(1:3),d_ssm(1:3),d_ljm(1:3)
18139 if (dtriss.eq.0) return
18143 !C write(iout,*) resi,resj,resk
18145 dxi=dc_norm(1,nres+i)
18146 dyi=dc_norm(2,nres+i)
18147 dzi=dc_norm(3,nres+i)
18148 dsci_inv=vbld_inv(i+nres)
18157 dxj=dc_norm(1,nres+j)
18158 dyj=dc_norm(2,nres+j)
18159 dzj=dc_norm(3,nres+j)
18160 dscj_inv=vbld_inv(j+nres)
18166 dxk=dc_norm(1,nres+k)
18167 dyk=dc_norm(2,nres+k)
18168 dzk=dc_norm(3,nres+k)
18169 dscj_inv=vbld_inv(k+nres)
18179 rrij=(xij*xij+yij*yij+zij*zij)
18180 rij=dsqrt(rrij) ! sc_angular needs rij to really be the inverse
18181 rrik=(xik*xik+yik*yik+zik*zik)
18183 rrjk=(xjk*xjk+yjk*yjk+zjk*zjk)
18185 !C there are three combination of distances for each trisulfide bonds
18186 !C The first case the ith atom is the center
18187 !C Energy function is E=d/(a*(x-y)**2+b*(x+y)**2+c) where x is first
18188 !C distance y is second distance the a,b,c,d are parameters derived for
18189 !C this problem d parameter was set as a penalty currenlty set to 1.
18190 if ((iabs(j-i).le.2).or.(iabs(i-k).le.2)) then
18193 eij1=dtriss/(atriss*(rij-rik)**2+btriss*(rij+rik)**6+ctriss)
18195 !C second case jth atom is center
18196 if ((iabs(j-i).le.2).or.(iabs(j-k).le.2)) then
18199 eij2=dtriss/(atriss*(rij-rjk)**2+btriss*(rij+rjk)**6+ctriss)
18201 !C the third case kth atom is the center
18202 if ((iabs(i-k).le.2).or.(iabs(j-k).le.2)) then
18205 eij3=dtriss/(atriss*(rik-rjk)**2+btriss*(rik+rjk)**6+ctriss)
18211 !C write(iout,*)i,j,k,eij
18212 !C The energy penalty calculated now time for the gradient part
18213 !C derivative over rij
18214 fac=-eij1**2/dtriss*(2.0*atriss*(rij-rik)+6.0*btriss*(rij+rik)**5) &
18215 -eij2**2/dtriss*(2.0*atriss*(rij-rjk)+6.0*btriss*(rij+rjk)**5)
18220 gvdwx(m,i)=gvdwx(m,i)-gg(m)
18221 gvdwx(m,j)=gvdwx(m,j)+gg(m)
18225 gvdwc(l,i)=gvdwc(l,i)-gg(l)
18226 gvdwc(l,j)=gvdwc(l,j)+gg(l)
18228 !C now derivative over rik
18229 fac=-eij1**2/dtriss* &
18230 (-2.0*atriss*(rij-rik)+6.0*btriss*(rij+rik)**5) &
18231 -eij3**2/dtriss*(2.0*atriss*(rik-rjk)+6.0*btriss*(rik+rjk)**5)
18236 gvdwx(m,i)=gvdwx(m,i)-gg(m)
18237 gvdwx(m,k)=gvdwx(m,k)+gg(m)
18240 gvdwc(l,i)=gvdwc(l,i)-gg(l)
18241 gvdwc(l,k)=gvdwc(l,k)+gg(l)
18243 !C now derivative over rjk
18244 fac=-eij2**2/dtriss* &
18245 (-2.0*atriss*(rij-rjk)+6.0*btriss*(rij+rjk)**5)- &
18246 eij3**2/dtriss*(-2.0*atriss*(rik-rjk)+6.0*btriss*(rik+rjk)**5)
18251 gvdwx(m,j)=gvdwx(m,j)-gg(m)
18252 gvdwx(m,k)=gvdwx(m,k)+gg(m)
18255 gvdwc(l,j)=gvdwc(l,j)-gg(l)
18256 gvdwc(l,k)=gvdwc(l,k)+gg(l)
18259 end subroutine triple_ssbond_ene
18263 !-----------------------------------------------------------------------------
18264 real(kind=8) function h_base(x,deriv)
18265 ! A smooth function going 0->1 in range [0,1]
18266 ! It should NOT be called outside range [0,1], it will not work there.
18273 real(kind=8) :: deriv
18276 real(kind=8) :: xsq
18279 ! Two parabolas put together. First derivative zero at extrema
18280 !$$$ if (x.lt.0.5D0) then
18281 !$$$ h_base=2.0D0*x*x
18285 !$$$ h_base=1.0D0-2.0D0*deriv*deriv
18286 !$$$ deriv=4.0D0*deriv
18289 ! Third degree polynomial. First derivative zero at extrema
18290 h_base=x*x*(3.0d0-2.0d0*x)
18291 deriv=6.0d0*x*(1.0d0-x)
18293 ! Fifth degree polynomial. First and second derivatives zero at extrema
18295 !$$$ h_base=x*xsq*(6.0d0*xsq-15.0d0*x+10.0d0)
18297 !$$$ deriv=deriv*deriv
18298 !$$$ deriv=30.0d0*xsq*deriv
18301 end function h_base
18302 !-----------------------------------------------------------------------------
18303 subroutine dyn_set_nss
18304 ! Adjust nss and other relevant variables based on dyn_ssbond_ij
18306 use MD_data, only: totT,t_bath
18308 ! include 'DIMENSIONS'
18312 ! include 'COMMON.SBRIDGE'
18313 ! include 'COMMON.CHAIN'
18314 ! include 'COMMON.IOUNITS'
18315 ! include 'COMMON.SETUP'
18316 ! include 'COMMON.MD'
18318 real(kind=8) :: emin
18319 integer :: i,j,imin,ierr
18320 integer :: diff,allnss,newnss
18321 integer,dimension(maxdim) :: allflag,allihpb,alljhpb,& !(maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
18324 integer,dimension(0:nfgtasks) :: i_newnss
18325 integer,dimension(0:nfgtasks) :: displ
18326 integer,dimension(maxdim) :: g_newihpb,g_newjhpb !(maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
18327 integer :: g_newnss
18332 if (dyn_ssbond_ij(i,j).lt.1.0d300) then
18341 !mc write(iout,*)"ALLNSS ",allnss,(allihpb(i),alljhpb(i),i=1,allnss)
18345 if (allflag(i).eq.0 .and. &
18346 dyn_ssbond_ij(allihpb(i),alljhpb(i)).lt.emin) then
18347 emin=dyn_ssbond_ij(allihpb(i),alljhpb(i))
18351 if (emin.lt.1.0d300) then
18354 if (allflag(i).eq.0 .and. &
18355 (allihpb(i).eq.allihpb(imin) .or. &
18356 alljhpb(i).eq.allihpb(imin) .or. &
18357 allihpb(i).eq.alljhpb(imin) .or. &
18358 alljhpb(i).eq.alljhpb(imin))) then
18365 !mc write(iout,*)"ALLNSS ",allnss,(allihpb(i),alljhpb(i),i=1,allnss)
18369 if (allflag(i).eq.1) then
18371 newihpb(newnss)=allihpb(i)
18372 newjhpb(newnss)=alljhpb(i)
18377 if (nfgtasks.gt.1)then
18379 call MPI_Reduce(newnss,g_newnss,1,&
18380 MPI_INTEGER,MPI_SUM,king,FG_COMM,IERR)
18381 call MPI_Gather(newnss,1,MPI_INTEGER,&
18382 i_newnss,1,MPI_INTEGER,king,FG_COMM,IERR)
18384 do i=1,nfgtasks-1,1
18385 displ(i)=i_newnss(i-1)+displ(i-1)
18387 call MPI_Gatherv(newihpb,newnss,MPI_INTEGER,&
18388 g_newihpb,i_newnss,displ,MPI_INTEGER,&
18390 call MPI_Gatherv(newjhpb,newnss,MPI_INTEGER,&
18391 g_newjhpb,i_newnss,displ,MPI_INTEGER,&
18393 if(fg_rank.eq.0) then
18394 ! print *,'g_newnss',g_newnss
18395 ! print *,'g_newihpb',(g_newihpb(i),i=1,g_newnss)
18396 ! print *,'g_newjhpb',(g_newjhpb(i),i=1,g_newnss)
18399 newihpb(i)=g_newihpb(i)
18400 newjhpb(i)=g_newjhpb(i)
18408 !mc write(iout,*)"NEWNSS ",newnss,(newihpb(i),newjhpb(i),i=1,newnss)
18409 ! print *,newnss,nss,maxdim
18415 if (idssb(i).eq.newihpb(j) .and. &
18416 jdssb(i).eq.newjhpb(j)) found=.true.
18420 ! write(iout,*) "found",found,i,j
18421 if (.not.found.and.fg_rank.eq.0) &
18422 write(iout,'(a15,f12.2,f8.1,2i5)') &
18423 "SSBOND_BREAK",totT,t_bath,idssb(i),jdssb(i)
18432 if (newihpb(i).eq.idssb(j) .and. &
18433 newjhpb(i).eq.jdssb(j)) found=.true.
18437 ! write(iout,*) "found",found,i,j
18438 if (.not.found.and.fg_rank.eq.0) &
18439 write(iout,'(a15,f12.2,f8.1,2i5)') &
18440 "SSBOND_FORM",totT,t_bath,newihpb(i),newjhpb(i)
18447 idssb(i)=newihpb(i)
18448 jdssb(i)=newjhpb(i)
18452 end subroutine dyn_set_nss
18453 ! Lipid transfer energy function
18454 subroutine Eliptransfer(eliptran)
18455 !C this is done by Adasko
18456 !C print *,"wchodze"
18457 !C structure of box:
18459 !C--bordliptop-- buffore starts
18460 !C--bufliptop--- here true lipid starts
18462 !C--buflipbot--- lipid ends buffore starts
18463 !C--bordlipbot--buffore ends
18464 real(kind=8) :: fracinbuf,eliptran,sslip,positi,ssgradlip
18467 ! print *, "I am in eliptran"
18468 do i=ilip_start,ilip_end
18470 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1).or.(i.eq.nres))&
18473 positi=(mod(((c(3,i)+c(3,i+1))/2.0d0),boxzsize))
18474 if (positi.le.0.0) positi=positi+boxzsize
18476 !C first for peptide groups
18477 !c for each residue check if it is in lipid or lipid water border area
18478 if ((positi.gt.bordlipbot) &
18479 .and.(positi.lt.bordliptop)) then
18480 !C the energy transfer exist
18481 if (positi.lt.buflipbot) then
18482 !C what fraction I am in
18484 ((positi-bordlipbot)/lipbufthick)
18485 !C lipbufthick is thickenes of lipid buffore
18486 sslip=sscalelip(fracinbuf)
18487 ssgradlip=-sscagradlip(fracinbuf)/lipbufthick
18488 eliptran=eliptran+sslip*pepliptran
18489 gliptranc(3,i)=gliptranc(3,i)+ssgradlip*pepliptran/2.0d0
18490 gliptranc(3,i-1)=gliptranc(3,i-1)+ssgradlip*pepliptran/2.0d0
18491 !C gliptranc(3,i-2)=gliptranc(3,i)+ssgradlip*pepliptran
18493 !C print *,"doing sccale for lower part"
18494 !C print *,i,sslip,fracinbuf,ssgradlip
18495 elseif (positi.gt.bufliptop) then
18496 fracinbuf=1.0d0-((bordliptop-positi)/lipbufthick)
18497 sslip=sscalelip(fracinbuf)
18498 ssgradlip=sscagradlip(fracinbuf)/lipbufthick
18499 eliptran=eliptran+sslip*pepliptran
18500 gliptranc(3,i)=gliptranc(3,i)+ssgradlip*pepliptran/2.0d0
18501 gliptranc(3,i-1)=gliptranc(3,i-1)+ssgradlip*pepliptran/2.0d0
18502 !C gliptranc(3,i-2)=gliptranc(3,i)+ssgradlip*pepliptran
18503 !C print *, "doing sscalefor top part"
18504 !C print *,i,sslip,fracinbuf,ssgradlip
18506 eliptran=eliptran+pepliptran
18507 !C print *,"I am in true lipid"
18510 !C eliptran=elpitran+0.0 ! I am in water
18512 if (energy_dec) write(iout,*) i,"eliptran=",eliptran,positi,sslip
18514 ! here starts the side chain transfer
18515 do i=ilip_start,ilip_end
18516 if (itype(i,1).eq.ntyp1) cycle
18517 positi=(mod(c(3,i+nres),boxzsize))
18518 if (positi.le.0) positi=positi+boxzsize
18519 !C print *,mod(c(3,i+nres),boxzsize),bordlipbot,bordliptop
18520 !c for each residue check if it is in lipid or lipid water border area
18521 !C respos=mod(c(3,i+nres),boxzsize)
18522 !C print *,positi,bordlipbot,buflipbot
18523 if ((positi.gt.bordlipbot) &
18524 .and.(positi.lt.bordliptop)) then
18525 !C the energy transfer exist
18526 if (positi.lt.buflipbot) then
18528 ((positi-bordlipbot)/lipbufthick)
18529 !C lipbufthick is thickenes of lipid buffore
18530 sslip=sscalelip(fracinbuf)
18531 ssgradlip=-sscagradlip(fracinbuf)/lipbufthick
18532 eliptran=eliptran+sslip*liptranene(itype(i,1))
18533 gliptranx(3,i)=gliptranx(3,i) &
18534 +ssgradlip*liptranene(itype(i,1))
18535 gliptranc(3,i-1)= gliptranc(3,i-1) &
18536 +ssgradlip*liptranene(itype(i,1))
18537 !C print *,"doing sccale for lower part"
18538 elseif (positi.gt.bufliptop) then
18540 ((bordliptop-positi)/lipbufthick)
18541 sslip=sscalelip(fracinbuf)
18542 ssgradlip=sscagradlip(fracinbuf)/lipbufthick
18543 eliptran=eliptran+sslip*liptranene(itype(i,1))
18544 gliptranx(3,i)=gliptranx(3,i) &
18545 +ssgradlip*liptranene(itype(i,1))
18546 gliptranc(3,i-1)= gliptranc(3,i-1) &
18547 +ssgradlip*liptranene(itype(i,1))
18548 !C print *, "doing sscalefor top part",sslip,fracinbuf
18550 eliptran=eliptran+liptranene(itype(i,1))
18551 !C print *,"I am in true lipid"
18553 endif ! if in lipid or buffor
18555 !C eliptran=elpitran+0.0 ! I am in water
18556 if (energy_dec) write(iout,*) i,"eliptran=",eliptran
18559 end subroutine Eliptransfer
18560 !----------------------------------NANO FUNCTIONS
18561 !C-----------------------------------------------------------------------
18562 !C-----------------------------------------------------------
18563 !C This subroutine is to mimic the histone like structure but as well can be
18564 !C utilizet to nanostructures (infinit) small modification has to be used to
18565 !C make it finite (z gradient at the ends has to be changes as well as the x,y
18566 !C gradient has to be modified at the ends
18567 !C The energy function is Kihara potential
18568 !C E=4esp*((sigma/(r-r0))^12 - (sigma/(r-r0))^6)
18569 !C 4eps is depth of well sigma is r_minimum r is distance from center of tube
18570 !C and r0 is the excluded size of nanotube (can be set to 0 if we want just a
18571 !C simple Kihara potential
18572 subroutine calctube(Etube)
18573 real(kind=8),dimension(3) :: vectube
18574 real(kind=8) :: Etube,xtemp,xminact,yminact,&
18575 ytemp,xmin,ymin,tub_r,rdiff,rdiff6,fac,positi, &
18576 sc_aa_tube,sc_bb_tube
18579 do i=itube_start,itube_end
18581 enetube(i+nres)=0.0d0
18583 !C first we calculate the distance from tube center
18585 do i=itube_start,itube_end
18586 !C lets ommit dummy atoms for now
18587 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1)) cycle
18588 !C now calculate distance from center of tube and direction vectors
18591 ! Find minimum distance in periodic box
18593 vectube(1)=mod((c(1,i)+c(1,i+1))/2.0d0,boxxsize)
18594 vectube(1)=vectube(1)+boxxsize*j
18595 vectube(2)=mod((c(2,i)+c(2,i+1))/2.0d0,boxysize)
18596 vectube(2)=vectube(2)+boxysize*j
18597 xminact=abs(vectube(1)-tubecenter(1))
18598 yminact=abs(vectube(2)-tubecenter(2))
18599 if (xmin.gt.xminact) then
18603 if (ymin.gt.yminact) then
18610 vectube(1)=vectube(1)-tubecenter(1)
18611 vectube(2)=vectube(2)-tubecenter(2)
18613 !C print *,"x",(c(1,i)+c(1,i+1))/2.0d0,tubecenter(1)
18614 !C print *,"y",(c(2,i)+c(2,i+1))/2.0d0,tubecenter(2)
18616 !C as the tube is infinity we do not calculate the Z-vector use of Z
18619 !C now calculte the distance
18620 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
18621 !C now normalize vector
18622 vectube(1)=vectube(1)/tub_r
18623 vectube(2)=vectube(2)/tub_r
18624 !C calculte rdiffrence between r and r0
18627 rdiff6=rdiff**6.0d0
18628 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
18629 enetube(i)=pep_aa_tube/rdiff6**2.0d0+pep_bb_tube/rdiff6
18630 !C write(iout,*) "TU13",i,rdiff6,enetube(i)
18631 !C print *,rdiff,rdiff6,pep_aa_tube
18632 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
18633 !C now we calculate gradient
18634 fac=(-12.0d0*pep_aa_tube/rdiff6- &
18635 6.0d0*pep_bb_tube)/rdiff6/rdiff
18636 !C write(iout,'(a5,i4,f12.1,3f12.5)') "TU13",i,rdiff6,enetube(i),
18638 !C now direction of gg_tube vector
18640 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac/2.0d0
18641 gg_tube(j,i)=gg_tube(j,i)+vectube(j)*fac/2.0d0
18644 !C basically thats all code now we split for side-chains (REMEMBER to sum up at the END)
18645 !C print *,gg_tube(1,0),"TU"
18648 do i=itube_start,itube_end
18649 !C Lets not jump over memory as we use many times iti
18651 !C lets ommit dummy atoms for now
18652 if ((iti.eq.ntyp1) &
18653 !C in UNRES uncomment the line below as GLY has no side-chain...
18659 vectube(1)=mod((c(1,i+nres)),boxxsize)
18660 vectube(1)=vectube(1)+boxxsize*j
18661 vectube(2)=mod((c(2,i+nres)),boxysize)
18662 vectube(2)=vectube(2)+boxysize*j
18664 xminact=abs(vectube(1)-tubecenter(1))
18665 yminact=abs(vectube(2)-tubecenter(2))
18666 if (xmin.gt.xminact) then
18670 if (ymin.gt.yminact) then
18677 !C write(iout,*), "tututu", vectube(1),tubecenter(1),vectube(2),
18679 vectube(1)=vectube(1)-tubecenter(1)
18680 vectube(2)=vectube(2)-tubecenter(2)
18682 !C as the tube is infinity we do not calculate the Z-vector use of Z
18685 !C now calculte the distance
18686 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
18687 !C now normalize vector
18688 vectube(1)=vectube(1)/tub_r
18689 vectube(2)=vectube(2)/tub_r
18691 !C calculte rdiffrence between r and r0
18694 rdiff6=rdiff**6.0d0
18695 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
18696 sc_aa_tube=sc_aa_tube_par(iti)
18697 sc_bb_tube=sc_bb_tube_par(iti)
18698 enetube(i+nres)=sc_aa_tube/rdiff6**2.0d0+sc_bb_tube/rdiff6
18699 fac=-12.0d0*sc_aa_tube/rdiff6**2.0d0/rdiff- &
18700 6.0d0*sc_bb_tube/rdiff6/rdiff
18701 !C now direction of gg_tube vector
18703 gg_tube_SC(j,i)=gg_tube_SC(j,i)+vectube(j)*fac
18704 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac
18707 do i=itube_start,itube_end
18708 Etube=Etube+enetube(i)+enetube(i+nres)
18710 !C print *,"ETUBE", etube
18712 end subroutine calctube
18713 !C TO DO 1) add to total energy
18714 !C 2) add to gradient summation
18715 !C 3) add reading parameters (AND of course oppening of PARAM file)
18716 !C 4) add reading the center of tube
18718 !C 6) add to zerograd
18719 !C 7) allocate matrices
18722 !C-----------------------------------------------------------------------
18723 !C-----------------------------------------------------------
18724 !C This subroutine is to mimic the histone like structure but as well can be
18725 !C utilizet to nanostructures (infinit) small modification has to be used to
18726 !C make it finite (z gradient at the ends has to be changes as well as the x,y
18727 !C gradient has to be modified at the ends
18728 !C The energy function is Kihara potential
18729 !C E=4esp*((sigma/(r-r0))^12 - (sigma/(r-r0))^6)
18730 !C 4eps is depth of well sigma is r_minimum r is distance from center of tube
18731 !C and r0 is the excluded size of nanotube (can be set to 0 if we want just a
18732 !C simple Kihara potential
18733 subroutine calctube2(Etube)
18734 real(kind=8),dimension(3) :: vectube
18735 real(kind=8) :: Etube,xtemp,xminact,yminact,&
18736 ytemp,xmin,ymin,tub_r,rdiff,rdiff6,fac,positi,fracinbuf,&
18737 sstube,ssgradtube,sc_aa_tube,sc_bb_tube
18740 do i=itube_start,itube_end
18742 enetube(i+nres)=0.0d0
18744 !C first we calculate the distance from tube center
18745 !C first sugare-phosphate group for NARES this would be peptide group
18747 do i=itube_start,itube_end
18748 !C lets ommit dummy atoms for now
18750 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1)) cycle
18751 !C now calculate distance from center of tube and direction vectors
18752 !C vectube(1)=mod((c(1,i)+c(1,i+1))/2.0d0,boxxsize)
18753 !C if (vectube(1).lt.0) vectube(1)=vectube(1)+boxxsize
18754 !C vectube(2)=mod((c(2,i)+c(2,i+1))/2.0d0,boxysize)
18755 !C if (vectube(2).lt.0) vectube(2)=vectube(2)+boxysize
18759 vectube(1)=mod((c(1,i)+c(1,i+1))/2.0d0,boxxsize)
18760 vectube(1)=vectube(1)+boxxsize*j
18761 vectube(2)=mod((c(2,i)+c(2,i+1))/2.0d0,boxysize)
18762 vectube(2)=vectube(2)+boxysize*j
18764 xminact=abs(vectube(1)-tubecenter(1))
18765 yminact=abs(vectube(2)-tubecenter(2))
18766 if (xmin.gt.xminact) then
18770 if (ymin.gt.yminact) then
18777 vectube(1)=vectube(1)-tubecenter(1)
18778 vectube(2)=vectube(2)-tubecenter(2)
18780 !C print *,"x",(c(1,i)+c(1,i+1))/2.0d0,tubecenter(1)
18781 !C print *,"y",(c(2,i)+c(2,i+1))/2.0d0,tubecenter(2)
18783 !C as the tube is infinity we do not calculate the Z-vector use of Z
18786 !C now calculte the distance
18787 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
18788 !C now normalize vector
18789 vectube(1)=vectube(1)/tub_r
18790 vectube(2)=vectube(2)/tub_r
18791 !C calculte rdiffrence between r and r0
18794 rdiff6=rdiff**6.0d0
18795 !C THIS FRAGMENT MAKES TUBE FINITE
18796 positi=mod((c(3,i)+c(3,i+1))/2.0d0,boxzsize)
18797 if (positi.le.0) positi=positi+boxzsize
18798 !C print *,mod(c(3,i+nres),boxzsize),bordlipbot,bordliptop
18799 !c for each residue check if it is in lipid or lipid water border area
18800 !C respos=mod(c(3,i+nres),boxzsize)
18801 !C print *,positi,bordtubebot,buftubebot,bordtubetop
18802 if ((positi.gt.bordtubebot) &
18803 .and.(positi.lt.bordtubetop)) then
18804 !C the energy transfer exist
18805 if (positi.lt.buftubebot) then
18807 ((positi-bordtubebot)/tubebufthick)
18808 !C lipbufthick is thickenes of lipid buffore
18809 sstube=sscalelip(fracinbuf)
18810 ssgradtube=-sscagradlip(fracinbuf)/tubebufthick
18811 !C print *,ssgradtube, sstube,tubetranene(itype(i,1))
18812 enetube(i)=enetube(i)+sstube*tubetranenepep
18813 !C gg_tube_SC(3,i)=gg_tube_SC(3,i)
18814 !C &+ssgradtube*tubetranene(itype(i,1))
18815 !C gg_tube(3,i-1)= gg_tube(3,i-1)
18816 !C &+ssgradtube*tubetranene(itype(i,1))
18817 !C print *,"doing sccale for lower part"
18818 elseif (positi.gt.buftubetop) then
18820 ((bordtubetop-positi)/tubebufthick)
18821 sstube=sscalelip(fracinbuf)
18822 ssgradtube=sscagradlip(fracinbuf)/tubebufthick
18823 enetube(i)=enetube(i)+sstube*tubetranenepep
18824 !C gg_tube_SC(3,i)=gg_tube_SC(3,i)
18825 !C &+ssgradtube*tubetranene(itype(i,1))
18826 !C gg_tube(3,i-1)= gg_tube(3,i-1)
18827 !C &+ssgradtube*tubetranene(itype(i,1))
18828 !C print *, "doing sscalefor top part",sslip,fracinbuf
18832 enetube(i)=enetube(i)+sstube*tubetranenepep
18833 !C print *,"I am in true lipid"
18837 !C ssgradtube=0.0d0
18839 endif ! if in lipid or buffor
18841 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
18842 enetube(i)=enetube(i)+sstube* &
18843 (pep_aa_tube/rdiff6**2.0d0+pep_bb_tube/rdiff6)
18844 !C write(iout,*) "TU13",i,rdiff6,enetube(i)
18845 !C print *,rdiff,rdiff6,pep_aa_tube
18846 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
18847 !C now we calculate gradient
18848 fac=(-12.0d0*pep_aa_tube/rdiff6- &
18849 6.0d0*pep_bb_tube)/rdiff6/rdiff*sstube
18850 !C write(iout,'(a5,i4,f12.1,3f12.5)') "TU13",i,rdiff6,enetube(i),
18853 !C now direction of gg_tube vector
18855 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac/2.0d0
18856 gg_tube(j,i)=gg_tube(j,i)+vectube(j)*fac/2.0d0
18858 gg_tube(3,i)=gg_tube(3,i) &
18859 +ssgradtube*enetube(i)/sstube/2.0d0
18860 gg_tube(3,i-1)= gg_tube(3,i-1) &
18861 +ssgradtube*enetube(i)/sstube/2.0d0
18864 !C basically thats all code now we split for side-chains (REMEMBER to sum up at the END)
18865 !C print *,gg_tube(1,0),"TU"
18866 do i=itube_start,itube_end
18867 !C Lets not jump over memory as we use many times iti
18869 !C lets ommit dummy atoms for now
18870 if ((iti.eq.ntyp1) &
18871 !!C in UNRES uncomment the line below as GLY has no side-chain...
18874 vectube(1)=c(1,i+nres)
18875 vectube(1)=mod(vectube(1),boxxsize)
18876 if (vectube(1).lt.0) vectube(1)=vectube(1)+boxxsize
18877 vectube(2)=c(2,i+nres)
18878 vectube(2)=mod(vectube(2),boxysize)
18879 if (vectube(2).lt.0) vectube(2)=vectube(2)+boxysize
18881 vectube(1)=vectube(1)-tubecenter(1)
18882 vectube(2)=vectube(2)-tubecenter(2)
18883 !C THIS FRAGMENT MAKES TUBE FINITE
18884 positi=(mod(c(3,i+nres),boxzsize))
18885 if (positi.le.0) positi=positi+boxzsize
18886 !C print *,mod(c(3,i+nres),boxzsize),bordlipbot,bordliptop
18887 !c for each residue check if it is in lipid or lipid water border area
18888 !C respos=mod(c(3,i+nres),boxzsize)
18889 !C print *,positi,bordtubebot,buftubebot,bordtubetop
18891 if ((positi.gt.bordtubebot) &
18892 .and.(positi.lt.bordtubetop)) then
18893 !C the energy transfer exist
18894 if (positi.lt.buftubebot) then
18896 ((positi-bordtubebot)/tubebufthick)
18897 !C lipbufthick is thickenes of lipid buffore
18898 sstube=sscalelip(fracinbuf)
18899 ssgradtube=-sscagradlip(fracinbuf)/tubebufthick
18900 !C print *,ssgradtube, sstube,tubetranene(itype(i,1))
18901 enetube(i+nres)=enetube(i+nres)+sstube*tubetranene(itype(i,1))
18902 !C gg_tube_SC(3,i)=gg_tube_SC(3,i)
18903 !C &+ssgradtube*tubetranene(itype(i,1))
18904 !C gg_tube(3,i-1)= gg_tube(3,i-1)
18905 !C &+ssgradtube*tubetranene(itype(i,1))
18906 !C print *,"doing sccale for lower part"
18907 elseif (positi.gt.buftubetop) then
18909 ((bordtubetop-positi)/tubebufthick)
18911 sstube=sscalelip(fracinbuf)
18912 ssgradtube=sscagradlip(fracinbuf)/tubebufthick
18913 enetube(i+nres)=enetube(i+nres)+sstube*tubetranene(itype(i,1))
18914 !C gg_tube_SC(3,i)=gg_tube_SC(3,i)
18915 !C &+ssgradtube*tubetranene(itype(i,1))
18916 !C gg_tube(3,i-1)= gg_tube(3,i-1)
18917 !C &+ssgradtube*tubetranene(itype(i,1))
18918 !C print *, "doing sscalefor top part",sslip,fracinbuf
18922 enetube(i+nres)=enetube(i+nres)+sstube*tubetranene(itype(i,1))
18923 !C print *,"I am in true lipid"
18927 !C ssgradtube=0.0d0
18929 endif ! if in lipid or buffor
18930 !CEND OF FINITE FRAGMENT
18931 !C as the tube is infinity we do not calculate the Z-vector use of Z
18934 !C now calculte the distance
18935 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
18936 !C now normalize vector
18937 vectube(1)=vectube(1)/tub_r
18938 vectube(2)=vectube(2)/tub_r
18939 !C calculte rdiffrence between r and r0
18942 rdiff6=rdiff**6.0d0
18943 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
18944 sc_aa_tube=sc_aa_tube_par(iti)
18945 sc_bb_tube=sc_bb_tube_par(iti)
18946 enetube(i+nres)=(sc_aa_tube/rdiff6**2.0d0+sc_bb_tube/rdiff6)&
18947 *sstube+enetube(i+nres)
18948 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
18949 !C now we calculate gradient
18950 fac=(-12.0d0*sc_aa_tube/rdiff6**2.0d0/rdiff-&
18951 6.0d0*sc_bb_tube/rdiff6/rdiff)*sstube
18952 !C now direction of gg_tube vector
18954 gg_tube_SC(j,i)=gg_tube_SC(j,i)+vectube(j)*fac
18955 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac
18957 gg_tube_SC(3,i)=gg_tube_SC(3,i) &
18958 +ssgradtube*enetube(i+nres)/sstube
18959 gg_tube(3,i-1)= gg_tube(3,i-1) &
18960 +ssgradtube*enetube(i+nres)/sstube
18963 do i=itube_start,itube_end
18964 Etube=Etube+enetube(i)+enetube(i+nres)
18966 !C print *,"ETUBE", etube
18968 end subroutine calctube2
18969 !=====================================================================================================================================
18970 subroutine calcnano(Etube)
18971 real(kind=8),dimension(3) :: vectube
18973 real(kind=8) :: Etube,xtemp,xminact,yminact,&
18974 ytemp,xmin,ymin,tub_r,rdiff,rdiff6,fac,denominator,faccav,&
18975 sc_aa_tube,sc_bb_tube,zmin,ztemp,zminact
18976 integer:: i,j,iti,r
18979 ! print *,itube_start,itube_end,"poczatek"
18980 do i=itube_start,itube_end
18982 enetube(i+nres)=0.0d0
18984 !C first we calculate the distance from tube center
18985 !C first sugare-phosphate group for NARES this would be peptide group
18987 do i=itube_start,itube_end
18988 !C lets ommit dummy atoms for now
18989 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1)) cycle
18990 !C now calculate distance from center of tube and direction vectors
18996 vectube(1)=dmod((c(1,i)+c(1,i+1))/2.0d0,boxxsize)
18997 vectube(1)=vectube(1)+boxxsize*j
18998 vectube(2)=dmod((c(2,i)+c(2,i+1))/2.0d0,boxysize)
18999 vectube(2)=vectube(2)+boxysize*j
19000 vectube(3)=dmod((c(3,i)+c(3,i+1))/2.0d0,boxzsize)
19001 vectube(3)=vectube(3)+boxzsize*j
19004 xminact=dabs(vectube(1)-tubecenter(1))
19005 yminact=dabs(vectube(2)-tubecenter(2))
19006 zminact=dabs(vectube(3)-tubecenter(3))
19008 if (xmin.gt.xminact) then
19012 if (ymin.gt.yminact) then
19016 if (zmin.gt.zminact) then
19025 vectube(1)=vectube(1)-tubecenter(1)
19026 vectube(2)=vectube(2)-tubecenter(2)
19027 vectube(3)=vectube(3)-tubecenter(3)
19029 !C print *,"x",(c(1,i)+c(1,i+1))/2.0d0,tubecenter(1)
19030 !C print *,"y",(c(2,i)+c(2,i+1))/2.0d0,tubecenter(2)
19031 !C as the tube is infinity we do not calculate the Z-vector use of Z
19033 !C vectube(3)=0.0d0
19034 !C now calculte the distance
19035 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
19036 !C now normalize vector
19037 vectube(1)=vectube(1)/tub_r
19038 vectube(2)=vectube(2)/tub_r
19039 vectube(3)=vectube(3)/tub_r
19040 !C calculte rdiffrence between r and r0
19043 rdiff6=rdiff**6.0d0
19044 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
19045 enetube(i)=pep_aa_tube/rdiff6**2.0d0+pep_bb_tube/rdiff6
19046 !C write(iout,*) "TU13",i,rdiff6,enetube(i)
19047 !C print *,rdiff,rdiff6,pep_aa_tube
19048 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
19049 !C now we calculate gradient
19050 fac=(-12.0d0*pep_aa_tube/rdiff6- &
19051 6.0d0*pep_bb_tube)/rdiff6/rdiff
19052 !C write(iout,'(a5,i4,f12.1,3f12.5)') "TU13",i,rdiff6,enetube(i),
19054 if (acavtubpep.eq.0.0d0) then
19059 denominator=(1.0d0+dcavtubpep*rdiff6*rdiff6)
19061 (bcavtubpep*rdiff+acavtubpep*dsqrt(rdiff)+ccavtubpep) &
19064 faccav=((bcavtubpep*1.0d0+acavtubpep/2.0d0/dsqrt(rdiff)) &
19065 *denominator-(bcavtubpep*rdiff+acavtubpep*dsqrt(rdiff) &
19066 +ccavtubpep)*rdiff6**2.0d0/rdiff*dcavtubpep*12.0d0) &
19067 /denominator**2.0d0
19072 if (energy_dec) write(iout,*),i,rdiff,enetube(i),enecavtube(i)
19074 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac/2.0d0
19075 gg_tube(j,i)=gg_tube(j,i)+vectube(j)*fac/2.0d0
19079 do i=itube_start,itube_end
19080 enecavtube(i)=0.0d0
19081 !C Lets not jump over memory as we use many times iti
19083 !C lets ommit dummy atoms for now
19084 if ((iti.eq.ntyp1) &
19085 !C in UNRES uncomment the line below as GLY has no side-chain...
19092 vectube(1)=dmod((c(1,i+nres)),boxxsize)
19093 vectube(1)=vectube(1)+boxxsize*j
19094 vectube(2)=dmod((c(2,i+nres)),boxysize)
19095 vectube(2)=vectube(2)+boxysize*j
19096 vectube(3)=dmod((c(3,i+nres)),boxzsize)
19097 vectube(3)=vectube(3)+boxzsize*j
19100 xminact=dabs(vectube(1)-tubecenter(1))
19101 yminact=dabs(vectube(2)-tubecenter(2))
19102 zminact=dabs(vectube(3)-tubecenter(3))
19104 if (xmin.gt.xminact) then
19108 if (ymin.gt.yminact) then
19112 if (zmin.gt.zminact) then
19121 !C write(iout,*), "tututu", vectube(1),tubecenter(1),vectube(2),
19123 vectube(1)=vectube(1)-tubecenter(1)
19124 vectube(2)=vectube(2)-tubecenter(2)
19125 vectube(3)=vectube(3)-tubecenter(3)
19126 !C now calculte the distance
19127 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
19128 !C now normalize vector
19129 vectube(1)=vectube(1)/tub_r
19130 vectube(2)=vectube(2)/tub_r
19131 vectube(3)=vectube(3)/tub_r
19133 !C calculte rdiffrence between r and r0
19136 rdiff6=rdiff**6.0d0
19137 sc_aa_tube=sc_aa_tube_par(iti)
19138 sc_bb_tube=sc_bb_tube_par(iti)
19139 enetube(i+nres)=sc_aa_tube/rdiff6**2.0d0+sc_bb_tube/rdiff6
19140 !C enetube(i+nres)=0.0d0
19141 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
19142 !C now we calculate gradient
19143 fac=-12.0d0*sc_aa_tube/rdiff6**2.0d0/rdiff- &
19144 6.0d0*sc_bb_tube/rdiff6/rdiff
19146 !C now direction of gg_tube vector
19147 !C Now cavity term E=a(x+bsqrt(x)+c)/(1+dx^12)
19148 if (acavtub(iti).eq.0.0d0) then
19150 enecavtube(i+nres)=0.0d0
19153 denominator=(1.0d0+dcavtub(iti)*rdiff6*rdiff6)
19154 enecavtube(i+nres)= &
19155 (bcavtub(iti)*rdiff+acavtub(iti)*dsqrt(rdiff)+ccavtub(iti)) &
19157 !C enecavtube(i)=0.0
19158 faccav=((bcavtub(iti)*1.0d0+acavtub(iti)/2.0d0/dsqrt(rdiff)) &
19159 *denominator-(bcavtub(iti)*rdiff+acavtub(iti)*dsqrt(rdiff) &
19160 +ccavtub(iti))*rdiff6**2.0d0/rdiff*dcavtub(iti)*12.0d0) &
19161 /denominator**2.0d0
19166 !C print *,"TUT",i,iti,rdiff,rdiff6,acavtub(iti),denominator,
19167 !C & enecavtube(i),faccav
19168 !C print *,"licz=",
19169 !C & (bcavtub(iti)*rdiff+acavtub(iti)*sqrt(rdiff)+ccavtub(iti))
19170 !C print *,"finene=",enetube(i+nres)+enecavtube(i)
19172 gg_tube_SC(j,i)=gg_tube_SC(j,i)+vectube(j)*fac
19173 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac
19175 if (energy_dec) write(iout,*),i,rdiff,enetube(i+nres),enecavtube(i+nres)
19180 do i=itube_start,itube_end
19181 Etube=Etube+enetube(i)+enetube(i+nres)+enecavtube(i) &
19182 +enecavtube(i+nres)
19185 ! print *,"begin", i,"a"
19188 ! rdiff6=rdiff**6.0d0
19189 ! sc_aa_tube=sc_aa_tube_par(i)
19190 ! sc_bb_tube=sc_bb_tube_par(i)
19191 ! enetube(i)=sc_aa_tube/rdiff6**2.0d0+sc_bb_tube/rdiff6
19192 ! denominator=(1.0d0+dcavtub(i)*rdiff6*rdiff6)
19194 ! (bcavtub(i)*rdiff+acavtub(i)*dsqrt(rdiff)+ccavtub(i)) &
19197 ! print '(5(f10.3,1x))',rdiff,enetube(i),enecavtube(i),enecavtube(i)+enetube(i)
19199 ! print *,"end",i,"a"
19201 !C print *,"ETUBE", etube
19203 end subroutine calcnano
19205 !===============================================
19206 !--------------------------------------------------------------------------------
19207 !C first for shielding is setting of function of side-chains
19209 subroutine set_shield_fac2
19210 real(kind=8) :: div77_81=0.974996043d0, &
19211 div4_81=0.2222222222d0
19212 real (kind=8) :: dist_pep_side,dist_side_calf,dist_pept_group, &
19213 scale_fac_dist,fac_help_scale,VofOverlap,VolumeTotal,costhet,&
19214 short,long,sinthet,costhet_fac,sh_frac_dist,rkprim,cosphi, &
19215 sinphi,cosphi_fac,pep_side0pept_group,cosalfa,fac_alfa_sin
19216 !C the vector between center of side_chain and peptide group
19217 real(kind=8),dimension(3) :: pep_side_long,side_calf, &
19218 pept_group,costhet_grad,cosphi_grad_long, &
19219 cosphi_grad_loc,pep_side_norm,side_calf_norm, &
19220 sh_frac_dist_grad,pep_side
19222 !C write(2,*) "ivec",ivec_start,ivec_end
19224 fac_shield(i)=0.0d0
19226 grad_shield(j,i)=0.0d0
19229 do i=ivec_start,ivec_end
19231 !C if ((itype(i,1).eq.ntyp1).and.itype(i+1,1).eq.ntyp1) cycle
19233 if ((itype(i,1).eq.ntyp1).and.itype(i+1,1).eq.ntyp1) cycle
19234 !Cif there two consequtive dummy atoms there is no peptide group between them
19235 !C the line below has to be changed for FGPROC>1
19238 if ((itype(k,1).eq.ntyp1).or.(itype(k,1).eq.10)) cycle
19242 !C first lets set vector conecting the ithe side-chain with kth side-chain
19243 pep_side(j)=c(j,k+nres)-(c(j,i)+c(j,i+1))/2.0d0
19244 !C pep_side(j)=2.0d0
19245 !C and vector conecting the side-chain with its proper calfa
19246 side_calf(j)=c(j,k+nres)-c(j,k)
19247 !C side_calf(j)=2.0d0
19248 pept_group(j)=c(j,i)-c(j,i+1)
19249 !C lets have their lenght
19250 dist_pep_side=pep_side(j)**2+dist_pep_side
19251 dist_side_calf=dist_side_calf+side_calf(j)**2
19252 dist_pept_group=dist_pept_group+pept_group(j)**2
19254 dist_pep_side=sqrt(dist_pep_side)
19255 dist_pept_group=sqrt(dist_pept_group)
19256 dist_side_calf=sqrt(dist_side_calf)
19258 pep_side_norm(j)=pep_side(j)/dist_pep_side
19259 side_calf_norm(j)=dist_side_calf
19261 !C now sscale fraction
19262 sh_frac_dist=-(dist_pep_side-rpp(1,1)-buff_shield)/buff_shield
19263 !C print *,buff_shield,"buff"
19265 if (sh_frac_dist.le.0.0) cycle
19266 !C print *,ishield_list(i),i
19267 !C If we reach here it means that this side chain reaches the shielding sphere
19268 !C Lets add him to the list for gradient
19269 ishield_list(i)=ishield_list(i)+1
19270 !C ishield_list is a list of non 0 side-chain that contribute to factor gradient
19271 !C this list is essential otherwise problem would be O3
19272 shield_list(ishield_list(i),i)=k
19273 !C Lets have the sscale value
19274 if (sh_frac_dist.gt.1.0) then
19275 scale_fac_dist=1.0d0
19277 sh_frac_dist_grad(j)=0.0d0
19280 scale_fac_dist=-sh_frac_dist*sh_frac_dist &
19281 *(2.0d0*sh_frac_dist-3.0d0)
19282 fac_help_scale=6.0d0*(sh_frac_dist-sh_frac_dist**2) &
19283 /dist_pep_side/buff_shield*0.5d0
19285 sh_frac_dist_grad(j)=fac_help_scale*pep_side(j)
19286 !C sh_frac_dist_grad(j)=0.0d0
19287 !C scale_fac_dist=1.0d0
19288 !C print *,"jestem",scale_fac_dist,fac_help_scale,
19289 !C & sh_frac_dist_grad(j)
19292 !C this is what is now we have the distance scaling now volume...
19293 short=short_r_sidechain(itype(k,1))
19294 long=long_r_sidechain(itype(k,1))
19295 costhet=1.0d0/dsqrt(1.0d0+short**2/dist_pep_side**2)
19296 sinthet=short/dist_pep_side*costhet
19297 !C now costhet_grad
19300 costhet_fac=costhet**3*short**2*(-0.5d0)/dist_pep_side**4
19301 !C sinthet_fac=costhet**2*0.5d0*(short**3/dist_pep_side**4*costhet
19302 !C & -short/dist_pep_side**2/costhet)
19303 !C costhet_fac=0.0d0
19305 costhet_grad(j)=costhet_fac*pep_side(j)
19307 !C remember for the final gradient multiply costhet_grad(j)
19308 !C for side_chain by factor -2 !
19309 !C fac alfa is angle between CB_k,CA_k, CA_i,CA_i+1
19310 !C pep_side0pept_group is vector multiplication
19311 pep_side0pept_group=0.0d0
19313 pep_side0pept_group=pep_side0pept_group+pep_side(j)*side_calf(j)
19315 cosalfa=(pep_side0pept_group/ &
19316 (dist_pep_side*dist_side_calf))
19317 fac_alfa_sin=1.0d0-cosalfa**2
19318 fac_alfa_sin=dsqrt(fac_alfa_sin)
19319 rkprim=fac_alfa_sin*(long-short)+short
19322 !C now costhet_grad
19323 cosphi=1.0d0/dsqrt(1.0d0+rkprim**2/dist_pep_side**2)
19325 cosphi_fac=cosphi**3*rkprim**2*(-0.5d0)/dist_pep_side**4
19326 sinphi=rkprim/dist_pep_side/dsqrt(1.0d0+rkprim**2/ &
19330 cosphi_grad_long(j)=cosphi_fac*pep_side(j) &
19331 +cosphi**3*0.5d0/dist_pep_side**2*(-rkprim) &
19332 *(long-short)/fac_alfa_sin*cosalfa/ &
19333 ((dist_pep_side*dist_side_calf))* &
19334 ((side_calf(j))-cosalfa* &
19335 ((pep_side(j)/dist_pep_side)*dist_side_calf))
19336 !C cosphi_grad_long(j)=0.0d0
19337 cosphi_grad_loc(j)=cosphi**3*0.5d0/dist_pep_side**2*(-rkprim) &
19338 *(long-short)/fac_alfa_sin*cosalfa &
19339 /((dist_pep_side*dist_side_calf))* &
19341 cosalfa*side_calf(j)/dist_side_calf*dist_pep_side)
19342 !C cosphi_grad_loc(j)=0.0d0
19344 !C print *,sinphi,sinthet
19345 VofOverlap=VSolvSphere/2.0d0*(1.0d0-dsqrt(1.0d0-sinphi*sinthet)) &
19348 !C now the gradient...
19350 grad_shield(j,i)=grad_shield(j,i) &
19351 !C gradient po skalowaniu
19352 +(sh_frac_dist_grad(j)*VofOverlap &
19353 !C gradient po costhet
19354 +scale_fac_dist*VSolvSphere/VSolvSphere_div/4.0d0* &
19355 (1.0d0/(-dsqrt(1.0d0-sinphi*sinthet))*( &
19356 sinphi/sinthet*costhet*costhet_grad(j) &
19357 +sinthet/sinphi*cosphi*cosphi_grad_long(j))) &
19359 !C grad_shield_side is Cbeta sidechain gradient
19360 grad_shield_side(j,ishield_list(i),i)=&
19361 (sh_frac_dist_grad(j)*-2.0d0&
19363 -scale_fac_dist*VSolvSphere/VSolvSphere_div/2.0d0*&
19364 (1.0d0/(-dsqrt(1.0d0-sinphi*sinthet))*(&
19365 sinphi/sinthet*costhet*costhet_grad(j)&
19366 +sinthet/sinphi*cosphi*cosphi_grad_long(j))) &
19369 grad_shield_loc(j,ishield_list(i),i)= &
19370 scale_fac_dist*VSolvSphere/VSolvSphere_div/2.0d0*&
19371 (1.0d0/(dsqrt(1.0d0-sinphi*sinthet))*(&
19372 sinthet/sinphi*cosphi*cosphi_grad_loc(j)&
19376 VolumeTotal=VolumeTotal+VofOverlap*scale_fac_dist
19378 fac_shield(i)=VolumeTotal*wshield+(1.0d0-wshield)
19380 !C write(2,*) "TOTAL VOLUME",i,itype(i,1),fac_shield(i)
19383 end subroutine set_shield_fac2
19384 !----------------------------------------------------------------------------
19385 ! SOUBROUTINE FOR AFM
19386 subroutine AFMvel(Eafmforce)
19387 use MD_data, only:totTafm
19388 real(kind=8),dimension(3) :: diffafm
19389 real(kind=8) :: afmdist,Eafmforce
19391 !C Only for check grad COMMENT if not used for checkgrad
19393 !C--------------------------------------------------------
19394 !C print *,"wchodze"
19398 diffafm(i)=c(i,afmend)-c(i,afmbeg)
19399 afmdist=afmdist+diffafm(i)**2
19401 afmdist=dsqrt(afmdist)
19403 Eafmforce=0.5d0*forceAFMconst &
19404 *(distafminit+totTafm*velAFMconst-afmdist)**2
19405 !C Eafmforce=-forceAFMconst*(dist-distafminit)
19407 gradafm(i,afmend-1)=-forceAFMconst* &
19408 (distafminit+totTafm*velAFMconst-afmdist) &
19409 *diffafm(i)/afmdist
19410 gradafm(i,afmbeg-1)=forceAFMconst* &
19411 (distafminit+totTafm*velAFMconst-afmdist) &
19412 *diffafm(i)/afmdist
19414 ! print *,'AFM',Eafmforce,totTafm*velAFMconst,afmdist
19416 end subroutine AFMvel
19417 !---------------------------------------------------------
19418 subroutine AFMforce(Eafmforce)
19420 real(kind=8),dimension(3) :: diffafm
19421 ! real(kind=8) ::afmdist
19422 real(kind=8) :: afmdist,Eafmforce
19427 diffafm(i)=c(i,afmend)-c(i,afmbeg)
19428 afmdist=afmdist+diffafm(i)**2
19430 afmdist=dsqrt(afmdist)
19431 ! print *,afmdist,distafminit
19432 Eafmforce=-forceAFMconst*(afmdist-distafminit)
19434 gradafm(i,afmend-1)=-forceAFMconst*diffafm(i)/afmdist
19435 gradafm(i,afmbeg-1)=forceAFMconst*diffafm(i)/afmdist
19437 !C print *,'AFM',Eafmforce
19439 end subroutine AFMforce
19441 !-----------------------------------------------------------------------------
19443 subroutine read_ssHist
19446 ! include 'DIMENSIONS'
19447 ! include "DIMENSIONS.FREE"
19448 ! include 'COMMON.FREE'
19451 character(len=80) :: controlcard
19454 call card_concat(controlcard,.true.)
19455 read(controlcard,*) &
19456 dyn_ssHist(i,0),(dyn_ssHist(i,j),j=1,2*dyn_ssHist(i,0))
19460 end subroutine read_ssHist
19462 !-----------------------------------------------------------------------------
19463 integer function indmat(i,j)
19465 ! get the position of the jth ijth fragment of the chain coordinate system
19466 ! in the fromto array.
19469 indmat=((2*(nres-2)-i)*(i-1))/2+j-1
19471 end function indmat
19472 !-----------------------------------------------------------------------------
19473 real(kind=8) function sigm(x)
19479 !-----------------------------------------------------------------------------
19480 !-----------------------------------------------------------------------------
19481 subroutine alloc_ener_arrays
19482 !EL Allocation of arrays used by module energy
19483 use MD_data, only: mset
19484 !el local variables
19487 if(nres.lt.100) then
19489 elseif(nres.lt.200) then
19490 maxconts=0.8*nres ! Max. number of contacts per residue
19492 maxconts=0.6*nres ! (maxconts=maxres/4)
19494 maxcont=12*nres ! Max. number of SC contacts
19495 maxvar=6*nres ! Max. number of variables
19496 !el maxdim=(nres-1)*(nres-2)/2 ! Max. number of derivatives of virtual-bond
19497 maxdim=nres*(nres-2)/2 ! Max. number of derivatives of virtual-bond
19498 !----------------------
19499 ! arrays in subroutine init_int_table
19501 !el allocate(itask_cont_from(0:nfgtasks-1)) !(0:max_fg_procs-1)
19502 !el allocate(itask_cont_to(0:nfgtasks-1)) !(0:max_fg_procs-1)
19504 allocate(nint_gr(nres))
19505 allocate(nscp_gr(nres))
19506 allocate(ielstart(nres))
19507 allocate(ielend(nres))
19509 allocate(istart(nres,maxint_gr))
19510 allocate(iend(nres,maxint_gr))
19511 !(maxres,maxint_gr)
19512 allocate(iscpstart(nres,maxint_gr))
19513 allocate(iscpend(nres,maxint_gr))
19514 !(maxres,maxint_gr)
19515 allocate(ielstart_vdw(nres))
19516 allocate(ielend_vdw(nres))
19518 allocate(nint_gr_nucl(nres))
19519 allocate(nscp_gr_nucl(nres))
19520 allocate(ielstart_nucl(nres))
19521 allocate(ielend_nucl(nres))
19523 allocate(istart_nucl(nres,maxint_gr))
19524 allocate(iend_nucl(nres,maxint_gr))
19525 !(maxres,maxint_gr)
19526 allocate(iscpstart_nucl(nres,maxint_gr))
19527 allocate(iscpend_nucl(nres,maxint_gr))
19528 !(maxres,maxint_gr)
19529 allocate(ielstart_vdw_nucl(nres))
19530 allocate(ielend_vdw_nucl(nres))
19532 allocate(lentyp(0:nfgtasks-1))
19534 !----------------------
19536 ! common /contacts/
19537 if(.not.allocated(icont_ref)) allocate(icont_ref(2,maxcont))
19538 allocate(icont(2,maxcont))
19540 ! common /contacts1/
19541 allocate(num_cont(0:nres+4))
19543 allocate(jcont(maxconts,nres))
19545 allocate(facont(maxconts,nres))
19547 allocate(gacont(3,maxconts,nres))
19548 !(3,maxconts,maxres)
19549 ! common /contacts_hb/
19550 allocate(gacontp_hb1(3,maxconts,nres))
19551 allocate(gacontp_hb2(3,maxconts,nres))
19552 allocate(gacontp_hb3(3,maxconts,nres))
19553 allocate(gacontm_hb1(3,maxconts,nres))
19554 allocate(gacontm_hb2(3,maxconts,nres))
19555 allocate(gacontm_hb3(3,maxconts,nres))
19556 allocate(gacont_hbr(3,maxconts,nres))
19557 allocate(grij_hb_cont(3,maxconts,nres))
19558 !(3,maxconts,maxres)
19559 allocate(facont_hb(maxconts,nres))
19561 allocate(ees0p(maxconts,nres))
19562 allocate(ees0m(maxconts,nres))
19563 allocate(d_cont(maxconts,nres))
19564 allocate(ees0plist(maxconts,nres))
19567 allocate(num_cont_hb(nres))
19569 allocate(jcont_hb(maxconts,nres))
19572 allocate(Ug(2,2,nres))
19573 allocate(Ugder(2,2,nres))
19574 allocate(Ug2(2,2,nres))
19575 allocate(Ug2der(2,2,nres))
19577 allocate(obrot(2,nres))
19578 allocate(obrot2(2,nres))
19579 allocate(obrot_der(2,nres))
19580 allocate(obrot2_der(2,nres))
19582 ! common /precomp1/
19583 allocate(mu(2,nres))
19584 allocate(muder(2,nres))
19585 allocate(Ub2(2,nres))
19588 allocate(Ub2der(2,nres))
19589 allocate(Ctobr(2,nres))
19590 allocate(Ctobrder(2,nres))
19591 allocate(Dtobr2(2,nres))
19592 allocate(Dtobr2der(2,nres))
19594 allocate(EUg(2,2,nres))
19595 allocate(EUgder(2,2,nres))
19596 allocate(CUg(2,2,nres))
19597 allocate(CUgder(2,2,nres))
19598 allocate(DUg(2,2,nres))
19599 allocate(Dugder(2,2,nres))
19600 allocate(DtUg2(2,2,nres))
19601 allocate(DtUg2der(2,2,nres))
19603 ! common /precomp2/
19604 allocate(Ug2Db1t(2,nres))
19605 allocate(Ug2Db1tder(2,nres))
19606 allocate(CUgb2(2,nres))
19607 allocate(CUgb2der(2,nres))
19609 allocate(EUgC(2,2,nres))
19610 allocate(EUgCder(2,2,nres))
19611 allocate(EUgD(2,2,nres))
19612 allocate(EUgDder(2,2,nres))
19613 allocate(DtUg2EUg(2,2,nres))
19614 allocate(Ug2DtEUg(2,2,nres))
19616 allocate(Ug2DtEUgder(2,2,2,nres))
19617 allocate(DtUg2EUgder(2,2,2,nres))
19619 ! common /rotat_old/
19620 allocate(costab(nres))
19621 allocate(sintab(nres))
19622 allocate(costab2(nres))
19623 allocate(sintab2(nres))
19626 allocate(a_chuj(2,2,maxconts,nres))
19627 !(2,2,maxconts,maxres)(maxconts=maxres/4)
19628 allocate(a_chuj_der(2,2,3,5,maxconts,nres))
19629 !(2,2,3,5,maxconts,maxres)(maxconts=maxres/4)
19630 ! common /contdistrib/
19631 allocate(ncont_sent(nres))
19632 allocate(ncont_recv(nres))
19634 allocate(iat_sent(nres))
19636 allocate(iint_sent(4,nres,nres))
19637 allocate(iint_sent_local(4,nres,nres))
19639 allocate(iturn3_sent(4,0:nres+4))
19640 allocate(iturn4_sent(4,0:nres+4))
19641 allocate(iturn3_sent_local(4,nres))
19642 allocate(iturn4_sent_local(4,nres))
19644 allocate(itask_cont_from(0:nfgtasks-1))
19645 allocate(itask_cont_to(0:nfgtasks-1))
19646 !(0:max_fg_procs-1)
19650 !----------------------
19653 allocate(dcdv(6,maxdim))
19654 allocate(dxdv(6,maxdim))
19656 allocate(dxds(6,nres))
19658 allocate(gradx(3,-1:nres,0:2))
19659 allocate(gradc(3,-1:nres,0:2))
19661 allocate(gvdwx(3,-1:nres))
19662 allocate(gvdwc(3,-1:nres))
19663 allocate(gelc(3,-1:nres))
19664 allocate(gelc_long(3,-1:nres))
19665 allocate(gvdwpp(3,-1:nres))
19666 allocate(gvdwc_scpp(3,-1:nres))
19667 allocate(gradx_scp(3,-1:nres))
19668 allocate(gvdwc_scp(3,-1:nres))
19669 allocate(ghpbx(3,-1:nres))
19670 allocate(ghpbc(3,-1:nres))
19671 allocate(gradcorr(3,-1:nres))
19672 allocate(gradcorr_long(3,-1:nres))
19673 allocate(gradcorr5_long(3,-1:nres))
19674 allocate(gradcorr6_long(3,-1:nres))
19675 allocate(gcorr6_turn_long(3,-1:nres))
19676 allocate(gradxorr(3,-1:nres))
19677 allocate(gradcorr5(3,-1:nres))
19678 allocate(gradcorr6(3,-1:nres))
19679 allocate(gliptran(3,-1:nres))
19680 allocate(gliptranc(3,-1:nres))
19681 allocate(gliptranx(3,-1:nres))
19682 allocate(gshieldx(3,-1:nres))
19683 allocate(gshieldc(3,-1:nres))
19684 allocate(gshieldc_loc(3,-1:nres))
19685 allocate(gshieldx_ec(3,-1:nres))
19686 allocate(gshieldc_ec(3,-1:nres))
19687 allocate(gshieldc_loc_ec(3,-1:nres))
19688 allocate(gshieldx_t3(3,-1:nres))
19689 allocate(gshieldc_t3(3,-1:nres))
19690 allocate(gshieldc_loc_t3(3,-1:nres))
19691 allocate(gshieldx_t4(3,-1:nres))
19692 allocate(gshieldc_t4(3,-1:nres))
19693 allocate(gshieldc_loc_t4(3,-1:nres))
19694 allocate(gshieldx_ll(3,-1:nres))
19695 allocate(gshieldc_ll(3,-1:nres))
19696 allocate(gshieldc_loc_ll(3,-1:nres))
19697 allocate(grad_shield(3,-1:nres))
19698 allocate(gg_tube_sc(3,-1:nres))
19699 allocate(gg_tube(3,-1:nres))
19700 allocate(gradafm(3,-1:nres))
19701 allocate(gradb_nucl(3,-1:nres))
19702 allocate(gradbx_nucl(3,-1:nres))
19703 allocate(gvdwpsb1(3,-1:nres))
19704 allocate(gelpp(3,-1:nres))
19705 allocate(gvdwpsb(3,-1:nres))
19706 allocate(gelsbc(3,-1:nres))
19707 allocate(gelsbx(3,-1:nres))
19708 allocate(gvdwsbx(3,-1:nres))
19709 allocate(gvdwsbc(3,-1:nres))
19710 allocate(gsbloc(3,-1:nres))
19711 allocate(gsblocx(3,-1:nres))
19712 allocate(gradcorr_nucl(3,-1:nres))
19713 allocate(gradxorr_nucl(3,-1:nres))
19714 allocate(gradcorr3_nucl(3,-1:nres))
19715 allocate(gradxorr3_nucl(3,-1:nres))
19716 allocate(gvdwpp_nucl(3,-1:nres))
19719 allocate(grad_shield_side(3,50,nres))
19720 allocate(grad_shield_loc(3,50,nres))
19721 ! grad for shielding surroing
19722 allocate(gloc(0:maxvar,0:2))
19723 allocate(gloc_x(0:maxvar,2))
19725 allocate(gel_loc(3,-1:nres))
19726 allocate(gel_loc_long(3,-1:nres))
19727 allocate(gcorr3_turn(3,-1:nres))
19728 allocate(gcorr4_turn(3,-1:nres))
19729 allocate(gcorr6_turn(3,-1:nres))
19730 allocate(gradb(3,-1:nres))
19731 allocate(gradbx(3,-1:nres))
19733 allocate(gel_loc_loc(maxvar))
19734 allocate(gel_loc_turn3(maxvar))
19735 allocate(gel_loc_turn4(maxvar))
19736 allocate(gel_loc_turn6(maxvar))
19737 allocate(gcorr_loc(maxvar))
19738 allocate(g_corr5_loc(maxvar))
19739 allocate(g_corr6_loc(maxvar))
19741 allocate(gsccorc(3,-1:nres))
19742 allocate(gsccorx(3,-1:nres))
19744 allocate(gsccor_loc(-1:nres))
19746 allocate(dtheta(3,2,-1:nres))
19748 allocate(gscloc(3,-1:nres))
19749 allocate(gsclocx(3,-1:nres))
19751 allocate(dphi(3,3,-1:nres))
19752 allocate(dalpha(3,3,-1:nres))
19753 allocate(domega(3,3,-1:nres))
19755 ! common /deriv_scloc/
19756 allocate(dXX_C1tab(3,nres))
19757 allocate(dYY_C1tab(3,nres))
19758 allocate(dZZ_C1tab(3,nres))
19759 allocate(dXX_Ctab(3,nres))
19760 allocate(dYY_Ctab(3,nres))
19761 allocate(dZZ_Ctab(3,nres))
19762 allocate(dXX_XYZtab(3,nres))
19763 allocate(dYY_XYZtab(3,nres))
19764 allocate(dZZ_XYZtab(3,nres))
19767 allocate(jgrad_start(nres))
19768 allocate(jgrad_end(nres))
19770 !----------------------
19773 allocate(ibond_displ(0:nfgtasks-1))
19774 allocate(ibond_count(0:nfgtasks-1))
19775 allocate(ithet_displ(0:nfgtasks-1))
19776 allocate(ithet_count(0:nfgtasks-1))
19777 allocate(iphi_displ(0:nfgtasks-1))
19778 allocate(iphi_count(0:nfgtasks-1))
19779 allocate(iphi1_displ(0:nfgtasks-1))
19780 allocate(iphi1_count(0:nfgtasks-1))
19781 allocate(ivec_displ(0:nfgtasks-1))
19782 allocate(ivec_count(0:nfgtasks-1))
19783 allocate(iset_displ(0:nfgtasks-1))
19784 allocate(iset_count(0:nfgtasks-1))
19785 allocate(iint_count(0:nfgtasks-1))
19786 allocate(iint_displ(0:nfgtasks-1))
19787 !(0:max_fg_procs-1)
19788 !----------------------
19791 allocate(gcart(3,-1:nres))
19792 allocate(gxcart(3,-1:nres))
19794 allocate(gradcag(3,-1:nres))
19795 allocate(gradxag(3,-1:nres))
19797 ! common /back_constr/
19798 !el in energy:Econstr_back allocate((:),allocatable :: utheta,ugamma,uscdiff !(maxfrag_back)
19799 allocate(dutheta(nres))
19800 allocate(dugamma(nres))
19802 allocate(duscdiff(3,nres))
19803 allocate(duscdiffx(3,nres))
19805 !el i io:read_fragments
19806 ! allocate((:,:,:),allocatable :: wfrag_back !(3,maxfrag_back,maxprocs/20)
19807 ! allocate((:,:,:),allocatable :: ifrag_back !(3,maxfrag_back,maxprocs/20)
19809 ! allocate(qinfrag(50,nprocs/20),wfrag(50,nprocs/20)) !(50,maxprocs/20)
19810 ! allocate(qinpair(100,nprocs/20),wpair(100,nprocs/20)) !(100,maxprocs/20)
19811 allocate(mset(0:nprocs)) !(maxprocs/20)
19813 ! allocate(ifrag(2,50,nprocs/20)) !(2,50,maxprocs/20)
19814 ! allocate(ipair(2,100,nprocs/20)) !(2,100,maxprocs/20)
19815 allocate(dUdconst(3,0:nres))
19816 allocate(dUdxconst(3,0:nres))
19817 allocate(dqwol(3,0:nres))
19818 allocate(dxqwol(3,0:nres))
19820 !----------------------
19822 ! common /sbridge/ in io_common: read_bridge
19823 !el allocate((:),allocatable :: iss !(maxss)
19824 ! common /links/ in io_common: read_bridge
19825 !el real(kind=8),dimension(:),allocatable :: dhpb,forcon,dhpb1 !(maxdim) !el dhpb1 !!! nie używane
19826 !el integer,dimension(:),allocatable :: ihpb,jhpb,ibecarb !(maxdim) !el ibecarb !!! nie używane
19827 ! common /dyn_ssbond/
19828 ! and side-chain vectors in theta or phi.
19829 allocate(dyn_ssbond_ij(0:nres+4,0:nres+4))
19833 dyn_ssbond_ij(:,:)=1.0d300
19837 ! if (nss.gt.0) then
19838 allocate(idssb(maxdim),jdssb(maxdim))
19839 ! allocate(newihpb(nss),newjhpb(nss))
19842 allocate(ishield_list(nres))
19843 allocate(shield_list(50,nres))
19844 allocate(dyn_ss_mask(nres))
19845 allocate(fac_shield(nres))
19846 allocate(enetube(nres*2))
19847 allocate(enecavtube(nres*2))
19850 dyn_ss_mask(:)=.false.
19851 !----------------------
19853 ! Parameters of the SCCOR term
19855 !el in io_conf: parmread
19856 ! allocate(v1sccor(maxterm_sccor,3,-ntyp:ntyp,-ntyp:ntyp))
19857 ! allocate(v2sccor(maxterm_sccor,3,-ntyp:ntyp,-ntyp:ntyp)) !(maxterm_sccor,3,-ntyp:ntyp,-ntyp:ntyp)
19858 ! allocate(v0sccor(maxterm_sccor,-ntyp:ntyp,-ntyp:ntyp)) !(maxterm_sccor,-ntyp:ntyp,-ntyp:ntyp)
19859 ! allocate(isccortyp(-ntyp:ntyp)) !(-ntyp:ntyp)
19860 ! allocate(nterm_sccor(-ntyp:ntyp,-ntyp:ntyp))
19861 ! allocate(nlor_sccor(-ntyp:ntyp,-ntyp:ntyp)) !(-ntyp:ntyp,-ntyp:ntyp)
19862 ! allocate(vlor1sccor(maxterm_sccor,20,20))
19863 ! allocate(vlor2sccor(maxterm_sccor,20,20))
19864 ! allocate(vlor3sccor(maxterm_sccor,20,20)) !(maxterm_sccor,20,20)
19866 allocate(gloc_sc(3,0:2*nres,0:10))
19867 !(3,0:maxres2,10)maxres2=2*maxres
19868 allocate(dcostau(3,3,3,2*nres))
19869 allocate(dsintau(3,3,3,2*nres))
19870 allocate(dtauangle(3,3,3,2*nres))
19871 allocate(dcosomicron(3,3,3,2*nres))
19872 allocate(domicron(3,3,3,2*nres))
19873 !(3,3,3,maxres2)maxres2=2*maxres
19874 !----------------------
19877 allocate(varall(maxvar))
19878 !(maxvar)(maxvar=6*maxres)
19879 allocate(mask_theta(nres))
19880 allocate(mask_phi(nres))
19881 allocate(mask_side(nres))
19883 !----------------------
19886 allocate(uy(3,nres))
19887 allocate(uz(3,nres))
19889 allocate(uygrad(3,3,2,nres))
19890 allocate(uzgrad(3,3,2,nres))
19894 end subroutine alloc_ener_arrays
19895 !-----------------------------------------------------------------
19896 subroutine ebond_nucl(estr_nucl)
19898 !c Evaluate the energy of stretching of the CA-CA and CA-SC virtual bonds
19901 real(kind=8),dimension(3) :: u,ud
19902 real(kind=8) :: usum,uprod,uprod1,uprod2,usumsqder
19903 real(kind=8) :: estr_nucl,diff
19904 integer :: iti,i,j,k,nbi
19906 !C print *,"I enter ebond"
19908 write (iout,*) "ibondp_start,ibondp_end",&
19909 ibondp_nucl_start,ibondp_nucl_end
19910 do i=ibondp_nucl_start,ibondp_nucl_end
19911 if (itype(i-1,2).eq.ntyp1_molec(2) .or. &
19912 itype(i,2).eq.ntyp1_molec(2)) cycle
19913 ! estr1=estr1+gnmr1(vbld(i),-1.0d0,distchainmax)
19915 ! gradb(j,i-1)=gnmr1prim(vbld(i),-1.0d0,distchainmax)
19916 ! & *dc(j,i-1)/vbld(i)
19918 ! if (energy_dec) write(iout,*)
19919 ! & "estr1",i,vbld(i),distchainmax,
19920 ! & gnmr1(vbld(i),-1.0d0,distchainmax)
19922 diff = vbld(i)-vbldp0_nucl
19923 if(energy_dec)write(iout,*) "estr_nucl_bb" , i,vbld(i),&
19924 vbldp0_nucl,diff,AKP_nucl*diff*diff
19925 estr_nucl=estr_nucl+diff*diff
19926 ! print *,estr_nucl
19928 gradb_nucl(j,i-1)=AKP_nucl*diff*dc(j,i-1)/vbld(i)
19930 !c write (iout,'(i5,3f10.5)') i,(gradb(j,i-1),j=1,3)
19932 estr_nucl=0.5d0*AKP_nucl*estr_nucl
19933 ! print *,"partial sum", estr_nucl,AKP_nucl
19936 write (iout,*) "ibondp_start,ibondp_end",&
19937 ibond_nucl_start,ibond_nucl_end
19939 do i=ibond_nucl_start,ibond_nucl_end
19940 !C print *, "I am stuck",i
19942 if (iti.eq.ntyp1_molec(2)) cycle
19943 nbi=nbondterm_nucl(iti)
19946 diff=vbld(i+nres)-vbldsc0_nucl(1,iti)
19949 write (iout,*) "estr_nucl_sc", i,iti,vbld(i+nres),vbldsc0_nucl(1,iti),diff, &
19950 AKSC_nucl(1,iti),AKSC_nucl(1,iti)*diff*diff
19951 estr_nucl=estr_nucl+0.5d0*AKSC_nucl(1,iti)*diff*diff
19952 ! print *,estr_nucl
19954 gradbx_nucl(j,i)=AKSC_nucl(1,iti)*diff*dc(j,i+nres)/vbld(i+nres)
19958 diff=vbld(i+nres)-vbldsc0_nucl(j,iti)
19959 ud(j)=aksc_nucl(j,iti)*diff
19960 u(j)=abond0_nucl(j,iti)+0.5d0*ud(j)*diff
19974 uprod2=uprod2*u(k)*u(k)
19978 usumsqder=usumsqder+ud(j)*uprod2
19980 estr_nucl=estr_nucl+uprod/usum
19982 gradbx_nucl(j,i)=usumsqder/(usum*usum)*dc(j,i+nres)/vbld(i+nres)
19986 !C print *,"I am about to leave ebond"
19988 end subroutine ebond_nucl
19990 !-----------------------------------------------------------------------------
19991 subroutine ebend_nucl(etheta_nucl)
19992 real(kind=8),dimension(nntheterm_nucl+1) :: coskt,sinkt !mmaxtheterm
19993 real(kind=8),dimension(nsingle_nucl+1) :: cosph1,sinph1,cosph2,sinph2 !maxsingle
19994 real(kind=8),dimension(ndouble_nucl+1,ndouble_nucl+1) :: cosph1ph2,sinph1ph2 !maxdouble,maxdouble
19995 logical :: lprn=.false., lprn1=.false.
19996 !el local variables
19997 integer :: i,k,iblock,ityp1,ityp2,ityp3,l,m
19998 real(kind=8) :: dethetai,dephii,dephii1,theti2,phii,phii1,ethetai
19999 real(kind=8) :: aux,etheta_nucl,ccl,ssl,scl,csl,ethetacnstr
20000 ! local variables for constrains
20001 real(kind=8) :: difi,thetiii
20004 ! print *,"ithet_start",ithet_nucl_start," ithet_end",ithet_nucl_end,nres
20005 do i=ithet_nucl_start,ithet_nucl_end
20006 if ((itype(i-1,2).eq.ntyp1_molec(2)).or.&
20007 (itype(i-2,2).eq.ntyp1_molec(2)).or. &
20008 (itype(i,2).eq.ntyp1_molec(2))) cycle
20012 theti2=0.5d0*theta(i)
20013 ityp2=ithetyp_nucl(itype(i-1,2))
20014 do k=1,nntheterm_nucl
20015 coskt(k)=dcos(k*theti2)
20016 sinkt(k)=dsin(k*theti2)
20018 if (i.gt.3 .and. itype(i-2,2).ne.ntyp1_molec(2)) then
20021 if (phii.ne.phii) phii=150.0
20025 ityp1=ithetyp_nucl(itype(i-2,2))
20026 do k=1,nsingle_nucl
20027 cosph1(k)=dcos(k*phii)
20028 sinph1(k)=dsin(k*phii)
20032 ityp1=nthetyp_nucl+1
20033 do k=1,nsingle_nucl
20039 if (i.lt.nres .and. itype(i,2).ne.ntyp1_molec(2)) then
20042 if (phii1.ne.phii1) phii1=150.0
20043 phii1=pinorm(phii1)
20047 ityp3=ithetyp_nucl(itype(i,2))
20048 do k=1,nsingle_nucl
20049 cosph2(k)=dcos(k*phii1)
20050 sinph2(k)=dsin(k*phii1)
20054 ityp3=nthetyp_nucl+1
20055 do k=1,nsingle_nucl
20060 ethetai=aa0thet_nucl(ityp1,ityp2,ityp3)
20061 do k=1,ndouble_nucl
20063 ccl=cosph1(l)*cosph2(k-l)
20064 ssl=sinph1(l)*sinph2(k-l)
20065 scl=sinph1(l)*cosph2(k-l)
20066 csl=cosph1(l)*sinph2(k-l)
20067 cosph1ph2(l,k)=ccl-ssl
20068 cosph1ph2(k,l)=ccl+ssl
20069 sinph1ph2(l,k)=scl+csl
20070 sinph1ph2(k,l)=scl-csl
20074 write (iout,*) "i",i," ityp1",ityp1," ityp2",ityp2,&
20075 " ityp3",ityp3," theti2",theti2," phii",phii," phii1",phii1
20076 write (iout,*) "coskt and sinkt",nntheterm_nucl
20077 do k=1,nntheterm_nucl
20078 write (iout,*) k,coskt(k),sinkt(k)
20081 do k=1,ntheterm_nucl
20082 ethetai=ethetai+aathet_nucl(k,ityp1,ityp2,ityp3)*sinkt(k)
20083 dethetai=dethetai+0.5d0*k*aathet_nucl(k,ityp1,ityp2,ityp3)&
20086 write (iout,*) "k",k," aathet",aathet_nucl(k,ityp1,ityp2,ityp3),&
20090 write (iout,*) "cosph and sinph"
20091 do k=1,nsingle_nucl
20092 write (iout,*) k,cosph1(k),sinph1(k),cosph2(k),sinph2(k)
20094 write (iout,*) "cosph1ph2 and sinph2ph2"
20095 do k=2,ndouble_nucl
20097 write (iout,*) l,k,cosph1ph2(l,k),cosph1ph2(k,l),&
20098 sinph1ph2(l,k),sinph1ph2(k,l)
20101 write(iout,*) "ethetai",ethetai
20103 do m=1,ntheterm2_nucl
20104 do k=1,nsingle_nucl
20105 aux=bbthet_nucl(k,m,ityp1,ityp2,ityp3)*cosph1(k)&
20106 +ccthet_nucl(k,m,ityp1,ityp2,ityp3)*sinph1(k)&
20107 +ddthet_nucl(k,m,ityp1,ityp2,ityp3)*cosph2(k)&
20108 +eethet_nucl(k,m,ityp1,ityp2,ityp3)*sinph2(k)
20109 ethetai=ethetai+sinkt(m)*aux
20110 dethetai=dethetai+0.5d0*m*aux*coskt(m)
20111 dephii=dephii+k*sinkt(m)*(&
20112 ccthet_nucl(k,m,ityp1,ityp2,ityp3)*cosph1(k)-&
20113 bbthet_nucl(k,m,ityp1,ityp2,ityp3)*sinph1(k))
20114 dephii1=dephii1+k*sinkt(m)*(&
20115 eethet_nucl(k,m,ityp1,ityp2,ityp3)*cosph2(k)-&
20116 ddthet_nucl(k,m,ityp1,ityp2,ityp3)*sinph2(k))
20118 write (iout,*) "m",m," k",k," bbthet",&
20119 bbthet_nucl(k,m,ityp1,ityp2,ityp3)," ccthet",&
20120 ccthet_nucl(k,m,ityp1,ityp2,ityp3)," ddthet",&
20121 ddthet_nucl(k,m,ityp1,ityp2,ityp3)," eethet",&
20122 eethet_nucl(k,m,ityp1,ityp2,ityp3)," ethetai",ethetai
20126 write(iout,*) "ethetai",ethetai
20127 do m=1,ntheterm3_nucl
20128 do k=2,ndouble_nucl
20130 aux=ffthet_nucl(l,k,m,ityp1,ityp2,ityp3)*cosph1ph2(l,k)+&
20131 ffthet_nucl(k,l,m,ityp1,ityp2,ityp3)*cosph1ph2(k,l)+&
20132 ggthet_nucl(l,k,m,ityp1,ityp2,ityp3)*sinph1ph2(l,k)+&
20133 ggthet_nucl(k,l,m,ityp1,ityp2,ityp3)*sinph1ph2(k,l)
20134 ethetai=ethetai+sinkt(m)*aux
20135 dethetai=dethetai+0.5d0*m*coskt(m)*aux
20136 dephii=dephii+l*sinkt(m)*(&
20137 -ffthet_nucl(l,k,m,ityp1,ityp2,ityp3)*sinph1ph2(l,k)-&
20138 ffthet_nucl(k,l,m,ityp1,ityp2,ityp3)*sinph1ph2(k,l)+&
20139 ggthet_nucl(l,k,m,ityp1,ityp2,ityp3)*cosph1ph2(l,k)+&
20140 ggthet_nucl(k,l,m,ityp1,ityp2,ityp3)*cosph1ph2(k,l))
20141 dephii1=dephii1+(k-l)*sinkt(m)*( &
20142 -ffthet_nucl(l,k,m,ityp1,ityp2,ityp3)*sinph1ph2(l,k)+&
20143 ffthet_nucl(k,l,m,ityp1,ityp2,ityp3)*sinph1ph2(k,l)+&
20144 ggthet_nucl(l,k,m,ityp1,ityp2,ityp3)*cosph1ph2(l,k)-&
20145 ggthet_nucl(k,l,m,ityp1,ityp2,ityp3)*cosph1ph2(k,l))
20147 write (iout,*) "m",m," k",k," l",l," ffthet", &
20148 ffthet_nucl(l,k,m,ityp1,ityp2,ityp3), &
20149 ffthet_nucl(k,l,m,ityp1,ityp2,ityp3)," ggthet",&
20150 ggthet_nucl(l,k,m,ityp1,ityp2,ityp3),&
20151 ggthet_nucl(k,l,m,ityp1,ityp2,ityp3)," ethetai",ethetai
20152 write (iout,*) cosph1ph2(l,k)*sinkt(m), &
20153 cosph1ph2(k,l)*sinkt(m),&
20154 sinph1ph2(l,k)*sinkt(m),sinph1ph2(k,l)*sinkt(m)
20160 if (lprn1) write (iout,'(i2,3f8.1,9h ethetai ,f10.5)') &
20161 i,theta(i)*rad2deg,phii*rad2deg, &
20162 phii1*rad2deg,ethetai
20163 etheta_nucl=etheta_nucl+ethetai
20164 ! print *,i,"partial sum",etheta_nucl
20165 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang_nucl*dephii
20166 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang_nucl*dephii1
20167 gloc(nphi+i-2,icg)=wang_nucl*dethetai
20170 end subroutine ebend_nucl
20171 !----------------------------------------------------
20172 subroutine etor_nucl(etors_nucl)
20173 ! implicit real*8 (a-h,o-z)
20174 ! include 'DIMENSIONS'
20175 ! include 'COMMON.VAR'
20176 ! include 'COMMON.GEO'
20177 ! include 'COMMON.LOCAL'
20178 ! include 'COMMON.TORSION'
20179 ! include 'COMMON.INTERACT'
20180 ! include 'COMMON.DERIV'
20181 ! include 'COMMON.CHAIN'
20182 ! include 'COMMON.NAMES'
20183 ! include 'COMMON.IOUNITS'
20184 ! include 'COMMON.FFIELD'
20185 ! include 'COMMON.TORCNSTR'
20186 ! include 'COMMON.CONTROL'
20187 real(kind=8) :: etors_nucl,edihcnstr
20189 !el local variables
20190 integer :: i,j,iblock,itori,itori1
20191 real(kind=8) :: phii,gloci,v1ij,v2ij,cosphi,sinphi,&
20192 vl1ij,vl2ij,vl3ij,pom1,difi,etors_ii,pom
20193 ! Set lprn=.true. for debugging
20197 ! print *,"iphi_nucl_start/end", iphi_nucl_start,iphi_nucl_end
20198 do i=iphi_nucl_start,iphi_nucl_end
20199 if (itype(i-2,2).eq.ntyp1_molec(2) .or. itype(i-1,2).eq.ntyp1_molec(2) &
20200 .or. itype(i-3,2).eq.ntyp1_molec(2) &
20201 .or. itype(i,2).eq.ntyp1_molec(2)) cycle
20203 itori=itortyp_nucl(itype(i-2,2))
20204 itori1=itortyp_nucl(itype(i-1,2))
20206 ! print *,i,itori,itori1
20208 !C Regular cosine and sine terms
20209 do j=1,nterm_nucl(itori,itori1)
20210 v1ij=v1_nucl(j,itori,itori1)
20211 v2ij=v2_nucl(j,itori,itori1)
20212 cosphi=dcos(j*phii)
20213 sinphi=dsin(j*phii)
20214 etors_nucl=etors_nucl+v1ij*cosphi+v2ij*sinphi
20215 if (energy_dec) etors_ii=etors_ii+&
20216 v1ij*cosphi+v2ij*sinphi
20217 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
20221 !C E = SUM ----------------------------------- - v1
20222 !C [v2 cos(phi/2)+v3 sin(phi/2)]^2 + 1
20224 cosphi=dcos(0.5d0*phii)
20225 sinphi=dsin(0.5d0*phii)
20226 do j=1,nlor_nucl(itori,itori1)
20227 vl1ij=vlor1_nucl(j,itori,itori1)
20228 vl2ij=vlor2_nucl(j,itori,itori1)
20229 vl3ij=vlor3_nucl(j,itori,itori1)
20230 pom=vl2ij*cosphi+vl3ij*sinphi
20231 pom1=1.0d0/(pom*pom+1.0d0)
20232 etors_nucl=etors_nucl+vl1ij*pom1
20233 if (energy_dec) etors_ii=etors_ii+ &
20236 gloci=gloci+vl1ij*(vl3ij*cosphi-vl2ij*sinphi)*pom
20238 !C Subtract the constant term
20239 etors_nucl=etors_nucl-v0_nucl(itori,itori1)
20240 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
20241 'etor',i,etors_ii-v0_nucl(itori,itori1)
20243 write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)') &
20244 restyp(itype(i-2,2),2),i-2,restyp(itype(i-1,2),2),i-1,itori,itori1, &
20245 (v1_nucl(j,itori,itori1),j=1,6),(v2_nucl(j,itori,itori1),j=1,6)
20246 gloc(i-3,icg)=gloc(i-3,icg)+wtor_nucl*gloci
20247 !c write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
20250 end subroutine etor_nucl
20251 !------------------------------------------------------------
20252 subroutine epp_nucl_sub(evdw1,ees)
20254 !C This subroutine calculates the average interaction energy and its gradient
20255 !C in the virtual-bond vectors between non-adjacent peptide groups, based on
20256 !C the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
20257 !C The potential depends both on the distance of peptide-group centers and on
20258 !C the orientation of the CA-CA virtual bonds.
20260 integer :: i,j,k,iteli,itelj,num_conti,isubchap,ind
20261 real(kind=8) :: dxi,dyi,dzi,dxj,dyj,dzj,aaa,bbb
20262 real(kind=8) :: xj,yj,zj,rij,rrmij,sss,r3ij,r6ij,evdw1,&
20263 dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
20264 dx_normj,dy_normj,dz_normj,rmij,ev1,ev2,evdwij,facvdw
20265 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
20266 dist_temp, dist_init,sss_grad,fac,evdw1ij
20267 integer xshift,yshift,zshift
20268 real(kind=8),dimension(3):: ggg,gggp,gggm,erij
20269 real(kind=8) :: ees,eesij
20270 !c 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
20271 real(kind=8) scal_el /0.5d0/
20277 !c Loop over all pairs of interacting peptide groups except i,i+2 and i,i+3
20279 ! print *,"iatel_s_nucl,iatel_e_nucl",iatel_s_nucl,iatel_e_nucl
20280 do i=iatel_s_nucl,iatel_e_nucl
20281 if (itype(i,2).eq.ntyp1_molec(2) .or. itype(i+1,2).eq.ntyp1_molec(2)) cycle
20285 dx_normi=dc_norm(1,i)
20286 dy_normi=dc_norm(2,i)
20287 dz_normi=dc_norm(3,i)
20288 xmedi=c(1,i)+0.5d0*dxi
20289 ymedi=c(2,i)+0.5d0*dyi
20290 zmedi=c(3,i)+0.5d0*dzi
20291 xmedi=dmod(xmedi,boxxsize)
20292 if (xmedi.lt.0) xmedi=xmedi+boxxsize
20293 ymedi=dmod(ymedi,boxysize)
20294 if (ymedi.lt.0) ymedi=ymedi+boxysize
20295 zmedi=dmod(zmedi,boxzsize)
20296 if (zmedi.lt.0) zmedi=zmedi+boxzsize
20298 do j=ielstart_nucl(i),ielend_nucl(i)
20299 if (itype(j,2).eq.ntyp1_molec(2) .or. itype(j+1,2).eq.ntyp1_molec(2)) cycle
20304 ! xj=c(1,j)+0.5D0*dxj-xmedi
20305 ! yj=c(2,j)+0.5D0*dyj-ymedi
20306 ! zj=c(3,j)+0.5D0*dzj-zmedi
20307 xj=c(1,j)+0.5D0*dxj
20308 yj=c(2,j)+0.5D0*dyj
20309 zj=c(3,j)+0.5D0*dzj
20310 xj=mod(xj,boxxsize)
20311 if (xj.lt.0) xj=xj+boxxsize
20312 yj=mod(yj,boxysize)
20313 if (yj.lt.0) yj=yj+boxysize
20314 zj=mod(zj,boxzsize)
20315 if (zj.lt.0) zj=zj+boxzsize
20317 dist_init=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
20324 xj=xj_safe+xshift*boxxsize
20325 yj=yj_safe+yshift*boxysize
20326 zj=zj_safe+zshift*boxzsize
20327 dist_temp=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
20328 if(dist_temp.lt.dist_init) then
20329 dist_init=dist_temp
20338 if (isubchap.eq.1) then
20349 rij=xj*xj+yj*yj+zj*zj
20350 !c write (2,*)"ij",i,j," r0pp",r0pp," rij",rij," epspp",epspp
20351 fac=(r0pp**2/rij)**3
20355 fac=(-ev1-evdw1ij)/rij
20356 ! write (2,*)"fac",fac," ev1",ev1," ev2",ev2," evdw1ij",evdw1ij
20357 if (energy_dec) write(iout,'(2i5,a9,f10.4)') i,j,"evdw1ij",evdw1ij
20358 evdw1=evdw1+evdw1ij
20360 !C Calculate contributions to the Cartesian gradient.
20366 gvdwpp_nucl(k,i)=gvdwpp_nucl(k,i)-ggg(k)
20367 gvdwpp_nucl(k,j)=gvdwpp_nucl(k,j)+ggg(k)
20369 !c phoshate-phosphate electrostatic interactions
20372 eesij=dexp(-BEES*rij)*fac
20373 ! write (2,*)"fac",fac," eesijpp",eesij
20374 if (energy_dec) write(iout,'(2i5,a9,f10.4)') i,j,"eesijpp",eesij
20377 fac=-(fac+BEES)*eesij*fac
20381 !c write(2,*) "ggg",i,j,ggg(1),ggg(2),ggg(3)
20382 !c write(2,*) "gelpp",i,(gelpp(k,i),k=1,3)
20383 !c write(2,*) "gelpp",j,(gelpp(k,j),k=1,3)
20385 gelpp(k,i)=gelpp(k,i)-ggg(k)
20386 gelpp(k,j)=gelpp(k,j)+ggg(k)
20393 !c write (2,*) "i",i," gelpp",(gelpp(k,i),k=1,3)
20395 gvdwpp_nucl(k,i)=6*gvdwpp_nucl(k,i)
20396 !c gelpp(k,i)=332.0d0*gelpp(k,i)
20397 gelpp(k,i)=AEES*gelpp(k,i)
20399 !c write (2,*) "i",i," gelpp",(gelpp(k,i),k=1,3)
20401 !c write (2,*) "total EES",ees
20403 end subroutine epp_nucl_sub
20404 !---------------------------------------------------------------------
20405 subroutine epsb(evdwpsb,eelpsb)
20408 !C This subroutine calculates the excluded-volume interaction energy between
20409 !C peptide-group centers and side chains and its gradient in virtual-bond and
20410 !C side-chain vectors.
20412 real(kind=8),dimension(3):: ggg
20413 integer :: i,iint,j,k,iteli,itypj,subchap
20414 real(kind=8) :: evdw2,evdw2_14,xi,yi,zi,xj,yj,zj,rrij,fac,&
20415 e1,e2,evdwij,rij,evdwpsb,eelpsb
20416 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
20417 dist_temp, dist_init
20418 integer xshift,yshift,zshift
20420 !cd print '(a)','Enter ESCP'
20421 !cd write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
20424 ! print *,"iatscp_s_nucl,iatscp_e_nucl",iatscp_s_nucl,iatscp_e_nucl
20425 do i=iatscp_s_nucl,iatscp_e_nucl
20426 if (itype(i,2).eq.ntyp1_molec(2) &
20427 .or. itype(i+1,2).eq.ntyp1_molec(2)) cycle
20428 xi=0.5D0*(c(1,i)+c(1,i+1))
20429 yi=0.5D0*(c(2,i)+c(2,i+1))
20430 zi=0.5D0*(c(3,i)+c(3,i+1))
20431 xi=mod(xi,boxxsize)
20432 if (xi.lt.0) xi=xi+boxxsize
20433 yi=mod(yi,boxysize)
20434 if (yi.lt.0) yi=yi+boxysize
20435 zi=mod(zi,boxzsize)
20436 if (zi.lt.0) zi=zi+boxzsize
20438 do iint=1,nscp_gr_nucl(i)
20440 do j=iscpstart_nucl(i,iint),iscpend_nucl(i,iint)
20442 if (itypj.eq.ntyp1_molec(2)) cycle
20443 !C Uncomment following three lines for SC-p interactions
20444 !c xj=c(1,nres+j)-xi
20445 !c yj=c(2,nres+j)-yi
20446 !c zj=c(3,nres+j)-zi
20447 !C Uncomment following three lines for Ca-p interactions
20454 xj=mod(xj,boxxsize)
20455 if (xj.lt.0) xj=xj+boxxsize
20456 yj=mod(yj,boxysize)
20457 if (yj.lt.0) yj=yj+boxysize
20458 zj=mod(zj,boxzsize)
20459 if (zj.lt.0) zj=zj+boxzsize
20460 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
20468 xj=xj_safe+xshift*boxxsize
20469 yj=yj_safe+yshift*boxysize
20470 zj=zj_safe+zshift*boxzsize
20471 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
20472 if(dist_temp.lt.dist_init) then
20473 dist_init=dist_temp
20482 if (subchap.eq.1) then
20492 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
20494 e1=fac*fac*aad_nucl(itypj)
20495 e2=fac*bad_nucl(itypj)
20496 if (iabs(j-i) .le. 2) then
20501 evdwpsb=evdwpsb+evdwij
20502 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a4)') &
20503 'evdw2',i,j,evdwij,"tu4"
20505 !C Calculate contributions to the gradient in the virtual-bond and SC vectors.
20507 fac=-(evdwij+e1)*rrij
20512 gvdwpsb1(k,i)=gvdwpsb1(k,i)-ggg(k)
20513 gvdwpsb(k,j)=gvdwpsb(k,j)+ggg(k)
20521 gvdwpsb(j,i)=expon*gvdwpsb(j,i)
20522 gvdwpsb1(j,i)=expon*gvdwpsb1(j,i)
20526 end subroutine epsb
20528 !------------------------------------------------------
20529 subroutine esb_gb(evdwsb,eelsb)
20532 integer :: iint,itypi,itypi1,itypj,subchap,num_conti2
20533 real(kind=8) :: xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
20534 real(kind=8) :: evdw,sig0iji,evdwsb,eelsb,ecorr,eelij
20535 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
20536 dist_temp, dist_init,aa,bb,faclip,sig0ij
20545 ! print *,"iastsc_nucl",iatsc_s_nucl,iatsc_e_nucl
20546 do i=iatsc_s_nucl,iatsc_e_nucl
20550 ! PRINT *,"I=",i,itypi
20551 if (itypi.eq.ntyp1_molec(2)) cycle
20552 itypi1=itype(i+1,2)
20556 xi=dmod(xi,boxxsize)
20557 if (xi.lt.0) xi=xi+boxxsize
20558 yi=dmod(yi,boxysize)
20559 if (yi.lt.0) yi=yi+boxysize
20560 zi=dmod(zi,boxzsize)
20561 if (zi.lt.0) zi=zi+boxzsize
20563 dxi=dc_norm(1,nres+i)
20564 dyi=dc_norm(2,nres+i)
20565 dzi=dc_norm(3,nres+i)
20566 dsci_inv=vbld_inv(i+nres)
20568 !C Calculate SC interaction energy.
20570 do iint=1,nint_gr_nucl(i)
20571 ! print *,"tu?",i,istart_nucl(i,iint),iend_nucl(i,iint)
20572 do j=istart_nucl(i,iint),iend_nucl(i,iint)
20576 if (itypj.eq.ntyp1_molec(2)) cycle
20577 dscj_inv=vbld_inv(j+nres)
20578 sig0ij=sigma_nucl(itypi,itypj)
20579 chi1=chi_nucl(itypi,itypj)
20580 chi2=chi_nucl(itypj,itypi)
20582 chip1=chip_nucl(itypi,itypj)
20583 chip2=chip_nucl(itypj,itypi)
20585 ! xj=c(1,nres+j)-xi
20586 ! yj=c(2,nres+j)-yi
20587 ! zj=c(3,nres+j)-zi
20591 xj=dmod(xj,boxxsize)
20592 if (xj.lt.0) xj=xj+boxxsize
20593 yj=dmod(yj,boxysize)
20594 if (yj.lt.0) yj=yj+boxysize
20595 zj=dmod(zj,boxzsize)
20596 if (zj.lt.0) zj=zj+boxzsize
20597 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
20605 xj=xj_safe+xshift*boxxsize
20606 yj=yj_safe+yshift*boxysize
20607 zj=zj_safe+zshift*boxzsize
20608 dist_temp=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
20609 if(dist_temp.lt.dist_init) then
20610 dist_init=dist_temp
20619 if (subchap.eq.1) then
20629 dxj=dc_norm(1,nres+j)
20630 dyj=dc_norm(2,nres+j)
20631 dzj=dc_norm(3,nres+j)
20632 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
20634 !C Calculate angle-dependent terms of energy and contributions to their
20639 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
20640 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
20641 om12=dxi*dxj+dyi*dyj+dzi*dzj
20642 call sc_angular_nucl
20644 sig=sig0ij*dsqrt(sigsq)
20645 rij_shift=1.0D0/rij-sig+sig0ij
20646 ! print *,rij_shift,"rij_shift"
20647 !c write (2,*) " rij",1.0D0/rij," sig",sig," sig0ij",sig0ij,
20648 !c & " rij_shift",rij_shift
20649 if (rij_shift.le.0.0D0) then
20654 !c---------------------------------------------------------------
20655 rij_shift=1.0D0/rij_shift
20656 fac=rij_shift**expon
20657 e1=fac*fac*aa_nucl(itypi,itypj)
20658 e2=fac*bb_nucl(itypi,itypj)
20659 evdwij=eps1*eps2rt*(e1+e2)
20660 !c write (2,*) "eps1",eps1," eps2rt",eps2rt,
20661 !c & " e1",e1," e2",e2," evdwij",evdwij
20663 evdwij=evdwij*eps2rt
20664 evdwsb=evdwsb+evdwij
20666 sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
20667 epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
20668 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
20669 restyp(itypi,2),i,restyp(itypj,2),j, &
20670 epsi,sigm,chi1,chi2,chip1,chip2, &
20671 eps1,eps2rt**2,sig,sig0ij, &
20672 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
20674 write (iout,*) "aa",aa_nucl(itypi,itypj)," bb",bb_nucl(itypi,itypj)
20677 if (energy_dec) write (iout,'(a6,2i5,e15.3,a4)') &
20678 'evdw',i,j,evdwij,"tu3"
20681 !C Calculate gradient components.
20682 e1=e1*eps1*eps2rt**2
20683 fac=-expon*(e1+evdwij)*rij_shift
20687 !C Calculate the radial part of the gradient
20691 !C Calculate angular part of the gradient.
20693 call eelsbij(eelij,num_conti2)
20694 if (energy_dec .and. &
20695 (j.eq.i+1.or.j.eq.nres-i+1.or.j.eq.nres-i.or.j.eq.nres-i+2)) &
20696 write (istat,'(e14.5)') evdwij
20700 num_cont_hb(i)=num_conti2
20702 !c write (iout,*) "Number of loop steps in EGB:",ind
20703 !cccc energy_dec=.false.
20705 end subroutine esb_gb
20706 !-------------------------------------------------------------------------------
20707 subroutine eelsbij(eesij,num_conti2)
20710 real(kind=8),dimension(3) :: ggg,gggp,gggm,dcosb,dcosg
20711 real(kind=8),dimension(3,3) :: erder,uryg,urzg,vryg,vrzg
20712 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
20713 dist_temp, dist_init,rlocshield,fracinbuf
20714 integer xshift,yshift,zshift,ilist,iresshield,num_conti2
20716 !c 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
20717 real(kind=8) scal_el /0.5d0/
20718 integer :: iteli,itelj,kkk,kkll,m,isubchap
20719 real(kind=8) :: ael6i,rrmij,rmij,r0ij,fcont,fprimcont,ees0tmp,facfac
20720 real(kind=8) :: ees,evdw1,eel_loc,aaa,bbb,ael3i,ael63i,ael32i
20721 real(kind=8) :: dx_normj,dy_normj,dz_normj,&
20722 r3ij,r6ij,cosa,cosb,cosg,fac,ev1,ev2,fac3,fac4,fac5,fac6,&
20723 el1,el2,el3,el4,eesij,ees0ij,facvdw,facel,fac1,ecosa,&
20724 ecosb,ecosg,ury,urz,vry,vrz,facr,a22der,a23der,a32der,&
20725 a33der,eel_loc_ij,cosa4,wij,cosbg1,cosbg2,ees0pij,&
20726 ees0pij1,ees0mij,ees0mij1,fac3p,ees0mijp,ees0pijp,&
20727 ecosa1,ecosb1,ecosg1,ecosa2,ecosb2,ecosg2,ecosap,ecosbp,&
20728 ecosgp,ecosam,ecosbm,ecosgm,ghalf,itypi,itypj
20732 ! print *,i,j,itypi,itypj,istype(i),istype(j),"????"
20733 ael6i=ael6_nucl(itypi,itypj)
20734 ael3i=ael3_nucl(itypi,itypj)
20735 ael63i=ael63_nucl(itypi,itypj)
20736 ael32i=ael32_nucl(itypi,itypj)
20737 !c write (iout,*) "eelecij",i,j,itype(i),itype(j),
20738 !c & ael6i,ael3i,ael63i,al32i,rij,rrij
20742 dx_normi=dc_norm(1,i+nres)
20743 dy_normi=dc_norm(2,i+nres)
20744 dz_normi=dc_norm(3,i+nres)
20745 dx_normj=dc_norm(1,j+nres)
20746 dy_normj=dc_norm(2,j+nres)
20747 dz_normj=dc_norm(3,j+nres)
20748 !c xj=c(1,j)+0.5D0*dxj-xmedi
20749 !c yj=c(2,j)+0.5D0*dyj-ymedi
20750 !c zj=c(3,j)+0.5D0*dzj-zmedi
20751 if (ipot_nucl.ne.2) then
20752 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
20753 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
20754 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
20762 fac=cosa-3.0D0*cosb*cosg
20764 fac1=3.0d0*(cosb*cosb+cosg*cosg)
20769 !c write (iout,*) "r3ij",r3ij," r6ij",r6ij," fac",fac," fac1",fac1,
20770 !c & " fac2",fac2," fac3",fac3," fac4",fac4," fac5",fac5," fac6",fac6
20771 el1=fac3*(4.0D0+facfac-fac1)
20773 el3=fac5*(2.0d0-2.0d0*facfac+fac1)
20775 eesij=el1+el2+el3+el4
20776 !C 12/26/95 - for the evaluation of multi-body H-bonding interactions
20777 ees0ij=4.0D0+facfac-fac1
20779 if (energy_dec) then
20780 if(j.eq.i+1.or.j.eq.nres-i+1.or.j.eq.nres-i.or.j.eq.nres-i+2) &
20781 write (istat,'(2a1,i4,1x,2a1,i4,4f10.5,3e12.5,$)') &
20782 sugartyp(istype(i)),restyp(itypi,2),i,sugartyp(istype(j)),&
20783 restyp(itypj,2),j,1.0d0/rij,cosa,cosb,cosg,fac*r3ij, &
20784 (4.0D0+facfac-fac1)*r6ij,(2.0d0-2.0d0*facfac+fac1)*r6ij
20785 write (iout,'(a6,2i5,e15.3)') 'ees',i,j,eesij
20789 !C Calculate contributions to the Cartesian gradient.
20791 facel=-3.0d0*rrij*(eesij+el1+el3+el4)
20797 !* Radial derivatives. First process both termini of the fragment (i,j)
20803 gelsbc(k,j)=gelsbc(k,j)+ggg(k)
20804 gelsbc(k,i)=gelsbc(k,i)-ggg(k)
20805 gelsbx(k,j)=gelsbx(k,j)+ggg(k)
20806 gelsbx(k,i)=gelsbx(k,i)-ggg(k)
20811 ecosa=2.0D0*fac3*fac1+fac4+(-4.0d0*fac5+2.0d0*fac6)*fac1
20816 ecosb=fac3*(fac1*cosg+cosb)+cosg*fac4+(cosb+2*fac1*cosg)*fac5+&
20818 ecosg=fac3*(fac1*cosb+cosg)+cosb*fac4+(cosg+2*fac1*cosb)*fac5+&
20821 dcosb(k)=rij*(dc_norm(k,i+nres)-erij(k)*cosb)
20822 dcosg(k)=rij*(dc_norm(k,j+nres)-erij(k)*cosg)
20825 ggg(k)=ecosb*dcosb(k)+ecosg*dcosg(k)
20828 gelsbx(k,i)=gelsbx(k,i)-ggg(k) &
20829 +(ecosa*(dc_norm(k,j+nres)-cosa*dc_norm(k,i+nres))&
20830 + ecosb*(erij(k)-cosb*dc_norm(k,i+nres)))*vbld_inv(i+nres)
20831 gelsbx(k,j)=gelsbx(k,j)+ggg(k) &
20832 +(ecosa*(dc_norm(k,i+nres)-cosa*dc_norm(k,j+nres))&
20833 + ecosg*(erij(k)-cosg*dc_norm(k,j+nres)))*vbld_inv(j+nres)
20834 gelsbc(k,j)=gelsbc(k,j)+ggg(k)
20835 gelsbc(k,i)=gelsbc(k,i)-ggg(k)
20837 ! IF ( (wcorr_nucl.gt.0.0d0.or.wcorr3_nucl.gt.0.0d0) .and.
20838 IF ( j.gt.i+1 .and.&
20839 num_conti.le.maxconts) THEN
20841 !C Calculate the contact function. The ith column of the array JCONT will
20842 !C contain the numbers of atoms that make contacts with the atom I (of numbers
20843 !C greater than I). The arrays FACONT and GACONT will contain the values of
20844 !C the contact function and its derivative.
20845 r0ij=2.20D0*sigma(itypi,itypj)
20846 !c write (2,*) "ij",i,j," rij",1.0d0/rij," r0ij",r0ij
20847 call gcont(rij,r0ij,1.0D0,0.2d0/r0ij,fcont,fprimcont)
20848 !c write (2,*) "fcont",fcont
20849 if (fcont.gt.0.0D0) then
20850 num_conti=num_conti+1
20851 num_conti2=num_conti2+1
20853 if (num_conti.gt.maxconts) then
20854 write (iout,*) 'WARNING - max. # of contacts exceeded;',&
20855 ' will skip next contacts for this conf.'
20857 jcont_hb(num_conti,i)=j
20858 !c write (iout,*) "num_conti",num_conti,
20859 !c & " jcont_hb",jcont_hb(num_conti,i)
20860 !C Calculate contact energies
20862 wij=cosa-3.0D0*cosb*cosg
20865 fac3=dsqrt(-ael6i)*r3ij
20866 !c write (2,*) "ael6i",ael6i," r3ij",r3ij," fac3",fac3
20867 ees0tmp=4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1
20868 if (ees0tmp.gt.0) then
20869 ees0pij=dsqrt(ees0tmp)
20873 ees0tmp=4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2
20874 if (ees0tmp.gt.0) then
20875 ees0mij=dsqrt(ees0tmp)
20879 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij)
20880 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij)
20881 !c write (iout,*) "i",i," j",j,
20882 !c & " ees0m",ees0m(num_conti,i)," ees0p",ees0p(num_conti,i)
20883 ees0pij1=fac3/ees0pij
20884 ees0mij1=fac3/ees0mij
20885 fac3p=-3.0D0*fac3*rrij
20886 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
20887 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
20888 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
20889 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
20890 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
20891 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
20892 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
20893 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
20894 ecosap=ecosa1+ecosa2
20895 ecosbp=ecosb1+ecosb2
20896 ecosgp=ecosg1+ecosg2
20897 ecosam=ecosa1-ecosa2
20898 ecosbm=ecosb1-ecosb2
20899 ecosgm=ecosg1-ecosg2
20901 facont_hb(num_conti,i)=fcont
20902 fprimcont=fprimcont/rij
20904 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
20905 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
20907 gggp(1)=gggp(1)+ees0pijp*xj
20908 gggp(2)=gggp(2)+ees0pijp*yj
20909 gggp(3)=gggp(3)+ees0pijp*zj
20910 gggm(1)=gggm(1)+ees0mijp*xj
20911 gggm(2)=gggm(2)+ees0mijp*yj
20912 gggm(3)=gggm(3)+ees0mijp*zj
20913 !C Derivatives due to the contact function
20914 gacont_hbr(1,num_conti,i)=fprimcont*xj
20915 gacont_hbr(2,num_conti,i)=fprimcont*yj
20916 gacont_hbr(3,num_conti,i)=fprimcont*zj
20919 !c Gradient of the correlation terms
20921 gacontp_hb1(k,num_conti,i)= &
20922 (ecosap*(dc_norm(k,j+nres)-cosa*dc_norm(k,i+nres)) &
20923 + ecosbp*(erij(k)-cosb*dc_norm(k,i+nres)))*vbld_inv(i+nres)
20924 gacontp_hb2(k,num_conti,i)= &
20925 (ecosap*(dc_norm(k,i+nres)-cosa*dc_norm(k,j+nres)) &
20926 + ecosgp*(erij(k)-cosg*dc_norm(k,j+nres)))*vbld_inv(j+nres)
20927 gacontp_hb3(k,num_conti,i)=gggp(k)
20928 gacontm_hb1(k,num_conti,i)= &
20929 (ecosam*(dc_norm(k,j+nres)-cosa*dc_norm(k,i+nres)) &
20930 + ecosbm*(erij(k)-cosb*dc_norm(k,i+nres)))*vbld_inv(i+nres)
20931 gacontm_hb2(k,num_conti,i)= &
20932 (ecosam*(dc_norm(k,i+nres)-cosa*dc_norm(k,j+nres))&
20933 + ecosgm*(erij(k)-cosg*dc_norm(k,j+nres)))*vbld_inv(j+nres)
20934 gacontm_hb3(k,num_conti,i)=gggm(k)
20940 end subroutine eelsbij
20941 !------------------------------------------------------------------
20942 subroutine sc_grad_nucl
20945 real(kind=8),dimension(3) :: dcosom1,dcosom2
20946 eom1=eps2der*eps2rt_om1+sigder*sigsq_om1
20947 eom2=eps2der*eps2rt_om2+sigder*sigsq_om2
20948 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12+sigder*sigsq_om12
20950 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
20951 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
20954 gg(k)=gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
20957 gvdwsbx(k,i)=gvdwsbx(k,i)-gg(k) &
20958 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))&
20959 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
20960 gvdwsbx(k,j)=gvdwsbx(k,j)+gg(k) &
20961 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
20962 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
20965 !C Calculate the components of the gradient in DC and X
20968 gvdwsbc(l,i)=gvdwsbc(l,i)-gg(l)
20969 gvdwsbc(l,j)=gvdwsbc(l,j)+gg(l)
20972 end subroutine sc_grad_nucl
20973 !-----------------------------------------------------------------------
20974 subroutine esb(esbloc)
20975 !C Calculate the local energy of a side chain and its derivatives in the
20976 !C corresponding virtual-bond valence angles THETA and the spherical angles
20977 !C ALPHA and OMEGA derived from AM1 all-atom calculations.
20978 !C added by Urszula Kozlowska. 07/11/2007
20980 real(kind=8),dimension(3):: x_prime,y_prime,z_prime
20981 real(kind=8),dimension(9):: x
20982 real(kind=8) :: sumene,dsc_i,dp2_i,xx,yy,zz,sumene1, &
20983 sumene2,sumene3,sumene4,s1,s1_6,s2,s2_6,&
20984 de_dxx,de_dyy,de_dzz,de_dt,s1_t,s1_6_t,s2_t,s2_6_t
20985 real(kind=8),dimension(3):: dXX_Ci1,dYY_Ci1,dZZ_Ci1,dXX_Ci,&
20986 dYY_Ci,dZZ_Ci,dXX_XYZ,dYY_XYZ,dZZ_XYZ,dt_dCi,dt_dCi1
20987 real(kind=8) :: esbloc,delta,cosfac2,cosfac,sinfac2,sinfac,de_dtt,&
20988 cossc,cossc1,cosfac2xx,sinfac2yy,pom1,pom
20989 integer::it,nlobit,i,j,k
20990 ! common /sccalc/ time11,time12,time112,theti,it,nlobit
20993 do i=loc_start_nucl,loc_end_nucl
20994 if (itype(i,2).eq.ntyp1_molec(2)) cycle
20995 costtab(i+1) =dcos(theta(i+1))
20996 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
20997 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
20998 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
20999 cosfac2=0.5d0/(1.0d0+costtab(i+1))
21000 cosfac=dsqrt(cosfac2)
21001 sinfac2=0.5d0/(1.0d0-costtab(i+1))
21002 sinfac=dsqrt(sinfac2)
21004 if (it.eq.10) goto 1
21007 !C Compute the axes of tghe local cartesian coordinates system; store in
21008 !c x_prime, y_prime and z_prime
21015 !C write(2,*) "dc_norm", dc_norm(1,i+nres),dc_norm(2,i+nres),
21016 !C & dc_norm(3,i+nres)
21018 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
21019 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
21022 z_prime(j) = -uz(j,i-1)
21030 xx = xx + x_prime(j)*dc_norm(j,i+nres)
21031 yy = yy + y_prime(j)*dc_norm(j,i+nres)
21032 zz = zz + z_prime(j)*dc_norm(j,i+nres)
21040 x(j) = sc_parmin_nucl(j,it)
21043 !Cc diagnostics - remove later
21044 xx1 = dcos(alph(2))
21045 yy1 = dsin(alph(2))*dcos(omeg(2))
21046 zz1 = -dsin(alph(2))*dsin(omeg(2))
21047 write(2,'(3f8.1,3f9.3,1x,3f9.3)') &
21048 alph(2)*rad2deg,omeg(2)*rad2deg,theta(3)*rad2deg,xx,yy,zz,&
21050 !C," --- ", xx_w,yy_w,zz_w
21053 sumene = enesc_nucl(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
21054 esbloc = esbloc + sumene
21055 sumene2= enesc_nucl(x,xx,yy,0.0d0,cost2tab(i+1),sint2tab(i+1))
21056 ! print *,"enecomp",sumene,sumene2
21057 ! if (energy_dec) write(iout,*) "i",i," esbloc",sumene,esbloc,xx,yy,zz
21058 ! if (energy_dec) write(iout,*) "x",(x(k),k=1,9)
21060 write (2,*) "x",(x(k),k=1,9)
21062 !C This section to check the numerical derivatives of the energy of ith side
21063 !C chain in xx, yy, zz, and theta. Use the -DDEBUG compiler option or insert
21064 !C #define DEBUG in the code to turn it on.
21066 write (2,*) "sumene =",sumene
21070 write (2,*) xx,yy,zz
21071 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
21072 de_dxx_num=(sumenep-sumene)/aincr
21074 write (2,*) "xx+ sumene from enesc=",sumenep,sumene
21077 write (2,*) xx,yy,zz
21078 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
21079 de_dyy_num=(sumenep-sumene)/aincr
21081 write (2,*) "yy+ sumene from enesc=",sumenep,sumene
21084 write (2,*) xx,yy,zz
21085 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
21086 de_dzz_num=(sumenep-sumene)/aincr
21088 write (2,*) "zz+ sumene from enesc=",sumenep,sumene
21089 costsave=cost2tab(i+1)
21090 sintsave=sint2tab(i+1)
21091 cost2tab(i+1)=dcos(0.5d0*(theta(i+1)+aincr))
21092 sint2tab(i+1)=dsin(0.5d0*(theta(i+1)+aincr))
21093 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
21094 de_dt_num=(sumenep-sumene)/aincr
21095 write (2,*) " t+ sumene from enesc=",sumenep,sumene
21096 cost2tab(i+1)=costsave
21097 sint2tab(i+1)=sintsave
21098 !C End of diagnostics section.
21101 !C Compute the gradient of esc
21103 de_dxx=x(1)+2*x(4)*xx+x(7)*zz+x(8)*yy
21104 de_dyy=x(2)+2*x(5)*yy+x(8)*xx+x(9)*zz
21105 de_dzz=x(3)+2*x(6)*zz+x(7)*xx+x(9)*yy
21108 write (2,*) "x",(x(k),k=1,9)
21109 write (2,*) "xx",xx," yy",yy," zz",zz
21110 write (2,*) "de_xx ",de_xx," de_yy ",de_yy,&
21111 " de_zz ",de_zz," de_tt ",de_tt
21112 write (2,*) "de_xx_num",de_dxx_num," de_yy_num",de_dyy_num,&
21113 " de_zz_num",de_dzz_num," de_dt_num",de_dt_num
21116 cossc=scalar(dc_norm(1,i),dc_norm(1,i+nres))
21117 cossc1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
21118 cosfac2xx=cosfac2*xx
21119 sinfac2yy=sinfac2*yy
21121 dt_dCi(k) = -(dc_norm(k,i-1)+costtab(i+1)*dc_norm(k,i))*&
21123 dt_dCi1(k)= -(dc_norm(k,i)+costtab(i+1)*dc_norm(k,i-1))*&
21125 pom=(dC_norm(k,i+nres)-cossc*dC_norm(k,i))*vbld_inv(i+1)
21126 pom1=(dC_norm(k,i+nres)-cossc1*dC_norm(k,i-1))*vbld_inv(i)
21127 !c write (iout,*) "i",i," k",k," pom",pom," pom1",pom1,
21128 !c & " dt_dCi",dt_dCi(k)," dt_dCi1",dt_dCi1(k)
21129 !c write (iout,*) "dC_norm",(dC_norm(j,i),j=1,3),
21130 !c & (dC_norm(j,i-1),j=1,3)," vbld_inv",vbld_inv(i+1),vbld_inv(i)
21131 dXX_Ci(k)=pom*cosfac-dt_dCi(k)*cosfac2xx
21132 dXX_Ci1(k)=-pom1*cosfac-dt_dCi1(k)*cosfac2xx
21133 dYY_Ci(k)=pom*sinfac+dt_dCi(k)*sinfac2yy
21134 dYY_Ci1(k)=pom1*sinfac+dt_dCi1(k)*sinfac2yy
21138 dZZ_Ci(k)=dZZ_Ci(k)-uzgrad(j,k,2,i-1)*dC_norm(j,i+nres)
21139 dZZ_Ci1(k)=dZZ_Ci1(k)-uzgrad(j,k,1,i-1)*dC_norm(j,i+nres)
21142 dXX_XYZ(k)=vbld_inv(i+nres)*(x_prime(k)-xx*dC_norm(k,i+nres))
21143 dYY_XYZ(k)=vbld_inv(i+nres)*(y_prime(k)-yy*dC_norm(k,i+nres))
21144 dZZ_XYZ(k)=vbld_inv(i+nres)*(z_prime(k)-zz*dC_norm(k,i+nres))
21146 dt_dCi(k) = -dt_dCi(k)/sinttab(i+1)
21147 dt_dCi1(k)= -dt_dCi1(k)/sinttab(i+1)
21151 dXX_Ctab(k,i)=dXX_Ci(k)
21152 dXX_C1tab(k,i)=dXX_Ci1(k)
21153 dYY_Ctab(k,i)=dYY_Ci(k)
21154 dYY_C1tab(k,i)=dYY_Ci1(k)
21155 dZZ_Ctab(k,i)=dZZ_Ci(k)
21156 dZZ_C1tab(k,i)=dZZ_Ci1(k)
21157 dXX_XYZtab(k,i)=dXX_XYZ(k)
21158 dYY_XYZtab(k,i)=dYY_XYZ(k)
21159 dZZ_XYZtab(k,i)=dZZ_XYZ(k)
21162 !c write (iout,*) "k",k," dxx_ci1",dxx_ci1(k)," dyy_ci1",
21163 !c & dyy_ci1(k)," dzz_ci1",dzz_ci1(k)
21164 !c write (iout,*) "k",k," dxx_ci",dxx_ci(k)," dyy_ci",
21165 !c & dyy_ci(k)," dzz_ci",dzz_ci(k)
21166 !c write (iout,*) "k",k," dt_dci",dt_dci(k)," dt_dci",
21168 !c write (iout,*) "k",k," dxx_XYZ",dxx_XYZ(k)," dyy_XYZ",
21169 !c & dyy_XYZ(k)," dzz_XYZ",dzz_XYZ(k)
21170 gsbloc(k,i-1)=gsbloc(k,i-1)+(de_dxx*dxx_ci1(k) &
21171 +de_dyy*dyy_ci1(k)+de_dzz*dzz_ci1(k)+de_dt*dt_dCi1(k))
21172 gsbloc(k,i)=gsbloc(k,i)+(de_dxx*dxx_Ci(k) &
21173 +de_dyy*dyy_Ci(k)+de_dzz*dzz_Ci(k)+de_dt*dt_dCi(k))
21174 gsblocx(k,i)= de_dxx*dxx_XYZ(k)&
21175 +de_dyy*dyy_XYZ(k)+de_dzz*dzz_XYZ(k)
21176 ! print *,i,de_dxx*dxx_ci1(k)+de_dyy*dyy_ci1(k),de_dzz*dzz_ci1(k)*2
21178 !c write(iout,*) "ENERGY GRAD = ", (gsbloc(k,i-1),k=1,3),
21179 !c & (gsbloc(k,i),k=1,3),(gsblocx(k,i),k=1,3)
21181 !C to check gradient call subroutine check_grad
21187 !=-------------------------------------------------------
21188 real(kind=8) function enesc_nucl(x,xx,yy,zz,cost2,sint2)
21190 real(kind=8),dimension(9):: x(9)
21191 real(kind=8) :: xx,yy,zz,cost2,sint2,sumene1,sumene2, &
21192 sumene3,sumene4,sumene,dsc_i,dp2_i,dscp1,dscp2,s1,s1_6,s2,s2_6
21194 !c write (2,*) "enesc"
21195 !c write (2,*) "x",(x(i),i=1,9)
21196 !c write(2,*)"xx",xx," yy",yy," zz",zz," cost2",cost2," sint2",sint2
21197 sumene=x(1)*xx+x(2)*yy+x(3)*zz+x(4)*xx**2 &
21198 + x(5)*yy**2+x(6)*zz**2+x(7)*xx*zz+x(8)*xx*yy &
21202 end function enesc_nucl
21203 !-----------------------------------------------------------------------------
21204 subroutine multibody_hb_nucl(ecorr,ecorr3,n_corr,n_corr1)
21207 integer,parameter :: max_cont=2000
21208 integer,parameter:: max_dim=2*(8*3+6)
21209 integer, parameter :: msglen1=max_cont*max_dim
21210 integer,parameter :: msglen2=2*msglen1
21211 integer source,CorrelType,CorrelID,Error
21212 real(kind=8) :: buffer(max_cont,max_dim)
21213 integer status(MPI_STATUS_SIZE)
21214 integer :: ierror,nbytes
21216 real(kind=8),dimension(3):: gx(3),gx1(3)
21217 real(kind=8) :: time00
21219 integer i,j,i1,j1,jj,kk,num_conti,num_conti1,nn
21220 real(kind=8) ecorr,ecorr3
21221 integer :: n_corr,n_corr1,mm,msglen
21222 !C Set lprn=.true. for debugging
21227 if(.not.allocated(zapas2)) allocate(zapas2(3,maxconts,nres,8))
21229 if (nfgtasks.le.1) goto 30
21231 write (iout,'(a)') 'Contact function values:'
21233 write (iout,'(2i3,50(1x,i2,f5.2))') &
21234 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i), &
21235 j=1,num_cont_hb(i))
21238 !C Caution! Following code assumes that electrostatic interactions concerning
21239 !C a given atom are split among at most two processors!
21249 !c write (*,*) 'MyRank',MyRank,' mm',mm
21252 !c write (*,*) 'Sending: MyRank',MyRank,' mm',mm,' ldone',ldone
21253 if (fg_rank.gt.0) then
21254 !C Send correlation contributions to the preceding processor
21256 nn=num_cont_hb(iatel_s_nucl)
21257 call pack_buffer(max_cont,max_dim,iatel_s,0,buffer)
21258 !c write (*,*) 'The BUFFER array:'
21260 !c write (*,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,30)
21262 if (ielstart_nucl(iatel_s_nucl).gt.iatel_s_nucl+ispp) then
21264 call pack_buffer(max_cont,max_dim,iatel_s+1,30,buffer)
21265 !C Clear the contacts of the atom passed to the neighboring processor
21266 nn=num_cont_hb(iatel_s_nucl+1)
21268 !c write (*,'(i2,9(3f8.3,2x))') i,(buffer(i,j+30),j=1,30)
21270 num_cont_hb(iatel_s_nucl)=0
21272 !cd write (iout,*) 'Processor ',fg_rank,MyRank,
21273 !cd & ' is sending correlation contribution to processor',fg_rank-1,
21274 !cd & ' msglen=',msglen
21275 !c write (*,*) 'Processor ',fg_rank,MyRank,
21276 !c & ' is sending correlation contribution to processor',fg_rank-1,
21277 !c & ' msglen=',msglen,' CorrelType=',CorrelType
21279 call MPI_Send(buffer,msglen,MPI_DOUBLE_PRECISION,fg_rank-1, &
21280 CorrelType,FG_COMM,IERROR)
21281 time_sendrecv=time_sendrecv+MPI_Wtime()-time00
21282 !cd write (iout,*) 'Processor ',fg_rank,
21283 !cd & ' has sent correlation contribution to processor',fg_rank-1,
21284 !cd & ' msglen=',msglen,' CorrelID=',CorrelID
21285 !c write (*,*) 'Processor ',fg_rank,
21286 !c & ' has sent correlation contribution to processor',fg_rank-1,
21287 !c & ' msglen=',msglen,' CorrelID=',CorrelID
21289 endif ! (fg_rank.gt.0)
21293 !c write (*,*) 'Receiving: MyRank',MyRank,' mm',mm,' ldone',ldone
21294 if (fg_rank.lt.nfgtasks-1) then
21295 !C Receive correlation contributions from the next processor
21297 if (ielend_nucl(iatel_e_nucl).lt.nct_molec(2)-1) msglen=msglen2
21298 !cd write (iout,*) 'Processor',fg_rank,
21299 !cd & ' is receiving correlation contribution from processor',fg_rank+1,
21300 !cd & ' msglen=',msglen,' CorrelType=',CorrelType
21301 !c write (*,*) 'Processor',fg_rank,
21302 !c &' is receiving correlation contribution from processor',fg_rank+1,
21303 !c & ' msglen=',msglen,' CorrelType=',CorrelType
21306 do while (nbytes.le.0)
21307 call MPI_Probe(fg_rank+1,CorrelType,FG_COMM,status,IERROR)
21308 call MPI_Get_count(status,MPI_DOUBLE_PRECISION,nbytes,IERROR)
21310 !c print *,'Processor',myrank,' msglen',msglen,' nbytes',nbytes
21311 call MPI_Recv(buffer,nbytes,MPI_DOUBLE_PRECISION, &
21312 fg_rank+1,CorrelType,FG_COMM,status,IERROR)
21313 time_sendrecv=time_sendrecv+MPI_Wtime()-time00
21314 !c write (*,*) 'Processor',fg_rank,
21315 !c &' has received correlation contribution from processor',fg_rank+1,
21316 !c & ' msglen=',msglen,' nbytes=',nbytes
21317 !c write (*,*) 'The received BUFFER array:'
21319 !c write (*,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,60)
21321 if (msglen.eq.msglen1) then
21322 call unpack_buffer(max_cont,max_dim,iatel_e_nucl+1,0,buffer)
21323 else if (msglen.eq.msglen2) then
21324 call unpack_buffer(max_cont,max_dim,iatel_e_nucl,0,buffer)
21325 call unpack_buffer(max_cont,max_dim,iatel_e_nucl+1,30,buffer)
21328 'ERROR!!!! message length changed while processing correlations.'
21330 'ERROR!!!! message length changed while processing correlations.'
21331 call MPI_Abort(MPI_COMM_WORLD,Error,IERROR)
21332 endif ! msglen.eq.msglen1
21333 endif ! fg_rank.lt.nfgtasks-1
21340 write (iout,'(a)') 'Contact function values:'
21341 do i=nnt_molec(2),nct_molec(2)-1
21342 write (iout,'(2i3,50(1x,i2,f5.2))') &
21343 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i), &
21344 j=1,num_cont_hb(i))
21349 !C Remove the loop below after debugging !!!
21350 ! do i=nnt_molec(2),nct_molec(2)
21352 ! gradcorr_nucl(j,i)=0.0D0
21353 ! gradxorr_nucl(j,i)=0.0D0
21354 ! gradcorr3_nucl(j,i)=0.0D0
21355 ! gradxorr3_nucl(j,i)=0.0D0
21358 ! print *,"iatsc_s_nucl,iatsc_e_nucl",iatsc_s_nucl,iatsc_e_nucl
21359 !C Calculate the local-electrostatic correlation terms
21360 do i=iatsc_s_nucl,iatsc_e_nucl
21362 num_conti=num_cont_hb(i)
21363 num_conti1=num_cont_hb(i+1)
21364 ! print *,i,num_conti,num_conti1
21369 !c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
21370 !c & ' jj=',jj,' kk=',kk
21371 if (j1.eq.j+1 .or. j1.eq.j-1) then
21373 !C Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
21374 !C The system gains extra energy.
21375 !C Tentative expression & coefficients; assumed d(stacking)=4.5 A,
21376 !C parallel dipoles of stacknig bases and sin(mui)sin(muj)/eps/d^3=0.7
21377 !C Need to implement full formulas 34 and 35 from Liwo et al., 1998.
21379 ecorr=ecorr+ehbcorr_nucl(i,j,i+1,j1,jj,kk,0.528D0,0.132D0)
21380 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
21381 'ecorrh',i,j,ehbcorr_nucl(i,j,i+1,j1,jj,kk,0.528D0,0.132D0)
21383 else if (j1.eq.j) then
21385 !C Contacts I-J and I-(J+1) occur simultaneously.
21386 !C The system loses extra energy.
21387 !C Tentative expression & c?oefficients; assumed d(stacking)=4.5 A,
21388 !C parallel dipoles of stacknig bases and sin(mui)sin(muj)/eps/d^3=0.7
21389 !C Need to implement full formulas 32 from Liwo et al., 1998.
21391 !c write (iout,*) 'ecorr3: i=',i,' j=',j,' i1=',i1,' j1=',j1,
21392 !c & ' jj=',jj,' kk=',kk
21393 ecorr3=ecorr3+ehbcorr3_nucl(i,j,i+1,j,jj,kk,0.310D0,-0.155D0)
21398 !c write (iout,*) 'ecorr3: i=',i,' j=',j,' i1=',i1,' j1=',j1,
21399 !c & ' jj=',jj,' kk=',kk
21400 if (j1.eq.j+1) then
21401 !C Contacts I-J and (I+1)-J occur simultaneously.
21402 !C The system loses extra energy.
21403 ecorr3=ecorr3+ehbcorr3_nucl(i,j,i,j+1,jj,kk,0.310D0,-0.155D0)
21409 end subroutine multibody_hb_nucl
21410 !-----------------------------------------------------------
21411 real(kind=8) function ehbcorr_nucl(i,j,k,l,jj,kk,coeffp,coeffm)
21412 ! implicit real*8 (a-h,o-z)
21413 ! include 'DIMENSIONS'
21414 ! include 'COMMON.IOUNITS'
21415 ! include 'COMMON.DERIV'
21416 ! include 'COMMON.INTERACT'
21417 ! include 'COMMON.CONTACTS'
21418 real(kind=8),dimension(3) :: gx,gx1
21420 !el local variables
21421 integer :: i,j,k,l,jj,kk,ll,ilist,m, iresshield
21422 real(kind=8) :: coeffp,coeffm,eij,ekl,ees0pij,ees0pkl,ees0mij,&
21423 ees0mkl,ees,coeffpees0pij,coeffmees0mij,&
21424 coeffpees0pkl,coeffmees0mkl,gradlongij,gradlongkl, &
21428 eij=facont_hb(jj,i)
21429 ekl=facont_hb(kk,k)
21430 ees0pij=ees0p(jj,i)
21431 ees0pkl=ees0p(kk,k)
21432 ees0mij=ees0m(jj,i)
21433 ees0mkl=ees0m(kk,k)
21435 ees=-(coeffp*ees0pij*ees0pkl+coeffm*ees0mij*ees0mkl)
21436 ! print *,"ehbcorr_nucl",ekont,ees
21437 !cd ees=-(coeffp*ees0pkl+coeffm*ees0mkl)
21438 !C Following 4 lines for diagnostics.
21443 !cd write (iout,*)'Contacts have occurred for nucleic bases',
21444 !cd & i,j,' fcont:',eij,' eij',' eesij',ees0pij,ees0mij,' and ',k,l
21445 !cd & ,' fcont ',ekl,' eeskl',ees0pkl,ees0mkl,' ees=',ees
21446 !C Calculate the multi-body contribution to energy.
21447 ! ecorr_nucl=ecorr_nucl+ekont*ees
21448 !C Calculate multi-body contributions to the gradient.
21449 coeffpees0pij=coeffp*ees0pij
21450 coeffmees0mij=coeffm*ees0mij
21451 coeffpees0pkl=coeffp*ees0pkl
21452 coeffmees0mkl=coeffm*ees0mkl
21454 gradxorr_nucl(ll,i)=gradxorr_nucl(ll,i) &
21455 -ekont*(coeffpees0pkl*gacontp_hb1(ll,jj,i)+&
21456 coeffmees0mkl*gacontm_hb1(ll,jj,i))
21457 gradxorr_nucl(ll,j)=gradxorr_nucl(ll,j) &
21458 -ekont*(coeffpees0pkl*gacontp_hb2(ll,jj,i)+&
21459 coeffmees0mkl*gacontm_hb2(ll,jj,i))
21460 gradxorr_nucl(ll,k)=gradxorr_nucl(ll,k) &
21461 -ekont*(coeffpees0pij*gacontp_hb1(ll,kk,k)+&
21462 coeffmees0mij*gacontm_hb1(ll,kk,k))
21463 gradxorr_nucl(ll,l)=gradxorr_nucl(ll,l) &
21464 -ekont*(coeffpees0pij*gacontp_hb2(ll,kk,k)+ &
21465 coeffmees0mij*gacontm_hb2(ll,kk,k))
21466 gradlongij=ees*ekl*gacont_hbr(ll,jj,i)- &
21467 ekont*(coeffpees0pkl*gacontp_hb3(ll,jj,i)+ &
21468 coeffmees0mkl*gacontm_hb3(ll,jj,i))
21469 gradcorr_nucl(ll,j)=gradcorr_nucl(ll,j)+gradlongij
21470 gradcorr_nucl(ll,i)=gradcorr_nucl(ll,i)-gradlongij
21471 gradlongkl=ees*eij*gacont_hbr(ll,kk,k)- &
21472 ekont*(coeffpees0pij*gacontp_hb3(ll,kk,k)+ &
21473 coeffmees0mij*gacontm_hb3(ll,kk,k))
21474 gradcorr_nucl(ll,l)=gradcorr_nucl(ll,l)+gradlongkl
21475 gradcorr_nucl(ll,k)=gradcorr_nucl(ll,k)-gradlongkl
21476 gradxorr_nucl(ll,i)=gradxorr_nucl(ll,i)-gradlongij
21477 gradxorr_nucl(ll,j)=gradxorr_nucl(ll,j)+gradlongij
21478 gradxorr_nucl(ll,k)=gradxorr_nucl(ll,k)-gradlongkl
21479 gradxorr_nucl(ll,l)=gradxorr_nucl(ll,l)+gradlongkl
21481 ehbcorr_nucl=ekont*ees
21483 end function ehbcorr_nucl
21484 !-------------------------------------------------------------------------
21486 real(kind=8) function ehbcorr3_nucl(i,j,k,l,jj,kk,coeffp,coeffm)
21487 ! implicit real*8 (a-h,o-z)
21488 ! include 'DIMENSIONS'
21489 ! include 'COMMON.IOUNITS'
21490 ! include 'COMMON.DERIV'
21491 ! include 'COMMON.INTERACT'
21492 ! include 'COMMON.CONTACTS'
21493 real(kind=8),dimension(3) :: gx,gx1
21495 !el local variables
21496 integer :: i,j,k,l,jj,kk,ll,ilist,m, iresshield
21497 real(kind=8) :: coeffp,coeffm,eij,ekl,ees0pij,ees0pkl,ees0mij,&
21498 ees0mkl,ees,coeffpees0pij,coeffmees0mij,&
21499 coeffpees0pkl,coeffmees0mkl,gradlongij,gradlongkl, &
21503 eij=facont_hb(jj,i)
21504 ekl=facont_hb(kk,k)
21505 ees0pij=ees0p(jj,i)
21506 ees0pkl=ees0p(kk,k)
21507 ees0mij=ees0m(jj,i)
21508 ees0mkl=ees0m(kk,k)
21510 ees=-(coeffp*ees0pij*ees0pkl+coeffm*ees0mij*ees0mkl)
21511 !cd ees=-(coeffp*ees0pkl+coeffm*ees0mkl)
21512 !C Following 4 lines for diagnostics.
21517 !cd write (iout,*)'Contacts have occurred for nucleic bases',
21518 !cd & i,j,' fcont:',eij,' eij',' eesij',ees0pij,ees0mij,' and ',k,l
21519 !cd & ,' fcont ',ekl,' eeskl',ees0pkl,ees0mkl,' ees=',ees
21520 !C Calculate the multi-body contribution to energy.
21521 ! ecorr=ecorr+ekont*ees
21522 !C Calculate multi-body contributions to the gradient.
21523 coeffpees0pij=coeffp*ees0pij
21524 coeffmees0mij=coeffm*ees0mij
21525 coeffpees0pkl=coeffp*ees0pkl
21526 coeffmees0mkl=coeffm*ees0mkl
21528 gradxorr3_nucl(ll,i)=gradxorr3_nucl(ll,i) &
21529 -ekont*(coeffpees0pkl*gacontp_hb1(ll,jj,i)+&
21530 coeffmees0mkl*gacontm_hb1(ll,jj,i))
21531 gradxorr3_nucl(ll,j)=gradxorr3_nucl(ll,j) &
21532 -ekont*(coeffpees0pkl*gacontp_hb2(ll,jj,i)+ &
21533 coeffmees0mkl*gacontm_hb2(ll,jj,i))
21534 gradxorr3_nucl(ll,k)=gradxorr3_nucl(ll,k) &
21535 -ekont*(coeffpees0pij*gacontp_hb1(ll,kk,k)+ &
21536 coeffmees0mij*gacontm_hb1(ll,kk,k))
21537 gradxorr3_nucl(ll,l)=gradxorr3_nucl(ll,l) &
21538 -ekont*(coeffpees0pij*gacontp_hb2(ll,kk,k)+ &
21539 coeffmees0mij*gacontm_hb2(ll,kk,k))
21540 gradlongij=ees*ekl*gacont_hbr(ll,jj,i)- &
21541 ekont*(coeffpees0pkl*gacontp_hb3(ll,jj,i)+ &
21542 coeffmees0mkl*gacontm_hb3(ll,jj,i))
21543 gradcorr3_nucl(ll,j)=gradcorr3_nucl(ll,j)+gradlongij
21544 gradcorr3_nucl(ll,i)=gradcorr3_nucl(ll,i)-gradlongij
21545 gradlongkl=ees*eij*gacont_hbr(ll,kk,k)- &
21546 ekont*(coeffpees0pij*gacontp_hb3(ll,kk,k)+ &
21547 coeffmees0mij*gacontm_hb3(ll,kk,k))
21548 gradcorr3_nucl(ll,l)=gradcorr3_nucl(ll,l)+gradlongkl
21549 gradcorr3_nucl(ll,k)=gradcorr3_nucl(ll,k)-gradlongkl
21550 gradxorr3_nucl(ll,i)=gradxorr3_nucl(ll,i)-gradlongij
21551 gradxorr3_nucl(ll,j)=gradxorr3_nucl(ll,j)+gradlongij
21552 gradxorr3_nucl(ll,k)=gradxorr3_nucl(ll,k)-gradlongkl
21553 gradxorr3_nucl(ll,l)=gradxorr3_nucl(ll,l)+gradlongkl
21555 ehbcorr3_nucl=ekont*ees
21557 end function ehbcorr3_nucl
21559 subroutine pack_buffer(dimen1,dimen2,atom,indx,buffer)
21560 integer dimen1,dimen2,atom,indx,numcont,i,ii,k,j,num_kont,num_kont_old
21561 real(kind=8):: buffer(dimen1,dimen2)
21562 num_kont=num_cont_hb(atom)
21566 buffer(i,indx+(k-1)*3+j)=zapas2(j,i,atom,k)
21569 buffer(i,indx+25)=facont_hb(i,atom)
21570 buffer(i,indx+26)=ees0p(i,atom)
21571 buffer(i,indx+27)=ees0m(i,atom)
21572 buffer(i,indx+28)=d_cont(i,atom)
21573 buffer(i,indx+29)=dfloat(jcont_hb(i,atom))
21575 buffer(1,indx+30)=dfloat(num_kont)
21577 end subroutine pack_buffer
21578 !c------------------------------------------------------------------------------
21579 subroutine unpack_buffer(dimen1,dimen2,atom,indx,buffer)
21580 integer dimen1,dimen2,atom,indx,numcont,i,ii,k,j,num_kont,num_kont_old
21581 real(kind=8):: buffer(dimen1,dimen2)
21582 ! double precision zapas
21583 ! common /contacts_hb/ zapas(3,maxconts,maxres,8),
21584 ! & facont_hb(maxconts,maxres),ees0p(maxconts,maxres),
21585 ! & ees0m(maxconts,maxres),d_cont(maxconts,maxres),
21586 ! & num_cont_hb(maxres),jcont_hb(maxconts,maxres)
21587 num_kont=buffer(1,indx+30)
21588 num_kont_old=num_cont_hb(atom)
21589 num_cont_hb(atom)=num_kont+num_kont_old
21594 zapas2(j,ii,atom,k)=buffer(i,indx+(k-1)*3+j)
21597 facont_hb(ii,atom)=buffer(i,indx+25)
21598 ees0p(ii,atom)=buffer(i,indx+26)
21599 ees0m(ii,atom)=buffer(i,indx+27)
21600 d_cont(i,atom)=buffer(i,indx+28)
21601 jcont_hb(ii,atom)=buffer(i,indx+29)
21604 end subroutine unpack_buffer
21605 !c------------------------------------------------------------------------------
21608 !----------------------------------------------------------------------------
21609 !-----------------------------------------------------------------------------
21610 !-----------------------------------------------------------------------------