1 c-------------------------------------------------------------------------------
2 subroutine brown_step(itime)
3 c------------------------------------------------
4 c Perform a single Euler integration step of Brownian dynamics
5 c------------------------------------------------
6 implicit real*8 (a-h,o-z)
11 include 'COMMON.CONTROL'
15 include 'COMMON.LANGEVIN'
17 include 'COMMON.LANGEVIN.lang0'
19 include 'COMMON.CHAIN'
20 include 'COMMON.DERIV'
22 include 'COMMON.LOCAL'
23 include 'COMMON.INTERACT'
24 include 'COMMON.IOUNITS'
25 include 'COMMON.NAMES'
26 include 'COMMON.TIME1'
27 double precision zapas(MAXRES6)
30 double precision stochforcvec(MAXRES6)
31 double precision Bmat(MAXRES6,MAXRES2),Cmat(maxres2,maxres2),
32 & Cinv(maxres2,maxres2),GBmat(MAXRES6,MAXRES2),
33 & Tmat(MAXRES6,MAXRES2),Pmat(maxres6,maxres6),Td(maxres6),
35 common /stochcalc/ stochforcvec
38 logical lprn /.false./,lprn1 /.false./
40 double precision difftol /1.0d-5/
43 if (itype(i).ne.10) nbond=nbond+1
47 write (iout,*) "Generalized inverse of fricmat"
48 call matout(dimen,dimen,MAXRES6,MAXRES6,fricmat)
60 Bmat(ind+j,ind1)=dC_norm(j,i)
65 if (itype(i).ne.10) then
68 Bmat(ind+j,ind1)=dC_norm(j,i+nres)
74 write (iout,*) "Matrix Bmat"
75 call MATOUT(nbond,dimen,MAXRES6,MAXRES2,Bmat)
81 GBmat(i,j)=GBmat(i,j)+fricmat(i,k)*Bmat(k,j)
86 write (iout,*) "Matrix GBmat"
87 call MATOUT(nbond,dimen,MAXRES6,MAXRES2,Gbmat)
93 Cmat(i,j)=Cmat(i,j)+Bmat(k,i)*GBmat(k,j)
98 write (iout,*) "Matrix Cmat"
99 call MATOUT(nbond,nbond,MAXRES2,MAXRES2,Cmat)
101 call matinvert(nbond,MAXRES2,Cmat,Cinv)
103 write (iout,*) "Matrix Cinv"
104 call MATOUT(nbond,nbond,MAXRES2,MAXRES2,Cinv)
110 Tmat(i,j)=Tmat(i,j)+GBmat(i,k)*Cinv(k,j)
115 write (iout,*) "Matrix Tmat"
116 call MATOUT(nbond,dimen,MAXRES6,MAXRES2,Tmat)
126 Pmat(i,j)=Pmat(i,j)-Tmat(i,k)*Bmat(j,k)
131 write (iout,*) "Matrix Pmat"
132 call MATOUT(dimen,dimen,MAXRES6,MAXRES6,Pmat)
139 Td(i)=Td(i)+vbl*Tmat(i,ind)
142 if (itype(k).ne.10) then
144 Td(i)=Td(i)+vbldsc0(1,itype(k))*Tmat(i,ind)
149 write (iout,*) "Vector Td"
151 write (iout,'(i5,f10.5)') i,Td(i)
154 call stochastic_force(stochforcvec)
156 write (iout,*) "stochforcvec"
158 write (iout,*) i,stochforcvec(i)
162 zapas(j)=-gcart(j,0)+stochforcvec(j)
164 dC_work(j)=dC_old(j,0)
170 zapas(ind)=-gcart(j,i)+stochforcvec(ind)
171 dC_work(ind)=dC_old(j,i)
175 if (itype(i).ne.10) then
178 zapas(ind)=-gxcart(j,i)+stochforcvec(ind)
179 dC_work(ind)=dC_old(j,i+nres)
185 write (iout,*) "Initial d_t_work"
187 write (iout,*) i,d_t_work(i)
194 d_t_work(i)=d_t_work(i)+fricmat(i,j)*zapas(j)
201 zapas(i)=zapas(i)+Pmat(i,j)*(dC_work(j)+d_t_work(j)*d_time)
205 write (iout,*) "Final d_t_work and zapas"
207 write (iout,*) i,d_t_work(i),zapas(i)
221 dc_work(ind+j)=dc(j,i)
227 d_t(j,i+nres)=d_t_work(ind+j)
228 dc(j,i+nres)=zapas(ind+j)
229 dc_work(ind+j)=dc(j,i+nres)
235 write (iout,*) "Before correction for rotational lengthening"
236 write (iout,*) "New coordinates",
237 & " and differences between actual and standard bond lengths"
242 write (iout,'(i5,3f10.5,5x,f10.5,e15.5)')
243 & i,(dC(j,i),j=1,3),xx
246 if (itype(i).ne.10) then
248 xx=vbld(i+nres)-vbldsc0(1,itype(i))
249 write (iout,'(i5,3f10.5,5x,f10.5,e15.5)')
250 & i,(dC(j,i+nres),j=1,3),xx
254 c Second correction (rotational lengthening)
260 blen2 = scalar(dc(1,i),dc(1,i))
261 ppvec(ind)=2*vbl**2-blen2
262 diffbond=dabs(vbl-dsqrt(blen2))
263 if (diffbond.gt.diffmax) diffmax=diffbond
264 if (ppvec(ind).gt.0.0d0) then
265 ppvec(ind)=dsqrt(ppvec(ind))
270 write (iout,'(i5,3f10.5)') ind,diffbond,ppvec(ind)
274 if (itype(i).ne.10) then
276 blen2 = scalar(dc(1,i+nres),dc(1,i+nres))
277 ppvec(ind)=2*vbldsc0(1,itype(i))**2-blen2
278 diffbond=dabs(vbldsc0(1,itype(i))-dsqrt(blen2))
279 if (diffbond.gt.diffmax) diffmax=diffbond
280 if (ppvec(ind).gt.0.0d0) then
281 ppvec(ind)=dsqrt(ppvec(ind))
286 write (iout,'(i5,3f10.5)') ind,diffbond,ppvec(ind)
290 if (lprn) write (iout,*) "iter",iter," diffmax",diffmax
291 if (diffmax.lt.difftol) goto 10
295 Td(i)=Td(i)+ppvec(j)*Tmat(i,j)
301 zapas(i)=zapas(i)+Pmat(i,j)*dc_work(j)
312 dc_work(ind+j)=zapas(ind+j)
317 if (itype(i).ne.10) then
319 dc(j,i+nres)=zapas(ind+j)
320 dc_work(ind+j)=zapas(ind+j)
325 c Building the chain from the newly calculated coordinates
328 if (large.and. mod(itime,ntwe).eq.0) then
329 write (iout,*) "Cartesian and internal coordinates: step 1"
332 write (iout,'(a)') "Potential forces"
334 write (iout,'(i3,3f10.5,3x,3f10.5)') i,(-gcart(j,i),j=1,3),
335 & (-gxcart(j,i),j=1,3)
337 write (iout,'(a)') "Stochastic forces"
339 write (iout,'(i3,3f10.5,3x,3f10.5)') i,(stochforc(j,i),j=1,3),
340 & (stochforc(j,i+nres),j=1,3)
342 write (iout,'(a)') "Velocities"
344 write (iout,'(i3,3f10.5,3x,3f10.5)') i,(d_t(j,i),j=1,3),
345 & (d_t(j,i+nres),j=1,3)
350 write (iout,*) "After correction for rotational lengthening"
351 write (iout,*) "New coordinates",
352 & " and differences between actual and standard bond lengths"
357 write (iout,'(i5,3f10.5,5x,f10.5,e15.5)')
358 & i,(dC(j,i),j=1,3),xx
361 if (itype(i).ne.10) then
363 xx=vbld(i+nres)-vbldsc0(1,itype(i))
364 write (iout,'(i5,3f10.5,5x,f10.5,e15.5)')
365 & i,(dC(j,i+nres),j=1,3),xx
370 c write (iout,*) "Too many attempts at correcting the bonds"
378 c Calculate energy and forces
380 call etotal(potEcomp)
381 potE=potEcomp(0)-potEcomp(20)
384 c Calculate the kinetic and total energy and the kinetic temperature
387 t_enegrad=t_enegrad+MPI_Wtime()-tt0
389 t_enegrad=t_enegrad+tcpu()-tt0
392 kinetic_T=2.0d0/(dimen*Rb)*EK