plt.close() plt.figure(2) plt.close() ##Main execution of program # define model grid grd = IsingGrid(dim, sizeN) if gridMode == 1: grd = PottsGrid(dim, sizeN, 10) if gridMode == 2: grd = SpinGlass(dim, sizeN) # set magnetic field grd.fieldB = magField # run.... output = wangLandau(grd) # write to file! dataOut = [] for i in range(0, len(output[0])): dataOut.append([output[2][i], output[0][i]]) plotArrayToFile(dataOut, fileOut) thermalizationSweeps, measurementSweeps = 10000, 50000 plotRange = [0.0, 2.0, 30] MetropolisModule.runAlgorithm(grd, plotRange, thermalizationSweeps, measurementSweeps, 5, fileOut + "_Metropolis")
normConstLog = np.log(normConst) #for i in range(0,len(logG)): #out[i]*=normConst #logG[i]+=normConstLog # pow(out[i],sumLogG) return [logG, out] def isFlatAverage(histogram): avg = np.mean(histogram) for i in range(0,len(histogram)): if(histogram[i]<0.8*avg): return False return True def isFlatStd(histogram, tolerance): avg = np.mean(histogram) std = np.std(histogram) return (std < (avg*tolerance)) def closeGraphs(): plt.figure(1) plt.close() plt.figure(2) plt.close() #main loop of program grd = IsingGrid(dim,sizeN) print('grid made') output = wangLandau(grd) print('output') plotArrayToFile(output[0],fileOut)
def closeGraphs(): plt.figure(1) plt.close() plt.figure(2) plt.close() ##Main execution of program #define model grid grd = IsingGrid(dim,sizeN) modeString = 'Ising' if(gridMode == 1): grd = PottsGrid(dim,sizeN,10) modeString = 'Potts' if(gridMode==2): grd= SpinGlass(dim,sizeN) modeString = 'Spin Glass' #set magnetic field grd.fieldB = magField #run.... output = wangLandau(grd) #write to file! dataOut =[] for i in range(0,len(output[0])): dataOut.append([output[2][i],output[0][i]]) plotArrayToFile(dataOut,fileOut, '#Wang Landau density of states for L=' + str(grd.gridSize) + ' dimension =' + str(grd.dimension) + ' ' + modeString + ' model.\n#Energy/Sites\tlogarithm of density of states\n',False)
normConst = float(dim**grid.gridSize)/sum(out) normConstLog = np.log(normConst) #for i in range(0,len(logG)): #out[i]*=normConst #logG[i]+=normConstLog # pow(out[i],sumLogG) return [logG, out] def isFlatAverage(histogram): avg = np.mean(histogram) for i in range(0,len(histogram)): if(histogram[i]<0.8*avg): return False return True def isFlatStd(histogram, tolerance): avg = np.mean(histogram) std = np.std(histogram) return (std < (avg*tolerance)) def closeGraphs(): plt.figure(1) plt.close() plt.figure(2) plt.close() #main loop of program grd = IsingGrid(dim,sizeN) output = wangLandau(grd) plotArrayToFile(output[0],fileOut)
plt.figure(2) plt.close() ##Main execution of program #define model grid grd = IsingGrid(dim, sizeN) if (gridMode == 1): grd = PottsGrid(dim, sizeN, 10) if (gridMode == 2): grd = SpinGlass(dim, sizeN) #set magnetic field grd.fieldB = magField #run.... output = wangLandau(grd) #write to file! dataOut = [] for i in range(0, len(output[0])): dataOut.append([output[2][i], output[0][i]]) plotArrayToFile(dataOut, fileOut) thermalizationSweeps, measurementSweeps = 10000, 50000 plotRange = [0.0, 2.0, 30] MetropolisModule.runAlgorithm(grd, plotRange, thermalizationSweeps, measurementSweeps, 5, fileOut + "_Metropolis")