-
Notifications
You must be signed in to change notification settings - Fork 4
/
mfmcg.py
42 lines (38 loc) · 922 Bytes
/
mfmcg.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from os import mkdir, getcwd
from cPickle import dump
from math import log10
from hamiltonian import ham
from metropolis import metropolis
from mfiter import RT
from datrendering import datname
cutoff=0.0032
h = ham(width=4,length=5,boundary='o',holes=[11])
ncir = 110
T = 100.0
lcir = int(log10(ncir)) + 1
dpath = 'data/'
ddir = dpath + datname(T,h.g) + '/'
print 'data stored in', ddir
try:
mkdir(dpath)
except:
print dpath,'exist'
try:
mkdir(ddir)
except:
raise OSError('Directory ' + ddir + ' exists.')
mt = metropolis(h,T=T*RT,cutoff=cutoff)
for i in xrange(ncir):
df = open(ddir + 'c' + str(i).zfill(lcir) + '.dat', 'w')
d, n, en, a = mt.next()
dump((i,d,n,en,a), df, -1)
print ''
print '*****************'
print ' Cycle %s ' % (i)
print '*****************'
print ''
print 'Acceptance rate:', a
print ''
print 'Average energies:', en
print ''
df.close()