def plot_from_data(T_data, C_data, fname=None, ax=None, axins=None, Tmax=0.25): if fname is not None: base = fname[:-4] method = os.path.split(fname)[-1].split('+')[0] if method == 'itwl': label = r'$1/t$-WL' + r'-$E_{barr}$=0.' + styles.get_barrier( base)[0] if method == 'sad': label = r'SAD' + r'-$E_{barr}$=0.' + styles.get_barrier(base)[0] if method == 'z': label = r'ZMC' + r'-$E_{barr}$=0.' + styles.get_barrier(base)[0] if method == 'tem': label = r'TEM' + r'-$E_{barr}$=0.' + styles.get_barrier(base)[0] else: base = None method = None label = 'exact' _, t_peak, _ = _set_temperatures(ax=ax, axins=axins, Tmax=Tmax) ax.plot(T_data, C_data, label=label, marker=styles.marker(base), color=styles.color(base), linestyle=styles.linestyle(base), markevery=10) # inset axes.... #axins = ax.inset_axes( 0.5 * np.array([1, 1, 0.47/0.5, 0.47/0.5]))#[0.005, 0.012, 25, 140]) axins.plot(T_data, C_data, label=label, marker=styles.marker(base), color=styles.color(base), linestyle=styles.linestyle(base), markevery=10) x1, x2, y1, y2 = 0.002, 0.009, 5, 30 # axins.set_xlim(x1, x2) axins.set_ylim(y1, y2)
def plot(S, fname=None, ax=None, axins=None, Tmax=0.25): timer = Timer(f'heat_capacity.plot {fname}') if fname is not None: base = fname[:-8] method = base[:base.find('-')] else: base = None method = None t_low, t_peak, t_high = _set_temperatures(ax=ax, axins=axins, Tmax=Tmax) timer_low_T = Timer('C for low T') c_low = np.array([C(T, S) for T in t_low]) del timer_low_T timer_peak = Timer('C for peak T') c_peak = np.array([C(T, S) for T in t_peak]) del timer_peak c_high = np.array([C(T, S) for T in t_high]) ax.plot(np.concatenate((t_low, t_peak, t_high)), np.concatenate((c_low, c_peak, c_high)), label=styles.pretty_label(base), color=styles.color(base), linestyle=styles.linestyle(base), markevery=10) # inset axes.... #axins = ax.inset_axes( 0.5 * np.array([1, 1, 0.47/0.5, 0.47/0.5]))#[0.005, 0.012, 25, 140]) axins.plot(np.concatenate((t_low, t_peak, t_high)), np.concatenate((c_low, c_peak, c_high)), label=styles.pretty_label(base), marker=styles.marker(base), color=styles.color(base), linestyle=styles.linestyle(base), markevery=10)
def plot(S, fname=None, ax=None, axins=None, Tmax=0.25): timer = Timer(f'heat_capacity.plot {fname}') if fname is not None: base = fname[:-8] method = base[:base.find('-')] else: base = None method = None # print('peak should be at', T_peak) T_width = T_peak * 0.7 # this is just a guess t_low = np.linspace(T_peak / 2, T_peak - T_width, 50) t_peak = np.linspace(T_peak - T_width, T_peak + T_width, 150) axins.set_xlim(T_peak - T_width, T_peak + T_width) t_high = np.linspace(T_peak + T_width, Tmax, 50) try: c_low = np.loadtxt(f'{base}-cv_low_saved.txt') except: timer_low_T = Timer('C for low T') c_low = np.array([C(T, S) for T in t_low]) del timer_low_T np.savetxt(f'{base}-cv_low_saved.txt', c_low) try: c_peak = np.loadtxt(f'{base}-cv_peak_saved.txt') except: c_peak = np.array([C(T, S) for T in t_peak]) np.savetxt(f'{base}-cv_peak_saved.txt', c_peak) try: c_high = np.loadtxt(f'{base}-cv_high_saved.txt') except: c_high = np.array([C(T, S) for T in t_high]) np.savetxt(f'{base}-cv_high_saved.txt', c_high) if method in {'wl', 'itwl', 'sad'}: ax.plot(np.concatenate((t_low, t_peak, t_high)), np.concatenate((c_low, c_peak, c_high)), label=styles.pretty_label(base), marker=styles.marker(base), color=styles.color(base), linestyle=styles.linestyle(base), markevery=10) elif method == 'z': ax.plot(np.concatenate((t_low, t_peak, t_high)), np.concatenate((c_low, c_peak, c_high)), label=styles.pretty_label(base), color=styles.color(base), linestyle=styles.linestyle(base), markevery=10) else: ax.plot(np.concatenate((t_low, t_peak, t_high)), np.concatenate((c_low, c_peak, c_high)), ':', label='exact', linewidth=2, color='tab:cyan') # inset axes.... #axins = ax.inset_axes( 0.5 * np.array([1, 1, 0.47/0.5, 0.47/0.5]))#[0.005, 0.012, 25, 140]) if method in {'wl', 'itwl', 'sad'}: precision = base[base.rfind('-') + 1:] axins.plot(t_peak, c_peak, label=styles.pretty_label(base), marker=styles.marker(base), color=styles.color(base), linestyle=styles.linestyle(base), markevery=10) elif method == 'z': axins.plot(t_peak, c_peak, label=styles.pretty_label(base), color=styles.color(base), linestyle=styles.linestyle(base), markevery=10) else: axins.plot(t_peak, c_peak, ':', label='exact', linewidth=2, color='tab:cyan')
label = r'ZMC' + r'-$E_{barr}$=0.' + styles.get_barrier( base)[0] if method == 'tem': label = r'TEM' + r'-$E_{barr}$=0.' + styles.get_barrier( base)[0] fname = tail + 'seed-' + str(seed) + front data = np.load(fname) for k in data.keys(): print(k) E = data['E'] error_dist = data['error_dist_S'] plt.figure('Entropy error distribution') plt.plot(E, error_dist, label=label, marker=styles.marker(base), color=styles.color(base), linestyle=styles.linestyle(base), markevery=75) plt.figure('Canonical error incorrect peak') plt.plot(data['E_dist'], data['can_error_low_T'], label=label, marker=styles.marker(base), color=styles.color(base), linestyle=styles.linestyle(base), markevery=75) plt.figure('Canonical error phase transition') plt.plot(data['E_dist'], data['can_error_high_t'], label=label,
paths.append(fname) for fname in paths: print() start_fname = time.process_time() base = fname[:-8] method = base[:base.find('-')] energy_boundaries, mean_e, my_lnw, my_system, p_exc = compute.read_file(base) # Create a function for the entropy l_function, eee, sss = compute.linear_entropy(energy_boundaries, mean_e, my_lnw) plt.figure('latest-entropy') #plt.plot(E, normalize_S(l_function(E)), label=base) if method in {'wl','itwl','sad'}: plt.plot(E, normalize_S(l_function(E)), label=base, marker = styles.marker(base), color = styles.color(base), linestyle= styles.linestyle(base), markevery=100) elif method == 'z': plt.plot(E, normalize_S(l_function(E)), label=base, color = styles.color(base), linestyle= styles.linestyle(base)) plt.figure('latest heat capacity') heat_capacity.plot(l_function, fname=fname,ax=ax, axins=axins) # correct_Cv = [heat_capacity.C(t,l_function) for t in T] # if method in {'wl','itwl','sad'}: # plt.plot(T, correct_Cv, label=base, marker = markers[precision], color = colors[method], linestyle= linestyles[method], markevery=5) # elif method == 'z': # plt.plot(T, correct_Cv, label=base, color = colors[method], linestyle= linestyles[method]) start_well_histogram = time.process_time() plt.figure('fraction-well') mean_which = np.loadtxt(f'{base}-which.dat')
def _plot_from_data(self, ax, axins, fname, data=None, data_bounds=None, subplot = None, dump_into_thesis = None): if data is None: data = self._query_fname(fname) if data_bounds is not None: lower_data, upper_data = data_bounds base = fname[:-4] method = os.path.split(fname)[-1].split('+')[0] print(method) if method == 'itwl': label = r'$1/t$-WL' + r'-$E_{barr}$=0.'+styles.get_barrier(base)[0] if method == 'sad': label = r'SAD' + r'-$E_{barr}$=0.'+styles.get_barrier(base)[0] if method == 'z': label = r'ZMC' + r'-$E_{barr}$=0.'+styles.get_barrier(base)[0] if method == 'tem': label = r'TEM' + r'-$E_{barr}$=0.'+styles.get_barrier(base)[0] if method in {'wl','itwl','sad', 'z'}: plt.figure('fraction-well') plt.plot(data['mean_e'], data['mean_which'], label=label) if len(data['hist']) != 0: plt.figure('histogram') plt.plot(data['mean_e'], data['hist'], label=label) plt.figure('latest-entropy') plt.plot(data['E'][:len(data['S'])], data['S'], label=label, marker = styles.marker(base), color = styles.color(base), linestyle= styles.linestyle(base), markevery=25) plt.figure('convergence') plt.loglog(data['moves'], data['errors_S'], label=label, marker = styles.marker(base), color = styles.color(base), linestyle= styles.linestyle(base), markevery=4) elif method == 'z': plt.plot(data['E'], data['S'], label=label, color = styles.color(base), linestyle= styles.linestyle(base)) if data_bounds is not None: plt.fill_between(lower_data['moves'], lower_data['errors_S'], upper_data['errors_S'], color = styles.color(base), linestyle=styles.linestyle(base), linewidth = 2, alpha = 0.2) heat_capacity.plot_from_data(data['T'][:len(data['C'])], data['C'], fname=fname, ax=ax, axins=axins) plt.figure('convergence-heat-capacity') plt.loglog(data['moves'], data['errors_C'], label=label, marker = styles.marker(base), color = styles.color(base), linestyle= styles.linestyle(base), markevery=4) if data_bounds is not None: plt.fill_between(lower_data['moves'], lower_data['errors_C'], upper_data['errors_C'], color = styles.color(base), alpha = 0.2) if False:#subplot is not None: axs = subplot[0] axins_subplot = subplot[1] if method in {'wl','itwl','sad'}: axs['(c)'].plot(data['E'][:len(data['S'])], data['S'], label=label, marker = styles.marker(base), color = styles.color(base), linestyle= styles.linestyle(base), markevery=250) elif method == 'z': axs['(c)'].plot(data['E'], data['S'], label=label, color = styles.color(base), linestyle= styles.linestyle(base)) heat_capacity.plot_from_data(data['T'][:len(data['C'])], data['C'], fname=fname, ax=axs['(d)'], axins=axins_subplot) plt.figure('convergence') if method in {'wl','itwl','sad'}: axs['(a)'].loglog(data['moves'], data['errors_S'], label=label, marker = styles.marker(base), color = styles.color(base), linestyle= styles.linestyle(base), markevery=2) elif method == 'z': axs['(a)'].loglog(data['moves'], data['errors_S'], label=label, color = styles.color(base), linestyle= styles.linestyle(base), linewidth = 3) if data_bounds is not None: axs['(a)'].fill_between(lower_data['moves'], lower_data['errors_S'], upper_data['errors_S'], color = styles.color(base), linestyle=styles.linestyle(base), linewidth = 2, alpha = 0.2) plt.figure('convergence-heat-capacity') if method in {'wl','itwl','sad'}: axs['(b)'].loglog(data['moves'], data['errors_C'], label=label, marker = styles.marker(base), color = styles.color(base), linestyle= styles.linestyle(base), markevery=2) elif method == 'z': axs['(b)'].loglog(data['moves'], data['errors_C'], label=label, color = styles.color(base), linestyle= styles.linestyle(base), linewidth = 3) if data_bounds is not None: axs['(b)'].fill_between(lower_data['moves'], lower_data['errors_C'], upper_data['errors_C'], color = styles.color(base), alpha = 0.2)