rc('text', usetex=True) def fit_function(x, a, b): """Function to fit against y = a * x + b :x: Float - Known data :a: Float - Unknown data :b: Float - Unknown data :returns: Float """ return a * x + b if __name__ == '__main__': # Format: Relative_box_size avg(D_H) std(D_H) Num_measurements simulation_data = calc.process_file("./h_dims", key=r"L=(\d+):", xy=r"(\d*\.?\d*) (\d*\.?\d*) (\d*\.?\d*) (\d*\.?\d*)") # Necessary for the zoomed inset # fig, ax = plt.subplots() system_size = 128 rel_box_sizes, avg_dhs, std_dhs, num_measurements = simulation_data[system_size] skip_boxes = [1/2, 1/4] # skip_boxes = [] c = const.COLOR_MAP["black"] unique_rel_boxes = list(reversed(sorted(list(set(rel_box_sizes))))) for sb in skip_boxes: unique_rel_boxes.remove(sb) x_relbox = [] y_lnnumboxes = []
import re import numpy as np import matplotlib.pyplot as plt from matplotlib import rc import helpers.calc as calc import helpers.constants as const import helpers.illustrations as illu rc('font', **{'family': 'serif', 'serif': ['DejaVu Sans']}) rc('text', usetex=True) if __name__ == '__main__': system_size = 64 # {system_size: [rel_box_size, avg(D_H), std(D_H), num_measurements], ...} simulation_data = calc.process_file( f"./data/h_dimensionXY", key=r"L=(\d*\.?\d*):", xy=r"(\d*\.?\d*) (\d*\.?\d*) (\d*\.?\d*) (\d*\.?\d*)") # Necessary for the zoomed inset fig, ax = plt.subplots() # Clear simulation data except system_size data = simulation_data[system_size] simulation_data.clear() simulation_data[system_size] = data ignore_relbox_sizes = [1 / 2] labeled = False color = const.COLOR_MAP["black"] for size in simulation_data:
''' Brief: Correct an error I made where all winding numbers were multiplied by 3 File name: plot_winding.py Author: Simon Rydell Python Version: 3.7 ''' import re import numpy as np import matplotlib.pyplot as plt from matplotlib import rc import helpers.calc as calc import helpers.constants as const import helpers.illustrations as illu rc('font', **{'family': 'serif', 'serif': ['DejaVu Sans']}) rc('text', usetex=True) if __name__ == '__main__': simulation_data = calc.process_file("./data/windingnum_temp_closetoTc.txt", key=r"L=(\d+):", xy=r"(\d*\.?\d*) (\d*\.?\d*)") with open("test.out", 'w') as f: for size in simulation_data: f.write(f"L={int(size)}:\n") for i in range(len(simulation_data[size][0])): winding_number = simulation_data[size][0][i] temperature = simulation_data[size][1][i] f.write(f"{winding_number/3} {temperature}\n")
# 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") frame = freeze_frames(stop_frames, frame) # Draw separating lines lines = [[ [[system_size / 2 - 0.5, system_size / 2 - 0.5], [-0.5, system_size - 0.5]], [[-0.5, system_size - 0.5], [system_size / 2 - 0.5, system_size / 2 - 0.5]], ],
import matplotlib.pyplot as plt from matplotlib import rc import helpers.calc as calc import helpers.constants as const import helpers.illustrations as illu from scipy.optimize import curve_fit rc('font', **{'family': 'serif', 'serif': ['DejaVu Sans']}) rc('text', usetex=True) if __name__ == '__main__': dimension = 2 # BM_singlevec/128 41051 ns 41025 ns 16924 singlevec_data = calc.process_file( f"./data/benchmark_latticeimpl.txt", key=r"xxxx", xy= r"BM_singlevec/(\d*\.?\d*)\s*(\d*\.?\d*) ns\s*(\d*\.?\d*) ns \s* (\d*\.?\d*)" ) multivec_data = calc.process_file( f"./data/benchmark_latticeimpl.txt", key=r"xxxx", xy= r"BM_vecofvecs/(\d*\.?\d*)\s*(\d*\.?\d*) ns\s*(\d*\.?\d*) ns \s* (\d*\.?\d*)" ) sizes_single, _time, cpu_time_single, _num_measurents = singlevec_data[0] sizes_multi, _time, cpu_time_multi, _num_measurents = multivec_data[0] # Normalize cpu_time_single cpu_time_single = [
def fit_function(x, a, exponent, b): """Function to fit against y = a * x^(exponent) :x: Float - Known data :a: Float - Unknown data :exponent: Float - Unknown data :returns: Float """ return a * np.power(x, exponent) + b if __name__ == '__main__': # Format: avg(E) std(E) Num_measurements # {system_size: [avg(E), std(E), num_measurements], ...} simulation_data = calc.process_file(f"./energy_sizeXY", key=r"L=(\d*\.?\d*):", xy=r"(\d*\.?\d*) (\d*\.?\d*) (\d*\.?\d*)") # Necessary for the zoomed inset fig, ax = plt.subplots() color = const.COLOR_MAP["black"] avg_es = [] for size in simulation_data: if 2 * size in simulation_data: avg_es.append(calc.add_mean(simulation_data[size][0])) simulation_data[size][0] = calc.add_mean(simulation_data[2 * size][0]) - calc.add_mean(simulation_data[size][0]) simulation_data[size][1] = calc.add_std(simulation_data[2 * size][1]) - calc.add_std(simulation_data[size][1]) simulation_data[size][2] = sum(simulation_data[size][2])
import re import numpy as np import matplotlib.pyplot as plt from matplotlib import rc import helpers.calc as calc import helpers.constants as const import helpers.illustrations as illu rc('font', **{'family': 'serif', 'serif': ['DejaVu Sans']}) rc('text', usetex=True) if __name__ == '__main__': # simulation_data = calc.process_file("./data/xy_winding.txt", # key=r"L=(\d+):", xy=r"(\d*\.?\d*) (\d*\.?\d*) (\d*\.?\d*) (\d*\.?\d*)") simulation_data = calc.process_file("../winding", key=r"L=(\d+):", xy=r"(\d*\.?\d*) (\d*\.?\d*) (\d*\.?\d*) (\d*\.?\d*)") # Should the zoomed inset be plotted? zoomed = True # Necessary for the zoomed inset fig, ax = plt.subplots() colors = const.GRADIENT["blue"] c_id = -1 plot_dict = {} zoomed_data = {} # Approximations of Tc closest_temps_to_tc = [0.333, 0.334] closest_ws_to_tc = [] for size in simulation_data:
import re import numpy as np import matplotlib.pyplot as plt from matplotlib import rc import helpers.calc as calc import helpers.constants as const import helpers.illustrations as illu rc('font', **{'family': 'serif', 'serif': ['DejaVu Sans']}) rc('text', usetex=True) if __name__ == '__main__': system_size = 128 # {box_size: [avg(D_H), std(D_H)], ...} simulation_data = calc.process_file( f"./data/hdims/box_size{system_size}.txt", key=r"box_size=(\d*\.?\d*):", xy=r"(\d*\.?\d*) (\d*\.?\d*e?-?\d*)") ignore_sizes = [64.0, 32.0] for size in ignore_sizes: simulation_data.pop(size) labeled = False color = const.COLOR_MAP["black"] for size in simulation_data: avg_dh = simulation_data[size][0][0] std_dh = simulation_data[size][1][0] if size == min(list(simulation_data)): print(f"D_H = {avg_dh:.5f} += {std_dh:.0e}") if not labeled:
:x: Know input :a: Unknown fit data :b: Unknown fit data :c: Unknown fit data :returns: a * log2(x) * x^b + c """ return a * np.log2(x) * np.power(x, b) + c if __name__ == '__main__': dimension = 2 # {box_size: [avg(D_H), std(D_H)], ...} # BM_DivideGraph/4 12078 ns 12064 ns 58434 simulation_data = calc.process_file(f"./data/benchmark_graphdiv.txt", key=r"xxxx", xy=r"BM_DivideGraph/(\d*\.?\d*)\s*(\d*\.?\d*) ns\s*(\d*\.?\d*) ns \s* (\d*\.?\d*)") sizes, time, cpu_time, num_measurents = simulation_data[0] # Normalize cpu_time cpu_time = [t / cpu_time[0] for t in cpu_time] # Get total number of sites sites = [np.power(s, dimension) for s in sizes] cpu_time = np.array(cpu_time) sites = np.array(sites) # fit_data_linear = calc.bootstrap(fit_func_linear, sites, cpu_time, 400) # fit_data_log = calc.bootstrap(fit_func_log, sites, cpu_time, 400)