def main(): # --- Set up all options -------------------------------------------------- # parse command line, getting algorithmic and plotting options. args = jk.parseCMD() reduceType = args.reduceType direc = args.fileNames[0] Lx = 12.0 # some plotting color and label options colors = ['Salmon','MediumSpringGreen','DarkViolet','Fuchsia','Blue', 'Maroon'] if args.RandomColors: random.shuffle(colors) # set up figure that displays all data figg = pl.figure(1) ax = figg.add_subplot(111) pl.xlabel(r'$T\ [K]$', fontsize=20) pl.ylabel('Spatial Density '+r'$[\si{\angstrom}^{-d}]$', fontsize=20) pl.grid(True) pl.xlim([0.5,3.0]) pl.ylim([0,0.07]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # set up bulk SVP densities for plot bulkVert = -30 minMus = 0.5 maxMus = 2.5 boxSubtract = 1.6 pl.plot([minMus, maxMus], [0.02198, 0.02198], 'k-', lw=3) pl.annotate('3d SVP', xy=(maxMus - boxSubtract, 0.02195), #xycoords='data', xytext=(-50, bulkVert), textcoords='offset points', bbox=dict(boxstyle="round", fc="0.8"), arrowprops=dict(arrowstyle="->", connectionstyle="angle,angleA=0,angleB=90,rad=10"), ) pl.plot([minMus, maxMus], [0.0432, 0.0432], 'k-', lw=3) pl.annotate('2d SVP', xy=(maxMus - boxSubtract, 0.0432), #xycoords='data', xytext=(-50, 30), textcoords='offset points', bbox=dict(boxstyle="round", fc="0.8"), arrowprops=dict(arrowstyle="->", connectionstyle="angle,angleA=0,angleB=90,rad=10"), ) pl.figure(2) pl.xlabel(r'$T\ [K]$', fontsize=20) pl.ylabel('Number of Particles', fontsize=20) pl.grid(True) pl.xlim([0.5,3.0]) pl.ylim([0,2]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # --- loop over all values of S ------------------------------------------- os.chdir(direc) Svals = glob.glob('S*') for nS, Sval in enumerate(Svals): os.chdir(Sval) # store bulk separation value S = re.search(r'\d+',Sval).group(0) # projected area of film region projArea = float(S)*Lx # set label for plot if 'distinguishable' in Sval: labell = 'S = '+str(S)+', Boltzmannons' else: labell = 'S = '+str(S)+', Bosons' # get all temperature directory names Tdirs = sorted(glob.glob('T*')) Ts = pl.array([]) Films = pl.array([]) Bulks = pl.array([]) filmErrs = pl.array([]) bulkErrs = pl.array([]) # --- loop over all temperature values -------------------------------- for Tdir in Tdirs: os.chdir(Tdir) # build array of temperatures Ts = pl.append(Ts, float(Tdir[1:])) # get data file name f = glob.glob('*Bipart*')[0] #densData = pl.genfromtxt(f, delimiter=',') filmavg,filmstd,filmbins,bulkavg,bulkstd,bulkbins = pl.genfromtxt(f, unpack=True, usecols=(0,1,2,3,4,5), delimiter=',') # get rid of any items which are not numbers.. # this is some beautiful Python juju. filmbins = filmbins[pl.logical_not(pl.isnan(filmbins))] filmstd = filmstd[pl.logical_not(pl.isnan(filmstd))] filmavg = filmavg[pl.logical_not(pl.isnan(filmavg))] bulkbins = bulkbins[pl.logical_not(pl.isnan(bulkbins))] bulkstd = bulkstd[pl.logical_not(pl.isnan(bulkstd))] bulkavg = bulkavg[pl.logical_not(pl.isnan(bulkavg))] filmweights = filmbins/pl.sum(filmbins) bulkweights = bulkbins/pl.sum(bulkbins) filmavg *= filmweights bulkavg *= bulkweights filmstd *= filmweights bulkstd *= bulkweights film = pl.sum(filmavg) bulk = pl.sum(bulkavg) filmstdErr = pl.sum(filmstd) bulkstdErr = pl.sum(bulkstd) Films = pl.append(Films, film) Bulks = pl.append(Bulks, bulk) filmErrs = pl.append(filmErrs, filmstdErr) bulkErrs = pl.append(bulkErrs, bulkstdErr) os.chdir('..') # add data to plot for given S value. pl.figure(1) pl.errorbar(Ts, Films, filmErrs, fmt='-o', color=colors[nS], label=labell+', 2d') pl.errorbar(Ts, Bulks, bulkErrs, fmt = '--d', color=colors[nS], label=labell+', 3d') pl.figure(2) pl.errorbar(Ts, Films*projArea, fmt='-o', color=colors[nS], label = labell+', 2d') os.chdir('..') pl.figure(1) pl.legend() #pl.savefig('Densities_vs_T_allS.pdf', format='pdf', # bbox_inches='tight') pl.figure(2) pl.legend() pl.show()
def main(): estimList = [] QHO = False args = aTools.parseCMD() fileNames = args.fileNames skip = args.skip # Check if any jackknife data files exist already. check = glob.glob('*Jack*') if check != []: sys.exit('Check your directory for Jackknife data files') reduceType = args.reduceType # check which ensemble canonical=True if fileNames[0][0]=='g': canonical=False # create list of temperatures temps = pl.array([]) tempList = aTools.getHeadersFromFile(fileNames[0]) for temp in tempList: temps = pl.append(temps,float(temp)) # perform jackknife analysis of data, writing to disk for fileName in fileNames: print '\n\n---',fileName,'---\n' # ======================================== # NON TRIVIAL WINDING ESTIMATOR # ======================================== if 'Ntwind' in fileName: estimList.append('Ntwind') ntWinds, ntWindErrs = pl.array([]), pl.array([]) fout = open('JackKnifeData_ntWind.dat','w') fout.write('#%15s\t%16s\n'%(reduceType, '<W^2>')) # read in data and call jackknife method. for n,temp in enumerate(tempList): ntWind = pl.array([]) with open(fileName, 'rb') as f: reader = csv.reader(f) for row in reader: if row[0][0] == '#': continue else: try: ntWind = pl.append(ntWind, float(row[n])) except: continue ntWindAve, ntWindErr = aTools.jackknife(ntWind[skip:]) print reduceType,' = ', temp print '<W^2> = ', ntWindAve,' +/- ',ntWindErr print 'numBins: ',len(ntWind),'\n' ntWinds = pl.append(ntWinds, ntWindAve) ntWindErrs = pl.append(ntWindErrs, ntWindErr) fout.write('%16.8E\t%16.8E\t%16.8E\n' %( float(temp), ntWindAve, ntWindErr )) fout.close() # ======================================== # ENERGY AND SPECIFIC HEAT ESTIMATOR # ======================================== if 'Estimator' in fileName: estimList.append('Estimator') Cvs,CvsErr = pl.array([]),pl.array([]) Es, EsErr = pl.array([]), pl.array([]) fout = open('JackKnifeData_Cv.dat', 'w') fout.write('#%15s\t%16s\t%16s\t%16s\t%16s\n'% ( reduceType, 'E', 'Eerr', 'Cv', 'CvErr')) # read in data and call jackknife method. n = 0 for temp in tempList: E = pl.array([]) Cv1 = pl.array([]) Cv2 = pl.array([]) Cv3 = pl.array([]) with open(fileName, 'rb') as f: reader = csv.reader(f) for row in reader: if row[0][0] == '#': continue else: try: E = pl.append(E, float(row[n])) Cv1 = pl.append(Cv1, float(row[n+1])) Cv2 = pl.append(Cv2, float(row[n+2])) Cv3 = pl.append(Cv3, float(row[n+3])) except: continue n += 4 EAve, Eerr = aTools.jackknife(E[skip:]) jkAve, jkErr = aTools.jackknife( Cv1[skip:],Cv2[skip:],Cv3[skip:]) print reduceType,' = ',float(temp) print '<E> = ',EAve,' +/- ',Eerr print '<Cv> = ',jkAve,' +/- ',jkErr Es = pl.append(Es, EAve) Cvs = pl.append(Cvs, jkAve) EsErr = pl.append(EsErr, Eerr) CvsErr = pl.append(CvsErr, jkErr) fout.write('%16.8E\t%16.8E\t%16.8E\t%16.8E\t%16.8E\n' %( float(temp), EAve, Eerr, jkAve, jkErr)) fout.close() # ======================================== # SUPERFLUID ESTIMATORS # ======================================== if 'Super' in fileName: estimList.append('Super') rhos_rhos, rhos_rhoErr = pl.array([]), pl.array([]) Wx2s, Wx2Err = pl.array([]), pl.array([]) Wy2s, Wy2Err = pl.array([]), pl.array([]) Wz2s, Wz2Err = pl.array([]), pl.array([]) fout = open('JackKnifeData_super.dat','w') fout.write('#%15s,\t%16s,\t%16s,\t%16s,\t%16s,\t\ %16s,\t%16s,\t%16s,\t%16s\n'%( reduceType, 'rho_s/rho', 'rho_s/rhoErr', 'Wx^2', 'Wx2_err', 'Wy^2', 'Wy2_err', 'Wz^2', 'Wz2_err')) # read in data and call jackknife method. n = 0 for temp in tempList: rhos_rho = pl.array([]) wx2 = pl.array([]) wy2 = pl.array([]) wz2 = pl.array([]) with open(fileName, 'rb') as f: reader = csv.reader(f) for row in reader: if row[0][0] == '#': continue else: try: rhos_rho = pl.append(rhos_rho, float(row[n])) wx2 = pl.append(wx2, float(row[n+1])) wy2 = pl.append(wy2, float(row[n+2])) wz2 = pl.append(wz2, float(row[n+3])) except: continue n += 4 superAve, superErr = aTools.jackknife(rhos_rho[skip:]) wx2Ave, wx2Err = aTools.jackknife(wx2[skip:]) wy2Ave, wy2Err = aTools.jackknife(wy2[skip:]) wz2Ave, wz2Err = aTools.jackknife(wz2[skip:]) print 'rho_s/rho = ', superAve,' +/- ',superErr rhos_rhos = pl.append(rhos_rhos, superAve) rhos_rhoErr = pl.append(rhos_rhoErr, superErr) Wx2s = pl.append(Wx2s, wx2Ave) Wx2Err = pl.append(Wx2Err, wx2Err) Wy2s = pl.append(Wy2s, wy2Ave) Wy2Err = pl.append(Wy2Err, wy2Err) Wz2s = pl.append(Wz2s, wz2Ave) Wz2Err = pl.append(Wz2Err, wz2Err) fout.write('%16.8E,\t%16.8E,\t%16.8E,\t%16.8E,\t\ %16.8E,\t%16.8E,\t%16.8E,\t%16.8E,\t%16.8E,\n' %( float(temp), superAve, superErr, wx2Ave, wx2Err, wy2Ave, wy2Err, wz2Ave, wz2Err)) # ======================================== # FILM AND BULK DENSITY ESTIMATORS # ======================================== if 'Bipart' in fileName: estimList.append('Bipart') filmDenses, bulkDenses = pl.array([]), pl.array([]) filmDensErrs, bulkDensErrs = pl.array([]), pl.array([]) fout = open('JackKnifeData_bipart.dat','w') fout.write('#%15s\t%16s\t%16s\t%16s\t%16s\n'%(reduceType, 'filmDens', 'filmDensErr', 'bulkDens', 'bulkDensErr')) # read in data and call jackknife method. n = 0 for temp in tempList: filmDens = pl.array([]) bulkDens = pl.array([]) with open(fileName, 'rb') as f: reader = csv.reader(f) for row in reader: if row[0][0] == '#': continue else: try: filmDens = pl.append(filmDens, float(row[n+2])) bulkDens = pl.append(bulkDens, float(row[n+3])) except: continue n += 2 filmDensAve, filmDensErr = aTools.jackknife(filmDens[skip:]) bulkDensAve, bulkDensErr = aTools.jackknife(bulkDens[skip:]) print 'filmDens = ', filmDensAve,' +/- ',filmDensErr print 'bulkDens = ', bulkDensAve,' +/- ',bulkDensErr filmDenses = pl.append(filmDenses, filmDensAve) filmDensErrs = pl.append(filmDensErrs, filmDensErr) bulkDenses = pl.append(bulkDenses, bulkDensAve) bulkDensErrs = pl.append(bulkDensErrs, bulkDensErr) fout.write('%16.8E\t%16.8E\t%16.8E\t%16.8E\t%16.8E\n' %( float(temp), filmDensAve, filmDensErr, bulkDensAve, bulkDensErr)) fout.close() # ========================================================================= # PLOTTING SECTION # ========================================================================= xLab = jk.getXlabel(reduceType) plotNum = 1 # PLOT ntWinding number squared if 'Ntwind' in estimList: pl.figure(plotNum) pl.errorbar(temps, ntWinds, ntWindErrs, fmt='o') pl.xlabel(xLab, fontsize=20) pl.ylabel(r'$\langle \Omega^2 \rangle$', fontsize=20) pl.grid(True) plotNum += 1 # PLOT specific heat vs. temperature if 'Estimator' in estimList: pl.figure(2) ax1 = pl.subplot(211) #if QHO: # plot analytic result # pl.plot(tempRange,CvAnalytic, label='Exact') pl.errorbar(temps,Cvs,CvsErr, label='PIMC',color='Violet',fmt='o') pl.ylabel('Specific Heat', fontsize=20) pl.grid(True) pl.legend(loc=2) # PLOT the energy vs. temperature pl.setp(ax1.get_xticklabels(), visible=False) ax2 = pl.subplot(212, sharex=ax1) #if QHO: # plot analytic result # pl.plot(tempRange,Eanalytic, label='Exact') pl.errorbar(temps,Es,EsErr, label='PIMC virial',color='Lime',fmt='o') pl.xlabel(xLab, fontsize=20) pl.ylabel('Energy [K]', fontsize=20) pl.grid(True) pl.legend(loc=2) plotNum += 1 # PLOT superfluid properties if 'Super' in estimList: pl.figure(plotNum) pl.errorbar(temps, rhos_rhos, rhos_rhoErr, fmt='o') pl.xlabel(xLab, fontsize=20) pl.ylabel('Superfluid Stiffness', fontsize=20) pl.grid(True) plotNum += 1 pl.figure(plotNum) pl.errorbar(temps, Wx2s, Wx2Err, fmt='o', label=r'$\langle W_x^2 \rangle$') pl.errorbar(temps, Wy2s, Wy2Err, fmt='o', label=r'$\langle W_y^2 \rangle$') pl.errorbar(temps, Wz2s, Wz2Err, fmt='o', label=r'$\langle W_z^2 \rangle$') pl.xlabel(xLab, fontsize=20) pl.ylabel(r'$\langle W_i^2 \rangle$', fontsize=20) pl.legend() pl.grid(True) plotNum += 1 pl.figure(plotNum) pl.errorbar(temps, Wz2s, Wz2Err, fmt='o', label=r'$\langle W_z^2 \rangle$') pl.xlabel(xLab, fontsize=20) pl.ylabel(r'$\langle W_z^2 \rangle$', fontsize=20) pl.legend() pl.grid(True) plotNum += 1 # PLOT film and bulk densities if 'Bipart' in estimList: pl.figure(plotNum) pl.errorbar(temps, filmDenses, filmDensErrs, label='film', fmt='o') pl.errorbar(temps, bulkDenses, bulkDensErrs, label='bulk', fmt='o') pl.xlabel(xLab, fontsize=20) pl.ylabel(r'$\mathrm{Density}\ [\AA^{-d}]$', fontsize=20) pl.legend() pl.grid(True) pl.show() # BELOW IS RESIDUE FROM A PREVIOUS VERSION OF THIS SCRIPT. # SOME OF IT MIGHT PROVE USEFUL. '''else: print 'Found existing data file in CWD.' temps, Es, EsErr, Cvs, CvsErr = pl.loadtxt( 'JackKnifeData_Cv.dat', unpack=True) if not QHO: temps, rhos_rhos, rhos_rhoErr, Wx2s, Wx2Err, Wy2s, Wy2Err, Wz2s, Wz2Err = pl.loadtxt( 'JackKnifeData_super.dat', unpack=True) if excVol: temps, filmDenses, filmDensErrs, bulkDenses, bulkDensErrs = pl.loadtxt( 'JackKnifeData_bipart.dat', unpack=True)''' '''
def main(): omega = True energy = False superFrac = True # --- Set up all options -------------------------------------------------- Ly = 12.0 # parse command line, getting algorithmic and plotting options. args = jk.parseCMD() reduceType = args.reduceType direc = args.fileNames[0] nCol = args.nCol nEst = args.nEst # some plotting color and label options xLab = jk.getXlabel(reduceType) extent = args.bulkSeparation colors = [ 'Salmon', 'MediumSpringGreen', 'DarkViolet', 'Fuchsia', 'Blue', 'Maroon' ] if args.RandomColors: random.shuffle(colors) # set up figure that displays all data figg = pl.figure(1) ax = figg.add_subplot(111) pl.xlabel(r'$T\ [K]$', fontsize=20) pl.ylabel(r'$\langle \Omega \rangle$', fontsize=20) pl.grid(True) pl.xlim([0.4, 2.6]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) figg2 = pl.figure(2) ax = figg2.add_subplot(111) pl.ylabel(r'$ \rho_s/\rho $', fontsize=20) pl.xlabel(r'$T\ [K]$', fontsize=20) pl.grid(True) pl.xlim([0.4, 2.6]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) figg3 = pl.figure(3) ax = figg3.add_subplot(111) pl.ylabel(r'$ \rho_{\text{film}}\ [\si{\angstrom}^{-2}] $', fontsize=20) pl.xlabel(r'$T\ [K]$', fontsize=20) pl.grid(True) pl.xlim([0.4, 2.6]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) figg4 = pl.figure(4) ax = figg4.add_subplot(111) pl.ylabel(r'$\langle \rho_{\text{bulk}} \rangle$', fontsize=20) pl.xlabel(r'$T\ [K]$', fontsize=20) pl.grid(True) pl.xlim([0.4, 2.6]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # --- loop over all values of S ------------------------------------------- os.chdir(direc) Svals = glob.glob('S*') Svals = natsort.natsorted(Svals) print Svals for nS, Sval in enumerate(Svals): os.chdir(Sval) # store bulk separation value S = re.search(r'\d+', Sval).group(0) print S # set normalization if omega: normFactor = 4.0 * (float(S) + Ly)**2 else: normFactor = 1.0 print normFactor # set label for plot #if 'distinguishable' in Sval: if 'noSwaps' in Sval: labell = 'S = ' + str( S) + ' ' + r'$\si{\angstrom}$' ', Boltzmannons' else: labell = 'S = ' + str(S) + ' ' + r'$\si{\angstrom}$' + ', Bosons' # get all temperature directory names Tdirs = sorted(glob.glob('T*')) # build array of norman winding values along with bins, for Lz plotting. windingAverages = pl.array([]) windingErrors = pl.array([]) filmAverages = pl.array([]) filmErrors = pl.array([]) bulkAverages = pl.array([]) bulkErrors = pl.array([]) superAverages = pl.array([]) superErrors = pl.array([]) Ts = pl.array([]) #Omegas = pl.array([]) #Errs = pl.array([]) #Films = pl.array([]) #Ferrs = pl.array([]) #Bulks = pl.array([]) #Berrs = pl.array([]) #Supers = pl.array([]) #Serrs = pl.array([]) # --- loop over all temperature values -------------------------------- for Tdir in Tdirs: os.chdir(Tdir) # build array of temperatures Ts = pl.append(Ts, float(Tdir[1:])) # --- angular winding --- f = glob.glob('*zAveragedNtwind*')[0] aCol = 3 sCol = 4 bCol = 5 avg, stdErr = cT.crunchZfile(f, aCol, sCol, bCol, normFactor) windingAverages = pl.append(windingAverages, avg) windingErrors = pl.append(windingErrors, stdErr) # --- film densities --- f = glob.glob('*zAveragedBipart*')[0] aCol = 0 sCol = 1 bCol = 2 avg, stdErr = cT.crunchZfile(f, aCol, sCol, bCol, 1.0) filmAverages = pl.append(filmAverages, avg) filmErrors = pl.append(filmErrors, stdErr) # --- bulk densities --- aCol = 3 sCol = 4 bCol = 5 avg, stdErr = cT.crunchZfile(f, aCol, sCol, bCol, 1.0) bulkAverages = pl.append(bulkAverages, avg) bulkErrors = pl.append(bulkErrors, stdErr) # --- superfluid fractions --- f = glob.glob('*zAveragedSuper*')[0] aCol = 0 sCol = 1 bCol = 2 avg, stdErr = cT.crunchZfile(f, aCol, sCol, bCol, 1.0) superAverages = pl.append(superAverages, avg) superErrors = pl.append(superErrors, stdErr) # ---------------------- os.chdir('..') # add data to plot for given S value. pl.figure(1) pl.errorbar(Ts, windingAverages, windingErrors, fmt='-o', color=colors[nS], label=labell) pl.figure(2) pl.errorbar(Ts, superAverages, superErrors, fmt='-o', color=colors[nS], label=labell) pl.figure(3) pl.errorbar(Ts, filmAverages, filmErrors, fmt='-o', color=colors[nS], label=labell) pl.figure(4) pl.errorbar(Ts, bulkAverages, bulkErrors, fmt='-o', color=colors[nS], label=labell) os.chdir('..') pl.figure(1) pl.legend() pl.savefig('Omega_vs_T_allS.pdf', format='pdf', bbox_inches='tight') pl.figure(2) pl.legend() #pl.savefig('SuperFrac_vs_T_allS.pdf', format='pdf', # bbox_inches='tight') pl.figure(3) pl.legend() pl.savefig('FilmDensities_vs_T_allS.pdf', format='pdf', bbox_inches='tight') pl.figure(4) pl.legend() pl.show()
def main(): estimList = [] QHO = False args = aTools.parseCMD() fileNames = args.fileNames skip = args.skip # Check if any jackknife data files exist already. check = glob.glob('*Jack*') if check != []: sys.exit('Check your directory for Jackknife data files') reduceType = args.reduceType # check which ensemble canonical = True if fileNames[0][0] == 'g': canonical = False # create list of temperatures temps = pl.array([]) tempList = aTools.getHeadersFromFile(fileNames[0]) for temp in tempList: temps = pl.append(temps, float(temp)) # perform jackknife analysis of data, writing to disk for fileName in fileNames: print '\n\n---', fileName, '---\n' # ======================================== # NON TRIVIAL WINDING ESTIMATOR # ======================================== if 'Ntwind' in fileName: estimList.append('Ntwind') ntWinds, ntWindErrs = pl.array([]), pl.array([]) fout = open('JackKnifeData_ntWind.dat', 'w') fout.write('#%15s\t%16s\n' % (reduceType, '<W^2>')) # read in data and call jackknife method. for n, temp in enumerate(tempList): ntWind = pl.array([]) with open(fileName, 'rb') as f: reader = csv.reader(f) for row in reader: if row[0][0] == '#': continue else: try: ntWind = pl.append(ntWind, float(row[n])) except: continue ntWindAve, ntWindErr = aTools.jackknife(ntWind[skip:]) print reduceType, ' = ', temp print '<W^2> = ', ntWindAve, ' +/- ', ntWindErr print 'numBins: ', len(ntWind), '\n' ntWinds = pl.append(ntWinds, ntWindAve) ntWindErrs = pl.append(ntWindErrs, ntWindErr) fout.write('%16.8E\t%16.8E\t%16.8E\n' % (float(temp), ntWindAve, ntWindErr)) fout.close() # ======================================== # ENERGY AND SPECIFIC HEAT ESTIMATOR # ======================================== if 'Estimator' in fileName: estimList.append('Estimator') Cvs, CvsErr = pl.array([]), pl.array([]) Es, EsErr = pl.array([]), pl.array([]) fout = open('JackKnifeData_Cv.dat', 'w') fout.write('#%15s\t%16s\t%16s\t%16s\t%16s\n' % (reduceType, 'E', 'Eerr', 'Cv', 'CvErr')) # read in data and call jackknife method. n = 0 for temp in tempList: E = pl.array([]) Cv1 = pl.array([]) Cv2 = pl.array([]) Cv3 = pl.array([]) with open(fileName, 'rb') as f: reader = csv.reader(f) for row in reader: if row[0][0] == '#': continue else: try: E = pl.append(E, float(row[n])) Cv1 = pl.append(Cv1, float(row[n + 1])) Cv2 = pl.append(Cv2, float(row[n + 2])) Cv3 = pl.append(Cv3, float(row[n + 3])) except: continue n += 4 EAve, Eerr = aTools.jackknife(E[skip:]) jkAve, jkErr = aTools.jackknife(Cv1[skip:], Cv2[skip:], Cv3[skip:]) print reduceType, ' = ', float(temp) print '<E> = ', EAve, ' +/- ', Eerr print '<Cv> = ', jkAve, ' +/- ', jkErr Es = pl.append(Es, EAve) Cvs = pl.append(Cvs, jkAve) EsErr = pl.append(EsErr, Eerr) CvsErr = pl.append(CvsErr, jkErr) fout.write('%16.8E\t%16.8E\t%16.8E\t%16.8E\t%16.8E\n' % (float(temp), EAve, Eerr, jkAve, jkErr)) fout.close() # ======================================== # SUPERFLUID ESTIMATORS # ======================================== if 'Super' in fileName: estimList.append('Super') rhos_rhos, rhos_rhoErr = pl.array([]), pl.array([]) Wx2s, Wx2Err = pl.array([]), pl.array([]) Wy2s, Wy2Err = pl.array([]), pl.array([]) Wz2s, Wz2Err = pl.array([]), pl.array([]) fout = open('JackKnifeData_super.dat', 'w') fout.write('#%15s,\t%16s,\t%16s,\t%16s,\t%16s,\t\ %16s,\t%16s,\t%16s,\t%16s\n' % (reduceType, 'rho_s/rho', 'rho_s/rhoErr', 'Wx^2', 'Wx2_err', 'Wy^2', 'Wy2_err', 'Wz^2', 'Wz2_err')) # read in data and call jackknife method. n = 0 for temp in tempList: rhos_rho = pl.array([]) wx2 = pl.array([]) wy2 = pl.array([]) wz2 = pl.array([]) with open(fileName, 'rb') as f: reader = csv.reader(f) for row in reader: if row[0][0] == '#': continue else: try: rhos_rho = pl.append(rhos_rho, float(row[n])) wx2 = pl.append(wx2, float(row[n + 1])) wy2 = pl.append(wy2, float(row[n + 2])) wz2 = pl.append(wz2, float(row[n + 3])) except: continue n += 4 superAve, superErr = aTools.jackknife(rhos_rho[skip:]) wx2Ave, wx2Err = aTools.jackknife(wx2[skip:]) wy2Ave, wy2Err = aTools.jackknife(wy2[skip:]) wz2Ave, wz2Err = aTools.jackknife(wz2[skip:]) print 'rho_s/rho = ', superAve, ' +/- ', superErr rhos_rhos = pl.append(rhos_rhos, superAve) rhos_rhoErr = pl.append(rhos_rhoErr, superErr) Wx2s = pl.append(Wx2s, wx2Ave) Wx2Err = pl.append(Wx2Err, wx2Err) Wy2s = pl.append(Wy2s, wy2Ave) Wy2Err = pl.append(Wy2Err, wy2Err) Wz2s = pl.append(Wz2s, wz2Ave) Wz2Err = pl.append(Wz2Err, wz2Err) fout.write('%16.8E,\t%16.8E,\t%16.8E,\t%16.8E,\t\ %16.8E,\t%16.8E,\t%16.8E,\t%16.8E,\t%16.8E,\n' % (float(temp), superAve, superErr, wx2Ave, wx2Err, wy2Ave, wy2Err, wz2Ave, wz2Err)) # ======================================== # FILM AND BULK DENSITY ESTIMATORS # ======================================== if 'Bipart' in fileName: estimList.append('Bipart') filmDenses, bulkDenses = pl.array([]), pl.array([]) filmDensErrs, bulkDensErrs = pl.array([]), pl.array([]) fout = open('JackKnifeData_bipart.dat', 'w') fout.write('#%15s\t%16s\t%16s\t%16s\t%16s\n' % (reduceType, 'filmDens', 'filmDensErr', 'bulkDens', 'bulkDensErr')) # read in data and call jackknife method. n = 0 for temp in tempList: filmDens = pl.array([]) bulkDens = pl.array([]) with open(fileName, 'rb') as f: reader = csv.reader(f) for row in reader: if row[0][0] == '#': continue else: try: filmDens = pl.append(filmDens, float(row[n + 2])) bulkDens = pl.append(bulkDens, float(row[n + 3])) except: continue n += 2 filmDensAve, filmDensErr = aTools.jackknife(filmDens[skip:]) bulkDensAve, bulkDensErr = aTools.jackknife(bulkDens[skip:]) print 'filmDens = ', filmDensAve, ' +/- ', filmDensErr print 'bulkDens = ', bulkDensAve, ' +/- ', bulkDensErr filmDenses = pl.append(filmDenses, filmDensAve) filmDensErrs = pl.append(filmDensErrs, filmDensErr) bulkDenses = pl.append(bulkDenses, bulkDensAve) bulkDensErrs = pl.append(bulkDensErrs, bulkDensErr) fout.write('%16.8E\t%16.8E\t%16.8E\t%16.8E\t%16.8E\n' % (float(temp), filmDensAve, filmDensErr, bulkDensAve, bulkDensErr)) fout.close() # ========================================================================= # PLOTTING SECTION # ========================================================================= xLab = jk.getXlabel(reduceType) plotNum = 1 # PLOT ntWinding number squared if 'Ntwind' in estimList: pl.figure(plotNum) pl.errorbar(temps, ntWinds, ntWindErrs, fmt='o') pl.xlabel(xLab, fontsize=20) pl.ylabel(r'$\langle \Omega^2 \rangle$', fontsize=20) pl.grid(True) plotNum += 1 # PLOT specific heat vs. temperature if 'Estimator' in estimList: pl.figure(2) ax1 = pl.subplot(211) #if QHO: # plot analytic result # pl.plot(tempRange,CvAnalytic, label='Exact') pl.errorbar(temps, Cvs, CvsErr, label='PIMC', color='Violet', fmt='o') pl.ylabel('Specific Heat', fontsize=20) pl.grid(True) pl.legend(loc=2) # PLOT the energy vs. temperature pl.setp(ax1.get_xticklabels(), visible=False) ax2 = pl.subplot(212, sharex=ax1) #if QHO: # plot analytic result # pl.plot(tempRange,Eanalytic, label='Exact') pl.errorbar(temps, Es, EsErr, label='PIMC virial', color='Lime', fmt='o') pl.xlabel(xLab, fontsize=20) pl.ylabel('Energy [K]', fontsize=20) pl.grid(True) pl.legend(loc=2) plotNum += 1 # PLOT superfluid properties if 'Super' in estimList: pl.figure(plotNum) pl.errorbar(temps, rhos_rhos, rhos_rhoErr, fmt='o') pl.xlabel(xLab, fontsize=20) pl.ylabel('Superfluid Stiffness', fontsize=20) pl.grid(True) plotNum += 1 pl.figure(plotNum) pl.errorbar(temps, Wx2s, Wx2Err, fmt='o', label=r'$\langle W_x^2 \rangle$') pl.errorbar(temps, Wy2s, Wy2Err, fmt='o', label=r'$\langle W_y^2 \rangle$') pl.errorbar(temps, Wz2s, Wz2Err, fmt='o', label=r'$\langle W_z^2 \rangle$') pl.xlabel(xLab, fontsize=20) pl.ylabel(r'$\langle W_i^2 \rangle$', fontsize=20) pl.legend() pl.grid(True) plotNum += 1 pl.figure(plotNum) pl.errorbar(temps, Wz2s, Wz2Err, fmt='o', label=r'$\langle W_z^2 \rangle$') pl.xlabel(xLab, fontsize=20) pl.ylabel(r'$\langle W_z^2 \rangle$', fontsize=20) pl.legend() pl.grid(True) plotNum += 1 # PLOT film and bulk densities if 'Bipart' in estimList: pl.figure(plotNum) pl.errorbar(temps, filmDenses, filmDensErrs, label='film', fmt='o') pl.errorbar(temps, bulkDenses, bulkDensErrs, label='bulk', fmt='o') pl.xlabel(xLab, fontsize=20) pl.ylabel(r'$\mathrm{Density}\ [\AA^{-d}]$', fontsize=20) pl.legend() pl.grid(True) pl.show() # BELOW IS RESIDUE FROM A PREVIOUS VERSION OF THIS SCRIPT. # SOME OF IT MIGHT PROVE USEFUL. '''else: print 'Found existing data file in CWD.' temps, Es, EsErr, Cvs, CvsErr = pl.loadtxt( 'JackKnifeData_Cv.dat', unpack=True) if not QHO: temps, rhos_rhos, rhos_rhoErr, Wx2s, Wx2Err, Wy2s, Wy2Err, Wz2s, Wz2Err = pl.loadtxt( 'JackKnifeData_super.dat', unpack=True) if excVol: temps, filmDenses, filmDensErrs, bulkDenses, bulkDensErrs = pl.loadtxt( 'JackKnifeData_bipart.dat', unpack=True)''' '''
def main(): omega = True energy = False superFrac = True # --- Set up all options -------------------------------------------------- Ly = 12.0 # parse command line, getting algorithmic and plotting options. args = jk.parseCMD() reduceType = args.reduceType direc = args.fileNames[0] nCol = args.nCol nEst = args.nEst # some plotting color and label options xLab = jk.getXlabel(reduceType) extent = args.bulkSeparation colors = ['Salmon','MediumSpringGreen','DarkViolet','Fuchsia','Blue', 'Maroon'] if args.RandomColors: random.shuffle(colors) # set up figure that displays all data figg = pl.figure(1) ax = figg.add_subplot(111) pl.xlabel(r'$T\ [K]$', fontsize=20) pl.ylabel(r'$\langle \Omega \rangle$', fontsize=20) pl.grid(True) pl.xlim([0.4,2.6]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) figg2 = pl.figure(2) ax = figg2.add_subplot(111) pl.ylabel(r'$ \rho_s/\rho $', fontsize=20) pl.xlabel(r'$T\ [K]$', fontsize=20) pl.grid(True) pl.xlim([0.4,2.6]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) figg3 = pl.figure(3) ax = figg3.add_subplot(111) pl.ylabel(r'$ \rho_{\text{film}}\ [\si{\angstrom}^{-2}] $', fontsize=20) pl.xlabel(r'$T\ [K]$', fontsize=20) pl.grid(True) pl.xlim([0.4,2.6]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) figg4 = pl.figure(4) ax = figg4.add_subplot(111) pl.ylabel(r'$\langle \rho_{\text{bulk}} \rangle$', fontsize=20) pl.xlabel(r'$T\ [K]$', fontsize=20) pl.grid(True) pl.xlim([0.4,2.6]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # --- loop over all values of S ------------------------------------------- os.chdir(direc) Svals = glob.glob('S*') Svals = natsort.natsorted(Svals) print Svals for nS, Sval in enumerate(Svals): os.chdir(Sval) # store bulk separation value S = re.search(r'\d+',Sval).group(0) print S # set normalization if omega: normFactor = 4.0*(float(S)+Ly)**2 else: normFactor = 1.0 print normFactor # set label for plot #if 'distinguishable' in Sval: if 'noSwaps' in Sval: labell = 'S = '+str(S)+' '+r'$\si{\angstrom}$'', Boltzmannons' else: labell = 'S = '+str(S)+' '+r'$\si{\angstrom}$'+', Bosons' # get all temperature directory names Tdirs = sorted(glob.glob('T*')) # build array of norman winding values along with bins, for Lz plotting. windingAverages = pl.array([]) windingErrors = pl.array([]) filmAverages = pl.array([]) filmErrors = pl.array([]) bulkAverages = pl.array([]) bulkErrors = pl.array([]) superAverages = pl.array([]) superErrors = pl.array([]) Ts = pl.array([]) #Omegas = pl.array([]) #Errs = pl.array([]) #Films = pl.array([]) #Ferrs = pl.array([]) #Bulks = pl.array([]) #Berrs = pl.array([]) #Supers = pl.array([]) #Serrs = pl.array([]) # --- loop over all temperature values -------------------------------- for Tdir in Tdirs: os.chdir(Tdir) # build array of temperatures Ts = pl.append(Ts, float(Tdir[1:])) # --- angular winding --- f = glob.glob('*zAveragedNtwind*')[0] aCol = 3 sCol = 4 bCol = 5 avg,stdErr = cT.crunchZfile(f,aCol,sCol,bCol,normFactor) windingAverages = pl.append(windingAverages, avg) windingErrors = pl.append(windingErrors, stdErr) # --- film densities --- f = glob.glob('*zAveragedBipart*')[0] aCol = 0 sCol = 1 bCol = 2 avg,stdErr = cT.crunchZfile(f,aCol,sCol,bCol,1.0) filmAverages = pl.append(filmAverages, avg) filmErrors = pl.append(filmErrors,stdErr) # --- bulk densities --- aCol = 3 sCol = 4 bCol = 5 avg,stdErr = cT.crunchZfile(f,aCol,sCol,bCol,1.0) bulkAverages = pl.append(bulkAverages,avg) bulkErrors = pl.append(bulkErrors, stdErr) # --- superfluid fractions --- f = glob.glob('*zAveragedSuper*')[0] aCol = 0 sCol = 1 bCol = 2 avg,stdErr = cT.crunchZfile(f,aCol,sCol,bCol,1.0) superAverages = pl.append(superAverages,avg) superErrors = pl.append(superErrors, stdErr) # ---------------------- os.chdir('..') # add data to plot for given S value. pl.figure(1) pl.errorbar(Ts, windingAverages, windingErrors, fmt='-o', color=colors[nS], label=labell) pl.figure(2) pl.errorbar(Ts, superAverages, superErrors, fmt='-o', color=colors[nS], label=labell) pl.figure(3) pl.errorbar(Ts, filmAverages, filmErrors, fmt='-o', color=colors[nS], label=labell) pl.figure(4) pl.errorbar(Ts, bulkAverages, bulkErrors, fmt='-o', color=colors[nS], label=labell) os.chdir('..') pl.figure(1) pl.legend() pl.savefig('Omega_vs_T_allS.pdf', format='pdf', bbox_inches='tight') pl.figure(2) pl.legend() #pl.savefig('SuperFrac_vs_T_allS.pdf', format='pdf', # bbox_inches='tight') pl.figure(3) pl.legend() pl.savefig('FilmDensities_vs_T_allS.pdf', format='pdf', bbox_inches='tight') pl.figure(4) pl.legend() pl.show()