Loading 2_offset_hierarchical_struct/plot_broken_edges.py +40 −3 Original line number Diff line number Diff line Loading @@ -134,6 +134,42 @@ def plot_average_per_height(average_heights_dict): axs[index].set_ylabel("Average number of broken edges") axs[index].set_title(f"Offset {offset}") plt.show() fig.savefig("avg_broken_edges_at_height.png") def get_current_toughness_dict(filepaths_dict : dict): output_dict = {} for offset, filepath in filepaths_dict.items(): output_dict[offset] = {} filepath = filepath[0].split('/')[1] + "/strength" with open(filepath, 'r') as file: data_dict = {} data_list = [] data_list = [line.rstrip() for line in file] data_list = [line.split(" ") for line in data_list] data_dict["ipavg"] = float(data_list[0][0]) data_dict["ipsig"] = float(data_list[0][1]) data_dict["tavg"] = float(data_list[1][0]) data_dict["tsig"] = float(data_list[1][1]) output_dict[offset] = data_dict return output_dict def plot_current_and_toughness(filepaths_dict : dict): data_dict = get_current_toughness_dict(filepaths_dict) fig, axs = plt.subplots(1,2) for offset, subdict in data_dict.items(): axs[0].errorbar(offset, subdict["ipavg"], yerr = subdict["ipsig"], fmt='o', color = 'black') axs[1].errorbar(offset, subdict["tavg"], yerr = subdict["tsig"], fmt='o', color = 'black') axs[0].set_xlabel("Offset") axs[1].set_xlabel("Offset") axs[0].set_ylabel("Peak current") axs[1].set_ylabel("Toughness") plt.show() fig.savefig("max_current_toughness_at_offset.png") Loading @@ -157,6 +193,7 @@ if __name__ == "__main__": 10 : ["/offset_10/FDB_PARSOL_SIRC-FCVC_SOG-IVCG_HFBA_CPC-NIC_-_{number}.h5".format(number=i) for i in range(1000, 1050)] } os.chdir("/FASTTEMP/p7/lpyka/hierarchical_interface/2_offset_hierarchical_struct") ''' data_dict = get_data_dict(filepaths_dict) # broken_edges = [] Loading @@ -172,9 +209,9 @@ if __name__ == "__main__": for offset, broken_edges in data_dict.items(): broken_edges_coordinates_dict[offset] = get_vertical_edges_coordinates(broken_edges, nx, ny) average_heights_dict[offset] = get_average_heights_dict(broken_edges_coordinates_dict[offset]) plot_average_per_height(average_heights_dict) ''' plot_current_and_toughness(filepaths_dict) #plot_average_per_height(average_heights_dict) #plot_distribution_of_height(broken_edges_coordinates_dict) #plot_edges(broken_edges_coordinates) Loading Loading
2_offset_hierarchical_struct/plot_broken_edges.py +40 −3 Original line number Diff line number Diff line Loading @@ -134,6 +134,42 @@ def plot_average_per_height(average_heights_dict): axs[index].set_ylabel("Average number of broken edges") axs[index].set_title(f"Offset {offset}") plt.show() fig.savefig("avg_broken_edges_at_height.png") def get_current_toughness_dict(filepaths_dict : dict): output_dict = {} for offset, filepath in filepaths_dict.items(): output_dict[offset] = {} filepath = filepath[0].split('/')[1] + "/strength" with open(filepath, 'r') as file: data_dict = {} data_list = [] data_list = [line.rstrip() for line in file] data_list = [line.split(" ") for line in data_list] data_dict["ipavg"] = float(data_list[0][0]) data_dict["ipsig"] = float(data_list[0][1]) data_dict["tavg"] = float(data_list[1][0]) data_dict["tsig"] = float(data_list[1][1]) output_dict[offset] = data_dict return output_dict def plot_current_and_toughness(filepaths_dict : dict): data_dict = get_current_toughness_dict(filepaths_dict) fig, axs = plt.subplots(1,2) for offset, subdict in data_dict.items(): axs[0].errorbar(offset, subdict["ipavg"], yerr = subdict["ipsig"], fmt='o', color = 'black') axs[1].errorbar(offset, subdict["tavg"], yerr = subdict["tsig"], fmt='o', color = 'black') axs[0].set_xlabel("Offset") axs[1].set_xlabel("Offset") axs[0].set_ylabel("Peak current") axs[1].set_ylabel("Toughness") plt.show() fig.savefig("max_current_toughness_at_offset.png") Loading @@ -157,6 +193,7 @@ if __name__ == "__main__": 10 : ["/offset_10/FDB_PARSOL_SIRC-FCVC_SOG-IVCG_HFBA_CPC-NIC_-_{number}.h5".format(number=i) for i in range(1000, 1050)] } os.chdir("/FASTTEMP/p7/lpyka/hierarchical_interface/2_offset_hierarchical_struct") ''' data_dict = get_data_dict(filepaths_dict) # broken_edges = [] Loading @@ -172,9 +209,9 @@ if __name__ == "__main__": for offset, broken_edges in data_dict.items(): broken_edges_coordinates_dict[offset] = get_vertical_edges_coordinates(broken_edges, nx, ny) average_heights_dict[offset] = get_average_heights_dict(broken_edges_coordinates_dict[offset]) plot_average_per_height(average_heights_dict) ''' plot_current_and_toughness(filepaths_dict) #plot_average_per_height(average_heights_dict) #plot_distribution_of_height(broken_edges_coordinates_dict) #plot_edges(broken_edges_coordinates) Loading