from IsingLattice import * from matplotlib import pylab as pl import numpy as np #First, we use the NumPy loadtxt function to read our previously saved file for the 2x2 lattice data_2x2_lattice=np.loadtxt("2x2_mine.dat") #Define number of spins in lattice (so that we can use this to convert values of energy to energy/spin) spins=4 #Plot temperature on x-axis and energy/ spin on y-axis pl.plot(data_2x2_lattice[:,0], data_2x2_lattice[:,1]/spins, 'bo-', markersize=3, label='Lattice Size: 2x2') #We can use a similar method for the rest of the lattice sizes #4x4 lattice: data_4x4_lattice=np.loadtxt("4x4_mine.dat") spins=16 pl.plot(data_4x4_lattice[:,0], data_4x4_lattice[:,1]/spins, 'go-', markersize=3, label='Lattice Size: 4x4') #8x8 lattice: data_8x8_lattice=np.loadtxt("8x8_mine.dat") spins=64 pl.plot(data_8x8_lattice[:,0], data_8x8_lattice[:,1]/spins, 'ro-', markersize = 3, label='Lattice Size: 8x8') #16x16 lattice: data_16x16_lattice=np.loadtxt("16x16_mine.dat") spins=256 pl.plot(data_16x16_lattice[:,0], data_16x16_lattice[:,1]/spins, 'co-', markersize = 3, label='Lattice Size: 16x16') #32x32 lattice: data_32x32_lattice=np.loadtxt("32x32_mine.dat") spins=1024 pl.plot(data_32x32_lattice[:,0], data_32x32_lattice[:,1]/spins, 'mo-', markersize = 3, label='Lattice Size: 32x32') #Titling Graph, Labelling Axes and Lines pl.title('Plots of Energy per Spin vs Temperature for Lattice Sizes Tested') pl.xlabel('Temperature') pl.ylabel('Energy per spin(in reduced units of kB)') pl.legend(loc='upper left') pl.show()