2 c RATTLE algorithm for velocity Verlet - step 1, UNRES
4 implicit real*8 (a-h,o-z)
6 include 'COMMON.CONTROL'
10 include 'COMMON.LANGEVIN'
12 include 'COMMON.LANGEVIN.lang0'
14 include 'COMMON.CHAIN'
15 include 'COMMON.DERIV'
17 include 'COMMON.LOCAL'
18 include 'COMMON.INTERACT'
19 include 'COMMON.IOUNITS'
20 include 'COMMON.NAMES'
21 include 'COMMON.TIME1'
22 double precision gginv(maxres2,maxres2),
23 & gdc(3,MAXRES2,MAXRES2),dC_uncor(3,MAXRES2),
24 & Cmat(MAXRES2,MAXRES2),x(MAXRES2),xcorr(3,MAXRES2)
25 common /przechowalnia/ GGinv,gdc,Cmat,nbond
26 integer max_rattle /5/
27 logical lprn /.false./, lprn1 /.false./,not_done
28 double precision tol_rattle /1.0d-5/
29 if (lprn) write (iout,*) "RATTLE1"
32 if (itype(i).ne.10) nbond=nbond+1
34 c Make a folded form of the Ginv-matrix
47 if (j.eq.1 .and. l.eq.1) GGinv(ii,jj)=Ginv(ind,ind1)
51 if (itype(k).ne.10) then
55 if (j.eq.1 .and. l.eq.1) GGinv(ii,jj)=Ginv(ind,ind1)
62 if (itype(i).ne.10) then
72 if (j.eq.1 .and. l.eq.1) GGinv(ii,jj)=Ginv(ind,ind1)
76 if (itype(k).ne.10) then
80 if (j.eq.1 .and. l.eq.1) GGinv(ii,jj)=Ginv(ind,ind1)
88 write (iout,*) "Matrix GGinv"
89 call MATOUT(nbond,nbond,MAXRES2,MAXRES2,GGinv)
95 if (iter.gt.max_rattle) then
96 write (iout,*) "Error - too many iterations in RATTLE."
99 c Calculate the matrix C = GG**(-1) dC_old o dC
104 dC_uncor(j,ind1)=dC(j,i)
108 if (itype(i).ne.10) then
111 dC_uncor(j,ind1)=dC(j,i+nres)
120 gdc(j,i,ind)=GGinv(i,ind)*dC_old(j,k)
124 if (itype(k).ne.10) then
127 gdc(j,i,ind)=GGinv(i,ind)*dC_old(j,k+nres)
132 c Calculate deviations from standard virtual-bond lengths
136 x(ind)=vbld(i+1)**2-vbl**2
139 if (itype(i).ne.10) then
141 x(ind)=vbld(i+nres)**2-vbldsc0(1,itype(i))**2
145 write (iout,*) "Coordinates and violations"
147 write(iout,'(i5,3f10.5,5x,e15.5)')
148 & i,(dC_uncor(j,i),j=1,3),x(i)
150 write (iout,*) "Velocities and violations"
154 write (iout,'(2i5,3f10.5,5x,e15.5)')
155 & i,ind,(d_t_new(j,i),j=1,3),scalar(d_t_new(1,i),dC_old(1,i))
158 if (itype(i).ne.10) then
160 write (iout,'(2i5,3f10.5,5x,e15.5)')
161 & i+nres,ind,(d_t_new(j,i+nres),j=1,3),
162 & scalar(d_t_new(1,i+nres),dC_old(1,i+nres))
165 c write (iout,*) "gdc"
167 c write (iout,*) "i",i
169 c write (iout,'(i5,3f10.5)') j,(gdc(k,j,i),k=1,3)
175 if (dabs(x(i)).gt.xmax) then
179 if (xmax.lt.tol_rattle) then
183 c Calculate the matrix of the system of equations
188 Cmat(i,j)=Cmat(i,j)+dC_uncor(k,i)*gdc(k,i,j)
193 write (iout,*) "Matrix Cmat"
194 call MATOUT(nbond,nbond,MAXRES2,MAXRES2,Cmat)
196 call gauss(Cmat,X,MAXRES2,nbond,1,*10)
197 c Add constraint term to positions
204 xx = xx+x(ii)*gdc(j,ind,ii)
208 d_t_new(j,i)=d_t_new(j,i)-xx/d_time
212 if (itype(i).ne.10) then
217 xx = xx+x(ii)*gdc(j,ind,ii)
220 dC(j,i+nres)=dC(j,i+nres)-xx
221 d_t_new(j,i+nres)=d_t_new(j,i+nres)-xx/d_time
225 c Rebuild the chain using the new coordinates
228 write (iout,*) "New coordinates, Lagrange multipliers,",
229 & " and differences between actual and standard bond lengths"
233 xx=vbld(i+1)**2-vbl**2
234 write (iout,'(i5,3f10.5,5x,f10.5,e15.5)')
235 & i,(dC(j,i),j=1,3),x(ind),xx
238 if (itype(i).ne.10) then
240 xx=vbld(i+nres)**2-vbldsc0(1,itype(i))**2
241 write (iout,'(i5,3f10.5,5x,f10.5,e15.5)')
242 & i,(dC(j,i+nres),j=1,3),x(ind),xx
245 write (iout,*) "Velocities and violations"
249 write (iout,'(2i5,3f10.5,5x,e15.5)')
250 & i,ind,(d_t_new(j,i),j=1,3),scalar(d_t_new(1,i),dC_old(1,i))
253 if (itype(i).ne.10) then
255 write (iout,'(2i5,3f10.5,5x,e15.5)')
256 & i+nres,ind,(d_t_new(j,i+nres),j=1,3),
257 & scalar(d_t_new(1,i+nres),dC_old(1,i+nres))
264 10 write (iout,*) "Error - singularity in solving the system",
265 & " of equations for Lagrange multipliers."
268 c------------------------------------------------------------------------------
270 c RATTLE algorithm for velocity Verlet - step 2, UNRES
272 implicit real*8 (a-h,o-z)
274 include 'COMMON.CONTROL'
278 include 'COMMON.LANGEVIN'
280 include 'COMMON.LANGEVIN.lang0'
282 include 'COMMON.CHAIN'
283 include 'COMMON.DERIV'
285 include 'COMMON.LOCAL'
286 include 'COMMON.INTERACT'
287 include 'COMMON.IOUNITS'
288 include 'COMMON.NAMES'
289 include 'COMMON.TIME1'
290 double precision gginv(maxres2,maxres2),
291 & gdc(3,MAXRES2,MAXRES2),dC_uncor(3,MAXRES2),
292 & Cmat(MAXRES2,MAXRES2),x(MAXRES2)
293 common /przechowalnia/ GGinv,gdc,Cmat,nbond
294 integer max_rattle /5/
295 logical lprn /.false./, lprn1 /.false./,not_done
296 double precision tol_rattle /1.0d-5/
297 if (lprn) write (iout,*) "RATTLE2"
298 if (lprn) write (iout,*) "Velocity correction"
299 c Calculate the matrix G dC
305 gdc(j,i,ind)=GGinv(i,ind)*dC(j,k)
309 if (itype(k).ne.10) then
312 gdc(j,i,ind)=GGinv(i,ind)*dC(j,k+nres)
318 c write (iout,*) "gdc"
320 c write (iout,*) "i",i
322 c write (iout,'(i5,3f10.5)') j,(gdc(k,j,i),k=1,3)
326 c Calculate the matrix of the system of equations
333 Cmat(ind,j)=Cmat(ind,j)+dC(k,i)*gdc(k,ind,j)
338 if (itype(i).ne.10) then
343 Cmat(ind,j)=Cmat(ind,j)+dC(k,i+nres)*gdc(k,ind,j)
348 c Calculate the scalar product dC o d_t_new
352 x(ind)=scalar(d_t(1,i),dC(1,i))
355 if (itype(i).ne.10) then
357 x(ind)=scalar(d_t(1,i+nres),dC(1,i+nres))
361 write (iout,*) "Velocities and violations"
365 write (iout,'(2i5,3f10.5,5x,e15.5)')
366 & i,ind,(d_t(j,i),j=1,3),x(ind)
369 if (itype(i).ne.10) then
371 write (iout,'(2i5,3f10.5,5x,e15.5)')
372 & i+nres,ind,(d_t(j,i+nres),j=1,3),x(ind)
378 if (dabs(x(i)).gt.xmax) then
382 if (xmax.lt.tol_rattle) then
387 write (iout,*) "Matrix Cmat"
388 call MATOUT(nbond,nbond,MAXRES2,MAXRES2,Cmat)
390 call gauss(Cmat,X,MAXRES2,nbond,1,*10)
391 c Add constraint term to velocities
398 xx = xx+x(ii)*gdc(j,ind,ii)
404 if (itype(i).ne.10) then
409 xx = xx+x(ii)*gdc(j,ind,ii)
411 d_t(j,i+nres)=d_t(j,i+nres)-xx
417 & "New velocities, Lagrange multipliers violations"
421 if (lprn) write (iout,'(2i5,3f10.5,5x,2e15.5)')
422 & i,ind,(d_t(j,i),j=1,3),x(ind),scalar(d_t(1,i),dC(1,i))
425 if (itype(i).ne.10) then
427 write (iout,'(2i5,3f10.5,5x,2e15.5)')
428 & i+nres,ind,(d_t(j,i+nres),j=1,3),x(ind),
429 & scalar(d_t(1,i+nres),dC(1,i+nres))
435 10 write (iout,*) "Error - singularity in solving the system",
436 & " of equations for Lagrange multipliers."
439 c------------------------------------------------------------------------------
440 subroutine rattle_brown
441 c RATTLE/LINCS algorithm for Brownian dynamics, UNRES
443 implicit real*8 (a-h,o-z)
445 include 'COMMON.CONTROL'
449 include 'COMMON.LANGEVIN'
451 include 'COMMON.LANGEVIN.lang0'
453 include 'COMMON.CHAIN'
454 include 'COMMON.DERIV'
456 include 'COMMON.LOCAL'
457 include 'COMMON.INTERACT'
458 include 'COMMON.IOUNITS'
459 include 'COMMON.NAMES'
460 include 'COMMON.TIME1'
461 double precision gginv(maxres2,maxres2),
462 & gdc(3,MAXRES2,MAXRES2),dC_uncor(3,MAXRES2),
463 & Cmat(MAXRES2,MAXRES2),x(MAXRES2)
464 common /przechowalnia/ GGinv,gdc,Cmat,nbond
465 integer max_rattle /5/
466 logical lprn /.true./, lprn1 /.true./,not_done
467 double precision tol_rattle /1.0d-5/
468 if (lprn) write (iout,*) "RATTLE_BROWN"
471 if (itype(i).ne.10) nbond=nbond+1
473 c Make a folded form of the Ginv-matrix
486 if (j.eq.1 .and. l.eq.1) GGinv(ii,jj)=fricmat(ind,ind1)
490 if (itype(k).ne.10) then
494 if (j.eq.1 .and. l.eq.1) GGinv(ii,jj)=fricmat(ind,ind1)
501 if (itype(i).ne.10) then
511 if (j.eq.1 .and. l.eq.1) GGinv(ii,jj)=fricmat(ind,ind1)
515 if (itype(k).ne.10) then
519 if (j.eq.1 .and. l.eq.1)GGinv(ii,jj)=fricmat(ind,ind1)
527 write (iout,*) "Matrix GGinv"
528 call MATOUT(nbond,nbond,MAXRES2,MAXRES2,GGinv)
534 if (iter.gt.max_rattle) then
535 write (iout,*) "Error - too many iterations in RATTLE."
538 c Calculate the matrix C = GG**(-1) dC_old o dC
543 dC_uncor(j,ind1)=dC(j,i)
547 if (itype(i).ne.10) then
550 dC_uncor(j,ind1)=dC(j,i+nres)
559 gdc(j,i,ind)=GGinv(i,ind)*dC_old(j,k)
563 if (itype(k).ne.10) then
566 gdc(j,i,ind)=GGinv(i,ind)*dC_old(j,k+nres)
571 c Calculate deviations from standard virtual-bond lengths
575 x(ind)=vbld(i+1)**2-vbl**2
578 if (itype(i).ne.10) then
580 x(ind)=vbld(i+nres)**2-vbldsc0(1,itype(i))**2
584 write (iout,*) "Coordinates and violations"
586 write(iout,'(i5,3f10.5,5x,e15.5)')
587 & i,(dC_uncor(j,i),j=1,3),x(i)
589 write (iout,*) "Velocities and violations"
593 write (iout,'(2i5,3f10.5,5x,e15.5)')
594 & i,ind,(d_t(j,i),j=1,3),scalar(d_t(1,i),dC_old(1,i))
597 if (itype(i).ne.10) then
599 write (iout,'(2i5,3f10.5,5x,e15.5)')
600 & i+nres,ind,(d_t(j,i+nres),j=1,3),
601 & scalar(d_t(1,i+nres),dC_old(1,i+nres))
608 write (iout,'(i5,3f10.5)') j,(gdc(k,j,i),k=1,3)
614 if (dabs(x(i)).gt.xmax) then
618 if (xmax.lt.tol_rattle) then
622 c Calculate the matrix of the system of equations
627 Cmat(i,j)=Cmat(i,j)+dC_uncor(k,i)*gdc(k,i,j)
632 write (iout,*) "Matrix Cmat"
633 call MATOUT(nbond,nbond,MAXRES2,MAXRES2,Cmat)
635 call gauss(Cmat,X,MAXRES2,nbond,1,*10)
636 c Add constraint term to positions
643 xx = xx+x(ii)*gdc(j,ind,ii)
646 d_t(j,i)=d_t(j,i)+xx/d_time
651 if (itype(i).ne.10) then
656 xx = xx+x(ii)*gdc(j,ind,ii)
659 d_t(j,i+nres)=d_t(j,i+nres)+xx/d_time
660 dC(j,i+nres)=dC(j,i+nres)+xx
664 c Rebuild the chain using the new coordinates
667 write (iout,*) "New coordinates, Lagrange multipliers,",
668 & " and differences between actual and standard bond lengths"
672 xx=vbld(i+1)**2-vbl**2
673 write (iout,'(i5,3f10.5,5x,f10.5,e15.5)')
674 & i,(dC(j,i),j=1,3),x(ind),xx
677 if (itype(i).ne.10) then
679 xx=vbld(i+nres)**2-vbldsc0(1,itype(i))**2
680 write (iout,'(i5,3f10.5,5x,f10.5,e15.5)')
681 & i,(dC(j,i+nres),j=1,3),x(ind),xx
684 write (iout,*) "Velocities and violations"
688 write (iout,'(2i5,3f10.5,5x,e15.5)')
689 & i,ind,(d_t_new(j,i),j=1,3),scalar(d_t_new(1,i),dC_old(1,i))
692 if (itype(i).ne.10) then
694 write (iout,'(2i5,3f10.5,5x,e15.5)')
695 & i+nres,ind,(d_t_new(j,i+nres),j=1,3),
696 & scalar(d_t_new(1,i+nres),dC_old(1,i+nres))
703 10 write (iout,*) "Error - singularity in solving the system",
704 & " of equations for Lagrange multipliers."