예제 #1
0
if 'noshow' in sys.argv:
    matplotlib.use('Agg')
import matplotlib.pyplot as plt

if os.path.exists('../data'):
    os.chdir('..')

moviedir = sys.argv[1]
frames = eval(sys.argv[2])  # a list of integers

Ss = []
labels = []

for f in frames:
    print f
    e, lndos = readnew.e_lndos('%s/%06d-lnw.dat' % (moviedir, f))
    its = readnew.iterations('%s/%06d-lnw.dat' % (moviedir, f))
    lndos = -lndos
    Smin = lndos[lndos > lndos[0]].min()
    lndos -= Smin
    if len(Ss) > 0:
        Ss.append(lndos - lastdos)
    else:
        Ss = [lndos]
    lastdos = lndos * 1
    labels.append('%d iterations' % its)

#    plt.stackplot(e[lndos > lndos[0]], lndos[lndos>lndos[0]])#, label='%d iterations' % its)
plt.stackplot(e, Ss, labels=labels)
plt.plot(e, lndos, color='black', linewidth=2)
plt.title('Density of States for various iterations')
예제 #2
0
    for i in range(len(T)):
        boltz_arg = S - E / T[i]
        P = np.exp(boltz_arg - boltz_arg.max())
        P = P / P.sum()
        U = (E * P).sum()
        C[i] = ((E - U)**2 * P).sum() / T[i]**2
    return C


T = np.arange(1.5, 5, 0.01)

# Compute the reference energy, entropy, and heat capacity once.
try:
    eref, lndosref, Nrt_ref = readnew.e_lndos_ps(ref)
except:
    eref, lndosref = readnew.e_lndos(ref)

#cvref = heat_capacity(T, eref, lndosref)
cvref = heat_capacity(T, eref[0:Emin - Emax + 1], lndosref[0:Emin - Emax + 1])

# form a dictionary to place into a pandas dataframe.
mydictionary = {
    'Temperature': T,
    'cvref': cvref,
}
df = pd.DataFrame(mydictionary)

for f in filename:
    name = '%s.yaml' % (f)

    for n in range(1, seed_avg + 1):
예제 #3
0
plt.figure(figsize=(5, 4))

inputs = [
    #('vanilla_wang_landau',
    #   'data/s000/periodic-ww1.30-ff0.30-N500-vanilla_wang_landau-minE-movie/002000-lndos.dat'),
    ('samc-1e+06',
     'data/s000/periodic-ww1.50-ff0.17-N256-samc-100000-movie/000600-lndos.dat'
     ),
    #('sad3', 'data/s000/periodic-ww1.30-ff0.30-N500-sad3-movie/002000-lndos.dat'),
    #('sad3-test', 'data/s000/periodic-ww1.30-ff0.30-N500-sad3-test-movie/002000-lndos.dat')
]

for method, fname in inputs:
    print('plotting', method)
    e, lndos = readnew.e_lndos(fname)
    colors.plot(e, lndos, method=method)

emax = -34
emin = -2000
eminimportant = -915
eSmax = -509
Smin = -1500
plt.axvline(eminimportant, linestyle=':', color='tab:gray')
plt.axvline(eSmax, linestyle=':', color='tab:gray')
#plt.axvline(emin)
#plt.axvline(eSmax)
plt.ylabel('$S/k_B$')
plt.ylim(Smin, 0)
plt.xlim(emin, emax)
plt.xlabel('$E$')
예제 #4
0
mine = 1e100
maxe = -1e100
numframes = 0

dataformat = 'data/%s/%s-%%s-movie/%%06d' % (subdirname, filename)

lastframe = -1
alldone = False
for frame in range(1, 100000):
    if alldone:
        break
    for suffix in suffixes:
        basename = dataformat % (suffix, frame)
        try:
            e, lndos = readnew.e_lndos(basename)
        except (KeyboardInterrupt, SystemExit):
            raise
        except:
            alldone = True
            break
        numframes = frame + 1
        if len(e[lndos != lndos[-1]]) > 1:
            mine = min(mine, e[lndos != lndos[-1]].min() - 5)
        if len(e[lndos != lndos[0]]):
            maxe = max(maxe, e[lndos != lndos[0]].max() + 5)
    if numframes % 25 == 0 and frame != lastframe:
        print('counting %dth frame' % numframes)
        lastframe = frame

bestframe = sorted(
예제 #5
0
파일: Read-ps.py 프로젝트: iCodeIN/deft
#arg number = ['000100']

all_methods = ['-tmi3', '-tmi2', '-tmi', '-toe', '-tmmc']
methods = []
prettymethods = []

T = []
u = []

energy = []
lndos = []
ps = []
hist = []

fref = 'data/lv/ww%.2f-ff%.2f-%gx%g-tmi3-dos.dat' % (ww, ff, lenx, lenyz)
energy_ref, lndos_ref = readnew.e_lndos(fref)
max_entropy_state = readnew.max_entropy_state(fref)

for method in all_methods:
    try:
        fbase = 'data/lv/ww%.2f-ff%.2f-%gx%g%s-movie/%s' % (
            ww, ff, lenx, lenyz, method, number)
        myT, myu, mycv, mys, myminT = readnew.T_u_cv_s_minT(fbase)
        myenergy, mylndos, myps = readnew.e_lndos_ps(fbase)
        _, myhist = readnew.e_hist(fbase)

    except:
        continue
    energy.append(myenergy[:len(lndos_ref)])
    lndos.append(mylndos[:len(lndos_ref)])
    ps.append(myps[:len(lndos_ref)])
예제 #6
0
data['movies']['entropy'] = np.array(data['movies']['entropy'])
lndos = data['movies']['entropy']
N_save_times = len(data['movies']['entropy'])

ref = reference
if ref[:len('data/')] != 'data/':
    ref = 'data/' + ref
maxref = Smax #int(readnew.max_entropy_state(ref))
minref = Smin # int(readnew.min_important_energy(ref))
n_energies = int(minref - maxref+1)
print maxref, minref
try:
    eref, lndosref, Nrt_ref = readnew.e_lndos_ps(ref)
except:
    eref, lndosref = readnew.e_lndos(ref)

errorinentropy = np.zeros(N_save_times)
maxerror = np.zeros(N_save_times)

for i in range(0,N_save_times):
    # below just set average S equal between lndos and lndosref
    if yamlRef:
        norm_factor = np.mean(lndos[i][maxyaml:minyaml+1]) - np.mean(lndosref[0:len(lndosref)])
        doserror = lndos[i][maxyaml:minyaml+1][::-1] - lndosref[0:len(lndosref)] - norm_factor
    else:
        norm_factor = np.mean(lndos[i][maxyaml:minyaml+1]) - np.mean(lndosref[maxref:minref+1])
        doserror = lndos[i][maxyaml:minyaml+1][::-1] - lndosref[maxref:minref+1] - norm_factor
    errorinentropy[i] = np.sum(abs(doserror))/len(doserror)
    maxerror[i] = np.amax(doserror) - np.amin(doserror)
예제 #7
0
파일: animate-dos.py 프로젝트: droundy/deft
mine = 1e100
maxe = -1e100
numframes = 0

dataformat = 'data/%s/%s-%%s-movie/%%06d' % (subdirname, filename)

lastframe = -1
alldone = False
for frame in range(1,100000):
    if alldone:
        break
    for suffix in suffixes:
        basename = dataformat % (suffix, frame)
        try:
            e, lndos = readnew.e_lndos(basename)
        except (KeyboardInterrupt, SystemExit):
            raise
        except:
            alldone = True
            break
        numframes = frame+1
        if len(e[lndos != lndos[-1]]) > 1:
            mine = min(mine, e[lndos != lndos[-1]].min() - 5)
        if len(e[lndos != lndos[0]]):
            maxe = max(maxe, e[lndos != lndos[0]].max()+5)
    if numframes % 25 == 0 and frame != lastframe:
        print('counting %dth frame' % numframes)
        lastframe = frame

bestframe = sorted(glob.glob('data/%s/%s-%s-movie/*-lndos.dat'
예제 #8
0
파일: Read-ps.py 프로젝트: droundy/deft
#arg number = [000100]

all_methods = [ '-tmi3', '-tmi2', '-tmi', '-toe', '-tmmc']
methods = []
prettymethods = []

T = []
u = []

energy = []
lndos = []
ps = []
hist = []

fref = 'data/lv/ww%.2f-ff%.2f-%gx%g-tmi3-dos.dat' % (ww,ff,lenx,lenyz)
energy_ref,lndos_ref = readnew.e_lndos(fref)
max_entropy_state = readnew.max_entropy_state(fref)

for method in all_methods:
    try:
        fbase = 'data/lv/ww%.2f-ff%.2f-%gx%g%s-movie/%s' % (ww,ff,lenx,lenyz,method,number)
        myT,myu,mycv,mys,myminT = readnew.T_u_cv_s_minT(fbase)
        myenergy,mylndos,myps = readnew.e_lndos_ps(fbase)
        _, myhist = readnew.e_hist(fbase)

    except:
        continue
    energy.append(myenergy[:len(lndos_ref)])
    lndos.append(mylndos[:len(lndos_ref)])
    ps.append(myps[:len(lndos_ref)])
    newhist = np.zeros_like(lndos_ref)
예제 #9
0
        matplotlib.use('Agg')
import matplotlib.pyplot as plt

if os.path.exists('../data'):
    os.chdir('..')

moviedir = sys.argv[1]
frames = eval(sys.argv[2]) # a list of integers


Ss = []
labels = []

for f in frames:
    print f
    e, lndos = readnew.e_lndos('%s/%06d-lnw.dat' % (moviedir, f))
    its = readnew.iterations('%s/%06d-lnw.dat' % (moviedir, f))
    lndos = -lndos
    Smin = lndos[lndos>lndos[0]].min()
    lndos -= Smin
    if len(Ss) > 0:
        Ss.append(lndos - lastdos)
    else:
        Ss = [lndos]
    lastdos = lndos*1
    labels.append('%d iterations' % its)

#    plt.stackplot(e[lndos > lndos[0]], lndos[lndos>lndos[0]])#, label='%d iterations' % its)
plt.stackplot(e, Ss, labels=labels)
plt.plot(e, lndos, color = 'black', linewidth = 2)
plt.title('Density of States for various iterations')