2 c RATTLE algorithm for velocity Verlet - step 1, UNRES
4 implicit real*8 (a-h,o-z)
7 include 'COMMON.CONTROL'
10 include 'COMMON.LAGRANGE'
12 include 'COMMON.LANGEVIN'
14 include 'COMMON.LANGEVIN.lang0'
16 include 'COMMON.CHAIN'
17 include 'COMMON.DERIV'
19 include 'COMMON.LOCAL'
20 include 'COMMON.INTERACT'
21 include 'COMMON.IOUNITS'
22 include 'COMMON.NAMES'
23 include 'COMMON.TIME1'
24 double precision gginv(maxres2,maxres2),
25 & gdc(3,MAXRES2,MAXRES2),dC_uncor(3,MAXRES2),
26 & Cmat(MAXRES2,MAXRES2),x(MAXRES2),xcorr(3,MAXRES2)
27 common /przechowalnia/ GGinv,gdc,Cmat,nbond
28 integer max_rattle /5/
29 logical lprn /.false./, lprn1 /.false./,not_done
30 double precision tol_rattle /1.0d-5/
31 if (lprn) write (iout,*) "RATTLE1"
34 if (itype(i).ne.10) nbond=nbond+1
36 c Make a folded form of the Ginv-matrix
49 if (j.eq.1 .and. l.eq.1) GGinv(ii,jj)=Ginv(ind,ind1)
53 if (itype(k).ne.10) then
57 if (j.eq.1 .and. l.eq.1) GGinv(ii,jj)=Ginv(ind,ind1)
64 if (itype(i).ne.10) then
74 if (j.eq.1 .and. l.eq.1) GGinv(ii,jj)=Ginv(ind,ind1)
78 if (itype(k).ne.10) then
82 if (j.eq.1 .and. l.eq.1) GGinv(ii,jj)=Ginv(ind,ind1)
90 write (iout,*) "Matrix GGinv"
91 call MATOUT(nbond,nbond,MAXRES2,MAXRES2,GGinv)
97 if (iter.gt.max_rattle) then
98 write (iout,*) "Error - too many iterations in RATTLE."
101 c Calculate the matrix C = GG**(-1) dC_old o dC
106 dC_uncor(j,ind1)=dC(j,i)
110 if (itype(i).ne.10) then
113 dC_uncor(j,ind1)=dC(j,i+nres)
122 gdc(j,i,ind)=GGinv(i,ind)*dC_old(j,k)
126 if (itype(k).ne.10) then
129 gdc(j,i,ind)=GGinv(i,ind)*dC_old(j,k+nres)
134 c Calculate deviations from standard virtual-bond lengths
138 x(ind)=vbld(i+1)**2-vbl**2
141 if (itype(i).ne.10) then
143 x(ind)=vbld(i+nres)**2-vbldsc0(1,itype(i))**2
147 write (iout,*) "Coordinates and violations"
149 write(iout,'(i5,3f10.5,5x,e15.5)')
150 & i,(dC_uncor(j,i),j=1,3),x(i)
152 write (iout,*) "Velocities and violations"
156 write (iout,'(2i5,3f10.5,5x,e15.5)')
157 & i,ind,(d_t_new(j,i),j=1,3),scalar(d_t_new(1,i),dC_old(1,i))
160 if (itype(i).ne.10) then
162 write (iout,'(2i5,3f10.5,5x,e15.5)')
163 & i+nres,ind,(d_t_new(j,i+nres),j=1,3),
164 & scalar(d_t_new(1,i+nres),dC_old(1,i+nres))
167 c write (iout,*) "gdc"
169 c write (iout,*) "i",i
171 c write (iout,'(i5,3f10.5)') j,(gdc(k,j,i),k=1,3)
177 if (dabs(x(i)).gt.xmax) then
181 if (xmax.lt.tol_rattle) then
185 c Calculate the matrix of the system of equations
190 Cmat(i,j)=Cmat(i,j)+dC_uncor(k,i)*gdc(k,i,j)
195 write (iout,*) "Matrix Cmat"
196 call MATOUT(nbond,nbond,MAXRES2,MAXRES2,Cmat)
198 call gauss(Cmat,X,MAXRES2,nbond,1,*10)
199 c Add constraint term to positions
206 xx = xx+x(ii)*gdc(j,ind,ii)
210 d_t_new(j,i)=d_t_new(j,i)-xx/d_time
214 if (itype(i).ne.10) then
219 xx = xx+x(ii)*gdc(j,ind,ii)
222 dC(j,i+nres)=dC(j,i+nres)-xx
223 d_t_new(j,i+nres)=d_t_new(j,i+nres)-xx/d_time
227 c Rebuild the chain using the new coordinates
230 write (iout,*) "New coordinates, Lagrange multipliers,",
231 & " and differences between actual and standard bond lengths"
235 xx=vbld(i+1)**2-vbl**2
236 write (iout,'(i5,3f10.5,5x,f10.5,e15.5)')
237 & i,(dC(j,i),j=1,3),x(ind),xx
240 if (itype(i).ne.10) then
242 xx=vbld(i+nres)**2-vbldsc0(1,itype(i))**2
243 write (iout,'(i5,3f10.5,5x,f10.5,e15.5)')
244 & i,(dC(j,i+nres),j=1,3),x(ind),xx
247 write (iout,*) "Velocities and violations"
251 write (iout,'(2i5,3f10.5,5x,e15.5)')
252 & i,ind,(d_t_new(j,i),j=1,3),scalar(d_t_new(1,i),dC_old(1,i))
255 if (itype(i).ne.10) then
257 write (iout,'(2i5,3f10.5,5x,e15.5)')
258 & i+nres,ind,(d_t_new(j,i+nres),j=1,3),
259 & scalar(d_t_new(1,i+nres),dC_old(1,i+nres))
266 10 write (iout,*) "Error - singularity in solving the system",
267 & " of equations for Lagrange multipliers."
271 & "RATTLE inactive; use -DRATTLE switch at compile time."
275 c------------------------------------------------------------------------------
277 c RATTLE algorithm for velocity Verlet - step 2, UNRES
279 implicit real*8 (a-h,o-z)
282 include 'COMMON.CONTROL'
285 include 'COMMON.LAGRANGE'
287 include 'COMMON.LANGEVIN'
289 include 'COMMON.LANGEVIN.lang0'
291 include 'COMMON.CHAIN'
292 include 'COMMON.DERIV'
294 include 'COMMON.LOCAL'
295 include 'COMMON.INTERACT'
296 include 'COMMON.IOUNITS'
297 include 'COMMON.NAMES'
298 include 'COMMON.TIME1'
299 double precision gginv(maxres2,maxres2),
300 & gdc(3,MAXRES2,MAXRES2),dC_uncor(3,MAXRES2),
301 & Cmat(MAXRES2,MAXRES2),x(MAXRES2)
302 common /przechowalnia/ GGinv,gdc,Cmat,nbond
303 integer max_rattle /5/
304 logical lprn /.false./, lprn1 /.false./,not_done
305 double precision tol_rattle /1.0d-5/
306 if (lprn) write (iout,*) "RATTLE2"
307 if (lprn) write (iout,*) "Velocity correction"
308 c Calculate the matrix G dC
314 gdc(j,i,ind)=GGinv(i,ind)*dC(j,k)
318 if (itype(k).ne.10) then
321 gdc(j,i,ind)=GGinv(i,ind)*dC(j,k+nres)
327 c write (iout,*) "gdc"
329 c write (iout,*) "i",i
331 c write (iout,'(i5,3f10.5)') j,(gdc(k,j,i),k=1,3)
335 c Calculate the matrix of the system of equations
342 Cmat(ind,j)=Cmat(ind,j)+dC(k,i)*gdc(k,ind,j)
347 if (itype(i).ne.10) then
352 Cmat(ind,j)=Cmat(ind,j)+dC(k,i+nres)*gdc(k,ind,j)
357 c Calculate the scalar product dC o d_t_new
361 x(ind)=scalar(d_t(1,i),dC(1,i))
364 if (itype(i).ne.10) then
366 x(ind)=scalar(d_t(1,i+nres),dC(1,i+nres))
370 write (iout,*) "Velocities and violations"
374 write (iout,'(2i5,3f10.5,5x,e15.5)')
375 & i,ind,(d_t(j,i),j=1,3),x(ind)
378 if (itype(i).ne.10) then
380 write (iout,'(2i5,3f10.5,5x,e15.5)')
381 & i+nres,ind,(d_t(j,i+nres),j=1,3),x(ind)
387 if (dabs(x(i)).gt.xmax) then
391 if (xmax.lt.tol_rattle) then
396 write (iout,*) "Matrix Cmat"
397 call MATOUT(nbond,nbond,MAXRES2,MAXRES2,Cmat)
399 call gauss(Cmat,X,MAXRES2,nbond,1,*10)
400 c Add constraint term to velocities
407 xx = xx+x(ii)*gdc(j,ind,ii)
413 if (itype(i).ne.10) then
418 xx = xx+x(ii)*gdc(j,ind,ii)
420 d_t(j,i+nres)=d_t(j,i+nres)-xx
426 & "New velocities, Lagrange multipliers violations"
430 if (lprn) write (iout,'(2i5,3f10.5,5x,2e15.5)')
431 & i,ind,(d_t(j,i),j=1,3),x(ind),scalar(d_t(1,i),dC(1,i))
434 if (itype(i).ne.10) then
436 write (iout,'(2i5,3f10.5,5x,2e15.5)')
437 & i+nres,ind,(d_t(j,i+nres),j=1,3),x(ind),
438 & scalar(d_t(1,i+nres),dC(1,i+nres))
444 10 write (iout,*) "Error - singularity in solving the system",
445 & " of equations for Lagrange multipliers."
449 & "RATTLE inactive; use -DRATTLE option at compile time."
453 c------------------------------------------------------------------------------
454 subroutine rattle_brown
455 c RATTLE/LINCS algorithm for Brownian dynamics, UNRES
457 implicit real*8 (a-h,o-z)
460 include 'COMMON.CONTROL'
463 include 'COMMON.LAGRANGE'
465 include 'COMMON.LANGEVIN'
467 include 'COMMON.LANGEVIN.lang0'
469 include 'COMMON.CHAIN'
470 include 'COMMON.DERIV'
472 include 'COMMON.LOCAL'
473 include 'COMMON.INTERACT'
474 include 'COMMON.IOUNITS'
475 include 'COMMON.NAMES'
476 include 'COMMON.TIME1'
477 double precision gginv(maxres2,maxres2),
478 & gdc(3,MAXRES2,MAXRES2),dC_uncor(3,MAXRES2),
479 & Cmat(MAXRES2,MAXRES2),x(MAXRES2)
480 common /przechowalnia/ GGinv,gdc,Cmat,nbond
481 integer max_rattle /5/
482 logical lprn /.true./, lprn1 /.true./,not_done
483 double precision tol_rattle /1.0d-5/
484 if (lprn) write (iout,*) "RATTLE_BROWN"
487 if (itype(i).ne.10) nbond=nbond+1
489 c Make a folded form of the Ginv-matrix
502 if (j.eq.1 .and. l.eq.1) GGinv(ii,jj)=fricmat(ind,ind1)
506 if (itype(k).ne.10) then
510 if (j.eq.1 .and. l.eq.1) GGinv(ii,jj)=fricmat(ind,ind1)
517 if (itype(i).ne.10) then
527 if (j.eq.1 .and. l.eq.1) GGinv(ii,jj)=fricmat(ind,ind1)
531 if (itype(k).ne.10) then
535 if (j.eq.1 .and. l.eq.1)GGinv(ii,jj)=fricmat(ind,ind1)
543 write (iout,*) "Matrix GGinv"
544 call MATOUT(nbond,nbond,MAXRES2,MAXRES2,GGinv)
550 if (iter.gt.max_rattle) then
551 write (iout,*) "Error - too many iterations in RATTLE."
554 c Calculate the matrix C = GG**(-1) dC_old o dC
559 dC_uncor(j,ind1)=dC(j,i)
563 if (itype(i).ne.10) then
566 dC_uncor(j,ind1)=dC(j,i+nres)
575 gdc(j,i,ind)=GGinv(i,ind)*dC_old(j,k)
579 if (itype(k).ne.10) then
582 gdc(j,i,ind)=GGinv(i,ind)*dC_old(j,k+nres)
587 c Calculate deviations from standard virtual-bond lengths
591 x(ind)=vbld(i+1)**2-vbl**2
594 if (itype(i).ne.10) then
596 x(ind)=vbld(i+nres)**2-vbldsc0(1,itype(i))**2
600 write (iout,*) "Coordinates and violations"
602 write(iout,'(i5,3f10.5,5x,e15.5)')
603 & i,(dC_uncor(j,i),j=1,3),x(i)
605 write (iout,*) "Velocities and violations"
609 write (iout,'(2i5,3f10.5,5x,e15.5)')
610 & i,ind,(d_t(j,i),j=1,3),scalar(d_t(1,i),dC_old(1,i))
613 if (itype(i).ne.10) then
615 write (iout,'(2i5,3f10.5,5x,e15.5)')
616 & i+nres,ind,(d_t(j,i+nres),j=1,3),
617 & scalar(d_t(1,i+nres),dC_old(1,i+nres))
624 write (iout,'(i5,3f10.5)') j,(gdc(k,j,i),k=1,3)
630 if (dabs(x(i)).gt.xmax) then
634 if (xmax.lt.tol_rattle) then
638 c Calculate the matrix of the system of equations
643 Cmat(i,j)=Cmat(i,j)+dC_uncor(k,i)*gdc(k,i,j)
648 write (iout,*) "Matrix Cmat"
649 call MATOUT(nbond,nbond,MAXRES2,MAXRES2,Cmat)
651 call gauss(Cmat,X,MAXRES2,nbond,1,*10)
652 c Add constraint term to positions
659 xx = xx+x(ii)*gdc(j,ind,ii)
662 d_t(j,i)=d_t(j,i)+xx/d_time
667 if (itype(i).ne.10) then
672 xx = xx+x(ii)*gdc(j,ind,ii)
675 d_t(j,i+nres)=d_t(j,i+nres)+xx/d_time
676 dC(j,i+nres)=dC(j,i+nres)+xx
680 c Rebuild the chain using the new coordinates
683 write (iout,*) "New coordinates, Lagrange multipliers,",
684 & " and differences between actual and standard bond lengths"
688 xx=vbld(i+1)**2-vbl**2
689 write (iout,'(i5,3f10.5,5x,f10.5,e15.5)')
690 & i,(dC(j,i),j=1,3),x(ind),xx
693 if (itype(i).ne.10) then
695 xx=vbld(i+nres)**2-vbldsc0(1,itype(i))**2
696 write (iout,'(i5,3f10.5,5x,f10.5,e15.5)')
697 & i,(dC(j,i+nres),j=1,3),x(ind),xx
700 write (iout,*) "Velocities and violations"
704 write (iout,'(2i5,3f10.5,5x,e15.5)')
705 & i,ind,(d_t_new(j,i),j=1,3),scalar(d_t_new(1,i),dC_old(1,i))
708 if (itype(i).ne.10) then
710 write (iout,'(2i5,3f10.5,5x,e15.5)')
711 & i+nres,ind,(d_t_new(j,i+nres),j=1,3),
712 & scalar(d_t_new(1,i+nres),dC_old(1,i+nres))
719 10 write (iout,*) "Error - singularity in solving the system",
720 & " of equations for Lagrange multipliers."
724 & "RATTLE inactive; use -DRATTLE option at compile time"