2 c RATTLE algorithm for velocity Verlet - step 1, UNRES
4 implicit real*8 (a-h,o-z)
7 include 'COMMON.CONTROL'
11 include 'COMMON.LANGEVIN'
13 include 'COMMON.LANGEVIN.lang0'
15 include 'COMMON.CHAIN'
16 include 'COMMON.DERIV'
18 include 'COMMON.LOCAL'
19 include 'COMMON.INTERACT'
20 include 'COMMON.IOUNITS'
21 include 'COMMON.NAMES'
22 include 'COMMON.TIME1'
23 double precision gginv(maxres2,maxres2),
24 & gdc(3,MAXRES2,MAXRES2),dC_uncor(3,MAXRES2),
25 & Cmat(MAXRES2,MAXRES2),x(MAXRES2),xcorr(3,MAXRES2)
26 common /przechowalnia/ GGinv,gdc,Cmat,nbond
27 integer max_rattle /5/
28 logical lprn /.false./, lprn1 /.false./,not_done
29 double precision tol_rattle /1.0d-5/
30 if (lprn) write (iout,*) "RATTLE1"
33 if (itype(i).ne.10) nbond=nbond+1
35 c Make a folded form of the Ginv-matrix
48 if (j.eq.1 .and. l.eq.1) GGinv(ii,jj)=Ginv(ind,ind1)
52 if (itype(k).ne.10) then
56 if (j.eq.1 .and. l.eq.1) GGinv(ii,jj)=Ginv(ind,ind1)
63 if (itype(i).ne.10) then
73 if (j.eq.1 .and. l.eq.1) GGinv(ii,jj)=Ginv(ind,ind1)
77 if (itype(k).ne.10) then
81 if (j.eq.1 .and. l.eq.1) GGinv(ii,jj)=Ginv(ind,ind1)
89 write (iout,*) "Matrix GGinv"
90 call MATOUT(nbond,nbond,MAXRES2,MAXRES2,GGinv)
96 if (iter.gt.max_rattle) then
97 write (iout,*) "Error - too many iterations in RATTLE."
100 c Calculate the matrix C = GG**(-1) dC_old o dC
105 dC_uncor(j,ind1)=dC(j,i)
109 if (itype(i).ne.10) then
112 dC_uncor(j,ind1)=dC(j,i+nres)
121 gdc(j,i,ind)=GGinv(i,ind)*dC_old(j,k)
125 if (itype(k).ne.10) then
128 gdc(j,i,ind)=GGinv(i,ind)*dC_old(j,k+nres)
133 c Calculate deviations from standard virtual-bond lengths
137 x(ind)=vbld(i+1)**2-vbl**2
140 if (itype(i).ne.10) then
142 x(ind)=vbld(i+nres)**2-vbldsc0(1,itype(i))**2
146 write (iout,*) "Coordinates and violations"
148 write(iout,'(i5,3f10.5,5x,e15.5)')
149 & i,(dC_uncor(j,i),j=1,3),x(i)
151 write (iout,*) "Velocities and violations"
155 write (iout,'(2i5,3f10.5,5x,e15.5)')
156 & i,ind,(d_t_new(j,i),j=1,3),scalar(d_t_new(1,i),dC_old(1,i))
159 if (itype(i).ne.10) then
161 write (iout,'(2i5,3f10.5,5x,e15.5)')
162 & i+nres,ind,(d_t_new(j,i+nres),j=1,3),
163 & scalar(d_t_new(1,i+nres),dC_old(1,i+nres))
166 c write (iout,*) "gdc"
168 c write (iout,*) "i",i
170 c write (iout,'(i5,3f10.5)') j,(gdc(k,j,i),k=1,3)
176 if (dabs(x(i)).gt.xmax) then
180 if (xmax.lt.tol_rattle) then
184 c Calculate the matrix of the system of equations
189 Cmat(i,j)=Cmat(i,j)+dC_uncor(k,i)*gdc(k,i,j)
194 write (iout,*) "Matrix Cmat"
195 call MATOUT(nbond,nbond,MAXRES2,MAXRES2,Cmat)
197 call gauss(Cmat,X,MAXRES2,nbond,1,*10)
198 c Add constraint term to positions
205 xx = xx+x(ii)*gdc(j,ind,ii)
209 d_t_new(j,i)=d_t_new(j,i)-xx/d_time
213 if (itype(i).ne.10) then
218 xx = xx+x(ii)*gdc(j,ind,ii)
221 dC(j,i+nres)=dC(j,i+nres)-xx
222 d_t_new(j,i+nres)=d_t_new(j,i+nres)-xx/d_time
226 c Rebuild the chain using the new coordinates
229 write (iout,*) "New coordinates, Lagrange multipliers,",
230 & " and differences between actual and standard bond lengths"
234 xx=vbld(i+1)**2-vbl**2
235 write (iout,'(i5,3f10.5,5x,f10.5,e15.5)')
236 & i,(dC(j,i),j=1,3),x(ind),xx
239 if (itype(i).ne.10) then
241 xx=vbld(i+nres)**2-vbldsc0(1,itype(i))**2
242 write (iout,'(i5,3f10.5,5x,f10.5,e15.5)')
243 & i,(dC(j,i+nres),j=1,3),x(ind),xx
246 write (iout,*) "Velocities and violations"
250 write (iout,'(2i5,3f10.5,5x,e15.5)')
251 & i,ind,(d_t_new(j,i),j=1,3),scalar(d_t_new(1,i),dC_old(1,i))
254 if (itype(i).ne.10) then
256 write (iout,'(2i5,3f10.5,5x,e15.5)')
257 & i+nres,ind,(d_t_new(j,i+nres),j=1,3),
258 & scalar(d_t_new(1,i+nres),dC_old(1,i+nres))
265 10 write (iout,*) "Error - singularity in solving the system",
266 & " of equations for Lagrange multipliers."
270 & "RATTLE inactive; use -DRATTLE switch at compile time."
274 c------------------------------------------------------------------------------
276 c RATTLE algorithm for velocity Verlet - step 2, UNRES
278 implicit real*8 (a-h,o-z)
281 include 'COMMON.CONTROL'
285 include 'COMMON.LANGEVIN'
287 include 'COMMON.LANGEVIN.lang0'
289 include 'COMMON.CHAIN'
290 include 'COMMON.DERIV'
292 include 'COMMON.LOCAL'
293 include 'COMMON.INTERACT'
294 include 'COMMON.IOUNITS'
295 include 'COMMON.NAMES'
296 include 'COMMON.TIME1'
297 double precision gginv(maxres2,maxres2),
298 & gdc(3,MAXRES2,MAXRES2),dC_uncor(3,MAXRES2),
299 & Cmat(MAXRES2,MAXRES2),x(MAXRES2)
300 common /przechowalnia/ GGinv,gdc,Cmat,nbond
301 integer max_rattle /5/
302 logical lprn /.false./, lprn1 /.false./,not_done
303 double precision tol_rattle /1.0d-5/
304 if (lprn) write (iout,*) "RATTLE2"
305 if (lprn) write (iout,*) "Velocity correction"
306 c Calculate the matrix G dC
312 gdc(j,i,ind)=GGinv(i,ind)*dC(j,k)
316 if (itype(k).ne.10) then
319 gdc(j,i,ind)=GGinv(i,ind)*dC(j,k+nres)
325 c write (iout,*) "gdc"
327 c write (iout,*) "i",i
329 c write (iout,'(i5,3f10.5)') j,(gdc(k,j,i),k=1,3)
333 c Calculate the matrix of the system of equations
340 Cmat(ind,j)=Cmat(ind,j)+dC(k,i)*gdc(k,ind,j)
345 if (itype(i).ne.10) then
350 Cmat(ind,j)=Cmat(ind,j)+dC(k,i+nres)*gdc(k,ind,j)
355 c Calculate the scalar product dC o d_t_new
359 x(ind)=scalar(d_t(1,i),dC(1,i))
362 if (itype(i).ne.10) then
364 x(ind)=scalar(d_t(1,i+nres),dC(1,i+nres))
368 write (iout,*) "Velocities and violations"
372 write (iout,'(2i5,3f10.5,5x,e15.5)')
373 & i,ind,(d_t(j,i),j=1,3),x(ind)
376 if (itype(i).ne.10) then
378 write (iout,'(2i5,3f10.5,5x,e15.5)')
379 & i+nres,ind,(d_t(j,i+nres),j=1,3),x(ind)
385 if (dabs(x(i)).gt.xmax) then
389 if (xmax.lt.tol_rattle) then
394 write (iout,*) "Matrix Cmat"
395 call MATOUT(nbond,nbond,MAXRES2,MAXRES2,Cmat)
397 call gauss(Cmat,X,MAXRES2,nbond,1,*10)
398 c Add constraint term to velocities
405 xx = xx+x(ii)*gdc(j,ind,ii)
411 if (itype(i).ne.10) then
416 xx = xx+x(ii)*gdc(j,ind,ii)
418 d_t(j,i+nres)=d_t(j,i+nres)-xx
424 & "New velocities, Lagrange multipliers violations"
428 if (lprn) write (iout,'(2i5,3f10.5,5x,2e15.5)')
429 & i,ind,(d_t(j,i),j=1,3),x(ind),scalar(d_t(1,i),dC(1,i))
432 if (itype(i).ne.10) then
434 write (iout,'(2i5,3f10.5,5x,2e15.5)')
435 & i+nres,ind,(d_t(j,i+nres),j=1,3),x(ind),
436 & scalar(d_t(1,i+nres),dC(1,i+nres))
442 10 write (iout,*) "Error - singularity in solving the system",
443 & " of equations for Lagrange multipliers."
447 & "RATTLE inactive; use -DRATTLE option at compile time."
451 c------------------------------------------------------------------------------
452 subroutine rattle_brown
453 c RATTLE/LINCS algorithm for Brownian dynamics, UNRES
455 implicit real*8 (a-h,o-z)
458 include 'COMMON.CONTROL'
462 include 'COMMON.LANGEVIN'
464 include 'COMMON.LANGEVIN.lang0'
466 include 'COMMON.CHAIN'
467 include 'COMMON.DERIV'
469 include 'COMMON.LOCAL'
470 include 'COMMON.INTERACT'
471 include 'COMMON.IOUNITS'
472 include 'COMMON.NAMES'
473 include 'COMMON.TIME1'
474 double precision gginv(maxres2,maxres2),
475 & gdc(3,MAXRES2,MAXRES2),dC_uncor(3,MAXRES2),
476 & Cmat(MAXRES2,MAXRES2),x(MAXRES2)
477 common /przechowalnia/ GGinv,gdc,Cmat,nbond
478 integer max_rattle /5/
479 logical lprn /.true./, lprn1 /.true./,not_done
480 double precision tol_rattle /1.0d-5/
481 if (lprn) write (iout,*) "RATTLE_BROWN"
484 if (itype(i).ne.10) nbond=nbond+1
486 c Make a folded form of the Ginv-matrix
499 if (j.eq.1 .and. l.eq.1) GGinv(ii,jj)=fricmat(ind,ind1)
503 if (itype(k).ne.10) then
507 if (j.eq.1 .and. l.eq.1) GGinv(ii,jj)=fricmat(ind,ind1)
514 if (itype(i).ne.10) then
524 if (j.eq.1 .and. l.eq.1) GGinv(ii,jj)=fricmat(ind,ind1)
528 if (itype(k).ne.10) then
532 if (j.eq.1 .and. l.eq.1)GGinv(ii,jj)=fricmat(ind,ind1)
540 write (iout,*) "Matrix GGinv"
541 call MATOUT(nbond,nbond,MAXRES2,MAXRES2,GGinv)
547 if (iter.gt.max_rattle) then
548 write (iout,*) "Error - too many iterations in RATTLE."
551 c Calculate the matrix C = GG**(-1) dC_old o dC
556 dC_uncor(j,ind1)=dC(j,i)
560 if (itype(i).ne.10) then
563 dC_uncor(j,ind1)=dC(j,i+nres)
572 gdc(j,i,ind)=GGinv(i,ind)*dC_old(j,k)
576 if (itype(k).ne.10) then
579 gdc(j,i,ind)=GGinv(i,ind)*dC_old(j,k+nres)
584 c Calculate deviations from standard virtual-bond lengths
588 x(ind)=vbld(i+1)**2-vbl**2
591 if (itype(i).ne.10) then
593 x(ind)=vbld(i+nres)**2-vbldsc0(1,itype(i))**2
597 write (iout,*) "Coordinates and violations"
599 write(iout,'(i5,3f10.5,5x,e15.5)')
600 & i,(dC_uncor(j,i),j=1,3),x(i)
602 write (iout,*) "Velocities and violations"
606 write (iout,'(2i5,3f10.5,5x,e15.5)')
607 & i,ind,(d_t(j,i),j=1,3),scalar(d_t(1,i),dC_old(1,i))
610 if (itype(i).ne.10) then
612 write (iout,'(2i5,3f10.5,5x,e15.5)')
613 & i+nres,ind,(d_t(j,i+nres),j=1,3),
614 & scalar(d_t(1,i+nres),dC_old(1,i+nres))
621 write (iout,'(i5,3f10.5)') j,(gdc(k,j,i),k=1,3)
627 if (dabs(x(i)).gt.xmax) then
631 if (xmax.lt.tol_rattle) then
635 c Calculate the matrix of the system of equations
640 Cmat(i,j)=Cmat(i,j)+dC_uncor(k,i)*gdc(k,i,j)
645 write (iout,*) "Matrix Cmat"
646 call MATOUT(nbond,nbond,MAXRES2,MAXRES2,Cmat)
648 call gauss(Cmat,X,MAXRES2,nbond,1,*10)
649 c Add constraint term to positions
656 xx = xx+x(ii)*gdc(j,ind,ii)
659 d_t(j,i)=d_t(j,i)+xx/d_time
664 if (itype(i).ne.10) then
669 xx = xx+x(ii)*gdc(j,ind,ii)
672 d_t(j,i+nres)=d_t(j,i+nres)+xx/d_time
673 dC(j,i+nres)=dC(j,i+nres)+xx
677 c Rebuild the chain using the new coordinates
680 write (iout,*) "New coordinates, Lagrange multipliers,",
681 & " and differences between actual and standard bond lengths"
685 xx=vbld(i+1)**2-vbl**2
686 write (iout,'(i5,3f10.5,5x,f10.5,e15.5)')
687 & i,(dC(j,i),j=1,3),x(ind),xx
690 if (itype(i).ne.10) then
692 xx=vbld(i+nres)**2-vbldsc0(1,itype(i))**2
693 write (iout,'(i5,3f10.5,5x,f10.5,e15.5)')
694 & i,(dC(j,i+nres),j=1,3),x(ind),xx
697 write (iout,*) "Velocities and violations"
701 write (iout,'(2i5,3f10.5,5x,e15.5)')
702 & i,ind,(d_t_new(j,i),j=1,3),scalar(d_t_new(1,i),dC_old(1,i))
705 if (itype(i).ne.10) then
707 write (iout,'(2i5,3f10.5,5x,e15.5)')
708 & i+nres,ind,(d_t_new(j,i+nres),j=1,3),
709 & scalar(d_t_new(1,i+nres),dC_old(1,i+nres))
716 10 write (iout,*) "Error - singularity in solving the system",
717 & " of equations for Lagrange multipliers."
721 & "RATTLE inactive; use -DRATTLE option at compile time"