From f2361d639b481034613af2b211135e5c51a09788 Mon Sep 17 00:00:00 2001 From: Sebastian Schachten Date: Thu, 23 Jan 2025 13:16:37 +0100 Subject: [PATCH 1/2] updated some script doc strings to better distinguish between them removed the part "complex_permeability" for 3F46 under "measurements", this is the permeability_data and was wrong sorted (data is still in database under "permeability_data") updated "permeability_data" of 3F46 in database, the data was wrong calculated --- materialdatabase/data/material_data_base.json | 552 +++++------------- ...tasheet_permeability_data_into_database.py | 123 ++-- .../write_datasheet_plots_into_database.py | 9 +- ...ility_data_from_datasheet_into_database.py | 19 +- ...y_data_from_datasheet_into_database_TDK.py | 8 +- 5 files changed, 244 insertions(+), 467 deletions(-) diff --git a/materialdatabase/data/material_data_base.json b/materialdatabase/data/material_data_base.json index e98414f..9ba61ce 100644 --- a/materialdatabase/data/material_data_base.json +++ b/materialdatabase/data/material_data_base.json @@ -23488,8 +23488,52 @@ ], "permeability_data": [ { - "temperature": 100, - "frequency": 1000000.0, + "mu_r_abs": [ + 850.299, + 872.052, + 876.271, + 880.027, + 882.902, + 884.771, + 886.414, + 886.88, + 886.903, + 887.142, + 890.458, + 892.58, + 892.712, + 894.801, + 898.42, + 902.103, + 905.613, + 907.611, + 909.41, + 912.056, + 915.611 + ], + "mu_phi_deg": [ + 0.86, + 0.816, + 0.807, + 0.8, + 0.797, + 0.782, + 0.772, + 0.768, + 0.766, + 0.775, + 0.787, + 0.814, + 0.846, + 0.884, + 0.925, + 0.968, + 1.015, + 1.062, + 1.131, + 1.199, + 1.257 + ], "flux_density": [ 0.0, 0.01, @@ -23513,56 +23557,56 @@ 0.046, 0.048 ], + "frequency": 1000000.0, + "temperature": 100 + }, + { "mu_r_abs": [ - 850.133, - 873.721, - 878.377, - 881.868, - 885.113, - 886.97, - 888.201, - 888.498, - 888.498, - 888.94, - 893.635, - 894.366, - 895.072, - 897.631, - 900.786, - 904.501, - 908.198, - 909.685, - 911.946, - 914.415, - 918.904 + 922.705, + 933.763, + 935.934, + 937.843, + 939.294, + 940.24, + 941.057, + 941.392, + 943.101, + 944.905, + 948.258, + 951.692, + 953.929, + 957.173, + 960.872, + 965.709, + 970.455, + 973.279, + 976.188, + 980.34, + 985.025 ], "mu_phi_deg": [ - 0.807, - 0.796, - 0.794, - 0.792, - 0.781, - 0.757, - 0.758, - 0.755, - 0.753, - 0.762, - 0.775, - 0.8, - 0.838, - 0.879, - 0.915, - 0.973, - 1.008, - 1.057, - 1.138, - 1.18, - 1.242 - ] - }, - { - "temperature": 100, - "frequency": 2000000.0, + 0.572, + 0.906, + 0.972, + 1.017, + 1.056, + 1.091, + 1.144, + 1.174, + 1.249, + 1.312, + 1.387, + 1.501, + 1.624, + 1.741, + 1.835, + 1.956, + 2.106, + 2.249, + 2.362, + 2.492, + 2.616 + ], "flux_density": [ 0.0, 0.01, @@ -23572,70 +23616,70 @@ 0.018, 0.02, 0.022, - 0.025, - 0.027, - 0.029, - 0.031, - 0.033, - 0.035, - 0.037, - 0.039, - 0.041, - 0.043, - 0.045, - 0.047, - 0.049 + 0.024, + 0.026, + 0.028, + 0.03, + 0.032, + 0.034, + 0.036, + 0.038, + 0.04, + 0.042, + 0.044, + 0.046, + 0.048 ], + "frequency": 2000000.0, + "temperature": 100 + }, + { "mu_r_abs": [ - 922.635, - 934.463, - 936.86, - 938.625, - 940.385, - 941.766, - 942.354, - 943.028, - 945.238, - 947.035, - 950.465, - 953.629, - 956.317, - 959.318, - 962.971, - 968.792, - 972.362, - 975.664, - 978.984, - 983.882, - 987.927 + 994.966, + 995.444, + 995.494, + 995.523, + 995.536, + 995.548, + 995.561, + 995.573, + 995.586, + 995.598, + 995.611, + 995.624, + 995.704, + 996.561, + 998.748, + 999.871, + 1001.786, + 1004.117, + 1005.018, + 1007.547, + 1010.455 ], "mu_phi_deg": [ - 0.589, - 0.881, - 0.94, - 0.997, - 1.026, - 1.069, - 1.135, - 1.161, - 1.23, - 1.289, - 1.373, - 1.491, - 1.627, - 1.731, - 1.834, - 1.973, - 2.146, - 2.263, - 2.37, - 2.521, - 2.578 - ] - }, - { - "temperature": 100, - "frequency": 3000000.0, + 3.116, + 3.737, + 3.803, + 3.839, + 3.841, + 3.845, + 3.874, + 3.891, + 3.879, + 3.853, + 3.854, + 3.873, + 3.927, + 3.979, + 4.014, + 4.037, + 4.082, + 4.136, + 4.192, + 4.26, + 4.326 + ], "flux_density": [ 0.0, 0.01, @@ -23643,308 +23687,28 @@ 0.012, 0.013, 0.014, + 0.015, 0.016, 0.017, 0.018, 0.019, 0.02, - 0.021, 0.022, 0.023, 0.024, 0.025, 0.026, + 0.027, 0.028, 0.029, - 0.03, - 0.031 - ], - "mu_r_abs": [ - 995.305, - 995.305, - 995.305, - 995.305, - 995.305, - 995.305, - 995.305, - 995.892, - 996.479, - 996.479, - 996.479, - 996.488, - 997.21, - 998.692, - 1001.517, - 1002.494, - 1004.783, - 1005.869, - 1006.877, - 1010.439, - 1013.393 + 0.03 ], - "mu_phi_deg": [ - 3.345, - 3.651, - 3.684, - 3.741, - 3.746, - 3.749, - 3.759, - 3.801, - 3.754, - 3.756, - 3.781, - 3.775, - 3.833, - 3.915, - 3.925, - 3.985, - 4.02, - 4.07, - 4.128, - 4.201, - 4.2 - ] + "frequency": 3000000.0, + "temperature": 100 } ] }, "measurements": { - "complex_permeability": { - "datasheet": { - "data_type": "complex_permeability_data", - "name": "datasheet", - "company": "Ferroxcube", - "date": "2016-03-03 00:00:00", - "test_setup": { - "name": "datasheet", - "Toroid": "R_14x9x5", - "Measurement_Method": "datasheet", - "Equipment": "datasheet", - "comment": "" - }, - "measurement_data": [ - { - "temperature": 100, - "frequency": 1000000.0, - "flux_density": [ - 0.0, - 0.01, - 0.012, - 0.014, - 0.016, - 0.018, - 0.02, - 0.022, - 0.024, - 0.026, - 0.028, - 0.03, - 0.032, - 0.034, - 0.036, - 0.038, - 0.04, - 0.042, - 0.044, - 0.046, - 0.048 - ], - "mu_r_abs": [ - 850.133, - 873.721, - 878.377, - 881.868, - 885.113, - 886.97, - 888.201, - 888.498, - 888.498, - 888.94, - 893.635, - 894.366, - 895.072, - 897.631, - 900.786, - 904.501, - 908.198, - 909.685, - 911.946, - 914.415, - 918.904 - ], - "mu_phi_deg": [ - 0.807, - 0.796, - 0.794, - 0.792, - 0.781, - 0.757, - 0.758, - 0.755, - 0.753, - 0.762, - 0.775, - 0.8, - 0.838, - 0.879, - 0.915, - 0.973, - 1.008, - 1.057, - 1.138, - 1.18, - 1.242 - ] - }, - { - "temperature": 100, - "frequency": 2000000.0, - "flux_density": [ - 0.0, - 0.01, - 0.012, - 0.014, - 0.016, - 0.018, - 0.02, - 0.022, - 0.025, - 0.027, - 0.029, - 0.031, - 0.033, - 0.035, - 0.037, - 0.039, - 0.041, - 0.043, - 0.045, - 0.047, - 0.049 - ], - "mu_r_abs": [ - 922.635, - 934.463, - 936.86, - 938.625, - 940.385, - 941.766, - 942.354, - 943.028, - 945.238, - 947.035, - 950.465, - 953.629, - 956.317, - 959.318, - 962.971, - 968.792, - 972.362, - 975.664, - 978.984, - 983.882, - 987.927 - ], - "mu_phi_deg": [ - 0.589, - 0.881, - 0.94, - 0.997, - 1.026, - 1.069, - 1.135, - 1.161, - 1.23, - 1.289, - 1.373, - 1.491, - 1.627, - 1.731, - 1.834, - 1.973, - 2.146, - 2.263, - 2.37, - 2.521, - 2.578 - ] - }, - { - "temperature": 100, - "frequency": 3000000.0, - "flux_density": [ - 0.0, - 0.01, - 0.011, - 0.012, - 0.013, - 0.014, - 0.016, - 0.017, - 0.018, - 0.019, - 0.02, - 0.021, - 0.022, - 0.023, - 0.024, - 0.025, - 0.026, - 0.028, - 0.029, - 0.03, - 0.031 - ], - "mu_r_abs": [ - 995.305, - 995.305, - 995.305, - 995.305, - 995.305, - 995.305, - 995.305, - 995.892, - 996.479, - 996.479, - 996.479, - 996.488, - 997.21, - 998.692, - 1001.517, - 1002.494, - 1004.783, - 1005.869, - 1006.877, - 1010.439, - 1013.393 - ], - "mu_phi_deg": [ - 3.345, - 3.651, - 3.684, - 3.741, - 3.746, - 3.749, - 3.759, - 3.801, - 3.754, - 3.756, - 3.781, - 3.775, - 3.833, - 3.915, - 3.925, - 3.985, - 4.02, - 4.07, - 4.128, - 4.201, - 4.2 - ] - } - ] - } - }, "complex_permittivity": { "LEA_MTB_small_signal": { "data_type": "complex_permittivity_data", diff --git a/materialdatabase/scripts/write_datasheet_permeability_data_into_database.py b/materialdatabase/scripts/write_datasheet_permeability_data_into_database.py index 918ed65..b016a31 100644 --- a/materialdatabase/scripts/write_datasheet_permeability_data_into_database.py +++ b/materialdatabase/scripts/write_datasheet_permeability_data_into_database.py @@ -1,12 +1,18 @@ -"""Write permeability data of datasheets into the database.""" +""" +Script to write permeability_data of datasheet data into the database, only for the ferrite material 3F46 of Ferroxcube. + +The data under the key "permeability_data" is used for the FEM-simulations in FEMMT. Based on the data in the datasheet, the amplitude and angle of the +permeability is calculated for different magnetic flux density values. +""" + from materialdatabase.material_data_base_classes import * +from materialdatabase.material_data_base_functions import * import materialdatabase.paths as paths import datetime -import pandas as pd # Control flags -write_data = True -plot_data = True +WRITE = False +PLOT = True # Set parameters core_name = 'R_14x9x5' # d_out x d_in x h @@ -17,17 +23,16 @@ frequencies_db = [1e6, 2e6, 3e6] # Path to folder with datasheet data -datasheet_path = paths.datasheet_path - +datasheet_path = paths.datasheet_path + "Ferroxcube/3F46_digitized/" powerloss_data = [] -powerloss_files = ["powerloss_density_over_b_field_1MHz_100C_new.csv", - "powerloss_density_over_b_field_2MHz_100C_new.csv", - "powerloss_density_over_b_field_3MHz_100C_new.csv"] +powerloss_files = ["powerloss_flux_density_100C_1000kHz.csv", + "powerloss_flux_density_100C_2000kHz.csv", + "powerloss_flux_density_100C_3000kHz.csv"] permeability_amplitude_data = [] -permeability_amplitude_files = ["permeability_over_b_field_1MHz_100C_new.csv", +permeability_amplitude_files = ["amplitude_permeability_100C_1000kHz.csv", "placeholder.csv", # placeholder because no data for 2MHz - "permeability_over_b_field_3MHz_100C_new.csv"] + "amplitude_permeability_100C_3000kHz.csv"] b_field_data = [] permeability_angle_data = [] @@ -35,82 +40,78 @@ for index in range(len(powerloss_files)): print(index+1, "out of", len(powerloss_files), "calculated") - fig, ax = plt.subplots(nrows=3, ncols=1, sharex=True) - # adding the graph by 2MHz if index == 1: - permeability_amplitude_dataframe_1 = pd.read_csv(os.path.join(datasheet_path, permeability_amplitude_files[0]), encoding="latin1") - permeability_amplitude_dataframe_3 = pd.read_csv(os.path.join(datasheet_path, permeability_amplitude_files[2]), encoding="latin1") + permeability_amplitude_df_1 = read_in_digitized_datasheet_plot(path=os.path.join(datasheet_path, permeability_amplitude_files[0])) + permeability_amplitude_df_3 = read_in_digitized_datasheet_plot(path=os.path.join(datasheet_path, permeability_amplitude_files[2])) - permeability_amplitude_dataframe_1_interpolated = updates_x_ticks_for_graph(x_data=permeability_amplitude_dataframe_1["x"], - y_data=permeability_amplitude_dataframe_1[" y"], - x_new=permeability_amplitude_dataframe_3["x"]) - - b_field = permeability_amplitude_dataframe_3["x"] + permeability_amplitude_df_3_interpolated = updates_x_ticks_for_graph(x_data=permeability_amplitude_df_3[0], y_data=permeability_amplitude_df_3[1], + x_new=permeability_amplitude_df_1[0]) + b_field = permeability_amplitude_df_1[0] # calculating the mean of the graphs by 1MHz and 3 MHz for the missing graph of 2MHz - permeability_mean = np.mean(np.array([permeability_amplitude_dataframe_1_interpolated, permeability_amplitude_dataframe_3[" y"]]), axis=0) + permeability_mean = np.mean(np.array([permeability_amplitude_df_1[1], permeability_amplitude_df_3_interpolated]), axis=0) - permeability_amplitude_dataframe = pd.DataFrame(data={"x": b_field, " y": permeability_mean}) + permeability_amplitude_df = [b_field, permeability_mean] else: - permeability_amplitude_dataframe = pd.read_csv(os.path.join(datasheet_path, permeability_amplitude_files[index]), encoding="latin1") + permeability_amplitude_df = read_in_digitized_datasheet_plot(path=os.path.join(datasheet_path, permeability_amplitude_files[index])) - powerloss_dataframe = pd.read_csv(os.path.join(datasheet_path, powerloss_files[index]), encoding="latin1") + powerloss_df = read_in_digitized_datasheet_plot(path=os.path.join(datasheet_path, powerloss_files[index])) - permeability_interpolated = updates_x_ticks_for_graph(x_data=permeability_amplitude_dataframe["x"], y_data=permeability_amplitude_dataframe[" y"], - x_new=powerloss_dataframe["x"]) + min_b = max([min(powerloss_df[0]), min(permeability_amplitude_df[0])]) + max_b = min([max(powerloss_df[0]), max(permeability_amplitude_df[0])]) + b_common = np.linspace(min_b, max_b, 20) - b_reduced, f_p_hys_interpol_common, f_b_phi_interpol_common = interpolate_a_b_c(powerloss_dataframe["x"]/1000, permeability_interpolated, - mu_phi_deg__from_mu_r_and_p_hyst(frequency=frequencies_db[index], - b_peak=powerloss_dataframe["x"]/1000, - mu_r=permeability_interpolated, - p_hyst=powerloss_dataframe[" y"]*1000)) + permeability_updated = updates_x_ticks_for_graph(x_data=permeability_amplitude_df[0], y_data=permeability_amplitude_df[1], x_new=b_common) + powerloss_updated = updates_x_ticks_for_graph(x_data=powerloss_df[0], y_data=powerloss_df[1], x_new=b_common) - b_ref, mu_r, mu_phi_deg = sort_data(b_reduced, f_p_hys_interpol_common, f_b_phi_interpol_common) + mu_phi_deg = mu_phi_deg__from_mu_r_and_p_hyst(frequency=frequencies_db[index], b_peak=b_common/1000, mu_r=permeability_updated, + p_hyst=np.array(powerloss_updated)*1000) - b_ref, mu_r, mu_phi_deg = process_permeability_data(b_ref_raw=b_ref, mu_r_raw=mu_r, mu_phi_deg_raw=mu_phi_deg, b_min=0.005, b_max=0.051, - smooth_data=False, crop_data=True, plot_data=True, ax=ax, f=frequencies_db[index], T=temperature_db) + b_ref, mu_r, mu_phi_deg = process_permeability_data(b_ref_raw=b_common/1000, mu_r_raw=permeability_updated, mu_phi_deg_raw=mu_phi_deg, + b_min=0.005, b_max=0.051, smooth_data=False, crop_data=False, plot_data=PLOT, + f=frequencies_db[index], T=temperature_db) permeability_amplitude_data.append(mu_r) - powerloss_data.append(powerloss_dataframe[" y"]*1000) + powerloss_data.append(np.array(powerloss_updated)*1000) b_field_data.append(b_ref) - permeability_angle_data.append(mu_phi_deg) # Plot - if plot_data: + if PLOT: fig, ax = plt.subplots(nrows=2, ncols=1, sharex=True) + ax[1].plot(b_ref, mu_phi_deg, label="angle") ax[0].plot(b_ref, mu_r, label="amplitude") - ax[1].set_xlabel(PlotLabels.b_field.value) + for ind in range(len(ax)): ax[ind].grid(True, which="both") ax[ind].legend() plt.show() -# Writing into material database -if write_data: - - flag_overwrite = True - create_empty_material(material_name, manufacturer) - create_permeability_measurement_in_database(material_name, measurement_setup="datasheet", - company=manufacturer, date=date, - test_setup_name="datasheet", - toroid_dimensions=core_name, - measurement_method="datasheet", - equipment_names="datasheet", comment="") - - for index, value in enumerate(frequencies_db): - - write_permeability_data_into_database(frequency=value, - temperature=temperature_db, - b_ref=np.round(b_field_data[index], 3), - mu_r_abs=np.round(permeability_amplitude_data[index], 3), - mu_phi_deg=np.round(permeability_angle_data[index], 3), - material_name=material_name, - measurement_setup="datasheet", - overwrite=flag_overwrite) - flag_overwrite = False +if WRITE: + with open(relative_path_to_db, "r") as jsonFile: + database = json.load(jsonFile) +else: + database = {material_name.value: {"manufacturer_datasheet": {}}} + +data_list = [] +for index, value in enumerate(frequencies_db): + print(value) + print(temperature_db) + + data_dict = {"mu_r_abs": list(np.round(permeability_amplitude_data[index], 3)), + "mu_phi_deg": list(np.round(permeability_angle_data[index], 3)), + "flux_density": list(np.round(b_field_data[index], 3)), + "frequency": frequencies_db[index], + "temperature": temperature_db} + data_list.append(data_dict) + +database[material_name.value]["manufacturer_datasheet"]["permeability_data"] = data_list + +if WRITE: + with open(relative_path_to_db, "w") as jsonFile: + json.dump(database, jsonFile, indent=2) diff --git a/materialdatabase/scripts/write_datasheet_plots_into_database.py b/materialdatabase/scripts/write_datasheet_plots_into_database.py index 6637acd..c28a16e 100644 --- a/materialdatabase/scripts/write_datasheet_plots_into_database.py +++ b/materialdatabase/scripts/write_datasheet_plots_into_database.py @@ -1,4 +1,9 @@ -"""Script to write the data of manufacturer datasheets plots into the database.""" +""" +Script to write the data of manufacturer datasheets plots into the database. + +This script is used for all materials and the data is not used for the FEM-simulations in FEMMT. The data is only for plotting and comparisons. +""" + from matplotlib import pyplot as plt import numpy as np from materialdatabase.enumerations import * @@ -33,7 +38,7 @@ - Powerloss in Watt per cubic Meter """ -WRITE = True +WRITE = False # MAGNETIC FIELD STRENGTH Oersted_TO_Ampere_Per_Meter = False h_field_factor = 1 diff --git a/materialdatabase/scripts/write_permeability_data_from_datasheet_into_database.py b/materialdatabase/scripts/write_permeability_data_from_datasheet_into_database.py index 1699462..f673981 100644 --- a/materialdatabase/scripts/write_permeability_data_from_datasheet_into_database.py +++ b/materialdatabase/scripts/write_permeability_data_from_datasheet_into_database.py @@ -1,11 +1,18 @@ -"""Script to write permeability_data of datasheet data into the database.""" +""" +Script to write permeability_data of datasheet data into the database. + +The data under the key "permeability_data" is used for the FEM-simulations in FEMMT. Based on the data in the datasheet, the amplitude and angle of the +permeability is calculated for different magnetic flux density values. This script is used for all material, except the materials manufactured +by Epcos TDK. For this, there is a separate script called write_permeability_data_from_datasheet_into_database_TDK.py. +""" + import numpy as np from materialdatabase.material_data_base_classes import * from materialdatabase.material_data_base_functions import * from materialdatabase.paths import * # Control flags -WRITE = True +WRITE = False material = str(Material._79.value) manufacturer = str(Manufacturer.FairRite.value) @@ -96,10 +103,6 @@ mu_r=amplitude_permeability_flux_density_1000kHz_100C, p_hyst=np.array(powerloss_1000kHz_100C[1])*1000) -# print(mu_phi_deg_25kHz) -# print(mu_phi_deg_50kHz) -# print(mu_phi_deg_100kHz) -# print(mu_phi_deg_200kHz) mu_r_list = [amplitude_permeability_flux_density_100kHz_25C, amplitude_permeability_flux_density_300kHz_25C, amplitude_permeability_flux_density_500kHz_25C, amplitude_permeability_flux_density_750kHz_25C, amplitude_permeability_flux_density_1000kHz_25C, @@ -123,9 +126,7 @@ for index, value in enumerate(frequency): print(value) print(temperature[index]) - # print(np.array(flux_density[index])) - # print(mu_r_list[index]) - # print(mu_phi_deg_list[index]) + b_ref, mu_r, mu_phi_deg = process_permeability_data(b_ref_raw=np.array(flux_density[index]), mu_r_raw=mu_r_list[index], mu_phi_deg_raw=mu_phi_deg_list[index], b_min=0.005, b_max=0.31, smooth_data=False, crop_data=False, plot_data=True, f=frequency[index], T=temperature[index]) diff --git a/materialdatabase/scripts/write_permeability_data_from_datasheet_into_database_TDK.py b/materialdatabase/scripts/write_permeability_data_from_datasheet_into_database_TDK.py index 38be2f5..4793819 100644 --- a/materialdatabase/scripts/write_permeability_data_from_datasheet_into_database_TDK.py +++ b/materialdatabase/scripts/write_permeability_data_from_datasheet_into_database_TDK.py @@ -1,4 +1,10 @@ -"""Script to write permeability_data of datasheet data into the database only for TDK.""" +""" +Script to write permeability_data of datasheet data into the database, only for materials manufactured by Epcos TDK. + +The data under the key "permeability_data" is used for the FEM-simulations in FEMMT. Based on the data in the datasheet, the amplitude and angle of the +permeability is calculated for different magnetic flux density values. +""" + from materialdatabase.material_data_base_functions import * from materialdatabase.paths import * import numpy as np From f57df57268d1a2f451a83606b985ed9f38b04ca5 Mon Sep 17 00:00:00 2001 From: Sebastian Schachten Date: Thu, 23 Jan 2025 13:16:37 +0100 Subject: [PATCH 2/2] updated some script doc strings to better distinguish between them removed the part "complex_permeability" for 3F46 under "measurements", this is the permeability_data and was wrong sorted (data is still in database under "permeability_data") updated "permeability_data" of 3F46 in database, the data was wrong calculated --- materialdatabase/data/material_data_base.json | 552 +++++------------- ...tasheet_permeability_data_into_database.py | 123 ++-- .../write_datasheet_plots_into_database.py | 9 +- ...ility_data_from_datasheet_into_database.py | 19 +- ...y_data_from_datasheet_into_database_TDK.py | 8 +- 5 files changed, 244 insertions(+), 467 deletions(-) diff --git a/materialdatabase/data/material_data_base.json b/materialdatabase/data/material_data_base.json index e98414f..9ba61ce 100644 --- a/materialdatabase/data/material_data_base.json +++ b/materialdatabase/data/material_data_base.json @@ -23488,8 +23488,52 @@ ], "permeability_data": [ { - "temperature": 100, - "frequency": 1000000.0, + "mu_r_abs": [ + 850.299, + 872.052, + 876.271, + 880.027, + 882.902, + 884.771, + 886.414, + 886.88, + 886.903, + 887.142, + 890.458, + 892.58, + 892.712, + 894.801, + 898.42, + 902.103, + 905.613, + 907.611, + 909.41, + 912.056, + 915.611 + ], + "mu_phi_deg": [ + 0.86, + 0.816, + 0.807, + 0.8, + 0.797, + 0.782, + 0.772, + 0.768, + 0.766, + 0.775, + 0.787, + 0.814, + 0.846, + 0.884, + 0.925, + 0.968, + 1.015, + 1.062, + 1.131, + 1.199, + 1.257 + ], "flux_density": [ 0.0, 0.01, @@ -23513,56 +23557,56 @@ 0.046, 0.048 ], + "frequency": 1000000.0, + "temperature": 100 + }, + { "mu_r_abs": [ - 850.133, - 873.721, - 878.377, - 881.868, - 885.113, - 886.97, - 888.201, - 888.498, - 888.498, - 888.94, - 893.635, - 894.366, - 895.072, - 897.631, - 900.786, - 904.501, - 908.198, - 909.685, - 911.946, - 914.415, - 918.904 + 922.705, + 933.763, + 935.934, + 937.843, + 939.294, + 940.24, + 941.057, + 941.392, + 943.101, + 944.905, + 948.258, + 951.692, + 953.929, + 957.173, + 960.872, + 965.709, + 970.455, + 973.279, + 976.188, + 980.34, + 985.025 ], "mu_phi_deg": [ - 0.807, - 0.796, - 0.794, - 0.792, - 0.781, - 0.757, - 0.758, - 0.755, - 0.753, - 0.762, - 0.775, - 0.8, - 0.838, - 0.879, - 0.915, - 0.973, - 1.008, - 1.057, - 1.138, - 1.18, - 1.242 - ] - }, - { - "temperature": 100, - "frequency": 2000000.0, + 0.572, + 0.906, + 0.972, + 1.017, + 1.056, + 1.091, + 1.144, + 1.174, + 1.249, + 1.312, + 1.387, + 1.501, + 1.624, + 1.741, + 1.835, + 1.956, + 2.106, + 2.249, + 2.362, + 2.492, + 2.616 + ], "flux_density": [ 0.0, 0.01, @@ -23572,70 +23616,70 @@ 0.018, 0.02, 0.022, - 0.025, - 0.027, - 0.029, - 0.031, - 0.033, - 0.035, - 0.037, - 0.039, - 0.041, - 0.043, - 0.045, - 0.047, - 0.049 + 0.024, + 0.026, + 0.028, + 0.03, + 0.032, + 0.034, + 0.036, + 0.038, + 0.04, + 0.042, + 0.044, + 0.046, + 0.048 ], + "frequency": 2000000.0, + "temperature": 100 + }, + { "mu_r_abs": [ - 922.635, - 934.463, - 936.86, - 938.625, - 940.385, - 941.766, - 942.354, - 943.028, - 945.238, - 947.035, - 950.465, - 953.629, - 956.317, - 959.318, - 962.971, - 968.792, - 972.362, - 975.664, - 978.984, - 983.882, - 987.927 + 994.966, + 995.444, + 995.494, + 995.523, + 995.536, + 995.548, + 995.561, + 995.573, + 995.586, + 995.598, + 995.611, + 995.624, + 995.704, + 996.561, + 998.748, + 999.871, + 1001.786, + 1004.117, + 1005.018, + 1007.547, + 1010.455 ], "mu_phi_deg": [ - 0.589, - 0.881, - 0.94, - 0.997, - 1.026, - 1.069, - 1.135, - 1.161, - 1.23, - 1.289, - 1.373, - 1.491, - 1.627, - 1.731, - 1.834, - 1.973, - 2.146, - 2.263, - 2.37, - 2.521, - 2.578 - ] - }, - { - "temperature": 100, - "frequency": 3000000.0, + 3.116, + 3.737, + 3.803, + 3.839, + 3.841, + 3.845, + 3.874, + 3.891, + 3.879, + 3.853, + 3.854, + 3.873, + 3.927, + 3.979, + 4.014, + 4.037, + 4.082, + 4.136, + 4.192, + 4.26, + 4.326 + ], "flux_density": [ 0.0, 0.01, @@ -23643,308 +23687,28 @@ 0.012, 0.013, 0.014, + 0.015, 0.016, 0.017, 0.018, 0.019, 0.02, - 0.021, 0.022, 0.023, 0.024, 0.025, 0.026, + 0.027, 0.028, 0.029, - 0.03, - 0.031 - ], - "mu_r_abs": [ - 995.305, - 995.305, - 995.305, - 995.305, - 995.305, - 995.305, - 995.305, - 995.892, - 996.479, - 996.479, - 996.479, - 996.488, - 997.21, - 998.692, - 1001.517, - 1002.494, - 1004.783, - 1005.869, - 1006.877, - 1010.439, - 1013.393 + 0.03 ], - "mu_phi_deg": [ - 3.345, - 3.651, - 3.684, - 3.741, - 3.746, - 3.749, - 3.759, - 3.801, - 3.754, - 3.756, - 3.781, - 3.775, - 3.833, - 3.915, - 3.925, - 3.985, - 4.02, - 4.07, - 4.128, - 4.201, - 4.2 - ] + "frequency": 3000000.0, + "temperature": 100 } ] }, "measurements": { - "complex_permeability": { - "datasheet": { - "data_type": "complex_permeability_data", - "name": "datasheet", - "company": "Ferroxcube", - "date": "2016-03-03 00:00:00", - "test_setup": { - "name": "datasheet", - "Toroid": "R_14x9x5", - "Measurement_Method": "datasheet", - "Equipment": "datasheet", - "comment": "" - }, - "measurement_data": [ - { - "temperature": 100, - "frequency": 1000000.0, - "flux_density": [ - 0.0, - 0.01, - 0.012, - 0.014, - 0.016, - 0.018, - 0.02, - 0.022, - 0.024, - 0.026, - 0.028, - 0.03, - 0.032, - 0.034, - 0.036, - 0.038, - 0.04, - 0.042, - 0.044, - 0.046, - 0.048 - ], - "mu_r_abs": [ - 850.133, - 873.721, - 878.377, - 881.868, - 885.113, - 886.97, - 888.201, - 888.498, - 888.498, - 888.94, - 893.635, - 894.366, - 895.072, - 897.631, - 900.786, - 904.501, - 908.198, - 909.685, - 911.946, - 914.415, - 918.904 - ], - "mu_phi_deg": [ - 0.807, - 0.796, - 0.794, - 0.792, - 0.781, - 0.757, - 0.758, - 0.755, - 0.753, - 0.762, - 0.775, - 0.8, - 0.838, - 0.879, - 0.915, - 0.973, - 1.008, - 1.057, - 1.138, - 1.18, - 1.242 - ] - }, - { - "temperature": 100, - "frequency": 2000000.0, - "flux_density": [ - 0.0, - 0.01, - 0.012, - 0.014, - 0.016, - 0.018, - 0.02, - 0.022, - 0.025, - 0.027, - 0.029, - 0.031, - 0.033, - 0.035, - 0.037, - 0.039, - 0.041, - 0.043, - 0.045, - 0.047, - 0.049 - ], - "mu_r_abs": [ - 922.635, - 934.463, - 936.86, - 938.625, - 940.385, - 941.766, - 942.354, - 943.028, - 945.238, - 947.035, - 950.465, - 953.629, - 956.317, - 959.318, - 962.971, - 968.792, - 972.362, - 975.664, - 978.984, - 983.882, - 987.927 - ], - "mu_phi_deg": [ - 0.589, - 0.881, - 0.94, - 0.997, - 1.026, - 1.069, - 1.135, - 1.161, - 1.23, - 1.289, - 1.373, - 1.491, - 1.627, - 1.731, - 1.834, - 1.973, - 2.146, - 2.263, - 2.37, - 2.521, - 2.578 - ] - }, - { - "temperature": 100, - "frequency": 3000000.0, - "flux_density": [ - 0.0, - 0.01, - 0.011, - 0.012, - 0.013, - 0.014, - 0.016, - 0.017, - 0.018, - 0.019, - 0.02, - 0.021, - 0.022, - 0.023, - 0.024, - 0.025, - 0.026, - 0.028, - 0.029, - 0.03, - 0.031 - ], - "mu_r_abs": [ - 995.305, - 995.305, - 995.305, - 995.305, - 995.305, - 995.305, - 995.305, - 995.892, - 996.479, - 996.479, - 996.479, - 996.488, - 997.21, - 998.692, - 1001.517, - 1002.494, - 1004.783, - 1005.869, - 1006.877, - 1010.439, - 1013.393 - ], - "mu_phi_deg": [ - 3.345, - 3.651, - 3.684, - 3.741, - 3.746, - 3.749, - 3.759, - 3.801, - 3.754, - 3.756, - 3.781, - 3.775, - 3.833, - 3.915, - 3.925, - 3.985, - 4.02, - 4.07, - 4.128, - 4.201, - 4.2 - ] - } - ] - } - }, "complex_permittivity": { "LEA_MTB_small_signal": { "data_type": "complex_permittivity_data", diff --git a/materialdatabase/scripts/write_datasheet_permeability_data_into_database.py b/materialdatabase/scripts/write_datasheet_permeability_data_into_database.py index 918ed65..b016a31 100644 --- a/materialdatabase/scripts/write_datasheet_permeability_data_into_database.py +++ b/materialdatabase/scripts/write_datasheet_permeability_data_into_database.py @@ -1,12 +1,18 @@ -"""Write permeability data of datasheets into the database.""" +""" +Script to write permeability_data of datasheet data into the database, only for the ferrite material 3F46 of Ferroxcube. + +The data under the key "permeability_data" is used for the FEM-simulations in FEMMT. Based on the data in the datasheet, the amplitude and angle of the +permeability is calculated for different magnetic flux density values. +""" + from materialdatabase.material_data_base_classes import * +from materialdatabase.material_data_base_functions import * import materialdatabase.paths as paths import datetime -import pandas as pd # Control flags -write_data = True -plot_data = True +WRITE = False +PLOT = True # Set parameters core_name = 'R_14x9x5' # d_out x d_in x h @@ -17,17 +23,16 @@ frequencies_db = [1e6, 2e6, 3e6] # Path to folder with datasheet data -datasheet_path = paths.datasheet_path - +datasheet_path = paths.datasheet_path + "Ferroxcube/3F46_digitized/" powerloss_data = [] -powerloss_files = ["powerloss_density_over_b_field_1MHz_100C_new.csv", - "powerloss_density_over_b_field_2MHz_100C_new.csv", - "powerloss_density_over_b_field_3MHz_100C_new.csv"] +powerloss_files = ["powerloss_flux_density_100C_1000kHz.csv", + "powerloss_flux_density_100C_2000kHz.csv", + "powerloss_flux_density_100C_3000kHz.csv"] permeability_amplitude_data = [] -permeability_amplitude_files = ["permeability_over_b_field_1MHz_100C_new.csv", +permeability_amplitude_files = ["amplitude_permeability_100C_1000kHz.csv", "placeholder.csv", # placeholder because no data for 2MHz - "permeability_over_b_field_3MHz_100C_new.csv"] + "amplitude_permeability_100C_3000kHz.csv"] b_field_data = [] permeability_angle_data = [] @@ -35,82 +40,78 @@ for index in range(len(powerloss_files)): print(index+1, "out of", len(powerloss_files), "calculated") - fig, ax = plt.subplots(nrows=3, ncols=1, sharex=True) - # adding the graph by 2MHz if index == 1: - permeability_amplitude_dataframe_1 = pd.read_csv(os.path.join(datasheet_path, permeability_amplitude_files[0]), encoding="latin1") - permeability_amplitude_dataframe_3 = pd.read_csv(os.path.join(datasheet_path, permeability_amplitude_files[2]), encoding="latin1") + permeability_amplitude_df_1 = read_in_digitized_datasheet_plot(path=os.path.join(datasheet_path, permeability_amplitude_files[0])) + permeability_amplitude_df_3 = read_in_digitized_datasheet_plot(path=os.path.join(datasheet_path, permeability_amplitude_files[2])) - permeability_amplitude_dataframe_1_interpolated = updates_x_ticks_for_graph(x_data=permeability_amplitude_dataframe_1["x"], - y_data=permeability_amplitude_dataframe_1[" y"], - x_new=permeability_amplitude_dataframe_3["x"]) - - b_field = permeability_amplitude_dataframe_3["x"] + permeability_amplitude_df_3_interpolated = updates_x_ticks_for_graph(x_data=permeability_amplitude_df_3[0], y_data=permeability_amplitude_df_3[1], + x_new=permeability_amplitude_df_1[0]) + b_field = permeability_amplitude_df_1[0] # calculating the mean of the graphs by 1MHz and 3 MHz for the missing graph of 2MHz - permeability_mean = np.mean(np.array([permeability_amplitude_dataframe_1_interpolated, permeability_amplitude_dataframe_3[" y"]]), axis=0) + permeability_mean = np.mean(np.array([permeability_amplitude_df_1[1], permeability_amplitude_df_3_interpolated]), axis=0) - permeability_amplitude_dataframe = pd.DataFrame(data={"x": b_field, " y": permeability_mean}) + permeability_amplitude_df = [b_field, permeability_mean] else: - permeability_amplitude_dataframe = pd.read_csv(os.path.join(datasheet_path, permeability_amplitude_files[index]), encoding="latin1") + permeability_amplitude_df = read_in_digitized_datasheet_plot(path=os.path.join(datasheet_path, permeability_amplitude_files[index])) - powerloss_dataframe = pd.read_csv(os.path.join(datasheet_path, powerloss_files[index]), encoding="latin1") + powerloss_df = read_in_digitized_datasheet_plot(path=os.path.join(datasheet_path, powerloss_files[index])) - permeability_interpolated = updates_x_ticks_for_graph(x_data=permeability_amplitude_dataframe["x"], y_data=permeability_amplitude_dataframe[" y"], - x_new=powerloss_dataframe["x"]) + min_b = max([min(powerloss_df[0]), min(permeability_amplitude_df[0])]) + max_b = min([max(powerloss_df[0]), max(permeability_amplitude_df[0])]) + b_common = np.linspace(min_b, max_b, 20) - b_reduced, f_p_hys_interpol_common, f_b_phi_interpol_common = interpolate_a_b_c(powerloss_dataframe["x"]/1000, permeability_interpolated, - mu_phi_deg__from_mu_r_and_p_hyst(frequency=frequencies_db[index], - b_peak=powerloss_dataframe["x"]/1000, - mu_r=permeability_interpolated, - p_hyst=powerloss_dataframe[" y"]*1000)) + permeability_updated = updates_x_ticks_for_graph(x_data=permeability_amplitude_df[0], y_data=permeability_amplitude_df[1], x_new=b_common) + powerloss_updated = updates_x_ticks_for_graph(x_data=powerloss_df[0], y_data=powerloss_df[1], x_new=b_common) - b_ref, mu_r, mu_phi_deg = sort_data(b_reduced, f_p_hys_interpol_common, f_b_phi_interpol_common) + mu_phi_deg = mu_phi_deg__from_mu_r_and_p_hyst(frequency=frequencies_db[index], b_peak=b_common/1000, mu_r=permeability_updated, + p_hyst=np.array(powerloss_updated)*1000) - b_ref, mu_r, mu_phi_deg = process_permeability_data(b_ref_raw=b_ref, mu_r_raw=mu_r, mu_phi_deg_raw=mu_phi_deg, b_min=0.005, b_max=0.051, - smooth_data=False, crop_data=True, plot_data=True, ax=ax, f=frequencies_db[index], T=temperature_db) + b_ref, mu_r, mu_phi_deg = process_permeability_data(b_ref_raw=b_common/1000, mu_r_raw=permeability_updated, mu_phi_deg_raw=mu_phi_deg, + b_min=0.005, b_max=0.051, smooth_data=False, crop_data=False, plot_data=PLOT, + f=frequencies_db[index], T=temperature_db) permeability_amplitude_data.append(mu_r) - powerloss_data.append(powerloss_dataframe[" y"]*1000) + powerloss_data.append(np.array(powerloss_updated)*1000) b_field_data.append(b_ref) - permeability_angle_data.append(mu_phi_deg) # Plot - if plot_data: + if PLOT: fig, ax = plt.subplots(nrows=2, ncols=1, sharex=True) + ax[1].plot(b_ref, mu_phi_deg, label="angle") ax[0].plot(b_ref, mu_r, label="amplitude") - ax[1].set_xlabel(PlotLabels.b_field.value) + for ind in range(len(ax)): ax[ind].grid(True, which="both") ax[ind].legend() plt.show() -# Writing into material database -if write_data: - - flag_overwrite = True - create_empty_material(material_name, manufacturer) - create_permeability_measurement_in_database(material_name, measurement_setup="datasheet", - company=manufacturer, date=date, - test_setup_name="datasheet", - toroid_dimensions=core_name, - measurement_method="datasheet", - equipment_names="datasheet", comment="") - - for index, value in enumerate(frequencies_db): - - write_permeability_data_into_database(frequency=value, - temperature=temperature_db, - b_ref=np.round(b_field_data[index], 3), - mu_r_abs=np.round(permeability_amplitude_data[index], 3), - mu_phi_deg=np.round(permeability_angle_data[index], 3), - material_name=material_name, - measurement_setup="datasheet", - overwrite=flag_overwrite) - flag_overwrite = False +if WRITE: + with open(relative_path_to_db, "r") as jsonFile: + database = json.load(jsonFile) +else: + database = {material_name.value: {"manufacturer_datasheet": {}}} + +data_list = [] +for index, value in enumerate(frequencies_db): + print(value) + print(temperature_db) + + data_dict = {"mu_r_abs": list(np.round(permeability_amplitude_data[index], 3)), + "mu_phi_deg": list(np.round(permeability_angle_data[index], 3)), + "flux_density": list(np.round(b_field_data[index], 3)), + "frequency": frequencies_db[index], + "temperature": temperature_db} + data_list.append(data_dict) + +database[material_name.value]["manufacturer_datasheet"]["permeability_data"] = data_list + +if WRITE: + with open(relative_path_to_db, "w") as jsonFile: + json.dump(database, jsonFile, indent=2) diff --git a/materialdatabase/scripts/write_datasheet_plots_into_database.py b/materialdatabase/scripts/write_datasheet_plots_into_database.py index 6637acd..c28a16e 100644 --- a/materialdatabase/scripts/write_datasheet_plots_into_database.py +++ b/materialdatabase/scripts/write_datasheet_plots_into_database.py @@ -1,4 +1,9 @@ -"""Script to write the data of manufacturer datasheets plots into the database.""" +""" +Script to write the data of manufacturer datasheets plots into the database. + +This script is used for all materials and the data is not used for the FEM-simulations in FEMMT. The data is only for plotting and comparisons. +""" + from matplotlib import pyplot as plt import numpy as np from materialdatabase.enumerations import * @@ -33,7 +38,7 @@ - Powerloss in Watt per cubic Meter """ -WRITE = True +WRITE = False # MAGNETIC FIELD STRENGTH Oersted_TO_Ampere_Per_Meter = False h_field_factor = 1 diff --git a/materialdatabase/scripts/write_permeability_data_from_datasheet_into_database.py b/materialdatabase/scripts/write_permeability_data_from_datasheet_into_database.py index 1699462..f673981 100644 --- a/materialdatabase/scripts/write_permeability_data_from_datasheet_into_database.py +++ b/materialdatabase/scripts/write_permeability_data_from_datasheet_into_database.py @@ -1,11 +1,18 @@ -"""Script to write permeability_data of datasheet data into the database.""" +""" +Script to write permeability_data of datasheet data into the database. + +The data under the key "permeability_data" is used for the FEM-simulations in FEMMT. Based on the data in the datasheet, the amplitude and angle of the +permeability is calculated for different magnetic flux density values. This script is used for all material, except the materials manufactured +by Epcos TDK. For this, there is a separate script called write_permeability_data_from_datasheet_into_database_TDK.py. +""" + import numpy as np from materialdatabase.material_data_base_classes import * from materialdatabase.material_data_base_functions import * from materialdatabase.paths import * # Control flags -WRITE = True +WRITE = False material = str(Material._79.value) manufacturer = str(Manufacturer.FairRite.value) @@ -96,10 +103,6 @@ mu_r=amplitude_permeability_flux_density_1000kHz_100C, p_hyst=np.array(powerloss_1000kHz_100C[1])*1000) -# print(mu_phi_deg_25kHz) -# print(mu_phi_deg_50kHz) -# print(mu_phi_deg_100kHz) -# print(mu_phi_deg_200kHz) mu_r_list = [amplitude_permeability_flux_density_100kHz_25C, amplitude_permeability_flux_density_300kHz_25C, amplitude_permeability_flux_density_500kHz_25C, amplitude_permeability_flux_density_750kHz_25C, amplitude_permeability_flux_density_1000kHz_25C, @@ -123,9 +126,7 @@ for index, value in enumerate(frequency): print(value) print(temperature[index]) - # print(np.array(flux_density[index])) - # print(mu_r_list[index]) - # print(mu_phi_deg_list[index]) + b_ref, mu_r, mu_phi_deg = process_permeability_data(b_ref_raw=np.array(flux_density[index]), mu_r_raw=mu_r_list[index], mu_phi_deg_raw=mu_phi_deg_list[index], b_min=0.005, b_max=0.31, smooth_data=False, crop_data=False, plot_data=True, f=frequency[index], T=temperature[index]) diff --git a/materialdatabase/scripts/write_permeability_data_from_datasheet_into_database_TDK.py b/materialdatabase/scripts/write_permeability_data_from_datasheet_into_database_TDK.py index 38be2f5..4793819 100644 --- a/materialdatabase/scripts/write_permeability_data_from_datasheet_into_database_TDK.py +++ b/materialdatabase/scripts/write_permeability_data_from_datasheet_into_database_TDK.py @@ -1,4 +1,10 @@ -"""Script to write permeability_data of datasheet data into the database only for TDK.""" +""" +Script to write permeability_data of datasheet data into the database, only for materials manufactured by Epcos TDK. + +The data under the key "permeability_data" is used for the FEM-simulations in FEMMT. Based on the data in the datasheet, the amplitude and angle of the +permeability is calculated for different magnetic flux density values. +""" + from materialdatabase.material_data_base_functions import * from materialdatabase.paths import * import numpy as np