def runAlgorithm(model, temperatureRange,tSweeps,mSweeps,averages,outputFile): global grid, fileOut, thermalizationSweeps, measurementSweeps, numAverages, plotRange grid = model fileOut = outputFile thermalizationSweeps, measurementSweeps = tSweeps, mSweeps numAverages = averages plotRange = temperatureRange header = '#Thermalization Sweeps:' + str(thermalizationSweeps) + '\tMeasurement Sweeps:'+ str(measurementSweeps) +'\n#' + str(model.dimension) + 'dimensional grid with N=' + str(model.gridSize) + '\n#Pairs of y values (yval, yerr)\n#Temp\tEnergy\tE^2\tMagnetization^2\tMagnetization^4\n' plotToFile(plotFunc,plotRange,fileOut,header,False,True)
def runAlgorithm(model, temperatureRange, tSweeps, mSweeps, averages, outputFile): global grid, fileOut, thermalizationSweeps, measurementSweeps, numAverages, plotRange grid = model fileOut = outputFile thermalizationSweeps, measurementSweeps = tSweeps, mSweeps numAverages = averages plotRange = temperatureRange header = '#Thermalization Sweeps:' + str( thermalizationSweeps ) + '\tMeasurement Sweeps:' + str(measurementSweeps) + '\n#' + str( model.dimension ) + 'dimensional grid with N=' + str( model.gridSize ) + '\n#Pairs of y values (yval, yerr)\n#Temp\tEnergy\tE^2\tMagnetization^2\tMagnetization^4\n' plotToFile(plotFunc, plotRange, fileOut, header, False, True)
logNorm = np.log(totalStates()) for i in range(0, len(logG)): file.write(str(energies[i]) + '\t' + str(logG[i] - logNorm) + "\n") file.close() def plotFunction(x): #function to pass to file output module return [ calcThermalAverage(energyFunc, x), calcThermalAverage(energySqr, x) ] ###main execution global numStates for i in range(0, len(filesToRead)): fileIn = filesToRead[i] fileOut = fileIn + '_ThermalAverage' file = open(fileIn, 'r') energies, logG = [], [] for line in file: #Read log[g(E)] from file generated by wang-landau algorithm... if (line[0] != '#'): vals = str.split(line, '\t') energies.append(float(vals[0])) logG.append(float(vals[1])) file.close() normalizeG() numSites = len(logG) + 1 numStates = totalStates() plotToFile(plotFunction, plotRange, fileOut) #output thermal averages writeDOS() #output normalized DOS
return energy**2 ##file output def writeDOS(): file = open(fileIn + "_NormG",'w') logNorm = np.log(totalStates()) for i in range(0,len(logG)): file.write(str(energies[i]) + '\t' + str(logG[i] - logNorm) + "\n") file.close() def plotFunction(x): #function to pass to file output module return [calcThermalAverage(energyFunc,x), calcThermalAverage(energySqr,x)] ###main execution global numStates for i in range(0,len(filesToRead)): fileIn = filesToRead[i] fileOut = fileIn + '_ThermalAverage' file = open(fileIn,'r') energies, logG = [], [] for line in file: #Read log[g(E)] from file generated by wang-landau algorithm... if(line[0] != '#'): vals = str.split(line,'\t') energies.append(float(vals[0])) logG.append(float(vals[1])) file.close() normalizeG() numSites = len(logG) + 1 numStates = totalStates() plotToFile(plotFunction, plotRange, fileOut) #output thermal averages writeDOS() #output normalized DOS