1 double precision function qwolynes(seg1,seg2,flag,seg3,seg4)
2 implicit real*8 (a-h,o-z)
4 include 'COMMON.IOUNITS'
6 include 'COMMON.INTERACT'
9 integer i,j,jl,k,l,il,kl,nl,np,seg1,seg2,seg3,seg4,secseg
11 double precision dist,qm
12 double precision qq,qqij,qqijCM,dij,d0ij,dijCM,d0ijCM
13 logical lprn /.false./
24 write (iout,*) "seg1",seg1," seg2",seg2," seg3",seg3," seg4",seg4,
32 if (itype(il).ne.10) then
37 if (itype(jl).ne.10) then
42 qqijCM = qcontrib(il,jl,ilnres,jlnres)
45 write (iout,*) "qqijCM",qqijCM
51 write (iout,*) "nl",nl," qq",qq
56 if((seg3-il).lt.3) then
63 if (itype(il).ne.10) then
68 if (itype(jl).ne.10) then
73 qqijCM = qcontrib(il,jl,ilnres,jlnres)
76 write (iout,*) "qqijCM",qqijCM
86 dqwol(j,i)=dqwol(j,i)/nl
87 dxqwol(j,i)=dxqwol(j,i)/nl
92 c-------------------------------------------------------------------
93 subroutine qwol_num(seg1,seg2,flag,seg3,seg4)
94 implicit real*8 (a-h,o-z)
96 include 'COMMON.IOUNITS'
97 include 'COMMON.CHAIN'
98 include 'COMMON.INTERACT'
101 integer seg1,seg2,seg3,seg4
103 double precision qwolan(3,0:maxres),cdummy(3,0:maxres2),
104 & qwolxan(3,0:maxres),q1,q2
105 double precision delta /1.0d-7/
106 write (iout,*) "seg1",seg1," seg2",seg2," seg3",seg3," seg4",seg4
107 write(iout,*) "dQ/dc backbone "
109 write(iout,'(i5,3e15.5)') i, (dqwol(j,i),j=1,3)
111 write(iout,*) "dQ/dX side chain "
113 write(iout,'(i5,3e15.5)') i,(dxqwol(j,i),j=1,3)
119 q1=qwolynes(seg1,seg2,flag,seg3,seg4)
120 c(j,i)=cdummy(j,i)+delta
121 q2=qwolynes(seg1,seg2,flag,seg3,seg4)
122 qwolan(j,i)=0.5d0*(q2-q1)/delta
124 c write (iout,*) "i",i," j",j," q1",q1," a2",q2
129 cdummy(j,i+nres)=c(j,i+nres)
130 c(j,i+nres)=c(j,i+nres)-delta
131 q1=qwolynes(seg1,seg2,flag,seg3,seg4)
132 c(j,i+nres)=cdummy(j,i+nres)+delta
133 q2=qwolynes(seg1,seg2,flag,seg3,seg4)
134 qwolxan(j,i)=0.5d0*(q2-q1)/delta
135 c(j,i+nres)=cdummy(j,i+nres)
138 write(iout,*) "Numerical Q cartesian gradients backbone: "
140 write(iout,'(i5,3e15.5)') i, (qwolan(j,i),j=1,3)
142 write(iout,*) "Numerical Q cartesian gradients side-chain: "
144 write(iout,'(i5,3e15.5)') i, (qwolxan(j,i),j=1,3)
148 c------------------------------------------------------------------------
150 c MD with umbrella_sampling using Wolyne's distance measure as a constraint
151 implicit real*8 (a-h,o-z)
153 include 'COMMON.CONTROL'
157 include 'COMMON.LANGEVIN'
159 include 'COMMON.LANGEVIN.lang0'
161 include 'COMMON.CHAIN'
162 include 'COMMON.DERIV'
164 include 'COMMON.LOCAL'
165 include 'COMMON.INTERACT'
166 include 'COMMON.IOUNITS'
167 include 'COMMON.NAMES'
168 include 'COMMON.TIME1'
169 double precision uzap1,uzap2,hm1,hm2,hmnum
170 double precision ucdelan,dUcartan(3,0:MAXRES)
171 & ,dUxcartan(3,0:MAXRES),cdummy(3,0:MAXRES),
172 & duconst(3,0:MAXRES),duxconst(3,0:MAXRES)
173 integer kstart,kend,lstart,lend,idummy
174 double precision delta /1.0d-7/
185 qfrag(i)=qwolynes(ifrag(1,i,iset),ifrag(2,i,iset),.true.
187 Uconst=Uconst+wfrag(i,iset)*harmonic(qfrag(i),qinfrag(i,iset))
188 c Calculating the derivatives of Constraint energy with respect to Q
189 Ucdfrag=wfrag(i,iset)*harmonicprim(qfrag(i),qinfrag(i,iset))
190 c Calculating the derivatives of Q with respect to cartesian coordinates
193 duconst(j,ii)=dUconst(j,ii)+ucdfrag*dqwol(j,ii)
194 dUxconst(j,ii)=dUxconst(j,ii)+ucdfrag*dxqwol(j,ii)
197 c write (iout,*) "Calling qwol_num"
198 c call qwol_num(ifrag(1,i),ifrag(2,i),.true.,idummy,idummy)
201 kstart=ifrag(1,ipair(1,i,iset),iset)
202 kend=ifrag(2,ipair(1,i,iset),iset)
203 lstart=ifrag(1,ipair(2,i,iset),iset)
204 lend=ifrag(2,ipair(2,i,iset),iset)
205 qpair(i)=qwolynes(kstart,kend,.false.,lstart,lend)
206 Uconst=Uconst+wpair(i,iset)*harmonic(qpair(i),qinpair(i,iset))
208 Ucdpair=wpair(i,iset)*harmonicprim(qpair(i),qinpair(i,iset))
212 duconst(j,ii)=dUconst(j,ii)+ucdpair*dqwol(j,ii)
213 dUxconst(j,ii)=dUxconst(j,ii)+ucdpair*dxqwol(j,ii)
217 c write(iout,*) "Uconst inside subroutine ", Uconst
218 c Transforming the gradients from Cs to dCs for the backbone
222 dudconst(k,i)=dudconst(k,i)+duconst(k,j)+duxconst(k,j)
226 c Transforming the gradients from Cs to dCs for the side chains
229 dudxconst(j,i)=duxconst(j,i)
232 c write(iout,*) "dU/dc backbone "
234 c write(iout,'(i5,3e15.5)') ii, (duconst(j,ii),j=1,3)
236 c write(iout,*) "dU/dX side chain "
238 c write(iout,'(i5,3e15.5)') ii,(duxconst(j,ii),j=1,3)
240 c write(iout,*) "dU/ddc backbone "
242 c write(iout,'(i5,3e15.5)') ii, (dudconst(j,ii),j=1,3)
244 c write(iout,*) "dU/ddX side chain "
246 c write(iout,'(i5,3e15.5)') ii,(dudxconst(j,ii),j=1,3)
248 c Calculating numerical gradients of dUconst/ddc and dUconst/ddx
252 c-----------------------------------------------------------------------
253 subroutine dEconstrQ_num
254 c Calculating numerical dUconst/ddc and dUconst/ddx
255 implicit real*8 (a-h,o-z)
257 include 'COMMON.CONTROL'
261 include 'COMMON.LANGEVIN'
263 include 'COMMON.LANGEVIN.lang0'
265 include 'COMMON.CHAIN'
266 include 'COMMON.DERIV'
268 include 'COMMON.LOCAL'
269 include 'COMMON.INTERACT'
270 include 'COMMON.IOUNITS'
271 include 'COMMON.NAMES'
272 include 'COMMON.TIME1'
273 double precision uzap1,uzap2
274 double precision dUcartan(3,0:MAXRES)
275 & ,dUxcartan(3,0:MAXRES),cdummy(3,0:MAXRES)
276 integer kstart,kend,lstart,lend,idummy
277 double precision delta /1.0d-7/
283 dc(j,i)=dc(j,i)+delta
287 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),
288 & .true.,idummy,idummy)
289 uzap2=uzap2+wfrag(ii,iset)*harmonic(qfrag(ii),
293 kstart=ifrag(1,ipair(1,ii,iset),iset)
294 kend=ifrag(2,ipair(1,ii,iset),iset)
295 lstart=ifrag(1,ipair(2,ii,iset),iset)
296 lend=ifrag(2,ipair(2,ii,iset),iset)
297 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
298 uzap2=uzap2+wpair(ii,iset)*
299 & harmonic(qpair(ii),qinpair(ii,iset))
305 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),
306 & .true.,idummy,idummy)
307 uzap1=uzap1+wfrag(ii,iset)*
308 & harmonic(qfrag(ii),qinfrag(ii,iset))
311 kstart=ifrag(1,ipair(1,ii,iset),iset)
312 kend=ifrag(2,ipair(1,ii,iset),iset)
313 lstart=ifrag(1,ipair(2,ii,iset),iset)
314 lend=ifrag(2,ipair(2,ii,iset),iset)
315 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
316 uzap1=uzap1+wpair(ii,iset)*
317 & harmonic(qpair(ii),qinpair(ii,iset))
319 ducartan(j,i)=(uzap2-uzap1)/(delta)
322 c Calculating numerical gradients for dU/ddx
328 cdummy(j,i)=dc(j,i+nres)
329 dc(j,i+nres)=dc(j,i+nres)+delta
333 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),
334 & .true.,idummy,idummy)
335 uzap2=uzap2+wfrag(ii,iset)*
336 & harmonic(qfrag(ii),qinfrag(ii,iset))
339 kstart=ifrag(1,ipair(1,ii,iset),iset)
340 kend=ifrag(2,ipair(1,ii,iset),iset)
341 lstart=ifrag(1,ipair(2,ii,iset),iset)
342 lend=ifrag(2,ipair(2,ii,iset),iset)
343 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
344 uzap2=uzap2+wpair(ii,iset)*
345 & harmonic(qpair(ii),qinpair(ii,iset))
347 dc(j,i+nres)=cdummy(j,i)
351 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),
352 & .true.,idummy,idummy)
353 uzap1=uzap1+wfrag(ii,iset)*
354 & harmonic(qfrag(ii),qinfrag(ii,iset))
357 kstart=ifrag(1,ipair(1,ii,iset),iset)
358 kend=ifrag(2,ipair(1,ii,iset),iset)
359 lstart=ifrag(1,ipair(2,ii,iset),iset)
360 lend=ifrag(2,ipair(2,ii,iset),iset)
361 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
362 uzap1=uzap1+wpair(ii,iset)*
363 & harmonic(qpair(ii),qinpair(ii,iset))
365 duxcartan(j,i)=(uzap2-uzap1)/(delta)
368 write(iout,*) "Numerical dUconst/ddc backbone "
370 write(iout,'(i5,3e15.5)') ii,(dUcartan(j,ii),j=1,3)
372 write(iout,*) "Numerical dUconst/ddx side-chain "
374 write(iout,'(i5,3e15.5)') ii,(dUxcartan(j,ii),j=1,3)
378 c---------------------------------------------------------------------------
379 double precision function qcontrib(il,jl,il1,jl1)
382 include 'COMMON.IOUNITS'
383 include 'COMMON.CHAIN'
384 include 'COMMON.INTERACT'
386 integer i,j,k,il,jl,il1,jl1,nd
387 double precision dist
389 double precision dij1,dij2,dij3,dij4,d0ij1,d0ij2,d0ij3,d0ij4,fac,
390 & fac1,ddave,ssij,ddqij
391 logical lprn /.false./
392 d0ij1=dsqrt((cref(1,jl)-cref(1,il))**2+
393 & (cref(2,jl)-cref(2,il))**2+
394 & (cref(3,jl)-cref(3,il))**2)
396 ddave=(dij1-d0ij1)**2
399 d0ij2=dsqrt((cref(1,jl1)-cref(1,il))**2+
400 & (cref(2,jl1)-cref(2,il))**2+
401 & (cref(3,jl1)-cref(3,il))**2)
403 ddave=ddave+(dij2-d0ij2)**2
407 d0ij3=dsqrt((cref(1,jl)-cref(1,il1))**2+
408 & (cref(2,jl)-cref(2,il1))**2+
409 & (cref(3,jl)-cref(3,il1))**2)
411 ddave=ddave+(dij3-d0ij3)**2
414 if (il1.ne.il .and. jl1.ne.jl) then
415 d0ij4=dsqrt((cref(1,jl1)-cref(1,il1))**2+
416 & (cref(2,jl1)-cref(2,il1))**2+
417 & (cref(3,jl1)-cref(3,il1))**2)
419 ddave=ddave+(dij4-d0ij4)**2
424 write (iout,*) "il",il," jl",jl,
425 & " itype",itype(il),itype(jl)," nd",nd
426 write (iout,*)"d0ij",d0ij1,d0ij2,d0ij3,d0ij4,
427 & " dij",dij1,dij2,dij3,dij4," ddave",ddave
430 c ssij = (0.25d0*d0ij1)**2
431 if (il.ne.il1 .and. jl.ne.jl1) then
432 ssij = 16.0d0/(d0ij1*d0ij4)
434 ssij = 16.0d0/(d0ij1*d0ij1)
436 qcontrib = dexp(-0.5d0*ddave*ssij)
438 fac1 = qcontrib*ssij/nd
439 fac = fac1*(dij1-d0ij1)/dij1
441 ddqij = (c(k,il)-c(k,jl))*fac
442 dqwol(k,il)=dqwol(k,il)+ddqij
443 dqwol(k,jl)=dqwol(k,jl)-ddqij
446 fac = fac1*(dij2-d0ij2)/dij2
448 ddqij = (c(k,il)-c(k,jl1))*fac
449 dqwol(k,il)=dqwol(k,il)+ddqij
450 dxqwol(k,jl)=dxqwol(k,jl)-ddqij
454 fac = fac1*(dij3-d0ij3)/dij3
456 ddqij = (c(k,il1)-c(k,jl))*fac
457 dxqwol(k,il)=dxqwol(k,il)+ddqij
458 dqwol(k,jl)=dqwol(k,jl)-ddqij
461 if (il1.ne.il .and. jl1.ne.jl) then
462 fac = fac1*(dij4-d0ij4)/dij4
464 ddqij = (c(k,il1)-c(k,jl1))*fac
465 dxqwol(k,il)=dxqwol(k,il)+ddqij
466 dxqwol(k,jl)=dxqwol(k,jl)-ddqij