From a9b6f40f894a37481c5d7fa679d32fff456e9f66 Mon Sep 17 00:00:00 2001 From: abujazar Date: Mon, 8 Jul 2024 05:07:18 +0200 Subject: [PATCH 1/8] conductor distribution for rectangular --- femmt/drawing.py | 334 ++++++++++++++---- femmt/enumerations.py | 18 + femmt/examples/basic_example_inductor_foil.py | 190 ++++++++++ femmt/model.py | 19 +- 4 files changed, 492 insertions(+), 69 deletions(-) create mode 100644 femmt/examples/basic_example_inductor_foil.py diff --git a/femmt/drawing.py b/femmt/drawing.py index 1191051d..413ff4a6 100644 --- a/femmt/drawing.py +++ b/femmt/drawing.py @@ -716,6 +716,9 @@ def draw_conductors(self, draw_top_down=True): winding_scheme = virtual_winding_window.winding_scheme alignment = virtual_winding_window.alignment placing_strategy = virtual_winding_window.placing_strategy + foil_vertical_placing_strategy = virtual_winding_window.foil_vertical_placing_strategy + foil_horizontal_placing_strategy = virtual_winding_window.foil_horizontal_placing_strategy + zigzag = virtual_winding_window.zigzag num = winding.winding_number @@ -751,96 +754,293 @@ def draw_conductors(self, draw_top_down=True): # TODO Add check if turns do not fit in winding window # Foil conductors where each conductor is very high and the conductors are expanding in the x-direction if virtual_winding_window.wrap_para == WrapParaType.FixedThickness: - # Wrap defined number of turns and chosen thickness - winding.a_cell = winding.thickness * (top_bound - bot_bound) - for i in range(turns): - # CHECK if right bound is reached - if (left_bound + (i + 1) * winding.thickness + i * self.insulation.cond_cond[num][num]) <= right_bound: + # Placing Foil vertical rectangular conductors from left to right + if foil_vertical_placing_strategy == FoilVerticalDistribution.HorizontalRightward: + # Wrap defined number of turns and chosen thickness + winding.a_cell = winding.thickness * (top_bound - bot_bound) + for i in range(turns): + # CHECK if right bound is reached + if (left_bound + (i + 1) * winding.thickness + i * self.insulation.cond_cond[num][num]) <= right_bound: + # Foils + self.p_conductor[num].append([ + left_bound + i * winding.thickness + i * self.insulation.cond_cond[num][num], + bot_bound, + 0, + self.mesh_data.c_conductor[num]]) + self.p_conductor[num].append([ + left_bound + (i + 1) * winding.thickness + i * self.insulation.cond_cond[num][num], + bot_bound, + 0, + self.mesh_data.c_conductor[num]]) + self.p_conductor[num].append([ + left_bound + i * winding.thickness + i * self.insulation.cond_cond[num][num], + top_bound, + 0, + self.mesh_data.c_conductor[num]]) + self.p_conductor[num].append([ + left_bound + (i + 1) * winding.thickness + i * self.insulation.cond_cond[num][num], + top_bound, + 0, + self.mesh_data.c_conductor[num]]) + center_point = self.get_center_of_rect(self.p_conductor[num][-4], self.p_conductor[num][-3], + self.p_conductor[num][-2], self.p_conductor[num][-1]) + self.p_conductor[num].append([center_point[0], center_point[1], 0, self.mesh_data.c_center_conductor[num]]) + # Placing Foil vertical rectangular conductors from left to right + elif foil_vertical_placing_strategy == FoilVerticalDistribution.HorizontalLeftward: + # Wrap defined number of turns and chosen thickness + winding.a_cell = winding.thickness * (top_bound - bot_bound) + for i in range(turns): + # CHECK if left bound is reached + if (right_bound - (i + 1) * winding.thickness - i * self.insulation.cond_cond[num][num]) >= left_bound: + # Foils + self.p_conductor[num].append([ + right_bound - i * winding.thickness - i * self.insulation.cond_cond[num][num], + bot_bound, + 0, + self.mesh_data.c_conductor[num]]) + self.p_conductor[num].append([ + right_bound - (i + 1) * winding.thickness - i * self.insulation.cond_cond[num][num], + bot_bound, + 0, + self.mesh_data.c_conductor[num]]) + self.p_conductor[num].append([ + right_bound - i * winding.thickness - i * self.insulation.cond_cond[num][num], + top_bound, + 0, + self.mesh_data.c_conductor[num]]) + self.p_conductor[num].append([ + right_bound - (i + 1) * winding.thickness - i * self.insulation.cond_cond[num][num], + top_bound, + 0, + self.mesh_data.c_conductor[num]]) + # Find the center point for each turn + center_point = self.get_center_of_rect(self.p_conductor[num][-4], self.p_conductor[num][-3], + self.p_conductor[num][-2], self.p_conductor[num][-1]) + self.p_conductor[num].append([center_point[0], center_point[1], 0, self.mesh_data.c_center_conductor[num]]) + # Interpolate type is where the foils will have a dynamic thickness + elif virtual_winding_window.wrap_para == WrapParaType.Interpolate: + # Placing Foil vertical rectangular conductors from left to right + if foil_vertical_placing_strategy == FoilVerticalDistribution.HorizontalRightward: + # Fill the allowed space in the Winding Window with a chosen number of turns + # we need first to calculate the area of every turn + # Find the wrap turn space + turn_thickness = (right_bound - left_bound - (turns - 1) * self.insulation.cond_cond[num][num]) / turns + window_height = top_bound - bot_bound + winding.a_cell = turn_thickness * window_height + # if winding.thickness is None: + # winding.thickness = (right_bound - left_bound - (turns - 1) * self.insulation.cond_cond[num][num]) / turns + # Generate interpolated positions for each turn, starting from the left and moving right + x_interpol = np.linspace(left_bound, right_bound + self.insulation.cond_cond[num][num], turns + 1) + + for i in range(turns): # Foils self.p_conductor[num].append([ - left_bound + i * winding.thickness + i * self.insulation.cond_cond[num][num], + x_interpol[i], bot_bound, 0, self.mesh_data.c_conductor[num]]) self.p_conductor[num].append([ - left_bound + (i + 1) * winding.thickness + i * self.insulation.cond_cond[num][num], + x_interpol[i + 1] - self.insulation.cond_cond[num][num], bot_bound, 0, self.mesh_data.c_conductor[num]]) self.p_conductor[num].append([ - left_bound + i * winding.thickness + i * self.insulation.cond_cond[num][num], + x_interpol[i], top_bound, 0, self.mesh_data.c_conductor[num]]) self.p_conductor[num].append([ - left_bound + (i + 1) * winding.thickness + i * self.insulation.cond_cond[num][num], + x_interpol[i + 1] - self.insulation.cond_cond[num][num], top_bound, 0, self.mesh_data.c_conductor[num]]) + # Find the center point of each turn center_point = self.get_center_of_rect(self.p_conductor[num][-4], self.p_conductor[num][-3], self.p_conductor[num][-2], self.p_conductor[num][-1]) self.p_conductor[num].append([center_point[0], center_point[1], 0, self.mesh_data.c_center_conductor[num]]) - elif virtual_winding_window.wrap_para == WrapParaType.Interpolate: - # Fill the allowed space in the Winding Window with a chosen number of turns - x_interpol = np.linspace(left_bound, right_bound + self.insulation.cond_cond[num][num], turns + 1) - for i in range(turns): - # Foils - self.p_conductor[num].append([ - x_interpol[i], - bot_bound, - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - x_interpol[i + 1] - self.insulation.cond_cond[num][num], - bot_bound, - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - x_interpol[i], - top_bound, - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - x_interpol[i + 1] - self.insulation.cond_cond[num][num], - top_bound, - 0, - self.mesh_data.c_conductor[num]]) - center_point = self.get_center_of_rect(self.p_conductor[num][-4], self.p_conductor[num][-3], - self.p_conductor[num][-2], self.p_conductor[num][-1]) - self.p_conductor[num].append([center_point[0], center_point[1], 0, self.mesh_data.c_center_conductor[num]]) + # Placing Foil vertical rectangular conductors from left to right + elif foil_vertical_placing_strategy == FoilVerticalDistribution.HorizontalLeftward: + # Fill the allowed space in the Winding Window with a chosen number of turns + # we need first to calculate the area of every turn + # Find the wrap turn space + turn_thickness = (right_bound - left_bound - (turns - 1) * self.insulation.cond_cond[num][num]) / turns + window_height = top_bound - bot_bound + winding.a_cell = turn_thickness * window_height + # Generate interpolated positions for each turn, starting from the right and moving left + x_interpol = np.linspace(right_bound, left_bound - self.insulation.cond_cond[num][num], turns + 1) + + for i in range(turns): + # Foils + self.p_conductor[num].append([ + x_interpol[i], + bot_bound, + 0, + self.mesh_data.c_conductor[num]]) + self.p_conductor[num].append([ + x_interpol[i + 1] + self.insulation.cond_cond[num][num], + bot_bound, + 0, + self.mesh_data.c_conductor[num]]) + self.p_conductor[num].append([ + x_interpol[i], + top_bound, + 0, + self.mesh_data.c_conductor[num]]) + self.p_conductor[num].append([ + x_interpol[i + 1] + self.insulation.cond_cond[num][num], + top_bound, + 0, + self.mesh_data.c_conductor[num]]) + center_point = self.get_center_of_rect(self.p_conductor[num][-4], self.p_conductor[num][-3], + self.p_conductor[num][-2], self.p_conductor[num][-1]) + self.p_conductor[num].append([center_point[0], center_point[1], 0, self.mesh_data.c_center_conductor[num]]) + else: raise Exception(f"Unknown wrap para type {virtual_winding_window.wrap_para}") + # Foil conductors where each conductor is very long and the conductors are expanding the y-direction elif winding_scheme == WindingScheme.FoilHorizontal: - # Foil conductors where each conductor is very long and the conductors are expanding the y-direction - # Stack defined number of turns and chosen thickness - winding.a_cell = winding.thickness * (right_bound - left_bound) - for i in range(turns): - # CHECK if top bound is reached - if round(bot_bound + (i + 1) * winding.thickness + i * self.insulation.cond_cond[num][num], 6) <= round(top_bound, 6): - # stacking from the ground - self.p_conductor[num].append([ - left_bound, - bot_bound + i * winding.thickness + i * self.insulation.cond_cond[num][num], - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - right_bound, - bot_bound + i * winding.thickness + i * self.insulation.cond_cond[num][num], - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - left_bound, - bot_bound + (i + 1) * winding.thickness + i * self.insulation.cond_cond[num][num], - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - right_bound, - bot_bound + (i + 1) * winding.thickness + i * self.insulation.cond_cond[num][num], - 0, - self.mesh_data.c_conductor[num]]) - center_point = self.get_center_of_rect(self.p_conductor[num][-4], self.p_conductor[num][-3], - self.p_conductor[num][-2], self.p_conductor[num][-1]) - self.p_conductor[num].append([center_point[0], center_point[1], 0, self.mesh_data.c_center_conductor[num]]) + # the user can choose the thickness + if virtual_winding_window.wrap_para == WrapParaType.FixedThickness: + # Placing Foil horizontal rectangular conductors from bot to top + if foil_horizontal_placing_strategy == FoilHorizontalDistribution.VerticalUpward: + # Stack defined number of turns and chosen thickness + # Find the turn space + winding.a_cell = winding.thickness * (right_bound - left_bound) + for i in range(turns): + # CHECK if top bound is reached + if round( + bot_bound + (i + 1) * winding.thickness + i * self.insulation.cond_cond[num][num], 6 + ) <= round(top_bound, 6): + # stacking from the ground + self.p_conductor[num].append([ + left_bound, + bot_bound + i * winding.thickness + i * self.insulation.cond_cond[num][num], + 0, + self.mesh_data.c_conductor[num]]) + self.p_conductor[num].append([ + right_bound, + bot_bound + i * winding.thickness + i * self.insulation.cond_cond[num][num], + 0, + self.mesh_data.c_conductor[num]]) + self.p_conductor[num].append([ + left_bound, + bot_bound + (i + 1) * winding.thickness + i * self.insulation.cond_cond[num][num], + 0, + self.mesh_data.c_conductor[num]]) + self.p_conductor[num].append([ + right_bound, + bot_bound + (i + 1) * winding.thickness + i * self.insulation.cond_cond[num][num], + 0, + self.mesh_data.c_conductor[num]]) + # Find the center point of each turn + center_point = self.get_center_of_rect(self.p_conductor[num][-4], self.p_conductor[num][-3], + self.p_conductor[num][-2], self.p_conductor[num][-1]) + self.p_conductor[num].append([center_point[0], center_point[1], 0, self.mesh_data.c_center_conductor[num]]) + # Placing Foil horizontal rectangular conductors from top to bot + elif foil_horizontal_placing_strategy == FoilHorizontalDistribution.VerticalDownward: + # Foil conductors where each conductor is very long and the conductors are expanding in the y-direction + # Stack defined number of turns and chosen thickness + winding.a_cell = winding.thickness * (right_bound - left_bound) + for i in range(turns): + # CHECK if bottom bound is reached + if round( + top_bound - (i + 1) * winding.thickness - i * self.insulation.cond_cond[num][num], 6 + ) >= round(bot_bound, 6): + # stacking from the top + self.p_conductor[num].append([ + left_bound, + top_bound - i * winding.thickness - i * self.insulation.cond_cond[num][num], + 0, + self.mesh_data.c_conductor[num]]) + self.p_conductor[num].append([ + right_bound, + top_bound - i * winding.thickness - i * self.insulation.cond_cond[num][num], + 0, + self.mesh_data.c_conductor[num]]) + self.p_conductor[num].append([ + left_bound, + top_bound - (i + 1) * winding.thickness - i * self.insulation.cond_cond[num][num], + 0, + self.mesh_data.c_conductor[num]]) + self.p_conductor[num].append([ + right_bound, + top_bound - (i + 1) * winding.thickness - i * self.insulation.cond_cond[num][num], + 0, + self.mesh_data.c_conductor[num]]) + # Find the center point of each turn + center_point = self.get_center_of_rect(self.p_conductor[num][-4], self.p_conductor[num][-3], + self.p_conductor[num][-2], self.p_conductor[num][-1]) + self.p_conductor[num].append([center_point[0], center_point[1], 0, self.mesh_data.c_center_conductor[num]]) + # Interpolate type is where the foils will have a dynamic thickness + elif virtual_winding_window.wrap_para == WrapParaType.Interpolate: + # Placing Foil horizontal rectangular conductors from bot to top + if foil_horizontal_placing_strategy == FoilHorizontalDistribution.VerticalUpward: + # Turn space + turn_thickness = (top_bound - bot_bound - (turns - 1) * self.insulation.cond_cond[num][num]) / turns + window_width = right_bound - left_bound + winding.a_cell = turn_thickness * window_width + # Generate interpolated positions for each turn, starting from the bottom and moving top + y_interpol = np.linspace(bot_bound, top_bound + self.insulation.cond_cond[num][num], turns + 1) + for i in range(turns): + # Foils + self.p_conductor[num].append([ + left_bound, + y_interpol[i], + 0, + self.mesh_data.c_conductor[num]]) + self.p_conductor[num].append([ + left_bound, + y_interpol[i + 1] - self.insulation.cond_cond[num][num], + 0, + self.mesh_data.c_conductor[num]]) + self.p_conductor[num].append([ + right_bound, + y_interpol[i], + 0, + self.mesh_data.c_conductor[num]]) + self.p_conductor[num].append([ + right_bound, + y_interpol[i + 1] - self.insulation.cond_cond[num][num], + 0, + self.mesh_data.c_conductor[num]]) + # Find the center point of each turn + center_point = self.get_center_of_rect(self.p_conductor[num][-4], self.p_conductor[num][-3], + self.p_conductor[num][-2], self.p_conductor[num][-1]) + self.p_conductor[num].append([center_point[0], center_point[1], 0, self.mesh_data.c_center_conductor[num]]) + # Placing Foil horizontal rectangular conductors from top to bot. + elif foil_horizontal_placing_strategy == FoilHorizontalDistribution.VerticalDownward: + # turn space + turn_thickness = (top_bound - bot_bound - (turns - 1) * self.insulation.cond_cond[num][num]) / turns + window_width = right_bound - left_bound + winding.a_cell = turn_thickness * window_width + # Generate interpolated positions for each turn, starting from the top and moving bottom + y_interpol = np.linspace(top_bound, bot_bound - self.insulation.cond_cond[num][num], turns + 1) + for i in range(turns): + # Foils + self.p_conductor[num].append([ + left_bound, + y_interpol[i], + 0, + self.mesh_data.c_conductor[num]]) + self.p_conductor[num].append([ + left_bound, + y_interpol[i + 1] + self.insulation.cond_cond[num][num], + 0, + self.mesh_data.c_conductor[num]]) + self.p_conductor[num].append([ + right_bound, + y_interpol[i], + 0, + self.mesh_data.c_conductor[num]]) + self.p_conductor[num].append([ + right_bound, + y_interpol[i + 1] + self.insulation.cond_cond[num][num], + 0, + self.mesh_data.c_conductor[num]]) + # Find the center point of each turn. + center_point = self.get_center_of_rect(self.p_conductor[num][-4], self.p_conductor[num][-3], + self.p_conductor[num][-2], self.p_conductor[num][-1]) + self.p_conductor[num].append([center_point[0], center_point[1], 0, self.mesh_data.c_center_conductor[num]]) else: raise Exception(f"Winding scheme {winding_scheme.name} is not implemented.") diff --git a/femmt/enumerations.py b/femmt/enumerations.py index 516c8d66..d8ba617d 100644 --- a/femmt/enumerations.py +++ b/femmt/enumerations.py @@ -224,6 +224,24 @@ class ConductorDistribution(IntEnum): HorizontalLeftward_VerticalDownward = 8 """Places conductors horizontally leftward first, then moves vertically downward for the next set with consistent direction.""" +class FoilVerticalDistribution(IntEnum): + """Defines specific strategies for placing rectangular foil vertical conductors starting from the peripheral (edges) of the virtual winding window.""" + + HorizontalRightward = 1 + """Moves horizontally rightward for the next set with consistent direction.""" + + HorizontalLeftward = 2 + """Moves horizontally leftward for the next set with consistent direction.""" + +class FoilHorizontalDistribution(IntEnum): + """Defines specific strategies for placing rectangular foil horizontal conductors starting from the peripheral (edges) of the virtual winding window.""" + + VerticalUpward = 1 + """Moves vertically upward for the next set with consistent direction.""" + + VerticalDownward = 2 + """Moves vertically downward for the next set with consistent direction.""" + class CenterTappedInterleavingType(IntEnum): """Contains different interleaving types for the center tapped transformer.""" diff --git a/femmt/examples/basic_example_inductor_foil.py b/femmt/examples/basic_example_inductor_foil.py new file mode 100644 index 00000000..56ccac46 --- /dev/null +++ b/femmt/examples/basic_example_inductor_foil.py @@ -0,0 +1,190 @@ +"""Basic example to show how to simulate an inductor with vertical and horizontal foil winding.""" +import femmt as fmt +import os + + +def basic_example_inductor_foil(onelab_folder: str = None, show_visual_outputs: bool = True, is_test: bool = False): + """Run the example code for the inductor with vertical and horizontal foil winding.""" + + def example_thermal_simulation(show_thermal_visual_outputs: bool = True, flag_insulation: bool = True): + # Thermal simulation: + # The losses calculated by the magnetics simulation can be used to calculate the heat distribution of the + # given magnetic component. In order to use the thermal simulation, thermal conductivities for each material + # can be entered as well as a boundary temperature which will be applied on the boundary of the + # simulation (dirichlet boundary condition). + + # The case parameter sets the thermal conductivity for a case which will be set around the core. + # This could model some case in which the transformer is placed in together with a set potting material. + thermal_conductivity_dict = { + "air": 0.0263, + "case": { # epoxy resign + "top": 1.54, + "top_right": 1.54, + "right": 1.54, + "bot_right": 1.54, + "bot": 1.54 + }, + "core": 5, # ferrite + "winding": 400, # copper + "air_gaps": 180, # aluminium nitride + "insulation": 0.42 if flag_insulation else None # polyethylene + } + + # Here the case size can be determined + case_gap_top = 0.002 + case_gap_right = 0.0025 + case_gap_bot = 0.002 + + # Here the boundary temperatures can be set, currently it is set to 20°C (around 293°K). + # This does not change the results of the simulation (at least when every boundary is set equally) + # but will set the temperature offset. + boundary_temperatures = { + "value_boundary_top": 20, + "value_boundary_top_right": 20, + "value_boundary_right_top": 20, + "value_boundary_right": 20, + "value_boundary_right_bottom": 20, + "value_boundary_bottom_right": 20, + "value_boundary_bottom": 20 + } + + # Here the boundary sides can be turned on (1) or off (0) + # By turning off the flag a neumann boundary will be applied at this point with heat flux = 0 + boundary_flags = { + "flag_boundary_top": 0, + "flag_boundary_top_right": 0, + "flag_boundary_right_top": 1, + "flag_boundary_right": 1, + "flag_boundary_right_bottom": 1, + "flag_boundary_bottom_right": 1, + "flag_boundary_bottom": 1 + } + + # In order for the thermal simulation to work an electro_magnetic simulation has to run before. + # The em-simulation will create a file containing the losses. + # When the losses file is already created and contains the losses for the current model, it is enough to + # run geo.create_model in order for the thermal simulation to work (geo.single_simulation is not needed). + # Obviously when the model is modified and the losses can be out of date and therefore the + # geo.single_simulation needs to run again. + geo.thermal_simulation(thermal_conductivity_dict, boundary_temperatures, boundary_flags, case_gap_top, + case_gap_right, case_gap_bot, show_thermal_visual_outputs, + color_scheme=fmt.colors_ba_jonas, colors_geometry=fmt.colors_geometry_ba_jonas, + flag_insulation=flag_insulation) + + example_results_folder = os.path.join(os.path.dirname(__file__), "example_results") + if not os.path.exists(example_results_folder): + os.mkdir(example_results_folder) + + # Example for a transformer with multiple virtual winding windows. + working_directory = os.path.join(example_results_folder, "inductor_foil") + if not os.path.exists(working_directory): + os.mkdir(working_directory) + + # Define configurations + configurations = [ + { # FoilVertical, move Horizontal to the right with fixed thickness + "scheme": fmt.WindingScheme.FoilVertical, + "strategy": fmt.FoilVerticalDistribution.HorizontalRightward, + "wrap_para_type": fmt.WrapParaType.FixedThickness, + "description": "Vertical foil with fixed thickness and horizontal rightward placement" + }, + { # FoilVertical, move Horizontal to the left with fixed thickness + "scheme": fmt.WindingScheme.FoilVertical, + "strategy": fmt.FoilVerticalDistribution.HorizontalLeftward, + "wrap_para_type": fmt.WrapParaType.FixedThickness, + "description": "Vertical foil with fixed thickness and horizontal leftward placement" + }, + { # FoilVertical, move Horizontal to the right with dynamic thickness (interpolate) + "scheme": fmt.WindingScheme.FoilVertical, + "strategy": fmt.FoilVerticalDistribution.HorizontalRightward, + "wrap_para_type": fmt.WrapParaType.Interpolate, + "description": "Vertical foil with interpolate and horizontal rightward placement" + }, + { # FoilVertical, move Horizontal to the left with dynamic thickness (interpolate) + "scheme": fmt.WindingScheme.FoilVertical, + "strategy": fmt.FoilVerticalDistribution.HorizontalLeftward, + "wrap_para_type": fmt.WrapParaType.Interpolate, + "description": "Vertical foil with interpolate and horizontal leftward placement" + }, + { # FoilHorizontal, move upward with fixed thickness + "scheme": fmt.WindingScheme.FoilHorizontal, + "strategy": fmt.FoilHorizontalDistribution.VerticalUpward, + "wrap_para_type": fmt.WrapParaType.FixedThickness, + "description": "Horizontal foil with fixed thickness and vertical upward placement" + }, + { # FoilHorizontal, move downward with fixed thickness + "scheme": fmt.WindingScheme.FoilHorizontal, + "strategy": fmt.FoilHorizontalDistribution.VerticalDownward, + "wrap_para_type": fmt.WrapParaType.FixedThickness, + "description": "Horizontal foil with fixed thickness and vertical downward placement" + }, + { # FoilHorizontal, move upward with dynamic thickness (interpolate) + "scheme": fmt.WindingScheme.FoilHorizontal, + "strategy": fmt.FoilHorizontalDistribution.VerticalUpward, + "wrap_para_type": fmt.WrapParaType.Interpolate, + "description": "Horizontal foil with interpolate and vertical upward placement" + }, + { # FoilHorizontal, move downward with dynamic thickness (interpolate) + "scheme": fmt.WindingScheme.FoilHorizontal, + "strategy": fmt.FoilHorizontalDistribution.VerticalDownward, + "wrap_para_type": fmt.WrapParaType.Interpolate, + "description": "Horizontal foil with interpolate and vertical downward placement" + } + ] + + for config in configurations: + print(f"Running configuration: {config['description']}") + + # Set is_gui = True so FEMMt won't ask for the onelab path if no config is found. + geo = fmt.MagneticComponent(component_type=fmt.ComponentType.Inductor, working_directory=working_directory, + verbosity=fmt.Verbosity.ToConsole, is_gui=is_test) + + # This line is for automated pytest running on GitHub only. Please ignore this line! + if onelab_folder is not None: + geo.file_data.onelab_folder_path = onelab_folder + + core_db = fmt.core_database()["PQ 40/40"] + core_dimensions = fmt.dtos.SingleCoreDimensions(core_inner_diameter=core_db["core_inner_diameter"], + window_w=core_db["window_w"], + window_h=core_db["window_h"], + core_h=core_db["core_h"]) + + core = fmt.Core(core_type=fmt.CoreType.Single, core_dimensions=core_dimensions, + mu_r_abs=3100, phi_mu_deg=12, + sigma=0.6, permeability_datasource=fmt.MaterialDataSource.Custom, + permittivity_datasource=fmt.MaterialDataSource.Custom) + geo.set_core(core) + + air_gaps = fmt.AirGaps(fmt.AirGapMethod.Center, core) + air_gaps.add_air_gap(fmt.AirGapLegPosition.CenterLeg, 0.0005) + geo.set_air_gaps(air_gaps) + + insulation = fmt.Insulation() + insulation.add_core_insulations(0.001, 0.001, 0.002, 0.001) + insulation.add_winding_insulations([[0.0005]]) + geo.set_insulation(insulation) + + winding_window = fmt.WindingWindow(core, insulation) + vww = winding_window.split_window(fmt.WindingWindowSplit.NoSplit) + + winding = fmt.Conductor(0, fmt.Conductivity.Copper, winding_material_temperature=25) + winding.set_rectangular_conductor(thickness=1e-3) + + if config["scheme"] == fmt.WindingScheme.FoilVertical: + vww.set_winding(winding, 5, config["scheme"], wrap_para_type=config["wrap_para_type"], + foil_vertical_placing_strategy=config["strategy"]) + else: + vww.set_winding(winding, 5, config["scheme"], wrap_para_type=config["wrap_para_type"], + foil_horizontal_placing_strategy=config["strategy"]) + + geo.set_winding_windows([winding_window]) + + geo.create_model(freq=100000, pre_visualize_geometry=show_visual_outputs, save_png=False) + + # geo.single_simulation(freq=100000, current=[3], show_fem_simulation_results=show_visual_outputs) + + # example_thermal_simulation(show_visual_outputs, flag_insulation=True) + + +if __name__ == "__main__": + basic_example_inductor_foil(show_visual_outputs=True) diff --git a/femmt/model.py b/femmt/model.py index 88f6070a..eccbb211 100644 --- a/femmt/model.py +++ b/femmt/model.py @@ -77,7 +77,7 @@ def __init__(self, winding_number: int, conductivity: Conductivity, parallel: bo else: raise Exception(f"Material {conductivity.name} not found in database") - def set_rectangular_conductor(self, thickness: float): + def set_rectangular_conductor(self, thickness: float = None): """Set a rectangular, solid conductor.""" if self.conductor_is_set: raise Exception("Only one conductor can be set for each winding!") @@ -766,7 +766,8 @@ def __init__(self, bot_bound: float, top_bound: float, left_bound: float, right_ def set_winding(self, conductor: Conductor, turns: int, winding_scheme: WindingScheme, alignment: Optional[Align] = None, placing_strategy: Optional[ConductorDistribution] = None, zigzag: bool = False, - wrap_para_type: WrapParaType = None): + wrap_para_type: WrapParaType = None, foil_vertical_placing_strategy: Optional[FoilVerticalDistribution] = None, + foil_horizontal_placing_strategy: Optional[FoilHorizontalDistribution] = None): """Set a single winding to the current virtual winding window. A single winding always contains one conductor. :param conductor: Conductor which will be set to the vww. @@ -777,8 +778,14 @@ def set_winding(self, conductor: Conductor, turns: int, winding_scheme: WindingS :type winding_scheme: WindingScheme :param placing_strategy: Placing strategy defines the way the conductors are placing in vww :type placing_strategy: ConductorPlacingStrategy, optional + :param zigzag: Zigzag movement for conductors + :type placing_strategy: bool, define to False :param wrap_para_type: Additional wrap parameter. Not always needed, defaults to None :type wrap_para_type: WrapParaType, optional + :param foil_vertical_placing_strategy: foil_vertical_placing_strategy defines the way the rectangular foil vertical conductors are placing in vww + :type foil_vertical_placing_strategy: FoilVerticalDistribution, optional + :param foil_horizontal_placing_strategy: foil_horizontal_placing_strategy defines the way the rectangular foil Horizontal conductors are placing in vww + :type foil_horizontal_placing_strategy: foil_horizontal_placing_strategy, optional """ self.winding_type = WindingType.Single self.winding_scheme = winding_scheme @@ -786,6 +793,8 @@ def set_winding(self, conductor: Conductor, turns: int, winding_scheme: WindingS self.turns = [0] * (conductor.winding_number + 1) # TODO: find another solution for this (is needed in mesh.py for air_stacked) # self.turns = [0] * (3) # TODO: find another solution for this (is needed in mesh.py for air_stacked) self.placing_strategy = placing_strategy + self.foil_vertical_placing_strategy = foil_vertical_placing_strategy + self.foil_horizontal_placing_strategy = foil_horizontal_placing_strategy self.alignment = alignment self.zigzag = zigzag self.turns.insert(conductor.winding_number, turns) @@ -797,6 +806,12 @@ def set_winding(self, conductor: Conductor, turns: int, winding_scheme: WindingS if winding_scheme is WindingScheme.FoilVertical and wrap_para_type is None: raise Exception("When winding scheme is FoilVertical a wrap para type must be set.") + if winding_scheme is WindingScheme.FoilVertical and foil_vertical_placing_strategy is None: + raise Exception("When winding scheme is FoilVertical a foil_vertical_placing_strategy must be set ") + if winding_scheme is WindingScheme.FoilHorizontal and WrapParaType is None: + raise Exception("When winding scheme is FoilHorizontal a wrap para type must be set.") + if winding_scheme is WindingScheme.FoilHorizontal and foil_horizontal_placing_strategy is None: + raise Exception("When winding scheme is FoilHorizontal a foil_horizontal_placing_strategy must be set ") def set_interleaved_winding(self, conductor1: Conductor, turns1: int, conductor2: Conductor, turns2: int, winding_scheme: InterleavedWindingScheme): From abe9f69ba6ffb1bcc8152a84a31e96a0f98a9060 Mon Sep 17 00:00:00 2001 From: abujazar Date: Tue, 9 Jul 2024 05:49:28 +0200 Subject: [PATCH 2/8] critical change. Caluclate the thickness dynamically und update it in data.py --- femmt/data.py | 12 ++++++++++-- femmt/drawing.py | 26 ++++++++++++++++---------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/femmt/data.py b/femmt/data.py index 7cfc7b21..469aa324 100644 --- a/femmt/data.py +++ b/femmt/data.py @@ -123,6 +123,8 @@ class MeshData: window_w: float windings: List["Conductor"] # This is written as string because it is a forward import + frequency: float + def __init__(self, mesh_accuracy_core: float, mesh_accuracy_window: float, mesh_accuracy_conductor: float, @@ -163,6 +165,7 @@ def update_data(self, frequency: float, skin_mesh_factor: float) -> None: :type skin_mesh_factor: float """ self.skin_mesh_factor = skin_mesh_factor + self.frequency = frequency # Update Skin Depth (needed for meshing) if frequency is not None: @@ -178,6 +181,11 @@ def update_data(self, frequency: float, skin_mesh_factor: float) -> None: elif self.windings[i].conductor_type == ConductorType.RoundLitz: self.c_conductor[i] = self.windings[i].conductor_radius / 4 * self.mesh_accuracy_conductor self.c_center_conductor[i] = self.windings[i].conductor_radius / 4 * self.mesh_accuracy_conductor - else: - self.c_conductor[i] = self.windings[i].thickness / 4 * self.mesh_accuracy_conductor # TODO: dynamic implementation + # else: + # self.c_conductor[i] = self.windings[i].thickness / 4 * self.mesh_accuracy_conductor # TODO: dynamic implementation + # self.c_center_conductor[i] = self.center_factor * self.windings[i].thickness / 4 * self.mesh_accuracy_conductor + elif self.windings[i].conductor_type == ConductorType.RectangularSolid: + if self.windings[i].thickness is None: + continue # Skip update if thickness is not set + self.c_conductor[i] = self.windings[i].thickness / 4 * self.mesh_accuracy_conductor self.c_center_conductor[i] = self.center_factor * self.windings[i].thickness / 4 * self.mesh_accuracy_conductor diff --git a/femmt/drawing.py b/femmt/drawing.py index 413ff4a6..06ac890d 100644 --- a/femmt/drawing.py +++ b/femmt/drawing.py @@ -824,11 +824,11 @@ def draw_conductors(self, draw_top_down=True): # Fill the allowed space in the Winding Window with a chosen number of turns # we need first to calculate the area of every turn # Find the wrap turn space - turn_thickness = (right_bound - left_bound - (turns - 1) * self.insulation.cond_cond[num][num]) / turns + winding.thickness = (right_bound - left_bound - (turns - 1) * self.insulation.cond_cond[num][num]) / turns window_height = top_bound - bot_bound - winding.a_cell = turn_thickness * window_height - # if winding.thickness is None: - # winding.thickness = (right_bound - left_bound - (turns - 1) * self.insulation.cond_cond[num][num]) / turns + winding.a_cell = winding.thickness * window_height + # Update MeshData with the new thickness + self.mesh_data.update_data(frequency=self.mesh_data.frequency, skin_mesh_factor=self.mesh_data.skin_mesh_factor) # Generate interpolated positions for each turn, starting from the left and moving right x_interpol = np.linspace(left_bound, right_bound + self.insulation.cond_cond[num][num], turns + 1) @@ -863,9 +863,11 @@ def draw_conductors(self, draw_top_down=True): # Fill the allowed space in the Winding Window with a chosen number of turns # we need first to calculate the area of every turn # Find the wrap turn space - turn_thickness = (right_bound - left_bound - (turns - 1) * self.insulation.cond_cond[num][num]) / turns + winding.thickness = (right_bound - left_bound - (turns - 1) * self.insulation.cond_cond[num][num]) / turns window_height = top_bound - bot_bound - winding.a_cell = turn_thickness * window_height + winding.a_cell = winding.thickness * window_height + # Update MeshData with the new thickness + self.mesh_data.update_data(frequency=self.mesh_data.frequency, skin_mesh_factor=self.mesh_data.skin_mesh_factor) # Generate interpolated positions for each turn, starting from the right and moving left x_interpol = np.linspace(right_bound, left_bound - self.insulation.cond_cond[num][num], turns + 1) @@ -976,9 +978,11 @@ def draw_conductors(self, draw_top_down=True): # Placing Foil horizontal rectangular conductors from bot to top if foil_horizontal_placing_strategy == FoilHorizontalDistribution.VerticalUpward: # Turn space - turn_thickness = (top_bound - bot_bound - (turns - 1) * self.insulation.cond_cond[num][num]) / turns + winding.thickness = (top_bound - bot_bound - (turns - 1) * self.insulation.cond_cond[num][num]) / turns window_width = right_bound - left_bound - winding.a_cell = turn_thickness * window_width + winding.a_cell = winding.thickness * window_width + # Update MeshData with the new thickness + self.mesh_data.update_data(frequency=self.mesh_data.frequency, skin_mesh_factor=self.mesh_data.skin_mesh_factor) # Generate interpolated positions for each turn, starting from the bottom and moving top y_interpol = np.linspace(bot_bound, top_bound + self.insulation.cond_cond[num][num], turns + 1) for i in range(turns): @@ -1010,9 +1014,11 @@ def draw_conductors(self, draw_top_down=True): # Placing Foil horizontal rectangular conductors from top to bot. elif foil_horizontal_placing_strategy == FoilHorizontalDistribution.VerticalDownward: # turn space - turn_thickness = (top_bound - bot_bound - (turns - 1) * self.insulation.cond_cond[num][num]) / turns + winding.thickness = (top_bound - bot_bound - (turns - 1) * self.insulation.cond_cond[num][num]) / turns window_width = right_bound - left_bound - winding.a_cell = turn_thickness * window_width + winding.a_cell = winding.thickness * window_width + # Update MeshData with the new thickness + self.mesh_data.update_data(frequency=self.mesh_data.frequency, skin_mesh_factor=self.mesh_data.skin_mesh_factor) # Generate interpolated positions for each turn, starting from the top and moving bottom y_interpol = np.linspace(top_bound, bot_bound - self.insulation.cond_cond[num][num], turns + 1) for i in range(turns): From 8f998a093eb6b81c41519aee94855e897a382559 Mon Sep 17 00:00:00 2001 From: abujazar Date: Tue, 9 Jul 2024 09:38:28 +0200 Subject: [PATCH 3/8] simplifying the code in drawing.py and add the alignment --- femmt/drawing.py | 420 ++++++------------ femmt/examples/basic_example_inductor_foil.py | 88 +++- .../examples/basic_inductor_foil_vertical.py | 3 +- femmt/model.py | 6 +- 4 files changed, 220 insertions(+), 297 deletions(-) diff --git a/femmt/drawing.py b/femmt/drawing.py index 06ac890d..b4be5ef8 100644 --- a/femmt/drawing.py +++ b/femmt/drawing.py @@ -754,299 +754,155 @@ def draw_conductors(self, draw_top_down=True): # TODO Add check if turns do not fit in winding window # Foil conductors where each conductor is very high and the conductors are expanding in the x-direction if virtual_winding_window.wrap_para == WrapParaType.FixedThickness: - # Placing Foil vertical rectangular conductors from left to right - if foil_vertical_placing_strategy == FoilVerticalDistribution.HorizontalRightward: - # Wrap defined number of turns and chosen thickness - winding.a_cell = winding.thickness * (top_bound - bot_bound) - for i in range(turns): - # CHECK if right bound is reached - if (left_bound + (i + 1) * winding.thickness + i * self.insulation.cond_cond[num][num]) <= right_bound: - # Foils - self.p_conductor[num].append([ - left_bound + i * winding.thickness + i * self.insulation.cond_cond[num][num], - bot_bound, - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - left_bound + (i + 1) * winding.thickness + i * self.insulation.cond_cond[num][num], - bot_bound, - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - left_bound + i * winding.thickness + i * self.insulation.cond_cond[num][num], - top_bound, - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - left_bound + (i + 1) * winding.thickness + i * self.insulation.cond_cond[num][num], - top_bound, - 0, - self.mesh_data.c_conductor[num]]) - center_point = self.get_center_of_rect(self.p_conductor[num][-4], self.p_conductor[num][-3], - self.p_conductor[num][-2], self.p_conductor[num][-1]) - self.p_conductor[num].append([center_point[0], center_point[1], 0, self.mesh_data.c_center_conductor[num]]) - # Placing Foil vertical rectangular conductors from left to right - elif foil_vertical_placing_strategy == FoilVerticalDistribution.HorizontalLeftward: - # Wrap defined number of turns and chosen thickness - winding.a_cell = winding.thickness * (top_bound - bot_bound) - for i in range(turns): - # CHECK if left bound is reached - if (right_bound - (i + 1) * winding.thickness - i * self.insulation.cond_cond[num][num]) >= left_bound: - # Foils - self.p_conductor[num].append([ - right_bound - i * winding.thickness - i * self.insulation.cond_cond[num][num], - bot_bound, - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - right_bound - (i + 1) * winding.thickness - i * self.insulation.cond_cond[num][num], - bot_bound, - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - right_bound - i * winding.thickness - i * self.insulation.cond_cond[num][num], - top_bound, - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - right_bound - (i + 1) * winding.thickness - i * self.insulation.cond_cond[num][num], - top_bound, - 0, - self.mesh_data.c_conductor[num]]) - # Find the center point for each turn - center_point = self.get_center_of_rect(self.p_conductor[num][-4], self.p_conductor[num][-3], - self.p_conductor[num][-2], self.p_conductor[num][-1]) - self.p_conductor[num].append([center_point[0], center_point[1], 0, self.mesh_data.c_center_conductor[num]]) + # Wrap defined number of turns and chosen thickness + winding.a_cell = winding.thickness * (top_bound - bot_bound) + for i in range(turns): + # Starting point of x depending on the distribution way if it is from left to right or vice versa. + if foil_vertical_placing_strategy == FoilVerticalDistribution.HorizontalRightward: + x_start = left_bound + i * winding.thickness + i * self.insulation.cond_cond[num][num] + x_move = left_bound + (i + 1) * winding.thickness + i * self.insulation.cond_cond[num][num] + if x_move > right_bound: + break + elif foil_vertical_placing_strategy == FoilVerticalDistribution.HorizontalLeftward: + x_start = right_bound - i * winding.thickness - i * self.insulation.cond_cond[num][num] + x_move = right_bound - (i + 1) * winding.thickness - i * self.insulation.cond_cond[num][num] + if x_move < left_bound: + break + # Foil + self.p_conductor[num].extend([ + [x_start, bot_bound, 0, self.mesh_data.c_conductor[num]], + [x_move, bot_bound, 0, self.mesh_data.c_conductor[num]], + [x_start, top_bound, 0, self.mesh_data.c_conductor[num]], + [x_move, top_bound, 0, self.mesh_data.c_conductor[num]] + ]) + # Find the center point of each turn + center_point = self.get_center_of_rect(self.p_conductor[num][-4], self.p_conductor[num][-3], + self.p_conductor[num][-2], self.p_conductor[num][-1]) + self.p_conductor[num].append([center_point[0], center_point[1], 0, self.mesh_data.c_center_conductor[num]]) # Interpolate type is where the foils will have a dynamic thickness elif virtual_winding_window.wrap_para == WrapParaType.Interpolate: - # Placing Foil vertical rectangular conductors from left to right - if foil_vertical_placing_strategy == FoilVerticalDistribution.HorizontalRightward: - # Fill the allowed space in the Winding Window with a chosen number of turns - # we need first to calculate the area of every turn - # Find the wrap turn space - winding.thickness = (right_bound - left_bound - (turns - 1) * self.insulation.cond_cond[num][num]) / turns - window_height = top_bound - bot_bound - winding.a_cell = winding.thickness * window_height - # Update MeshData with the new thickness - self.mesh_data.update_data(frequency=self.mesh_data.frequency, skin_mesh_factor=self.mesh_data.skin_mesh_factor) - # Generate interpolated positions for each turn, starting from the left and moving right - x_interpol = np.linspace(left_bound, right_bound + self.insulation.cond_cond[num][num], turns + 1) - - for i in range(turns): - # Foils - self.p_conductor[num].append([ - x_interpol[i], - bot_bound, - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - x_interpol[i + 1] - self.insulation.cond_cond[num][num], - bot_bound, - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - x_interpol[i], - top_bound, - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - x_interpol[i + 1] - self.insulation.cond_cond[num][num], - top_bound, - 0, - self.mesh_data.c_conductor[num]]) - # Find the center point of each turn - center_point = self.get_center_of_rect(self.p_conductor[num][-4], self.p_conductor[num][-3], - self.p_conductor[num][-2], self.p_conductor[num][-1]) - self.p_conductor[num].append([center_point[0], center_point[1], 0, self.mesh_data.c_center_conductor[num]]) - # Placing Foil vertical rectangular conductors from left to right - elif foil_vertical_placing_strategy == FoilVerticalDistribution.HorizontalLeftward: - # Fill the allowed space in the Winding Window with a chosen number of turns - # we need first to calculate the area of every turn - # Find the wrap turn space - winding.thickness = (right_bound - left_bound - (turns - 1) * self.insulation.cond_cond[num][num]) / turns - window_height = top_bound - bot_bound - winding.a_cell = winding.thickness * window_height - # Update MeshData with the new thickness - self.mesh_data.update_data(frequency=self.mesh_data.frequency, skin_mesh_factor=self.mesh_data.skin_mesh_factor) - # Generate interpolated positions for each turn, starting from the right and moving left - x_interpol = np.linspace(right_bound, left_bound - self.insulation.cond_cond[num][num], turns + 1) - - for i in range(turns): - # Foils - self.p_conductor[num].append([ - x_interpol[i], - bot_bound, - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - x_interpol[i + 1] + self.insulation.cond_cond[num][num], - bot_bound, - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - x_interpol[i], - top_bound, - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - x_interpol[i + 1] + self.insulation.cond_cond[num][num], - top_bound, - 0, - self.mesh_data.c_conductor[num]]) - center_point = self.get_center_of_rect(self.p_conductor[num][-4], self.p_conductor[num][-3], - self.p_conductor[num][-2], self.p_conductor[num][-1]) - self.p_conductor[num].append([center_point[0], center_point[1], 0, self.mesh_data.c_center_conductor[num]]) + # Fill the allowed space in the Winding Window with a chosen number of turns + # we need first to calculate the area of every turn + # Find the wrap turn space + winding.thickness = (right_bound - left_bound - (turns - 1) * self.insulation.cond_cond[num][num]) / turns + window_height = top_bound - bot_bound + winding.a_cell = winding.thickness * window_height + # Update MeshData with the new thickness + self.mesh_data.update_data(frequency=self.mesh_data.frequency, skin_mesh_factor=self.mesh_data.skin_mesh_factor) + for i in range(turns): + if foil_vertical_placing_strategy == FoilVerticalDistribution.HorizontalRightward: + # Generate interpolated positions for each turn, starting from the left and moving right + x_interpol = np.linspace(left_bound, right_bound + self.insulation.cond_cond[num][num], turns + 1) + x_start = x_interpol[i] + x_move = x_interpol[i + 1] - self.insulation.cond_cond[num][num] + elif foil_vertical_placing_strategy == FoilVerticalDistribution.HorizontalLeftward: + # Generate interpolated positions for each turn, starting from the right and moving left + x_interpol = np.linspace(right_bound, left_bound - self.insulation.cond_cond[num][num], turns + 1) + x_start = x_interpol[i] + x_move = x_interpol[i + 1] + self.insulation.cond_cond[num][num] + # Foil + self.p_conductor[num].extend([ + [x_start, bot_bound, 0, self.mesh_data.c_conductor[num]], + [x_move, bot_bound, 0, self.mesh_data.c_conductor[num]], + [x_start, top_bound, 0, self.mesh_data.c_conductor[num]], + [x_move, top_bound, 0, self.mesh_data.c_conductor[num]] + ]) + # Find the center point of each turn + center_point = self.get_center_of_rect(self.p_conductor[num][-4], self.p_conductor[num][-3], + self.p_conductor[num][-2], self.p_conductor[num][-1]) + self.p_conductor[num].append([center_point[0], center_point[1], 0, self.mesh_data.c_center_conductor[num]]) else: raise Exception(f"Unknown wrap para type {virtual_winding_window.wrap_para}") + # Apply alignment + if alignment == Align.ToEdges: + pass + if alignment == Align.CenterOnHorizontalAxis: + raise ValueError("FoilVertical Conductors can not be centered horizontally as they are very high") + if alignment == Align.CenterOnVerticalAxis: + min_x = min(point[0] for point in self.p_conductor[num]) + max_x = max(point[0] for point in self.p_conductor[num]) + occupied_width = max_x - min_x + occupied_midpoint_x = min_x + (occupied_width / 2) + window_midpoint_x = (left_bound + right_bound) / 2 + adjustment_x = window_midpoint_x - occupied_midpoint_x + for i, _ in enumerate(self.p_conductor[num]): + self.p_conductor[num][i][0] += adjustment_x # Foil conductors where each conductor is very long and the conductors are expanding the y-direction elif winding_scheme == WindingScheme.FoilHorizontal: # the user can choose the thickness if virtual_winding_window.wrap_para == WrapParaType.FixedThickness: - # Placing Foil horizontal rectangular conductors from bot to top - if foil_horizontal_placing_strategy == FoilHorizontalDistribution.VerticalUpward: - # Stack defined number of turns and chosen thickness - # Find the turn space - winding.a_cell = winding.thickness * (right_bound - left_bound) - for i in range(turns): - # CHECK if top bound is reached - if round( - bot_bound + (i + 1) * winding.thickness + i * self.insulation.cond_cond[num][num], 6 - ) <= round(top_bound, 6): - # stacking from the ground - self.p_conductor[num].append([ - left_bound, - bot_bound + i * winding.thickness + i * self.insulation.cond_cond[num][num], - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - right_bound, - bot_bound + i * winding.thickness + i * self.insulation.cond_cond[num][num], - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - left_bound, - bot_bound + (i + 1) * winding.thickness + i * self.insulation.cond_cond[num][num], - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - right_bound, - bot_bound + (i + 1) * winding.thickness + i * self.insulation.cond_cond[num][num], - 0, - self.mesh_data.c_conductor[num]]) - # Find the center point of each turn - center_point = self.get_center_of_rect(self.p_conductor[num][-4], self.p_conductor[num][-3], - self.p_conductor[num][-2], self.p_conductor[num][-1]) - self.p_conductor[num].append([center_point[0], center_point[1], 0, self.mesh_data.c_center_conductor[num]]) - # Placing Foil horizontal rectangular conductors from top to bot - elif foil_horizontal_placing_strategy == FoilHorizontalDistribution.VerticalDownward: - # Foil conductors where each conductor is very long and the conductors are expanding in the y-direction - # Stack defined number of turns and chosen thickness - winding.a_cell = winding.thickness * (right_bound - left_bound) - for i in range(turns): - # CHECK if bottom bound is reached - if round( - top_bound - (i + 1) * winding.thickness - i * self.insulation.cond_cond[num][num], 6 - ) >= round(bot_bound, 6): - # stacking from the top - self.p_conductor[num].append([ - left_bound, - top_bound - i * winding.thickness - i * self.insulation.cond_cond[num][num], - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - right_bound, - top_bound - i * winding.thickness - i * self.insulation.cond_cond[num][num], - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - left_bound, - top_bound - (i + 1) * winding.thickness - i * self.insulation.cond_cond[num][num], - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - right_bound, - top_bound - (i + 1) * winding.thickness - i * self.insulation.cond_cond[num][num], - 0, - self.mesh_data.c_conductor[num]]) - # Find the center point of each turn - center_point = self.get_center_of_rect(self.p_conductor[num][-4], self.p_conductor[num][-3], - self.p_conductor[num][-2], self.p_conductor[num][-1]) - self.p_conductor[num].append([center_point[0], center_point[1], 0, self.mesh_data.c_center_conductor[num]]) + # Find the turn space + winding.a_cell = winding.thickness * (right_bound - left_bound) + for i in range(turns): + # Starting point of y depending on the distribution way if it is from left to right or vice versa. + if foil_horizontal_placing_strategy == FoilHorizontalDistribution.VerticalUpward: + y_start = bot_bound + i * winding.thickness + i * self.insulation.cond_cond[num][num] + y_move = bot_bound + (i + 1) * winding.thickness + i * self.insulation.cond_cond[num][num] + if round(y_move) > top_bound: + break + elif foil_horizontal_placing_strategy == FoilHorizontalDistribution.VerticalDownward: + y_start = top_bound - i * winding.thickness - i * self.insulation.cond_cond[num][num] + y_move = top_bound - (i + 1) * winding.thickness - i * self.insulation.cond_cond[num][num] + if round(y_move) < bot_bound: + break + # Foil + self.p_conductor[num].extend([ + [left_bound, y_start, 0, self.mesh_data.c_conductor[num]], + [right_bound, y_start, 0, self.mesh_data.c_conductor[num]], + [left_bound, y_move, 0, self.mesh_data.c_conductor[num]], + [right_bound, y_move, 0, self.mesh_data.c_conductor[num]] + ]) + # Find the center point of each turn + center_point = self.get_center_of_rect(self.p_conductor[num][-4], self.p_conductor[num][-3], + self.p_conductor[num][-2], self.p_conductor[num][-1]) + self.p_conductor[num].append([center_point[0], center_point[1], 0, self.mesh_data.c_center_conductor[num]]) # Interpolate type is where the foils will have a dynamic thickness elif virtual_winding_window.wrap_para == WrapParaType.Interpolate: - # Placing Foil horizontal rectangular conductors from bot to top - if foil_horizontal_placing_strategy == FoilHorizontalDistribution.VerticalUpward: - # Turn space - winding.thickness = (top_bound - bot_bound - (turns - 1) * self.insulation.cond_cond[num][num]) / turns - window_width = right_bound - left_bound - winding.a_cell = winding.thickness * window_width - # Update MeshData with the new thickness - self.mesh_data.update_data(frequency=self.mesh_data.frequency, skin_mesh_factor=self.mesh_data.skin_mesh_factor) - # Generate interpolated positions for each turn, starting from the bottom and moving top - y_interpol = np.linspace(bot_bound, top_bound + self.insulation.cond_cond[num][num], turns + 1) - for i in range(turns): - # Foils - self.p_conductor[num].append([ - left_bound, - y_interpol[i], - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - left_bound, - y_interpol[i + 1] - self.insulation.cond_cond[num][num], - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - right_bound, - y_interpol[i], - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - right_bound, - y_interpol[i + 1] - self.insulation.cond_cond[num][num], - 0, - self.mesh_data.c_conductor[num]]) - # Find the center point of each turn - center_point = self.get_center_of_rect(self.p_conductor[num][-4], self.p_conductor[num][-3], - self.p_conductor[num][-2], self.p_conductor[num][-1]) - self.p_conductor[num].append([center_point[0], center_point[1], 0, self.mesh_data.c_center_conductor[num]]) - # Placing Foil horizontal rectangular conductors from top to bot. - elif foil_horizontal_placing_strategy == FoilHorizontalDistribution.VerticalDownward: - # turn space - winding.thickness = (top_bound - bot_bound - (turns - 1) * self.insulation.cond_cond[num][num]) / turns - window_width = right_bound - left_bound - winding.a_cell = winding.thickness * window_width - # Update MeshData with the new thickness - self.mesh_data.update_data(frequency=self.mesh_data.frequency, skin_mesh_factor=self.mesh_data.skin_mesh_factor) - # Generate interpolated positions for each turn, starting from the top and moving bottom - y_interpol = np.linspace(top_bound, bot_bound - self.insulation.cond_cond[num][num], turns + 1) - for i in range(turns): - # Foils - self.p_conductor[num].append([ - left_bound, - y_interpol[i], - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - left_bound, - y_interpol[i + 1] + self.insulation.cond_cond[num][num], - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - right_bound, - y_interpol[i], - 0, - self.mesh_data.c_conductor[num]]) - self.p_conductor[num].append([ - right_bound, - y_interpol[i + 1] + self.insulation.cond_cond[num][num], - 0, - self.mesh_data.c_conductor[num]]) - # Find the center point of each turn. - center_point = self.get_center_of_rect(self.p_conductor[num][-4], self.p_conductor[num][-3], - self.p_conductor[num][-2], self.p_conductor[num][-1]) - self.p_conductor[num].append([center_point[0], center_point[1], 0, self.mesh_data.c_center_conductor[num]]) + # Turn space + winding.thickness = (top_bound - bot_bound - (turns - 1) * self.insulation.cond_cond[num][num]) / turns + window_width = right_bound - left_bound + winding.a_cell = winding.thickness * window_width + # Update MeshData with the new thickness + self.mesh_data.update_data(frequency=self.mesh_data.frequency, skin_mesh_factor=self.mesh_data.skin_mesh_factor) + for i in range(turns): + # Placing Foil horizontal rectangular conductors from bot to top + if foil_horizontal_placing_strategy == FoilHorizontalDistribution.VerticalUpward: + # Generate interpolated positions for each turn, starting from the bottom and moving top + y_interpol = np.linspace(bot_bound, top_bound + self.insulation.cond_cond[num][num], turns + 1) + y_start = y_interpol[i] + y_move = y_interpol[i + 1] - self.insulation.cond_cond[num][num] + elif foil_horizontal_placing_strategy == FoilHorizontalDistribution.VerticalDownward: + y_interpol = np.linspace(top_bound, bot_bound - self.insulation.cond_cond[num][num], turns + 1) + y_start = y_interpol[i] + y_move = y_interpol[i + 1] + self.insulation.cond_cond[num][num] + # Foil + self.p_conductor[num].extend([ + [left_bound, y_start, 0, self.mesh_data.c_conductor[num]], + [right_bound, y_start, 0, self.mesh_data.c_conductor[num]], + [left_bound, y_move, 0, self.mesh_data.c_conductor[num]], + [right_bound, y_move, 0, self.mesh_data.c_conductor[num]] + ]) + # Find the center point of each turn + center_point = self.get_center_of_rect(self.p_conductor[num][-4], self.p_conductor[num][-3], + self.p_conductor[num][-2], self.p_conductor[num][-1]) + self.p_conductor[num].append([center_point[0], center_point[1], 0, self.mesh_data.c_center_conductor[num]]) + + # Apply alignment + if alignment == Align.ToEdges: + pass + if alignment == Align.CenterOnHorizontalAxis: + min_y = min(point[1] for point in self.p_conductor[num]) + max_y = max(point[1] for point in self.p_conductor[num]) + occupied_height = max_y - min_y + occupied_midpoint_y = min_y + occupied_height / 2 + window_midpoint_y = (bot_bound + top_bound) / 2 + adjustment_y = window_midpoint_y - occupied_midpoint_y + for i, _ in enumerate(self.p_conductor[num]): + self.p_conductor[num][i][1] += adjustment_y + if alignment == Align.CenterOnVerticalAxis: + raise ValueError("FoilHorizontal Conductors can not be centered on vertical axis as they are long") + else: raise Exception(f"Winding scheme {winding_scheme.name} is not implemented.") diff --git a/femmt/examples/basic_example_inductor_foil.py b/femmt/examples/basic_example_inductor_foil.py index 56ccac46..5deb1a08 100644 --- a/femmt/examples/basic_example_inductor_foil.py +++ b/femmt/examples/basic_example_inductor_foil.py @@ -86,49 +86,113 @@ def example_thermal_simulation(show_thermal_visual_outputs: bool = True, flag_in "scheme": fmt.WindingScheme.FoilVertical, "strategy": fmt.FoilVerticalDistribution.HorizontalRightward, "wrap_para_type": fmt.WrapParaType.FixedThickness, - "description": "Vertical foil with fixed thickness and horizontal rightward placement" + "alignment": fmt.Align.CenterOnVerticalAxis, + "description": "Vertical foil with fixed thickness and horizontal rightward placement, centered on vertical axis" }, { # FoilVertical, move Horizontal to the left with fixed thickness "scheme": fmt.WindingScheme.FoilVertical, "strategy": fmt.FoilVerticalDistribution.HorizontalLeftward, "wrap_para_type": fmt.WrapParaType.FixedThickness, - "description": "Vertical foil with fixed thickness and horizontal leftward placement" + "alignment": fmt.Align.CenterOnVerticalAxis, + "description": "Vertical foil with fixed thickness and horizontal leftward placement, centered on vertical axis" }, { # FoilVertical, move Horizontal to the right with dynamic thickness (interpolate) "scheme": fmt.WindingScheme.FoilVertical, "strategy": fmt.FoilVerticalDistribution.HorizontalRightward, "wrap_para_type": fmt.WrapParaType.Interpolate, - "description": "Vertical foil with interpolate and horizontal rightward placement" + "alignment": fmt.Align.CenterOnVerticalAxis, + "description": "Vertical foil with interpolate and horizontal rightward placement, centered on vertical axis" }, { # FoilVertical, move Horizontal to the left with dynamic thickness (interpolate) "scheme": fmt.WindingScheme.FoilVertical, "strategy": fmt.FoilVerticalDistribution.HorizontalLeftward, "wrap_para_type": fmt.WrapParaType.Interpolate, - "description": "Vertical foil with interpolate and horizontal leftward placement" + "alignment": fmt.Align.CenterOnVerticalAxis, + "description": "Vertical foil with interpolate and horizontal leftward placement, centered on vertical axis" }, { # FoilHorizontal, move upward with fixed thickness "scheme": fmt.WindingScheme.FoilHorizontal, "strategy": fmt.FoilHorizontalDistribution.VerticalUpward, "wrap_para_type": fmt.WrapParaType.FixedThickness, - "description": "Horizontal foil with fixed thickness and vertical upward placement" + "alignment": fmt.Align.CenterOnHorizontalAxis, + "description": "Horizontal foil with fixed thickness and vertical upward placement, centered on horizontal axis" }, { # FoilHorizontal, move downward with fixed thickness "scheme": fmt.WindingScheme.FoilHorizontal, "strategy": fmt.FoilHorizontalDistribution.VerticalDownward, "wrap_para_type": fmt.WrapParaType.FixedThickness, - "description": "Horizontal foil with fixed thickness and vertical downward placement" + "alignment": fmt.Align.CenterOnHorizontalAxis, + "description": "Horizontal foil with fixed thickness and vertical downward placement, centered on horizontal axis" }, { # FoilHorizontal, move upward with dynamic thickness (interpolate) "scheme": fmt.WindingScheme.FoilHorizontal, "strategy": fmt.FoilHorizontalDistribution.VerticalUpward, "wrap_para_type": fmt.WrapParaType.Interpolate, - "description": "Horizontal foil with interpolate and vertical upward placement" + "alignment": fmt.Align.CenterOnHorizontalAxis, + "description": "Horizontal foil with interpolate and vertical upward placement, centered on horizontal axis" }, { # FoilHorizontal, move downward with dynamic thickness (interpolate) "scheme": fmt.WindingScheme.FoilHorizontal, "strategy": fmt.FoilHorizontalDistribution.VerticalDownward, "wrap_para_type": fmt.WrapParaType.Interpolate, - "description": "Horizontal foil with interpolate and vertical downward placement" + "alignment": fmt.Align.CenterOnHorizontalAxis, + "description": "Horizontal foil with interpolate and vertical downward placement, centered on horizontal axis" + }, + { # FoilVertical, move Horizontal to the right with fixed thickness, to edges + "scheme": fmt.WindingScheme.FoilVertical, + "strategy": fmt.FoilVerticalDistribution.HorizontalRightward, + "wrap_para_type": fmt.WrapParaType.FixedThickness, + "alignment": fmt.Align.ToEdges, + "description": "Vertical foil with fixed thickness and horizontal rightward placement, to edges" + }, + { # FoilVertical, move Horizontal to the left with fixed thickness, to edges + "scheme": fmt.WindingScheme.FoilVertical, + "strategy": fmt.FoilVerticalDistribution.HorizontalLeftward, + "wrap_para_type": fmt.WrapParaType.FixedThickness, + "alignment": fmt.Align.ToEdges, + "description": "Vertical foil with fixed thickness and horizontal leftward placement, to edges" + }, + { # FoilVertical, move Horizontal to the right with dynamic thickness (interpolate), to edges + "scheme": fmt.WindingScheme.FoilVertical, + "strategy": fmt.FoilVerticalDistribution.HorizontalRightward, + "wrap_para_type": fmt.WrapParaType.Interpolate, + "alignment": fmt.Align.ToEdges, + "description": "Vertical foil with interpolate and horizontal rightward placement, to edges" + }, + { # FoilVertical, move Horizontal to the left with dynamic thickness (interpolate), to edges + "scheme": fmt.WindingScheme.FoilVertical, + "strategy": fmt.FoilVerticalDistribution.HorizontalLeftward, + "wrap_para_type": fmt.WrapParaType.Interpolate, + "alignment": fmt.Align.ToEdges, + "description": "Vertical foil with interpolate and horizontal leftward placement, to edges" + }, + { # FoilHorizontal, move upward with fixed thickness, to edges + "scheme": fmt.WindingScheme.FoilHorizontal, + "strategy": fmt.FoilHorizontalDistribution.VerticalUpward, + "wrap_para_type": fmt.WrapParaType.FixedThickness, + "alignment": fmt.Align.ToEdges, + "description": "Horizontal foil with fixed thickness and vertical upward placement, to edges" + }, + { # FoilHorizontal, move downward with fixed thickness, to edges + "scheme": fmt.WindingScheme.FoilHorizontal, + "strategy": fmt.FoilHorizontalDistribution.VerticalDownward, + "wrap_para_type": fmt.WrapParaType.FixedThickness, + "alignment": fmt.Align.ToEdges, + "description": "Horizontal foil with fixed thickness and vertical downward placement, to edges" + }, + { # FoilHorizontal, move upward with dynamic thickness (interpolate), to edges + "scheme": fmt.WindingScheme.FoilHorizontal, + "strategy": fmt.FoilHorizontalDistribution.VerticalUpward, + "wrap_para_type": fmt.WrapParaType.Interpolate, + "alignment": fmt.Align.ToEdges, + "description": "Horizontal foil with interpolate and vertical upward placement, to edges" + }, + { # FoilHorizontal, move downward with dynamic thickness (interpolate), to edges + "scheme": fmt.WindingScheme.FoilHorizontal, + "strategy": fmt.FoilHorizontalDistribution.VerticalDownward, + "wrap_para_type": fmt.WrapParaType.Interpolate, + "alignment": fmt.Align.ToEdges, + "description": "Horizontal foil with interpolate and vertical downward placement, to edges" } ] @@ -171,11 +235,11 @@ def example_thermal_simulation(show_thermal_visual_outputs: bool = True, flag_in winding.set_rectangular_conductor(thickness=1e-3) if config["scheme"] == fmt.WindingScheme.FoilVertical: - vww.set_winding(winding, 5, config["scheme"], wrap_para_type=config["wrap_para_type"], - foil_vertical_placing_strategy=config["strategy"]) + vww.set_winding(winding, 3, config["scheme"], wrap_para_type=config["wrap_para_type"], + foil_vertical_placing_strategy=config["strategy"], alignment=config["alignment"]) else: - vww.set_winding(winding, 5, config["scheme"], wrap_para_type=config["wrap_para_type"], - foil_horizontal_placing_strategy=config["strategy"]) + vww.set_winding(winding, 3, config["scheme"], wrap_para_type=config["wrap_para_type"], + foil_horizontal_placing_strategy=config["strategy"], alignment=config["alignment"]) geo.set_winding_windows([winding_window]) diff --git a/femmt/examples/basic_inductor_foil_vertical.py b/femmt/examples/basic_inductor_foil_vertical.py index a6ae07e2..e8640c5e 100644 --- a/femmt/examples/basic_inductor_foil_vertical.py +++ b/femmt/examples/basic_inductor_foil_vertical.py @@ -119,7 +119,8 @@ def example_thermal_simulation(show_thermal_visual_outputs: bool = True, flag_in winding = fmt.Conductor(0, fmt.Conductivity.Copper, winding_material_temperature=25) winding.set_rectangular_conductor(thickness=1e-3) - vww.set_winding(winding, 5, fmt.WindingScheme.FoilVertical, wrap_para_type=wrap_para_type) + vww.set_winding(winding, 5, fmt.WindingScheme.FoilVertical, fmt.Align.ToEdges, wrap_para_type=wrap_para_type, + foil_vertical_placing_strategy=fmt.FoilVerticalDistribution.HorizontalRightward) geo.set_winding_windows([winding_window]) geo.create_model(freq=100000, pre_visualize_geometry=show_visual_outputs, save_png=False) diff --git a/femmt/model.py b/femmt/model.py index eccbb211..df9532ee 100644 --- a/femmt/model.py +++ b/femmt/model.py @@ -801,8 +801,10 @@ def set_winding(self, conductor: Conductor, turns: int, winding_scheme: WindingS self.winding_is_set = True self.wrap_para = wrap_para_type - if alignment is not None and placing_strategy is None: - raise Exception("When alignment is there a placing_strategy must be set") + # if alignment is not None and placing_strategy is None: + # raise Exception("When alignment is there a placing_strategy must be set") + # if alignment is not None and (placing_strategy is None and foil_vertical_placing_strategy is None and foil_horizontal_placing_strategy is None): + # raise Exception("When alignment is set, at least one placing strategy must be set") if winding_scheme is WindingScheme.FoilVertical and wrap_para_type is None: raise Exception("When winding scheme is FoilVertical a wrap para type must be set.") From 8e3b4a331f26d7b3a6c88ea547192bd81cc7943a Mon Sep 17 00:00:00 2001 From: abujazar Date: Tue, 9 Jul 2024 10:02:28 +0200 Subject: [PATCH 4/8] adjust foil vertical and horizontal in test --- tests/integration/test_femmt.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/integration/test_femmt.py b/tests/integration/test_femmt.py index 70afb87f..1b8d2245 100644 --- a/tests/integration/test_femmt.py +++ b/tests/integration/test_femmt.py @@ -733,7 +733,8 @@ def fixture_inductor_core_fixed_loss_angle_foil_vertical(temp_folder): winding = fmt.Conductor(0, fmt.Conductivity.Copper, winding_material_temperature=25) winding.set_rectangular_conductor(thickness=1e-3) - vww.set_winding(winding, 5, fmt.WindingScheme.FoilVertical, wrap_para_type=wrap_para_type) + vww.set_winding(winding, 5, fmt.WindingScheme.FoilVertical, fmt.Align.ToEdges, wrap_para_type=wrap_para_type, + foil_vertical_placing_strategy=fmt.FoilVerticalDistribution.HorizontalRightward) geo.set_winding_windows([winding_window]) geo.create_model(freq=100000, pre_visualize_geometry=False, save_png=False) @@ -851,7 +852,8 @@ def fixture_inductor_core_fixed_loss_angle_foil_horizontal(temp_folder): winding = fmt.Conductor(0, fmt.Conductivity.Copper, winding_material_temperature=25) winding.set_rectangular_conductor(thickness=1e-3) - vww.set_winding(winding, 12, fmt.WindingScheme.FoilHorizontal, wrap_para_type=wrap_para_type) + vww.set_winding(winding, 12, fmt.WindingScheme.FoilHorizontal, fmt.Align.ToEdges, wrap_para_type=wrap_para_type, + foil_horizontal_placing_strategy=fmt.FoilHorizontalDistribution.VerticalUpward) geo.set_winding_windows([winding_window]) geo.create_model(freq=100000, pre_visualize_geometry=False, save_png=False) From 85f292224a183fb035a757f6179fe27916ed5bed Mon Sep 17 00:00:00 2001 From: abujazar Date: Tue, 9 Jul 2024 18:15:48 +0200 Subject: [PATCH 5/8] add the functionality of wrapparetype and conductor diestributin to the center tapped transformers. Adjust the test file for the new changes --- femmt/drawing.py | 4 +- .../basic_transformer_center_tapped.py | 4 +- ...basic_transformer_stacked_center_tapped.py | 4 +- femmt/functions_topologies.py | 39 ++++++++++++------- tests/integration/test_femmt.py | 4 +- 5 files changed, 36 insertions(+), 19 deletions(-) diff --git a/femmt/drawing.py b/femmt/drawing.py index b4be5ef8..ebf38f71 100644 --- a/femmt/drawing.py +++ b/femmt/drawing.py @@ -839,12 +839,12 @@ def draw_conductors(self, draw_top_down=True): if foil_horizontal_placing_strategy == FoilHorizontalDistribution.VerticalUpward: y_start = bot_bound + i * winding.thickness + i * self.insulation.cond_cond[num][num] y_move = bot_bound + (i + 1) * winding.thickness + i * self.insulation.cond_cond[num][num] - if round(y_move) > top_bound: + if round(y_move, 6) > round(top_bound, 6): break elif foil_horizontal_placing_strategy == FoilHorizontalDistribution.VerticalDownward: y_start = top_bound - i * winding.thickness - i * self.insulation.cond_cond[num][num] y_move = top_bound - (i + 1) * winding.thickness - i * self.insulation.cond_cond[num][num] - if round(y_move) < bot_bound: + if round(y_move) < round(bot_bound): break # Foil self.p_conductor[num].extend([ diff --git a/femmt/examples/basic_transformer_center_tapped.py b/femmt/examples/basic_transformer_center_tapped.py index 3ea3382f..207a644b 100644 --- a/femmt/examples/basic_transformer_center_tapped.py +++ b/femmt/examples/basic_transformer_center_tapped.py @@ -117,7 +117,9 @@ def example_thermal_simulation(show_thermal_visual_outputs: bool = True, flag_in interleaving_scheme=fmt.InterleavingSchemesFoilLitz.ter_3_4_sec_ter_4_3_sec, primary_additional_bobbin=100, winding_temperature=100, - center_foil_additional_bobbin=0e-3) + center_foil_additional_bobbin=0e-3, + wrap_para_type=fmt.WrapParaType.FixedThickness, + foil_horizontal_placing_strategy=fmt.FoilHorizontalDistribution.VerticalUpward) geo.set_insulation(insulation) geo.set_winding_windows([winding_window]) diff --git a/femmt/examples/basic_transformer_stacked_center_tapped.py b/femmt/examples/basic_transformer_stacked_center_tapped.py index bf9d4e22..4a357664 100644 --- a/femmt/examples/basic_transformer_stacked_center_tapped.py +++ b/femmt/examples/basic_transformer_stacked_center_tapped.py @@ -121,7 +121,9 @@ def example_thermal_simulation(show_thermal_visual_outputs: bool = True, flag_in primary_additional_bobbin=1e-3, winding_temperature=100, bobbin_coil_left=3e-3, - center_foil_additional_bobbin=0e-3) + center_foil_additional_bobbin=0e-3, + wrap_para_type=fmt.WrapParaType.FixedThickness, + foil_horizontal_placing_strategy=fmt.FoilHorizontalDistribution.VerticalUpward) geo.set_insulation(insulation) geo.set_winding_windows([coil_window, transformer_window]) diff --git a/femmt/functions_topologies.py b/femmt/functions_topologies.py index dc9130d6..6dd953fe 100644 --- a/femmt/functions_topologies.py +++ b/femmt/functions_topologies.py @@ -59,7 +59,7 @@ def check_if_primary_conductor_row_fits_in_vww(vww, row_element: ConductorRow, w def place_center_tapped_conductor_row(vwws, row_element, row_winding_scheme_type, no_vww, primary_conductors_to_be_placed, - winding1, winding2, winding3, winding_insulations): + winding1, winding2, winding3, winding_insulations, wrap_para_type, foil_horizontal_placing_strategy=None): """ Place center-tapped conductor row. @@ -71,29 +71,33 @@ def place_center_tapped_conductor_row(vwws, row_element, row_winding_scheme_type :param winding1: :param winding2: :param winding3: + :param wrap_para_type: wrap parameter type + :param foil_horizontal_placing_strategy: strategy for placing foil horizontal windings :return: """ if row_element.winding_tag == WindingTag.Primary: check_if_primary_conductor_row_fits_in_vww(vww=vwws[no_vww], row_element=row_element, winding_element=winding1, winding_insulations=winding_insulations) primary_conductors_to_be_placed -= row_element.number_of_conds_per_row if primary_conductors_to_be_placed >= 0: - vwws[no_vww].set_winding(winding1, row_element.number_of_conds_per_row, row_winding_scheme_type) + vwws[no_vww].set_winding(winding1, row_element.number_of_conds_per_row, row_winding_scheme_type, wrap_para_type=wrap_para_type) elif primary_conductors_to_be_placed < 0: - # In the last row,only th rest shall be placed - vwws[no_vww].set_winding(winding1, row_element.number_of_conds_per_row + primary_conductors_to_be_placed, row_winding_scheme_type) + # In the last row, only the rest shall be placed + vwws[no_vww].set_winding(winding1, row_element.number_of_conds_per_row + primary_conductors_to_be_placed, row_winding_scheme_type, wrap_para_type=wrap_para_type) primary_conductors_to_be_placed = 0 elif row_element.winding_tag == WindingTag.Secondary: - vwws[no_vww].set_winding(winding2, row_element.number_of_conds_per_row, row_winding_scheme_type) + vwws[no_vww].set_winding(winding2, row_element.number_of_conds_per_row, row_winding_scheme_type, + wrap_para_type=wrap_para_type, foil_horizontal_placing_strategy=foil_horizontal_placing_strategy) elif row_element.winding_tag == WindingTag.Tertiary: - vwws[no_vww].set_winding(winding3, row_element.number_of_conds_per_row, row_winding_scheme_type) + vwws[no_vww].set_winding(winding3, row_element.number_of_conds_per_row, row_winding_scheme_type, + wrap_para_type=wrap_para_type, foil_horizontal_placing_strategy=foil_horizontal_placing_strategy) return primary_conductors_to_be_placed def place_windings_in_vwws(vwws, winding_scheme_type, transformer_stack, primary_turns, - winding1, winding2, winding3, winding_insulations): + winding1, winding2, winding3, winding_insulations, wrap_para_type, foil_horizontal_placing_strategy=None): """ Place windings in virtual winding windows. @@ -106,6 +110,8 @@ def place_windings_in_vwws(vwws, winding_scheme_type, transformer_stack, primary :param winding2: :param winding3: :param winding_insulations: + :param wrap_para_type: wrap parameter type + :param foil_horizontal_placing_strategy: strategy for placing foil horizontal windings :return: """ # Count how many virtual winding windows were set @@ -127,7 +133,9 @@ def place_windings_in_vwws(vwws, winding_scheme_type, transformer_stack, primary no_vww=set_vwws, primary_conductors_to_be_placed=primary_conductors_to_be_placed, winding1=winding1, winding2=winding2, winding3=winding3, - winding_insulations=winding_insulations) + winding_insulations=winding_insulations, + wrap_para_type=wrap_para_type, + foil_horizontal_placing_strategy=foil_horizontal_placing_strategy) set_vwws += 1 elif isinstance(row_element, CenterTappedGroup): @@ -166,7 +174,7 @@ def set_center_tapped_windings(core, iso_primary_to_primary, iso_secondary_to_secondary, iso_primary_to_secondary, interleaving_type: CenterTappedInterleavingType, interleaving_scheme: InterleavingSchemesFoilLitz, bobbin_coil_top=None, bobbin_coil_bot=None, bobbin_coil_left=None, bobbin_coil_right=None, - primary_coil_turns=None, winding_temperature: Optional[float] = None): + primary_coil_turns=None, winding_temperature: Optional[float] = None, wrap_para_type=WrapParaType.FixedThickness, foil_horizontal_placing_strategy=None): """ Set center tapped windings. @@ -188,13 +196,15 @@ def set_center_tapped_windings(core, :param primary_radius: :param secondary_parallel_turns: :param secondary_thickness_foil: - :param bobbin_coil_right: - :param bobbin_coil_left: - :param bobbin_coil_bot: - :param bobbin_coil_top: + :param bobbin_coil_right: + :param bobbin_coil_left: + :param bobbin_coil_bot: + :param bobbin_coil_top: :param primary_coil_turns: :param winding_temperature: winding temperature in °C :type winding_temperature: Optional[float] + :param wrap_para_type: wrap parameter type + :param foil_horizontal_placing_strategy: strategy for placing foil horizontal windings :return: """ def define_insulations(): @@ -268,7 +278,8 @@ def define_rows(): vwws_bot, winding_scheme_type = ww_bot.split_with_stack(transformer_stack) # Place the windings in the virtual winding windows - vwws_bot = place_windings_in_vwws(vwws_bot, winding_scheme_type, transformer_stack, primary_turns, winding1, winding2, winding3, winding_insulations) + vwws_bot = place_windings_in_vwws(vwws_bot, winding_scheme_type, transformer_stack, primary_turns, winding1, winding2, winding3, winding_insulations, + wrap_para_type=wrap_para_type, foil_horizontal_placing_strategy=foil_horizontal_placing_strategy) # If "stacked-core", also set primary coil turns if core.core_type == CoreType.Stacked: diff --git a/tests/integration/test_femmt.py b/tests/integration/test_femmt.py index 1b8d2245..76b23243 100644 --- a/tests/integration/test_femmt.py +++ b/tests/integration/test_femmt.py @@ -1356,7 +1356,9 @@ def fixture_transformer_stacked_center_tapped(temp_folder): primary_additional_bobbin=1e-3, winding_temperature=100, bobbin_coil_left=3e-3, - center_foil_additional_bobbin=0e-3) + center_foil_additional_bobbin=0e-3, + wrap_para_type=fmt.WrapParaType.FixedThickness, + foil_horizontal_placing_strategy=fmt.FoilHorizontalDistribution.VerticalUpward) geo.set_insulation(insulation) geo.set_winding_windows([coil_window, transformer_window]) From 3fde691dfac497245756b1c4bdc59d5bb8249697 Mon Sep 17 00:00:00 2001 From: abujazar Date: Tue, 9 Jul 2024 18:19:08 +0200 Subject: [PATCH 6/8] fixing pycode style --- femmt/functions_topologies.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/femmt/functions_topologies.py b/femmt/functions_topologies.py index 6dd953fe..38f962b9 100644 --- a/femmt/functions_topologies.py +++ b/femmt/functions_topologies.py @@ -82,7 +82,8 @@ def place_center_tapped_conductor_row(vwws, row_element, row_winding_scheme_type vwws[no_vww].set_winding(winding1, row_element.number_of_conds_per_row, row_winding_scheme_type, wrap_para_type=wrap_para_type) elif primary_conductors_to_be_placed < 0: # In the last row, only the rest shall be placed - vwws[no_vww].set_winding(winding1, row_element.number_of_conds_per_row + primary_conductors_to_be_placed, row_winding_scheme_type, wrap_para_type=wrap_para_type) + vwws[no_vww].set_winding(winding1, row_element.number_of_conds_per_row + primary_conductors_to_be_placed, row_winding_scheme_type, + wrap_para_type=wrap_para_type) primary_conductors_to_be_placed = 0 elif row_element.winding_tag == WindingTag.Secondary: @@ -174,7 +175,8 @@ def set_center_tapped_windings(core, iso_primary_to_primary, iso_secondary_to_secondary, iso_primary_to_secondary, interleaving_type: CenterTappedInterleavingType, interleaving_scheme: InterleavingSchemesFoilLitz, bobbin_coil_top=None, bobbin_coil_bot=None, bobbin_coil_left=None, bobbin_coil_right=None, - primary_coil_turns=None, winding_temperature: Optional[float] = None, wrap_para_type=WrapParaType.FixedThickness, foil_horizontal_placing_strategy=None): + primary_coil_turns=None, winding_temperature: Optional[float] = None, wrap_para_type=WrapParaType.FixedThickness, + foil_horizontal_placing_strategy=None): """ Set center tapped windings. From 9beebce14185072aca8bb05e4c65993c3c07a8aa Mon Sep 17 00:00:00 2001 From: abujazar Date: Fri, 12 Jul 2024 11:41:15 +0200 Subject: [PATCH 7/8] Replacing the names of alignment with each other --- femmt/drawing.py | 14 ++++---- femmt/enumerations.py | 8 ++--- femmt/examples/basic_example_inductor_foil.py | 32 +++++++++---------- .../examples/basic_transformer_6_windings.py | 6 ++-- gui/femmt_gui.py | 8 ++--- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/femmt/drawing.py b/femmt/drawing.py index ebf38f71..6caa51b2 100644 --- a/femmt/drawing.py +++ b/femmt/drawing.py @@ -817,9 +817,9 @@ def draw_conductors(self, draw_top_down=True): # Apply alignment if alignment == Align.ToEdges: pass - if alignment == Align.CenterOnHorizontalAxis: - raise ValueError("FoilVertical Conductors can not be centered horizontally as they are very high") if alignment == Align.CenterOnVerticalAxis: + raise ValueError("FoilVertical Conductors can not be centered on vertical axis as they are very high") + if alignment == Align.CenterOnHorizontalAxis: min_x = min(point[0] for point in self.p_conductor[num]) max_x = max(point[0] for point in self.p_conductor[num]) occupied_width = max_x - min_x @@ -891,7 +891,7 @@ def draw_conductors(self, draw_top_down=True): # Apply alignment if alignment == Align.ToEdges: pass - if alignment == Align.CenterOnHorizontalAxis: + if alignment == Align.CenterOnVerticalAxis: min_y = min(point[1] for point in self.p_conductor[num]) max_y = max(point[1] for point in self.p_conductor[num]) occupied_height = max_y - min_y @@ -900,8 +900,8 @@ def draw_conductors(self, draw_top_down=True): adjustment_y = window_midpoint_y - occupied_midpoint_y for i, _ in enumerate(self.p_conductor[num]): self.p_conductor[num][i][1] += adjustment_y - if alignment == Align.CenterOnVerticalAxis: - raise ValueError("FoilHorizontal Conductors can not be centered on vertical axis as they are long") + if alignment == Align.CenterOnHorizontalAxis: + raise ValueError("FoilHorizontal Conductors can not be centered on horizontal axis as they are long") else: raise Exception(f"Winding scheme {winding_scheme.name} is not implemented.") @@ -1022,7 +1022,7 @@ def draw_conductors(self, draw_top_down=True): pass # Center the turns on horizontal axis - elif alignment == Align.CenterOnHorizontalAxis: + elif alignment == Align.CenterOnVerticalAxis: # Calculate vertical bounds of the occupied space by turns to adjust y min_y = min(point[1] for point in self.p_conductor[num]) # Find the lowest y position among all turns max_y = max(point[1] for point in self.p_conductor[num]) # Find the highest y position among all turns @@ -1039,7 +1039,7 @@ def draw_conductors(self, draw_top_down=True): self.p_conductor[num][i][1] += adjustment_y # Center the turns on vertical axis - elif alignment == Align.CenterOnVerticalAxis: + elif alignment == Align.CenterOnHorizontalAxis: # Calculate horizontal bounds of the occupied space by turns to adjust x min_x = min(point[0] for point in self.p_conductor[num]) # Find the leftmost x position among all turns max_x = max(point[0] for point in self.p_conductor[num]) # Find the rightmost x position among all turns diff --git a/femmt/enumerations.py b/femmt/enumerations.py index d8ba617d..32450c2a 100644 --- a/femmt/enumerations.py +++ b/femmt/enumerations.py @@ -191,12 +191,12 @@ class Align(IntEnum): ToEdges = 1 """Conductors are placed according to the specified peripheral placing strategy without adjusting for central alignment.""" - CenterOnHorizontalAxis = 2 - """Conductors are centered across the middle line of the horizontal axis.""" - - CenterOnVerticalAxis = 3 + CenterOnVerticalAxis = 2 """Conductors are centered across the middle line of the vertical axis.""" + CenterOnHorizontalAxis = 3 + """Conductors are centered across the middle line of the horizontal axis.""" + class ConductorDistribution(IntEnum): """Defines specific strategies for placing conductors starting from the peripheral (edges) of the virtual winding window.""" diff --git a/femmt/examples/basic_example_inductor_foil.py b/femmt/examples/basic_example_inductor_foil.py index 5deb1a08..ea49a824 100644 --- a/femmt/examples/basic_example_inductor_foil.py +++ b/femmt/examples/basic_example_inductor_foil.py @@ -86,57 +86,57 @@ def example_thermal_simulation(show_thermal_visual_outputs: bool = True, flag_in "scheme": fmt.WindingScheme.FoilVertical, "strategy": fmt.FoilVerticalDistribution.HorizontalRightward, "wrap_para_type": fmt.WrapParaType.FixedThickness, - "alignment": fmt.Align.CenterOnVerticalAxis, - "description": "Vertical foil with fixed thickness and horizontal rightward placement, centered on vertical axis" + "alignment": fmt.Align.CenterOnHorizontalAxis, + "description": "Vertical foil with fixed thickness and horizontal rightward placement, centered on horizontal axis" }, { # FoilVertical, move Horizontal to the left with fixed thickness "scheme": fmt.WindingScheme.FoilVertical, "strategy": fmt.FoilVerticalDistribution.HorizontalLeftward, "wrap_para_type": fmt.WrapParaType.FixedThickness, - "alignment": fmt.Align.CenterOnVerticalAxis, - "description": "Vertical foil with fixed thickness and horizontal leftward placement, centered on vertical axis" + "alignment": fmt.Align.CenterOnHorizontalAxis, + "description": "Vertical foil with fixed thickness and horizontal leftward placement, centered on horizontal axis" }, { # FoilVertical, move Horizontal to the right with dynamic thickness (interpolate) "scheme": fmt.WindingScheme.FoilVertical, "strategy": fmt.FoilVerticalDistribution.HorizontalRightward, "wrap_para_type": fmt.WrapParaType.Interpolate, - "alignment": fmt.Align.CenterOnVerticalAxis, - "description": "Vertical foil with interpolate and horizontal rightward placement, centered on vertical axis" + "alignment": fmt.Align.CenterOnHorizontalAxis, + "description": "Vertical foil with interpolate and horizontal rightward placement, centered on horizontal axis" }, { # FoilVertical, move Horizontal to the left with dynamic thickness (interpolate) "scheme": fmt.WindingScheme.FoilVertical, "strategy": fmt.FoilVerticalDistribution.HorizontalLeftward, "wrap_para_type": fmt.WrapParaType.Interpolate, - "alignment": fmt.Align.CenterOnVerticalAxis, - "description": "Vertical foil with interpolate and horizontal leftward placement, centered on vertical axis" + "alignment": fmt.Align.CenterOnHorizontalAxis, + "description": "Vertical foil with interpolate and horizontal leftward placement, centered on horizontal axis" }, { # FoilHorizontal, move upward with fixed thickness "scheme": fmt.WindingScheme.FoilHorizontal, "strategy": fmt.FoilHorizontalDistribution.VerticalUpward, "wrap_para_type": fmt.WrapParaType.FixedThickness, - "alignment": fmt.Align.CenterOnHorizontalAxis, - "description": "Horizontal foil with fixed thickness and vertical upward placement, centered on horizontal axis" + "alignment": fmt.Align.CenterOnVerticalAxis, + "description": "Horizontal foil with fixed thickness and vertical upward placement, centered on vertical axis" }, { # FoilHorizontal, move downward with fixed thickness "scheme": fmt.WindingScheme.FoilHorizontal, "strategy": fmt.FoilHorizontalDistribution.VerticalDownward, "wrap_para_type": fmt.WrapParaType.FixedThickness, - "alignment": fmt.Align.CenterOnHorizontalAxis, - "description": "Horizontal foil with fixed thickness and vertical downward placement, centered on horizontal axis" + "alignment": fmt.Align.CenterOnVerticalAxis, + "description": "Horizontal foil with fixed thickness and vertical downward placement, centered on vertical axis" }, { # FoilHorizontal, move upward with dynamic thickness (interpolate) "scheme": fmt.WindingScheme.FoilHorizontal, "strategy": fmt.FoilHorizontalDistribution.VerticalUpward, "wrap_para_type": fmt.WrapParaType.Interpolate, - "alignment": fmt.Align.CenterOnHorizontalAxis, - "description": "Horizontal foil with interpolate and vertical upward placement, centered on horizontal axis" + "alignment": fmt.Align.CenterOnVerticalAxis, + "description": "Horizontal foil with interpolate and vertical upward placement, centered on vertical axis" }, { # FoilHorizontal, move downward with dynamic thickness (interpolate) "scheme": fmt.WindingScheme.FoilHorizontal, "strategy": fmt.FoilHorizontalDistribution.VerticalDownward, "wrap_para_type": fmt.WrapParaType.Interpolate, - "alignment": fmt.Align.CenterOnHorizontalAxis, - "description": "Horizontal foil with interpolate and vertical downward placement, centered on horizontal axis" + "alignment": fmt.Align.CenterOnVerticalAxis, + "description": "Horizontal foil with interpolate and vertical downward placement, centered on vertical axis" }, { # FoilVertical, move Horizontal to the right with fixed thickness, to edges "scheme": fmt.WindingScheme.FoilVertical, diff --git a/femmt/examples/basic_transformer_6_windings.py b/femmt/examples/basic_transformer_6_windings.py index 580a1eca..e153100e 100644 --- a/femmt/examples/basic_transformer_6_windings.py +++ b/femmt/examples/basic_transformer_6_windings.py @@ -144,12 +144,12 @@ def example_thermal_simulation(show_thermal_visual_outputs: bool = True, flag_in winding6.set_litz_round_conductor(0.95e-3 / 2, 40, 0.1e-3 / 2, None, fmt.ConductorArrangement.Square) # 7. assign windings to virtual winding windows (cells) - cells[0].set_winding(winding1, 7, fmt.WindingType.Single, fmt.Align.CenterOnVerticalAxis, fmt.ConductorDistribution.VerticalUpward_HorizontalRightward) + cells[0].set_winding(winding1, 7, fmt.WindingType.Single, fmt.Align.CenterOnHorizontalAxis, fmt.ConductorDistribution.VerticalUpward_HorizontalRightward) cells[1].set_winding(winding2, 7, fmt.WindingType.Single, fmt.Align.ToEdges, fmt.ConductorDistribution.VerticalDownward_HorizontalLeftward, zigzag=True) - cells[2].set_winding(winding3, 5, fmt.WindingType.Single, fmt.Align.CenterOnHorizontalAxis, fmt.ConductorDistribution.HorizontalRightward_VerticalUpward, + cells[2].set_winding(winding3, 5, fmt.WindingType.Single, fmt.Align.CenterOnVerticalAxis, fmt.ConductorDistribution.HorizontalRightward_VerticalUpward, zigzag=True) cells[3].set_winding(winding4, 7, fmt.WindingType.Single, fmt.Align.ToEdges, fmt.ConductorDistribution.HorizontalLeftward_VerticalUpward) - cells[4].set_winding(winding5, 5, fmt.WindingType.Single, fmt.Align.CenterOnHorizontalAxis, fmt.ConductorDistribution.HorizontalLeftward_VerticalDownward) + cells[4].set_winding(winding5, 5, fmt.WindingType.Single, fmt.Align.CenterOnVerticalAxis, fmt.ConductorDistribution.HorizontalLeftward_VerticalDownward) cells[5].set_winding(winding6, 6, fmt.WindingType.Single, fmt.Align.ToEdges, fmt.ConductorDistribution.VerticalUpward_HorizontalLeftward) geo.set_winding_windows([winding_window]) diff --git a/gui/femmt_gui.py b/gui/femmt_gui.py index 9aa854a8..c015dc55 100644 --- a/gui/femmt_gui.py +++ b/gui/femmt_gui.py @@ -215,8 +215,8 @@ def __init__(self, parent=None): "+-20": "+/- 20%", "excel": "MS Excel", "ToEdges": "To Edges", - "CenterOnHorizontalAxis": "Center On Horizontal Axis", - "CenterOnVerticalAxis": "Center On Vertical Axis", + "CenterOnVerticalAxis": "Center On Horizontal Axis", + "CenterOnHorizontalAxis": "Center On Vertical Axis", "VerticalUpward_HorizontalRightward": "Vertical Upward, Horizontal Rightward", "VerticalUpward_HorizontalLeftward": "Vertical Upward, Horizontal Leftward", "VerticalDownward_HorizontalRightward": "Vertical Downward, Horizontal Rightward", @@ -2295,8 +2295,8 @@ def md_initialize_controls(self) -> None: alignment_options = [ self.translation_dict["ToEdges"], - self.translation_dict["CenterOnHorizontalAxis"], - self.translation_dict["CenterOnVerticalAxis"] + self.translation_dict["CenterOnVerticalAxis"], + self.translation_dict["CenterOnHorizontalAxis"] ] placement_strategy_options = [ self.translation_dict["VerticalUpward_HorizontalRightward"], From 2f89a88680670913dd2ef21c1b97ff51f9f0885d Mon Sep 17 00:00:00 2001 From: gituser789 <62549000+gituser789@users.noreply.github.com> Date: Fri, 12 Jul 2024 13:49:12 +0200 Subject: [PATCH 8/8] update pytest --- .../transformer_stacked_center_tapped.json | 520 +++++++++--------- 1 file changed, 260 insertions(+), 260 deletions(-) diff --git a/tests/integration/fixtures/transformer_stacked_center_tapped.json b/tests/integration/fixtures/transformer_stacked_center_tapped.json index e17c14b0..71dd3da4 100644 --- a/tests/integration/fixtures/transformer_stacked_center_tapped.json +++ b/tests/integration/fixtures/transformer_stacked_center_tapped.json @@ -4,443 +4,443 @@ "f": 200000, "winding1": { "turn_losses": [ - 0.008541752173831645, - 0.003968218221909105, - 0.001390821221519239, - 0.001851172696353658, - 0.002168267202156991, - 0.002211631087158516, - 0.002598868358241228, - 0.00197685820320632, - 0.002247757225141572, - 0.002033053636656423, - 0.00260015080013749, - 0.001977744302973084, - 0.002247620428588397, - 0.002031911944311252, - 0.001851418342433172, - 0.002167497601032835, - 0.002211171617383295 + 0.008542703107806797, + 0.003968617208521701, + 0.001390905258941591, + 0.00185132696036921, + 0.002168448691368134, + 0.002211807504744031, + 0.002599116132297964, + 0.001977022091587579, + 0.002247943014271974, + 0.002033203709070649, + 0.002600398724133577, + 0.001977908295116525, + 0.002247806197903583, + 0.00203206188742886, + 0.001851572637800228, + 0.002167678999831929, + 0.002211347977640514 ], "flux": [ - 9.15699207751355e-05, - -8.386492840689989e-07 + 9.156992101041677e-05, + -8.386555162293644e-07 ], "flux_over_current": [ - 9.156992077513565e-05, - -8.56113683355559e-07 + 9.156992101041688e-05, + -8.561199607565207e-07 ], "V": [ - 1.075824183307009, - 115.0701561587862 + 1.075832071721707, + 115.0701564544493 ], "number_turns": 17, "I": [ - 1, - 0 + 1.0, + 0.0 ], - "winding_losses": 0.04407591506303424, - "P": 0.5379120916535045, - "Q": 57.5350780793931, - "S": 57.537592572336635 + "winding_losses": 0.04407986839883479, + "P": 0.5379160358608535, + "Q": 57.53507822722465, + "S": 57.53759275703578 }, "winding2": { "turn_losses": [ - 0.1019643920562172 + 0.1019643880033791 ], "flux": [ - 6.286697063614871e-06, - -5.467440528740752e-08 + 6.286697057874954e-06, + -5.467442762732828e-08 ], "flux_over_current": [ - 0, - 0 + 0.0, + 0.0 ], "V": [ - 0.06850455015744664, - 7.900092277562893 + 0.06850457823180017, + 7.900092270414718 ], "number_turns": 2, "I": [ - 0, - 0 + -0.0, + 0.0 ], - "winding_losses": 0.1019643920562172, + "winding_losses": 0.1019643880033791, "P": 0.0, - "Q": 0.0, + "Q": -0.0, "S": 0.0 }, "winding3": { "turn_losses": [ - 0.1019391760302305 + 0.1019391719713209 ], "flux": [ - 6.286682807579194e-06, - -5.467017044024799e-08 + 6.286682801841255e-06, + -5.467019277059482e-08 ], "flux_over_current": [ - 0, - 0 + 0.0, + 0.0 ], "V": [ - 0.06849922803946086, - 7.900074383666314 + 0.06849925610173582, + 7.900074376520628 ], "number_turns": 2, "I": [ - 0, - 0 + -0.0, + 0.0 ], - "winding_losses": 0.1019391760302305, + "winding_losses": 0.1019391719713209, "P": 0.0, - "Q": 0.0, + "Q": -0.0, "S": 0.0 }, - "core_eddy_losses": 0.04383790680275548, - "core_hyst_losses": 0.2460947015967551, + "core_eddy_losses": 0.04383790689903968, + "core_hyst_losses": 0.2460947011205926, "core_parts": { "core_part_1": { - "eddy_losses": 0.02218993737951974, - "hyst_losses": 0.1635433989635752, - "total_core_part_1": 0.18573333634309494 + "eddy_losses": 0.02218993736042537, + "hyst_losses": 0.163543398774068, + "total_core_part_1": 0.1857333361344934 }, "core_part_2": { - "eddy_losses": 0.009791666072425684, - "hyst_losses": 0.03390680946075323, - "total_core_part_2": 0.04369847553317892 + "eddy_losses": 0.009791666071759221, + "hyst_losses": 0.03390680946008991, + "total_core_part_2": 0.04369847553184913 }, "core_part_3": { - "eddy_losses": 0.01140363237555786, - "hyst_losses": 0.04123517175514735, - "total_core_part_3": 0.05263880413070521 + "eddy_losses": 0.0114036324585013, + "hyst_losses": 0.04123517113868308, + "total_core_part_3": 0.05263880359718438 }, "core_part_4": { - "eddy_losses": 0.0001594592866302471, - "hyst_losses": 0.005236988749817697, - "total_core_part_4": 0.005396448036447944 + "eddy_losses": 0.0001594592890253699, + "hyst_losses": 0.005236988789249132, + "total_core_part_4": 0.005396448078274502 }, "core_part_5": { - "eddy_losses": 0.0002932116886217164, - "hyst_losses": 0.002172332667460895, - "total_core_part_5": 0.0024655443560826114 + "eddy_losses": 0.0002932117193285656, + "hyst_losses": 0.002172332958502035, + "total_core_part_5": 0.0024655446778306007 } }, - "all_winding_losses": 0.24797948314948193 + "all_winding_losses": 0.2479834283735348 }, { "f": 200000, "winding1": { "turn_losses": [ - 4.834938066855998e-09, - 3.068316315736771e-09, - 1.704139667869485e-09, - 4.556467064138306e-07, - 1.270781673896084e-07, - 1.437370008324068e-07, - 6.144498980594562e-06, - 7.342939031888047e-07, - 2.698048999031644e-07, - 1.927065621418408e-07, - 4.020416082487182e-06, - 2.117238574102762e-07, - 1.401028591239736e-07, - 1.469967101498047e-07, - 1.498379320040966e-06, - 3.830679178816399e-07, - 2.134419421077562e-07 + 4.835510372452093e-09, + 3.068679263555039e-09, + 1.704341390932952e-09, + 4.557004360827026e-07, + 1.270929821530091e-07, + 1.437537818023121e-07, + 6.145223006157276e-06, + 7.343802598309789e-07, + 2.69836517248095e-07, + 1.927291532985421e-07, + 4.020889780804613e-06, + 2.117485720813924e-07, + 1.401192217657431e-07, + 1.470139352473753e-07, + 1.498556115353888e-06, + 3.831128752685796e-07, + 2.134669196550611e-07 ], "flux": [ - 6.286693688322755e-06, - -5.451418894426435e-08 + 6.286693682634191e-06, + -5.451421146222363e-08 ], "flux_over_current": [ - 0, - 0 + 0.0, + 0.0 ], "V": [ - 0.06850455020148277, - 7.900092282641613 + 0.06850457849838489, + 7.900092275493189 ], "number_turns": 17, "I": [ - 0, - 0 + -0.0, + 0.0 ], - "winding_losses": 1.469150230371631e-05, + "winding_losses": 1.469323208777648e-05, "P": 0.0, - "Q": 0.0, + "Q": -0.0, "S": 0.0 }, "winding2": { "turn_losses": [ - 0.0007108991687329272 + 0.0007108991236104469 ], "flux": [ - 4.512803594008998e-07, - -4.346937050992999e-09 + 4.512803587131295e-07, + -4.346939706114667e-09 ], "flux_over_current": [ - 4.512801685180457e-07, - -4.4162054528517e-09 + 4.5128016783330135e-07, + -4.416208108108973e-09 ], "V": [ - 0.005549567442968834, - 0.5670953848508224 + 0.005549570779663531, + 0.5670953839903473 ], "number_turns": 2, "I": [ - 1, - 0 + 1.0, + 0.0 ], - "winding_losses": 0.0007108991687329272, - "P": 0.002774783721484417, - "Q": 0.2835476924254112, - "S": 0.2835612690486425 + "winding_losses": 0.0007108991236104469, + "P": 0.0027747853898317655, + "Q": 0.28354769199517366, + "S": 0.2835612686347511 }, "winding3": { "turn_losses": [ - 0.0005305673009990069 + 0.0005305672818427922 ], "flux": [ - 4.495543147848843e-07, - -3.709533467276233e-09 + 4.495543146921361e-07, + -3.709535211316626e-09 ], "flux_over_current": [ - 0, - 0 + 0.0, + 0.0 ], "V": [ - 0.004648255527799099, - 0.5649262615859673 + 0.004648257719457393, + 0.5649262614728052 ], "number_turns": 2, "I": [ - 0, - 0 + -0.0, + 0.0 ], - "winding_losses": 0.0005305673009990069, + "winding_losses": 0.0005305672818427922, "P": 0.0, - "Q": 0.0, + "Q": -0.0, "S": 0.0 }, - "core_eddy_losses": 0.0002143439156935739, - "core_hyst_losses": 0.001304281835007416, + "core_eddy_losses": 0.0002143439155122739, + "core_hyst_losses": 0.001304281833331408, "core_parts": { "core_part_1": { - "eddy_losses": 0.0001134494894501494, - "hyst_losses": 0.0008362875522278055, - "total_core_part_1": 0.0009497370416779549 + "eddy_losses": 0.0001134494894393441, + "hyst_losses": 0.0008362875516479464, + "total_core_part_1": 0.0009497370410872906 }, "core_part_2": { - "eddy_losses": 4.973810787009916e-05, - "hyst_losses": 0.000174760369525331, - "total_core_part_2": 0.00022449847739543016 + "eddy_losses": 4.973810781895965e-05, + "hyst_losses": 0.0001747603693220365, + "total_core_part_2": 0.00022449847714099615 }, "core_part_3": { - "eddy_losses": 5.04483320192113e-05, - "hyst_losses": 0.0002679562211271343, - "total_core_part_3": 0.0003184045531463456 + "eddy_losses": 5.044833190153973e-05, + "hyst_losses": 0.0002679562203044421, + "total_core_part_3": 0.0003184045522059818 }, "core_part_4": { - "eddy_losses": 7.073786141215493e-07, - "hyst_losses": 2.52363541580663e-05, - "total_core_part_4": 2.594373277218785e-05 + "eddy_losses": 7.073786123969039e-07, + "hyst_losses": 2.523635408795771e-05, + "total_core_part_4": 2.5943732700354615e-05 }, "core_part_5": { - "eddy_losses": 6.077399914843102e-10, - "hyst_losses": 4.133796908084463e-08, - "total_core_part_5": 4.1945709072328944e-08 + "eddy_losses": 6.077400331077091e-10, + "hyst_losses": 4.133796902455782e-08, + "total_core_part_5": 4.194570905766553e-08 } }, - "all_winding_losses": 0.0012561579720356505 + "all_winding_losses": 0.0012561596375410156 }, { "f": 200000, "winding1": { "turn_losses": [ - 4.79834805092075e-09, - 3.044968012021852e-09, - 1.691150267023873e-09, - 1.496727246903301e-06, - 3.829449565941002e-07, - 2.134134756703817e-07, - 4.01515448268565e-06, - 2.115370663227131e-07, - 1.400551449461836e-07, - 1.470379635490239e-07, - 6.151408629535814e-06, - 7.348953252856075e-07, - 2.69780716479141e-07, - 1.925514115330115e-07, - 4.562666547415435e-07, - 1.270214435421698e-07, - 1.436526138492555e-07 + 4.798916037860224e-09, + 3.045328205928308e-09, + 1.6913504568787e-09, + 1.49690384567642e-06, + 3.829898997613016e-07, + 2.134384500278639e-07, + 4.015627561233917e-06, + 2.115617596845249e-07, + 1.400715021338737e-07, + 1.470551931159929e-07, + 6.152133467749551e-06, + 7.349817515446802e-07, + 2.698123306743806e-07, + 1.925739851248629e-07, + 4.563204579684449e-07, + 1.270362518125225e-07, + 1.436693849787421e-07 ], "flux": [ - 6.286679449050754e-06, - -5.450995373940315e-08 + 6.286679443364881e-06, + -5.450997614145758e-08 ], "flux_over_current": [ - 0, - 0 + 0.0, + 0.0 ], "V": [ - 0.06849922808609141, - 7.900074389044708 + 0.0684992562373434, + 7.900074381899629 ], "number_turns": 17, "I": [ - 0, - 0 + -0.0, + 0.0 ], - "winding_losses": 1.469198159796789e-05, + "winding_losses": 1.469371143618775e-05, "P": 0.0, - "Q": 0.0, + "Q": -0.0, "S": 0.0 }, "winding2": { "turn_losses": [ - 0.000530780790352444 + 0.000530780771185841 ], "flux": [ - 4.495543155702817e-07, - -3.709533537632315e-09 + 4.495543154775827e-07, + -3.709535274063814e-09 ], "flux_over_current": [ - 0, - 0 + 0.0, + 0.0 ], "V": [ - 0.004648255527975351, - 0.5649262616073979 + 0.004648257710071186, + 0.5649262614943001 ], "number_turns": 2, "I": [ - 0, - 0 + -0.0, + 0.0 ], - "winding_losses": 0.000530780790352444, + "winding_losses": 0.000530780771185841, "P": 0.0, - "Q": 0.0, + "Q": -0.0, "S": 0.0 }, "winding3": { "turn_losses": [ - 0.0007105581613914807 + 0.0007105581163531528 ], "flux": [ - 4.512802146938208e-07, - -4.346749945121606e-09 + 4.512802140063889e-07, + -4.346752592841043e-09 ], "flux_over_current": [ - 4.51280024548456e-07, - -4.416018385222308e-09 + 4.512800238640483e-07, + -4.416021033078172e-09 ], "V": [ - 0.005549332366852745, - 0.5670952039333003 + 0.005549335694246558, + 0.5670952030732482 ], "number_turns": 2, "I": [ - 1, - 0 + 1.0, + 0.0 ], - "winding_losses": 0.0007105581613914807, - "P": 0.0027746661834263725, - "Q": 0.28354760196665013, - "S": 0.28356117744406995 + "winding_losses": 0.0007105581163531528, + "P": 0.002774667847123279, + "Q": 0.2835476015366241, + "S": 0.2835611770303439 }, - "core_eddy_losses": 0.0002143429830001761, - "core_hyst_losses": 0.00130429226843181, + "core_eddy_losses": 0.0002143429828191004, + "core_hyst_losses": 0.001304292266753075, "core_parts": { "core_part_1": { - "eddy_losses": 0.0001139340677571248, - "hyst_losses": 0.0008388440332254215, - "total_core_part_1": 0.0009527781009825463 + "eddy_losses": 0.0001139340675496661, + "hyst_losses": 0.0008388440316214416, + "total_core_part_1": 0.0009527780991711077 }, "core_part_2": { - "eddy_losses": 4.962139239588722e-05, - "hyst_losses": 0.0001743243518659552, - "total_core_part_2": 0.0002239457442618424 + "eddy_losses": 4.962139241155262e-05, + "hyst_losses": 0.0001743243519353918, + "total_core_part_2": 0.00022394574434694443 }, "core_part_3": { - "eddy_losses": 5.008482721396263e-05, - "hyst_losses": 0.0002660351283912122, - "total_core_part_3": 0.0003161199556051748 + "eddy_losses": 5.008482722454549e-05, + "hyst_losses": 0.0002660351282522264, + "total_core_part_3": 0.0003161199554767719 }, "core_part_4": { - "eddy_losses": 7.020923680804415e-07, - "hyst_losses": 2.504772900146398e-05, - "total_core_part_4": 2.574982136954442e-05 + "eddy_losses": 7.020923681718612e-07, + "hyst_losses": 2.504772899621523e-05, + "total_core_part_4": 2.5749821364387092e-05 }, "core_part_5": { - "eddy_losses": 6.032651210515042e-10, - "hyst_losses": 4.102594774973978e-08, - "total_core_part_5": 4.1629212870791285e-08 + "eddy_losses": 6.032651639296326e-10, + "hyst_losses": 4.102594779991037e-08, + "total_core_part_5": 4.1629212963840005e-08 } }, - "all_winding_losses": 0.0012560309333418925 + "all_winding_losses": 0.0012560325989751815 } ], "total_losses": { "winding1": { - "total": 0.04410529854693591, + "total": 0.044109255342358815, "turns": [ - 0.008541761807117762, - 0.003968224335193432, - 0.0013908246168091738, - 0.001853125070306975, - 0.0021687772252809746, - 0.002211988237635019, - 0.0026090280117045087, - 0.0019778040341758315, - 0.0022481670851864214, - 0.0020333933811821137, - 0.002610322624849513, - 0.00197869092215578, - 0.002248030312164, - 0.002032251492432935, - 0.0018533729884079545, - 0.0021680076903942587, - 0.0022115287119392523 + 0.008542712742233208, + 0.00396862332252917, + 0.0013909086546334388, + 0.0018532795646509692, + 0.0021689587742500485, + 0.002212164696975861, + 0.0026092769828653553, + 0.001977968033607094, + 0.002248352922291356, + 0.0020335434934170634, + 0.0026105717473821313, + 0.001978855025440151, + 0.002248216129456023, + 0.0020324014753492323, + 0.0018535275143735503, + 0.00216818914895901, + 0.0022117051139451476 ] }, "winding2": { - "total": 0.10320607201530257, + "total": 0.1032060678981754, "turns": [ - 0.10320607201530257 + 0.1032060678981754 ] }, "winding3": { - "total": 0.103180301492621, + "total": 0.10318029736951684, "turns": [ - 0.103180301492621 + 0.10318029736951684 ] }, - "all_windings": 0.25049167205485945, - "eddy_core": 0.04426659370144923, - "hyst_core_fundamental_freq": 0.2460947015967551, - "total_core_part_1": 0.18763585148575543, - "total_eddy_core_part_1": 0.022417320936727013, - "total_hyst_core_part_1": 0.16521853054902844, - "total_core_part_2": 0.04414691975483619, - "total_eddy_core_part_2": 0.009891025572691671, - "total_hyst_core_part_2": 0.03425589418214452, - "total_core_part_3": 0.053273328639456725, - "total_eddy_core_part_3": 0.011504165534791033, - "total_hyst_core_part_3": 0.0417691631046657, - "total_core_part_4": 0.005448141590589677, - "total_eddy_core_part_4": 0.00016086875761244909, - "total_hyst_core_part_4": 0.005287272832977227, - "total_core_part_5": 0.0024656279310045544, - "total_eddy_core_part_5": 0.0002932128996268289, - "total_hyst_core_part_5": 0.0021724150313777255, - "core": 0.2903612952982043, - "total_losses": 0.5408529673530638 + "all_windings": 0.250495620610051, + "eddy_core": 0.04426659379737105, + "hyst_core_fundamental_freq": 0.2460947011205926, + "total_core_part_1": 0.18763585127475177, + "total_eddy_core_part_1": 0.02241732091741438, + "total_hyst_core_part_1": 0.16521853035733738, + "total_core_part_2": 0.044146919753337066, + "total_eddy_core_part_2": 0.009891025571989733, + "total_hyst_core_part_2": 0.034255894181347335, + "total_core_part_3": 0.05327332810486714, + "total_eddy_core_part_3": 0.011504165617627383, + "total_hyst_core_part_3": 0.04176916248723975, + "total_core_part_4": 0.005448141632339244, + "total_eddy_core_part_4": 0.00016086876000593865, + "total_hyst_core_part_4": 0.0052872728723333045, + "total_core_part_5": 0.0024656282527526223, + "total_eddy_core_part_5": 0.00029321293033376266, + "total_hyst_core_part_5": 0.0021724153224188594, + "core": 0.29036129491796364, + "total_losses": 0.5408569155280146 }, "simulation_settings": { "simulation_name": null, - "date": "2023-11-15 08:48:55", + "date": "2024-07-12 13:24:52", "component_type": "IntegratedTransformer", "working_directory": "/home/nikolasf/Dokumente/01_git/30_Python/FEMMT/tests/integration/temp", "core": { @@ -516,7 +516,7 @@ "right_bound": 0.024, "winding_type": "Single", "winding_scheme": "FoilHorizontal", - "wrap_para": null, + "wrap_para": "FixedThickness", "windings": [ { "winding_number": 2, @@ -543,7 +543,7 @@ "right_bound": 0.024, "winding_type": "Single", "winding_scheme": "Single", - "wrap_para": null, + "wrap_para": "FixedThickness", "windings": [ { "winding_number": 0, @@ -570,7 +570,7 @@ "right_bound": 0.024, "winding_type": "Single", "winding_scheme": "Single", - "wrap_para": null, + "wrap_para": "FixedThickness", "windings": [ { "winding_number": 0, @@ -597,7 +597,7 @@ "right_bound": 0.024, "winding_type": "Single", "winding_scheme": "FoilHorizontal", - "wrap_para": null, + "wrap_para": "FixedThickness", "windings": [ { "winding_number": 1, @@ -624,7 +624,7 @@ "right_bound": 0.024, "winding_type": "Single", "winding_scheme": "FoilHorizontal", - "wrap_para": null, + "wrap_para": "FixedThickness", "windings": [ { "winding_number": 2, @@ -651,7 +651,7 @@ "right_bound": 0.024, "winding_type": "Single", "winding_scheme": "Single", - "wrap_para": null, + "wrap_para": "FixedThickness", "windings": [ { "winding_number": 0, @@ -678,7 +678,7 @@ "right_bound": 0.024, "winding_type": "Single", "winding_scheme": "Single", - "wrap_para": null, + "wrap_para": "FixedThickness", "windings": [ { "winding_number": 0, @@ -705,7 +705,7 @@ "right_bound": 0.024, "winding_type": "Single", "winding_scheme": "FoilHorizontal", - "wrap_para": null, + "wrap_para": "FixedThickness", "windings": [ { "winding_number": 1, @@ -773,8 +773,8 @@ } }, "misc": { - "core_2daxi_volume": 4.7045349987507137e-05, - "core_2daxi_total_volume": 8.42732229325462e-05, + "core_2daxi_volume": 4.704534998750719e-05, + "core_2daxi_total_volume": 8.427322293254624e-05, "core_2daxi_weight": 0.0, "wire_lengths": [ 1.8679909918244912,