def freeze_frames(num_frames, current_frame): """Freeze frames for num_frames :num_frames: Int - Number of frames frozen :current_frame: Int :returns: Int - current_frame """ for _ in range(1, num_frames + 1): current_frame += 1 print("\n====================================") print(f"On freeze frame: {current_frame}") illu.save_figure(f"frames/ising/{current_frame:03}") pdf_frames.append(f"plots/frames/ising/{current_frame:03}.pdf") return current_frame
:sites: 1xn array of Site Objects :returns: [[min_x, max_x], [min_y, max_y]] """ pass if __name__ == '__main__': fig, ax = plt.subplots() system_size = 128 dimension = 2 # Color of flux c = const.COLOR_MAP["black"] # plot_setup(system_size) # Load graph sites = ani.process_graph_file(f"ising/large_cluster/largest_cluster", dimension) ax.axis('off') # movegraph = 128 * 50 movegraph = 90 # Plot all flux for site in sites: site.weights = [w / 2 for w in site.weights] site.i = site.i + movegraph site.neighbours = [n + movegraph for n in site.neighbours] site.plot_arrows_to_neighbours(ax, system_size, color=c, style='-') illu.save_figure(f"largest_cluster_testing_nolattice")
x, y = 6, 6 s = 2.5 color = "#d64d4d" figname = "percolatingFlux" illu.plot_lattice(x, y, size=1) # Simple loop cluster illu.fill_with_arrows([2, 3], [5, 3], size=s, color=color) illu.fill_with_arrows([5, 3], [5, 5], size=s, color=color) illu.fill_with_arrows([5, 5], [4, 5], size=s, color=color) illu.fill_with_arrows([4, 5], [4, 4], size=s, color=color) illu.fill_with_arrows([4, 4], [2, 4], size=s, color=color) illu.fill_with_arrows([2, 4], [2, 3], size=s, color=color) # Loop cluster with a link with 2 flux quanta illu.fill_with_arrows([0, 2], [1, 2], size=s, color=color) illu.fill_with_arrows([1, 2], [1, 3], size=s, color=color) illu.fill_with_arrows([1, 3], [0, 3], size=2.5 * s, color=color) illu.fill_with_arrows([0, 3], [0, 4], size=s, color=color) illu.fill_with_arrows([0, 4], [1, 4], size=s, color=color) illu.fill_with_arrows([1, 4], [1, 3], size=s, color=color) illu.fill_with_arrows([0, 3], [0, 2], size=s, color=color) # Percolating cluster illu.fill_with_arrows([-1, 1], [x + 1, 1], size=s, color=color) # plt.show() illu.save_figure(figname) # plt.savefig(f"./plots/{figname}.{form}",\ # bbox_inches='tight', format=form, dpi=1200)
Author: Simon Rydell Python Version: 3.7 ''' import matplotlib.pyplot as plt import helpers.illustrations as illu fig = plt.figure() ax = fig.add_subplot(111, aspect='equal') circle = plt.Circle((0.5, 0.5), 0.3, color="#202020") ax.add_artist(circle) plt.grid(color='k', linestyle='-', linewidth=1) ax.set_xticklabels([]) ax.set_yticklabels([]) plt.annotate(r"$\}$", fontsize=60, rotation=-90, xy=(0.2154, 0.00), xycoords='figure fraction') plt.annotate(r"$\epsilon$", fontsize=20, xy=(0.265, 0.), xycoords='figure fraction') illu.save_figure("circle_within_boxes") # plt.show()
simulation_data = process_file("./data/loop_lengths128x128.txt") clean_processed_data(simulation_data, exclude_system_size=[]) # plot_syssize_vs_looplength(simulation_data) errorbar_data = {} for size in simulation_data: errorbar_data[size] = [ np.average(simulation_data[size]), np.std(simulation_data[size]), len(simulation_data[size]) ] calc.plot_errorbars( errorbar_data, # label=r"$\bar{D}_H \pm \sigma_{\bar{D}_H}$", color=const.COLOR_MAP["black"]) plot_syssize_vs_fit(simulation_data) plt.title("Maximum loop length on a 2D Ising lattice") plt.xlabel("Linear system size") plt.ylabel("Loop length") plt.legend() savefig = False if savefig: illu.save_figure(f"maximum_loop_length_for_2D_Ising") plt.show()
ax.scatter(*site.convert_to_xyz(site.i, system_size), c=const.COLOR_MAP["red"], s=3) # site.plot_arrows_to_neighbours(ax, system_size, color=c) pdf_frames = [] theta = 30 current_frame = -1 max_angle = 360 for angle in np.arange(0, max_angle, 1): current_frame += 1 print("\n=========================") print(f"On frame number: {current_frame}") # Set viewing angle ax.view_init(theta, angle) illu.save_figure(f"frames/xy/largest_cluster/{current_frame:03}") pdf_frames.append( f"plots/frames/xy/largest_cluster/{current_frame:03}.pdf") # ax.cla() output_file = "plots/3dxy_largest_cluster_test" print(f"Merging the pdfs into {output_file}.pdf") ani.merge_pdfs(pdf_frames, output_file) # print(f"Creating the gif {output_file}.gif") # ani.pdf2gif(output_file, output_file)
# colors = ["#966842", "#f44747", "#eedc31", "#7fdb6a", "#0e68ce"] plt.loglog(xdata, fit_function(xdata, *opt_pars),\ c="#0e68ce",\ label=fr"$\propto L^{{ {opt_pars[1]:.2f} \pm {stderr_pars[opt_pars[1]]:.3f} }}$") # plt.loglog(xdata, fit_function(xdata, *[0.51, .25]),\ # c="#7fdb6a", label=r"$\propto L^{{ 2 - \eta_{Ising} }}$") # plt.loglog(xdata, fit_function(xdata, *[0.35, 0]),\ # c="#f44747", label=r"$\propto L^{{ 2 }}$") print(f"exponent = {opt_pars[1]:.6} +- {stderr_pars[opt_pars[1]]:.4}") if __name__ == '__main__': simulation_data = process_file("./data/total_loop_length.txt") clean_processed_data(simulation_data, exclude_system_size=[]) # plot_hist_of_error(simulation_data) plot_setup() plot_syssize_vs_looplength(simulation_data) plot_syssize_vs_fit(simulation_data) plt.legend() savefig = False if savefig: illu.save_figure("total_loop_length128x128Ising") # plt.savefig(f"./plots/total_loop_length128x128Ising.png",\ # bbox_inches='tight') plt.show()
for frame in range(227, last_simulation_frame + 1): # for frame in range(348, last_simulation_frame + 1): print("\n====================================") print(f"On frame: {frame}") plot_setup(system_size) # Load graph sites = ani.process_graph_file(f"ising/{frame}", dimension) # Plot all flux for site in sites: site.plot_arrows_to_neighbours(ax, system_size, color=c, style='-') illu.save_figure(f"frames/ising/{frame:03}") pdf_frames.append(f"plots/frames/ising/{frame:03}.pdf") if frame == last_simulation_frame: frame = freeze_frames(stop_frames, frame) # Clear axis for next plot ax.cla() largest_worm = calc.process_file("data/animation/ising/largest_worm", "xxxx", r"(\d*)") plot_setup(system_size) plot_largest_worm(largest_worm, sites, system_size, ax) print("Freeze frames for largest_worm")
import matplotlib.pyplot as plt import helpers.illustrations as illu import matplotlib.patches as patches import random fig = plt.figure() ax = fig.add_subplot(111, aspect='equal') ax.set_xticklabels([]) ax.set_yticklabels([]) # 4 small boxes l = 30 for x in range(l): for y in range(l): xy = (x, y) c = random.choice([ "#202020", "#202020", "#202020", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF" ]) ax.add_patch(patches.Rectangle(xy, 1, 1, facecolor=c, fill=True)) ax.set_xlim([-1, l + 1]) ax.set_ylim([-1, l + 1]) ax.axis('off') # plt.grid(color='k', linestyle='-', linewidth=1) illu.save_figure("hk_grid") # plt.show()
if __name__ == '__main__': simulation_data = process_file("./data/susceptibility.txt") clean_processed_data(simulation_data, exclude_system_size=[]) # plot_hist_of_error(simulation_data) plot_setup() # plot_syssize_vs_susc(simulation_data) errorbar_data = {} for size in simulation_data: errorbar_data[size] = [np.average(simulation_data[size]), np.std(simulation_data[size]), len(simulation_data[size])] calc.plot_errorbars(errorbar_data, label=r"$\bar{\chi} \pm \sigma_{\bar{\chi}}$", color=const.COLOR_MAP["black"]) plot_syssize_vs_fit(simulation_data) # plt.xticks(list(simulation_data.keys()), # list(simulation_data.keys())) plt.legend() savefig = True if savefig: illu.save_figure("susceptibility128x128Ising") # plt.show()