def calcCvNoWHAM(binenergy, visits, Tlist, NDOF): """compute the heat capacity using the direct calculation, i.e. not WHAM This method computes <E^2> - <E>^2 directly from the visits histogram. The heat capacity is returned at the temperatures of the replicas. Parameters ---------- binenergy : ndarray the (lower bound) energy of the bins visits : 2d array visits[r,b] is the number of visits in replica r to energy bin b Tlist : array the temperatures of the replicas ndof : int the number of degrees of freedom in the system """ nreps, nbins = np.shape(visits) cvdata = np.zeros([nreps, 6]) for i in range(nreps): cvdata[i,0] = Tlist[i] m, std = utils.wstd(binenergy, visits[i,:]) cvdata[i,4] = m cvdata[i,3] = std #print std, Tlist[i], NDOF, std**2, Tlist[i]**2 cv = float(NDOF)/2. + std**2 / Tlist[i]**2 cvdata[i,5] = cv return cvdata
def calcCvNoWHAM(binenergy, visits, Tlist, NDOF): """compute the heat capacity using the direct calculation, i.e. not WHAM This method computes <E^2> - <E>^2 directly from the visits histogram. The heat capacity is returned at the temperatures of the replicas. Parameters ---------- binenergy : ndarray the (lower bound) energy of the bins visits : 2d array visits[r,b] is the number of visits in replica r to energy bin b Tlist : array the temperatures of the replicas ndof : int the number of degrees of freedom in the system """ nreps, nbins = np.shape(visits) cvdata = np.zeros([nreps, 6]) for i in range(nreps): cvdata[i, 0] = Tlist[i] m, std = utils.wstd(binenergy, visits[i, :]) cvdata[i, 4] = m cvdata[i, 3] = std #print std, Tlist[i], NDOF, std**2, Tlist[i]**2 cv = float(NDOF) / 2. + std**2 / Tlist[i]**2 cvdata[i, 5] = cv return cvdata
def readVisitsFiles(): #load a Visits.his file to get the energy histograms dirlist = plotVisits.getDirList() vis = plotVisits.listVisitsFiles(dirlist[0]) vis = vis[-1] fname = vis.fname allvisits = [] for d in dirlist: visits = utils.VisitsHis( d+"/" + fname ) allvisits.append(visits) means = [] stds = [] for v in allvisits: v.read() energies, visits = v.getHis() m, std = utils.wstd(energies, visits) means.append(m) stds.append(std) return np.array(means), np.array(stds)
def checkWHAM(binenergy, visits, cvdata, Tlist): for i in range(len(Tlist)): m, std = utils.wstd(binenergy, visits[i,:]) print "wham_check", Tlist[i], m, std
def checkWHAM(binenergy, visits, cvdata, Tlist): for i in range(len(Tlist)): m, std = utils.wstd(binenergy, visits[i, :]) print "wham_check", Tlist[i], m, std