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,gUb2 !(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(4) :: gmuij,gmuij1,gmuij2,gmuji1,gmuji2
91 real(kind=8),dimension(:),allocatable :: costab,sintab,&
92 costab2,sintab2 !(maxres)
93 ! This common block contains dipole-interaction matrices and their
94 ! Cartesian derivatives.
96 real(kind=8),dimension(:,:,:,:),allocatable :: a_chuj !(2,2,maxconts,maxres)
97 real(kind=8),dimension(:,:,:,:,:,:),allocatable :: a_chuj_der !(2,2,3,5,maxconts,maxres)
99 real(kind=8),dimension(2,2,2) :: AEA,AEAderg,EAEA,AECA,&
100 AECAderg,ADtEA,ADtEA1,AEAb1,AEAb1derg,AEAb2
101 real(kind=8),dimension(2,2,2,2) :: EAEAderg,ADtEAderg,&
103 real(kind=8),dimension(2,2,3,5,2,2) :: AEAderx,EAEAderx,&
104 AECAderx,ADtEAderx,ADtEA1derx
105 real(kind=8),dimension(2,3,5,2,2,2) :: AEAb1derx,AEAb2derx
106 real(kind=8),dimension(3,2) :: g_contij
107 real(kind=8) :: ekont
108 ! 12/13/2008 (again Poland-Jaruzel war anniversary)
109 ! RE: Parallelization of 4th and higher order loc-el correlations
110 ! common /contdistrib/
111 integer,dimension(:),allocatable :: ncont_sent,ncont_recv !(maxres)
112 ! ncont_sent,ncont_recv są w multibody_ello i multibody_hb
113 !-----------------------------------------------------------------------------
116 ! real(kind=8),dimension(:,:),allocatable :: dcdv,dxdv !(6,maxdim)
117 ! real(kind=8),dimension(:,:),allocatable :: dxds !(6,maxres)
118 ! real(kind=8),dimension(:,:,:),allocatable :: gradx,gradc !(3,maxres,2)
119 real(kind=8),dimension(:,:),allocatable :: gvdwc,gelc,gelc_long,&
120 gvdwpp,gvdwc_scpp,gradx_scp,gvdwc_scp,ghpbx,ghpbc,&
121 gradcorr,gradcorr_long,gradcorr5_long,gradcorr6_long,&
122 gcorr6_turn_long,gradxorr,gradcorr5,gradcorr6,gliptran,gliptranc,&
124 gshieldx,gshieldc,gshieldc_loc,gshieldx_ec,&
125 gshieldc_ec,gshieldc_loc_ec,gshieldx_t3, &
126 gshieldc_t3,gshieldc_loc_t3,gshieldx_t4,gshieldc_t4, &
127 gshieldc_loc_t4,gshieldx_ll,gshieldc_ll,gshieldc_loc_ll,&
128 grad_shield,gg_tube,gg_tube_sc,gradafm !(3,maxres)
129 !-----------------------------NUCLEIC GRADIENT
130 real(kind=8),dimension(:,:),allocatable ::gradb_nucl,gradbx_nucl, &
131 gvdwpsb1,gelpp,gvdwpsb,gelsbc,gelsbx,gvdwsbx,gvdwsbc,gsbloc,&
132 gsblocx,gradcorr_nucl,gradxorr_nucl,gradcorr3_nucl,gradxorr3_nucl,&
134 !-----------------------------NUCLEIC-PROTEIN GRADIENT
135 real(kind=8),dimension(:,:),allocatable :: gvdwx_scbase,gvdwc_scbase,&
136 gvdwx_pepbase,gvdwc_pepbase,gvdwx_scpho,gvdwc_scpho,&
138 !------------------------------IONS GRADIENT
139 real(kind=8),dimension(:,:),allocatable :: gradcatcat, &
140 gradpepcat,gradpepcatx,gradnuclcat,gradnuclcatx
141 ! real(kind=8),dimension(:,:),allocatable :: gloc,gloc_x !(maxvar,2)
144 real(kind=8),dimension(:,:),allocatable :: gel_loc,gel_loc_long,&
145 gcorr3_turn,gcorr4_turn,gcorr6_turn,gradb,gradbx !(3,maxres)
146 real(kind=8),dimension(:),allocatable :: gel_loc_loc,&
147 gel_loc_turn3,gel_loc_turn4,gel_loc_turn6,gcorr_loc,g_corr5_loc,&
148 g_corr6_loc !(maxvar)
149 real(kind=8),dimension(:,:),allocatable :: gsccorc,gsccorx !(3,maxres)
150 real(kind=8),dimension(:),allocatable :: gsccor_loc !(maxres)
151 ! real(kind=8),dimension(:,:,:),allocatable :: dtheta !(3,2,maxres)
152 real(kind=8),dimension(:,:),allocatable :: gscloc,gsclocx !(3,maxres)
153 ! real(kind=8),dimension(:,:,:),allocatable :: dphi,dalpha,domega !(3,3,maxres)
154 real(kind=8),dimension(:,:,:),allocatable :: grad_shield_side, &
155 grad_shield_loc ! (3,maxcontsshileding,maxnres)
158 real(kind=8), dimension(:),allocatable :: fac_shield
159 real(kind=8),dimension(3,5,2) :: derx,derx_turn
160 ! common /deriv_scloc/
161 real(kind=8),dimension(:,:),allocatable :: dXX_C1tab,dYY_C1tab,&
162 dZZ_C1tab,dXX_Ctab,dYY_Ctab,dZZ_Ctab,dXX_XYZtab,dYY_XYZtab,&
163 dZZ_XYZtab !(3,maxres)
164 !-----------------------------------------------------------------------------
167 real(kind=8) :: gvdwc_max,gvdwc_scp_max,gelc_max,gvdwpp_max,&
168 gradb_max,ghpbc_max,&
169 gradcorr_max,gel_loc_max,gcorr3_turn_max,gcorr4_turn_max,&
170 gradcorr5_max,gradcorr6_max,gcorr6_turn_max,gsccorc_max,&
171 gscloc_max,gvdwx_max,gradx_scp_max,ghpbx_max,gradxorr_max,&
172 gsccorx_max,gsclocx_max
173 !-----------------------------------------------------------------------------
175 ! common /back_constr/
176 real(kind=8),dimension(:),allocatable :: dutheta,dugamma !(maxres)
177 real(kind=8),dimension(:,:),allocatable :: duscdiff,duscdiffx !(3,maxres)
179 real(kind=8) :: Ucdfrag,Ucdpair
180 real(kind=8),dimension(:,:),allocatable :: dUdconst,dUdxconst,&
181 dqwol,dxqwol !(3,0:MAXRES)
182 !-----------------------------------------------------------------------------
184 ! common /dyn_ssbond/
185 real(kind=8),dimension(:,:),allocatable :: dyn_ssbond_ij !(maxres,maxres)
186 !-----------------------------------------------------------------------------
188 ! Parameters of the SCCOR term
190 real(kind=8),dimension(:,:,:,:),allocatable :: dcostau,dsintau,&
191 dcosomicron,domicron !(3,3,3,maxres2)
192 !-----------------------------------------------------------------------------
195 real(kind=8),dimension(:,:),allocatable :: uy,uz !(3,maxres)
196 real(kind=8),dimension(:,:,:,:),allocatable :: uygrad,uzgrad !(3,3,2,maxres)
197 !-----------------------------------------------------------------------------
198 ! common /przechowalnia/
199 real(kind=8),dimension(:,:,:),allocatable :: zapas
200 real(kind=8),dimension(:,:,:,:),allocatable ::zapas2 !(max_dim,maxconts,max_fg_procs)
201 real(kind=8),dimension(:,:,:),allocatable :: fromto !(3,3,maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
202 !-----------------------------------------------------------------------------
203 !-----------------------------------------------------------------------------
206 !-----------------------------------------------------------------------------
208 !-----------------------------------------------------------------------------
209 ! energy_p_new_barrier.F
210 !-----------------------------------------------------------------------------
211 subroutine etotal(energia)
212 ! implicit real*8 (a-h,o-z)
213 ! include 'DIMENSIONS'
218 !MS$ATTRIBUTES C :: proc_proc
224 ! include 'COMMON.SETUP'
225 ! include 'COMMON.IOUNITS'
226 real(kind=8),dimension(0:n_ene) :: energia
227 ! include 'COMMON.LOCAL'
228 ! include 'COMMON.FFIELD'
229 ! include 'COMMON.DERIV'
230 ! include 'COMMON.INTERACT'
231 ! include 'COMMON.SBRIDGE'
232 ! include 'COMMON.CHAIN'
233 ! include 'COMMON.VAR'
234 ! include 'COMMON.MD'
235 ! include 'COMMON.CONTROL'
236 ! include 'COMMON.TIME1'
237 real(kind=8) :: time00
239 integer :: n_corr,n_corr1,ierror,imatupdate
240 real(kind=8) :: etors,edihcnstr,etors_d,esccor,ehpb
241 real(kind=8) :: evdw,evdw1,evdw2,evdw2_14,escloc,ees,eel_loc
242 real(kind=8) :: eello_turn3,eello_turn4,estr,ebe,eliptran,etube, &
243 Eafmforce,ethetacnstr
244 real(kind=8) :: ecorr,ecorr5,ecorr6,eturn6,ehomology_constr
245 ! now energies for nulceic alone parameters
246 real(kind=8) :: evdwpp,eespp,evdwpsb,eelpsb,evdwsb,eelsb,estr_nucl,&
247 ebe_nucl,esbloc,etors_nucl,etors_d_nucl,ecorr_nucl,&
250 real(kind=8) :: ecation_prot,ecationcation,ecations_prot_amber,&
252 ! energies for protein nucleic acid interaction
253 real(kind=8) :: escbase,epepbase,escpho,epeppho
256 real(kind=8) :: weights_(n_ene) !,time_Bcast,time_Bcastw
257 ! shielding effect varibles for MPI
258 real(kind=8) :: fac_shieldbuf(nres), &
259 grad_shield_locbuf1(3*maxcontsshi*nres), &
260 grad_shield_sidebuf1(3*maxcontsshi*nres), &
261 grad_shield_locbuf2(3*maxcontsshi*nres), &
262 grad_shield_sidebuf2(3*maxcontsshi*nres), &
263 grad_shieldbuf1(3*nres), &
264 grad_shieldbuf2(3*nres)
266 integer ishield_listbuf(-1:nres), &
267 shield_listbuf(maxcontsshi,-1:nres),k,j,i,iii,impishi,mojint,jjj
268 ! print *,"I START ENERGY"
270 ! if (mod(itime_mat,imatupdate).eq.0) call make_SCSC_inter_list
271 ! real(kind=8), dimension(:),allocatable:: fac_shieldbuf
272 ! real(kind=8), dimension(:,:,:),allocatable:: &
273 ! grad_shield_locbuf,grad_shield_sidebuf
274 ! real(kind=8), dimension(:,:),allocatable:: &
276 ! integer, dimension(:),allocatable:: &
278 ! integer, dimension(:,:),allocatable:: shield_listbuf
280 ! if (.not.allocated(fac_shieldbuf)) then
281 ! allocate(fac_shieldbuf(nres))
282 ! allocate(grad_shield_locbuf(3,maxcontsshi,-1:nres))
283 ! allocate(grad_shield_sidebuf(3,maxcontsshi,-1:nres))
284 ! allocate(grad_shieldbuf(3,-1:nres))
285 ! allocate(ishield_listbuf(nres))
286 ! allocate(shield_listbuf(maxcontsshi,nres))
288 ! print *,"wstrain check", wstrain
289 ! print*,"ETOTAL Processor",fg_rank," absolute rank",myrank,
290 ! & " nfgtasks",nfgtasks
291 if (nfgtasks.gt.1) then
293 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
294 if (fg_rank.eq.0) then
295 call MPI_Bcast(0,1,MPI_INTEGER,king,FG_COMM,IERROR)
296 ! print *,"Processor",myrank," BROADCAST iorder"
297 ! FG master sets up the WEIGHTS_ array which will be broadcast to the
298 ! FG slaves as WEIGHTS array.
318 weights_(26)=wvdwpp_nucl
324 weights_(32)=wbond_nucl
325 weights_(33)=wang_nucl
327 weights_(35)=wtor_nucl
328 weights_(36)=wtor_d_nucl
329 weights_(37)=wcorr_nucl
330 weights_(38)=wcorr3_nucl
332 weights_(42)=wcatprot
334 weights_(47)=wpepbase
337 weights_(50)=wcatnucl
338 ! wcatcat= weights(41)
339 ! wcatprot=weights(42)
341 ! FG Master broadcasts the WEIGHTS_ array
342 call MPI_Bcast(weights_(1),n_ene,&
343 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
345 ! FG slaves receive the WEIGHTS array
346 call MPI_Bcast(weights(1),n_ene,&
347 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
367 wvdwpp_nucl =weights(26)
373 wbond_nucl =weights(32)
374 wang_nucl =weights(33)
376 wtor_nucl =weights(35)
377 wtor_d_nucl =weights(36)
378 wcorr_nucl =weights(37)
379 wcorr3_nucl =weights(38)
387 ! welpsb=weights(28)*fact(1)
389 ! wcorr_nucl= weights(37)*fact(1)
390 ! wcorr3_nucl=weights(38)*fact(2)
391 ! wtor_nucl= weights(35)*fact(1)
392 ! wtor_d_nucl=weights(36)*fact(2)
395 time_Bcast=time_Bcast+MPI_Wtime()-time00
396 time_Bcastw=time_Bcastw+MPI_Wtime()-time00
397 ! call chainbuild_cart
399 ! print *,"itime_mat",itime_mat,imatupdate
400 if (nfgtasks.gt.1) then
401 call MPI_Bcast(itime_mat,1,MPI_INT,king,FG_COMM,IERROR)
403 if (mod(itime_mat,imatupdate).eq.0) call make_SCp_inter_list
404 ! write (iout,*) "after make_SCp_inter_list"
405 if (mod(itime_mat,imatupdate).eq.0) call make_SCSC_inter_list
406 ! write (iout,*) "after make_SCSC_inter_list"
408 if (mod(itime_mat,imatupdate).eq.0) call make_pp_inter_list
409 ! write (iout,*) "after make_pp_inter_list"
411 ! print *,'Processor',myrank,' calling etotal ipot=',ipot
412 ! print *,'Processor',myrank,' nnt=',nnt,' nct=',nct
414 ! if (modecalc.eq.12.or.modecalc.eq.14) then
415 ! call int_from_cart1(.false.)
422 ! Compute the side-chain and electrostatic interaction energy
423 ! print *, "Before EVDW"
424 ! goto (101,102,103,104,105,106) ipot
426 ! Lennard-Jones potential.
430 !d print '(a)','Exit ELJcall el'
432 ! Lennard-Jones-Kihara potential (shifted).
433 ! 102 call eljk(evdw)
437 ! Berne-Pechukas potential (dilated LJ, angular dependence).
442 ! Gay-Berne potential (shifted LJ, angular dependence).
445 ! print *,"MOMO",scelemode
446 if (scelemode.eq.0) then
452 ! Gay-Berne-Vorobjev potential (shifted LJ, angular dependence).
453 ! 105 call egbv(evdw)
457 ! Soft-sphere potential
458 ! 106 call e_softsphere(evdw)
460 call e_softsphere(evdw)
462 ! Calculate electrostatic (H-bonding) energy of the main chain.
466 write(iout,*)"Wrong ipot"
471 ! print *,"after EGB"
473 if (shield_mode.eq.2) then
476 if (nfgtasks.gt.1) then
477 grad_shield_sidebuf1(:)=0.0d0
478 grad_shield_locbuf1(:)=0.0d0
479 grad_shield_sidebuf2(:)=0.0d0
480 grad_shield_locbuf2(:)=0.0d0
481 grad_shieldbuf1(:)=0.0d0
482 grad_shieldbuf2(:)=0.0d0
485 write(iout,*) "befor reduce fac_shield reduce"
487 write(2,*) "fac",itype(i,1),fac_shield(i),grad_shield(1,i)
488 write(2,*) "list", shield_list(1,i),ishield_list(i), &
489 grad_shield_side(1,1,i),grad_shield_loc(1,1,i)
498 grad_shieldbuf1(iii)=grad_shield(k,i)
505 grad_shield_sidebuf1(jjj)=grad_shield_side(k,j,i)
506 grad_shield_locbuf1(jjj)=grad_shield_loc(k,j,i)
510 call MPI_Allgatherv(fac_shield(ivec_start), &
511 ivec_count(fg_rank1), &
512 MPI_DOUBLE_PRECISION,fac_shieldbuf(1),ivec_count(0), &
514 MPI_DOUBLE_PRECISION,FG_COMM,IERROR)
515 call MPI_Allgatherv(shield_list(1,ivec_start), &
516 ivec_count(fg_rank1), &
517 MPI_I50,shield_listbuf(1,1),ivec_count(0), &
519 MPI_I50,FG_COMM,IERROR)
520 ! write(2,*) "After I50"
522 call MPI_Allgatherv(ishield_list(ivec_start), &
523 ivec_count(fg_rank1), &
524 MPI_INTEGER,ishield_listbuf(1),ivec_count(0), &
526 MPI_INTEGER,FG_COMM,IERROR)
527 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
529 ! write(2,*) ivec_count(fg_rank1)*3,ivec_count(0)*3,ivec_displ(0)*3,3*ivec_start-2
530 ! write (2,*) "before"
531 ! write(2,*) grad_shieldbuf1
532 ! call MPI_Allgatherv(grad_shieldbuf1(3*ivec_start-2), &
533 ! ivec_count(fg_rank1)*3, &
534 ! MPI_DOUBLE_PRECISION,grad_shieldbuf2(1),ivec_count(0), &
536 ! MPI_DOUBLE_PRECISION,FG_COMM,IERROR)
537 call MPI_Allreduce(grad_shieldbuf1(1),grad_shieldbuf2(1), &
539 MPI_DOUBLE_PRECISION, &
542 call MPI_Allreduce(grad_shield_sidebuf1(1),grad_shield_sidebuf2(1), &
543 nres*3*maxcontsshi, &
544 MPI_DOUBLE_PRECISION, &
548 call MPI_Allreduce(grad_shield_locbuf1(1),grad_shield_locbuf2(1), &
549 nres*3*maxcontsshi, &
550 MPI_DOUBLE_PRECISION, &
555 ! write(2,*) grad_shieldbuf2
557 ! call MPI_Allgatherv(grad_shield_sidebuf1(3*maxcontsshi*ivec_start-2), &
558 ! ivec_count(fg_rank1)*3*maxcontsshi, &
559 ! MPI_DOUBLE_PRECISION,grad_shield_sidebuf2(1),ivec_count(0)*3*maxcontsshi,&
560 ! ivec_displ(0)*3*maxcontsshi, &
561 ! MPI_DOUBLE_PRECISION,FG_COMM,IERROR)
562 ! write(2,*) "After grad_shield_side"
564 ! call MPI_Allgatherv(grad_shield_locbuf1(3*maxcontsshi*ivec_start-2), &
565 ! ivec_count(fg_rank1)*3*maxcontsshi, &
566 ! MPI_DOUBLE_PRECISION,grad_shield_locbuf2(1),ivec_count(0)*3*maxcontsshi, &
567 ! ivec_displ(0)*3*maxcontsshi, &
568 ! MPI_DOUBLE_PRECISION,FG_COMM,IERROR)
569 ! write(2,*) "After MPI_SHI"
574 fac_shield(i)=fac_shieldbuf(i)
575 ishield_list(i)=ishield_listbuf(i)
576 ! write(iout,*) i,fac_shield(i)
579 grad_shield(j,i)=grad_shieldbuf2(iii)
581 do j=1,ishield_list(i)
582 ! write (iout,*) "ishild", ishield_list(i),i
583 shield_list(j,i)=shield_listbuf(j,i)
588 grad_shield_loc(k,j,i)=grad_shield_locbuf2(jjj)
589 grad_shield_side(k,j,i)=grad_shield_sidebuf2(jjj)
595 write(iout,*) "after reduce fac_shield reduce"
597 write(2,*) "fac",itype(i,1),fac_shield(i),grad_shield(1,i)
598 write(2,*) "list", shield_list(1,i),ishield_list(i), &
599 grad_shield_side(1,1,i),grad_shield_loc(1,1,i)
607 ! print *,"AFTER EGB",ipot,evdw
609 !mc Sep-06: egb takes care of dynamic ss bonds too
611 ! if (dyn_ss) call dyn_set_nss
612 ! print *,"Processor",myrank," computed USCSC"
618 time_vec=time_vec+MPI_Wtime()-time01
624 ! print *,"Processor",myrank," left VEC_AND_DERIV"
627 ! print *,"after ipot if", ipot
628 if (welec.gt.0d0.or.wvdwpp.gt.0d0.or.wel_loc.gt.0d0.or. &
629 wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0 &
630 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
631 .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
633 if (welec.gt.0d0.or.wel_loc.gt.0d0.or. &
634 wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0 &
635 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
636 .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
638 ! print *,"just befor eelec call"
639 call eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
640 ! print *, "ELEC calc"
649 ! write (iout,*) "Soft-spheer ELEC potential"
650 call eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,&
653 ! print *,"Processor",myrank," computed UELEC"
655 ! Calculate excluded-volume interaction energy between peptide groups
658 ! write(iout,*) "in etotal calc exc;luded",ipot
662 call escp(evdw2,evdw2_14)
668 ! write (iout,*) "Soft-sphere SCP potential"
669 call escp_soft_sphere(evdw2,evdw2_14)
671 ! write(iout,*) "in etotal before ebond",ipot
674 ! Calculate the bond-stretching energy
677 ! print *,"EBOND",estr
678 ! write(iout,*) "in etotal afer ebond",ipot
681 ! Calculate the disulfide-bridge and other energy and the contributions
682 ! from other distance constraints.
683 ! print *,'Calling EHPB'
685 !elwrite(iout,*) "in etotal afer edis",ipot
686 ! print *,'EHPB exitted succesfully.'
688 ! Calculate the virtual-bond-angle energy.
689 ! write(iout,*) "in etotal afer edis",ipot
691 ! if (wang.gt.0.0d0) then
692 ! call ebend(ebe,ethetacnstr)
697 if (wang.gt.0d0) then
698 if (tor_mode.eq.0) then
701 !C ebend kcc is Kubo cumulant clustered rigorous attemp to derive the
709 if (with_theta_constr) call etheta_constr(ethetacnstr)
711 ! write(iout,*) "in etotal afer ebe",ipot
713 ! print *,"Processor",myrank," computed UB"
715 ! Calculate the SC local energy.
718 !elwrite(iout,*) "in etotal afer esc",ipot
719 ! print *,"Processor",myrank," computed USC"
721 ! Calculate the virtual-bond torsional energy.
723 !d print *,'nterm=',nterm
724 ! if (wtor.gt.0) then
725 ! call etor(etors,edihcnstr)
730 if (wtor.gt.0.0d0) then
731 if (tor_mode.eq.0) then
734 !C etor kcc is Kubo cumulant clustered rigorous attemp to derive the
742 if (ndih_constr.gt.0) call etor_constr(edihcnstr)
743 !c print *,"Processor",myrank," computed Utor"
745 ! print *,"Processor",myrank," computed Utor"
746 if (constr_homology.ge.1) then
747 call e_modeller(ehomology_constr)
748 ! print *,'iset=',iset,'me=',me,ehomology_constr,
749 ! & 'Processor',fg_rank,' CG group',kolor,
750 ! & ' absolute rank',MyRank
753 ehomology_constr=0.0d0
757 ! 6/23/01 Calculate double-torsional energy
759 !elwrite(iout,*) "in etotal",ipot
760 if (wtor_d.gt.0) then
765 ! print *,"Processor",myrank," computed Utord"
767 ! 21/5/07 Calculate local sicdechain correlation energy
769 if (wsccor.gt.0.0d0) then
770 call eback_sc_corr(esccor)
775 ! write(iout,*) "before multibody"
777 ! print *,"Processor",myrank," computed Usccorr"
779 ! 12/1/95 Multi-body terms
784 if ((wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 &
785 .or. wturn6.gt.0.0d0) .and. ipot.lt.6) then
786 call multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
787 !d write(2,*)'multibody_eello n_corr=',n_corr,' n_corr1=',n_corr1,
788 !d &" ecorr",ecorr," ecorr5",ecorr5," ecorr6",ecorr6," eturn6",eturn6
795 !elwrite(iout,*) "in etotal",ipot
796 if ((wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) .and. ipot.lt.6) then
797 call multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
798 !d write (iout,*) "multibody_hb ecorr",ecorr
800 ! write(iout,*) "afeter multibody hb"
802 ! print *,"Processor",myrank," computed Ucorr"
804 ! If performing constraint dynamics, call the constraint energy
805 ! after the equilibration time
806 if((usampl).and.(totT.gt.eq_time)) then
807 write(iout,*) "usampl",usampl
809 !elwrite(iout,*) "afeter multibody hb"
811 !elwrite(iout,*) "afeter multibody hb"
817 ! write(iout,*) "after Econstr"
819 if (wliptran.gt.0) then
820 ! print *,"PRZED WYWOLANIEM"
821 call Eliptransfer(eliptran)
825 if (fg_rank.eq.0) then
826 if (AFMlog.gt.0) then
827 call AFMforce(Eafmforce)
828 else if (selfguide.gt.0) then
829 call AFMvel(Eafmforce)
834 if (tubemode.eq.1) then
836 else if (tubemode.eq.2) then
837 call calctube2(etube)
838 elseif (tubemode.eq.3) then
843 !--------------------------------------------------------
844 ! write (iout,*) "NRES_MOLEC(2),",nres_molec(2)
845 ! print *,"before",ees,evdw1,ecorr
846 ! write(iout,*) ecorr_nucl,"ecorr_nucl",nres_molec(2)
847 if (nres_molec(2).gt.0) then
848 call ebond_nucl(estr_nucl)
849 call ebend_nucl(ebe_nucl)
850 call etor_nucl(etors_nucl)
851 call esb_gb(evdwsb,eelsb)
852 call epp_nucl_sub(evdwpp,eespp)
853 call epsb(evdwpsb,eelpsb)
855 call multibody_hb_nucl(ecorr_nucl,ecorr3_nucl,n_corr,n_corr1)
856 call ecat_nucl(ecation_nucl)
873 ! write(iout,*) ecorr_nucl,"ecorr_nucl",nres_molec(2)
874 ! print *,"before ecatcat",wcatcat
875 if (nres_molec(5).gt.0) then
876 if (nfgtasks.gt.1) then
877 if (fg_rank.eq.0) then
878 call ecatcat(ecationcation)
881 call ecatcat(ecationcation)
883 if (oldion.gt.0) then
884 call ecat_prot(ecation_prot)
886 call ecats_prot_amber(ecation_prot)
892 if ((nres_molec(2).gt.0).and.(nres_molec(1).gt.0)) then
893 call eprot_sc_base(escbase)
894 call epep_sc_base(epepbase)
895 call eprot_sc_phosphate(escpho)
896 call eprot_pep_phosphate(epeppho)
903 ! call ecatcat(ecationcation)
904 ! print *,"after ebend", wtor_nucl
906 time_enecalc=time_enecalc+MPI_Wtime()-time00
908 ! print *,"Processor",myrank," computed Uconstr"
917 energia(2)=evdw2-evdw2_14
934 energia(8)=eello_turn3
935 energia(9)=eello_turn4
942 energia(19)=edihcnstr
944 energia(20)=Uconst+Uconst_back
947 energia(23)=Eafmforce
948 energia(24)=ethetacnstr
950 !---------------------------------------------------------------
957 energia(32)=estr_nucl
960 energia(35)=etors_nucl
961 energia(36)=etors_d_nucl
962 energia(37)=ecorr_nucl
963 energia(38)=ecorr3_nucl
964 !----------------------------------------------------------------------
965 ! Here are the energies showed per procesor if the are more processors
966 ! per molecule then we sum it up in sum_energy subroutine
967 ! print *," Processor",myrank," calls SUM_ENERGY"
968 energia(42)=ecation_prot
969 energia(41)=ecationcation
974 ! energia(50)=ecations_prot_amber
975 energia(50)=ecation_nucl
976 energia(51)=ehomology_constr
977 call sum_energy(energia,.true.)
978 if (dyn_ss) call dyn_set_nss
979 ! print *," Processor",myrank," left SUM_ENERGY"
981 time_sumene=time_sumene+MPI_Wtime()-time00
983 ! call enerprint(energia)
984 !elwrite(iout,*)"finish etotal"
986 end subroutine etotal
987 !-----------------------------------------------------------------------------
988 subroutine sum_energy(energia,reduce)
989 ! implicit real*8 (a-h,o-z)
990 ! include 'DIMENSIONS'
994 !MS$ATTRIBUTES C :: proc_proc
1000 ! include 'COMMON.SETUP'
1001 ! include 'COMMON.IOUNITS'
1002 real(kind=8) :: energia(0:n_ene),enebuff(0:n_ene+1)
1003 ! include 'COMMON.FFIELD'
1004 ! include 'COMMON.DERIV'
1005 ! include 'COMMON.INTERACT'
1006 ! include 'COMMON.SBRIDGE'
1007 ! include 'COMMON.CHAIN'
1008 ! include 'COMMON.VAR'
1009 ! include 'COMMON.CONTROL'
1010 ! include 'COMMON.TIME1'
1012 real(kind=8) :: evdw,evdw2,evdw2_14,ees,evdw1,ecorr,ecorr5,ecorr6
1013 real(kind=8) :: eel_loc,eello_turn3,eello_turn4,eturn6,ebe,escloc
1014 real(kind=8) :: etors,etors_d,ehpb,edihcnstr,estr,esccor,etot, &
1015 eliptran,etube, Eafmforce,ethetacnstr
1016 real(kind=8) :: evdwpp,eespp,evdwpsb,eelpsb,evdwsb,eelsb,estr_nucl,&
1017 ebe_nucl,esbloc,etors_nucl,etors_d_nucl,ecorr_nucl,&
1018 ecorr3_nucl,ehomology_constr
1019 real(kind=8) :: ecation_prot,ecationcation,ecations_prot_amber,&
1021 real(kind=8) :: escbase,epepbase,escpho,epeppho
1025 real(kind=8) :: time00
1026 if (nfgtasks.gt.1 .and. reduce) then
1029 write (iout,*) "energies before REDUCE"
1030 call enerprint(energia)
1034 enebuff(i)=energia(i)
1037 call MPI_Barrier(FG_COMM,IERR)
1038 time_barrier_e=time_barrier_e+MPI_Wtime()-time00
1040 call MPI_Reduce(enebuff(0),energia(0),n_ene+1,&
1041 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
1043 write (iout,*) "energies after REDUCE"
1044 call enerprint(energia)
1047 time_Reduce=time_Reduce+MPI_Wtime()-time00
1049 if (fg_rank.eq.0) then
1053 evdw2=energia(2)+energia(18)
1054 evdw2_14=energia(18)
1069 eello_turn3=energia(8)
1070 eello_turn4=energia(9)
1077 edihcnstr=energia(19)
1081 eliptran=energia(22)
1082 Eafmforce=energia(23)
1083 ethetacnstr=energia(24)
1091 estr_nucl=energia(32)
1092 ebe_nucl=energia(33)
1094 etors_nucl=energia(35)
1095 etors_d_nucl=energia(36)
1096 ecorr_nucl=energia(37)
1097 ecorr3_nucl=energia(38)
1098 ecation_prot=energia(42)
1099 ecationcation=energia(41)
1101 epepbase=energia(47)
1104 ecation_nucl=energia(50)
1105 ehomology_constr=energia(51)
1106 ! ecations_prot_amber=energia(50)
1108 ! energia(41)=ecation_prot
1109 ! energia(42)=ecationcation
1113 etot=wsc*evdw+wscp*evdw2+welec*ees+wvdwpp*evdw1 &
1114 +wang*ebe+wtor*etors+wscloc*escloc &
1115 +wstrain*ehpb+wcorr*ecorr+wcorr5*ecorr5 &
1116 +wcorr6*ecorr6+wturn4*eello_turn4+wturn3*eello_turn3 &
1117 +wturn6*eturn6+wel_loc*eel_loc+edihcnstr+wtor_d*etors_d &
1118 +wbond*estr+Uconst+wsccor*esccor+wliptran*eliptran+wtube*etube&
1119 +Eafmforce+ethetacnstr+ehomology_constr &
1120 +wbond_nucl*estr_nucl+wang_nucl*ebe_nucl&
1121 +wvdwpp_nucl*evdwpp+welpp*eespp+wvdwpsb*evdwpsb+welpsb*eelpsb&
1122 +wvdwsb*evdwsb+welsb*eelsb+wsbloc*esbloc+wtor_nucl*etors_nucl&
1123 +wtor_d_nucl*etors_d_nucl+wcorr_nucl*ecorr_nucl+wcorr3_nucl*ecorr3_nucl&
1124 +wcatprot*ecation_prot+wcatcat*ecationcation+wscbase*escbase&
1125 +wpepbase*epepbase+wscpho*escpho+wpeppho*epeppho+wcatnucl*ecation_nucl
1127 etot=wsc*evdw+wscp*evdw2+welec*(ees+evdw1) &
1128 +wang*ebe+wtor*etors+wscloc*escloc &
1129 +wstrain*ehpb+wcorr*ecorr+wcorr5*ecorr5 &
1130 +wcorr6*ecorr6+wturn4*eello_turn4+wturn3*eello_turn3 &
1131 +wturn6*eturn6+wel_loc*eel_loc+edihcnstr+wtor_d*etors_d &
1132 +wbond*estr+Uconst+wsccor*esccor+wliptran*eliptran+wtube*etube&
1133 +Eafmforce+ethetacnstr+ehomology_constr &
1134 +wbond_nucl*estr_nucl+wang_nucl*ebe_nucl&
1135 +wvdwpp_nucl*evdwpp+welpp*eespp+wvdwpsb*evdwpsb+welpsb*eelpsb&
1136 +wvdwsb*evdwsb+welsb*eelsb+wsbloc*esbloc+wtor_nucl*etors_nucl&
1137 +wtor_d_nucl*etors_d_nucl+wcorr_nucl*ecorr_nucl+wcorr3_nucl*ecorr3_nucl&
1138 +wcatprot*ecation_prot+wcatcat*ecationcation+wscbase*escbase&
1139 +wpepbase*epepbase+wscpho*escpho+wpeppho*epeppho+wcatnucl*ecation_nucl
1145 if (isnan(etot).ne.0) energia(0)=1.0d+99
1147 if (isnan(etot)) energia(0)=1.0d+99
1152 idumm=proc_proc(etot,i)
1154 call proc_proc(etot,i)
1156 if(i.eq.1)energia(0)=1.0d+99
1161 ! call enerprint(energia)
1164 end subroutine sum_energy
1165 !-----------------------------------------------------------------------------
1166 subroutine rescale_weights(t_bath)
1167 ! implicit real*8 (a-h,o-z)
1171 ! include 'DIMENSIONS'
1172 ! include 'COMMON.IOUNITS'
1173 ! include 'COMMON.FFIELD'
1174 ! include 'COMMON.SBRIDGE'
1175 real(kind=8) :: kfac=2.4d0
1176 real(kind=8) :: x,x2,x3,x4,x5,licznik=1.12692801104297249644
1178 real(kind=8) :: t_bath,facT(6) !,facT2,facT3,facT4,facT5,facT6
1179 real(kind=8) :: T0=3.0d2
1182 ! facT=2*temp0/(t_bath+temp0)
1183 if (rescale_mode.eq.0) then
1190 else if (rescale_mode.eq.1) then
1191 facT(1)=kfac/(kfac-1.0d0+t_bath/temp0)
1192 facT(2)=kfac**2/(kfac**2-1.0d0+(t_bath/temp0)**2)
1193 facT(3)=kfac**3/(kfac**3-1.0d0+(t_bath/temp0)**3)
1194 facT(4)=kfac**4/(kfac**4-1.0d0+(t_bath/temp0)**4)
1195 facT(5)=kfac**5/(kfac**5-1.0d0+(t_bath/temp0)**5)
1197 !#if defined(WHAM_RUN) || defined(CLUSTER)
1199 ! tt = 1.0d0/(beta_h(ib,ipar)*1.987D-3)
1200 facT(6)=(320.0+80.0*dtanh((t_bath-320.0)/80.0))/320.0
1201 #elif defined(FUNCT)
1207 else if (rescale_mode.eq.2) then
1213 facT(1)=licznik/dlog(dexp(x)+dexp(-x))
1214 facT(2)=licznik/dlog(dexp(x2)+dexp(-x2))
1215 facT(3)=licznik/dlog(dexp(x3)+dexp(-x3))
1216 facT(4)=licznik/dlog(dexp(x4)+dexp(-x4))
1217 facT(5)=licznik/dlog(dexp(x5)+dexp(-x5))
1219 !#if defined(WHAM_RUN) || defined(CLUSTER)
1221 facT(6)=(320.0+80.0*dtanh((t_bath-320.0)/80.0))/320.0
1222 #elif defined(FUNCT)
1229 write (iout,*) "Wrong RESCALE_MODE",rescale_mode
1230 write (*,*) "Wrong RESCALE_MODE",rescale_mode
1232 call MPI_Finalize(MPI_COMM_WORLD,IERROR)
1236 welec=weights(3)*fact(1)
1237 wcorr=weights(4)*fact(3)
1238 wcorr5=weights(5)*fact(4)
1239 wcorr6=weights(6)*fact(5)
1240 wel_loc=weights(7)*fact(2)
1241 wturn3=weights(8)*fact(2)
1242 wturn4=weights(9)*fact(3)
1243 wturn6=weights(10)*fact(5)
1244 wtor=weights(13)*fact(1)
1245 wtor_d=weights(14)*fact(2)
1246 wsccor=weights(21)*fact(1)
1247 welpsb=weights(28)*fact(1)
1248 wcorr_nucl= weights(37)*fact(1)
1249 wcorr3_nucl=weights(38)*fact(2)
1250 wtor_nucl= weights(35)*fact(1)
1251 wtor_d_nucl=weights(36)*fact(2)
1252 wpepbase=weights(47)*fact(1)
1254 end subroutine rescale_weights
1255 !-----------------------------------------------------------------------------
1256 subroutine enerprint(energia)
1257 ! implicit real*8 (a-h,o-z)
1258 ! include 'DIMENSIONS'
1259 ! include 'COMMON.IOUNITS'
1260 ! include 'COMMON.FFIELD'
1261 ! include 'COMMON.SBRIDGE'
1262 ! include 'COMMON.MD'
1263 real(kind=8) :: energia(0:n_ene)
1265 real(kind=8) :: etot,evdw,evdw2,ees,evdw1,ecorr,ecorr5,ecorr6,eel_loc
1266 real(kind=8) :: eello_turn6,eello_turn3,eello_turn4,ebe,escloc
1267 real(kind=8) :: etors,etors_d,ehpb,edihcnstr,estr,Uconst,esccor,eliptran,&
1268 etube,ethetacnstr,Eafmforce
1269 real(kind=8) :: evdwpp,eespp,evdwpsb,eelpsb,evdwsb,eelsb,estr_nucl,&
1270 ebe_nucl,esbloc,etors_nucl,etors_d_nucl,ecorr_nucl,&
1271 ecorr3_nucl,ehomology_constr
1272 real(kind=8) :: ecation_prot,ecationcation,ecations_prot_amber,&
1274 real(kind=8) :: escbase,epepbase,escpho,epeppho
1280 evdw2=energia(2)+energia(18)
1292 eello_turn3=energia(8)
1293 eello_turn4=energia(9)
1294 eello_turn6=energia(10)
1300 edihcnstr=energia(19)
1304 eliptran=energia(22)
1305 Eafmforce=energia(23)
1306 ethetacnstr=energia(24)
1314 estr_nucl=energia(32)
1315 ebe_nucl=energia(33)
1317 etors_nucl=energia(35)
1318 etors_d_nucl=energia(36)
1319 ecorr_nucl=energia(37)
1320 ecorr3_nucl=energia(38)
1321 ecation_prot=energia(42)
1322 ecationcation=energia(41)
1324 epepbase=energia(47)
1327 ecation_nucl=energia(50)
1328 ehomology_constr=energia(51)
1330 ! ecations_prot_amber=energia(50)
1332 write (iout,10) evdw,wsc,evdw2,wscp,ees,welec,evdw1,wvdwpp,&
1333 estr,wbond,ebe,wang,&
1334 escloc,wscloc,etors,wtor,etors_d,wtor_d,ehpb,wstrain,&
1336 ecorr5,wcorr5,ecorr6,wcorr6,eel_loc,wel_loc,eello_turn3,wturn3,&
1337 eello_turn4,wturn4,eello_turn6,wturn6,esccor,wsccor,&
1338 edihcnstr,ethetacnstr,ebr*nss,&
1339 Uconst,eliptran,wliptran,Eafmforce,etube,wtube, & ! till now protein
1340 estr_nucl,wbond_nucl,ebe_nucl,wang_nucl, &
1341 evdwpp,wvdwpp_nucl,eespp,welpp,evdwpsb,wvdwpsb,eelpsb,welpsb,&
1342 evdwsb,wvdwsb,eelsb,welsb,esbloc,wsbloc,etors_nucl,wtor_nucl,&
1343 etors_d_nucl,wtor_d_nucl,ecorr_nucl,wcorr_nucl,&
1344 ecorr3_nucl,wcorr3_nucl,ecation_prot,wcatprot,ecationcation,wcatcat, &
1345 escbase,wscbase,epepbase,wpepbase,escpho,wscpho,epeppho,wpeppho,&
1346 ecation_nucl,wcatnucl,ehomology_constr,etot
1347 10 format (/'Virtual-chain energies:'// &
1348 'EVDW= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-SC)'/ &
1349 'EVDW2= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-p)'/ &
1350 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p)'/ &
1351 'EVDWPP=',1pE16.6,' WEIGHT=',1pD16.6,' (p-p VDW)'/ &
1352 'ESTR= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching)'/ &
1353 'EBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (bending)'/ &
1354 'ESC= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/ &
1355 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/ &
1356 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/ &
1357 'EHBP= ',1pE16.6,' WEIGHT=',1pD16.6, &
1358 ' (SS bridges & dist. cnstr.)'/ &
1359 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
1360 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
1361 'ECORR6=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
1362 'EELLO= ',1pE16.6,' WEIGHT=',1pD16.6,' (electrostatic-local)'/ &
1363 'ETURN3=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 3rd order)'/ &
1364 'ETURN4=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 4th order)'/ &
1365 'ETURN6=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 6th order)'/ &
1366 'ESCCOR=',1pE16.6,' WEIGHT=',1pD16.6,' (backbone-rotamer corr)'/ &
1367 'EDIHC= ',1pE16.6,' (dihedral angle constraints)'/ &
1368 'ETHETC= ',1pE16.6,' (valence angle constraints)'/ &
1369 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/ &
1370 'UCONST= ',1pE16.6,' (Constraint energy)'/ &
1371 'ELT=',1pE16.6, ' WEIGHT=',1pD16.6,' (Lipid transfer energy)'/&
1372 'EAFM= ',1pE16.6,' (atomic-force microscopy)'/ &
1373 'ETUBE=',1pE16.6, ' WEIGHT=',1pD16.6,' (cylindrical energy)'/ &
1374 'ESTR_nucl=',1pE16.6,' WEIGHT=',1pD16.6,' (stretching for nucleic)'/ &
1375 'EBE_nucl=',1pE16.6,' WEIGHT=',1pD16.6,' (bending for nucleic)'/ &
1376 'EVDW_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-phosphate VDW)'/ &
1377 'EESPP_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-phosphate elec)'/ &
1378 'EVDWPSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-sugarbase VDW)'/ &
1379 'EESPSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-sugarbase elec)'/ &
1380 'EVDWSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(sugarbase-sugarbase VDW)'/ &
1381 'EESSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(sugarbase-sugarbase elec)'/ &
1382 'ESBLOC_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(sugarbase rotamer)'/ &
1383 'ETORS_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(torsional)'/ &
1384 'ETORSD_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(double torsional)'/ &
1385 'ECORR_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(multibody 4th order)'/ &
1386 'ECORR3_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(multibody 3th order)'/ &
1387 'ECATPROT=',1pE16.6,' WEIGHT=',1pD16.6,'(cation prot)'/ &
1388 'ECATCAT=',1pE16.6,' WEIGHT=',1pD16.6,'(cation cation)'/ &
1389 'ESCBASE=',1pE16.6,' WEIGHT=',1pD16.6,'(sc-prot nucl-base)'/ &
1390 'EPEPBASE=',1pE16.6,' WEIGHT=',1pD16.6,'(pep-prot nucl-base)'/ &
1391 'ESCPHO=',1pE16.6,' WEIGHT=',1pD16.6,'(sc-prot nucl-phosphate)'/&
1392 'EPEPPHO=',1pE16.6,' WEIGHT=',1pD16.6,'(pep-prot nucl-phosphate)'/&
1393 'ECATBASE=',1pE16.6,' WEIGHT=',1pD16.6,'(cation nucl-base)'/&
1394 'H_CONS=',1pE16.6,' (Homology model constraints energy)'/&
1395 'ETOT= ',1pE16.6,' (total)')
1397 write (iout,10) evdw,wsc,evdw2,wscp,ees,welec,&
1398 estr,wbond,ebe,wang,&
1399 escloc,wscloc,etors,wtor,etors_d,wtor_d,ehpb,wstrain,&
1401 ecorr5,wcorr5,ecorr6,wcorr6,eel_loc,wel_loc,eello_turn3,wturn3,&
1402 eello_turn4,wturn4,eello_turn6,wturn6,esccor,wsccor,edihcnstr,&
1403 ethetacnstr,ebr*nss,Uconst,eliptran,wliptran,Eafmforce, &
1404 etube,wtube, ehomology_constr,&
1405 estr_nucl,wbond_nucl, ebe_nucl,wang_nucl,&
1406 evdwpp,wvdwpp_nucl,eespp,welpp,evdwpsb,wvdwpsb,eelpsb,welpsb,&
1407 evdwsb,wvdwsb,eelsb,welsb,esbloc,wsbloc,etors_nucl,wtor_nucl,&
1408 etors_d_nucl,wtor_d_nucl,ecorr_nucl,wcorr_nucl,&
1409 ecorr3_nucl,wcorr3_nucl,ecation_prot,wcatprot,ecationcation,wcatcat, &
1410 escbase,wscbase,epepbase,wpepbase,escpho,wscpho,epeppho,wpeppho,&
1411 ecation_nucl,wcatnucl,ehomology_constr,etot
1412 10 format (/'Virtual-chain energies:'// &
1413 'EVDW= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-SC)'/ &
1414 'EVDW2= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-p)'/ &
1415 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p)'/ &
1416 'ESTR= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching)'/ &
1417 'EBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (bending)'/ &
1418 'ESC= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/ &
1419 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/ &
1420 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/ &
1421 'EHBP= ',1pE16.6,' WEIGHT=',1pD16.6, &
1422 ' (SS bridges & dist. cnstr.)'/ &
1423 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
1424 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
1425 'ECORR6=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
1426 'EELLO= ',1pE16.6,' WEIGHT=',1pD16.6,' (electrostatic-local)'/ &
1427 'ETURN3=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 3rd order)'/ &
1428 'ETURN4=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 4th order)'/ &
1429 'ETURN6=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 6th order)'/ &
1430 'ESCCOR=',1pE16.6,' WEIGHT=',1pD16.6,' (backbone-rotamer corr)'/ &
1431 'EDIHC= ',1pE16.6,' (dihedral angle constraints)'/ &
1432 'ETHETC= ',1pE16.6,' (valence angle constraints)'/ &
1433 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/ &
1434 'UCONST=',1pE16.6,' (Constraint energy)'/ &
1435 'ELT=',1pE16.6, ' WEIGHT=',1pD16.6,' (Lipid transfer energy)'/ &
1436 'EAFM= ',1pE16.6,' (atomic-force microscopy)'/ &
1437 'ETUBE=',1pE16.6, ' WEIGHT=',1pD16.6,' (cylindrical energy)'/ &
1438 'ESTR_nucl= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching for nucleic)'/ &
1439 'EBE_nucl=',1pE16.6,' WEIGHT=',1pD16.6,' (bending for nucleic)'/ &
1440 'EVDW_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-phosphate VDW)'/ &
1441 'EESPP_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-phosphate elec)'/ &
1442 'EVDWPSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-sugarbase VDW)'/ &
1443 'EESPSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-sugarbase elec)'/ &
1444 'EVDWSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(sugarbase-sugarbase VDW)'/ &
1445 'EESSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(sugarbase-sugarbase elec)'/ &
1446 'ESBLOC_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(sugarbase rotamer)'/ &
1447 'ETORS_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(torsional)'/ &
1448 'ETORSD_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(double torsional)'/ &
1449 'ECORR_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(multibody 4th order)'/ &
1450 'ECORR3_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(multibody 3th order)'/ &
1451 'ECATPROT=',1pE16.6,' WEIGHT=',1pD16.6,'(cation prot)'/ &
1452 'ECATCAT=',1pE16.6,' WEIGHT=',1pD16.6,'(cation cation)'/ &
1453 'ESCBASE=',1pE16.6,' WEIGHT=',1pD16.6,'(sc-prot nucl-base)'/ &
1454 'EPEPBASE=',1pE16.6,' WEIGHT=',1pD16.6,'(pep-prot nucl-base)'/ &
1455 'ESCPHO=',1pE16.6,' WEIGHT=',1pD16.6,'(sc-prot nucl-phosphate)'/&
1456 'EPEPPHO=',1pE16.6,' WEIGHT=',1pD16.6,'(pep-prot nucl-phosphate)'/&
1457 'ECATBASE=',1pE16.6,' WEIGHT=',1pD16.6,'(cation nucl-base)'/&
1458 'H_CONS=',1pE16.6,' (Homology model constraints energy)'/&
1459 'ETOT= ',1pE16.6,' (total)')
1462 end subroutine enerprint
1463 !-----------------------------------------------------------------------------
1464 subroutine elj(evdw)
1466 ! This subroutine calculates the interaction energy of nonbonded side chains
1467 ! assuming the LJ potential of interaction.
1469 ! implicit real*8 (a-h,o-z)
1470 ! include 'DIMENSIONS'
1471 real(kind=8),parameter :: accur=1.0d-10
1472 ! include 'COMMON.GEO'
1473 ! include 'COMMON.VAR'
1474 ! include 'COMMON.LOCAL'
1475 ! include 'COMMON.CHAIN'
1476 ! include 'COMMON.DERIV'
1477 ! include 'COMMON.INTERACT'
1478 ! include 'COMMON.TORSION'
1479 ! include 'COMMON.SBRIDGE'
1480 ! include 'COMMON.NAMES'
1481 ! include 'COMMON.IOUNITS'
1482 ! include 'COMMON.CONTACTS'
1483 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
1484 integer :: num_conti
1486 integer :: i,itypi,iint,j,itypi1,itypj,k
1487 real(kind=8) :: rij,rcut,fcont,fprimcont,rrij,sslipi,ssgradlipi,&
1488 aa,bb,sslipj,ssgradlipj
1489 real(kind=8) :: evdw,xi,yi,zi,xj,yj,zj
1490 real(kind=8) :: eps0ij,fac,e1,e2,evdwij,sigij,r0ij
1492 ! write(iout,*)'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
1494 ! allocate(num_cont(iatsc_s:iatsc_e)) !(maxres) nnt,nct-2
1495 ! allocate(jcont(nres/4,iatsc_s:iatsc_e)) !(maxconts,maxres) (maxconts=maxres/4)
1496 ! allocate(facont(nres/4,iatsc_s:iatsc_e)) !(maxconts,maxres)
1497 ! allocate(gacont(3,nres/4,iatsc_s:iatsc_e)) !(3,maxconts,maxres)
1499 do i=iatsc_s,iatsc_e
1500 itypi=iabs(itype(i,1))
1501 if (itypi.eq.ntyp1) cycle
1502 itypi1=iabs(itype(i+1,1))
1506 call to_box(xi,yi,zi)
1507 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
1512 ! Calculate SC interaction energy.
1514 do iint=1,nint_gr(i)
1515 !d write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
1516 !d & 'iend=',iend(i,iint)
1517 do j=istart(i,iint),iend(i,iint)
1518 itypj=iabs(itype(j,1))
1519 if (itypj.eq.ntyp1) cycle
1523 call to_box(xj,yj,zj)
1524 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
1525 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
1526 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
1527 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
1528 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
1529 xj=boxshift(xj-xi,boxxsize)
1530 yj=boxshift(yj-yi,boxysize)
1531 zj=boxshift(zj-zi,boxzsize)
1532 ! Change 12/1/95 to calculate four-body interactions
1533 rij=xj*xj+yj*yj+zj*zj
1535 ! write (iout,*)'i=',i,' j=',j,' itypi=',itypi,' itypj=',itypj
1536 eps0ij=eps(itypi,itypj)
1538 e1=fac*fac*aa_aq(itypi,itypj)
1539 e2=fac*bb_aq(itypi,itypj)
1541 !d sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1542 !d epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1543 !d write (iout,'(2(a3,i3,2x),6(1pd12.4)/2(3(1pd12.4),5x)/)')
1544 !d & restyp(itypi,1),i,restyp(itypj,1),j,aa(itypi,itypj),
1545 !d & bb(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,epsi,sigm,
1546 !d & (c(k,i),k=1,3),(c(k,j),k=1,3)
1549 ! Calculate the components of the gradient in DC and X
1551 fac=-rrij*(e1+evdwij)
1556 gvdwx(k,i)=gvdwx(k,i)-gg(k)
1557 gvdwx(k,j)=gvdwx(k,j)+gg(k)
1558 gvdwc(k,i)=gvdwc(k,i)-gg(k)
1559 gvdwc(k,j)=gvdwc(k,j)+gg(k)
1563 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
1567 ! 12/1/95, revised on 5/20/97
1569 ! Calculate the contact function. The ith column of the array JCONT will
1570 ! contain the numbers of atoms that make contacts with the atom I (of numbers
1571 ! greater than I). The arrays FACONT and GACONT will contain the values of
1572 ! the contact function and its derivative.
1574 ! Uncomment next line, if the correlation interactions include EVDW explicitly.
1575 ! if (j.gt.i+1 .and. evdwij.le.0.0D0) then
1576 ! Uncomment next line, if the correlation interactions are contact function only
1577 if (j.gt.i+1.and. eps0ij.gt.0.0D0) then
1579 sigij=sigma(itypi,itypj)
1580 r0ij=rs0(itypi,itypj)
1582 ! Check whether the SC's are not too far to make a contact.
1585 call gcont(rij,rcut,1.0d0,0.2d0*rcut,fcont,fprimcont)
1586 ! Add a new contact, if the SC's are close enough, but not too close (r<sigma).
1588 if (fcont.gt.0.0D0) then
1589 ! If the SC-SC distance if close to sigma, apply spline.
1590 !Adam call gcont(-rij,-1.03d0*sigij,2.0d0*sigij,1.0d0,
1591 !Adam & fcont1,fprimcont1)
1592 !Adam fcont1=1.0d0-fcont1
1593 !Adam if (fcont1.gt.0.0d0) then
1594 !Adam fprimcont=fprimcont*fcont1+fcont*fprimcont1
1595 !Adam fcont=fcont*fcont1
1597 ! Uncomment following 4 lines to have the geometric average of the epsilon0's
1598 !ga eps0ij=1.0d0/dsqrt(eps0ij)
1600 !ga gg(k)=gg(k)*eps0ij
1602 !ga eps0ij=-evdwij*eps0ij
1603 ! Uncomment for AL's type of SC correlation interactions.
1604 !adam eps0ij=-evdwij
1605 num_conti=num_conti+1
1606 jcont(num_conti,i)=j
1607 facont(num_conti,i)=fcont*eps0ij
1608 fprimcont=eps0ij*fprimcont/rij
1610 !Adam gacont(1,num_conti,i)=-fprimcont*xj+fcont*gg(1)
1611 !Adam gacont(2,num_conti,i)=-fprimcont*yj+fcont*gg(2)
1612 !Adam gacont(3,num_conti,i)=-fprimcont*zj+fcont*gg(3)
1613 ! Uncomment following 3 lines for Skolnick's type of SC correlation.
1614 gacont(1,num_conti,i)=-fprimcont*xj
1615 gacont(2,num_conti,i)=-fprimcont*yj
1616 gacont(3,num_conti,i)=-fprimcont*zj
1617 !d write (iout,'(2i5,2f10.5)') i,j,rij,facont(num_conti,i)
1618 !d write (iout,'(2i3,3f10.5)')
1619 !d & i,j,(gacont(kk,num_conti,i),kk=1,3)
1625 num_cont(i)=num_conti
1629 gvdwc(j,i)=expon*gvdwc(j,i)
1630 gvdwx(j,i)=expon*gvdwx(j,i)
1633 !******************************************************************************
1637 ! To save time, the factor of EXPON has been extracted from ALL components
1638 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
1641 !******************************************************************************
1644 !-----------------------------------------------------------------------------
1645 subroutine eljk(evdw)
1647 ! This subroutine calculates the interaction energy of nonbonded side chains
1648 ! assuming the LJK potential of interaction.
1650 ! implicit real*8 (a-h,o-z)
1651 ! include 'DIMENSIONS'
1652 ! include 'COMMON.GEO'
1653 ! include 'COMMON.VAR'
1654 ! include 'COMMON.LOCAL'
1655 ! include 'COMMON.CHAIN'
1656 ! include 'COMMON.DERIV'
1657 ! include 'COMMON.INTERACT'
1658 ! include 'COMMON.IOUNITS'
1659 ! include 'COMMON.NAMES'
1660 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
1663 integer :: i,iint,j,itypi,itypi1,k,itypj
1664 real(kind=8) :: rrij,xi,yi,zi,xj,yj,zj,fac_augm,e_augm,r_inv_ij, &
1665 sslipi,ssgradlipi, sslipj,ssgradlipj, aa, bb
1666 real(kind=8) :: evdw,rij,r_shift_inv,fac,e1,e2,evdwij
1668 ! print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
1670 do i=iatsc_s,iatsc_e
1671 itypi=iabs(itype(i,1))
1672 if (itypi.eq.ntyp1) cycle
1673 itypi1=iabs(itype(i+1,1))
1677 call to_box(xi,yi,zi)
1678 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
1681 ! Calculate SC interaction energy.
1683 do iint=1,nint_gr(i)
1684 do j=istart(i,iint),iend(i,iint)
1685 itypj=iabs(itype(j,1))
1686 if (itypj.eq.ntyp1) cycle
1690 call to_box(xj,yj,zj)
1691 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
1692 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
1693 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
1694 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
1695 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
1696 xj=boxshift(xj-xi,boxxsize)
1697 yj=boxshift(yj-yi,boxysize)
1698 zj=boxshift(zj-zi,boxzsize)
1699 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1700 fac_augm=rrij**expon
1701 e_augm=augm(itypi,itypj)*fac_augm
1702 r_inv_ij=dsqrt(rrij)
1704 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
1705 fac=r_shift_inv**expon
1706 e1=fac*fac*aa_aq(itypi,itypj)
1707 e2=fac*bb_aq(itypi,itypj)
1709 !d sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1710 !d epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1711 !d write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
1712 !d & restyp(itypi,1),i,restyp(itypj,1),j,aa(itypi,itypj),
1713 !d & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
1714 !d & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
1715 !d & (c(k,i),k=1,3),(c(k,j),k=1,3)
1718 ! Calculate the components of the gradient in DC and X
1720 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
1725 gvdwx(k,i)=gvdwx(k,i)-gg(k)
1726 gvdwx(k,j)=gvdwx(k,j)+gg(k)
1727 gvdwc(k,i)=gvdwc(k,i)-gg(k)
1728 gvdwc(k,j)=gvdwc(k,j)+gg(k)
1732 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
1740 gvdwc(j,i)=expon*gvdwc(j,i)
1741 gvdwx(j,i)=expon*gvdwx(j,i)
1746 !-----------------------------------------------------------------------------
1747 subroutine ebp(evdw)
1749 ! This subroutine calculates the interaction energy of nonbonded side chains
1750 ! assuming the Berne-Pechukas potential of interaction.
1754 ! implicit real*8 (a-h,o-z)
1755 ! include 'DIMENSIONS'
1756 ! include 'COMMON.GEO'
1757 ! include 'COMMON.VAR'
1758 ! include 'COMMON.LOCAL'
1759 ! include 'COMMON.CHAIN'
1760 ! include 'COMMON.DERIV'
1761 ! include 'COMMON.NAMES'
1762 ! include 'COMMON.INTERACT'
1763 ! include 'COMMON.IOUNITS'
1764 ! include 'COMMON.CALC'
1766 !el integer :: icall
1767 !el common /srutu/ icall
1768 ! double precision rrsave(maxdim)
1771 integer :: iint,itypi,itypi1,itypj
1772 real(kind=8) :: rrij,xi,yi,zi, sslipi,ssgradlipi, sslipj, &
1774 real(kind=8) :: evdw,fac,e1,e2,sigm,epsi
1776 ! print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
1778 ! if (icall.eq.0) then
1784 do i=iatsc_s,iatsc_e
1785 itypi=iabs(itype(i,1))
1786 if (itypi.eq.ntyp1) cycle
1787 itypi1=iabs(itype(i+1,1))
1791 call to_box(xi,yi,zi)
1792 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
1793 dxi=dc_norm(1,nres+i)
1794 dyi=dc_norm(2,nres+i)
1795 dzi=dc_norm(3,nres+i)
1796 ! dsci_inv=dsc_inv(itypi)
1797 dsci_inv=vbld_inv(i+nres)
1799 ! Calculate SC interaction energy.
1801 do iint=1,nint_gr(i)
1802 do j=istart(i,iint),iend(i,iint)
1804 itypj=iabs(itype(j,1))
1805 if (itypj.eq.ntyp1) cycle
1806 ! dscj_inv=dsc_inv(itypj)
1807 dscj_inv=vbld_inv(j+nres)
1808 chi1=chi(itypi,itypj)
1809 chi2=chi(itypj,itypi)
1816 alf12=0.5D0*(alf1+alf2)
1817 ! For diagnostics only!!!
1830 call to_box(xj,yj,zj)
1831 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
1832 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
1833 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
1834 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
1835 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
1836 xj=boxshift(xj-xi,boxxsize)
1837 yj=boxshift(yj-yi,boxysize)
1838 zj=boxshift(zj-zi,boxzsize)
1839 dxj=dc_norm(1,nres+j)
1840 dyj=dc_norm(2,nres+j)
1841 dzj=dc_norm(3,nres+j)
1842 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1843 !d if (icall.eq.0) then
1849 ! Calculate the angle-dependent terms of energy & contributions to derivatives.
1851 ! Calculate whole angle-dependent part of epsilon and contributions
1852 ! to its derivatives
1853 fac=(rrij*sigsq)**expon2
1854 e1=fac*fac*aa_aq(itypi,itypj)
1855 e2=fac*bb_aq(itypi,itypj)
1856 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
1857 eps2der=evdwij*eps3rt
1858 eps3der=evdwij*eps2rt
1859 evdwij=evdwij*eps2rt*eps3rt
1862 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
1863 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
1864 !d write (iout,'(2(a3,i3,2x),15(0pf7.3))')
1865 !d & restyp(itypi,1),i,restyp(itypj,1),j,
1866 !d & epsi,sigm,chi1,chi2,chip1,chip2,
1867 !d & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
1868 !d & om1,om2,om12,1.0D0/dsqrt(rrij),
1871 ! Calculate gradient components.
1872 e1=e1*eps1*eps2rt**2*eps3rt**2
1873 fac=-expon*(e1+evdwij)
1876 ! Calculate radial part of the gradient
1880 ! Calculate the angular part of the gradient and sum add the contributions
1881 ! to the appropriate components of the Cartesian gradient.
1889 !-----------------------------------------------------------------------------
1890 subroutine egb(evdw)
1892 ! This subroutine calculates the interaction energy of nonbonded side chains
1893 ! assuming the Gay-Berne potential of interaction.
1896 ! implicit real*8 (a-h,o-z)
1897 ! include 'DIMENSIONS'
1898 ! include 'COMMON.GEO'
1899 ! include 'COMMON.VAR'
1900 ! include 'COMMON.LOCAL'
1901 ! include 'COMMON.CHAIN'
1902 ! include 'COMMON.DERIV'
1903 ! include 'COMMON.NAMES'
1904 ! include 'COMMON.INTERACT'
1905 ! include 'COMMON.IOUNITS'
1906 ! include 'COMMON.CALC'
1907 ! include 'COMMON.CONTROL'
1908 ! include 'COMMON.SBRIDGE'
1911 integer :: iint,itypi,itypi1,itypj,subchap,icont
1912 real(kind=8) :: rrij,xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
1913 real(kind=8) :: evdw,sig0ij
1914 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
1915 dist_temp, dist_init,aa,bb,ssgradlipi,ssgradlipj, &
1916 sslipi,sslipj,faclip
1918 real(kind=8) :: fracinbuf
1920 !cccc energy_dec=.false.
1921 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
1924 ! if (icall.eq.0) lprn=.false.
1932 ! write (iout,*) "RWA", g_listscsc_start,g_listscsc_end,i,j
1934 do icont=g_listscsc_start,g_listscsc_end
1935 i=newcontlisti(icont)
1936 j=newcontlistj(icont)
1937 ! write (iout,*) "RWA", g_listscsc_start,g_listscsc_end,i,j
1938 ! do i=iatsc_s,iatsc_e
1939 !C print *,"I am in EVDW",i
1940 itypi=iabs(itype(i,1))
1941 ! if (i.ne.47) cycle
1942 if (itypi.eq.ntyp1) cycle
1943 itypi1=iabs(itype(i+1,1))
1947 call to_box(xi,yi,zi)
1948 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
1950 dxi=dc_norm(1,nres+i)
1951 dyi=dc_norm(2,nres+i)
1952 dzi=dc_norm(3,nres+i)
1953 ! dsci_inv=dsc_inv(itypi)
1954 dsci_inv=vbld_inv(i+nres)
1955 ! write (iout,*) "i",i,dsc_inv(itypi),dsci_inv,1.0d0/vbld(i+nres)
1956 ! write (iout,*) "dcnori",dxi*dxi+dyi*dyi+dzi*dzi
1958 ! Calculate SC interaction energy.
1960 ! do iint=1,nint_gr(i)
1961 ! do j=istart(i,iint),iend(i,iint)
1962 IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
1963 call dyn_ssbond_ene(i,j,evdwij)
1965 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
1966 'evdw',i,j,evdwij,' ss'
1967 ! if (energy_dec) write (iout,*) &
1968 ! 'evdw',i,j,evdwij,' ss'
1969 do k=j+1,iend(i,iint)
1970 !C search over all next residues
1971 if (dyn_ss_mask(k)) then
1972 !C check if they are cysteins
1973 !C write(iout,*) 'k=',k
1975 !c write(iout,*) "PRZED TRI", evdwij
1976 ! evdwij_przed_tri=evdwij
1977 call triple_ssbond_ene(i,j,k,evdwij)
1978 !c if(evdwij_przed_tri.ne.evdwij) then
1979 !c write (iout,*) "TRI:", evdwij, evdwij_przed_tri
1982 !c write(iout,*) "PO TRI", evdwij
1983 !C call the energy function that removes the artifical triple disulfide
1984 !C bond the soubroutine is located in ssMD.F
1986 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
1987 'evdw',i,j,evdwij,'tss'
1988 endif!dyn_ss_mask(k)
1992 itypj=iabs(itype(j,1))
1993 if (itypj.eq.ntyp1) cycle
1994 ! if (j.ne.78) cycle
1995 ! dscj_inv=dsc_inv(itypj)
1996 dscj_inv=vbld_inv(j+nres)
1997 ! write (iout,*) "j",j,dsc_inv(itypj),dscj_inv,&
1998 ! 1.0d0/vbld(j+nres) !d
1999 ! write (iout,*) "i",i," j", j," itype",itype(i,1),itype(j,1)
2000 sig0ij=sigma(itypi,itypj)
2001 chi1=chi(itypi,itypj)
2002 chi2=chi(itypj,itypi)
2009 alf12=0.5D0*(alf1+alf2)
2010 ! For diagnostics only!!!
2023 call to_box(xj,yj,zj)
2024 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
2025 ! write (iout,*) "KWA2", itypi,itypj
2026 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
2027 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
2028 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
2029 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
2030 xj=boxshift(xj-xi,boxxsize)
2031 yj=boxshift(yj-yi,boxysize)
2032 zj=boxshift(zj-zi,boxzsize)
2033 dxj=dc_norm(1,nres+j)
2034 dyj=dc_norm(2,nres+j)
2035 dzj=dc_norm(3,nres+j)
2036 ! write (iout,*) "dcnorj",dxi*dxi+dyi*dyi+dzi*dzi
2037 ! write (iout,*) "j",j," dc_norm",& !d
2038 ! dc_norm(1,nres+j),dc_norm(2,nres+j),dc_norm(3,nres+j)
2039 ! write(iout,*)"rrij ",rrij
2040 ! write(iout,*)"xj yj zj ", xj, yj, zj
2041 ! write(iout,*)"xi yi zi ", xi, yi, zi
2042 ! write(iout,*)"c ", c(1,:), c(2,:), c(3,:)
2043 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
2045 sss_ele_cut=sscale_ele(1.0d0/(rij))
2046 sss_ele_grad=sscagrad_ele(1.0d0/(rij))
2047 ! print *,sss_ele_cut,sss_ele_grad,&
2048 ! 1.0d0/(rij),r_cut_ele,rlamb_ele
2049 if (sss_ele_cut.le.0.0) cycle
2050 ! Calculate angle-dependent terms of energy and contributions to their
2054 sig=sig0ij*dsqrt(sigsq)
2055 rij_shift=1.0D0/rij-sig+sig0ij
2056 ! write(iout,*)" rij_shift",rij_shift," rij",rij," sig",sig,&
2058 ! for diagnostics; uncomment
2059 ! rij_shift=1.2*sig0ij
2060 ! I hate to put IF's in the loops, but here don't have another choice!!!!
2061 if (rij_shift.le.0.0D0) then
2063 !d write (iout,'(2(a3,i3,2x),17(0pf7.3))')
2064 !d & restyp(itypi,1),i,restyp(itypj,1),j,
2065 !d & rij_shift,1.0D0/rij,sig,sig0ij,sigsq,1-dsqrt(sigsq)
2069 !---------------------------------------------------------------
2070 rij_shift=1.0D0/rij_shift
2071 fac=rij_shift**expon
2073 e1=fac*fac*aa!(itypi,itypj)
2074 e2=fac*bb!(itypi,itypj)
2075 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
2076 eps2der=evdwij*eps3rt
2077 eps3der=evdwij*eps2rt
2078 ! write(iout,*)"aa, bb ",aa(:,:),bb(:,:)
2079 ! write (iout,*) "sigsq",sigsq," sig",sig," eps2rt",eps2rt,& !d
2080 ! " eps3rt",eps3rt," eps1",eps1," e1",e1," e2",e2," fac",fac !d
2081 evdwij=evdwij*eps2rt*eps3rt
2082 evdw=evdw+evdwij*sss_ele_cut
2084 sigm=dabs(aa/bb)**(1.0D0/6.0D0)
2085 epsi=bb**2/aa!(itypi,itypj)
2086 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
2087 restyp(itypi,1),i,restyp(itypj,1),j, &
2088 epsi,sigm,chi1,chi2,chip1,chip2, &
2089 eps1,eps2rt**2,eps3rt**2,sig,sig0ij, &
2090 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift, &
2094 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,2e10.2,e11.3)')&
2095 'evdw',i,j,evdwij,xi,xj,rij !,"egb"
2096 !C print *,i,j,c(1,i),c(1,j),c(2,i),c(2,j),c(3,i),c(3,j)
2097 ! if (energy_dec) write (iout,*) &
2099 ! print *,"ZALAMKA", evdw
2101 ! Calculate gradient components.
2102 e1=e1*eps1*eps2rt**2*eps3rt**2
2103 fac=-expon*(e1+evdwij)*rij_shift
2106 ! print *,'before fac',fac,rij,evdwij
2107 fac=fac+evdwij*sss_ele_grad/sss_ele_cut&
2109 ! print *,'grad part scale',fac, &
2110 ! evdwij*sss_ele_grad/sss_ele_cut &
2111 ! /sigma(itypi,itypj)*rij
2113 ! Calculate the radial part of the gradient
2117 !C Calculate the radial part of the gradient
2118 gg_lipi(3)=eps1*(eps2rt*eps2rt)&
2119 *(eps3rt*eps3rt)*sss_ele_cut/2.0d0*(faclip*faclip*&
2120 (aa_lip(itypi,itypj)-aa_aq(itypi,itypj))&
2121 +faclip*(bb_lip(itypi,itypj)-bb_aq(itypi,itypj)))
2122 gg_lipj(3)=ssgradlipj*gg_lipi(3)
2123 gg_lipi(3)=gg_lipi(3)*ssgradlipi
2125 ! print *,'before sc_grad', gg(1),gg(2),gg(3)
2126 ! Calculate angular part of the gradient.
2132 ! print *,"ZALAMKA", evdw
2133 ! write (iout,*) "Number of loop steps in EGB:",ind
2134 !ccc energy_dec=.false.
2137 !-----------------------------------------------------------------------------
2138 subroutine egbv(evdw)
2140 ! This subroutine calculates the interaction energy of nonbonded side chains
2141 ! assuming the Gay-Berne-Vorobjev potential of interaction.
2145 ! implicit real*8 (a-h,o-z)
2146 ! include 'DIMENSIONS'
2147 ! include 'COMMON.GEO'
2148 ! include 'COMMON.VAR'
2149 ! include 'COMMON.LOCAL'
2150 ! include 'COMMON.CHAIN'
2151 ! include 'COMMON.DERIV'
2152 ! include 'COMMON.NAMES'
2153 ! include 'COMMON.INTERACT'
2154 ! include 'COMMON.IOUNITS'
2155 ! include 'COMMON.CALC'
2157 !el integer :: icall
2158 !el common /srutu/ icall
2161 integer :: iint,itypi,itypi1,itypj
2162 real(kind=8) :: rrij,xi,yi,zi,r0ij,fac_augm,e_augm,fac,e1,e2, &
2163 sigm,sslipi,ssgradlipi, sslipj,ssgradlipj, aa, bb
2164 real(kind=8) :: evdw,sig0ij,sig,rij_shift,epsi
2166 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
2169 ! if (icall.eq.0) lprn=.true.
2171 do i=iatsc_s,iatsc_e
2172 itypi=iabs(itype(i,1))
2173 if (itypi.eq.ntyp1) cycle
2174 itypi1=iabs(itype(i+1,1))
2178 call to_box(xi,yi,zi)
2179 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
2180 dxi=dc_norm(1,nres+i)
2181 dyi=dc_norm(2,nres+i)
2182 dzi=dc_norm(3,nres+i)
2183 ! dsci_inv=dsc_inv(itypi)
2184 dsci_inv=vbld_inv(i+nres)
2186 ! Calculate SC interaction energy.
2188 do iint=1,nint_gr(i)
2189 do j=istart(i,iint),iend(i,iint)
2191 itypj=iabs(itype(j,1))
2192 if (itypj.eq.ntyp1) cycle
2193 ! dscj_inv=dsc_inv(itypj)
2194 dscj_inv=vbld_inv(j+nres)
2195 sig0ij=sigma(itypi,itypj)
2196 r0ij=r0(itypi,itypj)
2197 chi1=chi(itypi,itypj)
2198 chi2=chi(itypj,itypi)
2205 alf12=0.5D0*(alf1+alf2)
2206 ! For diagnostics only!!!
2219 call to_box(xj,yj,zj)
2220 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
2221 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
2222 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
2223 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
2224 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
2225 xj=boxshift(xj-xi,boxxsize)
2226 yj=boxshift(yj-yi,boxysize)
2227 zj=boxshift(zj-zi,boxzsize)
2228 dxj=dc_norm(1,nres+j)
2229 dyj=dc_norm(2,nres+j)
2230 dzj=dc_norm(3,nres+j)
2231 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
2233 ! Calculate angle-dependent terms of energy and contributions to their
2237 sig=sig0ij*dsqrt(sigsq)
2238 rij_shift=1.0D0/rij-sig+r0ij
2239 ! I hate to put IF's in the loops, but here don't have another choice!!!!
2240 if (rij_shift.le.0.0D0) then
2245 !---------------------------------------------------------------
2246 rij_shift=1.0D0/rij_shift
2247 fac=rij_shift**expon
2248 e1=fac*fac*aa_aq(itypi,itypj)
2249 e2=fac*bb_aq(itypi,itypj)
2250 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
2251 eps2der=evdwij*eps3rt
2252 eps3der=evdwij*eps2rt
2253 fac_augm=rrij**expon
2254 e_augm=augm(itypi,itypj)*fac_augm
2255 evdwij=evdwij*eps2rt*eps3rt
2256 evdw=evdw+evdwij+e_augm
2258 sigm=dabs(aa_aq(itypi,itypj)/&
2259 bb_aq(itypi,itypj))**(1.0D0/6.0D0)
2260 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
2261 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
2262 restyp(itypi,1),i,restyp(itypj,1),j,&
2263 epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),&
2264 chi1,chi2,chip1,chip2,&
2265 eps1,eps2rt**2,eps3rt**2,&
2266 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
2269 ! Calculate gradient components.
2270 e1=e1*eps1*eps2rt**2*eps3rt**2
2271 fac=-expon*(e1+evdwij)*rij_shift
2273 fac=rij*fac-2*expon*rrij*e_augm
2274 ! Calculate the radial part of the gradient
2278 ! Calculate angular part of the gradient.
2284 !-----------------------------------------------------------------------------
2285 !el subroutine sc_angular in module geometry
2286 !-----------------------------------------------------------------------------
2287 subroutine e_softsphere(evdw)
2289 ! This subroutine calculates the interaction energy of nonbonded side chains
2290 ! assuming the LJ potential of interaction.
2292 ! implicit real*8 (a-h,o-z)
2293 ! include 'DIMENSIONS'
2294 real(kind=8),parameter :: accur=1.0d-10
2295 ! include 'COMMON.GEO'
2296 ! include 'COMMON.VAR'
2297 ! include 'COMMON.LOCAL'
2298 ! include 'COMMON.CHAIN'
2299 ! include 'COMMON.DERIV'
2300 ! include 'COMMON.INTERACT'
2301 ! include 'COMMON.TORSION'
2302 ! include 'COMMON.SBRIDGE'
2303 ! include 'COMMON.NAMES'
2304 ! include 'COMMON.IOUNITS'
2305 ! include 'COMMON.CONTACTS'
2306 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
2307 !d print *,'Entering Esoft_sphere nnt=',nnt,' nct=',nct
2309 integer :: i,iint,j,itypi,itypi1,itypj,k
2310 real(kind=8) :: evdw,xj,yj,zj,xi,yi,zi,rij,r0ij,r0ijsq,evdwij
2314 do i=iatsc_s,iatsc_e
2315 itypi=iabs(itype(i,1))
2316 if (itypi.eq.ntyp1) cycle
2317 itypi1=iabs(itype(i+1,1))
2321 call to_box(xi,yi,zi)
2324 ! Calculate SC interaction energy.
2326 do iint=1,nint_gr(i)
2327 !d write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
2328 !d & 'iend=',iend(i,iint)
2329 do j=istart(i,iint),iend(i,iint)
2330 itypj=iabs(itype(j,1))
2331 if (itypj.eq.ntyp1) cycle
2332 xj=boxshift(c(1,nres+j)-xi,boxxsize)
2333 yj=boxshift(c(2,nres+j)-yi,boxysize)
2334 zj=boxshift(c(3,nres+j)-zi,boxzsize)
2335 rij=xj*xj+yj*yj+zj*zj
2336 ! write (iout,*)'i=',i,' j=',j,' itypi=',itypi,' itypj=',itypj
2337 r0ij=r0(itypi,itypj)
2339 ! print *,i,j,r0ij,dsqrt(rij)
2340 if (rij.lt.r0ijsq) then
2341 evdwij=0.25d0*(rij-r0ijsq)**2
2349 ! Calculate the components of the gradient in DC and X
2355 gvdwx(k,i)=gvdwx(k,i)-gg(k)
2356 gvdwx(k,j)=gvdwx(k,j)+gg(k)
2357 gvdwc(k,i)=gvdwc(k,i)-gg(k)
2358 gvdwc(k,j)=gvdwc(k,j)+gg(k)
2362 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
2369 end subroutine e_softsphere
2370 !-----------------------------------------------------------------------------
2371 subroutine eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
2373 ! Soft-sphere potential of p-p interaction
2375 ! implicit real*8 (a-h,o-z)
2376 ! include 'DIMENSIONS'
2377 ! include 'COMMON.CONTROL'
2378 ! include 'COMMON.IOUNITS'
2379 ! include 'COMMON.GEO'
2380 ! include 'COMMON.VAR'
2381 ! include 'COMMON.LOCAL'
2382 ! include 'COMMON.CHAIN'
2383 ! include 'COMMON.DERIV'
2384 ! include 'COMMON.INTERACT'
2385 ! include 'COMMON.CONTACTS'
2386 ! include 'COMMON.TORSION'
2387 ! include 'COMMON.VECTORS'
2388 ! include 'COMMON.FFIELD'
2389 real(kind=8),dimension(3) :: ggg
2390 !d write(iout,*) 'In EELEC_soft_sphere'
2392 integer :: i,j,k,num_conti,iteli,itelj
2393 real(kind=8) :: ees,evdw1,eel_loc,eello_turn3,eello_turn4
2394 real(kind=8) :: dxi,dyi,dzi,xmedi,ymedi,zmedi,r0ij,r0ijsq
2395 real(kind=8) :: dxj,dyj,dzj,xj,yj,zj,rij,evdw1ij,fac
2403 do i=iatel_s,iatel_e
2404 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
2408 xmedi=c(1,i)+0.5d0*dxi
2409 ymedi=c(2,i)+0.5d0*dyi
2410 zmedi=c(3,i)+0.5d0*dzi
2411 call to_box(xmedi,ymedi,zmedi)
2413 ! write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
2414 do j=ielstart(i),ielend(i)
2415 if (itype(j,1).eq.ntyp1 .or. itype(j+1,1).eq.ntyp1) cycle
2419 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
2420 r0ij=rpp(iteli,itelj)
2425 xj=c(1,j)+0.5D0*dxj-xmedi
2426 yj=c(2,j)+0.5D0*dyj-ymedi
2427 zj=c(3,j)+0.5D0*dzj-zmedi
2428 call to_box(xj,yj,zj)
2429 xj=boxshift(xj-xmedi,boxxsize)
2430 yj=boxshift(yj-ymedi,boxysize)
2431 zj=boxshift(zj-zmedi,boxzsize)
2432 rij=xj*xj+yj*yj+zj*zj
2433 if (rij.lt.r0ijsq) then
2434 evdw1ij=0.25d0*(rij-r0ijsq)**2
2442 ! Calculate contributions to the Cartesian gradient.
2448 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
2449 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
2452 ! Loop over residues i+1 thru j-1.
2456 !grad gelc(l,k)=gelc(l,k)+ggg(l)
2461 !grad do i=nnt,nct-1
2463 !grad gelc(k,i)=gelc(k,i)+0.5d0*gelc(k,i)
2465 !grad do j=i+1,nct-1
2467 !grad gelc(k,i)=gelc(k,i)+gelc(k,j)
2472 end subroutine eelec_soft_sphere
2473 !-----------------------------------------------------------------------------
2474 subroutine vec_and_deriv
2475 ! implicit real*8 (a-h,o-z)
2476 ! include 'DIMENSIONS'
2480 ! include 'COMMON.IOUNITS'
2481 ! include 'COMMON.GEO'
2482 ! include 'COMMON.VAR'
2483 ! include 'COMMON.LOCAL'
2484 ! include 'COMMON.CHAIN'
2485 ! include 'COMMON.VECTORS'
2486 ! include 'COMMON.SETUP'
2487 ! include 'COMMON.TIME1'
2488 real(kind=8),dimension(3,3,2) :: uyder,uzder
2489 real(kind=8),dimension(2) :: vbld_inv_temp
2490 ! Compute the local reference systems. For reference system (i), the
2491 ! X-axis points from CA(i) to CA(i+1), the Y axis is in the
2492 ! CA(i)-CA(i+1)-CA(i+2) plane, and the Z axis is perpendicular to this plane.
2495 real(kind=8) :: facy,fac,costh
2498 do i=ivec_start,ivec_end
2502 if (i.eq.nres-1) then
2503 ! Case of the last full residue
2504 ! Compute the Z-axis
2505 call vecpr(dc_norm(1,i),dc_norm(1,i-1),uz(1,i))
2506 costh=dcos(pi-theta(nres))
2507 fac=1.0d0/dsqrt(1.0d0-costh*costh)
2511 ! Compute the derivatives of uz
2513 uzder(2,1,1)=-dc_norm(3,i-1)
2514 uzder(3,1,1)= dc_norm(2,i-1)
2515 uzder(1,2,1)= dc_norm(3,i-1)
2517 uzder(3,2,1)=-dc_norm(1,i-1)
2518 uzder(1,3,1)=-dc_norm(2,i-1)
2519 uzder(2,3,1)= dc_norm(1,i-1)
2522 uzder(2,1,2)= dc_norm(3,i)
2523 uzder(3,1,2)=-dc_norm(2,i)
2524 uzder(1,2,2)=-dc_norm(3,i)
2526 uzder(3,2,2)= dc_norm(1,i)
2527 uzder(1,3,2)= dc_norm(2,i)
2528 uzder(2,3,2)=-dc_norm(1,i)
2530 ! Compute the Y-axis
2533 uy(k,i)=fac*(dc_norm(k,i-1)-costh*dc_norm(k,i))
2535 ! Compute the derivatives of uy
2538 uyder(k,j,1)=2*dc_norm(k,i-1)*dc_norm(j,i) &
2539 -dc_norm(k,i)*dc_norm(j,i-1)
2540 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
2542 uyder(j,j,1)=uyder(j,j,1)-costh
2543 uyder(j,j,2)=1.0d0+uyder(j,j,2)
2548 uygrad(l,k,j,i)=uyder(l,k,j)
2549 uzgrad(l,k,j,i)=uzder(l,k,j)
2553 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
2554 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
2555 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
2556 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
2559 ! Compute the Z-axis
2560 call vecpr(dc_norm(1,i),dc_norm(1,i+1),uz(1,i))
2561 costh=dcos(pi-theta(i+2))
2562 fac=1.0d0/dsqrt(1.0d0-costh*costh)
2566 ! Compute the derivatives of uz
2568 uzder(2,1,1)=-dc_norm(3,i+1)
2569 uzder(3,1,1)= dc_norm(2,i+1)
2570 uzder(1,2,1)= dc_norm(3,i+1)
2572 uzder(3,2,1)=-dc_norm(1,i+1)
2573 uzder(1,3,1)=-dc_norm(2,i+1)
2574 uzder(2,3,1)= dc_norm(1,i+1)
2577 uzder(2,1,2)= dc_norm(3,i)
2578 uzder(3,1,2)=-dc_norm(2,i)
2579 uzder(1,2,2)=-dc_norm(3,i)
2581 uzder(3,2,2)= dc_norm(1,i)
2582 uzder(1,3,2)= dc_norm(2,i)
2583 uzder(2,3,2)=-dc_norm(1,i)
2585 ! Compute the Y-axis
2588 uy(k,i)=facy*(dc_norm(k,i+1)-costh*dc_norm(k,i))
2590 ! Compute the derivatives of uy
2593 uyder(k,j,1)=2*dc_norm(k,i+1)*dc_norm(j,i) &
2594 -dc_norm(k,i)*dc_norm(j,i+1)
2595 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
2597 uyder(j,j,1)=uyder(j,j,1)-costh
2598 uyder(j,j,2)=1.0d0+uyder(j,j,2)
2603 uygrad(l,k,j,i)=uyder(l,k,j)
2604 uzgrad(l,k,j,i)=uzder(l,k,j)
2608 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
2609 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
2610 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
2611 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
2615 vbld_inv_temp(1)=vbld_inv(i+1)
2616 if (i.lt.nres-1) then
2617 vbld_inv_temp(2)=vbld_inv(i+2)
2619 vbld_inv_temp(2)=vbld_inv(i)
2624 uygrad(l,k,j,i)=vbld_inv_temp(j)*uygrad(l,k,j,i)
2625 uzgrad(l,k,j,i)=vbld_inv_temp(j)*uzgrad(l,k,j,i)
2630 #if defined(PARVEC) && defined(MPI)
2631 if (nfgtasks1.gt.1) then
2633 ! print *,"Processor",fg_rank1,kolor1," ivec_start",ivec_start,
2634 ! & " ivec_displ",(ivec_displ(i),i=0,nfgtasks1-1),
2635 ! & " ivec_count",(ivec_count(i),i=0,nfgtasks1-1)
2636 call MPI_Allgatherv(uy(1,ivec_start),ivec_count(fg_rank1),&
2637 MPI_UYZ,uy(1,1),ivec_count(0),ivec_displ(0),MPI_UYZ,&
2639 call MPI_Allgatherv(uz(1,ivec_start),ivec_count(fg_rank1),&
2640 MPI_UYZ,uz(1,1),ivec_count(0),ivec_displ(0),MPI_UYZ,&
2642 call MPI_Allgatherv(uygrad(1,1,1,ivec_start),&
2643 ivec_count(fg_rank1),MPI_UYZGRAD,uygrad(1,1,1,1),ivec_count(0),&
2644 ivec_displ(0),MPI_UYZGRAD,FG_COMM1,IERR)
2645 call MPI_Allgatherv(uzgrad(1,1,1,ivec_start),&
2646 ivec_count(fg_rank1),MPI_UYZGRAD,uzgrad(1,1,1,1),ivec_count(0),&
2647 ivec_displ(0),MPI_UYZGRAD,FG_COMM1,IERR)
2648 time_gather=time_gather+MPI_Wtime()-time00
2650 ! if (fg_rank.eq.0) then
2651 ! write (iout,*) "Arrays UY and UZ"
2653 ! write (iout,'(i5,3f10.5,5x,3f10.5)') i,(uy(k,i),k=1,3),
2659 end subroutine vec_and_deriv
2660 !-----------------------------------------------------------------------------
2661 subroutine check_vecgrad
2662 ! implicit real*8 (a-h,o-z)
2663 ! include 'DIMENSIONS'
2664 ! include 'COMMON.IOUNITS'
2665 ! include 'COMMON.GEO'
2666 ! include 'COMMON.VAR'
2667 ! include 'COMMON.LOCAL'
2668 ! include 'COMMON.CHAIN'
2669 ! include 'COMMON.VECTORS'
2670 real(kind=8),dimension(3,3,2,nres) :: uygradt,uzgradt !(3,3,2,maxres)
2671 real(kind=8),dimension(3,nres) :: uyt,uzt !(3,maxres)
2672 real(kind=8),dimension(3,3,2) :: uygradn,uzgradn
2673 real(kind=8),dimension(3) :: erij
2674 real(kind=8) :: delta=1.0d-7
2680 !rc write(iout,'(2i5,2(3f10.5,5x))') i,1,dc_norm(:,i)
2681 !rc write(iout,'(2i5,2(3f10.5,5x))') i,2,uy(:,i)
2682 !rc write(iout,'(2i5,2(3f10.5,5x)/)')i,3,uz(:,i)
2683 !d write(iout,'(2i5,2(3f10.5,5x))') i,1,
2684 !d & (dc_norm(if90,i),if90=1,3)
2685 !d write(iout,'(2i5,2(3f10.5,5x))') i,2,(uy(if90,i),if90=1,3)
2686 !d write(iout,'(2i5,2(3f10.5,5x)/)')i,3,(uz(if90,i),if90=1,3)
2687 !d write(iout,'(a)')
2693 uygradt(l,k,j,i)=uygrad(l,k,j,i)
2694 uzgradt(l,k,j,i)=uzgrad(l,k,j,i)
2707 !d write (iout,*) 'i=',i
2709 erij(k)=dc_norm(k,i)
2713 dc_norm(k,i)=erij(k)
2715 dc_norm(j,i)=dc_norm(j,i)+delta
2716 ! fac=dsqrt(scalar(dc_norm(1,i),dc_norm(1,i)))
2718 ! dc_norm(k,i)=dc_norm(k,i)/fac
2720 ! write (iout,*) (dc_norm(k,i),k=1,3)
2721 ! write (iout,*) (erij(k),k=1,3)
2724 uygradn(k,j,1)=(uy(k,i)-uyt(k,i))/delta
2725 uygradn(k,j,2)=(uy(k,i-1)-uyt(k,i-1))/delta
2726 uzgradn(k,j,1)=(uz(k,i)-uzt(k,i))/delta
2727 uzgradn(k,j,2)=(uz(k,i-1)-uzt(k,i-1))/delta
2729 ! write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2730 ! & j,(uzgradt(k,j,1,i),k=1,3),(uzgradn(k,j,1),k=1,3),
2731 ! & (uzgradt(k,j,2,i-1),k=1,3),(uzgradn(k,j,2),k=1,3)
2734 dc_norm(k,i)=erij(k)
2737 !d write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2738 !d & k,(uygradt(k,l,1,i),l=1,3),(uygradn(k,l,1),l=1,3),
2739 !d & (uygradt(k,l,2,i-1),l=1,3),(uygradn(k,l,2),l=1,3)
2740 !d write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2741 !d & k,(uzgradt(k,l,1,i),l=1,3),(uzgradn(k,l,1),l=1,3),
2742 !d & (uzgradt(k,l,2,i-1),l=1,3),(uzgradn(k,l,2),l=1,3)
2743 !d write (iout,'(a)')
2747 end subroutine check_vecgrad
2748 !-----------------------------------------------------------------------------
2749 subroutine set_matrices
2750 ! implicit real*8 (a-h,o-z)
2751 ! include 'DIMENSIONS'
2754 ! include "COMMON.SETUP"
2756 integer :: status(MPI_STATUS_SIZE)
2758 ! include 'COMMON.IOUNITS'
2759 ! include 'COMMON.GEO'
2760 ! include 'COMMON.VAR'
2761 ! include 'COMMON.LOCAL'
2762 ! include 'COMMON.CHAIN'
2763 ! include 'COMMON.DERIV'
2764 ! include 'COMMON.INTERACT'
2765 ! include 'COMMON.CONTACTS'
2766 ! include 'COMMON.TORSION'
2767 ! include 'COMMON.VECTORS'
2768 ! include 'COMMON.FFIELD'
2769 real(kind=8) :: auxvec(2),auxmat(2,2)
2770 integer :: i,iti1,iti,k,l
2771 real(kind=8) :: sin1,cos1,sin2,cos2,dwacos2,dwasin2,cost1,sint1,&
2772 sint1sq,sint1cub,sint1cost1,b1k,b2k,aux
2773 ! print *,"in set matrices"
2775 ! Compute the virtual-bond-torsional-angle dependent quantities needed
2776 ! to calculate the el-loc multibody terms of various order.
2781 do i=ivec_start+2,ivec_end+2
2785 if (i.gt. nnt+2 .and. i.lt.nct+2) then
2786 if (itype(i-2,1).eq.0) then
2789 iti = itype2loc(itype(i-2,1))
2794 !c if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
2795 if (i.gt. nnt+1 .and. i.lt.nct+1) then
2796 iti1 = itype2loc(itype(i-1,1))
2800 ! print *,i,itype(i-2,1),iti
2802 cost1=dcos(theta(i-1))
2803 sint1=dsin(theta(i-1))
2805 sint1cub=sint1sq*sint1
2806 sint1cost1=2*sint1*cost1
2807 ! print *,"cost1",cost1,theta(i-1)
2808 !c write (iout,*) "bnew1",i,iti
2809 !c write (iout,*) (bnew1(k,1,iti),k=1,3)
2810 !c write (iout,*) (bnew1(k,2,iti),k=1,3)
2811 !c write (iout,*) "bnew2",i,iti
2812 !c write (iout,*) (bnew2(k,1,iti),k=1,3)
2813 !c write (iout,*) (bnew2(k,2,iti),k=1,3)
2815 ! print *,bnew1(1,k,iti),"bnew1"
2817 b1k=bnew1(1,k,iti)+(bnew1(2,k,iti)+bnew1(3,k,iti)*cost1)*cost1
2819 ! write(*,*) shape(b1)
2820 ! if(.not.allocated(b1)) print *, "WTF?"
2825 gtb1(k,i-2)=cost1*b1k-sint1sq*&
2826 (bnew1(2,k,iti)+2*bnew1(3,k,iti)*cost1)
2827 ! print *,gtb1(k,i-2)
2829 b2k=bnew2(1,k,iti)+(bnew2(2,k,iti)+bnew2(3,k,iti)*cost1)*cost1
2833 gtb2(k,i-2)=cost1*b2k-sint1sq*&
2834 (bnew2(2,k,iti)+2*bnew2(3,k,iti)*cost1)
2835 ! print *,gtb2(k,i-2)
2840 aux=ccnew(1,k,iti)+(ccnew(2,k,iti)+ccnew(3,k,iti)*cost1)*cost1
2841 cc(1,k,i-2)=sint1sq*aux
2842 gtcc(1,k,i-2)=sint1cost1*aux-sint1cub*&
2843 (ccnew(2,k,iti)+2*ccnew(3,k,iti)*cost1)
2844 aux=ddnew(1,k,iti)+(ddnew(2,k,iti)+ddnew(3,k,iti)*cost1)*cost1
2845 dd(1,k,i-2)=sint1sq*aux
2846 gtdd(1,k,i-2)=sint1cost1*aux-sint1cub*&
2847 (ddnew(2,k,iti)+2*ddnew(3,k,iti)*cost1)
2849 ! print *,"after cc"
2850 cc(2,1,i-2)=cc(1,2,i-2)
2851 cc(2,2,i-2)=-cc(1,1,i-2)
2852 gtcc(2,1,i-2)=gtcc(1,2,i-2)
2853 gtcc(2,2,i-2)=-gtcc(1,1,i-2)
2854 dd(2,1,i-2)=dd(1,2,i-2)
2855 dd(2,2,i-2)=-dd(1,1,i-2)
2856 gtdd(2,1,i-2)=gtdd(1,2,i-2)
2857 gtdd(2,2,i-2)=-gtdd(1,1,i-2)
2858 ! print *,"after dd"
2862 aux=eenew(1,l,k,iti)+eenew(2,l,k,iti)*cost1
2863 EE(l,k,i-2)=sint1sq*aux
2864 gtEE(l,k,i-2)=sint1cost1*aux-sint1cub*eenew(2,l,k,iti)
2867 EE(1,1,i-2)=EE(1,1,i-2)+e0new(1,iti)*cost1
2868 EE(1,2,i-2)=EE(1,2,i-2)+e0new(2,iti)+e0new(3,iti)*cost1
2869 EE(2,1,i-2)=EE(2,1,i-2)+e0new(2,iti)*cost1+e0new(3,iti)
2870 EE(2,2,i-2)=EE(2,2,i-2)-e0new(1,iti)
2871 gtEE(1,1,i-2)=gtEE(1,1,i-2)-e0new(1,iti)*sint1
2872 gtEE(1,2,i-2)=gtEE(1,2,i-2)-e0new(3,iti)*sint1
2873 gtEE(2,1,i-2)=gtEE(2,1,i-2)-e0new(2,iti)*sint1
2874 ! print *,"after ee"
2876 !c b1tilde(1,i-2)=b1(1,i-2)
2877 !c b1tilde(2,i-2)=-b1(2,i-2)
2878 !c b2tilde(1,i-2)=b2(1,i-2)
2879 !c b2tilde(2,i-2)=-b2(2,i-2)
2881 write (iout,*) 'i=',i-2,gtb1(2,i-2),gtb1(1,i-2)
2882 write(iout,*) 'b1=',(b1(k,i-2),k=1,2)
2883 write(iout,*) 'b2=',(b2(k,i-2),k=1,2)
2884 write (iout,*) 'theta=', theta(i-1)
2887 if (i.gt. nnt+2 .and. i.lt.nct+2) then
2888 ! write(iout,*) "i,",molnum(i),nloctyp
2889 ! print *, "i,",molnum(i),i,itype(i-2,1)
2890 if (molnum(i).eq.1) then
2891 if (itype(i-2,1).eq.ntyp1) then
2894 iti = itype2loc(itype(i-2,1))
2902 !c write (iout,*) "i",i-1," itype",itype(i-2)," iti",iti
2903 !c if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
2904 if (i.gt. nnt+1 .and. i.lt.nct+1) then
2905 iti1 = itype2loc(itype(i-1,1))
2916 CC(k,l,i-2)=ccold(k,l,iti)
2917 DD(k,l,i-2)=ddold(k,l,iti)
2918 EE(k,l,i-2)=eeold(k,l,iti)
2922 b1tilde(1,i-2)= b1(1,i-2)
2923 b1tilde(2,i-2)=-b1(2,i-2)
2924 b2tilde(1,i-2)= b2(1,i-2)
2925 b2tilde(2,i-2)=-b2(2,i-2)
2927 Ctilde(1,1,i-2)= CC(1,1,i-2)
2928 Ctilde(1,2,i-2)= CC(1,2,i-2)
2929 Ctilde(2,1,i-2)=-CC(2,1,i-2)
2930 Ctilde(2,2,i-2)=-CC(2,2,i-2)
2932 Dtilde(1,1,i-2)= DD(1,1,i-2)
2933 Dtilde(1,2,i-2)= DD(1,2,i-2)
2934 Dtilde(2,1,i-2)=-DD(2,1,i-2)
2935 Dtilde(2,2,i-2)=-DD(2,2,i-2)
2938 do i=ivec_start+2,ivec_end+2
2944 if (i .lt. nres+1) then
2981 if (i .gt. 3 .and. i .lt. nres+1) then
2982 obrot_der(1,i-2)=-sin1
2983 obrot_der(2,i-2)= cos1
2984 Ugder(1,1,i-2)= sin1
2985 Ugder(1,2,i-2)=-cos1
2986 Ugder(2,1,i-2)=-cos1
2987 Ugder(2,2,i-2)=-sin1
2990 obrot2_der(1,i-2)=-dwasin2
2991 obrot2_der(2,i-2)= dwacos2
2992 Ug2der(1,1,i-2)= dwasin2
2993 Ug2der(1,2,i-2)=-dwacos2
2994 Ug2der(2,1,i-2)=-dwacos2
2995 Ug2der(2,2,i-2)=-dwasin2
2997 obrot_der(1,i-2)=0.0d0
2998 obrot_der(2,i-2)=0.0d0
2999 Ugder(1,1,i-2)=0.0d0
3000 Ugder(1,2,i-2)=0.0d0
3001 Ugder(2,1,i-2)=0.0d0
3002 Ugder(2,2,i-2)=0.0d0
3003 obrot2_der(1,i-2)=0.0d0
3004 obrot2_der(2,i-2)=0.0d0
3005 Ug2der(1,1,i-2)=0.0d0
3006 Ug2der(1,2,i-2)=0.0d0
3007 Ug2der(2,1,i-2)=0.0d0
3008 Ug2der(2,2,i-2)=0.0d0
3010 ! if (i.gt. iatel_s+2 .and. i.lt.iatel_e+5) then
3011 if (i.gt. nnt+2 .and. i.lt.nct+2) then
3012 if (itype(i-2,1).eq.0) then
3015 iti = itype2loc(itype(i-2,1))
3020 ! if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
3021 if (i.gt. nnt+1 .and. i.lt.nct+1) then
3022 if (itype(i-1,1).eq.0) then
3025 iti1 = itype2loc(itype(i-1,1))
3030 ! print *,iti,i,"iti",iti1,itype(i-1,1),itype(i-2,1)
3031 !d write (iout,*) '*******i',i,' iti1',iti
3032 ! write (iout,*) 'b1',b1(:,iti)
3033 ! write (iout,*) 'b2',b2(:,i-2)
3034 !d write (iout,*) 'Ug',Ug(:,:,i-2)
3035 ! if (i .gt. iatel_s+2) then
3036 if (i .gt. nnt+2) then
3037 call matvec2(Ug(1,1,i-2),b2(1,i-2),Ub2(1,i-2))
3039 call matvec2(Ug(1,1,i-2),gtb2(1,i-2),gUb2(1,i-2))
3040 !c write (iout,*) Ug(1,1,i-2),gtb2(1,i-2),gUb2(1,i-2),"chuj"
3043 call matmat2(EE(1,1,i-2),Ug(1,1,i-2),EUg(1,1,i-2))
3044 call matmat2(gtEE(1,1,i-2),Ug(1,1,i-2),gtEUg(1,1,i-2))
3045 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) &
3047 call matmat2(CC(1,1,i-2),Ug(1,1,i-2),CUg(1,1,i-2))
3048 call matmat2(DD(1,1,i-2),Ug(1,1,i-2),DUg(1,1,i-2))
3049 call matmat2(Dtilde(1,1,i-2),Ug2(1,1,i-2),DtUg2(1,1,i-2))
3050 call matvec2(Ctilde(1,1,i-1),obrot(1,i-2),Ctobr(1,i-2))
3051 call matvec2(Dtilde(1,1,i-2),obrot2(1,i-2),Dtobr2(1,i-2))
3062 DtUg2(l,k,i-2)=0.0d0
3066 call matvec2(Ugder(1,1,i-2),b2(1,i-2),Ub2der(1,i-2))
3067 call matmat2(EE(1,1,i-2),Ugder(1,1,i-2),EUgder(1,1,i-2))
3069 muder(k,i-2)=Ub2der(k,i-2)
3071 ! if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
3072 if (i.gt. nnt+1 .and. i.lt.nct+1) then
3073 if (itype(i-1,1).eq.0) then
3075 elseif (itype(i-1,1).le.ntyp) then
3076 iti1 = itype2loc(itype(i-1,1))
3084 mu(k,i-2)=Ub2(k,i-2)+b1(k,i-1)
3086 if (energy_dec) write (iout,*) 'Ub2 ',i,Ub2(:,i-2)
3087 if (energy_dec) write (iout,*) 'b1 ',iti1,b1(:,i-1)
3088 if (energy_dec) write (iout,*) 'mu ',i,iti1,mu(:,i-2)
3089 !d write (iout,*) 'mu1',mu1(:,i-2)
3090 !d write (iout,*) 'mu2',mu2(:,i-2)
3091 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.wcorr6.gt.0.0d0) &
3093 call matmat2(CC(1,1,i-1),Ugder(1,1,i-2),CUgder(1,1,i-2))
3094 call matmat2(DD(1,1,i-2),Ugder(1,1,i-2),DUgder(1,1,i-2))
3095 call matmat2(Dtilde(1,1,i-2),Ug2der(1,1,i-2),DtUg2der(1,1,i-2))
3096 call matvec2(Ctilde(1,1,i-1),obrot_der(1,i-2),Ctobrder(1,i-2))
3097 call matvec2(Dtilde(1,1,i-2),obrot2_der(1,i-2),Dtobr2der(1,i-2))
3098 ! Vectors and matrices dependent on a single virtual-bond dihedral.
3099 call matvec2(DD(1,1,i-2),b1tilde(1,i-1),auxvec(1))
3100 call matvec2(Ug2(1,1,i-2),auxvec(1),Ug2Db1t(1,i-2))
3101 call matvec2(Ug2der(1,1,i-2),auxvec(1),Ug2Db1tder(1,i-2))
3102 call matvec2(CC(1,1,i-1),Ub2(1,i-2),CUgb2(1,i-2))
3103 call matvec2(CC(1,1,i-1),Ub2der(1,i-2),CUgb2der(1,i-2))
3104 call matmat2(EUg(1,1,i-2),CC(1,1,iti1),EUgC(1,1,i-2))
3105 call matmat2(EUgder(1,1,i-2),CC(1,1,iti1),EUgCder(1,1,i-2))
3106 call matmat2(EUg(1,1,i-2),DD(1,1,iti1),EUgD(1,1,i-2))
3107 call matmat2(EUgder(1,1,i-2),DD(1,1,iti1),EUgDder(1,1,i-2))
3110 ! Matrices dependent on two consecutive virtual-bond dihedrals.
3111 ! The order of matrices is from left to right.
3112 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.wcorr6.gt.0.0d0) &
3114 ! do i=max0(ivec_start,2),ivec_end
3116 call matmat2(DtUg2(1,1,i-1),EUg(1,1,i),DtUg2EUg(1,1,i))
3117 call matmat2(DtUg2der(1,1,i-1),EUg(1,1,i),DtUg2EUgder(1,1,1,i))
3118 call matmat2(DtUg2(1,1,i-1),EUgder(1,1,i),DtUg2EUgder(1,1,2,i))
3119 call transpose2(DtUg2(1,1,i-1),auxmat(1,1))
3120 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUg(1,1,i))
3121 call matmat2(auxmat(1,1),EUgder(1,1,i),Ug2DtEUgder(1,1,2,i))
3122 call transpose2(DtUg2der(1,1,i-1),auxmat(1,1))
3123 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUgder(1,1,1,i))
3126 #if defined(MPI) && defined(PARMAT)
3128 ! if (fg_rank.eq.0) then
3129 write (iout,*) "Arrays UG and UGDER before GATHER"
3131 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
3132 ((ug(l,k,i),l=1,2),k=1,2),&
3133 ((ugder(l,k,i),l=1,2),k=1,2)
3135 write (iout,*) "Arrays UG2 and UG2DER"
3137 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
3138 ((ug2(l,k,i),l=1,2),k=1,2),&
3139 ((ug2der(l,k,i),l=1,2),k=1,2)
3141 write (iout,*) "Arrays OBROT OBROT2 OBROTDER and OBROT2DER"
3143 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
3144 (obrot(k,i),k=1,2),(obrot2(k,i),k=1,2),&
3145 (obrot_der(k,i),k=1,2),(obrot2_der(k,i),k=1,2)
3147 write (iout,*) "Arrays COSTAB SINTAB COSTAB2 and SINTAB2"
3149 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
3150 costab(i),sintab(i),costab2(i),sintab2(i)
3152 write (iout,*) "Array MUDER"
3154 write (iout,'(i5,2f10.5)') i,muder(1,i),muder(2,i)
3158 if (nfgtasks.gt.1) then
3160 ! write(iout,*)"Processor",fg_rank,kolor," ivec_start",ivec_start,
3161 ! & " ivec_displ",(ivec_displ(i),i=0,nfgtasks-1),
3162 ! & " ivec_count",(ivec_count(i),i=0,nfgtasks-1)
3164 call MPI_Allgatherv(Ub2(1,ivec_start),ivec_count(fg_rank1),&
3165 MPI_MU,Ub2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
3167 call MPI_Allgatherv(Ub2der(1,ivec_start),ivec_count(fg_rank1),&
3168 MPI_MU,Ub2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
3170 call MPI_Allgatherv(mu(1,ivec_start),ivec_count(fg_rank1),&
3171 MPI_MU,mu(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
3173 call MPI_Allgatherv(muder(1,ivec_start),ivec_count(fg_rank1),&
3174 MPI_MU,muder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
3176 call MPI_Allgatherv(Eug(1,1,ivec_start),ivec_count(fg_rank1),&
3177 MPI_MAT1,Eug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3179 call MPI_Allgatherv(Eugder(1,1,ivec_start),ivec_count(fg_rank1),&
3180 MPI_MAT1,Eugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3182 call MPI_Allgatherv(costab(ivec_start),ivec_count(fg_rank1),&
3183 MPI_DOUBLE_PRECISION,costab(1),ivec_count(0),ivec_displ(0),&
3184 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
3185 call MPI_Allgatherv(sintab(ivec_start),ivec_count(fg_rank1),&
3186 MPI_DOUBLE_PRECISION,sintab(1),ivec_count(0),ivec_displ(0),&
3187 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
3188 call MPI_Allgatherv(costab2(ivec_start),ivec_count(fg_rank1),&
3189 MPI_DOUBLE_PRECISION,costab2(1),ivec_count(0),ivec_displ(0),&
3190 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
3191 call MPI_Allgatherv(sintab2(ivec_start),ivec_count(fg_rank1),&
3192 MPI_DOUBLE_PRECISION,sintab2(1),ivec_count(0),ivec_displ(0),&
3193 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
3194 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) &
3196 call MPI_Allgatherv(Ctobr(1,ivec_start),ivec_count(fg_rank1),&
3197 MPI_MU,Ctobr(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
3199 call MPI_Allgatherv(Ctobrder(1,ivec_start),ivec_count(fg_rank1),&
3200 MPI_MU,Ctobrder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
3202 call MPI_Allgatherv(Dtobr2(1,ivec_start),ivec_count(fg_rank1),&
3203 MPI_MU,Dtobr2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
3205 call MPI_Allgatherv(Dtobr2der(1,ivec_start),ivec_count(fg_rank1),&
3206 MPI_MU,Dtobr2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
3208 call MPI_Allgatherv(Ug2Db1t(1,ivec_start),ivec_count(fg_rank1),&
3209 MPI_MU,Ug2Db1t(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
3211 call MPI_Allgatherv(Ug2Db1tder(1,ivec_start),&
3212 ivec_count(fg_rank1),&
3213 MPI_MU,Ug2Db1tder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
3215 call MPI_Allgatherv(CUgb2(1,ivec_start),ivec_count(fg_rank1),&
3216 MPI_MU,CUgb2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
3218 call MPI_Allgatherv(CUgb2der(1,ivec_start),ivec_count(fg_rank1),&
3219 MPI_MU,CUgb2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
3221 call MPI_Allgatherv(Cug(1,1,ivec_start),ivec_count(fg_rank1),&
3222 MPI_MAT1,Cug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3224 call MPI_Allgatherv(Cugder(1,1,ivec_start),ivec_count(fg_rank1),&
3225 MPI_MAT1,Cugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3227 call MPI_Allgatherv(Dug(1,1,ivec_start),ivec_count(fg_rank1),&
3228 MPI_MAT1,Dug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3230 call MPI_Allgatherv(Dugder(1,1,ivec_start),ivec_count(fg_rank1),&
3231 MPI_MAT1,Dugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3233 call MPI_Allgatherv(Dtug2(1,1,ivec_start),ivec_count(fg_rank1),&
3234 MPI_MAT1,Dtug2(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3236 call MPI_Allgatherv(Dtug2der(1,1,ivec_start),&
3237 ivec_count(fg_rank1),&
3238 MPI_MAT1,Dtug2der(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3240 call MPI_Allgatherv(EugC(1,1,ivec_start),ivec_count(fg_rank1),&
3241 MPI_MAT1,EugC(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3243 call MPI_Allgatherv(EugCder(1,1,ivec_start),ivec_count(fg_rank1),&
3244 MPI_MAT1,EugCder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3246 call MPI_Allgatherv(EugD(1,1,ivec_start),ivec_count(fg_rank1),&
3247 MPI_MAT1,EugD(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3249 call MPI_Allgatherv(EugDder(1,1,ivec_start),ivec_count(fg_rank1),&
3250 MPI_MAT1,EugDder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3252 call MPI_Allgatherv(DtUg2EUg(1,1,ivec_start),&
3253 ivec_count(fg_rank1),&
3254 MPI_MAT1,DtUg2EUg(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3256 call MPI_Allgatherv(Ug2DtEUg(1,1,ivec_start),&
3257 ivec_count(fg_rank1),&
3258 MPI_MAT1,Ug2DtEUg(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3260 call MPI_Allgatherv(DtUg2EUgder(1,1,1,ivec_start),&
3261 ivec_count(fg_rank1),&
3262 MPI_MAT2,DtUg2EUgder(1,1,1,1),ivec_count(0),ivec_displ(0),&
3263 MPI_MAT2,FG_COMM1,IERR)
3264 call MPI_Allgatherv(Ug2DtEUgder(1,1,1,ivec_start),&
3265 ivec_count(fg_rank1),&
3266 MPI_MAT2,Ug2DtEUgder(1,1,1,1),ivec_count(0),ivec_displ(0),&
3267 MPI_MAT2,FG_COMM1,IERR)
3270 ! Passes matrix info through the ring
3273 if (irecv.lt.0) irecv=nfgtasks1-1
3276 if (inext.ge.nfgtasks1) inext=0
3278 ! write (iout,*) "isend",isend," irecv",irecv
3280 lensend=lentyp(isend)
3281 lenrecv=lentyp(irecv)
3282 ! write (iout,*) "lensend",lensend," lenrecv",lenrecv
3283 ! call MPI_SENDRECV(ug(1,1,ivec_displ(isend)+1),1,
3284 ! & MPI_ROTAT1(lensend),inext,2200+isend,
3285 ! & ug(1,1,ivec_displ(irecv)+1),1,MPI_ROTAT1(lenrecv),
3286 ! & iprev,2200+irecv,FG_COMM,status,IERR)
3287 ! write (iout,*) "Gather ROTAT1"
3289 ! call MPI_SENDRECV(obrot(1,ivec_displ(isend)+1),1,
3290 ! & MPI_ROTAT2(lensend),inext,3300+isend,
3291 ! & obrot(1,ivec_displ(irecv)+1),1,MPI_ROTAT2(lenrecv),
3292 ! & iprev,3300+irecv,FG_COMM,status,IERR)
3293 ! write (iout,*) "Gather ROTAT2"
3295 call MPI_SENDRECV(costab(ivec_displ(isend)+1),1,&
3296 MPI_ROTAT_OLD(lensend),inext,4400+isend,&
3297 costab(ivec_displ(irecv)+1),1,MPI_ROTAT_OLD(lenrecv),&
3298 iprev,4400+irecv,FG_COMM,status,IERR)
3299 ! write (iout,*) "Gather ROTAT_OLD"
3301 call MPI_SENDRECV(mu(1,ivec_displ(isend)+1),1,&
3302 MPI_PRECOMP11(lensend),inext,5500+isend,&
3303 mu(1,ivec_displ(irecv)+1),1,MPI_PRECOMP11(lenrecv),&
3304 iprev,5500+irecv,FG_COMM,status,IERR)
3305 ! write (iout,*) "Gather PRECOMP11"
3307 call MPI_SENDRECV(Eug(1,1,ivec_displ(isend)+1),1,&
3308 MPI_PRECOMP12(lensend),inext,6600+isend,&
3309 Eug(1,1,ivec_displ(irecv)+1),1,MPI_PRECOMP12(lenrecv),&
3310 iprev,6600+irecv,FG_COMM,status,IERR)
3311 ! write (iout,*) "Gather PRECOMP12"
3313 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) &
3315 call MPI_SENDRECV(ug2db1t(1,ivec_displ(isend)+1),1,&
3316 MPI_ROTAT2(lensend),inext,7700+isend,&
3317 ug2db1t(1,ivec_displ(irecv)+1),1,MPI_ROTAT2(lenrecv),&
3318 iprev,7700+irecv,FG_COMM,status,IERR)
3319 ! write (iout,*) "Gather PRECOMP21"
3321 call MPI_SENDRECV(EUgC(1,1,ivec_displ(isend)+1),1,&
3322 MPI_PRECOMP22(lensend),inext,8800+isend,&
3323 EUgC(1,1,ivec_displ(irecv)+1),1,MPI_PRECOMP22(lenrecv),&
3324 iprev,8800+irecv,FG_COMM,status,IERR)
3325 ! write (iout,*) "Gather PRECOMP22"
3327 call MPI_SENDRECV(Ug2DtEUgder(1,1,1,ivec_displ(isend)+1),1,&
3328 MPI_PRECOMP23(lensend),inext,9900+isend,&
3329 Ug2DtEUgder(1,1,1,ivec_displ(irecv)+1),1,&
3330 MPI_PRECOMP23(lenrecv),&
3331 iprev,9900+irecv,FG_COMM,status,IERR)
3332 ! write (iout,*) "Gather PRECOMP23"
3337 if (irecv.lt.0) irecv=nfgtasks1-1
3340 time_gather=time_gather+MPI_Wtime()-time00
3343 ! if (fg_rank.eq.0) then
3344 write (iout,*) "Arrays UG and UGDER"
3346 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
3347 ((ug(l,k,i),l=1,2),k=1,2),&
3348 ((ugder(l,k,i),l=1,2),k=1,2)
3350 write (iout,*) "Arrays UG2 and UG2DER"
3352 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
3353 ((ug2(l,k,i),l=1,2),k=1,2),&
3354 ((ug2der(l,k,i),l=1,2),k=1,2)
3356 write (iout,*) "Arrays OBROT OBROT2 OBROTDER and OBROT2DER"
3358 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
3359 (obrot(k,i),k=1,2),(obrot2(k,i),k=1,2),&
3360 (obrot_der(k,i),k=1,2),(obrot2_der(k,i),k=1,2)
3362 write (iout,*) "Arrays COSTAB SINTAB COSTAB2 and SINTAB2"
3364 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
3365 costab(i),sintab(i),costab2(i),sintab2(i)
3367 write (iout,*) "Array MUDER"
3369 write (iout,'(i5,2f10.5)') i,muder(1,i),muder(2,i)
3375 !d iti = itortyp(itype(i,1))
3378 !d write (iout,'(2f10.5,5x,2f10.5,5x,2f10.5)')
3379 !d & (EE(j,k,iti),k=1,2),(Ug(j,k,i),k=1,2),(EUg(j,k,i),k=1,2)
3383 end subroutine set_matrices
3384 !-----------------------------------------------------------------------------
3385 subroutine eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
3387 ! This subroutine calculates the average interaction energy and its gradient
3388 ! in the virtual-bond vectors between non-adjacent peptide groups, based on
3389 ! the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
3390 ! The potential depends both on the distance of peptide-group centers and on
3391 ! the orientation of the CA-CA virtual bonds.
3394 ! implicit real*8 (a-h,o-z)
3398 ! include 'DIMENSIONS'
3399 ! include 'COMMON.CONTROL'
3400 ! include 'COMMON.SETUP'
3401 ! include 'COMMON.IOUNITS'
3402 ! include 'COMMON.GEO'
3403 ! include 'COMMON.VAR'
3404 ! include 'COMMON.LOCAL'
3405 ! include 'COMMON.CHAIN'
3406 ! include 'COMMON.DERIV'
3407 ! include 'COMMON.INTERACT'
3408 ! include 'COMMON.CONTACTS'
3409 ! include 'COMMON.TORSION'
3410 ! include 'COMMON.VECTORS'
3411 ! include 'COMMON.FFIELD'
3412 ! include 'COMMON.TIME1'
3413 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg
3414 real(kind=8),dimension(3,3) :: erder,uryg,urzg,vryg,vrzg
3415 real(kind=8),dimension(2,2) :: acipa !el,a_temp
3416 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
3417 real(kind=8),dimension(4) :: muij
3418 !el integer :: num_conti,j1,j2
3419 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
3420 !el dz_normi,xmedi,ymedi,zmedi
3422 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
3423 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
3426 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
3428 real(kind=8) :: scal_el=1.0d0
3430 real(kind=8) :: scal_el=0.5d0
3433 ! 13-go grudnia roku pamietnego...
3434 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
3436 0.0d0,0.0d0,1.0d0/),shape(unmat))
3438 integer :: i,k,j,icont
3439 real(kind=8) :: ees,evdw1,eel_loc,eello_turn3,eello_turn4
3440 real(kind=8) :: fac,t_eelecij,fracinbuf
3443 !d write(iout,*) 'In EELEC'
3444 ! print *,"IN EELEC"
3446 !d write(iout,*) 'Type',i
3447 !d write(iout,*) 'B1',B1(:,i)
3448 !d write(iout,*) 'B2',B2(:,i)
3449 !d write(iout,*) 'CC',CC(:,:,i)
3450 !d write(iout,*) 'DD',DD(:,:,i)
3451 !d write(iout,*) 'EE',EE(:,:,i)
3453 !d call check_vecgrad
3468 if (icheckgrad.eq.1) then
3471 ! dc_norm(1,i)=0.0d0
3472 ! dc_norm(2,i)=0.0d0
3473 ! dc_norm(3,i)=0.0d0
3476 fac=1.0d0/dsqrt(scalar(dc(1,i),dc(1,i)))
3478 dc_norm(k,i)=dc(k,i)*fac
3480 ! write (iout,*) 'i',i,' fac',fac
3483 ! print *,wel_loc,"wel_loc",wcorr4,wcorr5,wcorr6,wturn3,wturn4, &
3485 if (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
3486 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 .or. &
3487 wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) then
3488 ! call vec_and_deriv
3492 ! print *, "before set matrices"
3494 ! print *, "after set matrices"
3497 time_mat=time_mat+MPI_Wtime()-time01
3500 ! print *, "after set matrices"
3502 !d write (iout,*) 'i=',i
3504 !d write (iout,'(i5,2f10.5)') k,uy(k,i),uz(k,i)
3507 !d write (iout,'(f10.5,2x,3f10.5,2x,3f10.5)')
3508 !d & uz(k,i),(uzgrad(k,l,1,i),l=1,3),(uzgrad(k,l,2,i),l=1,3)
3521 !d print '(a)','Enter EELEC'
3522 !d write (iout,*) 'iatel_s=',iatel_s,' iatel_e=',iatel_e
3523 ! if (.not.allocated(gel_loc_loc)) allocate(gel_loc_loc(nres)) !(maxvar)(maxvar=6*maxres)
3524 ! if (.not.allocated(gcorr_loc)) allocate(gcorr_loc(nres)) !(maxvar)(maxvar=6*maxres)
3526 gel_loc_loc(i)=0.0d0
3531 ! 9/27/08 AL Split the interaction loop to ensure load balancing of turn terms
3533 ! Loop over i,i+2 and i,i+3 pairs of the peptide groups
3537 ! print *,"before iturn3 loop"
3538 do i=iturn3_start,iturn3_end
3539 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1 &
3540 .or. itype(i+2,1).eq.ntyp1 .or. itype(i+3,1).eq.ntyp1) cycle
3544 dx_normi=dc_norm(1,i)
3545 dy_normi=dc_norm(2,i)
3546 dz_normi=dc_norm(3,i)
3547 xmedi=c(1,i)+0.5d0*dxi
3548 ymedi=c(2,i)+0.5d0*dyi
3549 zmedi=c(3,i)+0.5d0*dzi
3550 call to_box(xmedi,ymedi,zmedi)
3551 call lipid_layer(xmedi,ymedi,zmedi,sslipi,ssgradlipi)
3553 call eelecij(i,i+2,ees,evdw1,eel_loc)
3554 if (wturn3.gt.0.0d0) call eturn3(i,eello_turn3)
3555 num_cont_hb(i)=num_conti
3557 do i=iturn4_start,iturn4_end
3558 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1 &
3559 .or. itype(i+3,1).eq.ntyp1 &
3560 .or. itype(i+4,1).eq.ntyp1) cycle
3561 ! print *,"before2",i,i+3, gshieldc_t4(2,i+3),gshieldc_t4(2,i)
3565 dx_normi=dc_norm(1,i)
3566 dy_normi=dc_norm(2,i)
3567 dz_normi=dc_norm(3,i)
3568 xmedi=c(1,i)+0.5d0*dxi
3569 ymedi=c(2,i)+0.5d0*dyi
3570 zmedi=c(3,i)+0.5d0*dzi
3571 call to_box(xmedi,ymedi,zmedi)
3572 call lipid_layer(xmedi,ymedi,zmedi,sslipi,ssgradlipi)
3573 num_conti=num_cont_hb(i)
3574 call eelecij(i,i+3,ees,evdw1,eel_loc)
3575 if (wturn4.gt.0.0d0 .and. itype(i+2,1).ne.ntyp1) &
3576 call eturn4(i,eello_turn4)
3577 ! print *,"before",i,i+3, gshieldc_t4(2,i+3),gshieldc_t4(2,i)
3578 num_cont_hb(i)=num_conti
3581 ! Loop over all pairs of interacting peptide groups except i,i+2 and i,i+3
3583 ! print *,"iatel_s,iatel_e,",iatel_s,iatel_e
3584 ! do i=iatel_s,iatel_e
3586 do icont=g_listpp_start,g_listpp_end
3587 i=newcontlistppi(icont)
3588 j=newcontlistppj(icont)
3589 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
3593 dx_normi=dc_norm(1,i)
3594 dy_normi=dc_norm(2,i)
3595 dz_normi=dc_norm(3,i)
3596 xmedi=c(1,i)+0.5d0*dxi
3597 ymedi=c(2,i)+0.5d0*dyi
3598 zmedi=c(3,i)+0.5d0*dzi
3599 call to_box(xmedi,ymedi,zmedi)
3600 call lipid_layer(xmedi,ymedi,zmedi,sslipi,ssgradlipi)
3602 ! write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
3603 num_conti=num_cont_hb(i)
3604 ! do j=ielstart(i),ielend(i)
3605 ! write (iout,*) i,j,itype(i,1),itype(j,1)
3606 if (itype(j,1).eq.ntyp1.or. itype(j+1,1).eq.ntyp1) cycle
3607 call eelecij(i,j,ees,evdw1,eel_loc)
3609 num_cont_hb(i)=num_conti
3611 ! write (iout,*) "Number of loop steps in EELEC:",ind
3613 !d write (iout,'(i3,3f10.5,5x,3f10.5)')
3614 !d & i,(gel_loc(k,i),k=1,3),gel_loc_loc(i)
3616 ! 12/7/99 Adam eello_turn3 will be considered as a separate energy term
3617 !cc eel_loc=eel_loc+eello_turn3
3618 !d print *,"Processor",fg_rank," t_eelecij",t_eelecij
3620 end subroutine eelec
3621 !-----------------------------------------------------------------------------
3622 subroutine eelecij(i,j,ees,evdw1,eel_loc)
3625 ! implicit real*8 (a-h,o-z)
3626 ! include 'DIMENSIONS'
3630 ! include 'COMMON.CONTROL'
3631 ! include 'COMMON.IOUNITS'
3632 ! include 'COMMON.GEO'
3633 ! include 'COMMON.VAR'
3634 ! include 'COMMON.LOCAL'
3635 ! include 'COMMON.CHAIN'
3636 ! include 'COMMON.DERIV'
3637 ! include 'COMMON.INTERACT'
3638 ! include 'COMMON.CONTACTS'
3639 ! include 'COMMON.TORSION'
3640 ! include 'COMMON.VECTORS'
3641 ! include 'COMMON.FFIELD'
3642 ! include 'COMMON.TIME1'
3643 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg,xtemp
3644 real(kind=8),dimension(3,3) :: erder,uryg,urzg,vryg,vrzg
3645 real(kind=8),dimension(2,2) :: acipa !el,a_temp
3646 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
3647 real(kind=8),dimension(4) :: muij
3648 real(kind=8) :: geel_loc_ij,geel_loc_ji
3649 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
3650 dist_temp, dist_init,rlocshield,fracinbuf
3651 integer xshift,yshift,zshift,ilist,iresshield
3652 !el integer :: num_conti,j1,j2
3653 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
3654 !el dz_normi,xmedi,ymedi,zmedi
3656 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
3657 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
3660 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
3662 real(kind=8) :: scal_el=1.0d0
3664 real(kind=8) :: scal_el=0.5d0
3667 ! 13-go grudnia roku pamietnego...
3668 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
3670 0.0d0,0.0d0,1.0d0/),shape(unmat))
3671 ! integer :: maxconts=nres/4
3673 integer :: k,i,j,iteli,itelj,kkk,l,kkll,m,isubchap
3674 real(kind=8) :: ael6i,rrmij,rmij,r0ij,fcont,fprimcont,ees0tmp
3675 real(kind=8) :: faclipij2, faclipij
3676 real(kind=8) :: ees,evdw1,eel_loc,aaa,bbb,ael3i
3677 real(kind=8) :: dxj,dyj,dzj,dx_normj,dy_normj,dz_normj,xj,yj,zj,&
3678 rij,r3ij,r6ij,cosa,cosb,cosg,fac,ev1,ev2,fac3,fac4,&
3679 evdwij,el1,el2,eesij,ees0ij,facvdw,facel,fac1,ecosa,&
3680 ecosb,ecosg,ury,urz,vry,vrz,facr,a22der,a23der,a32der,&
3681 a33der,eel_loc_ij,cosa4,wij,cosbg1,cosbg2,ees0pij,&
3682 ees0pij1,ees0mij,ees0mij1,fac3p,ees0mijp,ees0pijp,&
3683 ecosa1,ecosb1,ecosg1,ecosa2,ecosb2,ecosg2,ecosap,ecosbp,&
3684 ecosgp,ecosam,ecosbm,ecosgm,ghalf
3686 ! allocate(a_chuj(2,2,maxconts,nres)) !(2,2,maxconts,maxres)
3687 ! allocate(a_chuj_der(2,2,3,5,maxconts,nres)) !(2,2,3,5,maxconts,maxres)
3689 ! time00=MPI_Wtime()
3690 !d write (iout,*) "eelecij",i,j
3694 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
3695 aaa=app(iteli,itelj)
3696 bbb=bpp(iteli,itelj)
3697 ael6i=ael6(iteli,itelj)
3698 ael3i=ael3(iteli,itelj)
3702 dx_normj=dc_norm(1,j)
3703 dy_normj=dc_norm(2,j)
3704 dz_normj=dc_norm(3,j)
3705 ! xj=c(1,j)+0.5D0*dxj-xmedi
3706 ! yj=c(2,j)+0.5D0*dyj-ymedi
3707 ! zj=c(3,j)+0.5D0*dzj-zmedi
3712 call to_box(xj,yj,zj)
3713 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
3714 faclipij=(sslipi+sslipj)/2.0d0*lipscale+1.0d0
3715 faclipij2=(sslipi+sslipj)/2.0d0*lipscale**2+1.0d0
3716 xj=boxshift(xj-xmedi,boxxsize)
3717 yj=boxshift(yj-ymedi,boxysize)
3718 zj=boxshift(zj-zmedi,boxzsize)
3720 rij=xj*xj+yj*yj+zj*zj
3723 !C print *,xmedi,ymedi,zmedi,xj,yj,zj,boxxsize,rij
3724 sss_ele_cut=sscale_ele(rij)
3725 sss_ele_grad=sscagrad_ele(rij)
3727 ! sss_ele_grad=0.0d0
3728 ! print *,sss_ele_cut,sss_ele_grad,&
3729 ! (rij),r_cut_ele,rlamb_ele
3730 if (sss_ele_cut.le.0.0) go to 128
3735 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
3736 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
3737 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
3738 fac=cosa-3.0D0*cosb*cosg
3740 ! 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
3741 if (j.eq.i+2) ev1=scal_el*ev1
3746 el1=fac3*(4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg))
3749 if (shield_mode.gt.0) then
3750 !C fac_shield(i)=0.4
3751 !C fac_shield(j)=0.6
3752 el1=el1*fac_shield(i)**2*fac_shield(j)**2
3753 el2=el2*fac_shield(i)**2*fac_shield(j)**2
3755 ees=ees+eesij*sss_ele_cut
3756 !C FOR NOW SHIELD IS NOT USED WITH LIPSCALE
3757 !C & *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3763 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)*sss_ele_cut
3764 !C print *,"TUCC",(sslipi+sslipj)/2.0d0*lipscale**2+1.0d0
3767 ! 12/26/95 - for the evaluation of multi-body H-bonding interactions
3768 ees0ij=4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg)
3769 ! ees=ees+eesij*sss_ele_cut
3770 evdw1=evdw1+evdwij*sss_ele_cut &
3771 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3772 !d write(iout,'(2(2i3,2x),7(1pd12.4)/2(3(1pd12.4),5x)/)')
3773 !d & iteli,i,itelj,j,aaa,bbb,ael6i,ael3i,
3774 !d & 1.0D0/dsqrt(rrmij),evdwij,eesij,
3775 !d & xmedi,ymedi,zmedi,xj,yj,zj
3777 if (energy_dec) then
3778 ! write (iout,'(a6,2i5,0pf7.3,2i5,2e11.3)') &
3779 ! 'evdw1',i,j,evdwij,&
3780 ! iteli,itelj,aaa,evdw1
3781 write (iout,'(a6,2i5,0pf7.3)') 'evdw1',i,j,evdwij
3782 write (iout,'(a6,2i5,0pf7.3)') 'ees',i,j,eesij
3785 ! Calculate contributions to the Cartesian gradient.
3788 facvdw=-6*rrmij*(ev1+evdwij)*sss_ele_cut &
3789 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3790 facel=-3*rrmij*(el1+eesij)*sss_ele_cut &
3791 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3797 ! Radial derivatives. First process both termini of the fragment (i,j)
3799 ggg(1)=facel*xj+sss_ele_grad*rmij*eesij*xj* &
3800 ((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3801 ggg(2)=facel*yj+sss_ele_grad*rmij*eesij*yj* &
3802 ((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3803 ggg(3)=facel*zj+sss_ele_grad*rmij*eesij*zj* &
3804 ((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3806 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
3807 (shield_mode.gt.0)) then
3809 do ilist=1,ishield_list(i)
3810 iresshield=shield_list(ilist,i)
3812 rlocshield=grad_shield_side(k,ilist,i)*eesij/fac_shield(i)&
3814 gshieldx(k,iresshield)=gshieldx(k,iresshield)+ &
3816 +grad_shield_loc(k,ilist,i)*eesij/fac_shield(i)*2.0 &
3818 gshieldc(k,iresshield-1)=gshieldc(k,iresshield-1)+rlocshield
3821 do ilist=1,ishield_list(j)
3822 iresshield=shield_list(ilist,j)
3824 rlocshield=grad_shield_side(k,ilist,j)*eesij/fac_shield(j) &
3826 gshieldx(k,iresshield)=gshieldx(k,iresshield)+ &
3828 +grad_shield_loc(k,ilist,j)*eesij/fac_shield(j)*2.0 &
3830 gshieldc(k,iresshield-1)=gshieldc(k,iresshield-1)+rlocshield
3834 gshieldc(k,i)=gshieldc(k,i)+ &
3835 grad_shield(k,i)*eesij/fac_shield(i)*2.0 &
3838 gshieldc(k,j)=gshieldc(k,j)+ &
3839 grad_shield(k,j)*eesij/fac_shield(j)*2.0 &
3842 gshieldc(k,i-1)=gshieldc(k,i-1)+ &
3843 grad_shield(k,i)*eesij/fac_shield(i)*2.0 &
3846 gshieldc(k,j-1)=gshieldc(k,j-1)+ &
3847 grad_shield(k,j)*eesij/fac_shield(j)*2.0 &
3855 ! ghalf=0.5D0*ggg(k)
3856 ! gelc(k,i)=gelc(k,i)+ghalf
3857 ! gelc(k,j)=gelc(k,j)+ghalf
3859 ! 9/28/08 AL Gradient compotents will be summed only at the end
3861 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
3862 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
3864 gelc_long(3,j)=gelc_long(3,j)+ &
3865 ssgradlipj*eesij/2.0d0*lipscale**2&
3868 gelc_long(3,i)=gelc_long(3,i)+ &
3869 ssgradlipi*eesij/2.0d0*lipscale**2&
3874 ! Loop over residues i+1 thru j-1.
3878 !grad gelc(l,k)=gelc(l,k)+ggg(l)
3881 ggg(1)=facvdw*xj+sss_ele_grad*rmij*evdwij*xj &
3882 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3883 ggg(2)=facvdw*yj+sss_ele_grad*rmij*evdwij*yj &
3884 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3885 ggg(3)=facvdw*zj+sss_ele_grad*rmij*evdwij*zj &
3886 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3889 ! ghalf=0.5D0*ggg(k)
3890 ! gvdwpp(k,i)=gvdwpp(k,i)+ghalf
3891 ! gvdwpp(k,j)=gvdwpp(k,j)+ghalf
3893 ! 9/28/08 AL Gradient compotents will be summed only at the end
3895 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
3896 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
3899 !C Lipidic part for scaling weight
3900 gvdwpp(3,j)=gvdwpp(3,j)+ &
3901 sss_ele_cut*ssgradlipj*evdwij/2.0d0*lipscale**2
3902 gvdwpp(3,i)=gvdwpp(3,i)+ &
3903 sss_ele_cut*ssgradlipi*evdwij/2.0d0*lipscale**2
3904 !! Loop over residues i+1 thru j-1.
3908 !grad gvdwpp(l,k)=gvdwpp(l,k)+ggg(l)
3912 facvdw=(ev1+evdwij)*sss_ele_cut &
3913 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3915 facel=(el1+eesij)*sss_ele_cut
3917 fac=-3*rrmij*(facvdw+facvdw+facel)
3922 ! Radial derivatives. First process both termini of the fragment (i,j)
3924 ggg(1)=fac*xj+sss_ele_grad*rmij*(eesij+evdwij)*xj
3925 ggg(2)=fac*yj+sss_ele_grad*rmij*(eesij+evdwij)*yj
3926 ggg(3)=fac*zj+sss_ele_grad*rmij*(eesij+evdwij)*zj
3928 ! ghalf=0.5D0*ggg(k)
3929 ! gelc(k,i)=gelc(k,i)+ghalf
3930 ! gelc(k,j)=gelc(k,j)+ghalf
3932 ! 9/28/08 AL Gradient compotents will be summed only at the end
3934 gelc_long(k,j)=gelc(k,j)+ggg(k)
3935 gelc_long(k,i)=gelc(k,i)-ggg(k)
3938 ! Loop over residues i+1 thru j-1.
3942 !grad gelc(l,k)=gelc(l,k)+ggg(l)
3945 ! 9/28/08 AL Gradient compotents will be summed only at the end
3946 ggg(1)=facvdw*xj+sss_ele_grad*rmij*evdwij*xj &
3947 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3948 ggg(2)=facvdw*yj+sss_ele_grad*rmij*evdwij*yj &
3949 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3950 ggg(3)=facvdw*zj+sss_ele_grad*rmij*evdwij*zj &
3951 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3954 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
3955 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
3957 gvdwpp(3,j)=gvdwpp(3,j)+ &
3958 sss_ele_cut*ssgradlipj*evdwij/2.0d0*lipscale**2
3959 gvdwpp(3,i)=gvdwpp(3,i)+ &
3960 sss_ele_cut*ssgradlipi*evdwij/2.0d0*lipscale**2
3966 ecosa=2.0D0*fac3*fac1+fac4
3969 ecosb=(fac3*(fac1*cosg+cosb)+cosg*fac4)
3970 ecosg=(fac3*(fac1*cosb+cosg)+cosb*fac4)
3972 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
3973 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
3975 !d print '(2i3,2(3(1pd14.5),3x))',i,j,(dcosb(k),k=1,3),
3976 !d & (dcosg(k),k=1,3)
3978 ggg(k)=(ecosb*dcosb(k)+ecosg*dcosg(k))*sss_ele_cut &
3979 *fac_shield(i)**2*fac_shield(j)**2 &
3980 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3984 ! ghalf=0.5D0*ggg(k)
3985 ! gelc(k,i)=gelc(k,i)+ghalf
3986 ! & +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
3987 ! & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
3988 ! gelc(k,j)=gelc(k,j)+ghalf
3989 ! & +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
3990 ! & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
3994 !grad gelc(l,k)=gelc(l,k)+ggg(l)
3998 gelc(k,i)=gelc(k,i) &
3999 +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
4000 + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)&
4002 *fac_shield(i)**2*fac_shield(j)**2 &
4003 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
4005 gelc(k,j)=gelc(k,j) &
4006 +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
4007 + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
4009 *fac_shield(i)**2*fac_shield(j)**2 &
4010 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
4012 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
4013 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
4016 IF (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
4017 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 &
4018 .or. wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
4020 ! 9/25/99 Mixed third-order local-electrostatic terms. The local-interaction
4021 ! energy of a peptide unit is assumed in the form of a second-order
4022 ! Fourier series in the angles lambda1 and lambda2 (see Nishikawa et al.
4023 ! Macromolecules, 1974, 7, 797-806 for definition). This correlation terms
4024 ! are computed for EVERY pair of non-contiguous peptide groups.
4026 if (j.lt.nres-1) then
4037 muij(kkk)=mu(k,i)*mu(l,j)
4039 gmuij1(kkk)=gtb1(k,i+1)*mu(l,j)
4040 !c write(iout,*) 'k=',k,i,gtb1(k,i+1),gtb1(k,i+1)*mu(l,j)
4041 gmuij2(kkk)=gUb2(k,i)*mu(l,j)
4042 gmuji1(kkk)=mu(k,i)*gtb1(l,j+1)
4043 !c write(iout,*) 'l=',l,j,gtb1(l,j+1),gtb1(l,j+1)*mu(k,i)
4044 gmuji2(kkk)=mu(k,i)*gUb2(l,j)
4049 !d write (iout,*) 'EELEC: i',i,' j',j
4050 !d write (iout,*) 'j',j,' j1',j1,' j2',j2
4051 !d write(iout,*) 'muij',muij
4052 ury=scalar(uy(1,i),erij)
4053 urz=scalar(uz(1,i),erij)
4054 vry=scalar(uy(1,j),erij)
4055 vrz=scalar(uz(1,j),erij)
4056 a22=scalar(uy(1,i),uy(1,j))-3*ury*vry
4057 a23=scalar(uy(1,i),uz(1,j))-3*ury*vrz
4058 a32=scalar(uz(1,i),uy(1,j))-3*urz*vry
4059 a33=scalar(uz(1,i),uz(1,j))-3*urz*vrz
4060 fac=dsqrt(-ael6i)*r3ij
4065 !d write (iout,'(4i5,4f10.5)')
4066 !d & i,itortyp(itype(i,1)),j,itortyp(itype(j,1)),a22,a23,a32,a33
4067 !d write (iout,'(6f10.5)') (muij(k),k=1,4),fac,eel_loc_ij
4068 !d write (iout,'(2(3f10.5,5x)/2(3f10.5,5x))') uy(:,i),uz(:,i),
4069 !d & uy(:,j),uz(:,j)
4070 !d write (iout,'(4f10.5)')
4071 !d & scalar(uy(1,i),uy(1,j)),scalar(uy(1,i),uz(1,j)),
4072 !d & scalar(uz(1,i),uy(1,j)),scalar(uz(1,i),uz(1,j))
4073 !d write (iout,'(4f10.5)') ury,urz,vry,vrz
4074 !d write (iout,'(9f10.5/)')
4075 !d & fac22,a22,fac23,a23,fac32,a32,fac33,a33,eel_loc_ij
4076 ! Derivatives of the elements of A in virtual-bond vectors
4077 call unormderiv(erij(1),unmat(1,1),rmij,erder(1,1))
4079 uryg(k,1)=scalar(erder(1,k),uy(1,i))
4080 uryg(k,2)=scalar(uygrad(1,k,1,i),erij(1))
4081 uryg(k,3)=scalar(uygrad(1,k,2,i),erij(1))
4082 urzg(k,1)=scalar(erder(1,k),uz(1,i))
4083 urzg(k,2)=scalar(uzgrad(1,k,1,i),erij(1))
4084 urzg(k,3)=scalar(uzgrad(1,k,2,i),erij(1))
4085 vryg(k,1)=scalar(erder(1,k),uy(1,j))
4086 vryg(k,2)=scalar(uygrad(1,k,1,j),erij(1))
4087 vryg(k,3)=scalar(uygrad(1,k,2,j),erij(1))
4088 vrzg(k,1)=scalar(erder(1,k),uz(1,j))
4089 vrzg(k,2)=scalar(uzgrad(1,k,1,j),erij(1))
4090 vrzg(k,3)=scalar(uzgrad(1,k,2,j),erij(1))
4092 ! Compute radial contributions to the gradient
4110 ! Add the contributions coming from er
4113 agg(k,1)=agg(k,1)+fac3*(uryg(k,1)*vry+vryg(k,1)*ury)
4114 agg(k,2)=agg(k,2)+fac3*(uryg(k,1)*vrz+vrzg(k,1)*ury)
4115 agg(k,3)=agg(k,3)+fac3*(urzg(k,1)*vry+vryg(k,1)*urz)
4116 agg(k,4)=agg(k,4)+fac3*(urzg(k,1)*vrz+vrzg(k,1)*urz)
4119 ! Derivatives in DC(i)
4120 !grad ghalf1=0.5d0*agg(k,1)
4121 !grad ghalf2=0.5d0*agg(k,2)
4122 !grad ghalf3=0.5d0*agg(k,3)
4123 !grad ghalf4=0.5d0*agg(k,4)
4124 aggi(k,1)=fac*(scalar(uygrad(1,k,1,i),uy(1,j)) &
4125 -3.0d0*uryg(k,2)*vry)!+ghalf1
4126 aggi(k,2)=fac*(scalar(uygrad(1,k,1,i),uz(1,j)) &
4127 -3.0d0*uryg(k,2)*vrz)!+ghalf2
4128 aggi(k,3)=fac*(scalar(uzgrad(1,k,1,i),uy(1,j)) &
4129 -3.0d0*urzg(k,2)*vry)!+ghalf3
4130 aggi(k,4)=fac*(scalar(uzgrad(1,k,1,i),uz(1,j)) &
4131 -3.0d0*urzg(k,2)*vrz)!+ghalf4
4132 ! Derivatives in DC(i+1)
4133 aggi1(k,1)=fac*(scalar(uygrad(1,k,2,i),uy(1,j)) &
4134 -3.0d0*uryg(k,3)*vry)!+agg(k,1)
4135 aggi1(k,2)=fac*(scalar(uygrad(1,k,2,i),uz(1,j)) &
4136 -3.0d0*uryg(k,3)*vrz)!+agg(k,2)
4137 aggi1(k,3)=fac*(scalar(uzgrad(1,k,2,i),uy(1,j)) &
4138 -3.0d0*urzg(k,3)*vry)!+agg(k,3)
4139 aggi1(k,4)=fac*(scalar(uzgrad(1,k,2,i),uz(1,j)) &
4140 -3.0d0*urzg(k,3)*vrz)!+agg(k,4)
4141 ! Derivatives in DC(j)
4142 aggj(k,1)=fac*(scalar(uygrad(1,k,1,j),uy(1,i)) &
4143 -3.0d0*vryg(k,2)*ury)!+ghalf1
4144 aggj(k,2)=fac*(scalar(uzgrad(1,k,1,j),uy(1,i)) &
4145 -3.0d0*vrzg(k,2)*ury)!+ghalf2
4146 aggj(k,3)=fac*(scalar(uygrad(1,k,1,j),uz(1,i)) &
4147 -3.0d0*vryg(k,2)*urz)!+ghalf3
4148 aggj(k,4)=fac*(scalar(uzgrad(1,k,1,j),uz(1,i)) &
4149 -3.0d0*vrzg(k,2)*urz)!+ghalf4
4150 ! Derivatives in DC(j+1) or DC(nres-1)
4151 aggj1(k,1)=fac*(scalar(uygrad(1,k,2,j),uy(1,i)) &
4152 -3.0d0*vryg(k,3)*ury)
4153 aggj1(k,2)=fac*(scalar(uzgrad(1,k,2,j),uy(1,i)) &
4154 -3.0d0*vrzg(k,3)*ury)
4155 aggj1(k,3)=fac*(scalar(uygrad(1,k,2,j),uz(1,i)) &
4156 -3.0d0*vryg(k,3)*urz)
4157 aggj1(k,4)=fac*(scalar(uzgrad(1,k,2,j),uz(1,i)) &
4158 -3.0d0*vrzg(k,3)*urz)
4159 !grad if (j.eq.nres-1 .and. i.lt.j-2) then
4161 !grad aggj1(k,l)=aggj1(k,l)+agg(k,l)
4174 aggi(k,l)=-aggi(k,l)
4175 aggi1(k,l)=-aggi1(k,l)
4176 aggj(k,l)=-aggj(k,l)
4177 aggj1(k,l)=-aggj1(k,l)
4180 if (j.lt.nres-1) then
4186 aggi(k,l)=-aggi(k,l)
4187 aggi1(k,l)=-aggi1(k,l)
4188 aggj(k,l)=-aggj(k,l)
4189 aggj1(k,l)=-aggj1(k,l)
4200 aggi(k,l)=-aggi(k,l)
4201 aggi1(k,l)=-aggi1(k,l)
4202 aggj(k,l)=-aggj(k,l)
4203 aggj1(k,l)=-aggj1(k,l)
4208 IF (wel_loc.gt.0.0d0) THEN
4209 ! Contribution to the local-electrostatic energy coming from the i-j pair
4210 eel_loc_ij=a22*muij(1)+a23*muij(2)+a32*muij(3) &
4212 if (shield_mode.eq.0) then
4216 eel_loc_ij=eel_loc_ij &
4217 *fac_shield(i)*fac_shield(j) &
4218 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4219 !C Now derivative over eel_loc
4220 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
4221 (shield_mode.gt.0)) then
4224 do ilist=1,ishield_list(i)
4225 iresshield=shield_list(ilist,i)
4227 rlocshield=grad_shield_side(k,ilist,i)*eel_loc_ij &
4230 gshieldx_ll(k,iresshield)=gshieldx_ll(k,iresshield)+ &
4232 +grad_shield_loc(k,ilist,i)*eel_loc_ij/fac_shield(i) &
4235 gshieldc_ll(k,iresshield-1)=gshieldc_ll(k,iresshield-1)&
4239 do ilist=1,ishield_list(j)
4240 iresshield=shield_list(ilist,j)
4242 rlocshield=grad_shield_side(k,ilist,j)*eel_loc_ij &
4245 gshieldx_ll(k,iresshield)=gshieldx_ll(k,iresshield)+ &
4247 +grad_shield_loc(k,ilist,j)*eel_loc_ij/fac_shield(j) &
4250 gshieldc_ll(k,iresshield-1)=gshieldc_ll(k,iresshield-1)&
4257 gshieldc_ll(k,i)=gshieldc_ll(k,i)+ &
4258 grad_shield(k,i)*eel_loc_ij/fac_shield(i) &
4260 gshieldc_ll(k,j)=gshieldc_ll(k,j)+ &
4261 grad_shield(k,j)*eel_loc_ij/fac_shield(j) &
4263 gshieldc_ll(k,i-1)=gshieldc_ll(k,i-1)+ &
4264 grad_shield(k,i)*eel_loc_ij/fac_shield(i) &
4266 gshieldc_ll(k,j-1)=gshieldc_ll(k,j-1)+ &
4267 grad_shield(k,j)*eel_loc_ij/fac_shield(j) &
4274 geel_loc_ij=(a22*gmuij1(1)&
4278 *fac_shield(i)*fac_shield(j)&
4280 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4283 !c write(iout,*) "derivative over thatai"
4284 !c write(iout,*) a22*gmuij1(1), a23*gmuij1(2) ,a32*gmuij1(3),
4286 gloc(nphi+i,icg)=gloc(nphi+i,icg)+&
4288 !c write(iout,*) "derivative over thatai-1"
4289 !c write(iout,*) a22*gmuij2(1), a23*gmuij2(2) ,a32*gmuij2(3),
4296 gloc(nphi+i-1,icg)=gloc(nphi+i-1,icg)+&
4297 geel_loc_ij*wel_loc&
4298 *fac_shield(i)*fac_shield(j)&
4300 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4303 !c Derivative over j residue
4304 geel_loc_ji=a22*gmuji1(1)&
4308 !c write(iout,*) "derivative over thataj"
4309 !c write(iout,*) a22*gmuji1(1), a23*gmuji1(2) ,a32*gmuji1(3),
4312 gloc(nphi+j,icg)=gloc(nphi+j,icg)+&
4313 geel_loc_ji*wel_loc&
4314 *fac_shield(i)*fac_shield(j)&
4316 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4324 !c write(iout,*) "derivative over thataj-1"
4325 !c write(iout,*) a22*gmuji2(1), a23*gmuji2(2) ,a32*gmuji2(3),
4327 gloc(nphi+j-1,icg)=gloc(nphi+j-1,icg)+&
4328 geel_loc_ji*wel_loc&
4329 *fac_shield(i)*fac_shield(j)&
4331 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4335 ! write (iout,*) 'i',i,' j',j,' eel_loc_ij',eel_loc_ij
4337 ! if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
4338 ! 'eelloc',i,j,eel_loc_ij
4339 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,8f8.3)') &
4340 'eelloc',i,j,eel_loc_ij,a22,muij(1),a23,muij(2),a32,muij(3),a33,muij(4)
4341 ! print *,"EELLOC",i,gel_loc_loc(i-1)
4343 ! if (energy_dec) write (iout,*) "a22",a22," a23",a23," a32",a32," a33",a33
4344 ! if (energy_dec) write (iout,*) "muij",muij
4345 ! write (iout,*) a22,muij(1),a23,muij(2),a32,muij(3)
4347 eel_loc=eel_loc+eel_loc_ij*sss_ele_cut
4348 ! Partial derivatives in virtual-bond dihedral angles gamma
4350 gel_loc_loc(i-1)=gel_loc_loc(i-1)+ &
4351 (a22*muder(1,i)*mu(1,j)+a23*muder(1,i)*mu(2,j) &
4352 +a32*muder(2,i)*mu(1,j)+a33*muder(2,i)*mu(2,j)) &
4354 *fac_shield(i)*fac_shield(j) &
4355 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4357 gel_loc_loc(j-1)=gel_loc_loc(j-1)+ &
4358 (a22*mu(1,i)*muder(1,j)+a23*mu(1,i)*muder(2,j) &
4359 +a32*mu(2,i)*muder(1,j)+a33*mu(2,i)*muder(2,j)) &
4361 *fac_shield(i)*fac_shield(j) &
4362 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4363 ! Derivatives of eello in DC(i+1) thru DC(j-1) or DC(nres-2)
4365 ! ggg(1)=(agg(1,1)*muij(1)+ &
4366 ! agg(1,2)*muij(2)+agg(1,3)*muij(3)+agg(1,4)*muij(4)) &
4368 ! +eel_loc_ij*sss_ele_grad*rmij*xj
4369 ! ggg(2)=(agg(2,1)*muij(1)+ &
4370 ! agg(2,2)*muij(2)+agg(2,3)*muij(3)+agg(2,4)*muij(4)) &
4372 ! +eel_loc_ij*sss_ele_grad*rmij*yj
4373 ! ggg(3)=(agg(3,1)*muij(1)+ &
4374 ! agg(3,2)*muij(2)+agg(3,3)*muij(3)+agg(3,4)*muij(4)) &
4376 ! +eel_loc_ij*sss_ele_grad*rmij*zj
4382 ggg(l)=(agg(l,1)*muij(1)+ &
4383 agg(l,2)*muij(2)+agg(l,3)*muij(3)+agg(l,4)*muij(4))&
4385 *fac_shield(i)*fac_shield(j) &
4386 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0) &
4387 +eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
4390 gel_loc_long(l,j)=gel_loc_long(l,j)+ggg(l)
4391 gel_loc_long(l,i)=gel_loc_long(l,i)-ggg(l)
4392 !grad ghalf=0.5d0*ggg(l)
4393 !grad gel_loc(l,i)=gel_loc(l,i)+ghalf
4394 !grad gel_loc(l,j)=gel_loc(l,j)+ghalf
4396 gel_loc_long(3,j)=gel_loc_long(3,j)+ &
4397 ssgradlipj*eel_loc_ij/2.0d0*lipscale/ &
4398 ((sslipi+sslipj)/2.0d0*lipscale+1.0d0)*sss_ele_cut
4400 gel_loc_long(3,i)=gel_loc_long(3,i)+ &
4401 ssgradlipi*eel_loc_ij/2.0d0*lipscale/ &
4402 ((sslipi+sslipj)/2.0d0*lipscale+1.0d0)*sss_ele_cut
4406 !grad gel_loc(l,k)=gel_loc(l,k)+ggg(l)
4409 ! Remaining derivatives of eello
4411 gel_loc(l,i)=gel_loc(l,i)+(aggi(l,1)*muij(1)+ &
4412 aggi(l,2)*muij(2)+aggi(l,3)*muij(3)+aggi(l,4)*muij(4))&
4414 *fac_shield(i)*fac_shield(j) &
4415 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4417 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
4418 gel_loc(l,i+1)=gel_loc(l,i+1)+(aggi1(l,1)*muij(1)+ &
4419 aggi1(l,2)*muij(2)+aggi1(l,3)*muij(3) &
4420 +aggi1(l,4)*muij(4))&
4422 *fac_shield(i)*fac_shield(j) &
4423 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4425 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
4426 gel_loc(l,j)=gel_loc(l,j)+(aggj(l,1)*muij(1)+ &
4427 aggj(l,2)*muij(2)+aggj(l,3)*muij(3)+aggj(l,4)*muij(4))&
4429 *fac_shield(i)*fac_shield(j) &
4430 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4432 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
4433 gel_loc(l,j1)=gel_loc(l,j1)+(aggj1(l,1)*muij(1)+ &
4434 aggj1(l,2)*muij(2)+aggj1(l,3)*muij(3) &
4435 +aggj1(l,4)*muij(4))&
4437 *fac_shield(i)*fac_shield(j) &
4438 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4440 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
4443 ! Change 12/26/95 to calculate four-body contributions to H-bonding energy
4444 ! if (j.gt.i+1 .and. num_conti.le.maxconts) then
4445 if (wcorr+wcorr4+wcorr5+wcorr6.gt.0.0d0 &
4446 .and. num_conti.le.maxconts) then
4447 ! write (iout,*) i,j," entered corr"
4449 ! Calculate the contact function. The ith column of the array JCONT will
4450 ! contain the numbers of atoms that make contacts with the atom I (of numbers
4451 ! greater than I). The arrays FACONT and GACONT will contain the values of
4452 ! the contact function and its derivative.
4453 ! r0ij=1.02D0*rpp(iteli,itelj)
4454 ! r0ij=1.11D0*rpp(iteli,itelj)
4455 r0ij=2.20D0*rpp(iteli,itelj)
4456 ! r0ij=1.55D0*rpp(iteli,itelj)
4457 call gcont(rij,r0ij,1.0D0,0.2d0*r0ij,fcont,fprimcont)
4458 !elwrite(iout,*) "num_conti",num_conti, "maxconts",maxconts
4459 if (fcont.gt.0.0D0) then
4460 num_conti=num_conti+1
4461 if (num_conti.gt.maxconts) then
4462 !el write (iout,*) "esrgresgdsrgdfsrgdswrgaresfgaerwgae"
4463 !el write (iout,*) "num_conti",num_conti, "maxconts",maxconts
4464 write (iout,*) 'WARNING - max. # of contacts exceeded;',&
4465 ' will skip next contacts for this conf.', num_conti
4467 jcont_hb(num_conti,i)=j
4468 !d write (iout,*) "i",i," j",j," num_conti",num_conti,
4469 !d & " jcont_hb",jcont_hb(num_conti,i)
4470 IF (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. &
4471 wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
4472 ! 9/30/99 (AL) - store components necessary to evaluate higher-order loc-el
4474 d_cont(num_conti,i)=rij
4475 !d write (2,'(3e15.5)') rij,r0ij+0.2d0*r0ij,rij
4476 ! --- Electrostatic-interaction matrix ---
4477 a_chuj(1,1,num_conti,i)=a22
4478 a_chuj(1,2,num_conti,i)=a23
4479 a_chuj(2,1,num_conti,i)=a32
4480 a_chuj(2,2,num_conti,i)=a33
4481 ! --- Gradient of rij
4483 grij_hb_cont(kkk,num_conti,i)=erij(kkk)
4490 a_chuj_der(k,l,m,1,num_conti,i)=agg(m,kkll)
4491 a_chuj_der(k,l,m,2,num_conti,i)=aggi(m,kkll)
4492 a_chuj_der(k,l,m,3,num_conti,i)=aggi1(m,kkll)
4493 a_chuj_der(k,l,m,4,num_conti,i)=aggj(m,kkll)
4494 a_chuj_der(k,l,m,5,num_conti,i)=aggj1(m,kkll)
4499 IF (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) THEN
4500 ! Calculate contact energies
4502 wij=cosa-3.0D0*cosb*cosg
4505 ! fac3=dsqrt(-ael6i)/r0ij**3
4506 fac3=dsqrt(-ael6i)*r3ij
4507 ! ees0pij=dsqrt(4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1)
4508 ees0tmp=4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1
4509 if (ees0tmp.gt.0) then
4510 ees0pij=dsqrt(ees0tmp)
4514 if (shield_mode.eq.0) then
4518 ees0plist(num_conti,i)=j
4520 ! ees0mij=dsqrt(4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2)
4521 ees0tmp=4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2
4522 if (ees0tmp.gt.0) then
4523 ees0mij=dsqrt(ees0tmp)
4528 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij) &
4530 *fac_shield(i)*fac_shield(j)
4531 ! *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4533 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij) &
4535 *fac_shield(i)*fac_shield(j)
4536 ! *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4538 ! Diagnostics. Comment out or remove after debugging!
4539 ! ees0p(num_conti,i)=0.5D0*fac3*ees0pij
4540 ! ees0m(num_conti,i)=0.5D0*fac3*ees0mij
4541 ! ees0m(num_conti,i)=0.0D0
4543 ! write (iout,*) 'i=',i,' j=',j,' rij=',rij,' r0ij=',r0ij,
4544 ! & ' ees0ij=',ees0p(num_conti,i),ees0m(num_conti,i),' fcont=',fcont
4545 ! Angular derivatives of the contact function
4546 ees0pij1=fac3/ees0pij
4547 ees0mij1=fac3/ees0mij
4548 fac3p=-3.0D0*fac3*rrmij
4549 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
4550 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
4552 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
4553 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
4554 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
4555 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
4556 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
4557 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
4558 ecosap=ecosa1+ecosa2
4559 ecosbp=ecosb1+ecosb2
4560 ecosgp=ecosg1+ecosg2
4561 ecosam=ecosa1-ecosa2
4562 ecosbm=ecosb1-ecosb2
4563 ecosgm=ecosg1-ecosg2
4572 facont_hb(num_conti,i)=fcont
4573 fprimcont=fprimcont/rij
4574 !d facont_hb(num_conti,i)=1.0D0
4575 ! Following line is for diagnostics.
4578 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
4579 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
4582 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
4583 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
4585 gggp(1)=gggp(1)+ees0pijp*xj &
4586 +ees0p(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
4587 gggp(2)=gggp(2)+ees0pijp*yj &
4588 +ees0p(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
4589 gggp(3)=gggp(3)+ees0pijp*zj &
4590 +ees0p(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
4592 gggm(1)=gggm(1)+ees0mijp*xj &
4593 +ees0m(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
4595 gggm(2)=gggm(2)+ees0mijp*yj &
4596 +ees0m(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
4598 gggm(3)=gggm(3)+ees0mijp*zj &
4599 +ees0m(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
4601 ! Derivatives due to the contact function
4602 gacont_hbr(1,num_conti,i)=fprimcont*xj
4603 gacont_hbr(2,num_conti,i)=fprimcont*yj
4604 gacont_hbr(3,num_conti,i)=fprimcont*zj
4607 ! 10/24/08 cgrad and ! comments indicate the parts of the code removed
4608 ! following the change of gradient-summation algorithm.
4610 !grad ghalfp=0.5D0*gggp(k)
4611 !grad ghalfm=0.5D0*gggm(k)
4612 gacontp_hb1(k,num_conti,i)= & !ghalfp+
4613 (ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
4614 + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
4615 *sss_ele_cut*fac_shield(i)*fac_shield(j) ! &
4616 ! *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4619 gacontp_hb2(k,num_conti,i)= & !ghalfp+
4620 (ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
4621 + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
4622 *sss_ele_cut*fac_shield(i)*fac_shield(j)! &
4623 ! *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4626 gacontp_hb3(k,num_conti,i)=gggp(k) &
4627 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4628 ! *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4630 gacontm_hb1(k,num_conti,i)= & !ghalfm+
4631 (ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
4632 + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
4633 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4634 ! *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4636 gacontm_hb2(k,num_conti,i)= & !ghalfm+
4637 (ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
4638 + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1) &
4639 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4640 ! *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4642 gacontm_hb3(k,num_conti,i)=gggm(k) &
4643 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4644 ! *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4647 ! Diagnostics. Comment out or remove after debugging!
4649 !diag gacontp_hb1(k,num_conti,i)=0.0D0
4650 !diag gacontp_hb2(k,num_conti,i)=0.0D0
4651 !diag gacontp_hb3(k,num_conti,i)=0.0D0
4652 !diag gacontm_hb1(k,num_conti,i)=0.0D0
4653 !diag gacontm_hb2(k,num_conti,i)=0.0D0
4654 !diag gacontm_hb3(k,num_conti,i)=0.0D0
4657 endif ! num_conti.le.maxconts
4660 if (wturn3.gt.0.0d0 .or. wturn4.gt.0.0d0) then
4663 ghalf=0.5d0*agg(l,k)
4664 aggi(l,k)=aggi(l,k)+ghalf
4665 aggi1(l,k)=aggi1(l,k)+agg(l,k)
4666 aggj(l,k)=aggj(l,k)+ghalf
4669 if (j.eq.nres-1 .and. i.lt.j-2) then
4672 aggj1(l,k)=aggj1(l,k)+agg(l,k)
4678 ! t_eelecij=t_eelecij+MPI_Wtime()-time00
4680 end subroutine eelecij
4681 !-----------------------------------------------------------------------------
4682 subroutine eturn3(i,eello_turn3)
4683 ! Third- and fourth-order contributions from turns
4686 ! implicit real*8 (a-h,o-z)
4687 ! include 'DIMENSIONS'
4688 ! include 'COMMON.IOUNITS'
4689 ! include 'COMMON.GEO'
4690 ! include 'COMMON.VAR'
4691 ! include 'COMMON.LOCAL'
4692 ! include 'COMMON.CHAIN'
4693 ! include 'COMMON.DERIV'
4694 ! include 'COMMON.INTERACT'
4695 ! include 'COMMON.CONTACTS'
4696 ! include 'COMMON.TORSION'
4697 ! include 'COMMON.VECTORS'
4698 ! include 'COMMON.FFIELD'
4699 ! include 'COMMON.CONTROL'
4700 real(kind=8),dimension(3) :: ggg
4701 real(kind=8),dimension(2,2) :: auxmat,auxmat1,auxmat2,pizda,&
4702 e1t,e2t,e3t,e1tder,e2tder,e3tder,e1a,ae3,ae3e2,gpizda1,&
4703 gpizda2,auxgmat1,auxgmatt1,auxgmat2,auxgmatt2
4705 real(kind=8),dimension(2) :: auxvec,auxvec1
4706 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
4707 real(kind=8),dimension(2,2) :: auxmat3 !el, a_temp
4708 !el integer :: num_conti,j1,j2
4709 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
4710 !el dz_normi,xmedi,ymedi,zmedi
4712 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
4713 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
4716 integer :: i,j,l,k,ilist,iresshield
4717 real(kind=8) :: eello_turn3,zj,fracinbuf,eello_t3, rlocshield,xj,yj
4721 ! write (iout,*) "eturn3",i,j,j1,j2
4722 zj=(c(3,j)+c(3,j+1))/2.0d0
4723 call to_box(xj,yj,zj)
4724 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
4730 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4732 ! Third-order contributions
4739 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4740 !d call checkint_turn3(i,a_temp,eello_turn3_num)
4741 call matmat2(EUg(1,1,i+1),EUg(1,1,i+2),auxmat(1,1))
4742 call matmat2(gtEUg(1,1,i+1),EUg(1,1,i+2),auxgmat1(1,1))
4743 call matmat2(EUg(1,1,i+1),gtEUg(1,1,i+2),auxgmat2(1,1))
4744 call transpose2(auxmat(1,1),auxmat1(1,1))
4745 call transpose2(auxgmat1(1,1),auxgmatt1(1,1))
4746 call transpose2(auxgmat2(1,1),auxgmatt2(1,1))
4747 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4748 call matmat2(a_temp(1,1),auxgmatt1(1,1),gpizda1(1,1))
4749 call matmat2(a_temp(1,1),auxgmatt2(1,1),gpizda2(1,1))
4751 if (shield_mode.eq.0) then
4756 eello_turn3=eello_turn3+0.5d0*(pizda(1,1)+pizda(2,2)) &
4757 *fac_shield(i)*fac_shield(j) &
4758 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4760 0.5d0*(pizda(1,1)+pizda(2,2)) &
4761 *fac_shield(i)*fac_shield(j)
4763 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
4764 'eturn3',i,j,0.5d0*(pizda(1,1)+pizda(2,2))
4766 !C Derivatives in theta
4767 gloc(nphi+i,icg)=gloc(nphi+i,icg) &
4768 +0.5d0*(gpizda1(1,1)+gpizda1(2,2))*wturn3&
4769 *fac_shield(i)*fac_shield(j) &
4770 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4772 gloc(nphi+i+1,icg)=gloc(nphi+i+1,icg)&
4773 +0.5d0*(gpizda2(1,1)+gpizda2(2,2))*wturn3&
4774 *fac_shield(i)*fac_shield(j) &
4775 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4782 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
4783 (shield_mode.gt.0)) then
4786 do ilist=1,ishield_list(i)
4787 iresshield=shield_list(ilist,i)
4789 rlocshield=grad_shield_side(k,ilist,i)*eello_t3/fac_shield(i)
4790 gshieldx_t3(k,iresshield)=gshieldx_t3(k,iresshield)+ &
4792 +grad_shield_loc(k,ilist,i)*eello_t3/fac_shield(i)
4793 gshieldc_t3(k,iresshield-1)=gshieldc_t3(k,iresshield-1) &
4797 do ilist=1,ishield_list(j)
4798 iresshield=shield_list(ilist,j)
4800 rlocshield=grad_shield_side(k,ilist,j)*eello_t3/fac_shield(j)
4801 gshieldx_t3(k,iresshield)=gshieldx_t3(k,iresshield)+ &
4803 +grad_shield_loc(k,ilist,j)*eello_t3/fac_shield(j)
4804 gshieldc_t3(k,iresshield-1)=gshieldc_t3(k,iresshield-1) &
4811 gshieldc_t3(k,i)=gshieldc_t3(k,i)+ &
4812 grad_shield(k,i)*eello_t3/fac_shield(i)
4813 gshieldc_t3(k,j)=gshieldc_t3(k,j)+ &
4814 grad_shield(k,j)*eello_t3/fac_shield(j)
4815 gshieldc_t3(k,i-1)=gshieldc_t3(k,i-1)+ &
4816 grad_shield(k,i)*eello_t3/fac_shield(i)
4817 gshieldc_t3(k,j-1)=gshieldc_t3(k,j-1)+ &
4818 grad_shield(k,j)*eello_t3/fac_shield(j)
4822 !d write (2,*) 'i,',i,' j',j,'eello_turn3',
4823 !d & 0.5d0*(pizda(1,1)+pizda(2,2)),
4824 !d & ' eello_turn3_num',4*eello_turn3_num
4825 ! Derivatives in gamma(i)
4826 call matmat2(EUgder(1,1,i+1),EUg(1,1,i+2),auxmat2(1,1))
4827 call transpose2(auxmat2(1,1),auxmat3(1,1))
4828 call matmat2(a_temp(1,1),auxmat3(1,1),pizda(1,1))
4829 gel_loc_turn3(i)=gel_loc_turn3(i)+0.5d0*(pizda(1,1)+pizda(2,2))&
4830 *fac_shield(i)*fac_shield(j) &
4831 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4832 ! Derivatives in gamma(i+1)
4833 call matmat2(EUg(1,1,i+1),EUgder(1,1,i+2),auxmat2(1,1))
4834 call transpose2(auxmat2(1,1),auxmat3(1,1))
4835 call matmat2(a_temp(1,1),auxmat3(1,1),pizda(1,1))
4836 gel_loc_turn3(i+1)=gel_loc_turn3(i+1) &
4837 +0.5d0*(pizda(1,1)+pizda(2,2)) &
4838 *fac_shield(i)*fac_shield(j) &
4839 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4841 ! Cartesian derivatives
4843 ! ghalf1=0.5d0*agg(l,1)
4844 ! ghalf2=0.5d0*agg(l,2)
4845 ! ghalf3=0.5d0*agg(l,3)
4846 ! ghalf4=0.5d0*agg(l,4)
4847 a_temp(1,1)=aggi(l,1)!+ghalf1
4848 a_temp(1,2)=aggi(l,2)!+ghalf2
4849 a_temp(2,1)=aggi(l,3)!+ghalf3
4850 a_temp(2,2)=aggi(l,4)!+ghalf4
4851 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4852 gcorr3_turn(l,i)=gcorr3_turn(l,i) &
4853 +0.5d0*(pizda(1,1)+pizda(2,2)) &
4854 *fac_shield(i)*fac_shield(j) &
4855 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4857 a_temp(1,1)=aggi1(l,1)!+agg(l,1)
4858 a_temp(1,2)=aggi1(l,2)!+agg(l,2)
4859 a_temp(2,1)=aggi1(l,3)!+agg(l,3)
4860 a_temp(2,2)=aggi1(l,4)!+agg(l,4)
4861 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4862 gcorr3_turn(l,i+1)=gcorr3_turn(l,i+1) &
4863 +0.5d0*(pizda(1,1)+pizda(2,2)) &
4864 *fac_shield(i)*fac_shield(j) &
4865 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4867 a_temp(1,1)=aggj(l,1)!+ghalf1
4868 a_temp(1,2)=aggj(l,2)!+ghalf2
4869 a_temp(2,1)=aggj(l,3)!+ghalf3
4870 a_temp(2,2)=aggj(l,4)!+ghalf4
4871 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4872 gcorr3_turn(l,j)=gcorr3_turn(l,j) &
4873 +0.5d0*(pizda(1,1)+pizda(2,2)) &
4874 *fac_shield(i)*fac_shield(j) &
4875 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4877 a_temp(1,1)=aggj1(l,1)
4878 a_temp(1,2)=aggj1(l,2)
4879 a_temp(2,1)=aggj1(l,3)
4880 a_temp(2,2)=aggj1(l,4)
4881 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4882 gcorr3_turn(l,j1)=gcorr3_turn(l,j1) &
4883 +0.5d0*(pizda(1,1)+pizda(2,2)) &
4884 *fac_shield(i)*fac_shield(j) &
4885 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4887 gshieldc_t3(3,i)=gshieldc_t3(3,i)+ &
4888 ssgradlipi*eello_t3/4.0d0*lipscale
4889 gshieldc_t3(3,j)=gshieldc_t3(3,j)+ &
4890 ssgradlipj*eello_t3/4.0d0*lipscale
4891 gshieldc_t3(3,i-1)=gshieldc_t3(3,i-1)+ &
4892 ssgradlipi*eello_t3/4.0d0*lipscale
4893 gshieldc_t3(3,j-1)=gshieldc_t3(3,j-1)+ &
4894 ssgradlipj*eello_t3/4.0d0*lipscale
4897 end subroutine eturn3
4898 !-----------------------------------------------------------------------------
4899 subroutine eturn4(i,eello_turn4)
4900 ! Third- and fourth-order contributions from turns
4903 ! implicit real*8 (a-h,o-z)
4904 ! include 'DIMENSIONS'
4905 ! include 'COMMON.IOUNITS'
4906 ! include 'COMMON.GEO'
4907 ! include 'COMMON.VAR'
4908 ! include 'COMMON.LOCAL'
4909 ! include 'COMMON.CHAIN'
4910 ! include 'COMMON.DERIV'
4911 ! include 'COMMON.INTERACT'
4912 ! include 'COMMON.CONTACTS'
4913 ! include 'COMMON.TORSION'
4914 ! include 'COMMON.VECTORS'
4915 ! include 'COMMON.FFIELD'
4916 ! include 'COMMON.CONTROL'
4917 real(kind=8),dimension(3) :: ggg
4918 real(kind=8),dimension(2,2) :: auxmat,auxmat1,auxmat2,pizda,&
4919 e1t,e2t,e3t,e1tder,e2tder,e3tder,e1a,ae3,ae3e2,&
4921 gte1a,gtae3,gtae3e2, ae3gte2,&
4922 gtEpizda1,gtEpizda2,gtEpizda3
4924 real(kind=8),dimension(2) :: auxvec,auxvec1,auxgEvec1,auxgEvec2,&
4927 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
4928 real(kind=8),dimension(2,2) :: auxmat3 !el a_temp
4929 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
4930 !el dz_normi,xmedi,ymedi,zmedi
4931 !el integer :: num_conti,j1,j2
4932 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
4933 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
4936 integer :: i,j,iti1,iti2,iti3,l,k,ilist,iresshield
4937 real(kind=8) :: eello_turn4,s1,s2,s3,zj,fracinbuf,eello_t4,&
4938 rlocshield,gs23,gs32,gsE13,gs13,gs21,gsE31,gsEE1,gsEE2,gsEE3,xj,yj
4942 ! if (j.ne.20) return
4943 ! print *,i,j,gshieldc_t4(2,j),gshieldc_t4(2,j+1)
4944 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4946 ! Fourth-order contributions
4954 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4955 !d call checkint_turn4(i,a_temp,eello_turn4_num)
4956 ! write (iout,*) "eturn4 i",i," j",j," j1",j1," j2",j2
4957 zj=(c(3,j)+c(3,j+1))/2.0d0
4958 call to_box(xj,yj,zj)
4959 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
4969 ! write(iout,*) "iti1",iti1," iti2",iti2," iti3",iti3
4970 call transpose2(EUg(1,1,i+1),e1t(1,1))
4971 call transpose2(Eug(1,1,i+2),e2t(1,1))
4972 call transpose2(Eug(1,1,i+3),e3t(1,1))
4973 !C Ematrix derivative in theta
4974 call transpose2(gtEUg(1,1,i+1),gte1t(1,1))
4975 call transpose2(gtEug(1,1,i+2),gte2t(1,1))
4976 call transpose2(gtEug(1,1,i+3),gte3t(1,1))
4978 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
4979 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
4980 call matmat2(gte1t(1,1),a_temp(1,1),gte1a(1,1))
4981 call matvec2(e1a(1,1),gUb2(1,i+3),auxgvec(1))
4982 !c auxalary matrix of E i+1
4983 call matvec2(gte1a(1,1),Ub2(1,i+3),auxgEvec1(1))
4984 s1=scalar2(b1(1,iti2),auxvec(1))
4985 !c derivative of theta i+2 with constant i+3
4986 gs23=scalar2(gtb1(1,i+2),auxvec(1))
4987 !c derivative of theta i+2 with constant i+2
4988 gs32=scalar2(b1(1,i+2),auxgvec(1))
4989 !c derivative of E matix in theta of i+1
4990 gsE13=scalar2(b1(1,i+2),auxgEvec1(1))
4992 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
4993 call matmat2(a_temp(1,1),gte3t(1,1),gtae3(1,1))
4994 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
4995 !c auxilary matrix auxgvec of Ub2 with constant E matirx
4996 call matvec2(ae3(1,1),gUb2(1,i+2),auxgvec(1))
4997 !c auxilary matrix auxgEvec1 of E matix with Ub2 constant
4998 call matvec2(gtae3(1,1),Ub2(1,i+2),auxgEvec3(1))
4999 s2=scalar2(b1(1,i+1),auxvec(1))
5000 !c derivative of theta i+1 with constant i+3
5001 gs13=scalar2(gtb1(1,i+1),auxvec(1))
5002 !c derivative of theta i+2 with constant i+1
5003 gs21=scalar2(b1(1,i+1),auxgvec(1))
5004 !c derivative of theta i+3 with constant i+1
5005 gsE31=scalar2(b1(1,i+1),auxgEvec3(1))
5007 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
5008 call matmat2(gtae3(1,1),e2t(1,1),gtae3e2(1,1))
5009 !c ae3gte2 is derivative over i+2
5010 call matmat2(ae3(1,1),gte2t(1,1),ae3gte2(1,1))
5012 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
5013 call matmat2(ae3e2(1,1),gte1t(1,1),gtEpizda1(1,1))
5015 call matmat2(ae3gte2(1,1),e1t(1,1),gtEpizda2(1,1))
5017 call matmat2(gtae3e2(1,1),e1t(1,1),gtEpizda3(1,1))
5019 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5020 gsEE1=0.5d0*(gtEpizda1(1,1)+gtEpizda1(2,2))
5021 gsEE2=0.5d0*(gtEpizda2(1,1)+gtEpizda2(2,2))
5022 gsEE3=0.5d0*(gtEpizda3(1,1)+gtEpizda3(2,2))
5023 if (shield_mode.eq.0) then
5028 eello_turn4=eello_turn4-(s1+s2+s3) &
5029 *fac_shield(i)*fac_shield(j) &
5030 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5031 eello_t4=-(s1+s2+s3) &
5032 *fac_shield(i)*fac_shield(j)
5033 !C Now derivative over shield:
5034 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
5035 (shield_mode.gt.0)) then
5038 do ilist=1,ishield_list(i)
5039 iresshield=shield_list(ilist,i)
5041 rlocshield=grad_shield_side(k,ilist,i)*eello_t4/fac_shield(i)
5042 ! print *,"rlocshield",rlocshield,grad_shield_side(k,ilist,i),iresshield
5043 gshieldx_t4(k,iresshield)=gshieldx_t4(k,iresshield)+ &
5045 +grad_shield_loc(k,ilist,i)*eello_t4/fac_shield(i)
5046 gshieldc_t4(k,iresshield-1)=gshieldc_t4(k,iresshield-1) &
5050 do ilist=1,ishield_list(j)
5051 iresshield=shield_list(ilist,j)
5053 ! print *,"rlocshieldj",j,rlocshield,grad_shield_side(k,ilist,j),iresshield
5054 rlocshield=grad_shield_side(k,ilist,j)*eello_t4/fac_shield(j)
5055 gshieldx_t4(k,iresshield)=gshieldx_t4(k,iresshield)+ &
5057 +grad_shield_loc(k,ilist,j)*eello_t4/fac_shield(j)
5058 gshieldc_t4(k,iresshield-1)=gshieldc_t4(k,iresshield-1) &
5060 ! print *,"after", gshieldc_t4(k,iresshield-1),iresshield-1,gshieldc_t4(k,iresshield)
5065 gshieldc_t4(k,i)=gshieldc_t4(k,i)+ &
5066 grad_shield(k,i)*eello_t4/fac_shield(i)
5067 gshieldc_t4(k,j)=gshieldc_t4(k,j)+ &
5068 grad_shield(k,j)*eello_t4/fac_shield(j)
5069 gshieldc_t4(k,i-1)=gshieldc_t4(k,i-1)+ &
5070 grad_shield(k,i)*eello_t4/fac_shield(i)
5071 gshieldc_t4(k,j-1)=gshieldc_t4(k,j-1)+ &
5072 grad_shield(k,j)*eello_t4/fac_shield(j)
5073 ! print *,"gshieldc_t4(k,j+1)",j,gshieldc_t4(k,j+1)
5077 gloc(nphi+i,icg)=gloc(nphi+i,icg)&
5078 -(gs13+gsE13+gsEE1)*wturn4&
5079 *fac_shield(i)*fac_shield(j)
5080 gloc(nphi+i+1,icg)= gloc(nphi+i+1,icg)&
5081 -(gs23+gs21+gsEE2)*wturn4&
5082 *fac_shield(i)*fac_shield(j)
5084 gloc(nphi+i+2,icg)= gloc(nphi+i+2,icg)&
5085 -(gs32+gsE31+gsEE3)*wturn4&
5086 *fac_shield(i)*fac_shield(j)
5088 !c gloc(nphi+i+1,icg)=gloc(nphi+i+1,icg)-
5091 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
5092 'eturn4',i,j,-(s1+s2+s3)
5093 !d write (2,*) 'i,',i,' j',j,'eello_turn4',-(s1+s2+s3),
5094 !d & ' eello_turn4_num',8*eello_turn4_num
5095 ! Derivatives in gamma(i)
5096 call transpose2(EUgder(1,1,i+1),e1tder(1,1))
5097 call matmat2(e1tder(1,1),a_temp(1,1),auxmat(1,1))
5098 call matvec2(auxmat(1,1),Ub2(1,i+3),auxvec(1))
5099 s1=scalar2(b1(1,i+1),auxvec(1))
5100 call matmat2(ae3e2(1,1),e1tder(1,1),pizda(1,1))
5101 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5102 gel_loc_turn4(i)=gel_loc_turn4(i)-(s1+s3) &
5103 *fac_shield(i)*fac_shield(j) &
5104 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5106 ! Derivatives in gamma(i+1)
5107 call transpose2(EUgder(1,1,i+2),e2tder(1,1))
5108 call matvec2(ae3(1,1),Ub2der(1,i+2),auxvec(1))
5109 s2=scalar2(b1(1,iti1),auxvec(1))
5110 call matmat2(ae3(1,1),e2tder(1,1),auxmat(1,1))
5111 call matmat2(auxmat(1,1),e1t(1,1),pizda(1,1))
5112 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5113 gel_loc_turn4(i+1)=gel_loc_turn4(i+1)-(s2+s3) &
5114 *fac_shield(i)*fac_shield(j) &
5115 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5117 ! Derivatives in gamma(i+2)
5118 call transpose2(EUgder(1,1,i+3),e3tder(1,1))
5119 call matvec2(e1a(1,1),Ub2der(1,i+3),auxvec(1))
5120 s1=scalar2(b1(1,iti2),auxvec(1))
5121 call matmat2(a_temp(1,1),e3tder(1,1),auxmat(1,1))
5122 call matvec2(auxmat(1,1),Ub2(1,i+2),auxvec(1))
5123 s2=scalar2(b1(1,iti1),auxvec(1))
5124 call matmat2(auxmat(1,1),e2t(1,1),auxmat3(1,1))
5125 call matmat2(auxmat3(1,1),e1t(1,1),pizda(1,1))
5126 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5127 gel_loc_turn4(i+2)=gel_loc_turn4(i+2)-(s1+s2+s3) &
5128 *fac_shield(i)*fac_shield(j) &
5129 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5131 ! Cartesian derivatives
5132 ! Derivatives of this turn contributions in DC(i+2)
5133 if (j.lt.nres-1) then
5135 a_temp(1,1)=agg(l,1)
5136 a_temp(1,2)=agg(l,2)
5137 a_temp(2,1)=agg(l,3)
5138 a_temp(2,2)=agg(l,4)
5139 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
5140 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
5141 s1=scalar2(b1(1,iti2),auxvec(1))
5142 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
5143 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
5144 s2=scalar2(b1(1,iti1),auxvec(1))
5145 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
5146 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
5147 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5149 gcorr4_turn(l,i+2)=gcorr4_turn(l,i+2)-(s1+s2+s3)&
5150 *fac_shield(i)*fac_shield(j) &
5151 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5155 ! Remaining derivatives of this turn contribution
5157 a_temp(1,1)=aggi(l,1)
5158 a_temp(1,2)=aggi(l,2)
5159 a_temp(2,1)=aggi(l,3)
5160 a_temp(2,2)=aggi(l,4)
5161 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
5162 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
5163 s1=scalar2(b1(1,iti2),auxvec(1))
5164 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
5165 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
5166 s2=scalar2(b1(1,iti1),auxvec(1))
5167 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
5168 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
5169 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5170 gcorr4_turn(l,i)=gcorr4_turn(l,i)-(s1+s2+s3) &
5171 *fac_shield(i)*fac_shield(j) &
5172 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5175 a_temp(1,1)=aggi1(l,1)
5176 a_temp(1,2)=aggi1(l,2)
5177 a_temp(2,1)=aggi1(l,3)
5178 a_temp(2,2)=aggi1(l,4)
5179 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
5180 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
5181 s1=scalar2(b1(1,iti2),auxvec(1))
5182 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
5183 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
5184 s2=scalar2(b1(1,iti1),auxvec(1))
5185 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
5186 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
5187 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5188 gcorr4_turn(l,i+1)=gcorr4_turn(l,i+1)-(s1+s2+s3) &
5189 *fac_shield(i)*fac_shield(j) &
5190 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5193 a_temp(1,1)=aggj(l,1)
5194 a_temp(1,2)=aggj(l,2)
5195 a_temp(2,1)=aggj(l,3)
5196 a_temp(2,2)=aggj(l,4)
5197 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
5198 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
5199 s1=scalar2(b1(1,iti2),auxvec(1))
5200 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
5201 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
5202 s2=scalar2(b1(1,iti1),auxvec(1))
5203 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
5204 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
5205 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5206 ! if (j.lt.nres-1) then
5207 gcorr4_turn(l,j)=gcorr4_turn(l,j)-(s1+s2+s3) &
5208 *fac_shield(i)*fac_shield(j) &
5209 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5212 a_temp(1,1)=aggj1(l,1)
5213 a_temp(1,2)=aggj1(l,2)
5214 a_temp(2,1)=aggj1(l,3)
5215 a_temp(2,2)=aggj1(l,4)
5216 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
5217 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
5218 s1=scalar2(b1(1,iti2),auxvec(1))
5219 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
5220 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
5221 s2=scalar2(b1(1,iti1),auxvec(1))
5222 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
5223 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
5224 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5225 ! write (iout,*) "s1",s1," s2",s2," s3",s3," s1+s2+s3",s1+s2+s3
5226 ! if (j.lt.nres-1) then
5227 ! print *,"juest before",j1, gcorr4_turn(l,j1)
5228 gcorr4_turn(l,j1)=gcorr4_turn(l,j1)-(s1+s2+s3) &
5229 *fac_shield(i)*fac_shield(j) &
5230 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5231 ! if (shield_mode.gt.0) then
5232 ! print *,"juest after",j1, gcorr4_turn(l,j1),gshieldc_t4(k,j1),gshieldc_loc_t4(k,j1),gel_loc_turn4(i+2)
5234 ! print *,"juest after",j1, gcorr4_turn(l,j1),gel_loc_turn4(i+2)
5238 gshieldc_t4(3,i)=gshieldc_t4(3,i)+ &
5239 ssgradlipi*eello_t4/4.0d0*lipscale
5240 gshieldc_t4(3,j)=gshieldc_t4(3,j)+ &
5241 ssgradlipj*eello_t4/4.0d0*lipscale
5242 gshieldc_t4(3,i-1)=gshieldc_t4(3,i-1)+ &
5243 ssgradlipi*eello_t4/4.0d0*lipscale
5244 gshieldc_t4(3,j-1)=gshieldc_t4(3,j-1)+ &
5245 ssgradlipj*eello_t4/4.0d0*lipscale
5248 end subroutine eturn4
5249 !-----------------------------------------------------------------------------
5250 subroutine unormderiv(u,ugrad,unorm,ungrad)
5251 ! This subroutine computes the derivatives of a normalized vector u, given
5252 ! the derivatives computed without normalization conditions, ugrad. Returns
5255 real(kind=8),dimension(3) :: u,vec
5256 real(kind=8),dimension(3,3) ::ugrad,ungrad
5257 real(kind=8) :: unorm !,scalar
5259 ! write (2,*) 'ugrad',ugrad
5262 vec(i)=scalar(ugrad(1,i),u(1))
5264 ! write (2,*) 'vec',vec
5267 ungrad(j,i)=(ugrad(j,i)-u(j)*vec(i))*unorm
5270 ! write (2,*) 'ungrad',ungrad
5272 end subroutine unormderiv
5273 !-----------------------------------------------------------------------------
5274 subroutine escp_soft_sphere(evdw2,evdw2_14)
5276 ! This subroutine calculates the excluded-volume interaction energy between
5277 ! peptide-group centers and side chains and its gradient in virtual-bond and
5278 ! side-chain vectors.
5280 ! implicit real*8 (a-h,o-z)
5281 ! include 'DIMENSIONS'
5282 ! include 'COMMON.GEO'
5283 ! include 'COMMON.VAR'
5284 ! include 'COMMON.LOCAL'
5285 ! include 'COMMON.CHAIN'
5286 ! include 'COMMON.DERIV'
5287 ! include 'COMMON.INTERACT'
5288 ! include 'COMMON.FFIELD'
5289 ! include 'COMMON.IOUNITS'
5290 ! include 'COMMON.CONTROL'
5291 real(kind=8),dimension(3) :: ggg
5293 integer :: i,iint,j,k,iteli,itypj
5294 real(kind=8) :: evdw2,evdw2_14,r0_scp,xi,yi,zi,xj,yj,zj,&
5295 fac,rij,r0ij,r0ijsq,evdwij,e1,e2
5300 !d print '(a)','Enter ESCP'
5301 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
5302 do i=iatscp_s,iatscp_e
5303 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
5305 xi=0.5D0*(c(1,i)+c(1,i+1))
5306 yi=0.5D0*(c(2,i)+c(2,i+1))
5307 zi=0.5D0*(c(3,i)+c(3,i+1))
5308 call to_box(xi,yi,zi)
5310 do iint=1,nscp_gr(i)
5312 do j=iscpstart(i,iint),iscpend(i,iint)
5313 if (itype(j,1).eq.ntyp1) cycle
5314 itypj=iabs(itype(j,1))
5315 ! Uncomment following three lines for SC-p interactions
5319 ! Uncomment following three lines for Ca-p interactions
5323 call to_box(xj,yj,zj)
5324 xj=boxshift(xj-xi,boxxsize)
5325 yj=boxshift(yj-yi,boxysize)
5326 zj=boxshift(zj-zi,boxzsize)
5327 rij=xj*xj+yj*yj+zj*zj
5330 if (rij.lt.r0ijsq) then
5331 evdwij=0.25d0*(rij-r0ijsq)**2
5339 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
5344 !grad if (j.lt.i) then
5345 !d write (iout,*) 'j<i'
5346 ! Uncomment following three lines for SC-p interactions
5348 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
5351 !d write (iout,*) 'j>i'
5353 !grad ggg(k)=-ggg(k)
5354 ! Uncomment following line for SC-p interactions
5355 ! gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
5359 !grad gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
5361 !grad kstart=min0(i+1,j)
5362 !grad kend=max0(i-1,j-1)
5363 !d write (iout,*) 'i=',i,' j=',j,' kstart=',kstart,' kend=',kend
5364 !d write (iout,*) ggg(1),ggg(2),ggg(3)
5365 !grad do k=kstart,kend
5367 !grad gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
5371 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
5372 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
5379 end subroutine escp_soft_sphere
5380 !-----------------------------------------------------------------------------
5381 subroutine escp(evdw2,evdw2_14)
5383 ! This subroutine calculates the excluded-volume interaction energy between
5384 ! peptide-group centers and side chains and its gradient in virtual-bond and
5385 ! side-chain vectors.
5387 ! implicit real*8 (a-h,o-z)
5388 ! include 'DIMENSIONS'
5389 ! include 'COMMON.GEO'
5390 ! include 'COMMON.VAR'
5391 ! include 'COMMON.LOCAL'
5392 ! include 'COMMON.CHAIN'
5393 ! include 'COMMON.DERIV'
5394 ! include 'COMMON.INTERACT'
5395 ! include 'COMMON.FFIELD'
5396 ! include 'COMMON.IOUNITS'
5397 ! include 'COMMON.CONTROL'
5398 real(kind=8),dimension(3) :: ggg
5400 integer :: i,iint,j,k,iteli,itypj,subchap,icont
5401 real(kind=8) :: evdw2,evdw2_14,xi,yi,zi,xj,yj,zj,rrij,fac,&
5403 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
5404 dist_temp, dist_init
5405 integer xshift,yshift,zshift
5409 !d print '(a)','Enter ESCP'
5410 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
5411 ! do i=iatscp_s,iatscp_e
5412 do icont=g_listscp_start,g_listscp_end
5413 i=newcontlistscpi(icont)
5414 j=newcontlistscpj(icont)
5415 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
5417 xi=0.5D0*(c(1,i)+c(1,i+1))
5418 yi=0.5D0*(c(2,i)+c(2,i+1))
5419 zi=0.5D0*(c(3,i)+c(3,i+1))
5420 call to_box(xi,yi,zi)
5422 ! do iint=1,nscp_gr(i)
5424 ! do j=iscpstart(i,iint),iscpend(i,iint)
5425 itypj=iabs(itype(j,1))
5426 if (itypj.eq.ntyp1) cycle
5427 ! Uncomment following three lines for SC-p interactions
5431 ! Uncomment following three lines for Ca-p interactions
5439 call to_box(xj,yj,zj)
5440 xj=boxshift(xj-xi,boxxsize)
5441 yj=boxshift(yj-yi,boxysize)
5442 zj=boxshift(zj-zi,boxzsize)
5444 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
5445 rij=dsqrt(1.0d0/rrij)
5446 sss_ele_cut=sscale_ele(rij)
5447 sss_ele_grad=sscagrad_ele(rij)
5448 ! print *,sss_ele_cut,sss_ele_grad,&
5449 ! (rij),r_cut_ele,rlamb_ele
5450 if (sss_ele_cut.le.0.0) cycle
5452 e1=fac*fac*aad(itypj,iteli)
5453 e2=fac*bad(itypj,iteli)
5454 if (iabs(j-i) .le. 2) then
5457 evdw2_14=evdw2_14+(e1+e2)*sss_ele_cut
5460 evdw2=evdw2+evdwij*sss_ele_cut
5461 ! if (energy_dec) write (iout,'(a6,2i5,0pf7.3,2i3,3e11.3)') &
5462 ! 'evdw2',i,j,evdwij,iteli,itypj,fac,aad(itypj,iteli),&
5463 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
5466 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
5468 fac=-(evdwij+e1)*rrij*sss_ele_cut
5469 fac=fac+evdwij*sss_ele_grad/rij/expon
5473 !grad if (j.lt.i) then
5474 !d write (iout,*) 'j<i'
5475 ! Uncomment following three lines for SC-p interactions
5477 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
5480 !d write (iout,*) 'j>i'
5482 !grad ggg(k)=-ggg(k)
5483 ! Uncomment following line for SC-p interactions
5484 !cgrad gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
5485 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
5489 !grad gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
5491 !grad kstart=min0(i+1,j)
5492 !grad kend=max0(i-1,j-1)
5493 !d write (iout,*) 'i=',i,' j=',j,' kstart=',kstart,' kend=',kend
5494 !d write (iout,*) ggg(1),ggg(2),ggg(3)
5495 !grad do k=kstart,kend
5497 !grad gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
5501 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
5502 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
5510 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
5511 gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
5512 gradx_scp(j,i)=expon*gradx_scp(j,i)
5515 !******************************************************************************
5519 ! To save time the factor EXPON has been extracted from ALL components
5520 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
5523 !******************************************************************************
5526 !-----------------------------------------------------------------------------
5527 subroutine edis(ehpb)
5529 ! Evaluate bridge-strain energy and its gradient in virtual-bond and SC vectors.
5531 ! implicit real*8 (a-h,o-z)
5532 ! include 'DIMENSIONS'
5533 ! include 'COMMON.SBRIDGE'
5534 ! include 'COMMON.CHAIN'
5535 ! include 'COMMON.DERIV'
5536 ! include 'COMMON.VAR'
5537 ! include 'COMMON.INTERACT'
5538 ! include 'COMMON.IOUNITS'
5539 real(kind=8),dimension(3) :: ggg
5541 integer :: i,j,ii,jj,iii,jjj,k
5542 real(kind=8) :: fac,eij,rdis,ehpb,dd,waga
5545 !d write(iout,*)'edis: nhpb=',nhpb,' fbr=',fbr
5546 !d write(iout,*)'link_start=',link_start,' link_end=',link_end
5547 if (link_end.eq.0) return
5548 do i=link_start,link_end
5549 ! If ihpb(i) and jhpb(i) > NRES, this is a SC-SC distance, otherwise a
5550 ! CA-CA distance used in regularization of structure.
5553 ! iii and jjj point to the residues for which the distance is assigned.
5554 if (ii.gt.nres) then
5561 ! write (iout,*) "i",i," ii",ii," iii",iii," jj",jj," jjj",jjj,
5562 ! & dhpb(i),dhpb1(i),forcon(i)
5563 ! 24/11/03 AL: SS bridges handled separately because of introducing a specific
5564 ! distance and angle dependent SS bond potential.
5565 !mc if (ii.gt.nres .and. itype(iii).eq.1 .and. itype(jjj).eq.1) then
5566 ! 18/07/06 MC: Use the convention that the first nss pairs are SS bonds
5567 if (.not.dyn_ss .and. i.le.nss) then
5568 ! 15/02/13 CC dynamic SSbond - additional check
5569 if (ii.gt.nres .and. iabs(itype(iii,1)).eq.1 .and. &
5570 iabs(itype(jjj,1)).eq.1) then
5571 call ssbond_ene(iii,jjj,eij)
5573 !d write (iout,*) "eij",eij
5575 else if (ii.gt.nres .and. jj.gt.nres) then
5576 !c Restraints from contact prediction
5578 if (constr_dist.eq.11) then
5579 ehpb=ehpb+fordepth(i)**4.0d0 &
5580 *rlornmr1(dd,dhpb(i),dhpb1(i),forcon(i))
5581 fac=fordepth(i)**4.0d0 &
5582 *rlornmr1prim(dd,dhpb(i),dhpb1(i),forcon(i))/dd
5583 if (energy_dec) write (iout,'(a6,2i5,3f8.3)') "edisl",ii,jj, &
5586 if (dhpb1(i).gt.0.0d0) then
5587 ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5588 fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
5589 !c write (iout,*) "beta nmr",
5590 !c & dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5594 !C Get the force constant corresponding to this distance.
5596 !C Calculate the contribution to energy.
5597 ehpb=ehpb+waga*rdis*rdis
5598 !c write (iout,*) "beta reg",dd,waga*rdis*rdis
5600 !C Evaluate gradient.
5606 ggg(j)=fac*(c(j,jj)-c(j,ii))
5609 ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
5610 ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
5613 ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
5614 ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
5618 if (constr_dist.eq.11) then
5619 ehpb=ehpb+fordepth(i)**4.0d0 &
5620 *rlornmr1(dd,dhpb(i),dhpb1(i),forcon(i))
5621 fac=fordepth(i)**4.0d0 &
5622 *rlornmr1prim(dd,dhpb(i),dhpb1(i),forcon(i))/dd
5623 if (energy_dec) write (iout,'(a6,2i5,3f8.3)') "edisl",ii,jj, &
5626 if (dhpb1(i).gt.0.0d0) then
5627 ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5628 fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
5629 !c write (iout,*) "alph nmr",
5630 !c & dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5633 !C Get the force constant corresponding to this distance.
5635 !C Calculate the contribution to energy.
5636 ehpb=ehpb+waga*rdis*rdis
5637 !c write (iout,*) "alpha reg",dd,waga*rdis*rdis
5639 !C Evaluate gradient.
5646 ggg(j)=fac*(c(j,jj)-c(j,ii))
5648 !cd print '(i3,3(1pe14.5))',i,(ggg(j),j=1,3)
5649 !C If this is a SC-SC distance, we need to calculate the contributions to the
5650 !C Cartesian gradient in the SC vectors (ghpbx).
5653 ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
5654 ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
5657 !cgrad do j=iii,jjj-1
5659 !cgrad ghpbc(k,j)=ghpbc(k,j)+ggg(k)
5663 ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
5664 ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
5668 if (constr_dist.ne.11) ehpb=0.5D0*ehpb
5672 !-----------------------------------------------------------------------------
5673 subroutine ssbond_ene(i,j,eij)
5675 ! Calculate the distance and angle dependent SS-bond potential energy
5676 ! using a free-energy function derived based on RHF/6-31G** ab initio
5677 ! calculations of diethyl disulfide.
5679 ! A. Liwo and U. Kozlowska, 11/24/03
5681 ! implicit real*8 (a-h,o-z)
5682 ! include 'DIMENSIONS'
5683 ! include 'COMMON.SBRIDGE'
5684 ! include 'COMMON.CHAIN'
5685 ! include 'COMMON.DERIV'
5686 ! include 'COMMON.LOCAL'
5687 ! include 'COMMON.INTERACT'
5688 ! include 'COMMON.VAR'
5689 ! include 'COMMON.IOUNITS'
5690 real(kind=8),dimension(3) :: erij,dcosom1,dcosom2,gg
5692 integer :: i,j,itypi,itypj,k
5693 real(kind=8) :: eij,rij,rrij,xi,yi,zi,dxi,dyi,dzi,dsci_inv,&
5694 xj,yj,zj,dxj,dyj,dzj,om1,om2,om12,deltad,dscj_inv,&
5695 deltat1,deltat2,deltat12,ed,pom1,pom2,eom1,eom2,eom12,&
5698 itypi=iabs(itype(i,1))
5702 call to_box(xi,yi,zi)
5704 dxi=dc_norm(1,nres+i)
5705 dyi=dc_norm(2,nres+i)
5706 dzi=dc_norm(3,nres+i)
5707 ! dsci_inv=dsc_inv(itypi)
5708 dsci_inv=vbld_inv(nres+i)
5709 itypj=iabs(itype(j,1))
5710 ! dscj_inv=dsc_inv(itypj)
5711 dscj_inv=vbld_inv(nres+j)
5715 call to_box(xj,yj,zj)
5716 dxj=dc_norm(1,nres+j)
5717 dyj=dc_norm(2,nres+j)
5718 dzj=dc_norm(3,nres+j)
5719 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
5724 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
5725 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
5726 om12=dxi*dxj+dyi*dyj+dzi*dzj
5728 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
5729 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
5735 deltat12=om2-om1+2.0d0
5737 eij=akcm*deltad*deltad+akth*(deltat1*deltat1+deltat2*deltat2) &
5738 +akct*deltad*deltat12 &
5739 +v1ss*cosphi+v2ss*cosphi*cosphi+v3ss*cosphi*cosphi*cosphi+ebr
5740 ! write(iout,*) i,j,"rij",rij,"d0cm",d0cm," akcm",akcm," akth",akth,
5741 ! & " akct",akct," deltad",deltad," deltat",deltat1,deltat2,
5742 ! & " deltat12",deltat12," eij",eij
5743 ed=2*akcm*deltad+akct*deltat12
5745 pom2=v1ss+2*v2ss*cosphi+3*v3ss*cosphi*cosphi
5746 eom1=-2*akth*deltat1-pom1-om2*pom2
5747 eom2= 2*akth*deltat2+pom1-om1*pom2
5750 ggk=ed*erij(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
5751 ghpbx(k,i)=ghpbx(k,i)-ggk &
5752 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
5753 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
5754 ghpbx(k,j)=ghpbx(k,j)+ggk &
5755 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
5756 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
5757 ghpbc(k,i)=ghpbc(k,i)-ggk
5758 ghpbc(k,j)=ghpbc(k,j)+ggk
5761 ! Calculate the components of the gradient in DC and X
5765 !grad ghpbc(l,k)=ghpbc(l,k)+gg(l)
5769 end subroutine ssbond_ene
5770 !-----------------------------------------------------------------------------
5771 subroutine ebond(estr)
5773 ! Evaluate the energy of stretching of the CA-CA and CA-SC virtual bonds
5775 ! implicit real*8 (a-h,o-z)
5776 ! include 'DIMENSIONS'
5777 ! include 'COMMON.LOCAL'
5778 ! include 'COMMON.GEO'
5779 ! include 'COMMON.INTERACT'
5780 ! include 'COMMON.DERIV'
5781 ! include 'COMMON.VAR'
5782 ! include 'COMMON.CHAIN'
5783 ! include 'COMMON.IOUNITS'
5784 ! include 'COMMON.NAMES'
5785 ! include 'COMMON.FFIELD'
5786 ! include 'COMMON.CONTROL'
5787 ! include 'COMMON.SETUP'
5788 real(kind=8),dimension(3) :: u,ud
5790 integer :: i,j,iti,nbi,k
5791 real(kind=8) :: estr,estr1,diff,uprod,usum,usumsqder,&
5796 ! if (.not.allocated(gradb)) allocate(gradb(3,nres)) !(3,maxres)
5797 ! if (.not.allocated(gradbx)) allocate(gradbx(3,nres)) !(3,maxres)
5799 do i=ibondp_start,ibondp_end
5800 if (itype(i-1,1).eq.ntyp1 .and. itype(i,1).eq.ntyp1) cycle
5801 if (itype(i-1,1).eq.ntyp1 .or. itype(i,1).eq.ntyp1) then
5802 !C estr1=estr1+gnmr1(vbld(i),-1.0d0,distchainmax)
5804 !C gradb(j,i-1)=gnmr1prim(vbld(i),-1.0d0,distchainmax) &
5805 !C *dc(j,i-1)/vbld(i)
5807 !C if (energy_dec) write(iout,*) &
5808 !C "estr1",i,gnmr1(vbld(i),-1.0d0,distchainmax)
5809 diff = vbld(i)-vbldpDUM
5811 diff = vbld(i)-vbldp0
5813 if (energy_dec) write (iout,'(a7,i5,4f7.3)') &
5814 "estr bb",i,vbld(i),vbldp0,diff,AKP*diff*diff
5817 gradb(j,i-1)=AKP*diff*dc(j,i-1)/vbld(i)
5819 ! write (iout,'(i5,3f10.5)') i,(gradb(j,i-1),j=1,3)
5822 estr=0.5d0*AKP*estr+estr1
5823 ! print *,"estr_bb",estr,AKP
5825 ! 09/18/07 AL: multimodal bond potential based on AM1 CA-SC PMF's included
5827 do i=ibond_start,ibond_end
5828 iti=iabs(itype(i,1))
5829 if (iti.eq.0) print *,"WARNING WRONG SETTTING",i
5830 if (iti.ne.10 .and. iti.ne.ntyp1) then
5833 diff=vbld(i+nres)-vbldsc0(1,iti)
5834 if (energy_dec) write (iout,*) &
5835 "estr sc",i,iti,vbld(i+nres),vbldsc0(1,iti),diff,&
5836 AKSC(1,iti),AKSC(1,iti)*diff*diff
5837 estr=estr+0.5d0*AKSC(1,iti)*diff*diff
5838 ! print *,"estr_sc",estr
5840 gradbx(j,i)=AKSC(1,iti)*diff*dc(j,i+nres)/vbld(i+nres)
5844 diff=vbld(i+nres)-vbldsc0(j,iti)
5845 ud(j)=aksc(j,iti)*diff
5846 u(j)=abond0(j,iti)+0.5d0*ud(j)*diff
5860 uprod2=uprod2*u(k)*u(k)
5864 usumsqder=usumsqder+ud(j)*uprod2
5866 estr=estr+uprod/usum
5867 ! print *,"estr_sc",estr,i
5869 if (energy_dec) write (iout,*) &
5870 "estr sc",i,iti,vbld(i+nres),vbldsc0(1,iti),diff,&
5871 AKSC(1,iti),uprod/usum
5873 gradbx(j,i)=usumsqder/(usum*usum)*dc(j,i+nres)/vbld(i+nres)
5879 end subroutine ebond
5881 !-----------------------------------------------------------------------------
5882 subroutine ebend(etheta)
5884 ! Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
5885 ! angles gamma and its derivatives in consecutive thetas and gammas.
5888 ! implicit real*8 (a-h,o-z)
5889 ! include 'DIMENSIONS'
5890 ! include 'COMMON.LOCAL'
5891 ! include 'COMMON.GEO'
5892 ! include 'COMMON.INTERACT'
5893 ! include 'COMMON.DERIV'
5894 ! include 'COMMON.VAR'
5895 ! include 'COMMON.CHAIN'
5896 ! include 'COMMON.IOUNITS'
5897 ! include 'COMMON.NAMES'
5898 ! include 'COMMON.FFIELD'
5899 ! include 'COMMON.CONTROL'
5900 !el real(kind=8) :: term1,term2,termm,diffak,ratak,&
5901 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
5902 !el delthe0,sig0inv,sigtc,sigsqtc,delthec
5904 !el common /calcthet/ term1,term2,termm,diffak,ratak,&
5905 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
5906 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,it
5908 integer :: i,k,ichir1,ichir2,itype1,ichir11,ichir12,itype2,&
5910 real(kind=8) :: etheta,delta,ss,ssd,phii,phii1,thet_pred_mean,&
5911 athetk,bthetk,dthett,dthetg1,dthetg2,f0,fprim0,E_tc0,fprim_tc0,&
5912 f1,fprim1,E_tc1,ethetai,E_theta,E_tc
5913 real(kind=8),dimension(2) :: y,z
5916 ! time11=dexp(-2*time)
5919 ! write (*,'(a,i2)') 'EBEND ICG=',icg
5920 do i=ithet_start,ithet_end
5921 if (itype(i-1,1).eq.ntyp1) cycle
5922 ! Zero the energy function and its derivative at 0 or pi.
5923 call splinthet(theta(i),0.5d0*delta,ss,ssd)
5925 ichir1=isign(1,itype(i-2,1))
5926 ichir2=isign(1,itype(i,1))
5927 if (itype(i-2,1).eq.10) ichir1=isign(1,itype(i-1,1))
5928 if (itype(i,1).eq.10) ichir2=isign(1,itype(i-1,1))
5929 if (itype(i-1,1).eq.10) then
5930 itype1=isign(10,itype(i-2,1))
5931 ichir11=isign(1,itype(i-2,1))
5932 ichir12=isign(1,itype(i-2,1))
5933 itype2=isign(10,itype(i,1))
5934 ichir21=isign(1,itype(i,1))
5935 ichir22=isign(1,itype(i,1))
5938 if (i.gt.3 .and. itype(i-2,1).ne.ntyp1) then
5941 if (phii.ne.phii) phii=150.0
5951 if (i.lt.nres .and. itype(i,1).ne.ntyp1) then
5954 if (phii1.ne.phii1) phii1=150.0
5966 ! Calculate the "mean" value of theta from the part of the distribution
5967 ! dependent on the adjacent virtual-bond-valence angles (gamma1 & gamma2).
5968 ! In following comments this theta will be referred to as t_c.
5969 thet_pred_mean=0.0d0
5971 athetk=athet(k,it,ichir1,ichir2)
5972 bthetk=bthet(k,it,ichir1,ichir2)
5974 athetk=athet(k,itype1,ichir11,ichir12)
5975 bthetk=bthet(k,itype2,ichir21,ichir22)
5977 thet_pred_mean=thet_pred_mean+athetk*y(k)+bthetk*z(k)
5979 dthett=thet_pred_mean*ssd
5980 thet_pred_mean=thet_pred_mean*ss+a0thet(it)
5981 ! Derivatives of the "mean" values in gamma1 and gamma2.
5982 dthetg1=(-athet(1,it,ichir1,ichir2)*y(2) &
5983 +athet(2,it,ichir1,ichir2)*y(1))*ss
5984 dthetg2=(-bthet(1,it,ichir1,ichir2)*z(2) &
5985 +bthet(2,it,ichir1,ichir2)*z(1))*ss
5987 dthetg1=(-athet(1,itype1,ichir11,ichir12)*y(2) &
5988 +athet(2,itype1,ichir11,ichir12)*y(1))*ss
5989 dthetg2=(-bthet(1,itype2,ichir21,ichir22)*z(2) &
5990 +bthet(2,itype2,ichir21,ichir22)*z(1))*ss
5992 if (theta(i).gt.pi-delta) then
5993 call theteng(pi-delta,thet_pred_mean,theta0(it),f0,fprim0,&
5995 call mixder(pi-delta,thet_pred_mean,theta0(it),fprim_tc0)
5996 call theteng(pi,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
5997 call spline1(theta(i),pi-delta,delta,f0,f1,fprim0,ethetai,&
5999 call spline2(theta(i),pi-delta,delta,E_tc0,E_tc1,fprim_tc0,&
6001 else if (theta(i).lt.delta) then
6002 call theteng(delta,thet_pred_mean,theta0(it),f0,fprim0,E_tc0)
6003 call theteng(0.0d0,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
6004 call spline1(theta(i),delta,-delta,f0,f1,fprim0,ethetai,&
6006 call mixder(delta,thet_pred_mean,theta0(it),fprim_tc0)
6007 call spline2(theta(i),delta,-delta,E_tc0,E_tc1,fprim_tc0,&
6010 call theteng(theta(i),thet_pred_mean,theta0(it),ethetai,&
6013 etheta=etheta+ethetai
6014 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
6016 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*E_tc*dthetg1
6017 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*E_tc*dthetg2
6018 gloc(nphi+i-2,icg)=wang*(E_theta+E_tc*dthett)
6020 ! print *,ithetaconstr_start,ithetaconstr_end,"TU"
6022 ! Ufff.... We've done all this!!!
6024 end subroutine ebend
6025 !-----------------------------------------------------------------------------
6026 subroutine theteng(thetai,thet_pred_mean,theta0i,ethetai,E_theta,E_tc)
6029 ! implicit real*8 (a-h,o-z)
6030 ! include 'DIMENSIONS'
6031 ! include 'COMMON.LOCAL'
6032 ! include 'COMMON.IOUNITS'
6033 !el real(kind=8) :: term1,term2,termm,diffak,ratak,&
6034 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
6035 !el delthe0,sig0inv,sigtc,sigsqtc,delthec
6037 real(kind=8) :: thetai,thet_pred_mean,theta0i,ethetai,E_theta,E_tc
6039 !el common /calcthet/ term1,term2,termm,diffak,ratak,&
6040 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
6041 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,it
6043 real(kind=8) :: sig,fac,escloci0,escloci1,esclocbi0,dersc12,&
6044 esclocbi1,chuju,esclocbi,dersc02,dersc01,ss,ssd
6046 ! Calculate the contributions to both Gaussian lobes.
6047 ! 6/6/97 - Deform the Gaussians using the factor of 1/(1+time)
6048 ! The "polynomial part" of the "standard deviation" of this part of
6052 sig=sig*thet_pred_mean+polthet(j,it)
6054 ! Derivative of the "interior part" of the "standard deviation of the"
6055 ! gamma-dependent Gaussian lobe in t_c.
6056 sigtc=3*polthet(3,it)
6058 sigtc=sigtc*thet_pred_mean+j*polthet(j,it)
6061 ! Set the parameters of both Gaussian lobes of the distribution.
6062 ! "Standard deviation" of the gamma-dependent Gaussian lobe (sigtc)
6063 fac=sig*sig+sigc0(it)
6066 ! Following variable (sigsqtc) is -(1/2)d[sigma(t_c)**(-2))]/dt_c
6067 sigsqtc=-4.0D0*sigcsq*sigtc
6068 ! print *,i,sig,sigtc,sigsqtc
6069 ! Following variable (sigtc) is d[sigma(t_c)]/dt_c
6070 sigtc=-sigtc/(fac*fac)
6071 ! Following variable is sigma(t_c)**(-2)
6072 sigcsq=sigcsq*sigcsq
6074 sig0inv=1.0D0/sig0i**2
6075 delthec=thetai-thet_pred_mean
6076 delthe0=thetai-theta0i
6077 term1=-0.5D0*sigcsq*delthec*delthec
6078 term2=-0.5D0*sig0inv*delthe0*delthe0
6079 ! Following fuzzy logic is to avoid underflows in dexp and subsequent INFs and
6080 ! NaNs in taking the logarithm. We extract the largest exponent which is added
6081 ! to the energy (this being the log of the distribution) at the end of energy
6082 ! term evaluation for this virtual-bond angle.
6083 if (term1.gt.term2) then
6085 term2=dexp(term2-termm)
6089 term1=dexp(term1-termm)
6092 ! The ratio between the gamma-independent and gamma-dependent lobes of
6093 ! the distribution is a Gaussian function of thet_pred_mean too.
6094 diffak=gthet(2,it)-thet_pred_mean
6095 ratak=diffak/gthet(3,it)**2
6096 ak=dexp(gthet(1,it)-0.5D0*diffak*ratak)
6097 ! Let's differentiate it in thet_pred_mean NOW.
6099 ! Now put together the distribution terms to make complete distribution.
6100 termexp=term1+ak*term2
6101 termpre=sigc+ak*sig0i
6102 ! Contribution of the bending energy from this theta is just the -log of
6103 ! the sum of the contributions from the two lobes and the pre-exponential
6104 ! factor. Simple enough, isn't it?
6105 ethetai=(-dlog(termexp)-termm+dlog(termpre))
6106 ! NOW the derivatives!!!
6107 ! 6/6/97 Take into account the deformation.
6108 E_theta=(delthec*sigcsq*term1 &
6109 +ak*delthe0*sig0inv*term2)/termexp
6110 E_tc=((sigtc+aktc*sig0i)/termpre &
6111 -((delthec*sigcsq+delthec*delthec*sigsqtc)*term1+ &
6112 aktc*term2)/termexp)
6114 end subroutine theteng
6116 !-----------------------------------------------------------------------------
6117 subroutine ebend(etheta)
6119 ! Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
6120 ! angles gamma and its derivatives in consecutive thetas and gammas.
6121 ! ab initio-derived potentials from
6122 ! Kozlowska et al., J. Phys.: Condens. Matter 19 (2007) 285203
6124 ! implicit real*8 (a-h,o-z)
6125 ! include 'DIMENSIONS'
6126 ! include 'COMMON.LOCAL'
6127 ! include 'COMMON.GEO'
6128 ! include 'COMMON.INTERACT'
6129 ! include 'COMMON.DERIV'
6130 ! include 'COMMON.VAR'
6131 ! include 'COMMON.CHAIN'
6132 ! include 'COMMON.IOUNITS'
6133 ! include 'COMMON.NAMES'
6134 ! include 'COMMON.FFIELD'
6135 ! include 'COMMON.CONTROL'
6136 real(kind=8),dimension(nntheterm) :: coskt,sinkt !mmaxtheterm
6137 real(kind=8),dimension(nsingle) :: cosph1,sinph1,cosph2,sinph2 !maxsingle
6138 real(kind=8),dimension(ndouble,ndouble) :: cosph1ph2,sinph1ph2 !maxdouble,maxdouble
6139 logical :: lprn=.false., lprn1=.false.
6141 integer :: i,k,iblock,ityp1,ityp2,ityp3,l,m
6142 real(kind=8) :: dethetai,dephii,dephii1,theti2,phii,phii1,ethetai
6143 real(kind=8) :: aux,etheta,ccl,ssl,scl,csl,ethetacnstr
6144 ! local variables for constrains
6145 real(kind=8) :: difi,thetiii
6147 ! write(iout,*) "in ebend",ithet_start,ithet_end
6150 do i=ithet_start,ithet_end
6151 if (itype(i-1,1).eq.ntyp1) cycle
6152 if (itype(i-2,1).eq.ntyp1.or.itype(i,1).eq.ntyp1) cycle
6153 if (iabs(itype(i+1,1)).eq.20) iblock=2
6154 if (iabs(itype(i+1,1)).ne.20) iblock=1
6158 theti2=0.5d0*theta(i)
6159 ityp2=ithetyp((itype(i-1,1)))
6161 coskt(k)=dcos(k*theti2)
6162 sinkt(k)=dsin(k*theti2)
6164 if (i.gt.3 .and. itype(max0(i-3,1),1).ne.ntyp1) then
6167 if (phii.ne.phii) phii=150.0
6171 ityp1=ithetyp((itype(i-2,1)))
6172 ! propagation of chirality for glycine type
6174 cosph1(k)=dcos(k*phii)
6175 sinph1(k)=dsin(k*phii)
6179 ityp1=ithetyp(itype(i-2,1))
6185 if (i.lt.nres .and. itype(i+1,1).ne.ntyp1) then
6188 if (phii1.ne.phii1) phii1=150.0
6193 ityp3=ithetyp((itype(i,1)))
6195 cosph2(k)=dcos(k*phii1)
6196 sinph2(k)=dsin(k*phii1)
6200 ityp3=ithetyp(itype(i,1))
6206 ethetai=aa0thet(ityp1,ityp2,ityp3,iblock)
6209 ccl=cosph1(l)*cosph2(k-l)
6210 ssl=sinph1(l)*sinph2(k-l)
6211 scl=sinph1(l)*cosph2(k-l)
6212 csl=cosph1(l)*sinph2(k-l)
6213 cosph1ph2(l,k)=ccl-ssl
6214 cosph1ph2(k,l)=ccl+ssl
6215 sinph1ph2(l,k)=scl+csl
6216 sinph1ph2(k,l)=scl-csl
6220 write (iout,*) "i",i," ityp1",ityp1," ityp2",ityp2,&
6221 " ityp3",ityp3," theti2",theti2," phii",phii," phii1",phii1
6222 write (iout,*) "coskt and sinkt"
6224 write (iout,*) k,coskt(k),sinkt(k)
6228 ethetai=ethetai+aathet(k,ityp1,ityp2,ityp3,iblock)*sinkt(k)
6229 dethetai=dethetai+0.5d0*k*aathet(k,ityp1,ityp2,ityp3,iblock) &
6232 write (iout,*) "k",k,&
6233 "aathet",aathet(k,ityp1,ityp2,ityp3,iblock),&
6237 write (iout,*) "cosph and sinph"
6239 write (iout,*) k,cosph1(k),sinph1(k),cosph2(k),sinph2(k)
6241 write (iout,*) "cosph1ph2 and sinph2ph2"
6244 write (iout,*) l,k,cosph1ph2(l,k),cosph1ph2(k,l),&
6245 sinph1ph2(l,k),sinph1ph2(k,l)
6248 write(iout,*) "ethetai",ethetai
6252 aux=bbthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph1(k) &
6253 +ccthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph1(k) &
6254 +ddthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph2(k) &
6255 +eethet(k,m,ityp1,ityp2,ityp3,iblock)*sinph2(k)
6256 ethetai=ethetai+sinkt(m)*aux
6257 dethetai=dethetai+0.5d0*m*aux*coskt(m)
6258 dephii=dephii+k*sinkt(m)* &
6259 (ccthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph1(k)- &
6260 bbthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph1(k))
6261 dephii1=dephii1+k*sinkt(m)* &
6262 (eethet(k,m,ityp1,ityp2,ityp3,iblock)*cosph2(k)- &
6263 ddthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph2(k))
6265 write (iout,*) "m",m," k",k," bbthet", &
6266 bbthet(k,m,ityp1,ityp2,ityp3,iblock)," ccthet", &
6267 ccthet(k,m,ityp1,ityp2,ityp3,iblock)," ddthet", &
6268 ddthet(k,m,ityp1,ityp2,ityp3,iblock)," eethet", &
6269 eethet(k,m,ityp1,ityp2,ityp3,iblock)," ethetai",ethetai
6273 write(iout,*) "ethetai",ethetai
6277 aux=ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)+ &
6278 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l)+ &
6279 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)+ &
6280 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)
6281 ethetai=ethetai+sinkt(m)*aux
6282 dethetai=dethetai+0.5d0*m*coskt(m)*aux
6283 dephii=dephii+l*sinkt(m)* &
6284 (-ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)- &
6285 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)+ &
6286 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)+ &
6287 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l))
6288 dephii1=dephii1+(k-l)*sinkt(m)* &
6289 (-ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)+ &
6290 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)+ &
6291 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)- &
6292 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l))
6294 write (iout,*) "m",m," k",k," l",l," ffthet",&
6295 ffthet(l,k,m,ityp1,ityp2,ityp3,iblock),&
6296 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)," ggthet",&
6297 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock),&
6298 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock),&
6300 write (iout,*) cosph1ph2(l,k)*sinkt(m),&
6301 cosph1ph2(k,l)*sinkt(m),&
6302 sinph1ph2(l,k)*sinkt(m),sinph1ph2(k,l)*sinkt(m)
6310 write (iout,'(i2,3f8.1,9h ethetai ,f10.5)') &
6311 i,theta(i)*rad2deg,phii*rad2deg,&
6312 phii1*rad2deg,ethetai
6314 etheta=etheta+ethetai
6315 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
6317 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*dephii
6318 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*dephii1
6319 gloc(nphi+i-2,icg)=wang*dethetai
6321 !-----------thete constrains
6322 ! if (tor_mode.ne.2) then
6325 end subroutine ebend
6328 !-----------------------------------------------------------------------------
6329 subroutine esc(escloc)
6330 ! Calculate the local energy of a side chain and its derivatives in the
6331 ! corresponding virtual-bond valence angles THETA and the spherical angles
6335 ! implicit real*8 (a-h,o-z)
6336 ! include 'DIMENSIONS'
6337 ! include 'COMMON.GEO'
6338 ! include 'COMMON.LOCAL'
6339 ! include 'COMMON.VAR'
6340 ! include 'COMMON.INTERACT'
6341 ! include 'COMMON.DERIV'
6342 ! include 'COMMON.CHAIN'
6343 ! include 'COMMON.IOUNITS'
6344 ! include 'COMMON.NAMES'
6345 ! include 'COMMON.FFIELD'
6346 ! include 'COMMON.CONTROL'
6347 real(kind=8),dimension(3) :: x,dersc,xemp,dersc0,dersc1,&
6348 ddersc0,ddummy,xtemp,temp
6349 !el real(kind=8) :: time11,time12,time112,theti
6350 real(kind=8) :: escloc,delta
6351 !el integer :: it,nlobit
6352 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
6355 real(kind=8) :: escloci0,escloci1,escloci,esclocbi0,&
6356 dersc12,esclocbi1,chuju,esclocbi,dersc02,dersc01,ss,ssd
6359 ! write (iout,'(a)') 'ESC'
6360 do i=loc_start,loc_end
6362 if (it.eq.ntyp1) cycle
6363 if (it.eq.10) goto 1
6364 nlobit=nlob(iabs(it))
6365 ! print *,'i=',i,' it=',it,' nlobit=',nlobit
6366 ! write (iout,*) 'i=',i,' ssa=',ssa,' ssad=',ssad
6367 theti=theta(i+1)-pipol
6372 if (x(2).gt.pi-delta) then
6376 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
6378 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
6379 call spline1(x(2),pi-delta,delta,escloci0,escloci1,dersc0(2),&
6381 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),&
6382 ddersc0(1),dersc(1))
6383 call spline2(x(2),pi-delta,delta,dersc0(3),dersc1(3),&
6384 ddersc0(3),dersc(3))
6386 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
6388 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
6389 call spline1(x(2),pi-delta,delta,esclocbi0,esclocbi1,&
6390 dersc0(2),esclocbi,dersc02)
6391 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),&
6393 call splinthet(x(2),0.5d0*delta,ss,ssd)
6398 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
6400 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
6401 ! write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
6403 escloci=ss*escloci+(1.0d0-ss)*esclocbi
6405 ! write (iout,*) escloci
6406 else if (x(2).lt.delta) then
6410 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
6412 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
6413 call spline1(x(2),delta,-delta,escloci0,escloci1,dersc0(2),&
6415 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),&
6416 ddersc0(1),dersc(1))
6417 call spline2(x(2),delta,-delta,dersc0(3),dersc1(3),&
6418 ddersc0(3),dersc(3))
6420 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
6422 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
6423 call spline1(x(2),delta,-delta,esclocbi0,esclocbi1,&
6424 dersc0(2),esclocbi,dersc02)
6425 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),&
6430 call splinthet(x(2),0.5d0*delta,ss,ssd)
6432 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
6434 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
6435 ! write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
6437 escloci=ss*escloci+(1.0d0-ss)*esclocbi
6438 ! write (iout,*) escloci
6440 call enesc(x,escloci,dersc,ddummy,.false.)
6443 escloc=escloc+escloci
6444 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
6446 ! write (iout,*) 'i=',i,' escloci=',escloci,' dersc=',dersc
6448 gloc(nphi+i-1,icg)=gloc(nphi+i-1,icg)+ &
6450 gloc(ialph(i,1),icg)=wscloc*dersc(2)
6451 gloc(ialph(i,1)+nside,icg)=wscloc*dersc(3)
6456 !-----------------------------------------------------------------------------
6457 subroutine enesc(x,escloci,dersc,ddersc,mixed)
6460 ! implicit real*8 (a-h,o-z)
6461 ! include 'DIMENSIONS'
6462 ! include 'COMMON.GEO'
6463 ! include 'COMMON.LOCAL'
6464 ! include 'COMMON.IOUNITS'
6465 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
6466 real(kind=8),dimension(3) :: x,z,dersc,ddersc
6467 real(kind=8),dimension(3,nlobit,-1:1) :: Ax !(3,maxlob,-1:1)
6468 real(kind=8),dimension(nlobit,-1:1) :: contr !(maxlob,-1:1)
6469 real(kind=8) :: escloci
6472 integer :: j,iii,l,k !el,it,nlobit
6473 real(kind=8) :: escloc_i,x3,Axk,expfac,emin !el,theti,&
6474 !el time11,time12,time112
6475 ! write (iout,*) 'it=',it,' nlobit=',nlobit
6479 if (mixed) ddersc(j)=0.0d0
6483 ! Because of periodicity of the dependence of the SC energy in omega we have
6484 ! to add up the contributions from x(3)-2*pi, x(3), and x(3+2*pi).
6485 ! To avoid underflows, first compute & store the exponents.
6493 z(k)=x(k)-censc(k,j,it)
6498 Axk=Axk+gaussc(l,k,j,it)*z(l)
6504 expfac=expfac+Ax(k,j,iii)*z(k)
6512 ! As in the case of ebend, we want to avoid underflows in exponentiation and
6513 ! subsequent NaNs and INFs in energy calculation.
6514 ! Find the largest exponent
6518 if (emin.gt.contr(j,iii)) emin=contr(j,iii)
6522 !d print *,'it=',it,' emin=',emin
6524 ! Compute the contribution to SC energy and derivatives
6529 adexp=bsc(j,iabs(it))-0.5D0*contr(j,iii)+emin
6530 if(adexp.ne.adexp) adexp=1.0
6533 expfac=dexp(bsc(j,iabs(it))-0.5D0*contr(j,iii)+emin)
6535 !d print *,'j=',j,' expfac=',expfac
6536 escloc_i=escloc_i+expfac
6538 dersc(k)=dersc(k)+Ax(k,j,iii)*expfac
6542 ddersc(k)=ddersc(k)+(-Ax(2,j,iii)*Ax(k,j,iii) &
6543 +gaussc(k,2,j,it))*expfac
6550 dersc(1)=dersc(1)/cos(theti)**2
6551 ddersc(1)=ddersc(1)/cos(theti)**2
6554 escloci=-(dlog(escloc_i)-emin)
6556 dersc(j)=dersc(j)/escloc_i
6560 ddersc(j)=(ddersc(j)/escloc_i+dersc(2)*dersc(j))
6564 end subroutine enesc
6565 !-----------------------------------------------------------------------------
6566 subroutine enesc_bound(x,escloci,dersc,dersc12,mixed)
6569 ! implicit real*8 (a-h,o-z)
6570 ! include 'DIMENSIONS'
6571 ! include 'COMMON.GEO'
6572 ! include 'COMMON.LOCAL'
6573 ! include 'COMMON.IOUNITS'
6574 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
6575 real(kind=8),dimension(3) :: x,z,dersc
6576 real(kind=8),dimension(3,nlobit) :: Ax !(3,maxlob)
6577 real(kind=8),dimension(nlobit) :: contr !(maxlob)
6578 real(kind=8) :: escloci,dersc12,emin
6581 integer :: j,k,l !el,it,nlobit
6582 real(kind=8) :: escloc_i,Axk,expfac !el,time11,time12,time112,theti
6592 z(k)=x(k)-censc(k,j,it)
6598 Axk=Axk+gaussc(l,k,j,it)*z(l)
6604 expfac=expfac+Ax(k,j)*z(k)
6609 ! As in the case of ebend, we want to avoid underflows in exponentiation and
6610 ! subsequent NaNs and INFs in energy calculation.
6611 ! Find the largest exponent
6614 if (emin.gt.contr(j)) emin=contr(j)
6618 ! Compute the contribution to SC energy and derivatives
6622 expfac=dexp(bsc(j,iabs(it))-0.5D0*contr(j)+emin)
6623 escloc_i=escloc_i+expfac
6625 dersc(k)=dersc(k)+Ax(k,j)*expfac
6627 if (mixed) dersc12=dersc12+(-Ax(2,j)*Ax(1,j) &
6628 +gaussc(1,2,j,it))*expfac
6632 dersc(1)=dersc(1)/cos(theti)**2
6633 dersc12=dersc12/cos(theti)**2
6634 escloci=-(dlog(escloc_i)-emin)
6636 dersc(j)=dersc(j)/escloc_i
6638 if (mixed) dersc12=(dersc12/escloc_i+dersc(2)*dersc(1))
6640 end subroutine enesc_bound
6642 !-----------------------------------------------------------------------------
6643 subroutine esc(escloc)
6644 ! Calculate the local energy of a side chain and its derivatives in the
6645 ! corresponding virtual-bond valence angles THETA and the spherical angles
6646 ! ALPHA and OMEGA derived from AM1 all-atom calculations.
6647 ! added by Urszula Kozlowska. 07/11/2007
6650 ! implicit real*8 (a-h,o-z)
6651 ! include 'DIMENSIONS'
6652 ! include 'COMMON.GEO'
6653 ! include 'COMMON.LOCAL'
6654 ! include 'COMMON.VAR'
6655 ! include 'COMMON.SCROT'
6656 ! include 'COMMON.INTERACT'
6657 ! include 'COMMON.DERIV'
6658 ! include 'COMMON.CHAIN'
6659 ! include 'COMMON.IOUNITS'
6660 ! include 'COMMON.NAMES'
6661 ! include 'COMMON.FFIELD'
6662 ! include 'COMMON.CONTROL'
6663 ! include 'COMMON.VECTORS'
6664 real(kind=8),dimension(3) :: x_prime,y_prime,z_prime
6665 real(kind=8),dimension(65) :: x
6666 real(kind=8) :: sumene,dsc_i,dp2_i,xx,yy,zz,sumene1,sumene2,sumene3,&
6667 sumene4,s1,s1_6,s2,s2_6,de_dxx,de_dyy,de_dzz,de_dt
6668 real(kind=8) :: s1_t,s1_6_t,s2_t,s2_6_t
6669 real(kind=8),dimension(3) :: dXX_Ci1,dYY_Ci1,dZZ_Ci1,dXX_Ci,dYY_Ci,&
6670 dZZ_Ci,dXX_XYZ,dYY_XYZ,dZZ_XYZ,dt_dCi,dt_dCi1
6672 integer :: i,j,k !el,it,nlobit
6673 real(kind=8) :: cosfac2,sinfac2,cosfac,sinfac,escloc,delta
6674 !el real(kind=8) :: time11,time12,time112,theti
6675 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
6676 real(kind=8) :: dscp1,dscp2,pom_s1,pom_s16,pom_s2,pom_s26,&
6677 pom,pom_dx,pom_dy,pom_dt1,pom_dt2,pom1,pom2,&
6678 sumene1x,sumene2x,sumene3x,sumene4x,&
6679 sumene1y,sumene2y,sumene3y,sumene4y,cossc,cossc1,&
6682 real(kind=8) :: aincr,xxsave,sumenep,de_dxx_num,yysave,&
6683 de_dyy_num,zzsave,de_dzz_num,costsave,sintsave,&
6686 ! if (.not.allocated(gsclocx)) allocate(gsclocx(3,nres)) !(3,maxres)
6690 do i=loc_start,loc_end
6691 if (itype(i,1).eq.ntyp1) cycle
6692 costtab(i+1) =dcos(theta(i+1))
6693 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
6694 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
6695 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
6696 cosfac2=0.5d0/(1.0d0+costtab(i+1))
6697 cosfac=dsqrt(cosfac2)
6698 sinfac2=0.5d0/(1.0d0-costtab(i+1))
6699 sinfac=dsqrt(sinfac2)
6701 if (it.eq.10) goto 1
6703 ! Compute the axes of tghe local cartesian coordinates system; store in
6704 ! x_prime, y_prime and z_prime
6711 ! write(2,*) "dc_norm", dc_norm(1,i+nres),dc_norm(2,i+nres),
6712 ! & dc_norm(3,i+nres)
6714 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
6715 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
6718 z_prime(j) = -uz(j,i-1)*dsign(1.0d0,dfloat(itype(i,1)))
6721 ! write (2,*) "x_prime",(x_prime(j),j=1,3)
6722 ! write (2,*) "y_prime",(y_prime(j),j=1,3)
6723 ! write (2,*) "z_prime",(z_prime(j),j=1,3)
6724 ! write (2,*) "xx",scalar(x_prime(1),x_prime(1)),
6725 ! & " xy",scalar(x_prime(1),y_prime(1)),
6726 ! & " xz",scalar(x_prime(1),z_prime(1)),
6727 ! & " yy",scalar(y_prime(1),y_prime(1)),
6728 ! & " yz",scalar(y_prime(1),z_prime(1)),
6729 ! & " zz",scalar(z_prime(1),z_prime(1))
6731 ! Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
6732 ! to local coordinate system. Store in xx, yy, zz.
6738 xx = xx + x_prime(j)*dc_norm(j,i+nres)
6739 yy = yy + y_prime(j)*dc_norm(j,i+nres)
6740 zz = zz + z_prime(j)*dc_norm(j,i+nres)
6747 ! Compute the energy of the ith side cbain
6749 ! write (2,*) "xx",xx," yy",yy," zz",zz
6752 x(j) = sc_parmin(j,it)
6755 !c diagnostics - remove later
6757 yy1 = dsin(alph(2))*dcos(omeg(2))
6758 zz1 = -dsign(1.0,dfloat(itype(i,1)))*dsin(alph(2))*dsin(omeg(2))
6759 write(2,'(3f8.1,3f9.3,1x,3f9.3)') &
6760 alph(2)*rad2deg,omeg(2)*rad2deg,theta(3)*rad2deg,xx,yy,zz,&
6762 !," --- ", xx_w,yy_w,zz_w
6765 sumene1= x(1)+ x(2)*xx+ x(3)*yy+ x(4)*zz+ x(5)*xx**2 &
6766 + x(6)*yy**2+ x(7)*zz**2+ x(8)*xx*zz+ x(9)*xx*yy &
6768 sumene2= x(11) + x(12)*xx + x(13)*yy + x(14)*zz + x(15)*xx**2 &
6769 + x(16)*yy**2 + x(17)*zz**2 + x(18)*xx*zz + x(19)*xx*yy &
6771 sumene3= x(21) +x(22)*xx +x(23)*yy +x(24)*zz +x(25)*xx**2 &
6772 +x(26)*yy**2 +x(27)*zz**2 +x(28)*xx*zz +x(29)*xx*yy &
6773 +x(30)*yy*zz +x(31)*xx**3 +x(32)*yy**3 +x(33)*zz**3 &
6774 +x(34)*(xx**2)*yy +x(35)*(xx**2)*zz +x(36)*(yy**2)*xx &
6775 +x(37)*(yy**2)*zz +x(38)*(zz**2)*xx +x(39)*(zz**2)*yy &
6777 sumene4= x(41) +x(42)*xx +x(43)*yy +x(44)*zz +x(45)*xx**2 &
6778 +x(46)*yy**2 +x(47)*zz**2 +x(48)*xx*zz +x(49)*xx*yy &
6779 +x(50)*yy*zz +x(51)*xx**3 +x(52)*yy**3 +x(53)*zz**3 &
6780 +x(54)*(xx**2)*yy +x(55)*(xx**2)*zz +x(56)*(yy**2)*xx &
6781 +x(57)*(yy**2)*zz +x(58)*(zz**2)*xx +x(59)*(zz**2)*yy &
6783 dsc_i = 0.743d0+x(61)
6785 dscp1=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
6786 *(xx*cost2tab(i+1)+yy*sint2tab(i+1)))
6787 dscp2=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
6788 *(xx*cost2tab(i+1)-yy*sint2tab(i+1)))
6789 s1=(1+x(63))/(0.1d0 + dscp1)
6790 s1_6=(1+x(64))/(0.1d0 + dscp1**6)
6791 s2=(1+x(65))/(0.1d0 + dscp2)
6792 s2_6=(1+x(65))/(0.1d0 + dscp2**6)
6793 sumene = ( sumene3*sint2tab(i+1) + sumene1)*(s1+s1_6) &
6794 + (sumene4*cost2tab(i+1) +sumene2)*(s2+s2_6)
6795 ! write(2,'(i2," sumene",7f9.3)') i,sumene1,sumene2,sumene3,
6797 ! & dscp1,dscp2,sumene
6798 ! sumene = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6799 escloc = escloc + sumene
6800 if (energy_dec) write (2,*) "i",i," itype",itype(i,1)," it",it, &
6801 " escloc",sumene,escloc,it,itype(i,1)
6802 ! write (2,*) "i",i," escloc",sumene,escloc,it,itype(i,1)
6807 ! This section to check the numerical derivatives of the energy of ith side
6808 ! chain in xx, yy, zz, and theta. Use the -DDEBUG compiler option or insert
6809 ! #define DEBUG in the code to turn it on.
6811 write (2,*) "sumene =",sumene
6815 write (2,*) xx,yy,zz
6816 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6817 de_dxx_num=(sumenep-sumene)/aincr
6819 write (2,*) "xx+ sumene from enesc=",sumenep
6822 write (2,*) xx,yy,zz
6823 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6824 de_dyy_num=(sumenep-sumene)/aincr
6826 write (2,*) "yy+ sumene from enesc=",sumenep
6829 write (2,*) xx,yy,zz
6830 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6831 de_dzz_num=(sumenep-sumene)/aincr
6833 write (2,*) "zz+ sumene from enesc=",sumenep
6834 costsave=cost2tab(i+1)
6835 sintsave=sint2tab(i+1)
6836 cost2tab(i+1)=dcos(0.5d0*(theta(i+1)+aincr))
6837 sint2tab(i+1)=dsin(0.5d0*(theta(i+1)+aincr))
6838 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
6839 de_dt_num=(sumenep-sumene)/aincr
6840 write (2,*) " t+ sumene from enesc=",sumenep
6841 cost2tab(i+1)=costsave
6842 sint2tab(i+1)=sintsave
6843 ! End of diagnostics section.
6846 ! Compute the gradient of esc
6848 ! zz=zz*dsign(1.0,dfloat(itype(i,1)))
6849 pom_s1=(1.0d0+x(63))/(0.1d0 + dscp1)**2
6850 pom_s16=6*(1.0d0+x(64))/(0.1d0 + dscp1**6)**2
6851 pom_s2=(1.0d0+x(65))/(0.1d0 + dscp2)**2
6852 pom_s26=6*(1.0d0+x(65))/(0.1d0 + dscp2**6)**2
6853 pom_dx=dsc_i*dp2_i*cost2tab(i+1)
6854 pom_dy=dsc_i*dp2_i*sint2tab(i+1)
6855 pom_dt1=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)-yy*cost2tab(i+1))
6856 pom_dt2=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)+yy*cost2tab(i+1))
6857 pom1=(sumene3*sint2tab(i+1)+sumene1) &
6858 *(pom_s1/dscp1+pom_s16*dscp1**4)
6859 pom2=(sumene4*cost2tab(i+1)+sumene2) &
6860 *(pom_s2/dscp2+pom_s26*dscp2**4)
6861 sumene1x=x(2)+2*x(5)*xx+x(8)*zz+ x(9)*yy
6862 sumene3x=x(22)+2*x(25)*xx+x(28)*zz+x(29)*yy+3*x(31)*xx**2 &
6863 +2*x(34)*xx*yy +2*x(35)*xx*zz +x(36)*(yy**2) +x(38)*(zz**2) &
6865 sumene2x=x(12)+2*x(15)*xx+x(18)*zz+ x(19)*yy
6866 sumene4x=x(42)+2*x(45)*xx +x(48)*zz +x(49)*yy +3*x(51)*xx**2 &
6867 +2*x(54)*xx*yy+2*x(55)*xx*zz+x(56)*(yy**2)+x(58)*(zz**2) &
6869 de_dxx =(sumene1x+sumene3x*sint2tab(i+1))*(s1+s1_6) &
6870 +(sumene2x+sumene4x*cost2tab(i+1))*(s2+s2_6) &
6873 write(2,*), "de_dxx = ", de_dxx,de_dxx_num,itype(i,1)
6876 sumene1y=x(3) + 2*x(6)*yy + x(9)*xx + x(10)*zz
6877 sumene3y=x(23) +2*x(26)*yy +x(29)*xx +x(30)*zz +3*x(32)*yy**2 &
6878 +x(34)*(xx**2) +2*x(36)*yy*xx +2*x(37)*yy*zz +x(39)*(zz**2) &
6880 sumene2y=x(13) + 2*x(16)*yy + x(19)*xx + x(20)*zz
6881 sumene4y=x(43)+2*x(46)*yy+x(49)*xx +x(50)*zz &
6882 +3*x(52)*yy**2+x(54)*xx**2+2*x(56)*yy*xx +2*x(57)*yy*zz &
6883 +x(59)*zz**2 +x(60)*xx*zz
6884 de_dyy =(sumene1y+sumene3y*sint2tab(i+1))*(s1+s1_6) &
6885 +(sumene2y+sumene4y*cost2tab(i+1))*(s2+s2_6) &
6888 write(2,*), "de_dyy = ", de_dyy,de_dyy_num,itype(i,1)
6891 de_dzz =(x(24) +2*x(27)*zz +x(28)*xx +x(30)*yy &
6892 +3*x(33)*zz**2 +x(35)*xx**2 +x(37)*yy**2 +2*x(38)*zz*xx &
6893 +2*x(39)*zz*yy +x(40)*xx*yy)*sint2tab(i+1)*(s1+s1_6) &
6894 +(x(4) + 2*x(7)*zz+ x(8)*xx + x(10)*yy)*(s1+s1_6) &
6895 +(x(44)+2*x(47)*zz +x(48)*xx +x(50)*yy +3*x(53)*zz**2 &
6896 +x(55)*xx**2 +x(57)*(yy**2)+2*x(58)*zz*xx +2*x(59)*zz*yy &
6897 +x(60)*xx*yy)*cost2tab(i+1)*(s2+s2_6) &
6898 + ( x(14) + 2*x(17)*zz+ x(18)*xx + x(20)*yy)*(s2+s2_6)
6900 write(2,*), "de_dzz = ", de_dzz,de_dzz_num,itype(i,1)
6903 de_dt = 0.5d0*sumene3*cost2tab(i+1)*(s1+s1_6) &
6904 -0.5d0*sumene4*sint2tab(i+1)*(s2+s2_6) &
6905 +pom1*pom_dt1+pom2*pom_dt2
6907 write(2,*), "de_dt = ", de_dt,de_dt_num,itype(i,1)
6911 cossc=scalar(dc_norm(1,i),dc_norm(1,i+nres))
6912 cossc1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
6913 cosfac2xx=cosfac2*xx
6914 sinfac2yy=sinfac2*yy
6916 dt_dCi(k) = -(dc_norm(k,i-1)+costtab(i+1)*dc_norm(k,i))* &
6918 dt_dCi1(k)= -(dc_norm(k,i)+costtab(i+1)*dc_norm(k,i-1))* &
6920 pom=(dC_norm(k,i+nres)-cossc*dC_norm(k,i))*vbld_inv(i+1)
6921 pom1=(dC_norm(k,i+nres)-cossc1*dC_norm(k,i-1))*vbld_inv(i)
6922 ! write (iout,*) "i",i," k",k," pom",pom," pom1",pom1,
6923 ! & " dt_dCi",dt_dCi(k)," dt_dCi1",dt_dCi1(k)
6924 ! write (iout,*) "dC_norm",(dC_norm(j,i),j=1,3),
6925 ! & (dC_norm(j,i-1),j=1,3)," vbld_inv",vbld_inv(i+1),vbld_inv(i)
6926 dXX_Ci(k)=pom*cosfac-dt_dCi(k)*cosfac2xx
6927 dXX_Ci1(k)=-pom1*cosfac-dt_dCi1(k)*cosfac2xx
6928 dYY_Ci(k)=pom*sinfac+dt_dCi(k)*sinfac2yy
6929 dYY_Ci1(k)=pom1*sinfac+dt_dCi1(k)*sinfac2yy
6933 dZZ_Ci(k)=dZZ_Ci(k)-uzgrad(j,k,2,i-1) &
6934 *dsign(1.0d0,dfloat(itype(i,1)))*dC_norm(j,i+nres)
6935 dZZ_Ci1(k)=dZZ_Ci1(k)-uzgrad(j,k,1,i-1) &
6936 *dsign(1.0d0,dfloat(itype(i,1)))*dC_norm(j,i+nres)
6939 dXX_XYZ(k)=vbld_inv(i+nres)*(x_prime(k)-xx*dC_norm(k,i+nres))
6940 dYY_XYZ(k)=vbld_inv(i+nres)*(y_prime(k)-yy*dC_norm(k,i+nres))
6941 dZZ_XYZ(k)=vbld_inv(i+nres)* &
6942 (z_prime(k)-zz*dC_norm(k,i+nres))
6944 dt_dCi(k) = -dt_dCi(k)/sinttab(i+1)
6945 dt_dCi1(k)= -dt_dCi1(k)/sinttab(i+1)
6949 dXX_Ctab(k,i)=dXX_Ci(k)
6950 dXX_C1tab(k,i)=dXX_Ci1(k)
6951 dYY_Ctab(k,i)=dYY_Ci(k)
6952 dYY_C1tab(k,i)=dYY_Ci1(k)
6953 dZZ_Ctab(k,i)=dZZ_Ci(k)
6954 dZZ_C1tab(k,i)=dZZ_Ci1(k)
6955 dXX_XYZtab(k,i)=dXX_XYZ(k)
6956 dYY_XYZtab(k,i)=dYY_XYZ(k)
6957 dZZ_XYZtab(k,i)=dZZ_XYZ(k)
6961 ! write (iout,*) "k",k," dxx_ci1",dxx_ci1(k)," dyy_ci1",
6962 ! & dyy_ci1(k)," dzz_ci1",dzz_ci1(k)
6963 ! write (iout,*) "k",k," dxx_ci",dxx_ci(k)," dyy_ci",
6964 ! & dyy_ci(k)," dzz_ci",dzz_ci(k)
6965 ! write (iout,*) "k",k," dt_dci",dt_dci(k)," dt_dci",
6967 ! write (iout,*) "k",k," dxx_XYZ",dxx_XYZ(k)," dyy_XYZ",
6968 ! & dyy_XYZ(k)," dzz_XYZ",dzz_XYZ(k)
6969 gscloc(k,i-1)=gscloc(k,i-1)+de_dxx*dxx_ci1(k) &
6970 +de_dyy*dyy_ci1(k)+de_dzz*dzz_ci1(k)+de_dt*dt_dCi1(k)
6971 gscloc(k,i)=gscloc(k,i)+de_dxx*dxx_Ci(k) &
6972 +de_dyy*dyy_Ci(k)+de_dzz*dzz_Ci(k)+de_dt*dt_dCi(k)
6973 gsclocx(k,i)= de_dxx*dxx_XYZ(k) &
6974 +de_dyy*dyy_XYZ(k)+de_dzz*dzz_XYZ(k)
6976 ! write(iout,*) "ENERGY GRAD = ", (gscloc(k,i-1),k=1,3),
6977 ! & (gscloc(k,i),k=1,3),(gsclocx(k,i),k=1,3)
6979 ! to check gradient call subroutine check_grad
6985 !-----------------------------------------------------------------------------
6986 real(kind=8) function enesc(x,xx,yy,zz,cost2,sint2)
6988 real(kind=8),dimension(65) :: x
6989 real(kind=8) :: xx,yy,zz,cost2,sint2,sumene1,sumene2,sumene3,&
6990 sumene4,sumene,dsc_i,dp2_i,dscp1,dscp2,s1,s1_6,s2,s2_6
6992 sumene1= x(1)+ x(2)*xx+ x(3)*yy+ x(4)*zz+ x(5)*xx**2 &
6993 + x(6)*yy**2+ x(7)*zz**2+ x(8)*xx*zz+ x(9)*xx*yy &
6995 sumene2= x(11) + x(12)*xx + x(13)*yy + x(14)*zz + x(15)*xx**2 &
6996 + x(16)*yy**2 + x(17)*zz**2 + x(18)*xx*zz + x(19)*xx*yy &
6998 sumene3= x(21) +x(22)*xx +x(23)*yy +x(24)*zz +x(25)*xx**2 &
6999 +x(26)*yy**2 +x(27)*zz**2 +x(28)*xx*zz +x(29)*xx*yy &
7000 +x(30)*yy*zz +x(31)*xx**3 +x(32)*yy**3 +x(33)*zz**3 &
7001 +x(34)*(xx**2)*yy +x(35)*(xx**2)*zz +x(36)*(yy**2)*xx &
7002 +x(37)*(yy**2)*zz +x(38)*(zz**2)*xx +x(39)*(zz**2)*yy &
7004 sumene4= x(41) +x(42)*xx +x(43)*yy +x(44)*zz +x(45)*xx**2 &
7005 +x(46)*yy**2 +x(47)*zz**2 +x(48)*xx*zz +x(49)*xx*yy &
7006 +x(50)*yy*zz +x(51)*xx**3 +x(52)*yy**3 +x(53)*zz**3 &
7007 +x(54)*(xx**2)*yy +x(55)*(xx**2)*zz +x(56)*(yy**2)*xx &
7008 +x(57)*(yy**2)*zz +x(58)*(zz**2)*xx +x(59)*(zz**2)*yy &
7010 dsc_i = 0.743d0+x(61)
7012 dscp1=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
7013 *(xx*cost2+yy*sint2))
7014 dscp2=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
7015 *(xx*cost2-yy*sint2))
7016 s1=(1+x(63))/(0.1d0 + dscp1)
7017 s1_6=(1+x(64))/(0.1d0 + dscp1**6)
7018 s2=(1+x(65))/(0.1d0 + dscp2)
7019 s2_6=(1+x(65))/(0.1d0 + dscp2**6)
7020 sumene = ( sumene3*sint2 + sumene1)*(s1+s1_6) &
7021 + (sumene4*cost2 +sumene2)*(s2+s2_6)
7026 !-----------------------------------------------------------------------------
7027 subroutine gcont(rij,r0ij,eps0ij,delta,fcont,fprimcont)
7029 ! This procedure calculates two-body contact function g(rij) and its derivative:
7032 ! g(rij) = esp0ij*(-0.9375*x+0.625*x**3-0.1875*x**5) ! -1 =< x =< 1
7035 ! where x=(rij-r0ij)/delta
7037 ! rij - interbody distance, r0ij - contact distance, eps0ij - contact energy
7040 real(kind=8) :: rij,r0ij,eps0ij,fcont,fprimcont
7041 real(kind=8) :: x,x2,x4,delta
7045 if (x.lt.-1.0D0) then
7048 else if (x.le.1.0D0) then
7051 fcont=eps0ij*(x*(-0.9375D0+0.6250D0*x2-0.1875D0*x4)+0.5D0)
7052 fprimcont=eps0ij * (-0.9375D0+1.8750D0*x2-0.9375D0*x4)/delta
7058 end subroutine gcont
7059 !-----------------------------------------------------------------------------
7060 subroutine splinthet(theti,delta,ss,ssder)
7061 ! implicit real*8 (a-h,o-z)
7062 ! include 'DIMENSIONS'
7063 ! include 'COMMON.VAR'
7064 ! include 'COMMON.GEO'
7065 real(kind=8) :: theti,delta,ss,ssder
7066 real(kind=8) :: thetup,thetlow
7069 if (theti.gt.pipol) then
7070 call gcont(theti,thetup,1.0d0,delta,ss,ssder)
7072 call gcont(-theti,-thetlow,1.0d0,delta,ss,ssder)
7076 end subroutine splinthet
7077 !-----------------------------------------------------------------------------
7078 subroutine spline1(x,x0,delta,f0,f1,fprim0,f,fprim)
7080 real(kind=8) :: x,x0,delta,f0,f1,fprim0,f,fprim
7081 real(kind=8) :: ksi,ksi2,ksi3,a1,a2,a3
7082 a1=fprim0*delta/(f1-f0)
7088 f=f0+(f1-f0)*ksi*(a1+ksi*(a2+a3*ksi))
7089 fprim=(f1-f0)/delta*(a1+ksi*(2*a2+3*ksi*a3))
7091 end subroutine spline1
7092 !-----------------------------------------------------------------------------
7093 subroutine spline2(x,x0,delta,f0x,f1x,fprim0x,fx)
7095 real(kind=8) :: x,x0,delta,f0x,f1x,fprim0x,fx
7096 real(kind=8) :: ksi,ksi2,ksi3,a1,a2,a3
7101 a2=3*(f1x-f0x)-2*fprim0x*delta
7102 a3=fprim0x*delta-2*(f1x-f0x)
7103 fx=f0x+a1*ksi+a2*ksi2+a3*ksi3
7105 end subroutine spline2
7106 !-----------------------------------------------------------------------------
7108 !-----------------------------------------------------------------------------
7109 subroutine etor(etors,edihcnstr)
7110 ! implicit real*8 (a-h,o-z)
7111 ! include 'DIMENSIONS'
7112 ! include 'COMMON.VAR'
7113 ! include 'COMMON.GEO'
7114 ! include 'COMMON.LOCAL'
7115 ! include 'COMMON.TORSION'
7116 ! include 'COMMON.INTERACT'
7117 ! include 'COMMON.DERIV'
7118 ! include 'COMMON.CHAIN'
7119 ! include 'COMMON.NAMES'
7120 ! include 'COMMON.IOUNITS'
7121 ! include 'COMMON.FFIELD'
7122 ! include 'COMMON.TORCNSTR'
7123 ! include 'COMMON.CONTROL'
7124 real(kind=8) :: etors,edihcnstr
7128 real(kind=8) :: phii,fac,etors_ii
7130 ! Set lprn=.true. for debugging
7134 do i=iphi_start,iphi_end
7136 if (itype(i-2,1).eq.ntyp1.or. itype(i-1,1).eq.ntyp1 &
7137 .or. itype(i,1).eq.ntyp1) cycle
7138 itori=itortyp(itype(i-2,1))
7139 itori1=itortyp(itype(i-1,1))
7142 ! Proline-Proline pair is a special case...
7143 if (itori.eq.3 .and. itori1.eq.3) then
7144 if (phii.gt.-dwapi3) then
7146 fac=1.0D0/(1.0D0-cosphi)
7147 etorsi=v1(1,3,3)*fac
7148 etorsi=etorsi+etorsi
7149 etors=etors+etorsi-v1(1,3,3)
7150 if (energy_dec) etors_ii=etors_ii+etorsi-v1(1,3,3)
7151 gloci=gloci-3*fac*etorsi*dsin(3*phii)
7154 v1ij=v1(j+1,itori,itori1)
7155 v2ij=v2(j+1,itori,itori1)
7158 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
7159 if (energy_dec) etors_ii=etors_ii+ &
7160 v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
7161 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
7165 v1ij=v1(j,itori,itori1)
7166 v2ij=v2(j,itori,itori1)
7169 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
7170 if (energy_dec) etors_ii=etors_ii+ &
7171 v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
7172 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
7175 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
7178 write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)') &
7179 restyp(itype(i-2,1),1),i-2,restyp(itype(i-1,1),1),i-1,itori,itori1,&
7180 (v1(j,itori,itori1),j=1,6),(v2(j,itori,itori1),j=1,6)
7181 gloc(i-3,icg)=gloc(i-3,icg)+wtor*gloci
7182 ! write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
7184 ! 6/20/98 - dihedral angle constraints
7187 itori=idih_constr(i)
7190 if (difi.gt.drange(i)) then
7192 edihcnstr=edihcnstr+0.25d0*ftors(i)*difi**4
7193 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors(i)*difi**3
7194 else if (difi.lt.-drange(i)) then
7196 edihcnstr=edihcnstr+0.25d0*ftors(i)*difi**4
7197 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors(i)*difi**3
7199 ! write (iout,'(2i5,2f8.3,2e14.5)') i,itori,rad2deg*phii,
7200 ! & rad2deg*difi,0.25d0*ftors*difi**4,gloc(itori-3,icg)
7202 ! write (iout,*) 'edihcnstr',edihcnstr
7205 !-----------------------------------------------------------------------------
7206 subroutine etor_d(etors_d)
7207 real(kind=8) :: etors_d
7210 end subroutine etor_d
7211 !-----------------------------------------------------------------------------
7212 c LICZENIE WIEZOW Z ROWNANIA ENERGII MODELLERA
7213 subroutine e_modeller(ehomology_constr)
7214 real(kind=8) :: ehomology_constr
7215 ehomology_constr=0.0d0
7216 write (iout,*) "!!!!!UWAGA, JESTEM W DZIWNEJ PETLI, TEST!!!!!"
7218 end subroutine e_modeller
7219 C !!!!!!!! NIE CZYTANE !!!!!!!!!!!
7221 !-----------------------------------------------------------------------------
7222 subroutine etor(etors)
7223 ! implicit real*8 (a-h,o-z)
7224 ! include 'DIMENSIONS'
7225 ! include 'COMMON.VAR'
7226 ! include 'COMMON.GEO'
7227 ! include 'COMMON.LOCAL'
7228 ! include 'COMMON.TORSION'
7229 ! include 'COMMON.INTERACT'
7230 ! include 'COMMON.DERIV'
7231 ! include 'COMMON.CHAIN'
7232 ! include 'COMMON.NAMES'
7233 ! include 'COMMON.IOUNITS'
7234 ! include 'COMMON.FFIELD'
7235 ! include 'COMMON.TORCNSTR'
7236 ! include 'COMMON.CONTROL'
7237 real(kind=8) :: etors,edihcnstr
7240 integer :: i,j,iblock,itori,itori1
7241 real(kind=8) :: phii,gloci,v1ij,v2ij,cosphi,sinphi,&
7242 vl1ij,vl2ij,vl3ij,pom1,difi,etors_ii,pom
7243 ! Set lprn=.true. for debugging
7247 do i=iphi_start,iphi_end
7248 if (itype(i-2,1).eq.ntyp1 .or. itype(i-1,1).eq.ntyp1 &
7249 .or. itype(i-3,1).eq.ntyp1 &
7250 .or. itype(i,1).eq.ntyp1) cycle
7252 if (iabs(itype(i,1)).eq.20) then
7257 itori=itortyp(itype(i-2,1))
7258 itori1=itortyp(itype(i-1,1))
7261 ! Regular cosine and sine terms
7262 do j=1,nterm(itori,itori1,iblock)
7263 v1ij=v1(j,itori,itori1,iblock)
7264 v2ij=v2(j,itori,itori1,iblock)
7267 etors=etors+v1ij*cosphi+v2ij*sinphi
7268 if (energy_dec) etors_ii=etors_ii+ &
7269 v1ij*cosphi+v2ij*sinphi
7270 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
7274 ! E = SUM ----------------------------------- - v1
7275 ! [v2 cos(phi/2)+v3 sin(phi/2)]^2 + 1
7277 cosphi=dcos(0.5d0*phii)
7278 sinphi=dsin(0.5d0*phii)
7279 do j=1,nlor(itori,itori1,iblock)
7280 vl1ij=vlor1(j,itori,itori1)
7281 vl2ij=vlor2(j,itori,itori1)
7282 vl3ij=vlor3(j,itori,itori1)
7283 pom=vl2ij*cosphi+vl3ij*sinphi
7284 pom1=1.0d0/(pom*pom+1.0d0)
7285 etors=etors+vl1ij*pom1
7286 if (energy_dec) etors_ii=etors_ii+ &
7289 gloci=gloci+vl1ij*(vl3ij*cosphi-vl2ij*sinphi)*pom
7291 ! Subtract the constant term
7292 etors=etors-v0(itori,itori1,iblock)
7293 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
7294 'etor',i,etors_ii-v0(itori,itori1,iblock)
7296 write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)') &
7297 restyp(itype(i-2,1),1),i-2,restyp(itype(i-1,1),1),i-1,itori,itori1,&
7298 (v1(j,itori,itori1,iblock),j=1,6),&
7299 (v2(j,itori,itori1,iblock),j=1,6)
7300 gloc(i-3,icg)=gloc(i-3,icg)+wtor*gloci
7301 ! write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
7303 ! 6/20/98 - dihedral angle constraints
7306 !C The rigorous attempt to derive energy function
7307 !-------------------------------------------------------------------------------------------
7308 subroutine etor_kcc(etors)
7309 double precision c1(0:maxval_kcc),c2(0:maxval_kcc)
7310 real(kind=8) :: etors,glocig,glocit1,glocit2,sinthet1,&
7311 sinthet2,costhet1,costhet2,sint1t2,sint1t2n,phii,sinphi,cosphi,&
7312 sint1t2n1,sumvalc,gradvalct1,gradvalct2,sumvals,gradvalst1,&
7315 integer :: i,j,itori,itori1,nval,k,l
7317 if (lprn) write (iout,*) "etor_kcc tor_mode",tor_mode
7319 do i=iphi_start,iphi_end
7320 !C ANY TWO ARE DUMMY ATOMS in row CYCLE
7321 !c if (((itype(i-3).eq.ntyp1).and.(itype(i-2).eq.ntyp1)).or.
7322 !c & ((itype(i-2).eq.ntyp1).and.(itype(i-1).eq.ntyp1)) .or.
7323 !c & ((itype(i-1).eq.ntyp1).and.(itype(i).eq.ntyp1))) cycle
7324 if (itype(i-2,1).eq.ntyp1.or. itype(i-1,1).eq.ntyp1 &
7325 .or. itype(i,1).eq.ntyp1 .or. itype(i-3,1).eq.ntyp1) cycle
7326 itori=itortyp(itype(i-2,1))
7327 itori1=itortyp(itype(i-1,1))
7332 !C to avoid multiple devision by 2
7333 !c theti22=0.5d0*theta(i)
7334 !C theta 12 is the theta_1 /2
7335 !C theta 22 is theta_2 /2
7336 !c theti12=0.5d0*theta(i-1)
7337 !C and appropriate sinus function
7338 sinthet1=dsin(theta(i-1))
7339 sinthet2=dsin(theta(i))
7340 costhet1=dcos(theta(i-1))
7341 costhet2=dcos(theta(i))
7342 !C to speed up lets store its mutliplication
7343 sint1t2=sinthet2*sinthet1
7345 !C \sum_{i=1}^n (sin(theta_1) * sin(theta_2))^n * (c_n* cos(n*gamma)
7346 !C +d_n*sin(n*gamma)) *
7347 !C \sum_{i=1}^m (1+a_m*Tb_m(cos(theta_1 /2))+b_m*Tb_m(cos(theta_2 /2)))
7348 !C we have two sum 1) Non-Chebyshev which is with n and gamma
7349 nval=nterm_kcc_Tb(itori,itori1)
7355 c1(j)=c1(j-1)*costhet1
7356 c2(j)=c2(j-1)*costhet2
7360 do j=1,nterm_kcc(itori,itori1)
7364 sint1t2n=sint1t2n*sint1t2
7370 sumvalc=sumvalc+v1_kcc(l,k,j,itori1,itori)*c1(k)*c2(l)
7371 gradvalct1=gradvalct1+ &
7372 (k-1)*v1_kcc(l,k,j,itori1,itori)*c1(k-1)*c2(l)
7373 gradvalct2=gradvalct2+ &
7374 (l-1)*v1_kcc(l,k,j,itori1,itori)*c1(k)*c2(l-1)
7377 gradvalct1=-gradvalct1*sinthet1
7378 gradvalct2=-gradvalct2*sinthet2
7384 sumvals=sumvals+v2_kcc(l,k,j,itori1,itori)*c1(k)*c2(l)
7385 gradvalst1=gradvalst1+ &
7386 (k-1)*v2_kcc(l,k,j,itori1,itori)*c1(k-1)*c2(l)
7387 gradvalst2=gradvalst2+ &
7388 (l-1)*v2_kcc(l,k,j,itori1,itori)*c1(k)*c2(l-1)
7391 gradvalst1=-gradvalst1*sinthet1
7392 gradvalst2=-gradvalst2*sinthet2
7393 if (lprn) write (iout,*)j,"sumvalc",sumvalc," sumvals",sumvals
7394 etori=etori+sint1t2n*(sumvalc*cosphi+sumvals*sinphi)
7395 !C glocig is the gradient local i site in gamma
7396 glocig=glocig+j*sint1t2n*(sumvals*cosphi-sumvalc*sinphi)
7397 !C now gradient over theta_1
7398 glocit1=glocit1+sint1t2n*(gradvalct1*cosphi+gradvalst1*sinphi)&
7399 +j*sint1t2n1*costhet1*sinthet2*(sumvalc*cosphi+sumvals*sinphi)
7400 glocit2=glocit2+sint1t2n*(gradvalct2*cosphi+gradvalst2*sinphi)&
7401 +j*sint1t2n1*sinthet1*costhet2*(sumvalc*cosphi+sumvals*sinphi)
7404 gloc(i-3,icg)=gloc(i-3,icg)+wtor*glocig
7405 !C derivative over theta1
7406 gloc(nphi+i-3,icg)=gloc(nphi+i-3,icg)+wtor*glocit1
7407 !C now derivative over theta2
7408 gloc(nphi+i-2,icg)=gloc(nphi+i-2,icg)+wtor*glocit2
7410 write (iout,*) i-2,i-1,itype(i-2,1),itype(i-1,1),itori,itori1,&
7411 theta(i-1)*rad2deg,theta(i)*rad2deg,phii*rad2deg,etori
7412 write (iout,*) "c1",(c1(k),k=0,nval), &
7413 " c2",(c2(k),k=0,nval)
7417 end subroutine etor_kcc
7418 !------------------------------------------------------------------------------
7420 subroutine etor_constr(edihcnstr)
7421 real(kind=8) :: etors,edihcnstr
7424 integer :: i,j,iblock,itori,itori1
7425 real(kind=8) :: phii,gloci,v1ij,v2ij,cosphi,sinphi,&
7426 vl1ij,vl2ij,vl3ij,pom1,difi,etors_ii,pom,&
7427 gaudih_i,gauder_i,s,cos_i,dexpcos_i
7429 if (raw_psipred) then
7430 do i=idihconstr_start,idihconstr_end
7431 itori=idih_constr(i)
7433 gaudih_i=vpsipred(1,i)
7437 cos_i=(1.0d0-dcos(phii-phibound(j,i)))/s**2
7438 dexpcos_i=dexp(-cos_i*cos_i)
7439 gaudih_i=gaudih_i+vpsipred(j+1,i)*dexpcos_i
7440 gauder_i=gauder_i-2*vpsipred(j+1,i)*dsin(phii-phibound(j,i)) &
7441 *cos_i*dexpcos_i/s**2
7443 edihcnstr=edihcnstr-wdihc*dlog(gaudih_i)
7444 gloc(itori-3,icg)=gloc(itori-3,icg)-wdihc*gauder_i/gaudih_i
7446 write (iout,'(2i5,f8.3,f8.5,2(f8.5,2f8.3),f10.5)') &
7447 i,itori,phii*rad2deg,vpsipred(1,i),vpsipred(2,i),&
7448 phibound(1,i)*rad2deg,sdihed(1,i)*rad2deg,vpsipred(3,i),&
7449 phibound(2,i)*rad2deg,sdihed(2,i)*rad2deg,&
7450 -wdihc*dlog(gaudih_i)
7454 do i=idihconstr_start,idihconstr_end
7455 itori=idih_constr(i)
7457 difi=pinorm(phii-phi0(i))
7458 if (difi.gt.drange(i)) then
7460 edihcnstr=edihcnstr+0.25d0*ftors(i)*difi**4
7461 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors(i)*difi**3
7462 else if (difi.lt.-drange(i)) then
7464 edihcnstr=edihcnstr+0.25d0*ftors(i)*difi**4
7465 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors(i)*difi**3
7475 end subroutine etor_constr
7476 !-----------------------------------------------------------------------------
7477 subroutine etor_d(etors_d)
7478 ! 6/23/01 Compute double torsional energy
7479 ! implicit real*8 (a-h,o-z)
7480 ! include 'DIMENSIONS'
7481 ! include 'COMMON.VAR'
7482 ! include 'COMMON.GEO'
7483 ! include 'COMMON.LOCAL'
7484 ! include 'COMMON.TORSION'
7485 ! include 'COMMON.INTERACT'
7486 ! include 'COMMON.DERIV'
7487 ! include 'COMMON.CHAIN'
7488 ! include 'COMMON.NAMES'
7489 ! include 'COMMON.IOUNITS'
7490 ! include 'COMMON.FFIELD'
7491 ! include 'COMMON.TORCNSTR'
7492 real(kind=8) :: etors_d,etors_d_ii
7495 integer :: i,j,k,l,itori,itori1,itori2,iblock
7496 real(kind=8) :: phii,phii1,gloci1,gloci2,&
7497 v1cij,v1sij,v2cij,v2sij,cosphi1,sinphi1,&
7498 sinphi2,cosphi2,v1cdij,v2cdij,v1sdij,v2sdij,&
7499 cosphi1p2,cosphi1m2,sinphi1p2,sinphi1m2
7500 ! Set lprn=.true. for debugging
7504 ! write(iout,*) "a tu??"
7505 do i=iphid_start,iphid_end
7507 if (itype(i-2,1).eq.ntyp1 .or. itype(i-1,1).eq.ntyp1 &
7508 .or. itype(i-3,1).eq.ntyp1 &
7509 .or. itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
7510 itori=itortyp(itype(i-2,1))
7511 itori1=itortyp(itype(i-1,1))
7512 itori2=itortyp(itype(i,1))
7518 if (iabs(itype(i+1,1)).eq.20) iblock=2
7520 ! Regular cosine and sine terms
7521 do j=1,ntermd_1(itori,itori1,itori2,iblock)
7522 v1cij=v1c(1,j,itori,itori1,itori2,iblock)
7523 v1sij=v1s(1,j,itori,itori1,itori2,iblock)
7524 v2cij=v1c(2,j,itori,itori1,itori2,iblock)
7525 v2sij=v1s(2,j,itori,itori1,itori2,iblock)
7526 cosphi1=dcos(j*phii)
7527 sinphi1=dsin(j*phii)
7528 cosphi2=dcos(j*phii1)
7529 sinphi2=dsin(j*phii1)
7530 etors_d=etors_d+v1cij*cosphi1+v1sij*sinphi1+ &
7531 v2cij*cosphi2+v2sij*sinphi2
7532 if (energy_dec) etors_d_ii=etors_d_ii+ &
7533 v1cij*cosphi1+v1sij*sinphi1+v2cij*cosphi2+v2sij*sinphi2
7534 gloci1=gloci1+j*(v1sij*cosphi1-v1cij*sinphi1)
7535 gloci2=gloci2+j*(v2sij*cosphi2-v2cij*sinphi2)
7537 do k=2,ntermd_2(itori,itori1,itori2,iblock)
7539 v1cdij = v2c(k,l,itori,itori1,itori2,iblock)
7540 v2cdij = v2c(l,k,itori,itori1,itori2,iblock)
7541 v1sdij = v2s(k,l,itori,itori1,itori2,iblock)
7542 v2sdij = v2s(l,k,itori,itori1,itori2,iblock)
7543 cosphi1p2=dcos(l*phii+(k-l)*phii1)
7544 cosphi1m2=dcos(l*phii-(k-l)*phii1)
7545 sinphi1p2=dsin(l*phii+(k-l)*phii1)
7546 sinphi1m2=dsin(l*phii-(k-l)*phii1)
7547 etors_d=etors_d+v1cdij*cosphi1p2+v2cdij*cosphi1m2+ &
7548 v1sdij*sinphi1p2+v2sdij*sinphi1m2
7549 if (energy_dec) etors_d_ii=etors_d_ii+ &
7550 v1cdij*cosphi1p2+v2cdij*cosphi1m2+ &
7551 v1sdij*sinphi1p2+v2sdij*sinphi1m2
7552 gloci1=gloci1+l*(v1sdij*cosphi1p2+v2sdij*cosphi1m2 &
7553 -v1cdij*sinphi1p2-v2cdij*sinphi1m2)
7554 gloci2=gloci2+(k-l)*(v1sdij*cosphi1p2-v2sdij*cosphi1m2 &
7555 -v1cdij*sinphi1p2+v2cdij*sinphi1m2)
7558 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
7559 'etor_d',i,etors_d_ii
7560 gloc(i-3,icg)=gloc(i-3,icg)+wtor_d*gloci1
7561 gloc(i-2,icg)=gloc(i-2,icg)+wtor_d*gloci2
7564 end subroutine etor_d
7566 !----------------------------------------------------------------------------
7567 !----------------------------------------------------------------------------
7568 subroutine e_modeller(ehomology_constr)
7570 ! include 'DIMENSIONS'
7571 use MD_data, only: iset
7572 real(kind=8) :: ehomology_constr
7573 integer nnn,i,ii,j,k,ijk,jik,ki,kk,nexl,irec,l
7574 integer katy, odleglosci, test7
7575 real(kind=8) :: odleg, odleg2, odleg3, kat, kat2, kat3
7576 real(kind=8) :: Eval,Erot,min_odl
7577 real(kind=8),dimension(constr_homology) :: distance,distancek,godl,dih_diff,gdih, &
7579 uscdiffk,guscdiff2,guscdiff3,&
7584 ! FP - 30/10/2014 Temporary specifications for homology restraints
7586 real(kind=8) :: utheta_i,gutheta_i,sum_gtheta,sum_sgtheta,&
7588 real(kind=8), dimension (nres) :: guscdiff,usc_diff
7589 real(kind=8) :: sum_godl,sgodl,grad_odl3,ggodl,sum_gdih,&
7590 sum_guscdiff,sum_sgdih,sgdih,grad_dih3,usc_diff_i,dxx,dyy,dzz,&
7591 betai,sum_sgodl,dij,max_template
7592 ! real(kind=8) :: dist,pinorm
7594 ! include 'COMMON.SBRIDGE'
7595 ! include 'COMMON.CHAIN'
7596 ! include 'COMMON.GEO'
7597 ! include 'COMMON.DERIV'
7598 ! include 'COMMON.LOCAL'
7599 ! include 'COMMON.INTERACT'
7600 ! include 'COMMON.VAR'
7601 ! include 'COMMON.IOUNITS'
7602 ! include 'COMMON.MD'
7603 ! include 'COMMON.CONTROL'
7604 ! include 'COMMON.HOMOLOGY'
7605 ! include 'COMMON.QRESTR'
7607 ! From subroutine Econstr_back
7609 ! include 'COMMON.NAMES'
7610 ! include 'COMMON.TIME1'
7615 distancek(i)=9999999.9
7621 ! Pseudo-energy and gradient from homology restraints (MODELLER-like
7623 ! AL 5/2/14 - Introduce list of restraints
7624 ! write(iout,*) "waga_theta",waga_theta,"waga_d",waga_d
7626 write(iout,*) "------- dist restrs start -------"
7628 do ii = link_start_homo,link_end_homo
7632 ! write (iout,*) "dij(",i,j,") =",dij
7634 do k=1,constr_homology
7635 ! write(iout,*) ii,k,i,j,l_homo(k,ii),dij,odl(k,ii)
7636 if(.not.l_homo(k,ii)) then
7640 distance(k)=odl(k,ii)-dij
7641 ! write (iout,*) "distance(",k,") =",distance(k)
7643 ! For Gaussian-type Urestr
7645 distancek(k)=0.5d0*distance(k)**2*sigma_odl(k,ii) ! waga_dist rmvd from Gaussian argument
7646 ! write (iout,*) "sigma_odl(",k,ii,") =",sigma_odl(k,ii)
7647 ! write (iout,*) "distancek(",k,") =",distancek(k)
7648 ! distancek(k)=0.5d0*waga_dist*distance(k)**2*sigma_odl(k,ii)
7650 ! For Lorentzian-type Urestr
7652 if (waga_dist.lt.0.0d0) then
7653 sigma_odlir(k,ii)=dsqrt(1/sigma_odl(k,ii))
7654 distancek(k)=distance(k)**2/(sigma_odlir(k,ii)* &
7655 (distance(k)**2+sigma_odlir(k,ii)**2))
7659 ! min_odl=minval(distancek)
7663 do kk=1,constr_homology
7664 if(l_homo(kk,ii)) then
7665 min_odl=distancek(kk)
7669 do kk=1,constr_homology
7670 if (l_homo(kk,ii) .and. distancek(kk).lt.min_odl) &
7671 min_odl=distancek(kk)
7675 ! write (iout,* )"min_odl",min_odl
7677 write (iout,*) "ij dij",i,j,dij
7678 write (iout,*) "distance",(distance(k),k=1,constr_homology)
7679 write (iout,*) "distancek",(distancek(k),k=1,constr_homology)
7680 write (iout,* )"min_odl",min_odl
7685 if (waga_dist.ge.0.0d0) then
7691 do k=1,constr_homology
7692 ! Nie wiem po co to liczycie jeszcze raz!
7693 ! odleg3=-waga_dist(iset)*((distance(i,j,k)**2)/
7694 ! & (2*(sigma_odl(i,j,k))**2))
7695 if(.not.l_homo(k,ii)) cycle
7696 if (waga_dist.ge.0.0d0) then
7698 ! For Gaussian-type Urestr
7700 godl(k)=dexp(-distancek(k)+min_odl)
7701 odleg2=odleg2+godl(k)
7703 ! For Lorentzian-type Urestr
7706 odleg2=odleg2+distancek(k)
7709 !cc write(iout,779) i,j,k, "odleg2=",odleg2, "odleg3=", odleg3,
7710 !cc & "dEXP(odleg3)=", dEXP(odleg3),"distance(i,j,k)^2=",
7711 !cc & distance(i,j,k)**2, "dist(i+1,j+1)=", dist(i+1,j+1),
7712 !cc & "sigma_odl(i,j,k)=", sigma_odl(i,j,k)
7715 ! write (iout,*) "godl",(godl(k),k=1,constr_homology) ! exponents
7716 ! write (iout,*) "ii i j",ii,i,j," odleg2",odleg2 ! sum of exps
7718 write (iout,*) "godl",(godl(k),k=1,constr_homology) ! exponents
7719 write (iout,*) "ii i j",ii,i,j," odleg2",odleg2 ! sum of exps
7721 if (waga_dist.ge.0.0d0) then
7723 ! For Gaussian-type Urestr
7725 odleg=odleg-dLOG(odleg2/constr_homology)+min_odl
7727 ! For Lorentzian-type Urestr
7730 odleg=odleg+odleg2/constr_homology
7733 ! write (iout,*) "odleg",odleg ! sum of -ln-s
7736 ! For Gaussian-type Urestr
7738 if (waga_dist.ge.0.0d0) sum_godl=odleg2
7740 do k=1,constr_homology
7741 ! godl=dexp(((-(distance(i,j,k)**2)/(2*(sigma_odl(i,j,k))**2))
7742 ! & *waga_dist)+min_odl
7743 ! sgodl=-godl(k)*distance(k)*sigma_odl(k,ii)*waga_dist
7745 if(.not.l_homo(k,ii)) cycle
7746 if (waga_dist.ge.0.0d0) then
7747 ! For Gaussian-type Urestr
7749 sgodl=-godl(k)*distance(k)*sigma_odl(k,ii) ! waga_dist rmvd
7751 ! For Lorentzian-type Urestr
7754 sgodl=-2*sigma_odlir(k,ii)*(distance(k)/(distance(k)**2+ &
7755 sigma_odlir(k,ii)**2)**2)
7757 sum_sgodl=sum_sgodl+sgodl
7759 ! sgodl2=sgodl2+sgodl
7760 ! write(iout,*) i, j, k, distance(i,j,k), "W GRADIENCIE1"
7761 ! write(iout,*) "constr_homology=",constr_homology
7762 ! write(iout,*) i, j, k, "TEST K"
7764 ! print *, "ok",iset
7765 if (waga_dist.ge.0.0d0) then
7767 ! For Gaussian-type Urestr
7769 grad_odl3=waga_homology(iset)*waga_dist &
7770 *sum_sgodl/(sum_godl*dij)
7773 ! For Lorentzian-type Urestr
7776 ! Original grad expr modified by analogy w Gaussian-type Urestr grad
7777 ! grad_odl3=-waga_homology(iset)*waga_dist*sum_sgodl
7778 grad_odl3=-waga_homology(iset)*waga_dist* &
7779 sum_sgodl/(constr_homology*dij)
7783 ! grad_odl3=sum_sgodl/(sum_godl*dij)
7786 ! write(iout,*) i, j, k, distance(i,j,k), "W GRADIENCIE2"
7787 ! write(iout,*) (distance(i,j,k)**2), (2*(sigma_odl(i,j,k))**2),
7788 ! & (-(distance(i,j,k)**2)/(2*(sigma_odl(i,j,k))**2))
7790 !cc write(iout,*) godl, sgodl, grad_odl3
7792 ! grad_odl=grad_odl+grad_odl3
7795 ggodl=grad_odl3*(c(jik,i)-c(jik,j))
7796 !cc write(iout,*) c(jik,i+1), c(jik,j+1), (c(jik,i+1)-c(jik,j+1))
7797 !cc write(iout,746) "GRAD_ODL_1", i, j, jik, ggodl,
7798 !cc & ghpbc(jik,i+1), ghpbc(jik,j+1)
7799 ghpbc(jik,i)=ghpbc(jik,i)+ggodl
7800 ghpbc(jik,j)=ghpbc(jik,j)-ggodl
7801 !cc write(iout,746) "GRAD_ODL_2", i, j, jik, ggodl,
7802 !cc & ghpbc(jik,i+1), ghpbc(jik,j+1)
7803 ! if (i.eq.25.and.j.eq.27) then
7804 ! write(iout,*) "jik",jik,"i",i,"j",j
7805 ! write(iout,*) "sum_sgodl",sum_sgodl,"sgodl",sgodl
7806 ! write(iout,*) "grad_odl3",grad_odl3
7807 ! write(iout,*) "c(",jik,i,")",c(jik,i),"c(",jik,j,")",c(jik,j)
7808 ! write(iout,*) "ggodl",ggodl
7809 ! write(iout,*) "ghpbc(",jik,i,")",
7810 ! & ghpbc(jik,i),"ghpbc(",jik,j,")",
7814 !cc write(iout,778)"TEST: odleg2=", odleg2, "DLOG(odleg2)=",
7815 !cc & dLOG(odleg2),"-odleg=", -odleg
7817 enddo ! ii-loop for dist
7819 write(iout,*) "------- dist restrs end -------"
7820 ! if (waga_angle.eq.1.0d0 .or. waga_theta.eq.1.0d0 .or.
7821 ! & waga_d.eq.1.0d0) call sum_gradient
7823 ! Pseudo-energy and gradient from dihedral-angle restraints from
7824 ! homology templates
7825 ! write (iout,*) "End of distance loop"
7828 ! write (iout,*) idihconstr_start_homo,idihconstr_end_homo
7830 write(iout,*) "------- dih restrs start -------"
7831 do i=idihconstr_start_homo,idihconstr_end_homo
7832 write (iout,*) "gloc_init(",i,icg,")",gloc(i,icg)
7835 do i=idihconstr_start_homo,idihconstr_end_homo
7837 ! betai=beta(i,i+1,i+2,i+3)
7839 ! write (iout,*) "betai =",betai
7840 do k=1,constr_homology
7841 dih_diff(k)=pinorm(dih(k,i)-betai)
7842 !d write (iout,'(a8,2i4,2f15.8)') "dih_diff",i,k,dih_diff(k)
7843 !d & ,sigma_dih(k,i)
7844 ! if (dih_diff(i,k).gt.3.14159) dih_diff(i,k)=
7845 ! & -(6.28318-dih_diff(i,k))
7846 ! if (dih_diff(i,k).lt.-3.14159) dih_diff(i,k)=
7847 ! & 6.28318+dih_diff(i,k)
7849 kat3=-0.5d0*dih_diff(k)**2*sigma_dih(k,i) ! waga_angle rmvd from Gaussian argument
7851 kat3=(dcos(dih_diff(k))-1)*sigma_dih(k,i) ! waga_angle rmvd from Gaussian argument
7853 ! kat3=-0.5d0*waga_angle*dih_diff(k)**2*sigma_dih(k,i)
7856 ! write(iout,*) "kat2=", kat2, "exp(kat3)=", exp(kat3)
7859 ! write (iout,*) "gdih",(gdih(k),k=1,constr_homology) ! exps
7860 ! write (iout,*) "i",i," betai",betai," kat2",kat2 ! sum of exps
7862 write (iout,*) "i",i," betai",betai," kat2",kat2
7863 write (iout,*) "gdih",(gdih(k),k=1,constr_homology)
7865 if (kat2.le.1.0d-14) cycle
7866 kat=kat-dLOG(kat2/constr_homology)
7867 ! write (iout,*) "kat",kat ! sum of -ln-s
7869 !cc write(iout,778)"TEST: kat2=", kat2, "DLOG(kat2)=",
7870 !cc & dLOG(kat2), "-kat=", -kat
7872 ! ----------------------------------------------------------------------
7874 ! ----------------------------------------------------------------------
7878 do k=1,constr_homology
7880 sgdih=-gdih(k)*dih_diff(k)*sigma_dih(k,i) ! waga_angle rmvd
7882 sgdih=-gdih(k)*dsin(dih_diff(k))*sigma_dih(k,i) ! waga_angle rmvd
7884 ! sgdih=-gdih(k)*dih_diff(k)*sigma_dih(k,i)*waga_angle
7885 sum_sgdih=sum_sgdih+sgdih
7887 ! grad_dih3=sum_sgdih/sum_gdih
7888 grad_dih3=waga_homology(iset)*waga_angle*sum_sgdih/sum_gdih
7891 ! write(iout,*)i,k,gdih,sgdih,beta(i+1,i+2,i+3,i+4),grad_dih3
7892 !cc write(iout,747) "GRAD_KAT_1", i, nphi, icg, grad_dih3,
7893 !cc & gloc(nphi+i-3,icg)
7894 gloc(i-3,icg)=gloc(i-3,icg)+grad_dih3
7896 ! write(iout,*) "i",i,"icg",icg,"gloc(",i,icg,")",gloc(i,icg)
7898 !cc write(iout,747) "GRAD_KAT_2", i, nphi, icg, grad_dih3,
7899 !cc & gloc(nphi+i-3,icg)
7901 enddo ! i-loop for dih
7903 write(iout,*) "------- dih restrs end -------"
7906 ! Pseudo-energy and gradient for theta angle restraints from
7907 ! homology templates
7908 ! FP 01/15 - inserted from econstr_local_test.F, loop structure
7912 ! For constr_homology reference structures (FP)
7914 ! Uconst_back_tot=0.0d0
7917 ! Econstr_back legacy
7919 ! do i=ithet_start,ithet_end
7922 ! do i=loc_start,loc_end
7926 duscdiffx(j,i)=0.0d0
7931 ! write (iout,*) "ithet_start =",ithet_start,"ithet_end =",ithet_end
7932 ! write (iout,*) "waga_theta",waga_theta
7933 if (waga_theta.gt.0.0d0) then
7935 write (iout,*) "usampl",usampl
7936 write(iout,*) "------- theta restrs start -------"
7937 ! do i=ithet_start,ithet_end
7938 ! write (iout,*) "gloc_init(",nphi+i,icg,")",gloc(nphi+i,icg)
7941 ! write (iout,*) "maxres",maxres,"nres",nres
7943 do i=ithet_start,ithet_end
7946 ! ii = ifrag_back(2,i,iset)-ifrag_back(1,i,iset)
7948 ! Deviation of theta angles wrt constr_homology ref structures
7950 utheta_i=0.0d0 ! argument of Gaussian for single k
7951 gutheta_i=0.0d0 ! Sum of Gaussians over constr_homology ref structures
7952 ! do j=ifrag_back(1,i,iset)+2,ifrag_back(2,i,iset) ! original loop
7953 ! over residues in a fragment
7954 ! write (iout,*) "theta(",i,")=",theta(i)
7955 do k=1,constr_homology
7957 ! dtheta_i=theta(j)-thetaref(j,iref)
7958 ! dtheta_i=thetaref(k,i)-theta(i) ! original form without indexing
7959 theta_diff(k)=thetatpl(k,i)-theta(i)
7960 !d write (iout,'(a8,2i4,2f15.8)') "theta_diff",i,k,theta_diff(k)
7961 !d & ,sigma_theta(k,i)
7964 utheta_i=-0.5d0*theta_diff(k)**2*sigma_theta(k,i) ! waga_theta rmvd from Gaussian argument
7965 ! utheta_i=-0.5d0*waga_theta*theta_diff(k)**2*sigma_theta(k,i) ! waga_theta?
7966 gtheta(k)=dexp(utheta_i) ! + min_utheta_i?
7967 gutheta_i=gutheta_i+gtheta(k) ! Sum of Gaussians (pk)
7968 ! Gradient for single Gaussian restraint in subr Econstr_back
7969 ! dutheta(j-2)=dutheta(j-2)+wfrag_back(1,i,iset)*dtheta_i/(ii-1)
7972 ! write (iout,*) "gtheta",(gtheta(k),k=1,constr_homology) ! exps
7973 ! write (iout,*) "i",i," gutheta_i",gutheta_i ! sum of exps
7976 ! Gradient for multiple Gaussian restraint
7977 sum_gtheta=gutheta_i
7979 do k=1,constr_homology
7980 ! New generalized expr for multiple Gaussian from Econstr_back
7981 sgtheta=-gtheta(k)*theta_diff(k)*sigma_theta(k,i) ! waga_theta rmvd
7983 ! sgtheta=-gtheta(k)*theta_diff(k)*sigma_theta(k,i)*waga_theta ! right functional form?
7984 sum_sgtheta=sum_sgtheta+sgtheta ! cum variable
7986 ! Final value of gradient using same var as in Econstr_back
7987 gloc(nphi+i-2,icg)=gloc(nphi+i-2,icg) &
7988 +sum_sgtheta/sum_gtheta*waga_theta &
7989 *waga_homology(iset)
7992 ! dutheta(i-2)=sum_sgtheta/sum_gtheta*waga_theta
7993 ! & *waga_homology(iset)
7994 ! dutheta(i)=sum_sgtheta/sum_gtheta
7996 ! Uconst_back=Uconst_back+waga_theta*utheta(i) ! waga_theta added as weight
7997 Eval=Eval-dLOG(gutheta_i/constr_homology)
7998 ! write (iout,*) "utheta(",i,")=",utheta(i) ! -ln of sum of exps
7999 ! write (iout,*) "Uconst_back",Uconst_back ! sum of -ln-s
8000 ! Uconst_back=Uconst_back+utheta(i)
8001 enddo ! (i-loop for theta)
8003 write(iout,*) "------- theta restrs end -------"
8007 ! Deviation of local SC geometry
8009 ! Separation of two i-loops (instructed by AL - 11/3/2014)
8011 ! write (iout,*) "loc_start =",loc_start,"loc_end =",loc_end
8012 ! write (iout,*) "waga_d",waga_d
8015 write(iout,*) "------- SC restrs start -------"
8016 write (iout,*) "Initial duscdiff,duscdiffx"
8017 do i=loc_start,loc_end
8018 write (iout,*) i,(duscdiff(jik,i),jik=1,3), &
8019 (duscdiffx(jik,i),jik=1,3)
8022 do i=loc_start,loc_end
8023 usc_diff_i=0.0d0 ! argument of Gaussian for single k
8024 guscdiff(i)=0.0d0 ! Sum of Gaussians over constr_homology ref structures
8025 ! do j=ifrag_back(1,i,iset)+1,ifrag_back(2,i,iset)-1 ! Econstr_back legacy
8026 ! write(iout,*) "xxtab, yytab, zztab"
8027 ! write(iout,'(i5,3f8.2)') i,xxtab(i),yytab(i),zztab(i)
8028 do k=1,constr_homology
8030 dxx=-xxtpl(k,i)+xxtab(i) ! Diff b/w x component of ith SC vector in model and kth ref str?
8031 ! Original sign inverted for calc of gradients (s. Econstr_back)
8032 dyy=-yytpl(k,i)+yytab(i) ! ibid y
8033 dzz=-zztpl(k,i)+zztab(i) ! ibid z
8034 ! write(iout,*) "dxx, dyy, dzz"
8035 !d write(iout,'(2i5,4f8.2)') k,i,dxx,dyy,dzz,sigma_d(k,i)
8037 usc_diff_i=-0.5d0*(dxx**2+dyy**2+dzz**2)*sigma_d(k,i) ! waga_d rmvd from Gaussian argument
8038 ! usc_diff(i)=-0.5d0*waga_d*(dxx**2+dyy**2+dzz**2)*sigma_d(k,i) ! waga_d?
8039 ! uscdiffk(k)=usc_diff(i)
8040 guscdiff2(k)=dexp(usc_diff_i) ! without min_scdiff
8041 ! write(iout,*) "i",i," k",k," sigma_d",sigma_d(k,i),
8042 ! & " guscdiff2",guscdiff2(k)
8043 guscdiff(i)=guscdiff(i)+guscdiff2(k) !Sum of Gaussians (pk)
8044 ! write (iout,'(i5,6f10.5)') j,xxtab(j),yytab(j),zztab(j),
8045 ! & xxref(j),yyref(j),zzref(j)
8050 ! Generalized expression for multiple Gaussian acc to that for a single
8051 ! Gaussian in Econstr_back as instructed by AL (FP - 03/11/2014)
8053 ! Original implementation
8054 ! sum_guscdiff=guscdiff(i)
8056 ! sum_sguscdiff=0.0d0
8057 ! do k=1,constr_homology
8058 ! sguscdiff=-guscdiff2(k)*dscdiff(k)*sigma_d(k,i)*waga_d !waga_d?
8059 ! sguscdiff=-guscdiff3(k)*dscdiff(k)*sigma_d(k,i)*waga_d ! w min_uscdiff
8060 ! sum_sguscdiff=sum_sguscdiff+sguscdiff
8063 ! Implementation of new expressions for gradient (Jan. 2015)
8065 ! grad_uscdiff=sum_sguscdiff/(sum_guscdiff*dtab) !?
8066 do k=1,constr_homology
8068 ! New calculation of dxx, dyy, and dzz corrected by AL (07/11), was missing and wrong
8069 ! before. Now the drivatives should be correct
8071 dxx=-xxtpl(k,i)+xxtab(i) ! Diff b/w x component of ith SC vector in model and kth ref str?
8072 ! Original sign inverted for calc of gradients (s. Econstr_back)
8073 dyy=-yytpl(k,i)+yytab(i) ! ibid y
8074 dzz=-zztpl(k,i)+zztab(i) ! ibid z
8075 sum_guscdiff=guscdiff2(k)* &!(dsqrt(dxx*dxx+dyy*dyy+dzz*dzz))* -> wrong!
8076 sigma_d(k,i) ! for the grad wrt r'
8077 ! sum_sguscdiff=sum_sguscdiff+sum_guscdiff
8080 ! New implementation
8081 sum_guscdiff = waga_homology(iset)*waga_d*sum_guscdiff
8083 duscdiff(jik,i-1)=duscdiff(jik,i-1)+ &
8084 sum_guscdiff*(dXX_C1tab(jik,i)*dxx+ &
8085 dYY_C1tab(jik,i)*dyy+dZZ_C1tab(jik,i)*dzz)/guscdiff(i)
8086 duscdiff(jik,i)=duscdiff(jik,i)+ &
8087 sum_guscdiff*(dXX_Ctab(jik,i)*dxx+ &
8088 dYY_Ctab(jik,i)*dyy+dZZ_Ctab(jik,i)*dzz)/guscdiff(i)
8089 duscdiffx(jik,i)=duscdiffx(jik,i)+ &
8090 sum_guscdiff*(dXX_XYZtab(jik,i)*dxx+ &
8091 dYY_XYZtab(jik,i)*dyy+dZZ_XYZtab(jik,i)*dzz)/guscdiff(i)
8095 ! write(iout,*) "jik",jik,"i",i
8096 write(iout,*) "dxx, dyy, dzz"
8097 write(iout,'(2i5,3f8.2)') k,i,dxx,dyy,dzz
8098 write(iout,*) "guscdiff2(",k,")",guscdiff2(k)
8099 write(iout,*) "sum_sguscdiff",sum_guscdiff,waga_homology(iset),waga_d
8100 write(iout,*) "dXX_Ctab(",jik,i,")",dXX_Ctab(jik,i)
8101 write(iout,*) "dYY_Ctab(",jik,i,")",dYY_Ctab(jik,i)
8102 write(iout,*) "dZZ_Ctab(",jik,i,")",dZZ_Ctab(jik,i)
8103 write(iout,*) "dXX_C1tab(",jik,i,")",dXX_C1tab(jik,i)
8104 write(iout,*) "dYY_C1tab(",jik,i,")",dYY_C1tab(jik,i)
8105 write(iout,*) "dZZ_C1tab(",jik,i,")",dZZ_C1tab(jik,i)
8106 write(iout,*) "dXX_XYZtab(",jik,i,")",dXX_XYZtab(jik,i)
8107 write(iout,*) "dYY_XYZtab(",jik,i,")",dYY_XYZtab(jik,i)
8108 write(iout,*) "dZZ_XYZtab(",jik,i,")",dZZ_XYZtab(jik,i)
8109 write(iout,*) "duscdiff(",jik,i-1,")",duscdiff(jik,i-1)
8110 write(iout,*) "duscdiff(",jik,i,")",duscdiff(jik,i)
8111 write(iout,*) "duscdiffx(",jik,i,")",duscdiffx(jik,i)
8118 ! uscdiff(i)=-dLOG(guscdiff(i)/(ii-1)) ! Weighting by (ii-1) required?
8119 ! usc_diff(i)=-dLOG(guscdiff(i)/constr_homology) ! + min_uscdiff ?
8121 ! write (iout,*) i," uscdiff",uscdiff(i)
8123 ! Put together deviations from local geometry
8125 ! Uconst_back=Uconst_back+wfrag_back(1,i,iset)*utheta(i)+
8126 ! & wfrag_back(3,i,iset)*uscdiff(i)
8127 Erot=Erot-dLOG(guscdiff(i)/constr_homology)
8128 ! write (iout,*) "usc_diff(",i,")=",usc_diff(i) ! -ln of sum of exps
8129 ! write (iout,*) "Uconst_back",Uconst_back ! cum sum of -ln-s
8130 ! Uconst_back=Uconst_back+usc_diff(i)
8132 ! Gradient of multiple Gaussian restraint (FP - 04/11/2014 - right?)
8134 ! New implment: multiplied by sum_sguscdiff
8137 enddo ! (i-loop for dscdiff)
8142 write(iout,*) "------- SC restrs end -------"
8143 write (iout,*) "------ After SC loop in e_modeller ------"
8144 do i=loc_start,loc_end
8145 write (iout,*) "i",i," gradc",(gradc(j,i,icg),j=1,3)
8146 write (iout,*) "i",i," gradx",(gradx(j,i,icg),j=1,3)
8148 if (waga_theta.eq.1.0d0) then
8149 write (iout,*) "in e_modeller after SC restr end: dutheta"
8150 do i=ithet_start,ithet_end
8151 write (iout,*) i,dutheta(i)
8154 if (waga_d.eq.1.0d0) then
8155 write (iout,*) "e_modeller after SC loop: duscdiff/x"
8157 write (iout,*) i,(duscdiff(j,i),j=1,3)
8158 write (iout,*) i,(duscdiffx(j,i),j=1,3)
8163 ! Total energy from homology restraints
8165 write (iout,*) "odleg",odleg," kat",kat
8168 ! Addition of energy of theta angle and SC local geom over constr_homologs ref strs
8170 ! ehomology_constr=odleg+kat
8172 ! For Lorentzian-type Urestr
8175 if (waga_dist.ge.0.0d0) then
8177 ! For Gaussian-type Urestr
8179 ehomology_constr=(waga_dist*odleg+waga_angle*kat+ &
8180 waga_theta*Eval+waga_d*Erot)*waga_homology(iset)
8181 ! write (iout,*) "ehomology_constr=",ehomology_constr
8185 ! For Lorentzian-type Urestr
8187 ehomology_constr=(-waga_dist*odleg+waga_angle*kat+ &
8188 waga_theta*Eval+waga_d*Erot)*waga_homology(iset)
8189 ! write (iout,*) "ehomology_constr=",ehomology_constr
8193 write (iout,*) "odleg",waga_dist,odleg," kat",waga_angle,kat, &
8194 "Eval",waga_theta,eval, &
8196 write (iout,*) "ehomology_constr",ehomology_constr
8202 748 format(a8,f12.3,a6,f12.3,a7,f12.3)
8203 747 format(a12,i4,i4,i4,f8.3,f8.3)
8204 746 format(a12,i4,i4,i4,f8.3,f8.3,f8.3)
8205 778 format(a7,1X,f10.3,1X,a4,1X,f10.3,1X,a5,1X,f10.3)
8206 779 format(i3,1X,i3,1X,i2,1X,a7,1X,f7.3,1X,a7,1X,f7.3,1X,a13,1X, &
8207 f7.3,1X,a17,1X,f9.3,1X,a10,1X,f8.3,1X,a10,1X,f8.3)
8208 end subroutine e_modeller
8210 !----------------------------------------------------------------------------
8211 subroutine ebend_kcc(etheta)
8213 double precision thybt1(maxang_kcc),etheta
8214 integer :: i,iti,j,ihelp
8215 real (kind=8) :: sinthet,costhet,sumth1thyb,gradthybt1
8216 !C Set lprn=.true. for debugging
8219 !C print *,"wchodze kcc"
8220 if (lprn) write (iout,*) "ebend_kcc tor_mode",tor_mode
8222 do i=ithet_start,ithet_end
8223 !c print *,i,itype(i-1),itype(i),itype(i-2)
8224 if ((itype(i-1,1).eq.ntyp1).or.itype(i-2,1).eq.ntyp1 &
8225 .or.itype(i,1).eq.ntyp1) cycle
8226 iti=iabs(itortyp(itype(i-1,1)))
8227 sinthet=dsin(theta(i))
8228 costhet=dcos(theta(i))
8229 do j=1,nbend_kcc_Tb(iti)
8230 thybt1(j)=v1bend_chyb(j,iti)
8232 sumth1thyb=v1bend_chyb(0,iti)+ &
8233 tschebyshev(1,nbend_kcc_Tb(iti),thybt1(1),costhet)
8234 if (lprn) write (iout,*) i-1,itype(i-1,1),iti,theta(i)*rad2deg,&
8236 ihelp=nbend_kcc_Tb(iti)-1
8237 gradthybt1=gradtschebyshev(0,ihelp,thybt1(1),costhet)
8238 etheta=etheta+sumth1thyb
8239 !C print *,sumth1thyb,gradthybt1,sinthet*(-0.5d0)
8240 gloc(nphi+i-2,icg)=gloc(nphi+i-2,icg)-wang*gradthybt1*sinthet
8243 end subroutine ebend_kcc
8245 !c-------------------------------------------------------------------------------------
8246 subroutine etheta_constr(ethetacnstr)
8247 real (kind=8) :: ethetacnstr,thetiii,difi
8250 !C print *,ithetaconstr_start,ithetaconstr_end,"TU"
8251 do i=ithetaconstr_start,ithetaconstr_end
8252 itheta=itheta_constr(i)
8253 thetiii=theta(itheta)
8254 difi=pinorm(thetiii-theta_constr0(i))
8255 if (difi.gt.theta_drange(i)) then
8256 difi=difi-theta_drange(i)
8257 ethetacnstr=ethetacnstr+0.25d0*for_thet_constr(i)*difi**4
8258 gloc(itheta+nphi-2,icg)=gloc(itheta+nphi-2,icg) &
8259 +for_thet_constr(i)*difi**3
8260 else if (difi.lt.-drange(i)) then
8262 ethetacnstr=ethetacnstr+0.25d0*for_thet_constr(i)*difi**4
8263 gloc(itheta+nphi-2,icg)=gloc(itheta+nphi-2,icg) &
8264 +for_thet_constr(i)*difi**3
8268 if (energy_dec) then
8269 write (iout,'(a6,2i5,4f8.3,2e14.5)') "ethetc",&
8270 i,itheta,rad2deg*thetiii,&
8271 rad2deg*theta_constr0(i), rad2deg*theta_drange(i),&
8272 rad2deg*difi,0.25d0*for_thet_constr(i)*difi**4,&
8273 gloc(itheta+nphi-2,icg)
8277 end subroutine etheta_constr
8279 !-----------------------------------------------------------------------------
8280 subroutine eback_sc_corr(esccor)
8281 ! 7/21/2007 Correlations between the backbone-local and side-chain-local
8282 ! conformational states; temporarily implemented as differences
8283 ! between UNRES torsional potentials (dependent on three types of
8284 ! residues) and the torsional potentials dependent on all 20 types
8285 ! of residues computed from AM1 energy surfaces of terminally-blocked
8286 ! amino-acid residues.
8287 ! implicit real*8 (a-h,o-z)
8288 ! include 'DIMENSIONS'
8289 ! include 'COMMON.VAR'
8290 ! include 'COMMON.GEO'
8291 ! include 'COMMON.LOCAL'
8292 ! include 'COMMON.TORSION'
8293 ! include 'COMMON.SCCOR'
8294 ! include 'COMMON.INTERACT'
8295 ! include 'COMMON.DERIV'
8296 ! include 'COMMON.CHAIN'
8297 ! include 'COMMON.NAMES'
8298 ! include 'COMMON.IOUNITS'
8299 ! include 'COMMON.FFIELD'
8300 ! include 'COMMON.CONTROL'
8301 real(kind=8) :: esccor,esccor_ii,phii,gloci,v1ij,v2ij,&
8304 integer :: i,interty,j,isccori,isccori1,intertyp
8305 ! Set lprn=.true. for debugging
8308 ! write (iout,*) "EBACK_SC_COR",itau_start,itau_end
8310 do i=itau_start,itau_end
8311 if ((itype(i-2,1).eq.ntyp1).or.(itype(i-1,1).eq.ntyp1)) cycle
8313 isccori=isccortyp(itype(i-2,1))
8314 isccori1=isccortyp(itype(i-1,1))
8316 ! write (iout,*) "EBACK_SC_COR",i,nterm_sccor(isccori,isccori1)
8318 do intertyp=1,3 !intertyp
8320 !c Added 09 May 2012 (Adasko)
8321 !c Intertyp means interaction type of backbone mainchain correlation:
8322 ! 1 = SC...Ca...Ca...Ca
8323 ! 2 = Ca...Ca...Ca...SC
8324 ! 3 = SC...Ca...Ca...SCi
8326 if (((intertyp.eq.3).and.((itype(i-2,1).eq.10).or. &
8327 (itype(i-1,1).eq.10).or.(itype(i-2,1).eq.ntyp1).or. &
8328 (itype(i-1,1).eq.ntyp1))) &
8329 .or. ((intertyp.eq.1).and.((itype(i-2,1).eq.10) &
8330 .or.(itype(i-2,1).eq.ntyp1).or.(itype(i-1,1).eq.ntyp1) &
8331 .or.(itype(i,1).eq.ntyp1))) &
8332 .or.((intertyp.eq.2).and.((itype(i-1,1).eq.10).or. &
8333 (itype(i-1,1).eq.ntyp1).or.(itype(i-2,1).eq.ntyp1).or. &
8334 (itype(i-3,1).eq.ntyp1)))) cycle
8335 if ((intertyp.eq.2).and.(i.eq.4).and.(itype(1,1).eq.ntyp1)) cycle
8336 if ((intertyp.eq.1).and.(i.eq.nres).and.(itype(nres,1).eq.ntyp1)) &
8338 do j=1,nterm_sccor(isccori,isccori1)
8339 v1ij=v1sccor(j,intertyp,isccori,isccori1)
8340 v2ij=v2sccor(j,intertyp,isccori,isccori1)
8341 cosphi=dcos(j*tauangle(intertyp,i))
8342 sinphi=dsin(j*tauangle(intertyp,i))
8343 if (energy_dec) esccor_ii=esccor_ii+v1ij*cosphi+v2ij*sinphi
8344 esccor=esccor+v1ij*cosphi+v2ij*sinphi
8345 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
8347 if (energy_dec) write (iout,'(a6,i5,i2,0pf7.3)') &
8348 'esccor',i,intertyp,esccor_ii
8349 ! write (iout,*) "EBACK_SC_COR",i,v1ij*cosphi+v2ij*sinphi,intertyp
8350 gloc_sc(intertyp,i-3,icg)=gloc_sc(intertyp,i-3,icg)+wsccor*gloci
8352 write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)') &
8353 restyp(itype(i-2,1),1),i-2,restyp(itype(i-1,1),1),i-1,isccori,isccori1,&
8354 (v1sccor(j,intertyp,isccori,isccori1),j=1,6),&
8355 (v2sccor(j,intertyp,isccori,isccori1),j=1,6)
8356 gsccor_loc(i-3)=gsccor_loc(i-3)+gloci
8361 end subroutine eback_sc_corr
8362 !-----------------------------------------------------------------------------
8363 subroutine multibody(ecorr)
8364 ! This subroutine calculates multi-body contributions to energy following
8365 ! the idea of Skolnick et al. If side chains I and J make a contact and
8366 ! at the same time side chains I+1 and J+1 make a contact, an extra
8367 ! contribution equal to sqrt(eps(i,j)*eps(i+1,j+1)) is added.
8368 ! implicit real*8 (a-h,o-z)
8369 ! include 'DIMENSIONS'
8370 ! include 'COMMON.IOUNITS'
8371 ! include 'COMMON.DERIV'
8372 ! include 'COMMON.INTERACT'
8373 ! include 'COMMON.CONTACTS'
8374 real(kind=8),dimension(3) :: gx,gx1
8376 real(kind=8) :: ecorr
8377 integer :: i,j,ishift,i1,num_conti,num_conti1,j1,jj,kk
8378 ! Set lprn=.true. for debugging
8382 write (iout,'(a)') 'Contact function values:'
8384 write (iout,'(i2,20(1x,i2,f10.5))') &
8385 i,(jcont(j,i),facont(j,i),j=1,num_cont(i))
8390 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres))
8391 ! if (.not.allocated(gradxorr)) allocate(gradxorr(3,nres))
8403 num_conti=num_cont(i)
8404 num_conti1=num_cont(i1)
8409 if (j1.eq.j+ishift .or. j1.eq.j-ishift) then
8410 !d write(iout,*)'i=',i,' j=',j,' i1=',i1,' j1=',j1,
8411 !d & ' ishift=',ishift
8412 ! Contacts I--J and I+ISHIFT--J+-ISHIFT1 occur simultaneously.
8413 ! The system gains extra energy.
8414 ecorr=ecorr+esccorr(i,j,i1,j1,jj,kk)
8415 endif ! j1==j+-ishift
8423 end subroutine multibody
8424 !-----------------------------------------------------------------------------
8425 real(kind=8) function esccorr(i,j,k,l,jj,kk)
8426 ! implicit real*8 (a-h,o-z)
8427 ! include 'DIMENSIONS'
8428 ! include 'COMMON.IOUNITS'
8429 ! include 'COMMON.DERIV'
8430 ! include 'COMMON.INTERACT'
8431 ! include 'COMMON.CONTACTS'
8432 real(kind=8),dimension(3) :: gx,gx1
8434 integer :: i,j,k,l,jj,kk,m,ll
8435 real(kind=8) :: eij,ekl
8439 !d write (iout,'(4i5,3f10.5)') i,j,k,l,eij,ekl,-eij*ekl
8440 ! Calculate the multi-body contribution to energy.
8441 ! Calculate multi-body contributions to the gradient.
8442 !d write (iout,'(2(2i3,3f10.5))')i,j,(gacont(m,jj,i),m=1,3),
8443 !d & k,l,(gacont(m,kk,k),m=1,3)
8445 gx(m) =ekl*gacont(m,jj,i)
8446 gx1(m)=eij*gacont(m,kk,k)
8447 gradxorr(m,i)=gradxorr(m,i)-gx(m)
8448 gradxorr(m,j)=gradxorr(m,j)+gx(m)
8449 gradxorr(m,k)=gradxorr(m,k)-gx1(m)
8450 gradxorr(m,l)=gradxorr(m,l)+gx1(m)
8454 gradcorr(ll,m)=gradcorr(ll,m)+gx(ll)
8459 gradcorr(ll,m)=gradcorr(ll,m)+gx1(ll)
8464 end function esccorr
8465 !-----------------------------------------------------------------------------
8466 subroutine multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
8467 ! This subroutine calculates multi-body contributions to hydrogen-bonding
8468 ! implicit real*8 (a-h,o-z)
8469 ! include 'DIMENSIONS'
8470 ! include 'COMMON.IOUNITS'
8473 ! integer :: maxconts !max_cont=maxconts =nres/4
8474 integer,parameter :: max_dim=26
8475 integer :: source,CorrelType,CorrelID,CorrelType1,CorrelID1,Error
8476 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
8477 !el real(kind=8) :: zapas(max_dim,maxconts,nfgtasks)
8478 !el common /przechowalnia/ zapas
8479 integer :: status(MPI_STATUS_SIZE)
8480 integer,dimension((nres/4)*2) :: req !maxconts*2
8481 integer :: status_array(MPI_STATUS_SIZE,(nres/4)*2),nn,ireq,ierr
8483 ! include 'COMMON.SETUP'
8484 ! include 'COMMON.FFIELD'
8485 ! include 'COMMON.DERIV'
8486 ! include 'COMMON.INTERACT'
8487 ! include 'COMMON.CONTACTS'
8488 ! include 'COMMON.CONTROL'
8489 ! include 'COMMON.LOCAL'
8490 real(kind=8),dimension(3) :: gx,gx1
8491 real(kind=8) :: time00,ecorr,ecorr5,ecorr6
8492 logical :: lprn,ldone
8494 integer :: i,j,ii,k,n_corr,n_corr1,i1,num_conti,num_conti1,&
8495 jj,jp,kk,j1,jp1,jjc,iii,nnn,iproc
8497 ! Set lprn=.true. for debugging
8501 if(.not.allocated(zapas)) allocate(zapas(max_dim,maxconts,nfgtasks))
8504 if (nfgtasks.le.1) goto 30
8506 write (iout,'(a)') 'Contact function values before RECEIVE:'
8508 write (iout,'(2i3,50(1x,i2,f5.2))') &
8509 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
8514 do i=1,ntask_cont_from
8517 do i=1,ntask_cont_to
8520 ! write (iout,*) "ntask_cont_from",ntask_cont_from," ntask_cont_to",
8522 ! Make the list of contacts to send to send to other procesors
8523 ! write (iout,*) "limits",max0(iturn4_end-1,iatel_s),iturn3_end
8525 do i=iturn3_start,iturn3_end
8526 ! write (iout,*) "make contact list turn3",i," num_cont",
8528 call add_hb_contact(i,i+2,iturn3_sent_local(1,i))
8530 do i=iturn4_start,iturn4_end
8531 ! write (iout,*) "make contact list turn4",i," num_cont",
8533 call add_hb_contact(i,i+3,iturn4_sent_local(1,i))
8537 ! write (iout,*) "make contact list longrange",i,ii," num_cont",
8539 do j=1,num_cont_hb(i)
8542 iproc=iint_sent_local(k,jjc,ii)
8543 ! write (iout,*) "i",i," j",j," k",k," jjc",jjc," iproc",iproc
8544 if (iproc.gt.0) then
8545 ncont_sent(iproc)=ncont_sent(iproc)+1
8546 nn=ncont_sent(iproc)
8548 zapas(2,nn,iproc)=jjc
8549 zapas(3,nn,iproc)=facont_hb(j,i)
8550 zapas(4,nn,iproc)=ees0p(j,i)
8551 zapas(5,nn,iproc)=ees0m(j,i)
8552 zapas(6,nn,iproc)=gacont_hbr(1,j,i)
8553 zapas(7,nn,iproc)=gacont_hbr(2,j,i)
8554 zapas(8,nn,iproc)=gacont_hbr(3,j,i)
8555 zapas(9,nn,iproc)=gacontm_hb1(1,j,i)
8556 zapas(10,nn,iproc)=gacontm_hb1(2,j,i)
8557 zapas(11,nn,iproc)=gacontm_hb1(3,j,i)
8558 zapas(12,nn,iproc)=gacontp_hb1(1,j,i)
8559 zapas(13,nn,iproc)=gacontp_hb1(2,j,i)
8560 zapas(14,nn,iproc)=gacontp_hb1(3,j,i)
8561 zapas(15,nn,iproc)=gacontm_hb2(1,j,i)
8562 zapas(16,nn,iproc)=gacontm_hb2(2,j,i)
8563 zapas(17,nn,iproc)=gacontm_hb2(3,j,i)
8564 zapas(18,nn,iproc)=gacontp_hb2(1,j,i)
8565 zapas(19,nn,iproc)=gacontp_hb2(2,j,i)
8566 zapas(20,nn,iproc)=gacontp_hb2(3,j,i)
8567 zapas(21,nn,iproc)=gacontm_hb3(1,j,i)
8568 zapas(22,nn,iproc)=gacontm_hb3(2,j,i)
8569 zapas(23,nn,iproc)=gacontm_hb3(3,j,i)
8570 zapas(24,nn,iproc)=gacontp_hb3(1,j,i)
8571 zapas(25,nn,iproc)=gacontp_hb3(2,j,i)
8572 zapas(26,nn,iproc)=gacontp_hb3(3,j,i)
8579 "Numbers of contacts to be sent to other processors",&
8580 (ncont_sent(i),i=1,ntask_cont_to)
8581 write (iout,*) "Contacts sent"
8582 do ii=1,ntask_cont_to
8584 iproc=itask_cont_to(ii)
8585 write (iout,*) nn," contacts to processor",iproc,&
8586 " of CONT_TO_COMM group"
8588 write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
8596 CorrelID1=nfgtasks+fg_rank+1
8598 ! Receive the numbers of needed contacts from other processors
8599 do ii=1,ntask_cont_from
8600 iproc=itask_cont_from(ii)
8602 call MPI_Irecv(ncont_recv(ii),1,MPI_INTEGER,iproc,CorrelType,&
8603 FG_COMM,req(ireq),IERR)
8605 ! write (iout,*) "IRECV ended"
8607 ! Send the number of contacts needed by other processors
8608 do ii=1,ntask_cont_to
8609 iproc=itask_cont_to(ii)
8611 call MPI_Isend(ncont_sent(ii),1,MPI_INTEGER,iproc,CorrelType,&
8612 FG_COMM,req(ireq),IERR)
8614 ! write (iout,*) "ISEND ended"
8615 ! write (iout,*) "number of requests (nn)",ireq
8618 call MPI_Waitall(ireq,req,status_array,ierr)
8620 ! & "Numbers of contacts to be received from other processors",
8621 ! & (ncont_recv(i),i=1,ntask_cont_from)
8625 do ii=1,ntask_cont_from
8626 iproc=itask_cont_from(ii)
8628 ! write (iout,*) "Receiving",nn," contacts from processor",iproc,
8629 ! & " of CONT_TO_COMM group"
8633 call MPI_Irecv(zapas_recv(1,1,ii),nn*max_dim,&
8634 MPI_DOUBLE_PRECISION,iproc,CorrelType1,FG_COMM,req(ireq),IERR)
8635 ! write (iout,*) "ireq,req",ireq,req(ireq)
8638 ! Send the contacts to processors that need them
8639 do ii=1,ntask_cont_to
8640 iproc=itask_cont_to(ii)
8642 ! write (iout,*) nn," contacts to processor",iproc,
8643 ! & " of CONT_TO_COMM group"
8646 call MPI_Isend(zapas(1,1,ii),nn*max_dim,MPI_DOUBLE_PRECISION,&
8647 iproc,CorrelType1,FG_COMM,req(ireq),IERR)
8648 ! write (iout,*) "ireq,req",ireq,req(ireq)
8650 ! write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
8654 ! write (iout,*) "number of requests (contacts)",ireq
8655 ! write (iout,*) "req",(req(i),i=1,4)
8658 call MPI_Waitall(ireq,req,status_array,ierr)
8659 do iii=1,ntask_cont_from
8660 iproc=itask_cont_from(iii)
8663 write (iout,*) "Received",nn," contacts from processor",iproc,&
8664 " of CONT_FROM_COMM group"
8667 write(iout,'(2f5.0,4f10.5)')(zapas_recv(j,i,iii),j=1,5)
8672 ii=zapas_recv(1,i,iii)
8673 ! Flag the received contacts to prevent double-counting
8674 jj=-zapas_recv(2,i,iii)
8675 ! write (iout,*) "iii",iii," i",i," ii",ii," jj",jj
8677 nnn=num_cont_hb(ii)+1
8680 facont_hb(nnn,ii)=zapas_recv(3,i,iii)
8681 ees0p(nnn,ii)=zapas_recv(4,i,iii)
8682 ees0m(nnn,ii)=zapas_recv(5,i,iii)
8683 gacont_hbr(1,nnn,ii)=zapas_recv(6,i,iii)
8684 gacont_hbr(2,nnn,ii)=zapas_recv(7,i,iii)
8685 gacont_hbr(3,nnn,ii)=zapas_recv(8,i,iii)
8686 gacontm_hb1(1,nnn,ii)=zapas_recv(9,i,iii)
8687 gacontm_hb1(2,nnn,ii)=zapas_recv(10,i,iii)
8688 gacontm_hb1(3,nnn,ii)=zapas_recv(11,i,iii)
8689 gacontp_hb1(1,nnn,ii)=zapas_recv(12,i,iii)
8690 gacontp_hb1(2,nnn,ii)=zapas_recv(13,i,iii)
8691 gacontp_hb1(3,nnn,ii)=zapas_recv(14,i,iii)
8692 gacontm_hb2(1,nnn,ii)=zapas_recv(15,i,iii)
8693 gacontm_hb2(2,nnn,ii)=zapas_recv(16,i,iii)
8694 gacontm_hb2(3,nnn,ii)=zapas_recv(17,i,iii)
8695 gacontp_hb2(1,nnn,ii)=zapas_recv(18,i,iii)
8696 gacontp_hb2(2,nnn,ii)=zapas_recv(19,i,iii)
8697 gacontp_hb2(3,nnn,ii)=zapas_recv(20,i,iii)
8698 gacontm_hb3(1,nnn,ii)=zapas_recv(21,i,iii)
8699 gacontm_hb3(2,nnn,ii)=zapas_recv(22,i,iii)
8700 gacontm_hb3(3,nnn,ii)=zapas_recv(23,i,iii)
8701 gacontp_hb3(1,nnn,ii)=zapas_recv(24,i,iii)
8702 gacontp_hb3(2,nnn,ii)=zapas_recv(25,i,iii)
8703 gacontp_hb3(3,nnn,ii)=zapas_recv(26,i,iii)
8708 write (iout,'(a)') 'Contact function values after receive:'
8710 write (iout,'(2i3,50(1x,i3,f5.2))') &
8711 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
8719 write (iout,'(a)') 'Contact function values:'
8721 write (iout,'(2i3,50(1x,i3,f5.2))') &
8722 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
8728 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres))
8729 ! if (.not.allocated(gradxorr)) allocate(gradxorr(3,nres))
8730 ! Remove the loop below after debugging !!!
8737 ! Calculate the local-electrostatic correlation terms
8738 do i=min0(iatel_s,iturn4_start),max0(iatel_e,iturn3_end)
8740 num_conti=num_cont_hb(i)
8741 num_conti1=num_cont_hb(i+1)
8748 ! write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,&
8749 ! ' jj=',jj,' kk=',kk,"jp=",jp,"jp1",jp1
8750 if ((j.gt.0 .and. j1.gt.0 .or. j.gt.0 .and. j1.lt.0 &
8751 .or. j.lt.0 .and. j1.gt.0) .and. &
8752 (jp1.eq.jp+1 .or. jp1.eq.jp-1)) then
8753 ! Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
8754 ! The system gains extra energy.
8755 ecorr=ecorr+ehbcorr(i,jp,i+1,jp1,jj,kk,0.72D0,0.32D0)
8756 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
8757 'ecorrh',i,j,ehbcorr(i,jp,i+1,jp1,jj,kk,0.72D0,0.32D0)
8759 else if (j1.eq.j) then
8760 ! Contacts I-J and I-(J+1) occur simultaneously.
8761 ! The system loses extra energy.
8762 ! ecorr=ecorr+ehbcorr(i,j,i+1,j,jj,kk,0.60D0,-0.40D0)
8767 ! write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
8768 ! & ' jj=',jj,' kk=',kk
8770 ! Contacts I-J and (I+1)-J occur simultaneously.
8771 ! The system loses extra energy.
8772 ! ecorr=ecorr+ehbcorr(i,j,i,j+1,jj,kk,0.60D0,-0.40D0)
8778 end subroutine multibody_hb
8779 !-----------------------------------------------------------------------------
8780 subroutine add_hb_contact(ii,jj,itask)
8781 ! implicit real*8 (a-h,o-z)
8782 ! include "DIMENSIONS"
8783 ! include "COMMON.IOUNITS"
8784 ! include "COMMON.CONTACTS"
8785 ! integer,parameter :: maxconts=nres/4
8786 integer,parameter :: max_dim=26
8787 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
8788 ! real(kind=8) :: zapas(max_dim,maxconts,nfgtasks)
8789 ! common /przechowalnia/ zapas
8790 integer :: i,j,ii,jj,iproc,nn,jjc
8791 integer,dimension(4) :: itask
8792 ! write (iout,*) "itask",itask
8795 if (iproc.gt.0) then
8796 do j=1,num_cont_hb(ii)
8798 ! write (iout,*) "i",ii," j",jj," jjc",jjc
8800 ncont_sent(iproc)=ncont_sent(iproc)+1
8801 nn=ncont_sent(iproc)
8802 zapas(1,nn,iproc)=ii
8803 zapas(2,nn,iproc)=jjc
8804 zapas(3,nn,iproc)=facont_hb(j,ii)
8805 zapas(4,nn,iproc)=ees0p(j,ii)
8806 zapas(5,nn,iproc)=ees0m(j,ii)
8807 zapas(6,nn,iproc)=gacont_hbr(1,j,ii)
8808 zapas(7,nn,iproc)=gacont_hbr(2,j,ii)
8809 zapas(8,nn,iproc)=gacont_hbr(3,j,ii)
8810 zapas(9,nn,iproc)=gacontm_hb1(1,j,ii)
8811 zapas(10,nn,iproc)=gacontm_hb1(2,j,ii)
8812 zapas(11,nn,iproc)=gacontm_hb1(3,j,ii)
8813 zapas(12,nn,iproc)=gacontp_hb1(1,j,ii)
8814 zapas(13,nn,iproc)=gacontp_hb1(2,j,ii)
8815 zapas(14,nn,iproc)=gacontp_hb1(3,j,ii)
8816 zapas(15,nn,iproc)=gacontm_hb2(1,j,ii)
8817 zapas(16,nn,iproc)=gacontm_hb2(2,j,ii)
8818 zapas(17,nn,iproc)=gacontm_hb2(3,j,ii)
8819 zapas(18,nn,iproc)=gacontp_hb2(1,j,ii)
8820 zapas(19,nn,iproc)=gacontp_hb2(2,j,ii)
8821 zapas(20,nn,iproc)=gacontp_hb2(3,j,ii)
8822 zapas(21,nn,iproc)=gacontm_hb3(1,j,ii)
8823 zapas(22,nn,iproc)=gacontm_hb3(2,j,ii)
8824 zapas(23,nn,iproc)=gacontm_hb3(3,j,ii)
8825 zapas(24,nn,iproc)=gacontp_hb3(1,j,ii)
8826 zapas(25,nn,iproc)=gacontp_hb3(2,j,ii)
8827 zapas(26,nn,iproc)=gacontp_hb3(3,j,ii)
8834 end subroutine add_hb_contact
8835 !-----------------------------------------------------------------------------
8836 subroutine multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
8837 ! This subroutine calculates multi-body contributions to hydrogen-bonding
8838 ! implicit real*8 (a-h,o-z)
8839 ! include 'DIMENSIONS'
8840 ! include 'COMMON.IOUNITS'
8841 integer,parameter :: max_dim=70
8844 ! integer :: maxconts !max_cont=maxconts=nres/4
8845 integer :: source,CorrelType,CorrelID,CorrelType1,CorrelID1,Error
8846 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks)
8847 ! real(kind=8) :: zapas(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
8848 ! common /przechowalnia/ zapas
8849 integer :: status(MPI_STATUS_SIZE),req((nres/4)*2),&
8850 status_array(MPI_STATUS_SIZE,(nres/4)*2),jjc,iproc,ireq,nn,ind,&
8853 ! include 'COMMON.SETUP'
8854 ! include 'COMMON.FFIELD'
8855 ! include 'COMMON.DERIV'
8856 ! include 'COMMON.LOCAL'
8857 ! include 'COMMON.INTERACT'
8858 ! include 'COMMON.CONTACTS'
8859 ! include 'COMMON.CHAIN'
8860 ! include 'COMMON.CONTROL'
8861 real(kind=8),dimension(3) :: gx,gx1
8862 integer,dimension(nres) :: num_cont_hb_old
8863 logical :: lprn,ldone
8864 !EL double precision eello4,eello5,eelo6,eello_turn6
8865 !EL external eello4,eello5,eello6,eello_turn6
8867 integer :: i,ii,j,k,l,jj,kk,ll,mm,n_corr,n_corr1,num_conti,jp,&
8868 j1,jp1,i1,num_conti1
8869 real(kind=8) :: sqd1,sqd2,sred_geom,fac_prim1,fac_prim2,fprimcont
8870 real(kind=8) :: ecorr,ecorr5,ecorr6,eturn6
8872 ! Set lprn=.true. for debugging
8877 if(.not.allocated(zapas)) allocate(zapas(max_dim,maxconts,nfgtasks))
8879 num_cont_hb_old(i)=num_cont_hb(i)
8883 if (nfgtasks.le.1) goto 30
8885 write (iout,'(a)') 'Contact function values before RECEIVE:'
8887 write (iout,'(2i3,50(1x,i2,f5.2))') &
8888 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
8893 do i=1,ntask_cont_from
8896 do i=1,ntask_cont_to
8899 ! write (iout,*) "ntask_cont_from",ntask_cont_from," ntask_cont_to",
8901 ! Make the list of contacts to send to send to other procesors
8902 do i=iturn3_start,iturn3_end
8903 ! write (iout,*) "make contact list turn3",i," num_cont",
8905 call add_hb_contact_eello(i,i+2,iturn3_sent_local(1,i))
8907 do i=iturn4_start,iturn4_end
8908 ! write (iout,*) "make contact list turn4",i," num_cont",
8910 call add_hb_contact_eello(i,i+3,iturn4_sent_local(1,i))
8914 ! write (iout,*) "make contact list longrange",i,ii," num_cont",
8916 do j=1,num_cont_hb(i)
8919 iproc=iint_sent_local(k,jjc,ii)
8920 ! write (iout,*) "i",i," j",j," k",k," jjc",jjc," iproc",iproc
8921 if (iproc.ne.0) then
8922 ncont_sent(iproc)=ncont_sent(iproc)+1
8923 nn=ncont_sent(iproc)
8925 zapas(2,nn,iproc)=jjc
8926 zapas(3,nn,iproc)=d_cont(j,i)
8930 zapas(ind,nn,iproc)=grij_hb_cont(kk,j,i)
8935 zapas(ind,nn,iproc)=a_chuj(ll,kk,j,i)
8943 zapas(ind,nn,iproc)=a_chuj_der(mm,ll,kk,jj,j,i)
8954 "Numbers of contacts to be sent to other processors",&
8955 (ncont_sent(i),i=1,ntask_cont_to)
8956 write (iout,*) "Contacts sent"
8957 do ii=1,ntask_cont_to
8959 iproc=itask_cont_to(ii)
8960 write (iout,*) nn," contacts to processor",iproc,&
8961 " of CONT_TO_COMM group"
8963 write(iout,'(2f5.0,10f10.5)')(zapas(j,i,ii),j=1,10)
8971 CorrelID1=nfgtasks+fg_rank+1
8973 ! Receive the numbers of needed contacts from other processors
8974 do ii=1,ntask_cont_from
8975 iproc=itask_cont_from(ii)
8977 call MPI_Irecv(ncont_recv(ii),1,MPI_INTEGER,iproc,CorrelType,&
8978 FG_COMM,req(ireq),IERR)
8980 ! write (iout,*) "IRECV ended"
8982 ! Send the number of contacts needed by other processors
8983 do ii=1,ntask_cont_to
8984 iproc=itask_cont_to(ii)
8986 call MPI_Isend(ncont_sent(ii),1,MPI_INTEGER,iproc,CorrelType,&
8987 FG_COMM,req(ireq),IERR)
8989 ! write (iout,*) "ISEND ended"
8990 ! write (iout,*) "number of requests (nn)",ireq
8993 call MPI_Waitall(ireq,req,status_array,ierr)
8995 ! & "Numbers of contacts to be received from other processors",
8996 ! & (ncont_recv(i),i=1,ntask_cont_from)
9000 do ii=1,ntask_cont_from
9001 iproc=itask_cont_from(ii)
9003 ! write (iout,*) "Receiving",nn," contacts from processor",iproc,
9004 ! & " of CONT_TO_COMM group"
9008 call MPI_Irecv(zapas_recv(1,1,ii),nn*max_dim,&
9009 MPI_DOUBLE_PRECISION,iproc,CorrelType1,FG_COMM,req(ireq),IERR)
9010 ! write (iout,*) "ireq,req",ireq,req(ireq)
9013 ! Send the contacts to processors that need them
9014 do ii=1,ntask_cont_to
9015 iproc=itask_cont_to(ii)
9017 ! write (iout,*) nn," contacts to processor",iproc,
9018 ! & " of CONT_TO_COMM group"
9021 call MPI_Isend(zapas(1,1,ii),nn*max_dim,MPI_DOUBLE_PRECISION,&
9022 iproc,CorrelType1,FG_COMM,req(ireq),IERR)
9023 ! write (iout,*) "ireq,req",ireq,req(ireq)
9025 ! write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
9029 ! write (iout,*) "number of requests (contacts)",ireq
9030 ! write (iout,*) "req",(req(i),i=1,4)
9033 call MPI_Waitall(ireq,req,status_array,ierr)
9034 do iii=1,ntask_cont_from
9035 iproc=itask_cont_from(iii)
9038 write (iout,*) "Received",nn," contacts from processor",iproc,&
9039 " of CONT_FROM_COMM group"
9042 write(iout,'(2f5.0,10f10.5)')(zapas_recv(j,i,iii),j=1,10)
9047 ii=zapas_recv(1,i,iii)
9048 ! Flag the received contacts to prevent double-counting
9049 jj=-zapas_recv(2,i,iii)
9050 ! write (iout,*) "iii",iii," i",i," ii",ii," jj",jj
9052 nnn=num_cont_hb(ii)+1
9055 d_cont(nnn,ii)=zapas_recv(3,i,iii)
9059 grij_hb_cont(kk,nnn,ii)=zapas_recv(ind,i,iii)
9064 a_chuj(ll,kk,nnn,ii)=zapas_recv(ind,i,iii)
9072 a_chuj_der(mm,ll,kk,jj,nnn,ii)=zapas_recv(ind,i,iii)
9081 write (iout,'(a)') 'Contact function values after receive:'
9083 write (iout,'(2i3,50(1x,i3,5f6.3))') &
9084 i,num_cont_hb(i),(jcont_hb(j,i),d_cont(j,i),&
9085 ((a_chuj(ll,kk,j,i),ll=1,2),kk=1,2),j=1,num_cont_hb(i))
9092 write (iout,'(a)') 'Contact function values:'
9094 write (iout,'(2i3,50(1x,i2,5f6.3))') &
9095 i,num_cont_hb(i),(jcont_hb(j,i),d_cont(j,i),&
9096 ((a_chuj(ll,kk,j,i),ll=1,2),kk=1,2),j=1,num_cont_hb(i))
9103 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres))
9104 ! if (.not.allocated(gradxorr)) allocate(gradxorr(3,nres))
9105 ! Remove the loop below after debugging !!!
9112 ! Calculate the dipole-dipole interaction energies
9113 if (wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) then
9114 do i=iatel_s,iatel_e+1
9115 num_conti=num_cont_hb(i)
9124 ! Calculate the local-electrostatic correlation terms
9125 ! write (iout,*) "gradcorr5 in eello5 before loop"
9127 ! write (iout,'(i5,3f10.5)')
9128 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
9130 do i=min0(iatel_s,iturn4_start),max0(iatel_e+1,iturn3_end+1)
9131 ! write (iout,*) "corr loop i",i
9133 num_conti=num_cont_hb(i)
9134 num_conti1=num_cont_hb(i+1)
9141 ! write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
9142 ! & ' jj=',jj,' kk=',kk
9143 ! if (j1.eq.j+1 .or. j1.eq.j-1) then
9144 if ((j.gt.0 .and. j1.gt.0 .or. j.gt.0 .and. j1.lt.0 &
9145 .or. j.lt.0 .and. j1.gt.0) .and. &
9146 (jp1.eq.jp+1 .or. jp1.eq.jp-1)) then
9147 ! Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
9148 ! The system gains extra energy.
9150 sqd1=dsqrt(d_cont(jj,i))
9151 sqd2=dsqrt(d_cont(kk,i1))
9152 sred_geom = sqd1*sqd2
9153 IF (sred_geom.lt.cutoff_corr) THEN
9154 call gcont(sred_geom,r0_corr,1.0D0,delt_corr,&
9156 !d write (iout,*) 'i=',i,' j=',jp,' i1=',i1,' j1=',jp1,
9157 !d & ' jj=',jj,' kk=',kk
9158 fac_prim1=0.5d0*sqd2/sqd1*fprimcont
9159 fac_prim2=0.5d0*sqd1/sqd2*fprimcont
9161 g_contij(l,1)=fac_prim1*grij_hb_cont(l,jj,i)
9162 g_contij(l,2)=fac_prim2*grij_hb_cont(l,kk,i1)
9165 !d write (iout,*) 'sred_geom=',sred_geom,
9166 !d & ' ekont=',ekont,' fprim=',fprimcont,
9167 !d & ' fac_prim1',fac_prim1,' fac_prim2',fac_prim2
9168 !d write (iout,*) "g_contij",g_contij
9169 !d write (iout,*) "grij_hb_cont i",grij_hb_cont(:,jj,i)
9170 !d write (iout,*) "grij_hb_cont i1",grij_hb_cont(:,jj,i1)
9171 call calc_eello(i,jp,i+1,jp1,jj,kk)
9172 if (wcorr4.gt.0.0d0) &
9173 ecorr=ecorr+eello4(i,jp,i+1,jp1,jj,kk)
9174 if (energy_dec.and.wcorr4.gt.0.0d0) &
9175 write (iout,'(a6,4i5,0pf7.3)') &
9176 'ecorr4',i,j,i+1,j1,eello4(i,jp,i+1,jp1,jj,kk)
9177 ! write (iout,*) "gradcorr5 before eello5"
9179 ! write (iout,'(i5,3f10.5)')
9180 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
9182 if (wcorr5.gt.0.0d0) &
9183 ecorr5=ecorr5+eello5(i,jp,i+1,jp1,jj,kk)
9184 ! write (iout,*) "gradcorr5 after eello5"
9186 ! write (iout,'(i5,3f10.5)')
9187 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
9189 if (energy_dec.and.wcorr5.gt.0.0d0) &
9190 write (iout,'(a6,4i5,0pf7.3)') &
9191 'ecorr5',i,j,i+1,j1,eello5(i,jp,i+1,jp1,jj,kk)
9192 !d write(2,*)'wcorr6',wcorr6,' wturn6',wturn6
9193 !d write(2,*)'ijkl',i,jp,i+1,jp1
9194 if (wcorr6.gt.0.0d0 .and. (jp.ne.i+4 .or. jp1.ne.i+3 &
9195 .or. wturn6.eq.0.0d0))then
9196 !d write (iout,*) '******ecorr6: i,j,i+1,j1',i,j,i+1,j1
9197 ecorr6=ecorr6+eello6(i,jp,i+1,jp1,jj,kk)
9198 if (energy_dec) write (iout,'(a6,4i5,0pf7.3)') &
9199 'ecorr6',i,j,i+1,j1,eello6(i,jp,i+1,jp1,jj,kk)
9200 !d write (iout,*) 'ecorr',ecorr,' ecorr5=',ecorr5,
9201 !d & 'ecorr6=',ecorr6
9202 !d write (iout,'(4e15.5)') sred_geom,
9203 !d & dabs(eello4(i,jp,i+1,jp1,jj,kk)),
9204 !d & dabs(eello5(i,jp,i+1,jp1,jj,kk)),
9205 !d & dabs(eello6(i,jp,i+1,jp1,jj,kk))
9206 else if (wturn6.gt.0.0d0 &
9207 .and. (jp.eq.i+4 .and. jp1.eq.i+3)) then
9208 !d write (iout,*) '******eturn6: i,j,i+1,j1',i,jip,i+1,jp1
9209 eturn6=eturn6+eello_turn6(i,jj,kk)
9210 if (energy_dec) write (iout,'(a6,4i5,0pf7.3)') &
9211 'eturn6',i,j,i+1,j1,eello_turn6(i,jj,kk)
9212 !d write (2,*) 'multibody_eello:eturn6',eturn6
9221 num_cont_hb(i)=num_cont_hb_old(i)
9223 ! write (iout,*) "gradcorr5 in eello5"
9225 ! write (iout,'(i5,3f10.5)')
9226 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
9229 end subroutine multibody_eello
9230 !-----------------------------------------------------------------------------
9231 subroutine add_hb_contact_eello(ii,jj,itask)
9232 ! implicit real*8 (a-h,o-z)
9233 ! include "DIMENSIONS"
9234 ! include "COMMON.IOUNITS"
9235 ! include "COMMON.CONTACTS"
9236 ! integer,parameter :: maxconts=nres/4
9237 integer,parameter :: max_dim=70
9238 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks)
9239 ! real(kind=8) :: zapas(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
9240 ! common /przechowalnia/ zapas
9242 integer :: i,j,ii,jj,iproc,nn,ind,jjc,kk,ll,mm
9243 integer,dimension(4) ::itask
9244 ! write (iout,*) "itask",itask
9247 if (iproc.gt.0) then
9248 do j=1,num_cont_hb(ii)
9250 ! write (iout,*) "send turns i",ii," j",jj," jjc",jjc
9252 ncont_sent(iproc)=ncont_sent(iproc)+1
9253 nn=ncont_sent(iproc)
9254 zapas(1,nn,iproc)=ii
9255 zapas(2,nn,iproc)=jjc
9256 zapas(3,nn,iproc)=d_cont(j,ii)
9260 zapas(ind,nn,iproc)=grij_hb_cont(kk,j,ii)
9265 zapas(ind,nn,iproc)=a_chuj(ll,kk,j,ii)
9273 zapas(ind,nn,iproc)=a_chuj_der(mm,ll,kk,jj,j,ii)
9284 end subroutine add_hb_contact_eello
9285 !-----------------------------------------------------------------------------
9286 real(kind=8) function ehbcorr(i,j,k,l,jj,kk,coeffp,coeffm)
9287 ! implicit real*8 (a-h,o-z)
9288 ! include 'DIMENSIONS'
9289 ! include 'COMMON.IOUNITS'
9290 ! include 'COMMON.DERIV'
9291 ! include 'COMMON.INTERACT'
9292 ! include 'COMMON.CONTACTS'
9293 real(kind=8),dimension(3) :: gx,gx1
9296 integer :: i,j,k,l,jj,kk,ll,ilist,m, iresshield
9297 real(kind=8) :: coeffp,coeffm,eij,ekl,ees0pij,ees0pkl,ees0mij,&
9298 ees0mkl,ees,coeffpees0pij,coeffmees0mij,&
9299 coeffpees0pkl,coeffmees0mkl,gradlongij,gradlongkl, &
9310 ees=-(coeffp*ees0pij*ees0pkl+coeffm*ees0mij*ees0mkl)
9311 !d ees=-(coeffp*ees0pkl+coeffm*ees0mkl)
9312 ! Following 4 lines for diagnostics.
9317 ! write (iout,'(2(a,2i3,a,f10.5,a,2f10.5),a,f10.5,a,$)')
9318 ! & 'Contacts ',i,j,
9319 ! & ' eij',eij,' eesij',ees0pij,ees0mij,' and ',k,l
9320 ! & ,' fcont ',ekl,' eeskl',ees0pkl,ees0mkl,' energy=',ekont*ees,
9322 ! Calculate the multi-body contribution to energy.
9323 ! ecorr=ecorr+ekont*ees
9324 ! Calculate multi-body contributions to the gradient.
9325 coeffpees0pij=coeffp*ees0pij
9326 coeffmees0mij=coeffm*ees0mij
9327 coeffpees0pkl=coeffp*ees0pkl
9328 coeffmees0mkl=coeffm*ees0mkl
9330 !grad ghalfi=ees*ekl*gacont_hbr(ll,jj,i)
9331 gradcorr(ll,i)=gradcorr(ll,i) & !+0.5d0*ghalfi
9332 -ekont*(coeffpees0pkl*gacontp_hb1(ll,jj,i)+ &
9333 coeffmees0mkl*gacontm_hb1(ll,jj,i))
9334 gradcorr(ll,j)=gradcorr(ll,j) & !+0.5d0*ghalfi
9335 -ekont*(coeffpees0pkl*gacontp_hb2(ll,jj,i)+ &
9336 coeffmees0mkl*gacontm_hb2(ll,jj,i))
9337 !grad ghalfk=ees*eij*gacont_hbr(ll,kk,k)
9338 gradcorr(ll,k)=gradcorr(ll,k) & !+0.5d0*ghalfk
9339 -ekont*(coeffpees0pij*gacontp_hb1(ll,kk,k)+&
9340 coeffmees0mij*gacontm_hb1(ll,kk,k))
9341 gradcorr(ll,l)=gradcorr(ll,l) & !+0.5d0*ghalfk
9342 -ekont*(coeffpees0pij*gacontp_hb2(ll,kk,k)+ &
9343 coeffmees0mij*gacontm_hb2(ll,kk,k))
9344 gradlongij=ees*ekl*gacont_hbr(ll,jj,i)- &
9345 ekont*(coeffpees0pkl*gacontp_hb3(ll,jj,i)+ &
9346 coeffmees0mkl*gacontm_hb3(ll,jj,i))
9347 gradcorr_long(ll,j)=gradcorr_long(ll,j)+gradlongij
9348 gradcorr_long(ll,i)=gradcorr_long(ll,i)-gradlongij
9349 gradlongkl=ees*eij*gacont_hbr(ll,kk,k)- &
9350 ekont*(coeffpees0pij*gacontp_hb3(ll,kk,k)+ &
9351 coeffmees0mij*gacontm_hb3(ll,kk,k))
9352 gradcorr_long(ll,l)=gradcorr_long(ll,l)+gradlongkl
9353 gradcorr_long(ll,k)=gradcorr_long(ll,k)-gradlongkl
9354 ! write (iout,'(2f10.5,2x,$)') gradlongij,gradlongkl
9359 !grad gradcorr(ll,m)=gradcorr(ll,m)+
9360 !grad & ees*ekl*gacont_hbr(ll,jj,i)-
9361 !grad & ekont*(coeffp*ees0pkl*gacontp_hb3(ll,jj,i)+
9362 !grad & coeffm*ees0mkl*gacontm_hb3(ll,jj,i))
9367 !grad gradcorr(ll,m)=gradcorr(ll,m)+
9368 !grad & ees*eij*gacont_hbr(ll,kk,k)-
9369 !grad & ekont*(coeffp*ees0pij*gacontp_hb3(ll,kk,k)+
9370 !grad & coeffm*ees0mij*gacontm_hb3(ll,kk,k))
9373 ! write (iout,*) "ehbcorr",ekont*ees
9375 if (shield_mode.gt.0) then
9378 !C print *,i,j,fac_shield(i),fac_shield(j),
9379 !C &fac_shield(k),fac_shield(l)
9380 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
9381 (fac_shield(k).gt.0).and.(fac_shield(l).gt.0)) then
9382 do ilist=1,ishield_list(i)
9383 iresshield=shield_list(ilist,i)
9385 rlocshield=grad_shield_side(m,ilist,i)*ehbcorr/fac_shield(i)
9386 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+ &
9388 +grad_shield_loc(m,ilist,i)*ehbcorr/fac_shield(i)
9389 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1) &
9393 do ilist=1,ishield_list(j)
9394 iresshield=shield_list(ilist,j)
9396 rlocshield=grad_shield_side(m,ilist,j)*ehbcorr/fac_shield(j)
9397 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+ &
9399 +grad_shield_loc(m,ilist,j)*ehbcorr/fac_shield(j)
9400 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1) &
9405 do ilist=1,ishield_list(k)
9406 iresshield=shield_list(ilist,k)
9408 rlocshield=grad_shield_side(m,ilist,k)*ehbcorr/fac_shield(k)
9409 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+ &
9411 +grad_shield_loc(m,ilist,k)*ehbcorr/fac_shield(k)
9412 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1) &
9416 do ilist=1,ishield_list(l)
9417 iresshield=shield_list(ilist,l)
9419 rlocshield=grad_shield_side(m,ilist,l)*ehbcorr/fac_shield(l)
9420 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+ &
9422 +grad_shield_loc(m,ilist,l)*ehbcorr/fac_shield(l)
9423 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1) &
9428 gshieldc_ec(m,i)=gshieldc_ec(m,i)+ &
9429 grad_shield(m,i)*ehbcorr/fac_shield(i)
9430 gshieldc_ec(m,j)=gshieldc_ec(m,j)+ &
9431 grad_shield(m,j)*ehbcorr/fac_shield(j)
9432 gshieldc_ec(m,i-1)=gshieldc_ec(m,i-1)+ &
9433 grad_shield(m,i)*ehbcorr/fac_shield(i)
9434 gshieldc_ec(m,j-1)=gshieldc_ec(m,j-1)+ &
9435 grad_shield(m,j)*ehbcorr/fac_shield(j)
9437 gshieldc_ec(m,k)=gshieldc_ec(m,k)+ &
9438 grad_shield(m,k)*ehbcorr/fac_shield(k)
9439 gshieldc_ec(m,l)=gshieldc_ec(m,l)+ &
9440 grad_shield(m,l)*ehbcorr/fac_shield(l)
9441 gshieldc_ec(m,k-1)=gshieldc_ec(m,k-1)+ &
9442 grad_shield(m,k)*ehbcorr/fac_shield(k)
9443 gshieldc_ec(m,l-1)=gshieldc_ec(m,l-1)+ &
9444 grad_shield(m,l)*ehbcorr/fac_shield(l)
9450 end function ehbcorr
9452 !-----------------------------------------------------------------------------
9453 subroutine dipole(i,j,jj)
9454 ! implicit real*8 (a-h,o-z)
9455 ! include 'DIMENSIONS'
9456 ! include 'COMMON.IOUNITS'
9457 ! include 'COMMON.CHAIN'
9458 ! include 'COMMON.FFIELD'
9459 ! include 'COMMON.DERIV'
9460 ! include 'COMMON.INTERACT'
9461 ! include 'COMMON.CONTACTS'
9462 ! include 'COMMON.TORSION'
9463 ! include 'COMMON.VAR'
9464 ! include 'COMMON.GEO'
9465 real(kind=8),dimension(2,2) :: dipi,dipj,auxmat
9466 real(kind=8),dimension(2) :: dipderi,dipderj,auxvec
9467 integer :: i,j,jj,iii,jjj,kkk,lll,iti1,itj1
9469 allocate(dip(4,maxconts,nres),dipderg(4,maxconts,nres))
9470 allocate(dipderx(3,5,4,maxconts,nres))
9473 iti1 = itortyp(itype(i+1,1))
9474 if (j.lt.nres-1) then
9475 itj1 = itype2loc(itype(j+1,1))
9480 dipi(iii,1)=Ub2(iii,i)
9481 dipderi(iii)=Ub2der(iii,i)
9482 dipi(iii,2)=b1(iii,iti1)
9483 dipj(iii,1)=Ub2(iii,j)
9484 dipderj(iii)=Ub2der(iii,j)
9485 dipj(iii,2)=b1(iii,itj1)
9489 call matvec2(a_chuj(1,1,jj,i),dipj(1,iii),auxvec(1))
9492 dip(kkk,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
9499 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),dipj(1,iii),&
9503 dipderx(lll,kkk,mmm,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
9508 call transpose2(a_chuj(1,1,jj,i),auxmat(1,1))
9509 call matvec2(auxmat(1,1),dipderi(1),auxvec(1))
9511 dipderg(iii,jj,i)=scalar2(auxvec(1),dipj(1,iii))
9513 call matvec2(a_chuj(1,1,jj,i),dipderj(1),auxvec(1))
9515 dipderg(iii+2,jj,i)=scalar2(auxvec(1),dipi(1,iii))
9518 end subroutine dipole
9520 !-----------------------------------------------------------------------------
9521 subroutine calc_eello(i,j,k,l,jj,kk)
9523 ! This subroutine computes matrices and vectors needed to calculate
9524 ! the fourth-, fifth-, and sixth-order local-electrostatic terms.
9527 ! implicit real*8 (a-h,o-z)
9528 ! include 'DIMENSIONS'
9529 ! include 'COMMON.IOUNITS'
9530 ! include 'COMMON.CHAIN'
9531 ! include 'COMMON.DERIV'
9532 ! include 'COMMON.INTERACT'
9533 ! include 'COMMON.CONTACTS'
9534 ! include 'COMMON.TORSION'
9535 ! include 'COMMON.VAR'
9536 ! include 'COMMON.GEO'
9537 ! include 'COMMON.FFIELD'
9538 real(kind=8),dimension(2,2) :: aa1,aa2,aa1t,aa2t,auxmat
9539 real(kind=8),dimension(2,2,3,5) :: aa1tder,aa2tder
9540 integer :: i,j,k,l,jj,kk,iii,jjj,kkk,lll,iti,itk1,itj,itl,itl1,&
9543 !el common /kutas/ lprn
9544 !d write (iout,*) 'calc_eello: i=',i,' j=',j,' k=',k,' l=',l,
9545 !d & ' jj=',jj,' kk=',kk
9546 !d if (i.ne.2 .or. j.ne.4 .or. k.ne.3 .or. l.ne.5) return
9547 !d write (iout,*) "a_chujij",((a_chuj(iii,jjj,jj,i),iii=1,2),jjj=1,2)
9548 !d write (iout,*) "a_chujkl",((a_chuj(iii,jjj,kk,k),iii=1,2),jjj=1,2)
9551 aa1(iii,jjj)=a_chuj(iii,jjj,jj,i)
9552 aa2(iii,jjj)=a_chuj(iii,jjj,kk,k)
9555 call transpose2(aa1(1,1),aa1t(1,1))
9556 call transpose2(aa2(1,1),aa2t(1,1))
9559 call transpose2(a_chuj_der(1,1,lll,kkk,jj,i),&
9560 aa1tder(1,1,lll,kkk))
9561 call transpose2(a_chuj_der(1,1,lll,kkk,kk,k),&
9562 aa2tder(1,1,lll,kkk))
9566 ! parallel orientation of the two CA-CA-CA frames.
9568 iti=itortyp(itype(i,1))
9572 itk1=itortyp(itype(k+1,1))
9573 itj=itortyp(itype(j,1))
9574 if (l.lt.nres-1) then
9575 itl1=itortyp(itype(l+1,1))
9579 ! A1 kernel(j+1) A2T
9581 !d write (iout,'(3f10.5,5x,3f10.5)')
9582 !d & (EUg(iii,jjj,k),jjj=1,2),(EUg(iii,jjj,l),jjj=1,2)
9584 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
9585 aa2tder(1,1,1,1),1,.false.,EUg(1,1,l),EUgder(1,1,l),&
9586 AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
9587 ! Following matrices are needed only for 6-th order cumulants
9588 IF (wcorr6.gt.0.0d0) THEN
9589 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
9590 aa2tder(1,1,1,1),1,.false.,EUgC(1,1,l),EUgCder(1,1,l),&
9591 AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
9592 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
9593 aa2tder(1,1,1,1),2,.false.,Ug2DtEUg(1,1,l),&
9594 Ug2DtEUgder(1,1,1,l),ADtEA(1,1,1),ADtEAderg(1,1,1,1),&
9595 ADtEAderx(1,1,1,1,1,1))
9597 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
9598 aa2tder(1,1,1,1),2,.false.,DtUg2EUg(1,1,l),&
9599 DtUg2EUgder(1,1,1,l),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),&
9600 ADtEA1derx(1,1,1,1,1,1))
9602 ! End 6-th order cumulants
9605 !d write (2,*) 'In calc_eello6'
9607 !d write (2,*) 'iii=',iii
9609 !d write (2,*) 'kkk=',kkk
9611 !d write (2,'(3(2f10.5),5x)')
9612 !d & ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
9617 call transpose2(EUgder(1,1,k),auxmat(1,1))
9618 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
9619 call transpose2(EUg(1,1,k),auxmat(1,1))
9620 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
9621 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
9625 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),&
9626 EAEAderx(1,1,lll,kkk,iii,1))
9630 ! A1T kernel(i+1) A2
9631 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
9632 a_chuj_der(1,1,1,1,kk,k),1,.false.,EUg(1,1,k),EUgder(1,1,k),&
9633 AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
9634 ! Following matrices are needed only for 6-th order cumulants
9635 IF (wcorr6.gt.0.0d0) THEN
9636 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
9637 a_chuj_der(1,1,1,1,kk,k),1,.false.,EUgC(1,1,k),EUgCder(1,1,k),&
9638 AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
9639 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
9640 a_chuj_der(1,1,1,1,kk,k),2,.false.,Ug2DtEUg(1,1,k),&
9641 Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),&
9642 ADtEAderx(1,1,1,1,1,2))
9643 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
9644 a_chuj_der(1,1,1,1,kk,k),2,.false.,DtUg2EUg(1,1,k),&
9645 DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),&
9646 ADtEA1derx(1,1,1,1,1,2))
9648 ! End 6-th order cumulants
9649 call transpose2(EUgder(1,1,l),auxmat(1,1))
9650 call matmat2(auxmat(1,1),AEA(1,1,2),EAEAderg(1,1,1,2))
9651 call transpose2(EUg(1,1,l),auxmat(1,1))
9652 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
9653 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
9657 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
9658 EAEAderx(1,1,lll,kkk,iii,2))
9663 ! Calculate the vectors and their derivatives in virtual-bond dihedral angles.
9664 ! They are needed only when the fifth- or the sixth-order cumulants are
9666 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) THEN
9667 call transpose2(AEA(1,1,1),auxmat(1,1))
9668 call matvec2(auxmat(1,1),b1(1,iti),AEAb1(1,1,1))
9669 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
9670 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
9671 call transpose2(AEAderg(1,1,1),auxmat(1,1))
9672 call matvec2(auxmat(1,1),b1(1,iti),AEAb1derg(1,1,1))
9673 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
9674 call matvec2(AEA(1,1,1),b1(1,itk1),AEAb1(1,2,1))
9675 call matvec2(AEAderg(1,1,1),b1(1,itk1),AEAb1derg(1,2,1))
9676 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
9677 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
9678 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
9679 call transpose2(AEA(1,1,2),auxmat(1,1))
9680 call matvec2(auxmat(1,1),b1(1,itj),AEAb1(1,1,2))
9681 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2(1,1,2))
9682 call matvec2(auxmat(1,1),Ub2der(1,j),AEAb2derg(1,2,1,2))
9683 call transpose2(AEAderg(1,1,2),auxmat(1,1))
9684 call matvec2(auxmat(1,1),b1(1,itj),AEAb1derg(1,1,2))
9685 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2derg(1,1,1,2))
9686 call matvec2(AEA(1,1,2),b1(1,itl1),AEAb1(1,2,2))
9687 call matvec2(AEAderg(1,1,2),b1(1,itl1),AEAb1derg(1,2,2))
9688 call matvec2(AEA(1,1,2),Ub2(1,l+1),AEAb2(1,2,2))
9689 call matvec2(AEAderg(1,1,2),Ub2(1,l+1),AEAb2derg(1,1,2,2))
9690 call matvec2(AEA(1,1,2),Ub2der(1,l+1),AEAb2derg(1,2,2,2))
9691 ! Calculate the Cartesian derivatives of the vectors.
9695 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
9696 call matvec2(auxmat(1,1),b1(1,iti),&
9697 AEAb1derx(1,lll,kkk,iii,1,1))
9698 call matvec2(auxmat(1,1),Ub2(1,i),&
9699 AEAb2derx(1,lll,kkk,iii,1,1))
9700 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,itk1),&
9701 AEAb1derx(1,lll,kkk,iii,2,1))
9702 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),&
9703 AEAb2derx(1,lll,kkk,iii,2,1))
9704 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
9705 call matvec2(auxmat(1,1),b1(1,itj),&
9706 AEAb1derx(1,lll,kkk,iii,1,2))
9707 call matvec2(auxmat(1,1),Ub2(1,j),&
9708 AEAb2derx(1,lll,kkk,iii,1,2))
9709 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,itl1),&
9710 AEAb1derx(1,lll,kkk,iii,2,2))
9711 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,l+1),&
9712 AEAb2derx(1,lll,kkk,iii,2,2))
9719 ! Antiparallel orientation of the two CA-CA-CA frames.
9721 iti=itortyp(itype(i,1))
9725 itk1=itortyp(itype(k+1,1))
9726 itl=itortyp(itype(l,1))
9727 itj=itortyp(itype(j,1))
9728 if (j.lt.nres-1) then
9729 itj1=itortyp(itype(j+1,1))
9733 ! A2 kernel(j-1)T A1T
9734 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
9735 aa2tder(1,1,1,1),1,.true.,EUg(1,1,j),EUgder(1,1,j),&
9736 AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
9737 ! Following matrices are needed only for 6-th order cumulants
9738 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and. &
9739 j.eq.i+4 .and. l.eq.i+3)) THEN
9740 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
9741 aa2tder(1,1,1,1),1,.true.,EUgC(1,1,j),EUgCder(1,1,j),&
9742 AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
9743 call kernel(aa2(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
9744 aa2tder(1,1,1,1),2,.true.,Ug2DtEUg(1,1,j),&
9745 Ug2DtEUgder(1,1,1,j),ADtEA(1,1,1),ADtEAderg(1,1,1,1),&
9746 ADtEAderx(1,1,1,1,1,1))
9747 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
9748 aa2tder(1,1,1,1),2,.true.,DtUg2EUg(1,1,j),&
9749 DtUg2EUgder(1,1,1,j),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),&
9750 ADtEA1derx(1,1,1,1,1,1))
9752 ! End 6-th order cumulants
9753 call transpose2(EUgder(1,1,k),auxmat(1,1))
9754 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
9755 call transpose2(EUg(1,1,k),auxmat(1,1))
9756 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
9757 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
9761 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),&
9762 EAEAderx(1,1,lll,kkk,iii,1))
9766 ! A2T kernel(i+1)T A1
9767 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
9768 a_chuj_der(1,1,1,1,jj,i),1,.true.,EUg(1,1,k),EUgder(1,1,k),&
9769 AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
9770 ! Following matrices are needed only for 6-th order cumulants
9771 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and. &
9772 j.eq.i+4 .and. l.eq.i+3)) THEN
9773 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
9774 a_chuj_der(1,1,1,1,jj,i),1,.true.,EUgC(1,1,k),EUgCder(1,1,k),&
9775 AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
9776 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
9777 a_chuj_der(1,1,1,1,jj,i),2,.true.,Ug2DtEUg(1,1,k),&
9778 Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),&
9779 ADtEAderx(1,1,1,1,1,2))
9780 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
9781 a_chuj_der(1,1,1,1,jj,i),2,.true.,DtUg2EUg(1,1,k),&
9782 DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),&
9783 ADtEA1derx(1,1,1,1,1,2))
9785 ! End 6-th order cumulants
9786 call transpose2(EUgder(1,1,j),auxmat(1,1))
9787 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,2,2))
9788 call transpose2(EUg(1,1,j),auxmat(1,1))
9789 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
9790 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
9794 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
9795 EAEAderx(1,1,lll,kkk,iii,2))
9800 ! Calculate the vectors and their derivatives in virtual-bond dihedral angles.
9801 ! They are needed only when the fifth- or the sixth-order cumulants are
9803 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 .or. &
9804 (wturn6.gt.0.0d0 .and. j.eq.i+4 .and. l.eq.i+3)) THEN
9805 call transpose2(AEA(1,1,1),auxmat(1,1))
9806 call matvec2(auxmat(1,1),b1(1,iti),AEAb1(1,1,1))
9807 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
9808 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
9809 call transpose2(AEAderg(1,1,1),auxmat(1,1))
9810 call matvec2(auxmat(1,1),b1(1,iti),AEAb1derg(1,1,1))
9811 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
9812 call matvec2(AEA(1,1,1),b1(1,itk1),AEAb1(1,2,1))
9813 call matvec2(AEAderg(1,1,1),b1(1,itk1),AEAb1derg(1,2,1))
9814 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
9815 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
9816 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
9817 call transpose2(AEA(1,1,2),auxmat(1,1))
9818 call matvec2(auxmat(1,1),b1(1,itj1),AEAb1(1,1,2))
9819 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2(1,1,2))
9820 call matvec2(auxmat(1,1),Ub2der(1,l),AEAb2derg(1,2,1,2))
9821 call transpose2(AEAderg(1,1,2),auxmat(1,1))
9822 call matvec2(auxmat(1,1),b1(1,itl),AEAb1(1,1,2))
9823 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2derg(1,1,1,2))
9824 call matvec2(AEA(1,1,2),b1(1,itj1),AEAb1(1,2,2))
9825 call matvec2(AEAderg(1,1,2),b1(1,itj1),AEAb1derg(1,2,2))
9826 call matvec2(AEA(1,1,2),Ub2(1,j),AEAb2(1,2,2))
9827 call matvec2(AEAderg(1,1,2),Ub2(1,j),AEAb2derg(1,1,2,2))
9828 call matvec2(AEA(1,1,2),Ub2der(1,j),AEAb2derg(1,2,2,2))
9829 ! Calculate the Cartesian derivatives of the vectors.
9833 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
9834 call matvec2(auxmat(1,1),b1(1,iti),&
9835 AEAb1derx(1,lll,kkk,iii,1,1))
9836 call matvec2(auxmat(1,1),Ub2(1,i),&
9837 AEAb2derx(1,lll,kkk,iii,1,1))
9838 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,itk1),&
9839 AEAb1derx(1,lll,kkk,iii,2,1))
9840 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),&
9841 AEAb2derx(1,lll,kkk,iii,2,1))
9842 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
9843 call matvec2(auxmat(1,1),b1(1,itl),&
9844 AEAb1derx(1,lll,kkk,iii,1,2))
9845 call matvec2(auxmat(1,1),Ub2(1,l),&
9846 AEAb2derx(1,lll,kkk,iii,1,2))
9847 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,itj1),&
9848 AEAb1derx(1,lll,kkk,iii,2,2))
9849 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,j),&
9850 AEAb2derx(1,lll,kkk,iii,2,2))
9858 end subroutine calc_eello
9859 !-----------------------------------------------------------------------------
9860 subroutine kernel(aa1,aa2t,aa1derx,aa2tderx,nderg,transp,KK,KKderg,AKA,AKAderg,AKAderx)
9865 real(kind=8),dimension(2,2) :: aa1,aa2t,KK,AKA
9866 real(kind=8),dimension(2,2,3,5) :: aa1derx,aa2tderx
9867 real(kind=8),dimension(2,2,3,5,2) :: AKAderx
9868 real(kind=8),dimension(2,2,nderg) :: KKderg,AKAderg
9869 integer :: iii,kkk,lll
9872 !el common /kutas/ lprn
9873 call prodmat3(aa1(1,1),aa2t(1,1),KK(1,1),transp,AKA(1,1))
9875 call prodmat3(aa1(1,1),aa2t(1,1),KKderg(1,1,iii),transp,&
9878 !d if (lprn) write (2,*) 'In kernel'
9880 !d if (lprn) write (2,*) 'kkk=',kkk
9882 call prodmat3(aa1derx(1,1,lll,kkk),aa2t(1,1),&
9883 KK(1,1),transp,AKAderx(1,1,lll,kkk,1))
9885 !d write (2,*) 'lll=',lll
9886 !d write (2,*) 'iii=1'
9888 !d write (2,'(3(2f10.5),5x)')
9889 !d & (AKAderx(jjj,mmm,lll,kkk,1),mmm=1,2)
9892 call prodmat3(aa1(1,1),aa2tderx(1,1,lll,kkk),&
9893 KK(1,1),transp,AKAderx(1,1,lll,kkk,2))
9895 !d write (2,*) 'lll=',lll
9896 !d write (2,*) 'iii=2'
9898 !d write (2,'(3(2f10.5),5x)')
9899 !d & (AKAderx(jjj,mmm,lll,kkk,2),mmm=1,2)
9905 end subroutine kernel
9906 !-----------------------------------------------------------------------------
9907 real(kind=8) function eello4(i,j,k,l,jj,kk)
9908 ! implicit real*8 (a-h,o-z)
9909 ! include 'DIMENSIONS'
9910 ! include 'COMMON.IOUNITS'
9911 ! include 'COMMON.CHAIN'
9912 ! include 'COMMON.DERIV'
9913 ! include 'COMMON.INTERACT'
9914 ! include 'COMMON.CONTACTS'
9915 ! include 'COMMON.TORSION'
9916 ! include 'COMMON.VAR'
9917 ! include 'COMMON.GEO'
9918 real(kind=8),dimension(2,2) :: pizda
9919 real(kind=8),dimension(3) :: ggg1,ggg2
9920 real(kind=8) :: eel4,glongij,glongkl
9921 integer :: i,j,k,l,jj,kk,iii,kkk,lll,j1,j2,l1,l2,ll
9922 !d if (i.ne.1 .or. j.ne.5 .or. k.ne.2 .or.l.ne.4) then
9926 !d print *,'eello4:',i,j,k,l,jj,kk
9927 !d write (2,*) 'i',i,' j',j,' k',k,' l',l
9928 !d call checkint4(i,j,k,l,jj,kk,eel4_num)
9929 !old eij=facont_hb(jj,i)
9930 !old ekl=facont_hb(kk,k)
9932 eel4=-EAEA(1,1,1)-EAEA(2,2,1)
9933 !d eel41=-EAEA(1,1,2)-EAEA(2,2,2)
9934 gcorr_loc(k-1)=gcorr_loc(k-1) &
9935 -ekont*(EAEAderg(1,1,1,1)+EAEAderg(2,2,1,1))
9937 gcorr_loc(l-1)=gcorr_loc(l-1) &
9938 -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
9940 gcorr_loc(j-1)=gcorr_loc(j-1) &
9941 -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
9946 derx(lll,kkk,iii)=-EAEAderx(1,1,lll,kkk,iii,1) &
9947 -EAEAderx(2,2,lll,kkk,iii,1)
9948 !d derx(lll,kkk,iii)=0.0d0
9952 !d gcorr_loc(l-1)=0.0d0
9953 !d gcorr_loc(j-1)=0.0d0
9954 !d gcorr_loc(k-1)=0.0d0
9956 !d write (iout,*)'Contacts have occurred for peptide groups',
9957 !d & i,j,' fcont:',eij,' eij',' and ',k,l,
9958 !d & ' fcont ',ekl,' eel4=',eel4,' eel4_num',16*eel4_num
9959 if (j.lt.nres-1) then
9966 if (l.lt.nres-1) then
9974 !grad ggg1(ll)=eel4*g_contij(ll,1)
9975 !grad ggg2(ll)=eel4*g_contij(ll,2)
9976 glongij=eel4*g_contij(ll,1)+ekont*derx(ll,1,1)
9977 glongkl=eel4*g_contij(ll,2)+ekont*derx(ll,1,2)
9978 !grad ghalf=0.5d0*ggg1(ll)
9979 gradcorr(ll,i)=gradcorr(ll,i)+ekont*derx(ll,2,1)
9980 gradcorr(ll,i+1)=gradcorr(ll,i+1)+ekont*derx(ll,3,1)
9981 gradcorr(ll,j)=gradcorr(ll,j)+ekont*derx(ll,4,1)
9982 gradcorr(ll,j1)=gradcorr(ll,j1)+ekont*derx(ll,5,1)
9983 gradcorr_long(ll,j)=gradcorr_long(ll,j)+glongij
9984 gradcorr_long(ll,i)=gradcorr_long(ll,i)-glongij
9985 !grad ghalf=0.5d0*ggg2(ll)
9986 gradcorr(ll,k)=gradcorr(ll,k)+ekont*derx(ll,2,2)
9987 gradcorr(ll,k+1)=gradcorr(ll,k+1)+ekont*derx(ll,3,2)
9988 gradcorr(ll,l)=gradcorr(ll,l)+ekont*derx(ll,4,2)
9989 gradcorr(ll,l1)=gradcorr(ll,l1)+ekont*derx(ll,5,2)
9990 gradcorr_long(ll,l)=gradcorr_long(ll,l)+glongkl
9991 gradcorr_long(ll,k)=gradcorr_long(ll,k)-glongkl
9995 !grad gradcorr(ll,m)=gradcorr(ll,m)+ggg1(ll)
10000 !grad gradcorr(ll,m)=gradcorr(ll,m)+ggg2(ll)
10005 !grad gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,1)
10010 !grad gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,2)
10014 !d write (2,*) iii,gcorr_loc(iii)
10017 !d write (2,*) 'ekont',ekont
10018 !d write (iout,*) 'eello4',ekont*eel4
10020 end function eello4
10021 !-----------------------------------------------------------------------------
10022 real(kind=8) function eello5(i,j,k,l,jj,kk)
10023 ! implicit real*8 (a-h,o-z)
10024 ! include 'DIMENSIONS'
10025 ! include 'COMMON.IOUNITS'
10026 ! include 'COMMON.CHAIN'
10027 ! include 'COMMON.DERIV'
10028 ! include 'COMMON.INTERACT'
10029 ! include 'COMMON.CONTACTS'
10030 ! include 'COMMON.TORSION'
10031 ! include 'COMMON.VAR'
10032 ! include 'COMMON.GEO'
10033 real(kind=8),dimension(2,2) :: pizda,auxmat,auxmat1
10034 real(kind=8),dimension(2) :: vv
10035 real(kind=8),dimension(3) :: ggg1,ggg2
10036 real(kind=8) :: eello5_1,eello5_2,eello5_3,eello5_4,eel5
10037 real(kind=8) :: gradcorr5ij,gradcorr5kl,ghalf
10038 integer :: i,j,k,l,jj,kk,itk,itl,itj,iii,kkk,lll,j1,j2,l1,l2,ll
10039 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
10041 ! Parallel chains C
10044 ! /l\ / \ \ / \ / \ / C
10045 ! / \ / \ \ / \ / \ / C
10046 ! j| o |l1 | o | o| o | | o |o C
10047 ! \ |/k\| |/ \| / |/ \| |/ \| C
10048 ! \i/ \ / \ / / \ / \ C
10050 ! (I) (II) (III) (IV) C
10052 ! eello5_1 eello5_2 eello5_3 eello5_4 C
10054 ! Antiparallel chains C
10057 ! /j\ / \ \ / \ / \ / C
10058 ! / \ / \ \ / \ / \ / C
10059 ! j1| o |l | o | o| o | | o |o C
10060 ! \ |/k\| |/ \| / |/ \| |/ \| C
10061 ! \i/ \ / \ / / \ / \ C
10063 ! (I) (II) (III) (IV) C
10065 ! eello5_1 eello5_2 eello5_3 eello5_4 C
10067 ! o denotes a local interaction, vertical lines an electrostatic interaction. C
10069 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
10070 !d if (i.ne.2 .or. j.ne.6 .or. k.ne.3 .or. l.ne.5) then
10075 !d & 'EELLO5: Contacts have occurred for peptide groups',i,j,
10077 itk=itortyp(itype(k,1))
10078 itl=itortyp(itype(l,1))
10079 itj=itortyp(itype(j,1))
10084 !d call checkint5(i,j,k,l,jj,kk,eel5_1_num,eel5_2_num,
10085 !d & eel5_3_num,eel5_4_num)
10089 derx(lll,kkk,iii)=0.0d0
10093 !d eij=facont_hb(jj,i)
10094 !d ekl=facont_hb(kk,k)
10096 !d write (iout,*)'Contacts have occurred for peptide groups',
10097 !d & i,j,' fcont:',eij,' eij',' and ',k,l
10099 ! Contribution from the graph I.
10100 !d write (2,*) 'AEA ',AEA(1,1,1),AEA(2,1,1),AEA(1,2,1),AEA(2,2,1)
10101 !d write (2,*) 'AEAb2',AEAb2(1,1,1),AEAb2(2,1,1)
10102 call transpose2(EUg(1,1,k),auxmat(1,1))
10103 call matmat2(AEA(1,1,1),auxmat(1,1),pizda(1,1))
10104 vv(1)=pizda(1,1)-pizda(2,2)
10105 vv(2)=pizda(1,2)+pizda(2,1)
10106 eello5_1=scalar2(AEAb2(1,1,1),Ub2(1,k)) &
10107 +0.5d0*scalar2(vv(1),Dtobr2(1,i))
10108 ! Explicit gradient in virtual-dihedral angles.
10109 if (i.gt.1) g_corr5_loc(i-1)=g_corr5_loc(i-1) &
10110 +ekont*(scalar2(AEAb2derg(1,2,1,1),Ub2(1,k)) &
10111 +0.5d0*scalar2(vv(1),Dtobr2der(1,i)))
10112 call transpose2(EUgder(1,1,k),auxmat1(1,1))
10113 call matmat2(AEA(1,1,1),auxmat1(1,1),pizda(1,1))
10114 vv(1)=pizda(1,1)-pizda(2,2)
10115 vv(2)=pizda(1,2)+pizda(2,1)
10116 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
10117 +ekont*(scalar2(AEAb2(1,1,1),Ub2der(1,k)) &
10118 +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
10119 call matmat2(AEAderg(1,1,1),auxmat(1,1),pizda(1,1))
10120 vv(1)=pizda(1,1)-pizda(2,2)
10121 vv(2)=pizda(1,2)+pizda(2,1)
10123 if (l.lt.nres-1) g_corr5_loc(l-1)=g_corr5_loc(l-1) &
10124 +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k)) &
10125 +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
10127 if (j.lt.nres-1) g_corr5_loc(j-1)=g_corr5_loc(j-1) &
10128 +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k)) &
10129 +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
10131 ! Cartesian gradient
10135 call matmat2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1),&
10137 vv(1)=pizda(1,1)-pizda(2,2)
10138 vv(2)=pizda(1,2)+pizda(2,1)
10139 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
10140 +scalar2(AEAb2derx(1,lll,kkk,iii,1,1),Ub2(1,k)) &
10141 +0.5d0*scalar2(vv(1),Dtobr2(1,i))
10147 ! Contribution from graph II
10148 call transpose2(EE(1,1,itk),auxmat(1,1))
10149 call matmat2(auxmat(1,1),AEA(1,1,1),pizda(1,1))
10150 vv(1)=pizda(1,1)+pizda(2,2)
10151 vv(2)=pizda(2,1)-pizda(1,2)
10152 eello5_2=scalar2(AEAb1(1,2,1),b1(1,itk)) &
10153 -0.5d0*scalar2(vv(1),Ctobr(1,k))
10154 ! Explicit gradient in virtual-dihedral angles.
10155 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
10156 -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,k))
10157 call matmat2(auxmat(1,1),AEAderg(1,1,1),pizda(1,1))
10158 vv(1)=pizda(1,1)+pizda(2,2)
10159 vv(2)=pizda(2,1)-pizda(1,2)
10161 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
10162 +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,itk)) &
10163 -0.5d0*scalar2(vv(1),Ctobr(1,k)))
10165 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
10166 +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,itk)) &
10167 -0.5d0*scalar2(vv(1),Ctobr(1,k)))
10169 ! Cartesian gradient
10173 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),&
10175 vv(1)=pizda(1,1)+pizda(2,2)
10176 vv(2)=pizda(2,1)-pizda(1,2)
10177 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
10178 +scalar2(AEAb1derx(1,lll,kkk,iii,2,1),b1(1,itk)) &
10179 -0.5d0*scalar2(vv(1),Ctobr(1,k))
10187 ! Parallel orientation
10188 ! Contribution from graph III
10189 call transpose2(EUg(1,1,l),auxmat(1,1))
10190 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
10191 vv(1)=pizda(1,1)-pizda(2,2)
10192 vv(2)=pizda(1,2)+pizda(2,1)
10193 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,l)) &
10194 +0.5d0*scalar2(vv(1),Dtobr2(1,j))
10195 ! Explicit gradient in virtual-dihedral angles.
10196 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
10197 +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,l)) &
10198 +0.5d0*scalar2(vv(1),Dtobr2der(1,j)))
10199 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
10200 vv(1)=pizda(1,1)-pizda(2,2)
10201 vv(2)=pizda(1,2)+pizda(2,1)
10202 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
10203 +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,l)) &
10204 +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
10205 call transpose2(EUgder(1,1,l),auxmat1(1,1))
10206 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
10207 vv(1)=pizda(1,1)-pizda(2,2)
10208 vv(2)=pizda(1,2)+pizda(2,1)
10209 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
10210 +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,l)) &
10211 +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
10212 ! Cartesian gradient
10216 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),&
10218 vv(1)=pizda(1,1)-pizda(2,2)
10219 vv(2)=pizda(1,2)+pizda(2,1)
10220 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
10221 +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,l)) &
10222 +0.5d0*scalar2(vv(1),Dtobr2(1,j))
10227 ! Contribution from graph IV
10229 call transpose2(EE(1,1,itl),auxmat(1,1))
10230 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
10231 vv(1)=pizda(1,1)+pizda(2,2)
10232 vv(2)=pizda(2,1)-pizda(1,2)
10233 eello5_4=scalar2(AEAb1(1,2,2),b1(1,itl)) &
10234 -0.5d0*scalar2(vv(1),Ctobr(1,l))
10235 ! Explicit gradient in virtual-dihedral angles.
10236 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
10237 -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,l))
10238 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
10239 vv(1)=pizda(1,1)+pizda(2,2)
10240 vv(2)=pizda(2,1)-pizda(1,2)
10241 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
10242 +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,itl)) &
10243 -0.5d0*scalar2(vv(1),Ctobr(1,l)))
10244 ! Cartesian gradient
10248 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
10250 vv(1)=pizda(1,1)+pizda(2,2)
10251 vv(2)=pizda(2,1)-pizda(1,2)
10252 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
10253 +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,itl)) &
10254 -0.5d0*scalar2(vv(1),Ctobr(1,l))
10259 ! Antiparallel orientation
10260 ! Contribution from graph III
10262 call transpose2(EUg(1,1,j),auxmat(1,1))
10263 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
10264 vv(1)=pizda(1,1)-pizda(2,2)
10265 vv(2)=pizda(1,2)+pizda(2,1)
10266 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,j)) &
10267 +0.5d0*scalar2(vv(1),Dtobr2(1,l))
10268 ! Explicit gradient in virtual-dihedral angles.
10269 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
10270 +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,j)) &
10271 +0.5d0*scalar2(vv(1),Dtobr2der(1,l)))
10272 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
10273 vv(1)=pizda(1,1)-pizda(2,2)
10274 vv(2)=pizda(1,2)+pizda(2,1)
10275 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
10276 +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,j)) &
10277 +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
10278 call transpose2(EUgder(1,1,j),auxmat1(1,1))
10279 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
10280 vv(1)=pizda(1,1)-pizda(2,2)
10281 vv(2)=pizda(1,2)+pizda(2,1)
10282 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
10283 +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,j)) &
10284 +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
10285 ! Cartesian gradient
10289 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),&
10291 vv(1)=pizda(1,1)-pizda(2,2)
10292 vv(2)=pizda(1,2)+pizda(2,1)
10293 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii) &
10294 +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,j)) &
10295 +0.5d0*scalar2(vv(1),Dtobr2(1,l))
10300 ! Contribution from graph IV
10302 call transpose2(EE(1,1,itj),auxmat(1,1))
10303 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
10304 vv(1)=pizda(1,1)+pizda(2,2)
10305 vv(2)=pizda(2,1)-pizda(1,2)
10306 eello5_4=scalar2(AEAb1(1,2,2),b1(1,itj)) &
10307 -0.5d0*scalar2(vv(1),Ctobr(1,j))
10308 ! Explicit gradient in virtual-dihedral angles.
10309 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
10310 -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,j))
10311 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
10312 vv(1)=pizda(1,1)+pizda(2,2)
10313 vv(2)=pizda(2,1)-pizda(1,2)
10314 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
10315 +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,itj)) &
10316 -0.5d0*scalar2(vv(1),Ctobr(1,j)))
10317 ! Cartesian gradient
10321 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
10323 vv(1)=pizda(1,1)+pizda(2,2)
10324 vv(2)=pizda(2,1)-pizda(1,2)
10325 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii) &
10326 +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,itj)) &
10327 -0.5d0*scalar2(vv(1),Ctobr(1,j))
10333 eel5=eello5_1+eello5_2+eello5_3+eello5_4
10334 !d if (i.eq.2 .and. j.eq.8 .and. k.eq.3 .and. l.eq.7) then
10335 !d write (2,*) 'ijkl',i,j,k,l
10336 !d write (2,*) 'eello5_1',eello5_1,' eello5_2',eello5_2,
10337 !d & ' eello5_3',eello5_3,' eello5_4',eello5_4
10339 !d write(iout,*) 'eello5_1',eello5_1,' eel5_1_num',16*eel5_1_num
10340 !d write(iout,*) 'eello5_2',eello5_2,' eel5_2_num',16*eel5_2_num
10341 !d write(iout,*) 'eello5_3',eello5_3,' eel5_3_num',16*eel5_3_num
10342 !d write(iout,*) 'eello5_4',eello5_4,' eel5_4_num',16*eel5_4_num
10343 if (j.lt.nres-1) then
10350 if (l.lt.nres-1) then
10360 !d write (2,*) 'eij',eij,' ekl',ekl,' ekont',ekont
10361 ! 2/11/08 AL Gradients over DC's connecting interacting sites will be
10362 ! summed up outside the subrouine as for the other subroutines
10363 ! handling long-range interactions. The old code is commented out
10364 ! with "cgrad" to keep track of changes.
10366 !grad ggg1(ll)=eel5*g_contij(ll,1)
10367 !grad ggg2(ll)=eel5*g_contij(ll,2)
10368 gradcorr5ij=eel5*g_contij(ll,1)+ekont*derx(ll,1,1)
10369 gradcorr5kl=eel5*g_contij(ll,2)+ekont*derx(ll,1,2)
10370 ! write (iout,'(a,3i3,a,5f8.3,2i3,a,5f8.3,a,f8.3)')
10371 ! & "ecorr5",ll,i,j," derx",derx(ll,2,1),derx(ll,3,1),derx(ll,4,1),
10372 ! & derx(ll,5,1),k,l," derx",derx(ll,2,2),derx(ll,3,2),
10373 ! & derx(ll,4,2),derx(ll,5,2)," ekont",ekont
10374 ! write (iout,'(a,3i3,a,3f8.3,2i3,a,3f8.3)')
10375 ! & "ecorr5",ll,i,j," gradcorr5",g_contij(ll,1),derx(ll,1,1),
10377 ! & k,l," gradcorr5",g_contij(ll,2),derx(ll,1,2),gradcorr5kl
10378 !old ghalf=0.5d0*eel5*ekl*gacont_hbr(ll,jj,i)
10379 !grad ghalf=0.5d0*ggg1(ll)
10381 gradcorr5(ll,i)=gradcorr5(ll,i)+ekont*derx(ll,2,1)
10382 gradcorr5(ll,i+1)=gradcorr5(ll,i+1)+ekont*derx(ll,3,1)
10383 gradcorr5(ll,j)=gradcorr5(ll,j)+ekont*derx(ll,4,1)
10384 gradcorr5(ll,j1)=gradcorr5(ll,j1)+ekont*derx(ll,5,1)
10385 gradcorr5_long(ll,j)=gradcorr5_long(ll,j)+gradcorr5ij
10386 gradcorr5_long(ll,i)=gradcorr5_long(ll,i)-gradcorr5ij
10387 !old ghalf=0.5d0*eel5*eij*gacont_hbr(ll,kk,k)
10388 !grad ghalf=0.5d0*ggg2(ll)
10390 gradcorr5(ll,k)=gradcorr5(ll,k)+ghalf+ekont*derx(ll,2,2)
10391 gradcorr5(ll,k+1)=gradcorr5(ll,k+1)+ekont*derx(ll,3,2)
10392 gradcorr5(ll,l)=gradcorr5(ll,l)+ghalf+ekont*derx(ll,4,2)
10393 gradcorr5(ll,l1)=gradcorr5(ll,l1)+ekont*derx(ll,5,2)
10394 gradcorr5_long(ll,l)=gradcorr5_long(ll,l)+gradcorr5kl
10395 gradcorr5_long(ll,k)=gradcorr5_long(ll,k)-gradcorr5kl
10400 !old gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*ekl*gacont_hbr(ll,jj,i)
10401 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ggg1(ll)
10406 !old gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*eij*gacont_hbr(ll,kk,k)
10407 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ggg2(ll)
10413 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,1)
10418 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,2)
10422 !d write (2,*) iii,g_corr5_loc(iii)
10425 !d write (2,*) 'ekont',ekont
10426 !d write (iout,*) 'eello5',ekont*eel5
10428 end function eello5
10429 !-----------------------------------------------------------------------------
10430 real(kind=8) function eello6(i,j,k,l,jj,kk)
10431 ! implicit real*8 (a-h,o-z)
10432 ! include 'DIMENSIONS'
10433 ! include 'COMMON.IOUNITS'
10434 ! include 'COMMON.CHAIN'
10435 ! include 'COMMON.DERIV'
10436 ! include 'COMMON.INTERACT'
10437 ! include 'COMMON.CONTACTS'
10438 ! include 'COMMON.TORSION'
10439 ! include 'COMMON.VAR'
10440 ! include 'COMMON.GEO'
10441 ! include 'COMMON.FFIELD'
10442 real(kind=8),dimension(3) :: ggg1,ggg2
10443 real(kind=8) :: eello6_1,eello6_2,eello6_3,eello6_4,eello6_5,&
10445 real(kind=8) :: gradcorr6ij,gradcorr6kl
10446 integer :: i,j,k,l,jj,kk,iii,kkk,lll,j1,j2,l1,l2,ll
10447 !d if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
10452 !d & 'EELLO6: Contacts have occurred for peptide groups',i,j,
10460 !d call checkint6(i,j,k,l,jj,kk,eel6_1_num,eel6_2_num,
10461 !d & eel6_3_num,eel6_4_num,eel6_5_num,eel6_6_num)
10465 derx(lll,kkk,iii)=0.0d0
10469 !d eij=facont_hb(jj,i)
10470 !d ekl=facont_hb(kk,k)
10476 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
10477 eello6_2=eello6_graph1(j,i,l,k,2,.false.)
10478 eello6_3=eello6_graph2(i,j,k,l,jj,kk,.false.)
10479 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
10480 eello6_5=eello6_graph4(j,i,l,k,jj,kk,2,.false.)
10481 eello6_6=eello6_graph3(i,j,k,l,jj,kk,.false.)
10483 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
10484 eello6_2=eello6_graph1(l,k,j,i,2,.true.)
10485 eello6_3=eello6_graph2(i,l,k,j,jj,kk,.true.)
10486 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
10487 if (wturn6.eq.0.0d0 .or. j.ne.i+4) then
10488 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
10492 eello6_6=eello6_graph3(i,l,k,j,jj,kk,.true.)
10494 ! If turn contributions are considered, they will be handled separately.
10495 eel6=eello6_1+eello6_2+eello6_3+eello6_4+eello6_5+eello6_6
10496 !d write(iout,*) 'eello6_1',eello6_1!,' eel6_1_num',16*eel6_1_num
10497 !d write(iout,*) 'eello6_2',eello6_2!,' eel6_2_num',16*eel6_2_num
10498 !d write(iout,*) 'eello6_3',eello6_3!,' eel6_3_num',16*eel6_3_num
10499 !d write(iout,*) 'eello6_4',eello6_4!,' eel6_4_num',16*eel6_4_num
10500 !d write(iout,*) 'eello6_5',eello6_5!,' eel6_5_num',16*eel6_5_num
10501 !d write(iout,*) 'eello6_6',eello6_6!,' eel6_6_num',16*eel6_6_num
10503 if (j.lt.nres-1) then
10510 if (l.lt.nres-1) then
10518 !grad ggg1(ll)=eel6*g_contij(ll,1)
10519 !grad ggg2(ll)=eel6*g_contij(ll,2)
10520 !old ghalf=0.5d0*eel6*ekl*gacont_hbr(ll,jj,i)
10521 !grad ghalf=0.5d0*ggg1(ll)
10523 gradcorr6ij=eel6*g_contij(ll,1)+ekont*derx(ll,1,1)
10524 gradcorr6kl=eel6*g_contij(ll,2)+ekont*derx(ll,1,2)
10525 gradcorr6(ll,i)=gradcorr6(ll,i)+ekont*derx(ll,2,1)
10526 gradcorr6(ll,i+1)=gradcorr6(ll,i+1)+ekont*derx(ll,3,1)
10527 gradcorr6(ll,j)=gradcorr6(ll,j)+ekont*derx(ll,4,1)
10528 gradcorr6(ll,j1)=gradcorr6(ll,j1)+ekont*derx(ll,5,1)
10529 gradcorr6_long(ll,j)=gradcorr6_long(ll,j)+gradcorr6ij
10530 gradcorr6_long(ll,i)=gradcorr6_long(ll,i)-gradcorr6ij
10531 !grad ghalf=0.5d0*ggg2(ll)
10532 !old ghalf=0.5d0*eel6*eij*gacont_hbr(ll,kk,k)
10534 gradcorr6(ll,k)=gradcorr6(ll,k)+ekont*derx(ll,2,2)
10535 gradcorr6(ll,k+1)=gradcorr6(ll,k+1)+ekont*derx(ll,3,2)
10536 gradcorr6(ll,l)=gradcorr6(ll,l)+ekont*derx(ll,4,2)
10537 gradcorr6(ll,l1)=gradcorr6(ll,l1)+ekont*derx(ll,5,2)
10538 gradcorr6_long(ll,l)=gradcorr6_long(ll,l)+gradcorr6kl
10539 gradcorr6_long(ll,k)=gradcorr6_long(ll,k)-gradcorr6kl
10544 !old gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*ekl*gacont_hbr(ll,jj,i)
10545 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ggg1(ll)
10550 !old gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*eij*gacont_hbr(ll,kk,k)
10551 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ggg2(ll)
10557 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,1)
10562 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,2)
10566 !d write (2,*) iii,g_corr6_loc(iii)
10569 !d write (2,*) 'ekont',ekont
10570 !d write (iout,*) 'eello6',ekont*eel6
10572 end function eello6
10573 !-----------------------------------------------------------------------------
10574 real(kind=8) function eello6_graph1(i,j,k,l,imat,swap)
10576 ! implicit real*8 (a-h,o-z)
10577 ! include 'DIMENSIONS'
10578 ! include 'COMMON.IOUNITS'
10579 ! include 'COMMON.CHAIN'
10580 ! include 'COMMON.DERIV'
10581 ! include 'COMMON.INTERACT'
10582 ! include 'COMMON.CONTACTS'
10583 ! include 'COMMON.TORSION'
10584 ! include 'COMMON.VAR'
10585 ! include 'COMMON.GEO'
10586 real(kind=8),dimension(2) :: vv,vv1
10587 real(kind=8),dimension(2,2) :: pizda,auxmat,pizda1
10589 !el logical :: lprn
10590 !el common /kutas/ lprn
10591 integer :: i,j,k,l,imat,itk,iii,kkk,lll,ind
10592 real(kind=8) :: s1,s2,s3,s4,s5
10593 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
10595 ! Parallel Antiparallel C
10601 ! \ j|/k\| / \ |/k\|l / C
10602 ! \ / \ / \ / \ / C
10606 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
10607 itk=itortyp(itype(k,1))
10608 s1= scalar2(AEAb1(1,2,imat),CUgb2(1,i))
10609 s2=-scalar2(AEAb2(1,1,imat),Ug2Db1t(1,k))
10610 s3= scalar2(AEAb2(1,1,imat),CUgb2(1,k))
10611 call transpose2(EUgC(1,1,k),auxmat(1,1))
10612 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
10613 vv1(1)=pizda1(1,1)-pizda1(2,2)
10614 vv1(2)=pizda1(1,2)+pizda1(2,1)
10615 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
10616 vv(1)=AEAb1(1,2,imat)*b1(1,itk)-AEAb1(2,2,imat)*b1(2,itk)
10617 vv(2)=AEAb1(1,2,imat)*b1(2,itk)+AEAb1(2,2,imat)*b1(1,itk)
10618 s5=scalar2(vv(1),Dtobr2(1,i))
10619 !d write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4', s4,' s5',s5
10620 eello6_graph1=-0.5d0*(s1+s2+s3+s4+s5)
10621 if (i.gt.1) g_corr6_loc(i-1)=g_corr6_loc(i-1) &
10622 -0.5d0*ekont*(scalar2(AEAb1(1,2,imat),CUgb2der(1,i)) &
10623 -scalar2(AEAb2derg(1,2,1,imat),Ug2Db1t(1,k)) &
10624 +scalar2(AEAb2derg(1,2,1,imat),CUgb2(1,k)) &
10625 +0.5d0*scalar2(vv1(1),Dtobr2der(1,i)) &
10626 +scalar2(vv(1),Dtobr2der(1,i)))
10627 call matmat2(AEAderg(1,1,imat),auxmat(1,1),pizda1(1,1))
10628 vv1(1)=pizda1(1,1)-pizda1(2,2)
10629 vv1(2)=pizda1(1,2)+pizda1(2,1)
10630 vv(1)=AEAb1derg(1,2,imat)*b1(1,itk)-AEAb1derg(2,2,imat)*b1(2,itk)
10631 vv(2)=AEAb1derg(1,2,imat)*b1(2,itk)+AEAb1derg(2,2,imat)*b1(1,itk)
10633 g_corr6_loc(l-1)=g_corr6_loc(l-1) &
10634 +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i)) &
10635 -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k)) &
10636 +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k)) &
10637 +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
10639 g_corr6_loc(j-1)=g_corr6_loc(j-1) &
10640 +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i)) &
10641 -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k)) &
10642 +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k)) &
10643 +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
10645 call transpose2(EUgCder(1,1,k),auxmat(1,1))
10646 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
10647 vv1(1)=pizda1(1,1)-pizda1(2,2)
10648 vv1(2)=pizda1(1,2)+pizda1(2,1)
10649 if (k.gt.1) g_corr6_loc(k-1)=g_corr6_loc(k-1) &
10650 +ekont*(-0.5d0*(-scalar2(AEAb2(1,1,imat),Ug2Db1tder(1,k)) &
10651 +scalar2(AEAb2(1,1,imat),CUgb2der(1,k)) &
10652 +0.5d0*scalar2(vv1(1),Dtobr2(1,i))))
10661 s1= scalar2(AEAb1derx(1,lll,kkk,iii,2,imat),CUgb2(1,i))
10662 s2=-scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),Ug2Db1t(1,k))
10663 s3= scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),CUgb2(1,k))
10664 call transpose2(EUgC(1,1,k),auxmat(1,1))
10665 call matmat2(AEAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),&
10667 vv1(1)=pizda1(1,1)-pizda1(2,2)
10668 vv1(2)=pizda1(1,2)+pizda1(2,1)
10669 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
10670 vv(1)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(1,itk) &
10671 -AEAb1derx(2,lll,kkk,iii,2,imat)*b1(2,itk)
10672 vv(2)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(2,itk) &
10673 +AEAb1derx(2,lll,kkk,iii,2,imat)*b1(1,itk)
10674 s5=scalar2(vv(1),Dtobr2(1,i))
10675 derx(lll,kkk,ind)=derx(lll,kkk,ind)-0.5d0*(s1+s2+s3+s4+s5)
10680 end function eello6_graph1
10681 !-----------------------------------------------------------------------------
10682 real(kind=8) function eello6_graph2(i,j,k,l,jj,kk,swap)
10684 ! implicit real*8 (a-h,o-z)
10685 ! include 'DIMENSIONS'
10686 ! include 'COMMON.IOUNITS'
10687 ! include 'COMMON.CHAIN'
10688 ! include 'COMMON.DERIV'
10689 ! include 'COMMON.INTERACT'
10690 ! include 'COMMON.CONTACTS'
10691 ! include 'COMMON.TORSION'
10692 ! include 'COMMON.VAR'
10693 ! include 'COMMON.GEO'
10695 real(kind=8),dimension(2) :: vv,auxvec,auxvec1,auxvec2
10696 real(kind=8),dimension(2,2) :: pizda,auxmat,auxmat1
10697 !el logical :: lprn
10698 !el common /kutas/ lprn
10699 integer :: i,j,k,l,jj,kk,iii,kkk,lll,jjj,mmm
10700 real(kind=8) :: s2,s3,s4
10701 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
10703 ! Parallel Antiparallel C
10709 ! \ j|/k\| \ |/k\|l C
10714 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
10715 !d write (2,*) 'eello6_graph2: i,',i,' j',j,' k',k,' l',l
10716 ! AL 7/4/01 s1 would occur in the sixth-order moment,
10717 ! but not in a cluster cumulant
10719 s1=dip(1,jj,i)*dip(1,kk,k)
10721 call matvec2(ADtEA1(1,1,1),Ub2(1,k),auxvec(1))
10722 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
10723 call matvec2(ADtEA(1,1,2),Ub2(1,l),auxvec1(1))
10724 s3=-0.5d0*scalar2(Ub2(1,j),auxvec1(1))
10725 call transpose2(EUg(1,1,k),auxmat(1,1))
10726 call matmat2(ADtEA1(1,1,1),auxmat(1,1),pizda(1,1))
10727 vv(1)=pizda(1,1)-pizda(2,2)
10728 vv(2)=pizda(1,2)+pizda(2,1)
10729 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
10730 !d write (2,*) 'eello6_graph2:','s1',s1,' s2',s2,' s3',s3,' s4',s4
10732 eello6_graph2=-(s1+s2+s3+s4)
10734 eello6_graph2=-(s2+s3+s4)
10736 ! eello6_graph2=-s3
10737 ! Derivatives in gamma(i-1)
10740 s1=dipderg(1,jj,i)*dip(1,kk,k)
10742 s2=-0.5d0*scalar2(Ub2der(1,i),auxvec(1))
10743 call matvec2(ADtEAderg(1,1,1,2),Ub2(1,l),auxvec2(1))
10744 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
10745 s4=-0.25d0*scalar2(vv(1),Dtobr2der(1,i))
10747 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
10749 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
10751 ! g_corr6_loc(i-1)=g_corr6_loc(i-1)-s3
10753 ! Derivatives in gamma(k-1)
10755 s1=dip(1,jj,i)*dipderg(1,kk,k)
10757 call matvec2(ADtEA1(1,1,1),Ub2der(1,k),auxvec2(1))
10758 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
10759 call matvec2(ADtEAderg(1,1,2,2),Ub2(1,l),auxvec2(1))
10760 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
10761 call transpose2(EUgder(1,1,k),auxmat1(1,1))
10762 call matmat2(ADtEA1(1,1,1),auxmat1(1,1),pizda(1,1))
10763 vv(1)=pizda(1,1)-pizda(2,2)
10764 vv(2)=pizda(1,2)+pizda(2,1)
10765 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
10767 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
10769 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
10771 ! g_corr6_loc(k-1)=g_corr6_loc(k-1)-s3
10772 ! Derivatives in gamma(j-1) or gamma(l-1)
10775 s1=dipderg(3,jj,i)*dip(1,kk,k)
10777 call matvec2(ADtEA1derg(1,1,1,1),Ub2(1,k),auxvec2(1))
10778 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
10779 s3=-0.5d0*scalar2(Ub2der(1,j),auxvec1(1))
10780 call matmat2(ADtEA1derg(1,1,1,1),auxmat(1,1),pizda(1,1))
10781 vv(1)=pizda(1,1)-pizda(2,2)
10782 vv(2)=pizda(1,2)+pizda(2,1)
10783 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
10786 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
10788 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
10791 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s3+s4)
10792 ! g_corr6_loc(j-1)=g_corr6_loc(j-1)-s3
10794 ! Derivatives in gamma(l-1) or gamma(j-1)
10797 s1=dip(1,jj,i)*dipderg(3,kk,k)
10799 call matvec2(ADtEA1derg(1,1,2,1),Ub2(1,k),auxvec2(1))
10800 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
10801 call matvec2(ADtEA(1,1,2),Ub2der(1,l),auxvec2(1))
10802 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
10803 call matmat2(ADtEA1derg(1,1,2,1),auxmat(1,1),pizda(1,1))
10804 vv(1)=pizda(1,1)-pizda(2,2)
10805 vv(2)=pizda(1,2)+pizda(2,1)
10806 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
10809 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
10811 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
10814 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s3+s4)
10815 ! g_corr6_loc(l-1)=g_corr6_loc(l-1)-s3
10817 ! Cartesian derivatives.
10819 write (2,*) 'In eello6_graph2'
10821 write (2,*) 'iii=',iii
10823 write (2,*) 'kkk=',kkk
10825 write (2,'(3(2f10.5),5x)') &
10826 ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
10836 s1=dipderx(lll,kkk,1,jj,i)*dip(1,kk,k)
10838 s1=dip(1,jj,i)*dipderx(lll,kkk,1,kk,k)
10841 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,1),Ub2(1,k),&
10843 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
10844 call matvec2(ADtEAderx(1,1,lll,kkk,iii,2),Ub2(1,l),&
10846 s3=-0.5d0*scalar2(Ub2(1,j),auxvec(1))
10847 call transpose2(EUg(1,1,k),auxmat(1,1))
10848 call matmat2(ADtEA1derx(1,1,lll,kkk,iii,1),auxmat(1,1),&
10850 vv(1)=pizda(1,1)-pizda(2,2)
10851 vv(2)=pizda(1,2)+pizda(2,1)
10852 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
10853 !d write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4',s4
10855 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
10857 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
10860 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
10862 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
10868 end function eello6_graph2
10869 !-----------------------------------------------------------------------------
10870 real(kind=8) function eello6_graph3(i,j,k,l,jj,kk,swap)
10871 ! implicit real*8 (a-h,o-z)
10872 ! include 'DIMENSIONS'
10873 ! include 'COMMON.IOUNITS'
10874 ! include 'COMMON.CHAIN'
10875 ! include 'COMMON.DERIV'
10876 ! include 'COMMON.INTERACT'
10877 ! include 'COMMON.CONTACTS'
10878 ! include 'COMMON.TORSION'
10879 ! include 'COMMON.VAR'
10880 ! include 'COMMON.GEO'
10881 real(kind=8),dimension(2) :: vv,auxvec
10882 real(kind=8),dimension(2,2) :: pizda,auxmat
10884 integer :: i,j,k,l,jj,kk,iti,itj1,itk,itk1,iii,lll,kkk,itl1
10885 real(kind=8) :: s1,s2,s3,s4
10886 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
10888 ! Parallel Antiparallel C
10893 ! /| o |o o| o |\ C
10894 ! j|/k\| / |/k\|l / C
10899 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
10901 ! 4/7/01 AL Component s1 was removed, because it pertains to the respective
10902 ! energy moment and not to the cluster cumulant.
10903 iti=itortyp(itype(i,1))
10904 if (j.lt.nres-1) then
10905 itj1=itortyp(itype(j+1,1))
10909 itk=itortyp(itype(k,1))
10910 itk1=itortyp(itype(k+1,1))
10911 if (l.lt.nres-1) then
10912 itl1=itortyp(itype(l+1,1))
10917 s1=dip(4,jj,i)*dip(4,kk,k)
10919 call matvec2(AECA(1,1,1),b1(1,itk1),auxvec(1))
10920 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
10921 call matvec2(AECA(1,1,2),b1(1,itl1),auxvec(1))
10922 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
10923 call transpose2(EE(1,1,itk),auxmat(1,1))
10924 call matmat2(auxmat(1,1),AECA(1,1,1),pizda(1,1))
10925 vv(1)=pizda(1,1)+pizda(2,2)
10926 vv(2)=pizda(2,1)-pizda(1,2)
10927 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
10928 !d write (2,*) 'eello6_graph3:','s1',s1,' s2',s2,' s3',s3,' s4',s4,
10929 !d & "sum",-(s2+s3+s4)
10931 eello6_graph3=-(s1+s2+s3+s4)
10933 eello6_graph3=-(s2+s3+s4)
10935 ! eello6_graph3=-s4
10936 ! Derivatives in gamma(k-1)
10937 call matvec2(AECAderg(1,1,2),b1(1,itl1),auxvec(1))
10938 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
10939 s4=-0.25d0*scalar2(vv(1),Ctobrder(1,k))
10940 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s3+s4)
10941 ! Derivatives in gamma(l-1)
10942 call matvec2(AECAderg(1,1,1),b1(1,itk1),auxvec(1))
10943 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
10944 call matmat2(auxmat(1,1),AECAderg(1,1,1),pizda(1,1))
10945 vv(1)=pizda(1,1)+pizda(2,2)
10946 vv(2)=pizda(2,1)-pizda(1,2)
10947 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
10948 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
10949 ! Cartesian derivatives.
10955 s1=dipderx(lll,kkk,4,jj,i)*dip(4,kk,k)
10957 s1=dip(4,jj,i)*dipderx(lll,kkk,4,kk,k)
10960 call matvec2(AECAderx(1,1,lll,kkk,iii,1),b1(1,itk1),&
10962 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
10963 call matvec2(AECAderx(1,1,lll,kkk,iii,2),b1(1,itl1),&
10965 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
10966 call matmat2(auxmat(1,1),AECAderx(1,1,lll,kkk,iii,1),&
10968 vv(1)=pizda(1,1)+pizda(2,2)
10969 vv(2)=pizda(2,1)-pizda(1,2)
10970 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
10972 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
10974 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
10977 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
10979 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
10981 ! derx(lll,kkk,iii)=derx(lll,kkk,iii)-s4
10986 end function eello6_graph3
10987 !-----------------------------------------------------------------------------
10988 real(kind=8) function eello6_graph4(i,j,k,l,jj,kk,imat,swap)
10989 ! implicit real*8 (a-h,o-z)
10990 ! include 'DIMENSIONS'
10991 ! include 'COMMON.IOUNITS'
10992 ! include 'COMMON.CHAIN'
10993 ! include 'COMMON.DERIV'
10994 ! include 'COMMON.INTERACT'
10995 ! include 'COMMON.CONTACTS'
10996 ! include 'COMMON.TORSION'
10997 ! include 'COMMON.VAR'
10998 ! include 'COMMON.GEO'
10999 ! include 'COMMON.FFIELD'
11000 real(kind=8),dimension(2) :: vv,auxvec,auxvec1
11001 real(kind=8),dimension(2,2) :: pizda,auxmat,auxmat1
11003 integer :: i,j,k,l,jj,kk,imat,iti,itj,itj1,itk,itk1,itl,itl1,&
11005 real(kind=8) :: s1,s2,s3,s4
11006 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
11008 ! Parallel Antiparallel C
11013 ! /| o |o o| o |\ C
11014 ! \ j|/k\| \ |/k\|l C
11019 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
11021 ! 4/7/01 AL Component s1 was removed, because it pertains to the respective
11022 ! energy moment and not to the cluster cumulant.
11023 !d write (2,*) 'eello_graph4: wturn6',wturn6
11024 iti=itortyp(itype(i,1))
11025 itj=itortyp(itype(j,1))
11026 if (j.lt.nres-1) then
11027 itj1=itortyp(itype(j+1,1))
11031 itk=itortyp(itype(k,1))
11032 if (k.lt.nres-1) then
11033 itk1=itortyp(itype(k+1,1))
11037 itl=itortyp(itype(l,1))
11038 if (l.lt.nres-1) then
11039 itl1=itortyp(itype(l+1,1))
11043 !d write (2,*) 'eello6_graph4:','i',i,' j',j,' k',k,' l',l
11044 !d write (2,*) 'iti',iti,' itj',itj,' itj1',itj1,' itk',itk,
11045 !d & ' itl',itl,' itl1',itl1
11047 if (imat.eq.1) then
11048 s1=dip(3,jj,i)*dip(3,kk,k)
11050 s1=dip(2,jj,j)*dip(2,kk,l)
11053 call matvec2(AECA(1,1,imat),Ub2(1,k),auxvec(1))
11054 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
11056 call matvec2(ADtEA1(1,1,3-imat),b1(1,itj1),auxvec1(1))
11057 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
11059 call matvec2(ADtEA1(1,1,3-imat),b1(1,itl1),auxvec1(1))
11060 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
11062 call transpose2(EUg(1,1,k),auxmat(1,1))
11063 call matmat2(AECA(1,1,imat),auxmat(1,1),pizda(1,1))
11064 vv(1)=pizda(1,1)-pizda(2,2)
11065 vv(2)=pizda(2,1)+pizda(1,2)
11066 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
11067 !d write (2,*) 'eello6_graph4:','s1',s1,' s2',s2,' s3',s3,' s4',s4
11069 eello6_graph4=-(s1+s2+s3+s4)
11071 eello6_graph4=-(s2+s3+s4)
11073 ! Derivatives in gamma(i-1)
11076 if (imat.eq.1) then
11077 s1=dipderg(2,jj,i)*dip(3,kk,k)
11079 s1=dipderg(4,jj,j)*dip(2,kk,l)
11082 s2=0.5d0*scalar2(Ub2der(1,i),auxvec(1))
11084 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,itj1),auxvec1(1))
11085 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
11087 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,itl1),auxvec1(1))
11088 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
11090 s4=0.25d0*scalar2(vv(1),Dtobr2der(1,i))
11091 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
11092 !d write (2,*) 'turn6 derivatives'
11094 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s1+s2+s3+s4)
11096 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s2+s3+s4)
11100 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
11102 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
11106 ! Derivatives in gamma(k-1)
11108 if (imat.eq.1) then
11109 s1=dip(3,jj,i)*dipderg(2,kk,k)
11111 s1=dip(2,jj,j)*dipderg(4,kk,l)
11114 call matvec2(AECA(1,1,imat),Ub2der(1,k),auxvec1(1))
11115 s2=0.5d0*scalar2(Ub2(1,i),auxvec1(1))
11117 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,itj1),auxvec1(1))
11118 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
11120 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,itl1),auxvec1(1))
11121 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
11123 call transpose2(EUgder(1,1,k),auxmat1(1,1))
11124 call matmat2(AECA(1,1,imat),auxmat1(1,1),pizda(1,1))
11125 vv(1)=pizda(1,1)-pizda(2,2)
11126 vv(2)=pizda(2,1)+pizda(1,2)
11127 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
11128 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
11130 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s1+s2+s3+s4)
11132 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s2+s3+s4)
11136 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
11138 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
11141 ! Derivatives in gamma(j-1) or gamma(l-1)
11142 if (l.eq.j+1 .and. l.gt.1) then
11143 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
11144 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
11145 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
11146 vv(1)=pizda(1,1)-pizda(2,2)
11147 vv(2)=pizda(2,1)+pizda(1,2)
11148 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
11149 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
11150 else if (j.gt.1) then
11151 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
11152 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
11153 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
11154 vv(1)=pizda(1,1)-pizda(2,2)
11155 vv(2)=pizda(2,1)+pizda(1,2)
11156 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
11157 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
11158 gel_loc_turn6(j-1)=gel_loc_turn6(j-1)-ekont*(s2+s4)
11160 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s4)
11163 ! Cartesian derivatives.
11169 if (imat.eq.1) then
11170 s1=dipderx(lll,kkk,3,jj,i)*dip(3,kk,k)
11172 s1=dipderx(lll,kkk,2,jj,j)*dip(2,kk,l)
11175 if (imat.eq.1) then
11176 s1=dip(3,jj,i)*dipderx(lll,kkk,3,kk,k)
11178 s1=dip(2,jj,j)*dipderx(lll,kkk,2,kk,l)
11182 call matvec2(AECAderx(1,1,lll,kkk,iii,imat),Ub2(1,k),&
11184 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
11186 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),&
11187 b1(1,itj1),auxvec(1))
11188 s3=-0.5d0*scalar2(b1(1,itj),auxvec(1))
11190 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),&
11191 b1(1,itl1),auxvec(1))
11192 s3=-0.5d0*scalar2(b1(1,itl),auxvec(1))
11194 call matmat2(AECAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),&
11196 vv(1)=pizda(1,1)-pizda(2,2)
11197 vv(2)=pizda(2,1)+pizda(1,2)
11198 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
11200 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
11202 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii) &
11205 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii) &
11208 derx_turn(lll,kkk,iii)=derx_turn(lll,kkk,iii)-s3
11211 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s1+s2+s4)
11213 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s2+s4)
11215 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
11219 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
11221 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
11224 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
11226 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
11233 end function eello6_graph4
11234 !-----------------------------------------------------------------------------
11235 real(kind=8) function eello_turn6(i,jj,kk)
11236 ! implicit real*8 (a-h,o-z)
11237 ! include 'DIMENSIONS'
11238 ! include 'COMMON.IOUNITS'
11239 ! include 'COMMON.CHAIN'
11240 ! include 'COMMON.DERIV'
11241 ! include 'COMMON.INTERACT'
11242 ! include 'COMMON.CONTACTS'
11243 ! include 'COMMON.TORSION'
11244 ! include 'COMMON.VAR'
11245 ! include 'COMMON.GEO'
11246 real(kind=8),dimension(2) :: vtemp1,vtemp2,vtemp3,vtemp4,gvec
11247 real(kind=8),dimension(2,2) :: atemp,auxmat,achuj_temp,gtemp
11248 real(kind=8),dimension(3) :: ggg1,ggg2
11249 real(kind=8),dimension(2) :: vtemp1d,vtemp2d,vtemp3d,vtemp4d,gvecd
11250 real(kind=8),dimension(2,2) :: atempd,auxmatd,achuj_tempd,gtempd
11251 ! 4/7/01 AL Components s1, s8, and s13 were removed, because they pertain to
11252 ! the respective energy moment and not to the cluster cumulant.
11253 !el local variables
11254 integer :: i,jj,kk,j,k,l,iti,itk,itk1,itl,itj,iii,kkk,lll
11255 integer :: j1,j2,l1,l2,ll
11256 real(kind=8) :: s1,s2,s8,s13,s12,eello6_5,eel_turn6
11257 real(kind=8) :: s1d,s8d,s12d,s2d,gturn6ij,gturn6kl
11266 iti=itortyp(itype(i,1))
11267 itk=itortyp(itype(k,1))
11268 itk1=itortyp(itype(k+1,1))
11269 itl=itortyp(itype(l,1))
11270 itj=itortyp(itype(j,1))
11271 !d write (2,*) 'itk',itk,' itk1',itk1,' itl',itl,' itj',itj
11272 !d write (2,*) 'i',i,' k',k,' j',j,' l',l
11273 !d if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
11278 !d & 'EELLO6: Contacts have occurred for peptide groups',i,j,
11280 !d call checkint_turn6(i,jj,kk,eel_turn6_num)
11284 derx_turn(lll,kkk,iii)=0.0d0
11291 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
11293 !d write (2,*) 'eello6_5',eello6_5
11295 call transpose2(AEA(1,1,1),auxmat(1,1))
11296 call matmat2(EUg(1,1,i+1),auxmat(1,1),auxmat(1,1))
11297 ss1=scalar2(Ub2(1,i+2),b1(1,itl))
11298 s1 = (auxmat(1,1)+auxmat(2,2))*ss1
11300 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1(1))
11301 call matvec2(AEA(1,1,1),vtemp1(1),vtemp1(1))
11302 s2 = scalar2(b1(1,itk),vtemp1(1))
11304 call transpose2(AEA(1,1,2),atemp(1,1))
11305 call matmat2(atemp(1,1),EUg(1,1,i+4),atemp(1,1))
11306 call matvec2(Ug2(1,1,i+2),dd(1,1,itk1),vtemp2(1))
11307 s8 = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
11309 call matmat2(EUg(1,1,i+3),AEA(1,1,2),auxmat(1,1))
11310 call matvec2(auxmat(1,1),Ub2(1,i+4),vtemp3(1))
11311 s12 = scalar2(Ub2(1,i+2),vtemp3(1))
11313 call transpose2(a_chuj(1,1,kk,i+1),achuj_temp(1,1))
11314 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtemp(1,1))
11315 call matmat2(gtemp(1,1),EUg(1,1,i+3),gtemp(1,1))
11316 call matvec2(a_chuj(1,1,jj,i),Ub2(1,i+4),vtemp4(1))
11317 ss13 = scalar2(b1(1,itk),vtemp4(1))
11318 s13 = (gtemp(1,1)+gtemp(2,2))*ss13
11320 ! write (2,*) 's1,s2,s8,s12,s13',s1,s2,s8,s12,s13
11326 eel_turn6 = eello6_5 - 0.5d0*(s1+s2+s12+s8+s13)
11327 ! Derivatives in gamma(i+2)
11331 call transpose2(AEA(1,1,1),auxmatd(1,1))
11332 call matmat2(EUgder(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
11333 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
11334 call transpose2(AEAderg(1,1,2),atempd(1,1))
11335 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
11336 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
11338 call matmat2(EUg(1,1,i+3),AEAderg(1,1,2),auxmatd(1,1))
11339 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
11340 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
11346 gel_loc_turn6(i)=gel_loc_turn6(i)-0.5d0*ekont*(s1d+s8d+s12d)
11347 ! Derivatives in gamma(i+3)
11349 call transpose2(AEA(1,1,1),auxmatd(1,1))
11350 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
11351 ss1d=scalar2(Ub2der(1,i+2),b1(1,itl))
11352 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1d
11354 call matvec2(EUgder(1,1,i+2),b1(1,itl),vtemp1d(1))
11355 call matvec2(AEA(1,1,1),vtemp1d(1),vtemp1d(1))
11356 s2d = scalar2(b1(1,itk),vtemp1d(1))
11358 call matvec2(Ug2der(1,1,i+2),dd(1,1,itk1),vtemp2d(1))
11359 s8d = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,itl),vtemp2d(1))
11361 s12d = scalar2(Ub2der(1,i+2),vtemp3(1))
11363 call matmat2(achuj_temp(1,1),EUgder(1,1,i+2),gtempd(1,1))
11364 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
11365 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
11373 gel_loc_turn6(i+1)=gel_loc_turn6(i+1) &
11374 -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
11376 gel_loc_turn6(i+1)=gel_loc_turn6(i+1) &
11377 -0.5d0*ekont*(s2d+s12d)
11379 ! Derivatives in gamma(i+4)
11380 call matmat2(EUgder(1,1,i+3),AEA(1,1,2),auxmatd(1,1))
11381 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
11382 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
11384 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtempd(1,1))
11385 call matmat2(gtempd(1,1),EUgder(1,1,i+3),gtempd(1,1))
11386 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
11394 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d+s13d)
11396 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d)
11398 ! Derivatives in gamma(i+5)
11400 call transpose2(AEAderg(1,1,1),auxmatd(1,1))
11401 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
11402 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
11404 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1d(1))
11405 call matvec2(AEAderg(1,1,1),vtemp1d(1),vtemp1d(1))
11406 s2d = scalar2(b1(1,itk),vtemp1d(1))
11408 call transpose2(AEA(1,1,2),atempd(1,1))
11409 call matmat2(atempd(1,1),EUgder(1,1,i+4),atempd(1,1))
11410 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
11412 call matvec2(auxmat(1,1),Ub2der(1,i+4),vtemp3d(1))
11413 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
11415 call matvec2(a_chuj(1,1,jj,i),Ub2der(1,i+4),vtemp4d(1))
11416 ss13d = scalar2(b1(1,itk),vtemp4d(1))
11417 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
11425 gel_loc_turn6(i+3)=gel_loc_turn6(i+3) &
11426 -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
11428 gel_loc_turn6(i+3)=gel_loc_turn6(i+3) &
11429 -0.5d0*ekont*(s2d+s12d)
11431 ! Cartesian derivatives
11436 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmatd(1,1))
11437 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
11438 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
11440 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1(1))
11441 call matvec2(AEAderx(1,1,lll,kkk,iii,1),vtemp1(1),&
11443 s2d = scalar2(b1(1,itk),vtemp1d(1))
11445 call transpose2(AEAderx(1,1,lll,kkk,iii,2),atempd(1,1))
11446 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
11447 s8d = -(atempd(1,1)+atempd(2,2))* &
11448 scalar2(cc(1,1,itl),vtemp2(1))
11450 call matmat2(EUg(1,1,i+3),AEAderx(1,1,lll,kkk,iii,2),&
11452 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
11453 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
11460 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii) &
11463 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii) &
11467 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii) &
11470 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii) &
11479 call transpose2(a_chuj_der(1,1,lll,kkk,kk,i+1),&
11481 call matmat2(achuj_tempd(1,1),EUg(1,1,i+2),gtempd(1,1))
11482 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
11483 s13d=(gtempd(1,1)+gtempd(2,2))*ss13
11484 derx_turn(lll,kkk,2) = derx_turn(lll,kkk,2)-0.5d0*s13d
11485 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),Ub2(1,i+4),&
11487 ss13d = scalar2(b1(1,itk),vtemp4d(1))
11488 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
11489 derx_turn(lll,kkk,1) = derx_turn(lll,kkk,1)-0.5d0*s13d
11493 !d write(iout,*) 'eel6_turn6',eel_turn6,' eel_turn6_num',
11494 !d & 16*eel_turn6_num
11496 if (j.lt.nres-1) then
11503 if (l.lt.nres-1) then
11511 !grad ggg1(ll)=eel_turn6*g_contij(ll,1)
11512 !grad ggg2(ll)=eel_turn6*g_contij(ll,2)
11513 !grad ghalf=0.5d0*ggg1(ll)
11515 gturn6ij=eel_turn6*g_contij(ll,1)+ekont*derx_turn(ll,1,1)
11516 gturn6kl=eel_turn6*g_contij(ll,2)+ekont*derx_turn(ll,1,2)
11517 gcorr6_turn(ll,i)=gcorr6_turn(ll,i) & !+ghalf
11518 +ekont*derx_turn(ll,2,1)
11519 gcorr6_turn(ll,i+1)=gcorr6_turn(ll,i+1)+ekont*derx_turn(ll,3,1)
11520 gcorr6_turn(ll,j)=gcorr6_turn(ll,j) & !+ghalf
11521 +ekont*derx_turn(ll,4,1)
11522 gcorr6_turn(ll,j1)=gcorr6_turn(ll,j1)+ekont*derx_turn(ll,5,1)
11523 gcorr6_turn_long(ll,j)=gcorr6_turn_long(ll,j)+gturn6ij
11524 gcorr6_turn_long(ll,i)=gcorr6_turn_long(ll,i)-gturn6ij
11525 !grad ghalf=0.5d0*ggg2(ll)
11527 gcorr6_turn(ll,k)=gcorr6_turn(ll,k) & !+ghalf
11528 +ekont*derx_turn(ll,2,2)
11529 gcorr6_turn(ll,k+1)=gcorr6_turn(ll,k+1)+ekont*derx_turn(ll,3,2)
11530 gcorr6_turn(ll,l)=gcorr6_turn(ll,l) & !+ghalf
11531 +ekont*derx_turn(ll,4,2)
11532 gcorr6_turn(ll,l1)=gcorr6_turn(ll,l1)+ekont*derx_turn(ll,5,2)
11533 gcorr6_turn_long(ll,l)=gcorr6_turn_long(ll,l)+gturn6kl
11534 gcorr6_turn_long(ll,k)=gcorr6_turn_long(ll,k)-gturn6kl
11539 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg1(ll)
11544 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg2(ll)
11550 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,1)
11555 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,2)
11559 !d write (2,*) iii,g_corr6_loc(iii)
11561 eello_turn6=ekont*eel_turn6
11562 !d write (2,*) 'ekont',ekont
11563 !d write (2,*) 'eel_turn6',ekont*eel_turn6
11565 end function eello_turn6
11566 !-----------------------------------------------------------------------------
11567 subroutine MATVEC2(A1,V1,V2)
11568 !DIR$ INLINEALWAYS MATVEC2
11570 !DEC$ ATTRIBUTES FORCEINLINE::MATVEC2
11572 ! implicit real*8 (a-h,o-z)
11573 ! include 'DIMENSIONS'
11574 real(kind=8),dimension(2) :: V1,V2
11575 real(kind=8),dimension(2,2) :: A1
11576 real(kind=8) :: vaux1,vaux2
11580 ! 3 VI=VI+A1(I,K)*V1(K)
11584 vaux1=a1(1,1)*v1(1)+a1(1,2)*v1(2)
11585 vaux2=a1(2,1)*v1(1)+a1(2,2)*v1(2)
11589 end subroutine MATVEC2
11590 !-----------------------------------------------------------------------------
11591 subroutine MATMAT2(A1,A2,A3)
11593 !DEC$ ATTRIBUTES FORCEINLINE::MATMAT2
11595 ! implicit real*8 (a-h,o-z)
11596 ! include 'DIMENSIONS'
11597 real(kind=8),dimension(2,2) :: A1,A2,A3
11598 real(kind=8) :: ai3_11,ai3_12,ai3_21,ai3_22
11599 ! DIMENSION AI3(2,2)
11603 ! A3IJ=A3IJ+A1(I,K)*A2(K,J)
11609 ai3_11=a1(1,1)*a2(1,1)+a1(1,2)*a2(2,1)
11610 ai3_12=a1(1,1)*a2(1,2)+a1(1,2)*a2(2,2)
11611 ai3_21=a1(2,1)*a2(1,1)+a1(2,2)*a2(2,1)
11612 ai3_22=a1(2,1)*a2(1,2)+a1(2,2)*a2(2,2)
11618 end subroutine MATMAT2
11619 !-----------------------------------------------------------------------------
11620 real(kind=8) function scalar2(u,v)
11621 !DIR$ INLINEALWAYS scalar2
11623 real(kind=8),dimension(2) :: u,v
11626 scalar2=u(1)*v(1)+u(2)*v(2)
11628 end function scalar2
11629 !-----------------------------------------------------------------------------
11630 subroutine transpose2(a,at)
11631 !DIR$ INLINEALWAYS transpose2
11633 !DEC$ ATTRIBUTES FORCEINLINE::transpose2
11636 real(kind=8),dimension(2,2) :: a,at
11642 end subroutine transpose2
11643 !-----------------------------------------------------------------------------
11644 subroutine transpose(n,a,at)
11647 real(kind=8),dimension(n,n) :: a,at
11654 end subroutine transpose
11655 !-----------------------------------------------------------------------------
11656 subroutine prodmat3(a1,a2,kk,transp,prod)
11657 !DIR$ INLINEALWAYS prodmat3
11659 !DEC$ ATTRIBUTES FORCEINLINE::prodmat3
11663 real(kind=8),dimension(2,2) :: a1,a2,a2t,kk,prod
11665 !rc double precision auxmat(2,2),prod_(2,2)
11668 !rc call transpose2(kk(1,1),auxmat(1,1))
11669 !rc call matmat2(a1(1,1),auxmat(1,1),auxmat(1,1))
11670 !rc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
11672 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,1) &
11673 +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,1)
11674 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,2) &
11675 +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,2)
11676 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,1) &
11677 +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,1)
11678 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,2) &
11679 +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,2)
11682 !rc call matmat2(a1(1,1),kk(1,1),auxmat(1,1))
11683 !rc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
11685 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,1) &
11686 +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,1)
11687 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,2) &
11688 +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,2)
11689 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,1) &
11690 +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,1)
11691 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,2) &
11692 +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,2)
11695 ! call transpose2(a2(1,1),a2t(1,1))
11698 !rc print *,((prod_(i,j),i=1,2),j=1,2)
11699 !rc print *,((prod(i,j),i=1,2),j=1,2)
11702 end subroutine prodmat3
11703 !-----------------------------------------------------------------------------
11704 ! energy_p_new_barrier.F
11705 !-----------------------------------------------------------------------------
11706 subroutine sum_gradient
11707 ! implicit real*8 (a-h,o-z)
11708 use io_base, only: pdbout
11709 ! include 'DIMENSIONS'
11713 !MS$ATTRIBUTES C :: proc_proc
11719 real(kind=8),dimension(3,-1:nres) :: gradbufc,gradbufx,gradbufc_sum,&
11720 gloc_scbuf !(3,maxres)
11722 real(kind=8),dimension(4*nres) :: glocbuf !(4*maxres)
11724 !el local variables
11725 integer :: i,j,k,ierror,ierr
11726 real(kind=8) :: gvdwc_norm,gvdwc_scp_norm,gelc_norm,gvdwpp_norm,&
11727 gradb_norm,ghpbc_norm,gradcorr_norm,gel_loc_norm,&
11728 gcorr3_turn_norm,gcorr4_turn_norm,gradcorr5_norm,&
11729 gradcorr6_norm,gcorr6_turn_norm,gsccorr_norm,&
11730 gscloc_norm,gvdwx_norm,gradx_scp_norm,ghpbx_norm,&
11731 gradxorr_norm,gsccorrx_norm,gsclocx_norm,gcorr6_max,&
11732 gsccorr_max,gsccorrx_max,time00
11734 ! include 'COMMON.SETUP'
11735 ! include 'COMMON.IOUNITS'
11736 ! include 'COMMON.FFIELD'
11737 ! include 'COMMON.DERIV'
11738 ! include 'COMMON.INTERACT'
11739 ! include 'COMMON.SBRIDGE'
11740 ! include 'COMMON.CHAIN'
11741 ! include 'COMMON.VAR'
11742 ! include 'COMMON.CONTROL'
11743 ! include 'COMMON.TIME1'
11744 ! include 'COMMON.MAXGRAD'
11745 ! include 'COMMON.SCCOR'
11751 write (iout,*) "sum_gradient gvdwc, gvdwx"
11753 write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)') &
11754 i,(gvdwx(j,i),j=1,3),(gvdwc(j,i),j=1,3)
11764 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
11765 if (nfgtasks.gt.1 .and. fg_rank.eq.0) &
11766 call MPI_Bcast(1,1,MPI_INTEGER,king,FG_COMM,IERROR)
11769 ! 9/29/08 AL Transform parts of gradients in site coordinates to the gradient
11770 ! in virtual-bond-vector coordinates
11773 ! write (iout,*) "gel_loc gel_loc_long and gel_loc_loc"
11775 ! write (iout,'(i5,3f10.5,2x,3f10.5,2x,f10.5)')
11776 ! & i,(gel_loc(j,i),j=1,3),(gel_loc_long(j,i),j=1,3),gel_loc_loc(i)
11778 ! write (iout,*) "gel_loc_tur3 gel_loc_turn4"
11780 ! write (iout,'(i5,3f10.5,2x,f10.5)')
11781 ! & i,(gcorr4_turn(j,i),j=1,3),gel_loc_turn4(i)
11783 ! write (iout,*) "gvdwc gvdwc_scp gvdwc_scpp"
11785 ! write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)') &
11786 ! i,(gvdwc(j,i),j=1,3),(gvdwc_scp(j,i),j=1,3),&
11787 ! (gvdwc_scpp(j,i),j=1,3)
11789 ! write (iout,*) "gelc_long gvdwpp gel_loc_long"
11791 ! write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)') &
11792 ! i,(gelc_long(j,i),j=1,3),(gvdwpp(j,i),j=1,3),&
11793 ! (gelc_loc_long(j,i),j=1,3)
11800 gradbufc(j,i)=wsc*gvdwc(j,i)+ &
11801 wscp*(gvdwc_scp(j,i)+gvdwc_scpp(j,i))+ &
11802 welec*gelc_long(j,i)+wvdwpp*gvdwpp(j,i)+ &
11803 wel_loc*gel_loc_long(j,i)+ &
11804 wcorr*gradcorr_long(j,i)+ &
11805 wcorr5*gradcorr5_long(j,i)+ &
11806 wcorr6*gradcorr6_long(j,i)+ &
11807 wturn6*gcorr6_turn_long(j,i)+ &
11808 wstrain*ghpbc(j,i) &
11809 +wliptran*gliptranc(j,i) &
11811 +welec*gshieldc(j,i) &
11812 +wcorr*gshieldc_ec(j,i) &
11813 +wturn3*gshieldc_t3(j,i)&
11814 +wturn4*gshieldc_t4(j,i)&
11815 +wel_loc*gshieldc_ll(j,i)&
11816 +wtube*gg_tube(j,i) &
11817 +wvdwpp_nucl*gvdwpp_nucl(j,i)+welpp*gelpp(j,i)+ &
11818 wvdwpsb*(gvdwpsb(j,i)+gvdwpsb1(j,i))+ &
11819 wvdwsb*gvdwsbc(j,i)+welsb*gelsbc(j,i)+ &
11820 wcorr_nucl*gradcorr_nucl(j,i)&
11821 +wcorr3_nucl*gradcorr3_nucl(j,i)+&
11822 wcatprot* gradpepcat(j,i)+ &
11823 wcatcat*gradcatcat(j,i)+ &
11824 wscbase*gvdwc_scbase(j,i)+ &
11825 wpepbase*gvdwc_pepbase(j,i)+&
11826 wscpho*gvdwc_scpho(j,i)+ &
11827 wpeppho*gvdwc_peppho(j,i)+wcatnucl*gradnuclcat(j,i)
11838 gradbufc(j,i)=wsc*gvdwc(j,i)+ &
11839 wscp*(gvdwc_scp(j,i)+gvdwc_scpp(j,i))+ &
11840 welec*gelc_long(j,i)+ &
11841 wbond*gradb(j,i)+ &
11842 wel_loc*gel_loc_long(j,i)+ &
11843 wcorr*gradcorr_long(j,i)+ &
11844 wcorr5*gradcorr5_long(j,i)+ &
11845 wcorr6*gradcorr6_long(j,i)+ &
11846 wturn6*gcorr6_turn_long(j,i)+ &
11847 wstrain*ghpbc(j,i) &
11848 +wliptran*gliptranc(j,i) &
11850 +welec*gshieldc(j,i)&
11851 +wcorr*gshieldc_ec(j,i) &
11852 +wturn4*gshieldc_t4(j,i) &
11853 +wel_loc*gshieldc_ll(j,i)&
11854 +wtube*gg_tube(j,i) &
11855 +wvdwpp_nucl*gvdwpp_nucl(j,i)+welpp*gelpp(j,i)+ &
11856 wvdwpsb*(gvdwpsb(j,i)+gvdwpsb1(j,i))+ &
11857 wvdwsb*gvdwsbc(j,i)+welsb*gelsbc(j,i)+ &
11858 wcorr_nucl*gradcorr_nucl(j,i) &
11859 +wcorr3_nucl*gradcorr3_nucl(j,i) +&
11860 wcatprot* gradpepcat(j,i)+ &
11861 wcatcat*gradcatcat(j,i)+ &
11862 wscbase*gvdwc_scbase(j,i)+ &
11863 wpepbase*gvdwc_pepbase(j,i)+&
11864 wscpho*gvdwc_scpho(j,i)+&
11865 wpeppho*gvdwc_peppho(j,i)+wcatnucl*gradnuclcat(j,i)
11872 if (nfgtasks.gt.1) then
11875 write (iout,*) "gradbufc before allreduce"
11877 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
11883 gradbufc_sum(j,i)=gradbufc(j,i)
11886 ! call MPI_AllReduce(gradbufc(1,1),gradbufc_sum(1,1),3*nres,
11887 ! & MPI_DOUBLE_PRECISION,MPI_SUM,FG_COMM,IERR)
11888 ! time_reduce=time_reduce+MPI_Wtime()-time00
11890 ! write (iout,*) "gradbufc_sum after allreduce"
11892 ! write (iout,'(i3,3f10.5)') i,(gradbufc_sum(j,i),j=1,3)
11897 ! time_allreduce=time_allreduce+MPI_Wtime()-time00
11901 gradbufc(k,i)=0.0d0
11905 write (iout,*) "igrad_start",igrad_start," igrad_end",igrad_end
11906 write (iout,*) (i," jgrad_start",jgrad_start(i),&
11907 " jgrad_end ",jgrad_end(i),&
11908 i=igrad_start,igrad_end)
11911 ! Obsolete and inefficient code; we can make the effort O(n) and, therefore,
11912 ! do not parallelize this part.
11914 ! do i=igrad_start,igrad_end
11915 ! do j=jgrad_start(i),jgrad_end(i)
11917 ! gradbufc(k,i)=gradbufc(k,i)+gradbufc_sum(k,j)
11922 gradbufc(j,nres-1)=gradbufc_sum(j,nres)
11926 gradbufc(j,i)=gradbufc(j,i+1)+gradbufc_sum(j,i+1)
11930 write (iout,*) "gradbufc after summing"
11932 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
11940 write (iout,*) "gradbufc"
11942 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
11949 gradbufc_sum(j,i)=gradbufc(j,i)
11950 gradbufc(j,i)=0.0d0
11954 gradbufc(j,nres-1)=gradbufc_sum(j,nres)
11958 gradbufc(j,i)=gradbufc(j,i+1)+gradbufc_sum(j,i+1)
11963 ! gradbufc(k,i)=0.0d0
11967 ! gradbufc(k,i)=gradbufc(k,i)+gradbufc(k,j)
11973 write (iout,*) "gradbufc after summing"
11975 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
11984 gradbufc(k,nres)=0.0d0
11986 !el----------------
11987 !el if (.not.allocated(gradx)) allocate(gradx(3,nres,2)) !(3,maxres,2)
11988 !el if (.not.allocated(gradc)) allocate(gradc(3,nres,2)) !(3,maxres,2)
11989 !el-----------------
11993 gradc(j,i,icg)=gradbufc(j,i)+welec*gelc(j,i)+ &
11994 wel_loc*gel_loc(j,i)+ &
11995 0.5d0*(wscp*gvdwc_scpp(j,i)+ &
11996 welec*gelc_long(j,i)+wvdwpp*gvdwpp(j,i)+ &
11997 wel_loc*gel_loc_long(j,i)+ &
11998 wcorr*gradcorr_long(j,i)+ &
11999 wcorr5*gradcorr5_long(j,i)+ &
12000 wcorr6*gradcorr6_long(j,i)+ &
12001 wturn6*gcorr6_turn_long(j,i))+ &
12002 wbond*gradb(j,i)+ &
12003 wcorr*gradcorr(j,i)+ &
12004 wturn3*gcorr3_turn(j,i)+ &
12005 wturn4*gcorr4_turn(j,i)+ &
12006 wcorr5*gradcorr5(j,i)+ &
12007 wcorr6*gradcorr6(j,i)+ &
12008 wturn6*gcorr6_turn(j,i)+ &
12009 wsccor*gsccorc(j,i) &
12010 +wscloc*gscloc(j,i) &
12011 +wliptran*gliptranc(j,i) &
12013 +welec*gshieldc(j,i) &
12014 +welec*gshieldc_loc(j,i) &
12015 +wcorr*gshieldc_ec(j,i) &
12016 +wcorr*gshieldc_loc_ec(j,i) &
12017 +wturn3*gshieldc_t3(j,i) &
12018 +wturn3*gshieldc_loc_t3(j,i) &
12019 +wturn4*gshieldc_t4(j,i) &
12020 +wturn4*gshieldc_loc_t4(j,i) &
12021 +wel_loc*gshieldc_ll(j,i) &
12022 +wel_loc*gshieldc_loc_ll(j,i) &
12023 +wtube*gg_tube(j,i) &
12024 +0.5d0*(wvdwpp_nucl*gvdwpp_nucl(j,i)+welpp*gelpp(j,i)&
12025 +wvdwpsb*gvdwpsb1(j,i))&
12026 +wbond_nucl*gradb_nucl(j,i)+wsbloc*gsbloc(j,i)
12027 ! if (i.eq.21) then
12028 ! print *,"in sum",gradc(j,i,icg),wturn4*gcorr4_turn(j,i),&
12029 ! wturn4*gshieldc_t4(j,i), &
12030 ! wturn4*gshieldc_loc_t4(j,i)
12032 ! if ((i.le.2).and.(i.ge.1))
12033 ! print *,gradc(j,i,icg),&
12034 ! gradbufc(j,i),welec*gelc(j,i), &
12035 ! wel_loc*gel_loc(j,i), &
12036 ! wscp*gvdwc_scpp(j,i), &
12037 ! welec*gelc_long(j,i),wvdwpp*gvdwpp(j,i), &
12038 ! wel_loc*gel_loc_long(j,i), &
12039 ! wcorr*gradcorr_long(j,i), &
12040 ! wcorr5*gradcorr5_long(j,i), &
12041 ! wcorr6*gradcorr6_long(j,i), &
12042 ! wturn6*gcorr6_turn_long(j,i), &
12043 ! wbond*gradb(j,i), &
12044 ! wcorr*gradcorr(j,i), &
12045 ! wturn3*gcorr3_turn(j,i), &
12046 ! wturn4*gcorr4_turn(j,i), &
12047 ! wcorr5*gradcorr5(j,i), &
12048 ! wcorr6*gradcorr6(j,i), &
12049 ! wturn6*gcorr6_turn(j,i), &
12050 ! wsccor*gsccorc(j,i) &
12051 ! ,wscloc*gscloc(j,i) &
12052 ! ,wliptran*gliptranc(j,i) &
12054 ! ,welec*gshieldc(j,i) &
12055 ! ,welec*gshieldc_loc(j,i) &
12056 ! ,wcorr*gshieldc_ec(j,i) &
12057 ! ,wcorr*gshieldc_loc_ec(j,i) &
12058 ! ,wturn3*gshieldc_t3(j,i) &
12059 ! ,wturn3*gshieldc_loc_t3(j,i) &
12060 ! ,wturn4*gshieldc_t4(j,i) &
12061 ! ,wturn4*gshieldc_loc_t4(j,i) &
12062 ! ,wel_loc*gshieldc_ll(j,i) &
12063 ! ,wel_loc*gshieldc_loc_ll(j,i) &
12064 ! ,wtube*gg_tube(j,i) &
12065 ! ,wbond_nucl*gradb_nucl(j,i) &
12066 ! ,wvdwpp_nucl*gvdwpp_nucl(j,i),welpp*gelpp(j,i),&
12067 ! wvdwpsb*gvdwpsb1(j,i)&
12068 ! ,wbond_nucl*gradb_nucl(j,i),wsbloc*gsbloc(j,i)
12072 gradc(j,i,icg)=gradbufc(j,i)+welec*gelc(j,i)+ &
12073 wel_loc*gel_loc(j,i)+ &
12074 0.5d0*(wscp*gvdwc_scpp(j,i)+ &
12075 welec*gelc_long(j,i)+ &
12076 wel_loc*gel_loc_long(j,i)+ &
12077 !el wcorr*gcorr_long(j,i)+ & !el gcorr_long- brak deklaracji
12078 wcorr5*gradcorr5_long(j,i)+ &
12079 wcorr6*gradcorr6_long(j,i)+ &
12080 wturn6*gcorr6_turn_long(j,i))+ &
12081 wbond*gradb(j,i)+ &
12082 wcorr*gradcorr(j,i)+ &
12083 wturn3*gcorr3_turn(j,i)+ &
12084 wturn4*gcorr4_turn(j,i)+ &
12085 wcorr5*gradcorr5(j,i)+ &
12086 wcorr6*gradcorr6(j,i)+ &
12087 wturn6*gcorr6_turn(j,i)+ &
12088 wsccor*gsccorc(j,i) &
12089 +wscloc*gscloc(j,i) &
12091 +wliptran*gliptranc(j,i) &
12092 +welec*gshieldc(j,i) &
12093 +welec*gshieldc_loc(j,i) &
12094 +wcorr*gshieldc_ec(j,i) &
12095 +wcorr*gshieldc_loc_ec(j,i) &
12096 +wturn3*gshieldc_t3(j,i) &
12097 +wturn3*gshieldc_loc_t3(j,i) &
12098 +wturn4*gshieldc_t4(j,i) &
12099 +wturn4*gshieldc_loc_t4(j,i) &
12100 +wel_loc*gshieldc_ll(j,i) &
12101 +wel_loc*gshieldc_loc_ll(j,i) &
12102 +wtube*gg_tube(j,i) &
12103 +wbond_nucl*gradb_nucl(j,i) &
12104 +0.5d0*(wvdwpp_nucl*gvdwpp_nucl(j,i)+welpp*gelpp(j,i)&
12105 +wvdwpsb*gvdwpsb1(j,i))&
12106 +wsbloc*gsbloc(j,i)+wcatnucl*gradnuclcat(j,i)
12112 gradx(j,i,icg)=wsc*gvdwx(j,i)+wscp*gradx_scp(j,i)+ &
12113 wbond*gradbx(j,i)+ &
12114 wstrain*ghpbx(j,i)+wcorr*gradxorr(j,i)+ &
12115 wsccor*gsccorx(j,i) &
12116 +wscloc*gsclocx(j,i) &
12117 +wliptran*gliptranx(j,i) &
12118 +welec*gshieldx(j,i) &
12119 +wcorr*gshieldx_ec(j,i) &
12120 +wturn3*gshieldx_t3(j,i) &
12121 +wturn4*gshieldx_t4(j,i) &
12122 +wel_loc*gshieldx_ll(j,i)&
12123 +wtube*gg_tube_sc(j,i) &
12124 +wbond_nucl*gradbx_nucl(j,i) &
12125 +wvdwsb*gvdwsbx(j,i) &
12126 +welsb*gelsbx(j,i) &
12127 +wcorr_nucl*gradxorr_nucl(j,i)&
12128 +wcorr3_nucl*gradxorr3_nucl(j,i) &
12129 +wsbloc*gsblocx(j,i) &
12130 +wcatprot* gradpepcatx(j,i)&
12131 +wscbase*gvdwx_scbase(j,i) &
12132 +wpepbase*gvdwx_pepbase(j,i)&
12133 +wscpho*gvdwx_scpho(j,i)+wcatnucl*gradnuclcatx(j,i)
12134 ! if (i.eq.3) print *,"tu?", wscpho,gvdwx_scpho(j,i)
12138 ! write(iout,*), "const_homol",constr_homology
12139 if (constr_homology.gt.0) then
12142 gradc(j,i,icg)=gradc(j,i,icg)+duscdiff(j,i)
12143 ! write(iout,*) "duscdiff",duscdiff(j,i)
12144 gradx(j,i,icg)=gradx(j,i,icg)+duscdiffx(j,i)
12150 write (iout,*) "gloc before adding corr"
12152 write (iout,*) i,gloc(i,icg)
12156 gloc(i,icg)=gloc(i,icg)+wcorr*gcorr_loc(i) &
12157 +wcorr5*g_corr5_loc(i) &
12158 +wcorr6*g_corr6_loc(i) &
12159 +wturn4*gel_loc_turn4(i) &
12160 +wturn3*gel_loc_turn3(i) &
12161 +wturn6*gel_loc_turn6(i) &
12162 +wel_loc*gel_loc_loc(i)
12165 write (iout,*) "gloc after adding corr"
12167 write (iout,*) i,gloc(i,icg)
12172 if (nfgtasks.gt.1) then
12175 gradbufc(j,i)=gradc(j,i,icg)
12176 gradbufx(j,i)=gradx(j,i,icg)
12180 glocbuf(i)=gloc(i,icg)
12184 write (iout,*) "gloc_sc before reduce"
12187 write (iout,*) i,j,gloc_sc(j,i,icg)
12194 gloc_scbuf(j,i)=gloc_sc(j,i,icg)
12198 call MPI_Barrier(FG_COMM,IERR)
12199 time_barrier_g=time_barrier_g+MPI_Wtime()-time00
12201 call MPI_Reduce(gradbufc(1,0),gradc(1,0,icg),3*nres+3,&
12202 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
12203 call MPI_Reduce(gradbufx(1,0),gradx(1,0,icg),3*nres+3,&
12204 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
12205 call MPI_Reduce(glocbuf(1),gloc(1,icg),4*nres,&
12206 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
12207 time_reduce=time_reduce+MPI_Wtime()-time00
12208 call MPI_Reduce(gloc_scbuf(1,0),gloc_sc(1,0,icg),3*nres+3,&
12209 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
12210 time_reduce=time_reduce+MPI_Wtime()-time00
12212 ! print *,"gradbuf",gradbufc(1,1),gradc(1,1,icg)
12214 write (iout,*) "gloc_sc after reduce"
12217 write (iout,*) i,j,gloc_sc(j,i,icg)
12223 write (iout,*) "gloc after reduce"
12225 write (iout,*) i,gloc(i,icg)
12230 if (gnorm_check) then
12232 ! Compute the maximum elements of the gradient
12235 gvdwc_scp_max=0.0d0
12242 gcorr3_turn_max=0.0d0
12243 gcorr4_turn_max=0.0d0
12244 gradcorr5_max=0.0d0
12245 gradcorr6_max=0.0d0
12246 gcorr6_turn_max=0.0d0
12250 gradx_scp_max=0.0d0
12256 gvdwc_norm=dsqrt(scalar(gvdwc(1,i),gvdwc(1,i)))
12257 if (gvdwc_norm.gt.gvdwc_max) gvdwc_max=gvdwc_norm
12258 gvdwc_scp_norm=dsqrt(scalar(gvdwc_scp(1,i),gvdwc_scp(1,i)))
12259 if (gvdwc_scp_norm.gt.gvdwc_scp_max) &
12260 gvdwc_scp_max=gvdwc_scp_norm
12261 gelc_norm=dsqrt(scalar(gelc(1,i),gelc(1,i)))
12262 if (gelc_norm.gt.gelc_max) gelc_max=gelc_norm
12263 gvdwpp_norm=dsqrt(scalar(gvdwpp(1,i),gvdwpp(1,i)))
12264 if (gvdwpp_norm.gt.gvdwpp_max) gvdwpp_max=gvdwpp_norm
12265 gradb_norm=dsqrt(scalar(gradb(1,i),gradb(1,i)))
12266 if (gradb_norm.gt.gradb_max) gradb_max=gradb_norm
12267 ghpbc_norm=dsqrt(scalar(ghpbc(1,i),ghpbc(1,i)))
12268 if (ghpbc_norm.gt.ghpbc_max) ghpbc_max=ghpbc_norm
12269 gradcorr_norm=dsqrt(scalar(gradcorr(1,i),gradcorr(1,i)))
12270 if (gradcorr_norm.gt.gradcorr_max) gradcorr_max=gradcorr_norm
12271 gel_loc_norm=dsqrt(scalar(gel_loc(1,i),gel_loc(1,i)))
12272 if (gel_loc_norm.gt.gel_loc_max) gel_loc_max=gel_loc_norm
12273 gcorr3_turn_norm=dsqrt(scalar(gcorr3_turn(1,i),&
12275 if (gcorr3_turn_norm.gt.gcorr3_turn_max) &
12276 gcorr3_turn_max=gcorr3_turn_norm
12277 gcorr4_turn_norm=dsqrt(scalar(gcorr4_turn(1,i),&
12279 if (gcorr4_turn_norm.gt.gcorr4_turn_max) &
12280 gcorr4_turn_max=gcorr4_turn_norm
12281 gradcorr5_norm=dsqrt(scalar(gradcorr5(1,i),gradcorr5(1,i)))
12282 if (gradcorr5_norm.gt.gradcorr5_max) &
12283 gradcorr5_max=gradcorr5_norm
12284 gradcorr6_norm=dsqrt(scalar(gradcorr6(1,i),gradcorr6(1,i)))
12285 if (gradcorr6_norm.gt.gradcorr6_max) gcorr6_max=gradcorr6_norm
12286 gcorr6_turn_norm=dsqrt(scalar(gcorr6_turn(1,i),&
12288 if (gcorr6_turn_norm.gt.gcorr6_turn_max) &
12289 gcorr6_turn_max=gcorr6_turn_norm
12290 gsccorr_norm=dsqrt(scalar(gsccorc(1,i),gsccorc(1,i)))
12291 if (gsccorr_norm.gt.gsccorr_max) gsccorr_max=gsccorr_norm
12292 gscloc_norm=dsqrt(scalar(gscloc(1,i),gscloc(1,i)))
12293 if (gscloc_norm.gt.gscloc_max) gscloc_max=gscloc_norm
12294 gvdwx_norm=dsqrt(scalar(gvdwx(1,i),gvdwx(1,i)))
12295 if (gvdwx_norm.gt.gvdwx_max) gvdwx_max=gvdwx_norm
12296 gradx_scp_norm=dsqrt(scalar(gradx_scp(1,i),gradx_scp(1,i)))
12297 if (gradx_scp_norm.gt.gradx_scp_max) &
12298 gradx_scp_max=gradx_scp_norm
12299 ghpbx_norm=dsqrt(scalar(ghpbx(1,i),ghpbx(1,i)))
12300 if (ghpbx_norm.gt.ghpbx_max) ghpbx_max=ghpbx_norm
12301 gradxorr_norm=dsqrt(scalar(gradxorr(1,i),gradxorr(1,i)))
12302 if (gradxorr_norm.gt.gradxorr_max) gradxorr_max=gradxorr_norm
12303 gsccorrx_norm=dsqrt(scalar(gsccorx(1,i),gsccorx(1,i)))
12304 if (gsccorrx_norm.gt.gsccorrx_max) gsccorrx_max=gsccorrx_norm
12305 gsclocx_norm=dsqrt(scalar(gsclocx(1,i),gsclocx(1,i)))
12306 if (gsclocx_norm.gt.gsclocx_max) gsclocx_max=gsclocx_norm
12310 open(istat,file=statname,position="append")
12312 open(istat,file=statname,access="append")
12314 write (istat,'(1h#,21f10.2)') gvdwc_max,gvdwc_scp_max,&
12315 gelc_max,gvdwpp_max,gradb_max,ghpbc_max,&
12316 gradcorr_max,gel_loc_max,gcorr3_turn_max,gcorr4_turn_max,&
12317 gradcorr5_max,gradcorr6_max,gcorr6_turn_max,gsccorc_max,&
12318 gscloc_max,gvdwx_max,gradx_scp_max,ghpbx_max,gradxorr_max,&
12319 gsccorx_max,gsclocx_max
12321 if (gvdwc_max.gt.1.0d4) then
12322 write (iout,*) "gvdwc gvdwx gradb gradbx"
12324 write(iout,'(i5,4(3f10.2,5x))') i,(gvdwc(j,i),gvdwx(j,i),&
12325 gradb(j,i),gradbx(j,i),j=1,3)
12327 call pdbout(0.0d0,'cipiszcze',iout)
12334 write (iout,*) "gradc gradx gloc"
12336 write (iout,'(i5,3f10.5,5x,3f10.5,5x,f10.5)') &
12337 i,(gradc(j,i,icg),j=1,3),(gradx(j,i,icg),j=1,3),gloc(i,icg)
12342 time_sumgradient=time_sumgradient+MPI_Wtime()-time01
12345 end subroutine sum_gradient
12346 !-----------------------------------------------------------------------------
12348 ! implicit real*8 (a-h,o-z)
12350 ! include 'DIMENSIONS'
12351 ! include 'COMMON.CHAIN'
12352 ! include 'COMMON.DERIV'
12353 ! include 'COMMON.CALC'
12354 ! include 'COMMON.IOUNITS'
12355 real(kind=8), dimension(3) :: dcosom1,dcosom2
12356 ! print *,"wchodze"
12357 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1 &
12358 +dCAVdOM1+ dGCLdOM1+ dPOLdOM1
12359 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2 &
12360 +dCAVdOM2+ dGCLdOM2+ dPOLdOM2
12362 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12 &
12363 -2.0D0*alf12*eps3der+sigder*sigsq_om12&
12364 +dCAVdOM12+ dGCLdOM12
12368 ! eom12=evdwij*eps1_om12
12370 ! write (iout,*) "eps2der",eps2der," eps3der",eps3der,&
12372 ! write (iout,*) "eps1_om12",eps1_om12," eps2rt_om12",eps2rt_om12
12373 ! write (iout,*) "eom1",eom1," eom2",eom2," eom12",eom12
12374 !C print *,sss_ele_cut,'in sc_grad'
12376 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
12377 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
12380 gg(k)=(gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k))*sss_ele_cut
12381 !C print *,'gg',k,gg(k)
12383 ! print *,i,j,gg_lipi(3),gg_lipj(3),sss_ele_cut
12384 ! write (iout,*) "gg",(gg(k),k=1,3)
12386 gvdwx(k,i)=gvdwx(k,i)-gg(k) +gg_lipi(k)&
12387 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
12388 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv &
12391 gvdwx(k,j)=gvdwx(k,j)+gg(k)+gg_lipj(k)&
12392 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
12393 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv &
12396 ! write (iout,*)(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
12397 ! +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
12398 ! write (iout,*)(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
12399 ! +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
12402 ! Calculate the components of the gradient in DC and X
12406 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
12410 gvdwc(l,i)=gvdwc(l,i)-gg(l)+gg_lipi(l)
12411 gvdwc(l,j)=gvdwc(l,j)+gg(l)+gg_lipj(l)
12414 end subroutine sc_grad
12416 subroutine sc_grad_cat
12418 real(kind=8), dimension(3) :: dcosom1,dcosom2
12419 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1 &
12420 +dCAVdOM1+ dGCLdOM1+ dPOLdOM1
12421 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2 &
12422 +dCAVdOM2+ dGCLdOM2+ dPOLdOM2
12424 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12 &
12425 -2.0D0*alf12*eps3der+sigder*sigsq_om12&
12426 +dCAVdOM12+ dGCLdOM12
12430 ! eom12=evdwij*eps1_om12
12434 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
12435 dcosom2(k)=rij*(dc_norm(k,j)-om2*erij(k))
12438 gg(k)=(gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k))
12439 !C print *,'gg',k,gg(k)
12441 ! print *,i,j,gg_lipi(3),gg_lipj(3),sss_ele_cut
12442 ! write (iout,*) "gg",(gg(k),k=1,3)
12444 gradpepcatx(k,i)=gradpepcatx(k,i)-gg(k) &
12445 +(eom12*(dc_norm(k,j)-om12*dc_norm(k,nres+i)) &
12446 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
12448 ! gradpepcatx(k,j)=gradpepcatx(k,j)+gg(k) &
12449 ! +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,j)) &
12450 ! +eom2*(erij(k)-om2*dc_norm(k,j)))*dscj_inv
12452 ! write (iout,*)(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
12453 ! +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
12454 ! write (iout,*)(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
12455 ! +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
12458 ! Calculate the components of the gradient in DC and X
12461 gradpepcat(l,i)=gradpepcat(l,i)-gg(l)
12462 gradpepcat(l,j)=gradpepcat(l,j)+gg(l)
12464 end subroutine sc_grad_cat
12466 subroutine sc_grad_cat_pep
12468 real(kind=8), dimension(3) :: dcosom1,dcosom2
12469 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1 &
12470 +dCAVdOM1+ dGCLdOM1+ dPOLdOM1
12471 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2 &
12472 +dCAVdOM2+ dGCLdOM2+ dPOLdOM2
12474 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12 &
12475 -2.0D0*alf12*eps3der+sigder*sigsq_om12&
12476 +dCAVdOM12+ dGCLdOM12
12480 ! eom12=evdwij*eps1_om12
12484 dcosom1(k) = rij * (dc_norm(k,i) - om1 * erij(k))
12485 dcosom2(k) = rij * (dc_norm(k,nres+j) - om2 * erij(k))
12486 gg(k) = gg(k) + eom1 * dcosom1(k) + eom2 * dcosom2(k)
12487 gvdwc_pepbase(k,i)= gvdwc_pepbase(k,i) +0.5*(- gg(k)) &
12488 + (-eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,i)))&
12490 - (eom1*(erij(k)-om1*dc_norm(k,i)))*dsci_inv*2.0
12491 gvdwc_pepbase(k,i+1)= gvdwc_pepbase(k,i+1) +0.5*(- gg(k)) &
12492 - (-eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,i))) &
12494 + (eom1*(erij(k)-om1*dc_norm(k,i)))*dsci_inv*2.0
12495 gradpepcat(k,j)=gradpepcat(k,j)+gg(k)
12497 end subroutine sc_grad_cat_pep
12500 !-----------------------------------------------------------------------------
12501 subroutine mixder(thetai,thet_pred_mean,theta0i,E_tc_t)
12504 ! implicit real*8 (a-h,o-z)
12505 ! include 'DIMENSIONS'
12506 ! include 'COMMON.LOCAL'
12507 ! include 'COMMON.IOUNITS'
12508 !el real(kind=8) :: term1,term2,termm,diffak,ratak,&
12509 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
12510 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,
12511 real(kind=8) :: thetai,thet_pred_mean,theta0i,E_tc_t
12512 real(kind=8) :: t3,t6,t9,t12,t14,t16,t21,t23,t26,t27,t32,t40
12514 !el common /calcthet/ term1,term2,termm,diffak,ratak,&
12515 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
12516 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,it
12517 !el local variables
12519 delthec=thetai-thet_pred_mean
12520 delthe0=thetai-theta0i
12521 ! "Thank you" to MAPLE (probably spared one day of hand-differentiation).
12522 t3 = thetai-thet_pred_mean
12526 t14 = t12+t6*sigsqtc
12528 t21 = thetai-theta0i
12534 E_tc_t = -((sigcsq+2.D0*t3*sigsqtc)*t9-t14*sigcsq*t3*t16*t9 &
12535 -aktc*sig0inv*t27)/t32+(t14*t9+aktc*t26)/t40 &
12536 *(-t12*t9-ak*sig0inv*t27)
12538 end subroutine mixder
12540 !-----------------------------------------------------------------------------
12542 !-----------------------------------------------------------------------------
12544 !-----------------------------------------------------------------------------
12545 ! This subroutine calculates the derivatives of the consecutive virtual
12546 ! bond vectors and the SC vectors in the virtual-bond angles theta and
12547 ! virtual-torsional angles phi, as well as the derivatives of SC vectors
12548 ! in the angles alpha and omega, describing the location of a side chain
12549 ! in its local coordinate system.
12551 ! The derivatives are stored in the following arrays:
12553 ! DDCDV - the derivatives of virtual-bond vectors DC in theta and phi.
12554 ! The structure is as follows:
12556 ! dDC(x,2)/dT(3),...,dDC(z,2)/dT(3),0, 0, 0
12557 ! 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)
12558 ! . . . . . . . . . . . . . . . . . .
12559 ! 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)
12563 ! 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)
12565 ! DXDV - the derivatives of the side-chain vectors in theta and phi.
12566 ! The structure is same as above.
12568 ! DCDS - the derivatives of the side chain vectors in the local spherical
12569 ! andgles alph and omega:
12571 ! 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)
12572 ! 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)
12576 ! 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)
12578 ! Version of March '95, based on an early version of November '91.
12580 !**********************************************************************
12581 ! implicit real*8 (a-h,o-z)
12582 ! include 'DIMENSIONS'
12583 ! include 'COMMON.VAR'
12584 ! include 'COMMON.CHAIN'
12585 ! include 'COMMON.DERIV'
12586 ! include 'COMMON.GEO'
12587 ! include 'COMMON.LOCAL'
12588 ! include 'COMMON.INTERACT'
12589 real(kind=8),dimension(3,3,nres) :: drt,rdt,prordt,prodrt !(3,3,maxres)
12590 real(kind=8),dimension(3,3) :: dp,temp
12591 !el real(kind=8) :: fromto(3,3,maxdim) !(3,3,maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
12592 real(kind=8),dimension(3) :: xx,xx1
12593 !el local variables
12594 integer :: i,k,l,j,m,ind,ind1,jjj
12595 real(kind=8) :: alphi,omegi,theta2,dpkl,dpjk,xj,rj,dxoijk,dxoiij,&
12596 tempkl,dsci,cosalphi,sinalphi,cosomegi,sinomegi,cost2,&
12597 sint2,xp,yp,xxp,yyp,zzp,dj
12599 ! common /przechowalnia/ fromto
12600 if(.not. allocated(fromto)) allocate(fromto(3,3,maxdim))
12601 ! get the position of the jth ijth fragment of the chain coordinate system
12602 ! in the fromto array.
12603 ! indmat(i,j)=((2*(nres-2)-i)*(i-1))/2+j-1
12605 ! maxdim=(nres-1)*(nres-2)/2
12606 ! allocate(dcdv(6,maxdim),dxds(6,nres))
12607 ! calculate the derivatives of transformation matrix elements in theta
12610 !el call flush(iout) !el
12612 rdt(1,1,i)=-rt(1,2,i)
12613 rdt(1,2,i)= rt(1,1,i)
12615 rdt(2,1,i)=-rt(2,2,i)
12616 rdt(2,2,i)= rt(2,1,i)
12618 rdt(3,1,i)=-rt(3,2,i)
12619 rdt(3,2,i)= rt(3,1,i)
12623 ! derivatives in phi
12629 drt(2,1,i)= rt(3,1,i)
12630 drt(2,2,i)= rt(3,2,i)
12631 drt(2,3,i)= rt(3,3,i)
12632 drt(3,1,i)=-rt(2,1,i)
12633 drt(3,2,i)=-rt(2,2,i)
12634 drt(3,3,i)=-rt(2,3,i)
12637 ! generate the matrix products of type r(i)t(i)...r(j)t(j)
12643 temp(k,l)=rt(k,l,i)
12648 fromto(k,l,ind)=temp(k,l)
12657 dpkl=dpkl+temp(k,m)*rt(m,l,j)
12660 fromto(k,l,ind)=dpkl
12671 ! Calculate derivatives.
12677 ! Derivatives of DC(i+1) in theta(i+2)
12683 dpjk=dpjk+prod(j,l,i)*rdt(l,k,i)
12686 prordt(j,k,i)=dp(j,k)
12689 dcdv(j,ind1)=vbld(i+1)*dp(j,1)
12692 ! Derivatives of SC(i+1) in theta(i+2)
12694 xx1(1)=-0.5D0*xloc(2,i+1)
12695 xx1(2)= 0.5D0*xloc(1,i+1)
12699 xj=xj+r(j,k,i)*xx1(k)
12706 rj=rj+prod(j,k,i)*xx(k)
12711 ! Derivatives of SC(i+1) in theta(i+3). The have to be handled differently
12712 ! than the other off-diagonal derivatives.
12717 dxoiij=dxoiij+dp(j,k)*xrot(k,i+2)
12719 dxdv(j,ind1+1)=dxoiij
12721 !d print *,ind1+1,(dxdv(j,ind1+1),j=1,3)
12723 ! Derivatives of DC(i+1) in phi(i+2)
12729 dpjk=dpjk+prod(j,l,i)*drt(l,k,i)
12732 prodrt(j,k,i)=dp(j,k)
12734 dcdv(j+3,ind1)=vbld(i+1)*dp(j,1)
12737 ! Derivatives of SC(i+1) in phi(i+2)
12740 xx(3)= xloc(2,i+1)*r(2,2,i)+xloc(3,i+1)*r(2,3,i)
12741 xx(2)=-xloc(2,i+1)*r(3,2,i)-xloc(3,i+1)*r(3,3,i)
12745 rj=rj+prod(j,k,i)*xx(k)
12750 ! Derivatives of SC(i+1) in phi(i+3).
12755 dxoiij=dxoiij+dp(j,k)*xrot(k,i+2)
12757 dxdv(j+3,ind1+1)=dxoiij
12760 ! Calculate the derivatives of DC(i+1) and SC(i+1) in theta(i+3) thru
12761 ! theta(nres) and phi(i+3) thru phi(nres).
12765 ind=indmat(i+1,j+1)
12766 !d print *,'i=',i,' j=',j,' ind=',ind,' ind1=',ind1
12771 tempkl=tempkl+prordt(k,m,i)*fromto(m,l,ind)
12776 !d print '(9f8.3)',((fromto(k,l,ind),l=1,3),k=1,3)
12777 !d print '(9f8.3)',((prod(k,l,i),l=1,3),k=1,3)
12778 !d print '(9f8.3)',((temp(k,l),l=1,3),k=1,3)
12779 ! Derivatives of virtual-bond vectors in theta
12781 dcdv(k,ind1)=vbld(i+1)*temp(k,1)
12783 !d print '(3f8.3)',(dcdv(k,ind1),k=1,3)
12784 ! Derivatives of SC vectors in theta
12788 dxoijk=dxoijk+temp(k,l)*xrot(l,j+2)
12790 dxdv(k,ind1+1)=dxoijk
12793 !--- Calculate the derivatives in phi
12799 tempkl=tempkl+prodrt(k,m,i)*fromto(m,l,ind)
12805 dcdv(k+3,ind1)=vbld(i+1)*temp(k,1)
12810 dxoijk=dxoijk+temp(k,l)*xrot(l,j+2)
12812 dxdv(k+3,ind1+1)=dxoijk
12817 ! Derivatives in alpha and omega:
12820 ! dsci=dsc(itype(i,1))
12825 if(alphi.ne.alphi) alphi=100.0
12826 if(omegi.ne.omegi) omegi=-100.0
12831 !d print *,'i=',i,' dsci=',dsci,' alphi=',alphi,' omegi=',omegi
12832 cosalphi=dcos(alphi)
12833 sinalphi=dsin(alphi)
12834 cosomegi=dcos(omegi)
12835 sinomegi=dsin(omegi)
12836 temp(1,1)=-dsci*sinalphi
12837 temp(2,1)= dsci*cosalphi*cosomegi
12838 temp(3,1)=-dsci*cosalphi*sinomegi
12840 temp(2,2)=-dsci*sinalphi*sinomegi
12841 temp(3,2)=-dsci*sinalphi*cosomegi
12842 theta2=pi-0.5D0*theta(i+1)
12846 !d print *,((temp(l,k),l=1,3),k=1,2)
12850 xxp= xp*cost2+yp*sint2
12851 yyp=-xp*sint2+yp*cost2
12854 xx(2)=yyp*r(2,2,i-1)+zzp*r(2,3,i-1)
12855 xx(3)=yyp*r(3,2,i-1)+zzp*r(3,3,i-1)
12859 dj=dj+prod(k,l,i-1)*xx(l)
12867 end subroutine cartder
12868 !-----------------------------------------------------------------------------
12870 !-----------------------------------------------------------------------------
12871 subroutine check_cartgrad
12872 ! Check the gradient of Cartesian coordinates in internal coordinates.
12873 ! implicit real*8 (a-h,o-z)
12874 ! include 'DIMENSIONS'
12875 ! include 'COMMON.IOUNITS'
12876 ! include 'COMMON.VAR'
12877 ! include 'COMMON.CHAIN'
12878 ! include 'COMMON.GEO'
12879 ! include 'COMMON.LOCAL'
12880 ! include 'COMMON.DERIV'
12881 real(kind=8),dimension(6,nres) :: temp
12882 real(kind=8),dimension(3) :: xx,gg
12883 integer :: i,k,j,ii
12884 real(kind=8) :: aincr,aincr2,alphi,omegi,theti,thet,phii
12885 ! indmat(i,j)=((2*(nres-2)-i)*(i-1))/2+j-1
12887 ! Check the gradient of the virtual-bond and SC vectors in the internal
12893 write (iout,'(a)') '**************** dx/dalpha'
12897 alph(i)=alph(i)+aincr
12899 temp(k,i)=dc(k,nres+i)
12903 gg(k)=(dc(k,nres+i)-temp(k,i))/aincr
12904 xx(k)=dabs((gg(k)-dxds(k,i))/(aincr*dabs(dxds(k,i))+aincr))
12906 write (iout,'(i4,3e15.6/4x,3e15.6,3f9.3)') &
12907 i,(gg(k),k=1,3),(dxds(k,i),k=1,3),(xx(k),k=1,3)
12913 write (iout,'(a)') '**************** dx/domega'
12917 omeg(i)=omeg(i)+aincr
12919 temp(k,i)=dc(k,nres+i)
12923 gg(k)=(dc(k,nres+i)-temp(k,i))/aincr
12924 xx(k)=dabs((gg(k)-dxds(k+3,i))/ &
12925 (aincr*dabs(dxds(k+3,i))+aincr))
12927 write (iout,'(i4,3e15.6/4x,3e15.6,3f9.3)') &
12928 i,(gg(k),k=1,3),(dxds(k+3,i),k=1,3),(xx(k),k=1,3)
12934 write (iout,'(a)') '**************** dx/dtheta'
12938 theta(i)=theta(i)+aincr
12941 temp(k,j)=dc(k,nres+j)
12947 ! print *,'i=',i-2,' j=',j-1,' ii=',ii
12949 gg(k)=(dc(k,nres+j)-temp(k,j))/aincr
12950 xx(k)=dabs((gg(k)-dxdv(k,ii))/ &
12951 (aincr*dabs(dxdv(k,ii))+aincr))
12953 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
12954 i,j,(gg(k),k=1,3),(dxdv(k,ii),k=1,3),(xx(k),k=1,3)
12961 write (iout,'(a)') '***************** dx/dphi'
12964 phi(i)=phi(i)+aincr
12967 temp(k,j)=dc(k,nres+j)
12975 gg(k)=(dc(k,nres+j)-temp(k,j))/aincr
12976 xx(k)=dabs((gg(k)-dxdv(k+3,ii))/ &
12977 (aincr*dabs(dxdv(k+3,ii))+aincr))
12979 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
12980 i,j,(gg(k),k=1,3),(dxdv(k+3,ii),k=1,3),(xx(k),k=1,3)
12983 phi(i)=phi(i)-aincr
12986 write (iout,'(a)') '****************** ddc/dtheta'
12989 theta(i+2)=thet+aincr
13000 gg(k)=(dc(k,j)-temp(k,j))/aincr
13001 xx(k)=dabs((gg(k)-dcdv(k,ii))/ &
13002 (aincr*dabs(dcdv(k,ii))+aincr))
13004 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
13005 i,j,(gg(k),k=1,3),(dcdv(k,ii),k=1,3),(xx(k),k=1,3)
13015 write (iout,'(a)') '******************* ddc/dphi'
13018 phi(i+3)=phii+aincr
13029 gg(k)=(dc(k,j)-temp(k,j))/aincr
13030 xx(k)=dabs((gg(k)-dcdv(k+3,ii))/ &
13031 (aincr*dabs(dcdv(k+3,ii))+aincr))
13033 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
13034 i,j,(gg(k),k=1,3),(dcdv(k+3,ii),k=1,3),(xx(k),k=1,3)
13045 end subroutine check_cartgrad
13046 !-----------------------------------------------------------------------------
13047 subroutine check_ecart
13048 ! Check the gradient of the energy in Cartesian coordinates.
13049 ! implicit real*8 (a-h,o-z)
13050 ! include 'DIMENSIONS'
13051 ! include 'COMMON.CHAIN'
13052 ! include 'COMMON.DERIV'
13053 ! include 'COMMON.IOUNITS'
13054 ! include 'COMMON.VAR'
13055 ! include 'COMMON.CONTACTS'
13057 !el integer :: icall
13058 !el common /srutu/ icall
13059 real(kind=8),dimension(6) :: ggg
13060 real(kind=8),dimension(3) :: cc,xx,ddc,ddx
13061 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
13062 real(kind=8),dimension(6,nres) :: grad_s
13063 real(kind=8),dimension(0:n_ene) :: energia,energia1
13064 integer :: uiparm(1)
13065 real(kind=8) :: urparm(1)
13067 integer :: nf,i,j,k
13068 real(kind=8) :: aincr,etot,etot1
13074 print '(a)','CG processor',me,' calling CHECK_CART.',aincr
13077 call geom_to_var(nvar,x)
13078 call etotal(energia)
13080 !el call enerprint(energia)
13081 call gradient(nvar,x,nf,g,uiparm,urparm,fdum)
13084 write (iout,'(i5,3f10.5)') i,(gradxorr(j,i),j=1,3)
13088 grad_s(j,i)=gradc(j,i,icg)
13089 grad_s(j+3,i)=gradx(j,i,icg)
13093 write (iout,'(/a/)') 'Gradient in virtual-bond and SC vectors'
13098 ddx(j)=dc(j,i+nres)
13101 dc(j,i)=dc(j,i)+aincr
13103 c(j,k)=c(j,k)+aincr
13104 c(j,k+nres)=c(j,k+nres)+aincr
13107 call etotal(energia1)
13109 ggg(j)=(etot1-etot)/aincr
13112 c(j,k)=c(j,k)-aincr
13113 c(j,k+nres)=c(j,k+nres)-aincr
13117 c(j,i+nres)=c(j,i+nres)+aincr
13118 dc(j,i+nres)=dc(j,i+nres)+aincr
13120 call etotal(energia1)
13122 ggg(j+3)=(etot1-etot)/aincr
13124 dc(j,i+nres)=ddx(j)
13126 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/)') &
13127 i,(ggg(k),k=1,6),(grad_s(k,i),k=1,6)
13130 end subroutine check_ecart
13132 !-----------------------------------------------------------------------------
13133 subroutine check_ecartint
13134 ! Check the gradient of the energy in Cartesian coordinates.
13135 use io_base, only: intout
13136 use MD_data, only: iset
13137 ! implicit real*8 (a-h,o-z)
13138 ! include 'DIMENSIONS'
13139 ! include 'COMMON.CONTROL'
13140 ! include 'COMMON.CHAIN'
13141 ! include 'COMMON.DERIV'
13142 ! include 'COMMON.IOUNITS'
13143 ! include 'COMMON.VAR'
13144 ! include 'COMMON.CONTACTS'
13145 ! include 'COMMON.MD'
13146 ! include 'COMMON.LOCAL'
13147 ! include 'COMMON.SPLITELE'
13149 !el integer :: icall
13150 !el common /srutu/ icall
13151 real(kind=8),dimension(6) :: ggg,ggg1
13152 real(kind=8),dimension(3) :: cc,xx,ddc,ddx,ddc1,ddcn
13153 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
13154 real(kind=8),dimension(3) :: dcnorm_safe1,dcnorm_safe2,dxnorm_safe
13155 real(kind=8),dimension(6,0:nres) :: grad_s,grad_s1 !(6,0:maxres)
13156 real(kind=8),dimension(nres) :: phi_temp,theta_temp,alph_temp,omeg_temp !(maxres)
13157 real(kind=8),dimension(0:n_ene) :: energia,energia1
13158 integer :: uiparm(1)
13159 real(kind=8) :: urparm(1)
13161 integer :: i,j,k,nf
13162 real(kind=8) :: rlambd,aincr,etot,etot1,etot11,etot12,etot2,&
13169 if (iset.eq.0) iset=1
13171 ! call intcartderiv
13172 ! call checkintcartgrad
13175 write(iout,*) 'Calling CHECK_ECARTINT.'
13178 call geom_to_var(nvar,x)
13179 write (iout,*) "split_ene ",split_ene
13181 if (.not.split_ene) then
13183 call etotal(energia)
13188 write (iout,'(i5,3f10.5)') i,(gradxorr(j,i),j=1,3)
13191 grad_s(j,0)=gcart(j,0)
13195 grad_s(j,i)=gcart(j,i)
13196 grad_s(j+3,i)=gxcart(j,i)
13200 !- split gradient check
13202 call etotal_long(energia)
13203 !el call enerprint(energia)
13207 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
13208 (gxcart(j,i),j=1,3)
13211 grad_s(j,0)=gcart(j,0)
13215 grad_s(j,i)=gcart(j,i)
13216 grad_s(j+3,i)=gxcart(j,i)
13220 call etotal_short(energia)
13221 call enerprint(energia)
13225 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
13226 (gxcart(j,i),j=1,3)
13229 grad_s1(j,0)=gcart(j,0)
13233 grad_s1(j,i)=gcart(j,i)
13234 grad_s1(j+3,i)=gxcart(j,i)
13238 write (iout,'(/a/)') 'Gradient in virtual-bond and SC vectors'
13242 if (nnt.gt.1 .and. i.eq.nnt) ddc1(j)=c(j,1)
13243 if (nct.lt.nres .and. i.eq.nct) ddcn(j)=c(j,nres)
13246 dcnorm_safe1(j)=dc_norm(j,i-1)
13247 dcnorm_safe2(j)=dc_norm(j,i)
13248 dxnorm_safe(j)=dc_norm(j,i+nres)
13251 c(j,i)=ddc(j)+aincr
13252 if (nnt.gt.1 .and. i.eq.nnt) c(j,1)=c(j,1)+aincr
13253 if (nct.lt.nres .and. i.eq.nct) c(j,nres)=c(j,nres)+aincr
13254 if (i.gt.1) dc(j,i-1)=c(j,i)-c(j,i-1)
13255 dc(j,i)=c(j,i+1)-c(j,i)
13256 dc(j,i+nres)=c(j,i+nres)-c(j,i)
13257 call int_from_cart1(.false.)
13258 if (.not.split_ene) then
13260 call etotal(energia1)
13262 write (iout,*) "ij",i,j," etot1",etot1
13265 call etotal_long(energia1)
13267 call etotal_short(energia1)
13270 !- end split gradient
13271 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot1",etot1
13272 c(j,i)=ddc(j)-aincr
13273 if (nnt.gt.1 .and. i.eq.nnt) c(j,1)=ddc1(j)-aincr
13274 if (nct.lt.nres .and. i.eq.nct) c(j,nres)=ddcn(j)-aincr
13275 if (i.gt.1) dc(j,i-1)=c(j,i)-c(j,i-1)
13276 dc(j,i)=c(j,i+1)-c(j,i)
13277 dc(j,i+nres)=c(j,i+nres)-c(j,i)
13278 call int_from_cart1(.false.)
13279 if (.not.split_ene) then
13281 call etotal(energia1)
13283 write (iout,*) "ij",i,j," etot2",etot2
13284 ggg(j)=(etot1-etot2)/(2*aincr)
13287 call etotal_long(energia1)
13289 ggg(j)=(etot11-etot21)/(2*aincr)
13290 call etotal_short(energia1)
13292 ggg1(j)=(etot12-etot22)/(2*aincr)
13293 !- end split gradient
13294 ! write (iout,*) "etot21",etot21," etot22",etot22
13296 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
13298 if (nnt.gt.1 .and. i.eq.nnt) c(j,1)=ddc1(j)
13299 if (nct.lt.nres .and. i.eq.nct) c(j,nres)=ddcn(j)
13300 if (i.gt.1) dc(j,i-1)=c(j,i)-c(j,i-1)
13301 dc(j,i)=c(j,i+1)-c(j,i)
13302 dc(j,i+nres)=c(j,i+nres)-c(j,i)
13303 dc_norm(j,i-1)=dcnorm_safe1(j)
13304 dc_norm(j,i)=dcnorm_safe2(j)
13305 dc_norm(j,i+nres)=dxnorm_safe(j)
13308 c(j,i+nres)=ddx(j)+aincr
13309 dc(j,i+nres)=c(j,i+nres)-c(j,i)
13310 call int_from_cart1(.false.)
13311 if (.not.split_ene) then
13313 call etotal(energia1)
13317 call etotal_long(energia1)
13319 call etotal_short(energia1)
13322 !- end split gradient
13323 c(j,i+nres)=ddx(j)-aincr
13324 dc(j,i+nres)=c(j,i+nres)-c(j,i)
13325 call int_from_cart1(.false.)
13326 if (.not.split_ene) then
13328 call etotal(energia1)
13330 ggg(j+3)=(etot1-etot2)/(2*aincr)
13333 call etotal_long(energia1)
13335 ggg(j+3)=(etot11-etot21)/(2*aincr)
13336 call etotal_short(energia1)
13338 ggg1(j+3)=(etot12-etot22)/(2*aincr)
13339 !- end split gradient
13341 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
13343 dc(j,i+nres)=c(j,i+nres)-c(j,i)
13344 dc_norm(j,i+nres)=dxnorm_safe(j)
13345 call int_from_cart1(.false.)
13347 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
13348 i,(ggg(k),k=1,6),(grad_s(k,i),k=1,6),(ggg(k)/grad_s(k,i),k=1,6)
13349 if (split_ene) then
13350 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
13351 i,(ggg1(k),k=1,6),(grad_s1(k,i),k=1,6),(ggg1(k)/grad_s1(k,i),&
13353 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
13354 i,(ggg(k)+ggg1(k),k=1,6),(grad_s(k,i)+grad_s1(k,i),k=1,6),&
13355 ((ggg(k)+ggg1(k))/(grad_s(k,i)+grad_s1(k,i)),k=1,6)
13359 end subroutine check_ecartint
13361 !-----------------------------------------------------------------------------
13362 subroutine check_ecartint
13363 ! Check the gradient of the energy in Cartesian coordinates.
13364 use io_base, only: intout
13365 use MD_data, only: iset
13366 ! implicit real*8 (a-h,o-z)
13367 ! include 'DIMENSIONS'
13368 ! include 'COMMON.CONTROL'
13369 ! include 'COMMON.CHAIN'
13370 ! include 'COMMON.DERIV'
13371 ! include 'COMMON.IOUNITS'
13372 ! include 'COMMON.VAR'
13373 ! include 'COMMON.CONTACTS'
13374 ! include 'COMMON.MD'
13375 ! include 'COMMON.LOCAL'
13376 ! include 'COMMON.SPLITELE'
13378 !el integer :: icall
13379 !el common /srutu/ icall
13380 real(kind=8),dimension(6) :: ggg,ggg1
13381 real(kind=8),dimension(3) :: cc,xx,ddc,ddx
13382 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
13383 real(kind=8),dimension(3) :: dcnorm_safe,dxnorm_safe
13384 real(kind=8),dimension(6,0:nres) :: grad_s,grad_s1 !(6,0:maxres)
13385 real(kind=8),dimension(nres) :: phi_temp,theta_temp,alph_temp,omeg_temp !(maxres)
13386 real(kind=8),dimension(0:n_ene) :: energia,energia1
13387 integer :: uiparm(1)
13388 real(kind=8) :: urparm(1)
13390 integer :: i,j,k,nf
13391 real(kind=8) :: rlambd,aincr,etot,etot1,etot11,etot12,etot2,&
13398 if (iset.eq.0) iset=1
13400 ! call intcartderiv
13401 ! call checkintcartgrad
13404 write(iout,*) 'Calling CHECK_ECARTINT.',aincr
13407 call geom_to_var(nvar,x)
13408 if (.not.split_ene) then
13409 call etotal(energia)
13411 !el call enerprint(energia)
13415 write (iout,'(i5,3f10.5)') i,(gradxorr(j,i),j=1,3)
13418 grad_s(j,0)=gcart(j,0)
13419 grad_s(j+3,0)=gxcart(j,0)
13423 grad_s(j,i)=gcart(j,i)
13424 ! if (i.eq.21) print *,"PRZEKAZANIE",gcart(j,i)
13426 ! if (i.le.2) print *,"tu?!",gcart(j,i),grad_s(j,i),gxcart(j,i)
13427 grad_s(j+3,i)=gxcart(j,i)
13431 !- split gradient check
13433 call etotal_long(energia)
13434 !el call enerprint(energia)
13438 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
13439 (gxcart(j,i),j=1,3)
13442 grad_s(j,0)=gcart(j,0)
13446 grad_s(j,i)=gcart(j,i)
13447 ! if (i.eq.21) print *,"PRZEKAZANIE",gcart(j,i)
13448 grad_s(j+3,i)=gxcart(j,i)
13452 call etotal_short(energia)
13453 !el call enerprint(energia)
13457 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
13458 (gxcart(j,i),j=1,3)
13461 grad_s1(j,0)=gcart(j,0)
13465 grad_s1(j,i)=gcart(j,i)
13466 grad_s1(j+3,i)=gxcart(j,i)
13470 write (iout,'(/a/)') 'Gradient in virtual-bond and SC vectors'
13475 ddx(j)=dc(j,i+nres)
13477 dcnorm_safe(k)=dc_norm(k,i)
13478 dxnorm_safe(k)=dc_norm(k,i+nres)
13482 dc(j,i)=ddc(j)+aincr
13483 call chainbuild_cart
13485 ! Broadcast the order to compute internal coordinates to the slaves.
13486 ! if (nfgtasks.gt.1)
13487 ! & call MPI_Bcast(6,1,MPI_INTEGER,king,FG_COMM,IERROR)
13489 ! call int_from_cart1(.false.)
13490 if (.not.split_ene) then
13492 call etotal(energia1)
13494 ! call enerprint(energia1)
13497 call etotal_long(energia1)
13499 call etotal_short(energia1)
13501 ! write (iout,*) "etot11",etot11," etot12",etot12
13503 !- end split gradient
13504 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot1",etot1
13505 dc(j,i)=ddc(j)-aincr
13506 call chainbuild_cart
13507 ! call int_from_cart1(.false.)
13508 if (.not.split_ene) then
13510 call etotal(energia1)
13512 ggg(j)=(etot1-etot2)/(2*aincr)
13515 call etotal_long(energia1)
13517 ggg(j)=(etot11-etot21)/(2*aincr)
13518 call etotal_short(energia1)
13520 ggg1(j)=(etot12-etot22)/(2*aincr)
13521 !- end split gradient
13522 ! write (iout,*) "etot21",etot21," etot22",etot22
13524 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
13526 call chainbuild_cart
13529 dc(j,i+nres)=ddx(j)+aincr
13530 call chainbuild_cart
13531 ! write (iout,*) "i",i," j",j," dxnorm+ and dxnorm"
13532 ! write (iout,'(3f15.10)') (dc_norm(k,i+nres),k=1,3)
13533 ! write (iout,'(3f15.10)') (dxnorm_safe(k),k=1,3)
13534 ! write (iout,*) "dxnormnorm",dsqrt(
13535 ! & dc_norm(1,i+nres)**2+dc_norm(2,i+nres)**2+dc_norm(3,i+nres)**2)
13536 ! write (iout,*) "dxnormnormsafe",dsqrt(
13537 ! & dxnorm_safe(1)**2+dxnorm_safe(2)**2+dxnorm_safe(3)**2)
13539 if (.not.split_ene) then
13541 call etotal(energia1)
13545 call etotal_long(energia1)
13547 call etotal_short(energia1)
13550 !- end split gradient
13551 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot1",etot1
13552 dc(j,i+nres)=ddx(j)-aincr
13553 call chainbuild_cart
13554 ! write (iout,*) "i",i," j",j," dxnorm- and dxnorm"
13555 ! write (iout,'(3f15.10)') (dc_norm(k,i+nres),k=1,3)
13556 ! write (iout,'(3f15.10)') (dxnorm_safe(k),k=1,3)
13558 ! write (iout,*) "dxnormnorm",dsqrt(
13559 ! & dc_norm(1,i+nres)**2+dc_norm(2,i+nres)**2+dc_norm(3,i+nres)**2)
13560 ! write (iout,*) "dxnormnormsafe",dsqrt(
13561 ! & dxnorm_safe(1)**2+dxnorm_safe(2)**2+dxnorm_safe(3)**2)
13562 if (.not.split_ene) then
13564 call etotal(energia1)
13566 ggg(j+3)=(etot1-etot2)/(2*aincr)
13569 call etotal_long(energia1)
13571 ggg(j+3)=(etot11-etot21)/(2*aincr)
13572 call etotal_short(energia1)
13574 ggg1(j+3)=(etot12-etot22)/(2*aincr)
13575 !- end split gradient
13577 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
13578 dc(j,i+nres)=ddx(j)
13579 call chainbuild_cart
13581 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
13582 i,(ggg(k),k=1,6),(grad_s(k,i),k=1,6),(ggg(k)/grad_s(k,i),k=1,6)
13583 if (split_ene) then
13584 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
13585 i,(ggg1(k),k=1,6),(grad_s1(k,i),k=1,6),(ggg1(k)/grad_s1(k,i),&
13587 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
13588 i,(ggg(k)+ggg1(k),k=1,6),(grad_s(k,i)+grad_s1(k,i),k=1,6),&
13589 ((ggg(k)+ggg1(k))/(grad_s(k,i)+grad_s1(k,i)),k=1,6)
13593 end subroutine check_ecartint
13595 !-----------------------------------------------------------------------------
13596 subroutine check_eint
13597 ! Check the gradient of energy in internal coordinates.
13598 ! implicit real*8 (a-h,o-z)
13599 ! include 'DIMENSIONS'
13600 ! include 'COMMON.CHAIN'
13601 ! include 'COMMON.DERIV'
13602 ! include 'COMMON.IOUNITS'
13603 ! include 'COMMON.VAR'
13604 ! include 'COMMON.GEO'
13606 !el integer :: icall
13607 !el common /srutu/ icall
13608 real(kind=8),dimension(6*nres) :: x,gana,gg !(maxvar) (maxvar=6*maxres)
13609 integer :: uiparm(1)
13610 real(kind=8) :: urparm(1)
13611 real(kind=8),dimension(0:n_ene) :: energia,energia1,energia2
13612 character(len=6) :: key
13615 real(kind=8) :: xi,aincr,etot,etot1,etot2
13618 print '(a)','Calling CHECK_INT.'
13622 call geom_to_var(nvar,x)
13623 call var_to_geom(nvar,x)
13626 ! print *,'ICG=',ICG
13627 call etotal(energia)
13629 !el call enerprint(energia)
13630 ! print *,'ICG=',ICG
13632 if (MyID.ne.BossID) then
13633 call mp_bcast(x(1),8*(nvar+3),BossID,fgGroupID)
13641 !d write (iout,'(10f8.3)') (rad2deg*x(i),i=1,nvar)
13642 call gradient(nvar,x,nf,gana,uiparm,urparm,fdum)
13643 !d write (iout,'(i3,1pe14.4)') (i,gana(i),i=1,nvar+20) !sp
13647 x(i)=xi-0.5D0*aincr
13648 call var_to_geom(nvar,x)
13650 call etotal(energia1)
13652 x(i)=xi+0.5D0*aincr
13653 call var_to_geom(nvar,x)
13655 call etotal(energia2)
13657 gg(i)=(etot2-etot1)/aincr
13658 write (iout,*) i,etot1,etot2
13661 write (iout,'(/2a)')' Variable Numerical Analytical',&
13664 if (i.le.nphi) then
13667 else if (i.le.nphi+ntheta) then
13670 else if (i.le.nphi+ntheta+nside) then
13674 ii=i-(nphi+ntheta+nside)
13677 write (iout,'(i3,a,i3,3(1pd16.6))') &
13678 i,key,ii,gg(i),gana(i),&
13679 100.0D0*dabs(gg(i)-gana(i))/(dabs(gana(i))+aincr)
13682 end subroutine check_eint
13683 !-----------------------------------------------------------------------------
13685 !-----------------------------------------------------------------------------
13686 subroutine Econstr_back
13687 ! MD with umbrella_sampling using Wolyne's distance measure as a constraint
13688 ! implicit real*8 (a-h,o-z)
13689 ! include 'DIMENSIONS'
13690 ! include 'COMMON.CONTROL'
13691 ! include 'COMMON.VAR'
13692 ! include 'COMMON.MD'
13695 ! include 'COMMON.LANGEVIN'
13697 ! include 'COMMON.LANGEVIN.lang0'
13699 ! include 'COMMON.CHAIN'
13700 ! include 'COMMON.DERIV'
13701 ! include 'COMMON.GEO'
13702 ! include 'COMMON.LOCAL'
13703 ! include 'COMMON.INTERACT'
13704 ! include 'COMMON.IOUNITS'
13705 ! include 'COMMON.NAMES'
13706 ! include 'COMMON.TIME1'
13707 integer :: i,j,ii,k
13708 real(kind=8) :: utheta_i,dtheta_i,ugamma_i,dgamma_i,dxx,dyy,dzz
13710 if(.not.allocated(utheta)) allocate(utheta(nfrag_back))
13711 if(.not.allocated(ugamma)) allocate(ugamma(nfrag_back))
13712 if(.not.allocated(uscdiff)) allocate(uscdiff(nfrag_back))
13719 duscdiff(j,i)=0.0d0
13720 duscdiffx(j,i)=0.0d0
13724 ii = ifrag_back(2,i,iset)-ifrag_back(1,i,iset)
13726 ! Deviations from theta angles
13729 do j=ifrag_back(1,i,iset)+2,ifrag_back(2,i,iset)
13730 dtheta_i=theta(j)-thetaref(j)
13731 utheta_i=utheta_i+0.5d0*dtheta_i*dtheta_i
13732 dutheta(j-2)=dutheta(j-2)+wfrag_back(1,i,iset)*dtheta_i/(ii-1)
13734 utheta(i)=utheta_i/(ii-1)
13736 ! Deviations from gamma angles
13739 do j=ifrag_back(1,i,iset)+3,ifrag_back(2,i,iset)
13740 dgamma_i=pinorm(phi(j)-phiref(j))
13741 ! write (iout,*) j,phi(j),phi(j)-phiref(j)
13742 ugamma_i=ugamma_i+0.5d0*dgamma_i*dgamma_i
13743 dugamma(j-3)=dugamma(j-3)+wfrag_back(2,i,iset)*dgamma_i/(ii-2)
13744 ! write (iout,*) i,j,dgamma_i,wfrag_back(2,i,iset),dugamma(j-3)
13746 ugamma(i)=ugamma_i/(ii-2)
13748 ! Deviations from local SC geometry
13751 do j=ifrag_back(1,i,iset)+1,ifrag_back(2,i,iset)-1
13752 dxx=xxtab(j)-xxref(j)
13753 dyy=yytab(j)-yyref(j)
13754 dzz=zztab(j)-zzref(j)
13755 uscdiff(i)=uscdiff(i)+dxx*dxx+dyy*dyy+dzz*dzz
13757 duscdiff(k,j-1)=duscdiff(k,j-1)+wfrag_back(3,i,iset)* &
13758 (dXX_C1tab(k,j)*dxx+dYY_C1tab(k,j)*dyy+dZZ_C1tab(k,j)*dzz)/ &
13760 duscdiff(k,j)=duscdiff(k,j)+wfrag_back(3,i,iset)* &
13761 (dXX_Ctab(k,j)*dxx+dYY_Ctab(k,j)*dyy+dZZ_Ctab(k,j)*dzz)/ &
13763 duscdiffx(k,j)=duscdiffx(k,j)+wfrag_back(3,i,iset)* &
13764 (dXX_XYZtab(k,j)*dxx+dYY_XYZtab(k,j)*dyy+dZZ_XYZtab(k,j)*dzz) &
13767 ! write (iout,'(i5,6f10.5)') j,xxtab(j),yytab(j),zztab(j),
13768 ! & xxref(j),yyref(j),zzref(j)
13770 uscdiff(i)=0.5d0*uscdiff(i)/(ii-1)
13771 ! write (iout,*) i," uscdiff",uscdiff(i)
13773 ! Put together deviations from local geometry
13775 Uconst_back=Uconst_back+wfrag_back(1,i,iset)*utheta(i)+ &
13776 wfrag_back(2,i,iset)*ugamma(i)+wfrag_back(3,i,iset)*uscdiff(i)
13777 ! write(iout,*) "i",i," utheta",utheta(i)," ugamma",ugamma(i),
13778 ! & " uconst_back",uconst_back
13779 utheta(i)=dsqrt(utheta(i))
13780 ugamma(i)=dsqrt(ugamma(i))
13781 uscdiff(i)=dsqrt(uscdiff(i))
13784 end subroutine Econstr_back
13785 !-----------------------------------------------------------------------------
13786 ! energy_p_new-sep_barrier.F
13787 !-----------------------------------------------------------------------------
13788 real(kind=8) function sscale(r)
13789 ! include "COMMON.SPLITELE"
13790 real(kind=8) :: r,gamm
13791 if(r.lt.r_cut-rlamb) then
13793 else if(r.le.r_cut.and.r.ge.r_cut-rlamb) then
13794 gamm=(r-(r_cut-rlamb))/rlamb
13795 sscale=1.0d0+gamm*gamm*(2*gamm-3.0d0)
13800 end function sscale
13801 real(kind=8) function sscale_grad(r)
13802 ! include "COMMON.SPLITELE"
13803 real(kind=8) :: r,gamm
13804 if(r.lt.r_cut-rlamb) then
13806 else if(r.le.r_cut.and.r.ge.r_cut-rlamb) then
13807 gamm=(r-(r_cut-rlamb))/rlamb
13808 sscale_grad=gamm*(6*gamm-6.0d0)/rlamb
13813 end function sscale_grad
13815 !!!!!!!!!! PBCSCALE
13816 real(kind=8) function sscale_ele(r)
13817 ! include "COMMON.SPLITELE"
13818 real(kind=8) :: r,gamm
13819 if(r.lt.r_cut_ele-rlamb_ele) then
13821 else if(r.le.r_cut_ele.and.r.ge.r_cut_ele-rlamb_ele) then
13822 gamm=(r-(r_cut_ele-rlamb_ele))/rlamb_ele
13823 sscale_ele=1.0d0+gamm*gamm*(2*gamm-3.0d0)
13828 end function sscale_ele
13830 real(kind=8) function sscagrad_ele(r)
13831 real(kind=8) :: r,gamm
13832 ! include "COMMON.SPLITELE"
13833 if(r.lt.r_cut_ele-rlamb_ele) then
13835 else if(r.le.r_cut_ele.and.r.ge.r_cut_ele-rlamb_ele) then
13836 gamm=(r-(r_cut_ele-rlamb_ele))/rlamb_ele
13837 sscagrad_ele=gamm*(6*gamm-6.0d0)/rlamb_ele
13842 end function sscagrad_ele
13843 real(kind=8) function sscalelip(r)
13844 real(kind=8) r,gamm
13845 sscalelip=1.0d0+r*r*(2.0d0*r-3.0d0)
13847 end function sscalelip
13848 !C-----------------------------------------------------------------------
13849 real(kind=8) function sscagradlip(r)
13850 real(kind=8) r,gamm
13851 sscagradlip=r*(6.0d0*r-6.0d0)
13853 end function sscagradlip
13856 !-----------------------------------------------------------------------------
13857 subroutine elj_long(evdw)
13859 ! This subroutine calculates the interaction energy of nonbonded side chains
13860 ! assuming the LJ potential of interaction.
13862 ! implicit real*8 (a-h,o-z)
13863 ! include 'DIMENSIONS'
13864 ! include 'COMMON.GEO'
13865 ! include 'COMMON.VAR'
13866 ! include 'COMMON.LOCAL'
13867 ! include 'COMMON.CHAIN'
13868 ! include 'COMMON.DERIV'
13869 ! include 'COMMON.INTERACT'
13870 ! include 'COMMON.TORSION'
13871 ! include 'COMMON.SBRIDGE'
13872 ! include 'COMMON.NAMES'
13873 ! include 'COMMON.IOUNITS'
13874 ! include 'COMMON.CONTACTS'
13875 real(kind=8),parameter :: accur=1.0d-10
13876 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
13877 !el local variables
13878 integer :: i,iint,j,k,itypi,itypi1,itypj
13879 real(kind=8) :: xi,yi,zi,xj,yj,zj,rij,sss,rrij,fac,eps0ij
13880 real(kind=8) :: e1,e2,evdwij,evdw,sslipi,ssgradlipi,&
13881 sslipj,ssgradlipj,aa,bb
13882 ! write(iout,*)'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
13884 do i=iatsc_s,iatsc_e
13886 if (itypi.eq.ntyp1) cycle
13887 itypi1=itype(i+1,1)
13891 call to_box(xi,yi,zi)
13892 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
13894 ! Calculate SC interaction energy.
13896 do iint=1,nint_gr(i)
13897 !d write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
13898 !d & 'iend=',iend(i,iint)
13899 do j=istart(i,iint),iend(i,iint)
13901 if (itypj.eq.ntyp1) cycle
13905 call to_box(xj,yj,zj)
13906 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
13907 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
13908 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
13909 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
13910 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
13911 xj=boxshift(xj-xi,boxxsize)
13912 yj=boxshift(yj-yi,boxysize)
13913 zj=boxshift(zj-zi,boxzsize)
13914 rij=xj*xj+yj*yj+zj*zj
13915 sss=sscale(dsqrt(rij)/sigma(itypi,itypj))
13916 if (sss.lt.1.0d0) then
13918 eps0ij=eps(itypi,itypj)
13920 e1=fac*fac*aa_aq(itypi,itypj)
13921 e2=fac*bb_aq(itypi,itypj)
13923 evdw=evdw+(1.0d0-sss)*evdwij
13925 ! Calculate the components of the gradient in DC and X
13927 fac=-rrij*(e1+evdwij)*(1.0d0-sss)
13932 gvdwx(k,i)=gvdwx(k,i)-gg(k)
13933 gvdwx(k,j)=gvdwx(k,j)+gg(k)
13934 gvdwc(k,i)=gvdwc(k,i)-gg(k)
13935 gvdwc(k,j)=gvdwc(k,j)+gg(k)
13943 gvdwc(j,i)=expon*gvdwc(j,i)
13944 gvdwx(j,i)=expon*gvdwx(j,i)
13947 !******************************************************************************
13951 ! To save time, the factor of EXPON has been extracted from ALL components
13952 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
13955 !******************************************************************************
13957 end subroutine elj_long
13958 !-----------------------------------------------------------------------------
13959 subroutine elj_short(evdw)
13961 ! This subroutine calculates the interaction energy of nonbonded side chains
13962 ! assuming the LJ potential of interaction.
13964 ! implicit real*8 (a-h,o-z)
13965 ! include 'DIMENSIONS'
13966 ! include 'COMMON.GEO'
13967 ! include 'COMMON.VAR'
13968 ! include 'COMMON.LOCAL'
13969 ! include 'COMMON.CHAIN'
13970 ! include 'COMMON.DERIV'
13971 ! include 'COMMON.INTERACT'
13972 ! include 'COMMON.TORSION'
13973 ! include 'COMMON.SBRIDGE'
13974 ! include 'COMMON.NAMES'
13975 ! include 'COMMON.IOUNITS'
13976 ! include 'COMMON.CONTACTS'
13977 real(kind=8),parameter :: accur=1.0d-10
13978 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
13979 !el local variables
13980 integer :: i,iint,j,k,itypi,itypi1,itypj,num_conti
13981 real(kind=8) :: xi,yi,zi,xj,yj,zj,rij,sss,rrij,fac,eps0ij
13982 real(kind=8) :: e1,e2,evdwij,evdw,sslipi,ssgradlipi,&
13984 ! write(iout,*)'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
13986 do i=iatsc_s,iatsc_e
13988 if (itypi.eq.ntyp1) cycle
13989 itypi1=itype(i+1,1)
13993 call to_box(xi,yi,zi)
13994 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
13998 ! Calculate SC interaction energy.
14000 do iint=1,nint_gr(i)
14001 !d write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
14002 !d & 'iend=',iend(i,iint)
14003 do j=istart(i,iint),iend(i,iint)
14005 if (itypj.eq.ntyp1) cycle
14009 ! Change 12/1/95 to calculate four-body interactions
14010 rij=xj*xj+yj*yj+zj*zj
14011 sss=sscale(dsqrt(rij)/sigma(itypi,itypj))
14012 if (sss.gt.0.0d0) then
14014 eps0ij=eps(itypi,itypj)
14016 e1=fac*fac*aa_aq(itypi,itypj)
14017 e2=fac*bb_aq(itypi,itypj)
14019 evdw=evdw+sss*evdwij
14021 ! Calculate the components of the gradient in DC and X
14023 fac=-rrij*(e1+evdwij)*sss
14028 gvdwx(k,i)=gvdwx(k,i)-gg(k)
14029 gvdwx(k,j)=gvdwx(k,j)+gg(k)
14030 gvdwc(k,i)=gvdwc(k,i)-gg(k)
14031 gvdwc(k,j)=gvdwc(k,j)+gg(k)
14039 gvdwc(j,i)=expon*gvdwc(j,i)
14040 gvdwx(j,i)=expon*gvdwx(j,i)
14043 !******************************************************************************
14047 ! To save time, the factor of EXPON has been extracted from ALL components
14048 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
14051 !******************************************************************************
14053 end subroutine elj_short
14054 !-----------------------------------------------------------------------------
14055 subroutine eljk_long(evdw)
14057 ! This subroutine calculates the interaction energy of nonbonded side chains
14058 ! assuming the LJK potential of interaction.
14060 ! implicit real*8 (a-h,o-z)
14061 ! include 'DIMENSIONS'
14062 ! include 'COMMON.GEO'
14063 ! include 'COMMON.VAR'
14064 ! include 'COMMON.LOCAL'
14065 ! include 'COMMON.CHAIN'
14066 ! include 'COMMON.DERIV'
14067 ! include 'COMMON.INTERACT'
14068 ! include 'COMMON.IOUNITS'
14069 ! include 'COMMON.NAMES'
14070 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
14072 !el local variables
14073 integer :: i,iint,j,k,itypi,itypi1,itypj
14074 real(kind=8) :: rrij,r_inv_ij,xj,yj,zj,xi,yi,zi,fac,evdw,&
14075 fac_augm,e_augm,rij,sss,r_shift_inv,e1,e2,evdwij
14076 ! print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
14078 do i=iatsc_s,iatsc_e
14080 if (itypi.eq.ntyp1) cycle
14081 itypi1=itype(i+1,1)
14085 call to_box(xi,yi,zi)
14088 ! Calculate SC interaction energy.
14090 do iint=1,nint_gr(i)
14091 do j=istart(i,iint),iend(i,iint)
14093 if (itypj.eq.ntyp1) cycle
14097 call to_box(xj,yj,zj)
14098 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
14099 fac_augm=rrij**expon
14100 e_augm=augm(itypi,itypj)*fac_augm
14101 r_inv_ij=dsqrt(rrij)
14103 sss=sscale(rij/sigma(itypi,itypj))
14104 if (sss.lt.1.0d0) then
14105 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
14106 fac=r_shift_inv**expon
14107 e1=fac*fac*aa_aq(itypi,itypj)
14108 e2=fac*bb_aq(itypi,itypj)
14109 evdwij=e_augm+e1+e2
14110 !d sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
14111 !d epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
14112 !d write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
14113 !d & restyp(itypi,1),i,restyp(itypj,1),j,aa(itypi,itypj),
14114 !d & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
14115 !d & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
14116 !d & (c(k,i),k=1,3),(c(k,j),k=1,3)
14117 evdw=evdw+(1.0d0-sss)*evdwij
14119 ! Calculate the components of the gradient in DC and X
14121 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
14122 fac=fac*(1.0d0-sss)
14127 gvdwx(k,i)=gvdwx(k,i)-gg(k)
14128 gvdwx(k,j)=gvdwx(k,j)+gg(k)
14129 gvdwc(k,i)=gvdwc(k,i)-gg(k)
14130 gvdwc(k,j)=gvdwc(k,j)+gg(k)
14138 gvdwc(j,i)=expon*gvdwc(j,i)
14139 gvdwx(j,i)=expon*gvdwx(j,i)
14143 end subroutine eljk_long
14144 !-----------------------------------------------------------------------------
14145 subroutine eljk_short(evdw)
14147 ! This subroutine calculates the interaction energy of nonbonded side chains
14148 ! assuming the LJK potential of interaction.
14150 ! implicit real*8 (a-h,o-z)
14151 ! include 'DIMENSIONS'
14152 ! include 'COMMON.GEO'
14153 ! include 'COMMON.VAR'
14154 ! include 'COMMON.LOCAL'
14155 ! include 'COMMON.CHAIN'
14156 ! include 'COMMON.DERIV'
14157 ! include 'COMMON.INTERACT'
14158 ! include 'COMMON.IOUNITS'
14159 ! include 'COMMON.NAMES'
14160 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
14162 !el local variables
14163 integer :: i,iint,j,k,itypi,itypi1,itypj
14164 real(kind=8) :: rrij,r_inv_ij,xj,yj,zj,xi,yi,zi,fac,evdw,&
14165 fac_augm,e_augm,rij,sss,r_shift_inv,e1,e2,evdwij,&
14166 sslipi,ssgradlipi,sslipj,ssgradlipj,aa,bb
14167 ! print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
14169 do i=iatsc_s,iatsc_e
14171 if (itypi.eq.ntyp1) cycle
14172 itypi1=itype(i+1,1)
14176 call to_box(xi,yi,zi)
14177 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
14179 ! Calculate SC interaction energy.
14181 do iint=1,nint_gr(i)
14182 do j=istart(i,iint),iend(i,iint)
14184 if (itypj.eq.ntyp1) cycle
14188 call to_box(xj,yj,zj)
14189 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
14190 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
14191 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
14192 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
14193 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
14194 xj=boxshift(xj-xi,boxxsize)
14195 yj=boxshift(yj-yi,boxysize)
14196 zj=boxshift(zj-zi,boxzsize)
14197 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
14198 fac_augm=rrij**expon
14199 e_augm=augm(itypi,itypj)*fac_augm
14200 r_inv_ij=dsqrt(rrij)
14202 sss=sscale(rij/sigma(itypi,itypj))
14203 if (sss.gt.0.0d0) then
14204 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
14205 fac=r_shift_inv**expon
14206 e1=fac*fac*aa_aq(itypi,itypj)
14207 e2=fac*bb_aq(itypi,itypj)
14208 evdwij=e_augm+e1+e2
14209 !d sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
14210 !d epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
14211 !d write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
14212 !d & restyp(itypi,1),i,restyp(itypj,1),j,aa(itypi,itypj),
14213 !d & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
14214 !d & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
14215 !d & (c(k,i),k=1,3),(c(k,j),k=1,3)
14216 evdw=evdw+sss*evdwij
14218 ! Calculate the components of the gradient in DC and X
14220 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
14226 gvdwx(k,i)=gvdwx(k,i)-gg(k)
14227 gvdwx(k,j)=gvdwx(k,j)+gg(k)
14228 gvdwc(k,i)=gvdwc(k,i)-gg(k)
14229 gvdwc(k,j)=gvdwc(k,j)+gg(k)
14237 gvdwc(j,i)=expon*gvdwc(j,i)
14238 gvdwx(j,i)=expon*gvdwx(j,i)
14242 end subroutine eljk_short
14243 !-----------------------------------------------------------------------------
14244 subroutine ebp_long(evdw)
14245 ! This subroutine calculates the interaction energy of nonbonded side chains
14246 ! assuming the Berne-Pechukas potential of interaction.
14249 ! implicit real*8 (a-h,o-z)
14250 ! include 'DIMENSIONS'
14251 ! include 'COMMON.GEO'
14252 ! include 'COMMON.VAR'
14253 ! include 'COMMON.LOCAL'
14254 ! include 'COMMON.CHAIN'
14255 ! include 'COMMON.DERIV'
14256 ! include 'COMMON.NAMES'
14257 ! include 'COMMON.INTERACT'
14258 ! include 'COMMON.IOUNITS'
14259 ! include 'COMMON.CALC'
14261 !el integer :: icall
14262 !el common /srutu/ icall
14263 ! double precision rrsave(maxdim)
14265 !el local variables
14266 integer :: iint,itypi,itypi1,itypj
14267 real(kind=8) :: rrij,xi,yi,zi,fac,sslipi,ssgradlipi,&
14268 sslipj,ssgradlipj,aa,bb
14269 real(kind=8) :: sss,e1,e2,evdw,sigm,epsi
14271 ! print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
14273 ! if (icall.eq.0) then
14279 do i=iatsc_s,iatsc_e
14281 if (itypi.eq.ntyp1) cycle
14282 itypi1=itype(i+1,1)
14286 call to_box(xi,yi,zi)
14287 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
14288 dxi=dc_norm(1,nres+i)
14289 dyi=dc_norm(2,nres+i)
14290 dzi=dc_norm(3,nres+i)
14291 ! dsci_inv=dsc_inv(itypi)
14292 dsci_inv=vbld_inv(i+nres)
14294 ! Calculate SC interaction energy.
14296 do iint=1,nint_gr(i)
14297 do j=istart(i,iint),iend(i,iint)
14300 if (itypj.eq.ntyp1) cycle
14301 ! dscj_inv=dsc_inv(itypj)
14302 dscj_inv=vbld_inv(j+nres)
14303 chi1=chi(itypi,itypj)
14304 chi2=chi(itypj,itypi)
14309 alf12=0.5D0*(alf1+alf2)
14313 call to_box(xj,yj,zj)
14314 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
14315 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
14316 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
14317 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
14318 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
14319 xj=boxshift(xj-xi,boxxsize)
14320 yj=boxshift(yj-yi,boxysize)
14321 zj=boxshift(zj-zi,boxzsize)
14322 dxj=dc_norm(1,nres+j)
14323 dyj=dc_norm(2,nres+j)
14324 dzj=dc_norm(3,nres+j)
14325 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
14327 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
14329 if (sss.lt.1.0d0) then
14331 ! Calculate the angle-dependent terms of energy & contributions to derivatives.
14333 ! Calculate whole angle-dependent part of epsilon and contributions
14334 ! to its derivatives
14335 fac=(rrij*sigsq)**expon2
14336 e1=fac*fac*aa_aq(itypi,itypj)
14337 e2=fac*bb_aq(itypi,itypj)
14338 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
14339 eps2der=evdwij*eps3rt
14340 eps3der=evdwij*eps2rt
14341 evdwij=evdwij*eps2rt*eps3rt
14342 evdw=evdw+evdwij*(1.0d0-sss)
14344 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
14345 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
14346 !d write (iout,'(2(a3,i3,2x),15(0pf7.3))')
14347 !d & restyp(itypi,1),i,restyp(itypj,1),j,
14348 !d & epsi,sigm,chi1,chi2,chip1,chip2,
14349 !d & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
14350 !d & om1,om2,om12,1.0D0/dsqrt(rrij),
14353 ! Calculate gradient components.
14354 e1=e1*eps1*eps2rt**2*eps3rt**2
14355 fac=-expon*(e1+evdwij)
14358 ! Calculate radial part of the gradient
14362 ! Calculate the angular part of the gradient and sum add the contributions
14363 ! to the appropriate components of the Cartesian gradient.
14364 call sc_grad_scale(1.0d0-sss)
14371 end subroutine ebp_long
14372 !-----------------------------------------------------------------------------
14373 subroutine ebp_short(evdw)
14375 ! This subroutine calculates the interaction energy of nonbonded side chains
14376 ! assuming the Berne-Pechukas potential of interaction.
14379 ! implicit real*8 (a-h,o-z)
14380 ! include 'DIMENSIONS'
14381 ! include 'COMMON.GEO'
14382 ! include 'COMMON.VAR'
14383 ! include 'COMMON.LOCAL'
14384 ! include 'COMMON.CHAIN'
14385 ! include 'COMMON.DERIV'
14386 ! include 'COMMON.NAMES'
14387 ! include 'COMMON.INTERACT'
14388 ! include 'COMMON.IOUNITS'
14389 ! include 'COMMON.CALC'
14391 !el integer :: icall
14392 !el common /srutu/ icall
14393 ! double precision rrsave(maxdim)
14395 !el local variables
14396 integer :: iint,itypi,itypi1,itypj
14397 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi
14398 real(kind=8) :: sss,e1,e2,evdw,aa,bb, &
14399 sslipi,ssgradlipi,sslipj,ssgradlipj
14401 ! print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
14403 ! if (icall.eq.0) then
14409 do i=iatsc_s,iatsc_e
14411 if (itypi.eq.ntyp1) cycle
14412 itypi1=itype(i+1,1)
14416 call to_box(xi,yi,zi)
14417 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
14419 dxi=dc_norm(1,nres+i)
14420 dyi=dc_norm(2,nres+i)
14421 dzi=dc_norm(3,nres+i)
14422 ! dsci_inv=dsc_inv(itypi)
14423 dsci_inv=vbld_inv(i+nres)
14425 ! Calculate SC interaction energy.
14427 do iint=1,nint_gr(i)
14428 do j=istart(i,iint),iend(i,iint)
14431 if (itypj.eq.ntyp1) cycle
14432 ! dscj_inv=dsc_inv(itypj)
14433 dscj_inv=vbld_inv(j+nres)
14434 chi1=chi(itypi,itypj)
14435 chi2=chi(itypj,itypi)
14442 alf12=0.5D0*(alf1+alf2)
14446 call to_box(xj,yj,zj)
14447 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
14448 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
14449 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
14450 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
14451 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
14452 xj=boxshift(xj-xi,boxxsize)
14453 yj=boxshift(yj-yi,boxysize)
14454 zj=boxshift(zj-zi,boxzsize)
14455 dxj=dc_norm(1,nres+j)
14456 dyj=dc_norm(2,nres+j)
14457 dzj=dc_norm(3,nres+j)
14458 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
14460 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
14462 if (sss.gt.0.0d0) then
14464 ! Calculate the angle-dependent terms of energy & contributions to derivatives.
14466 ! Calculate whole angle-dependent part of epsilon and contributions
14467 ! to its derivatives
14468 fac=(rrij*sigsq)**expon2
14469 e1=fac*fac*aa_aq(itypi,itypj)
14470 e2=fac*bb_aq(itypi,itypj)
14471 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
14472 eps2der=evdwij*eps3rt
14473 eps3der=evdwij*eps2rt
14474 evdwij=evdwij*eps2rt*eps3rt
14475 evdw=evdw+evdwij*sss
14477 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
14478 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
14479 !d write (iout,'(2(a3,i3,2x),15(0pf7.3))')
14480 !d & restyp(itypi,1),i,restyp(itypj,1),j,
14481 !d & epsi,sigm,chi1,chi2,chip1,chip2,
14482 !d & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
14483 !d & om1,om2,om12,1.0D0/dsqrt(rrij),
14486 ! Calculate gradient components.
14487 e1=e1*eps1*eps2rt**2*eps3rt**2
14488 fac=-expon*(e1+evdwij)
14491 ! Calculate radial part of the gradient
14495 ! Calculate the angular part of the gradient and sum add the contributions
14496 ! to the appropriate components of the Cartesian gradient.
14497 call sc_grad_scale(sss)
14504 end subroutine ebp_short
14505 !-----------------------------------------------------------------------------
14506 subroutine egb_long(evdw)
14508 ! This subroutine calculates the interaction energy of nonbonded side chains
14509 ! assuming the Gay-Berne potential of interaction.
14512 ! implicit real*8 (a-h,o-z)
14513 ! include 'DIMENSIONS'
14514 ! include 'COMMON.GEO'
14515 ! include 'COMMON.VAR'
14516 ! include 'COMMON.LOCAL'
14517 ! include 'COMMON.CHAIN'
14518 ! include 'COMMON.DERIV'
14519 ! include 'COMMON.NAMES'
14520 ! include 'COMMON.INTERACT'
14521 ! include 'COMMON.IOUNITS'
14522 ! include 'COMMON.CALC'
14523 ! include 'COMMON.CONTROL'
14525 !el local variables
14526 integer :: iint,itypi,itypi1,itypj,subchap
14527 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,sig,sig0ij,rij_shift
14528 real(kind=8) :: sss,e1,e2,evdw,sss_grad
14529 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
14530 dist_temp, dist_init,aa,bb,fracinbuf,sslipi,sslipj,&
14531 ssgradlipi,ssgradlipj
14535 !cccc energy_dec=.false.
14536 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
14539 ! if (icall.eq.0) lprn=.false.
14541 do i=iatsc_s,iatsc_e
14543 if (itypi.eq.ntyp1) cycle
14544 itypi1=itype(i+1,1)
14548 call to_box(xi,yi,zi)
14549 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
14550 dxi=dc_norm(1,nres+i)
14551 dyi=dc_norm(2,nres+i)
14552 dzi=dc_norm(3,nres+i)
14553 ! dsci_inv=dsc_inv(itypi)
14554 dsci_inv=vbld_inv(i+nres)
14555 ! write (iout,*) "i",i,dsc_inv(itypi),dsci_inv,1.0d0/vbld(i+nres)
14556 ! write (iout,*) "dcnori",dxi*dxi+dyi*dyi+dzi*dzi
14558 ! Calculate SC interaction energy.
14560 do iint=1,nint_gr(i)
14561 do j=istart(i,iint),iend(i,iint)
14562 IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
14563 ! call dyn_ssbond_ene(i,j,evdwij)
14565 ! if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
14566 ! 'evdw',i,j,evdwij,' ss'
14567 ! if (energy_dec) write (iout,*) &
14568 ! 'evdw',i,j,evdwij,' ss'
14569 ! do k=j+1,iend(i,iint)
14570 !C search over all next residues
14571 ! if (dyn_ss_mask(k)) then
14572 !C check if they are cysteins
14573 !C write(iout,*) 'k=',k
14575 !c write(iout,*) "PRZED TRI", evdwij
14576 ! evdwij_przed_tri=evdwij
14577 ! call triple_ssbond_ene(i,j,k,evdwij)
14578 !c if(evdwij_przed_tri.ne.evdwij) then
14579 !c write (iout,*) "TRI:", evdwij, evdwij_przed_tri
14582 !c write(iout,*) "PO TRI", evdwij
14583 !C call the energy function that removes the artifical triple disulfide
14584 !C bond the soubroutine is located in ssMD.F
14586 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
14587 'evdw',i,j,evdwij,'tss'
14588 ! endif!dyn_ss_mask(k)
14594 if (itypj.eq.ntyp1) cycle
14595 ! dscj_inv=dsc_inv(itypj)
14596 dscj_inv=vbld_inv(j+nres)
14597 ! write (iout,*) "j",j,dsc_inv(itypj),dscj_inv,
14598 ! & 1.0d0/vbld(j+nres)
14599 ! write (iout,*) "i",i," j", j," itype",itype(i,1),itype(j,1)
14600 sig0ij=sigma(itypi,itypj)
14601 chi1=chi(itypi,itypj)
14602 chi2=chi(itypj,itypi)
14609 alf12=0.5D0*(alf1+alf2)
14613 ! Searching for nearest neighbour
14614 call to_box(xj,yj,zj)
14615 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
14616 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
14617 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
14618 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
14619 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
14620 xj=boxshift(xj-xi,boxxsize)
14621 yj=boxshift(yj-yi,boxysize)
14622 zj=boxshift(zj-zi,boxzsize)
14623 dxj=dc_norm(1,nres+j)
14624 dyj=dc_norm(2,nres+j)
14625 dzj=dc_norm(3,nres+j)
14626 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
14628 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
14629 sss_ele_cut=sscale_ele(1.0d0/(rij))
14630 sss_ele_grad=sscagrad_ele(1.0d0/(rij))
14631 sss_grad=sscale_grad(1.0d0/(rij*sigmaii(itypi,itypj)))
14632 if (sss_ele_cut.le.0.0) cycle
14633 if (sss.lt.1.0d0) then
14635 ! Calculate angle-dependent terms of energy and contributions to their
14639 sig=sig0ij*dsqrt(sigsq)
14640 rij_shift=1.0D0/rij-sig+sig0ij
14641 ! for diagnostics; uncomment
14642 ! rij_shift=1.2*sig0ij
14643 ! I hate to put IF's in the loops, but here don't have another choice!!!!
14644 if (rij_shift.le.0.0D0) then
14646 !d write (iout,'(2(a3,i3,2x),17(0pf7.3))')
14647 !d & restyp(itypi,1),i,restyp(itypj,1),j,
14648 !d & rij_shift,1.0D0/rij,sig,sig0ij,sigsq,1-dsqrt(sigsq)
14652 !---------------------------------------------------------------
14653 rij_shift=1.0D0/rij_shift
14654 fac=rij_shift**expon
14657 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
14658 eps2der=evdwij*eps3rt
14659 eps3der=evdwij*eps2rt
14660 ! write (iout,*) "sigsq",sigsq," sig",sig," eps2rt",eps2rt,
14661 ! & " eps3rt",eps3rt," eps1",eps1," e1",e1," e2",e2
14662 evdwij=evdwij*eps2rt*eps3rt
14663 evdw=evdw+evdwij*(1.0d0-sss)*sss_ele_cut
14665 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
14666 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
14667 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
14668 restyp(itypi,1),i,restyp(itypj,1),j,&
14669 epsi,sigm,chi1,chi2,chip1,chip2,&
14670 eps1,eps2rt**2,eps3rt**2,sig,sig0ij,&
14671 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
14675 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
14677 ! if (energy_dec) write (iout,*) &
14678 ! 'evdw',i,j,evdwij,"egb_long"
14680 ! Calculate gradient components.
14681 e1=e1*eps1*eps2rt**2*eps3rt**2
14682 fac=-expon*(e1+evdwij)*rij_shift
14685 fac=fac+evdwij*(sss_ele_grad/sss_ele_cut&
14686 *rij-sss_grad/(1.0-sss)*rij &
14687 /sigmaii(itypi,itypj))
14689 ! Calculate the radial part of the gradient
14693 ! Calculate angular part of the gradient.
14694 call sc_grad_scale(1.0d0-sss)
14700 ! write (iout,*) "Number of loop steps in EGB:",ind
14701 !ccc energy_dec=.false.
14703 end subroutine egb_long
14704 !-----------------------------------------------------------------------------
14705 subroutine egb_short(evdw)
14707 ! This subroutine calculates the interaction energy of nonbonded side chains
14708 ! assuming the Gay-Berne potential of interaction.
14711 ! implicit real*8 (a-h,o-z)
14712 ! include 'DIMENSIONS'
14713 ! include 'COMMON.GEO'
14714 ! include 'COMMON.VAR'
14715 ! include 'COMMON.LOCAL'
14716 ! include 'COMMON.CHAIN'
14717 ! include 'COMMON.DERIV'
14718 ! include 'COMMON.NAMES'
14719 ! include 'COMMON.INTERACT'
14720 ! include 'COMMON.IOUNITS'
14721 ! include 'COMMON.CALC'
14722 ! include 'COMMON.CONTROL'
14724 !el local variables
14725 integer :: iint,itypi,itypi1,itypj,subchap
14726 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,sig0ij,sig
14727 real(kind=8) :: sss,e1,e2,evdw,rij_shift,sss_grad
14728 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
14729 dist_temp, dist_init,aa,bb,fracinbuf,sslipi,sslipj,&
14730 ssgradlipi,ssgradlipj
14732 !cccc energy_dec=.false.
14733 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
14736 ! if (icall.eq.0) lprn=.false.
14738 do i=iatsc_s,iatsc_e
14740 if (itypi.eq.ntyp1) cycle
14741 itypi1=itype(i+1,1)
14745 call to_box(xi,yi,zi)
14746 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
14748 dxi=dc_norm(1,nres+i)
14749 dyi=dc_norm(2,nres+i)
14750 dzi=dc_norm(3,nres+i)
14751 ! dsci_inv=dsc_inv(itypi)
14752 dsci_inv=vbld_inv(i+nres)
14754 dxi=dc_norm(1,nres+i)
14755 dyi=dc_norm(2,nres+i)
14756 dzi=dc_norm(3,nres+i)
14757 ! dsci_inv=dsc_inv(itypi)
14758 dsci_inv=vbld_inv(i+nres)
14759 do iint=1,nint_gr(i)
14760 do j=istart(i,iint),iend(i,iint)
14761 IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
14762 call dyn_ssbond_ene(i,j,evdwij)
14764 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
14765 'evdw',i,j,evdwij,' ss'
14766 do k=j+1,iend(i,iint)
14767 !C search over all next residues
14768 if (dyn_ss_mask(k)) then
14769 !C check if they are cysteins
14770 !C write(iout,*) 'k=',k
14772 !c write(iout,*) "PRZED TRI", evdwij
14773 ! evdwij_przed_tri=evdwij
14774 call triple_ssbond_ene(i,j,k,evdwij)
14775 !c if(evdwij_przed_tri.ne.evdwij) then
14776 !c write (iout,*) "TRI:", evdwij, evdwij_przed_tri
14779 !c write(iout,*) "PO TRI", evdwij
14780 !C call the energy function that removes the artifical triple disulfide
14781 !C bond the soubroutine is located in ssMD.F
14783 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
14784 'evdw',i,j,evdwij,'tss'
14785 endif!dyn_ss_mask(k)
14790 if (itypj.eq.ntyp1) cycle
14791 ! dscj_inv=dsc_inv(itypj)
14792 dscj_inv=vbld_inv(j+nres)
14793 dscj_inv=dsc_inv(itypj)
14794 ! write (iout,*) "j",j,dsc_inv(itypj),dscj_inv,
14795 ! & 1.0d0/vbld(j+nres)
14796 ! write (iout,*) "i",i," j", j," itype",itype(i,1),itype(j,1)
14797 sig0ij=sigma(itypi,itypj)
14798 chi1=chi(itypi,itypj)
14799 chi2=chi(itypj,itypi)
14806 alf12=0.5D0*(alf1+alf2)
14807 ! xj=c(1,nres+j)-xi
14808 ! yj=c(2,nres+j)-yi
14809 ! zj=c(3,nres+j)-zi
14813 ! Searching for nearest neighbour
14814 call to_box(xj,yj,zj)
14815 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
14816 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
14817 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
14818 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
14819 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
14820 xj=boxshift(xj-xi,boxxsize)
14821 yj=boxshift(yj-yi,boxysize)
14822 zj=boxshift(zj-zi,boxzsize)
14823 dxj=dc_norm(1,nres+j)
14824 dyj=dc_norm(2,nres+j)
14825 dzj=dc_norm(3,nres+j)
14826 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
14828 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
14829 sss_grad=sscale_grad(1.0d0/(rij*sigmaii(itypi,itypj)))
14830 sss_ele_cut=sscale_ele(1.0d0/(rij))
14831 sss_ele_grad=sscagrad_ele(1.0d0/(rij))
14832 if (sss_ele_cut.le.0.0) cycle
14834 if (sss.gt.0.0d0) then
14836 ! Calculate angle-dependent terms of energy and contributions to their
14840 sig=sig0ij*dsqrt(sigsq)
14841 rij_shift=1.0D0/rij-sig+sig0ij
14842 ! for diagnostics; uncomment
14843 ! rij_shift=1.2*sig0ij
14844 ! I hate to put IF's in the loops, but here don't have another choice!!!!
14845 if (rij_shift.le.0.0D0) then
14847 !d write (iout,'(2(a3,i3,2x),17(0pf7.3))')
14848 !d & restyp(itypi,1),i,restyp(itypj,1),j,
14849 !d & rij_shift,1.0D0/rij,sig,sig0ij,sigsq,1-dsqrt(sigsq)
14853 !---------------------------------------------------------------
14854 rij_shift=1.0D0/rij_shift
14855 fac=rij_shift**expon
14858 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
14859 eps2der=evdwij*eps3rt
14860 eps3der=evdwij*eps2rt
14861 ! write (iout,*) "sigsq",sigsq," sig",sig," eps2rt",eps2rt,
14862 ! & " eps3rt",eps3rt," eps1",eps1," e1",e1," e2",e2
14863 evdwij=evdwij*eps2rt*eps3rt
14864 evdw=evdw+evdwij*sss*sss_ele_cut
14866 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
14867 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
14868 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
14869 restyp(itypi,1),i,restyp(itypj,1),j,&
14870 epsi,sigm,chi1,chi2,chip1,chip2,&
14871 eps1,eps2rt**2,eps3rt**2,sig,sig0ij,&
14872 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
14876 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
14878 ! if (energy_dec) write (iout,*) &
14879 ! 'evdw',i,j,evdwij,"egb_short"
14881 ! Calculate gradient components.
14882 e1=e1*eps1*eps2rt**2*eps3rt**2
14883 fac=-expon*(e1+evdwij)*rij_shift
14886 fac=fac+evdwij*(sss_ele_grad/sss_ele_cut&
14887 *rij+sss_grad/sss*rij &
14888 /sigmaii(itypi,itypj))
14891 ! Calculate the radial part of the gradient
14895 ! Calculate angular part of the gradient.
14896 call sc_grad_scale(sss)
14902 ! write (iout,*) "Number of loop steps in EGB:",ind
14903 !ccc energy_dec=.false.
14905 end subroutine egb_short
14906 !-----------------------------------------------------------------------------
14907 subroutine egbv_long(evdw)
14909 ! This subroutine calculates the interaction energy of nonbonded side chains
14910 ! assuming the Gay-Berne-Vorobjev potential of interaction.
14913 ! implicit real*8 (a-h,o-z)
14914 ! include 'DIMENSIONS'
14915 ! include 'COMMON.GEO'
14916 ! include 'COMMON.VAR'
14917 ! include 'COMMON.LOCAL'
14918 ! include 'COMMON.CHAIN'
14919 ! include 'COMMON.DERIV'
14920 ! include 'COMMON.NAMES'
14921 ! include 'COMMON.INTERACT'
14922 ! include 'COMMON.IOUNITS'
14923 ! include 'COMMON.CALC'
14925 !el integer :: icall
14926 !el common /srutu/ icall
14928 !el local variables
14929 integer :: iint,itypi,itypi1,itypj
14930 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,r0ij,sig,sig0ij,&
14931 sslipi,ssgradlipi,sslipj,ssgradlipj,aa,bb
14932 real(kind=8) :: sss,e1,e2,evdw,fac_augm,e_augm,rij_shift
14934 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
14937 ! if (icall.eq.0) lprn=.true.
14939 do i=iatsc_s,iatsc_e
14941 if (itypi.eq.ntyp1) cycle
14942 itypi1=itype(i+1,1)
14946 call to_box(xi,yi,zi)
14947 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
14948 dxi=dc_norm(1,nres+i)
14949 dyi=dc_norm(2,nres+i)
14950 dzi=dc_norm(3,nres+i)
14952 ! dsci_inv=dsc_inv(itypi)
14953 dsci_inv=vbld_inv(i+nres)
14955 ! Calculate SC interaction energy.
14957 do iint=1,nint_gr(i)
14958 do j=istart(i,iint),iend(i,iint)
14961 if (itypj.eq.ntyp1) cycle
14962 ! dscj_inv=dsc_inv(itypj)
14963 dscj_inv=vbld_inv(j+nres)
14964 sig0ij=sigma(itypi,itypj)
14965 r0ij=r0(itypi,itypj)
14966 chi1=chi(itypi,itypj)
14967 chi2=chi(itypj,itypi)
14974 alf12=0.5D0*(alf1+alf2)
14978 call to_box(xj,yj,zj)
14979 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
14980 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
14981 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
14982 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
14983 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
14984 xj=boxshift(xj-xi,boxxsize)
14985 yj=boxshift(yj-yi,boxysize)
14986 zj=boxshift(zj-zi,boxzsize)
14987 dxj=dc_norm(1,nres+j)
14988 dyj=dc_norm(2,nres+j)
14989 dzj=dc_norm(3,nres+j)
14990 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
14993 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
14995 if (sss.lt.1.0d0) then
14997 ! Calculate angle-dependent terms of energy and contributions to their
15001 sig=sig0ij*dsqrt(sigsq)
15002 rij_shift=1.0D0/rij-sig+r0ij
15003 ! I hate to put IF's in the loops, but here don't have another choice!!!!
15004 if (rij_shift.le.0.0D0) then
15009 !---------------------------------------------------------------
15010 rij_shift=1.0D0/rij_shift
15011 fac=rij_shift**expon
15012 e1=fac*fac*aa_aq(itypi,itypj)
15013 e2=fac*bb_aq(itypi,itypj)
15014 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
15015 eps2der=evdwij*eps3rt
15016 eps3der=evdwij*eps2rt
15017 fac_augm=rrij**expon
15018 e_augm=augm(itypi,itypj)*fac_augm
15019 evdwij=evdwij*eps2rt*eps3rt
15020 evdw=evdw+(evdwij+e_augm)*(1.0d0-sss)
15022 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
15023 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
15024 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
15025 restyp(itypi,1),i,restyp(itypj,1),j,&
15026 epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),&
15027 chi1,chi2,chip1,chip2,&
15028 eps1,eps2rt**2,eps3rt**2,&
15029 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
15032 ! Calculate gradient components.
15033 e1=e1*eps1*eps2rt**2*eps3rt**2
15034 fac=-expon*(e1+evdwij)*rij_shift
15036 fac=rij*fac-2*expon*rrij*e_augm
15037 ! Calculate the radial part of the gradient
15041 ! Calculate angular part of the gradient.
15042 call sc_grad_scale(1.0d0-sss)
15047 end subroutine egbv_long
15048 !-----------------------------------------------------------------------------
15049 subroutine egbv_short(evdw)
15051 ! This subroutine calculates the interaction energy of nonbonded side chains
15052 ! assuming the Gay-Berne-Vorobjev potential of interaction.
15055 ! implicit real*8 (a-h,o-z)
15056 ! include 'DIMENSIONS'
15057 ! include 'COMMON.GEO'
15058 ! include 'COMMON.VAR'
15059 ! include 'COMMON.LOCAL'
15060 ! include 'COMMON.CHAIN'
15061 ! include 'COMMON.DERIV'
15062 ! include 'COMMON.NAMES'
15063 ! include 'COMMON.INTERACT'
15064 ! include 'COMMON.IOUNITS'
15065 ! include 'COMMON.CALC'
15067 !el integer :: icall
15068 !el common /srutu/ icall
15070 !el local variables
15071 integer :: iint,itypi,itypi1,itypj
15072 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,rij_shift,&
15073 sslipi,ssgradlipi, sslipj,ssgradlipj,aa,bb
15074 real(kind=8) :: sss,e1,e2,evdw,r0ij,sig,sig0ij,fac_augm,e_augm
15076 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
15079 ! if (icall.eq.0) lprn=.true.
15081 do i=iatsc_s,iatsc_e
15083 if (itypi.eq.ntyp1) cycle
15084 itypi1=itype(i+1,1)
15088 dxi=dc_norm(1,nres+i)
15089 dyi=dc_norm(2,nres+i)
15090 dzi=dc_norm(3,nres+i)
15091 call to_box(xi,yi,zi)
15092 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
15093 ! dsci_inv=dsc_inv(itypi)
15094 dsci_inv=vbld_inv(i+nres)
15096 ! Calculate SC interaction energy.
15098 do iint=1,nint_gr(i)
15099 do j=istart(i,iint),iend(i,iint)
15102 if (itypj.eq.ntyp1) cycle
15103 ! dscj_inv=dsc_inv(itypj)
15104 dscj_inv=vbld_inv(j+nres)
15105 sig0ij=sigma(itypi,itypj)
15106 r0ij=r0(itypi,itypj)
15107 chi1=chi(itypi,itypj)
15108 chi2=chi(itypj,itypi)
15115 alf12=0.5D0*(alf1+alf2)
15119 call to_box(xj,yj,zj)
15120 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
15121 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
15122 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
15123 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
15124 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
15125 xj=boxshift(xj-xi,boxxsize)
15126 yj=boxshift(yj-yi,boxysize)
15127 zj=boxshift(zj-zi,boxzsize)
15128 dxj=dc_norm(1,nres+j)
15129 dyj=dc_norm(2,nres+j)
15130 dzj=dc_norm(3,nres+j)
15131 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
15134 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
15136 if (sss.gt.0.0d0) then
15138 ! Calculate angle-dependent terms of energy and contributions to their
15142 sig=sig0ij*dsqrt(sigsq)
15143 rij_shift=1.0D0/rij-sig+r0ij
15144 ! I hate to put IF's in the loops, but here don't have another choice!!!!
15145 if (rij_shift.le.0.0D0) then
15150 !---------------------------------------------------------------
15151 rij_shift=1.0D0/rij_shift
15152 fac=rij_shift**expon
15153 e1=fac*fac*aa_aq(itypi,itypj)
15154 e2=fac*bb_aq(itypi,itypj)
15155 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
15156 eps2der=evdwij*eps3rt
15157 eps3der=evdwij*eps2rt
15158 fac_augm=rrij**expon
15159 e_augm=augm(itypi,itypj)*fac_augm
15160 evdwij=evdwij*eps2rt*eps3rt
15161 evdw=evdw+(evdwij+e_augm)*sss
15163 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
15164 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
15165 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
15166 restyp(itypi,1),i,restyp(itypj,1),j,&
15167 epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),&
15168 chi1,chi2,chip1,chip2,&
15169 eps1,eps2rt**2,eps3rt**2,&
15170 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
15173 ! Calculate gradient components.
15174 e1=e1*eps1*eps2rt**2*eps3rt**2
15175 fac=-expon*(e1+evdwij)*rij_shift
15177 fac=rij*fac-2*expon*rrij*e_augm
15178 ! Calculate the radial part of the gradient
15182 ! Calculate angular part of the gradient.
15183 call sc_grad_scale(sss)
15188 end subroutine egbv_short
15189 !-----------------------------------------------------------------------------
15190 subroutine eelec_scale(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
15192 ! This subroutine calculates the average interaction energy and its gradient
15193 ! in the virtual-bond vectors between non-adjacent peptide groups, based on
15194 ! the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
15195 ! The potential depends both on the distance of peptide-group centers and on
15196 ! the orientation of the CA-CA virtual bonds.
15198 ! implicit real*8 (a-h,o-z)
15204 ! include 'DIMENSIONS'
15205 ! include 'COMMON.CONTROL'
15206 ! include 'COMMON.SETUP'
15207 ! include 'COMMON.IOUNITS'
15208 ! include 'COMMON.GEO'
15209 ! include 'COMMON.VAR'
15210 ! include 'COMMON.LOCAL'
15211 ! include 'COMMON.CHAIN'
15212 ! include 'COMMON.DERIV'
15213 ! include 'COMMON.INTERACT'
15214 ! include 'COMMON.CONTACTS'
15215 ! include 'COMMON.TORSION'
15216 ! include 'COMMON.VECTORS'
15217 ! include 'COMMON.FFIELD'
15218 ! include 'COMMON.TIME1'
15219 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg
15220 real(kind=8),dimension(3,3) ::erder,uryg,urzg,vryg,vrzg
15221 real(kind=8),dimension(2,2) :: acipa !el,a_temp
15222 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
15223 real(kind=8),dimension(4) :: muij
15224 !el integer :: num_conti,j1,j2
15225 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
15226 !el dz_normi,xmedi,ymedi,zmedi
15227 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
15228 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
15229 !el num_conti,j1,j2
15230 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
15232 real(kind=8) :: scal_el=1.0d0
15234 real(kind=8) :: scal_el=0.5d0
15237 ! 13-go grudnia roku pamietnego...
15238 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
15239 0.0d0,1.0d0,0.0d0,&
15240 0.0d0,0.0d0,1.0d0/),shape(unmat))
15241 !el local variables
15243 real(kind=8) :: fac
15244 real(kind=8) :: dxj,dyj,dzj
15245 real(kind=8) :: ees,evdw1,eel_loc,eello_turn3,eello_turn4
15247 ! allocate(num_cont_hb(nres)) !(maxres)
15248 !d write(iout,*) 'In EELEC'
15250 !d write(iout,*) 'Type',i
15251 !d write(iout,*) 'B1',B1(:,i)
15252 !d write(iout,*) 'B2',B2(:,i)
15253 !d write(iout,*) 'CC',CC(:,:,i)
15254 !d write(iout,*) 'DD',DD(:,:,i)
15255 !d write(iout,*) 'EE',EE(:,:,i)
15257 !d call check_vecgrad
15259 if (icheckgrad.eq.1) then
15261 fac=1.0d0/dsqrt(scalar(dc(1,i),dc(1,i)))
15263 dc_norm(k,i)=dc(k,i)*fac
15265 ! write (iout,*) 'i',i,' fac',fac
15268 if (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
15269 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 .or. &
15270 wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) then
15271 ! call vec_and_deriv
15275 ! print *, "before set matrices"
15277 ! print *,"after set martices"
15279 time_mat=time_mat+MPI_Wtime()-time01
15283 !d write (iout,*) 'i=',i
15285 !d write (iout,'(i5,2f10.5)') k,uy(k,i),uz(k,i)
15288 !d write (iout,'(f10.5,2x,3f10.5,2x,3f10.5)')
15289 !d & uz(k,i),(uzgrad(k,l,1,i),l=1,3),(uzgrad(k,l,2,i),l=1,3)
15302 !d print '(a)','Enter EELEC'
15303 !d write (iout,*) 'iatel_s=',iatel_s,' iatel_e=',iatel_e
15304 ! if (.not.allocated(gel_loc_loc)) allocate(gel_loc_loc(nres)) !(maxvar)(maxvar=6*maxres)
15305 ! if (.not.allocated(gcorr_loc)) allocate(gcorr_loc(nres)) !(maxvar)(maxvar=6*maxres)
15307 gel_loc_loc(i)=0.0d0
15312 ! 9/27/08 AL Split the interaction loop to ensure load balancing of turn terms
15314 ! Loop over i,i+2 and i,i+3 pairs of the peptide groups
15316 do i=iturn3_start,iturn3_end
15317 if (itype(i,1).eq.ntyp1.or. itype(i+1,1).eq.ntyp1 &
15318 .or. itype(i+2,1).eq.ntyp1 .or. itype(i+3,1).eq.ntyp1) cycle
15322 dx_normi=dc_norm(1,i)
15323 dy_normi=dc_norm(2,i)
15324 dz_normi=dc_norm(3,i)
15325 xmedi=c(1,i)+0.5d0*dxi
15326 ymedi=c(2,i)+0.5d0*dyi
15327 zmedi=c(3,i)+0.5d0*dzi
15328 call to_box(xmedi,ymedi,zmedi)
15329 call lipid_layer(xmedi,ymedi,zmedi,sslipi,ssgradlipi)
15331 call eelecij_scale(i,i+2,ees,evdw1,eel_loc)
15332 if (wturn3.gt.0.0d0) call eturn3(i,eello_turn3)
15333 num_cont_hb(i)=num_conti
15335 do i=iturn4_start,iturn4_end
15336 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1 &
15337 .or. itype(i+3,1).eq.ntyp1 &
15338 .or. itype(i+4,1).eq.ntyp1) cycle
15342 dx_normi=dc_norm(1,i)
15343 dy_normi=dc_norm(2,i)
15344 dz_normi=dc_norm(3,i)
15345 xmedi=c(1,i)+0.5d0*dxi
15346 ymedi=c(2,i)+0.5d0*dyi
15347 zmedi=c(3,i)+0.5d0*dzi
15349 call to_box(xmedi,ymedi,zmedi)
15350 call lipid_layer(xmedi,ymedi,zmedi,sslipi,ssgradlipi)
15352 num_conti=num_cont_hb(i)
15353 call eelecij_scale(i,i+3,ees,evdw1,eel_loc)
15354 if (wturn4.gt.0.0d0 .and. itype(i+2,1).ne.ntyp1) &
15355 call eturn4(i,eello_turn4)
15356 num_cont_hb(i)=num_conti
15359 ! Loop over all pairs of interacting peptide groups except i,i+2 and i,i+3
15361 do i=iatel_s,iatel_e
15362 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
15366 dx_normi=dc_norm(1,i)
15367 dy_normi=dc_norm(2,i)
15368 dz_normi=dc_norm(3,i)
15369 xmedi=c(1,i)+0.5d0*dxi
15370 ymedi=c(2,i)+0.5d0*dyi
15371 zmedi=c(3,i)+0.5d0*dzi
15372 call to_box(xmedi,ymedi,zmedi)
15373 call lipid_layer(xmedi,ymedi,zmedi,sslipi,ssgradlipi)
15374 ! write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
15375 num_conti=num_cont_hb(i)
15376 do j=ielstart(i),ielend(i)
15377 if (itype(j,1).eq.ntyp1 .or. itype(j+1,1).eq.ntyp1) cycle
15378 call eelecij_scale(i,j,ees,evdw1,eel_loc)
15380 num_cont_hb(i)=num_conti
15382 ! write (iout,*) "Number of loop steps in EELEC:",ind
15384 !d write (iout,'(i3,3f10.5,5x,3f10.5)')
15385 !d & i,(gel_loc(k,i),k=1,3),gel_loc_loc(i)
15387 ! 12/7/99 Adam eello_turn3 will be considered as a separate energy term
15388 !cc eel_loc=eel_loc+eello_turn3
15389 !d print *,"Processor",fg_rank," t_eelecij",t_eelecij
15391 end subroutine eelec_scale
15392 !-----------------------------------------------------------------------------
15393 subroutine eelecij_scale(i,j,ees,evdw1,eel_loc)
15394 ! implicit real*8 (a-h,o-z)
15397 ! include 'DIMENSIONS'
15401 ! include 'COMMON.CONTROL'
15402 ! include 'COMMON.IOUNITS'
15403 ! include 'COMMON.GEO'
15404 ! include 'COMMON.VAR'
15405 ! include 'COMMON.LOCAL'
15406 ! include 'COMMON.CHAIN'
15407 ! include 'COMMON.DERIV'
15408 ! include 'COMMON.INTERACT'
15409 ! include 'COMMON.CONTACTS'
15410 ! include 'COMMON.TORSION'
15411 ! include 'COMMON.VECTORS'
15412 ! include 'COMMON.FFIELD'
15413 ! include 'COMMON.TIME1'
15414 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg,xtemp
15415 real(kind=8),dimension(3,3) :: erder,uryg,urzg,vryg,vrzg
15416 real(kind=8),dimension(2,2) :: acipa !el,a_temp
15417 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
15418 real(kind=8),dimension(4) :: muij
15419 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
15420 dist_temp, dist_init,sss_grad
15421 integer xshift,yshift,zshift
15423 !el integer :: num_conti,j1,j2
15424 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
15425 !el dz_normi,xmedi,ymedi,zmedi
15426 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
15427 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
15428 !el num_conti,j1,j2
15429 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
15431 real(kind=8) :: scal_el=1.0d0
15433 real(kind=8) :: scal_el=0.5d0
15436 ! 13-go grudnia roku pamietnego...
15437 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
15438 0.0d0,1.0d0,0.0d0,&
15439 0.0d0,0.0d0,1.0d0/),shape(unmat))
15440 !el local variables
15441 integer :: i,j,k,l,iteli,itelj,kkk,kkll,m,isubchap
15442 real(kind=8) :: aaa,bbb,ael6i,ael3i,dxj,dyj,dzj
15443 real(kind=8) :: xj,yj,zj,rij,rrmij,rmij,sss,r3ij,r6ij,fac
15444 real(kind=8) :: cosa,cosb,cosg,ev1,ev2,fac3,fac4,evdwij
15445 real(kind=8) :: el1,el2,eesij,ees0ij,r0ij,fcont,fprimcont
15446 real(kind=8) :: ees0tmp,ees0pij1,ees0mij1,ees0pijp,ees0mijp
15447 real(kind=8) :: ees,evdw1,eel_loc,eel_loc_ij,dx_normj,dy_normj,&
15448 dz_normj,facvdw,facel,fac1,facr,ecosa,ecosb,ecosg,&
15449 ury,urz,vry,vrz,a22der,a23der,a32der,a33der,cosa4,&
15450 wij,cosbg1,cosbg2,ees0pij,ees0mij,fac3p,ecosa1,ecosb1,&
15451 ecosg1,ecosa2,ecosb2,ecosg2,ecosap,ecosbp,ecosgp,&
15452 ecosam,ecosbm,ecosgm,ghalf,time00,faclipij,faclipij2
15453 ! integer :: maxconts
15454 ! maxconts = nres/4
15455 ! allocate(gacontp_hb1(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
15456 ! allocate(gacontp_hb2(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
15457 ! allocate(gacontp_hb3(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
15458 ! allocate(gacontm_hb1(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
15459 ! allocate(gacontm_hb2(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
15460 ! allocate(gacontm_hb3(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
15461 ! allocate(gacont_hbr(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
15462 ! allocate(grij_hb_cont(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
15463 ! allocate(facont_hb(maxconts,nres)) !(maxconts,maxres)
15464 ! allocate(ees0p(maxconts,nres)) !(maxconts,maxres)
15465 ! allocate(ees0m(maxconts,nres)) !(maxconts,maxres)
15466 ! allocate(d_cont(maxconts,nres)) !(maxconts,maxres)
15467 ! allocate(jcont_hb(maxconts,nres)) !(maxconts,maxres)
15469 ! allocate(a_chuj(2,2,maxconts,nres)) !(2,2,maxconts,maxres)
15470 ! allocate(a_chuj_der(2,2,3,5,maxconts,nres)) !(2,2,3,5,maxconts,maxres)
15475 !d write (iout,*) "eelecij",i,j
15479 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
15480 aaa=app(iteli,itelj)
15481 bbb=bpp(iteli,itelj)
15482 ael6i=ael6(iteli,itelj)
15483 ael3i=ael3(iteli,itelj)
15487 dx_normj=dc_norm(1,j)
15488 dy_normj=dc_norm(2,j)
15489 dz_normj=dc_norm(3,j)
15490 ! xj=c(1,j)+0.5D0*dxj-xmedi
15491 ! yj=c(2,j)+0.5D0*dyj-ymedi
15492 ! zj=c(3,j)+0.5D0*dzj-zmedi
15493 xj=c(1,j)+0.5D0*dxj
15494 yj=c(2,j)+0.5D0*dyj
15495 zj=c(3,j)+0.5D0*dzj
15496 call to_box(xj,yj,zj)
15497 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
15498 faclipij=(sslipi+sslipj)/2.0d0*lipscale+1.0d0
15499 faclipij2=(sslipi+sslipj)/2.0d0*lipscale**2+1.0d0
15500 xj=boxshift(xj-xmedi,boxxsize)
15501 yj=boxshift(yj-ymedi,boxysize)
15502 zj=boxshift(zj-zmedi,boxzsize)
15503 rij=xj*xj+yj*yj+zj*zj
15507 ! For extracting the short-range part of Evdwpp
15508 sss=sscale(rij/rpp(iteli,itelj))
15509 sss_ele_cut=sscale_ele(rij)
15510 sss_ele_grad=sscagrad_ele(rij)
15511 sss_grad=sscale_grad((rij/rpp(iteli,itelj)))
15512 ! sss_ele_cut=1.0d0
15513 ! sss_ele_grad=0.0d0
15514 if (sss_ele_cut.le.0.0) go to 128
15518 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
15519 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
15520 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
15521 fac=cosa-3.0D0*cosb*cosg
15523 ! 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
15524 if (j.eq.i+2) ev1=scal_el*ev1
15529 el1=fac3*(4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg))
15532 ! 12/26/95 - for the evaluation of multi-body H-bonding interactions
15533 ees0ij=4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg)
15534 ees=ees+eesij*sss_ele_cut
15535 evdw1=evdw1+evdwij*(1.0d0-sss)*sss_ele_cut
15536 !d write(iout,'(2(2i3,2x),7(1pd12.4)/2(3(1pd12.4),5x)/)')
15537 !d & iteli,i,itelj,j,aaa,bbb,ael6i,ael3i,
15538 !d & 1.0D0/dsqrt(rrmij),evdwij,eesij,
15539 !d & xmedi,ymedi,zmedi,xj,yj,zj
15541 if (energy_dec) then
15542 write (iout,'(a6,2i5,0pf7.3,f7.3)') 'evdw1',i,j,evdwij,sss
15543 write (iout,'(a6,2i5,0pf7.3)') 'ees',i,j,eesij
15547 ! Calculate contributions to the Cartesian gradient.
15550 facvdw=-6*rrmij*(ev1+evdwij)*(1.0d0-sss)*sss_ele_cut
15551 facel=-3*rrmij*(el1+eesij)*sss_ele_cut
15557 ! Radial derivatives. First process both termini of the fragment (i,j)
15559 ggg(1)=facel*xj+sss_ele_grad*rmij*eesij*xj
15560 ggg(2)=facel*yj+sss_ele_grad*rmij*eesij*yj
15561 ggg(3)=facel*zj+sss_ele_grad*rmij*eesij*zj
15563 ! ghalf=0.5D0*ggg(k)
15564 ! gelc(k,i)=gelc(k,i)+ghalf
15565 ! gelc(k,j)=gelc(k,j)+ghalf
15567 ! 9/28/08 AL Gradient compotents will be summed only at the end
15569 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
15570 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
15573 ! Loop over residues i+1 thru j-1.
15577 !grad gelc(l,k)=gelc(l,k)+ggg(l)
15580 ggg(1)=facvdw*xj+sss_ele_grad*rmij*evdwij*xj*(1.0d0-sss) &
15581 -evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*xj
15582 ggg(2)=facvdw*yj+sss_ele_grad*rmij*evdwij*yj*(1.0d0-sss) &
15583 -evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*yj
15584 ggg(3)=facvdw*zj+sss_ele_grad*rmij*evdwij*zj*(1.0d0-sss) &
15585 -evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*zj
15587 ! ghalf=0.5D0*ggg(k)
15588 ! gvdwpp(k,i)=gvdwpp(k,i)+ghalf
15589 ! gvdwpp(k,j)=gvdwpp(k,j)+ghalf
15591 ! 9/28/08 AL Gradient compotents will be summed only at the end
15593 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
15594 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
15597 ! Loop over residues i+1 thru j-1.
15601 !grad gvdwpp(l,k)=gvdwpp(l,k)+ggg(l)
15605 facvdw=(ev1+evdwij)*(1.0d0-sss)*sss_ele_cut
15606 facel=(el1+eesij)*sss_ele_cut
15608 fac=-3*rrmij*(facvdw+facvdw+facel)
15613 ! Radial derivatives. First process both termini of the fragment (i,j)
15619 ! ghalf=0.5D0*ggg(k)
15620 ! gelc(k,i)=gelc(k,i)+ghalf
15621 ! gelc(k,j)=gelc(k,j)+ghalf
15623 ! 9/28/08 AL Gradient compotents will be summed only at the end
15625 gelc_long(k,j)=gelc(k,j)+ggg(k)
15626 gelc_long(k,i)=gelc(k,i)-ggg(k)
15629 ! Loop over residues i+1 thru j-1.
15633 !grad gelc(l,k)=gelc(l,k)+ggg(l)
15636 ! 9/28/08 AL Gradient compotents will be summed only at the end
15641 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
15642 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
15648 ecosa=2.0D0*fac3*fac1+fac4
15651 ecosb=(fac3*(fac1*cosg+cosb)+cosg*fac4)
15652 ecosg=(fac3*(fac1*cosb+cosg)+cosb*fac4)
15654 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
15655 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
15657 !d print '(2i3,2(3(1pd14.5),3x))',i,j,(dcosb(k),k=1,3),
15658 !d & (dcosg(k),k=1,3)
15660 ggg(k)=(ecosb*dcosb(k)+ecosg*dcosg(k) )*sss_ele_cut
15663 ! ghalf=0.5D0*ggg(k)
15664 ! gelc(k,i)=gelc(k,i)+ghalf
15665 ! & +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
15666 ! & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
15667 ! gelc(k,j)=gelc(k,j)+ghalf
15668 ! & +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
15669 ! & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
15673 !grad gelc(l,k)=gelc(l,k)+ggg(l)
15677 gelc(k,i)=gelc(k,i) &
15678 +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
15679 + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)&
15681 gelc(k,j)=gelc(k,j) &
15682 +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
15683 + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
15685 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
15686 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
15688 IF (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
15689 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 &
15690 .or. wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
15692 ! 9/25/99 Mixed third-order local-electrostatic terms. The local-interaction
15693 ! energy of a peptide unit is assumed in the form of a second-order
15694 ! Fourier series in the angles lambda1 and lambda2 (see Nishikawa et al.
15695 ! Macromolecules, 1974, 7, 797-806 for definition). This correlation terms
15696 ! are computed for EVERY pair of non-contiguous peptide groups.
15698 if (j.lt.nres-1) then
15709 muij(kkk)=mu(k,i)*mu(l,j)
15712 !d write (iout,*) 'EELEC: i',i,' j',j
15713 !d write (iout,*) 'j',j,' j1',j1,' j2',j2
15714 !d write(iout,*) 'muij',muij
15715 ury=scalar(uy(1,i),erij)
15716 urz=scalar(uz(1,i),erij)
15717 vry=scalar(uy(1,j),erij)
15718 vrz=scalar(uz(1,j),erij)
15719 a22=scalar(uy(1,i),uy(1,j))-3*ury*vry
15720 a23=scalar(uy(1,i),uz(1,j))-3*ury*vrz
15721 a32=scalar(uz(1,i),uy(1,j))-3*urz*vry
15722 a33=scalar(uz(1,i),uz(1,j))-3*urz*vrz
15723 fac=dsqrt(-ael6i)*r3ij
15728 !d write (iout,'(4i5,4f10.5)')
15729 !d & i,itortyp(itype(i,1)),j,itortyp(itype(j,1)),a22,a23,a32,a33
15730 !d write (iout,'(6f10.5)') (muij(k),k=1,4),fac,eel_loc_ij
15731 !d write (iout,'(2(3f10.5,5x)/2(3f10.5,5x))') uy(:,i),uz(:,i),
15732 !d & uy(:,j),uz(:,j)
15733 !d write (iout,'(4f10.5)')
15734 !d & scalar(uy(1,i),uy(1,j)),scalar(uy(1,i),uz(1,j)),
15735 !d & scalar(uz(1,i),uy(1,j)),scalar(uz(1,i),uz(1,j))
15736 !d write (iout,'(4f10.5)') ury,urz,vry,vrz
15737 !d write (iout,'(9f10.5/)')
15738 !d & fac22,a22,fac23,a23,fac32,a32,fac33,a33,eel_loc_ij
15739 ! Derivatives of the elements of A in virtual-bond vectors
15740 call unormderiv(erij(1),unmat(1,1),rmij,erder(1,1))
15742 uryg(k,1)=scalar(erder(1,k),uy(1,i))
15743 uryg(k,2)=scalar(uygrad(1,k,1,i),erij(1))
15744 uryg(k,3)=scalar(uygrad(1,k,2,i),erij(1))
15745 urzg(k,1)=scalar(erder(1,k),uz(1,i))
15746 urzg(k,2)=scalar(uzgrad(1,k,1,i),erij(1))
15747 urzg(k,3)=scalar(uzgrad(1,k,2,i),erij(1))
15748 vryg(k,1)=scalar(erder(1,k),uy(1,j))
15749 vryg(k,2)=scalar(uygrad(1,k,1,j),erij(1))
15750 vryg(k,3)=scalar(uygrad(1,k,2,j),erij(1))
15751 vrzg(k,1)=scalar(erder(1,k),uz(1,j))
15752 vrzg(k,2)=scalar(uzgrad(1,k,1,j),erij(1))
15753 vrzg(k,3)=scalar(uzgrad(1,k,2,j),erij(1))
15755 ! Compute radial contributions to the gradient
15773 ! Add the contributions coming from er
15776 agg(k,1)=agg(k,1)+fac3*(uryg(k,1)*vry+vryg(k,1)*ury)
15777 agg(k,2)=agg(k,2)+fac3*(uryg(k,1)*vrz+vrzg(k,1)*ury)
15778 agg(k,3)=agg(k,3)+fac3*(urzg(k,1)*vry+vryg(k,1)*urz)
15779 agg(k,4)=agg(k,4)+fac3*(urzg(k,1)*vrz+vrzg(k,1)*urz)
15782 ! Derivatives in DC(i)
15783 !grad ghalf1=0.5d0*agg(k,1)
15784 !grad ghalf2=0.5d0*agg(k,2)
15785 !grad ghalf3=0.5d0*agg(k,3)
15786 !grad ghalf4=0.5d0*agg(k,4)
15787 aggi(k,1)=fac*(scalar(uygrad(1,k,1,i),uy(1,j)) &
15788 -3.0d0*uryg(k,2)*vry)!+ghalf1
15789 aggi(k,2)=fac*(scalar(uygrad(1,k,1,i),uz(1,j)) &
15790 -3.0d0*uryg(k,2)*vrz)!+ghalf2
15791 aggi(k,3)=fac*(scalar(uzgrad(1,k,1,i),uy(1,j)) &
15792 -3.0d0*urzg(k,2)*vry)!+ghalf3
15793 aggi(k,4)=fac*(scalar(uzgrad(1,k,1,i),uz(1,j)) &
15794 -3.0d0*urzg(k,2)*vrz)!+ghalf4
15795 ! Derivatives in DC(i+1)
15796 aggi1(k,1)=fac*(scalar(uygrad(1,k,2,i),uy(1,j)) &
15797 -3.0d0*uryg(k,3)*vry)!+agg(k,1)
15798 aggi1(k,2)=fac*(scalar(uygrad(1,k,2,i),uz(1,j)) &
15799 -3.0d0*uryg(k,3)*vrz)!+agg(k,2)
15800 aggi1(k,3)=fac*(scalar(uzgrad(1,k,2,i),uy(1,j)) &
15801 -3.0d0*urzg(k,3)*vry)!+agg(k,3)
15802 aggi1(k,4)=fac*(scalar(uzgrad(1,k,2,i),uz(1,j)) &
15803 -3.0d0*urzg(k,3)*vrz)!+agg(k,4)
15804 ! Derivatives in DC(j)
15805 aggj(k,1)=fac*(scalar(uygrad(1,k,1,j),uy(1,i)) &
15806 -3.0d0*vryg(k,2)*ury)!+ghalf1
15807 aggj(k,2)=fac*(scalar(uzgrad(1,k,1,j),uy(1,i)) &
15808 -3.0d0*vrzg(k,2)*ury)!+ghalf2
15809 aggj(k,3)=fac*(scalar(uygrad(1,k,1,j),uz(1,i)) &
15810 -3.0d0*vryg(k,2)*urz)!+ghalf3
15811 aggj(k,4)=fac*(scalar(uzgrad(1,k,1,j),uz(1,i)) &
15812 -3.0d0*vrzg(k,2)*urz)!+ghalf4
15813 ! Derivatives in DC(j+1) or DC(nres-1)
15814 aggj1(k,1)=fac*(scalar(uygrad(1,k,2,j),uy(1,i)) &
15815 -3.0d0*vryg(k,3)*ury)
15816 aggj1(k,2)=fac*(scalar(uzgrad(1,k,2,j),uy(1,i)) &
15817 -3.0d0*vrzg(k,3)*ury)
15818 aggj1(k,3)=fac*(scalar(uygrad(1,k,2,j),uz(1,i)) &
15819 -3.0d0*vryg(k,3)*urz)
15820 aggj1(k,4)=fac*(scalar(uzgrad(1,k,2,j),uz(1,i)) &
15821 -3.0d0*vrzg(k,3)*urz)
15822 !grad if (j.eq.nres-1 .and. i.lt.j-2) then
15824 !grad aggj1(k,l)=aggj1(k,l)+agg(k,l)
15837 aggi(k,l)=-aggi(k,l)
15838 aggi1(k,l)=-aggi1(k,l)
15839 aggj(k,l)=-aggj(k,l)
15840 aggj1(k,l)=-aggj1(k,l)
15843 if (j.lt.nres-1) then
15849 aggi(k,l)=-aggi(k,l)
15850 aggi1(k,l)=-aggi1(k,l)
15851 aggj(k,l)=-aggj(k,l)
15852 aggj1(k,l)=-aggj1(k,l)
15863 aggi(k,l)=-aggi(k,l)
15864 aggi1(k,l)=-aggi1(k,l)
15865 aggj(k,l)=-aggj(k,l)
15866 aggj1(k,l)=-aggj1(k,l)
15871 IF (wel_loc.gt.0.0d0) THEN
15872 ! Contribution to the local-electrostatic energy coming from the i-j pair
15873 eel_loc_ij=a22*muij(1)+a23*muij(2)+a32*muij(3) &
15875 ! write (iout,*) 'i',i,' j',j,' eel_loc_ij',eel_loc_ij
15876 ! print *,"EELLOC",i,gel_loc_loc(i-1)
15877 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
15878 'eelloc',i,j,eel_loc_ij
15879 ! write (iout,*) a22,muij(1),a23,muij(2),a32,muij(3) !d
15881 eel_loc=eel_loc+eel_loc_ij*sss_ele_cut
15882 ! Partial derivatives in virtual-bond dihedral angles gamma
15884 gel_loc_loc(i-1)=gel_loc_loc(i-1)+ &
15885 (a22*muder(1,i)*mu(1,j)+a23*muder(1,i)*mu(2,j) &
15886 +a32*muder(2,i)*mu(1,j)+a33*muder(2,i)*mu(2,j)) &
15888 gel_loc_loc(j-1)=gel_loc_loc(j-1)+ &
15889 (a22*mu(1,i)*muder(1,j)+a23*mu(1,i)*muder(2,j) &
15890 +a32*mu(2,i)*muder(1,j)+a33*mu(2,i)*muder(2,j)) &
15896 ! Derivatives of eello in DC(i+1) thru DC(j-1) or DC(nres-2)
15898 ggg(l)=(agg(l,1)*muij(1)+ &
15899 agg(l,2)*muij(2)+agg(l,3)*muij(3)+agg(l,4)*muij(4))&
15901 +eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
15903 gel_loc_long(l,j)=gel_loc_long(l,j)+ggg(l)
15904 gel_loc_long(l,i)=gel_loc_long(l,i)-ggg(l)
15905 !grad ghalf=0.5d0*ggg(l)
15906 !grad gel_loc(l,i)=gel_loc(l,i)+ghalf
15907 !grad gel_loc(l,j)=gel_loc(l,j)+ghalf
15911 !grad gel_loc(l,k)=gel_loc(l,k)+ggg(l)
15914 ! Remaining derivatives of eello
15916 gel_loc(l,i)=gel_loc(l,i)+(aggi(l,1)*muij(1)+ &
15917 aggi(l,2)*muij(2)+aggi(l,3)*muij(3)+aggi(l,4)*muij(4))&
15920 gel_loc(l,i+1)=gel_loc(l,i+1)+(aggi1(l,1)*muij(1)+ &
15921 aggi1(l,2)*muij(2)+aggi1(l,3)*muij(3)+aggi1(l,4)*muij(4))&
15924 gel_loc(l,j)=gel_loc(l,j)+(aggj(l,1)*muij(1)+ &
15925 aggj(l,2)*muij(2)+aggj(l,3)*muij(3)+aggj(l,4)*muij(4))&
15928 gel_loc(l,j1)=gel_loc(l,j1)+(aggj1(l,1)*muij(1)+ &
15929 aggj1(l,2)*muij(2)+aggj1(l,3)*muij(3)+aggj1(l,4)*muij(4))&
15934 ! Change 12/26/95 to calculate four-body contributions to H-bonding energy
15935 ! if (j.gt.i+1 .and. num_conti.le.maxconts) then
15936 if (wcorr+wcorr4+wcorr5+wcorr6.gt.0.0d0 &
15937 .and. num_conti.le.maxconts) then
15938 ! write (iout,*) i,j," entered corr"
15940 ! Calculate the contact function. The ith column of the array JCONT will
15941 ! contain the numbers of atoms that make contacts with the atom I (of numbers
15942 ! greater than I). The arrays FACONT and GACONT will contain the values of
15943 ! the contact function and its derivative.
15944 ! r0ij=1.02D0*rpp(iteli,itelj)
15945 ! r0ij=1.11D0*rpp(iteli,itelj)
15946 r0ij=2.20D0*rpp(iteli,itelj)
15947 ! r0ij=1.55D0*rpp(iteli,itelj)
15948 call gcont(rij,r0ij,1.0D0,0.2d0*r0ij,fcont,fprimcont)
15949 !elwrite(iout,*) "num_conti",num_conti, "maxconts",maxconts
15950 if (fcont.gt.0.0D0) then
15951 num_conti=num_conti+1
15952 if (num_conti.gt.maxconts) then
15953 !elwrite(iout,*) "num_conti",num_conti, "maxconts",maxconts
15954 write (iout,*) 'WARNING - max. # of contacts exceeded;',&
15955 ' will skip next contacts for this conf.',num_conti
15957 jcont_hb(num_conti,i)=j
15958 !d write (iout,*) "i",i," j",j," num_conti",num_conti,
15959 !d & " jcont_hb",jcont_hb(num_conti,i)
15960 IF (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. &
15961 wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
15962 ! 9/30/99 (AL) - store components necessary to evaluate higher-order loc-el
15964 d_cont(num_conti,i)=rij
15965 !d write (2,'(3e15.5)') rij,r0ij+0.2d0*r0ij,rij
15966 ! --- Electrostatic-interaction matrix ---
15967 a_chuj(1,1,num_conti,i)=a22
15968 a_chuj(1,2,num_conti,i)=a23
15969 a_chuj(2,1,num_conti,i)=a32
15970 a_chuj(2,2,num_conti,i)=a33
15971 ! --- Gradient of rij
15973 grij_hb_cont(kkk,num_conti,i)=erij(kkk)
15980 a_chuj_der(k,l,m,1,num_conti,i)=agg(m,kkll)
15981 a_chuj_der(k,l,m,2,num_conti,i)=aggi(m,kkll)
15982 a_chuj_der(k,l,m,3,num_conti,i)=aggi1(m,kkll)
15983 a_chuj_der(k,l,m,4,num_conti,i)=aggj(m,kkll)
15984 a_chuj_der(k,l,m,5,num_conti,i)=aggj1(m,kkll)
15989 IF (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) THEN
15990 ! Calculate contact energies
15992 wij=cosa-3.0D0*cosb*cosg
15995 ! fac3=dsqrt(-ael6i)/r0ij**3
15996 fac3=dsqrt(-ael6i)*r3ij
15997 ! ees0pij=dsqrt(4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1)
15998 ees0tmp=4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1
15999 if (ees0tmp.gt.0) then
16000 ees0pij=dsqrt(ees0tmp)
16004 ! ees0mij=dsqrt(4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2)
16005 ees0tmp=4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2
16006 if (ees0tmp.gt.0) then
16007 ees0mij=dsqrt(ees0tmp)
16012 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij) &
16015 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij) &
16018 ! Diagnostics. Comment out or remove after debugging!
16019 ! ees0p(num_conti,i)=0.5D0*fac3*ees0pij
16020 ! ees0m(num_conti,i)=0.5D0*fac3*ees0mij
16021 ! ees0m(num_conti,i)=0.0D0
16023 ! write (iout,*) 'i=',i,' j=',j,' rij=',rij,' r0ij=',r0ij,
16024 ! & ' ees0ij=',ees0p(num_conti,i),ees0m(num_conti,i),' fcont=',fcont
16025 ! Angular derivatives of the contact function
16026 ees0pij1=fac3/ees0pij
16027 ees0mij1=fac3/ees0mij
16028 fac3p=-3.0D0*fac3*rrmij
16029 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
16030 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
16032 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
16033 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
16034 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
16035 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
16036 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
16037 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
16038 ecosap=ecosa1+ecosa2
16039 ecosbp=ecosb1+ecosb2
16040 ecosgp=ecosg1+ecosg2
16041 ecosam=ecosa1-ecosa2
16042 ecosbm=ecosb1-ecosb2
16043 ecosgm=ecosg1-ecosg2
16052 facont_hb(num_conti,i)=fcont
16053 fprimcont=fprimcont/rij
16054 !d facont_hb(num_conti,i)=1.0D0
16055 ! Following line is for diagnostics.
16058 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
16059 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
16062 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
16063 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
16065 ! gggp(1)=gggp(1)+ees0pijp*xj
16066 ! gggp(2)=gggp(2)+ees0pijp*yj
16067 ! gggp(3)=gggp(3)+ees0pijp*zj
16068 ! gggm(1)=gggm(1)+ees0mijp*xj
16069 ! gggm(2)=gggm(2)+ees0mijp*yj
16070 ! gggm(3)=gggm(3)+ees0mijp*zj
16071 gggp(1)=gggp(1)+ees0pijp*xj &
16072 +ees0p(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
16073 gggp(2)=gggp(2)+ees0pijp*yj &
16074 +ees0p(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
16075 gggp(3)=gggp(3)+ees0pijp*zj &
16076 +ees0p(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
16078 gggm(1)=gggm(1)+ees0mijp*xj &
16079 +ees0m(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
16081 gggm(2)=gggm(2)+ees0mijp*yj &
16082 +ees0m(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
16084 gggm(3)=gggm(3)+ees0mijp*zj &
16085 +ees0m(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
16087 ! Derivatives due to the contact function
16088 gacont_hbr(1,num_conti,i)=fprimcont*xj
16089 gacont_hbr(2,num_conti,i)=fprimcont*yj
16090 gacont_hbr(3,num_conti,i)=fprimcont*zj
16093 ! 10/24/08 cgrad and ! comments indicate the parts of the code removed
16094 ! following the change of gradient-summation algorithm.
16096 !grad ghalfp=0.5D0*gggp(k)
16097 !grad ghalfm=0.5D0*gggm(k)
16098 ! gacontp_hb1(k,num_conti,i)= & !ghalfp
16099 ! +(ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
16100 ! + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
16101 ! gacontp_hb2(k,num_conti,i)= & !ghalfp
16102 ! +(ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
16103 ! + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
16104 ! gacontp_hb3(k,num_conti,i)=gggp(k)
16105 ! gacontm_hb1(k,num_conti,i)= &!ghalfm
16106 ! +(ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
16107 ! + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
16108 ! gacontm_hb2(k,num_conti,i)= & !ghalfm
16109 ! +(ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
16110 ! + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
16111 ! gacontm_hb3(k,num_conti,i)=gggm(k)
16112 gacontp_hb1(k,num_conti,i)= & !ghalfp+
16113 (ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
16114 + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
16117 gacontp_hb2(k,num_conti,i)= & !ghalfp+
16118 (ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
16119 + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
16122 gacontp_hb3(k,num_conti,i)=gggp(k) &
16125 gacontm_hb1(k,num_conti,i)= & !ghalfm+
16126 (ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
16127 + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
16130 gacontm_hb2(k,num_conti,i)= & !ghalfm+
16131 (ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
16132 + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1) &
16135 gacontm_hb3(k,num_conti,i)=gggm(k) &
16140 endif ! num_conti.le.maxconts
16143 if (wturn3.gt.0.0d0 .or. wturn4.gt.0.0d0) then
16146 ghalf=0.5d0*agg(l,k)
16147 aggi(l,k)=aggi(l,k)+ghalf
16148 aggi1(l,k)=aggi1(l,k)+agg(l,k)
16149 aggj(l,k)=aggj(l,k)+ghalf
16152 if (j.eq.nres-1 .and. i.lt.j-2) then
16155 aggj1(l,k)=aggj1(l,k)+agg(l,k)
16161 ! t_eelecij=t_eelecij+MPI_Wtime()-time00
16163 end subroutine eelecij_scale
16164 !-----------------------------------------------------------------------------
16165 subroutine evdwpp_short(evdw1)
16169 ! implicit real*8 (a-h,o-z)
16170 ! include 'DIMENSIONS'
16171 ! include 'COMMON.CONTROL'
16172 ! include 'COMMON.IOUNITS'
16173 ! include 'COMMON.GEO'
16174 ! include 'COMMON.VAR'
16175 ! include 'COMMON.LOCAL'
16176 ! include 'COMMON.CHAIN'
16177 ! include 'COMMON.DERIV'
16178 ! include 'COMMON.INTERACT'
16179 ! include 'COMMON.CONTACTS'
16180 ! include 'COMMON.TORSION'
16181 ! include 'COMMON.VECTORS'
16182 ! include 'COMMON.FFIELD'
16183 real(kind=8),dimension(3) :: ggg
16184 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
16186 real(kind=8) :: scal_el=1.0d0
16188 real(kind=8) :: scal_el=0.5d0
16190 !el local variables
16191 integer :: i,j,k,iteli,itelj,num_conti,isubchap
16192 real(kind=8) :: dxi,dyi,dzi,dxj,dyj,dzj,aaa,bbb
16193 real(kind=8) :: xj,yj,zj,rij,rrmij,sss,r3ij,r6ij,evdw1,&
16194 dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
16195 dx_normj,dy_normj,dz_normj,rmij,ev1,ev2,evdwij,facvdw
16196 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
16197 dist_temp, dist_init,sss_grad,sslipi,ssgradlipi,&
16198 sslipj,ssgradlipj,faclipij2
16199 integer xshift,yshift,zshift
16203 ! write (iout,*) "iatel_s_vdw",iatel_s_vdw,
16204 ! & " iatel_e_vdw",iatel_e_vdw
16206 do i=iatel_s_vdw,iatel_e_vdw
16207 if (itype(i,1).eq.ntyp1.or. itype(i+1,1).eq.ntyp1) cycle
16211 dx_normi=dc_norm(1,i)
16212 dy_normi=dc_norm(2,i)
16213 dz_normi=dc_norm(3,i)
16214 xmedi=c(1,i)+0.5d0*dxi
16215 ymedi=c(2,i)+0.5d0*dyi
16216 zmedi=c(3,i)+0.5d0*dzi
16217 call to_box(xmedi,ymedi,zmedi)
16218 call lipid_layer(xmedi,ymedi,zmedi,sslipi,ssgradlipi)
16220 ! write (iout,*) 'i',i,' ielstart',ielstart_vdw(i),
16221 ! & ' ielend',ielend_vdw(i)
16223 do j=ielstart_vdw(i),ielend_vdw(i)
16224 if (itype(j,1).eq.ntyp1 .or. itype(j+1,1).eq.ntyp1) cycle
16228 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
16229 aaa=app(iteli,itelj)
16230 bbb=bpp(iteli,itelj)
16234 dx_normj=dc_norm(1,j)
16235 dy_normj=dc_norm(2,j)
16236 dz_normj=dc_norm(3,j)
16237 ! xj=c(1,j)+0.5D0*dxj-xmedi
16238 ! yj=c(2,j)+0.5D0*dyj-ymedi
16239 ! zj=c(3,j)+0.5D0*dzj-zmedi
16240 xj=c(1,j)+0.5D0*dxj
16241 yj=c(2,j)+0.5D0*dyj
16242 zj=c(3,j)+0.5D0*dzj
16243 call to_box(xj,yj,zj)
16244 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
16245 faclipij2=(sslipi+sslipj)/2.0d0*lipscale**2+1.0d0
16246 xj=boxshift(xj-xmedi,boxxsize)
16247 yj=boxshift(yj-ymedi,boxysize)
16248 zj=boxshift(zj-zmedi,boxzsize)
16249 rij=xj*xj+yj*yj+zj*zj
16252 sss=sscale(rij/rpp(iteli,itelj))
16253 sss_ele_cut=sscale_ele(rij)
16254 sss_ele_grad=sscagrad_ele(rij)
16255 sss_grad=sscale_grad((rij/rpp(iteli,itelj)))
16256 if (sss_ele_cut.le.0.0) cycle
16257 if (sss.gt.0.0d0) then
16262 ! 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
16263 if (j.eq.i+2) ev1=scal_el*ev1
16266 if (energy_dec) then
16267 write (iout,'(a6,2i5,0pf7.3,f7.3)') 'evdw1',i,j,evdwij,sss
16269 evdw1=evdw1+evdwij*sss*sss_ele_cut
16271 ! Calculate contributions to the Cartesian gradient.
16273 facvdw=-6*rrmij*(ev1+evdwij)*sss*sss_ele_cut
16277 ggg(1)=facvdw*xj+sss_ele_grad*rmij*evdwij*xj*sss &
16278 +evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*xj
16279 ggg(2)=facvdw*yj+sss_ele_grad*rmij*evdwij*yj*sss &
16280 +evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*yj
16281 ggg(3)=facvdw*zj+sss_ele_grad*rmij*evdwij*zj*sss &
16282 +evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*zj
16285 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
16286 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
16292 end subroutine evdwpp_short
16293 !-----------------------------------------------------------------------------
16294 subroutine escp_long(evdw2,evdw2_14)
16296 ! This subroutine calculates the excluded-volume interaction energy between
16297 ! peptide-group centers and side chains and its gradient in virtual-bond and
16298 ! side-chain vectors.
16300 ! implicit real*8 (a-h,o-z)
16301 ! include 'DIMENSIONS'
16302 ! include 'COMMON.GEO'
16303 ! include 'COMMON.VAR'
16304 ! include 'COMMON.LOCAL'
16305 ! include 'COMMON.CHAIN'
16306 ! include 'COMMON.DERIV'
16307 ! include 'COMMON.INTERACT'
16308 ! include 'COMMON.FFIELD'
16309 ! include 'COMMON.IOUNITS'
16310 ! include 'COMMON.CONTROL'
16311 real(kind=8),dimension(3) :: ggg
16312 !el local variables
16313 integer :: i,iint,j,k,iteli,itypj,subchap
16314 real(kind=8) :: xi,yi,zi,xj,yj,zj,rrij,sss,fac,e1,e2,sss_grad,rij
16315 real(kind=8) :: evdw2,evdw2_14,evdwij
16316 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
16317 dist_temp, dist_init
16321 !d print '(a)','Enter ESCP'
16322 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
16323 do i=iatscp_s,iatscp_e
16324 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
16326 xi=0.5D0*(c(1,i)+c(1,i+1))
16327 yi=0.5D0*(c(2,i)+c(2,i+1))
16328 zi=0.5D0*(c(3,i)+c(3,i+1))
16329 call to_box(xi,yi,zi)
16330 do iint=1,nscp_gr(i)
16332 do j=iscpstart(i,iint),iscpend(i,iint)
16334 if (itypj.eq.ntyp1) cycle
16335 ! Uncomment following three lines for SC-p interactions
16336 ! xj=c(1,nres+j)-xi
16337 ! yj=c(2,nres+j)-yi
16338 ! zj=c(3,nres+j)-zi
16339 ! Uncomment following three lines for Ca-p interactions
16343 call to_box(xj,yj,zj)
16344 xj=boxshift(xj-xi,boxxsize)
16345 yj=boxshift(yj-yi,boxysize)
16346 zj=boxshift(zj-zi,boxzsize)
16347 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
16349 rij=dsqrt(1.0d0/rrij)
16350 sss_ele_cut=sscale_ele(rij)
16351 sss_ele_grad=sscagrad_ele(rij)
16352 ! print *,sss_ele_cut,sss_ele_grad,&
16353 ! (rij),r_cut_ele,rlamb_ele
16354 if (sss_ele_cut.le.0.0) cycle
16355 sss=sscale((rij/rscp(itypj,iteli)))
16356 sss_grad=sscale_grad(rij/rscp(itypj,iteli))
16357 if (sss.lt.1.0d0) then
16360 e1=fac*fac*aad(itypj,iteli)
16361 e2=fac*bad(itypj,iteli)
16362 if (iabs(j-i) .le. 2) then
16365 evdw2_14=evdw2_14+(e1+e2)*(1.0d0-sss)*sss_ele_cut
16368 evdw2=evdw2+evdwij*(1.0d0-sss)*sss_ele_cut
16369 if (energy_dec) write (iout,'(a6,2i5,2(0pf7.3))') &
16370 'evdw2',i,j,sss,evdwij
16372 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
16374 fac=-(evdwij+e1)*rrij*(1.0d0-sss)*sss_ele_cut
16375 fac=fac+evdwij*sss_ele_grad/rij/expon*(1.0d0-sss)&
16376 -evdwij*sss_ele_cut/rij/expon*sss_grad/rscp(itypj,iteli)
16380 ! Uncomment following three lines for SC-p interactions
16382 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
16384 ! Uncomment following line for SC-p interactions
16385 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
16387 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
16388 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
16397 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
16398 gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
16399 gradx_scp(j,i)=expon*gradx_scp(j,i)
16402 !******************************************************************************
16406 ! To save time the factor EXPON has been extracted from ALL components
16407 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
16410 !******************************************************************************
16412 end subroutine escp_long
16413 !-----------------------------------------------------------------------------
16414 subroutine escp_short(evdw2,evdw2_14)
16416 ! This subroutine calculates the excluded-volume interaction energy between
16417 ! peptide-group centers and side chains and its gradient in virtual-bond and
16418 ! side-chain vectors.
16420 ! implicit real*8 (a-h,o-z)
16421 ! include 'DIMENSIONS'
16422 ! include 'COMMON.GEO'
16423 ! include 'COMMON.VAR'
16424 ! include 'COMMON.LOCAL'
16425 ! include 'COMMON.CHAIN'
16426 ! include 'COMMON.DERIV'
16427 ! include 'COMMON.INTERACT'
16428 ! include 'COMMON.FFIELD'
16429 ! include 'COMMON.IOUNITS'
16430 ! include 'COMMON.CONTROL'
16431 real(kind=8),dimension(3) :: ggg
16432 !el local variables
16433 integer :: i,iint,j,k,iteli,itypj,subchap
16434 real(kind=8) :: xi,yi,zi,xj,yj,zj,rrij,sss,fac,e1,e2,sss_grad,rij
16435 real(kind=8) :: evdw2,evdw2_14,evdwij
16436 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
16437 dist_temp, dist_init
16441 !d print '(a)','Enter ESCP'
16442 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
16443 do i=iatscp_s,iatscp_e
16444 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
16446 xi=0.5D0*(c(1,i)+c(1,i+1))
16447 yi=0.5D0*(c(2,i)+c(2,i+1))
16448 zi=0.5D0*(c(3,i)+c(3,i+1))
16449 call to_box(xi,yi,zi)
16450 if (zi.lt.0) zi=zi+boxzsize
16452 do iint=1,nscp_gr(i)
16454 do j=iscpstart(i,iint),iscpend(i,iint)
16456 if (itypj.eq.ntyp1) cycle
16457 ! Uncomment following three lines for SC-p interactions
16458 ! xj=c(1,nres+j)-xi
16459 ! yj=c(2,nres+j)-yi
16460 ! zj=c(3,nres+j)-zi
16461 ! Uncomment following three lines for Ca-p interactions
16468 call to_box(xj,yj,zj)
16469 xj=boxshift(xj-xi,boxxsize)
16470 yj=boxshift(yj-yi,boxysize)
16471 zj=boxshift(zj-zi,boxzsize)
16472 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
16473 rij=dsqrt(1.0d0/rrij)
16474 sss_ele_cut=sscale_ele(rij)
16475 sss_ele_grad=sscagrad_ele(rij)
16476 ! print *,sss_ele_cut,sss_ele_grad,&
16477 ! (rij),r_cut_ele,rlamb_ele
16478 if (sss_ele_cut.le.0.0) cycle
16479 sss=sscale(rij/rscp(itypj,iteli))
16480 sss_grad=sscale_grad(rij/rscp(itypj,iteli))
16481 if (sss.gt.0.0d0) then
16484 e1=fac*fac*aad(itypj,iteli)
16485 e2=fac*bad(itypj,iteli)
16486 if (iabs(j-i) .le. 2) then
16489 evdw2_14=evdw2_14+(e1+e2)*sss*sss_ele_cut
16492 evdw2=evdw2+evdwij*sss*sss_ele_cut
16493 if (energy_dec) write (iout,'(a6,2i5,2(0pf7.3))') &
16494 'evdw2',i,j,sss,evdwij
16496 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
16498 fac=-(evdwij+e1)*rrij*sss*sss_ele_cut
16499 fac=fac+evdwij*sss_ele_grad/rij/expon*sss &
16500 +evdwij*sss_ele_cut/rij/expon*sss_grad/rscp(itypj,iteli)
16505 ! Uncomment following three lines for SC-p interactions
16507 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
16509 ! Uncomment following line for SC-p interactions
16510 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
16512 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
16513 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
16522 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
16523 gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
16524 gradx_scp(j,i)=expon*gradx_scp(j,i)
16527 !******************************************************************************
16531 ! To save time the factor EXPON has been extracted from ALL components
16532 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
16535 !******************************************************************************
16537 end subroutine escp_short
16538 !-----------------------------------------------------------------------------
16539 ! energy_p_new-sep_barrier.F
16540 !-----------------------------------------------------------------------------
16541 subroutine sc_grad_scale(scalfac)
16542 ! implicit real*8 (a-h,o-z)
16544 ! include 'DIMENSIONS'
16545 ! include 'COMMON.CHAIN'
16546 ! include 'COMMON.DERIV'
16547 ! include 'COMMON.CALC'
16548 ! include 'COMMON.IOUNITS'
16549 real(kind=8),dimension(3) :: dcosom1,dcosom2
16550 real(kind=8) :: scalfac
16551 !el local variables
16552 ! integer :: i,j,k,l
16554 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
16555 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
16556 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12 &
16557 -2.0D0*alf12*eps3der+sigder*sigsq_om12
16561 ! eom12=evdwij*eps1_om12
16563 ! write (iout,*) "eps2der",eps2der," eps3der",eps3der,
16564 ! & " sigder",sigder
16565 ! write (iout,*) "eps1_om12",eps1_om12," eps2rt_om12",eps2rt_om12
16566 ! write (iout,*) "eom1",eom1," eom2",eom2," eom12",eom12
16568 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
16569 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
16572 gg(k)=(gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k))*scalfac&
16575 ! write (iout,*) "gg",(gg(k),k=1,3)
16577 gvdwx(k,i)=gvdwx(k,i)-gg(k) &
16578 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
16579 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv*scalfac&
16581 gvdwx(k,j)=gvdwx(k,j)+gg(k) &
16582 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
16583 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv*scalfac&
16585 ! write (iout,*)(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))
16586 ! & +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
16587 ! write (iout,*)(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))
16588 ! & +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
16591 ! Calculate the components of the gradient in DC and X
16594 gvdwc(l,i)=gvdwc(l,i)-gg(l)
16595 gvdwc(l,j)=gvdwc(l,j)+gg(l)
16598 end subroutine sc_grad_scale
16599 !-----------------------------------------------------------------------------
16600 ! energy_split-sep.F
16601 !-----------------------------------------------------------------------------
16602 subroutine etotal_long(energia)
16604 ! Compute the long-range slow-varying contributions to the energy
16606 ! implicit real*8 (a-h,o-z)
16607 ! include 'DIMENSIONS'
16608 use MD_data, only: totT,usampl,eq_time
16612 !MS$ATTRIBUTES C :: proc_proc
16617 real(kind=8),dimension(n_ene) :: weights_!,time_Bcast,time_Bcastw
16619 ! include 'COMMON.SETUP'
16620 ! include 'COMMON.IOUNITS'
16621 ! include 'COMMON.FFIELD'
16622 ! include 'COMMON.DERIV'
16623 ! include 'COMMON.INTERACT'
16624 ! include 'COMMON.SBRIDGE'
16625 ! include 'COMMON.CHAIN'
16626 ! include 'COMMON.VAR'
16627 ! include 'COMMON.LOCAL'
16628 ! include 'COMMON.MD'
16629 real(kind=8),dimension(0:n_ene) :: energia
16630 !el local variables
16631 integer :: i,n_corr,n_corr1,ierror,ierr
16632 real(kind=8) :: evdw2,evdw2_14,ehpb,etors,edihcnstr,etors_d,esccor,&
16633 evdw,ees,evdw1,eel_loc,eello_turn3,eello_turn4,&
16634 ecorr,ecorr5,ecorr6,eturn6,time00, ehomology_constr
16635 ! write(iout,'(a,i2)')'Calling etotal_long ipot=',ipot
16636 !elwrite(iout,*)"in etotal long"
16638 if (modecalc.eq.12.or.modecalc.eq.14) then
16640 ! if (fg_rank.eq.0) call int_from_cart1(.false.)
16642 call int_from_cart1(.false.)
16645 !elwrite(iout,*)"in etotal long"
16646 ehomology_constr=0.0d0
16648 ! write(iout,*) "ETOTAL_LONG Processor",fg_rank,
16649 ! & " absolute rank",myrank," nfgtasks",nfgtasks
16651 if (nfgtasks.gt.1) then
16653 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
16654 if (fg_rank.eq.0) then
16655 call MPI_Bcast(3,1,MPI_INTEGER,king,FG_COMM,IERROR)
16656 ! write (iout,*) "Processor",myrank," BROADCAST iorder"
16658 ! FG master sets up the WEIGHTS_ array which will be broadcast to the
16659 ! FG slaves as WEIGHTS array.
16666 weights_(7)=wel_loc
16669 weights_(10)=wturn6
16671 weights_(12)=wscloc
16673 weights_(14)=wtor_d
16674 weights_(15)=wstrain
16675 weights_(16)=wvdwpp
16677 weights_(18)=scal14
16678 weights_(21)=wsccor
16679 ! FG Master broadcasts the WEIGHTS_ array
16680 call MPI_Bcast(weights_(1),n_ene,&
16681 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
16683 ! FG slaves receive the WEIGHTS array
16684 call MPI_Bcast(weights(1),n_ene,&
16685 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
16700 wstrain=weights(15)
16706 call MPI_Bcast(dc(1,1),6*nres,MPI_DOUBLE_PRECISION,&
16708 time_Bcast=time_Bcast+MPI_Wtime()-time00
16709 time_Bcastw=time_Bcastw+MPI_Wtime()-time00
16710 ! call chainbuild_cart
16711 ! call int_from_cart1(.false.)
16713 ! write (iout,*) 'Processor',myrank,
16714 ! & ' calling etotal_short ipot=',ipot
16716 ! print *,'Processor',myrank,' nnt=',nnt,' nct=',nct
16718 !d print *,'nnt=',nnt,' nct=',nct
16720 !elwrite(iout,*)"in etotal long"
16721 ! Compute the side-chain and electrostatic interaction energy
16723 goto (101,102,103,104,105,106) ipot
16724 ! Lennard-Jones potential.
16725 101 call elj_long(evdw)
16726 !d print '(a)','Exit ELJ'
16728 ! Lennard-Jones-Kihara potential (shifted).
16729 102 call eljk_long(evdw)
16731 ! Berne-Pechukas potential (dilated LJ, angular dependence).
16732 103 call ebp_long(evdw)
16734 ! Gay-Berne potential (shifted LJ, angular dependence).
16735 104 call egb_long(evdw)
16737 ! Gay-Berne-Vorobjev potential (shifted LJ, angular dependence).
16738 105 call egbv_long(evdw)
16740 ! Soft-sphere potential
16741 106 call e_softsphere(evdw)
16743 ! Calculate electrostatic (H-bonding) energy of the main chain.
16747 if (ipot.lt.6) then
16749 if (welec.gt.0d0.or.wvdwpp.gt.0d0.or.wel_loc.gt.0d0.or. &
16750 wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0 &
16751 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
16752 .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
16754 if (welec.gt.0d0.or.wel_loc.gt.0d0.or. &
16755 wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0 &
16756 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
16757 .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
16759 call eelec_scale(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
16768 ! write (iout,*) "Soft-spheer ELEC potential"
16769 call eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,&
16773 ! Calculate excluded-volume interaction energy between peptide groups
16776 if (ipot.lt.6) then
16777 if(wscp.gt.0d0) then
16778 call escp_long(evdw2,evdw2_14)
16784 call escp_soft_sphere(evdw2,evdw2_14)
16787 ! 12/1/95 Multi-body terms
16791 if ((wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 &
16792 .or. wturn6.gt.0.0d0) .and. ipot.lt.6) then
16793 call multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
16794 ! write (2,*) 'n_corr=',n_corr,' n_corr1=',n_corr1,
16795 ! &" ecorr",ecorr," ecorr5",ecorr5," ecorr6",ecorr6," eturn6",eturn6
16802 if ((wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) .and. ipot.lt.6) then
16803 call multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
16806 ! If performing constraint dynamics, call the constraint energy
16807 ! after the equilibration time
16808 if(usampl.and.totT.gt.eq_time) then
16823 energia(2)=evdw2-evdw2_14
16824 energia(18)=evdw2_14
16833 energia(3)=ees+evdw1
16840 energia(8)=eello_turn3
16841 energia(9)=eello_turn4
16843 energia(20)=Uconst+Uconst_back
16844 energia(51)=ehomology_constr
16845 call sum_energy(energia,.true.)
16846 ! write (iout,*) "Exit ETOTAL_LONG"
16849 end subroutine etotal_long
16850 !-----------------------------------------------------------------------------
16851 subroutine etotal_short(energia)
16853 ! Compute the short-range fast-varying contributions to the energy
16855 ! implicit real*8 (a-h,o-z)
16856 ! include 'DIMENSIONS'
16860 !MS$ATTRIBUTES C :: proc_proc
16865 integer :: ierror,ierr
16866 real(kind=8),dimension(n_ene) :: weights_
16867 real(kind=8) :: time00
16869 ! include 'COMMON.SETUP'
16870 ! include 'COMMON.IOUNITS'
16871 ! include 'COMMON.FFIELD'
16872 ! include 'COMMON.DERIV'
16873 ! include 'COMMON.INTERACT'
16874 ! include 'COMMON.SBRIDGE'
16875 ! include 'COMMON.CHAIN'
16876 ! include 'COMMON.VAR'
16877 ! include 'COMMON.LOCAL'
16878 real(kind=8),dimension(0:n_ene) :: energia
16879 !el local variables
16881 real(kind=8) :: evdw,evdw1,evdw2,evdw2_14,esccor,etors_d,etors
16882 real(kind=8) :: ehpb,escloc,estr,ebe,edihcnstr,ethetacnstr, &
16886 ! write(iout,'(a,i2)')'Calling etotal_short ipot=',ipot
16888 if (modecalc.eq.12.or.modecalc.eq.14) then
16890 if (fg_rank.eq.0) call int_from_cart1(.false.)
16892 call int_from_cart1(.false.)
16896 ! write(iout,*) "ETOTAL_SHORT Processor",fg_rank,
16897 ! & " absolute rank",myrank," nfgtasks",nfgtasks
16899 if (nfgtasks.gt.1) then
16901 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
16902 if (fg_rank.eq.0) then
16903 call MPI_Bcast(2,1,MPI_INTEGER,king,FG_COMM,IERROR)
16904 ! write (iout,*) "Processor",myrank," BROADCAST iorder"
16906 ! FG master sets up the WEIGHTS_ array which will be broadcast to the
16907 ! FG slaves as WEIGHTS array.
16914 weights_(7)=wel_loc
16917 weights_(10)=wturn6
16919 weights_(12)=wscloc
16921 weights_(14)=wtor_d
16922 weights_(15)=wstrain
16923 weights_(16)=wvdwpp
16925 weights_(18)=scal14
16926 weights_(21)=wsccor
16927 ! FG Master broadcasts the WEIGHTS_ array
16928 call MPI_Bcast(weights_(1),n_ene,&
16929 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
16931 ! FG slaves receive the WEIGHTS array
16932 call MPI_Bcast(weights(1),n_ene,&
16933 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
16948 wstrain=weights(15)
16954 ! write (iout,*),"Processor",myrank," BROADCAST weights"
16955 call MPI_Bcast(c(1,1),nres6,MPI_DOUBLE_PRECISION,&
16957 ! write (iout,*) "Processor",myrank," BROADCAST c"
16958 call MPI_Bcast(dc(1,1),nres6,MPI_DOUBLE_PRECISION,&
16960 ! write (iout,*) "Processor",myrank," BROADCAST dc"
16961 call MPI_Bcast(dc_norm(1,1),nres6,MPI_DOUBLE_PRECISION,&
16963 ! write (iout,*) "Processor",myrank," BROADCAST dc_norm"
16964 call MPI_Bcast(theta(1),nres,MPI_DOUBLE_PRECISION,&
16966 ! write (iout,*) "Processor",myrank," BROADCAST theta"
16967 call MPI_Bcast(phi(1),nres,MPI_DOUBLE_PRECISION,&
16969 ! write (iout,*) "Processor",myrank," BROADCAST phi"
16970 call MPI_Bcast(alph(1),nres,MPI_DOUBLE_PRECISION,&
16972 ! write (iout,*) "Processor",myrank," BROADCAST alph"
16973 call MPI_Bcast(omeg(1),nres,MPI_DOUBLE_PRECISION,&
16975 ! write (iout,*) "Processor",myrank," BROADCAST omeg"
16976 call MPI_Bcast(vbld(1),2*nres,MPI_DOUBLE_PRECISION,&
16978 ! write (iout,*) "Processor",myrank," BROADCAST vbld"
16979 call MPI_Bcast(vbld_inv(1),2*nres,MPI_DOUBLE_PRECISION,&
16981 time_Bcast=time_Bcast+MPI_Wtime()-time00
16982 ! write (iout,*) "Processor",myrank," BROADCAST vbld_inv"
16984 ! write (iout,*) 'Processor',myrank,
16985 ! & ' calling etotal_short ipot=',ipot
16987 ! print *,'Processor',myrank,' nnt=',nnt,' nct=',nct
16989 ! call int_from_cart1(.false.)
16991 ! Compute the side-chain and electrostatic interaction energy
16993 goto (101,102,103,104,105,106) ipot
16994 ! Lennard-Jones potential.
16995 101 call elj_short(evdw)
16996 !d print '(a)','Exit ELJ'
16998 ! Lennard-Jones-Kihara potential (shifted).
16999 102 call eljk_short(evdw)
17001 ! Berne-Pechukas potential (dilated LJ, angular dependence).
17002 103 call ebp_short(evdw)
17004 ! Gay-Berne potential (shifted LJ, angular dependence).
17005 104 call egb_short(evdw)
17007 ! Gay-Berne-Vorobjev potential (shifted LJ, angular dependence).
17008 105 call egbv_short(evdw)
17010 ! Soft-sphere potential - already dealt with in the long-range part
17012 ! 106 call e_softsphere_short(evdw)
17014 ! Calculate electrostatic (H-bonding) energy of the main chain.
17018 ! Calculate the short-range part of Evdwpp
17020 call evdwpp_short(evdw1)
17022 ! Calculate the short-range part of ESCp
17024 if (ipot.lt.6) then
17025 call escp_short(evdw2,evdw2_14)
17028 ! Calculate the bond-stretching energy
17032 ! Calculate the disulfide-bridge and other energy and the contributions
17033 ! from other distance constraints.
17036 ! Calculate the virtual-bond-angle energy.
17038 ! Calculate the SC local energy.
17043 if (wang.gt.0d0) then
17044 if (tor_mode.eq.0) then
17047 !C ebend kcc is Kubo cumulant clustered rigorous attemp to derive the
17049 call ebend_kcc(ebe)
17055 if (with_theta_constr) call etheta_constr(ethetacnstr)
17057 ! write(iout,*) "in etotal afer ebe",ipot
17059 ! print *,"Processor",myrank," computed UB"
17061 ! Calculate the SC local energy.
17064 !elwrite(iout,*) "in etotal afer esc",ipot
17065 ! print *,"Processor",myrank," computed USC"
17067 ! Calculate the virtual-bond torsional energy.
17069 !d print *,'nterm=',nterm
17070 ! if (wtor.gt.0) then
17071 ! call etor(etors,edihcnstr)
17076 if (wtor.gt.0.0d0) then
17077 if (tor_mode.eq.0) then
17080 !C etor kcc is Kubo cumulant clustered rigorous attemp to derive the
17082 call etor_kcc(etors)
17088 if (ndih_constr.gt.0) call etor_constr(edihcnstr)
17090 ! Calculate the virtual-bond torsional energy.
17093 ! 6/23/01 Calculate double-torsional energy
17095 if ((wtor_d.gt.0.0d0).and.(tor_mode.eq.0)) then
17096 call etor_d(etors_d)
17099 ! Homology restraints
17101 if (constr_homology.ge.1) then
17102 call e_modeller(ehomology_constr)
17105 ehomology_constr=0.0d0
17109 ! 21/5/07 Calculate local sicdechain correlation energy
17111 if (wsccor.gt.0.0d0) then
17112 call eback_sc_corr(esccor)
17117 ! Put energy components into an array
17124 energia(2)=evdw2-evdw2_14
17125 energia(18)=evdw2_14
17138 energia(14)=etors_d
17141 energia(19)=edihcnstr
17143 energia(51)=ehomology_constr
17144 ! write (iout,*) "ETOTAL_SHORT before SUM_ENERGY"
17146 call sum_energy(energia,.true.)
17147 ! write (iout,*) "Exit ETOTAL_SHORT"
17150 end subroutine etotal_short
17151 !-----------------------------------------------------------------------------
17153 !-----------------------------------------------------------------------------
17154 real(kind=8) function gnmr1(y,ymin,ymax)
17156 real(kind=8) :: y,ymin,ymax
17157 real(kind=8) :: wykl=4.0d0
17158 if (y.lt.ymin) then
17159 gnmr1=(ymin-y)**wykl/wykl
17160 else if (y.gt.ymax) then
17161 gnmr1=(y-ymax)**wykl/wykl
17167 !-----------------------------------------------------------------------------
17168 real(kind=8) function gnmr1prim(y,ymin,ymax)
17170 real(kind=8) :: y,ymin,ymax
17171 real(kind=8) :: wykl=4.0d0
17172 if (y.lt.ymin) then
17173 gnmr1prim=-(ymin-y)**(wykl-1)
17174 else if (y.gt.ymax) then
17175 gnmr1prim=(y-ymax)**(wykl-1)
17180 end function gnmr1prim
17181 !----------------------------------------------------------------------------
17182 real(kind=8) function rlornmr1(y,ymin,ymax,sigma)
17183 real(kind=8) y,ymin,ymax,sigma
17184 real(kind=8) wykl /4.0d0/
17185 if (y.lt.ymin) then
17186 rlornmr1=(ymin-y)**wykl/((ymin-y)**wykl+sigma**wykl)
17187 else if (y.gt.ymax) then
17188 rlornmr1=(y-ymax)**wykl/((y-ymax)**wykl+sigma**wykl)
17193 end function rlornmr1
17194 !------------------------------------------------------------------------------
17195 real(kind=8) function rlornmr1prim(y,ymin,ymax,sigma)
17196 real(kind=8) y,ymin,ymax,sigma
17197 real(kind=8) wykl /4.0d0/
17198 if (y.lt.ymin) then
17199 rlornmr1prim=-(ymin-y)**(wykl-1)*sigma**wykl*wykl/ &
17200 ((ymin-y)**wykl+sigma**wykl)**2
17201 else if (y.gt.ymax) then
17202 rlornmr1prim=(y-ymax)**(wykl-1)*sigma**wykl*wykl/ &
17203 ((y-ymax)**wykl+sigma**wykl)**2
17208 end function rlornmr1prim
17210 real(kind=8) function harmonic(y,ymax)
17212 real(kind=8) :: y,ymax
17213 real(kind=8) :: wykl=2.0d0
17214 harmonic=(y-ymax)**wykl
17216 end function harmonic
17217 !-----------------------------------------------------------------------------
17218 real(kind=8) function harmonicprim(y,ymax)
17219 real(kind=8) :: y,ymin,ymax
17220 real(kind=8) :: wykl=2.0d0
17221 harmonicprim=(y-ymax)*wykl
17223 end function harmonicprim
17224 !-----------------------------------------------------------------------------
17226 !-----------------------------------------------------------------------------
17227 subroutine gradient(n,x,nf,g,uiparm,urparm,ufparm)
17229 use io_base, only:intout,briefout
17230 ! implicit real*8 (a-h,o-z)
17231 ! include 'DIMENSIONS'
17232 ! include 'COMMON.CHAIN'
17233 ! include 'COMMON.DERIV'
17234 ! include 'COMMON.VAR'
17235 ! include 'COMMON.INTERACT'
17236 ! include 'COMMON.FFIELD'
17237 ! include 'COMMON.MD'
17238 ! include 'COMMON.IOUNITS'
17239 real(kind=8),external :: ufparm
17240 integer :: uiparm(1)
17241 real(kind=8) :: urparm(1)
17242 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
17243 real(kind=8) :: f,gthetai,gphii,galphai,gomegai
17244 integer :: n,nf,ind,ind1,i,k,j
17246 ! This subroutine calculates total internal coordinate gradient.
17247 ! Depending on the number of function evaluations, either whole energy
17248 ! is evaluated beforehand, Cartesian coordinates and their derivatives in
17249 ! internal coordinates are reevaluated or only the cartesian-in-internal
17250 ! coordinate derivatives are evaluated. The subroutine was designed to work
17256 !d print *,'grad',nf,icg
17257 if (nf-nfl+1) 20,30,40
17258 20 call func(n,x,nf,f,uiparm,urparm,ufparm)
17259 ! write (iout,*) 'grad 20'
17260 if (nf.eq.0) return
17262 30 call var_to_geom(n,x)
17264 ! write (iout,*) 'grad 30'
17266 ! Evaluate the derivatives of virtual bond lengths and SC vectors in variables.
17269 ! write (iout,*) 'grad 40'
17270 ! print *,'GRADIENT: nnt=',nnt,' nct=',nct,' expon=',expon
17272 ! Convert the Cartesian gradient into internal-coordinate gradient.
17282 ! print *,'GRAD: i=',i,' jc=',j,' ind=',ind
17284 gthetai=gthetai+dcdv(k,ind)*gradc(k,j,icg)
17287 gphii=gphii+dcdv(k+3,ind)*gradc(k,j,icg)
17293 ! print *,'GRAD: i=',i,' jx=',j,' ind1=',ind1
17295 gthetai=gthetai+dxdv(k,ind1)*gradx(k,j,icg)
17296 gphii=gphii+dxdv(k+3,ind1)*gradx(k,j,icg)
17299 if (i.gt.1) g(i-1)=gphii
17300 if (n.gt.nphi) g(nphi+i)=gthetai
17302 if (n.le.nphi+ntheta) goto 10
17304 if (itype(i,1).ne.10) then
17308 galphai=galphai+dxds(k,i)*gradx(k,i,icg)
17311 gomegai=gomegai+dxds(k+3,i)*gradx(k,i,icg)
17313 g(ialph(i,1))=galphai
17314 g(ialph(i,1)+nside)=gomegai
17318 ! Add the components corresponding to local energy terms.
17322 !d write (iout,*) 'i=',i,'g=',g(i),' gloc=',gloc(i,icg)
17323 g(i)=g(i)+gloc(i,icg)
17325 ! Uncomment following three lines for diagnostics.
17327 !elwrite(iout,*) "in gradient after calling intout"
17328 !d call briefout(0,0.0d0)
17329 !d write (iout,'(i3,1pe15.5)') (k,g(k),k=1,n)
17331 end subroutine gradient
17332 !-----------------------------------------------------------------------------
17333 subroutine func(n,x,nf,f,uiparm,urparm,ufparm) !from minimize_p.F
17336 ! implicit real*8 (a-h,o-z)
17337 ! include 'DIMENSIONS'
17338 ! include 'COMMON.DERIV'
17339 ! include 'COMMON.IOUNITS'
17340 ! include 'COMMON.GEO'
17343 !el common /chuju/ jjj
17344 real(kind=8) :: energia(0:n_ene)
17345 integer :: uiparm(1)
17346 real(kind=8) :: urparm(1)
17348 real(kind=8),external :: ufparm
17349 real(kind=8),dimension(6*nres) :: x !(maxvar) (maxvar=6*maxres)
17350 ! if (jjj.gt.0) then
17351 ! write (iout,'(10f8.3)') (rad2deg*x(i),i=1,n)
17355 !d print *,'func',nf,nfl,icg
17356 call var_to_geom(n,x)
17359 !d write (iout,*) 'ETOTAL called from FUNC'
17360 call etotal(energia)
17363 ! if (jjj.gt.0) then
17364 ! write (iout,'(10f8.3)') (rad2deg*x(i),i=1,n)
17365 ! write (iout,*) 'f=',etot
17369 end subroutine func
17370 !-----------------------------------------------------------------------------
17371 subroutine cartgrad
17372 ! implicit real*8 (a-h,o-z)
17373 ! include 'DIMENSIONS'
17375 use MD_data, only: totT,usampl,eq_time
17379 ! include 'COMMON.CHAIN'
17380 ! include 'COMMON.DERIV'
17381 ! include 'COMMON.VAR'
17382 ! include 'COMMON.INTERACT'
17383 ! include 'COMMON.FFIELD'
17384 ! include 'COMMON.MD'
17385 ! include 'COMMON.IOUNITS'
17386 ! include 'COMMON.TIME1'
17389 real(kind=8) :: time00,time01
17391 ! This subrouting calculates total Cartesian coordinate gradient.
17392 ! The subroutine chainbuild_cart and energy MUST be called beforehand.
17395 #ifdef TIMINGtime01
17403 !el write (iout,*) "After sum_gradient"
17405 write (iout,*) "After sum_gradient"
17407 write (iout,*) i," gradc ",(gradc(j,i,icg),j=1,3)
17408 write (iout,*) i," gradx ",(gradx(j,i,icg),j=1,3)
17412 ! If performing constraint dynamics, add the gradients of the constraint energy
17413 if(usampl.and.totT.gt.eq_time) then
17416 gradc(j,i,icg)=gradc(j,i,icg)+dudconst(j,i)+duscdiff(j,i)
17417 gradx(j,i,icg)=gradx(j,i,icg)+dudxconst(j,i)+duscdiffx(j,i)
17421 gloc(i,icg)=gloc(i,icg)+dugamma(i)
17424 gloc(nphi+i,icg)=gloc(nphi+i,icg)+dutheta(i)
17427 !elwrite (iout,*) "After sum_gradient"
17432 !elwrite (iout,*) "After sum_gradient"
17434 time_intcartderiv=time_intcartderiv+MPI_Wtime()-time01
17436 ! call checkintcartgrad
17437 ! write(iout,*) 'calling int_to_cart'
17440 write (iout,*) "gcart, gxcart, gloc before int_to_cart"
17444 gcart(j,i)=gradc(j,i,icg)
17445 gxcart(j,i)=gradx(j,i,icg)
17446 ! if (i.le.2) print *,"gcart_one",gcart(j,i),gradc(j,i,icg)
17449 write (iout,'(i5,2(3f10.5,5x),f10.5)') i,(gcart(j,i),j=1,3),&
17450 (gxcart(j,i),j=1,3),gloc(i,icg)
17456 ! print *,"gcart_two",gxcart(2,2),gradx(2,2,icg)
17458 ! print *,"gcart_two",gxcart(2,2),gradx(2,2,icg)
17461 time_inttocart=time_inttocart+MPI_Wtime()-time01
17464 write (iout,*) "gcart and gxcart after int_to_cart"
17466 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
17467 (gxcart(j,i),j=1,3)
17473 write (iout,*) "CARGRAD"
17477 gcart(j,i)=-gcart(j,i)+gcart(j,i-1)-gxcart(j,i)
17478 ! gcart_new(j,i)=-gcart(j,i)+gcart(j,i-1)-gxcart(j,i)
17480 ! write (iout,'(i5,3f10.5,5x,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3), &
17481 ! (gcart_new(j,i),j=1,3),(gxcart(j,i),j=1,3)
17483 ! Correction: dummy residues
17486 ! gcart_new(j,nnt)=gcart_new(j,nnt)+gcart_new(j,1)
17487 gcart(j,nnt)=gcart(j,nnt)+gcart(j,1)
17490 if (nct.lt.nres) then
17492 ! gcart_new(j,nct)=gcart_new(j,nct)+gcart_new(j,nres)
17493 gcart(j,nct)=gcart(j,nct)+gcart(j,nres)
17498 time_cartgrad=time_cartgrad+MPI_Wtime()-time00
17502 end subroutine cartgrad
17503 !-----------------------------------------------------------------------------
17504 subroutine zerograd
17505 ! implicit real*8 (a-h,o-z)
17506 ! include 'DIMENSIONS'
17507 ! include 'COMMON.DERIV'
17508 ! include 'COMMON.CHAIN'
17509 ! include 'COMMON.VAR'
17510 ! include 'COMMON.MD'
17511 ! include 'COMMON.SCCOR'
17513 !el local variables
17514 integer :: i,j,intertyp,k
17515 ! Initialize Cartesian-coordinate gradient
17517 ! if (.not.allocated(gradx)) allocate(gradx(3,nres,2)) !(3,maxres,2)
17518 ! if (.not.allocated(gradc)) allocate(gradc(3,nres,2)) !(3,maxres,2)
17520 ! allocate(gvdwx(3,nres),gvdwc(3,nres),gelc(3,nres),gelc_long(3,nres))
17521 ! allocate(gvdwpp(3,nres),gvdwc_scpp(3,nres),gradx_scp(3,nres))
17522 ! allocate(gvdwc_scp(3,nres),ghpbx(3,nres),ghpbc(3,nres))
17523 ! allocate(gradcorr_long(3,nres))
17524 ! allocate(gradcorr5_long(3,nres),gradcorr6_long(3,nres))
17525 ! allocate(gcorr6_turn_long(3,nres))
17526 ! allocate(gradcorr5(3,nres),gradcorr6(3,nres)) !(3,maxres)
17528 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres)) !(3,maxres)
17530 ! allocate(gel_loc(3,nres),gel_loc_long(3,nres),gcorr3_turn(3,nres))
17531 ! allocate(gcorr4_turn(3,nres),gcorr6_turn(3,nres))
17533 ! if (.not.allocated(gradb)) allocate(gradb(3,nres)) !(3,maxres)
17534 ! if (.not.allocated(gradbx)) allocate(gradbx(3,nres)) !(3,maxres)
17536 ! allocate(gsccorc(3,nres),gsccorx(3,nres)) !(3,maxres)
17537 ! allocate(gscloc(3,nres)) !(3,maxres)
17538 ! if (.not.allocated(gsclocx)) allocate(gsclocx(3,nres)) !(3,maxres)
17542 ! common /deriv_scloc/
17543 ! allocate(dXX_C1tab(3,nres),dYY_C1tab(3,nres),dZZ_C1tab(3,nres))
17544 ! allocate(dXX_Ctab(3,nres),dYY_Ctab(3,nres),dZZ_Ctab(3,nres))
17545 ! allocate(dXX_XYZtab(3,nres),dYY_XYZtab(3,nres),dZZ_XYZtab(3,nres)) !(3,maxres)
17547 ! allocate(jgrad_start(nres),jgrad_end(nres)) !(maxres)
17551 ! gradc(j,i,icg)=0.0d0
17552 ! gradx(j,i,icg)=0.0d0
17554 ! allocate(gloc_sc(3,nres,10)) !(3,0:maxres2,10)maxres2=2*maxres
17555 !elwrite(iout,*) "icg",icg
17559 gradx_scp(j,i)=0.0D0
17561 gvdwc_scp(j,i)=0.0D0
17562 gvdwc_scpp(j,i)=0.0d0
17564 gelc_long(j,i)=0.0D0
17569 gel_loc_long(j,i)=0.0d0
17572 gcorr3_turn(j,i)=0.0d0
17573 gcorr4_turn(j,i)=0.0d0
17574 gradcorr(j,i)=0.0d0
17575 gradcorr_long(j,i)=0.0d0
17576 gradcorr5_long(j,i)=0.0d0
17577 gradcorr6_long(j,i)=0.0d0
17578 gcorr6_turn_long(j,i)=0.0d0
17579 gradcorr5(j,i)=0.0d0
17580 gradcorr6(j,i)=0.0d0
17581 gcorr6_turn(j,i)=0.0d0
17584 gradc(j,i,icg)=0.0d0
17585 gradx(j,i,icg)=0.0d0
17588 gliptran(j,i)=0.0d0
17589 gliptranx(j,i)=0.0d0
17590 gliptranc(j,i)=0.0d0
17591 gshieldx(j,i)=0.0d0
17592 gshieldc(j,i)=0.0d0
17593 gshieldc_loc(j,i)=0.0d0
17594 gshieldx_ec(j,i)=0.0d0
17595 gshieldc_ec(j,i)=0.0d0
17596 gshieldc_loc_ec(j,i)=0.0d0
17597 gshieldx_t3(j,i)=0.0d0
17598 gshieldc_t3(j,i)=0.0d0
17599 gshieldc_loc_t3(j,i)=0.0d0
17600 gshieldx_t4(j,i)=0.0d0
17601 gshieldc_t4(j,i)=0.0d0
17602 gshieldc_loc_t4(j,i)=0.0d0
17603 gshieldx_ll(j,i)=0.0d0
17604 gshieldc_ll(j,i)=0.0d0
17605 gshieldc_loc_ll(j,i)=0.0d0
17607 gg_tube_sc(j,i)=0.0d0
17609 gradb_nucl(j,i)=0.0d0
17610 gradbx_nucl(j,i)=0.0d0
17611 gvdwpp_nucl(j,i)=0.0d0
17615 gvdwpsb1(j,i)=0.0d0
17619 gradcorr_nucl(j,i)=0.0d0
17620 gradcorr3_nucl(j,i)=0.0d0
17621 gradxorr_nucl(j,i)=0.0d0
17622 gradxorr3_nucl(j,i)=0.0d0
17626 gradpepcat(j,i)=0.0d0
17627 gradpepcatx(j,i)=0.0d0
17628 gradcatcat(j,i)=0.0d0
17629 gvdwx_scbase(j,i)=0.0d0
17630 gvdwc_scbase(j,i)=0.0d0
17631 gvdwx_pepbase(j,i)=0.0d0
17632 gvdwc_pepbase(j,i)=0.0d0
17633 gvdwx_scpho(j,i)=0.0d0
17634 gvdwc_scpho(j,i)=0.0d0
17635 gvdwc_peppho(j,i)=0.0d0
17636 gradnuclcatx(j,i)=0.0d0
17637 gradnuclcat(j,i)=0.0d0
17638 duscdiff(j,i)=0.0d0
17639 duscdiffx(j,i)=0.0d0
17645 gloc_sc(intertyp,i,icg)=0.0d0
17654 grad_shield_side(k,j,i)=0.0d0
17655 grad_shield_loc(k,j,i)=0.0d0
17662 ! Initialize the gradient of local energy terms.
17664 ! allocate(gloc(4*nres,2)) !!(maxvar,2)(maxvar=6*maxres)
17665 ! if (.not.allocated(gel_loc_loc)) allocate(gel_loc_loc(nres)) !(maxvar)(maxvar=6*maxres)
17666 ! if (.not.allocated(gcorr_loc)) allocate(gcorr_loc(nres)) !(maxvar)(maxvar=6*maxres)
17667 ! allocate(g_corr5_loc(nres),g_corr6_loc(nres)) !(maxvar)(maxvar=6*maxres)
17668 ! allocate(gel_loc_turn3(nres))
17669 ! allocate(gel_loc_turn4(nres),gel_loc_turn6(nres)) !(maxvar)(maxvar=6*maxres)
17670 ! allocate(gsccor_loc(nres)) !(maxres)
17676 gel_loc_loc(i)=0.0d0
17678 g_corr5_loc(i)=0.0d0
17679 g_corr6_loc(i)=0.0d0
17680 gel_loc_turn3(i)=0.0d0
17681 gel_loc_turn4(i)=0.0d0
17682 gel_loc_turn6(i)=0.0d0
17683 gsccor_loc(i)=0.0d0
17685 ! initialize gcart and gxcart
17686 ! allocate(gcart(3,0:nres),gxcart(3,0:nres)) !(3,0:MAXRES)
17694 end subroutine zerograd
17695 !-----------------------------------------------------------------------------
17696 real(kind=8) function fdum()
17700 !-----------------------------------------------------------------------------
17702 !-----------------------------------------------------------------------------
17703 subroutine intcartderiv
17704 ! implicit real*8 (a-h,o-z)
17705 ! include 'DIMENSIONS'
17709 ! include 'COMMON.SETUP'
17710 ! include 'COMMON.CHAIN'
17711 ! include 'COMMON.VAR'
17712 ! include 'COMMON.GEO'
17713 ! include 'COMMON.INTERACT'
17714 ! include 'COMMON.DERIV'
17715 ! include 'COMMON.IOUNITS'
17716 ! include 'COMMON.LOCAL'
17717 ! include 'COMMON.SCCOR'
17718 real(kind=8) :: pi4,pi34
17719 real(kind=8),dimension(3,2,nres) :: dcostheta ! (3,2,maxres)
17720 real(kind=8),dimension(3,3,nres) :: dcosphi,dsinphi,dcosalpha,&
17721 dcosomega,dsinomega !(3,3,maxres)
17722 real(kind=8),dimension(3) :: vo1,vo2,vo3,dummy,vp1,vp2,vp3,vpp1,n
17725 real(kind=8) :: cost,sint,cost1,sint1,cost2,sint2,sing,cosg,scalp,&
17726 fac0,fac1,fac2,fac3,fac4,fac5,fac6,ctgt,ctgt1,cosg_inv,&
17727 fac7,fac8,fac9,scala1,scala2,cosa,sina,sino,fac15,fac16,&
17728 fac17,coso_inv,fac10,fac11,fac12,fac13,fac14,IERROR
17732 !el from module energy-------------
17733 !el allocate(dcostau(3,3,3,itau_start:itau_end)) !(3,3,3,maxres2)maxres2=2*maxres
17734 !el allocate(dsintau(3,3,3,itau_start:itau_end))
17735 !el allocate(dtauangle(3,3,3,itau_start:itau_end))
17737 !el allocate(dcostau(3,3,3,0:nres2)) !(3,3,3,maxres2)maxres2=2*maxres
17738 !el allocate(dsintau(3,3,3,0:nres2))
17739 !el allocate(dtauangle(3,3,3,0:nres2))
17740 !el allocate(domicron(3,2,2,0:nres2))
17741 !el allocate(dcosomicron(3,2,2,0:nres2))
17745 #if defined(MPI) && defined(PARINTDER)
17746 if (nfgtasks.gt.1 .and. me.eq.king) &
17747 call MPI_Bcast(8,1,MPI_INTEGER,king,FG_COMM,IERROR)
17752 ! allocate(dtheta(3,2,nres)) !(3,2,maxres)
17753 ! allocate(dphi(3,3,nres),dalpha(3,3,nres),domega(3,3,nres)) !(3,3,maxres)
17755 ! write (iout,*) "iphi1_start",iphi1_start," iphi1_end",iphi1_end
17758 dtheta(j,1,i)=0.0d0
17759 dtheta(j,2,i)=0.0d0
17763 dcosomicron(j,1,1,i)=0.0d0
17764 dcosomicron(j,1,2,i)=0.0d0
17765 dcosomicron(j,2,1,i)=0.0d0
17766 dcosomicron(j,2,2,i)=0.0d0
17769 ! Derivatives of theta's
17770 #if defined(MPI) && defined(PARINTDER)
17771 ! We need dtheta(:,:,i-1) to compute dphi(:,:,i)
17772 do i=max0(ithet_start-1,3),ithet_end
17776 cost=dcos(theta(i))
17777 sint=sqrt(1-cost*cost)
17779 dcostheta(j,1,i)=-(dc_norm(j,i-1)+cost*dc_norm(j,i-2))/&
17781 if (itype(i-1,1).ne.ntyp1) dtheta(j,1,i)=-dcostheta(j,1,i)/sint
17782 dcostheta(j,2,i)=-(dc_norm(j,i-2)+cost*dc_norm(j,i-1))/&
17784 if (itype(i-1,1).ne.ntyp1) dtheta(j,2,i)=-dcostheta(j,2,i)/sint
17787 #if defined(MPI) && defined(PARINTDER)
17788 ! We need dtheta(:,:,i-1) to compute dphi(:,:,i)
17789 do i=max0(ithet_start-1,3),ithet_end
17793 if ((itype(i-1,1).ne.10).and.(itype(i-1,1).ne.ntyp1).and.molnum(i).ne.5) then
17794 cost1=dcos(omicron(1,i))
17795 sint1=sqrt(1-cost1*cost1)
17796 cost2=dcos(omicron(2,i))
17797 sint2=sqrt(1-cost2*cost2)
17799 !C Calculate derivative over first omicron (Cai-2,Cai-1,SCi-1)
17800 dcosomicron(j,1,1,i)=-(dc_norm(j,i-1+nres)+ &
17801 cost1*dc_norm(j,i-2))/ &
17803 domicron(j,1,1,i)=-1.0/sint1*dcosomicron(j,1,1,i)
17804 dcosomicron(j,1,2,i)=-(dc_norm(j,i-2) &
17805 +cost1*(dc_norm(j,i-1+nres)))/ &
17807 domicron(j,1,2,i)=-1.0/sint1*dcosomicron(j,1,2,i)
17808 !C Calculate derivative over second omicron Sci-1,Cai-1 Cai
17809 !C Looks messy but better than if in loop
17810 dcosomicron(j,2,1,i)=-(-dc_norm(j,i-1+nres) &
17811 +cost2*dc_norm(j,i-1))/ &
17813 domicron(j,2,1,i)=-1.0/sint2*dcosomicron(j,2,1,i)
17814 dcosomicron(j,2,2,i)=-(dc_norm(j,i-1) &
17815 +cost2*(-dc_norm(j,i-1+nres)))/ &
17817 ! write(iout,*) "vbld", i,itype(i,1),vbld(i-1+nres)
17818 domicron(j,2,2,i)=-1.0/sint2*dcosomicron(j,2,2,i)
17822 !elwrite(iout,*) "after vbld write"
17823 ! Derivatives of phi:
17824 ! If phi is 0 or 180 degrees, then the formulas
17825 ! have to be derived by power series expansion of the
17826 ! conventional formulas around 0 and 180.
17828 do i=iphi1_start,iphi1_end
17832 ! if (itype(i-1,1).eq.21 .or. itype(i-2,1).eq.21 ) cycle
17833 ! the conventional case
17834 sint=dsin(theta(i))
17835 sint1=dsin(theta(i-1))
17837 cost=dcos(theta(i))
17838 cost1=dcos(theta(i-1))
17840 scalp=scalar(dc_norm(1,i-3),dc_norm(1,i-1))
17841 fac0=1.0d0/(sint1*sint)
17844 fac3=cosg*cost1/(sint1*sint1)
17845 fac4=cosg*cost/(sint*sint)
17846 ! Obtaining the gamma derivatives from sine derivative
17847 if (phi(i).gt.-pi4.and.phi(i).le.pi4.or. &
17848 phi(i).gt.pi34.and.phi(i).le.pi.or. &
17849 phi(i).ge.-pi.and.phi(i).le.-pi34) then
17850 call vecpr(dc_norm(1,i-1),dc_norm(1,i-2),vp1)
17851 call vecpr(dc_norm(1,i-3),dc_norm(1,i-1),vp2)
17852 call vecpr(dc_norm(1,i-3),dc_norm(1,i-2),vp3)
17856 cosg_inv=1.0d0/cosg
17857 if (itype(i-1,1).ne.ntyp1 .and. itype(i-2,1).ne.ntyp1) then
17858 dsinphi(j,1,i)=-sing*ctgt1*dtheta(j,1,i-1) &
17859 -(fac0*vp1(j)+sing*dc_norm(j,i-3))*vbld_inv(i-2)
17860 dphi(j,1,i)=cosg_inv*dsinphi(j,1,i)
17862 -sing*(ctgt1*dtheta(j,2,i-1)+ctgt*dtheta(j,1,i)) &
17863 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
17864 dphi(j,2,i)=cosg_inv*dsinphi(j,2,i)
17865 dsinphi(j,3,i)=-sing*ctgt*dtheta(j,2,i) &
17866 +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i)
17867 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
17868 dphi(j,3,i)=cosg_inv*dsinphi(j,3,i)
17870 ! Bug fixed 3/24/05 (AL)
17872 ! Obtaining the gamma derivatives from cosine derivative
17875 if (itype(i-1,1).ne.ntyp1 .and. itype(i-2,1).ne.ntyp1) then
17876 dcosphi(j,1,i)=fac1*dcostheta(j,1,i-1)+fac3* &
17877 dcostheta(j,1,i-1)-fac0*(dc_norm(j,i-1)-scalp* &
17878 dc_norm(j,i-3))/vbld(i-2)
17879 dphi(j,1,i)=-1.0/sing*dcosphi(j,1,i)
17880 dcosphi(j,2,i)=fac1*dcostheta(j,2,i-1)+fac2* &
17881 dcostheta(j,1,i)+fac3*dcostheta(j,2,i-1)+fac4* &
17883 dphi(j,2,i)=-1.0/sing*dcosphi(j,2,i)
17884 dcosphi(j,3,i)=fac2*dcostheta(j,2,i)+fac4* &
17885 dcostheta(j,2,i)-fac0*(dc_norm(j,i-3)-scalp* &
17886 dc_norm(j,i-1))/vbld(i)
17887 dphi(j,3,i)=-1.0/sing*dcosphi(j,3,i)
17890 write(iout,*) "just after",dphi(j,3,i),sing,dcosphi(j,3,i)
17897 !alculate derivative of Tauangle
17899 do i=itau_start,itau_end
17902 !elwrite(iout,*) " vecpr",i,nres
17904 if ((itype(i-2,1).eq.ntyp1).or.(itype(i-2,1).eq.10)) cycle
17905 ! if ((itype(i-2,1).eq.ntyp1).or.(itype(i-2,1).eq.10).or.
17906 ! & (itype(i-1,1).eq.ntyp1).or.(itype(i,1).eq.ntyp1)) cycle
17907 !c dtauangle(j,intertyp,dervityp,residue number)
17908 !c INTERTYP=1 SC...Ca...Ca..Ca
17909 ! the conventional case
17910 sint=dsin(theta(i))
17911 sint1=dsin(omicron(2,i-1))
17912 sing=dsin(tauangle(1,i))
17913 cost=dcos(theta(i))
17914 cost1=dcos(omicron(2,i-1))
17915 cosg=dcos(tauangle(1,i))
17916 !elwrite(iout,*) " vecpr5",i,nres
17918 !elwrite(iout,*) " vecpreee",i,nres,j,i-2+nres
17919 !elwrite(iout,*) " vecpr5",dc_norm2(1,1)
17920 dc_norm2(j,i-2+nres)=-dc_norm(j,i-2+nres)
17921 ! write(iout,*) dc_norm2(j,i-2+nres),"dcnorm"
17923 scalp=scalar(dc_norm2(1,i-2+nres),dc_norm(1,i-1))
17924 fac0=1.0d0/(sint1*sint)
17927 fac3=cosg*cost1/(sint1*sint1)
17928 fac4=cosg*cost/(sint*sint)
17929 ! write(iout,*) "faki",fac0,fac1,fac2,fac3,fac4
17930 ! Obtaining the gamma derivatives from sine derivative
17931 if (tauangle(1,i).gt.-pi4.and.tauangle(1,i).le.pi4.or. &
17932 tauangle(1,i).gt.pi34.and.tauangle(1,i).le.pi.or. &
17933 tauangle(1,i).gt.-pi.and.tauangle(1,i).le.-pi34) then
17934 call vecpr(dc_norm(1,i-1),dc_norm(1,i-2),vp1)
17935 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-1),vp2)
17936 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-2),vp3)
17940 cosg_inv=1.0d0/cosg
17941 dsintau(j,1,1,i)=-sing*ctgt1*domicron(j,2,2,i-1) &
17942 -(fac0*vp1(j)+sing*(dc_norm2(j,i-2+nres))) &
17943 *vbld_inv(i-2+nres)
17944 dtauangle(j,1,1,i)=cosg_inv*dsintau(j,1,1,i)
17945 dsintau(j,1,2,i)= &
17946 -sing*(ctgt1*domicron(j,2,1,i-1)+ctgt*dtheta(j,1,i)) &
17947 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
17948 ! write(iout,*) "dsintau", dsintau(j,1,2,i)
17949 dtauangle(j,1,2,i)=cosg_inv*dsintau(j,1,2,i)
17950 ! Bug fixed 3/24/05 (AL)
17951 dsintau(j,1,3,i)=-sing*ctgt*dtheta(j,2,i) &
17952 +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i)
17953 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
17954 dtauangle(j,1,3,i)=cosg_inv*dsintau(j,1,3,i)
17956 ! Obtaining the gamma derivatives from cosine derivative
17959 dcostau(j,1,1,i)=fac1*dcosomicron(j,2,2,i-1)+fac3* &
17960 dcosomicron(j,2,2,i-1)-fac0*(dc_norm(j,i-1)-scalp* &
17961 (dc_norm2(j,i-2+nres)))/vbld(i-2+nres)
17962 dtauangle(j,1,1,i)=-1/sing*dcostau(j,1,1,i)
17963 dcostau(j,1,2,i)=fac1*dcosomicron(j,2,1,i-1)+fac2* &
17964 dcostheta(j,1,i)+fac3*dcosomicron(j,2,1,i-1)+fac4* &
17966 dtauangle(j,1,2,i)=-1/sing*dcostau(j,1,2,i)
17967 dcostau(j,1,3,i)=fac2*dcostheta(j,2,i)+fac4* &
17968 dcostheta(j,2,i)-fac0*(-dc_norm(j,i-2+nres)-scalp* &
17969 dc_norm(j,i-1))/vbld(i)
17970 dtauangle(j,1,3,i)=-1/sing*dcostau(j,1,3,i)
17971 ! write (iout,*) "else",i
17975 ! write(iout,*) "tu",i,k,(dtauangle(j,1,k,i),j=1,3)
17978 !C Second case Ca...Ca...Ca...SC
17980 do i=itau_start,itau_end
17984 if ((itype(i-1,1).eq.ntyp1).or.(itype(i-1,1).eq.10).or. &
17985 (itype(i-2,1).eq.ntyp1).or.(itype(i-3,1).eq.ntyp1)) cycle
17986 ! the conventional case
17987 sint=dsin(omicron(1,i))
17988 sint1=dsin(theta(i-1))
17989 sing=dsin(tauangle(2,i))
17990 cost=dcos(omicron(1,i))
17991 cost1=dcos(theta(i-1))
17992 cosg=dcos(tauangle(2,i))
17994 ! dc_norm2(j,i-1+nres)=-dc_norm(j,i-1+nres)
17996 scalp=scalar(dc_norm(1,i-3),dc_norm(1,i-1+nres))
17997 fac0=1.0d0/(sint1*sint)
18000 fac3=cosg*cost1/(sint1*sint1)
18001 fac4=cosg*cost/(sint*sint)
18002 ! Obtaining the gamma derivatives from sine derivative
18003 if (tauangle(2,i).gt.-pi4.and.tauangle(2,i).le.pi4.or. &
18004 tauangle(2,i).gt.pi34.and.tauangle(2,i).le.pi.or. &
18005 tauangle(2,i).gt.-pi.and.tauangle(2,i).le.-pi34) then
18006 call vecpr(dc_norm2(1,i-1+nres),dc_norm(1,i-2),vp1)
18007 call vecpr(dc_norm(1,i-3),dc_norm(1,i-1+nres),vp2)
18008 call vecpr(dc_norm(1,i-3),dc_norm(1,i-2),vp3)
18012 cosg_inv=1.0d0/cosg
18013 dsintau(j,2,1,i)=-sing*ctgt1*dtheta(j,1,i-1) &
18014 +(fac0*vp1(j)-sing*dc_norm(j,i-3))*vbld_inv(i-2)
18015 ! write(iout,*) i,j,dsintau(j,2,1,i),sing*ctgt1*dtheta(j,1,i-1),
18016 ! &fac0*vp1(j),sing*dc_norm(j,i-3),vbld_inv(i-2),"dsintau(2,1)"
18017 dtauangle(j,2,1,i)=cosg_inv*dsintau(j,2,1,i)
18018 dsintau(j,2,2,i)= &
18019 -sing*(ctgt1*dtheta(j,2,i-1)+ctgt*domicron(j,1,1,i)) &
18020 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
18021 ! write(iout,*) "sprawdzenie",i,j,sing*ctgt1*dtheta(j,2,i-1),
18022 ! & sing*ctgt*domicron(j,1,2,i),
18023 ! & (fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
18024 dtauangle(j,2,2,i)=cosg_inv*dsintau(j,2,2,i)
18025 ! Bug fixed 3/24/05 (AL)
18026 dsintau(j,2,3,i)=-sing*ctgt*domicron(j,1,2,i) &
18027 +(fac0*vp3(j)-sing*dc_norm(j,i-1+nres))*vbld_inv(i-1+nres)
18028 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
18029 dtauangle(j,2,3,i)=cosg_inv*dsintau(j,2,3,i)
18031 ! Obtaining the gamma derivatives from cosine derivative
18034 dcostau(j,2,1,i)=fac1*dcostheta(j,1,i-1)+fac3* &
18035 dcostheta(j,1,i-1)-fac0*(dc_norm(j,i-1+nres)-scalp* &
18036 dc_norm(j,i-3))/vbld(i-2)
18037 dtauangle(j,2,1,i)=-1/sing*dcostau(j,2,1,i)
18038 dcostau(j,2,2,i)=fac1*dcostheta(j,2,i-1)+fac2* &
18039 dcosomicron(j,1,1,i)+fac3*dcostheta(j,2,i-1)+fac4* &
18040 dcosomicron(j,1,1,i)
18041 dtauangle(j,2,2,i)=-1/sing*dcostau(j,2,2,i)
18042 dcostau(j,2,3,i)=fac2*dcosomicron(j,1,2,i)+fac4* &
18043 dcosomicron(j,1,2,i)-fac0*(dc_norm(j,i-3)-scalp* &
18044 dc_norm(j,i-1+nres))/vbld(i-1+nres)
18045 dtauangle(j,2,3,i)=-1/sing*dcostau(j,2,3,i)
18046 ! write(iout,*) i,j,"else", dtauangle(j,2,3,i)
18051 !CC third case SC...Ca...Ca...SC
18054 do i=itau_start,itau_end
18058 ! the conventional case
18059 if ((itype(i-1,1).eq.ntyp1).or.(itype(i-1,1).eq.10).or. &
18060 (itype(i-2,1).eq.ntyp1).or.(itype(i-2,1).eq.10)) cycle
18061 sint=dsin(omicron(1,i))
18062 sint1=dsin(omicron(2,i-1))
18063 sing=dsin(tauangle(3,i))
18064 cost=dcos(omicron(1,i))
18065 cost1=dcos(omicron(2,i-1))
18066 cosg=dcos(tauangle(3,i))
18068 dc_norm2(j,i-2+nres)=-dc_norm(j,i-2+nres)
18069 ! dc_norm2(j,i-1+nres)=-dc_norm(j,i-1+nres)
18071 scalp=scalar(dc_norm2(1,i-2+nres),dc_norm(1,i-1+nres))
18072 fac0=1.0d0/(sint1*sint)
18075 fac3=cosg*cost1/(sint1*sint1)
18076 fac4=cosg*cost/(sint*sint)
18077 ! Obtaining the gamma derivatives from sine derivative
18078 if (tauangle(3,i).gt.-pi4.and.tauangle(3,i).le.pi4.or. &
18079 tauangle(3,i).gt.pi34.and.tauangle(3,i).le.pi.or. &
18080 tauangle(3,i).gt.-pi.and.tauangle(3,i).le.-pi34) then
18081 call vecpr(dc_norm(1,i-1+nres),dc_norm(1,i-2),vp1)
18082 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-1+nres),vp2)
18083 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-2),vp3)
18087 cosg_inv=1.0d0/cosg
18088 dsintau(j,3,1,i)=-sing*ctgt1*domicron(j,2,2,i-1) &
18089 -(fac0*vp1(j)-sing*dc_norm(j,i-2+nres)) &
18090 *vbld_inv(i-2+nres)
18091 dtauangle(j,3,1,i)=cosg_inv*dsintau(j,3,1,i)
18092 dsintau(j,3,2,i)= &
18093 -sing*(ctgt1*domicron(j,2,1,i-1)+ctgt*domicron(j,1,1,i)) &
18094 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
18095 dtauangle(j,3,2,i)=cosg_inv*dsintau(j,3,2,i)
18096 ! Bug fixed 3/24/05 (AL)
18097 dsintau(j,3,3,i)=-sing*ctgt*domicron(j,1,2,i) &
18098 +(fac0*vp3(j)-sing*dc_norm(j,i-1+nres)) &
18099 *vbld_inv(i-1+nres)
18100 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
18101 dtauangle(j,3,3,i)=cosg_inv*dsintau(j,3,3,i)
18103 ! Obtaining the gamma derivatives from cosine derivative
18106 dcostau(j,3,1,i)=fac1*dcosomicron(j,2,2,i-1)+fac3* &
18107 dcosomicron(j,2,2,i-1)-fac0*(dc_norm(j,i-1+nres)-scalp* &
18108 dc_norm2(j,i-2+nres))/vbld(i-2+nres)
18109 dtauangle(j,3,1,i)=-1/sing*dcostau(j,3,1,i)
18110 dcostau(j,3,2,i)=fac1*dcosomicron(j,2,1,i-1)+fac2* &
18111 dcosomicron(j,1,1,i)+fac3*dcosomicron(j,2,1,i-1)+fac4* &
18112 dcosomicron(j,1,1,i)
18113 dtauangle(j,3,2,i)=-1/sing*dcostau(j,3,2,i)
18114 dcostau(j,3,3,i)=fac2*dcosomicron(j,1,2,i)+fac4* &
18115 dcosomicron(j,1,2,i)-fac0*(dc_norm2(j,i-2+nres)-scalp* &
18116 dc_norm(j,i-1+nres))/vbld(i-1+nres)
18117 dtauangle(j,3,3,i)=-1/sing*dcostau(j,3,3,i)
18118 ! write(iout,*) "else",i
18124 ! Derivatives of side-chain angles alpha and omega
18125 #if defined(MPI) && defined(PARINTDER)
18126 do i=ibond_start,ibond_end
18130 if(itype(i,1).ne.10 .and. itype(i,1).ne.ntyp1) then
18131 fac5=1.0d0/dsqrt(2*(1+dcos(theta(i+1))))
18134 fac8=fac5/vbld(i+1)
18135 fac9=fac5/vbld(i+nres)
18136 scala1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
18137 scala2=scalar(dc_norm(1,i),dc_norm(1,i+nres))
18138 cosa=dsqrt(0.5d0/(1.0d0+dcos(theta(i+1))))* &
18139 (scalar(dC_norm(1,i),dC_norm(1,i+nres)) &
18140 -scalar(dC_norm(1,i-1),dC_norm(1,i+nres)))
18141 sina=sqrt(1-cosa*cosa)
18143 ! write (iout,*) "i",i," cosa",cosa," sina",sina," sino",sino
18145 dcosalpha(j,1,i)=fac6*(scala1*dc_norm(j,i-1)- &
18146 dc_norm(j,i+nres))-cosa*fac7*dcostheta(j,1,i+1)
18147 dalpha(j,1,i)=-1/sina*dcosalpha(j,1,i)
18148 dcosalpha(j,2,i)=fac8*(dc_norm(j,i+nres)- &
18149 scala2*dc_norm(j,i))-cosa*fac7*dcostheta(j,2,i+1)
18150 dalpha(j,2,i)=-1/sina*dcosalpha(j,2,i)
18151 dcosalpha(j,3,i)=(fac9*(dc_norm(j,i)- &
18152 dc_norm(j,i-1))-(cosa*dc_norm(j,i+nres))/ &
18154 dalpha(j,3,i)=-1/sina*dcosalpha(j,3,i)
18156 ! obtaining the derivatives of omega from sines
18157 if(omeg(i).gt.-pi4.and.omeg(i).le.pi4.or. &
18158 omeg(i).gt.pi34.and.omeg(i).le.pi.or. &
18159 omeg(i).gt.-pi.and.omeg(i).le.-pi34) then
18160 fac15=dcos(theta(i+1))/(dsin(theta(i+1))* &
18162 fac16=dcos(alph(i))/(dsin(alph(i))*dsin(alph(i)))
18163 fac17=1.0d0/(dsin(theta(i+1))*dsin(alph(i)))
18164 call vecpr(dc_norm(1,i+nres),dc_norm(1,i),vo1)
18165 call vecpr(dc_norm(1,i+nres),dc_norm(1,i-1),vo2)
18166 call vecpr(dc_norm(1,i),dc_norm(1,i-1),vo3)
18167 coso_inv=1.0d0/dcos(omeg(i))
18169 dsinomega(j,1,i)=sino*(fac15*dcostheta(j,1,i+1) &
18170 +fac16*dcosalpha(j,1,i))-fac17/vbld(i)*vo1(j)- &
18171 (sino*dc_norm(j,i-1))/vbld(i)
18172 domega(j,1,i)=coso_inv*dsinomega(j,1,i)
18173 dsinomega(j,2,i)=sino*(fac15*dcostheta(j,2,i+1) &
18174 +fac16*dcosalpha(j,2,i))+fac17/vbld(i+1)*vo2(j) &
18175 -sino*dc_norm(j,i)/vbld(i+1)
18176 domega(j,2,i)=coso_inv*dsinomega(j,2,i)
18177 dsinomega(j,3,i)=sino*fac16*dcosalpha(j,3,i)- &
18178 fac17/vbld(i+nres)*vo3(j)-sino*dc_norm(j,i+nres)/ &
18180 domega(j,3,i)=coso_inv*dsinomega(j,3,i)
18183 ! obtaining the derivatives of omega from cosines
18184 fac10=sqrt(0.5d0*(1-dcos(theta(i+1))))
18185 fac11=sqrt(0.5d0*(1+dcos(theta(i+1))))
18190 dcosomega(j,1,i)=(-(0.25d0*cosa/fac11* &
18191 dcostheta(j,1,i+1)+fac11*dcosalpha(j,1,i))*fac12+ &
18192 (0.25d0/fac10*sina*dcostheta(j,1,i+1)+cosa/sina* &
18193 fac10*dcosalpha(j,1,i))*(scala2-fac11*cosa))/fac13
18194 domega(j,1,i)=-1/sino*dcosomega(j,1,i)
18195 dcosomega(j,2,i)=(((dc_norm(j,i+nres)-scala2* &
18196 dc_norm(j,i))/vbld(i+1)-0.25d0*cosa/fac11* &
18197 dcostheta(j,2,i+1)-fac11*dcosalpha(j,2,i))*fac12+ &
18198 (scala2-fac11*cosa)*(0.25d0*sina/fac10* &
18199 dcostheta(j,2,i+1)+fac10*cosa/sina*dcosalpha(j,2,i)))/fac13
18200 domega(j,2,i)=-1/sino*dcosomega(j,2,i)
18201 dcosomega(j,3,i)=1/fac10*((1/vbld(i+nres)*(dc_norm(j,i)- &
18202 scala2*dc_norm(j,i+nres))-fac11*dcosalpha(j,3,i))*sina+ &
18203 (scala2-fac11*cosa)*(cosa/sina*dcosalpha(j,3,i)))/fac14
18204 domega(j,3,i)=-1/sino*dcosomega(j,3,i)
18210 dalpha(k,j,i)=0.0d0
18211 domega(k,j,i)=0.0d0
18217 #if defined(MPI) && defined(PARINTDER)
18218 if (nfgtasks.gt.1) then
18220 !d write (iout,*) "Gather dtheta"
18221 !d call flush(iout)
18222 write (iout,*) "dtheta before gather"
18224 write (iout,'(i3,3(3f8.5,3x))') i,((dtheta(j,k,i),k=1,3),j=1,2)
18227 call MPI_Gatherv(dtheta(1,1,ithet_start),ithet_count(fg_rank),&
18228 MPI_THET,dtheta(1,1,1),ithet_count(0),ithet_displ(0),MPI_THET,&
18229 king,FG_COMM,IERROR)
18232 !d write (iout,*) "Gather dphi"
18233 !d call flush(iout)
18234 write (iout,*) "dphi before gather"
18236 write (iout,'(i3,3(3f8.5,3x))') i,((dphi(j,k,i),k=1,3),j=1,3)
18240 call MPI_Gatherv(dphi(1,1,iphi1_start),iphi1_count(fg_rank),&
18241 MPI_GAM,dphi(1,1,1),iphi1_count(0),iphi1_displ(0),MPI_GAM,&
18242 king,FG_COMM,IERROR)
18243 !d write (iout,*) "Gather dalpha"
18244 !d call flush(iout)
18246 call MPI_Gatherv(dalpha(1,1,ibond_start),ibond_count(fg_rank),&
18247 MPI_GAM,dalpha(1,1,1),ibond_count(0),ibond_displ(0),MPI_GAM,&
18248 king,FG_COMM,IERROR)
18249 !d write (iout,*) "Gather domega"
18250 !d call flush(iout)
18251 call MPI_Gatherv(domega(1,1,ibond_start),ibond_count(fg_rank),&
18252 MPI_GAM,domega(1,1,1),ibond_count(0),ibond_displ(0),MPI_GAM,&
18253 king,FG_COMM,IERROR)
18259 write (iout,*) "dtheta after gather"
18261 write (iout,'(i3,3(3f8.5,3x))') i,((dtheta(j,k,i),j=1,3),k=1,2)
18263 write (iout,*) "dphi after gather"
18265 write (iout,'(i3,3(3f8.5,3x))') i,((dphi(j,k,i),j=1,3),k=1,3)
18267 write (iout,*) "dalpha after gather"
18269 write (iout,'(i3,3(3f8.5,3x))') i,((dalpha(j,k,i),j=1,3),k=1,3)
18271 write (iout,*) "domega after gather"
18273 write (iout,'(i3,3(3f8.5,3x))') i,((domega(j,k,i),j=1,3),k=1,3)
18278 end subroutine intcartderiv
18279 !-----------------------------------------------------------------------------
18280 subroutine checkintcartgrad
18281 ! implicit real*8 (a-h,o-z)
18282 ! include 'DIMENSIONS'
18286 ! include 'COMMON.CHAIN'
18287 ! include 'COMMON.VAR'
18288 ! include 'COMMON.GEO'
18289 ! include 'COMMON.INTERACT'
18290 ! include 'COMMON.DERIV'
18291 ! include 'COMMON.IOUNITS'
18292 ! include 'COMMON.SETUP'
18293 real(kind=8),dimension(3,2,nres) :: dthetanum !(3,2,maxres)
18294 real(kind=8),dimension(3,3,nres) :: dphinum,dalphanum,domeganum !(3,3,maxres)
18295 real(kind=8),dimension(nres) :: theta_s,phi_s,alph_s,omeg_s !(maxres)
18296 real(kind=8),dimension(3) :: dc_norm_s
18297 real(kind=8) :: aincr=1.0d-5
18299 real(kind=8) :: dcji
18302 theta_s(i)=theta(i)
18306 ! Check theta gradient
18308 "Analytical (upper) and numerical (lower) gradient of theta"
18313 dc(j,i-2)=dcji+aincr
18314 call chainbuild_cart
18315 call int_from_cart1(.false.)
18316 dthetanum(j,1,i)=(theta(i)-theta_s(i))/aincr
18319 dc(j,i-1)=dc(j,i-1)+aincr
18320 call chainbuild_cart
18321 dthetanum(j,2,i)=(theta(i)-theta_s(i))/aincr
18324 !el write (iout,'(i5,3f10.5,5x,3f10.5)') i,(dtheta(j,1,i),j=1,3),&
18325 !el (dtheta(j,2,i),j=1,3)
18326 !el write (iout,'(5x,3f10.5,5x,3f10.5)') (dthetanum(j,1,i),j=1,3),&
18327 !el (dthetanum(j,2,i),j=1,3)
18328 !el write (iout,'(5x,3f10.5,5x,3f10.5)') &
18329 !el (dthetanum(j,1,i)/dtheta(j,1,i),j=1,3),&
18330 !el (dthetanum(j,2,i)/dtheta(j,2,i),j=1,3)
18333 ! Check gamma gradient
18335 "Analytical (upper) and numerical (lower) gradient of gamma"
18339 dc(j,i-3)=dcji+aincr
18340 call chainbuild_cart
18341 dphinum(j,1,i)=(phi(i)-phi_s(i))/aincr
18344 dc(j,i-2)=dcji+aincr
18345 call chainbuild_cart
18346 dphinum(j,2,i)=(phi(i)-phi_s(i))/aincr
18349 dc(j,i-1)=dc(j,i-1)+aincr
18350 call chainbuild_cart
18351 dphinum(j,3,i)=(phi(i)-phi_s(i))/aincr
18354 !el write (iout,'(i5,3(3f10.5,5x))') i,(dphi(j,1,i),j=1,3),&
18355 !el (dphi(j,2,i),j=1,3),(dphi(j,3,i),j=1,3)
18356 !el write (iout,'(5x,3(3f10.5,5x))') (dphinum(j,1,i),j=1,3),&
18357 !el (dphinum(j,2,i),j=1,3),(dphinum(j,3,i),j=1,3)
18358 !el write (iout,'(5x,3(3f10.5,5x))') &
18359 !el (dphinum(j,1,i)/dphi(j,1,i),j=1,3),&
18360 !el (dphinum(j,2,i)/dphi(j,2,i),j=1,3),&
18361 !el (dphinum(j,3,i)/dphi(j,3,i),j=1,3)
18364 ! Check alpha gradient
18366 "Analytical (upper) and numerical (lower) gradient of alpha"
18368 if(itype(i,1).ne.10) then
18371 dc(j,i-1)=dcji+aincr
18372 call chainbuild_cart
18373 dalphanum(j,1,i)=(alph(i)-alph_s(i)) &
18378 call chainbuild_cart
18379 dalphanum(j,2,i)=(alph(i)-alph_s(i)) &
18383 dc(j,i+nres)=dc(j,i+nres)+aincr
18384 call chainbuild_cart
18385 dalphanum(j,3,i)=(alph(i)-alph_s(i)) &
18390 !el write (iout,'(i5,3(3f10.5,5x))') i,(dalpha(j,1,i),j=1,3),&
18391 !el (dalpha(j,2,i),j=1,3),(dalpha(j,3,i),j=1,3)
18392 !el write (iout,'(5x,3(3f10.5,5x))') (dalphanum(j,1,i),j=1,3),&
18393 !el (dalphanum(j,2,i),j=1,3),(dalphanum(j,3,i),j=1,3)
18394 !el write (iout,'(5x,3(3f10.5,5x))') &
18395 !el (dalphanum(j,1,i)/dalpha(j,1,i),j=1,3),&
18396 !el (dalphanum(j,2,i)/dalpha(j,2,i),j=1,3),&
18397 !el (dalphanum(j,3,i)/dalpha(j,3,i),j=1,3)
18400 ! Check omega gradient
18402 "Analytical (upper) and numerical (lower) gradient of omega"
18404 if(itype(i,1).ne.10) then
18407 dc(j,i-1)=dcji+aincr
18408 call chainbuild_cart
18409 domeganum(j,1,i)=(omeg(i)-omeg_s(i)) &
18414 call chainbuild_cart
18415 domeganum(j,2,i)=(omeg(i)-omeg_s(i)) &
18419 dc(j,i+nres)=dc(j,i+nres)+aincr
18420 call chainbuild_cart
18421 domeganum(j,3,i)=(omeg(i)-omeg_s(i)) &
18426 !el write (iout,'(i5,3(3f10.5,5x))') i,(domega(j,1,i),j=1,3),&
18427 !el (domega(j,2,i),j=1,3),(domega(j,3,i),j=1,3)
18428 !el write (iout,'(5x,3(3f10.5,5x))') (domeganum(j,1,i),j=1,3),&
18429 !el (domeganum(j,2,i),j=1,3),(domeganum(j,3,i),j=1,3)
18430 !el write (iout,'(5x,3(3f10.5,5x))') &
18431 !el (domeganum(j,1,i)/domega(j,1,i),j=1,3),&
18432 !el (domeganum(j,2,i)/domega(j,2,i),j=1,3),&
18433 !el (domeganum(j,3,i)/domega(j,3,i),j=1,3)
18437 end subroutine checkintcartgrad
18438 !-----------------------------------------------------------------------------
18440 !-----------------------------------------------------------------------------
18441 real(kind=8) function qwolynes(seg1,seg2,flag,seg3,seg4)
18442 ! implicit real*8 (a-h,o-z)
18443 ! include 'DIMENSIONS'
18444 ! include 'COMMON.IOUNITS'
18445 ! include 'COMMON.CHAIN'
18446 ! include 'COMMON.INTERACT'
18447 ! include 'COMMON.VAR'
18448 integer :: i,j,jl,k,l,il,kl,nl,np,ip,kp,seg1,seg2,seg3,seg4,secseg
18449 integer :: kkk,nsep=3
18450 real(kind=8) :: qm !dist,
18451 real(kind=8) :: qq,qqij,qqijCM,dij,d0ij,dijCM,d0ijCM,qqmax
18452 logical :: lprn=.false.
18454 ! real(kind=8) :: sigm,x
18456 !el sigm(x)=0.25d0*x ! local function
18462 do il=seg1+nsep,seg2
18465 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2 + &
18466 (cref(2,jl,kkk)-cref(2,il,kkk))**2 + &
18467 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
18469 qqij = dexp(-0.5d0*((dij-d0ij)/(sigm(d0ij)))**2)
18470 if (itype(il,1).ne.10 .or. itype(jl,1).ne.10) then
18473 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
18474 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
18475 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
18476 dijCM=dist(il+nres,jl+nres)
18477 qqijCM = dexp(-0.5d0*((dijCM-d0ijCM)/(sigm(d0ijCM)))**2)
18479 qq = qq+qqij+qqijCM
18485 if((seg3-il).lt.3) then
18492 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2+ &
18493 (cref(2,jl,kkk)-cref(2,il,kkk))**2+ &
18494 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
18496 qqij = dexp(-0.5d0*((dij-d0ij)/(sigm(d0ij)))**2)
18497 if (itype(il,1).ne.10 .or. itype(jl,1).ne.10) then
18500 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
18501 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
18502 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
18503 dijCM=dist(il+nres,jl+nres)
18504 qqijCM = dexp(-0.5d0*((dijCM-d0ijCM)/(sigm(d0ijCM)))**2)
18506 qq = qq+qqij+qqijCM
18511 if (qqmax.le.qq) qqmax=qq
18513 qwolynes=1.0d0-qqmax
18515 end function qwolynes
18516 !-----------------------------------------------------------------------------
18517 subroutine qwolynes_prim(seg1,seg2,flag,seg3,seg4)
18518 ! implicit real*8 (a-h,o-z)
18519 ! include 'DIMENSIONS'
18520 ! include 'COMMON.IOUNITS'
18521 ! include 'COMMON.CHAIN'
18522 ! include 'COMMON.INTERACT'
18523 ! include 'COMMON.VAR'
18524 ! include 'COMMON.MD'
18525 integer :: i,j,jl,k,l,il,nl,seg1,seg2,seg3,seg4,secseg
18526 integer :: nsep=3, kkk
18527 !el real(kind=8) :: dist
18528 real(kind=8) :: dij,d0ij,dijCM,d0ijCM
18529 logical :: lprn=.false.
18531 real(kind=8) :: sim,dd0,fac,ddqij
18532 !el sigm(x)=0.25d0*x ! local function
18542 do il=seg1+nsep,seg2
18545 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2+ &
18546 (cref(2,jl,kkk)-cref(2,il,kkk))**2+ &
18547 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
18549 sim = 1.0d0/sigm(d0ij)
18552 fac = dd0*sim/dij*dexp(-0.5d0*dd0*dd0*sim)
18554 ddqij = (c(k,il)-c(k,jl))*fac
18555 dqwol(k,il)=dqwol(k,il)+ddqij
18556 dqwol(k,jl)=dqwol(k,jl)-ddqij
18559 if (itype(il,1).ne.10 .or. itype(jl,1).ne.10) then
18562 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
18563 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
18564 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
18565 dijCM=dist(il+nres,jl+nres)
18566 sim = 1.0d0/sigm(d0ijCM)
18569 fac=dd0*sim/dijCM*dexp(-0.5d0*dd0*dd0*sim)
18571 ddqij = (c(k,il+nres)-c(k,jl+nres))*fac
18572 dxqwol(k,il)=dxqwol(k,il)+ddqij
18573 dxqwol(k,jl)=dxqwol(k,jl)-ddqij
18580 if((seg3-il).lt.3) then
18587 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2+ &
18588 (cref(2,jl,kkk)-cref(2,il,kkk))**2+ &
18589 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
18591 sim = 1.0d0/sigm(d0ij)
18594 fac = dd0*sim/dij*dexp(-0.5d0*dd0*dd0*sim)
18596 ddqij = (c(k,il)-c(k,jl))*fac
18597 dqwol(k,il)=dqwol(k,il)+ddqij
18598 dqwol(k,jl)=dqwol(k,jl)-ddqij
18600 if (itype(il,1).ne.10 .or. itype(jl,1).ne.10) then
18603 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
18604 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
18605 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
18606 dijCM=dist(il+nres,jl+nres)
18607 sim = 1.0d0/sigm(d0ijCM)
18610 fac = dd0*sim/dijCM*dexp(-0.5d0*dd0*dd0*sim)
18612 ddqij = (c(k,il+nres)-c(k,jl+nres))*fac
18613 dxqwol(k,il)=dxqwol(k,il)+ddqij
18614 dxqwol(k,jl)=dxqwol(k,jl)-ddqij
18623 dqwol(j,i)=dqwol(j,i)/nl
18624 dxqwol(j,i)=dxqwol(j,i)/nl
18628 end subroutine qwolynes_prim
18629 !-----------------------------------------------------------------------------
18630 subroutine qwol_num(seg1,seg2,flag,seg3,seg4)
18631 ! implicit real*8 (a-h,o-z)
18632 ! include 'DIMENSIONS'
18633 ! include 'COMMON.IOUNITS'
18634 ! include 'COMMON.CHAIN'
18635 ! include 'COMMON.INTERACT'
18636 ! include 'COMMON.VAR'
18637 integer :: seg1,seg2,seg3,seg4
18639 real(kind=8),dimension(3,0:nres) :: qwolan,qwolxan
18640 real(kind=8),dimension(3,0:2*nres) :: cdummy
18641 real(kind=8) :: q1,q2
18642 real(kind=8) :: delta=1.0d-10
18647 q1=qwolynes(seg1,seg2,flag,seg3,seg4)
18649 c(j,i)=c(j,i)+delta
18650 q2=qwolynes(seg1,seg2,flag,seg3,seg4)
18651 qwolan(j,i)=(q2-q1)/delta
18657 q1=qwolynes(seg1,seg2,flag,seg3,seg4)
18658 cdummy(j,i+nres)=c(j,i+nres)
18659 c(j,i+nres)=c(j,i+nres)+delta
18660 q2=qwolynes(seg1,seg2,flag,seg3,seg4)
18661 qwolxan(j,i)=(q2-q1)/delta
18662 c(j,i+nres)=cdummy(j,i+nres)
18665 ! write(iout,*) "Numerical Q carteisan gradients backbone: "
18667 ! write(iout,'(i5,3e15.5)') i, (qwolan(j,i),j=1,3)
18669 ! write(iout,*) "Numerical Q carteisan gradients side-chain: "
18671 ! write(iout,'(i5,3e15.5)') i, (qwolxan(j,i),j=1,3)
18674 end subroutine qwol_num
18675 !-----------------------------------------------------------------------------
18676 subroutine EconstrQ
18677 ! MD with umbrella_sampling using Wolyne's distance measure as a constraint
18678 ! implicit real*8 (a-h,o-z)
18679 ! include 'DIMENSIONS'
18680 ! include 'COMMON.CONTROL'
18681 ! include 'COMMON.VAR'
18682 ! include 'COMMON.MD'
18685 ! include 'COMMON.LANGEVIN'
18687 ! include 'COMMON.LANGEVIN.lang0'
18689 ! include 'COMMON.CHAIN'
18690 ! include 'COMMON.DERIV'
18691 ! include 'COMMON.GEO'
18692 ! include 'COMMON.LOCAL'
18693 ! include 'COMMON.INTERACT'
18694 ! include 'COMMON.IOUNITS'
18695 ! include 'COMMON.NAMES'
18696 ! include 'COMMON.TIME1'
18697 real(kind=8) :: uzap1,uzap2,hm1,hm2,hmnum,ucdelan
18698 real(kind=8),dimension(3,0:nres) :: dUcartan,dUxcartan,cdummy,&
18700 integer :: kstart,kend,lstart,lend,idummy
18701 real(kind=8) :: delta=1.0d-7
18702 integer :: i,j,k,ii
18706 dudconst(j,i)=0.0d0
18707 duxconst(j,i)=0.0d0
18708 dudxconst(j,i)=0.0d0
18713 qfrag(i)=qwolynes(ifrag(1,i,iset),ifrag(2,i,iset),.true.,&
18715 Uconst=Uconst+wfrag(i,iset)*harmonic(qfrag(i),qinfrag(i,iset))
18716 ! Calculating the derivatives of Constraint energy with respect to Q
18717 Ucdfrag=wfrag(i,iset)*harmonicprim(qfrag(i),&
18719 ! hm1=harmonic(qfrag(i,iset),qinfrag(i,iset))
18720 ! hm2=harmonic(qfrag(i,iset)+delta,qinfrag(i,iset))
18721 ! hmnum=(hm2-hm1)/delta
18722 ! write(iout,*) "harmonicprim frag",harmonicprim(qfrag(i,iset),
18723 ! & qinfrag(i,iset))
18724 ! write(iout,*) "harmonicnum frag", hmnum
18725 ! Calculating the derivatives of Q with respect to cartesian coordinates
18726 call qwolynes_prim(ifrag(1,i,iset),ifrag(2,i,iset),.true.,&
18728 ! write(iout,*) "dqwol "
18730 ! write(iout,'(i5,3e15.5)') ii,(dqwol(j,ii),j=1,3)
18732 ! write(iout,*) "dxqwol "
18734 ! write(iout,'(i5,3e15.5)') ii,(dxqwol(j,ii),j=1,3)
18736 ! Calculating numerical gradients of dU/dQi and dQi/dxi
18737 ! call qwol_num(ifrag(1,i,iset),ifrag(2,i,iset),.true.
18738 ! & ,idummy,idummy)
18739 ! The gradients of Uconst in Cs
18742 duconst(j,ii)=dUconst(j,ii)+ucdfrag*dqwol(j,ii)
18743 dUxconst(j,ii)=dUxconst(j,ii)+ucdfrag*dxqwol(j,ii)
18748 kstart=ifrag(1,ipair(1,i,iset),iset)
18749 kend=ifrag(2,ipair(1,i,iset),iset)
18750 lstart=ifrag(1,ipair(2,i,iset),iset)
18751 lend=ifrag(2,ipair(2,i,iset),iset)
18752 qpair(i)=qwolynes(kstart,kend,.false.,lstart,lend)
18753 Uconst=Uconst+wpair(i,iset)*harmonic(qpair(i),qinpair(i,iset))
18754 ! Calculating dU/dQ
18755 Ucdpair=wpair(i,iset)*harmonicprim(qpair(i),qinpair(i,iset))
18756 ! hm1=harmonic(qpair(i),qinpair(i,iset))
18757 ! hm2=harmonic(qpair(i)+delta,qinpair(i,iset))
18758 ! hmnum=(hm2-hm1)/delta
18759 ! write(iout,*) "harmonicprim pair ",harmonicprim(qpair(i),
18760 ! & qinpair(i,iset))
18761 ! write(iout,*) "harmonicnum pair ", hmnum
18762 ! Calculating dQ/dXi
18763 call qwolynes_prim(kstart,kend,.false.,&
18765 ! write(iout,*) "dqwol "
18767 ! write(iout,'(i5,3e15.5)') ii,(dqwol(j,ii),j=1,3)
18769 ! write(iout,*) "dxqwol "
18771 ! write(iout,'(i5,3e15.5)') ii,(dxqwol(j,ii),j=1,3)
18773 ! Calculating numerical gradients
18774 ! call qwol_num(kstart,kend,.false.
18776 ! The gradients of Uconst in Cs
18779 duconst(j,ii)=dUconst(j,ii)+ucdpair*dqwol(j,ii)
18780 dUxconst(j,ii)=dUxconst(j,ii)+ucdpair*dxqwol(j,ii)
18784 ! write(iout,*) "Uconst inside subroutine ", Uconst
18785 ! Transforming the gradients from Cs to dCs for the backbone
18789 dudconst(k,i)=dudconst(k,i)+duconst(k,j)+duxconst(k,j)
18793 ! Transforming the gradients from Cs to dCs for the side chains
18796 dudxconst(j,i)=duxconst(j,i)
18799 ! write(iout,*) "dU/ddc backbone "
18801 ! write(iout,'(i5,3e15.5)') ii, (dudconst(j,ii),j=1,3)
18803 ! write(iout,*) "dU/ddX side chain "
18805 ! write(iout,'(i5,3e15.5)') ii,(duxconst(j,ii),j=1,3)
18807 ! Calculating numerical gradients of dUconst/ddc and dUconst/ddx
18808 ! call dEconstrQ_num
18810 end subroutine EconstrQ
18811 !-----------------------------------------------------------------------------
18812 subroutine dEconstrQ_num
18813 ! Calculating numerical dUconst/ddc and dUconst/ddx
18814 ! implicit real*8 (a-h,o-z)
18815 ! include 'DIMENSIONS'
18816 ! include 'COMMON.CONTROL'
18817 ! include 'COMMON.VAR'
18818 ! include 'COMMON.MD'
18821 ! include 'COMMON.LANGEVIN'
18823 ! include 'COMMON.LANGEVIN.lang0'
18825 ! include 'COMMON.CHAIN'
18826 ! include 'COMMON.DERIV'
18827 ! include 'COMMON.GEO'
18828 ! include 'COMMON.LOCAL'
18829 ! include 'COMMON.INTERACT'
18830 ! include 'COMMON.IOUNITS'
18831 ! include 'COMMON.NAMES'
18832 ! include 'COMMON.TIME1'
18833 real(kind=8) :: uzap1,uzap2
18834 real(kind=8),dimension(3,0:nres) :: dUcartan,dUxcartan,cdummy
18835 integer :: kstart,kend,lstart,lend,idummy
18836 real(kind=8) :: delta=1.0d-7
18837 !el local variables
18843 dUcartan(j,i)=0.0d0
18844 cdummy(j,i)=dc(j,i)
18845 dc(j,i)=dc(j,i)+delta
18846 call chainbuild_cart
18849 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),.true.,&
18851 uzap2=uzap2+wfrag(ii,iset)*harmonic(qfrag(ii),&
18855 kstart=ifrag(1,ipair(1,ii,iset),iset)
18856 kend=ifrag(2,ipair(1,ii,iset),iset)
18857 lstart=ifrag(1,ipair(2,ii,iset),iset)
18858 lend=ifrag(2,ipair(2,ii,iset),iset)
18859 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
18860 uzap2=uzap2+wpair(ii,iset)*harmonic(qpair(ii),&
18863 dc(j,i)=cdummy(j,i)
18864 call chainbuild_cart
18867 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),.true.,&
18869 uzap1=uzap1+wfrag(ii,iset)*harmonic(qfrag(ii),&
18873 kstart=ifrag(1,ipair(1,ii,iset),iset)
18874 kend=ifrag(2,ipair(1,ii,iset),iset)
18875 lstart=ifrag(1,ipair(2,ii,iset),iset)
18876 lend=ifrag(2,ipair(2,ii,iset),iset)
18877 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
18878 uzap1=uzap1+wpair(ii,iset)*harmonic(qpair(ii),&
18881 ducartan(j,i)=(uzap2-uzap1)/(delta)
18884 ! Calculating numerical gradients for dU/ddx
18886 duxcartan(j,i)=0.0d0
18888 cdummy(j,i)=dc(j,i+nres)
18889 dc(j,i+nres)=dc(j,i+nres)+delta
18890 call chainbuild_cart
18893 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),.true.,&
18895 uzap2=uzap2+wfrag(ii,iset)*harmonic(qfrag(ii),&
18899 kstart=ifrag(1,ipair(1,ii,iset),iset)
18900 kend=ifrag(2,ipair(1,ii,iset),iset)
18901 lstart=ifrag(1,ipair(2,ii,iset),iset)
18902 lend=ifrag(2,ipair(2,ii,iset),iset)
18903 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
18904 uzap2=uzap2+wpair(ii,iset)*harmonic(qpair(ii),&
18907 dc(j,i+nres)=cdummy(j,i)
18908 call chainbuild_cart
18911 qfrag(ii)=qwolynes(ifrag(1,ii,iset),&
18912 ifrag(2,ii,iset),.true.,idummy,idummy)
18913 uzap1=uzap1+wfrag(ii,iset)*harmonic(qfrag(ii),&
18917 kstart=ifrag(1,ipair(1,ii,iset),iset)
18918 kend=ifrag(2,ipair(1,ii,iset),iset)
18919 lstart=ifrag(1,ipair(2,ii,iset),iset)
18920 lend=ifrag(2,ipair(2,ii,iset),iset)
18921 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
18922 uzap1=uzap1+wpair(ii,iset)*harmonic(qpair(ii),&
18925 duxcartan(j,i)=(uzap2-uzap1)/(delta)
18928 write(iout,*) "Numerical dUconst/ddc backbone "
18930 write(iout,'(i5,3e15.5)') ii,(dUcartan(j,ii),j=1,3)
18932 ! write(iout,*) "Numerical dUconst/ddx side-chain "
18934 ! write(iout,'(i5,3e15.5)') ii,(dUxcartan(j,ii),j=1,3)
18937 end subroutine dEconstrQ_num
18938 !-----------------------------------------------------------------------------
18940 !-----------------------------------------------------------------------------
18941 subroutine check_energies
18943 ! use random, only: ran_number
18947 ! include 'DIMENSIONS'
18948 ! include 'COMMON.CHAIN'
18949 ! include 'COMMON.VAR'
18950 ! include 'COMMON.IOUNITS'
18951 ! include 'COMMON.SBRIDGE'
18952 ! include 'COMMON.LOCAL'
18953 ! include 'COMMON.GEO'
18955 ! External functions
18956 !EL double precision ran_number
18957 !EL external ran_number
18960 integer :: i,j,k,l,lmax,p,pmax
18961 real(kind=8) :: rmin,rmax
18962 real(kind=8) :: eij
18965 real(kind=8) :: wi,rij,tj,pj
18987 !t wi=ran_number(0.0D0,pi)
18988 ! wi=ran_number(0.0D0,pi/6.0D0)
18990 !t tj=ran_number(0.0D0,pi)
18991 !t pj=ran_number(0.0D0,pi)
18992 ! pj=ran_number(0.0D0,pi/6.0D0)
18996 !t rij=ran_number(rmin,rmax)
18998 c(1,j)=d*sin(pj)*cos(tj)
18999 c(2,j)=d*sin(pj)*sin(tj)
19005 c(3,i)=-rij-d*cos(wi)
19008 dc(k,nres+i)=c(k,nres+i)-c(k,i)
19009 dc_norm(k,nres+i)=dc(k,nres+i)/d
19010 dc(k,nres+j)=c(k,nres+j)-c(k,j)
19011 dc_norm(k,nres+j)=dc(k,nres+j)/d
19014 call dyn_ssbond_ene(i,j,eij)
19019 end subroutine check_energies
19020 !-----------------------------------------------------------------------------
19021 subroutine dyn_ssbond_ene(resi,resj,eij)
19026 ! include 'DIMENSIONS'
19027 ! include 'COMMON.SBRIDGE'
19028 ! include 'COMMON.CHAIN'
19029 ! include 'COMMON.DERIV'
19030 ! include 'COMMON.LOCAL'
19031 ! include 'COMMON.INTERACT'
19032 ! include 'COMMON.VAR'
19033 ! include 'COMMON.IOUNITS'
19034 ! include 'COMMON.CALC'
19038 ! include 'COMMON.MD'
19039 ! use MD, only: totT,t_bath
19042 ! External functions
19043 !EL double precision h_base
19044 !EL external h_base
19047 integer :: resi,resj
19050 real(kind=8) :: eij
19053 logical :: havebond
19054 integer itypi,itypj
19055 real(kind=8) :: rrij,ssd,deltat1,deltat2,deltat12,cosphi
19056 real(kind=8) :: sig0ij,ljd,sig,fac,e1,e2
19057 real(kind=8),dimension(3) :: dcosom1,dcosom2
19059 real(kind=8) :: pom1,pom2
19060 real(kind=8) :: ljA,ljB,ljXs
19061 real(kind=8),dimension(1:3) :: d_ljB
19062 real(kind=8) :: ssA,ssB,ssC,ssXs
19063 real(kind=8) :: ssxm,ljxm,ssm,ljm
19064 real(kind=8),dimension(1:3) :: d_ssxm,d_ljxm,d_ssm,d_ljm
19065 real(kind=8) :: f1,f2,h1,h2,hd1,hd2
19066 real(kind=8) :: omega,delta_inv,deltasq_inv,fac1,fac2
19067 !-------FIRST METHOD
19069 real(kind=8),dimension(1:3) :: d_xm
19070 !-------END FIRST METHOD
19071 !-------SECOND METHOD
19072 !$$$ double precision ss,d_ss(0:3),ljf,d_ljf(0:3)
19073 !-------END SECOND METHOD
19075 !-------TESTING CODE
19076 !el logical :: checkstop,transgrad
19077 !el common /sschecks/ checkstop,transgrad
19079 integer :: icheck,nicheck,jcheck,njcheck
19080 real(kind=8),dimension(-1:1) :: echeck
19081 real(kind=8) :: deps,ssx0,ljx0
19082 !-------END TESTING CODE
19088 !el allocate(dyn_ssbond_ij(iatsc_s:iatsc_e,nres))
19089 !el allocate(dyn_ssbond_ij(0:nres+4,nres))
19092 dxi=dc_norm(1,nres+i)
19093 dyi=dc_norm(2,nres+i)
19094 dzi=dc_norm(3,nres+i)
19095 dsci_inv=vbld_inv(i+nres)
19098 xj=c(1,nres+j)-c(1,nres+i)
19099 yj=c(2,nres+j)-c(2,nres+i)
19100 zj=c(3,nres+j)-c(3,nres+i)
19101 dxj=dc_norm(1,nres+j)
19102 dyj=dc_norm(2,nres+j)
19103 dzj=dc_norm(3,nres+j)
19104 dscj_inv=vbld_inv(j+nres)
19106 chi1=chi(itypi,itypj)
19107 chi2=chi(itypj,itypi)
19114 alf12=0.5D0*(alf1+alf2)
19116 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
19117 rij=dsqrt(rrij) ! sc_angular needs rij to really be the inverse
19118 ! The following are set in sc_angular
19122 ! om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
19123 ! om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
19124 ! om12=dxi*dxj+dyi*dyj+dzi*dzj
19126 rij=1.0D0/rij ! Reset this so it makes sense
19128 sig0ij=sigma(itypi,itypj)
19129 sig=sig0ij*dsqrt(1.0D0/sigsq)
19132 ljA=eps1*eps2rt**2*eps3rt**2
19133 ljB=ljA*bb_aq(itypi,itypj)
19134 ljA=ljA*aa_aq(itypi,itypj)
19135 ljxm=ljXs+(-2.0D0*aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
19140 deltat12=om2-om1+2.0d0
19141 cosphi=om12-om1*om2
19145 +akth*(deltat1*deltat1+deltat2*deltat2) &
19146 +v1ss*cosphi+v2ss*cosphi*cosphi+v3ss*cosphi*cosphi*cosphi
19147 ssxm=ssXs-0.5D0*ssB/ssA
19149 !-------TESTING CODE
19150 !$$$c Some extra output
19151 !$$$ ssm=ssC-0.25D0*ssB*ssB/ssA
19152 !$$$ ljm=-0.25D0*ljB*bb(itypi,itypj)/aa(itypi,itypj)
19153 !$$$ ssx0=ssB*ssB-4.0d0*ssA*ssC
19154 !$$$ if (ssx0.gt.0.0d0) then
19155 !$$$ ssx0=ssXs+0.5d0*(-ssB+sqrt(ssx0))/ssA
19159 !$$$ ljx0=ljXs+(-aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
19160 !$$$ write(iout,'(a,4f8.2,2f15.2,3f6.2)')"SSENERGIES ",
19161 !$$$ & ssxm,ljxm,ssx0,ljx0,ssm,ljm,om1,om2,om12
19163 !-------END TESTING CODE
19165 !-------TESTING CODE
19166 ! Stop and plot energy and derivative as a function of distance
19167 if (checkstop) then
19168 ssm=ssC-0.25D0*ssB*ssB/ssA
19169 ljm=-0.25D0*ljB*bb_aq(itypi,itypj)/aa_aq(itypi,itypj)
19170 if (ssm.lt.ljm .and. &
19171 dabs(rij-0.5d0*(ssxm+ljxm)).lt.0.35d0*(ljxm-ssxm)) then
19179 if (.not.checkstop) then
19184 do icheck=0,nicheck
19185 do jcheck=-1,njcheck
19186 if (checkstop) rij=(ssxm-1.0d0)+ &
19187 ((ljxm-ssxm+2.0d0)*icheck)/nicheck+jcheck*deps
19188 !-------END TESTING CODE
19190 if (rij.gt.ljxm) then
19193 fac=(1.0D0/ljd)**expon
19194 e1=fac*fac*aa_aq(itypi,itypj)
19195 e2=fac*bb_aq(itypi,itypj)
19196 eij=eps1*eps2rt*eps3rt*(e1+e2)
19199 eij=eij*eps2rt*eps3rt
19202 e1=e1*eps1*eps2rt**2*eps3rt**2
19203 ed=-expon*(e1+eij)/ljd
19205 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
19206 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
19207 eom12=eij*eps1_om12+eps2der*eps2rt_om12 &
19208 -2.0D0*alf12*eps3der+sigder*sigsq_om12
19209 else if (rij.lt.ssxm) then
19212 eij=ssA*ssd*ssd+ssB*ssd+ssC
19214 ed=2*akcm*ssd+akct*deltat12
19216 pom2=v1ss+2*v2ss*cosphi+3*v3ss*cosphi*cosphi
19217 eom1=-2*akth*deltat1-pom1-om2*pom2
19218 eom2= 2*akth*deltat2+pom1-om1*pom2
19221 omega=v1ss+2.0d0*v2ss*cosphi+3.0d0*v3ss*cosphi*cosphi
19223 d_ssxm(1)=0.5D0*akct/ssA
19224 d_ssxm(2)=-d_ssxm(1)
19227 d_ljxm(1)=sig0ij/sqrt(sigsq**3)
19228 d_ljxm(2)=d_ljxm(1)*sigsq_om2
19229 d_ljxm(3)=d_ljxm(1)*sigsq_om12
19230 d_ljxm(1)=d_ljxm(1)*sigsq_om1
19232 !-------FIRST METHOD, DISCONTINUOUS SECOND DERIVATIVE
19233 xm=0.5d0*(ssxm+ljxm)
19235 d_xm(k)=0.5d0*(d_ssxm(k)+d_ljxm(k))
19237 if (rij.lt.xm) then
19239 ssm=ssC-0.25D0*ssB*ssB/ssA
19240 d_ssm(1)=0.5D0*akct*ssB/ssA
19241 d_ssm(2)=2.0D0*akth*deltat2-om1*omega-d_ssm(1)
19242 d_ssm(1)=-2.0D0*akth*deltat1-om2*omega+d_ssm(1)
19244 f1=(rij-xm)/(ssxm-xm)
19245 f2=(rij-ssxm)/(xm-ssxm)
19249 delta_inv=1.0d0/(xm-ssxm)
19250 deltasq_inv=delta_inv*delta_inv
19252 fac1=deltasq_inv*fac*(xm-rij)
19253 fac2=deltasq_inv*fac*(rij-ssxm)
19254 ed=delta_inv*(Ht*hd2-ssm*hd1)
19255 eom1=fac1*d_ssxm(1)+fac2*d_xm(1)+h1*d_ssm(1)
19256 eom2=fac1*d_ssxm(2)+fac2*d_xm(2)+h1*d_ssm(2)
19257 eom12=fac1*d_ssxm(3)+fac2*d_xm(3)+h1*d_ssm(3)
19260 ljm=-0.25D0*ljB*bb_aq(itypi,itypj)/aa_aq(itypi,itypj)
19261 d_ljm(1)=-0.5D0*bb_aq(itypi,itypj)/aa_aq(itypi,itypj)*ljB
19262 d_ljm(2)=d_ljm(1)*(0.5D0*eps2rt_om2/eps2rt+alf2/eps3rt)
19263 d_ljm(3)=d_ljm(1)*(0.5D0*eps1_om12+0.5D0*eps2rt_om12/eps2rt- &
19265 d_ljm(1)=d_ljm(1)*(0.5D0*eps2rt_om1/eps2rt-alf1/eps3rt)
19266 f1=(rij-ljxm)/(xm-ljxm)
19267 f2=(rij-xm)/(ljxm-xm)
19271 delta_inv=1.0d0/(ljxm-xm)
19272 deltasq_inv=delta_inv*delta_inv
19274 fac1=deltasq_inv*fac*(ljxm-rij)
19275 fac2=deltasq_inv*fac*(rij-xm)
19276 ed=delta_inv*(ljm*hd2-Ht*hd1)
19277 eom1=fac1*d_xm(1)+fac2*d_ljxm(1)+h2*d_ljm(1)
19278 eom2=fac1*d_xm(2)+fac2*d_ljxm(2)+h2*d_ljm(2)
19279 eom12=fac1*d_xm(3)+fac2*d_ljxm(3)+h2*d_ljm(3)
19281 !-------END FIRST METHOD, DISCONTINUOUS SECOND DERIVATIVE
19283 !-------SECOND METHOD, CONTINUOUS SECOND DERIVATIVE
19289 !$$$ d_ljB(1)=ljB*(eps2rt_om1/eps2rt-2.0d0*alf1/eps3rt)
19290 !$$$ d_ljB(2)=ljB*(eps2rt_om2/eps2rt+2.0d0*alf2/eps3rt)
19291 !$$$ d_ljB(3)=ljB*(eps1_om12+eps2rt_om12/eps2rt-2.0d0*alf12/eps3rt)
19293 !$$$ ssm=ssC-0.25D0*ssB*ssB/ssA
19294 !$$$ d_ssm(1)=0.5D0*akct*ssB/ssA
19295 !$$$ d_ssm(2)=2.0D0*akth*deltat2-om1*omega-d_ssm(1)
19296 !$$$ d_ssm(1)=-2.0D0*akth*deltat1-om2*omega+d_ssm(1)
19297 !$$$ d_ssm(3)=omega
19299 !$$$ ljm=-0.25D0*bb(itypi,itypj)/aa(itypi,itypj)
19301 !$$$ d_ljm(k)=ljm*d_ljB(k)
19305 !$$$ ss=ssA*ssd*ssd+ssB*ssd+ssC
19306 !$$$ d_ss(0)=2.0d0*ssA*ssd+ssB
19307 !$$$ d_ss(2)=akct*ssd
19308 !$$$ d_ss(1)=-d_ss(2)-2.0d0*akth*deltat1-om2*omega
19309 !$$$ d_ss(2)=d_ss(2)+2.0d0*akth*deltat2-om1*omega
19312 !$$$ ljf=bb(itypi,itypj)/aa(itypi,itypj)
19313 !$$$ ljf=9.0d0*ljf*(-0.5d0*ljf)**(1.0d0/3.0d0)
19314 !$$$ d_ljf(0)=ljf*2.0d0*ljB*fac1
19316 !$$$ d_ljf(k)=d_ljm(k)+ljf*(d_ljB(k)*fac1*fac1-
19317 !$$$ & 2.0d0*ljB*fac1*d_ljxm(k))
19319 !$$$ ljf=ljm+ljf*ljB*fac1*fac1
19321 !$$$ f1=(rij-ljxm)/(ssxm-ljxm)
19322 !$$$ f2=(rij-ssxm)/(ljxm-ssxm)
19323 !$$$ h1=h_base(f1,hd1)
19324 !$$$ h2=h_base(f2,hd2)
19325 !$$$ eij=ss*h1+ljf*h2
19326 !$$$ delta_inv=1.0d0/(ljxm-ssxm)
19327 !$$$ deltasq_inv=delta_inv*delta_inv
19328 !$$$ fac=ljf*hd2-ss*hd1
19329 !$$$ ed=d_ss(0)*h1+d_ljf(0)*h2+delta_inv*fac
19330 !$$$ eom1=d_ss(1)*h1+d_ljf(1)*h2+deltasq_inv*fac*
19331 !$$$ & (fac1*d_ssxm(1)-fac2*(d_ljxm(1)))
19332 !$$$ eom2=d_ss(2)*h1+d_ljf(2)*h2+deltasq_inv*fac*
19333 !$$$ & (fac1*d_ssxm(2)-fac2*(d_ljxm(2)))
19334 !$$$ eom12=d_ss(3)*h1+d_ljf(3)*h2+deltasq_inv*fac*
19335 !$$$ & (fac1*d_ssxm(3)-fac2*(d_ljxm(3)))
19337 !$$$ havebond=.false.
19338 !$$$ if (ed.gt.0.0d0) havebond=.true.
19339 !-------END SECOND METHOD, CONTINUOUS SECOND DERIVATIVE
19346 ! if (dyn_ssbond_ij(i,j).eq.1.0d300) then
19347 ! write(iout,'(a15,f12.2,f8.1,2i5)')
19348 ! & "SSBOND_E_FORM",totT,t_bath,i,j
19352 dyn_ssbond_ij(i,j)=eij
19353 else if (.not.havebond .and. dyn_ssbond_ij(i,j).lt.1.0d300) then
19354 dyn_ssbond_ij(i,j)=1.0d300
19357 ! write(iout,'(a15,f12.2,f8.1,2i5)')
19358 ! & "SSBOND_E_BREAK",totT,t_bath,i,j
19363 !-------TESTING CODE
19364 !el if (checkstop) then
19365 if (jcheck.eq.0) write(iout,'(a,3f15.8,$)') &
19366 "CHECKSTOP",rij,eij,ed
19370 if (checkstop) then
19371 write(iout,'(f15.8)')(echeck(1)-echeck(-1))*0.5d0/deps
19374 if (checkstop) then
19378 !-------END TESTING CODE
19381 dcosom1(k)=(dc_norm(k,nres+i)-om1*erij(k))/rij
19382 dcosom2(k)=(dc_norm(k,nres+j)-om2*erij(k))/rij
19385 gg(k)=ed*erij(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
19388 gvdwx(k,i)=gvdwx(k,i)-gg(k) &
19389 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
19390 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
19391 gvdwx(k,j)=gvdwx(k,j)+gg(k) &
19392 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
19393 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
19397 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
19402 gvdwc(l,i)=gvdwc(l,i)-gg(l)
19403 gvdwc(l,j)=gvdwc(l,j)+gg(l)
19407 end subroutine dyn_ssbond_ene
19408 !--------------------------------------------------------------------------
19409 subroutine triple_ssbond_ene(resi,resj,resk,eij)
19414 ! include 'DIMENSIONS'
19415 ! include 'COMMON.SBRIDGE'
19416 ! include 'COMMON.CHAIN'
19417 ! include 'COMMON.DERIV'
19418 ! include 'COMMON.LOCAL'
19419 ! include 'COMMON.INTERACT'
19420 ! include 'COMMON.VAR'
19421 ! include 'COMMON.IOUNITS'
19422 ! include 'COMMON.CALC'
19426 ! include 'COMMON.MD'
19427 ! use MD, only: totT,t_bath
19430 double precision h_base
19434 integer resi,resj,resk,m,itypi,itypj,itypk
19436 !c Output arguments
19437 double precision eij,eij1,eij2,eij3
19441 !c integer itypi,itypj,k,l
19442 double precision rrij,ssd,deltat1,deltat2,deltat12,cosphi
19443 double precision rrik,rrjk,rik,rjk,xi,xk,yi,yk,zi,zk,xij,yij,zij
19444 double precision xik,yik,zik,xjk,yjk,zjk,dxk,dyk,dzk
19445 double precision sig0ij,ljd,sig,fac,e1,e2
19446 double precision dcosom1(3),dcosom2(3),ed
19447 double precision pom1,pom2
19448 double precision ljA,ljB,ljXs
19449 double precision d_ljB(1:3)
19450 double precision ssA,ssB,ssC,ssXs
19451 double precision ssxm,ljxm,ssm,ljm
19452 double precision d_ssxm(1:3),d_ljxm(1:3),d_ssm(1:3),d_ljm(1:3)
19454 if (dtriss.eq.0) return
19458 !C write(iout,*) resi,resj,resk
19460 dxi=dc_norm(1,nres+i)
19461 dyi=dc_norm(2,nres+i)
19462 dzi=dc_norm(3,nres+i)
19463 dsci_inv=vbld_inv(i+nres)
19467 call to_box(xi,yi,zi)
19472 call to_box(xj,yj,zj)
19473 dxj=dc_norm(1,nres+j)
19474 dyj=dc_norm(2,nres+j)
19475 dzj=dc_norm(3,nres+j)
19476 dscj_inv=vbld_inv(j+nres)
19481 call to_box(xk,yk,zk)
19482 dxk=dc_norm(1,nres+k)
19483 dyk=dc_norm(2,nres+k)
19484 dzk=dc_norm(3,nres+k)
19485 dscj_inv=vbld_inv(k+nres)
19495 rrij=(xij*xij+yij*yij+zij*zij)
19496 rij=dsqrt(rrij) ! sc_angular needs rij to really be the inverse
19497 rrik=(xik*xik+yik*yik+zik*zik)
19499 rrjk=(xjk*xjk+yjk*yjk+zjk*zjk)
19501 !C there are three combination of distances for each trisulfide bonds
19502 !C The first case the ith atom is the center
19503 !C Energy function is E=d/(a*(x-y)**2+b*(x+y)**2+c) where x is first
19504 !C distance y is second distance the a,b,c,d are parameters derived for
19505 !C this problem d parameter was set as a penalty currenlty set to 1.
19506 if ((iabs(j-i).le.2).or.(iabs(i-k).le.2)) then
19509 eij1=dtriss/(atriss*(rij-rik)**2+btriss*(rij+rik)**6+ctriss)
19511 !C second case jth atom is center
19512 if ((iabs(j-i).le.2).or.(iabs(j-k).le.2)) then
19515 eij2=dtriss/(atriss*(rij-rjk)**2+btriss*(rij+rjk)**6+ctriss)
19517 !C the third case kth atom is the center
19518 if ((iabs(i-k).le.2).or.(iabs(j-k).le.2)) then
19521 eij3=dtriss/(atriss*(rik-rjk)**2+btriss*(rik+rjk)**6+ctriss)
19527 !C write(iout,*)i,j,k,eij
19528 !C The energy penalty calculated now time for the gradient part
19529 !C derivative over rij
19530 fac=-eij1**2/dtriss*(2.0*atriss*(rij-rik)+6.0*btriss*(rij+rik)**5) &
19531 -eij2**2/dtriss*(2.0*atriss*(rij-rjk)+6.0*btriss*(rij+rjk)**5)
19536 gvdwx(m,i)=gvdwx(m,i)-gg(m)
19537 gvdwx(m,j)=gvdwx(m,j)+gg(m)
19541 gvdwc(l,i)=gvdwc(l,i)-gg(l)
19542 gvdwc(l,j)=gvdwc(l,j)+gg(l)
19544 !C now derivative over rik
19545 fac=-eij1**2/dtriss* &
19546 (-2.0*atriss*(rij-rik)+6.0*btriss*(rij+rik)**5) &
19547 -eij3**2/dtriss*(2.0*atriss*(rik-rjk)+6.0*btriss*(rik+rjk)**5)
19552 gvdwx(m,i)=gvdwx(m,i)-gg(m)
19553 gvdwx(m,k)=gvdwx(m,k)+gg(m)
19556 gvdwc(l,i)=gvdwc(l,i)-gg(l)
19557 gvdwc(l,k)=gvdwc(l,k)+gg(l)
19559 !C now derivative over rjk
19560 fac=-eij2**2/dtriss* &
19561 (-2.0*atriss*(rij-rjk)+6.0*btriss*(rij+rjk)**5)- &
19562 eij3**2/dtriss*(-2.0*atriss*(rik-rjk)+6.0*btriss*(rik+rjk)**5)
19567 gvdwx(m,j)=gvdwx(m,j)-gg(m)
19568 gvdwx(m,k)=gvdwx(m,k)+gg(m)
19571 gvdwc(l,j)=gvdwc(l,j)-gg(l)
19572 gvdwc(l,k)=gvdwc(l,k)+gg(l)
19575 end subroutine triple_ssbond_ene
19579 !-----------------------------------------------------------------------------
19580 real(kind=8) function h_base(x,deriv)
19581 ! A smooth function going 0->1 in range [0,1]
19582 ! It should NOT be called outside range [0,1], it will not work there.
19589 real(kind=8) :: deriv
19592 real(kind=8) :: xsq
19595 ! Two parabolas put together. First derivative zero at extrema
19596 !$$$ if (x.lt.0.5D0) then
19597 !$$$ h_base=2.0D0*x*x
19601 !$$$ h_base=1.0D0-2.0D0*deriv*deriv
19602 !$$$ deriv=4.0D0*deriv
19605 ! Third degree polynomial. First derivative zero at extrema
19606 h_base=x*x*(3.0d0-2.0d0*x)
19607 deriv=6.0d0*x*(1.0d0-x)
19609 ! Fifth degree polynomial. First and second derivatives zero at extrema
19611 !$$$ h_base=x*xsq*(6.0d0*xsq-15.0d0*x+10.0d0)
19613 !$$$ deriv=deriv*deriv
19614 !$$$ deriv=30.0d0*xsq*deriv
19617 end function h_base
19618 !-----------------------------------------------------------------------------
19619 subroutine dyn_set_nss
19620 ! Adjust nss and other relevant variables based on dyn_ssbond_ij
19622 use MD_data, only: totT,t_bath
19624 ! include 'DIMENSIONS'
19628 ! include 'COMMON.SBRIDGE'
19629 ! include 'COMMON.CHAIN'
19630 ! include 'COMMON.IOUNITS'
19631 ! include 'COMMON.SETUP'
19632 ! include 'COMMON.MD'
19634 real(kind=8) :: emin
19635 integer :: i,j,imin,ierr
19636 integer :: diff,allnss,newnss
19637 integer,dimension(maxdim) :: allflag,allihpb,alljhpb,& !(maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
19640 integer,dimension(0:nfgtasks) :: i_newnss
19641 integer,dimension(0:nfgtasks) :: displ
19642 integer,dimension(maxdim) :: g_newihpb,g_newjhpb !(maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
19643 integer :: g_newnss
19648 if (dyn_ssbond_ij(i,j).lt.1.0d300) then
19657 !mc write(iout,*)"ALLNSS ",allnss,(allihpb(i),alljhpb(i),i=1,allnss)
19661 if (allflag(i).eq.0 .and. &
19662 dyn_ssbond_ij(allihpb(i),alljhpb(i)).lt.emin) then
19663 emin=dyn_ssbond_ij(allihpb(i),alljhpb(i))
19667 if (emin.lt.1.0d300) then
19670 if (allflag(i).eq.0 .and. &
19671 (allihpb(i).eq.allihpb(imin) .or. &
19672 alljhpb(i).eq.allihpb(imin) .or. &
19673 allihpb(i).eq.alljhpb(imin) .or. &
19674 alljhpb(i).eq.alljhpb(imin))) then
19681 !mc write(iout,*)"ALLNSS ",allnss,(allihpb(i),alljhpb(i),i=1,allnss)
19685 if (allflag(i).eq.1) then
19687 newihpb(newnss)=allihpb(i)
19688 newjhpb(newnss)=alljhpb(i)
19693 if (nfgtasks.gt.1)then
19695 call MPI_Reduce(newnss,g_newnss,1,&
19696 MPI_INTEGER,MPI_SUM,king,FG_COMM,IERR)
19697 call MPI_Gather(newnss,1,MPI_INTEGER,&
19698 i_newnss,1,MPI_INTEGER,king,FG_COMM,IERR)
19700 do i=1,nfgtasks-1,1
19701 displ(i)=i_newnss(i-1)+displ(i-1)
19703 call MPI_Gatherv(newihpb,newnss,MPI_INTEGER,&
19704 g_newihpb,i_newnss,displ,MPI_INTEGER,&
19706 call MPI_Gatherv(newjhpb,newnss,MPI_INTEGER,&
19707 g_newjhpb,i_newnss,displ,MPI_INTEGER,&
19709 if(fg_rank.eq.0) then
19710 ! print *,'g_newnss',g_newnss
19711 ! print *,'g_newihpb',(g_newihpb(i),i=1,g_newnss)
19712 ! print *,'g_newjhpb',(g_newjhpb(i),i=1,g_newnss)
19715 newihpb(i)=g_newihpb(i)
19716 newjhpb(i)=g_newjhpb(i)
19724 !mc write(iout,*)"NEWNSS ",newnss,(newihpb(i),newjhpb(i),i=1,newnss)
19725 ! print *,newnss,nss,maxdim
19731 if (idssb(i).eq.newihpb(j) .and. &
19732 jdssb(i).eq.newjhpb(j)) found=.true.
19736 ! write(iout,*) "found",found,i,j
19737 if (.not.found.and.fg_rank.eq.0) &
19738 write(iout,'(a15,f12.2,f8.1,2i5)') &
19739 "SSBOND_BREAK",totT,t_bath,idssb(i),jdssb(i)
19748 if (newihpb(i).eq.idssb(j) .and. &
19749 newjhpb(i).eq.jdssb(j)) found=.true.
19753 ! write(iout,*) "found",found,i,j
19754 if (.not.found.and.fg_rank.eq.0) &
19755 write(iout,'(a15,f12.2,f8.1,2i5)') &
19756 "SSBOND_FORM",totT,t_bath,newihpb(i),newjhpb(i)
19763 idssb(i)=newihpb(i)
19764 jdssb(i)=newjhpb(i)
19768 end subroutine dyn_set_nss
19769 ! Lipid transfer energy function
19770 subroutine Eliptransfer(eliptran)
19771 !C this is done by Adasko
19772 !C print *,"wchodze"
19773 !C structure of box:
19775 !C--bordliptop-- buffore starts
19776 !C--bufliptop--- here true lipid starts
19778 !C--buflipbot--- lipid ends buffore starts
19779 !C--bordlipbot--buffore ends
19780 real(kind=8) :: fracinbuf,eliptran,sslip,positi,ssgradlip
19783 ! print *, "I am in eliptran"
19784 do i=ilip_start,ilip_end
19786 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1).or.(i.eq.nres))&
19789 positi=(mod(((c(3,i)+c(3,i+1))/2.0d0),boxzsize))
19790 if (positi.le.0.0) positi=positi+boxzsize
19792 !C first for peptide groups
19793 !c for each residue check if it is in lipid or lipid water border area
19794 if ((positi.gt.bordlipbot) &
19795 .and.(positi.lt.bordliptop)) then
19796 !C the energy transfer exist
19797 if (positi.lt.buflipbot) then
19798 !C what fraction I am in
19800 ((positi-bordlipbot)/lipbufthick)
19801 !C lipbufthick is thickenes of lipid buffore
19802 sslip=sscalelip(fracinbuf)
19803 ssgradlip=-sscagradlip(fracinbuf)/lipbufthick
19804 eliptran=eliptran+sslip*pepliptran
19805 gliptranc(3,i)=gliptranc(3,i)+ssgradlip*pepliptran/2.0d0
19806 gliptranc(3,i-1)=gliptranc(3,i-1)+ssgradlip*pepliptran/2.0d0
19807 !C gliptranc(3,i-2)=gliptranc(3,i)+ssgradlip*pepliptran
19809 !C print *,"doing sccale for lower part"
19810 !C print *,i,sslip,fracinbuf,ssgradlip
19811 elseif (positi.gt.bufliptop) then
19812 fracinbuf=1.0d0-((bordliptop-positi)/lipbufthick)
19813 sslip=sscalelip(fracinbuf)
19814 ssgradlip=sscagradlip(fracinbuf)/lipbufthick
19815 eliptran=eliptran+sslip*pepliptran
19816 gliptranc(3,i)=gliptranc(3,i)+ssgradlip*pepliptran/2.0d0
19817 gliptranc(3,i-1)=gliptranc(3,i-1)+ssgradlip*pepliptran/2.0d0
19818 !C gliptranc(3,i-2)=gliptranc(3,i)+ssgradlip*pepliptran
19819 !C print *, "doing sscalefor top part"
19820 !C print *,i,sslip,fracinbuf,ssgradlip
19822 eliptran=eliptran+pepliptran
19823 !C print *,"I am in true lipid"
19826 !C eliptran=elpitran+0.0 ! I am in water
19828 if (energy_dec) write(iout,*) i,"eliptran=",eliptran,positi,sslip
19830 ! here starts the side chain transfer
19831 do i=ilip_start,ilip_end
19832 if (itype(i,1).eq.ntyp1) cycle
19833 positi=(mod(c(3,i+nres),boxzsize))
19834 if (positi.le.0) positi=positi+boxzsize
19835 !C print *,mod(c(3,i+nres),boxzsize),bordlipbot,bordliptop
19836 !c for each residue check if it is in lipid or lipid water border area
19837 !C respos=mod(c(3,i+nres),boxzsize)
19838 !C print *,positi,bordlipbot,buflipbot
19839 if ((positi.gt.bordlipbot) &
19840 .and.(positi.lt.bordliptop)) then
19841 !C the energy transfer exist
19842 if (positi.lt.buflipbot) then
19844 ((positi-bordlipbot)/lipbufthick)
19845 !C lipbufthick is thickenes of lipid buffore
19846 sslip=sscalelip(fracinbuf)
19847 ssgradlip=-sscagradlip(fracinbuf)/lipbufthick
19848 eliptran=eliptran+sslip*liptranene(itype(i,1))
19849 gliptranx(3,i)=gliptranx(3,i) &
19850 +ssgradlip*liptranene(itype(i,1))
19851 gliptranc(3,i-1)= gliptranc(3,i-1) &
19852 +ssgradlip*liptranene(itype(i,1))
19853 !C print *,"doing sccale for lower part"
19854 elseif (positi.gt.bufliptop) then
19856 ((bordliptop-positi)/lipbufthick)
19857 sslip=sscalelip(fracinbuf)
19858 ssgradlip=sscagradlip(fracinbuf)/lipbufthick
19859 eliptran=eliptran+sslip*liptranene(itype(i,1))
19860 gliptranx(3,i)=gliptranx(3,i) &
19861 +ssgradlip*liptranene(itype(i,1))
19862 gliptranc(3,i-1)= gliptranc(3,i-1) &
19863 +ssgradlip*liptranene(itype(i,1))
19864 !C print *, "doing sscalefor top part",sslip,fracinbuf
19866 eliptran=eliptran+liptranene(itype(i,1))
19867 !C print *,"I am in true lipid"
19869 endif ! if in lipid or buffor
19871 !C eliptran=elpitran+0.0 ! I am in water
19872 if (energy_dec) write(iout,*) i,"eliptran=",eliptran
19875 end subroutine Eliptransfer
19876 !----------------------------------NANO FUNCTIONS
19877 !C-----------------------------------------------------------------------
19878 !C-----------------------------------------------------------
19879 !C This subroutine is to mimic the histone like structure but as well can be
19880 !C utilizet to nanostructures (infinit) small modification has to be used to
19881 !C make it finite (z gradient at the ends has to be changes as well as the x,y
19882 !C gradient has to be modified at the ends
19883 !C The energy function is Kihara potential
19884 !C E=4esp*((sigma/(r-r0))^12 - (sigma/(r-r0))^6)
19885 !C 4eps is depth of well sigma is r_minimum r is distance from center of tube
19886 !C and r0 is the excluded size of nanotube (can be set to 0 if we want just a
19887 !C simple Kihara potential
19888 subroutine calctube(Etube)
19889 real(kind=8),dimension(3) :: vectube
19890 real(kind=8) :: Etube,xtemp,xminact,yminact,&
19891 ytemp,xmin,ymin,tub_r,rdiff,rdiff6,fac,positi, &
19892 sc_aa_tube,sc_bb_tube
19895 do i=itube_start,itube_end
19897 enetube(i+nres)=0.0d0
19899 !C first we calculate the distance from tube center
19901 do i=itube_start,itube_end
19902 !C lets ommit dummy atoms for now
19903 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1)) cycle
19904 !C now calculate distance from center of tube and direction vectors
19907 ! Find minimum distance in periodic box
19909 vectube(1)=mod((c(1,i)+c(1,i+1))/2.0d0,boxxsize)
19910 vectube(1)=vectube(1)+boxxsize*j
19911 vectube(2)=mod((c(2,i)+c(2,i+1))/2.0d0,boxysize)
19912 vectube(2)=vectube(2)+boxysize*j
19913 xminact=abs(vectube(1)-tubecenter(1))
19914 yminact=abs(vectube(2)-tubecenter(2))
19915 if (xmin.gt.xminact) then
19919 if (ymin.gt.yminact) then
19926 vectube(1)=vectube(1)-tubecenter(1)
19927 vectube(2)=vectube(2)-tubecenter(2)
19929 !C print *,"x",(c(1,i)+c(1,i+1))/2.0d0,tubecenter(1)
19930 !C print *,"y",(c(2,i)+c(2,i+1))/2.0d0,tubecenter(2)
19932 !C as the tube is infinity we do not calculate the Z-vector use of Z
19935 !C now calculte the distance
19936 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
19937 !C now normalize vector
19938 vectube(1)=vectube(1)/tub_r
19939 vectube(2)=vectube(2)/tub_r
19940 !C calculte rdiffrence between r and r0
19943 rdiff6=rdiff**6.0d0
19944 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
19945 enetube(i)=pep_aa_tube/rdiff6**2.0d0+pep_bb_tube/rdiff6
19946 !C write(iout,*) "TU13",i,rdiff6,enetube(i)
19947 !C print *,rdiff,rdiff6,pep_aa_tube
19948 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
19949 !C now we calculate gradient
19950 fac=(-12.0d0*pep_aa_tube/rdiff6- &
19951 6.0d0*pep_bb_tube)/rdiff6/rdiff
19952 !C write(iout,'(a5,i4,f12.1,3f12.5)') "TU13",i,rdiff6,enetube(i),
19954 !C now direction of gg_tube vector
19956 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac/2.0d0
19957 gg_tube(j,i)=gg_tube(j,i)+vectube(j)*fac/2.0d0
19960 !C basically thats all code now we split for side-chains (REMEMBER to sum up at the END)
19961 !C print *,gg_tube(1,0),"TU"
19964 do i=itube_start,itube_end
19965 !C Lets not jump over memory as we use many times iti
19967 !C lets ommit dummy atoms for now
19968 if ((iti.eq.ntyp1) &
19969 !C in UNRES uncomment the line below as GLY has no side-chain...
19975 vectube(1)=mod((c(1,i+nres)),boxxsize)
19976 vectube(1)=vectube(1)+boxxsize*j
19977 vectube(2)=mod((c(2,i+nres)),boxysize)
19978 vectube(2)=vectube(2)+boxysize*j
19980 xminact=abs(vectube(1)-tubecenter(1))
19981 yminact=abs(vectube(2)-tubecenter(2))
19982 if (xmin.gt.xminact) then
19986 if (ymin.gt.yminact) then
19993 !C write(iout,*), "tututu", vectube(1),tubecenter(1),vectube(2),
19995 vectube(1)=vectube(1)-tubecenter(1)
19996 vectube(2)=vectube(2)-tubecenter(2)
19998 !C as the tube is infinity we do not calculate the Z-vector use of Z
20001 !C now calculte the distance
20002 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
20003 !C now normalize vector
20004 vectube(1)=vectube(1)/tub_r
20005 vectube(2)=vectube(2)/tub_r
20007 !C calculte rdiffrence between r and r0
20010 rdiff6=rdiff**6.0d0
20011 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
20012 sc_aa_tube=sc_aa_tube_par(iti)
20013 sc_bb_tube=sc_bb_tube_par(iti)
20014 enetube(i+nres)=sc_aa_tube/rdiff6**2.0d0+sc_bb_tube/rdiff6
20015 fac=-12.0d0*sc_aa_tube/rdiff6**2.0d0/rdiff- &
20016 6.0d0*sc_bb_tube/rdiff6/rdiff
20017 !C now direction of gg_tube vector
20019 gg_tube_SC(j,i)=gg_tube_SC(j,i)+vectube(j)*fac
20020 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac
20023 do i=itube_start,itube_end
20024 Etube=Etube+enetube(i)+enetube(i+nres)
20026 !C print *,"ETUBE", etube
20028 end subroutine calctube
20029 !C TO DO 1) add to total energy
20030 !C 2) add to gradient summation
20031 !C 3) add reading parameters (AND of course oppening of PARAM file)
20032 !C 4) add reading the center of tube
20034 !C 6) add to zerograd
20035 !C 7) allocate matrices
20038 !C-----------------------------------------------------------------------
20039 !C-----------------------------------------------------------
20040 !C This subroutine is to mimic the histone like structure but as well can be
20041 !C utilizet to nanostructures (infinit) small modification has to be used to
20042 !C make it finite (z gradient at the ends has to be changes as well as the x,y
20043 !C gradient has to be modified at the ends
20044 !C The energy function is Kihara potential
20045 !C E=4esp*((sigma/(r-r0))^12 - (sigma/(r-r0))^6)
20046 !C 4eps is depth of well sigma is r_minimum r is distance from center of tube
20047 !C and r0 is the excluded size of nanotube (can be set to 0 if we want just a
20048 !C simple Kihara potential
20049 subroutine calctube2(Etube)
20050 real(kind=8),dimension(3) :: vectube
20051 real(kind=8) :: Etube,xtemp,xminact,yminact,&
20052 ytemp,xmin,ymin,tub_r,rdiff,rdiff6,fac,positi,fracinbuf,&
20053 sstube,ssgradtube,sc_aa_tube,sc_bb_tube
20056 do i=itube_start,itube_end
20058 enetube(i+nres)=0.0d0
20060 !C first we calculate the distance from tube center
20061 !C first sugare-phosphate group for NARES this would be peptide group
20063 do i=itube_start,itube_end
20064 !C lets ommit dummy atoms for now
20066 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1)) cycle
20067 !C now calculate distance from center of tube and direction vectors
20068 !C vectube(1)=mod((c(1,i)+c(1,i+1))/2.0d0,boxxsize)
20069 !C if (vectube(1).lt.0) vectube(1)=vectube(1)+boxxsize
20070 !C vectube(2)=mod((c(2,i)+c(2,i+1))/2.0d0,boxysize)
20071 !C if (vectube(2).lt.0) vectube(2)=vectube(2)+boxysize
20075 vectube(1)=mod((c(1,i)+c(1,i+1))/2.0d0,boxxsize)
20076 vectube(1)=vectube(1)+boxxsize*j
20077 vectube(2)=mod((c(2,i)+c(2,i+1))/2.0d0,boxysize)
20078 vectube(2)=vectube(2)+boxysize*j
20080 xminact=abs(vectube(1)-tubecenter(1))
20081 yminact=abs(vectube(2)-tubecenter(2))
20082 if (xmin.gt.xminact) then
20086 if (ymin.gt.yminact) then
20093 vectube(1)=vectube(1)-tubecenter(1)
20094 vectube(2)=vectube(2)-tubecenter(2)
20096 !C print *,"x",(c(1,i)+c(1,i+1))/2.0d0,tubecenter(1)
20097 !C print *,"y",(c(2,i)+c(2,i+1))/2.0d0,tubecenter(2)
20099 !C as the tube is infinity we do not calculate the Z-vector use of Z
20102 !C now calculte the distance
20103 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
20104 !C now normalize vector
20105 vectube(1)=vectube(1)/tub_r
20106 vectube(2)=vectube(2)/tub_r
20107 !C calculte rdiffrence between r and r0
20110 rdiff6=rdiff**6.0d0
20111 !C THIS FRAGMENT MAKES TUBE FINITE
20112 positi=mod((c(3,i)+c(3,i+1))/2.0d0,boxzsize)
20113 if (positi.le.0) positi=positi+boxzsize
20114 !C print *,mod(c(3,i+nres),boxzsize),bordlipbot,bordliptop
20115 !c for each residue check if it is in lipid or lipid water border area
20116 !C respos=mod(c(3,i+nres),boxzsize)
20117 !C print *,positi,bordtubebot,buftubebot,bordtubetop
20118 if ((positi.gt.bordtubebot) &
20119 .and.(positi.lt.bordtubetop)) then
20120 !C the energy transfer exist
20121 if (positi.lt.buftubebot) then
20123 ((positi-bordtubebot)/tubebufthick)
20124 !C lipbufthick is thickenes of lipid buffore
20125 sstube=sscalelip(fracinbuf)
20126 ssgradtube=-sscagradlip(fracinbuf)/tubebufthick
20127 !C print *,ssgradtube, sstube,tubetranene(itype(i,1))
20128 enetube(i)=enetube(i)+sstube*tubetranenepep
20129 !C gg_tube_SC(3,i)=gg_tube_SC(3,i)
20130 !C &+ssgradtube*tubetranene(itype(i,1))
20131 !C gg_tube(3,i-1)= gg_tube(3,i-1)
20132 !C &+ssgradtube*tubetranene(itype(i,1))
20133 !C print *,"doing sccale for lower part"
20134 elseif (positi.gt.buftubetop) then
20136 ((bordtubetop-positi)/tubebufthick)
20137 sstube=sscalelip(fracinbuf)
20138 ssgradtube=sscagradlip(fracinbuf)/tubebufthick
20139 enetube(i)=enetube(i)+sstube*tubetranenepep
20140 !C gg_tube_SC(3,i)=gg_tube_SC(3,i)
20141 !C &+ssgradtube*tubetranene(itype(i,1))
20142 !C gg_tube(3,i-1)= gg_tube(3,i-1)
20143 !C &+ssgradtube*tubetranene(itype(i,1))
20144 !C print *, "doing sscalefor top part",sslip,fracinbuf
20148 enetube(i)=enetube(i)+sstube*tubetranenepep
20149 !C print *,"I am in true lipid"
20153 !C ssgradtube=0.0d0
20155 endif ! if in lipid or buffor
20157 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
20158 enetube(i)=enetube(i)+sstube* &
20159 (pep_aa_tube/rdiff6**2.0d0+pep_bb_tube/rdiff6)
20160 !C write(iout,*) "TU13",i,rdiff6,enetube(i)
20161 !C print *,rdiff,rdiff6,pep_aa_tube
20162 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
20163 !C now we calculate gradient
20164 fac=(-12.0d0*pep_aa_tube/rdiff6- &
20165 6.0d0*pep_bb_tube)/rdiff6/rdiff*sstube
20166 !C write(iout,'(a5,i4,f12.1,3f12.5)') "TU13",i,rdiff6,enetube(i),
20169 !C now direction of gg_tube vector
20171 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac/2.0d0
20172 gg_tube(j,i)=gg_tube(j,i)+vectube(j)*fac/2.0d0
20174 gg_tube(3,i)=gg_tube(3,i) &
20175 +ssgradtube*enetube(i)/sstube/2.0d0
20176 gg_tube(3,i-1)= gg_tube(3,i-1) &
20177 +ssgradtube*enetube(i)/sstube/2.0d0
20180 !C basically thats all code now we split for side-chains (REMEMBER to sum up at the END)
20181 !C print *,gg_tube(1,0),"TU"
20182 do i=itube_start,itube_end
20183 !C Lets not jump over memory as we use many times iti
20185 !C lets ommit dummy atoms for now
20186 if ((iti.eq.ntyp1) &
20187 !!C in UNRES uncomment the line below as GLY has no side-chain...
20190 vectube(1)=c(1,i+nres)
20191 vectube(1)=mod(vectube(1),boxxsize)
20192 if (vectube(1).lt.0) vectube(1)=vectube(1)+boxxsize
20193 vectube(2)=c(2,i+nres)
20194 vectube(2)=mod(vectube(2),boxysize)
20195 if (vectube(2).lt.0) vectube(2)=vectube(2)+boxysize
20197 vectube(1)=vectube(1)-tubecenter(1)
20198 vectube(2)=vectube(2)-tubecenter(2)
20199 !C THIS FRAGMENT MAKES TUBE FINITE
20200 positi=(mod(c(3,i+nres),boxzsize))
20201 if (positi.le.0) positi=positi+boxzsize
20202 !C print *,mod(c(3,i+nres),boxzsize),bordlipbot,bordliptop
20203 !c for each residue check if it is in lipid or lipid water border area
20204 !C respos=mod(c(3,i+nres),boxzsize)
20205 !C print *,positi,bordtubebot,buftubebot,bordtubetop
20207 if ((positi.gt.bordtubebot) &
20208 .and.(positi.lt.bordtubetop)) then
20209 !C the energy transfer exist
20210 if (positi.lt.buftubebot) then
20212 ((positi-bordtubebot)/tubebufthick)
20213 !C lipbufthick is thickenes of lipid buffore
20214 sstube=sscalelip(fracinbuf)
20215 ssgradtube=-sscagradlip(fracinbuf)/tubebufthick
20216 !C print *,ssgradtube, sstube,tubetranene(itype(i,1))
20217 enetube(i+nres)=enetube(i+nres)+sstube*tubetranene(itype(i,1))
20218 !C gg_tube_SC(3,i)=gg_tube_SC(3,i)
20219 !C &+ssgradtube*tubetranene(itype(i,1))
20220 !C gg_tube(3,i-1)= gg_tube(3,i-1)
20221 !C &+ssgradtube*tubetranene(itype(i,1))
20222 !C print *,"doing sccale for lower part"
20223 elseif (positi.gt.buftubetop) then
20225 ((bordtubetop-positi)/tubebufthick)
20227 sstube=sscalelip(fracinbuf)
20228 ssgradtube=sscagradlip(fracinbuf)/tubebufthick
20229 enetube(i+nres)=enetube(i+nres)+sstube*tubetranene(itype(i,1))
20230 !C gg_tube_SC(3,i)=gg_tube_SC(3,i)
20231 !C &+ssgradtube*tubetranene(itype(i,1))
20232 !C gg_tube(3,i-1)= gg_tube(3,i-1)
20233 !C &+ssgradtube*tubetranene(itype(i,1))
20234 !C print *, "doing sscalefor top part",sslip,fracinbuf
20238 enetube(i+nres)=enetube(i+nres)+sstube*tubetranene(itype(i,1))
20239 !C print *,"I am in true lipid"
20243 !C ssgradtube=0.0d0
20245 endif ! if in lipid or buffor
20246 !CEND OF FINITE FRAGMENT
20247 !C as the tube is infinity we do not calculate the Z-vector use of Z
20250 !C now calculte the distance
20251 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
20252 !C now normalize vector
20253 vectube(1)=vectube(1)/tub_r
20254 vectube(2)=vectube(2)/tub_r
20255 !C calculte rdiffrence between r and r0
20258 rdiff6=rdiff**6.0d0
20259 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
20260 sc_aa_tube=sc_aa_tube_par(iti)
20261 sc_bb_tube=sc_bb_tube_par(iti)
20262 enetube(i+nres)=(sc_aa_tube/rdiff6**2.0d0+sc_bb_tube/rdiff6)&
20263 *sstube+enetube(i+nres)
20264 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
20265 !C now we calculate gradient
20266 fac=(-12.0d0*sc_aa_tube/rdiff6**2.0d0/rdiff-&
20267 6.0d0*sc_bb_tube/rdiff6/rdiff)*sstube
20268 !C now direction of gg_tube vector
20270 gg_tube_SC(j,i)=gg_tube_SC(j,i)+vectube(j)*fac
20271 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac
20273 gg_tube_SC(3,i)=gg_tube_SC(3,i) &
20274 +ssgradtube*enetube(i+nres)/sstube
20275 gg_tube(3,i-1)= gg_tube(3,i-1) &
20276 +ssgradtube*enetube(i+nres)/sstube
20279 do i=itube_start,itube_end
20280 Etube=Etube+enetube(i)+enetube(i+nres)
20282 !C print *,"ETUBE", etube
20284 end subroutine calctube2
20285 !=====================================================================================================================================
20286 subroutine calcnano(Etube)
20287 real(kind=8),dimension(3) :: vectube
20289 real(kind=8) :: Etube,xtemp,xminact,yminact,&
20290 ytemp,xmin,ymin,tub_r,rdiff,rdiff6,fac,denominator,faccav,&
20291 sc_aa_tube,sc_bb_tube,zmin,ztemp,zminact
20292 integer:: i,j,iti,r
20295 ! print *,itube_start,itube_end,"poczatek"
20296 do i=itube_start,itube_end
20298 enetube(i+nres)=0.0d0
20300 !C first we calculate the distance from tube center
20301 !C first sugare-phosphate group for NARES this would be peptide group
20303 do i=itube_start,itube_end
20304 !C lets ommit dummy atoms for now
20305 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1)) cycle
20306 !C now calculate distance from center of tube and direction vectors
20312 vectube(1)=dmod((c(1,i)+c(1,i+1))/2.0d0,boxxsize)
20313 vectube(1)=vectube(1)+boxxsize*j
20314 vectube(2)=dmod((c(2,i)+c(2,i+1))/2.0d0,boxysize)
20315 vectube(2)=vectube(2)+boxysize*j
20316 vectube(3)=dmod((c(3,i)+c(3,i+1))/2.0d0,boxzsize)
20317 vectube(3)=vectube(3)+boxzsize*j
20320 xminact=dabs(vectube(1)-tubecenter(1))
20321 yminact=dabs(vectube(2)-tubecenter(2))
20322 zminact=dabs(vectube(3)-tubecenter(3))
20324 if (xmin.gt.xminact) then
20328 if (ymin.gt.yminact) then
20332 if (zmin.gt.zminact) then
20341 vectube(1)=vectube(1)-tubecenter(1)
20342 vectube(2)=vectube(2)-tubecenter(2)
20343 vectube(3)=vectube(3)-tubecenter(3)
20345 !C print *,"x",(c(1,i)+c(1,i+1))/2.0d0,tubecenter(1)
20346 !C print *,"y",(c(2,i)+c(2,i+1))/2.0d0,tubecenter(2)
20347 !C as the tube is infinity we do not calculate the Z-vector use of Z
20349 !C vectube(3)=0.0d0
20350 !C now calculte the distance
20351 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
20352 !C now normalize vector
20353 vectube(1)=vectube(1)/tub_r
20354 vectube(2)=vectube(2)/tub_r
20355 vectube(3)=vectube(3)/tub_r
20356 !C calculte rdiffrence between r and r0
20359 rdiff6=rdiff**6.0d0
20360 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
20361 enetube(i)=pep_aa_tube/rdiff6**2.0d0+pep_bb_tube/rdiff6
20362 !C write(iout,*) "TU13",i,rdiff6,enetube(i)
20363 !C print *,rdiff,rdiff6,pep_aa_tube
20364 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
20365 !C now we calculate gradient
20366 fac=(-12.0d0*pep_aa_tube/rdiff6- &
20367 6.0d0*pep_bb_tube)/rdiff6/rdiff
20368 !C write(iout,'(a5,i4,f12.1,3f12.5)') "TU13",i,rdiff6,enetube(i),
20370 if (acavtubpep.eq.0.0d0) then
20375 denominator=(1.0d0+dcavtubpep*rdiff6*rdiff6)
20377 (bcavtubpep*rdiff+acavtubpep*dsqrt(rdiff)+ccavtubpep) &
20380 faccav=((bcavtubpep*1.0d0+acavtubpep/2.0d0/dsqrt(rdiff)) &
20381 *denominator-(bcavtubpep*rdiff+acavtubpep*dsqrt(rdiff) &
20382 +ccavtubpep)*rdiff6**2.0d0/rdiff*dcavtubpep*12.0d0) &
20383 /denominator**2.0d0
20388 if (energy_dec) write(iout,*),i,rdiff,enetube(i),enecavtube(i)
20390 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac/2.0d0
20391 gg_tube(j,i)=gg_tube(j,i)+vectube(j)*fac/2.0d0
20395 do i=itube_start,itube_end
20396 enecavtube(i)=0.0d0
20397 !C Lets not jump over memory as we use many times iti
20399 !C lets ommit dummy atoms for now
20400 if ((iti.eq.ntyp1) &
20401 !C in UNRES uncomment the line below as GLY has no side-chain...
20408 vectube(1)=dmod((c(1,i+nres)),boxxsize)
20409 vectube(1)=vectube(1)+boxxsize*j
20410 vectube(2)=dmod((c(2,i+nres)),boxysize)
20411 vectube(2)=vectube(2)+boxysize*j
20412 vectube(3)=dmod((c(3,i+nres)),boxzsize)
20413 vectube(3)=vectube(3)+boxzsize*j
20416 xminact=dabs(vectube(1)-tubecenter(1))
20417 yminact=dabs(vectube(2)-tubecenter(2))
20418 zminact=dabs(vectube(3)-tubecenter(3))
20420 if (xmin.gt.xminact) then
20424 if (ymin.gt.yminact) then
20428 if (zmin.gt.zminact) then
20437 !C write(iout,*), "tututu", vectube(1),tubecenter(1),vectube(2),
20439 vectube(1)=vectube(1)-tubecenter(1)
20440 vectube(2)=vectube(2)-tubecenter(2)
20441 vectube(3)=vectube(3)-tubecenter(3)
20442 !C now calculte the distance
20443 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
20444 !C now normalize vector
20445 vectube(1)=vectube(1)/tub_r
20446 vectube(2)=vectube(2)/tub_r
20447 vectube(3)=vectube(3)/tub_r
20449 !C calculte rdiffrence between r and r0
20452 rdiff6=rdiff**6.0d0
20453 sc_aa_tube=sc_aa_tube_par(iti)
20454 sc_bb_tube=sc_bb_tube_par(iti)
20455 enetube(i+nres)=sc_aa_tube/rdiff6**2.0d0+sc_bb_tube/rdiff6
20456 !C enetube(i+nres)=0.0d0
20457 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
20458 !C now we calculate gradient
20459 fac=-12.0d0*sc_aa_tube/rdiff6**2.0d0/rdiff- &
20460 6.0d0*sc_bb_tube/rdiff6/rdiff
20462 !C now direction of gg_tube vector
20463 !C Now cavity term E=a(x+bsqrt(x)+c)/(1+dx^12)
20464 if (acavtub(iti).eq.0.0d0) then
20466 enecavtube(i+nres)=0.0d0
20469 denominator=(1.0d0+dcavtub(iti)*rdiff6*rdiff6)
20470 enecavtube(i+nres)= &
20471 (bcavtub(iti)*rdiff+acavtub(iti)*dsqrt(rdiff)+ccavtub(iti)) &
20473 !C enecavtube(i)=0.0
20474 faccav=((bcavtub(iti)*1.0d0+acavtub(iti)/2.0d0/dsqrt(rdiff)) &
20475 *denominator-(bcavtub(iti)*rdiff+acavtub(iti)*dsqrt(rdiff) &
20476 +ccavtub(iti))*rdiff6**2.0d0/rdiff*dcavtub(iti)*12.0d0) &
20477 /denominator**2.0d0
20482 !C print *,"TUT",i,iti,rdiff,rdiff6,acavtub(iti),denominator,
20483 !C & enecavtube(i),faccav
20484 !C print *,"licz=",
20485 !C & (bcavtub(iti)*rdiff+acavtub(iti)*sqrt(rdiff)+ccavtub(iti))
20486 !C print *,"finene=",enetube(i+nres)+enecavtube(i)
20488 gg_tube_SC(j,i)=gg_tube_SC(j,i)+vectube(j)*fac
20489 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac
20491 if (energy_dec) write(iout,*),i,rdiff,enetube(i+nres),enecavtube(i+nres)
20496 do i=itube_start,itube_end
20497 Etube=Etube+enetube(i)+enetube(i+nres)+enecavtube(i) &
20498 +enecavtube(i+nres)
20501 ! print *,"begin", i,"a"
20504 ! rdiff6=rdiff**6.0d0
20505 ! sc_aa_tube=sc_aa_tube_par(i)
20506 ! sc_bb_tube=sc_bb_tube_par(i)
20507 ! enetube(i)=sc_aa_tube/rdiff6**2.0d0+sc_bb_tube/rdiff6
20508 ! denominator=(1.0d0+dcavtub(i)*rdiff6*rdiff6)
20510 ! (bcavtub(i)*rdiff+acavtub(i)*dsqrt(rdiff)+ccavtub(i)) &
20513 ! print '(5(f10.3,1x))',rdiff,enetube(i),enecavtube(i),enecavtube(i)+enetube(i)
20515 ! print *,"end",i,"a"
20517 !C print *,"ETUBE", etube
20519 end subroutine calcnano
20521 !===============================================
20522 !--------------------------------------------------------------------------------
20523 !C first for shielding is setting of function of side-chains
20525 subroutine set_shield_fac2
20526 real(kind=8) :: div77_81=0.974996043d0, &
20527 div4_81=0.2222222222d0
20528 real (kind=8) :: dist_pep_side,dist_side_calf,dist_pept_group, &
20529 scale_fac_dist,fac_help_scale,VofOverlap,VolumeTotal,costhet,&
20530 short,long,sinthet,costhet_fac,sh_frac_dist,rkprim,cosphi, &
20531 sinphi,cosphi_fac,pep_side0pept_group,cosalfa,fac_alfa_sin
20532 !C the vector between center of side_chain and peptide group
20533 real(kind=8),dimension(3) :: pep_side_long,side_calf, &
20534 pept_group,costhet_grad,cosphi_grad_long, &
20535 cosphi_grad_loc,pep_side_norm,side_calf_norm, &
20536 sh_frac_dist_grad,pep_side
20538 !C write(2,*) "ivec",ivec_start,ivec_end
20540 fac_shield(i)=0.0d0
20543 grad_shield(j,i)=0.0d0
20546 do i=ivec_start,ivec_end
20548 !C if ((itype(i,1).eq.ntyp1).and.itype(i+1,1).eq.ntyp1) cycle
20549 ! ishield_list(i)=0
20550 if ((itype(i,1).eq.ntyp1).and.itype(i+1,1).eq.ntyp1) cycle
20551 !Cif there two consequtive dummy atoms there is no peptide group between them
20552 !C the line below has to be changed for FGPROC>1
20555 if ((itype(k,1).eq.ntyp1).or.(itype(k,1).eq.10)) cycle
20559 !C first lets set vector conecting the ithe side-chain with kth side-chain
20560 pep_side(j)=c(j,k+nres)-(c(j,i)+c(j,i+1))/2.0d0
20561 !C pep_side(j)=2.0d0
20562 !C and vector conecting the side-chain with its proper calfa
20563 side_calf(j)=c(j,k+nres)-c(j,k)
20564 !C side_calf(j)=2.0d0
20565 pept_group(j)=c(j,i)-c(j,i+1)
20566 !C lets have their lenght
20567 dist_pep_side=pep_side(j)**2+dist_pep_side
20568 dist_side_calf=dist_side_calf+side_calf(j)**2
20569 dist_pept_group=dist_pept_group+pept_group(j)**2
20571 dist_pep_side=sqrt(dist_pep_side)
20572 dist_pept_group=sqrt(dist_pept_group)
20573 dist_side_calf=sqrt(dist_side_calf)
20575 pep_side_norm(j)=pep_side(j)/dist_pep_side
20576 side_calf_norm(j)=dist_side_calf
20578 !C now sscale fraction
20579 sh_frac_dist=-(dist_pep_side-rpp(1,1)-buff_shield)/buff_shield
20580 ! print *,buff_shield,"buff",sh_frac_dist
20582 if (sh_frac_dist.le.0.0) cycle
20583 !C print *,ishield_list(i),i
20584 !C If we reach here it means that this side chain reaches the shielding sphere
20585 !C Lets add him to the list for gradient
20586 ishield_list(i)=ishield_list(i)+1
20587 !C ishield_list is a list of non 0 side-chain that contribute to factor gradient
20588 !C this list is essential otherwise problem would be O3
20589 shield_list(ishield_list(i),i)=k
20590 !C Lets have the sscale value
20591 if (sh_frac_dist.gt.1.0) then
20592 scale_fac_dist=1.0d0
20594 sh_frac_dist_grad(j)=0.0d0
20597 scale_fac_dist=-sh_frac_dist*sh_frac_dist &
20598 *(2.0d0*sh_frac_dist-3.0d0)
20599 fac_help_scale=6.0d0*(sh_frac_dist-sh_frac_dist**2) &
20600 /dist_pep_side/buff_shield*0.5d0
20602 sh_frac_dist_grad(j)=fac_help_scale*pep_side(j)
20603 !C sh_frac_dist_grad(j)=0.0d0
20604 !C scale_fac_dist=1.0d0
20605 !C print *,"jestem",scale_fac_dist,fac_help_scale,
20606 !C & sh_frac_dist_grad(j)
20609 !C this is what is now we have the distance scaling now volume...
20610 short=short_r_sidechain(itype(k,1))
20611 long=long_r_sidechain(itype(k,1))
20612 costhet=1.0d0/dsqrt(1.0d0+short**2/dist_pep_side**2)
20613 sinthet=short/dist_pep_side*costhet
20614 ! print *,"SORT",short,long,sinthet,costhet
20615 !C now costhet_grad
20618 costhet_fac=costhet**3*short**2*(-0.5d0)/dist_pep_side**4
20619 !C sinthet_fac=costhet**2*0.5d0*(short**3/dist_pep_side**4*costhet
20620 !C & -short/dist_pep_side**2/costhet)
20621 !C costhet_fac=0.0d0
20623 costhet_grad(j)=costhet_fac*pep_side(j)
20625 !C remember for the final gradient multiply costhet_grad(j)
20626 !C for side_chain by factor -2 !
20627 !C fac alfa is angle between CB_k,CA_k, CA_i,CA_i+1
20628 !C pep_side0pept_group is vector multiplication
20629 pep_side0pept_group=0.0d0
20631 pep_side0pept_group=pep_side0pept_group+pep_side(j)*side_calf(j)
20633 cosalfa=(pep_side0pept_group/ &
20634 (dist_pep_side*dist_side_calf))
20635 fac_alfa_sin=1.0d0-cosalfa**2
20636 fac_alfa_sin=dsqrt(fac_alfa_sin)
20637 rkprim=fac_alfa_sin*(long-short)+short
20640 !C now costhet_grad
20641 cosphi=1.0d0/dsqrt(1.0d0+rkprim**2/dist_pep_side**2)
20643 cosphi_fac=cosphi**3*rkprim**2*(-0.5d0)/dist_pep_side**4
20644 sinphi=rkprim/dist_pep_side/dsqrt(1.0d0+rkprim**2/ &
20648 cosphi_grad_long(j)=cosphi_fac*pep_side(j) &
20649 +cosphi**3*0.5d0/dist_pep_side**2*(-rkprim) &
20650 *(long-short)/fac_alfa_sin*cosalfa/ &
20651 ((dist_pep_side*dist_side_calf))* &
20652 ((side_calf(j))-cosalfa* &
20653 ((pep_side(j)/dist_pep_side)*dist_side_calf))
20654 !C cosphi_grad_long(j)=0.0d0
20655 cosphi_grad_loc(j)=cosphi**3*0.5d0/dist_pep_side**2*(-rkprim) &
20656 *(long-short)/fac_alfa_sin*cosalfa &
20657 /((dist_pep_side*dist_side_calf))* &
20659 cosalfa*side_calf(j)/dist_side_calf*dist_pep_side)
20660 !C cosphi_grad_loc(j)=0.0d0
20662 !C print *,sinphi,sinthet
20663 VofOverlap=VSolvSphere/2.0d0*(1.0d0-dsqrt(1.0d0-sinphi*sinthet)) &
20666 !C now the gradient...
20668 grad_shield(j,i)=grad_shield(j,i) &
20669 !C gradient po skalowaniu
20670 +(sh_frac_dist_grad(j)*VofOverlap &
20671 !C gradient po costhet
20672 +scale_fac_dist*VSolvSphere/VSolvSphere_div/4.0d0* &
20673 (1.0d0/(-dsqrt(1.0d0-sinphi*sinthet))*( &
20674 sinphi/sinthet*costhet*costhet_grad(j) &
20675 +sinthet/sinphi*cosphi*cosphi_grad_long(j))) &
20677 !C grad_shield_side is Cbeta sidechain gradient
20678 grad_shield_side(j,ishield_list(i),i)=&
20679 (sh_frac_dist_grad(j)*-2.0d0&
20681 -scale_fac_dist*VSolvSphere/VSolvSphere_div/2.0d0*&
20682 (1.0d0/(-dsqrt(1.0d0-sinphi*sinthet))*(&
20683 sinphi/sinthet*costhet*costhet_grad(j)&
20684 +sinthet/sinphi*cosphi*cosphi_grad_long(j))) &
20686 ! print *, 1.0d0/(-dsqrt(1.0d0-sinphi*sinthet)),&
20688 ! +sinthet/sinphi,"HERE"
20689 grad_shield_loc(j,ishield_list(i),i)= &
20690 scale_fac_dist*VSolvSphere/VSolvSphere_div/2.0d0*&
20691 (1.0d0/(dsqrt(1.0d0-sinphi*sinthet))*(&
20692 sinthet/sinphi*cosphi*cosphi_grad_loc(j)&
20695 ! print *,grad_shield_loc(j,ishield_list(i),i)
20697 VolumeTotal=VolumeTotal+VofOverlap*scale_fac_dist
20699 fac_shield(i)=VolumeTotal*wshield+(1.0d0-wshield)
20701 ! write(2,*) "TOTAL VOLUME",i,itype(i,1),fac_shield(i)
20704 end subroutine set_shield_fac2
20705 !----------------------------------------------------------------------------
20706 ! SOUBROUTINE FOR AFM
20707 subroutine AFMvel(Eafmforce)
20708 use MD_data, only:totTafm
20709 real(kind=8),dimension(3) :: diffafm
20710 real(kind=8) :: afmdist,Eafmforce
20712 !C Only for check grad COMMENT if not used for checkgrad
20714 !C--------------------------------------------------------
20715 !C print *,"wchodze"
20719 diffafm(i)=c(i,afmend)-c(i,afmbeg)
20720 afmdist=afmdist+diffafm(i)**2
20722 afmdist=dsqrt(afmdist)
20724 Eafmforce=0.5d0*forceAFMconst &
20725 *(distafminit+totTafm*velAFMconst-afmdist)**2
20726 !C Eafmforce=-forceAFMconst*(dist-distafminit)
20728 gradafm(i,afmend-1)=-forceAFMconst* &
20729 (distafminit+totTafm*velAFMconst-afmdist) &
20730 *diffafm(i)/afmdist
20731 gradafm(i,afmbeg-1)=forceAFMconst* &
20732 (distafminit+totTafm*velAFMconst-afmdist) &
20733 *diffafm(i)/afmdist
20735 ! print *,'AFM',Eafmforce,totTafm*velAFMconst,afmdist
20737 end subroutine AFMvel
20738 !---------------------------------------------------------
20739 subroutine AFMforce(Eafmforce)
20741 real(kind=8),dimension(3) :: diffafm
20742 ! real(kind=8) ::afmdist
20743 real(kind=8) :: afmdist,Eafmforce
20748 diffafm(i)=c(i,afmend)-c(i,afmbeg)
20749 afmdist=afmdist+diffafm(i)**2
20751 afmdist=dsqrt(afmdist)
20752 ! print *,afmdist,distafminit
20753 Eafmforce=-forceAFMconst*(afmdist-distafminit)
20755 gradafm(i,afmend-1)=-forceAFMconst*diffafm(i)/afmdist
20756 gradafm(i,afmbeg-1)=forceAFMconst*diffafm(i)/afmdist
20758 !C print *,'AFM',Eafmforce
20760 end subroutine AFMforce
20762 !-----------------------------------------------------------------------------
20764 subroutine read_ssHist
20767 ! include 'DIMENSIONS'
20768 ! include "DIMENSIONS.FREE"
20769 ! include 'COMMON.FREE'
20772 character(len=80) :: controlcard
20775 call card_concat(controlcard,.true.)
20776 read(controlcard,*) &
20777 dyn_ssHist(i,0),(dyn_ssHist(i,j),j=1,2*dyn_ssHist(i,0))
20781 end subroutine read_ssHist
20783 !-----------------------------------------------------------------------------
20784 integer function indmat(i,j)
20786 ! get the position of the jth ijth fragment of the chain coordinate system
20787 ! in the fromto array.
20790 indmat=((2*(nres-2)-i)*(i-1))/2+j-1
20792 end function indmat
20793 !-----------------------------------------------------------------------------
20794 real(kind=8) function sigm(x)
20800 !-----------------------------------------------------------------------------
20801 !-----------------------------------------------------------------------------
20802 subroutine alloc_ener_arrays
20803 !EL Allocation of arrays used by module energy
20804 use MD_data, only: mset
20805 !el local variables
20808 if(nres.lt.100) then
20810 elseif(nres.lt.200) then
20811 maxconts=10*nres ! Max. number of contacts per residue
20813 maxconts=10*nres ! (maxconts=maxres/4)
20815 maxcont=100*nres ! Max. number of SC contacts
20816 maxvar=6*nres ! Max. number of variables
20817 !el maxdim=(nres-1)*(nres-2)/2 ! Max. number of derivatives of virtual-bond
20818 maxdim=nres*(nres-2)/2 ! Max. number of derivatives of virtual-bond
20819 !----------------------
20820 ! arrays in subroutine init_int_table
20822 !el allocate(itask_cont_from(0:nfgtasks-1)) !(0:max_fg_procs-1)
20823 !el allocate(itask_cont_to(0:nfgtasks-1)) !(0:max_fg_procs-1)
20825 allocate(nint_gr(nres))
20826 allocate(nscp_gr(nres))
20827 allocate(ielstart(nres))
20828 allocate(ielend(nres))
20830 allocate(istart(nres,maxint_gr))
20831 allocate(iend(nres,maxint_gr))
20832 !(maxres,maxint_gr)
20833 allocate(iscpstart(nres,maxint_gr))
20834 allocate(iscpend(nres,maxint_gr))
20835 !(maxres,maxint_gr)
20836 allocate(ielstart_vdw(nres))
20837 allocate(ielend_vdw(nres))
20839 allocate(nint_gr_nucl(nres))
20840 allocate(nscp_gr_nucl(nres))
20841 allocate(ielstart_nucl(nres))
20842 allocate(ielend_nucl(nres))
20844 allocate(istart_nucl(nres,maxint_gr))
20845 allocate(iend_nucl(nres,maxint_gr))
20846 !(maxres,maxint_gr)
20847 allocate(iscpstart_nucl(nres,maxint_gr))
20848 allocate(iscpend_nucl(nres,maxint_gr))
20849 !(maxres,maxint_gr)
20850 allocate(ielstart_vdw_nucl(nres))
20851 allocate(ielend_vdw_nucl(nres))
20853 allocate(lentyp(0:nfgtasks-1))
20855 !----------------------
20857 ! common /contacts/
20858 if(.not.allocated(icont_ref)) allocate(icont_ref(2,maxcont))
20859 allocate(icont(2,maxcont))
20861 ! common /contacts1/
20862 allocate(num_cont(0:nres+4))
20864 allocate(jcont(maxconts,nres))
20866 allocate(facont(maxconts,nres))
20868 allocate(gacont(3,maxconts,nres))
20869 !(3,maxconts,maxres)
20870 ! common /contacts_hb/
20871 allocate(gacontp_hb1(3,maxconts,nres))
20872 allocate(gacontp_hb2(3,maxconts,nres))
20873 allocate(gacontp_hb3(3,maxconts,nres))
20874 allocate(gacontm_hb1(3,maxconts,nres))
20875 allocate(gacontm_hb2(3,maxconts,nres))
20876 allocate(gacontm_hb3(3,maxconts,nres))
20877 allocate(gacont_hbr(3,maxconts,nres))
20878 allocate(grij_hb_cont(3,maxconts,nres))
20879 !(3,maxconts,maxres)
20880 allocate(facont_hb(maxconts,nres))
20882 allocate(ees0p(maxconts,nres))
20883 allocate(ees0m(maxconts,nres))
20884 allocate(d_cont(maxconts,nres))
20885 allocate(ees0plist(maxconts,nres))
20888 allocate(num_cont_hb(nres))
20890 allocate(jcont_hb(maxconts,nres))
20893 allocate(Ug(2,2,nres))
20894 allocate(Ugder(2,2,nres))
20895 allocate(Ug2(2,2,nres))
20896 allocate(Ug2der(2,2,nres))
20898 allocate(obrot(2,nres))
20899 allocate(obrot2(2,nres))
20900 allocate(obrot_der(2,nres))
20901 allocate(obrot2_der(2,nres))
20903 ! common /precomp1/
20904 allocate(mu(2,nres))
20905 allocate(muder(2,nres))
20906 allocate(Ub2(2,nres))
20909 allocate(Ub2der(2,nres))
20910 allocate(Ctobr(2,nres))
20911 allocate(Ctobrder(2,nres))
20912 allocate(Dtobr2(2,nres))
20913 allocate(Dtobr2der(2,nres))
20915 allocate(EUg(2,2,nres))
20916 allocate(EUgder(2,2,nres))
20917 allocate(CUg(2,2,nres))
20918 allocate(CUgder(2,2,nres))
20919 allocate(DUg(2,2,nres))
20920 allocate(Dugder(2,2,nres))
20921 allocate(DtUg2(2,2,nres))
20922 allocate(DtUg2der(2,2,nres))
20924 ! common /precomp2/
20925 allocate(Ug2Db1t(2,nres))
20926 allocate(Ug2Db1tder(2,nres))
20927 allocate(CUgb2(2,nres))
20928 allocate(CUgb2der(2,nres))
20930 allocate(EUgC(2,2,nres))
20931 allocate(EUgCder(2,2,nres))
20932 allocate(EUgD(2,2,nres))
20933 allocate(EUgDder(2,2,nres))
20934 allocate(DtUg2EUg(2,2,nres))
20935 allocate(Ug2DtEUg(2,2,nres))
20937 allocate(Ug2DtEUgder(2,2,2,nres))
20938 allocate(DtUg2EUgder(2,2,2,nres))
20940 allocate(b1(2,nres)) !(2,-maxtor:maxtor)
20941 allocate(b2(2,nres)) !(2,-maxtor:maxtor)
20942 allocate(b1tilde(2,nres)) !(2,-maxtor:maxtor)
20943 allocate(b2tilde(2,nres)) !(2,-maxtor:maxtor)
20945 allocate(ctilde(2,2,nres))
20946 allocate(dtilde(2,2,nres)) !(2,2,-maxtor:maxtor)
20947 allocate(gtb1(2,nres))
20948 allocate(gtb2(2,nres))
20949 allocate(cc(2,2,nres))
20950 allocate(dd(2,2,nres))
20951 allocate(ee(2,2,nres))
20952 allocate(gtcc(2,2,nres))
20953 allocate(gtdd(2,2,nres))
20954 allocate(gtee(2,2,nres))
20955 allocate(gUb2(2,nres))
20956 allocate(gteUg(2,2,nres))
20958 ! common /rotat_old/
20959 allocate(costab(nres))
20960 allocate(sintab(nres))
20961 allocate(costab2(nres))
20962 allocate(sintab2(nres))
20965 allocate(a_chuj(2,2,maxconts,nres))
20966 !(2,2,maxconts,maxres)(maxconts=maxres/4)
20967 allocate(a_chuj_der(2,2,3,5,maxconts,nres))
20968 !(2,2,3,5,maxconts,maxres)(maxconts=maxres/4)
20969 ! common /contdistrib/
20970 allocate(ncont_sent(nres))
20971 allocate(ncont_recv(nres))
20973 allocate(iat_sent(nres))
20975 allocate(iint_sent(4,nres,nres))
20976 allocate(iint_sent_local(4,nres,nres))
20978 allocate(iturn3_sent(4,0:nres+4))
20979 allocate(iturn4_sent(4,0:nres+4))
20980 allocate(iturn3_sent_local(4,nres))
20981 allocate(iturn4_sent_local(4,nres))
20983 allocate(itask_cont_from(0:nfgtasks-1))
20984 allocate(itask_cont_to(0:nfgtasks-1))
20985 !(0:max_fg_procs-1)
20989 !----------------------
20992 allocate(dcdv(6,maxdim))
20993 allocate(dxdv(6,maxdim))
20995 allocate(dxds(6,nres))
20997 allocate(gradx(3,-1:nres,0:2))
20998 allocate(gradc(3,-1:nres,0:2))
21000 allocate(gvdwx(3,-1:nres))
21001 allocate(gvdwc(3,-1:nres))
21002 allocate(gelc(3,-1:nres))
21003 allocate(gelc_long(3,-1:nres))
21004 allocate(gvdwpp(3,-1:nres))
21005 allocate(gvdwc_scpp(3,-1:nres))
21006 allocate(gradx_scp(3,-1:nres))
21007 allocate(gvdwc_scp(3,-1:nres))
21008 allocate(ghpbx(3,-1:nres))
21009 allocate(ghpbc(3,-1:nres))
21010 allocate(gradcorr(3,-1:nres))
21011 allocate(gradcorr_long(3,-1:nres))
21012 allocate(gradcorr5_long(3,-1:nres))
21013 allocate(gradcorr6_long(3,-1:nres))
21014 allocate(gcorr6_turn_long(3,-1:nres))
21015 allocate(gradxorr(3,-1:nres))
21016 allocate(gradcorr5(3,-1:nres))
21017 allocate(gradcorr6(3,-1:nres))
21018 allocate(gliptran(3,-1:nres))
21019 allocate(gliptranc(3,-1:nres))
21020 allocate(gliptranx(3,-1:nres))
21021 allocate(gshieldx(3,-1:nres))
21022 allocate(gshieldc(3,-1:nres))
21023 allocate(gshieldc_loc(3,-1:nres))
21024 allocate(gshieldx_ec(3,-1:nres))
21025 allocate(gshieldc_ec(3,-1:nres))
21026 allocate(gshieldc_loc_ec(3,-1:nres))
21027 allocate(gshieldx_t3(3,-1:nres))
21028 allocate(gshieldc_t3(3,-1:nres))
21029 allocate(gshieldc_loc_t3(3,-1:nres))
21030 allocate(gshieldx_t4(3,-1:nres))
21031 allocate(gshieldc_t4(3,-1:nres))
21032 allocate(gshieldc_loc_t4(3,-1:nres))
21033 allocate(gshieldx_ll(3,-1:nres))
21034 allocate(gshieldc_ll(3,-1:nres))
21035 allocate(gshieldc_loc_ll(3,-1:nres))
21036 allocate(grad_shield(3,-1:nres))
21037 allocate(gg_tube_sc(3,-1:nres))
21038 allocate(gg_tube(3,-1:nres))
21039 allocate(gradafm(3,-1:nres))
21040 allocate(gradb_nucl(3,-1:nres))
21041 allocate(gradbx_nucl(3,-1:nres))
21042 allocate(gvdwpsb1(3,-1:nres))
21043 allocate(gelpp(3,-1:nres))
21044 allocate(gvdwpsb(3,-1:nres))
21045 allocate(gelsbc(3,-1:nres))
21046 allocate(gelsbx(3,-1:nres))
21047 allocate(gvdwsbx(3,-1:nres))
21048 allocate(gvdwsbc(3,-1:nres))
21049 allocate(gsbloc(3,-1:nres))
21050 allocate(gsblocx(3,-1:nres))
21051 allocate(gradcorr_nucl(3,-1:nres))
21052 allocate(gradxorr_nucl(3,-1:nres))
21053 allocate(gradcorr3_nucl(3,-1:nres))
21054 allocate(gradxorr3_nucl(3,-1:nres))
21055 allocate(gvdwpp_nucl(3,-1:nres))
21056 allocate(gradpepcat(3,-1:nres))
21057 allocate(gradpepcatx(3,-1:nres))
21058 allocate(gradcatcat(3,-1:nres))
21059 allocate(gradnuclcat(3,-1:nres))
21060 allocate(gradnuclcatx(3,-1:nres))
21062 allocate(grad_shield_side(3,maxcontsshi,-1:nres))
21063 allocate(grad_shield_loc(3,maxcontsshi,-1:nres))
21064 ! grad for shielding surroing
21065 allocate(gloc(0:maxvar,0:2))
21066 allocate(gloc_x(0:maxvar,2))
21068 allocate(gel_loc(3,-1:nres))
21069 allocate(gel_loc_long(3,-1:nres))
21070 allocate(gcorr3_turn(3,-1:nres))
21071 allocate(gcorr4_turn(3,-1:nres))
21072 allocate(gcorr6_turn(3,-1:nres))
21073 allocate(gradb(3,-1:nres))
21074 allocate(gradbx(3,-1:nres))
21076 allocate(gel_loc_loc(maxvar))
21077 allocate(gel_loc_turn3(maxvar))
21078 allocate(gel_loc_turn4(maxvar))
21079 allocate(gel_loc_turn6(maxvar))
21080 allocate(gcorr_loc(maxvar))
21081 allocate(g_corr5_loc(maxvar))
21082 allocate(g_corr6_loc(maxvar))
21084 allocate(gsccorc(3,-1:nres))
21085 allocate(gsccorx(3,-1:nres))
21087 allocate(gsccor_loc(-1:nres))
21089 allocate(gvdwx_scbase(3,-1:nres))
21090 allocate(gvdwc_scbase(3,-1:nres))
21091 allocate(gvdwx_pepbase(3,-1:nres))
21092 allocate(gvdwc_pepbase(3,-1:nres))
21093 allocate(gvdwx_scpho(3,-1:nres))
21094 allocate(gvdwc_scpho(3,-1:nres))
21095 allocate(gvdwc_peppho(3,-1:nres))
21097 allocate(dtheta(3,2,-1:nres))
21099 allocate(gscloc(3,-1:nres))
21100 allocate(gsclocx(3,-1:nres))
21102 allocate(dphi(3,3,-1:nres))
21103 allocate(dalpha(3,3,-1:nres))
21104 allocate(domega(3,3,-1:nres))
21106 ! common /deriv_scloc/
21107 allocate(dXX_C1tab(3,nres))
21108 allocate(dYY_C1tab(3,nres))
21109 allocate(dZZ_C1tab(3,nres))
21110 allocate(dXX_Ctab(3,nres))
21111 allocate(dYY_Ctab(3,nres))
21112 allocate(dZZ_Ctab(3,nres))
21113 allocate(dXX_XYZtab(3,nres))
21114 allocate(dYY_XYZtab(3,nres))
21115 allocate(dZZ_XYZtab(3,nres))
21118 allocate(jgrad_start(nres))
21119 allocate(jgrad_end(nres))
21121 !----------------------
21124 allocate(ibond_displ(0:nfgtasks-1))
21125 allocate(ibond_count(0:nfgtasks-1))
21126 allocate(ithet_displ(0:nfgtasks-1))
21127 allocate(ithet_count(0:nfgtasks-1))
21128 allocate(iphi_displ(0:nfgtasks-1))
21129 allocate(iphi_count(0:nfgtasks-1))
21130 allocate(iphi1_displ(0:nfgtasks-1))
21131 allocate(iphi1_count(0:nfgtasks-1))
21132 allocate(ivec_displ(0:nfgtasks-1))
21133 allocate(ivec_count(0:nfgtasks-1))
21134 allocate(iset_displ(0:nfgtasks-1))
21135 allocate(iset_count(0:nfgtasks-1))
21136 allocate(iint_count(0:nfgtasks-1))
21137 allocate(iint_displ(0:nfgtasks-1))
21138 !(0:max_fg_procs-1)
21139 !----------------------
21142 allocate(gcart(3,-1:nres))
21143 allocate(gxcart(3,-1:nres))
21145 allocate(gradcag(3,-1:nres))
21146 allocate(gradxag(3,-1:nres))
21148 ! common /back_constr/
21149 !el in energy:Econstr_back allocate((:),allocatable :: utheta,ugamma,uscdiff !(maxfrag_back)
21150 allocate(dutheta(nres))
21151 allocate(dugamma(nres))
21153 allocate(duscdiff(3,-1:nres))
21154 allocate(duscdiffx(3,-1:nres))
21156 !el i io:read_fragments
21157 ! allocate((:,:,:),allocatable :: wfrag_back !(3,maxfrag_back,maxprocs/20)
21158 ! allocate((:,:,:),allocatable :: ifrag_back !(3,maxfrag_back,maxprocs/20)
21160 ! allocate(qinfrag(50,nprocs/20),wfrag(50,nprocs/20)) !(50,maxprocs/20)
21161 ! allocate(qinpair(100,nprocs/20),wpair(100,nprocs/20)) !(100,maxprocs/20)
21162 allocate(mset(0:nprocs)) !(maxprocs/20)
21164 ! allocate(ifrag(2,50,nprocs/20)) !(2,50,maxprocs/20)
21165 ! allocate(ipair(2,100,nprocs/20)) !(2,100,maxprocs/20)
21166 allocate(dUdconst(3,0:nres))
21167 allocate(dUdxconst(3,0:nres))
21168 allocate(dqwol(3,0:nres))
21169 allocate(dxqwol(3,0:nres))
21171 !----------------------
21173 ! common /sbridge/ in io_common: read_bridge
21174 !el allocate((:),allocatable :: iss !(maxss)
21175 ! common /links/ in io_common: read_bridge
21176 !el real(kind=8),dimension(:),allocatable :: dhpb,forcon,dhpb1 !(maxdim) !el dhpb1 !!! nie używane
21177 !el integer,dimension(:),allocatable :: ihpb,jhpb,ibecarb !(maxdim) !el ibecarb !!! nie używane
21178 ! common /dyn_ssbond/
21179 ! and side-chain vectors in theta or phi.
21180 allocate(dyn_ssbond_ij(0:nres+4,0:nres+4))
21184 dyn_ssbond_ij(:,:)=1.0d300
21188 ! if (nss.gt.0) then
21189 allocate(idssb(maxdim),jdssb(maxdim))
21190 ! allocate(newihpb(nss),newjhpb(nss))
21193 allocate(ishield_list(-1:nres))
21194 allocate(shield_list(maxcontsshi,-1:nres))
21195 allocate(dyn_ss_mask(nres))
21196 allocate(fac_shield(-1:nres))
21197 allocate(enetube(nres*2))
21198 allocate(enecavtube(nres*2))
21201 dyn_ss_mask(:)=.false.
21202 !----------------------
21204 ! Parameters of the SCCOR term
21206 !el in io_conf: parmread
21207 ! allocate(v1sccor(maxterm_sccor,3,-ntyp:ntyp,-ntyp:ntyp))
21208 ! allocate(v2sccor(maxterm_sccor,3,-ntyp:ntyp,-ntyp:ntyp)) !(maxterm_sccor,3,-ntyp:ntyp,-ntyp:ntyp)
21209 ! allocate(v0sccor(maxterm_sccor,-ntyp:ntyp,-ntyp:ntyp)) !(maxterm_sccor,-ntyp:ntyp,-ntyp:ntyp)
21210 ! allocate(isccortyp(-ntyp:ntyp)) !(-ntyp:ntyp)
21211 ! allocate(nterm_sccor(-ntyp:ntyp,-ntyp:ntyp))
21212 ! allocate(nlor_sccor(-ntyp:ntyp,-ntyp:ntyp)) !(-ntyp:ntyp,-ntyp:ntyp)
21213 ! allocate(vlor1sccor(maxterm_sccor,20,20))
21214 ! allocate(vlor2sccor(maxterm_sccor,20,20))
21215 ! allocate(vlor3sccor(maxterm_sccor,20,20)) !(maxterm_sccor,20,20)
21217 allocate(gloc_sc(3,0:2*nres,0:10))
21218 !(3,0:maxres2,10)maxres2=2*maxres
21219 allocate(dcostau(3,3,3,2*nres))
21220 allocate(dsintau(3,3,3,2*nres))
21221 allocate(dtauangle(3,3,3,2*nres))
21222 allocate(dcosomicron(3,3,3,2*nres))
21223 allocate(domicron(3,3,3,2*nres))
21224 !(3,3,3,maxres2)maxres2=2*maxres
21225 !----------------------
21228 allocate(varall(maxvar))
21229 !(maxvar)(maxvar=6*maxres)
21230 allocate(mask_theta(nres))
21231 allocate(mask_phi(nres))
21232 allocate(mask_side(nres))
21234 !----------------------
21237 allocate(uy(3,nres))
21238 allocate(uz(3,nres))
21240 allocate(uygrad(3,3,2,nres))
21241 allocate(uzgrad(3,3,2,nres))
21243 ! allocateion of lists JPRDLA
21244 allocate(newcontlistppi(300*nres))
21245 allocate(newcontlistscpi(300*nres))
21246 allocate(newcontlisti(300*nres))
21247 allocate(newcontlistppj(300*nres))
21248 allocate(newcontlistscpj(300*nres))
21249 allocate(newcontlistj(300*nres))
21252 end subroutine alloc_ener_arrays
21253 !-----------------------------------------------------------------
21254 subroutine ebond_nucl(estr_nucl)
21256 !c Evaluate the energy of stretching of the CA-CA and CA-SC virtual bonds
21259 real(kind=8),dimension(3) :: u,ud
21260 real(kind=8) :: usum,uprod,uprod1,uprod2,usumsqder
21261 real(kind=8) :: estr_nucl,diff
21262 integer :: iti,i,j,k,nbi
21264 !C print *,"I enter ebond"
21266 write (iout,*) "ibondp_start,ibondp_end",&
21267 ibondp_nucl_start,ibondp_nucl_end
21268 do i=ibondp_nucl_start,ibondp_nucl_end
21269 if (itype(i-1,2).eq.ntyp1_molec(2) .or. &
21270 itype(i,2).eq.ntyp1_molec(2)) cycle
21271 ! estr1=estr1+gnmr1(vbld(i),-1.0d0,distchainmax)
21273 ! gradb(j,i-1)=gnmr1prim(vbld(i),-1.0d0,distchainmax)
21274 ! & *dc(j,i-1)/vbld(i)
21276 ! if (energy_dec) write(iout,*)
21277 ! & "estr1",i,vbld(i),distchainmax,
21278 ! & gnmr1(vbld(i),-1.0d0,distchainmax)
21280 diff = vbld(i)-vbldp0_nucl
21281 if(energy_dec)write(iout,*) "estr_nucl_bb" , i,vbld(i),&
21282 vbldp0_nucl,diff,AKP_nucl*diff*diff
21283 estr_nucl=estr_nucl+diff*diff
21284 ! print *,estr_nucl
21286 gradb_nucl(j,i-1)=AKP_nucl*diff*dc(j,i-1)/vbld(i)
21288 !c write (iout,'(i5,3f10.5)') i,(gradb(j,i-1),j=1,3)
21290 estr_nucl=0.5d0*AKP_nucl*estr_nucl
21291 ! print *,"partial sum", estr_nucl,AKP_nucl
21294 write (iout,*) "ibondp_start,ibondp_end",&
21295 ibond_nucl_start,ibond_nucl_end
21297 do i=ibond_nucl_start,ibond_nucl_end
21298 !C print *, "I am stuck",i
21300 if (iti.eq.ntyp1_molec(2)) cycle
21301 nbi=nbondterm_nucl(iti)
21304 diff=vbld(i+nres)-vbldsc0_nucl(1,iti)
21307 write (iout,*) "estr_nucl_sc", i,iti,vbld(i+nres),vbldsc0_nucl(1,iti),diff, &
21308 AKSC_nucl(1,iti),AKSC_nucl(1,iti)*diff*diff
21309 estr_nucl=estr_nucl+0.5d0*AKSC_nucl(1,iti)*diff*diff
21310 ! print *,estr_nucl
21312 gradbx_nucl(j,i)=AKSC_nucl(1,iti)*diff*dc(j,i+nres)/vbld(i+nres)
21316 diff=vbld(i+nres)-vbldsc0_nucl(j,iti)
21317 ud(j)=aksc_nucl(j,iti)*diff
21318 u(j)=abond0_nucl(j,iti)+0.5d0*ud(j)*diff
21332 uprod2=uprod2*u(k)*u(k)
21336 usumsqder=usumsqder+ud(j)*uprod2
21338 estr_nucl=estr_nucl+uprod/usum
21340 gradbx_nucl(j,i)=usumsqder/(usum*usum)*dc(j,i+nres)/vbld(i+nres)
21344 !C print *,"I am about to leave ebond"
21346 end subroutine ebond_nucl
21348 !-----------------------------------------------------------------------------
21349 subroutine ebend_nucl(etheta_nucl)
21350 real(kind=8),dimension(nntheterm_nucl+1) :: coskt,sinkt !mmaxtheterm
21351 real(kind=8),dimension(nsingle_nucl+1) :: cosph1,sinph1,cosph2,sinph2 !maxsingle
21352 real(kind=8),dimension(ndouble_nucl+1,ndouble_nucl+1) :: cosph1ph2,sinph1ph2 !maxdouble,maxdouble
21353 logical :: lprn=.false., lprn1=.false.
21354 !el local variables
21355 integer :: i,k,iblock,ityp1,ityp2,ityp3,l,m
21356 real(kind=8) :: dethetai,dephii,dephii1,theti2,phii,phii1,ethetai
21357 real(kind=8) :: aux,etheta_nucl,ccl,ssl,scl,csl,ethetacnstr
21358 ! local variables for constrains
21359 real(kind=8) :: difi,thetiii
21362 ! print *,"ithet_start",ithet_nucl_start," ithet_end",ithet_nucl_end,nres
21363 do i=ithet_nucl_start,ithet_nucl_end
21364 if ((itype(i-1,2).eq.ntyp1_molec(2)).or.&
21365 (itype(i-2,2).eq.ntyp1_molec(2)).or. &
21366 (itype(i,2).eq.ntyp1_molec(2))) cycle
21370 theti2=0.5d0*theta(i)
21371 ityp2=ithetyp_nucl(itype(i-1,2))
21372 do k=1,nntheterm_nucl
21373 coskt(k)=dcos(k*theti2)
21374 sinkt(k)=dsin(k*theti2)
21376 if (i.gt.3 .and. itype(i-2,2).ne.ntyp1_molec(2)) then
21379 if (phii.ne.phii) phii=150.0
21383 ityp1=ithetyp_nucl(itype(i-2,2))
21384 do k=1,nsingle_nucl
21385 cosph1(k)=dcos(k*phii)
21386 sinph1(k)=dsin(k*phii)
21390 ityp1=nthetyp_nucl+1
21391 do k=1,nsingle_nucl
21397 if (i.lt.nres .and. itype(i,2).ne.ntyp1_molec(2)) then
21400 if (phii1.ne.phii1) phii1=150.0
21401 phii1=pinorm(phii1)
21405 ityp3=ithetyp_nucl(itype(i,2))
21406 do k=1,nsingle_nucl
21407 cosph2(k)=dcos(k*phii1)
21408 sinph2(k)=dsin(k*phii1)
21412 ityp3=nthetyp_nucl+1
21413 do k=1,nsingle_nucl
21418 ethetai=aa0thet_nucl(ityp1,ityp2,ityp3)
21419 do k=1,ndouble_nucl
21421 ccl=cosph1(l)*cosph2(k-l)
21422 ssl=sinph1(l)*sinph2(k-l)
21423 scl=sinph1(l)*cosph2(k-l)
21424 csl=cosph1(l)*sinph2(k-l)
21425 cosph1ph2(l,k)=ccl-ssl
21426 cosph1ph2(k,l)=ccl+ssl
21427 sinph1ph2(l,k)=scl+csl
21428 sinph1ph2(k,l)=scl-csl
21432 write (iout,*) "i",i," ityp1",ityp1," ityp2",ityp2,&
21433 " ityp3",ityp3," theti2",theti2," phii",phii," phii1",phii1
21434 write (iout,*) "coskt and sinkt",nntheterm_nucl
21435 do k=1,nntheterm_nucl
21436 write (iout,*) k,coskt(k),sinkt(k)
21439 do k=1,ntheterm_nucl
21440 ethetai=ethetai+aathet_nucl(k,ityp1,ityp2,ityp3)*sinkt(k)
21441 dethetai=dethetai+0.5d0*k*aathet_nucl(k,ityp1,ityp2,ityp3)&
21444 write (iout,*) "k",k," aathet",aathet_nucl(k,ityp1,ityp2,ityp3),&
21448 write (iout,*) "cosph and sinph"
21449 do k=1,nsingle_nucl
21450 write (iout,*) k,cosph1(k),sinph1(k),cosph2(k),sinph2(k)
21452 write (iout,*) "cosph1ph2 and sinph2ph2"
21453 do k=2,ndouble_nucl
21455 write (iout,*) l,k,cosph1ph2(l,k),cosph1ph2(k,l),&
21456 sinph1ph2(l,k),sinph1ph2(k,l)
21459 write(iout,*) "ethetai",ethetai
21461 do m=1,ntheterm2_nucl
21462 do k=1,nsingle_nucl
21463 aux=bbthet_nucl(k,m,ityp1,ityp2,ityp3)*cosph1(k)&
21464 +ccthet_nucl(k,m,ityp1,ityp2,ityp3)*sinph1(k)&
21465 +ddthet_nucl(k,m,ityp1,ityp2,ityp3)*cosph2(k)&
21466 +eethet_nucl(k,m,ityp1,ityp2,ityp3)*sinph2(k)
21467 ethetai=ethetai+sinkt(m)*aux
21468 dethetai=dethetai+0.5d0*m*aux*coskt(m)
21469 dephii=dephii+k*sinkt(m)*(&
21470 ccthet_nucl(k,m,ityp1,ityp2,ityp3)*cosph1(k)-&
21471 bbthet_nucl(k,m,ityp1,ityp2,ityp3)*sinph1(k))
21472 dephii1=dephii1+k*sinkt(m)*(&
21473 eethet_nucl(k,m,ityp1,ityp2,ityp3)*cosph2(k)-&
21474 ddthet_nucl(k,m,ityp1,ityp2,ityp3)*sinph2(k))
21476 write (iout,*) "m",m," k",k," bbthet",&
21477 bbthet_nucl(k,m,ityp1,ityp2,ityp3)," ccthet",&
21478 ccthet_nucl(k,m,ityp1,ityp2,ityp3)," ddthet",&
21479 ddthet_nucl(k,m,ityp1,ityp2,ityp3)," eethet",&
21480 eethet_nucl(k,m,ityp1,ityp2,ityp3)," ethetai",ethetai
21484 write(iout,*) "ethetai",ethetai
21485 do m=1,ntheterm3_nucl
21486 do k=2,ndouble_nucl
21488 aux=ffthet_nucl(l,k,m,ityp1,ityp2,ityp3)*cosph1ph2(l,k)+&
21489 ffthet_nucl(k,l,m,ityp1,ityp2,ityp3)*cosph1ph2(k,l)+&
21490 ggthet_nucl(l,k,m,ityp1,ityp2,ityp3)*sinph1ph2(l,k)+&
21491 ggthet_nucl(k,l,m,ityp1,ityp2,ityp3)*sinph1ph2(k,l)
21492 ethetai=ethetai+sinkt(m)*aux
21493 dethetai=dethetai+0.5d0*m*coskt(m)*aux
21494 dephii=dephii+l*sinkt(m)*(&
21495 -ffthet_nucl(l,k,m,ityp1,ityp2,ityp3)*sinph1ph2(l,k)-&
21496 ffthet_nucl(k,l,m,ityp1,ityp2,ityp3)*sinph1ph2(k,l)+&
21497 ggthet_nucl(l,k,m,ityp1,ityp2,ityp3)*cosph1ph2(l,k)+&
21498 ggthet_nucl(k,l,m,ityp1,ityp2,ityp3)*cosph1ph2(k,l))
21499 dephii1=dephii1+(k-l)*sinkt(m)*( &
21500 -ffthet_nucl(l,k,m,ityp1,ityp2,ityp3)*sinph1ph2(l,k)+&
21501 ffthet_nucl(k,l,m,ityp1,ityp2,ityp3)*sinph1ph2(k,l)+&
21502 ggthet_nucl(l,k,m,ityp1,ityp2,ityp3)*cosph1ph2(l,k)-&
21503 ggthet_nucl(k,l,m,ityp1,ityp2,ityp3)*cosph1ph2(k,l))
21505 write (iout,*) "m",m," k",k," l",l," ffthet", &
21506 ffthet_nucl(l,k,m,ityp1,ityp2,ityp3), &
21507 ffthet_nucl(k,l,m,ityp1,ityp2,ityp3)," ggthet",&
21508 ggthet_nucl(l,k,m,ityp1,ityp2,ityp3),&
21509 ggthet_nucl(k,l,m,ityp1,ityp2,ityp3)," ethetai",ethetai
21510 write (iout,*) cosph1ph2(l,k)*sinkt(m), &
21511 cosph1ph2(k,l)*sinkt(m),&
21512 sinph1ph2(l,k)*sinkt(m),sinph1ph2(k,l)*sinkt(m)
21518 if (lprn1) write (iout,'(i2,3f8.1,9h ethetai ,f10.5)') &
21519 i,theta(i)*rad2deg,phii*rad2deg, &
21520 phii1*rad2deg,ethetai
21521 etheta_nucl=etheta_nucl+ethetai
21522 ! print *,i,"partial sum",etheta_nucl
21523 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang_nucl*dephii
21524 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang_nucl*dephii1
21525 gloc(nphi+i-2,icg)=wang_nucl*dethetai
21528 end subroutine ebend_nucl
21529 !----------------------------------------------------
21530 subroutine etor_nucl(etors_nucl)
21531 ! implicit real*8 (a-h,o-z)
21532 ! include 'DIMENSIONS'
21533 ! include 'COMMON.VAR'
21534 ! include 'COMMON.GEO'
21535 ! include 'COMMON.LOCAL'
21536 ! include 'COMMON.TORSION'
21537 ! include 'COMMON.INTERACT'
21538 ! include 'COMMON.DERIV'
21539 ! include 'COMMON.CHAIN'
21540 ! include 'COMMON.NAMES'
21541 ! include 'COMMON.IOUNITS'
21542 ! include 'COMMON.FFIELD'
21543 ! include 'COMMON.TORCNSTR'
21544 ! include 'COMMON.CONTROL'
21545 real(kind=8) :: etors_nucl,edihcnstr
21547 !el local variables
21548 integer :: i,j,iblock,itori,itori1
21549 real(kind=8) :: phii,gloci,v1ij,v2ij,cosphi,sinphi,&
21550 vl1ij,vl2ij,vl3ij,pom1,difi,etors_ii,pom
21551 ! Set lprn=.true. for debugging
21555 ! print *,"iphi_nucl_start/end", iphi_nucl_start,iphi_nucl_end
21556 do i=iphi_nucl_start,iphi_nucl_end
21557 if (itype(i-2,2).eq.ntyp1_molec(2) .or. itype(i-1,2).eq.ntyp1_molec(2) &
21558 .or. itype(i-3,2).eq.ntyp1_molec(2) &
21559 .or. itype(i,2).eq.ntyp1_molec(2)) cycle
21561 itori=itortyp_nucl(itype(i-2,2))
21562 itori1=itortyp_nucl(itype(i-1,2))
21564 ! print *,i,itori,itori1
21566 !C Regular cosine and sine terms
21567 do j=1,nterm_nucl(itori,itori1)
21568 v1ij=v1_nucl(j,itori,itori1)
21569 v2ij=v2_nucl(j,itori,itori1)
21570 cosphi=dcos(j*phii)
21571 sinphi=dsin(j*phii)
21572 etors_nucl=etors_nucl+v1ij*cosphi+v2ij*sinphi
21573 if (energy_dec) etors_ii=etors_ii+&
21574 v1ij*cosphi+v2ij*sinphi
21575 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
21579 !C E = SUM ----------------------------------- - v1
21580 !C [v2 cos(phi/2)+v3 sin(phi/2)]^2 + 1
21582 cosphi=dcos(0.5d0*phii)
21583 sinphi=dsin(0.5d0*phii)
21584 do j=1,nlor_nucl(itori,itori1)
21585 vl1ij=vlor1_nucl(j,itori,itori1)
21586 vl2ij=vlor2_nucl(j,itori,itori1)
21587 vl3ij=vlor3_nucl(j,itori,itori1)
21588 pom=vl2ij*cosphi+vl3ij*sinphi
21589 pom1=1.0d0/(pom*pom+1.0d0)
21590 etors_nucl=etors_nucl+vl1ij*pom1
21591 if (energy_dec) etors_ii=etors_ii+ &
21594 gloci=gloci+vl1ij*(vl3ij*cosphi-vl2ij*sinphi)*pom
21596 !C Subtract the constant term
21597 etors_nucl=etors_nucl-v0_nucl(itori,itori1)
21598 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
21599 'etor',i,etors_ii-v0_nucl(itori,itori1)
21601 write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)') &
21602 restyp(itype(i-2,2),2),i-2,restyp(itype(i-1,2),2),i-1,itori,itori1, &
21603 (v1_nucl(j,itori,itori1),j=1,6),(v2_nucl(j,itori,itori1),j=1,6)
21604 gloc(i-3,icg)=gloc(i-3,icg)+wtor_nucl*gloci
21605 !c write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
21608 end subroutine etor_nucl
21609 !------------------------------------------------------------
21610 subroutine epp_nucl_sub(evdw1,ees)
21612 !C This subroutine calculates the average interaction energy and its gradient
21613 !C in the virtual-bond vectors between non-adjacent peptide groups, based on
21614 !C the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
21615 !C The potential depends both on the distance of peptide-group centers and on
21616 !C the orientation of the CA-CA virtual bonds.
21618 integer :: i,j,k,iteli,itelj,num_conti,isubchap,ind
21619 real(kind=8) :: dxi,dyi,dzi,dxj,dyj,dzj,aaa,bbbi,sslipi,ssgradlipi, &
21620 sslipj,ssgradlipj,faclipij2
21621 real(kind=8) :: xj,yj,zj,rij,rrmij,sss,r3ij,r6ij,evdw1,&
21622 dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
21623 dx_normj,dy_normj,dz_normj,rmij,ev1,ev2,evdwij,facvdw
21624 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
21625 dist_temp, dist_init,sss_grad,fac,evdw1ij
21626 integer xshift,yshift,zshift
21627 real(kind=8),dimension(3):: ggg,gggp,gggm,erij
21628 real(kind=8) :: ees,eesij
21629 !c 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
21630 real(kind=8) scal_el /0.5d0/
21636 !c Loop over all pairs of interacting peptide groups except i,i+2 and i,i+3
21638 ! print *,"iatel_s_nucl,iatel_e_nucl",iatel_s_nucl,iatel_e_nucl
21639 do i=iatel_s_nucl,iatel_e_nucl
21640 if (itype(i,2).eq.ntyp1_molec(2) .or. itype(i+1,2).eq.ntyp1_molec(2)) cycle
21644 dx_normi=dc_norm(1,i)
21645 dy_normi=dc_norm(2,i)
21646 dz_normi=dc_norm(3,i)
21647 xmedi=c(1,i)+0.5d0*dxi
21648 ymedi=c(2,i)+0.5d0*dyi
21649 zmedi=c(3,i)+0.5d0*dzi
21650 call to_box(xmedi,ymedi,zmedi)
21651 call lipid_layer(xmedi,ymedi,zmedi,sslipi,ssgradlipi)
21653 do j=ielstart_nucl(i),ielend_nucl(i)
21654 if (itype(j,2).eq.ntyp1_molec(2) .or. itype(j+1,2).eq.ntyp1_molec(2)) cycle
21659 ! xj=c(1,j)+0.5D0*dxj-xmedi
21660 ! yj=c(2,j)+0.5D0*dyj-ymedi
21661 ! zj=c(3,j)+0.5D0*dzj-zmedi
21662 xj=c(1,j)+0.5D0*dxj
21663 yj=c(2,j)+0.5D0*dyj
21664 zj=c(3,j)+0.5D0*dzj
21665 call to_box(xj,yj,zj)
21666 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
21667 faclipij2=(sslipi+sslipj)/2.0d0*lipscale**2+1.0d0
21668 xj=boxshift(xj-xmedi,boxxsize)
21669 yj=boxshift(yj-ymedi,boxysize)
21670 zj=boxshift(zj-zmedi,boxzsize)
21671 rij=xj*xj+yj*yj+zj*zj
21672 !c write (2,*)"ij",i,j," r0pp",r0pp," rij",rij," epspp",epspp
21673 fac=(r0pp**2/rij)**3
21677 fac=(-ev1-evdw1ij)/rij
21678 ! write (2,*)"fac",fac," ev1",ev1," ev2",ev2," evdw1ij",evdw1ij
21679 if (energy_dec) write(iout,'(2i5,a9,f10.4)') i,j,"evdw1ij",evdw1ij
21680 evdw1=evdw1+evdw1ij
21682 !C Calculate contributions to the Cartesian gradient.
21688 gvdwpp_nucl(k,i)=gvdwpp_nucl(k,i)-ggg(k)
21689 gvdwpp_nucl(k,j)=gvdwpp_nucl(k,j)+ggg(k)
21691 !c phoshate-phosphate electrostatic interactions
21694 eesij=dexp(-BEES*rij)*fac
21695 ! write (2,*)"fac",fac," eesijpp",eesij
21696 if (energy_dec) write(iout,'(2i5,a9,f10.4)') i,j,"eesijpp",eesij
21699 fac=-(fac+BEES)*eesij*fac
21703 !c write(2,*) "ggg",i,j,ggg(1),ggg(2),ggg(3)
21704 !c write(2,*) "gelpp",i,(gelpp(k,i),k=1,3)
21705 !c write(2,*) "gelpp",j,(gelpp(k,j),k=1,3)
21707 gelpp(k,i)=gelpp(k,i)-ggg(k)
21708 gelpp(k,j)=gelpp(k,j)+ggg(k)
21715 !c write (2,*) "i",i," gelpp",(gelpp(k,i),k=1,3)
21717 gvdwpp_nucl(k,i)=6*gvdwpp_nucl(k,i)
21718 !c gelpp(k,i)=332.0d0*gelpp(k,i)
21719 gelpp(k,i)=AEES*gelpp(k,i)
21721 !c write (2,*) "i",i," gelpp",(gelpp(k,i),k=1,3)
21723 !c write (2,*) "total EES",ees
21725 end subroutine epp_nucl_sub
21726 !---------------------------------------------------------------------
21727 subroutine epsb(evdwpsb,eelpsb)
21730 !C This subroutine calculates the excluded-volume interaction energy between
21731 !C peptide-group centers and side chains and its gradient in virtual-bond and
21732 !C side-chain vectors.
21734 real(kind=8),dimension(3):: ggg
21735 integer :: i,iint,j,k,iteli,itypj,subchap
21736 real(kind=8) :: evdw2,evdw2_14,xi,yi,zi,xj,yj,zj,rrij,fac,&
21737 e1,e2,evdwij,rij,evdwpsb,eelpsb
21738 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
21739 dist_temp, dist_init
21740 integer xshift,yshift,zshift
21742 !cd print '(a)','Enter ESCP'
21743 !cd write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
21746 ! print *,"iatscp_s_nucl,iatscp_e_nucl",iatscp_s_nucl,iatscp_e_nucl
21747 do i=iatscp_s_nucl,iatscp_e_nucl
21748 if (itype(i,2).eq.ntyp1_molec(2) &
21749 .or. itype(i+1,2).eq.ntyp1_molec(2)) cycle
21750 xi=0.5D0*(c(1,i)+c(1,i+1))
21751 yi=0.5D0*(c(2,i)+c(2,i+1))
21752 zi=0.5D0*(c(3,i)+c(3,i+1))
21753 call to_box(xi,yi,zi)
21755 do iint=1,nscp_gr_nucl(i)
21757 do j=iscpstart_nucl(i,iint),iscpend_nucl(i,iint)
21759 if (itypj.eq.ntyp1_molec(2)) cycle
21760 !C Uncomment following three lines for SC-p interactions
21761 !c xj=c(1,nres+j)-xi
21762 !c yj=c(2,nres+j)-yi
21763 !c zj=c(3,nres+j)-zi
21764 !C Uncomment following three lines for Ca-p interactions
21771 call to_box(xj,yj,zj)
21772 xj=boxshift(xj-xi,boxxsize)
21773 yj=boxshift(yj-yi,boxysize)
21774 zj=boxshift(zj-zi,boxzsize)
21776 dist_init=xj**2+yj**2+zj**2
21778 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
21780 e1=fac*fac*aad_nucl(itypj)
21781 e2=fac*bad_nucl(itypj)
21782 if (iabs(j-i) .le. 2) then
21787 evdwpsb=evdwpsb+evdwij
21788 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a4)') &
21789 'evdw2',i,j,evdwij,"tu4"
21791 !C Calculate contributions to the gradient in the virtual-bond and SC vectors.
21793 fac=-(evdwij+e1)*rrij
21798 gvdwpsb1(k,i)=gvdwpsb1(k,i)-ggg(k)
21799 gvdwpsb(k,j)=gvdwpsb(k,j)+ggg(k)
21807 gvdwpsb(j,i)=expon*gvdwpsb(j,i)
21808 gvdwpsb1(j,i)=expon*gvdwpsb1(j,i)
21812 end subroutine epsb
21814 !------------------------------------------------------
21815 subroutine esb_gb(evdwsb,eelsb)
21818 integer :: iint,itypi,itypi1,itypj,subchap,num_conti2
21819 real(kind=8) :: xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
21820 real(kind=8) :: evdw,sig0iji,evdwsb,eelsb,ecorr,eelij
21821 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
21822 dist_temp, dist_init,aa,bb,faclip,sig0ij
21831 ! print *,"iastsc_nucl",iatsc_s_nucl,iatsc_e_nucl
21832 do i=iatsc_s_nucl,iatsc_e_nucl
21836 ! PRINT *,"I=",i,itypi
21837 if (itypi.eq.ntyp1_molec(2)) cycle
21838 itypi1=itype(i+1,2)
21842 call to_box(xi,yi,zi)
21843 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
21844 dxi=dc_norm(1,nres+i)
21845 dyi=dc_norm(2,nres+i)
21846 dzi=dc_norm(3,nres+i)
21847 dsci_inv=vbld_inv(i+nres)
21849 !C Calculate SC interaction energy.
21851 do iint=1,nint_gr_nucl(i)
21852 ! print *,"tu?",i,istart_nucl(i,iint),iend_nucl(i,iint)
21853 do j=istart_nucl(i,iint),iend_nucl(i,iint)
21857 if (itypj.eq.ntyp1_molec(2)) cycle
21858 dscj_inv=vbld_inv(j+nres)
21859 sig0ij=sigma_nucl(itypi,itypj)
21860 chi1=chi_nucl(itypi,itypj)
21861 chi2=chi_nucl(itypj,itypi)
21863 chip1=chip_nucl(itypi,itypj)
21864 chip2=chip_nucl(itypj,itypi)
21866 ! xj=c(1,nres+j)-xi
21867 ! yj=c(2,nres+j)-yi
21868 ! zj=c(3,nres+j)-zi
21872 call to_box(xj,yj,zj)
21873 ! call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
21874 ! aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
21875 ! +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
21876 ! bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
21877 ! +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
21878 xj=boxshift(xj-xi,boxxsize)
21879 yj=boxshift(yj-yi,boxysize)
21880 zj=boxshift(zj-zi,boxzsize)
21882 dxj=dc_norm(1,nres+j)
21883 dyj=dc_norm(2,nres+j)
21884 dzj=dc_norm(3,nres+j)
21885 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
21887 !C Calculate angle-dependent terms of energy and contributions to their
21892 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
21893 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
21894 om12=dxi*dxj+dyi*dyj+dzi*dzj
21895 call sc_angular_nucl
21897 sig=sig0ij*dsqrt(sigsq)
21898 rij_shift=1.0D0/rij-sig+sig0ij
21899 ! print *,rij_shift,"rij_shift"
21900 !c write (2,*) " rij",1.0D0/rij," sig",sig," sig0ij",sig0ij,
21901 !c & " rij_shift",rij_shift
21902 if (rij_shift.le.0.0D0) then
21907 !c---------------------------------------------------------------
21908 rij_shift=1.0D0/rij_shift
21909 fac=rij_shift**expon
21910 e1=fac*fac*aa_nucl(itypi,itypj)
21911 e2=fac*bb_nucl(itypi,itypj)
21912 evdwij=eps1*eps2rt*(e1+e2)
21913 !c write (2,*) "eps1",eps1," eps2rt",eps2rt,
21914 !c & " e1",e1," e2",e2," evdwij",evdwij
21916 evdwij=evdwij*eps2rt
21917 evdwsb=evdwsb+evdwij
21919 sigm=dabs(aa_nucl(itypi,itypj)/bb_nucl(itypi,itypj))**(1.0D0/6.0D0)
21920 epsi=bb_nucl(itypi,itypj)**2/aa_nucl(itypi,itypj)
21921 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
21922 restyp(itypi,2),i,restyp(itypj,2),j, &
21923 epsi,sigm,chi1,chi2,chip1,chip2, &
21924 eps1,eps2rt**2,sig,sig0ij, &
21925 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
21927 write (iout,*) "aa",aa_nucl(itypi,itypj)," bb",bb_nucl(itypi,itypj)
21930 if (energy_dec) write (iout,'(a6,2i5,e15.3,a4)') &
21931 'evdw',i,j,evdwij,"tu3"
21934 !C Calculate gradient components.
21935 e1=e1*eps1*eps2rt**2
21936 fac=-expon*(e1+evdwij)*rij_shift
21940 !C Calculate the radial part of the gradient
21944 !C Calculate angular part of the gradient.
21946 call eelsbij(eelij,num_conti2)
21947 if (energy_dec .and. &
21948 (j.eq.i+1.or.j.eq.nres-i+1.or.j.eq.nres-i.or.j.eq.nres-i+2)) &
21949 write (istat,'(e14.5)') evdwij
21953 num_cont_hb(i)=num_conti2
21955 !c write (iout,*) "Number of loop steps in EGB:",ind
21956 !cccc energy_dec=.false.
21958 end subroutine esb_gb
21959 !-------------------------------------------------------------------------------
21960 subroutine eelsbij(eesij,num_conti2)
21963 real(kind=8),dimension(3) :: ggg,gggp,gggm,dcosb,dcosg
21964 real(kind=8),dimension(3,3) :: erder,uryg,urzg,vryg,vrzg
21965 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
21966 dist_temp, dist_init,rlocshield,fracinbuf
21967 integer xshift,yshift,zshift,ilist,iresshield,num_conti2
21969 !c 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
21970 real(kind=8) scal_el /0.5d0/
21971 integer :: iteli,itelj,kkk,kkll,m,isubchap
21972 real(kind=8) :: ael6i,rrmij,rmij,r0ij,fcont,fprimcont,ees0tmp,facfac
21973 real(kind=8) :: ees,evdw1,eel_loc,aaa,bbb,ael3i,ael63i,ael32i
21974 real(kind=8) :: dx_normj,dy_normj,dz_normj,&
21975 r3ij,r6ij,cosa,cosb,cosg,fac,ev1,ev2,fac3,fac4,fac5,fac6,&
21976 el1,el2,el3,el4,eesij,ees0ij,facvdw,facel,fac1,ecosa,&
21977 ecosb,ecosg,ury,urz,vry,vrz,facr,a22der,a23der,a32der,&
21978 a33der,eel_loc_ij,cosa4,wij,cosbg1,cosbg2,ees0pij,&
21979 ees0pij1,ees0mij,ees0mij1,fac3p,ees0mijp,ees0pijp,&
21980 ecosa1,ecosb1,ecosg1,ecosa2,ecosb2,ecosg2,ecosap,ecosbp,&
21981 ecosgp,ecosam,ecosbm,ecosgm,ghalf,itypi,itypj
21985 ! print *,i,j,itypi,itypj,istype(i),istype(j),"????"
21986 ael6i=ael6_nucl(itypi,itypj)
21987 ael3i=ael3_nucl(itypi,itypj)
21988 ael63i=ael63_nucl(itypi,itypj)
21989 ael32i=ael32_nucl(itypi,itypj)
21990 !c write (iout,*) "eelecij",i,j,itype(i),itype(j),
21991 !c & ael6i,ael3i,ael63i,al32i,rij,rrij
21995 dx_normi=dc_norm(1,i+nres)
21996 dy_normi=dc_norm(2,i+nres)
21997 dz_normi=dc_norm(3,i+nres)
21998 dx_normj=dc_norm(1,j+nres)
21999 dy_normj=dc_norm(2,j+nres)
22000 dz_normj=dc_norm(3,j+nres)
22001 !c xj=c(1,j)+0.5D0*dxj-xmedi
22002 !c yj=c(2,j)+0.5D0*dyj-ymedi
22003 !c zj=c(3,j)+0.5D0*dzj-zmedi
22004 if (ipot_nucl.ne.2) then
22005 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
22006 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
22007 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
22015 fac=cosa-3.0D0*cosb*cosg
22017 fac1=3.0d0*(cosb*cosb+cosg*cosg)
22022 !c write (iout,*) "r3ij",r3ij," r6ij",r6ij," fac",fac," fac1",fac1,
22023 !c & " fac2",fac2," fac3",fac3," fac4",fac4," fac5",fac5," fac6",fac6
22024 el1=fac3*(4.0D0+facfac-fac1)
22026 el3=fac5*(2.0d0-2.0d0*facfac+fac1)
22028 eesij=el1+el2+el3+el4
22029 !C 12/26/95 - for the evaluation of multi-body H-bonding interactions
22030 ees0ij=4.0D0+facfac-fac1
22032 if (energy_dec) then
22033 if(j.eq.i+1.or.j.eq.nres-i+1.or.j.eq.nres-i.or.j.eq.nres-i+2) &
22034 write (istat,'(2a1,i4,1x,2a1,i4,4f10.5,3e12.5,$)') &
22035 sugartyp(istype(i)),restyp(itypi,2),i,sugartyp(istype(j)),&
22036 restyp(itypj,2),j,1.0d0/rij,cosa,cosb,cosg,fac*r3ij, &
22037 (4.0D0+facfac-fac1)*r6ij,(2.0d0-2.0d0*facfac+fac1)*r6ij
22038 write (iout,'(a6,2i5,e15.3)') 'ees',i,j,eesij
22042 !C Calculate contributions to the Cartesian gradient.
22044 facel=-3.0d0*rrij*(eesij+el1+el3+el4)
22050 !* Radial derivatives. First process both termini of the fragment (i,j)
22056 gelsbc(k,j)=gelsbc(k,j)+ggg(k)
22057 gelsbc(k,i)=gelsbc(k,i)-ggg(k)
22058 gelsbx(k,j)=gelsbx(k,j)+ggg(k)
22059 gelsbx(k,i)=gelsbx(k,i)-ggg(k)
22064 ecosa=2.0D0*fac3*fac1+fac4+(-4.0d0*fac5+2.0d0*fac6)*fac1
22069 ecosb=fac3*(fac1*cosg+cosb)+cosg*fac4+(cosb+2*fac1*cosg)*fac5+&
22071 ecosg=fac3*(fac1*cosb+cosg)+cosb*fac4+(cosg+2*fac1*cosb)*fac5+&
22074 dcosb(k)=rij*(dc_norm(k,i+nres)-erij(k)*cosb)
22075 dcosg(k)=rij*(dc_norm(k,j+nres)-erij(k)*cosg)
22078 ggg(k)=ecosb*dcosb(k)+ecosg*dcosg(k)
22081 gelsbx(k,i)=gelsbx(k,i)-ggg(k) &
22082 +(ecosa*(dc_norm(k,j+nres)-cosa*dc_norm(k,i+nres))&
22083 + ecosb*(erij(k)-cosb*dc_norm(k,i+nres)))*vbld_inv(i+nres)
22084 gelsbx(k,j)=gelsbx(k,j)+ggg(k) &
22085 +(ecosa*(dc_norm(k,i+nres)-cosa*dc_norm(k,j+nres))&
22086 + ecosg*(erij(k)-cosg*dc_norm(k,j+nres)))*vbld_inv(j+nres)
22087 gelsbc(k,j)=gelsbc(k,j)+ggg(k)
22088 gelsbc(k,i)=gelsbc(k,i)-ggg(k)
22090 ! IF ( (wcorr_nucl.gt.0.0d0.or.wcorr3_nucl.gt.0.0d0) .and.
22091 IF ( j.gt.i+1 .and.&
22092 num_conti.le.maxcont) THEN
22094 !C Calculate the contact function. The ith column of the array JCONT will
22095 !C contain the numbers of atoms that make contacts with the atom I (of numbers
22096 !C greater than I). The arrays FACONT and GACONT will contain the values of
22097 !C the contact function and its derivative.
22098 r0ij=2.20D0*sigma_nucl(itypi,itypj)
22099 !c write (2,*) "ij",i,j," rij",1.0d0/rij," r0ij",r0ij
22100 call gcont(rij,r0ij,1.0D0,0.2d0/r0ij,fcont,fprimcont)
22101 !c write (2,*) "fcont",fcont
22102 if (fcont.gt.0.0D0) then
22103 num_conti=num_conti+1
22104 num_conti2=num_conti2+1
22106 if (num_conti.gt.maxconts) then
22107 write (iout,*) 'WARNING - max. # of contacts exceeded;',&
22108 ' will skip next contacts for this conf.',maxconts
22110 jcont_hb(num_conti,i)=j
22111 !c write (iout,*) "num_conti",num_conti,
22112 !c & " jcont_hb",jcont_hb(num_conti,i)
22113 !C Calculate contact energies
22115 wij=cosa-3.0D0*cosb*cosg
22118 fac3=dsqrt(-ael6i)*r3ij
22119 !c write (2,*) "ael6i",ael6i," r3ij",r3ij," fac3",fac3
22120 ees0tmp=4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1
22121 if (ees0tmp.gt.0) then
22122 ees0pij=dsqrt(ees0tmp)
22126 ees0tmp=4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2
22127 if (ees0tmp.gt.0) then
22128 ees0mij=dsqrt(ees0tmp)
22132 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij)
22133 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij)
22134 !c write (iout,*) "i",i," j",j,
22135 !c & " ees0m",ees0m(num_conti,i)," ees0p",ees0p(num_conti,i)
22136 ees0pij1=fac3/ees0pij
22137 ees0mij1=fac3/ees0mij
22138 fac3p=-3.0D0*fac3*rrij
22139 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
22140 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
22141 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
22142 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
22143 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
22144 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
22145 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
22146 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
22147 ecosap=ecosa1+ecosa2
22148 ecosbp=ecosb1+ecosb2
22149 ecosgp=ecosg1+ecosg2
22150 ecosam=ecosa1-ecosa2
22151 ecosbm=ecosb1-ecosb2
22152 ecosgm=ecosg1-ecosg2
22154 facont_hb(num_conti,i)=fcont
22155 fprimcont=fprimcont/rij
22157 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
22158 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
22160 gggp(1)=gggp(1)+ees0pijp*xj
22161 gggp(2)=gggp(2)+ees0pijp*yj
22162 gggp(3)=gggp(3)+ees0pijp*zj
22163 gggm(1)=gggm(1)+ees0mijp*xj
22164 gggm(2)=gggm(2)+ees0mijp*yj
22165 gggm(3)=gggm(3)+ees0mijp*zj
22166 !C Derivatives due to the contact function
22167 gacont_hbr(1,num_conti,i)=fprimcont*xj
22168 gacont_hbr(2,num_conti,i)=fprimcont*yj
22169 gacont_hbr(3,num_conti,i)=fprimcont*zj
22172 !c Gradient of the correlation terms
22174 gacontp_hb1(k,num_conti,i)= &
22175 (ecosap*(dc_norm(k,j+nres)-cosa*dc_norm(k,i+nres)) &
22176 + ecosbp*(erij(k)-cosb*dc_norm(k,i+nres)))*vbld_inv(i+nres)
22177 gacontp_hb2(k,num_conti,i)= &
22178 (ecosap*(dc_norm(k,i+nres)-cosa*dc_norm(k,j+nres)) &
22179 + ecosgp*(erij(k)-cosg*dc_norm(k,j+nres)))*vbld_inv(j+nres)
22180 gacontp_hb3(k,num_conti,i)=gggp(k)
22181 gacontm_hb1(k,num_conti,i)= &
22182 (ecosam*(dc_norm(k,j+nres)-cosa*dc_norm(k,i+nres)) &
22183 + ecosbm*(erij(k)-cosb*dc_norm(k,i+nres)))*vbld_inv(i+nres)
22184 gacontm_hb2(k,num_conti,i)= &
22185 (ecosam*(dc_norm(k,i+nres)-cosa*dc_norm(k,j+nres))&
22186 + ecosgm*(erij(k)-cosg*dc_norm(k,j+nres)))*vbld_inv(j+nres)
22187 gacontm_hb3(k,num_conti,i)=gggm(k)
22193 end subroutine eelsbij
22194 !------------------------------------------------------------------
22195 subroutine sc_grad_nucl
22198 real(kind=8),dimension(3) :: dcosom1,dcosom2
22199 eom1=eps2der*eps2rt_om1+sigder*sigsq_om1
22200 eom2=eps2der*eps2rt_om2+sigder*sigsq_om2
22201 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12+sigder*sigsq_om12
22203 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
22204 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
22207 gg(k)=gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
22210 gvdwsbx(k,i)=gvdwsbx(k,i)-gg(k) &
22211 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))&
22212 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
22213 gvdwsbx(k,j)=gvdwsbx(k,j)+gg(k) &
22214 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
22215 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
22218 !C Calculate the components of the gradient in DC and X
22221 gvdwsbc(l,i)=gvdwsbc(l,i)-gg(l)
22222 gvdwsbc(l,j)=gvdwsbc(l,j)+gg(l)
22225 end subroutine sc_grad_nucl
22226 !-----------------------------------------------------------------------
22227 subroutine esb(esbloc)
22228 !C Calculate the local energy of a side chain and its derivatives in the
22229 !C corresponding virtual-bond valence angles THETA and the spherical angles
22230 !C ALPHA and OMEGA derived from AM1 all-atom calculations.
22231 !C added by Urszula Kozlowska. 07/11/2007
22233 real(kind=8),dimension(3):: x_prime,y_prime,z_prime
22234 real(kind=8),dimension(9):: x
22235 real(kind=8) :: sumene,dsc_i,dp2_i,xx,yy,zz,sumene1, &
22236 sumene2,sumene3,sumene4,s1,s1_6,s2,s2_6,&
22237 de_dxx,de_dyy,de_dzz,de_dt,s1_t,s1_6_t,s2_t,s2_6_t
22238 real(kind=8),dimension(3):: dXX_Ci1,dYY_Ci1,dZZ_Ci1,dXX_Ci,&
22239 dYY_Ci,dZZ_Ci,dXX_XYZ,dYY_XYZ,dZZ_XYZ,dt_dCi,dt_dCi1
22240 real(kind=8) :: esbloc,delta,cosfac2,cosfac,sinfac2,sinfac,de_dtt,&
22241 cossc,cossc1,cosfac2xx,sinfac2yy,pom1,pom
22242 integer::it,nlobit,i,j,k
22243 ! common /sccalc/ time11,time12,time112,theti,it,nlobit
22246 do i=loc_start_nucl,loc_end_nucl
22247 if (itype(i,2).eq.ntyp1_molec(2)) cycle
22248 costtab(i+1) =dcos(theta(i+1))
22249 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
22250 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
22251 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
22252 cosfac2=0.5d0/(1.0d0+costtab(i+1))
22253 cosfac=dsqrt(cosfac2)
22254 sinfac2=0.5d0/(1.0d0-costtab(i+1))
22255 sinfac=dsqrt(sinfac2)
22257 if (it.eq.10) goto 1
22260 !C Compute the axes of tghe local cartesian coordinates system; store in
22261 !c x_prime, y_prime and z_prime
22268 !C write(2,*) "dc_norm", dc_norm(1,i+nres),dc_norm(2,i+nres),
22269 !C & dc_norm(3,i+nres)
22271 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
22272 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
22275 z_prime(j) = -uz(j,i-1)
22283 xx = xx + x_prime(j)*dc_norm(j,i+nres)
22284 yy = yy + y_prime(j)*dc_norm(j,i+nres)
22285 zz = zz + z_prime(j)*dc_norm(j,i+nres)
22293 x(j) = sc_parmin_nucl(j,it)
22296 !Cc diagnostics - remove later
22297 xx1 = dcos(alph(2))
22298 yy1 = dsin(alph(2))*dcos(omeg(2))
22299 zz1 = -dsin(alph(2))*dsin(omeg(2))
22300 write(2,'(3f8.1,3f9.3,1x,3f9.3)') &
22301 alph(2)*rad2deg,omeg(2)*rad2deg,theta(3)*rad2deg,xx,yy,zz,&
22303 !C," --- ", xx_w,yy_w,zz_w
22306 sumene = enesc_nucl(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
22307 esbloc = esbloc + sumene
22308 sumene2= enesc_nucl(x,xx,yy,0.0d0,cost2tab(i+1),sint2tab(i+1))
22309 ! print *,"enecomp",sumene,sumene2
22310 ! if (energy_dec) write(iout,*) "i",i," esbloc",sumene,esbloc,xx,yy,zz
22311 ! if (energy_dec) write(iout,*) "x",(x(k),k=1,9)
22313 write (2,*) "x",(x(k),k=1,9)
22315 !C This section to check the numerical derivatives of the energy of ith side
22316 !C chain in xx, yy, zz, and theta. Use the -DDEBUG compiler option or insert
22317 !C #define DEBUG in the code to turn it on.
22319 write (2,*) "sumene =",sumene
22323 write (2,*) xx,yy,zz
22324 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
22325 de_dxx_num=(sumenep-sumene)/aincr
22327 write (2,*) "xx+ sumene from enesc=",sumenep,sumene
22330 write (2,*) xx,yy,zz
22331 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
22332 de_dyy_num=(sumenep-sumene)/aincr
22334 write (2,*) "yy+ sumene from enesc=",sumenep,sumene
22337 write (2,*) xx,yy,zz
22338 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
22339 de_dzz_num=(sumenep-sumene)/aincr
22341 write (2,*) "zz+ sumene from enesc=",sumenep,sumene
22342 costsave=cost2tab(i+1)
22343 sintsave=sint2tab(i+1)
22344 cost2tab(i+1)=dcos(0.5d0*(theta(i+1)+aincr))
22345 sint2tab(i+1)=dsin(0.5d0*(theta(i+1)+aincr))
22346 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
22347 de_dt_num=(sumenep-sumene)/aincr
22348 write (2,*) " t+ sumene from enesc=",sumenep,sumene
22349 cost2tab(i+1)=costsave
22350 sint2tab(i+1)=sintsave
22351 !C End of diagnostics section.
22354 !C Compute the gradient of esc
22356 de_dxx=x(1)+2*x(4)*xx+x(7)*zz+x(8)*yy
22357 de_dyy=x(2)+2*x(5)*yy+x(8)*xx+x(9)*zz
22358 de_dzz=x(3)+2*x(6)*zz+x(7)*xx+x(9)*yy
22361 write (2,*) "x",(x(k),k=1,9)
22362 write (2,*) "xx",xx," yy",yy," zz",zz
22363 write (2,*) "de_xx ",de_xx," de_yy ",de_yy,&
22364 " de_zz ",de_zz," de_tt ",de_tt
22365 write (2,*) "de_xx_num",de_dxx_num," de_yy_num",de_dyy_num,&
22366 " de_zz_num",de_dzz_num," de_dt_num",de_dt_num
22369 cossc=scalar(dc_norm(1,i),dc_norm(1,i+nres))
22370 cossc1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
22371 cosfac2xx=cosfac2*xx
22372 sinfac2yy=sinfac2*yy
22374 dt_dCi(k) = -(dc_norm(k,i-1)+costtab(i+1)*dc_norm(k,i))*&
22376 dt_dCi1(k)= -(dc_norm(k,i)+costtab(i+1)*dc_norm(k,i-1))*&
22378 pom=(dC_norm(k,i+nres)-cossc*dC_norm(k,i))*vbld_inv(i+1)
22379 pom1=(dC_norm(k,i+nres)-cossc1*dC_norm(k,i-1))*vbld_inv(i)
22380 !c write (iout,*) "i",i," k",k," pom",pom," pom1",pom1,
22381 !c & " dt_dCi",dt_dCi(k)," dt_dCi1",dt_dCi1(k)
22382 !c write (iout,*) "dC_norm",(dC_norm(j,i),j=1,3),
22383 !c & (dC_norm(j,i-1),j=1,3)," vbld_inv",vbld_inv(i+1),vbld_inv(i)
22384 dXX_Ci(k)=pom*cosfac-dt_dCi(k)*cosfac2xx
22385 dXX_Ci1(k)=-pom1*cosfac-dt_dCi1(k)*cosfac2xx
22386 dYY_Ci(k)=pom*sinfac+dt_dCi(k)*sinfac2yy
22387 dYY_Ci1(k)=pom1*sinfac+dt_dCi1(k)*sinfac2yy
22391 dZZ_Ci(k)=dZZ_Ci(k)-uzgrad(j,k,2,i-1)*dC_norm(j,i+nres)
22392 dZZ_Ci1(k)=dZZ_Ci1(k)-uzgrad(j,k,1,i-1)*dC_norm(j,i+nres)
22395 dXX_XYZ(k)=vbld_inv(i+nres)*(x_prime(k)-xx*dC_norm(k,i+nres))
22396 dYY_XYZ(k)=vbld_inv(i+nres)*(y_prime(k)-yy*dC_norm(k,i+nres))
22397 dZZ_XYZ(k)=vbld_inv(i+nres)*(z_prime(k)-zz*dC_norm(k,i+nres))
22399 dt_dCi(k) = -dt_dCi(k)/sinttab(i+1)
22400 dt_dCi1(k)= -dt_dCi1(k)/sinttab(i+1)
22404 dXX_Ctab(k,i)=dXX_Ci(k)
22405 dXX_C1tab(k,i)=dXX_Ci1(k)
22406 dYY_Ctab(k,i)=dYY_Ci(k)
22407 dYY_C1tab(k,i)=dYY_Ci1(k)
22408 dZZ_Ctab(k,i)=dZZ_Ci(k)
22409 dZZ_C1tab(k,i)=dZZ_Ci1(k)
22410 dXX_XYZtab(k,i)=dXX_XYZ(k)
22411 dYY_XYZtab(k,i)=dYY_XYZ(k)
22412 dZZ_XYZtab(k,i)=dZZ_XYZ(k)
22415 !c write (iout,*) "k",k," dxx_ci1",dxx_ci1(k)," dyy_ci1",
22416 !c & dyy_ci1(k)," dzz_ci1",dzz_ci1(k)
22417 !c write (iout,*) "k",k," dxx_ci",dxx_ci(k)," dyy_ci",
22418 !c & dyy_ci(k)," dzz_ci",dzz_ci(k)
22419 !c write (iout,*) "k",k," dt_dci",dt_dci(k)," dt_dci",
22421 !c write (iout,*) "k",k," dxx_XYZ",dxx_XYZ(k)," dyy_XYZ",
22422 !c & dyy_XYZ(k)," dzz_XYZ",dzz_XYZ(k)
22423 gsbloc(k,i-1)=gsbloc(k,i-1)+(de_dxx*dxx_ci1(k) &
22424 +de_dyy*dyy_ci1(k)+de_dzz*dzz_ci1(k)+de_dt*dt_dCi1(k))
22425 gsbloc(k,i)=gsbloc(k,i)+(de_dxx*dxx_Ci(k) &
22426 +de_dyy*dyy_Ci(k)+de_dzz*dzz_Ci(k)+de_dt*dt_dCi(k))
22427 gsblocx(k,i)= de_dxx*dxx_XYZ(k)&
22428 +de_dyy*dyy_XYZ(k)+de_dzz*dzz_XYZ(k)
22429 ! print *,i,de_dxx*dxx_ci1(k)+de_dyy*dyy_ci1(k),de_dzz*dzz_ci1(k)*2
22431 !c write(iout,*) "ENERGY GRAD = ", (gsbloc(k,i-1),k=1,3),
22432 !c & (gsbloc(k,i),k=1,3),(gsblocx(k,i),k=1,3)
22434 !C to check gradient call subroutine check_grad
22440 !=-------------------------------------------------------
22441 real(kind=8) function enesc_nucl(x,xx,yy,zz,cost2,sint2)
22443 real(kind=8),dimension(9):: x(9)
22444 real(kind=8) :: xx,yy,zz,cost2,sint2,sumene1,sumene2, &
22445 sumene3,sumene4,sumene,dsc_i,dp2_i,dscp1,dscp2,s1,s1_6,s2,s2_6
22447 !c write (2,*) "enesc"
22448 !c write (2,*) "x",(x(i),i=1,9)
22449 !c write(2,*)"xx",xx," yy",yy," zz",zz," cost2",cost2," sint2",sint2
22450 sumene=x(1)*xx+x(2)*yy+x(3)*zz+x(4)*xx**2 &
22451 + x(5)*yy**2+x(6)*zz**2+x(7)*xx*zz+x(8)*xx*yy &
22455 end function enesc_nucl
22456 !-----------------------------------------------------------------------------
22457 subroutine multibody_hb_nucl(ecorr,ecorr3,n_corr,n_corr1)
22460 integer,parameter :: max_cont=2000
22461 integer,parameter:: max_dim=2*(8*3+6)
22462 integer, parameter :: msglen1=max_cont*max_dim
22463 integer,parameter :: msglen2=2*msglen1
22464 integer source,CorrelType,CorrelID,Error
22465 real(kind=8) :: buffer(max_cont,max_dim)
22466 integer status(MPI_STATUS_SIZE)
22467 integer :: ierror,nbytes
22469 real(kind=8),dimension(3):: gx(3),gx1(3)
22470 real(kind=8) :: time00
22472 integer i,j,i1,j1,jj,kk,num_conti,num_conti1,nn
22473 real(kind=8) ecorr,ecorr3
22474 integer :: n_corr,n_corr1,mm,msglen
22475 !C Set lprn=.true. for debugging
22480 if(.not.allocated(zapas2)) allocate(zapas2(3,maxconts,nres,8))
22482 if (nfgtasks.le.1) goto 30
22484 write (iout,'(a)') 'Contact function values:'
22486 write (iout,'(2i3,50(1x,i2,f5.2))') &
22487 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i), &
22488 j=1,num_cont_hb(i))
22491 !C Caution! Following code assumes that electrostatic interactions concerning
22492 !C a given atom are split among at most two processors!
22502 !c write (*,*) 'MyRank',MyRank,' mm',mm
22505 !c write (*,*) 'Sending: MyRank',MyRank,' mm',mm,' ldone',ldone
22506 if (fg_rank.gt.0) then
22507 !C Send correlation contributions to the preceding processor
22509 nn=num_cont_hb(iatel_s_nucl)
22510 call pack_buffer(max_cont,max_dim,iatel_s,0,buffer)
22511 !c write (*,*) 'The BUFFER array:'
22513 !c write (*,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,30)
22515 if (ielstart_nucl(iatel_s_nucl).gt.iatel_s_nucl+ispp) then
22517 call pack_buffer(max_cont,max_dim,iatel_s+1,30,buffer)
22518 !C Clear the contacts of the atom passed to the neighboring processor
22519 nn=num_cont_hb(iatel_s_nucl+1)
22521 !c write (*,'(i2,9(3f8.3,2x))') i,(buffer(i,j+30),j=1,30)
22523 num_cont_hb(iatel_s_nucl)=0
22525 !cd write (iout,*) 'Processor ',fg_rank,MyRank,
22526 !cd & ' is sending correlation contribution to processor',fg_rank-1,
22527 !cd & ' msglen=',msglen
22528 !c write (*,*) 'Processor ',fg_rank,MyRank,
22529 !c & ' is sending correlation contribution to processor',fg_rank-1,
22530 !c & ' msglen=',msglen,' CorrelType=',CorrelType
22532 call MPI_Send(buffer,msglen,MPI_DOUBLE_PRECISION,fg_rank-1, &
22533 CorrelType,FG_COMM,IERROR)
22534 time_sendrecv=time_sendrecv+MPI_Wtime()-time00
22535 !cd write (iout,*) 'Processor ',fg_rank,
22536 !cd & ' has sent correlation contribution to processor',fg_rank-1,
22537 !cd & ' msglen=',msglen,' CorrelID=',CorrelID
22538 !c write (*,*) 'Processor ',fg_rank,
22539 !c & ' has sent correlation contribution to processor',fg_rank-1,
22540 !c & ' msglen=',msglen,' CorrelID=',CorrelID
22542 endif ! (fg_rank.gt.0)
22546 !c write (*,*) 'Receiving: MyRank',MyRank,' mm',mm,' ldone',ldone
22547 if (fg_rank.lt.nfgtasks-1) then
22548 !C Receive correlation contributions from the next processor
22550 if (ielend_nucl(iatel_e_nucl).lt.nct_molec(2)-1) msglen=msglen2
22551 !cd write (iout,*) 'Processor',fg_rank,
22552 !cd & ' is receiving correlation contribution from processor',fg_rank+1,
22553 !cd & ' msglen=',msglen,' CorrelType=',CorrelType
22554 !c write (*,*) 'Processor',fg_rank,
22555 !c &' is receiving correlation contribution from processor',fg_rank+1,
22556 !c & ' msglen=',msglen,' CorrelType=',CorrelType
22559 do while (nbytes.le.0)
22560 call MPI_Probe(fg_rank+1,CorrelType,FG_COMM,status,IERROR)
22561 call MPI_Get_count(status,MPI_DOUBLE_PRECISION,nbytes,IERROR)
22563 !c print *,'Processor',myrank,' msglen',msglen,' nbytes',nbytes
22564 call MPI_Recv(buffer,nbytes,MPI_DOUBLE_PRECISION, &
22565 fg_rank+1,CorrelType,FG_COMM,status,IERROR)
22566 time_sendrecv=time_sendrecv+MPI_Wtime()-time00
22567 !c write (*,*) 'Processor',fg_rank,
22568 !c &' has received correlation contribution from processor',fg_rank+1,
22569 !c & ' msglen=',msglen,' nbytes=',nbytes
22570 !c write (*,*) 'The received BUFFER array:'
22572 !c write (*,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,60)
22574 if (msglen.eq.msglen1) then
22575 call unpack_buffer(max_cont,max_dim,iatel_e_nucl+1,0,buffer)
22576 else if (msglen.eq.msglen2) then
22577 call unpack_buffer(max_cont,max_dim,iatel_e_nucl,0,buffer)
22578 call unpack_buffer(max_cont,max_dim,iatel_e_nucl+1,30,buffer)
22581 'ERROR!!!! message length changed while processing correlations.'
22583 'ERROR!!!! message length changed while processing correlations.'
22584 call MPI_Abort(MPI_COMM_WORLD,Error,IERROR)
22585 endif ! msglen.eq.msglen1
22586 endif ! fg_rank.lt.nfgtasks-1
22593 write (iout,'(a)') 'Contact function values:'
22594 do i=nnt_molec(2),nct_molec(2)-1
22595 write (iout,'(2i3,50(1x,i2,f5.2))') &
22596 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i), &
22597 j=1,num_cont_hb(i))
22602 !C Remove the loop below after debugging !!!
22603 ! do i=nnt_molec(2),nct_molec(2)
22605 ! gradcorr_nucl(j,i)=0.0D0
22606 ! gradxorr_nucl(j,i)=0.0D0
22607 ! gradcorr3_nucl(j,i)=0.0D0
22608 ! gradxorr3_nucl(j,i)=0.0D0
22611 ! print *,"iatsc_s_nucl,iatsc_e_nucl",iatsc_s_nucl,iatsc_e_nucl
22612 !C Calculate the local-electrostatic correlation terms
22613 do i=iatsc_s_nucl,iatsc_e_nucl
22615 num_conti=num_cont_hb(i)
22616 num_conti1=num_cont_hb(i+1)
22617 ! print *,i,num_conti,num_conti1
22622 !c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
22623 !c & ' jj=',jj,' kk=',kk
22624 if (j1.eq.j+1 .or. j1.eq.j-1) then
22626 !C Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
22627 !C The system gains extra energy.
22628 !C Tentative expression & coefficients; assumed d(stacking)=4.5 A,
22629 !C parallel dipoles of stacknig bases and sin(mui)sin(muj)/eps/d^3=0.7
22630 !C Need to implement full formulas 34 and 35 from Liwo et al., 1998.
22632 ecorr=ecorr+ehbcorr_nucl(i,j,i+1,j1,jj,kk,0.528D0,0.132D0)
22633 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
22634 'ecorrh',i,j,ehbcorr_nucl(i,j,i+1,j1,jj,kk,0.528D0,0.132D0)
22636 else if (j1.eq.j) then
22638 !C Contacts I-J and I-(J+1) occur simultaneously.
22639 !C The system loses extra energy.
22640 !C Tentative expression & c?oefficients; assumed d(stacking)=4.5 A,
22641 !C parallel dipoles of stacknig bases and sin(mui)sin(muj)/eps/d^3=0.7
22642 !C Need to implement full formulas 32 from Liwo et al., 1998.
22644 !c write (iout,*) 'ecorr3: i=',i,' j=',j,' i1=',i1,' j1=',j1,
22645 !c & ' jj=',jj,' kk=',kk
22646 ecorr3=ecorr3+ehbcorr3_nucl(i,j,i+1,j,jj,kk,0.310D0,-0.155D0)
22651 !c write (iout,*) 'ecorr3: i=',i,' j=',j,' i1=',i1,' j1=',j1,
22652 !c & ' jj=',jj,' kk=',kk
22653 if (j1.eq.j+1) then
22654 !C Contacts I-J and (I+1)-J occur simultaneously.
22655 !C The system loses extra energy.
22656 ecorr3=ecorr3+ehbcorr3_nucl(i,j,i,j+1,jj,kk,0.310D0,-0.155D0)
22662 end subroutine multibody_hb_nucl
22663 !-----------------------------------------------------------
22664 real(kind=8) function ehbcorr_nucl(i,j,k,l,jj,kk,coeffp,coeffm)
22665 ! implicit real*8 (a-h,o-z)
22666 ! include 'DIMENSIONS'
22667 ! include 'COMMON.IOUNITS'
22668 ! include 'COMMON.DERIV'
22669 ! include 'COMMON.INTERACT'
22670 ! include 'COMMON.CONTACTS'
22671 real(kind=8),dimension(3) :: gx,gx1
22673 !el local variables
22674 integer :: i,j,k,l,jj,kk,ll,ilist,m, iresshield
22675 real(kind=8) :: coeffp,coeffm,eij,ekl,ees0pij,ees0pkl,ees0mij,&
22676 ees0mkl,ees,coeffpees0pij,coeffmees0mij,&
22677 coeffpees0pkl,coeffmees0mkl,gradlongij,gradlongkl, &
22681 eij=facont_hb(jj,i)
22682 ekl=facont_hb(kk,k)
22683 ees0pij=ees0p(jj,i)
22684 ees0pkl=ees0p(kk,k)
22685 ees0mij=ees0m(jj,i)
22686 ees0mkl=ees0m(kk,k)
22688 ees=-(coeffp*ees0pij*ees0pkl+coeffm*ees0mij*ees0mkl)
22689 ! print *,"ehbcorr_nucl",ekont,ees
22690 !cd ees=-(coeffp*ees0pkl+coeffm*ees0mkl)
22691 !C Following 4 lines for diagnostics.
22696 !cd write (iout,*)'Contacts have occurred for nucleic bases',
22697 !cd & i,j,' fcont:',eij,' eij',' eesij',ees0pij,ees0mij,' and ',k,l
22698 !cd & ,' fcont ',ekl,' eeskl',ees0pkl,ees0mkl,' ees=',ees
22699 !C Calculate the multi-body contribution to energy.
22700 ! ecorr_nucl=ecorr_nucl+ekont*ees
22701 !C Calculate multi-body contributions to the gradient.
22702 coeffpees0pij=coeffp*ees0pij
22703 coeffmees0mij=coeffm*ees0mij
22704 coeffpees0pkl=coeffp*ees0pkl
22705 coeffmees0mkl=coeffm*ees0mkl
22707 gradxorr_nucl(ll,i)=gradxorr_nucl(ll,i) &
22708 -ekont*(coeffpees0pkl*gacontp_hb1(ll,jj,i)+&
22709 coeffmees0mkl*gacontm_hb1(ll,jj,i))
22710 gradxorr_nucl(ll,j)=gradxorr_nucl(ll,j) &
22711 -ekont*(coeffpees0pkl*gacontp_hb2(ll,jj,i)+&
22712 coeffmees0mkl*gacontm_hb2(ll,jj,i))
22713 gradxorr_nucl(ll,k)=gradxorr_nucl(ll,k) &
22714 -ekont*(coeffpees0pij*gacontp_hb1(ll,kk,k)+&
22715 coeffmees0mij*gacontm_hb1(ll,kk,k))
22716 gradxorr_nucl(ll,l)=gradxorr_nucl(ll,l) &
22717 -ekont*(coeffpees0pij*gacontp_hb2(ll,kk,k)+ &
22718 coeffmees0mij*gacontm_hb2(ll,kk,k))
22719 gradlongij=ees*ekl*gacont_hbr(ll,jj,i)- &
22720 ekont*(coeffpees0pkl*gacontp_hb3(ll,jj,i)+ &
22721 coeffmees0mkl*gacontm_hb3(ll,jj,i))
22722 gradcorr_nucl(ll,j)=gradcorr_nucl(ll,j)+gradlongij
22723 gradcorr_nucl(ll,i)=gradcorr_nucl(ll,i)-gradlongij
22724 gradlongkl=ees*eij*gacont_hbr(ll,kk,k)- &
22725 ekont*(coeffpees0pij*gacontp_hb3(ll,kk,k)+ &
22726 coeffmees0mij*gacontm_hb3(ll,kk,k))
22727 gradcorr_nucl(ll,l)=gradcorr_nucl(ll,l)+gradlongkl
22728 gradcorr_nucl(ll,k)=gradcorr_nucl(ll,k)-gradlongkl
22729 gradxorr_nucl(ll,i)=gradxorr_nucl(ll,i)-gradlongij
22730 gradxorr_nucl(ll,j)=gradxorr_nucl(ll,j)+gradlongij
22731 gradxorr_nucl(ll,k)=gradxorr_nucl(ll,k)-gradlongkl
22732 gradxorr_nucl(ll,l)=gradxorr_nucl(ll,l)+gradlongkl
22734 ehbcorr_nucl=ekont*ees
22736 end function ehbcorr_nucl
22737 !-------------------------------------------------------------------------
22739 real(kind=8) function ehbcorr3_nucl(i,j,k,l,jj,kk,coeffp,coeffm)
22740 ! implicit real*8 (a-h,o-z)
22741 ! include 'DIMENSIONS'
22742 ! include 'COMMON.IOUNITS'
22743 ! include 'COMMON.DERIV'
22744 ! include 'COMMON.INTERACT'
22745 ! include 'COMMON.CONTACTS'
22746 real(kind=8),dimension(3) :: gx,gx1
22748 !el local variables
22749 integer :: i,j,k,l,jj,kk,ll,ilist,m, iresshield
22750 real(kind=8) :: coeffp,coeffm,eij,ekl,ees0pij,ees0pkl,ees0mij,&
22751 ees0mkl,ees,coeffpees0pij,coeffmees0mij,&
22752 coeffpees0pkl,coeffmees0mkl,gradlongij,gradlongkl, &
22756 eij=facont_hb(jj,i)
22757 ekl=facont_hb(kk,k)
22758 ees0pij=ees0p(jj,i)
22759 ees0pkl=ees0p(kk,k)
22760 ees0mij=ees0m(jj,i)
22761 ees0mkl=ees0m(kk,k)
22763 ees=-(coeffp*ees0pij*ees0pkl+coeffm*ees0mij*ees0mkl)
22764 !cd ees=-(coeffp*ees0pkl+coeffm*ees0mkl)
22765 !C Following 4 lines for diagnostics.
22770 !cd write (iout,*)'Contacts have occurred for nucleic bases',
22771 !cd & i,j,' fcont:',eij,' eij',' eesij',ees0pij,ees0mij,' and ',k,l
22772 !cd & ,' fcont ',ekl,' eeskl',ees0pkl,ees0mkl,' ees=',ees
22773 !C Calculate the multi-body contribution to energy.
22774 ! ecorr=ecorr+ekont*ees
22775 !C Calculate multi-body contributions to the gradient.
22776 coeffpees0pij=coeffp*ees0pij
22777 coeffmees0mij=coeffm*ees0mij
22778 coeffpees0pkl=coeffp*ees0pkl
22779 coeffmees0mkl=coeffm*ees0mkl
22781 gradxorr3_nucl(ll,i)=gradxorr3_nucl(ll,i) &
22782 -ekont*(coeffpees0pkl*gacontp_hb1(ll,jj,i)+&
22783 coeffmees0mkl*gacontm_hb1(ll,jj,i))
22784 gradxorr3_nucl(ll,j)=gradxorr3_nucl(ll,j) &
22785 -ekont*(coeffpees0pkl*gacontp_hb2(ll,jj,i)+ &
22786 coeffmees0mkl*gacontm_hb2(ll,jj,i))
22787 gradxorr3_nucl(ll,k)=gradxorr3_nucl(ll,k) &
22788 -ekont*(coeffpees0pij*gacontp_hb1(ll,kk,k)+ &
22789 coeffmees0mij*gacontm_hb1(ll,kk,k))
22790 gradxorr3_nucl(ll,l)=gradxorr3_nucl(ll,l) &
22791 -ekont*(coeffpees0pij*gacontp_hb2(ll,kk,k)+ &
22792 coeffmees0mij*gacontm_hb2(ll,kk,k))
22793 gradlongij=ees*ekl*gacont_hbr(ll,jj,i)- &
22794 ekont*(coeffpees0pkl*gacontp_hb3(ll,jj,i)+ &
22795 coeffmees0mkl*gacontm_hb3(ll,jj,i))
22796 gradcorr3_nucl(ll,j)=gradcorr3_nucl(ll,j)+gradlongij
22797 gradcorr3_nucl(ll,i)=gradcorr3_nucl(ll,i)-gradlongij
22798 gradlongkl=ees*eij*gacont_hbr(ll,kk,k)- &
22799 ekont*(coeffpees0pij*gacontp_hb3(ll,kk,k)+ &
22800 coeffmees0mij*gacontm_hb3(ll,kk,k))
22801 gradcorr3_nucl(ll,l)=gradcorr3_nucl(ll,l)+gradlongkl
22802 gradcorr3_nucl(ll,k)=gradcorr3_nucl(ll,k)-gradlongkl
22803 gradxorr3_nucl(ll,i)=gradxorr3_nucl(ll,i)-gradlongij
22804 gradxorr3_nucl(ll,j)=gradxorr3_nucl(ll,j)+gradlongij
22805 gradxorr3_nucl(ll,k)=gradxorr3_nucl(ll,k)-gradlongkl
22806 gradxorr3_nucl(ll,l)=gradxorr3_nucl(ll,l)+gradlongkl
22808 ehbcorr3_nucl=ekont*ees
22810 end function ehbcorr3_nucl
22812 subroutine pack_buffer(dimen1,dimen2,atom,indx,buffer)
22813 integer dimen1,dimen2,atom,indx,numcont,i,ii,k,j,num_kont,num_kont_old
22814 real(kind=8):: buffer(dimen1,dimen2)
22815 num_kont=num_cont_hb(atom)
22819 buffer(i,indx+(k-1)*3+j)=zapas2(j,i,atom,k)
22822 buffer(i,indx+25)=facont_hb(i,atom)
22823 buffer(i,indx+26)=ees0p(i,atom)
22824 buffer(i,indx+27)=ees0m(i,atom)
22825 buffer(i,indx+28)=d_cont(i,atom)
22826 buffer(i,indx+29)=dfloat(jcont_hb(i,atom))
22828 buffer(1,indx+30)=dfloat(num_kont)
22830 end subroutine pack_buffer
22831 !c------------------------------------------------------------------------------
22832 subroutine unpack_buffer(dimen1,dimen2,atom,indx,buffer)
22833 integer dimen1,dimen2,atom,indx,numcont,i,ii,k,j,num_kont,num_kont_old
22834 real(kind=8):: buffer(dimen1,dimen2)
22835 ! double precision zapas
22836 ! common /contacts_hb/ zapas(3,maxconts,maxres,8),
22837 ! & facont_hb(maxconts,maxres),ees0p(maxconts,maxres),
22838 ! & ees0m(maxconts,maxres),d_cont(maxconts,maxres),
22839 ! & num_cont_hb(maxres),jcont_hb(maxconts,maxres)
22840 num_kont=buffer(1,indx+30)
22841 num_kont_old=num_cont_hb(atom)
22842 num_cont_hb(atom)=num_kont+num_kont_old
22847 zapas2(j,ii,atom,k)=buffer(i,indx+(k-1)*3+j)
22850 facont_hb(ii,atom)=buffer(i,indx+25)
22851 ees0p(ii,atom)=buffer(i,indx+26)
22852 ees0m(ii,atom)=buffer(i,indx+27)
22853 d_cont(i,atom)=buffer(i,indx+28)
22854 jcont_hb(ii,atom)=buffer(i,indx+29)
22857 end subroutine unpack_buffer
22858 !c------------------------------------------------------------------------------
22860 subroutine ecatcat(ecationcation)
22861 integer :: i,j,itmp,xshift,yshift,zshift,subchap,k,itypi,itypj
22862 real(kind=8) :: xi,yi,zi,xj,yj,zj,ract,rcat0,epscalc,r06,r012,&
22863 r7,r4,ecationcation,k0,rcal,aa,bb,sslipi,ssgradlipi,sslipj,ssgradlipj
22864 real(kind=8) xj_temp,yj_temp,zj_temp,xj_safe,yj_safe,zj_safe, &
22865 dist_init,dist_temp,Evan1cat,Evan2cat,Eeleccat
22866 real(kind=8),dimension(3) ::dEvan1Cmcat,dEvan2Cmcat,dEeleccat,&
22869 ecationcation=0.0d0
22870 if (nres_molec(5).eq.0) return
22875 ! k0 = 332.0*(2.0*2.0)/80.0
22879 itmp=itmp+nres_molec(i)
22881 ! write(iout,*) "itmp",itmp
22882 do i=itmp+1,itmp+nres_molec(5)-1
22887 ! write (iout,*) i,"TUTUT",c(1,i)
22889 call to_box(xi,yi,zi)
22890 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
22891 do j=i+1,itmp+nres_molec(5)
22893 ! print *,i,j,itypi,itypj
22894 k0 = 332.0*(ichargecat(itypi)*ichargecat(itypj))/80.0
22895 ! print *,i,j,'catcat'
22899 call to_box(xj,yj,zj)
22900 ! call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
22901 ! aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
22902 ! +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
22903 ! bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
22904 ! +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
22905 xj=boxshift(xj-xi,boxxsize)
22906 yj=boxshift(yj-yi,boxysize)
22907 zj=boxshift(zj-zi,boxzsize)
22908 rcal =xj**2+yj**2+zj**2
22914 ! k0 = 332*(2*2)/80
22915 Evan1cat=epscalc*(r012/(rcal**6))
22916 Evan2cat=epscalc*2*(r06/(rcal**3))
22924 dEvan1Cmcat(k)=-12*r(k)*epscalc*r012/r7
22925 dEvan2Cmcat(k)=-12*r(k)*epscalc*r06/r4
22926 dEeleccat(k)=-k0*r(k)/ract**3
22929 gg(k) = dEvan1Cmcat(k)+dEvan2Cmcat(k)+dEeleccat(k)
22930 gradcatcat(k,i)=gradcatcat(k,i)-gg(k)
22931 gradcatcat(k,j)=gradcatcat(k,j)+gg(k)
22933 if (energy_dec) write (iout,*) i,j,Evan1cat,Evan2cat,Eeleccat,&
22934 r012,rcal**6,ichargecat(itypi)*ichargecat(itypj)
22935 ! write(iout,*) "ecatcat",i,j, ecationcation,xj,yj,zj
22936 ecationcation=ecationcation+Evan1cat+Evan2cat+Eeleccat
22940 end subroutine ecatcat
22941 !---------------------------------------------------------------------------
22943 subroutine ecats_prot_amber(evdw)
22944 ! subroutine ecat_prot2(ecation_prot)
22949 !el local variables
22950 integer :: iint,itypi1,subchap,isel,itmp
22951 real(kind=8) :: rrij,xi,yi,zi,sig,rij_shift,e1,e2,sigm,epsi
22952 real(kind=8) :: evdw,aa,bb
22953 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
22954 dist_temp, dist_init,ssgradlipi,ssgradlipj, &
22955 sslipi,sslipj,faclip,alpha_sco
22957 real(kind=8) :: fracinbuf
22958 real (kind=8) :: escpho
22959 real (kind=8),dimension(4):: ener
22960 real(kind=8) :: b1,b2,egb
22961 real(kind=8) :: Fisocav,ECL,Elj,Equad,Epol,eheadtail,&
22963 Chif,ChiLambf,Fcav,dFdR,dFdOM1,&
22964 ecations_prot_amber,dFdOM2,dFdL,dFdOM12,&
22967 ! real(kind=8),dimension(3,2)::erhead_tail
22968 ! real(kind=8),dimension(3) :: Rhead_distance,ertail,erhead,Rtail_distance
22969 real(kind=8) :: facd4, adler, Fgb, facd3
22970 integer troll,jj,istate
22971 real (kind=8) :: dcosom1(3),dcosom2(3)
22974 if (nres_molec(5).eq.0) return
22976 ! sss_ele_cut=1.0d0
22980 itmp=itmp+nres_molec(i)
22983 ! do i=1,nres_molec(1)-1 ! loop over all peptide groups needs parralelization
22984 do i=ibond_start,ibond_end
22986 ! print *,"I am in EVDW",i
22987 itypi=iabs(itype(i,1))
22989 ! if (i.ne.47) cycle
22990 if ((itypi.eq.ntyp1).or.(itypi.eq.10)) cycle
22991 itypi1=iabs(itype(i+1,1))
22995 call to_box(xi,yi,zi)
22996 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
22997 dxi=dc_norm(1,nres+i)
22998 dyi=dc_norm(2,nres+i)
22999 dzi=dc_norm(3,nres+i)
23000 dsci_inv=vbld_inv(i+nres)
23001 do j=itmp+1,itmp+nres_molec(5)
23003 ! Calculate SC interaction energy.
23004 itypj=iabs(itype(j,5))
23005 if ((itypj.eq.ntyp1)) cycle
23006 CALL elgrad_init_cat(eheadtail,Egb,Ecl,Elj,Equad,Epol)
23013 call to_box(xj,yj,zj)
23014 ! call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
23015 ! aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
23016 ! +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
23017 ! bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
23018 ! +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
23019 xj=boxshift(xj-xi,boxxsize)
23020 yj=boxshift(yj-yi,boxysize)
23021 zj=boxshift(zj-zi,boxzsize)
23023 ! dxj = dc_norm( 1, nres+j )
23024 ! dyj = dc_norm( 2, nres+j )
23025 ! dzj = dc_norm( 3, nres+j )
23029 ! Parameters from fitting the analitical expressions to the PMF obtained by umbrella
23030 ! sampling performed with amber package
23034 ! a12sq = rborn(itypi,itypj) * rborn(itypj,itypi)
23035 chi1 = chi1cat(itypi,itypj)
23036 chis1 = chis1cat(itypi,itypj)
23037 chip1 = chipp1cat(itypi,itypj)
23044 ! chis2 = chis(itypj,itypi)
23045 chis12 = chis1 * chis2
23046 sig1 = sigmap1cat(itypi,itypj)
23047 ! sig2 = sigmap2(itypi,itypj)
23048 ! alpha factors from Fcav/Gcav
23049 b1cav = alphasurcat(1,itypi,itypj)
23050 b2cav = alphasurcat(2,itypi,itypj)
23051 b3cav = alphasurcat(3,itypi,itypj)
23052 b4cav = alphasurcat(4,itypi,itypj)
23054 ! used to determine whether we want to do quadrupole calculations
23055 eps_in = epsintabcat(itypi,itypj)
23056 if (eps_in.eq.0.0) eps_in=1.0
23058 eps_inout_fac = ( (1.0d0/eps_in) - (1.0d0/eps_out))
23062 ctail(k,1)=c(k,i+nres)
23065 !c! tail distances will be themselves usefull elswhere
23066 !c1 (in Gcav, for example)
23067 Rtail_distance(1) = ctail( 1, 2 ) - ctail( 1,1 )
23068 Rtail_distance(2) = ctail( 2, 2 ) - ctail( 2,1 )
23069 Rtail_distance(3) = ctail( 3, 2 ) - ctail( 3,1 )
23071 (Rtail_distance(1)*Rtail_distance(1)) &
23072 + (Rtail_distance(2)*Rtail_distance(2)) &
23073 + (Rtail_distance(3)*Rtail_distance(3)))
23074 ! tail location and distance calculations
23076 d1 = dheadcat(1, 1, itypi, itypj)
23077 ! d2 = dhead(2, 1, itypi, itypj)
23079 ! location of polar head is computed by taking hydrophobic centre
23080 ! and moving by a d1 * dc_norm vector
23081 ! see unres publications for very informative images
23082 chead(k,1) = c(k, i+nres) + d1 * dc_norm(k, i+nres)
23083 chead(k,2) = c(k, j)
23085 ! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
23086 ! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
23087 Rhead_distance(k) = chead(k,2) - chead(k,1)
23089 ! pitagoras (root of sum of squares)
23091 (Rhead_distance(1)*Rhead_distance(1)) &
23092 + (Rhead_distance(2)*Rhead_distance(2)) &
23093 + (Rhead_distance(3)*Rhead_distance(3)))
23094 !-------------------------------------------------------------------
23095 ! zero everything that should be zero'ed
23113 dscj_inv = vbld_inv(j+nres)
23114 ! print *,i,j,dscj_inv,dsci_inv
23115 ! rij holds 1/(distance of Calpha atoms)
23116 rrij = 1.0D0 / ( xj*xj + yj*yj + zj*zj)
23119 ! this should be in elgrad_init but om's are calculated by sc_angular
23120 ! which in turn is used by older potentials
23121 ! om = omega, sqom = om^2
23124 sqom12 = om12 * om12
23126 ! now we calculate EGB - Gey-Berne
23127 ! It will be summed up in evdwij and saved in evdw
23128 sigsq = 1.0D0 / sigsq
23129 sig = sig0ij * dsqrt(sigsq)
23130 ! rij_shift = 1.0D0 / rij - sig + sig0ij
23131 rij_shift = Rtail - sig + sig0ij
23132 IF (rij_shift.le.0.0D0) THEN
23136 sigder = -sig * sigsq
23137 rij_shift = 1.0D0 / rij_shift
23138 fac = rij_shift**expon
23139 c1 = fac * fac * aa_aq_cat(itypi,itypj)
23140 ! print *,"ADAM",aa_aq(itypi,itypj)
23143 c2 = fac * bb_aq_cat(itypi,itypj)
23145 evdwij = eps1 * eps2rt * eps3rt * ( c1 + c2 )
23146 eps2der = eps3rt * evdwij
23147 eps3der = eps2rt * evdwij
23148 ! evdwij = 4.0d0 * eps2rt * eps3rt * evdwij
23149 evdwij = eps2rt * eps3rt * evdwij
23151 ! IF (bb_aq(itypi,itypj).gt.0) THEN
23152 ! evdw_p = evdw_p + evdwij
23154 ! evdw_m = evdw_m + evdwij
23160 c1 = c1 * eps1 * eps2rt**2 * eps3rt**2
23161 fac = -expon * (c1 + evdwij) * rij_shift
23162 sigder = fac * sigder
23163 ! Calculate distance derivative
23168 fac = chis1 * sqom1 + chis2 * sqom2 &
23169 - 2.0d0 * chis12 * om1 * om2 * om12
23170 pom = 1.0d0 - chis1 * chis2 * sqom12
23171 Lambf = (1.0d0 - (fac / pom))
23172 Lambf = dsqrt(Lambf)
23173 sparrow = 1.0d0 / dsqrt(sig1**2.0d0 + sig2**2.0d0)
23174 Chif = Rtail * sparrow
23175 ChiLambf = Chif * Lambf
23176 eagle = dsqrt(ChiLambf)
23177 bat = ChiLambf ** 11.0d0
23178 top = b1cav * ( eagle + b2cav * ChiLambf - b3cav )
23179 bot = 1.0d0 + b4cav * (ChiLambf ** 12.0d0)
23183 dtop = b1cav * ((Lambf / (2.0d0 * eagle)) + (b2cav * Lambf))
23184 dbot = 12.0d0 * b4cav * bat * Lambf
23185 dFdR = ((dtop * bot - top * dbot) / botsq) * sparrow
23187 dtop = b1cav * ((Chif / (2.0d0 * eagle)) + (b2cav * Chif))
23188 dbot = 12.0d0 * b4cav * bat * Chif
23189 eagle = Lambf * pom
23190 dFdOM1 = -(chis1 * om1 - chis12 * om2 * om12) / (eagle)
23191 dFdOM2 = -(chis2 * om2 - chis12 * om1 * om12) / (eagle)
23192 dFdOM12 = chis12 * (chis1 * om1 * om12 - om2) &
23193 * (chis2 * om2 * om12 - om1) / (eagle * pom)
23195 dFdL = ((dtop * bot - top * dbot) / botsq)
23196 dCAVdOM1 = dFdL * ( dFdOM1 )
23197 dCAVdOM2 = dFdL * ( dFdOM2 )
23198 dCAVdOM12 = dFdL * ( dFdOM12 )
23201 ertail(k) = Rtail_distance(k)/Rtail
23203 erdxi = scalar( ertail(1), dC_norm(1,i+nres) )
23204 erdxj = scalar( ertail(1), dC_norm(1,j) )
23205 facd1 = dtailcat(1,itypi,itypj) * vbld_inv(i+nres)
23206 facd2 = dtailcat(2,itypi,itypj) * vbld_inv(j+nres)
23208 pom = ertail(k)-facd1*(ertail(k)-erdxi*dC_norm(k,i+nres))
23209 gradpepcatx(k,i) = gradpepcatx(k,i) &
23210 - (( dFdR + gg(k) ) * pom)
23211 pom = ertail(k)-facd2*(ertail(k)-erdxj*dC_norm(k,j+nres))
23212 ! gvdwx(k,j) = gvdwx(k,j) &
23213 ! + (( dFdR + gg(k) ) * pom)
23214 gradpepcat(k,i) = gradpepcat(k,i) &
23215 - (( dFdR + gg(k) ) * ertail(k))
23216 gradpepcat(k,j) = gradpepcat(k,j) &
23217 + (( dFdR + gg(k) ) * ertail(k))
23220 !c! Compute head-head and head-tail energies for each state
23221 isel = iabs(Qi) + 1 ! ion is always charged so iabs(Qj)
23222 IF (isel.eq.0) THEN
23223 !c! No charges - do nothing
23226 ELSE IF (isel.eq.1) THEN
23227 !c! Nonpolar-charge interactions
23228 if ((itype(i,1).eq.27).or.(itype(i,1).eq.26).or.(itype(i,1).eq.25)) then
23232 if ((itype(j,1).eq.27).or.(itype(j,1).eq.26).or.(itype(j,1).eq.25)) then
23239 ! eheadtail = 0.0d0
23241 ELSE IF (isel.eq.3) THEN
23242 !c! Dipole-charge interactions
23243 if ((itype(i,1).eq.27).or.(itype(i,1).eq.26).or.(itype(i,1).eq.25)) then
23247 if ((itype(j,1).eq.27).or.(itype(j,1).eq.26).or.(itype(j,1).eq.25)) then
23251 ! write(iout,*) "KURWA0",d1
23253 CALL edq_cat(ecl, elj, epol)
23254 eheadtail = ECL + elj + epol
23255 ! eheadtail = 0.0d0
23257 ELSE IF ((isel.eq.2)) THEN
23259 !c! Same charge-charge interaction ( +/+ or -/- )
23260 if ((itype(i,1).eq.27).or.(itype(i,1).eq.26).or.(itype(i,1).eq.25)) then
23264 if ((itype(j,1).eq.27).or.(itype(j,1).eq.26).or.(itype(j,1).eq.25)) then
23269 CALL eqq_cat(Ecl,Egb,Epol,Fisocav,Elj)
23270 eheadtail = ECL + Egb + Epol + Fisocav + Elj
23271 ! eheadtail = 0.0d0
23273 ! ELSE IF ((isel.eq.2.and. &
23274 ! iabs(Qi).eq.1).and. &
23275 ! nstate(itypi,itypj).ne.1) THEN
23276 !c! Different charge-charge interaction ( +/- or -/+ )
23277 ! if ((itype(i,1).eq.27).or.(itype(i,1).eq.26).or.(itype(i,1).eq.25)) then
23281 ! if ((itype(j,1).eq.27).or.(itype(j,1).eq.26).or.(itype(j,1).eq.25)) then
23286 ! CALL energy_quad(istate,eheadtail,Ecl,Egb,Epol,Fisocav,Elj,Equad)
23287 END IF ! this endif ends the "catch the gly-gly" at the beggining of Fcav
23288 evdw = evdw + Fcav + eheadtail
23290 IF (energy_dec) write (iout,'(2(1x,a3,i3),3f6.2,10f16.7)') &
23291 restyp(itype(i,1),1),i,restyp(itype(j,1),1),j,&
23292 1.0d0/rij,Rtail,Rhead,evdwij,Fcav,Ecl,Egb,Epol,Fisocav,Elj,&
23293 Equad,evdwij+Fcav+eheadtail,evdw
23294 ! evdw = evdw + Fcav + eheadtail
23296 ! iF (nstate(itypi,itypj).eq.1) THEN
23299 !c!-------------------------------------------------------------------
23303 !c write (iout,*) "Number of loop steps in EGB:",ind
23304 !c energy_dec=.false.
23305 ! print *,"EVDW KURW",evdw,nres
23308 do i=ibond_start,ibond_end
23310 ! print *,"I am in EVDW",i
23311 itypi=10 ! the peptide group parameters are for glicine
23313 ! if (i.ne.47) cycle
23314 if ((itype(i,1).eq.ntyp1).or.itype(i+1,1).eq.ntyp1) cycle
23315 itypi1=iabs(itype(i+1,1))
23316 xi=(c(1,i)+c(1,i+1))/2.0
23317 yi=(c(2,i)+c(2,i+1))/2.0
23318 zi=(c(3,i)+c(3,i+1))/2.0
23319 call to_box(xi,yi,zi)
23323 dsci_inv=vbld_inv(i+1)/2.0
23324 do j=itmp+1,itmp+nres_molec(5)
23326 ! Calculate SC interaction energy.
23327 itypj=iabs(itype(j,5))
23328 if ((itypj.eq.ntyp1)) cycle
23329 CALL elgrad_init_cat_pep(eheadtail,Egb,Ecl,Elj,Equad,Epol)
23335 call to_box(xj,yj,zj)
23336 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
23338 dxj = 0.0d0! dc_norm( 1, nres+j )
23339 dyj = 0.0d0!dc_norm( 2, nres+j )
23340 dzj = 0.0d0! dc_norm( 3, nres+j )
23344 ! Parameters from fitting the analitical expressions to the PMF obtained by umbrella
23345 ! sampling performed with amber package
23349 ! a12sq = rborn(itypi,itypj) * rborn(itypj,itypi)
23350 chi1 = chi1cat(itypi,itypj)
23351 chis1 = chis1cat(itypi,itypj)
23352 chip1 = chipp1cat(itypi,itypj)
23359 ! chis2 = chis(itypj,itypi)
23360 chis12 = chis1 * chis2
23361 sig1 = sigmap1cat(itypi,itypj)
23362 ! sig2 = sigmap2(itypi,itypj)
23363 ! alpha factors from Fcav/Gcav
23364 b1cav = alphasurcat(1,itypi,itypj)
23365 b2cav = alphasurcat(2,itypi,itypj)
23366 b3cav = alphasurcat(3,itypi,itypj)
23367 b4cav = alphasurcat(4,itypi,itypj)
23369 ! used to determine whether we want to do quadrupole calculations
23370 eps_in = epsintabcat(itypi,itypj)
23371 if (eps_in.eq.0.0) eps_in=1.0
23373 eps_inout_fac = ( (1.0d0/eps_in) - (1.0d0/eps_out))
23377 ctail(k,1)=(c(k,i)+c(k,i+1))/2.0
23380 !c! tail distances will be themselves usefull elswhere
23381 !c1 (in Gcav, for example)
23382 Rtail_distance(1) = ctail( 1, 2 ) - ctail( 1,1 )
23383 Rtail_distance(2) = ctail( 2, 2 ) - ctail( 2,1 )
23384 Rtail_distance(3) = ctail( 3, 2 ) - ctail( 3,1 )
23386 (Rtail_distance(1)*Rtail_distance(1)) &
23387 + (Rtail_distance(2)*Rtail_distance(2)) &
23388 + (Rtail_distance(3)*Rtail_distance(3)))
23389 ! tail location and distance calculations
23391 d1 = dheadcat(1, 1, itypi, itypj)
23394 ! d2 = dhead(2, 1, itypi, itypj)
23396 ! location of polar head is computed by taking hydrophobic centre
23397 ! and moving by a d1 * dc_norm vector
23398 ! see unres publications for very informative images
23399 chead(k,1) = (c(k, i)+c(k,i+1))/2.0 + d1 * dc_norm(k, i)
23400 chead(k,2) = c(k, j)
23402 ! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
23403 ! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
23404 Rhead_distance(k) = chead(k,2) - chead(k,1)
23406 ! pitagoras (root of sum of squares)
23408 (Rhead_distance(1)*Rhead_distance(1)) &
23409 + (Rhead_distance(2)*Rhead_distance(2)) &
23410 + (Rhead_distance(3)*Rhead_distance(3)))
23411 !-------------------------------------------------------------------
23412 ! zero everything that should be zero'ed
23430 dscj_inv = vbld_inv(j+nres)
23431 ! print *,i,j,dscj_inv,dsci_inv
23432 ! rij holds 1/(distance of Calpha atoms)
23433 rrij = 1.0D0 / ( xj*xj + yj*yj + zj*zj)
23436 ! this should be in elgrad_init but om's are calculated by sc_angular
23437 ! which in turn is used by older potentials
23438 ! om = omega, sqom = om^2
23441 sqom12 = om12 * om12
23443 ! now we calculate EGB - Gey-Berne
23444 ! It will be summed up in evdwij and saved in evdw
23445 sigsq = 1.0D0 / sigsq
23446 sig = sig0ij * dsqrt(sigsq)
23447 ! rij_shift = 1.0D0 / rij - sig + sig0ij
23448 rij_shift = Rtail - sig + sig0ij
23449 IF (rij_shift.le.0.0D0) THEN
23453 sigder = -sig * sigsq
23454 rij_shift = 1.0D0 / rij_shift
23455 fac = rij_shift**expon
23456 c1 = fac * fac * aa_aq_cat(itypi,itypj)
23457 ! print *,"ADAM",aa_aq(itypi,itypj)
23460 c2 = fac * bb_aq_cat(itypi,itypj)
23462 evdwij = eps1 * eps2rt * eps3rt * ( c1 + c2 )
23463 eps2der = eps3rt * evdwij
23464 eps3der = eps2rt * evdwij
23465 ! evdwij = 4.0d0 * eps2rt * eps3rt * evdwij
23466 evdwij = eps2rt * eps3rt * evdwij
23468 ! IF (bb_aq(itypi,itypj).gt.0) THEN
23469 ! evdw_p = evdw_p + evdwij
23471 ! evdw_m = evdw_m + evdwij
23477 c1 = c1 * eps1 * eps2rt**2 * eps3rt**2
23478 fac = -expon * (c1 + evdwij) * rij_shift
23479 sigder = fac * sigder
23480 ! Calculate distance derivative
23485 fac = chis1 * sqom1 + chis2 * sqom2 &
23486 - 2.0d0 * chis12 * om1 * om2 * om12
23488 pom = 1.0d0 - chis1 * chis2 * sqom12
23489 ! print *,"TUT2",fac,chis1,sqom1,pom
23490 Lambf = (1.0d0 - (fac / pom))
23491 Lambf = dsqrt(Lambf)
23492 sparrow = 1.0d0 / dsqrt(sig1**2.0d0 + sig2**2.0d0)
23493 Chif = Rtail * sparrow
23494 ChiLambf = Chif * Lambf
23495 eagle = dsqrt(ChiLambf)
23496 bat = ChiLambf ** 11.0d0
23497 top = b1cav * ( eagle + b2cav * ChiLambf - b3cav )
23498 bot = 1.0d0 + b4cav * (ChiLambf ** 12.0d0)
23502 dtop = b1cav * ((Lambf / (2.0d0 * eagle)) + (b2cav * Lambf))
23503 dbot = 12.0d0 * b4cav * bat * Lambf
23504 dFdR = ((dtop * bot - top * dbot) / botsq) * sparrow
23506 dtop = b1cav * ((Chif / (2.0d0 * eagle)) + (b2cav * Chif))
23507 dbot = 12.0d0 * b4cav * bat * Chif
23508 eagle = Lambf * pom
23509 dFdOM1 = -(chis1 * om1 - chis12 * om2 * om12) / (eagle)
23510 dFdOM2 = -(chis2 * om2 - chis12 * om1 * om12) / (eagle)
23511 dFdOM12 = chis12 * (chis1 * om1 * om12 - om2) &
23512 * (chis2 * om2 * om12 - om1) / (eagle * pom)
23514 dFdL = ((dtop * bot - top * dbot) / botsq)
23515 dCAVdOM1 = dFdL * ( dFdOM1 )
23516 dCAVdOM2 = dFdL * ( dFdOM2 )
23517 dCAVdOM12 = dFdL * ( dFdOM12 )
23520 ertail(k) = Rtail_distance(k)/Rtail
23522 erdxi = scalar( ertail(1), dC_norm(1,i) )
23523 erdxj = scalar( ertail(1), dC_norm(1,j) )
23524 facd1 = dtailcat(1,itypi,itypj) * vbld_inv(i)
23525 facd2 = dtailcat(2,itypi,itypj) * vbld_inv(j+nres)
23527 pom = ertail(k)-facd1*(ertail(k)-erdxi*dC_norm(k,i))
23528 ! gradpepcatx(k,i) = gradpepcatx(k,i) &
23529 ! - (( dFdR + gg(k) ) * pom)
23530 pom = ertail(k)-facd2*(ertail(k)-erdxj*dC_norm(k,j+nres))
23531 ! gvdwx(k,j) = gvdwx(k,j) &
23532 ! + (( dFdR + gg(k) ) * pom)
23533 gradpepcat(k,i) = gradpepcat(k,i) &
23534 - (( dFdR + gg(k) ) * ertail(k))/2.0d0
23535 gradpepcat(k,i+1) = gradpepcat(k,i+1) &
23536 - (( dFdR + gg(k) ) * ertail(k))/2.0d0
23538 gradpepcat(k,j) = gradpepcat(k,j) &
23539 + (( dFdR + gg(k) ) * ertail(k))
23542 !c! Compute head-head and head-tail energies for each state
23544 !c! Dipole-charge interactions
23545 if ((itype(i,1).eq.27).or.(itype(i,1).eq.26).or.(itype(i,1).eq.25)) then
23549 if ((itype(j,1).eq.27).or.(itype(j,1).eq.26).or.(itype(j,1).eq.25)) then
23553 CALL edq_cat_pep(ecl, elj, epol)
23554 eheadtail = ECL + elj + epol
23555 ! print *,"i,",i,eheadtail
23556 ! eheadtail = 0.0d0
23558 evdw = evdw + Fcav + eheadtail
23560 IF (energy_dec) write (iout,'(2(1x,a3,i3),3f6.2,10f16.7)') &
23561 restyp(itype(i,1),1),i,restyp(itype(j,1),1),j,&
23562 1.0d0/rij,Rtail,Rhead,evdwij,Fcav,Ecl,Egb,Epol,Fisocav,Elj,&
23563 Equad,evdwij+Fcav+eheadtail,evdw
23564 ! evdw = evdw + Fcav + eheadtail
23566 ! iF (nstate(itypi,itypj).eq.1) THEN
23567 CALL sc_grad_cat_pep
23569 !c!-------------------------------------------------------------------
23573 !c write (iout,*) "Number of loop steps in EGB:",ind
23574 !c energy_dec=.false.
23575 ! print *,"EVDW KURW",evdw,nres
23579 end subroutine ecats_prot_amber
23581 !---------------------------------------------------------------------------
23583 subroutine ecat_prot(ecation_prot)
23586 integer i,j,k,subchap,itmp,inum
23587 real(kind=8) :: xi,yi,zi,xj,yj,zj,ract,rcat0,epscalc,r06,r012,&
23588 r7,r4,ecationcation
23589 real(kind=8) xj_temp,yj_temp,zj_temp,xj_safe,yj_safe,zj_safe, &
23590 dist_init,dist_temp,ecation_prot,rcal,rocal, &
23591 Evan1,Evan2,EC,cm1mag,DASGL,delta,r0p,Epepcat, &
23592 catl,cml,calpl, Etotal_p, Etotal_m,rtab,wdip,wmodquad,wquad1, &
23593 wquad2,wvan1,E1,E2,wconst,wvan2,rcpm,dcmag,sin2thet,sinthet, &
23594 costhet,v1m,v2m,wh2o,wc,rsecp,Ir,Irsecp,Irthrp,Irfourp,Irfiftp,&
23595 Irsistp,Irseven,Irtwelv,Irthir,dE1dr,dE2dr,dEdcos,wquad2p,opt, &
23596 rs,rthrp,rfourp,rsixp,reight,Irsixp,Ireight,Irtw,Irfourt, &
23597 opt1,opt2,opt3,opt4,opt5,opt6,opt7,opt8,opt9,opt10,opt11,opt12,&
23598 opt13,opt14,opt15,opt16,opt17,opt18,opt19, &
23599 Equad1,Equad2,dscmag,v1dpv2,dscmag3,constA,constB,Edip,&
23601 real(kind=8),dimension(3) ::dEvan1Cmcat,dEvan2Cmcat,dEeleccat,&
23602 gg,r,EtotalCat,dEtotalCm,dEtotalCalp,dEvan1Cm,dEvan2Cm, &
23603 dEtotalpep,dEtotalcat_num,dEddci,dEtotalcm_num,dEtotalcalp_num, &
23604 tab1,tab2,tab3,diff,cm1,sc,p,tcat,talp,cm,drcp,drcp_norm,vcat, &
23605 v1,v2,v3,myd_norm,dx,vcm,valpha,drdpep,dcosdpep,dcosddci,dEdpep,&
23606 dEcCat,dEdipCm,dEdipCalp,dEquad1Cat,dEquad1Cm,dEquad1Calp, &
23607 dEquad2Cat,dEquad2Cm,dEquad2Calpd,Evan1Cat,dEvan1Calp,dEvan2Cat,&
23608 dEvan2Calp,dEtotalCat,dscvec,dEcCm,dEcCalp,dEdipCat,dEquad2Calp,&
23610 real(kind=8),dimension(6) :: vcatprm
23612 ! first lets calculate interaction with peptide groups
23613 if (nres_molec(5).eq.0) return
23616 itmp=itmp+nres_molec(i)
23618 ! do i=1,nres_molec(1)-1 ! loop over all peptide groups needs parralelization
23619 do i=ibond_start,ibond_end
23621 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1)) cycle ! leave dummy atoms
23622 xi=0.5d0*(c(1,i)+c(1,i+1))
23623 yi=0.5d0*(c(2,i)+c(2,i+1))
23624 zi=0.5d0*(c(3,i)+c(3,i+1))
23625 call to_box(xi,yi,zi)
23627 do j=itmp+1,itmp+nres_molec(5)
23628 ! print *,"WTF",itmp,j,i
23629 ! all parameters were for Ca2+ to approximate single charge divide by two
23631 if ((itype(j,5).eq.1).or.(itype(j,5).eq.3)) ndiv=2.0
23633 wdip =1.092777950857032D2
23635 wmodquad=-2.174122713004870D4
23636 wmodquad=wmodquad/wconst
23637 wquad1 = 3.901232068562804D1
23638 wquad1=wquad1/wconst
23640 wquad2=wquad2/wconst
23648 call to_box(xj,yj,zj)
23649 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
23652 rcpm = sqrt(xj**2+yj**2+zj**2)
23653 drcp_norm(1)=xj/rcpm
23654 drcp_norm(2)=yj/rcpm
23655 drcp_norm(3)=zj/rcpm
23658 dcmag=dcmag+dc(k,i)**2
23662 myd_norm(k)=dc(k,i)/dcmag
23664 costhet=drcp_norm(1)*myd_norm(1)+drcp_norm(2)*myd_norm(2)+&
23665 drcp_norm(3)*myd_norm(3)
23668 Irsecp = 1.0d0/rsecp
23669 Irthrp = Irsecp/rcpm
23670 Irfourp = Irthrp/rcpm
23671 Irfiftp = Irfourp/rcpm
23672 Irsistp=Irfiftp/rcpm
23673 Irseven=Irsistp/rcpm
23674 Irtwelv=Irsistp*Irsistp
23675 Irthir=Irtwelv/rcpm
23676 sin2thet = (1-costhet*costhet)
23677 sinthet=sqrt(sin2thet)
23678 E1 = wdip*Irsecp*costhet+(wmodquad*Irfourp+wquad1*Irthrp)&
23680 E2 = -wquad1*Irthrp*wquad2+wvan1*(wvan2**12*Irtwelv-&
23681 2*wvan2**6*Irsistp)
23682 ecation_prot = ecation_prot+E1+E2
23683 ! print *,"ecatprot",i,j,ecation_prot,rcpm
23684 dE1dr = -2*costhet*wdip*Irthrp-&
23685 (4*wmodquad*Irfiftp+3*wquad1*Irfourp)*sin2thet
23686 dE2dr = 3*wquad1*wquad2*Irfourp- &
23687 12*wvan1*wvan2**6*(wvan2**6*Irthir-Irseven)
23688 dEdcos = wdip*Irsecp-2*(wmodquad*Irfourp+wquad1*Irthrp)*costhet
23690 drdpep(k) = -drcp_norm(k)
23691 dcosdpep(k) = Ir*(costhet*drcp_norm(k)-myd_norm(k))
23692 dcosddci(k) = drcp_norm(k)/dcmag-costhet*myd_norm(k)/dcmag
23693 dEdpep(k) = (dE1dr+dE2dr)*drdpep(k)+dEdcos*dcosdpep(k)
23694 dEddci(k) = dEdcos*dcosddci(k)
23697 gradpepcat(k,i)=gradpepcat(k,i)+0.5D0*dEdpep(k)-dEddci(k)
23698 gradpepcat(k,i+1)=gradpepcat(k,i+1)+0.5D0*dEdpep(k)+dEddci(k)
23699 gradpepcat(k,j)=gradpepcat(k,j)-dEdpep(k)
23703 !------------------------------------------sidechains
23704 ! do i=1,nres_molec(1)
23705 do i=ibond_start,ibond_end
23706 if ((itype(i,1).eq.ntyp1)) cycle ! leave dummy atoms
23708 ! print *,i,ecation_prot
23712 call to_box(xi,yi,zi)
23714 cm1(k)=dc(k,i+nres)
23716 cm1mag=sqrt(cm1(1)**2+cm1(2)**2+cm1(3)**2)
23717 do j=itmp+1,itmp+nres_molec(5)
23719 if ((itype(j,5).eq.1).or.(itype(j,5).eq.3)) ndiv=2.0
23724 call to_box(xj,yj,zj)
23725 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
23729 if((itype(i,1).eq.15.or.itype(i,1).eq.16).or.&
23730 ((itype(i,1).eq.27).or.(itype(i,1).eq.26).or.&
23731 (itype(i,1).eq.25))) then
23732 if(itype(i,1).eq.16) then
23738 vcatprm(k)=catprm(k,inum)
23740 dASGL=catprm(7,inum)
23742 ! vcm(k)=(cm1(k)/cm1mag)*dASGL+c(k,i+nres)
23743 vcm(1)=(cm1(1)/cm1mag)*dASGL+xi
23744 vcm(2)=(cm1(2)/cm1mag)*dASGL+yi
23745 vcm(3)=(cm1(3)/cm1mag)*dASGL+zi
23749 if (subchap.eq.1) then
23758 valpha(1)=xi-c(1,i+nres)+c(1,i)
23759 valpha(2)=yi-c(2,i+nres)+c(2,i)
23760 valpha(3)=zi-c(3,i+nres)+c(3,i)
23764 dx(k) = vcat(k)-vcm(k)
23767 v1(k)=(vcm(k)-valpha(k))
23768 v2(k)=(vcat(k)-valpha(k))
23770 v1m = sqrt(v1(1)**2+v1(2)**2+v1(3)**2)
23771 v2m = sqrt(v2(1)**2+v2(2)**2+v2(3)**2)
23772 v1dpv2 = v1(1)*v2(1)+v1(2)*v2(2)+v1(3)*v2(3)
23774 ! The weights of the energy function calculated from
23775 !The quantum mechanical GAMESS simulations of calcium with ASP/GLU
23776 if ((itype(i,1).eq.27).or.(itype(i,1).eq.26).or.(itype(i,1).eq.25)) then
23782 if ((itype(j,5).eq.1).or.(itype(j,5).eq.3)) ndiv=2.0
23791 wquad2 = vcatprm(4)
23793 wquad2p = 1.0d0-wquad2
23796 opt = dx(1)**2+dx(2)**2
23797 rsecp = opt+dx(3)**2
23801 rsixp = rfourp*rsecp
23804 Irsecp = 1.0d0/rsecp
23806 Irfourp = Irthrp/rs
23807 Irsixp = 1.0d0/rsixp
23808 Ireight=1.0d0/reight
23812 opt1 = (4*rs*dx(3)*wdip)
23813 opt2 = 6*rsecp*wquad1*opt
23814 opt3 = wquad1*wquad2p*Irsixp
23815 opt4 = (wvan1*wvan2**12)
23816 opt5 = opt4*12*Irfourt
23817 opt6 = 2*wvan1*wvan2**6
23818 opt7 = 6*opt6*Ireight
23821 opt11 = (rsecp*v2m)**2
23822 opt12 = (rsecp*v1m)**2
23823 opt14 = (v1m*v2m*rsecp)**2
23824 opt15 = -wquad1/v2m**2
23825 opt16 = (rthrp*(v1m*v2m)**2)**2
23826 opt17 = (v1m**2*rthrp)**2
23827 opt18 = -wquad1/rthrp
23828 opt19 = (v1m**2*v2m**2)**2
23831 dEcCat(k) = -(dx(k)*wc)*Irthrp
23832 dEcCm(k)=(dx(k)*wc)*Irthrp
23835 Edip=opt8*(v1dpv2)/(rsecp*v2m)
23837 dEdipCat(k)=opt8*(v1(k)*rsecp*v2m-((v2(k)/v2m &
23838 *rsecp+2*dx(k)*v2m)*v1dpv2))/opt11
23839 dEdipCm(k)=opt10*(v2(k)*rsecp*v1m-((v1(k)/v1m &
23840 *rsecp-2*dx(k)*v1m)*v1dpv2))/opt12
23841 dEdipCalp(k)=wdip*((-v1(k)-v2(k))*rsecp*v1m &
23842 *v2m-(-v1(k)/v1m*v2m*rsecp-v2(k)/v2m*v1m*rsecp) &
23845 Equad1=-wquad1*v1dpv2**2/(rthrp*(v1m*v2m)**2)
23847 dEquad1Cat(k)=-wquad1*(2*v1(k)*v1dpv2*(rthrp* &
23848 (v1m*v2m)**2)-(3*dx(k)*rs*(v1m*v2m)**2+2*v1m*2* &
23849 v2(k)*1/2*1/v2m*v1m*v2m*rthrp)*v1dpv2**2)/opt16
23850 dEquad1Cm(k)=-wquad1*(2*v2(k)*v1dpv2*(rthrp* &
23851 (v1m*v2m)**2)-(-3*dx(k)*rs*(v1m*v2m)**2+2*v2m*2* &
23852 v1(k)*1/2*1/v1m*v2m*v1m*rthrp)*v1dpv2**2)/opt16
23853 dEquad1Calp(k)=opt18*(2*(-v1(k)-v2(k))*v1dpv2* &
23854 v1m**2*v2m**2-(-2*v1(k)*v2m**2-2*v2(k)*v1m**2)* &
23857 Equad2=wquad1*wquad2p*Irthrp
23859 dEquad2Cat(k)=-3*dx(k)*rs*opt3
23860 dEquad2Cm(k)=3*dx(k)*rs*opt3
23861 dEquad2Calp(k)=0.0d0
23865 dEvan1Cat(k)=-dx(k)*opt5
23866 dEvan1Cm(k)=dx(k)*opt5
23867 dEvan1Calp(k)=0.0d0
23871 dEvan2Cat(k)=dx(k)*opt7
23872 dEvan2Cm(k)=-dx(k)*opt7
23873 dEvan2Calp(k)=0.0d0
23875 ecation_prot=ecation_prot+Ec+Edip+Equad1+Equad2+Evan1+Evan2
23876 ! print *,ecation_prot,Ec+Edip+Equad1+Equad2+Evan1+Evan2
23879 dEtotalCat(k)=dEcCat(k)+dEdipCat(k)+dEquad1Cat(k)+ &
23880 dEquad2Cat(k)+dEvan1Cat(k)+dEvan2Cat(k)
23881 !c write(*,*) 'dEtotalCat inside', (dEtotalCat(l),l=1,3)
23882 dEtotalCm(k)=dEcCm(k)+dEdipCm(k)+dEquad1Cm(k)+ &
23883 dEquad2Cm(k)+dEvan1Cm(k)+dEvan2Cm(k)
23884 dEtotalCalp(k)=dEcCalp(k)+dEdipCalp(k)+dEquad1Calp(k) &
23885 +dEquad2Calp(k)+dEvan1Calp(k)+dEvan2Calp(k)
23889 dscvec(k) = dc(k,i+nres)
23890 dscmag = dscmag+dscvec(k)*dscvec(k)
23893 dscmag = sqrt(dscmag)
23894 dscmag3 = dscmag3*dscmag
23895 constA = 1.0d0+dASGL/dscmag
23898 constB = constB+dscvec(k)*dEtotalCm(k)
23900 constB = constB*dASGL/dscmag3
23902 gg(k) = dEtotalCm(k)+dEtotalCalp(k)
23903 gradpepcatx(k,i)=gradpepcatx(k,i)+ &
23904 constA*dEtotalCm(k)-constB*dscvec(k)
23905 ! print *,j,constA,dEtotalCm(k),constB,dscvec(k)
23906 gradpepcat(k,i)=gradpepcat(k,i)+gg(k)
23907 gradpepcat(k,j)=gradpepcat(k,j)+dEtotalCat(k)
23909 else if (itype(i,1).eq.13.or.itype(i,1).eq.14) then
23910 if(itype(i,1).eq.14) then
23916 vcatprm(k)=catprm(k,inum)
23918 dASGL=catprm(7,inum)
23920 ! vcm(k)=(cm1(k)/cm1mag)*dASGL+c(k,i+nres)
23924 vcm(1)=(cm1(1)/cm1mag)*dASGL+xi
23925 vcm(2)=(cm1(2)/cm1mag)*dASGL+yi
23926 vcm(3)=(cm1(3)/cm1mag)*dASGL+zi
23927 if (subchap.eq.1) then
23936 valpha(1)=xi-c(1,i+nres)+c(1,i)
23937 valpha(2)=yi-c(2,i+nres)+c(2,i)
23938 valpha(3)=zi-c(3,i+nres)+c(3,i)
23942 dx(k) = vcat(k)-vcm(k)
23945 v1(k)=(vcm(k)-valpha(k))
23946 v2(k)=(vcat(k)-valpha(k))
23948 v1m = sqrt(v1(1)**2+v1(2)**2+v1(3)**2)
23949 v2m = sqrt(v2(1)**2+v2(2)**2+v2(3)**2)
23950 v1dpv2 = v1(1)*v2(1)+v1(2)*v2(2)+v1(3)*v2(3)
23951 ! The weights of the energy function calculated from
23952 !The quantum mechanical GAMESS simulations of ASN/GLN with calcium
23954 if ((itype(j,5).eq.1).or.(itype(j,5).eq.3)) ndiv=2.0
23961 wquad2 = vcatprm(4)
23966 opt = dx(1)**2+dx(2)**2
23967 rsecp = opt+dx(3)**2
23971 rsixp = rfourp*rsecp
23976 Irfourp = Irthrp/rs
23982 opt1 = (4*rs*dx(3)*wdip)
23983 opt2 = 6*rsecp*wquad1*opt
23984 opt3 = wquad1*wquad2p*Irsixp
23985 opt4 = (wvan1*wvan2**12)
23986 opt5 = opt4*12*Irfourt
23987 opt6 = 2*wvan1*wvan2**6
23988 opt7 = 6*opt6*Ireight
23991 opt11 = (rsecp*v2m)**2
23992 opt12 = (rsecp*v1m)**2
23993 opt14 = (v1m*v2m*rsecp)**2
23994 opt15 = -wquad1/v2m**2
23995 opt16 = (rthrp*(v1m*v2m)**2)**2
23996 opt17 = (v1m**2*rthrp)**2
23997 opt18 = -wquad1/rthrp
23998 opt19 = (v1m**2*v2m**2)**2
23999 Edip=opt8*(v1dpv2)/(rsecp*v2m)
24001 dEdipCat(k)=opt8*(v1(k)*rsecp*v2m-((v2(k)/v2m&
24002 *rsecp+2*dx(k)*v2m)*v1dpv2))/opt11
24003 dEdipCm(k)=opt10*(v2(k)*rsecp*v1m-((v1(k)/v1m&
24004 *rsecp-2*dx(k)*v1m)*v1dpv2))/opt12
24005 dEdipCalp(k)=wdip*((-v1(k)-v2(k))*rsecp*v1m&
24006 *v2m-(-v1(k)/v1m*v2m*rsecp-v2(k)/v2m*v1m*rsecp)&
24009 Equad1=-wquad1*v1dpv2**2/(rthrp*(v1m*v2m)**2)
24011 dEquad1Cat(k)=-wquad1*(2*v1(k)*v1dpv2*(rthrp*&
24012 (v1m*v2m)**2)-(3*dx(k)*rs*(v1m*v2m)**2+2*v1m*2*&
24013 v2(k)*1/2*1/v2m*v1m*v2m*rthrp)*v1dpv2**2)/opt16
24014 dEquad1Cm(k)=-wquad1*(2*v2(k)*v1dpv2*(rthrp*&
24015 (v1m*v2m)**2)-(-3*dx(k)*rs*(v1m*v2m)**2+2*v2m*2*&
24016 v1(k)*1/2*1/v1m*v2m*v1m*rthrp)*v1dpv2**2)/opt16
24017 dEquad1Calp(k)=opt18*(2*(-v1(k)-v2(k))*v1dpv2* &
24018 v1m**2*v2m**2-(-2*v1(k)*v2m**2-2*v2(k)*v1m**2)*&
24021 Equad2=wquad1*wquad2p*Irthrp
24023 dEquad2Cat(k)=-3*dx(k)*rs*opt3
24024 dEquad2Cm(k)=3*dx(k)*rs*opt3
24025 dEquad2Calp(k)=0.0d0
24029 dEvan1Cat(k)=-dx(k)*opt5
24030 dEvan1Cm(k)=dx(k)*opt5
24031 dEvan1Calp(k)=0.0d0
24035 dEvan2Cat(k)=dx(k)*opt7
24036 dEvan2Cm(k)=-dx(k)*opt7
24037 dEvan2Calp(k)=0.0d0
24039 ecation_prot = ecation_prot+Edip+Equad1+Equad2+Evan1+Evan2
24041 dEtotalCat(k)=dEdipCat(k)+dEquad1Cat(k)+ &
24042 dEquad2Cat(k)+dEvan1Cat(k)+dEvan2Cat(k)
24043 dEtotalCm(k)=dEdipCm(k)+dEquad1Cm(k)+ &
24044 dEquad2Cm(k)+dEvan1Cm(k)+dEvan2Cm(k)
24045 dEtotalCalp(k)=dEdipCalp(k)+dEquad1Calp(k) &
24046 +dEquad2Calp(k)+dEvan1Calp(k)+dEvan2Calp(k)
24050 dscvec(k) = c(k,i+nres)-c(k,i)
24056 dscmag = dscmag+dscvec(k)*dscvec(k)
24059 dscmag = sqrt(dscmag)
24060 dscmag3 = dscmag3*dscmag
24061 constA = 1+dASGL/dscmag
24064 constB = constB+dscvec(k)*dEtotalCm(k)
24066 constB = constB*dASGL/dscmag3
24068 gg(k) = dEtotalCm(k)+dEtotalCalp(k)
24069 gradpepcatx(k,i)=gradpepcatx(k,i)+ &
24070 constA*dEtotalCm(k)-constB*dscvec(k)
24071 gradpepcat(k,i)=gradpepcat(k,i)+gg(k)
24072 gradpepcat(k,j)=gradpepcat(k,j)+dEtotalCat(k)
24077 ! r(k) = c(k,j)-c(k,i+nres)
24081 rcal = rcal+r(k)*r(k)
24086 r0p=0.5*(rocal+sig0(itype(i,1)))
24089 Evan1=epscalc*(r012/rcal**6)
24090 Evan2=epscalc*2*(r06/rcal**3)
24094 dEvan1Cm(k) = 12*r(k)*epscalc*r012/r7
24095 dEvan2Cm(k) = 12*r(k)*epscalc*r06/r4
24098 dEtotalCm(k)=dEvan1Cm(k)+dEvan2Cm(k)
24100 ecation_prot = ecation_prot+ Evan1+Evan2
24102 gradpepcatx(k,i)=gradpepcatx(k,i)+ &
24104 gradpepcat(k,i)=gradpepcat(k,i)+dEtotalCm(k)
24105 gradpepcat(k,j)=gradpepcat(k,j)-dEtotalCm(k)
24107 endif ! 13-16 residues
24111 end subroutine ecat_prot
24113 !----------------------------------------------------------------------------
24114 !---------------------------------------------------------------------------
24115 subroutine ecat_nucl(ecation_nucl)
24116 integer i,j,k,subchap,itmp,inum,itypi,itypj
24117 real(kind=8) :: xi,yi,zi,xj,yj,zj
24118 real(kind=8) xj_temp,yj_temp,zj_temp,xj_safe,yj_safe,zj_safe, &
24119 dist_init,dist_temp,ecation_nucl,Evan1,Evan2,Ecav,Egb,wdip1,wdip2, &
24120 wvan1,wvan2,wgbsig,wgbeps,wgbchi,wgbchip,wcav1,wcav2,wcav3,wcav4, &
24121 wcavsig,wcavchi,v1m,v1dpdx,wh2o,wc,Edip,rcs2,invrcs6,invrcs8,invrcs12, &
24122 invrcs14,rcb,rcb2,invrcb,invrcb2,invrcb4,invrcb6,cosinus,cos2,dcosdcatconst, &
24123 dcosdcalpconst,dcosdcmconst,rcav,rcav11,rcav12,constcav1,constcav2, &
24124 constgb1,constgb2,constdvan1,constdvan2,sgb,sgb6,sgb7,sgb12,sgb13, &
24125 cavnum,cavdenom,invcavdenom2,dcavnumdcos,dcavnumdr,dcavdenomdcos, &
24126 dcavdenomdr,sslipi,ssgradlipi,sslipj,ssgradlipj,aa,bb
24127 real(kind=8),dimension(3) ::gg,r,dEtotalCm,dEtotalCalp,dEvan1Cm,&
24128 dEvan2Cm,cm1,cm,vcat,vsug,v1,v2,dx,vcm,dEdipCm,dEdipCalp, &
24129 dEvan1Calp,dEvan2Cat,dEvan2Calp,dEtotalCat,dEdipCat,dEvan1Cat,dcosdcat, &
24130 dcosdcalp,dcosdcm,dEgbdCat,dEgbdCalp,dEgbdCm,dEcavdCat,dEcavdCalp, &
24132 real(kind=8),dimension(14) :: vcatnuclprm
24134 if (nres_molec(5).eq.0) return
24137 itmp=itmp+nres_molec(i)
24139 do i=iatsc_s_nucl,iatsc_e_nucl
24140 if ((itype(i,2).eq.ntyp1_molec(2))) cycle ! leave dummy atoms
24144 call to_box(xi,yi,zi)
24145 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
24147 cm1(k)=dc(k,i+nres)
24149 do j=itmp+1,itmp+nres_molec(5)
24153 call to_box(xj,yj,zj)
24154 ! call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
24155 ! aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
24156 ! +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
24157 ! bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
24158 ! +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
24159 xj=boxshift(xj-xi,boxxsize)
24160 yj=boxshift(yj-yi,boxysize)
24161 zj=boxshift(zj-zi,boxzsize)
24163 dist_init=xj**2+yj**2+zj**2
24168 vcatnuclprm(k)=catnuclprm(k,itypi,itypj)
24176 dx(k) = vcat(k)-vcm(k)
24180 v2(k)=(vcat(k)-vsug(k))
24182 v1m = sqrt(v1(1)**2+v1(2)**2+v1(3)**2)
24183 v1dpdx = v1(1)*dx(1)+v1(2)*dx(2)+v1(3)*dx(3)
24184 ! The weights of the energy function calculated from
24185 !The quantum mechanical Gaussian simulations of potassium and sodium with deoxynucleosides
24187 wdip1 = vcatnuclprm(1)
24188 wdip1 = wdip1/wh2o !w1
24189 wdip2 = vcatnuclprm(2)
24190 wdip2 = wdip2/wh2o !w2
24191 wvan1 = vcatnuclprm(3)
24192 wvan2 = vcatnuclprm(4) !pis1
24193 wgbsig = vcatnuclprm(5) !sigma0
24194 wgbeps = vcatnuclprm(6) !epsi0
24195 wgbchi = vcatnuclprm(7) !chi1
24196 wgbchip = vcatnuclprm(8) !chip1
24197 wcavsig = vcatnuclprm(9) !sig
24198 wcav1 = vcatnuclprm(10) !b1
24199 wcav2 = vcatnuclprm(11) !b2
24200 wcav3 = vcatnuclprm(12) !b3
24201 wcav4 = vcatnuclprm(13) !b4
24202 wcavchi = vcatnuclprm(14) !chis1
24203 rcs2 = v2(1)**2+v2(2)**2+v2(3)**2
24204 invrcs6 = 1/rcs2**3
24205 invrcs8 = invrcs6/rcs2
24206 invrcs12 = invrcs6**2
24207 invrcs14 = invrcs12/rcs2
24208 rcb2 = dx(1)**2+dx(2)**2+dx(3)**2
24211 invrcb2 = invrcb**2
24212 invrcb4 = invrcb2**2
24213 invrcb6 = invrcb4*invrcb2
24214 cosinus = v1dpdx/(v1m*rcb)
24216 dcosdcatconst = invrcb2/v1m
24217 dcosdcalpconst = invrcb/v1m**2
24218 dcosdcmconst = invrcb2/v1m**2
24220 dcosdcat(k) = (v1(k)*rcb-dx(k)*v1m*cosinus)*dcosdcatconst
24221 dcosdcalp(k) = (v1(k)*rcb*cosinus-dx(k)*v1m)*dcosdcalpconst
24222 dcosdcm(k) = ((dx(k)-v1(k))*v1m*rcb+ &
24223 cosinus*(dx(k)*v1m**2-v1(k)*rcb2))*dcosdcmconst
24227 rcav12 = rcav11*rcav
24228 constcav1 = 1-wcavchi*cos2
24229 constcav2 = sqrt(constcav1)
24230 constgb1 = 1/sqrt(1-wgbchi*cos2)
24231 constgb2 = wgbeps*(1-wgbchip*cos2)**2
24232 constdvan1 = 12*wvan1*wvan2**12*invrcs14
24233 constdvan2 = 6*wvan1*wvan2**6*invrcs8
24234 !----------------------------------------------------------------------------
24236 !---------------------------------------------------------------------------
24237 sgb = 1/(1-constgb1+(rcb/wgbsig))
24242 Egb = constgb2*(sgb12-sgb6)
24244 dEgbdCat(k) = -constgb2/wgbsig*(12*sgb13-6*sgb7)*invrcb*dx(k) &
24245 +(constgb1**3*constgb2*wgbchi*cosinus*(12*sgb13-6*sgb7) &
24246 -4*wgbeps*wgbchip*cosinus*(1-wgbchip*cos2)*(sgb12-sgb6))*dcosdcat(k)
24247 dEgbdCm(k) = constgb2/wgbsig*(12*sgb13-6*sgb7)*invrcb*dx(k) &
24248 +(constgb1**3*constgb2*wgbchi*cosinus*(12*sgb13-6*sgb7) &
24249 -4*wgbeps*wgbchip*cosinus*(1-wgbchip*cos2)*(sgb12-sgb6))*dcosdcm(k)
24250 dEgbdCalp(k) = (constgb1**3*constgb2*wgbchi*cosinus &
24251 *(12*sgb13-6*sgb7) &
24252 -4*wgbeps*wgbchip*cosinus*(1-wgbchip*cos2)*(sgb12-sgb6))*dcosdcalp(k)
24254 !----------------------------------------------------------------------------
24256 !---------------------------------------------------------------------------
24257 cavnum = sqrt(rcav*constcav2)+wcav2*rcav*constcav2-wcav3
24258 cavdenom = 1+wcav4*rcav12*constcav1**6
24259 Ecav = wcav1*cavnum/cavdenom
24260 invcavdenom2 = 1/cavdenom**2
24261 dcavnumdcos = -wcavchi*cosinus/constcav2 &
24262 *(sqrt(rcav/constcav2)/2+wcav2*rcav)
24263 dcavnumdr = (0.5*sqrt(constcav2/rcav)+wcav2*constcav2)/wcavsig
24264 dcavdenomdcos = -12*wcav4*wcavchi*rcav12*constcav1**5*cosinus
24265 dcavdenomdr = 12*wcav4/wcavsig*rcav11*constcav1**6
24267 dEcavdCat(k) = ((dcavnumdcos*cavdenom-dcavdenomdcos*cavnum) &
24268 *dcosdcat(k)+(dcavnumdr*cavdenom-dcavdenomdr*cavnum)/rcb*dx(k))*wcav1*invcavdenom2
24269 dEcavdCm(k) = ((dcavnumdcos*cavdenom-dcavdenomdcos*cavnum) &
24270 *dcosdcm(k)-(dcavnumdr*cavdenom-dcavdenomdr*cavnum)/rcb*dx(k))*wcav1*invcavdenom2
24271 dEcavdCalp(k) = (dcavnumdcos*cavdenom-dcavdenomdcos*cavnum) &
24272 *dcosdcalp(k)*wcav1*invcavdenom2
24274 !----------------------------------------------------------------------------
24275 !van der Waals and dipole-charge interaction energy
24276 !---------------------------------------------------------------------------
24277 Evan1 = wvan1*wvan2**12*invrcs12
24279 dEvan1Cat(k) = -v2(k)*constdvan1
24280 dEvan1Cm(k) = 0.0d0
24281 dEvan1Calp(k) = v2(k)*constdvan1
24283 Evan2 = -wvan1*wvan2**6*invrcs6
24285 dEvan2Cat(k) = v2(k)*constdvan2
24286 dEvan2Cm(k) = 0.0d0
24287 dEvan2Calp(k) = -v2(k)*constdvan2
24289 Edip = wdip1*cosinus*invrcb2-wdip2*(1-cos2)*invrcb4
24291 dEdipCat(k) = (-2*wdip1*cosinus*invrcb4 &
24292 +4*wdip2*(1-cos2)*invrcb6)*dx(k) &
24293 +dcosdcat(k)*(wdip1*invrcb2+2*wdip2*cosinus*invrcb4)
24294 dEdipCm(k) = (2*wdip1*cosinus*invrcb4 &
24295 -4*wdip2*(1-cos2)*invrcb6)*dx(k) &
24296 +dcosdcm(k)*(wdip1*invrcb2+2*wdip2*cosinus*invrcb4)
24297 dEdipCalp(k) = dcosdcalp(k)*(wdip1*invrcb2 &
24298 +2*wdip2*cosinus*invrcb4)
24300 if (energy_dec) write (iout,'(2i5,4(a6,f7.3))') i,j, &
24301 ' E GB ',Egb,' ECav ',Ecav,' Evdw ',Evan1+Evan2,' Edip ',Edip
24302 ecation_nucl=ecation_nucl+Ecav+Egb+Edip+Evan1+Evan2
24304 dEtotalCat(k) = dEcavdCat(k)+dEvan1Cat(k)+dEvan2Cat(k) &
24305 +dEgbdCat(k)+dEdipCat(k)
24306 dEtotalCm(k) = dEcavdCm(k)+dEvan1Cm(k)+dEvan2Cm(k) &
24307 +dEgbdCm(k)+dEdipCm(k)
24308 dEtotalCalp(k) = dEcavdCalp(k)+dEgbdCalp(k)+dEvan1Calp(k) &
24309 +dEdipCalp(k)+dEvan2Calp(k)
24312 gg(k) = dEtotalCm(k)+dEtotalCalp(k)
24313 gradnuclcatx(k,i)=gradnuclcatx(k,i)+dEtotalCm(k)
24314 gradnuclcat(k,i)=gradnuclcat(k,i)+gg(k)
24315 gradnuclcat(k,j)=gradnuclcat(k,j)+dEtotalCat(k)
24320 end subroutine ecat_nucl
24322 !-----------------------------------------------------------------------------
24323 !-----------------------------------------------------------------------------
24324 subroutine eprot_sc_base(escbase)
24326 ! implicit real*8 (a-h,o-z)
24327 ! include 'DIMENSIONS'
24328 ! include 'COMMON.GEO'
24329 ! include 'COMMON.VAR'
24330 ! include 'COMMON.LOCAL'
24331 ! include 'COMMON.CHAIN'
24332 ! include 'COMMON.DERIV'
24333 ! include 'COMMON.NAMES'
24334 ! include 'COMMON.INTERACT'
24335 ! include 'COMMON.IOUNITS'
24336 ! include 'COMMON.CALC'
24337 ! include 'COMMON.CONTROL'
24338 ! include 'COMMON.SBRIDGE'
24340 !el local variables
24341 integer :: iint,itypi,itypi1,itypj,subchap
24342 real(kind=8) :: rrij,xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
24343 real(kind=8) :: evdw,sig0ij
24344 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
24345 dist_temp, dist_init,aa,bb,ssgradlipi,ssgradlipj, &
24346 sslipi,sslipj,faclip
24348 real(kind=8) :: fracinbuf
24349 real (kind=8) :: escbase
24350 real (kind=8),dimension(4):: ener
24351 real(kind=8) :: b1,b2,b3,b4,egb,eps_in,eps_inout_fac,eps_out
24352 real(kind=8) :: ECL,Elj,Equad,Epol,eheadtail,rhead,dGCLOM2,&
24353 sqom1,sqom2,sqom12,c1,c2,c3,pom,Lambf,sparrow,&
24354 Chif,ChiLambf,bat,eagle,top,bot,botsq,Fcav,dtop,dFdR,dFdOM1,&
24355 dFdOM2,w1,w2,w3,dGCLdR,dFdL,dFdOM12,dbot ,&
24356 r1,eps_head,alphapol1,pis,facd2,d2,facd1,d1,erdxj,erdxi,federmaus,&
24357 dPOLdR1,dFGBdOM2,dFGBdR1,dPOLdFGB1,RR1,MomoFac1,hawk,d1i,d1j,&
24358 sig1,sig2,chis12,chis2,ee1,fgb1,a12sq,chis1
24359 real(kind=8),dimension(3,2)::chead,erhead_tail
24360 real(kind=8),dimension(3) :: Rhead_distance,ertail,erhead
24364 ! do i=1,nres_molec(1)
24365 do i=ibond_start,ibond_end
24366 if (itype(i,1).eq.ntyp1_molec(1)) cycle
24368 dxi = dc_norm(1,nres+i)
24369 dyi = dc_norm(2,nres+i)
24370 dzi = dc_norm(3,nres+i)
24371 dsci_inv = vbld_inv(i+nres)
24375 call to_box(xi,yi,zi)
24376 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
24377 do j=nres_molec(1)+1,nres_molec(2)+nres_molec(1)
24379 if (itype(j,2).eq.ntyp1_molec(2))cycle
24383 call to_box(xj,yj,zj)
24384 ! call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
24385 ! aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
24386 ! +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
24387 ! bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
24388 ! +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
24389 xj=boxshift(xj-xi,boxxsize)
24390 yj=boxshift(yj-yi,boxysize)
24391 zj=boxshift(zj-zi,boxzsize)
24393 dxj = dc_norm( 1, nres+j )
24394 dyj = dc_norm( 2, nres+j )
24395 dzj = dc_norm( 3, nres+j )
24396 ! print *,i,j,itypi,itypj
24397 d1i = dhead_scbasei(itypi,itypj) !this is shift of dipole/charge
24398 d1j = dhead_scbasej(itypi,itypj) !this is shift of dipole/charge
24401 ! BetaT = 1.0d0 / (298.0d0 * Rb)
24403 sig0ij = sigma_scbase( itypi,itypj )
24404 chi1 = chi_scbase( itypi, itypj,1 )
24405 chi2 = chi_scbase( itypi, itypj,2 )
24408 chi12 = chi1 * chi2
24409 chip1 = chipp_scbase( itypi, itypj,1 )
24410 chip2 = chipp_scbase( itypi, itypj,2 )
24413 chip12 = chip1 * chip2
24414 ! not used by momo potential, but needed by sc_angular which is shared
24415 ! by all energy_potential subroutines
24419 a12sq = rborn_scbasei(itypi,itypj) * rborn_scbasej(itypi,itypj)
24420 ! a12sq = a12sq * a12sq
24421 ! charge of amino acid itypi is...
24422 chis1 = chis_scbase(itypi,itypj,1)
24423 chis2 = chis_scbase(itypi,itypj,2)
24424 chis12 = chis1 * chis2
24425 sig1 = sigmap1_scbase(itypi,itypj)
24426 sig2 = sigmap2_scbase(itypi,itypj)
24427 ! write (*,*) "sig1 = ", sig1
24428 ! write (*,*) "sig2 = ", sig2
24429 ! alpha factors from Fcav/Gcav
24430 b1 = alphasur_scbase(1,itypi,itypj)
24432 b2 = alphasur_scbase(2,itypi,itypj)
24433 b3 = alphasur_scbase(3,itypi,itypj)
24434 b4 = alphasur_scbase(4,itypi,itypj)
24435 ! used to determine whether we want to do quadrupole calculations
24437 eps_in = epsintab_scbase(itypi,itypj)
24438 if (eps_in.eq.0.0) eps_in=1.0
24439 eps_inout_fac = ( (1.0d0/eps_in) - (1.0d0/eps_out))
24440 ! write (*,*) "eps_inout_fac = ", eps_inout_fac
24441 !-------------------------------------------------------------------
24442 ! tail location and distance calculations
24444 ! location of polar head is computed by taking hydrophobic centre
24445 ! and moving by a d1 * dc_norm vector
24446 ! see unres publications for very informative images
24447 chead(k,1) = c(k, i+nres) + d1i * dc_norm(k, i+nres)
24448 chead(k,2) = c(k, j+nres) + d1j * dc_norm(k, j+nres)
24450 ! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
24451 ! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
24452 Rhead_distance(k) = chead(k,2) - chead(k,1)
24454 ! pitagoras (root of sum of squares)
24456 (Rhead_distance(1)*Rhead_distance(1)) &
24457 + (Rhead_distance(2)*Rhead_distance(2)) &
24458 + (Rhead_distance(3)*Rhead_distance(3)))
24459 !-------------------------------------------------------------------
24460 ! zero everything that should be zero'ed
24478 dscj_inv = vbld_inv(j+nres)
24479 ! print *,i,j,dscj_inv,dsci_inv
24480 ! rij holds 1/(distance of Calpha atoms)
24481 rrij = 1.0D0 / ( xj*xj + yj*yj + zj*zj)
24483 !----------------------------
24485 ! this should be in elgrad_init but om's are calculated by sc_angular
24486 ! which in turn is used by older potentials
24487 ! om = omega, sqom = om^2
24490 sqom12 = om12 * om12
24492 ! now we calculate EGB - Gey-Berne
24493 ! It will be summed up in evdwij and saved in evdw
24494 sigsq = 1.0D0 / sigsq
24495 sig = sig0ij * dsqrt(sigsq)
24496 ! rij_shift = 1.0D0 / rij - sig + sig0ij
24497 rij_shift = 1.0/rij - sig + sig0ij
24498 IF (rij_shift.le.0.0D0) THEN
24502 sigder = -sig * sigsq
24503 rij_shift = 1.0D0 / rij_shift
24504 fac = rij_shift**expon
24505 c1 = fac * fac * aa_scbase(itypi,itypj)
24507 c2 = fac * bb_scbase(itypi,itypj)
24509 evdwij = eps1 * eps2rt * eps3rt * ( c1 + c2 )
24510 eps2der = eps3rt * evdwij
24511 eps3der = eps2rt * evdwij
24512 ! evdwij = 4.0d0 * eps2rt * eps3rt * evdwij
24513 evdwij = eps2rt * eps3rt * evdwij
24514 c1 = c1 * eps1 * eps2rt**2 * eps3rt**2
24515 fac = -expon * (c1 + evdwij) * rij_shift
24516 sigder = fac * sigder
24518 ! Calculate distance derivative
24522 ! if (b2.gt.0.0) then
24523 fac = chis1 * sqom1 + chis2 * sqom2 &
24524 - 2.0d0 * chis12 * om1 * om2 * om12
24525 ! we will use pom later in Gcav, so dont mess with it!
24526 pom = 1.0d0 - chis1 * chis2 * sqom12
24527 Lambf = (1.0d0 - (fac / pom))
24528 Lambf = dsqrt(Lambf)
24529 sparrow = 1.0d0 / dsqrt(sig1**2.0d0 + sig2**2.0d0)
24530 ! write (*,*) "sparrow = ", sparrow
24531 Chif = 1.0d0/rij * sparrow
24532 ChiLambf = Chif * Lambf
24533 eagle = dsqrt(ChiLambf)
24534 bat = ChiLambf ** 11.0d0
24535 top = b1 * ( eagle + b2 * ChiLambf - b3 )
24536 bot = 1.0d0 + b4 * (ChiLambf ** 12.0d0)
24540 dtop = b1 * ((Lambf / (2.0d0 * eagle)) + (b2 * Lambf))
24541 dbot = 12.0d0 * b4 * bat * Lambf
24542 dFdR = ((dtop * bot - top * dbot) / botsq) * sparrow
24544 ! write (*,*) "dFcav/dR = ", dFdR
24545 dtop = b1 * ((Chif / (2.0d0 * eagle)) + (b2 * Chif))
24546 dbot = 12.0d0 * b4 * bat * Chif
24547 eagle = Lambf * pom
24548 dFdOM1 = -(chis1 * om1 - chis12 * om2 * om12) / (eagle)
24549 dFdOM2 = -(chis2 * om2 - chis12 * om1 * om12) / (eagle)
24550 dFdOM12 = chis12 * (chis1 * om1 * om12 - om2) &
24551 * (chis2 * om2 * om12 - om1) / (eagle * pom)
24553 dFdL = ((dtop * bot - top * dbot) / botsq)
24555 dCAVdOM1 = dFdL * ( dFdOM1 )
24556 dCAVdOM2 = dFdL * ( dFdOM2 )
24557 dCAVdOM12 = dFdL * ( dFdOM12 )
24562 ! eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
24563 ! eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
24564 ! eom12=evdwij*eps1_om12+eps2der*eps2rt_om12 &
24565 ! -2.0D0*alf12*eps3der+sigder*sigsq_om12
24566 ! print *,"EOMY",eom1,eom2,eom12
24567 ! erdxi = scalar( ertail(1), dC_norm(1,i+nres) )
24568 ! erdxj = scalar( ertail(1), dC_norm(1,j+nres) )
24570 ! facd1 = dtail(1,itypi,itypj) * vbld_inv(i+nres)
24571 ! facd2 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
24573 ! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
24574 ! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
24576 !-facd1*(ertail(k)-erdxi*dC_norm(k,i+nres))
24577 gvdwx_scbase(k,i) = gvdwx_scbase(k,i) &
24578 - (( dFdR + gg(k) ) * pom)
24579 ! +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
24580 ! +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
24581 ! & - ( dFdR * pom )
24583 !-facd2*(ertail(k)-erdxj*dC_norm(k,j+nres))
24584 gvdwx_scbase(k,j) = gvdwx_scbase(k,j) &
24585 + (( dFdR + gg(k) ) * pom)
24586 ! +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
24587 ! +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
24588 !c! & + ( dFdR * pom )
24590 gvdwc_scbase(k,i) = gvdwc_scbase(k,i) &
24591 - (( dFdR + gg(k) ) * ertail(k))
24592 !c! & - ( dFdR * ertail(k))
24594 gvdwc_scbase(k,j) = gvdwc_scbase(k,j) &
24595 + (( dFdR + gg(k) ) * ertail(k))
24596 !c! & + ( dFdR * ertail(k))
24599 !c! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
24600 !c! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
24607 if (wdipdip_scbase(2,itypi,itypj).gt.0.0d0) then
24608 w1 = wdipdip_scbase(1,itypi,itypj)
24609 w2 = -wdipdip_scbase(3,itypi,itypj)/2.0
24610 w3 = wdipdip_scbase(2,itypi,itypj)
24611 !c!-------------------------------------------------------------------
24613 fac = (om12 - 3.0d0 * om1 * om2)
24614 c1 = (w1 / (Rhead**3.0d0)) * fac
24615 c2 = (w2 / Rhead ** 6.0d0) &
24616 * (4.0d0 + fac * fac -3.0d0 * (sqom1 + sqom2))
24617 c3= (w3/ Rhead ** 6.0d0) &
24618 * (2.0d0 - 2.0d0*fac*fac +3.0d0*(sqom1 + sqom2))
24620 !c! write (*,*) "w1 = ", w1
24621 !c! write (*,*) "w2 = ", w2
24622 !c! write (*,*) "om1 = ", om1
24623 !c! write (*,*) "om2 = ", om2
24624 !c! write (*,*) "om12 = ", om12
24625 !c! write (*,*) "fac = ", fac
24626 !c! write (*,*) "c1 = ", c1
24627 !c! write (*,*) "c2 = ", c2
24628 !c! write (*,*) "Ecl = ", Ecl
24629 !c! write (*,*) "c2_1 = ", (w2 / Rhead ** 6.0d0)
24630 !c! write (*,*) "c2_2 = ",
24631 !c! & (4.0d0 + fac * fac -3.0d0 * (sqom1 + sqom2))
24632 !c!-------------------------------------------------------------------
24633 !c! dervative of ECL is GCL...
24635 c1 = (-3.0d0 * w1 * fac) / (Rhead ** 4.0d0)
24636 c2 = (-6.0d0 * w2) / (Rhead ** 7.0d0) &
24637 * (4.0d0 + fac * fac - 3.0d0 * (sqom1 + sqom2))
24638 c3= (-6.0d0 * w3) / (Rhead ** 7.0d0) &
24639 * (2.0d0 - 2.0d0*fac*fac +3.0d0*(sqom1 + sqom2))
24640 dGCLdR = c1 - c2 + c3
24642 c1 = (-3.0d0 * w1 * om2 ) / (Rhead**3.0d0)
24643 c2 = (-6.0d0 * w2) / (Rhead**6.0d0) &
24644 * ( om2 * om12 - 3.0d0 * om1 * sqom2 + om1 )
24645 c3 =(6.0d0*w3/ Rhead ** 6.0d0)*(om1-2.0d0*(fac)*(-om2))
24646 dGCLdOM1 = c1 - c2 + c3
24648 c1 = (-3.0d0 * w1 * om1 ) / (Rhead**3.0d0)
24649 c2 = (-6.0d0 * w2) / (Rhead**6.0d0) &
24650 * ( om1 * om12 - 3.0d0 * sqom1 * om2 + om2 )
24651 c3 =(6.0d0*w3/ Rhead ** 6.0d0)*(om2-2.0d0*(fac)*(-om1))
24652 dGCLdOM2 = c1 - c2 + c3
24654 c1 = w1 / (Rhead ** 3.0d0)
24655 c2 = ( 2.0d0 * w2 * fac ) / Rhead ** 6.0d0
24656 c3 = (w3/ Rhead ** 6.0d0)*(-4.0d0*fac)
24657 dGCLdOM12 = c1 - c2 + c3
24659 erhead(k) = Rhead_distance(k)/Rhead
24661 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
24662 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
24663 facd1 = d1i * vbld_inv(i+nres)
24664 facd2 = d1j * vbld_inv(j+nres)
24667 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
24668 gvdwx_scbase(k,i) = gvdwx_scbase(k,i) &
24670 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
24671 gvdwx_scbase(k,j) = gvdwx_scbase(k,j) &
24674 gvdwc_scbase(k,i) = gvdwc_scbase(k,i) &
24675 - dGCLdR * erhead(k)
24676 gvdwc_scbase(k,j) = gvdwc_scbase(k,j) &
24677 + dGCLdR * erhead(k)
24680 !now charge with dipole eg. ARG-dG
24681 if (wqdip_scbase(2,itypi,itypj).gt.0.0d0) then
24682 alphapol1 = alphapol_scbase(itypi,itypj)
24683 w1 = wqdip_scbase(1,itypi,itypj)
24684 w2 = wqdip_scbase(2,itypi,itypj)
24687 ! pis = sig0head_scbase(itypi,itypj)
24688 ! eps_head = epshead_scbase(itypi,itypj)
24689 !c!-------------------------------------------------------------------
24690 !c! R1 - distance between head of ith side chain and tail of jth sidechain
24693 !c! Calculate head-to-tail distances tail is center of side-chain
24694 R1=R1+(c(k,j+nres)-chead(k,1))**2
24699 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
24700 !c! & +dhead(1,1,itypi,itypj))**2))
24701 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
24702 !c! & +dhead(2,1,itypi,itypj))**2))
24704 !c!-------------------------------------------------------------------
24707 hawk = w2 * (1.0d0 - sqom2)
24708 Ecl = sparrow / Rhead**2.0d0 &
24709 - hawk / Rhead**4.0d0
24710 !c!-------------------------------------------------------------------
24711 !c! derivative of ecl is Gcl
24713 dGCLdR = - 2.0d0 * sparrow / Rhead**3.0d0 &
24714 + 4.0d0 * hawk / Rhead**5.0d0
24716 dGCLdOM1 = (w1) / (Rhead**2.0d0)
24718 dGCLdOM2 = (2.0d0 * w2 * om2) / (Rhead ** 4.0d0)
24719 !c--------------------------------------------------------------------
24720 !c Polarization energy
24722 MomoFac1 = (1.0d0 - chi1 * sqom2)
24723 RR1 = R1 * R1 / MomoFac1
24724 ee1 = exp(-( RR1 / (4.0d0 * a12sq) ))
24725 fgb1 = sqrt( RR1 + a12sq * ee1)
24726 ! eps_inout_fac=0.0d0
24727 epol = 332.0d0 * eps_inout_fac * (( alphapol1 / fgb1 )**4.0d0)
24728 ! derivative of Epol is Gpol...
24729 dPOLdFGB1 = -(1328.0d0 * eps_inout_fac * alphapol1 ** 4.0d0) &
24731 dFGBdR1 = ( (R1 / MomoFac1) &
24732 * ( 2.0d0 - (0.5d0 * ee1) ) ) &
24734 dFGBdOM2 = (((R1 * R1 * chi1 * om2) / (MomoFac1 * MomoFac1)) &
24735 * (2.0d0 - 0.5d0 * ee1) ) &
24737 dPOLdR1 = dPOLdFGB1 * dFGBdR1
24740 dPOLdOM2 = dPOLdFGB1 * dFGBdOM2
24742 erhead(k) = Rhead_distance(k)/Rhead
24743 erhead_tail(k,1) = ((c(k,j+nres)-chead(k,1))/R1)
24746 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
24747 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
24748 bat = scalar( erhead_tail(1,1), dC_norm(1,i+nres) )
24750 federmaus = scalar(erhead_tail(1,1),dC_norm(1,j+nres))
24751 facd1 = d1i * vbld_inv(i+nres)
24752 facd2 = d1j * vbld_inv(j+nres)
24753 ! facd4 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
24756 hawk = (erhead_tail(k,1) + &
24757 facd1 * (erhead_tail(k,1) - bat * dC_norm(k,i+nres)))
24760 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
24761 gvdwx_scbase(k,i) = gvdwx_scbase(k,i) &
24763 - dPOLdR1 * (erhead_tail(k,1))
24766 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
24767 gvdwx_scbase(k,j) = gvdwx_scbase(k,j) &
24769 + dPOLdR1 * (erhead_tail(k,1))
24773 gvdwc_scbase(k,i) = gvdwc_scbase(k,i) &
24774 - dGCLdR * erhead(k) &
24775 - dPOLdR1 * erhead_tail(k,1)
24776 ! & - dGLJdR * erhead(k)
24778 gvdwc_scbase(k,j) = gvdwc_scbase(k,j) &
24779 + dGCLdR * erhead(k) &
24780 + dPOLdR1 * erhead_tail(k,1)
24781 ! & + dGLJdR * erhead(k)
24785 ! print *,i,j,evdwij,epol,Fcav,ECL
24786 escbase=escbase+evdwij+epol+Fcav+ECL
24787 call sc_grad_scbase
24792 end subroutine eprot_sc_base
24793 SUBROUTINE sc_grad_scbase
24796 real (kind=8) :: dcosom1(3),dcosom2(3)
24798 eps2der * eps2rt_om1 &
24799 - 2.0D0 * alf1 * eps3der &
24800 + sigder * sigsq_om1 &
24806 eps2der * eps2rt_om2 &
24807 + 2.0D0 * alf2 * eps3der &
24808 + sigder * sigsq_om2 &
24814 evdwij * eps1_om12 &
24815 + eps2der * eps2rt_om12 &
24816 - 2.0D0 * alf12 * eps3der &
24817 + sigder *sigsq_om12 &
24821 ! print *,eom1,eom2,eom12,i,j,"eom1,2,12",erij(1),erij(2),erij(3)
24822 ! print *,dsci_inv,dscj_inv,dc_norm(2,nres+j),dc_norm(2,nres+i),&
24823 ! gg(1),gg(2),"rozne"
24825 dcosom1(k) = rij * (dc_norm(k,nres+i) - om1 * erij(k))
24826 dcosom2(k) = rij * (dc_norm(k,nres+j) - om2 * erij(k))
24827 gg(k) = gg(k) + eom1 * dcosom1(k) + eom2 * dcosom2(k)
24828 gvdwx_scbase(k,i)= gvdwx_scbase(k,i) - gg(k) &
24829 + (eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
24830 + eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
24831 gvdwx_scbase(k,j)= gvdwx_scbase(k,j) + gg(k) &
24832 + (eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
24833 + eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
24834 gvdwc_scbase(k,i)=gvdwc_scbase(k,i)-gg(k)
24835 gvdwc_scbase(k,j)=gvdwc_scbase(k,j)+gg(k)
24838 END SUBROUTINE sc_grad_scbase
24841 subroutine epep_sc_base(epepbase)
24844 !el local variables
24845 integer :: iint,itypi,itypi1,itypj,subchap
24846 real(kind=8) :: rrij,xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
24847 real(kind=8) :: evdw,sig0ij
24848 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
24849 dist_temp, dist_init,aa,bb,ssgradlipi,ssgradlipj, &
24850 sslipi,sslipj,faclip
24852 real(kind=8) :: fracinbuf
24853 real (kind=8) :: epepbase
24854 real (kind=8),dimension(4):: ener
24855 real(kind=8) :: b1,b2,b3,b4,egb,eps_in,eps_inout_fac,eps_out
24856 real(kind=8) :: ECL,Elj,Equad,Epol,eheadtail,rhead,dGCLOM2,&
24857 sqom1,sqom2,sqom12,c1,c2,c3,pom,Lambf,sparrow,&
24858 Chif,ChiLambf,bat,eagle,top,bot,botsq,Fcav,dtop,dFdR,dFdOM1,&
24859 dFdOM2,w1,w2,w3,dGCLdR,dFdL,dFdOM12,dbot ,&
24860 r1,eps_head,alphapol1,pis,facd2,d2,facd1,d1,erdxj,erdxi,federmaus,&
24861 dPOLdR1,dFGBdOM2,dFGBdR1,dPOLdFGB1,RR1,MomoFac1,hawk,d1i,d1j,&
24862 sig1,sig2,chis12,chis2,ee1,fgb1,a12sq,chis1
24863 real(kind=8),dimension(3,2)::chead,erhead_tail
24864 real(kind=8),dimension(3) :: Rhead_distance,ertail,erhead
24868 ! do i=1,nres_molec(1)-1
24869 do i=ibond_start,ibond_end
24870 if (itype(i,1).eq.ntyp1_molec(1).or.itype(i+1,1).eq.ntyp1_molec(1)) cycle
24871 !C itypi = itype(i,1)
24875 ! print *,dxi,(-c(1,i)+c(1,i+1))*vbld_inv(i+1)
24876 dsci_inv = vbld_inv(i+1)/2.0
24877 xi=(c(1,i)+c(1,i+1))/2.0
24878 yi=(c(2,i)+c(2,i+1))/2.0
24879 zi=(c(3,i)+c(3,i+1))/2.0
24880 call to_box(xi,yi,zi)
24881 do j=nres_molec(1)+1,nres_molec(2)+nres_molec(1)
24883 if (itype(j,2).eq.ntyp1_molec(2))cycle
24887 call to_box(xj,yj,zj)
24888 xj=boxshift(xj-xi,boxxsize)
24889 yj=boxshift(yj-yi,boxysize)
24890 zj=boxshift(zj-zi,boxzsize)
24891 dist_init=xj**2+yj**2+zj**2
24892 dxj = dc_norm( 1, nres+j )
24893 dyj = dc_norm( 2, nres+j )
24894 dzj = dc_norm( 3, nres+j )
24895 ! d1i = dhead_scbasei(itypi) !this is shift of dipole/charge
24896 ! d1j = dhead_scbasej(itypi) !this is shift of dipole/charge
24899 sig0ij = sigma_pepbase(itypj )
24900 chi1 = chi_pepbase(itypj,1 )
24901 chi2 = chi_pepbase(itypj,2 )
24904 chi12 = chi1 * chi2
24905 chip1 = chipp_pepbase(itypj,1 )
24906 chip2 = chipp_pepbase(itypj,2 )
24909 chip12 = chip1 * chip2
24910 chis1 = chis_pepbase(itypj,1)
24911 chis2 = chis_pepbase(itypj,2)
24912 chis12 = chis1 * chis2
24913 sig1 = sigmap1_pepbase(itypj)
24914 sig2 = sigmap2_pepbase(itypj)
24915 ! write (*,*) "sig1 = ", sig1
24916 ! write (*,*) "sig2 = ", sig2
24918 ! location of polar head is computed by taking hydrophobic centre
24919 ! and moving by a d1 * dc_norm vector
24920 ! see unres publications for very informative images
24921 chead(k,1) = (c(k,i)+c(k,i+1))/2.0
24922 ! + d1i * dc_norm(k, i+nres)
24923 chead(k,2) = c(k, j+nres)
24924 ! + d1j * dc_norm(k, j+nres)
24926 ! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
24927 ! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
24928 Rhead_distance(k) = chead(k,2) - chead(k,1)
24929 ! print *,gvdwc_pepbase(k,i)
24933 (Rhead_distance(1)*Rhead_distance(1)) &
24934 + (Rhead_distance(2)*Rhead_distance(2)) &
24935 + (Rhead_distance(3)*Rhead_distance(3)))
24937 ! alpha factors from Fcav/Gcav
24938 b1 = alphasur_pepbase(1,itypj)
24940 b2 = alphasur_pepbase(2,itypj)
24941 b3 = alphasur_pepbase(3,itypj)
24942 b4 = alphasur_pepbase(4,itypj)
24946 rrij = 1.0D0 / ( xj*xj + yj*yj + zj*zj)
24949 !----------------------------
24967 dscj_inv = vbld_inv(j+nres)
24969 ! this should be in elgrad_init but om's are calculated by sc_angular
24970 ! which in turn is used by older potentials
24971 ! om = omega, sqom = om^2
24974 sqom12 = om12 * om12
24976 ! now we calculate EGB - Gey-Berne
24977 ! It will be summed up in evdwij and saved in evdw
24978 sigsq = 1.0D0 / sigsq
24979 sig = sig0ij * dsqrt(sigsq)
24980 rij_shift = 1.0/rij - sig + sig0ij
24981 IF (rij_shift.le.0.0D0) THEN
24985 sigder = -sig * sigsq
24986 rij_shift = 1.0D0 / rij_shift
24987 fac = rij_shift**expon
24988 c1 = fac * fac * aa_pepbase(itypj)
24990 c2 = fac * bb_pepbase(itypj)
24992 evdwij = eps1 * eps2rt * eps3rt * ( c1 + c2 )
24993 eps2der = eps3rt * evdwij
24994 eps3der = eps2rt * evdwij
24995 ! evdwij = 4.0d0 * eps2rt * eps3rt * evdwij
24996 evdwij = eps2rt * eps3rt * evdwij
24997 c1 = c1 * eps1 * eps2rt**2 * eps3rt**2
24998 fac = -expon * (c1 + evdwij) * rij_shift
24999 sigder = fac * sigder
25001 ! Calculate distance derivative
25005 fac = chis1 * sqom1 + chis2 * sqom2 &
25006 - 2.0d0 * chis12 * om1 * om2 * om12
25007 ! we will use pom later in Gcav, so dont mess with it!
25008 pom = 1.0d0 - chis1 * chis2 * sqom12
25009 Lambf = (1.0d0 - (fac / pom))
25010 Lambf = dsqrt(Lambf)
25011 sparrow = 1.0d0 / dsqrt(sig1**2.0d0 + sig2**2.0d0)
25012 ! write (*,*) "sparrow = ", sparrow
25013 Chif = 1.0d0/rij * sparrow
25014 ChiLambf = Chif * Lambf
25015 eagle = dsqrt(ChiLambf)
25016 bat = ChiLambf ** 11.0d0
25017 top = b1 * ( eagle + b2 * ChiLambf - b3 )
25018 bot = 1.0d0 + b4 * (ChiLambf ** 12.0d0)
25022 dtop = b1 * ((Lambf / (2.0d0 * eagle)) + (b2 * Lambf))
25023 dbot = 12.0d0 * b4 * bat * Lambf
25024 dFdR = ((dtop * bot - top * dbot) / botsq) * sparrow
25026 ! write (*,*) "dFcav/dR = ", dFdR
25027 dtop = b1 * ((Chif / (2.0d0 * eagle)) + (b2 * Chif))
25028 dbot = 12.0d0 * b4 * bat * Chif
25029 eagle = Lambf * pom
25030 dFdOM1 = -(chis1 * om1 - chis12 * om2 * om12) / (eagle)
25031 dFdOM2 = -(chis2 * om2 - chis12 * om1 * om12) / (eagle)
25032 dFdOM12 = chis12 * (chis1 * om1 * om12 - om2) &
25033 * (chis2 * om2 * om12 - om1) / (eagle * pom)
25035 dFdL = ((dtop * bot - top * dbot) / botsq)
25037 dCAVdOM1 = dFdL * ( dFdOM1 )
25038 dCAVdOM2 = dFdL * ( dFdOM2 )
25039 dCAVdOM12 = dFdL * ( dFdOM12 )
25045 ! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
25046 ! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
25048 !-facd1*(ertail(k)-erdxi*dC_norm(k,i+nres))
25049 gvdwc_pepbase(k,i) = gvdwc_pepbase(k,i) &
25050 - (( dFdR + gg(k) ) * pom)/2.0
25051 ! print *,gvdwc_pepbase(k,i),i,(( dFdR + gg(k) ) * pom)/2.0
25052 ! +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
25053 ! +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
25054 ! & - ( dFdR * pom )
25056 !-facd2*(ertail(k)-erdxj*dC_norm(k,j+nres))
25057 gvdwx_pepbase(k,j) = gvdwx_pepbase(k,j) &
25058 + (( dFdR + gg(k) ) * pom)
25059 ! +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
25060 ! +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
25061 !c! & + ( dFdR * pom )
25063 gvdwc_pepbase(k,i+1) = gvdwc_pepbase(k,i+1) &
25064 - (( dFdR + gg(k) ) * ertail(k))/2.0
25065 ! print *,gvdwc_pepbase(k,i+1),i+1,(( dFdR + gg(k) ) * pom)/2.0
25067 !c! & - ( dFdR * ertail(k))
25069 gvdwc_pepbase(k,j) = gvdwc_pepbase(k,j) &
25070 + (( dFdR + gg(k) ) * ertail(k))
25071 !c! & + ( dFdR * ertail(k))
25074 !c! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
25075 !c! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
25079 w1 = wdipdip_pepbase(1,itypj)
25080 w2 = -wdipdip_pepbase(3,itypj)/2.0
25081 w3 = wdipdip_pepbase(2,itypj)
25084 !c!-------------------------------------------------------------------
25087 fac = (om12 - 3.0d0 * om1 * om2)
25088 c1 = (w1 / (Rhead**3.0d0)) * fac
25089 c2 = (w2 / Rhead ** 6.0d0) &
25090 * (4.0d0 + fac * fac -3.0d0 * (sqom1 + sqom2))
25091 c3= (w3/ Rhead ** 6.0d0) &
25092 * (2.0d0 - 2.0d0*fac*fac +3.0d0*(sqom1 + sqom2))
25096 c1 = (-3.0d0 * w1 * fac) / (Rhead ** 4.0d0)
25097 c2 = (-6.0d0 * w2) / (Rhead ** 7.0d0) &
25098 * (4.0d0 + fac * fac - 3.0d0 * (sqom1 + sqom2))
25099 c3= (-6.0d0 * w3) / (Rhead ** 7.0d0) &
25100 * (2.0d0 - 2.0d0*fac*fac +3.0d0*(sqom1 + sqom2))
25102 dGCLdR = c1 - c2 + c3
25104 c1 = (-3.0d0 * w1 * om2 ) / (Rhead**3.0d0)
25105 c2 = (-6.0d0 * w2) / (Rhead**6.0d0) &
25106 * ( om2 * om12 - 3.0d0 * om1 * sqom2 + om1 )
25107 c3 =(6.0d0*w3/ Rhead ** 6.0d0)*(om1-2.0d0*(fac)*(-om2))
25108 dGCLdOM1 = c1 - c2 + c3
25110 c1 = (-3.0d0 * w1 * om1 ) / (Rhead**3.0d0)
25111 c2 = (-6.0d0 * w2) / (Rhead**6.0d0) &
25112 * ( om1 * om12 - 3.0d0 * sqom1 * om2 + om2 )
25113 c3 =(6.0d0*w3/ Rhead ** 6.0d0)*(om2-2.0d0*(fac)*(-om1))
25115 dGCLdOM2 = c1 - c2 + c3
25117 c1 = w1 / (Rhead ** 3.0d0)
25118 c2 = ( 2.0d0 * w2 * fac ) / Rhead ** 6.0d0
25119 c3 = (w3/ Rhead ** 6.0d0)*(-4.0d0*fac)
25120 dGCLdOM12 = c1 - c2 + c3
25122 erhead(k) = Rhead_distance(k)/Rhead
25124 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
25125 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
25126 ! facd1 = d1 * vbld_inv(i+nres)
25127 ! facd2 = d2 * vbld_inv(j+nres)
25131 !+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
25132 ! gvdwx_pepbase(k,i) = gvdwx_scbase(k,i) &
25135 !+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
25136 gvdwx_pepbase(k,j) = gvdwx_pepbase(k,j) &
25139 gvdwc_pepbase(k,i) = gvdwc_pepbase(k,i) &
25140 - dGCLdR * erhead(k)/2.0d0
25141 ! print *,gvdwc_pepbase(k,i+1),i+1,- dGCLdR * erhead(k)/2.0d0
25142 gvdwc_pepbase(k,i+1) = gvdwc_pepbase(k,i+1) &
25143 - dGCLdR * erhead(k)/2.0d0
25144 ! print *,gvdwc_pepbase(k,i+1),i+1,- dGCLdR * erhead(k)/2.0d0
25145 gvdwc_pepbase(k,j) = gvdwc_pepbase(k,j) &
25146 + dGCLdR * erhead(k)
25148 ! print *,i,j,evdwij,Fcav,ECL,"vdw,cav,ecl"
25149 epepbase=epepbase+evdwij+Fcav+ECL
25150 call sc_grad_pepbase
25153 END SUBROUTINE epep_sc_base
25154 SUBROUTINE sc_grad_pepbase
25157 real (kind=8) :: dcosom1(3),dcosom2(3)
25159 eps2der * eps2rt_om1 &
25160 - 2.0D0 * alf1 * eps3der &
25161 + sigder * sigsq_om1 &
25167 eps2der * eps2rt_om2 &
25168 + 2.0D0 * alf2 * eps3der &
25169 + sigder * sigsq_om2 &
25175 evdwij * eps1_om12 &
25176 + eps2der * eps2rt_om12 &
25177 - 2.0D0 * alf12 * eps3der &
25178 + sigder *sigsq_om12 &
25183 ! print *,eom1,eom2,eom12,om12,i,j,"eom1,2,12",erij(1),erij(2),erij(3)
25184 ! if (i.eq.30) print *,gvdwc_pepbase(k,i),- gg(k),&
25185 ! (-eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,i)))&
25187 ! print *,dsci_inv,dscj_inv,dc_norm(2,nres+j),dc_norm(2,nres+i),&
25188 ! gg(1),gg(2),"rozne"
25190 dcosom1(k) = rij * (dc_norm(k,i) - om1 * erij(k))
25191 dcosom2(k) = rij * (dc_norm(k,nres+j) - om2 * erij(k))
25192 gg(k) = gg(k) + eom1 * dcosom1(k) + eom2 * dcosom2(k)
25193 gvdwc_pepbase(k,i)= gvdwc_pepbase(k,i) +0.5*(- gg(k)) &
25194 + (-eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,i)))&
25196 - (eom1*(erij(k)-om1*dc_norm(k,i)))*dsci_inv*2.0
25197 gvdwc_pepbase(k,i+1)= gvdwc_pepbase(k,i+1) +0.5*(- gg(k)) &
25198 - (-eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,i))) &
25200 + (eom1*(erij(k)-om1*dc_norm(k,i)))*dsci_inv*2.0
25201 ! print *,eom12,eom2,om12,om2
25202 !eom12*(-dc_norm(k,i)/2.0-om12*dc_norm(k,nres+j)),&
25203 ! (eom2*(erij(k)-om2*dc_norm(k,nres+j)))
25204 gvdwx_pepbase(k,j)= gvdwx_pepbase(k,j) + gg(k) &
25205 + (eom12*(dc_norm(k,i)-om12*dc_norm(k,nres+j))&
25206 + eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
25207 gvdwc_pepbase(k,j)=gvdwc_pepbase(k,j)+gg(k)
25210 END SUBROUTINE sc_grad_pepbase
25211 subroutine eprot_sc_phosphate(escpho)
25213 ! implicit real*8 (a-h,o-z)
25214 ! include 'DIMENSIONS'
25215 ! include 'COMMON.GEO'
25216 ! include 'COMMON.VAR'
25217 ! include 'COMMON.LOCAL'
25218 ! include 'COMMON.CHAIN'
25219 ! include 'COMMON.DERIV'
25220 ! include 'COMMON.NAMES'
25221 ! include 'COMMON.INTERACT'
25222 ! include 'COMMON.IOUNITS'
25223 ! include 'COMMON.CALC'
25224 ! include 'COMMON.CONTROL'
25225 ! include 'COMMON.SBRIDGE'
25227 !el local variables
25228 integer :: iint,itypi,itypi1,itypj,subchap
25229 real(kind=8) :: rrij,xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
25230 real(kind=8) :: evdw,sig0ij,aa,bb
25231 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
25232 dist_temp, dist_init,ssgradlipi,ssgradlipj, &
25233 sslipi,sslipj,faclip,alpha_sco
25235 real(kind=8) :: fracinbuf
25236 real (kind=8) :: escpho
25237 real (kind=8),dimension(4):: ener
25238 real(kind=8) :: b1,b2,b3,b4,egb,eps_in,eps_inout_fac,eps_out
25239 real(kind=8) :: ECL,Elj,Equad,Epol,eheadtail,rhead,dGCLOM2,&
25240 sqom1,sqom2,sqom12,c1,c2,pom,Lambf,sparrow,&
25241 Chif,ChiLambf,bat,eagle,top,bot,botsq,Fcav,dtop,dFdR,dFdOM1,&
25242 dFdOM2,w1,w2,dGCLdR,dFdL,dFdOM12,dbot ,&
25243 r1,eps_head,alphapol1,pis,facd2,d2,facd1,d1,erdxj,erdxi,federmaus,&
25244 dPOLdR1,dFGBdOM2,dFGBdR1,dPOLdFGB1,RR1,MomoFac1,hawk,d1i,d1j,&
25245 sig1,sig2,chis12,chis2,ee1,fgb1,a12sq,chis1,Rhead_sq,Qij,dFGBdOM1
25246 real(kind=8),dimension(3,2)::chead,erhead_tail
25247 real(kind=8),dimension(3) :: Rhead_distance,ertail,erhead
25251 ! do i=1,nres_molec(1)
25252 do i=ibond_start,ibond_end
25253 if (itype(i,1).eq.ntyp1_molec(1)) cycle
25255 dxi = dc_norm(1,nres+i)
25256 dyi = dc_norm(2,nres+i)
25257 dzi = dc_norm(3,nres+i)
25258 dsci_inv = vbld_inv(i+nres)
25262 call to_box(xi,yi,zi)
25263 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
25264 do j=nres_molec(1)+1,nres_molec(2)+nres_molec(1)-1
25266 if ((itype(j,2).eq.ntyp1_molec(2)).or.&
25267 (itype(j+1,2).eq.ntyp1_molec(2))) cycle
25268 xj=(c(1,j)+c(1,j+1))/2.0
25269 yj=(c(2,j)+c(2,j+1))/2.0
25270 zj=(c(3,j)+c(3,j+1))/2.0
25271 call to_box(xj,yj,zj)
25272 ! call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
25273 ! aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
25274 ! +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
25275 ! bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
25276 ! +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
25277 xj=boxshift(xj-xi,boxxsize)
25278 yj=boxshift(yj-yi,boxysize)
25279 zj=boxshift(zj-zi,boxzsize)
25280 dxj = dc_norm( 1,j )
25281 dyj = dc_norm( 2,j )
25282 dzj = dc_norm( 3,j )
25283 dscj_inv = vbld_inv(j+1)
25286 sig0ij = sigma_scpho(itypi )
25287 chi1 = chi_scpho(itypi,1 )
25288 chi2 = chi_scpho(itypi,2 )
25291 chi12 = chi1 * chi2
25292 chip1 = chipp_scpho(itypi,1 )
25293 chip2 = chipp_scpho(itypi,2 )
25296 chip12 = chip1 * chip2
25297 chis1 = chis_scpho(itypi,1)
25298 chis2 = chis_scpho(itypi,2)
25299 chis12 = chis1 * chis2
25300 sig1 = sigmap1_scpho(itypi)
25301 sig2 = sigmap2_scpho(itypi)
25302 ! write (*,*) "sig1 = ", sig1
25303 ! write (*,*) "sig1 = ", sig1
25304 ! write (*,*) "sig2 = ", sig2
25305 ! alpha factors from Fcav/Gcav
25309 a12sq = rborn_scphoi(itypi) * rborn_scphoj(itypi)
25311 b1 = alphasur_scpho(1,itypi)
25313 b2 = alphasur_scpho(2,itypi)
25314 b3 = alphasur_scpho(3,itypi)
25315 b4 = alphasur_scpho(4,itypi)
25316 ! used to determine whether we want to do quadrupole calculations
25318 eps_in = epsintab_scpho(itypi)
25319 if (eps_in.eq.0.0) eps_in=1.0
25320 eps_inout_fac = ( (1.0d0/eps_in) - (1.0d0/eps_out))
25321 ! write (*,*) "eps_inout_fac = ", eps_inout_fac
25322 !-------------------------------------------------------------------
25323 ! tail location and distance calculations
25324 d1i = dhead_scphoi(itypi) !this is shift of dipole/charge
25327 ! location of polar head is computed by taking hydrophobic centre
25328 ! and moving by a d1 * dc_norm vector
25329 ! see unres publications for very informative images
25330 chead(k,1) = c(k, i+nres) + d1i * dc_norm(k, i+nres)
25331 chead(k,2) = (c(k, j) + c(k, j+1))/2.0
25333 ! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
25334 ! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
25335 Rhead_distance(k) = chead(k,2) - chead(k,1)
25337 ! pitagoras (root of sum of squares)
25339 (Rhead_distance(1)*Rhead_distance(1)) &
25340 + (Rhead_distance(2)*Rhead_distance(2)) &
25341 + (Rhead_distance(3)*Rhead_distance(3)))
25342 Rhead_sq=Rhead**2.0
25343 !-------------------------------------------------------------------
25344 ! zero everything that should be zero'ed
25363 dscj_inv = vbld_inv(j+1)/2.0
25364 !dhead_scbasej(itypi,itypj)
25365 ! print *,i,j,dscj_inv,dsci_inv
25366 ! rij holds 1/(distance of Calpha atoms)
25367 rrij = 1.0D0 / ( xj*xj + yj*yj + zj*zj)
25369 !----------------------------
25371 ! this should be in elgrad_init but om's are calculated by sc_angular
25372 ! which in turn is used by older potentials
25373 ! om = omega, sqom = om^2
25376 sqom12 = om12 * om12
25378 ! now we calculate EGB - Gey-Berne
25379 ! It will be summed up in evdwij and saved in evdw
25380 sigsq = 1.0D0 / sigsq
25381 sig = sig0ij * dsqrt(sigsq)
25382 ! rij_shift = 1.0D0 / rij - sig + sig0ij
25383 rij_shift = 1.0/rij - sig + sig0ij
25384 IF (rij_shift.le.0.0D0) THEN
25388 sigder = -sig * sigsq
25389 rij_shift = 1.0D0 / rij_shift
25390 fac = rij_shift**expon
25391 c1 = fac * fac * aa_scpho(itypi)
25393 c2 = fac * bb_scpho(itypi)
25395 evdwij = eps1 * eps2rt * eps3rt * ( c1 + c2 )
25396 eps2der = eps3rt * evdwij
25397 eps3der = eps2rt * evdwij
25398 ! evdwij = 4.0d0 * eps2rt * eps3rt * evdwij
25399 evdwij = eps2rt * eps3rt * evdwij
25400 c1 = c1 * eps1 * eps2rt**2 * eps3rt**2
25401 fac = -expon * (c1 + evdwij) * rij_shift
25402 sigder = fac * sigder
25404 ! Calculate distance derivative
25408 fac = chis1 * sqom1 + chis2 * sqom2 &
25409 - 2.0d0 * chis12 * om1 * om2 * om12
25410 ! we will use pom later in Gcav, so dont mess with it!
25411 pom = 1.0d0 - chis1 * chis2 * sqom12
25412 Lambf = (1.0d0 - (fac / pom))
25413 Lambf = dsqrt(Lambf)
25414 sparrow = 1.0d0 / dsqrt(sig1**2.0d0 + sig2**2.0d0)
25415 ! write (*,*) "sparrow = ", sparrow
25416 Chif = 1.0d0/rij * sparrow
25417 ChiLambf = Chif * Lambf
25418 eagle = dsqrt(ChiLambf)
25419 bat = ChiLambf ** 11.0d0
25420 top = b1 * ( eagle + b2 * ChiLambf - b3 )
25421 bot = 1.0d0 + b4 * (ChiLambf ** 12.0d0)
25424 dtop = b1 * ((Lambf / (2.0d0 * eagle)) + (b2 * Lambf))
25425 dbot = 12.0d0 * b4 * bat * Lambf
25426 dFdR = ((dtop * bot - top * dbot) / botsq) * sparrow
25428 ! write (*,*) "dFcav/dR = ", dFdR
25429 dtop = b1 * ((Chif / (2.0d0 * eagle)) + (b2 * Chif))
25430 dbot = 12.0d0 * b4 * bat * Chif
25431 eagle = Lambf * pom
25432 dFdOM1 = -(chis1 * om1 - chis12 * om2 * om12) / (eagle)
25433 dFdOM2 = -(chis2 * om2 - chis12 * om1 * om12) / (eagle)
25434 dFdOM12 = chis12 * (chis1 * om1 * om12 - om2) &
25435 * (chis2 * om2 * om12 - om1) / (eagle * pom)
25437 dFdL = ((dtop * bot - top * dbot) / botsq)
25439 dCAVdOM1 = dFdL * ( dFdOM1 )
25440 dCAVdOM2 = dFdL * ( dFdOM2 )
25441 dCAVdOM12 = dFdL * ( dFdOM12 )
25447 ! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
25448 ! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
25449 ! if (i.eq.3) print *,'decl0',gvdwx_scpho(k,i),i
25452 ! print *,pom,gg(k),dFdR
25453 !-facd1*(ertail(k)-erdxi*dC_norm(k,i+nres))
25454 gvdwx_scpho(k,i) = gvdwx_scpho(k,i) &
25455 - (( dFdR + gg(k) ) * pom)
25456 ! +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
25457 ! +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
25458 ! & - ( dFdR * pom )
25460 !-facd2*(ertail(k)-erdxj*dC_norm(k,j+nres))
25461 ! gvdwx_scpho(k,j) = gvdwx_scpho(k,j) &
25462 ! + (( dFdR + gg(k) ) * pom)
25463 ! +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
25464 ! +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
25465 !c! & + ( dFdR * pom )
25467 gvdwc_scpho(k,i) = gvdwc_scpho(k,i) &
25468 - (( dFdR + gg(k) ) * ertail(k))
25469 !c! & - ( dFdR * ertail(k))
25471 gvdwc_scpho(k,j) = gvdwc_scpho(k,j) &
25472 + (( dFdR + gg(k) ) * ertail(k))/2.0
25474 gvdwc_scpho(k,j+1) = gvdwc_scpho(k,j+1) &
25475 + (( dFdR + gg(k) ) * ertail(k))/2.0
25477 !c! & + ( dFdR * ertail(k))
25481 !c! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
25482 !c! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
25483 ! alphapol1 = alphapol_scpho(itypi)
25484 if (wqq_scpho(itypi).ne.0.0) then
25485 Qij=wqq_scpho(itypi)/eps_in
25486 alpha_sco=1.d0/alphi_scpho(itypi)
25488 Ecl = (332.0d0 * Qij*dexp(-Rhead*alpha_sco)) / Rhead
25489 !c! derivative of Ecl is Gcl...
25490 dGCLdR = (-332.0d0 * Qij*dexp(-Rhead*alpha_sco)* &
25491 (Rhead*alpha_sco+1) ) / Rhead_sq
25492 if (energy_dec) write(iout,*) "ECL",ECL,Rhead,1.0/rij
25493 else if (wqdip_scpho(2,itypi).gt.0.0d0) then
25494 w1 = wqdip_scpho(1,itypi)
25495 w2 = wqdip_scpho(2,itypi)
25498 ! pis = sig0head_scbase(itypi,itypj)
25499 ! eps_head = epshead_scbase(itypi,itypj)
25500 !c!-------------------------------------------------------------------
25502 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
25503 !c! & +dhead(1,1,itypi,itypj))**2))
25504 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
25505 !c! & +dhead(2,1,itypi,itypj))**2))
25507 !c!-------------------------------------------------------------------
25510 hawk = w2 * (1.0d0 - sqom2)
25511 Ecl = sparrow / Rhead**2.0d0 &
25512 - hawk / Rhead**4.0d0
25513 !c!-------------------------------------------------------------------
25514 if (energy_dec) write(iout,*) "ECLdipdip",ECL,Rhead,&
25517 !c! derivative of ecl is Gcl
25519 dGCLdR = - 2.0d0 * sparrow / Rhead**3.0d0 &
25520 + 4.0d0 * hawk / Rhead**5.0d0
25522 dGCLdOM1 = (w1) / (Rhead**2.0d0)
25524 dGCLdOM2 = (2.0d0 * w2 * om2) / (Rhead ** 4.0d0)
25527 !c--------------------------------------------------------------------
25528 !c Polarization energy
25532 !c! Calculate head-to-tail distances tail is center of side-chain
25533 R1=R1+((c(k,j)+c(k,j+1))/2.0-chead(k,1))**2
25538 alphapol1 = alphapol_scpho(itypi)
25540 MomoFac1 = (1.0d0 - chi2 * sqom1)
25541 RR1 = R1 * R1 / MomoFac1
25542 ee1 = exp(-( RR1 / (4.0d0 * a12sq) ))
25543 ! print *,"ee1",ee1,a12sq,alphapol1,eps_inout_fac
25544 fgb1 = sqrt( RR1 + a12sq * ee1)
25545 ! eps_inout_fac=0.0d0
25546 epol = 332.0d0 * eps_inout_fac * (( alphapol1 / fgb1 )**4.0d0)
25547 ! derivative of Epol is Gpol...
25548 dPOLdFGB1 = -(1328.0d0 * eps_inout_fac * alphapol1 ** 4.0d0) &
25550 dFGBdR1 = ( (R1 / MomoFac1) &
25551 * ( 2.0d0 - (0.5d0 * ee1) ) ) &
25553 dFGBdOM2 = (((R1 * R1 * chi1 * om2) / (MomoFac1 * MomoFac1)) &
25554 * (2.0d0 - 0.5d0 * ee1) ) &
25556 dPOLdR1 = dPOLdFGB1 * dFGBdR1
25559 dFGBdOM1 = (((R1 * R1 * chi2 * om1) / (MomoFac1 * MomoFac1)) &
25560 * (2.0d0 - 0.5d0 * ee1) ) &
25563 dPOLdOM1 = dPOLdFGB1 * dFGBdOM1
25566 erhead(k) = Rhead_distance(k)/Rhead
25567 erhead_tail(k,1) = (((c(k,j)+c(k,j+1))/2.0-chead(k,1))/R1)
25570 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
25571 erdxj = scalar( erhead(1), dC_norm(1,j) )
25572 bat = scalar( erhead_tail(1,1), dC_norm(1,i+nres) )
25574 federmaus = scalar(erhead_tail(1,1),dC_norm(1,j))
25575 facd1 = d1i * vbld_inv(i+nres)
25576 facd2 = d1j * vbld_inv(j)
25577 ! facd4 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
25580 hawk = (erhead_tail(k,1) + &
25581 facd1 * (erhead_tail(k,1) - bat * dC_norm(k,i+nres)))
25584 ! if (i.eq.3) print *,'decl1',dGCLdR,dPOLdR1,gvdwc_scpho(k,i),i,&
25585 ! pom,(erhead_tail(k,1))
25587 ! print *,'decl',dGCLdR,dPOLdR1,gvdwc_scpho(k,i)
25588 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
25589 gvdwx_scpho(k,i) = gvdwx_scpho(k,i) &
25591 - dPOLdR1 * (erhead_tail(k,1))
25594 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j))
25595 ! gvdwx_scpho(k,j) = gvdwx_scpho(k,j) &
25597 ! + dPOLdR1 * (erhead_tail(k,1))
25601 gvdwc_scpho(k,i) = gvdwc_scpho(k,i) &
25602 - dGCLdR * erhead(k) &
25603 - dPOLdR1 * erhead_tail(k,1)
25604 ! & - dGLJdR * erhead(k)
25606 gvdwc_scpho(k,j) = gvdwc_scpho(k,j) &
25607 + (dGCLdR * erhead(k) &
25608 + dPOLdR1 * erhead_tail(k,1))/2.0
25609 gvdwc_scpho(k,j+1) = gvdwc_scpho(k,j+1) &
25610 + (dGCLdR * erhead(k) &
25611 + dPOLdR1 * erhead_tail(k,1))/2.0
25613 ! & + dGLJdR * erhead(k)
25614 ! if (i.eq.3) print *,'decl2',dGCLdR,dPOLdR1,gvdwc_scpho(k,i),i
25617 ! if (i.eq.3) print *,i,j,evdwij,epol,Fcav,ECL
25618 if (energy_dec) write (iout,'(a22,2i5,4f8.3,f16.3)'), &
25619 "escpho:evdw,pol,cav,CL",i,j,evdwij,epol,Fcav,ECL,escpho
25620 escpho=escpho+evdwij+epol+Fcav+ECL
25627 end subroutine eprot_sc_phosphate
25628 SUBROUTINE sc_grad_scpho
25631 real (kind=8) :: dcosom1(3),dcosom2(3)
25633 eps2der * eps2rt_om1 &
25634 - 2.0D0 * alf1 * eps3der &
25635 + sigder * sigsq_om1 &
25641 eps2der * eps2rt_om2 &
25642 + 2.0D0 * alf2 * eps3der &
25643 + sigder * sigsq_om2 &
25649 evdwij * eps1_om12 &
25650 + eps2der * eps2rt_om12 &
25651 - 2.0D0 * alf12 * eps3der &
25652 + sigder *sigsq_om12 &
25657 ! print *,eom1,eom2,eom12,om12,i,j,"eom1,2,12",erij(1),erij(2),erij(3)
25658 ! if (i.eq.30) print *,gvdwc_scpho(k,i),- gg(k),&
25659 ! (-eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,i)))&
25661 ! print *,dsci_inv,dscj_inv,dc_norm(2,nres+j),dc_norm(2,nres+i),&
25662 ! gg(1),gg(2),"rozne"
25664 dcosom1(k) = rij * (dc_norm(k,nres+i) - om1 * erij(k))
25665 dcosom2(k) = rij * (dc_norm(k,j) - om2 * erij(k))
25666 gg(k) = gg(k) + eom1 * dcosom1(k) + eom2 * dcosom2(k)
25667 gvdwc_scpho(k,j)= gvdwc_scpho(k,j) +0.5*( gg(k)) &
25668 + (-eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,j)))&
25670 - (eom2*(erij(k)-om2*dc_norm(k,j)))*dscj_inv*2.0
25671 gvdwc_scpho(k,j+1)= gvdwc_scpho(k,j+1) +0.5*( gg(k)) &
25672 - (-eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,j))) &
25674 + (eom2*(erij(k)-om2*dc_norm(k,j)))*dscj_inv*2.0
25675 gvdwx_scpho(k,i)= gvdwx_scpho(k,i) - gg(k) &
25676 + (eom12*(dc_norm(k,j)-om12*dc_norm(k,nres+i)) &
25677 + eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
25679 ! print *,eom12,eom2,om12,om2
25680 !eom12*(-dc_norm(k,i)/2.0-om12*dc_norm(k,nres+j)),&
25681 ! (eom2*(erij(k)-om2*dc_norm(k,nres+j)))
25682 ! gvdwx_scpho(k,j)= gvdwx_scpho(k,j) + gg(k) &
25683 ! + (eom12*(dc_norm(k,i)-om12*dc_norm(k,nres+j))&
25684 ! + eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
25685 gvdwc_scpho(k,i)=gvdwc_scpho(k,i)-gg(k)
25688 END SUBROUTINE sc_grad_scpho
25689 subroutine eprot_pep_phosphate(epeppho)
25691 ! implicit real*8 (a-h,o-z)
25692 ! include 'DIMENSIONS'
25693 ! include 'COMMON.GEO'
25694 ! include 'COMMON.VAR'
25695 ! include 'COMMON.LOCAL'
25696 ! include 'COMMON.CHAIN'
25697 ! include 'COMMON.DERIV'
25698 ! include 'COMMON.NAMES'
25699 ! include 'COMMON.INTERACT'
25700 ! include 'COMMON.IOUNITS'
25701 ! include 'COMMON.CALC'
25702 ! include 'COMMON.CONTROL'
25703 ! include 'COMMON.SBRIDGE'
25705 !el local variables
25706 integer :: iint,itypi,itypi1,itypj,subchap
25707 real(kind=8) :: rrij,xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
25708 real(kind=8) :: evdw,sig0ij
25709 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
25710 dist_temp, dist_init,aa,bb,ssgradlipi,ssgradlipj, &
25711 sslipi,sslipj,faclip
25713 real(kind=8) :: fracinbuf
25714 real (kind=8) :: epeppho
25715 real (kind=8),dimension(4):: ener
25716 real(kind=8) :: b1,b2,b3,b4,egb,eps_in,eps_inout_fac,eps_out
25717 real(kind=8) :: ECL,Elj,Equad,Epol,eheadtail,rhead,dGCLOM2,&
25718 sqom1,sqom2,sqom12,c1,c2,pom,Lambf,sparrow,&
25719 Chif,ChiLambf,bat,eagle,top,bot,botsq,Fcav,dtop,dFdR,dFdOM1,&
25720 dFdOM2,w1,w2,dGCLdR,dFdL,dFdOM12,dbot ,&
25721 r1,eps_head,alphapol1,pis,facd2,d2,facd1,d1,erdxj,erdxi,federmaus,&
25722 dPOLdR1,dFGBdOM2,dFGBdR1,dPOLdFGB1,RR1,MomoFac1,hawk,d1i,d1j,&
25723 sig1,sig2,chis12,chis2,ee1,fgb1,a12sq,chis1,Rhead_sq,Qij,dFGBdOM1
25724 real(kind=8),dimension(3,2)::chead,erhead_tail
25725 real(kind=8),dimension(3) :: Rhead_distance,ertail,erhead
25727 real (kind=8) :: dcosom1(3),dcosom2(3)
25729 ! do i=1,nres_molec(1)
25730 do i=ibond_start,ibond_end
25731 if (itype(i,1).eq.ntyp1_molec(1)) cycle
25733 dsci_inv = vbld_inv(i+1)/2.0
25737 xi=(c(1,i)+c(1,i+1))/2.0
25738 yi=(c(2,i)+c(2,i+1))/2.0
25739 zi=(c(3,i)+c(3,i+1))/2.0
25740 call to_box(xi,yi,zi)
25742 do j=nres_molec(1)+1,nres_molec(2)+nres_molec(1)-1
25744 if ((itype(j,2).eq.ntyp1_molec(2)).or.&
25745 (itype(j+1,2).eq.ntyp1_molec(2))) cycle
25746 xj=(c(1,j)+c(1,j+1))/2.0
25747 yj=(c(2,j)+c(2,j+1))/2.0
25748 zj=(c(3,j)+c(3,j+1))/2.0
25749 call to_box(xj,yj,zj)
25750 xj=boxshift(xj-xi,boxxsize)
25751 yj=boxshift(yj-yi,boxysize)
25752 zj=boxshift(zj-zi,boxzsize)
25754 dist_init=xj**2+yj**2+zj**2
25755 rrij = 1.0D0 / ( xj*xj + yj*yj + zj*zj)
25757 dxj = dc_norm( 1,j )
25758 dyj = dc_norm( 2,j )
25759 dzj = dc_norm( 3,j )
25760 dscj_inv = vbld_inv(j+1)/2.0
25762 sig0ij = sigma_peppho
25765 chi12 = chi1 * chi2
25768 chip12 = chip1 * chip2
25771 chis12 = chis1 * chis2
25772 sig1 = sigmap1_peppho
25773 sig2 = sigmap2_peppho
25774 ! write (*,*) "sig1 = ", sig1
25775 ! write (*,*) "sig1 = ", sig1
25776 ! write (*,*) "sig2 = ", sig2
25777 ! alpha factors from Fcav/Gcav
25781 b1 = alphasur_peppho(1)
25783 b2 = alphasur_peppho(2)
25784 b3 = alphasur_peppho(3)
25785 b4 = alphasur_peppho(4)
25807 fac = rij_shift**expon
25808 c1 = fac * fac * aa_peppho
25810 c2 = fac * bb_peppho
25813 ! Now cavity....................
25814 eagle = dsqrt(1.0/rij_shift)
25815 top = b1 * ( eagle + b2 * 1.0/rij_shift - b3 )
25816 bot = 1.0d0 + b4 * (1.0/rij_shift ** 12.0d0)
25819 dtop = b1 * ((1.0/ (2.0d0 * eagle)) + (b2))
25820 dbot = 12.0d0 * b4 * (1.0/rij_shift) ** 11.0d0
25821 dFdR = ((dtop * bot - top * dbot) / botsq)
25822 w1 = wqdip_peppho(1)
25823 w2 = wqdip_peppho(2)
25826 ! pis = sig0head_scbase(itypi,itypj)
25827 ! eps_head = epshead_scbase(itypi,itypj)
25828 !c!-------------------------------------------------------------------
25830 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
25831 !c! & +dhead(1,1,itypi,itypj))**2))
25832 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
25833 !c! & +dhead(2,1,itypi,itypj))**2))
25835 !c!-------------------------------------------------------------------
25838 hawk = w2 * (1.0d0 - sqom1)
25839 Ecl = sparrow * rij_shift**2.0d0 &
25840 - hawk * rij_shift**4.0d0
25841 !c!-------------------------------------------------------------------
25842 !c! derivative of ecl is Gcl
25845 dGCLdR = - 2.0d0 * sparrow * rij_shift**3.0d0 &
25846 + 4.0d0 * hawk * rij_shift**5.0d0
25848 dGCLdOM1 = (w1) * (rij_shift**2.0d0)
25850 dGCLdOM2 = (2.0d0 * w2 * om1) * (rij_shift ** 4.0d0)
25851 eom1 = dGCLdOM1+dGCLdOM2
25854 fac = -expon * (c1 + evdwij) * rij_shift+dFdR+dGCLdR
25860 gvdwc_peppho(k,j) = gvdwc_peppho(k,j) +gg(k)/2.0
25861 gvdwc_peppho(k,j+1) = gvdwc_peppho(k,j+1) +gg(k)/2.0
25862 gvdwc_peppho(k,i) = gvdwc_peppho(k,i) -gg(k)/2.0
25863 gvdwc_peppho(k,i+1) = gvdwc_peppho(k,i+1) -gg(k)/2.0
25868 dcosom1(k) = rij* (dc_norm(k,i) - om1 * erij(k))
25869 dcosom2(k) = rij* (dc_norm(k,j) - om2 * erij(k))
25870 gg(k) = gg(k) + eom1 * dcosom1(k)! + eom2 * dcosom2(k)
25871 gvdwc_peppho(k,j)= gvdwc_peppho(k,j) +0.5*( gg(k)) !&
25872 ! - (eom2*(erij(k)-om2*dc_norm(k,j)))*dscj_inv*2.0
25873 gvdwc_peppho(k,j+1)= gvdwc_peppho(k,j+1) +0.5*( gg(k)) !&
25874 ! + (eom2*(erij(k)-om2*dc_norm(k,j)))*dscj_inv*2.0
25875 gvdwc_peppho(k,i)= gvdwc_peppho(k,i) -0.5*( gg(k)) &
25876 - (eom1*(erij(k)-om1*dc_norm(k,i)))*dsci_inv*2.0
25877 gvdwc_peppho(k,i+1)= gvdwc_peppho(k,i+1) - 0.5*( gg(k)) &
25878 + (eom1*(erij(k)-om1*dc_norm(k,i)))*dsci_inv*2.0
25880 epeppho=epeppho+evdwij+Fcav+ECL
25881 ! print *,i,j,evdwij,Fcav,ECL,rij_shift
25884 end subroutine eprot_pep_phosphate
25885 !!!!!!!!!!!!!!!!-------------------------------------------------------------
25886 subroutine emomo(evdw)
25889 ! implicit real*8 (a-h,o-z)
25890 ! include 'DIMENSIONS'
25891 ! include 'COMMON.GEO'
25892 ! include 'COMMON.VAR'
25893 ! include 'COMMON.LOCAL'
25894 ! include 'COMMON.CHAIN'
25895 ! include 'COMMON.DERIV'
25896 ! include 'COMMON.NAMES'
25897 ! include 'COMMON.INTERACT'
25898 ! include 'COMMON.IOUNITS'
25899 ! include 'COMMON.CALC'
25900 ! include 'COMMON.CONTROL'
25901 ! include 'COMMON.SBRIDGE'
25903 !el local variables
25904 integer :: iint,itypi1,subchap,isel
25905 real(kind=8) :: rrij,xi,yi,zi,sig,rij_shift,e1,e2,sigm,epsi
25906 real(kind=8) :: evdw,aa,bb
25907 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
25908 dist_temp, dist_init,ssgradlipi,ssgradlipj, &
25909 sslipi,sslipj,faclip,alpha_sco
25911 real(kind=8) :: fracinbuf
25912 real (kind=8) :: escpho
25913 real (kind=8),dimension(4):: ener
25914 real(kind=8) :: b1,b2,egb
25915 real(kind=8) :: Fisocav,ECL,Elj,Equad,Epol,eheadtail,&
25917 Chif,ChiLambf,Fcav,dFdR,dFdOM1,&
25918 dFdOM2,dFdL,dFdOM12,&
25921 ! real(kind=8),dimension(3,2)::erhead_tail
25922 ! real(kind=8),dimension(3) :: Rhead_distance,ertail,erhead,Rtail_distance
25923 real(kind=8) :: facd4, adler, Fgb, facd3
25924 integer troll,jj,istate
25925 real (kind=8) :: dcosom1(3),dcosom2(3)
25929 ! print *,"EVDW KURW",evdw,nres
25930 do i=iatsc_s,iatsc_e
25931 ! print *,"I am in EVDW",i
25932 itypi=iabs(itype(i,1))
25933 ! if (i.ne.47) cycle
25934 if (itypi.eq.ntyp1) cycle
25935 itypi1=iabs(itype(i+1,1))
25939 call to_box(xi,yi,zi)
25940 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
25941 if ((zi.gt.bordlipbot) &
25942 .and.(zi.lt.bordliptop)) then
25943 !C the energy transfer exist
25944 if (zi.lt.buflipbot) then
25945 !C what fraction I am in
25947 ((zi-bordlipbot)/lipbufthick)
25948 !C lipbufthick is thickenes of lipid buffore
25949 sslipi=sscalelip(fracinbuf)
25950 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
25951 elseif (zi.gt.bufliptop) then
25952 fracinbuf=1.0d0-((bordliptop-zi)/lipbufthick)
25953 sslipi=sscalelip(fracinbuf)
25954 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
25963 ! print *, sslipi,ssgradlipi
25964 dxi=dc_norm(1,nres+i)
25965 dyi=dc_norm(2,nres+i)
25966 dzi=dc_norm(3,nres+i)
25967 ! dsci_inv=dsc_inv(itypi)
25968 dsci_inv=vbld_inv(i+nres)
25969 ! write (iout,*) "i",i,dsc_inv(itypi),dsci_inv,1.0d0/vbld(i+nres)
25970 ! write (iout,*) "dcnori",dxi*dxi+dyi*dyi+dzi*dzi
25972 ! Calculate SC interaction energy.
25974 do iint=1,nint_gr(i)
25975 do j=istart(i,iint),iend(i,iint)
25976 ! print *,"JA PIER",i,j,iint,istart(i,iint),iend(i,iint)
25977 IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
25978 call dyn_ssbond_ene(i,j,evdwij)
25980 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
25981 'evdw',i,j,evdwij,' ss'
25982 ! if (energy_dec) write (iout,*) &
25983 ! 'evdw',i,j,evdwij,' ss'
25984 do k=j+1,iend(i,iint)
25985 !C search over all next residues
25986 if (dyn_ss_mask(k)) then
25987 !C check if they are cysteins
25988 !C write(iout,*) 'k=',k
25990 !c write(iout,*) "PRZED TRI", evdwij
25991 ! evdwij_przed_tri=evdwij
25992 call triple_ssbond_ene(i,j,k,evdwij)
25993 !c if(evdwij_przed_tri.ne.evdwij) then
25994 !c write (iout,*) "TRI:", evdwij, evdwij_przed_tri
25997 !c write(iout,*) "PO TRI", evdwij
25998 !C call the energy function that removes the artifical triple disulfide
25999 !C bond the soubroutine is located in ssMD.F
26001 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
26002 'evdw',i,j,evdwij,'tss'
26003 endif!dyn_ss_mask(k)
26007 itypj=iabs(itype(j,1))
26008 if (itypj.eq.ntyp1) cycle
26009 CALL elgrad_init(eheadtail,Egb,Ecl,Elj,Equad,Epol)
26011 ! if (j.ne.78) cycle
26012 ! dscj_inv=dsc_inv(itypj)
26013 dscj_inv=vbld_inv(j+nres)
26017 call to_box(xj,yj,zj)
26018 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
26019 write(iout,*) "KRUWA", i,j
26020 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
26021 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
26022 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
26023 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
26024 xj=boxshift(xj-xi,boxxsize)
26025 yj=boxshift(yj-yi,boxysize)
26026 zj=boxshift(zj-zi,boxzsize)
26027 dxj = dc_norm( 1, nres+j )
26028 dyj = dc_norm( 2, nres+j )
26029 dzj = dc_norm( 3, nres+j )
26030 ! print *,i,j,itypi,itypj
26033 ! BetaT = 1.0d0 / (298.0d0 * Rb)
26035 !1! sig0ij = sigma_scsc( itypi,itypj )
26040 ! not used by momo potential, but needed by sc_angular which is shared
26041 ! by all energy_potential subroutines
26045 a12sq = rborn(itypi,itypj) * rborn(itypj,itypi)
26046 ! a12sq = a12sq * a12sq
26047 ! charge of amino acid itypi is...
26048 chis1 = chis(itypi,itypj)
26049 chis2 = chis(itypj,itypi)
26050 chis12 = chis1 * chis2
26051 sig1 = sigmap1(itypi,itypj)
26052 sig2 = sigmap2(itypi,itypj)
26053 ! write (*,*) "sig1 = ", sig1
26056 ! chis12 = chis1 * chis2
26059 ! write (*,*) "sig2 = ", sig2
26060 ! alpha factors from Fcav/Gcav
26061 b1cav = alphasur(1,itypi,itypj)
26063 b2cav = alphasur(2,itypi,itypj)
26064 b3cav = alphasur(3,itypi,itypj)
26065 b4cav = alphasur(4,itypi,itypj)
26066 ! used to determine whether we want to do quadrupole calculations
26067 eps_in = epsintab(itypi,itypj)
26068 if (eps_in.eq.0.0) eps_in=1.0
26070 eps_inout_fac = ( (1.0d0/eps_in) - (1.0d0/eps_out))
26072 ! dtail(1,itypi,itypj)=0.0
26073 ! dtail(2,itypi,itypj)=0.0
26076 ctail(k,1)=c(k,i+nres)-dtail(1,itypi,itypj)*dc_norm(k,nres+i)
26077 ctail(k,2)=c(k,j+nres)-dtail(2,itypi,itypj)*dc_norm(k,nres+j)
26079 !c! tail distances will be themselves usefull elswhere
26080 !c1 (in Gcav, for example)
26081 Rtail_distance(1) = ctail( 1, 2 ) - ctail( 1,1 )
26082 Rtail_distance(2) = ctail( 2, 2 ) - ctail( 2,1 )
26083 Rtail_distance(3) = ctail( 3, 2 ) - ctail( 3,1 )
26085 (Rtail_distance(1)*Rtail_distance(1)) &
26086 + (Rtail_distance(2)*Rtail_distance(2)) &
26087 + (Rtail_distance(3)*Rtail_distance(3)))
26089 ! write (*,*) "eps_inout_fac = ", eps_inout_fac
26090 !-------------------------------------------------------------------
26091 ! tail location and distance calculations
26092 d1 = dhead(1, 1, itypi, itypj)
26093 d2 = dhead(2, 1, itypi, itypj)
26096 ! location of polar head is computed by taking hydrophobic centre
26097 ! and moving by a d1 * dc_norm vector
26098 ! see unres publications for very informative images
26099 chead(k,1) = c(k, i+nres) + d1 * dc_norm(k, i+nres)
26100 chead(k,2) = c(k, j+nres) + d2 * dc_norm(k, j+nres)
26102 ! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
26103 ! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
26104 Rhead_distance(k) = chead(k,2) - chead(k,1)
26106 ! pitagoras (root of sum of squares)
26108 (Rhead_distance(1)*Rhead_distance(1)) &
26109 + (Rhead_distance(2)*Rhead_distance(2)) &
26110 + (Rhead_distance(3)*Rhead_distance(3)))
26111 !-------------------------------------------------------------------
26112 ! zero everything that should be zero'ed
26130 dscj_inv = vbld_inv(j+nres)
26131 ! print *,i,j,dscj_inv,dsci_inv
26132 ! rij holds 1/(distance of Calpha atoms)
26133 rrij = 1.0D0 / ( xj*xj + yj*yj + zj*zj)
26135 !----------------------------
26137 ! this should be in elgrad_init but om's are calculated by sc_angular
26138 ! which in turn is used by older potentials
26139 ! om = omega, sqom = om^2
26142 sqom12 = om12 * om12
26144 ! now we calculate EGB - Gey-Berne
26145 ! It will be summed up in evdwij and saved in evdw
26146 sigsq = 1.0D0 / sigsq
26147 sig = sig0ij * dsqrt(sigsq)
26148 ! rij_shift = 1.0D0 / rij - sig + sig0ij
26149 rij_shift = Rtail - sig + sig0ij
26150 IF (rij_shift.le.0.0D0) THEN
26154 sigder = -sig * sigsq
26155 rij_shift = 1.0D0 / rij_shift
26156 fac = rij_shift**expon
26157 c1 = fac * fac * aa_aq(itypi,itypj)
26158 ! print *,"ADAM",aa_aq(itypi,itypj)
26161 c2 = fac * bb_aq(itypi,itypj)
26163 evdwij = eps1 * eps2rt * eps3rt * ( c1 + c2 )
26164 eps2der = eps3rt * evdwij
26165 eps3der = eps2rt * evdwij
26166 ! evdwij = 4.0d0 * eps2rt * eps3rt * evdwij
26167 evdwij = eps2rt * eps3rt * evdwij
26169 ! IF (bb_aq(itypi,itypj).gt.0) THEN
26170 ! evdw_p = evdw_p + evdwij
26172 ! evdw_m = evdw_m + evdwij
26179 c1 = c1 * eps1 * eps2rt**2 * eps3rt**2
26180 fac = -expon * (c1 + evdwij) * rij_shift
26181 sigder = fac * sigder
26183 ! Calculate distance derivative
26187 ! if (b2.gt.0.0) then
26188 fac = chis1 * sqom1 + chis2 * sqom2 &
26189 - 2.0d0 * chis12 * om1 * om2 * om12
26190 ! we will use pom later in Gcav, so dont mess with it!
26191 pom = 1.0d0 - chis1 * chis2 * sqom12
26192 Lambf = (1.0d0 - (fac / pom))
26193 ! print *,"fac,pom",fac,pom,Lambf
26194 Lambf = dsqrt(Lambf)
26195 sparrow = 1.0d0 / dsqrt(sig1**2.0d0 + sig2**2.0d0)
26196 ! print *,"sig1,sig2",sig1,sig2,itypi,itypj
26197 ! write (*,*) "sparrow = ", sparrow
26198 Chif = Rtail * sparrow
26199 ! print *,"rij,sparrow",rij , sparrow
26200 ChiLambf = Chif * Lambf
26201 eagle = dsqrt(ChiLambf)
26202 bat = ChiLambf ** 11.0d0
26203 top = b1cav * ( eagle + b2cav * ChiLambf - b3cav )
26204 bot = 1.0d0 + b4cav * (ChiLambf ** 12.0d0)
26206 ! print *,top,bot,"bot,top",ChiLambf,Chif
26209 dtop = b1cav * ((Lambf / (2.0d0 * eagle)) + (b2cav * Lambf))
26210 dbot = 12.0d0 * b4cav * bat * Lambf
26211 dFdR = ((dtop * bot - top * dbot) / botsq) * sparrow
26213 dtop = b1cav * ((Chif / (2.0d0 * eagle)) + (b2cav * Chif))
26214 dbot = 12.0d0 * b4cav * bat * Chif
26215 eagle = Lambf * pom
26216 dFdOM1 = -(chis1 * om1 - chis12 * om2 * om12) / (eagle)
26217 dFdOM2 = -(chis2 * om2 - chis12 * om1 * om12) / (eagle)
26218 dFdOM12 = chis12 * (chis1 * om1 * om12 - om2) &
26219 * (chis2 * om2 * om12 - om1) / (eagle * pom)
26221 dFdL = ((dtop * bot - top * dbot) / botsq)
26223 dCAVdOM1 = dFdL * ( dFdOM1 )
26224 dCAVdOM2 = dFdL * ( dFdOM2 )
26225 dCAVdOM12 = dFdL * ( dFdOM12 )
26228 ertail(k) = Rtail_distance(k)/Rtail
26230 erdxi = scalar( ertail(1), dC_norm(1,i+nres) )
26231 erdxj = scalar( ertail(1), dC_norm(1,j+nres) )
26232 facd1 = dtail(1,itypi,itypj) * vbld_inv(i+nres)
26233 facd2 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
26235 !c! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
26236 !c! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
26237 pom = ertail(k)-facd1*(ertail(k)-erdxi*dC_norm(k,i+nres))
26238 gvdwx(k,i) = gvdwx(k,i) &
26239 - (( dFdR + gg(k) ) * pom)
26240 !c! & - ( dFdR * pom )
26241 pom = ertail(k)-facd2*(ertail(k)-erdxj*dC_norm(k,j+nres))
26242 gvdwx(k,j) = gvdwx(k,j) &
26243 + (( dFdR + gg(k) ) * pom)
26244 !c! & + ( dFdR * pom )
26246 gvdwc(k,i) = gvdwc(k,i) &
26247 - (( dFdR + gg(k) ) * ertail(k))
26248 !c! & - ( dFdR * ertail(k))
26250 gvdwc(k,j) = gvdwc(k,j) &
26251 + (( dFdR + gg(k) ) * ertail(k))
26252 !c! & + ( dFdR * ertail(k))
26255 ! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
26256 ! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
26260 !c! Compute head-head and head-tail energies for each state
26262 isel = iabs(Qi) + iabs(Qj)
26263 ! double charge for Phophorylated! itype - 25,27,27
26264 ! if ((itype(i).eq.27).or.(itype(i).eq.26).or.(itype(i).eq.25)) then
26268 ! if ((itype(j).eq.27).or.(itype(j).eq.26).or.(itype(j).eq.25)) then
26274 IF (isel.eq.0) THEN
26275 !c! No charges - do nothing
26278 ELSE IF (isel.eq.4) THEN
26279 !c! Calculate dipole-dipole interactions
26282 ! eheadtail = 0.0d0
26284 ELSE IF (isel.eq.1 .and. iabs(Qi).eq.1) THEN
26285 !c! Charge-nonpolar interactions
26286 if ((itype(i,1).eq.27).or.(itype(i,1).eq.26).or.(itype(i,1).eq.25)) then
26290 if ((itype(j,1).eq.27).or.(itype(j,1).eq.26).or.(itype(j,1).eq.25)) then
26297 ! eheadtail = 0.0d0
26299 ELSE IF (isel.eq.1 .and. iabs(Qj).eq.1) THEN
26300 !c! Nonpolar-charge interactions
26301 if ((itype(i,1).eq.27).or.(itype(i,1).eq.26).or.(itype(i,1).eq.25)) then
26305 if ((itype(j,1).eq.27).or.(itype(j,1).eq.26).or.(itype(j,1).eq.25)) then
26312 ! eheadtail = 0.0d0
26314 ELSE IF (isel.eq.3 .and. icharge(itypj).eq.2) THEN
26315 !c! Charge-dipole interactions
26316 if ((itype(i,1).eq.27).or.(itype(i,1).eq.26).or.(itype(i,1).eq.25)) then
26320 if ((itype(j,1).eq.27).or.(itype(j,1).eq.26).or.(itype(j,1).eq.25)) then
26325 CALL eqd(ecl, elj, epol)
26326 eheadtail = ECL + elj + epol
26327 ! eheadtail = 0.0d0
26329 ELSE IF (isel.eq.3 .and. icharge(itypi).eq.2) THEN
26330 !c! Dipole-charge interactions
26331 if ((itype(i,1).eq.27).or.(itype(i,1).eq.26).or.(itype(i,1).eq.25)) then
26335 if ((itype(j,1).eq.27).or.(itype(j,1).eq.26).or.(itype(j,1).eq.25)) then
26339 CALL edq(ecl, elj, epol)
26340 eheadtail = ECL + elj + epol
26341 ! eheadtail = 0.0d0
26343 ELSE IF ((isel.eq.2.and. &
26344 iabs(Qi).eq.1).and. &
26345 nstate(itypi,itypj).eq.1) THEN
26346 !c! Same charge-charge interaction ( +/+ or -/- )
26347 if ((itype(i,1).eq.27).or.(itype(i,1).eq.26).or.(itype(i,1).eq.25)) then
26351 if ((itype(j,1).eq.27).or.(itype(j,1).eq.26).or.(itype(j,1).eq.25)) then
26356 CALL eqq(Ecl,Egb,Epol,Fisocav,Elj)
26357 eheadtail = ECL + Egb + Epol + Fisocav + Elj
26358 ! eheadtail = 0.0d0
26360 ELSE IF ((isel.eq.2.and. &
26361 iabs(Qi).eq.1).and. &
26362 nstate(itypi,itypj).ne.1) THEN
26363 !c! Different charge-charge interaction ( +/- or -/+ )
26364 if ((itype(i,1).eq.27).or.(itype(i,1).eq.26).or.(itype(i,1).eq.25)) then
26368 if ((itype(j,1).eq.27).or.(itype(j,1).eq.26).or.(itype(j,1).eq.25)) then
26373 CALL energy_quad(istate,eheadtail,Ecl,Egb,Epol,Fisocav,Elj,Equad)
26375 END IF ! this endif ends the "catch the gly-gly" at the beggining of Fcav
26376 evdw = evdw + Fcav + eheadtail
26378 IF (energy_dec) write (iout,'(2(1x,a3,i3),3f6.2,10f16.7)') &
26379 restyp(itype(i,1),1),i,restyp(itype(j,1),1),j,&
26380 1.0d0/rij,Rtail,Rhead,evdwij,Fcav,Ecl,Egb,Epol,Fisocav,Elj,&
26381 Equad,evdwij+Fcav+eheadtail,evdw
26382 ! evdw = evdw + Fcav + eheadtail
26384 iF (nstate(itypi,itypj).eq.1) THEN
26387 !c!-------------------------------------------------------------------
26392 !c write (iout,*) "Number of loop steps in EGB:",ind
26393 !c energy_dec=.false.
26394 ! print *,"EVDW KURW",evdw,nres
26397 END SUBROUTINE emomo
26398 !C------------------------------------------------------------------------------------
26399 SUBROUTINE eqq(Ecl,Egb,Epol,Fisocav,Elj)
26402 real (kind=8) :: facd3, facd4, federmaus, adler,&
26403 Ecl,Egb,Epol,Fisocav,Elj,Fgb,debkap
26405 !c! Epol and Gpol analytical parameters
26406 alphapol1 = alphapol(itypi,itypj)
26407 alphapol2 = alphapol(itypj,itypi)
26408 !c! Fisocav and Gisocav analytical parameters
26409 al1 = alphiso(1,itypi,itypj)
26410 al2 = alphiso(2,itypi,itypj)
26411 al3 = alphiso(3,itypi,itypj)
26412 al4 = alphiso(4,itypi,itypj)
26414 / dsqrt(sigiso1(itypi, itypj)**2.0d0 &
26415 + sigiso2(itypi,itypj)**2.0d0))
26417 pis = sig0head(itypi,itypj)
26418 eps_head = epshead(itypi,itypj)
26419 Rhead_sq = Rhead * Rhead
26420 !c! R1 - distance between head of ith side chain and tail of jth sidechain
26421 !c! R2 - distance between head of jth side chain and tail of ith sidechain
26425 !c! Calculate head-to-tail distances needed by Epol
26426 R1=R1+(ctail(k,2)-chead(k,1))**2
26427 R2=R2+(chead(k,2)-ctail(k,1))**2
26433 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
26434 !c! & +dhead(1,1,itypi,itypj))**2))
26435 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
26436 !c! & +dhead(2,1,itypi,itypj))**2))
26438 !c!-------------------------------------------------------------------
26439 !c! Coulomb electrostatic interaction
26440 Ecl = (332.0d0 * Qij) / Rhead
26441 !c! derivative of Ecl is Gcl...
26442 dGCLdR = (-332.0d0 * Qij ) / Rhead_sq
26446 ee0 = dexp(-( Rhead_sq ) / (4.0d0 * a12sq))
26447 Fgb = sqrt( ( Rhead_sq ) + a12sq * ee0)
26448 debkap=debaykap(itypi,itypj)
26449 Egb = -(332.0d0 * Qij *&
26450 (1.0/eps_in-dexp(-debkap*Fgb)/eps_out)) / Fgb
26451 ! print *,"EGB WTF",Qij,eps_inout_fac,Fgb,itypi,itypj,eps_in,eps_out
26452 !c! Derivative of Egb is Ggb...
26453 dGGBdFGB = -(-332.0d0 * Qij * &
26454 (1.0/eps_in-dexp(-debkap*Fgb)/eps_out))/(Fgb*Fgb)&
26456 (dexp(-debkap*Fgb)*debkap/eps_out))/ Fgb
26457 dFGBdR = ( Rhead * ( 2.0d0 - (0.5d0 * ee0) ) )/ ( 2.0d0 * Fgb )
26458 dGGBdR = dGGBdFGB * dFGBdR
26459 !c!-------------------------------------------------------------------
26460 !c! Fisocav - isotropic cavity creation term
26461 !c! or "how much energy it costs to put charged head in water"
26463 top = al1 * (dsqrt(pom) + al2 * pom - al3)
26464 bot = (1.0d0 + al4 * pom**12.0d0)
26466 FisoCav = top / bot
26467 ! write (*,*) "Rhead = ",Rhead
26468 ! write (*,*) "csig = ",csig
26469 ! write (*,*) "pom = ",pom
26470 ! write (*,*) "al1 = ",al1
26471 ! write (*,*) "al2 = ",al2
26472 ! write (*,*) "al3 = ",al3
26473 ! write (*,*) "al4 = ",al4
26474 ! write (*,*) "top = ",top
26475 ! write (*,*) "bot = ",bot
26476 !c! Derivative of Fisocav is GCV...
26477 dtop = al1 * ((1.0d0 / (2.0d0 * dsqrt(pom))) + al2)
26478 dbot = 12.0d0 * al4 * pom ** 11.0d0
26479 dGCVdR = ((dtop * bot - top * dbot) / botsq) * csig
26480 !c!-------------------------------------------------------------------
26482 !c! Polarization energy - charged heads polarize hydrophobic "neck"
26483 MomoFac1 = (1.0d0 - chi1 * sqom2)
26484 MomoFac2 = (1.0d0 - chi2 * sqom1)
26485 RR1 = ( R1 * R1 ) / MomoFac1
26486 RR2 = ( R2 * R2 ) / MomoFac2
26487 ee1 = exp(-( RR1 / (4.0d0 * a12sq) ))
26488 ee2 = exp(-( RR2 / (4.0d0 * a12sq) ))
26489 fgb1 = sqrt( RR1 + a12sq * ee1 )
26490 fgb2 = sqrt( RR2 + a12sq * ee2 )
26491 epol = 332.0d0 * eps_inout_fac * ( &
26492 (( alphapol1 / fgb1 )**4.0d0)+((alphapol2/fgb2) ** 4.0d0 ))
26494 dPOLdFGB1 = -(1328.0d0 * eps_inout_fac * alphapol1 ** 4.0d0)&
26496 dPOLdFGB2 = -(1328.0d0 * eps_inout_fac * alphapol2 ** 4.0d0)&
26498 dFGBdR1 = ( (R1 / MomoFac1)* ( 2.0d0 - (0.5d0 * ee1) ) )&
26500 dFGBdR2 = ( (R2 / MomoFac2)* ( 2.0d0 - (0.5d0 * ee2) ) )&
26502 dFGBdOM2 = (((R1 * R1 * chi1 * om2) / (MomoFac1 * MomoFac1))&
26503 * ( 2.0d0 - 0.5d0 * ee1) ) / ( 2.0d0 * fgb1 )
26504 dFGBdOM1 = (((R2 * R2 * chi2 * om1) / (MomoFac2 * MomoFac2))&
26505 * ( 2.0d0 - 0.5d0 * ee2) ) / ( 2.0d0 * fgb2 )
26506 dPOLdR1 = dPOLdFGB1 * dFGBdR1
26507 !c! dPOLdR1 = 0.0d0
26508 dPOLdR2 = dPOLdFGB2 * dFGBdR2
26509 !c! dPOLdR2 = 0.0d0
26510 dPOLdOM1 = dPOLdFGB2 * dFGBdOM1
26511 !c! dPOLdOM1 = 0.0d0
26512 dPOLdOM2 = dPOLdFGB1 * dFGBdOM2
26513 !c! dPOLdOM2 = 0.0d0
26514 !c!-------------------------------------------------------------------
26516 !c! Lennard-Jones 6-12 interaction between heads
26517 pom = (pis / Rhead)**6.0d0
26518 Elj = 4.0d0 * eps_head * pom * (pom-1.0d0)
26519 !c! derivative of Elj is Glj
26520 dGLJdR = 4.0d0 * eps_head*(((-12.0d0*pis**12.0d0)/(Rhead**13.0d0))&
26521 + (( 6.0d0*pis**6.0d0) /(Rhead**7.0d0)))
26522 !c!-------------------------------------------------------------------
26523 !c! Return the results
26524 !c! These things do the dRdX derivatives, that is
26525 !c! allow us to change what we see from function that changes with
26526 !c! distance to function that changes with LOCATION (of the interaction
26529 erhead(k) = Rhead_distance(k)/Rhead
26530 erhead_tail(k,1) = ((ctail(k,2)-chead(k,1))/R1)
26531 erhead_tail(k,2) = ((chead(k,2)-ctail(k,1))/R2)
26534 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
26535 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
26536 bat = scalar( erhead_tail(1,1), dC_norm(1,i+nres) )
26537 federmaus = scalar(erhead_tail(1,1),dC_norm(1,j+nres))
26538 eagle = scalar( erhead_tail(1,2), dC_norm(1,j+nres) )
26539 adler = scalar( erhead_tail(1,2), dC_norm(1,i+nres) )
26540 facd1 = d1 * vbld_inv(i+nres)
26541 facd2 = d2 * vbld_inv(j+nres)
26542 facd3 = dtail(1,itypi,itypj) * vbld_inv(i+nres)
26543 facd4 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
26545 !c! Now we add appropriate partial derivatives (one in each dimension)
26547 hawk = (erhead_tail(k,1) + &
26548 facd1 * (erhead_tail(k,1) - bat * dC_norm(k,i+nres)))
26549 condor = (erhead_tail(k,2) + &
26550 facd2 * (erhead_tail(k,2) - eagle * dC_norm(k,j+nres)))
26552 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
26553 gvdwx(k,i) = gvdwx(k,i) &
26558 - dPOLdR2 * (erhead_tail(k,2)&
26559 -facd3 * (erhead_tail(k,2) - adler * dC_norm(k,i+nres)))&
26562 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
26563 gvdwx(k,j) = gvdwx(k,j)+ dGCLdR * pom&
26564 + dGGBdR * pom+ dGCVdR * pom&
26565 + dPOLdR1 * (erhead_tail(k,1)&
26566 -facd4 * (erhead_tail(k,1) - federmaus * dC_norm(k,j+nres)))&
26567 + dPOLdR2 * condor + dGLJdR * pom
26569 gvdwc(k,i) = gvdwc(k,i) &
26570 - dGCLdR * erhead(k)&
26571 - dGGBdR * erhead(k)&
26572 - dGCVdR * erhead(k)&
26573 - dPOLdR1 * erhead_tail(k,1)&
26574 - dPOLdR2 * erhead_tail(k,2)&
26575 - dGLJdR * erhead(k)
26577 gvdwc(k,j) = gvdwc(k,j) &
26578 + dGCLdR * erhead(k) &
26579 + dGGBdR * erhead(k) &
26580 + dGCVdR * erhead(k) &
26581 + dPOLdR1 * erhead_tail(k,1) &
26582 + dPOLdR2 * erhead_tail(k,2)&
26583 + dGLJdR * erhead(k)
26589 SUBROUTINE eqq_cat(Ecl,Egb,Epol,Fisocav,Elj)
26592 real (kind=8) :: facd3, facd4, federmaus, adler,&
26593 Ecl,Egb,Epol,Fisocav,Elj,Fgb,debkap
26595 !c! Epol and Gpol analytical parameters
26596 alphapol1 = alphapolcat(itypi,itypj)
26597 alphapol2 = alphapolcat(itypj,itypi)
26598 !c! Fisocav and Gisocav analytical parameters
26599 al1 = alphisocat(1,itypi,itypj)
26600 al2 = alphisocat(2,itypi,itypj)
26601 al3 = alphisocat(3,itypi,itypj)
26602 al4 = alphisocat(4,itypi,itypj)
26604 / dsqrt(sigiso1cat(itypi, itypj)**2.0d0 &
26605 + sigiso2cat(itypi,itypj)**2.0d0))
26607 pis = sig0headcat(itypi,itypj)
26608 eps_head = epsheadcat(itypi,itypj)
26609 Rhead_sq = Rhead * Rhead
26610 !c! R1 - distance between head of ith side chain and tail of jth sidechain
26611 !c! R2 - distance between head of jth side chain and tail of ith sidechain
26615 !c! Calculate head-to-tail distances needed by Epol
26616 R1=R1+(ctail(k,2)-chead(k,1))**2
26617 R2=R2+(chead(k,2)-ctail(k,1))**2
26623 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
26624 !c! & +dhead(1,1,itypi,itypj))**2))
26625 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
26626 !c! & +dhead(2,1,itypi,itypj))**2))
26628 !c!-------------------------------------------------------------------
26629 !c! Coulomb electrostatic interaction
26630 Ecl = (332.0d0 * Qij) / Rhead
26631 !c! derivative of Ecl is Gcl...
26632 dGCLdR = (-332.0d0 * Qij ) / Rhead_sq
26636 ee0 = dexp(-( Rhead_sq ) / (4.0d0 * a12sq))
26637 Fgb = sqrt( ( Rhead_sq ) + a12sq * ee0)
26638 debkap=debaykapcat(itypi,itypj)
26639 Egb = -(332.0d0 * Qij *&
26640 (1.0/eps_in-dexp(-debkap*Fgb)/eps_out)) / Fgb
26641 ! print *,"EGB WTF",Qij,eps_inout_fac,Fgb,itypi,itypj,eps_in,eps_out
26642 !c! Derivative of Egb is Ggb...
26643 dGGBdFGB = -(-332.0d0 * Qij * &
26644 (1.0/eps_in-dexp(-debkap*Fgb)/eps_out))/(Fgb*Fgb)&
26646 (dexp(-debkap*Fgb)*debkap/eps_out))/ Fgb
26647 dFGBdR = ( Rhead * ( 2.0d0 - (0.5d0 * ee0) ) )/ ( 2.0d0 * Fgb )
26648 dGGBdR = dGGBdFGB * dFGBdR
26649 !c!-------------------------------------------------------------------
26650 !c! Fisocav - isotropic cavity creation term
26651 !c! or "how much energy it costs to put charged head in water"
26653 top = al1 * (dsqrt(pom) + al2 * pom - al3)
26654 bot = (1.0d0 + al4 * pom**12.0d0)
26656 FisoCav = top / bot
26657 ! write (*,*) "Rhead = ",Rhead
26658 ! write (*,*) "csig = ",csig
26659 ! write (*,*) "pom = ",pom
26660 ! write (*,*) "al1 = ",al1
26661 ! write (*,*) "al2 = ",al2
26662 ! write (*,*) "al3 = ",al3
26663 ! write (*,*) "al4 = ",al4
26664 ! write (*,*) "top = ",top
26665 ! write (*,*) "bot = ",bot
26666 !c! Derivative of Fisocav is GCV...
26667 dtop = al1 * ((1.0d0 / (2.0d0 * dsqrt(pom))) + al2)
26668 dbot = 12.0d0 * al4 * pom ** 11.0d0
26669 dGCVdR = ((dtop * bot - top * dbot) / botsq) * csig
26670 !c!-------------------------------------------------------------------
26672 !c! Polarization energy - charged heads polarize hydrophobic "neck"
26673 MomoFac1 = (1.0d0 - chi1 * sqom2)
26674 MomoFac2 = (1.0d0 - chi2 * sqom1)
26675 RR1 = ( R1 * R1 ) / MomoFac1
26676 RR2 = ( R2 * R2 ) / MomoFac2
26677 ee1 = exp(-( RR1 / (4.0d0 * a12sq) ))
26678 ee2 = exp(-( RR2 / (4.0d0 * a12sq) ))
26679 fgb1 = sqrt( RR1 + a12sq * ee1 )
26680 fgb2 = sqrt( RR2 + a12sq * ee2 )
26681 epol = 332.0d0 * eps_inout_fac * ( &
26682 (( alphapol1 / fgb1 )**4.0d0)+((alphapol2/fgb2) ** 4.0d0 ))
26684 dPOLdFGB1 = -(1328.0d0 * eps_inout_fac * alphapol1 ** 4.0d0)&
26686 dPOLdFGB2 = -(1328.0d0 * eps_inout_fac * alphapol2 ** 4.0d0)&
26688 dFGBdR1 = ( (R1 / MomoFac1)* ( 2.0d0 - (0.5d0 * ee1) ) )&
26690 dFGBdR2 = ( (R2 / MomoFac2)* ( 2.0d0 - (0.5d0 * ee2) ) )&
26692 dFGBdOM2 = (((R1 * R1 * chi1 * om2) / (MomoFac1 * MomoFac1))&
26693 * ( 2.0d0 - 0.5d0 * ee1) ) / ( 2.0d0 * fgb1 )
26694 dFGBdOM1 = (((R2 * R2 * chi2 * om1) / (MomoFac2 * MomoFac2))&
26695 * ( 2.0d0 - 0.5d0 * ee2) ) / ( 2.0d0 * fgb2 )
26696 dPOLdR1 = dPOLdFGB1 * dFGBdR1
26697 !c! dPOLdR1 = 0.0d0
26698 dPOLdR2 = dPOLdFGB2 * dFGBdR2
26699 !c! dPOLdR2 = 0.0d0
26700 dPOLdOM1 = dPOLdFGB2 * dFGBdOM1
26701 !c! dPOLdOM1 = 0.0d0
26702 dPOLdOM2 = dPOLdFGB1 * dFGBdOM2
26703 !c! dPOLdOM2 = 0.0d0
26704 !c!-------------------------------------------------------------------
26706 !c! Lennard-Jones 6-12 interaction between heads
26707 pom = (pis / Rhead)**6.0d0
26708 Elj = 4.0d0 * eps_head * pom * (pom-1.0d0)
26709 !c! derivative of Elj is Glj
26710 dGLJdR = 4.0d0 * eps_head*(((-12.0d0*pis**12.0d0)/(Rhead**13.0d0))&
26711 + (( 6.0d0*pis**6.0d0) /(Rhead**7.0d0)))
26712 !c!-------------------------------------------------------------------
26713 !c! Return the results
26714 !c! These things do the dRdX derivatives, that is
26715 !c! allow us to change what we see from function that changes with
26716 !c! distance to function that changes with LOCATION (of the interaction
26719 erhead(k) = Rhead_distance(k)/Rhead
26720 erhead_tail(k,1) = ((ctail(k,2)-chead(k,1))/R1)
26721 erhead_tail(k,2) = ((chead(k,2)-ctail(k,1))/R2)
26724 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
26725 erdxj = scalar( erhead(1), dC_norm(1,j) )
26726 bat = scalar( erhead_tail(1,1), dC_norm(1,i+nres) )
26727 federmaus = scalar(erhead_tail(1,1),dC_norm(1,j))
26728 eagle = scalar( erhead_tail(1,2), dC_norm(1,j) )
26729 adler = scalar( erhead_tail(1,2), dC_norm(1,i+nres) )
26730 facd1 = d1 * vbld_inv(i+nres)
26731 facd2 = d2 * vbld_inv(j)
26732 facd3 = dtailcat(1,itypi,itypj) * vbld_inv(i+nres)
26733 facd4 = dtailcat(2,itypi,itypj) * vbld_inv(j)
26735 !c! Now we add appropriate partial derivatives (one in each dimension)
26737 hawk = (erhead_tail(k,1) + &
26738 facd1 * (erhead_tail(k,1) - bat * dC_norm(k,i+nres)))
26739 condor = (erhead_tail(k,2) + &
26740 facd2 * (erhead_tail(k,2) - eagle * dC_norm(k,j)))
26742 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
26743 gradpepcatx(k,i) = gradpepcatx(k,i) &
26748 - dPOLdR2 * (erhead_tail(k,2)&
26749 -facd3 * (erhead_tail(k,2) - adler * dC_norm(k,i+nres)))&
26752 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j))
26753 ! gradpepcatx(k,j) = gradpepcatx(k,j)+ dGCLdR * pom&
26754 ! + dGGBdR * pom+ dGCVdR * pom&
26755 ! + dPOLdR1 * (erhead_tail(k,1)&
26756 ! -facd4 * (erhead_tail(k,1) - federmaus * dC_norm(k,j)))&
26757 ! + dPOLdR2 * condor + dGLJdR * pom
26759 gradpepcat(k,i) = gradpepcat(k,i) &
26760 - dGCLdR * erhead(k)&
26761 - dGGBdR * erhead(k)&
26762 - dGCVdR * erhead(k)&
26763 - dPOLdR1 * erhead_tail(k,1)&
26764 - dPOLdR2 * erhead_tail(k,2)&
26765 - dGLJdR * erhead(k)
26767 gradpepcat(k,j) = gradpepcat(k,j) &
26768 + dGCLdR * erhead(k) &
26769 + dGGBdR * erhead(k) &
26770 + dGCVdR * erhead(k) &
26771 + dPOLdR1 * erhead_tail(k,1) &
26772 + dPOLdR2 * erhead_tail(k,2)&
26773 + dGLJdR * erhead(k)
26777 END SUBROUTINE eqq_cat
26778 !c!-------------------------------------------------------------------
26779 SUBROUTINE energy_quad(istate,eheadtail,Ecl,Egb,Epol,Fisocav,Elj,Equad)
26783 double precision eheadtail,Ecl,Egb,Epol,Fisocav,Elj,Equad
26784 double precision ener(4)
26785 double precision dcosom1(3),dcosom2(3)
26786 !c! used in Epol derivatives
26787 double precision facd3, facd4
26788 double precision federmaus, adler
26789 integer istate,ii,jj
26790 real (kind=8) :: Fgb
26791 ! print *,"CALLING EQUAD"
26792 !c! Epol and Gpol analytical parameters
26793 alphapol1 = alphapol(itypi,itypj)
26794 alphapol2 = alphapol(itypj,itypi)
26795 !c! Fisocav and Gisocav analytical parameters
26796 al1 = alphiso(1,itypi,itypj)
26797 al2 = alphiso(2,itypi,itypj)
26798 al3 = alphiso(3,itypi,itypj)
26799 al4 = alphiso(4,itypi,itypj)
26800 csig = (1.0d0 / dsqrt(sigiso1(itypi, itypj)**2.0d0&
26801 + sigiso2(itypi,itypj)**2.0d0))
26803 w1 = wqdip(1,itypi,itypj)
26804 w2 = wqdip(2,itypi,itypj)
26805 pis = sig0head(itypi,itypj)
26806 eps_head = epshead(itypi,itypj)
26807 !c! First things first:
26808 !c! We need to do sc_grad's job with GB and Fcav
26809 eom1 = eps2der * eps2rt_om1 &
26810 - 2.0D0 * alf1 * eps3der&
26811 + sigder * sigsq_om1&
26813 eom2 = eps2der * eps2rt_om2 &
26814 + 2.0D0 * alf2 * eps3der&
26815 + sigder * sigsq_om2&
26817 eom12 = evdwij * eps1_om12 &
26818 + eps2der * eps2rt_om12 &
26819 - 2.0D0 * alf12 * eps3der&
26820 + sigder *sigsq_om12&
26822 !c! now some magical transformations to project gradient into
26823 !c! three cartesian vectors
26825 dcosom1(k) = rij * (dc_norm(k,nres+i) - om1 * erij(k))
26826 dcosom2(k) = rij * (dc_norm(k,nres+j) - om2 * erij(k))
26827 gg(k) = gg(k) + eom1 * dcosom1(k) + eom2 * dcosom2(k)
26828 !c! this acts on hydrophobic center of interaction
26829 gvdwx(k,i)= gvdwx(k,i) - gg(k) &
26830 + (eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))&
26831 + eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
26832 gvdwx(k,j)= gvdwx(k,j) + gg(k) &
26833 + (eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))&
26834 + eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
26835 !c! this acts on Calpha
26836 gvdwc(k,i)=gvdwc(k,i)-gg(k)
26837 gvdwc(k,j)=gvdwc(k,j)+gg(k)
26839 !c! sc_grad is done, now we will compute
26844 DO istate = 1, nstate(itypi,itypj)
26845 !c*************************************************************
26846 IF (istate.ne.1) THEN
26847 IF (istate.lt.3) THEN
26853 d1 = dhead(1,ii,itypi,itypj)
26854 d2 = dhead(2,jj,itypi,itypj)
26856 chead(k,1) = c(k, i+nres) + d1 * dc_norm(k, i+nres)
26857 chead(k,2) = c(k, j+nres) + d2 * dc_norm(k, j+nres)
26858 Rhead_distance(k) = chead(k,2) - chead(k,1)
26860 !c! pitagoras (root of sum of squares)
26862 (Rhead_distance(1)*Rhead_distance(1)) &
26863 + (Rhead_distance(2)*Rhead_distance(2)) &
26864 + (Rhead_distance(3)*Rhead_distance(3)))
26866 Rhead_sq = Rhead * Rhead
26868 !c! R1 - distance between head of ith side chain and tail of jth sidechain
26869 !c! R2 - distance between head of jth side chain and tail of ith sidechain
26873 !c! Calculate head-to-tail distances
26874 R1=R1+(ctail(k,2)-chead(k,1))**2
26875 R2=R2+(chead(k,2)-ctail(k,1))**2
26880 Ecl = (332.0d0 * Qij) / (Rhead * eps_in)
26882 !c! write (*,*) "Ecl = ", Ecl
26883 !c! derivative of Ecl is Gcl...
26884 dGCLdR = (-332.0d0 * Qij ) / (Rhead_sq * eps_in)
26889 !c!-------------------------------------------------------------------
26890 !c! Generalised Born Solvent Polarization
26891 ee0 = dexp(-( Rhead_sq ) / (4.0d0 * a12sq))
26892 Fgb = sqrt( ( Rhead_sq ) + a12sq * ee0)
26893 Egb = -(332.0d0 * Qij * eps_inout_fac) / Fgb
26895 !c! write (*,*) "a1*a2 = ", a12sq
26896 !c! write (*,*) "Rhead = ", Rhead
26897 !c! write (*,*) "Rhead_sq = ", Rhead_sq
26898 !c! write (*,*) "ee = ", ee
26899 !c! write (*,*) "Fgb = ", Fgb
26900 !c! write (*,*) "fac = ", eps_inout_fac
26901 !c! write (*,*) "Qij = ", Qij
26902 !c! write (*,*) "Egb = ", Egb
26903 !c! Derivative of Egb is Ggb...
26904 !c! dFGBdR is used by Quad's later...
26905 dGGBdFGB = -(-332.0d0 * Qij * eps_inout_fac) / (Fgb * Fgb)
26906 dFGBdR = ( Rhead * ( 2.0d0 - (0.5d0 * ee0) ) )&
26908 dGGBdR = dGGBdFGB * dFGBdR
26910 !c!-------------------------------------------------------------------
26911 !c! Fisocav - isotropic cavity creation term
26913 top = al1 * (dsqrt(pom) + al2 * pom - al3)
26914 bot = (1.0d0 + al4 * pom**12.0d0)
26916 FisoCav = top / bot
26917 dtop = al1 * ((1.0d0 / (2.0d0 * dsqrt(pom))) + al2)
26918 dbot = 12.0d0 * al4 * pom ** 11.0d0
26919 dGCVdR = ((dtop * bot - top * dbot) / botsq) * csig
26921 !c!-------------------------------------------------------------------
26922 !c! Polarization energy
26924 MomoFac1 = (1.0d0 - chi1 * sqom2)
26925 MomoFac2 = (1.0d0 - chi2 * sqom1)
26926 RR1 = ( R1 * R1 ) / MomoFac1
26927 RR2 = ( R2 * R2 ) / MomoFac2
26928 ee1 = exp(-( RR1 / (4.0d0 * a12sq) ))
26929 ee2 = exp(-( RR2 / (4.0d0 * a12sq) ))
26930 fgb1 = sqrt( RR1 + a12sq * ee1 )
26931 fgb2 = sqrt( RR2 + a12sq * ee2 )
26932 epol = 332.0d0 * eps_inout_fac * (&
26933 (( alphapol1 / fgb1 )**4.0d0)+((alphapol2/fgb2) ** 4.0d0 ))
26935 !c! derivative of Epol is Gpol...
26936 dPOLdFGB1 = -(1328.0d0 * eps_inout_fac * alphapol1 ** 4.0d0)&
26938 dPOLdFGB2 = -(1328.0d0 * eps_inout_fac * alphapol2 ** 4.0d0)&
26940 dFGBdR1 = ( (R1 / MomoFac1) &
26941 * ( 2.0d0 - (0.5d0 * ee1) ) )&
26943 dFGBdR2 = ( (R2 / MomoFac2) &
26944 * ( 2.0d0 - (0.5d0 * ee2) ) ) &
26946 dFGBdOM2 = (((R1 * R1 * chi1 * om2) / (MomoFac1 * MomoFac1)) &
26947 * ( 2.0d0 - 0.5d0 * ee1) ) &
26949 dFGBdOM1 = (((R2 * R2 * chi2 * om1) / (MomoFac2 * MomoFac2)) &
26950 * ( 2.0d0 - 0.5d0 * ee2) ) &
26952 dPOLdR1 = dPOLdFGB1 * dFGBdR1
26953 !c! dPOLdR1 = 0.0d0
26954 dPOLdR2 = dPOLdFGB2 * dFGBdR2
26955 !c! dPOLdR2 = 0.0d0
26956 dPOLdOM1 = dPOLdFGB2 * dFGBdOM1
26957 !c! dPOLdOM1 = 0.0d0
26958 dPOLdOM2 = dPOLdFGB1 * dFGBdOM2
26959 pom = (pis / Rhead)**6.0d0
26960 Elj = 4.0d0 * eps_head * pom * (pom-1.0d0)
26962 !c! derivative of Elj is Glj
26963 dGLJdR = 4.0d0 * eps_head &
26964 * (((-12.0d0*pis**12.0d0)/(Rhead**13.0d0)) &
26965 + (( 6.0d0*pis**6.0d0) /(Rhead**7.0d0)))
26967 !c!-------------------------------------------------------------------
26969 IF (Wqd.ne.0.0d0) THEN
26970 Beta1 = 5.0d0 + 3.0d0 * (sqom12 - 1.0d0) &
26971 - 37.5d0 * ( sqom1 + sqom2 ) &
26972 + 157.5d0 * ( sqom1 * sqom2 ) &
26973 - 45.0d0 * om1*om2*om12
26974 fac = -( Wqd / (2.0d0 * Fgb**5.0d0) )
26975 Equad = fac * Beta1
26977 !c! derivative of Equad...
26978 dQUADdR = ((2.5d0 * Wqd * Beta1) / (Fgb**6.0d0)) * dFGBdR
26979 !c! dQUADdR = 0.0d0
26980 dQUADdOM1 = fac* (-75.0d0*om1 + 315.0d0*om1*sqom2 - 45.0d0*om2*om12)
26981 !c! dQUADdOM1 = 0.0d0
26982 dQUADdOM2 = fac* (-75.0d0*om2 + 315.0d0*sqom1*om2 - 45.0d0*om1*om12)
26983 !c! dQUADdOM2 = 0.0d0
26984 dQUADdOM12 = fac * ( 6.0d0*om12 - 45.0d0*om1*om2 )
26989 !c!-------------------------------------------------------------------
26990 !c! Return the results
26992 eom1 = dPOLdOM1 + dQUADdOM1
26993 eom2 = dPOLdOM2 + dQUADdOM2
26995 !c! now some magical transformations to project gradient into
26996 !c! three cartesian vectors
26998 dcosom1(k) = rij * (dc_norm(k,nres+i) - om1 * erij(k))
26999 dcosom2(k) = rij * (dc_norm(k,nres+j) - om2 * erij(k))
27000 tuna(k) = eom1 * dcosom1(k) + eom2 * dcosom2(k)
27004 erhead(k) = Rhead_distance(k)/Rhead
27005 erhead_tail(k,1) = ((ctail(k,2)-chead(k,1))/R1)
27006 erhead_tail(k,2) = ((chead(k,2)-ctail(k,1))/R2)
27008 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
27009 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
27010 bat = scalar( erhead_tail(1,1), dC_norm(1,i+nres) )
27011 federmaus = scalar(erhead_tail(1,1),dC_norm(1,j+nres))
27012 eagle = scalar( erhead_tail(1,2), dC_norm(1,j+nres) )
27013 adler = scalar( erhead_tail(1,2), dC_norm(1,i+nres) )
27014 facd1 = d1 * vbld_inv(i+nres)
27015 facd2 = d2 * vbld_inv(j+nres)
27016 facd3 = dtail(1,itypi,itypj) * vbld_inv(i+nres)
27017 facd4 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
27019 hawk = erhead_tail(k,1) + &
27020 facd1 * (erhead_tail(k,1) - bat * dC_norm(k,i+nres))
27021 condor = erhead_tail(k,2) + &
27022 facd2 * (erhead_tail(k,2) - eagle * dC_norm(k,j+nres))
27024 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
27025 !c! this acts on hydrophobic center of interaction
27026 gheadtail(k,1,1) = gheadtail(k,1,1) &
27031 - dPOLdR2 * (erhead_tail(k,2) &
27032 -facd3 * (erhead_tail(k,2) - adler * dC_norm(k,i+nres)))&
27036 + (eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))&
27037 + eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
27039 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
27040 !c! this acts on hydrophobic center of interaction
27041 gheadtail(k,2,1) = gheadtail(k,2,1) &
27045 + dPOLdR1 * (erhead_tail(k,1) &
27046 -facd4 * (erhead_tail(k,1) - federmaus * dC_norm(k,j+nres))) &
27047 + dPOLdR2 * condor &
27051 + (eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
27052 + eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
27054 !c! this acts on Calpha
27055 gheadtail(k,3,1) = gheadtail(k,3,1) &
27056 - dGCLdR * erhead(k)&
27057 - dGGBdR * erhead(k)&
27058 - dGCVdR * erhead(k)&
27059 - dPOLdR1 * erhead_tail(k,1)&
27060 - dPOLdR2 * erhead_tail(k,2)&
27061 - dGLJdR * erhead(k) &
27062 - dQUADdR * erhead(k)&
27064 !c! this acts on Calpha
27065 gheadtail(k,4,1) = gheadtail(k,4,1) &
27066 + dGCLdR * erhead(k) &
27067 + dGGBdR * erhead(k) &
27068 + dGCVdR * erhead(k) &
27069 + dPOLdR1 * erhead_tail(k,1) &
27070 + dPOLdR2 * erhead_tail(k,2) &
27071 + dGLJdR * erhead(k) &
27072 + dQUADdR * erhead(k)&
27075 ener(istate) = ECL + Egb + Epol + Fisocav + Elj + Equad
27076 eheadtail = eheadtail &
27077 + wstate(istate, itypi, itypj) &
27078 * dexp(-betaT * ener(istate))
27079 !c! foreach cartesian dimension
27081 !c! foreach of two gvdwx and gvdwc
27083 gheadtail(k,l,2) = gheadtail(k,l,2) &
27084 + wstate( istate, itypi, itypj ) &
27085 * dexp(-betaT * ener(istate)) &
27087 gheadtail(k,l,1) = 0.0d0
27091 !c! Here ended the gigantic DO istate = 1, 4, which starts
27092 !c! at the beggining of the subroutine
27096 gheadtail(k,l,2) = gheadtail(k,l,2) / eheadtail
27098 gvdwx(k,i) = gvdwx(k,i) + gheadtail(k,1,2)
27099 gvdwx(k,j) = gvdwx(k,j) + gheadtail(k,2,2)
27100 gvdwc(k,i) = gvdwc(k,i) + gheadtail(k,3,2)
27101 gvdwc(k,j) = gvdwc(k,j) + gheadtail(k,4,2)
27103 gheadtail(k,l,1) = 0.0d0
27104 gheadtail(k,l,2) = 0.0d0
27107 eheadtail = (-dlog(eheadtail)) / betaT
27114 END SUBROUTINE energy_quad
27115 !!-----------------------------------------------------------
27116 SUBROUTINE eqn(Epol)
27120 double precision facd4, federmaus,epol
27121 alphapol1 = alphapol(itypi,itypj)
27122 !c! R1 - distance between head of ith side chain and tail of jth sidechain
27125 !c! Calculate head-to-tail distances
27126 R1=R1+(ctail(k,2)-chead(k,1))**2
27131 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
27132 !c! & +dhead(1,1,itypi,itypj))**2))
27133 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
27134 !c! & +dhead(2,1,itypi,itypj))**2))
27135 !c--------------------------------------------------------------------
27136 !c Polarization energy
27138 MomoFac1 = (1.0d0 - chi1 * sqom2)
27139 RR1 = R1 * R1 / MomoFac1
27140 ee1 = exp(-( RR1 / (4.0d0 * a12sq) ))
27141 fgb1 = sqrt( RR1 + a12sq * ee1)
27142 epol = 332.0d0 * eps_inout_fac * (( alphapol1 / fgb1 )**4.0d0)
27143 dPOLdFGB1 = -(1328.0d0 * eps_inout_fac * alphapol1 ** 4.0d0) &
27145 dFGBdR1 = ( (R1 / MomoFac1) &
27146 * ( 2.0d0 - (0.5d0 * ee1) ) ) &
27148 dFGBdOM2 = (((R1 * R1 * chi1 * om2) / (MomoFac1 * MomoFac1)) &
27149 * (2.0d0 - 0.5d0 * ee1) ) &
27151 dPOLdR1 = dPOLdFGB1 * dFGBdR1
27152 !c! dPOLdR1 = 0.0d0
27154 dPOLdOM2 = dPOLdFGB1 * dFGBdOM2
27156 erhead_tail(k,1) = ((ctail(k,2)-chead(k,1))/R1)
27158 bat = scalar( erhead_tail(1,1), dC_norm(1,i+nres) )
27159 federmaus = scalar(erhead_tail(1,1),dC_norm(1,j+nres))
27160 facd1 = d1 * vbld_inv(i+nres)
27161 facd4 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
27164 hawk = (erhead_tail(k,1) + &
27165 facd1 * (erhead_tail(k,1) - bat * dC_norm(k,i+nres)))
27167 gvdwx(k,i) = gvdwx(k,i) &
27169 gvdwx(k,j) = gvdwx(k,j) &
27170 + dPOLdR1 * (erhead_tail(k,1) &
27171 -facd4 * (erhead_tail(k,1) - federmaus * dC_norm(k,j+nres)))
27173 gvdwc(k,i) = gvdwc(k,i) - dPOLdR1 * erhead_tail(k,1)
27174 gvdwc(k,j) = gvdwc(k,j) + dPOLdR1 * erhead_tail(k,1)
27179 SUBROUTINE enq(Epol)
27182 double precision facd3, adler,epol
27183 alphapol2 = alphapol(itypj,itypi)
27184 !c! R2 - distance between head of jth side chain and tail of ith sidechain
27187 !c! Calculate head-to-tail distances
27188 R2=R2+(chead(k,2)-ctail(k,1))**2
27193 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
27194 !c! & +dhead(1,1,itypi,itypj))**2))
27195 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
27196 !c! & +dhead(2,1,itypi,itypj))**2))
27197 !c------------------------------------------------------------------------
27198 !c Polarization energy
27199 MomoFac2 = (1.0d0 - chi2 * sqom1)
27200 RR2 = R2 * R2 / MomoFac2
27201 ee2 = exp(-(RR2 / (4.0d0 * a12sq)))
27202 fgb2 = sqrt(RR2 + a12sq * ee2)
27203 epol = 332.0d0 * eps_inout_fac * ((alphapol2/fgb2) ** 4.0d0 )
27204 dPOLdFGB2 = -(1328.0d0 * eps_inout_fac * alphapol2 ** 4.0d0) &
27206 dFGBdR2 = ( (R2 / MomoFac2) &
27207 * ( 2.0d0 - (0.5d0 * ee2) ) ) &
27209 dFGBdOM1 = (((R2 * R2 * chi2 * om1) / (MomoFac2 * MomoFac2)) &
27210 * (2.0d0 - 0.5d0 * ee2) ) &
27212 dPOLdR2 = dPOLdFGB2 * dFGBdR2
27213 !c! dPOLdR2 = 0.0d0
27214 dPOLdOM1 = dPOLdFGB2 * dFGBdOM1
27215 !c! dPOLdOM1 = 0.0d0
27217 !c!-------------------------------------------------------------------
27218 !c! Return the results
27219 !c! (See comments in Eqq)
27221 erhead_tail(k,2) = ((chead(k,2)-ctail(k,1))/R2)
27223 eagle = scalar( erhead_tail(1,2), dC_norm(1,j+nres) )
27224 adler = scalar( erhead_tail(1,2), dC_norm(1,i+nres) )
27225 facd2 = d2 * vbld_inv(j+nres)
27226 facd3 = dtail(1,itypi,itypj) * vbld_inv(i+nres)
27228 condor = (erhead_tail(k,2) &
27229 + facd2 * (erhead_tail(k,2) - eagle * dC_norm(k,j+nres)))
27231 gvdwx(k,i) = gvdwx(k,i) &
27232 - dPOLdR2 * (erhead_tail(k,2) &
27233 -facd3 * (erhead_tail(k,2) - adler * dC_norm(k,i+nres)))
27234 gvdwx(k,j) = gvdwx(k,j) &
27237 gvdwc(k,i) = gvdwc(k,i) &
27238 - dPOLdR2 * erhead_tail(k,2)
27239 gvdwc(k,j) = gvdwc(k,j) &
27240 + dPOLdR2 * erhead_tail(k,2)
27246 SUBROUTINE enq_cat(Epol)
27249 double precision facd3, adler,epol
27250 alphapol2 = alphapolcat(itypj,itypi)
27251 !c! R2 - distance between head of jth side chain and tail of ith sidechain
27254 !c! Calculate head-to-tail distances
27255 R2=R2+(chead(k,2)-ctail(k,1))**2
27260 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
27261 !c! & +dhead(1,1,itypi,itypj))**2))
27262 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
27263 !c! & +dhead(2,1,itypi,itypj))**2))
27264 !c------------------------------------------------------------------------
27265 !c Polarization energy
27266 MomoFac2 = (1.0d0 - chi2 * sqom1)
27267 RR2 = R2 * R2 / MomoFac2
27268 ee2 = exp(-(RR2 / (4.0d0 * a12sq)))
27269 fgb2 = sqrt(RR2 + a12sq * ee2)
27270 epol = 332.0d0 * eps_inout_fac * ((alphapol2/fgb2) ** 4.0d0 )
27271 dPOLdFGB2 = -(1328.0d0 * eps_inout_fac * alphapol2 ** 4.0d0) &
27273 dFGBdR2 = ( (R2 / MomoFac2) &
27274 * ( 2.0d0 - (0.5d0 * ee2) ) ) &
27276 dFGBdOM1 = (((R2 * R2 * chi2 * om1) / (MomoFac2 * MomoFac2)) &
27277 * (2.0d0 - 0.5d0 * ee2) ) &
27279 dPOLdR2 = dPOLdFGB2 * dFGBdR2
27280 !c! dPOLdR2 = 0.0d0
27281 dPOLdOM1 = dPOLdFGB2 * dFGBdOM1
27282 !c! dPOLdOM1 = 0.0d0
27285 !c!-------------------------------------------------------------------
27286 !c! Return the results
27287 !c! (See comments in Eqq)
27289 erhead_tail(k,2) = ((chead(k,2)-ctail(k,1))/R2)
27291 eagle = scalar( erhead_tail(1,2), dC_norm(1,j) )
27292 adler = scalar( erhead_tail(1,2), dC_norm(1,i+nres) )
27293 facd2 = d2 * vbld_inv(j+nres)
27294 facd3 = dtailcat(1,itypi,itypj) * vbld_inv(i+nres)
27296 condor = (erhead_tail(k,2) &
27297 + facd2 * (erhead_tail(k,2) - eagle * dC_norm(k,j)))
27299 gradpepcatx(k,i) = gradpepcatx(k,i) &
27300 - dPOLdR2 * (erhead_tail(k,2) &
27301 -facd3 * (erhead_tail(k,2) - adler * dC_norm(k,i+nres)))
27302 ! gradpepcatx(k,j) = gradpepcatx(k,j) &
27303 ! + dPOLdR2 * condor
27305 gradpepcat(k,i) = gradpepcat(k,i) &
27306 - dPOLdR2 * erhead_tail(k,2)
27307 gradpepcat(k,j) = gradpepcat(k,j) &
27308 + dPOLdR2 * erhead_tail(k,2)
27312 END SUBROUTINE enq_cat
27314 SUBROUTINE eqd(Ecl,Elj,Epol)
27317 double precision facd4, federmaus,ecl,elj,epol
27318 alphapol1 = alphapol(itypi,itypj)
27319 w1 = wqdip(1,itypi,itypj)
27320 w2 = wqdip(2,itypi,itypj)
27321 pis = sig0head(itypi,itypj)
27322 eps_head = epshead(itypi,itypj)
27323 !c!-------------------------------------------------------------------
27324 !c! R1 - distance between head of ith side chain and tail of jth sidechain
27327 !c! Calculate head-to-tail distances
27328 R1=R1+(ctail(k,2)-chead(k,1))**2
27333 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
27334 !c! & +dhead(1,1,itypi,itypj))**2))
27335 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
27336 !c! & +dhead(2,1,itypi,itypj))**2))
27338 !c!-------------------------------------------------------------------
27340 sparrow = w1 * Qi * om1
27341 hawk = w2 * Qi * Qi * (1.0d0 - sqom2)
27342 Ecl = sparrow / Rhead**2.0d0 &
27343 - hawk / Rhead**4.0d0
27344 dGCLdR = - 2.0d0 * sparrow / Rhead**3.0d0 &
27345 + 4.0d0 * hawk / Rhead**5.0d0
27347 dGCLdOM1 = (w1 * Qi) / (Rhead**2.0d0)
27349 dGCLdOM2 = (2.0d0 * w2 * Qi * Qi * om2) / (Rhead ** 4.0d0)
27350 !c--------------------------------------------------------------------
27351 !c Polarization energy
27353 MomoFac1 = (1.0d0 - chi1 * sqom2)
27354 RR1 = R1 * R1 / MomoFac1
27355 ee1 = exp(-( RR1 / (4.0d0 * a12sq) ))
27356 fgb1 = sqrt( RR1 + a12sq * ee1)
27357 epol = 332.0d0 * eps_inout_fac * (( alphapol1 / fgb1 )**4.0d0)
27359 !c!------------------------------------------------------------------
27360 !c! derivative of Epol is Gpol...
27361 dPOLdFGB1 = -(1328.0d0 * eps_inout_fac * alphapol1 ** 4.0d0) &
27363 dFGBdR1 = ( (R1 / MomoFac1) &
27364 * ( 2.0d0 - (0.5d0 * ee1) ) ) &
27366 dFGBdOM2 = (((R1 * R1 * chi1 * om2) / (MomoFac1 * MomoFac1)) &
27367 * (2.0d0 - 0.5d0 * ee1) ) &
27369 dPOLdR1 = dPOLdFGB1 * dFGBdR1
27370 !c! dPOLdR1 = 0.0d0
27372 dPOLdOM2 = dPOLdFGB1 * dFGBdOM2
27373 !c! dPOLdOM2 = 0.0d0
27374 !c!-------------------------------------------------------------------
27376 pom = (pis / Rhead)**6.0d0
27377 Elj = 4.0d0 * eps_head * pom * (pom-1.0d0)
27378 !c! derivative of Elj is Glj
27379 dGLJdR = 4.0d0 * eps_head &
27380 * (((-12.0d0*pis**12.0d0)/(Rhead**13.0d0)) &
27381 + (( 6.0d0*pis**6.0d0) /(Rhead**7.0d0)))
27383 erhead(k) = Rhead_distance(k)/Rhead
27384 erhead_tail(k,1) = ((ctail(k,2)-chead(k,1))/R1)
27387 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
27388 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
27389 bat = scalar( erhead_tail(1,1), dC_norm(1,i+nres) )
27390 federmaus = scalar(erhead_tail(1,1),dC_norm(1,j+nres))
27391 facd1 = d1 * vbld_inv(i+nres)
27392 facd2 = d2 * vbld_inv(j+nres)
27393 facd4 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
27396 hawk = (erhead_tail(k,1) + &
27397 facd1 * (erhead_tail(k,1) - bat * dC_norm(k,i+nres)))
27399 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
27400 gvdwx(k,i) = gvdwx(k,i) &
27405 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
27406 gvdwx(k,j) = gvdwx(k,j) &
27408 + dPOLdR1 * (erhead_tail(k,1) &
27409 -facd4 * (erhead_tail(k,1) - federmaus * dC_norm(k,j+nres))) &
27413 gvdwc(k,i) = gvdwc(k,i) &
27414 - dGCLdR * erhead(k) &
27415 - dPOLdR1 * erhead_tail(k,1) &
27416 - dGLJdR * erhead(k)
27418 gvdwc(k,j) = gvdwc(k,j) &
27419 + dGCLdR * erhead(k) &
27420 + dPOLdR1 * erhead_tail(k,1) &
27421 + dGLJdR * erhead(k)
27426 SUBROUTINE edq(Ecl,Elj,Epol)
27431 double precision facd3, adler,ecl,elj,epol
27432 alphapol2 = alphapol(itypj,itypi)
27433 w1 = wqdip(1,itypi,itypj)
27434 w2 = wqdip(2,itypi,itypj)
27435 pis = sig0head(itypi,itypj)
27436 eps_head = epshead(itypi,itypj)
27437 !c!-------------------------------------------------------------------
27438 !c! R2 - distance between head of jth side chain and tail of ith sidechain
27441 !c! Calculate head-to-tail distances
27442 R2=R2+(chead(k,2)-ctail(k,1))**2
27447 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
27448 !c! & +dhead(1,1,itypi,itypj))**2))
27449 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
27450 !c! & +dhead(2,1,itypi,itypj))**2))
27453 !c!-------------------------------------------------------------------
27455 sparrow = w1 * Qj * om1
27456 hawk = w2 * Qj * Qj * (1.0d0 - sqom2)
27457 ECL = sparrow / Rhead**2.0d0 &
27458 - hawk / Rhead**4.0d0
27459 !c!-------------------------------------------------------------------
27460 !c! derivative of ecl is Gcl
27462 dGCLdR = - 2.0d0 * sparrow / Rhead**3.0d0 &
27463 + 4.0d0 * hawk / Rhead**5.0d0
27465 dGCLdOM1 = (w1 * Qj) / (Rhead**2.0d0)
27467 dGCLdOM2 = (2.0d0 * w2 * Qj * Qj * om2) / (Rhead ** 4.0d0)
27468 !c--------------------------------------------------------------------
27469 !c Polarization energy
27471 MomoFac2 = (1.0d0 - chi2 * sqom1)
27472 RR2 = R2 * R2 / MomoFac2
27473 ee2 = exp(-(RR2 / (4.0d0 * a12sq)))
27474 fgb2 = sqrt(RR2 + a12sq * ee2)
27475 epol = 332.0d0 * eps_inout_fac * ((alphapol2/fgb2) ** 4.0d0 )
27476 dPOLdFGB2 = -(1328.0d0 * eps_inout_fac * alphapol2 ** 4.0d0) &
27478 dFGBdR2 = ( (R2 / MomoFac2) &
27479 * ( 2.0d0 - (0.5d0 * ee2) ) ) &
27481 dFGBdOM1 = (((R2 * R2 * chi2 * om1) / (MomoFac2 * MomoFac2)) &
27482 * (2.0d0 - 0.5d0 * ee2) ) &
27484 dPOLdR2 = dPOLdFGB2 * dFGBdR2
27485 !c! dPOLdR2 = 0.0d0
27486 dPOLdOM1 = dPOLdFGB2 * dFGBdOM1
27487 !c! dPOLdOM1 = 0.0d0
27489 !c!-------------------------------------------------------------------
27491 pom = (pis / Rhead)**6.0d0
27492 Elj = 4.0d0 * eps_head * pom * (pom-1.0d0)
27493 !c! derivative of Elj is Glj
27494 dGLJdR = 4.0d0 * eps_head &
27495 * (((-12.0d0*pis**12.0d0)/(Rhead**13.0d0)) &
27496 + (( 6.0d0*pis**6.0d0) /(Rhead**7.0d0)))
27497 !c!-------------------------------------------------------------------
27498 !c! Return the results
27499 !c! (see comments in Eqq)
27501 erhead(k) = Rhead_distance(k)/Rhead
27502 erhead_tail(k,2) = ((chead(k,2)-ctail(k,1))/R2)
27504 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
27505 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
27506 eagle = scalar( erhead_tail(1,2), dC_norm(1,j+nres) )
27507 adler = scalar( erhead_tail(1,2), dC_norm(1,i+nres) )
27508 facd1 = d1 * vbld_inv(i+nres)
27509 facd2 = d2 * vbld_inv(j+nres)
27510 facd3 = dtail(1,itypi,itypj) * vbld_inv(i+nres)
27512 condor = (erhead_tail(k,2) &
27513 + facd2 * (erhead_tail(k,2) - eagle * dC_norm(k,j+nres)))
27515 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
27516 gvdwx(k,i) = gvdwx(k,i) &
27518 - dPOLdR2 * (erhead_tail(k,2) &
27519 -facd3 * (erhead_tail(k,2) - adler * dC_norm(k,i+nres))) &
27522 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
27523 gvdwx(k,j) = gvdwx(k,j) &
27525 + dPOLdR2 * condor &
27529 gvdwc(k,i) = gvdwc(k,i) &
27530 - dGCLdR * erhead(k) &
27531 - dPOLdR2 * erhead_tail(k,2) &
27532 - dGLJdR * erhead(k)
27534 gvdwc(k,j) = gvdwc(k,j) &
27535 + dGCLdR * erhead(k) &
27536 + dPOLdR2 * erhead_tail(k,2) &
27537 + dGLJdR * erhead(k)
27543 SUBROUTINE edq_cat(Ecl,Elj,Epol)
27547 double precision facd3, adler,ecl,elj,epol
27548 alphapol2 = alphapolcat(itypj,itypi)
27549 w1 = wqdipcat(1,itypi,itypj)
27550 w2 = wqdipcat(2,itypi,itypj)
27551 pis = sig0headcat(itypi,itypj)
27552 eps_head = epsheadcat(itypi,itypj)
27553 !c!-------------------------------------------------------------------
27554 !c! R2 - distance between head of jth side chain and tail of ith sidechain
27557 !c! Calculate head-to-tail distances
27558 R2=R2+(chead(k,2)-ctail(k,1))**2
27563 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
27564 !c! & +dhead(1,1,itypi,itypj))**2))
27565 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
27566 !c! & +dhead(2,1,itypi,itypj))**2))
27569 !c!-------------------------------------------------------------------
27571 ! write(iout,*) "KURWA2",Rhead
27572 sparrow = w1 * Qj * om1
27573 hawk = w2 * Qj * Qj * (1.0d0 - sqom2)
27574 ECL = sparrow / Rhead**2.0d0 &
27575 - hawk / Rhead**4.0d0
27576 !c!-------------------------------------------------------------------
27577 !c! derivative of ecl is Gcl
27579 dGCLdR = - 2.0d0 * sparrow / Rhead**3.0d0 &
27580 + 4.0d0 * hawk / Rhead**5.0d0
27582 dGCLdOM1 = (w1 * Qj) / (Rhead**2.0d0)
27584 dGCLdOM2 = (2.0d0 * w2 * Qj * Qj * om2) / (Rhead ** 4.0d0)
27585 !c--------------------------------------------------------------------
27586 !c--------------------------------------------------------------------
27587 !c Polarization energy
27589 MomoFac2 = (1.0d0 - chi2 * sqom1)
27590 RR2 = R2 * R2 / MomoFac2
27591 ee2 = exp(-(RR2 / (4.0d0 * a12sq)))
27592 fgb2 = sqrt(RR2 + a12sq * ee2)
27593 epol = 332.0d0 * eps_inout_fac * ((alphapol2/fgb2) ** 4.0d0 )
27594 dPOLdFGB2 = -(1328.0d0 * eps_inout_fac * alphapol2 ** 4.0d0) &
27596 dFGBdR2 = ( (R2 / MomoFac2) &
27597 * ( 2.0d0 - (0.5d0 * ee2) ) ) &
27599 dFGBdOM1 = (((R2 * R2 * chi2 * om1) / (MomoFac2 * MomoFac2)) &
27600 * (2.0d0 - 0.5d0 * ee2) ) &
27602 dPOLdR2 = dPOLdFGB2 * dFGBdR2
27603 !c! dPOLdR2 = 0.0d0
27604 dPOLdOM1 = dPOLdFGB2 * dFGBdOM1
27605 !c! dPOLdOM1 = 0.0d0
27607 !c!-------------------------------------------------------------------
27609 pom = (pis / Rhead)**6.0d0
27610 Elj = 4.0d0 * eps_head * pom * (pom-1.0d0)
27611 !c! derivative of Elj is Glj
27612 dGLJdR = 4.0d0 * eps_head &
27613 * (((-12.0d0*pis**12.0d0)/(Rhead**13.0d0)) &
27614 + (( 6.0d0*pis**6.0d0) /(Rhead**7.0d0)))
27615 !c!-------------------------------------------------------------------
27617 !c! Return the results
27618 !c! (see comments in Eqq)
27620 erhead(k) = Rhead_distance(k)/Rhead
27621 erhead_tail(k,2) = ((chead(k,2)-ctail(k,1))/R2)
27623 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
27624 erdxj = scalar( erhead(1), dC_norm(1,j) )
27625 eagle = scalar( erhead_tail(1,2), dC_norm(1,j) )
27626 adler = scalar( erhead_tail(1,2), dC_norm(1,i+nres) )
27627 facd1 = d1 * vbld_inv(i+nres)
27628 facd2 = d2 * vbld_inv(j)
27629 facd3 = dtailcat(1,itypi,itypj) * vbld_inv(i+nres)
27631 condor = (erhead_tail(k,2) &
27632 + facd2 * (erhead_tail(k,2) - eagle * dC_norm(k,j)))
27634 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
27635 gradpepcatx(k,i) = gradpepcatx(k,i) &
27637 - dPOLdR2 * (erhead_tail(k,2) &
27638 -facd3 * (erhead_tail(k,2) - adler * dC_norm(k,i+nres))) &
27641 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j))
27642 ! gradpepcatx(k,j) = gradpepcatx(k,j) &
27644 ! + dPOLdR2 * condor &
27648 gradpepcat(k,i) = gradpepcat(k,i) &
27649 - dGCLdR * erhead(k) &
27650 - dPOLdR2 * erhead_tail(k,2) &
27651 - dGLJdR * erhead(k)
27653 gradpepcat(k,j) = gradpepcat(k,j) &
27654 + dGCLdR * erhead(k) &
27655 + dPOLdR2 * erhead_tail(k,2) &
27656 + dGLJdR * erhead(k)
27660 END SUBROUTINE edq_cat
27662 SUBROUTINE edq_cat_pep(Ecl,Elj,Epol)
27666 double precision facd3, adler,ecl,elj,epol
27667 alphapol2 = alphapolcat(itypj,itypi)
27668 w1 = wqdipcat(1,itypi,itypj)
27669 w2 = wqdipcat(2,itypi,itypj)
27670 pis = sig0headcat(itypi,itypj)
27671 eps_head = epsheadcat(itypi,itypj)
27672 !c!-------------------------------------------------------------------
27673 !c! R2 - distance between head of jth side chain and tail of ith sidechain
27676 !c! Calculate head-to-tail distances
27677 R2=R2+(chead(k,2)-ctail(k,1))**2
27682 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
27683 !c! & +dhead(1,1,itypi,itypj))**2))
27684 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
27685 !c! & +dhead(2,1,itypi,itypj))**2))
27688 !c!-------------------------------------------------------------------
27690 sparrow = w1 * Qj * om1
27691 hawk = w2 * Qj * Qj * (1.0d0 - sqom2)
27692 ! print *,"CO2", itypi,itypj
27693 ! print *,"CO?!.", w1,w2,Qj,om1
27694 ECL = sparrow / Rhead**2.0d0 &
27695 - hawk / Rhead**4.0d0
27696 !c!-------------------------------------------------------------------
27697 !c! derivative of ecl is Gcl
27699 dGCLdR = - 2.0d0 * sparrow / Rhead**3.0d0 &
27700 + 4.0d0 * hawk / Rhead**5.0d0
27702 dGCLdOM1 = (w1 * Qj) / (Rhead**2.0d0)
27704 dGCLdOM2 = (2.0d0 * w2 * Qj * Qj * om2) / (Rhead ** 4.0d0)
27705 !c--------------------------------------------------------------------
27706 !c--------------------------------------------------------------------
27707 !c Polarization energy
27709 MomoFac2 = (1.0d0 - chi2 * sqom1)
27710 RR2 = R2 * R2 / MomoFac2
27711 ee2 = exp(-(RR2 / (4.0d0 * a12sq)))
27712 fgb2 = sqrt(RR2 + a12sq * ee2)
27713 epol = 332.0d0 * eps_inout_fac * ((alphapol2/fgb2) ** 4.0d0 )
27714 dPOLdFGB2 = -(1328.0d0 * eps_inout_fac * alphapol2 ** 4.0d0) &
27716 dFGBdR2 = ( (R2 / MomoFac2) &
27717 * ( 2.0d0 - (0.5d0 * ee2) ) ) &
27719 dFGBdOM1 = (((R2 * R2 * chi2 * om1) / (MomoFac2 * MomoFac2)) &
27720 * (2.0d0 - 0.5d0 * ee2) ) &
27722 dPOLdR2 = dPOLdFGB2 * dFGBdR2
27723 !c! dPOLdR2 = 0.0d0
27724 dPOLdOM1 = dPOLdFGB2 * dFGBdOM1
27725 !c! dPOLdOM1 = 0.0d0
27727 !c!-------------------------------------------------------------------
27729 pom = (pis / Rhead)**6.0d0
27730 Elj = 4.0d0 * eps_head * pom * (pom-1.0d0)
27731 !c! derivative of Elj is Glj
27732 dGLJdR = 4.0d0 * eps_head &
27733 * (((-12.0d0*pis**12.0d0)/(Rhead**13.0d0)) &
27734 + (( 6.0d0*pis**6.0d0) /(Rhead**7.0d0)))
27735 !c!-------------------------------------------------------------------
27737 !c! Return the results
27738 !c! (see comments in Eqq)
27740 erhead(k) = Rhead_distance(k)/Rhead
27741 erhead_tail(k,2) = ((chead(k,2)-ctail(k,1))/R2)
27743 erdxi = scalar( erhead(1), dC_norm(1,i) )
27744 erdxj = scalar( erhead(1), dC_norm(1,j) )
27745 eagle = scalar( erhead_tail(1,2), dC_norm(1,j) )
27746 adler = scalar( erhead_tail(1,2), dC_norm(1,i) )
27747 facd1 = d1 * vbld_inv(i+1)/2.0
27748 facd2 = d2 * vbld_inv(j)
27749 facd3 = dtailcat(1,itypi,itypj) * vbld_inv(i+1)/2.0
27751 condor = (erhead_tail(k,2) &
27752 + facd2 * (erhead_tail(k,2) - eagle * dC_norm(k,j)))
27754 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i))
27755 ! gradpepcatx(k,i) = gradpepcatx(k,i) &
27757 ! - dPOLdR2 * (erhead_tail(k,2) &
27758 ! -facd3 * (erhead_tail(k,2) - adler * dC_norm(k,i+nres))) &
27761 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j))
27762 ! gradpepcatx(k,j) = gradpepcatx(k,j) &
27764 ! + dPOLdR2 * condor &
27768 gradpepcat(k,i) = gradpepcat(k,i) +0.5d0*( &
27769 - dGCLdR * erhead(k) &
27770 - dPOLdR2 * erhead_tail(k,2) &
27771 - dGLJdR * erhead(k))
27772 gradpepcat(k,i+1) = gradpepcat(k,i+1) +0.5d0*( &
27773 - dGCLdR * erhead(k) &
27774 - dPOLdR2 * erhead_tail(k,2) &
27775 - dGLJdR * erhead(k))
27778 gradpepcat(k,j) = gradpepcat(k,j) &
27779 + dGCLdR * erhead(k) &
27780 + dPOLdR2 * erhead_tail(k,2) &
27781 + dGLJdR * erhead(k)
27785 END SUBROUTINE edq_cat_pep
27787 SUBROUTINE edd(ECL)
27792 double precision ecl
27793 !c! csig = sigiso(itypi,itypj)
27794 w1 = wqdip(1,itypi,itypj)
27795 w2 = wqdip(2,itypi,itypj)
27796 !c!-------------------------------------------------------------------
27798 fac = (om12 - 3.0d0 * om1 * om2)
27799 c1 = (w1 / (Rhead**3.0d0)) * fac
27800 c2 = (w2 / Rhead ** 6.0d0) &
27801 * (4.0d0 + fac * fac -3.0d0 * (sqom1 + sqom2))
27803 !c! write (*,*) "w1 = ", w1
27804 !c! write (*,*) "w2 = ", w2
27805 !c! write (*,*) "om1 = ", om1
27806 !c! write (*,*) "om2 = ", om2
27807 !c! write (*,*) "om12 = ", om12
27808 !c! write (*,*) "fac = ", fac
27809 !c! write (*,*) "c1 = ", c1
27810 !c! write (*,*) "c2 = ", c2
27811 !c! write (*,*) "Ecl = ", Ecl
27812 !c! write (*,*) "c2_1 = ", (w2 / Rhead ** 6.0d0)
27813 !c! write (*,*) "c2_2 = ",
27814 !c! & (4.0d0 + fac * fac -3.0d0 * (sqom1 + sqom2))
27815 !c!-------------------------------------------------------------------
27816 !c! dervative of ECL is GCL...
27818 c1 = (-3.0d0 * w1 * fac) / (Rhead ** 4.0d0)
27819 c2 = (-6.0d0 * w2) / (Rhead ** 7.0d0) &
27820 * (4.0d0 + fac * fac - 3.0d0 * (sqom1 + sqom2))
27823 c1 = (-3.0d0 * w1 * om2 ) / (Rhead**3.0d0)
27824 c2 = (-6.0d0 * w2) / (Rhead**6.0d0) &
27825 * ( om2 * om12 - 3.0d0 * om1 * sqom2 + om1 )
27828 c1 = (-3.0d0 * w1 * om1 ) / (Rhead**3.0d0)
27829 c2 = (-6.0d0 * w2) / (Rhead**6.0d0) &
27830 * ( om1 * om12 - 3.0d0 * sqom1 * om2 + om2 )
27833 c1 = w1 / (Rhead ** 3.0d0)
27834 c2 = ( 2.0d0 * w2 * fac ) / Rhead ** 6.0d0
27835 dGCLdOM12 = c1 - c2
27836 !c!-------------------------------------------------------------------
27837 !c! Return the results
27838 !c! (see comments in Eqq)
27840 erhead(k) = Rhead_distance(k)/Rhead
27842 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
27843 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
27844 facd1 = d1 * vbld_inv(i+nres)
27845 facd2 = d2 * vbld_inv(j+nres)
27848 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
27849 gvdwx(k,i) = gvdwx(k,i) - dGCLdR * pom
27850 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
27851 gvdwx(k,j) = gvdwx(k,j) + dGCLdR * pom
27853 gvdwc(k,i) = gvdwc(k,i) - dGCLdR * erhead(k)
27854 gvdwc(k,j) = gvdwc(k,j) + dGCLdR * erhead(k)
27858 SUBROUTINE elgrad_init(eheadtail,Egb,Ecl,Elj,Equad,Epol)
27863 real(kind=8) :: eheadtail,Egb,Ecl,Elj,Equad,Epol,Rb
27867 !c! 1/(Gas Constant * Thermostate temperature) = BetaT
27868 !c! ENABLE THIS LINE WHEN USING CHECKGRAD!!!
27870 !c! BetaT = 1.0d0 / (t_bath * Rb)i
27872 BetaT = 1.0d0 / (298.0d0 * Rb)
27873 !c! Gay-berne var's
27874 sig0ij = sigma( itypi,itypj )
27875 chi1 = chi( itypi, itypj )
27876 chi2 = chi( itypj, itypi )
27877 chi12 = chi1 * chi2
27878 chip1 = chipp( itypi, itypj )
27879 chip2 = chipp( itypj, itypi )
27880 chip12 = chip1 * chip2
27887 !c! not used by momo potential, but needed by sc_angular which is shared
27888 !c! by all energy_potential subroutines
27892 !c! location, location, location
27893 ! xj = c( 1, nres+j ) - xi
27894 ! yj = c( 2, nres+j ) - yi
27895 ! zj = c( 3, nres+j ) - zi
27896 dxj = dc_norm( 1, nres+j )
27897 dyj = dc_norm( 2, nres+j )
27898 dzj = dc_norm( 3, nres+j )
27899 !c! distance from center of chain(?) to polar/charged head
27900 !c! write (*,*) "istate = ", 1
27901 !c! write (*,*) "ii = ", 1
27902 !c! write (*,*) "jj = ", 1
27903 d1 = dhead(1, 1, itypi, itypj)
27904 d2 = dhead(2, 1, itypi, itypj)
27906 a12sq = rborn(itypi,itypj) * rborn(itypj,itypi)
27907 !c! a12sq = a12sq * a12sq
27908 !c! charge of amino acid itypi is...
27909 Qi = icharge(itypi)
27910 Qj = icharge(itypj)
27913 chis1 = chis(itypi,itypj)
27914 chis2 = chis(itypj,itypi)
27915 chis12 = chis1 * chis2
27916 sig1 = sigmap1(itypi,itypj)
27917 sig2 = sigmap2(itypi,itypj)
27918 !c! write (*,*) "sig1 = ", sig1
27919 !c! write (*,*) "sig2 = ", sig2
27920 !c! alpha factors from Fcav/Gcav
27921 b1cav = alphasur(1,itypi,itypj)
27923 b2cav = alphasur(2,itypi,itypj)
27924 b3cav = alphasur(3,itypi,itypj)
27925 b4cav = alphasur(4,itypi,itypj)
27926 wqd = wquad(itypi, itypj)
27928 eps_in = epsintab(itypi,itypj)
27929 eps_inout_fac = ( (1.0d0/eps_in) - (1.0d0/eps_out))
27930 !c! write (*,*) "eps_inout_fac = ", eps_inout_fac
27931 !c!-------------------------------------------------------------------
27932 !c! tail location and distance calculations
27935 ctail(k,1)=c(k,i+nres)-dtail(1,itypi,itypj)*dc_norm(k,nres+i)
27936 ctail(k,2)=c(k,j+nres)-dtail(2,itypi,itypj)*dc_norm(k,nres+j)
27938 !c! tail distances will be themselves usefull elswhere
27939 !c1 (in Gcav, for example)
27940 Rtail_distance(1) = ctail( 1, 2 ) - ctail( 1,1 )
27941 Rtail_distance(2) = ctail( 2, 2 ) - ctail( 2,1 )
27942 Rtail_distance(3) = ctail( 3, 2 ) - ctail( 3,1 )
27944 (Rtail_distance(1)*Rtail_distance(1)) &
27945 + (Rtail_distance(2)*Rtail_distance(2)) &
27946 + (Rtail_distance(3)*Rtail_distance(3)))
27947 !c!-------------------------------------------------------------------
27948 !c! Calculate location and distance between polar heads
27949 !c! distance between heads
27950 !c! for each one of our three dimensional space...
27951 d1 = dhead(1, 1, itypi, itypj)
27952 d2 = dhead(2, 1, itypi, itypj)
27955 !c! location of polar head is computed by taking hydrophobic centre
27956 !c! and moving by a d1 * dc_norm vector
27957 !c! see unres publications for very informative images
27958 chead(k,1) = c(k, i+nres) + d1 * dc_norm(k, i+nres)
27959 chead(k,2) = c(k, j+nres) + d2 * dc_norm(k, j+nres)
27961 !c! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
27962 !c! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
27963 Rhead_distance(k) = chead(k,2) - chead(k,1)
27965 !c! pitagoras (root of sum of squares)
27967 (Rhead_distance(1)*Rhead_distance(1)) &
27968 + (Rhead_distance(2)*Rhead_distance(2)) &
27969 + (Rhead_distance(3)*Rhead_distance(3)))
27970 !c!-------------------------------------------------------------------
27971 !c! zero everything that should be zero'ed
27984 END SUBROUTINE elgrad_init
27987 SUBROUTINE elgrad_init_cat(eheadtail,Egb,Ecl,Elj,Equad,Epol)
27990 real(kind=8) :: eheadtail,Egb,Ecl,Elj,Equad,Epol,Rb
27994 !c! 1/(Gas Constant * Thermostate temperature) = BetaT
27995 !c! ENABLE THIS LINE WHEN USING CHECKGRAD!!!
27997 !c! BetaT = 1.0d0 / (t_bath * Rb)i
27999 BetaT = 1.0d0 / (298.0d0 * Rb)
28000 !c! Gay-berne var's
28001 sig0ij = sigmacat( itypi,itypj )
28002 chi1 = chi1cat( itypi, itypj )
28005 chip1 = chipp1cat( itypi, itypj )
28008 !c! not used by momo potential, but needed by sc_angular which is shared
28009 !c! by all energy_potential subroutines
28013 dxj = dc_norm( 1, nres+j )
28014 dyj = dc_norm( 2, nres+j )
28015 dzj = dc_norm( 3, nres+j )
28016 !c! distance from center of chain(?) to polar/charged head
28017 d1 = dheadcat(1, 1, itypi, itypj)
28018 d2 = dheadcat(2, 1, itypi, itypj)
28020 a12sq = rborn1cat(itypi,itypj) * rborn2cat(itypi,itypj)
28021 !c! a12sq = a12sq * a12sq
28022 !c! charge of amino acid itypi is...
28023 Qi = icharge(itypi)
28024 Qj = ichargecat(itypj)
28027 chis1 = chis1cat(itypi,itypj)
28030 sig1 = sigmap1cat(itypi,itypj)
28031 sig2 = sigmap2cat(itypi,itypj)
28032 !c! alpha factors from Fcav/Gcav
28033 b1cav = alphasurcat(1,itypi,itypj)
28034 b2cav = alphasurcat(2,itypi,itypj)
28035 b3cav = alphasurcat(3,itypi,itypj)
28036 b4cav = alphasurcat(4,itypi,itypj)
28037 wqd = wquadcat(itypi, itypj)
28039 eps_in = epsintabcat(itypi,itypj)
28040 eps_inout_fac = ( (1.0d0/eps_in) - (1.0d0/eps_out))
28041 !c!-------------------------------------------------------------------
28042 !c! tail location and distance calculations
28045 ctail(k,1)=c(k,i+nres)-dtailcat(1,itypi,itypj)*dc_norm(k,nres+i)
28046 ctail(k,2)=c(k,j)!-dtailcat(2,itypi,itypj)*dc_norm(k,nres+j)
28048 !c! tail distances will be themselves usefull elswhere
28049 !c1 (in Gcav, for example)
28050 Rtail_distance(1) = ctail( 1, 2 ) - ctail( 1,1 )
28051 Rtail_distance(2) = ctail( 2, 2 ) - ctail( 2,1 )
28052 Rtail_distance(3) = ctail( 3, 2 ) - ctail( 3,1 )
28054 (Rtail_distance(1)*Rtail_distance(1)) &
28055 + (Rtail_distance(2)*Rtail_distance(2)) &
28056 + (Rtail_distance(3)*Rtail_distance(3)))
28057 !c!-------------------------------------------------------------------
28058 !c! Calculate location and distance between polar heads
28059 !c! distance between heads
28060 !c! for each one of our three dimensional space...
28061 d1 = dheadcat(1, 1, itypi, itypj)
28062 d2 = dheadcat(2, 1, itypi, itypj)
28065 !c! location of polar head is computed by taking hydrophobic centre
28066 !c! and moving by a d1 * dc_norm vector
28067 !c! see unres publications for very informative images
28068 chead(k,1) = c(k, i+nres) + d1 * dc_norm(k, i+nres)
28069 chead(k,2) = c(k, j)
28071 !c! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
28072 !c! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
28073 Rhead_distance(k) = chead(k,2) - chead(k,1)
28075 !c! pitagoras (root of sum of squares)
28077 (Rhead_distance(1)*Rhead_distance(1)) &
28078 + (Rhead_distance(2)*Rhead_distance(2)) &
28079 + (Rhead_distance(3)*Rhead_distance(3)))
28080 !c!-------------------------------------------------------------------
28081 !c! zero everything that should be zero'ed
28094 END SUBROUTINE elgrad_init_cat
28096 SUBROUTINE elgrad_init_cat_pep(eheadtail,Egb,Ecl,Elj,Equad,Epol)
28099 real(kind=8) :: eheadtail,Egb,Ecl,Elj,Equad,Epol,Rb
28103 !c! 1/(Gas Constant * Thermostate temperature) = BetaT
28104 !c! ENABLE THIS LINE WHEN USING CHECKGRAD!!!
28106 !c! BetaT = 1.0d0 / (t_bath * Rb)i
28108 BetaT = 1.0d0 / (298.0d0 * Rb)
28109 !c! Gay-berne var's
28110 sig0ij = sigmacat( itypi,itypj )
28111 chi1 = chi1cat( itypi, itypj )
28114 chip1 = chipp1cat( itypi, itypj )
28117 !c! not used by momo potential, but needed by sc_angular which is shared
28118 !c! by all energy_potential subroutines
28122 dxj = 0.0d0 !dc_norm( 1, nres+j )
28123 dyj = 0.0d0 !dc_norm( 2, nres+j )
28124 dzj = 0.0d0 !dc_norm( 3, nres+j )
28125 !c! distance from center of chain(?) to polar/charged head
28126 d1 = dheadcat(1, 1, itypi, itypj)
28127 d2 = dheadcat(2, 1, itypi, itypj)
28129 a12sq = rborn1cat(itypi,itypj) * rborn2cat(itypi,itypj)
28130 !c! a12sq = a12sq * a12sq
28131 !c! charge of amino acid itypi is...
28133 Qj = ichargecat(itypj)
28136 chis1 = chis1cat(itypi,itypj)
28139 sig1 = sigmap1cat(itypi,itypj)
28140 sig2 = sigmap2cat(itypi,itypj)
28141 !c! alpha factors from Fcav/Gcav
28142 b1cav = alphasurcat(1,itypi,itypj)
28143 b2cav = alphasurcat(2,itypi,itypj)
28144 b3cav = alphasurcat(3,itypi,itypj)
28145 b4cav = alphasurcat(4,itypi,itypj)
28146 wqd = wquadcat(itypi, itypj)
28148 eps_in = epsintabcat(itypi,itypj)
28149 eps_inout_fac = ( (1.0d0/eps_in) - (1.0d0/eps_out))
28150 !c!-------------------------------------------------------------------
28151 !c! tail location and distance calculations
28154 ctail(k,1)=(c(k,i)+c(k,i+1))/2.0-dtailcat(1,itypi,itypj)*dc_norm(k,i)
28155 ctail(k,2)=c(k,j)!-dtailcat(2,itypi,itypj)*dc_norm(k,nres+j)
28157 !c! tail distances will be themselves usefull elswhere
28158 !c1 (in Gcav, for example)
28159 Rtail_distance(1) = ctail( 1, 2 ) - ctail( 1,1 )
28160 Rtail_distance(2) = ctail( 2, 2 ) - ctail( 2,1 )
28161 Rtail_distance(3) = ctail( 3, 2 ) - ctail( 3,1 )
28163 (Rtail_distance(1)*Rtail_distance(1)) &
28164 + (Rtail_distance(2)*Rtail_distance(2)) &
28165 + (Rtail_distance(3)*Rtail_distance(3)))
28166 !c!-------------------------------------------------------------------
28167 !c! Calculate location and distance between polar heads
28168 !c! distance between heads
28169 !c! for each one of our three dimensional space...
28170 d1 = dheadcat(1, 1, itypi, itypj)
28171 d2 = dheadcat(2, 1, itypi, itypj)
28174 !c! location of polar head is computed by taking hydrophobic centre
28175 !c! and moving by a d1 * dc_norm vector
28176 !c! see unres publications for very informative images
28177 chead(k,1) = (c(k, i)+c(k,i+1))/2.0 + d1 * dc_norm(k, i)
28178 chead(k,2) = c(k, j)
28180 !c! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
28181 !c! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
28182 Rhead_distance(k) = chead(k,2) - chead(k,1)
28184 !c! pitagoras (root of sum of squares)
28186 (Rhead_distance(1)*Rhead_distance(1)) &
28187 + (Rhead_distance(2)*Rhead_distance(2)) &
28188 + (Rhead_distance(3)*Rhead_distance(3)))
28189 !c!-------------------------------------------------------------------
28190 !c! zero everything that should be zero'ed
28203 END SUBROUTINE elgrad_init_cat_pep
28205 double precision function tschebyshev(m,n,x,y)
28208 double precision x(n),y,yy(0:maxvar),aux
28209 !c Tschebyshev polynomial. Note that the first term is omitted
28210 !c m=0: the constant term is included
28211 !c m=1: the constant term is not included
28215 yy(i)=2*yy(1)*yy(i-1)-yy(i-2)
28223 end function tschebyshev
28224 !C--------------------------------------------------------------------------
28225 double precision function gradtschebyshev(m,n,x,y)
28228 double precision x(n+1),y,yy(0:maxvar),aux
28229 !c Tschebyshev polynomial. Note that the first term is omitted
28230 !c m=0: the constant term is included
28231 !c m=1: the constant term is not included
28235 yy(i)=2*y*yy(i-1)-yy(i-2)
28239 aux=aux+x(i+1)*yy(i)*(i+1)
28240 !C print *, x(i+1),yy(i),i
28242 gradtschebyshev=aux
28244 end function gradtschebyshev
28246 subroutine make_SCSC_inter_list
28248 real*8 :: xi,yi,zi,xj,yj,zj,xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp
28249 real*8 :: dist_init, dist_temp,r_buff_list
28250 integer:: contlisti(250*nres),contlistj(250*nres)
28251 ! integer :: newcontlisti(200*nres),newcontlistj(200*nres)
28252 integer i,j,itypi,itypj,subchap,xshift,yshift,zshift,iint,ilist_sc,g_ilist_sc
28253 integer displ(0:nprocs),i_ilist_sc(0:nprocs),ierr
28254 ! print *,"START make_SC"
28257 do i=iatsc_s,iatsc_e
28258 itypi=iabs(itype(i,1))
28259 if (itypi.eq.ntyp1) cycle
28263 call to_box(xi,yi,zi)
28264 do iint=1,nint_gr(i)
28265 do j=istart(i,iint),iend(i,iint)
28266 itypj=iabs(itype(j,1))
28267 if (itypj.eq.ntyp1) cycle
28271 call to_box(xj,yj,zj)
28272 ! call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
28273 ! faclipij2=(sslipi+sslipj)/2.0d0*lipscale**2+1.0d0
28274 xj=boxshift(xj-xi,boxxsize)
28275 yj=boxshift(yj-yi,boxysize)
28276 zj=boxshift(zj-zi,boxzsize)
28277 dist_init=xj**2+yj**2+zj**2
28278 ! dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
28279 ! r_buff_list is a read value for a buffer
28280 if (sqrt(dist_init).le.(r_cut_ele+r_buff_list)) then
28281 ! Here the list is created
28282 ilist_sc=ilist_sc+1
28283 ! this can be substituted by cantor and anti-cantor
28284 contlisti(ilist_sc)=i
28285 contlistj(ilist_sc)=j
28291 ! call MPI_Reduce(ilist_sc,g_ilist_sc,1,&
28292 ! MPI_INTEGER,MPI_SUM,king,FG_COMM,IERR)
28293 ! call MPI_Gather(newnss,1,MPI_INTEGER,&
28294 ! i_newnss,1,MPI_INTEGER,king,FG_COMM,IERR)
28296 write (iout,*) "before MPIREDUCE",ilist_sc
28298 write (iout,*) i,contlisti(i),contlistj(i)
28301 if (nfgtasks.gt.1)then
28303 call MPI_Reduce(ilist_sc,g_ilist_sc,1,&
28304 MPI_INTEGER,MPI_SUM,king,FG_COMM,IERR)
28305 ! write(iout,*) "before bcast",g_ilist_sc
28306 call MPI_Gather(ilist_sc,1,MPI_INTEGER,&
28307 i_ilist_sc,1,MPI_INTEGER,king,FG_COMM,IERR)
28309 do i=1,nfgtasks-1,1
28310 displ(i)=i_ilist_sc(i-1)+displ(i-1)
28312 ! write(iout,*) "before gather",displ(0),displ(1)
28313 call MPI_Gatherv(contlisti,ilist_sc,MPI_INTEGER,&
28314 newcontlisti,i_ilist_sc,displ,MPI_INTEGER,&
28316 call MPI_Gatherv(contlistj,ilist_sc,MPI_INTEGER,&
28317 newcontlistj,i_ilist_sc,displ,MPI_INTEGER,&
28319 call MPI_Bcast(g_ilist_sc,1,MPI_INT,king,FG_COMM,IERR)
28320 ! write(iout,*) "before bcast",g_ilist_sc
28321 ! call MPI_Bcast(g_ilist_sc,1,MPI_INT,king,FG_COMM)
28322 call MPI_Bcast(newcontlisti,g_ilist_sc,MPI_INT,king,FG_COMM,IERR)
28323 call MPI_Bcast(newcontlistj,g_ilist_sc,MPI_INT,king,FG_COMM,IERR)
28325 ! call MPI_Bcast(g_ilist_sc,1,MPI_INT,king,FG_COMM)
28328 g_ilist_sc=ilist_sc
28331 newcontlisti(i)=contlisti(i)
28332 newcontlistj(i)=contlistj(i)
28337 write (iout,*) "after MPIREDUCE",g_ilist_sc
28339 write (iout,*) i,newcontlisti(i),newcontlistj(i)
28342 call int_bounds(g_ilist_sc,g_listscsc_start,g_listscsc_end)
28344 end subroutine make_SCSC_inter_list
28345 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
28347 subroutine make_SCp_inter_list
28348 use MD_data, only: itime_mat
28351 real*8 :: xi,yi,zi,xj,yj,zj,xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp
28352 real*8 :: dist_init, dist_temp,r_buff_list
28353 integer:: contlistscpi(250*nres),contlistscpj(250*nres)
28354 ! integer :: newcontlistscpi(200*nres),newcontlistscpj(200*nres)
28355 integer i,j,itypi,itypj,subchap,xshift,yshift,zshift,iint,ilist_scp,g_ilist_scp
28356 integer displ(0:nprocs),i_ilist_scp(0:nprocs),ierr
28357 ! print *,"START make_SC"
28360 do i=iatscp_s,iatscp_e
28361 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
28362 xi=0.5D0*(c(1,i)+c(1,i+1))
28363 yi=0.5D0*(c(2,i)+c(2,i+1))
28364 zi=0.5D0*(c(3,i)+c(3,i+1))
28365 call to_box(xi,yi,zi)
28366 do iint=1,nscp_gr(i)
28368 do j=iscpstart(i,iint),iscpend(i,iint)
28369 itypj=iabs(itype(j,1))
28370 if (itypj.eq.ntyp1) cycle
28371 ! Uncomment following three lines for SC-p interactions
28372 ! xj=c(1,nres+j)-xi
28373 ! yj=c(2,nres+j)-yi
28374 ! zj=c(3,nres+j)-zi
28375 ! Uncomment following three lines for Ca-p interactions
28382 call to_box(xj,yj,zj)
28383 xj=boxshift(xj-xi,boxxsize)
28384 yj=boxshift(yj-yi,boxysize)
28385 zj=boxshift(zj-zi,boxzsize)
28386 dist_init=xj**2+yj**2+zj**2
28388 ! r_buff_list is a read value for a buffer
28389 if ((sqrt(dist_init).le.(r_cut_ele)).and.(ifirstrun.eq.0)) then
28390 ! Here the list is created
28391 ilist_scp_first=ilist_scp_first+1
28392 ! this can be substituted by cantor and anti-cantor
28393 contlistscpi_f(ilist_scp_first)=i
28394 contlistscpj_f(ilist_scp_first)=j
28397 ! r_buff_list is a read value for a buffer
28398 if (sqrt(dist_init).le.(r_cut_ele+r_buff_list)) then
28399 ! Here the list is created
28400 ilist_scp=ilist_scp+1
28401 ! this can be substituted by cantor and anti-cantor
28402 contlistscpi(ilist_scp)=i
28403 contlistscpj(ilist_scp)=j
28409 write (iout,*) "before MPIREDUCE",ilist_scp
28411 write (iout,*) i,contlistscpi(i),contlistscpj(i)
28414 if (nfgtasks.gt.1)then
28416 call MPI_Reduce(ilist_scp,g_ilist_scp,1,&
28417 MPI_INTEGER,MPI_SUM,king,FG_COMM,IERR)
28418 ! write(iout,*) "before bcast",g_ilist_sc
28419 call MPI_Gather(ilist_scp,1,MPI_INTEGER,&
28420 i_ilist_scp,1,MPI_INTEGER,king,FG_COMM,IERR)
28422 do i=1,nfgtasks-1,1
28423 displ(i)=i_ilist_scp(i-1)+displ(i-1)
28425 ! write(iout,*) "before gather",displ(0),displ(1)
28426 call MPI_Gatherv(contlistscpi,ilist_scp,MPI_INTEGER,&
28427 newcontlistscpi,i_ilist_scp,displ,MPI_INTEGER,&
28429 call MPI_Gatherv(contlistscpj,ilist_scp,MPI_INTEGER,&
28430 newcontlistscpj,i_ilist_scp,displ,MPI_INTEGER,&
28432 call MPI_Bcast(g_ilist_scp,1,MPI_INT,king,FG_COMM,IERR)
28433 ! write(iout,*) "before bcast",g_ilist_sc
28434 ! call MPI_Bcast(g_ilist_sc,1,MPI_INT,king,FG_COMM)
28435 call MPI_Bcast(newcontlistscpi,g_ilist_scp,MPI_INT,king,FG_COMM,IERR)
28436 call MPI_Bcast(newcontlistscpj,g_ilist_scp,MPI_INT,king,FG_COMM,IERR)
28438 ! call MPI_Bcast(g_ilist_sc,1,MPI_INT,king,FG_COMM)
28441 g_ilist_scp=ilist_scp
28444 newcontlistscpi(i)=contlistscpi(i)
28445 newcontlistscpj(i)=contlistscpj(i)
28450 write (iout,*) "after MPIREDUCE",g_ilist_scp
28452 write (iout,*) i,newcontlistscpi(i),newcontlistscpj(i)
28455 ! if (ifirstrun.eq.0) ifirstrun=1
28456 ! do i=1,ilist_scp_first
28457 ! do j=1,g_ilist_scp
28458 ! if ((newcontlistscpi(j).eq.contlistscpi_f(i)).and.&
28459 ! (newcontlistscpj(j).eq.contlistscpj_f(i))) go to 126
28461 ! print *,itime_mat,"ERROR matrix needs updating"
28462 ! print *,contlistscpi_f(i),contlistscpj_f(i)
28466 call int_bounds(g_ilist_scp,g_listscp_start,g_listscp_end)
28469 end subroutine make_SCp_inter_list
28471 !-----------------------------------------------------------------------------
28472 !-----------------------------------------------------------------------------
28475 subroutine make_pp_inter_list
28477 real*8 :: xi,yi,zi,xj,yj,zj,xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp
28478 real*8 :: xmedj,ymedj,zmedj,sslipi,ssgradlipi,faclipij2,sslipj,ssgradlipj
28479 real*8 :: dist_init, dist_temp,r_buff_list,dxi,dyi,dzi,xmedi,ymedi,zmedi
28480 real*8 :: dx_normi,dy_normi,dz_normi,dxj,dyj,dzj,dx_normj,dy_normj,dz_normj
28481 integer:: contlistppi(250*nres),contlistppj(250*nres)
28482 ! integer :: newcontlistppi(200*nres),newcontlistppj(200*nres)
28483 integer i,j,itypi,itypj,subchap,xshift,yshift,zshift,iint,ilist_pp,g_ilist_pp
28484 integer displ(0:nprocs),i_ilist_pp(0:nprocs),ierr
28485 ! write(iout,*),"START make_pp",iatel_s,iatel_e,r_cut_ele+r_buff_list
28488 do i=iatel_s,iatel_e
28489 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
28493 dx_normi=dc_norm(1,i)
28494 dy_normi=dc_norm(2,i)
28495 dz_normi=dc_norm(3,i)
28496 xmedi=c(1,i)+0.5d0*dxi
28497 ymedi=c(2,i)+0.5d0*dyi
28498 zmedi=c(3,i)+0.5d0*dzi
28500 call to_box(xmedi,ymedi,zmedi)
28501 call lipid_layer(xmedi,ymedi,zmedi,sslipi,ssgradlipi)
28502 ! write (iout,*) i,j,itype(i,1),itype(j,1)
28503 ! if (itype(j,1).eq.ntyp1.or. itype(j+1,1).eq.ntyp1) cycle
28506 do j=ielstart(i),ielend(i)
28507 ! write (iout,*) i,j,itype(i,1),itype(j,1)
28508 if (itype(j,1).eq.ntyp1.or. itype(j+1,1).eq.ntyp1) cycle
28512 dx_normj=dc_norm(1,j)
28513 dy_normj=dc_norm(2,j)
28514 dz_normj=dc_norm(3,j)
28515 ! xj=c(1,j)+0.5D0*dxj-xmedi
28516 ! yj=c(2,j)+0.5D0*dyj-ymedi
28517 ! zj=c(3,j)+0.5D0*dzj-zmedi
28518 xj=c(1,j)+0.5D0*dxj
28519 yj=c(2,j)+0.5D0*dyj
28520 zj=c(3,j)+0.5D0*dzj
28521 call to_box(xj,yj,zj)
28522 ! call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
28523 ! faclipij2=(sslipi+sslipj)/2.0d0*lipscale**2+1.0d0
28524 xj=boxshift(xj-xmedi,boxxsize)
28525 yj=boxshift(yj-ymedi,boxysize)
28526 zj=boxshift(zj-zmedi,boxzsize)
28527 dist_init=xj**2+yj**2+zj**2
28528 if (sqrt(dist_init).le.(r_cut_ele+r_buff_list)) then
28529 ! Here the list is created
28530 ilist_pp=ilist_pp+1
28531 ! this can be substituted by cantor and anti-cantor
28532 contlistppi(ilist_pp)=i
28533 contlistppj(ilist_pp)=j
28539 write (iout,*) "before MPIREDUCE",ilist_pp
28541 write (iout,*) i,contlistppi(i),contlistppj(i)
28544 if (nfgtasks.gt.1)then
28546 call MPI_Reduce(ilist_pp,g_ilist_pp,1,&
28547 MPI_INTEGER,MPI_SUM,king,FG_COMM,IERR)
28548 ! write(iout,*) "before bcast",g_ilist_sc
28549 call MPI_Gather(ilist_pp,1,MPI_INTEGER,&
28550 i_ilist_pp,1,MPI_INTEGER,king,FG_COMM,IERR)
28552 do i=1,nfgtasks-1,1
28553 displ(i)=i_ilist_pp(i-1)+displ(i-1)
28555 ! write(iout,*) "before gather",displ(0),displ(1)
28556 call MPI_Gatherv(contlistppi,ilist_pp,MPI_INTEGER,&
28557 newcontlistppi,i_ilist_pp,displ,MPI_INTEGER,&
28559 call MPI_Gatherv(contlistppj,ilist_pp,MPI_INTEGER,&
28560 newcontlistppj,i_ilist_pp,displ,MPI_INTEGER,&
28562 call MPI_Bcast(g_ilist_pp,1,MPI_INT,king,FG_COMM,IERR)
28563 ! write(iout,*) "before bcast",g_ilist_sc
28564 ! call MPI_Bcast(g_ilist_sc,1,MPI_INT,king,FG_COMM)
28565 call MPI_Bcast(newcontlistppi,g_ilist_pp,MPI_INT,king,FG_COMM,IERR)
28566 call MPI_Bcast(newcontlistppj,g_ilist_pp,MPI_INT,king,FG_COMM,IERR)
28568 ! call MPI_Bcast(g_ilist_sc,1,MPI_INT,king,FG_COMM)
28571 g_ilist_pp=ilist_pp
28574 newcontlistppi(i)=contlistppi(i)
28575 newcontlistppj(i)=contlistppj(i)
28578 call int_bounds(g_ilist_pp,g_listpp_start,g_listpp_end)
28580 write (iout,*) "after MPIREDUCE",g_ilist_pp
28582 write (iout,*) i,newcontlistppi(i),newcontlistppj(i)
28586 end subroutine make_pp_inter_list
28588 !-----------------------------------------------------------------------------
28589 double precision function boxshift(x,boxsize)
28591 double precision x,boxsize
28592 double precision xtemp
28593 xtemp=dmod(x,boxsize)
28594 if (dabs(xtemp-boxsize).lt.dabs(xtemp)) then
28595 boxshift=xtemp-boxsize
28596 else if (dabs(xtemp+boxsize).lt.dabs(xtemp)) then
28597 boxshift=xtemp+boxsize
28602 end function boxshift
28603 !-----------------------------------------------------------------------------
28604 subroutine to_box(xi,yi,zi)
28606 ! include 'DIMENSIONS'
28607 ! include 'COMMON.CHAIN'
28608 double precision xi,yi,zi
28609 xi=dmod(xi,boxxsize)
28610 if (xi.lt.0.0d0) xi=xi+boxxsize
28611 yi=dmod(yi,boxysize)
28612 if (yi.lt.0.0d0) yi=yi+boxysize
28613 zi=dmod(zi,boxzsize)
28614 if (zi.lt.0.0d0) zi=zi+boxzsize
28616 end subroutine to_box
28617 !--------------------------------------------------------------------------
28618 subroutine lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
28620 ! include 'DIMENSIONS'
28621 ! include 'COMMON.IOUNITS'
28622 ! include 'COMMON.CHAIN'
28623 double precision xi,yi,zi,sslipi,ssgradlipi
28624 double precision fracinbuf
28625 ! double precision sscalelip,sscagradlip
28627 write (iout,*) "bordlipbot",bordlipbot," bordliptop",bordliptop
28628 write (iout,*) "buflipbot",buflipbot," lipbufthick",lipbufthick
28629 write (iout,*) "xi yi zi",xi,yi,zi
28631 if ((zi.gt.bordlipbot).and.(zi.lt.bordliptop)) then
28632 ! the energy transfer exist
28633 if (zi.lt.buflipbot) then
28634 ! what fraction I am in
28635 fracinbuf=1.0d0-((zi-bordlipbot)/lipbufthick)
28636 ! lipbufthick is thickenes of lipid buffore
28637 sslipi=sscalelip(fracinbuf)
28638 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
28639 elseif (zi.gt.bufliptop) then
28640 fracinbuf=1.0d0-((bordliptop-zi)/lipbufthick)
28641 sslipi=sscalelip(fracinbuf)
28642 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
28652 write (iout,*) "sslipi",sslipi," ssgradlipi",ssgradlipi
28655 end subroutine lipid_layer
28657 !--------------------------------------------------------------------------
28658 !--------------------------------------------------------------------------