09: Run copied code
This commit is contained in:
File diff suppressed because one or more lines are too long
@ -1,7 +1,11 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
import argparse
|
||||||
|
import time
|
||||||
|
import h5py
|
||||||
|
|
||||||
|
starttime = time.asctime()
|
||||||
|
|
||||||
rng = np.random.default_rng()
|
rng = np.random.default_rng()
|
||||||
import matplotlib.pylab as plt
|
|
||||||
%matplotlib inline
|
|
||||||
|
|
||||||
def potential_v(x,lamb):
|
def potential_v(x,lamb):
|
||||||
'''Compute the potential function V(x).'''
|
'''Compute the potential function V(x).'''
|
||||||
@ -49,9 +53,9 @@ kappas = np.linspace(0.08,0.18,11)
|
|||||||
width = 3
|
width = 3
|
||||||
num_sites = width**4
|
num_sites = width**4
|
||||||
delta = 1.5 # chosen to have ~ 50% acceptance
|
delta = 1.5 # chosen to have ~ 50% acceptance
|
||||||
equil_sweeps = 1000
|
equil_sweeps = 10
|
||||||
measure_sweeps = 2
|
measure_sweeps = 2
|
||||||
measurements = 2000
|
measurements = 20
|
||||||
|
|
||||||
mean_magn = []
|
mean_magn = []
|
||||||
for kappa in kappas:
|
for kappa in kappas:
|
||||||
@ -64,8 +68,18 @@ for kappa in kappas:
|
|||||||
mean, err = batch_estimate(np.abs(magnetizations),lambda x:np.mean(x),10)
|
mean, err = batch_estimate(np.abs(magnetizations),lambda x:np.mean(x),10)
|
||||||
mean_magn.append([mean,err])
|
mean_magn.append([mean,err])
|
||||||
|
|
||||||
plt.errorbar(kappas,[m[0] for m in mean_magn],yerr=[m[1] for m in mean_magn],fmt='-o')
|
output_filename = 'preliminary_simulation.h5'
|
||||||
plt.xlabel(r"$\kappa$")
|
with h5py.File(output_filename,'a') as f:
|
||||||
plt.ylabel(r"$|m|$")
|
if not "mean-magn" in f:
|
||||||
plt.title(r"Absolute field average on $3^4$ lattice, $\lambda = 1.5$")
|
dataset = f.create_dataset("mean-magn", chunks=True, data=mean_magn)
|
||||||
plt.show()
|
# store some information as metadata for the data set
|
||||||
|
dataset.attrs["lamb"] = lamb
|
||||||
|
dataset.attrs["kappas"] = kappas
|
||||||
|
dataset.attrs["width"] = width
|
||||||
|
dataset.attrs["num_sites"] = num_sites
|
||||||
|
dataset.attrs["delta"] = delta
|
||||||
|
dataset.attrs["equil_sweeps"] = equil_sweeps
|
||||||
|
dataset.attrs["measure_sweeps"] = measure_sweeps
|
||||||
|
dataset.attrs["measurements"] = measurements
|
||||||
|
dataset.attrs["start time"] = starttime
|
||||||
|
dataset.attrs["stop time"] = time.asctime()
|
||||||
|
|||||||
BIN
Exercise sheet 9/preliminary_simulation.h5
Normal file
BIN
Exercise sheet 9/preliminary_simulation.h5
Normal file
Binary file not shown.
Reference in New Issue
Block a user