def system(self): return readsystem.readsystem(self.data)
else: print('What kind of file is this?!') exit(1) base = os.path.splitext(fname)[0] total_energy = np.array(data_loaded['total_energy'], dtype=float) histogram = np.array(data_loaded['histogram']) rel_bins = np.array(data_loaded['rel_bins']) bin_norm = data_loaded['bin_norm'] max_energy = data_loaded['max_energy'] min_energy = data_loaded['min_energy'] lnw = np.array(data_loaded['lnw']) lnw -= lnw.max() lnw -= np.log(np.sum(np.exp(lnw))) # w = w / sum(w) to normalize system = readsystem.readsystem(data_loaded) energy_boundaries = [max_energy] energy_per_rel_bin = 1/bin_norm*(max_energy-min_energy) for b in rel_bins: energy_boundaries.append(energy_boundaries[-1] - b*energy_per_rel_bin) energy_boundaries = np.array(energy_boundaries) np.savetxt(base+'-energy-boundaries.dat', energy_boundaries) mean_energy = total_energy/histogram #includes unbounded extremes np.savetxt(base+'-mean-energy.dat', mean_energy) np.savetxt(base+'-lnw.dat', lnw) #includes unbounded extremes with open(base+'-system.dat', 'w') as f:
remaining_entopy = 0 for i in range(1, len(above_count)): lnw.append(remaining_entopy + np.log(above_count[i] / count[i])) remaining_entopy = remaining_entopy + np.log(below_count[i] / count[i]) mean_energy.append(above_total[i] / above_count[i]) lnw.append(remaining_entopy) if replicas[-1]['below_count'] > 0: mean_energy.append(replicas[-1]['below_total'] / replicas[-1]['below_count']) else: mean_energy.append(np.NaN) lnw = np.array(lnw) lnw -= np.log(np.sum(np.exp(lnw))) # w = w / sum(w) to normalize mean_energy = np.array(mean_energy) energy_boundaries = [] for i in range(1, len(above_count)): energy_boundaries.append(replicas[i]['cutoff_energy']) energy_boundaries = np.array(energy_boundaries) system = readsystem.readsystem(replicas[0]) np.savetxt(base + '-energy-boundaries.dat', energy_boundaries) np.savetxt(base + '-mean-energy.dat', mean_energy) np.savetxt(base + '-lnw.dat', lnw) #includes unbounded extremes with open(base + '-system.dat', 'w') as f: yaml.safe_dump(system, f)