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'
8 integer i,j,jl,k,l,il,kl,nl,np,ip,kp,seg1,seg2,seg3,seg4,
11 double precision dist,qm
12 double precision qq,qqij,qqijCM,dij,d0ij,dijCM,d0ijCM
13 logical lprn /.false./
15 double precision sigm,x
23 d0ij=dsqrt((cref(1,jl)-cref(1,il))**2+
24 & (cref(2,jl)-cref(2,il))**2+
25 & (cref(3,jl)-cref(3,il))**2)
27 qqij = dexp(-0.5d0*((dij-d0ij)/(sigm(d0ij)))**2)
28 if (itype(il).ne.10 .or. itype(jl).ne.10) then
31 & (cref(1,jl+nres)-cref(1,il+nres))**2+
32 & (cref(2,jl+nres)-cref(2,il+nres))**2+
33 & (cref(3,jl+nres)-cref(3,il+nres))**2)
34 dijCM=dist(il+nres,jl+nres)
35 qqijCM = dexp(-0.5d0*((dijCM-d0ijCM)/(sigm(d0ijCM)))**2)
43 if((seg3-il).lt.3) then
50 d0ij=dsqrt((cref(1,jl)-cref(1,il))**2+
51 & (cref(2,jl)-cref(2,il))**2+
52 & (cref(3,jl)-cref(3,il))**2)
54 qqij = dexp(-0.5d0*((dij-d0ij)/(sigm(d0ij)))**2)
55 if (itype(il).ne.10 .or. itype(jl).ne.10) then
58 & (cref(1,jl+nres)-cref(1,il+nres))**2+
59 & (cref(2,jl+nres)-cref(2,il+nres))**2+
60 & (cref(3,jl+nres)-cref(3,il+nres))**2)
61 dijCM=dist(il+nres,jl+nres)
62 qqijCM = dexp(-0.5d0*((dijCM-d0ijCM)/(sigm(d0ijCM)))**2)
72 c-------------------------------------------------------------------
73 subroutine qwolynes_prim(seg1,seg2,flag,seg3,seg4)
74 implicit real*8 (a-h,o-z)
76 include 'COMMON.IOUNITS'
77 include 'COMMON.CHAIN'
78 include 'COMMON.INTERACT'
81 integer i,j,jl,k,l,il,nl,seg1,seg2,seg3,seg4,
85 double precision dij,d0ij,dijCM,d0ijCM
86 logical lprn /.false./
88 double precision sigm,x,sim,dd0,fac,ddqij
102 d0ij=dsqrt((cref(1,jl)-cref(1,il))**2+
103 & (cref(2,jl)-cref(2,il))**2+
104 & (cref(3,jl)-cref(3,il))**2)
106 sim = 1.0d0/sigm(d0ij)
109 fac = dd0*sim/dij*dexp(-0.5d0*dd0*dd0*sim)
111 ddqij = (c(k,il)-c(k,jl))*fac
112 dqwol(k,il)=dqwol(k,il)+ddqij
113 dqwol(k,jl)=dqwol(k,jl)-ddqij
116 if (itype(il).ne.10 .or. itype(jl).ne.10) then
119 & (cref(1,jl+nres)-cref(1,il+nres))**2+
120 & (cref(2,jl+nres)-cref(2,il+nres))**2+
121 & (cref(3,jl+nres)-cref(3,il+nres))**2)
122 dijCM=dist(il+nres,jl+nres)
123 sim = 1.0d0/sigm(d0ijCM)
126 fac=dd0*sim/dijCM*dexp(-0.5d0*dd0*dd0*sim)
128 ddqij = (c(k,il+nres)-c(k,jl+nres))*fac
129 dxqwol(k,il)=dxqwol(k,il)+ddqij
130 dxqwol(k,jl)=dxqwol(k,jl)-ddqij
137 if((seg3-il).lt.3) then
144 d0ij=dsqrt((cref(1,jl)-cref(1,il))**2+
145 & (cref(2,jl)-cref(2,il))**2+
146 & (cref(3,jl)-cref(3,il))**2)
148 sim = 1.0d0/sigm(d0ij)
151 fac = dd0*sim/dij*dexp(-0.5d0*dd0*dd0*sim)
153 ddqij = (c(k,il)-c(k,jl))*fac
154 dqwol(k,il)=dqwol(k,il)+ddqij
155 dqwol(k,jl)=dqwol(k,jl)-ddqij
157 if (itype(il).ne.10 .or. itype(jl).ne.10) then
160 & (cref(1,jl+nres)-cref(1,il+nres))**2+
161 & (cref(2,jl+nres)-cref(2,il+nres))**2+
162 & (cref(3,jl+nres)-cref(3,il+nres))**2)
163 dijCM=dist(il+nres,jl+nres)
164 sim = 1.0d0/sigm(d0ijCM)
167 fac = dd0*sim/dijCM*dexp(-0.5d0*dd0*dd0*sim)
169 ddqij = (c(k,il+nres)-c(k,jl+nres))*fac
170 dxqwol(k,il)=dxqwol(k,il)+ddqij
171 dxqwol(k,jl)=dxqwol(k,jl)-ddqij
179 dqwol(j,i)=dqwol(j,i)/nl
180 dxqwol(j,i)=dxqwol(j,i)/nl
185 c-------------------------------------------------------------------
186 subroutine qwol_num(seg1,seg2,flag,seg3,seg4)
187 implicit real*8 (a-h,o-z)
189 include 'COMMON.IOUNITS'
190 include 'COMMON.CHAIN'
191 include 'COMMON.INTERACT'
193 integer seg1,seg2,seg3,seg4
195 double precision qwolan(3,0:maxres),cdummy(3,0:maxres2),
196 & qwolxan(3,0:maxres),q1,q2
197 double precision delta /1.0d-10/
200 q1=qwolynes(seg1,seg2,flag,seg3,seg4)
203 q2=qwolynes(seg1,seg2,flag,seg3,seg4)
204 qwolan(j,i)=(q2-q1)/delta
210 q1=qwolynes(seg1,seg2,flag,seg3,seg4)
211 cdummy(j,i+nres)=c(j,i+nres)
212 c(j,i+nres)=c(j,i+nres)+delta
213 q2=qwolynes(seg1,seg2,flag,seg3,seg4)
214 qwolxan(j,i)=(q2-q1)/delta
215 c(j,i+nres)=cdummy(j,i+nres)
218 c write(iout,*) "Numerical Q carteisan gradients backbone: "
220 c write(iout,'(i5,3e15.5)') i, (qwolan(j,i),j=1,3)
222 c write(iout,*) "Numerical Q carteisan gradients side-chain: "
224 c write(iout,'(i5,3e15.5)') i, (qwolxan(j,i),j=1,3)
228 c------------------------------------------------------------------------
230 c MD with umbrella_sampling using Wolyne's distance measure as a constraint
231 implicit real*8 (a-h,o-z)
233 include 'COMMON.CONTROL'
237 include 'COMMON.LANGEVIN'
239 include 'COMMON.LANGEVIN.lang0'
241 include 'COMMON.CHAIN'
242 include 'COMMON.DERIV'
244 include 'COMMON.LOCAL'
245 include 'COMMON.INTERACT'
246 include 'COMMON.IOUNITS'
247 include 'COMMON.NAMES'
248 include 'COMMON.TIME1'
249 double precision uzap1,uzap2,hm1,hm2,hmnum
250 double precision ucdelan,dUcartan(3,0:MAXRES)
251 & ,dUxcartan(3,0:MAXRES),cdummy(3,0:MAXRES),
252 & duconst(3,0:MAXRES),duxconst(3,0:MAXRES)
253 integer kstart,kend,lstart,lend,idummy
254 double precision delta /1.0d-7/
265 qfrag(i)=qwolynes(ifrag(1,i,iset),ifrag(2,i,iset),.true.
267 Uconst=Uconst+wfrag(i,iset)*harmonic(qfrag(i),qinfrag(i,iset))
268 c Calculating the derivatives of Constraint energy with respect to Q
269 Ucdfrag=wfrag(i,iset)*harmonicprim(qfrag(i),
271 c hm1=harmonic(qfrag(i,iset),qinfrag(i,iset))
272 c hm2=harmonic(qfrag(i,iset)+delta,qinfrag(i,iset))
273 c hmnum=(hm2-hm1)/delta
274 c write(iout,*) "harmonicprim frag",harmonicprim(qfrag(i,iset),
276 c write(iout,*) "harmonicnum frag", hmnum
277 c Calculating the derivatives of Q with respect to cartesian coordinates
278 call qwolynes_prim(ifrag(1,i,iset),ifrag(2,i,iset),.true.
280 c write(iout,*) "dqwol "
282 c write(iout,'(i5,3e15.5)') ii,(dqwol(j,ii),j=1,3)
284 c write(iout,*) "dxqwol "
286 c write(iout,'(i5,3e15.5)') ii,(dxqwol(j,ii),j=1,3)
288 c Calculating numerical gradients of dU/dQi and dQi/dxi
289 c call qwol_num(ifrag(1,i,iset),ifrag(2,i,iset),.true.
291 c The gradients of Uconst in Cs
294 duconst(j,ii)=dUconst(j,ii)+ucdfrag*dqwol(j,ii)
295 dUxconst(j,ii)=dUxconst(j,ii)+ucdfrag*dxqwol(j,ii)
300 kstart=ifrag(1,ipair(1,i,iset),iset)
301 kend=ifrag(2,ipair(1,i,iset),iset)
302 lstart=ifrag(1,ipair(2,i,iset),iset)
303 lend=ifrag(2,ipair(2,i,iset),iset)
304 qpair(i)=qwolynes(kstart,kend,.false.,lstart,lend)
305 Uconst=Uconst+wpair(i,iset)*harmonic(qpair(i),qinpair(i,iset))
307 Ucdpair=wpair(i,iset)*harmonicprim(qpair(i),qinpair(i,iset))
308 c hm1=harmonic(qpair(i),qinpair(i,iset))
309 c hm2=harmonic(qpair(i)+delta,qinpair(i,iset))
310 c hmnum=(hm2-hm1)/delta
311 c write(iout,*) "harmonicprim pair ",harmonicprim(qpair(i),
313 c write(iout,*) "harmonicnum pair ", hmnum
315 call qwolynes_prim(kstart,kend,.false.
317 c write(iout,*) "dqwol "
319 c write(iout,'(i5,3e15.5)') ii,(dqwol(j,ii),j=1,3)
321 c write(iout,*) "dxqwol "
323 c write(iout,'(i5,3e15.5)') ii,(dxqwol(j,ii),j=1,3)
325 c Calculating numerical gradients
326 c call qwol_num(kstart,kend,.false.
328 c The gradients of Uconst in Cs
331 duconst(j,ii)=dUconst(j,ii)+ucdpair*dqwol(j,ii)
332 dUxconst(j,ii)=dUxconst(j,ii)+ucdpair*dxqwol(j,ii)
336 c write(iout,*) "Uconst inside subroutine ", Uconst
337 c Transforming the gradients from Cs to dCs for the backbone
341 dudconst(k,i)=dudconst(k,i)+duconst(k,j)+duxconst(k,j)
345 c Transforming the gradients from Cs to dCs for the side chains
348 dudxconst(j,i)=duxconst(j,i)
351 c write(iout,*) "dU/ddc backbone "
353 c write(iout,'(i5,3e15.5)') ii, (dudconst(j,ii),j=1,3)
355 c write(iout,*) "dU/ddX side chain "
357 c write(iout,'(i5,3e15.5)') ii,(duxconst(j,ii),j=1,3)
359 c Calculating numerical gradients of dUconst/ddc and dUconst/ddx
363 c-----------------------------------------------------------------------
364 subroutine dEconstrQ_num
365 c Calculating numerical dUconst/ddc and dUconst/ddx
366 implicit real*8 (a-h,o-z)
368 include 'COMMON.CONTROL'
372 include 'COMMON.LANGEVIN'
374 include 'COMMON.LANGEVIN.lang0'
376 include 'COMMON.CHAIN'
377 include 'COMMON.DERIV'
379 include 'COMMON.LOCAL'
380 include 'COMMON.INTERACT'
381 include 'COMMON.IOUNITS'
382 include 'COMMON.NAMES'
383 include 'COMMON.TIME1'
384 double precision uzap1,uzap2
385 double precision dUcartan(3,0:MAXRES)
386 & ,dUxcartan(3,0:MAXRES),cdummy(3,0:MAXRES)
387 integer kstart,kend,lstart,lend,idummy
388 double precision delta /1.0d-7/
394 dc(j,i)=dc(j,i)+delta
398 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),.true.
400 uzap2=uzap2+wfrag(ii,iset)*harmonic(qfrag(ii),
404 kstart=ifrag(1,ipair(1,ii,iset),iset)
405 kend=ifrag(2,ipair(1,ii,iset),iset)
406 lstart=ifrag(1,ipair(2,ii,iset),iset)
407 lend=ifrag(2,ipair(2,ii,iset),iset)
408 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
409 uzap2=uzap2+wpair(ii,iset)*harmonic(qpair(ii),
416 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),.true.
418 uzap1=uzap1+wfrag(ii,iset)*harmonic(qfrag(ii),
422 kstart=ifrag(1,ipair(1,ii,iset),iset)
423 kend=ifrag(2,ipair(1,ii,iset),iset)
424 lstart=ifrag(1,ipair(2,ii,iset),iset)
425 lend=ifrag(2,ipair(2,ii,iset),iset)
426 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
427 uzap1=uzap1+wpair(ii,iset)*harmonic(qpair(ii),
430 ducartan(j,i)=(uzap2-uzap1)/(delta)
433 c Calculating numerical gradients for dU/ddx
437 cdummy(j,i)=dc(j,i+nres)
438 dc(j,i+nres)=dc(j,i+nres)+delta
442 qfrag(ii)=qwolynes(ifrag(1,ii,iset),ifrag(2,ii,iset),.true.
444 uzap2=uzap2+wfrag(ii,iset)*harmonic(qfrag(ii),
448 kstart=ifrag(1,ipair(1,ii,iset),iset)
449 kend=ifrag(2,ipair(1,ii,iset),iset)
450 lstart=ifrag(1,ipair(2,ii,iset),iset)
451 lend=ifrag(2,ipair(2,ii,iset),iset)
452 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
453 uzap2=uzap2+wpair(ii,iset)*harmonic(qpair(ii),
456 dc(j,i+nres)=cdummy(j,i)
460 qfrag(ii)=qwolynes(ifrag(1,ii,iset),
461 & ifrag(2,ii,iset),.true.,idummy,idummy)
462 uzap1=uzap1+wfrag(ii,iset)*harmonic(qfrag(ii),
466 kstart=ifrag(1,ipair(1,ii,iset),iset)
467 kend=ifrag(2,ipair(1,ii,iset),iset)
468 lstart=ifrag(1,ipair(2,ii,iset),iset)
469 lend=ifrag(2,ipair(2,ii,iset),iset)
470 qpair(ii)=qwolynes(kstart,kend,.false.,lstart,lend)
471 uzap1=uzap1+wpair(ii,iset)*harmonic(qpair(ii),
474 duxcartan(j,i)=(uzap2-uzap1)/(delta)
477 write(iout,*) "Numerical dUconst/ddc backbone "
479 write(iout,'(i5,3e15.5)') ii,(dUcartan(j,ii),j=1,3)
481 c write(iout,*) "Numerical dUconst/ddx side-chain "
483 c write(iout,'(i5,3e15.5)') ii,(dUxcartan(j,ii),j=1,3)
487 c---------------------------------------------------------------------------