source: mulcan_sim.f@ e40e335

Last change on this file since e40e335 was e40e335, checked in by baerbaer <baerbaer@…>, 16 years ago

Initial import to BerliOS corresponding to 3.0.4

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/smmp/trunk@1 26dc1dd8-5c4e-0410-9ffe-d298b4865968

  • Property mode set to 100644
File size: 5.3 KB
Line 
1c **************************************************************
2c
3c This file contains the subroutines: mulcan_sim,muca_weight2
4c
5c Copyright 2003-2005 Frank Eisenmenger, U.H.E. Hansmann,
6c Shura Hayryan, Chin-Ku
7c Copyright 2007 Frank Eisenmenger, U.H.E. Hansmann,
8c Jan H. Meinke, Sandipan Mohanty
9c
10c **************************************************************
11
12 subroutine mulcan_sim
13C
14C PURPOSE: PERFORM A MULTICANONICAL SIMULATION
15C REQUIRES AS INPUT THE MULTICANONICAL PARAMETER AS CALCULATED
16C BY THE SUBROUTINE mulcan_par
17C
18c CALLS: addang, contacts,energy,metropolis
19c
20 include 'INCL.H'
21
22c external rand
23 external muca_weight2
24
25 logical restart
26
27 parameter(restart=.false.)
28 parameter(kmin=-12,kmax=20,ebin=1.0d0)
29 parameter(nsweep=100000,nequi=100)
30 Parameter(nsave=1000,nmes=10)
31C
32C restart: .true. = restart of simulation
33C .false. = start of simulation with random configuration
34C kmin,kmax: Range of multicanonical parameter
35C ebin: bin size for multicanonical parameter
36C nequi: Number of sweeps for equilibrisation
37C nsweep: Number of sweeps for simulation run
38C nsave: Number of sweeps after which actual configuration is saved
39C for re-starts
40C nmes: Number of sweeps between measurments
41C
42
43 dimension xhist(kmin:kmax),ihist(kmin:kmax)
44 common/muca2/b(kmin:kmax),alpha(kmin:kmax)
45
46
47C FILE with last conformation (for re-starts)
48 open(8,file='EXAMPLES/start.d')
49C File with contact map of reference configuration
50 open(9,file='EXAMPLES/enkefa.ref')
51C File with multicanonical parameter
52 open(10,file='EXAMPLES/muca.d')
53C Result file: Time series of certain quantities
54 open(11, file='EXAMPLES/time.d')
55
56
57 do j=kmin,kmax
58 ihist(j)= 0
59 end do
60
61 nresi=irsml2(1)-irsml1(1) + 1
62c nresi: Number of residues
63
64C READ REFERENCE CONTACT MAP
65 nci = 0
66 do i=1,nresi
67 read(9,*) (iref(i,j) , j=1,nresi)
68 end do
69 do i=1,nresi
70 do j=nresi,i+3,-1
71 if(iref(i,j).eq.1) nci = nci + 1
72 end do
73 end do
74 write(*,*) 'Number of contacts in reference conformation:',nci
75
76C READ IN FIELDS WITH MULTICANONICAL PARAMETER
77 Do j=kmin,kmax
78 read(10,*) i,b(i),alpha(i)
79 end do
80C
81
82 if(restart) then
83 read(8,*) nswm, eol_old
84 read(8,*) (xhist(j), j=kmin,kmax)
85 do i=1,nvr
86 read(8,*) j, x
87 iv = idvr(j)
88 vlvr(iv) = x
89 end do
90 write(*,*) 'Last iteration, energy:',nswm,eol_old
91 else
92c _________________________________ random start
93 do i=1,nvr
94 iv=idvr(i) ! provides index of non-fixed variable
95 dv=axvr(iv)*(grnd()-0.5)
96 vr=addang(pi,dv)
97 vlvr(iv)=vr
98 enddo
99 end if
100c
101 eol = energy()
102 write (*,'(e12.5,/)') eol
103 call contacts(nhy,nhx,dham)
104 write(*,*) 'Number of contacts in start configuration:',nhy
105 write(*,*) 'Number of native contacts in start configuration:',
106 & nhx
107 do i=1,nresi
108 write(*,'(62I1)') (ijcont(i,j), j=1,nresi)
109 end do
110 write(*,*)
111C
112
113
114 if(.not.restart) then
115c =====================Equilibrization by Metropolis
116 do nsw=1,nequi
117 call metropolis(eol,acz,muca_weight2)
118 end do
119 do i=kmin,kmax
120 ihist(i) = 0
121 end do
122 nswm = 1
123 end if
124
125C======================Simulation
126 acz = 0.0d0
127C LOOP OVER SWEEPS
128 do nsw=nswm,nsweep
129C
130C METROPOLIS UPDATE
131 call metropolis(eol,acz,muca_weight2)
132 muold = min(kmax,max(kmin,int(eol/ebin+sign(0.5d0,eol))))
133 ihist(muold) = ihist(muold) + 1
134C
135C SAVE ACTUAL CONFORMATIONS FOR RE-STARTS:
136 if(mod(nsw,nsave).eq.0) then
137 rewind 8
138 write(8,*) nswm, eol
139 write(8,*) (xhist(j), j=kmin,kmax)
140 do i=1,nvr
141 iv = idvr(i)
142 write(8,*) i,vlvr(iv)
143 end do
144 end if
145C Measurements after NMES sweeps
146 if(mod(nsw,nmes).eq.0) then
147C Take a histogram of energy
148 do i=kmin,kmax
149 xhist(i) = xhist(i) + ihist(i)
150 ihist(i) = 0
151 end do
152c Calculate contacts in actual configuartion and compare with reference
153C configuration
154c call contacts(nhx,nhy,dham)
155C nhx : Number of contcats in actual conformation
156C nhy : Number of contacts which are identical in actual and reference
157C configuration
158C dham: Hamming distance between actual and reference configuration
159C
160 write(11,'(i7,f12.2,2i8,f12.4)') nsw,eol,nhx,nhy,dham
161 end if
162 end do
163C END OF SIMULATION
164
165C FINAL OUTPUT:
166 acz = acz/dble(nsw*nvr)
167 write(*,*) 'last energy',eol
168 write(*,*) 'aczeptance rate:',acz
169
170C WRITE DOWN (UN-REWEIGHTED) HISTOGRAM OF MULTICANONICAL SIMULATION
171 do i=kmin,kmax
172 if(xhist(i).gt.0.0d0) then
173 write(*,*) i,xhist(i)
174 end if
175 end do
176c =====================
177 close(8)
178 close(9)
179 close(10)
180 close(11)
181
182 return
183 end
184
185c ************************************************************
186 real*8 function muca_weight2(x)
187
188 implicit real*8 (a-h,o-z)
189 implicit integer*4 (i-n)
190
191 Parameter(kmin=-12,kmax=20,ebin=1.0d0)
192
193 common/muca2/b(kmin:kmax),alpha(kmin:kmax)
194
195 muold = min(kmax,max(kmin,int(x/ebin+sign(0.5d0,x))))
196 muca_weight2 = b(muold)*x + alpha(muold)
197
198 return
199
200 end
201
202
Note: See TracBrowser for help on using the repository browser.