1 subroutine friction_force
2 implicit real*8 (a-h,o-z)
9 include 'COMMON.INTERACT'
11 include 'COMMON.LAGRANGE'
13 include 'COMMON.LANGEVIN'
15 include 'COMMON.LANGEVIN.lang0'
17 include 'COMMON.IOUNITS'
18 double precision gamvec(MAXRES6)
20 double precision vv(3),vvtot(3,maxres),v_work(MAXRES6),
21 & ginvfric(maxres2,maxres2)
22 common /przechowalnia/ ginvfric
24 logical lprn /.false./, checkmode /.false./
38 d_t_work(ind+j)=d_t(j,i)
43 if ((itype(i).ne.10).and.(itype(i).ne.ntyp1)) then
45 d_t_work(ind+j)=d_t(j,i+nres)
51 call fricmat_mult(d_t_work,fric_work)
53 if (.not.checkmode) return
56 write (iout,*) "d_t_work and fric_work"
58 write (iout,'(i3,2e15.5)') i,d_t_work(i),fric_work(i)
62 friction(j,0)=fric_work(j)
67 friction(j,i)=fric_work(ind+j)
72 if ((itype(i).ne.10).and.(itype(i).ne.ntyp1)) then
74 friction(j,i+nres)=fric_work(ind+j)
80 write(iout,*) "Friction backbone"
82 write(iout,'(i5,3e15.5,5x,3e15.5)')
83 & i,(friction(j,i),j=1,3),(d_t(j,i),j=1,3)
85 write(iout,*) "Friction side chain"
87 write(iout,'(i5,3e15.5,5x,3e15.5)')
88 & i,(friction(j,i+nres),j=1,3),(d_t(j,i+nres),j=1,3)
97 vvtot(j,i)=vv(j)+0.5d0*d_t(j,i)
98 vvtot(j,i+nres)=vv(j)+d_t(j,i+nres)
102 write (iout,*) "vvtot backbone and sidechain"
104 write (iout,'(i5,3e15.5,5x,3e15.5)') i,(vvtot(j,i),j=1,3),
105 & (vvtot(j,i+nres),j=1,3)
110 v_work(ind+j)=vvtot(j,i)
116 v_work(ind+j)=vvtot(j,i+nres)
120 write (iout,*) "v_work gamvec and site-based friction forces"
122 write (iout,'(i5,3e15.5)') i,v_work(i),gamvec(i),
123 & gamvec(i)*v_work(i)
126 c fric_work1(i)=0.0d0
128 c fric_work1(i)=fric_work1(i)-A(j,i)*gamvec(j)*v_work(j)
131 c write (iout,*) "fric_work and fric_work1"
133 c write (iout,'(i5,2e15.5)') i,fric_work(i),fric_work1(i)
139 ginvfric(i,j)=ginvfric(i,j)+ginv(i,k)*fricmat(k,j)
143 write (iout,*) "ginvfric"
145 write (iout,'(i5,100f8.3)') i,(ginvfric(i,j),j=1,dimen)
147 write (iout,*) "symmetry check"
150 write (iout,*) i,j,ginvfric(i,j)-ginvfric(j,i)
156 c-----------------------------------------------------
157 subroutine stochastic_force(stochforcvec)
158 implicit real*8 (a-h,o-z)
164 include 'COMMON.CHAIN'
165 include 'COMMON.DERIV'
167 include 'COMMON.LOCAL'
168 include 'COMMON.INTERACT'
170 include 'COMMON.TIME1'
172 include 'COMMON.LANGEVIN'
174 include 'COMMON.LANGEVIN.lang0'
176 include 'COMMON.IOUNITS'
178 double precision x,sig,lowb,highb,
179 & ff(3),force(3,0:MAXRES2),zeta2,lowb2,
180 & highb2,sig2,forcvec(MAXRES6),stochforcvec(MAXRES6)
181 logical lprn /.false./
194 c Compute the stochastic forces acting on bodies. Store in force.
200 force(j,i)=anorm_distr(x,sig,lowb,highb)
208 force(j,i+nres)=anorm_distr(x,sig2,lowb2,highb2)
212 time_fsample=time_fsample+MPI_Wtime()-time00
214 time_fsample=time_fsample+tcpu()-time00
216 c Compute the stochastic forces acting on virtual-bond vectors.
222 stochforc(j,i)=ff(j)+0.5d0*force(j,i)
225 ff(j)=ff(j)+force(j,i)
227 if (itype(i+1).ne.ntyp1) then
229 stochforc(j,i)=stochforc(j,i)+force(j,i+nres+1)
230 ff(j)=ff(j)+force(j,i+nres+1)
235 stochforc(j,0)=ff(j)+force(j,nnt+nres)
238 if ((itype(i).ne.10).and.(itype(i).ne.ntyp1)) then
240 stochforc(j,i+nres)=force(j,i+nres)
246 stochforcvec(j)=stochforc(j,0)
251 stochforcvec(ind+j)=stochforc(j,i)
256 if ((itype(i).ne.10).and.(itype(i).ne.ntyp1)) then
258 stochforcvec(ind+j)=stochforc(j,i+nres)
264 write (iout,*) "stochforcvec"
266 write(iout,'(i5,e15.5)') i,stochforcvec(i)
268 write(iout,*) "Stochastic forces backbone"
270 write(iout,'(i5,3e15.5)') i,(stochforc(j,i),j=1,3)
272 write(iout,*) "Stochastic forces side chain"
274 write(iout,'(i5,3e15.5)')
275 & i,(stochforc(j,i+nres),j=1,3)
285 forcvec(ind+j)=force(j,i)
292 forcvec(j+ind)=force(j,i+nres)
297 write (iout,*) "forcvec"
301 write (iout,'(2i3,2f10.5)') i,j,force(j,i),
308 write (iout,'(2i3,2f10.5)') i,j,force(j,i+nres),
318 c------------------------------------------------------------------
319 subroutine setup_fricmat
320 implicit real*8 (a-h,o-z)
326 include 'COMMON.CHAIN'
327 include 'COMMON.DERIV'
329 include 'COMMON.LOCAL'
330 include 'COMMON.INTERACT'
332 include 'COMMON.LAGRANGE'
333 include 'COMMON.SETUP'
334 include 'COMMON.TIME1'
335 c integer licznik /0/
338 include 'COMMON.LANGEVIN'
340 include 'COMMON.LANGEVIN.lang0'
342 include 'COMMON.IOUNITS'
344 integer i,j,ind,ind1,m
345 logical lprn /.false./
346 double precision dtdi,gamvec(MAXRES2),
347 & ginvfric(maxres2,maxres2),Ghalf(mmaxres2),fcopy(maxres2,maxres2)
348 common /syfek/ gamvec
349 double precision work(8*maxres2)
350 integer iwork(maxres2)
351 common /przechowalnia/ ginvfric,Ghalf,fcopy
353 if (fg_rank.ne.king) goto 10
355 c Zeroing out fricmat
361 c Load the friction coefficients corresponding to peptide groups
367 c Load the friction coefficients corresponding to side chains
375 gamvec(ii)=gamsc(iabs(iti))
377 if (surfarea) call sdarea(gamvec)
379 c write (iout,*) "Matrix A and vector gamma"
381 c write (iout,'(i2,$)') i
383 c write (iout,'(f4.1,$)') A(i,j)
385 c write (iout,'(f8.3)') gamvec(i)
389 write (iout,*) "Vector gamvec"
391 write (iout,'(i5,f10.5)') i, gamvec(i)
395 c The friction matrix
400 dtdi=dtdi+A(j,k)*A(j,i)*gamvec(j)
407 write (iout,'(//a)') "Matrix fricmat"
408 call matout2(dimen,dimen,maxres2,maxres2,fricmat)
410 if (lang.eq.2 .or. lang.eq.3) then
411 c Mass-scale the friction matrix if non-direct integration will be performed
417 Ginvfric(i,j)=Ginvfric(i,j)+
418 & Gsqrm(i,k)*Gsqrm(l,j)*fricmat(k,l)
423 c Diagonalize the friction matrix
428 Ghalf(ind)=Ginvfric(i,j)
431 call gldiag(maxres2,dimen,dimen,Ghalf,work,fricgam,fricvec,
434 write (iout,'(//2a)') "Eigenvectors and eigenvalues of the",
435 & " mass-scaled friction matrix"
436 call eigout(dimen,dimen,maxres2,maxres2,fricvec,fricgam)
438 c Precompute matrices for tinker stochastic integrator
445 mt1(i,j)=mt1(i,j)+fricvec(k,i)*gsqrm(k,j)
446 mt2(i,j)=mt2(i,j)+fricvec(k,i)*gsqrp(k,j)
452 else if (lang.eq.4) then
453 c Diagonalize the friction matrix
458 Ghalf(ind)=fricmat(i,j)
461 call gldiag(maxres2,dimen,dimen,Ghalf,work,fricgam,fricvec,
464 write (iout,'(//2a)') "Eigenvectors and eigenvalues of the",
466 call eigout(dimen,dimen,maxres2,maxres2,fricvec,fricgam)
468 c Determine the number of zero eigenvalues of the friction matrix
469 nzero=max0(dimen-dimen1,0)
470 c do while (fricgam(nzero+1).le.1.0d-5 .and. nzero.lt.dimen)
473 write (iout,*) "Number of zero eigenvalues:",nzero
478 fricmat(i,j)=fricmat(i,j)
479 & +fricvec(i,k)*fricvec(j,k)/fricgam(k)
484 write (iout,'(//a)') "Generalized inverse of fricmat"
485 call matout(dimen,dimen,maxres6,maxres6,fricmat)
490 if (nfgtasks.gt.1) then
491 if (fg_rank.eq.0) then
492 c The matching BROADCAST for fg processors is called in ERGASTULUM
498 call MPI_Bcast(10,1,MPI_INTEGER,king,FG_COMM,IERROR)
500 time_Bcast=time_Bcast+MPI_Wtime()-time00
502 time_Bcast=time_Bcast+tcpu()-time00
504 c print *,"Processor",myrank,
505 c & " BROADCAST iorder in SETUP_FRICMAT"
508 c write (iout,*) "setup_fricmat licznik",licznik
514 c Scatter the friction matrix
515 call MPI_Scatterv(fricmat(1,1),nginv_counts(0),
516 & nginv_start(0),MPI_DOUBLE_PRECISION,fcopy(1,1),
517 & myginv_ng_count,MPI_DOUBLE_PRECISION,king,FG_COMM,IERROR)
520 time_scatter=time_scatter+MPI_Wtime()-time00
521 time_scatter_fmat=time_scatter_fmat+MPI_Wtime()-time00
523 time_scatter=time_scatter+tcpu()-time00
524 time_scatter_fmat=time_scatter_fmat+tcpu()-time00
529 fricmat(j,i)=fcopy(i,j)
532 c write (iout,*) "My chunk of fricmat"
533 c call MATOUT2(my_ng_count,dimen,maxres2,maxres2,fcopy)
538 c-------------------------------------------------------------------------------
539 subroutine sdarea(gamvec)
541 c Scale the friction coefficients according to solvent accessible surface areas
542 c Code adapted from TINKER
545 implicit real*8 (a-h,o-z)
547 include 'COMMON.CONTROL'
551 include 'COMMON.LANGEVIN'
553 include 'COMMON.LANGEVIN.lang0'
555 include 'COMMON.CHAIN'
556 include 'COMMON.DERIV'
558 include 'COMMON.LOCAL'
559 include 'COMMON.INTERACT'
560 include 'COMMON.IOUNITS'
561 include 'COMMON.NAMES'
562 double precision radius(maxres2),gamvec(maxres2)
563 parameter (twosix=1.122462048309372981d0)
564 logical lprn /.false./
566 c determine new friction coefficients every few SD steps
568 c set the atomic radii to estimates of sigma values
570 c print *,"Entered sdarea"
576 c Load peptide group radii
580 c Load side chain radii
583 radius(i+nres)=restok(iti)
586 c write (iout,*) "i",i," radius",radius(i)
589 radius(i) = radius(i) / twosix
590 if (radius(i) .ne. 0.0d0) radius(i) = radius(i) + probe
593 c scale atomic friction coefficients by accessible area
595 if (lprn) write (iout,*)
596 & "Original gammas, surface areas, scaling factors, new gammas, ",
597 & "std's of stochastic forces"
600 if (radius(i).gt.0.0d0) then
601 call surfatom (i,area,radius)
602 ratio = dmax1(area/(4.0d0*pi*radius(i)**2),1.0d-1)
603 if (lprn) write (iout,'(i5,3f10.5,$)')
604 & i,gamvec(ind+1),area,ratio
607 gamvec(ind) = ratio * gamvec(ind)
609 stdforcp(i)=stdfp*dsqrt(gamvec(ind))
610 if (lprn) write (iout,'(2f10.5)') gamvec(ind),stdforcp(i)
614 if (radius(i+nres).gt.0.0d0) then
615 call surfatom (i+nres,area,radius)
616 ratio = dmax1(area/(4.0d0*pi*radius(i+nres)**2),1.0d-1)
617 if (lprn) write (iout,'(i5,3f10.5,$)')
618 & i,gamvec(ind+1),area,ratio
621 gamvec(ind) = ratio * gamvec(ind)
623 if (itype(i).ne.ntyp1)
624 & stdforcsc(i)=stdfsc(itype(i))*dsqrt(gamvec(ind))
625 if (lprn) write (iout,'(2f10.5)') gamvec(ind),stdforcsc(i)