2 !-----------------------------------------------------------------------------
6 use geometry_data, only:nres
8 !-----------------------------------------------------------------------------
10 !-----------------------------------------------------------------------------
12 !-----------------------------------------------------------------------------
13 subroutine muca_delta(remd_t_bath,remd_ene,i,iex,delta)
16 ! implicit real*8 (a-h,o-z)
17 ! include 'DIMENSIONS'
18 ! include 'COMMON.MUCA'
21 real(kind=8),dimension(nprocs) :: remd_t_bath !(maxprocs)
22 real(kind=8),dimension(nprocs) :: remd_ene !(maxprocs)
23 ! real(kind=8) :: muca_ene
24 real(kind=8) :: betai,betaiex,delta
26 betai=1.0/(Rb*remd_t_bath(i))
27 betaiex=1.0/(Rb*remd_t_bath(iex))
29 delta=betai*(muca_ene(remd_ene(iex),i,remd_t_bath)- &
30 muca_ene(remd_ene(i),i,remd_t_bath)) &
31 -betaiex*(muca_ene(remd_ene(iex),iex,remd_t_bath)- &
32 muca_ene(remd_ene(i),iex,remd_t_bath))
35 end subroutine muca_delta
36 !-----------------------------------------------------------------------------
37 real(kind=8) function muca_ene(energy,i,remd_t_bath)
40 ! implicit real*8 (a-h,o-z)
41 ! include 'DIMENSIONS'
42 ! include 'COMMON.MUCA'
44 real(kind=8) :: y,yp,energy
45 real(kind=8),dimension(nprocs) :: remd_t_bath !(maxprocs)
48 if (energy.lt.elowi(i)) then
49 call splint(emuca,nemuca,nemuca2,nmuca,elowi(i),y,yp)
50 muca_ene=remd_t_bath(i)*Rb*(yp*(energy-elowi(i))+y)
51 elseif (energy.gt.ehighi(i)) then
52 call splint(emuca,nemuca,nemuca2,nmuca,ehighi(i),y,yp)
53 muca_ene=remd_t_bath(i)*Rb*(yp*(energy-ehighi(i))+y)
55 call splint(emuca,nemuca,nemuca2,nmuca,energy,y,yp)
56 muca_ene=remd_t_bath(i)*Rb*y
60 !-----------------------------------------------------------------------------
61 subroutine muca_update(energy)
66 ! implicit real*8 (a-h,o-z)
67 ! include 'DIMENSIONS'
68 ! include 'COMMON.MUCA'
69 ! include 'COMMON.CONTROL'
71 ! include 'COMMON.REMD'
72 ! include 'COMMON.SETUP'
73 ! include 'COMMON.IOUNITS'
74 real(kind=8) :: energy
75 real(kind=8) :: yp1,ypn
76 integer :: k,i,ismooth,ist,ien,j
79 k=int((energy-emuca(1))/hbin)+1
81 IF(muca_smooth.eq.1.or.muca_smooth.eq.3) THEN
83 write (iout,*) 'MUCA reject',energy,emuca(k)
84 if(energy.ge.ehigh.and.(energy-ehigh).lt.hbin) then
85 write (iout,*) 'MUCA ehigh',energy,emuca(k)
90 if(k.gt.0.and.energy.lt.ehigh) hist(k)=hist(k)+1
92 if(k.gt.0.and.k.lt.4*nres) hist(k)=hist(k)+1
94 if(mod(imtime,mucadyn).eq.0) then
97 IF(muca_smooth.eq.2.or.muca_smooth.eq.3) THEN
98 nemuca(i)=nemuca(i)+dlog(hist(i)+1)
100 if (hist(i).gt.0) hist(i)=dlog(hist(i))
101 nemuca(i)=nemuca(i)+hist(i)
104 write(iout,'(a24,i8,2f12.5)')'nemuca before smoothing ',&
105 imtime,emuca(i),nemuca(i)
113 IF(muca_smooth.eq.1.or.muca_smooth.eq.3) THEN
117 ! if(nemuca(j).lt.nemuca(i)) lnotend=.true.
122 write (iout,*) 'MUCA update smoothing',ist,ien
124 nemuca(i)=(nemuca(i-1)+nemuca(i)+nemuca(i+1))/3
131 if(nemuca(j).lt.nemuca(i)) then
134 if(ien.lt.j+1) ien=j+1
141 write (iout,*) 'MUCA update ',imtime,' smooth= ',ismooth
144 call spline(emuca,nemuca,nmuca,yp1,ypn,nemuca2)
149 end subroutine muca_update
150 !-----------------------------------------------------------------------------
151 real(kind=8) function muca_factor(energy)
153 ! implicit real*8 (a-h,o-z)
154 ! include 'DIMENSIONS'
155 ! include 'COMMON.MUCA'
156 real(kind=8) :: y,yp,energy
158 if (energy.lt.elow) then
159 call splint(emuca,nemuca,nemuca2,nmuca,elow,y,yp)
160 elseif (energy.gt.ehigh) then
161 call splint(emuca,nemuca,nemuca2,nmuca,ehigh,y,yp)
163 call splint(emuca,nemuca,nemuca2,nmuca,energy,y,yp)
166 if(yp.ge.factor_min) then
169 muca_factor=factor_min
171 !d print *,'energy, muca_factor',energy,muca_factor
173 end function muca_factor
174 !-----------------------------------------------------------------------------
175 subroutine spline(x,y,n,yp1,ypn,y2)
178 REAL(kind=8) :: yp1,ypn,x(n),y(n),y2(n)
179 integer,PARAMETER :: NMAX=500
181 REAL(kind=8) :: p,qn,sig,un,u(NMAX)
182 if (yp1.gt..99e30) then
187 u(1)=(3./(x(2)-x(1)))*((y(2)-y(1))/(x(2)-x(1))-yp1)
190 sig=(x(i)-x(i-1))/(x(i+1)-x(i-1))
193 u(i)=(6.*((y(i+1)-y(i))/(x(i+1)-x(i))-(y(i)-y(i-1)) &
194 /(x(i)-x(i-1)))/(x(i+1)-x(i-1))-sig*u(i-1))/p
196 if (ypn.gt..99e30) then
201 un=(3./(x(n)-x(n-1)))*(ypn-(y(n)-y(n-1))/(x(n)-x(n-1)))
203 y2(n)=(un-qn*u(n-1))/(qn*y2(n-1)+1.)
205 y2(k)=y2(k)*y2(k+1)+u(k)
208 end subroutine spline
209 !-----------------------------------------------------------------------------
210 subroutine splint(xa,ya,y2a,n,x,y,yp)
213 REAL(kind=8) :: x,y,xa(n),y2a(n),ya(n),yp
215 REAL(kind=8) :: a,b,h
218 1 if (khi-klo.gt.1) then
228 if (h.eq.0.) pause 'bad xa input in splint'
231 y=a*ya(klo)+b*ya(khi)+ &
232 ((a**3-a)*y2a(klo)+(b**3-b)*y2a(khi))*(h**2)/6.
233 yp=-ya(klo)/h+ya(khi)/h-3*(a**2)*y2a(klo)*h/6. &
234 +(3*(b**2)-1)*y2a(khi)*h/6.
236 end subroutine splint
237 !-----------------------------------------------------------------------------
239 !-----------------------------------------------------------------------------
242 use control_data, only: modecalc,maxprocs
246 ! implicit real*8 (a-h,o-z)
247 ! include 'DIMENSIONS'
248 ! include 'COMMON.MUCA'
249 ! include 'COMMON.CONTROL'
250 ! include 'COMMON.MD'
251 ! include 'COMMON.REMD'
252 ! include 'COMMON.SETUP'
253 ! include 'COMMON.IOUNITS'
254 real(kind=8) :: yp1,ypn,yp,x,y,muca_ene !,muca_factor
256 real(kind=8) :: emuca_alloc(4*maxres),nemuca_alloc(4*maxres)
257 integer(kind=2) :: i2rep_alloc(0:maxprocs)
259 ! real(kind=8) :: var,ene
262 allocate(hist(4*maxres)) !(4*maxres)
263 !el allocate(i2rep(0:nodes+1)) !(0:maxprocs)
267 if (modecalc.eq.14.and..not.remd_tlist) then
268 print *,"MUCAREMD works only with TLIST"
271 open(89,file='muca.input')
274 if (modecalc.eq.14) then
275 allocate(elowi(nrep),ehighi(nrep)) !(maxprocs)
276 read(89,*) (elowi(i),ehighi(i),i=1,nrep)
286 allocate(i2rep(k)) !(0:maxprocs)
288 i2rep(j)=i2rep_alloc(j)
290 elow=elowi(i2rep(me))
291 ehigh=ehighi(i2rep(me))
299 read(89,*) elow,ehigh
306 read(89,*,end=100) emuca_alloc(i),nemuca_alloc(i)
307 !d nemuca(i)=nemuca(i)*remd_t(me+1)*Rb
309 allocate(emuca(i),nemuca(i),nemuca2(i)) !4*maxres
311 emuca(j)=emuca_alloc(j)
312 nemuca(j)=nemuca_alloc(j)
316 hbin=emuca(nmuca)-emuca(nmuca-1)
317 write (iout,*) 'hbin',hbin
318 write (iout,*) me,'elow,ehigh',elow,ehigh
321 call spline(emuca,nemuca,nmuca,yp1,ypn,nemuca2)
323 factor_min=muca_factor(ehigh)
326 end subroutine read_muca
327 !-----------------------------------------------------------------------------
328 subroutine print_muca
330 use control_data, only: modecalc,mucadyn,maxprocs
334 ! implicit real*8 (a-h,o-z)
335 ! include 'DIMENSIONS'
336 ! include 'COMMON.MUCA'
337 ! include 'COMMON.CONTROL'
338 ! include 'COMMON.MD'
339 ! include 'COMMON.REMD'
340 ! include 'COMMON.SETUP'
341 ! include 'COMMON.IOUNITS'
342 real(kind=8) :: yp1,ypn,yp,x,y !,muca_ene,muca_factor
343 real(kind=8) :: dummy(maxprocs)
358 ! print *,'nemuca ',emuca(i),nemuca(i)
361 if (modecalc.eq.14) then
363 yp=muca_factor(x)*remd_t(i2rep(me))*Rb
364 dummy(me+1)=remd_t(i2rep(me))
365 y=muca_ene(x,me+1,dummy)
367 yp=muca_factor(x)*remd_t(me+1)*Rb
368 y=muca_ene(x,me+1,remd_t)
370 write (iout,'(i4,i12,a12,2f15.5,a10,f15.5)') me,imtime,&
371 'muca factor ',x,yp,' muca ene',y
373 yp=muca_factor(x)*t_bath*Rb
375 y=muca_ene(x,1,dummy)
376 write (iout,'(i4,i12,a12,2f15.5,a10,f15.5)') me,imtime,&
377 'muca factor ',x,yp,' muca ene',y
381 if(mucadyn.gt.0) then
383 write(iout,'(a13,i8,2f12.5)') 'nemuca after ',&
384 imtime,emuca(i),nemuca(i)
388 end subroutine print_muca
389 !-----------------------------------------------------------------------------
390 !-----------------------------------------------------------------------------