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,gradcattranx,&
141 gradcattranc,gradcatangc,gradcatangx
142 ! real(kind=8),dimension(:,:),allocatable :: gloc,gloc_x !(maxvar,2)
143 !----------------------------------------
144 real(kind=8),dimension(:,:),allocatable ::gradlipelec,gradlipbond,&
147 real(kind=8),dimension(:,:),allocatable :: gel_loc,gel_loc_long,&
148 gcorr3_turn,gcorr4_turn,gcorr6_turn,gradb,gradbx !(3,maxres)
149 real(kind=8),dimension(:),allocatable :: gel_loc_loc,&
150 gel_loc_turn3,gel_loc_turn4,gel_loc_turn6,gcorr_loc,g_corr5_loc,&
151 g_corr6_loc !(maxvar)
152 real(kind=8),dimension(:,:),allocatable :: gsccorc,gsccorx !(3,maxres)
153 real(kind=8),dimension(:),allocatable :: gsccor_loc !(maxres)
154 ! real(kind=8),dimension(:,:,:),allocatable :: dtheta !(3,2,maxres)
155 real(kind=8),dimension(:,:),allocatable :: gscloc,gsclocx !(3,maxres)
156 ! real(kind=8),dimension(:,:,:),allocatable :: dphi,dalpha,domega !(3,3,maxres)
157 real(kind=8),dimension(:,:,:),allocatable :: grad_shield_side, &
158 grad_shield_loc ! (3,maxcontsshileding,maxnres)
161 real(kind=8), dimension(:),allocatable :: fac_shield
162 real(kind=8),dimension(3,5,2) :: derx,derx_turn
163 ! common /deriv_scloc/
164 real(kind=8),dimension(:,:),allocatable :: dXX_C1tab,dYY_C1tab,&
165 dZZ_C1tab,dXX_Ctab,dYY_Ctab,dZZ_Ctab,dXX_XYZtab,dYY_XYZtab,&
166 dZZ_XYZtab !(3,maxres)
167 !-----------------------------------------------------------------------------
170 real(kind=8) :: gvdwc_max,gvdwc_scp_max,gelc_max,gvdwpp_max,&
171 gradb_max,ghpbc_max,&
172 gradcorr_max,gel_loc_max,gcorr3_turn_max,gcorr4_turn_max,&
173 gradcorr5_max,gradcorr6_max,gcorr6_turn_max,gsccorc_max,&
174 gscloc_max,gvdwx_max,gradx_scp_max,ghpbx_max,gradxorr_max,&
175 gsccorx_max,gsclocx_max
176 !-----------------------------------------------------------------------------
178 ! common /back_constr/
179 real(kind=8),dimension(:),allocatable :: dutheta,dugamma !(maxres)
180 real(kind=8),dimension(:,:),allocatable :: duscdiff,duscdiffx !(3,maxres)
182 real(kind=8) :: Ucdfrag,Ucdpair
183 real(kind=8),dimension(:,:),allocatable :: dUdconst,dUdxconst,&
184 dqwol,dxqwol !(3,0:MAXRES)
185 !-----------------------------------------------------------------------------
187 ! common /dyn_ssbond/
188 real(kind=8),dimension(:),allocatable :: dyn_ssbond_ij !(maxres,maxres)
189 !-----------------------------------------------------------------------------
191 ! Parameters of the SCCOR term
193 real(kind=8),dimension(:,:,:,:),allocatable :: dcostau,dsintau,&
194 dcosomicron,domicron !(3,3,3,maxres2)
195 !-----------------------------------------------------------------------------
198 real(kind=8),dimension(:,:),allocatable :: uy,uz !(3,maxres)
199 real(kind=8),dimension(:,:,:,:),allocatable :: uygrad,uzgrad !(3,3,2,maxres)
200 !-----------------------------------------------------------------------------
201 ! common /przechowalnia/
202 real(kind=8),dimension(:,:,:),allocatable :: zapas
203 real(kind=8),dimension(:,:,:,:),allocatable ::zapas2 !(max_dim,maxconts,max_fg_procs)
205 real(kind=8),dimension(:,:),allocatable :: fromto !(3,3,maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
207 real(kind=8),dimension(:,:,:),allocatable :: fromto !(3,3,maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
209 !-----------------------------------------------------------------------------
210 !-----------------------------------------------------------------------------
213 !-----------------------------------------------------------------------------
215 !-----------------------------------------------------------------------------
216 ! energy_p_new_barrier.F
217 !-----------------------------------------------------------------------------
218 subroutine etotal(energia)
219 ! implicit real(kind=8) (a-h,o-z)
220 ! include 'DIMENSIONS'
225 !MS$ATTRIBUTES C :: proc_proc
231 ! include 'COMMON.SETUP'
232 ! include 'COMMON.IOUNITS'
233 real(kind=8),dimension(0:n_ene) :: energia
234 ! include 'COMMON.LOCAL'
235 ! include 'COMMON.FFIELD'
236 ! include 'COMMON.DERIV'
237 ! include 'COMMON.INTERACT'
238 ! include 'COMMON.SBRIDGE'
239 ! include 'COMMON.CHAIN'
240 ! include 'COMMON.VAR'
241 ! include 'COMMON.MD'
242 ! include 'COMMON.CONTROL'
243 ! include 'COMMON.TIME1'
244 real(kind=8) :: time00
246 integer :: n_corr,n_corr1,ierror,imatupdate
247 real(kind=8) :: etors,edihcnstr,etors_d,esccor,ehpb
248 real(kind=8) :: evdw,evdw1,evdw2,evdw2_14,escloc,ees,eel_loc
249 real(kind=8) :: eello_turn3,eello_turn4,estr,ebe,eliptran,etube, &
250 Eafmforce,ethetacnstr
251 real(kind=8) :: ecorr,ecorr5,ecorr6,eturn6,ehomology_constr
252 ! now energies for nulceic alone parameters
253 real(kind=8) :: evdwpp,eespp,evdwpsb,eelpsb,evdwsb,eelsb,estr_nucl,&
254 ebe_nucl,esbloc,etors_nucl,etors_d_nucl,ecorr_nucl,&
257 real(kind=8) :: ecation_prot,ecationcation,ecations_prot_amber,&
258 ecation_nucl,ecat_prottran,ecation_protang
259 ! energies for protein nucleic acid interaction
260 real(kind=8) :: escbase,epepbase,escpho,epeppho
261 ! energies for MARTINI
262 real(kind=8) :: elipbond,elipang,elipelec,eliplj
265 real(kind=8) :: weights_(n_ene) !,time_Bcast,time_Bcastw
266 ! shielding effect varibles for MPI
267 real(kind=8) :: fac_shieldbuf(nres_molec(1)), &
268 grad_shield_locbuf1(3*maxcontsshi*nres_molec(1)), &
269 grad_shield_sidebuf1(3*maxcontsshi*nres_molec(1)), &
270 grad_shield_locbuf2(3*maxcontsshi*nres_molec(1)), &
271 grad_shield_sidebuf2(3*maxcontsshi*nres_molec(1)), &
272 grad_shieldbuf1(3*nres_molec(1)), &
273 grad_shieldbuf2(3*nres_molec(1))
275 integer ishield_listbuf(-1:nres_molec(1)), &
276 shield_listbuf(maxcontsshi,-1:nres_molec(1)),k,j,i,iii,impishi,mojint,jjj
277 integer :: imatupdate2
278 ! print *,"I START ENERGY"
281 ! if (mod(itime_mat,imatupdate).eq.0) call make_SCSC_inter_list
282 ! real(kind=8), dimension(:),allocatable:: fac_shieldbuf
283 ! real(kind=8), dimension(:,:,:),allocatable:: &
284 ! grad_shield_locbuf,grad_shield_sidebuf
285 ! real(kind=8), dimension(:,:),allocatable:: &
287 ! integer, dimension(:),allocatable:: &
289 ! integer, dimension(:,:),allocatable:: shield_listbuf
291 ! if (.not.allocated(fac_shieldbuf)) then
292 ! allocate(fac_shieldbuf(nres))
293 ! allocate(grad_shield_locbuf(3,maxcontsshi,-1:nres))
294 ! allocate(grad_shield_sidebuf(3,maxcontsshi,-1:nres))
295 ! allocate(grad_shieldbuf(3,-1:nres))
296 ! allocate(ishield_listbuf(nres))
297 ! allocate(shield_listbuf(maxcontsshi,nres))
299 ! print *,"wstrain check", wstrain
300 ! print*,"ETOTAL Processor",fg_rank," absolute rank",myrank,
301 ! & " nfgtasks",nfgtasks
302 if (nfgtasks.gt.1) then
304 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
305 if (fg_rank.eq.0) then
306 call MPI_Bcast(0,1,MPI_INTEGER,king,FG_COMM,IERROR)
307 ! print *,"Processor",myrank," BROADCAST iorder"
308 ! FG master sets up the WEIGHTS_ array which will be broadcast to the
309 ! FG slaves as WEIGHTS array.
329 weights_(26)=wvdwpp_nucl
335 weights_(32)=wbond_nucl
336 weights_(33)=wang_nucl
338 weights_(35)=wtor_nucl
339 weights_(36)=wtor_d_nucl
340 weights_(37)=wcorr_nucl
341 weights_(38)=wcorr3_nucl
343 weights_(42)=wcatprot
345 weights_(47)=wpepbase
348 weights_(50)=wcatnucl
349 weights_(56)=wcat_tran
351 ! wcatcat= weights(41)
352 ! wcatprot=weights(42)
354 ! FG Master broadcasts the WEIGHTS_ array
355 call MPI_Bcast(weights_(1),n_ene,&
356 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
358 ! FG slaves receive the WEIGHTS array
359 call MPI_Bcast(weights(1),n_ene,&
360 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
380 wvdwpp_nucl =weights(26)
386 wbond_nucl =weights(32)
387 wang_nucl =weights(33)
389 wtor_nucl =weights(35)
390 wtor_d_nucl =weights(36)
391 wcorr_nucl =weights(37)
392 wcorr3_nucl =weights(38)
400 wcat_tran=weights(56)
402 ! welpsb=weights(28)*fact(1)
404 ! wcorr_nucl= weights(37)*fact(1)
405 ! wcorr3_nucl=weights(38)*fact(2)
406 ! wtor_nucl= weights(35)*fact(1)
407 ! wtor_d_nucl=weights(36)*fact(2)
410 time_Bcast=time_Bcast+MPI_Wtime()-time00
411 time_Bcastw=time_Bcastw+MPI_Wtime()-time00
412 ! call chainbuild_cart
414 ! print *,"itime_mat",itime_mat,imatupdate
415 if (nfgtasks.gt.1) then
416 call MPI_Bcast(itime_mat,1,MPI_INT,king,FG_COMM,IERROR)
418 if (nres_molec(1).gt.0) then
419 if (mod(itime_mat,imatupdate).eq.0) call make_SCp_inter_list
420 ! write (iout,*) "after make_SCp_inter_list"
421 if (mod(itime_mat,imatupdate).eq.0) call make_SCSC_inter_list
422 ! write (iout,*) "after make_SCSC_inter_list"
424 if (mod(itime_mat,imatupdate).eq.0) call make_pp_inter_list
425 if (nres_molec(5).gt.0) then
426 if (mod(itime_mat,imatupdate).eq.0) then
427 ! print *,'Processor',myrank,' calling etotal ipot=',ipot
428 call make_cat_pep_list
429 ! call make_cat_cat_list
433 if (nres_molec(5).gt.0) then
434 if (mod(itime_mat,imatupdate2).eq.0) then
435 ! print *, "before cat cat"
436 ! print *,'Processor',myrank,' calling etotal ipot=',ipot
437 ! call make_cat_pep_list
438 call make_cat_cat_list
441 ! write (iout,*) "after make_pp_inter_list"
443 ! print *,'Processor',myrank,' calling etotal ipot=',ipot
444 ! print *,'Processor',myrank,' nnt=',nnt,' nct=',nct
446 ! if (modecalc.eq.12.or.modecalc.eq.14) then
447 ! call int_from_cart1(.false.)
454 ! Compute the side-chain and electrostatic interaction energy
455 ! print *, "Before EVDW"
456 ! goto (101,102,103,104,105,106) ipot
457 if (nres_molec(1).gt.0) then
459 ! Lennard-Jones potential.
463 !d print '(a)','Exit ELJcall el'
465 ! Lennard-Jones-Kihara potential (shifted).
466 ! 102 call eljk(evdw)
470 ! Berne-Pechukas potential (dilated LJ, angular dependence).
475 ! Gay-Berne potential (shifted LJ, angular dependence).
478 ! print *,"MOMO",scelemode
479 if (scelemode.eq.0) then
485 ! Gay-Berne-Vorobjev potential (shifted LJ, angular dependence).
486 ! 105 call egbv(evdw)
490 ! Soft-sphere potential
491 ! 106 call e_softsphere(evdw)
493 call e_softsphere(evdw)
495 ! Calculate electrostatic (H-bonding) energy of the main chain.
499 write(iout,*)"Wrong ipot"
504 ! print *,"after EGB"
506 if (shield_mode.eq.2) then
509 if (nfgtasks.gt.1) then
510 grad_shield_sidebuf1(:)=0.0d0
511 grad_shield_locbuf1(:)=0.0d0
512 grad_shield_sidebuf2(:)=0.0d0
513 grad_shield_locbuf2(:)=0.0d0
514 grad_shieldbuf1(:)=0.0d0
515 grad_shieldbuf2(:)=0.0d0
518 write(iout,*) "befor reduce fac_shield reduce"
520 write(2,*) "fac",itype(i,1),fac_shield(i),grad_shield(1,i)
521 write(2,*) "list", shield_list(1,i),ishield_list(i), &
522 grad_shield_side(1,1,i),grad_shield_loc(1,1,i)
531 grad_shieldbuf1(iii)=grad_shield(k,i)
538 grad_shield_sidebuf1(jjj)=grad_shield_side(k,j,i)
539 grad_shield_locbuf1(jjj)=grad_shield_loc(k,j,i)
543 call MPI_Allgatherv(fac_shield(ivec_start), &
544 ivec_count(fg_rank1), &
545 MPI_DOUBLE_PRECISION,fac_shieldbuf(1),ivec_count(0), &
547 MPI_DOUBLE_PRECISION,FG_COMM,IERROR)
548 call MPI_Allgatherv(shield_list(1,ivec_start), &
549 ivec_count(fg_rank1), &
550 MPI_I50,shield_listbuf(1,1),ivec_count(0), &
552 MPI_I50,FG_COMM,IERROR)
553 ! write(2,*) "After I50"
555 call MPI_Allgatherv(ishield_list(ivec_start), &
556 ivec_count(fg_rank1), &
557 MPI_INTEGER,ishield_listbuf(1),ivec_count(0), &
559 MPI_INTEGER,FG_COMM,IERROR)
560 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
562 ! write(2,*) ivec_count(fg_rank1)*3,ivec_count(0)*3,ivec_displ(0)*3,3*ivec_start-2
563 ! write (2,*) "before"
564 ! write(2,*) grad_shieldbuf1
565 ! call MPI_Allgatherv(grad_shieldbuf1(3*ivec_start-2), &
566 ! ivec_count(fg_rank1)*3, &
567 ! MPI_DOUBLE_PRECISION,grad_shieldbuf2(1),ivec_count(0), &
569 ! MPI_DOUBLE_PRECISION,FG_COMM,IERROR)
570 call MPI_Allreduce(grad_shieldbuf1(1),grad_shieldbuf2(1), &
572 MPI_DOUBLE_PRECISION, &
575 call MPI_Allreduce(grad_shield_sidebuf1(1),grad_shield_sidebuf2(1), &
576 nres*3*maxcontsshi, &
577 MPI_DOUBLE_PRECISION, &
581 call MPI_Allreduce(grad_shield_locbuf1(1),grad_shield_locbuf2(1), &
582 nres*3*maxcontsshi, &
583 MPI_DOUBLE_PRECISION, &
588 ! write(2,*) grad_shieldbuf2
590 ! call MPI_Allgatherv(grad_shield_sidebuf1(3*maxcontsshi*ivec_start-2), &
591 ! ivec_count(fg_rank1)*3*maxcontsshi, &
592 ! MPI_DOUBLE_PRECISION,grad_shield_sidebuf2(1),ivec_count(0)*3*maxcontsshi,&
593 ! ivec_displ(0)*3*maxcontsshi, &
594 ! MPI_DOUBLE_PRECISION,FG_COMM,IERROR)
595 ! write(2,*) "After grad_shield_side"
597 ! call MPI_Allgatherv(grad_shield_locbuf1(3*maxcontsshi*ivec_start-2), &
598 ! ivec_count(fg_rank1)*3*maxcontsshi, &
599 ! MPI_DOUBLE_PRECISION,grad_shield_locbuf2(1),ivec_count(0)*3*maxcontsshi, &
600 ! ivec_displ(0)*3*maxcontsshi, &
601 ! MPI_DOUBLE_PRECISION,FG_COMM,IERROR)
602 ! write(2,*) "After MPI_SHI"
607 fac_shield(i)=fac_shieldbuf(i)
608 ishield_list(i)=ishield_listbuf(i)
609 ! write(iout,*) i,fac_shield(i)
612 grad_shield(j,i)=grad_shieldbuf2(iii)
614 do j=1,ishield_list(i)
615 ! write (iout,*) "ishild", ishield_list(i),i
616 shield_list(j,i)=shield_listbuf(j,i)
621 grad_shield_loc(k,j,i)=grad_shield_locbuf2(jjj)
622 grad_shield_side(k,j,i)=grad_shield_sidebuf2(jjj)
628 write(iout,*) "after reduce fac_shield reduce"
630 write(2,*) "fac",itype(i,1),fac_shield(i),grad_shield(1,i)
631 write(2,*) "list", shield_list(1,i),ishield_list(i), &
632 grad_shield_side(1,1,i),grad_shield_loc(1,1,i)
640 ! print *,"AFTER EGB",ipot,evdw
642 !mc Sep-06: egb takes care of dynamic ss bonds too
644 ! if (dyn_ss) call dyn_set_nss
645 ! print *,"Processor",myrank," computed USCSC"
651 time_vec=time_vec+MPI_Wtime()-time01
657 ! print *,"Processor",myrank," left VEC_AND_DERIV"
660 ! print *,"after ipot if", ipot
661 if (welec.gt.0d0.or.wvdwpp.gt.0d0.or.wel_loc.gt.0d0.or. &
662 wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0 &
663 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
664 .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
666 if (welec.gt.0d0.or.wel_loc.gt.0d0.or. &
667 wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0 &
668 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
669 .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
671 ! print *,"just befor eelec call"
672 call eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
673 ! print *, "ELEC calc"
682 ! write (iout,*) "Soft-spheer ELEC potential"
683 call eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,&
686 ! print *,"Processor",myrank," computed UELEC"
688 ! Calculate excluded-volume interaction energy between peptide groups
691 ! write(iout,*) "in etotal calc exc;luded",ipot
695 call escp(evdw2,evdw2_14)
701 ! write (iout,*) "Soft-sphere SCP potential"
702 call escp_soft_sphere(evdw2,evdw2_14)
704 ! write(iout,*) "in etotal before ebond",ipot
705 ! print *,"after escp"
707 ! Calculate the bond-stretching energy
710 ! print *,"EBOND",estr
711 ! write(iout,*) "in etotal afer ebond",ipot
714 ! Calculate the disulfide-bridge and other energy and the contributions
715 ! from other distance constraints.
716 ! print *,'Calling EHPB'
718 !elwrite(iout,*) "in etotal afer edis",ipot
719 ! print *,'EHPB exitted succesfully.'
721 ! Calculate the virtual-bond-angle energy.
722 ! write(iout,*) "in etotal afer edis",ipot
724 ! if (wang.gt.0.0d0) then
725 ! call ebend(ebe,ethetacnstr)
730 if (wang.gt.0d0) then
731 if (tor_mode.eq.0) then
734 !C ebend kcc is Kubo cumulant clustered rigorous attemp to derive the
742 ! write(iout,*) with_theta_constr,"with_theta_constr"
743 if (with_theta_constr) call etheta_constr(ethetacnstr)
745 ! write(iout,*) "in etotal afer ebe",ipot
747 ! print *,"Processor",myrank," computed UB"
749 ! Calculate the SC local energy.
752 ! print *, "in etotal afer esc",wtor
753 ! print *,"Processor",myrank," computed USC"
755 ! Calculate the virtual-bond torsional energy.
757 !d print *,'nterm=',nterm
758 ! if (wtor.gt.0) then
759 ! call etor(etors,edihcnstr)
764 if (wtor.gt.0.0d0) then
765 ! print *,"WTOR",wtor,tor_mode
766 if (tor_mode.eq.0) then
769 !C etor kcc is Kubo cumulant clustered rigorous attemp to derive the
777 if (ndih_constr.gt.0) call etor_constr(edihcnstr)
778 !c print *,"Processor",myrank," computed Utor"
780 ! print *, "constr_homol",constr_homology
781 ! print *,"Processor",myrank," computed Utor"
782 if (constr_homology.ge.1) then
783 call e_modeller(ehomology_constr)
784 ! print *,'iset=',iset,'me=',me,ehomology_constr,
785 ! & 'Processor',fg_rank,' CG group',kolor,
786 ! & ' absolute rank',MyRank
789 ehomology_constr=0.0d0
793 ! 6/23/01 Calculate double-torsional energy
795 ! print *, "before etor_d",wtor_d
796 if (wtor_d.gt.0) then
801 ! print *,"Processor",myrank," computed Utord"
803 ! 21/5/07 Calculate local sicdechain correlation energy
805 if (wsccor.gt.0.0d0) then
806 call eback_sc_corr(esccor)
811 ! write(iout,*) "before multibody"
813 ! print *,"Processor",myrank," computed Usccorr"
815 ! 12/1/95 Multi-body terms
820 if ((wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 &
821 .or. wturn6.gt.0.0d0) .and. ipot.lt.6) then
822 call multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
823 !d write(2,*)'multibody_eello n_corr=',n_corr,' n_corr1=',n_corr1,
824 !d &" ecorr",ecorr," ecorr5",ecorr5," ecorr6",ecorr6," eturn6",eturn6
831 !elwrite(iout,*) "in etotal",ipot
832 if ((wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) .and. ipot.lt.6) then
833 call multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
834 !d write (iout,*) "multibody_hb ecorr",ecorr
836 ! write(iout,*) "afeter multibody hb"
838 ! print *,"Processor",myrank," computed Ucorr"
840 ! If performing constraint dynamics, call the constraint energy
841 ! after the equilibration time
842 if((usampl).and.(totT.gt.eq_time)) then
843 write(iout,*) "usampl",usampl
845 !elwrite(iout,*) "afeter multibody hb"
847 !elwrite(iout,*) "afeter multibody hb"
853 ! write(iout,*) "after Econstr"
855 if (wliptran.gt.0) then
856 ! print *,"PRZED WYWOLANIEM"
857 call Eliptransfer(eliptran)
893 ehomology_constr=0.0d0
896 ! write(iout,*) "TU JEST PRZED EHPB"
898 if (fg_rank.eq.0) then
899 if (AFMlog.gt.0) then
900 call AFMforce(Eafmforce)
901 else if (selfguide.gt.0) then
902 call AFMvel(Eafmforce)
907 ! print *,"before tubemode",tubemode
908 if (tubemode.eq.1) then
910 else if (tubemode.eq.2) then
911 call calctube2(etube)
912 elseif (tubemode.eq.3) then
917 ! print *, "TU JEST PRZED EHPB"
920 !--------------------------------------------------------
921 ! print *, "NRES_MOLEC(2),",nres_molec(2)
922 ! print *,"before",ees,evdw1,ecorr
923 ! write(iout,*) ecorr_nucl,"ecorr_nucl",nres_molec(2)
924 if (nres_molec(2).gt.0) then
925 call ebond_nucl(estr_nucl)
926 call ebend_nucl(ebe_nucl)
927 call etor_nucl(etors_nucl)
928 call esb_gb(evdwsb,eelsb)
929 call epp_nucl_sub(evdwpp,eespp)
930 call epsb(evdwpsb,eelpsb)
932 call multibody_hb_nucl(ecorr_nucl,ecorr3_nucl,n_corr,n_corr1)
933 call ecat_nucl(ecation_nucl)
950 ! write(iout,*) ecorr_nucl,"ecorr_nucl",nres_molec(2)
951 ! print *,"before ecatcat",wcatcat
952 if (nres_molec(5).gt.0) then
953 if (g_ilist_catsctran.gt.0) then
954 call ecat_prot_transition(ecat_prottran)
958 if (g_ilist_catscang.gt.0) then
959 call ecat_prot_ang(ecation_protang)
961 ecation_protang=0.0d0
963 ! if (nfgtasks.gt.1) then
964 ! if (fg_rank.eq.0) then
965 if (nres_molec(5).gt.1) call ecatcat(ecationcation)
968 ! if (nres_molec(5).gt.1) call ecatcat(ecationcation)
970 if (oldion.gt.0) then
971 if (g_ilist_catpnorm.gt.0) call ecat_prot(ecation_prot)
973 if (g_ilist_catpnorm.gt.0) call ecats_prot_amber(ecation_prot)
978 ecation_protang=0.0d0
981 if (g_ilist_catscnorm.eq.0) ecation_prot=0.0d0
982 if ((nres_molec(2).gt.0).and.(nres_molec(1).gt.0)) then
983 call eprot_sc_base(escbase)
984 call epep_sc_base(epepbase)
985 call eprot_sc_phosphate(escpho)
986 call eprot_pep_phosphate(epeppho)
993 ! MARTINI FORCE FIELD ENERGY TERMS
994 if (nres_molec(4).gt.0) then
995 if (nfgtasks.gt.1) then
996 if (fg_rank.eq.0) then
997 call lipid_bond(elipbond)
998 call lipid_angle(elipang)
1001 call lipid_bond(elipbond)
1002 call lipid_angle(elipang)
1004 call lipid_LJ(eliplj)
1005 call lipid_elec(elipelec)
1012 ! call ecatcat(ecationcation)
1013 ! print *,"after ebend", wtor_nucl
1015 time_enecalc=time_enecalc+MPI_Wtime()-time00
1017 ! print *,"Processor",myrank," computed Uconstr"
1026 energia(2)=evdw2-evdw2_14
1027 energia(18)=evdw2_14
1036 energia(3)=ees+evdw1
1043 energia(8)=eello_turn3
1044 energia(9)=eello_turn4
1051 energia(19)=edihcnstr
1053 energia(20)=Uconst+Uconst_back
1055 energia(22)=eliptran
1056 energia(23)=Eafmforce
1057 energia(24)=ethetacnstr
1059 !---------------------------------------------------------------
1066 energia(32)=estr_nucl
1067 energia(33)=ebe_nucl
1069 energia(35)=etors_nucl
1070 energia(36)=etors_d_nucl
1071 energia(37)=ecorr_nucl
1072 energia(38)=ecorr3_nucl
1073 !----------------------------------------------------------------------
1074 ! Here are the energies showed per procesor if the are more processors
1075 ! per molecule then we sum it up in sum_energy subroutine
1076 ! print *," Processor",myrank," calls SUM_ENERGY"
1077 energia(42)=ecation_prot
1078 energia(41)=ecationcation
1080 energia(47)=epepbase
1083 ! energia(50)=ecations_prot_amber
1084 energia(50)=ecation_nucl
1085 energia(51)=ehomology_constr
1086 ! energia(51)=homology
1087 energia(52)=elipbond
1090 energia(55)=elipelec
1091 energia(56)=ecat_prottran
1092 energia(57)=ecation_protang
1093 ! write(iout,*) elipelec,"elipelec"
1094 ! write(iout,*) elipang,"elipang"
1095 ! write(iout,*) eliplj,"eliplj"
1096 call sum_energy(energia,.true.)
1097 if (dyn_ss) call dyn_set_nss
1098 ! print *," Processor",myrank," left SUM_ENERGY"
1100 time_sumene=time_sumene+MPI_Wtime()-time00
1102 ! call enerprint(energia)
1103 !elwrite(iout,*)"finish etotal"
1105 end subroutine etotal
1106 !-----------------------------------------------------------------------------
1107 subroutine sum_energy(energia,reduce)
1108 ! implicit real(kind=8) (a-h,o-z)
1109 ! include 'DIMENSIONS'
1113 !MS$ATTRIBUTES C :: proc_proc
1119 ! include 'COMMON.SETUP'
1120 ! include 'COMMON.IOUNITS'
1121 real(kind=8) :: energia(0:n_ene),enebuff(0:n_ene+1)
1122 ! include 'COMMON.FFIELD'
1123 ! include 'COMMON.DERIV'
1124 ! include 'COMMON.INTERACT'
1125 ! include 'COMMON.SBRIDGE'
1126 ! include 'COMMON.CHAIN'
1127 ! include 'COMMON.VAR'
1128 ! include 'COMMON.CONTROL'
1129 ! include 'COMMON.TIME1'
1131 real(kind=8) :: evdw,evdw2,evdw2_14,ees,evdw1,ecorr,ecorr5,ecorr6
1132 real(kind=8) :: eel_loc,eello_turn3,eello_turn4,eturn6,ebe,escloc
1133 real(kind=8) :: etors,etors_d,ehpb,edihcnstr,estr,esccor,etot, &
1134 eliptran,etube, Eafmforce,ethetacnstr
1135 real(kind=8) :: evdwpp,eespp,evdwpsb,eelpsb,evdwsb,eelsb,estr_nucl,&
1136 ebe_nucl,esbloc,etors_nucl,etors_d_nucl,ecorr_nucl,&
1137 ecorr3_nucl,ehomology_constr
1138 real(kind=8) :: ecation_prot,ecationcation,ecations_prot_amber,&
1139 ecation_nucl,ecat_prottran,ecation_protang
1140 real(kind=8) :: escbase,epepbase,escpho,epeppho
1142 real(kind=8) :: elipbond,elipang,eliplj,elipelec
1145 real(kind=8) :: time00
1146 if (nfgtasks.gt.1 .and. reduce) then
1149 write (iout,*) "energies before REDUCE"
1150 call enerprint(energia)
1154 enebuff(i)=energia(i)
1157 call MPI_Barrier(FG_COMM,IERR)
1158 time_barrier_e=time_barrier_e+MPI_Wtime()-time00
1160 call MPI_Reduce(enebuff(0),energia(0),n_ene+1,&
1161 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
1163 write (iout,*) "energies after REDUCE"
1164 call enerprint(energia)
1167 time_Reduce=time_Reduce+MPI_Wtime()-time00
1169 if (fg_rank.eq.0) then
1173 evdw2=energia(2)+energia(18)
1174 evdw2_14=energia(18)
1189 eello_turn3=energia(8)
1190 eello_turn4=energia(9)
1197 edihcnstr=energia(19)
1201 eliptran=energia(22)
1202 Eafmforce=energia(23)
1203 ethetacnstr=energia(24)
1211 estr_nucl=energia(32)
1212 ebe_nucl=energia(33)
1214 etors_nucl=energia(35)
1215 etors_d_nucl=energia(36)
1216 ecorr_nucl=energia(37)
1217 ecorr3_nucl=energia(38)
1218 ecation_prot=energia(42)
1219 ecationcation=energia(41)
1221 epepbase=energia(47)
1224 ecation_nucl=energia(50)
1225 ehomology_constr=energia(51)
1226 elipbond=energia(52)
1229 elipelec=energia(55)
1230 ecat_prottran=energia(56)
1231 ecation_protang=energia(57)
1232 ! ecations_prot_amber=energia(50)
1234 ! energia(41)=ecation_prot
1235 ! energia(42)=ecationcation
1239 etot=wsc*evdw+wscp*evdw2+welec*ees+wvdwpp*evdw1 &
1240 +wang*ebe+wtor*etors+wscloc*escloc &
1241 +wstrain*ehpb+wcorr*ecorr+wcorr5*ecorr5 &
1242 +wcorr6*ecorr6+wturn4*eello_turn4+wturn3*eello_turn3 &
1243 +wturn6*eturn6+wel_loc*eel_loc+edihcnstr+wtor_d*etors_d &
1244 +wbond*estr+Uconst+wsccor*esccor+wliptran*eliptran+wtube*etube&
1245 +Eafmforce+ethetacnstr &
1246 +wbond_nucl*estr_nucl+wang_nucl*ebe_nucl&
1247 +wvdwpp_nucl*evdwpp+welpp*eespp+wvdwpsb*evdwpsb+welpsb*eelpsb&
1248 +wvdwsb*evdwsb+welsb*eelsb+wsbloc*esbloc+wtor_nucl*etors_nucl&
1249 +wtor_d_nucl*etors_d_nucl+wcorr_nucl*ecorr_nucl+wcorr3_nucl*ecorr3_nucl&
1250 +wcatprot*ecation_prot+wcatcat*ecationcation+wscbase*escbase&
1251 +wpepbase*epepbase+wscpho*escpho+wpeppho*epeppho+wcatnucl*ecation_nucl&
1252 +elipbond+elipang+eliplj+elipelec+wcat_tran*ecat_prottran+ecation_protang&
1259 etot=wsc*evdw+wscp*evdw2+welec*(ees+evdw1) &
1260 +wang*ebe+wtor*etors+wscloc*escloc &
1261 +wstrain*ehpb+wcorr*ecorr+wcorr5*ecorr5 &
1262 +wcorr6*ecorr6+wturn4*eello_turn4+wturn3*eello_turn3 &
1263 +wturn6*eturn6+wel_loc*eel_loc+edihcnstr+wtor_d*etors_d &
1264 +wbond*estr+Uconst+wsccor*esccor+wliptran*eliptran+wtube*etube&
1265 +Eafmforce+ethetacnstr &
1266 +wbond_nucl*estr_nucl+wang_nucl*ebe_nucl&
1267 +wvdwpp_nucl*evdwpp+welpp*eespp+wvdwpsb*evdwpsb+welpsb*eelpsb&
1268 +wvdwsb*evdwsb+welsb*eelsb+wsbloc*esbloc+wtor_nucl*etors_nucl&
1269 +wtor_d_nucl*etors_d_nucl+wcorr_nucl*ecorr_nucl+wcorr3_nucl*ecorr3_nucl&
1270 +wcatprot*ecation_prot+wcatcat*ecationcation+wscbase*escbase&
1271 +wpepbase*epepbase+wscpho*escpho+wpeppho*epeppho+wcatnucl*ecation_nucl&
1272 +elipbond+elipang+eliplj+elipelec+wcat_tran*ecat_prottran+ecation_protang&
1283 if (isnan(etot).ne.0) energia(0)=1.0d+99
1285 if (isnan(etot)) energia(0)=1.0d+99
1290 idumm=proc_proc(etot,i)
1292 call proc_proc(etot,i)
1294 if(i.eq.1)energia(0)=1.0d+99
1299 ! call enerprint(energia)
1302 end subroutine sum_energy
1303 !-----------------------------------------------------------------------------
1304 subroutine rescale_weights(t_bath)
1305 ! implicit real(kind=8) (a-h,o-z)
1309 ! include 'DIMENSIONS'
1310 ! include 'COMMON.IOUNITS'
1311 ! include 'COMMON.FFIELD'
1312 ! include 'COMMON.SBRIDGE'
1313 real(kind=8) :: kfac=2.4d0
1314 real(kind=8) :: x,x2,x3,x4,x5,licznik=1.12692801104297249644
1316 real(kind=8) :: t_bath,facT(6) !,facT2,facT3,facT4,facT5,facT6
1317 real(kind=8) :: T0=3.0d2
1320 ! facT=2*temp0/(t_bath+temp0)
1321 if (rescale_mode.eq.0) then
1328 else if (rescale_mode.eq.1) then
1329 facT(1)=kfac/(kfac-1.0d0+t_bath/temp0)
1330 facT(2)=kfac**2/(kfac**2-1.0d0+(t_bath/temp0)**2)
1331 facT(3)=kfac**3/(kfac**3-1.0d0+(t_bath/temp0)**3)
1332 facT(4)=kfac**4/(kfac**4-1.0d0+(t_bath/temp0)**4)
1333 facT(5)=kfac**5/(kfac**5-1.0d0+(t_bath/temp0)**5)
1335 !#if defined(WHAM_RUN) || defined(CLUSTER)
1337 ! tt = 1.0d0/(beta_h(ib,ipar)*1.987D-3)
1338 facT(6)=(320.0+80.0*dtanh((t_bath-320.0)/80.0))/320.0
1339 #elif defined(FUNCT)
1345 else if (rescale_mode.eq.2) then
1351 facT(1)=licznik/dlog(dexp(x)+dexp(-x))
1352 facT(2)=licznik/dlog(dexp(x2)+dexp(-x2))
1353 facT(3)=licznik/dlog(dexp(x3)+dexp(-x3))
1354 facT(4)=licznik/dlog(dexp(x4)+dexp(-x4))
1355 facT(5)=licznik/dlog(dexp(x5)+dexp(-x5))
1357 !#if defined(WHAM_RUN) || defined(CLUSTER)
1359 facT(6)=(320.0+80.0*dtanh((t_bath-320.0)/80.0))/320.0
1360 #elif defined(FUNCT)
1367 write (iout,*) "Wrong RESCALE_MODE",rescale_mode
1368 write (*,*) "Wrong RESCALE_MODE",rescale_mode
1370 call MPI_Finalize(MPI_COMM_WORLD,IERROR)
1374 welec=weights(3)*fact(1)
1375 wcorr=weights(4)*fact(3)
1376 wcorr5=weights(5)*fact(4)
1377 wcorr6=weights(6)*fact(5)
1378 wel_loc=weights(7)*fact(2)
1379 wturn3=weights(8)*fact(2)
1380 wturn4=weights(9)*fact(3)
1381 wturn6=weights(10)*fact(5)
1382 wtor=weights(13)*fact(1)
1383 wtor_d=weights(14)*fact(2)
1384 wsccor=weights(21)*fact(1)
1385 welpsb=weights(28)*fact(1)
1386 wcorr_nucl= weights(37)*fact(1)
1387 wcorr3_nucl=weights(38)*fact(2)
1388 wtor_nucl= weights(35)*fact(1)
1389 wtor_d_nucl=weights(36)*fact(2)
1390 wpepbase=weights(47)*fact(1)
1392 end subroutine rescale_weights
1393 !-----------------------------------------------------------------------------
1394 subroutine enerprint(energia)
1395 ! implicit real(kind=8) (a-h,o-z)
1396 ! include 'DIMENSIONS'
1397 ! include 'COMMON.IOUNITS'
1398 ! include 'COMMON.FFIELD'
1399 ! include 'COMMON.SBRIDGE'
1400 ! include 'COMMON.MD'
1401 real(kind=8) :: energia(0:n_ene)
1403 real(kind=8) :: etot,evdw,evdw2,ees,evdw1,ecorr,ecorr5,ecorr6,eel_loc
1404 real(kind=8) :: eello_turn6,eello_turn3,eello_turn4,ebe,escloc
1405 real(kind=8) :: etors,etors_d,ehpb,edihcnstr,estr,Uconst,esccor,eliptran,&
1406 etube,ethetacnstr,Eafmforce
1407 real(kind=8) :: evdwpp,eespp,evdwpsb,eelpsb,evdwsb,eelsb,estr_nucl,&
1408 ebe_nucl,esbloc,etors_nucl,etors_d_nucl,ecorr_nucl,&
1409 ecorr3_nucl,ehomology_constr
1410 real(kind=8) :: ecation_prot,ecationcation,ecations_prot_amber,&
1411 ecation_nucl,ecat_prottran,ecation_protang
1412 real(kind=8) :: escbase,epepbase,escpho,epeppho
1413 real(kind=8) :: elipbond,elipang,eliplj,elipelec
1418 evdw2=energia(2)+energia(18)
1430 eello_turn3=energia(8)
1431 eello_turn4=energia(9)
1432 eello_turn6=energia(10)
1438 edihcnstr=energia(19)
1442 eliptran=energia(22)
1443 Eafmforce=energia(23)
1444 ethetacnstr=energia(24)
1452 estr_nucl=energia(32)
1453 ebe_nucl=energia(33)
1455 etors_nucl=energia(35)
1456 etors_d_nucl=energia(36)
1457 ecorr_nucl=energia(37)
1458 ecorr3_nucl=energia(38)
1459 ecation_prot=energia(42)
1460 ecationcation=energia(41)
1462 epepbase=energia(47)
1465 ecation_nucl=energia(50)
1466 elipbond=energia(52)
1469 elipelec=energia(55)
1470 ecat_prottran=energia(56)
1471 ecation_protang=energia(57)
1472 ehomology_constr=energia(51)
1474 ! ecations_prot_amber=energia(50)
1476 write (iout,10) evdw,wsc,evdw2,wscp,ees,welec,evdw1,wvdwpp,&
1477 estr,wbond,ebe,wang,&
1478 escloc,wscloc,etors,wtor,etors_d,wtor_d,ehpb,wstrain,&
1480 ecorr5,wcorr5,ecorr6,wcorr6,eel_loc,wel_loc,eello_turn3,wturn3,&
1481 eello_turn4,wturn4,eello_turn6,wturn6,esccor,wsccor,&
1482 edihcnstr,ethetacnstr,ebr*nss,&
1483 Uconst,eliptran,wliptran,Eafmforce,etube,wtube, & ! till now protein
1484 estr_nucl,wbond_nucl,ebe_nucl,wang_nucl, &
1485 evdwpp,wvdwpp_nucl,eespp,welpp,evdwpsb,wvdwpsb,eelpsb,welpsb,&
1486 evdwsb,wvdwsb,eelsb,welsb,esbloc,wsbloc,etors_nucl,wtor_nucl,&
1487 etors_d_nucl,wtor_d_nucl,ecorr_nucl,wcorr_nucl,&
1488 ecorr3_nucl,wcorr3_nucl,ecation_prot,wcatprot,&
1489 ecat_prottran,wcat_tran,ecation_protang,wcat_ang,&
1490 ecationcation,wcatcat, &
1491 escbase,wscbase,epepbase,wpepbase,escpho,wscpho,epeppho,wpeppho,&
1492 ecation_nucl,wcatnucl,ehomology_constr,&
1493 elipbond,elipang,eliplj,elipelec,etot
1494 10 format (/'Virtual-chain energies:'// &
1495 'EVDW= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-SC)'/ &
1496 'EVDW2= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-p)'/ &
1497 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p)'/ &
1498 'EVDWPP=',1pE16.6,' WEIGHT=',1pD16.6,' (p-p VDW)'/ &
1499 'ESTR= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching)'/ &
1500 'EBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (bending)'/ &
1501 'ESC= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/ &
1502 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/ &
1503 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/ &
1504 'EHBP= ',1pE16.6,' WEIGHT=',1pD16.6, &
1505 ' (SS bridges & dist. cnstr.)'/ &
1506 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
1507 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
1508 'ECORR6=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
1509 'EELLO= ',1pE16.6,' WEIGHT=',1pD16.6,' (electrostatic-local)'/ &
1510 'ETURN3=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 3rd order)'/ &
1511 'ETURN4=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 4th order)'/ &
1512 'ETURN6=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 6th order)'/ &
1513 'ESCCOR=',1pE16.6,' WEIGHT=',1pD16.6,' (backbone-rotamer corr)'/ &
1514 'EDIHC= ',1pE16.6,' (dihedral angle constraints)'/ &
1515 'ETHETC= ',1pE16.6,' (valence angle constraints)'/ &
1516 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/ &
1517 'UCONST= ',1pE16.6,' (Constraint energy)'/ &
1518 'ELT=',1pE16.6, ' WEIGHT=',1pD16.6,' (Lipid transfer energy)'/&
1519 'EAFM= ',1pE16.6,' (atomic-force microscopy)'/ &
1520 'ETUBE=',1pE16.6, ' WEIGHT=',1pD16.6,' (cylindrical energy)'/ &
1521 'ESTR_nucl=',1pE16.6,' WEIGHT=',1pD16.6,' (stretching for nucleic)'/ &
1522 'EBE_nucl=',1pE16.6,' WEIGHT=',1pD16.6,' (bending for nucleic)'/ &
1523 'EVDW_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-phosphate VDW)'/ &
1524 'EESPP_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-phosphate elec)'/ &
1525 'EVDWPSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-sugarbase VDW)'/ &
1526 'EESPSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-sugarbase elec)'/ &
1527 'EVDWSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(sugarbase-sugarbase VDW)'/ &
1528 'EESSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(sugarbase-sugarbase elec)'/ &
1529 'ESBLOC_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(sugarbase rotamer)'/ &
1530 'ETORS_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(torsional)'/ &
1531 'ETORSD_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(double torsional)'/ &
1532 'ECORR_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(multibody 4th order)'/ &
1533 'ECORR3_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(multibody 3th order)'/ &
1534 'ECATPROT=',1pE16.6,' WEIGHT=',1pD16.6,'(cation prot)'/ &
1535 'ECATPTRAN=',1pE16.6,' WEIGHT=',1pD16.6,'(cation prot tran)'/ &
1536 'ECATPANG=',1pE16.6,' WEIGHT=',1pD16.6,'(cation prot angle)'/ &
1537 'ECATCAT=',1pE16.6,' WEIGHT=',1pD16.6,'(cation cation)'/ &
1538 'ESCBASE=',1pE16.6,' WEIGHT=',1pD16.6,'(sc-prot nucl-base)'/ &
1539 'EPEPBASE=',1pE16.6,' WEIGHT=',1pD16.6,'(pep-prot nucl-base)'/ &
1540 'ESCPHO=',1pE16.6,' WEIGHT=',1pD16.6,'(sc-prot nucl-phosphate)'/&
1541 'EPEPPHO=',1pE16.6,' WEIGHT=',1pD16.6,'(pep-prot nucl-phosphate)'/&
1542 'ECATBASE=',1pE16.6,' WEIGHT=',1pD16.6,'(cation nucl-base)'/&
1543 'H_CONS=',1pE16.6,' (Homology model constraints energy)'/&
1544 'ELIPBOND=',1pE16.6,'(matrini bond energy)'/&
1545 'ELIPANG=',1pE16.6,'(matrini angle energy)'/&
1546 'ELIPLJ=',1pE16.6,'(matrini Lennard-Jones energy)'/&
1547 'ELIPELEC=',1pE16.6,'(matrini electrostatic energy)'/&
1548 'ETOT= ',1pE16.6,' (total)')
1550 write (iout,10) evdw,wsc,evdw2,wscp,ees,welec,&
1551 estr,wbond,ebe,wang,&
1552 escloc,wscloc,etors,wtor,etors_d,wtor_d,ehpb,wstrain,&
1554 ecorr5,wcorr5,ecorr6,wcorr6,eel_loc,wel_loc,eello_turn3,wturn3,&
1555 eello_turn4,wturn4,eello_turn6,wturn6,esccor,wsccor,edihcnstr,&
1556 ethetacnstr,ebr*nss,Uconst,eliptran,wliptran,Eafmforce, &
1557 etube,wtube, ehomology_constr,&
1558 estr_nucl,wbond_nucl, ebe_nucl,wang_nucl,&
1559 evdwpp,wvdwpp_nucl,eespp,welpp,evdwpsb,wvdwpsb,eelpsb,welpsb,&
1560 evdwsb,wvdwsb,eelsb,welsb,esbloc,wsbloc,etors_nucl,wtor_nucl,&
1561 etors_d_nucl,wtor_d_nucl,ecorr_nucl,wcorr_nucl,&
1562 ecorr3_nucl,wcorr3_nucl,ecation_prot,wcatprot,ecationcation,wcatcat, &
1563 escbase,wscbase,epepbase,wpepbase,escpho,wscpho,epeppho,wpeppho,&
1564 ecation_nucl,wcatnucl,ehomology_constr,etot
1565 10 format (/'Virtual-chain energies:'// &
1566 'EVDW= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-SC)'/ &
1567 'EVDW2= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC-p)'/ &
1568 'EES= ',1pE16.6,' WEIGHT=',1pD16.6,' (p-p)'/ &
1569 'ESTR= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching)'/ &
1570 'EBE= ',1pE16.6,' WEIGHT=',1pD16.6,' (bending)'/ &
1571 'ESC= ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/ &
1572 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/ &
1573 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/ &
1574 'EHBP= ',1pE16.6,' WEIGHT=',1pD16.6, &
1575 ' (SS bridges & dist. cnstr.)'/ &
1576 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
1577 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
1578 'ECORR6=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/ &
1579 'EELLO= ',1pE16.6,' WEIGHT=',1pD16.6,' (electrostatic-local)'/ &
1580 'ETURN3=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 3rd order)'/ &
1581 'ETURN4=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 4th order)'/ &
1582 'ETURN6=',1pE16.6,' WEIGHT=',1pD16.6,' (turns, 6th order)'/ &
1583 'ESCCOR=',1pE16.6,' WEIGHT=',1pD16.6,' (backbone-rotamer corr)'/ &
1584 'EDIHC= ',1pE16.6,' (dihedral angle constraints)'/ &
1585 'ETHETC= ',1pE16.6,' (valence angle constraints)'/ &
1586 'ESS= ',1pE16.6,' (disulfide-bridge intrinsic energy)'/ &
1587 'UCONST=',1pE16.6,' (Constraint energy)'/ &
1588 'ELT=',1pE16.6, ' WEIGHT=',1pD16.6,' (Lipid transfer energy)'/ &
1589 'EAFM= ',1pE16.6,' (atomic-force microscopy)'/ &
1590 'ETUBE=',1pE16.6, ' WEIGHT=',1pD16.6,' (cylindrical energy)'/ &
1591 'ESTR_nucl= ',1pE16.6,' WEIGHT=',1pD16.6,' (stretching for nucleic)'/ &
1592 'EBE_nucl=',1pE16.6,' WEIGHT=',1pD16.6,' (bending for nucleic)'/ &
1593 'EVDW_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-phosphate VDW)'/ &
1594 'EESPP_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-phosphate elec)'/ &
1595 'EVDWPSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-sugarbase VDW)'/ &
1596 'EESPSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(phosphate-sugarbase elec)'/ &
1597 'EVDWSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(sugarbase-sugarbase VDW)'/ &
1598 'EESSB_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(sugarbase-sugarbase elec)'/ &
1599 'ESBLOC_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(sugarbase rotamer)'/ &
1600 'ETORS_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(torsional)'/ &
1601 'ETORSD_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(double torsional)'/ &
1602 'ECORR_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(multibody 4th order)'/ &
1603 'ECORR3_nucl=',1pE16.6,' WEIGHT=',1pD16.6,'(multibody 3th order)'/ &
1604 'ECATPROT=',1pE16.6,' WEIGHT=',1pD16.6,'(cation prot)'/ &
1605 'ECATCAT=',1pE16.6,' WEIGHT=',1pD16.6,'(cation cation)'/ &
1606 'ESCBASE=',1pE16.6,' WEIGHT=',1pD16.6,'(sc-prot nucl-base)'/ &
1607 'EPEPBASE=',1pE16.6,' WEIGHT=',1pD16.6,'(pep-prot nucl-base)'/ &
1608 'ESCPHO=',1pE16.6,' WEIGHT=',1pD16.6,'(sc-prot nucl-phosphate)'/&
1609 'EPEPPHO=',1pE16.6,' WEIGHT=',1pD16.6,'(pep-prot nucl-phosphate)'/&
1610 'ECATBASE=',1pE16.6,' WEIGHT=',1pD16.6,'(cation nucl-base)'/&
1611 'H_CONS=',1pE16.6,' (Homology model constraints energy)'/&
1612 'ELIPBOND=',1pE16.6,'(matrini bond energy)'/&
1613 'ELIPANG=',1pE16.6,'(matrini angle energy)'/&
1614 'ELIPLJ=',1pE16.6,'(matrini Lennard-Jones energy)'/&
1615 'ELIPELEC=',1pE16.6,'(matrini electrostatic energy)'/&
1616 'ETOT= ',1pE16.6,' (total)')
1619 end subroutine enerprint
1620 !-----------------------------------------------------------------------------
1621 subroutine elj(evdw)
1623 ! This subroutine calculates the interaction energy of nonbonded side chains
1624 ! assuming the LJ potential of interaction.
1626 ! implicit real(kind=8) (a-h,o-z)
1627 ! include 'DIMENSIONS'
1628 real(kind=8),parameter :: accur=1.0d-10
1629 ! include 'COMMON.GEO'
1630 ! include 'COMMON.VAR'
1631 ! include 'COMMON.LOCAL'
1632 ! include 'COMMON.CHAIN'
1633 ! include 'COMMON.DERIV'
1634 ! include 'COMMON.INTERACT'
1635 ! include 'COMMON.TORSION'
1636 ! include 'COMMON.SBRIDGE'
1637 ! include 'COMMON.NAMES'
1638 ! include 'COMMON.IOUNITS'
1639 ! include 'COMMON.CONTACTS'
1640 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
1641 integer :: num_conti
1643 integer :: i,itypi,iint,j,itypi1,itypj,k
1644 real(kind=8) :: rij,rcut,fcont,fprimcont,rrij,sslipi,ssgradlipi,&
1645 aa,bb,sslipj,ssgradlipj
1646 real(kind=8) :: evdw,xi,yi,zi,xj,yj,zj
1647 real(kind=8) :: eps0ij,fac,e1,e2,evdwij,sigij,r0ij
1649 ! write(iout,*)'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
1651 ! allocate(num_cont(iatsc_s:iatsc_e)) !(maxres) nnt,nct-2
1652 ! allocate(jcont(nres/4,iatsc_s:iatsc_e)) !(maxconts,maxres) (maxconts=maxres/4)
1653 ! allocate(facont(nres/4,iatsc_s:iatsc_e)) !(maxconts,maxres)
1654 ! allocate(gacont(3,nres/4,iatsc_s:iatsc_e)) !(3,maxconts,maxres)
1656 do i=iatsc_s,iatsc_e
1657 itypi=iabs(itype(i,1))
1658 if (itypi.eq.ntyp1) cycle
1659 itypi1=iabs(itype(i+1,1))
1663 call to_box(xi,yi,zi)
1664 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
1669 ! Calculate SC interaction energy.
1671 do iint=1,nint_gr(i)
1672 !d write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
1673 !d & 'iend=',iend(i,iint)
1674 do j=istart(i,iint),iend(i,iint)
1675 itypj=iabs(itype(j,1))
1676 if (itypj.eq.ntyp1) cycle
1680 call to_box(xj,yj,zj)
1681 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
1682 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
1683 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
1684 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
1685 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
1686 xj=boxshift(xj-xi,boxxsize)
1687 yj=boxshift(yj-yi,boxysize)
1688 zj=boxshift(zj-zi,boxzsize)
1689 ! Change 12/1/95 to calculate four-body interactions
1690 rij=xj*xj+yj*yj+zj*zj
1692 ! write (iout,*)'i=',i,' j=',j,' itypi=',itypi,' itypj=',itypj
1693 eps0ij=eps(itypi,itypj)
1695 e1=fac*fac*aa_aq(itypi,itypj)
1696 e2=fac*bb_aq(itypi,itypj)
1698 !d sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1699 !d epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1700 !d write (iout,'(2(a3,i3,2x),6(1pd12.4)/2(3(1pd12.4),5x)/)')
1701 !d & restyp(itypi,1),i,restyp(itypj,1),j,aa(itypi,itypj),
1702 !d & bb(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,epsi,sigm,
1703 !d & (c(k,i),k=1,3),(c(k,j),k=1,3)
1706 ! Calculate the components of the gradient in DC and X
1708 fac=-rrij*(e1+evdwij)
1713 gvdwx(k,i)=gvdwx(k,i)-gg(k)
1714 gvdwx(k,j)=gvdwx(k,j)+gg(k)
1715 gvdwc(k,i)=gvdwc(k,i)-gg(k)
1716 gvdwc(k,j)=gvdwc(k,j)+gg(k)
1720 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
1724 ! 12/1/95, revised on 5/20/97
1726 ! Calculate the contact function. The ith column of the array JCONT will
1727 ! contain the numbers of atoms that make contacts with the atom I (of numbers
1728 ! greater than I). The arrays FACONT and GACONT will contain the values of
1729 ! the contact function and its derivative.
1731 ! Uncomment next line, if the correlation interactions include EVDW explicitly.
1732 ! if (j.gt.i+1 .and. evdwij.le.0.0D0) then
1733 ! Uncomment next line, if the correlation interactions are contact function only
1734 if (j.gt.i+1.and. eps0ij.gt.0.0D0) then
1736 sigij=sigma(itypi,itypj)
1737 r0ij=rs0(itypi,itypj)
1739 ! Check whether the SC's are not too far to make a contact.
1742 call gcont(rij,rcut,1.0d0,0.2d0*rcut,fcont,fprimcont)
1743 ! Add a new contact, if the SC's are close enough, but not too close (r<sigma).
1745 if (fcont.gt.0.0D0) then
1746 ! If the SC-SC distance if close to sigma, apply spline.
1747 !Adam call gcont(-rij,-1.03d0*sigij,2.0d0*sigij,1.0d0,
1748 !Adam & fcont1,fprimcont1)
1749 !Adam fcont1=1.0d0-fcont1
1750 !Adam if (fcont1.gt.0.0d0) then
1751 !Adam fprimcont=fprimcont*fcont1+fcont*fprimcont1
1752 !Adam fcont=fcont*fcont1
1754 ! Uncomment following 4 lines to have the geometric average of the epsilon0's
1755 !ga eps0ij=1.0d0/dsqrt(eps0ij)
1757 !ga gg(k)=gg(k)*eps0ij
1759 !ga eps0ij=-evdwij*eps0ij
1760 ! Uncomment for AL's type of SC correlation interactions.
1761 !adam eps0ij=-evdwij
1762 num_conti=num_conti+1
1763 jcont(num_conti,i)=j
1764 facont(num_conti,i)=fcont*eps0ij
1765 fprimcont=eps0ij*fprimcont/rij
1767 !Adam gacont(1,num_conti,i)=-fprimcont*xj+fcont*gg(1)
1768 !Adam gacont(2,num_conti,i)=-fprimcont*yj+fcont*gg(2)
1769 !Adam gacont(3,num_conti,i)=-fprimcont*zj+fcont*gg(3)
1770 ! Uncomment following 3 lines for Skolnick's type of SC correlation.
1771 gacont(1,num_conti,i)=-fprimcont*xj
1772 gacont(2,num_conti,i)=-fprimcont*yj
1773 gacont(3,num_conti,i)=-fprimcont*zj
1774 !d write (iout,'(2i5,2f10.5)') i,j,rij,facont(num_conti,i)
1775 !d write (iout,'(2i3,3f10.5)')
1776 !d & i,j,(gacont(kk,num_conti,i),kk=1,3)
1782 num_cont(i)=num_conti
1786 gvdwc(j,i)=expon*gvdwc(j,i)
1787 gvdwx(j,i)=expon*gvdwx(j,i)
1790 !******************************************************************************
1794 ! To save time, the factor of EXPON has been extracted from ALL components
1795 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
1798 !******************************************************************************
1801 !-----------------------------------------------------------------------------
1802 subroutine eljk(evdw)
1804 ! This subroutine calculates the interaction energy of nonbonded side chains
1805 ! assuming the LJK potential of interaction.
1807 ! implicit real(kind=8) (a-h,o-z)
1808 ! include 'DIMENSIONS'
1809 ! include 'COMMON.GEO'
1810 ! include 'COMMON.VAR'
1811 ! include 'COMMON.LOCAL'
1812 ! include 'COMMON.CHAIN'
1813 ! include 'COMMON.DERIV'
1814 ! include 'COMMON.INTERACT'
1815 ! include 'COMMON.IOUNITS'
1816 ! include 'COMMON.NAMES'
1817 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
1820 integer :: i,iint,j,itypi,itypi1,k,itypj
1821 real(kind=8) :: rrij,xi,yi,zi,xj,yj,zj,fac_augm,e_augm,r_inv_ij, &
1822 sslipi,ssgradlipi, sslipj,ssgradlipj, aa, bb
1823 real(kind=8) :: evdw,rij,r_shift_inv,fac,e1,e2,evdwij
1825 ! print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
1827 do i=iatsc_s,iatsc_e
1828 itypi=iabs(itype(i,1))
1829 if (itypi.eq.ntyp1) cycle
1830 itypi1=iabs(itype(i+1,1))
1834 call to_box(xi,yi,zi)
1835 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
1838 ! Calculate SC interaction energy.
1840 do iint=1,nint_gr(i)
1841 do j=istart(i,iint),iend(i,iint)
1842 itypj=iabs(itype(j,1))
1843 if (itypj.eq.ntyp1) cycle
1847 call to_box(xj,yj,zj)
1848 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
1849 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
1850 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
1851 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
1852 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
1853 xj=boxshift(xj-xi,boxxsize)
1854 yj=boxshift(yj-yi,boxysize)
1855 zj=boxshift(zj-zi,boxzsize)
1856 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
1857 fac_augm=rrij**expon
1858 e_augm=augm(itypi,itypj)*fac_augm
1859 r_inv_ij=dsqrt(rrij)
1861 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
1862 fac=r_shift_inv**expon
1863 e1=fac*fac*aa_aq(itypi,itypj)
1864 e2=fac*bb_aq(itypi,itypj)
1866 !d sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
1867 !d epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
1868 !d write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
1869 !d & restyp(itypi,1),i,restyp(itypj,1),j,aa(itypi,itypj),
1870 !d & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
1871 !d & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
1872 !d & (c(k,i),k=1,3),(c(k,j),k=1,3)
1875 ! Calculate the components of the gradient in DC and X
1877 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
1882 gvdwx(k,i)=gvdwx(k,i)-gg(k)
1883 gvdwx(k,j)=gvdwx(k,j)+gg(k)
1884 gvdwc(k,i)=gvdwc(k,i)-gg(k)
1885 gvdwc(k,j)=gvdwc(k,j)+gg(k)
1889 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
1897 gvdwc(j,i)=expon*gvdwc(j,i)
1898 gvdwx(j,i)=expon*gvdwx(j,i)
1903 !-----------------------------------------------------------------------------
1904 subroutine ebp(evdw)
1906 ! This subroutine calculates the interaction energy of nonbonded side chains
1907 ! assuming the Berne-Pechukas potential of interaction.
1911 ! implicit real(kind=8) (a-h,o-z)
1912 ! include 'DIMENSIONS'
1913 ! include 'COMMON.GEO'
1914 ! include 'COMMON.VAR'
1915 ! include 'COMMON.LOCAL'
1916 ! include 'COMMON.CHAIN'
1917 ! include 'COMMON.DERIV'
1918 ! include 'COMMON.NAMES'
1919 ! include 'COMMON.INTERACT'
1920 ! include 'COMMON.IOUNITS'
1921 ! include 'COMMON.CALC'
1923 !el integer :: icall
1924 !el common /srutu/ icall
1925 ! double precision rrsave(maxdim)
1928 integer :: iint,itypi,itypi1,itypj
1929 real(kind=8) :: rrij,xi,yi,zi, sslipi,ssgradlipi, sslipj, &
1931 real(kind=8) :: evdw,fac,e1,e2,sigm,epsi
1933 ! print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
1935 ! if (icall.eq.0) then
1941 do i=iatsc_s,iatsc_e
1942 itypi=iabs(itype(i,1))
1943 if (itypi.eq.ntyp1) cycle
1944 itypi1=iabs(itype(i+1,1))
1948 call to_box(xi,yi,zi)
1949 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)
1956 ! Calculate SC interaction energy.
1958 do iint=1,nint_gr(i)
1959 do j=istart(i,iint),iend(i,iint)
1961 itypj=iabs(itype(j,1))
1962 if (itypj.eq.ntyp1) cycle
1963 ! dscj_inv=dsc_inv(itypj)
1964 dscj_inv=vbld_inv(j+nres)
1965 chi1=chi(itypi,itypj)
1966 chi2=chi(itypj,itypi)
1973 alf12=0.5D0*(alf1+alf2)
1974 ! For diagnostics only!!!
1987 call to_box(xj,yj,zj)
1988 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
1989 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
1990 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
1991 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
1992 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
1993 xj=boxshift(xj-xi,boxxsize)
1994 yj=boxshift(yj-yi,boxysize)
1995 zj=boxshift(zj-zi,boxzsize)
1996 dxj=dc_norm(1,nres+j)
1997 dyj=dc_norm(2,nres+j)
1998 dzj=dc_norm(3,nres+j)
1999 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
2000 !d if (icall.eq.0) then
2006 ! Calculate the angle-dependent terms of energy & contributions to derivatives.
2008 ! Calculate whole angle-dependent part of epsilon and contributions
2009 ! to its derivatives
2010 fac=(rrij*sigsq)**expon2
2011 e1=fac*fac*aa_aq(itypi,itypj)
2012 e2=fac*bb_aq(itypi,itypj)
2013 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
2014 eps2der=evdwij*eps3rt
2015 eps3der=evdwij*eps2rt
2016 evdwij=evdwij*eps2rt*eps3rt
2019 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
2020 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
2021 !d write (iout,'(2(a3,i3,2x),15(0pf7.3))')
2022 !d & restyp(itypi,1),i,restyp(itypj,1),j,
2023 !d & epsi,sigm,chi1,chi2,chip1,chip2,
2024 !d & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
2025 !d & om1,om2,om12,1.0D0/dsqrt(rrij),
2028 ! Calculate gradient components.
2029 e1=e1*eps1*eps2rt**2*eps3rt**2
2030 fac=-expon*(e1+evdwij)
2033 ! Calculate radial part of the gradient
2037 ! Calculate the angular part of the gradient and sum add the contributions
2038 ! to the appropriate components of the Cartesian gradient.
2046 !-----------------------------------------------------------------------------
2047 subroutine egb(evdw)
2049 ! This subroutine calculates the interaction energy of nonbonded side chains
2050 ! assuming the Gay-Berne potential of interaction.
2053 ! implicit real(kind=8) (a-h,o-z)
2054 ! include 'DIMENSIONS'
2055 ! include 'COMMON.GEO'
2056 ! include 'COMMON.VAR'
2057 ! include 'COMMON.LOCAL'
2058 ! include 'COMMON.CHAIN'
2059 ! include 'COMMON.DERIV'
2060 ! include 'COMMON.NAMES'
2061 ! include 'COMMON.INTERACT'
2062 ! include 'COMMON.IOUNITS'
2063 ! include 'COMMON.CALC'
2064 ! include 'COMMON.CONTROL'
2065 ! include 'COMMON.SBRIDGE'
2068 integer :: iint,itypi,itypi1,itypj,subchap,icont,countss
2069 real(kind=8) :: rrij,xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
2070 real(kind=8) :: evdw,sig0ij
2071 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
2072 dist_temp, dist_init,aa,bb,ssgradlipi,ssgradlipj, &
2073 sslipi,sslipj,faclip
2075 real(kind=8) :: fracinbuf
2077 !cccc energy_dec=.false.
2078 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
2082 ! if (icall.eq.0) lprn=.false.
2090 ! write (iout,*) "RWA", g_listscsc_start,g_listscsc_end,i,j
2091 if (nres_molec(1).eq.0) return
2092 do icont=g_listscsc_start,g_listscsc_end
2093 i=newcontlisti(icont)
2094 j=newcontlistj(icont)
2095 ! write (iout,*) "RWA", g_listscsc_start,g_listscsc_end,i,j
2096 ! do i=iatsc_s,iatsc_e
2097 !C print *,"I am in EVDW",i
2098 itypi=iabs(itype(i,1))
2099 ! if (i.ne.47) cycle
2100 if (itypi.eq.ntyp1) cycle
2101 itypi1=iabs(itype(i+1,1))
2105 call to_box(xi,yi,zi)
2106 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
2108 dxi=dc_norm(1,nres+i)
2109 dyi=dc_norm(2,nres+i)
2110 dzi=dc_norm(3,nres+i)
2111 ! dsci_inv=dsc_inv(itypi)
2112 dsci_inv=vbld_inv(i+nres)
2113 ! write (iout,*) "i",i,dsc_inv(itypi),dsci_inv,1.0d0/vbld(i+nres)
2114 ! write (iout,*) "dcnori",dxi*dxi+dyi*dyi+dzi*dzi
2116 ! Calculate SC interaction energy.
2118 ! do iint=1,nint_gr(i)
2119 ! do j=istart(i,iint),iend(i,iint)
2120 IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
2122 call dyn_ssbond_ene(i,j,evdwij,countss)
2124 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
2125 'evdw',i,j,evdwij,' ss'
2126 ! if (energy_dec) write (iout,*) &
2127 ! 'evdw',i,j,evdwij,' ss'
2129 !C search over all next residues
2130 if (dyn_ss_mask(k)) then
2131 !C check if they are cysteins
2132 !C write(iout,*) 'k=',k
2134 !c write(iout,*) "PRZED TRI", evdwij
2135 ! evdwij_przed_tri=evdwij
2136 call triple_ssbond_ene(i,j,k,evdwij)
2137 !c if(evdwij_przed_tri.ne.evdwij) then
2138 !c write (iout,*) "TRI:", evdwij, evdwij_przed_tri
2141 !c write(iout,*) "PO TRI", evdwij
2142 !C call the energy function that removes the artifical triple disulfide
2143 !C bond the soubroutine is located in ssMD.F
2145 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
2146 'evdw',i,j,evdwij,'tss'
2147 endif!dyn_ss_mask(k)
2151 itypj=iabs(itype(j,1))
2152 if (itypj.eq.ntyp1) cycle
2153 ! if (j.ne.78) cycle
2154 ! dscj_inv=dsc_inv(itypj)
2155 dscj_inv=vbld_inv(j+nres)
2156 ! write (iout,*) "j",j,dsc_inv(itypj),dscj_inv,&
2157 ! 1.0d0/vbld(j+nres) !d
2158 ! write (iout,*) "i",i," j", j," itype",itype(i,1),itype(j,1)
2159 sig0ij=sigma(itypi,itypj)
2160 chi1=chi(itypi,itypj)
2161 chi2=chi(itypj,itypi)
2168 alf12=0.5D0*(alf1+alf2)
2169 ! For diagnostics only!!!
2182 call to_box(xj,yj,zj)
2183 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
2184 ! write (iout,*) "KWA2", itypi,itypj
2185 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
2186 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
2187 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
2188 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
2189 xj=boxshift(xj-xi,boxxsize)
2190 yj=boxshift(yj-yi,boxysize)
2191 zj=boxshift(zj-zi,boxzsize)
2192 dxj=dc_norm(1,nres+j)
2193 dyj=dc_norm(2,nres+j)
2194 dzj=dc_norm(3,nres+j)
2195 ! write (iout,*) "dcnorj",dxi*dxi+dyi*dyi+dzi*dzi
2196 ! write (iout,*) "j",j," dc_norm",& !d
2197 ! dc_norm(1,nres+j),dc_norm(2,nres+j),dc_norm(3,nres+j)
2198 ! write(iout,*)"rrij ",rrij
2199 ! write(iout,*)"xj yj zj ", xj, yj, zj
2200 ! write(iout,*)"xi yi zi ", xi, yi, zi
2201 ! write(iout,*)"c ", c(1,:), c(2,:), c(3,:)
2202 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
2204 sss_ele_cut=sscale_ele(1.0d0/(rij))
2205 sss_ele_grad=sscagrad_ele(1.0d0/(rij))
2206 ! print *,sss_ele_cut,sss_ele_grad,&
2207 ! 1.0d0/(rij),r_cut_ele,rlamb_ele
2208 if (sss_ele_cut.le.0.0) cycle
2209 ! Calculate angle-dependent terms of energy and contributions to their
2213 sig=sig0ij*dsqrt(sigsq)
2214 rij_shift=1.0D0/rij-sig+sig0ij
2215 ! write(iout,*)" rij_shift",rij_shift," rij",rij," sig",sig,&
2217 ! for diagnostics; uncomment
2218 ! rij_shift=1.2*sig0ij
2219 ! I hate to put IF's in the loops, but here don't have another choice!!!!
2220 if (rij_shift.le.0.0D0) then
2222 !d write (iout,'(2(a3,i3,2x),17(0pf7.3))')
2223 !d & restyp(itypi,1),i,restyp(itypj,1),j,
2224 !d & rij_shift,1.0D0/rij,sig,sig0ij,sigsq,1-dsqrt(sigsq)
2228 !---------------------------------------------------------------
2229 rij_shift=1.0D0/rij_shift
2230 fac=rij_shift**expon
2232 e1=fac*fac*aa!(itypi,itypj)
2233 e2=fac*bb!(itypi,itypj)
2234 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
2235 eps2der=evdwij*eps3rt
2236 eps3der=evdwij*eps2rt
2237 ! write(iout,*)"aa, bb ",aa(:,:),bb(:,:)
2238 ! write (iout,*) "sigsq",sigsq," sig",sig," eps2rt",eps2rt,& !d
2239 ! " eps3rt",eps3rt," eps1",eps1," e1",e1," e2",e2," fac",fac !d
2240 evdwij=evdwij*eps2rt*eps3rt
2241 evdw=evdw+evdwij*sss_ele_cut
2243 sigm=dabs(aa/bb)**(1.0D0/6.0D0)
2244 epsi=bb**2/aa!(itypi,itypj)
2245 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
2246 restyp(itypi,1),i,restyp(itypj,1),j, &
2247 epsi,sigm,chi1,chi2,chip1,chip2, &
2248 eps1,eps2rt**2,eps3rt**2,sig,sig0ij, &
2249 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift, &
2253 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,2e10.2,e11.3)')&
2254 'evdw',i,j,evdwij,1.0D0/rij,1.0D0/rij_shift,dabs(aa/bb)**(1.0D0/6.0D0)!,"egb"
2255 !C print *,i,j,c(1,i),c(1,j),c(2,i),c(2,j),c(3,i),c(3,j)
2256 ! if (energy_dec) write (iout,*) &
2258 ! print *,"ZALAMKA", evdw
2260 ! Calculate gradient components.
2261 e1=e1*eps1*eps2rt**2*eps3rt**2
2262 fac=-expon*(e1+evdwij)*rij_shift
2265 ! print *,'before fac',fac,rij,evdwij
2266 fac=fac+evdwij*sss_ele_grad/sss_ele_cut&
2268 ! print *,'grad part scale',fac, &
2269 ! evdwij*sss_ele_grad/sss_ele_cut &
2270 ! /sigma(itypi,itypj)*rij
2272 ! Calculate the radial part of the gradient
2276 !C Calculate the radial part of the gradient
2277 gg_lipi(3)=eps1*(eps2rt*eps2rt)&
2278 *(eps3rt*eps3rt)*sss_ele_cut/2.0d0*(faclip*faclip*&
2279 (aa_lip(itypi,itypj)-aa_aq(itypi,itypj))&
2280 +faclip*(bb_lip(itypi,itypj)-bb_aq(itypi,itypj)))
2281 gg_lipj(3)=ssgradlipj*gg_lipi(3)
2282 gg_lipi(3)=gg_lipi(3)*ssgradlipi
2284 ! print *,'before sc_grad', gg(1),gg(2),gg(3)
2285 ! Calculate angular part of the gradient.
2291 ! print *,"ZALAMKA", evdw
2292 ! write (iout,*) "Number of loop steps in EGB:",ind
2293 !ccc energy_dec=.false.
2296 !-----------------------------------------------------------------------------
2297 subroutine egbv(evdw)
2299 ! This subroutine calculates the interaction energy of nonbonded side chains
2300 ! assuming the Gay-Berne-Vorobjev potential of interaction.
2304 ! implicit real(kind=8) (a-h,o-z)
2305 ! include 'DIMENSIONS'
2306 ! include 'COMMON.GEO'
2307 ! include 'COMMON.VAR'
2308 ! include 'COMMON.LOCAL'
2309 ! include 'COMMON.CHAIN'
2310 ! include 'COMMON.DERIV'
2311 ! include 'COMMON.NAMES'
2312 ! include 'COMMON.INTERACT'
2313 ! include 'COMMON.IOUNITS'
2314 ! include 'COMMON.CALC'
2316 !el integer :: icall
2317 !el common /srutu/ icall
2320 integer :: iint,itypi,itypi1,itypj
2321 real(kind=8) :: rrij,xi,yi,zi,r0ij,fac_augm,e_augm,fac,e1,e2, &
2322 sigm,sslipi,ssgradlipi, sslipj,ssgradlipj, aa, bb
2323 real(kind=8) :: evdw,sig0ij,sig,rij_shift,epsi
2325 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
2328 ! if (icall.eq.0) lprn=.true.
2330 do i=iatsc_s,iatsc_e
2331 itypi=iabs(itype(i,1))
2332 if (itypi.eq.ntyp1) cycle
2333 itypi1=iabs(itype(i+1,1))
2337 call to_box(xi,yi,zi)
2338 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
2339 dxi=dc_norm(1,nres+i)
2340 dyi=dc_norm(2,nres+i)
2341 dzi=dc_norm(3,nres+i)
2342 ! dsci_inv=dsc_inv(itypi)
2343 dsci_inv=vbld_inv(i+nres)
2345 ! Calculate SC interaction energy.
2347 do iint=1,nint_gr(i)
2348 do j=istart(i,iint),iend(i,iint)
2350 itypj=iabs(itype(j,1))
2351 if (itypj.eq.ntyp1) cycle
2352 ! dscj_inv=dsc_inv(itypj)
2353 dscj_inv=vbld_inv(j+nres)
2354 sig0ij=sigma(itypi,itypj)
2355 r0ij=r0(itypi,itypj)
2356 chi1=chi(itypi,itypj)
2357 chi2=chi(itypj,itypi)
2364 alf12=0.5D0*(alf1+alf2)
2365 ! For diagnostics only!!!
2378 call to_box(xj,yj,zj)
2379 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
2380 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
2381 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
2382 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
2383 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
2384 xj=boxshift(xj-xi,boxxsize)
2385 yj=boxshift(yj-yi,boxysize)
2386 zj=boxshift(zj-zi,boxzsize)
2387 dxj=dc_norm(1,nres+j)
2388 dyj=dc_norm(2,nres+j)
2389 dzj=dc_norm(3,nres+j)
2390 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
2392 ! Calculate angle-dependent terms of energy and contributions to their
2396 sig=sig0ij*dsqrt(sigsq)
2397 rij_shift=1.0D0/rij-sig+r0ij
2398 ! I hate to put IF's in the loops, but here don't have another choice!!!!
2399 if (rij_shift.le.0.0D0) then
2404 !---------------------------------------------------------------
2405 rij_shift=1.0D0/rij_shift
2406 fac=rij_shift**expon
2407 e1=fac*fac*aa_aq(itypi,itypj)
2408 e2=fac*bb_aq(itypi,itypj)
2409 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
2410 eps2der=evdwij*eps3rt
2411 eps3der=evdwij*eps2rt
2412 fac_augm=rrij**expon
2413 e_augm=augm(itypi,itypj)*fac_augm
2414 evdwij=evdwij*eps2rt*eps3rt
2415 evdw=evdw+evdwij+e_augm
2417 sigm=dabs(aa_aq(itypi,itypj)/&
2418 bb_aq(itypi,itypj))**(1.0D0/6.0D0)
2419 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
2420 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
2421 restyp(itypi,1),i,restyp(itypj,1),j,&
2422 epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),&
2423 chi1,chi2,chip1,chip2,&
2424 eps1,eps2rt**2,eps3rt**2,&
2425 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
2428 ! Calculate gradient components.
2429 e1=e1*eps1*eps2rt**2*eps3rt**2
2430 fac=-expon*(e1+evdwij)*rij_shift
2432 fac=rij*fac-2*expon*rrij*e_augm
2433 ! Calculate the radial part of the gradient
2437 ! Calculate angular part of the gradient.
2443 !-----------------------------------------------------------------------------
2444 !el subroutine sc_angular in module geometry
2445 !-----------------------------------------------------------------------------
2446 subroutine e_softsphere(evdw)
2448 ! This subroutine calculates the interaction energy of nonbonded side chains
2449 ! assuming the LJ potential of interaction.
2451 ! implicit real(kind=8) (a-h,o-z)
2452 ! include 'DIMENSIONS'
2453 real(kind=8),parameter :: accur=1.0d-10
2454 ! include 'COMMON.GEO'
2455 ! include 'COMMON.VAR'
2456 ! include 'COMMON.LOCAL'
2457 ! include 'COMMON.CHAIN'
2458 ! include 'COMMON.DERIV'
2459 ! include 'COMMON.INTERACT'
2460 ! include 'COMMON.TORSION'
2461 ! include 'COMMON.SBRIDGE'
2462 ! include 'COMMON.NAMES'
2463 ! include 'COMMON.IOUNITS'
2464 ! include 'COMMON.CONTACTS'
2465 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
2466 !d print *,'Entering Esoft_sphere nnt=',nnt,' nct=',nct
2468 integer :: i,iint,j,itypi,itypi1,itypj,k
2469 real(kind=8) :: evdw,xj,yj,zj,xi,yi,zi,rij,r0ij,r0ijsq,evdwij
2473 do i=iatsc_s,iatsc_e
2474 itypi=iabs(itype(i,1))
2475 if (itypi.eq.ntyp1) cycle
2476 itypi1=iabs(itype(i+1,1))
2480 call to_box(xi,yi,zi)
2483 ! Calculate SC interaction energy.
2485 do iint=1,nint_gr(i)
2486 !d write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
2487 !d & 'iend=',iend(i,iint)
2488 do j=istart(i,iint),iend(i,iint)
2489 itypj=iabs(itype(j,1))
2490 if (itypj.eq.ntyp1) cycle
2491 xj=boxshift(c(1,nres+j)-xi,boxxsize)
2492 yj=boxshift(c(2,nres+j)-yi,boxysize)
2493 zj=boxshift(c(3,nres+j)-zi,boxzsize)
2494 rij=xj*xj+yj*yj+zj*zj
2495 ! write (iout,*)'i=',i,' j=',j,' itypi=',itypi,' itypj=',itypj
2496 r0ij=r0(itypi,itypj)
2498 ! print *,i,j,r0ij,dsqrt(rij)
2499 if (rij.lt.r0ijsq) then
2500 evdwij=0.25d0*(rij-r0ijsq)**2
2508 ! Calculate the components of the gradient in DC and X
2514 gvdwx(k,i)=gvdwx(k,i)-gg(k)
2515 gvdwx(k,j)=gvdwx(k,j)+gg(k)
2516 gvdwc(k,i)=gvdwc(k,i)-gg(k)
2517 gvdwc(k,j)=gvdwc(k,j)+gg(k)
2521 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
2528 end subroutine e_softsphere
2529 !-----------------------------------------------------------------------------
2530 subroutine eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
2532 ! Soft-sphere potential of p-p interaction
2534 ! implicit real(kind=8) (a-h,o-z)
2535 ! include 'DIMENSIONS'
2536 ! include 'COMMON.CONTROL'
2537 ! include 'COMMON.IOUNITS'
2538 ! include 'COMMON.GEO'
2539 ! include 'COMMON.VAR'
2540 ! include 'COMMON.LOCAL'
2541 ! include 'COMMON.CHAIN'
2542 ! include 'COMMON.DERIV'
2543 ! include 'COMMON.INTERACT'
2544 ! include 'COMMON.CONTACTS'
2545 ! include 'COMMON.TORSION'
2546 ! include 'COMMON.VECTORS'
2547 ! include 'COMMON.FFIELD'
2548 real(kind=8),dimension(3) :: ggg
2549 !d write(iout,*) 'In EELEC_soft_sphere'
2551 integer :: i,j,k,num_conti,iteli,itelj
2552 real(kind=8) :: ees,evdw1,eel_loc,eello_turn3,eello_turn4
2553 real(kind=8) :: dxi,dyi,dzi,xmedi,ymedi,zmedi,r0ij,r0ijsq
2554 real(kind=8) :: dxj,dyj,dzj,xj,yj,zj,rij,evdw1ij,fac
2562 do i=iatel_s,iatel_e
2563 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
2567 xmedi=c(1,i)+0.5d0*dxi
2568 ymedi=c(2,i)+0.5d0*dyi
2569 zmedi=c(3,i)+0.5d0*dzi
2570 call to_box(xmedi,ymedi,zmedi)
2572 ! write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
2573 do j=ielstart(i),ielend(i)
2574 if (itype(j,1).eq.ntyp1 .or. itype(j+1,1).eq.ntyp1) cycle
2578 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
2579 r0ij=rpp(iteli,itelj)
2584 xj=c(1,j)+0.5D0*dxj-xmedi
2585 yj=c(2,j)+0.5D0*dyj-ymedi
2586 zj=c(3,j)+0.5D0*dzj-zmedi
2587 call to_box(xj,yj,zj)
2588 xj=boxshift(xj-xmedi,boxxsize)
2589 yj=boxshift(yj-ymedi,boxysize)
2590 zj=boxshift(zj-zmedi,boxzsize)
2591 rij=xj*xj+yj*yj+zj*zj
2592 if (rij.lt.r0ijsq) then
2593 evdw1ij=0.25d0*(rij-r0ijsq)**2
2601 ! Calculate contributions to the Cartesian gradient.
2607 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
2608 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
2611 ! Loop over residues i+1 thru j-1.
2615 !grad gelc(l,k)=gelc(l,k)+ggg(l)
2620 !grad do i=nnt,nct-1
2622 !grad gelc(k,i)=gelc(k,i)+0.5d0*gelc(k,i)
2624 !grad do j=i+1,nct-1
2626 !grad gelc(k,i)=gelc(k,i)+gelc(k,j)
2631 end subroutine eelec_soft_sphere
2632 !-----------------------------------------------------------------------------
2633 subroutine vec_and_deriv
2634 ! implicit real(kind=8) (a-h,o-z)
2635 ! include 'DIMENSIONS'
2639 ! include 'COMMON.IOUNITS'
2640 ! include 'COMMON.GEO'
2641 ! include 'COMMON.VAR'
2642 ! include 'COMMON.LOCAL'
2643 ! include 'COMMON.CHAIN'
2644 ! include 'COMMON.VECTORS'
2645 ! include 'COMMON.SETUP'
2646 ! include 'COMMON.TIME1'
2647 real(kind=8),dimension(3,3,2) :: uyder,uzder
2648 real(kind=8),dimension(2) :: vbld_inv_temp
2649 ! Compute the local reference systems. For reference system (i), the
2650 ! X-axis points from CA(i) to CA(i+1), the Y axis is in the
2651 ! CA(i)-CA(i+1)-CA(i+2) plane, and the Z axis is perpendicular to this plane.
2654 real(kind=8) :: facy,fac,costh
2657 do i=ivec_start,ivec_end
2661 if (i.eq.nres-1) then
2662 ! Case of the last full residue
2663 ! Compute the Z-axis
2664 call vecpr(dc_norm(1,i),dc_norm(1,i-1),uz(1,i))
2665 costh=dcos(pi-theta(nres))
2666 fac=1.0d0/dsqrt(1.0d0-costh*costh)
2670 ! Compute the derivatives of uz
2672 uzder(2,1,1)=-dc_norm(3,i-1)
2673 uzder(3,1,1)= dc_norm(2,i-1)
2674 uzder(1,2,1)= dc_norm(3,i-1)
2676 uzder(3,2,1)=-dc_norm(1,i-1)
2677 uzder(1,3,1)=-dc_norm(2,i-1)
2678 uzder(2,3,1)= dc_norm(1,i-1)
2681 uzder(2,1,2)= dc_norm(3,i)
2682 uzder(3,1,2)=-dc_norm(2,i)
2683 uzder(1,2,2)=-dc_norm(3,i)
2685 uzder(3,2,2)= dc_norm(1,i)
2686 uzder(1,3,2)= dc_norm(2,i)
2687 uzder(2,3,2)=-dc_norm(1,i)
2689 ! Compute the Y-axis
2692 uy(k,i)=fac*(dc_norm(k,i-1)-costh*dc_norm(k,i))
2694 ! Compute the derivatives of uy
2697 uyder(k,j,1)=2*dc_norm(k,i-1)*dc_norm(j,i) &
2698 -dc_norm(k,i)*dc_norm(j,i-1)
2699 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
2701 uyder(j,j,1)=uyder(j,j,1)-costh
2702 uyder(j,j,2)=1.0d0+uyder(j,j,2)
2707 uygrad(l,k,j,i)=uyder(l,k,j)
2708 uzgrad(l,k,j,i)=uzder(l,k,j)
2712 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
2713 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
2714 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
2715 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
2718 ! Compute the Z-axis
2719 call vecpr(dc_norm(1,i),dc_norm(1,i+1),uz(1,i))
2720 costh=dcos(pi-theta(i+2))
2721 fac=1.0d0/dsqrt(1.0d0-costh*costh)
2725 ! Compute the derivatives of uz
2727 uzder(2,1,1)=-dc_norm(3,i+1)
2728 uzder(3,1,1)= dc_norm(2,i+1)
2729 uzder(1,2,1)= dc_norm(3,i+1)
2731 uzder(3,2,1)=-dc_norm(1,i+1)
2732 uzder(1,3,1)=-dc_norm(2,i+1)
2733 uzder(2,3,1)= dc_norm(1,i+1)
2736 uzder(2,1,2)= dc_norm(3,i)
2737 uzder(3,1,2)=-dc_norm(2,i)
2738 uzder(1,2,2)=-dc_norm(3,i)
2740 uzder(3,2,2)= dc_norm(1,i)
2741 uzder(1,3,2)= dc_norm(2,i)
2742 uzder(2,3,2)=-dc_norm(1,i)
2744 ! Compute the Y-axis
2747 uy(k,i)=facy*(dc_norm(k,i+1)-costh*dc_norm(k,i))
2749 ! Compute the derivatives of uy
2752 uyder(k,j,1)=2*dc_norm(k,i+1)*dc_norm(j,i) &
2753 -dc_norm(k,i)*dc_norm(j,i+1)
2754 uyder(k,j,2)=-dc_norm(j,i)*dc_norm(k,i)
2756 uyder(j,j,1)=uyder(j,j,1)-costh
2757 uyder(j,j,2)=1.0d0+uyder(j,j,2)
2762 uygrad(l,k,j,i)=uyder(l,k,j)
2763 uzgrad(l,k,j,i)=uzder(l,k,j)
2767 call unormderiv(uy(1,i),uyder(1,1,1),facy,uygrad(1,1,1,i))
2768 call unormderiv(uy(1,i),uyder(1,1,2),facy,uygrad(1,1,2,i))
2769 call unormderiv(uz(1,i),uzder(1,1,1),fac,uzgrad(1,1,1,i))
2770 call unormderiv(uz(1,i),uzder(1,1,2),fac,uzgrad(1,1,2,i))
2774 vbld_inv_temp(1)=vbld_inv(i+1)
2775 if (i.lt.nres-1) then
2776 vbld_inv_temp(2)=vbld_inv(i+2)
2778 vbld_inv_temp(2)=vbld_inv(i)
2783 uygrad(l,k,j,i)=vbld_inv_temp(j)*uygrad(l,k,j,i)
2784 uzgrad(l,k,j,i)=vbld_inv_temp(j)*uzgrad(l,k,j,i)
2789 #if defined(PARVEC) && defined(MPI)
2790 if (nfgtasks1.gt.1) then
2792 ! print *,"Processor",fg_rank1,kolor1," ivec_start",ivec_start,
2793 ! & " ivec_displ",(ivec_displ(i),i=0,nfgtasks1-1),
2794 ! & " ivec_count",(ivec_count(i),i=0,nfgtasks1-1)
2795 call MPI_Allgatherv(uy(1,ivec_start),ivec_count(fg_rank1),&
2796 MPI_UYZ,uy(1,1),ivec_count(0),ivec_displ(0),MPI_UYZ,&
2798 call MPI_Allgatherv(uz(1,ivec_start),ivec_count(fg_rank1),&
2799 MPI_UYZ,uz(1,1),ivec_count(0),ivec_displ(0),MPI_UYZ,&
2801 call MPI_Allgatherv(uygrad(1,1,1,ivec_start),&
2802 ivec_count(fg_rank1),MPI_UYZGRAD,uygrad(1,1,1,1),ivec_count(0),&
2803 ivec_displ(0),MPI_UYZGRAD,FG_COMM1,IERR)
2804 call MPI_Allgatherv(uzgrad(1,1,1,ivec_start),&
2805 ivec_count(fg_rank1),MPI_UYZGRAD,uzgrad(1,1,1,1),ivec_count(0),&
2806 ivec_displ(0),MPI_UYZGRAD,FG_COMM1,IERR)
2807 time_gather=time_gather+MPI_Wtime()-time00
2809 ! if (fg_rank.eq.0) then
2810 ! write (iout,*) "Arrays UY and UZ"
2812 ! write (iout,'(i5,3f10.5,5x,3f10.5)') i,(uy(k,i),k=1,3),
2818 end subroutine vec_and_deriv
2819 !-----------------------------------------------------------------------------
2820 subroutine check_vecgrad
2821 ! implicit real(kind=8) (a-h,o-z)
2822 ! include 'DIMENSIONS'
2823 ! include 'COMMON.IOUNITS'
2824 ! include 'COMMON.GEO'
2825 ! include 'COMMON.VAR'
2826 ! include 'COMMON.LOCAL'
2827 ! include 'COMMON.CHAIN'
2828 ! include 'COMMON.VECTORS'
2829 real(kind=8),dimension(3,3,2,nres) :: uygradt,uzgradt !(3,3,2,maxres)
2830 real(kind=8),dimension(3,nres) :: uyt,uzt !(3,maxres)
2831 real(kind=8),dimension(3,3,2) :: uygradn,uzgradn
2832 real(kind=8),dimension(3) :: erij
2833 real(kind=8) :: delta=1.0d-7
2839 !rc write(iout,'(2i5,2(3f10.5,5x))') i,1,dc_norm(:,i)
2840 !rc write(iout,'(2i5,2(3f10.5,5x))') i,2,uy(:,i)
2841 !rc write(iout,'(2i5,2(3f10.5,5x)/)')i,3,uz(:,i)
2842 !d write(iout,'(2i5,2(3f10.5,5x))') i,1,
2843 !d & (dc_norm(if90,i),if90=1,3)
2844 !d write(iout,'(2i5,2(3f10.5,5x))') i,2,(uy(if90,i),if90=1,3)
2845 !d write(iout,'(2i5,2(3f10.5,5x)/)')i,3,(uz(if90,i),if90=1,3)
2846 !d write(iout,'(a)')
2852 uygradt(l,k,j,i)=uygrad(l,k,j,i)
2853 uzgradt(l,k,j,i)=uzgrad(l,k,j,i)
2866 !d write (iout,*) 'i=',i
2868 erij(k)=dc_norm(k,i)
2872 dc_norm(k,i)=erij(k)
2874 dc_norm(j,i)=dc_norm(j,i)+delta
2875 ! fac=dsqrt(scalar(dc_norm(1,i),dc_norm(1,i)))
2877 ! dc_norm(k,i)=dc_norm(k,i)/fac
2879 ! write (iout,*) (dc_norm(k,i),k=1,3)
2880 ! write (iout,*) (erij(k),k=1,3)
2883 uygradn(k,j,1)=(uy(k,i)-uyt(k,i))/delta
2884 uygradn(k,j,2)=(uy(k,i-1)-uyt(k,i-1))/delta
2885 uzgradn(k,j,1)=(uz(k,i)-uzt(k,i))/delta
2886 uzgradn(k,j,2)=(uz(k,i-1)-uzt(k,i-1))/delta
2888 ! write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2889 ! & j,(uzgradt(k,j,1,i),k=1,3),(uzgradn(k,j,1),k=1,3),
2890 ! & (uzgradt(k,j,2,i-1),k=1,3),(uzgradn(k,j,2),k=1,3)
2893 dc_norm(k,i)=erij(k)
2896 !d write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2897 !d & k,(uygradt(k,l,1,i),l=1,3),(uygradn(k,l,1),l=1,3),
2898 !d & (uygradt(k,l,2,i-1),l=1,3),(uygradn(k,l,2),l=1,3)
2899 !d write (iout,'(i5,3f8.5,3x,3f8.5,5x,3f8.5,3x,3f8.5)')
2900 !d & k,(uzgradt(k,l,1,i),l=1,3),(uzgradn(k,l,1),l=1,3),
2901 !d & (uzgradt(k,l,2,i-1),l=1,3),(uzgradn(k,l,2),l=1,3)
2902 !d write (iout,'(a)')
2906 end subroutine check_vecgrad
2907 !-----------------------------------------------------------------------------
2908 subroutine set_matrices
2909 ! implicit real(kind=8) (a-h,o-z)
2910 ! include 'DIMENSIONS'
2913 ! include "COMMON.SETUP"
2915 integer :: status(MPI_STATUS_SIZE)
2917 ! include 'COMMON.IOUNITS'
2918 ! include 'COMMON.GEO'
2919 ! include 'COMMON.VAR'
2920 ! include 'COMMON.LOCAL'
2921 ! include 'COMMON.CHAIN'
2922 ! include 'COMMON.DERIV'
2923 ! include 'COMMON.INTERACT'
2924 ! include 'COMMON.CONTACTS'
2925 ! include 'COMMON.TORSION'
2926 ! include 'COMMON.VECTORS'
2927 ! include 'COMMON.FFIELD'
2928 real(kind=8) :: auxvec(2),auxmat(2,2)
2929 integer :: i,iti1,iti,k,l,ii,innt,inct
2930 real(kind=8) :: sin1,cos1,sin2,cos2,dwacos2,dwasin2,cost1,sint1,&
2931 sint1sq,sint1cub,sint1cost1,b1k,b2k,aux
2932 ! print *,"in set matrices"
2934 ! Compute the virtual-bond-torsional-angle dependent quantities needed
2935 ! to calculate the el-loc multibody terms of various order.
2940 do i=ivec_start+2,ivec_end+2
2946 !c write (iout,*) "i",i,i-2," ii",ii
2948 innt=chain_border(1,ii)
2949 inct=chain_border(2,ii)
2950 !c write (iout,*) "i",i,i-2," ii",ii," innt",innt," inct",inct
2951 !c if (i.gt. nnt+2 .and. i.lt.nct+2) then
2952 if (i.gt. innt+2 .and. i.lt.inct+2) then
2953 if (itype(i-2,1).eq.0) then
2956 iti = itype2loc(itype(i-2,1))
2961 !c if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
2962 if (i.gt. innt+1 .and. i.lt.inct+1) then
2963 ! iti1 = itype2loc(itype(i-1))
2964 if (itype(i-1,1).eq.0) then
2967 iti1 = itype2loc(itype(i-1,1))
2973 if (i.gt. nnt+2 .and. i.lt.nct+2) then
2974 if (itype(i-2,1).eq.0) then
2977 iti = itype2loc(itype(i-2,1))
2982 !c if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
2983 if (i.gt. nnt+1 .and. i.lt.nct+1) then
2984 iti1 = itype2loc(itype(i-1,1))
2989 ! print *,i,itype(i-2,1),iti
2991 cost1=dcos(theta(i-1))
2992 sint1=dsin(theta(i-1))
2994 sint1cub=sint1sq*sint1
2995 sint1cost1=2*sint1*cost1
2996 ! print *,"cost1",cost1,theta(i-1)
2997 !c write (iout,*) "bnew1",i,iti
2998 !c write (iout,*) (bnew1(k,1,iti),k=1,3)
2999 !c write (iout,*) (bnew1(k,2,iti),k=1,3)
3000 !c write (iout,*) "bnew2",i,iti
3001 !c write (iout,*) (bnew2(k,1,iti),k=1,3)
3002 !c write (iout,*) (bnew2(k,2,iti),k=1,3)
3004 ! print *,bnew1(1,k,iti),"bnew1"
3006 b1k=bnew1(1,k,iti)+(bnew1(2,k,iti)+bnew1(3,k,iti)*cost1)*cost1
3008 ! write(*,*) shape(b1)
3009 ! if(.not.allocated(b1)) print *, "WTF?"
3014 gtb1(k,i-2)=cost1*b1k-sint1sq*&
3015 (bnew1(2,k,iti)+2*bnew1(3,k,iti)*cost1)
3016 ! print *,gtb1(k,i-2)
3018 b2k=bnew2(1,k,iti)+(bnew2(2,k,iti)+bnew2(3,k,iti)*cost1)*cost1
3022 gtb2(k,i-2)=cost1*b2k-sint1sq*&
3023 (bnew2(2,k,iti)+2*bnew2(3,k,iti)*cost1)
3024 ! print *,gtb2(k,i-2)
3029 aux=ccnew(1,k,iti)+(ccnew(2,k,iti)+ccnew(3,k,iti)*cost1)*cost1
3030 cc(1,k,i-2)=sint1sq*aux
3031 gtcc(1,k,i-2)=sint1cost1*aux-sint1cub*&
3032 (ccnew(2,k,iti)+2*ccnew(3,k,iti)*cost1)
3033 aux=ddnew(1,k,iti)+(ddnew(2,k,iti)+ddnew(3,k,iti)*cost1)*cost1
3034 dd(1,k,i-2)=sint1sq*aux
3035 gtdd(1,k,i-2)=sint1cost1*aux-sint1cub*&
3036 (ddnew(2,k,iti)+2*ddnew(3,k,iti)*cost1)
3038 ! print *,"after cc"
3039 cc(2,1,i-2)=cc(1,2,i-2)
3040 cc(2,2,i-2)=-cc(1,1,i-2)
3041 gtcc(2,1,i-2)=gtcc(1,2,i-2)
3042 gtcc(2,2,i-2)=-gtcc(1,1,i-2)
3043 dd(2,1,i-2)=dd(1,2,i-2)
3044 dd(2,2,i-2)=-dd(1,1,i-2)
3045 gtdd(2,1,i-2)=gtdd(1,2,i-2)
3046 gtdd(2,2,i-2)=-gtdd(1,1,i-2)
3047 ! print *,"after dd"
3051 aux=eenew(1,l,k,iti)+eenew(2,l,k,iti)*cost1
3052 EE(l,k,i-2)=sint1sq*aux
3053 gtEE(l,k,i-2)=sint1cost1*aux-sint1cub*eenew(2,l,k,iti)
3056 EE(1,1,i-2)=EE(1,1,i-2)+e0new(1,iti)*cost1
3057 EE(1,2,i-2)=EE(1,2,i-2)+e0new(2,iti)+e0new(3,iti)*cost1
3058 EE(2,1,i-2)=EE(2,1,i-2)+e0new(2,iti)*cost1+e0new(3,iti)
3059 EE(2,2,i-2)=EE(2,2,i-2)-e0new(1,iti)
3060 gtEE(1,1,i-2)=gtEE(1,1,i-2)-e0new(1,iti)*sint1
3061 gtEE(1,2,i-2)=gtEE(1,2,i-2)-e0new(3,iti)*sint1
3062 gtEE(2,1,i-2)=gtEE(2,1,i-2)-e0new(2,iti)*sint1
3063 ! print *,"after ee"
3065 !c b1tilde(1,i-2)=b1(1,i-2)
3066 !c b1tilde(2,i-2)=-b1(2,i-2)
3067 !c b2tilde(1,i-2)=b2(1,i-2)
3068 !c b2tilde(2,i-2)=-b2(2,i-2)
3070 write (iout,*) 'i=',i-2,gtb1(2,i-2),gtb1(1,i-2)
3071 write(iout,*) 'b1=',(b1(k,i-2),k=1,2)
3072 write(iout,*) 'b2=',(b2(k,i-2),k=1,2)
3073 write (iout,*) 'theta=', theta(i-1)
3076 if (i.gt. innt+2 .and. i.lt.inct+2) then
3077 ! write(iout,*) "i,",molnum(i),nloctyp
3078 ! print *, "i,",molnum(i),i,itype(i-2,1)
3079 if (molnum(i).eq.1) then
3080 if (itype(i-2,1).eq.ntyp1) then
3083 iti = itype2loc(itype(i-2,1))
3091 !c write (iout,*) "i",i-1," itype",itype(i-2)," iti",iti
3092 !c if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
3093 if (i.gt. nnt+1 .and. i.lt.nct+1) then
3094 iti1 = itype2loc(itype(i-1,1))
3105 CC(k,l,i-2)=ccold(k,l,iti)
3106 DD(k,l,i-2)=ddold(k,l,iti)
3107 EE(k,l,i-2)=eeold(k,l,iti)
3111 b1tilde(1,i-2)= b1(1,i-2)
3112 b1tilde(2,i-2)=-b1(2,i-2)
3113 b2tilde(1,i-2)= b2(1,i-2)
3114 b2tilde(2,i-2)=-b2(2,i-2)
3116 Ctilde(1,1,i-2)= CC(1,1,i-2)
3117 Ctilde(1,2,i-2)= CC(1,2,i-2)
3118 Ctilde(2,1,i-2)=-CC(2,1,i-2)
3119 Ctilde(2,2,i-2)=-CC(2,2,i-2)
3121 Dtilde(1,1,i-2)= DD(1,1,i-2)
3122 Dtilde(1,2,i-2)= DD(1,2,i-2)
3123 Dtilde(2,1,i-2)=-DD(2,1,i-2)
3124 Dtilde(2,2,i-2)=-DD(2,2,i-2)
3127 do i=ivec_start+2,ivec_end+2
3133 if (i .lt. nres+1 .and. (itype(i-1,1).lt.ntyp1).and.(itype(i-1,1).ne.0)) then
3134 ! if (i .lt. nres+1) then
3171 if (i .gt. 3) then ! .and. i .lt. nres+1) then
3172 obrot_der(1,i-2)=-sin1
3173 obrot_der(2,i-2)= cos1
3174 Ugder(1,1,i-2)= sin1
3175 Ugder(1,2,i-2)=-cos1
3176 Ugder(2,1,i-2)=-cos1
3177 Ugder(2,2,i-2)=-sin1
3180 obrot2_der(1,i-2)=-dwasin2
3181 obrot2_der(2,i-2)= dwacos2
3182 Ug2der(1,1,i-2)= dwasin2
3183 Ug2der(1,2,i-2)=-dwacos2
3184 Ug2der(2,1,i-2)=-dwacos2
3185 Ug2der(2,2,i-2)=-dwasin2
3187 obrot_der(1,i-2)=0.0d0
3188 obrot_der(2,i-2)=0.0d0
3189 Ugder(1,1,i-2)=0.0d0
3190 Ugder(1,2,i-2)=0.0d0
3191 Ugder(2,1,i-2)=0.0d0
3192 Ugder(2,2,i-2)=0.0d0
3193 obrot2_der(1,i-2)=0.0d0
3194 obrot2_der(2,i-2)=0.0d0
3195 Ug2der(1,1,i-2)=0.0d0
3196 Ug2der(1,2,i-2)=0.0d0
3197 Ug2der(2,1,i-2)=0.0d0
3198 Ug2der(2,2,i-2)=0.0d0
3200 ! if (i.gt. iatel_s+2 .and. i.lt.iatel_e+5) then
3201 if (i.gt. nnt+2 .and. i.lt.nct+2) then
3202 if (itype(i-2,1).eq.0) then
3205 iti = itype2loc(itype(i-2,1))
3210 ! if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
3211 if (i.gt. nnt+1 .and. i.lt.nct+1) then
3212 if (itype(i-1,1).eq.0) then
3215 iti1 = itype2loc(itype(i-1,1))
3220 ! print *,iti,i,"iti",iti1,itype(i-1,1),itype(i-2,1)
3221 !d write (iout,*) '*******i',i,' iti1',iti
3222 ! write (iout,*) 'b1',b1(:,iti)
3223 ! write (iout,*) 'b2',b2(:,i-2)
3224 !d write (iout,*) 'Ug',Ug(:,:,i-2)
3225 ! if (i .gt. iatel_s+2) then
3226 if (i .gt. nnt+2) then
3227 call matvec2(Ug(1,1,i-2),b2(1,i-2),Ub2(1,i-2))
3229 call matvec2(Ug(1,1,i-2),gtb2(1,i-2),gUb2(1,i-2))
3230 !c write (iout,*) Ug(1,1,i-2),gtb2(1,i-2),gUb2(1,i-2),"chuj"
3233 call matmat2(EE(1,1,i-2),Ug(1,1,i-2),EUg(1,1,i-2))
3234 call matmat2(gtEE(1,1,i-2),Ug(1,1,i-2),gtEUg(1,1,i-2))
3235 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) &
3237 call matmat2(CC(1,1,i-2),Ug(1,1,i-2),CUg(1,1,i-2))
3238 call matmat2(DD(1,1,i-2),Ug(1,1,i-2),DUg(1,1,i-2))
3239 call matmat2(Dtilde(1,1,i-2),Ug2(1,1,i-2),DtUg2(1,1,i-2))
3240 call matvec2(Ctilde(1,1,i-1),obrot(1,i-2),Ctobr(1,i-2))
3241 call matvec2(Dtilde(1,1,i-2),obrot2(1,i-2),Dtobr2(1,i-2))
3252 DtUg2(l,k,i-2)=0.0d0
3256 call matvec2(Ugder(1,1,i-2),b2(1,i-2),Ub2der(1,i-2))
3257 call matmat2(EE(1,1,i-2),Ugder(1,1,i-2),EUgder(1,1,i-2))
3259 muder(k,i-2)=Ub2der(k,i-2)
3261 ! if (i.gt. iatel_s+1 .and. i.lt.iatel_e+4) then
3262 if (i.gt. nnt+1 .and. i.lt.nct+1) then
3263 if (itype(i-1,1).eq.0) then
3265 elseif (itype(i-1,1).le.ntyp) then
3266 iti1 = itype2loc(itype(i-1,1))
3274 mu(k,i-2)=Ub2(k,i-2)+b1(k,i-1)
3276 if (energy_dec) write (iout,*) 'Ub2 ',i,Ub2(:,i-2)
3277 if (energy_dec) write (iout,*) 'b1 ',iti1,b1(:,i-1)
3278 if (energy_dec) write (iout,*) 'mu ',i,iti1,mu(:,i-2)
3279 !d write (iout,*) 'mu1',mu1(:,i-2)
3280 !d write (iout,*) 'mu2',mu2(:,i-2)
3281 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.wcorr6.gt.0.0d0) &
3283 call matmat2(CC(1,1,i-1),Ugder(1,1,i-2),CUgder(1,1,i-2))
3284 call matmat2(DD(1,1,i-2),Ugder(1,1,i-2),DUgder(1,1,i-2))
3285 call matmat2(Dtilde(1,1,i-2),Ug2der(1,1,i-2),DtUg2der(1,1,i-2))
3286 call matvec2(Ctilde(1,1,i-1),obrot_der(1,i-2),Ctobrder(1,i-2))
3287 call matvec2(Dtilde(1,1,i-2),obrot2_der(1,i-2),Dtobr2der(1,i-2))
3288 ! Vectors and matrices dependent on a single virtual-bond dihedral.
3289 call matvec2(DD(1,1,i-2),b1tilde(1,i-1),auxvec(1))
3290 call matvec2(Ug2(1,1,i-2),auxvec(1),Ug2Db1t(1,i-2))
3291 call matvec2(Ug2der(1,1,i-2),auxvec(1),Ug2Db1tder(1,i-2))
3292 call matvec2(CC(1,1,i-1),Ub2(1,i-2),CUgb2(1,i-2))
3293 call matvec2(CC(1,1,i-1),Ub2der(1,i-2),CUgb2der(1,i-2))
3294 call matmat2(EUg(1,1,i-2),CC(1,1,iti1),EUgC(1,1,i-2))
3295 call matmat2(EUgder(1,1,i-2),CC(1,1,iti1),EUgCder(1,1,i-2))
3296 call matmat2(EUg(1,1,i-2),DD(1,1,iti1),EUgD(1,1,i-2))
3297 call matmat2(EUgder(1,1,i-2),DD(1,1,iti1),EUgDder(1,1,i-2))
3300 ! Matrices dependent on two consecutive virtual-bond dihedrals.
3301 ! The order of matrices is from left to right.
3302 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or.wcorr6.gt.0.0d0) &
3304 ! do i=max0(ivec_start,2),ivec_end
3306 call matmat2(DtUg2(1,1,i-1),EUg(1,1,i),DtUg2EUg(1,1,i))
3307 call matmat2(DtUg2der(1,1,i-1),EUg(1,1,i),DtUg2EUgder(1,1,1,i))
3308 call matmat2(DtUg2(1,1,i-1),EUgder(1,1,i),DtUg2EUgder(1,1,2,i))
3309 call transpose2(DtUg2(1,1,i-1),auxmat(1,1))
3310 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUg(1,1,i))
3311 call matmat2(auxmat(1,1),EUgder(1,1,i),Ug2DtEUgder(1,1,2,i))
3312 call transpose2(DtUg2der(1,1,i-1),auxmat(1,1))
3313 call matmat2(auxmat(1,1),EUg(1,1,i),Ug2DtEUgder(1,1,1,i))
3316 #if defined(MPI) && defined(PARMAT)
3318 ! if (fg_rank.eq.0) then
3319 write (iout,*) "Arrays UG and UGDER before GATHER"
3321 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
3322 ((ug(l,k,i),l=1,2),k=1,2),&
3323 ((ugder(l,k,i),l=1,2),k=1,2)
3325 write (iout,*) "Arrays UG2 and UG2DER"
3327 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
3328 ((ug2(l,k,i),l=1,2),k=1,2),&
3329 ((ug2der(l,k,i),l=1,2),k=1,2)
3331 write (iout,*) "Arrays OBROT OBROT2 OBROTDER and OBROT2DER"
3333 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
3334 (obrot(k,i),k=1,2),(obrot2(k,i),k=1,2),&
3335 (obrot_der(k,i),k=1,2),(obrot2_der(k,i),k=1,2)
3337 write (iout,*) "Arrays COSTAB SINTAB COSTAB2 and SINTAB2"
3339 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
3340 costab(i),sintab(i),costab2(i),sintab2(i)
3342 write (iout,*) "Array MUDER"
3344 write (iout,'(i5,2f10.5)') i,muder(1,i),muder(2,i)
3348 if (nfgtasks.gt.1) then
3350 ! write(iout,*)"Processor",fg_rank,kolor," ivec_start",ivec_start,
3351 ! & " ivec_displ",(ivec_displ(i),i=0,nfgtasks-1),
3352 ! & " ivec_count",(ivec_count(i),i=0,nfgtasks-1)
3354 call MPI_Allgatherv(Ub2(1,ivec_start),ivec_count(fg_rank1),&
3355 MPI_MU,Ub2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
3357 call MPI_Allgatherv(Ub2der(1,ivec_start),ivec_count(fg_rank1),&
3358 MPI_MU,Ub2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
3360 call MPI_Allgatherv(mu(1,ivec_start),ivec_count(fg_rank1),&
3361 MPI_MU,mu(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
3363 call MPI_Allgatherv(muder(1,ivec_start),ivec_count(fg_rank1),&
3364 MPI_MU,muder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
3366 call MPI_Allgatherv(Eug(1,1,ivec_start),ivec_count(fg_rank1),&
3367 MPI_MAT1,Eug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3369 call MPI_Allgatherv(Eugder(1,1,ivec_start),ivec_count(fg_rank1),&
3370 MPI_MAT1,Eugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3372 call MPI_Allgatherv(costab(ivec_start),ivec_count(fg_rank1),&
3373 MPI_DOUBLE_PRECISION,costab(1),ivec_count(0),ivec_displ(0),&
3374 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
3375 call MPI_Allgatherv(sintab(ivec_start),ivec_count(fg_rank1),&
3376 MPI_DOUBLE_PRECISION,sintab(1),ivec_count(0),ivec_displ(0),&
3377 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
3378 call MPI_Allgatherv(costab2(ivec_start),ivec_count(fg_rank1),&
3379 MPI_DOUBLE_PRECISION,costab2(1),ivec_count(0),ivec_displ(0),&
3380 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
3381 call MPI_Allgatherv(sintab2(ivec_start),ivec_count(fg_rank1),&
3382 MPI_DOUBLE_PRECISION,sintab2(1),ivec_count(0),ivec_displ(0),&
3383 MPI_DOUBLE_PRECISION,FG_COMM1,IERR)
3384 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) &
3386 call MPI_Allgatherv(Ctobr(1,ivec_start),ivec_count(fg_rank1),&
3387 MPI_MU,Ctobr(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
3389 call MPI_Allgatherv(Ctobrder(1,ivec_start),ivec_count(fg_rank1),&
3390 MPI_MU,Ctobrder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
3392 call MPI_Allgatherv(Dtobr2(1,ivec_start),ivec_count(fg_rank1),&
3393 MPI_MU,Dtobr2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
3395 call MPI_Allgatherv(Dtobr2der(1,ivec_start),ivec_count(fg_rank1),&
3396 MPI_MU,Dtobr2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
3398 call MPI_Allgatherv(Ug2Db1t(1,ivec_start),ivec_count(fg_rank1),&
3399 MPI_MU,Ug2Db1t(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
3401 call MPI_Allgatherv(Ug2Db1tder(1,ivec_start),&
3402 ivec_count(fg_rank1),&
3403 MPI_MU,Ug2Db1tder(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
3405 call MPI_Allgatherv(CUgb2(1,ivec_start),ivec_count(fg_rank1),&
3406 MPI_MU,CUgb2(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
3408 call MPI_Allgatherv(CUgb2der(1,ivec_start),ivec_count(fg_rank1),&
3409 MPI_MU,CUgb2der(1,1),ivec_count(0),ivec_displ(0),MPI_MU,&
3411 call MPI_Allgatherv(Cug(1,1,ivec_start),ivec_count(fg_rank1),&
3412 MPI_MAT1,Cug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3414 call MPI_Allgatherv(Cugder(1,1,ivec_start),ivec_count(fg_rank1),&
3415 MPI_MAT1,Cugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3417 call MPI_Allgatherv(Dug(1,1,ivec_start),ivec_count(fg_rank1),&
3418 MPI_MAT1,Dug(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3420 call MPI_Allgatherv(Dugder(1,1,ivec_start),ivec_count(fg_rank1),&
3421 MPI_MAT1,Dugder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3423 call MPI_Allgatherv(Dtug2(1,1,ivec_start),ivec_count(fg_rank1),&
3424 MPI_MAT1,Dtug2(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3426 call MPI_Allgatherv(Dtug2der(1,1,ivec_start),&
3427 ivec_count(fg_rank1),&
3428 MPI_MAT1,Dtug2der(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3430 call MPI_Allgatherv(EugC(1,1,ivec_start),ivec_count(fg_rank1),&
3431 MPI_MAT1,EugC(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3433 call MPI_Allgatherv(EugCder(1,1,ivec_start),ivec_count(fg_rank1),&
3434 MPI_MAT1,EugCder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3436 call MPI_Allgatherv(EugD(1,1,ivec_start),ivec_count(fg_rank1),&
3437 MPI_MAT1,EugD(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3439 call MPI_Allgatherv(EugDder(1,1,ivec_start),ivec_count(fg_rank1),&
3440 MPI_MAT1,EugDder(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3442 call MPI_Allgatherv(DtUg2EUg(1,1,ivec_start),&
3443 ivec_count(fg_rank1),&
3444 MPI_MAT1,DtUg2EUg(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3446 call MPI_Allgatherv(Ug2DtEUg(1,1,ivec_start),&
3447 ivec_count(fg_rank1),&
3448 MPI_MAT1,Ug2DtEUg(1,1,1),ivec_count(0),ivec_displ(0),MPI_MAT1,&
3450 call MPI_Allgatherv(DtUg2EUgder(1,1,1,ivec_start),&
3451 ivec_count(fg_rank1),&
3452 MPI_MAT2,DtUg2EUgder(1,1,1,1),ivec_count(0),ivec_displ(0),&
3453 MPI_MAT2,FG_COMM1,IERR)
3454 call MPI_Allgatherv(Ug2DtEUgder(1,1,1,ivec_start),&
3455 ivec_count(fg_rank1),&
3456 MPI_MAT2,Ug2DtEUgder(1,1,1,1),ivec_count(0),ivec_displ(0),&
3457 MPI_MAT2,FG_COMM1,IERR)
3460 ! Passes matrix info through the ring
3463 if (irecv.lt.0) irecv=nfgtasks1-1
3466 if (inext.ge.nfgtasks1) inext=0
3468 ! write (iout,*) "isend",isend," irecv",irecv
3470 lensend=lentyp(isend)
3471 lenrecv=lentyp(irecv)
3472 ! write (iout,*) "lensend",lensend," lenrecv",lenrecv
3473 ! call MPI_SENDRECV(ug(1,1,ivec_displ(isend)+1),1,
3474 ! & MPI_ROTAT1(lensend),inext,2200+isend,
3475 ! & ug(1,1,ivec_displ(irecv)+1),1,MPI_ROTAT1(lenrecv),
3476 ! & iprev,2200+irecv,FG_COMM,status,IERR)
3477 ! write (iout,*) "Gather ROTAT1"
3479 ! call MPI_SENDRECV(obrot(1,ivec_displ(isend)+1),1,
3480 ! & MPI_ROTAT2(lensend),inext,3300+isend,
3481 ! & obrot(1,ivec_displ(irecv)+1),1,MPI_ROTAT2(lenrecv),
3482 ! & iprev,3300+irecv,FG_COMM,status,IERR)
3483 ! write (iout,*) "Gather ROTAT2"
3485 call MPI_SENDRECV(costab(ivec_displ(isend)+1),1,&
3486 MPI_ROTAT_OLD(lensend),inext,4400+isend,&
3487 costab(ivec_displ(irecv)+1),1,MPI_ROTAT_OLD(lenrecv),&
3488 iprev,4400+irecv,FG_COMM,status,IERR)
3489 ! write (iout,*) "Gather ROTAT_OLD"
3491 call MPI_SENDRECV(mu(1,ivec_displ(isend)+1),1,&
3492 MPI_PRECOMP11(lensend),inext,5500+isend,&
3493 mu(1,ivec_displ(irecv)+1),1,MPI_PRECOMP11(lenrecv),&
3494 iprev,5500+irecv,FG_COMM,status,IERR)
3495 ! write (iout,*) "Gather PRECOMP11"
3497 call MPI_SENDRECV(Eug(1,1,ivec_displ(isend)+1),1,&
3498 MPI_PRECOMP12(lensend),inext,6600+isend,&
3499 Eug(1,1,ivec_displ(irecv)+1),1,MPI_PRECOMP12(lenrecv),&
3500 iprev,6600+irecv,FG_COMM,status,IERR)
3501 ! write (iout,*) "Gather PRECOMP12"
3503 if (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) &
3505 call MPI_SENDRECV(ug2db1t(1,ivec_displ(isend)+1),1,&
3506 MPI_ROTAT2(lensend),inext,7700+isend,&
3507 ug2db1t(1,ivec_displ(irecv)+1),1,MPI_ROTAT2(lenrecv),&
3508 iprev,7700+irecv,FG_COMM,status,IERR)
3509 ! write (iout,*) "Gather PRECOMP21"
3511 call MPI_SENDRECV(EUgC(1,1,ivec_displ(isend)+1),1,&
3512 MPI_PRECOMP22(lensend),inext,8800+isend,&
3513 EUgC(1,1,ivec_displ(irecv)+1),1,MPI_PRECOMP22(lenrecv),&
3514 iprev,8800+irecv,FG_COMM,status,IERR)
3515 ! write (iout,*) "Gather PRECOMP22"
3517 call MPI_SENDRECV(Ug2DtEUgder(1,1,1,ivec_displ(isend)+1),1,&
3518 MPI_PRECOMP23(lensend),inext,9900+isend,&
3519 Ug2DtEUgder(1,1,1,ivec_displ(irecv)+1),1,&
3520 MPI_PRECOMP23(lenrecv),&
3521 iprev,9900+irecv,FG_COMM,status,IERR)
3522 ! write (iout,*) "Gather PRECOMP23"
3527 if (irecv.lt.0) irecv=nfgtasks1-1
3530 time_gather=time_gather+MPI_Wtime()-time00
3533 ! if (fg_rank.eq.0) then
3534 write (iout,*) "Arrays UG and UGDER"
3536 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
3537 ((ug(l,k,i),l=1,2),k=1,2),&
3538 ((ugder(l,k,i),l=1,2),k=1,2)
3540 write (iout,*) "Arrays UG2 and UG2DER"
3542 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
3543 ((ug2(l,k,i),l=1,2),k=1,2),&
3544 ((ug2der(l,k,i),l=1,2),k=1,2)
3546 write (iout,*) "Arrays OBROT OBROT2 OBROTDER and OBROT2DER"
3548 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
3549 (obrot(k,i),k=1,2),(obrot2(k,i),k=1,2),&
3550 (obrot_der(k,i),k=1,2),(obrot2_der(k,i),k=1,2)
3552 write (iout,*) "Arrays COSTAB SINTAB COSTAB2 and SINTAB2"
3554 write (iout,'(i5,4f10.5,5x,4f10.5)') i,&
3555 costab(i),sintab(i),costab2(i),sintab2(i)
3557 write (iout,*) "Array MUDER"
3559 write (iout,'(i5,2f10.5)') i,muder(1,i),muder(2,i)
3565 !d iti = itortyp(itype(i,1))
3568 !d write (iout,'(2f10.5,5x,2f10.5,5x,2f10.5)')
3569 !d & (EE(j,k,iti),k=1,2),(Ug(j,k,i),k=1,2),(EUg(j,k,i),k=1,2)
3573 end subroutine set_matrices
3574 !-----------------------------------------------------------------------------
3575 subroutine eelec(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
3577 ! This subroutine calculates the average interaction energy and its gradient
3578 ! in the virtual-bond vectors between non-adjacent peptide groups, based on
3579 ! the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
3580 ! The potential depends both on the distance of peptide-group centers and on
3581 ! the orientation of the CA-CA virtual bonds.
3584 ! implicit real(kind=8) (a-h,o-z)
3588 ! include 'DIMENSIONS'
3589 ! include 'COMMON.CONTROL'
3590 ! include 'COMMON.SETUP'
3591 ! include 'COMMON.IOUNITS'
3592 ! include 'COMMON.GEO'
3593 ! include 'COMMON.VAR'
3594 ! include 'COMMON.LOCAL'
3595 ! include 'COMMON.CHAIN'
3596 ! include 'COMMON.DERIV'
3597 ! include 'COMMON.INTERACT'
3598 ! include 'COMMON.CONTACTS'
3599 ! include 'COMMON.TORSION'
3600 ! include 'COMMON.VECTORS'
3601 ! include 'COMMON.FFIELD'
3602 ! include 'COMMON.TIME1'
3603 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg
3604 real(kind=8),dimension(3,3) :: erder,uryg,urzg,vryg,vrzg
3605 real(kind=8),dimension(2,2) :: acipa !el,a_temp
3606 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
3607 real(kind=8),dimension(4) :: muij
3608 !el integer :: num_conti,j1,j2
3609 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
3610 !el dz_normi,xmedi,ymedi,zmedi
3612 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
3613 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
3616 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
3618 real(kind=8) :: scal_el=1.0d0
3620 real(kind=8) :: scal_el=0.5d0
3623 ! 13-go grudnia roku pamietnego...
3624 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
3626 0.0d0,0.0d0,1.0d0/),shape(unmat))
3628 integer :: i,k,j,icont
3629 real(kind=8) :: ees,evdw1,eel_loc,eello_turn3,eello_turn4
3630 real(kind=8) :: fac,t_eelecij,fracinbuf
3633 !d write(iout,*) 'In EELEC'
3634 ! print *,"IN EELEC"
3636 !d write(iout,*) 'Type',i
3637 !d write(iout,*) 'B1',B1(:,i)
3638 !d write(iout,*) 'B2',B2(:,i)
3639 !d write(iout,*) 'CC',CC(:,:,i)
3640 !d write(iout,*) 'DD',DD(:,:,i)
3641 !d write(iout,*) 'EE',EE(:,:,i)
3643 !d call check_vecgrad
3656 if (nres_molec(1).eq.0) return
3659 if (icheckgrad.eq.1) then
3662 ! dc_norm(1,i)=0.0d0
3663 ! dc_norm(2,i)=0.0d0
3664 ! dc_norm(3,i)=0.0d0
3667 fac=1.0d0/dsqrt(scalar(dc(1,i),dc(1,i)))
3669 dc_norm(k,i)=dc(k,i)*fac
3671 ! write (iout,*) 'i',i,' fac',fac
3674 ! print *,wel_loc,"wel_loc",wcorr4,wcorr5,wcorr6,wturn3,wturn4, &
3676 if (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
3677 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 .or. &
3678 wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) then
3679 ! call vec_and_deriv
3683 ! print *, "before set matrices"
3685 ! print *, "after set matrices"
3688 time_mat=time_mat+MPI_Wtime()-time01
3691 ! print *, "after set matrices"
3693 !d write (iout,*) 'i=',i
3695 !d write (iout,'(i5,2f10.5)') k,uy(k,i),uz(k,i)
3698 !d write (iout,'(f10.5,2x,3f10.5,2x,3f10.5)')
3699 !d & uz(k,i),(uzgrad(k,l,1,i),l=1,3),(uzgrad(k,l,2,i),l=1,3)
3712 !d print '(a)','Enter EELEC'
3713 !d write (iout,*) 'iatel_s=',iatel_s,' iatel_e=',iatel_e
3714 ! if (.not.allocated(gel_loc_loc)) allocate(gel_loc_loc(nres)) !(maxvar)(maxvar=6*maxres)
3715 ! if (.not.allocated(gcorr_loc)) allocate(gcorr_loc(nres)) !(maxvar)(maxvar=6*maxres)
3717 gel_loc_loc(i)=0.0d0
3722 ! 9/27/08 AL Split the interaction loop to ensure load balancing of turn terms
3724 ! Loop over i,i+2 and i,i+3 pairs of the peptide groups
3728 ! print *,"before iturn3 loop"
3729 do i=iturn3_start,iturn3_end
3730 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1 &
3731 .or. itype(i+2,1).eq.ntyp1 .or. itype(i+3,1).eq.ntyp1) cycle
3735 dx_normi=dc_norm(1,i)
3736 dy_normi=dc_norm(2,i)
3737 dz_normi=dc_norm(3,i)
3738 xmedi=c(1,i)+0.5d0*dxi
3739 ymedi=c(2,i)+0.5d0*dyi
3740 zmedi=c(3,i)+0.5d0*dzi
3741 call to_box(xmedi,ymedi,zmedi)
3742 call lipid_layer(xmedi,ymedi,zmedi,sslipi,ssgradlipi)
3744 call eelecij(i,i+2,ees,evdw1,eel_loc)
3745 if (wturn3.gt.0.0d0) call eturn3(i,eello_turn3)
3746 num_cont_hb(i)=num_conti
3748 do i=iturn4_start,iturn4_end
3749 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1 &
3750 .or. itype(i+3,1).eq.ntyp1 &
3751 .or. itype(i+4,1).eq.ntyp1) cycle
3752 ! print *,"before2",i,i+3, gshieldc_t4(2,i+3),gshieldc_t4(2,i)
3756 dx_normi=dc_norm(1,i)
3757 dy_normi=dc_norm(2,i)
3758 dz_normi=dc_norm(3,i)
3759 xmedi=c(1,i)+0.5d0*dxi
3760 ymedi=c(2,i)+0.5d0*dyi
3761 zmedi=c(3,i)+0.5d0*dzi
3762 call to_box(xmedi,ymedi,zmedi)
3763 call lipid_layer(xmedi,ymedi,zmedi,sslipi,ssgradlipi)
3764 num_conti=num_cont_hb(i)
3765 call eelecij(i,i+3,ees,evdw1,eel_loc)
3766 if (wturn4.gt.0.0d0 .and. itype(i+2,1).ne.ntyp1) &
3767 call eturn4(i,eello_turn4)
3768 ! print *,"before",i,i+3, gshieldc_t4(2,i+3),gshieldc_t4(2,i)
3769 num_cont_hb(i)=num_conti
3772 ! Loop over all pairs of interacting peptide groups except i,i+2 and i,i+3
3774 ! print *,"iatel_s,iatel_e,",iatel_s,iatel_e
3775 ! do i=iatel_s,iatel_e
3777 do icont=g_listpp_start,g_listpp_end
3778 i=newcontlistppi(icont)
3779 j=newcontlistppj(icont)
3780 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
3784 dx_normi=dc_norm(1,i)
3785 dy_normi=dc_norm(2,i)
3786 dz_normi=dc_norm(3,i)
3787 xmedi=c(1,i)+0.5d0*dxi
3788 ymedi=c(2,i)+0.5d0*dyi
3789 zmedi=c(3,i)+0.5d0*dzi
3790 call to_box(xmedi,ymedi,zmedi)
3791 call lipid_layer(xmedi,ymedi,zmedi,sslipi,ssgradlipi)
3793 ! write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
3794 num_conti=num_cont_hb(i)
3795 ! do j=ielstart(i),ielend(i)
3796 ! write (iout,*) i,j,itype(i,1),itype(j,1)
3797 if (itype(j,1).eq.ntyp1.or. itype(j+1,1).eq.ntyp1) cycle
3798 call eelecij(i,j,ees,evdw1,eel_loc)
3800 num_cont_hb(i)=num_conti
3802 ! write (iout,*) "Number of loop steps in EELEC:",ind
3804 !d write (iout,'(i3,3f10.5,5x,3f10.5)')
3805 !d & i,(gel_loc(k,i),k=1,3),gel_loc_loc(i)
3807 ! 12/7/99 Adam eello_turn3 will be considered as a separate energy term
3808 !cc eel_loc=eel_loc+eello_turn3
3809 !d print *,"Processor",fg_rank," t_eelecij",t_eelecij
3811 end subroutine eelec
3812 !-----------------------------------------------------------------------------
3813 subroutine eelecij(i,j,ees,evdw1,eel_loc)
3816 ! implicit real(kind=8) (a-h,o-z)
3817 ! include 'DIMENSIONS'
3821 ! include 'COMMON.CONTROL'
3822 ! include 'COMMON.IOUNITS'
3823 ! include 'COMMON.GEO'
3824 ! include 'COMMON.VAR'
3825 ! include 'COMMON.LOCAL'
3826 ! include 'COMMON.CHAIN'
3827 ! include 'COMMON.DERIV'
3828 ! include 'COMMON.INTERACT'
3829 ! include 'COMMON.CONTACTS'
3830 ! include 'COMMON.TORSION'
3831 ! include 'COMMON.VECTORS'
3832 ! include 'COMMON.FFIELD'
3833 ! include 'COMMON.TIME1'
3834 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg,xtemp
3835 real(kind=8),dimension(3,3) :: erder,uryg,urzg,vryg,vrzg
3836 real(kind=8),dimension(2,2) :: acipa !el,a_temp
3837 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
3838 real(kind=8),dimension(4) :: muij
3839 real(kind=8) :: geel_loc_ij,geel_loc_ji
3840 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
3841 dist_temp, dist_init,rlocshield,fracinbuf
3842 integer xshift,yshift,zshift,ilist,iresshield
3843 !el integer :: num_conti,j1,j2
3844 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
3845 !el dz_normi,xmedi,ymedi,zmedi
3847 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
3848 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
3851 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
3853 real(kind=8) :: scal_el=1.0d0
3855 real(kind=8) :: scal_el=0.5d0
3858 ! 13-go grudnia roku pamietnego...
3859 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
3861 0.0d0,0.0d0,1.0d0/),shape(unmat))
3862 ! integer :: maxconts=nres/4
3864 integer :: k,i,j,iteli,itelj,kkk,l,kkll,m,isubchap
3865 real(kind=8) :: ael6i,rrmij,rmij,r0ij,fcont,fprimcont,ees0tmp
3866 real(kind=8) :: faclipij2, faclipij
3867 real(kind=8) :: ees,evdw1,eel_loc,aaa,bbb,ael3i
3868 real(kind=8) :: dxj,dyj,dzj,dx_normj,dy_normj,dz_normj,xj,yj,zj,&
3869 rij,r3ij,r6ij,cosa,cosb,cosg,fac,ev1,ev2,fac3,fac4,&
3870 evdwij,el1,el2,eesij,ees0ij,facvdw,facel,fac1,ecosa,&
3871 ecosb,ecosg,ury,urz,vry,vrz,facr,a22der,a23der,a32der,&
3872 a33der,eel_loc_ij,cosa4,wij,cosbg1,cosbg2,ees0pij,&
3873 ees0pij1,ees0mij,ees0mij1,fac3p,ees0mijp,ees0pijp,&
3874 ecosa1,ecosb1,ecosg1,ecosa2,ecosb2,ecosg2,ecosap,ecosbp,&
3875 ecosgp,ecosam,ecosbm,ecosgm,ghalf
3877 ! allocate(a_chuj(2,2,maxconts,nres)) !(2,2,maxconts,maxres)
3878 ! allocate(a_chuj_der(2,2,3,5,maxconts,nres)) !(2,2,3,5,maxconts,maxres)
3880 ! time00=MPI_Wtime()
3881 !d write (iout,*) "eelecij",i,j
3885 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
3886 aaa=app(iteli,itelj)
3887 bbb=bpp(iteli,itelj)
3888 ael6i=ael6(iteli,itelj)
3889 ael3i=ael3(iteli,itelj)
3893 dx_normj=dc_norm(1,j)
3894 dy_normj=dc_norm(2,j)
3895 dz_normj=dc_norm(3,j)
3896 ! xj=c(1,j)+0.5D0*dxj-xmedi
3897 ! yj=c(2,j)+0.5D0*dyj-ymedi
3898 ! zj=c(3,j)+0.5D0*dzj-zmedi
3903 call to_box(xj,yj,zj)
3904 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
3905 faclipij=(sslipi+sslipj)/2.0d0*lipscale+1.0d0
3906 faclipij2=(sslipi+sslipj)/2.0d0*lipscale**2+1.0d0
3907 xj=boxshift(xj-xmedi,boxxsize)
3908 yj=boxshift(yj-ymedi,boxysize)
3909 zj=boxshift(zj-zmedi,boxzsize)
3911 rij=xj*xj+yj*yj+zj*zj
3914 !C print *,xmedi,ymedi,zmedi,xj,yj,zj,boxxsize,rij
3915 sss_ele_cut=sscale_ele(rij)
3916 sss_ele_grad=sscagrad_ele(rij)
3918 ! sss_ele_grad=0.0d0
3919 ! print *,sss_ele_cut,sss_ele_grad,&
3920 ! (rij),r_cut_ele,rlamb_ele
3921 if (sss_ele_cut.le.0.0) go to 128
3926 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
3927 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
3928 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
3929 fac=cosa-3.0D0*cosb*cosg
3931 ! 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
3932 if (j.eq.i+2) ev1=scal_el*ev1
3937 el1=fac3*(4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg))
3940 if (shield_mode.gt.0) then
3941 !C fac_shield(i)=0.4
3942 !C fac_shield(j)=0.6
3943 el1=el1*fac_shield(i)**2*fac_shield(j)**2
3944 el2=el2*fac_shield(i)**2*fac_shield(j)**2
3946 ees=ees+eesij*sss_ele_cut
3947 !C FOR NOW SHIELD IS NOT USED WITH LIPSCALE
3948 !C & *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3954 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)*sss_ele_cut
3955 !C print *,"TUCC",(sslipi+sslipj)/2.0d0*lipscale**2+1.0d0
3958 ! 12/26/95 - for the evaluation of multi-body H-bonding interactions
3959 ees0ij=4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg)
3960 ! ees=ees+eesij*sss_ele_cut
3961 evdw1=evdw1+evdwij*sss_ele_cut &
3962 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3963 !d write(iout,'(2(2i3,2x),7(1pd12.4)/2(3(1pd12.4),5x)/)')
3964 !d & iteli,i,itelj,j,aaa,bbb,ael6i,ael3i,
3965 !d & 1.0D0/dsqrt(rrmij),evdwij,eesij,
3966 !d & xmedi,ymedi,zmedi,xj,yj,zj
3968 if (energy_dec) then
3969 ! write (iout,'(a6,2i5,0pf7.3,2i5,2e11.3)') &
3970 ! 'evdw1',i,j,evdwij,&
3971 ! iteli,itelj,aaa,evdw1
3972 write (iout,'(a6,2i5,0pf7.3)') 'evdw1',i,j,evdwij
3973 write (iout,'(a6,2i5,0pf7.3)') 'ees',i,j,eesij
3976 ! Calculate contributions to the Cartesian gradient.
3979 facvdw=-6*rrmij*(ev1+evdwij)*sss_ele_cut &
3980 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3981 facel=-3*rrmij*(el1+eesij)*sss_ele_cut &
3982 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3988 ! Radial derivatives. First process both termini of the fragment (i,j)
3990 ggg(1)=facel*xj+sss_ele_grad*rmij*eesij*xj* &
3991 ((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3992 ggg(2)=facel*yj+sss_ele_grad*rmij*eesij*yj* &
3993 ((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3994 ggg(3)=facel*zj+sss_ele_grad*rmij*eesij*zj* &
3995 ((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
3997 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
3998 (shield_mode.gt.0)) then
4000 do ilist=1,ishield_list(i)
4001 iresshield=shield_list(ilist,i)
4003 rlocshield=grad_shield_side(k,ilist,i)*eesij/fac_shield(i)&
4005 gshieldx(k,iresshield)=gshieldx(k,iresshield)+ &
4007 +grad_shield_loc(k,ilist,i)*eesij/fac_shield(i)*2.0 &
4009 gshieldc(k,iresshield-1)=gshieldc(k,iresshield-1)+rlocshield
4012 do ilist=1,ishield_list(j)
4013 iresshield=shield_list(ilist,j)
4015 rlocshield=grad_shield_side(k,ilist,j)*eesij/fac_shield(j) &
4017 gshieldx(k,iresshield)=gshieldx(k,iresshield)+ &
4019 +grad_shield_loc(k,ilist,j)*eesij/fac_shield(j)*2.0 &
4021 gshieldc(k,iresshield-1)=gshieldc(k,iresshield-1)+rlocshield
4025 gshieldc(k,i)=gshieldc(k,i)+ &
4026 grad_shield(k,i)*eesij/fac_shield(i)*2.0 &
4029 gshieldc(k,j)=gshieldc(k,j)+ &
4030 grad_shield(k,j)*eesij/fac_shield(j)*2.0 &
4033 gshieldc(k,i-1)=gshieldc(k,i-1)+ &
4034 grad_shield(k,i)*eesij/fac_shield(i)*2.0 &
4037 gshieldc(k,j-1)=gshieldc(k,j-1)+ &
4038 grad_shield(k,j)*eesij/fac_shield(j)*2.0 &
4046 ! ghalf=0.5D0*ggg(k)
4047 ! gelc(k,i)=gelc(k,i)+ghalf
4048 ! gelc(k,j)=gelc(k,j)+ghalf
4050 ! 9/28/08 AL Gradient compotents will be summed only at the end
4052 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
4053 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
4055 gelc_long(3,j)=gelc_long(3,j)+ &
4056 ssgradlipj*eesij/2.0d0*lipscale**2&
4059 gelc_long(3,i)=gelc_long(3,i)+ &
4060 ssgradlipi*eesij/2.0d0*lipscale**2&
4065 ! Loop over residues i+1 thru j-1.
4069 !grad gelc(l,k)=gelc(l,k)+ggg(l)
4072 ggg(1)=facvdw*xj+sss_ele_grad*rmij*evdwij*xj &
4073 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
4074 ggg(2)=facvdw*yj+sss_ele_grad*rmij*evdwij*yj &
4075 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
4076 ggg(3)=facvdw*zj+sss_ele_grad*rmij*evdwij*zj &
4077 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
4080 ! ghalf=0.5D0*ggg(k)
4081 ! gvdwpp(k,i)=gvdwpp(k,i)+ghalf
4082 ! gvdwpp(k,j)=gvdwpp(k,j)+ghalf
4084 ! 9/28/08 AL Gradient compotents will be summed only at the end
4086 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
4087 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
4090 !C Lipidic part for scaling weight
4091 gvdwpp(3,j)=gvdwpp(3,j)+ &
4092 sss_ele_cut*ssgradlipj*evdwij/2.0d0*lipscale**2
4093 gvdwpp(3,i)=gvdwpp(3,i)+ &
4094 sss_ele_cut*ssgradlipi*evdwij/2.0d0*lipscale**2
4095 !! Loop over residues i+1 thru j-1.
4099 !grad gvdwpp(l,k)=gvdwpp(l,k)+ggg(l)
4103 facvdw=(ev1+evdwij)*sss_ele_cut &
4104 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
4106 facel=(el1+eesij)*sss_ele_cut
4108 fac=-3*rrmij*(facvdw+facvdw+facel)
4113 ! Radial derivatives. First process both termini of the fragment (i,j)
4115 ggg(1)=fac*xj+sss_ele_grad*rmij*(eesij+evdwij)*xj
4116 ggg(2)=fac*yj+sss_ele_grad*rmij*(eesij+evdwij)*yj
4117 ggg(3)=fac*zj+sss_ele_grad*rmij*(eesij+evdwij)*zj
4119 ! ghalf=0.5D0*ggg(k)
4120 ! gelc(k,i)=gelc(k,i)+ghalf
4121 ! gelc(k,j)=gelc(k,j)+ghalf
4123 ! 9/28/08 AL Gradient compotents will be summed only at the end
4125 gelc_long(k,j)=gelc(k,j)+ggg(k)
4126 gelc_long(k,i)=gelc(k,i)-ggg(k)
4129 ! Loop over residues i+1 thru j-1.
4133 !grad gelc(l,k)=gelc(l,k)+ggg(l)
4136 ! 9/28/08 AL Gradient compotents will be summed only at the end
4137 ggg(1)=facvdw*xj+sss_ele_grad*rmij*evdwij*xj &
4138 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
4139 ggg(2)=facvdw*yj+sss_ele_grad*rmij*evdwij*yj &
4140 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
4141 ggg(3)=facvdw*zj+sss_ele_grad*rmij*evdwij*zj &
4142 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
4145 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
4146 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
4148 gvdwpp(3,j)=gvdwpp(3,j)+ &
4149 sss_ele_cut*ssgradlipj*evdwij/2.0d0*lipscale**2
4150 gvdwpp(3,i)=gvdwpp(3,i)+ &
4151 sss_ele_cut*ssgradlipi*evdwij/2.0d0*lipscale**2
4157 ecosa=2.0D0*fac3*fac1+fac4
4160 ecosb=(fac3*(fac1*cosg+cosb)+cosg*fac4)
4161 ecosg=(fac3*(fac1*cosb+cosg)+cosb*fac4)
4163 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
4164 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
4166 !d print '(2i3,2(3(1pd14.5),3x))',i,j,(dcosb(k),k=1,3),
4167 !d & (dcosg(k),k=1,3)
4169 ggg(k)=(ecosb*dcosb(k)+ecosg*dcosg(k))*sss_ele_cut &
4170 *fac_shield(i)**2*fac_shield(j)**2 &
4171 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
4175 ! ghalf=0.5D0*ggg(k)
4176 ! gelc(k,i)=gelc(k,i)+ghalf
4177 ! & +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
4178 ! & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
4179 ! gelc(k,j)=gelc(k,j)+ghalf
4180 ! & +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
4181 ! & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
4185 !grad gelc(l,k)=gelc(l,k)+ggg(l)
4189 gelc(k,i)=gelc(k,i) &
4190 +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
4191 + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)&
4193 *fac_shield(i)**2*fac_shield(j)**2 &
4194 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
4196 gelc(k,j)=gelc(k,j) &
4197 +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
4198 + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
4200 *fac_shield(i)**2*fac_shield(j)**2 &
4201 *((sslipi+sslipj)/2.0d0*lipscale**2+1.0d0)
4203 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
4204 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
4207 IF (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
4208 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 &
4209 .or. wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
4211 ! 9/25/99 Mixed third-order local-electrostatic terms. The local-interaction
4212 ! energy of a peptide unit is assumed in the form of a second-order
4213 ! Fourier series in the angles lambda1 and lambda2 (see Nishikawa et al.
4214 ! Macromolecules, 1974, 7, 797-806 for definition). This correlation terms
4215 ! are computed for EVERY pair of non-contiguous peptide groups.
4217 if (j.lt.nres-1) then
4228 muij(kkk)=mu(k,i)*mu(l,j)
4230 gmuij1(kkk)=gtb1(k,i+1)*mu(l,j)
4231 !c write(iout,*) 'k=',k,i,gtb1(k,i+1),gtb1(k,i+1)*mu(l,j)
4232 gmuij2(kkk)=gUb2(k,i)*mu(l,j)
4233 gmuji1(kkk)=mu(k,i)*gtb1(l,j+1)
4234 !c write(iout,*) 'l=',l,j,gtb1(l,j+1),gtb1(l,j+1)*mu(k,i)
4235 gmuji2(kkk)=mu(k,i)*gUb2(l,j)
4240 !d write (iout,*) 'EELEC: i',i,' j',j
4241 !d write (iout,*) 'j',j,' j1',j1,' j2',j2
4242 !d write(iout,*) 'muij',muij
4243 ury=scalar(uy(1,i),erij)
4244 urz=scalar(uz(1,i),erij)
4245 vry=scalar(uy(1,j),erij)
4246 vrz=scalar(uz(1,j),erij)
4247 a22=scalar(uy(1,i),uy(1,j))-3*ury*vry
4248 a23=scalar(uy(1,i),uz(1,j))-3*ury*vrz
4249 a32=scalar(uz(1,i),uy(1,j))-3*urz*vry
4250 a33=scalar(uz(1,i),uz(1,j))-3*urz*vrz
4251 fac=dsqrt(-ael6i)*r3ij
4256 !d write (iout,'(4i5,4f10.5)')
4257 !d & i,itortyp(itype(i,1)),j,itortyp(itype(j,1)),a22,a23,a32,a33
4258 !d write (iout,'(6f10.5)') (muij(k),k=1,4),fac,eel_loc_ij
4259 !d write (iout,'(2(3f10.5,5x)/2(3f10.5,5x))') uy(:,i),uz(:,i),
4260 !d & uy(:,j),uz(:,j)
4261 !d write (iout,'(4f10.5)')
4262 !d & scalar(uy(1,i),uy(1,j)),scalar(uy(1,i),uz(1,j)),
4263 !d & scalar(uz(1,i),uy(1,j)),scalar(uz(1,i),uz(1,j))
4264 !d write (iout,'(4f10.5)') ury,urz,vry,vrz
4265 !d write (iout,'(9f10.5/)')
4266 !d & fac22,a22,fac23,a23,fac32,a32,fac33,a33,eel_loc_ij
4267 ! Derivatives of the elements of A in virtual-bond vectors
4268 call unormderiv(erij(1),unmat(1,1),rmij,erder(1,1))
4270 uryg(k,1)=scalar(erder(1,k),uy(1,i))
4271 uryg(k,2)=scalar(uygrad(1,k,1,i),erij(1))
4272 uryg(k,3)=scalar(uygrad(1,k,2,i),erij(1))
4273 urzg(k,1)=scalar(erder(1,k),uz(1,i))
4274 urzg(k,2)=scalar(uzgrad(1,k,1,i),erij(1))
4275 urzg(k,3)=scalar(uzgrad(1,k,2,i),erij(1))
4276 vryg(k,1)=scalar(erder(1,k),uy(1,j))
4277 vryg(k,2)=scalar(uygrad(1,k,1,j),erij(1))
4278 vryg(k,3)=scalar(uygrad(1,k,2,j),erij(1))
4279 vrzg(k,1)=scalar(erder(1,k),uz(1,j))
4280 vrzg(k,2)=scalar(uzgrad(1,k,1,j),erij(1))
4281 vrzg(k,3)=scalar(uzgrad(1,k,2,j),erij(1))
4283 ! Compute radial contributions to the gradient
4301 ! Add the contributions coming from er
4304 agg(k,1)=agg(k,1)+fac3*(uryg(k,1)*vry+vryg(k,1)*ury)
4305 agg(k,2)=agg(k,2)+fac3*(uryg(k,1)*vrz+vrzg(k,1)*ury)
4306 agg(k,3)=agg(k,3)+fac3*(urzg(k,1)*vry+vryg(k,1)*urz)
4307 agg(k,4)=agg(k,4)+fac3*(urzg(k,1)*vrz+vrzg(k,1)*urz)
4310 ! Derivatives in DC(i)
4311 !grad ghalf1=0.5d0*agg(k,1)
4312 !grad ghalf2=0.5d0*agg(k,2)
4313 !grad ghalf3=0.5d0*agg(k,3)
4314 !grad ghalf4=0.5d0*agg(k,4)
4315 aggi(k,1)=fac*(scalar(uygrad(1,k,1,i),uy(1,j)) &
4316 -3.0d0*uryg(k,2)*vry)!+ghalf1
4317 aggi(k,2)=fac*(scalar(uygrad(1,k,1,i),uz(1,j)) &
4318 -3.0d0*uryg(k,2)*vrz)!+ghalf2
4319 aggi(k,3)=fac*(scalar(uzgrad(1,k,1,i),uy(1,j)) &
4320 -3.0d0*urzg(k,2)*vry)!+ghalf3
4321 aggi(k,4)=fac*(scalar(uzgrad(1,k,1,i),uz(1,j)) &
4322 -3.0d0*urzg(k,2)*vrz)!+ghalf4
4323 ! Derivatives in DC(i+1)
4324 aggi1(k,1)=fac*(scalar(uygrad(1,k,2,i),uy(1,j)) &
4325 -3.0d0*uryg(k,3)*vry)!+agg(k,1)
4326 aggi1(k,2)=fac*(scalar(uygrad(1,k,2,i),uz(1,j)) &
4327 -3.0d0*uryg(k,3)*vrz)!+agg(k,2)
4328 aggi1(k,3)=fac*(scalar(uzgrad(1,k,2,i),uy(1,j)) &
4329 -3.0d0*urzg(k,3)*vry)!+agg(k,3)
4330 aggi1(k,4)=fac*(scalar(uzgrad(1,k,2,i),uz(1,j)) &
4331 -3.0d0*urzg(k,3)*vrz)!+agg(k,4)
4332 ! Derivatives in DC(j)
4333 aggj(k,1)=fac*(scalar(uygrad(1,k,1,j),uy(1,i)) &
4334 -3.0d0*vryg(k,2)*ury)!+ghalf1
4335 aggj(k,2)=fac*(scalar(uzgrad(1,k,1,j),uy(1,i)) &
4336 -3.0d0*vrzg(k,2)*ury)!+ghalf2
4337 aggj(k,3)=fac*(scalar(uygrad(1,k,1,j),uz(1,i)) &
4338 -3.0d0*vryg(k,2)*urz)!+ghalf3
4339 aggj(k,4)=fac*(scalar(uzgrad(1,k,1,j),uz(1,i)) &
4340 -3.0d0*vrzg(k,2)*urz)!+ghalf4
4341 ! Derivatives in DC(j+1) or DC(nres-1)
4342 aggj1(k,1)=fac*(scalar(uygrad(1,k,2,j),uy(1,i)) &
4343 -3.0d0*vryg(k,3)*ury)
4344 aggj1(k,2)=fac*(scalar(uzgrad(1,k,2,j),uy(1,i)) &
4345 -3.0d0*vrzg(k,3)*ury)
4346 aggj1(k,3)=fac*(scalar(uygrad(1,k,2,j),uz(1,i)) &
4347 -3.0d0*vryg(k,3)*urz)
4348 aggj1(k,4)=fac*(scalar(uzgrad(1,k,2,j),uz(1,i)) &
4349 -3.0d0*vrzg(k,3)*urz)
4350 !grad if (j.eq.nres-1 .and. i.lt.j-2) then
4352 !grad aggj1(k,l)=aggj1(k,l)+agg(k,l)
4365 aggi(k,l)=-aggi(k,l)
4366 aggi1(k,l)=-aggi1(k,l)
4367 aggj(k,l)=-aggj(k,l)
4368 aggj1(k,l)=-aggj1(k,l)
4371 if (j.lt.nres-1) then
4377 aggi(k,l)=-aggi(k,l)
4378 aggi1(k,l)=-aggi1(k,l)
4379 aggj(k,l)=-aggj(k,l)
4380 aggj1(k,l)=-aggj1(k,l)
4391 aggi(k,l)=-aggi(k,l)
4392 aggi1(k,l)=-aggi1(k,l)
4393 aggj(k,l)=-aggj(k,l)
4394 aggj1(k,l)=-aggj1(k,l)
4399 IF (wel_loc.gt.0.0d0) THEN
4400 ! Contribution to the local-electrostatic energy coming from the i-j pair
4401 eel_loc_ij=a22*muij(1)+a23*muij(2)+a32*muij(3) &
4403 if (shield_mode.eq.0) then
4407 eel_loc_ij=eel_loc_ij &
4408 *fac_shield(i)*fac_shield(j) &
4409 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4410 !C Now derivative over eel_loc
4411 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
4412 (shield_mode.gt.0)) then
4415 do ilist=1,ishield_list(i)
4416 iresshield=shield_list(ilist,i)
4418 rlocshield=grad_shield_side(k,ilist,i)*eel_loc_ij &
4421 gshieldx_ll(k,iresshield)=gshieldx_ll(k,iresshield)+ &
4423 +grad_shield_loc(k,ilist,i)*eel_loc_ij/fac_shield(i) &
4426 gshieldc_ll(k,iresshield-1)=gshieldc_ll(k,iresshield-1)&
4430 do ilist=1,ishield_list(j)
4431 iresshield=shield_list(ilist,j)
4433 rlocshield=grad_shield_side(k,ilist,j)*eel_loc_ij &
4436 gshieldx_ll(k,iresshield)=gshieldx_ll(k,iresshield)+ &
4438 +grad_shield_loc(k,ilist,j)*eel_loc_ij/fac_shield(j) &
4441 gshieldc_ll(k,iresshield-1)=gshieldc_ll(k,iresshield-1)&
4448 gshieldc_ll(k,i)=gshieldc_ll(k,i)+ &
4449 grad_shield(k,i)*eel_loc_ij/fac_shield(i) &
4451 gshieldc_ll(k,j)=gshieldc_ll(k,j)+ &
4452 grad_shield(k,j)*eel_loc_ij/fac_shield(j) &
4454 gshieldc_ll(k,i-1)=gshieldc_ll(k,i-1)+ &
4455 grad_shield(k,i)*eel_loc_ij/fac_shield(i) &
4457 gshieldc_ll(k,j-1)=gshieldc_ll(k,j-1)+ &
4458 grad_shield(k,j)*eel_loc_ij/fac_shield(j) &
4465 geel_loc_ij=(a22*gmuij1(1)&
4469 *fac_shield(i)*fac_shield(j)&
4471 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4474 !c write(iout,*) "derivative over thatai"
4475 !c write(iout,*) a22*gmuij1(1), a23*gmuij1(2) ,a32*gmuij1(3),
4477 gloc(nphi+i,icg)=gloc(nphi+i,icg)+&
4479 !c write(iout,*) "derivative over thatai-1"
4480 !c write(iout,*) a22*gmuij2(1), a23*gmuij2(2) ,a32*gmuij2(3),
4487 gloc(nphi+i-1,icg)=gloc(nphi+i-1,icg)+&
4488 geel_loc_ij*wel_loc&
4489 *fac_shield(i)*fac_shield(j)&
4491 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4494 !c Derivative over j residue
4495 geel_loc_ji=a22*gmuji1(1)&
4499 !c write(iout,*) "derivative over thataj"
4500 !c write(iout,*) a22*gmuji1(1), a23*gmuji1(2) ,a32*gmuji1(3),
4503 gloc(nphi+j,icg)=gloc(nphi+j,icg)+&
4504 geel_loc_ji*wel_loc&
4505 *fac_shield(i)*fac_shield(j)&
4507 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4515 !c write(iout,*) "derivative over thataj-1"
4516 !c write(iout,*) a22*gmuji2(1), a23*gmuji2(2) ,a32*gmuji2(3),
4518 gloc(nphi+j-1,icg)=gloc(nphi+j-1,icg)+&
4519 geel_loc_ji*wel_loc&
4520 *fac_shield(i)*fac_shield(j)&
4522 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4526 ! write (iout,*) 'i',i,' j',j,' eel_loc_ij',eel_loc_ij
4528 ! if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
4529 ! 'eelloc',i,j,eel_loc_ij
4530 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,8f8.3)') &
4531 'eelloc',i,j,eel_loc_ij,a22,muij(1),a23,muij(2),a32,muij(3),a33,muij(4)
4532 ! print *,"EELLOC",i,gel_loc_loc(i-1)
4534 ! if (energy_dec) write (iout,*) "a22",a22," a23",a23," a32",a32," a33",a33
4535 ! if (energy_dec) write (iout,*) "muij",muij
4536 ! write (iout,*) a22,muij(1),a23,muij(2),a32,muij(3)
4538 eel_loc=eel_loc+eel_loc_ij*sss_ele_cut
4539 ! Partial derivatives in virtual-bond dihedral angles gamma
4541 gel_loc_loc(i-1)=gel_loc_loc(i-1)+ &
4542 (a22*muder(1,i)*mu(1,j)+a23*muder(1,i)*mu(2,j) &
4543 +a32*muder(2,i)*mu(1,j)+a33*muder(2,i)*mu(2,j)) &
4545 *fac_shield(i)*fac_shield(j) &
4546 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4548 gel_loc_loc(j-1)=gel_loc_loc(j-1)+ &
4549 (a22*mu(1,i)*muder(1,j)+a23*mu(1,i)*muder(2,j) &
4550 +a32*mu(2,i)*muder(1,j)+a33*mu(2,i)*muder(2,j)) &
4552 *fac_shield(i)*fac_shield(j) &
4553 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4554 ! Derivatives of eello in DC(i+1) thru DC(j-1) or DC(nres-2)
4556 ! ggg(1)=(agg(1,1)*muij(1)+ &
4557 ! agg(1,2)*muij(2)+agg(1,3)*muij(3)+agg(1,4)*muij(4)) &
4559 ! +eel_loc_ij*sss_ele_grad*rmij*xj
4560 ! ggg(2)=(agg(2,1)*muij(1)+ &
4561 ! agg(2,2)*muij(2)+agg(2,3)*muij(3)+agg(2,4)*muij(4)) &
4563 ! +eel_loc_ij*sss_ele_grad*rmij*yj
4564 ! ggg(3)=(agg(3,1)*muij(1)+ &
4565 ! agg(3,2)*muij(2)+agg(3,3)*muij(3)+agg(3,4)*muij(4)) &
4567 ! +eel_loc_ij*sss_ele_grad*rmij*zj
4573 ggg(l)=(agg(l,1)*muij(1)+ &
4574 agg(l,2)*muij(2)+agg(l,3)*muij(3)+agg(l,4)*muij(4))&
4576 *fac_shield(i)*fac_shield(j) &
4577 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0) &
4578 +eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
4581 gel_loc_long(l,j)=gel_loc_long(l,j)+ggg(l)
4582 gel_loc_long(l,i)=gel_loc_long(l,i)-ggg(l)
4583 !grad ghalf=0.5d0*ggg(l)
4584 !grad gel_loc(l,i)=gel_loc(l,i)+ghalf
4585 !grad gel_loc(l,j)=gel_loc(l,j)+ghalf
4587 gel_loc_long(3,j)=gel_loc_long(3,j)+ &
4588 ssgradlipj*eel_loc_ij/2.0d0*lipscale/ &
4589 ((sslipi+sslipj)/2.0d0*lipscale+1.0d0)*sss_ele_cut
4591 gel_loc_long(3,i)=gel_loc_long(3,i)+ &
4592 ssgradlipi*eel_loc_ij/2.0d0*lipscale/ &
4593 ((sslipi+sslipj)/2.0d0*lipscale+1.0d0)*sss_ele_cut
4597 !grad gel_loc(l,k)=gel_loc(l,k)+ggg(l)
4600 ! Remaining derivatives of eello
4602 gel_loc(l,i)=gel_loc(l,i)+(aggi(l,1)*muij(1)+ &
4603 aggi(l,2)*muij(2)+aggi(l,3)*muij(3)+aggi(l,4)*muij(4))&
4605 *fac_shield(i)*fac_shield(j) &
4606 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4608 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
4609 gel_loc(l,i+1)=gel_loc(l,i+1)+(aggi1(l,1)*muij(1)+ &
4610 aggi1(l,2)*muij(2)+aggi1(l,3)*muij(3) &
4611 +aggi1(l,4)*muij(4))&
4613 *fac_shield(i)*fac_shield(j) &
4614 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4616 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
4617 gel_loc(l,j)=gel_loc(l,j)+(aggj(l,1)*muij(1)+ &
4618 aggj(l,2)*muij(2)+aggj(l,3)*muij(3)+aggj(l,4)*muij(4))&
4620 *fac_shield(i)*fac_shield(j) &
4621 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4623 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
4624 gel_loc(l,j1)=gel_loc(l,j1)+(aggj1(l,1)*muij(1)+ &
4625 aggj1(l,2)*muij(2)+aggj1(l,3)*muij(3) &
4626 +aggj1(l,4)*muij(4))&
4628 *fac_shield(i)*fac_shield(j) &
4629 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4631 !+eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
4634 ! Change 12/26/95 to calculate four-body contributions to H-bonding energy
4635 ! if (j.gt.i+1 .and. num_conti.le.maxconts) then
4636 if (wcorr+wcorr4+wcorr5+wcorr6.gt.0.0d0 &
4637 .and. num_conti.le.maxconts) then
4638 ! write (iout,*) i,j," entered corr"
4640 ! Calculate the contact function. The ith column of the array JCONT will
4641 ! contain the numbers of atoms that make contacts with the atom I (of numbers
4642 ! greater than I). The arrays FACONT and GACONT will contain the values of
4643 ! the contact function and its derivative.
4644 ! r0ij=1.02D0*rpp(iteli,itelj)
4645 ! r0ij=1.11D0*rpp(iteli,itelj)
4646 r0ij=2.20D0*rpp(iteli,itelj)
4647 ! r0ij=1.55D0*rpp(iteli,itelj)
4648 call gcont(rij,r0ij,1.0D0,0.2d0*r0ij,fcont,fprimcont)
4649 !elwrite(iout,*) "num_conti",num_conti, "maxconts",maxconts
4650 if (fcont.gt.0.0D0) then
4651 num_conti=num_conti+1
4652 if (num_conti.gt.maxconts) then
4653 !el write (iout,*) "esrgresgdsrgdfsrgdswrgaresfgaerwgae"
4654 !el write (iout,*) "num_conti",num_conti, "maxconts",maxconts
4655 write (iout,*) 'WARNING - max. # of contacts exceeded;',&
4656 ' will skip next contacts for this conf.', num_conti
4658 jcont_hb(num_conti,i)=j
4659 !d write (iout,*) "i",i," j",j," num_conti",num_conti,
4660 !d & " jcont_hb",jcont_hb(num_conti,i)
4661 IF (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. &
4662 wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
4663 ! 9/30/99 (AL) - store components necessary to evaluate higher-order loc-el
4665 d_cont(num_conti,i)=rij
4666 !d write (2,'(3e15.5)') rij,r0ij+0.2d0*r0ij,rij
4667 ! --- Electrostatic-interaction matrix ---
4668 a_chuj(1,1,num_conti,i)=a22
4669 a_chuj(1,2,num_conti,i)=a23
4670 a_chuj(2,1,num_conti,i)=a32
4671 a_chuj(2,2,num_conti,i)=a33
4672 ! --- Gradient of rij
4674 grij_hb_cont(kkk,num_conti,i)=erij(kkk)
4681 a_chuj_der(k,l,m,1,num_conti,i)=agg(m,kkll)
4682 a_chuj_der(k,l,m,2,num_conti,i)=aggi(m,kkll)
4683 a_chuj_der(k,l,m,3,num_conti,i)=aggi1(m,kkll)
4684 a_chuj_der(k,l,m,4,num_conti,i)=aggj(m,kkll)
4685 a_chuj_der(k,l,m,5,num_conti,i)=aggj1(m,kkll)
4690 IF (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) THEN
4691 ! Calculate contact energies
4693 wij=cosa-3.0D0*cosb*cosg
4696 ! fac3=dsqrt(-ael6i)/r0ij**3
4697 fac3=dsqrt(-ael6i)*r3ij
4698 ! ees0pij=dsqrt(4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1)
4699 ees0tmp=4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1
4700 if (ees0tmp.gt.0) then
4701 ees0pij=dsqrt(ees0tmp)
4705 if (shield_mode.eq.0) then
4709 ees0plist(num_conti,i)=j
4711 ! ees0mij=dsqrt(4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2)
4712 ees0tmp=4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2
4713 if (ees0tmp.gt.0) then
4714 ees0mij=dsqrt(ees0tmp)
4719 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij) &
4721 *fac_shield(i)*fac_shield(j)
4722 ! *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4724 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij) &
4726 *fac_shield(i)*fac_shield(j)
4727 ! *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4729 ! Diagnostics. Comment out or remove after debugging!
4730 ! ees0p(num_conti,i)=0.5D0*fac3*ees0pij
4731 ! ees0m(num_conti,i)=0.5D0*fac3*ees0mij
4732 ! ees0m(num_conti,i)=0.0D0
4734 ! write (iout,*) 'i=',i,' j=',j,' rij=',rij,' r0ij=',r0ij,
4735 ! & ' ees0ij=',ees0p(num_conti,i),ees0m(num_conti,i),' fcont=',fcont
4736 ! Angular derivatives of the contact function
4737 ees0pij1=fac3/ees0pij
4738 ees0mij1=fac3/ees0mij
4739 fac3p=-3.0D0*fac3*rrmij
4740 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
4741 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
4743 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
4744 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
4745 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
4746 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
4747 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
4748 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
4749 ecosap=ecosa1+ecosa2
4750 ecosbp=ecosb1+ecosb2
4751 ecosgp=ecosg1+ecosg2
4752 ecosam=ecosa1-ecosa2
4753 ecosbm=ecosb1-ecosb2
4754 ecosgm=ecosg1-ecosg2
4763 facont_hb(num_conti,i)=fcont
4764 fprimcont=fprimcont/rij
4765 !d facont_hb(num_conti,i)=1.0D0
4766 ! Following line is for diagnostics.
4769 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
4770 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
4773 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
4774 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
4776 gggp(1)=gggp(1)+ees0pijp*xj &
4777 +ees0p(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
4778 gggp(2)=gggp(2)+ees0pijp*yj &
4779 +ees0p(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
4780 gggp(3)=gggp(3)+ees0pijp*zj &
4781 +ees0p(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
4783 gggm(1)=gggm(1)+ees0mijp*xj &
4784 +ees0m(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
4786 gggm(2)=gggm(2)+ees0mijp*yj &
4787 +ees0m(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
4789 gggm(3)=gggm(3)+ees0mijp*zj &
4790 +ees0m(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
4792 ! Derivatives due to the contact function
4793 gacont_hbr(1,num_conti,i)=fprimcont*xj
4794 gacont_hbr(2,num_conti,i)=fprimcont*yj
4795 gacont_hbr(3,num_conti,i)=fprimcont*zj
4798 ! 10/24/08 cgrad and ! comments indicate the parts of the code removed
4799 ! following the change of gradient-summation algorithm.
4801 !grad ghalfp=0.5D0*gggp(k)
4802 !grad ghalfm=0.5D0*gggm(k)
4803 gacontp_hb1(k,num_conti,i)= & !ghalfp+
4804 (ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
4805 + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
4806 *sss_ele_cut*fac_shield(i)*fac_shield(j) ! &
4807 ! *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4810 gacontp_hb2(k,num_conti,i)= & !ghalfp+
4811 (ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
4812 + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
4813 *sss_ele_cut*fac_shield(i)*fac_shield(j)! &
4814 ! *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4817 gacontp_hb3(k,num_conti,i)=gggp(k) &
4818 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4819 ! *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4821 gacontm_hb1(k,num_conti,i)= & !ghalfm+
4822 (ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
4823 + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
4824 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4825 ! *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4827 gacontm_hb2(k,num_conti,i)= & !ghalfm+
4828 (ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
4829 + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1) &
4830 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4831 ! *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4833 gacontm_hb3(k,num_conti,i)=gggm(k) &
4834 *sss_ele_cut*fac_shield(i)*fac_shield(j)
4835 ! *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4838 ! Diagnostics. Comment out or remove after debugging!
4840 !diag gacontp_hb1(k,num_conti,i)=0.0D0
4841 !diag gacontp_hb2(k,num_conti,i)=0.0D0
4842 !diag gacontp_hb3(k,num_conti,i)=0.0D0
4843 !diag gacontm_hb1(k,num_conti,i)=0.0D0
4844 !diag gacontm_hb2(k,num_conti,i)=0.0D0
4845 !diag gacontm_hb3(k,num_conti,i)=0.0D0
4848 endif ! num_conti.le.maxconts
4851 if (wturn3.gt.0.0d0 .or. wturn4.gt.0.0d0) then
4854 ghalf=0.5d0*agg(l,k)
4855 aggi(l,k)=aggi(l,k)+ghalf
4856 aggi1(l,k)=aggi1(l,k)+agg(l,k)
4857 aggj(l,k)=aggj(l,k)+ghalf
4860 if (j.eq.nres-1 .and. i.lt.j-2) then
4863 aggj1(l,k)=aggj1(l,k)+agg(l,k)
4869 ! t_eelecij=t_eelecij+MPI_Wtime()-time00
4871 end subroutine eelecij
4872 !-----------------------------------------------------------------------------
4873 subroutine eturn3(i,eello_turn3)
4874 ! Third- and fourth-order contributions from turns
4877 ! implicit real(kind=8) (a-h,o-z)
4878 ! include 'DIMENSIONS'
4879 ! include 'COMMON.IOUNITS'
4880 ! include 'COMMON.GEO'
4881 ! include 'COMMON.VAR'
4882 ! include 'COMMON.LOCAL'
4883 ! include 'COMMON.CHAIN'
4884 ! include 'COMMON.DERIV'
4885 ! include 'COMMON.INTERACT'
4886 ! include 'COMMON.CONTACTS'
4887 ! include 'COMMON.TORSION'
4888 ! include 'COMMON.VECTORS'
4889 ! include 'COMMON.FFIELD'
4890 ! include 'COMMON.CONTROL'
4891 real(kind=8),dimension(3) :: ggg
4892 real(kind=8),dimension(2,2) :: auxmat,auxmat1,auxmat2,pizda,&
4893 e1t,e2t,e3t,e1tder,e2tder,e3tder,e1a,ae3,ae3e2,gpizda1,&
4894 gpizda2,auxgmat1,auxgmatt1,auxgmat2,auxgmatt2
4896 real(kind=8),dimension(2) :: auxvec,auxvec1
4897 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
4898 real(kind=8),dimension(2,2) :: auxmat3 !el, a_temp
4899 !el integer :: num_conti,j1,j2
4900 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
4901 !el dz_normi,xmedi,ymedi,zmedi
4903 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
4904 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
4907 integer :: i,j,l,k,ilist,iresshield
4908 real(kind=8) :: eello_turn3,zj,fracinbuf,eello_t3, rlocshield,xj,yj
4912 ! write (iout,*) "eturn3",i,j,j1,j2
4913 zj=(c(3,j)+c(3,j+1))/2.0d0
4914 call to_box(xj,yj,zj)
4915 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
4921 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4923 ! Third-order contributions
4930 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
4931 !d call checkint_turn3(i,a_temp,eello_turn3_num)
4932 call matmat2(EUg(1,1,i+1),EUg(1,1,i+2),auxmat(1,1))
4933 call matmat2(gtEUg(1,1,i+1),EUg(1,1,i+2),auxgmat1(1,1))
4934 call matmat2(EUg(1,1,i+1),gtEUg(1,1,i+2),auxgmat2(1,1))
4935 call transpose2(auxmat(1,1),auxmat1(1,1))
4936 call transpose2(auxgmat1(1,1),auxgmatt1(1,1))
4937 call transpose2(auxgmat2(1,1),auxgmatt2(1,1))
4938 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
4939 call matmat2(a_temp(1,1),auxgmatt1(1,1),gpizda1(1,1))
4940 call matmat2(a_temp(1,1),auxgmatt2(1,1),gpizda2(1,1))
4942 if (shield_mode.eq.0) then
4947 eello_turn3=eello_turn3+0.5d0*(pizda(1,1)+pizda(2,2)) &
4948 *fac_shield(i)*fac_shield(j) &
4949 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4951 0.5d0*(pizda(1,1)+pizda(2,2)) &
4952 *fac_shield(i)*fac_shield(j)
4954 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
4955 'eturn3',i,j,0.5d0*(pizda(1,1)+pizda(2,2))
4957 !C Derivatives in theta
4958 gloc(nphi+i,icg)=gloc(nphi+i,icg) &
4959 +0.5d0*(gpizda1(1,1)+gpizda1(2,2))*wturn3&
4960 *fac_shield(i)*fac_shield(j) &
4961 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4963 gloc(nphi+i+1,icg)=gloc(nphi+i+1,icg)&
4964 +0.5d0*(gpizda2(1,1)+gpizda2(2,2))*wturn3&
4965 *fac_shield(i)*fac_shield(j) &
4966 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
4973 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
4974 (shield_mode.gt.0)) then
4977 do ilist=1,ishield_list(i)
4978 iresshield=shield_list(ilist,i)
4980 rlocshield=grad_shield_side(k,ilist,i)*eello_t3/fac_shield(i)
4981 gshieldx_t3(k,iresshield)=gshieldx_t3(k,iresshield)+ &
4983 +grad_shield_loc(k,ilist,i)*eello_t3/fac_shield(i)
4984 gshieldc_t3(k,iresshield-1)=gshieldc_t3(k,iresshield-1) &
4988 do ilist=1,ishield_list(j)
4989 iresshield=shield_list(ilist,j)
4991 rlocshield=grad_shield_side(k,ilist,j)*eello_t3/fac_shield(j)
4992 gshieldx_t3(k,iresshield)=gshieldx_t3(k,iresshield)+ &
4994 +grad_shield_loc(k,ilist,j)*eello_t3/fac_shield(j)
4995 gshieldc_t3(k,iresshield-1)=gshieldc_t3(k,iresshield-1) &
5002 gshieldc_t3(k,i)=gshieldc_t3(k,i)+ &
5003 grad_shield(k,i)*eello_t3/fac_shield(i)
5004 gshieldc_t3(k,j)=gshieldc_t3(k,j)+ &
5005 grad_shield(k,j)*eello_t3/fac_shield(j)
5006 gshieldc_t3(k,i-1)=gshieldc_t3(k,i-1)+ &
5007 grad_shield(k,i)*eello_t3/fac_shield(i)
5008 gshieldc_t3(k,j-1)=gshieldc_t3(k,j-1)+ &
5009 grad_shield(k,j)*eello_t3/fac_shield(j)
5013 !d write (2,*) 'i,',i,' j',j,'eello_turn3',
5014 !d & 0.5d0*(pizda(1,1)+pizda(2,2)),
5015 !d & ' eello_turn3_num',4*eello_turn3_num
5016 ! Derivatives in gamma(i)
5017 call matmat2(EUgder(1,1,i+1),EUg(1,1,i+2),auxmat2(1,1))
5018 call transpose2(auxmat2(1,1),auxmat3(1,1))
5019 call matmat2(a_temp(1,1),auxmat3(1,1),pizda(1,1))
5020 gel_loc_turn3(i)=gel_loc_turn3(i)+0.5d0*(pizda(1,1)+pizda(2,2))&
5021 *fac_shield(i)*fac_shield(j) &
5022 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5023 ! Derivatives in gamma(i+1)
5024 call matmat2(EUg(1,1,i+1),EUgder(1,1,i+2),auxmat2(1,1))
5025 call transpose2(auxmat2(1,1),auxmat3(1,1))
5026 call matmat2(a_temp(1,1),auxmat3(1,1),pizda(1,1))
5027 gel_loc_turn3(i+1)=gel_loc_turn3(i+1) &
5028 +0.5d0*(pizda(1,1)+pizda(2,2)) &
5029 *fac_shield(i)*fac_shield(j) &
5030 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5032 ! Cartesian derivatives
5034 ! ghalf1=0.5d0*agg(l,1)
5035 ! ghalf2=0.5d0*agg(l,2)
5036 ! ghalf3=0.5d0*agg(l,3)
5037 ! ghalf4=0.5d0*agg(l,4)
5038 a_temp(1,1)=aggi(l,1)!+ghalf1
5039 a_temp(1,2)=aggi(l,2)!+ghalf2
5040 a_temp(2,1)=aggi(l,3)!+ghalf3
5041 a_temp(2,2)=aggi(l,4)!+ghalf4
5042 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
5043 gcorr3_turn(l,i)=gcorr3_turn(l,i) &
5044 +0.5d0*(pizda(1,1)+pizda(2,2)) &
5045 *fac_shield(i)*fac_shield(j) &
5046 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5048 a_temp(1,1)=aggi1(l,1)!+agg(l,1)
5049 a_temp(1,2)=aggi1(l,2)!+agg(l,2)
5050 a_temp(2,1)=aggi1(l,3)!+agg(l,3)
5051 a_temp(2,2)=aggi1(l,4)!+agg(l,4)
5052 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
5053 gcorr3_turn(l,i+1)=gcorr3_turn(l,i+1) &
5054 +0.5d0*(pizda(1,1)+pizda(2,2)) &
5055 *fac_shield(i)*fac_shield(j) &
5056 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5058 a_temp(1,1)=aggj(l,1)!+ghalf1
5059 a_temp(1,2)=aggj(l,2)!+ghalf2
5060 a_temp(2,1)=aggj(l,3)!+ghalf3
5061 a_temp(2,2)=aggj(l,4)!+ghalf4
5062 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
5063 gcorr3_turn(l,j)=gcorr3_turn(l,j) &
5064 +0.5d0*(pizda(1,1)+pizda(2,2)) &
5065 *fac_shield(i)*fac_shield(j) &
5066 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5068 a_temp(1,1)=aggj1(l,1)
5069 a_temp(1,2)=aggj1(l,2)
5070 a_temp(2,1)=aggj1(l,3)
5071 a_temp(2,2)=aggj1(l,4)
5072 call matmat2(a_temp(1,1),auxmat1(1,1),pizda(1,1))
5073 gcorr3_turn(l,j1)=gcorr3_turn(l,j1) &
5074 +0.5d0*(pizda(1,1)+pizda(2,2)) &
5075 *fac_shield(i)*fac_shield(j) &
5076 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5078 gshieldc_t3(3,i)=gshieldc_t3(3,i)+ &
5079 ssgradlipi*eello_t3/4.0d0*lipscale
5080 gshieldc_t3(3,j)=gshieldc_t3(3,j)+ &
5081 ssgradlipj*eello_t3/4.0d0*lipscale
5082 gshieldc_t3(3,i-1)=gshieldc_t3(3,i-1)+ &
5083 ssgradlipi*eello_t3/4.0d0*lipscale
5084 gshieldc_t3(3,j-1)=gshieldc_t3(3,j-1)+ &
5085 ssgradlipj*eello_t3/4.0d0*lipscale
5088 end subroutine eturn3
5089 !-----------------------------------------------------------------------------
5090 subroutine eturn4(i,eello_turn4)
5091 ! Third- and fourth-order contributions from turns
5094 ! implicit real(kind=8) (a-h,o-z)
5095 ! include 'DIMENSIONS'
5096 ! include 'COMMON.IOUNITS'
5097 ! include 'COMMON.GEO'
5098 ! include 'COMMON.VAR'
5099 ! include 'COMMON.LOCAL'
5100 ! include 'COMMON.CHAIN'
5101 ! include 'COMMON.DERIV'
5102 ! include 'COMMON.INTERACT'
5103 ! include 'COMMON.CONTACTS'
5104 ! include 'COMMON.TORSION'
5105 ! include 'COMMON.VECTORS'
5106 ! include 'COMMON.FFIELD'
5107 ! include 'COMMON.CONTROL'
5108 real(kind=8),dimension(3) :: ggg
5109 real(kind=8),dimension(2,2) :: auxmat,auxmat1,auxmat2,pizda,&
5110 e1t,e2t,e3t,e1tder,e2tder,e3tder,e1a,ae3,ae3e2,&
5112 gte1a,gtae3,gtae3e2, ae3gte2,&
5113 gtEpizda1,gtEpizda2,gtEpizda3
5115 real(kind=8),dimension(2) :: auxvec,auxvec1,auxgEvec1,auxgEvec2,&
5118 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
5119 real(kind=8),dimension(2,2) :: auxmat3 !el a_temp
5120 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
5121 !el dz_normi,xmedi,ymedi,zmedi
5122 !el integer :: num_conti,j1,j2
5123 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
5124 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
5127 integer :: i,j,iti1,iti2,iti3,l,k,ilist,iresshield
5128 real(kind=8) :: eello_turn4,s1,s2,s3,zj,fracinbuf,eello_t4,&
5129 rlocshield,gs23,gs32,gsE13,gs13,gs21,gsE31,gsEE1,gsEE2,gsEE3,xj,yj
5133 ! if (j.ne.20) return
5134 ! print *,i,j,gshieldc_t4(2,j),gshieldc_t4(2,j+1)
5135 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
5137 ! Fourth-order contributions
5145 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
5146 !d call checkint_turn4(i,a_temp,eello_turn4_num)
5147 ! write (iout,*) "eturn4 i",i," j",j," j1",j1," j2",j2
5148 zj=(c(3,j)+c(3,j+1))/2.0d0
5149 call to_box(xj,yj,zj)
5150 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
5160 ! write(iout,*) "iti1",iti1," iti2",iti2," iti3",iti3
5161 call transpose2(EUg(1,1,i+1),e1t(1,1))
5162 call transpose2(Eug(1,1,i+2),e2t(1,1))
5163 call transpose2(Eug(1,1,i+3),e3t(1,1))
5164 !C Ematrix derivative in theta
5165 call transpose2(gtEUg(1,1,i+1),gte1t(1,1))
5166 call transpose2(gtEug(1,1,i+2),gte2t(1,1))
5167 call transpose2(gtEug(1,1,i+3),gte3t(1,1))
5169 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
5170 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
5171 call matmat2(gte1t(1,1),a_temp(1,1),gte1a(1,1))
5172 call matvec2(e1a(1,1),gUb2(1,i+3),auxgvec(1))
5173 !c auxalary matrix of E i+1
5174 call matvec2(gte1a(1,1),Ub2(1,i+3),auxgEvec1(1))
5175 s1=scalar2(b1(1,iti2),auxvec(1))
5176 !c derivative of theta i+2 with constant i+3
5177 gs23=scalar2(gtb1(1,i+2),auxvec(1))
5178 !c derivative of theta i+2 with constant i+2
5179 gs32=scalar2(b1(1,i+2),auxgvec(1))
5180 !c derivative of E matix in theta of i+1
5181 gsE13=scalar2(b1(1,i+2),auxgEvec1(1))
5183 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
5184 call matmat2(a_temp(1,1),gte3t(1,1),gtae3(1,1))
5185 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
5186 !c auxilary matrix auxgvec of Ub2 with constant E matirx
5187 call matvec2(ae3(1,1),gUb2(1,i+2),auxgvec(1))
5188 !c auxilary matrix auxgEvec1 of E matix with Ub2 constant
5189 call matvec2(gtae3(1,1),Ub2(1,i+2),auxgEvec3(1))
5190 s2=scalar2(b1(1,i+1),auxvec(1))
5191 !c derivative of theta i+1 with constant i+3
5192 gs13=scalar2(gtb1(1,i+1),auxvec(1))
5193 !c derivative of theta i+2 with constant i+1
5194 gs21=scalar2(b1(1,i+1),auxgvec(1))
5195 !c derivative of theta i+3 with constant i+1
5196 gsE31=scalar2(b1(1,i+1),auxgEvec3(1))
5198 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
5199 call matmat2(gtae3(1,1),e2t(1,1),gtae3e2(1,1))
5200 !c ae3gte2 is derivative over i+2
5201 call matmat2(ae3(1,1),gte2t(1,1),ae3gte2(1,1))
5203 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
5204 call matmat2(ae3e2(1,1),gte1t(1,1),gtEpizda1(1,1))
5206 call matmat2(ae3gte2(1,1),e1t(1,1),gtEpizda2(1,1))
5208 call matmat2(gtae3e2(1,1),e1t(1,1),gtEpizda3(1,1))
5210 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5211 gsEE1=0.5d0*(gtEpizda1(1,1)+gtEpizda1(2,2))
5212 gsEE2=0.5d0*(gtEpizda2(1,1)+gtEpizda2(2,2))
5213 gsEE3=0.5d0*(gtEpizda3(1,1)+gtEpizda3(2,2))
5214 if (shield_mode.eq.0) then
5219 eello_turn4=eello_turn4-(s1+s2+s3) &
5220 *fac_shield(i)*fac_shield(j) &
5221 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5222 eello_t4=-(s1+s2+s3) &
5223 *fac_shield(i)*fac_shield(j)
5224 !C Now derivative over shield:
5225 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
5226 (shield_mode.gt.0)) then
5229 do ilist=1,ishield_list(i)
5230 iresshield=shield_list(ilist,i)
5232 rlocshield=grad_shield_side(k,ilist,i)*eello_t4/fac_shield(i)
5233 ! print *,"rlocshield",rlocshield,grad_shield_side(k,ilist,i),iresshield
5234 gshieldx_t4(k,iresshield)=gshieldx_t4(k,iresshield)+ &
5236 +grad_shield_loc(k,ilist,i)*eello_t4/fac_shield(i)
5237 gshieldc_t4(k,iresshield-1)=gshieldc_t4(k,iresshield-1) &
5241 do ilist=1,ishield_list(j)
5242 iresshield=shield_list(ilist,j)
5244 ! print *,"rlocshieldj",j,rlocshield,grad_shield_side(k,ilist,j),iresshield
5245 rlocshield=grad_shield_side(k,ilist,j)*eello_t4/fac_shield(j)
5246 gshieldx_t4(k,iresshield)=gshieldx_t4(k,iresshield)+ &
5248 +grad_shield_loc(k,ilist,j)*eello_t4/fac_shield(j)
5249 gshieldc_t4(k,iresshield-1)=gshieldc_t4(k,iresshield-1) &
5251 ! print *,"after", gshieldc_t4(k,iresshield-1),iresshield-1,gshieldc_t4(k,iresshield)
5256 gshieldc_t4(k,i)=gshieldc_t4(k,i)+ &
5257 grad_shield(k,i)*eello_t4/fac_shield(i)
5258 gshieldc_t4(k,j)=gshieldc_t4(k,j)+ &
5259 grad_shield(k,j)*eello_t4/fac_shield(j)
5260 gshieldc_t4(k,i-1)=gshieldc_t4(k,i-1)+ &
5261 grad_shield(k,i)*eello_t4/fac_shield(i)
5262 gshieldc_t4(k,j-1)=gshieldc_t4(k,j-1)+ &
5263 grad_shield(k,j)*eello_t4/fac_shield(j)
5264 ! print *,"gshieldc_t4(k,j+1)",j,gshieldc_t4(k,j+1)
5268 gloc(nphi+i,icg)=gloc(nphi+i,icg)&
5269 -(gs13+gsE13+gsEE1)*wturn4&
5270 *fac_shield(i)*fac_shield(j) &
5271 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5273 gloc(nphi+i+1,icg)= gloc(nphi+i+1,icg)&
5274 -(gs23+gs21+gsEE2)*wturn4&
5275 *fac_shield(i)*fac_shield(j)&
5276 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5278 gloc(nphi+i+2,icg)= gloc(nphi+i+2,icg)&
5279 -(gs32+gsE31+gsEE3)*wturn4&
5280 *fac_shield(i)*fac_shield(j)&
5281 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5284 !c gloc(nphi+i+1,icg)=gloc(nphi+i+1,icg)-
5287 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
5288 'eturn4',i,j,-(s1+s2+s3)
5289 !d write (2,*) 'i,',i,' j',j,'eello_turn4',-(s1+s2+s3),
5290 !d & ' eello_turn4_num',8*eello_turn4_num
5291 ! Derivatives in gamma(i)
5292 call transpose2(EUgder(1,1,i+1),e1tder(1,1))
5293 call matmat2(e1tder(1,1),a_temp(1,1),auxmat(1,1))
5294 call matvec2(auxmat(1,1),Ub2(1,i+3),auxvec(1))
5295 s1=scalar2(b1(1,i+1),auxvec(1))
5296 call matmat2(ae3e2(1,1),e1tder(1,1),pizda(1,1))
5297 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5298 gel_loc_turn4(i)=gel_loc_turn4(i)-(s1+s3) &
5299 *fac_shield(i)*fac_shield(j) &
5300 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5302 ! Derivatives in gamma(i+1)
5303 call transpose2(EUgder(1,1,i+2),e2tder(1,1))
5304 call matvec2(ae3(1,1),Ub2der(1,i+2),auxvec(1))
5305 s2=scalar2(b1(1,iti1),auxvec(1))
5306 call matmat2(ae3(1,1),e2tder(1,1),auxmat(1,1))
5307 call matmat2(auxmat(1,1),e1t(1,1),pizda(1,1))
5308 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5309 gel_loc_turn4(i+1)=gel_loc_turn4(i+1)-(s2+s3) &
5310 *fac_shield(i)*fac_shield(j) &
5311 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5313 ! Derivatives in gamma(i+2)
5314 call transpose2(EUgder(1,1,i+3),e3tder(1,1))
5315 call matvec2(e1a(1,1),Ub2der(1,i+3),auxvec(1))
5316 s1=scalar2(b1(1,iti2),auxvec(1))
5317 call matmat2(a_temp(1,1),e3tder(1,1),auxmat(1,1))
5318 call matvec2(auxmat(1,1),Ub2(1,i+2),auxvec(1))
5319 s2=scalar2(b1(1,iti1),auxvec(1))
5320 call matmat2(auxmat(1,1),e2t(1,1),auxmat3(1,1))
5321 call matmat2(auxmat3(1,1),e1t(1,1),pizda(1,1))
5322 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5323 gel_loc_turn4(i+2)=gel_loc_turn4(i+2)-(s1+s2+s3) &
5324 *fac_shield(i)*fac_shield(j) &
5325 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5327 ! Cartesian derivatives
5328 ! Derivatives of this turn contributions in DC(i+2)
5329 if (j.lt.nres-1) then
5331 a_temp(1,1)=agg(l,1)
5332 a_temp(1,2)=agg(l,2)
5333 a_temp(2,1)=agg(l,3)
5334 a_temp(2,2)=agg(l,4)
5335 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
5336 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
5337 s1=scalar2(b1(1,iti2),auxvec(1))
5338 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
5339 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
5340 s2=scalar2(b1(1,iti1),auxvec(1))
5341 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
5342 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
5343 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5345 gcorr4_turn(l,i+2)=gcorr4_turn(l,i+2)-(s1+s2+s3)&
5346 *fac_shield(i)*fac_shield(j) &
5347 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5351 ! Remaining derivatives of this turn contribution
5353 a_temp(1,1)=aggi(l,1)
5354 a_temp(1,2)=aggi(l,2)
5355 a_temp(2,1)=aggi(l,3)
5356 a_temp(2,2)=aggi(l,4)
5357 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
5358 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
5359 s1=scalar2(b1(1,iti2),auxvec(1))
5360 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
5361 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
5362 s2=scalar2(b1(1,iti1),auxvec(1))
5363 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
5364 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
5365 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5366 gcorr4_turn(l,i)=gcorr4_turn(l,i)-(s1+s2+s3) &
5367 *fac_shield(i)*fac_shield(j) &
5368 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5371 a_temp(1,1)=aggi1(l,1)
5372 a_temp(1,2)=aggi1(l,2)
5373 a_temp(2,1)=aggi1(l,3)
5374 a_temp(2,2)=aggi1(l,4)
5375 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
5376 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
5377 s1=scalar2(b1(1,iti2),auxvec(1))
5378 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
5379 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
5380 s2=scalar2(b1(1,iti1),auxvec(1))
5381 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
5382 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
5383 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5384 gcorr4_turn(l,i+1)=gcorr4_turn(l,i+1)-(s1+s2+s3) &
5385 *fac_shield(i)*fac_shield(j) &
5386 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5389 a_temp(1,1)=aggj(l,1)
5390 a_temp(1,2)=aggj(l,2)
5391 a_temp(2,1)=aggj(l,3)
5392 a_temp(2,2)=aggj(l,4)
5393 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
5394 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
5395 s1=scalar2(b1(1,iti2),auxvec(1))
5396 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
5397 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
5398 s2=scalar2(b1(1,iti1),auxvec(1))
5399 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
5400 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
5401 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5402 ! if (j.lt.nres-1) then
5403 gcorr4_turn(l,j)=gcorr4_turn(l,j)-(s1+s2+s3) &
5404 *fac_shield(i)*fac_shield(j) &
5405 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5408 a_temp(1,1)=aggj1(l,1)
5409 a_temp(1,2)=aggj1(l,2)
5410 a_temp(2,1)=aggj1(l,3)
5411 a_temp(2,2)=aggj1(l,4)
5412 call matmat2(e1t(1,1),a_temp(1,1),e1a(1,1))
5413 call matvec2(e1a(1,1),Ub2(1,i+3),auxvec(1))
5414 s1=scalar2(b1(1,iti2),auxvec(1))
5415 call matmat2(a_temp(1,1),e3t(1,1),ae3(1,1))
5416 call matvec2(ae3(1,1),Ub2(1,i+2),auxvec(1))
5417 s2=scalar2(b1(1,iti1),auxvec(1))
5418 call matmat2(ae3(1,1),e2t(1,1),ae3e2(1,1))
5419 call matmat2(ae3e2(1,1),e1t(1,1),pizda(1,1))
5420 s3=0.5d0*(pizda(1,1)+pizda(2,2))
5421 ! write (iout,*) "s1",s1," s2",s2," s3",s3," s1+s2+s3",s1+s2+s3
5422 ! if (j.lt.nres-1) then
5423 ! print *,"juest before",j1, gcorr4_turn(l,j1)
5424 gcorr4_turn(l,j1)=gcorr4_turn(l,j1)-(s1+s2+s3) &
5425 *fac_shield(i)*fac_shield(j) &
5426 *((sslipi+sslipj)/2.0d0*lipscale+1.0d0)
5427 ! if (shield_mode.gt.0) then
5428 ! print *,"juest after",j1, gcorr4_turn(l,j1),gshieldc_t4(k,j1),gshieldc_loc_t4(k,j1),gel_loc_turn4(i+2)
5430 ! print *,"juest after",j1, gcorr4_turn(l,j1),gel_loc_turn4(i+2)
5434 gshieldc_t4(3,i)=gshieldc_t4(3,i)+ &
5435 ssgradlipi*eello_t4/4.0d0*lipscale
5436 gshieldc_t4(3,j)=gshieldc_t4(3,j)+ &
5437 ssgradlipj*eello_t4/4.0d0*lipscale
5438 gshieldc_t4(3,i-1)=gshieldc_t4(3,i-1)+ &
5439 ssgradlipi*eello_t4/4.0d0*lipscale
5440 gshieldc_t4(3,j-1)=gshieldc_t4(3,j-1)+ &
5441 ssgradlipj*eello_t4/4.0d0*lipscale
5444 end subroutine eturn4
5445 !-----------------------------------------------------------------------------
5446 subroutine unormderiv(u,ugrad,unorm,ungrad)
5447 ! This subroutine computes the derivatives of a normalized vector u, given
5448 ! the derivatives computed without normalization conditions, ugrad. Returns
5451 real(kind=8),dimension(3) :: u,vec
5452 real(kind=8),dimension(3,3) ::ugrad,ungrad
5453 real(kind=8) :: unorm !,scalar
5455 ! write (2,*) 'ugrad',ugrad
5458 vec(i)=scalar(ugrad(1,i),u(1))
5460 ! write (2,*) 'vec',vec
5463 ungrad(j,i)=(ugrad(j,i)-u(j)*vec(i))*unorm
5466 ! write (2,*) 'ungrad',ungrad
5468 end subroutine unormderiv
5469 !-----------------------------------------------------------------------------
5470 subroutine escp_soft_sphere(evdw2,evdw2_14)
5472 ! This subroutine calculates the excluded-volume interaction energy between
5473 ! peptide-group centers and side chains and its gradient in virtual-bond and
5474 ! side-chain vectors.
5476 ! implicit real(kind=8) (a-h,o-z)
5477 ! include 'DIMENSIONS'
5478 ! include 'COMMON.GEO'
5479 ! include 'COMMON.VAR'
5480 ! include 'COMMON.LOCAL'
5481 ! include 'COMMON.CHAIN'
5482 ! include 'COMMON.DERIV'
5483 ! include 'COMMON.INTERACT'
5484 ! include 'COMMON.FFIELD'
5485 ! include 'COMMON.IOUNITS'
5486 ! include 'COMMON.CONTROL'
5487 real(kind=8),dimension(3) :: ggg
5489 integer :: i,iint,j,k,iteli,itypj
5490 real(kind=8) :: evdw2,evdw2_14,r0_scp,xi,yi,zi,xj,yj,zj,&
5491 fac,rij,r0ij,r0ijsq,evdwij,e1,e2
5496 !d print '(a)','Enter ESCP'
5497 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
5498 do i=iatscp_s,iatscp_e
5499 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
5501 xi=0.5D0*(c(1,i)+c(1,i+1))
5502 yi=0.5D0*(c(2,i)+c(2,i+1))
5503 zi=0.5D0*(c(3,i)+c(3,i+1))
5504 call to_box(xi,yi,zi)
5506 do iint=1,nscp_gr(i)
5508 do j=iscpstart(i,iint),iscpend(i,iint)
5509 if (itype(j,1).eq.ntyp1) cycle
5510 itypj=iabs(itype(j,1))
5511 ! Uncomment following three lines for SC-p interactions
5515 ! Uncomment following three lines for Ca-p interactions
5519 call to_box(xj,yj,zj)
5520 xj=boxshift(xj-xi,boxxsize)
5521 yj=boxshift(yj-yi,boxysize)
5522 zj=boxshift(zj-zi,boxzsize)
5523 rij=xj*xj+yj*yj+zj*zj
5526 if (rij.lt.r0ijsq) then
5527 evdwij=0.25d0*(rij-r0ijsq)**2
5535 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
5540 !grad if (j.lt.i) then
5541 !d write (iout,*) 'j<i'
5542 ! Uncomment following three lines for SC-p interactions
5544 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
5547 !d write (iout,*) 'j>i'
5549 !grad ggg(k)=-ggg(k)
5550 ! Uncomment following line for SC-p interactions
5551 ! gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
5555 !grad gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
5557 !grad kstart=min0(i+1,j)
5558 !grad kend=max0(i-1,j-1)
5559 !d write (iout,*) 'i=',i,' j=',j,' kstart=',kstart,' kend=',kend
5560 !d write (iout,*) ggg(1),ggg(2),ggg(3)
5561 !grad do k=kstart,kend
5563 !grad gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
5567 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
5568 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
5575 end subroutine escp_soft_sphere
5576 !-----------------------------------------------------------------------------
5577 subroutine escp(evdw2,evdw2_14)
5579 ! This subroutine calculates the excluded-volume interaction energy between
5580 ! peptide-group centers and side chains and its gradient in virtual-bond and
5581 ! side-chain vectors.
5583 ! implicit real(kind=8) (a-h,o-z)
5584 ! include 'DIMENSIONS'
5585 ! include 'COMMON.GEO'
5586 ! include 'COMMON.VAR'
5587 ! include 'COMMON.LOCAL'
5588 ! include 'COMMON.CHAIN'
5589 ! include 'COMMON.DERIV'
5590 ! include 'COMMON.INTERACT'
5591 ! include 'COMMON.FFIELD'
5592 ! include 'COMMON.IOUNITS'
5593 ! include 'COMMON.CONTROL'
5594 real(kind=8),dimension(3) :: ggg
5596 integer :: i,iint,j,k,iteli,itypj,subchap,iconta
5597 real(kind=8) :: evdw2,evdw2_14,xi,yi,zi,xj,yj,zj,rrij,fac,&
5599 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
5600 dist_temp, dist_init
5601 integer xshift,yshift,zshift
5605 !d print '(a)','Enter ESCP'
5606 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
5607 ! do i=iatscp_s,iatscp_e
5608 if (nres_molec(1).eq.0) return
5609 do iconta=g_listscp_start,g_listscp_end
5610 ! print *,"icont",iconta,g_listscp_start,g_listscp_end
5611 i=newcontlistscpi(iconta)
5612 j=newcontlistscpj(iconta)
5613 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
5615 xi=0.5D0*(c(1,i)+c(1,i+1))
5616 yi=0.5D0*(c(2,i)+c(2,i+1))
5617 zi=0.5D0*(c(3,i)+c(3,i+1))
5618 call to_box(xi,yi,zi)
5619 ! print *,itel(i),i,j
5620 ! do iint=1,nscp_gr(i)
5622 ! do j=iscpstart(i,iint),iscpend(i,iint)
5623 itypj=iabs(itype(j,1))
5624 if (itypj.eq.ntyp1) cycle
5625 ! Uncomment following three lines for SC-p interactions
5629 ! Uncomment following three lines for Ca-p interactions
5637 call to_box(xj,yj,zj)
5638 xj=boxshift(xj-xi,boxxsize)
5639 yj=boxshift(yj-yi,boxysize)
5640 zj=boxshift(zj-zi,boxzsize)
5642 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
5643 rij=dsqrt(1.0d0/rrij)
5644 sss_ele_cut=sscale_ele(rij)
5645 sss_ele_grad=sscagrad_ele(rij)
5646 ! print *,sss_ele_cut,sss_ele_grad,&
5647 ! (rij),r_cut_ele,rlamb_ele
5648 if (sss_ele_cut.le.0.0) cycle
5650 e1=fac*fac*aad(itypj,iteli)
5651 e2=fac*bad(itypj,iteli)
5652 if (iabs(j-i) .le. 2) then
5655 evdw2_14=evdw2_14+(e1+e2)*sss_ele_cut
5658 evdw2=evdw2+evdwij*sss_ele_cut
5659 ! if (energy_dec) write (iout,'(a6,2i5,0pf7.3,2i3,3e11.3)') &
5660 ! 'evdw2',i,j,evdwij,iteli,itypj,fac,aad(itypj,iteli),&
5661 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
5664 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
5666 fac=-(evdwij+e1)*rrij*sss_ele_cut
5667 fac=fac+evdwij*sss_ele_grad/rij/expon
5671 !grad if (j.lt.i) then
5672 !d write (iout,*) 'j<i'
5673 ! Uncomment following three lines for SC-p interactions
5675 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
5678 !d write (iout,*) 'j>i'
5680 !grad ggg(k)=-ggg(k)
5681 ! Uncomment following line for SC-p interactions
5682 !cgrad gradx_scp(k,j)=gradx_scp(k,j)-ggg(k)
5683 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
5687 !grad gvdwc_scp(k,i)=gvdwc_scp(k,i)-0.5D0*ggg(k)
5689 !grad kstart=min0(i+1,j)
5690 !grad kend=max0(i-1,j-1)
5691 !d write (iout,*) 'i=',i,' j=',j,' kstart=',kstart,' kend=',kend
5692 !d write (iout,*) ggg(1),ggg(2),ggg(3)
5693 !grad do k=kstart,kend
5695 !grad gvdwc_scp(l,k)=gvdwc_scp(l,k)-ggg(l)
5699 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
5700 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
5708 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
5709 gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
5710 gradx_scp(j,i)=expon*gradx_scp(j,i)
5713 !******************************************************************************
5717 ! To save time the factor EXPON has been extracted from ALL components
5718 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
5721 !******************************************************************************
5724 !-----------------------------------------------------------------------------
5725 subroutine edis(ehpb)
5727 ! Evaluate bridge-strain energy and its gradient in virtual-bond and SC vectors.
5729 ! implicit real(kind=8) (a-h,o-z)
5730 ! include 'DIMENSIONS'
5731 ! include 'COMMON.SBRIDGE'
5732 ! include 'COMMON.CHAIN'
5733 ! include 'COMMON.DERIV'
5734 ! include 'COMMON.VAR'
5735 ! include 'COMMON.INTERACT'
5736 ! include 'COMMON.IOUNITS'
5737 real(kind=8),dimension(3) :: ggg,vec
5739 integer :: i,j,ii,jj,iii,jjj,k,mnumii,mnumjj
5740 real(kind=8) :: fac,eij,rdis,ehpb,dd,waga,xi,yi,zi,zj,yj,xj
5743 ! write(iout,*)'edis: nhpb=',nhpb!,' fbr=',fbr
5744 ! write(iout,*)'link_start=',link_start,' link_end=',link_end
5745 if (link_end.eq.0) return
5746 do i=link_start,link_end
5747 ! If ihpb(i) and jhpb(i) > NRES, this is a SC-SC distance, otherwise a
5748 ! CA-CA distance used in regularization of structure.
5752 ! iii and jjj point to the residues for which the distance is assigned.
5753 if (ii.gt.nres) then
5761 vec(j)=c(j,jj)-c(j,ii)
5765 if (energy_dec) write(iout,*) i,ii,jj,mnumii,mnumjj,itype(jjj,mnumjj),itype(iii,mnumii)
5766 if ((itype(iii,mnumii).gt.ntyp_molec(mnumii)).or.(itype(jjj,mnumjj).gt.ntyp_molec(mnumjj))) cycle
5768 ! write (iout,*) "i",i," ii",ii," iii",iii," jj",jj," jjj",jjj,
5769 ! & dhpb(i),dhpb1(i),forcon(i)
5770 ! 24/11/03 AL: SS bridges handled separately because of introducing a specific
5771 ! distance and angle dependent SS bond potential.
5772 !mc if (ii.gt.nres .and. itype(iii).eq.1 .and. itype(jjj).eq.1) then
5773 ! 18/07/06 MC: Use the convention that the first nss pairs are SS bonds
5774 if (.not.dyn_ss .and. i.le.nss) then
5775 ! 15/02/13 CC dynamic SSbond - additional check
5776 if (ii.gt.nres .and. iabs(itype(iii,1)).eq.1 .and. &
5777 iabs(itype(jjj,1)).eq.1) then
5778 call ssbond_ene(iii,jjj,eij)
5780 ! write (iout,*) "eij",eij,iii,jjj
5782 else if (ii.gt.nres .and. jj.gt.nres) then
5783 !c Restraints from contact prediction
5785 if (constr_dist.eq.11) then
5786 ehpb=ehpb+fordepth(i)**4.0d0 &
5787 *rlornmr1(dd,dhpb(i),dhpb1(i),forcon(i))
5788 fac=fordepth(i)**4.0d0 &
5789 *rlornmr1prim(dd,dhpb(i),dhpb1(i),forcon(i))/dd
5790 if (energy_dec) write (iout,'(a6,2i5,3f8.3)') "edisl",ii,jj, &
5793 if (dhpb1(i).gt.0.0d0) then
5794 ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5795 fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
5796 !c write (iout,*) "beta nmr",
5797 !c & dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5801 !C Get the force constant corresponding to this distance.
5803 !C Calculate the contribution to energy.
5804 ehpb=ehpb+waga*rdis*rdis
5805 !c write (iout,*) "beta reg",dd,waga*rdis*rdis
5807 !C Evaluate gradient.
5813 ggg(j)=fac*(c(j,jj)-c(j,ii))
5816 ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
5817 ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
5820 ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
5821 ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
5826 if (constr_dist.eq.11) then
5827 ehpb=ehpb+fordepth(i)**4.0d0 &
5828 *rlornmr1(dd,dhpb(i),dhpb1(i),forcon(i))
5829 fac=fordepth(i)**4.0d0 &
5830 *rlornmr1prim(dd,dhpb(i),dhpb1(i),forcon(i))/dd
5831 if (energy_dec) write (iout,'(a6,2i5,3f8.3)') "edisl",ii,jj, &
5834 if (dhpb1(i).gt.0.0d0) then
5835 ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5836 fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
5837 !c write (iout,*) "alph nmr",
5838 !c & dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
5843 call to_box(xi,yi,zi)
5847 call to_box(xj,yj,zj)
5848 xj=boxshift(xj-xi,boxxsize)
5849 yj=boxshift(yj-yi,boxysize)
5850 zj=boxshift(zj-zi,boxzsize)
5854 dd=sqrt(xj*xj+yj*yj+zj*zj)
5856 !C Get the force constant corresponding to this distance.
5858 !C Calculate the contribution to energy.
5859 ehpb=ehpb+waga*rdis*rdis
5860 if (energy_dec) write (iout,'(a6,2i5,5f10.3)') "edis",ii,jj, &
5861 ehpb,dd,dhpb(i),waga,rdis
5863 !c write (iout,*) "alpha reg",dd,waga*rdis*rdis
5865 !C Evaluate gradient.
5874 !cd print '(i3,3(1pe14.5))',i,(ggg(j),j=1,3)
5875 !C If this is a SC-SC distance, we need to calculate the contributions to the
5876 !C Cartesian gradient in the SC vectors (ghpbx).
5879 ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
5880 ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
5883 !cgrad do j=iii,jjj-1
5885 !cgrad ghpbc(k,j)=ghpbc(k,j)+ggg(k)
5889 ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
5890 ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
5894 if (constr_dist.ne.11) ehpb=0.5D0*ehpb
5898 !-----------------------------------------------------------------------------
5899 subroutine ssbond_ene(i,j,eij)
5901 ! Calculate the distance and angle dependent SS-bond potential energy
5902 ! using a free-energy function derived based on RHF/6-31G** ab initio
5903 ! calculations of diethyl disulfide.
5905 ! A. Liwo and U. Kozlowska, 11/24/03
5907 ! implicit real(kind=8) (a-h,o-z)
5908 ! include 'DIMENSIONS'
5909 ! include 'COMMON.SBRIDGE'
5910 ! include 'COMMON.CHAIN'
5911 ! include 'COMMON.DERIV'
5912 ! include 'COMMON.LOCAL'
5913 ! include 'COMMON.INTERACT'
5914 ! include 'COMMON.VAR'
5915 ! include 'COMMON.IOUNITS'
5916 real(kind=8),dimension(3) :: erij,dcosom1,dcosom2,gg
5918 integer :: i,j,itypi,itypj,k
5919 real(kind=8) :: eij,rij,rrij,xi,yi,zi,dxi,dyi,dzi,dsci_inv,&
5920 xj,yj,zj,dxj,dyj,dzj,om1,om2,om12,deltad,dscj_inv,&
5921 deltat1,deltat2,deltat12,ed,pom1,pom2,eom1,eom2,eom12,&
5924 itypi=iabs(itype(i,1))
5928 call to_box(xi,yi,zi)
5930 dxi=dc_norm(1,nres+i)
5931 dyi=dc_norm(2,nres+i)
5932 dzi=dc_norm(3,nres+i)
5933 ! dsci_inv=dsc_inv(itypi)
5934 dsci_inv=vbld_inv(nres+i)
5935 itypj=iabs(itype(j,1))
5936 ! dscj_inv=dsc_inv(itypj)
5937 dscj_inv=vbld_inv(nres+j)
5941 call to_box(xj,yj,zj)
5942 xj=boxshift(xj-xi,boxxsize)
5943 yj=boxshift(yj-yi,boxysize)
5944 zj=boxshift(zj-zi,boxzsize)
5945 dxj=dc_norm(1,nres+j)
5946 dyj=dc_norm(2,nres+j)
5947 dzj=dc_norm(3,nres+j)
5948 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
5953 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
5954 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
5955 om12=dxi*dxj+dyi*dyj+dzi*dzj
5957 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
5958 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
5964 deltat12=om2-om1+2.0d0
5966 eij=akcm*deltad*deltad+akth*(deltat1*deltat1+deltat2*deltat2) &
5967 +akct*deltad*deltat12 &
5968 +v1ss*cosphi+v2ss*cosphi*cosphi+v3ss*cosphi*cosphi*cosphi+ebr
5969 ! write(iout,*) i,j,"rij",rij,"d0cm",d0cm," akcm",akcm," akth",akth, &
5970 ! " akct",akct," deltad",deltad," deltat",deltat1,deltat2, &
5971 ! " deltat12",deltat12," eij",eij
5972 ed=2*akcm*deltad+akct*deltat12
5974 pom2=v1ss+2*v2ss*cosphi+3*v3ss*cosphi*cosphi
5975 eom1=-2*akth*deltat1-pom1-om2*pom2
5976 eom2= 2*akth*deltat2+pom1-om1*pom2
5979 ggk=ed*erij(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
5980 ghpbx(k,i)=ghpbx(k,i)-ggk &
5981 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
5982 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
5983 ghpbx(k,j)=ghpbx(k,j)+ggk &
5984 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
5985 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
5986 ghpbc(k,i)=ghpbc(k,i)-ggk
5987 ghpbc(k,j)=ghpbc(k,j)+ggk
5990 ! Calculate the components of the gradient in DC and X
5994 !grad ghpbc(l,k)=ghpbc(l,k)+gg(l)
5998 end subroutine ssbond_ene
5999 !-----------------------------------------------------------------------------
6000 subroutine ebond(estr)
6002 ! Evaluate the energy of stretching of the CA-CA and CA-SC virtual bonds
6004 ! implicit real(kind=8) (a-h,o-z)
6005 ! include 'DIMENSIONS'
6006 ! include 'COMMON.LOCAL'
6007 ! include 'COMMON.GEO'
6008 ! include 'COMMON.INTERACT'
6009 ! include 'COMMON.DERIV'
6010 ! include 'COMMON.VAR'
6011 ! include 'COMMON.CHAIN'
6012 ! include 'COMMON.IOUNITS'
6013 ! include 'COMMON.NAMES'
6014 ! include 'COMMON.FFIELD'
6015 ! include 'COMMON.CONTROL'
6016 ! include 'COMMON.SETUP'
6017 real(kind=8),dimension(3) :: u,ud
6019 integer :: i,j,iti,nbi,k
6020 real(kind=8) :: estr,estr1,diff,uprod,usum,usumsqder,&
6025 ! if (.not.allocated(gradb)) allocate(gradb(3,nres)) !(3,maxres)
6026 ! if (.not.allocated(gradbx)) allocate(gradbx(3,nres)) !(3,maxres)
6028 do i=ibondp_start,ibondp_end
6030 if (itype(i-1,1).eq.ntyp1 .or. itype(i,1).eq.ntyp1) cycle
6031 diff = vbld(i)-vbldp0
6033 if (itype(i-1,1).eq.ntyp1 .and. itype(i,1).eq.ntyp1) cycle
6034 if (itype(i-1,1).eq.ntyp1 .or. itype(i,1).eq.ntyp1) then
6035 !C estr1=estr1+gnmr1(vbld(i),-1.0d0,distchainmax)
6037 !C gradb(j,i-1)=gnmr1prim(vbld(i),-1.0d0,distchainmax) &
6038 !C *dc(j,i-1)/vbld(i)
6040 !C if (energy_dec) write(iout,*) &
6041 !C "estr1",i,gnmr1(vbld(i),-1.0d0,distchainmax)
6042 diff = vbld(i)-vbldpDUM
6044 diff = vbld(i)-vbldp0
6047 if (energy_dec) write (iout,'(a7,i5,4f7.3)') &
6048 "estr bb",i,vbld(i),vbldp0,diff,AKP*diff*diff
6051 gradb(j,i-1)=AKP*diff*dc(j,i-1)/vbld(i)
6053 ! write (iout,'(i5,3f10.5)') i,(gradb(j,i-1),j=1,3)
6056 estr=0.5d0*AKP*estr+estr1
6057 ! print *,"estr_bb",estr,AKP
6059 ! 09/18/07 AL: multimodal bond potential based on AM1 CA-SC PMF's included
6061 do i=ibond_start,ibond_end
6062 iti=iabs(itype(i,1))
6063 if (iti.eq.0) print *,"WARNING WRONG SETTTING",i
6064 if (iti.ne.10 .and. iti.ne.ntyp1) then
6067 diff=vbld(i+nres)-vbldsc0(1,iti)
6068 if (energy_dec) write (iout,*) &
6069 "estr sc",i,iti,vbld(i+nres),vbldsc0(1,iti),diff,&
6070 AKSC(1,iti),AKSC(1,iti)*diff*diff
6071 estr=estr+0.5d0*AKSC(1,iti)*diff*diff
6072 ! print *,"estr_sc",estr
6074 gradbx(j,i)=AKSC(1,iti)*diff*dc(j,i+nres)/vbld(i+nres)
6078 diff=vbld(i+nres)-vbldsc0(j,iti)
6079 ud(j)=aksc(j,iti)*diff
6080 u(j)=abond0(j,iti)+0.5d0*ud(j)*diff
6094 uprod2=uprod2*u(k)*u(k)
6098 usumsqder=usumsqder+ud(j)*uprod2
6100 estr=estr+uprod/usum
6101 ! print *,"estr_sc",estr,i
6103 if (energy_dec) write (iout,*) &
6104 "estr sc",i,iti,vbld(i+nres),vbldsc0(1,iti),diff,&
6105 AKSC(1,iti),uprod/usum
6107 gradbx(j,i)=usumsqder/(usum*usum)*dc(j,i+nres)/vbld(i+nres)
6113 end subroutine ebond
6115 !-----------------------------------------------------------------------------
6116 subroutine ebend(etheta)
6118 ! Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
6119 ! angles gamma and its derivatives in consecutive thetas and gammas.
6122 ! implicit real(kind=8) (a-h,o-z)
6123 ! include 'DIMENSIONS'
6124 ! include 'COMMON.LOCAL'
6125 ! include 'COMMON.GEO'
6126 ! include 'COMMON.INTERACT'
6127 ! include 'COMMON.DERIV'
6128 ! include 'COMMON.VAR'
6129 ! include 'COMMON.CHAIN'
6130 ! include 'COMMON.IOUNITS'
6131 ! include 'COMMON.NAMES'
6132 ! include 'COMMON.FFIELD'
6133 ! include 'COMMON.CONTROL'
6134 !el real(kind=8) :: term1,term2,termm,diffak,ratak,&
6135 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
6136 !el delthe0,sig0inv,sigtc,sigsqtc,delthec
6138 !el common /calcthet/ term1,term2,termm,diffak,ratak,&
6139 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
6140 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,it
6142 integer :: i,k,ichir1,ichir2,itype1,ichir11,ichir12,itype2,&
6144 real(kind=8) :: etheta,delta,ss,ssd,phii,phii1,thet_pred_mean,&
6145 athetk,bthetk,dthett,dthetg1,dthetg2,f0,fprim0,E_tc0,fprim_tc0,&
6146 f1,fprim1,E_tc1,ethetai,E_theta,E_tc
6147 real(kind=8),dimension(2) :: y,z
6150 ! time11=dexp(-2*time)
6153 ! write (*,'(a,i2)') 'EBEND ICG=',icg
6154 do i=ithet_start,ithet_end
6155 if (itype(i-1,1).eq.ntyp1) cycle
6156 ! Zero the energy function and its derivative at 0 or pi.
6157 call splinthet(theta(i),0.5d0*delta,ss,ssd)
6159 ichir1=isign(1,itype(i-2,1))
6160 ichir2=isign(1,itype(i,1))
6161 if (itype(i-2,1).eq.10) ichir1=isign(1,itype(i-1,1))
6162 if (itype(i,1).eq.10) ichir2=isign(1,itype(i-1,1))
6163 if (itype(i-1,1).eq.10) then
6164 itype1=isign(10,itype(i-2,1))
6165 ichir11=isign(1,itype(i-2,1))
6166 ichir12=isign(1,itype(i-2,1))
6167 itype2=isign(10,itype(i,1))
6168 ichir21=isign(1,itype(i,1))
6169 ichir22=isign(1,itype(i,1))
6172 if (i.gt.3 .and. itype(i-2,1).ne.ntyp1) then
6175 if (phii.ne.phii) phii=150.0
6185 if (i.lt.nres .and. itype(i,1).ne.ntyp1) then
6188 if (phii1.ne.phii1) phii1=150.0
6200 ! Calculate the "mean" value of theta from the part of the distribution
6201 ! dependent on the adjacent virtual-bond-valence angles (gamma1 & gamma2).
6202 ! In following comments this theta will be referred to as t_c.
6203 thet_pred_mean=0.0d0
6205 athetk=athet(k,it,ichir1,ichir2)
6206 bthetk=bthet(k,it,ichir1,ichir2)
6208 athetk=athet(k,itype1,ichir11,ichir12)
6209 bthetk=bthet(k,itype2,ichir21,ichir22)
6211 thet_pred_mean=thet_pred_mean+athetk*y(k)+bthetk*z(k)
6213 dthett=thet_pred_mean*ssd
6214 thet_pred_mean=thet_pred_mean*ss+a0thet(it)
6215 ! Derivatives of the "mean" values in gamma1 and gamma2.
6216 dthetg1=(-athet(1,it,ichir1,ichir2)*y(2) &
6217 +athet(2,it,ichir1,ichir2)*y(1))*ss
6218 dthetg2=(-bthet(1,it,ichir1,ichir2)*z(2) &
6219 +bthet(2,it,ichir1,ichir2)*z(1))*ss
6221 dthetg1=(-athet(1,itype1,ichir11,ichir12)*y(2) &
6222 +athet(2,itype1,ichir11,ichir12)*y(1))*ss
6223 dthetg2=(-bthet(1,itype2,ichir21,ichir22)*z(2) &
6224 +bthet(2,itype2,ichir21,ichir22)*z(1))*ss
6226 if (theta(i).gt.pi-delta) then
6227 call theteng(pi-delta,thet_pred_mean,theta0(it),f0,fprim0,&
6229 call mixder(pi-delta,thet_pred_mean,theta0(it),fprim_tc0)
6230 call theteng(pi,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
6231 call spline1(theta(i),pi-delta,delta,f0,f1,fprim0,ethetai,&
6233 call spline2(theta(i),pi-delta,delta,E_tc0,E_tc1,fprim_tc0,&
6235 else if (theta(i).lt.delta) then
6236 call theteng(delta,thet_pred_mean,theta0(it),f0,fprim0,E_tc0)
6237 call theteng(0.0d0,thet_pred_mean,theta0(it),f1,fprim1,E_tc1)
6238 call spline1(theta(i),delta,-delta,f0,f1,fprim0,ethetai,&
6240 call mixder(delta,thet_pred_mean,theta0(it),fprim_tc0)
6241 call spline2(theta(i),delta,-delta,E_tc0,E_tc1,fprim_tc0,&
6244 call theteng(theta(i),thet_pred_mean,theta0(it),ethetai,&
6247 etheta=etheta+ethetai
6248 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
6250 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*E_tc*dthetg1
6251 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*E_tc*dthetg2
6252 gloc(nphi+i-2,icg)=wang*(E_theta+E_tc*dthett)
6254 ! print *,ithetaconstr_start,ithetaconstr_end,"TU"
6256 ! Ufff.... We've done all this!!!
6258 end subroutine ebend
6259 !-----------------------------------------------------------------------------
6260 subroutine theteng(thetai,thet_pred_mean,theta0i,ethetai,E_theta,E_tc)
6263 ! implicit real(kind=8) (a-h,o-z)
6264 ! include 'DIMENSIONS'
6265 ! include 'COMMON.LOCAL'
6266 ! include 'COMMON.IOUNITS'
6267 !el real(kind=8) :: term1,term2,termm,diffak,ratak,&
6268 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
6269 !el delthe0,sig0inv,sigtc,sigsqtc,delthec
6271 real(kind=8) :: thetai,thet_pred_mean,theta0i,ethetai,E_theta,E_tc
6273 !el common /calcthet/ term1,term2,termm,diffak,ratak,&
6274 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
6275 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,it
6277 real(kind=8) :: sig,fac,escloci0,escloci1,esclocbi0,dersc12,&
6278 esclocbi1,chuju,esclocbi,dersc02,dersc01,ss,ssd
6280 ! Calculate the contributions to both Gaussian lobes.
6281 ! 6/6/97 - Deform the Gaussians using the factor of 1/(1+time)
6282 ! The "polynomial part" of the "standard deviation" of this part of
6286 sig=sig*thet_pred_mean+polthet(j,it)
6288 ! Derivative of the "interior part" of the "standard deviation of the"
6289 ! gamma-dependent Gaussian lobe in t_c.
6290 sigtc=3*polthet(3,it)
6292 sigtc=sigtc*thet_pred_mean+j*polthet(j,it)
6295 ! Set the parameters of both Gaussian lobes of the distribution.
6296 ! "Standard deviation" of the gamma-dependent Gaussian lobe (sigtc)
6297 fac=sig*sig+sigc0(it)
6300 ! Following variable (sigsqtc) is -(1/2)d[sigma(t_c)**(-2))]/dt_c
6301 sigsqtc=-4.0D0*sigcsq*sigtc
6302 ! print *,i,sig,sigtc,sigsqtc
6303 ! Following variable (sigtc) is d[sigma(t_c)]/dt_c
6304 sigtc=-sigtc/(fac*fac)
6305 ! Following variable is sigma(t_c)**(-2)
6306 sigcsq=sigcsq*sigcsq
6308 sig0inv=1.0D0/sig0i**2
6309 delthec=thetai-thet_pred_mean
6310 delthe0=thetai-theta0i
6311 term1=-0.5D0*sigcsq*delthec*delthec
6312 term2=-0.5D0*sig0inv*delthe0*delthe0
6313 ! Following fuzzy logic is to avoid underflows in dexp and subsequent INFs and
6314 ! NaNs in taking the logarithm. We extract the largest exponent which is added
6315 ! to the energy (this being the log of the distribution) at the end of energy
6316 ! term evaluation for this virtual-bond angle.
6317 if (term1.gt.term2) then
6319 term2=dexp(term2-termm)
6323 term1=dexp(term1-termm)
6326 ! The ratio between the gamma-independent and gamma-dependent lobes of
6327 ! the distribution is a Gaussian function of thet_pred_mean too.
6328 diffak=gthet(2,it)-thet_pred_mean
6329 ratak=diffak/gthet(3,it)**2
6330 ak=dexp(gthet(1,it)-0.5D0*diffak*ratak)
6331 ! Let's differentiate it in thet_pred_mean NOW.
6333 ! Now put together the distribution terms to make complete distribution.
6334 termexp=term1+ak*term2
6335 termpre=sigc+ak*sig0i
6336 ! Contribution of the bending energy from this theta is just the -log of
6337 ! the sum of the contributions from the two lobes and the pre-exponential
6338 ! factor. Simple enough, isn't it?
6339 ethetai=(-dlog(termexp)-termm+dlog(termpre))
6340 ! NOW the derivatives!!!
6341 ! 6/6/97 Take into account the deformation.
6342 E_theta=(delthec*sigcsq*term1 &
6343 +ak*delthe0*sig0inv*term2)/termexp
6344 E_tc=((sigtc+aktc*sig0i)/termpre &
6345 -((delthec*sigcsq+delthec*delthec*sigsqtc)*term1+ &
6346 aktc*term2)/termexp)
6348 end subroutine theteng
6350 !-----------------------------------------------------------------------------
6351 subroutine ebend(etheta)
6353 ! Evaluate the virtual-bond-angle energy given the virtual-bond dihedral
6354 ! angles gamma and its derivatives in consecutive thetas and gammas.
6355 ! ab initio-derived potentials from
6356 ! Kozlowska et al., J. Phys.: Condens. Matter 19 (2007) 285203
6358 ! implicit real(kind=8) (a-h,o-z)
6359 ! include 'DIMENSIONS'
6360 ! include 'COMMON.LOCAL'
6361 ! include 'COMMON.GEO'
6362 ! include 'COMMON.INTERACT'
6363 ! include 'COMMON.DERIV'
6364 ! include 'COMMON.VAR'
6365 ! include 'COMMON.CHAIN'
6366 ! include 'COMMON.IOUNITS'
6367 ! include 'COMMON.NAMES'
6368 ! include 'COMMON.FFIELD'
6369 ! include 'COMMON.CONTROL'
6370 real(kind=8),dimension(nntheterm) :: coskt,sinkt !mmaxtheterm
6371 real(kind=8),dimension(nsingle) :: cosph1,sinph1,cosph2,sinph2 !maxsingle
6372 real(kind=8),dimension(ndouble,ndouble) :: cosph1ph2,sinph1ph2 !maxdouble,maxdouble
6373 logical :: lprn=.false., lprn1=.false.
6375 integer :: i,k,iblock,ityp1,ityp2,ityp3,l,m
6376 real(kind=8) :: dethetai,dephii,dephii1,theti2,phii,phii1,ethetai
6377 real(kind=8) :: aux,etheta,ccl,ssl,scl,csl,ethetacnstr
6378 ! local variables for constrains
6379 real(kind=8) :: difi,thetiii
6381 ! write(iout,*) "in ebend",ithet_start,ithet_end
6384 do i=ithet_start,ithet_end
6385 if (itype(i-1,1).eq.ntyp1) cycle
6386 if (itype(i-2,1).eq.ntyp1.or.itype(i,1).eq.ntyp1) cycle
6387 if (iabs(itype(i+1,1)).eq.20) iblock=2
6388 if (iabs(itype(i+1,1)).ne.20) iblock=1
6392 theti2=0.5d0*theta(i)
6393 ityp2=ithetyp((itype(i-1,1)))
6395 coskt(k)=dcos(k*theti2)
6396 sinkt(k)=dsin(k*theti2)
6398 if (i.gt.3 .and. itype(max0(i-3,1),1).ne.ntyp1) then
6401 if (phii.ne.phii) phii=150.0
6405 ityp1=ithetyp((itype(i-2,1)))
6406 ! propagation of chirality for glycine type
6408 cosph1(k)=dcos(k*phii)
6409 sinph1(k)=dsin(k*phii)
6413 ityp1=ithetyp(itype(i-2,1))
6419 if (i.lt.nres .and. itype(i+1,1).ne.ntyp1) then
6422 if (phii1.ne.phii1) phii1=150.0
6427 ityp3=ithetyp((itype(i,1)))
6429 cosph2(k)=dcos(k*phii1)
6430 sinph2(k)=dsin(k*phii1)
6434 ityp3=ithetyp(itype(i,1))
6440 ethetai=aa0thet(ityp1,ityp2,ityp3,iblock)
6443 ccl=cosph1(l)*cosph2(k-l)
6444 ssl=sinph1(l)*sinph2(k-l)
6445 scl=sinph1(l)*cosph2(k-l)
6446 csl=cosph1(l)*sinph2(k-l)
6447 cosph1ph2(l,k)=ccl-ssl
6448 cosph1ph2(k,l)=ccl+ssl
6449 sinph1ph2(l,k)=scl+csl
6450 sinph1ph2(k,l)=scl-csl
6454 write (iout,*) "i",i," ityp1",ityp1," ityp2",ityp2,&
6455 " ityp3",ityp3," theti2",theti2," phii",phii," phii1",phii1
6456 write (iout,*) "coskt and sinkt"
6458 write (iout,*) k,coskt(k),sinkt(k)
6462 ethetai=ethetai+aathet(k,ityp1,ityp2,ityp3,iblock)*sinkt(k)
6463 dethetai=dethetai+0.5d0*k*aathet(k,ityp1,ityp2,ityp3,iblock) &
6466 write (iout,*) "k",k,&
6467 "aathet",aathet(k,ityp1,ityp2,ityp3,iblock),&
6471 write (iout,*) "cosph and sinph"
6473 write (iout,*) k,cosph1(k),sinph1(k),cosph2(k),sinph2(k)
6475 write (iout,*) "cosph1ph2 and sinph2ph2"
6478 write (iout,*) l,k,cosph1ph2(l,k),cosph1ph2(k,l),&
6479 sinph1ph2(l,k),sinph1ph2(k,l)
6482 write(iout,*) "ethetai",ethetai
6486 aux=bbthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph1(k) &
6487 +ccthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph1(k) &
6488 +ddthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph2(k) &
6489 +eethet(k,m,ityp1,ityp2,ityp3,iblock)*sinph2(k)
6490 ethetai=ethetai+sinkt(m)*aux
6491 dethetai=dethetai+0.5d0*m*aux*coskt(m)
6492 dephii=dephii+k*sinkt(m)* &
6493 (ccthet(k,m,ityp1,ityp2,ityp3,iblock)*cosph1(k)- &
6494 bbthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph1(k))
6495 dephii1=dephii1+k*sinkt(m)* &
6496 (eethet(k,m,ityp1,ityp2,ityp3,iblock)*cosph2(k)- &
6497 ddthet(k,m,ityp1,ityp2,ityp3,iblock)*sinph2(k))
6499 write (iout,*) "m",m," k",k," bbthet", &
6500 bbthet(k,m,ityp1,ityp2,ityp3,iblock)," ccthet", &
6501 ccthet(k,m,ityp1,ityp2,ityp3,iblock)," ddthet", &
6502 ddthet(k,m,ityp1,ityp2,ityp3,iblock)," eethet", &
6503 eethet(k,m,ityp1,ityp2,ityp3,iblock)," ethetai",ethetai
6507 write(iout,*) "ethetai",ethetai
6511 aux=ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)+ &
6512 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l)+ &
6513 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)+ &
6514 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)
6515 ethetai=ethetai+sinkt(m)*aux
6516 dethetai=dethetai+0.5d0*m*coskt(m)*aux
6517 dephii=dephii+l*sinkt(m)* &
6518 (-ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)- &
6519 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)+ &
6520 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)+ &
6521 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l))
6522 dephii1=dephii1+(k-l)*sinkt(m)* &
6523 (-ffthet(l,k,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(l,k)+ &
6524 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)*sinph1ph2(k,l)+ &
6525 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(l,k)- &
6526 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock)*cosph1ph2(k,l))
6528 write (iout,*) "m",m," k",k," l",l," ffthet",&
6529 ffthet(l,k,m,ityp1,ityp2,ityp3,iblock),&
6530 ffthet(k,l,m,ityp1,ityp2,ityp3,iblock)," ggthet",&
6531 ggthet(l,k,m,ityp1,ityp2,ityp3,iblock),&
6532 ggthet(k,l,m,ityp1,ityp2,ityp3,iblock),&
6534 write (iout,*) cosph1ph2(l,k)*sinkt(m),&
6535 cosph1ph2(k,l)*sinkt(m),&
6536 sinph1ph2(l,k)*sinkt(m),sinph1ph2(k,l)*sinkt(m)
6544 write (iout,'(i2,3f8.1,9h ethetai ,f10.5)') &
6545 i,theta(i)*rad2deg,phii*rad2deg,&
6546 phii1*rad2deg,ethetai
6548 etheta=etheta+ethetai
6549 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
6551 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang*dephii
6552 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang*dephii1
6553 gloc(nphi+i-2,icg)=wang*dethetai
6555 !-----------thete constrains
6556 ! if (tor_mode.ne.2) then
6559 end subroutine ebend
6562 !-----------------------------------------------------------------------------
6563 subroutine esc(escloc)
6564 ! Calculate the local energy of a side chain and its derivatives in the
6565 ! corresponding virtual-bond valence angles THETA and the spherical angles
6569 ! implicit real(kind=8) (a-h,o-z)
6570 ! include 'DIMENSIONS'
6571 ! include 'COMMON.GEO'
6572 ! include 'COMMON.LOCAL'
6573 ! include 'COMMON.VAR'
6574 ! include 'COMMON.INTERACT'
6575 ! include 'COMMON.DERIV'
6576 ! include 'COMMON.CHAIN'
6577 ! include 'COMMON.IOUNITS'
6578 ! include 'COMMON.NAMES'
6579 ! include 'COMMON.FFIELD'
6580 ! include 'COMMON.CONTROL'
6581 real(kind=8),dimension(3) :: x,dersc,xemp,dersc0,dersc1,&
6582 ddersc0,ddummy,xtemp,temp
6583 !el real(kind=8) :: time11,time12,time112,theti
6584 real(kind=8) :: escloc,delta
6585 !el integer :: it,nlobit
6586 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
6589 real(kind=8) :: escloci0,escloci1,escloci,esclocbi0,&
6590 dersc12,esclocbi1,chuju,esclocbi,dersc02,dersc01,ss,ssd
6593 ! write (iout,'(a)') 'ESC'
6594 do i=loc_start,loc_end
6596 if (it.eq.ntyp1) cycle
6597 if (it.eq.10) goto 1
6598 nlobit=nlob(iabs(it))
6599 ! print *,'i=',i,' it=',it,' nlobit=',nlobit
6600 ! write (iout,*) 'i=',i,' ssa=',ssa,' ssad=',ssad
6601 theti=theta(i+1)-pipol
6606 if (x(2).gt.pi-delta) then
6610 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
6612 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
6613 call spline1(x(2),pi-delta,delta,escloci0,escloci1,dersc0(2),&
6615 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),&
6616 ddersc0(1),dersc(1))
6617 call spline2(x(2),pi-delta,delta,dersc0(3),dersc1(3),&
6618 ddersc0(3),dersc(3))
6620 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
6622 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
6623 call spline1(x(2),pi-delta,delta,esclocbi0,esclocbi1,&
6624 dersc0(2),esclocbi,dersc02)
6625 call spline2(x(2),pi-delta,delta,dersc0(1),dersc1(1),&
6627 call splinthet(x(2),0.5d0*delta,ss,ssd)
6632 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
6634 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
6635 ! write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
6637 escloci=ss*escloci+(1.0d0-ss)*esclocbi
6639 ! write (iout,*) escloci
6640 else if (x(2).lt.delta) then
6644 call enesc(xtemp,escloci0,dersc0,ddersc0,.true.)
6646 call enesc(xtemp,escloci1,dersc1,ddummy,.false.)
6647 call spline1(x(2),delta,-delta,escloci0,escloci1,dersc0(2),&
6649 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),&
6650 ddersc0(1),dersc(1))
6651 call spline2(x(2),delta,-delta,dersc0(3),dersc1(3),&
6652 ddersc0(3),dersc(3))
6654 call enesc_bound(xtemp,esclocbi0,dersc0,dersc12,.true.)
6656 call enesc_bound(xtemp,esclocbi1,dersc1,chuju,.false.)
6657 call spline1(x(2),delta,-delta,esclocbi0,esclocbi1,&
6658 dersc0(2),esclocbi,dersc02)
6659 call spline2(x(2),delta,-delta,dersc0(1),dersc1(1),&
6664 call splinthet(x(2),0.5d0*delta,ss,ssd)
6666 dersc(k)=ss*dersc(k)+(1.0d0-ss)*dersc0(k)
6668 dersc(2)=dersc(2)+ssd*(escloci-esclocbi)
6669 ! write (iout,*) 'i=',i,x(2)*rad2deg,escloci0,escloci,
6671 escloci=ss*escloci+(1.0d0-ss)*esclocbi
6672 ! write (iout,*) escloci
6674 call enesc(x,escloci,dersc,ddummy,.false.)
6677 escloc=escloc+escloci
6678 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
6680 ! write (iout,*) 'i=',i,' escloci=',escloci,' dersc=',dersc
6682 gloc(nphi+i-1,icg)=gloc(nphi+i-1,icg)+ &
6684 gloc(ialph(i,1),icg)=wscloc*dersc(2)
6685 gloc(ialph(i,1)+nside,icg)=wscloc*dersc(3)
6690 !-----------------------------------------------------------------------------
6691 subroutine enesc(x,escloci,dersc,ddersc,mixed)
6694 ! implicit real(kind=8) (a-h,o-z)
6695 ! include 'DIMENSIONS'
6696 ! include 'COMMON.GEO'
6697 ! include 'COMMON.LOCAL'
6698 ! include 'COMMON.IOUNITS'
6699 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
6700 real(kind=8),dimension(3) :: x,z,dersc,ddersc
6701 real(kind=8),dimension(3,nlobit,-1:1) :: Ax !(3,maxlob,-1:1)
6702 real(kind=8),dimension(nlobit,-1:1) :: contr !(maxlob,-1:1)
6703 real(kind=8) :: escloci
6706 integer :: j,iii,l,k !el,it,nlobit
6707 real(kind=8) :: escloc_i,x3,Axk,expfac,emin !el,theti,&
6708 !el time11,time12,time112
6709 ! write (iout,*) 'it=',it,' nlobit=',nlobit
6713 if (mixed) ddersc(j)=0.0d0
6717 ! Because of periodicity of the dependence of the SC energy in omega we have
6718 ! to add up the contributions from x(3)-2*pi, x(3), and x(3+2*pi).
6719 ! To avoid underflows, first compute & store the exponents.
6727 z(k)=x(k)-censc(k,j,it)
6732 Axk=Axk+gaussc(l,k,j,it)*z(l)
6738 expfac=expfac+Ax(k,j,iii)*z(k)
6746 ! As in the case of ebend, we want to avoid underflows in exponentiation and
6747 ! subsequent NaNs and INFs in energy calculation.
6748 ! Find the largest exponent
6752 if (emin.gt.contr(j,iii)) emin=contr(j,iii)
6756 !d print *,'it=',it,' emin=',emin
6758 ! Compute the contribution to SC energy and derivatives
6763 adexp=bsc(j,iabs(it))-0.5D0*contr(j,iii)+emin
6764 if(adexp.ne.adexp) adexp=1.0
6767 expfac=dexp(bsc(j,iabs(it))-0.5D0*contr(j,iii)+emin)
6769 !d print *,'j=',j,' expfac=',expfac
6770 escloc_i=escloc_i+expfac
6772 dersc(k)=dersc(k)+Ax(k,j,iii)*expfac
6776 ddersc(k)=ddersc(k)+(-Ax(2,j,iii)*Ax(k,j,iii) &
6777 +gaussc(k,2,j,it))*expfac
6784 dersc(1)=dersc(1)/cos(theti)**2
6785 ddersc(1)=ddersc(1)/cos(theti)**2
6788 escloci=-(dlog(escloc_i)-emin)
6790 dersc(j)=dersc(j)/escloc_i
6794 ddersc(j)=(ddersc(j)/escloc_i+dersc(2)*dersc(j))
6798 end subroutine enesc
6799 !-----------------------------------------------------------------------------
6800 subroutine enesc_bound(x,escloci,dersc,dersc12,mixed)
6803 ! implicit real(kind=8) (a-h,o-z)
6804 ! include 'DIMENSIONS'
6805 ! include 'COMMON.GEO'
6806 ! include 'COMMON.LOCAL'
6807 ! include 'COMMON.IOUNITS'
6808 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
6809 real(kind=8),dimension(3) :: x,z,dersc
6810 real(kind=8),dimension(3,nlobit) :: Ax !(3,maxlob)
6811 real(kind=8),dimension(nlobit) :: contr !(maxlob)
6812 real(kind=8) :: escloci,dersc12,emin
6815 integer :: j,k,l !el,it,nlobit
6816 real(kind=8) :: escloc_i,Axk,expfac !el,time11,time12,time112,theti
6826 z(k)=x(k)-censc(k,j,it)
6832 Axk=Axk+gaussc(l,k,j,it)*z(l)
6838 expfac=expfac+Ax(k,j)*z(k)
6843 ! As in the case of ebend, we want to avoid underflows in exponentiation and
6844 ! subsequent NaNs and INFs in energy calculation.
6845 ! Find the largest exponent
6848 if (emin.gt.contr(j)) emin=contr(j)
6852 ! Compute the contribution to SC energy and derivatives
6856 expfac=dexp(bsc(j,iabs(it))-0.5D0*contr(j)+emin)
6857 escloc_i=escloc_i+expfac
6859 dersc(k)=dersc(k)+Ax(k,j)*expfac
6861 if (mixed) dersc12=dersc12+(-Ax(2,j)*Ax(1,j) &
6862 +gaussc(1,2,j,it))*expfac
6866 dersc(1)=dersc(1)/cos(theti)**2
6867 dersc12=dersc12/cos(theti)**2
6868 escloci=-(dlog(escloc_i)-emin)
6870 dersc(j)=dersc(j)/escloc_i
6872 if (mixed) dersc12=(dersc12/escloc_i+dersc(2)*dersc(1))
6874 end subroutine enesc_bound
6876 !-----------------------------------------------------------------------------
6877 subroutine esc(escloc)
6878 ! Calculate the local energy of a side chain and its derivatives in the
6879 ! corresponding virtual-bond valence angles THETA and the spherical angles
6880 ! ALPHA and OMEGA derived from AM1 all-atom calculations.
6881 ! added by Urszula Kozlowska. 07/11/2007
6884 ! implicit real(kind=8) (a-h,o-z)
6885 ! include 'DIMENSIONS'
6886 ! include 'COMMON.GEO'
6887 ! include 'COMMON.LOCAL'
6888 ! include 'COMMON.VAR'
6889 ! include 'COMMON.SCROT'
6890 ! include 'COMMON.INTERACT'
6891 ! include 'COMMON.DERIV'
6892 ! include 'COMMON.CHAIN'
6893 ! include 'COMMON.IOUNITS'
6894 ! include 'COMMON.NAMES'
6895 ! include 'COMMON.FFIELD'
6896 ! include 'COMMON.CONTROL'
6897 ! include 'COMMON.VECTORS'
6898 real(kind=8),dimension(3) :: x_prime,y_prime,z_prime
6899 real(kind=8),dimension(65) :: x
6900 real(kind=8) :: sumene,dsc_i,dp2_i,xx,yy,zz,sumene1,sumene2,sumene3,&
6901 sumene4,s1,s1_6,s2,s2_6,de_dxx,de_dyy,de_dzz,de_dt
6902 real(kind=8) :: s1_t,s1_6_t,s2_t,s2_6_t,gradene
6903 real(kind=8),dimension(3) :: dXX_Ci1,dYY_Ci1,dZZ_Ci1,dXX_Ci,dYY_Ci,&
6904 dZZ_Ci,dXX_XYZ,dYY_XYZ,dZZ_XYZ,dt_dCi,dt_dCi1
6906 integer :: i,j,k,iti !el,it,nlobit
6907 real(kind=8) :: cosfac2,sinfac2,cosfac,sinfac,escloc,delta
6908 !el real(kind=8) :: time11,time12,time112,theti
6909 !el common /sccalc/ time11,time12,time112,theti,it,nlobit
6910 real(kind=8) :: dscp1,dscp2,pom_s1,pom_s16,pom_s2,pom_s26,&
6911 pom,pom_dx,pom_dy,pom_dt1,pom_dt2,pom1,pom2,&
6912 sumene1x,sumene2x,sumene3x,sumene4x,&
6913 sumene1y,sumene2y,sumene3y,sumene4y,cossc,cossc1,&
6916 real(kind=8) :: aincr,xxsave,sumenep,de_dxx_num,yysave,&
6917 de_dyy_num,zzsave,de_dzz_num,costsave,sintsave,&
6920 ! if (.not.allocated(gsclocx)) allocate(gsclocx(3,nres)) !(3,maxres)
6924 do i=loc_start,loc_end
6927 ! th_gsclocm1(:,i-1)=0.0d0
6928 if (itype(i,1).eq.ntyp1) cycle
6929 costtab(i+1) =dcos(theta(i+1))
6930 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
6931 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
6932 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
6933 cosfac2=0.5d0/(1.0d0+costtab(i+1))
6934 cosfac=dsqrt(cosfac2)
6935 sinfac2=0.5d0/(1.0d0-costtab(i+1))
6936 sinfac=dsqrt(sinfac2)
6939 if (iti.eq.ntyp1 .or. iti.eq.10) cycle
6940 !c AL 3/30/2022 handle the cases of an isolated-residue chain
6941 if (i.eq.nnt .and. itype(i+1,1).eq.ntyp1) cycle
6942 if (i.eq.nct .and. itype(i-1,1).eq.ntyp1) cycle
6943 ! costtab(i+1) =dcos(theta(i+1))
6944 if (it.eq.10) goto 1
6946 if (i.eq.nct .or. itype(i+1,1).eq.ntyp1) then
6947 !c AL 3/30/2022 handle a sidechain of a loose C-end
6948 cossc1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
6949 sumene=arotam_end(0,1,iti)+&
6950 tschebyshev(1,nterm_scend(1,iti),arotam_end(1,1,iti),cossc1)
6951 escloc=escloc+sumene
6952 gradene=gradtschebyshev(0,nterm_scend(1,iti)-1,&
6953 arotam_end(1,1,iti),cossc1)
6954 gscloc(:,i-1)=gscloc(:,i-1)+&
6955 vbld_inv(i)*(dC_norm(:,i+nres)-dC_norm(:,i-1)&
6957 gsclocx(:,i)=gsclocx(:,i)+vbld_inv(i+nres)*&
6958 (dC_norm(:,i-1)-dC_norm(:,i+nres)*cossc1)*gradene
6960 if (energy_dec) write (2,'(2hC ,a3,i6,2(a,f10.5))')&
6961 restyp(iti,1),i," angle",rad2deg*dacos(cossc1)," escloc",sumene
6963 else if (i.eq.nnt .or. itype(i-1,1).eq.ntyp1) then
6964 !c AL 3/30/2022 handle a sidechain of a loose N-end
6965 cossc=scalar(dc_norm(1,i),dc_norm(1,i+nres))
6966 sumene=arotam_end(0,2,iti)+&
6967 tschebyshev(1,nterm_scend(2,iti),arotam_end(1,2,iti),cossc)
6968 escloc=escloc+sumene
6969 gradene=gradtschebyshev(0,nterm_scend(2,iti)-1,&
6970 arotam_end(1,2,iti),cossc)
6971 gscloc(:,i)=gscloc(:,i)+&
6972 vbld_inv(i+1)*(dC_norm(:,i+nres)-dC_norm(:,i)&
6974 gsclocx(:,i)=gsclocx(:,i)+vbld_inv(i+nres)*&
6975 (dC_norm(:,i)-dC_norm(:,i+nres)*cossc)*gradene
6977 if (energy_dec) write (2,'(2hN ,a3,i6,2(a,f10.5))')
6978 & restyp(iti),i," angle",rad2deg*dacos(cossc)," escloc",sumene
6983 ! Compute the axes of tghe local cartesian coordinates system; store in
6984 ! x_prime, y_prime and z_prime
6991 ! write(2,*) "dc_norm", dc_norm(1,i+nres),dc_norm(2,i+nres),
6992 ! & dc_norm(3,i+nres)
6994 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
6995 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
6998 z_prime(j) = -uz(j,i-1)*dsign(1.0d0,dfloat(itype(i,1)))
7001 ! write (2,*) "x_prime",(x_prime(j),j=1,3)
7002 ! write (2,*) "y_prime",(y_prime(j),j=1,3)
7003 ! write (2,*) "z_prime",(z_prime(j),j=1,3)
7004 ! write (2,*) "xx",scalar(x_prime(1),x_prime(1)),
7005 ! & " xy",scalar(x_prime(1),y_prime(1)),
7006 ! & " xz",scalar(x_prime(1),z_prime(1)),
7007 ! & " yy",scalar(y_prime(1),y_prime(1)),
7008 ! & " yz",scalar(y_prime(1),z_prime(1)),
7009 ! & " zz",scalar(z_prime(1),z_prime(1))
7011 ! Transform the unit vector of the ith side-chain centroid, dC_norm(*,i),
7012 ! to local coordinate system. Store in xx, yy, zz.
7018 xx = xx + x_prime(j)*dc_norm(j,i+nres)
7019 yy = yy + y_prime(j)*dc_norm(j,i+nres)
7020 zz = zz + z_prime(j)*dc_norm(j,i+nres)
7027 ! Compute the energy of the ith side cbain
7029 ! write (2,*) "xx",xx," yy",yy," zz",zz
7032 x(j) = sc_parmin(j,it)
7035 !c diagnostics - remove later
7037 yy1 = dsin(alph(2))*dcos(omeg(2))
7038 zz1 = -dsign(1.0,dfloat(itype(i,1)))*dsin(alph(2))*dsin(omeg(2))
7039 write(2,'(3f8.1,3f9.3,1x,3f9.3)') &
7040 alph(2)*rad2deg,omeg(2)*rad2deg,theta(3)*rad2deg,xx,yy,zz,&
7042 !," --- ", xx_w,yy_w,zz_w
7045 sumene1= x(1)+ x(2)*xx+ x(3)*yy+ x(4)*zz+ x(5)*xx**2 &
7046 + x(6)*yy**2+ x(7)*zz**2+ x(8)*xx*zz+ x(9)*xx*yy &
7048 sumene2= x(11) + x(12)*xx + x(13)*yy + x(14)*zz + x(15)*xx**2 &
7049 + x(16)*yy**2 + x(17)*zz**2 + x(18)*xx*zz + x(19)*xx*yy &
7051 sumene3= x(21) +x(22)*xx +x(23)*yy +x(24)*zz +x(25)*xx**2 &
7052 +x(26)*yy**2 +x(27)*zz**2 +x(28)*xx*zz +x(29)*xx*yy &
7053 +x(30)*yy*zz +x(31)*xx**3 +x(32)*yy**3 +x(33)*zz**3 &
7054 +x(34)*(xx**2)*yy +x(35)*(xx**2)*zz +x(36)*(yy**2)*xx &
7055 +x(37)*(yy**2)*zz +x(38)*(zz**2)*xx +x(39)*(zz**2)*yy &
7057 sumene4= x(41) +x(42)*xx +x(43)*yy +x(44)*zz +x(45)*xx**2 &
7058 +x(46)*yy**2 +x(47)*zz**2 +x(48)*xx*zz +x(49)*xx*yy &
7059 +x(50)*yy*zz +x(51)*xx**3 +x(52)*yy**3 +x(53)*zz**3 &
7060 +x(54)*(xx**2)*yy +x(55)*(xx**2)*zz +x(56)*(yy**2)*xx &
7061 +x(57)*(yy**2)*zz +x(58)*(zz**2)*xx +x(59)*(zz**2)*yy &
7063 dsc_i = 0.743d0+x(61)
7065 dscp1=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
7066 *(xx*cost2tab(i+1)+yy*sint2tab(i+1)))
7067 dscp2=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
7068 *(xx*cost2tab(i+1)-yy*sint2tab(i+1)))
7069 s1=(1+x(63))/(0.1d0 + dscp1)
7070 s1_6=(1+x(64))/(0.1d0 + dscp1**6)
7071 s2=(1+x(65))/(0.1d0 + dscp2)
7072 s2_6=(1+x(65))/(0.1d0 + dscp2**6)
7073 sumene = ( sumene3*sint2tab(i+1) + sumene1)*(s1+s1_6) &
7074 + (sumene4*cost2tab(i+1) +sumene2)*(s2+s2_6)
7075 ! write(2,'(i2," sumene",7f9.3)') i,sumene1,sumene2,sumene3,
7077 ! & dscp1,dscp2,sumene
7078 ! sumene = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
7079 escloc = escloc + sumene
7080 if (energy_dec) write (2,*) "i",i," itype",itype(i,1)," it",it, &
7081 " escloc",sumene,escloc,it,itype(i,1)
7082 ! write (2,*) "i",i," escloc",sumene,escloc,it,itype(i,1)
7087 ! This section to check the numerical derivatives of the energy of ith side
7088 ! chain in xx, yy, zz, and theta. Use the -DDEBUG compiler option or insert
7089 ! #define DEBUG in the code to turn it on.
7091 write (2,*) "sumene =",sumene
7095 write (2,*) xx,yy,zz
7096 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
7097 de_dxx_num=(sumenep-sumene)/aincr
7099 write (2,*) "xx+ sumene from enesc=",sumenep
7102 write (2,*) xx,yy,zz
7103 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
7104 de_dyy_num=(sumenep-sumene)/aincr
7106 write (2,*) "yy+ sumene from enesc=",sumenep
7109 write (2,*) xx,yy,zz
7110 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
7111 de_dzz_num=(sumenep-sumene)/aincr
7113 write (2,*) "zz+ sumene from enesc=",sumenep
7114 costsave=cost2tab(i+1)
7115 sintsave=sint2tab(i+1)
7116 cost2tab(i+1)=dcos(0.5d0*(theta(i+1)+aincr))
7117 sint2tab(i+1)=dsin(0.5d0*(theta(i+1)+aincr))
7118 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
7119 de_dt_num=(sumenep-sumene)/aincr
7120 write (2,*) " t+ sumene from enesc=",sumenep
7121 cost2tab(i+1)=costsave
7122 sint2tab(i+1)=sintsave
7123 ! End of diagnostics section.
7126 ! Compute the gradient of esc
7128 ! zz=zz*dsign(1.0,dfloat(itype(i,1)))
7129 pom_s1=(1.0d0+x(63))/(0.1d0 + dscp1)**2
7130 pom_s16=6*(1.0d0+x(64))/(0.1d0 + dscp1**6)**2
7131 pom_s2=(1.0d0+x(65))/(0.1d0 + dscp2)**2
7132 pom_s26=6*(1.0d0+x(65))/(0.1d0 + dscp2**6)**2
7133 pom_dx=dsc_i*dp2_i*cost2tab(i+1)
7134 pom_dy=dsc_i*dp2_i*sint2tab(i+1)
7135 pom_dt1=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)-yy*cost2tab(i+1))
7136 pom_dt2=-0.5d0*dsc_i*dp2_i*(xx*sint2tab(i+1)+yy*cost2tab(i+1))
7137 pom1=(sumene3*sint2tab(i+1)+sumene1) &
7138 *(pom_s1/dscp1+pom_s16*dscp1**4)
7139 pom2=(sumene4*cost2tab(i+1)+sumene2) &
7140 *(pom_s2/dscp2+pom_s26*dscp2**4)
7141 sumene1x=x(2)+2*x(5)*xx+x(8)*zz+ x(9)*yy
7142 sumene3x=x(22)+2*x(25)*xx+x(28)*zz+x(29)*yy+3*x(31)*xx**2 &
7143 +2*x(34)*xx*yy +2*x(35)*xx*zz +x(36)*(yy**2) +x(38)*(zz**2) &
7145 sumene2x=x(12)+2*x(15)*xx+x(18)*zz+ x(19)*yy
7146 sumene4x=x(42)+2*x(45)*xx +x(48)*zz +x(49)*yy +3*x(51)*xx**2 &
7147 +2*x(54)*xx*yy+2*x(55)*xx*zz+x(56)*(yy**2)+x(58)*(zz**2) &
7149 de_dxx =(sumene1x+sumene3x*sint2tab(i+1))*(s1+s1_6) &
7150 +(sumene2x+sumene4x*cost2tab(i+1))*(s2+s2_6) &
7153 write(2,*), "de_dxx = ", de_dxx,de_dxx_num,itype(i,1)
7156 sumene1y=x(3) + 2*x(6)*yy + x(9)*xx + x(10)*zz
7157 sumene3y=x(23) +2*x(26)*yy +x(29)*xx +x(30)*zz +3*x(32)*yy**2 &
7158 +x(34)*(xx**2) +2*x(36)*yy*xx +2*x(37)*yy*zz +x(39)*(zz**2) &
7160 sumene2y=x(13) + 2*x(16)*yy + x(19)*xx + x(20)*zz
7161 sumene4y=x(43)+2*x(46)*yy+x(49)*xx +x(50)*zz &
7162 +3*x(52)*yy**2+x(54)*xx**2+2*x(56)*yy*xx +2*x(57)*yy*zz &
7163 +x(59)*zz**2 +x(60)*xx*zz
7164 de_dyy =(sumene1y+sumene3y*sint2tab(i+1))*(s1+s1_6) &
7165 +(sumene2y+sumene4y*cost2tab(i+1))*(s2+s2_6) &
7168 write(2,*), "de_dyy = ", de_dyy,de_dyy_num,itype(i,1)
7171 de_dzz =(x(24) +2*x(27)*zz +x(28)*xx +x(30)*yy &
7172 +3*x(33)*zz**2 +x(35)*xx**2 +x(37)*yy**2 +2*x(38)*zz*xx &
7173 +2*x(39)*zz*yy +x(40)*xx*yy)*sint2tab(i+1)*(s1+s1_6) &
7174 +(x(4) + 2*x(7)*zz+ x(8)*xx + x(10)*yy)*(s1+s1_6) &
7175 +(x(44)+2*x(47)*zz +x(48)*xx +x(50)*yy +3*x(53)*zz**2 &
7176 +x(55)*xx**2 +x(57)*(yy**2)+2*x(58)*zz*xx +2*x(59)*zz*yy &
7177 +x(60)*xx*yy)*cost2tab(i+1)*(s2+s2_6) &
7178 + ( x(14) + 2*x(17)*zz+ x(18)*xx + x(20)*yy)*(s2+s2_6)
7180 write(2,*), "de_dzz = ", de_dzz,de_dzz_num,itype(i,1)
7183 de_dt = 0.5d0*sumene3*cost2tab(i+1)*(s1+s1_6) &
7184 -0.5d0*sumene4*sint2tab(i+1)*(s2+s2_6) &
7185 +pom1*pom_dt1+pom2*pom_dt2
7187 write(2,*), "de_dt = ", de_dt,de_dt_num,itype(i,1)
7191 cossc=scalar(dc_norm(1,i),dc_norm(1,i+nres))
7192 cossc1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
7193 cosfac2xx=cosfac2*xx
7194 sinfac2yy=sinfac2*yy
7196 dt_dCi(k) = -(dc_norm(k,i-1)+costtab(i+1)*dc_norm(k,i))* &
7198 dt_dCi1(k)= -(dc_norm(k,i)+costtab(i+1)*dc_norm(k,i-1))* &
7200 pom=(dC_norm(k,i+nres)-cossc*dC_norm(k,i))*vbld_inv(i+1)
7201 pom1=(dC_norm(k,i+nres)-cossc1*dC_norm(k,i-1))*vbld_inv(i)
7202 ! write (iout,*) "i",i," k",k," pom",pom," pom1",pom1,
7203 ! & " dt_dCi",dt_dCi(k)," dt_dCi1",dt_dCi1(k)
7204 ! write (iout,*) "dC_norm",(dC_norm(j,i),j=1,3),
7205 ! & (dC_norm(j,i-1),j=1,3)," vbld_inv",vbld_inv(i+1),vbld_inv(i)
7206 dXX_Ci(k)=pom*cosfac-dt_dCi(k)*cosfac2xx
7207 dXX_Ci1(k)=-pom1*cosfac-dt_dCi1(k)*cosfac2xx
7208 dYY_Ci(k)=pom*sinfac+dt_dCi(k)*sinfac2yy
7209 dYY_Ci1(k)=pom1*sinfac+dt_dCi1(k)*sinfac2yy
7213 dZZ_Ci(k)=dZZ_Ci(k)-uzgrad(j,k,2,i-1) &
7214 *dsign(1.0d0,dfloat(itype(i,1)))*dC_norm(j,i+nres)
7215 dZZ_Ci1(k)=dZZ_Ci1(k)-uzgrad(j,k,1,i-1) &
7216 *dsign(1.0d0,dfloat(itype(i,1)))*dC_norm(j,i+nres)
7219 dXX_XYZ(k)=vbld_inv(i+nres)*(x_prime(k)-xx*dC_norm(k,i+nres))
7220 dYY_XYZ(k)=vbld_inv(i+nres)*(y_prime(k)-yy*dC_norm(k,i+nres))
7221 dZZ_XYZ(k)=vbld_inv(i+nres)* &
7222 (z_prime(k)-zz*dC_norm(k,i+nres))
7224 dt_dCi(k) = -dt_dCi(k)/sinttab(i+1)
7225 dt_dCi1(k)= -dt_dCi1(k)/sinttab(i+1)
7229 dXX_Ctab(k,i)=dXX_Ci(k)
7230 dXX_C1tab(k,i)=dXX_Ci1(k)
7231 dYY_Ctab(k,i)=dYY_Ci(k)
7232 dYY_C1tab(k,i)=dYY_Ci1(k)
7233 dZZ_Ctab(k,i)=dZZ_Ci(k)
7234 dZZ_C1tab(k,i)=dZZ_Ci1(k)
7235 dXX_XYZtab(k,i)=dXX_XYZ(k)
7236 dYY_XYZtab(k,i)=dYY_XYZ(k)
7237 dZZ_XYZtab(k,i)=dZZ_XYZ(k)
7241 ! write (iout,*) "k",k," dxx_ci1",dxx_ci1(k)," dyy_ci1",
7242 ! & dyy_ci1(k)," dzz_ci1",dzz_ci1(k)
7243 ! write (iout,*) "k",k," dxx_ci",dxx_ci(k)," dyy_ci",
7244 ! & dyy_ci(k)," dzz_ci",dzz_ci(k)
7245 ! write (iout,*) "k",k," dt_dci",dt_dci(k)," dt_dci",
7247 ! write (iout,*) "k",k," dxx_XYZ",dxx_XYZ(k)," dyy_XYZ",
7248 ! & dyy_XYZ(k)," dzz_XYZ",dzz_XYZ(k)
7249 gscloc(k,i-1)=gscloc(k,i-1)+de_dxx*dxx_ci1(k) &
7250 +de_dyy*dyy_ci1(k)+de_dzz*dzz_ci1(k)+de_dt*dt_dCi1(k)
7251 gscloc(k,i)=gscloc(k,i)+de_dxx*dxx_Ci(k) &
7252 +de_dyy*dyy_Ci(k)+de_dzz*dzz_Ci(k)+de_dt*dt_dCi(k)
7253 gsclocx(k,i)= de_dxx*dxx_XYZ(k) &
7254 +de_dyy*dyy_XYZ(k)+de_dzz*dzz_XYZ(k)
7256 ! write(iout,*) "ENERGY GRAD = ", (gscloc(k,i-1),k=1,3),
7257 ! & (gscloc(k,i),k=1,3),(gsclocx(k,i),k=1,3)
7259 ! to check gradient call subroutine check_grad
7267 !-----------------------------------------------------------------------------
7268 real(kind=8) function enesc(x,xx,yy,zz,cost2,sint2)
7270 real(kind=8),dimension(65) :: x
7271 real(kind=8) :: xx,yy,zz,cost2,sint2,sumene1,sumene2,sumene3,&
7272 sumene4,sumene,dsc_i,dp2_i,dscp1,dscp2,s1,s1_6,s2,s2_6
7274 sumene1= x(1)+ x(2)*xx+ x(3)*yy+ x(4)*zz+ x(5)*xx**2 &
7275 + x(6)*yy**2+ x(7)*zz**2+ x(8)*xx*zz+ x(9)*xx*yy &
7277 sumene2= x(11) + x(12)*xx + x(13)*yy + x(14)*zz + x(15)*xx**2 &
7278 + x(16)*yy**2 + x(17)*zz**2 + x(18)*xx*zz + x(19)*xx*yy &
7280 sumene3= x(21) +x(22)*xx +x(23)*yy +x(24)*zz +x(25)*xx**2 &
7281 +x(26)*yy**2 +x(27)*zz**2 +x(28)*xx*zz +x(29)*xx*yy &
7282 +x(30)*yy*zz +x(31)*xx**3 +x(32)*yy**3 +x(33)*zz**3 &
7283 +x(34)*(xx**2)*yy +x(35)*(xx**2)*zz +x(36)*(yy**2)*xx &
7284 +x(37)*(yy**2)*zz +x(38)*(zz**2)*xx +x(39)*(zz**2)*yy &
7286 sumene4= x(41) +x(42)*xx +x(43)*yy +x(44)*zz +x(45)*xx**2 &
7287 +x(46)*yy**2 +x(47)*zz**2 +x(48)*xx*zz +x(49)*xx*yy &
7288 +x(50)*yy*zz +x(51)*xx**3 +x(52)*yy**3 +x(53)*zz**3 &
7289 +x(54)*(xx**2)*yy +x(55)*(xx**2)*zz +x(56)*(yy**2)*xx &
7290 +x(57)*(yy**2)*zz +x(58)*(zz**2)*xx +x(59)*(zz**2)*yy &
7292 dsc_i = 0.743d0+x(61)
7294 dscp1=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
7295 *(xx*cost2+yy*sint2))
7296 dscp2=dsqrt(dsc_i**2+dp2_i**2-2*dsc_i*dp2_i &
7297 *(xx*cost2-yy*sint2))
7298 s1=(1+x(63))/(0.1d0 + dscp1)
7299 s1_6=(1+x(64))/(0.1d0 + dscp1**6)
7300 s2=(1+x(65))/(0.1d0 + dscp2)
7301 s2_6=(1+x(65))/(0.1d0 + dscp2**6)
7302 sumene = ( sumene3*sint2 + sumene1)*(s1+s1_6) &
7303 + (sumene4*cost2 +sumene2)*(s2+s2_6)
7308 !-----------------------------------------------------------------------------
7309 subroutine gcont(rij,r0ij,eps0ij,delta,fcont,fprimcont)
7311 ! This procedure calculates two-body contact function g(rij) and its derivative:
7314 ! g(rij) = esp0ij*(-0.9375*x+0.625*x**3-0.1875*x**5) ! -1 =< x =< 1
7317 ! where x=(rij-r0ij)/delta
7319 ! rij - interbody distance, r0ij - contact distance, eps0ij - contact energy
7322 real(kind=8) :: rij,r0ij,eps0ij,fcont,fprimcont
7323 real(kind=8) :: x,x2,x4,delta
7327 if (x.lt.-1.0D0) then
7330 else if (x.le.1.0D0) then
7333 fcont=eps0ij*(x*(-0.9375D0+0.6250D0*x2-0.1875D0*x4)+0.5D0)
7334 fprimcont=eps0ij * (-0.9375D0+1.8750D0*x2-0.9375D0*x4)/delta
7340 end subroutine gcont
7341 !-----------------------------------------------------------------------------
7342 subroutine splinthet(theti,delta,ss,ssder)
7343 ! implicit real(kind=8) (a-h,o-z)
7344 ! include 'DIMENSIONS'
7345 ! include 'COMMON.VAR'
7346 ! include 'COMMON.GEO'
7347 real(kind=8) :: theti,delta,ss,ssder
7348 real(kind=8) :: thetup,thetlow
7351 if (theti.gt.pipol) then
7352 call gcont(theti,thetup,1.0d0,delta,ss,ssder)
7354 call gcont(-theti,-thetlow,1.0d0,delta,ss,ssder)
7358 end subroutine splinthet
7359 !-----------------------------------------------------------------------------
7360 subroutine spline1(x,x0,delta,f0,f1,fprim0,f,fprim)
7362 real(kind=8) :: x,x0,delta,f0,f1,fprim0,f,fprim
7363 real(kind=8) :: ksi,ksi2,ksi3,a1,a2,a3
7364 a1=fprim0*delta/(f1-f0)
7370 f=f0+(f1-f0)*ksi*(a1+ksi*(a2+a3*ksi))
7371 fprim=(f1-f0)/delta*(a1+ksi*(2*a2+3*ksi*a3))
7373 end subroutine spline1
7374 !-----------------------------------------------------------------------------
7375 subroutine spline2(x,x0,delta,f0x,f1x,fprim0x,fx)
7377 real(kind=8) :: x,x0,delta,f0x,f1x,fprim0x,fx
7378 real(kind=8) :: ksi,ksi2,ksi3,a1,a2,a3
7383 a2=3*(f1x-f0x)-2*fprim0x*delta
7384 a3=fprim0x*delta-2*(f1x-f0x)
7385 fx=f0x+a1*ksi+a2*ksi2+a3*ksi3
7387 end subroutine spline2
7388 !-----------------------------------------------------------------------------
7390 !-----------------------------------------------------------------------------
7391 subroutine etor(etors,edihcnstr)
7392 ! implicit real(kind=8) (a-h,o-z)
7393 ! include 'DIMENSIONS'
7394 ! include 'COMMON.VAR'
7395 ! include 'COMMON.GEO'
7396 ! include 'COMMON.LOCAL'
7397 ! include 'COMMON.TORSION'
7398 ! include 'COMMON.INTERACT'
7399 ! include 'COMMON.DERIV'
7400 ! include 'COMMON.CHAIN'
7401 ! include 'COMMON.NAMES'
7402 ! include 'COMMON.IOUNITS'
7403 ! include 'COMMON.FFIELD'
7404 ! include 'COMMON.TORCNSTR'
7405 ! include 'COMMON.CONTROL'
7406 real(kind=8) :: etors,edihcnstr
7410 real(kind=8) :: phii,fac,etors_ii
7412 ! Set lprn=.true. for debugging
7416 do i=iphi_start,iphi_end
7418 if (itype(i-2,1).eq.ntyp1.or. itype(i-1,1).eq.ntyp1 &
7419 .or. itype(i,1).eq.ntyp1) cycle
7420 itori=itortyp(itype(i-2,1))
7421 itori1=itortyp(itype(i-1,1))
7424 ! Proline-Proline pair is a special case...
7425 if (itori.eq.3 .and. itori1.eq.3) then
7426 if (phii.gt.-dwapi3) then
7428 fac=1.0D0/(1.0D0-cosphi)
7429 etorsi=v1(1,3,3)*fac
7430 etorsi=etorsi+etorsi
7431 etors=etors+etorsi-v1(1,3,3)
7432 if (energy_dec) etors_ii=etors_ii+etorsi-v1(1,3,3)
7433 gloci=gloci-3*fac*etorsi*dsin(3*phii)
7436 v1ij=v1(j+1,itori,itori1)
7437 v2ij=v2(j+1,itori,itori1)
7440 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
7441 if (energy_dec) etors_ii=etors_ii+ &
7442 v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
7443 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
7447 v1ij=v1(j,itori,itori1)
7448 v2ij=v2(j,itori,itori1)
7451 etors=etors+v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
7452 if (energy_dec) etors_ii=etors_ii+ &
7453 v1ij*cosphi+v2ij*sinphi+dabs(v1ij)+dabs(v2ij)
7454 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
7457 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
7460 write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)') &
7461 restyp(itype(i-2,1),1),i-2,restyp(itype(i-1,1),1),i-1,itori,itori1,&
7462 (v1(j,itori,itori1),j=1,6),(v2(j,itori,itori1),j=1,6)
7463 gloc(i-3,icg)=gloc(i-3,icg)+wtor*gloci
7464 ! write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
7466 ! 6/20/98 - dihedral angle constraints
7469 itori=idih_constr(i)
7472 if (difi.gt.drange(i)) then
7474 edihcnstr=edihcnstr+0.25d0*ftors(i)*difi**4
7475 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors(i)*difi**3
7476 else if (difi.lt.-drange(i)) then
7478 edihcnstr=edihcnstr+0.25d0*ftors(i)*difi**4
7479 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors(i)*difi**3
7481 ! write (iout,'(2i5,2f8.3,2e14.5)') i,itori,rad2deg*phii,
7482 ! & rad2deg*difi,0.25d0*ftors*difi**4,gloc(itori-3,icg)
7484 ! write (iout,*) 'edihcnstr',edihcnstr
7487 !-----------------------------------------------------------------------------
7488 subroutine etor_d(etors_d)
7489 real(kind=8) :: etors_d
7492 end subroutine etor_d
7493 !-----------------------------------------------------------------------------
7494 !c LICZENIE WIEZOW Z ROWNANIA ENERGII MODELLERA
7495 subroutine e_modeller(ehomology_constr)
7496 real(kind=8) :: ehomology_constr
7497 ehomology_constr=0.0d0
7498 write (iout,*) "!!!!!UWAGA, JESTEM W DZIWNEJ PETLI, TEST!!!!!"
7500 end subroutine e_modeller
7501 C !!!!!!!! NIE CZYTANE !!!!!!!!!!!
7503 !-----------------------------------------------------------------------------
7504 subroutine etor(etors)
7505 ! implicit real(kind=8) (a-h,o-z)
7506 ! include 'DIMENSIONS'
7507 ! include 'COMMON.VAR'
7508 ! include 'COMMON.GEO'
7509 ! include 'COMMON.LOCAL'
7510 ! include 'COMMON.TORSION'
7511 ! include 'COMMON.INTERACT'
7512 ! include 'COMMON.DERIV'
7513 ! include 'COMMON.CHAIN'
7514 ! include 'COMMON.NAMES'
7515 ! include 'COMMON.IOUNITS'
7516 ! include 'COMMON.FFIELD'
7517 ! include 'COMMON.TORCNSTR'
7518 ! include 'COMMON.CONTROL'
7519 real(kind=8) :: etors,edihcnstr
7522 integer :: i,j,iblock,itori,itori1
7523 real(kind=8) :: phii,gloci,v1ij,v2ij,cosphi,sinphi,&
7524 vl1ij,vl2ij,vl3ij,pom1,difi,etors_ii,pom
7525 ! Set lprn=.true. for debugging
7529 do i=iphi_start,iphi_end
7530 if (itype(i-2,1).eq.ntyp1 .or. itype(i-1,1).eq.ntyp1 &
7531 .or. itype(i-3,1).eq.ntyp1 &
7532 .or. itype(i,1).eq.ntyp1) cycle
7534 if (iabs(itype(i,1)).eq.20) then
7539 itori=itortyp(itype(i-2,1))
7540 itori1=itortyp(itype(i-1,1))
7543 ! Regular cosine and sine terms
7544 do j=1,nterm(itori,itori1,iblock)
7545 v1ij=v1(j,itori,itori1,iblock)
7546 v2ij=v2(j,itori,itori1,iblock)
7549 etors=etors+v1ij*cosphi+v2ij*sinphi
7550 if (energy_dec) etors_ii=etors_ii+ &
7551 v1ij*cosphi+v2ij*sinphi
7552 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
7556 ! E = SUM ----------------------------------- - v1
7557 ! [v2 cos(phi/2)+v3 sin(phi/2)]^2 + 1
7559 cosphi=dcos(0.5d0*phii)
7560 sinphi=dsin(0.5d0*phii)
7561 do j=1,nlor(itori,itori1,iblock)
7562 vl1ij=vlor1(j,itori,itori1)
7563 vl2ij=vlor2(j,itori,itori1)
7564 vl3ij=vlor3(j,itori,itori1)
7565 pom=vl2ij*cosphi+vl3ij*sinphi
7566 pom1=1.0d0/(pom*pom+1.0d0)
7567 etors=etors+vl1ij*pom1
7568 if (energy_dec) etors_ii=etors_ii+ &
7571 gloci=gloci+vl1ij*(vl3ij*cosphi-vl2ij*sinphi)*pom
7573 ! Subtract the constant term
7574 etors=etors-v0(itori,itori1,iblock)
7575 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
7576 'etor',i,etors_ii-v0(itori,itori1,iblock)
7578 write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)') &
7579 restyp(itype(i-2,1),1),i-2,restyp(itype(i-1,1),1),i-1,itori,itori1,&
7580 (v1(j,itori,itori1,iblock),j=1,6),&
7581 (v2(j,itori,itori1,iblock),j=1,6)
7582 gloc(i-3,icg)=gloc(i-3,icg)+wtor*gloci
7583 ! write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
7585 ! 6/20/98 - dihedral angle constraints
7588 !C The rigorous attempt to derive energy function
7589 !-------------------------------------------------------------------------------------------
7590 subroutine etor_kcc(etors)
7591 double precision c1(0:maxval_kcc),c2(0:maxval_kcc)
7592 real(kind=8) :: etors,glocig,glocit1,glocit2,sinthet1,&
7593 sinthet2,costhet1,costhet2,sint1t2,sint1t2n,phii,sinphi,cosphi,&
7594 sint1t2n1,sumvalc,gradvalct1,gradvalct2,sumvals,gradvalst1,&
7597 integer :: i,j,itori,itori1,nval,k,l
7599 if (lprn) write (iout,*) "etor_kcc tor_mode",tor_mode
7601 do i=iphi_start,iphi_end
7602 !C ANY TWO ARE DUMMY ATOMS in row CYCLE
7603 !c if (((itype(i-3).eq.ntyp1).and.(itype(i-2).eq.ntyp1)).or.
7604 !c & ((itype(i-2).eq.ntyp1).and.(itype(i-1).eq.ntyp1)) .or.
7605 !c & ((itype(i-1).eq.ntyp1).and.(itype(i).eq.ntyp1))) cycle
7606 if (itype(i-2,1).eq.ntyp1.or. itype(i-1,1).eq.ntyp1 &
7607 .or. itype(i,1).eq.ntyp1 .or. itype(i-3,1).eq.ntyp1) cycle
7608 itori=itortyp(itype(i-2,1))
7609 itori1=itortyp(itype(i-1,1))
7614 !C to avoid multiple devision by 2
7615 !c theti22=0.5d0*theta(i)
7616 !C theta 12 is the theta_1 /2
7617 !C theta 22 is theta_2 /2
7618 !c theti12=0.5d0*theta(i-1)
7619 !C and appropriate sinus function
7620 sinthet1=dsin(theta(i-1))
7621 sinthet2=dsin(theta(i))
7622 costhet1=dcos(theta(i-1))
7623 costhet2=dcos(theta(i))
7624 !C to speed up lets store its mutliplication
7625 sint1t2=sinthet2*sinthet1
7627 !C \sum_{i=1}^n (sin(theta_1) * sin(theta_2))^n * (c_n* cos(n*gamma)
7628 !C +d_n*sin(n*gamma)) *
7629 !C \sum_{i=1}^m (1+a_m*Tb_m(cos(theta_1 /2))+b_m*Tb_m(cos(theta_2 /2)))
7630 !C we have two sum 1) Non-Chebyshev which is with n and gamma
7631 nval=nterm_kcc_Tb(itori,itori1)
7637 c1(j)=c1(j-1)*costhet1
7638 c2(j)=c2(j-1)*costhet2
7642 do j=1,nterm_kcc(itori,itori1)
7646 sint1t2n=sint1t2n*sint1t2
7652 sumvalc=sumvalc+v1_kcc(l,k,j,itori1,itori)*c1(k)*c2(l)
7653 gradvalct1=gradvalct1+ &
7654 (k-1)*v1_kcc(l,k,j,itori1,itori)*c1(k-1)*c2(l)
7655 gradvalct2=gradvalct2+ &
7656 (l-1)*v1_kcc(l,k,j,itori1,itori)*c1(k)*c2(l-1)
7659 gradvalct1=-gradvalct1*sinthet1
7660 gradvalct2=-gradvalct2*sinthet2
7666 sumvals=sumvals+v2_kcc(l,k,j,itori1,itori)*c1(k)*c2(l)
7667 gradvalst1=gradvalst1+ &
7668 (k-1)*v2_kcc(l,k,j,itori1,itori)*c1(k-1)*c2(l)
7669 gradvalst2=gradvalst2+ &
7670 (l-1)*v2_kcc(l,k,j,itori1,itori)*c1(k)*c2(l-1)
7673 gradvalst1=-gradvalst1*sinthet1
7674 gradvalst2=-gradvalst2*sinthet2
7675 if (lprn) write (iout,*)j,"sumvalc",sumvalc," sumvals",sumvals
7676 etori=etori+sint1t2n*(sumvalc*cosphi+sumvals*sinphi)
7677 !C glocig is the gradient local i site in gamma
7678 glocig=glocig+j*sint1t2n*(sumvals*cosphi-sumvalc*sinphi)
7679 !C now gradient over theta_1
7680 glocit1=glocit1+sint1t2n*(gradvalct1*cosphi+gradvalst1*sinphi)&
7681 +j*sint1t2n1*costhet1*sinthet2*(sumvalc*cosphi+sumvals*sinphi)
7682 glocit2=glocit2+sint1t2n*(gradvalct2*cosphi+gradvalst2*sinphi)&
7683 +j*sint1t2n1*sinthet1*costhet2*(sumvalc*cosphi+sumvals*sinphi)
7686 gloc(i-3,icg)=gloc(i-3,icg)+wtor*glocig
7687 !C derivative over theta1
7688 gloc(nphi+i-3,icg)=gloc(nphi+i-3,icg)+wtor*glocit1
7689 !C now derivative over theta2
7690 gloc(nphi+i-2,icg)=gloc(nphi+i-2,icg)+wtor*glocit2
7692 write (iout,*) i-2,i-1,itype(i-2,1),itype(i-1,1),itori,itori1,&
7693 theta(i-1)*rad2deg,theta(i)*rad2deg,phii*rad2deg,etori
7694 write (iout,*) "c1",(c1(k),k=0,nval), &
7695 " c2",(c2(k),k=0,nval)
7699 end subroutine etor_kcc
7700 !------------------------------------------------------------------------------
7702 subroutine etor_constr(edihcnstr)
7703 real(kind=8) :: etors,edihcnstr
7706 integer :: i,j,iblock,itori,itori1
7707 real(kind=8) :: phii,gloci,v1ij,v2ij,cosphi,sinphi,&
7708 vl1ij,vl2ij,vl3ij,pom1,difi,etors_ii,pom,&
7709 gaudih_i,gauder_i,s,cos_i,dexpcos_i
7711 if (raw_psipred) then
7712 do i=idihconstr_start,idihconstr_end
7713 itori=idih_constr(i)
7715 gaudih_i=vpsipred(1,i)
7719 cos_i=(1.0d0-dcos(phii-phibound(j,i)))/s**2
7720 dexpcos_i=dexp(-cos_i*cos_i)
7721 gaudih_i=gaudih_i+vpsipred(j+1,i)*dexpcos_i
7722 gauder_i=gauder_i-2*vpsipred(j+1,i)*dsin(phii-phibound(j,i)) &
7723 *cos_i*dexpcos_i/s**2
7725 edihcnstr=edihcnstr-wdihc*dlog(gaudih_i)
7726 gloc(itori-3,icg)=gloc(itori-3,icg)-wdihc*gauder_i/gaudih_i
7728 write (iout,'(2i5,f8.3,f8.5,2(f8.5,2f8.3),f10.5)') &
7729 i,itori,phii*rad2deg,vpsipred(1,i),vpsipred(2,i),&
7730 phibound(1,i)*rad2deg,sdihed(1,i)*rad2deg,vpsipred(3,i),&
7731 phibound(2,i)*rad2deg,sdihed(2,i)*rad2deg,&
7732 -wdihc*dlog(gaudih_i)
7736 do i=idihconstr_start,idihconstr_end
7737 itori=idih_constr(i)
7739 difi=pinorm(phii-phi0(i))
7740 if (difi.gt.drange(i)) then
7742 edihcnstr=edihcnstr+0.25d0*ftors(i)*difi**4
7743 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors(i)*difi**3
7744 else if (difi.lt.-drange(i)) then
7746 edihcnstr=edihcnstr+0.25d0*ftors(i)*difi**4
7747 gloc(itori-3,icg)=gloc(itori-3,icg)+ftors(i)*difi**3
7757 end subroutine etor_constr
7758 !-----------------------------------------------------------------------------
7759 subroutine etor_d(etors_d)
7760 ! 6/23/01 Compute double torsional energy
7761 ! implicit real(kind=8) (a-h,o-z)
7762 ! include 'DIMENSIONS'
7763 ! include 'COMMON.VAR'
7764 ! include 'COMMON.GEO'
7765 ! include 'COMMON.LOCAL'
7766 ! include 'COMMON.TORSION'
7767 ! include 'COMMON.INTERACT'
7768 ! include 'COMMON.DERIV'
7769 ! include 'COMMON.CHAIN'
7770 ! include 'COMMON.NAMES'
7771 ! include 'COMMON.IOUNITS'
7772 ! include 'COMMON.FFIELD'
7773 ! include 'COMMON.TORCNSTR'
7774 real(kind=8) :: etors_d,etors_d_ii
7777 integer :: i,j,k,l,itori,itori1,itori2,iblock
7778 real(kind=8) :: phii,phii1,gloci1,gloci2,&
7779 v1cij,v1sij,v2cij,v2sij,cosphi1,sinphi1,&
7780 sinphi2,cosphi2,v1cdij,v2cdij,v1sdij,v2sdij,&
7781 cosphi1p2,cosphi1m2,sinphi1p2,sinphi1m2
7782 ! Set lprn=.true. for debugging
7786 ! write(iout,*) "a tu??"
7787 do i=iphid_start,iphid_end
7789 if (itype(i-2,1).eq.ntyp1 .or. itype(i-1,1).eq.ntyp1 &
7790 .or. itype(i-3,1).eq.ntyp1 &
7791 .or. itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
7792 itori=itortyp(itype(i-2,1))
7793 itori1=itortyp(itype(i-1,1))
7794 itori2=itortyp(itype(i,1))
7800 if (iabs(itype(i+1,1)).eq.20) iblock=2
7802 ! Regular cosine and sine terms
7803 do j=1,ntermd_1(itori,itori1,itori2,iblock)
7804 v1cij=v1c(1,j,itori,itori1,itori2,iblock)
7805 v1sij=v1s(1,j,itori,itori1,itori2,iblock)
7806 v2cij=v1c(2,j,itori,itori1,itori2,iblock)
7807 v2sij=v1s(2,j,itori,itori1,itori2,iblock)
7808 cosphi1=dcos(j*phii)
7809 sinphi1=dsin(j*phii)
7810 cosphi2=dcos(j*phii1)
7811 sinphi2=dsin(j*phii1)
7812 etors_d=etors_d+v1cij*cosphi1+v1sij*sinphi1+ &
7813 v2cij*cosphi2+v2sij*sinphi2
7814 if (energy_dec) etors_d_ii=etors_d_ii+ &
7815 v1cij*cosphi1+v1sij*sinphi1+v2cij*cosphi2+v2sij*sinphi2
7816 gloci1=gloci1+j*(v1sij*cosphi1-v1cij*sinphi1)
7817 gloci2=gloci2+j*(v2sij*cosphi2-v2cij*sinphi2)
7819 do k=2,ntermd_2(itori,itori1,itori2,iblock)
7821 v1cdij = v2c(k,l,itori,itori1,itori2,iblock)
7822 v2cdij = v2c(l,k,itori,itori1,itori2,iblock)
7823 v1sdij = v2s(k,l,itori,itori1,itori2,iblock)
7824 v2sdij = v2s(l,k,itori,itori1,itori2,iblock)
7825 cosphi1p2=dcos(l*phii+(k-l)*phii1)
7826 cosphi1m2=dcos(l*phii-(k-l)*phii1)
7827 sinphi1p2=dsin(l*phii+(k-l)*phii1)
7828 sinphi1m2=dsin(l*phii-(k-l)*phii1)
7829 etors_d=etors_d+v1cdij*cosphi1p2+v2cdij*cosphi1m2+ &
7830 v1sdij*sinphi1p2+v2sdij*sinphi1m2
7831 if (energy_dec) etors_d_ii=etors_d_ii+ &
7832 v1cdij*cosphi1p2+v2cdij*cosphi1m2+ &
7833 v1sdij*sinphi1p2+v2sdij*sinphi1m2
7834 gloci1=gloci1+l*(v1sdij*cosphi1p2+v2sdij*cosphi1m2 &
7835 -v1cdij*sinphi1p2-v2cdij*sinphi1m2)
7836 gloci2=gloci2+(k-l)*(v1sdij*cosphi1p2-v2sdij*cosphi1m2 &
7837 -v1cdij*sinphi1p2+v2cdij*sinphi1m2)
7840 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
7841 'etor_d',i,etors_d_ii
7842 gloc(i-3,icg)=gloc(i-3,icg)+wtor_d*gloci1
7843 gloc(i-2,icg)=gloc(i-2,icg)+wtor_d*gloci2
7846 end subroutine etor_d
7848 !----------------------------------------------------------------------------
7849 !----------------------------------------------------------------------------
7850 subroutine e_modeller(ehomology_constr)
7852 ! include 'DIMENSIONS'
7853 use MD_data, only: iset
7854 real(kind=8) :: ehomology_constr
7855 integer nnn,i,ii,j,k,ijk,jik,ki,kk,nexl,irec,l
7856 integer katy, odleglosci, test7
7857 real(kind=8) :: odleg, odleg2, odleg3, kat, kat2, kat3
7858 real(kind=8) :: Eval,Erot,min_odl
7859 real(kind=8),dimension(constr_homology) :: distance,distancek,godl,dih_diff,gdih, &
7861 uscdiffk,guscdiff2,guscdiff3,&
7866 ! FP - 30/10/2014 Temporary specifications for homology restraints
7868 real(kind=8) :: utheta_i,gutheta_i,sum_gtheta,sum_sgtheta,&
7870 real(kind=8), dimension (nres) :: guscdiff,usc_diff
7871 real(kind=8) :: sum_godl,sgodl,grad_odl3,ggodl,sum_gdih,&
7872 sum_guscdiff,sum_sgdih,sgdih,grad_dih3,usc_diff_i,dxx,dyy,dzz,&
7873 betai,sum_sgodl,dij,max_template
7874 ! real(kind=8) :: dist,pinorm
7876 ! include 'COMMON.SBRIDGE'
7877 ! include 'COMMON.CHAIN'
7878 ! include 'COMMON.GEO'
7879 ! include 'COMMON.DERIV'
7880 ! include 'COMMON.LOCAL'
7881 ! include 'COMMON.INTERACT'
7882 ! include 'COMMON.VAR'
7883 ! include 'COMMON.IOUNITS'
7884 ! include 'COMMON.MD'
7885 ! include 'COMMON.CONTROL'
7886 ! include 'COMMON.HOMOLOGY'
7887 ! include 'COMMON.QRESTR'
7889 ! From subroutine Econstr_back
7891 ! include 'COMMON.NAMES'
7892 ! include 'COMMON.TIME1'
7897 distancek(i)=9999999.9
7903 ! Pseudo-energy and gradient from homology restraints (MODELLER-like
7905 ! AL 5/2/14 - Introduce list of restraints
7906 ! write(iout,*) "waga_theta",waga_theta,"waga_d",waga_d
7908 write(iout,*) "------- dist restrs start -------"
7910 do ii = link_start_homo,link_end_homo
7914 ! write (iout,*) "dij(",i,j,") =",dij
7916 do k=1,constr_homology
7917 ! write(iout,*) ii,k,i,j,l_homo(k,ii),dij,odl(k,ii)
7918 if(.not.l_homo(k,ii)) then
7922 distance(k)=odl(k,ii)-dij
7923 ! write (iout,*) "distance(",k,") =",distance(k)
7925 ! For Gaussian-type Urestr
7927 distancek(k)=0.5d0*distance(k)**2*sigma_odl(k,ii) ! waga_dist rmvd from Gaussian argument
7928 ! write (iout,*) "sigma_odl(",k,ii,") =",sigma_odl(k,ii)
7929 ! write (iout,*) "distancek(",k,") =",distancek(k)
7930 ! distancek(k)=0.5d0*waga_dist*distance(k)**2*sigma_odl(k,ii)
7932 ! For Lorentzian-type Urestr
7934 if (waga_dist.lt.0.0d0) then
7935 sigma_odlir(k,ii)=dsqrt(1/sigma_odl(k,ii))
7936 distancek(k)=distance(k)**2/(sigma_odlir(k,ii)* &
7937 (distance(k)**2+sigma_odlir(k,ii)**2))
7941 ! min_odl=minval(distancek)
7945 do kk=1,constr_homology
7946 if(l_homo(kk,ii)) then
7947 min_odl=distancek(kk)
7951 do kk=1,constr_homology
7952 if (l_homo(kk,ii) .and. distancek(kk).lt.min_odl) &
7953 min_odl=distancek(kk)
7957 ! write (iout,* )"min_odl",min_odl
7959 write (iout,*) "ij dij",i,j,dij
7960 write (iout,*) "distance",(distance(k),k=1,constr_homology)
7961 write (iout,*) "distancek",(distancek(k),k=1,constr_homology)
7962 write (iout,* )"min_odl",min_odl
7967 if (waga_dist.ge.0.0d0) then
7973 do k=1,constr_homology
7974 ! Nie wiem po co to liczycie jeszcze raz!
7975 ! odleg3=-waga_dist(iset)*((distance(i,j,k)**2)/
7976 ! & (2*(sigma_odl(i,j,k))**2))
7977 if(.not.l_homo(k,ii)) cycle
7978 if (waga_dist.ge.0.0d0) then
7980 ! For Gaussian-type Urestr
7982 godl(k)=dexp(-distancek(k)+min_odl)
7983 odleg2=odleg2+godl(k)
7985 ! For Lorentzian-type Urestr
7988 odleg2=odleg2+distancek(k)
7991 !cc write(iout,779) i,j,k, "odleg2=",odleg2, "odleg3=", odleg3,
7992 !cc & "dEXP(odleg3)=", dEXP(odleg3),"distance(i,j,k)^2=",
7993 !cc & distance(i,j,k)**2, "dist(i+1,j+1)=", dist(i+1,j+1),
7994 !cc & "sigma_odl(i,j,k)=", sigma_odl(i,j,k)
7997 ! write (iout,*) "godl",(godl(k),k=1,constr_homology) ! exponents
7998 ! write (iout,*) "ii i j",ii,i,j," odleg2",odleg2 ! sum of exps
8000 write (iout,*) "godl",(godl(k),k=1,constr_homology) ! exponents
8001 write (iout,*) "ii i j",ii,i,j," odleg2",odleg2 ! sum of exps
8003 if (waga_dist.ge.0.0d0) then
8005 ! For Gaussian-type Urestr
8007 odleg=odleg-dLOG(odleg2/constr_homology)+min_odl
8009 ! For Lorentzian-type Urestr
8012 odleg=odleg+odleg2/constr_homology
8015 ! write (iout,*) "odleg",odleg ! sum of -ln-s
8018 ! For Gaussian-type Urestr
8020 if (waga_dist.ge.0.0d0) sum_godl=odleg2
8022 do k=1,constr_homology
8023 ! godl=dexp(((-(distance(i,j,k)**2)/(2*(sigma_odl(i,j,k))**2))
8024 ! & *waga_dist)+min_odl
8025 ! sgodl=-godl(k)*distance(k)*sigma_odl(k,ii)*waga_dist
8027 if(.not.l_homo(k,ii)) cycle
8028 if (waga_dist.ge.0.0d0) then
8029 ! For Gaussian-type Urestr
8031 sgodl=-godl(k)*distance(k)*sigma_odl(k,ii) ! waga_dist rmvd
8033 ! For Lorentzian-type Urestr
8036 sgodl=-2*sigma_odlir(k,ii)*(distance(k)/(distance(k)**2+ &
8037 sigma_odlir(k,ii)**2)**2)
8039 sum_sgodl=sum_sgodl+sgodl
8041 ! sgodl2=sgodl2+sgodl
8042 ! write(iout,*) i, j, k, distance(i,j,k), "W GRADIENCIE1"
8043 ! write(iout,*) "constr_homology=",constr_homology
8044 ! write(iout,*) i, j, k, "TEST K"
8046 ! print *, "ok",iset
8047 if (waga_dist.ge.0.0d0) then
8049 ! For Gaussian-type Urestr
8051 grad_odl3=waga_homology(iset)*waga_dist &
8052 *sum_sgodl/(sum_godl*dij)
8055 ! For Lorentzian-type Urestr
8058 ! Original grad expr modified by analogy w Gaussian-type Urestr grad
8059 ! grad_odl3=-waga_homology(iset)*waga_dist*sum_sgodl
8060 grad_odl3=-waga_homology(iset)*waga_dist* &
8061 sum_sgodl/(constr_homology*dij)
8065 ! grad_odl3=sum_sgodl/(sum_godl*dij)
8068 ! write(iout,*) i, j, k, distance(i,j,k), "W GRADIENCIE2"
8069 ! write(iout,*) (distance(i,j,k)**2), (2*(sigma_odl(i,j,k))**2),
8070 ! & (-(distance(i,j,k)**2)/(2*(sigma_odl(i,j,k))**2))
8072 !cc write(iout,*) godl, sgodl, grad_odl3
8074 ! grad_odl=grad_odl+grad_odl3
8077 ggodl=grad_odl3*(c(jik,i)-c(jik,j))
8078 !cc write(iout,*) c(jik,i+1), c(jik,j+1), (c(jik,i+1)-c(jik,j+1))
8079 !cc write(iout,746) "GRAD_ODL_1", i, j, jik, ggodl,
8080 !cc & ghpbc(jik,i+1), ghpbc(jik,j+1)
8081 ghpbc(jik,i)=ghpbc(jik,i)+ggodl
8082 ghpbc(jik,j)=ghpbc(jik,j)-ggodl
8083 !cc write(iout,746) "GRAD_ODL_2", i, j, jik, ggodl,
8084 !cc & ghpbc(jik,i+1), ghpbc(jik,j+1)
8085 ! if (i.eq.25.and.j.eq.27) then
8086 ! write(iout,*) "jik",jik,"i",i,"j",j
8087 ! write(iout,*) "sum_sgodl",sum_sgodl,"sgodl",sgodl
8088 ! write(iout,*) "grad_odl3",grad_odl3
8089 ! write(iout,*) "c(",jik,i,")",c(jik,i),"c(",jik,j,")",c(jik,j)
8090 ! write(iout,*) "ggodl",ggodl
8091 ! write(iout,*) "ghpbc(",jik,i,")",
8092 ! & ghpbc(jik,i),"ghpbc(",jik,j,")",
8096 !cc write(iout,778)"TEST: odleg2=", odleg2, "DLOG(odleg2)=",
8097 !cc & dLOG(odleg2),"-odleg=", -odleg
8099 enddo ! ii-loop for dist
8101 write(iout,*) "------- dist restrs end -------"
8102 ! if (waga_angle.eq.1.0d0 .or. waga_theta.eq.1.0d0 .or.
8103 ! & waga_d.eq.1.0d0) call sum_gradient
8105 ! Pseudo-energy and gradient from dihedral-angle restraints from
8106 ! homology templates
8107 ! write (iout,*) "End of distance loop"
8110 ! write (iout,*) idihconstr_start_homo,idihconstr_end_homo
8112 write(iout,*) "------- dih restrs start -------"
8113 do i=idihconstr_start_homo,idihconstr_end_homo
8114 write (iout,*) "gloc_init(",i,icg,")",gloc(i,icg)
8117 do i=idihconstr_start_homo,idihconstr_end_homo
8119 ! betai=beta(i,i+1,i+2,i+3)
8121 ! write (iout,*) "betai =",betai
8122 do k=1,constr_homology
8123 dih_diff(k)=pinorm(dih(k,i)-betai)
8124 !d write (iout,'(a8,2i4,2f15.8)') "dih_diff",i,k,dih_diff(k)
8125 !d & ,sigma_dih(k,i)
8126 ! if (dih_diff(i,k).gt.3.14159) dih_diff(i,k)=
8127 ! & -(6.28318-dih_diff(i,k))
8128 ! if (dih_diff(i,k).lt.-3.14159) dih_diff(i,k)=
8129 ! & 6.28318+dih_diff(i,k)
8131 kat3=-0.5d0*dih_diff(k)**2*sigma_dih(k,i) ! waga_angle rmvd from Gaussian argument
8133 kat3=(dcos(dih_diff(k))-1)*sigma_dih(k,i) ! waga_angle rmvd from Gaussian argument
8135 ! kat3=-0.5d0*waga_angle*dih_diff(k)**2*sigma_dih(k,i)
8138 ! write(iout,*) "kat2=", kat2, "exp(kat3)=", exp(kat3)
8141 ! write (iout,*) "gdih",(gdih(k),k=1,constr_homology) ! exps
8142 ! write (iout,*) "i",i," betai",betai," kat2",kat2 ! sum of exps
8144 write (iout,*) "i",i," betai",betai," kat2",kat2
8145 write (iout,*) "gdih",(gdih(k),k=1,constr_homology)
8147 if (kat2.le.1.0d-14) cycle
8148 kat=kat-dLOG(kat2/constr_homology)
8149 ! write (iout,*) "kat",kat ! sum of -ln-s
8151 !cc write(iout,778)"TEST: kat2=", kat2, "DLOG(kat2)=",
8152 !cc & dLOG(kat2), "-kat=", -kat
8154 ! ----------------------------------------------------------------------
8156 ! ----------------------------------------------------------------------
8160 do k=1,constr_homology
8162 sgdih=-gdih(k)*dih_diff(k)*sigma_dih(k,i) ! waga_angle rmvd
8164 sgdih=-gdih(k)*dsin(dih_diff(k))*sigma_dih(k,i) ! waga_angle rmvd
8166 ! sgdih=-gdih(k)*dih_diff(k)*sigma_dih(k,i)*waga_angle
8167 sum_sgdih=sum_sgdih+sgdih
8169 ! grad_dih3=sum_sgdih/sum_gdih
8170 grad_dih3=waga_homology(iset)*waga_angle*sum_sgdih/sum_gdih
8173 ! write(iout,*)i,k,gdih,sgdih,beta(i+1,i+2,i+3,i+4),grad_dih3
8174 !cc write(iout,747) "GRAD_KAT_1", i, nphi, icg, grad_dih3,
8175 !cc & gloc(nphi+i-3,icg)
8176 gloc(i-3,icg)=gloc(i-3,icg)+grad_dih3
8178 ! write(iout,*) "i",i,"icg",icg,"gloc(",i,icg,")",gloc(i,icg)
8180 !cc write(iout,747) "GRAD_KAT_2", i, nphi, icg, grad_dih3,
8181 !cc & gloc(nphi+i-3,icg)
8183 enddo ! i-loop for dih
8185 write(iout,*) "------- dih restrs end -------"
8188 ! Pseudo-energy and gradient for theta angle restraints from
8189 ! homology templates
8190 ! FP 01/15 - inserted from econstr_local_test.F, loop structure
8194 ! For constr_homology reference structures (FP)
8196 ! Uconst_back_tot=0.0d0
8199 ! Econstr_back legacy
8201 ! do i=ithet_start,ithet_end
8204 ! do i=loc_start,loc_end
8208 duscdiffx(j,i)=0.0d0
8213 ! write (iout,*) "ithet_start =",ithet_start,"ithet_end =",ithet_end
8214 ! write (iout,*) "waga_theta",waga_theta
8215 if (waga_theta.gt.0.0d0) then
8217 write (iout,*) "usampl",usampl
8218 write(iout,*) "------- theta restrs start -------"
8219 ! do i=ithet_start,ithet_end
8220 ! write (iout,*) "gloc_init(",nphi+i,icg,")",gloc(nphi+i,icg)
8223 ! write (iout,*) "maxres",maxres,"nres",nres
8225 do i=ithet_start,ithet_end
8228 ! ii = ifrag_back(2,i,iset)-ifrag_back(1,i,iset)
8230 ! Deviation of theta angles wrt constr_homology ref structures
8232 utheta_i=0.0d0 ! argument of Gaussian for single k
8233 gutheta_i=0.0d0 ! Sum of Gaussians over constr_homology ref structures
8234 ! do j=ifrag_back(1,i,iset)+2,ifrag_back(2,i,iset) ! original loop
8235 ! over residues in a fragment
8236 ! write (iout,*) "theta(",i,")=",theta(i)
8237 do k=1,constr_homology
8239 ! dtheta_i=theta(j)-thetaref(j,iref)
8240 ! dtheta_i=thetaref(k,i)-theta(i) ! original form without indexing
8241 theta_diff(k)=thetatpl(k,i)-theta(i)
8242 !d write (iout,'(a8,2i4,2f15.8)') "theta_diff",i,k,theta_diff(k)
8243 !d & ,sigma_theta(k,i)
8246 utheta_i=-0.5d0*theta_diff(k)**2*sigma_theta(k,i) ! waga_theta rmvd from Gaussian argument
8247 ! utheta_i=-0.5d0*waga_theta*theta_diff(k)**2*sigma_theta(k,i) ! waga_theta?
8248 gtheta(k)=dexp(utheta_i) ! + min_utheta_i?
8249 gutheta_i=gutheta_i+gtheta(k) ! Sum of Gaussians (pk)
8250 ! Gradient for single Gaussian restraint in subr Econstr_back
8251 ! dutheta(j-2)=dutheta(j-2)+wfrag_back(1,i,iset)*dtheta_i/(ii-1)
8254 ! write (iout,*) "gtheta",(gtheta(k),k=1,constr_homology) ! exps
8255 ! write (iout,*) "i",i," gutheta_i",gutheta_i ! sum of exps
8258 ! Gradient for multiple Gaussian restraint
8259 sum_gtheta=gutheta_i
8261 do k=1,constr_homology
8262 ! New generalized expr for multiple Gaussian from Econstr_back
8263 sgtheta=-gtheta(k)*theta_diff(k)*sigma_theta(k,i) ! waga_theta rmvd
8265 ! sgtheta=-gtheta(k)*theta_diff(k)*sigma_theta(k,i)*waga_theta ! right functional form?
8266 sum_sgtheta=sum_sgtheta+sgtheta ! cum variable
8268 ! Final value of gradient using same var as in Econstr_back
8269 gloc(nphi+i-2,icg)=gloc(nphi+i-2,icg) &
8270 +sum_sgtheta/sum_gtheta*waga_theta &
8271 *waga_homology(iset)
8274 ! dutheta(i-2)=sum_sgtheta/sum_gtheta*waga_theta
8275 ! & *waga_homology(iset)
8276 ! dutheta(i)=sum_sgtheta/sum_gtheta
8278 ! Uconst_back=Uconst_back+waga_theta*utheta(i) ! waga_theta added as weight
8279 Eval=Eval-dLOG(gutheta_i/constr_homology)
8280 ! write (iout,*) "utheta(",i,")=",utheta(i) ! -ln of sum of exps
8281 ! write (iout,*) "Uconst_back",Uconst_back ! sum of -ln-s
8282 ! Uconst_back=Uconst_back+utheta(i)
8283 enddo ! (i-loop for theta)
8285 write(iout,*) "------- theta restrs end -------"
8289 ! Deviation of local SC geometry
8291 ! Separation of two i-loops (instructed by AL - 11/3/2014)
8293 ! write (iout,*) "loc_start =",loc_start,"loc_end =",loc_end
8294 ! write (iout,*) "waga_d",waga_d
8297 write(iout,*) "------- SC restrs start -------"
8298 write (iout,*) "Initial duscdiff,duscdiffx"
8299 do i=loc_start,loc_end
8300 write (iout,*) i,(duscdiff(jik,i),jik=1,3), &
8301 (duscdiffx(jik,i),jik=1,3)
8304 do i=loc_start,loc_end
8305 usc_diff_i=0.0d0 ! argument of Gaussian for single k
8306 guscdiff(i)=0.0d0 ! Sum of Gaussians over constr_homology ref structures
8307 ! do j=ifrag_back(1,i,iset)+1,ifrag_back(2,i,iset)-1 ! Econstr_back legacy
8308 ! write(iout,*) "xxtab, yytab, zztab"
8309 ! write(iout,'(i5,3f8.2)') i,xxtab(i),yytab(i),zztab(i)
8310 do k=1,constr_homology
8312 dxx=-xxtpl(k,i)+xxtab(i) ! Diff b/w x component of ith SC vector in model and kth ref str?
8313 ! Original sign inverted for calc of gradients (s. Econstr_back)
8314 dyy=-yytpl(k,i)+yytab(i) ! ibid y
8315 dzz=-zztpl(k,i)+zztab(i) ! ibid z
8316 ! write(iout,*) "dxx, dyy, dzz"
8317 !d write(iout,'(2i5,4f8.2)') k,i,dxx,dyy,dzz,sigma_d(k,i)
8319 usc_diff_i=-0.5d0*(dxx**2+dyy**2+dzz**2)*sigma_d(k,i) ! waga_d rmvd from Gaussian argument
8320 ! usc_diff(i)=-0.5d0*waga_d*(dxx**2+dyy**2+dzz**2)*sigma_d(k,i) ! waga_d?
8321 ! uscdiffk(k)=usc_diff(i)
8322 guscdiff2(k)=dexp(usc_diff_i) ! without min_scdiff
8323 ! write(iout,*) "i",i," k",k," sigma_d",sigma_d(k,i),
8324 ! & " guscdiff2",guscdiff2(k)
8325 guscdiff(i)=guscdiff(i)+guscdiff2(k) !Sum of Gaussians (pk)
8326 ! write (iout,'(i5,6f10.5)') j,xxtab(j),yytab(j),zztab(j),
8327 ! & xxref(j),yyref(j),zzref(j)
8332 ! Generalized expression for multiple Gaussian acc to that for a single
8333 ! Gaussian in Econstr_back as instructed by AL (FP - 03/11/2014)
8335 ! Original implementation
8336 ! sum_guscdiff=guscdiff(i)
8338 ! sum_sguscdiff=0.0d0
8339 ! do k=1,constr_homology
8340 ! sguscdiff=-guscdiff2(k)*dscdiff(k)*sigma_d(k,i)*waga_d !waga_d?
8341 ! sguscdiff=-guscdiff3(k)*dscdiff(k)*sigma_d(k,i)*waga_d ! w min_uscdiff
8342 ! sum_sguscdiff=sum_sguscdiff+sguscdiff
8345 ! Implementation of new expressions for gradient (Jan. 2015)
8347 ! grad_uscdiff=sum_sguscdiff/(sum_guscdiff*dtab) !?
8348 do k=1,constr_homology
8350 ! New calculation of dxx, dyy, and dzz corrected by AL (07/11), was missing and wrong
8351 ! before. Now the drivatives should be correct
8353 dxx=-xxtpl(k,i)+xxtab(i) ! Diff b/w x component of ith SC vector in model and kth ref str?
8354 ! Original sign inverted for calc of gradients (s. Econstr_back)
8355 dyy=-yytpl(k,i)+yytab(i) ! ibid y
8356 dzz=-zztpl(k,i)+zztab(i) ! ibid z
8357 sum_guscdiff=guscdiff2(k)* &!(dsqrt(dxx*dxx+dyy*dyy+dzz*dzz))* -> wrong!
8358 sigma_d(k,i) ! for the grad wrt r'
8359 ! sum_sguscdiff=sum_sguscdiff+sum_guscdiff
8362 ! New implementation
8363 sum_guscdiff = waga_homology(iset)*waga_d*sum_guscdiff
8365 duscdiff(jik,i-1)=duscdiff(jik,i-1)+ &
8366 sum_guscdiff*(dXX_C1tab(jik,i)*dxx+ &
8367 dYY_C1tab(jik,i)*dyy+dZZ_C1tab(jik,i)*dzz)/guscdiff(i)
8368 duscdiff(jik,i)=duscdiff(jik,i)+ &
8369 sum_guscdiff*(dXX_Ctab(jik,i)*dxx+ &
8370 dYY_Ctab(jik,i)*dyy+dZZ_Ctab(jik,i)*dzz)/guscdiff(i)
8371 duscdiffx(jik,i)=duscdiffx(jik,i)+ &
8372 sum_guscdiff*(dXX_XYZtab(jik,i)*dxx+ &
8373 dYY_XYZtab(jik,i)*dyy+dZZ_XYZtab(jik,i)*dzz)/guscdiff(i)
8377 ! write(iout,*) "jik",jik,"i",i
8378 write(iout,*) "dxx, dyy, dzz"
8379 write(iout,'(2i5,3f8.2)') k,i,dxx,dyy,dzz
8380 write(iout,*) "guscdiff2(",k,")",guscdiff2(k)
8381 write(iout,*) "sum_sguscdiff",sum_guscdiff,waga_homology(iset),waga_d
8382 write(iout,*) "dXX_Ctab(",jik,i,")",dXX_Ctab(jik,i)
8383 write(iout,*) "dYY_Ctab(",jik,i,")",dYY_Ctab(jik,i)
8384 write(iout,*) "dZZ_Ctab(",jik,i,")",dZZ_Ctab(jik,i)
8385 write(iout,*) "dXX_C1tab(",jik,i,")",dXX_C1tab(jik,i)
8386 write(iout,*) "dYY_C1tab(",jik,i,")",dYY_C1tab(jik,i)
8387 write(iout,*) "dZZ_C1tab(",jik,i,")",dZZ_C1tab(jik,i)
8388 write(iout,*) "dXX_XYZtab(",jik,i,")",dXX_XYZtab(jik,i)
8389 write(iout,*) "dYY_XYZtab(",jik,i,")",dYY_XYZtab(jik,i)
8390 write(iout,*) "dZZ_XYZtab(",jik,i,")",dZZ_XYZtab(jik,i)
8391 write(iout,*) "duscdiff(",jik,i-1,")",duscdiff(jik,i-1)
8392 write(iout,*) "duscdiff(",jik,i,")",duscdiff(jik,i)
8393 write(iout,*) "duscdiffx(",jik,i,")",duscdiffx(jik,i)
8400 ! uscdiff(i)=-dLOG(guscdiff(i)/(ii-1)) ! Weighting by (ii-1) required?
8401 ! usc_diff(i)=-dLOG(guscdiff(i)/constr_homology) ! + min_uscdiff ?
8403 ! write (iout,*) i," uscdiff",uscdiff(i)
8405 ! Put together deviations from local geometry
8407 ! Uconst_back=Uconst_back+wfrag_back(1,i,iset)*utheta(i)+
8408 ! & wfrag_back(3,i,iset)*uscdiff(i)
8409 Erot=Erot-dLOG(guscdiff(i)/constr_homology)
8410 ! write (iout,*) "usc_diff(",i,")=",usc_diff(i) ! -ln of sum of exps
8411 ! write (iout,*) "Uconst_back",Uconst_back ! cum sum of -ln-s
8412 ! Uconst_back=Uconst_back+usc_diff(i)
8414 ! Gradient of multiple Gaussian restraint (FP - 04/11/2014 - right?)
8416 ! New implment: multiplied by sum_sguscdiff
8419 enddo ! (i-loop for dscdiff)
8424 write(iout,*) "------- SC restrs end -------"
8425 write (iout,*) "------ After SC loop in e_modeller ------"
8426 do i=loc_start,loc_end
8427 write (iout,*) "i",i," gradc",(gradc(j,i,icg),j=1,3)
8428 write (iout,*) "i",i," gradx",(gradx(j,i,icg),j=1,3)
8430 if (waga_theta.eq.1.0d0) then
8431 write (iout,*) "in e_modeller after SC restr end: dutheta"
8432 do i=ithet_start,ithet_end
8433 write (iout,*) i,dutheta(i)
8436 if (waga_d.eq.1.0d0) then
8437 write (iout,*) "e_modeller after SC loop: duscdiff/x"
8439 write (iout,*) i,(duscdiff(j,i),j=1,3)
8440 write (iout,*) i,(duscdiffx(j,i),j=1,3)
8445 ! Total energy from homology restraints
8447 write (iout,*) "odleg",odleg," kat",kat
8450 ! Addition of energy of theta angle and SC local geom over constr_homologs ref strs
8452 ! ehomology_constr=odleg+kat
8454 ! For Lorentzian-type Urestr
8457 if (waga_dist.ge.0.0d0) then
8459 ! For Gaussian-type Urestr
8461 ehomology_constr=(waga_dist*odleg+waga_angle*kat+ &
8462 waga_theta*Eval+waga_d*Erot)*waga_homology(iset)
8463 ! write (iout,*) "ehomology_constr=",ehomology_constr
8467 ! For Lorentzian-type Urestr
8469 ehomology_constr=(-waga_dist*odleg+waga_angle*kat+ &
8470 waga_theta*Eval+waga_d*Erot)*waga_homology(iset)
8471 ! write (iout,*) "ehomology_constr=",ehomology_constr
8475 write (iout,*) "odleg",waga_dist,odleg," kat",waga_angle,kat, &
8476 "Eval",waga_theta,eval, &
8478 write (iout,*) "ehomology_constr",ehomology_constr
8484 748 format(a8,f12.3,a6,f12.3,a7,f12.3)
8485 747 format(a12,i4,i4,i4,f8.3,f8.3)
8486 746 format(a12,i4,i4,i4,f8.3,f8.3,f8.3)
8487 778 format(a7,1X,f10.3,1X,a4,1X,f10.3,1X,a5,1X,f10.3)
8488 779 format(i3,1X,i3,1X,i2,1X,a7,1X,f7.3,1X,a7,1X,f7.3,1X,a13,1X, &
8489 f7.3,1X,a17,1X,f9.3,1X,a10,1X,f8.3,1X,a10,1X,f8.3)
8490 end subroutine e_modeller
8492 !----------------------------------------------------------------------------
8493 subroutine ebend_kcc(etheta)
8495 double precision thybt1(maxang_kcc),etheta
8496 integer :: i,iti,j,ihelp
8497 real (kind=8) :: sinthet,costhet,sumth1thyb,gradthybt1
8498 !C Set lprn=.true. for debugging
8501 !C print *,"wchodze kcc"
8502 if (lprn) write (iout,*) "ebend_kcc tor_mode",tor_mode
8504 do i=ithet_start,ithet_end
8505 !c print *,i,itype(i-1),itype(i),itype(i-2)
8506 if ((itype(i-1,1).eq.ntyp1).or.itype(i-2,1).eq.ntyp1 &
8507 .or.itype(i,1).eq.ntyp1) cycle
8508 iti=iabs(itortyp(itype(i-1,1)))
8509 sinthet=dsin(theta(i))
8510 costhet=dcos(theta(i))
8511 do j=1,nbend_kcc_Tb(iti)
8512 thybt1(j)=v1bend_chyb(j,iti)
8514 sumth1thyb=v1bend_chyb(0,iti)+ &
8515 tschebyshev(1,nbend_kcc_Tb(iti),thybt1(1),costhet)
8516 if (lprn) write (iout,*) i-1,itype(i-1,1),iti,theta(i)*rad2deg,&
8518 ihelp=nbend_kcc_Tb(iti)-1
8519 gradthybt1=gradtschebyshev(0,ihelp,thybt1(1),costhet)
8520 etheta=etheta+sumth1thyb
8521 !C print *,sumth1thyb,gradthybt1,sinthet*(-0.5d0)
8522 gloc(nphi+i-2,icg)=gloc(nphi+i-2,icg)-wang*gradthybt1*sinthet
8525 end subroutine ebend_kcc
8527 !c-------------------------------------------------------------------------------------
8528 subroutine etheta_constr(ethetacnstr)
8529 real (kind=8) :: ethetacnstr,thetiii,difi
8532 !C print *,ithetaconstr_start,ithetaconstr_end,"TU"
8533 do i=ithetaconstr_start,ithetaconstr_end
8534 itheta=itheta_constr(i)
8535 thetiii=theta(itheta)
8536 difi=pinorm(thetiii-theta_constr0(i))
8537 if (difi.gt.theta_drange(i)) then
8538 difi=difi-theta_drange(i)
8539 ethetacnstr=ethetacnstr+0.25d0*for_thet_constr(i)*difi**4
8540 gloc(itheta+nphi-2,icg)=gloc(itheta+nphi-2,icg) &
8541 +for_thet_constr(i)*difi**3
8542 else if (difi.lt.-drange(i)) then
8544 ethetacnstr=ethetacnstr+0.25d0*for_thet_constr(i)*difi**4
8545 gloc(itheta+nphi-2,icg)=gloc(itheta+nphi-2,icg) &
8546 +for_thet_constr(i)*difi**3
8550 if (energy_dec) then
8551 write (iout,'(a6,2i5,4f8.3,2e14.5)') "ethetc",&
8552 i,itheta,rad2deg*thetiii,&
8553 rad2deg*theta_constr0(i), rad2deg*theta_drange(i),&
8554 rad2deg*difi,0.25d0*for_thet_constr(i)*difi**4,&
8555 gloc(itheta+nphi-2,icg)
8559 end subroutine etheta_constr
8561 !-----------------------------------------------------------------------------
8562 subroutine eback_sc_corr(esccor)
8563 ! 7/21/2007 Correlations between the backbone-local and side-chain-local
8564 ! conformational states; temporarily implemented as differences
8565 ! between UNRES torsional potentials (dependent on three types of
8566 ! residues) and the torsional potentials dependent on all 20 types
8567 ! of residues computed from AM1 energy surfaces of terminally-blocked
8568 ! amino-acid residues.
8569 ! implicit real(kind=8) (a-h,o-z)
8570 ! include 'DIMENSIONS'
8571 ! include 'COMMON.VAR'
8572 ! include 'COMMON.GEO'
8573 ! include 'COMMON.LOCAL'
8574 ! include 'COMMON.TORSION'
8575 ! include 'COMMON.SCCOR'
8576 ! include 'COMMON.INTERACT'
8577 ! include 'COMMON.DERIV'
8578 ! include 'COMMON.CHAIN'
8579 ! include 'COMMON.NAMES'
8580 ! include 'COMMON.IOUNITS'
8581 ! include 'COMMON.FFIELD'
8582 ! include 'COMMON.CONTROL'
8583 real(kind=8) :: esccor,esccor_ii,phii,gloci,v1ij,v2ij,&
8586 integer :: i,interty,j,isccori,isccori1,intertyp
8587 ! Set lprn=.true. for debugging
8590 ! write (iout,*) "EBACK_SC_COR",itau_start,itau_end
8592 do i=itau_start,itau_end
8593 if ((itype(i-2,1).eq.ntyp1).or.(itype(i-1,1).eq.ntyp1)) cycle
8595 isccori=isccortyp(itype(i-2,1))
8596 isccori1=isccortyp(itype(i-1,1))
8598 ! write (iout,*) "EBACK_SC_COR",i,nterm_sccor(isccori,isccori1)
8600 do intertyp=1,3 !intertyp
8602 !c Added 09 May 2012 (Adasko)
8603 !c Intertyp means interaction type of backbone mainchain correlation:
8604 ! 1 = SC...Ca...Ca...Ca
8605 ! 2 = Ca...Ca...Ca...SC
8606 ! 3 = SC...Ca...Ca...SCi
8608 if (((intertyp.eq.3).and.((itype(i-2,1).eq.10).or. &
8609 (itype(i-1,1).eq.10).or.(itype(i-2,1).eq.ntyp1).or. &
8610 (itype(i-1,1).eq.ntyp1))) &
8611 .or. ((intertyp.eq.1).and.((itype(i-2,1).eq.10) &
8612 .or.(itype(i-2,1).eq.ntyp1).or.(itype(i-1,1).eq.ntyp1) &
8613 .or.(itype(i,1).eq.ntyp1))) &
8614 .or.((intertyp.eq.2).and.((itype(i-1,1).eq.10).or. &
8615 (itype(i-1,1).eq.ntyp1).or.(itype(i-2,1).eq.ntyp1).or. &
8616 (itype(i-3,1).eq.ntyp1)))) cycle
8617 if ((intertyp.eq.2).and.(i.eq.4).and.(itype(1,1).eq.ntyp1)) cycle
8618 if ((intertyp.eq.1).and.(i.eq.nres).and.(itype(nres,1).eq.ntyp1)) &
8620 do j=1,nterm_sccor(isccori,isccori1)
8621 v1ij=v1sccor(j,intertyp,isccori,isccori1)
8622 v2ij=v2sccor(j,intertyp,isccori,isccori1)
8623 cosphi=dcos(j*tauangle(intertyp,i))
8624 sinphi=dsin(j*tauangle(intertyp,i))
8625 if (energy_dec) esccor_ii=esccor_ii+v1ij*cosphi+v2ij*sinphi
8626 esccor=esccor+v1ij*cosphi+v2ij*sinphi
8627 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
8629 if (energy_dec) write (iout,'(a6,i5,i2,0pf7.3)') &
8630 'esccor',i,intertyp,esccor_ii
8631 ! write (iout,*) "EBACK_SC_COR",i,v1ij*cosphi+v2ij*sinphi,intertyp
8632 gloc_sc(intertyp,i-3,icg)=gloc_sc(intertyp,i-3,icg)+wsccor*gloci
8634 write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)') &
8635 restyp(itype(i-2,1),1),i-2,restyp(itype(i-1,1),1),i-1,isccori,isccori1,&
8636 (v1sccor(j,intertyp,isccori,isccori1),j=1,6),&
8637 (v2sccor(j,intertyp,isccori,isccori1),j=1,6)
8638 gsccor_loc(i-3)=gsccor_loc(i-3)+gloci
8643 end subroutine eback_sc_corr
8644 !-----------------------------------------------------------------------------
8645 subroutine multibody(ecorr)
8646 ! This subroutine calculates multi-body contributions to energy following
8647 ! the idea of Skolnick et al. If side chains I and J make a contact and
8648 ! at the same time side chains I+1 and J+1 make a contact, an extra
8649 ! contribution equal to sqrt(eps(i,j)*eps(i+1,j+1)) is added.
8650 ! implicit real(kind=8) (a-h,o-z)
8651 ! include 'DIMENSIONS'
8652 ! include 'COMMON.IOUNITS'
8653 ! include 'COMMON.DERIV'
8654 ! include 'COMMON.INTERACT'
8655 ! include 'COMMON.CONTACTS'
8656 real(kind=8),dimension(3) :: gx,gx1
8658 real(kind=8) :: ecorr
8659 integer :: i,j,ishift,i1,num_conti,num_conti1,j1,jj,kk
8660 ! Set lprn=.true. for debugging
8664 write (iout,'(a)') 'Contact function values:'
8666 write (iout,'(i2,20(1x,i2,f10.5))') &
8667 i,(jcont(j,i),facont(j,i),j=1,num_cont(i))
8672 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres))
8673 ! if (.not.allocated(gradxorr)) allocate(gradxorr(3,nres))
8685 num_conti=num_cont(i)
8686 num_conti1=num_cont(i1)
8691 if (j1.eq.j+ishift .or. j1.eq.j-ishift) then
8692 !d write(iout,*)'i=',i,' j=',j,' i1=',i1,' j1=',j1,
8693 !d & ' ishift=',ishift
8694 ! Contacts I--J and I+ISHIFT--J+-ISHIFT1 occur simultaneously.
8695 ! The system gains extra energy.
8696 ecorr=ecorr+esccorr(i,j,i1,j1,jj,kk)
8697 endif ! j1==j+-ishift
8705 end subroutine multibody
8706 !-----------------------------------------------------------------------------
8707 real(kind=8) function esccorr(i,j,k,l,jj,kk)
8708 ! implicit real(kind=8) (a-h,o-z)
8709 ! include 'DIMENSIONS'
8710 ! include 'COMMON.IOUNITS'
8711 ! include 'COMMON.DERIV'
8712 ! include 'COMMON.INTERACT'
8713 ! include 'COMMON.CONTACTS'
8714 real(kind=8),dimension(3) :: gx,gx1
8716 integer :: i,j,k,l,jj,kk,m,ll
8717 real(kind=8) :: eij,ekl
8721 !d write (iout,'(4i5,3f10.5)') i,j,k,l,eij,ekl,-eij*ekl
8722 ! Calculate the multi-body contribution to energy.
8723 ! Calculate multi-body contributions to the gradient.
8724 !d write (iout,'(2(2i3,3f10.5))')i,j,(gacont(m,jj,i),m=1,3),
8725 !d & k,l,(gacont(m,kk,k),m=1,3)
8727 gx(m) =ekl*gacont(m,jj,i)
8728 gx1(m)=eij*gacont(m,kk,k)
8729 gradxorr(m,i)=gradxorr(m,i)-gx(m)
8730 gradxorr(m,j)=gradxorr(m,j)+gx(m)
8731 gradxorr(m,k)=gradxorr(m,k)-gx1(m)
8732 gradxorr(m,l)=gradxorr(m,l)+gx1(m)
8736 gradcorr(ll,m)=gradcorr(ll,m)+gx(ll)
8741 gradcorr(ll,m)=gradcorr(ll,m)+gx1(ll)
8746 end function esccorr
8747 !-----------------------------------------------------------------------------
8748 subroutine multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
8749 ! This subroutine calculates multi-body contributions to hydrogen-bonding
8750 ! implicit real(kind=8) (a-h,o-z)
8751 ! include 'DIMENSIONS'
8752 ! include 'COMMON.IOUNITS'
8755 ! integer :: maxconts !max_cont=maxconts =nres/4
8756 integer,parameter :: max_dim=26
8757 integer :: source,CorrelType,CorrelID,CorrelType1,CorrelID1,Error
8758 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
8759 !el real(kind=8) :: zapas(max_dim,maxconts,nfgtasks)
8760 !el common /przechowalnia/ zapas
8761 integer :: status(MPI_STATUS_SIZE)
8762 integer,dimension((nres/4)*2) :: req !maxconts*2
8763 integer :: status_array(MPI_STATUS_SIZE,(nres/4)*2),nn,ireq,ierr
8765 ! include 'COMMON.SETUP'
8766 ! include 'COMMON.FFIELD'
8767 ! include 'COMMON.DERIV'
8768 ! include 'COMMON.INTERACT'
8769 ! include 'COMMON.CONTACTS'
8770 ! include 'COMMON.CONTROL'
8771 ! include 'COMMON.LOCAL'
8772 real(kind=8),dimension(3) :: gx,gx1
8773 real(kind=8) :: time00,ecorr,ecorr5,ecorr6
8774 logical :: lprn,ldone
8776 integer :: i,j,ii,k,n_corr,n_corr1,i1,num_conti,num_conti1,&
8777 jj,jp,kk,j1,jp1,jjc,iii,nnn,iproc
8779 ! Set lprn=.true. for debugging
8783 if(.not.allocated(zapas)) allocate(zapas(max_dim,maxconts,nfgtasks))
8786 if (nfgtasks.le.1) goto 30
8788 write (iout,'(a)') 'Contact function values before RECEIVE:'
8790 write (iout,'(2i3,50(1x,i2,f5.2))') &
8791 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
8796 do i=1,ntask_cont_from
8799 do i=1,ntask_cont_to
8802 ! write (iout,*) "ntask_cont_from",ntask_cont_from," ntask_cont_to",
8804 ! Make the list of contacts to send to send to other procesors
8805 ! write (iout,*) "limits",max0(iturn4_end-1,iatel_s),iturn3_end
8807 do i=iturn3_start,iturn3_end
8808 ! write (iout,*) "make contact list turn3",i," num_cont",
8810 call add_hb_contact(i,i+2,iturn3_sent_local(1,i))
8812 do i=iturn4_start,iturn4_end
8813 ! write (iout,*) "make contact list turn4",i," num_cont",
8815 call add_hb_contact(i,i+3,iturn4_sent_local(1,i))
8819 ! write (iout,*) "make contact list longrange",i,ii," num_cont",
8821 do j=1,num_cont_hb(i)
8824 iproc=iint_sent_local(k,jjc,ii)
8825 ! write (iout,*) "i",i," j",j," k",k," jjc",jjc," iproc",iproc
8826 if (iproc.gt.0) then
8827 ncont_sent(iproc)=ncont_sent(iproc)+1
8828 nn=ncont_sent(iproc)
8830 zapas(2,nn,iproc)=jjc
8831 zapas(3,nn,iproc)=facont_hb(j,i)
8832 zapas(4,nn,iproc)=ees0p(j,i)
8833 zapas(5,nn,iproc)=ees0m(j,i)
8834 zapas(6,nn,iproc)=gacont_hbr(1,j,i)
8835 zapas(7,nn,iproc)=gacont_hbr(2,j,i)
8836 zapas(8,nn,iproc)=gacont_hbr(3,j,i)
8837 zapas(9,nn,iproc)=gacontm_hb1(1,j,i)
8838 zapas(10,nn,iproc)=gacontm_hb1(2,j,i)
8839 zapas(11,nn,iproc)=gacontm_hb1(3,j,i)
8840 zapas(12,nn,iproc)=gacontp_hb1(1,j,i)
8841 zapas(13,nn,iproc)=gacontp_hb1(2,j,i)
8842 zapas(14,nn,iproc)=gacontp_hb1(3,j,i)
8843 zapas(15,nn,iproc)=gacontm_hb2(1,j,i)
8844 zapas(16,nn,iproc)=gacontm_hb2(2,j,i)
8845 zapas(17,nn,iproc)=gacontm_hb2(3,j,i)
8846 zapas(18,nn,iproc)=gacontp_hb2(1,j,i)
8847 zapas(19,nn,iproc)=gacontp_hb2(2,j,i)
8848 zapas(20,nn,iproc)=gacontp_hb2(3,j,i)
8849 zapas(21,nn,iproc)=gacontm_hb3(1,j,i)
8850 zapas(22,nn,iproc)=gacontm_hb3(2,j,i)
8851 zapas(23,nn,iproc)=gacontm_hb3(3,j,i)
8852 zapas(24,nn,iproc)=gacontp_hb3(1,j,i)
8853 zapas(25,nn,iproc)=gacontp_hb3(2,j,i)
8854 zapas(26,nn,iproc)=gacontp_hb3(3,j,i)
8861 "Numbers of contacts to be sent to other processors",&
8862 (ncont_sent(i),i=1,ntask_cont_to)
8863 write (iout,*) "Contacts sent"
8864 do ii=1,ntask_cont_to
8866 iproc=itask_cont_to(ii)
8867 write (iout,*) nn," contacts to processor",iproc,&
8868 " of CONT_TO_COMM group"
8870 write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
8878 CorrelID1=nfgtasks+fg_rank+1
8880 ! Receive the numbers of needed contacts from other processors
8881 do ii=1,ntask_cont_from
8882 iproc=itask_cont_from(ii)
8884 call MPI_Irecv(ncont_recv(ii),1,MPI_INTEGER,iproc,CorrelType,&
8885 FG_COMM,req(ireq),IERR)
8887 ! write (iout,*) "IRECV ended"
8889 ! Send the number of contacts needed by other processors
8890 do ii=1,ntask_cont_to
8891 iproc=itask_cont_to(ii)
8893 call MPI_Isend(ncont_sent(ii),1,MPI_INTEGER,iproc,CorrelType,&
8894 FG_COMM,req(ireq),IERR)
8896 ! write (iout,*) "ISEND ended"
8897 ! write (iout,*) "number of requests (nn)",ireq
8900 call MPI_Waitall(ireq,req,status_array,ierr)
8902 ! & "Numbers of contacts to be received from other processors",
8903 ! & (ncont_recv(i),i=1,ntask_cont_from)
8907 do ii=1,ntask_cont_from
8908 iproc=itask_cont_from(ii)
8910 ! write (iout,*) "Receiving",nn," contacts from processor",iproc,
8911 ! & " of CONT_TO_COMM group"
8915 call MPI_Irecv(zapas_recv(1,1,ii),nn*max_dim,&
8916 MPI_DOUBLE_PRECISION,iproc,CorrelType1,FG_COMM,req(ireq),IERR)
8917 ! write (iout,*) "ireq,req",ireq,req(ireq)
8920 ! Send the contacts to processors that need them
8921 do ii=1,ntask_cont_to
8922 iproc=itask_cont_to(ii)
8924 ! write (iout,*) nn," contacts to processor",iproc,
8925 ! & " of CONT_TO_COMM group"
8928 call MPI_Isend(zapas(1,1,ii),nn*max_dim,MPI_DOUBLE_PRECISION,&
8929 iproc,CorrelType1,FG_COMM,req(ireq),IERR)
8930 ! write (iout,*) "ireq,req",ireq,req(ireq)
8932 ! write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
8936 ! write (iout,*) "number of requests (contacts)",ireq
8937 ! write (iout,*) "req",(req(i),i=1,4)
8940 call MPI_Waitall(ireq,req,status_array,ierr)
8941 do iii=1,ntask_cont_from
8942 iproc=itask_cont_from(iii)
8945 write (iout,*) "Received",nn," contacts from processor",iproc,&
8946 " of CONT_FROM_COMM group"
8949 write(iout,'(2f5.0,4f10.5)')(zapas_recv(j,i,iii),j=1,5)
8954 ii=zapas_recv(1,i,iii)
8955 ! Flag the received contacts to prevent double-counting
8956 jj=-zapas_recv(2,i,iii)
8957 ! write (iout,*) "iii",iii," i",i," ii",ii," jj",jj
8959 nnn=num_cont_hb(ii)+1
8962 facont_hb(nnn,ii)=zapas_recv(3,i,iii)
8963 ees0p(nnn,ii)=zapas_recv(4,i,iii)
8964 ees0m(nnn,ii)=zapas_recv(5,i,iii)
8965 gacont_hbr(1,nnn,ii)=zapas_recv(6,i,iii)
8966 gacont_hbr(2,nnn,ii)=zapas_recv(7,i,iii)
8967 gacont_hbr(3,nnn,ii)=zapas_recv(8,i,iii)
8968 gacontm_hb1(1,nnn,ii)=zapas_recv(9,i,iii)
8969 gacontm_hb1(2,nnn,ii)=zapas_recv(10,i,iii)
8970 gacontm_hb1(3,nnn,ii)=zapas_recv(11,i,iii)
8971 gacontp_hb1(1,nnn,ii)=zapas_recv(12,i,iii)
8972 gacontp_hb1(2,nnn,ii)=zapas_recv(13,i,iii)
8973 gacontp_hb1(3,nnn,ii)=zapas_recv(14,i,iii)
8974 gacontm_hb2(1,nnn,ii)=zapas_recv(15,i,iii)
8975 gacontm_hb2(2,nnn,ii)=zapas_recv(16,i,iii)
8976 gacontm_hb2(3,nnn,ii)=zapas_recv(17,i,iii)
8977 gacontp_hb2(1,nnn,ii)=zapas_recv(18,i,iii)
8978 gacontp_hb2(2,nnn,ii)=zapas_recv(19,i,iii)
8979 gacontp_hb2(3,nnn,ii)=zapas_recv(20,i,iii)
8980 gacontm_hb3(1,nnn,ii)=zapas_recv(21,i,iii)
8981 gacontm_hb3(2,nnn,ii)=zapas_recv(22,i,iii)
8982 gacontm_hb3(3,nnn,ii)=zapas_recv(23,i,iii)
8983 gacontp_hb3(1,nnn,ii)=zapas_recv(24,i,iii)
8984 gacontp_hb3(2,nnn,ii)=zapas_recv(25,i,iii)
8985 gacontp_hb3(3,nnn,ii)=zapas_recv(26,i,iii)
8990 write (iout,'(a)') 'Contact function values after receive:'
8992 write (iout,'(2i3,50(1x,i3,f5.2))') &
8993 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
9001 write (iout,'(a)') 'Contact function values:'
9003 write (iout,'(2i3,50(1x,i3,f5.2))') &
9004 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
9010 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres))
9011 ! if (.not.allocated(gradxorr)) allocate(gradxorr(3,nres))
9012 ! Remove the loop below after debugging !!!
9019 ! Calculate the local-electrostatic correlation terms
9020 do i=min0(iatel_s,iturn4_start),max0(iatel_e,iturn3_end)
9022 num_conti=num_cont_hb(i)
9023 num_conti1=num_cont_hb(i+1)
9030 ! write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,&
9031 ! ' jj=',jj,' kk=',kk,"jp=",jp,"jp1",jp1
9032 if ((j.gt.0 .and. j1.gt.0 .or. j.gt.0 .and. j1.lt.0 &
9033 .or. j.lt.0 .and. j1.gt.0) .and. &
9034 (jp1.eq.jp+1 .or. jp1.eq.jp-1)) then
9035 ! Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
9036 ! The system gains extra energy.
9037 ecorr=ecorr+ehbcorr(i,jp,i+1,jp1,jj,kk,0.72D0,0.32D0)
9038 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
9039 'ecorrh',i,j,ehbcorr(i,jp,i+1,jp1,jj,kk,0.72D0,0.32D0)
9041 else if (j1.eq.j) then
9042 ! Contacts I-J and I-(J+1) occur simultaneously.
9043 ! The system loses extra energy.
9044 ! ecorr=ecorr+ehbcorr(i,j,i+1,j,jj,kk,0.60D0,-0.40D0)
9049 ! write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
9050 ! & ' jj=',jj,' kk=',kk
9052 ! Contacts I-J and (I+1)-J occur simultaneously.
9053 ! The system loses extra energy.
9054 ! ecorr=ecorr+ehbcorr(i,j,i,j+1,jj,kk,0.60D0,-0.40D0)
9060 end subroutine multibody_hb
9061 !-----------------------------------------------------------------------------
9062 subroutine add_hb_contact(ii,jj,itask)
9063 ! implicit real(kind=8) (a-h,o-z)
9064 ! include "DIMENSIONS"
9065 ! include "COMMON.IOUNITS"
9066 ! include "COMMON.CONTACTS"
9067 ! integer,parameter :: maxconts=nres/4
9068 integer,parameter :: max_dim=26
9069 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
9070 ! real(kind=8) :: zapas(max_dim,maxconts,nfgtasks)
9071 ! common /przechowalnia/ zapas
9072 integer :: i,j,ii,jj,iproc,nn,jjc
9073 integer,dimension(4) :: itask
9074 ! write (iout,*) "itask",itask
9077 if (iproc.gt.0) then
9078 do j=1,num_cont_hb(ii)
9080 ! write (iout,*) "i",ii," j",jj," jjc",jjc
9082 ncont_sent(iproc)=ncont_sent(iproc)+1
9083 nn=ncont_sent(iproc)
9084 zapas(1,nn,iproc)=ii
9085 zapas(2,nn,iproc)=jjc
9086 zapas(3,nn,iproc)=facont_hb(j,ii)
9087 zapas(4,nn,iproc)=ees0p(j,ii)
9088 zapas(5,nn,iproc)=ees0m(j,ii)
9089 zapas(6,nn,iproc)=gacont_hbr(1,j,ii)
9090 zapas(7,nn,iproc)=gacont_hbr(2,j,ii)
9091 zapas(8,nn,iproc)=gacont_hbr(3,j,ii)
9092 zapas(9,nn,iproc)=gacontm_hb1(1,j,ii)
9093 zapas(10,nn,iproc)=gacontm_hb1(2,j,ii)
9094 zapas(11,nn,iproc)=gacontm_hb1(3,j,ii)
9095 zapas(12,nn,iproc)=gacontp_hb1(1,j,ii)
9096 zapas(13,nn,iproc)=gacontp_hb1(2,j,ii)
9097 zapas(14,nn,iproc)=gacontp_hb1(3,j,ii)
9098 zapas(15,nn,iproc)=gacontm_hb2(1,j,ii)
9099 zapas(16,nn,iproc)=gacontm_hb2(2,j,ii)
9100 zapas(17,nn,iproc)=gacontm_hb2(3,j,ii)
9101 zapas(18,nn,iproc)=gacontp_hb2(1,j,ii)
9102 zapas(19,nn,iproc)=gacontp_hb2(2,j,ii)
9103 zapas(20,nn,iproc)=gacontp_hb2(3,j,ii)
9104 zapas(21,nn,iproc)=gacontm_hb3(1,j,ii)
9105 zapas(22,nn,iproc)=gacontm_hb3(2,j,ii)
9106 zapas(23,nn,iproc)=gacontm_hb3(3,j,ii)
9107 zapas(24,nn,iproc)=gacontp_hb3(1,j,ii)
9108 zapas(25,nn,iproc)=gacontp_hb3(2,j,ii)
9109 zapas(26,nn,iproc)=gacontp_hb3(3,j,ii)
9116 end subroutine add_hb_contact
9117 !-----------------------------------------------------------------------------
9118 subroutine multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
9119 ! This subroutine calculates multi-body contributions to hydrogen-bonding
9120 ! implicit real(kind=8) (a-h,o-z)
9121 ! include 'DIMENSIONS'
9122 ! include 'COMMON.IOUNITS'
9123 integer,parameter :: max_dim=70
9126 ! integer :: maxconts !max_cont=maxconts=nres/4
9127 integer :: source,CorrelType,CorrelID,CorrelType1,CorrelID1,Error
9128 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks)
9129 ! real(kind=8) :: zapas(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
9130 ! common /przechowalnia/ zapas
9131 integer :: status(MPI_STATUS_SIZE),req((nres/4)*2),&
9132 status_array(MPI_STATUS_SIZE,(nres/4)*2),jjc,iproc,ireq,nn,ind,&
9135 ! include 'COMMON.SETUP'
9136 ! include 'COMMON.FFIELD'
9137 ! include 'COMMON.DERIV'
9138 ! include 'COMMON.LOCAL'
9139 ! include 'COMMON.INTERACT'
9140 ! include 'COMMON.CONTACTS'
9141 ! include 'COMMON.CHAIN'
9142 ! include 'COMMON.CONTROL'
9143 real(kind=8),dimension(3) :: gx,gx1
9144 integer,dimension(nres) :: num_cont_hb_old
9145 logical :: lprn,ldone
9146 !EL double precision eello4,eello5,eelo6,eello_turn6
9147 !EL external eello4,eello5,eello6,eello_turn6
9149 integer :: i,ii,j,k,l,jj,kk,ll,mm,n_corr,n_corr1,num_conti,jp,&
9150 j1,jp1,i1,num_conti1
9151 real(kind=8) :: sqd1,sqd2,sred_geom,fac_prim1,fac_prim2,fprimcont
9152 real(kind=8) :: ecorr,ecorr5,ecorr6,eturn6
9154 ! Set lprn=.true. for debugging
9159 if(.not.allocated(zapas)) allocate(zapas(max_dim,maxconts,nfgtasks))
9161 num_cont_hb_old(i)=num_cont_hb(i)
9165 if (nfgtasks.le.1) goto 30
9167 write (iout,'(a)') 'Contact function values before RECEIVE:'
9169 write (iout,'(2i3,50(1x,i2,f5.2))') &
9170 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i),&
9175 do i=1,ntask_cont_from
9178 do i=1,ntask_cont_to
9181 ! write (iout,*) "ntask_cont_from",ntask_cont_from," ntask_cont_to",
9183 ! Make the list of contacts to send to send to other procesors
9184 do i=iturn3_start,iturn3_end
9185 ! write (iout,*) "make contact list turn3",i," num_cont",
9187 call add_hb_contact_eello(i,i+2,iturn3_sent_local(1,i))
9189 do i=iturn4_start,iturn4_end
9190 ! write (iout,*) "make contact list turn4",i," num_cont",
9192 call add_hb_contact_eello(i,i+3,iturn4_sent_local(1,i))
9196 ! write (iout,*) "make contact list longrange",i,ii," num_cont",
9198 do j=1,num_cont_hb(i)
9201 iproc=iint_sent_local(k,jjc,ii)
9202 ! write (iout,*) "i",i," j",j," k",k," jjc",jjc," iproc",iproc
9203 if (iproc.ne.0) then
9204 ncont_sent(iproc)=ncont_sent(iproc)+1
9205 nn=ncont_sent(iproc)
9207 zapas(2,nn,iproc)=jjc
9208 zapas(3,nn,iproc)=d_cont(j,i)
9212 zapas(ind,nn,iproc)=grij_hb_cont(kk,j,i)
9217 zapas(ind,nn,iproc)=a_chuj(ll,kk,j,i)
9225 zapas(ind,nn,iproc)=a_chuj_der(mm,ll,kk,jj,j,i)
9236 "Numbers of contacts to be sent to other processors",&
9237 (ncont_sent(i),i=1,ntask_cont_to)
9238 write (iout,*) "Contacts sent"
9239 do ii=1,ntask_cont_to
9241 iproc=itask_cont_to(ii)
9242 write (iout,*) nn," contacts to processor",iproc,&
9243 " of CONT_TO_COMM group"
9245 write(iout,'(2f5.0,10f10.5)')(zapas(j,i,ii),j=1,10)
9253 CorrelID1=nfgtasks+fg_rank+1
9255 ! Receive the numbers of needed contacts from other processors
9256 do ii=1,ntask_cont_from
9257 iproc=itask_cont_from(ii)
9259 call MPI_Irecv(ncont_recv(ii),1,MPI_INTEGER,iproc,CorrelType,&
9260 FG_COMM,req(ireq),IERR)
9262 ! write (iout,*) "IRECV ended"
9264 ! Send the number of contacts needed by other processors
9265 do ii=1,ntask_cont_to
9266 iproc=itask_cont_to(ii)
9268 call MPI_Isend(ncont_sent(ii),1,MPI_INTEGER,iproc,CorrelType,&
9269 FG_COMM,req(ireq),IERR)
9271 ! write (iout,*) "ISEND ended"
9272 ! write (iout,*) "number of requests (nn)",ireq
9275 call MPI_Waitall(ireq,req,status_array,ierr)
9277 ! & "Numbers of contacts to be received from other processors",
9278 ! & (ncont_recv(i),i=1,ntask_cont_from)
9282 do ii=1,ntask_cont_from
9283 iproc=itask_cont_from(ii)
9285 ! write (iout,*) "Receiving",nn," contacts from processor",iproc,
9286 ! & " of CONT_TO_COMM group"
9290 call MPI_Irecv(zapas_recv(1,1,ii),nn*max_dim,&
9291 MPI_DOUBLE_PRECISION,iproc,CorrelType1,FG_COMM,req(ireq),IERR)
9292 ! write (iout,*) "ireq,req",ireq,req(ireq)
9295 ! Send the contacts to processors that need them
9296 do ii=1,ntask_cont_to
9297 iproc=itask_cont_to(ii)
9299 ! write (iout,*) nn," contacts to processor",iproc,
9300 ! & " of CONT_TO_COMM group"
9303 call MPI_Isend(zapas(1,1,ii),nn*max_dim,MPI_DOUBLE_PRECISION,&
9304 iproc,CorrelType1,FG_COMM,req(ireq),IERR)
9305 ! write (iout,*) "ireq,req",ireq,req(ireq)
9307 ! write(iout,'(2f5.0,4f10.5)')(zapas(j,i,ii),j=1,5)
9311 ! write (iout,*) "number of requests (contacts)",ireq
9312 ! write (iout,*) "req",(req(i),i=1,4)
9315 call MPI_Waitall(ireq,req,status_array,ierr)
9316 do iii=1,ntask_cont_from
9317 iproc=itask_cont_from(iii)
9320 write (iout,*) "Received",nn," contacts from processor",iproc,&
9321 " of CONT_FROM_COMM group"
9324 write(iout,'(2f5.0,10f10.5)')(zapas_recv(j,i,iii),j=1,10)
9329 ii=zapas_recv(1,i,iii)
9330 ! Flag the received contacts to prevent double-counting
9331 jj=-zapas_recv(2,i,iii)
9332 ! write (iout,*) "iii",iii," i",i," ii",ii," jj",jj
9334 nnn=num_cont_hb(ii)+1
9337 d_cont(nnn,ii)=zapas_recv(3,i,iii)
9341 grij_hb_cont(kk,nnn,ii)=zapas_recv(ind,i,iii)
9346 a_chuj(ll,kk,nnn,ii)=zapas_recv(ind,i,iii)
9354 a_chuj_der(mm,ll,kk,jj,nnn,ii)=zapas_recv(ind,i,iii)
9363 write (iout,'(a)') 'Contact function values after receive:'
9365 write (iout,'(2i3,50(1x,i3,5f6.3))') &
9366 i,num_cont_hb(i),(jcont_hb(j,i),d_cont(j,i),&
9367 ((a_chuj(ll,kk,j,i),ll=1,2),kk=1,2),j=1,num_cont_hb(i))
9374 write (iout,'(a)') 'Contact function values:'
9376 write (iout,'(2i3,50(1x,i2,5f6.3))') &
9377 i,num_cont_hb(i),(jcont_hb(j,i),d_cont(j,i),&
9378 ((a_chuj(ll,kk,j,i),ll=1,2),kk=1,2),j=1,num_cont_hb(i))
9385 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres))
9386 ! if (.not.allocated(gradxorr)) allocate(gradxorr(3,nres))
9387 ! Remove the loop below after debugging !!!
9394 ! Calculate the dipole-dipole interaction energies
9395 if (wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) then
9396 do i=iatel_s,iatel_e+1
9397 num_conti=num_cont_hb(i)
9406 ! Calculate the local-electrostatic correlation terms
9407 ! write (iout,*) "gradcorr5 in eello5 before loop"
9409 ! write (iout,'(i5,3f10.5)')
9410 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
9412 do i=min0(iatel_s,iturn4_start),max0(iatel_e+1,iturn3_end+1)
9413 ! write (iout,*) "corr loop i",i
9415 num_conti=num_cont_hb(i)
9416 num_conti1=num_cont_hb(i+1)
9423 ! write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
9424 ! & ' jj=',jj,' kk=',kk
9425 ! if (j1.eq.j+1 .or. j1.eq.j-1) then
9426 if ((j.gt.0 .and. j1.gt.0 .or. j.gt.0 .and. j1.lt.0 &
9427 .or. j.lt.0 .and. j1.gt.0) .and. &
9428 (jp1.eq.jp+1 .or. jp1.eq.jp-1)) then
9429 ! Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
9430 ! The system gains extra energy.
9432 sqd1=dsqrt(d_cont(jj,i))
9433 sqd2=dsqrt(d_cont(kk,i1))
9434 sred_geom = sqd1*sqd2
9435 IF (sred_geom.lt.cutoff_corr) THEN
9436 call gcont(sred_geom,r0_corr,1.0D0,delt_corr,&
9438 !d write (iout,*) 'i=',i,' j=',jp,' i1=',i1,' j1=',jp1,
9439 !d & ' jj=',jj,' kk=',kk
9440 fac_prim1=0.5d0*sqd2/sqd1*fprimcont
9441 fac_prim2=0.5d0*sqd1/sqd2*fprimcont
9443 g_contij(l,1)=fac_prim1*grij_hb_cont(l,jj,i)
9444 g_contij(l,2)=fac_prim2*grij_hb_cont(l,kk,i1)
9447 !d write (iout,*) 'sred_geom=',sred_geom,
9448 !d & ' ekont=',ekont,' fprim=',fprimcont,
9449 !d & ' fac_prim1',fac_prim1,' fac_prim2',fac_prim2
9450 !d write (iout,*) "g_contij",g_contij
9451 !d write (iout,*) "grij_hb_cont i",grij_hb_cont(:,jj,i)
9452 !d write (iout,*) "grij_hb_cont i1",grij_hb_cont(:,jj,i1)
9453 call calc_eello(i,jp,i+1,jp1,jj,kk)
9454 if (wcorr4.gt.0.0d0) &
9455 ecorr=ecorr+eello4(i,jp,i+1,jp1,jj,kk)
9456 if (energy_dec.and.wcorr4.gt.0.0d0) &
9457 write (iout,'(a6,4i5,0pf7.3)') &
9458 'ecorr4',i,j,i+1,j1,eello4(i,jp,i+1,jp1,jj,kk)
9459 ! write (iout,*) "gradcorr5 before eello5"
9461 ! write (iout,'(i5,3f10.5)')
9462 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
9464 if (wcorr5.gt.0.0d0) &
9465 ecorr5=ecorr5+eello5(i,jp,i+1,jp1,jj,kk)
9466 ! write (iout,*) "gradcorr5 after eello5"
9468 ! write (iout,'(i5,3f10.5)')
9469 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
9471 if (energy_dec.and.wcorr5.gt.0.0d0) &
9472 write (iout,'(a6,4i5,0pf7.3)') &
9473 'ecorr5',i,j,i+1,j1,eello5(i,jp,i+1,jp1,jj,kk)
9474 !d write(2,*)'wcorr6',wcorr6,' wturn6',wturn6
9475 !d write(2,*)'ijkl',i,jp,i+1,jp1
9476 if (wcorr6.gt.0.0d0 .and. (jp.ne.i+4 .or. jp1.ne.i+3 &
9477 .or. wturn6.eq.0.0d0))then
9478 !d write (iout,*) '******ecorr6: i,j,i+1,j1',i,j,i+1,j1
9479 ecorr6=ecorr6+eello6(i,jp,i+1,jp1,jj,kk)
9480 if (energy_dec) write (iout,'(a6,4i5,0pf7.3)') &
9481 'ecorr6',i,j,i+1,j1,eello6(i,jp,i+1,jp1,jj,kk)
9482 !d write (iout,*) 'ecorr',ecorr,' ecorr5=',ecorr5,
9483 !d & 'ecorr6=',ecorr6
9484 !d write (iout,'(4e15.5)') sred_geom,
9485 !d & dabs(eello4(i,jp,i+1,jp1,jj,kk)),
9486 !d & dabs(eello5(i,jp,i+1,jp1,jj,kk)),
9487 !d & dabs(eello6(i,jp,i+1,jp1,jj,kk))
9488 else if (wturn6.gt.0.0d0 &
9489 .and. (jp.eq.i+4 .and. jp1.eq.i+3)) then
9490 !d write (iout,*) '******eturn6: i,j,i+1,j1',i,jip,i+1,jp1
9491 eturn6=eturn6+eello_turn6(i,jj,kk)
9492 if (energy_dec) write (iout,'(a6,4i5,0pf7.3)') &
9493 'eturn6',i,j,i+1,j1,eello_turn6(i,jj,kk)
9494 !d write (2,*) 'multibody_eello:eturn6',eturn6
9503 num_cont_hb(i)=num_cont_hb_old(i)
9505 ! write (iout,*) "gradcorr5 in eello5"
9507 ! write (iout,'(i5,3f10.5)')
9508 ! & iii,(gradcorr5(jjj,iii),jjj=1,3)
9511 end subroutine multibody_eello
9512 !-----------------------------------------------------------------------------
9513 subroutine add_hb_contact_eello(ii,jj,itask)
9514 ! implicit real(kind=8) (a-h,o-z)
9515 ! include "DIMENSIONS"
9516 ! include "COMMON.IOUNITS"
9517 ! include "COMMON.CONTACTS"
9518 ! integer,parameter :: maxconts=nres/4
9519 integer,parameter :: max_dim=70
9520 real(kind=8) :: zapas_recv(max_dim,maxconts,nfgtasks)
9521 ! real(kind=8) :: zapas(max_dim,maxconts,nfgtasks) !(max_dim,maxconts,max_fg_procs)
9522 ! common /przechowalnia/ zapas
9524 integer :: i,j,ii,jj,iproc,nn,ind,jjc,kk,ll,mm
9525 integer,dimension(4) ::itask
9526 ! write (iout,*) "itask",itask
9529 if (iproc.gt.0) then
9530 do j=1,num_cont_hb(ii)
9532 ! write (iout,*) "send turns i",ii," j",jj," jjc",jjc
9534 ncont_sent(iproc)=ncont_sent(iproc)+1
9535 nn=ncont_sent(iproc)
9536 zapas(1,nn,iproc)=ii
9537 zapas(2,nn,iproc)=jjc
9538 zapas(3,nn,iproc)=d_cont(j,ii)
9542 zapas(ind,nn,iproc)=grij_hb_cont(kk,j,ii)
9547 zapas(ind,nn,iproc)=a_chuj(ll,kk,j,ii)
9555 zapas(ind,nn,iproc)=a_chuj_der(mm,ll,kk,jj,j,ii)
9566 end subroutine add_hb_contact_eello
9567 !-----------------------------------------------------------------------------
9568 real(kind=8) function ehbcorr(i,j,k,l,jj,kk,coeffp,coeffm)
9569 ! implicit real(kind=8) (a-h,o-z)
9570 ! include 'DIMENSIONS'
9571 ! include 'COMMON.IOUNITS'
9572 ! include 'COMMON.DERIV'
9573 ! include 'COMMON.INTERACT'
9574 ! include 'COMMON.CONTACTS'
9575 real(kind=8),dimension(3) :: gx,gx1
9578 integer :: i,j,k,l,jj,kk,ll,ilist,m, iresshield
9579 real(kind=8) :: coeffp,coeffm,eij,ekl,ees0pij,ees0pkl,ees0mij,&
9580 ees0mkl,ees,coeffpees0pij,coeffmees0mij,&
9581 coeffpees0pkl,coeffmees0mkl,gradlongij,gradlongkl, &
9592 ees=-(coeffp*ees0pij*ees0pkl+coeffm*ees0mij*ees0mkl)
9593 !d ees=-(coeffp*ees0pkl+coeffm*ees0mkl)
9594 ! Following 4 lines for diagnostics.
9599 ! write (iout,'(2(a,2i3,a,f10.5,a,2f10.5),a,f10.5,a,$)')
9600 ! & 'Contacts ',i,j,
9601 ! & ' eij',eij,' eesij',ees0pij,ees0mij,' and ',k,l
9602 ! & ,' fcont ',ekl,' eeskl',ees0pkl,ees0mkl,' energy=',ekont*ees,
9604 ! Calculate the multi-body contribution to energy.
9605 ! ecorr=ecorr+ekont*ees
9606 ! Calculate multi-body contributions to the gradient.
9607 coeffpees0pij=coeffp*ees0pij
9608 coeffmees0mij=coeffm*ees0mij
9609 coeffpees0pkl=coeffp*ees0pkl
9610 coeffmees0mkl=coeffm*ees0mkl
9612 !grad ghalfi=ees*ekl*gacont_hbr(ll,jj,i)
9613 gradcorr(ll,i)=gradcorr(ll,i) & !+0.5d0*ghalfi
9614 -ekont*(coeffpees0pkl*gacontp_hb1(ll,jj,i)+ &
9615 coeffmees0mkl*gacontm_hb1(ll,jj,i))
9616 gradcorr(ll,j)=gradcorr(ll,j) & !+0.5d0*ghalfi
9617 -ekont*(coeffpees0pkl*gacontp_hb2(ll,jj,i)+ &
9618 coeffmees0mkl*gacontm_hb2(ll,jj,i))
9619 !grad ghalfk=ees*eij*gacont_hbr(ll,kk,k)
9620 gradcorr(ll,k)=gradcorr(ll,k) & !+0.5d0*ghalfk
9621 -ekont*(coeffpees0pij*gacontp_hb1(ll,kk,k)+&
9622 coeffmees0mij*gacontm_hb1(ll,kk,k))
9623 gradcorr(ll,l)=gradcorr(ll,l) & !+0.5d0*ghalfk
9624 -ekont*(coeffpees0pij*gacontp_hb2(ll,kk,k)+ &
9625 coeffmees0mij*gacontm_hb2(ll,kk,k))
9626 gradlongij=ees*ekl*gacont_hbr(ll,jj,i)- &
9627 ekont*(coeffpees0pkl*gacontp_hb3(ll,jj,i)+ &
9628 coeffmees0mkl*gacontm_hb3(ll,jj,i))
9629 gradcorr_long(ll,j)=gradcorr_long(ll,j)+gradlongij
9630 gradcorr_long(ll,i)=gradcorr_long(ll,i)-gradlongij
9631 gradlongkl=ees*eij*gacont_hbr(ll,kk,k)- &
9632 ekont*(coeffpees0pij*gacontp_hb3(ll,kk,k)+ &
9633 coeffmees0mij*gacontm_hb3(ll,kk,k))
9634 gradcorr_long(ll,l)=gradcorr_long(ll,l)+gradlongkl
9635 gradcorr_long(ll,k)=gradcorr_long(ll,k)-gradlongkl
9636 ! write (iout,'(2f10.5,2x,$)') gradlongij,gradlongkl
9641 !grad gradcorr(ll,m)=gradcorr(ll,m)+
9642 !grad & ees*ekl*gacont_hbr(ll,jj,i)-
9643 !grad & ekont*(coeffp*ees0pkl*gacontp_hb3(ll,jj,i)+
9644 !grad & coeffm*ees0mkl*gacontm_hb3(ll,jj,i))
9649 !grad gradcorr(ll,m)=gradcorr(ll,m)+
9650 !grad & ees*eij*gacont_hbr(ll,kk,k)-
9651 !grad & ekont*(coeffp*ees0pij*gacontp_hb3(ll,kk,k)+
9652 !grad & coeffm*ees0mij*gacontm_hb3(ll,kk,k))
9655 ! write (iout,*) "ehbcorr",ekont*ees
9657 if (shield_mode.gt.0) then
9660 !C print *,i,j,fac_shield(i),fac_shield(j),
9661 !C &fac_shield(k),fac_shield(l)
9662 if ((fac_shield(i).gt.0).and.(fac_shield(j).gt.0).and. &
9663 (fac_shield(k).gt.0).and.(fac_shield(l).gt.0)) then
9664 do ilist=1,ishield_list(i)
9665 iresshield=shield_list(ilist,i)
9667 rlocshield=grad_shield_side(m,ilist,i)*ehbcorr/fac_shield(i)
9668 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+ &
9670 +grad_shield_loc(m,ilist,i)*ehbcorr/fac_shield(i)
9671 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1) &
9675 do ilist=1,ishield_list(j)
9676 iresshield=shield_list(ilist,j)
9678 rlocshield=grad_shield_side(m,ilist,j)*ehbcorr/fac_shield(j)
9679 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+ &
9681 +grad_shield_loc(m,ilist,j)*ehbcorr/fac_shield(j)
9682 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1) &
9687 do ilist=1,ishield_list(k)
9688 iresshield=shield_list(ilist,k)
9690 rlocshield=grad_shield_side(m,ilist,k)*ehbcorr/fac_shield(k)
9691 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+ &
9693 +grad_shield_loc(m,ilist,k)*ehbcorr/fac_shield(k)
9694 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1) &
9698 do ilist=1,ishield_list(l)
9699 iresshield=shield_list(ilist,l)
9701 rlocshield=grad_shield_side(m,ilist,l)*ehbcorr/fac_shield(l)
9702 gshieldx_ec(m,iresshield)=gshieldx_ec(m,iresshield)+ &
9704 +grad_shield_loc(m,ilist,l)*ehbcorr/fac_shield(l)
9705 gshieldc_ec(m,iresshield-1)=gshieldc_ec(m,iresshield-1) &
9710 gshieldc_ec(m,i)=gshieldc_ec(m,i)+ &
9711 grad_shield(m,i)*ehbcorr/fac_shield(i)
9712 gshieldc_ec(m,j)=gshieldc_ec(m,j)+ &
9713 grad_shield(m,j)*ehbcorr/fac_shield(j)
9714 gshieldc_ec(m,i-1)=gshieldc_ec(m,i-1)+ &
9715 grad_shield(m,i)*ehbcorr/fac_shield(i)
9716 gshieldc_ec(m,j-1)=gshieldc_ec(m,j-1)+ &
9717 grad_shield(m,j)*ehbcorr/fac_shield(j)
9719 gshieldc_ec(m,k)=gshieldc_ec(m,k)+ &
9720 grad_shield(m,k)*ehbcorr/fac_shield(k)
9721 gshieldc_ec(m,l)=gshieldc_ec(m,l)+ &
9722 grad_shield(m,l)*ehbcorr/fac_shield(l)
9723 gshieldc_ec(m,k-1)=gshieldc_ec(m,k-1)+ &
9724 grad_shield(m,k)*ehbcorr/fac_shield(k)
9725 gshieldc_ec(m,l-1)=gshieldc_ec(m,l-1)+ &
9726 grad_shield(m,l)*ehbcorr/fac_shield(l)
9732 end function ehbcorr
9734 !-----------------------------------------------------------------------------
9735 subroutine dipole(i,j,jj)
9736 ! implicit real(kind=8) (a-h,o-z)
9737 ! include 'DIMENSIONS'
9738 ! include 'COMMON.IOUNITS'
9739 ! include 'COMMON.CHAIN'
9740 ! include 'COMMON.FFIELD'
9741 ! include 'COMMON.DERIV'
9742 ! include 'COMMON.INTERACT'
9743 ! include 'COMMON.CONTACTS'
9744 ! include 'COMMON.TORSION'
9745 ! include 'COMMON.VAR'
9746 ! include 'COMMON.GEO'
9747 real(kind=8),dimension(2,2) :: dipi,dipj,auxmat
9748 real(kind=8),dimension(2) :: dipderi,dipderj,auxvec
9749 integer :: i,j,jj,iii,jjj,kkk,lll,iti1,itj1
9751 allocate(dip(4,maxconts,nres),dipderg(4,maxconts,nres))
9752 allocate(dipderx(3,5,4,maxconts,nres))
9755 iti1 = itortyp(itype(i+1,1))
9756 if (j.lt.nres-1) then
9757 itj1 = itype2loc(itype(j+1,1))
9762 dipi(iii,1)=Ub2(iii,i)
9763 dipderi(iii)=Ub2der(iii,i)
9764 dipi(iii,2)=b1(iii,iti1)
9765 dipj(iii,1)=Ub2(iii,j)
9766 dipderj(iii)=Ub2der(iii,j)
9767 dipj(iii,2)=b1(iii,itj1)
9771 call matvec2(a_chuj(1,1,jj,i),dipj(1,iii),auxvec(1))
9774 dip(kkk,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
9781 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),dipj(1,iii),&
9785 dipderx(lll,kkk,mmm,jj,i)=scalar2(dipi(1,jjj),auxvec(1))
9790 call transpose2(a_chuj(1,1,jj,i),auxmat(1,1))
9791 call matvec2(auxmat(1,1),dipderi(1),auxvec(1))
9793 dipderg(iii,jj,i)=scalar2(auxvec(1),dipj(1,iii))
9795 call matvec2(a_chuj(1,1,jj,i),dipderj(1),auxvec(1))
9797 dipderg(iii+2,jj,i)=scalar2(auxvec(1),dipi(1,iii))
9800 end subroutine dipole
9802 !-----------------------------------------------------------------------------
9803 subroutine calc_eello(i,j,k,l,jj,kk)
9805 ! This subroutine computes matrices and vectors needed to calculate
9806 ! the fourth-, fifth-, and sixth-order local-electrostatic terms.
9809 ! implicit real(kind=8) (a-h,o-z)
9810 ! include 'DIMENSIONS'
9811 ! include 'COMMON.IOUNITS'
9812 ! include 'COMMON.CHAIN'
9813 ! include 'COMMON.DERIV'
9814 ! include 'COMMON.INTERACT'
9815 ! include 'COMMON.CONTACTS'
9816 ! include 'COMMON.TORSION'
9817 ! include 'COMMON.VAR'
9818 ! include 'COMMON.GEO'
9819 ! include 'COMMON.FFIELD'
9820 real(kind=8),dimension(2,2) :: aa1,aa2,aa1t,aa2t,auxmat
9821 real(kind=8),dimension(2,2,3,5) :: aa1tder,aa2tder
9822 integer :: i,j,k,l,jj,kk,iii,jjj,kkk,lll,iti,itk1,itj,itl,itl1,&
9825 !el common /kutas/ lprn
9826 !d write (iout,*) 'calc_eello: i=',i,' j=',j,' k=',k,' l=',l,
9827 !d & ' jj=',jj,' kk=',kk
9828 !d if (i.ne.2 .or. j.ne.4 .or. k.ne.3 .or. l.ne.5) return
9829 !d write (iout,*) "a_chujij",((a_chuj(iii,jjj,jj,i),iii=1,2),jjj=1,2)
9830 !d write (iout,*) "a_chujkl",((a_chuj(iii,jjj,kk,k),iii=1,2),jjj=1,2)
9833 aa1(iii,jjj)=a_chuj(iii,jjj,jj,i)
9834 aa2(iii,jjj)=a_chuj(iii,jjj,kk,k)
9837 call transpose2(aa1(1,1),aa1t(1,1))
9838 call transpose2(aa2(1,1),aa2t(1,1))
9841 call transpose2(a_chuj_der(1,1,lll,kkk,jj,i),&
9842 aa1tder(1,1,lll,kkk))
9843 call transpose2(a_chuj_der(1,1,lll,kkk,kk,k),&
9844 aa2tder(1,1,lll,kkk))
9848 ! parallel orientation of the two CA-CA-CA frames.
9850 iti=itortyp(itype(i,1))
9854 itk1=itortyp(itype(k+1,1))
9855 itj=itortyp(itype(j,1))
9856 if (l.lt.nres-1) then
9857 itl1=itortyp(itype(l+1,1))
9861 ! A1 kernel(j+1) A2T
9863 !d write (iout,'(3f10.5,5x,3f10.5)')
9864 !d & (EUg(iii,jjj,k),jjj=1,2),(EUg(iii,jjj,l),jjj=1,2)
9866 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
9867 aa2tder(1,1,1,1),1,.false.,EUg(1,1,l),EUgder(1,1,l),&
9868 AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
9869 ! Following matrices are needed only for 6-th order cumulants
9870 IF (wcorr6.gt.0.0d0) THEN
9871 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
9872 aa2tder(1,1,1,1),1,.false.,EUgC(1,1,l),EUgCder(1,1,l),&
9873 AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
9874 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
9875 aa2tder(1,1,1,1),2,.false.,Ug2DtEUg(1,1,l),&
9876 Ug2DtEUgder(1,1,1,l),ADtEA(1,1,1),ADtEAderg(1,1,1,1),&
9877 ADtEAderx(1,1,1,1,1,1))
9879 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
9880 aa2tder(1,1,1,1),2,.false.,DtUg2EUg(1,1,l),&
9881 DtUg2EUgder(1,1,1,l),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),&
9882 ADtEA1derx(1,1,1,1,1,1))
9884 ! End 6-th order cumulants
9887 !d write (2,*) 'In calc_eello6'
9889 !d write (2,*) 'iii=',iii
9891 !d write (2,*) 'kkk=',kkk
9893 !d write (2,'(3(2f10.5),5x)')
9894 !d & ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
9899 call transpose2(EUgder(1,1,k),auxmat(1,1))
9900 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
9901 call transpose2(EUg(1,1,k),auxmat(1,1))
9902 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
9903 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
9907 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),&
9908 EAEAderx(1,1,lll,kkk,iii,1))
9912 ! A1T kernel(i+1) A2
9913 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
9914 a_chuj_der(1,1,1,1,kk,k),1,.false.,EUg(1,1,k),EUgder(1,1,k),&
9915 AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
9916 ! Following matrices are needed only for 6-th order cumulants
9917 IF (wcorr6.gt.0.0d0) THEN
9918 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
9919 a_chuj_der(1,1,1,1,kk,k),1,.false.,EUgC(1,1,k),EUgCder(1,1,k),&
9920 AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
9921 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
9922 a_chuj_der(1,1,1,1,kk,k),2,.false.,Ug2DtEUg(1,1,k),&
9923 Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),&
9924 ADtEAderx(1,1,1,1,1,2))
9925 call kernel(aa1t(1,1),aa2(1,1),aa1tder(1,1,1,1),&
9926 a_chuj_der(1,1,1,1,kk,k),2,.false.,DtUg2EUg(1,1,k),&
9927 DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),&
9928 ADtEA1derx(1,1,1,1,1,2))
9930 ! End 6-th order cumulants
9931 call transpose2(EUgder(1,1,l),auxmat(1,1))
9932 call matmat2(auxmat(1,1),AEA(1,1,2),EAEAderg(1,1,1,2))
9933 call transpose2(EUg(1,1,l),auxmat(1,1))
9934 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
9935 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
9939 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
9940 EAEAderx(1,1,lll,kkk,iii,2))
9945 ! Calculate the vectors and their derivatives in virtual-bond dihedral angles.
9946 ! They are needed only when the fifth- or the sixth-order cumulants are
9948 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0) THEN
9949 call transpose2(AEA(1,1,1),auxmat(1,1))
9950 call matvec2(auxmat(1,1),b1(1,iti),AEAb1(1,1,1))
9951 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
9952 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
9953 call transpose2(AEAderg(1,1,1),auxmat(1,1))
9954 call matvec2(auxmat(1,1),b1(1,iti),AEAb1derg(1,1,1))
9955 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
9956 call matvec2(AEA(1,1,1),b1(1,itk1),AEAb1(1,2,1))
9957 call matvec2(AEAderg(1,1,1),b1(1,itk1),AEAb1derg(1,2,1))
9958 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
9959 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
9960 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
9961 call transpose2(AEA(1,1,2),auxmat(1,1))
9962 call matvec2(auxmat(1,1),b1(1,itj),AEAb1(1,1,2))
9963 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2(1,1,2))
9964 call matvec2(auxmat(1,1),Ub2der(1,j),AEAb2derg(1,2,1,2))
9965 call transpose2(AEAderg(1,1,2),auxmat(1,1))
9966 call matvec2(auxmat(1,1),b1(1,itj),AEAb1derg(1,1,2))
9967 call matvec2(auxmat(1,1),Ub2(1,j),AEAb2derg(1,1,1,2))
9968 call matvec2(AEA(1,1,2),b1(1,itl1),AEAb1(1,2,2))
9969 call matvec2(AEAderg(1,1,2),b1(1,itl1),AEAb1derg(1,2,2))
9970 call matvec2(AEA(1,1,2),Ub2(1,l+1),AEAb2(1,2,2))
9971 call matvec2(AEAderg(1,1,2),Ub2(1,l+1),AEAb2derg(1,1,2,2))
9972 call matvec2(AEA(1,1,2),Ub2der(1,l+1),AEAb2derg(1,2,2,2))
9973 ! Calculate the Cartesian derivatives of the vectors.
9977 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
9978 call matvec2(auxmat(1,1),b1(1,iti),&
9979 AEAb1derx(1,lll,kkk,iii,1,1))
9980 call matvec2(auxmat(1,1),Ub2(1,i),&
9981 AEAb2derx(1,lll,kkk,iii,1,1))
9982 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,itk1),&
9983 AEAb1derx(1,lll,kkk,iii,2,1))
9984 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),&
9985 AEAb2derx(1,lll,kkk,iii,2,1))
9986 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
9987 call matvec2(auxmat(1,1),b1(1,itj),&
9988 AEAb1derx(1,lll,kkk,iii,1,2))
9989 call matvec2(auxmat(1,1),Ub2(1,j),&
9990 AEAb2derx(1,lll,kkk,iii,1,2))
9991 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,itl1),&
9992 AEAb1derx(1,lll,kkk,iii,2,2))
9993 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,l+1),&
9994 AEAb2derx(1,lll,kkk,iii,2,2))
10001 ! Antiparallel orientation of the two CA-CA-CA frames.
10003 iti=itortyp(itype(i,1))
10007 itk1=itortyp(itype(k+1,1))
10008 itl=itortyp(itype(l,1))
10009 itj=itortyp(itype(j,1))
10010 if (j.lt.nres-1) then
10011 itj1=itortyp(itype(j+1,1))
10015 ! A2 kernel(j-1)T A1T
10016 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
10017 aa2tder(1,1,1,1),1,.true.,EUg(1,1,j),EUgder(1,1,j),&
10018 AEA(1,1,1),AEAderg(1,1,1),AEAderx(1,1,1,1,1,1))
10019 ! Following matrices are needed only for 6-th order cumulants
10020 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and. &
10021 j.eq.i+4 .and. l.eq.i+3)) THEN
10022 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
10023 aa2tder(1,1,1,1),1,.true.,EUgC(1,1,j),EUgCder(1,1,j),&
10024 AECA(1,1,1),AECAderg(1,1,1),AECAderx(1,1,1,1,1,1))
10025 call kernel(aa2(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
10026 aa2tder(1,1,1,1),2,.true.,Ug2DtEUg(1,1,j),&
10027 Ug2DtEUgder(1,1,1,j),ADtEA(1,1,1),ADtEAderg(1,1,1,1),&
10028 ADtEAderx(1,1,1,1,1,1))
10029 call kernel(aa1(1,1),aa2t(1,1),a_chuj_der(1,1,1,1,jj,i),&
10030 aa2tder(1,1,1,1),2,.true.,DtUg2EUg(1,1,j),&
10031 DtUg2EUgder(1,1,1,j),ADtEA1(1,1,1),ADtEA1derg(1,1,1,1),&
10032 ADtEA1derx(1,1,1,1,1,1))
10034 ! End 6-th order cumulants
10035 call transpose2(EUgder(1,1,k),auxmat(1,1))
10036 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,1,1))
10037 call transpose2(EUg(1,1,k),auxmat(1,1))
10038 call matmat2(auxmat(1,1),AEA(1,1,1),EAEA(1,1,1))
10039 call matmat2(auxmat(1,1),AEAderg(1,1,1),EAEAderg(1,1,2,1))
10043 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),&
10044 EAEAderx(1,1,lll,kkk,iii,1))
10048 ! A2T kernel(i+1)T A1
10049 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
10050 a_chuj_der(1,1,1,1,jj,i),1,.true.,EUg(1,1,k),EUgder(1,1,k),&
10051 AEA(1,1,2),AEAderg(1,1,2),AEAderx(1,1,1,1,1,2))
10052 ! Following matrices are needed only for 6-th order cumulants
10053 IF (wcorr6.gt.0.0d0 .or. (wturn6.gt.0.0d0 .and. &
10054 j.eq.i+4 .and. l.eq.i+3)) THEN
10055 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
10056 a_chuj_der(1,1,1,1,jj,i),1,.true.,EUgC(1,1,k),EUgCder(1,1,k),&
10057 AECA(1,1,2),AECAderg(1,1,2),AECAderx(1,1,1,1,1,2))
10058 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
10059 a_chuj_der(1,1,1,1,jj,i),2,.true.,Ug2DtEUg(1,1,k),&
10060 Ug2DtEUgder(1,1,1,k),ADtEA(1,1,2),ADtEAderg(1,1,1,2),&
10061 ADtEAderx(1,1,1,1,1,2))
10062 call kernel(aa2t(1,1),aa1(1,1),aa2tder(1,1,1,1),&
10063 a_chuj_der(1,1,1,1,jj,i),2,.true.,DtUg2EUg(1,1,k),&
10064 DtUg2EUgder(1,1,1,k),ADtEA1(1,1,2),ADtEA1derg(1,1,1,2),&
10065 ADtEA1derx(1,1,1,1,1,2))
10067 ! End 6-th order cumulants
10068 call transpose2(EUgder(1,1,j),auxmat(1,1))
10069 call matmat2(auxmat(1,1),AEA(1,1,1),EAEAderg(1,1,2,2))
10070 call transpose2(EUg(1,1,j),auxmat(1,1))
10071 call matmat2(auxmat(1,1),AEA(1,1,2),EAEA(1,1,2))
10072 call matmat2(auxmat(1,1),AEAderg(1,1,2),EAEAderg(1,1,2,2))
10076 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
10077 EAEAderx(1,1,lll,kkk,iii,2))
10082 ! Calculate the vectors and their derivatives in virtual-bond dihedral angles.
10083 ! They are needed only when the fifth- or the sixth-order cumulants are
10085 IF (wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 .or. &
10086 (wturn6.gt.0.0d0 .and. j.eq.i+4 .and. l.eq.i+3)) THEN
10087 call transpose2(AEA(1,1,1),auxmat(1,1))
10088 call matvec2(auxmat(1,1),b1(1,iti),AEAb1(1,1,1))
10089 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2(1,1,1))
10090 call matvec2(auxmat(1,1),Ub2der(1,i),AEAb2derg(1,2,1,1))
10091 call transpose2(AEAderg(1,1,1),auxmat(1,1))
10092 call matvec2(auxmat(1,1),b1(1,iti),AEAb1derg(1,1,1))
10093 call matvec2(auxmat(1,1),Ub2(1,i),AEAb2derg(1,1,1,1))
10094 call matvec2(AEA(1,1,1),b1(1,itk1),AEAb1(1,2,1))
10095 call matvec2(AEAderg(1,1,1),b1(1,itk1),AEAb1derg(1,2,1))
10096 call matvec2(AEA(1,1,1),Ub2(1,k+1),AEAb2(1,2,1))
10097 call matvec2(AEAderg(1,1,1),Ub2(1,k+1),AEAb2derg(1,1,2,1))
10098 call matvec2(AEA(1,1,1),Ub2der(1,k+1),AEAb2derg(1,2,2,1))
10099 call transpose2(AEA(1,1,2),auxmat(1,1))
10100 call matvec2(auxmat(1,1),b1(1,itj1),AEAb1(1,1,2))
10101 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2(1,1,2))
10102 call matvec2(auxmat(1,1),Ub2der(1,l),AEAb2derg(1,2,1,2))
10103 call transpose2(AEAderg(1,1,2),auxmat(1,1))
10104 call matvec2(auxmat(1,1),b1(1,itl),AEAb1(1,1,2))
10105 call matvec2(auxmat(1,1),Ub2(1,l),AEAb2derg(1,1,1,2))
10106 call matvec2(AEA(1,1,2),b1(1,itj1),AEAb1(1,2,2))
10107 call matvec2(AEAderg(1,1,2),b1(1,itj1),AEAb1derg(1,2,2))
10108 call matvec2(AEA(1,1,2),Ub2(1,j),AEAb2(1,2,2))
10109 call matvec2(AEAderg(1,1,2),Ub2(1,j),AEAb2derg(1,1,2,2))
10110 call matvec2(AEA(1,1,2),Ub2der(1,j),AEAb2derg(1,2,2,2))
10111 ! Calculate the Cartesian derivatives of the vectors.
10115 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1))
10116 call matvec2(auxmat(1,1),b1(1,iti),&
10117 AEAb1derx(1,lll,kkk,iii,1,1))
10118 call matvec2(auxmat(1,1),Ub2(1,i),&
10119 AEAb2derx(1,lll,kkk,iii,1,1))
10120 call matvec2(AEAderx(1,1,lll,kkk,iii,1),b1(1,itk1),&
10121 AEAb1derx(1,lll,kkk,iii,2,1))
10122 call matvec2(AEAderx(1,1,lll,kkk,iii,1),Ub2(1,k+1),&
10123 AEAb2derx(1,lll,kkk,iii,2,1))
10124 call transpose2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1))
10125 call matvec2(auxmat(1,1),b1(1,itl),&
10126 AEAb1derx(1,lll,kkk,iii,1,2))
10127 call matvec2(auxmat(1,1),Ub2(1,l),&
10128 AEAb2derx(1,lll,kkk,iii,1,2))
10129 call matvec2(AEAderx(1,1,lll,kkk,iii,2),b1(1,itj1),&
10130 AEAb1derx(1,lll,kkk,iii,2,2))
10131 call matvec2(AEAderx(1,1,lll,kkk,iii,2),Ub2(1,j),&
10132 AEAb2derx(1,lll,kkk,iii,2,2))
10140 end subroutine calc_eello
10141 !-----------------------------------------------------------------------------
10142 subroutine kernel(aa1,aa2t,aa1derx,aa2tderx,nderg,transp,KK,KKderg,AKA,AKAderg,AKAderx)
10147 real(kind=8),dimension(2,2) :: aa1,aa2t,KK,AKA
10148 real(kind=8),dimension(2,2,3,5) :: aa1derx,aa2tderx
10149 real(kind=8),dimension(2,2,3,5,2) :: AKAderx
10150 real(kind=8),dimension(2,2,nderg) :: KKderg,AKAderg
10151 integer :: iii,kkk,lll
10153 !el logical :: lprn
10154 !el common /kutas/ lprn
10155 call prodmat3(aa1(1,1),aa2t(1,1),KK(1,1),transp,AKA(1,1))
10157 call prodmat3(aa1(1,1),aa2t(1,1),KKderg(1,1,iii),transp,&
10160 !d if (lprn) write (2,*) 'In kernel'
10162 !d if (lprn) write (2,*) 'kkk=',kkk
10164 call prodmat3(aa1derx(1,1,lll,kkk),aa2t(1,1),&
10165 KK(1,1),transp,AKAderx(1,1,lll,kkk,1))
10167 !d write (2,*) 'lll=',lll
10168 !d write (2,*) 'iii=1'
10170 !d write (2,'(3(2f10.5),5x)')
10171 !d & (AKAderx(jjj,mmm,lll,kkk,1),mmm=1,2)
10174 call prodmat3(aa1(1,1),aa2tderx(1,1,lll,kkk),&
10175 KK(1,1),transp,AKAderx(1,1,lll,kkk,2))
10177 !d write (2,*) 'lll=',lll
10178 !d write (2,*) 'iii=2'
10180 !d write (2,'(3(2f10.5),5x)')
10181 !d & (AKAderx(jjj,mmm,lll,kkk,2),mmm=1,2)
10187 end subroutine kernel
10188 !-----------------------------------------------------------------------------
10189 real(kind=8) function eello4(i,j,k,l,jj,kk)
10190 ! implicit real(kind=8) (a-h,o-z)
10191 ! include 'DIMENSIONS'
10192 ! include 'COMMON.IOUNITS'
10193 ! include 'COMMON.CHAIN'
10194 ! include 'COMMON.DERIV'
10195 ! include 'COMMON.INTERACT'
10196 ! include 'COMMON.CONTACTS'
10197 ! include 'COMMON.TORSION'
10198 ! include 'COMMON.VAR'
10199 ! include 'COMMON.GEO'
10200 real(kind=8),dimension(2,2) :: pizda
10201 real(kind=8),dimension(3) :: ggg1,ggg2
10202 real(kind=8) :: eel4,glongij,glongkl
10203 integer :: i,j,k,l,jj,kk,iii,kkk,lll,j1,j2,l1,l2,ll
10204 !d if (i.ne.1 .or. j.ne.5 .or. k.ne.2 .or.l.ne.4) then
10208 !d print *,'eello4:',i,j,k,l,jj,kk
10209 !d write (2,*) 'i',i,' j',j,' k',k,' l',l
10210 !d call checkint4(i,j,k,l,jj,kk,eel4_num)
10211 !old eij=facont_hb(jj,i)
10212 !old ekl=facont_hb(kk,k)
10214 eel4=-EAEA(1,1,1)-EAEA(2,2,1)
10215 !d eel41=-EAEA(1,1,2)-EAEA(2,2,2)
10216 gcorr_loc(k-1)=gcorr_loc(k-1) &
10217 -ekont*(EAEAderg(1,1,1,1)+EAEAderg(2,2,1,1))
10219 gcorr_loc(l-1)=gcorr_loc(l-1) &
10220 -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
10222 gcorr_loc(j-1)=gcorr_loc(j-1) &
10223 -ekont*(EAEAderg(1,1,2,1)+EAEAderg(2,2,2,1))
10228 derx(lll,kkk,iii)=-EAEAderx(1,1,lll,kkk,iii,1) &
10229 -EAEAderx(2,2,lll,kkk,iii,1)
10230 !d derx(lll,kkk,iii)=0.0d0
10234 !d gcorr_loc(l-1)=0.0d0
10235 !d gcorr_loc(j-1)=0.0d0
10236 !d gcorr_loc(k-1)=0.0d0
10238 !d write (iout,*)'Contacts have occurred for peptide groups',
10239 !d & i,j,' fcont:',eij,' eij',' and ',k,l,
10240 !d & ' fcont ',ekl,' eel4=',eel4,' eel4_num',16*eel4_num
10241 if (j.lt.nres-1) then
10248 if (l.lt.nres-1) then
10256 !grad ggg1(ll)=eel4*g_contij(ll,1)
10257 !grad ggg2(ll)=eel4*g_contij(ll,2)
10258 glongij=eel4*g_contij(ll,1)+ekont*derx(ll,1,1)
10259 glongkl=eel4*g_contij(ll,2)+ekont*derx(ll,1,2)
10260 !grad ghalf=0.5d0*ggg1(ll)
10261 gradcorr(ll,i)=gradcorr(ll,i)+ekont*derx(ll,2,1)
10262 gradcorr(ll,i+1)=gradcorr(ll,i+1)+ekont*derx(ll,3,1)
10263 gradcorr(ll,j)=gradcorr(ll,j)+ekont*derx(ll,4,1)
10264 gradcorr(ll,j1)=gradcorr(ll,j1)+ekont*derx(ll,5,1)
10265 gradcorr_long(ll,j)=gradcorr_long(ll,j)+glongij
10266 gradcorr_long(ll,i)=gradcorr_long(ll,i)-glongij
10267 !grad ghalf=0.5d0*ggg2(ll)
10268 gradcorr(ll,k)=gradcorr(ll,k)+ekont*derx(ll,2,2)
10269 gradcorr(ll,k+1)=gradcorr(ll,k+1)+ekont*derx(ll,3,2)
10270 gradcorr(ll,l)=gradcorr(ll,l)+ekont*derx(ll,4,2)
10271 gradcorr(ll,l1)=gradcorr(ll,l1)+ekont*derx(ll,5,2)
10272 gradcorr_long(ll,l)=gradcorr_long(ll,l)+glongkl
10273 gradcorr_long(ll,k)=gradcorr_long(ll,k)-glongkl
10277 !grad gradcorr(ll,m)=gradcorr(ll,m)+ggg1(ll)
10282 !grad gradcorr(ll,m)=gradcorr(ll,m)+ggg2(ll)
10287 !grad gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,1)
10292 !grad gradcorr(ll,m)=gradcorr(ll,m)+ekont*derx(ll,1,2)
10296 !d write (2,*) iii,gcorr_loc(iii)
10299 !d write (2,*) 'ekont',ekont
10300 !d write (iout,*) 'eello4',ekont*eel4
10302 end function eello4
10303 !-----------------------------------------------------------------------------
10304 real(kind=8) function eello5(i,j,k,l,jj,kk)
10305 ! implicit real(kind=8) (a-h,o-z)
10306 ! include 'DIMENSIONS'
10307 ! include 'COMMON.IOUNITS'
10308 ! include 'COMMON.CHAIN'
10309 ! include 'COMMON.DERIV'
10310 ! include 'COMMON.INTERACT'
10311 ! include 'COMMON.CONTACTS'
10312 ! include 'COMMON.TORSION'
10313 ! include 'COMMON.VAR'
10314 ! include 'COMMON.GEO'
10315 real(kind=8),dimension(2,2) :: pizda,auxmat,auxmat1
10316 real(kind=8),dimension(2) :: vv
10317 real(kind=8),dimension(3) :: ggg1,ggg2
10318 real(kind=8) :: eello5_1,eello5_2,eello5_3,eello5_4,eel5
10319 real(kind=8) :: gradcorr5ij,gradcorr5kl,ghalf
10320 integer :: i,j,k,l,jj,kk,itk,itl,itj,iii,kkk,lll,j1,j2,l1,l2,ll
10321 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
10323 ! Parallel chains C
10326 ! /l\ / \ \ / \ / \ / C
10327 ! / \ / \ \ / \ / \ / C
10328 ! j| o |l1 | o | o| o | | o |o C
10329 ! \ |/k\| |/ \| / |/ \| |/ \| C
10330 ! \i/ \ / \ / / \ / \ C
10332 ! (I) (II) (III) (IV) C
10334 ! eello5_1 eello5_2 eello5_3 eello5_4 C
10336 ! Antiparallel chains C
10339 ! /j\ / \ \ / \ / \ / C
10340 ! / \ / \ \ / \ / \ / C
10341 ! j1| o |l | o | o| o | | o |o C
10342 ! \ |/k\| |/ \| / |/ \| |/ \| C
10343 ! \i/ \ / \ / / \ / \ C
10345 ! (I) (II) (III) (IV) C
10347 ! eello5_1 eello5_2 eello5_3 eello5_4 C
10349 ! o denotes a local interaction, vertical lines an electrostatic interaction. C
10351 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
10352 !d if (i.ne.2 .or. j.ne.6 .or. k.ne.3 .or. l.ne.5) then
10357 !d & 'EELLO5: Contacts have occurred for peptide groups',i,j,
10359 itk=itortyp(itype(k,1))
10360 itl=itortyp(itype(l,1))
10361 itj=itortyp(itype(j,1))
10366 !d call checkint5(i,j,k,l,jj,kk,eel5_1_num,eel5_2_num,
10367 !d & eel5_3_num,eel5_4_num)
10371 derx(lll,kkk,iii)=0.0d0
10375 !d eij=facont_hb(jj,i)
10376 !d ekl=facont_hb(kk,k)
10378 !d write (iout,*)'Contacts have occurred for peptide groups',
10379 !d & i,j,' fcont:',eij,' eij',' and ',k,l
10381 ! Contribution from the graph I.
10382 !d write (2,*) 'AEA ',AEA(1,1,1),AEA(2,1,1),AEA(1,2,1),AEA(2,2,1)
10383 !d write (2,*) 'AEAb2',AEAb2(1,1,1),AEAb2(2,1,1)
10384 call transpose2(EUg(1,1,k),auxmat(1,1))
10385 call matmat2(AEA(1,1,1),auxmat(1,1),pizda(1,1))
10386 vv(1)=pizda(1,1)-pizda(2,2)
10387 vv(2)=pizda(1,2)+pizda(2,1)
10388 eello5_1=scalar2(AEAb2(1,1,1),Ub2(1,k)) &
10389 +0.5d0*scalar2(vv(1),Dtobr2(1,i))
10390 ! Explicit gradient in virtual-dihedral angles.
10391 if (i.gt.1) g_corr5_loc(i-1)=g_corr5_loc(i-1) &
10392 +ekont*(scalar2(AEAb2derg(1,2,1,1),Ub2(1,k)) &
10393 +0.5d0*scalar2(vv(1),Dtobr2der(1,i)))
10394 call transpose2(EUgder(1,1,k),auxmat1(1,1))
10395 call matmat2(AEA(1,1,1),auxmat1(1,1),pizda(1,1))
10396 vv(1)=pizda(1,1)-pizda(2,2)
10397 vv(2)=pizda(1,2)+pizda(2,1)
10398 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
10399 +ekont*(scalar2(AEAb2(1,1,1),Ub2der(1,k)) &
10400 +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
10401 call matmat2(AEAderg(1,1,1),auxmat(1,1),pizda(1,1))
10402 vv(1)=pizda(1,1)-pizda(2,2)
10403 vv(2)=pizda(1,2)+pizda(2,1)
10405 if (l.lt.nres-1) g_corr5_loc(l-1)=g_corr5_loc(l-1) &
10406 +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k)) &
10407 +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
10409 if (j.lt.nres-1) g_corr5_loc(j-1)=g_corr5_loc(j-1) &
10410 +ekont*(scalar2(AEAb2derg(1,1,1,1),Ub2(1,k)) &
10411 +0.5d0*scalar2(vv(1),Dtobr2(1,i)))
10413 ! Cartesian gradient
10417 call matmat2(AEAderx(1,1,lll,kkk,iii,1),auxmat(1,1),&
10419 vv(1)=pizda(1,1)-pizda(2,2)
10420 vv(2)=pizda(1,2)+pizda(2,1)
10421 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
10422 +scalar2(AEAb2derx(1,lll,kkk,iii,1,1),Ub2(1,k)) &
10423 +0.5d0*scalar2(vv(1),Dtobr2(1,i))
10429 ! Contribution from graph II
10430 call transpose2(EE(1,1,itk),auxmat(1,1))
10431 call matmat2(auxmat(1,1),AEA(1,1,1),pizda(1,1))
10432 vv(1)=pizda(1,1)+pizda(2,2)
10433 vv(2)=pizda(2,1)-pizda(1,2)
10434 eello5_2=scalar2(AEAb1(1,2,1),b1(1,itk)) &
10435 -0.5d0*scalar2(vv(1),Ctobr(1,k))
10436 ! Explicit gradient in virtual-dihedral angles.
10437 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
10438 -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,k))
10439 call matmat2(auxmat(1,1),AEAderg(1,1,1),pizda(1,1))
10440 vv(1)=pizda(1,1)+pizda(2,2)
10441 vv(2)=pizda(2,1)-pizda(1,2)
10443 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
10444 +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,itk)) &
10445 -0.5d0*scalar2(vv(1),Ctobr(1,k)))
10447 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
10448 +ekont*(scalar2(AEAb1derg(1,2,1),b1(1,itk)) &
10449 -0.5d0*scalar2(vv(1),Ctobr(1,k)))
10451 ! Cartesian gradient
10455 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,1),&
10457 vv(1)=pizda(1,1)+pizda(2,2)
10458 vv(2)=pizda(2,1)-pizda(1,2)
10459 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
10460 +scalar2(AEAb1derx(1,lll,kkk,iii,2,1),b1(1,itk)) &
10461 -0.5d0*scalar2(vv(1),Ctobr(1,k))
10469 ! Parallel orientation
10470 ! Contribution from graph III
10471 call transpose2(EUg(1,1,l),auxmat(1,1))
10472 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
10473 vv(1)=pizda(1,1)-pizda(2,2)
10474 vv(2)=pizda(1,2)+pizda(2,1)
10475 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,l)) &
10476 +0.5d0*scalar2(vv(1),Dtobr2(1,j))
10477 ! Explicit gradient in virtual-dihedral angles.
10478 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
10479 +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,l)) &
10480 +0.5d0*scalar2(vv(1),Dtobr2der(1,j)))
10481 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
10482 vv(1)=pizda(1,1)-pizda(2,2)
10483 vv(2)=pizda(1,2)+pizda(2,1)
10484 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
10485 +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,l)) &
10486 +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
10487 call transpose2(EUgder(1,1,l),auxmat1(1,1))
10488 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
10489 vv(1)=pizda(1,1)-pizda(2,2)
10490 vv(2)=pizda(1,2)+pizda(2,1)
10491 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
10492 +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,l)) &
10493 +0.5d0*scalar2(vv(1),Dtobr2(1,j)))
10494 ! Cartesian gradient
10498 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),&
10500 vv(1)=pizda(1,1)-pizda(2,2)
10501 vv(2)=pizda(1,2)+pizda(2,1)
10502 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
10503 +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,l)) &
10504 +0.5d0*scalar2(vv(1),Dtobr2(1,j))
10509 ! Contribution from graph IV
10511 call transpose2(EE(1,1,itl),auxmat(1,1))
10512 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
10513 vv(1)=pizda(1,1)+pizda(2,2)
10514 vv(2)=pizda(2,1)-pizda(1,2)
10515 eello5_4=scalar2(AEAb1(1,2,2),b1(1,itl)) &
10516 -0.5d0*scalar2(vv(1),Ctobr(1,l))
10517 ! Explicit gradient in virtual-dihedral angles.
10518 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
10519 -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,l))
10520 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
10521 vv(1)=pizda(1,1)+pizda(2,2)
10522 vv(2)=pizda(2,1)-pizda(1,2)
10523 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
10524 +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,itl)) &
10525 -0.5d0*scalar2(vv(1),Ctobr(1,l)))
10526 ! Cartesian gradient
10530 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
10532 vv(1)=pizda(1,1)+pizda(2,2)
10533 vv(2)=pizda(2,1)-pizda(1,2)
10534 derx(lll,kkk,iii)=derx(lll,kkk,iii) &
10535 +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,itl)) &
10536 -0.5d0*scalar2(vv(1),Ctobr(1,l))
10541 ! Antiparallel orientation
10542 ! Contribution from graph III
10544 call transpose2(EUg(1,1,j),auxmat(1,1))
10545 call matmat2(AEA(1,1,2),auxmat(1,1),pizda(1,1))
10546 vv(1)=pizda(1,1)-pizda(2,2)
10547 vv(2)=pizda(1,2)+pizda(2,1)
10548 eello5_3=scalar2(AEAb2(1,1,2),Ub2(1,j)) &
10549 +0.5d0*scalar2(vv(1),Dtobr2(1,l))
10550 ! Explicit gradient in virtual-dihedral angles.
10551 g_corr5_loc(l-1)=g_corr5_loc(l-1) &
10552 +ekont*(scalar2(AEAb2derg(1,2,1,2),Ub2(1,j)) &
10553 +0.5d0*scalar2(vv(1),Dtobr2der(1,l)))
10554 call matmat2(AEAderg(1,1,2),auxmat(1,1),pizda(1,1))
10555 vv(1)=pizda(1,1)-pizda(2,2)
10556 vv(2)=pizda(1,2)+pizda(2,1)
10557 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
10558 +ekont*(scalar2(AEAb2derg(1,1,1,2),Ub2(1,j)) &
10559 +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
10560 call transpose2(EUgder(1,1,j),auxmat1(1,1))
10561 call matmat2(AEA(1,1,2),auxmat1(1,1),pizda(1,1))
10562 vv(1)=pizda(1,1)-pizda(2,2)
10563 vv(2)=pizda(1,2)+pizda(2,1)
10564 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
10565 +ekont*(scalar2(AEAb2(1,1,2),Ub2der(1,j)) &
10566 +0.5d0*scalar2(vv(1),Dtobr2(1,l)))
10567 ! Cartesian gradient
10571 call matmat2(AEAderx(1,1,lll,kkk,iii,2),auxmat(1,1),&
10573 vv(1)=pizda(1,1)-pizda(2,2)
10574 vv(2)=pizda(1,2)+pizda(2,1)
10575 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii) &
10576 +scalar2(AEAb2derx(1,lll,kkk,iii,1,2),Ub2(1,j)) &
10577 +0.5d0*scalar2(vv(1),Dtobr2(1,l))
10582 ! Contribution from graph IV
10584 call transpose2(EE(1,1,itj),auxmat(1,1))
10585 call matmat2(auxmat(1,1),AEA(1,1,2),pizda(1,1))
10586 vv(1)=pizda(1,1)+pizda(2,2)
10587 vv(2)=pizda(2,1)-pizda(1,2)
10588 eello5_4=scalar2(AEAb1(1,2,2),b1(1,itj)) &
10589 -0.5d0*scalar2(vv(1),Ctobr(1,j))
10590 ! Explicit gradient in virtual-dihedral angles.
10591 g_corr5_loc(j-1)=g_corr5_loc(j-1) &
10592 -0.5d0*ekont*scalar2(vv(1),Ctobrder(1,j))
10593 call matmat2(auxmat(1,1),AEAderg(1,1,2),pizda(1,1))
10594 vv(1)=pizda(1,1)+pizda(2,2)
10595 vv(2)=pizda(2,1)-pizda(1,2)
10596 g_corr5_loc(k-1)=g_corr5_loc(k-1) &
10597 +ekont*(scalar2(AEAb1derg(1,2,2),b1(1,itj)) &
10598 -0.5d0*scalar2(vv(1),Ctobr(1,j)))
10599 ! Cartesian gradient
10603 call matmat2(auxmat(1,1),AEAderx(1,1,lll,kkk,iii,2),&
10605 vv(1)=pizda(1,1)+pizda(2,2)
10606 vv(2)=pizda(2,1)-pizda(1,2)
10607 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii) &
10608 +scalar2(AEAb1derx(1,lll,kkk,iii,2,2),b1(1,itj)) &
10609 -0.5d0*scalar2(vv(1),Ctobr(1,j))
10615 eel5=eello5_1+eello5_2+eello5_3+eello5_4
10616 !d if (i.eq.2 .and. j.eq.8 .and. k.eq.3 .and. l.eq.7) then
10617 !d write (2,*) 'ijkl',i,j,k,l
10618 !d write (2,*) 'eello5_1',eello5_1,' eello5_2',eello5_2,
10619 !d & ' eello5_3',eello5_3,' eello5_4',eello5_4
10621 !d write(iout,*) 'eello5_1',eello5_1,' eel5_1_num',16*eel5_1_num
10622 !d write(iout,*) 'eello5_2',eello5_2,' eel5_2_num',16*eel5_2_num
10623 !d write(iout,*) 'eello5_3',eello5_3,' eel5_3_num',16*eel5_3_num
10624 !d write(iout,*) 'eello5_4',eello5_4,' eel5_4_num',16*eel5_4_num
10625 if (j.lt.nres-1) then
10632 if (l.lt.nres-1) then
10642 !d write (2,*) 'eij',eij,' ekl',ekl,' ekont',ekont
10643 ! 2/11/08 AL Gradients over DC's connecting interacting sites will be
10644 ! summed up outside the subrouine as for the other subroutines
10645 ! handling long-range interactions. The old code is commented out
10646 ! with "cgrad" to keep track of changes.
10648 !grad ggg1(ll)=eel5*g_contij(ll,1)
10649 !grad ggg2(ll)=eel5*g_contij(ll,2)
10650 gradcorr5ij=eel5*g_contij(ll,1)+ekont*derx(ll,1,1)
10651 gradcorr5kl=eel5*g_contij(ll,2)+ekont*derx(ll,1,2)
10652 ! write (iout,'(a,3i3,a,5f8.3,2i3,a,5f8.3,a,f8.3)')
10653 ! & "ecorr5",ll,i,j," derx",derx(ll,2,1),derx(ll,3,1),derx(ll,4,1),
10654 ! & derx(ll,5,1),k,l," derx",derx(ll,2,2),derx(ll,3,2),
10655 ! & derx(ll,4,2),derx(ll,5,2)," ekont",ekont
10656 ! write (iout,'(a,3i3,a,3f8.3,2i3,a,3f8.3)')
10657 ! & "ecorr5",ll,i,j," gradcorr5",g_contij(ll,1),derx(ll,1,1),
10659 ! & k,l," gradcorr5",g_contij(ll,2),derx(ll,1,2),gradcorr5kl
10660 !old ghalf=0.5d0*eel5*ekl*gacont_hbr(ll,jj,i)
10661 !grad ghalf=0.5d0*ggg1(ll)
10663 gradcorr5(ll,i)=gradcorr5(ll,i)+ekont*derx(ll,2,1)
10664 gradcorr5(ll,i+1)=gradcorr5(ll,i+1)+ekont*derx(ll,3,1)
10665 gradcorr5(ll,j)=gradcorr5(ll,j)+ekont*derx(ll,4,1)
10666 gradcorr5(ll,j1)=gradcorr5(ll,j1)+ekont*derx(ll,5,1)
10667 gradcorr5_long(ll,j)=gradcorr5_long(ll,j)+gradcorr5ij
10668 gradcorr5_long(ll,i)=gradcorr5_long(ll,i)-gradcorr5ij
10669 !old ghalf=0.5d0*eel5*eij*gacont_hbr(ll,kk,k)
10670 !grad ghalf=0.5d0*ggg2(ll)
10672 gradcorr5(ll,k)=gradcorr5(ll,k)+ghalf+ekont*derx(ll,2,2)
10673 gradcorr5(ll,k+1)=gradcorr5(ll,k+1)+ekont*derx(ll,3,2)
10674 gradcorr5(ll,l)=gradcorr5(ll,l)+ghalf+ekont*derx(ll,4,2)
10675 gradcorr5(ll,l1)=gradcorr5(ll,l1)+ekont*derx(ll,5,2)
10676 gradcorr5_long(ll,l)=gradcorr5_long(ll,l)+gradcorr5kl
10677 gradcorr5_long(ll,k)=gradcorr5_long(ll,k)-gradcorr5kl
10682 !old gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*ekl*gacont_hbr(ll,jj,i)
10683 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ggg1(ll)
10688 !old gradcorr5(ll,m)=gradcorr5(ll,m)+eel5*eij*gacont_hbr(ll,kk,k)
10689 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ggg2(ll)
10695 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,1)
10700 !grad gradcorr5(ll,m)=gradcorr5(ll,m)+ekont*derx(ll,1,2)
10704 !d write (2,*) iii,g_corr5_loc(iii)
10707 !d write (2,*) 'ekont',ekont
10708 !d write (iout,*) 'eello5',ekont*eel5
10710 end function eello5
10711 !-----------------------------------------------------------------------------
10712 real(kind=8) function eello6(i,j,k,l,jj,kk)
10713 ! implicit real(kind=8) (a-h,o-z)
10714 ! include 'DIMENSIONS'
10715 ! include 'COMMON.IOUNITS'
10716 ! include 'COMMON.CHAIN'
10717 ! include 'COMMON.DERIV'
10718 ! include 'COMMON.INTERACT'
10719 ! include 'COMMON.CONTACTS'
10720 ! include 'COMMON.TORSION'
10721 ! include 'COMMON.VAR'
10722 ! include 'COMMON.GEO'
10723 ! include 'COMMON.FFIELD'
10724 real(kind=8),dimension(3) :: ggg1,ggg2
10725 real(kind=8) :: eello6_1,eello6_2,eello6_3,eello6_4,eello6_5,&
10727 real(kind=8) :: gradcorr6ij,gradcorr6kl
10728 integer :: i,j,k,l,jj,kk,iii,kkk,lll,j1,j2,l1,l2,ll
10729 !d if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
10734 !d & 'EELLO6: Contacts have occurred for peptide groups',i,j,
10742 !d call checkint6(i,j,k,l,jj,kk,eel6_1_num,eel6_2_num,
10743 !d & eel6_3_num,eel6_4_num,eel6_5_num,eel6_6_num)
10747 derx(lll,kkk,iii)=0.0d0
10751 !d eij=facont_hb(jj,i)
10752 !d ekl=facont_hb(kk,k)
10758 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
10759 eello6_2=eello6_graph1(j,i,l,k,2,.false.)
10760 eello6_3=eello6_graph2(i,j,k,l,jj,kk,.false.)
10761 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
10762 eello6_5=eello6_graph4(j,i,l,k,jj,kk,2,.false.)
10763 eello6_6=eello6_graph3(i,j,k,l,jj,kk,.false.)
10765 eello6_1=eello6_graph1(i,j,k,l,1,.false.)
10766 eello6_2=eello6_graph1(l,k,j,i,2,.true.)
10767 eello6_3=eello6_graph2(i,l,k,j,jj,kk,.true.)
10768 eello6_4=eello6_graph4(i,j,k,l,jj,kk,1,.false.)
10769 if (wturn6.eq.0.0d0 .or. j.ne.i+4) then
10770 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
10774 eello6_6=eello6_graph3(i,l,k,j,jj,kk,.true.)
10776 ! If turn contributions are considered, they will be handled separately.
10777 eel6=eello6_1+eello6_2+eello6_3+eello6_4+eello6_5+eello6_6
10778 !d write(iout,*) 'eello6_1',eello6_1!,' eel6_1_num',16*eel6_1_num
10779 !d write(iout,*) 'eello6_2',eello6_2!,' eel6_2_num',16*eel6_2_num
10780 !d write(iout,*) 'eello6_3',eello6_3!,' eel6_3_num',16*eel6_3_num
10781 !d write(iout,*) 'eello6_4',eello6_4!,' eel6_4_num',16*eel6_4_num
10782 !d write(iout,*) 'eello6_5',eello6_5!,' eel6_5_num',16*eel6_5_num
10783 !d write(iout,*) 'eello6_6',eello6_6!,' eel6_6_num',16*eel6_6_num
10785 if (j.lt.nres-1) then
10792 if (l.lt.nres-1) then
10800 !grad ggg1(ll)=eel6*g_contij(ll,1)
10801 !grad ggg2(ll)=eel6*g_contij(ll,2)
10802 !old ghalf=0.5d0*eel6*ekl*gacont_hbr(ll,jj,i)
10803 !grad ghalf=0.5d0*ggg1(ll)
10805 gradcorr6ij=eel6*g_contij(ll,1)+ekont*derx(ll,1,1)
10806 gradcorr6kl=eel6*g_contij(ll,2)+ekont*derx(ll,1,2)
10807 gradcorr6(ll,i)=gradcorr6(ll,i)+ekont*derx(ll,2,1)
10808 gradcorr6(ll,i+1)=gradcorr6(ll,i+1)+ekont*derx(ll,3,1)
10809 gradcorr6(ll,j)=gradcorr6(ll,j)+ekont*derx(ll,4,1)
10810 gradcorr6(ll,j1)=gradcorr6(ll,j1)+ekont*derx(ll,5,1)
10811 gradcorr6_long(ll,j)=gradcorr6_long(ll,j)+gradcorr6ij
10812 gradcorr6_long(ll,i)=gradcorr6_long(ll,i)-gradcorr6ij
10813 !grad ghalf=0.5d0*ggg2(ll)
10814 !old ghalf=0.5d0*eel6*eij*gacont_hbr(ll,kk,k)
10816 gradcorr6(ll,k)=gradcorr6(ll,k)+ekont*derx(ll,2,2)
10817 gradcorr6(ll,k+1)=gradcorr6(ll,k+1)+ekont*derx(ll,3,2)
10818 gradcorr6(ll,l)=gradcorr6(ll,l)+ekont*derx(ll,4,2)
10819 gradcorr6(ll,l1)=gradcorr6(ll,l1)+ekont*derx(ll,5,2)
10820 gradcorr6_long(ll,l)=gradcorr6_long(ll,l)+gradcorr6kl
10821 gradcorr6_long(ll,k)=gradcorr6_long(ll,k)-gradcorr6kl
10826 !old gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*ekl*gacont_hbr(ll,jj,i)
10827 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ggg1(ll)
10832 !old gradcorr6(ll,m)=gradcorr6(ll,m)+eel6*eij*gacont_hbr(ll,kk,k)
10833 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ggg2(ll)
10839 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,1)
10844 !grad gradcorr6(ll,m)=gradcorr6(ll,m)+ekont*derx(ll,1,2)
10848 !d write (2,*) iii,g_corr6_loc(iii)
10851 !d write (2,*) 'ekont',ekont
10852 !d write (iout,*) 'eello6',ekont*eel6
10854 end function eello6
10855 !-----------------------------------------------------------------------------
10856 real(kind=8) function eello6_graph1(i,j,k,l,imat,swap)
10858 ! implicit real(kind=8) (a-h,o-z)
10859 ! include 'DIMENSIONS'
10860 ! include 'COMMON.IOUNITS'
10861 ! include 'COMMON.CHAIN'
10862 ! include 'COMMON.DERIV'
10863 ! include 'COMMON.INTERACT'
10864 ! include 'COMMON.CONTACTS'
10865 ! include 'COMMON.TORSION'
10866 ! include 'COMMON.VAR'
10867 ! include 'COMMON.GEO'
10868 real(kind=8),dimension(2) :: vv,vv1
10869 real(kind=8),dimension(2,2) :: pizda,auxmat,pizda1
10871 !el logical :: lprn
10872 !el common /kutas/ lprn
10873 integer :: i,j,k,l,imat,itk,iii,kkk,lll,ind
10874 real(kind=8) :: s1,s2,s3,s4,s5
10875 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
10877 ! Parallel Antiparallel C
10883 ! \ j|/k\| / \ |/k\|l / C
10884 ! \ / \ / \ / \ / C
10888 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
10889 itk=itortyp(itype(k,1))
10890 s1= scalar2(AEAb1(1,2,imat),CUgb2(1,i))
10891 s2=-scalar2(AEAb2(1,1,imat),Ug2Db1t(1,k))
10892 s3= scalar2(AEAb2(1,1,imat),CUgb2(1,k))
10893 call transpose2(EUgC(1,1,k),auxmat(1,1))
10894 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
10895 vv1(1)=pizda1(1,1)-pizda1(2,2)
10896 vv1(2)=pizda1(1,2)+pizda1(2,1)
10897 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
10898 vv(1)=AEAb1(1,2,imat)*b1(1,itk)-AEAb1(2,2,imat)*b1(2,itk)
10899 vv(2)=AEAb1(1,2,imat)*b1(2,itk)+AEAb1(2,2,imat)*b1(1,itk)
10900 s5=scalar2(vv(1),Dtobr2(1,i))
10901 !d write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4', s4,' s5',s5
10902 eello6_graph1=-0.5d0*(s1+s2+s3+s4+s5)
10903 if (i.gt.1) g_corr6_loc(i-1)=g_corr6_loc(i-1) &
10904 -0.5d0*ekont*(scalar2(AEAb1(1,2,imat),CUgb2der(1,i)) &
10905 -scalar2(AEAb2derg(1,2,1,imat),Ug2Db1t(1,k)) &
10906 +scalar2(AEAb2derg(1,2,1,imat),CUgb2(1,k)) &
10907 +0.5d0*scalar2(vv1(1),Dtobr2der(1,i)) &
10908 +scalar2(vv(1),Dtobr2der(1,i)))
10909 call matmat2(AEAderg(1,1,imat),auxmat(1,1),pizda1(1,1))
10910 vv1(1)=pizda1(1,1)-pizda1(2,2)
10911 vv1(2)=pizda1(1,2)+pizda1(2,1)
10912 vv(1)=AEAb1derg(1,2,imat)*b1(1,itk)-AEAb1derg(2,2,imat)*b1(2,itk)
10913 vv(2)=AEAb1derg(1,2,imat)*b1(2,itk)+AEAb1derg(2,2,imat)*b1(1,itk)
10915 g_corr6_loc(l-1)=g_corr6_loc(l-1) &
10916 +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i)) &
10917 -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k)) &
10918 +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k)) &
10919 +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
10921 g_corr6_loc(j-1)=g_corr6_loc(j-1) &
10922 +ekont*(-0.5d0*(scalar2(AEAb1derg(1,2,imat),CUgb2(1,i)) &
10923 -scalar2(AEAb2derg(1,1,1,imat),Ug2Db1t(1,k)) &
10924 +scalar2(AEAb2derg(1,1,1,imat),CUgb2(1,k)) &
10925 +0.5d0*scalar2(vv1(1),Dtobr2(1,i))+scalar2(vv(1),Dtobr2(1,i))))
10927 call transpose2(EUgCder(1,1,k),auxmat(1,1))
10928 call matmat2(AEA(1,1,imat),auxmat(1,1),pizda1(1,1))
10929 vv1(1)=pizda1(1,1)-pizda1(2,2)
10930 vv1(2)=pizda1(1,2)+pizda1(2,1)
10931 if (k.gt.1) g_corr6_loc(k-1)=g_corr6_loc(k-1) &
10932 +ekont*(-0.5d0*(-scalar2(AEAb2(1,1,imat),Ug2Db1tder(1,k)) &
10933 +scalar2(AEAb2(1,1,imat),CUgb2der(1,k)) &
10934 +0.5d0*scalar2(vv1(1),Dtobr2(1,i))))
10943 s1= scalar2(AEAb1derx(1,lll,kkk,iii,2,imat),CUgb2(1,i))
10944 s2=-scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),Ug2Db1t(1,k))
10945 s3= scalar2(AEAb2derx(1,lll,kkk,iii,1,imat),CUgb2(1,k))
10946 call transpose2(EUgC(1,1,k),auxmat(1,1))
10947 call matmat2(AEAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),&
10949 vv1(1)=pizda1(1,1)-pizda1(2,2)
10950 vv1(2)=pizda1(1,2)+pizda1(2,1)
10951 s4=0.5d0*scalar2(vv1(1),Dtobr2(1,i))
10952 vv(1)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(1,itk) &
10953 -AEAb1derx(2,lll,kkk,iii,2,imat)*b1(2,itk)
10954 vv(2)=AEAb1derx(1,lll,kkk,iii,2,imat)*b1(2,itk) &
10955 +AEAb1derx(2,lll,kkk,iii,2,imat)*b1(1,itk)
10956 s5=scalar2(vv(1),Dtobr2(1,i))
10957 derx(lll,kkk,ind)=derx(lll,kkk,ind)-0.5d0*(s1+s2+s3+s4+s5)
10962 end function eello6_graph1
10963 !-----------------------------------------------------------------------------
10964 real(kind=8) function eello6_graph2(i,j,k,l,jj,kk,swap)
10966 ! implicit real(kind=8) (a-h,o-z)
10967 ! include 'DIMENSIONS'
10968 ! include 'COMMON.IOUNITS'
10969 ! include 'COMMON.CHAIN'
10970 ! include 'COMMON.DERIV'
10971 ! include 'COMMON.INTERACT'
10972 ! include 'COMMON.CONTACTS'
10973 ! include 'COMMON.TORSION'
10974 ! include 'COMMON.VAR'
10975 ! include 'COMMON.GEO'
10977 real(kind=8),dimension(2) :: vv,auxvec,auxvec1,auxvec2
10978 real(kind=8),dimension(2,2) :: pizda,auxmat,auxmat1
10979 !el logical :: lprn
10980 !el common /kutas/ lprn
10981 integer :: i,j,k,l,jj,kk,iii,kkk,lll,jjj,mmm
10982 real(kind=8) :: s2,s3,s4
10983 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
10985 ! Parallel Antiparallel C
10991 ! \ j|/k\| \ |/k\|l C
10996 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
10997 !d write (2,*) 'eello6_graph2: i,',i,' j',j,' k',k,' l',l
10998 ! AL 7/4/01 s1 would occur in the sixth-order moment,
10999 ! but not in a cluster cumulant
11001 s1=dip(1,jj,i)*dip(1,kk,k)
11003 call matvec2(ADtEA1(1,1,1),Ub2(1,k),auxvec(1))
11004 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
11005 call matvec2(ADtEA(1,1,2),Ub2(1,l),auxvec1(1))
11006 s3=-0.5d0*scalar2(Ub2(1,j),auxvec1(1))
11007 call transpose2(EUg(1,1,k),auxmat(1,1))
11008 call matmat2(ADtEA1(1,1,1),auxmat(1,1),pizda(1,1))
11009 vv(1)=pizda(1,1)-pizda(2,2)
11010 vv(2)=pizda(1,2)+pizda(2,1)
11011 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
11012 !d write (2,*) 'eello6_graph2:','s1',s1,' s2',s2,' s3',s3,' s4',s4
11014 eello6_graph2=-(s1+s2+s3+s4)
11016 eello6_graph2=-(s2+s3+s4)
11018 ! eello6_graph2=-s3
11019 ! Derivatives in gamma(i-1)
11022 s1=dipderg(1,jj,i)*dip(1,kk,k)
11024 s2=-0.5d0*scalar2(Ub2der(1,i),auxvec(1))
11025 call matvec2(ADtEAderg(1,1,1,2),Ub2(1,l),auxvec2(1))
11026 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
11027 s4=-0.25d0*scalar2(vv(1),Dtobr2der(1,i))
11029 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
11031 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
11033 ! g_corr6_loc(i-1)=g_corr6_loc(i-1)-s3
11035 ! Derivatives in gamma(k-1)
11037 s1=dip(1,jj,i)*dipderg(1,kk,k)
11039 call matvec2(ADtEA1(1,1,1),Ub2der(1,k),auxvec2(1))
11040 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
11041 call matvec2(ADtEAderg(1,1,2,2),Ub2(1,l),auxvec2(1))
11042 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
11043 call transpose2(EUgder(1,1,k),auxmat1(1,1))
11044 call matmat2(ADtEA1(1,1,1),auxmat1(1,1),pizda(1,1))
11045 vv(1)=pizda(1,1)-pizda(2,2)
11046 vv(2)=pizda(1,2)+pizda(2,1)
11047 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
11049 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
11051 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
11053 ! g_corr6_loc(k-1)=g_corr6_loc(k-1)-s3
11054 ! Derivatives in gamma(j-1) or gamma(l-1)
11057 s1=dipderg(3,jj,i)*dip(1,kk,k)
11059 call matvec2(ADtEA1derg(1,1,1,1),Ub2(1,k),auxvec2(1))
11060 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
11061 s3=-0.5d0*scalar2(Ub2der(1,j),auxvec1(1))
11062 call matmat2(ADtEA1derg(1,1,1,1),auxmat(1,1),pizda(1,1))
11063 vv(1)=pizda(1,1)-pizda(2,2)
11064 vv(2)=pizda(1,2)+pizda(2,1)
11065 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
11068 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
11070 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
11073 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s3+s4)
11074 ! g_corr6_loc(j-1)=g_corr6_loc(j-1)-s3
11076 ! Derivatives in gamma(l-1) or gamma(j-1)
11079 s1=dip(1,jj,i)*dipderg(3,kk,k)
11081 call matvec2(ADtEA1derg(1,1,2,1),Ub2(1,k),auxvec2(1))
11082 s2=-0.5d0*scalar2(Ub2(1,i),auxvec2(1))
11083 call matvec2(ADtEA(1,1,2),Ub2der(1,l),auxvec2(1))
11084 s3=-0.5d0*scalar2(Ub2(1,j),auxvec2(1))
11085 call matmat2(ADtEA1derg(1,1,2,1),auxmat(1,1),pizda(1,1))
11086 vv(1)=pizda(1,1)-pizda(2,2)
11087 vv(2)=pizda(1,2)+pizda(2,1)
11088 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
11091 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*s1
11093 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*s1
11096 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s3+s4)
11097 ! g_corr6_loc(l-1)=g_corr6_loc(l-1)-s3
11099 ! Cartesian derivatives.
11101 write (2,*) 'In eello6_graph2'
11103 write (2,*) 'iii=',iii
11105 write (2,*) 'kkk=',kkk
11107 write (2,'(3(2f10.5),5x)') &
11108 ((ADtEA1derx(jjj,mmm,lll,kkk,iii,1),mmm=1,2),lll=1,3)
11118 s1=dipderx(lll,kkk,1,jj,i)*dip(1,kk,k)
11120 s1=dip(1,jj,i)*dipderx(lll,kkk,1,kk,k)
11123 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,1),Ub2(1,k),&
11125 s2=-0.5d0*scalar2(Ub2(1,i),auxvec(1))
11126 call matvec2(ADtEAderx(1,1,lll,kkk,iii,2),Ub2(1,l),&
11128 s3=-0.5d0*scalar2(Ub2(1,j),auxvec(1))
11129 call transpose2(EUg(1,1,k),auxmat(1,1))
11130 call matmat2(ADtEA1derx(1,1,lll,kkk,iii,1),auxmat(1,1),&
11132 vv(1)=pizda(1,1)-pizda(2,2)
11133 vv(2)=pizda(1,2)+pizda(2,1)
11134 s4=-0.25d0*scalar2(vv(1),Dtobr2(1,i))
11135 !d write (2,*) 's1',s1,' s2',s2,' s3',s3,' s4',s4
11137 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
11139 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
11142 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
11144 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
11150 end function eello6_graph2
11151 !-----------------------------------------------------------------------------
11152 real(kind=8) function eello6_graph3(i,j,k,l,jj,kk,swap)
11153 ! implicit real(kind=8) (a-h,o-z)
11154 ! include 'DIMENSIONS'
11155 ! include 'COMMON.IOUNITS'
11156 ! include 'COMMON.CHAIN'
11157 ! include 'COMMON.DERIV'
11158 ! include 'COMMON.INTERACT'
11159 ! include 'COMMON.CONTACTS'
11160 ! include 'COMMON.TORSION'
11161 ! include 'COMMON.VAR'
11162 ! include 'COMMON.GEO'
11163 real(kind=8),dimension(2) :: vv,auxvec
11164 real(kind=8),dimension(2,2) :: pizda,auxmat
11166 integer :: i,j,k,l,jj,kk,iti,itj1,itk,itk1,iii,lll,kkk,itl1
11167 real(kind=8) :: s1,s2,s3,s4
11168 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
11170 ! Parallel Antiparallel C
11175 ! /| o |o o| o |\ C
11176 ! j|/k\| / |/k\|l / C
11181 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
11183 ! 4/7/01 AL Component s1 was removed, because it pertains to the respective
11184 ! energy moment and not to the cluster cumulant.
11185 iti=itortyp(itype(i,1))
11186 if (j.lt.nres-1) then
11187 itj1=itortyp(itype(j+1,1))
11191 itk=itortyp(itype(k,1))
11192 itk1=itortyp(itype(k+1,1))
11193 if (l.lt.nres-1) then
11194 itl1=itortyp(itype(l+1,1))
11199 s1=dip(4,jj,i)*dip(4,kk,k)
11201 call matvec2(AECA(1,1,1),b1(1,itk1),auxvec(1))
11202 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
11203 call matvec2(AECA(1,1,2),b1(1,itl1),auxvec(1))
11204 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
11205 call transpose2(EE(1,1,itk),auxmat(1,1))
11206 call matmat2(auxmat(1,1),AECA(1,1,1),pizda(1,1))
11207 vv(1)=pizda(1,1)+pizda(2,2)
11208 vv(2)=pizda(2,1)-pizda(1,2)
11209 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
11210 !d write (2,*) 'eello6_graph3:','s1',s1,' s2',s2,' s3',s3,' s4',s4,
11211 !d & "sum",-(s2+s3+s4)
11213 eello6_graph3=-(s1+s2+s3+s4)
11215 eello6_graph3=-(s2+s3+s4)
11217 ! eello6_graph3=-s4
11218 ! Derivatives in gamma(k-1)
11219 call matvec2(AECAderg(1,1,2),b1(1,itl1),auxvec(1))
11220 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
11221 s4=-0.25d0*scalar2(vv(1),Ctobrder(1,k))
11222 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s3+s4)
11223 ! Derivatives in gamma(l-1)
11224 call matvec2(AECAderg(1,1,1),b1(1,itk1),auxvec(1))
11225 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
11226 call matmat2(auxmat(1,1),AECAderg(1,1,1),pizda(1,1))
11227 vv(1)=pizda(1,1)+pizda(2,2)
11228 vv(2)=pizda(2,1)-pizda(1,2)
11229 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
11230 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
11231 ! Cartesian derivatives.
11237 s1=dipderx(lll,kkk,4,jj,i)*dip(4,kk,k)
11239 s1=dip(4,jj,i)*dipderx(lll,kkk,4,kk,k)
11242 call matvec2(AECAderx(1,1,lll,kkk,iii,1),b1(1,itk1),&
11244 s2=0.5d0*scalar2(b1(1,itk),auxvec(1))
11245 call matvec2(AECAderx(1,1,lll,kkk,iii,2),b1(1,itl1),&
11247 s3=0.5d0*scalar2(b1(1,itj1),auxvec(1))
11248 call matmat2(auxmat(1,1),AECAderx(1,1,lll,kkk,iii,1),&
11250 vv(1)=pizda(1,1)+pizda(2,2)
11251 vv(2)=pizda(2,1)-pizda(1,2)
11252 s4=-0.25d0*scalar2(vv(1),Ctobr(1,k))
11254 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
11256 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
11259 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
11261 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
11263 ! derx(lll,kkk,iii)=derx(lll,kkk,iii)-s4
11268 end function eello6_graph3
11269 !-----------------------------------------------------------------------------
11270 real(kind=8) function eello6_graph4(i,j,k,l,jj,kk,imat,swap)
11271 ! implicit real(kind=8) (a-h,o-z)
11272 ! include 'DIMENSIONS'
11273 ! include 'COMMON.IOUNITS'
11274 ! include 'COMMON.CHAIN'
11275 ! include 'COMMON.DERIV'
11276 ! include 'COMMON.INTERACT'
11277 ! include 'COMMON.CONTACTS'
11278 ! include 'COMMON.TORSION'
11279 ! include 'COMMON.VAR'
11280 ! include 'COMMON.GEO'
11281 ! include 'COMMON.FFIELD'
11282 real(kind=8),dimension(2) :: vv,auxvec,auxvec1
11283 real(kind=8),dimension(2,2) :: pizda,auxmat,auxmat1
11285 integer :: i,j,k,l,jj,kk,imat,iti,itj,itj1,itk,itk1,itl,itl1,&
11287 real(kind=8) :: s1,s2,s3,s4
11288 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
11290 ! Parallel Antiparallel C
11295 ! /| o |o o| o |\ C
11296 ! \ j|/k\| \ |/k\|l C
11301 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
11303 ! 4/7/01 AL Component s1 was removed, because it pertains to the respective
11304 ! energy moment and not to the cluster cumulant.
11305 !d write (2,*) 'eello_graph4: wturn6',wturn6
11306 iti=itortyp(itype(i,1))
11307 itj=itortyp(itype(j,1))
11308 if (j.lt.nres-1) then
11309 itj1=itortyp(itype(j+1,1))
11313 itk=itortyp(itype(k,1))
11314 if (k.lt.nres-1) then
11315 itk1=itortyp(itype(k+1,1))
11319 itl=itortyp(itype(l,1))
11320 if (l.lt.nres-1) then
11321 itl1=itortyp(itype(l+1,1))
11325 !d write (2,*) 'eello6_graph4:','i',i,' j',j,' k',k,' l',l
11326 !d write (2,*) 'iti',iti,' itj',itj,' itj1',itj1,' itk',itk,
11327 !d & ' itl',itl,' itl1',itl1
11329 if (imat.eq.1) then
11330 s1=dip(3,jj,i)*dip(3,kk,k)
11332 s1=dip(2,jj,j)*dip(2,kk,l)
11335 call matvec2(AECA(1,1,imat),Ub2(1,k),auxvec(1))
11336 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
11338 call matvec2(ADtEA1(1,1,3-imat),b1(1,itj1),auxvec1(1))
11339 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
11341 call matvec2(ADtEA1(1,1,3-imat),b1(1,itl1),auxvec1(1))
11342 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
11344 call transpose2(EUg(1,1,k),auxmat(1,1))
11345 call matmat2(AECA(1,1,imat),auxmat(1,1),pizda(1,1))
11346 vv(1)=pizda(1,1)-pizda(2,2)
11347 vv(2)=pizda(2,1)+pizda(1,2)
11348 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
11349 !d write (2,*) 'eello6_graph4:','s1',s1,' s2',s2,' s3',s3,' s4',s4
11351 eello6_graph4=-(s1+s2+s3+s4)
11353 eello6_graph4=-(s2+s3+s4)
11355 ! Derivatives in gamma(i-1)
11358 if (imat.eq.1) then
11359 s1=dipderg(2,jj,i)*dip(3,kk,k)
11361 s1=dipderg(4,jj,j)*dip(2,kk,l)
11364 s2=0.5d0*scalar2(Ub2der(1,i),auxvec(1))
11366 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,itj1),auxvec1(1))
11367 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
11369 call matvec2(ADtEA1derg(1,1,1,3-imat),b1(1,itl1),auxvec1(1))
11370 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
11372 s4=0.25d0*scalar2(vv(1),Dtobr2der(1,i))
11373 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
11374 !d write (2,*) 'turn6 derivatives'
11376 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s1+s2+s3+s4)
11378 gel_loc_turn6(i-1)=gel_loc_turn6(i-1)-ekont*(s2+s3+s4)
11382 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s1+s2+s3+s4)
11384 g_corr6_loc(i-1)=g_corr6_loc(i-1)-ekont*(s2+s3+s4)
11388 ! Derivatives in gamma(k-1)
11390 if (imat.eq.1) then
11391 s1=dip(3,jj,i)*dipderg(2,kk,k)
11393 s1=dip(2,jj,j)*dipderg(4,kk,l)
11396 call matvec2(AECA(1,1,imat),Ub2der(1,k),auxvec1(1))
11397 s2=0.5d0*scalar2(Ub2(1,i),auxvec1(1))
11399 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,itj1),auxvec1(1))
11400 s3=-0.5d0*scalar2(b1(1,itj),auxvec1(1))
11402 call matvec2(ADtEA1derg(1,1,2,3-imat),b1(1,itl1),auxvec1(1))
11403 s3=-0.5d0*scalar2(b1(1,itl),auxvec1(1))
11405 call transpose2(EUgder(1,1,k),auxmat1(1,1))
11406 call matmat2(AECA(1,1,imat),auxmat1(1,1),pizda(1,1))
11407 vv(1)=pizda(1,1)-pizda(2,2)
11408 vv(2)=pizda(2,1)+pizda(1,2)
11409 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
11410 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
11412 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s1+s2+s3+s4)
11414 gel_loc_turn6(k-1)=gel_loc_turn6(k-1)-ekont*(s2+s3+s4)
11418 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s1+s2+s3+s4)
11420 g_corr6_loc(k-1)=g_corr6_loc(k-1)-ekont*(s2+s3+s4)
11423 ! Derivatives in gamma(j-1) or gamma(l-1)
11424 if (l.eq.j+1 .and. l.gt.1) then
11425 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
11426 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
11427 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
11428 vv(1)=pizda(1,1)-pizda(2,2)
11429 vv(2)=pizda(2,1)+pizda(1,2)
11430 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
11431 g_corr6_loc(l-1)=g_corr6_loc(l-1)-ekont*(s2+s4)
11432 else if (j.gt.1) then
11433 call matvec2(AECAderg(1,1,imat),Ub2(1,k),auxvec(1))
11434 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
11435 call matmat2(AECAderg(1,1,imat),auxmat(1,1),pizda(1,1))
11436 vv(1)=pizda(1,1)-pizda(2,2)
11437 vv(2)=pizda(2,1)+pizda(1,2)
11438 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
11439 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
11440 gel_loc_turn6(j-1)=gel_loc_turn6(j-1)-ekont*(s2+s4)
11442 g_corr6_loc(j-1)=g_corr6_loc(j-1)-ekont*(s2+s4)
11445 ! Cartesian derivatives.
11451 if (imat.eq.1) then
11452 s1=dipderx(lll,kkk,3,jj,i)*dip(3,kk,k)
11454 s1=dipderx(lll,kkk,2,jj,j)*dip(2,kk,l)
11457 if (imat.eq.1) then
11458 s1=dip(3,jj,i)*dipderx(lll,kkk,3,kk,k)
11460 s1=dip(2,jj,j)*dipderx(lll,kkk,2,kk,l)
11464 call matvec2(AECAderx(1,1,lll,kkk,iii,imat),Ub2(1,k),&
11466 s2=0.5d0*scalar2(Ub2(1,i),auxvec(1))
11468 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),&
11469 b1(1,itj1),auxvec(1))
11470 s3=-0.5d0*scalar2(b1(1,itj),auxvec(1))
11472 call matvec2(ADtEA1derx(1,1,lll,kkk,iii,3-imat),&
11473 b1(1,itl1),auxvec(1))
11474 s3=-0.5d0*scalar2(b1(1,itl),auxvec(1))
11476 call matmat2(AECAderx(1,1,lll,kkk,iii,imat),auxmat(1,1),&
11478 vv(1)=pizda(1,1)-pizda(2,2)
11479 vv(2)=pizda(2,1)+pizda(1,2)
11480 s4=0.25d0*scalar2(vv(1),Dtobr2(1,i))
11482 if (wturn6.gt.0.0d0 .and. k.eq.l+4 .and. i.eq.j+2) then
11484 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii) &
11487 derx_turn(lll,kkk,3-iii)=derx_turn(lll,kkk,3-iii) &
11490 derx_turn(lll,kkk,iii)=derx_turn(lll,kkk,iii)-s3
11493 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s1+s2+s4)
11495 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-(s2+s4)
11497 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
11501 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s1+s2+s4)
11503 derx(lll,kkk,iii)=derx(lll,kkk,iii)-(s2+s4)
11506 derx(lll,kkk,iii)=derx(lll,kkk,iii)-s3
11508 derx(lll,kkk,3-iii)=derx(lll,kkk,3-iii)-s3
11515 end function eello6_graph4
11516 !-----------------------------------------------------------------------------
11517 real(kind=8) function eello_turn6(i,jj,kk)
11518 ! implicit real(kind=8) (a-h,o-z)
11519 ! include 'DIMENSIONS'
11520 ! include 'COMMON.IOUNITS'
11521 ! include 'COMMON.CHAIN'
11522 ! include 'COMMON.DERIV'
11523 ! include 'COMMON.INTERACT'
11524 ! include 'COMMON.CONTACTS'
11525 ! include 'COMMON.TORSION'
11526 ! include 'COMMON.VAR'
11527 ! include 'COMMON.GEO'
11528 real(kind=8),dimension(2) :: vtemp1,vtemp2,vtemp3,vtemp4,gvec
11529 real(kind=8),dimension(2,2) :: atemp,auxmat,achuj_temp,gtemp
11530 real(kind=8),dimension(3) :: ggg1,ggg2
11531 real(kind=8),dimension(2) :: vtemp1d,vtemp2d,vtemp3d,vtemp4d,gvecd
11532 real(kind=8),dimension(2,2) :: atempd,auxmatd,achuj_tempd,gtempd
11533 ! 4/7/01 AL Components s1, s8, and s13 were removed, because they pertain to
11534 ! the respective energy moment and not to the cluster cumulant.
11535 !el local variables
11536 integer :: i,jj,kk,j,k,l,iti,itk,itk1,itl,itj,iii,kkk,lll
11537 integer :: j1,j2,l1,l2,ll
11538 real(kind=8) :: s1,s2,s8,s13,s12,eello6_5,eel_turn6
11539 real(kind=8) :: s1d,s8d,s12d,s2d,gturn6ij,gturn6kl
11548 iti=itortyp(itype(i,1))
11549 itk=itortyp(itype(k,1))
11550 itk1=itortyp(itype(k+1,1))
11551 itl=itortyp(itype(l,1))
11552 itj=itortyp(itype(j,1))
11553 !d write (2,*) 'itk',itk,' itk1',itk1,' itl',itl,' itj',itj
11554 !d write (2,*) 'i',i,' k',k,' j',j,' l',l
11555 !d if (i.ne.1 .or. j.ne.3 .or. k.ne.2 .or. l.ne.4) then
11560 !d & 'EELLO6: Contacts have occurred for peptide groups',i,j,
11562 !d call checkint_turn6(i,jj,kk,eel_turn6_num)
11566 derx_turn(lll,kkk,iii)=0.0d0
11573 eello6_5=eello6_graph4(l,k,j,i,kk,jj,2,.true.)
11575 !d write (2,*) 'eello6_5',eello6_5
11577 call transpose2(AEA(1,1,1),auxmat(1,1))
11578 call matmat2(EUg(1,1,i+1),auxmat(1,1),auxmat(1,1))
11579 ss1=scalar2(Ub2(1,i+2),b1(1,itl))
11580 s1 = (auxmat(1,1)+auxmat(2,2))*ss1
11582 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1(1))
11583 call matvec2(AEA(1,1,1),vtemp1(1),vtemp1(1))
11584 s2 = scalar2(b1(1,itk),vtemp1(1))
11586 call transpose2(AEA(1,1,2),atemp(1,1))
11587 call matmat2(atemp(1,1),EUg(1,1,i+4),atemp(1,1))
11588 call matvec2(Ug2(1,1,i+2),dd(1,1,itk1),vtemp2(1))
11589 s8 = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
11591 call matmat2(EUg(1,1,i+3),AEA(1,1,2),auxmat(1,1))
11592 call matvec2(auxmat(1,1),Ub2(1,i+4),vtemp3(1))
11593 s12 = scalar2(Ub2(1,i+2),vtemp3(1))
11595 call transpose2(a_chuj(1,1,kk,i+1),achuj_temp(1,1))
11596 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtemp(1,1))
11597 call matmat2(gtemp(1,1),EUg(1,1,i+3),gtemp(1,1))
11598 call matvec2(a_chuj(1,1,jj,i),Ub2(1,i+4),vtemp4(1))
11599 ss13 = scalar2(b1(1,itk),vtemp4(1))
11600 s13 = (gtemp(1,1)+gtemp(2,2))*ss13
11602 ! write (2,*) 's1,s2,s8,s12,s13',s1,s2,s8,s12,s13
11608 eel_turn6 = eello6_5 - 0.5d0*(s1+s2+s12+s8+s13)
11609 ! Derivatives in gamma(i+2)
11613 call transpose2(AEA(1,1,1),auxmatd(1,1))
11614 call matmat2(EUgder(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
11615 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
11616 call transpose2(AEAderg(1,1,2),atempd(1,1))
11617 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
11618 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
11620 call matmat2(EUg(1,1,i+3),AEAderg(1,1,2),auxmatd(1,1))
11621 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
11622 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
11628 gel_loc_turn6(i)=gel_loc_turn6(i)-0.5d0*ekont*(s1d+s8d+s12d)
11629 ! Derivatives in gamma(i+3)
11631 call transpose2(AEA(1,1,1),auxmatd(1,1))
11632 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
11633 ss1d=scalar2(Ub2der(1,i+2),b1(1,itl))
11634 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1d
11636 call matvec2(EUgder(1,1,i+2),b1(1,itl),vtemp1d(1))
11637 call matvec2(AEA(1,1,1),vtemp1d(1),vtemp1d(1))
11638 s2d = scalar2(b1(1,itk),vtemp1d(1))
11640 call matvec2(Ug2der(1,1,i+2),dd(1,1,itk1),vtemp2d(1))
11641 s8d = -(atemp(1,1)+atemp(2,2))*scalar2(cc(1,1,itl),vtemp2d(1))
11643 s12d = scalar2(Ub2der(1,i+2),vtemp3(1))
11645 call matmat2(achuj_temp(1,1),EUgder(1,1,i+2),gtempd(1,1))
11646 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
11647 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
11655 gel_loc_turn6(i+1)=gel_loc_turn6(i+1) &
11656 -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
11658 gel_loc_turn6(i+1)=gel_loc_turn6(i+1) &
11659 -0.5d0*ekont*(s2d+s12d)
11661 ! Derivatives in gamma(i+4)
11662 call matmat2(EUgder(1,1,i+3),AEA(1,1,2),auxmatd(1,1))
11663 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
11664 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
11666 call matmat2(achuj_temp(1,1),EUg(1,1,i+2),gtempd(1,1))
11667 call matmat2(gtempd(1,1),EUgder(1,1,i+3),gtempd(1,1))
11668 s13d = (gtempd(1,1)+gtempd(2,2))*ss13
11676 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d+s13d)
11678 gel_loc_turn6(i+2)=gel_loc_turn6(i+2)-0.5d0*ekont*(s12d)
11680 ! Derivatives in gamma(i+5)
11682 call transpose2(AEAderg(1,1,1),auxmatd(1,1))
11683 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
11684 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
11686 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1d(1))
11687 call matvec2(AEAderg(1,1,1),vtemp1d(1),vtemp1d(1))
11688 s2d = scalar2(b1(1,itk),vtemp1d(1))
11690 call transpose2(AEA(1,1,2),atempd(1,1))
11691 call matmat2(atempd(1,1),EUgder(1,1,i+4),atempd(1,1))
11692 s8d = -(atempd(1,1)+atempd(2,2))*scalar2(cc(1,1,itl),vtemp2(1))
11694 call matvec2(auxmat(1,1),Ub2der(1,i+4),vtemp3d(1))
11695 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
11697 call matvec2(a_chuj(1,1,jj,i),Ub2der(1,i+4),vtemp4d(1))
11698 ss13d = scalar2(b1(1,itk),vtemp4d(1))
11699 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
11707 gel_loc_turn6(i+3)=gel_loc_turn6(i+3) &
11708 -0.5d0*ekont*(s1d+s2d+s8d+s12d+s13d)
11710 gel_loc_turn6(i+3)=gel_loc_turn6(i+3) &
11711 -0.5d0*ekont*(s2d+s12d)
11713 ! Cartesian derivatives
11718 call transpose2(AEAderx(1,1,lll,kkk,iii,1),auxmatd(1,1))
11719 call matmat2(EUg(1,1,i+1),auxmatd(1,1),auxmatd(1,1))
11720 s1d = (auxmatd(1,1)+auxmatd(2,2))*ss1
11722 call matvec2(EUg(1,1,i+2),b1(1,itl),vtemp1(1))
11723 call matvec2(AEAderx(1,1,lll,kkk,iii,1),vtemp1(1),&
11725 s2d = scalar2(b1(1,itk),vtemp1d(1))
11727 call transpose2(AEAderx(1,1,lll,kkk,iii,2),atempd(1,1))
11728 call matmat2(atempd(1,1),EUg(1,1,i+4),atempd(1,1))
11729 s8d = -(atempd(1,1)+atempd(2,2))* &
11730 scalar2(cc(1,1,itl),vtemp2(1))
11732 call matmat2(EUg(1,1,i+3),AEAderx(1,1,lll,kkk,iii,2),&
11734 call matvec2(auxmatd(1,1),Ub2(1,i+4),vtemp3d(1))
11735 s12d = scalar2(Ub2(1,i+2),vtemp3d(1))
11742 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii) &
11745 derx_turn(lll,kkk,iii) = derx_turn(lll,kkk,iii) &
11749 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii) &
11752 derx_turn(lll,kkk,3-iii) = derx_turn(lll,kkk,3-iii) &
11761 call transpose2(a_chuj_der(1,1,lll,kkk,kk,i+1),&
11763 call matmat2(achuj_tempd(1,1),EUg(1,1,i+2),gtempd(1,1))
11764 call matmat2(gtempd(1,1),EUg(1,1,i+3),gtempd(1,1))
11765 s13d=(gtempd(1,1)+gtempd(2,2))*ss13
11766 derx_turn(lll,kkk,2) = derx_turn(lll,kkk,2)-0.5d0*s13d
11767 call matvec2(a_chuj_der(1,1,lll,kkk,jj,i),Ub2(1,i+4),&
11769 ss13d = scalar2(b1(1,itk),vtemp4d(1))
11770 s13d = (gtemp(1,1)+gtemp(2,2))*ss13d
11771 derx_turn(lll,kkk,1) = derx_turn(lll,kkk,1)-0.5d0*s13d
11775 !d write(iout,*) 'eel6_turn6',eel_turn6,' eel_turn6_num',
11776 !d & 16*eel_turn6_num
11778 if (j.lt.nres-1) then
11785 if (l.lt.nres-1) then
11793 !grad ggg1(ll)=eel_turn6*g_contij(ll,1)
11794 !grad ggg2(ll)=eel_turn6*g_contij(ll,2)
11795 !grad ghalf=0.5d0*ggg1(ll)
11797 gturn6ij=eel_turn6*g_contij(ll,1)+ekont*derx_turn(ll,1,1)
11798 gturn6kl=eel_turn6*g_contij(ll,2)+ekont*derx_turn(ll,1,2)
11799 gcorr6_turn(ll,i)=gcorr6_turn(ll,i) & !+ghalf
11800 +ekont*derx_turn(ll,2,1)
11801 gcorr6_turn(ll,i+1)=gcorr6_turn(ll,i+1)+ekont*derx_turn(ll,3,1)
11802 gcorr6_turn(ll,j)=gcorr6_turn(ll,j) & !+ghalf
11803 +ekont*derx_turn(ll,4,1)
11804 gcorr6_turn(ll,j1)=gcorr6_turn(ll,j1)+ekont*derx_turn(ll,5,1)
11805 gcorr6_turn_long(ll,j)=gcorr6_turn_long(ll,j)+gturn6ij
11806 gcorr6_turn_long(ll,i)=gcorr6_turn_long(ll,i)-gturn6ij
11807 !grad ghalf=0.5d0*ggg2(ll)
11809 gcorr6_turn(ll,k)=gcorr6_turn(ll,k) & !+ghalf
11810 +ekont*derx_turn(ll,2,2)
11811 gcorr6_turn(ll,k+1)=gcorr6_turn(ll,k+1)+ekont*derx_turn(ll,3,2)
11812 gcorr6_turn(ll,l)=gcorr6_turn(ll,l) & !+ghalf
11813 +ekont*derx_turn(ll,4,2)
11814 gcorr6_turn(ll,l1)=gcorr6_turn(ll,l1)+ekont*derx_turn(ll,5,2)
11815 gcorr6_turn_long(ll,l)=gcorr6_turn_long(ll,l)+gturn6kl
11816 gcorr6_turn_long(ll,k)=gcorr6_turn_long(ll,k)-gturn6kl
11821 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg1(ll)
11826 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ggg2(ll)
11832 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,1)
11837 !grad gcorr6_turn(ll,m)=gcorr6_turn(ll,m)+ekont*derx_turn(ll,1,2)
11841 !d write (2,*) iii,g_corr6_loc(iii)
11843 eello_turn6=ekont*eel_turn6
11844 !d write (2,*) 'ekont',ekont
11845 !d write (2,*) 'eel_turn6',ekont*eel_turn6
11847 end function eello_turn6
11848 !-----------------------------------------------------------------------------
11849 subroutine MATVEC2(A1,V1,V2)
11850 !DIR$ INLINEALWAYS MATVEC2
11852 !DEC$ ATTRIBUTES FORCEINLINE::MATVEC2
11854 ! implicit real(kind=8) (a-h,o-z)
11855 ! include 'DIMENSIONS'
11856 real(kind=8),dimension(2) :: V1,V2
11857 real(kind=8),dimension(2,2) :: A1
11858 real(kind=8) :: vaux1,vaux2
11862 ! 3 VI=VI+A1(I,K)*V1(K)
11866 vaux1=a1(1,1)*v1(1)+a1(1,2)*v1(2)
11867 vaux2=a1(2,1)*v1(1)+a1(2,2)*v1(2)
11871 end subroutine MATVEC2
11872 !-----------------------------------------------------------------------------
11873 subroutine MATMAT2(A1,A2,A3)
11875 !DEC$ ATTRIBUTES FORCEINLINE::MATMAT2
11877 ! implicit real(kind=8) (a-h,o-z)
11878 ! include 'DIMENSIONS'
11879 real(kind=8),dimension(2,2) :: A1,A2,A3
11880 real(kind=8) :: ai3_11,ai3_12,ai3_21,ai3_22
11881 ! DIMENSION AI3(2,2)
11885 ! A3IJ=A3IJ+A1(I,K)*A2(K,J)
11891 ai3_11=a1(1,1)*a2(1,1)+a1(1,2)*a2(2,1)
11892 ai3_12=a1(1,1)*a2(1,2)+a1(1,2)*a2(2,2)
11893 ai3_21=a1(2,1)*a2(1,1)+a1(2,2)*a2(2,1)
11894 ai3_22=a1(2,1)*a2(1,2)+a1(2,2)*a2(2,2)
11900 end subroutine MATMAT2
11901 !-----------------------------------------------------------------------------
11902 real(kind=8) function scalar2(u,v)
11903 !DIR$ INLINEALWAYS scalar2
11905 real(kind=8),dimension(2) :: u,v
11908 scalar2=u(1)*v(1)+u(2)*v(2)
11910 end function scalar2
11911 !-----------------------------------------------------------------------------
11912 subroutine transpose2(a,at)
11913 !DIR$ INLINEALWAYS transpose2
11915 !DEC$ ATTRIBUTES FORCEINLINE::transpose2
11918 real(kind=8),dimension(2,2) :: a,at
11924 end subroutine transpose2
11925 !-----------------------------------------------------------------------------
11926 subroutine transpose(n,a,at)
11929 real(kind=8),dimension(n,n) :: a,at
11936 end subroutine transpose
11937 !-----------------------------------------------------------------------------
11938 subroutine prodmat3(a1,a2,kk,transp,prod)
11939 !DIR$ INLINEALWAYS prodmat3
11941 !DEC$ ATTRIBUTES FORCEINLINE::prodmat3
11945 real(kind=8),dimension(2,2) :: a1,a2,a2t,kk,prod
11947 !rc double precision auxmat(2,2),prod_(2,2)
11950 !rc call transpose2(kk(1,1),auxmat(1,1))
11951 !rc call matmat2(a1(1,1),auxmat(1,1),auxmat(1,1))
11952 !rc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
11954 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,1) &
11955 +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,1)
11956 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(1,2))*a2(1,2) &
11957 +(a1(1,1)*kk(2,1)+a1(1,2)*kk(2,2))*a2(2,2)
11958 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,1) &
11959 +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,1)
11960 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(1,2))*a2(1,2) &
11961 +(a1(2,1)*kk(2,1)+a1(2,2)*kk(2,2))*a2(2,2)
11964 !rc call matmat2(a1(1,1),kk(1,1),auxmat(1,1))
11965 !rc call matmat2(auxmat(1,1),a2(1,1),prod_(1,1))
11967 prod(1,1)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,1) &
11968 +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,1)
11969 prod(1,2)=(a1(1,1)*kk(1,1)+a1(1,2)*kk(2,1))*a2(1,2) &
11970 +(a1(1,1)*kk(1,2)+a1(1,2)*kk(2,2))*a2(2,2)
11971 prod(2,1)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,1) &
11972 +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,1)
11973 prod(2,2)=(a1(2,1)*kk(1,1)+a1(2,2)*kk(2,1))*a2(1,2) &
11974 +(a1(2,1)*kk(1,2)+a1(2,2)*kk(2,2))*a2(2,2)
11977 ! call transpose2(a2(1,1),a2t(1,1))
11980 !rc print *,((prod_(i,j),i=1,2),j=1,2)
11981 !rc print *,((prod(i,j),i=1,2),j=1,2)
11984 end subroutine prodmat3
11985 !-----------------------------------------------------------------------------
11986 ! energy_p_new_barrier.F
11987 !-----------------------------------------------------------------------------
11988 subroutine sum_gradient
11989 ! implicit real(kind=8) (a-h,o-z)
11990 use io_base, only: pdbout
11991 ! include 'DIMENSIONS'
11995 !MS$ATTRIBUTES C :: proc_proc
12001 real(kind=8),dimension(3,-1:nres) :: gradbufc,gradbufx,gradbufc_sum,&
12002 gloc_scbuf !(3,maxres)
12004 real(kind=8),dimension(4*nres) :: glocbuf !(4*maxres)
12006 !el local variables
12007 integer :: i,j,k,ierror,ierr
12008 real(kind=8) :: gvdwc_norm,gvdwc_scp_norm,gelc_norm,gvdwpp_norm,&
12009 gradb_norm,ghpbc_norm,gradcorr_norm,gel_loc_norm,&
12010 gcorr3_turn_norm,gcorr4_turn_norm,gradcorr5_norm,&
12011 gradcorr6_norm,gcorr6_turn_norm,gsccorr_norm,&
12012 gscloc_norm,gvdwx_norm,gradx_scp_norm,ghpbx_norm,&
12013 gradxorr_norm,gsccorrx_norm,gsclocx_norm,gcorr6_max,&
12014 gsccorr_max,gsccorrx_max,time00
12016 ! include 'COMMON.SETUP'
12017 ! include 'COMMON.IOUNITS'
12018 ! include 'COMMON.FFIELD'
12019 ! include 'COMMON.DERIV'
12020 ! include 'COMMON.INTERACT'
12021 ! include 'COMMON.SBRIDGE'
12022 ! include 'COMMON.CHAIN'
12023 ! include 'COMMON.VAR'
12024 ! include 'COMMON.CONTROL'
12025 ! include 'COMMON.TIME1'
12026 ! include 'COMMON.MAXGRAD'
12027 ! include 'COMMON.SCCOR'
12033 write (iout,*) "sum_gradient gvdwc, gvdwx"
12035 write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)') &
12036 i,(gvdwx(j,i),j=1,3),(gvdwc(j,i),j=1,3)
12046 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
12047 if (nfgtasks.gt.1 .and. fg_rank.eq.0) &
12048 call MPI_Bcast(1,1,MPI_INTEGER,king,FG_COMM,IERROR)
12051 ! 9/29/08 AL Transform parts of gradients in site coordinates to the gradient
12052 ! in virtual-bond-vector coordinates
12055 ! write (iout,*) "gel_loc gel_loc_long and gel_loc_loc"
12057 ! write (iout,'(i5,3f10.5,2x,3f10.5,2x,f10.5)')
12058 ! & i,(gel_loc(j,i),j=1,3),(gel_loc_long(j,i),j=1,3),gel_loc_loc(i)
12060 ! write (iout,*) "gel_loc_tur3 gel_loc_turn4"
12062 ! write (iout,'(i5,3f10.5,2x,f10.5)')
12063 ! & i,(gcorr4_turn(j,i),j=1,3),gel_loc_turn4(i)
12065 ! write (iout,*) "gvdwc gvdwc_scp gvdwc_scpp"
12067 ! write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)') &
12068 ! i,(gvdwc(j,i),j=1,3),(gvdwc_scp(j,i),j=1,3),&
12069 ! (gvdwc_scpp(j,i),j=1,3)
12071 ! write (iout,*) "gelc_long gvdwpp gel_loc_long"
12073 ! write (iout,'(i3,3f10.5,5x,3f10.5,5x,f10.5)') &
12074 ! i,(gelc_long(j,i),j=1,3),(gvdwpp(j,i),j=1,3),&
12075 ! (gelc_loc_long(j,i),j=1,3)
12082 gradbufc(j,i)=wsc*gvdwc(j,i)+ &
12083 wscp*(gvdwc_scp(j,i)+gvdwc_scpp(j,i))+ &
12084 welec*gelc_long(j,i)+wvdwpp*gvdwpp(j,i)+ &
12085 wel_loc*gel_loc_long(j,i)+ &
12086 wcorr*gradcorr_long(j,i)+ &
12087 wcorr5*gradcorr5_long(j,i)+ &
12088 wcorr6*gradcorr6_long(j,i)+ &
12089 wturn6*gcorr6_turn_long(j,i)+ &
12090 wstrain*ghpbc(j,i) &
12091 +wliptran*gliptranc(j,i) &
12093 +welec*gshieldc(j,i) &
12094 +wcorr*gshieldc_ec(j,i) &
12095 +wturn3*gshieldc_t3(j,i)&
12096 +wturn4*gshieldc_t4(j,i)&
12097 +wel_loc*gshieldc_ll(j,i)&
12098 +wtube*gg_tube(j,i) &
12099 +wvdwpp_nucl*gvdwpp_nucl(j,i)+welpp*gelpp(j,i)+ &
12100 wvdwpsb*(gvdwpsb(j,i)+gvdwpsb1(j,i))+ &
12101 wvdwsb*gvdwsbc(j,i)+welsb*gelsbc(j,i)+ &
12102 wcorr_nucl*gradcorr_nucl(j,i)&
12103 +wcorr3_nucl*gradcorr3_nucl(j,i)+&
12104 wcatprot* gradpepcat(j,i)+ &
12105 wcatcat*gradcatcat(j,i)+ &
12106 wscbase*gvdwc_scbase(j,i)+ &
12107 wpepbase*gvdwc_pepbase(j,i)+&
12108 wscpho*gvdwc_scpho(j,i)+ &
12109 wpeppho*gvdwc_peppho(j,i)+wcatnucl*gradnuclcat(j,i)+ &
12110 gradlipbond(j,i)+gradlipang(j,i)+gradliplj(j,i)+gradlipelec(j,i)+&
12111 wcat_tran*gradcattranc(j,i)+gradcatangc(j,i)
12122 gradbufc(j,i)=wsc*gvdwc(j,i)+ &
12123 wscp*(gvdwc_scp(j,i)+gvdwc_scpp(j,i))+ &
12124 welec*gelc_long(j,i)+ &
12125 wbond*gradb(j,i)+ &
12126 wel_loc*gel_loc_long(j,i)+ &
12127 wcorr*gradcorr_long(j,i)+ &
12128 wcorr5*gradcorr5_long(j,i)+ &
12129 wcorr6*gradcorr6_long(j,i)+ &
12130 wturn6*gcorr6_turn_long(j,i)+ &
12131 wstrain*ghpbc(j,i) &
12132 +wliptran*gliptranc(j,i) &
12134 +welec*gshieldc(j,i)&
12135 +wcorr*gshieldc_ec(j,i) &
12136 +wturn4*gshieldc_t4(j,i) &
12137 +wel_loc*gshieldc_ll(j,i)&
12138 +wtube*gg_tube(j,i) &
12139 +wvdwpp_nucl*gvdwpp_nucl(j,i)+welpp*gelpp(j,i)+ &
12140 wvdwpsb*(gvdwpsb(j,i)+gvdwpsb1(j,i))+ &
12141 wvdwsb*gvdwsbc(j,i)+welsb*gelsbc(j,i)+ &
12142 wcorr_nucl*gradcorr_nucl(j,i) &
12143 +wcorr3_nucl*gradcorr3_nucl(j,i) +&
12144 wcatprot* gradpepcat(j,i)+ &
12145 wcatcat*gradcatcat(j,i)+ &
12146 wscbase*gvdwc_scbase(j,i)+ &
12147 wpepbase*gvdwc_pepbase(j,i)+&
12148 wscpho*gvdwc_scpho(j,i)+&
12149 wpeppho*gvdwc_peppho(j,i)+wcatnucl*gradnuclcat(j,i)+&
12150 gradlipbond(j,i)+gradlipang(j,i)+gradliplj(j,i)+gradlipelec(j,i)+&
12151 wcat_tran*gradcattranc(j,i)+gradcatangc(j,i)
12159 if (nfgtasks.gt.1) then
12162 write (iout,*) "gradbufc before allreduce"
12164 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
12170 gradbufc_sum(j,i)=gradbufc(j,i)
12173 ! call MPI_AllReduce(gradbufc(1,1),gradbufc_sum(1,1),3*nres,
12174 ! & MPI_DOUBLE_PRECISION,MPI_SUM,FG_COMM,IERR)
12175 ! time_reduce=time_reduce+MPI_Wtime()-time00
12177 ! write (iout,*) "gradbufc_sum after allreduce"
12179 ! write (iout,'(i3,3f10.5)') i,(gradbufc_sum(j,i),j=1,3)
12184 ! time_allreduce=time_allreduce+MPI_Wtime()-time00
12188 gradbufc(k,i)=0.0d0
12192 write (iout,*) "igrad_start",igrad_start," igrad_end",igrad_end
12193 write (iout,*) (i," jgrad_start",jgrad_start(i),&
12194 " jgrad_end ",jgrad_end(i),&
12195 i=igrad_start,igrad_end)
12198 ! Obsolete and inefficient code; we can make the effort O(n) and, therefore,
12199 ! do not parallelize this part.
12201 ! do i=igrad_start,igrad_end
12202 ! do j=jgrad_start(i),jgrad_end(i)
12204 ! gradbufc(k,i)=gradbufc(k,i)+gradbufc_sum(k,j)
12209 gradbufc(j,nres-1)=gradbufc_sum(j,nres)
12213 gradbufc(j,i)=gradbufc(j,i+1)+gradbufc_sum(j,i+1)
12217 write (iout,*) "gradbufc after summing"
12219 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
12227 write (iout,*) "gradbufc"
12229 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
12236 gradbufc_sum(j,i)=gradbufc(j,i)
12237 gradbufc(j,i)=0.0d0
12241 gradbufc(j,nres-1)=gradbufc_sum(j,nres)
12245 gradbufc(j,i)=gradbufc(j,i+1)+gradbufc_sum(j,i+1)
12250 ! gradbufc(k,i)=0.0d0
12254 ! gradbufc(k,i)=gradbufc(k,i)+gradbufc(k,j)
12260 write (iout,*) "gradbufc after summing"
12262 write (iout,'(i3,3f10.5)') i,(gradbufc(j,i),j=1,3)
12271 gradbufc(k,nres)=0.0d0
12273 !el----------------
12274 !el if (.not.allocated(gradx)) allocate(gradx(3,nres,2)) !(3,maxres,2)
12275 !el if (.not.allocated(gradc)) allocate(gradc(3,nres,2)) !(3,maxres,2)
12276 !el-----------------
12280 gradc(j,i,icg)=gradbufc(j,i)+welec*gelc(j,i)+ &
12281 wel_loc*gel_loc(j,i)+ &
12282 0.5d0*(wscp*gvdwc_scpp(j,i)+ &
12283 welec*gelc_long(j,i)+wvdwpp*gvdwpp(j,i)+ &
12284 wel_loc*gel_loc_long(j,i)+ &
12285 wcorr*gradcorr_long(j,i)+ &
12286 wcorr5*gradcorr5_long(j,i)+ &
12287 wcorr6*gradcorr6_long(j,i)+ &
12288 wturn6*gcorr6_turn_long(j,i))+ &
12289 wbond*gradb(j,i)+ &
12290 wcorr*gradcorr(j,i)+ &
12291 wturn3*gcorr3_turn(j,i)+ &
12292 wturn4*gcorr4_turn(j,i)+ &
12293 wcorr5*gradcorr5(j,i)+ &
12294 wcorr6*gradcorr6(j,i)+ &
12295 wturn6*gcorr6_turn(j,i)+ &
12296 wsccor*gsccorc(j,i) &
12297 +wscloc*gscloc(j,i) &
12298 +wliptran*gliptranc(j,i) &
12300 +welec*gshieldc(j,i) &
12301 +welec*gshieldc_loc(j,i) &
12302 +wcorr*gshieldc_ec(j,i) &
12303 +wcorr*gshieldc_loc_ec(j,i) &
12304 +wturn3*gshieldc_t3(j,i) &
12305 +wturn3*gshieldc_loc_t3(j,i) &
12306 +wturn4*gshieldc_t4(j,i) &
12307 +wturn4*gshieldc_loc_t4(j,i) &
12308 +wel_loc*gshieldc_ll(j,i) &
12309 +wel_loc*gshieldc_loc_ll(j,i) &
12310 +wtube*gg_tube(j,i) &
12311 +0.5d0*(wvdwpp_nucl*gvdwpp_nucl(j,i)+welpp*gelpp(j,i)&
12312 +wvdwpsb*gvdwpsb1(j,i))&
12313 +wbond_nucl*gradb_nucl(j,i)+wsbloc*gsbloc(j,i)!&
12314 ! + gradcattranc(j,i)
12315 ! if (i.eq.21) then
12316 ! print *,"in sum",gradc(j,i,icg),wturn4*gcorr4_turn(j,i),&
12317 ! wturn4*gshieldc_t4(j,i), &
12318 ! wturn4*gshieldc_loc_t4(j,i)
12320 ! if ((i.le.2).and.(i.ge.1))
12321 ! print *,gradc(j,i,icg),&
12322 ! gradbufc(j,i),welec*gelc(j,i), &
12323 ! wel_loc*gel_loc(j,i), &
12324 ! wscp*gvdwc_scpp(j,i), &
12325 ! welec*gelc_long(j,i),wvdwpp*gvdwpp(j,i), &
12326 ! wel_loc*gel_loc_long(j,i), &
12327 ! wcorr*gradcorr_long(j,i), &
12328 ! wcorr5*gradcorr5_long(j,i), &
12329 ! wcorr6*gradcorr6_long(j,i), &
12330 ! wturn6*gcorr6_turn_long(j,i), &
12331 ! wbond*gradb(j,i), &
12332 ! wcorr*gradcorr(j,i), &
12333 ! wturn3*gcorr3_turn(j,i), &
12334 ! wturn4*gcorr4_turn(j,i), &
12335 ! wcorr5*gradcorr5(j,i), &
12336 ! wcorr6*gradcorr6(j,i), &
12337 ! wturn6*gcorr6_turn(j,i), &
12338 ! wsccor*gsccorc(j,i) &
12339 ! ,wscloc*gscloc(j,i) &
12340 ! ,wliptran*gliptranc(j,i) &
12342 ! ,welec*gshieldc(j,i) &
12343 ! ,welec*gshieldc_loc(j,i) &
12344 ! ,wcorr*gshieldc_ec(j,i) &
12345 ! ,wcorr*gshieldc_loc_ec(j,i) &
12346 ! ,wturn3*gshieldc_t3(j,i) &
12347 ! ,wturn3*gshieldc_loc_t3(j,i) &
12348 ! ,wturn4*gshieldc_t4(j,i) &
12349 ! ,wturn4*gshieldc_loc_t4(j,i) &
12350 ! ,wel_loc*gshieldc_ll(j,i) &
12351 ! ,wel_loc*gshieldc_loc_ll(j,i) &
12352 ! ,wtube*gg_tube(j,i) &
12353 ! ,wbond_nucl*gradb_nucl(j,i) &
12354 ! ,wvdwpp_nucl*gvdwpp_nucl(j,i),welpp*gelpp(j,i),&
12355 ! wvdwpsb*gvdwpsb1(j,i)&
12356 ! ,wbond_nucl*gradb_nucl(j,i),wsbloc*gsbloc(j,i)
12360 gradc(j,i,icg)=gradbufc(j,i)+welec*gelc(j,i)+ &
12361 wel_loc*gel_loc(j,i)+ &
12362 0.5d0*(wscp*gvdwc_scpp(j,i)+ &
12363 welec*gelc_long(j,i)+ &
12364 wel_loc*gel_loc_long(j,i)+ &
12365 !el wcorr*gcorr_long(j,i)+ & !el gcorr_long- brak deklaracji
12366 wcorr5*gradcorr5_long(j,i)+ &
12367 wcorr6*gradcorr6_long(j,i)+ &
12368 wturn6*gcorr6_turn_long(j,i))+ &
12369 wbond*gradb(j,i)+ &
12370 wcorr*gradcorr(j,i)+ &
12371 wturn3*gcorr3_turn(j,i)+ &
12372 wturn4*gcorr4_turn(j,i)+ &
12373 wcorr5*gradcorr5(j,i)+ &
12374 wcorr6*gradcorr6(j,i)+ &
12375 wturn6*gcorr6_turn(j,i)+ &
12376 wsccor*gsccorc(j,i) &
12377 +wscloc*gscloc(j,i) &
12379 +wliptran*gliptranc(j,i) &
12380 +welec*gshieldc(j,i) &
12381 +welec*gshieldc_loc(j,i) &
12382 +wcorr*gshieldc_ec(j,i) &
12383 +wcorr*gshieldc_loc_ec(j,i) &
12384 +wturn3*gshieldc_t3(j,i) &
12385 +wturn3*gshieldc_loc_t3(j,i) &
12386 +wturn4*gshieldc_t4(j,i) &
12387 +wturn4*gshieldc_loc_t4(j,i) &
12388 +wel_loc*gshieldc_ll(j,i) &
12389 +wel_loc*gshieldc_loc_ll(j,i) &
12390 +wtube*gg_tube(j,i) &
12391 +wbond_nucl*gradb_nucl(j,i) &
12392 +0.5d0*(wvdwpp_nucl*gvdwpp_nucl(j,i)+welpp*gelpp(j,i)&
12393 +wvdwpsb*gvdwpsb1(j,i))&
12394 +wsbloc*gsbloc(j,i)+wcatnucl*gradnuclcat(j,i)!&
12395 ! + gradcattranc(j,i)
12401 gradx(j,i,icg)=wsc*gvdwx(j,i)+wscp*gradx_scp(j,i)+ &
12402 wbond*gradbx(j,i)+ &
12403 wstrain*ghpbx(j,i)+wcorr*gradxorr(j,i)+ &
12404 wsccor*gsccorx(j,i) &
12405 +wscloc*gsclocx(j,i) &
12406 +wliptran*gliptranx(j,i) &
12407 +welec*gshieldx(j,i) &
12408 +wcorr*gshieldx_ec(j,i) &
12409 +wturn3*gshieldx_t3(j,i) &
12410 +wturn4*gshieldx_t4(j,i) &
12411 +wel_loc*gshieldx_ll(j,i)&
12412 +wtube*gg_tube_sc(j,i) &
12413 +wbond_nucl*gradbx_nucl(j,i) &
12414 +wvdwsb*gvdwsbx(j,i) &
12415 +welsb*gelsbx(j,i) &
12416 +wcorr_nucl*gradxorr_nucl(j,i)&
12417 +wcorr3_nucl*gradxorr3_nucl(j,i) &
12418 +wsbloc*gsblocx(j,i) &
12419 +wcatprot* gradpepcatx(j,i)&
12420 +wscbase*gvdwx_scbase(j,i) &
12421 +wpepbase*gvdwx_pepbase(j,i)&
12422 +wscpho*gvdwx_scpho(j,i)+wcatnucl*gradnuclcatx(j,i)&
12423 +wcat_tran*gradcattranx(j,i)+gradcatangx(j,i)
12424 ! if (i.eq.3) print *,"tu?", wscpho,gvdwx_scpho(j,i)
12428 ! write(iout,*), "const_homol",constr_homology
12429 if (constr_homology.gt.0) then
12432 gradc(j,i,icg)=gradc(j,i,icg)+duscdiff(j,i)
12433 ! write(iout,*) "duscdiff",duscdiff(j,i)
12434 gradx(j,i,icg)=gradx(j,i,icg)+duscdiffx(j,i)
12440 write (iout,*) "gloc before adding corr"
12442 write (iout,*) i,gloc(i,icg)
12446 gloc(i,icg)=gloc(i,icg)+wcorr*gcorr_loc(i) &
12447 +wcorr5*g_corr5_loc(i) &
12448 +wcorr6*g_corr6_loc(i) &
12449 +wturn4*gel_loc_turn4(i) &
12450 +wturn3*gel_loc_turn3(i) &
12451 +wturn6*gel_loc_turn6(i) &
12452 +wel_loc*gel_loc_loc(i)
12455 write (iout,*) "gloc after adding corr"
12457 write (iout,*) i,gloc(i,icg)
12462 if (nfgtasks.gt.1) then
12465 gradbufc(j,i)=gradc(j,i,icg)
12466 gradbufx(j,i)=gradx(j,i,icg)
12470 glocbuf(i)=gloc(i,icg)
12474 write (iout,*) "gloc_sc before reduce"
12477 write (iout,*) i,j,gloc_sc(j,i,icg)
12484 gloc_scbuf(j,i)=gloc_sc(j,i,icg)
12488 call MPI_Barrier(FG_COMM,IERR)
12489 time_barrier_g=time_barrier_g+MPI_Wtime()-time00
12491 call MPI_Reduce(gradbufc(1,0),gradc(1,0,icg),3*nres+3,&
12492 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
12493 call MPI_Reduce(gradbufx(1,0),gradx(1,0,icg),3*nres+3,&
12494 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
12495 call MPI_Reduce(glocbuf(1),gloc(1,icg),4*nres,&
12496 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
12497 time_reduce=time_reduce+MPI_Wtime()-time00
12498 call MPI_Reduce(gloc_scbuf(1,0),gloc_sc(1,0,icg),3*nres+3,&
12499 MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
12500 time_reduce=time_reduce+MPI_Wtime()-time00
12502 ! print *,"gradbuf",gradbufc(1,1),gradc(1,1,icg)
12504 write (iout,*) "gloc_sc after reduce"
12507 write (iout,*) i,j,gloc_sc(j,i,icg)
12513 write (iout,*) "gloc after reduce"
12515 write (iout,*) i,gloc(i,icg)
12520 if (gnorm_check) then
12522 ! Compute the maximum elements of the gradient
12525 gvdwc_scp_max=0.0d0
12532 gcorr3_turn_max=0.0d0
12533 gcorr4_turn_max=0.0d0
12534 gradcorr5_max=0.0d0
12535 gradcorr6_max=0.0d0
12536 gcorr6_turn_max=0.0d0
12540 gradx_scp_max=0.0d0
12546 gvdwc_norm=dsqrt(scalar(gvdwc(1,i),gvdwc(1,i)))
12547 if (gvdwc_norm.gt.gvdwc_max) gvdwc_max=gvdwc_norm
12548 gvdwc_scp_norm=dsqrt(scalar(gvdwc_scp(1,i),gvdwc_scp(1,i)))
12549 if (gvdwc_scp_norm.gt.gvdwc_scp_max) &
12550 gvdwc_scp_max=gvdwc_scp_norm
12551 gelc_norm=dsqrt(scalar(gelc(1,i),gelc(1,i)))
12552 if (gelc_norm.gt.gelc_max) gelc_max=gelc_norm
12553 gvdwpp_norm=dsqrt(scalar(gvdwpp(1,i),gvdwpp(1,i)))
12554 if (gvdwpp_norm.gt.gvdwpp_max) gvdwpp_max=gvdwpp_norm
12555 gradb_norm=dsqrt(scalar(gradb(1,i),gradb(1,i)))
12556 if (gradb_norm.gt.gradb_max) gradb_max=gradb_norm
12557 ghpbc_norm=dsqrt(scalar(ghpbc(1,i),ghpbc(1,i)))
12558 if (ghpbc_norm.gt.ghpbc_max) ghpbc_max=ghpbc_norm
12559 gradcorr_norm=dsqrt(scalar(gradcorr(1,i),gradcorr(1,i)))
12560 if (gradcorr_norm.gt.gradcorr_max) gradcorr_max=gradcorr_norm
12561 gel_loc_norm=dsqrt(scalar(gel_loc(1,i),gel_loc(1,i)))
12562 if (gel_loc_norm.gt.gel_loc_max) gel_loc_max=gel_loc_norm
12563 gcorr3_turn_norm=dsqrt(scalar(gcorr3_turn(1,i),&
12565 if (gcorr3_turn_norm.gt.gcorr3_turn_max) &
12566 gcorr3_turn_max=gcorr3_turn_norm
12567 gcorr4_turn_norm=dsqrt(scalar(gcorr4_turn(1,i),&
12569 if (gcorr4_turn_norm.gt.gcorr4_turn_max) &
12570 gcorr4_turn_max=gcorr4_turn_norm
12571 gradcorr5_norm=dsqrt(scalar(gradcorr5(1,i),gradcorr5(1,i)))
12572 if (gradcorr5_norm.gt.gradcorr5_max) &
12573 gradcorr5_max=gradcorr5_norm
12574 gradcorr6_norm=dsqrt(scalar(gradcorr6(1,i),gradcorr6(1,i)))
12575 if (gradcorr6_norm.gt.gradcorr6_max) gcorr6_max=gradcorr6_norm
12576 gcorr6_turn_norm=dsqrt(scalar(gcorr6_turn(1,i),&
12578 if (gcorr6_turn_norm.gt.gcorr6_turn_max) &
12579 gcorr6_turn_max=gcorr6_turn_norm
12580 gsccorr_norm=dsqrt(scalar(gsccorc(1,i),gsccorc(1,i)))
12581 if (gsccorr_norm.gt.gsccorr_max) gsccorr_max=gsccorr_norm
12582 gscloc_norm=dsqrt(scalar(gscloc(1,i),gscloc(1,i)))
12583 if (gscloc_norm.gt.gscloc_max) gscloc_max=gscloc_norm
12584 gvdwx_norm=dsqrt(scalar(gvdwx(1,i),gvdwx(1,i)))
12585 if (gvdwx_norm.gt.gvdwx_max) gvdwx_max=gvdwx_norm
12586 gradx_scp_norm=dsqrt(scalar(gradx_scp(1,i),gradx_scp(1,i)))
12587 if (gradx_scp_norm.gt.gradx_scp_max) &
12588 gradx_scp_max=gradx_scp_norm
12589 ghpbx_norm=dsqrt(scalar(ghpbx(1,i),ghpbx(1,i)))
12590 if (ghpbx_norm.gt.ghpbx_max) ghpbx_max=ghpbx_norm
12591 gradxorr_norm=dsqrt(scalar(gradxorr(1,i),gradxorr(1,i)))
12592 if (gradxorr_norm.gt.gradxorr_max) gradxorr_max=gradxorr_norm
12593 gsccorrx_norm=dsqrt(scalar(gsccorx(1,i),gsccorx(1,i)))
12594 if (gsccorrx_norm.gt.gsccorrx_max) gsccorrx_max=gsccorrx_norm
12595 gsclocx_norm=dsqrt(scalar(gsclocx(1,i),gsclocx(1,i)))
12596 if (gsclocx_norm.gt.gsclocx_max) gsclocx_max=gsclocx_norm
12600 open(istat,file=statname,position="append")
12602 open(istat,file=statname,access="append")
12604 write (istat,'(1h#,21f10.2)') gvdwc_max,gvdwc_scp_max,&
12605 gelc_max,gvdwpp_max,gradb_max,ghpbc_max,&
12606 gradcorr_max,gel_loc_max,gcorr3_turn_max,gcorr4_turn_max,&
12607 gradcorr5_max,gradcorr6_max,gcorr6_turn_max,gsccorc_max,&
12608 gscloc_max,gvdwx_max,gradx_scp_max,ghpbx_max,gradxorr_max,&
12609 gsccorx_max,gsclocx_max
12611 if (gvdwc_max.gt.1.0d4) then
12612 write (iout,*) "gvdwc gvdwx gradb gradbx"
12614 write(iout,'(i5,4(3f10.2,5x))') i,(gvdwc(j,i),gvdwx(j,i),&
12615 gradb(j,i),gradbx(j,i),j=1,3)
12617 call pdbout(0.0d0,'cipiszcze',iout)
12624 write (iout,*) "gradc gradx gloc"
12626 write (iout,'(i5,3f10.5,5x,3f10.5,5x,f10.5)') &
12627 i,(gradc(j,i,icg),j=1,3),(gradx(j,i,icg),j=1,3),gloc(i,icg)
12632 time_sumgradient=time_sumgradient+MPI_Wtime()-time01
12635 end subroutine sum_gradient
12636 !-----------------------------------------------------------------------------
12638 ! implicit real(kind=8) (a-h,o-z)
12640 ! include 'DIMENSIONS'
12641 ! include 'COMMON.CHAIN'
12642 ! include 'COMMON.DERIV'
12643 ! include 'COMMON.CALC'
12644 ! include 'COMMON.IOUNITS'
12645 real(kind=8), dimension(3) :: dcosom1,dcosom2
12646 ! print *,"wchodze"
12647 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1 &
12648 +dCAVdOM1+ dGCLdOM1+ dPOLdOM1
12649 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2 &
12650 +dCAVdOM2+ dGCLdOM2+ dPOLdOM2
12652 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12 &
12653 -2.0D0*alf12*eps3der+sigder*sigsq_om12&
12654 +dCAVdOM12+ dGCLdOM12
12658 ! eom12=evdwij*eps1_om12
12660 ! write (iout,*) "eps2der",eps2der," eps3der",eps3der,&
12662 ! write (iout,*) "eps1_om12",eps1_om12," eps2rt_om12",eps2rt_om12
12663 ! write (iout,*) "eom1",eom1," eom2",eom2," eom12",eom12
12664 !C print *,sss_ele_cut,'in sc_grad'
12666 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
12667 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
12670 gg(k)=(gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k))*sss_ele_cut
12671 !C print *,'gg',k,gg(k)
12673 ! print *,i,j,gg_lipi(3),gg_lipj(3),sss_ele_cut
12674 ! write (iout,*) "gg",(gg(k),k=1,3)
12676 gvdwx(k,i)=gvdwx(k,i)-gg(k) +gg_lipi(k)&
12677 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
12678 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv &
12681 gvdwx(k,j)=gvdwx(k,j)+gg(k)+gg_lipj(k)&
12682 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
12683 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv &
12686 ! write (iout,*)(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
12687 ! +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
12688 ! write (iout,*)(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
12689 ! +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
12692 ! Calculate the components of the gradient in DC and X
12696 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
12700 gvdwc(l,i)=gvdwc(l,i)-gg(l)+gg_lipi(l)
12701 gvdwc(l,j)=gvdwc(l,j)+gg(l)+gg_lipj(l)
12704 end subroutine sc_grad
12706 subroutine sc_grad_cat
12708 real(kind=8), dimension(3) :: dcosom1,dcosom2
12709 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1 &
12710 +dCAVdOM1+ dGCLdOM1+ dPOLdOM1
12711 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2 &
12712 +dCAVdOM2+ dGCLdOM2+ dPOLdOM2
12714 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12 &
12715 -2.0D0*alf12*eps3der+sigder*sigsq_om12&
12716 +dCAVdOM12+ dGCLdOM12
12720 ! eom12=evdwij*eps1_om12
12724 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
12725 dcosom2(k)=rij*(dc_norm(k,j)-om2*erij(k))
12728 gg(k)=(gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k))
12729 ! print *,'gg',k,gg(k)
12731 ! print *,i,j,gg_lipi(3),gg_lipj(3),sss_ele_cut
12732 ! write (iout,*) "gg",(gg(k),k=1,3)
12734 gradpepcatx(k,i)=gradpepcatx(k,i)-gg(k)*sss_ele_cut &
12735 +(eom12*(dc_norm(k,j)-om12*dc_norm(k,nres+i)) &
12736 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv*sss_ele_cut
12738 ! gradpepcatx(k,j)=gradpepcatx(k,j)+gg(k) &
12739 ! +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,j)) &
12740 ! +eom2*(erij(k)-om2*dc_norm(k,j)))*dscj_inv
12742 ! write (iout,*)(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
12743 ! +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
12744 ! write (iout,*)(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
12745 ! +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
12748 ! Calculate the components of the gradient in DC and X
12751 gradpepcat(l,i)=gradpepcat(l,i)-gg(l)*sss_ele_cut
12752 gradpepcat(l,j)=gradpepcat(l,j)+gg(l)*sss_ele_cut
12754 end subroutine sc_grad_cat
12756 subroutine sc_grad_cat_pep
12758 real(kind=8), dimension(3) :: dcosom1,dcosom2
12759 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1 &
12760 +dCAVdOM1+ dGCLdOM1+ dPOLdOM1
12761 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2 &
12762 +dCAVdOM2+ dGCLdOM2+ dPOLdOM2
12764 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12 &
12765 -2.0D0*alf12*eps3der+sigder*sigsq_om12&
12766 +dCAVdOM12+ dGCLdOM12
12770 ! eom12=evdwij*eps1_om12
12772 ! write (iout,*) "gg",(gg(k),k=1,3)
12775 dcosom1(k) = rij * (dc_norm(k,i) - om1 * erij(k))
12776 dcosom2(k) = rij * (dc_norm(k,nres+j) - om2 * erij(k))
12777 gg(k) = gg(k) + eom1 * dcosom1(k) + eom2 * dcosom2(k)
12778 gradpepcat(k,i)= gradpepcat(k,i) +sss_ele_cut*(0.5*(- gg(k)) &
12779 + (-eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,i)))&
12781 - (eom1*(erij(k)-om1*dc_norm(k,i)))*dsci_inv*2.0)
12782 gradpepcat(k,i+1)= gradpepcat(k,i+1) +sss_ele_cut*(0.5*(- gg(k)) &
12783 - (-eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,i))) &
12785 + (eom1*(erij(k)-om1*dc_norm(k,i)))*dsci_inv*2.0)
12786 gradpepcat(k,j)=gradpepcat(k,j)+gg(k)*sss_ele_cut
12788 end subroutine sc_grad_cat_pep
12791 !-----------------------------------------------------------------------------
12792 subroutine mixder(thetai,thet_pred_mean,theta0i,E_tc_t)
12795 ! implicit real(kind=8) (a-h,o-z)
12796 ! include 'DIMENSIONS'
12797 ! include 'COMMON.LOCAL'
12798 ! include 'COMMON.IOUNITS'
12799 !el real(kind=8) :: term1,term2,termm,diffak,ratak,&
12800 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
12801 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,
12802 real(kind=8) :: thetai,thet_pred_mean,theta0i,E_tc_t
12803 real(kind=8) :: t3,t6,t9,t12,t14,t16,t21,t23,t26,t27,t32,t40
12805 !el common /calcthet/ term1,term2,termm,diffak,ratak,&
12806 !el ak,aktc,termpre,termexp,sigc,sig0i,time11,time12,sigcsq,&
12807 !el delthe0,sig0inv,sigtc,sigsqtc,delthec,it
12808 !el local variables
12810 delthec=thetai-thet_pred_mean
12811 delthe0=thetai-theta0i
12812 ! "Thank you" to MAPLE (probably spared one day of hand-differentiation).
12813 t3 = thetai-thet_pred_mean
12817 t14 = t12+t6*sigsqtc
12819 t21 = thetai-theta0i
12825 E_tc_t = -((sigcsq+2.D0*t3*sigsqtc)*t9-t14*sigcsq*t3*t16*t9 &
12826 -aktc*sig0inv*t27)/t32+(t14*t9+aktc*t26)/t40 &
12827 *(-t12*t9-ak*sig0inv*t27)
12829 end subroutine mixder
12831 !-----------------------------------------------------------------------------
12833 !-----------------------------------------------------------------------------
12835 !-----------------------------------------------------------------------------
12836 ! This subroutine calculates the derivatives of the consecutive virtual
12837 ! bond vectors and the SC vectors in the virtual-bond angles theta and
12838 ! virtual-torsional angles phi, as well as the derivatives of SC vectors
12839 ! in the angles alpha and omega, describing the location of a side chain
12840 ! in its local coordinate system.
12842 ! The derivatives are stored in the following arrays:
12844 ! DDCDV - the derivatives of virtual-bond vectors DC in theta and phi.
12845 ! The structure is as follows:
12847 ! dDC(x,2)/dT(3),...,dDC(z,2)/dT(3),0, 0, 0
12848 ! 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)
12849 ! . . . . . . . . . . . . . . . . . .
12850 ! 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)
12854 ! 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)
12856 ! DXDV - the derivatives of the side-chain vectors in theta and phi.
12857 ! The structure is same as above.
12859 ! DCDS - the derivatives of the side chain vectors in the local spherical
12860 ! andgles alph and omega:
12862 ! 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)
12863 ! 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)
12867 ! 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)
12869 ! Version of March '95, based on an early version of November '91.
12871 !**********************************************************************
12872 ! implicit real(kind=8) (a-h,o-z)
12873 ! include 'DIMENSIONS'
12874 ! include 'COMMON.VAR'
12875 ! include 'COMMON.CHAIN'
12876 ! include 'COMMON.DERIV'
12877 ! include 'COMMON.GEO'
12878 ! include 'COMMON.LOCAL'
12879 ! include 'COMMON.INTERACT'
12880 real(kind=8),dimension(3,3,nres) :: drt,rdt,prordt,prodrt !(3,3,maxres)
12881 real(kind=8),dimension(3,3) :: dp,temp
12882 !el real(kind=8) :: fromto(3,3,maxdim) !(3,3,maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
12883 real(kind=8),dimension(3) :: xx,xx1
12884 !el local variables
12885 integer :: i,k,l,j,m,ind,ind1,jjj
12886 real(kind=8) :: alphi,omegi,theta2,dpkl,dpjk,xj,rj,dxoijk,dxoiij,&
12887 tempkl,dsci,cosalphi,sinalphi,cosomegi,sinomegi,cost2,&
12888 sint2,xp,yp,xxp,yyp,zzp,dj
12890 ! common /przechowalnia/ fromto
12892 if(.not. allocated(fromto)) allocate(fromto(3,3))
12894 if(.not. allocated(fromto)) allocate(fromto(3,3,maxdim))
12896 ! get the position of the jth ijth fragment of the chain coordinate system
12897 ! in the fromto array.
12898 ! indmat(i,j)=((2*(nres-2)-i)*(i-1))/2+j-1
12900 ! maxdim=(nres-1)*(nres-2)/2
12901 ! allocate(dcdv(6,maxdim),dxds(6,nres))
12902 ! calculate the derivatives of transformation matrix elements in theta
12905 !el call flush(iout) !el
12907 rdt(1,1,i)=-rt(1,2,i)
12908 rdt(1,2,i)= rt(1,1,i)
12910 rdt(2,1,i)=-rt(2,2,i)
12911 rdt(2,2,i)= rt(2,1,i)
12913 rdt(3,1,i)=-rt(3,2,i)
12914 rdt(3,2,i)= rt(3,1,i)
12918 ! derivatives in phi
12924 drt(2,1,i)= rt(3,1,i)
12925 drt(2,2,i)= rt(3,2,i)
12926 drt(2,3,i)= rt(3,3,i)
12927 drt(3,1,i)=-rt(2,1,i)
12928 drt(3,2,i)=-rt(2,2,i)
12929 drt(3,3,i)=-rt(2,3,i)
12932 ! generate the matrix products of type r(i)t(i)...r(j)t(j)
12939 temp(k,l)=rt(k,l,i)
12944 fromto(k,l,ind)=temp(k,l)
12954 dpkl=dpkl+temp(k,m)*rt(m,l,j)
12957 fromto(k,l,ind)=dpkl
12969 ! Calculate derivatives.
12975 ! Derivatives of DC(i+1) in theta(i+2)
12981 dpjk=dpjk+prod(j,l,i)*rdt(l,k,i)
12984 prordt(j,k,i)=dp(j,k)
12987 dcdv(j,ind1)=vbld(i+1)*dp(j,1)
12990 ! Derivatives of SC(i+1) in theta(i+2)
12992 xx1(1)=-0.5D0*xloc(2,i+1)
12993 xx1(2)= 0.5D0*xloc(1,i+1)
12997 xj=xj+r(j,k,i)*xx1(k)
13004 rj=rj+prod(j,k,i)*xx(k)
13009 ! Derivatives of SC(i+1) in theta(i+3). The have to be handled differently
13010 ! than the other off-diagonal derivatives.
13015 dxoiij=dxoiij+dp(j,k)*xrot(k,i+2)
13017 dxdv(j,ind1+1)=dxoiij
13019 !d print *,ind1+1,(dxdv(j,ind1+1),j=1,3)
13021 ! Derivatives of DC(i+1) in phi(i+2)
13027 dpjk=dpjk+prod(j,l,i)*drt(l,k,i)
13030 prodrt(j,k,i)=dp(j,k)
13032 dcdv(j+3,ind1)=vbld(i+1)*dp(j,1)
13035 ! Derivatives of SC(i+1) in phi(i+2)
13038 xx(3)= xloc(2,i+1)*r(2,2,i)+xloc(3,i+1)*r(2,3,i)
13039 xx(2)=-xloc(2,i+1)*r(3,2,i)-xloc(3,i+1)*r(3,3,i)
13043 rj=rj+prod(j,k,i)*xx(k)
13048 ! Derivatives of SC(i+1) in phi(i+3).
13053 dxoiij=dxoiij+dp(j,k)*xrot(k,i+2)
13055 dxdv(j+3,ind1+1)=dxoiij
13058 ! Calculate the derivatives of DC(i+1) and SC(i+1) in theta(i+3) thru
13059 ! theta(nres) and phi(i+3) thru phi(nres).
13063 ind=indmat(i+1,j+1)
13064 !d print *,'i=',i,' j=',j,' ind=',ind,' ind1=',ind1
13066 call build_fromto(i+1,j+1,fromto)
13067 !c write(iout,'(7hfromto 9f10.5)')((fromto(k,l),l=1,3),k=1,3)
13072 tempkl=tempkl+prordt(k,m,i)*fromto(m,l)
13082 tempkl=tempkl+prordt(k,m,i)*fromto(m,l,ind)
13088 !d print '(9f8.3)',((fromto(k,l,ind),l=1,3),k=1,3)
13089 !d print '(9f8.3)',((prod(k,l,i),l=1,3),k=1,3)
13090 !d print '(9f8.3)',((temp(k,l),l=1,3),k=1,3)
13091 ! Derivatives of virtual-bond vectors in theta
13093 dcdv(k,ind1)=vbld(i+1)*temp(k,1)
13095 !d print '(3f8.3)',(dcdv(k,ind1),k=1,3)
13096 ! Derivatives of SC vectors in theta
13100 dxoijk=dxoijk+temp(k,l)*xrot(l,j+2)
13102 dxdv(k,ind1+1)=dxoijk
13105 !--- Calculate the derivatives in phi
13112 tempkl=tempkl+prodrt(k,m,i)*fromto(m,l)
13122 tempkl=tempkl+prodrt(k,m,i)*fromto(m,l,ind)
13131 dcdv(k+3,ind1)=vbld(i+1)*temp(k,1)
13136 dxoijk=dxoijk+temp(k,l)*xrot(l,j+2)
13138 dxdv(k+3,ind1+1)=dxoijk
13143 ! Derivatives in alpha and omega:
13146 ! dsci=dsc(itype(i,1))
13151 if(alphi.ne.alphi) alphi=100.0
13152 if(omegi.ne.omegi) omegi=-100.0
13157 !d print *,'i=',i,' dsci=',dsci,' alphi=',alphi,' omegi=',omegi
13158 cosalphi=dcos(alphi)
13159 sinalphi=dsin(alphi)
13160 cosomegi=dcos(omegi)
13161 sinomegi=dsin(omegi)
13162 temp(1,1)=-dsci*sinalphi
13163 temp(2,1)= dsci*cosalphi*cosomegi
13164 temp(3,1)=-dsci*cosalphi*sinomegi
13166 temp(2,2)=-dsci*sinalphi*sinomegi
13167 temp(3,2)=-dsci*sinalphi*cosomegi
13168 theta2=pi-0.5D0*theta(i+1)
13172 !d print *,((temp(l,k),l=1,3),k=1,2)
13176 xxp= xp*cost2+yp*sint2
13177 yyp=-xp*sint2+yp*cost2
13180 xx(2)=yyp*r(2,2,i-1)+zzp*r(2,3,i-1)
13181 xx(3)=yyp*r(3,2,i-1)+zzp*r(3,3,i-1)
13185 dj=dj+prod(k,l,i-1)*xx(l)
13193 end subroutine cartder
13195 subroutine build_fromto(i,j,fromto)
13197 integer i,j,jj,k,l,m
13198 double precision fromto(3,3),temp(3,3),dp(3,3)
13199 double precision dpkl
13202 ! generate the matrix products of type r(i)t(i)...r(j)t(j) on the fly
13204 ! write (iout,*) "temp on entry"
13205 ! write (iout,'(3f10.5)') ((temp(k,l),l=1,3),k=1,3)
13207 ! ind=indmat(i,i+1)
13211 temp(k,l)=rt(k,l,i)
13216 fromto(k,l)=temp(k,l)
13221 ! ind=indmat(i,j+1)
13226 dpkl=dpkl+temp(k,m)*rt(m,l,j-1)
13238 ! write (iout,*) "temp upon exit"
13239 ! write (iout,'(3f10.5)') ((temp(k,l),l=1,3),k=1,3)
13243 end subroutine build_fromto
13246 !-----------------------------------------------------------------------------
13248 !-----------------------------------------------------------------------------
13249 subroutine check_cartgrad
13250 ! Check the gradient of Cartesian coordinates in internal coordinates.
13251 ! implicit real(kind=8) (a-h,o-z)
13252 ! include 'DIMENSIONS'
13253 ! include 'COMMON.IOUNITS'
13254 ! include 'COMMON.VAR'
13255 ! include 'COMMON.CHAIN'
13256 ! include 'COMMON.GEO'
13257 ! include 'COMMON.LOCAL'
13258 ! include 'COMMON.DERIV'
13259 real(kind=8),dimension(6,nres) :: temp
13260 real(kind=8),dimension(3) :: xx,gg
13261 integer :: i,k,j,ii
13262 real(kind=8) :: aincr,aincr2,alphi,omegi,theti,thet,phii
13263 ! indmat(i,j)=((2*(nres-2)-i)*(i-1))/2+j-1
13265 ! Check the gradient of the virtual-bond and SC vectors in the internal
13271 write (iout,'(a)') '**************** dx/dalpha'
13275 alph(i)=alph(i)+aincr
13277 temp(k,i)=dc(k,nres+i)
13281 gg(k)=(dc(k,nres+i)-temp(k,i))/aincr
13282 xx(k)=dabs((gg(k)-dxds(k,i))/(aincr*dabs(dxds(k,i))+aincr))
13284 write (iout,'(i4,3e15.6/4x,3e15.6,3f9.3)') &
13285 i,(gg(k),k=1,3),(dxds(k,i),k=1,3),(xx(k),k=1,3)
13291 write (iout,'(a)') '**************** dx/domega'
13295 omeg(i)=omeg(i)+aincr
13297 temp(k,i)=dc(k,nres+i)
13301 gg(k)=(dc(k,nres+i)-temp(k,i))/aincr
13302 xx(k)=dabs((gg(k)-dxds(k+3,i))/ &
13303 (aincr*dabs(dxds(k+3,i))+aincr))
13305 write (iout,'(i4,3e15.6/4x,3e15.6,3f9.3)') &
13306 i,(gg(k),k=1,3),(dxds(k+3,i),k=1,3),(xx(k),k=1,3)
13312 write (iout,'(a)') '**************** dx/dtheta'
13316 theta(i)=theta(i)+aincr
13319 temp(k,j)=dc(k,nres+j)
13325 ! print *,'i=',i-2,' j=',j-1,' ii=',ii
13327 gg(k)=(dc(k,nres+j)-temp(k,j))/aincr
13328 xx(k)=dabs((gg(k)-dxdv(k,ii))/ &
13329 (aincr*dabs(dxdv(k,ii))+aincr))
13331 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
13332 i,j,(gg(k),k=1,3),(dxdv(k,ii),k=1,3),(xx(k),k=1,3)
13339 write (iout,'(a)') '***************** dx/dphi'
13342 phi(i)=phi(i)+aincr
13345 temp(k,j)=dc(k,nres+j)
13353 gg(k)=(dc(k,nres+j)-temp(k,j))/aincr
13354 xx(k)=dabs((gg(k)-dxdv(k+3,ii))/ &
13355 (aincr*dabs(dxdv(k+3,ii))+aincr))
13357 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
13358 i,j,(gg(k),k=1,3),(dxdv(k+3,ii),k=1,3),(xx(k),k=1,3)
13361 phi(i)=phi(i)-aincr
13364 write (iout,'(a)') '****************** ddc/dtheta'
13367 theta(i+2)=thet+aincr
13378 gg(k)=(dc(k,j)-temp(k,j))/aincr
13379 xx(k)=dabs((gg(k)-dcdv(k,ii))/ &
13380 (aincr*dabs(dcdv(k,ii))+aincr))
13382 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
13383 i,j,(gg(k),k=1,3),(dcdv(k,ii),k=1,3),(xx(k),k=1,3)
13393 write (iout,'(a)') '******************* ddc/dphi'
13396 phi(i+3)=phii+aincr
13407 gg(k)=(dc(k,j)-temp(k,j))/aincr
13408 xx(k)=dabs((gg(k)-dcdv(k+3,ii))/ &
13409 (aincr*dabs(dcdv(k+3,ii))+aincr))
13411 write (iout,'(2i4,3e14.6/8x,3e14.6,3f9.3)') &
13412 i,j,(gg(k),k=1,3),(dcdv(k+3,ii),k=1,3),(xx(k),k=1,3)
13423 end subroutine check_cartgrad
13424 !-----------------------------------------------------------------------------
13425 subroutine check_ecart
13426 ! Check the gradient of the energy in Cartesian coordinates.
13427 ! implicit real(kind=8) (a-h,o-z)
13428 ! include 'DIMENSIONS'
13429 ! include 'COMMON.CHAIN'
13430 ! include 'COMMON.DERIV'
13431 ! include 'COMMON.IOUNITS'
13432 ! include 'COMMON.VAR'
13433 ! include 'COMMON.CONTACTS'
13436 ! use minimm, only: funcgrad
13438 !el integer :: icall
13439 !el common /srutu/ icall
13440 ! real(kind=8) :: funcgrad
13441 real(kind=8),dimension(6) :: ggg
13442 real(kind=8),dimension(3) :: cc,xx,ddc,ddx
13443 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
13444 real(kind=8),dimension(6,nres) :: grad_s
13445 real(kind=8),dimension(0:n_ene) :: energia,energia1
13446 integer :: uiparm(1)
13447 real(kind=8) :: urparm(1)
13449 integer :: nf,i,j,k
13450 real(kind=8) :: aincr,etot,etot1,ff
13456 print '(a)','CG processor',me,' calling CHECK_CART.',aincr
13459 call geom_to_var(nvar,x)
13460 call etotal(energia)
13465 !el call enerprint(energia)
13466 call gradient(nvar,x,nf,g,uiparm,urparm,fdum)
13470 write (iout,'(i5,3f10.5)') i,(gradxorr(j,i),j=1,3)
13474 grad_s(j,i)=gradc(j,i,icg)
13475 grad_s(j+3,i)=gradx(j,i,icg)
13479 write (iout,'(/a/)') 'Gradient in virtual-bond and SC vectors'
13484 ddx(j)=dc(j,i+nres)
13487 dc(j,i)=dc(j,i)+aincr
13489 c(j,k)=c(j,k)+aincr
13490 c(j,k+nres)=c(j,k+nres)+aincr
13493 call etotal(energia1)
13495 ggg(j)=(etot1-etot)/aincr
13498 c(j,k)=c(j,k)-aincr
13499 c(j,k+nres)=c(j,k+nres)-aincr
13503 c(j,i+nres)=c(j,i+nres)+aincr
13504 dc(j,i+nres)=dc(j,i+nres)+aincr
13506 call etotal(energia1)
13508 ggg(j+3)=(etot1-etot)/aincr
13510 dc(j,i+nres)=ddx(j)
13512 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/)') &
13513 i,(ggg(k),k=1,6),(grad_s(k,i),k=1,6)
13516 end subroutine check_ecart
13518 !-----------------------------------------------------------------------------
13519 subroutine check_ecartint
13520 ! Check the gradient of the energy in Cartesian coordinates.
13521 use io_base, only: intout
13522 use MD_data, only: iset
13523 ! implicit real*8 (a-h,o-z)
13524 ! include 'DIMENSIONS'
13525 ! include 'COMMON.CONTROL'
13526 ! include 'COMMON.CHAIN'
13527 ! include 'COMMON.DERIV'
13528 ! include 'COMMON.IOUNITS'
13529 ! include 'COMMON.VAR'
13530 ! include 'COMMON.CONTACTS'
13531 ! include 'COMMON.MD'
13532 ! include 'COMMON.LOCAL'
13533 ! include 'COMMON.SPLITELE'
13535 !el integer :: icall
13536 !el common /srutu/ icall
13537 real(kind=8),dimension(6) :: ggg,ggg1
13538 real(kind=8),dimension(3) :: cc,xx,ddc,ddx,ddc1,ddcn
13539 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
13540 real(kind=8),dimension(3) :: dcnorm_safe1,dcnorm_safe2,dxnorm_safe
13541 real(kind=8),dimension(6,0:nres) :: grad_s,grad_s1 !(6,0:maxres)
13542 real(kind=8),dimension(nres) :: phi_temp,theta_temp,alph_temp,omeg_temp !(maxres)
13543 real(kind=8),dimension(0:n_ene) :: energia,energia1
13544 integer :: uiparm(1)
13545 real(kind=8) :: urparm(1)
13547 integer :: i,j,k,nf
13548 real(kind=8) :: rlambd,aincr,etot,etot1,etot11,etot12,etot2,&
13555 if (iset.eq.0) iset=1
13557 ! call intcartderiv
13558 ! call checkintcartgrad
13561 write(iout,*) 'Calling CHECK_ECARTINT.,kupa'
13564 call geom_to_var(nvar,x)
13565 write (iout,*) "split_ene ",split_ene
13567 if (.not.split_ene) then
13569 call etotal(energia)
13573 call grad_transform
13577 write (iout,'(i5,3f10.5)') i,(gradxorr(j,i),j=1,3)
13580 grad_s(j,0)=gcart(j,0)
13584 grad_s(j,i)=gcart(j,i)
13585 grad_s(j+3,i)=gxcart(j,i)
13586 write(iout,*) "before movement analytical gradient"
13591 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
13592 (gxcart(j,i),j=1,3)
13596 !- split gradient check
13598 call etotal_long(energia)
13599 !el call enerprint(energia)
13602 call grad_transform
13606 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
13607 (gxcart(j,i),j=1,3)
13610 grad_s(j,0)=gcart(j,0)
13614 grad_s(j,i)=gcart(j,i)
13615 grad_s(j+3,i)=gxcart(j,i)
13619 call etotal_short(energia)
13620 call enerprint(energia)
13623 call grad_transform
13628 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
13629 (gxcart(j,i),j=1,3)
13632 grad_s1(j,0)=gcart(j,0)
13636 grad_s1(j,i)=gcart(j,i)
13637 grad_s1(j+3,i)=gxcart(j,i)
13641 write (iout,'(/a/)') 'Gradient in virtual-bond and SC vectors'
13648 if (nnt.gt.1 .and. i.eq.nnt) ddc1(j)=c(j,1)
13649 if (nct.lt.nres .and. i.eq.nct) ddcn(j)=c(j,nres)
13652 dcnorm_safe1(j)=dc_norm(j,i-1)
13653 dcnorm_safe2(j)=dc_norm(j,i)
13654 dxnorm_safe(j)=dc_norm(j,i+nres)
13657 c(j,i)=ddc(j)+aincr
13658 if (nnt.gt.1 .and. i.eq.nnt) c(j,1)=c(j,1)+aincr
13659 if (nct.lt.nres .and. i.eq.nct) c(j,nres)=c(j,nres)+aincr
13660 if (i.gt.1) dc(j,i-1)=c(j,i)-c(j,i-1)
13661 dc(j,i)=c(j,i+1)-c(j,i)
13662 dc(j,i+nres)=c(j,i+nres)-c(j,i)
13663 call int_from_cart1(.false.)
13664 if (.not.split_ene) then
13666 call etotal(energia1)
13668 ! write (iout,*) "ij",i,j," etot1",etot1
13671 call etotal_long(energia1)
13673 call etotal_short(energia1)
13676 !- end split gradient
13677 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot1",etot1
13678 c(j,i)=ddc(j)-aincr
13679 if (nnt.gt.1 .and. i.eq.nnt) c(j,1)=ddc1(j)-aincr
13680 if (nct.lt.nres .and. i.eq.nct) c(j,nres)=ddcn(j)-aincr
13681 if (i.gt.1) dc(j,i-1)=c(j,i)-c(j,i-1)
13682 dc(j,i)=c(j,i+1)-c(j,i)
13683 dc(j,i+nres)=c(j,i+nres)-c(j,i)
13684 call int_from_cart1(.false.)
13685 if (.not.split_ene) then
13687 call etotal(energia1)
13689 ! write (iout,*) "ij",i,j," etot2",etot2
13690 ggg(j)=(etot1-etot2)/(2*aincr)
13693 call etotal_long(energia1)
13695 ggg(j)=(etot11-etot21)/(2*aincr)
13696 call etotal_short(energia1)
13698 ggg1(j)=(etot12-etot22)/(2*aincr)
13699 !- end split gradient
13700 ! write (iout,*) "etot21",etot21," etot22",etot22
13702 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
13704 if (nnt.gt.1 .and. i.eq.nnt) c(j,1)=ddc1(j)
13705 if (nct.lt.nres .and. i.eq.nct) c(j,nres)=ddcn(j)
13706 if (i.gt.1) dc(j,i-1)=c(j,i)-c(j,i-1)
13707 dc(j,i)=c(j,i+1)-c(j,i)
13708 dc(j,i+nres)=c(j,i+nres)-c(j,i)
13709 dc_norm(j,i-1)=dcnorm_safe1(j)
13710 dc_norm(j,i)=dcnorm_safe2(j)
13711 dc_norm(j,i+nres)=dxnorm_safe(j)
13714 c(j,i+nres)=ddx(j)+aincr
13715 dc(j,i+nres)=c(j,i+nres)-c(j,i)
13716 call int_from_cart1(.false.)
13717 if (.not.split_ene) then
13719 call etotal(energia1)
13723 call etotal_long(energia1)
13725 call etotal_short(energia1)
13728 !- end split gradient
13729 c(j,i+nres)=ddx(j)-aincr
13730 dc(j,i+nres)=c(j,i+nres)-c(j,i)
13731 call int_from_cart1(.false.)
13732 if (.not.split_ene) then
13734 call etotal(energia1)
13736 ggg(j+3)=(etot1-etot2)/(2*aincr)
13739 call etotal_long(energia1)
13741 ggg(j+3)=(etot11-etot21)/(2*aincr)
13742 call etotal_short(energia1)
13744 ggg1(j+3)=(etot12-etot22)/(2*aincr)
13745 !- end split gradient
13747 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
13749 dc(j,i+nres)=c(j,i+nres)-c(j,i)
13750 dc_norm(j,i+nres)=dxnorm_safe(j)
13751 call int_from_cart1(.false.)
13753 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
13754 i,(ggg(k),k=1,6),(grad_s(k,i),k=1,6),(ggg(k)/grad_s(k,i),k=1,6)
13755 if (split_ene) then
13756 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
13757 i,(ggg1(k),k=1,6),(grad_s1(k,i),k=1,6),(ggg1(k)/grad_s1(k,i),&
13759 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
13760 i,(ggg(k)+ggg1(k),k=1,6),(grad_s(k,i)+grad_s1(k,i),k=1,6),&
13761 ((ggg(k)+ggg1(k))/(grad_s(k,i)+grad_s1(k,i)),k=1,6)
13765 end subroutine check_ecartint
13767 !-----------------------------------------------------------------------------
13768 subroutine check_ecartint
13769 ! Check the gradient of the energy in Cartesian coordinates.
13770 use io_base, only: intout
13771 use MD_data, only: iset
13772 ! implicit real*8 (a-h,o-z)
13773 ! include 'DIMENSIONS'
13774 ! include 'COMMON.CONTROL'
13775 ! include 'COMMON.CHAIN'
13776 ! include 'COMMON.DERIV'
13777 ! include 'COMMON.IOUNITS'
13778 ! include 'COMMON.VAR'
13779 ! include 'COMMON.CONTACTS'
13780 ! include 'COMMON.MD'
13781 ! include 'COMMON.LOCAL'
13782 ! include 'COMMON.SPLITELE'
13784 !el integer :: icall
13785 !el common /srutu/ icall
13786 real(kind=8),dimension(6) :: ggg,ggg1
13787 real(kind=8),dimension(3) :: cc,xx,ddc,ddx
13788 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
13789 real(kind=8),dimension(3) :: dcnorm_safe,dxnorm_safe
13790 real(kind=8),dimension(6,0:nres) :: grad_s,grad_s1 !(6,0:maxres)
13791 real(kind=8),dimension(nres) :: phi_temp,theta_temp,alph_temp,omeg_temp !(maxres)
13792 real(kind=8),dimension(0:n_ene) :: energia,energia1
13793 integer :: uiparm(1)
13794 real(kind=8) :: urparm(1)
13796 integer :: i,j,k,nf
13797 real(kind=8) :: rlambd,aincr,etot,etot1,etot11,etot12,etot2,&
13804 if (iset.eq.0) iset=1
13806 ! call intcartderiv
13807 ! call checkintcartgrad
13810 write(iout,*) 'Calling CHECK_ECARTINT.',aincr
13813 call geom_to_var(nvar,x)
13814 if (.not.split_ene) then
13815 call etotal(energia)
13817 ! call enerprint(energia)
13821 write (iout,'(i5,3f10.5)') i,(gradxorr(j,i),j=1,3)
13824 grad_s(j,0)=gcart(j,0)
13825 grad_s(j+3,0)=gxcart(j,0)
13829 grad_s(j,i)=gcart(j,i)
13830 grad_s(j+3,i)=gxcart(j,i)
13833 write(iout,*) "before movement analytical gradient"
13835 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
13836 (gxcart(j,i),j=1,3)
13840 !- split gradient check
13842 call etotal_long(energia)
13843 !el call enerprint(energia)
13847 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
13848 (gxcart(j,i),j=1,3)
13851 grad_s(j,0)=gcart(j,0)
13855 grad_s(j,i)=gcart(j,i)
13856 ! if (i.eq.21) print *,"PRZEKAZANIE",gcart(j,i)
13857 grad_s(j+3,i)=gxcart(j,i)
13861 call etotal_short(energia)
13862 !el call enerprint(energia)
13866 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
13867 (gxcart(j,i),j=1,3)
13870 grad_s1(j,0)=gcart(j,0)
13874 grad_s1(j,i)=gcart(j,i)
13875 grad_s1(j+3,i)=gxcart(j,i)
13879 write (iout,'(/a/)') 'Gradient in virtual-bond and SC vectors'
13884 ddx(j)=dc(j,i+nres)
13886 dcnorm_safe(k)=dc_norm(k,i)
13887 dxnorm_safe(k)=dc_norm(k,i+nres)
13891 dc(j,i)=ddc(j)+aincr
13892 call chainbuild_cart
13894 ! Broadcast the order to compute internal coordinates to the slaves.
13895 ! if (nfgtasks.gt.1)
13896 ! & call MPI_Bcast(6,1,MPI_INTEGER,king,FG_COMM,IERROR)
13898 ! call int_from_cart1(.false.)
13899 if (.not.split_ene) then
13901 call etotal(energia1)
13903 ! call enerprint(energia1)
13906 call etotal_long(energia1)
13908 call etotal_short(energia1)
13910 ! write (iout,*) "etot11",etot11," etot12",etot12
13912 !- end split gradient
13913 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot1",etot1
13914 dc(j,i)=ddc(j)-aincr
13915 call chainbuild_cart
13916 ! call int_from_cart1(.false.)
13917 if (.not.split_ene) then
13919 call etotal(energia1)
13920 ! call enerprint(energia1)
13922 ggg(j)=(etot1-etot2)/(2*aincr)
13925 call etotal_long(energia1)
13927 ggg(j)=(etot11-etot21)/(2*aincr)
13928 call etotal_short(energia1)
13930 ggg1(j)=(etot12-etot22)/(2*aincr)
13931 !- end split gradient
13932 ! write (iout,*) "etot21",etot21," etot22",etot22
13934 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
13936 call chainbuild_cart
13939 dc(j,i+nres)=ddx(j)+aincr
13940 call chainbuild_cart
13941 ! write (iout,*) "i",i," j",j," dxnorm+ and dxnorm"
13942 ! write (iout,'(3f15.10)') (dc_norm(k,i+nres),k=1,3)
13943 ! write (iout,'(3f15.10)') (dxnorm_safe(k),k=1,3)
13944 ! write (iout,*) "dxnormnorm",dsqrt(
13945 ! & dc_norm(1,i+nres)**2+dc_norm(2,i+nres)**2+dc_norm(3,i+nres)**2)
13946 ! write (iout,*) "dxnormnormsafe",dsqrt(
13947 ! & dxnorm_safe(1)**2+dxnorm_safe(2)**2+dxnorm_safe(3)**2)
13949 if (.not.split_ene) then
13951 call etotal(energia1)
13952 ! call enerprint(energia1)
13954 ! print *,"ene",energia1(0),energia1(57)
13957 call etotal_long(energia1)
13959 call etotal_short(energia1)
13962 !- end split gradient
13963 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot1",etot1
13964 dc(j,i+nres)=ddx(j)-aincr
13965 call chainbuild_cart
13966 ! write (iout,*) "i",i," j",j," dxnorm- and dxnorm"
13967 ! write (iout,'(3f15.10)') (dc_norm(k,i+nres),k=1,3)
13968 ! write (iout,'(3f15.10)') (dxnorm_safe(k),k=1,3)
13970 ! write (iout,*) "dxnormnorm",dsqrt(
13971 ! & dc_norm(1,i+nres)**2+dc_norm(2,i+nres)**2+dc_norm(3,i+nres)**2)
13972 ! write (iout,*) "dxnormnormsafe",dsqrt(
13973 ! & dxnorm_safe(1)**2+dxnorm_safe(2)**2+dxnorm_safe(3)**2)
13974 if (.not.split_ene) then
13976 call etotal(energia1)
13978 ! call enerprint(energia1)
13979 ! print *,"ene",energia1(0),energia1(57)
13980 ggg(j+3)=(etot1-etot2)/(2*aincr)
13983 call etotal_long(energia1)
13985 ggg(j+3)=(etot11-etot21)/(2*aincr)
13986 call etotal_short(energia1)
13988 ggg1(j+3)=(etot12-etot22)/(2*aincr)
13989 !- end split gradient
13991 ! write(iout,'(2i5,2(a,f15.10))')i,j," etot",etot," etot2",etot2
13992 dc(j,i+nres)=ddx(j)
13993 call chainbuild_cart
13995 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
13996 i,(ggg(k),k=1,6),(grad_s(k,i),k=1,6),(ggg(k)/grad_s(k,i),k=1,6)
13997 if (split_ene) then
13998 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
13999 i,(ggg1(k),k=1,6),(grad_s1(k,i),k=1,6),(ggg1(k)/grad_s1(k,i),&
14001 write (iout,'(i3,6(1pe12.5)/3x,6(1pe12.5)/3x,6(1pe12.5)/)') &
14002 i,(ggg(k)+ggg1(k),k=1,6),(grad_s(k,i)+grad_s1(k,i),k=1,6),&
14003 ((ggg(k)+ggg1(k))/(grad_s(k,i)+grad_s1(k,i)),k=1,6)
14007 end subroutine check_ecartint
14009 !-----------------------------------------------------------------------------
14010 subroutine check_eint
14011 ! Check the gradient of energy in internal coordinates.
14012 ! implicit real(kind=8) (a-h,o-z)
14013 ! include 'DIMENSIONS'
14014 ! include 'COMMON.CHAIN'
14015 ! include 'COMMON.DERIV'
14016 ! include 'COMMON.IOUNITS'
14017 ! include 'COMMON.VAR'
14018 ! include 'COMMON.GEO'
14021 ! use minimm, only : funcgrad
14023 !el integer :: icall
14024 !el common /srutu/ icall
14025 ! real(kind=8) :: funcgrad
14026 real(kind=8),dimension(6*nres) :: x,gana,gg !(maxvar) (maxvar=6*maxres)
14027 integer :: uiparm(1)
14028 real(kind=8) :: urparm(1)
14029 real(kind=8),dimension(0:n_ene) :: energia,energia1,energia2
14030 character(len=6) :: key
14033 real(kind=8) :: xi,aincr,etot,etot1,etot2,ff
14036 print '(a)','Calling CHECK_INT.'
14040 call geom_to_var(nvar,x)
14041 call var_to_geom(nvar,x)
14044 ! print *,'ICG=',ICG
14045 call etotal(energia)
14047 !el call enerprint(energia)
14048 ! print *,'ICG=',ICG
14050 if (MyID.ne.BossID) then
14051 call mp_bcast(x(1),8*(nvar+3),BossID,fgGroupID)
14060 ff=funcgrad(x,gana)
14063 !d write (iout,'(10f8.3)') (rad2deg*x(i),i=1,nvar)
14064 call gradient(nvar,x,nf,gana,uiparm,urparm,fdum)
14065 !d write (iout,'(i3,1pe14.4)') (i,gana(i),i=1,nvar+20) !sp
14070 x(i)=xi-0.5D0*aincr
14071 call var_to_geom(nvar,x)
14073 call etotal(energia1)
14075 x(i)=xi+0.5D0*aincr
14076 call var_to_geom(nvar,x)
14078 call etotal(energia2)
14080 gg(i)=(etot2-etot1)/aincr
14081 write (iout,*) i,etot1,etot2
14084 write (iout,'(/2a)')' Variable Numerical Analytical',&
14087 if (i.le.nphi) then
14090 else if (i.le.nphi+ntheta) then
14093 else if (i.le.nphi+ntheta+nside) then
14097 ii=i-(nphi+ntheta+nside)
14100 write (iout,'(i3,a,i3,3(1pd16.6))') &
14101 i,key,ii,gg(i),gana(i),&
14102 100.0D0*dabs(gg(i)-gana(i))/(dabs(gana(i))+aincr)
14105 end subroutine check_eint
14106 !-----------------------------------------------------------------------------
14108 !-----------------------------------------------------------------------------
14109 subroutine Econstr_back
14110 ! MD with umbrella_sampling using Wolyne's distance measure as a constraint
14111 ! implicit real(kind=8) (a-h,o-z)
14112 ! include 'DIMENSIONS'
14113 ! include 'COMMON.CONTROL'
14114 ! include 'COMMON.VAR'
14115 ! include 'COMMON.MD'
14118 ! include 'COMMON.LANGEVIN'
14120 ! include 'COMMON.LANGEVIN.lang0'
14122 ! include 'COMMON.CHAIN'
14123 ! include 'COMMON.DERIV'
14124 ! include 'COMMON.GEO'
14125 ! include 'COMMON.LOCAL'
14126 ! include 'COMMON.INTERACT'
14127 ! include 'COMMON.IOUNITS'
14128 ! include 'COMMON.NAMES'
14129 ! include 'COMMON.TIME1'
14130 integer :: i,j,ii,k
14131 real(kind=8) :: utheta_i,dtheta_i,ugamma_i,dgamma_i,dxx,dyy,dzz
14133 if(.not.allocated(utheta)) allocate(utheta(nfrag_back))
14134 if(.not.allocated(ugamma)) allocate(ugamma(nfrag_back))
14135 if(.not.allocated(uscdiff)) allocate(uscdiff(nfrag_back))
14142 duscdiff(j,i)=0.0d0
14143 duscdiffx(j,i)=0.0d0
14147 ii = ifrag_back(2,i,iset)-ifrag_back(1,i,iset)
14149 ! Deviations from theta angles
14152 do j=ifrag_back(1,i,iset)+2,ifrag_back(2,i,iset)
14153 dtheta_i=theta(j)-thetaref(j)
14154 utheta_i=utheta_i+0.5d0*dtheta_i*dtheta_i
14155 dutheta(j-2)=dutheta(j-2)+wfrag_back(1,i,iset)*dtheta_i/(ii-1)
14157 utheta(i)=utheta_i/(ii-1)
14159 ! Deviations from gamma angles
14162 do j=ifrag_back(1,i,iset)+3,ifrag_back(2,i,iset)
14163 dgamma_i=pinorm(phi(j)-phiref(j))
14164 ! write (iout,*) j,phi(j),phi(j)-phiref(j)
14165 ugamma_i=ugamma_i+0.5d0*dgamma_i*dgamma_i
14166 dugamma(j-3)=dugamma(j-3)+wfrag_back(2,i,iset)*dgamma_i/(ii-2)
14167 ! write (iout,*) i,j,dgamma_i,wfrag_back(2,i,iset),dugamma(j-3)
14169 ugamma(i)=ugamma_i/(ii-2)
14171 ! Deviations from local SC geometry
14174 do j=ifrag_back(1,i,iset)+1,ifrag_back(2,i,iset)-1
14175 dxx=xxtab(j)-xxref(j)
14176 dyy=yytab(j)-yyref(j)
14177 dzz=zztab(j)-zzref(j)
14178 uscdiff(i)=uscdiff(i)+dxx*dxx+dyy*dyy+dzz*dzz
14180 duscdiff(k,j-1)=duscdiff(k,j-1)+wfrag_back(3,i,iset)* &
14181 (dXX_C1tab(k,j)*dxx+dYY_C1tab(k,j)*dyy+dZZ_C1tab(k,j)*dzz)/ &
14183 duscdiff(k,j)=duscdiff(k,j)+wfrag_back(3,i,iset)* &
14184 (dXX_Ctab(k,j)*dxx+dYY_Ctab(k,j)*dyy+dZZ_Ctab(k,j)*dzz)/ &
14186 duscdiffx(k,j)=duscdiffx(k,j)+wfrag_back(3,i,iset)* &
14187 (dXX_XYZtab(k,j)*dxx+dYY_XYZtab(k,j)*dyy+dZZ_XYZtab(k,j)*dzz) &
14190 ! write (iout,'(i5,6f10.5)') j,xxtab(j),yytab(j),zztab(j),
14191 ! & xxref(j),yyref(j),zzref(j)
14193 uscdiff(i)=0.5d0*uscdiff(i)/(ii-1)
14194 ! write (iout,*) i," uscdiff",uscdiff(i)
14196 ! Put together deviations from local geometry
14198 Uconst_back=Uconst_back+wfrag_back(1,i,iset)*utheta(i)+ &
14199 wfrag_back(2,i,iset)*ugamma(i)+wfrag_back(3,i,iset)*uscdiff(i)
14200 ! write(iout,*) "i",i," utheta",utheta(i)," ugamma",ugamma(i),
14201 ! & " uconst_back",uconst_back
14202 utheta(i)=dsqrt(utheta(i))
14203 ugamma(i)=dsqrt(ugamma(i))
14204 uscdiff(i)=dsqrt(uscdiff(i))
14207 end subroutine Econstr_back
14208 !-----------------------------------------------------------------------------
14209 ! energy_p_new-sep_barrier.F
14210 !-----------------------------------------------------------------------------
14211 real(kind=8) function sscale(r)
14212 ! include "COMMON.SPLITELE"
14213 real(kind=8) :: r,gamm
14214 if(r.lt.r_cut-rlamb) then
14216 else if(r.le.r_cut.and.r.ge.r_cut-rlamb) then
14217 gamm=(r-(r_cut-rlamb))/rlamb
14218 sscale=1.0d0+gamm*gamm*(2*gamm-3.0d0)
14223 end function sscale
14224 real(kind=8) function sscale_grad(r)
14225 ! include "COMMON.SPLITELE"
14226 real(kind=8) :: r,gamm
14227 if(r.lt.r_cut-rlamb) then
14229 else if(r.le.r_cut.and.r.ge.r_cut-rlamb) then
14230 gamm=(r-(r_cut-rlamb))/rlamb
14231 sscale_grad=gamm*(6*gamm-6.0d0)/rlamb
14236 end function sscale_grad
14238 real(kind=8) function sscale_martini(r)
14239 ! include "COMMON.SPLITELE"
14240 real(kind=8) :: r,gamm
14241 ! print *,"here2",r_cut_mart,r
14242 if(r.lt.r_cut_mart-rlamb_mart) then
14243 sscale_martini=1.0d0
14244 else if(r.le.r_cut_mart.and.r.ge.r_cut_mart-rlamb_mart) then
14245 gamm=(r-(r_cut_mart-rlamb_mart))/rlamb_mart
14246 sscale_martini=1.0d0+gamm*gamm*(2*gamm-3.0d0)
14248 sscale_martini=0.0d0
14251 end function sscale_martini
14252 real(kind=8) function sscale_grad_martini(r)
14253 ! include "COMMON.SPLITELE"
14254 real(kind=8) :: r,gamm
14255 if(r.lt.r_cut_mart-rlamb_mart) then
14256 sscale_grad_martini=0.0d0
14257 else if(r.le.r_cut_mart.and.r.ge.r_cut_mart-rlamb_mart) then
14258 gamm=(r-(r_cut_mart-rlamb_mart))/rlamb_mart
14259 sscale_grad_martini=gamm*(6*gamm-6.0d0)/rlamb_mart
14261 sscale_grad_martini=0.0d0
14264 end function sscale_grad_martini
14265 real(kind=8) function sscale_martini_angle(r)
14266 ! include "COMMON.SPLITELE"
14267 real(kind=8) :: r,gamm,r_cut_angle,rlamb_angle
14268 ! print *,"here2",r_cut_angle,r
14271 if(r.lt.r_cut_angle-rlamb_angle) then
14272 sscale_martini_angle=1.0d0
14273 else if(r.le.r_cut_angle.and.r.ge.r_cut_angle-rlamb_angle) then
14274 gamm=(r-(r_cut_angle-rlamb_angle))/rlamb_angle
14275 sscale_martini_angle=1.0d0+gamm*gamm*(2*gamm-3.0d0)
14277 sscale_martini_angle=0.0d0
14280 end function sscale_martini_angle
14281 real(kind=8) function sscale_grad_martini_angle(r)
14282 ! include "COMMON.SPLITELE"
14283 real(kind=8) :: r,gamm,r_cut_angle,rlamb_angle
14286 if(r.lt.r_cut_angle-rlamb_angle) then
14287 sscale_grad_martini_angle=0.0d0
14288 else if(r.le.r_cut_angle.and.r.ge.r_cut_angle-rlamb_angle) then
14289 gamm=(r-(r_cut_angle-rlamb_angle))/rlamb_angle
14290 sscale_grad_martini_angle=gamm*(6*gamm-6.0d0)/rlamb_angle
14292 sscale_grad_martini_angle=0.0d0
14295 end function sscale_grad_martini_angle
14298 !!!!!!!!!! PBCSCALE
14299 real(kind=8) function sscale_ele(r)
14300 ! include "COMMON.SPLITELE"
14301 real(kind=8) :: r,gamm
14302 if(r.lt.r_cut_ele-rlamb_ele) then
14304 else if(r.le.r_cut_ele.and.r.ge.r_cut_ele-rlamb_ele) then
14305 gamm=(r-(r_cut_ele-rlamb_ele))/rlamb_ele
14306 sscale_ele=1.0d0+gamm*gamm*(2*gamm-3.0d0)
14311 end function sscale_ele
14313 real(kind=8) function sscagrad_ele(r)
14314 real(kind=8) :: r,gamm
14315 ! include "COMMON.SPLITELE"
14316 if(r.lt.r_cut_ele-rlamb_ele) then
14318 else if(r.le.r_cut_ele.and.r.ge.r_cut_ele-rlamb_ele) then
14319 gamm=(r-(r_cut_ele-rlamb_ele))/rlamb_ele
14320 sscagrad_ele=gamm*(6*gamm-6.0d0)/rlamb_ele
14325 end function sscagrad_ele
14326 !!!!!!!!!! PBCSCALE
14327 real(kind=8) function sscale2(r,r_cc,r_ll)
14328 ! include "COMMON.SPLITELE"
14329 real(kind=8) :: r,gamm,r_cc,r_ll
14330 if(r.lt.r_cc-r_ll) then
14332 else if(r.le.r_cc.and.r.ge.r_cc-r_ll) then
14333 gamm=(r-(r_cc-r_ll))/r_ll
14334 sscale2=1.0d0+gamm*gamm*(2*gamm-3.0d0)
14339 end function sscale2
14341 real(kind=8) function sscagrad2(r,r_cc,r_ll)
14342 real(kind=8) :: r,gamm,r_cc,r_ll
14343 ! include "COMMON.SPLITELE"
14344 if(r.lt.r_cc-r_ll) then
14346 else if(r.le.r_cc.and.r.ge.r_cc-r_ll) then
14347 gamm=(r-(r_cc-r_ll))/r_ll
14348 sscagrad2=gamm*(6*gamm-6.0d0)/r_ll
14353 end function sscagrad2
14355 real(kind=8) function sscalelip(r)
14356 real(kind=8) r,gamm
14357 sscalelip=1.0d0+r*r*(2.0d0*r-3.0d0)
14359 end function sscalelip
14360 !C-----------------------------------------------------------------------
14361 real(kind=8) function sscagradlip(r)
14362 real(kind=8) r,gamm
14363 sscagradlip=r*(6.0d0*r-6.0d0)
14365 end function sscagradlip
14368 !-----------------------------------------------------------------------------
14369 subroutine elj_long(evdw)
14371 ! This subroutine calculates the interaction energy of nonbonded side chains
14372 ! assuming the LJ potential of interaction.
14374 ! implicit real(kind=8) (a-h,o-z)
14375 ! include 'DIMENSIONS'
14376 ! include 'COMMON.GEO'
14377 ! include 'COMMON.VAR'
14378 ! include 'COMMON.LOCAL'
14379 ! include 'COMMON.CHAIN'
14380 ! include 'COMMON.DERIV'
14381 ! include 'COMMON.INTERACT'
14382 ! include 'COMMON.TORSION'
14383 ! include 'COMMON.SBRIDGE'
14384 ! include 'COMMON.NAMES'
14385 ! include 'COMMON.IOUNITS'
14386 ! include 'COMMON.CONTACTS'
14387 real(kind=8),parameter :: accur=1.0d-10
14388 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
14389 !el local variables
14390 integer :: i,iint,j,k,itypi,itypi1,itypj
14391 real(kind=8) :: xi,yi,zi,xj,yj,zj,rij,sss,rrij,fac,eps0ij
14392 real(kind=8) :: e1,e2,evdwij,evdw,sslipi,ssgradlipi,&
14393 sslipj,ssgradlipj,aa,bb
14394 ! write(iout,*)'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
14396 do i=iatsc_s,iatsc_e
14398 if (itypi.eq.ntyp1) cycle
14399 itypi1=itype(i+1,1)
14403 call to_box(xi,yi,zi)
14404 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
14406 ! Calculate SC interaction energy.
14408 do iint=1,nint_gr(i)
14409 !d write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
14410 !d & 'iend=',iend(i,iint)
14411 do j=istart(i,iint),iend(i,iint)
14413 if (itypj.eq.ntyp1) cycle
14417 call to_box(xj,yj,zj)
14418 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
14419 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
14420 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
14421 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
14422 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
14423 xj=boxshift(xj-xi,boxxsize)
14424 yj=boxshift(yj-yi,boxysize)
14425 zj=boxshift(zj-zi,boxzsize)
14426 rij=xj*xj+yj*yj+zj*zj
14427 sss=sscale(dsqrt(rij)/sigma(itypi,itypj))
14428 if (sss.lt.1.0d0) then
14430 eps0ij=eps(itypi,itypj)
14432 e1=fac*fac*aa_aq(itypi,itypj)
14433 e2=fac*bb_aq(itypi,itypj)
14435 evdw=evdw+(1.0d0-sss)*evdwij
14437 ! Calculate the components of the gradient in DC and X
14439 fac=-rrij*(e1+evdwij)*(1.0d0-sss)
14444 gvdwx(k,i)=gvdwx(k,i)-gg(k)
14445 gvdwx(k,j)=gvdwx(k,j)+gg(k)
14446 gvdwc(k,i)=gvdwc(k,i)-gg(k)
14447 gvdwc(k,j)=gvdwc(k,j)+gg(k)
14455 gvdwc(j,i)=expon*gvdwc(j,i)
14456 gvdwx(j,i)=expon*gvdwx(j,i)
14459 !******************************************************************************
14463 ! To save time, the factor of EXPON has been extracted from ALL components
14464 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
14467 !******************************************************************************
14469 end subroutine elj_long
14470 !-----------------------------------------------------------------------------
14471 subroutine elj_short(evdw)
14473 ! This subroutine calculates the interaction energy of nonbonded side chains
14474 ! assuming the LJ potential of interaction.
14476 ! implicit real(kind=8) (a-h,o-z)
14477 ! include 'DIMENSIONS'
14478 ! include 'COMMON.GEO'
14479 ! include 'COMMON.VAR'
14480 ! include 'COMMON.LOCAL'
14481 ! include 'COMMON.CHAIN'
14482 ! include 'COMMON.DERIV'
14483 ! include 'COMMON.INTERACT'
14484 ! include 'COMMON.TORSION'
14485 ! include 'COMMON.SBRIDGE'
14486 ! include 'COMMON.NAMES'
14487 ! include 'COMMON.IOUNITS'
14488 ! include 'COMMON.CONTACTS'
14489 real(kind=8),parameter :: accur=1.0d-10
14490 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
14491 !el local variables
14492 integer :: i,iint,j,k,itypi,itypi1,itypj,num_conti
14493 real(kind=8) :: xi,yi,zi,xj,yj,zj,rij,sss,rrij,fac,eps0ij
14494 real(kind=8) :: e1,e2,evdwij,evdw,sslipi,ssgradlipi,&
14496 ! write(iout,*)'Entering ELJ nnt=',nnt,' nct=',nct,' expon=',expon
14498 do i=iatsc_s,iatsc_e
14500 if (itypi.eq.ntyp1) cycle
14501 itypi1=itype(i+1,1)
14505 call to_box(xi,yi,zi)
14506 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
14510 ! Calculate SC interaction energy.
14512 do iint=1,nint_gr(i)
14513 !d write (iout,*) 'i=',i,' iint=',iint,' istart=',istart(i,iint),
14514 !d & 'iend=',iend(i,iint)
14515 do j=istart(i,iint),iend(i,iint)
14517 if (itypj.eq.ntyp1) cycle
14521 ! Change 12/1/95 to calculate four-body interactions
14522 rij=xj*xj+yj*yj+zj*zj
14523 sss=sscale(dsqrt(rij)/sigma(itypi,itypj))
14524 if (sss.gt.0.0d0) then
14526 eps0ij=eps(itypi,itypj)
14528 e1=fac*fac*aa_aq(itypi,itypj)
14529 e2=fac*bb_aq(itypi,itypj)
14531 evdw=evdw+sss*evdwij
14533 ! Calculate the components of the gradient in DC and X
14535 fac=-rrij*(e1+evdwij)*sss
14540 gvdwx(k,i)=gvdwx(k,i)-gg(k)
14541 gvdwx(k,j)=gvdwx(k,j)+gg(k)
14542 gvdwc(k,i)=gvdwc(k,i)-gg(k)
14543 gvdwc(k,j)=gvdwc(k,j)+gg(k)
14551 gvdwc(j,i)=expon*gvdwc(j,i)
14552 gvdwx(j,i)=expon*gvdwx(j,i)
14555 !******************************************************************************
14559 ! To save time, the factor of EXPON has been extracted from ALL components
14560 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
14563 !******************************************************************************
14565 end subroutine elj_short
14566 !-----------------------------------------------------------------------------
14567 subroutine eljk_long(evdw)
14569 ! This subroutine calculates the interaction energy of nonbonded side chains
14570 ! assuming the LJK potential of interaction.
14572 ! implicit real(kind=8) (a-h,o-z)
14573 ! include 'DIMENSIONS'
14574 ! include 'COMMON.GEO'
14575 ! include 'COMMON.VAR'
14576 ! include 'COMMON.LOCAL'
14577 ! include 'COMMON.CHAIN'
14578 ! include 'COMMON.DERIV'
14579 ! include 'COMMON.INTERACT'
14580 ! include 'COMMON.IOUNITS'
14581 ! include 'COMMON.NAMES'
14582 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
14584 !el local variables
14585 integer :: i,iint,j,k,itypi,itypi1,itypj
14586 real(kind=8) :: rrij,r_inv_ij,xj,yj,zj,xi,yi,zi,fac,evdw,&
14587 fac_augm,e_augm,rij,sss,r_shift_inv,e1,e2,evdwij
14588 ! print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
14590 do i=iatsc_s,iatsc_e
14592 if (itypi.eq.ntyp1) cycle
14593 itypi1=itype(i+1,1)
14597 call to_box(xi,yi,zi)
14600 ! Calculate SC interaction energy.
14602 do iint=1,nint_gr(i)
14603 do j=istart(i,iint),iend(i,iint)
14605 if (itypj.eq.ntyp1) cycle
14609 call to_box(xj,yj,zj)
14610 xj=boxshift(xj-xi,boxxsize)
14611 yj=boxshift(yj-yi,boxysize)
14612 zj=boxshift(zj-zi,boxzsize)
14614 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
14615 fac_augm=rrij**expon
14616 e_augm=augm(itypi,itypj)*fac_augm
14617 r_inv_ij=dsqrt(rrij)
14619 sss=sscale(rij/sigma(itypi,itypj))
14620 if (sss.lt.1.0d0) then
14621 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
14622 fac=r_shift_inv**expon
14623 e1=fac*fac*aa_aq(itypi,itypj)
14624 e2=fac*bb_aq(itypi,itypj)
14625 evdwij=e_augm+e1+e2
14626 !d sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
14627 !d epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
14628 !d write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
14629 !d & restyp(itypi,1),i,restyp(itypj,1),j,aa(itypi,itypj),
14630 !d & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
14631 !d & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
14632 !d & (c(k,i),k=1,3),(c(k,j),k=1,3)
14633 evdw=evdw+(1.0d0-sss)*evdwij
14635 ! Calculate the components of the gradient in DC and X
14637 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
14638 fac=fac*(1.0d0-sss)
14643 gvdwx(k,i)=gvdwx(k,i)-gg(k)
14644 gvdwx(k,j)=gvdwx(k,j)+gg(k)
14645 gvdwc(k,i)=gvdwc(k,i)-gg(k)
14646 gvdwc(k,j)=gvdwc(k,j)+gg(k)
14654 gvdwc(j,i)=expon*gvdwc(j,i)
14655 gvdwx(j,i)=expon*gvdwx(j,i)
14659 end subroutine eljk_long
14660 !-----------------------------------------------------------------------------
14661 subroutine eljk_short(evdw)
14663 ! This subroutine calculates the interaction energy of nonbonded side chains
14664 ! assuming the LJK potential of interaction.
14666 ! implicit real(kind=8) (a-h,o-z)
14667 ! include 'DIMENSIONS'
14668 ! include 'COMMON.GEO'
14669 ! include 'COMMON.VAR'
14670 ! include 'COMMON.LOCAL'
14671 ! include 'COMMON.CHAIN'
14672 ! include 'COMMON.DERIV'
14673 ! include 'COMMON.INTERACT'
14674 ! include 'COMMON.IOUNITS'
14675 ! include 'COMMON.NAMES'
14676 real(kind=8),dimension(3) :: gg,gg_lipi,gg_lipj
14678 !el local variables
14679 integer :: i,iint,j,k,itypi,itypi1,itypj
14680 real(kind=8) :: rrij,r_inv_ij,xj,yj,zj,xi,yi,zi,fac,evdw,&
14681 fac_augm,e_augm,rij,sss,r_shift_inv,e1,e2,evdwij,&
14682 sslipi,ssgradlipi,sslipj,ssgradlipj,aa,bb
14683 ! print *,'Entering ELJK nnt=',nnt,' nct=',nct,' expon=',expon
14685 do i=iatsc_s,iatsc_e
14687 if (itypi.eq.ntyp1) cycle
14688 itypi1=itype(i+1,1)
14692 call to_box(xi,yi,zi)
14693 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
14695 ! Calculate SC interaction energy.
14697 do iint=1,nint_gr(i)
14698 do j=istart(i,iint),iend(i,iint)
14700 if (itypj.eq.ntyp1) cycle
14704 call to_box(xj,yj,zj)
14705 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
14706 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
14707 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
14708 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
14709 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
14710 xj=boxshift(xj-xi,boxxsize)
14711 yj=boxshift(yj-yi,boxysize)
14712 zj=boxshift(zj-zi,boxzsize)
14713 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
14714 fac_augm=rrij**expon
14715 e_augm=augm(itypi,itypj)*fac_augm
14716 r_inv_ij=dsqrt(rrij)
14718 sss=sscale(rij/sigma(itypi,itypj))
14719 if (sss.gt.0.0d0) then
14720 r_shift_inv=1.0D0/(rij+r0(itypi,itypj)-sigma(itypi,itypj))
14721 fac=r_shift_inv**expon
14722 e1=fac*fac*aa_aq(itypi,itypj)
14723 e2=fac*bb_aq(itypi,itypj)
14724 evdwij=e_augm+e1+e2
14725 !d sigm=dabs(aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
14726 !d epsi=bb(itypi,itypj)**2/aa(itypi,itypj)
14727 !d write (iout,'(2(a3,i3,2x),8(1pd12.4)/2(3(1pd12.4),5x)/)')
14728 !d & restyp(itypi,1),i,restyp(itypj,1),j,aa(itypi,itypj),
14729 !d & bb(itypi,itypj),augm(itypi,itypj),epsi,sigm,
14730 !d & sigma(itypi,itypj),1.0D0/dsqrt(rrij),evdwij,
14731 !d & (c(k,i),k=1,3),(c(k,j),k=1,3)
14732 evdw=evdw+sss*evdwij
14734 ! Calculate the components of the gradient in DC and X
14736 fac=-2.0D0*rrij*e_augm-r_inv_ij*r_shift_inv*(e1+e1+e2)
14742 gvdwx(k,i)=gvdwx(k,i)-gg(k)
14743 gvdwx(k,j)=gvdwx(k,j)+gg(k)
14744 gvdwc(k,i)=gvdwc(k,i)-gg(k)
14745 gvdwc(k,j)=gvdwc(k,j)+gg(k)
14753 gvdwc(j,i)=expon*gvdwc(j,i)
14754 gvdwx(j,i)=expon*gvdwx(j,i)
14758 end subroutine eljk_short
14759 !-----------------------------------------------------------------------------
14760 subroutine ebp_long(evdw)
14761 ! This subroutine calculates the interaction energy of nonbonded side chains
14762 ! assuming the Berne-Pechukas potential of interaction.
14765 ! implicit real(kind=8) (a-h,o-z)
14766 ! include 'DIMENSIONS'
14767 ! include 'COMMON.GEO'
14768 ! include 'COMMON.VAR'
14769 ! include 'COMMON.LOCAL'
14770 ! include 'COMMON.CHAIN'
14771 ! include 'COMMON.DERIV'
14772 ! include 'COMMON.NAMES'
14773 ! include 'COMMON.INTERACT'
14774 ! include 'COMMON.IOUNITS'
14775 ! include 'COMMON.CALC'
14777 !el integer :: icall
14778 !el common /srutu/ icall
14779 ! double precision rrsave(maxdim)
14781 !el local variables
14782 integer :: iint,itypi,itypi1,itypj
14783 real(kind=8) :: rrij,xi,yi,zi,fac,sslipi,ssgradlipi,&
14784 sslipj,ssgradlipj,aa,bb
14785 real(kind=8) :: sss,e1,e2,evdw,sigm,epsi
14787 ! print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
14789 ! if (icall.eq.0) then
14795 do i=iatsc_s,iatsc_e
14797 if (itypi.eq.ntyp1) cycle
14798 itypi1=itype(i+1,1)
14802 call to_box(xi,yi,zi)
14803 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
14804 dxi=dc_norm(1,nres+i)
14805 dyi=dc_norm(2,nres+i)
14806 dzi=dc_norm(3,nres+i)
14807 ! dsci_inv=dsc_inv(itypi)
14808 dsci_inv=vbld_inv(i+nres)
14810 ! Calculate SC interaction energy.
14812 do iint=1,nint_gr(i)
14813 do j=istart(i,iint),iend(i,iint)
14816 if (itypj.eq.ntyp1) cycle
14817 ! dscj_inv=dsc_inv(itypj)
14818 dscj_inv=vbld_inv(j+nres)
14819 !chi1=chi(itypi,itypj)
14820 !chi2=chi(itypj,itypi)
14825 alf12=0.5D0*(alf1+alf2)
14829 call to_box(xj,yj,zj)
14830 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
14831 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
14832 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
14833 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
14834 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
14835 xj=boxshift(xj-xi,boxxsize)
14836 yj=boxshift(yj-yi,boxysize)
14837 zj=boxshift(zj-zi,boxzsize)
14838 dxj=dc_norm(1,nres+j)
14839 dyj=dc_norm(2,nres+j)
14840 dzj=dc_norm(3,nres+j)
14841 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
14843 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
14845 if (sss.lt.1.0d0) then
14847 ! Calculate the angle-dependent terms of energy & contributions to derivatives.
14849 ! Calculate whole angle-dependent part of epsilon and contributions
14850 ! to its derivatives
14851 fac=(rrij*sigsq)**expon2
14852 e1=fac*fac*aa_aq(itypi,itypj)
14853 e2=fac*bb_aq(itypi,itypj)
14854 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
14855 eps2der=evdwij*eps3rt
14856 eps3der=evdwij*eps2rt
14857 evdwij=evdwij*eps2rt*eps3rt
14858 evdw=evdw+evdwij*(1.0d0-sss)
14860 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
14861 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
14862 !d write (iout,'(2(a3,i3,2x),15(0pf7.3))')
14863 !d & restyp(itypi,1),i,restyp(itypj,1),j,
14864 !d & epsi,sigm,chi1,chi2,chip1,chip2,
14865 !d & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
14866 !d & om1,om2,om12,1.0D0/dsqrt(rrij),
14869 ! Calculate gradient components.
14870 e1=e1*eps1*eps2rt**2*eps3rt**2
14871 fac=-expon*(e1+evdwij)
14874 ! Calculate radial part of the gradient
14878 ! Calculate the angular part of the gradient and sum add the contributions
14879 ! to the appropriate components of the Cartesian gradient.
14880 call sc_grad_scale(1.0d0-sss)
14887 end subroutine ebp_long
14888 !-----------------------------------------------------------------------------
14889 subroutine ebp_short(evdw)
14891 ! This subroutine calculates the interaction energy of nonbonded side chains
14892 ! assuming the Berne-Pechukas potential of interaction.
14895 ! implicit real(kind=8) (a-h,o-z)
14896 ! include 'DIMENSIONS'
14897 ! include 'COMMON.GEO'
14898 ! include 'COMMON.VAR'
14899 ! include 'COMMON.LOCAL'
14900 ! include 'COMMON.CHAIN'
14901 ! include 'COMMON.DERIV'
14902 ! include 'COMMON.NAMES'
14903 ! include 'COMMON.INTERACT'
14904 ! include 'COMMON.IOUNITS'
14905 ! include 'COMMON.CALC'
14907 !el integer :: icall
14908 !el common /srutu/ icall
14909 ! double precision rrsave(maxdim)
14911 !el local variables
14912 integer :: iint,itypi,itypi1,itypj
14913 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi
14914 real(kind=8) :: sss,e1,e2,evdw,aa,bb, &
14915 sslipi,ssgradlipi,sslipj,ssgradlipj
14917 ! print *,'Entering EBP nnt=',nnt,' nct=',nct,' expon=',expon
14919 ! if (icall.eq.0) then
14925 do i=iatsc_s,iatsc_e
14927 if (itypi.eq.ntyp1) cycle
14928 itypi1=itype(i+1,1)
14932 call to_box(xi,yi,zi)
14933 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
14935 dxi=dc_norm(1,nres+i)
14936 dyi=dc_norm(2,nres+i)
14937 dzi=dc_norm(3,nres+i)
14938 ! dsci_inv=dsc_inv(itypi)
14939 dsci_inv=vbld_inv(i+nres)
14941 ! Calculate SC interaction energy.
14943 do iint=1,nint_gr(i)
14944 do j=istart(i,iint),iend(i,iint)
14947 if (itypj.eq.ntyp1) cycle
14948 ! dscj_inv=dsc_inv(itypj)
14949 dscj_inv=vbld_inv(j+nres)
14950 chi1=chi(itypi,itypj)
14951 chi2=chi(itypj,itypi)
14958 alf12=0.5D0*(alf1+alf2)
14962 call to_box(xj,yj,zj)
14963 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
14964 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
14965 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
14966 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
14967 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
14968 xj=boxshift(xj-xi,boxxsize)
14969 yj=boxshift(yj-yi,boxysize)
14970 zj=boxshift(zj-zi,boxzsize)
14971 dxj=dc_norm(1,nres+j)
14972 dyj=dc_norm(2,nres+j)
14973 dzj=dc_norm(3,nres+j)
14974 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
14976 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
14978 if (sss.gt.0.0d0) then
14980 ! Calculate the angle-dependent terms of energy & contributions to derivatives.
14982 ! Calculate whole angle-dependent part of epsilon and contributions
14983 ! to its derivatives
14984 fac=(rrij*sigsq)**expon2
14985 e1=fac*fac*aa_aq(itypi,itypj)
14986 e2=fac*bb_aq(itypi,itypj)
14987 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
14988 eps2der=evdwij*eps3rt
14989 eps3der=evdwij*eps2rt
14990 evdwij=evdwij*eps2rt*eps3rt
14991 evdw=evdw+evdwij*sss
14993 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
14994 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
14995 !d write (iout,'(2(a3,i3,2x),15(0pf7.3))')
14996 !d & restyp(itypi,1),i,restyp(itypj,1),j,
14997 !d & epsi,sigm,chi1,chi2,chip1,chip2,
14998 !d & eps1,eps2rt**2,eps3rt**2,1.0D0/dsqrt(sigsq),
14999 !d & om1,om2,om12,1.0D0/dsqrt(rrij),
15002 ! Calculate gradient components.
15003 e1=e1*eps1*eps2rt**2*eps3rt**2
15004 fac=-expon*(e1+evdwij)
15007 ! Calculate radial part of the gradient
15011 ! Calculate the angular part of the gradient and sum add the contributions
15012 ! to the appropriate components of the Cartesian gradient.
15013 call sc_grad_scale(sss)
15020 end subroutine ebp_short
15021 !-----------------------------------------------------------------------------
15022 subroutine egb_long(evdw)
15024 ! This subroutine calculates the interaction energy of nonbonded side chains
15025 ! assuming the Gay-Berne potential of interaction.
15028 ! implicit real(kind=8) (a-h,o-z)
15029 ! include 'DIMENSIONS'
15030 ! include 'COMMON.GEO'
15031 ! include 'COMMON.VAR'
15032 ! include 'COMMON.LOCAL'
15033 ! include 'COMMON.CHAIN'
15034 ! include 'COMMON.DERIV'
15035 ! include 'COMMON.NAMES'
15036 ! include 'COMMON.INTERACT'
15037 ! include 'COMMON.IOUNITS'
15038 ! include 'COMMON.CALC'
15039 ! include 'COMMON.CONTROL'
15041 !el local variables
15042 integer :: iint,itypi,itypi1,itypj,subchap
15043 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,sig,sig0ij,rij_shift
15044 real(kind=8) :: sss,e1,e2,evdw,sss_grad
15045 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
15046 dist_temp, dist_init,aa,bb,fracinbuf,sslipi,sslipj,&
15047 ssgradlipi,ssgradlipj
15051 !cccc energy_dec=.false.
15052 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
15055 ! if (icall.eq.0) lprn=.false.
15057 do i=iatsc_s,iatsc_e
15059 if (itypi.eq.ntyp1) cycle
15060 itypi1=itype(i+1,1)
15064 call to_box(xi,yi,zi)
15065 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
15066 dxi=dc_norm(1,nres+i)
15067 dyi=dc_norm(2,nres+i)
15068 dzi=dc_norm(3,nres+i)
15069 ! dsci_inv=dsc_inv(itypi)
15070 dsci_inv=vbld_inv(i+nres)
15071 ! write (iout,*) "i",i,dsc_inv(itypi),dsci_inv,1.0d0/vbld(i+nres)
15072 ! write (iout,*) "dcnori",dxi*dxi+dyi*dyi+dzi*dzi
15074 ! Calculate SC interaction energy.
15076 do iint=1,nint_gr(i)
15077 do j=istart(i,iint),iend(i,iint)
15078 IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
15079 ! call dyn_ssbond_ene(i,j,evdwij)
15081 ! if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
15082 ! 'evdw',i,j,evdwij,' ss'
15083 ! if (energy_dec) write (iout,*) &
15084 ! 'evdw',i,j,evdwij,' ss'
15085 ! do k=j+1,iend(i,iint)
15086 !C search over all next residues
15087 ! if (dyn_ss_mask(k)) then
15088 !C check if they are cysteins
15089 !C write(iout,*) 'k=',k
15091 !c write(iout,*) "PRZED TRI", evdwij
15092 ! evdwij_przed_tri=evdwij
15093 ! call triple_ssbond_ene(i,j,k,evdwij)
15094 !c if(evdwij_przed_tri.ne.evdwij) then
15095 !c write (iout,*) "TRI:", evdwij, evdwij_przed_tri
15098 !c write(iout,*) "PO TRI", evdwij
15099 !C call the energy function that removes the artifical triple disulfide
15100 !C bond the soubroutine is located in ssMD.F
15102 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
15103 'evdw',i,j,evdwij,'tss'
15104 ! endif!dyn_ss_mask(k)
15110 if (itypj.eq.ntyp1) cycle
15111 ! dscj_inv=dsc_inv(itypj)
15112 dscj_inv=vbld_inv(j+nres)
15113 ! write (iout,*) "j",j,dsc_inv(itypj),dscj_inv,
15114 ! & 1.0d0/vbld(j+nres)
15115 ! write (iout,*) "i",i," j", j," itype",itype(i,1),itype(j,1)
15116 sig0ij=sigma(itypi,itypj)
15117 chi1=chi(itypi,itypj)
15118 chi2=chi(itypj,itypi)
15125 alf12=0.5D0*(alf1+alf2)
15129 ! Searching for nearest neighbour
15130 call to_box(xj,yj,zj)
15131 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
15132 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
15133 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
15134 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
15135 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
15136 xj=boxshift(xj-xi,boxxsize)
15137 yj=boxshift(yj-yi,boxysize)
15138 zj=boxshift(zj-zi,boxzsize)
15139 dxj=dc_norm(1,nres+j)
15140 dyj=dc_norm(2,nres+j)
15141 dzj=dc_norm(3,nres+j)
15142 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
15144 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
15145 sss_ele_cut=sscale_ele(1.0d0/(rij))
15146 sss_ele_grad=sscagrad_ele(1.0d0/(rij))
15147 sss_grad=sscale_grad(1.0d0/(rij*sigmaii(itypi,itypj)))
15148 if (sss_ele_cut.le.0.0) cycle
15149 if (sss.lt.1.0d0) then
15151 ! Calculate angle-dependent terms of energy and contributions to their
15155 sig=sig0ij*dsqrt(sigsq)
15156 rij_shift=1.0D0/rij-sig+sig0ij
15157 ! for diagnostics; uncomment
15158 ! rij_shift=1.2*sig0ij
15159 ! I hate to put IF's in the loops, but here don't have another choice!!!!
15160 if (rij_shift.le.0.0D0) then
15162 !d write (iout,'(2(a3,i3,2x),17(0pf7.3))')
15163 !d & restyp(itypi,1),i,restyp(itypj,1),j,
15164 !d & rij_shift,1.0D0/rij,sig,sig0ij,sigsq,1-dsqrt(sigsq)
15168 !---------------------------------------------------------------
15169 rij_shift=1.0D0/rij_shift
15170 fac=rij_shift**expon
15173 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
15174 eps2der=evdwij*eps3rt
15175 eps3der=evdwij*eps2rt
15176 ! write (iout,*) "sigsq",sigsq," sig",sig," eps2rt",eps2rt,
15177 ! & " eps3rt",eps3rt," eps1",eps1," e1",e1," e2",e2
15178 evdwij=evdwij*eps2rt*eps3rt
15179 evdw=evdw+evdwij*(1.0d0-sss)*sss_ele_cut
15181 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
15182 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
15183 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
15184 restyp(itypi,1),i,restyp(itypj,1),j,&
15185 epsi,sigm,chi1,chi2,chip1,chip2,&
15186 eps1,eps2rt**2,eps3rt**2,sig,sig0ij,&
15187 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
15191 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
15193 ! if (energy_dec) write (iout,*) &
15194 ! 'evdw',i,j,evdwij,"egb_long"
15196 ! Calculate gradient components.
15197 e1=e1*eps1*eps2rt**2*eps3rt**2
15198 fac=-expon*(e1+evdwij)*rij_shift
15201 fac=fac+evdwij*(sss_ele_grad/sss_ele_cut&
15202 *rij-sss_grad/(1.0-sss)*rij &
15203 /sigmaii(itypi,itypj))
15205 ! Calculate the radial part of the gradient
15209 ! Calculate angular part of the gradient.
15210 call sc_grad_scale(1.0d0-sss)
15216 ! write (iout,*) "Number of loop steps in EGB:",ind
15217 !ccc energy_dec=.false.
15219 end subroutine egb_long
15220 !-----------------------------------------------------------------------------
15221 subroutine egb_short(evdw)
15223 ! This subroutine calculates the interaction energy of nonbonded side chains
15224 ! assuming the Gay-Berne potential of interaction.
15227 ! implicit real(kind=8) (a-h,o-z)
15228 ! include 'DIMENSIONS'
15229 ! include 'COMMON.GEO'
15230 ! include 'COMMON.VAR'
15231 ! include 'COMMON.LOCAL'
15232 ! include 'COMMON.CHAIN'
15233 ! include 'COMMON.DERIV'
15234 ! include 'COMMON.NAMES'
15235 ! include 'COMMON.INTERACT'
15236 ! include 'COMMON.IOUNITS'
15237 ! include 'COMMON.CALC'
15238 ! include 'COMMON.CONTROL'
15240 !el local variables
15241 integer :: iint,itypi,itypi1,itypj,subchap,countss
15242 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,sig0ij,sig
15243 real(kind=8) :: sss,e1,e2,evdw,rij_shift,sss_grad
15244 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
15245 dist_temp, dist_init,aa,bb,fracinbuf,sslipi,sslipj,&
15246 ssgradlipi,ssgradlipj
15248 !cccc energy_dec=.false.
15249 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
15253 ! if (icall.eq.0) lprn=.false.
15255 do i=iatsc_s,iatsc_e
15257 if (itypi.eq.ntyp1) cycle
15258 itypi1=itype(i+1,1)
15262 call to_box(xi,yi,zi)
15263 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
15265 dxi=dc_norm(1,nres+i)
15266 dyi=dc_norm(2,nres+i)
15267 dzi=dc_norm(3,nres+i)
15268 ! dsci_inv=dsc_inv(itypi)
15269 dsci_inv=vbld_inv(i+nres)
15271 dxi=dc_norm(1,nres+i)
15272 dyi=dc_norm(2,nres+i)
15273 dzi=dc_norm(3,nres+i)
15274 ! dsci_inv=dsc_inv(itypi)
15275 dsci_inv=vbld_inv(i+nres)
15276 do iint=1,nint_gr(i)
15277 do j=istart(i,iint),iend(i,iint)
15278 IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
15280 call dyn_ssbond_ene(i,j,evdwij,countss)
15282 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
15283 'evdw',i,j,evdwij,' ss'
15284 do k=j+1,iend(i,iint)
15285 !C search over all next residues
15286 if (dyn_ss_mask(k)) then
15287 !C check if they are cysteins
15288 !C write(iout,*) 'k=',k
15290 !c write(iout,*) "PRZED TRI", evdwij
15291 ! evdwij_przed_tri=evdwij
15292 call triple_ssbond_ene(i,j,k,evdwij)
15293 !c if(evdwij_przed_tri.ne.evdwij) then
15294 !c write (iout,*) "TRI:", evdwij, evdwij_przed_tri
15297 !c write(iout,*) "PO TRI", evdwij
15298 !C call the energy function that removes the artifical triple disulfide
15299 !C bond the soubroutine is located in ssMD.F
15301 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
15302 'evdw',i,j,evdwij,'tss'
15303 endif!dyn_ss_mask(k)
15308 if (itypj.eq.ntyp1) cycle
15309 ! dscj_inv=dsc_inv(itypj)
15310 dscj_inv=vbld_inv(j+nres)
15311 dscj_inv=dsc_inv(itypj)
15312 ! write (iout,*) "j",j,dsc_inv(itypj),dscj_inv,
15313 ! & 1.0d0/vbld(j+nres)
15314 ! write (iout,*) "i",i," j", j," itype",itype(i,1),itype(j,1)
15315 sig0ij=sigma(itypi,itypj)
15316 chi1=chi(itypi,itypj)
15317 chi2=chi(itypj,itypi)
15324 alf12=0.5D0*(alf1+alf2)
15325 ! xj=c(1,nres+j)-xi
15326 ! yj=c(2,nres+j)-yi
15327 ! zj=c(3,nres+j)-zi
15331 ! Searching for nearest neighbour
15332 call to_box(xj,yj,zj)
15333 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
15334 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
15335 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
15336 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
15337 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
15338 xj=boxshift(xj-xi,boxxsize)
15339 yj=boxshift(yj-yi,boxysize)
15340 zj=boxshift(zj-zi,boxzsize)
15341 dxj=dc_norm(1,nres+j)
15342 dyj=dc_norm(2,nres+j)
15343 dzj=dc_norm(3,nres+j)
15344 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
15346 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
15347 sss_grad=sscale_grad(1.0d0/(rij*sigmaii(itypi,itypj)))
15348 sss_ele_cut=sscale_ele(1.0d0/(rij))
15349 sss_ele_grad=sscagrad_ele(1.0d0/(rij))
15350 if (sss_ele_cut.le.0.0) cycle
15352 if (sss.gt.0.0d0) then
15354 ! Calculate angle-dependent terms of energy and contributions to their
15358 sig=sig0ij*dsqrt(sigsq)
15359 rij_shift=1.0D0/rij-sig+sig0ij
15360 ! for diagnostics; uncomment
15361 ! rij_shift=1.2*sig0ij
15362 ! I hate to put IF's in the loops, but here don't have another choice!!!!
15363 if (rij_shift.le.0.0D0) then
15365 !d write (iout,'(2(a3,i3,2x),17(0pf7.3))')
15366 !d & restyp(itypi,1),i,restyp(itypj,1),j,
15367 !d & rij_shift,1.0D0/rij,sig,sig0ij,sigsq,1-dsqrt(sigsq)
15371 !---------------------------------------------------------------
15372 rij_shift=1.0D0/rij_shift
15373 fac=rij_shift**expon
15376 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
15377 eps2der=evdwij*eps3rt
15378 eps3der=evdwij*eps2rt
15379 ! write (iout,*) "sigsq",sigsq," sig",sig," eps2rt",eps2rt,
15380 ! & " eps3rt",eps3rt," eps1",eps1," e1",e1," e2",e2
15381 evdwij=evdwij*eps2rt*eps3rt
15382 evdw=evdw+evdwij*sss*sss_ele_cut
15384 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
15385 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
15386 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
15387 restyp(itypi,1),i,restyp(itypj,1),j,&
15388 epsi,sigm,chi1,chi2,chip1,chip2,&
15389 eps1,eps2rt**2,eps3rt**2,sig,sig0ij,&
15390 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
15394 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
15396 ! if (energy_dec) write (iout,*) &
15397 ! 'evdw',i,j,evdwij,"egb_short"
15399 ! Calculate gradient components.
15400 e1=e1*eps1*eps2rt**2*eps3rt**2
15401 fac=-expon*(e1+evdwij)*rij_shift
15404 fac=fac+evdwij*(sss_ele_grad/sss_ele_cut&
15405 *rij+sss_grad/sss*rij &
15406 /sigmaii(itypi,itypj))
15409 ! Calculate the radial part of the gradient
15413 ! Calculate angular part of the gradient.
15414 call sc_grad_scale(sss)
15420 ! write (iout,*) "Number of loop steps in EGB:",ind
15421 !ccc energy_dec=.false.
15423 end subroutine egb_short
15424 !-----------------------------------------------------------------------------
15425 subroutine egbv_long(evdw)
15427 ! This subroutine calculates the interaction energy of nonbonded side chains
15428 ! assuming the Gay-Berne-Vorobjev potential of interaction.
15431 ! implicit real(kind=8) (a-h,o-z)
15432 ! include 'DIMENSIONS'
15433 ! include 'COMMON.GEO'
15434 ! include 'COMMON.VAR'
15435 ! include 'COMMON.LOCAL'
15436 ! include 'COMMON.CHAIN'
15437 ! include 'COMMON.DERIV'
15438 ! include 'COMMON.NAMES'
15439 ! include 'COMMON.INTERACT'
15440 ! include 'COMMON.IOUNITS'
15441 ! include 'COMMON.CALC'
15443 !el integer :: icall
15444 !el common /srutu/ icall
15446 !el local variables
15447 integer :: iint,itypi,itypi1,itypj
15448 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,r0ij,sig,sig0ij,&
15449 sslipi,ssgradlipi,sslipj,ssgradlipj,aa,bb
15450 real(kind=8) :: sss,e1,e2,evdw,fac_augm,e_augm,rij_shift
15452 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
15455 ! if (icall.eq.0) lprn=.true.
15457 do i=iatsc_s,iatsc_e
15459 if (itypi.eq.ntyp1) cycle
15460 itypi1=itype(i+1,1)
15464 call to_box(xi,yi,zi)
15465 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
15466 dxi=dc_norm(1,nres+i)
15467 dyi=dc_norm(2,nres+i)
15468 dzi=dc_norm(3,nres+i)
15470 ! dsci_inv=dsc_inv(itypi)
15471 dsci_inv=vbld_inv(i+nres)
15473 ! Calculate SC interaction energy.
15475 do iint=1,nint_gr(i)
15476 do j=istart(i,iint),iend(i,iint)
15479 if (itypj.eq.ntyp1) cycle
15480 ! dscj_inv=dsc_inv(itypj)
15481 dscj_inv=vbld_inv(j+nres)
15482 sig0ij=sigma(itypi,itypj)
15483 r0ij=r0(itypi,itypj)
15484 chi1=chi(itypi,itypj)
15485 chi2=chi(itypj,itypi)
15492 alf12=0.5D0*(alf1+alf2)
15496 call to_box(xj,yj,zj)
15497 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
15498 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
15499 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
15500 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
15501 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
15502 xj=boxshift(xj-xi,boxxsize)
15503 yj=boxshift(yj-yi,boxysize)
15504 zj=boxshift(zj-zi,boxzsize)
15505 dxj=dc_norm(1,nres+j)
15506 dyj=dc_norm(2,nres+j)
15507 dzj=dc_norm(3,nres+j)
15508 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
15511 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
15513 if (sss.lt.1.0d0) then
15515 ! Calculate angle-dependent terms of energy and contributions to their
15519 sig=sig0ij*dsqrt(sigsq)
15520 rij_shift=1.0D0/rij-sig+r0ij
15521 ! I hate to put IF's in the loops, but here don't have another choice!!!!
15522 if (rij_shift.le.0.0D0) then
15527 !---------------------------------------------------------------
15528 rij_shift=1.0D0/rij_shift
15529 fac=rij_shift**expon
15530 e1=fac*fac*aa_aq(itypi,itypj)
15531 e2=fac*bb_aq(itypi,itypj)
15532 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
15533 eps2der=evdwij*eps3rt
15534 eps3der=evdwij*eps2rt
15535 fac_augm=rrij**expon
15536 e_augm=augm(itypi,itypj)*fac_augm
15537 evdwij=evdwij*eps2rt*eps3rt
15538 evdw=evdw+(evdwij+e_augm)*(1.0d0-sss)
15540 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
15541 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
15542 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
15543 restyp(itypi,1),i,restyp(itypj,1),j,&
15544 epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),&
15545 chi1,chi2,chip1,chip2,&
15546 eps1,eps2rt**2,eps3rt**2,&
15547 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
15550 ! Calculate gradient components.
15551 e1=e1*eps1*eps2rt**2*eps3rt**2
15552 fac=-expon*(e1+evdwij)*rij_shift
15554 fac=rij*fac-2*expon*rrij*e_augm
15555 ! Calculate the radial part of the gradient
15559 ! Calculate angular part of the gradient.
15560 call sc_grad_scale(1.0d0-sss)
15565 end subroutine egbv_long
15566 !-----------------------------------------------------------------------------
15567 subroutine egbv_short(evdw)
15569 ! This subroutine calculates the interaction energy of nonbonded side chains
15570 ! assuming the Gay-Berne-Vorobjev potential of interaction.
15573 ! implicit real(kind=8) (a-h,o-z)
15574 ! include 'DIMENSIONS'
15575 ! include 'COMMON.GEO'
15576 ! include 'COMMON.VAR'
15577 ! include 'COMMON.LOCAL'
15578 ! include 'COMMON.CHAIN'
15579 ! include 'COMMON.DERIV'
15580 ! include 'COMMON.NAMES'
15581 ! include 'COMMON.INTERACT'
15582 ! include 'COMMON.IOUNITS'
15583 ! include 'COMMON.CALC'
15585 !el integer :: icall
15586 !el common /srutu/ icall
15588 !el local variables
15589 integer :: iint,itypi,itypi1,itypj
15590 real(kind=8) :: rrij,xi,yi,zi,fac,sigm,epsi,rij_shift,&
15591 sslipi,ssgradlipi, sslipj,ssgradlipj,aa,bb
15592 real(kind=8) :: sss,e1,e2,evdw,r0ij,sig,sig0ij,fac_augm,e_augm
15594 ! print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
15597 ! if (icall.eq.0) lprn=.true.
15599 do i=iatsc_s,iatsc_e
15601 if (itypi.eq.ntyp1) cycle
15602 itypi1=itype(i+1,1)
15606 dxi=dc_norm(1,nres+i)
15607 dyi=dc_norm(2,nres+i)
15608 dzi=dc_norm(3,nres+i)
15609 call to_box(xi,yi,zi)
15610 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
15611 ! dsci_inv=dsc_inv(itypi)
15612 dsci_inv=vbld_inv(i+nres)
15614 ! Calculate SC interaction energy.
15616 do iint=1,nint_gr(i)
15617 do j=istart(i,iint),iend(i,iint)
15620 if (itypj.eq.ntyp1) cycle
15621 ! dscj_inv=dsc_inv(itypj)
15622 dscj_inv=vbld_inv(j+nres)
15623 sig0ij=sigma(itypi,itypj)
15624 r0ij=r0(itypi,itypj)
15625 chi1=chi(itypi,itypj)
15626 chi2=chi(itypj,itypi)
15633 alf12=0.5D0*(alf1+alf2)
15637 call to_box(xj,yj,zj)
15638 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
15639 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
15640 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
15641 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
15642 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
15643 xj=boxshift(xj-xi,boxxsize)
15644 yj=boxshift(yj-yi,boxysize)
15645 zj=boxshift(zj-zi,boxzsize)
15646 dxj=dc_norm(1,nres+j)
15647 dyj=dc_norm(2,nres+j)
15648 dzj=dc_norm(3,nres+j)
15649 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
15652 sss=sscale(1.0d0/(rij*sigmaii(itypi,itypj)))
15654 if (sss.gt.0.0d0) then
15656 ! Calculate angle-dependent terms of energy and contributions to their
15660 sig=sig0ij*dsqrt(sigsq)
15661 rij_shift=1.0D0/rij-sig+r0ij
15662 ! I hate to put IF's in the loops, but here don't have another choice!!!!
15663 if (rij_shift.le.0.0D0) then
15668 !---------------------------------------------------------------
15669 rij_shift=1.0D0/rij_shift
15670 fac=rij_shift**expon
15671 e1=fac*fac*aa_aq(itypi,itypj)
15672 e2=fac*bb_aq(itypi,itypj)
15673 evdwij=eps1*eps2rt*eps3rt*(e1+e2)
15674 eps2der=evdwij*eps3rt
15675 eps3der=evdwij*eps2rt
15676 fac_augm=rrij**expon
15677 e_augm=augm(itypi,itypj)*fac_augm
15678 evdwij=evdwij*eps2rt*eps3rt
15679 evdw=evdw+(evdwij+e_augm)*sss
15681 sigm=dabs(aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
15682 epsi=bb_aq(itypi,itypj)**2/aa_aq(itypi,itypj)
15683 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
15684 restyp(itypi,1),i,restyp(itypj,1),j,&
15685 epsi,sigm,sig,(augm(itypi,itypj)/epsi)**(1.0D0/12.0D0),&
15686 chi1,chi2,chip1,chip2,&
15687 eps1,eps2rt**2,eps3rt**2,&
15688 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
15691 ! Calculate gradient components.
15692 e1=e1*eps1*eps2rt**2*eps3rt**2
15693 fac=-expon*(e1+evdwij)*rij_shift
15695 fac=rij*fac-2*expon*rrij*e_augm
15696 ! Calculate the radial part of the gradient
15700 ! Calculate angular part of the gradient.
15701 call sc_grad_scale(sss)
15706 end subroutine egbv_short
15707 !-----------------------------------------------------------------------------
15708 subroutine eelec_scale(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
15710 ! This subroutine calculates the average interaction energy and its gradient
15711 ! in the virtual-bond vectors between non-adjacent peptide groups, based on
15712 ! the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
15713 ! The potential depends both on the distance of peptide-group centers and on
15714 ! the orientation of the CA-CA virtual bonds.
15716 ! implicit real(kind=8) (a-h,o-z)
15722 ! include 'DIMENSIONS'
15723 ! include 'COMMON.CONTROL'
15724 ! include 'COMMON.SETUP'
15725 ! include 'COMMON.IOUNITS'
15726 ! include 'COMMON.GEO'
15727 ! include 'COMMON.VAR'
15728 ! include 'COMMON.LOCAL'
15729 ! include 'COMMON.CHAIN'
15730 ! include 'COMMON.DERIV'
15731 ! include 'COMMON.INTERACT'
15732 ! include 'COMMON.CONTACTS'
15733 ! include 'COMMON.TORSION'
15734 ! include 'COMMON.VECTORS'
15735 ! include 'COMMON.FFIELD'
15736 ! include 'COMMON.TIME1'
15737 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg
15738 real(kind=8),dimension(3,3) ::erder,uryg,urzg,vryg,vrzg
15739 real(kind=8),dimension(2,2) :: acipa !el,a_temp
15740 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
15741 real(kind=8),dimension(4) :: muij
15742 !el integer :: num_conti,j1,j2
15743 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
15744 !el dz_normi,xmedi,ymedi,zmedi
15745 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
15746 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
15747 !el num_conti,j1,j2
15748 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
15750 real(kind=8) :: scal_el=1.0d0
15752 real(kind=8) :: scal_el=0.5d0
15755 ! 13-go grudnia roku pamietnego...
15756 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
15757 0.0d0,1.0d0,0.0d0,&
15758 0.0d0,0.0d0,1.0d0/),shape(unmat))
15759 !el local variables
15761 real(kind=8) :: fac
15762 real(kind=8) :: dxj,dyj,dzj
15763 real(kind=8) :: ees,evdw1,eel_loc,eello_turn3,eello_turn4
15765 ! allocate(num_cont_hb(nres)) !(maxres)
15766 !d write(iout,*) 'In EELEC'
15768 !d write(iout,*) 'Type',i
15769 !d write(iout,*) 'B1',B1(:,i)
15770 !d write(iout,*) 'B2',B2(:,i)
15771 !d write(iout,*) 'CC',CC(:,:,i)
15772 !d write(iout,*) 'DD',DD(:,:,i)
15773 !d write(iout,*) 'EE',EE(:,:,i)
15775 !d call check_vecgrad
15777 if (icheckgrad.eq.1) then
15779 fac=1.0d0/dsqrt(scalar(dc(1,i),dc(1,i)))
15781 dc_norm(k,i)=dc(k,i)*fac
15783 ! write (iout,*) 'i',i,' fac',fac
15786 if (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
15787 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 .or. &
15788 wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) then
15789 ! call vec_and_deriv
15793 ! print *, "before set matrices"
15795 ! print *,"after set martices"
15797 time_mat=time_mat+MPI_Wtime()-time01
15801 !d write (iout,*) 'i=',i
15803 !d write (iout,'(i5,2f10.5)') k,uy(k,i),uz(k,i)
15806 !d write (iout,'(f10.5,2x,3f10.5,2x,3f10.5)')
15807 !d & uz(k,i),(uzgrad(k,l,1,i),l=1,3),(uzgrad(k,l,2,i),l=1,3)
15820 !d print '(a)','Enter EELEC'
15821 !d write (iout,*) 'iatel_s=',iatel_s,' iatel_e=',iatel_e
15822 ! if (.not.allocated(gel_loc_loc)) allocate(gel_loc_loc(nres)) !(maxvar)(maxvar=6*maxres)
15823 ! if (.not.allocated(gcorr_loc)) allocate(gcorr_loc(nres)) !(maxvar)(maxvar=6*maxres)
15825 gel_loc_loc(i)=0.0d0
15830 ! 9/27/08 AL Split the interaction loop to ensure load balancing of turn terms
15832 ! Loop over i,i+2 and i,i+3 pairs of the peptide groups
15834 do i=iturn3_start,iturn3_end
15835 if (itype(i,1).eq.ntyp1.or. itype(i+1,1).eq.ntyp1 &
15836 .or. itype(i+2,1).eq.ntyp1 .or. itype(i+3,1).eq.ntyp1) cycle
15840 dx_normi=dc_norm(1,i)
15841 dy_normi=dc_norm(2,i)
15842 dz_normi=dc_norm(3,i)
15843 xmedi=c(1,i)+0.5d0*dxi
15844 ymedi=c(2,i)+0.5d0*dyi
15845 zmedi=c(3,i)+0.5d0*dzi
15846 call to_box(xmedi,ymedi,zmedi)
15847 call lipid_layer(xmedi,ymedi,zmedi,sslipi,ssgradlipi)
15849 call eelecij_scale(i,i+2,ees,evdw1,eel_loc)
15850 if (wturn3.gt.0.0d0) call eturn3(i,eello_turn3)
15851 num_cont_hb(i)=num_conti
15853 do i=iturn4_start,iturn4_end
15854 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1 &
15855 .or. itype(i+3,1).eq.ntyp1 &
15856 .or. itype(i+4,1).eq.ntyp1) cycle
15860 dx_normi=dc_norm(1,i)
15861 dy_normi=dc_norm(2,i)
15862 dz_normi=dc_norm(3,i)
15863 xmedi=c(1,i)+0.5d0*dxi
15864 ymedi=c(2,i)+0.5d0*dyi
15865 zmedi=c(3,i)+0.5d0*dzi
15867 call to_box(xmedi,ymedi,zmedi)
15868 call lipid_layer(xmedi,ymedi,zmedi,sslipi,ssgradlipi)
15870 num_conti=num_cont_hb(i)
15871 call eelecij_scale(i,i+3,ees,evdw1,eel_loc)
15872 if (wturn4.gt.0.0d0 .and. itype(i+2,1).ne.ntyp1) &
15873 call eturn4(i,eello_turn4)
15874 num_cont_hb(i)=num_conti
15877 ! Loop over all pairs of interacting peptide groups except i,i+2 and i,i+3
15879 do i=iatel_s,iatel_e
15880 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
15884 dx_normi=dc_norm(1,i)
15885 dy_normi=dc_norm(2,i)
15886 dz_normi=dc_norm(3,i)
15887 xmedi=c(1,i)+0.5d0*dxi
15888 ymedi=c(2,i)+0.5d0*dyi
15889 zmedi=c(3,i)+0.5d0*dzi
15890 call to_box(xmedi,ymedi,zmedi)
15891 call lipid_layer(xmedi,ymedi,zmedi,sslipi,ssgradlipi)
15892 ! write (iout,*) 'i',i,' ielstart',ielstart(i),' ielend',ielend(i)
15893 num_conti=num_cont_hb(i)
15894 do j=ielstart(i),ielend(i)
15895 if (itype(j,1).eq.ntyp1 .or. itype(j+1,1).eq.ntyp1) cycle
15896 call eelecij_scale(i,j,ees,evdw1,eel_loc)
15898 num_cont_hb(i)=num_conti
15900 ! write (iout,*) "Number of loop steps in EELEC:",ind
15902 !d write (iout,'(i3,3f10.5,5x,3f10.5)')
15903 !d & i,(gel_loc(k,i),k=1,3),gel_loc_loc(i)
15905 ! 12/7/99 Adam eello_turn3 will be considered as a separate energy term
15906 !cc eel_loc=eel_loc+eello_turn3
15907 !d print *,"Processor",fg_rank," t_eelecij",t_eelecij
15909 end subroutine eelec_scale
15910 !-----------------------------------------------------------------------------
15911 subroutine eelecij_scale(i,j,ees,evdw1,eel_loc)
15912 ! implicit real(kind=8) (a-h,o-z)
15915 ! include 'DIMENSIONS'
15919 ! include 'COMMON.CONTROL'
15920 ! include 'COMMON.IOUNITS'
15921 ! include 'COMMON.GEO'
15922 ! include 'COMMON.VAR'
15923 ! include 'COMMON.LOCAL'
15924 ! include 'COMMON.CHAIN'
15925 ! include 'COMMON.DERIV'
15926 ! include 'COMMON.INTERACT'
15927 ! include 'COMMON.CONTACTS'
15928 ! include 'COMMON.TORSION'
15929 ! include 'COMMON.VECTORS'
15930 ! include 'COMMON.FFIELD'
15931 ! include 'COMMON.TIME1'
15932 real(kind=8),dimension(3) :: ggg,gggp,gggm,erij,dcosb,dcosg,xtemp
15933 real(kind=8),dimension(3,3) :: erder,uryg,urzg,vryg,vrzg
15934 real(kind=8),dimension(2,2) :: acipa !el,a_temp
15935 !el real(kind=8),dimension(3,4) :: agg,aggi,aggi1,aggj,aggj1
15936 real(kind=8),dimension(4) :: muij
15937 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
15938 dist_temp, dist_init,sss_grad
15939 integer xshift,yshift,zshift
15941 !el integer :: num_conti,j1,j2
15942 !el real(kind=8) :: a22,a23,a32,a33,dxi,dyi,dzi,dx_normi,dy_normi,&
15943 !el dz_normi,xmedi,ymedi,zmedi
15944 !el common /locel/ a_temp,agg,aggi,aggi1,aggj,aggj1,a22,a23,a32,a33,&
15945 !el dxi,dyi,dzi,dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
15946 !el num_conti,j1,j2
15947 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
15949 real(kind=8) :: scal_el=1.0d0
15951 real(kind=8) :: scal_el=0.5d0
15954 ! 13-go grudnia roku pamietnego...
15955 real(kind=8),dimension(3,3) :: unmat=reshape((/1.0d0,0.0d0,0.0d0,&
15956 0.0d0,1.0d0,0.0d0,&
15957 0.0d0,0.0d0,1.0d0/),shape(unmat))
15958 !el local variables
15959 integer :: i,j,k,l,iteli,itelj,kkk,kkll,m,isubchap
15960 real(kind=8) :: aaa,bbb,ael6i,ael3i,dxj,dyj,dzj
15961 real(kind=8) :: xj,yj,zj,rij,rrmij,rmij,sss,r3ij,r6ij,fac
15962 real(kind=8) :: cosa,cosb,cosg,ev1,ev2,fac3,fac4,evdwij
15963 real(kind=8) :: el1,el2,eesij,ees0ij,r0ij,fcont,fprimcont
15964 real(kind=8) :: ees0tmp,ees0pij1,ees0mij1,ees0pijp,ees0mijp
15965 real(kind=8) :: ees,evdw1,eel_loc,eel_loc_ij,dx_normj,dy_normj,&
15966 dz_normj,facvdw,facel,fac1,facr,ecosa,ecosb,ecosg,&
15967 ury,urz,vry,vrz,a22der,a23der,a32der,a33der,cosa4,&
15968 wij,cosbg1,cosbg2,ees0pij,ees0mij,fac3p,ecosa1,ecosb1,&
15969 ecosg1,ecosa2,ecosb2,ecosg2,ecosap,ecosbp,ecosgp,&
15970 ecosam,ecosbm,ecosgm,ghalf,time00,faclipij,faclipij2
15971 ! integer :: maxconts
15972 ! maxconts = nres/4
15973 ! allocate(gacontp_hb1(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
15974 ! allocate(gacontp_hb2(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
15975 ! allocate(gacontp_hb3(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
15976 ! allocate(gacontm_hb1(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
15977 ! allocate(gacontm_hb2(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
15978 ! allocate(gacontm_hb3(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
15979 ! allocate(gacont_hbr(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
15980 ! allocate(grij_hb_cont(3,maxconts,nres)) !(3,maxconts,maxres) ! (maxconts=maxres/4)
15981 ! allocate(facont_hb(maxconts,nres)) !(maxconts,maxres)
15982 ! allocate(ees0p(maxconts,nres)) !(maxconts,maxres)
15983 ! allocate(ees0m(maxconts,nres)) !(maxconts,maxres)
15984 ! allocate(d_cont(maxconts,nres)) !(maxconts,maxres)
15985 ! allocate(jcont_hb(maxconts,nres)) !(maxconts,maxres)
15987 ! allocate(a_chuj(2,2,maxconts,nres)) !(2,2,maxconts,maxres)
15988 ! allocate(a_chuj_der(2,2,3,5,maxconts,nres)) !(2,2,3,5,maxconts,maxres)
15993 !d write (iout,*) "eelecij",i,j
15997 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
15998 aaa=app(iteli,itelj)
15999 bbb=bpp(iteli,itelj)
16000 ael6i=ael6(iteli,itelj)
16001 ael3i=ael3(iteli,itelj)
16005 dx_normj=dc_norm(1,j)
16006 dy_normj=dc_norm(2,j)
16007 dz_normj=dc_norm(3,j)
16008 ! xj=c(1,j)+0.5D0*dxj-xmedi
16009 ! yj=c(2,j)+0.5D0*dyj-ymedi
16010 ! zj=c(3,j)+0.5D0*dzj-zmedi
16011 xj=c(1,j)+0.5D0*dxj
16012 yj=c(2,j)+0.5D0*dyj
16013 zj=c(3,j)+0.5D0*dzj
16014 call to_box(xj,yj,zj)
16015 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
16016 faclipij=(sslipi+sslipj)/2.0d0*lipscale+1.0d0
16017 faclipij2=(sslipi+sslipj)/2.0d0*lipscale**2+1.0d0
16018 xj=boxshift(xj-xmedi,boxxsize)
16019 yj=boxshift(yj-ymedi,boxysize)
16020 zj=boxshift(zj-zmedi,boxzsize)
16021 rij=xj*xj+yj*yj+zj*zj
16025 ! For extracting the short-range part of Evdwpp
16026 sss=sscale(rij/rpp(iteli,itelj))
16027 sss_ele_cut=sscale_ele(rij)
16028 sss_ele_grad=sscagrad_ele(rij)
16029 sss_grad=sscale_grad((rij/rpp(iteli,itelj)))
16030 ! sss_ele_cut=1.0d0
16031 ! sss_ele_grad=0.0d0
16032 if (sss_ele_cut.le.0.0) go to 128
16036 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
16037 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
16038 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
16039 fac=cosa-3.0D0*cosb*cosg
16041 ! 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
16042 if (j.eq.i+2) ev1=scal_el*ev1
16047 el1=fac3*(4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg))
16050 ! 12/26/95 - for the evaluation of multi-body H-bonding interactions
16051 ees0ij=4.0D0+fac*fac-3.0D0*(cosb*cosb+cosg*cosg)
16052 ees=ees+eesij*sss_ele_cut
16053 evdw1=evdw1+evdwij*(1.0d0-sss)*sss_ele_cut
16054 !d write(iout,'(2(2i3,2x),7(1pd12.4)/2(3(1pd12.4),5x)/)')
16055 !d & iteli,i,itelj,j,aaa,bbb,ael6i,ael3i,
16056 !d & 1.0D0/dsqrt(rrmij),evdwij,eesij,
16057 !d & xmedi,ymedi,zmedi,xj,yj,zj
16059 if (energy_dec) then
16060 write (iout,'(a6,2i5,0pf7.3,f7.3)') 'evdw1',i,j,evdwij,sss
16061 write (iout,'(a6,2i5,0pf7.3)') 'ees',i,j,eesij
16065 ! Calculate contributions to the Cartesian gradient.
16068 facvdw=-6*rrmij*(ev1+evdwij)*(1.0d0-sss)*sss_ele_cut
16069 facel=-3*rrmij*(el1+eesij)*sss_ele_cut
16075 ! Radial derivatives. First process both termini of the fragment (i,j)
16077 ggg(1)=facel*xj+sss_ele_grad*rmij*eesij*xj
16078 ggg(2)=facel*yj+sss_ele_grad*rmij*eesij*yj
16079 ggg(3)=facel*zj+sss_ele_grad*rmij*eesij*zj
16081 ! ghalf=0.5D0*ggg(k)
16082 ! gelc(k,i)=gelc(k,i)+ghalf
16083 ! gelc(k,j)=gelc(k,j)+ghalf
16085 ! 9/28/08 AL Gradient compotents will be summed only at the end
16087 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
16088 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
16091 ! Loop over residues i+1 thru j-1.
16095 !grad gelc(l,k)=gelc(l,k)+ggg(l)
16098 ggg(1)=facvdw*xj+sss_ele_grad*rmij*evdwij*xj*(1.0d0-sss) &
16099 -evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*xj
16100 ggg(2)=facvdw*yj+sss_ele_grad*rmij*evdwij*yj*(1.0d0-sss) &
16101 -evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*yj
16102 ggg(3)=facvdw*zj+sss_ele_grad*rmij*evdwij*zj*(1.0d0-sss) &
16103 -evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*zj
16105 ! ghalf=0.5D0*ggg(k)
16106 ! gvdwpp(k,i)=gvdwpp(k,i)+ghalf
16107 ! gvdwpp(k,j)=gvdwpp(k,j)+ghalf
16109 ! 9/28/08 AL Gradient compotents will be summed only at the end
16111 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
16112 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
16115 ! Loop over residues i+1 thru j-1.
16119 !grad gvdwpp(l,k)=gvdwpp(l,k)+ggg(l)
16123 facvdw=(ev1+evdwij)*(1.0d0-sss)*sss_ele_cut
16124 facel=(el1+eesij)*sss_ele_cut
16126 fac=-3*rrmij*(facvdw+facvdw+facel)
16131 ! Radial derivatives. First process both termini of the fragment (i,j)
16137 ! ghalf=0.5D0*ggg(k)
16138 ! gelc(k,i)=gelc(k,i)+ghalf
16139 ! gelc(k,j)=gelc(k,j)+ghalf
16141 ! 9/28/08 AL Gradient compotents will be summed only at the end
16143 gelc_long(k,j)=gelc(k,j)+ggg(k)
16144 gelc_long(k,i)=gelc(k,i)-ggg(k)
16147 ! Loop over residues i+1 thru j-1.
16151 !grad gelc(l,k)=gelc(l,k)+ggg(l)
16154 ! 9/28/08 AL Gradient compotents will be summed only at the end
16159 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
16160 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
16166 ecosa=2.0D0*fac3*fac1+fac4
16169 ecosb=(fac3*(fac1*cosg+cosb)+cosg*fac4)
16170 ecosg=(fac3*(fac1*cosb+cosg)+cosb*fac4)
16172 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
16173 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
16175 !d print '(2i3,2(3(1pd14.5),3x))',i,j,(dcosb(k),k=1,3),
16176 !d & (dcosg(k),k=1,3)
16178 ggg(k)=(ecosb*dcosb(k)+ecosg*dcosg(k) )*sss_ele_cut
16181 ! ghalf=0.5D0*ggg(k)
16182 ! gelc(k,i)=gelc(k,i)+ghalf
16183 ! & +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i))
16184 ! & + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
16185 ! gelc(k,j)=gelc(k,j)+ghalf
16186 ! & +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j))
16187 ! & + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
16191 !grad gelc(l,k)=gelc(l,k)+ggg(l)
16195 gelc(k,i)=gelc(k,i) &
16196 +(ecosa*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
16197 + ecosb*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)&
16199 gelc(k,j)=gelc(k,j) &
16200 +(ecosa*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
16201 + ecosg*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
16203 gelc_long(k,j)=gelc_long(k,j)+ggg(k)
16204 gelc_long(k,i)=gelc_long(k,i)-ggg(k)
16206 IF (wel_loc.gt.0.0d0 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 &
16207 .or. wcorr6.gt.0.0d0 .or. wturn3.gt.0.0d0 &
16208 .or. wturn4.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
16210 ! 9/25/99 Mixed third-order local-electrostatic terms. The local-interaction
16211 ! energy of a peptide unit is assumed in the form of a second-order
16212 ! Fourier series in the angles lambda1 and lambda2 (see Nishikawa et al.
16213 ! Macromolecules, 1974, 7, 797-806 for definition). This correlation terms
16214 ! are computed for EVERY pair of non-contiguous peptide groups.
16216 if (j.lt.nres-1) then
16227 muij(kkk)=mu(k,i)*mu(l,j)
16230 !d write (iout,*) 'EELEC: i',i,' j',j
16231 !d write (iout,*) 'j',j,' j1',j1,' j2',j2
16232 !d write(iout,*) 'muij',muij
16233 ury=scalar(uy(1,i),erij)
16234 urz=scalar(uz(1,i),erij)
16235 vry=scalar(uy(1,j),erij)
16236 vrz=scalar(uz(1,j),erij)
16237 a22=scalar(uy(1,i),uy(1,j))-3*ury*vry
16238 a23=scalar(uy(1,i),uz(1,j))-3*ury*vrz
16239 a32=scalar(uz(1,i),uy(1,j))-3*urz*vry
16240 a33=scalar(uz(1,i),uz(1,j))-3*urz*vrz
16241 fac=dsqrt(-ael6i)*r3ij
16246 !d write (iout,'(4i5,4f10.5)')
16247 !d & i,itortyp(itype(i,1)),j,itortyp(itype(j,1)),a22,a23,a32,a33
16248 !d write (iout,'(6f10.5)') (muij(k),k=1,4),fac,eel_loc_ij
16249 !d write (iout,'(2(3f10.5,5x)/2(3f10.5,5x))') uy(:,i),uz(:,i),
16250 !d & uy(:,j),uz(:,j)
16251 !d write (iout,'(4f10.5)')
16252 !d & scalar(uy(1,i),uy(1,j)),scalar(uy(1,i),uz(1,j)),
16253 !d & scalar(uz(1,i),uy(1,j)),scalar(uz(1,i),uz(1,j))
16254 !d write (iout,'(4f10.5)') ury,urz,vry,vrz
16255 !d write (iout,'(9f10.5/)')
16256 !d & fac22,a22,fac23,a23,fac32,a32,fac33,a33,eel_loc_ij
16257 ! Derivatives of the elements of A in virtual-bond vectors
16258 call unormderiv(erij(1),unmat(1,1),rmij,erder(1,1))
16260 uryg(k,1)=scalar(erder(1,k),uy(1,i))
16261 uryg(k,2)=scalar(uygrad(1,k,1,i),erij(1))
16262 uryg(k,3)=scalar(uygrad(1,k,2,i),erij(1))
16263 urzg(k,1)=scalar(erder(1,k),uz(1,i))
16264 urzg(k,2)=scalar(uzgrad(1,k,1,i),erij(1))
16265 urzg(k,3)=scalar(uzgrad(1,k,2,i),erij(1))
16266 vryg(k,1)=scalar(erder(1,k),uy(1,j))
16267 vryg(k,2)=scalar(uygrad(1,k,1,j),erij(1))
16268 vryg(k,3)=scalar(uygrad(1,k,2,j),erij(1))
16269 vrzg(k,1)=scalar(erder(1,k),uz(1,j))
16270 vrzg(k,2)=scalar(uzgrad(1,k,1,j),erij(1))
16271 vrzg(k,3)=scalar(uzgrad(1,k,2,j),erij(1))
16273 ! Compute radial contributions to the gradient
16291 ! Add the contributions coming from er
16294 agg(k,1)=agg(k,1)+fac3*(uryg(k,1)*vry+vryg(k,1)*ury)
16295 agg(k,2)=agg(k,2)+fac3*(uryg(k,1)*vrz+vrzg(k,1)*ury)
16296 agg(k,3)=agg(k,3)+fac3*(urzg(k,1)*vry+vryg(k,1)*urz)
16297 agg(k,4)=agg(k,4)+fac3*(urzg(k,1)*vrz+vrzg(k,1)*urz)
16300 ! Derivatives in DC(i)
16301 !grad ghalf1=0.5d0*agg(k,1)
16302 !grad ghalf2=0.5d0*agg(k,2)
16303 !grad ghalf3=0.5d0*agg(k,3)
16304 !grad ghalf4=0.5d0*agg(k,4)
16305 aggi(k,1)=fac*(scalar(uygrad(1,k,1,i),uy(1,j)) &
16306 -3.0d0*uryg(k,2)*vry)!+ghalf1
16307 aggi(k,2)=fac*(scalar(uygrad(1,k,1,i),uz(1,j)) &
16308 -3.0d0*uryg(k,2)*vrz)!+ghalf2
16309 aggi(k,3)=fac*(scalar(uzgrad(1,k,1,i),uy(1,j)) &
16310 -3.0d0*urzg(k,2)*vry)!+ghalf3
16311 aggi(k,4)=fac*(scalar(uzgrad(1,k,1,i),uz(1,j)) &
16312 -3.0d0*urzg(k,2)*vrz)!+ghalf4
16313 ! Derivatives in DC(i+1)
16314 aggi1(k,1)=fac*(scalar(uygrad(1,k,2,i),uy(1,j)) &
16315 -3.0d0*uryg(k,3)*vry)!+agg(k,1)
16316 aggi1(k,2)=fac*(scalar(uygrad(1,k,2,i),uz(1,j)) &
16317 -3.0d0*uryg(k,3)*vrz)!+agg(k,2)
16318 aggi1(k,3)=fac*(scalar(uzgrad(1,k,2,i),uy(1,j)) &
16319 -3.0d0*urzg(k,3)*vry)!+agg(k,3)
16320 aggi1(k,4)=fac*(scalar(uzgrad(1,k,2,i),uz(1,j)) &
16321 -3.0d0*urzg(k,3)*vrz)!+agg(k,4)
16322 ! Derivatives in DC(j)
16323 aggj(k,1)=fac*(scalar(uygrad(1,k,1,j),uy(1,i)) &
16324 -3.0d0*vryg(k,2)*ury)!+ghalf1
16325 aggj(k,2)=fac*(scalar(uzgrad(1,k,1,j),uy(1,i)) &
16326 -3.0d0*vrzg(k,2)*ury)!+ghalf2
16327 aggj(k,3)=fac*(scalar(uygrad(1,k,1,j),uz(1,i)) &
16328 -3.0d0*vryg(k,2)*urz)!+ghalf3
16329 aggj(k,4)=fac*(scalar(uzgrad(1,k,1,j),uz(1,i)) &
16330 -3.0d0*vrzg(k,2)*urz)!+ghalf4
16331 ! Derivatives in DC(j+1) or DC(nres-1)
16332 aggj1(k,1)=fac*(scalar(uygrad(1,k,2,j),uy(1,i)) &
16333 -3.0d0*vryg(k,3)*ury)
16334 aggj1(k,2)=fac*(scalar(uzgrad(1,k,2,j),uy(1,i)) &
16335 -3.0d0*vrzg(k,3)*ury)
16336 aggj1(k,3)=fac*(scalar(uygrad(1,k,2,j),uz(1,i)) &
16337 -3.0d0*vryg(k,3)*urz)
16338 aggj1(k,4)=fac*(scalar(uzgrad(1,k,2,j),uz(1,i)) &
16339 -3.0d0*vrzg(k,3)*urz)
16340 !grad if (j.eq.nres-1 .and. i.lt.j-2) then
16342 !grad aggj1(k,l)=aggj1(k,l)+agg(k,l)
16355 aggi(k,l)=-aggi(k,l)
16356 aggi1(k,l)=-aggi1(k,l)
16357 aggj(k,l)=-aggj(k,l)
16358 aggj1(k,l)=-aggj1(k,l)
16361 if (j.lt.nres-1) then
16367 aggi(k,l)=-aggi(k,l)
16368 aggi1(k,l)=-aggi1(k,l)
16369 aggj(k,l)=-aggj(k,l)
16370 aggj1(k,l)=-aggj1(k,l)
16381 aggi(k,l)=-aggi(k,l)
16382 aggi1(k,l)=-aggi1(k,l)
16383 aggj(k,l)=-aggj(k,l)
16384 aggj1(k,l)=-aggj1(k,l)
16389 IF (wel_loc.gt.0.0d0) THEN
16390 ! Contribution to the local-electrostatic energy coming from the i-j pair
16391 eel_loc_ij=a22*muij(1)+a23*muij(2)+a32*muij(3) &
16393 ! write (iout,*) 'i',i,' j',j,' eel_loc_ij',eel_loc_ij
16394 ! print *,"EELLOC",i,gel_loc_loc(i-1)
16395 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
16396 'eelloc',i,j,eel_loc_ij
16397 ! write (iout,*) a22,muij(1),a23,muij(2),a32,muij(3) !d
16399 eel_loc=eel_loc+eel_loc_ij*sss_ele_cut
16400 ! Partial derivatives in virtual-bond dihedral angles gamma
16402 gel_loc_loc(i-1)=gel_loc_loc(i-1)+ &
16403 (a22*muder(1,i)*mu(1,j)+a23*muder(1,i)*mu(2,j) &
16404 +a32*muder(2,i)*mu(1,j)+a33*muder(2,i)*mu(2,j)) &
16406 gel_loc_loc(j-1)=gel_loc_loc(j-1)+ &
16407 (a22*mu(1,i)*muder(1,j)+a23*mu(1,i)*muder(2,j) &
16408 +a32*mu(2,i)*muder(1,j)+a33*mu(2,i)*muder(2,j)) &
16414 ! Derivatives of eello in DC(i+1) thru DC(j-1) or DC(nres-2)
16416 ggg(l)=(agg(l,1)*muij(1)+ &
16417 agg(l,2)*muij(2)+agg(l,3)*muij(3)+agg(l,4)*muij(4))&
16419 +eel_loc_ij*sss_ele_grad*rmij*xtemp(l)
16421 gel_loc_long(l,j)=gel_loc_long(l,j)+ggg(l)
16422 gel_loc_long(l,i)=gel_loc_long(l,i)-ggg(l)
16423 !grad ghalf=0.5d0*ggg(l)
16424 !grad gel_loc(l,i)=gel_loc(l,i)+ghalf
16425 !grad gel_loc(l,j)=gel_loc(l,j)+ghalf
16429 !grad gel_loc(l,k)=gel_loc(l,k)+ggg(l)
16432 ! Remaining derivatives of eello
16434 gel_loc(l,i)=gel_loc(l,i)+(aggi(l,1)*muij(1)+ &
16435 aggi(l,2)*muij(2)+aggi(l,3)*muij(3)+aggi(l,4)*muij(4))&
16438 gel_loc(l,i+1)=gel_loc(l,i+1)+(aggi1(l,1)*muij(1)+ &
16439 aggi1(l,2)*muij(2)+aggi1(l,3)*muij(3)+aggi1(l,4)*muij(4))&
16442 gel_loc(l,j)=gel_loc(l,j)+(aggj(l,1)*muij(1)+ &
16443 aggj(l,2)*muij(2)+aggj(l,3)*muij(3)+aggj(l,4)*muij(4))&
16446 gel_loc(l,j1)=gel_loc(l,j1)+(aggj1(l,1)*muij(1)+ &
16447 aggj1(l,2)*muij(2)+aggj1(l,3)*muij(3)+aggj1(l,4)*muij(4))&
16452 ! Change 12/26/95 to calculate four-body contributions to H-bonding energy
16453 ! if (j.gt.i+1 .and. num_conti.le.maxconts) then
16454 if (wcorr+wcorr4+wcorr5+wcorr6.gt.0.0d0 &
16455 .and. num_conti.le.maxconts) then
16456 ! write (iout,*) i,j," entered corr"
16458 ! Calculate the contact function. The ith column of the array JCONT will
16459 ! contain the numbers of atoms that make contacts with the atom I (of numbers
16460 ! greater than I). The arrays FACONT and GACONT will contain the values of
16461 ! the contact function and its derivative.
16462 ! r0ij=1.02D0*rpp(iteli,itelj)
16463 ! r0ij=1.11D0*rpp(iteli,itelj)
16464 r0ij=2.20D0*rpp(iteli,itelj)
16465 ! r0ij=1.55D0*rpp(iteli,itelj)
16466 call gcont(rij,r0ij,1.0D0,0.2d0*r0ij,fcont,fprimcont)
16467 !elwrite(iout,*) "num_conti",num_conti, "maxconts",maxconts
16468 if (fcont.gt.0.0D0) then
16469 num_conti=num_conti+1
16470 if (num_conti.gt.maxconts) then
16471 !elwrite(iout,*) "num_conti",num_conti, "maxconts",maxconts
16472 write (iout,*) 'WARNING - max. # of contacts exceeded;',&
16473 ' will skip next contacts for this conf.',num_conti
16475 jcont_hb(num_conti,i)=j
16476 !d write (iout,*) "i",i," j",j," num_conti",num_conti,
16477 !d & " jcont_hb",jcont_hb(num_conti,i)
16478 IF (wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. &
16479 wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0) THEN
16480 ! 9/30/99 (AL) - store components necessary to evaluate higher-order loc-el
16482 d_cont(num_conti,i)=rij
16483 !d write (2,'(3e15.5)') rij,r0ij+0.2d0*r0ij,rij
16484 ! --- Electrostatic-interaction matrix ---
16485 a_chuj(1,1,num_conti,i)=a22
16486 a_chuj(1,2,num_conti,i)=a23
16487 a_chuj(2,1,num_conti,i)=a32
16488 a_chuj(2,2,num_conti,i)=a33
16489 ! --- Gradient of rij
16491 grij_hb_cont(kkk,num_conti,i)=erij(kkk)
16498 a_chuj_der(k,l,m,1,num_conti,i)=agg(m,kkll)
16499 a_chuj_der(k,l,m,2,num_conti,i)=aggi(m,kkll)
16500 a_chuj_der(k,l,m,3,num_conti,i)=aggi1(m,kkll)
16501 a_chuj_der(k,l,m,4,num_conti,i)=aggj(m,kkll)
16502 a_chuj_der(k,l,m,5,num_conti,i)=aggj1(m,kkll)
16507 IF (wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) THEN
16508 ! Calculate contact energies
16510 wij=cosa-3.0D0*cosb*cosg
16513 ! fac3=dsqrt(-ael6i)/r0ij**3
16514 fac3=dsqrt(-ael6i)*r3ij
16515 ! ees0pij=dsqrt(4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1)
16516 ees0tmp=4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1
16517 if (ees0tmp.gt.0) then
16518 ees0pij=dsqrt(ees0tmp)
16522 ! ees0mij=dsqrt(4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2)
16523 ees0tmp=4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2
16524 if (ees0tmp.gt.0) then
16525 ees0mij=dsqrt(ees0tmp)
16530 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij) &
16533 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij) &
16536 ! Diagnostics. Comment out or remove after debugging!
16537 ! ees0p(num_conti,i)=0.5D0*fac3*ees0pij
16538 ! ees0m(num_conti,i)=0.5D0*fac3*ees0mij
16539 ! ees0m(num_conti,i)=0.0D0
16541 ! write (iout,*) 'i=',i,' j=',j,' rij=',rij,' r0ij=',r0ij,
16542 ! & ' ees0ij=',ees0p(num_conti,i),ees0m(num_conti,i),' fcont=',fcont
16543 ! Angular derivatives of the contact function
16544 ees0pij1=fac3/ees0pij
16545 ees0mij1=fac3/ees0mij
16546 fac3p=-3.0D0*fac3*rrmij
16547 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
16548 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
16550 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
16551 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
16552 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
16553 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
16554 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
16555 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
16556 ecosap=ecosa1+ecosa2
16557 ecosbp=ecosb1+ecosb2
16558 ecosgp=ecosg1+ecosg2
16559 ecosam=ecosa1-ecosa2
16560 ecosbm=ecosb1-ecosb2
16561 ecosgm=ecosg1-ecosg2
16570 facont_hb(num_conti,i)=fcont
16571 fprimcont=fprimcont/rij
16572 !d facont_hb(num_conti,i)=1.0D0
16573 ! Following line is for diagnostics.
16576 dcosb(k)=rmij*(dc_norm(k,i)-erij(k)*cosb)
16577 dcosg(k)=rmij*(dc_norm(k,j)-erij(k)*cosg)
16580 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
16581 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
16583 ! gggp(1)=gggp(1)+ees0pijp*xj
16584 ! gggp(2)=gggp(2)+ees0pijp*yj
16585 ! gggp(3)=gggp(3)+ees0pijp*zj
16586 ! gggm(1)=gggm(1)+ees0mijp*xj
16587 ! gggm(2)=gggm(2)+ees0mijp*yj
16588 ! gggm(3)=gggm(3)+ees0mijp*zj
16589 gggp(1)=gggp(1)+ees0pijp*xj &
16590 +ees0p(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
16591 gggp(2)=gggp(2)+ees0pijp*yj &
16592 +ees0p(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
16593 gggp(3)=gggp(3)+ees0pijp*zj &
16594 +ees0p(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
16596 gggm(1)=gggm(1)+ees0mijp*xj &
16597 +ees0m(num_conti,i)/sss_ele_cut*rmij*xj*sss_ele_grad
16599 gggm(2)=gggm(2)+ees0mijp*yj &
16600 +ees0m(num_conti,i)/sss_ele_cut*rmij*yj*sss_ele_grad
16602 gggm(3)=gggm(3)+ees0mijp*zj &
16603 +ees0m(num_conti,i)/sss_ele_cut*rmij*zj*sss_ele_grad
16605 ! Derivatives due to the contact function
16606 gacont_hbr(1,num_conti,i)=fprimcont*xj
16607 gacont_hbr(2,num_conti,i)=fprimcont*yj
16608 gacont_hbr(3,num_conti,i)=fprimcont*zj
16611 ! 10/24/08 cgrad and ! comments indicate the parts of the code removed
16612 ! following the change of gradient-summation algorithm.
16614 !grad ghalfp=0.5D0*gggp(k)
16615 !grad ghalfm=0.5D0*gggm(k)
16616 ! gacontp_hb1(k,num_conti,i)= & !ghalfp
16617 ! +(ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
16618 ! + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
16619 ! gacontp_hb2(k,num_conti,i)= & !ghalfp
16620 ! +(ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
16621 ! + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
16622 ! gacontp_hb3(k,num_conti,i)=gggp(k)
16623 ! gacontm_hb1(k,num_conti,i)= &!ghalfm
16624 ! +(ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
16625 ! + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1)
16626 ! gacontm_hb2(k,num_conti,i)= & !ghalfm
16627 ! +(ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
16628 ! + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)
16629 ! gacontm_hb3(k,num_conti,i)=gggm(k)
16630 gacontp_hb1(k,num_conti,i)= & !ghalfp+
16631 (ecosap*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
16632 + ecosbp*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
16635 gacontp_hb2(k,num_conti,i)= & !ghalfp+
16636 (ecosap*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
16637 + ecosgp*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1)&
16640 gacontp_hb3(k,num_conti,i)=gggp(k) &
16643 gacontm_hb1(k,num_conti,i)= & !ghalfm+
16644 (ecosam*(dc_norm(k,j)-cosa*dc_norm(k,i)) &
16645 + ecosbm*(erij(k)-cosb*dc_norm(k,i)))*vbld_inv(i+1) &
16648 gacontm_hb2(k,num_conti,i)= & !ghalfm+
16649 (ecosam*(dc_norm(k,i)-cosa*dc_norm(k,j)) &
16650 + ecosgm*(erij(k)-cosg*dc_norm(k,j)))*vbld_inv(j+1) &
16653 gacontm_hb3(k,num_conti,i)=gggm(k) &
16658 endif ! num_conti.le.maxconts
16661 if (wturn3.gt.0.0d0 .or. wturn4.gt.0.0d0) then
16664 ghalf=0.5d0*agg(l,k)
16665 aggi(l,k)=aggi(l,k)+ghalf
16666 aggi1(l,k)=aggi1(l,k)+agg(l,k)
16667 aggj(l,k)=aggj(l,k)+ghalf
16670 if (j.eq.nres-1 .and. i.lt.j-2) then
16673 aggj1(l,k)=aggj1(l,k)+agg(l,k)
16679 ! t_eelecij=t_eelecij+MPI_Wtime()-time00
16681 end subroutine eelecij_scale
16682 !-----------------------------------------------------------------------------
16683 subroutine evdwpp_short(evdw1)
16687 ! implicit real(kind=8) (a-h,o-z)
16688 ! include 'DIMENSIONS'
16689 ! include 'COMMON.CONTROL'
16690 ! include 'COMMON.IOUNITS'
16691 ! include 'COMMON.GEO'
16692 ! include 'COMMON.VAR'
16693 ! include 'COMMON.LOCAL'
16694 ! include 'COMMON.CHAIN'
16695 ! include 'COMMON.DERIV'
16696 ! include 'COMMON.INTERACT'
16697 ! include 'COMMON.CONTACTS'
16698 ! include 'COMMON.TORSION'
16699 ! include 'COMMON.VECTORS'
16700 ! include 'COMMON.FFIELD'
16701 real(kind=8),dimension(3) :: ggg
16702 ! 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
16704 real(kind=8) :: scal_el=1.0d0
16706 real(kind=8) :: scal_el=0.5d0
16708 !el local variables
16709 integer :: i,j,k,iteli,itelj,num_conti,isubchap
16710 real(kind=8) :: dxi,dyi,dzi,dxj,dyj,dzj,aaa,bbb
16711 real(kind=8) :: xj,yj,zj,rij,rrmij,sss,r3ij,r6ij,evdw1,&
16712 dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
16713 dx_normj,dy_normj,dz_normj,rmij,ev1,ev2,evdwij,facvdw
16714 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
16715 dist_temp, dist_init,sss_grad,sslipi,ssgradlipi,&
16716 sslipj,ssgradlipj,faclipij2
16717 integer xshift,yshift,zshift
16721 ! write (iout,*) "iatel_s_vdw",iatel_s_vdw,
16722 ! & " iatel_e_vdw",iatel_e_vdw
16724 do i=iatel_s_vdw,iatel_e_vdw
16725 if (itype(i,1).eq.ntyp1.or. itype(i+1,1).eq.ntyp1) cycle
16729 dx_normi=dc_norm(1,i)
16730 dy_normi=dc_norm(2,i)
16731 dz_normi=dc_norm(3,i)
16732 xmedi=c(1,i)+0.5d0*dxi
16733 ymedi=c(2,i)+0.5d0*dyi
16734 zmedi=c(3,i)+0.5d0*dzi
16735 call to_box(xmedi,ymedi,zmedi)
16736 call lipid_layer(xmedi,ymedi,zmedi,sslipi,ssgradlipi)
16738 ! write (iout,*) 'i',i,' ielstart',ielstart_vdw(i),
16739 ! & ' ielend',ielend_vdw(i)
16741 do j=ielstart_vdw(i),ielend_vdw(i)
16742 if (itype(j,1).eq.ntyp1 .or. itype(j+1,1).eq.ntyp1) cycle
16746 if (j.eq.i+2 .and. itelj.eq.2) iteli=2
16747 aaa=app(iteli,itelj)
16748 bbb=bpp(iteli,itelj)
16752 dx_normj=dc_norm(1,j)
16753 dy_normj=dc_norm(2,j)
16754 dz_normj=dc_norm(3,j)
16755 ! xj=c(1,j)+0.5D0*dxj-xmedi
16756 ! yj=c(2,j)+0.5D0*dyj-ymedi
16757 ! zj=c(3,j)+0.5D0*dzj-zmedi
16758 xj=c(1,j)+0.5D0*dxj
16759 yj=c(2,j)+0.5D0*dyj
16760 zj=c(3,j)+0.5D0*dzj
16761 call to_box(xj,yj,zj)
16762 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
16763 faclipij2=(sslipi+sslipj)/2.0d0*lipscale**2+1.0d0
16764 xj=boxshift(xj-xmedi,boxxsize)
16765 yj=boxshift(yj-ymedi,boxysize)
16766 zj=boxshift(zj-zmedi,boxzsize)
16767 rij=xj*xj+yj*yj+zj*zj
16770 sss=sscale(rij/rpp(iteli,itelj))
16771 sss_ele_cut=sscale_ele(rij)
16772 sss_ele_grad=sscagrad_ele(rij)
16773 sss_grad=sscale_grad((rij/rpp(iteli,itelj)))
16774 if (sss_ele_cut.le.0.0) cycle
16775 if (sss.gt.0.0d0) then
16780 ! 4/26/02 - AL scaling down 1,4 repulsive VDW interactions
16781 if (j.eq.i+2) ev1=scal_el*ev1
16784 if (energy_dec) then
16785 write (iout,'(a6,2i5,0pf7.3,f7.3)') 'evdw1',i,j,evdwij,sss
16787 evdw1=evdw1+evdwij*sss*sss_ele_cut
16789 ! Calculate contributions to the Cartesian gradient.
16791 facvdw=-6*rrmij*(ev1+evdwij)*sss*sss_ele_cut
16795 ggg(1)=facvdw*xj+sss_ele_grad*rmij*evdwij*xj*sss &
16796 +evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*xj
16797 ggg(2)=facvdw*yj+sss_ele_grad*rmij*evdwij*yj*sss &
16798 +evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*yj
16799 ggg(3)=facvdw*zj+sss_ele_grad*rmij*evdwij*zj*sss &
16800 +evdwij*sss_ele_cut/rij*sss_grad/rpp(iteli,itelj)*zj
16803 gvdwpp(k,j)=gvdwpp(k,j)+ggg(k)
16804 gvdwpp(k,i)=gvdwpp(k,i)-ggg(k)
16810 end subroutine evdwpp_short
16811 !-----------------------------------------------------------------------------
16812 subroutine escp_long(evdw2,evdw2_14)
16814 ! This subroutine calculates the excluded-volume interaction energy between
16815 ! peptide-group centers and side chains and its gradient in virtual-bond and
16816 ! side-chain vectors.
16818 ! implicit real(kind=8) (a-h,o-z)
16819 ! include 'DIMENSIONS'
16820 ! include 'COMMON.GEO'
16821 ! include 'COMMON.VAR'
16822 ! include 'COMMON.LOCAL'
16823 ! include 'COMMON.CHAIN'
16824 ! include 'COMMON.DERIV'
16825 ! include 'COMMON.INTERACT'
16826 ! include 'COMMON.FFIELD'
16827 ! include 'COMMON.IOUNITS'
16828 ! include 'COMMON.CONTROL'
16829 real(kind=8),dimension(3) :: ggg
16830 !el local variables
16831 integer :: i,iint,j,k,iteli,itypj,subchap
16832 real(kind=8) :: xi,yi,zi,xj,yj,zj,rrij,sss,fac,e1,e2,sss_grad,rij
16833 real(kind=8) :: evdw2,evdw2_14,evdwij
16834 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
16835 dist_temp, dist_init
16839 !d print '(a)','Enter ESCP'
16840 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
16841 do i=iatscp_s,iatscp_e
16842 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
16844 xi=0.5D0*(c(1,i)+c(1,i+1))
16845 yi=0.5D0*(c(2,i)+c(2,i+1))
16846 zi=0.5D0*(c(3,i)+c(3,i+1))
16847 call to_box(xi,yi,zi)
16848 do iint=1,nscp_gr(i)
16850 do j=iscpstart(i,iint),iscpend(i,iint)
16852 if (itypj.eq.ntyp1) cycle
16853 ! Uncomment following three lines for SC-p interactions
16854 ! xj=c(1,nres+j)-xi
16855 ! yj=c(2,nres+j)-yi
16856 ! zj=c(3,nres+j)-zi
16857 ! Uncomment following three lines for Ca-p interactions
16861 call to_box(xj,yj,zj)
16862 xj=boxshift(xj-xi,boxxsize)
16863 yj=boxshift(yj-yi,boxysize)
16864 zj=boxshift(zj-zi,boxzsize)
16865 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
16867 rij=dsqrt(1.0d0/rrij)
16868 sss_ele_cut=sscale_ele(rij)
16869 sss_ele_grad=sscagrad_ele(rij)
16870 ! print *,sss_ele_cut,sss_ele_grad,&
16871 ! (rij),r_cut_ele,rlamb_ele
16872 if (sss_ele_cut.le.0.0) cycle
16873 sss=sscale((rij/rscp(itypj,iteli)))
16874 sss_grad=sscale_grad(rij/rscp(itypj,iteli))
16875 if (sss.lt.1.0d0) then
16878 e1=fac*fac*aad(itypj,iteli)
16879 e2=fac*bad(itypj,iteli)
16880 if (iabs(j-i) .le. 2) then
16883 evdw2_14=evdw2_14+(e1+e2)*(1.0d0-sss)*sss_ele_cut
16886 evdw2=evdw2+evdwij*(1.0d0-sss)*sss_ele_cut
16887 if (energy_dec) write (iout,'(a6,2i5,2(0pf7.3))') &
16888 'evdw2',i,j,sss,evdwij
16890 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
16892 fac=-(evdwij+e1)*rrij*(1.0d0-sss)*sss_ele_cut
16893 fac=fac+evdwij*sss_ele_grad/rij/expon*(1.0d0-sss)&
16894 -evdwij*sss_ele_cut/rij/expon*sss_grad/rscp(itypj,iteli)
16898 ! Uncomment following three lines for SC-p interactions
16900 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
16902 ! Uncomment following line for SC-p interactions
16903 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
16905 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
16906 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
16915 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
16916 gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
16917 gradx_scp(j,i)=expon*gradx_scp(j,i)
16920 !******************************************************************************
16924 ! To save time the factor EXPON has been extracted from ALL components
16925 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
16928 !******************************************************************************
16930 end subroutine escp_long
16931 !-----------------------------------------------------------------------------
16932 subroutine escp_short(evdw2,evdw2_14)
16934 ! This subroutine calculates the excluded-volume interaction energy between
16935 ! peptide-group centers and side chains and its gradient in virtual-bond and
16936 ! side-chain vectors.
16938 ! implicit real(kind=8) (a-h,o-z)
16939 ! include 'DIMENSIONS'
16940 ! include 'COMMON.GEO'
16941 ! include 'COMMON.VAR'
16942 ! include 'COMMON.LOCAL'
16943 ! include 'COMMON.CHAIN'
16944 ! include 'COMMON.DERIV'
16945 ! include 'COMMON.INTERACT'
16946 ! include 'COMMON.FFIELD'
16947 ! include 'COMMON.IOUNITS'
16948 ! include 'COMMON.CONTROL'
16949 real(kind=8),dimension(3) :: ggg
16950 !el local variables
16951 integer :: i,iint,j,k,iteli,itypj,subchap
16952 real(kind=8) :: xi,yi,zi,xj,yj,zj,rrij,sss,fac,e1,e2,sss_grad,rij
16953 real(kind=8) :: evdw2,evdw2_14,evdwij
16954 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
16955 dist_temp, dist_init
16959 !d print '(a)','Enter ESCP'
16960 !d write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
16961 do i=iatscp_s,iatscp_e
16962 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
16964 xi=0.5D0*(c(1,i)+c(1,i+1))
16965 yi=0.5D0*(c(2,i)+c(2,i+1))
16966 zi=0.5D0*(c(3,i)+c(3,i+1))
16967 call to_box(xi,yi,zi)
16968 if (zi.lt.0) zi=zi+boxzsize
16970 do iint=1,nscp_gr(i)
16972 do j=iscpstart(i,iint),iscpend(i,iint)
16974 if (itypj.eq.ntyp1) cycle
16975 ! Uncomment following three lines for SC-p interactions
16976 ! xj=c(1,nres+j)-xi
16977 ! yj=c(2,nres+j)-yi
16978 ! zj=c(3,nres+j)-zi
16979 ! Uncomment following three lines for Ca-p interactions
16986 call to_box(xj,yj,zj)
16987 xj=boxshift(xj-xi,boxxsize)
16988 yj=boxshift(yj-yi,boxysize)
16989 zj=boxshift(zj-zi,boxzsize)
16990 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
16991 rij=dsqrt(1.0d0/rrij)
16992 sss_ele_cut=sscale_ele(rij)
16993 sss_ele_grad=sscagrad_ele(rij)
16994 ! print *,sss_ele_cut,sss_ele_grad,&
16995 ! (rij),r_cut_ele,rlamb_ele
16996 if (sss_ele_cut.le.0.0) cycle
16997 sss=sscale(rij/rscp(itypj,iteli))
16998 sss_grad=sscale_grad(rij/rscp(itypj,iteli))
16999 if (sss.gt.0.0d0) then
17002 e1=fac*fac*aad(itypj,iteli)
17003 e2=fac*bad(itypj,iteli)
17004 if (iabs(j-i) .le. 2) then
17007 evdw2_14=evdw2_14+(e1+e2)*sss*sss_ele_cut
17010 evdw2=evdw2+evdwij*sss*sss_ele_cut
17011 if (energy_dec) write (iout,'(a6,2i5,2(0pf7.3))') &
17012 'evdw2',i,j,sss,evdwij
17014 ! Calculate contributions to the gradient in the virtual-bond and SC vectors.
17016 fac=-(evdwij+e1)*rrij*sss*sss_ele_cut
17017 fac=fac+evdwij*sss_ele_grad/rij/expon*sss &
17018 +evdwij*sss_ele_cut/rij/expon*sss_grad/rscp(itypj,iteli)
17023 ! Uncomment following three lines for SC-p interactions
17025 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
17027 ! Uncomment following line for SC-p interactions
17028 ! gradx_scp(k,j)=gradx_scp(k,j)+ggg(k)
17030 gvdwc_scpp(k,i)=gvdwc_scpp(k,i)-ggg(k)
17031 gvdwc_scp(k,j)=gvdwc_scp(k,j)+ggg(k)
17040 gvdwc_scp(j,i)=expon*gvdwc_scp(j,i)
17041 gvdwc_scpp(j,i)=expon*gvdwc_scpp(j,i)
17042 gradx_scp(j,i)=expon*gradx_scp(j,i)
17045 !******************************************************************************
17049 ! To save time the factor EXPON has been extracted from ALL components
17050 ! of GVDWC and GRADX. Remember to multiply them by this factor before further
17053 !******************************************************************************
17055 end subroutine escp_short
17056 !-----------------------------------------------------------------------------
17057 ! energy_p_new-sep_barrier.F
17058 !-----------------------------------------------------------------------------
17059 subroutine sc_grad_scale(scalfac)
17060 ! implicit real(kind=8) (a-h,o-z)
17062 ! include 'DIMENSIONS'
17063 ! include 'COMMON.CHAIN'
17064 ! include 'COMMON.DERIV'
17065 ! include 'COMMON.CALC'
17066 ! include 'COMMON.IOUNITS'
17067 real(kind=8),dimension(3) :: dcosom1,dcosom2
17068 real(kind=8) :: scalfac
17069 !el local variables
17070 ! integer :: i,j,k,l
17072 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
17073 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
17074 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12 &
17075 -2.0D0*alf12*eps3der+sigder*sigsq_om12
17079 ! eom12=evdwij*eps1_om12
17081 ! write (iout,*) "eps2der",eps2der," eps3der",eps3der,
17082 ! & " sigder",sigder
17083 ! write (iout,*) "eps1_om12",eps1_om12," eps2rt_om12",eps2rt_om12
17084 ! write (iout,*) "eom1",eom1," eom2",eom2," eom12",eom12
17086 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
17087 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
17090 gg(k)=(gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k))*scalfac&
17093 ! write (iout,*) "gg",(gg(k),k=1,3)
17095 gvdwx(k,i)=gvdwx(k,i)-gg(k) &
17096 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
17097 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv*scalfac&
17099 gvdwx(k,j)=gvdwx(k,j)+gg(k) &
17100 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
17101 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv*scalfac&
17103 ! write (iout,*)(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))
17104 ! & +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
17105 ! write (iout,*)(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))
17106 ! & +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
17109 ! Calculate the components of the gradient in DC and X
17112 gvdwc(l,i)=gvdwc(l,i)-gg(l)
17113 gvdwc(l,j)=gvdwc(l,j)+gg(l)
17116 end subroutine sc_grad_scale
17117 !-----------------------------------------------------------------------------
17118 ! energy_split-sep.F
17119 !-----------------------------------------------------------------------------
17120 subroutine etotal_long(energia)
17122 ! Compute the long-range slow-varying contributions to the energy
17124 ! implicit real(kind=8) (a-h,o-z)
17125 ! include 'DIMENSIONS'
17126 use MD_data, only: totT,usampl,eq_time
17130 !MS$ATTRIBUTES C :: proc_proc
17135 real(kind=8),dimension(n_ene) :: weights_!,time_Bcast,time_Bcastw
17137 ! include 'COMMON.SETUP'
17138 ! include 'COMMON.IOUNITS'
17139 ! include 'COMMON.FFIELD'
17140 ! include 'COMMON.DERIV'
17141 ! include 'COMMON.INTERACT'
17142 ! include 'COMMON.SBRIDGE'
17143 ! include 'COMMON.CHAIN'
17144 ! include 'COMMON.VAR'
17145 ! include 'COMMON.LOCAL'
17146 ! include 'COMMON.MD'
17147 real(kind=8),dimension(0:n_ene) :: energia
17148 !el local variables
17149 integer :: i,n_corr,n_corr1,ierror,ierr
17150 real(kind=8) :: evdw2,evdw2_14,ehpb,etors,edihcnstr,etors_d,esccor,&
17151 evdw,ees,evdw1,eel_loc,eello_turn3,eello_turn4,&
17152 ecorr,ecorr5,ecorr6,eturn6,time00, ehomology_constr
17153 ! write(iout,'(a,i2)')'Calling etotal_long ipot=',ipot
17154 !elwrite(iout,*)"in etotal long"
17156 if (modecalc.eq.12.or.modecalc.eq.14) then
17158 ! if (fg_rank.eq.0) call int_from_cart1(.false.)
17160 call int_from_cart1(.false.)
17163 !elwrite(iout,*)"in etotal long"
17164 ehomology_constr=0.0d0
17166 ! write(iout,*) "ETOTAL_LONG Processor",fg_rank,
17167 ! & " absolute rank",myrank," nfgtasks",nfgtasks
17169 if (nfgtasks.gt.1) then
17171 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
17172 if (fg_rank.eq.0) then
17173 call MPI_Bcast(3,1,MPI_INTEGER,king,FG_COMM,IERROR)
17174 ! write (iout,*) "Processor",myrank," BROADCAST iorder"
17176 ! FG master sets up the WEIGHTS_ array which will be broadcast to the
17177 ! FG slaves as WEIGHTS array.
17184 weights_(7)=wel_loc
17187 weights_(10)=wturn6
17189 weights_(12)=wscloc
17191 weights_(14)=wtor_d
17192 weights_(15)=wstrain
17193 weights_(16)=wvdwpp
17195 weights_(18)=scal14
17196 weights_(21)=wsccor
17197 ! FG Master broadcasts the WEIGHTS_ array
17198 call MPI_Bcast(weights_(1),n_ene,&
17199 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
17201 ! FG slaves receive the WEIGHTS array
17202 call MPI_Bcast(weights(1),n_ene,&
17203 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
17218 wstrain=weights(15)
17224 call MPI_Bcast(dc(1,1),6*nres,MPI_DOUBLE_PRECISION,&
17226 time_Bcast=time_Bcast+MPI_Wtime()-time00
17227 time_Bcastw=time_Bcastw+MPI_Wtime()-time00
17228 ! call chainbuild_cart
17229 ! call int_from_cart1(.false.)
17231 ! write (iout,*) 'Processor',myrank,
17232 ! & ' calling etotal_short ipot=',ipot
17234 ! print *,'Processor',myrank,' nnt=',nnt,' nct=',nct
17236 !d print *,'nnt=',nnt,' nct=',nct
17238 !elwrite(iout,*)"in etotal long"
17239 ! Compute the side-chain and electrostatic interaction energy
17241 goto (101,102,103,104,105,106) ipot
17242 ! Lennard-Jones potential.
17243 101 call elj_long(evdw)
17244 !d print '(a)','Exit ELJ'
17246 ! Lennard-Jones-Kihara potential (shifted).
17247 102 call eljk_long(evdw)
17249 ! Berne-Pechukas potential (dilated LJ, angular dependence).
17250 103 call ebp_long(evdw)
17252 ! Gay-Berne potential (shifted LJ, angular dependence).
17253 104 call egb_long(evdw)
17255 ! Gay-Berne-Vorobjev potential (shifted LJ, angular dependence).
17256 105 call egbv_long(evdw)
17258 ! Soft-sphere potential
17259 106 call e_softsphere(evdw)
17261 ! Calculate electrostatic (H-bonding) energy of the main chain.
17265 if (ipot.lt.6) then
17267 if (welec.gt.0d0.or.wvdwpp.gt.0d0.or.wel_loc.gt.0d0.or. &
17268 wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0 &
17269 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
17270 .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
17272 if (welec.gt.0d0.or.wel_loc.gt.0d0.or. &
17273 wturn3.gt.0d0.or.wturn4.gt.0d0 .or. wcorr.gt.0.0d0 &
17274 .or. wcorr4.gt.0.0d0 .or. wcorr5.gt.0.d0 &
17275 .or. wcorr6.gt.0.0d0 .or. wturn6.gt.0.0d0 ) then
17277 call eelec_scale(ees,evdw1,eel_loc,eello_turn3,eello_turn4)
17286 ! write (iout,*) "Soft-spheer ELEC potential"
17287 call eelec_soft_sphere(ees,evdw1,eel_loc,eello_turn3,&
17291 ! Calculate excluded-volume interaction energy between peptide groups
17294 if (ipot.lt.6) then
17295 if(wscp.gt.0d0) then
17296 call escp_long(evdw2,evdw2_14)
17302 call escp_soft_sphere(evdw2,evdw2_14)
17305 ! 12/1/95 Multi-body terms
17309 if ((wcorr4.gt.0.0d0 .or. wcorr5.gt.0.0d0 .or. wcorr6.gt.0.0d0 &
17310 .or. wturn6.gt.0.0d0) .and. ipot.lt.6) then
17311 call multibody_eello(ecorr,ecorr5,ecorr6,eturn6,n_corr,n_corr1)
17312 ! write (2,*) 'n_corr=',n_corr,' n_corr1=',n_corr1,
17313 ! &" ecorr",ecorr," ecorr5",ecorr5," ecorr6",ecorr6," eturn6",eturn6
17320 if ((wcorr4.eq.0.0d0 .and. wcorr.gt.0.0d0) .and. ipot.lt.6) then
17321 call multibody_hb(ecorr,ecorr5,ecorr6,n_corr,n_corr1)
17324 ! If performing constraint dynamics, call the constraint energy
17325 ! after the equilibration time
17326 if(usampl.and.totT.gt.eq_time) then
17341 energia(2)=evdw2-evdw2_14
17342 energia(18)=evdw2_14
17351 energia(3)=ees+evdw1
17358 energia(8)=eello_turn3
17359 energia(9)=eello_turn4
17361 energia(20)=Uconst+Uconst_back
17362 energia(51)=ehomology_constr
17363 call sum_energy(energia,.true.)
17364 ! write (iout,*) "Exit ETOTAL_LONG"
17367 end subroutine etotal_long
17368 !-----------------------------------------------------------------------------
17369 subroutine etotal_short(energia)
17371 ! Compute the short-range fast-varying contributions to the energy
17373 ! implicit real(kind=8) (a-h,o-z)
17374 ! include 'DIMENSIONS'
17378 !MS$ATTRIBUTES C :: proc_proc
17383 integer :: ierror,ierr
17384 real(kind=8),dimension(n_ene) :: weights_
17385 real(kind=8) :: time00
17387 ! include 'COMMON.SETUP'
17388 ! include 'COMMON.IOUNITS'
17389 ! include 'COMMON.FFIELD'
17390 ! include 'COMMON.DERIV'
17391 ! include 'COMMON.INTERACT'
17392 ! include 'COMMON.SBRIDGE'
17393 ! include 'COMMON.CHAIN'
17394 ! include 'COMMON.VAR'
17395 ! include 'COMMON.LOCAL'
17396 real(kind=8),dimension(0:n_ene) :: energia
17397 !el local variables
17399 real(kind=8) :: evdw,evdw1,evdw2,evdw2_14,esccor,etors_d,etors
17400 real(kind=8) :: ehpb,escloc,estr,ebe,edihcnstr,ethetacnstr, &
17404 ! write(iout,'(a,i2)')'Calling etotal_short ipot=',ipot
17406 if (modecalc.eq.12.or.modecalc.eq.14) then
17408 if (fg_rank.eq.0) call int_from_cart1(.false.)
17410 call int_from_cart1(.false.)
17414 ! write(iout,*) "ETOTAL_SHORT Processor",fg_rank,
17415 ! & " absolute rank",myrank," nfgtasks",nfgtasks
17417 if (nfgtasks.gt.1) then
17419 ! FG slaves call the following matching MPI_Bcast in ERGASTULUM
17420 if (fg_rank.eq.0) then
17421 call MPI_Bcast(2,1,MPI_INTEGER,king,FG_COMM,IERROR)
17422 ! write (iout,*) "Processor",myrank," BROADCAST iorder"
17424 ! FG master sets up the WEIGHTS_ array which will be broadcast to the
17425 ! FG slaves as WEIGHTS array.
17432 weights_(7)=wel_loc
17435 weights_(10)=wturn6
17437 weights_(12)=wscloc
17439 weights_(14)=wtor_d
17440 weights_(15)=wstrain
17441 weights_(16)=wvdwpp
17443 weights_(18)=scal14
17444 weights_(21)=wsccor
17445 ! FG Master broadcasts the WEIGHTS_ array
17446 call MPI_Bcast(weights_(1),n_ene,&
17447 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
17449 ! FG slaves receive the WEIGHTS array
17450 call MPI_Bcast(weights(1),n_ene,&
17451 MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
17466 wstrain=weights(15)
17472 ! write (iout,*),"Processor",myrank," BROADCAST weights"
17473 call MPI_Bcast(c(1,1),nres6,MPI_DOUBLE_PRECISION,&
17475 ! write (iout,*) "Processor",myrank," BROADCAST c"
17476 call MPI_Bcast(dc(1,1),nres6,MPI_DOUBLE_PRECISION,&
17478 ! write (iout,*) "Processor",myrank," BROADCAST dc"
17479 call MPI_Bcast(dc_norm(1,1),nres6,MPI_DOUBLE_PRECISION,&
17481 ! write (iout,*) "Processor",myrank," BROADCAST dc_norm"
17482 call MPI_Bcast(theta(1),nres,MPI_DOUBLE_PRECISION,&
17484 ! write (iout,*) "Processor",myrank," BROADCAST theta"
17485 call MPI_Bcast(phi(1),nres,MPI_DOUBLE_PRECISION,&
17487 ! write (iout,*) "Processor",myrank," BROADCAST phi"
17488 call MPI_Bcast(alph(1),nres,MPI_DOUBLE_PRECISION,&
17490 ! write (iout,*) "Processor",myrank," BROADCAST alph"
17491 call MPI_Bcast(omeg(1),nres,MPI_DOUBLE_PRECISION,&
17493 ! write (iout,*) "Processor",myrank," BROADCAST omeg"
17494 call MPI_Bcast(vbld(1),2*nres,MPI_DOUBLE_PRECISION,&
17496 ! write (iout,*) "Processor",myrank," BROADCAST vbld"
17497 call MPI_Bcast(vbld_inv(1),2*nres,MPI_DOUBLE_PRECISION,&
17499 time_Bcast=time_Bcast+MPI_Wtime()-time00
17500 ! write (iout,*) "Processor",myrank," BROADCAST vbld_inv"
17502 ! write (iout,*) 'Processor',myrank,
17503 ! & ' calling etotal_short ipot=',ipot
17505 ! print *,'Processor',myrank,' nnt=',nnt,' nct=',nct
17507 ! call int_from_cart1(.false.)
17509 ! Compute the side-chain and electrostatic interaction energy
17511 goto (101,102,103,104,105,106) ipot
17512 ! Lennard-Jones potential.
17513 101 call elj_short(evdw)
17514 !d print '(a)','Exit ELJ'
17516 ! Lennard-Jones-Kihara potential (shifted).
17517 102 call eljk_short(evdw)
17519 ! Berne-Pechukas potential (dilated LJ, angular dependence).
17520 103 call ebp_short(evdw)
17522 ! Gay-Berne potential (shifted LJ, angular dependence).
17523 104 call egb_short(evdw)
17525 ! Gay-Berne-Vorobjev potential (shifted LJ, angular dependence).
17526 105 call egbv_short(evdw)
17528 ! Soft-sphere potential - already dealt with in the long-range part
17530 ! 106 call e_softsphere_short(evdw)
17532 ! Calculate electrostatic (H-bonding) energy of the main chain.
17536 ! Calculate the short-range part of Evdwpp
17538 call evdwpp_short(evdw1)
17540 ! Calculate the short-range part of ESCp
17542 if (ipot.lt.6) then
17543 call escp_short(evdw2,evdw2_14)
17546 ! Calculate the bond-stretching energy
17550 ! Calculate the disulfide-bridge and other energy and the contributions
17551 ! from other distance constraints.
17554 ! Calculate the virtual-bond-angle energy.
17556 ! Calculate the SC local energy.
17561 if (wang.gt.0d0) then
17562 if (tor_mode.eq.0) then
17565 !C ebend kcc is Kubo cumulant clustered rigorous attemp to derive the
17567 call ebend_kcc(ebe)
17573 if (with_theta_constr) call etheta_constr(ethetacnstr)
17575 ! write(iout,*) "in etotal afer ebe",ipot
17577 ! print *,"Processor",myrank," computed UB"
17579 ! Calculate the SC local energy.
17582 !elwrite(iout,*) "in etotal afer esc",ipot
17583 ! print *,"Processor",myrank," computed USC"
17585 ! Calculate the virtual-bond torsional energy.
17587 !d print *,'nterm=',nterm
17588 ! if (wtor.gt.0) then
17589 ! call etor(etors,edihcnstr)
17594 if (wtor.gt.0.0d0) then
17595 if (tor_mode.eq.0) then
17598 !C etor kcc is Kubo cumulant clustered rigorous attemp to derive the
17600 call etor_kcc(etors)
17606 if (ndih_constr.gt.0) call etor_constr(edihcnstr)
17608 ! Calculate the virtual-bond torsional energy.
17611 ! 6/23/01 Calculate double-torsional energy
17613 if ((wtor_d.gt.0.0d0).and.(tor_mode.eq.0)) then
17614 call etor_d(etors_d)
17617 ! Homology restraints
17619 if (constr_homology.ge.1) then
17620 call e_modeller(ehomology_constr)
17623 ehomology_constr=0.0d0
17627 ! 21/5/07 Calculate local sicdechain correlation energy
17629 if (wsccor.gt.0.0d0) then
17630 call eback_sc_corr(esccor)
17635 ! Put energy components into an array
17642 energia(2)=evdw2-evdw2_14
17643 energia(18)=evdw2_14
17656 energia(14)=etors_d
17659 energia(19)=edihcnstr
17661 energia(51)=ehomology_constr
17662 ! write (iout,*) "ETOTAL_SHORT before SUM_ENERGY"
17664 call sum_energy(energia,.true.)
17665 ! write (iout,*) "Exit ETOTAL_SHORT"
17668 end subroutine etotal_short
17669 !-----------------------------------------------------------------------------
17671 !-----------------------------------------------------------------------------
17672 real(kind=8) function gnmr1(y,ymin,ymax)
17674 real(kind=8) :: y,ymin,ymax
17675 real(kind=8) :: wykl=4.0d0
17676 if (y.lt.ymin) then
17677 gnmr1=(ymin-y)**wykl/wykl
17678 else if (y.gt.ymax) then
17679 gnmr1=(y-ymax)**wykl/wykl
17685 !-----------------------------------------------------------------------------
17686 real(kind=8) function gnmr1prim(y,ymin,ymax)
17688 real(kind=8) :: y,ymin,ymax
17689 real(kind=8) :: wykl=4.0d0
17690 if (y.lt.ymin) then
17691 gnmr1prim=-(ymin-y)**(wykl-1)
17692 else if (y.gt.ymax) then
17693 gnmr1prim=(y-ymax)**(wykl-1)
17698 end function gnmr1prim
17699 !----------------------------------------------------------------------------
17700 real(kind=8) function rlornmr1(y,ymin,ymax,sigma)
17701 real(kind=8) y,ymin,ymax,sigma
17702 real(kind=8) wykl /4.0d0/
17703 if (y.lt.ymin) then
17704 rlornmr1=(ymin-y)**wykl/((ymin-y)**wykl+sigma**wykl)
17705 else if (y.gt.ymax) then
17706 rlornmr1=(y-ymax)**wykl/((y-ymax)**wykl+sigma**wykl)
17711 end function rlornmr1
17712 !------------------------------------------------------------------------------
17713 real(kind=8) function rlornmr1prim(y,ymin,ymax,sigma)
17714 real(kind=8) y,ymin,ymax,sigma
17715 real(kind=8) wykl /4.0d0/
17716 if (y.lt.ymin) then
17717 rlornmr1prim=-(ymin-y)**(wykl-1)*sigma**wykl*wykl/ &
17718 ((ymin-y)**wykl+sigma**wykl)**2
17719 else if (y.gt.ymax) then
17720 rlornmr1prim=(y-ymax)**(wykl-1)*sigma**wykl*wykl/ &
17721 ((y-ymax)**wykl+sigma**wykl)**2
17726 end function rlornmr1prim
17728 real(kind=8) function harmonic(y,ymax)
17730 real(kind=8) :: y,ymax
17731 real(kind=8) :: wykl=2.0d0
17732 harmonic=(y-ymax)**wykl
17734 end function harmonic
17735 !-----------------------------------------------------------------------------
17736 real(kind=8) function harmonicprim(y,ymax)
17737 real(kind=8) :: y,ymin,ymax
17738 real(kind=8) :: wykl=2.0d0
17739 harmonicprim=(y-ymax)*wykl
17741 end function harmonicprim
17742 !-----------------------------------------------------------------------------
17744 !-----------------------------------------------------------------------------
17746 subroutine gradient(n,x,nf,g,uiparm,urparm,ufparm)
17748 use io_base, only:intout,briefout
17749 ! implicit real(kind=8) (a-h,o-z)
17750 ! include 'DIMENSIONS'
17751 ! include 'COMMON.CHAIN'
17752 ! include 'COMMON.DERIV'
17753 ! include 'COMMON.VAR'
17754 ! include 'COMMON.INTERACT'
17755 ! include 'COMMON.FFIELD'
17756 ! include 'COMMON.MD'
17757 ! include 'COMMON.IOUNITS'
17758 real(kind=8),external :: ufparm
17759 integer :: uiparm(1)
17760 real(kind=8) :: urparm(1)
17761 real(kind=8),dimension(6*nres) :: x,g !(maxvar) (maxvar=6*maxres)
17762 real(kind=8) :: f,gthetai,gphii,galphai,gomegai
17763 integer :: n,nf,ind,ind1,i,k,j
17765 ! This subroutine calculates total internal coordinate gradient.
17766 ! Depending on the number of function evaluations, either whole energy
17767 ! is evaluated beforehand, Cartesian coordinates and their derivatives in
17768 ! internal coordinates are reevaluated or only the cartesian-in-internal
17769 ! coordinate derivatives are evaluated. The subroutine was designed to work
17775 !d print *,'grad',nf,icg
17776 if (nf-nfl+1) 20,30,40
17777 20 call func(n,x,nf,f,uiparm,urparm,ufparm)
17778 ! write (iout,*) 'grad 20'
17779 if (nf.eq.0) return
17781 30 call var_to_geom(n,x)
17783 ! write (iout,*) 'grad 30'
17785 ! Evaluate the derivatives of virtual bond lengths and SC vectors in variables.
17788 ! write (iout,*) 'grad 40'
17789 ! print *,'GRADIENT: nnt=',nnt,' nct=',nct,' expon=',expon
17791 ! Convert the Cartesian gradient into internal-coordinate gradient.
17801 ! print *,'GRAD: i=',i,' jc=',j,' ind=',ind
17803 gthetai=gthetai+dcdv(k,ind)*gradc(k,j,icg)
17806 gphii=gphii+dcdv(k+3,ind)*gradc(k,j,icg)
17812 ! print *,'GRAD: i=',i,' jx=',j,' ind1=',ind1
17814 gthetai=gthetai+dxdv(k,ind1)*gradx(k,j,icg)
17815 gphii=gphii+dxdv(k+3,ind1)*gradx(k,j,icg)
17818 if (i.gt.1) g(i-1)=gphii
17819 if (n.gt.nphi) g(nphi+i)=gthetai
17821 if (n.le.nphi+ntheta) goto 10
17823 if (itype(i,1).ne.10) then
17827 galphai=galphai+dxds(k,i)*gradx(k,i,icg)
17830 gomegai=gomegai+dxds(k+3,i)*gradx(k,i,icg)
17832 g(ialph(i,1))=galphai
17833 g(ialph(i,1)+nside)=gomegai
17837 ! Add the components corresponding to local energy terms.
17841 !d write (iout,*) 'i=',i,'g=',g(i),' gloc=',gloc(i,icg)
17842 g(i)=g(i)+gloc(i,icg)
17844 ! Uncomment following three lines for diagnostics.
17846 !elwrite(iout,*) "in gradient after calling intout"
17847 !d call briefout(0,0.0d0)
17848 !d write (iout,'(i3,1pe15.5)') (k,g(k),k=1,n)
17850 end subroutine gradient
17852 !-----------------------------------------------------------------------------
17853 subroutine func(n,x,nf,f,uiparm,urparm,ufparm) !from minimize_p.F
17856 ! implicit real(kind=8) (a-h,o-z)
17857 ! include 'DIMENSIONS'
17858 ! include 'COMMON.DERIV'
17859 ! include 'COMMON.IOUNITS'
17860 ! include 'COMMON.GEO'
17863 !el common /chuju/ jjj
17864 real(kind=8) :: energia(0:n_ene)
17865 integer :: uiparm(1)
17866 real(kind=8) :: urparm(1)
17868 real(kind=8),external :: ufparm
17869 real(kind=8),dimension(6*nres) :: x !(maxvar) (maxvar=6*maxres)
17870 ! if (jjj.gt.0) then
17871 ! write (iout,'(10f8.3)') (rad2deg*x(i),i=1,n)
17875 !d print *,'func',nf,nfl,icg
17876 call var_to_geom(n,x)
17879 !d write (iout,*) 'ETOTAL called from FUNC'
17880 call etotal(energia)
17883 ! if (jjj.gt.0) then
17884 ! write (iout,'(10f8.3)') (rad2deg*x(i),i=1,n)
17885 ! write (iout,*) 'f=',etot
17889 end subroutine func
17890 !-----------------------------------------------------------------------------
17891 subroutine cartgrad
17892 ! implicit real(kind=8) (a-h,o-z)
17893 ! include 'DIMENSIONS'
17895 use MD_data, only: totT,usampl,eq_time
17899 ! include 'COMMON.CHAIN'
17900 ! include 'COMMON.DERIV'
17901 ! include 'COMMON.VAR'
17902 ! include 'COMMON.INTERACT'
17903 ! include 'COMMON.FFIELD'
17904 ! include 'COMMON.MD'
17905 ! include 'COMMON.IOUNITS'
17906 ! include 'COMMON.TIME1'
17909 real(kind=8) :: time00,time01
17911 ! This subrouting calculates total Cartesian coordinate gradient.
17912 ! The subroutine chainbuild_cart and energy MUST be called beforehand.
17915 #ifdef TIMINGtime01
17923 !el write (iout,*) "After sum_gradient"
17925 write (iout,*) "After sum_gradient"
17927 write (iout,*) i," gradc ",(gradc(j,i,icg),j=1,3)
17928 write (iout,*) i," gradx ",(gradx(j,i,icg),j=1,3)
17932 ! If performing constraint dynamics, add the gradients of the constraint energy
17933 if(usampl.and.totT.gt.eq_time) then
17936 gradc(j,i,icg)=gradc(j,i,icg)+dudconst(j,i)+duscdiff(j,i)
17937 gradx(j,i,icg)=gradx(j,i,icg)+dudxconst(j,i)+duscdiffx(j,i)
17941 gloc(i,icg)=gloc(i,icg)+dugamma(i)
17944 gloc(nphi+i,icg)=gloc(nphi+i,icg)+dutheta(i)
17947 !elwrite (iout,*) "After sum_gradient"
17952 !elwrite (iout,*) "After sum_gradient"
17954 time_intcartderiv=time_intcartderiv+MPI_Wtime()-time01
17956 ! call checkintcartgrad
17957 ! write(iout,*) 'calling int_to_cart'
17960 write (iout,*) "gcart, gxcart, gloc before int_to_cart"
17964 gcart(j,i)=gradc(j,i,icg)
17965 gxcart(j,i)=gradx(j,i,icg)
17966 ! if (i.le.2) print *,"gcart_one",gcart(j,i),gradc(j,i,icg)
17969 write (iout,'(i5,2(3f10.5,5x),4f10.5)') i,(gcart(j,i),j=1,3),&
17970 (gxcart(j,i),j=1,3),gloc(i,icg),(gloc_sc(j,i,icg),j=1,3)
17976 ! print *,"gcart_two",gxcart(2,2),gradx(2,2,icg)
17978 ! print *,"gcart_two",gxcart(2,2),gradx(2,2,icg)
17981 time_inttocart=time_inttocart+MPI_Wtime()-time01
17984 write (iout,*) "gcart and gxcart after int_to_cart"
17986 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),&
17987 (gxcart(j,i),j=1,3)
17993 write (iout,*) "CARGRAD"
17997 ! gcart(j,i)=-gcart(j,i)+gcart(j,i-1)-gxcart(j,i)
17998 ! gcart_new(j,i)=-gcart(j,i)+gcart(j,i-1)-gxcart(j,i)
18000 ! write (iout,'(i5,3f10.5,5x,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3), &
18001 ! (gcart_new(j,i),j=1,3),(gxcart(j,i),j=1,3)
18003 ! Correction: dummy residues
18004 ! if (nnt.gt.1) then
18006 ! ! gcart_new(j,nnt)=gcart_new(j,nnt)+gcart_new(j,1)
18007 ! gcart(j,nnt)=gcart(j,nnt)+gcart(j,1)
18010 ! if (nct.lt.nres) then
18012 ! ! gcart_new(j,nct)=gcart_new(j,nct)+gcart_new(j,nres)
18013 ! gcart(j,nct)=gcart(j,nct)+gcart(j,nres)
18016 ! call grad_transform
18019 time_cartgrad=time_cartgrad+MPI_Wtime()-time00
18023 end subroutine cartgrad
18026 subroutine grad_transform
18031 integer i,j,kk,mnum
18033 write (iout,*)"Converting virtual-bond gradient to CA/SC gradient"
18034 write (iout,*) "dC/dX gradient"
18036 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),
18037 & (gxcart(j,i),j=1,3)
18042 gcart(j,i)=-gcart(j,i)+gcart(j,i-1)-gxcart(j,i)
18043 ! gcart_new(j,i)=-gcart(j,i)+gcart(j,i-1)-gxcart(j,i)
18045 ! write (iout,'(i5,3f10.5,5x,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3), &
18046 ! (gcart_new(j,i),j=1,3),(gxcart(j,i),j=1,3)
18048 ! Correction: dummy residues
18051 if (itype(i-1,mnum).eq.ntyp1_molec(mnum) .and.&
18052 itype(i,mnum).ne.ntyp1_molec(mnum)) then
18053 gcart(:,i)=gcart(:,i)+gcart(:,i-1)
18054 else if (itype(i-1,mnum).ne.ntyp1_molec(mnum).and.&
18055 itype(i,mnum).eq.ntyp1_molec(mnum)) then
18056 gcart(:,i-1)=gcart(:,i-1)+gcart(:,i)
18059 ! if (nnt.gt.1) then
18061 ! gcart(j,nnt)=gcart(j,nnt)+gcart(j,1)
18064 ! if (nct.lt.nres) then
18066 !! gcart_new(j,nct)=gcart_new(j,nct)+gcart_new(j,nres)
18067 ! gcart(j,nct)=gcart(j,nct)+gcart(j,nres)
18071 write (iout,*) "CA/SC gradient"
18073 write (iout,'(i5,3f10.5,5x,3f10.5)') i,(gcart(j,i),j=1,3),
18074 & (gxcart(j,i),j=1,3)
18078 end subroutine grad_transform
18081 !-----------------------------------------------------------------------------
18082 subroutine zerograd
18083 ! implicit real(kind=8) (a-h,o-z)
18084 ! include 'DIMENSIONS'
18085 ! include 'COMMON.DERIV'
18086 ! include 'COMMON.CHAIN'
18087 ! include 'COMMON.VAR'
18088 ! include 'COMMON.MD'
18089 ! include 'COMMON.SCCOR'
18091 !el local variables
18092 integer :: i,j,intertyp,k
18093 ! Initialize Cartesian-coordinate gradient
18095 ! if (.not.allocated(gradx)) allocate(gradx(3,nres,2)) !(3,maxres,2)
18096 ! if (.not.allocated(gradc)) allocate(gradc(3,nres,2)) !(3,maxres,2)
18098 ! allocate(gvdwx(3,nres),gvdwc(3,nres),gelc(3,nres),gelc_long(3,nres))
18099 ! allocate(gvdwpp(3,nres),gvdwc_scpp(3,nres),gradx_scp(3,nres))
18100 ! allocate(gvdwc_scp(3,nres),ghpbx(3,nres),ghpbc(3,nres))
18101 ! allocate(gradcorr_long(3,nres))
18102 ! allocate(gradcorr5_long(3,nres),gradcorr6_long(3,nres))
18103 ! allocate(gcorr6_turn_long(3,nres))
18104 ! allocate(gradcorr5(3,nres),gradcorr6(3,nres)) !(3,maxres)
18106 ! if (.not.allocated(gradcorr)) allocate(gradcorr(3,nres)) !(3,maxres)
18108 ! allocate(gel_loc(3,nres),gel_loc_long(3,nres),gcorr3_turn(3,nres))
18109 ! allocate(gcorr4_turn(3,nres),gcorr6_turn(3,nres))
18111 ! if (.not.allocated(gradb)) allocate(gradb(3,nres)) !(3,maxres)
18112 ! if (.not.allocated(gradbx)) allocate(gradbx(3,nres)) !(3,maxres)
18114 ! allocate(gsccorc(3,nres),gsccorx(3,nres)) !(3,maxres)
18115 ! allocate(gscloc(3,nres)) !(3,maxres)
18116 ! if (.not.allocated(gsclocx)) allocate(gsclocx(3,nres)) !(3,maxres)
18120 ! common /deriv_scloc/
18121 ! allocate(dXX_C1tab(3,nres),dYY_C1tab(3,nres),dZZ_C1tab(3,nres))
18122 ! allocate(dXX_Ctab(3,nres),dYY_Ctab(3,nres),dZZ_Ctab(3,nres))
18123 ! allocate(dXX_XYZtab(3,nres),dYY_XYZtab(3,nres),dZZ_XYZtab(3,nres)) !(3,maxres)
18125 ! allocate(jgrad_start(nres),jgrad_end(nres)) !(maxres)
18129 ! gradc(j,i,icg)=0.0d0
18130 ! gradx(j,i,icg)=0.0d0
18132 ! allocate(gloc_sc(3,nres,10)) !(3,0:maxres2,10)maxres2=2*maxres
18133 !elwrite(iout,*) "icg",icg
18137 gradx_scp(j,i)=0.0D0
18139 gvdwc_scp(j,i)=0.0D0
18140 gvdwc_scpp(j,i)=0.0d0
18142 gelc_long(j,i)=0.0D0
18147 gel_loc_long(j,i)=0.0d0
18150 gcorr3_turn(j,i)=0.0d0
18151 gcorr4_turn(j,i)=0.0d0
18152 gradcorr(j,i)=0.0d0
18153 gradcorr_long(j,i)=0.0d0
18154 gradcorr5_long(j,i)=0.0d0
18155 gradcorr6_long(j,i)=0.0d0
18156 gcorr6_turn_long(j,i)=0.0d0
18157 gradcorr5(j,i)=0.0d0
18158 gradcorr6(j,i)=0.0d0
18159 gcorr6_turn(j,i)=0.0d0
18162 gradc(j,i,icg)=0.0d0
18163 gradx(j,i,icg)=0.0d0
18166 gliptran(j,i)=0.0d0
18167 gliptranx(j,i)=0.0d0
18168 gliptranc(j,i)=0.0d0
18169 gshieldx(j,i)=0.0d0
18170 gshieldc(j,i)=0.0d0
18171 gshieldc_loc(j,i)=0.0d0
18172 gshieldx_ec(j,i)=0.0d0
18173 gshieldc_ec(j,i)=0.0d0
18174 gshieldc_loc_ec(j,i)=0.0d0
18175 gshieldx_t3(j,i)=0.0d0
18176 gshieldc_t3(j,i)=0.0d0
18177 gshieldc_loc_t3(j,i)=0.0d0
18178 gshieldx_t4(j,i)=0.0d0
18179 gshieldc_t4(j,i)=0.0d0
18180 gshieldc_loc_t4(j,i)=0.0d0
18181 gshieldx_ll(j,i)=0.0d0
18182 gshieldc_ll(j,i)=0.0d0
18183 gshieldc_loc_ll(j,i)=0.0d0
18185 gg_tube_sc(j,i)=0.0d0
18187 gradb_nucl(j,i)=0.0d0
18188 gradbx_nucl(j,i)=0.0d0
18189 gvdwpp_nucl(j,i)=0.0d0
18193 gvdwpsb1(j,i)=0.0d0
18197 gradcorr_nucl(j,i)=0.0d0
18198 gradcorr3_nucl(j,i)=0.0d0
18199 gradxorr_nucl(j,i)=0.0d0
18200 gradxorr3_nucl(j,i)=0.0d0
18204 gradpepcat(j,i)=0.0d0
18205 gradpepcatx(j,i)=0.0d0
18206 gradcatcat(j,i)=0.0d0
18207 gvdwx_scbase(j,i)=0.0d0
18208 gvdwc_scbase(j,i)=0.0d0
18209 gvdwx_pepbase(j,i)=0.0d0
18210 gvdwc_pepbase(j,i)=0.0d0
18211 gvdwx_scpho(j,i)=0.0d0
18212 gvdwc_scpho(j,i)=0.0d0
18213 gvdwc_peppho(j,i)=0.0d0
18214 gradnuclcatx(j,i)=0.0d0
18215 gradnuclcat(j,i)=0.0d0
18216 gradlipbond(j,i)=0.0d0
18217 gradlipang(j,i)=0.0d0
18218 gradliplj(j,i)=0.0d0
18219 gradlipelec(j,i)=0.0d0
18220 gradcattranc(j,i)=0.0d0
18221 gradcattranx(j,i)=0.0d0
18222 gradcatangx(j,i)=0.0d0
18223 gradcatangc(j,i)=0.0d0
18224 duscdiff(j,i)=0.0d0
18225 duscdiffx(j,i)=0.0d0
18231 gloc_sc(intertyp,i,icg)=0.0d0
18240 grad_shield_side(k,j,i)=0.0d0
18241 grad_shield_loc(k,j,i)=0.0d0
18248 ! Initialize the gradient of local energy terms.
18250 ! allocate(gloc(4*nres,2)) !!(maxvar,2)(maxvar=6*maxres)
18251 ! if (.not.allocated(gel_loc_loc)) allocate(gel_loc_loc(nres)) !(maxvar)(maxvar=6*maxres)
18252 ! if (.not.allocated(gcorr_loc)) allocate(gcorr_loc(nres)) !(maxvar)(maxvar=6*maxres)
18253 ! allocate(g_corr5_loc(nres),g_corr6_loc(nres)) !(maxvar)(maxvar=6*maxres)
18254 ! allocate(gel_loc_turn3(nres))
18255 ! allocate(gel_loc_turn4(nres),gel_loc_turn6(nres)) !(maxvar)(maxvar=6*maxres)
18256 ! allocate(gsccor_loc(nres)) !(maxres)
18262 gel_loc_loc(i)=0.0d0
18264 g_corr5_loc(i)=0.0d0
18265 g_corr6_loc(i)=0.0d0
18266 gel_loc_turn3(i)=0.0d0
18267 gel_loc_turn4(i)=0.0d0
18268 gel_loc_turn6(i)=0.0d0
18269 gsccor_loc(i)=0.0d0
18271 ! initialize gcart and gxcart
18272 ! allocate(gcart(3,0:nres),gxcart(3,0:nres)) !(3,0:MAXRES)
18280 end subroutine zerograd
18281 !-----------------------------------------------------------------------------
18282 real(kind=8) function fdum()
18286 !-----------------------------------------------------------------------------
18288 !-----------------------------------------------------------------------------
18289 subroutine intcartderiv
18290 ! implicit real(kind=8) (a-h,o-z)
18291 ! include 'DIMENSIONS'
18295 ! include 'COMMON.SETUP'
18296 ! include 'COMMON.CHAIN'
18297 ! include 'COMMON.VAR'
18298 ! include 'COMMON.GEO'
18299 ! include 'COMMON.INTERACT'
18300 ! include 'COMMON.DERIV'
18301 ! include 'COMMON.IOUNITS'
18302 ! include 'COMMON.LOCAL'
18303 ! include 'COMMON.SCCOR'
18304 real(kind=8) :: pi4,pi34
18305 real(kind=8),dimension(3,2,nres) :: dcostheta ! (3,2,maxres)
18306 real(kind=8),dimension(3,3,nres) :: dcosphi,dsinphi,dcosalpha,&
18307 dcosomega,dsinomega !(3,3,maxres)
18308 real(kind=8),dimension(3) :: vo1,vo2,vo3,dummy,vp1,vp2,vp3,vpp1,n
18311 real(kind=8) :: cost,sint,cost1,sint1,cost2,sint2,sing,cosg,scalp,&
18312 fac0,fac1,fac2,fac3,fac4,fac5,fac6,ctgt,ctgt1,cosg_inv,&
18313 fac7,fac8,fac9,scala1,scala2,cosa,sina,sino,fac15,fac16,&
18314 fac17,coso_inv,fac10,fac11,fac12,fac13,fac14,IERROR
18318 !el from module energy-------------
18319 !el allocate(dcostau(3,3,3,itau_start:itau_end)) !(3,3,3,maxres2)maxres2=2*maxres
18320 !el allocate(dsintau(3,3,3,itau_start:itau_end))
18321 !el allocate(dtauangle(3,3,3,itau_start:itau_end))
18323 !el allocate(dcostau(3,3,3,0:nres2)) !(3,3,3,maxres2)maxres2=2*maxres
18324 !el allocate(dsintau(3,3,3,0:nres2))
18325 !el allocate(dtauangle(3,3,3,0:nres2))
18326 !el allocate(domicron(3,2,2,0:nres2))
18327 !el allocate(dcosomicron(3,2,2,0:nres2))
18331 #if defined(MPI) && defined(PARINTDER)
18332 if (nfgtasks.gt.1 .and. me.eq.king) &
18333 call MPI_Bcast(8,1,MPI_INTEGER,king,FG_COMM,IERROR)
18338 ! allocate(dtheta(3,2,nres)) !(3,2,maxres)
18339 ! allocate(dphi(3,3,nres),dalpha(3,3,nres),domega(3,3,nres)) !(3,3,maxres)
18341 ! write (iout,*) "iphi1_start",iphi1_start," iphi1_end",iphi1_end
18344 dtheta(j,1,i)=0.0d0
18345 dtheta(j,2,i)=0.0d0
18349 dcosomicron(j,1,1,i)=0.0d0
18350 dcosomicron(j,1,2,i)=0.0d0
18351 dcosomicron(j,2,1,i)=0.0d0
18352 dcosomicron(j,2,2,i)=0.0d0
18355 ! Derivatives of theta's
18356 #if defined(MPI) && defined(PARINTDER)
18357 ! We need dtheta(:,:,i-1) to compute dphi(:,:,i)
18358 do i=max0(ithet_start-1,3),ithet_end
18362 cost=dcos(theta(i))
18363 sint=sqrt(1-cost*cost)
18365 dcostheta(j,1,i)=-(dc_norm(j,i-1)+cost*dc_norm(j,i-2))/&
18367 if (((itype(i-1,1).ne.ntyp1).and.(sint.ne.0.0d0))) &
18368 dtheta(j,1,i)=-dcostheta(j,1,i)/sint
18369 dcostheta(j,2,i)=-(dc_norm(j,i-2)+cost*dc_norm(j,i-1))/&
18371 if ((itype(i-1,1).ne.ntyp1).and.(sint.ne.0.0d0))&
18372 dtheta(j,2,i)=-dcostheta(j,2,i)/sint
18375 #if defined(MPI) && defined(PARINTDER)
18376 ! We need dtheta(:,:,i-1) to compute dphi(:,:,i)
18377 do i=max0(ithet_start-1,3),ithet_end
18381 if ((itype(i-1,1).ne.10).and.(itype(i-1,1).ne.ntyp1).and.molnum(i).lt.4) then
18382 cost1=dcos(omicron(1,i))
18383 sint1=sqrt(1-cost1*cost1)
18384 cost2=dcos(omicron(2,i))
18385 sint2=sqrt(1-cost2*cost2)
18387 !C Calculate derivative over first omicron (Cai-2,Cai-1,SCi-1)
18388 dcosomicron(j,1,1,i)=-(dc_norm(j,i-1+nres)+ &
18389 cost1*dc_norm(j,i-2))/ &
18391 domicron(j,1,1,i)=-1.0/sint1*dcosomicron(j,1,1,i)
18392 dcosomicron(j,1,2,i)=-(dc_norm(j,i-2) &
18393 +cost1*(dc_norm(j,i-1+nres)))/ &
18395 domicron(j,1,2,i)=-1.0/sint1*dcosomicron(j,1,2,i)
18396 !C Calculate derivative over second omicron Sci-1,Cai-1 Cai
18397 !C Looks messy but better than if in loop
18398 dcosomicron(j,2,1,i)=-(-dc_norm(j,i-1+nres) &
18399 +cost2*dc_norm(j,i-1))/ &
18401 domicron(j,2,1,i)=-1.0/sint2*dcosomicron(j,2,1,i)
18402 dcosomicron(j,2,2,i)=-(dc_norm(j,i-1) &
18403 +cost2*(-dc_norm(j,i-1+nres)))/ &
18405 ! write(iout,*) "vbld", i,itype(i,1),vbld(i-1+nres)
18406 domicron(j,2,2,i)=-1.0/sint2*dcosomicron(j,2,2,i)
18410 !elwrite(iout,*) "after vbld write"
18411 ! Derivatives of phi:
18412 ! If phi is 0 or 180 degrees, then the formulas
18413 ! have to be derived by power series expansion of the
18414 ! conventional formulas around 0 and 180.
18416 do i=iphi1_start,iphi1_end
18420 ! if (itype(i-1,1).eq.21 .or. itype(i-2,1).eq.21 ) cycle
18421 ! the conventional case
18422 sint=dsin(theta(i))
18423 sint1=dsin(theta(i-1))
18425 cost=dcos(theta(i))
18426 cost1=dcos(theta(i-1))
18428 scalp=scalar(dc_norm(1,i-3),dc_norm(1,i-1))
18429 if ((sint*sint1).eq.0.0d0) then
18432 fac0=1.0d0/(sint1*sint)
18436 if (sint1.ne.0.0d0) then
18437 fac3=cosg*cost1/(sint1*sint1)
18441 if (sint.ne.0.0d0) then
18442 fac4=cosg*cost/(sint*sint)
18446 ! Obtaining the gamma derivatives from sine derivative
18447 if (phi(i).gt.-pi4.and.phi(i).le.pi4.or. &
18448 phi(i).gt.pi34.and.phi(i).le.pi.or. &
18449 phi(i).ge.-pi.and.phi(i).le.-pi34) then
18450 call vecpr(dc_norm(1,i-1),dc_norm(1,i-2),vp1)
18451 call vecpr(dc_norm(1,i-3),dc_norm(1,i-1),vp2)
18452 call vecpr(dc_norm(1,i-3),dc_norm(1,i-2),vp3)
18454 if (sint.ne.0.0d0) then
18459 if (sint1.ne.0.0d0) then
18464 cosg_inv=1.0d0/cosg
18465 ! if (itype(i-1,1).ne.ntyp1 .and. itype(i-2,1).ne.ntyp1) then
18466 dsinphi(j,1,i)=-sing*ctgt1*dtheta(j,1,i-1) &
18467 -(fac0*vp1(j)+sing*dc_norm(j,i-3))*vbld_inv(i-2)
18468 dphi(j,1,i)=cosg_inv*dsinphi(j,1,i)
18470 -sing*(ctgt1*dtheta(j,2,i-1)+ctgt*dtheta(j,1,i)) &
18471 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
18472 dphi(j,2,i)=cosg_inv*dsinphi(j,2,i)
18473 dsinphi(j,3,i)=-sing*ctgt*dtheta(j,2,i) &
18474 +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i)
18475 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
18476 dphi(j,3,i)=cosg_inv*dsinphi(j,3,i)
18478 ! write(iout,*) "just after,close to pi",dphi(j,3,i),&
18479 ! sing*(ctgt1*dtheta(j,2,i-1)),ctgt*dtheta(j,1,i), &
18480 ! (fac0*vp2(j)+sing*dc_norm(j,i-2)),vbld_inv(i-1)
18482 ! Bug fixed 3/24/05 (AL)
18484 ! Obtaining the gamma derivatives from cosine derivative
18487 ! if (itype(i-1,1).ne.ntyp1 .and. itype(i-2,1).ne.ntyp1) then
18488 dcosphi(j,1,i)=fac1*dcostheta(j,1,i-1)+fac3* &
18489 dcostheta(j,1,i-1)-fac0*(dc_norm(j,i-1)-scalp* &
18490 dc_norm(j,i-3))/vbld(i-2)
18491 dphi(j,1,i)=-1.0/sing*dcosphi(j,1,i)
18492 dcosphi(j,2,i)=fac1*dcostheta(j,2,i-1)+fac2* &
18493 dcostheta(j,1,i)+fac3*dcostheta(j,2,i-1)+fac4* &
18495 dphi(j,2,i)=-1.0/sing*dcosphi(j,2,i)
18496 dcosphi(j,3,i)=fac2*dcostheta(j,2,i)+fac4* &
18497 dcostheta(j,2,i)-fac0*(dc_norm(j,i-3)-scalp* &
18498 dc_norm(j,i-1))/vbld(i)
18499 dphi(j,3,i)=-1.0/sing*dcosphi(j,3,i)
18502 write(iout,*) "just after",dphi(j,3,i),sing,dcosphi(j,3,i)
18509 !alculate derivative of Tauangle
18511 do i=itau_start,itau_end
18514 !elwrite(iout,*) " vecpr",i,nres
18516 if ((itype(i-2,1).eq.ntyp1).or.(itype(i-2,1).eq.10)) cycle
18517 ! if ((itype(i-2,1).eq.ntyp1).or.(itype(i-2,1).eq.10).or.
18518 ! & (itype(i-1,1).eq.ntyp1).or.(itype(i,1).eq.ntyp1)) cycle
18519 !c dtauangle(j,intertyp,dervityp,residue number)
18520 !c INTERTYP=1 SC...Ca...Ca..Ca
18521 ! the conventional case
18522 sint=dsin(theta(i))
18523 sint1=dsin(omicron(2,i-1))
18524 sing=dsin(tauangle(1,i))
18525 cost=dcos(theta(i))
18526 cost1=dcos(omicron(2,i-1))
18527 cosg=dcos(tauangle(1,i))
18528 !elwrite(iout,*) " vecpr5",i,nres
18530 !elwrite(iout,*) " vecpreee",i,nres,j,i-2+nres
18531 !elwrite(iout,*) " vecpr5",dc_norm2(1,1)
18532 dc_norm2(j,i-2+nres)=-dc_norm(j,i-2+nres)
18533 ! write(iout,*) dc_norm2(j,i-2+nres),"dcnorm"
18535 scalp=scalar(dc_norm2(1,i-2+nres),dc_norm(1,i-1))
18536 ! write(iout,*) "faki",fac0,fac1,fac2,fac3,fac
18537 if ((sint*sint1).eq.0.0d0) then
18540 fac0=1.0d0/(sint1*sint)
18544 if (sint1.ne.0.0d0) then
18545 fac3=cosg*cost1/(sint1*sint1)
18549 if (sint.ne.0.0d0) then
18550 fac4=cosg*cost/(sint*sint)
18555 ! Obtaining the gamma derivatives from sine derivative
18556 if (tauangle(1,i).gt.-pi4.and.tauangle(1,i).le.pi4.or. &
18557 tauangle(1,i).gt.pi34.and.tauangle(1,i).le.pi.or. &
18558 tauangle(1,i).gt.-pi.and.tauangle(1,i).le.-pi34) then
18559 call vecpr(dc_norm(1,i-1),dc_norm(1,i-2),vp1)
18560 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-1),vp2)
18561 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-2),vp3)
18565 cosg_inv=1.0d0/cosg
18566 dsintau(j,1,1,i)=-sing*ctgt1*domicron(j,2,2,i-1) &
18567 -(fac0*vp1(j)+sing*(dc_norm2(j,i-2+nres))) &
18568 *vbld_inv(i-2+nres)
18569 dtauangle(j,1,1,i)=cosg_inv*dsintau(j,1,1,i)
18570 dsintau(j,1,2,i)= &
18571 -sing*(ctgt1*domicron(j,2,1,i-1)+ctgt*dtheta(j,1,i)) &
18572 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
18573 ! write(iout,*) "dsintau", dsintau(j,1,2,i)
18574 dtauangle(j,1,2,i)=cosg_inv*dsintau(j,1,2,i)
18575 ! Bug fixed 3/24/05 (AL)
18576 dsintau(j,1,3,i)=-sing*ctgt*dtheta(j,2,i) &
18577 +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i)
18578 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
18579 dtauangle(j,1,3,i)=cosg_inv*dsintau(j,1,3,i)
18581 ! Obtaining the gamma derivatives from cosine derivative
18584 dcostau(j,1,1,i)=fac1*dcosomicron(j,2,2,i-1)+fac3* &
18585 dcosomicron(j,2,2,i-1)-fac0*(dc_norm(j,i-1)-scalp* &
18586 (dc_norm2(j,i-2+nres)))/vbld(i-2+nres)
18587 dtauangle(j,1,1,i)=-1/sing*dcostau(j,1,1,i)
18588 dcostau(j,1,2,i)=fac1*dcosomicron(j,2,1,i-1)+fac2* &
18589 dcostheta(j,1,i)+fac3*dcosomicron(j,2,1,i-1)+fac4* &
18591 dtauangle(j,1,2,i)=-1/sing*dcostau(j,1,2,i)
18592 dcostau(j,1,3,i)=fac2*dcostheta(j,2,i)+fac4* &
18593 dcostheta(j,2,i)-fac0*(-dc_norm(j,i-2+nres)-scalp* &
18594 dc_norm(j,i-1))/vbld(i)
18595 dtauangle(j,1,3,i)=-1/sing*dcostau(j,1,3,i)
18596 ! write (iout,*) "else",i
18600 ! write(iout,*) "tu",i,k,(dtauangle(j,1,k,i),j=1,3)
18603 !C Second case Ca...Ca...Ca...SC
18605 do i=itau_start,itau_end
18609 if ((itype(i-1,1).eq.ntyp1).or.(itype(i-1,1).eq.10).or. &
18610 (itype(i-2,1).eq.ntyp1).or.(itype(i-3,1).eq.ntyp1)) cycle
18611 ! the conventional case
18612 sint=dsin(omicron(1,i))
18613 sint1=dsin(theta(i-1))
18614 sing=dsin(tauangle(2,i))
18615 cost=dcos(omicron(1,i))
18616 cost1=dcos(theta(i-1))
18617 cosg=dcos(tauangle(2,i))
18619 ! dc_norm2(j,i-1+nres)=-dc_norm(j,i-1+nres)
18621 scalp=scalar(dc_norm(1,i-3),dc_norm(1,i-1+nres))
18622 if ((sint*sint1).eq.0.0d0) then
18625 fac0=1.0d0/(sint1*sint)
18629 if (sint1.ne.0.0d0) then
18630 fac3=cosg*cost1/(sint1*sint1)
18634 if (sint.ne.0.0d0) then
18635 fac4=cosg*cost/(sint*sint)
18639 ! Obtaining the gamma derivatives from sine derivative
18640 if (tauangle(2,i).gt.-pi4.and.tauangle(2,i).le.pi4.or. &
18641 tauangle(2,i).gt.pi34.and.tauangle(2,i).le.pi.or. &
18642 tauangle(2,i).gt.-pi.and.tauangle(2,i).le.-pi34) then
18643 call vecpr(dc_norm2(1,i-1+nres),dc_norm(1,i-2),vp1)
18644 call vecpr(dc_norm(1,i-3),dc_norm(1,i-1+nres),vp2)
18645 call vecpr(dc_norm(1,i-3),dc_norm(1,i-2),vp3)
18649 cosg_inv=1.0d0/cosg
18650 dsintau(j,2,1,i)=-sing*ctgt1*dtheta(j,1,i-1) &
18651 +(fac0*vp1(j)-sing*dc_norm(j,i-3))*vbld_inv(i-2)
18652 ! write(iout,*) i,j,dsintau(j,2,1,i),sing*ctgt1*dtheta(j,1,i-1),
18653 ! &fac0*vp1(j),sing*dc_norm(j,i-3),vbld_inv(i-2),"dsintau(2,1)"
18654 dtauangle(j,2,1,i)=cosg_inv*dsintau(j,2,1,i)
18655 dsintau(j,2,2,i)= &
18656 -sing*(ctgt1*dtheta(j,2,i-1)+ctgt*domicron(j,1,1,i)) &
18657 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
18658 ! write(iout,*) "sprawdzenie",i,j,sing*ctgt1*dtheta(j,2,i-1),
18659 ! & sing*ctgt*domicron(j,1,2,i),
18660 ! & (fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
18661 dtauangle(j,2,2,i)=cosg_inv*dsintau(j,2,2,i)
18662 ! Bug fixed 3/24/05 (AL)
18663 dsintau(j,2,3,i)=-sing*ctgt*domicron(j,1,2,i) &
18664 +(fac0*vp3(j)-sing*dc_norm(j,i-1+nres))*vbld_inv(i-1+nres)
18665 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
18666 dtauangle(j,2,3,i)=cosg_inv*dsintau(j,2,3,i)
18668 ! Obtaining the gamma derivatives from cosine derivative
18671 dcostau(j,2,1,i)=fac1*dcostheta(j,1,i-1)+fac3* &
18672 dcostheta(j,1,i-1)-fac0*(dc_norm(j,i-1+nres)-scalp* &
18673 dc_norm(j,i-3))/vbld(i-2)
18674 dtauangle(j,2,1,i)=-1/sing*dcostau(j,2,1,i)
18675 dcostau(j,2,2,i)=fac1*dcostheta(j,2,i-1)+fac2* &
18676 dcosomicron(j,1,1,i)+fac3*dcostheta(j,2,i-1)+fac4* &
18677 dcosomicron(j,1,1,i)
18678 dtauangle(j,2,2,i)=-1/sing*dcostau(j,2,2,i)
18679 dcostau(j,2,3,i)=fac2*dcosomicron(j,1,2,i)+fac4* &
18680 dcosomicron(j,1,2,i)-fac0*(dc_norm(j,i-3)-scalp* &
18681 dc_norm(j,i-1+nres))/vbld(i-1+nres)
18682 dtauangle(j,2,3,i)=-1/sing*dcostau(j,2,3,i)
18683 ! write(iout,*) i,j,"else", dtauangle(j,2,3,i)
18688 !CC third case SC...Ca...Ca...SC
18691 do i=itau_start,itau_end
18695 ! the conventional case
18696 if ((itype(i-1,1).eq.ntyp1).or.(itype(i-1,1).eq.10).or. &
18697 (itype(i-2,1).eq.ntyp1).or.(itype(i-2,1).eq.10)) cycle
18698 sint=dsin(omicron(1,i))
18699 sint1=dsin(omicron(2,i-1))
18700 sing=dsin(tauangle(3,i))
18701 cost=dcos(omicron(1,i))
18702 cost1=dcos(omicron(2,i-1))
18703 cosg=dcos(tauangle(3,i))
18705 dc_norm2(j,i-2+nres)=-dc_norm(j,i-2+nres)
18706 ! dc_norm2(j,i-1+nres)=-dc_norm(j,i-1+nres)
18708 scalp=scalar(dc_norm2(1,i-2+nres),dc_norm(1,i-1+nres))
18709 if ((sint*sint1).eq.0.0d0) then
18712 fac0=1.0d0/(sint1*sint)
18716 if (sint1.ne.0.0d0) then
18717 fac3=cosg*cost1/(sint1*sint1)
18721 if (sint.ne.0.0d0) then
18722 fac4=cosg*cost/(sint*sint)
18726 ! Obtaining the gamma derivatives from sine derivative
18727 if (tauangle(3,i).gt.-pi4.and.tauangle(3,i).le.pi4.or. &
18728 tauangle(3,i).gt.pi34.and.tauangle(3,i).le.pi.or. &
18729 tauangle(3,i).gt.-pi.and.tauangle(3,i).le.-pi34) then
18730 call vecpr(dc_norm(1,i-1+nres),dc_norm(1,i-2),vp1)
18731 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-1+nres),vp2)
18732 call vecpr(dc_norm2(1,i-2+nres),dc_norm(1,i-2),vp3)
18736 cosg_inv=1.0d0/cosg
18737 dsintau(j,3,1,i)=-sing*ctgt1*domicron(j,2,2,i-1) &
18738 -(fac0*vp1(j)-sing*dc_norm(j,i-2+nres)) &
18739 *vbld_inv(i-2+nres)
18740 dtauangle(j,3,1,i)=cosg_inv*dsintau(j,3,1,i)
18741 dsintau(j,3,2,i)= &
18742 -sing*(ctgt1*domicron(j,2,1,i-1)+ctgt*domicron(j,1,1,i)) &
18743 -(fac0*vp2(j)+sing*dc_norm(j,i-2))*vbld_inv(i-1)
18744 dtauangle(j,3,2,i)=cosg_inv*dsintau(j,3,2,i)
18745 ! Bug fixed 3/24/05 (AL)
18746 dsintau(j,3,3,i)=-sing*ctgt*domicron(j,1,2,i) &
18747 +(fac0*vp3(j)-sing*dc_norm(j,i-1+nres)) &
18748 *vbld_inv(i-1+nres)
18749 ! & +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
18750 dtauangle(j,3,3,i)=cosg_inv*dsintau(j,3,3,i)
18752 ! Obtaining the gamma derivatives from cosine derivative
18755 dcostau(j,3,1,i)=fac1*dcosomicron(j,2,2,i-1)+fac3* &
18756 dcosomicron(j,2,2,i-1)-fac0*(dc_norm(j,i-1+nres)-scalp* &
18757 dc_norm2(j,i-2+nres))/vbld(i-2+nres)
18758 dtauangle(j,3,1,i)=-1/sing*dcostau(j,3,1,i)
18759 dcostau(j,3,2,i)=fac1*dcosomicron(j,2,1,i-1)+fac2* &
18760 dcosomicron(j,1,1,i)+fac3*dcosomicron(j,2,1,i-1)+fac4* &
18761 dcosomicron(j,1,1,i)
18762 dtauangle(j,3,2,i)=-1/sing*dcostau(j,3,2,i)
18763 dcostau(j,3,3,i)=fac2*dcosomicron(j,1,2,i)+fac4* &
18764 dcosomicron(j,1,2,i)-fac0*(dc_norm2(j,i-2+nres)-scalp* &
18765 dc_norm(j,i-1+nres))/vbld(i-1+nres)
18766 dtauangle(j,3,3,i)=-1/sing*dcostau(j,3,3,i)
18767 ! write(iout,*) "else",i
18773 ! Derivatives of side-chain angles alpha and omega
18774 #if defined(MPI) && defined(PARINTDER)
18775 do i=ibond_start,ibond_end
18779 if(itype(i,1).ne.10 .and. itype(i,1).ne.ntyp1) then
18780 fac5=1.0d0/dsqrt(2*(1+dcos(theta(i+1))))
18783 fac8=fac5/vbld(i+1)
18784 fac9=fac5/vbld(i+nres)
18785 scala1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
18786 scala2=scalar(dc_norm(1,i),dc_norm(1,i+nres))
18787 cosa=dsqrt(0.5d0/(1.0d0+dcos(theta(i+1))))* &
18788 (scalar(dC_norm(1,i),dC_norm(1,i+nres)) &
18789 -scalar(dC_norm(1,i-1),dC_norm(1,i+nres)))
18790 sina=sqrt(1-cosa*cosa)
18792 ! write (iout,*) "i",i," cosa",cosa," sina",sina," sino",sino
18794 dcosalpha(j,1,i)=fac6*(scala1*dc_norm(j,i-1)- &
18795 dc_norm(j,i+nres))-cosa*fac7*dcostheta(j,1,i+1)
18796 dalpha(j,1,i)=-1/sina*dcosalpha(j,1,i)
18797 dcosalpha(j,2,i)=fac8*(dc_norm(j,i+nres)- &
18798 scala2*dc_norm(j,i))-cosa*fac7*dcostheta(j,2,i+1)
18799 dalpha(j,2,i)=-1/sina*dcosalpha(j,2,i)
18800 dcosalpha(j,3,i)=(fac9*(dc_norm(j,i)- &
18801 dc_norm(j,i-1))-(cosa*dc_norm(j,i+nres))/ &
18803 dalpha(j,3,i)=-1/sina*dcosalpha(j,3,i)
18805 ! obtaining the derivatives of omega from sines
18806 if(omeg(i).gt.-pi4.and.omeg(i).le.pi4.or. &
18807 omeg(i).gt.pi34.and.omeg(i).le.pi.or. &
18808 omeg(i).gt.-pi.and.omeg(i).le.-pi34) then
18809 fac15=dcos(theta(i+1))/(dsin(theta(i+1))* &
18811 fac16=dcos(alph(i))/(dsin(alph(i))*dsin(alph(i)))
18812 fac17=1.0d0/(dsin(theta(i+1))*dsin(alph(i)))
18813 call vecpr(dc_norm(1,i+nres),dc_norm(1,i),vo1)
18814 call vecpr(dc_norm(1,i+nres),dc_norm(1,i-1),vo2)
18815 call vecpr(dc_norm(1,i),dc_norm(1,i-1),vo3)
18816 coso_inv=1.0d0/dcos(omeg(i))
18818 dsinomega(j,1,i)=sino*(fac15*dcostheta(j,1,i+1) &
18819 +fac16*dcosalpha(j,1,i))-fac17/vbld(i)*vo1(j)- &
18820 (sino*dc_norm(j,i-1))/vbld(i)
18821 domega(j,1,i)=coso_inv*dsinomega(j,1,i)
18822 dsinomega(j,2,i)=sino*(fac15*dcostheta(j,2,i+1) &
18823 +fac16*dcosalpha(j,2,i))+fac17/vbld(i+1)*vo2(j) &
18824 -sino*dc_norm(j,i)/vbld(i+1)
18825 domega(j,2,i)=coso_inv*dsinomega(j,2,i)
18826 dsinomega(j,3,i)=sino*fac16*dcosalpha(j,3,i)- &
18827 fac17/vbld(i+nres)*vo3(j)-sino*dc_norm(j,i+nres)/ &
18829 domega(j,3,i)=coso_inv*dsinomega(j,3,i)
18832 ! obtaining the derivatives of omega from cosines
18833 fac10=sqrt(0.5d0*(1-dcos(theta(i+1))))
18834 fac11=sqrt(0.5d0*(1+dcos(theta(i+1))))
18839 dcosomega(j,1,i)=(-(0.25d0*cosa/fac11* &
18840 dcostheta(j,1,i+1)+fac11*dcosalpha(j,1,i))*fac12+ &
18841 (0.25d0/fac10*sina*dcostheta(j,1,i+1)+cosa/sina* &
18842 fac10*dcosalpha(j,1,i))*(scala2-fac11*cosa))/fac13
18843 domega(j,1,i)=-1/sino*dcosomega(j,1,i)
18844 dcosomega(j,2,i)=(((dc_norm(j,i+nres)-scala2* &
18845 dc_norm(j,i))/vbld(i+1)-0.25d0*cosa/fac11* &
18846 dcostheta(j,2,i+1)-fac11*dcosalpha(j,2,i))*fac12+ &
18847 (scala2-fac11*cosa)*(0.25d0*sina/fac10* &
18848 dcostheta(j,2,i+1)+fac10*cosa/sina*dcosalpha(j,2,i)))/fac13
18849 domega(j,2,i)=-1/sino*dcosomega(j,2,i)
18850 dcosomega(j,3,i)=1/fac10*((1/vbld(i+nres)*(dc_norm(j,i)- &
18851 scala2*dc_norm(j,i+nres))-fac11*dcosalpha(j,3,i))*sina+ &
18852 (scala2-fac11*cosa)*(cosa/sina*dcosalpha(j,3,i)))/fac14
18853 domega(j,3,i)=-1/sino*dcosomega(j,3,i)
18859 dalpha(k,j,i)=0.0d0
18860 domega(k,j,i)=0.0d0
18866 #if defined(MPI) && defined(PARINTDER)
18867 if (nfgtasks.gt.1) then
18869 !d write (iout,*) "Gather dtheta"
18870 !d call flush(iout)
18871 write (iout,*) "dtheta before gather"
18873 write (iout,'(i3,3(3f8.5,3x))') i,((dtheta(j,k,i),k=1,3),j=1,2)
18876 call MPI_Gatherv(dtheta(1,1,ithet_start),ithet_count(fg_rank),&
18877 MPI_THET,dtheta(1,1,1),ithet_count(0),ithet_displ(0),MPI_THET,&
18878 king,FG_COMM,IERROR)
18881 !d write (iout,*) "Gather dphi"
18882 !d call flush(iout)
18883 write (iout,*) "dphi before gather"
18885 write (iout,'(i3,3(3f8.5,3x))') i,((dphi(j,k,i),k=1,3),j=1,3)
18889 call MPI_Gatherv(dphi(1,1,iphi1_start),iphi1_count(fg_rank),&
18890 MPI_GAM,dphi(1,1,1),iphi1_count(0),iphi1_displ(0),MPI_GAM,&
18891 king,FG_COMM,IERROR)
18892 !d write (iout,*) "Gather dalpha"
18893 !d call flush(iout)
18895 call MPI_Gatherv(dalpha(1,1,ibond_start),ibond_count(fg_rank),&
18896 MPI_GAM,dalpha(1,1,1),ibond_count(0),ibond_displ(0),MPI_GAM,&
18897 king,FG_COMM,IERROR)
18898 !d write (iout,*) "Gather domega"
18899 !d call flush(iout)
18900 call MPI_Gatherv(domega(1,1,ibond_start),ibond_count(fg_rank),&
18901 MPI_GAM,domega(1,1,1),ibond_count(0),ibond_displ(0),MPI_GAM,&
18902 king,FG_COMM,IERROR)
18908 write (iout,*) "dtheta after gather"
18910 write (iout,'(i3,3(3f8.5,3x))') i,((dtheta(j,k,i),j=1,3),k=1,2)
18912 write (iout,*) "dphi after gather"
18914 write (iout,'(i3,3(3f8.5,3x))') i,((dphi(j,k,i),j=1,3),k=1,3)
18916 write (iout,*) "dalpha after gather"
18918 write (iout,'(i3,3(3f8.5,3x))') i,((dalpha(j,k,i),j=1,3),k=1,3)
18920 write (iout,*) "domega after gather"
18922 write (iout,'(i3,3(3f8.5,3x))') i,((domega(j,k,i),j=1,3),k=1,3)
18927 end subroutine intcartderiv
18928 !-----------------------------------------------------------------------------
18929 subroutine checkintcartgrad
18930 ! implicit real(kind=8) (a-h,o-z)
18931 ! include 'DIMENSIONS'
18935 ! include 'COMMON.CHAIN'
18936 ! include 'COMMON.VAR'
18937 ! include 'COMMON.GEO'
18938 ! include 'COMMON.INTERACT'
18939 ! include 'COMMON.DERIV'
18940 ! include 'COMMON.IOUNITS'
18941 ! include 'COMMON.SETUP'
18942 real(kind=8),dimension(3,2,nres) :: dthetanum !(3,2,maxres)
18943 real(kind=8),dimension(3,3,nres) :: dphinum,dalphanum,domeganum !(3,3,maxres)
18944 real(kind=8),dimension(nres) :: theta_s,phi_s,alph_s,omeg_s !(maxres)
18945 real(kind=8),dimension(3) :: dc_norm_s
18946 real(kind=8) :: aincr=1.0d-5
18948 real(kind=8) :: dcji
18951 theta_s(i)=theta(i)
18955 ! Check theta gradient
18957 "Analytical (upper) and numerical (lower) gradient of theta"
18962 dc(j,i-2)=dcji+aincr
18963 call chainbuild_cart
18964 call int_from_cart1(.false.)
18965 dthetanum(j,1,i)=(theta(i)-theta_s(i))/aincr
18968 dc(j,i-1)=dc(j,i-1)+aincr
18969 call chainbuild_cart
18970 dthetanum(j,2,i)=(theta(i)-theta_s(i))/aincr
18973 !el write (iout,'(i5,3f10.5,5x,3f10.5)') i,(dtheta(j,1,i),j=1,3),&
18974 !el (dtheta(j,2,i),j=1,3)
18975 !el write (iout,'(5x,3f10.5,5x,3f10.5)') (dthetanum(j,1,i),j=1,3),&
18976 !el (dthetanum(j,2,i),j=1,3)
18977 !el write (iout,'(5x,3f10.5,5x,3f10.5)') &
18978 !el (dthetanum(j,1,i)/dtheta(j,1,i),j=1,3),&
18979 !el (dthetanum(j,2,i)/dtheta(j,2,i),j=1,3)
18982 ! Check gamma gradient
18984 "Analytical (upper) and numerical (lower) gradient of gamma"
18988 dc(j,i-3)=dcji+aincr
18989 call chainbuild_cart
18990 dphinum(j,1,i)=(phi(i)-phi_s(i))/aincr
18993 dc(j,i-2)=dcji+aincr
18994 call chainbuild_cart
18995 dphinum(j,2,i)=(phi(i)-phi_s(i))/aincr
18998 dc(j,i-1)=dc(j,i-1)+aincr
18999 call chainbuild_cart
19000 dphinum(j,3,i)=(phi(i)-phi_s(i))/aincr
19003 !el write (iout,'(i5,3(3f10.5,5x))') i,(dphi(j,1,i),j=1,3),&
19004 !el (dphi(j,2,i),j=1,3),(dphi(j,3,i),j=1,3)
19005 !el write (iout,'(5x,3(3f10.5,5x))') (dphinum(j,1,i),j=1,3),&
19006 !el (dphinum(j,2,i),j=1,3),(dphinum(j,3,i),j=1,3)
19007 !el write (iout,'(5x,3(3f10.5,5x))') &
19008 !el (dphinum(j,1,i)/dphi(j,1,i),j=1,3),&
19009 !el (dphinum(j,2,i)/dphi(j,2,i),j=1,3),&
19010 !el (dphinum(j,3,i)/dphi(j,3,i),j=1,3)
19013 ! Check alpha gradient
19015 "Analytical (upper) and numerical (lower) gradient of alpha"
19017 if(itype(i,1).ne.10) then
19020 dc(j,i-1)=dcji+aincr
19021 call chainbuild_cart
19022 dalphanum(j,1,i)=(alph(i)-alph_s(i)) &
19027 call chainbuild_cart
19028 dalphanum(j,2,i)=(alph(i)-alph_s(i)) &
19032 dc(j,i+nres)=dc(j,i+nres)+aincr
19033 call chainbuild_cart
19034 dalphanum(j,3,i)=(alph(i)-alph_s(i)) &
19039 !el write (iout,'(i5,3(3f10.5,5x))') i,(dalpha(j,1,i),j=1,3),&
19040 !el (dalpha(j,2,i),j=1,3),(dalpha(j,3,i),j=1,3)
19041 !el write (iout,'(5x,3(3f10.5,5x))') (dalphanum(j,1,i),j=1,3),&
19042 !el (dalphanum(j,2,i),j=1,3),(dalphanum(j,3,i),j=1,3)
19043 !el write (iout,'(5x,3(3f10.5,5x))') &
19044 !el (dalphanum(j,1,i)/dalpha(j,1,i),j=1,3),&
19045 !el (dalphanum(j,2,i)/dalpha(j,2,i),j=1,3),&
19046 !el (dalphanum(j,3,i)/dalpha(j,3,i),j=1,3)
19049 ! Check omega gradient
19051 "Analytical (upper) and numerical (lower) gradient of omega"
19053 if(itype(i,1).ne.10) then
19056 dc(j,i-1)=dcji+aincr
19057 call chainbuild_cart
19058 domeganum(j,1,i)=(omeg(i)-omeg_s(i)) &
19063 call chainbuild_cart
19064 domeganum(j,2,i)=(omeg(i)-omeg_s(i)) &
19068 dc(j,i+nres)=dc(j,i+nres)+aincr
19069 call chainbuild_cart
19070 domeganum(j,3,i)=(omeg(i)-omeg_s(i)) &
19075 !el write (iout,'(i5,3(3f10.5,5x))') i,(domega(j,1,i),j=1,3),&
19076 !el (domega(j,2,i),j=1,3),(domega(j,3,i),j=1,3)
19077 !el write (iout,'(5x,3(3f10.5,5x))') (domeganum(j,1,i),j=1,3),&
19078 !el (domeganum(j,2,i),j=1,3),(domeganum(j,3,i),j=1,3)
19079 !el write (iout,'(5x,3(3f10.5,5x))') &
19080 !el (domeganum(j,1,i)/domega(j,1,i),j=1,3),&
19081 !el (domeganum(j,2,i)/domega(j,2,i),j=1,3),&
19082 !el (domeganum(j,3,i)/domega(j,3,i),j=1,3)
19086 end subroutine checkintcartgrad
19087 !-----------------------------------------------------------------------------
19089 !-----------------------------------------------------------------------------
19090 real(kind=8) function qwolynes(seg1,seg2,flag,seg3,seg4)
19091 ! implicit real(kind=8) (a-h,o-z)
19092 ! include 'DIMENSIONS'
19093 ! include 'COMMON.IOUNITS'
19094 ! include 'COMMON.CHAIN'
19095 ! include 'COMMON.INTERACT'
19096 ! include 'COMMON.VAR'
19097 integer :: i,j,jl,k,l,il,kl,nl,np,ip,kp,seg1,seg2,seg3,seg4,secseg
19098 integer :: kkk,nsep=3
19099 real(kind=8) :: qm !dist,
19100 real(kind=8) :: qq,qqij,qqijCM,dij,d0ij,dijCM,d0ijCM,qqmax
19101 logical :: lprn=.false.
19103 ! real(kind=8) :: sigm,x
19105 !el sigm(x)=0.25d0*x ! local function
19111 do il=seg1+nsep,seg2
19114 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2 + &
19115 (cref(2,jl,kkk)-cref(2,il,kkk))**2 + &
19116 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
19118 qqij = dexp(-0.5d0*((dij-d0ij)/(sigm(d0ij)))**2)
19119 if (itype(il,1).ne.10 .or. itype(jl,1).ne.10) then
19122 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
19123 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
19124 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
19125 dijCM=dist(il+nres,jl+nres)
19126 qqijCM = dexp(-0.5d0*((dijCM-d0ijCM)/(sigm(d0ijCM)))**2)
19128 qq = qq+qqij+qqijCM
19134 if((seg3-il).lt.3) then
19141 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2+ &
19142 (cref(2,jl,kkk)-cref(2,il,kkk))**2+ &
19143 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
19145 qqij = dexp(-0.5d0*((dij-d0ij)/(sigm(d0ij)))**2)
19146 if (itype(il,1).ne.10 .or. itype(jl,1).ne.10) then
19149 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
19150 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
19151 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
19152 dijCM=dist(il+nres,jl+nres)
19153 qqijCM = dexp(-0.5d0*((dijCM-d0ijCM)/(sigm(d0ijCM)))**2)
19155 qq = qq+qqij+qqijCM
19160 if (qqmax.le.qq) qqmax=qq
19162 qwolynes=1.0d0-qqmax
19164 end function qwolynes
19165 !-----------------------------------------------------------------------------
19166 subroutine qwolynes_prim(seg1,seg2,flag,seg3,seg4)
19167 ! implicit real(kind=8) (a-h,o-z)
19168 ! include 'DIMENSIONS'
19169 ! include 'COMMON.IOUNITS'
19170 ! include 'COMMON.CHAIN'
19171 ! include 'COMMON.INTERACT'
19172 ! include 'COMMON.VAR'
19173 ! include 'COMMON.MD'
19174 integer :: i,j,jl,k,l,il,nl,seg1,seg2,seg3,seg4,secseg
19175 integer :: nsep=3, kkk
19176 !el real(kind=8) :: dist
19177 real(kind=8) :: dij,d0ij,dijCM,d0ijCM
19178 logical :: lprn=.false.
19180 real(kind=8) :: sim,dd0,fac,ddqij
19181 !el sigm(x)=0.25d0*x ! local function
19191 do il=seg1+nsep,seg2
19194 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2+ &
19195 (cref(2,jl,kkk)-cref(2,il,kkk))**2+ &
19196 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
19198 sim = 1.0d0/sigm(d0ij)
19201 fac = dd0*sim/dij*dexp(-0.5d0*dd0*dd0*sim)
19203 ddqij = (c(k,il)-c(k,jl))*fac
19204 dqwol(k,il)=dqwol(k,il)+ddqij
19205 dqwol(k,jl)=dqwol(k,jl)-ddqij
19208 if (itype(il,1).ne.10 .or. itype(jl,1).ne.10) then
19211 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
19212 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
19213 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
19214 dijCM=dist(il+nres,jl+nres)
19215 sim = 1.0d0/sigm(d0ijCM)
19218 fac=dd0*sim/dijCM*dexp(-0.5d0*dd0*dd0*sim)
19220 ddqij = (c(k,il+nres)-c(k,jl+nres))*fac
19221 dxqwol(k,il)=dxqwol(k,il)+ddqij
19222 dxqwol(k,jl)=dxqwol(k,jl)-ddqij
19229 if((seg3-il).lt.3) then
19236 d0ij=dsqrt((cref(1,jl,kkk)-cref(1,il,kkk))**2+ &
19237 (cref(2,jl,kkk)-cref(2,il,kkk))**2+ &
19238 (cref(3,jl,kkk)-cref(3,il,kkk))**2)
19240 sim = 1.0d0/sigm(d0ij)
19243 fac = dd0*sim/dij*dexp(-0.5d0*dd0*dd0*sim)
19245 ddqij = (c(k,il)-c(k,jl))*fac
19246 dqwol(k,il)=dqwol(k,il)+ddqij
19247 dqwol(k,jl)=dqwol(k,jl)-ddqij
19249 if (itype(il,1).ne.10 .or. itype(jl,1).ne.10) then
19252 (cref(1,jl+nres,kkk)-cref(1,il+nres,kkk))**2+ &
19253 (cref(2,jl+nres,kkk)-cref(2,il+nres,kkk))**2+ &
19254 (cref(3,jl+nres,kkk)-cref(3,il+nres,kkk))**2)
19255 dijCM=dist(il+nres,jl+nres)
19256 sim = 1.0d0/sigm(d0ijCM)
19259 fac = dd0*sim/dijCM*dexp(-0.5d0*dd0*dd0*sim)
19261 ddqij = (c(k,il+nres)-c(k,jl+nres))*fac
19262 dxqwol(k,il)=dxqwol(k,il)+ddqij
19263 dxqwol(k,jl)=dxqwol(k,jl)-ddqij
19272 dqwol(j,i)=dqwol(j,i)/nl
19273 dxqwol(j,i)=dxqwol(j,i)/nl
19277 end subroutine qwolynes_prim
19278 !-----------------------------------------------------------------------------
19279 subroutine qwol_num(seg1,seg2,flag,seg3,seg4)
19280 ! implicit real(kind=8) (a-h,o-z)
19281 ! include 'DIMENSIONS'
19282 ! include 'COMMON.IOUNITS'
19283 ! include 'COMMON.CHAIN'
19284 ! include 'COMMON.INTERACT'
19285 ! include 'COMMON.VAR'
19286 integer :: seg1,seg2,seg3,seg4
19288 real(kind=8),dimension(3,0:nres) :: qwolan,qwolxan
19289 real(kind=8),dimension(3,0:2*nres) :: cdummy
19290 real(kind=8) :: q1,q2
19291 real(kind=8) :: delta=1.0d-10
19296 q1=qwolynes(seg1,seg2,flag,seg3,seg4)
19298 c(j,i)=c(j,i)+delta
19299 q2=qwolynes(seg1,seg2,flag,seg3,seg4)
19300 qwolan(j,i)=(q2-q1)/delta
19306 q1=qwolynes(seg1,seg2,flag,seg3,seg4)
19307 cdummy(j,i+nres)=c(j,i+nres)
19308 c(j,i+nres)=c(j,i+nres)+delta
19309 q2=qwolynes(seg1,seg2,flag,seg3,seg4)
19310 qwolxan(j,i)=(q2-q1)/delta
19311 c(j,i+nres)=cdummy(j,i+nres)
19314 ! write(iout,*) "Numerical Q carteisan gradients backbone: "
19316 ! write(iout,'(i5,3e15.5)') i, (qwolan(j,i),j=1,3)
19318 ! write(iout,*) "Numerical Q carteisan gradients side-chain: "
19320 ! write(iout,'(i5,3e15.5)') i, (qwolxan(j,i),j=1,3)
19323 end subroutine qwol_num
19324 !-----------------------------------------------------------------------------
19325 subroutine EconstrQ
19326 ! MD with umbrella_sampling using Wolyne's distance measure as a constraint
19327 ! implicit real(kind=8) (a-h,o-z)
19328 ! include 'DIMENSIONS'
19329 ! include 'COMMON.CONTROL'
19330 ! include 'COMMON.VAR'
19331 ! include 'COMMON.MD'
19334 ! include 'COMMON.LANGEVIN'
19336 ! include 'COMMON.LANGEVIN.lang0'
19338 ! include 'COMMON.CHAIN'
19339 ! include 'COMMON.DERIV'
19340 ! include 'COMMON.GEO'
19341 ! include 'COMMON.LOCAL'
19342 ! include 'COMMON.INTERACT'
19343 ! include 'COMMON.IOUNITS'
19344 ! include 'COMMON.NAMES'
19345 ! include 'COMMON.TIME1'
19346 real(kind=8) :: uzap1,uzap2,hm1,hm2,hmnum,ucdelan
19347 real(kind=8),dimension(3,0:nres) :: dUcartan,dUxcartan,cdummy,&
19349 integer :: kstart,kend,lstart,lend,idummy
19350 real(kind=8) :: delta=1.0d-7
19351 integer :: i,j,k,ii
19355 dudconst(j,i)=0.0d0
19356 duxconst(j,i)=0.0d0
19357 dudxconst(j,i)=0.0d0
19362 qfrag(i)=qwolynes(ifrag(1,i,iset),ifrag(2,i,iset),.true.,&
19364 Uconst=Uconst+wfrag(i,iset)*harmonic(qfrag(i),qinfrag(i,iset))
19365 ! Calculating the derivatives of Constraint energy with respect to Q
19366 Ucdfrag=wfrag(i,iset)*harmonicprim(qfrag(i),&
19368 ! hm1=harmonic(qfrag(i,iset),qinfrag(i,iset))
19369 ! hm2=harmonic(qfrag(i,iset)+delta,qinfrag(i,iset))
19370 ! hmnum=(hm2-hm1)/delta
19371 ! write(iout,*) "harmonicprim frag",harmonicprim(qfrag(i,iset),
19372 ! & qinfrag(i,iset))
19373 ! write(iout,*) "harmonicnum frag", hmnum
19374 ! Calculating the derivatives of Q with respect to cartesian coordinates
19375 call qwolynes_prim(ifrag(1,i,iset),ifrag(2,i,iset),.true.,&
19377 ! write(iout,*) "dqwol "
19379 ! write(iout,'(i5,3e15.5)') ii,(dqwol(j,ii),j=1,3)
19381 ! write(iout,*) "dxqwol "
19383 ! write(iout,'(i5,3e15.5)') ii,(dxqwol(j,ii),j=1,3)
19385 ! Calculating numerical gradients of dU/dQi and dQi/dxi
19386 ! call qwol_num(ifrag(1,i,iset),ifrag(2,i,iset),.true.
19387 ! & ,idummy,idummy)
19388 ! The gradients of Uconst in Cs
19391 duconst(j,ii)=dUconst(j,ii)+ucdfrag*dqwol(j,ii)
19392 dUxconst(j,ii)=dUxconst(j,ii)+ucdfrag*dxqwol(j,ii)
19397 kstart=ifrag(1,ipair(1,i,iset),iset)
19398 kend=ifrag(2,ipair(1,i,iset),iset)
19399 lstart=ifrag(1,ipair(2,i,iset),iset)
19400 lend=ifrag(2,ipair(2,i,iset),iset)
19401 qpair(i)=qwolynes(kstart,kend,.false.,lstart,lend)
19402 Uconst=Uconst+wpair(i,iset)*harmonic(qpair(i),qinpair(i,iset))
19403 ! Calculating dU/dQ
19404 Ucdpair=wpair(i,iset)*harmonicprim(qpair(i),qinpair(i,iset))
19405 ! hm1=harmonic(qpair(i),qinpair(i,iset))
19406 ! hm2=harmonic(qpair(i)+delta,qinpair(i,iset))
19407 ! hmnum=(hm2-hm1)/delta
19408 ! write(iout,*) "harmonicprim pair ",harmonicprim(qpair(i),
19409 ! & qinpair(i,iset))
19410 ! write(iout,*) "harmonicnum pair ", hmnum
19411 ! Calculating dQ/dXi
19412 call qwolynes_prim(kstart,kend,.false.,&
19414 ! write(iout,*) "dqwol "
19416 ! write(iout,'(i5,3e15.5)') ii,(dqwol(j,ii),j=1,3)
19418 ! write(iout,*) "dxqwol "
19420 ! write(iout,'(i5,3e15.5)') ii,(dxqwol(j,ii),j=1,3)
19422 ! Calculating numerical gradients
19423 ! call qwol_num(kstart,kend,.false.
19425 ! The gradients of Uconst in Cs
19428 duconst(j,ii)=dUconst(j,ii)+ucdpair*dqwol(j,ii)
19429 dUxconst(j,ii)=dUxconst(j,ii)+ucdpair*dxqwol(j,ii)
19433 ! write(iout,*) "Uconst inside subroutine ", Uconst
19434 ! Transforming the gradients from Cs to dCs for the backbone
19438 dudconst(k,i)=dudconst(k,i)+duconst(k,j)+duxconst(k,j)
19442 ! Transforming the gradients from Cs to dCs for the side chains
19445 dudxconst(j,i)=duxconst(j,i)
19448 ! write(iout,*) "dU/ddc backbone "
19450 ! write(iout,'(i5,3e15.5)') ii, (dudconst(j,ii),j=1,3)
19452 ! write(iout,*) "dU/ddX side chain "
19454 ! write(iout,'(i5,3e15.5)') ii,(duxconst(j,ii),j=1,3)
19456 ! Calculating numerical gradients of dUconst/ddc and dUconst/ddx
19457 ! call dEconstrQ_num
19459 end subroutine EconstrQ
19460 !-----------------------------------------------------------------------------
19461 subroutine dEconstrQ_num
19462 ! Calculating numerical dUconst/ddc and dUconst/ddx
19463 ! implicit real(kind=8) (a-h,o-z)
19464 ! include 'DIMENSIONS'
19465 ! include 'COMMON.CONTROL'
19466 ! include 'COMMON.VAR'
19467 ! include 'COMMON.MD'
19470 ! include 'COMMON.LANGEVIN'
19472 ! include 'COMMON.LANGEVIN.lang0'
19474 ! include 'COMMON.CHAIN'
19475 ! include 'COMMON.DERIV'
19476 ! include 'COMMON.GEO'
19477 ! include 'COMMON.LOCAL'
19478 ! include 'COMMON.INTERACT'
19479 ! include 'COMMON.IOUNITS'
19480 ! include 'COMMON.NAMES'
19481 ! include 'COMMON.TIME1'
19482 real(kind=8) :: uzap1,uzap2
19483 real(kind=8),dimension(3,0:nres) :: dUcartan,dUxcartan,cdummy
19484 integer :: kstart,kend,lstart,lend,idummy
19485 real(kind=8) :: delta=1.0d-7
19486 !el local variables
19492 dUcartan(j,i)=0.0d0
19493 cdummy(j,i)=dc(j,i)
19494 dc(j,i)=dc(j,i)+delta
19495 call chainbuild_cart
19498 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),.true.,&
19500 uzap2=uzap2+wfrag(ii,iset)*harmonic(qfrag(ii),&
19504 kstart=ifrag(1,ipair(1,ii,iset),iset)
19505 kend=ifrag(2,ipair(1,ii,iset),iset)
19506 lstart=ifrag(1,ipair(2,ii,iset),iset)
19507 lend=ifrag(2,ipair(2,ii,iset),iset)
19508 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
19509 uzap2=uzap2+wpair(ii,iset)*harmonic(qpair(ii),&
19512 dc(j,i)=cdummy(j,i)
19513 call chainbuild_cart
19516 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),.true.,&
19518 uzap1=uzap1+wfrag(ii,iset)*harmonic(qfrag(ii),&
19522 kstart=ifrag(1,ipair(1,ii,iset),iset)
19523 kend=ifrag(2,ipair(1,ii,iset),iset)
19524 lstart=ifrag(1,ipair(2,ii,iset),iset)
19525 lend=ifrag(2,ipair(2,ii,iset),iset)
19526 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
19527 uzap1=uzap1+wpair(ii,iset)*harmonic(qpair(ii),&
19530 ducartan(j,i)=(uzap2-uzap1)/(delta)
19533 ! Calculating numerical gradients for dU/ddx
19535 duxcartan(j,i)=0.0d0
19537 cdummy(j,i)=dc(j,i+nres)
19538 dc(j,i+nres)=dc(j,i+nres)+delta
19539 call chainbuild_cart
19542 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),.true.,&
19544 uzap2=uzap2+wfrag(ii,iset)*harmonic(qfrag(ii),&
19548 kstart=ifrag(1,ipair(1,ii,iset),iset)
19549 kend=ifrag(2,ipair(1,ii,iset),iset)
19550 lstart=ifrag(1,ipair(2,ii,iset),iset)
19551 lend=ifrag(2,ipair(2,ii,iset),iset)
19552 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
19553 uzap2=uzap2+wpair(ii,iset)*harmonic(qpair(ii),&
19556 dc(j,i+nres)=cdummy(j,i)
19557 call chainbuild_cart
19560 qfrag(ii)=qwolynes(ifrag(1,ii,iset),&
19561 ifrag(2,ii,iset),.true.,idummy,idummy)
19562 uzap1=uzap1+wfrag(ii,iset)*harmonic(qfrag(ii),&
19566 kstart=ifrag(1,ipair(1,ii,iset),iset)
19567 kend=ifrag(2,ipair(1,ii,iset),iset)
19568 lstart=ifrag(1,ipair(2,ii,iset),iset)
19569 lend=ifrag(2,ipair(2,ii,iset),iset)
19570 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
19571 uzap1=uzap1+wpair(ii,iset)*harmonic(qpair(ii),&
19574 duxcartan(j,i)=(uzap2-uzap1)/(delta)
19577 write(iout,*) "Numerical dUconst/ddc backbone "
19579 write(iout,'(i5,3e15.5)') ii,(dUcartan(j,ii),j=1,3)
19581 ! write(iout,*) "Numerical dUconst/ddx side-chain "
19583 ! write(iout,'(i5,3e15.5)') ii,(dUxcartan(j,ii),j=1,3)
19586 end subroutine dEconstrQ_num
19587 !-----------------------------------------------------------------------------
19589 !-----------------------------------------------------------------------------
19590 subroutine check_energies
19592 ! use random, only: ran_number
19596 ! include 'DIMENSIONS'
19597 ! include 'COMMON.CHAIN'
19598 ! include 'COMMON.VAR'
19599 ! include 'COMMON.IOUNITS'
19600 ! include 'COMMON.SBRIDGE'
19601 ! include 'COMMON.LOCAL'
19602 ! include 'COMMON.GEO'
19604 ! External functions
19605 !EL double precision ran_number
19606 !EL external ran_number
19609 integer :: i,j,k,l,lmax,p,pmax,countss
19610 real(kind=8) :: rmin,rmax
19611 real(kind=8) :: eij
19614 real(kind=8) :: wi,rij,tj,pj
19636 !t wi=ran_number(0.0D0,pi)
19637 ! wi=ran_number(0.0D0,pi/6.0D0)
19639 !t tj=ran_number(0.0D0,pi)
19640 !t pj=ran_number(0.0D0,pi)
19641 ! pj=ran_number(0.0D0,pi/6.0D0)
19645 !t rij=ran_number(rmin,rmax)
19647 c(1,j)=d*sin(pj)*cos(tj)
19648 c(2,j)=d*sin(pj)*sin(tj)
19654 c(3,i)=-rij-d*cos(wi)
19657 dc(k,nres+i)=c(k,nres+i)-c(k,i)
19658 dc_norm(k,nres+i)=dc(k,nres+i)/d
19659 dc(k,nres+j)=c(k,nres+j)-c(k,j)
19660 dc_norm(k,nres+j)=dc(k,nres+j)/d
19663 call dyn_ssbond_ene(i,j,eij,countss)
19668 end subroutine check_energies
19669 !-----------------------------------------------------------------------------
19670 subroutine dyn_ssbond_ene(resi,resj,eij,countss)
19675 ! include 'DIMENSIONS'
19676 ! include 'COMMON.SBRIDGE'
19677 ! include 'COMMON.CHAIN'
19678 ! include 'COMMON.DERIV'
19679 ! include 'COMMON.LOCAL'
19680 ! include 'COMMON.INTERACT'
19681 ! include 'COMMON.VAR'
19682 ! include 'COMMON.IOUNITS'
19683 ! include 'COMMON.CALC'
19687 ! include 'COMMON.MD'
19688 ! use MD, only: totT,t_bath
19691 ! External functions
19692 !EL double precision h_base
19693 !EL external h_base
19696 integer :: resi,resj
19699 real(kind=8) :: eij
19702 logical :: havebond
19703 integer itypi,itypj,countss
19704 real(kind=8) :: rrij,ssd,deltat1,deltat2,deltat12,cosphi
19705 real(kind=8) :: sig0ij,ljd,sig,fac,e1,e2
19706 real(kind=8),dimension(3) :: dcosom1,dcosom2
19708 real(kind=8) :: pom1,pom2
19709 real(kind=8) :: ljA,ljB,ljXs
19710 real(kind=8),dimension(1:3) :: d_ljB
19711 real(kind=8) :: ssA,ssB,ssC,ssXs
19712 real(kind=8) :: ssxm,ljxm,ssm,ljm
19713 real(kind=8),dimension(1:3) :: d_ssxm,d_ljxm,d_ssm,d_ljm
19714 real(kind=8) :: f1,f2,h1,h2,hd1,hd2
19715 real(kind=8) :: omega,delta_inv,deltasq_inv,fac1,fac2
19716 !-------FIRST METHOD
19718 real(kind=8),dimension(1:3) :: d_xm
19719 !-------END FIRST METHOD
19720 !-------SECOND METHOD
19721 !$$$ double precision ss,d_ss(0:3),ljf,d_ljf(0:3)
19722 !-------END SECOND METHOD
19724 !-------TESTING CODE
19725 !el logical :: checkstop,transgrad
19726 !el common /sschecks/ checkstop,transgrad
19728 integer :: icheck,nicheck,jcheck,njcheck
19729 real(kind=8),dimension(-1:1) :: echeck
19730 real(kind=8) :: deps,ssx0,ljx0
19731 !-------END TESTING CODE
19737 !el allocate(dyn_ssbond_ij(iatsc_s:iatsc_e,nres))
19738 !el allocate(dyn_ssbond_ij(0:nres+4,nres))
19741 dxi=dc_norm(1,nres+i)
19742 dyi=dc_norm(2,nres+i)
19743 dzi=dc_norm(3,nres+i)
19744 dsci_inv=vbld_inv(i+nres)
19747 xj=c(1,nres+j)-c(1,nres+i)
19748 yj=c(2,nres+j)-c(2,nres+i)
19749 zj=c(3,nres+j)-c(3,nres+i)
19750 dxj=dc_norm(1,nres+j)
19751 dyj=dc_norm(2,nres+j)
19752 dzj=dc_norm(3,nres+j)
19753 dscj_inv=vbld_inv(j+nres)
19755 chi1=chi(itypi,itypj)
19756 chi2=chi(itypj,itypi)
19763 alf12=0.5D0*(alf1+alf2)
19765 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
19766 rij=dsqrt(rrij) ! sc_angular needs rij to really be the inverse
19767 ! The following are set in sc_angular
19771 ! om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
19772 ! om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
19773 ! om12=dxi*dxj+dyi*dyj+dzi*dzj
19775 rij=1.0D0/rij ! Reset this so it makes sense
19777 sig0ij=sigma(itypi,itypj)
19778 sig=sig0ij*dsqrt(1.0D0/sigsq)
19781 ljA=eps1*eps2rt**2*eps3rt**2
19782 ljB=ljA*bb_aq(itypi,itypj)
19783 ljA=ljA*aa_aq(itypi,itypj)
19784 ljxm=ljXs+(-2.0D0*aa_aq(itypi,itypj)/bb_aq(itypi,itypj))**(1.0D0/6.0D0)
19789 deltat12=om2-om1+2.0d0
19790 cosphi=om12-om1*om2
19794 +akth*(deltat1*deltat1+deltat2*deltat2) &
19795 +v1ss*cosphi+v2ss*cosphi*cosphi+v3ss*cosphi*cosphi*cosphi
19796 ssxm=ssXs-0.5D0*ssB/ssA
19798 !-------TESTING CODE
19799 !$$$c Some extra output
19800 !$$$ ssm=ssC-0.25D0*ssB*ssB/ssA
19801 !$$$ ljm=-0.25D0*ljB*bb(itypi,itypj)/aa(itypi,itypj)
19802 !$$$ ssx0=ssB*ssB-4.0d0*ssA*ssC
19803 !$$$ if (ssx0.gt.0.0d0) then
19804 !$$$ ssx0=ssXs+0.5d0*(-ssB+sqrt(ssx0))/ssA
19808 !$$$ ljx0=ljXs+(-aa(itypi,itypj)/bb(itypi,itypj))**(1.0D0/6.0D0)
19809 !$$$ write(iout,'(a,4f8.2,2f15.2,3f6.2)')"SSENERGIES ",
19810 !$$$ & ssxm,ljxm,ssx0,ljx0,ssm,ljm,om1,om2,om12
19812 !-------END TESTING CODE
19814 !-------TESTING CODE
19815 ! Stop and plot energy and derivative as a function of distance
19816 if (checkstop) then
19817 ssm=ssC-0.25D0*ssB*ssB/ssA
19818 ljm=-0.25D0*ljB*bb_aq(itypi,itypj)/aa_aq(itypi,itypj)
19819 if (ssm.lt.ljm .and. &
19820 dabs(rij-0.5d0*(ssxm+ljxm)).lt.0.35d0*(ljxm-ssxm)) then
19828 if (.not.checkstop) then
19833 do icheck=0,nicheck
19834 do jcheck=-1,njcheck
19835 if (checkstop) rij=(ssxm-1.0d0)+ &
19836 ((ljxm-ssxm+2.0d0)*icheck)/nicheck+jcheck*deps
19837 !-------END TESTING CODE
19839 if (rij.gt.ljxm) then
19842 fac=(1.0D0/ljd)**expon
19843 e1=fac*fac*aa_aq(itypi,itypj)
19844 e2=fac*bb_aq(itypi,itypj)
19845 eij=eps1*eps2rt*eps3rt*(e1+e2)
19848 eij=eij*eps2rt*eps3rt
19851 e1=e1*eps1*eps2rt**2*eps3rt**2
19852 ed=-expon*(e1+eij)/ljd
19854 eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
19855 eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
19856 eom12=eij*eps1_om12+eps2der*eps2rt_om12 &
19857 -2.0D0*alf12*eps3der+sigder*sigsq_om12
19858 else if (rij.lt.ssxm) then
19861 eij=ssA*ssd*ssd+ssB*ssd+ssC
19863 ed=2*akcm*ssd+akct*deltat12
19865 pom2=v1ss+2*v2ss*cosphi+3*v3ss*cosphi*cosphi
19866 eom1=-2*akth*deltat1-pom1-om2*pom2
19867 eom2= 2*akth*deltat2+pom1-om1*pom2
19870 omega=v1ss+2.0d0*v2ss*cosphi+3.0d0*v3ss*cosphi*cosphi
19872 d_ssxm(1)=0.5D0*akct/ssA
19873 d_ssxm(2)=-d_ssxm(1)
19876 d_ljxm(1)=sig0ij/sqrt(sigsq**3)
19877 d_ljxm(2)=d_ljxm(1)*sigsq_om2
19878 d_ljxm(3)=d_ljxm(1)*sigsq_om12
19879 d_ljxm(1)=d_ljxm(1)*sigsq_om1
19881 !-------FIRST METHOD, DISCONTINUOUS SECOND DERIVATIVE
19882 xm=0.5d0*(ssxm+ljxm)
19884 d_xm(k)=0.5d0*(d_ssxm(k)+d_ljxm(k))
19886 if (rij.lt.xm) then
19888 ssm=ssC-0.25D0*ssB*ssB/ssA
19889 d_ssm(1)=0.5D0*akct*ssB/ssA
19890 d_ssm(2)=2.0D0*akth*deltat2-om1*omega-d_ssm(1)
19891 d_ssm(1)=-2.0D0*akth*deltat1-om2*omega+d_ssm(1)
19893 f1=(rij-xm)/(ssxm-xm)
19894 f2=(rij-ssxm)/(xm-ssxm)
19898 delta_inv=1.0d0/(xm-ssxm)
19899 deltasq_inv=delta_inv*delta_inv
19901 fac1=deltasq_inv*fac*(xm-rij)
19902 fac2=deltasq_inv*fac*(rij-ssxm)
19903 ed=delta_inv*(Ht*hd2-ssm*hd1)
19904 eom1=fac1*d_ssxm(1)+fac2*d_xm(1)+h1*d_ssm(1)
19905 eom2=fac1*d_ssxm(2)+fac2*d_xm(2)+h1*d_ssm(2)
19906 eom12=fac1*d_ssxm(3)+fac2*d_xm(3)+h1*d_ssm(3)
19909 ljm=-0.25D0*ljB*bb_aq(itypi,itypj)/aa_aq(itypi,itypj)
19910 d_ljm(1)=-0.5D0*bb_aq(itypi,itypj)/aa_aq(itypi,itypj)*ljB
19911 d_ljm(2)=d_ljm(1)*(0.5D0*eps2rt_om2/eps2rt+alf2/eps3rt)
19912 d_ljm(3)=d_ljm(1)*(0.5D0*eps1_om12+0.5D0*eps2rt_om12/eps2rt- &
19914 d_ljm(1)=d_ljm(1)*(0.5D0*eps2rt_om1/eps2rt-alf1/eps3rt)
19915 f1=(rij-ljxm)/(xm-ljxm)
19916 f2=(rij-xm)/(ljxm-xm)
19920 delta_inv=1.0d0/(ljxm-xm)
19921 deltasq_inv=delta_inv*delta_inv
19923 fac1=deltasq_inv*fac*(ljxm-rij)
19924 fac2=deltasq_inv*fac*(rij-xm)
19925 ed=delta_inv*(ljm*hd2-Ht*hd1)
19926 eom1=fac1*d_xm(1)+fac2*d_ljxm(1)+h2*d_ljm(1)
19927 eom2=fac1*d_xm(2)+fac2*d_ljxm(2)+h2*d_ljm(2)
19928 eom12=fac1*d_xm(3)+fac2*d_ljxm(3)+h2*d_ljm(3)
19930 !-------END FIRST METHOD, DISCONTINUOUS SECOND DERIVATIVE
19932 !-------SECOND METHOD, CONTINUOUS SECOND DERIVATIVE
19938 !$$$ d_ljB(1)=ljB*(eps2rt_om1/eps2rt-2.0d0*alf1/eps3rt)
19939 !$$$ d_ljB(2)=ljB*(eps2rt_om2/eps2rt+2.0d0*alf2/eps3rt)
19940 !$$$ d_ljB(3)=ljB*(eps1_om12+eps2rt_om12/eps2rt-2.0d0*alf12/eps3rt)
19942 !$$$ ssm=ssC-0.25D0*ssB*ssB/ssA
19943 !$$$ d_ssm(1)=0.5D0*akct*ssB/ssA
19944 !$$$ d_ssm(2)=2.0D0*akth*deltat2-om1*omega-d_ssm(1)
19945 !$$$ d_ssm(1)=-2.0D0*akth*deltat1-om2*omega+d_ssm(1)
19946 !$$$ d_ssm(3)=omega
19948 !$$$ ljm=-0.25D0*bb(itypi,itypj)/aa(itypi,itypj)
19950 !$$$ d_ljm(k)=ljm*d_ljB(k)
19954 !$$$ ss=ssA*ssd*ssd+ssB*ssd+ssC
19955 !$$$ d_ss(0)=2.0d0*ssA*ssd+ssB
19956 !$$$ d_ss(2)=akct*ssd
19957 !$$$ d_ss(1)=-d_ss(2)-2.0d0*akth*deltat1-om2*omega
19958 !$$$ d_ss(2)=d_ss(2)+2.0d0*akth*deltat2-om1*omega
19961 !$$$ ljf=bb(itypi,itypj)/aa(itypi,itypj)
19962 !$$$ ljf=9.0d0*ljf*(-0.5d0*ljf)**(1.0d0/3.0d0)
19963 !$$$ d_ljf(0)=ljf*2.0d0*ljB*fac1
19965 !$$$ d_ljf(k)=d_ljm(k)+ljf*(d_ljB(k)*fac1*fac1-
19966 !$$$ & 2.0d0*ljB*fac1*d_ljxm(k))
19968 !$$$ ljf=ljm+ljf*ljB*fac1*fac1
19970 !$$$ f1=(rij-ljxm)/(ssxm-ljxm)
19971 !$$$ f2=(rij-ssxm)/(ljxm-ssxm)
19972 !$$$ h1=h_base(f1,hd1)
19973 !$$$ h2=h_base(f2,hd2)
19974 !$$$ eij=ss*h1+ljf*h2
19975 !$$$ delta_inv=1.0d0/(ljxm-ssxm)
19976 !$$$ deltasq_inv=delta_inv*delta_inv
19977 !$$$ fac=ljf*hd2-ss*hd1
19978 !$$$ ed=d_ss(0)*h1+d_ljf(0)*h2+delta_inv*fac
19979 !$$$ eom1=d_ss(1)*h1+d_ljf(1)*h2+deltasq_inv*fac*
19980 !$$$ & (fac1*d_ssxm(1)-fac2*(d_ljxm(1)))
19981 !$$$ eom2=d_ss(2)*h1+d_ljf(2)*h2+deltasq_inv*fac*
19982 !$$$ & (fac1*d_ssxm(2)-fac2*(d_ljxm(2)))
19983 !$$$ eom12=d_ss(3)*h1+d_ljf(3)*h2+deltasq_inv*fac*
19984 !$$$ & (fac1*d_ssxm(3)-fac2*(d_ljxm(3)))
19986 !$$$ havebond=.false.
19987 !$$$ if (ed.gt.0.0d0) havebond=.true.
19988 !-------END SECOND METHOD, CONTINUOUS SECOND DERIVATIVE
19995 ! if (dyn_ssbond_ij(i,j).eq.1.0d300) then
19996 ! write(iout,'(a15,f12.2,f8.1,2i5)')
19997 ! & "SSBOND_E_FORM",totT,t_bath,i,j
20001 dyn_ssbond_ij(countss)=eij
20002 else if (.not.havebond .and. dyn_ssbond_ij(countss).lt.1.0d300) then
20003 dyn_ssbond_ij(countss)=1.0d300
20006 ! write(iout,'(a15,f12.2,f8.1,2i5)')
20007 ! & "SSBOND_E_BREAK",totT,t_bath,i,j
20012 !-------TESTING CODE
20013 !el if (checkstop) then
20014 if (jcheck.eq.0) write(iout,'(a,3f15.8,$)') &
20015 "CHECKSTOP",rij,eij,ed
20019 if (checkstop) then
20020 write(iout,'(f15.8)')(echeck(1)-echeck(-1))*0.5d0/deps
20023 if (checkstop) then
20027 !-------END TESTING CODE
20030 dcosom1(k)=(dc_norm(k,nres+i)-om1*erij(k))/rij
20031 dcosom2(k)=(dc_norm(k,nres+j)-om2*erij(k))/rij
20034 gg(k)=ed*erij(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
20037 gvdwx(k,i)=gvdwx(k,i)-gg(k) &
20038 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
20039 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
20040 gvdwx(k,j)=gvdwx(k,j)+gg(k) &
20041 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
20042 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
20046 !grad gvdwc(l,k)=gvdwc(l,k)+gg(l)
20051 gvdwc(l,i)=gvdwc(l,i)-gg(l)
20052 gvdwc(l,j)=gvdwc(l,j)+gg(l)
20056 end subroutine dyn_ssbond_ene
20057 !--------------------------------------------------------------------------
20058 subroutine triple_ssbond_ene(resi,resj,resk,eij)
20063 ! include 'DIMENSIONS'
20064 ! include 'COMMON.SBRIDGE'
20065 ! include 'COMMON.CHAIN'
20066 ! include 'COMMON.DERIV'
20067 ! include 'COMMON.LOCAL'
20068 ! include 'COMMON.INTERACT'
20069 ! include 'COMMON.VAR'
20070 ! include 'COMMON.IOUNITS'
20071 ! include 'COMMON.CALC'
20075 ! include 'COMMON.MD'
20076 ! use MD, only: totT,t_bath
20079 double precision h_base
20083 integer resi,resj,resk,m,itypi,itypj,itypk
20085 !c Output arguments
20086 double precision eij,eij1,eij2,eij3
20090 !c integer itypi,itypj,k,l
20091 double precision rrij,ssd,deltat1,deltat2,deltat12,cosphi
20092 double precision rrik,rrjk,rik,rjk,xi,xk,yi,yk,zi,zk,xij,yij,zij
20093 double precision xik,yik,zik,xjk,yjk,zjk,dxk,dyk,dzk
20094 double precision sig0ij,ljd,sig,fac,e1,e2
20095 double precision dcosom1(3),dcosom2(3),ed
20096 double precision pom1,pom2
20097 double precision ljA,ljB,ljXs
20098 double precision d_ljB(1:3)
20099 double precision ssA,ssB,ssC,ssXs
20100 double precision ssxm,ljxm,ssm,ljm
20101 double precision d_ssxm(1:3),d_ljxm(1:3),d_ssm(1:3),d_ljm(1:3)
20103 if (dtriss.eq.0) return
20107 !C write(iout,*) resi,resj,resk
20109 dxi=dc_norm(1,nres+i)
20110 dyi=dc_norm(2,nres+i)
20111 dzi=dc_norm(3,nres+i)
20112 dsci_inv=vbld_inv(i+nres)
20116 call to_box(xi,yi,zi)
20121 call to_box(xj,yj,zj)
20122 dxj=dc_norm(1,nres+j)
20123 dyj=dc_norm(2,nres+j)
20124 dzj=dc_norm(3,nres+j)
20125 dscj_inv=vbld_inv(j+nres)
20130 call to_box(xk,yk,zk)
20131 dxk=dc_norm(1,nres+k)
20132 dyk=dc_norm(2,nres+k)
20133 dzk=dc_norm(3,nres+k)
20134 dscj_inv=vbld_inv(k+nres)
20144 rrij=(xij*xij+yij*yij+zij*zij)
20145 rij=dsqrt(rrij) ! sc_angular needs rij to really be the inverse
20146 rrik=(xik*xik+yik*yik+zik*zik)
20148 rrjk=(xjk*xjk+yjk*yjk+zjk*zjk)
20150 !C there are three combination of distances for each trisulfide bonds
20151 !C The first case the ith atom is the center
20152 !C Energy function is E=d/(a*(x-y)**2+b*(x+y)**2+c) where x is first
20153 !C distance y is second distance the a,b,c,d are parameters derived for
20154 !C this problem d parameter was set as a penalty currenlty set to 1.
20155 if ((iabs(j-i).le.2).or.(iabs(i-k).le.2)) then
20158 eij1=dtriss/(atriss*(rij-rik)**2+btriss*(rij+rik)**6+ctriss)
20160 !C second case jth atom is center
20161 if ((iabs(j-i).le.2).or.(iabs(j-k).le.2)) then
20164 eij2=dtriss/(atriss*(rij-rjk)**2+btriss*(rij+rjk)**6+ctriss)
20166 !C the third case kth atom is the center
20167 if ((iabs(i-k).le.2).or.(iabs(j-k).le.2)) then
20170 eij3=dtriss/(atriss*(rik-rjk)**2+btriss*(rik+rjk)**6+ctriss)
20176 !C write(iout,*)i,j,k,eij
20177 !C The energy penalty calculated now time for the gradient part
20178 !C derivative over rij
20179 fac=-eij1**2/dtriss*(2.0*atriss*(rij-rik)+6.0*btriss*(rij+rik)**5) &
20180 -eij2**2/dtriss*(2.0*atriss*(rij-rjk)+6.0*btriss*(rij+rjk)**5)
20185 gvdwx(m,i)=gvdwx(m,i)-gg(m)
20186 gvdwx(m,j)=gvdwx(m,j)+gg(m)
20190 gvdwc(l,i)=gvdwc(l,i)-gg(l)
20191 gvdwc(l,j)=gvdwc(l,j)+gg(l)
20193 !C now derivative over rik
20194 fac=-eij1**2/dtriss* &
20195 (-2.0*atriss*(rij-rik)+6.0*btriss*(rij+rik)**5) &
20196 -eij3**2/dtriss*(2.0*atriss*(rik-rjk)+6.0*btriss*(rik+rjk)**5)
20201 gvdwx(m,i)=gvdwx(m,i)-gg(m)
20202 gvdwx(m,k)=gvdwx(m,k)+gg(m)
20205 gvdwc(l,i)=gvdwc(l,i)-gg(l)
20206 gvdwc(l,k)=gvdwc(l,k)+gg(l)
20208 !C now derivative over rjk
20209 fac=-eij2**2/dtriss* &
20210 (-2.0*atriss*(rij-rjk)+6.0*btriss*(rij+rjk)**5)- &
20211 eij3**2/dtriss*(-2.0*atriss*(rik-rjk)+6.0*btriss*(rik+rjk)**5)
20216 gvdwx(m,j)=gvdwx(m,j)-gg(m)
20217 gvdwx(m,k)=gvdwx(m,k)+gg(m)
20220 gvdwc(l,j)=gvdwc(l,j)-gg(l)
20221 gvdwc(l,k)=gvdwc(l,k)+gg(l)
20224 end subroutine triple_ssbond_ene
20228 !-----------------------------------------------------------------------------
20229 real(kind=8) function h_base(x,deriv)
20230 ! A smooth function going 0->1 in range [0,1]
20231 ! It should NOT be called outside range [0,1], it will not work there.
20238 real(kind=8) :: deriv
20241 real(kind=8) :: xsq
20244 ! Two parabolas put together. First derivative zero at extrema
20245 !$$$ if (x.lt.0.5D0) then
20246 !$$$ h_base=2.0D0*x*x
20250 !$$$ h_base=1.0D0-2.0D0*deriv*deriv
20251 !$$$ deriv=4.0D0*deriv
20254 ! Third degree polynomial. First derivative zero at extrema
20255 h_base=x*x*(3.0d0-2.0d0*x)
20256 deriv=6.0d0*x*(1.0d0-x)
20258 ! Fifth degree polynomial. First and second derivatives zero at extrema
20260 !$$$ h_base=x*xsq*(6.0d0*xsq-15.0d0*x+10.0d0)
20262 !$$$ deriv=deriv*deriv
20263 !$$$ deriv=30.0d0*xsq*deriv
20266 end function h_base
20267 !-----------------------------------------------------------------------------
20268 subroutine dyn_set_nss
20269 ! Adjust nss and other relevant variables based on dyn_ssbond_ij
20271 use MD_data, only: totT,t_bath
20273 ! include 'DIMENSIONS'
20277 ! include 'COMMON.SBRIDGE'
20278 ! include 'COMMON.CHAIN'
20279 ! include 'COMMON.IOUNITS'
20280 ! include 'COMMON.SETUP'
20281 ! include 'COMMON.MD'
20283 real(kind=8) :: emin
20284 integer :: i,j,imin,ierr,k
20285 integer :: diff,allnss,newnss
20286 integer,dimension(maxdim) :: allflag,allihpb,alljhpb,& !(maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
20287 newihpb,newjhpb,aliass
20289 integer,dimension(0:nfgtasks) :: i_newnss
20290 integer,dimension(0:nfgtasks) :: displ
20291 integer,dimension(maxdim) :: g_newihpb,g_newjhpb !(maxdim)(maxdim=(maxres-1)*(maxres-2)/2)
20292 integer :: g_newnss
20298 if ((itype(i,1).eq.1).and.(itype(j,1).eq.1)) then
20300 if (dyn_ssbond_ij(k).lt.1.0d300) then
20311 !mc write(iout,*)"ALLNSS ",allnss,(allihpb(i),alljhpb(i),i=1,allnss)
20315 if (allflag(i).eq.0 .and. &
20316 dyn_ssbond_ij(aliass(allnss)).lt.emin) then
20317 emin=dyn_ssbond_ij(aliass(allnss))
20321 if (emin.lt.1.0d300) then
20324 if (allflag(i).eq.0 .and. &
20325 (allihpb(i).eq.allihpb(imin) .or. &
20326 alljhpb(i).eq.allihpb(imin) .or. &
20327 allihpb(i).eq.alljhpb(imin) .or. &
20328 alljhpb(i).eq.alljhpb(imin))) then
20335 !mc write(iout,*)"ALLNSS ",allnss,(allihpb(i),alljhpb(i),i=1,allnss)
20339 if (allflag(i).eq.1) then
20341 newihpb(newnss)=allihpb(i)
20342 newjhpb(newnss)=alljhpb(i)
20347 if (nfgtasks.gt.1)then
20349 call MPI_Reduce(newnss,g_newnss,1,&
20350 MPI_INTEGER,MPI_SUM,king,FG_COMM,IERR)
20351 call MPI_Gather(newnss,1,MPI_INTEGER,&
20352 i_newnss,1,MPI_INTEGER,king,FG_COMM,IERR)
20354 do i=1,nfgtasks-1,1
20355 displ(i)=i_newnss(i-1)+displ(i-1)
20357 call MPI_Gatherv(newihpb,newnss,MPI_INTEGER,&
20358 g_newihpb,i_newnss,displ,MPI_INTEGER,&
20360 call MPI_Gatherv(newjhpb,newnss,MPI_INTEGER,&
20361 g_newjhpb,i_newnss,displ,MPI_INTEGER,&
20363 if(fg_rank.eq.0) then
20364 ! print *,'g_newnss',g_newnss
20365 ! print *,'g_newihpb',(g_newihpb(i),i=1,g_newnss)
20366 ! print *,'g_newjhpb',(g_newjhpb(i),i=1,g_newnss)
20369 newihpb(i)=g_newihpb(i)
20370 newjhpb(i)=g_newjhpb(i)
20378 !mc write(iout,*)"NEWNSS ",newnss,(newihpb(i),newjhpb(i),i=1,newnss)
20379 ! print *,newnss,nss,maxdim
20385 if (idssb(i).eq.newihpb(j) .and. &
20386 jdssb(i).eq.newjhpb(j)) found=.true.
20388 #if .not. defined(WHAM_RUN) && .not. defined(CLUSTER)
20389 ! write(iout,*) "found",found,i,j
20390 if (.not.found.and.fg_rank.eq.0) &
20391 write(iout,'(a15,f12.2,f8.1,2i5)') &
20392 "SSBOND_BREAK",totT,t_bath,idssb(i),jdssb(i)
20400 if (newihpb(i).eq.idssb(j) .and. &
20401 newjhpb(i).eq.jdssb(j)) found=.true.
20403 #if .not. defined(WHAM_RUN) && .not. defined(CLUSTER)
20404 ! write(iout,*) "found",found,i,j
20405 if (.not.found.and.fg_rank.eq.0) &
20406 write(iout,'(a15,f12.2,f8.1,2i5)') &
20407 "SSBOND_FORM",totT,t_bath,newihpb(i),newjhpb(i)
20410 !#if .not. defined(WHAM_RUN) && .not. defined(CLUSTER)
20413 idssb(i)=newihpb(i)
20414 jdssb(i)=newjhpb(i)
20421 end subroutine dyn_set_nss
20422 ! Lipid transfer energy function
20423 subroutine Eliptransfer(eliptran)
20424 !C this is done by Adasko
20425 !C print *,"wchodze"
20426 !C structure of box:
20428 !C--bordliptop-- buffore starts
20429 !C--bufliptop--- here true lipid starts
20431 !C--buflipbot--- lipid ends buffore starts
20432 !C--bordlipbot--buffore ends
20433 real(kind=8) :: fracinbuf,eliptran,sslip,positi,ssgradlip
20436 ! print *, "I am in eliptran"
20437 do i=ilip_start,ilip_end
20439 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1).or.(i.eq.nres))&
20442 positi=(mod(((c(3,i)+c(3,i+1))/2.0d0),boxzsize))
20443 if (positi.le.0.0) positi=positi+boxzsize
20445 !C first for peptide groups
20446 !c for each residue check if it is in lipid or lipid water border area
20447 if ((positi.gt.bordlipbot) &
20448 .and.(positi.lt.bordliptop)) then
20449 !C the energy transfer exist
20450 if (positi.lt.buflipbot) then
20451 !C what fraction I am in
20453 ((positi-bordlipbot)/lipbufthick)
20454 !C lipbufthick is thickenes of lipid buffore
20455 sslip=sscalelip(fracinbuf)
20456 ssgradlip=-sscagradlip(fracinbuf)/lipbufthick
20457 eliptran=eliptran+sslip*pepliptran
20458 gliptranc(3,i)=gliptranc(3,i)+ssgradlip*pepliptran/2.0d0
20459 gliptranc(3,i-1)=gliptranc(3,i-1)+ssgradlip*pepliptran/2.0d0
20460 !C gliptranc(3,i-2)=gliptranc(3,i)+ssgradlip*pepliptran
20462 !C print *,"doing sccale for lower part"
20463 !C print *,i,sslip,fracinbuf,ssgradlip
20464 elseif (positi.gt.bufliptop) then
20465 fracinbuf=1.0d0-((bordliptop-positi)/lipbufthick)
20466 sslip=sscalelip(fracinbuf)
20467 ssgradlip=sscagradlip(fracinbuf)/lipbufthick
20468 eliptran=eliptran+sslip*pepliptran
20469 gliptranc(3,i)=gliptranc(3,i)+ssgradlip*pepliptran/2.0d0
20470 gliptranc(3,i-1)=gliptranc(3,i-1)+ssgradlip*pepliptran/2.0d0
20471 !C gliptranc(3,i-2)=gliptranc(3,i)+ssgradlip*pepliptran
20472 !C print *, "doing sscalefor top part"
20473 !C print *,i,sslip,fracinbuf,ssgradlip
20475 eliptran=eliptran+pepliptran
20476 !C print *,"I am in true lipid"
20479 !C eliptran=elpitran+0.0 ! I am in water
20481 if (energy_dec) write(iout,*) i,"eliptran=",eliptran,positi,sslip
20483 ! here starts the side chain transfer
20484 do i=ilip_start,ilip_end
20485 if (itype(i,1).eq.ntyp1) cycle
20486 positi=(mod(c(3,i+nres),boxzsize))
20487 if (positi.le.0) positi=positi+boxzsize
20488 !C print *,mod(c(3,i+nres),boxzsize),bordlipbot,bordliptop
20489 !c for each residue check if it is in lipid or lipid water border area
20490 !C respos=mod(c(3,i+nres),boxzsize)
20491 !C print *,positi,bordlipbot,buflipbot
20492 if ((positi.gt.bordlipbot) &
20493 .and.(positi.lt.bordliptop)) then
20494 !C the energy transfer exist
20495 if (positi.lt.buflipbot) then
20497 ((positi-bordlipbot)/lipbufthick)
20498 !C lipbufthick is thickenes of lipid buffore
20499 sslip=sscalelip(fracinbuf)
20500 ssgradlip=-sscagradlip(fracinbuf)/lipbufthick
20501 eliptran=eliptran+sslip*liptranene(itype(i,1))
20502 gliptranx(3,i)=gliptranx(3,i) &
20503 +ssgradlip*liptranene(itype(i,1))
20504 gliptranc(3,i-1)= gliptranc(3,i-1) &
20505 +ssgradlip*liptranene(itype(i,1))
20506 !C print *,"doing sccale for lower part"
20507 elseif (positi.gt.bufliptop) then
20509 ((bordliptop-positi)/lipbufthick)
20510 sslip=sscalelip(fracinbuf)
20511 ssgradlip=sscagradlip(fracinbuf)/lipbufthick
20512 eliptran=eliptran+sslip*liptranene(itype(i,1))
20513 gliptranx(3,i)=gliptranx(3,i) &
20514 +ssgradlip*liptranene(itype(i,1))
20515 gliptranc(3,i-1)= gliptranc(3,i-1) &
20516 +ssgradlip*liptranene(itype(i,1))
20517 !C print *, "doing sscalefor top part",sslip,fracinbuf
20519 eliptran=eliptran+liptranene(itype(i,1))
20520 !C print *,"I am in true lipid"
20522 endif ! if in lipid or buffor
20524 !C eliptran=elpitran+0.0 ! I am in water
20525 if (energy_dec) write(iout,*) i,"eliptran=",eliptran
20528 end subroutine Eliptransfer
20529 !----------------------------------NANO FUNCTIONS
20530 !C-----------------------------------------------------------------------
20531 !C-----------------------------------------------------------
20532 !C This subroutine is to mimic the histone like structure but as well can be
20533 !C utilizet to nanostructures (infinit) small modification has to be used to
20534 !C make it finite (z gradient at the ends has to be changes as well as the x,y
20535 !C gradient has to be modified at the ends
20536 !C The energy function is Kihara potential
20537 !C E=4esp*((sigma/(r-r0))^12 - (sigma/(r-r0))^6)
20538 !C 4eps is depth of well sigma is r_minimum r is distance from center of tube
20539 !C and r0 is the excluded size of nanotube (can be set to 0 if we want just a
20540 !C simple Kihara potential
20541 subroutine calctube(Etube)
20542 real(kind=8),dimension(3) :: vectube
20543 real(kind=8) :: Etube,xtemp,xminact,yminact,&
20544 ytemp,xmin,ymin,tub_r,rdiff,rdiff6,fac,positi, &
20545 sc_aa_tube,sc_bb_tube
20548 do i=itube_start,itube_end
20550 enetube(i+nres)=0.0d0
20552 !C first we calculate the distance from tube center
20554 do i=itube_start,itube_end
20555 !C lets ommit dummy atoms for now
20556 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1)) cycle
20557 !C now calculate distance from center of tube and direction vectors
20560 ! Find minimum distance in periodic box
20562 vectube(1)=mod((c(1,i)+c(1,i+1))/2.0d0,boxxsize)
20563 vectube(1)=vectube(1)+boxxsize*j
20564 vectube(2)=mod((c(2,i)+c(2,i+1))/2.0d0,boxysize)
20565 vectube(2)=vectube(2)+boxysize*j
20566 xminact=abs(vectube(1)-tubecenter(1))
20567 yminact=abs(vectube(2)-tubecenter(2))
20568 if (xmin.gt.xminact) then
20572 if (ymin.gt.yminact) then
20579 vectube(1)=vectube(1)-tubecenter(1)
20580 vectube(2)=vectube(2)-tubecenter(2)
20582 !C print *,"x",(c(1,i)+c(1,i+1))/2.0d0,tubecenter(1)
20583 !C print *,"y",(c(2,i)+c(2,i+1))/2.0d0,tubecenter(2)
20585 !C as the tube is infinity we do not calculate the Z-vector use of Z
20588 !C now calculte the distance
20589 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
20590 !C now normalize vector
20591 vectube(1)=vectube(1)/tub_r
20592 vectube(2)=vectube(2)/tub_r
20593 !C calculte rdiffrence between r and r0
20596 rdiff6=rdiff**6.0d0
20597 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
20598 enetube(i)=pep_aa_tube/rdiff6**2.0d0+pep_bb_tube/rdiff6
20599 !C write(iout,*) "TU13",i,rdiff6,enetube(i)
20600 !C print *,rdiff,rdiff6,pep_aa_tube
20601 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
20602 !C now we calculate gradient
20603 fac=(-12.0d0*pep_aa_tube/rdiff6- &
20604 6.0d0*pep_bb_tube)/rdiff6/rdiff
20605 !C write(iout,'(a5,i4,f12.1,3f12.5)') "TU13",i,rdiff6,enetube(i),
20607 !C now direction of gg_tube vector
20609 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac/2.0d0
20610 gg_tube(j,i)=gg_tube(j,i)+vectube(j)*fac/2.0d0
20613 !C basically thats all code now we split for side-chains (REMEMBER to sum up at the END)
20614 !C print *,gg_tube(1,0),"TU"
20617 do i=itube_start,itube_end
20618 !C Lets not jump over memory as we use many times iti
20620 !C lets ommit dummy atoms for now
20621 if ((iti.eq.ntyp1) &
20622 !C in UNRES uncomment the line below as GLY has no side-chain...
20628 vectube(1)=mod((c(1,i+nres)),boxxsize)
20629 vectube(1)=vectube(1)+boxxsize*j
20630 vectube(2)=mod((c(2,i+nres)),boxysize)
20631 vectube(2)=vectube(2)+boxysize*j
20633 xminact=abs(vectube(1)-tubecenter(1))
20634 yminact=abs(vectube(2)-tubecenter(2))
20635 if (xmin.gt.xminact) then
20639 if (ymin.gt.yminact) then
20646 !C write(iout,*), "tututu", vectube(1),tubecenter(1),vectube(2),
20648 vectube(1)=vectube(1)-tubecenter(1)
20649 vectube(2)=vectube(2)-tubecenter(2)
20651 !C as the tube is infinity we do not calculate the Z-vector use of Z
20654 !C now calculte the distance
20655 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
20656 !C now normalize vector
20657 vectube(1)=vectube(1)/tub_r
20658 vectube(2)=vectube(2)/tub_r
20660 !C calculte rdiffrence between r and r0
20663 rdiff6=rdiff**6.0d0
20664 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
20665 sc_aa_tube=sc_aa_tube_par(iti)
20666 sc_bb_tube=sc_bb_tube_par(iti)
20667 enetube(i+nres)=sc_aa_tube/rdiff6**2.0d0+sc_bb_tube/rdiff6
20668 fac=-12.0d0*sc_aa_tube/rdiff6**2.0d0/rdiff- &
20669 6.0d0*sc_bb_tube/rdiff6/rdiff
20670 !C now direction of gg_tube vector
20672 gg_tube_SC(j,i)=gg_tube_SC(j,i)+vectube(j)*fac
20673 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac
20676 do i=itube_start,itube_end
20677 Etube=Etube+enetube(i)+enetube(i+nres)
20679 !C print *,"ETUBE", etube
20681 end subroutine calctube
20682 !C TO DO 1) add to total energy
20683 !C 2) add to gradient summation
20684 !C 3) add reading parameters (AND of course oppening of PARAM file)
20685 !C 4) add reading the center of tube
20687 !C 6) add to zerograd
20688 !C 7) allocate matrices
20691 !C-----------------------------------------------------------------------
20692 !C-----------------------------------------------------------
20693 !C This subroutine is to mimic the histone like structure but as well can be
20694 !C utilizet to nanostructures (infinit) small modification has to be used to
20695 !C make it finite (z gradient at the ends has to be changes as well as the x,y
20696 !C gradient has to be modified at the ends
20697 !C The energy function is Kihara potential
20698 !C E=4esp*((sigma/(r-r0))^12 - (sigma/(r-r0))^6)
20699 !C 4eps is depth of well sigma is r_minimum r is distance from center of tube
20700 !C and r0 is the excluded size of nanotube (can be set to 0 if we want just a
20701 !C simple Kihara potential
20702 subroutine calctube2(Etube)
20703 real(kind=8),dimension(3) :: vectube
20704 real(kind=8) :: Etube,xtemp,xminact,yminact,&
20705 ytemp,xmin,ymin,tub_r,rdiff,rdiff6,fac,positi,fracinbuf,&
20706 sstube,ssgradtube,sc_aa_tube,sc_bb_tube
20709 do i=itube_start,itube_end
20711 enetube(i+nres)=0.0d0
20713 !C first we calculate the distance from tube center
20714 !C first sugare-phosphate group for NARES this would be peptide group
20716 do i=itube_start,itube_end
20717 !C lets ommit dummy atoms for now
20719 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1)) cycle
20720 !C now calculate distance from center of tube and direction vectors
20721 !C vectube(1)=mod((c(1,i)+c(1,i+1))/2.0d0,boxxsize)
20722 !C if (vectube(1).lt.0) vectube(1)=vectube(1)+boxxsize
20723 !C vectube(2)=mod((c(2,i)+c(2,i+1))/2.0d0,boxysize)
20724 !C if (vectube(2).lt.0) vectube(2)=vectube(2)+boxysize
20728 vectube(1)=mod((c(1,i)+c(1,i+1))/2.0d0,boxxsize)
20729 vectube(1)=vectube(1)+boxxsize*j
20730 vectube(2)=mod((c(2,i)+c(2,i+1))/2.0d0,boxysize)
20731 vectube(2)=vectube(2)+boxysize*j
20733 xminact=abs(vectube(1)-tubecenter(1))
20734 yminact=abs(vectube(2)-tubecenter(2))
20735 if (xmin.gt.xminact) then
20739 if (ymin.gt.yminact) then
20746 vectube(1)=vectube(1)-tubecenter(1)
20747 vectube(2)=vectube(2)-tubecenter(2)
20749 !C print *,"x",(c(1,i)+c(1,i+1))/2.0d0,tubecenter(1)
20750 !C print *,"y",(c(2,i)+c(2,i+1))/2.0d0,tubecenter(2)
20752 !C as the tube is infinity we do not calculate the Z-vector use of Z
20755 !C now calculte the distance
20756 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
20757 !C now normalize vector
20758 vectube(1)=vectube(1)/tub_r
20759 vectube(2)=vectube(2)/tub_r
20760 !C calculte rdiffrence between r and r0
20763 rdiff6=rdiff**6.0d0
20764 !C THIS FRAGMENT MAKES TUBE FINITE
20765 positi=mod((c(3,i)+c(3,i+1))/2.0d0,boxzsize)
20766 if (positi.le.0) positi=positi+boxzsize
20767 !C print *,mod(c(3,i+nres),boxzsize),bordlipbot,bordliptop
20768 !c for each residue check if it is in lipid or lipid water border area
20769 !C respos=mod(c(3,i+nres),boxzsize)
20770 !C print *,positi,bordtubebot,buftubebot,bordtubetop
20771 if ((positi.gt.bordtubebot) &
20772 .and.(positi.lt.bordtubetop)) then
20773 !C the energy transfer exist
20774 if (positi.lt.buftubebot) then
20776 ((positi-bordtubebot)/tubebufthick)
20777 !C lipbufthick is thickenes of lipid buffore
20778 sstube=sscalelip(fracinbuf)
20779 ssgradtube=-sscagradlip(fracinbuf)/tubebufthick
20780 !C print *,ssgradtube, sstube,tubetranene(itype(i,1))
20781 enetube(i)=enetube(i)+sstube*tubetranenepep
20782 !C gg_tube_SC(3,i)=gg_tube_SC(3,i)
20783 !C &+ssgradtube*tubetranene(itype(i,1))
20784 !C gg_tube(3,i-1)= gg_tube(3,i-1)
20785 !C &+ssgradtube*tubetranene(itype(i,1))
20786 !C print *,"doing sccale for lower part"
20787 elseif (positi.gt.buftubetop) then
20789 ((bordtubetop-positi)/tubebufthick)
20790 sstube=sscalelip(fracinbuf)
20791 ssgradtube=sscagradlip(fracinbuf)/tubebufthick
20792 enetube(i)=enetube(i)+sstube*tubetranenepep
20793 !C gg_tube_SC(3,i)=gg_tube_SC(3,i)
20794 !C &+ssgradtube*tubetranene(itype(i,1))
20795 !C gg_tube(3,i-1)= gg_tube(3,i-1)
20796 !C &+ssgradtube*tubetranene(itype(i,1))
20797 !C print *, "doing sscalefor top part",sslip,fracinbuf
20801 enetube(i)=enetube(i)+sstube*tubetranenepep
20802 !C print *,"I am in true lipid"
20806 !C ssgradtube=0.0d0
20808 endif ! if in lipid or buffor
20810 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
20811 enetube(i)=enetube(i)+sstube* &
20812 (pep_aa_tube/rdiff6**2.0d0+pep_bb_tube/rdiff6)
20813 !C write(iout,*) "TU13",i,rdiff6,enetube(i)
20814 !C print *,rdiff,rdiff6,pep_aa_tube
20815 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
20816 !C now we calculate gradient
20817 fac=(-12.0d0*pep_aa_tube/rdiff6- &
20818 6.0d0*pep_bb_tube)/rdiff6/rdiff*sstube
20819 !C write(iout,'(a5,i4,f12.1,3f12.5)') "TU13",i,rdiff6,enetube(i),
20822 !C now direction of gg_tube vector
20824 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac/2.0d0
20825 gg_tube(j,i)=gg_tube(j,i)+vectube(j)*fac/2.0d0
20827 gg_tube(3,i)=gg_tube(3,i) &
20828 +ssgradtube*enetube(i)/sstube/2.0d0
20829 gg_tube(3,i-1)= gg_tube(3,i-1) &
20830 +ssgradtube*enetube(i)/sstube/2.0d0
20833 !C basically thats all code now we split for side-chains (REMEMBER to sum up at the END)
20834 !C print *,gg_tube(1,0),"TU"
20835 do i=itube_start,itube_end
20836 !C Lets not jump over memory as we use many times iti
20838 !C lets ommit dummy atoms for now
20839 if ((iti.eq.ntyp1) &
20840 !!C in UNRES uncomment the line below as GLY has no side-chain...
20843 vectube(1)=c(1,i+nres)
20844 vectube(1)=mod(vectube(1),boxxsize)
20845 if (vectube(1).lt.0) vectube(1)=vectube(1)+boxxsize
20846 vectube(2)=c(2,i+nres)
20847 vectube(2)=mod(vectube(2),boxysize)
20848 if (vectube(2).lt.0) vectube(2)=vectube(2)+boxysize
20850 vectube(1)=vectube(1)-tubecenter(1)
20851 vectube(2)=vectube(2)-tubecenter(2)
20852 !C THIS FRAGMENT MAKES TUBE FINITE
20853 positi=(mod(c(3,i+nres),boxzsize))
20854 if (positi.le.0) positi=positi+boxzsize
20855 !C print *,mod(c(3,i+nres),boxzsize),bordlipbot,bordliptop
20856 !c for each residue check if it is in lipid or lipid water border area
20857 !C respos=mod(c(3,i+nres),boxzsize)
20858 !C print *,positi,bordtubebot,buftubebot,bordtubetop
20860 if ((positi.gt.bordtubebot) &
20861 .and.(positi.lt.bordtubetop)) then
20862 !C the energy transfer exist
20863 if (positi.lt.buftubebot) then
20865 ((positi-bordtubebot)/tubebufthick)
20866 !C lipbufthick is thickenes of lipid buffore
20867 sstube=sscalelip(fracinbuf)
20868 ssgradtube=-sscagradlip(fracinbuf)/tubebufthick
20869 !C print *,ssgradtube, sstube,tubetranene(itype(i,1))
20870 enetube(i+nres)=enetube(i+nres)+sstube*tubetranene(itype(i,1))
20871 !C gg_tube_SC(3,i)=gg_tube_SC(3,i)
20872 !C &+ssgradtube*tubetranene(itype(i,1))
20873 !C gg_tube(3,i-1)= gg_tube(3,i-1)
20874 !C &+ssgradtube*tubetranene(itype(i,1))
20875 !C print *,"doing sccale for lower part"
20876 elseif (positi.gt.buftubetop) then
20878 ((bordtubetop-positi)/tubebufthick)
20880 sstube=sscalelip(fracinbuf)
20881 ssgradtube=sscagradlip(fracinbuf)/tubebufthick
20882 enetube(i+nres)=enetube(i+nres)+sstube*tubetranene(itype(i,1))
20883 !C gg_tube_SC(3,i)=gg_tube_SC(3,i)
20884 !C &+ssgradtube*tubetranene(itype(i,1))
20885 !C gg_tube(3,i-1)= gg_tube(3,i-1)
20886 !C &+ssgradtube*tubetranene(itype(i,1))
20887 !C print *, "doing sscalefor top part",sslip,fracinbuf
20891 enetube(i+nres)=enetube(i+nres)+sstube*tubetranene(itype(i,1))
20892 !C print *,"I am in true lipid"
20896 !C ssgradtube=0.0d0
20898 endif ! if in lipid or buffor
20899 !CEND OF FINITE FRAGMENT
20900 !C as the tube is infinity we do not calculate the Z-vector use of Z
20903 !C now calculte the distance
20904 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
20905 !C now normalize vector
20906 vectube(1)=vectube(1)/tub_r
20907 vectube(2)=vectube(2)/tub_r
20908 !C calculte rdiffrence between r and r0
20911 rdiff6=rdiff**6.0d0
20912 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
20913 sc_aa_tube=sc_aa_tube_par(iti)
20914 sc_bb_tube=sc_bb_tube_par(iti)
20915 enetube(i+nres)=(sc_aa_tube/rdiff6**2.0d0+sc_bb_tube/rdiff6)&
20916 *sstube+enetube(i+nres)
20917 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
20918 !C now we calculate gradient
20919 fac=(-12.0d0*sc_aa_tube/rdiff6**2.0d0/rdiff-&
20920 6.0d0*sc_bb_tube/rdiff6/rdiff)*sstube
20921 !C now direction of gg_tube vector
20923 gg_tube_SC(j,i)=gg_tube_SC(j,i)+vectube(j)*fac
20924 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac
20926 gg_tube_SC(3,i)=gg_tube_SC(3,i) &
20927 +ssgradtube*enetube(i+nres)/sstube
20928 gg_tube(3,i-1)= gg_tube(3,i-1) &
20929 +ssgradtube*enetube(i+nres)/sstube
20932 do i=itube_start,itube_end
20933 Etube=Etube+enetube(i)+enetube(i+nres)
20935 !C print *,"ETUBE", etube
20937 end subroutine calctube2
20938 !=====================================================================================================================================
20939 subroutine calcnano(Etube)
20940 use MD_data, only:totTafm
20941 real(kind=8),dimension(3) :: vectube,cm
20943 real(kind=8) :: Etube,xtemp,xminact,yminact,&
20944 ytemp,xmin,ymin,tub_r,rdiff,rdiff6,fac,denominator,faccav,&
20945 sc_aa_tube,sc_bb_tube,zmin,ztemp,zminact,tubezcenter,xi,yi,zi!,&
20947 real(kind=8) :: eps,sig,aa_tub_lip,bb_tub_lip
20948 integer:: i,j,iti,r,ilol,ityp
20951 call to_box(tubecenter(1),tubecenter(2),tubecenter(3))
20952 ! print *,itube_start,itube_end,"poczatek"
20953 do i=itube_start,itube_end
20955 enetube(i+nres)=0.0d0
20957 !C first we calculate the distance from tube center
20958 !C first sugare-phosphate group for NARES this would be peptide group
20960 do i=itube_start,itube_end
20961 !C lets ommit dummy atoms for now
20962 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1)) cycle
20963 !C now calculate distance from center of tube and direction vectors
20966 xi=(c(1,i)+c(1,i+1))/2.0d0
20967 yi=(c(2,i)+c(2,i+1))/2.0d0
20968 zi=((c(3,i)+c(3,i+1))/2.0d0)
20969 call to_box(xi,yi,zi)
20970 ! tubezcenter=totTafm*velNANOconst+tubecenter(3)
20972 vectube(1)=boxshift(xi-tubecenter(1),boxxsize)
20973 vectube(2)=boxshift(yi-tubecenter(2),boxysize)
20974 vectube(3)=boxshift(zi-tubecenter(3),boxzsize)
20976 !C print *,"x",(c(1,i)+c(1,i+1))/2.0d0,tubecenter(1)
20977 !C print *,"y",(c(2,i)+c(2,i+1))/2.0d0,tubecenter(2)
20978 !C as the tube is infinity we do not calculate the Z-vector use of Z
20980 !C vectube(3)=0.0d0
20981 !C now calculte the distance
20982 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
20983 !C now normalize vector
20984 vectube(1)=vectube(1)/tub_r
20985 vectube(2)=vectube(2)/tub_r
20986 vectube(3)=vectube(3)/tub_r
20987 !C calculte rdiffrence between r and r0
20990 rdiff6=rdiff**6.0d0
20991 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
20992 enetube(i)=pep_aa_tube/rdiff6**2.0d0+pep_bb_tube/rdiff6
20993 !C write(iout,*) "TU13",i,rdiff6,enetube(i)
20994 !C print *,rdiff,rdiff6,pep_aa_tube
20995 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
20996 !C now we calculate gradient
20997 fac=(-12.0d0*pep_aa_tube/rdiff6- &
20998 6.0d0*pep_bb_tube)/rdiff6/rdiff
20999 !C write(iout,'(a5,i4,f12.1,3f12.5)') "TU13",i,rdiff6,enetube(i),
21001 if (acavtubpep.eq.0.0d0) then
21006 denominator=(1.0d0+dcavtubpep*rdiff6*rdiff6)
21008 (bcavtubpep*rdiff+acavtubpep*dsqrt(rdiff)+ccavtubpep) &
21011 faccav=((bcavtubpep*1.0d0+acavtubpep/2.0d0/dsqrt(rdiff)) &
21012 *denominator-(bcavtubpep*rdiff+acavtubpep*dsqrt(rdiff) &
21013 +ccavtubpep)*rdiff6**2.0d0/rdiff*dcavtubpep*12.0d0) &
21014 /denominator**2.0d0
21019 if (energy_dec) write(iout,*),"ETUBE_PEP",i,rdiff,enetube(i),enecavtube(i)
21021 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac/2.0d0
21022 gg_tube(j,i)=gg_tube(j,i)+vectube(j)*fac/2.0d0
21026 do i=itube_start,itube_end
21027 enecavtube(i)=0.0d0
21028 !C Lets not jump over memory as we use many times iti
21030 !C lets ommit dummy atoms for now
21031 if ((iti.eq.ntyp1) &
21032 !C in UNRES uncomment the line below as GLY has no side-chain...
21038 call to_box(xi,yi,zi)
21039 tubezcenter=totTafm*velNANOconst+tubecenter(3)
21041 vectube(1)=boxshift(xi-tubecenter(1),boxxsize)
21042 vectube(2)=boxshift(yi-tubecenter(2),boxysize)
21043 vectube(3)=boxshift(zi-tubecenter(3),boxzsize)
21046 !C now calculte the distance
21047 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
21048 !C now normalize vector
21049 vectube(1)=vectube(1)/tub_r
21050 vectube(2)=vectube(2)/tub_r
21051 vectube(3)=vectube(3)/tub_r
21053 !C calculte rdiffrence between r and r0
21056 rdiff6=rdiff**6.0d0
21057 sc_aa_tube=sc_aa_tube_par(iti)
21058 sc_bb_tube=sc_bb_tube_par(iti)
21059 enetube(i+nres)=sc_aa_tube/rdiff6**2.0d0+sc_bb_tube/rdiff6
21060 !C enetube(i+nres)=0.0d0
21061 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
21062 !C now we calculate gradient
21063 fac=-12.0d0*sc_aa_tube/rdiff6**2.0d0/rdiff- &
21064 6.0d0*sc_bb_tube/rdiff6/rdiff
21066 !C now direction of gg_tube vector
21067 !C Now cavity term E=a(x+bsqrt(x)+c)/(1+dx^12)
21068 if (acavtub(iti).eq.0.0d0) then
21070 enecavtube(i+nres)=0.0d0
21073 denominator=(1.0d0+dcavtub(iti)*rdiff6*rdiff6)
21074 enecavtube(i+nres)= &
21075 (bcavtub(iti)*rdiff+acavtub(iti)*dsqrt(rdiff)+ccavtub(iti)) &
21077 !C enecavtube(i)=0.0
21078 faccav=((bcavtub(iti)*1.0d0+acavtub(iti)/2.0d0/dsqrt(rdiff)) &
21079 *denominator-(bcavtub(iti)*rdiff+acavtub(iti)*dsqrt(rdiff) &
21080 +ccavtub(iti))*rdiff6**2.0d0/rdiff*dcavtub(iti)*12.0d0) &
21081 /denominator**2.0d0
21086 !C print *,"TUT",i,iti,rdiff,rdiff6,acavtub(iti),denominator,
21087 !C & enecavtube(i),faccav
21088 !C print *,"licz=",
21089 !C & (bcavtub(iti)*rdiff+acavtub(iti)*sqrt(rdiff)+ccavtub(iti))
21090 !C print *,"finene=",enetube(i+nres)+enecavtube(i)
21092 gg_tube_SC(j,i)=gg_tube_SC(j,i)+vectube(j)*fac
21093 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac
21095 if (energy_dec) write(iout,*),"ETUBE",i,rdiff,enetube(i+nres),enecavtube(i+nres)
21100 do i=itube_start,itube_end
21101 Etube=Etube+enetube(i)+enetube(i+nres)+enecavtube(i) &
21102 +enecavtube(i+nres)
21105 do i=ilipbond_start_tub,ilipbond_end_tub
21107 ! print *,"ilipbond_start",ilipbond_start,i,ityp
21108 if (ityp.gt.ntyp_molec(4)) cycle
21109 !C now calculate distance from center of tube and direction vectors
21110 eps=lip_sig(ityp,18)*4.0d0
21111 sig=lip_sig(ityp,18)
21112 aa_tub_lip=eps/(sig**12)
21113 bb_tub_lip=eps/(sig**6)
21118 call to_box(xi,yi,zi)
21119 ! tubezcenter=totTafm*velNANOconst+tubecenter(3)
21121 vectube(1)=boxshift(xi-tubecenter(1),boxxsize)
21122 vectube(2)=boxshift(yi-tubecenter(2),boxysize)
21123 vectube(3)=boxshift(zi-tubecenter(3),boxzsize)
21125 !C print *,"x",(c(1,i)+c(1,i+1))/2.0d0,tubecenter(1)
21126 !C print *,"y",(c(2,i)+c(2,i+1))/2.0d0,tubecenter(2)
21127 !C as the tube is infinity we do not calculate the Z-vector use of Z
21129 !C vectube(3)=0.0d0
21130 !C now calculte the distance
21131 tub_r=dsqrt(vectube(1)**2+vectube(2)**2+vectube(3)**2)
21132 !C now normalize vector
21133 vectube(1)=vectube(1)/tub_r
21134 vectube(2)=vectube(2)/tub_r
21135 vectube(3)=vectube(3)/tub_r
21136 !C calculte rdiffrence between r and r0
21139 rdiff6=rdiff**6.0d0
21140 !C for vectorization reasons we will sumup at the end to avoid depenence of previous
21141 enetube(i)=aa_tub_lip/rdiff6**2.0d0+bb_tub_lip/rdiff6
21142 Etube=Etube+enetube(i)
21143 !C write(iout,*) "TU13",i,rdiff6,enetube(i)
21144 !C print *,rdiff,rdiff6,pep_aa_tube
21145 !C pep_aa_tube and pep_bb_tube are precomputed values A=4eps*sigma^12 B=4eps*sigma^6
21146 !C now we calculate gradient
21147 fac=(-12.0d0*aa_tub_lip/rdiff6- &
21148 6.0d0*bb_tub_lip)/rdiff6/rdiff
21150 gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac
21152 if (energy_dec) write(iout,*) "ETUBLIP",i,rdiff,enetube(i+nres)
21156 !-----------------------------------------------------------------------
21157 if (fg_rank.eq.0) then
21158 if (velNANOconst.ne.0) then
21165 cm(j)=cm(j)+c(j,ilol)
21169 cm(j)=cm(j)/inanomove
21171 vecsim=velNANOconst*totTafm+distnanoinit
21172 vectrue=cm(3)-tubecenter(3)
21173 etube=etube+0.5d0*forcenanoconst*( vectrue-vecsim)**2
21174 fac=forcenanoconst*(vectrue-vecsim)/inanomove
21177 gg_tube(3,ilol-1)=gg_tube(3,ilol-1)+fac
21182 ! print *,"begin", i,"a"
21185 ! rdiff6=rdiff**6.0d0
21186 ! sc_aa_tube=sc_aa_tube_par(i)
21187 ! sc_bb_tube=sc_bb_tube_par(i)
21188 ! enetube(i)=sc_aa_tube/rdiff6**2.0d0+sc_bb_tube/rdiff6
21189 ! denominator=(1.0d0+dcavtub(i)*rdiff6*rdiff6)
21191 ! (bcavtub(i)*rdiff+acavtub(i)*dsqrt(rdiff)+ccavtub(i)) &
21194 ! print '(5(f10.3,1x))',rdiff,enetube(i),enecavtube(i),enecavtube(i)+enetube(i)
21196 ! print *,"end",i,"a"
21198 !C print *,"ETUBE", etube
21200 end subroutine calcnano
21202 !===============================================
21203 !--------------------------------------------------------------------------------
21204 !C first for shielding is setting of function of side-chains
21206 subroutine set_shield_fac2
21207 real(kind=8) :: div77_81=0.974996043d0, &
21208 div4_81=0.2222222222d0
21209 real (kind=8) :: dist_pep_side,dist_side_calf,dist_pept_group, &
21210 scale_fac_dist,fac_help_scale,VofOverlap,VolumeTotal,costhet,&
21211 short,long,sinthet,costhet_fac,sh_frac_dist,rkprim,cosphi, &
21212 sinphi,cosphi_fac,pep_side0pept_group,cosalfa,fac_alfa_sin
21213 !C the vector between center of side_chain and peptide group
21214 real(kind=8),dimension(3) :: pep_side_long,side_calf, &
21215 pept_group,costhet_grad,cosphi_grad_long, &
21216 cosphi_grad_loc,pep_side_norm,side_calf_norm, &
21217 sh_frac_dist_grad,pep_side
21219 !C write(2,*) "ivec",ivec_start,ivec_end
21221 fac_shield(i)=0.0d0
21224 grad_shield(j,i)=0.0d0
21227 do i=ivec_start,ivec_end
21229 !C if ((itype(i,1).eq.ntyp1).and.itype(i+1,1).eq.ntyp1) cycle
21230 ! ishield_list(i)=0
21231 if ((itype(i,1).eq.ntyp1).and.itype(i+1,1).eq.ntyp1) cycle
21232 !Cif there two consequtive dummy atoms there is no peptide group between them
21233 !C the line below has to be changed for FGPROC>1
21236 if ((itype(k,1).eq.ntyp1).or.(itype(k,1).eq.10)) cycle
21240 !C first lets set vector conecting the ithe side-chain with kth side-chain
21241 pep_side(j)=c(j,k+nres)-(c(j,i)+c(j,i+1))/2.0d0
21242 !C pep_side(j)=2.0d0
21243 !C and vector conecting the side-chain with its proper calfa
21244 side_calf(j)=c(j,k+nres)-c(j,k)
21245 !C side_calf(j)=2.0d0
21246 pept_group(j)=c(j,i)-c(j,i+1)
21247 !C lets have their lenght
21248 dist_pep_side=pep_side(j)**2+dist_pep_side
21249 dist_side_calf=dist_side_calf+side_calf(j)**2
21250 dist_pept_group=dist_pept_group+pept_group(j)**2
21252 dist_pep_side=sqrt(dist_pep_side)
21253 dist_pept_group=sqrt(dist_pept_group)
21254 dist_side_calf=sqrt(dist_side_calf)
21256 pep_side_norm(j)=pep_side(j)/dist_pep_side
21257 side_calf_norm(j)=dist_side_calf
21259 !C now sscale fraction
21260 sh_frac_dist=-(dist_pep_side-rpp(1,1)-buff_shield)/buff_shield
21261 ! print *,buff_shield,"buff",sh_frac_dist
21263 if (sh_frac_dist.le.0.0) cycle
21264 !C print *,ishield_list(i),i
21265 !C If we reach here it means that this side chain reaches the shielding sphere
21266 !C Lets add him to the list for gradient
21267 ishield_list(i)=ishield_list(i)+1
21268 !C ishield_list is a list of non 0 side-chain that contribute to factor gradient
21269 !C this list is essential otherwise problem would be O3
21270 shield_list(ishield_list(i),i)=k
21271 !C Lets have the sscale value
21272 if (sh_frac_dist.gt.1.0) then
21273 scale_fac_dist=1.0d0
21275 sh_frac_dist_grad(j)=0.0d0
21278 scale_fac_dist=-sh_frac_dist*sh_frac_dist &
21279 *(2.0d0*sh_frac_dist-3.0d0)
21280 fac_help_scale=6.0d0*(sh_frac_dist-sh_frac_dist**2) &
21281 /dist_pep_side/buff_shield*0.5d0
21283 sh_frac_dist_grad(j)=fac_help_scale*pep_side(j)
21284 !C sh_frac_dist_grad(j)=0.0d0
21285 !C scale_fac_dist=1.0d0
21286 !C print *,"jestem",scale_fac_dist,fac_help_scale,
21287 !C & sh_frac_dist_grad(j)
21290 !C this is what is now we have the distance scaling now volume...
21291 short=short_r_sidechain(itype(k,1))
21292 long=long_r_sidechain(itype(k,1))
21293 costhet=1.0d0/dsqrt(1.0d0+short**2/dist_pep_side**2)
21294 sinthet=short/dist_pep_side*costhet
21295 ! print *,"SORT",short,long,sinthet,costhet
21296 !C now costhet_grad
21299 costhet_fac=costhet**3*short**2*(-0.5d0)/dist_pep_side**4
21300 !C sinthet_fac=costhet**2*0.5d0*(short**3/dist_pep_side**4*costhet
21301 !C & -short/dist_pep_side**2/costhet)
21302 !C costhet_fac=0.0d0
21304 costhet_grad(j)=costhet_fac*pep_side(j)
21306 !C remember for the final gradient multiply costhet_grad(j)
21307 !C for side_chain by factor -2 !
21308 !C fac alfa is angle between CB_k,CA_k, CA_i,CA_i+1
21309 !C pep_side0pept_group is vector multiplication
21310 pep_side0pept_group=0.0d0
21312 pep_side0pept_group=pep_side0pept_group+pep_side(j)*side_calf(j)
21314 cosalfa=(pep_side0pept_group/ &
21315 (dist_pep_side*dist_side_calf))
21316 fac_alfa_sin=1.0d0-cosalfa**2
21317 fac_alfa_sin=dsqrt(fac_alfa_sin)
21318 rkprim=fac_alfa_sin*(long-short)+short
21321 !C now costhet_grad
21322 cosphi=1.0d0/dsqrt(1.0d0+rkprim**2/dist_pep_side**2)
21324 cosphi_fac=cosphi**3*rkprim**2*(-0.5d0)/dist_pep_side**4
21325 sinphi=rkprim/dist_pep_side/dsqrt(1.0d0+rkprim**2/ &
21329 cosphi_grad_long(j)=cosphi_fac*pep_side(j) &
21330 +cosphi**3*0.5d0/dist_pep_side**2*(-rkprim) &
21331 *(long-short)/fac_alfa_sin*cosalfa/ &
21332 ((dist_pep_side*dist_side_calf))* &
21333 ((side_calf(j))-cosalfa* &
21334 ((pep_side(j)/dist_pep_side)*dist_side_calf))
21335 !C cosphi_grad_long(j)=0.0d0
21336 cosphi_grad_loc(j)=cosphi**3*0.5d0/dist_pep_side**2*(-rkprim) &
21337 *(long-short)/fac_alfa_sin*cosalfa &
21338 /((dist_pep_side*dist_side_calf))* &
21340 cosalfa*side_calf(j)/dist_side_calf*dist_pep_side)
21341 !C cosphi_grad_loc(j)=0.0d0
21343 !C print *,sinphi,sinthet
21344 VofOverlap=VSolvSphere/2.0d0*(1.0d0-dsqrt(1.0d0-sinphi*sinthet)) &
21347 !C now the gradient...
21349 grad_shield(j,i)=grad_shield(j,i) &
21350 !C gradient po skalowaniu
21351 +(sh_frac_dist_grad(j)*VofOverlap &
21352 !C gradient po costhet
21353 +scale_fac_dist*VSolvSphere/VSolvSphere_div/4.0d0* &
21354 (1.0d0/(-dsqrt(1.0d0-sinphi*sinthet))*( &
21355 sinphi/sinthet*costhet*costhet_grad(j) &
21356 +sinthet/sinphi*cosphi*cosphi_grad_long(j))) &
21358 !C grad_shield_side is Cbeta sidechain gradient
21359 grad_shield_side(j,ishield_list(i),i)=&
21360 (sh_frac_dist_grad(j)*-2.0d0&
21362 -scale_fac_dist*VSolvSphere/VSolvSphere_div/2.0d0*&
21363 (1.0d0/(-dsqrt(1.0d0-sinphi*sinthet))*(&
21364 sinphi/sinthet*costhet*costhet_grad(j)&
21365 +sinthet/sinphi*cosphi*cosphi_grad_long(j))) &
21367 ! print *, 1.0d0/(-dsqrt(1.0d0-sinphi*sinthet)),&
21369 ! +sinthet/sinphi,"HERE"
21370 grad_shield_loc(j,ishield_list(i),i)= &
21371 scale_fac_dist*VSolvSphere/VSolvSphere_div/2.0d0*&
21372 (1.0d0/(dsqrt(1.0d0-sinphi*sinthet))*(&
21373 sinthet/sinphi*cosphi*cosphi_grad_loc(j)&
21376 ! print *,grad_shield_loc(j,ishield_list(i),i)
21378 VolumeTotal=VolumeTotal+VofOverlap*scale_fac_dist
21380 fac_shield(i)=VolumeTotal*wshield+(1.0d0-wshield)
21382 ! write(2,*) "TOTAL VOLUME",i,itype(i,1),fac_shield(i)
21385 end subroutine set_shield_fac2
21386 !----------------------------------------------------------------------------
21387 ! SOUBROUTINE FOR AFM
21388 subroutine AFMvel(Eafmforce)
21389 use MD_data, only:totTafm
21390 real(kind=8),dimension(3) :: diffafm,cbeg,cend
21391 real(kind=8) :: afmdist,Eafmforce
21393 !C Only for check grad COMMENT if not used for checkgrad
21395 !C--------------------------------------------------------
21396 !C print *,"wchodze"
21401 if (afmbeg.eq.-1) then
21404 cbeg(j)=cbeg(j)+c(j,afmbegcentr(i))/nbegafmmat
21409 cbeg(j)=c(j,afmend)
21412 if (afmend.eq.-1) then
21415 cend(j)=cend(j)+c(j,afmendcentr(i))/nendafmmat
21419 cend(j)=c(j,afmend)
21423 diffafm(i)=cend(i)-cbeg(i)
21424 afmdist=afmdist+diffafm(i)**2
21426 afmdist=dsqrt(afmdist)
21428 Eafmforce=0.5d0*forceAFMconst &
21429 *(distafminit+totTafm*velAFMconst-afmdist)**2
21430 !C Eafmforce=-forceAFMconst*(dist-distafminit)
21431 if (afmend.eq.-1) then
21434 gradafm(j,afmendcentr(i)-1)=-forceAFMconst* &
21435 (distafminit+totTafm*velAFMconst-afmdist) &
21436 *diffafm(j)/afmdist/nendafmmat
21441 gradafm(i,afmend-1)=-forceAFMconst* &
21442 (distafminit+totTafm*velAFMconst-afmdist) &
21443 *diffafm(i)/afmdist
21446 if (afmbeg.eq.-1) then
21449 gradafm(i,afmbegcentr(i)-1)=forceAFMconst* &
21450 (distafminit+totTafm*velAFMconst-afmdist) &
21451 *diffafm(i)/afmdist
21456 gradafm(i,afmbeg-1)=forceAFMconst* &
21457 (distafminit+totTafm*velAFMconst-afmdist) &
21458 *diffafm(i)/afmdist
21461 ! print *,'AFM',Eafmforce,totTafm*velAFMconst,afmdist
21463 end subroutine AFMvel
21464 !---------------------------------------------------------
21465 subroutine AFMforce(Eafmforce)
21467 real(kind=8),dimension(3) :: diffafm
21468 ! real(kind=8) ::afmdist
21469 real(kind=8) :: afmdist,Eafmforce
21474 diffafm(i)=c(i,afmend)-c(i,afmbeg)
21475 afmdist=afmdist+diffafm(i)**2
21477 afmdist=dsqrt(afmdist)
21478 ! print *,afmdist,distafminit
21479 Eafmforce=-forceAFMconst*(afmdist-distafminit)
21481 gradafm(i,afmend-1)=-forceAFMconst*diffafm(i)/afmdist
21482 gradafm(i,afmbeg-1)=forceAFMconst*diffafm(i)/afmdist
21484 !C print *,'AFM',Eafmforce
21486 end subroutine AFMforce
21488 !-----------------------------------------------------------------------------
21490 subroutine read_ssHist
21493 ! include 'DIMENSIONS'
21494 ! include "DIMENSIONS.FREE"
21495 ! include 'COMMON.FREE'
21498 character(len=80) :: controlcard
21501 call card_concat(controlcard,.true.)
21502 read(controlcard,*) &
21503 dyn_ssHist(i,0),(dyn_ssHist(i,j),j=1,2*dyn_ssHist(i,0))
21507 end subroutine read_ssHist
21509 !-----------------------------------------------------------------------------
21510 integer function indmat(i,j)
21512 ! get the position of the jth ijth fragment of the chain coordinate system
21513 ! in the fromto array.
21516 indmat=((2*(nres-2)-i)*(i-1))/2+j-1
21518 end function indmat
21519 !-----------------------------------------------------------------------------
21520 real(kind=8) function sigm(x)
21526 !-----------------------------------------------------------------------------
21527 !-----------------------------------------------------------------------------
21528 subroutine alloc_ener_arrays
21529 !EL Allocation of arrays used by module energy
21530 use MD_data, only: mset
21531 !el local variables
21534 if(nres.lt.100) then
21536 elseif(nres.lt.200) then
21537 maxconts=10*nres ! Max. number of contacts per residue
21539 maxconts=10*nres ! (maxconts=maxres/4)
21541 maxcont=100*nres ! Max. number of SC contacts
21542 maxvar=6*nres ! Max. number of variables
21543 !el maxdim=(nres-1)*(nres-2)/2 ! Max. number of derivatives of virtual-bond
21544 maxdim=nres*(nres-2)/2 ! Max. number of derivatives of virtual-bond
21545 !----------------------
21546 ! arrays in subroutine init_int_table
21548 !el allocate(itask_cont_from(0:nfgtasks-1)) !(0:max_fg_procs-1)
21549 !el allocate(itask_cont_to(0:nfgtasks-1)) !(0:max_fg_procs-1)
21551 allocate(nint_gr(nres))
21552 allocate(nscp_gr(nres))
21553 allocate(ielstart(nres))
21554 allocate(ielend(nres))
21556 allocate(istart(nres,maxint_gr))
21557 allocate(iend(nres,maxint_gr))
21558 !(maxres,maxint_gr)
21559 allocate(iscpstart(nres,maxint_gr))
21560 allocate(iscpend(nres,maxint_gr))
21561 !(maxres,maxint_gr)
21562 allocate(ielstart_vdw(nres))
21563 allocate(ielend_vdw(nres))
21565 allocate(nint_gr_nucl(nres))
21566 allocate(nscp_gr_nucl(nres))
21567 allocate(ielstart_nucl(nres))
21568 allocate(ielend_nucl(nres))
21570 allocate(istart_nucl(nres,maxint_gr))
21571 allocate(iend_nucl(nres,maxint_gr))
21572 !(maxres,maxint_gr)
21573 allocate(iscpstart_nucl(nres,maxint_gr))
21574 allocate(iscpend_nucl(nres,maxint_gr))
21575 !(maxres,maxint_gr)
21576 allocate(ielstart_vdw_nucl(nres))
21577 allocate(ielend_vdw_nucl(nres))
21579 allocate(lentyp(0:nfgtasks-1))
21581 !----------------------
21583 ! common /contacts/
21584 if(.not.allocated(icont_ref)) allocate(icont_ref(2,maxcont))
21585 allocate(icont(2,maxcont))
21587 ! common /contacts1/
21588 allocate(num_cont(0:nres+4))
21591 allocate(jcont(maxconts,nres))
21593 allocate(facont(maxconts,nres))
21595 allocate(gacont(3,maxconts,nres))
21596 !(3,maxconts,maxres)
21597 ! common /contacts_hb/
21598 allocate(gacontp_hb1(3,maxconts,nres))
21599 allocate(gacontp_hb2(3,maxconts,nres))
21600 allocate(gacontp_hb3(3,maxconts,nres))
21601 allocate(gacontm_hb1(3,maxconts,nres))
21602 allocate(gacontm_hb2(3,maxconts,nres))
21603 allocate(gacontm_hb3(3,maxconts,nres))
21604 allocate(gacont_hbr(3,maxconts,nres))
21605 allocate(grij_hb_cont(3,maxconts,nres))
21606 !(3,maxconts,maxres)
21607 allocate(facont_hb(maxconts,nres))
21609 allocate(ees0p(maxconts,nres))
21610 allocate(ees0m(maxconts,nres))
21611 allocate(d_cont(maxconts,nres))
21612 allocate(ees0plist(maxconts,nres))
21616 allocate(jcont_hb(maxconts,nres))
21618 allocate(num_cont_hb(nres))
21621 allocate(Ug(2,2,nres))
21622 allocate(Ugder(2,2,nres))
21623 allocate(Ug2(2,2,nres))
21624 allocate(Ug2der(2,2,nres))
21626 allocate(obrot(2,nres))
21627 allocate(obrot2(2,nres))
21628 allocate(obrot_der(2,nres))
21629 allocate(obrot2_der(2,nres))
21631 ! common /precomp1/
21632 allocate(mu(2,nres))
21633 allocate(muder(2,nres))
21634 allocate(Ub2(2,nres))
21637 allocate(Ub2der(2,nres))
21638 allocate(Ctobr(2,nres))
21639 allocate(Ctobrder(2,nres))
21640 allocate(Dtobr2(2,nres))
21641 allocate(Dtobr2der(2,nres))
21643 allocate(EUg(2,2,nres))
21644 allocate(EUgder(2,2,nres))
21645 allocate(CUg(2,2,nres))
21646 allocate(CUgder(2,2,nres))
21647 allocate(DUg(2,2,nres))
21648 allocate(Dugder(2,2,nres))
21649 allocate(DtUg2(2,2,nres))
21650 allocate(DtUg2der(2,2,nres))
21652 ! common /precomp2/
21653 allocate(Ug2Db1t(2,nres))
21654 allocate(Ug2Db1tder(2,nres))
21655 allocate(CUgb2(2,nres))
21656 allocate(CUgb2der(2,nres))
21658 allocate(EUgC(2,2,nres))
21659 allocate(EUgCder(2,2,nres))
21660 allocate(EUgD(2,2,nres))
21661 allocate(EUgDder(2,2,nres))
21662 allocate(DtUg2EUg(2,2,nres))
21663 allocate(Ug2DtEUg(2,2,nres))
21665 allocate(Ug2DtEUgder(2,2,2,nres))
21666 allocate(DtUg2EUgder(2,2,2,nres))
21668 allocate(b1(2,nres)) !(2,-maxtor:maxtor)
21669 allocate(b2(2,nres)) !(2,-maxtor:maxtor)
21670 allocate(b1tilde(2,nres)) !(2,-maxtor:maxtor)
21671 allocate(b2tilde(2,nres)) !(2,-maxtor:maxtor)
21673 allocate(ctilde(2,2,nres))
21674 allocate(dtilde(2,2,nres)) !(2,2,-maxtor:maxtor)
21675 allocate(gtb1(2,nres))
21676 allocate(gtb2(2,nres))
21677 allocate(cc(2,2,nres))
21678 allocate(dd(2,2,nres))
21679 allocate(ee(2,2,nres))
21680 allocate(gtcc(2,2,nres))
21681 allocate(gtdd(2,2,nres))
21682 allocate(gtee(2,2,nres))
21683 allocate(gUb2(2,nres))
21684 allocate(gteUg(2,2,nres))
21686 ! common /rotat_old/
21687 allocate(costab(nres))
21688 allocate(sintab(nres))
21689 allocate(costab2(nres))
21690 allocate(sintab2(nres))
21693 ! allocate(a_chuj(2,2,maxconts,nres))
21694 !(2,2,maxconts,maxres)(maxconts=maxres/4)
21695 ! allocate(a_chuj_der(2,2,3,5,maxconts,nres))
21696 !(2,2,3,5,maxconts,maxres)(maxconts=maxres/4)
21697 ! common /contdistrib/
21698 allocate(ncont_sent(nres))
21699 allocate(ncont_recv(nres))
21701 allocate(iat_sent(nres))
21704 print *,"before iint_sent allocate"
21705 allocate(iint_sent(4,nres,nres))
21706 allocate(iint_sent_local(4,nres,nres))
21707 print *,"after iint_sent allocate"
21710 allocate(iturn3_sent(4,0:nres+4))
21711 allocate(iturn4_sent(4,0:nres+4))
21712 allocate(iturn3_sent_local(4,nres))
21713 allocate(iturn4_sent_local(4,nres))
21715 allocate(itask_cont_from(0:nfgtasks-1))
21716 allocate(itask_cont_to(0:nfgtasks-1))
21717 !(0:max_fg_procs-1)
21721 !----------------------
21725 print *,"before dcdv allocate"
21726 allocate(dcdv(6,nres+2))
21727 allocate(dxdv(6,nres+2))
21729 print *,"before dcdv allocate"
21730 allocate(dcdv(6,maxdim))
21731 allocate(dxdv(6,maxdim))
21734 allocate(dxds(6,nres))
21736 allocate(gradx(3,-1:nres,0:2))
21737 allocate(gradc(3,-1:nres,0:2))
21739 allocate(gvdwx(3,-1:nres))
21740 allocate(gvdwc(3,-1:nres))
21741 allocate(gelc(3,-1:nres))
21742 allocate(gelc_long(3,-1:nres))
21743 allocate(gvdwpp(3,-1:nres))
21744 allocate(gvdwc_scpp(3,-1:nres))
21745 allocate(gradx_scp(3,-1:nres))
21746 allocate(gvdwc_scp(3,-1:nres))
21747 allocate(ghpbx(3,-1:nres))
21748 allocate(ghpbc(3,-1:nres))
21749 allocate(gradcorr(3,-1:nres))
21750 allocate(gradcorr_long(3,-1:nres))
21751 allocate(gradcorr5_long(3,-1:nres))
21752 allocate(gradcorr6_long(3,-1:nres))
21753 allocate(gcorr6_turn_long(3,-1:nres))
21754 allocate(gradxorr(3,-1:nres))
21755 allocate(gradcorr5(3,-1:nres))
21756 allocate(gradcorr6(3,-1:nres))
21757 allocate(gliptran(3,-1:nres))
21758 allocate(gliptranc(3,-1:nres))
21759 allocate(gliptranx(3,-1:nres))
21760 allocate(gshieldx(3,-1:nres))
21761 allocate(gshieldc(3,-1:nres))
21762 allocate(gshieldc_loc(3,-1:nres))
21763 allocate(gshieldx_ec(3,-1:nres))
21764 allocate(gshieldc_ec(3,-1:nres))
21765 allocate(gshieldc_loc_ec(3,-1:nres))
21766 allocate(gshieldx_t3(3,-1:nres))
21767 allocate(gshieldc_t3(3,-1:nres))
21768 allocate(gshieldc_loc_t3(3,-1:nres))
21769 allocate(gshieldx_t4(3,-1:nres))
21770 allocate(gshieldc_t4(3,-1:nres))
21771 allocate(gshieldc_loc_t4(3,-1:nres))
21772 allocate(gshieldx_ll(3,-1:nres))
21773 allocate(gshieldc_ll(3,-1:nres))
21774 allocate(gshieldc_loc_ll(3,-1:nres))
21775 allocate(grad_shield(3,-1:nres))
21776 allocate(gg_tube_sc(3,-1:nres))
21777 allocate(gg_tube(3,-1:nres))
21778 allocate(gradafm(3,-1:nres))
21779 allocate(gradb_nucl(3,-1:nres))
21780 allocate(gradbx_nucl(3,-1:nres))
21781 allocate(gvdwpsb1(3,-1:nres))
21782 allocate(gelpp(3,-1:nres))
21783 allocate(gvdwpsb(3,-1:nres))
21784 allocate(gelsbc(3,-1:nres))
21785 allocate(gelsbx(3,-1:nres))
21786 allocate(gvdwsbx(3,-1:nres))
21787 allocate(gvdwsbc(3,-1:nres))
21788 allocate(gsbloc(3,-1:nres))
21789 allocate(gsblocx(3,-1:nres))
21790 allocate(gradcorr_nucl(3,-1:nres))
21791 allocate(gradxorr_nucl(3,-1:nres))
21792 allocate(gradcorr3_nucl(3,-1:nres))
21793 allocate(gradxorr3_nucl(3,-1:nres))
21794 allocate(gvdwpp_nucl(3,-1:nres))
21795 allocate(gradpepcat(3,-1:nres))
21796 allocate(gradpepcatx(3,-1:nres))
21797 allocate(gradcatcat(3,-1:nres))
21798 allocate(gradnuclcat(3,-1:nres))
21799 allocate(gradnuclcatx(3,-1:nres))
21800 allocate(gradlipbond(3,-1:nres))
21801 allocate(gradlipang(3,-1:nres))
21802 allocate(gradliplj(3,-1:nres))
21803 allocate(gradlipelec(3,-1:nres))
21804 allocate(gradcattranc(3,-1:nres))
21805 allocate(gradcattranx(3,-1:nres))
21806 allocate(gradcatangx(3,-1:nres))
21807 allocate(gradcatangc(3,-1:nres))
21809 allocate(grad_shield_side(3,maxcontsshi,-1:nres))
21810 allocate(grad_shield_loc(3,maxcontsshi,-1:nres))
21811 ! grad for shielding surroing
21812 allocate(gloc(0:maxvar,0:2))
21813 allocate(gloc_x(0:maxvar,2))
21815 allocate(gel_loc(3,-1:nres))
21816 allocate(gel_loc_long(3,-1:nres))
21817 allocate(gcorr3_turn(3,-1:nres))
21818 allocate(gcorr4_turn(3,-1:nres))
21819 allocate(gcorr6_turn(3,-1:nres))
21820 allocate(gradb(3,-1:nres))
21821 allocate(gradbx(3,-1:nres))
21823 allocate(gel_loc_loc(maxvar))
21824 allocate(gel_loc_turn3(maxvar))
21825 allocate(gel_loc_turn4(maxvar))
21826 allocate(gel_loc_turn6(maxvar))
21827 allocate(gcorr_loc(maxvar))
21828 allocate(g_corr5_loc(maxvar))
21829 allocate(g_corr6_loc(maxvar))
21831 allocate(gsccorc(3,-1:nres))
21832 allocate(gsccorx(3,-1:nres))
21834 allocate(gsccor_loc(-1:nres))
21836 allocate(gvdwx_scbase(3,-1:nres))
21837 allocate(gvdwc_scbase(3,-1:nres))
21838 allocate(gvdwx_pepbase(3,-1:nres))
21839 allocate(gvdwc_pepbase(3,-1:nres))
21840 allocate(gvdwx_scpho(3,-1:nres))
21841 allocate(gvdwc_scpho(3,-1:nres))
21842 allocate(gvdwc_peppho(3,-1:nres))
21844 allocate(dtheta(3,2,-1:nres))
21846 allocate(gscloc(3,-1:nres))
21847 allocate(gsclocx(3,-1:nres))
21849 allocate(dphi(3,3,-1:nres))
21850 allocate(dalpha(3,3,-1:nres))
21851 allocate(domega(3,3,-1:nres))
21853 ! common /deriv_scloc/
21854 allocate(dXX_C1tab(3,nres))
21855 allocate(dYY_C1tab(3,nres))
21856 allocate(dZZ_C1tab(3,nres))
21857 allocate(dXX_Ctab(3,nres))
21858 allocate(dYY_Ctab(3,nres))
21859 allocate(dZZ_Ctab(3,nres))
21860 allocate(dXX_XYZtab(3,nres))
21861 allocate(dYY_XYZtab(3,nres))
21862 allocate(dZZ_XYZtab(3,nres))
21865 allocate(jgrad_start(nres))
21866 allocate(jgrad_end(nres))
21868 !----------------------
21871 allocate(ibond_displ(0:nfgtasks-1))
21872 allocate(ibond_count(0:nfgtasks-1))
21873 allocate(ithet_displ(0:nfgtasks-1))
21874 allocate(ithet_count(0:nfgtasks-1))
21875 allocate(iphi_displ(0:nfgtasks-1))
21876 allocate(iphi_count(0:nfgtasks-1))
21877 allocate(iphi1_displ(0:nfgtasks-1))
21878 allocate(iphi1_count(0:nfgtasks-1))
21879 allocate(ivec_displ(0:nfgtasks-1))
21880 allocate(ivec_count(0:nfgtasks-1))
21881 allocate(iset_displ(0:nfgtasks-1))
21882 allocate(iset_count(0:nfgtasks-1))
21883 allocate(iint_count(0:nfgtasks-1))
21884 allocate(iint_displ(0:nfgtasks-1))
21885 !(0:max_fg_procs-1)
21886 !----------------------
21889 allocate(gcart(3,-1:nres))
21890 allocate(gxcart(3,-1:nres))
21892 allocate(gradcag(3,-1:nres))
21893 allocate(gradxag(3,-1:nres))
21895 ! common /back_constr/
21896 !el in energy:Econstr_back allocate((:),allocatable :: utheta,ugamma,uscdiff !(maxfrag_back)
21897 allocate(dutheta(nres))
21898 allocate(dugamma(nres))
21900 allocate(duscdiff(3,-1:nres))
21901 allocate(duscdiffx(3,-1:nres))
21903 !el i io:read_fragments
21904 ! allocate((:,:,:),allocatable :: wfrag_back !(3,maxfrag_back,maxprocs/20)
21905 ! allocate((:,:,:),allocatable :: ifrag_back !(3,maxfrag_back,maxprocs/20)
21907 ! allocate(qinfrag(50,nprocs/20),wfrag(50,nprocs/20)) !(50,maxprocs/20)
21908 ! allocate(qinpair(100,nprocs/20),wpair(100,nprocs/20)) !(100,maxprocs/20)
21909 allocate(mset(0:nprocs)) !(maxprocs/20)
21911 ! allocate(ifrag(2,50,nprocs/20)) !(2,50,maxprocs/20)
21912 ! allocate(ipair(2,100,nprocs/20)) !(2,100,maxprocs/20)
21913 allocate(dUdconst(3,0:nres))
21914 allocate(dUdxconst(3,0:nres))
21915 allocate(dqwol(3,0:nres))
21916 allocate(dxqwol(3,0:nres))
21918 !----------------------
21920 ! common /sbridge/ in io_common: read_bridge
21921 !el allocate((:),allocatable :: iss !(maxss)
21922 ! common /links/ in io_common: read_bridge
21923 !el real(kind=8),dimension(:),allocatable :: dhpb,forcon,dhpb1 !(maxdim) !el dhpb1 !!! nie używane
21924 !el integer,dimension(:),allocatable :: ihpb,jhpb,ibecarb !(maxdim) !el ibecarb !!! nie używane
21925 ! common /dyn_ssbond/
21926 ! and side-chain vectors in theta or phi.
21927 allocate(dyn_ssbond_ij(10000))
21931 dyn_ssbond_ij(:)=1.0d300
21935 ! if (nss.gt.0) then
21936 allocate(idssb(maxdim),jdssb(maxdim))
21937 ! allocate(newihpb(nss),newjhpb(nss))
21940 allocate(ishield_list(-1:nres))
21941 allocate(shield_list(maxcontsshi,-1:nres))
21942 allocate(dyn_ss_mask(nres))
21943 allocate(fac_shield(-1:nres))
21944 allocate(enetube(nres*2))
21945 allocate(enecavtube(nres*2))
21948 dyn_ss_mask(:)=.false.
21949 !----------------------
21951 ! Parameters of the SCCOR term
21953 !el in io_conf: parmread
21954 ! allocate(v1sccor(maxterm_sccor,3,-ntyp:ntyp,-ntyp:ntyp))
21955 ! allocate(v2sccor(maxterm_sccor,3,-ntyp:ntyp,-ntyp:ntyp)) !(maxterm_sccor,3,-ntyp:ntyp,-ntyp:ntyp)
21956 ! allocate(v0sccor(maxterm_sccor,-ntyp:ntyp,-ntyp:ntyp)) !(maxterm_sccor,-ntyp:ntyp,-ntyp:ntyp)
21957 ! allocate(isccortyp(-ntyp:ntyp)) !(-ntyp:ntyp)
21958 ! allocate(nterm_sccor(-ntyp:ntyp,-ntyp:ntyp))
21959 ! allocate(nlor_sccor(-ntyp:ntyp,-ntyp:ntyp)) !(-ntyp:ntyp,-ntyp:ntyp)
21960 ! allocate(vlor1sccor(maxterm_sccor,20,20))
21961 ! allocate(vlor2sccor(maxterm_sccor,20,20))
21962 ! allocate(vlor3sccor(maxterm_sccor,20,20)) !(maxterm_sccor,20,20)
21964 allocate(gloc_sc(3,0:2*nres,0:10))
21965 !(3,0:maxres2,10)maxres2=2*maxres
21966 allocate(dcostau(3,3,3,2*nres))
21967 allocate(dsintau(3,3,3,2*nres))
21968 allocate(dtauangle(3,3,3,2*nres))
21969 allocate(dcosomicron(3,3,3,2*nres))
21970 allocate(domicron(3,3,3,2*nres))
21971 !(3,3,3,maxres2)maxres2=2*maxres
21972 !----------------------
21975 allocate(varall(maxvar))
21976 !(maxvar)(maxvar=6*maxres)
21977 allocate(mask_theta(nres))
21978 allocate(mask_phi(nres))
21979 allocate(mask_side(nres))
21981 !----------------------
21984 allocate(uy(3,nres))
21985 allocate(uz(3,nres))
21987 allocate(uygrad(3,3,2,nres))
21988 allocate(uzgrad(3,3,2,nres))
21990 print *,"before all 300"
21991 ! allocateion of lists JPRDLA
21992 allocate(newcontlistppi(300*nres))
21993 allocate(newcontlistscpi(350*nres))
21994 allocate(newcontlisti(300*nres))
21995 allocate(newcontlistppj(300*nres))
21996 allocate(newcontlistscpj(350*nres))
21997 allocate(newcontlistj(300*nres))
21998 allocate(newcontlistcatsctrani(300*nres))
21999 allocate(newcontlistcatsctranj(300*nres))
22000 allocate(newcontlistcatptrani(300*nres))
22001 allocate(newcontlistcatptranj(300*nres))
22002 allocate(newcontlistcatscnormi(300*nres))
22003 allocate(newcontlistcatscnormj(300*nres))
22004 allocate(newcontlistcatpnormi(300*nres))
22005 allocate(newcontlistcatpnormj(300*nres))
22006 allocate(newcontlistcatcatnormi(900*nres))
22007 allocate(newcontlistcatcatnormj(900*nres))
22009 allocate(newcontlistcatscangi(300*nres))
22010 allocate(newcontlistcatscangj(300*nres))
22011 allocate(newcontlistcatscangfi(300*nres))
22012 allocate(newcontlistcatscangfj(300*nres))
22013 allocate(newcontlistcatscangfk(300*nres))
22014 allocate(newcontlistcatscangti(300*nres))
22015 allocate(newcontlistcatscangtj(300*nres))
22016 allocate(newcontlistcatscangtk(300*nres))
22017 allocate(newcontlistcatscangtl(300*nres))
22021 end subroutine alloc_ener_arrays
22022 !-----------------------------------------------------------------
22023 subroutine ebond_nucl(estr_nucl)
22025 !c Evaluate the energy of stretching of the CA-CA and CA-SC virtual bonds
22028 real(kind=8),dimension(3) :: u,ud
22029 real(kind=8) :: usum,uprod,uprod1,uprod2,usumsqder
22030 real(kind=8) :: estr_nucl,diff
22031 integer :: iti,i,j,k,nbi
22033 !C print *,"I enter ebond"
22035 write (iout,*) "ibondp_start,ibondp_end",&
22036 ibondp_nucl_start,ibondp_nucl_end
22037 do i=ibondp_nucl_start,ibondp_nucl_end
22039 if (itype(i-1,2).eq.ntyp1_molec(2)&
22040 .and.itype(i,2).eq.ntyp1_molec(2)) cycle
22041 if (itype(i-1,2).eq.ntyp1_molec(2)&
22042 .or. itype(i,2).eq.ntyp1_molec(2)) then
22043 !C estr1=estr1+gnmr1(vbld(i),-1.0d0,distchainmax)
22045 !C gradb(j,i-1)=gnmr1prim(vbld(i),-1.0d0,distchainmax) &
22046 !C *dc(j,i-1)/vbld(i)
22048 !C if (energy_dec) write(iout,*) &
22049 !C "estr1",i,gnmr1(vbld(i),-1.0d0,distchainmax)
22050 diff = vbld(i)-vbldpDUM
22052 diff = vbld(i)-vbldp0_nucl
22054 ! estr1=estr1+gnmr1(vbld(i),-1.0d0,distchainmax)
22056 ! gradb(j,i-1)=gnmr1prim(vbld(i),-1.0d0,distchainmax)
22057 ! & *dc(j,i-1)/vbld(i)
22059 ! if (energy_dec) write(iout,*)
22060 ! & "estr1",i,vbld(i),distchainmax,
22061 ! & gnmr1(vbld(i),-1.0d0,distchainmax)
22063 if(energy_dec)write(iout,*) "estr_nucl_bb" , i,vbld(i),&
22064 vbldp0_nucl,diff,AKP_nucl*diff*diff
22065 estr_nucl=estr_nucl+diff*diff
22066 ! print *,estr_nucl
22068 gradb_nucl(j,i-1)=AKP_nucl*diff*dc(j,i-1)/vbld(i)
22070 !c write (iout,'(i5,3f10.5)') i,(gradb(j,i-1),j=1,3)
22072 estr_nucl=0.5d0*AKP_nucl*estr_nucl
22073 ! print *,"partial sum", estr_nucl,AKP_nucl
22076 write (iout,*) "ibondp_start,ibondp_end",&
22077 ibond_nucl_start,ibond_nucl_end
22079 do i=ibond_nucl_start,ibond_nucl_end
22080 !C print *, "I am stuck",i
22082 if (iti.eq.ntyp1_molec(2)) cycle
22083 nbi=nbondterm_nucl(iti)
22086 diff=vbld(i+nres)-vbldsc0_nucl(1,iti)
22089 write (iout,*) "estr_nucl_sc", i,iti,vbld(i+nres),vbldsc0_nucl(1,iti),diff, &
22090 AKSC_nucl(1,iti),AKSC_nucl(1,iti)*diff*diff
22091 estr_nucl=estr_nucl+0.5d0*AKSC_nucl(1,iti)*diff*diff
22092 ! print *,estr_nucl
22094 gradbx_nucl(j,i)=AKSC_nucl(1,iti)*diff*dc(j,i+nres)/vbld(i+nres)
22098 diff=vbld(i+nres)-vbldsc0_nucl(j,iti)
22099 ud(j)=aksc_nucl(j,iti)*diff
22100 u(j)=abond0_nucl(j,iti)+0.5d0*ud(j)*diff
22114 uprod2=uprod2*u(k)*u(k)
22118 usumsqder=usumsqder+ud(j)*uprod2
22120 estr_nucl=estr_nucl+uprod/usum
22122 gradbx_nucl(j,i)=usumsqder/(usum*usum)*dc(j,i+nres)/vbld(i+nres)
22126 !C print *,"I am about to leave ebond"
22128 end subroutine ebond_nucl
22130 !-----------------------------------------------------------------------------
22131 subroutine ebend_nucl(etheta_nucl)
22132 real(kind=8),dimension(nntheterm_nucl+1) :: coskt,sinkt !mmaxtheterm
22133 real(kind=8),dimension(nsingle_nucl+1) :: cosph1,sinph1,cosph2,sinph2 !maxsingle
22134 real(kind=8),dimension(ndouble_nucl+1,ndouble_nucl+1) :: cosph1ph2,sinph1ph2 !maxdouble,maxdouble
22135 logical :: lprn=.false., lprn1=.false.
22136 !el local variables
22137 integer :: i,k,iblock,ityp1,ityp2,ityp3,l,m
22138 real(kind=8) :: dethetai,dephii,dephii1,theti2,phii,phii1,ethetai
22139 real(kind=8) :: aux,etheta_nucl,ccl,ssl,scl,csl,ethetacnstr
22140 ! local variables for constrains
22141 real(kind=8) :: difi,thetiii
22144 ! print *,"ithet_start",ithet_nucl_start," ithet_end",ithet_nucl_end,nres
22145 do i=ithet_nucl_start,ithet_nucl_end
22146 if ((itype(i-1,2).eq.ntyp1_molec(2)).or.&
22147 (itype(i-2,2).eq.ntyp1_molec(2)).or. &
22148 (itype(i,2).eq.ntyp1_molec(2))) cycle
22152 theti2=0.5d0*theta(i)
22153 ityp2=ithetyp_nucl(itype(i-1,2))
22154 do k=1,nntheterm_nucl
22155 coskt(k)=dcos(k*theti2)
22156 sinkt(k)=dsin(k*theti2)
22158 if (i.gt.3 .and. itype(i-2,2).ne.ntyp1_molec(2)) then
22161 if (phii.ne.phii) phii=150.0
22165 ityp1=ithetyp_nucl(itype(i-2,2))
22166 do k=1,nsingle_nucl
22167 cosph1(k)=dcos(k*phii)
22168 sinph1(k)=dsin(k*phii)
22172 ityp1=nthetyp_nucl+1
22173 do k=1,nsingle_nucl
22179 if (i.lt.nres .and. itype(i,2).ne.ntyp1_molec(2)) then
22182 if (phii1.ne.phii1) phii1=150.0
22183 phii1=pinorm(phii1)
22187 ityp3=ithetyp_nucl(itype(i,2))
22188 do k=1,nsingle_nucl
22189 cosph2(k)=dcos(k*phii1)
22190 sinph2(k)=dsin(k*phii1)
22194 ityp3=nthetyp_nucl+1
22195 do k=1,nsingle_nucl
22200 ethetai=aa0thet_nucl(ityp1,ityp2,ityp3)
22201 do k=1,ndouble_nucl
22203 ccl=cosph1(l)*cosph2(k-l)
22204 ssl=sinph1(l)*sinph2(k-l)
22205 scl=sinph1(l)*cosph2(k-l)
22206 csl=cosph1(l)*sinph2(k-l)
22207 cosph1ph2(l,k)=ccl-ssl
22208 cosph1ph2(k,l)=ccl+ssl
22209 sinph1ph2(l,k)=scl+csl
22210 sinph1ph2(k,l)=scl-csl
22214 write (iout,*) "i",i," ityp1",ityp1," ityp2",ityp2,&
22215 " ityp3",ityp3," theti2",theti2," phii",phii," phii1",phii1
22216 write (iout,*) "coskt and sinkt",nntheterm_nucl
22217 do k=1,nntheterm_nucl
22218 write (iout,*) k,coskt(k),sinkt(k)
22221 do k=1,ntheterm_nucl
22222 ethetai=ethetai+aathet_nucl(k,ityp1,ityp2,ityp3)*sinkt(k)
22223 dethetai=dethetai+0.5d0*k*aathet_nucl(k,ityp1,ityp2,ityp3)&
22226 write (iout,*) "k",k," aathet",aathet_nucl(k,ityp1,ityp2,ityp3),&
22230 write (iout,*) "cosph and sinph"
22231 do k=1,nsingle_nucl
22232 write (iout,*) k,cosph1(k),sinph1(k),cosph2(k),sinph2(k)
22234 write (iout,*) "cosph1ph2 and sinph2ph2"
22235 do k=2,ndouble_nucl
22237 write (iout,*) l,k,cosph1ph2(l,k),cosph1ph2(k,l),&
22238 sinph1ph2(l,k),sinph1ph2(k,l)
22241 write(iout,*) "ethetai",ethetai
22243 do m=1,ntheterm2_nucl
22244 do k=1,nsingle_nucl
22245 aux=bbthet_nucl(k,m,ityp1,ityp2,ityp3)*cosph1(k)&
22246 +ccthet_nucl(k,m,ityp1,ityp2,ityp3)*sinph1(k)&
22247 +ddthet_nucl(k,m,ityp1,ityp2,ityp3)*cosph2(k)&
22248 +eethet_nucl(k,m,ityp1,ityp2,ityp3)*sinph2(k)
22249 ethetai=ethetai+sinkt(m)*aux
22250 dethetai=dethetai+0.5d0*m*aux*coskt(m)
22251 dephii=dephii+k*sinkt(m)*(&
22252 ccthet_nucl(k,m,ityp1,ityp2,ityp3)*cosph1(k)-&
22253 bbthet_nucl(k,m,ityp1,ityp2,ityp3)*sinph1(k))
22254 dephii1=dephii1+k*sinkt(m)*(&
22255 eethet_nucl(k,m,ityp1,ityp2,ityp3)*cosph2(k)-&
22256 ddthet_nucl(k,m,ityp1,ityp2,ityp3)*sinph2(k))
22258 write (iout,*) "m",m," k",k," bbthet",&
22259 bbthet_nucl(k,m,ityp1,ityp2,ityp3)," ccthet",&
22260 ccthet_nucl(k,m,ityp1,ityp2,ityp3)," ddthet",&
22261 ddthet_nucl(k,m,ityp1,ityp2,ityp3)," eethet",&
22262 eethet_nucl(k,m,ityp1,ityp2,ityp3)," ethetai",ethetai
22266 write(iout,*) "ethetai",ethetai
22267 do m=1,ntheterm3_nucl
22268 do k=2,ndouble_nucl
22270 aux=ffthet_nucl(l,k,m,ityp1,ityp2,ityp3)*cosph1ph2(l,k)+&
22271 ffthet_nucl(k,l,m,ityp1,ityp2,ityp3)*cosph1ph2(k,l)+&
22272 ggthet_nucl(l,k,m,ityp1,ityp2,ityp3)*sinph1ph2(l,k)+&
22273 ggthet_nucl(k,l,m,ityp1,ityp2,ityp3)*sinph1ph2(k,l)
22274 ethetai=ethetai+sinkt(m)*aux
22275 dethetai=dethetai+0.5d0*m*coskt(m)*aux
22276 dephii=dephii+l*sinkt(m)*(&
22277 -ffthet_nucl(l,k,m,ityp1,ityp2,ityp3)*sinph1ph2(l,k)-&
22278 ffthet_nucl(k,l,m,ityp1,ityp2,ityp3)*sinph1ph2(k,l)+&
22279 ggthet_nucl(l,k,m,ityp1,ityp2,ityp3)*cosph1ph2(l,k)+&
22280 ggthet_nucl(k,l,m,ityp1,ityp2,ityp3)*cosph1ph2(k,l))
22281 dephii1=dephii1+(k-l)*sinkt(m)*( &
22282 -ffthet_nucl(l,k,m,ityp1,ityp2,ityp3)*sinph1ph2(l,k)+&
22283 ffthet_nucl(k,l,m,ityp1,ityp2,ityp3)*sinph1ph2(k,l)+&
22284 ggthet_nucl(l,k,m,ityp1,ityp2,ityp3)*cosph1ph2(l,k)-&
22285 ggthet_nucl(k,l,m,ityp1,ityp2,ityp3)*cosph1ph2(k,l))
22287 write (iout,*) "m",m," k",k," l",l," ffthet", &
22288 ffthet_nucl(l,k,m,ityp1,ityp2,ityp3), &
22289 ffthet_nucl(k,l,m,ityp1,ityp2,ityp3)," ggthet",&
22290 ggthet_nucl(l,k,m,ityp1,ityp2,ityp3),&
22291 ggthet_nucl(k,l,m,ityp1,ityp2,ityp3)," ethetai",ethetai
22292 write (iout,*) cosph1ph2(l,k)*sinkt(m), &
22293 cosph1ph2(k,l)*sinkt(m),&
22294 sinph1ph2(l,k)*sinkt(m),sinph1ph2(k,l)*sinkt(m)
22300 if (lprn1) write (iout,'(i2,3f8.1,9h ethetai ,f10.5)') &
22301 i,theta(i)*rad2deg,phii*rad2deg, &
22302 phii1*rad2deg,ethetai
22303 etheta_nucl=etheta_nucl+ethetai
22304 ! print *,i,"partial sum",etheta_nucl
22305 if (i.gt.3) gloc(i-3,icg)=gloc(i-3,icg)+wang_nucl*dephii
22306 if (i.lt.nres) gloc(i-2,icg)=gloc(i-2,icg)+wang_nucl*dephii1
22307 gloc(nphi+i-2,icg)=wang_nucl*dethetai
22310 end subroutine ebend_nucl
22311 !----------------------------------------------------
22312 subroutine etor_nucl(etors_nucl)
22313 ! implicit real(kind=8) (a-h,o-z)
22314 ! include 'DIMENSIONS'
22315 ! include 'COMMON.VAR'
22316 ! include 'COMMON.GEO'
22317 ! include 'COMMON.LOCAL'
22318 ! include 'COMMON.TORSION'
22319 ! include 'COMMON.INTERACT'
22320 ! include 'COMMON.DERIV'
22321 ! include 'COMMON.CHAIN'
22322 ! include 'COMMON.NAMES'
22323 ! include 'COMMON.IOUNITS'
22324 ! include 'COMMON.FFIELD'
22325 ! include 'COMMON.TORCNSTR'
22326 ! include 'COMMON.CONTROL'
22327 real(kind=8) :: etors_nucl,edihcnstr
22329 !el local variables
22330 integer :: i,j,iblock,itori,itori1
22331 real(kind=8) :: phii,gloci,v1ij,v2ij,cosphi,sinphi,&
22332 vl1ij,vl2ij,vl3ij,pom1,difi,etors_ii,pom
22333 ! Set lprn=.true. for debugging
22337 ! print *,"iphi_nucl_start/end", iphi_nucl_start,iphi_nucl_end
22338 do i=iphi_nucl_start,iphi_nucl_end
22339 if (itype(i-2,2).eq.ntyp1_molec(2) .or. itype(i-1,2).eq.ntyp1_molec(2) &
22340 .or. itype(i-3,2).eq.ntyp1_molec(2) &
22341 .or. itype(i,2).eq.ntyp1_molec(2)) cycle
22343 itori=itortyp_nucl(itype(i-2,2))
22344 itori1=itortyp_nucl(itype(i-1,2))
22346 ! print *,i,itori,itori1
22348 !C Regular cosine and sine terms
22349 do j=1,nterm_nucl(itori,itori1)
22350 v1ij=v1_nucl(j,itori,itori1)
22351 v2ij=v2_nucl(j,itori,itori1)
22352 cosphi=dcos(j*phii)
22353 sinphi=dsin(j*phii)
22354 etors_nucl=etors_nucl+v1ij*cosphi+v2ij*sinphi
22355 if (energy_dec) etors_ii=etors_ii+&
22356 v1ij*cosphi+v2ij*sinphi
22357 gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
22361 !C E = SUM ----------------------------------- - v1
22362 !C [v2 cos(phi/2)+v3 sin(phi/2)]^2 + 1
22364 cosphi=dcos(0.5d0*phii)
22365 sinphi=dsin(0.5d0*phii)
22366 do j=1,nlor_nucl(itori,itori1)
22367 vl1ij=vlor1_nucl(j,itori,itori1)
22368 vl2ij=vlor2_nucl(j,itori,itori1)
22369 vl3ij=vlor3_nucl(j,itori,itori1)
22370 pom=vl2ij*cosphi+vl3ij*sinphi
22371 pom1=1.0d0/(pom*pom+1.0d0)
22372 etors_nucl=etors_nucl+vl1ij*pom1
22373 if (energy_dec) etors_ii=etors_ii+ &
22376 gloci=gloci+vl1ij*(vl3ij*cosphi-vl2ij*sinphi)*pom
22378 !C Subtract the constant term
22379 etors_nucl=etors_nucl-v0_nucl(itori,itori1)
22380 if (energy_dec) write (iout,'(a6,i5,0pf7.3)') &
22381 'etor',i,etors_ii-v0_nucl(itori,itori1)
22383 write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)') &
22384 restyp(itype(i-2,2),2),i-2,restyp(itype(i-1,2),2),i-1,itori,itori1, &
22385 (v1_nucl(j,itori,itori1),j=1,6),(v2_nucl(j,itori,itori1),j=1,6)
22386 gloc(i-3,icg)=gloc(i-3,icg)+wtor_nucl*gloci
22387 !c write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
22390 end subroutine etor_nucl
22391 !------------------------------------------------------------
22392 subroutine epp_nucl_sub(evdw1,ees)
22394 !C This subroutine calculates the average interaction energy and its gradient
22395 !C in the virtual-bond vectors between non-adjacent peptide groups, based on
22396 !C the potential described in Liwo et al., Protein Sci., 1993, 2, 1715.
22397 !C The potential depends both on the distance of peptide-group centers and on
22398 !C the orientation of the CA-CA virtual bonds.
22400 integer :: i,j,k,iteli,itelj,num_conti,isubchap,ind
22401 real(kind=8) :: dxi,dyi,dzi,dxj,dyj,dzj,aaa,bbbi,sslipi,ssgradlipi, &
22402 sslipj,ssgradlipj,faclipij2
22403 real(kind=8) :: xj,yj,zj,rij,rrmij,sss,r3ij,r6ij,evdw1,&
22404 dx_normi,dy_normi,dz_normi,xmedi,ymedi,zmedi,&
22405 dx_normj,dy_normj,dz_normj,rmij,ev1,ev2,evdwij,facvdw
22406 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
22407 dist_temp, dist_init,sss_grad,fac,evdw1ij
22408 integer xshift,yshift,zshift
22409 real(kind=8),dimension(3):: ggg,gggp,gggm,erij
22410 real(kind=8) :: ees,eesij
22411 !c 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
22412 real(kind=8) scal_el /0.5d0/
22418 !c Loop over all pairs of interacting peptide groups except i,i+2 and i,i+3
22420 ! print *,"iatel_s_nucl,iatel_e_nucl",iatel_s_nucl,iatel_e_nucl
22421 do i=iatel_s_nucl,iatel_e_nucl
22422 if (itype(i,2).eq.ntyp1_molec(2) .or. itype(i+1,2).eq.ntyp1_molec(2)) cycle
22426 dx_normi=dc_norm(1,i)
22427 dy_normi=dc_norm(2,i)
22428 dz_normi=dc_norm(3,i)
22429 xmedi=c(1,i)+0.5d0*dxi
22430 ymedi=c(2,i)+0.5d0*dyi
22431 zmedi=c(3,i)+0.5d0*dzi
22432 call to_box(xmedi,ymedi,zmedi)
22433 call lipid_layer(xmedi,ymedi,zmedi,sslipi,ssgradlipi)
22435 do j=ielstart_nucl(i),ielend_nucl(i)
22436 if (itype(j,2).eq.ntyp1_molec(2) .or. itype(j+1,2).eq.ntyp1_molec(2)) cycle
22441 ! xj=c(1,j)+0.5D0*dxj-xmedi
22442 ! yj=c(2,j)+0.5D0*dyj-ymedi
22443 ! zj=c(3,j)+0.5D0*dzj-zmedi
22444 xj=c(1,j)+0.5D0*dxj
22445 yj=c(2,j)+0.5D0*dyj
22446 zj=c(3,j)+0.5D0*dzj
22447 call to_box(xj,yj,zj)
22448 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
22449 faclipij2=(sslipi+sslipj)/2.0d0*lipscale**2+1.0d0
22450 xj=boxshift(xj-xmedi,boxxsize)
22451 yj=boxshift(yj-ymedi,boxysize)
22452 zj=boxshift(zj-zmedi,boxzsize)
22453 rij=xj*xj+yj*yj+zj*zj
22454 !c write (2,*)"ij",i,j," r0pp",r0pp," rij",rij," epspp",epspp
22455 fac=(r0pp**2/rij)**3
22459 fac=(-ev1-evdw1ij)/rij
22460 ! write (2,*)"fac",fac," ev1",ev1," ev2",ev2," evdw1ij",evdw1ij
22461 if (energy_dec) write(iout,'(2i5,a9,f10.4)') i,j,"evdw1ij",evdw1ij
22462 evdw1=evdw1+evdw1ij
22464 !C Calculate contributions to the Cartesian gradient.
22470 gvdwpp_nucl(k,i)=gvdwpp_nucl(k,i)-ggg(k)
22471 gvdwpp_nucl(k,j)=gvdwpp_nucl(k,j)+ggg(k)
22473 !c phoshate-phosphate electrostatic interactions
22476 eesij=dexp(-BEES*rij)*fac
22477 ! write (2,*)"fac",fac," eesijpp",eesij
22478 if (energy_dec) write(iout,'(2i5,a9,f10.4)') i,j,"eesijpp",eesij
22481 fac=-(fac+BEES)*eesij*fac
22485 !c write(2,*) "ggg",i,j,ggg(1),ggg(2),ggg(3)
22486 !c write(2,*) "gelpp",i,(gelpp(k,i),k=1,3)
22487 !c write(2,*) "gelpp",j,(gelpp(k,j),k=1,3)
22489 gelpp(k,i)=gelpp(k,i)-ggg(k)
22490 gelpp(k,j)=gelpp(k,j)+ggg(k)
22497 !c write (2,*) "i",i," gelpp",(gelpp(k,i),k=1,3)
22499 gvdwpp_nucl(k,i)=6*gvdwpp_nucl(k,i)
22500 !c gelpp(k,i)=332.0d0*gelpp(k,i)
22501 gelpp(k,i)=AEES*gelpp(k,i)
22503 !c write (2,*) "i",i," gelpp",(gelpp(k,i),k=1,3)
22505 !c write (2,*) "total EES",ees
22507 end subroutine epp_nucl_sub
22508 !---------------------------------------------------------------------
22509 subroutine epsb(evdwpsb,eelpsb)
22512 !C This subroutine calculates the excluded-volume interaction energy between
22513 !C peptide-group centers and side chains and its gradient in virtual-bond and
22514 !C side-chain vectors.
22516 real(kind=8),dimension(3):: ggg
22517 integer :: i,iint,j,k,iteli,itypj,subchap
22518 real(kind=8) :: evdw2,evdw2_14,xi,yi,zi,xj,yj,zj,rrij,fac,&
22519 e1,e2,evdwij,rij,evdwpsb,eelpsb
22520 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
22521 dist_temp, dist_init
22522 integer xshift,yshift,zshift
22524 !cd print '(a)','Enter ESCP'
22525 !cd write (iout,*) 'iatscp_s=',iatscp_s,' iatscp_e=',iatscp_e
22528 ! print *,"iatscp_s_nucl,iatscp_e_nucl",iatscp_s_nucl,iatscp_e_nucl
22529 do i=iatscp_s_nucl,iatscp_e_nucl
22530 if (itype(i,2).eq.ntyp1_molec(2) &
22531 .or. itype(i+1,2).eq.ntyp1_molec(2)) cycle
22532 xi=0.5D0*(c(1,i)+c(1,i+1))
22533 yi=0.5D0*(c(2,i)+c(2,i+1))
22534 zi=0.5D0*(c(3,i)+c(3,i+1))
22535 call to_box(xi,yi,zi)
22537 do iint=1,nscp_gr_nucl(i)
22539 do j=iscpstart_nucl(i,iint),iscpend_nucl(i,iint)
22541 if (itypj.eq.ntyp1_molec(2)) cycle
22542 !C Uncomment following three lines for SC-p interactions
22543 !c xj=c(1,nres+j)-xi
22544 !c yj=c(2,nres+j)-yi
22545 !c zj=c(3,nres+j)-zi
22546 !C Uncomment following three lines for Ca-p interactions
22553 call to_box(xj,yj,zj)
22554 xj=boxshift(xj-xi,boxxsize)
22555 yj=boxshift(yj-yi,boxysize)
22556 zj=boxshift(zj-zi,boxzsize)
22558 dist_init=xj**2+yj**2+zj**2
22560 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
22562 e1=fac*fac*aad_nucl(itypj)
22563 e2=fac*bad_nucl(itypj)
22564 if (iabs(j-i) .le. 2) then
22569 evdwpsb=evdwpsb+evdwij
22570 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a4)') &
22571 'evdw2',i,j,evdwij,"tu4"
22573 !C Calculate contributions to the gradient in the virtual-bond and SC vectors.
22575 fac=-(evdwij+e1)*rrij
22580 gvdwpsb1(k,i)=gvdwpsb1(k,i)-ggg(k)
22581 gvdwpsb(k,j)=gvdwpsb(k,j)+ggg(k)
22589 gvdwpsb(j,i)=expon*gvdwpsb(j,i)
22590 gvdwpsb1(j,i)=expon*gvdwpsb1(j,i)
22594 end subroutine epsb
22596 !------------------------------------------------------
22597 subroutine esb_gb(evdwsb,eelsb)
22600 integer :: iint,itypi,itypi1,itypj,subchap,num_conti2
22601 real(kind=8) :: xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
22602 real(kind=8) :: evdw,sig0iji,evdwsb,eelsb,ecorr,eelij
22603 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
22604 dist_temp, dist_init,aa,bb,faclip,sig0ij
22613 ! print *,"iastsc_nucl",iatsc_s_nucl,iatsc_e_nucl
22614 do i=iatsc_s_nucl,iatsc_e_nucl
22618 ! PRINT *,"I=",i,itypi
22619 if (itypi.eq.ntyp1_molec(2)) cycle
22620 itypi1=itype(i+1,2)
22624 call to_box(xi,yi,zi)
22625 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
22626 dxi=dc_norm(1,nres+i)
22627 dyi=dc_norm(2,nres+i)
22628 dzi=dc_norm(3,nres+i)
22629 dsci_inv=vbld_inv(i+nres)
22631 !C Calculate SC interaction energy.
22633 do iint=1,nint_gr_nucl(i)
22634 ! print *,"tu?",i,istart_nucl(i,iint),iend_nucl(i,iint)
22635 do j=istart_nucl(i,iint),iend_nucl(i,iint)
22639 if (itypj.eq.ntyp1_molec(2)) cycle
22640 dscj_inv=vbld_inv(j+nres)
22641 sig0ij=sigma_nucl(itypi,itypj)
22642 chi1=chi_nucl(itypi,itypj)
22643 chi2=chi_nucl(itypj,itypi)
22645 chip1=chip_nucl(itypi,itypj)
22646 chip2=chip_nucl(itypj,itypi)
22648 ! xj=c(1,nres+j)-xi
22649 ! yj=c(2,nres+j)-yi
22650 ! zj=c(3,nres+j)-zi
22654 call to_box(xj,yj,zj)
22655 ! call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
22656 ! aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
22657 ! +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
22658 ! bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
22659 ! +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
22660 xj=boxshift(xj-xi,boxxsize)
22661 yj=boxshift(yj-yi,boxysize)
22662 zj=boxshift(zj-zi,boxzsize)
22664 dxj=dc_norm(1,nres+j)
22665 dyj=dc_norm(2,nres+j)
22666 dzj=dc_norm(3,nres+j)
22667 rrij=1.0D0/(xj*xj+yj*yj+zj*zj)
22669 !C Calculate angle-dependent terms of energy and contributions to their
22674 om1=dxi*erij(1)+dyi*erij(2)+dzi*erij(3)
22675 om2=dxj*erij(1)+dyj*erij(2)+dzj*erij(3)
22676 om12=dxi*dxj+dyi*dyj+dzi*dzj
22677 call sc_angular_nucl
22679 sig=sig0ij*dsqrt(sigsq)
22680 rij_shift=1.0D0/rij-sig+sig0ij
22681 ! print *,rij_shift,"rij_shift"
22682 !c write (2,*) " rij",1.0D0/rij," sig",sig," sig0ij",sig0ij,
22683 !c & " rij_shift",rij_shift
22684 if (rij_shift.le.0.0D0) then
22689 !c---------------------------------------------------------------
22690 rij_shift=1.0D0/rij_shift
22691 fac=rij_shift**expon
22692 e1=fac*fac*aa_nucl(itypi,itypj)
22693 e2=fac*bb_nucl(itypi,itypj)
22694 evdwij=eps1*eps2rt*(e1+e2)
22695 !c write (2,*) "eps1",eps1," eps2rt",eps2rt,
22696 !c & " e1",e1," e2",e2," evdwij",evdwij
22698 evdwij=evdwij*eps2rt
22699 evdwsb=evdwsb+evdwij
22701 sigm=dabs(aa_nucl(itypi,itypj)/bb_nucl(itypi,itypj))**(1.0D0/6.0D0)
22702 epsi=bb_nucl(itypi,itypj)**2/aa_nucl(itypi,itypj)
22703 write (iout,'(2(a3,i3,2x),17(0pf7.3))') &
22704 restyp(itypi,2),i,restyp(itypj,2),j, &
22705 epsi,sigm,chi1,chi2,chip1,chip2, &
22706 eps1,eps2rt**2,sig,sig0ij, &
22707 om1,om2,om12,1.0D0/rij,1.0D0/rij_shift,&
22709 write (iout,*) "aa",aa_nucl(itypi,itypj)," bb",bb_nucl(itypi,itypj)
22712 if (energy_dec) write (iout,'(a6,2i5,e15.3,a4)') &
22713 'evdw',i,j,evdwij,"tu3"
22716 !C Calculate gradient components.
22717 e1=e1*eps1*eps2rt**2
22718 fac=-expon*(e1+evdwij)*rij_shift
22722 !C Calculate the radial part of the gradient
22726 !C Calculate angular part of the gradient.
22728 call eelsbij(eelij,num_conti2)
22729 if (energy_dec .and. &
22730 (j.eq.i+1.or.j.eq.nres-i+1.or.j.eq.nres-i.or.j.eq.nres-i+2)) &
22731 write (istat,'(e14.5)') evdwij
22735 num_cont_hb(i)=num_conti2
22737 !c write (iout,*) "Number of loop steps in EGB:",ind
22738 !cccc energy_dec=.false.
22740 end subroutine esb_gb
22741 !-------------------------------------------------------------------------------
22742 subroutine eelsbij(eesij,num_conti2)
22745 real(kind=8),dimension(3) :: ggg,gggp,gggm,dcosb,dcosg
22746 real(kind=8),dimension(3,3) :: erder,uryg,urzg,vryg,vrzg
22747 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
22748 dist_temp, dist_init,rlocshield,fracinbuf
22749 integer xshift,yshift,zshift,ilist,iresshield,num_conti2
22751 !c 4/26/02 - AL scaling factor for 1,4 repulsive VDW interactions
22752 real(kind=8) scal_el /0.5d0/
22753 integer :: iteli,itelj,kkk,kkll,m,isubchap
22754 real(kind=8) :: ael6i,rrmij,rmij,r0ij,fcont,fprimcont,ees0tmp,facfac
22755 real(kind=8) :: ees,evdw1,eel_loc,aaa,bbb,ael3i,ael63i,ael32i
22756 real(kind=8) :: dx_normj,dy_normj,dz_normj,&
22757 r3ij,r6ij,cosa,cosb,cosg,fac,ev1,ev2,fac3,fac4,fac5,fac6,&
22758 el1,el2,el3,el4,eesij,ees0ij,facvdw,facel,fac1,ecosa,&
22759 ecosb,ecosg,ury,urz,vry,vrz,facr,a22der,a23der,a32der,&
22760 a33der,eel_loc_ij,cosa4,wij,cosbg1,cosbg2,ees0pij,&
22761 ees0pij1,ees0mij,ees0mij1,fac3p,ees0mijp,ees0pijp,&
22762 ecosa1,ecosb1,ecosg1,ecosa2,ecosb2,ecosg2,ecosap,ecosbp,&
22763 ecosgp,ecosam,ecosbm,ecosgm,ghalf,itypi,itypj
22767 ! print *,i,j,itypi,itypj,istype(i),istype(j),"????"
22768 ael6i=ael6_nucl(itypi,itypj)
22769 ael3i=ael3_nucl(itypi,itypj)
22770 ael63i=ael63_nucl(itypi,itypj)
22771 ael32i=ael32_nucl(itypi,itypj)
22772 !c write (iout,*) "eelecij",i,j,itype(i),itype(j),
22773 !c & ael6i,ael3i,ael63i,al32i,rij,rrij
22777 dx_normi=dc_norm(1,i+nres)
22778 dy_normi=dc_norm(2,i+nres)
22779 dz_normi=dc_norm(3,i+nres)
22780 dx_normj=dc_norm(1,j+nres)
22781 dy_normj=dc_norm(2,j+nres)
22782 dz_normj=dc_norm(3,j+nres)
22783 !c xj=c(1,j)+0.5D0*dxj-xmedi
22784 !c yj=c(2,j)+0.5D0*dyj-ymedi
22785 !c zj=c(3,j)+0.5D0*dzj-zmedi
22786 if (ipot_nucl.ne.2) then
22787 cosa=dx_normi*dx_normj+dy_normi*dy_normj+dz_normi*dz_normj
22788 cosb=(xj*dx_normi+yj*dy_normi+zj*dz_normi)*rmij
22789 cosg=(xj*dx_normj+yj*dy_normj+zj*dz_normj)*rmij
22797 fac=cosa-3.0D0*cosb*cosg
22799 fac1=3.0d0*(cosb*cosb+cosg*cosg)
22804 !c write (iout,*) "r3ij",r3ij," r6ij",r6ij," fac",fac," fac1",fac1,
22805 !c & " fac2",fac2," fac3",fac3," fac4",fac4," fac5",fac5," fac6",fac6
22806 el1=fac3*(4.0D0+facfac-fac1)
22808 el3=fac5*(2.0d0-2.0d0*facfac+fac1)
22810 eesij=el1+el2+el3+el4
22811 !C 12/26/95 - for the evaluation of multi-body H-bonding interactions
22812 ees0ij=4.0D0+facfac-fac1
22814 if (energy_dec) then
22815 if(j.eq.i+1.or.j.eq.nres-i+1.or.j.eq.nres-i.or.j.eq.nres-i+2) &
22816 write (istat,'(2a1,i4,1x,2a1,i4,4f10.5,3e12.5,$)') &
22817 sugartyp(istype(i)),restyp(itypi,2),i,sugartyp(istype(j)),&
22818 restyp(itypj,2),j,1.0d0/rij,cosa,cosb,cosg,fac*r3ij, &
22819 (4.0D0+facfac-fac1)*r6ij,(2.0d0-2.0d0*facfac+fac1)*r6ij
22820 write (iout,'(a6,2i5,e15.3)') 'ees',i,j,eesij
22824 !C Calculate contributions to the Cartesian gradient.
22826 facel=-3.0d0*rrij*(eesij+el1+el3+el4)
22832 !* Radial derivatives. First process both termini of the fragment (i,j)
22838 gelsbc(k,j)=gelsbc(k,j)+ggg(k)
22839 gelsbc(k,i)=gelsbc(k,i)-ggg(k)
22840 gelsbx(k,j)=gelsbx(k,j)+ggg(k)
22841 gelsbx(k,i)=gelsbx(k,i)-ggg(k)
22846 ecosa=2.0D0*fac3*fac1+fac4+(-4.0d0*fac5+2.0d0*fac6)*fac1
22851 ecosb=fac3*(fac1*cosg+cosb)+cosg*fac4+(cosb+2*fac1*cosg)*fac5+&
22853 ecosg=fac3*(fac1*cosb+cosg)+cosb*fac4+(cosg+2*fac1*cosb)*fac5+&
22856 dcosb(k)=rij*(dc_norm(k,i+nres)-erij(k)*cosb)
22857 dcosg(k)=rij*(dc_norm(k,j+nres)-erij(k)*cosg)
22860 ggg(k)=ecosb*dcosb(k)+ecosg*dcosg(k)
22863 gelsbx(k,i)=gelsbx(k,i)-ggg(k) &
22864 +(ecosa*(dc_norm(k,j+nres)-cosa*dc_norm(k,i+nres))&
22865 + ecosb*(erij(k)-cosb*dc_norm(k,i+nres)))*vbld_inv(i+nres)
22866 gelsbx(k,j)=gelsbx(k,j)+ggg(k) &
22867 +(ecosa*(dc_norm(k,i+nres)-cosa*dc_norm(k,j+nres))&
22868 + ecosg*(erij(k)-cosg*dc_norm(k,j+nres)))*vbld_inv(j+nres)
22869 gelsbc(k,j)=gelsbc(k,j)+ggg(k)
22870 gelsbc(k,i)=gelsbc(k,i)-ggg(k)
22872 ! IF ( (wcorr_nucl.gt.0.0d0.or.wcorr3_nucl.gt.0.0d0) .and.
22873 IF ( j.gt.i+1 .and.&
22874 num_conti.le.maxcont) THEN
22876 !C Calculate the contact function. The ith column of the array JCONT will
22877 !C contain the numbers of atoms that make contacts with the atom I (of numbers
22878 !C greater than I). The arrays FACONT and GACONT will contain the values of
22879 !C the contact function and its derivative.
22880 r0ij=2.20D0*sigma_nucl(itypi,itypj)
22881 !c write (2,*) "ij",i,j," rij",1.0d0/rij," r0ij",r0ij
22882 call gcont(rij,r0ij,1.0D0,0.2d0/r0ij,fcont,fprimcont)
22883 !c write (2,*) "fcont",fcont
22884 if (fcont.gt.0.0D0) then
22885 num_conti=num_conti+1
22886 num_conti2=num_conti2+1
22888 if (num_conti.gt.maxconts) then
22889 write (iout,*) 'WARNING - max. # of contacts exceeded;',&
22890 ' will skip next contacts for this conf.',maxconts
22892 jcont_hb(num_conti,i)=j
22893 !c write (iout,*) "num_conti",num_conti,
22894 !c & " jcont_hb",jcont_hb(num_conti,i)
22895 !C Calculate contact energies
22897 wij=cosa-3.0D0*cosb*cosg
22900 fac3=dsqrt(-ael6i)*r3ij
22901 !c write (2,*) "ael6i",ael6i," r3ij",r3ij," fac3",fac3
22902 ees0tmp=4.0D0+cosa4+wij*wij-3.0D0*cosbg1*cosbg1
22903 if (ees0tmp.gt.0) then
22904 ees0pij=dsqrt(ees0tmp)
22908 ees0tmp=4.0D0-cosa4+wij*wij-3.0D0*cosbg2*cosbg2
22909 if (ees0tmp.gt.0) then
22910 ees0mij=dsqrt(ees0tmp)
22914 ees0p(num_conti,i)=0.5D0*fac3*(ees0pij+ees0mij)
22915 ees0m(num_conti,i)=0.5D0*fac3*(ees0pij-ees0mij)
22916 !c write (iout,*) "i",i," j",j,
22917 !c & " ees0m",ees0m(num_conti,i)," ees0p",ees0p(num_conti,i)
22918 ees0pij1=fac3/ees0pij
22919 ees0mij1=fac3/ees0mij
22920 fac3p=-3.0D0*fac3*rrij
22921 ees0pijp=0.5D0*fac3p*(ees0pij+ees0mij)
22922 ees0mijp=0.5D0*fac3p*(ees0pij-ees0mij)
22923 ecosa1= ees0pij1*( 1.0D0+0.5D0*wij)
22924 ecosb1=-1.5D0*ees0pij1*(wij*cosg+cosbg1)
22925 ecosg1=-1.5D0*ees0pij1*(wij*cosb+cosbg1)
22926 ecosa2= ees0mij1*(-1.0D0+0.5D0*wij)
22927 ecosb2=-1.5D0*ees0mij1*(wij*cosg+cosbg2)
22928 ecosg2=-1.5D0*ees0mij1*(wij*cosb-cosbg2)
22929 ecosap=ecosa1+ecosa2
22930 ecosbp=ecosb1+ecosb2
22931 ecosgp=ecosg1+ecosg2
22932 ecosam=ecosa1-ecosa2
22933 ecosbm=ecosb1-ecosb2
22934 ecosgm=ecosg1-ecosg2
22936 facont_hb(num_conti,i)=fcont
22937 fprimcont=fprimcont/rij
22939 gggp(k)=ecosbp*dcosb(k)+ecosgp*dcosg(k)
22940 gggm(k)=ecosbm*dcosb(k)+ecosgm*dcosg(k)
22942 gggp(1)=gggp(1)+ees0pijp*xj
22943 gggp(2)=gggp(2)+ees0pijp*yj
22944 gggp(3)=gggp(3)+ees0pijp*zj
22945 gggm(1)=gggm(1)+ees0mijp*xj
22946 gggm(2)=gggm(2)+ees0mijp*yj
22947 gggm(3)=gggm(3)+ees0mijp*zj
22948 !C Derivatives due to the contact function
22949 gacont_hbr(1,num_conti,i)=fprimcont*xj
22950 gacont_hbr(2,num_conti,i)=fprimcont*yj
22951 gacont_hbr(3,num_conti,i)=fprimcont*zj
22954 !c Gradient of the correlation terms
22956 gacontp_hb1(k,num_conti,i)= &
22957 (ecosap*(dc_norm(k,j+nres)-cosa*dc_norm(k,i+nres)) &
22958 + ecosbp*(erij(k)-cosb*dc_norm(k,i+nres)))*vbld_inv(i+nres)
22959 gacontp_hb2(k,num_conti,i)= &
22960 (ecosap*(dc_norm(k,i+nres)-cosa*dc_norm(k,j+nres)) &
22961 + ecosgp*(erij(k)-cosg*dc_norm(k,j+nres)))*vbld_inv(j+nres)
22962 gacontp_hb3(k,num_conti,i)=gggp(k)
22963 gacontm_hb1(k,num_conti,i)= &
22964 (ecosam*(dc_norm(k,j+nres)-cosa*dc_norm(k,i+nres)) &
22965 + ecosbm*(erij(k)-cosb*dc_norm(k,i+nres)))*vbld_inv(i+nres)
22966 gacontm_hb2(k,num_conti,i)= &
22967 (ecosam*(dc_norm(k,i+nres)-cosa*dc_norm(k,j+nres))&
22968 + ecosgm*(erij(k)-cosg*dc_norm(k,j+nres)))*vbld_inv(j+nres)
22969 gacontm_hb3(k,num_conti,i)=gggm(k)
22975 end subroutine eelsbij
22976 !------------------------------------------------------------------
22977 subroutine sc_grad_nucl
22980 real(kind=8),dimension(3) :: dcosom1,dcosom2
22981 eom1=eps2der*eps2rt_om1+sigder*sigsq_om1
22982 eom2=eps2der*eps2rt_om2+sigder*sigsq_om2
22983 eom12=evdwij*eps1_om12+eps2der*eps2rt_om12+sigder*sigsq_om12
22985 dcosom1(k)=rij*(dc_norm(k,nres+i)-om1*erij(k))
22986 dcosom2(k)=rij*(dc_norm(k,nres+j)-om2*erij(k))
22989 gg(k)=gg(k)+eom1*dcosom1(k)+eom2*dcosom2(k)
22992 gvdwsbx(k,i)=gvdwsbx(k,i)-gg(k) &
22993 +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))&
22994 +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
22995 gvdwsbx(k,j)=gvdwsbx(k,j)+gg(k) &
22996 +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
22997 +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
23000 !C Calculate the components of the gradient in DC and X
23003 gvdwsbc(l,i)=gvdwsbc(l,i)-gg(l)
23004 gvdwsbc(l,j)=gvdwsbc(l,j)+gg(l)
23007 end subroutine sc_grad_nucl
23008 !-----------------------------------------------------------------------
23009 subroutine esb(esbloc)
23010 !C Calculate the local energy of a side chain and its derivatives in the
23011 !C corresponding virtual-bond valence angles THETA and the spherical angles
23012 !C ALPHA and OMEGA derived from AM1 all-atom calculations.
23013 !C added by Urszula Kozlowska. 07/11/2007
23015 real(kind=8),dimension(3):: x_prime,y_prime,z_prime
23016 real(kind=8),dimension(9):: x
23017 real(kind=8) :: sumene,dsc_i,dp2_i,xx,yy,zz,sumene1, &
23018 sumene2,sumene3,sumene4,s1,s1_6,s2,s2_6,&
23019 de_dxx,de_dyy,de_dzz,de_dt,s1_t,s1_6_t,s2_t,s2_6_t
23020 real(kind=8),dimension(3):: dXX_Ci1,dYY_Ci1,dZZ_Ci1,dXX_Ci,&
23021 dYY_Ci,dZZ_Ci,dXX_XYZ,dYY_XYZ,dZZ_XYZ,dt_dCi,dt_dCi1
23022 real(kind=8) :: esbloc,delta,cosfac2,cosfac,sinfac2,sinfac,de_dtt,&
23023 cossc,cossc1,cosfac2xx,sinfac2yy,pom1,pom
23024 integer::it,nlobit,i,j,k
23025 ! common /sccalc/ time11,time12,time112,theti,it,nlobit
23028 do i=loc_start_nucl,loc_end_nucl
23029 if (itype(i,2).eq.ntyp1_molec(2)) cycle
23030 costtab(i+1) =dcos(theta(i+1))
23031 sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
23032 cost2tab(i+1)=dsqrt(0.5d0*(1.0d0+costtab(i+1)))
23033 sint2tab(i+1)=dsqrt(0.5d0*(1.0d0-costtab(i+1)))
23034 cosfac2=0.5d0/(1.0d0+costtab(i+1))
23035 cosfac=dsqrt(cosfac2)
23036 sinfac2=0.5d0/(1.0d0-costtab(i+1))
23037 sinfac=dsqrt(sinfac2)
23039 if (it.eq.10) goto 1
23042 !C Compute the axes of tghe local cartesian coordinates system; store in
23043 !c x_prime, y_prime and z_prime
23050 !C write(2,*) "dc_norm", dc_norm(1,i+nres),dc_norm(2,i+nres),
23051 !C & dc_norm(3,i+nres)
23053 x_prime(j) = (dc_norm(j,i) - dc_norm(j,i-1))*cosfac
23054 y_prime(j) = (dc_norm(j,i) + dc_norm(j,i-1))*sinfac
23057 z_prime(j) = -uz(j,i-1)
23065 xx = xx + x_prime(j)*dc_norm(j,i+nres)
23066 yy = yy + y_prime(j)*dc_norm(j,i+nres)
23067 zz = zz + z_prime(j)*dc_norm(j,i+nres)
23075 x(j) = sc_parmin_nucl(j,it)
23078 !Cc diagnostics - remove later
23079 xx1 = dcos(alph(2))
23080 yy1 = dsin(alph(2))*dcos(omeg(2))
23081 zz1 = -dsin(alph(2))*dsin(omeg(2))
23082 write(2,'(3f8.1,3f9.3,1x,3f9.3)') &
23083 alph(2)*rad2deg,omeg(2)*rad2deg,theta(3)*rad2deg,xx,yy,zz,&
23085 !C," --- ", xx_w,yy_w,zz_w
23088 sumene = enesc_nucl(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
23089 esbloc = esbloc + sumene
23090 sumene2= enesc_nucl(x,xx,yy,0.0d0,cost2tab(i+1),sint2tab(i+1))
23091 ! print *,"enecomp",sumene,sumene2
23092 if (energy_dec) write(iout,*) "i",i," esbloc",sumene,esbloc,xx,yy,zz
23093 ! if (energy_dec) write(iout,*) "x",(x(k),k=1,9)
23095 write (2,*) "x",(x(k),k=1,9)
23097 !C This section to check the numerical derivatives of the energy of ith side
23098 !C chain in xx, yy, zz, and theta. Use the -DDEBUG compiler option or insert
23099 !C #define DEBUG in the code to turn it on.
23101 write (2,*) "sumene =",sumene
23105 write (2,*) xx,yy,zz
23106 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
23107 de_dxx_num=(sumenep-sumene)/aincr
23109 write (2,*) "xx+ sumene from enesc=",sumenep,sumene
23112 write (2,*) xx,yy,zz
23113 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
23114 de_dyy_num=(sumenep-sumene)/aincr
23116 write (2,*) "yy+ sumene from enesc=",sumenep,sumene
23119 write (2,*) xx,yy,zz
23120 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
23121 de_dzz_num=(sumenep-sumene)/aincr
23123 write (2,*) "zz+ sumene from enesc=",sumenep,sumene
23124 costsave=cost2tab(i+1)
23125 sintsave=sint2tab(i+1)
23126 cost2tab(i+1)=dcos(0.5d0*(theta(i+1)+aincr))
23127 sint2tab(i+1)=dsin(0.5d0*(theta(i+1)+aincr))
23128 sumenep = enesc(x,xx,yy,zz,cost2tab(i+1),sint2tab(i+1))
23129 de_dt_num=(sumenep-sumene)/aincr
23130 write (2,*) " t+ sumene from enesc=",sumenep,sumene
23131 cost2tab(i+1)=costsave
23132 sint2tab(i+1)=sintsave
23133 !C End of diagnostics section.
23136 !C Compute the gradient of esc
23138 de_dxx=x(1)+2*x(4)*xx+x(7)*zz+x(8)*yy
23139 de_dyy=x(2)+2*x(5)*yy+x(8)*xx+x(9)*zz
23140 de_dzz=x(3)+2*x(6)*zz+x(7)*xx+x(9)*yy
23143 write (2,*) "x",(x(k),k=1,9)
23144 write (2,*) "xx",xx," yy",yy," zz",zz
23145 write (2,*) "de_xx ",de_xx," de_yy ",de_yy,&
23146 " de_zz ",de_zz," de_tt ",de_tt
23147 write (2,*) "de_xx_num",de_dxx_num," de_yy_num",de_dyy_num,&
23148 " de_zz_num",de_dzz_num," de_dt_num",de_dt_num
23151 cossc=scalar(dc_norm(1,i),dc_norm(1,i+nres))
23152 cossc1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
23153 cosfac2xx=cosfac2*xx
23154 sinfac2yy=sinfac2*yy
23156 dt_dCi(k) = -(dc_norm(k,i-1)+costtab(i+1)*dc_norm(k,i))*&
23158 dt_dCi1(k)= -(dc_norm(k,i)+costtab(i+1)*dc_norm(k,i-1))*&
23160 pom=(dC_norm(k,i+nres)-cossc*dC_norm(k,i))*vbld_inv(i+1)
23161 pom1=(dC_norm(k,i+nres)-cossc1*dC_norm(k,i-1))*vbld_inv(i)
23162 !c write (iout,*) "i",i," k",k," pom",pom," pom1",pom1,
23163 !c & " dt_dCi",dt_dCi(k)," dt_dCi1",dt_dCi1(k)
23164 !c write (iout,*) "dC_norm",(dC_norm(j,i),j=1,3),
23165 !c & (dC_norm(j,i-1),j=1,3)," vbld_inv",vbld_inv(i+1),vbld_inv(i)
23166 dXX_Ci(k)=pom*cosfac-dt_dCi(k)*cosfac2xx
23167 dXX_Ci1(k)=-pom1*cosfac-dt_dCi1(k)*cosfac2xx
23168 dYY_Ci(k)=pom*sinfac+dt_dCi(k)*sinfac2yy
23169 dYY_Ci1(k)=pom1*sinfac+dt_dCi1(k)*sinfac2yy
23173 dZZ_Ci(k)=dZZ_Ci(k)-uzgrad(j,k,2,i-1)*dC_norm(j,i+nres)
23174 dZZ_Ci1(k)=dZZ_Ci1(k)-uzgrad(j,k,1,i-1)*dC_norm(j,i+nres)
23177 dXX_XYZ(k)=vbld_inv(i+nres)*(x_prime(k)-xx*dC_norm(k,i+nres))
23178 dYY_XYZ(k)=vbld_inv(i+nres)*(y_prime(k)-yy*dC_norm(k,i+nres))
23179 dZZ_XYZ(k)=vbld_inv(i+nres)*(z_prime(k)-zz*dC_norm(k,i+nres))
23181 dt_dCi(k) = -dt_dCi(k)/sinttab(i+1)
23182 dt_dCi1(k)= -dt_dCi1(k)/sinttab(i+1)
23186 dXX_Ctab(k,i)=dXX_Ci(k)
23187 dXX_C1tab(k,i)=dXX_Ci1(k)
23188 dYY_Ctab(k,i)=dYY_Ci(k)
23189 dYY_C1tab(k,i)=dYY_Ci1(k)
23190 dZZ_Ctab(k,i)=dZZ_Ci(k)
23191 dZZ_C1tab(k,i)=dZZ_Ci1(k)
23192 dXX_XYZtab(k,i)=dXX_XYZ(k)
23193 dYY_XYZtab(k,i)=dYY_XYZ(k)
23194 dZZ_XYZtab(k,i)=dZZ_XYZ(k)
23197 !c write (iout,*) "k",k," dxx_ci1",dxx_ci1(k)," dyy_ci1",
23198 !c & dyy_ci1(k)," dzz_ci1",dzz_ci1(k)
23199 !c write (iout,*) "k",k," dxx_ci",dxx_ci(k)," dyy_ci",
23200 !c & dyy_ci(k)," dzz_ci",dzz_ci(k)
23201 !c write (iout,*) "k",k," dt_dci",dt_dci(k)," dt_dci",
23203 !c write (iout,*) "k",k," dxx_XYZ",dxx_XYZ(k)," dyy_XYZ",
23204 !c & dyy_XYZ(k)," dzz_XYZ",dzz_XYZ(k)
23205 gsbloc(k,i-1)=gsbloc(k,i-1)+(de_dxx*dxx_ci1(k) &
23206 +de_dyy*dyy_ci1(k)+de_dzz*dzz_ci1(k)+de_dt*dt_dCi1(k))
23207 gsbloc(k,i)=gsbloc(k,i)+(de_dxx*dxx_Ci(k) &
23208 +de_dyy*dyy_Ci(k)+de_dzz*dzz_Ci(k)+de_dt*dt_dCi(k))
23209 gsblocx(k,i)= de_dxx*dxx_XYZ(k)&
23210 +de_dyy*dyy_XYZ(k)+de_dzz*dzz_XYZ(k)
23211 ! print *,i,de_dxx*dxx_ci1(k)+de_dyy*dyy_ci1(k),de_dzz*dzz_ci1(k)*2
23213 !c write(iout,*) "ENERGY GRAD = ", (gsbloc(k,i-1),k=1,3),
23214 !c & (gsbloc(k,i),k=1,3),(gsblocx(k,i),k=1,3)
23216 !C to check gradient call subroutine check_grad
23222 !=-------------------------------------------------------
23223 real(kind=8) function enesc_nucl(x,xx,yy,zz,cost2,sint2)
23225 real(kind=8),dimension(9):: x(9)
23226 real(kind=8) :: xx,yy,zz,cost2,sint2,sumene1,sumene2, &
23227 sumene3,sumene4,sumene,dsc_i,dp2_i,dscp1,dscp2,s1,s1_6,s2,s2_6
23229 !c write (2,*) "enesc"
23230 !c write (2,*) "x",(x(i),i=1,9)
23231 !c write(2,*)"xx",xx," yy",yy," zz",zz," cost2",cost2," sint2",sint2
23232 sumene=x(1)*xx+x(2)*yy+x(3)*zz+x(4)*xx**2 &
23233 + x(5)*yy**2+x(6)*zz**2+x(7)*xx*zz+x(8)*xx*yy &
23237 end function enesc_nucl
23238 !-----------------------------------------------------------------------------
23239 subroutine multibody_hb_nucl(ecorr,ecorr3,n_corr,n_corr1)
23242 integer,parameter :: max_cont=2000
23243 integer,parameter:: max_dim=2*(8*3+6)
23244 integer, parameter :: msglen1=max_cont*max_dim
23245 integer,parameter :: msglen2=2*msglen1
23246 integer source,CorrelType,CorrelID,Error
23247 real(kind=8) :: buffer(max_cont,max_dim)
23248 integer status(MPI_STATUS_SIZE)
23249 integer :: ierror,nbytes
23251 real(kind=8),dimension(3):: gx(3),gx1(3)
23252 real(kind=8) :: time00
23254 integer i,j,i1,j1,jj,kk,num_conti,num_conti1,nn
23255 real(kind=8) ecorr,ecorr3
23256 integer :: n_corr,n_corr1,mm,msglen
23257 !C Set lprn=.true. for debugging
23262 if(.not.allocated(zapas2)) allocate(zapas2(3,maxconts,nres,8))
23264 if (nfgtasks.le.1) goto 30
23266 write (iout,'(a)') 'Contact function values:'
23268 write (iout,'(2i3,50(1x,i2,f5.2))') &
23269 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i), &
23270 j=1,num_cont_hb(i))
23273 !C Caution! Following code assumes that electrostatic interactions concerning
23274 !C a given atom are split among at most two processors!
23284 !c write (*,*) 'MyRank',MyRank,' mm',mm
23287 !c write (*,*) 'Sending: MyRank',MyRank,' mm',mm,' ldone',ldone
23288 if (fg_rank.gt.0) then
23289 !C Send correlation contributions to the preceding processor
23291 nn=num_cont_hb(iatel_s_nucl)
23292 call pack_buffer(max_cont,max_dim,iatel_s,0,buffer)
23293 !c write (*,*) 'The BUFFER array:'
23295 !c write (*,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,30)
23297 if (ielstart_nucl(iatel_s_nucl).gt.iatel_s_nucl+ispp) then
23299 call pack_buffer(max_cont,max_dim,iatel_s+1,30,buffer)
23300 !C Clear the contacts of the atom passed to the neighboring processor
23301 nn=num_cont_hb(iatel_s_nucl+1)
23303 !c write (*,'(i2,9(3f8.3,2x))') i,(buffer(i,j+30),j=1,30)
23305 num_cont_hb(iatel_s_nucl)=0
23307 !cd write (iout,*) 'Processor ',fg_rank,MyRank,
23308 !cd & ' is sending correlation contribution to processor',fg_rank-1,
23309 !cd & ' msglen=',msglen
23310 !c write (*,*) 'Processor ',fg_rank,MyRank,
23311 !c & ' is sending correlation contribution to processor',fg_rank-1,
23312 !c & ' msglen=',msglen,' CorrelType=',CorrelType
23314 call MPI_Send(buffer,msglen,MPI_DOUBLE_PRECISION,fg_rank-1, &
23315 CorrelType,FG_COMM,IERROR)
23316 time_sendrecv=time_sendrecv+MPI_Wtime()-time00
23317 !cd write (iout,*) 'Processor ',fg_rank,
23318 !cd & ' has sent correlation contribution to processor',fg_rank-1,
23319 !cd & ' msglen=',msglen,' CorrelID=',CorrelID
23320 !c write (*,*) 'Processor ',fg_rank,
23321 !c & ' has sent correlation contribution to processor',fg_rank-1,
23322 !c & ' msglen=',msglen,' CorrelID=',CorrelID
23324 endif ! (fg_rank.gt.0)
23328 !c write (*,*) 'Receiving: MyRank',MyRank,' mm',mm,' ldone',ldone
23329 if (fg_rank.lt.nfgtasks-1) then
23330 !C Receive correlation contributions from the next processor
23332 if (ielend_nucl(iatel_e_nucl).lt.nct_molec(2)-1) msglen=msglen2
23333 !cd write (iout,*) 'Processor',fg_rank,
23334 !cd & ' is receiving correlation contribution from processor',fg_rank+1,
23335 !cd & ' msglen=',msglen,' CorrelType=',CorrelType
23336 !c write (*,*) 'Processor',fg_rank,
23337 !c &' is receiving correlation contribution from processor',fg_rank+1,
23338 !c & ' msglen=',msglen,' CorrelType=',CorrelType
23341 do while (nbytes.le.0)
23342 call MPI_Probe(fg_rank+1,CorrelType,FG_COMM,status,IERROR)
23343 call MPI_Get_count(status,MPI_DOUBLE_PRECISION,nbytes,IERROR)
23345 !c print *,'Processor',myrank,' msglen',msglen,' nbytes',nbytes
23346 call MPI_Recv(buffer,nbytes,MPI_DOUBLE_PRECISION, &
23347 fg_rank+1,CorrelType,FG_COMM,status,IERROR)
23348 time_sendrecv=time_sendrecv+MPI_Wtime()-time00
23349 !c write (*,*) 'Processor',fg_rank,
23350 !c &' has received correlation contribution from processor',fg_rank+1,
23351 !c & ' msglen=',msglen,' nbytes=',nbytes
23352 !c write (*,*) 'The received BUFFER array:'
23354 !c write (*,'(i2,9(3f8.3,2x))') i,(buffer(i,j),j=1,60)
23356 if (msglen.eq.msglen1) then
23357 call unpack_buffer(max_cont,max_dim,iatel_e_nucl+1,0,buffer)
23358 else if (msglen.eq.msglen2) then
23359 call unpack_buffer(max_cont,max_dim,iatel_e_nucl,0,buffer)
23360 call unpack_buffer(max_cont,max_dim,iatel_e_nucl+1,30,buffer)
23363 'ERROR!!!! message length changed while processing correlations.'
23365 'ERROR!!!! message length changed while processing correlations.'
23366 call MPI_Abort(MPI_COMM_WORLD,Error,IERROR)
23367 endif ! msglen.eq.msglen1
23368 endif ! fg_rank.lt.nfgtasks-1
23375 write (iout,'(a)') 'Contact function values:'
23376 do i=nnt_molec(2),nct_molec(2)-1
23377 write (iout,'(2i3,50(1x,i2,f5.2))') &
23378 i,num_cont_hb(i),(jcont_hb(j,i),facont_hb(j,i), &
23379 j=1,num_cont_hb(i))
23384 !C Remove the loop below after debugging !!!
23385 ! do i=nnt_molec(2),nct_molec(2)
23387 ! gradcorr_nucl(j,i)=0.0D0
23388 ! gradxorr_nucl(j,i)=0.0D0
23389 ! gradcorr3_nucl(j,i)=0.0D0
23390 ! gradxorr3_nucl(j,i)=0.0D0
23393 ! print *,"iatsc_s_nucl,iatsc_e_nucl",iatsc_s_nucl,iatsc_e_nucl
23394 !C Calculate the local-electrostatic correlation terms
23395 do i=iatsc_s_nucl,iatsc_e_nucl
23397 num_conti=num_cont_hb(i)
23398 num_conti1=num_cont_hb(i+1)
23399 ! print *,i,num_conti,num_conti1
23404 !c write (iout,*) 'i=',i,' j=',j,' i1=',i1,' j1=',j1,
23405 !c & ' jj=',jj,' kk=',kk
23406 if (j1.eq.j+1 .or. j1.eq.j-1) then
23408 !C Contacts I-J and (I+1)-(J+1) or (I+1)-(J-1) occur simultaneously.
23409 !C The system gains extra energy.
23410 !C Tentative expression & coefficients; assumed d(stacking)=4.5 A,
23411 !C parallel dipoles of stacknig bases and sin(mui)sin(muj)/eps/d^3=0.7
23412 !C Need to implement full formulas 34 and 35 from Liwo et al., 1998.
23414 ecorr=ecorr+ehbcorr_nucl(i,j,i+1,j1,jj,kk,0.528D0,0.132D0)
23415 if (energy_dec) write (iout,'(a6,2i5,0pf7.3)') &
23416 'ecorrh',i,j,ehbcorr_nucl(i,j,i+1,j1,jj,kk,0.528D0,0.132D0)
23418 else if (j1.eq.j) then
23420 !C Contacts I-J and I-(J+1) occur simultaneously.
23421 !C The system loses extra energy.
23422 !C Tentative expression & c?oefficients; assumed d(stacking)=4.5 A,
23423 !C parallel dipoles of stacknig bases and sin(mui)sin(muj)/eps/d^3=0.7
23424 !C Need to implement full formulas 32 from Liwo et al., 1998.
23426 !c write (iout,*) 'ecorr3: i=',i,' j=',j,' i1=',i1,' j1=',j1,
23427 !c & ' jj=',jj,' kk=',kk
23428 ecorr3=ecorr3+ehbcorr3_nucl(i,j,i+1,j,jj,kk,0.310D0,-0.155D0)
23433 !c write (iout,*) 'ecorr3: i=',i,' j=',j,' i1=',i1,' j1=',j1,
23434 !c & ' jj=',jj,' kk=',kk
23435 if (j1.eq.j+1) then
23436 !C Contacts I-J and (I+1)-J occur simultaneously.
23437 !C The system loses extra energy.
23438 ecorr3=ecorr3+ehbcorr3_nucl(i,j,i,j+1,jj,kk,0.310D0,-0.155D0)
23444 end subroutine multibody_hb_nucl
23445 !-----------------------------------------------------------
23446 real(kind=8) function ehbcorr_nucl(i,j,k,l,jj,kk,coeffp,coeffm)
23447 ! implicit real(kind=8) (a-h,o-z)
23448 ! include 'DIMENSIONS'
23449 ! include 'COMMON.IOUNITS'
23450 ! include 'COMMON.DERIV'
23451 ! include 'COMMON.INTERACT'
23452 ! include 'COMMON.CONTACTS'
23453 real(kind=8),dimension(3) :: gx,gx1
23455 !el local variables
23456 integer :: i,j,k,l,jj,kk,ll,ilist,m, iresshield
23457 real(kind=8) :: coeffp,coeffm,eij,ekl,ees0pij,ees0pkl,ees0mij,&
23458 ees0mkl,ees,coeffpees0pij,coeffmees0mij,&
23459 coeffpees0pkl,coeffmees0mkl,gradlongij,gradlongkl, &
23463 eij=facont_hb(jj,i)
23464 ekl=facont_hb(kk,k)
23465 ees0pij=ees0p(jj,i)
23466 ees0pkl=ees0p(kk,k)
23467 ees0mij=ees0m(jj,i)
23468 ees0mkl=ees0m(kk,k)
23470 ees=-(coeffp*ees0pij*ees0pkl+coeffm*ees0mij*ees0mkl)
23471 ! print *,"ehbcorr_nucl",ekont,ees
23472 !cd ees=-(coeffp*ees0pkl+coeffm*ees0mkl)
23473 !C Following 4 lines for diagnostics.
23478 !cd write (iout,*)'Contacts have occurred for nucleic bases',
23479 !cd & i,j,' fcont:',eij,' eij',' eesij',ees0pij,ees0mij,' and ',k,l
23480 !cd & ,' fcont ',ekl,' eeskl',ees0pkl,ees0mkl,' ees=',ees
23481 !C Calculate the multi-body contribution to energy.
23482 ! ecorr_nucl=ecorr_nucl+ekont*ees
23483 !C Calculate multi-body contributions to the gradient.
23484 coeffpees0pij=coeffp*ees0pij
23485 coeffmees0mij=coeffm*ees0mij
23486 coeffpees0pkl=coeffp*ees0pkl
23487 coeffmees0mkl=coeffm*ees0mkl
23489 gradxorr_nucl(ll,i)=gradxorr_nucl(ll,i) &
23490 -ekont*(coeffpees0pkl*gacontp_hb1(ll,jj,i)+&
23491 coeffmees0mkl*gacontm_hb1(ll,jj,i))
23492 gradxorr_nucl(ll,j)=gradxorr_nucl(ll,j) &
23493 -ekont*(coeffpees0pkl*gacontp_hb2(ll,jj,i)+&
23494 coeffmees0mkl*gacontm_hb2(ll,jj,i))
23495 gradxorr_nucl(ll,k)=gradxorr_nucl(ll,k) &
23496 -ekont*(coeffpees0pij*gacontp_hb1(ll,kk,k)+&
23497 coeffmees0mij*gacontm_hb1(ll,kk,k))
23498 gradxorr_nucl(ll,l)=gradxorr_nucl(ll,l) &
23499 -ekont*(coeffpees0pij*gacontp_hb2(ll,kk,k)+ &
23500 coeffmees0mij*gacontm_hb2(ll,kk,k))
23501 gradlongij=ees*ekl*gacont_hbr(ll,jj,i)- &
23502 ekont*(coeffpees0pkl*gacontp_hb3(ll,jj,i)+ &
23503 coeffmees0mkl*gacontm_hb3(ll,jj,i))
23504 gradcorr_nucl(ll,j)=gradcorr_nucl(ll,j)+gradlongij
23505 gradcorr_nucl(ll,i)=gradcorr_nucl(ll,i)-gradlongij
23506 gradlongkl=ees*eij*gacont_hbr(ll,kk,k)- &
23507 ekont*(coeffpees0pij*gacontp_hb3(ll,kk,k)+ &
23508 coeffmees0mij*gacontm_hb3(ll,kk,k))
23509 gradcorr_nucl(ll,l)=gradcorr_nucl(ll,l)+gradlongkl
23510 gradcorr_nucl(ll,k)=gradcorr_nucl(ll,k)-gradlongkl
23511 gradxorr_nucl(ll,i)=gradxorr_nucl(ll,i)-gradlongij
23512 gradxorr_nucl(ll,j)=gradxorr_nucl(ll,j)+gradlongij
23513 gradxorr_nucl(ll,k)=gradxorr_nucl(ll,k)-gradlongkl
23514 gradxorr_nucl(ll,l)=gradxorr_nucl(ll,l)+gradlongkl
23516 ehbcorr_nucl=ekont*ees
23518 end function ehbcorr_nucl
23519 !-------------------------------------------------------------------------
23521 real(kind=8) function ehbcorr3_nucl(i,j,k,l,jj,kk,coeffp,coeffm)
23522 ! implicit real(kind=8) (a-h,o-z)
23523 ! include 'DIMENSIONS'
23524 ! include 'COMMON.IOUNITS'
23525 ! include 'COMMON.DERIV'
23526 ! include 'COMMON.INTERACT'
23527 ! include 'COMMON.CONTACTS'
23528 real(kind=8),dimension(3) :: gx,gx1
23530 !el local variables
23531 integer :: i,j,k,l,jj,kk,ll,ilist,m, iresshield
23532 real(kind=8) :: coeffp,coeffm,eij,ekl,ees0pij,ees0pkl,ees0mij,&
23533 ees0mkl,ees,coeffpees0pij,coeffmees0mij,&
23534 coeffpees0pkl,coeffmees0mkl,gradlongij,gradlongkl, &
23538 eij=facont_hb(jj,i)
23539 ekl=facont_hb(kk,k)
23540 ees0pij=ees0p(jj,i)
23541 ees0pkl=ees0p(kk,k)
23542 ees0mij=ees0m(jj,i)
23543 ees0mkl=ees0m(kk,k)
23545 ees=-(coeffp*ees0pij*ees0pkl+coeffm*ees0mij*ees0mkl)
23546 !cd ees=-(coeffp*ees0pkl+coeffm*ees0mkl)
23547 !C Following 4 lines for diagnostics.
23552 !cd write (iout,*)'Contacts have occurred for nucleic bases',
23553 !cd & i,j,' fcont:',eij,' eij',' eesij',ees0pij,ees0mij,' and ',k,l
23554 !cd & ,' fcont ',ekl,' eeskl',ees0pkl,ees0mkl,' ees=',ees
23555 !C Calculate the multi-body contribution to energy.
23556 ! ecorr=ecorr+ekont*ees
23557 !C Calculate multi-body contributions to the gradient.
23558 coeffpees0pij=coeffp*ees0pij
23559 coeffmees0mij=coeffm*ees0mij
23560 coeffpees0pkl=coeffp*ees0pkl
23561 coeffmees0mkl=coeffm*ees0mkl
23563 gradxorr3_nucl(ll,i)=gradxorr3_nucl(ll,i) &
23564 -ekont*(coeffpees0pkl*gacontp_hb1(ll,jj,i)+&
23565 coeffmees0mkl*gacontm_hb1(ll,jj,i))
23566 gradxorr3_nucl(ll,j)=gradxorr3_nucl(ll,j) &
23567 -ekont*(coeffpees0pkl*gacontp_hb2(ll,jj,i)+ &
23568 coeffmees0mkl*gacontm_hb2(ll,jj,i))
23569 gradxorr3_nucl(ll,k)=gradxorr3_nucl(ll,k) &
23570 -ekont*(coeffpees0pij*gacontp_hb1(ll,kk,k)+ &
23571 coeffmees0mij*gacontm_hb1(ll,kk,k))
23572 gradxorr3_nucl(ll,l)=gradxorr3_nucl(ll,l) &
23573 -ekont*(coeffpees0pij*gacontp_hb2(ll,kk,k)+ &
23574 coeffmees0mij*gacontm_hb2(ll,kk,k))
23575 gradlongij=ees*ekl*gacont_hbr(ll,jj,i)- &
23576 ekont*(coeffpees0pkl*gacontp_hb3(ll,jj,i)+ &
23577 coeffmees0mkl*gacontm_hb3(ll,jj,i))
23578 gradcorr3_nucl(ll,j)=gradcorr3_nucl(ll,j)+gradlongij
23579 gradcorr3_nucl(ll,i)=gradcorr3_nucl(ll,i)-gradlongij
23580 gradlongkl=ees*eij*gacont_hbr(ll,kk,k)- &
23581 ekont*(coeffpees0pij*gacontp_hb3(ll,kk,k)+ &
23582 coeffmees0mij*gacontm_hb3(ll,kk,k))
23583 gradcorr3_nucl(ll,l)=gradcorr3_nucl(ll,l)+gradlongkl
23584 gradcorr3_nucl(ll,k)=gradcorr3_nucl(ll,k)-gradlongkl
23585 gradxorr3_nucl(ll,i)=gradxorr3_nucl(ll,i)-gradlongij
23586 gradxorr3_nucl(ll,j)=gradxorr3_nucl(ll,j)+gradlongij
23587 gradxorr3_nucl(ll,k)=gradxorr3_nucl(ll,k)-gradlongkl
23588 gradxorr3_nucl(ll,l)=gradxorr3_nucl(ll,l)+gradlongkl
23590 ehbcorr3_nucl=ekont*ees
23592 end function ehbcorr3_nucl
23594 subroutine pack_buffer(dimen1,dimen2,atom,indx,buffer)
23595 integer dimen1,dimen2,atom,indx,numcont,i,ii,k,j,num_kont,num_kont_old
23596 real(kind=8):: buffer(dimen1,dimen2)
23597 num_kont=num_cont_hb(atom)
23601 buffer(i,indx+(k-1)*3+j)=zapas2(j,i,atom,k)
23604 buffer(i,indx+25)=facont_hb(i,atom)
23605 buffer(i,indx+26)=ees0p(i,atom)
23606 buffer(i,indx+27)=ees0m(i,atom)
23607 buffer(i,indx+28)=d_cont(i,atom)
23608 buffer(i,indx+29)=dfloat(jcont_hb(i,atom))
23610 buffer(1,indx+30)=dfloat(num_kont)
23612 end subroutine pack_buffer
23613 !c------------------------------------------------------------------------------
23614 subroutine unpack_buffer(dimen1,dimen2,atom,indx,buffer)
23615 integer dimen1,dimen2,atom,indx,numcont,i,ii,k,j,num_kont,num_kont_old
23616 real(kind=8):: buffer(dimen1,dimen2)
23617 ! double precision zapas
23618 ! common /contacts_hb/ zapas(3,maxconts,maxres,8),
23619 ! & facont_hb(maxconts,maxres),ees0p(maxconts,maxres),
23620 ! & ees0m(maxconts,maxres),d_cont(maxconts,maxres),
23621 ! & num_cont_hb(maxres),jcont_hb(maxconts,maxres)
23622 num_kont=buffer(1,indx+30)
23623 num_kont_old=num_cont_hb(atom)
23624 num_cont_hb(atom)=num_kont+num_kont_old
23629 zapas2(j,ii,atom,k)=buffer(i,indx+(k-1)*3+j)
23632 facont_hb(ii,atom)=buffer(i,indx+25)
23633 ees0p(ii,atom)=buffer(i,indx+26)
23634 ees0m(ii,atom)=buffer(i,indx+27)
23635 d_cont(i,atom)=buffer(i,indx+28)
23636 jcont_hb(ii,atom)=buffer(i,indx+29)
23639 end subroutine unpack_buffer
23640 !c------------------------------------------------------------------------------
23642 subroutine ecatcat(ecationcation)
23643 use MD_data, only: t_bath
23644 integer :: i,j,itmp,xshift,yshift,zshift,subchap,k,itypi,itypj,irdiff,&
23646 real(kind=8) :: xi,yi,zi,xj,yj,zj,ract,rcat0,epscalc,r06,r012,&
23647 r7,r4,ecationcation,k0,rcal,aa,bb,sslipi,ssgradlipi,sslipj,ssgradlipj
23648 real(kind=8) :: xj_temp,yj_temp,zj_temp,xj_safe,yj_safe,zj_safe, &
23649 dist_init,dist_temp,Evan1cat,Evan2cat,Eeleccat
23650 real(kind=8) :: awat,bwat,cwat,dwat,sss2min2,sss2mingrad2,rdiff,ewater
23651 real(kind=8),dimension(3) ::dEvan1Cmcat,dEvan2Cmcat,dEeleccat,&
23654 ecationcation=0.0d0
23655 if (nres_molec(5).le.1) return
23660 ! k0 = 332.0*(2.0*2.0)/80.0
23664 ! itmp=itmp+nres_molec(i)
23666 ! write(iout,*) "itmp",g_listcatcatnorm_start, g_listcatcatnorm_end
23667 ! do i=itmp+1,itmp+nres_molec(5)-1
23668 do ii=g_listcatcatnorm_start, g_listcatcatnorm_end
23669 i=newcontlistcatcatnormi(ii)
23670 j=newcontlistcatcatnormj(ii)
23675 ! write (iout,*) i,"TUTUT",c(1,i)
23677 call to_box(xi,yi,zi)
23678 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
23679 ! do j=i+1,itmp+nres_molec(5)
23681 ! print *,i,j,itypi,itypj
23682 k0 = 332.0*(ichargecat(itypi)*ichargecat(itypj))/80.0
23683 ! print *,i,j,'catcat'
23687 call to_box(xj,yj,zj)
23688 ! call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
23689 ! aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
23690 ! +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
23691 ! bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
23692 ! +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
23693 xj=boxshift(xj-xi,boxxsize)
23694 yj=boxshift(yj-yi,boxysize)
23695 zj=boxshift(zj-zi,boxzsize)
23696 rcal =xj**2+yj**2+zj**2
23698 if ((itypi.gt.1).or.(itypj.gt.1)) then
23699 if (sss2min2.eq.0.0d0) cycle
23700 sss2min2=sscale2(ract,12.0d0,1.0d0)
23701 sss2mingrad2=sscagrad2(ract,12.0d0,1.0d0)
23706 ! k0 = 332*(2*2)/80
23707 Evan1cat=epscalc*(r012/(rcal**6))
23708 Evan2cat=epscalc*2*(r06/(rcal**3))
23716 dEvan1Cmcat(k)=-12*r(k)*epscalc*r012/r7
23717 dEvan2Cmcat(k)=-12*r(k)*epscalc*r06/r4
23718 dEeleccat(k)=-k0*r(k)/ract**3
23721 gg(k) = dEvan1Cmcat(k)+dEvan2Cmcat(k)+dEeleccat(k)
23722 gradcatcat(k,i)=gradcatcat(k,i)-(gg(k)*sss2min2+(Evan1cat+Evan2cat+Eeleccat)*sss2mingrad2)
23723 gradcatcat(k,j)=gradcatcat(k,j)+gg(k)*sss2min2+(Evan1cat+Evan2cat+Eeleccat)*sss2mingrad2
23725 if (energy_dec) write (iout,*) "ecatcat",i,j,Evan1cat,Evan2cat,Eeleccat,&
23726 r012,rcal**6,ichargecat(itypi)*ichargecat(itypj)
23727 ! write(iout,*) "ecatcat",i,j, ecationcation,xj,yj,zj
23728 ecationcation=ecationcation+(Evan1cat+Evan2cat+Eeleccat)*sss2min2
23729 else !this is water part and other non standard molecules
23731 sss2min2=sscale2(ract,10.0d0,1.0d0)! cutoff for water interaction is 15A
23732 if (sss2min2.eq.0.0d0) cycle
23733 sss2mingrad2=sscagrad2(ract,10.0d0,1.0d0)
23734 irdiff=int((ract-2.06d0)*50.0d0)+1
23736 rdiff=ract-((irdiff-1)*0.02d0+2.06d0)
23737 if (irdiff.le.0) then
23741 ! print *,rdiff,ract,irdiff,sss2mingrad2
23742 awat=awaterenta(irdiff)-awaterentro(irdiff)*t_bath/1000.0d0
23743 bwat=bwaterenta(irdiff)-bwaterentro(irdiff)*t_bath/1000.0d0
23744 cwat=cwaterenta(irdiff)-cwaterentro(irdiff)*t_bath/1000.0d0
23745 dwat=dwaterenta(irdiff)-dwaterentro(irdiff)*t_bath/1000.0d0
23750 ewater=awat+bwat*rdiff+cwat*rdiff*rdiff+dwat*rdiff*rdiff*rdiff
23751 ecationcation=ecationcation+ewater*sss2min2
23753 gg(k)=(bwat+2.0d0*cwat*rdiff+dwat*3.0d0*rdiff*rdiff)*r(k)/ract
23754 gradcatcat(k,i)=gradcatcat(k,i)-gg(k)*sss2min2-sss2mingrad2*ewater*r(k)/ract
23755 gradcatcat(k,j)=gradcatcat(k,j)+gg(k)*sss2min2+sss2mingrad2*ewater*r(k)/ract
23757 if (energy_dec) write(iout,'(2f8.2,f10.2,2i5)') rdiff,ract,ecationcation,i,j
23762 end subroutine ecatcat
23763 !---------------------------------------------------------------------------
23765 subroutine ecats_prot_amber(evdw)
23766 ! subroutine ecat_prot2(ecation_prot)
23771 !el local variables
23772 integer :: iint,itypi1,subchap,isel,itmp
23773 real(kind=8) :: rrij,xi,yi,zi,sig,rij_shift,e1,e2,sigm,epsi
23774 real(kind=8) :: evdw,aa,bb
23775 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
23776 dist_temp, dist_init,ssgradlipi,ssgradlipj, &
23777 sslipi,sslipj,faclip,alpha_sco
23779 real(kind=8) :: fracinbuf
23780 real (kind=8) :: escpho
23781 real (kind=8),dimension(4):: ener
23782 real(kind=8) :: b1,b2,egb
23783 real(kind=8) :: Fisocav,ECL,Elj,Equad,Epol,eheadtail,&
23785 Chif,ChiLambf,Fcav,dFdR,dFdOM1,&
23786 ecations_prot_amber,dFdOM2,dFdL,dFdOM12,&
23789 ! real(kind=8),dimension(3,2)::erhead_tail
23790 ! real(kind=8),dimension(3) :: Rhead_distance,ertail,erhead,Rtail_distance
23791 real(kind=8) :: facd4, adler, Fgb, facd3
23792 integer troll,jj,istate
23793 real (kind=8) :: dcosom1(3),dcosom2(3)
23794 real(kind=8) ::locbox(3)
23800 if (nres_molec(5).eq.0) return
23802 ! sss_ele_cut=1.0d0
23806 itmp=itmp+nres_molec(i)
23809 ! do i=1,nres_molec(1)-1 ! loop over all peptide groups needs parralelization
23810 ! do i=ibond_start,ibond_end
23811 do ki=g_listcatscnorm_start,g_listcatscnorm_end
23812 i=newcontlistcatscnormi(ki)
23813 j=newcontlistcatscnormj(ki)
23815 ! print *,"I am in EVDW",i
23816 itypi=iabs(itype(i,1))
23818 ! if (i.ne.47) cycle
23819 if ((itypi.eq.ntyp1).or.(itypi.eq.10)) cycle
23820 itypi1=iabs(itype(i+1,1))
23824 call to_box(xi,yi,zi)
23825 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
23826 dxi=dc_norm(1,nres+i)
23827 dyi=dc_norm(2,nres+i)
23828 dzi=dc_norm(3,nres+i)
23829 dsci_inv=vbld_inv(i+nres)
23830 ! do j=itmp+1,itmp+nres_molec(5)
23832 ! Calculate SC interaction energy.
23833 itypj=iabs(itype(j,5))
23834 if ((itypj.eq.ntyp1)) cycle
23835 CALL elgrad_init_cat(eheadtail,Egb,Ecl,Elj,Equad,Epol)
23842 call to_box(xj,yj,zj)
23843 ! write(iout,*) "xi,yi,zi,xj,yj,zj", xi,yi,zi,xj,yj,zj
23845 ! call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
23846 ! aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
23847 ! +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
23848 ! bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
23849 ! +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
23850 xj=boxshift(xj-xi,boxxsize)
23851 yj=boxshift(yj-yi,boxysize)
23852 zj=boxshift(zj-zi,boxzsize)
23853 ! write(iout,*) "xj,yj,zj", xj,yj,zj,boxxsize
23858 ! dxj = dc_norm( 1, nres+j )
23859 ! dyj = dc_norm( 2, nres+j )
23860 ! dzj = dc_norm( 3, nres+j )
23864 ! Parameters from fitting the analitical expressions to the PMF obtained by umbrella
23865 ! sampling performed with amber package
23869 ! a12sq = rborn(itypi,itypj) * rborn(itypj,itypi)
23870 chi1 = chi1cat(itypi,itypj)
23871 chis1 = chis1cat(itypi,itypj)
23872 chip1 = chipp1cat(itypi,itypj)
23879 ! chis2 = chis(itypj,itypi)
23880 chis12 = chis1 * chis2
23881 sig1 = sigmap1cat(itypi,itypj)
23883 ! sig2 = sigmap2(itypi,itypj)
23884 ! alpha factors from Fcav/Gcav
23885 b1cav = alphasurcat(1,itypi,itypj)
23886 b2cav = alphasurcat(2,itypi,itypj)
23887 b3cav = alphasurcat(3,itypi,itypj)
23888 b4cav = alphasurcat(4,itypi,itypj)
23895 ! used to determine whether we want to do quadrupole calculations
23896 eps_in = epsintabcat(itypi,itypj)
23897 if (eps_in.eq.0.0) eps_in=1.0
23899 eps_inout_fac = ( (1.0d0/eps_in) - (1.0d0/eps_out))
23903 ctail(k,1)=c(k,i+nres)
23906 call to_box(ctail(1,1),ctail(2,1),ctail(3,1))
23907 call to_box(ctail(1,2),ctail(2,2),ctail(3,2))
23908 !c! tail distances will be themselves usefull elswhere
23909 !c1 (in Gcav, for example)
23911 Rtail_distance(k) = boxshift(ctail(k,2) - ctail(k,1),locbox(k))
23914 (Rtail_distance(1)*Rtail_distance(1)) &
23915 + (Rtail_distance(2)*Rtail_distance(2)) &
23916 + (Rtail_distance(3)*Rtail_distance(3)))
23917 ! tail location and distance calculations
23919 d1 = dheadcat(1, 1, itypi, itypj)
23920 ! d2 = dhead(2, 1, itypi, itypj)
23922 ! location of polar head is computed by taking hydrophobic centre
23923 ! and moving by a d1 * dc_norm vector
23924 ! see unres publications for very informative images
23925 chead(k,1) = c(k, i+nres) + d1 * dc_norm(k, i+nres)
23926 chead(k,2) = c(k, j)
23928 call to_box(chead(1,1),chead(2,1),chead(3,1))
23929 call to_box(chead(1,2),chead(2,2),chead(3,2))
23930 ! write(iout,*) "TEST",chead(1,1),chead(2,1),chead(3,1),dc_norm(k, i+nres),d1
23932 ! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
23933 ! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
23935 Rhead_distance(k) = boxshift(chead(k,2) - chead(k,1),locbox(k))
23937 ! pitagoras (root of sum of squares)
23939 (Rhead_distance(1)*Rhead_distance(1)) &
23940 + (Rhead_distance(2)*Rhead_distance(2)) &
23941 + (Rhead_distance(3)*Rhead_distance(3)))
23942 !-------------------------------------------------------------------
23943 ! zero everything that should be zero'ed
23962 dscj_inv = vbld_inv(j+nres)
23963 ! print *,i,j,dscj_inv,dsci_inv
23964 ! rij holds 1/(distance of Calpha atoms)
23965 rrij = 1.0D0 / ( xj*xj + yj*yj + zj*zj)
23967 sss_ele_cut=sscale_ele(1.0d0/(rij))
23968 sss_ele_grad=sscagrad_ele(1.0d0/(rij))
23969 ! print *,sss_ele_cut,sss_ele_grad,&
23970 ! 1.0d0/(rij),r_cut_ele,rlamb_ele
23971 if (sss_ele_cut.le.0.0) cycle
23973 ! this should be in elgrad_init but om's are calculated by sc_angular
23974 ! which in turn is used by older potentials
23975 ! om = omega, sqom = om^2
23978 sqom12 = om12 * om12
23980 ! now we calculate EGB - Gey-Berne
23981 ! It will be summed up in evdwij and saved in evdw
23982 sigsq = 1.0D0 / sigsq
23983 sig = sig0ij * dsqrt(sigsq)
23984 ! rij_shift = 1.0D0 / rij - sig + sig0ij
23985 rij_shift = Rtail - sig + sig0ij
23986 IF (rij_shift.le.0.0D0) THEN
23988 if (evdw.gt.1.0d6) then
23989 write (*,'(2(1x,a3,i3),7f7.2)') &
23990 restyp(itype(i,1),1),i,restyp(itype(j,1),1),j,&
23991 1.0d0/rij,Rtail,Rhead,rij_shift, sig, sig0ij,sigsq
23992 write(*,*) facsig,faceps1_inv,om1,chiom1,chi1
23993 write(*,*) "ANISO?!",chi1
23994 !evdwij,Fcav,Ecl,Egb,Epol,Fisocav,Elj,&
23995 ! Equad,evdwij+Fcav+eheadtail,evdw
24000 sigder = -sig * sigsq
24001 rij_shift = 1.0D0 / rij_shift
24002 fac = rij_shift**expon
24003 c1 = fac * fac * aa_aq_cat(itypi,itypj)
24004 ! print *,"ADAM",aa_aq(itypi,itypj)
24007 c2 = fac * bb_aq_cat(itypi,itypj)
24009 evdwij = eps1 * eps2rt * eps3rt * ( c1 + c2 )
24010 eps2der = eps3rt * evdwij
24011 eps3der = eps2rt * evdwij
24012 ! evdwij = 4.0d0 * eps2rt * eps3rt * evdwij
24013 evdwij = eps2rt * eps3rt * evdwij
24015 ! IF (bb_aq(itypi,itypj).gt.0) THEN
24016 ! evdw_p = evdw_p + evdwij
24018 ! evdw_m = evdw_m + evdwij
24022 + evdwij*sss_ele_cut
24024 c1 = c1 * eps1 * eps2rt**2 * eps3rt**2
24025 fac = -expon * (c1 + evdwij) * rij_shift
24026 sigder = fac * sigder
24027 ! Calculate distance derivative
24028 gg(1) = fac*sss_ele_cut+evdwij*sss_ele_grad
24029 gg(2) = fac*sss_ele_cut+evdwij*sss_ele_grad
24030 gg(3) = fac*sss_ele_cut+evdwij*sss_ele_grad
24031 ! print *,"GG(1),distance grad",gg(1)
24032 fac = chis1 * sqom1 + chis2 * sqom2 &
24033 - 2.0d0 * chis12 * om1 * om2 * om12
24034 pom = 1.0d0 - chis1 * chis2 * sqom12
24035 Lambf = (1.0d0 - (fac / pom))
24036 Lambf = dsqrt(Lambf)
24037 sparrow = 1.0d0 / dsqrt(sig1**2.0d0 + sig2**2.0d0)
24038 Chif = Rtail * sparrow
24039 ChiLambf = Chif * Lambf
24040 eagle = dsqrt(ChiLambf)
24041 bat = ChiLambf ** 11.0d0
24042 top = b1cav * ( eagle + b2cav * ChiLambf - b3cav )
24043 bot = 1.0d0 + b4cav * (ChiLambf ** 12.0d0)
24047 dtop = b1cav * ((Lambf / (2.0d0 * eagle)) + (b2cav * Lambf))
24048 dbot = 12.0d0 * b4cav * bat * Lambf
24049 dFdR = ((dtop * bot - top * dbot) / botsq) * sparrow*sss_ele_cut+&
24051 Fcav=Fcav*sss_ele_cut
24052 dtop = b1cav * ((Chif / (2.0d0 * eagle)) + (b2cav * Chif))
24053 dbot = 12.0d0 * b4cav * bat * Chif
24054 eagle = Lambf * pom
24055 dFdOM1 = -(chis1 * om1 - chis12 * om2 * om12) / (eagle)
24056 dFdOM2 = -(chis2 * om2 - chis12 * om1 * om12) / (eagle)
24057 dFdOM12 = chis12 * (chis1 * om1 * om12 - om2) &
24058 * (chis2 * om2 * om12 - om1) / (eagle * pom)
24060 dFdL = ((dtop * bot - top * dbot) / botsq)
24061 dCAVdOM1 = dFdL * ( dFdOM1 )
24062 dCAVdOM2 = dFdL * ( dFdOM2 )
24063 dCAVdOM12 = dFdL * ( dFdOM12 )
24066 ertail(k) = Rtail_distance(k)/Rtail
24068 erdxi = scalar( ertail(1), dC_norm(1,i+nres) )
24069 erdxj = scalar( ertail(1), dC_norm(1,j) )
24070 facd1 = dtailcat(1,itypi,itypj) * vbld_inv(i+nres)
24071 facd2 = dtailcat(2,itypi,itypj) * vbld_inv(j)
24073 pom = ertail(k)-facd1*(ertail(k)-erdxi*dC_norm(k,i+nres))
24074 gradpepcatx(k,i) = gradpepcatx(k,i) &
24075 - (( dFdR + gg(k) ) * pom)
24076 pom = ertail(k)-facd2*(ertail(k)-erdxj*dC_norm(k,j))
24077 ! gvdwx(k,j) = gvdwx(k,j) &
24078 ! + (( dFdR + gg(k) ) * pom)
24079 gradpepcat(k,i) = gradpepcat(k,i) &
24080 - (( dFdR + gg(k) ) * ertail(k))
24081 gradpepcat(k,j) = gradpepcat(k,j) &
24082 + (( dFdR + gg(k) ) * ertail(k))
24085 !c! Compute head-head and head-tail energies for each state
24086 !! if (.false.) then ! turn off electrostatic
24087 if (itype(j,5).gt.0) then ! the normal cation case
24088 isel = iabs(Qi) + 1 ! ion is always charged so iabs(Qj)
24089 ! print *,i,itype(i,1),isel
24090 IF (isel.eq.0) THEN
24092 ELSE IF (isel.eq.1) THEN
24093 if ((itype(i,1).eq.27).or.(itype(i,1).eq.26).or.(itype(i,1).eq.25)) then
24099 ELSE IF (isel.eq.3) THEN
24100 if ((itype(i,1).eq.27).or.(itype(i,1).eq.26).or.(itype(i,1).eq.25)) then
24104 CALL edq_cat(ecl, elj, epol)
24105 eheadtail = ECL + elj + epol
24106 ELSE IF ((isel.eq.2)) THEN
24107 if ((itype(i,1).eq.27).or.(itype(i,1).eq.26).or.(itype(i,1).eq.25)) then
24111 CALL eqq_cat(Ecl,Egb,Epol,Fisocav,Elj)
24112 eheadtail = ECL + Egb + Epol + Fisocav + Elj
24113 END IF ! this endif ends the "catch the gly-gly" at the beggining of Fcav
24114 else ! here is water and other molecules
24117 ! if (isel.eq.4) isel=2
24118 if (isel.eq.2) then
24120 else if (isel.eq.3) then
24121 if ((itype(i,1).eq.27).or.(itype(i,1).eq.26).or.(itype(i,1).eq.25)) then
24125 call eqd_cat(ecl,elj,epol)
24126 eheadtail = ECL + elj + epol
24127 else if (isel.eq.4) then
24131 ! write(iout,*) "not yet implemented",j,itype(j,5)
24133 !! endif ! turn off electrostatic
24134 evdw = evdw + Fcav + eheadtail
24135 ! if (evdw.gt.1.0d6) then
24136 ! write (*,'(2(1x,a3,i3),3f6.2,10f16.7)') &
24137 ! restyp(itype(i,1),1),i,restyp(itype(j,1),1),j,&
24138 ! 1.0d0/rij,Rtail,Rhead,evdwij,Fcav,Ecl,Egb,Epol,Fisocav,Elj,&
24139 ! Equad,evdwij+Fcav+eheadtail,evdw
24142 IF (energy_dec) write (iout,'(2(1x,a3,i3),3f6.2,10f16.7)') &
24143 restyp(itype(i,1),1),i,restyp(itype(j,1),1),j,&
24144 1.0d0/rij,Rtail,Rhead,evdwij,Fcav,Ecl,Egb,Epol,Fisocav,Elj,&
24145 Equad,evdwij+Fcav+eheadtail,evdw
24146 ! evdw = evdw + Fcav + eheadtail
24147 if (energy_dec) write(iout,*) "FCAV", &
24148 sig1,sig2,b1cav,b2cav,b3cav,b4cav
24149 ! print *,"before sc_grad_cat", i,j, gradpepcat(1,j)
24150 ! iF (nstate(itypi,itypj).eq.1) THEN
24152 ! print *,"after sc_grad_cat", i,j, gradpepcat(1,j)
24155 !c!-------------------------------------------------------------------
24159 !c write (iout,*) "Number of loop steps in EGB:",ind
24160 !c energy_dec=.false.
24161 ! print *,"EVDW KURW",evdw,nres
24165 ! do i=ibond_start,ibond_end
24167 do ki=g_listcatpnorm_start,g_listcatpnorm_end
24168 i=newcontlistcatpnormi(ki)
24169 j=newcontlistcatpnormj(ki)
24171 ! print *,"I am in EVDW",i
24172 itypi=10 ! the peptide group parameters are for glicine
24174 ! if (i.ne.47) cycle
24175 if ((itype(i,1).eq.ntyp1).or.itype(i+1,1).eq.ntyp1) cycle
24176 itypi1=iabs(itype(i+1,1))
24177 xi=(c(1,i)+c(1,i+1))/2.0
24178 yi=(c(2,i)+c(2,i+1))/2.0
24179 zi=(c(3,i)+c(3,i+1))/2.0
24180 call to_box(xi,yi,zi)
24184 dsci_inv=vbld_inv(i+1)/2.0
24185 ! do j=itmp+1,itmp+nres_molec(5)
24187 ! Calculate SC interaction energy.
24188 itypj=iabs(itype(j,5))
24189 if ((itypj.eq.ntyp1)) cycle
24190 CALL elgrad_init_cat_pep(eheadtail,Egb,Ecl,Elj,Equad,Epol)
24196 call to_box(xj,yj,zj)
24197 xj=boxshift(xj-xi,boxxsize)
24198 yj=boxshift(yj-yi,boxysize)
24199 zj=boxshift(zj-zi,boxzsize)
24201 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
24203 dxj = 0.0d0! dc_norm( 1, nres+j )
24204 dyj = 0.0d0!dc_norm( 2, nres+j )
24205 dzj = 0.0d0! dc_norm( 3, nres+j )
24209 ! Parameters from fitting the analitical expressions to the PMF obtained by umbrella
24210 ! sampling performed with amber package
24214 ! a12sq = rborn(itypi,itypj) * rborn(itypj,itypi)
24215 chi1 = chi1cat(itypi,itypj)
24216 chis1 = chis1cat(itypi,itypj)
24217 chip1 = chipp1cat(itypi,itypj)
24224 ! chis2 = chis(itypj,itypi)
24225 chis12 = chis1 * chis2
24226 sig1 = sigmap1cat(itypi,itypj)
24228 ! sig2 = sigmap2(itypi,itypj)
24229 ! alpha factors from Fcav/Gcav
24230 b1cav = alphasurcat(1,itypi,itypj)
24231 b2cav = alphasurcat(2,itypi,itypj)
24232 b3cav = alphasurcat(3,itypi,itypj)
24233 b4cav = alphasurcat(4,itypi,itypj)
24235 ! used to determine whether we want to do quadrupole calculations
24236 eps_in = epsintabcat(itypi,itypj)
24237 if (eps_in.eq.0.0) eps_in=1.0
24239 eps_inout_fac = ( (1.0d0/eps_in) - (1.0d0/eps_out))
24243 ctail(k,1)=(c(k,i)+c(k,i+1))/2.0
24246 call to_box(ctail(1,1),ctail(2,1),ctail(3,1))
24247 call to_box(ctail(1,2),ctail(2,2),ctail(3,2))
24248 !c! tail distances will be themselves usefull elswhere
24249 !c1 (in Gcav, for example)
24251 Rtail_distance(k) = boxshift(ctail(k,2) - ctail(k,1),locbox(k))
24254 !c! tail distances will be themselves usefull elswhere
24255 !c1 (in Gcav, for example)
24257 (Rtail_distance(1)*Rtail_distance(1)) &
24258 + (Rtail_distance(2)*Rtail_distance(2)) &
24259 + (Rtail_distance(3)*Rtail_distance(3)))
24260 ! tail location and distance calculations
24262 d1 = dheadcat(1, 1, itypi, itypj)
24265 ! d2 = dhead(2, 1, itypi, itypj)
24267 ! location of polar head is computed by taking hydrophobic centre
24268 ! and moving by a d1 * dc_norm vector
24269 ! see unres publications for very informative images
24270 chead(k,1) = (c(k, i)+c(k,i+1))/2.0 + d1 * dc_norm(k, i)
24271 chead(k,2) = c(k, j)
24274 ! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
24275 ! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
24276 call to_box(chead(1,1),chead(2,1),chead(3,1))
24277 call to_box(chead(1,2),chead(2,2),chead(3,2))
24280 ! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
24281 ! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
24283 Rhead_distance(k) = boxshift(chead(k,2) - chead(k,1),locbox(k))
24286 ! pitagoras (root of sum of squares)
24288 (Rhead_distance(1)*Rhead_distance(1)) &
24289 + (Rhead_distance(2)*Rhead_distance(2)) &
24290 + (Rhead_distance(3)*Rhead_distance(3)))
24291 !-------------------------------------------------------------------
24292 ! zero everything that should be zero'ed
24310 dscj_inv = 0.0d0 ! vbld_inv(j+nres)
24311 ! print *,i,j,dscj_inv,dsci_inv
24312 ! rij holds 1/(distance of Calpha atoms)
24313 rrij = 1.0D0 / ( xj*xj + yj*yj + zj*zj)
24315 sss_ele_cut=sscale_ele(1.0d0/(rij))
24316 sss_ele_grad=sscagrad_ele(1.0d0/(rij))
24317 ! print *,sss_ele_cut,sss_ele_grad,&
24318 ! 1.0d0/(rij),r_cut_ele,rlamb_ele
24319 if (sss_ele_cut.le.0.0) cycle
24321 ! this should be in elgrad_init but om's are calculated by sc_angular
24322 ! which in turn is used by older potentials
24323 ! om = omega, sqom = om^2
24328 sqom12 = om12 * om12
24330 ! now we calculate EGB - Gey-Berne
24331 ! It will be summed up in evdwij and saved in evdw
24332 sigsq = 1.0D0 / sigsq
24333 sig = sig0ij * dsqrt(sigsq)
24334 ! rij_shift = 1.0D0 / rij - sig + sig0ij
24335 rij_shift = Rtail - sig + sig0ij
24336 IF (rij_shift.le.0.0D0) THEN
24338 ! if (evdw.gt.1.0d6) then
24339 ! write (*,'(2(1x,a3,i3),6f6.2)') &
24340 ! restyp(itype(i,1),1),i,restyp(itype(j,1),1),j,&
24341 ! 1.0d0/rij,Rtail,Rhead,rij_shift, sig, sig0ij
24342 !evdwij,Fcav,Ecl,Egb,Epol,Fisocav,Elj,&
24343 ! Equad,evdwij+Fcav+eheadtail,evdw
24347 sigder = -sig * sigsq
24348 rij_shift = 1.0D0 / rij_shift
24349 fac = rij_shift**expon
24350 c1 = fac * fac * aa_aq_cat(itypi,itypj)
24351 ! print *,"ADAM",aa_aq(itypi,itypj)
24354 c2 = fac * bb_aq_cat(itypi,itypj)
24356 evdwij = eps1 * eps2rt * eps3rt * ( c1 + c2 )
24357 eps2der = eps3rt * evdwij
24358 eps3der = eps2rt * evdwij
24359 ! evdwij = 4.0d0 * eps2rt * eps3rt * evdwij
24360 evdwij = eps2rt * eps3rt * evdwij
24362 ! IF (bb_aq(itypi,itypj).gt.0) THEN
24363 ! evdw_p = evdw_p + evdwij
24365 ! evdw_m = evdw_m + evdwij
24369 + evdwij*sss_ele_cut
24371 c1 = c1 * eps1 * eps2rt**2 * eps3rt**2
24372 fac = -expon * (c1 + evdwij) * rij_shift
24373 sigder = fac * sigder
24374 ! Calculate distance derivative
24375 gg(1) = fac*sss_ele_cut+evdwij*sss_ele_grad
24376 gg(2) = fac*sss_ele_cut+evdwij*sss_ele_grad
24377 gg(3) = fac*sss_ele_cut+evdwij*sss_ele_grad
24379 fac = chis1 * sqom1 + chis2 * sqom2 &
24380 - 2.0d0 * chis12 * om1 * om2 * om12
24382 pom = 1.0d0 - chis1 * chis2 * sqom12
24383 ! print *,"TUT2",fac,chis1,sqom1,pom
24384 Lambf = (1.0d0 - (fac / pom))
24385 Lambf = dsqrt(Lambf)
24386 sparrow = 1.0d0 / dsqrt(sig1**2.0d0 + sig2**2.0d0)
24387 Chif = Rtail * sparrow
24388 ChiLambf = Chif * Lambf
24389 eagle = dsqrt(ChiLambf)
24390 bat = ChiLambf ** 11.0d0
24391 top = b1cav * ( eagle + b2cav * ChiLambf - b3cav )
24392 bot = 1.0d0 + b4cav * (ChiLambf ** 12.0d0)
24396 dtop = b1cav * ((Lambf / (2.0d0 * eagle)) + (b2cav * Lambf))
24397 dbot = 12.0d0 * b4cav * bat * Lambf
24398 dFdR = ((dtop * bot - top * dbot) / botsq) * sparrow*sss_ele_cut+&
24400 Fcav=Fcav*sss_ele_cut
24401 dtop = b1cav * ((Chif / (2.0d0 * eagle)) + (b2cav * Chif))
24402 dbot = 12.0d0 * b4cav * bat * Chif
24403 eagle = Lambf * pom
24404 dFdOM1 = -(chis1 * om1 - chis12 * om2 * om12) / (eagle)
24406 dFdOM2 = -(chis2 * om2 - chis12 * om1 * om12) / (eagle)
24407 dFdOM12 = chis12 * (chis1 * om1 * om12 - om2) &
24408 * (chis2 * om2 * om12 - om1) / (eagle * pom)
24410 dFdL = ((dtop * bot - top * dbot) / botsq)
24411 dCAVdOM1 = dFdL * ( dFdOM1 )
24412 ! dCAVdOM2 = dFdL * ( dFdOM2 )
24413 ! dCAVdOM12 = dFdL * ( dFdOM12 )
24418 ertail(k) = Rtail_distance(k)/Rtail
24420 erdxi = scalar( ertail(1), dC_norm(1,i) )
24421 erdxj = scalar( ertail(1), dC_norm(1,j) )
24422 facd1 = dtailcat(1,itypi,itypj) * vbld_inv(i)
24423 facd2 = dtailcat(2,itypi,itypj) * vbld_inv(j+nres)
24425 pom = ertail(k)-facd1*(ertail(k)-erdxi*dC_norm(k,i))
24426 ! gradpepcatx(k,i) = gradpepcatx(k,i) &
24427 ! - (( dFdR + gg(k) ) * pom)
24428 pom = ertail(k)-facd2*(ertail(k)-erdxj*dC_norm(k,j+nres))
24429 ! gvdwx(k,j) = gvdwx(k,j) &
24430 ! + (( dFdR + gg(k) ) * pom)
24431 gradpepcat(k,i) = gradpepcat(k,i) &
24432 - (( dFdR + gg(k) ) * ertail(k))/2.0d0
24433 gradpepcat(k,i+1) = gradpepcat(k,i+1) &
24434 - (( dFdR + gg(k) ) * ertail(k))/2.0d0
24436 gradpepcat(k,j) = gradpepcat(k,j) &
24437 + (( dFdR + gg(k) ) * ertail(k))
24440 if (itype(j,5).gt.0) then
24441 !c! Compute head-head and head-tail energies for each state
24443 !c! Dipole-charge interactions
24444 CALL edq_cat_pep(ecl, elj, epol)
24445 eheadtail = ECL + elj + epol
24446 ! print *,"i,",i,eheadtail
24447 ! eheadtail = 0.0d0
24449 !HERE WATER and other types of molecules solvents will be added
24450 ! write(iout,*) "not yet implemented"
24451 CALL edd_cat_pep(ecl)
24456 evdw = evdw + Fcav + eheadtail
24457 ! if (evdw.gt.1.0d6) then
24458 ! write (*,'(2(1x,a3,i3),3f6.2,10f16.7)') &
24459 ! restyp(itype(i,1),1),i,restyp(itype(j,1),1),j,&
24460 ! 1.0d0/rij,Rtail,Rhead,evdwij,Fcav,Ecl,Egb,Epol,Fisocav,Elj,&
24461 ! Equad,evdwij+Fcav+eheadtail,evdw
24463 IF (energy_dec) write (iout,'(2(1x,a3,i3),3f6.2,10f16.7)') &
24464 restyp(itype(i,1),1),i,restyp(itype(j,1),1),j,&
24465 1.0d0/rij,Rtail,Rhead,evdwij,Fcav,Ecl,Egb,Epol,Fisocav,Elj,&
24466 Equad,evdwij+Fcav+eheadtail,evdw
24467 ! evdw = evdw + Fcav + eheadtail
24469 ! iF (nstate(itypi,itypj).eq.1) THEN
24470 CALL sc_grad_cat_pep
24472 !c!-------------------------------------------------------------------
24476 !c write (iout,*) "Number of loop steps in EGB:",ind
24477 !c energy_dec=.false.
24478 ! print *,"EVDW KURW",evdw,nres
24480 ! print *,"before leave sc_grad_cat", i,j, gradpepcat(1,nres-1)
24483 end subroutine ecats_prot_amber
24485 !---------------------------------------------------------------------------
24487 subroutine ecat_prot(ecation_prot)
24490 integer i,j,k,subchap,itmp,inum
24491 real(kind=8) :: xi,yi,zi,xj,yj,zj,ract,rcat0,epscalc,r06,r012,&
24493 real(kind=8) xj_temp,yj_temp,zj_temp,xj_safe,yj_safe,zj_safe, &
24494 dist_init,dist_temp,ecation_prot,rcal,rocal, &
24495 Evan1,Evan2,EC,cm1mag,DASGL,delta,r0p,Epepcat, &
24496 catl,cml,calpl, Etotal_p, Etotal_m,rtab,wdip,wmodquad,wquad1, &
24497 wquad2,wvan1,E1,E2,wconst,wvan2,rcpm,dcmag,sin2thet,sinthet, &
24498 costhet,v1m,v2m,wh2o,wc,rsecp,Ir,Irsecp,Irthrp,Irfourp,Irfiftp,&
24499 Irsistp,Irseven,Irtwelv,Irthir,dE1dr,dE2dr,dEdcos,wquad2p,opt, &
24500 rs,rthrp,rfourp,rsixp,reight,Irsixp,Ireight,Irtw,Irfourt, &
24501 opt1,opt2,opt3,opt4,opt5,opt6,opt7,opt8,opt9,opt10,opt11,opt12,&
24502 opt13,opt14,opt15,opt16,opt17,opt18,opt19, &
24503 Equad1,Equad2,dscmag,v1dpv2,dscmag3,constA,constB,Edip,&
24505 real(kind=8),dimension(3) ::dEvan1Cmcat,dEvan2Cmcat,dEeleccat,&
24506 gg,r,EtotalCat,dEtotalCm,dEtotalCalp,dEvan1Cm,dEvan2Cm, &
24507 dEtotalpep,dEtotalcat_num,dEddci,dEtotalcm_num,dEtotalcalp_num, &
24508 tab1,tab2,tab3,diff,cm1,sc,p,tcat,talp,cm,drcp,drcp_norm,vcat, &
24509 v1,v2,v3,myd_norm,dx,vcm,valpha,drdpep,dcosdpep,dcosddci,dEdpep,&
24510 dEcCat,dEdipCm,dEdipCalp,dEquad1Cat,dEquad1Cm,dEquad1Calp, &
24511 dEquad2Cat,dEquad2Cm,dEquad2Calpd,Evan1Cat,dEvan1Calp,dEvan2Cat,&
24512 dEvan2Calp,dEtotalCat,dscvec,dEcCm,dEcCalp,dEdipCat,dEquad2Calp,&
24514 real(kind=8),dimension(6) :: vcatprm
24516 ! first lets calculate interaction with peptide groups
24517 if (nres_molec(5).eq.0) return
24520 itmp=itmp+nres_molec(i)
24522 ! do i=1,nres_molec(1)-1 ! loop over all peptide groups needs parralelization
24523 do i=ibond_start,ibond_end
24526 if ((itype(i,1).eq.ntyp1).or.(itype(i+1,1).eq.ntyp1)) cycle ! leave dummy atoms
24527 xi=0.5d0*(c(1,i)+c(1,i+1))
24528 yi=0.5d0*(c(2,i)+c(2,i+1))
24529 zi=0.5d0*(c(3,i)+c(3,i+1))
24530 call to_box(xi,yi,zi)
24532 do j=itmp+1,itmp+nres_molec(5)
24533 ! print *,"WTF",itmp,j,i
24534 ! all parameters were for Ca2+ to approximate single charge divide by two
24536 if ((itype(j,5).eq.1).or.(itype(j,5).eq.3)) ndiv=2.0
24538 wdip =1.092777950857032D2
24540 wmodquad=-2.174122713004870D4
24541 wmodquad=wmodquad/wconst
24542 wquad1 = 3.901232068562804D1
24543 wquad1=wquad1/wconst
24545 wquad2=wquad2/wconst
24553 call to_box(xj,yj,zj)
24554 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
24557 rcpm = sqrt(xj**2+yj**2+zj**2)
24558 drcp_norm(1)=xj/rcpm
24559 drcp_norm(2)=yj/rcpm
24560 drcp_norm(3)=zj/rcpm
24563 dcmag=dcmag+dc(k,i)**2
24567 myd_norm(k)=dc(k,i)/dcmag
24569 costhet=drcp_norm(1)*myd_norm(1)+drcp_norm(2)*myd_norm(2)+&
24570 drcp_norm(3)*myd_norm(3)
24573 Irsecp = 1.0d0/rsecp
24574 Irthrp = Irsecp/rcpm
24575 Irfourp = Irthrp/rcpm
24576 Irfiftp = Irfourp/rcpm
24577 Irsistp=Irfiftp/rcpm
24578 Irseven=Irsistp/rcpm
24579 Irtwelv=Irsistp*Irsistp
24580 Irthir=Irtwelv/rcpm
24581 sin2thet = (1-costhet*costhet)
24582 sinthet=sqrt(sin2thet)
24583 E1 = wdip*Irsecp*costhet+(wmodquad*Irfourp+wquad1*Irthrp)&
24585 E2 = -wquad1*Irthrp*wquad2+wvan1*(wvan2**12*Irtwelv-&
24586 2*wvan2**6*Irsistp)
24587 ecation_prot = ecation_prot+E1+E2
24588 ! print *,"ecatprot",i,j,ecation_prot,rcpm
24589 dE1dr = -2*costhet*wdip*Irthrp-&
24590 (4*wmodquad*Irfiftp+3*wquad1*Irfourp)*sin2thet
24591 dE2dr = 3*wquad1*wquad2*Irfourp- &
24592 12*wvan1*wvan2**6*(wvan2**6*Irthir-Irseven)
24593 dEdcos = wdip*Irsecp-2*(wmodquad*Irfourp+wquad1*Irthrp)*costhet
24595 drdpep(k) = -drcp_norm(k)
24596 dcosdpep(k) = Ir*(costhet*drcp_norm(k)-myd_norm(k))
24597 dcosddci(k) = drcp_norm(k)/dcmag-costhet*myd_norm(k)/dcmag
24598 dEdpep(k) = (dE1dr+dE2dr)*drdpep(k)+dEdcos*dcosdpep(k)
24599 dEddci(k) = dEdcos*dcosddci(k)
24602 gradpepcat(k,i)=gradpepcat(k,i)+0.5D0*dEdpep(k)-dEddci(k)
24603 gradpepcat(k,i+1)=gradpepcat(k,i+1)+0.5D0*dEdpep(k)+dEddci(k)
24604 gradpepcat(k,j)=gradpepcat(k,j)-dEdpep(k)
24608 !------------------------------------------sidechains
24609 ! do i=1,nres_molec(1)
24610 do i=ibond_start,ibond_end
24611 if ((itype(i,1).eq.ntyp1)) cycle ! leave dummy atoms
24613 ! print *,i,ecation_prot
24617 call to_box(xi,yi,zi)
24619 cm1(k)=dc(k,i+nres)
24621 cm1mag=sqrt(cm1(1)**2+cm1(2)**2+cm1(3)**2)
24622 do j=itmp+1,itmp+nres_molec(5)
24624 if ((itype(j,5).eq.1).or.(itype(j,5).eq.3)) ndiv=2.0
24629 call to_box(xj,yj,zj)
24630 dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
24634 if((itype(i,1).eq.15.or.itype(i,1).eq.16).or.&
24635 ((itype(i,1).eq.27).or.(itype(i,1).eq.26).or.&
24636 (itype(i,1).eq.25))) then
24637 if(itype(i,1).eq.16) then
24643 vcatprm(k)=catprm(k,inum)
24645 dASGL=catprm(7,inum)
24647 ! vcm(k)=(cm1(k)/cm1mag)*dASGL+c(k,i+nres)
24648 vcm(1)=(cm1(1)/cm1mag)*dASGL+xi
24649 vcm(2)=(cm1(2)/cm1mag)*dASGL+yi
24650 vcm(3)=(cm1(3)/cm1mag)*dASGL+zi
24654 if (subchap.eq.1) then
24663 valpha(1)=xi-c(1,i+nres)+c(1,i)
24664 valpha(2)=yi-c(2,i+nres)+c(2,i)
24665 valpha(3)=zi-c(3,i+nres)+c(3,i)
24669 dx(k) = vcat(k)-vcm(k)
24672 v1(k)=(vcm(k)-valpha(k))
24673 v2(k)=(vcat(k)-valpha(k))
24675 v1m = sqrt(v1(1)**2+v1(2)**2+v1(3)**2)
24676 v2m = sqrt(v2(1)**2+v2(2)**2+v2(3)**2)
24677 v1dpv2 = v1(1)*v2(1)+v1(2)*v2(2)+v1(3)*v2(3)
24679 ! The weights of the energy function calculated from
24680 !The quantum mechanical GAMESS simulations of calcium with ASP/GLU
24681 if ((itype(i,1).eq.27).or.(itype(i,1).eq.26).or.(itype(i,1).eq.25)) then
24687 if ((itype(j,5).eq.1).or.(itype(j,5).eq.3)) ndiv=2.0
24696 wquad2 = vcatprm(4)
24698 wquad2p = 1.0d0-wquad2
24701 opt = dx(1)**2+dx(2)**2
24702 rsecp = opt+dx(3)**2
24706 rsixp = rfourp*rsecp
24709 Irsecp = 1.0d0/rsecp
24711 Irfourp = Irthrp/rs
24712 Irsixp = 1.0d0/rsixp
24713 Ireight=1.0d0/reight
24717 opt1 = (4*rs*dx(3)*wdip)
24718 opt2 = 6*rsecp*wquad1*opt
24719 opt3 = wquad1*wquad2p*Irsixp
24720 opt4 = (wvan1*wvan2**12)
24721 opt5 = opt4*12*Irfourt
24722 opt6 = 2*wvan1*wvan2**6
24723 opt7 = 6*opt6*Ireight
24726 opt11 = (rsecp*v2m)**2
24727 opt12 = (rsecp*v1m)**2
24728 opt14 = (v1m*v2m*rsecp)**2
24729 opt15 = -wquad1/v2m**2
24730 opt16 = (rthrp*(v1m*v2m)**2)**2
24731 opt17 = (v1m**2*rthrp)**2
24732 opt18 = -wquad1/rthrp
24733 opt19 = (v1m**2*v2m**2)**2
24736 dEcCat(k) = -(dx(k)*wc)*Irthrp
24737 dEcCm(k)=(dx(k)*wc)*Irthrp
24740 Edip=opt8*(v1dpv2)/(rsecp*v2m)
24742 dEdipCat(k)=opt8*(v1(k)*rsecp*v2m-((v2(k)/v2m &
24743 *rsecp+2*dx(k)*v2m)*v1dpv2))/opt11
24744 dEdipCm(k)=opt10*(v2(k)*rsecp*v1m-((v1(k)/v1m &
24745 *rsecp-2*dx(k)*v1m)*v1dpv2))/opt12
24746 dEdipCalp(k)=wdip*((-v1(k)-v2(k))*rsecp*v1m &
24747 *v2m-(-v1(k)/v1m*v2m*rsecp-v2(k)/v2m*v1m*rsecp) &
24750 Equad1=-wquad1*v1dpv2**2/(rthrp*(v1m*v2m)**2)
24752 dEquad1Cat(k)=-wquad1*(2*v1(k)*v1dpv2*(rthrp* &
24753 (v1m*v2m)**2)-(3*dx(k)*rs*(v1m*v2m)**2+2*v1m*2* &
24754 v2(k)*1/2*1/v2m*v1m*v2m*rthrp)*v1dpv2**2)/opt16
24755 dEquad1Cm(k)=-wquad1*(2*v2(k)*v1dpv2*(rthrp* &
24756 (v1m*v2m)**2)-(-3*dx(k)*rs*(v1m*v2m)**2+2*v2m*2* &
24757 v1(k)*1/2*1/v1m*v2m*v1m*rthrp)*v1dpv2**2)/opt16
24758 dEquad1Calp(k)=opt18*(2*(-v1(k)-v2(k))*v1dpv2* &
24759 v1m**2*v2m**2-(-2*v1(k)*v2m**2-2*v2(k)*v1m**2)* &
24762 Equad2=wquad1*wquad2p*Irthrp
24764 dEquad2Cat(k)=-3*dx(k)*rs*opt3
24765 dEquad2Cm(k)=3*dx(k)*rs*opt3
24766 dEquad2Calp(k)=0.0d0
24770 dEvan1Cat(k)=-dx(k)*opt5
24771 dEvan1Cm(k)=dx(k)*opt5
24772 dEvan1Calp(k)=0.0d0
24776 dEvan2Cat(k)=dx(k)*opt7
24777 dEvan2Cm(k)=-dx(k)*opt7
24778 dEvan2Calp(k)=0.0d0
24780 ecation_prot=ecation_prot+Ec+Edip+Equad1+Equad2+Evan1+Evan2
24781 ! print *,ecation_prot,Ec+Edip+Equad1+Equad2+Evan1+Evan2
24784 dEtotalCat(k)=dEcCat(k)+dEdipCat(k)+dEquad1Cat(k)+ &
24785 dEquad2Cat(k)+dEvan1Cat(k)+dEvan2Cat(k)
24786 !c write(*,*) 'dEtotalCat inside', (dEtotalCat(l),l=1,3)
24787 dEtotalCm(k)=dEcCm(k)+dEdipCm(k)+dEquad1Cm(k)+ &
24788 dEquad2Cm(k)+dEvan1Cm(k)+dEvan2Cm(k)
24789 dEtotalCalp(k)=dEcCalp(k)+dEdipCalp(k)+dEquad1Calp(k) &
24790 +dEquad2Calp(k)+dEvan1Calp(k)+dEvan2Calp(k)
24794 dscvec(k) = dc(k,i+nres)
24795 dscmag = dscmag+dscvec(k)*dscvec(k)
24798 dscmag = sqrt(dscmag)
24799 dscmag3 = dscmag3*dscmag
24800 constA = 1.0d0+dASGL/dscmag
24803 constB = constB+dscvec(k)*dEtotalCm(k)
24805 constB = constB*dASGL/dscmag3
24807 gg(k) = dEtotalCm(k)+dEtotalCalp(k)
24808 gradpepcatx(k,i)=gradpepcatx(k,i)+ &
24809 constA*dEtotalCm(k)-constB*dscvec(k)
24810 ! print *,j,constA,dEtotalCm(k),constB,dscvec(k)
24811 gradpepcat(k,i)=gradpepcat(k,i)+gg(k)
24812 gradpepcat(k,j)=gradpepcat(k,j)+dEtotalCat(k)
24814 else if (itype(i,1).eq.13.or.itype(i,1).eq.14) then
24815 if(itype(i,1).eq.14) then
24821 vcatprm(k)=catprm(k,inum)
24823 dASGL=catprm(7,inum)
24825 ! vcm(k)=(cm1(k)/cm1mag)*dASGL+c(k,i+nres)
24829 vcm(1)=(cm1(1)/cm1mag)*dASGL+xi
24830 vcm(2)=(cm1(2)/cm1mag)*dASGL+yi
24831 vcm(3)=(cm1(3)/cm1mag)*dASGL+zi
24832 if (subchap.eq.1) then
24841 valpha(1)=xi-c(1,i+nres)+c(1,i)
24842 valpha(2)=yi-c(2,i+nres)+c(2,i)
24843 valpha(3)=zi-c(3,i+nres)+c(3,i)
24847 dx(k) = vcat(k)-vcm(k)
24850 v1(k)=(vcm(k)-valpha(k))
24851 v2(k)=(vcat(k)-valpha(k))
24853 v1m = sqrt(v1(1)**2+v1(2)**2+v1(3)**2)
24854 v2m = sqrt(v2(1)**2+v2(2)**2+v2(3)**2)
24855 v1dpv2 = v1(1)*v2(1)+v1(2)*v2(2)+v1(3)*v2(3)
24856 ! The weights of the energy function calculated from
24857 !The quantum mechanical GAMESS simulations of ASN/GLN with calcium
24859 if ((itype(j,5).eq.1).or.(itype(j,5).eq.3)) ndiv=2.0
24866 wquad2 = vcatprm(4)
24871 opt = dx(1)**2+dx(2)**2
24872 rsecp = opt+dx(3)**2
24876 rsixp = rfourp*rsecp
24881 Irfourp = Irthrp/rs
24887 opt1 = (4*rs*dx(3)*wdip)
24888 opt2 = 6*rsecp*wquad1*opt
24889 opt3 = wquad1*wquad2p*Irsixp
24890 opt4 = (wvan1*wvan2**12)
24891 opt5 = opt4*12*Irfourt
24892 opt6 = 2*wvan1*wvan2**6
24893 opt7 = 6*opt6*Ireight
24896 opt11 = (rsecp*v2m)**2
24897 opt12 = (rsecp*v1m)**2
24898 opt14 = (v1m*v2m*rsecp)**2
24899 opt15 = -wquad1/v2m**2
24900 opt16 = (rthrp*(v1m*v2m)**2)**2
24901 opt17 = (v1m**2*rthrp)**2
24902 opt18 = -wquad1/rthrp
24903 opt19 = (v1m**2*v2m**2)**2
24904 Edip=opt8*(v1dpv2)/(rsecp*v2m)
24906 dEdipCat(k)=opt8*(v1(k)*rsecp*v2m-((v2(k)/v2m&
24907 *rsecp+2*dx(k)*v2m)*v1dpv2))/opt11
24908 dEdipCm(k)=opt10*(v2(k)*rsecp*v1m-((v1(k)/v1m&
24909 *rsecp-2*dx(k)*v1m)*v1dpv2))/opt12
24910 dEdipCalp(k)=wdip*((-v1(k)-v2(k))*rsecp*v1m&
24911 *v2m-(-v1(k)/v1m*v2m*rsecp-v2(k)/v2m*v1m*rsecp)&
24914 Equad1=-wquad1*v1dpv2**2/(rthrp*(v1m*v2m)**2)
24916 dEquad1Cat(k)=-wquad1*(2*v1(k)*v1dpv2*(rthrp*&
24917 (v1m*v2m)**2)-(3*dx(k)*rs*(v1m*v2m)**2+2*v1m*2*&
24918 v2(k)*1/2*1/v2m*v1m*v2m*rthrp)*v1dpv2**2)/opt16
24919 dEquad1Cm(k)=-wquad1*(2*v2(k)*v1dpv2*(rthrp*&
24920 (v1m*v2m)**2)-(-3*dx(k)*rs*(v1m*v2m)**2+2*v2m*2*&
24921 v1(k)*1/2*1/v1m*v2m*v1m*rthrp)*v1dpv2**2)/opt16
24922 dEquad1Calp(k)=opt18*(2*(-v1(k)-v2(k))*v1dpv2* &
24923 v1m**2*v2m**2-(-2*v1(k)*v2m**2-2*v2(k)*v1m**2)*&
24926 Equad2=wquad1*wquad2p*Irthrp
24928 dEquad2Cat(k)=-3*dx(k)*rs*opt3
24929 dEquad2Cm(k)=3*dx(k)*rs*opt3
24930 dEquad2Calp(k)=0.0d0
24934 dEvan1Cat(k)=-dx(k)*opt5
24935 dEvan1Cm(k)=dx(k)*opt5
24936 dEvan1Calp(k)=0.0d0
24940 dEvan2Cat(k)=dx(k)*opt7
24941 dEvan2Cm(k)=-dx(k)*opt7
24942 dEvan2Calp(k)=0.0d0
24944 ecation_prot = ecation_prot+Edip+Equad1+Equad2+Evan1+Evan2
24946 dEtotalCat(k)=dEdipCat(k)+dEquad1Cat(k)+ &
24947 dEquad2Cat(k)+dEvan1Cat(k)+dEvan2Cat(k)
24948 dEtotalCm(k)=dEdipCm(k)+dEquad1Cm(k)+ &
24949 dEquad2Cm(k)+dEvan1Cm(k)+dEvan2Cm(k)
24950 dEtotalCalp(k)=dEdipCalp(k)+dEquad1Calp(k) &
24951 +dEquad2Calp(k)+dEvan1Calp(k)+dEvan2Calp(k)
24955 dscvec(k) = c(k,i+nres)-c(k,i)
24961 dscmag = dscmag+dscvec(k)*dscvec(k)
24964 dscmag = sqrt(dscmag)
24965 dscmag3 = dscmag3*dscmag
24966 constA = 1+dASGL/dscmag
24969 constB = constB+dscvec(k)*dEtotalCm(k)
24971 constB = constB*dASGL/dscmag3
24973 gg(k) = dEtotalCm(k)+dEtotalCalp(k)
24974 gradpepcatx(k,i)=gradpepcatx(k,i)+ &
24975 constA*dEtotalCm(k)-constB*dscvec(k)
24976 gradpepcat(k,i)=gradpepcat(k,i)+gg(k)
24977 gradpepcat(k,j)=gradpepcat(k,j)+dEtotalCat(k)
24982 ! r(k) = c(k,j)-c(k,i+nres)
24986 rcal = rcal+r(k)*r(k)
24991 r0p=0.5*(rocal+sig0(itype(i,1)))
24994 Evan1=epscalc*(r012/rcal**6)
24995 Evan2=epscalc*2*(r06/rcal**3)
24999 dEvan1Cm(k) = 12*r(k)*epscalc*r012/r7
25000 dEvan2Cm(k) = 12*r(k)*epscalc*r06/r4
25003 dEtotalCm(k)=dEvan1Cm(k)+dEvan2Cm(k)
25005 ecation_prot = ecation_prot+ Evan1+Evan2
25007 gradpepcatx(k,i)=gradpepcatx(k,i)+ &
25009 gradpepcat(k,i)=gradpepcat(k,i)+dEtotalCm(k)
25010 gradpepcat(k,j)=gradpepcat(k,j)-dEtotalCm(k)
25012 endif ! 13-16 residues
25016 end subroutine ecat_prot
25018 !----------------------------------------------------------------------------
25019 !---------------------------------------------------------------------------
25020 subroutine ecat_nucl(ecation_nucl)
25021 integer i,j,k,subchap,itmp,inum,itypi,itypj
25022 real(kind=8) :: xi,yi,zi,xj,yj,zj
25023 real(kind=8) xj_temp,yj_temp,zj_temp,xj_safe,yj_safe,zj_safe, &
25024 dist_init,dist_temp,ecation_nucl,Evan1,Evan2,Ecav,Egb,wdip1,wdip2, &
25025 wvan1,wvan2,wgbsig,wgbeps,wgbchi,wgbchip,wcav1,wcav2,wcav3,wcav4, &
25026 wcavsig,wcavchi,v1m,v1dpdx,wh2o,wc,Edip,rcs2,invrcs6,invrcs8,invrcs12, &
25027 invrcs14,rcb,rcb2,invrcb,invrcb2,invrcb4,invrcb6,cosinus,cos2,dcosdcatconst, &
25028 dcosdcalpconst,dcosdcmconst,rcav,rcav11,rcav12,constcav1,constcav2, &
25029 constgb1,constgb2,constdvan1,constdvan2,sgb,sgb6,sgb7,sgb12,sgb13, &
25030 cavnum,cavdenom,invcavdenom2,dcavnumdcos,dcavnumdr,dcavdenomdcos, &
25031 dcavdenomdr,sslipi,ssgradlipi,sslipj,ssgradlipj,aa,bb
25032 real(kind=8),dimension(3) ::gg,r,dEtotalCm,dEtotalCalp,dEvan1Cm,&
25033 dEvan2Cm,cm1,cm,vcat,vsug,v1,v2,dx,vcm,dEdipCm,dEdipCalp, &
25034 dEvan1Calp,dEvan2Cat,dEvan2Calp,dEtotalCat,dEdipCat,dEvan1Cat,dcosdcat, &
25035 dcosdcalp,dcosdcm,dEgbdCat,dEgbdCalp,dEgbdCm,dEcavdCat,dEcavdCalp, &
25037 real(kind=8),dimension(14) :: vcatnuclprm
25043 if (nres_molec(5).eq.0) return
25046 itmp=itmp+nres_molec(i)
25048 ! print *,nres_molec(2),"nres2"
25049 do i=ibond_nucl_start,ibond_nucl_end
25050 ! do i=iatsc_s_nucl,iatsc_e_nucl
25051 if ((itype(i,2).eq.ntyp1_molec(2))) cycle ! leave dummy atoms
25055 call to_box(xi,yi,zi)
25056 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
25058 cm1(k)=dc(k,i+nres)
25060 do j=itmp+1,itmp+nres_molec(5)
25064 call to_box(xj,yj,zj)
25066 ! write(iout,*) "xi,yi,zi,xj,yj,zj", xi,yi,zi,xj,yj,zj
25067 ! call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
25068 ! aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
25069 ! +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
25070 ! bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
25071 ! +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
25072 xj=boxshift(xj-xi,boxxsize)
25073 yj=boxshift(yj-yi,boxysize)
25074 zj=boxshift(zj-zi,boxzsize)
25075 ! write(iout,*) 'after shift', xj,yj,zj
25076 dist_init=xj**2+yj**2+zj**2
25081 vcatnuclprm(k)=catnuclprm(k,itypi,itypj)
25088 call to_box(vcm(1),vcm(2),vcm(3))
25089 call to_box(vsug(1),vsug(2),vsug(3))
25090 call to_box(vcat(1),vcat(2),vcat(3))
25092 ! dx(k) = vcat(k)-vcm(k)
25094 dx(k)=boxshift(vcat(k)-vcm(k),boxik(k))
25097 v2(k)=boxshift(vcat(k)-vsug(k),boxik(k))
25099 v1m = sqrt(v1(1)**2+v1(2)**2+v1(3)**2)
25100 v1dpdx = v1(1)*dx(1)+v1(2)*dx(2)+v1(3)*dx(3)
25101 ! The weights of the energy function calculated from
25102 !The quantum mechanical Gaussian simulations of potassium and sodium with deoxynucleosides
25104 wdip1 = vcatnuclprm(1)
25105 wdip1 = wdip1/wh2o !w1
25106 wdip2 = vcatnuclprm(2)
25107 wdip2 = wdip2/wh2o !w2
25108 wvan1 = vcatnuclprm(3)
25109 wvan2 = vcatnuclprm(4) !pis1
25110 wgbsig = vcatnuclprm(5) !sigma0
25111 wgbeps = vcatnuclprm(6) !epsi0
25112 wgbchi = vcatnuclprm(7) !chi1
25113 wgbchip = vcatnuclprm(8) !chip1
25114 wcavsig = vcatnuclprm(9) !sig
25115 wcav1 = vcatnuclprm(10) !b1
25116 wcav2 = vcatnuclprm(11) !b2
25117 wcav3 = vcatnuclprm(12) !b3
25118 wcav4 = vcatnuclprm(13) !b4
25119 wcavchi = vcatnuclprm(14) !chis1
25120 rcs2 = v2(1)**2+v2(2)**2+v2(3)**2
25121 invrcs6 = 1/rcs2**3
25122 invrcs8 = invrcs6/rcs2
25123 invrcs12 = invrcs6**2
25124 invrcs14 = invrcs12/rcs2
25125 rcb2 = dx(1)**2+dx(2)**2+dx(3)**2
25128 invrcb2 = invrcb**2
25129 invrcb4 = invrcb2**2
25130 invrcb6 = invrcb4*invrcb2
25131 cosinus = v1dpdx/(v1m*rcb)
25133 dcosdcatconst = invrcb2/v1m
25134 dcosdcalpconst = invrcb/v1m**2
25135 dcosdcmconst = invrcb2/v1m**2
25137 dcosdcat(k) = (v1(k)*rcb-dx(k)*v1m*cosinus)*dcosdcatconst
25138 dcosdcalp(k) = (v1(k)*rcb*cosinus-dx(k)*v1m)*dcosdcalpconst
25139 dcosdcm(k) = ((dx(k)-v1(k))*v1m*rcb+ &
25140 cosinus*(dx(k)*v1m**2-v1(k)*rcb2))*dcosdcmconst
25144 rcav12 = rcav11*rcav
25145 constcav1 = 1-wcavchi*cos2
25146 constcav2 = sqrt(constcav1)
25147 constgb1 = 1/sqrt(1-wgbchi*cos2)
25148 constgb2 = wgbeps*(1-wgbchip*cos2)**2
25149 constdvan1 = 12*wvan1*wvan2**12*invrcs14
25150 constdvan2 = 6*wvan1*wvan2**6*invrcs8
25151 !----------------------------------------------------------------------------
25153 !---------------------------------------------------------------------------
25154 sgb = 1/(1-constgb1+(rcb/wgbsig))
25159 Egb = constgb2*(sgb12-sgb6)
25161 dEgbdCat(k) = -constgb2/wgbsig*(12*sgb13-6*sgb7)*invrcb*dx(k) &
25162 +(constgb1**3*constgb2*wgbchi*cosinus*(12*sgb13-6*sgb7) &
25163 -4*wgbeps*wgbchip*cosinus*(1-wgbchip*cos2)*(sgb12-sgb6))*dcosdcat(k)
25164 dEgbdCm(k) = constgb2/wgbsig*(12*sgb13-6*sgb7)*invrcb*dx(k) &
25165 +(constgb1**3*constgb2*wgbchi*cosinus*(12*sgb13-6*sgb7) &
25166 -4*wgbeps*wgbchip*cosinus*(1-wgbchip*cos2)*(sgb12-sgb6))*dcosdcm(k)
25167 dEgbdCalp(k) = (constgb1**3*constgb2*wgbchi*cosinus &
25168 *(12*sgb13-6*sgb7) &
25169 -4*wgbeps*wgbchip*cosinus*(1-wgbchip*cos2)*(sgb12-sgb6))*dcosdcalp(k)
25171 !----------------------------------------------------------------------------
25173 !---------------------------------------------------------------------------
25174 cavnum = sqrt(rcav*constcav2)+wcav2*rcav*constcav2-wcav3
25175 cavdenom = 1+wcav4*rcav12*constcav1**6
25176 Ecav = wcav1*cavnum/cavdenom
25177 invcavdenom2 = 1/cavdenom**2
25178 dcavnumdcos = -wcavchi*cosinus/constcav2 &
25179 *(sqrt(rcav/constcav2)/2+wcav2*rcav)
25180 dcavnumdr = (0.5*sqrt(constcav2/rcav)+wcav2*constcav2)/wcavsig
25181 dcavdenomdcos = -12*wcav4*wcavchi*rcav12*constcav1**5*cosinus
25182 dcavdenomdr = 12*wcav4/wcavsig*rcav11*constcav1**6
25184 dEcavdCat(k) = ((dcavnumdcos*cavdenom-dcavdenomdcos*cavnum) &
25185 *dcosdcat(k)+(dcavnumdr*cavdenom-dcavdenomdr*cavnum)/rcb*dx(k))*wcav1*invcavdenom2
25186 dEcavdCm(k) = ((dcavnumdcos*cavdenom-dcavdenomdcos*cavnum) &
25187 *dcosdcm(k)-(dcavnumdr*cavdenom-dcavdenomdr*cavnum)/rcb*dx(k))*wcav1*invcavdenom2
25188 dEcavdCalp(k) = (dcavnumdcos*cavdenom-dcavdenomdcos*cavnum) &
25189 *dcosdcalp(k)*wcav1*invcavdenom2
25191 !----------------------------------------------------------------------------
25192 !van der Waals and dipole-charge interaction energy
25193 !---------------------------------------------------------------------------
25194 Evan1 = wvan1*wvan2**12*invrcs12
25196 dEvan1Cat(k) = -v2(k)*constdvan1
25197 dEvan1Cm(k) = 0.0d0
25198 dEvan1Calp(k) = v2(k)*constdvan1
25200 Evan2 = -wvan1*wvan2**6*invrcs6
25202 dEvan2Cat(k) = v2(k)*constdvan2
25203 dEvan2Cm(k) = 0.0d0
25204 dEvan2Calp(k) = -v2(k)*constdvan2
25206 Edip = wdip1*cosinus*invrcb2-wdip2*(1-cos2)*invrcb4
25208 dEdipCat(k) = (-2*wdip1*cosinus*invrcb4 &
25209 +4*wdip2*(1-cos2)*invrcb6)*dx(k) &
25210 +dcosdcat(k)*(wdip1*invrcb2+2*wdip2*cosinus*invrcb4)
25211 dEdipCm(k) = (2*wdip1*cosinus*invrcb4 &
25212 -4*wdip2*(1-cos2)*invrcb6)*dx(k) &
25213 +dcosdcm(k)*(wdip1*invrcb2+2*wdip2*cosinus*invrcb4)
25214 dEdipCalp(k) = dcosdcalp(k)*(wdip1*invrcb2 &
25215 +2*wdip2*cosinus*invrcb4)
25217 if (energy_dec) write (iout,'(2i5,4(a6,f7.3))') i,j, &
25218 ' E GB ',Egb,' ECav ',Ecav,' Evdw ',Evan1+Evan2,' Edip ',Edip
25219 ecation_nucl=ecation_nucl+Ecav+Egb+Edip+Evan1+Evan2
25221 dEtotalCat(k) = dEcavdCat(k)+dEvan1Cat(k)+dEvan2Cat(k) &
25222 +dEgbdCat(k)+dEdipCat(k)
25223 dEtotalCm(k) = dEcavdCm(k)+dEvan1Cm(k)+dEvan2Cm(k) &
25224 +dEgbdCm(k)+dEdipCm(k)
25225 dEtotalCalp(k) = dEcavdCalp(k)+dEgbdCalp(k)+dEvan1Calp(k) &
25226 +dEdipCalp(k)+dEvan2Calp(k)
25229 gg(k) = dEtotalCm(k)+dEtotalCalp(k)
25230 gradnuclcatx(k,i)=gradnuclcatx(k,i)+dEtotalCm(k)
25231 gradnuclcat(k,i)=gradnuclcat(k,i)+gg(k)
25232 gradnuclcat(k,j)=gradnuclcat(k,j)+dEtotalCat(k)
25237 end subroutine ecat_nucl
25239 !-----------------------------------------------------------------------------
25240 !-----------------------------------------------------------------------------
25241 subroutine eprot_sc_base(escbase)
25243 ! implicit real(kind=8) (a-h,o-z)
25244 ! include 'DIMENSIONS'
25245 ! include 'COMMON.GEO'
25246 ! include 'COMMON.VAR'
25247 ! include 'COMMON.LOCAL'
25248 ! include 'COMMON.CHAIN'
25249 ! include 'COMMON.DERIV'
25250 ! include 'COMMON.NAMES'
25251 ! include 'COMMON.INTERACT'
25252 ! include 'COMMON.IOUNITS'
25253 ! include 'COMMON.CALC'
25254 ! include 'COMMON.CONTROL'
25255 ! include 'COMMON.SBRIDGE'
25257 !el local variables
25258 integer :: iint,itypi,itypi1,itypj,subchap
25259 real(kind=8) :: rrij,xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
25260 real(kind=8) :: evdw,sig0ij
25261 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
25262 dist_temp, dist_init,aa,bb,ssgradlipi,ssgradlipj, &
25263 sslipi,sslipj,faclip
25265 real(kind=8) :: fracinbuf
25266 real (kind=8) :: escbase
25267 real (kind=8),dimension(4):: ener
25268 real(kind=8) :: b1,b2,b3,b4,egb,eps_in,eps_inout_fac,eps_out
25269 real(kind=8) :: ECL,Elj,Equad,Epol,eheadtail,rhead,dGCLOM2,&
25270 sqom1,sqom2,sqom12,c1,c2,c3,pom,Lambf,sparrow,&
25271 Chif,ChiLambf,bat,eagle,top,bot,botsq,Fcav,dtop,dFdR,dFdOM1,&
25272 dFdOM2,w1,w2,w3,dGCLdR,dFdL,dFdOM12,dbot ,&
25273 r1,eps_head,alphapol1,pis,facd2,d2,facd1,d1,erdxj,erdxi,federmaus,&
25274 dPOLdR1,dFGBdOM2,dFGBdR1,dPOLdFGB1,RR1,MomoFac1,hawk,d1i,d1j,&
25275 sig1,sig2,chis12,chis2,ee1,fgb1,a12sq,chis1
25276 real(kind=8),dimension(3,2)::chead,erhead_tail
25277 real(kind=8),dimension(3) :: Rhead_distance,ertail,erhead
25281 ! do i=1,nres_molec(1)
25282 do i=ibond_start,ibond_end
25283 if (itype(i,1).eq.ntyp1_molec(1)) cycle
25285 dxi = dc_norm(1,nres+i)
25286 dyi = dc_norm(2,nres+i)
25287 dzi = dc_norm(3,nres+i)
25288 dsci_inv = vbld_inv(i+nres)
25292 call to_box(xi,yi,zi)
25293 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
25294 do j=nres_molec(1)+1,nres_molec(2)+nres_molec(1)
25296 if (itype(j,2).eq.ntyp1_molec(2))cycle
25300 call to_box(xj,yj,zj)
25301 ! call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
25302 ! aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
25303 ! +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
25304 ! bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
25305 ! +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
25306 xj=boxshift(xj-xi,boxxsize)
25307 yj=boxshift(yj-yi,boxysize)
25308 zj=boxshift(zj-zi,boxzsize)
25310 dxj = dc_norm( 1, nres+j )
25311 dyj = dc_norm( 2, nres+j )
25312 dzj = dc_norm( 3, nres+j )
25313 ! print *,i,j,itypi,itypj
25314 d1i = dhead_scbasei(itypi,itypj) !this is shift of dipole/charge
25315 d1j = dhead_scbasej(itypi,itypj) !this is shift of dipole/charge
25318 ! BetaT = 1.0d0 / (298.0d0 * Rb)
25320 sig0ij = sigma_scbase( itypi,itypj )
25321 if (sig0ij.lt.0.2) print *,"KURWA",sig0ij,itypi,itypj
25322 chi1 = chi_scbase( itypi, itypj,1 )
25323 chi2 = chi_scbase( itypi, itypj,2 )
25326 chi12 = chi1 * chi2
25327 chip1 = chipp_scbase( itypi, itypj,1 )
25328 chip2 = chipp_scbase( itypi, itypj,2 )
25331 chip12 = chip1 * chip2
25332 ! not used by momo potential, but needed by sc_angular which is shared
25333 ! by all energy_potential subroutines
25337 a12sq = rborn_scbasei(itypi,itypj) * rborn_scbasej(itypi,itypj)
25338 ! a12sq = a12sq * a12sq
25339 ! charge of amino acid itypi is...
25340 chis1 = chis_scbase(itypi,itypj,1)
25341 chis2 = chis_scbase(itypi,itypj,2)
25342 chis12 = chis1 * chis2
25343 sig1 = sigmap1_scbase(itypi,itypj)
25344 sig2 = sigmap2_scbase(itypi,itypj)
25345 ! write (*,*) "sig1 = ", sig1
25346 ! write (*,*) "sig2 = ", sig2
25347 ! alpha factors from Fcav/Gcav
25348 b1 = alphasur_scbase(1,itypi,itypj)
25350 b2 = alphasur_scbase(2,itypi,itypj)
25351 b3 = alphasur_scbase(3,itypi,itypj)
25352 b4 = alphasur_scbase(4,itypi,itypj)
25353 ! used to determine whether we want to do quadrupole calculations
25355 eps_in = epsintab_scbase(itypi,itypj)
25356 if (eps_in.eq.0.0) eps_in=1.0
25357 eps_inout_fac = ( (1.0d0/eps_in) - (1.0d0/eps_out))
25358 ! write (*,*) "eps_inout_fac = ", eps_inout_fac
25359 !-------------------------------------------------------------------
25360 ! tail location and distance calculations
25362 ! location of polar head is computed by taking hydrophobic centre
25363 ! and moving by a d1 * dc_norm vector
25364 ! see unres publications for very informative images
25365 chead(k,1) = c(k, i+nres) + d1i * dc_norm(k, i+nres)
25366 chead(k,2) = c(k, j+nres) + d1j * dc_norm(k, j+nres)
25368 ! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
25369 ! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
25370 Rhead_distance(k) = chead(k,2) - chead(k,1)
25372 ! pitagoras (root of sum of squares)
25374 (Rhead_distance(1)*Rhead_distance(1)) &
25375 + (Rhead_distance(2)*Rhead_distance(2)) &
25376 + (Rhead_distance(3)*Rhead_distance(3)))
25377 !-------------------------------------------------------------------
25378 ! zero everything that should be zero'ed
25396 dscj_inv = vbld_inv(j+nres)
25397 ! print *,i,j,dscj_inv,dsci_inv
25398 ! rij holds 1/(distance of Calpha atoms)
25399 rrij = 1.0D0 / ( xj*xj + yj*yj + zj*zj)
25401 !----------------------------
25403 ! this should be in elgrad_init but om's are calculated by sc_angular
25404 ! which in turn is used by older potentials
25405 ! om = omega, sqom = om^2
25408 sqom12 = om12 * om12
25410 ! now we calculate EGB - Gey-Berne
25411 ! It will be summed up in evdwij and saved in evdw
25412 sigsq = 1.0D0 / sigsq
25413 sig = sig0ij * dsqrt(sigsq)
25414 ! rij_shift = 1.0D0 / rij - sig + sig0ij
25415 rij_shift = 1.0/rij - sig + sig0ij
25416 IF (rij_shift.le.0.0D0) THEN
25420 sigder = -sig * sigsq
25421 rij_shift = 1.0D0 / rij_shift
25422 fac = rij_shift**expon
25423 c1 = fac * fac * aa_scbase(itypi,itypj)
25425 c2 = fac * bb_scbase(itypi,itypj)
25427 evdwij = eps1 * eps2rt * eps3rt * ( c1 + c2 )
25428 eps2der = eps3rt * evdwij
25429 eps3der = eps2rt * evdwij
25430 ! evdwij = 4.0d0 * eps2rt * eps3rt * evdwij
25431 evdwij = eps2rt * eps3rt * evdwij
25432 c1 = c1 * eps1 * eps2rt**2 * eps3rt**2
25433 fac = -expon * (c1 + evdwij) * rij_shift
25434 sigder = fac * sigder
25436 ! Calculate distance derivative
25440 ! if (b2.gt.0.0) then
25441 fac = chis1 * sqom1 + chis2 * sqom2 &
25442 - 2.0d0 * chis12 * om1 * om2 * om12
25443 ! we will use pom later in Gcav, so dont mess with it!
25444 pom = 1.0d0 - chis1 * chis2 * sqom12
25445 Lambf = (1.0d0 - (fac / pom))
25446 Lambf = dsqrt(Lambf)
25447 sparrow=dsqrt(sig1**2.0d0 + sig2**2.0d0)
25448 if (b1.eq.0.0d0) sparrow=1.0d0
25449 sparrow = 1.0d0 / sparrow
25450 ! write (*,*) "sparrow = ", sparrow,sig1,sig2,b1
25451 Chif = 1.0d0/rij * sparrow
25452 ChiLambf = Chif * Lambf
25453 eagle = dsqrt(ChiLambf)
25454 bat = ChiLambf ** 11.0d0
25455 top = b1 * ( eagle + b2 * ChiLambf - b3 )
25456 bot = 1.0d0 + b4 * (ChiLambf ** 12.0d0)
25460 dtop = b1 * ((Lambf / (2.0d0 * eagle)) + (b2 * Lambf))
25461 dbot = 12.0d0 * b4 * bat * Lambf
25462 dFdR = ((dtop * bot - top * dbot) / botsq) * sparrow
25464 ! write (*,*) "dFcav/dR = ", dFdR
25465 dtop = b1 * ((Chif / (2.0d0 * eagle)) + (b2 * Chif))
25466 dbot = 12.0d0 * b4 * bat * Chif
25467 eagle = Lambf * pom
25468 dFdOM1 = -(chis1 * om1 - chis12 * om2 * om12) / (eagle)
25469 dFdOM2 = -(chis2 * om2 - chis12 * om1 * om12) / (eagle)
25470 dFdOM12 = chis12 * (chis1 * om1 * om12 - om2) &
25471 * (chis2 * om2 * om12 - om1) / (eagle * pom)
25473 dFdL = ((dtop * bot - top * dbot) / botsq)
25475 dCAVdOM1 = dFdL * ( dFdOM1 )
25476 dCAVdOM2 = dFdL * ( dFdOM2 )
25477 dCAVdOM12 = dFdL * ( dFdOM12 )
25482 ! eom1=eps2der*eps2rt_om1-2.0D0*alf1*eps3der+sigder*sigsq_om1
25483 ! eom2=eps2der*eps2rt_om2+2.0D0*alf2*eps3der+sigder*sigsq_om2
25484 ! eom12=evdwij*eps1_om12+eps2der*eps2rt_om12 &
25485 ! -2.0D0*alf12*eps3der+sigder*sigsq_om12
25486 ! print *,"EOMY",eom1,eom2,eom12
25487 ! erdxi = scalar( ertail(1), dC_norm(1,i+nres) )
25488 ! erdxj = scalar( ertail(1), dC_norm(1,j+nres) )
25490 ! facd1 = dtail(1,itypi,itypj) * vbld_inv(i+nres)
25491 ! facd2 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
25493 ! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
25494 ! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
25496 !-facd1*(ertail(k)-erdxi*dC_norm(k,i+nres))
25497 gvdwx_scbase(k,i) = gvdwx_scbase(k,i) &
25498 - (( dFdR + gg(k) ) * pom)
25499 ! +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
25500 ! +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
25501 ! & - ( dFdR * pom )
25503 !-facd2*(ertail(k)-erdxj*dC_norm(k,j+nres))
25504 gvdwx_scbase(k,j) = gvdwx_scbase(k,j) &
25505 + (( dFdR + gg(k) ) * pom)
25506 ! +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
25507 ! +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
25508 !c! & + ( dFdR * pom )
25510 gvdwc_scbase(k,i) = gvdwc_scbase(k,i) &
25511 - (( dFdR + gg(k) ) * ertail(k))
25512 !c! & - ( dFdR * ertail(k))
25514 gvdwc_scbase(k,j) = gvdwc_scbase(k,j) &
25515 + (( dFdR + gg(k) ) * ertail(k))
25516 !c! & + ( dFdR * ertail(k))
25519 !c! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
25520 !c! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
25527 if (wdipdip_scbase(2,itypi,itypj).gt.0.0d0) then
25528 w1 = wdipdip_scbase(1,itypi,itypj)
25529 w2 = -wdipdip_scbase(3,itypi,itypj)/2.0
25530 w3 = wdipdip_scbase(2,itypi,itypj)
25531 !c!-------------------------------------------------------------------
25533 fac = (om12 - 3.0d0 * om1 * om2)
25534 c1 = (w1 / (Rhead**3.0d0)) * fac
25535 c2 = (w2 / Rhead ** 6.0d0) &
25536 * (4.0d0 + fac * fac -3.0d0 * (sqom1 + sqom2))
25537 c3= (w3/ Rhead ** 6.0d0) &
25538 * (2.0d0 - 2.0d0*fac*fac +3.0d0*(sqom1 + sqom2))
25540 !c! write (*,*) "w1 = ", w1
25541 !c! write (*,*) "w2 = ", w2
25542 !c! write (*,*) "om1 = ", om1
25543 !c! write (*,*) "om2 = ", om2
25544 !c! write (*,*) "om12 = ", om12
25545 !c! write (*,*) "fac = ", fac
25546 !c! write (*,*) "c1 = ", c1
25547 !c! write (*,*) "c2 = ", c2
25548 !c! write (*,*) "Ecl = ", Ecl
25549 !c! write (*,*) "c2_1 = ", (w2 / Rhead ** 6.0d0)
25550 !c! write (*,*) "c2_2 = ",
25551 !c! & (4.0d0 + fac * fac -3.0d0 * (sqom1 + sqom2))
25552 !c!-------------------------------------------------------------------
25553 !c! dervative of ECL is GCL...
25555 c1 = (-3.0d0 * w1 * fac) / (Rhead ** 4.0d0)
25556 c2 = (-6.0d0 * w2) / (Rhead ** 7.0d0) &
25557 * (4.0d0 + fac * fac - 3.0d0 * (sqom1 + sqom2))
25558 c3= (-6.0d0 * w3) / (Rhead ** 7.0d0) &
25559 * (2.0d0 - 2.0d0*fac*fac +3.0d0*(sqom1 + sqom2))
25560 dGCLdR = c1 - c2 + c3
25562 c1 = (-3.0d0 * w1 * om2 ) / (Rhead**3.0d0)
25563 c2 = (-6.0d0 * w2) / (Rhead**6.0d0) &
25564 * ( om2 * om12 - 3.0d0 * om1 * sqom2 + om1 )
25565 c3 =(6.0d0*w3/ Rhead ** 6.0d0)*(om1-2.0d0*(fac)*(-om2))
25566 dGCLdOM1 = c1 - c2 + c3
25568 c1 = (-3.0d0 * w1 * om1 ) / (Rhead**3.0d0)
25569 c2 = (-6.0d0 * w2) / (Rhead**6.0d0) &
25570 * ( om1 * om12 - 3.0d0 * sqom1 * om2 + om2 )
25571 c3 =(6.0d0*w3/ Rhead ** 6.0d0)*(om2-2.0d0*(fac)*(-om1))
25572 dGCLdOM2 = c1 - c2 + c3
25574 c1 = w1 / (Rhead ** 3.0d0)
25575 c2 = ( 2.0d0 * w2 * fac ) / Rhead ** 6.0d0
25576 c3 = (w3/ Rhead ** 6.0d0)*(-4.0d0*fac)
25577 dGCLdOM12 = c1 - c2 + c3
25579 erhead(k) = Rhead_distance(k)/Rhead
25581 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
25582 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
25583 facd1 = d1i * vbld_inv(i+nres)
25584 facd2 = d1j * vbld_inv(j+nres)
25587 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
25588 gvdwx_scbase(k,i) = gvdwx_scbase(k,i) &
25590 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
25591 gvdwx_scbase(k,j) = gvdwx_scbase(k,j) &
25594 gvdwc_scbase(k,i) = gvdwc_scbase(k,i) &
25595 - dGCLdR * erhead(k)
25596 gvdwc_scbase(k,j) = gvdwc_scbase(k,j) &
25597 + dGCLdR * erhead(k)
25600 !now charge with dipole eg. ARG-dG
25601 if (wqdip_scbase(2,itypi,itypj).gt.0.0d0) then
25602 alphapol1 = alphapol_scbase(itypi,itypj)
25603 w1 = wqdip_scbase(1,itypi,itypj)
25604 w2 = wqdip_scbase(2,itypi,itypj)
25607 ! pis = sig0head_scbase(itypi,itypj)
25608 ! eps_head = epshead_scbase(itypi,itypj)
25609 !c!-------------------------------------------------------------------
25610 !c! R1 - distance between head of ith side chain and tail of jth sidechain
25613 !c! Calculate head-to-tail distances tail is center of side-chain
25614 R1=R1+(c(k,j+nres)-chead(k,1))**2
25619 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
25620 !c! & +dhead(1,1,itypi,itypj))**2))
25621 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
25622 !c! & +dhead(2,1,itypi,itypj))**2))
25624 !c!-------------------------------------------------------------------
25627 hawk = w2 * (1.0d0 - sqom2)
25628 Ecl = sparrow / Rhead**2.0d0 &
25629 - hawk / Rhead**4.0d0
25630 !c!-------------------------------------------------------------------
25631 !c! derivative of ecl is Gcl
25633 dGCLdR = - 2.0d0 * sparrow / Rhead**3.0d0 &
25634 + 4.0d0 * hawk / Rhead**5.0d0
25636 dGCLdOM1 = (w1) / (Rhead**2.0d0)
25638 dGCLdOM2 = (2.0d0 * w2 * om2) / (Rhead ** 4.0d0)
25639 !c--------------------------------------------------------------------
25640 !c Polarization energy
25642 MomoFac1 = (1.0d0 - chi1 * sqom2)
25643 RR1 = R1 * R1 / MomoFac1
25644 ee1 = exp(-( RR1 / (4.0d0 * a12sq) ))
25645 fgb1 = sqrt( RR1 + a12sq * ee1)
25646 ! eps_inout_fac=0.0d0
25647 epol = 332.0d0 * eps_inout_fac * (( alphapol1 / fgb1 )**4.0d0)
25648 ! derivative of Epol is Gpol...
25649 dPOLdFGB1 = -(1328.0d0 * eps_inout_fac * alphapol1 ** 4.0d0) &
25651 dFGBdR1 = ( (R1 / MomoFac1) &
25652 * ( 2.0d0 - (0.5d0 * ee1) ) ) &
25654 dFGBdOM2 = (((R1 * R1 * chi1 * om2) / (MomoFac1 * MomoFac1)) &
25655 * (2.0d0 - 0.5d0 * ee1) ) &
25657 dPOLdR1 = dPOLdFGB1 * dFGBdR1
25660 dPOLdOM2 = dPOLdFGB1 * dFGBdOM2
25662 erhead(k) = Rhead_distance(k)/Rhead
25663 erhead_tail(k,1) = ((c(k,j+nres)-chead(k,1))/R1)
25666 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
25667 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
25668 bat = scalar( erhead_tail(1,1), dC_norm(1,i+nres) )
25670 federmaus = scalar(erhead_tail(1,1),dC_norm(1,j+nres))
25671 facd1 = d1i * vbld_inv(i+nres)
25672 facd2 = d1j * vbld_inv(j+nres)
25673 ! facd4 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
25676 hawk = (erhead_tail(k,1) + &
25677 facd1 * (erhead_tail(k,1) - bat * dC_norm(k,i+nres)))
25680 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
25681 gvdwx_scbase(k,i) = gvdwx_scbase(k,i) &
25683 - dPOLdR1 * (erhead_tail(k,1))
25686 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
25687 gvdwx_scbase(k,j) = gvdwx_scbase(k,j) &
25689 + dPOLdR1 * (erhead_tail(k,1))
25693 gvdwc_scbase(k,i) = gvdwc_scbase(k,i) &
25694 - dGCLdR * erhead(k) &
25695 - dPOLdR1 * erhead_tail(k,1)
25696 ! & - dGLJdR * erhead(k)
25698 gvdwc_scbase(k,j) = gvdwc_scbase(k,j) &
25699 + dGCLdR * erhead(k) &
25700 + dPOLdR1 * erhead_tail(k,1)
25701 ! & + dGLJdR * erhead(k)
25705 ! print *,i,j,evdwij,epol,Fcav,ECL
25706 escbase=escbase+evdwij+epol+Fcav+ECL
25707 if (energy_dec) write (iout,'(a22,2i5,4f8.3,f16.3)'), &
25708 "escbase:evdw,pol,cav,CL",i,j,evdwij,epol,Fcav,ECL,escbase
25709 if (energy_dec) write (iout,*) "evdwij,", evdwij, 1.0/rij, sig, sig0ij
25710 call sc_grad_scbase
25715 end subroutine eprot_sc_base
25716 SUBROUTINE sc_grad_scbase
25719 real (kind=8) :: dcosom1(3),dcosom2(3)
25721 eps2der * eps2rt_om1 &
25722 - 2.0D0 * alf1 * eps3der &
25723 + sigder * sigsq_om1 &
25729 eps2der * eps2rt_om2 &
25730 + 2.0D0 * alf2 * eps3der &
25731 + sigder * sigsq_om2 &
25737 evdwij * eps1_om12 &
25738 + eps2der * eps2rt_om12 &
25739 - 2.0D0 * alf12 * eps3der &
25740 + sigder *sigsq_om12 &
25744 ! print *,eom1,eom2,eom12,i,j,"eom1,2,12",erij(1),erij(2),erij(3)
25745 ! print *,dsci_inv,dscj_inv,dc_norm(2,nres+j),dc_norm(2,nres+i),&
25746 ! gg(1),gg(2),"rozne"
25748 dcosom1(k) = rij * (dc_norm(k,nres+i) - om1 * erij(k))
25749 dcosom2(k) = rij * (dc_norm(k,nres+j) - om2 * erij(k))
25750 gg(k) = gg(k) + eom1 * dcosom1(k) + eom2 * dcosom2(k)
25751 gvdwx_scbase(k,i)= gvdwx_scbase(k,i) - gg(k) &
25752 + (eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
25753 + eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
25754 gvdwx_scbase(k,j)= gvdwx_scbase(k,j) + gg(k) &
25755 + (eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
25756 + eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
25757 gvdwc_scbase(k,i)=gvdwc_scbase(k,i)-gg(k)
25758 gvdwc_scbase(k,j)=gvdwc_scbase(k,j)+gg(k)
25762 END SUBROUTINE sc_grad_scbase
25765 subroutine epep_sc_base(epepbase)
25768 !el local variables
25769 integer :: iint,itypi,itypi1,itypj,subchap
25770 real(kind=8) :: rrij,xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
25771 real(kind=8) :: evdw,sig0ij
25772 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
25773 dist_temp, dist_init,aa,bb,ssgradlipi,ssgradlipj, &
25774 sslipi,sslipj,faclip
25776 real(kind=8) :: fracinbuf
25777 real (kind=8) :: epepbase
25778 real (kind=8),dimension(4):: ener
25779 real(kind=8) :: b1,b2,b3,b4,egb,eps_in,eps_inout_fac,eps_out
25780 real(kind=8) :: ECL,Elj,Equad,Epol,eheadtail,rhead,dGCLOM2,&
25781 sqom1,sqom2,sqom12,c1,c2,c3,pom,Lambf,sparrow,&
25782 Chif,ChiLambf,bat,eagle,top,bot,botsq,Fcav,dtop,dFdR,dFdOM1,&
25783 dFdOM2,w1,w2,w3,dGCLdR,dFdL,dFdOM12,dbot ,&
25784 r1,eps_head,alphapol1,pis,facd2,d2,facd1,d1,erdxj,erdxi,federmaus,&
25785 dPOLdR1,dFGBdOM2,dFGBdR1,dPOLdFGB1,RR1,MomoFac1,hawk,d1i,d1j,&
25786 sig1,sig2,chis12,chis2,ee1,fgb1,a12sq,chis1
25787 real(kind=8),dimension(3,2)::chead,erhead_tail
25788 real(kind=8),dimension(3) :: Rhead_distance,ertail,erhead
25792 ! do i=1,nres_molec(1)-1
25793 do i=ibond_start,ibond_end
25794 if (itype(i,1).eq.ntyp1_molec(1).or.itype(i+1,1).eq.ntyp1_molec(1)) cycle
25795 !C itypi = itype(i,1)
25799 ! print *,dxi,(-c(1,i)+c(1,i+1))*vbld_inv(i+1)
25800 dsci_inv = vbld_inv(i+1)/2.0
25801 xi=(c(1,i)+c(1,i+1))/2.0
25802 yi=(c(2,i)+c(2,i+1))/2.0
25803 zi=(c(3,i)+c(3,i+1))/2.0
25804 call to_box(xi,yi,zi)
25805 do j=nres_molec(1)+1,nres_molec(2)+nres_molec(1)
25807 if (itype(j,2).eq.ntyp1_molec(2))cycle
25811 call to_box(xj,yj,zj)
25812 xj=boxshift(xj-xi,boxxsize)
25813 yj=boxshift(yj-yi,boxysize)
25814 zj=boxshift(zj-zi,boxzsize)
25815 dist_init=xj**2+yj**2+zj**2
25816 dxj = dc_norm( 1, nres+j )
25817 dyj = dc_norm( 2, nres+j )
25818 dzj = dc_norm( 3, nres+j )
25819 ! d1i = dhead_scbasei(itypi) !this is shift of dipole/charge
25820 ! d1j = dhead_scbasej(itypi) !this is shift of dipole/charge
25823 sig0ij = sigma_pepbase(itypj )
25824 chi1 = chi_pepbase(itypj,1 )
25825 chi2 = chi_pepbase(itypj,2 )
25828 chi12 = chi1 * chi2
25829 chip1 = chipp_pepbase(itypj,1 )
25830 chip2 = chipp_pepbase(itypj,2 )
25833 chip12 = chip1 * chip2
25834 chis1 = chis_pepbase(itypj,1)
25835 chis2 = chis_pepbase(itypj,2)
25836 chis12 = chis1 * chis2
25837 sig1 = sigmap1_pepbase(itypj)
25838 sig2 = sigmap2_pepbase(itypj)
25839 ! write (*,*) "sig1 = ", sig1
25840 ! write (*,*) "sig2 = ", sig2
25842 ! location of polar head is computed by taking hydrophobic centre
25843 ! and moving by a d1 * dc_norm vector
25844 ! see unres publications for very informative images
25845 chead(k,1) = (c(k,i)+c(k,i+1))/2.0
25846 ! + d1i * dc_norm(k, i+nres)
25847 chead(k,2) = c(k, j+nres)
25848 ! + d1j * dc_norm(k, j+nres)
25850 ! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
25851 ! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
25852 Rhead_distance(k) = chead(k,2) - chead(k,1)
25853 ! print *,gvdwc_pepbase(k,i)
25857 (Rhead_distance(1)*Rhead_distance(1)) &
25858 + (Rhead_distance(2)*Rhead_distance(2)) &
25859 + (Rhead_distance(3)*Rhead_distance(3)))
25861 ! alpha factors from Fcav/Gcav
25862 b1 = alphasur_pepbase(1,itypj)
25864 b2 = alphasur_pepbase(2,itypj)
25865 b3 = alphasur_pepbase(3,itypj)
25866 b4 = alphasur_pepbase(4,itypj)
25870 rrij = 1.0D0 / ( xj*xj + yj*yj + zj*zj)
25873 !----------------------------
25891 dscj_inv = vbld_inv(j+nres)
25893 ! this should be in elgrad_init but om's are calculated by sc_angular
25894 ! which in turn is used by older potentials
25895 ! om = omega, sqom = om^2
25898 sqom12 = om12 * om12
25900 ! now we calculate EGB - Gey-Berne
25901 ! It will be summed up in evdwij and saved in evdw
25902 sigsq = 1.0D0 / sigsq
25903 sig = sig0ij * dsqrt(sigsq)
25904 rij_shift = 1.0/rij - sig + sig0ij
25905 IF (rij_shift.le.0.0D0) THEN
25909 sigder = -sig * sigsq
25910 rij_shift = 1.0D0 / rij_shift
25911 fac = rij_shift**expon
25912 c1 = fac * fac * aa_pepbase(itypj)
25914 c2 = fac * bb_pepbase(itypj)
25916 evdwij = eps1 * eps2rt * eps3rt * ( c1 + c2 )
25917 eps2der = eps3rt * evdwij
25918 eps3der = eps2rt * evdwij
25919 ! evdwij = 4.0d0 * eps2rt * eps3rt * evdwij
25920 evdwij = eps2rt * eps3rt * evdwij
25921 c1 = c1 * eps1 * eps2rt**2 * eps3rt**2
25922 fac = -expon * (c1 + evdwij) * rij_shift
25923 sigder = fac * sigder
25925 ! Calculate distance derivative
25929 fac = chis1 * sqom1 + chis2 * sqom2 &
25930 - 2.0d0 * chis12 * om1 * om2 * om12
25931 ! we will use pom later in Gcav, so dont mess with it!
25932 pom = 1.0d0 - chis1 * chis2 * sqom12
25933 Lambf = (1.0d0 - (fac / pom))
25934 Lambf = dsqrt(Lambf)
25935 sparrow = 1.0d0 / dsqrt(sig1**2.0d0 + sig2**2.0d0)
25936 ! write (*,*) "sparrow = ", sparrow
25937 Chif = 1.0d0/rij * sparrow
25938 ChiLambf = Chif * Lambf
25939 eagle = dsqrt(ChiLambf)
25940 bat = ChiLambf ** 11.0d0
25941 top = b1 * ( eagle + b2 * ChiLambf - b3 )
25942 bot = 1.0d0 + b4 * (ChiLambf ** 12.0d0)
25946 dtop = b1 * ((Lambf / (2.0d0 * eagle)) + (b2 * Lambf))
25947 dbot = 12.0d0 * b4 * bat * Lambf
25948 dFdR = ((dtop * bot - top * dbot) / botsq) * sparrow
25950 ! write (*,*) "dFcav/dR = ", dFdR
25951 dtop = b1 * ((Chif / (2.0d0 * eagle)) + (b2 * Chif))
25952 dbot = 12.0d0 * b4 * bat * Chif
25953 eagle = Lambf * pom
25954 dFdOM1 = -(chis1 * om1 - chis12 * om2 * om12) / (eagle)
25955 dFdOM2 = -(chis2 * om2 - chis12 * om1 * om12) / (eagle)
25956 dFdOM12 = chis12 * (chis1 * om1 * om12 - om2) &
25957 * (chis2 * om2 * om12 - om1) / (eagle * pom)
25959 dFdL = ((dtop * bot - top * dbot) / botsq)
25961 dCAVdOM1 = dFdL * ( dFdOM1 )
25962 dCAVdOM2 = dFdL * ( dFdOM2 )
25963 dCAVdOM12 = dFdL * ( dFdOM12 )
25969 ! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
25970 ! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
25972 !-facd1*(ertail(k)-erdxi*dC_norm(k,i+nres))
25973 gvdwc_pepbase(k,i) = gvdwc_pepbase(k,i) &
25974 - (( dFdR + gg(k) ) * pom)/2.0
25975 ! print *,gvdwc_pepbase(k,i),i,(( dFdR + gg(k) ) * pom)/2.0
25976 ! +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
25977 ! +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
25978 ! & - ( dFdR * pom )
25980 !-facd2*(ertail(k)-erdxj*dC_norm(k,j+nres))
25981 gvdwx_pepbase(k,j) = gvdwx_pepbase(k,j) &
25982 + (( dFdR + gg(k) ) * pom)
25983 ! +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
25984 ! +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
25985 !c! & + ( dFdR * pom )
25987 gvdwc_pepbase(k,i+1) = gvdwc_pepbase(k,i+1) &
25988 - (( dFdR + gg(k) ) * ertail(k))/2.0
25989 ! print *,gvdwc_pepbase(k,i+1),i+1,(( dFdR + gg(k) ) * pom)/2.0
25991 !c! & - ( dFdR * ertail(k))
25993 gvdwc_pepbase(k,j) = gvdwc_pepbase(k,j) &
25994 + (( dFdR + gg(k) ) * ertail(k))
25995 !c! & + ( dFdR * ertail(k))
25998 !c! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
25999 !c! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
26003 w1 = wdipdip_pepbase(1,itypj)
26004 w2 = -wdipdip_pepbase(3,itypj)/2.0
26005 w3 = wdipdip_pepbase(2,itypj)
26008 !c!-------------------------------------------------------------------
26011 fac = (om12 - 3.0d0 * om1 * om2)
26012 c1 = (w1 / (Rhead**3.0d0)) * fac
26013 c2 = (w2 / Rhead ** 6.0d0) &
26014 * (4.0d0 + fac * fac -3.0d0 * (sqom1 + sqom2))
26015 c3= (w3/ Rhead ** 6.0d0) &
26016 * (2.0d0 - 2.0d0*fac*fac +3.0d0*(sqom1 + sqom2))
26020 c1 = (-3.0d0 * w1 * fac) / (Rhead ** 4.0d0)
26021 c2 = (-6.0d0 * w2) / (Rhead ** 7.0d0) &
26022 * (4.0d0 + fac * fac - 3.0d0 * (sqom1 + sqom2))
26023 c3= (-6.0d0 * w3) / (Rhead ** 7.0d0) &
26024 * (2.0d0 - 2.0d0*fac*fac +3.0d0*(sqom1 + sqom2))
26026 dGCLdR = c1 - c2 + c3
26028 c1 = (-3.0d0 * w1 * om2 ) / (Rhead**3.0d0)
26029 c2 = (-6.0d0 * w2) / (Rhead**6.0d0) &
26030 * ( om2 * om12 - 3.0d0 * om1 * sqom2 + om1 )
26031 c3 =(6.0d0*w3/ Rhead ** 6.0d0)*(om1-2.0d0*(fac)*(-om2))
26032 dGCLdOM1 = c1 - c2 + c3
26034 c1 = (-3.0d0 * w1 * om1 ) / (Rhead**3.0d0)
26035 c2 = (-6.0d0 * w2) / (Rhead**6.0d0) &
26036 * ( om1 * om12 - 3.0d0 * sqom1 * om2 + om2 )
26037 c3 =(6.0d0*w3/ Rhead ** 6.0d0)*(om2-2.0d0*(fac)*(-om1))
26039 dGCLdOM2 = c1 - c2 + c3
26041 c1 = w1 / (Rhead ** 3.0d0)
26042 c2 = ( 2.0d0 * w2 * fac ) / Rhead ** 6.0d0
26043 c3 = (w3/ Rhead ** 6.0d0)*(-4.0d0*fac)
26044 dGCLdOM12 = c1 - c2 + c3
26046 erhead(k) = Rhead_distance(k)/Rhead
26048 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
26049 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
26050 ! facd1 = d1 * vbld_inv(i+nres)
26051 ! facd2 = d2 * vbld_inv(j+nres)
26055 !+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
26056 ! gvdwx_pepbase(k,i) = gvdwx_scbase(k,i) &
26059 !+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
26060 gvdwx_pepbase(k,j) = gvdwx_pepbase(k,j) &
26063 gvdwc_pepbase(k,i) = gvdwc_pepbase(k,i) &
26064 - dGCLdR * erhead(k)/2.0d0
26065 ! print *,gvdwc_pepbase(k,i+1),i+1,- dGCLdR * erhead(k)/2.0d0
26066 gvdwc_pepbase(k,i+1) = gvdwc_pepbase(k,i+1) &
26067 - dGCLdR * erhead(k)/2.0d0
26068 ! print *,gvdwc_pepbase(k,i+1),i+1,- dGCLdR * erhead(k)/2.0d0
26069 gvdwc_pepbase(k,j) = gvdwc_pepbase(k,j) &
26070 + dGCLdR * erhead(k)
26072 ! print *,i,j,evdwij,Fcav,ECL,"vdw,cav,ecl"
26073 epepbase=epepbase+evdwij+Fcav+ECL
26074 if (energy_dec) write (iout,'(a22,2i5,4f8.3,f16.3)'), &
26075 "epepbase:evdw,pol,cav,CL",i,j,evdwij,epol,Fcav,ECL,epepbase
26076 call sc_grad_pepbase
26079 END SUBROUTINE epep_sc_base
26080 SUBROUTINE sc_grad_pepbase
26083 real (kind=8) :: dcosom1(3),dcosom2(3)
26085 eps2der * eps2rt_om1 &
26086 - 2.0D0 * alf1 * eps3der &
26087 + sigder * sigsq_om1 &
26093 eps2der * eps2rt_om2 &
26094 + 2.0D0 * alf2 * eps3der &
26095 + sigder * sigsq_om2 &
26101 evdwij * eps1_om12 &
26102 + eps2der * eps2rt_om12 &
26103 - 2.0D0 * alf12 * eps3der &
26104 + sigder *sigsq_om12 &
26109 ! print *,eom1,eom2,eom12,om12,i,j,"eom1,2,12",erij(1),erij(2),erij(3)
26110 ! if (i.eq.30) print *,gvdwc_pepbase(k,i),- gg(k),&
26111 ! (-eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,i)))&
26113 ! print *,dsci_inv,dscj_inv,dc_norm(2,nres+j),dc_norm(2,nres+i),&
26114 ! gg(1),gg(2),"rozne"
26116 dcosom1(k) = rij * (dc_norm(k,i) - om1 * erij(k))
26117 dcosom2(k) = rij * (dc_norm(k,nres+j) - om2 * erij(k))
26118 gg(k) = gg(k) + eom1 * dcosom1(k) + eom2 * dcosom2(k)
26119 gvdwc_pepbase(k,i)= gvdwc_pepbase(k,i) +0.5*(- gg(k)) &
26120 + (-eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,i)))&
26122 - (eom1*(erij(k)-om1*dc_norm(k,i)))*dsci_inv*2.0
26123 gvdwc_pepbase(k,i+1)= gvdwc_pepbase(k,i+1) +0.5*(- gg(k)) &
26124 - (-eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,i))) &
26126 + (eom1*(erij(k)-om1*dc_norm(k,i)))*dsci_inv*2.0
26127 ! print *,eom12,eom2,om12,om2
26128 !eom12*(-dc_norm(k,i)/2.0-om12*dc_norm(k,nres+j)),&
26129 ! (eom2*(erij(k)-om2*dc_norm(k,nres+j)))
26130 gvdwx_pepbase(k,j)= gvdwx_pepbase(k,j) + gg(k) &
26131 + (eom12*(dc_norm(k,i)-om12*dc_norm(k,nres+j))&
26132 + eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
26133 gvdwc_pepbase(k,j)=gvdwc_pepbase(k,j)+gg(k)
26136 END SUBROUTINE sc_grad_pepbase
26137 subroutine eprot_sc_phosphate(escpho)
26139 ! implicit real(kind=8) (a-h,o-z)
26140 ! include 'DIMENSIONS'
26141 ! include 'COMMON.GEO'
26142 ! include 'COMMON.VAR'
26143 ! include 'COMMON.LOCAL'
26144 ! include 'COMMON.CHAIN'
26145 ! include 'COMMON.DERIV'
26146 ! include 'COMMON.NAMES'
26147 ! include 'COMMON.INTERACT'
26148 ! include 'COMMON.IOUNITS'
26149 ! include 'COMMON.CALC'
26150 ! include 'COMMON.CONTROL'
26151 ! include 'COMMON.SBRIDGE'
26153 !el local variables
26154 integer :: iint,itypi,itypi1,itypj,subchap
26155 real(kind=8) :: rrij,xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
26156 real(kind=8) :: evdw,sig0ij,aa,bb
26157 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
26158 dist_temp, dist_init,ssgradlipi,ssgradlipj, &
26159 sslipi,sslipj,faclip,alpha_sco
26161 real(kind=8) :: fracinbuf
26162 real (kind=8) :: escpho
26163 real (kind=8),dimension(4):: ener
26164 real(kind=8) :: b1,b2,b3,b4,egb,eps_in,eps_inout_fac,eps_out
26165 real(kind=8) :: ECL,Elj,Equad,Epol,eheadtail,rhead,dGCLOM2,&
26166 sqom1,sqom2,sqom12,c1,c2,pom,Lambf,sparrow,&
26167 Chif,ChiLambf,bat,eagle,top,bot,botsq,Fcav,dtop,dFdR,dFdOM1,&
26168 dFdOM2,w1,w2,dGCLdR,dFdL,dFdOM12,dbot ,&
26169 r1,eps_head,alphapol1,pis,facd2,d2,facd1,d1,erdxj,erdxi,federmaus,&
26170 dPOLdR1,dFGBdOM2,dFGBdR1,dPOLdFGB1,RR1,MomoFac1,hawk,d1i,d1j,&
26171 sig1,sig2,chis12,chis2,ee1,fgb1,a12sq,chis1,Rhead_sq,Qij,dFGBdOM1
26172 real(kind=8),dimension(3,2)::chead,erhead_tail
26173 real(kind=8),dimension(3) :: Rhead_distance,ertail,erhead
26177 ! do i=1,nres_molec(1)
26178 do i=ibond_start,ibond_end
26179 if (itype(i,1).eq.ntyp1_molec(1)) cycle
26181 dxi = dc_norm(1,nres+i)
26182 dyi = dc_norm(2,nres+i)
26183 dzi = dc_norm(3,nres+i)
26184 dsci_inv = vbld_inv(i+nres)
26188 call to_box(xi,yi,zi)
26189 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
26190 do j=nres_molec(1)+1,nres_molec(2)+nres_molec(1)-1
26192 if ((itype(j,2).eq.ntyp1_molec(2)).or.&
26193 (itype(j+1,2).eq.ntyp1_molec(2))) cycle
26194 xj=(c(1,j)+c(1,j+1))/2.0
26195 yj=(c(2,j)+c(2,j+1))/2.0
26196 zj=(c(3,j)+c(3,j+1))/2.0
26197 call to_box(xj,yj,zj)
26198 ! call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
26199 ! aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
26200 ! +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
26201 ! bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
26202 ! +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
26203 xj=boxshift(xj-xi,boxxsize)
26204 yj=boxshift(yj-yi,boxysize)
26205 zj=boxshift(zj-zi,boxzsize)
26206 dxj = dc_norm( 1,j )
26207 dyj = dc_norm( 2,j )
26208 dzj = dc_norm( 3,j )
26209 dscj_inv = vbld_inv(j+1)
26212 sig0ij = sigma_scpho(itypi )
26213 chi1 = chi_scpho(itypi,1 )
26214 chi2 = chi_scpho(itypi,2 )
26217 chi12 = chi1 * chi2
26218 chip1 = chipp_scpho(itypi,1 )
26219 chip2 = chipp_scpho(itypi,2 )
26222 chip12 = chip1 * chip2
26223 chis1 = chis_scpho(itypi,1)
26224 chis2 = chis_scpho(itypi,2)
26225 chis12 = chis1 * chis2
26226 sig1 = sigmap1_scpho(itypi)
26227 sig2 = sigmap2_scpho(itypi)
26228 ! write (*,*) "sig1 = ", sig1
26229 ! write (*,*) "sig1 = ", sig1
26230 ! write (*,*) "sig2 = ", sig2
26231 ! alpha factors from Fcav/Gcav
26235 a12sq = rborn_scphoi(itypi) * rborn_scphoj(itypi)
26237 b1 = alphasur_scpho(1,itypi)
26239 b2 = alphasur_scpho(2,itypi)
26240 b3 = alphasur_scpho(3,itypi)
26241 b4 = alphasur_scpho(4,itypi)
26242 ! used to determine whether we want to do quadrupole calculations
26244 eps_in = epsintab_scpho(itypi)
26245 if (eps_in.eq.0.0) eps_in=1.0
26246 eps_inout_fac = ( (1.0d0/eps_in) - (1.0d0/eps_out))
26247 ! write (*,*) "eps_inout_fac = ", eps_inout_fac
26248 !-------------------------------------------------------------------
26249 ! tail location and distance calculations
26250 d1i = dhead_scphoi(itypi) !this is shift of dipole/charge
26253 ! location of polar head is computed by taking hydrophobic centre
26254 ! and moving by a d1 * dc_norm vector
26255 ! see unres publications for very informative images
26256 chead(k,1) = c(k, i+nres) + d1i * dc_norm(k, i+nres)
26257 chead(k,2) = (c(k, j) + c(k, j+1))/2.0
26259 ! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
26260 ! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
26261 Rhead_distance(k) = chead(k,2) - chead(k,1)
26263 ! pitagoras (root of sum of squares)
26265 (Rhead_distance(1)*Rhead_distance(1)) &
26266 + (Rhead_distance(2)*Rhead_distance(2)) &
26267 + (Rhead_distance(3)*Rhead_distance(3)))
26268 Rhead_sq=Rhead**2.0
26269 !-------------------------------------------------------------------
26270 ! zero everything that should be zero'ed
26289 dscj_inv = vbld_inv(j+1)/2.0
26290 !dhead_scbasej(itypi,itypj)
26291 ! print *,i,j,dscj_inv,dsci_inv
26292 ! rij holds 1/(distance of Calpha atoms)
26293 rrij = 1.0D0 / ( xj*xj + yj*yj + zj*zj)
26295 !----------------------------
26297 ! this should be in elgrad_init but om's are calculated by sc_angular
26298 ! which in turn is used by older potentials
26299 ! om = omega, sqom = om^2
26302 sqom12 = om12 * om12
26304 ! now we calculate EGB - Gey-Berne
26305 ! It will be summed up in evdwij and saved in evdw
26306 sigsq = 1.0D0 / sigsq
26307 sig = sig0ij * dsqrt(sigsq)
26308 ! rij_shift = 1.0D0 / rij - sig + sig0ij
26309 rij_shift = 1.0/rij - sig + sig0ij
26310 IF (rij_shift.le.0.0D0) THEN
26314 sigder = -sig * sigsq
26315 rij_shift = 1.0D0 / rij_shift
26316 fac = rij_shift**expon
26317 c1 = fac * fac * aa_scpho(itypi)
26319 c2 = fac * bb_scpho(itypi)
26321 evdwij = eps1 * eps2rt * eps3rt * ( c1 + c2 )
26322 eps2der = eps3rt * evdwij
26323 eps3der = eps2rt * evdwij
26324 ! evdwij = 4.0d0 * eps2rt * eps3rt * evdwij
26325 evdwij = eps2rt * eps3rt * evdwij
26326 c1 = c1 * eps1 * eps2rt**2 * eps3rt**2
26327 fac = -expon * (c1 + evdwij) * rij_shift
26328 sigder = fac * sigder
26330 ! Calculate distance derivative
26334 fac = chis1 * sqom1 + chis2 * sqom2 &
26335 - 2.0d0 * chis12 * om1 * om2 * om12
26336 ! we will use pom later in Gcav, so dont mess with it!
26337 pom = 1.0d0 - chis1 * chis2 * sqom12
26338 Lambf = (1.0d0 - (fac / pom))
26339 Lambf = dsqrt(Lambf)
26340 sparrow = 1.0d0 / dsqrt(sig1**2.0d0 + sig2**2.0d0)
26341 ! write (*,*) "sparrow = ", sparrow
26342 Chif = 1.0d0/rij * sparrow
26343 ChiLambf = Chif * Lambf
26344 eagle = dsqrt(ChiLambf)
26345 bat = ChiLambf ** 11.0d0
26346 top = b1 * ( eagle + b2 * ChiLambf - b3 )
26347 bot = 1.0d0 + b4 * (ChiLambf ** 12.0d0)
26350 dtop = b1 * ((Lambf / (2.0d0 * eagle)) + (b2 * Lambf))
26351 dbot = 12.0d0 * b4 * bat * Lambf
26352 dFdR = ((dtop * bot - top * dbot) / botsq) * sparrow
26354 ! write (*,*) "dFcav/dR = ", dFdR
26355 dtop = b1 * ((Chif / (2.0d0 * eagle)) + (b2 * Chif))
26356 dbot = 12.0d0 * b4 * bat * Chif
26357 eagle = Lambf * pom
26358 dFdOM1 = -(chis1 * om1 - chis12 * om2 * om12) / (eagle)
26359 dFdOM2 = -(chis2 * om2 - chis12 * om1 * om12) / (eagle)
26360 dFdOM12 = chis12 * (chis1 * om1 * om12 - om2) &
26361 * (chis2 * om2 * om12 - om1) / (eagle * pom)
26363 dFdL = ((dtop * bot - top * dbot) / botsq)
26365 dCAVdOM1 = dFdL * ( dFdOM1 )
26366 dCAVdOM2 = dFdL * ( dFdOM2 )
26367 dCAVdOM12 = dFdL * ( dFdOM12 )
26373 ! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
26374 ! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
26375 ! if (i.eq.3) print *,'decl0',gvdwx_scpho(k,i),i
26378 ! print *,pom,gg(k),dFdR
26379 !-facd1*(ertail(k)-erdxi*dC_norm(k,i+nres))
26380 gvdwx_scpho(k,i) = gvdwx_scpho(k,i) &
26381 - (( dFdR + gg(k) ) * pom)
26382 ! +(eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i)) &
26383 ! +eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
26384 ! & - ( dFdR * pom )
26386 !-facd2*(ertail(k)-erdxj*dC_norm(k,j+nres))
26387 ! gvdwx_scpho(k,j) = gvdwx_scpho(k,j) &
26388 ! + (( dFdR + gg(k) ) * pom)
26389 ! +(eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
26390 ! +eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
26391 !c! & + ( dFdR * pom )
26393 gvdwc_scpho(k,i) = gvdwc_scpho(k,i) &
26394 - (( dFdR + gg(k) ) * ertail(k))
26395 !c! & - ( dFdR * ertail(k))
26397 gvdwc_scpho(k,j) = gvdwc_scpho(k,j) &
26398 + (( dFdR + gg(k) ) * ertail(k))/2.0
26400 gvdwc_scpho(k,j+1) = gvdwc_scpho(k,j+1) &
26401 + (( dFdR + gg(k) ) * ertail(k))/2.0
26403 !c! & + ( dFdR * ertail(k))
26407 !c! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
26408 !c! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
26409 ! alphapol1 = alphapol_scpho(itypi)
26410 if (wqq_scpho(itypi).ne.0.0) then
26411 Qij=wqq_scpho(itypi)/eps_in
26412 alpha_sco=1.d0/alphi_scpho(itypi)
26414 Ecl = (332.0d0 * Qij*dexp(-Rhead*alpha_sco)) / Rhead
26415 !c! derivative of Ecl is Gcl...
26416 dGCLdR = (-332.0d0 * Qij*dexp(-Rhead*alpha_sco)* &
26417 (Rhead*alpha_sco+1) ) / Rhead_sq
26418 if (energy_dec) write(iout,*) "ECL",ECL,Rhead,1.0/rij
26419 else if (wqdip_scpho(2,itypi).gt.0.0d0) then
26420 w1 = wqdip_scpho(1,itypi)
26421 w2 = wqdip_scpho(2,itypi)
26424 ! pis = sig0head_scbase(itypi,itypj)
26425 ! eps_head = epshead_scbase(itypi,itypj)
26426 !c!-------------------------------------------------------------------
26428 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
26429 !c! & +dhead(1,1,itypi,itypj))**2))
26430 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
26431 !c! & +dhead(2,1,itypi,itypj))**2))
26433 !c!-------------------------------------------------------------------
26436 hawk = w2 * (1.0d0 - sqom2)
26437 Ecl = sparrow / Rhead**2.0d0 &
26438 - hawk / Rhead**4.0d0
26439 !c!-------------------------------------------------------------------
26440 if (energy_dec) write(iout,*) "ECLdipdip",ECL,Rhead,&
26443 !c! derivative of ecl is Gcl
26445 dGCLdR = - 2.0d0 * sparrow / Rhead**3.0d0 &
26446 + 4.0d0 * hawk / Rhead**5.0d0
26448 dGCLdOM1 = (w1) / (Rhead**2.0d0)
26450 dGCLdOM2 = (2.0d0 * w2 * om2) / (Rhead ** 4.0d0)
26453 !c--------------------------------------------------------------------
26454 !c Polarization energy
26458 !c! Calculate head-to-tail distances tail is center of side-chain
26459 R1=R1+((c(k,j)+c(k,j+1))/2.0-chead(k,1))**2
26464 alphapol1 = alphapol_scpho(itypi)
26466 MomoFac1 = (1.0d0 - chi2 * sqom1)
26467 RR1 = R1 * R1 / MomoFac1
26468 ee1 = exp(-( RR1 / (4.0d0 * a12sq) ))
26469 ! print *,"ee1",ee1,a12sq,alphapol1,eps_inout_fac
26470 fgb1 = sqrt( RR1 + a12sq * ee1)
26471 ! eps_inout_fac=0.0d0
26472 epol = 332.0d0 * eps_inout_fac * (( alphapol1 / fgb1 )**4.0d0)
26473 ! derivative of Epol is Gpol...
26474 dPOLdFGB1 = -(1328.0d0 * eps_inout_fac * alphapol1 ** 4.0d0) &
26476 dFGBdR1 = ( (R1 / MomoFac1) &
26477 * ( 2.0d0 - (0.5d0 * ee1) ) ) &
26479 dFGBdOM2 = (((R1 * R1 * chi1 * om2) / (MomoFac1 * MomoFac1)) &
26480 * (2.0d0 - 0.5d0 * ee1) ) &
26482 dPOLdR1 = dPOLdFGB1 * dFGBdR1
26485 dFGBdOM1 = (((R1 * R1 * chi2 * om1) / (MomoFac1 * MomoFac1)) &
26486 * (2.0d0 - 0.5d0 * ee1) ) &
26489 dPOLdOM1 = dPOLdFGB1 * dFGBdOM1
26492 erhead(k) = Rhead_distance(k)/Rhead
26493 erhead_tail(k,1) = (((c(k,j)+c(k,j+1))/2.0-chead(k,1))/R1)
26496 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
26497 erdxj = scalar( erhead(1), dC_norm(1,j) )
26498 bat = scalar( erhead_tail(1,1), dC_norm(1,i+nres) )
26500 federmaus = scalar(erhead_tail(1,1),dC_norm(1,j))
26501 facd1 = d1i * vbld_inv(i+nres)
26502 facd2 = d1j * vbld_inv(j)
26503 ! facd4 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
26506 hawk = (erhead_tail(k,1) + &
26507 facd1 * (erhead_tail(k,1) - bat * dC_norm(k,i+nres)))
26510 ! if (i.eq.3) print *,'decl1',dGCLdR,dPOLdR1,gvdwc_scpho(k,i),i,&
26511 ! pom,(erhead_tail(k,1))
26513 ! print *,'decl',dGCLdR,dPOLdR1,gvdwc_scpho(k,i)
26514 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
26515 gvdwx_scpho(k,i) = gvdwx_scpho(k,i) &
26517 - dPOLdR1 * (erhead_tail(k,1))
26520 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j))
26521 ! gvdwx_scpho(k,j) = gvdwx_scpho(k,j) &
26523 ! + dPOLdR1 * (erhead_tail(k,1))
26527 gvdwc_scpho(k,i) = gvdwc_scpho(k,i) &
26528 - dGCLdR * erhead(k) &
26529 - dPOLdR1 * erhead_tail(k,1)
26530 ! & - dGLJdR * erhead(k)
26532 gvdwc_scpho(k,j) = gvdwc_scpho(k,j) &
26533 + (dGCLdR * erhead(k) &
26534 + dPOLdR1 * erhead_tail(k,1))/2.0
26535 gvdwc_scpho(k,j+1) = gvdwc_scpho(k,j+1) &
26536 + (dGCLdR * erhead(k) &
26537 + dPOLdR1 * erhead_tail(k,1))/2.0
26539 ! & + dGLJdR * erhead(k)
26540 ! if (i.eq.3) print *,'decl2',dGCLdR,dPOLdR1,gvdwc_scpho(k,i),i
26543 ! if (i.eq.3) print *,i,j,evdwij,epol,Fcav,ECL
26544 if (energy_dec) write (iout,'(a22,2i5,4f8.3,f16.3)'), &
26545 "escpho:evdw,pol,cav,CL",i,j,evdwij,epol,Fcav,ECL,escpho
26546 escpho=escpho+evdwij+epol+Fcav+ECL
26553 end subroutine eprot_sc_phosphate
26554 SUBROUTINE sc_grad_scpho
26557 real (kind=8) :: dcosom1(3),dcosom2(3)
26559 eps2der * eps2rt_om1 &
26560 - 2.0D0 * alf1 * eps3der &
26561 + sigder * sigsq_om1 &
26567 eps2der * eps2rt_om2 &
26568 + 2.0D0 * alf2 * eps3der &
26569 + sigder * sigsq_om2 &
26575 evdwij * eps1_om12 &
26576 + eps2der * eps2rt_om12 &
26577 - 2.0D0 * alf12 * eps3der &
26578 + sigder *sigsq_om12 &
26583 ! print *,eom1,eom2,eom12,om12,i,j,"eom1,2,12",erij(1),erij(2),erij(3)
26584 ! if (i.eq.30) print *,gvdwc_scpho(k,i),- gg(k),&
26585 ! (-eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,i)))&
26587 ! print *,dsci_inv,dscj_inv,dc_norm(2,nres+j),dc_norm(2,nres+i),&
26588 ! gg(1),gg(2),"rozne"
26590 dcosom1(k) = rij * (dc_norm(k,nres+i) - om1 * erij(k))
26591 dcosom2(k) = rij * (dc_norm(k,j) - om2 * erij(k))
26592 gg(k) = gg(k) + eom1 * dcosom1(k) + eom2 * dcosom2(k)
26593 gvdwc_scpho(k,j)= gvdwc_scpho(k,j) +0.5*( gg(k)) &
26594 + (-eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,j)))&
26596 - (eom2*(erij(k)-om2*dc_norm(k,j)))*dscj_inv*2.0
26597 gvdwc_scpho(k,j+1)= gvdwc_scpho(k,j+1) +0.5*( gg(k)) &
26598 - (-eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,j))) &
26600 + (eom2*(erij(k)-om2*dc_norm(k,j)))*dscj_inv*2.0
26601 gvdwx_scpho(k,i)= gvdwx_scpho(k,i) - gg(k) &
26602 + (eom12*(dc_norm(k,j)-om12*dc_norm(k,nres+i)) &
26603 + eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv
26605 ! print *,eom12,eom2,om12,om2
26606 !eom12*(-dc_norm(k,i)/2.0-om12*dc_norm(k,nres+j)),&
26607 ! (eom2*(erij(k)-om2*dc_norm(k,nres+j)))
26608 ! gvdwx_scpho(k,j)= gvdwx_scpho(k,j) + gg(k) &
26609 ! + (eom12*(dc_norm(k,i)-om12*dc_norm(k,nres+j))&
26610 ! + eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv
26611 gvdwc_scpho(k,i)=gvdwc_scpho(k,i)-gg(k)
26614 END SUBROUTINE sc_grad_scpho
26615 subroutine eprot_pep_phosphate(epeppho)
26617 ! implicit real(kind=8) (a-h,o-z)
26618 ! include 'DIMENSIONS'
26619 ! include 'COMMON.GEO'
26620 ! include 'COMMON.VAR'
26621 ! include 'COMMON.LOCAL'
26622 ! include 'COMMON.CHAIN'
26623 ! include 'COMMON.DERIV'
26624 ! include 'COMMON.NAMES'
26625 ! include 'COMMON.INTERACT'
26626 ! include 'COMMON.IOUNITS'
26627 ! include 'COMMON.CALC'
26628 ! include 'COMMON.CONTROL'
26629 ! include 'COMMON.SBRIDGE'
26631 !el local variables
26632 integer :: iint,itypi,itypi1,itypj,subchap
26633 real(kind=8) :: rrij,xi,yi,zi,sig,rij_shift,fac,e1,e2,sigm,epsi
26634 real(kind=8) :: evdw,sig0ij
26635 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
26636 dist_temp, dist_init,aa,bb,ssgradlipi,ssgradlipj, &
26637 sslipi,sslipj,faclip
26639 real(kind=8) :: fracinbuf
26640 real (kind=8) :: epeppho
26641 real (kind=8),dimension(4):: ener
26642 real(kind=8) :: b1,b2,b3,b4,egb,eps_in,eps_inout_fac,eps_out
26643 real(kind=8) :: ECL,Elj,Equad,Epol,eheadtail,rhead,dGCLOM2,&
26644 sqom1,sqom2,sqom12,c1,c2,pom,Lambf,sparrow,&
26645 Chif,ChiLambf,bat,eagle,top,bot,botsq,Fcav,dtop,dFdR,dFdOM1,&
26646 dFdOM2,w1,w2,dGCLdR,dFdL,dFdOM12,dbot ,&
26647 r1,eps_head,alphapol1,pis,facd2,d2,facd1,d1,erdxj,erdxi,federmaus,&
26648 dPOLdR1,dFGBdOM2,dFGBdR1,dPOLdFGB1,RR1,MomoFac1,hawk,d1i,d1j,&
26649 sig1,sig2,chis12,chis2,ee1,fgb1,a12sq,chis1,Rhead_sq,Qij,dFGBdOM1
26650 real(kind=8),dimension(3,2)::chead,erhead_tail
26651 real(kind=8),dimension(3) :: Rhead_distance,ertail,erhead
26653 real (kind=8) :: dcosom1(3),dcosom2(3)
26655 ! do i=1,nres_molec(1)
26656 do i=ibond_start,ibond_end
26657 if (itype(i,1).eq.ntyp1_molec(1)) cycle
26659 dsci_inv = vbld_inv(i+1)/2.0
26663 xi=(c(1,i)+c(1,i+1))/2.0
26664 yi=(c(2,i)+c(2,i+1))/2.0
26665 zi=(c(3,i)+c(3,i+1))/2.0
26666 call to_box(xi,yi,zi)
26668 do j=nres_molec(1)+1,nres_molec(2)+nres_molec(1)-1
26670 if ((itype(j,2).eq.ntyp1_molec(2)).or.&
26671 (itype(j+1,2).eq.ntyp1_molec(2))) cycle
26672 xj=(c(1,j)+c(1,j+1))/2.0
26673 yj=(c(2,j)+c(2,j+1))/2.0
26674 zj=(c(3,j)+c(3,j+1))/2.0
26675 call to_box(xj,yj,zj)
26676 xj=boxshift(xj-xi,boxxsize)
26677 yj=boxshift(yj-yi,boxysize)
26678 zj=boxshift(zj-zi,boxzsize)
26680 dist_init=xj**2+yj**2+zj**2
26681 rrij = 1.0D0 / ( xj*xj + yj*yj + zj*zj)
26683 dxj = dc_norm( 1,j )
26684 dyj = dc_norm( 2,j )
26685 dzj = dc_norm( 3,j )
26686 dscj_inv = vbld_inv(j+1)/2.0
26688 sig0ij = sigma_peppho
26691 chi12 = chi1 * chi2
26694 chip12 = chip1 * chip2
26697 chis12 = chis1 * chis2
26698 sig1 = sigmap1_peppho
26699 sig2 = sigmap2_peppho
26700 ! write (*,*) "sig1 = ", sig1
26701 ! write (*,*) "sig1 = ", sig1
26702 ! write (*,*) "sig2 = ", sig2
26703 ! alpha factors from Fcav/Gcav
26707 b1 = alphasur_peppho(1)
26709 b2 = alphasur_peppho(2)
26710 b3 = alphasur_peppho(3)
26711 b4 = alphasur_peppho(4)
26733 fac = rij_shift**expon
26734 c1 = fac * fac * aa_peppho
26736 c2 = fac * bb_peppho
26739 ! Now cavity....................
26740 eagle = dsqrt(1.0/rij_shift)
26741 top = b1 * ( eagle + b2 * 1.0/rij_shift - b3 )
26742 bot = 1.0d0 + b4 * (1.0/rij_shift ** 12.0d0)
26745 dtop = b1 * ((1.0/ (2.0d0 * eagle)) + (b2))
26746 dbot = 12.0d0 * b4 * (1.0/rij_shift) ** 11.0d0
26747 dFdR = ((dtop * bot - top * dbot) / botsq)
26748 w1 = wqdip_peppho(1)
26749 w2 = wqdip_peppho(2)
26752 ! pis = sig0head_scbase(itypi,itypj)
26753 ! eps_head = epshead_scbase(itypi,itypj)
26754 !c!-------------------------------------------------------------------
26756 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
26757 !c! & +dhead(1,1,itypi,itypj))**2))
26758 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
26759 !c! & +dhead(2,1,itypi,itypj))**2))
26761 !c!-------------------------------------------------------------------
26764 hawk = w2 * (1.0d0 - sqom1)
26765 Ecl = sparrow * rij_shift**2.0d0 &
26766 - hawk * rij_shift**4.0d0
26767 !c!-------------------------------------------------------------------
26768 !c! derivative of ecl is Gcl
26771 dGCLdR = - 2.0d0 * sparrow * rij_shift**3.0d0 &
26772 + 4.0d0 * hawk * rij_shift**5.0d0
26774 dGCLdOM1 = (w1) * (rij_shift**2.0d0)
26776 dGCLdOM2 = (2.0d0 * w2 * om1) * (rij_shift ** 4.0d0)
26777 eom1 = dGCLdOM1+dGCLdOM2
26780 fac = -expon * (c1 + evdwij) * rij_shift+dFdR+dGCLdR
26786 gvdwc_peppho(k,j) = gvdwc_peppho(k,j) +gg(k)/2.0
26787 gvdwc_peppho(k,j+1) = gvdwc_peppho(k,j+1) +gg(k)/2.0
26788 gvdwc_peppho(k,i) = gvdwc_peppho(k,i) -gg(k)/2.0
26789 gvdwc_peppho(k,i+1) = gvdwc_peppho(k,i+1) -gg(k)/2.0
26794 dcosom1(k) = rij* (dc_norm(k,i) - om1 * erij(k))
26795 dcosom2(k) = rij* (dc_norm(k,j) - om2 * erij(k))
26796 gg(k) = gg(k) + eom1 * dcosom1(k)! + eom2 * dcosom2(k)
26797 gvdwc_peppho(k,j)= gvdwc_peppho(k,j) +0.5*( gg(k)) !&
26798 ! - (eom2*(erij(k)-om2*dc_norm(k,j)))*dscj_inv*2.0
26799 gvdwc_peppho(k,j+1)= gvdwc_peppho(k,j+1) +0.5*( gg(k)) !&
26800 ! + (eom2*(erij(k)-om2*dc_norm(k,j)))*dscj_inv*2.0
26801 gvdwc_peppho(k,i)= gvdwc_peppho(k,i) -0.5*( gg(k)) &
26802 - (eom1*(erij(k)-om1*dc_norm(k,i)))*dsci_inv*2.0
26803 gvdwc_peppho(k,i+1)= gvdwc_peppho(k,i+1) - 0.5*( gg(k)) &
26804 + (eom1*(erij(k)-om1*dc_norm(k,i)))*dsci_inv*2.0
26806 if (energy_dec) write (iout,'(a22,2i5,4f8.3,f16.3)'), &
26807 "epeppho:evdw,pol,cav,CL",i,j,evdwij,epol,Fcav,ECL,epeppho
26809 epeppho=epeppho+evdwij+Fcav+ECL
26810 ! print *,i,j,evdwij,Fcav,ECL,rij_shift
26813 end subroutine eprot_pep_phosphate
26814 !!!!!!!!!!!!!!!!-------------------------------------------------------------
26815 subroutine emomo(evdw)
26818 ! implicit real(kind=8) (a-h,o-z)
26819 ! include 'DIMENSIONS'
26820 ! include 'COMMON.GEO'
26821 ! include 'COMMON.VAR'
26822 ! include 'COMMON.LOCAL'
26823 ! include 'COMMON.CHAIN'
26824 ! include 'COMMON.DERIV'
26825 ! include 'COMMON.NAMES'
26826 ! include 'COMMON.INTERACT'
26827 ! include 'COMMON.IOUNITS'
26828 ! include 'COMMON.CALC'
26829 ! include 'COMMON.CONTROL'
26830 ! include 'COMMON.SBRIDGE'
26832 !el local variables
26833 integer :: iint,itypi1,subchap,isel,countss
26834 real(kind=8) :: rrij,xi,yi,zi,sig,rij_shift,e1,e2,sigm,epsi
26835 real(kind=8) :: evdw,aa,bb
26836 real(kind=8) :: xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp,&
26837 dist_temp, dist_init,ssgradlipi,ssgradlipj, &
26838 sslipi,sslipj,faclip,alpha_sco
26839 integer :: ii,icont
26840 real(kind=8) :: fracinbuf
26841 real (kind=8) :: escpho
26842 real (kind=8),dimension(4):: ener
26843 real(kind=8) :: b1,b2,egb
26844 real(kind=8) :: Fisocav,ECL,Elj,Equad,Epol,eheadtail,&
26846 Chif,ChiLambf,Fcav,dFdR,dFdOM1,&
26847 dFdOM2,dFdL,dFdOM12,&
26850 ! real(kind=8),dimension(3,2)::erhead_tail
26851 ! real(kind=8),dimension(3) :: Rhead_distance,ertail,erhead,Rtail_distance
26852 real(kind=8) :: facd4, adler, Fgb, facd3
26853 integer troll,jj,istate
26854 real (kind=8) :: dcosom1(3),dcosom2(3)
26859 ! print *,"EVDW KURW",evdw,nres
26860 ! do i=iatsc_s,iatsc_e
26861 ! print *,"I am in EVDW",i
26862 do icont=g_listscsc_start,g_listscsc_end
26863 i=newcontlisti(icont)
26864 j=newcontlistj(icont)
26866 itypi=iabs(itype(i,1))
26867 ! if (i.ne.47) cycle
26868 if (itypi.eq.ntyp1) cycle
26869 itypi1=iabs(itype(i+1,1))
26873 call to_box(xi,yi,zi)
26874 call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
26876 ! print *, sslipi,ssgradlipi
26877 dxi=dc_norm(1,nres+i)
26878 dyi=dc_norm(2,nres+i)
26879 dzi=dc_norm(3,nres+i)
26880 ! dsci_inv=dsc_inv(itypi)
26881 dsci_inv=vbld_inv(i+nres)
26882 ! write (iout,*) "i",i,dsc_inv(itypi),dsci_inv,1.0d0/vbld(i+nres)
26883 ! write (iout,*) "dcnori",dxi*dxi+dyi*dyi+dzi*dzi
26885 ! Calculate SC interaction energy.
26887 ! do iint=1,nint_gr(i)
26888 ! do j=istart(i,iint),iend(i,iint)
26889 ! print *,"JA PIER",i,j,iint,istart(i,iint),iend(i,iint)
26890 IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
26891 call dyn_ssbond_ene(i,j,evdwij,countss)
26893 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
26894 'evdw',i,j,evdwij,' ss'
26895 ! if (energy_dec) write (iout,*) &
26896 ! 'evdw',i,j,evdwij,' ss'
26897 do k=j+1,iend(i,iint)
26898 !C search over all next residues
26899 if (dyn_ss_mask(k)) then
26900 !C check if they are cysteins
26901 !C write(iout,*) 'k=',k
26903 !c write(iout,*) "PRZED TRI", evdwij
26904 ! evdwij_przed_tri=evdwij
26905 call triple_ssbond_ene(i,j,k,evdwij)
26906 !c if(evdwij_przed_tri.ne.evdwij) then
26907 !c write (iout,*) "TRI:", evdwij, evdwij_przed_tri
26910 !c write(iout,*) "PO TRI", evdwij
26911 !C call the energy function that removes the artifical triple disulfide
26912 !C bond the soubroutine is located in ssMD.F
26914 if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') &
26915 'evdw',i,j,evdwij,'tss'
26916 endif!dyn_ss_mask(k)
26920 itypj=iabs(itype(j,1))
26921 if (itypj.eq.ntyp1) cycle
26922 CALL elgrad_init(eheadtail,Egb,Ecl,Elj,Equad,Epol)
26924 ! if (j.ne.78) cycle
26925 ! dscj_inv=dsc_inv(itypj)
26926 dscj_inv=vbld_inv(j+nres)
26930 call to_box(xj,yj,zj)
26931 call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
26932 ! write(iout,*) "KRUWA", i,j
26933 aa=aa_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
26934 +aa_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
26935 bb=bb_lip(itypi,itypj)*(sslipi+sslipj)/2.0d0 &
26936 +bb_aq(itypi,itypj)*(2.0d0-sslipi-sslipj)/2.0d0
26937 xj=boxshift(xj-xi,boxxsize)
26938 yj=boxshift(yj-yi,boxysize)
26939 zj=boxshift(zj-zi,boxzsize)
26940 dxj = dc_norm( 1, nres+j )
26941 dyj = dc_norm( 2, nres+j )
26942 dzj = dc_norm( 3, nres+j )
26943 ! print *,i,j,itypi,itypj
26946 ! BetaT = 1.0d0 / (298.0d0 * Rb)
26948 !1! sig0ij = sigma_scsc( itypi,itypj )
26953 ! not used by momo potential, but needed by sc_angular which is shared
26954 ! by all energy_potential subroutines
26958 a12sq = rborn(itypi,itypj) * rborn(itypj,itypi)
26959 ! a12sq = a12sq * a12sq
26960 ! charge of amino acid itypi is...
26961 chis1 = chis(itypi,itypj)
26962 chis2 = chis(itypj,itypi)
26963 chis12 = chis1 * chis2
26964 sig1 = sigmap1(itypi,itypj)
26965 sig2 = sigmap2(itypi,itypj)
26966 ! write (*,*) "sig1 = ", sig1
26969 ! chis12 = chis1 * chis2
26972 ! write (*,*) "sig2 = ", sig2
26973 ! alpha factors from Fcav/Gcav
26974 b1cav = alphasur(1,itypi,itypj)
26976 b2cav = alphasur(2,itypi,itypj)
26977 b3cav = alphasur(3,itypi,itypj)
26978 b4cav = alphasur(4,itypi,itypj)
26979 ! used to determine whether we want to do quadrupole calculations
26980 eps_in = epsintab(itypi,itypj)
26981 if (eps_in.eq.0.0) eps_in=1.0
26983 eps_inout_fac = ( (1.0d0/eps_in) - (1.0d0/eps_out))
26985 ! dtail(1,itypi,itypj)=0.0
26986 ! dtail(2,itypi,itypj)=0.0
26989 ctail(k,1)=c(k,i+nres)-dtail(1,itypi,itypj)*dc_norm(k,nres+i)
26990 ctail(k,2)=c(k,j+nres)-dtail(2,itypi,itypj)*dc_norm(k,nres+j)
26992 call to_box (ctail(1,1),ctail(2,1),ctail(3,1))
26993 call to_box (ctail(1,2),ctail(2,2),ctail(3,2))
26995 !c! tail distances will be themselves usefull elswhere
26996 !c1 (in Gcav, for example)
26997 Rtail_distance(1)=boxshift(ctail( 1, 2 ) - ctail( 1,1 ),boxxsize)
26998 Rtail_distance(2)=boxshift(ctail( 2, 2 ) - ctail( 2,1 ),boxysize)
26999 Rtail_distance(3)=boxshift(ctail( 3, 2 ) - ctail( 3,1 ),boxzsize)
27001 (Rtail_distance(1)*Rtail_distance(1)) &
27002 + (Rtail_distance(2)*Rtail_distance(2)) &
27003 + (Rtail_distance(3)*Rtail_distance(3)))
27005 ! write (*,*) "eps_inout_fac = ", eps_inout_fac
27006 !-------------------------------------------------------------------
27007 ! tail location and distance calculations
27008 d1 = dhead(1, 1, itypi, itypj)
27009 d2 = dhead(2, 1, itypi, itypj)
27012 ! location of polar head is computed by taking hydrophobic centre
27013 ! and moving by a d1 * dc_norm vector
27014 ! see unres publications for very informative images
27015 chead(k,1) = c(k, i+nres) + d1 * dc_norm(k, i+nres)
27016 chead(k,2) = c(k, j+nres) + d2 * dc_norm(k, j+nres)
27019 if (energy_dec) write(iout,*) "before",chead(1,1),chead(2,1),chead(3,1)
27020 if (energy_dec) write(iout,*) "before",chead(1,2),chead(2,2),chead(3,2)
27021 call to_box (chead(1,1),chead(2,1),chead(3,1))
27022 call to_box (chead(1,2),chead(2,2),chead(3,2))
27024 !c! head distances will be themselves usefull elswhere
27025 !c1 (in Gcav, for example)
27026 if (energy_dec) write(iout,*) "after",chead(1,1),chead(2,1),chead(3,1)
27027 if (energy_dec) write(iout,*) "after",chead(1,2),chead(2,2),chead(3,2)
27029 Rhead_distance(1)=boxshift(chead( 1, 2 ) - chead( 1,1 ),boxxsize)
27030 Rhead_distance(2)=boxshift(chead( 2, 2 ) - chead( 2,1 ),boxysize)
27031 Rhead_distance(3)=boxshift(chead( 3, 2 ) - chead( 3,1 ),boxzsize)
27032 if (energy_dec) write(iout,*) "after,rdi",(Rhead_distance(k),k=1,3)
27033 ! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
27034 ! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
27035 ! Rhead_distance(k) = chead(k,2) - chead(k,1)
27037 ! pitagoras (root of sum of squares)
27039 (Rhead_distance(1)*Rhead_distance(1)) &
27040 + (Rhead_distance(2)*Rhead_distance(2)) &
27041 + (Rhead_distance(3)*Rhead_distance(3)))
27042 !-------------------------------------------------------------------
27043 ! zero everything that should be zero'ed
27061 dscj_inv = vbld_inv(j+nres)
27062 ! print *,i,j,dscj_inv,dsci_inv
27063 ! rij holds 1/(distance of Calpha atoms)
27064 rrij = 1.0D0 / ( xj*xj + yj*yj + zj*zj)
27066 sss_ele_cut=sscale_ele(1.0d0/(rij))
27067 sss_ele_grad=sscagrad_ele(1.0d0/(rij))
27068 ! print *,sss_ele_cut,sss_ele_grad,&
27069 ! 1.0d0/(rij),r_cut_ele,rlamb_ele
27070 if (sss_ele_cut.le.0.0) cycle
27072 !----------------------------
27074 ! this should be in elgrad_init but om's are calculated by sc_angular
27075 ! which in turn is used by older potentials
27076 ! om = omega, sqom = om^2
27079 sqom12 = om12 * om12
27081 ! now we calculate EGB - Gey-Berne
27082 ! It will be summed up in evdwij and saved in evdw
27083 sigsq = 1.0D0 / sigsq
27084 sig = sig0ij * dsqrt(sigsq)
27085 ! rij_shift = 1.0D0 / rij - sig + sig0ij
27086 rij_shift = Rtail - sig + sig0ij
27087 IF (rij_shift.le.0.0D0) THEN
27091 sigder = -sig * sigsq
27092 rij_shift = 1.0D0 / rij_shift
27093 fac = rij_shift**expon
27094 c1 = fac * fac * aa_aq(itypi,itypj)
27095 ! print *,"ADAM",aa_aq(itypi,itypj)
27098 c2 = fac * bb_aq(itypi,itypj)
27100 evdwij = eps1 * eps2rt * eps3rt * ( c1 + c2 )
27101 eps2der = eps3rt * evdwij
27102 eps3der = eps2rt * evdwij
27103 ! evdwij = 4.0d0 * eps2rt * eps3rt * evdwij
27104 evdwij = eps2rt * eps3rt * evdwij
27106 ! IF (bb_aq(itypi,itypj).gt.0) THEN
27107 ! evdw_p = evdw_p + evdwij
27109 ! evdw_m = evdw_m + evdwij
27113 + evdwij*sss_ele_cut
27116 c1 = c1 * eps1 * eps2rt**2 * eps3rt**2
27117 fac = -expon * (c1 + evdwij) * rij_shift
27118 sigder = fac * sigder
27120 ! Calculate distance derivative
27121 gg(1) = fac*sss_ele_cut+evdwij*sss_ele_grad
27122 gg(2) = fac*sss_ele_cut+evdwij*sss_ele_grad
27123 gg(3) = fac*sss_ele_cut+evdwij*sss_ele_grad
27124 ! if (b2.gt.0.0) then
27125 fac = chis1 * sqom1 + chis2 * sqom2 &
27126 - 2.0d0 * chis12 * om1 * om2 * om12
27127 ! we will use pom later in Gcav, so dont mess with it!
27128 pom = 1.0d0 - chis1 * chis2 * sqom12
27129 Lambf = (1.0d0 - (fac / pom))
27130 ! print *,"fac,pom",fac,pom,Lambf
27131 Lambf = dsqrt(Lambf)
27132 sparrow = 1.0d0 / dsqrt(sig1**2.0d0 + sig2**2.0d0)
27133 ! print *,"sig1,sig2",sig1,sig2,itypi,itypj
27134 ! write (*,*) "sparrow = ", sparrow
27135 Chif = Rtail * sparrow
27136 ! print *,"rij,sparrow",rij , sparrow
27137 ChiLambf = Chif * Lambf
27138 eagle = dsqrt(ChiLambf)
27139 bat = ChiLambf ** 11.0d0
27140 top = b1cav * ( eagle + b2cav * ChiLambf - b3cav )
27141 bot = 1.0d0 + b4cav * (ChiLambf ** 12.0d0)
27143 ! print *,top,bot,"bot,top",ChiLambf,Chif
27146 dtop = b1cav * ((Lambf / (2.0d0 * eagle)) + (b2cav * Lambf))
27147 dbot = 12.0d0 * b4cav * bat * Lambf
27148 dFdR = ((dtop * bot - top * dbot) / botsq) * sparrow*sss_ele_cut&
27151 dtop = b1cav * ((Chif / (2.0d0 * eagle)) + (b2cav * Chif))
27152 dbot = 12.0d0 * b4cav * bat * Chif
27153 eagle = Lambf * pom
27154 dFdOM1 = -(chis1 * om1 - chis12 * om2 * om12) / (eagle)
27155 dFdOM2 = -(chis2 * om2 - chis12 * om1 * om12) / (eagle)
27156 dFdOM12 = chis12 * (chis1 * om1 * om12 - om2) &
27157 * (chis2 * om2 * om12 - om1) / (eagle * pom)
27159 dFdL = ((dtop * bot - top * dbot) / botsq)
27161 dCAVdOM1 = dFdL * ( dFdOM1 )
27162 dCAVdOM2 = dFdL * ( dFdOM2 )
27163 dCAVdOM12 = dFdL * ( dFdOM12 )
27166 ertail(k) = Rtail_distance(k)/Rtail
27168 erdxi = scalar( ertail(1), dC_norm(1,i+nres) )
27169 erdxj = scalar( ertail(1), dC_norm(1,j+nres) )
27170 facd1 = dtail(1,itypi,itypj) * vbld_inv(i+nres)
27171 facd2 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
27173 !c! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
27174 !c! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
27175 pom = ertail(k)-facd1*(ertail(k)-erdxi*dC_norm(k,i+nres))
27176 gvdwx(k,i) = gvdwx(k,i) &
27177 - (( dFdR + gg(k) ) * pom)
27178 !c! & - ( dFdR * pom )
27179 pom = ertail(k)-facd2*(ertail(k)-erdxj*dC_norm(k,j+nres))
27180 gvdwx(k,j) = gvdwx(k,j) &
27181 + (( dFdR + gg(k) ) * pom)
27182 !c! & + ( dFdR * pom )
27184 gvdwc(k,i) = gvdwc(k,i) &
27185 - (( dFdR + gg(k) ) * ertail(k))
27186 !c! & - ( dFdR * ertail(k))
27188 gvdwc(k,j) = gvdwc(k,j) &
27189 + (( dFdR + gg(k) ) * ertail(k))
27190 !c! & + ( dFdR * ertail(k))
27193 ! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
27194 ! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
27198 !c! Compute head-head and head-tail energies for each state
27200 isel = iabs(Qi) + iabs(Qj)
27201 ! double charge for Phophorylated! itype - 25,27,27
27202 ! if ((itype(i).eq.27).or.(itype(i).eq.26).or.(itype(i).eq.25)) then
27206 ! if ((itype(j).eq.27).or.(itype(j).eq.26).or.(itype(j).eq.25)) then
27212 IF (isel.eq.0) THEN
27213 !c! No charges - do nothing
27216 ELSE IF (isel.eq.4) THEN
27217 !c! Calculate dipole-dipole interactions
27220 ! eheadtail = 0.0d0
27222 ELSE IF (isel.eq.1 .and. iabs(Qi).eq.1) THEN
27223 !c! Charge-nonpolar interactions
27224 if ((itype(i,1).eq.27).or.(itype(i,1).eq.26).or.(itype(i,1).eq.25)) then
27228 if ((itype(j,1).eq.27).or.(itype(j,1).eq.26).or.(itype(j,1).eq.25)) then
27235 ! eheadtail = 0.0d0
27237 ELSE IF (isel.eq.1 .and. iabs(Qj).eq.1) THEN
27238 !c! Nonpolar-charge interactions
27239 if ((itype(i,1).eq.27).or.(itype(i,1).eq.26).or.(itype(i,1).eq.25)) then
27243 if ((itype(j,1).eq.27).or.(itype(j,1).eq.26).or.(itype(j,1).eq.25)) then
27250 ! eheadtail = 0.0d0
27252 ELSE IF (isel.eq.3 .and. icharge(itypj).eq.2) THEN
27253 !c! Charge-dipole interactions
27254 if ((itype(i,1).eq.27).or.(itype(i,1).eq.26).or.(itype(i,1).eq.25)) then
27258 if ((itype(j,1).eq.27).or.(itype(j,1).eq.26).or.(itype(j,1).eq.25)) then
27263 CALL eqd(ecl, elj, epol)
27264 eheadtail = ECL + elj + epol
27265 ! eheadtail = 0.0d0
27267 ELSE IF (isel.eq.3 .and. icharge(itypi).eq.2) THEN
27268 !c! Dipole-charge interactions
27269 if ((itype(i,1).eq.27).or.(itype(i,1).eq.26).or.(itype(i,1).eq.25)) then
27273 if ((itype(j,1).eq.27).or.(itype(j,1).eq.26).or.(itype(j,1).eq.25)) then
27277 CALL edq(ecl, elj, epol)
27278 eheadtail = ECL + elj + epol
27279 ! eheadtail = 0.0d0
27281 ELSE IF ((isel.eq.2.and. &
27282 iabs(Qi).eq.1).and. &
27283 nstate(itypi,itypj).eq.1) THEN
27284 !c! Same charge-charge interaction ( +/+ or -/- )
27285 if ((itype(i,1).eq.27).or.(itype(i,1).eq.26).or.(itype(i,1).eq.25)) then
27289 if ((itype(j,1).eq.27).or.(itype(j,1).eq.26).or.(itype(j,1).eq.25)) then
27294 CALL eqq(Ecl,Egb,Epol,Fisocav,Elj)
27295 eheadtail = ECL + Egb + Epol + Fisocav + Elj
27296 ! eheadtail = 0.0d0
27298 ELSE IF ((isel.eq.2.and. &
27299 iabs(Qi).eq.1).and. &
27300 nstate(itypi,itypj).ne.1) THEN
27301 !c! Different charge-charge interaction ( +/- or -/+ )
27302 if ((itype(i,1).eq.27).or.(itype(i,1).eq.26).or.(itype(i,1).eq.25)) then
27306 if ((itype(j,1).eq.27).or.(itype(j,1).eq.26).or.(itype(j,1).eq.25)) then
27311 CALL energy_quad(istate,eheadtail,Ecl,Egb,Epol,Fisocav,Elj,Equad)
27313 END IF ! this endif ends the "catch the gly-gly" at the beggining of Fcav
27314 evdw = evdw + Fcav + eheadtail
27316 IF (energy_dec) write (iout,'(2(1x,a3,i3),3f6.2,10f16.7)') &
27317 restyp(itype(i,1),1),i,restyp(itype(j,1),1),j,&
27318 1.0d0/rij,Rtail,Rhead,evdwij,Fcav,Ecl,Egb,Epol,Fisocav,Elj,&
27319 Equad,evdwij+Fcav+eheadtail,evdw
27320 ! evdw = evdw + Fcav + eheadtail
27322 iF (nstate(itypi,itypj).eq.1) THEN
27325 !c!-------------------------------------------------------------------
27330 !c write (iout,*) "Number of loop steps in EGB:",ind
27331 !c energy_dec=.false.
27332 ! print *,"EVDW KURW",evdw,nres
27335 END SUBROUTINE emomo
27336 !C------------------------------------------------------------------------------------
27337 SUBROUTINE eqq(Ecl,Egb,Epol,Fisocav,Elj)
27340 real (kind=8) :: facd3, facd4, federmaus, adler,&
27341 Ecl,Egb,Epol,Fisocav,Elj,Fgb,debkap
27343 !c! Epol and Gpol analytical parameters
27344 alphapol1 = alphapol(itypi,itypj)
27345 alphapol2 = alphapol(itypj,itypi)
27346 !c! Fisocav and Gisocav analytical parameters
27347 al1 = alphiso(1,itypi,itypj)
27348 al2 = alphiso(2,itypi,itypj)
27349 al3 = alphiso(3,itypi,itypj)
27350 al4 = alphiso(4,itypi,itypj)
27352 / dsqrt(sigiso1(itypi, itypj)**2.0d0 &
27353 + sigiso2(itypi,itypj)**2.0d0))
27355 pis = sig0head(itypi,itypj)
27356 eps_head = epshead(itypi,itypj)
27357 Rhead_sq = Rhead * Rhead
27358 !c! R1 - distance between head of ith side chain and tail of jth sidechain
27359 !c! R2 - distance between head of jth side chain and tail of ith sidechain
27363 !c! Calculate head-to-tail distances needed by Epol
27364 R1=R1+(ctail(k,2)-chead(k,1))**2
27365 R2=R2+(chead(k,2)-ctail(k,1))**2
27371 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
27372 !c! & +dhead(1,1,itypi,itypj))**2))
27373 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
27374 !c! & +dhead(2,1,itypi,itypj))**2))
27376 !c!-------------------------------------------------------------------
27377 !c! Coulomb electrostatic interaction
27378 Ecl = (332.0d0 * Qij) / Rhead
27379 !c! derivative of Ecl is Gcl...
27380 dGCLdR = (-332.0d0 * Qij ) / Rhead_sq*sss_ele_cut+ECL*sss_ele_grad
27384 ECL=ECL*sss_ele_grad
27385 ee0 = dexp(-( Rhead_sq ) / (4.0d0 * a12sq))
27386 Fgb = sqrt( ( Rhead_sq ) + a12sq * ee0)
27387 debkap=debaykap(itypi,itypj)
27388 Egb = -(332.0d0 * Qij *&
27389 (1.0/eps_in-dexp(-debkap*Fgb)/eps_out)) / Fgb
27390 ! print *,"EGB WTF",Qij,eps_inout_fac,Fgb,itypi,itypj,eps_in,eps_out
27391 !c! Derivative of Egb is Ggb...
27392 dGGBdFGB = -(-332.0d0 * Qij * &
27393 (1.0/eps_in-dexp(-debkap*Fgb)/eps_out))/(Fgb*Fgb)&
27395 (dexp(-debkap*Fgb)*debkap/eps_out))/ Fgb
27396 dFGBdR = ( Rhead * ( 2.0d0 - (0.5d0 * ee0) ) )/ ( 2.0d0 * Fgb )
27397 dGGBdR = dGGBdFGB * dFGBdR*sss_ele_cut+Egb*sss_ele_grad
27398 Egb=Egb*sss_ele_cut
27399 !c!-------------------------------------------------------------------
27400 !c! Fisocav - isotropic cavity creation term
27401 !c! or "how much energy it costs to put charged head in water"
27403 top = al1 * (dsqrt(pom) + al2 * pom - al3)
27404 bot = (1.0d0 + al4 * pom**12.0d0)
27406 FisoCav = top / bot
27407 ! write (*,*) "Rhead = ",Rhead
27408 ! write (*,*) "csig = ",csig
27409 ! write (*,*) "pom = ",pom
27410 ! write (*,*) "al1 = ",al1
27411 ! write (*,*) "al2 = ",al2
27412 ! write (*,*) "al3 = ",al3
27413 ! write (*,*) "al4 = ",al4
27414 ! write (*,*) "top = ",top
27415 ! write (*,*) "bot = ",bot
27416 !c! Derivative of Fisocav is GCV...
27417 dtop = al1 * ((1.0d0 / (2.0d0 * dsqrt(pom))) + al2)
27418 dbot = 12.0d0 * al4 * pom ** 11.0d0
27419 dGCVdR = ((dtop * bot - top * dbot) / botsq) * csig
27420 !c!-------------------------------------------------------------------
27422 !c! Polarization energy - charged heads polarize hydrophobic "neck"
27423 MomoFac1 = (1.0d0 - chi1 * sqom2)
27424 MomoFac2 = (1.0d0 - chi2 * sqom1)
27425 RR1 = ( R1 * R1 ) / MomoFac1
27426 RR2 = ( R2 * R2 ) / MomoFac2
27427 ee1 = exp(-( RR1 / (4.0d0 * a12sq) ))
27428 ee2 = exp(-( RR2 / (4.0d0 * a12sq) ))
27429 fgb1 = sqrt( RR1 + a12sq * ee1 )
27430 fgb2 = sqrt( RR2 + a12sq * ee2 )
27431 epol = 332.0d0 * eps_inout_fac * ( &
27432 (( alphapol1 / fgb1 )**4.0d0)+((alphapol2/fgb2) ** 4.0d0 ))
27434 dPOLdFGB1 = -(1328.0d0 * eps_inout_fac * alphapol1 ** 4.0d0)&
27436 dPOLdFGB2 = -(1328.0d0 * eps_inout_fac * alphapol2 ** 4.0d0)&
27438 dFGBdR1 = ( (R1 / MomoFac1)* ( 2.0d0 - (0.5d0 * ee1) ) )&
27440 dFGBdR2 = ( (R2 / MomoFac2)* ( 2.0d0 - (0.5d0 * ee2) ) )&
27442 dFGBdOM2 = (((R1 * R1 * chi1 * om2) / (MomoFac1 * MomoFac1))&
27443 * ( 2.0d0 - 0.5d0 * ee1) ) / ( 2.0d0 * fgb1 )
27444 dFGBdOM1 = (((R2 * R2 * chi2 * om1) / (MomoFac2 * MomoFac2))&
27445 * ( 2.0d0 - 0.5d0 * ee2) ) / ( 2.0d0 * fgb2 )
27446 dPOLdR1 = dPOLdFGB1 * dFGBdR1*sss_ele_cut
27447 !c! dPOLdR1 = 0.0d0
27448 dPOLdR2 = dPOLdFGB2 * dFGBdR2*sss_ele_cut
27449 !c! dPOLdR2 = 0.0d0
27450 dPOLdOM1 = dPOLdFGB2 * dFGBdOM1
27451 !c! dPOLdOM1 = 0.0d0
27452 dPOLdOM2 = dPOLdFGB1 * dFGBdOM2
27453 !c! dPOLdOM2 = 0.0d0
27454 !c!-------------------------------------------------------------------
27456 !c! Lennard-Jones 6-12 interaction between heads
27457 pom = (pis / Rhead)**6.0d0
27458 Elj = 4.0d0 * eps_head * pom * (pom-1.0d0)
27459 !c! derivative of Elj is Glj
27460 dGLJdR = 4.0d0 * eps_head*(((-12.0d0*pis**12.0d0)/(Rhead**13.0d0))&
27461 + (( 6.0d0*pis**6.0d0) /(Rhead**7.0d0)))*sss_ele_cut+&
27462 (ELJ+epol)*sss_ele_grad
27463 epol=epol*sss_ele_cut
27464 Elj=Elj*sss_ele_cut
27465 !c!-------------------------------------------------------------------
27466 !c! Return the results
27467 !c! These things do the dRdX derivatives, that is
27468 !c! allow us to change what we see from function that changes with
27469 !c! distance to function that changes with LOCATION (of the interaction
27472 erhead(k) = Rhead_distance(k)/Rhead
27473 erhead_tail(k,1) = ((ctail(k,2)-chead(k,1))/R1)
27474 erhead_tail(k,2) = ((chead(k,2)-ctail(k,1))/R2)
27477 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
27478 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
27479 bat = scalar( erhead_tail(1,1), dC_norm(1,i+nres) )
27480 federmaus = scalar(erhead_tail(1,1),dC_norm(1,j+nres))
27481 eagle = scalar( erhead_tail(1,2), dC_norm(1,j+nres) )
27482 adler = scalar( erhead_tail(1,2), dC_norm(1,i+nres) )
27483 facd1 = d1 * vbld_inv(i+nres)
27484 facd2 = d2 * vbld_inv(j+nres)
27485 facd3 = dtail(1,itypi,itypj) * vbld_inv(i+nres)
27486 facd4 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
27488 !c! Now we add appropriate partial derivatives (one in each dimension)
27490 hawk = (erhead_tail(k,1) + &
27491 facd1 * (erhead_tail(k,1) - bat * dC_norm(k,i+nres)))
27492 condor = (erhead_tail(k,2) + &
27493 facd2 * (erhead_tail(k,2) - eagle * dC_norm(k,j+nres)))
27495 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
27496 gvdwx(k,i) = gvdwx(k,i) &
27501 - dPOLdR2 * (erhead_tail(k,2)&
27502 -facd3 * (erhead_tail(k,2) - adler * dC_norm(k,i+nres)))&
27505 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
27506 gvdwx(k,j) = gvdwx(k,j)+ dGCLdR * pom&
27507 + dGGBdR * pom+ dGCVdR * pom&
27508 + dPOLdR1 * (erhead_tail(k,1)&
27509 -facd4 * (erhead_tail(k,1) - federmaus * dC_norm(k,j+nres)))&
27510 + dPOLdR2 * condor + dGLJdR * pom
27512 gvdwc(k,i) = gvdwc(k,i) &
27513 - dGCLdR * erhead(k)&
27514 - dGGBdR * erhead(k)&
27515 - dGCVdR * erhead(k)&
27516 - dPOLdR1 * erhead_tail(k,1)&
27517 - dPOLdR2 * erhead_tail(k,2)&
27518 - dGLJdR * erhead(k)
27520 gvdwc(k,j) = gvdwc(k,j) &
27521 + dGCLdR * erhead(k) &
27522 + dGGBdR * erhead(k) &
27523 + dGCVdR * erhead(k) &
27524 + dPOLdR1 * erhead_tail(k,1) &
27525 + dPOLdR2 * erhead_tail(k,2)&
27526 + dGLJdR * erhead(k)
27532 SUBROUTINE eqq_cat(Ecl,Egb,Epol,Fisocav,Elj)
27535 real (kind=8) :: facd3, facd4, federmaus, adler,&
27536 Ecl,Egb,Epol,Fisocav,Elj,Fgb,debkap
27538 !c! Epol and Gpol analytical parameters
27539 alphapol1 = alphapolcat(itypi,itypj)
27540 alphapol2 = alphapolcat2(itypj,itypi)
27541 !c! Fisocav and Gisocav analytical parameters
27542 al1 = alphisocat(1,itypi,itypj)
27543 al2 = alphisocat(2,itypi,itypj)
27544 al3 = alphisocat(3,itypi,itypj)
27545 al4 = alphisocat(4,itypi,itypj)
27547 / dsqrt(sigiso1cat(itypi, itypj)**2.0d0 &
27548 + sigiso2cat(itypi,itypj)**2.0d0))
27550 pis = sig0headcat(itypi,itypj)
27551 eps_head = epsheadcat(itypi,itypj)
27552 Rhead_sq = Rhead * Rhead
27553 !c! R1 - distance between head of ith side chain and tail of jth sidechain
27554 !c! R2 - distance between head of jth side chain and tail of ith sidechain
27558 !c! Calculate head-to-tail distances needed by Epol
27559 R1=R1+(ctail(k,2)-chead(k,1))**2
27560 R2=R2+(chead(k,2)-ctail(k,1))**2
27566 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
27567 !c! & +dhead(1,1,itypi,itypj))**2))
27568 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
27569 !c! & +dhead(2,1,itypi,itypj))**2))
27571 !c!-------------------------------------------------------------------
27572 !c! Coulomb electrostatic interaction
27573 Ecl = (332.0d0 * Qij) / Rhead
27574 !c! derivative of Ecl is Gcl...
27575 dGCLdR = (-332.0d0 * Qij ) / Rhead_sq*sss_ele_cut+ECL*sss_ele_grad
27576 ECL=ECL*sss_ele_cut
27581 ee0 = dexp(-( Rhead_sq ) / (4.0d0 * a12sq))
27582 Fgb = sqrt( ( Rhead_sq ) + a12sq * ee0)
27583 debkap=debaykapcat(itypi,itypj)
27584 if (energy_dec) write(iout,*) "egb",Qij,debkap,Fgb,a12sq,ee0
27585 Egb = -(332.0d0 * Qij *&
27586 (1.0/eps_in-dexp(-debkap*Fgb)/eps_out)) / Fgb
27587 ! print *,"EGB WTF",Qij,eps_inout_fac,Fgb,itypi,itypj,eps_in,eps_out
27588 !c! Derivative of Egb is Ggb...
27589 dGGBdFGB = -(-332.0d0 * Qij * &
27590 (1.0/eps_in-dexp(-debkap*Fgb)/eps_out))/(Fgb*Fgb)&
27592 (dexp(-debkap*Fgb)*debkap/eps_out))/ Fgb
27593 dFGBdR = ( Rhead * ( 2.0d0 - (0.5d0 * ee0) ) )/ ( 2.0d0 * Fgb )
27594 dGGBdR = dGGBdFGB * dFGBdR*sss_ele_cut+Egb*sss_ele_grad
27595 Egb=Egb*sss_ele_grad
27596 !c!-------------------------------------------------------------------
27597 !c! Fisocav - isotropic cavity creation term
27598 !c! or "how much energy it costs to put charged head in water"
27600 top = al1 * (dsqrt(pom) + al2 * pom - al3)
27601 bot = (1.0d0 + al4 * pom**12.0d0)
27603 FisoCav = top / bot
27604 ! write (*,*) "Rhead = ",Rhead
27605 ! write (*,*) "csig = ",csig
27606 ! write (*,*) "pom = ",pom
27607 ! write (*,*) "al1 = ",al1
27608 ! write (*,*) "al2 = ",al2
27609 ! write (*,*) "al3 = ",al3
27610 ! write (*,*) "al4 = ",al4
27611 ! write (*,*) "top = ",top
27612 ! write (*,*) "bot = ",bot
27613 !c! Derivative of Fisocav is GCV...
27614 dtop = al1 * ((1.0d0 / (2.0d0 * dsqrt(pom))) + al2)
27615 dbot = 12.0d0 * al4 * pom ** 11.0d0
27616 dGCVdR = ((dtop * bot - top * dbot) / botsq) * csig*sss_ele_cut&
27617 +FisoCav*sss_ele_grad
27618 FisoCav=FisoCav*sss_ele_cut
27619 !c!-------------------------------------------------------------------
27621 !c! Polarization energy - charged heads polarize hydrophobic "neck"
27622 MomoFac1 = (1.0d0 - chi1 * sqom2)
27623 MomoFac2 = (1.0d0 - chi2 * sqom1)
27624 RR1 = ( R1 * R1 ) / MomoFac1
27625 RR2 = ( R2 * R2 ) / MomoFac2
27626 ee1 = exp(-( RR1 / (4.0d0 * a12sq) ))
27627 ee2 = exp(-( RR2 / (4.0d0 * a12sq) ))
27628 fgb1 = sqrt( RR1 + a12sq * ee1 )
27629 fgb2 = sqrt( RR2 + a12sq * ee2 )
27630 epol = 332.0d0 * eps_inout_fac * ( &
27631 (( alphapol1 / fgb1 )**4.0d0)+((alphapol2/fgb2) ** 4.0d0 ))
27633 dPOLdFGB1 = -(1328.0d0 * eps_inout_fac * alphapol1 ** 4.0d0)&
27635 dPOLdFGB2 = -(1328.0d0 * eps_inout_fac * alphapol2 ** 4.0d0)&
27637 dFGBdR1 = ( (R1 / MomoFac1)* ( 2.0d0 - (0.5d0 * ee1) ) )&
27639 dFGBdR2 = ( (R2 / MomoFac2)* ( 2.0d0 - (0.5d0 * ee2) ) )&
27641 dFGBdOM2 = (((R1 * R1 * chi1 * om2) / (MomoFac1 * MomoFac1))&
27642 * ( 2.0d0 - 0.5d0 * ee1) ) / ( 2.0d0 * fgb1 )
27643 dFGBdOM1 = (((R2 * R2 * chi2 * om1) / (MomoFac2 * MomoFac2))&
27644 * ( 2.0d0 - 0.5d0 * ee2) ) / ( 2.0d0 * fgb2 )
27645 dPOLdR1 = dPOLdFGB1 * dFGBdR1!*sss_ele_cut+epol*sss_ele_grad
27646 !c! dPOLdR1 = 0.0d0
27647 dPOLdR2 = dPOLdFGB2 * dFGBdR2!*sss_ele_cut+epol*sss_ele_grad
27648 !c! dPOLdR2 = 0.0d0
27649 dPOLdOM1 = dPOLdFGB2 * dFGBdOM1
27650 !c! dPOLdOM1 = 0.0d0
27651 dPOLdOM2 = dPOLdFGB1 * dFGBdOM2
27652 ! epol=epol*sss_ele_cut
27653 !c! dPOLdOM2 = 0.0d0
27654 !c!-------------------------------------------------------------------
27656 !c! Lennard-Jones 6-12 interaction between heads
27657 pom = (pis / Rhead)**6.0d0
27658 Elj = 4.0d0 * eps_head * pom * (pom-1.0d0)
27659 !c! derivative of Elj is Glj
27660 dGLJdR = 4.0d0 * eps_head*(((-12.0d0*pis**12.0d0)/(Rhead**13.0d0))&
27661 + (( 6.0d0*pis**6.0d0) /(Rhead**7.0d0)))*sss_ele_cut&
27662 +(Elj+epol)*sss_ele_grad
27663 Elj=Elj*sss_ele_cut
27664 epol=epol*sss_ele_cut
27665 !c!-------------------------------------------------------------------
27666 !c! Return the results
27667 !c! These things do the dRdX derivatives, that is
27668 !c! allow us to change what we see from function that changes with
27669 !c! distance to function that changes with LOCATION (of the interaction
27672 erhead(k) = Rhead_distance(k)/Rhead
27673 erhead_tail(k,1) = ((ctail(k,2)-chead(k,1))/R1)
27674 erhead_tail(k,2) = ((chead(k,2)-ctail(k,1))/R2)
27677 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
27678 erdxj = scalar( erhead(1), dC_norm(1,j) )
27679 bat = scalar( erhead_tail(1,1), dC_norm(1,i+nres) )
27680 federmaus = scalar(erhead_tail(1,1),dC_norm(1,j))
27681 eagle = scalar( erhead_tail(1,2), dC_norm(1,j) )
27682 adler = scalar( erhead_tail(1,2), dC_norm(1,i+nres) )
27683 facd1 = d1 * vbld_inv(i+nres)
27684 facd2 = d2 * vbld_inv(j)
27685 facd3 = dtailcat(1,itypi,itypj) * vbld_inv(i+nres)
27686 facd4 = dtailcat(2,itypi,itypj) * vbld_inv(j)
27688 !c! Now we add appropriate partial derivatives (one in each dimension)
27690 hawk = (erhead_tail(k,1) + &
27691 facd1 * (erhead_tail(k,1) - bat * dC_norm(k,i+nres)))
27692 condor = (erhead_tail(k,2) + &
27693 facd2 * (erhead_tail(k,2) - eagle * dC_norm(k,j)))
27695 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
27696 gradpepcatx(k,i) = gradpepcatx(k,i) &
27701 - dPOLdR2 * (erhead_tail(k,2)&
27702 -facd3 * (erhead_tail(k,2) - adler * dC_norm(k,i+nres)))&
27705 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j))
27706 ! gradpepcatx(k,j) = gradpepcatx(k,j)+ dGCLdR * pom&
27707 ! + dGGBdR * pom+ dGCVdR * pom&
27708 ! + dPOLdR1 * (erhead_tail(k,1)&
27709 ! -facd4 * (erhead_tail(k,1) - federmaus * dC_norm(k,j)))&
27710 ! + dPOLdR2 * condor + dGLJdR * pom
27712 gradpepcat(k,i) = gradpepcat(k,i) &
27713 - dGCLdR * erhead(k)&
27714 - dGGBdR * erhead(k)&
27715 - dGCVdR * erhead(k)&
27716 - dPOLdR1 * erhead_tail(k,1)&
27717 - dPOLdR2 * erhead_tail(k,2)&
27718 - dGLJdR * erhead(k)
27720 gradpepcat(k,j) = gradpepcat(k,j) &
27721 + dGCLdR * erhead(k) &
27722 + dGGBdR * erhead(k) &
27723 + dGCVdR * erhead(k) &
27724 + dPOLdR1 * erhead_tail(k,1) &
27725 + dPOLdR2 * erhead_tail(k,2)&
27726 + dGLJdR * erhead(k)
27730 END SUBROUTINE eqq_cat
27731 !c!-------------------------------------------------------------------
27732 SUBROUTINE energy_quad(istate,eheadtail,Ecl,Egb,Epol,Fisocav,Elj,Equad)
27736 double precision eheadtail,Ecl,Egb,Epol,Fisocav,Elj,Equad
27737 double precision ener(4)
27738 double precision dcosom1(3),dcosom2(3)
27739 !c! used in Epol derivatives
27740 double precision facd3, facd4
27741 double precision federmaus, adler
27742 integer istate,ii,jj
27743 real (kind=8) :: Fgb
27744 ! print *,"CALLING EQUAD"
27745 !c! Epol and Gpol analytical parameters
27746 alphapol1 = alphapol(itypi,itypj)
27747 alphapol2 = alphapol(itypj,itypi)
27748 !c! Fisocav and Gisocav analytical parameters
27749 al1 = alphiso(1,itypi,itypj)
27750 al2 = alphiso(2,itypi,itypj)
27751 al3 = alphiso(3,itypi,itypj)
27752 al4 = alphiso(4,itypi,itypj)
27753 csig = (1.0d0 / dsqrt(sigiso1(itypi, itypj)**2.0d0&
27754 + sigiso2(itypi,itypj)**2.0d0))
27756 w1 = wqdip(1,itypi,itypj)
27757 w2 = wqdip(2,itypi,itypj)
27758 pis = sig0head(itypi,itypj)
27759 eps_head = epshead(itypi,itypj)
27760 !c! First things first:
27761 !c! We need to do sc_grad's job with GB and Fcav
27762 eom1 = eps2der * eps2rt_om1 &
27763 - 2.0D0 * alf1 * eps3der&
27764 + sigder * sigsq_om1&
27766 eom2 = eps2der * eps2rt_om2 &
27767 + 2.0D0 * alf2 * eps3der&
27768 + sigder * sigsq_om2&
27770 eom12 = evdwij * eps1_om12 &
27771 + eps2der * eps2rt_om12 &
27772 - 2.0D0 * alf12 * eps3der&
27773 + sigder *sigsq_om12&
27775 !c! now some magical transformations to project gradient into
27776 !c! three cartesian vectors
27778 dcosom1(k) = rij * (dc_norm(k,nres+i) - om1 * erij(k))
27779 dcosom2(k) = rij * (dc_norm(k,nres+j) - om2 * erij(k))
27780 gg(k) = gg(k) + eom1 * dcosom1(k) + eom2 * dcosom2(k)
27781 !c! this acts on hydrophobic center of interaction
27782 gvdwx(k,i)= gvdwx(k,i) - gg(k)*sss_ele_cut &
27783 + (eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))&
27784 + eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv*sss_ele_cut
27785 gvdwx(k,j)= gvdwx(k,j) + gg(k)*sss_ele_cut &
27786 + (eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j))&
27787 + eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv*sss_ele_cut
27788 !c! this acts on Calpha
27789 gvdwc(k,i)=gvdwc(k,i)-gg(k)*sss_ele_cut
27790 gvdwc(k,j)=gvdwc(k,j)+gg(k)*sss_ele_cut
27792 !c! sc_grad is done, now we will compute
27797 DO istate = 1, nstate(itypi,itypj)
27798 !c*************************************************************
27799 IF (istate.ne.1) THEN
27800 IF (istate.lt.3) THEN
27806 d1 = dhead(1,ii,itypi,itypj)
27807 d2 = dhead(2,jj,itypi,itypj)
27809 chead(k,1) = c(k, i+nres) + d1 * dc_norm(k, i+nres)
27810 chead(k,2) = c(k, j+nres) + d2 * dc_norm(k, j+nres)
27813 call to_box (chead(1,1),chead(2,1),chead(3,1))
27814 call to_box (chead(1,2),chead(2,2),chead(3,2))
27816 !c! head distances will be themselves usefull elswhere
27817 !c1 (in Gcav, for example)
27819 Rhead_distance(1)=boxshift(chead( 1, 2 ) - chead( 1,1 ),boxxsize)
27820 Rhead_distance(2)=boxshift(chead( 2, 2 ) - chead( 2,1 ),boxysize)
27821 Rhead_distance(3)=boxshift(chead( 3, 2 ) - chead( 3,1 ),boxzsize)
27822 ! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
27823 ! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
27824 ! Rhead_distance(k) = chead(k,2) - chead(k,1)
27826 ! pitagoras (root of sum of squares)
27828 (Rhead_distance(1)*Rhead_distance(1)) &
27829 + (Rhead_distance(2)*Rhead_distance(2)) &
27830 + (Rhead_distance(3)*Rhead_distance(3)))
27833 ! chead(k,1) = c(k, i+nres) + d1 * dc_norm(k, i+nres)
27834 ! chead(k,2) = c(k, j+nres) + d2 * dc_norm(k, j+nres)
27835 ! Rhead_distance(k) = chead(k,2) - chead(k,1)
27837 !c! pitagoras (root of sum of squares)
27839 ! (Rhead_distance(1)*Rhead_distance(1)) &
27840 ! + (Rhead_distance(2)*Rhead_distance(2)) &
27841 ! + (Rhead_distance(3)*Rhead_distance(3)))
27843 Rhead_sq = Rhead * Rhead
27845 !c! R1 - distance between head of ith side chain and tail of jth sidechain
27846 !c! R2 - distance between head of jth side chain and tail of ith sidechain
27850 !c! Calculate head-to-tail distances
27851 R1=R1+(ctail(k,2)-chead(k,1))**2
27852 R2=R2+(chead(k,2)-ctail(k,1))**2
27857 Ecl = (332.0d0 * Qij) / (Rhead * eps_in)
27859 !c! write (*,*) "Ecl = ", Ecl
27860 !c! derivative of Ecl is Gcl...
27861 dGCLdR = (-332.0d0 * Qij ) / (Rhead_sq * eps_in)*sss_ele_cut+ECL*sss_ele_grad
27862 ECL=ecl*sss_ele_cut
27867 !c!-------------------------------------------------------------------
27868 !c! Generalised Born Solvent Polarization
27869 ee0 = dexp(-( Rhead_sq ) / (4.0d0 * a12sq))
27870 Fgb = sqrt( ( Rhead_sq ) + a12sq * ee0)
27871 Egb = -(332.0d0 * Qij * eps_inout_fac) / Fgb
27873 !c! write (*,*) "a1*a2 = ", a12sq
27874 !c! write (*,*) "Rhead = ", Rhead
27875 !c! write (*,*) "Rhead_sq = ", Rhead_sq
27876 !c! write (*,*) "ee = ", ee
27877 !c! write (*,*) "Fgb = ", Fgb
27878 !c! write (*,*) "fac = ", eps_inout_fac
27879 !c! write (*,*) "Qij = ", Qij
27880 !c! write (*,*) "Egb = ", Egb
27881 !c! Derivative of Egb is Ggb...
27882 !c! dFGBdR is used by Quad's later...
27883 dGGBdFGB = -(-332.0d0 * Qij * eps_inout_fac) / (Fgb * Fgb)
27884 dFGBdR = ( Rhead * ( 2.0d0 - (0.5d0 * ee0) ) )&
27886 dGGBdR = dGGBdFGB * dFGBdR*sss_ele_cut+Egb*sss_ele_grad
27887 Egb=Egb*sss_ele_cut
27889 !c!-------------------------------------------------------------------
27890 !c! Fisocav - isotropic cavity creation term
27892 top = al1 * (dsqrt(pom) + al2 * pom - al3)
27893 bot = (1.0d0 + al4 * pom**12.0d0)
27895 FisoCav = top / bot
27896 dtop = al1 * ((1.0d0 / (2.0d0 * dsqrt(pom))) + al2)
27897 dbot = 12.0d0 * al4 * pom ** 11.0d0
27898 dGCVdR = ((dtop * bot - top * dbot) / botsq) * csig*sss_ele_cut+FisoCav*sss_ele_grad
27899 FisoCav=FisoCav*sss_ele_cut
27902 !c!-------------------------------------------------------------------
27903 !c! Polarization energy
27905 MomoFac1 = (1.0d0 - chi1 * sqom2)
27906 MomoFac2 = (1.0d0 - chi2 * sqom1)
27907 RR1 = ( R1 * R1 ) / MomoFac1
27908 RR2 = ( R2 * R2 ) / MomoFac2
27909 ee1 = exp(-( RR1 / (4.0d0 * a12sq) ))
27910 ee2 = exp(-( RR2 / (4.0d0 * a12sq) ))
27911 fgb1 = sqrt( RR1 + a12sq * ee1 )
27912 fgb2 = sqrt( RR2 + a12sq * ee2 )
27913 epol = 332.0d0 * eps_inout_fac * (&
27914 (( alphapol1 / fgb1 )**4.0d0)+((alphapol2/fgb2) ** 4.0d0 ))
27916 !c! derivative of Epol is Gpol...
27917 dPOLdFGB1 = -(1328.0d0 * eps_inout_fac * alphapol1 ** 4.0d0)&
27919 dPOLdFGB2 = -(1328.0d0 * eps_inout_fac * alphapol2 ** 4.0d0)&
27921 dFGBdR1 = ( (R1 / MomoFac1) &
27922 * ( 2.0d0 - (0.5d0 * ee1) ) )&
27924 dFGBdR2 = ( (R2 / MomoFac2) &
27925 * ( 2.0d0 - (0.5d0 * ee2) ) ) &
27927 dFGBdOM2 = (((R1 * R1 * chi1 * om2) / (MomoFac1 * MomoFac1)) &
27928 * ( 2.0d0 - 0.5d0 * ee1) ) &
27930 dFGBdOM1 = (((R2 * R2 * chi2 * om1) / (MomoFac2 * MomoFac2)) &
27931 * ( 2.0d0 - 0.5d0 * ee2) ) &
27933 dPOLdR1 = dPOLdFGB1 * dFGBdR1*sss_ele_cut
27934 !c! dPOLdR1 = 0.0d0
27935 dPOLdR2 = dPOLdFGB2 * dFGBdR2*sss_ele_cut
27936 !c! dPOLdR2 = 0.0d0
27937 dPOLdOM1 = dPOLdFGB2 * dFGBdOM1
27938 !c! dPOLdOM1 = 0.0d0
27939 dPOLdOM2 = dPOLdFGB1 * dFGBdOM2
27940 pom = (pis / Rhead)**6.0d0
27941 Elj = 4.0d0 * eps_head * pom * (pom-1.0d0)
27943 !c! derivative of Elj is Glj
27944 dGLJdR = 4.0d0 * eps_head &
27945 * (((-12.0d0*pis**12.0d0)/(Rhead**13.0d0)) &
27946 + (( 6.0d0*pis**6.0d0) /(Rhead**7.0d0)))*sss_ele_cut+&
27947 (epol+Elj)*sss_ele_grad
27948 Elj=Elj*sss_ele_cut
27949 epol=epol*sss_ele_cut
27951 !c!-------------------------------------------------------------------
27953 IF (Wqd.ne.0.0d0) THEN
27954 Beta1 = 5.0d0 + 3.0d0 * (sqom12 - 1.0d0) &
27955 - 37.5d0 * ( sqom1 + sqom2 ) &
27956 + 157.5d0 * ( sqom1 * sqom2 ) &
27957 - 45.0d0 * om1*om2*om12
27958 fac = -( Wqd / (2.0d0 * Fgb**5.0d0) )
27959 Equad = fac * Beta1
27961 !c! derivative of Equad...
27962 dQUADdR = ((2.5d0 * Wqd * Beta1) / (Fgb**6.0d0)) * dFGBdR*sss_ele_cut&
27963 + Equad*sss_ele_grad
27964 Equad=Equad*sss_ele_cut
27965 !c! dQUADdR = 0.0d0
27966 dQUADdOM1 = fac* (-75.0d0*om1 + 315.0d0*om1*sqom2 - 45.0d0*om2*om12)
27967 !c! dQUADdOM1 = 0.0d0
27968 dQUADdOM2 = fac* (-75.0d0*om2 + 315.0d0*sqom1*om2 - 45.0d0*om1*om12)
27969 !c! dQUADdOM2 = 0.0d0
27970 dQUADdOM12 = fac * ( 6.0d0*om12 - 45.0d0*om1*om2 )
27975 !c!-------------------------------------------------------------------
27976 !c! Return the results
27978 eom1 = dPOLdOM1 + dQUADdOM1
27979 eom2 = dPOLdOM2 + dQUADdOM2
27981 !c! now some magical transformations to project gradient into
27982 !c! three cartesian vectors
27984 dcosom1(k) = rij * (dc_norm(k,nres+i) - om1 * erij(k))
27985 dcosom2(k) = rij * (dc_norm(k,nres+j) - om2 * erij(k))
27986 tuna(k) = eom1 * dcosom1(k) + eom2 * dcosom2(k)*sss_ele_cut
27990 erhead(k) = Rhead_distance(k)/Rhead
27991 erhead_tail(k,1) = ((ctail(k,2)-chead(k,1))/R1)
27992 erhead_tail(k,2) = ((chead(k,2)-ctail(k,1))/R2)
27994 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
27995 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
27996 bat = scalar( erhead_tail(1,1), dC_norm(1,i+nres) )
27997 federmaus = scalar(erhead_tail(1,1),dC_norm(1,j+nres))
27998 eagle = scalar( erhead_tail(1,2), dC_norm(1,j+nres) )
27999 adler = scalar( erhead_tail(1,2), dC_norm(1,i+nres) )
28000 facd1 = d1 * vbld_inv(i+nres)
28001 facd2 = d2 * vbld_inv(j+nres)
28002 facd3 = dtail(1,itypi,itypj) * vbld_inv(i+nres)
28003 facd4 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
28005 hawk = erhead_tail(k,1) + &
28006 facd1 * (erhead_tail(k,1) - bat * dC_norm(k,i+nres))
28007 condor = erhead_tail(k,2) + &
28008 facd2 * (erhead_tail(k,2) - eagle * dC_norm(k,j+nres))
28010 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
28011 !c! this acts on hydrophobic center of interaction
28012 gheadtail(k,1,1) = gheadtail(k,1,1) &
28017 - dPOLdR2 * (erhead_tail(k,2) &
28018 -facd3 * (erhead_tail(k,2) - adler * dC_norm(k,i+nres)))&
28022 + (eom12*(dc_norm(k,nres+j)-om12*dc_norm(k,nres+i))&
28023 + eom1*(erij(k)-om1*dc_norm(k,nres+i)))*dsci_inv*sss_ele_cut
28025 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
28026 !c! this acts on hydrophobic center of interaction
28027 gheadtail(k,2,1) = gheadtail(k,2,1) &
28031 + dPOLdR1 * (erhead_tail(k,1) &
28032 -facd4 * (erhead_tail(k,1) - federmaus * dC_norm(k,j+nres))) &
28033 + dPOLdR2 * condor &
28037 + (eom12*(dc_norm(k,nres+i)-om12*dc_norm(k,nres+j)) &
28038 + eom2*(erij(k)-om2*dc_norm(k,nres+j)))*dscj_inv*sss_ele_cut
28040 !c! this acts on Calpha
28041 gheadtail(k,3,1) = gheadtail(k,3,1) &
28042 - dGCLdR * erhead(k)&
28043 - dGGBdR * erhead(k)&
28044 - dGCVdR * erhead(k)&
28045 - dPOLdR1 * erhead_tail(k,1)&
28046 - dPOLdR2 * erhead_tail(k,2)&
28047 - dGLJdR * erhead(k) &
28048 - dQUADdR * erhead(k)&
28050 !c! this acts on Calpha
28051 gheadtail(k,4,1) = gheadtail(k,4,1) &
28052 + dGCLdR * erhead(k) &
28053 + dGGBdR * erhead(k) &
28054 + dGCVdR * erhead(k) &
28055 + dPOLdR1 * erhead_tail(k,1) &
28056 + dPOLdR2 * erhead_tail(k,2) &
28057 + dGLJdR * erhead(k) &
28058 + dQUADdR * erhead(k)&
28061 ener(istate) = ECL + Egb + Epol + Fisocav + Elj + Equad
28062 eheadtail = eheadtail &
28063 + wstate(istate, itypi, itypj) &
28064 * dexp(-betaT * ener(istate))
28065 !c! foreach cartesian dimension
28067 !c! foreach of two gvdwx and gvdwc
28069 gheadtail(k,l,2) = gheadtail(k,l,2) &
28070 + wstate( istate, itypi, itypj ) &
28071 * dexp(-betaT * ener(istate)) &
28073 gheadtail(k,l,1) = 0.0d0
28077 !c! Here ended the gigantic DO istate = 1, 4, which starts
28078 !c! at the beggining of the subroutine
28082 gheadtail(k,l,2) = gheadtail(k,l,2) / eheadtail
28084 gvdwx(k,i) = gvdwx(k,i) + gheadtail(k,1,2)
28085 gvdwx(k,j) = gvdwx(k,j) + gheadtail(k,2,2)
28086 gvdwc(k,i) = gvdwc(k,i) + gheadtail(k,3,2)
28087 gvdwc(k,j) = gvdwc(k,j) + gheadtail(k,4,2)
28089 gheadtail(k,l,1) = 0.0d0
28090 gheadtail(k,l,2) = 0.0d0
28093 eheadtail = (-dlog(eheadtail)) / betaT
28100 END SUBROUTINE energy_quad
28101 !!-----------------------------------------------------------
28102 SUBROUTINE eqn(Epol)
28106 double precision facd4, federmaus,epol
28107 alphapol1 = alphapol(itypi,itypj)
28108 !c! R1 - distance between head of ith side chain and tail of jth sidechain
28111 !c! Calculate head-to-tail distances
28112 R1=R1+(ctail(k,2)-chead(k,1))**2
28117 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
28118 !c! & +dhead(1,1,itypi,itypj))**2))
28119 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
28120 !c! & +dhead(2,1,itypi,itypj))**2))
28121 !c--------------------------------------------------------------------
28122 !c Polarization energy
28124 MomoFac1 = (1.0d0 - chi1 * sqom2)
28125 RR1 = R1 * R1 / MomoFac1
28126 ee1 = exp(-( RR1 / (4.0d0 * a12sq) ))
28127 fgb1 = sqrt( RR1 + a12sq * ee1)
28128 epol = 332.0d0 * eps_inout_fac * (( alphapol1 / fgb1 )**4.0d0)
28129 dPOLdFGB1 = -(1328.0d0 * eps_inout_fac * alphapol1 ** 4.0d0) &
28131 dFGBdR1 = ( (R1 / MomoFac1) &
28132 * ( 2.0d0 - (0.5d0 * ee1) ) ) &
28134 dFGBdOM2 = (((R1 * R1 * chi1 * om2) / (MomoFac1 * MomoFac1)) &
28135 * (2.0d0 - 0.5d0 * ee1) ) &
28137 dPOLdR1 = dPOLdFGB1 * dFGBdR1*sss_ele_cut+epol*sss_ele_grad
28138 epol=epol*sss_ele_cut
28139 !c! dPOLdR1 = 0.0d0
28141 dPOLdOM2 = dPOLdFGB1 * dFGBdOM2
28143 erhead_tail(k,1) = ((ctail(k,2)-chead(k,1))/R1)
28145 bat = scalar( erhead_tail(1,1), dC_norm(1,i+nres) )
28146 federmaus = scalar(erhead_tail(1,1),dC_norm(1,j+nres))
28147 facd1 = d1 * vbld_inv(i+nres)
28148 facd4 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
28151 hawk = (erhead_tail(k,1) + &
28152 facd1 * (erhead_tail(k,1) - bat * dC_norm(k,i+nres)))
28154 gvdwx(k,i) = gvdwx(k,i) &
28156 gvdwx(k,j) = gvdwx(k,j) &
28157 + dPOLdR1 * (erhead_tail(k,1) &
28158 -facd4 * (erhead_tail(k,1) - federmaus * dC_norm(k,j+nres)))
28160 gvdwc(k,i) = gvdwc(k,i) - dPOLdR1 * erhead_tail(k,1)
28161 gvdwc(k,j) = gvdwc(k,j) + dPOLdR1 * erhead_tail(k,1)
28166 SUBROUTINE enq(Epol)
28169 double precision facd3, adler,epol
28170 alphapol2 = alphapol(itypj,itypi)
28171 !c! R2 - distance between head of jth side chain and tail of ith sidechain
28174 !c! Calculate head-to-tail distances
28175 R2=R2+(chead(k,2)-ctail(k,1))**2
28180 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
28181 !c! & +dhead(1,1,itypi,itypj))**2))
28182 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
28183 !c! & +dhead(2,1,itypi,itypj))**2))
28184 !c------------------------------------------------------------------------
28185 !c Polarization energy
28186 MomoFac2 = (1.0d0 - chi2 * sqom1)
28187 RR2 = R2 * R2 / MomoFac2
28188 ee2 = exp(-(RR2 / (4.0d0 * a12sq)))
28189 fgb2 = sqrt(RR2 + a12sq * ee2)
28190 epol = 332.0d0 * eps_inout_fac * ((alphapol2/fgb2) ** 4.0d0 )
28191 dPOLdFGB2 = -(1328.0d0 * eps_inout_fac * alphapol2 ** 4.0d0) &
28193 dFGBdR2 = ( (R2 / MomoFac2) &
28194 * ( 2.0d0 - (0.5d0 * ee2) ) ) &
28196 dFGBdOM1 = (((R2 * R2 * chi2 * om1) / (MomoFac2 * MomoFac2)) &
28197 * (2.0d0 - 0.5d0 * ee2) ) &
28199 dPOLdR2 = dPOLdFGB2 * dFGBdR2*sss_ele_cut+epol*sss_ele_grad
28200 epol=epol*sss_ele_cut
28201 !c! dPOLdR2 = 0.0d0
28202 dPOLdOM1 = dPOLdFGB2 * dFGBdOM1
28203 !c! dPOLdOM1 = 0.0d0
28205 !c!-------------------------------------------------------------------
28206 !c! Return the results
28207 !c! (See comments in Eqq)
28209 erhead_tail(k,2) = ((chead(k,2)-ctail(k,1))/R2)
28211 eagle = scalar( erhead_tail(1,2), dC_norm(1,j+nres) )
28212 adler = scalar( erhead_tail(1,2), dC_norm(1,i+nres) )
28213 facd2 = d2 * vbld_inv(j+nres)
28214 facd3 = dtail(1,itypi,itypj) * vbld_inv(i+nres)
28216 condor = (erhead_tail(k,2) &
28217 + facd2 * (erhead_tail(k,2) - eagle * dC_norm(k,j+nres)))
28219 gvdwx(k,i) = gvdwx(k,i) &
28220 - dPOLdR2 * (erhead_tail(k,2) &
28221 -facd3 * (erhead_tail(k,2) - adler * dC_norm(k,i+nres)))
28222 gvdwx(k,j) = gvdwx(k,j) &
28225 gvdwc(k,i) = gvdwc(k,i) &
28226 - dPOLdR2 * erhead_tail(k,2)
28227 gvdwc(k,j) = gvdwc(k,j) &
28228 + dPOLdR2 * erhead_tail(k,2)
28234 SUBROUTINE enq_cat(Epol)
28237 double precision facd3, adler,epol
28238 alphapol2 = alphapolcat(itypi,itypj)
28239 !c! R2 - distance between head of jth side chain and tail of ith sidechain
28242 !c! Calculate head-to-tail distances
28243 R2=R2+(chead(k,2)-ctail(k,1))**2
28248 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
28249 !c! & +dhead(1,1,itypi,itypj))**2))
28250 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
28251 !c! & +dhead(2,1,itypi,itypj))**2))
28252 !c------------------------------------------------------------------------
28253 !c Polarization energy
28254 MomoFac2 = (1.0d0 - chi2 * sqom1)
28255 RR2 = R2 * R2 / MomoFac2
28256 ee2 = exp(-(RR2 / (4.0d0 * a12sq)))
28257 fgb2 = sqrt(RR2 + a12sq * ee2)
28258 epol = 332.0d0 * eps_inout_fac * ((alphapol2/fgb2) ** 4.0d0 )
28259 dPOLdFGB2 = -(1328.0d0 * eps_inout_fac * alphapol2 ** 4.0d0) &
28261 dFGBdR2 = ( (R2 / MomoFac2) &
28262 * ( 2.0d0 - (0.5d0 * ee2) ) ) &
28264 dFGBdOM1 = (((R2 * R2 * chi2 * om1) / (MomoFac2 * MomoFac2)) &
28265 * (2.0d0 - 0.5d0 * ee2) ) &
28267 dPOLdR2 = dPOLdFGB2 * dFGBdR2*sss_ele_cut+epol*sss_ele_grad
28268 epol=epol*sss_ele_cut
28269 !c! dPOLdR2 = 0.0d0
28270 dPOLdOM1 = dPOLdFGB2 * dFGBdOM1
28271 !c! dPOLdOM1 = 0.0d0
28274 !c!-------------------------------------------------------------------
28275 !c! Return the results
28276 !c! (See comments in Eqq)
28278 erhead_tail(k,2) = ((chead(k,2)-ctail(k,1))/R2)
28280 eagle = scalar( erhead_tail(1,2), dC_norm(1,j) )
28281 adler = scalar( erhead_tail(1,2), dC_norm(1,i+nres) )
28282 facd2 = d2 * vbld_inv(j+nres)
28283 facd3 = dtailcat(1,itypi,itypj) * vbld_inv(i+nres)
28285 condor = (erhead_tail(k,2) &
28286 + facd2 * (erhead_tail(k,2) - eagle * dC_norm(k,j)))
28288 gradpepcatx(k,i) = gradpepcatx(k,i) &
28289 - dPOLdR2 * (erhead_tail(k,2) &
28290 -facd3 * (erhead_tail(k,2) - adler * dC_norm(k,i+nres)))
28291 ! gradpepcatx(k,j) = gradpepcatx(k,j) &
28292 ! + dPOLdR2 * condor
28294 gradpepcat(k,i) = gradpepcat(k,i) &
28295 - dPOLdR2 * erhead_tail(k,2)
28296 gradpepcat(k,j) = gradpepcat(k,j) &
28297 + dPOLdR2 * erhead_tail(k,2)
28301 END SUBROUTINE enq_cat
28303 SUBROUTINE eqd(Ecl,Elj,Epol)
28306 double precision facd4, federmaus,ecl,elj,epol
28307 alphapol1 = alphapol(itypi,itypj)
28308 w1 = wqdip(1,itypi,itypj)
28309 w2 = wqdip(2,itypi,itypj)
28310 pis = sig0head(itypi,itypj)
28311 eps_head = epshead(itypi,itypj)
28312 !c!-------------------------------------------------------------------
28313 !c! R1 - distance between head of ith side chain and tail of jth sidechain
28316 !c! Calculate head-to-tail distances
28317 R1=R1+(ctail(k,2)-chead(k,1))**2
28322 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
28323 !c! & +dhead(1,1,itypi,itypj))**2))
28324 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
28325 !c! & +dhead(2,1,itypi,itypj))**2))
28327 !c!-------------------------------------------------------------------
28329 sparrow = w1 * Qi * om1
28330 hawk = w2 * Qi * Qi * (1.0d0 - sqom2)
28331 Ecl = sparrow / Rhead**2.0d0 &
28332 - hawk / Rhead**4.0d0
28333 dGCLdR = (- 2.0d0 * sparrow / Rhead**3.0d0 &
28334 + 4.0d0 * hawk / Rhead**5.0d0)*sss_ele_cut+Ecl*sss_ele_grad
28335 Ecl=Ecl*sss_ele_cut
28337 dGCLdOM1 = (w1 * Qi) / (Rhead**2.0d0)
28339 dGCLdOM2 = (2.0d0 * w2 * Qi * Qi * om2) / (Rhead ** 4.0d0)
28340 !c--------------------------------------------------------------------
28341 !c Polarization energy
28343 MomoFac1 = (1.0d0 - chi1 * sqom2)
28344 RR1 = R1 * R1 / MomoFac1
28345 ee1 = exp(-( RR1 / (4.0d0 * a12sq) ))
28346 fgb1 = sqrt( RR1 + a12sq * ee1)
28347 epol = 332.0d0 * eps_inout_fac * (( alphapol1 / fgb1 )**4.0d0)
28349 !c!------------------------------------------------------------------
28350 !c! derivative of Epol is Gpol...
28351 dPOLdFGB1 = -(1328.0d0 * eps_inout_fac * alphapol1 ** 4.0d0) &
28353 dFGBdR1 = ( (R1 / MomoFac1) &
28354 * ( 2.0d0 - (0.5d0 * ee1) ) ) &
28356 dFGBdOM2 = (((R1 * R1 * chi1 * om2) / (MomoFac1 * MomoFac1)) &
28357 * (2.0d0 - 0.5d0 * ee1) ) &
28359 dPOLdR1 = dPOLdFGB1 * dFGBdR1*sss_ele_cut+epol*sss_ele_grad
28360 !c! dPOLdR1 = 0.0d0
28362 dPOLdOM2 = dPOLdFGB1 * dFGBdOM2
28363 !c! dPOLdOM2 = 0.0d0
28364 !c!-------------------------------------------------------------------
28366 pom = (pis / Rhead)**6.0d0
28367 Elj = 4.0d0 * eps_head * pom * (pom-1.0d0)
28368 !c! derivative of Elj is Glj
28369 dGLJdR = 4.0d0 * eps_head &
28370 * (((-12.0d0*pis**12.0d0)/(Rhead**13.0d0)) &
28371 + (( 6.0d0*pis**6.0d0) /(Rhead**7.0d0)))*sss_ele_cut+elj*sss_ele_grad
28372 Elj=Elj*sss_ele_cut
28374 erhead(k) = Rhead_distance(k)/Rhead
28375 erhead_tail(k,1) = ((ctail(k,2)-chead(k,1))/R1)
28378 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
28379 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
28380 bat = scalar( erhead_tail(1,1), dC_norm(1,i+nres) )
28381 federmaus = scalar(erhead_tail(1,1),dC_norm(1,j+nres))
28382 facd1 = d1 * vbld_inv(i+nres)
28383 facd2 = d2 * vbld_inv(j+nres)
28384 facd4 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
28387 hawk = (erhead_tail(k,1) + &
28388 facd1 * (erhead_tail(k,1) - bat * dC_norm(k,i+nres)))
28390 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
28391 gvdwx(k,i) = gvdwx(k,i) &
28396 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
28397 gvdwx(k,j) = gvdwx(k,j) &
28399 + dPOLdR1 * (erhead_tail(k,1) &
28400 -facd4 * (erhead_tail(k,1) - federmaus * dC_norm(k,j+nres))) &
28404 gvdwc(k,i) = gvdwc(k,i) &
28405 - dGCLdR * erhead(k) &
28406 - dPOLdR1 * erhead_tail(k,1) &
28407 - dGLJdR * erhead(k)
28409 gvdwc(k,j) = gvdwc(k,j) &
28410 + dGCLdR * erhead(k) &
28411 + dPOLdR1 * erhead_tail(k,1) &
28412 + dGLJdR * erhead(k)
28418 SUBROUTINE eqd_cat(Ecl,Elj,Epol)
28421 double precision facd4, federmaus,ecl,elj,epol
28422 alphapol1 = alphapolcat(itypi,itypj)
28423 w1 = wqdipcat(1,itypi,itypj)
28424 w2 = wqdipcat(2,itypi,itypj)
28425 pis = sig0headcat(itypi,itypj)
28426 eps_head = epsheadcat(itypi,itypj)
28430 !c!-------------------------------------------------------------------
28431 !c! R1 - distance between head of ith side chain and tail of jth sidechain
28434 !c! Calculate head-to-tail distances
28435 R1=R1+(ctail(k,2)-chead(k,1))**2
28440 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
28441 !c! & +dhead(1,1,itypi,itypj))**2))
28442 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
28443 !c! & +dhead(2,1,itypi,itypj))**2))
28445 !c!-------------------------------------------------------------------
28447 sparrow = w1 * Qi * om1
28448 hawk = w2 * Qi * Qi * (1.0d0 - sqom2)
28449 Ecl = sparrow / Rhead**2.0d0 &
28450 - hawk / Rhead**4.0d0
28451 dGCLdR =sss_ele_cut*(-2.0d0 * sparrow / Rhead**3.0d0 &
28452 + 4.0d0 * hawk / Rhead**5.0d0)+sss_ele_grad*ECL
28453 ECL=ECL*sss_ele_cut
28455 dGCLdOM1 = (w1 * Qi) / (Rhead**2.0d0)
28459 !(2.0d0 * w2 * Qi * Qi * om2) / (Rhead ** 4.0d0)
28461 !c--------------------------------------------------------------------
28462 !c Polarization energy
28464 MomoFac1 = (1.0d0 - chi1 * sqom2)
28465 RR1 = R1 * R1 / MomoFac1
28466 ee1 = exp(-( RR1 / (4.0d0 * a12sq) ))
28467 fgb1 = sqrt( RR1 + a12sq * ee1)
28468 epol = 332.0d0 * eps_inout_fac * (( alphapol1 / fgb1 )**4.0d0)
28470 !c!------------------------------------------------------------------
28471 !c! derivative of Epol is Gpol...
28472 dPOLdFGB1 = -(1328.0d0 * eps_inout_fac * alphapol1 ** 4.0d0) &
28474 dFGBdR1 = ( (R1 / MomoFac1) &
28475 * ( 2.0d0 - (0.5d0 * ee1) ) ) &
28477 dFGBdOM2 = 0.0d0 ! as om2 is 0
28478 ! (((R1 * R1 * chi1 * om2) / (MomoFac1 * MomoFac1)) &
28479 ! * (2.0d0 - 0.5d0 * ee1) ) &
28481 dPOLdR1 = dPOLdFGB1 * dFGBdR1*sss_ele_cut+epol*sss_ele_grad
28482 !c! dPOLdR1 = 0.0d0
28484 ! dPOLdOM2 = dPOLdFGB1 * dFGBdOM2
28486 epol=epol*sss_ele_cut
28487 !c!-------------------------------------------------------------------
28489 pom = (pis / Rhead)**6.0d0
28490 Elj = 4.0d0 * eps_head * pom * (pom-1.0d0)
28491 !c! derivative of Elj is Glj
28492 dGLJdR = 4.0d0 * eps_head*sss_ele_cut &
28493 * (((-12.0d0*pis**12.0d0)/(Rhead**13.0d0)) &
28494 + (( 6.0d0*pis**6.0d0) /(Rhead**7.0d0)))+Elj*sss_ele_grad
28495 Elj=Elj*sss_ele_cut
28497 erhead(k) = Rhead_distance(k)/Rhead
28498 erhead_tail(k,1) = ((ctail(k,2)-chead(k,1))/R1)
28501 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
28502 bat = scalar( erhead_tail(1,1), dC_norm(1,i+nres) )
28503 facd1 = d1 * vbld_inv(i+nres)
28506 hawk = (erhead_tail(k,1) + &
28507 facd1 * (erhead_tail(k,1) - bat * dC_norm(k,i+nres)))
28509 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
28510 gradpepcatx(k,i) = gradpepcatx(k,i) &
28515 ! pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
28516 ! gradpepcatx(k,j) = gradpepcatx(k,j) &
28518 ! + dPOLdR1 * (erhead_tail(k,1) &
28519 ! -facd4 * (erhead_tail(k,1) - federmaus * dC_norm(k,j+nres))) &
28523 gradpepcat(k,i) = gradpepcat(k,i) &
28524 - dGCLdR * erhead(k) &
28525 - dPOLdR1 * erhead_tail(k,1) &
28526 - dGLJdR * erhead(k)
28528 gradpepcat(k,j) = gradpepcat(k,j) &
28529 + dGCLdR * erhead(k) &
28530 + dPOLdR1 * erhead_tail(k,1) &
28531 + dGLJdR * erhead(k)
28535 END SUBROUTINE eqd_cat
28537 SUBROUTINE edq(Ecl,Elj,Epol)
28542 double precision facd3, adler,ecl,elj,epol
28543 alphapol2 = alphapol(itypj,itypi)
28544 w1 = wqdip(1,itypi,itypj)
28545 w2 = wqdip(2,itypi,itypj)
28546 pis = sig0head(itypi,itypj)
28547 eps_head = epshead(itypi,itypj)
28548 !c!-------------------------------------------------------------------
28549 !c! R2 - distance between head of jth side chain and tail of ith sidechain
28552 !c! Calculate head-to-tail distances
28553 R2=R2+(chead(k,2)-ctail(k,1))**2
28558 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
28559 !c! & +dhead(1,1,itypi,itypj))**2))
28560 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
28561 !c! & +dhead(2,1,itypi,itypj))**2))
28564 !c!-------------------------------------------------------------------
28566 sparrow = w1 * Qj * om1
28567 hawk = w2 * Qj * Qj * (1.0d0 - sqom2)
28568 ECL = sparrow / Rhead**2.0d0 &
28569 - hawk / Rhead**4.0d0
28570 !c!-------------------------------------------------------------------
28571 !c! derivative of ecl is Gcl
28573 dGCLdR =sss_ele_cut*(- 2.0d0 * sparrow / Rhead**3.0d0 &
28574 + 4.0d0 * hawk / Rhead**5.0d0)+Ecl*sss_ele_grad
28576 dGCLdOM1 = (w1 * Qj) / (Rhead**2.0d0)
28578 dGCLdOM2 = (2.0d0 * w2 * Qj * Qj * om2) / (Rhead ** 4.0d0)
28579 !c--------------------------------------------------------------------
28580 !c Polarization energy
28582 MomoFac2 = (1.0d0 - chi2 * sqom1)
28583 RR2 = R2 * R2 / MomoFac2
28584 ee2 = exp(-(RR2 / (4.0d0 * a12sq)))
28585 fgb2 = sqrt(RR2 + a12sq * ee2)
28586 epol = 332.0d0 * eps_inout_fac * ((alphapol2/fgb2) ** 4.0d0 )
28587 dPOLdFGB2 = -(1328.0d0 * eps_inout_fac * alphapol2 ** 4.0d0) &
28589 dFGBdR2 = ( (R2 / MomoFac2) &
28590 * ( 2.0d0 - (0.5d0 * ee2) ) ) &
28592 dFGBdOM1 = (((R2 * R2 * chi2 * om1) / (MomoFac2 * MomoFac2)) &
28593 * (2.0d0 - 0.5d0 * ee2) ) &
28595 dPOLdR2 = dPOLdFGB2 * dFGBdR2*sss_ele_cut
28596 epol=epol*sss_ele_cut
28597 !c! dPOLdR2 = 0.0d0
28598 dPOLdOM1 = dPOLdFGB2 * dFGBdOM1
28599 !c! dPOLdOM1 = 0.0d0
28601 !c!-------------------------------------------------------------------
28603 pom = (pis / Rhead)**6.0d0
28604 Elj = 4.0d0 * eps_head * pom * (pom-1.0d0)
28605 !c! derivative of Elj is Glj
28606 dGLJdR = 4.0d0 * eps_head &
28607 * (((-12.0d0*pis**12.0d0)/(Rhead**13.0d0)) &
28608 + (( 6.0d0*pis**6.0d0) /(Rhead**7.0d0)))*sss_ele_cut+Elj*sss_ele_grad
28609 elj=elj*sss_ele_cut
28610 !c!-------------------------------------------------------------------
28611 !c! Return the results
28612 !c! (see comments in Eqq)
28614 erhead(k) = Rhead_distance(k)/Rhead
28615 erhead_tail(k,2) = ((chead(k,2)-ctail(k,1))/R2)
28617 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
28618 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
28619 eagle = scalar( erhead_tail(1,2), dC_norm(1,j+nres) )
28620 adler = scalar( erhead_tail(1,2), dC_norm(1,i+nres) )
28621 facd1 = d1 * vbld_inv(i+nres)
28622 facd2 = d2 * vbld_inv(j+nres)
28623 facd3 = dtail(1,itypi,itypj) * vbld_inv(i+nres)
28625 condor = (erhead_tail(k,2) &
28626 + facd2 * (erhead_tail(k,2) - eagle * dC_norm(k,j+nres)))
28628 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
28629 gvdwx(k,i) = gvdwx(k,i) &
28631 - dPOLdR2 * (erhead_tail(k,2) &
28632 -facd3 * (erhead_tail(k,2) - adler * dC_norm(k,i+nres))) &
28635 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
28636 gvdwx(k,j) = gvdwx(k,j) &
28638 + dPOLdR2 * condor &
28642 gvdwc(k,i) = gvdwc(k,i) &
28643 - dGCLdR * erhead(k) &
28644 - dPOLdR2 * erhead_tail(k,2) &
28645 - dGLJdR * erhead(k)
28647 gvdwc(k,j) = gvdwc(k,j) &
28648 + dGCLdR * erhead(k) &
28649 + dPOLdR2 * erhead_tail(k,2) &
28650 + dGLJdR * erhead(k)
28656 SUBROUTINE edq_cat(Ecl,Elj,Epol)
28660 double precision facd3, adler,ecl,elj,epol
28661 alphapol2 = alphapolcat(itypi,itypj)
28662 w1 = wqdipcat(1,itypi,itypj)
28663 w2 = wqdipcat(2,itypi,itypj)
28664 pis = sig0headcat(itypi,itypj)
28665 eps_head = epsheadcat(itypi,itypj)
28666 !c!-------------------------------------------------------------------
28667 !c! R2 - distance between head of jth side chain and tail of ith sidechain
28670 !c! Calculate head-to-tail distances
28671 R2=R2+(chead(k,2)-ctail(k,1))**2
28676 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
28677 !c! & +dhead(1,1,itypi,itypj))**2))
28678 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
28679 !c! & +dhead(2,1,itypi,itypj))**2))
28682 !c!-------------------------------------------------------------------
28684 ! write(iout,*) "KURWA2",Rhead
28685 sparrow = w1 * Qj * om1
28686 hawk = w2 * Qj * Qj * (1.0d0 - sqom2)
28687 ECL = sparrow / Rhead**2.0d0 &
28688 - hawk / Rhead**4.0d0
28689 !c!-------------------------------------------------------------------
28690 !c! derivative of ecl is Gcl
28692 dGCLdR =( - 2.0d0 * sparrow / Rhead**3.0d0 &
28693 + 4.0d0 * hawk / Rhead**5.0d0)*sss_ele_cut+ECL*sss_ele_grad
28695 dGCLdOM1 = (w1 * Qj) / (Rhead**2.0d0)
28697 dGCLdOM2 = (2.0d0 * w2 * Qj * Qj * om2) / (Rhead ** 4.0d0)
28698 ECL=ECL*sss_ele_cut
28699 !c--------------------------------------------------------------------
28700 !c--------------------------------------------------------------------
28701 !c Polarization energy
28703 MomoFac2 = (1.0d0 - chi2 * sqom1)
28704 RR2 = R2 * R2 / MomoFac2
28705 ee2 = exp(-(RR2 / (4.0d0 * a12sq)))
28706 fgb2 = sqrt(RR2 + a12sq * ee2)
28707 epol = 332.0d0 * eps_inout_fac * ((alphapol2/fgb2) ** 4.0d0 )
28708 dPOLdFGB2 = -(1328.0d0 * eps_inout_fac * alphapol2 ** 4.0d0) &
28710 dFGBdR2 = ( (R2 / MomoFac2) &
28711 * ( 2.0d0 - (0.5d0 * ee2) ) ) &
28713 dFGBdOM1 = (((R2 * R2 * chi2 * om1) / (MomoFac2 * MomoFac2)) &
28714 * (2.0d0 - 0.5d0 * ee2) ) &
28716 dPOLdR2 = dPOLdFGB2 * dFGBdR2*sss_ele_cut+epol*sss_ele_grad
28717 !c! dPOLdR2 = 0.0d0
28718 dPOLdOM1 = dPOLdFGB2 * dFGBdOM1
28719 !c! dPOLdOM1 = 0.0d0
28721 epol=epol*sss_ele_cut
28722 !c!-------------------------------------------------------------------
28724 pom = (pis / Rhead)**6.0d0
28725 Elj = 4.0d0 * eps_head * pom * (pom-1.0d0)
28726 !c! derivative of Elj is Glj
28727 dGLJdR = 4.0d0 * eps_head &
28728 * (((-12.0d0*pis**12.0d0)/(Rhead**13.0d0)) &
28729 + (( 6.0d0*pis**6.0d0) /(Rhead**7.0d0)))*sss_ele_cut+&
28731 Elj=Elj*sss_ele_cut
28732 !c!-------------------------------------------------------------------
28734 !c! Return the results
28735 !c! (see comments in Eqq)
28737 erhead(k) = Rhead_distance(k)/Rhead
28738 erhead_tail(k,2) = ((chead(k,2)-ctail(k,1))/R2)
28740 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
28741 erdxj = scalar( erhead(1), dC_norm(1,j) )
28742 eagle = scalar( erhead_tail(1,2), dC_norm(1,j) )
28743 adler = scalar( erhead_tail(1,2), dC_norm(1,i+nres) )
28744 facd1 = d1 * vbld_inv(i+nres)
28745 facd2 = d2 * vbld_inv(j)
28746 facd3 = dtailcat(1,itypi,itypj) * vbld_inv(i+nres)
28748 condor = (erhead_tail(k,2) &
28749 + facd2 * (erhead_tail(k,2) - eagle * dC_norm(k,j)))
28751 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
28752 gradpepcatx(k,i) = gradpepcatx(k,i) &
28754 - dPOLdR2 * (erhead_tail(k,2) &
28755 -facd3 * (erhead_tail(k,2) - adler * dC_norm(k,i+nres))) &
28758 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j))
28759 ! gradpepcatx(k,j) = gradpepcatx(k,j) &
28761 ! + dPOLdR2 * condor &
28765 gradpepcat(k,i) = gradpepcat(k,i) &
28766 - dGCLdR * erhead(k) &
28767 - dPOLdR2 * erhead_tail(k,2) &
28768 - dGLJdR * erhead(k)
28770 gradpepcat(k,j) = gradpepcat(k,j) &
28771 + dGCLdR * erhead(k) &
28772 + dPOLdR2 * erhead_tail(k,2) &
28773 + dGLJdR * erhead(k)
28777 END SUBROUTINE edq_cat
28779 SUBROUTINE edq_cat_pep(Ecl,Elj,Epol)
28783 double precision facd3, adler,ecl,elj,epol
28784 alphapol2 = alphapolcat(itypi,itypj)
28785 w1 = wqdipcat(1,itypi,itypj)
28786 w2 = wqdipcat(2,itypi,itypj)
28787 pis = sig0headcat(itypi,itypj)
28788 eps_head = epsheadcat(itypi,itypj)
28789 !c!-------------------------------------------------------------------
28790 !c! R2 - distance between head of jth side chain and tail of ith sidechain
28793 !c! Calculate head-to-tail distances
28794 R2=R2+(chead(k,2)-ctail(k,1))**2
28799 !c! R1 = dsqrt((Rtail**2)+((dtail(1,itypi,itypj)
28800 !c! & +dhead(1,1,itypi,itypj))**2))
28801 !c! R2 = dsqrt((Rtail**2)+((dtail(2,itypi,itypj)
28802 !c! & +dhead(2,1,itypi,itypj))**2))
28805 !c!-------------------------------------------------------------------
28807 sparrow = w1 * Qj * om1
28808 hawk = w2 * Qj * Qj * (1.0d0 - sqom2)
28809 ! print *,"CO2", itypi,itypj
28810 ! print *,"CO?!.", w1,w2,Qj,om1
28811 ECL = sparrow / Rhead**2.0d0 &
28812 - hawk / Rhead**4.0d0
28813 !c!-------------------------------------------------------------------
28814 !c! derivative of ecl is Gcl
28816 dGCLdR = (- 2.0d0 * sparrow / Rhead**3.0d0 &
28817 + 4.0d0 * hawk / Rhead**5.0d0)*sss_ele_cut+&
28819 ECL=ECL*sss_ele_cut
28821 dGCLdOM1 = (w1 * Qj) / (Rhead**2.0d0)
28823 dGCLdOM2 = (2.0d0 * w2 * Qj * Qj * om2) / (Rhead ** 4.0d0)
28824 !c--------------------------------------------------------------------
28825 !c--------------------------------------------------------------------
28826 !c Polarization energy
28828 MomoFac2 = (1.0d0 - chi2 * sqom1)
28829 RR2 = R2 * R2 / MomoFac2
28830 ee2 = exp(-(RR2 / (4.0d0 * a12sq)))
28831 fgb2 = sqrt(RR2 + a12sq * ee2)
28832 epol = 332.0d0 * eps_inout_fac * ((alphapol2/fgb2) ** 4.0d0 )
28833 dPOLdFGB2 = -(1328.0d0 * eps_inout_fac * alphapol2 ** 4.0d0) &
28835 dFGBdR2 = ( (R2 / MomoFac2) &
28836 * ( 2.0d0 - (0.5d0 * ee2) ) ) &
28838 dFGBdOM1 = (((R2 * R2 * chi2 * om1) / (MomoFac2 * MomoFac2)) &
28839 * (2.0d0 - 0.5d0 * ee2) ) &
28841 dPOLdR2 = dPOLdFGB2 * dFGBdR2*sss_ele_cut+epol*sss_ele_grad
28842 epol=epol*sss_ele_grad
28843 !c! dPOLdR2 = 0.0d0
28844 dPOLdOM1 = dPOLdFGB2 * dFGBdOM1
28845 !c! dPOLdOM1 = 0.0d0
28847 !c!-------------------------------------------------------------------
28849 pom = (pis / Rhead)**6.0d0
28850 Elj = 4.0d0 * eps_head * pom * (pom-1.0d0)
28851 !c! derivative of Elj is Glj
28852 dGLJdR = 4.0d0 * eps_head*sss_ele_cut &
28853 * (((-12.0d0*pis**12.0d0)/(Rhead**13.0d0)) &
28854 + (( 6.0d0*pis**6.0d0) /(Rhead**7.0d0)))+Elj*sss_ele_grad
28855 Elj=Elj*sss_ele_cut
28856 !c!-------------------------------------------------------------------
28858 !c! Return the results
28859 !c! (see comments in Eqq)
28861 erhead(k) = Rhead_distance(k)/Rhead
28862 erhead_tail(k,2) = ((chead(k,2)-ctail(k,1))/R2)
28864 erdxi = scalar( erhead(1), dC_norm(1,i) )
28865 erdxj = scalar( erhead(1), dC_norm(1,j) )
28866 eagle = scalar( erhead_tail(1,2), dC_norm(1,j) )
28867 adler = scalar( erhead_tail(1,2), dC_norm(1,i) )
28868 facd1 = d1 * vbld_inv(i+1)/2.0
28869 facd2 = d2 * vbld_inv(j)
28870 facd3 = dtailcat(1,itypi,itypj) * vbld_inv(i+1)/2.0
28872 condor = (erhead_tail(k,2) &
28873 + facd2 * (erhead_tail(k,2) - eagle * dC_norm(k,j)))
28875 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i))
28876 ! gradpepcatx(k,i) = gradpepcatx(k,i) &
28878 ! - dPOLdR2 * (erhead_tail(k,2) &
28879 ! -facd3 * (erhead_tail(k,2) - adler * dC_norm(k,i+nres))) &
28882 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j))
28883 ! gradpepcatx(k,j) = gradpepcatx(k,j) &
28885 ! + dPOLdR2 * condor &
28889 gradpepcat(k,i) = gradpepcat(k,i) +0.5d0*( &
28890 - dGCLdR * erhead(k) &
28891 - dPOLdR2 * erhead_tail(k,2) &
28892 - dGLJdR * erhead(k))
28893 gradpepcat(k,i+1) = gradpepcat(k,i+1) +0.5d0*( &
28894 - dGCLdR * erhead(k) &
28895 - dPOLdR2 * erhead_tail(k,2) &
28896 - dGLJdR * erhead(k))
28899 gradpepcat(k,j) = gradpepcat(k,j) &
28900 + dGCLdR * erhead(k) &
28901 + dPOLdR2 * erhead_tail(k,2) &
28902 + dGLJdR * erhead(k)
28906 END SUBROUTINE edq_cat_pep
28908 SUBROUTINE edd(ECL)
28913 double precision ecl
28914 !c! csig = sigiso(itypi,itypj)
28915 w1 = wqdip(1,itypi,itypj)
28916 w2 = wqdip(2,itypi,itypj)
28917 !c!-------------------------------------------------------------------
28919 fac = (om12 - 3.0d0 * om1 * om2)
28920 c1 = (w1 / (Rhead**3.0d0)) * fac
28921 c2 = (w2 / Rhead ** 6.0d0) &
28922 * (4.0d0 + fac * fac -3.0d0 * (sqom1 + sqom2))
28924 !c! write (*,*) "w1 = ", w1
28925 !c! write (*,*) "w2 = ", w2
28926 !c! write (*,*) "om1 = ", om1
28927 !c! write (*,*) "om2 = ", om2
28928 !c! write (*,*) "om12 = ", om12
28929 !c! write (*,*) "fac = ", fac
28930 !c! write (*,*) "c1 = ", c1
28931 !c! write (*,*) "c2 = ", c2
28932 !c! write (*,*) "Ecl = ", Ecl
28933 !c! write (*,*) "c2_1 = ", (w2 / Rhead ** 6.0d0)
28934 !c! write (*,*) "c2_2 = ",
28935 !c! & (4.0d0 + fac * fac -3.0d0 * (sqom1 + sqom2))
28936 !c!-------------------------------------------------------------------
28937 !c! dervative of ECL is GCL...
28939 c1 = (-3.0d0 * w1 * fac) / (Rhead ** 4.0d0)
28940 c2 = (-6.0d0 * w2) / (Rhead ** 7.0d0) &
28941 * (4.0d0 + fac * fac - 3.0d0 * (sqom1 + sqom2))
28942 dGCLdR = (c1 - c2)*sss_ele_cut+ECL*sss_ele_grad
28943 ECL=ECL*sss_ele_cut
28945 c1 = (-3.0d0 * w1 * om2 ) / (Rhead**3.0d0)
28946 c2 = (-6.0d0 * w2) / (Rhead**6.0d0) &
28947 * ( om2 * om12 - 3.0d0 * om1 * sqom2 + om1 )
28950 c1 = (-3.0d0 * w1 * om1 ) / (Rhead**3.0d0)
28951 c2 = (-6.0d0 * w2) / (Rhead**6.0d0) &
28952 * ( om1 * om12 - 3.0d0 * sqom1 * om2 + om2 )
28955 c1 = w1 / (Rhead ** 3.0d0)
28956 c2 = ( 2.0d0 * w2 * fac ) / Rhead ** 6.0d0
28957 dGCLdOM12 = c1 - c2
28958 !c!-------------------------------------------------------------------
28959 !c! Return the results
28960 !c! (see comments in Eqq)
28962 erhead(k) = Rhead_distance(k)/Rhead
28964 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
28965 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
28966 facd1 = d1 * vbld_inv(i+nres)
28967 facd2 = d2 * vbld_inv(j+nres)
28970 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
28971 gvdwx(k,i) = gvdwx(k,i) - dGCLdR * pom
28972 pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
28973 gvdwx(k,j) = gvdwx(k,j) + dGCLdR * pom
28975 gvdwc(k,i) = gvdwc(k,i) - dGCLdR * erhead(k)
28976 gvdwc(k,j) = gvdwc(k,j) + dGCLdR * erhead(k)
28980 SUBROUTINE edd_cat(ECL)
28985 double precision ecl
28986 !c! csig = sigiso(itypi,itypj)
28987 w1 = wqdipcat(1,itypi,itypj)
28988 w2 = wqdipcat(2,itypi,itypj)
28990 !c!-------------------------------------------------------------------
28992 ! print *,"om1",om1,om2,om12
28993 fac = - 3.0d0 * om1 !after integer and simplify
28994 c1 = (w1 / (Rhead**3.0d0)) * fac
28995 c2 = (w2 / Rhead ** 6.0d0) &
28996 * (4.0d0 + 6.0d0*sqom1 ) !after integration and simplification
28998 !c! dervative of ECL is GCL...
29000 c1 = (-3.0d0 * w1 * fac) / (Rhead ** 4.0d0)
29001 c2 = (-6.0d0 * w2) / (Rhead ** 7.0d0) &
29002 * (4.0d0 + 6.0d0*sqom1)
29003 dGCLdR = (c1 - c2)*sss_ele_cut+ECL*sss_ele_grad
29005 c1 = (-3.0d0 * w1) / (Rhead**3.0d0)
29006 c2 = (12.0d0 * w2*om1) / (Rhead**6.0d0)
29009 ! c1 = (-3.0d0 * w1 * om1 ) / (Rhead**3.0d0)
29010 c1=0.0 ! this is because om2 is 0
29011 ! c2 = (-6.0d0 * w2) / (Rhead**6.0d0) &
29012 ! * ( om1 * om12 - 3.0d0 * sqom1 * om2 + om2 )
29016 ! c1 = w1 / (Rhead ** 3.0d0)
29017 c1=0.0d0 ! this is because om12 is 0
29018 ! c2 = ( 2.0d0 * w2 * fac ) / Rhead ** 6.0d0
29019 c2=0.0d0 !om12 is 0
29020 dGCLdOM12 = c1 - c2
29021 !c!-------------------------------------------------------------------
29022 !c! Return the results
29023 !c! (see comments in Eqq)
29025 erhead(k) = Rhead_distance(k)/Rhead
29027 erdxi = scalar( erhead(1), dC_norm(1,i+nres) )
29028 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
29029 facd1 = d1 * vbld_inv(i+nres)
29030 facd2 = d2 * vbld_inv(j+nres)
29033 pom = erhead(k)+facd1*(erhead(k)-erdxi*dC_norm(k,i+nres))
29034 gradpepcatx(k,i) = gradpepcatx(k,i) - dGCLdR * pom
29035 ! pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
29036 ! gradpepcatx(k,j) = gradpepcatx(k,j) + dGCLdR * pom
29038 gradpepcat(k,i) = gradpepcat(k,i) - dGCLdR * erhead(k)
29039 gradpepcat(k,j) = gradpepcat(k,j) + dGCLdR * erhead(k)
29042 END SUBROUTINE edd_cat
29043 SUBROUTINE edd_cat_pep(ECL)
29048 double precision ecl
29049 !c! csig = sigiso(itypi,itypj)
29050 w1 = wqdipcat(1,itypi,itypj)
29051 w2 = wqdipcat(2,itypi,itypj)
29052 !c!-------------------------------------------------------------------
29054 fac = (om12 - 3.0d0 * om1 * om2)
29055 c1 = (w1 / (Rhead**3.0d0)) * fac
29056 c2 = (w2 / Rhead ** 6.0d0) &
29057 * (4.0d0 + fac * fac -3.0d0 * (sqom1 + sqom2))
29060 c1 = (-3.0d0 * w1 * fac) / (Rhead ** 4.0d0)
29061 c2 = (-6.0d0 * w2) / (Rhead ** 7.0d0) &
29062 * (4.0d0 + fac * fac - 3.0d0 * (sqom1 + sqom2))
29063 dGCLdR = (c1 - c2)*sss_ele_cut+ECL*sss_ele_grad
29064 ECL=ECL*sss_ele_cut
29066 c1 = (-3.0d0 * w1 * om2 ) / (Rhead**3.0d0)
29067 c2 = (-6.0d0 * w2) / (Rhead**6.0d0) &
29068 * ( om2 * om12 - 3.0d0 * om1 * sqom2 + om1 )
29071 c1 = (-3.0d0 * w1 * om1 ) / (Rhead**3.0d0)
29072 c2 = (-6.0d0 * w2) / (Rhead**6.0d0) &
29073 * ( om1 * om12 - 3.0d0 * sqom1 * om2 + om2 )
29075 dGCLdOM2=0.0d0 ! this is because om2=0
29077 c1 = w1 / (Rhead ** 3.0d0)
29078 c2 = ( 2.0d0 * w2 * fac ) / Rhead ** 6.0d0
29079 dGCLdOM12 = c1 - c2
29080 dGCLdOM12=0.0d0 !this is because om12=0.0
29081 !c!-------------------------------------------------------------------
29082 !c! Return the results
29083 !c! (see comments in Eqq)
29085 erhead(k) = Rhead_distance(k)/Rhead
29087 erdxi = scalar( erhead(1), dC_norm(1,i) )
29088 erdxj = scalar( erhead(1), dC_norm(1,j+nres) )
29089 facd1 = d1 * vbld_inv(i)
29090 facd2 = d2 * vbld_inv(j+nres)
29093 pom = facd1*(erhead(k)-erdxi*dC_norm(k,i))
29094 gradpepcat(k,i) = gradpepcat(k,i) + dGCLdR * pom
29095 gradpepcat(k,i+1) = gradpepcat(k,i+1) - dGCLdR * pom
29096 ! pom = erhead(k)+facd2*(erhead(k)-erdxj*dC_norm(k,j+nres))
29097 ! gradpepcatx(k,j) = gradpepcatx(k,j) + dGCLdR * pom
29099 gradpepcat(k,i) = gradpepcat(k,i) - dGCLdR * erhead(k)*0.5d0
29100 gradpepcat(k,i+1) = gradpepcat(k,i+1)- dGCLdR * erhead(k)*0.5d0
29101 gradpepcat(k,j) = gradpepcat(k,j) + dGCLdR * erhead(k)
29104 END SUBROUTINE edd_cat_pep
29106 SUBROUTINE elgrad_init(eheadtail,Egb,Ecl,Elj,Equad,Epol)
29111 real(kind=8) :: eheadtail,Egb,Ecl,Elj,Equad,Epol,Rb
29115 !c! 1/(Gas Constant * Thermostate temperature) = BetaT
29116 !c! ENABLE THIS LINE WHEN USING CHECKGRAD!!!
29118 !c! BetaT = 1.0d0 / (t_bath * Rb)i
29120 BetaT = 1.0d0 / (298.0d0 * Rb)
29121 !c! Gay-berne var's
29122 sig0ij = sigma( itypi,itypj )
29123 chi1 = chi( itypi, itypj )
29124 chi2 = chi( itypj, itypi )
29125 chi12 = chi1 * chi2
29126 chip1 = chipp( itypi, itypj )
29127 chip2 = chipp( itypj, itypi )
29128 chip12 = chip1 * chip2
29135 !c! not used by momo potential, but needed by sc_angular which is shared
29136 !c! by all energy_potential subroutines
29140 !c! location, location, location
29141 ! xj = c( 1, nres+j ) - xi
29142 ! yj = c( 2, nres+j ) - yi
29143 ! zj = c( 3, nres+j ) - zi
29144 dxj = dc_norm( 1, nres+j )
29145 dyj = dc_norm( 2, nres+j )
29146 dzj = dc_norm( 3, nres+j )
29147 !c! distance from center of chain(?) to polar/charged head
29148 !c! write (*,*) "istate = ", 1
29149 !c! write (*,*) "ii = ", 1
29150 !c! write (*,*) "jj = ", 1
29151 d1 = dhead(1, 1, itypi, itypj)
29152 d2 = dhead(2, 1, itypi, itypj)
29154 a12sq = rborn(itypi,itypj) * rborn(itypj,itypi)
29155 !c! a12sq = a12sq * a12sq
29156 !c! charge of amino acid itypi is...
29157 Qi = icharge(itypi)
29158 Qj = icharge(itypj)
29161 chis1 = chis(itypi,itypj)
29162 chis2 = chis(itypj,itypi)
29163 chis12 = chis1 * chis2
29164 sig1 = sigmap1(itypi,itypj)
29165 sig2 = sigmap2(itypi,itypj)
29166 !c! write (*,*) "sig1 = ", sig1
29167 !c! write (*,*) "sig2 = ", sig2
29168 !c! alpha factors from Fcav/Gcav
29169 b1cav = alphasur(1,itypi,itypj)
29171 b2cav = alphasur(2,itypi,itypj)
29172 b3cav = alphasur(3,itypi,itypj)
29173 b4cav = alphasur(4,itypi,itypj)
29174 wqd = wquad(itypi, itypj)
29176 eps_in = epsintab(itypi,itypj)
29177 eps_inout_fac = ( (1.0d0/eps_in) - (1.0d0/eps_out))
29178 !c! write (*,*) "eps_inout_fac = ", eps_inout_fac
29179 !c!-------------------------------------------------------------------
29180 !c! tail location and distance calculations
29183 ctail(k,1)=c(k,i+nres)-dtail(1,itypi,itypj)*dc_norm(k,nres+i)
29184 ctail(k,2)=c(k,j+nres)-dtail(2,itypi,itypj)*dc_norm(k,nres+j)
29186 !c! tail distances will be themselves usefull elswhere
29187 !c1 (in Gcav, for example)
29188 Rtail_distance(1) = ctail( 1, 2 ) - ctail( 1,1 )
29189 Rtail_distance(2) = ctail( 2, 2 ) - ctail( 2,1 )
29190 Rtail_distance(3) = ctail( 3, 2 ) - ctail( 3,1 )
29192 (Rtail_distance(1)*Rtail_distance(1)) &
29193 + (Rtail_distance(2)*Rtail_distance(2)) &
29194 + (Rtail_distance(3)*Rtail_distance(3)))
29195 !c!-------------------------------------------------------------------
29196 !c! Calculate location and distance between polar heads
29197 !c! distance between heads
29198 !c! for each one of our three dimensional space...
29199 d1 = dhead(1, 1, itypi, itypj)
29200 d2 = dhead(2, 1, itypi, itypj)
29203 !c! location of polar head is computed by taking hydrophobic centre
29204 !c! and moving by a d1 * dc_norm vector
29205 !c! see unres publications for very informative images
29206 chead(k,1) = c(k, i+nres) + d1 * dc_norm(k, i+nres)
29207 chead(k,2) = c(k, j+nres) + d2 * dc_norm(k, j+nres)
29209 !c! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
29210 !c! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
29211 Rhead_distance(k) = chead(k,2) - chead(k,1)
29213 !c! pitagoras (root of sum of squares)
29215 (Rhead_distance(1)*Rhead_distance(1)) &
29216 + (Rhead_distance(2)*Rhead_distance(2)) &
29217 + (Rhead_distance(3)*Rhead_distance(3)))
29218 !c!-------------------------------------------------------------------
29219 !c! zero everything that should be zero'ed
29232 END SUBROUTINE elgrad_init
29235 SUBROUTINE elgrad_init_cat(eheadtail,Egb,Ecl,Elj,Equad,Epol)
29238 real(kind=8) :: eheadtail,Egb,Ecl,Elj,Equad,Epol,Rb
29242 !c! 1/(Gas Constant * Thermostate temperature) = BetaT
29243 !c! ENABLE THIS LINE WHEN USING CHECKGRAD!!!
29245 !c! BetaT = 1.0d0 / (t_bath * Rb)i
29247 BetaT = 1.0d0 / (298.0d0 * Rb)
29248 !c! Gay-berne var's
29249 sig0ij = sigmacat( itypi,itypj )
29250 chi1 = chi1cat( itypi, itypj )
29253 chip1 = chipp1cat( itypi, itypj )
29256 !c! not used by momo potential, but needed by sc_angular which is shared
29257 !c! by all energy_potential subroutines
29261 dxj = 0.0d0 !dc_norm( 1, nres+j )
29262 dyj = 0.0d0 !dc_norm( 2, nres+j )
29263 dzj = 0.0d0 !dc_norm( 3, nres+j )
29264 !c! distance from center of chain(?) to polar/charged head
29265 d1 = dheadcat(1, 1, itypi, itypj)
29266 d2 = dheadcat(2, 1, itypi, itypj)
29268 a12sq = rborn1cat(itypi,itypj) * rborn2cat(itypi,itypj)
29269 !c! a12sq = a12sq * a12sq
29270 !c! charge of amino acid itypi is...
29271 Qi = icharge(itypi)
29272 Qj = ichargecat(itypj)
29275 chis1 = chis1cat(itypi,itypj)
29278 sig1 = sigmap1cat(itypi,itypj)
29279 sig2 = sigmap2cat(itypi,itypj)
29280 !c! alpha factors from Fcav/Gcav
29281 b1cav = alphasurcat(1,itypi,itypj)
29282 b2cav = alphasurcat(2,itypi,itypj)
29283 b3cav = alphasurcat(3,itypi,itypj)
29284 b4cav = alphasurcat(4,itypi,itypj)
29285 wqd = wquadcat(itypi, itypj)
29287 eps_in = epsintabcat(itypi,itypj)
29288 eps_inout_fac = ( (1.0d0/eps_in) - (1.0d0/eps_out))
29289 !c!-------------------------------------------------------------------
29290 !c! tail location and distance calculations
29293 ctail(k,1)=c(k,i+nres)-dtailcat(1,itypi,itypj)*dc_norm(k,nres+i)
29294 ctail(k,2)=c(k,j)!-dtailcat(2,itypi,itypj)*dc_norm(k,nres+j)
29296 !c! tail distances will be themselves usefull elswhere
29297 !c1 (in Gcav, for example)
29298 Rtail_distance(1) = ctail( 1, 2 ) - ctail( 1,1 )
29299 Rtail_distance(2) = ctail( 2, 2 ) - ctail( 2,1 )
29300 Rtail_distance(3) = ctail( 3, 2 ) - ctail( 3,1 )
29302 (Rtail_distance(1)*Rtail_distance(1)) &
29303 + (Rtail_distance(2)*Rtail_distance(2)) &
29304 + (Rtail_distance(3)*Rtail_distance(3)))
29305 !c!-------------------------------------------------------------------
29306 !c! Calculate location and distance between polar heads
29307 !c! distance between heads
29308 !c! for each one of our three dimensional space...
29309 d1 = dheadcat(1, 1, itypi, itypj)
29310 d2 = dheadcat(2, 1, itypi, itypj)
29313 !c! location of polar head is computed by taking hydrophobic centre
29314 !c! and moving by a d1 * dc_norm vector
29315 !c! see unres publications for very informative images
29316 chead(k,1) = c(k, i+nres) + d1 * dc_norm(k, i+nres)
29317 chead(k,2) = c(k, j)
29319 !c! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
29320 !c! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
29321 Rhead_distance(k) = chead(k,2) - chead(k,1)
29323 !c! pitagoras (root of sum of squares)
29325 (Rhead_distance(1)*Rhead_distance(1)) &
29326 + (Rhead_distance(2)*Rhead_distance(2)) &
29327 + (Rhead_distance(3)*Rhead_distance(3)))
29328 !c!-------------------------------------------------------------------
29329 !c! zero everything that should be zero'ed
29342 END SUBROUTINE elgrad_init_cat
29344 SUBROUTINE elgrad_init_cat_pep(eheadtail,Egb,Ecl,Elj,Equad,Epol)
29347 real(kind=8) :: eheadtail,Egb,Ecl,Elj,Equad,Epol,Rb
29351 !c! 1/(Gas Constant * Thermostate temperature) = BetaT
29352 !c! ENABLE THIS LINE WHEN USING CHECKGRAD!!!
29354 !c! BetaT = 1.0d0 / (t_bath * Rb)i
29356 BetaT = 1.0d0 / (298.0d0 * Rb)
29357 !c! Gay-berne var's
29358 sig0ij = sigmacat( itypi,itypj )
29359 chi1 = chi1cat( itypi, itypj )
29362 chip1 = chipp1cat( itypi, itypj )
29365 !c! not used by momo potential, but needed by sc_angular which is shared
29366 !c! by all energy_potential subroutines
29370 dxj = 0.0d0 !dc_norm( 1, nres+j )
29371 dyj = 0.0d0 !dc_norm( 2, nres+j )
29372 dzj = 0.0d0 !dc_norm( 3, nres+j )
29373 !c! distance from center of chain(?) to polar/charged head
29374 d1 = dheadcat(1, 1, itypi, itypj)
29375 d2 = dheadcat(2, 1, itypi, itypj)
29377 a12sq = rborn1cat(itypi,itypj) * rborn2cat(itypi,itypj)
29378 !c! a12sq = a12sq * a12sq
29379 !c! charge of amino acid itypi is...
29381 Qj = ichargecat(itypj)
29384 chis1 = chis1cat(itypi,itypj)
29387 sig1 = sigmap1cat(itypi,itypj)
29388 sig2 = sigmap2cat(itypi,itypj)
29389 !c! alpha factors from Fcav/Gcav
29390 b1cav = alphasurcat(1,itypi,itypj)
29391 b2cav = alphasurcat(2,itypi,itypj)
29392 b3cav = alphasurcat(3,itypi,itypj)
29393 b4cav = alphasurcat(4,itypi,itypj)
29394 wqd = wquadcat(itypi, itypj)
29396 eps_in = epsintabcat(itypi,itypj)
29397 eps_inout_fac = ( (1.0d0/eps_in) - (1.0d0/eps_out))
29398 !c!-------------------------------------------------------------------
29399 !c! tail location and distance calculations
29402 ctail(k,1)=(c(k,i)+c(k,i+1))/2.0-dtailcat(1,itypi,itypj)*dc_norm(k,i)
29403 ctail(k,2)=c(k,j)!-dtailcat(2,itypi,itypj)*dc_norm(k,nres+j)
29405 !c! tail distances will be themselves usefull elswhere
29406 !c1 (in Gcav, for example)
29407 Rtail_distance(1) = ctail( 1, 2 ) - ctail( 1,1 )
29408 Rtail_distance(2) = ctail( 2, 2 ) - ctail( 2,1 )
29409 Rtail_distance(3) = ctail( 3, 2 ) - ctail( 3,1 )
29411 (Rtail_distance(1)*Rtail_distance(1)) &
29412 + (Rtail_distance(2)*Rtail_distance(2)) &
29413 + (Rtail_distance(3)*Rtail_distance(3)))
29414 !c!-------------------------------------------------------------------
29415 !c! Calculate location and distance between polar heads
29416 !c! distance between heads
29417 !c! for each one of our three dimensional space...
29418 d1 = dheadcat(1, 1, itypi, itypj)
29419 d2 = dheadcat(2, 1, itypi, itypj)
29422 !c! location of polar head is computed by taking hydrophobic centre
29423 !c! and moving by a d1 * dc_norm vector
29424 !c! see unres publications for very informative images
29425 chead(k,1) = (c(k, i)+c(k,i+1))/2.0 + d1 * dc_norm(k, i)
29426 chead(k,2) = c(k, j)
29428 !c! Rsc_distance(k) = dabs(c(k, i+nres) - c(k, j+nres))
29429 !c! Rsc(k) = Rsc_distance(k) * Rsc_distance(k)
29430 Rhead_distance(k) = chead(k,2) - chead(k,1)
29432 !c! pitagoras (root of sum of squares)
29434 (Rhead_distance(1)*Rhead_distance(1)) &
29435 + (Rhead_distance(2)*Rhead_distance(2)) &
29436 + (Rhead_distance(3)*Rhead_distance(3)))
29437 !c!-------------------------------------------------------------------
29438 !c! zero everything that should be zero'ed
29451 END SUBROUTINE elgrad_init_cat_pep
29453 double precision function tschebyshev(m,n,x,y)
29456 double precision x(n),y,yy(0:maxvar),aux
29457 !c Tschebyshev polynomial. Note that the first term is omitted
29458 !c m=0: the constant term is included
29459 !c m=1: the constant term is not included
29463 yy(i)=2*yy(1)*yy(i-1)-yy(i-2)
29471 end function tschebyshev
29472 !C--------------------------------------------------------------------------
29473 double precision function gradtschebyshev(m,n,x,y)
29476 double precision x(n+1),y,yy(0:maxvar),aux
29477 !c Tschebyshev polynomial. Note that the first term is omitted
29478 !c m=0: the constant term is included
29479 !c m=1: the constant term is not included
29483 yy(i)=2*y*yy(i-1)-yy(i-2)
29487 aux=aux+x(i+1)*yy(i)*(i+1)
29488 !C print *, x(i+1),yy(i),i
29490 gradtschebyshev=aux
29492 end function gradtschebyshev
29493 !!!!!!!!!--------------------------------------------------------------
29494 subroutine lipid_bond(elipbond)
29495 real(kind=8) :: elipbond,fac,dist_sub,sumdist
29496 real(kind=8), dimension(3):: dist
29497 integer(kind=8) :: i,j,k,ibra,ityp,jtyp,ityp1
29499 ! print *,"before",ilipbond_start,ilipbond_end
29500 do i=ilipbond_start,ilipbond_end
29501 ! print *,i,i+1,"i,i+1"
29504 ! print *,ityp,ityp1,"itype"
29506 if (ityp.eq.12) ibra=i
29507 if ((ityp.eq.ntyp1_molec(4)).or.(ityp1.ge.ntyp1_molec(4)-1)) cycle
29508 if (ityp.eq.(ntyp1_molec(4)-1)) then
29509 !cofniecie do ostatnie GL1
29517 dist(k)=c(k,j)-c(k,i+1)
29521 sumdist=sumdist+dist(k)**2
29523 dist_sub=sqrt(sumdist)
29524 ! print *,"before",i,j,ityp1,ityp,jtyp
29525 elipbond=elipbond+kbondlip*((dist_sub-lip_bond(jtyp,ityp1))**2)
29526 fac=kbondlip*(dist_sub-lip_bond(jtyp,ityp1))
29528 gradlipbond(k,i+1)= gradlipbond(k,i+1)-fac*dist(k)/dist_sub
29529 gradlipbond(k,j)=gradlipbond(k,j)+fac*dist(k)/dist_sub
29531 if (energy_dec) write(iout,*) "lipbond",j,i+1,dist_sub,lip_bond(jtyp,ityp1),kbondlip,fac
29533 elipbond=elipbond*0.5d0
29535 end subroutine lipid_bond
29536 !---------------------------------------------------------------------------------------
29537 subroutine lipid_angle(elipang)
29538 real(kind=8) :: elipang,alfa,xa(3),xb(3),alfaact,alfa0,force,fac,&
29539 scalara,vnorm,wnorm,sss,sss_grad,eangle
29540 integer :: i,j,k,l,m,ibra,ityp1,itypm1,itypp1
29542 ! print *,"ilipang_start,ilipang_end",ilipang_start,ilipang_end
29543 do i=ilipang_start,ilipang_end
29546 ! the loop is centered on the central residue
29547 itypm1=itype(i-1,4)
29549 itypp1=itype(i+1,4)
29550 ! print *,i,i,j,"processor",fg_rank
29554 if (ityp1.eq.12) ibra=i
29555 if ((itypm1.eq.ntyp1_molec(4)).or.(ityp1.eq.ntyp1_molec(4))&
29556 .or.(itypp1.eq.ntyp1_molec(4))) cycle !cycle if any of the angles is dummy
29557 if ((itypm1.eq.ntyp1_molec(4)-1).or.(itypp1.eq.ntyp1_molec(4)-1)) cycle
29558 ! branching is only to one angle
29559 if (ityp1.eq.ntyp1_molec(4)-1) then
29566 xa(m)=c(m,j)-c(m,k)
29567 xb(m)=c(m,l)-c(m,k)
29570 vnorm=dsqrt(xa(1)*xa(1)+xa(2)*xa(2)+xa(3)*xa(3))
29571 wnorm=dsqrt(xb(1)*xb(1)+xb(2)*xb(2)+xb(3)*xb(3))
29572 scalara=(xa(1)*xb(1)+xa(2)*xb(2)+xa(3)*xb(3))/(vnorm*wnorm)
29573 ! if (((scalar*scalar).gt.0.99999999d0).and.(alfa0.eq.180.0d0)) cycle
29576 ! sss=sscale_martini_angle(alfaact)
29577 ! sss_grad=sscale_grad_martini_angle(alfaact)
29578 ! print *,sss_grad,"sss_grad",sss
29579 ! if (sss.le.0.0) cycle
29580 ! if (sss_grad.ne.0.0) print *,sss_grad,"sss_grad"
29581 force=lip_angle_force(itypm1,ityp1,itypp1)
29582 alfa0=lip_angle_angle(itypm1,ityp1,itypp1)
29583 eangle=force*(alfaact-dcos(alfa0))*(alfaact-dcos(alfa0))*0.5d0
29584 elipang=elipang+eangle!*(1001.0d0-1000.0d0*sss)
29585 fac=force*(alfaact-dcos(alfa0))!*(1001.0d0-1000.0d0*sss)-sss_grad*eangle*1000.0d0
29587 gradlipang(m,j)=gradlipang(m,j)+(fac &!/dsqrt(1.0d0-scalar*scalar)&
29588 *(xb(m)-scalara*wnorm*xa(m)/vnorm)&
29589 /(vnorm*wnorm))!-sss_grad*eangle*xa(m)/vnorm
29591 gradlipang(m,l)=gradlipang(m,l)+(fac & !/dsqrt(1.0d0-scalar*scalar)&
29592 *(xa(m)-scalara*vnorm*xb(m)/wnorm)&
29593 /(vnorm*wnorm))!+sss_grad*eangle*xb(m)/wnorm
29595 gradlipang(m,k)=gradlipang(m,k)-(fac)& !/dsqrt(1.0d0-scalar*scalar)&
29596 *(xb(m)-scalara*wnorm*xa(m)/vnorm)&
29597 /((vnorm*wnorm))-(fac & !/dsqrt(1.0d0-scalar*scalar)&
29598 *(xa(m)-scalara*vnorm*xb(m)/wnorm)&
29599 /(vnorm*wnorm))!-sss_grad*eangle*xa(m)/vnorm&
29600 !-sss_grad*eangle*xb(m)/wnorm
29603 ! *(xb(m)*vnorm*wnorm)&
29605 !-xa(m)*xa(m)*xb(m)*wnorm/vnorm)&
29607 if (energy_dec) write(iout,*) "elipang",j,k,l,force,alfa0,alfaact,elipang
29610 end subroutine lipid_angle
29611 !--------------------------------------------------------------------
29612 subroutine lipid_lj(eliplj)
29613 real(kind=8) :: eliplj,fac,sumdist,dist_sub,LJ1,LJ2,LJ,&
29614 xj,yj,zj,xi,yi,zi,sss,sss_grad
29615 real(kind=8), dimension(3):: dist
29616 integer :: i,j,k,inum,ityp,jtyp
29618 do inum=iliplj_start,iliplj_end
29619 i=mlipljlisti(inum)
29620 j=mlipljlistj(inum)
29621 ! print *,inum,i,j,"processor",fg_rank
29627 call to_box(xi,yi,zi)
29631 call to_box(xj,yj,zj)
29632 xj=boxshift(xj-xi,boxxsize)
29633 yj=boxshift(yj-yi,boxysize)
29634 zj=boxshift(zj-zi,boxzsize)
29639 ! dist(k)=c(k,j)-c(k,i)
29643 sumdist=sumdist+dist(k)**2
29646 dist_sub=sqrt(sumdist)
29647 sss=sscale_martini(dist_sub)
29648 if (energy_dec) write(iout,*) "LJ LIP bef",i,j,ityp,jtyp,dist_sub
29649 if (sss.le.0.0) cycle
29650 sss_grad=sscale_grad_martini(dist_sub)
29651 LJ1 = (lip_sig(ityp,jtyp)/dist_sub)**6
29654 LJ = 4.0d0*lip_eps(ityp,jtyp)*LJ
29655 eliplj = eliplj + LJ*sss
29656 fac=4.0d0*lip_eps(ityp,jtyp)*(-6.0d0*LJ1/dist_sub+12.0d0*LJ2/dist_sub)
29658 gradliplj(k,i)=gradliplj(k,i)+fac*dist(k)/dist_sub*sss-sss_grad*LJ*dist(k)/dist_sub
29659 gradliplj(k,j)=gradliplj(k,j)-fac*dist(k)/dist_sub*sss+sss_grad*LJ*dist(k)/dist_sub
29661 if (energy_dec) write(iout,'(a7,4i5,2f8.3)') "LJ LIP",i,j,ityp,jtyp,LJ,dist_sub
29664 end subroutine lipid_lj
29665 !--------------------------------------------------------------------------------------
29666 subroutine lipid_elec(elipelec)
29667 real(kind=8) :: elipelec,fac,sumdist,dist_sub,xj,yj,zj,xi,yi,zi,EQ,&
29669 real(kind=8), dimension(3):: dist
29670 integer :: i,j,k,inum,ityp,jtyp
29672 ! print *,"processor",fg_rank,ilip_elec_start,ilipelec_end
29673 do inum=ilip_elec_start,ilipelec_end
29674 i=mlipeleclisti(inum)
29675 j=mlipeleclistj(inum)
29676 ! print *,inum,i,j,"processor",fg_rank
29682 call to_box(xi,yi,zi)
29686 call to_box(xj,yj,zj)
29687 xj=boxshift(xj-xi,boxxsize)
29688 yj=boxshift(yj-yi,boxysize)
29689 zj=boxshift(zj-zi,boxzsize)
29694 ! dist(k)=c(k,j)-c(k,i)
29698 sumdist=sumdist+dist(k)**2
29700 dist_sub=sqrt(sumdist)
29701 sss=sscale_martini(dist_sub)
29702 ! print *,sss,dist_sub
29703 if (energy_dec) write(iout,*) "EQ LIP",sss,dist_sub,i,j
29704 if (sss.le.0.0) cycle
29705 sss_grad=sscale_grad_martini(dist_sub)
29706 ! print *,"sss",sss,sss_grad
29707 EQ=k_coulomb_lip*(ichargelipid(ityp)*ichargelipid(jtyp)/dist_sub)
29708 elipelec=elipelec+EQ*sss
29709 fac=k_coulomb_lip*(ichargelipid(ityp)*ichargelipid(jtyp)/sumdist)*sss
29711 gradlipelec(k,i)=gradlipelec(k,i)+fac*dist(k)/dist_sub&
29712 -sss_grad*EQ*dist(k)/dist_sub
29713 gradlipelec(k,j)=gradlipelec(k,j)-fac*dist(k)/dist_sub&
29714 +sss_grad*EQ*dist(k)/dist_sub
29716 if (energy_dec) write(iout,*) "EQ LIP",i,j,ityp,jtyp,EQ,dist_sub,elipelec
29719 end subroutine lipid_elec
29720 !-------------------------------------------------------------------------
29721 subroutine make_SCSC_inter_list
29723 real(kind=8) :: xi,yi,zi,xj,yj,zj,xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp
29724 real(kind=8) :: dist_init, dist_temp,r_buff_list
29725 integer:: contlisti(250*nres),contlistj(250*nres)
29726 ! integer :: newcontlisti(200*nres),newcontlistj(200*nres)
29727 integer i,j,itypi,itypj,subchap,xshift,yshift,zshift,iint,ilist_sc,g_ilist_sc
29728 integer displ(0:nprocs),i_ilist_sc(0:nprocs),ierr
29729 ! print *,"START make_SC"
29732 do i=iatsc_s,iatsc_e
29733 itypi=iabs(itype(i,1))
29734 if (itypi.eq.ntyp1) cycle
29738 call to_box(xi,yi,zi)
29739 do iint=1,nint_gr(i)
29740 ! print *,"is it wrong", iint,i
29741 do j=istart(i,iint),iend(i,iint)
29742 itypj=iabs(itype(j,1))
29743 if (energy_dec) write(iout,*) "LISTA ZAKRES",istart(i,iint),iend(i,iint),iatsc_s,iatsc_e
29744 if (itypj.eq.ntyp1) cycle
29748 call to_box(xj,yj,zj)
29749 ! call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
29750 ! faclipij2=(sslipi+sslipj)/2.0d0*lipscale**2+1.0d0
29751 xj=boxshift(xj-xi,boxxsize)
29752 yj=boxshift(yj-yi,boxysize)
29753 zj=boxshift(zj-zi,boxzsize)
29754 dist_init=xj**2+yj**2+zj**2
29755 ! dist_init=(xj-xi)**2+(yj-yi)**2+(zj-zi)**2
29756 ! r_buff_list is a read value for a buffer
29757 if (sqrt(dist_init).le.(r_cut_ele+r_buff_list)) then
29758 ! Here the list is created
29759 ilist_sc=ilist_sc+1
29760 ! this can be substituted by cantor and anti-cantor
29761 contlisti(ilist_sc)=i
29762 contlistj(ilist_sc)=j
29768 ! call MPI_Reduce(ilist_sc,g_ilist_sc,1,&
29769 ! MPI_INTEGER,MPI_SUM,king,FG_COMM,IERR)
29770 ! call MPI_Gather(newnss,1,MPI_INTEGER,&
29771 ! i_newnss,1,MPI_INTEGER,king,FG_COMM,IERR)
29773 write (iout,*) "before MPIREDUCE",ilist_sc
29775 write (iout,*) i,contlisti(i),contlistj(i)
29778 if (nfgtasks.gt.1)then
29780 call MPI_Reduce(ilist_sc,g_ilist_sc,1,&
29781 MPI_INTEGER,MPI_SUM,king,FG_COMM,IERR)
29782 ! write(iout,*) "before bcast",g_ilist_sc
29783 call MPI_Gather(ilist_sc,1,MPI_INTEGER,&
29784 i_ilist_sc,1,MPI_INTEGER,king,FG_COMM,IERR)
29786 do i=1,nfgtasks-1,1
29787 displ(i)=i_ilist_sc(i-1)+displ(i-1)
29789 ! write(iout,*) "before gather",displ(0),displ(1)
29790 call MPI_Gatherv(contlisti,ilist_sc,MPI_INTEGER,&
29791 newcontlisti,i_ilist_sc,displ,MPI_INTEGER,&
29793 call MPI_Gatherv(contlistj,ilist_sc,MPI_INTEGER,&
29794 newcontlistj,i_ilist_sc,displ,MPI_INTEGER,&
29796 call MPI_Bcast(g_ilist_sc,1,MPI_INT,king,FG_COMM,IERR)
29797 ! write(iout,*) "before bcast",g_ilist_sc
29798 ! call MPI_Bcast(g_ilist_sc,1,MPI_INT,king,FG_COMM)
29799 call MPI_Bcast(newcontlisti,g_ilist_sc,MPI_INT,king,FG_COMM,IERR)
29800 call MPI_Bcast(newcontlistj,g_ilist_sc,MPI_INT,king,FG_COMM,IERR)
29802 ! call MPI_Bcast(g_ilist_sc,1,MPI_INT,king,FG_COMM)
29805 g_ilist_sc=ilist_sc
29808 newcontlisti(i)=contlisti(i)
29809 newcontlistj(i)=contlistj(i)
29814 write (iout,*) "after MPIREDUCE",g_ilist_sc
29816 write (iout,*) i,newcontlisti(i),newcontlistj(i)
29819 call int_bounds(g_ilist_sc,g_listscsc_start,g_listscsc_end)
29821 end subroutine make_SCSC_inter_list
29822 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
29824 subroutine make_SCp_inter_list
29825 use MD_data, only: itime_mat
29828 real(kind=8) :: xi,yi,zi,xj,yj,zj,xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp
29829 real(kind=8) :: dist_init, dist_temp,r_buff_list
29830 integer:: contlistscpi(350*nres),contlistscpj(350*nres)
29831 ! integer :: newcontlistscpi(200*nres),newcontlistscpj(200*nres)
29832 integer i,j,itypi,itypj,subchap,xshift,yshift,zshift,iint,ilist_scp,g_ilist_scp
29833 integer displ(0:nprocs),i_ilist_scp(0:nprocs),ierr
29834 ! print *,"START make_SC"
29837 do i=iatscp_s,iatscp_e
29838 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
29839 xi=0.5D0*(c(1,i)+c(1,i+1))
29840 yi=0.5D0*(c(2,i)+c(2,i+1))
29841 zi=0.5D0*(c(3,i)+c(3,i+1))
29842 call to_box(xi,yi,zi)
29843 do iint=1,nscp_gr(i)
29845 do j=iscpstart(i,iint),iscpend(i,iint)
29846 itypj=iabs(itype(j,1))
29847 if (itypj.eq.ntyp1) cycle
29848 ! Uncomment following three lines for SC-p interactions
29849 ! xj=c(1,nres+j)-xi
29850 ! yj=c(2,nres+j)-yi
29851 ! zj=c(3,nres+j)-zi
29852 ! Uncomment following three lines for Ca-p interactions
29859 call to_box(xj,yj,zj)
29860 xj=boxshift(xj-xi,boxxsize)
29861 yj=boxshift(yj-yi,boxysize)
29862 zj=boxshift(zj-zi,boxzsize)
29863 dist_init=xj**2+yj**2+zj**2
29865 ! r_buff_list is a read value for a buffer
29866 if ((sqrt(dist_init).le.(r_cut_ele)).and.(ifirstrun.eq.0)) then
29867 ! Here the list is created
29868 ilist_scp_first=ilist_scp_first+1
29869 ! this can be substituted by cantor and anti-cantor
29870 contlistscpi_f(ilist_scp_first)=i
29871 contlistscpj_f(ilist_scp_first)=j
29874 ! r_buff_list is a read value for a buffer
29875 if (sqrt(dist_init).le.(r_cut_ele+r_buff_list)) then
29876 ! Here the list is created
29877 ilist_scp=ilist_scp+1
29878 ! this can be substituted by cantor and anti-cantor
29879 contlistscpi(ilist_scp)=i
29880 contlistscpj(ilist_scp)=j
29886 write (iout,*) "before MPIREDUCE",ilist_scp
29888 write (iout,*) i,contlistscpi(i),contlistscpj(i)
29891 if (nfgtasks.gt.1)then
29893 call MPI_Reduce(ilist_scp,g_ilist_scp,1,&
29894 MPI_INTEGER,MPI_SUM,king,FG_COMM,IERR)
29895 ! write(iout,*) "before bcast",g_ilist_sc
29896 call MPI_Gather(ilist_scp,1,MPI_INTEGER,&
29897 i_ilist_scp,1,MPI_INTEGER,king,FG_COMM,IERR)
29899 do i=1,nfgtasks-1,1
29900 displ(i)=i_ilist_scp(i-1)+displ(i-1)
29902 ! write(iout,*) "before gather",displ(0),displ(1)
29903 call MPI_Gatherv(contlistscpi,ilist_scp,MPI_INTEGER,&
29904 newcontlistscpi,i_ilist_scp,displ,MPI_INTEGER,&
29906 call MPI_Gatherv(contlistscpj,ilist_scp,MPI_INTEGER,&
29907 newcontlistscpj,i_ilist_scp,displ,MPI_INTEGER,&
29909 call MPI_Bcast(g_ilist_scp,1,MPI_INT,king,FG_COMM,IERR)
29910 ! write(iout,*) "before bcast",g_ilist_sc
29911 ! call MPI_Bcast(g_ilist_sc,1,MPI_INT,king,FG_COMM)
29912 call MPI_Bcast(newcontlistscpi,g_ilist_scp,MPI_INT,king,FG_COMM,IERR)
29913 call MPI_Bcast(newcontlistscpj,g_ilist_scp,MPI_INT,king,FG_COMM,IERR)
29915 ! call MPI_Bcast(g_ilist_sc,1,MPI_INT,king,FG_COMM)
29918 g_ilist_scp=ilist_scp
29921 newcontlistscpi(i)=contlistscpi(i)
29922 newcontlistscpj(i)=contlistscpj(i)
29927 write (iout,*) "after MPIREDUCE",g_ilist_scp
29929 write (iout,*) i,newcontlistscpi(i),newcontlistscpj(i)
29932 ! if (ifirstrun.eq.0) ifirstrun=1
29933 ! do i=1,ilist_scp_first
29934 ! do j=1,g_ilist_scp
29935 ! if ((newcontlistscpi(j).eq.contlistscpi_f(i)).and.&
29936 ! (newcontlistscpj(j).eq.contlistscpj_f(i))) go to 126
29938 ! print *,itime_mat,"ERROR matrix needs updating"
29939 ! print *,contlistscpi_f(i),contlistscpj_f(i)
29943 call int_bounds(g_ilist_scp,g_listscp_start,g_listscp_end)
29946 end subroutine make_SCp_inter_list
29948 !-----------------------------------------------------------------------------
29949 !-----------------------------------------------------------------------------
29952 subroutine make_pp_inter_list
29954 real(kind=8) :: xi,yi,zi,xj,yj,zj,xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp
29955 real(kind=8) :: xmedj,ymedj,zmedj,sslipi,ssgradlipi,faclipij2,sslipj,ssgradlipj
29956 real(kind=8) :: dist_init, dist_temp,r_buff_list,dxi,dyi,dzi,xmedi,ymedi,zmedi
29957 real(kind=8) :: dx_normi,dy_normi,dz_normi,dxj,dyj,dzj,dx_normj,dy_normj,dz_normj
29958 integer:: contlistppi(250*nres),contlistppj(250*nres)
29959 ! integer :: newcontlistppi(200*nres),newcontlistppj(200*nres)
29960 integer i,j,itypi,itypj,subchap,xshift,yshift,zshift,iint,ilist_pp,g_ilist_pp
29961 integer displ(0:nprocs),i_ilist_pp(0:nprocs),ierr
29962 ! write(iout,*),"START make_pp",iatel_s,iatel_e,r_cut_ele+r_buff_list
29965 do i=iatel_s,iatel_e
29966 if (itype(i,1).eq.ntyp1 .or. itype(i+1,1).eq.ntyp1) cycle
29970 dx_normi=dc_norm(1,i)
29971 dy_normi=dc_norm(2,i)
29972 dz_normi=dc_norm(3,i)
29973 xmedi=c(1,i)+0.5d0*dxi
29974 ymedi=c(2,i)+0.5d0*dyi
29975 zmedi=c(3,i)+0.5d0*dzi
29977 call to_box(xmedi,ymedi,zmedi)
29978 call lipid_layer(xmedi,ymedi,zmedi,sslipi,ssgradlipi)
29979 ! write (iout,*) i,j,itype(i,1),itype(j,1)
29980 ! if (itype(j,1).eq.ntyp1.or. itype(j+1,1).eq.ntyp1) cycle
29983 do j=ielstart(i),ielend(i)
29984 ! write (iout,*) i,j,itype(i,1),itype(j,1)
29985 if (itype(j,1).eq.ntyp1.or. itype(j+1,1).eq.ntyp1) cycle
29989 dx_normj=dc_norm(1,j)
29990 dy_normj=dc_norm(2,j)
29991 dz_normj=dc_norm(3,j)
29992 ! xj=c(1,j)+0.5D0*dxj-xmedi
29993 ! yj=c(2,j)+0.5D0*dyj-ymedi
29994 ! zj=c(3,j)+0.5D0*dzj-zmedi
29995 xj=c(1,j)+0.5D0*dxj
29996 yj=c(2,j)+0.5D0*dyj
29997 zj=c(3,j)+0.5D0*dzj
29998 call to_box(xj,yj,zj)
29999 ! call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
30000 ! faclipij2=(sslipi+sslipj)/2.0d0*lipscale**2+1.0d0
30001 xj=boxshift(xj-xmedi,boxxsize)
30002 yj=boxshift(yj-ymedi,boxysize)
30003 zj=boxshift(zj-zmedi,boxzsize)
30004 dist_init=xj**2+yj**2+zj**2
30005 if (sqrt(dist_init).le.(r_cut_ele+r_buff_list)) then
30006 ! Here the list is created
30007 ilist_pp=ilist_pp+1
30008 ! this can be substituted by cantor and anti-cantor
30009 contlistppi(ilist_pp)=i
30010 contlistppj(ilist_pp)=j
30016 write (iout,*) "before MPIREDUCE",ilist_pp
30018 write (iout,*) i,contlistppi(i),contlistppj(i)
30021 if (nfgtasks.gt.1)then
30023 call MPI_Reduce(ilist_pp,g_ilist_pp,1,&
30024 MPI_INTEGER,MPI_SUM,king,FG_COMM,IERR)
30025 ! write(iout,*) "before bcast",g_ilist_sc
30026 call MPI_Gather(ilist_pp,1,MPI_INTEGER,&
30027 i_ilist_pp,1,MPI_INTEGER,king,FG_COMM,IERR)
30029 do i=1,nfgtasks-1,1
30030 displ(i)=i_ilist_pp(i-1)+displ(i-1)
30032 ! write(iout,*) "before gather",displ(0),displ(1)
30033 call MPI_Gatherv(contlistppi,ilist_pp,MPI_INTEGER,&
30034 newcontlistppi,i_ilist_pp,displ,MPI_INTEGER,&
30036 call MPI_Gatherv(contlistppj,ilist_pp,MPI_INTEGER,&
30037 newcontlistppj,i_ilist_pp,displ,MPI_INTEGER,&
30039 call MPI_Bcast(g_ilist_pp,1,MPI_INT,king,FG_COMM,IERR)
30040 ! write(iout,*) "before bcast",g_ilist_sc
30041 ! call MPI_Bcast(g_ilist_sc,1,MPI_INT,king,FG_COMM)
30042 call MPI_Bcast(newcontlistppi,g_ilist_pp,MPI_INT,king,FG_COMM,IERR)
30043 call MPI_Bcast(newcontlistppj,g_ilist_pp,MPI_INT,king,FG_COMM,IERR)
30045 ! call MPI_Bcast(g_ilist_sc,1,MPI_INT,king,FG_COMM)
30048 g_ilist_pp=ilist_pp
30051 newcontlistppi(i)=contlistppi(i)
30052 newcontlistppj(i)=contlistppj(i)
30055 call int_bounds(g_ilist_pp,g_listpp_start,g_listpp_end)
30057 write (iout,*) "after MPIREDUCE",g_ilist_pp
30059 write (iout,*) i,newcontlistppi(i),newcontlistppj(i)
30063 end subroutine make_pp_inter_list
30064 !---------------------------------------------------------------------------
30065 subroutine make_cat_pep_list
30067 real(kind=8) :: xi,yi,zi,xj,yj,zj,xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp
30068 real(kind=8) :: xmedj,ymedj,zmedj,sslipi,ssgradlipi,faclipij2,sslipj,ssgradlipj
30069 real(kind=8) :: dist_init, dist_temp,r_buff_list,dxi,dyi,dzi,xmedi,ymedi,zmedi
30070 real(kind=8) :: dx_normi,dy_normi,dz_normi,dxj,dyj,dzj,dx_normj,dy_normj,dz_normj
30071 real(kind=8) :: xja,yja,zja
30072 integer:: contlistcatpnormi(300*nres),contlistcatpnormj(300*nres)
30073 integer:: contlistcatscnormi(250*nres),contlistcatscnormj(250*nres)
30074 integer:: contlistcatptrani(250*nres),contlistcatptranj(250*nres)
30075 integer:: contlistcatsctrani(250*nres),contlistcatsctranj(250*nres)
30076 integer:: contlistcatscangi(250*nres),contlistcatscangj(250*nres)
30077 integer:: contlistcatscangfi(250*nres),contlistcatscangfj(250*nres),&
30078 contlistcatscangfk(250*nres)
30079 integer:: contlistcatscangti(250*nres),contlistcatscangtj(250*nres)
30080 integer:: contlistcatscangtk(250*nres),contlistcatscangtl(250*nres)
30083 ! integer :: newcontlistppi(200*nres),newcontlistppj(200*nres)
30084 integer i,j,itypi,itypj,subchap,xshift,yshift,zshift,iint,ilist_catscnorm,&
30085 ilist_catsctran,ilist_catpnorm,ilist_catptran,itmp,ilist_catscang,&
30086 ilist_catscangf,ilist_catscangt,k
30087 integer displ(0:nprocs),i_ilist_catscnorm(0:nprocs),ierr,&
30088 i_ilist_catpnorm(0:nprocs),i_ilist_catsctran(0:nprocs),&
30089 i_ilist_catptran(0:nprocs),i_ilist_catscang(0:nprocs),&
30090 i_ilist_catscangf(0:nprocs),i_ilist_catscangt(0:nprocs)
30091 ! write(iout,*),"START make_pp",iatel_s,iatel_e,r_cut_ele+r_buff_list
30102 itmp=itmp+nres_molec(i)
30105 ! do i=1,nres_molec(1)-1 ! loop over all peptide groups needs parralelization
30106 do i=ibond_start,ibond_end
30108 ! print *,"I am in EVDW",i
30109 itypi=iabs(itype(i,1))
30111 ! if (i.ne.47) cycle
30112 if ((itypi.eq.ntyp1).or.(itypi.eq.10)) cycle
30113 ! itypi1=iabs(itype(i+1,1))
30117 call to_box(xi,yi,zi)
30118 dxi=dc_norm(1,nres+i)
30119 dyi=dc_norm(2,nres+i)
30120 dzi=dc_norm(3,nres+i)
30121 xmedi=c(1,i)+0.5d0*dxi
30122 ymedi=c(2,i)+0.5d0*dyi
30123 zmedi=c(3,i)+0.5d0*dzi
30124 call to_box(xmedi,ymedi,zmedi)
30126 ! dsci_inv=vbld_inv(i+nres)
30127 do j=itmp+1,itmp+nres_molec(5)
30131 dx_normj=dc_norm(1,j)
30132 dy_normj=dc_norm(2,j)
30133 dz_normj=dc_norm(3,j)
30137 call to_box(xj,yj,zj)
30138 ! call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
30139 ! faclipij2=(sslipi+sslipj)/2.0d0*lipscale**2+1.0d0
30140 xja=boxshift(xj-xmedi,boxxsize)
30141 yja=boxshift(yj-ymedi,boxysize)
30142 zja=boxshift(zj-zmedi,boxzsize)
30143 dist_init=xja**2+yja**2+zja**2
30144 if (sqrt(dist_init).le.(r_cut_ele+r_buff_list)) then
30145 ! Here the list is created
30146 if (itype(j,5).le.5) then
30147 ilist_catpnorm=ilist_catpnorm+1
30148 ! this can be substituted by cantor and anti-cantor
30149 contlistcatpnormi(ilist_catpnorm)=i
30150 contlistcatpnormj(ilist_catpnorm)=j
30152 ilist_catptran=ilist_catptran+1
30153 ! this can be substituted by cantor and anti-cantor
30154 contlistcatptrani(ilist_catptran)=i
30155 contlistcatptranj(ilist_catptran)=j
30158 xja=boxshift(xj-xi,boxxsize)
30159 yja=boxshift(yj-yi,boxysize)
30160 zja=boxshift(zj-zi,boxzsize)
30161 dist_init=xja**2+yja**2+zja**2
30162 if (sqrt(dist_init).le.(r_cut_ele+r_buff_list)) then
30163 ! Here the list is created
30164 if (itype(j,5).le.5) then
30165 ilist_catscnorm=ilist_catscnorm+1
30166 ! this can be substituted by cantor and anti-cantor
30167 ! write(iout,*) "have contact",i,j,ilist_catscnorm
30168 contlistcatscnormi(ilist_catscnorm)=i
30169 contlistcatscnormj(ilist_catscnorm)=j
30170 ! write(iout,*) "have contact2",i,j,ilist_catscnorm,&
30171 ! contlistcatscnormi(ilist_catscnorm),contlistcatscnormj(ilist_catscnorm)
30174 ilist_catsctran=ilist_catsctran+1
30175 ! this can be substituted by cantor and anti-cantor
30176 contlistcatsctrani(ilist_catsctran)=i
30177 contlistcatsctranj(ilist_catsctran)=j
30178 ! print *,"KUR**",i,j,itype(i,1)
30179 if (((itype(i,1).eq.1).or.(itype(i,1).eq.15).or.&
30180 (itype(i,1).eq.16).or.(itype(i,1).eq.17)).and.&
30181 ((sqrt(dist_init).le.(r_cut_ang+r_buff_list)))) then
30182 ! print *,"KUR**2",i,j,itype(i,1),ilist_catscang+1
30184 ilist_catscang=ilist_catscang+1
30185 contlistcatscangi(ilist_catscang)=i
30186 contlistcatscangj(ilist_catscang)=j
30195 write (iout,*) "before MPIREDUCE",ilist_catsctran,ilist_catptran,&
30196 ilist_catscnorm,ilist_catpnorm,ilist_catscang
30198 do i=1,ilist_catsctran
30199 write (iout,*) i,contlistcatsctrani(i),contlistcatsctranj(i),&
30200 itype(j,contlistcatsctranj(i))
30202 do i=1,ilist_catptran
30203 write (iout,*) i,contlistcatptrani(i),contlistcatsctranj(i)
30205 do i=1,ilist_catscnorm
30206 write (iout,*) i,contlistcatscnormi(i),contlistcatscnormj(i)
30208 do i=1,ilist_catpnorm
30209 write (iout,*) i,contlistcatpnormi(i),contlistcatscnormj(i)
30211 do i=1,ilist_catscang
30212 write (iout,*) i,contlistcatscangi(i),contlistcatscangi(i)
30217 if (nfgtasks.gt.1)then
30219 call MPI_Reduce(ilist_catsctran,g_ilist_catsctran,1,&
30220 MPI_INTEGER,MPI_SUM,king,FG_COMM,IERR)
30221 ! write(iout,*) "before bcast",g_ilist_sc
30222 call MPI_Gather(ilist_catsctran,1,MPI_INTEGER,&
30223 i_ilist_catsctran,1,MPI_INTEGER,king,FG_COMM,IERR)
30225 do i=1,nfgtasks-1,1
30226 displ(i)=i_ilist_catsctran(i-1)+displ(i-1)
30228 ! write(iout,*) "before gather",displ(0),displ(1)
30229 call MPI_Gatherv(contlistcatsctrani,ilist_catsctran,MPI_INTEGER,&
30230 newcontlistcatsctrani,i_ilist_catsctran,displ,MPI_INTEGER,&
30232 call MPI_Gatherv(contlistcatsctranj,ilist_catsctran,MPI_INTEGER,&
30233 newcontlistcatsctranj,i_ilist_catsctran,displ,MPI_INTEGER,&
30235 call MPI_Bcast(g_ilist_catsctran,1,MPI_INT,king,FG_COMM,IERR)
30236 ! write(iout,*) "before bcast",g_ilist_sc
30237 ! call MPI_Bcast(g_ilist_sc,1,MPI_INT,king,FG_COMM)
30238 call MPI_Bcast(newcontlistcatsctrani,g_ilist_catsctran,MPI_INT,king,FG_COMM,IERR)
30239 call MPI_Bcast(newcontlistcatsctranj,g_ilist_catsctran,MPI_INT,king,FG_COMM,IERR)
30242 call MPI_Reduce(ilist_catptran,g_ilist_catptran,1,&
30243 MPI_INTEGER,MPI_SUM,king,FG_COMM,IERR)
30244 ! write(iout,*) "before bcast",g_ilist_sc
30245 call MPI_Gather(ilist_catptran,1,MPI_INTEGER,&
30246 i_ilist_catptran,1,MPI_INTEGER,king,FG_COMM,IERR)
30248 do i=1,nfgtasks-1,1
30249 displ(i)=i_ilist_catptran(i-1)+displ(i-1)
30251 ! write(iout,*) "before gather",displ(0),displ(1)
30252 call MPI_Gatherv(contlistcatptrani,ilist_catptran,MPI_INTEGER,&
30253 newcontlistcatptrani,i_ilist_catptran,displ,MPI_INTEGER,&
30255 call MPI_Gatherv(contlistcatptranj,ilist_catptran,MPI_INTEGER,&
30256 newcontlistcatptranj,i_ilist_catptran,displ,MPI_INTEGER,&
30258 call MPI_Bcast(g_ilist_catptran,1,MPI_INT,king,FG_COMM,IERR)
30259 ! write(iout,*) "before bcast",g_ilist_sc
30260 ! call MPI_Bcast(g_ilist_sc,1,MPI_INT,king,FG_COMM)
30261 call MPI_Bcast(newcontlistcatptrani,g_ilist_catptran,MPI_INT,king,FG_COMM,IERR)
30262 call MPI_Bcast(newcontlistcatptranj,g_ilist_catptran,MPI_INT,king,FG_COMM,IERR)
30264 ! call MPI_Bcast(g_ilist_sc,1,MPI_INT,king,FG_COMM)
30266 call MPI_Reduce(ilist_catscnorm,g_ilist_catscnorm,1,&
30267 MPI_INTEGER,MPI_SUM,king,FG_COMM,IERR)
30268 ! write(iout,*) "before bcast",g_ilist_sc
30269 call MPI_Gather(ilist_catscnorm,1,MPI_INTEGER,&
30270 i_ilist_catscnorm,1,MPI_INTEGER,king,FG_COMM,IERR)
30272 do i=1,nfgtasks-1,1
30273 displ(i)=i_ilist_catscnorm(i-1)+displ(i-1)
30275 ! write(iout,*) "before gather",displ(0),displ(1)
30276 call MPI_Gatherv(contlistcatscnormi,ilist_catscnorm,MPI_INTEGER,&
30277 newcontlistcatscnormi,i_ilist_catscnorm,displ,MPI_INTEGER,&
30279 call MPI_Gatherv(contlistcatscnormj,ilist_catscnorm,MPI_INTEGER,&
30280 newcontlistcatscnormj,i_ilist_catscnorm,displ,MPI_INTEGER,&
30282 call MPI_Bcast(g_ilist_catscnorm,1,MPI_INT,king,FG_COMM,IERR)
30283 ! write(iout,*) "before bcast",g_ilist_sc
30284 ! call MPI_Bcast(g_ilist_sc,1,MPI_INT,king,FG_COMM)
30285 call MPI_Bcast(newcontlistcatscnormi,g_ilist_catscnorm,MPI_INT,king,FG_COMM,IERR)
30286 call MPI_Bcast(newcontlistcatscnormj,g_ilist_catscnorm,MPI_INT,king,FG_COMM,IERR)
30290 call MPI_Reduce(ilist_catpnorm,g_ilist_catpnorm,1,&
30291 MPI_INTEGER,MPI_SUM,king,FG_COMM,IERR)
30292 ! write(iout,*) "before bcast",g_ilist_sc
30293 call MPI_Gather(ilist_catpnorm,1,MPI_INTEGER,&
30294 i_ilist_catpnorm,1,MPI_INTEGER,king,FG_COMM,IERR)
30296 do i=1,nfgtasks-1,1
30297 displ(i)=i_ilist_catpnorm(i-1)+displ(i-1)
30299 ! write(iout,*) "before gather",displ(0),displ(1)
30300 call MPI_Gatherv(contlistcatpnormi,ilist_catpnorm,MPI_INTEGER,&
30301 newcontlistcatpnormi,i_ilist_catpnorm,displ,MPI_INTEGER,&
30303 call MPI_Gatherv(contlistcatpnormj,ilist_catpnorm,MPI_INTEGER,&
30304 newcontlistcatpnormj,i_ilist_catpnorm,displ,MPI_INTEGER,&
30306 call MPI_Bcast(g_ilist_catpnorm,1,MPI_INT,king,FG_COMM,IERR)
30307 ! write(iout,*) "before bcast",g_ilist_sc
30308 ! call MPI_Bcast(g_ilist_sc,1,MPI_INT,king,FG_COMM)
30309 call MPI_Bcast(newcontlistcatpnormi,g_ilist_catpnorm,MPI_INT,king,FG_COMM,IERR)
30310 call MPI_Bcast(newcontlistcatpnormj,g_ilist_catpnorm,MPI_INT,king,FG_COMM,IERR)
30314 call MPI_Reduce(ilist_catscang,g_ilist_catscang,1,&
30315 MPI_INTEGER,MPI_SUM,king,FG_COMM,IERR)
30316 ! write(iout,*) "before bcast",g_ilist_sc
30317 call MPI_Gather(ilist_catscang,1,MPI_INTEGER,&
30318 i_ilist_catscang,1,MPI_INTEGER,king,FG_COMM,IERR)
30320 do i=1,nfgtasks-1,1
30321 displ(i)=i_ilist_catscang(i-1)+displ(i-1)
30323 ! write(iout,*) "before gather",displ(0),displ(1)
30324 call MPI_Gatherv(contlistcatscangi,ilist_catscang,MPI_INTEGER,&
30325 newcontlistcatscangi,i_ilist_catscang,displ,MPI_INTEGER,&
30327 call MPI_Gatherv(contlistcatscangj,ilist_catscang,MPI_INTEGER,&
30328 newcontlistcatscangj,i_ilist_catscang,displ,MPI_INTEGER,&
30330 call MPI_Bcast(g_ilist_catscang,1,MPI_INT,king,FG_COMM,IERR)
30331 ! write(iout,*) "before bcast",g_ilist_sc
30332 ! call MPI_Bcast(g_ilist_sc,1,MPI_INT,king,FG_COMM)
30333 call MPI_Bcast(newcontlistcatscangi,g_ilist_catscang,MPI_INT,king,FG_COMM,IERR)
30334 call MPI_Bcast(newcontlistcatscangj,g_ilist_catscang,MPI_INT,king,FG_COMM,IERR)
30338 g_ilist_catscnorm=ilist_catscnorm
30339 g_ilist_catsctran=ilist_catsctran
30340 g_ilist_catpnorm=ilist_catpnorm
30341 g_ilist_catptran=ilist_catptran
30342 g_ilist_catscang=ilist_catscang
30345 do i=1,ilist_catscnorm
30346 newcontlistcatscnormi(i)=contlistcatscnormi(i)
30347 newcontlistcatscnormj(i)=contlistcatscnormj(i)
30349 do i=1,ilist_catpnorm
30350 newcontlistcatpnormi(i)=contlistcatpnormi(i)
30351 newcontlistcatpnormj(i)=contlistcatpnormj(i)
30353 do i=1,ilist_catsctran
30354 newcontlistcatsctrani(i)=contlistcatsctrani(i)
30355 newcontlistcatsctranj(i)=contlistcatsctranj(i)
30357 do i=1,ilist_catptran
30358 newcontlistcatptrani(i)=contlistcatptrani(i)
30359 newcontlistcatptranj(i)=contlistcatptranj(i)
30362 do i=1,ilist_catscang
30363 newcontlistcatscangi(i)=contlistcatscangi(i)
30364 newcontlistcatscangj(i)=contlistcatscangj(i)
30369 call int_bounds(g_ilist_catsctran,g_listcatsctran_start,g_listcatsctran_end)
30370 call int_bounds(g_ilist_catptran,g_listcatptran_start,g_listcatptran_end)
30371 call int_bounds(g_ilist_catscnorm,g_listcatscnorm_start,g_listcatscnorm_end)
30372 call int_bounds(g_ilist_catpnorm,g_listcatpnorm_start,g_listcatpnorm_end)
30373 call int_bounds(g_ilist_catscang,g_listcatscang_start,g_listcatscang_end)
30374 ! make new ang list
30376 do i=g_listcatscang_start,g_listcatscang_end
30377 do j=2,g_ilist_catscang
30378 ! print *,"RWA",i,j,contlistcatscangj(i),contlistcatscangj(j)
30380 if (newcontlistcatscangj(i).ne.newcontlistcatscangj(j)) cycle
30381 ilist_catscangf=ilist_catscangf+1
30382 contlistcatscangfi(ilist_catscangf)=newcontlistcatscangi(i)
30383 contlistcatscangfj(ilist_catscangf)=newcontlistcatscangj(i)
30384 contlistcatscangfk(ilist_catscangf)=newcontlistcatscangi(j)
30385 ! print *,"TUTU",g_listcatscang_start,g_listcatscang_end,i,j,g_ilist_catscangf,myrank
30388 if (nfgtasks.gt.1)then
30390 call MPI_Reduce(ilist_catscangf,g_ilist_catscangf,1,&
30391 MPI_INTEGER,MPI_SUM,king,FG_COMM,IERR)
30392 ! write(iout,*) "before bcast",g_ilist_sc
30393 call MPI_Gather(ilist_catscangf,1,MPI_INTEGER,&
30394 i_ilist_catscangf,1,MPI_INTEGER,king,FG_COMM,IERR)
30396 do i=1,nfgtasks-1,1
30397 displ(i)=i_ilist_catscangf(i-1)+displ(i-1)
30399 ! write(iout,*) "before gather",displ(0),displ(1)
30400 call MPI_Gatherv(contlistcatscangfi,ilist_catscangf,MPI_INTEGER,&
30401 newcontlistcatscangfi,i_ilist_catscangf,displ,MPI_INTEGER,&
30403 call MPI_Gatherv(contlistcatscangfj,ilist_catscangf,MPI_INTEGER,&
30404 newcontlistcatscangfj,i_ilist_catscangf,displ,MPI_INTEGER,&
30406 call MPI_Gatherv(contlistcatscangfk,ilist_catscangf,MPI_INTEGER,&
30407 newcontlistcatscangfk,i_ilist_catscangf,displ,MPI_INTEGER,&
30410 call MPI_Bcast(g_ilist_catscangf,1,MPI_INT,king,FG_COMM,IERR)
30411 ! write(iout,*) "before bcast",g_ilist_sc
30412 ! call MPI_Bcast(g_ilist_sc,1,MPI_INT,king,FG_COMM)
30413 call MPI_Bcast(newcontlistcatscangfi,g_ilist_catscangf,MPI_INT,king,FG_COMM,IERR)
30414 call MPI_Bcast(newcontlistcatscangfj,g_ilist_catscangf,MPI_INT,king,FG_COMM,IERR)
30415 call MPI_Bcast(newcontlistcatscangfk,g_ilist_catscangf,MPI_INT,king,FG_COMM,IERR)
30417 g_ilist_catscangf=ilist_catscangf
30418 do i=1,ilist_catscangf
30419 newcontlistcatscangfi(i)=contlistcatscangfi(i)
30420 newcontlistcatscangfj(i)=contlistcatscangfj(i)
30421 newcontlistcatscangfk(i)=contlistcatscangfk(i)
30424 call int_bounds(g_ilist_catscangf,g_listcatscangf_start,g_listcatscangf_end)
30428 do i=g_listcatscang_start,g_listcatscang_end
30429 do j=1,g_ilist_catscang
30430 do k=1,g_ilist_catscang
30431 ! print *,"TUTU1",g_listcatscang_start,g_listcatscang_end,i,j
30433 if (newcontlistcatscangj(i).ne.newcontlistcatscangj(j)) cycle
30434 if (newcontlistcatscangj(i).ne.newcontlistcatscangj(k)) cycle
30435 if (newcontlistcatscangj(k).ne.newcontlistcatscangj(j)) cycle
30436 if (newcontlistcatscangi(i).eq.newcontlistcatscangi(j)) cycle
30437 if (newcontlistcatscangi(i).eq.newcontlistcatscangi(k)) cycle
30438 if (newcontlistcatscangi(k).eq.newcontlistcatscangi(j)) cycle
30439 ! print *,"TUTU2",g_listcatscang_start,g_listcatscang_end,i,j
30441 ilist_catscangt=ilist_catscangt+1
30442 contlistcatscangti(ilist_catscangt)=newcontlistcatscangi(i)
30443 contlistcatscangtj(ilist_catscangt)=newcontlistcatscangj(i)
30444 contlistcatscangtk(ilist_catscangt)=newcontlistcatscangi(j)
30445 contlistcatscangtl(ilist_catscangt)=newcontlistcatscangi(k)
30450 if (nfgtasks.gt.1)then
30452 call MPI_Reduce(ilist_catscangt,g_ilist_catscangt,1,&
30453 MPI_INTEGER,MPI_SUM,king,FG_COMM,IERR)
30454 ! write(iout,*) "before bcast",g_ilist_sc
30455 call MPI_Gather(ilist_catscangt,1,MPI_INTEGER,&
30456 i_ilist_catscangt,1,MPI_INTEGER,king,FG_COMM,IERR)
30458 do i=1,nfgtasks-1,1
30459 displ(i)=i_ilist_catscangt(i-1)+displ(i-1)
30461 ! write(iout,*) "before gather",displ(0),displ(1)
30462 call MPI_Gatherv(contlistcatscangti,ilist_catscangt,MPI_INTEGER,&
30463 newcontlistcatscangti,i_ilist_catscangt,displ,MPI_INTEGER,&
30465 call MPI_Gatherv(contlistcatscangtj,ilist_catscangt,MPI_INTEGER,&
30466 newcontlistcatscangtj,i_ilist_catscangt,displ,MPI_INTEGER,&
30468 call MPI_Gatherv(contlistcatscangtk,ilist_catscangt,MPI_INTEGER,&
30469 newcontlistcatscangtk,i_ilist_catscangt,displ,MPI_INTEGER,&
30471 call MPI_Gatherv(contlistcatscangtl,ilist_catscangt,MPI_INTEGER,&
30472 newcontlistcatscangtl,i_ilist_catscangt,displ,MPI_INTEGER,&
30475 call MPI_Bcast(g_ilist_catscangt,1,MPI_INT,king,FG_COMM,IERR)
30476 ! write(iout,*) "before bcast",g_ilist_sc
30477 ! call MPI_Bcast(g_ilist_sc,1,MPI_INT,king,FG_COMM)
30478 call MPI_Bcast(newcontlistcatscangti,g_ilist_catscangt,MPI_INT,king,FG_COMM,IERR)
30479 call MPI_Bcast(newcontlistcatscangtj,g_ilist_catscangt,MPI_INT,king,FG_COMM,IERR)
30480 call MPI_Bcast(newcontlistcatscangtk,g_ilist_catscangt,MPI_INT,king,FG_COMM,IERR)
30481 call MPI_Bcast(newcontlistcatscangtl,g_ilist_catscangt,MPI_INT,king,FG_COMM,IERR)
30484 g_ilist_catscangt=ilist_catscangt
30485 do i=1,ilist_catscangt
30486 newcontlistcatscangti(i)=contlistcatscangti(i)
30487 newcontlistcatscangtj(i)=contlistcatscangtj(i)
30488 newcontlistcatscangtk(i)=contlistcatscangtk(i)
30489 newcontlistcatscangtl(i)=contlistcatscangtl(i)
30492 call int_bounds(g_ilist_catscangt,g_listcatscangt_start,g_listcatscangt_end)
30499 write (iout,*) "after MPIREDUCE",ilist_catsctran,ilist_catptran, &
30500 ilist_catscnorm,ilist_catpnorm
30502 do i=1,g_ilist_catsctran
30503 write (iout,*) i,newcontlistcatsctrani(i),newcontlistcatsctranj(i)
30505 do i=1,g_ilist_catptran
30506 write (iout,*) i,newcontlistcatptrani(i),newcontlistcatsctranj(i)
30508 do i=1,g_ilist_catscnorm
30509 write (iout,*) i,newcontlistcatscnormi(i),newcontlistcatscnormj(i)
30511 do i=1,g_ilist_catpnorm
30512 write (iout,*) i,newcontlistcatpnormi(i),newcontlistcatscnormj(i)
30514 do i=1,g_ilist_catscang
30515 write (iout,*) i,newcontlistcatscangi(i),newcontlistcatscangj(i)
30519 end subroutine make_cat_pep_list
30521 subroutine make_cat_cat_list
30523 real(kind=8) :: xi,yi,zi,xj,yj,zj,xj_safe,yj_safe,zj_safe,xj_temp,yj_temp,zj_temp
30524 real(kind=8) :: xmedj,ymedj,zmedj,sslipi,ssgradlipi,faclipij2,sslipj,ssgradlipj
30525 real(kind=8) :: dist_init, dist_temp,r_buff_list,dxi,dyi,dzi,xmedi,ymedi,zmedi
30526 real(kind=8) :: dx_normi,dy_normi,dz_normi,dxj,dyj,dzj,dx_normj,dy_normj,dz_normj
30527 real(kind=8) :: xja,yja,zja
30528 integer,dimension(:),allocatable:: contlistcatpnormi,contlistcatpnormj
30529 ! integer :: newcontlistppi(200*nres),newcontlistppj(200*nres)
30530 integer i,j,itypi,itypj,subchap,xshift,yshift,zshift,iint,ilist_catscnorm,&
30531 ilist_catsctran,ilist_catpnorm,ilist_catptran,itmp,ilist_catscang,&
30532 ilist_catscangf,ilist_catscangt,k
30533 integer displ(0:nprocs),i_ilist_catscnorm(0:nprocs),ierr,&
30534 i_ilist_catpnorm(0:nprocs),i_ilist_catsctran(0:nprocs),&
30535 i_ilist_catptran(0:nprocs),i_ilist_catscang(0:nprocs),&
30536 i_ilist_catscangf(0:nprocs),i_ilist_catscangt(0:nprocs)
30537 ! write(iout,*),"START make_catcat"
30544 if (.not.allocated(contlistcatpnormi)) then
30545 allocate(contlistcatpnormi(900*nres))
30546 allocate(contlistcatpnormj(900*nres))
30551 itmp=itmp+nres_molec(i)
30554 ! do i=1,nres_molec(1)-1 ! loop over all peptide groups needs parralelization
30555 do i=icatb_start,icatb_end
30559 call to_box(xi,yi,zi)
30563 ! dsci_inv=vbld_inv(i+nres)
30564 do j=i+1,itmp+nres_molec(5)
30568 dx_normj=dc_norm(1,j)
30569 dy_normj=dc_norm(2,j)
30570 dz_normj=dc_norm(3,j)
30574 call to_box(xj,yj,zj)
30575 ! call lipid_layer(xj,yj,zj,sslipj,ssgradlipj)
30576 ! faclipij2=(sslipi+sslipj)/2.0d0*lipscale**2+1.0d0
30577 xja=boxshift(xj-xi,boxxsize)
30578 yja=boxshift(yj-yi,boxysize)
30579 zja=boxshift(zj-zi,boxzsize)
30580 dist_init=xja**2+yja**2+zja**2
30581 if (sqrt(dist_init).le.(10.0+r_buff_list)) then
30582 ! Here the list is created
30584 ! print *,i,j,dist_init,ilist_catpnorm
30586 ilist_catpnorm=ilist_catpnorm+1
30588 ! this can be substituted by cantor and anti-cantor
30589 contlistcatpnormi(ilist_catpnorm)=i
30590 contlistcatpnormj(ilist_catpnorm)=j
30596 write (iout,*) "before MPIREDUCE",ilist_catsctran,ilist_catptran,&
30597 ilist_catscnorm,ilist_catpnorm,ilist_catscang
30599 do i=1,ilist_catpnorm
30600 write (iout,*) i,contlistcatpnormi(i)
30605 if (nfgtasks.gt.1)then
30607 call MPI_Reduce(ilist_catpnorm,g_ilist_catcatnorm,1,&
30608 MPI_INTEGER,MPI_SUM,king,FG_COMM,IERR)
30609 ! write(iout,*) "before bcast",g_ilist_sc
30610 call MPI_Gather(ilist_catpnorm,1,MPI_INTEGER,&
30611 i_ilist_catpnorm,1,MPI_INTEGER,king,FG_COMM,IERR)
30613 do i=1,nfgtasks-1,1
30614 displ(i)=i_ilist_catpnorm(i-1)+displ(i-1)
30616 ! write(iout,*) "before gather",displ(0),displ(1)
30617 call MPI_Gatherv(contlistcatpnormi,ilist_catpnorm,MPI_INTEGER,&
30618 newcontlistcatcatnormi,i_ilist_catpnorm,displ,MPI_INTEGER,&
30620 call MPI_Gatherv(contlistcatpnormj,ilist_catpnorm,MPI_INTEGER,&
30621 newcontlistcatcatnormj,i_ilist_catpnorm,displ,MPI_INTEGER,&
30623 call MPI_Bcast(g_ilist_catcatnorm,1,MPI_INT,king,FG_COMM,IERR)
30624 ! write(iout,*) "before bcast",g_ilist_sc
30625 ! call MPI_Bcast(g_ilist_sc,1,MPI_INT,king,FG_COMM)
30626 call MPI_Bcast(newcontlistcatcatnormi,g_ilist_catcatnorm,MPI_INT,king,FG_COMM,IERR)
30627 call MPI_Bcast(newcontlistcatcatnormj,g_ilist_catcatnorm,MPI_INT,king,FG_COMM,IERR)
30631 g_ilist_catcatnorm=ilist_catpnorm
30632 do i=1,ilist_catpnorm
30633 newcontlistcatcatnormi(i)=contlistcatpnormi(i)
30634 newcontlistcatcatnormj(i)=contlistcatpnormj(i)
30637 call int_bounds(g_ilist_catcatnorm,g_listcatcatnorm_start,g_listcatcatnorm_end)
30640 write (iout,*) "after MPIREDUCE",g_ilist_catcatnorm
30642 do i=1,g_ilist_catcatnorm
30643 write (iout,*) i,newcontlistcatcatnormi(i),newcontlistcatcatnormj(i)
30646 ! write(iout,*),"END make_catcat"
30648 end subroutine make_cat_cat_list
30651 !-----------------------------------------------------------------------------
30652 double precision function boxshift(x,boxsize)
30654 double precision x,boxsize
30655 double precision xtemp
30656 xtemp=dmod(x,boxsize)
30657 if (dabs(xtemp-boxsize).lt.dabs(xtemp)) then
30658 boxshift=xtemp-boxsize
30659 else if (dabs(xtemp+boxsize).lt.dabs(xtemp)) then
30660 boxshift=xtemp+boxsize
30665 end function boxshift
30666 !-----------------------------------------------------------------------------
30667 subroutine to_box(xi,yi,zi)
30669 ! include 'DIMENSIONS'
30670 ! include 'COMMON.CHAIN'
30671 double precision xi,yi,zi
30672 xi=dmod(xi,boxxsize)
30673 if (xi.lt.0.0d0) xi=xi+boxxsize
30674 yi=dmod(yi,boxysize)
30675 if (yi.lt.0.0d0) yi=yi+boxysize
30676 zi=dmod(zi,boxzsize)
30677 if (zi.lt.0.0d0) zi=zi+boxzsize
30679 end subroutine to_box
30680 !--------------------------------------------------------------------------
30681 subroutine lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
30683 ! include 'DIMENSIONS'
30684 ! include 'COMMON.IOUNITS'
30685 ! include 'COMMON.CHAIN'
30686 double precision xi,yi,zi,sslipi,ssgradlipi
30687 double precision fracinbuf
30688 ! double precision sscalelip,sscagradlip
30690 write (iout,*) "bordlipbot",bordlipbot," bordliptop",bordliptop
30691 write (iout,*) "buflipbot",buflipbot," lipbufthick",lipbufthick
30692 write (iout,*) "xi yi zi",xi,yi,zi
30694 if ((zi.gt.bordlipbot).and.(zi.lt.bordliptop)) then
30695 ! the energy transfer exist
30696 if (zi.lt.buflipbot) then
30697 ! what fraction I am in
30698 fracinbuf=1.0d0-((zi-bordlipbot)/lipbufthick)
30699 ! lipbufthick is thickenes of lipid buffore
30700 sslipi=sscalelip(fracinbuf)
30701 ssgradlipi=-sscagradlip(fracinbuf)/lipbufthick
30702 elseif (zi.gt.bufliptop) then
30703 fracinbuf=1.0d0-((bordliptop-zi)/lipbufthick)
30704 sslipi=sscalelip(fracinbuf)
30705 ssgradlipi=sscagradlip(fracinbuf)/lipbufthick
30715 write (iout,*) "sslipi",sslipi," ssgradlipi",ssgradlipi
30718 end subroutine lipid_layer
30719 !-------------------------------------------------------------
30720 subroutine ecat_prot_transition(ecation_prottran)
30721 integer:: itypi,itypj,ityptrani,ityptranj,k,l,i,j
30722 real(kind=8),dimension(3):: cjtemp,citemp,diff,dsctemp,vecsc,&
30723 diffnorm,boxx,r,dEvan1Cm,dEvan2Cm,dEtotalCm
30724 real(kind=8):: ecation_prottran,dista,sdist,De,ene,x0left,&
30725 alphac,grad,sumvec,simplesum,pom,erdxi,facd1,&
30726 sss_ele_cut,sss_ele_cut_grad,sss2min,sss2mingrad,&
30727 ene1,ene2,grad1,grad2,evan1,evan2,rcal,r4,r7,r0p,&
30728 r06,r012,epscalc,rocal,ract
30729 ecation_prottran=0.0d0
30733 write(iout,*) "start ecattran",g_listcatsctran_start,g_listcatsctran_end
30734 do k=g_listcatsctran_start,g_listcatsctran_end
30735 i=newcontlistcatsctrani(k)
30736 j=newcontlistcatsctranj(k)
30737 ! print *,i,j,"in new tran"
30739 citemp(l)=c(l,i+nres)
30743 itypi=itype(i,1) !as the first is the protein part
30744 itypj=itype(j,5) !as the second part is always cation
30745 ! remapping to internal types
30746 ! read (iiontran,*,err=123,end=123) (agamacattran(k,j,i),k=1,3),&
30747 ! (athetacattran(k,j,i),k=1,6),acatshiftdsc(j,i),bcatshiftdsc(j,i),&
30748 ! demorsecat(j,i),alphamorsecat(j,i),x0catleft(j,i),x0catright(j,i),&
30751 if (itypj.eq.6) then
30752 ityptranj=1 !as now only Zn2+ is this needs to be modified for other ions
30754 if (itypi.eq.16) then
30756 elseif (itypi.eq.1) then
30758 elseif (itypi.eq.15) then
30760 elseif (itypi.eq.17) then
30762 elseif (itypi.eq.2) then
30768 if (ityptrani.gt.ntrantyp(ityptranj)) then
30770 ! write(iout,*),gradcattranc(l,j),gradcattranx(l,i)
30773 call to_box(cjtemp(1),cjtemp(2),cjtemp(3))
30774 call to_box(citemp(1),citemp(2),citemp(3))
30777 r(l)=boxshift(cjtemp(l)-citemp(l),boxx(l))
30778 rcal=rcal+r(l)*r(l)
30781 if (ract.gt.r_cut_ele) cycle
30782 sss_ele_cut=sscale_ele(ract)
30783 sss_ele_cut_grad=sscagrad_ele(ract)
30786 r0p=0.5*(rocal+sig0(itype(i,1)))
30789 Evan1=epscalc*(r012/rcal**6)
30790 Evan2=epscalc*2*(r06/rcal**3)
30794 dEvan1Cm(l) = 12*r(l)*epscalc*r012/r7
30795 dEvan2Cm(l) = 12*r(l)*epscalc*r06/r4
30798 dEtotalCm(l)=(dEvan1Cm(l)+dEvan2Cm(l))*sss_ele_cut-&
30799 (Evan1+Evan2)*sss_ele_cut_grad*r(l)/ract
30801 ecation_prottran = ecation_prottran+&
30802 (Evan1+Evan2)*sss_ele_cut
30804 gradcattranx(l,i)=gradcattranx(l,i)+dEtotalCm(l)
30805 gradcattranc(l,i)=gradcattranc(l,i)+dEtotalCm(l)
30806 gradcattranc(l,j)=gradcattranc(l,j)-dEtotalCm(l)
30815 vecsc(l)=citemp(l)-c(l,i)
30816 sumvec=sumvec+vecsc(l)**2
30817 simplesum=simplesum+vecsc(l)
30819 sumvec=dsqrt(sumvec)
30820 call to_box(cjtemp(1),cjtemp(2),cjtemp(3))
30821 call to_box(citemp(1),citemp(2),citemp(3))
30824 dsctemp(l)=c(l,i+nres)&
30825 +(acatshiftdsc(ityptrani,ityptranj)-1.0d0)*vecsc(l)&
30826 +bcatshiftdsc(ityptrani,ityptranj)*vecsc(l)/sumvec
30828 call to_box(dsctemp(1),dsctemp(2),dsctemp(3))
30831 diff(l)=boxshift(dsctemp(l)-cjtemp(l),boxx(l))
30832 sdist=sdist+diff(l)*diff(l)
30835 if (dista.gt.r_cut_ele) cycle
30837 sss_ele_cut=sscale_ele(dista)
30838 sss_ele_cut_grad=sscagrad_ele(dista)
30839 sss2min=sscale2(dista,x0cattrans(ityptrani,ityptranj)-0.1d0,0.2d0)
30840 De=demorsecat(ityptrani,ityptranj)
30841 alphac=alphamorsecat(ityptrani,ityptranj)
30842 if (sss2min.eq.1.0d0) then
30843 ! print *,"ityptrani",ityptrani,ityptranj
30844 x0left=x0catleft(ityptrani,ityptranj) ! to mn
30845 ene=sss_ele_cut*(-De+De*(1.0d0-dexp(-alphac*(dista-x0left)))**2)
30846 grad=2.0d0*alphac*De*dexp(-alphac*(dista-x0left))*&
30847 (1.0d0-dexp(-alphac*(dista-x0left)))*sss_ele_cut&
30848 +ene/sss_ele_cut*sss_ele_cut_grad
30849 else if (sss2min.eq.0.0d0) then
30850 x0left=x0catright(ityptrani,ityptranj)
30851 ene=sss_ele_cut*(-De+De*(1.0d0-dexp(-alphac*(dista-x0left)))**2)
30852 grad=2.0d0*alphac*De*dexp(-alphac*(dista-x0left))*&
30853 (1.0d0-dexp(-alphac*(dista-x0left)))*sss_ele_cut&
30854 +ene/sss_ele_cut*sss_ele_cut_grad
30856 sss2mingrad=sscagrad2(dista,x0cattrans(ityptrani,ityptranj)-0.1d0,0.2d0)
30857 x0left=x0catleft(ityptrani,ityptranj)
30858 ene1=sss_ele_cut*(-De+De*(1.0d0-dexp(-alphac*(dista-x0left)))**2)
30859 grad1=2.0d0*alphac*De*dexp(-alphac*(dista-x0left))*&
30860 (1.0d0-dexp(-alphac*(dista-x0left)))*sss_ele_cut&
30861 +ene/sss_ele_cut*sss_ele_cut_grad
30862 x0left=x0catright(ityptrani,ityptranj)
30863 ene2=sss_ele_cut*(-De+De*(1.0d0-dexp(-alphac*(dista-x0left)))**2)
30864 grad2=2.0d0*alphac*De*dexp(-alphac*(dista-x0left))*&
30865 (1.0d0-dexp(-alphac*(dista-x0left)))*sss_ele_cut&
30866 +ene/sss_ele_cut*sss_ele_cut_grad
30867 ene=sss2min*ene1+(1.0d0-sss2min)*ene2
30868 grad=sss2min*grad1+(1.0d0-sss2min)*grad2+sss2mingrad*(ene1-ene2)
30871 diffnorm(l)= diff(l)/dista
30873 erdxi=scalar(diffnorm(1),dc_norm(1,i+nres))
30874 facd1=bcatshiftdsc(ityptrani,ityptranj)/sumvec
30878 ! ertail(k) = Rtail_distance(k)/Rtail
30880 ! erdxi = scalar( ertail(1), dC_norm(1,i+nres) )
30881 ! erdxj = scalar( ertail(1), dC_norm(1,j+nres) )
30882 ! facd1 = dtail(1,itypi,itypj) * vbld_inv(i+nres)
30883 ! facd2 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
30885 !c! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
30886 !c! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
30887 ! pom = ertail(k)-facd1*(ertail(k)-erdxi*dC_norm(k,i+nres))
30888 ! gvdwx(k,i) = gvdwx(k,i) &
30889 ! - (( dFdR + gg(k) ) * pom)
30890 pom=diffnorm(l)+facd1*(diffnorm(l)-erdxi*dc_norm(l,i+nres))
30891 ! write(iout,*),gradcattranc(l,j),gradcattranx(l,i),grad*diff(l)/dista
30893 gradcattranx(l,i)=gradcattranx(l,i)+grad*pom&
30894 +grad*diffnorm(l)*(acatshiftdsc(ityptrani,ityptranj)-1.0d0)
30895 ! *( bcatshiftdsc(ityptrani,ityptranj)*&
30896 ! (1.0d0/sumvec-(vecsc(l)*simplesum)*(sumvec**(-3.0d0))))
30897 gradcattranc(l,i)=gradcattranc(l,i)+grad*diff(l)/dista
30898 ! +sss_ele_cut_grad*ene*diff(l)/dista/sss_ele_cut
30899 gradcattranc(l,j)=gradcattranc(l,j)-grad*diff(l)/dista
30900 ! -sss_ele_cut_grad*ene*diff(l)/dista/sss_ele_cut
30902 ecation_prottran=ecation_prottran+ene
30903 if (energy_dec) write(iout,*) "etrancat",i,j,ene,x0left,De,dista,&
30907 ! do k=g_listcatptran_start,g_listcatptran_end
30908 ! ene=0.0d0 this will be used if peptide group interaction is needed
30914 subroutine ecat_prot_ang(ecation_protang)
30915 integer:: itypi,itypj,ityptrani,ityptranj,k,l,i,j,n,m,&
30916 ityptrani1,ityptranj1,ityptrani2,ityptranj2,&
30917 i1,i2,j1,j2,k1,k2,k3,i3,j3,ityptrani3,ityptranj3
30919 real(kind=8),dimension(3):: cjtemp,citemp,diff,dsctemp,vecsc,&
30920 diffnorm,boxx,dscvec,dscvecnorm,diffnorm2,&
30921 dscvec2,dscvecnorm2,cjtemp2,citemp2,diff2,dsctemp2,&
30922 vecsc2,diff1,diffnorm1,diff3,mindiffnorm2
30923 real(kind=8),dimension(3):: dscvec1,dscvecnorm1,cjtemp1,citemp1,vecsc1,dsctemp1,&
30924 dscvec3,dscvecnorm3,cjtemp3,citemp3,vecsc3,dsctemp3,&
30925 diffnorm3,diff4,diffnorm4
30927 real(kind=8):: ecation_protang,dista,sdist,De,ene,x0left,&
30928 alphac,grad,sumvec,sumdscvec,pom,erdxi,facd1,&
30929 sss_ele_cut,sss_ele_cut_grad,sss2min,sss2mingrad,&
30930 simplesum,cosval,part1,part2a,part2,part2b,part3,&
30931 part4a,part4b,part4,bottom,dista2,sdist2,sumvec2,&
30932 sumdscvec2,simplesum2,dista1,sdist1,sumvec1,simplesum1,&
30933 sumdscvec1,facd2,scal1a,scal1b,scal2a,scal2b,&
30934 sss2mingrad1,sss2mingrad2,sss2min1,sss2min2,pom1,pom2,&
30935 det1ij,det2ij,cosom1,cosom2,cosom12,cosphij,dista3,&
30937 real(kind=8):: sinom1,sinom2,sinaux,dephiij,sumdscvec3,sumscvec3,&
30938 cosphi,sdist3,simplesum3,det1t2ij,sss2mingrad3,sss2min3,&
30939 scal1c,scal2c,scal3a,scal3b,scal3c,facd3,facd2b,scal3d,&
30940 scal3e,dista4,sdist4,pom3,sssmintot
30942 ecation_protang=0.0d0
30946 ! print *,"KUR**3",g_listcatscang_start,g_listcatscang_end
30949 do k=g_listcatscang_start,g_listcatscang_end
30951 i=newcontlistcatscangi(k)
30952 j=newcontlistcatscangj(k)
30953 itypi=itype(i,1) !as the first is the protein part
30954 itypj=itype(j,5) !as the second part is always cation
30955 ! print *,"KUR**4",i,j,itypi,itypj
30956 ! remapping to internal types
30957 ! read (iiontran,*,err=123,end=123) (agamacattran(k,j,i),k=1,3),&
30958 ! (athetacattran(k,j,i),k=1,6),acatshiftdsc(j,i),bcatshiftdsc(j,i),&
30959 ! demorsecat(j,i),alphamorsecat(j,i),x0catleft(j,i),x0catright(j,i),&
30961 if (itypj.eq.6) then
30962 ityptranj=1 !as now only Zn2+ is this needs to be modified for other ions
30964 if (itypi.eq.16) then
30966 elseif (itypi.eq.1) then
30968 elseif (itypi.eq.15) then
30970 elseif (itypi.eq.17) then
30972 elseif (itypi.eq.2) then
30977 if (ityptrani.gt.ntrantyp(ityptranj)) cycle
30979 citemp(l)=c(l,i+nres)
30985 vecsc(l)=citemp(l)-c(l,i)
30986 sumvec=sumvec+vecsc(l)**2
30987 simplesum=simplesum+vecsc(l)
30989 sumvec=dsqrt(sumvec)
30994 +(acatshiftdsc(ityptrani,ityptranj))*vecsc(l)&
30995 +bcatshiftdsc(ityptrani,ityptranj)*vecsc(l)/sumvec
30998 (acatshiftdsc(ityptrani,ityptranj))*vecsc(l)&
30999 +bcatshiftdsc(ityptrani,ityptranj)*vecsc(l)/sumvec
31000 sumdscvec=sumdscvec+dscvec(l)**2
31002 sumdscvec=dsqrt(sumdscvec)
31004 dscvecnorm(l)=dscvec(l)/sumdscvec
31006 call to_box(dsctemp(1),dsctemp(2),dsctemp(3))
31007 call to_box(cjtemp(1),cjtemp(2),cjtemp(3))
31010 diff(l)=boxshift(dsctemp(l)-cjtemp(l),boxx(l))
31011 sdist=sdist+diff(l)*diff(l)
31015 diffnorm(l)= diff(l)/dista
31017 cosval=scalar(diffnorm(1),dc_norm(1,i+nres))
31019 sss2min=sscale2(dista,r_cut_ang,1.0d0)
31020 sss2mingrad=sscagrad2(dista,r_cut_ang,1.0d0)
31022 +tschebyshev(1,6,athetacattran(1,ityptrani,ityptranj),cosval)
31023 grad=gradtschebyshev(0,5,athetacattran(1,ityptrani,ityptranj),cosval)*sss2min
31025 facd1=bcatshiftdsc(ityptrani,ityptranj)/sumvec
31026 erdxi=scalar(diffnorm(1),dc_norm(1,i+nres))
31032 bottom=sumvec**2*sdist
31033 part1=diff(l)*sumvec*dista
31034 part2a=(acatshiftdsc(ityptrani,ityptranj))*vecsc(l)
31036 !bcatshiftdsc(ityptrani,ityptranj)/sumvec*&
31037 !(vecsc(l)-cosval*dista*dc_norm(l,i+nres))
31038 part2=(part2a+part2b)*sumvec*dista
31039 part3=cosval*sumvec*dista*dc_norm(l,i+nres)*dista
31040 part4a=diff(l)*acatshiftdsc(ityptrani,ityptranj)
31041 part4b=bcatshiftdsc(ityptrani,ityptranj)/sumvec*&
31042 (diff(l)-cosval*dista*dc_norm(l,i+nres))
31043 part4=cosval*sumvec*(part4a+part4b)*sumvec
31044 ! gradlipang(m,l)=gradlipang(m,l)+(fac &
31045 ! *(xa(m)-scalar*vnorm*xb(m)/wnorm)&
31049 ! ertail(k) = Rtail_distance(k)/Rtail
31051 ! erdxi = scalar( ertail(1), dC_norm(1,i+nres) )
31052 ! erdxj = scalar( ertail(1), dC_norm(1,j+nres) )
31053 ! facd1 = dtail(1,itypi,itypj) * vbld_inv(i+nres)
31054 ! facd2 = dtail(2,itypi,itypj) * vbld_inv(j+nres)
31056 !c! write (*,*) "Gvdwc(",k,",",i,")=", gvdwc(k,i)
31057 !c! write (*,*) "Gvdwc(",k,",",j,")=", gvdwc(k,j)
31058 ! pom = ertail(k)-facd1*(ertail(k)-erdxi*dC_norm(k,i+nres))
31059 ! gvdwx(k,i) = gvdwx(k,i) &
31060 ! - (( dFdR + gg(k) ) * pom)
31061 pom=diffnorm(l)+facd1*(diffnorm(l)-erdxi*dc_norm(l,i+nres))
31063 gradcatangc(l,j)=gradcatangc(l,j)-grad*&
31064 (dscvec(l)-cosval*diffnorm(l)*sumdscvec)/(sumdscvec*dista)-&
31065 ene*sss2mingrad*diffnorm(l)
31067 gradcatangc(l,i)=gradcatangc(l,i)+grad*&
31068 (dscvec(l)-cosval*diffnorm(l)*sumdscvec)/(sumdscvec*dista)+&
31069 ene*sss2mingrad*diffnorm(l)
31071 gradcatangx(l,i)=gradcatangx(l,i)+grad*&
31072 (part1+part2-part3-part4)/bottom+&
31073 ene*sss2mingrad*pom+&
31074 ene*sss2mingrad*diffnorm(l)*(acatshiftdsc(ityptrani,ityptranj)-1.0d0)
31075 ! +grad*(dscvec(l)-cosval*diffnorm(l)*sumdscvec)/(sumdscvec*dista)&
31076 ! +grad*pom+grad*diffnorm(l)*(acatshiftdsc(ityptrani,ityptranj)-1.0d0)
31078 ! (diff(l)-cosval*dscvecnorm(l)*dista)/(sumdscvec*dista)
31085 ! print *,i,j,cosval,tschebyshev(1,3,aomicattr(1,ityptranj),cosval)&
31086 ! ,aomicattr(0,ityptranj),ene
31087 if (energy_dec) write(iout,*) i,j,ityptrani,ityptranj,ene,cosval
31088 ecation_protang=ecation_protang+ene*sss2min
31091 ! print *,"KUR**",g_listcatscangf_start,g_listcatscangf_end
31092 do k=g_listcatscangf_start,g_listcatscangf_end
31094 i1=newcontlistcatscangfi(k)
31095 j1=newcontlistcatscangfj(k)
31096 itypi=itype(i1,1) !as the first is the protein part
31097 itypj=itype(j1,5) !as the second part is always cation
31098 if (itypj.eq.6) then
31099 ityptranj1=1 !as now only Zn2+ is this needs to be modified for other ions
31101 if (itypi.eq.16) then
31103 elseif (itypi.eq.1) then
31105 elseif (itypi.eq.15) then
31107 elseif (itypi.eq.17) then
31109 elseif (itypi.eq.2) then
31115 citemp1(l)=c(l,i1+nres)
31121 vecsc1(l)=citemp1(l)-c(l,i1)
31122 sumvec1=sumvec1+vecsc1(l)**2
31123 simplesum1=simplesum1+vecsc1(l)
31125 sumvec1=dsqrt(sumvec1)
31128 dsctemp1(l)=c(l,i1)&
31130 +(acatshiftdsc(ityptrani1,ityptranj1))*vecsc1(l)&
31131 +bcatshiftdsc(ityptrani1,ityptranj1)*vecsc1(l)/sumvec1
31134 (acatshiftdsc(ityptrani1,ityptranj1))*vecsc1(l)&
31135 +bcatshiftdsc(ityptrani1,ityptranj1)*vecsc1(l)/sumvec1
31136 sumdscvec1=sumdscvec1+dscvec1(l)**2
31138 sumdscvec1=dsqrt(sumdscvec1)
31140 dscvecnorm1(l)=dscvec1(l)/sumdscvec1
31142 call to_box(dsctemp1(1),dsctemp1(2),dsctemp1(3))
31143 call to_box(cjtemp1(1),cjtemp1(2),cjtemp1(3))
31146 diff1(l)=boxshift(dsctemp1(l)-cjtemp1(l),boxx(l))
31147 sdist1=sdist1+diff1(l)*diff1(l)
31149 dista1=sqrt(sdist1)
31151 diffnorm1(l)= diff1(l)/dista1
31153 sss2min1=sscale2(dista1,r_cut_ang,1.0d0)
31154 sss2mingrad1=sscagrad2(dista1,r_cut_ang,1.0d0)
31155 if (ityptrani1.gt.ntrantyp(ityptranj1)) cycle
31157 !-----------------------------------------------------------------
31158 ! do m=k+1,g_listcatscang_end
31160 i2=newcontlistcatscangfk(k)
31162 if (j1.ne.j2) cycle
31163 itypi=itype(i2,1) !as the first is the protein part
31164 itypj=itype(j2,5) !as the second part is always cation
31165 if (itypj.eq.6) then
31166 ityptranj2=1 !as now only Zn2+ is this needs to be modified for other ions
31168 if (itypi.eq.16) then
31170 elseif (itypi.eq.1) then
31172 elseif (itypi.eq.15) then
31174 elseif (itypi.eq.17) then
31176 elseif (itypi.eq.2) then
31181 if (ityptrani2.gt.ntrantyp(ityptranj2)) cycle
31184 citemp2(l)=c(l,i2+nres)
31190 vecsc2(l)=citemp2(l)-c(l,i2)
31191 sumvec2=sumvec2+vecsc2(l)**2
31192 simplesum2=simplesum2+vecsc2(l)
31194 sumvec2=dsqrt(sumvec2)
31197 dsctemp2(l)=c(l,i2)&
31199 +(acatshiftdsc(ityptrani2,ityptranj2))*vecsc2(l)&
31200 +bcatshiftdsc(ityptrani2,ityptranj2)*vecsc2(l)/sumvec2
31203 (acatshiftdsc(ityptrani2,ityptranj2))*vecsc2(l)&
31204 +bcatshiftdsc(ityptrani2,ityptranj2)*vecsc2(l)/sumvec2
31205 sumdscvec2=sumdscvec2+dscvec2(l)**2
31207 sumdscvec2=dsqrt(sumdscvec2)
31209 dscvecnorm2(l)=dscvec2(l)/sumdscvec2
31211 call to_box(dsctemp2(1),dsctemp2(2),dsctemp2(3))
31212 call to_box(cjtemp2(1),cjtemp2(2),cjtemp2(3))
31215 diff2(l)=boxshift(dsctemp2(l)-cjtemp2(l),boxx(l))
31217 sdist2=sdist2+diff2(l)*diff2(l)
31219 dista2=sqrt(sdist2)
31221 diffnorm2(l)= diff2(l)/dista2
31223 ! print *,i1,i2,diffnorm2(1)
31224 cosval=scalar(diffnorm1(1),diffnorm2(1))
31226 sss2min2=sscale2(dista2,r_cut_ang,1.0d0)
31227 sss2mingrad2=sscagrad2(dista2,r_cut_ang,1.0d0)
31228 ene=ene+tschebyshev(1,3,aomicattr(1,ityptranj1),cosval)
31229 grad=gradtschebyshev(0,2,aomicattr(1,ityptranj1),cosval)*sss2min2*sss2min1
31234 ecation_protang=ecation_protang+ene*sss2min2*sss2min1
31235 facd1=bcatshiftdsc(ityptrani1,ityptranj1)/sumvec1
31236 facd2=bcatshiftdsc(ityptrani2,ityptranj2)/sumvec2
31237 scal1a=scalar(diffnorm1(1),dc_norm(1,i1+nres))
31238 scal1b=scalar(diffnorm2(1),dc_norm(1,i1+nres))
31239 scal2a=scalar(diffnorm1(1),dc_norm(1,i2+nres))
31240 scal2b=scalar(diffnorm2(1),dc_norm(1,i2+nres))
31242 if (energy_dec) write(iout,*) "omi", i,j,ityptrani,ityptranj,ene,cosval,aomicattr(1,ityptranj1),&
31243 aomicattr(2,ityptranj1),aomicattr(3,ityptranj1),tschebyshev(1,3,aomicattr(1,ityptranj1),cosval)
31247 pom1=diffnorm1(l)+facd1*(diffnorm1(l)-scal1a*dc_norm(l,i1+nres))
31248 pom2=diffnorm2(l)+facd2*(diffnorm2(l)-scal2b*dc_norm(l,i2+nres))
31251 gradcatangc(l,i1)=gradcatangc(l,i1)+grad*(diff2(l)-&
31252 cosval*diffnorm1(l)*dista2)/(dista2*dista1)+&
31253 ene*sss2mingrad1*diffnorm1(l)*sss2min2
31256 gradcatangx(l,i1)=gradcatangx(l,i1)+grad/(dista2*dista1)*&
31257 (acatshiftdsc(ityptrani1,ityptranj1)*diff2(l)+&
31258 facd1*(diff2(l)-scal1b*dc_norm(l,i1+nres)*dista2)-&
31259 cosval*dista2/dista1*&
31260 (acatshiftdsc(ityptrani1,ityptranj1)*diff1(l)+&
31261 facd1*(diff1(l)-scal1a*dc_norm(l,i1+nres)*dista1)))+&
31262 ene*sss2mingrad1*sss2min2*(pom1+&
31263 diffnorm1(l)*(acatshiftdsc(ityptrani1,ityptranj1)-1.0d0))
31266 gradcatangx(l,i2)=gradcatangx(l,i2)+grad/(dista2*dista1)*&
31267 (acatshiftdsc(ityptrani2,ityptranj2)*diff1(l)+&
31268 facd2*(diff1(l)-scal2a*dc_norm(l,i2+nres)*dista1)-&
31269 cosval*dista1/dista2*&
31270 (acatshiftdsc(ityptrani2,ityptranj2)*diff2(l)+&
31271 facd2*(diff2(l)-scal2b*dc_norm(l,i2+nres)*dista2)))+&
31272 ene*sss2mingrad2*sss2min1*(pom2+&
31273 diffnorm2(l)*(acatshiftdsc(ityptrani2,ityptranj2)-1.0d0))
31276 gradcatangx(l,i2)=gradcatangx(l,i2)
31277 gradcatangc(l,i2)=gradcatangc(l,i2)+grad*(diff1(l)-&
31278 cosval*diffnorm2(l)*dista1)/(dista2*dista1)+&
31279 ene*sss2mingrad2*diffnorm2(l)*sss2min1
31281 gradcatangc(l,j2)=gradcatangc(l,j2)-grad*(diff2(l)/dista2/dista1-&
31282 cosval*diff1(l)/dista1/dista1+diff1(l)/dista2/dista1-&
31283 cosval*diff2(l)/dista2/dista2)-&
31284 ene*sss2mingrad1*diffnorm1(l)*sss2min2-&
31285 ene*sss2mingrad2*diffnorm2(l)*sss2min1
31294 ! do k1=g_listcatscang_start,g_listcatscang_end
31295 ! print *,"KURNA",g_listcatscangt_start,g_listcatscangt_end
31296 do k1=g_listcatscangt_start,g_listcatscangt_end
31297 i1=newcontlistcatscangti(k1)
31298 j1=newcontlistcatscangtj(k1)
31299 itypi=itype(i1,1) !as the first is the protein part
31300 itypj=itype(j1,5) !as the second part is always cation
31301 if (itypj.eq.6) then
31302 ityptranj1=1 !as now only Zn2+ is this needs to be modified for other ions
31304 if (itypi.eq.16) then
31306 elseif (itypi.eq.1) then
31308 elseif (itypi.eq.15) then
31310 elseif (itypi.eq.17) then
31312 elseif (itypi.eq.2) then
31318 citemp1(l)=c(l,i1+nres)
31324 vecsc1(l)=citemp1(l)-c(l,i1)
31325 sumvec1=sumvec1+vecsc1(l)**2
31326 simplesum1=simplesum1+vecsc1(l)
31328 sumvec1=dsqrt(sumvec1)
31331 dsctemp1(l)=c(l,i1)&
31332 +(acatshiftdsc(ityptrani1,ityptranj1))*vecsc1(l)&
31333 +bcatshiftdsc(ityptrani1,ityptranj1)*vecsc1(l)/sumvec1
31335 (acatshiftdsc(ityptrani1,ityptranj1))*vecsc1(l)&
31336 +bcatshiftdsc(ityptrani1,ityptranj1)*vecsc1(l)/sumvec1
31337 sumdscvec1=sumdscvec1+dscvec1(l)**2
31339 sumdscvec1=dsqrt(sumdscvec1)
31341 dscvecnorm1(l)=dscvec1(l)/sumdscvec1
31343 call to_box(dsctemp1(1),dsctemp1(2),dsctemp1(3))
31344 call to_box(cjtemp1(1),cjtemp1(2),cjtemp1(3))
31347 diff1(l)=boxshift(dsctemp1(l)-cjtemp1(l),boxx(l))
31348 sdist1=sdist1+diff1(l)*diff1(l)
31350 dista1=sqrt(sdist1)
31352 diffnorm1(l)= diff1(l)/dista1
31354 sss2min1=sscale2(dista1,r_cut_ang,1.0d0)
31355 sss2mingrad1=sscagrad2(dista1,r_cut_ang,1.0d0)
31356 if (ityptrani1.gt.ntrantyp(ityptranj1)) cycle
31357 !---------------before second loop
31358 ! do k2=k1+1,g_listcatscang_end
31359 i2=newcontlistcatscangtk(k1)
31361 ! print *,"TUTU3",i1,i2,j1,j2
31362 if (i2.eq.i1) cycle
31363 if (j2.ne.j1) cycle
31364 itypi=itype(i2,1) !as the first is the protein part
31365 itypj=itype(j2,5) !as the second part is always cation
31366 if (itypj.eq.6) then
31367 ityptranj2=1 !as now only Zn2+ is this needs to be modified for other ions
31369 if (itypi.eq.16) then
31371 elseif (itypi.eq.1) then
31373 elseif (itypi.eq.15) then
31375 elseif (itypi.eq.17) then
31377 elseif (itypi.eq.2) then
31382 if (ityptrani2.gt.ntrantyp(ityptranj2)) cycle
31384 citemp2(l)=c(l,i2+nres)
31390 vecsc2(l)=citemp2(l)-c(l,i2)
31391 sumvec2=sumvec2+vecsc2(l)**2
31392 simplesum2=simplesum2+vecsc2(l)
31394 sumvec2=dsqrt(sumvec2)
31397 dsctemp2(l)=c(l,i2)&
31398 +(acatshiftdsc(ityptrani2,ityptranj2))*vecsc2(l)&
31399 +bcatshiftdsc(ityptrani2,ityptranj2)*vecsc2(l)/sumvec2
31401 (acatshiftdsc(ityptrani2,ityptranj2))*vecsc2(l)&
31402 +bcatshiftdsc(ityptrani2,ityptranj2)*vecsc2(l)/sumvec2
31403 sumdscvec2=sumdscvec2+dscvec2(l)**2
31405 sumdscvec2=dsqrt(sumdscvec2)
31407 dscvecnorm2(l)=dscvec2(l)/sumdscvec2
31409 call to_box(dsctemp2(1),dsctemp2(2),dsctemp2(3))
31410 call to_box(cjtemp2(1),cjtemp2(2),cjtemp2(3))
31413 diff2(l)=boxshift(dsctemp2(l)-cjtemp2(l),boxx(l))
31415 sdist2=sdist2+diff2(l)*diff2(l)
31417 dista2=sqrt(sdist2)
31419 diffnorm2(l)= diff2(l)/dista2
31420 mindiffnorm2(l)=-diffnorm2(l)
31422 ! print *,i1,i2,diffnorm2(1)
31423 cosom1=scalar(diffnorm1(1),diffnorm2(1))
31424 sss2min2=sscale2(dista2,r_cut_ang,1.0d0)
31425 sss2mingrad2=sscagrad2(dista2,r_cut_ang,1.0d0)
31427 !---------------- before third loop
31428 ! do k3=g_listcatscang_start,g_listcatscang_end
31430 i3=newcontlistcatscangtl(k1)
31432 ! print *,"TUTU4",i1,i2,i3,j1,j2,j3
31434 if (i3.eq.i2) cycle
31435 if (i3.eq.i1) cycle
31436 if (j3.ne.j1) cycle
31437 itypi=itype(i3,1) !as the first is the protein part
31438 itypj=itype(j3,5) !as the second part is always cation
31439 if (itypj.eq.6) then
31440 ityptranj3=1 !as now only Zn2+ is this needs to be modified for other ions
31442 if (itypi.eq.16) then
31444 elseif (itypi.eq.1) then
31446 elseif (itypi.eq.15) then
31448 elseif (itypi.eq.17) then
31450 elseif (itypi.eq.2) then
31455 if (ityptrani3.gt.ntrantyp(ityptranj3)) cycle
31457 citemp3(l)=c(l,i3+nres)
31463 vecsc3(l)=citemp3(l)-c(l,i3)
31464 sumvec3=sumvec3+vecsc3(l)**2
31465 simplesum3=simplesum3+vecsc3(l)
31467 sumvec3=dsqrt(sumvec3)
31470 dsctemp3(l)=c(l,i3)&
31471 +(acatshiftdsc(ityptrani3,ityptranj3))*vecsc3(l)&
31472 +bcatshiftdsc(ityptrani3,ityptranj3)*vecsc3(l)/sumvec3
31474 (acatshiftdsc(ityptrani3,ityptranj3))*vecsc3(l)&
31475 +bcatshiftdsc(ityptrani3,ityptranj3)*vecsc3(l)/sumvec3
31476 sumdscvec3=sumdscvec3+dscvec3(l)**2
31478 sumdscvec3=dsqrt(sumdscvec3)
31480 dscvecnorm3(l)=dscvec3(l)/sumdscvec3
31482 call to_box(dsctemp3(1),dsctemp3(2),dsctemp3(3))
31483 call to_box(cjtemp3(1),cjtemp3(2),cjtemp3(3))
31486 diff3(l)=boxshift(dsctemp3(l)-dsctemp2(l),boxx(l))
31487 sdist3=sdist3+diff3(l)*diff3(l)
31489 dista3=sqrt(sdist3)
31491 diffnorm3(l)= diff3(l)/dista3
31495 diff4(l)=boxshift(dsctemp3(l)-cjtemp2(l),boxx(l))
31497 sdist4=sdist4+diff4(l)*diff4(l)
31499 dista4=sqrt(sdist4)
31501 diffnorm4(l)= diff4(l)/dista4
31504 sss2min3=sscale2(dista4,r_cut_ang,1.0d0)
31505 sss2mingrad3=sscagrad2(dista4,r_cut_ang,1.0d0)
31506 sssmintot=sss2min3*sss2min2*sss2min1
31507 if (ityptrani3.gt.ntrantyp(ityptranj3)) cycle
31508 cosom12=scalar(diffnorm3(1),diffnorm1(1))
31509 cosom2=scalar(diffnorm3(1),mindiffnorm2(1))
31510 sinom1=dsqrt(1.0d0-cosom1*cosom1)
31511 sinom2=dsqrt(1.0d0-cosom2*cosom2)
31512 cosphi=cosom12-cosom1*cosom2
31513 sinaux=sinom1*sinom2
31514 ene=ene+mytschebyshev(1,3,agamacattran(1,ityptrani2,ityptranj2),cosphi,sinaux)
31515 call mygradtschebyshev(1,3,agamacattran(1,ityptrani2,ityptranj2)&
31516 ,cosphi,sinaux,dephiij,det1t2ij)
31518 det1ij=-det1t2ij*sinom2*cosom1/sinom1-dephiij*cosom2
31519 det2ij=-det1t2ij*sinom1*cosom2/sinom2-dephiij*cosom1
31520 facd1=bcatshiftdsc(ityptrani1,ityptranj1)/sumvec1
31521 facd2=bcatshiftdsc(ityptrani2,ityptranj2)/sumvec2
31522 ! facd2b=bcatshiftdsc(ityptrani2,ityptranj2)/sumvec3
31523 facd3=bcatshiftdsc(ityptrani3,ityptranj3)/sumvec3
31524 scal1a=scalar(diffnorm1(1),dc_norm(1,i1+nres))
31525 scal1b=scalar(diffnorm2(1),dc_norm(1,i1+nres))
31526 scal1c=scalar(diffnorm3(1),dc_norm(1,i1+nres))
31527 scal2a=scalar(diffnorm1(1),dc_norm(1,i2+nres))
31528 scal2b=scalar(diffnorm2(1),dc_norm(1,i2+nres))
31529 scal2c=scalar(diffnorm3(1),dc_norm(1,i2+nres))
31530 scal3a=scalar(diffnorm1(1),dc_norm(1,i3+nres))
31531 scal3b=scalar(mindiffnorm2(1),dc_norm(1,i3+nres))
31532 scal3d=scalar(diffnorm2(1),dc_norm(1,i3+nres))
31533 scal3c=scalar(diffnorm3(1),dc_norm(1,i3+nres))
31534 scal3e=scalar(diffnorm4(1),dc_norm(1,i3+nres))
31538 pom1=diffnorm1(l)+facd1*(diffnorm1(l)-scal1a*dc_norm(l,i1+nres))
31539 pom2=diffnorm2(l)+facd2*(diffnorm2(l)-scal2b*dc_norm(l,i2+nres))
31540 pom3=diffnorm4(l)+facd3*(diffnorm4(l)-scal3e*dc_norm(l,i3+nres))
31542 gradcatangc(l,i1)=gradcatangc(l,i1)&
31543 +det1ij*sssmintot*(diff2(l)-diffnorm1(l)*cosom1*dista2)/(dista2*dista1)+&
31544 dephiij*sssmintot*(diff3(l)-diffnorm1(l)*cosom12*dista3)/(dista3*dista1)&
31545 +ene*sss2mingrad1*diffnorm1(l)*sss2min2*sss2min3
31548 gradcatangc(l,i2)=gradcatangc(l,i2)+(&
31549 det1ij*(diff1(l)-diffnorm2(l)*cosom1*dista1)/(dista2*dista1)+&
31550 det2ij*(-diff3(l)+mindiffnorm2(l)*cosom2*dista3)/(dista3*dista2)&
31551 -det2ij*(-diff2(l)-diffnorm3(l)*cosom2*dista2)/(dista3*dista2)&
31552 -dephiij*(diff1(l)-diffnorm3(l)*cosom12*dista1)/(dista3*dista1))*sssmintot&
31553 +ene*sss2mingrad2*diffnorm2(l)*sss2min1*sss2min3
31557 gradcatangc(l,i3)=gradcatangc(l,i3)&
31558 +det2ij*(-diff2(l)-diffnorm3(l)*cosom2*dista2)/(dista3*dista2)*sssmintot&
31559 +dephiij*(diff1(l)-diffnorm3(l)*cosom12*dista1)/(dista3*dista1)*sssmintot&
31560 +ene*sss2mingrad3*diffnorm4(l)*sss2min1*sss2min2
31563 gradcatangc(l,j1)=gradcatangc(l,j1)-&
31564 sssmintot*(det1ij*(diff2(l)-diffnorm1(l)*cosom1*dista2)/(dista2*dista1)+&
31565 dephiij*(diff3(l)-diffnorm1(l)*cosom12*dista3)/(dista3*dista1))&
31566 -(det1ij*(diff1(l)-diffnorm2(l)*cosom1*dista1)/(dista1*dista2)+&
31567 det2ij*(-diff3(l)+mindiffnorm2(l)*cosom2*dista3)/(dista3*dista2))*sssmintot&
31568 -ene*sss2mingrad1*diffnorm1(l)*sss2min2*sss2min3&
31569 -ene*sss2mingrad2*diffnorm2(l)*sss2min1*sss2min3&
31570 -ene*sss2mingrad3*diffnorm4(l)*sss2min1*sss2min2
31573 gradcatangx(l,i1)=gradcatangx(l,i1)+(det1ij/(dista2*dista1)*&
31574 (acatshiftdsc(ityptrani1,ityptranj1)*diff2(l)+&
31575 facd1*(diff2(l)-scal1b*dc_norm(l,i1+nres)*dista2)-&
31576 cosom1*dista2/dista1*&
31577 (acatshiftdsc(ityptrani1,ityptranj1)*diff1(l)+&
31578 facd1*(diff1(l)-scal1a*dc_norm(l,i1+nres)*dista1)))&
31579 +dephiij/(dista3*dista1)*&
31580 (acatshiftdsc(ityptrani1,ityptranj1)*diff3(l)+&
31581 facd1*(diff3(l)-scal1c*dc_norm(l,i1+nres)*dista3)-&
31582 cosom12*dista3/dista1*&
31583 (acatshiftdsc(ityptrani1,ityptranj1)*diff1(l)+&
31584 facd1*(diff1(l)-scal1a*dc_norm(l,i1+nres)*dista1))))*sssmintot&
31585 +ene*sss2mingrad1*sss2min2*sss2min3*(pom1+&
31586 diffnorm1(l)*(acatshiftdsc(ityptrani1,ityptranj1)-1.0d0))
31589 gradcatangx(l,i3)=gradcatangx(l,i3)+(&
31590 det2ij/(dista3*dista2)*&
31591 (acatshiftdsc(ityptrani3,ityptranj3)*(-diff2(l))+&
31592 facd3*(-diff2(l)-scal3b*dc_norm(l,i3+nres)*dista2)-&
31593 cosom2*dista2/dista3*&
31594 (acatshiftdsc(ityptrani3,ityptranj3)*diff3(l)+&
31595 facd3*(diff3(l)-scal3c*dc_norm(l,i3+nres)*dista3)))&
31596 +dephiij/(dista3*dista1)*&
31597 (acatshiftdsc(ityptrani3,ityptranj3)*diff1(l)+&
31598 facd3*(diff1(l)-scal3a*dc_norm(l,i3+nres)*dista1)-&
31599 cosom12*dista1/dista3*&
31600 (acatshiftdsc(ityptrani3,ityptranj3)*diff3(l)+&
31601 facd3*(diff3(l)-scal3c*dc_norm(l,i3+nres)*dista3))))*sssmintot&
31602 +ene*sss2mingrad3*sss2min2*sss2min1*(pom3+&
31603 diffnorm4(l)*(acatshiftdsc(ityptrani3,ityptranj3)-1.0d0))
31606 gradcatangx(l,i2)=gradcatangx(l,i2)+(&!
31607 det1ij/(dista2*dista1)*&!
31608 (acatshiftdsc(ityptrani2,ityptranj2)*diff1(l)&!
31609 +facd2*(diff1(l)-scal2a*dc_norm(l,i2+nres)*dista1)&
31610 -cosom1*dista1/dista2*&!
31611 (acatshiftdsc(ityptrani2,ityptranj2)*diff2(l)+&!
31612 facd2*(diff2(l)-scal2b*dc_norm(l,i2+nres)*dista2)))+&
31613 det2ij/(dista3*dista2)*&!
31614 (acatshiftdsc(ityptrani2,ityptranj2)*diff2(l)+&!
31615 facd2*(diff2(l)-scal2b*dc_norm(l,i2+nres)*dista2)&
31616 -(acatshiftdsc(ityptrani2,ityptranj2)*diff3(l)+&!
31617 facd2*(diff3(l)-scal2c*dc_norm(l,i2+nres)*dista3))&
31618 -cosom2*dista3/dista2*&!
31619 (acatshiftdsc(ityptrani2,ityptranj2)*diff2(l)+&!
31620 facd2*(diff2(l)-scal2b*dc_norm(l,i2+nres)*dista2))&
31621 +cosom2*dista2/dista3*&!
31622 (acatshiftdsc(ityptrani2,ityptranj2)*diff3(l)+&!
31623 facd2*(diff3(l)-scal2c*dc_norm(l,i2+nres)*dista3)))&
31624 +dephiij/(dista3*dista1)*&!
31625 (-(acatshiftdsc(ityptrani2,ityptranj2)*diff1(l)+&!
31626 facd2*(diff1(l)-scal2a*dc_norm(l,i2+nres)*dista1))+&
31627 cosom12*dista1/dista3*&!
31628 (acatshiftdsc(ityptrani2,ityptranj2)*diff3(l)+&!
31629 facd2*(diff3(l)-scal2c*dc_norm(l,i2+nres)*dista3))))*sssmintot&
31630 +ene*sss2mingrad2*sss2min3*sss2min1*(pom2+&
31631 diffnorm2(l)*(acatshiftdsc(ityptrani2,ityptranj2)-1.0d0))
31635 ! print *,i1,i2,i3,j1,j2,j3,"tors",ene,sinaux,cosphi
31636 ! print *,"param",agamacattran(1,ityptrani2,ityptranj2),ityptranj2,ityptrani2
31637 ecation_protang=ecation_protang+ene*sssmintot
31644 !--------------------------------------------------------------------------
31645 !c------------------------------------------------------------------------------
31646 double precision function mytschebyshev(m,n,x,y,yt)
31649 double precision x(n),y,yt,yy(0:100),aux
31650 !c Tschebyshev polynomial in y multiplied by sin(t1)sin(t2) (yt).
31651 !c Note that the first term is omitted
31652 !c m=0: the constant term is included
31653 !c m=1: the constant term is not included
31657 yy(i)=2*yy(1)*yy(i-1)-yy(i-2)*yt*yt
31663 !c print *,(yy(i),i=1,n)
31667 !C--------------------------------------------------------------------------
31668 !C--------------------------------------------------------------------------
31669 subroutine mygradtschebyshev(m,n,x,y,yt,fy,fyt)
31672 double precision x(n+1),y,yt,fy,fyt,yy(0:100),yb(0:100), &
31674 !c Derivative of Tschebyshev polynomial in y multiplied by sin(t1)sin(t2) (yt).
31675 !c Note that the first term is omitted
31676 !c m=0: the constant term is included
31677 !c m=1: the constant term is not included
31685 yy(i)=2*yy(1)*yy(i-1)-yy(i-2)*yt*yt
31686 yb(i)=2*yy(i-1)+2*yy(1)*yb(i-1)-yb(i-2)*yt*yt
31687 ybt(i)=2*yy(1)*ybt(i-1)-ybt(i-2)*yt*yt-2*yy(i-2)*yt
31693 fyt=fyt+x(i)*ybt(i)
31697 subroutine fodstep(nsteps)
31698 use geometry_data, only: c, nres, theta, alph
31699 use geometry, only:alpha,beta,dist
31700 integer, intent(in) :: nsteps
31701 integer idxtomod, j, i
31702 double precision RD0, RD1, fi
31703 ! double precision alpha
31704 ! double precision beta
31705 ! double precision dist
31706 ! double precision compute_RD
31707 double precision TT
31709 !c ! Założenia: dla łańcucha zapisanego w tablicy c zawierającego
31710 !c ! nres elementów CA i CB da się wyznaczyć kąty płaskie
31711 !c ! theta (procedura Alpha) i kąty torsyjne (procedura beta),
31712 !c ! zapisywane w tablicach theta i alph.
31713 !c ! Na podstawie danych z tych tablic da się odtworzyć
31714 !c ! strukturę 3D łańcucha procedurą chainbuild.
31716 ! print *,"fodstep: nres=",nres
31718 ! print *, "RD0before step: ",RD0
31720 !c ! Wyznaczenie kątów theta na podstawie struktury
31721 !c ! zapisanej w tablicy c
31723 TT=alpha(i-2,i-1,i)
31725 !c print *,"TT=",TT
31727 !c ! Wyznaczenie kątów phi na podstawie struktury
31728 !c ! zapisanej w tablicy c
31730 phi(i)=beta(i-3,i-2,i-1,i)
31732 !c ! Wyznaczenie odległości między atomami
31733 !c ! vbld(i)=dist(i-1,i)
31735 vbld(i)=dist(i-1,i)
31737 !c ! losujemy kilka liczb
31738 call random_number(r21)
31739 !c ! r21(1): indeks pozycji do zmiany
31740 !c ! r21(2): kąt (r21(2)/20.0-1/40.0)
31741 !c ! r21(3): wybór tablicy
31743 !c print *, "RD before step: ",RD0
31744 fi = (r21(2)/20.0-1.0/40.0) ! o tyle radianów zmienimy losowy kąt
31745 if (r21(3) .le. 0.5) then
31746 idxtomod = 3+r21(1)*(nres - 2)
31747 theta(idxtomod) = theta(idxtomod)+fi
31748 ! print *,"Zmiana kąta theta(",&
31749 ! idxtomod,") o fi = ",fi
31751 idxtomod = 4+r21(1)*(nres - 3)
31752 phi(idxtomod) = phi(idxtomod)+fi
31753 ! print *,"Zmiana kąta phi(",&
31754 ! idxtomod,") o fi = ",fi
31756 !c ! odtwarzamy łańcuch
31758 !c ! czy coś się polepszyło?
31760 if (RD1 .gt. RD0) then ! nie, wycofujemy zmianę
31761 ! print *, "RD after step: ",RD1," rejected"
31762 if (r21(3) .le. 0.5) then
31763 theta(idxtomod) = theta(idxtomod)-fi
31765 phi(idxtomod) = phi(idxtomod)-fi
31767 call chainbuild ! odtworzenie pierwotnej wersji (bez zmienionego kąta)
31769 ! print *, "RD after step: ",RD1," accepted"
31774 !c-----------------------------------------------------------------------------------------
31775 subroutine orientation_matrix(res) ! obliczenie macierzy oraz przygotowanie ea z tymi przeksztalceniami
31776 use geometry_data, only: c, nres
31777 use energy_data, only: itype
31778 double precision, intent(out) :: res(4,4)
31779 double precision resM(4,4)
31780 double precision M(4,4)
31781 double precision M2(4,4)
31782 integer i, j, maxi, maxj
31783 ! double precision sq
31784 double precision maxd, dd
31785 double precision v1(3)
31786 double precision v2(3)
31787 double precision vecnea(3)
31788 double precision mean_ea(3)
31789 double precision fi
31790 !c ! liczymy atomy efektywne i zapisujemy w tablicy ea
31792 !c if (itype(i,1) .ne. 10) then
31793 if (itype(i,1) .ne. 10) then
31794 ea(1,i) = c(1,i+nres)
31795 ea(2,i) = c(2,i+nres)
31796 ea(3,i) = c(3,i+nres)
31803 call IdentityM(resM)
31804 if (nres .le. 2) then
31805 print *, "nres too small (should be at least 2), stopping"
31812 !c ! szukamy najwiekszej odleglosci miedzy atomami efektywnymi ea
31813 call Dist3d(maxd,v1,v2)
31814 !c ! odleglosc miedzy pierwsza para atomow efektywnych
31825 call Dist3d(dd,v1,v2)
31826 if (dd .gt. maxd) then
31833 vecnea(1)=ea(1,maxi)-ea(1,maxj)
31834 vecnea(2)=ea(2,maxi)-ea(2,maxj)
31835 vecnea(3)=ea(3,maxi)-ea(3,maxj)
31836 if (vecnea(1) .lt. 0) then
31837 vecnea(1) = -vecnea(1)
31838 vecnea(2) = -vecnea(2)
31839 vecnea(3) = -vecnea(3)
31841 !c ! obliczenie kata obrotu wokol osi Z
31842 fi = -atan2(vecnea(2),vecnea(1))
31844 !c ! obliczenie kata obrotu wokol osi Y
31845 fi = atan2(vecnea(3), sqrt(sq(vecnea(1))+sq(vecnea(2))))
31846 call RotateY(M2,fi)
31848 !c ! Przeksztalcamy wszystkie atomy efektywne
31849 !c ! uzyskujac najwieksza odleglosc ulożona wzdluz OX
31850 !c ! ea = transform_eatoms(ea,M)
31855 call tranform_point(v2,v1,M)
31861 !c ! Teraz szukamy najdluzszego rzutu na plaszczyzne YZ
31862 !c ! (czyli w liczeniu odleglosci bierzemy pod uwage tylko wsp. y, z)
31863 maxd = sqrt( sq(ea(2,1)-ea(2,2)) + sq(ea(3,1)-ea(3,2))) ! aktualnie max odl
31864 maxi = 1 ! indeksy atomow
31865 maxj = 2 ! miedzy ktorymi jest max odl (chwilowe)
31868 dd = sqrt( (ea(2,i)-ea(2,j))**2 + (ea(3,i)-ea(3,j))**2)
31869 if (dd .gt. maxd) then
31876 !c ! Teraz obrocimy wszystko wokol OX tak, zeby znaleziony rzut
31877 !c ! byl rownolegly do OY
31878 vecnea(1) = ea(1,maxi)-ea(1,maxj)
31879 vecnea(2) = ea(2,maxi)-ea(2,maxj)
31880 vecnea(3) = ea(3,maxi)-ea(3,maxj)
31881 !c ! jeśli współrzędna vecnea.y < 0, to robimy odwrotnie
31882 if (vecnea(2) .lt. 0) then
31883 vecnea(1) = -vecnea(1)
31884 vecnea(2) = -vecnea(2)
31885 vecnea(3) = -vecnea(3)
31887 !c ! obliczenie kąta obrotu wokół osi X
31888 fi = -atan2(vecnea(3),vecnea(2))
31890 !c ! Przeksztalcamy wszystkie atomy efektywne
31895 call tranform_point(v2,v1,M)
31900 resM = matmul(M,resM) ! zbieramy wynik (sprawdzic kolejnosc M,resM)
31906 mean_ea(1) = mean_ea(1) + ea(1,i)
31907 mean_ea(2) = mean_ea(2) + ea(2,i)
31908 mean_ea(3) = mean_ea(3) + ea(3,i)
31910 v1(1) = -mean_ea(1)/nres
31911 v1(2) = -mean_ea(2)/nres
31912 v1(3) = -mean_ea(3)/nres
31913 call TranslateV(M,v1)
31914 resM = matmul(M,resM)
31917 ea(1,i) = ea(1,i) + v1(1)
31918 ea(2,i) = ea(2,i) + v1(2)
31919 ea(3,i) = ea(3,i) + v1(3)
31922 !c ! wynikowa macierz przeksztalcenia lancucha
31923 !c ! (ale lancuch w ea juz mamy przeksztalcony)
31926 double precision function compute_rd
31927 use geometry_data, only: nres
31928 use energy_data, only: itype
31930 double precision or_mat(4,4)
31931 ! double precision hydrophobicity
31933 double precision cutoff
31934 double precision ho(70000)
31935 double precision ht(70000)
31936 double precision hosum, htsum
31937 double precision marg, sigmax, sigmay, sigmaz
31939 double precision v1(3)
31940 double precision v2(3)
31941 double precision rijdivc, coll, tmpkwadrat, tmppotega, dist
31942 double precision OdivT, OdivR, ot_one, or_one, RD_classic
31943 call orientation_matrix(or_mat)
31944 !c ! tam juz liczy sie tablica ea
31947 !c ! granica oddzialywania w A (powyzej ignorujemy oddzialywanie)
31948 !c ! Najpierw liczymy "obserwowana hydrofobowosc"
31949 hosum = 0.0d0 ! na sume pol ho, do celow pozniejszej normalizacji
31953 if (j .eq. i) then ! nie uwzgledniamy oddzialywania atomu z samym soba
31962 call Dist3d(dist,v1,v2) ! odleglosc miedzy atomami
31963 if (dist .gt. cutoff) then ! za daleko, nie uwzgledniamy
31966 rijdivc = dist / cutoff
31968 tmppotega = rijdivc*rijdivc
31969 tmpkwadrat = tmppotega
31970 coll = coll + 7*tmpkwadrat
31971 tmppotega = tmppotega * tmpkwadrat ! do potęgi 4
31972 coll = coll - 9*tmppotega
31973 tmppotega = tmppotega * tmpkwadrat ! do potęgi 6
31974 coll = coll + 5*tmppotega
31975 tmppotega = tmppotega * tmpkwadrat ! do potęgi 8
31976 coll = coll - tmppotega
31977 !c ! Wersja: Bryliński 2007
31978 !c ! EAtoms[j].collectedhp += EAtoms[i].hyphob*(1 - 0.5 * coll);
31979 !c ! ea$ho[j] = ea$ho[j] + hydrophobicity(ea$resid[i])*(1-0.5*coll)
31980 !c ! Wersja: Banach Konieczny Roterman 2014
31981 !c ! EAtoms[j].collectedhp += (EAtoms[i].hyphob+EAtoms[j].hyphob)*(1 - 0.5 * coll);
31982 !c ponizej bylo itype(i,1) w miejscu itype(i) oraz itype(j,1) w miejscu itype(j)
31983 ho(j) = ho(j) + (hydrophobicity(itype(i,1))+&
31984 hydrophobicity(itype(j,1)))*(1.0d0-0.5_8*coll)
31986 hosum = hosum + ho(j)
31990 ho(i) = ho(i) / hosum
31992 !c ! Koniec liczenia hydrofobowosci obserwowanej (profil ho)
31993 !c ! Teraz liczymy "teoretyczna hydrofobowosc", wedlug kropli i rozkladu Gaussa
31995 !c ! tu zbieramy sume ht, uzyjemy potem do normalizacji
31996 !c ! Ustalimy teraz parametry rozkladu Gaussa, czyli sigmy (srodek jest w (0,0,0)).
31997 !c ! To bedzie (max odl od srodka + margines) / 3, oddzielnie dla kazdej wspolrzednej.
32000 !c ! jeszcze raz zerujemy
32001 !c ! szukamy ekstremalnej wartosci wspolrzednej x (max wart bezwzgl)
32004 if (abs(ea(1,i))>sigmax) then
32005 sigmax = abs(ea(1,i))
32008 sigmax = (marg + sigmax) / 3.0d0
32009 !c ! szukamy ekstremalnej wartosci wspolrzednej y (max wart bezwzgl)
32012 if (abs(ea(2,i))>sigmay) then
32013 sigmay = abs(ea(2,i))
32016 sigmay = (marg + sigmay) / 3.0d0
32017 !c ! szukamy ekstremalnej wartosci wspolrzednej z (max wart bezwzgl)
32020 if (abs(ea(3,i))>sigmaz) then
32021 sigmaz = abs(ea(3,i))
32024 sigmaz = (marg + sigmaz) / 3.0d0
32025 !c !sigmax = (marg + max(abs(max(ea$acoor[,1])), abs(min(ea$acoor[,1]))))/3.0
32026 !c !sigmay = (marg + max(abs(max(ea$acoor[,2])), abs(min(ea$acoor[,2]))))/3.0
32027 !c !sigmaz = (marg + max(abs(max(ea$acoor[,3])), abs(min(ea$acoor[,3]))))/3.0
32028 !c ! print *,"sigmax =",sigmax," sigmay =",sigmay," sigmaz = ",sigmaz
32030 ht(j)= exp(-(ea(1,j))**2/(2*sigmax**2))&
32031 * exp(-(ea(2,j))**2/(2*sigmay**2)) &
32032 * exp(-(ea(3,j))**2/(2*sigmaz**2))
32033 htsum = htsum + ht(j)
32037 ht(i) = ht(i) / htsum
32039 !c ! Teraz liczymy RD
32043 if (ho(j) .ne. 0) then
32044 ot_one = ho(j) * log(ho(j)/ht(j)) / log(2.0d0)
32045 OdivT = OdivT + ot_one
32046 or_one = ho(j) * log(ho(j)/ (1.0d0/neatoms)) / log(2.0_8)
32047 OdivR = OdivR + or_one
32050 RD_classic = OdivT / (OdivT+OdivR)
32051 compute_rd = RD_classic
32054 function hydrophobicity(id) ! do przepisania (bylo: identyfikowanie aa po nazwach)
32056 double precision hydrophobicity
32057 hydrophobicity = 0.0d0
32058 if (id .eq. 1) then
32059 hydrophobicity = 1.000d0 ! CYS
32062 if (id .eq. 2) then
32063 hydrophobicity = 0.828d0 ! MET
32066 if (id .eq. 3) then
32067 hydrophobicity = 0.906d0 ! PHE
32070 if (id .eq. 4) then
32071 hydrophobicity = 0.883d0 ! ILE
32074 if (id .eq. 5) then
32075 hydrophobicity = 0.783d0 ! LEU
32078 if (id .eq. 6) then
32079 hydrophobicity = 0.811d0 ! VAL
32082 if (id .eq. 7) then
32083 hydrophobicity = 0.856d0 ! TRP
32086 if (id .eq. 8) then
32087 hydrophobicity = 0.700d0 ! TYR
32090 if (id .eq. 9) then
32091 hydrophobicity = 0.572d0 ! ALA
32094 if (id .eq. 10) then
32095 hydrophobicity = 0.550d0 ! GLY
32098 if (id .eq. 11) then
32099 hydrophobicity = 0.478d0 ! THR
32102 if (id .eq. 12) then
32103 hydrophobicity = 0.422d0 ! SER
32106 if (id .eq. 13) then
32107 hydrophobicity = 0.250d0 ! GLN
32110 if (id .eq. 14) then
32111 hydrophobicity = 0.278d0 ! ASN
32114 if (id .eq. 15) then
32115 hydrophobicity = 0.083d0 ! GLU
32118 if (id .eq. 16) then
32119 hydrophobicity = 0.167d0 ! ASP
32122 if (id .eq. 17) then
32123 hydrophobicity = 0.628d0 ! HIS
32126 if (id .eq. 18) then
32127 hydrophobicity = 0.272d0 ! ARG
32130 if (id .eq. 19) then
32131 hydrophobicity = 0.000d0 ! LYS
32134 if (id .eq. 20) then
32135 hydrophobicity = 0.300d0 ! PRO
32139 end function hydrophobicity
32140 subroutine mycrossprod(res,b,c)
32142 double precision, intent(out) :: res(3)
32143 double precision, intent(in) :: b(3)
32144 double precision, intent(in) :: c(3)
32145 !c ! Tylko dla wektorów trójwymiarowych, ale nie sprawdzamy tego tutaj
32146 res(1) = b(2)*c(3)-b(3)*c(2)
32147 res(2) = b(3)*c(1)-b(1)*c(3)
32148 res(3) = b(1)*c(2)-b(2)*c(1)
32151 subroutine mydotprod(res,b,c)
32153 double precision, intent(out) :: res
32154 double precision, intent(in) :: b(3)
32155 double precision, intent(in) :: c(3)
32156 !c ! Tylko dla wektorów trójwymiarowych, ale nie sprawdzamy tego tutaj
32157 res = b(1)*c(1)+b(2)*c(2)+b(3)*c(3)
32160 !c ! cosinus k¹ta miêdzy wektorami trójwymiarowymi
32161 subroutine cosfi(res, x, y)
32163 double precision, intent(out) :: res
32164 double precision, intent(in) :: x(3)
32165 double precision, intent(in) :: y(3)
32166 double precision LxLy
32167 LxLy=sqrt(x(1)*x(1)+x(2)*x(2)+x(3)*x(3)) *&
32168 sqrt(y(1)*y(1)+y(2)*y(2)+y(3)*y(3))
32169 if (LxLy==0.0) then
32172 call mydotprod(res,x,y)
32179 subroutine Dist3d(res,v1,v2)
32181 double precision, intent(out) :: res
32182 double precision, intent(in) :: v1(3)
32183 double precision, intent(in) :: v2(3)
32184 ! double precision sq
32185 res = sqrt( sq(v1(1)-v2(1)) + sq(v1(2)-v2(2)) + sq(v1(3)-v2(3)))
32188 !c ! Przeksztalca wsp. 3d uzywajac macierzy przeksztalcenia M (4x4)
32189 subroutine tranform_point(res,v3d,M)
32191 double precision, intent(out) :: res(3)
32192 double precision, intent(in) :: v3d(3)
32193 double precision, intent(in) :: M(4,4)
32195 res(1) = M(1,1)*v3d(1) + M(1,2)*v3d(2) + M(1,3)*v3d(3) + M(1,4)
32196 res(2) = M(2,1)*v3d(1) + M(2,2)*v3d(2) + M(2,3)*v3d(3) + M(2,4)
32197 res(3) = M(3,1)*v3d(1) + M(3,2)*v3d(2) + M(3,3)*v3d(3) + M(3,4)
32200 !c ! TranslateV: macierz translacji o wektor V
32201 subroutine TranslateV(res,V)
32203 double precision, intent(out) :: res(4,4)
32204 double precision, intent(in) :: v(3)
32223 !c ! RotateX: macierz obrotu wokol osi OX o kat fi
32224 subroutine RotateX(res,fi)
32226 double precision, intent(out) :: res(4,4)
32227 double precision, intent(in) :: fi
32234 res(2,3) = -sin(fi)
32246 !c ! RotateY: macierz obrotu wokol osi OY o kat fi
32247 subroutine RotateY(res,fi)
32249 double precision, intent(out) :: res(4,4)
32250 double precision, intent(in) :: fi
32259 res(3,1) = -sin(fi)
32269 !c ! RotateZ: macierz obrotu wokol osi OZ o kat fi
32270 subroutine RotateZ(res,fi)
32272 double precision, intent(out) :: res(4,4)
32273 double precision, intent(in) :: fi
32275 res(1,2) = -sin(fi)
32293 subroutine IdentityM(res)
32295 double precision, intent(out) :: res(4,4)
32314 double precision function sq(x)
32321 double precision function funcgrad(x,g)
32322 use MD_data, only: totT,usampl
32324 double precision energia(0:n_ene)
32325 double precision x(nvar),g(nvar)
32327 call var_to_geom(nvar,x)
32330 call etotal(energia(0))
32332 funcgrad=energia(0)
32333 call cart2intgrad(nvar,g)
32336 gloc(i,icg)=gloc(i,icg)+dugamma(i)
32339 gloc(nphi+i,icg)=gloc(nphi+i,icg)+dutheta(i)
32343 g(i)=g(i)+gloc(i,icg)
32346 end function funcgrad
32347 subroutine cart2intgrad(n,g)
32349 double precision g(n)
32350 double precision drt(3,3,nres),rdt(3,3,nres),dp(3,3),&
32351 temp(3,3),prordt(3,3,nres),prodrt(3,3,nres)
32352 double precision xx(3),xx1(3),alphi,omegi,xj,dpjk,yp,xp,xxp,yyp
32353 double precision cosalphi,sinalphi,cosomegi,sinomegi,theta2,&
32354 cost2,sint2,rj,dxoiij,tempkl,dxoijk,dsci,zzp,dj,dpkl
32355 double precision fromto(3,3),aux(6)
32356 integer i,ii,j,jjj,k,l,m,indi,ind,ind1
32360 if (sideonly) goto 10
32362 rdt(1,1,i)=-rt(1,2,i)
32363 rdt(1,2,i)= rt(1,1,i)
32365 rdt(2,1,i)=-rt(2,2,i)
32366 rdt(2,2,i)= rt(2,1,i)
32368 rdt(3,1,i)=-rt(3,2,i)
32369 rdt(3,2,i)= rt(3,1,i)
32376 drt(2,1,i)= rt(3,1,i)
32377 drt(2,2,i)= rt(3,2,i)
32378 drt(2,3,i)= rt(3,3,i)
32379 drt(3,1,i)=-rt(2,1,i)
32380 drt(3,2,i)=-rt(2,2,i)
32381 drt(3,3,i)=-rt(2,3,i)
32386 if (n.gt.nphi) then
32392 dpjk=dpjk+prod(j,l,i)*rdt(l,k,i)
32395 prordt(j,k,i)=dp(j,k)
32398 g(nphi+i)=g(nphi+i)+vbld(i+2)*dp(j,1)*gradc(j,i+1,icg)
32400 xx1(1)=-0.5D0*xloc(2,i+1)
32401 xx1(2)= 0.5D0*xloc(1,i+1)
32405 xj=xj+r(j,k,i)*xx1(k)
32412 rj=rj+prod(j,k,i)*xx(k)
32414 g(nphi+i)=g(nphi+i)+rj*gradx(j,i+1,icg)
32416 if (i.lt.nres-2) then
32420 dxoiij=dxoiij+dp(j,k)*xrot(k,i+2)
32422 g(nphi+i)=g(nphi+i)+dxoiij*gradx(j,i+2,icg)
32434 dpjk=dpjk+prod(j,l,i)*drt(l,k,i)
32437 prodrt(j,k,i)=dp(j,k)
32439 g(i-1)=g(i-1)+vbld(i+2)*dp(j,1)*gradc(j,i+1,icg)
32443 xx(3)= xloc(2,i+1)*r(2,2,i)+xloc(3,i+1)*r(2,3,i)
32444 xx(2)=-xloc(2,i+1)*r(3,2,i)-xloc(3,i+1)*r(3,3,i)
32449 rj=rj+prod(j,k,i)*xx(k)
32451 g(i-1)=g(i-1)-rj*gradx(j,i+1,icg)
32458 dxoiij=dxoiij+dp(j,k)*xrot(k,i+2)
32460 g(i-1)=g(i-1)+dxoiij*gradx(j,i+2,icg)
32465 call build_fromto(i+1,j+1,fromto)
32470 tempkl=tempkl+prordt(k,m,i)*fromto(m,l)
32475 if (n.gt.nphi) then
32477 g(nphi+i)=g(nphi+i)+vbld(j+2)*temp(k,1)*gradc(k,j+1,icg)
32482 dxoijk=dxoijk+temp(k,l)*xrot(l,j+2)
32484 g(nphi+i)=g(nphi+i)+dxoijk*gradx(k,j+2,icg)
32491 tempkl=tempkl+prodrt(k,m,i)*fromto(m,l)
32498 g(i-1)=g(i-1)+vbld(j+2)*temp(k,1)*gradc(k,j+1,icg)
32503 dxoijk=dxoijk+temp(k,l)*xrot(l,j+2)
32505 g(i-1)=g(i-1)+dxoijk*gradx(k,j+2,icg)
32511 if (nvar.le.nphi+ntheta) return
32515 if (iabs(itype(i,1)).eq.10 .or. itype(i,1).eq.ntyp1& !) cycle
32516 .or. mask_side(i).eq.0 ) cycle
32522 if(alphi.ne.alphi) alphi=100.0
32523 if(omegi.ne.omegi) omegi=-100.0
32528 cosalphi=dcos(alphi)
32529 sinalphi=dsin(alphi)
32530 cosomegi=dcos(omegi)
32531 sinomegi=dsin(omegi)
32532 temp(1,1)=-dsci*sinalphi
32533 temp(2,1)= dsci*cosalphi*cosomegi
32534 temp(3,1)=-dsci*cosalphi*sinomegi
32536 temp(2,2)=-dsci*sinalphi*sinomegi
32537 temp(3,2)=-dsci*sinalphi*cosomegi
32538 theta2=pi-0.5D0*theta(i+1)
32545 xxp= xp*cost2+yp*sint2
32546 yyp=-xp*sint2+yp*cost2
32549 xx(2)=yyp*r(2,2,i-1)+zzp*r(2,3,i-1)
32550 xx(3)=yyp*r(3,2,i-1)+zzp*r(3,3,i-1)
32554 dj=dj+prod(k,l,i-1)*xx(l)
32561 g(ii)=g(ii)+aux(k)*gradx(k,i,icg)
32562 g(ii+nside)=g(ii+nside)+aux(k+3)*gradx(k,i,icg)
32566 end subroutine cart2intgrad
32570 !--------------------------------------------------------------------------