Skip to content

Commit

Permalink
Merge pull request #53 from upb-lea/Thermal_Simulation
Browse files Browse the repository at this point in the history
Add thermal simulation for all component types
  • Loading branch information
gituser789 authored Oct 20, 2023
2 parents 42d52a0 + 5785eca commit caf3272
Show file tree
Hide file tree
Showing 25 changed files with 1,711 additions and 1,140 deletions.
1,201 changes: 762 additions & 439 deletions femmt/component.py

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions femmt/examples/basic_inductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os

def basic_example_inductor(onelab_folder: str = None, show_visual_outputs: bool = True, is_test: bool = False):
def example_thermal_simulation(show_visual_outputs: bool = True):
def example_thermal_simulation(show_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
Expand All @@ -23,7 +23,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
"core": 5, # ferrite
"winding": 400, # copper
"air_gaps": 180, # aluminiumnitride
"insulation": 0.42 # polyethylen
"insulation": 0.42 if flag_insulation else None # polyethylen
}

# Here the case size can be determined
Expand Down Expand Up @@ -66,7 +66,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
# 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_visual_outputs, color_scheme=fmt.colors_ba_jonas,
colors_geometry=fmt.colors_geometry_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")
Expand Down Expand Up @@ -116,7 +116,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
geo.set_air_gaps(air_gaps)

# 4. set insulations
insulation = fmt.Insulation()
insulation = fmt.Insulation(flag_insulation=True)
insulation.add_core_insulations(0.001, 0.001, 0.004, 0.001)
insulation.add_winding_insulations([[0.0005]])
geo.set_insulation(insulation)
Expand All @@ -133,7 +133,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
# fill_factor=None, conductor_arrangement=fmt.ConductorArrangement.Square)

# 7. add conductor to vww and add winding window to MagneticComponent
vww.set_winding(winding, 9, None)
vww.set_winding(winding, 7, None)
geo.set_winding_windows([winding_window])

# 8. create the model
Expand All @@ -154,7 +154,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
# 9. start simulation

# 7. prepare and start thermal simulation
example_thermal_simulation(show_visual_outputs)
example_thermal_simulation(show_visual_outputs, flag_insulation=True)

if __name__ == "__main__":
basic_example_inductor(show_visual_outputs=True)
10 changes: 5 additions & 5 deletions femmt/examples/basic_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
def basic_example_transformer(onelab_folder: str = None, show_visual_outputs: bool = True, is_test: bool = False):


def example_thermal_simulation(show_visual_outputs: bool = True):
def example_thermal_simulation(show_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
Expand All @@ -24,7 +24,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
"core": 5, # ferrite
"winding": 400, # copper
"air_gaps": 180, # aluminiumnitride
"insulation": 0.42 # polyethylen
"insulation": 0.42 if flag_insulation else None # polyethylen
}

# Here the case size can be determined
Expand Down Expand Up @@ -67,7 +67,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
# 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_visual_outputs, color_scheme=fmt.colors_ba_jonas,
colors_geometry=fmt.colors_geometry_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):
Expand Down Expand Up @@ -101,7 +101,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
geo.set_air_gaps(air_gaps)

# 4. set insulation
insulation = fmt.Insulation()
insulation = fmt.Insulation(flag_insulation=True)
insulation.add_core_insulations(0.001, 0.001, 0.002, 0.001)
insulation.add_winding_insulations([[0.0002, 0.001],
[0.001, 0.0002]])
Expand Down Expand Up @@ -135,7 +135,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
geo.create_model(freq=200000, pre_visualize_geometry=show_visual_outputs)
geo.single_simulation(freq=200000, current=[2, 2], phi_deg=[0, 180], show_fem_simulation_results=show_visual_outputs)

example_thermal_simulation(show_visual_outputs)
example_thermal_simulation(show_visual_outputs, flag_insulation= True)


if __name__ == "__main__":
Expand Down
7 changes: 4 additions & 3 deletions femmt/examples/basic_transformer_center_tapped.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os

def basic_example_transformer_center_tapped(onelab_folder: str = None, show_visual_outputs: bool = True, is_test: bool = False):
def example_thermal_simulation(show_visual_outputs: bool = True):
def example_thermal_simulation(show_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
Expand All @@ -22,7 +22,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
"core": 5, # ferrite
"winding": 400, # copper
"air_gaps": 180, # aluminiumnitride
"insulation": 0.42 # polyethylen
"insulation": 0.42 if flag_insulation else None # polyethylen
}

# Here the case size can be determined
Expand Down Expand Up @@ -64,7 +64,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
# 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_visual_outputs, color_scheme=fmt.colors_ba_jonas, colors_geometry=fmt.colors_geometry_ba_jonas)
case_gap_right, case_gap_bot, show_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):
Expand Down Expand Up @@ -108,6 +108,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):

geo.create_model(freq=200000, pre_visualize_geometry=show_visual_outputs)
geo.single_simulation(freq=200000, current=[20, 120, 120], phi_deg=[0, 180, 180], show_fem_simulation_results=show_visual_outputs)
example_thermal_simulation(show_visual_outputs, flag_insulation=False)

if __name__ == "__main__":
basic_example_transformer_center_tapped(show_visual_outputs=True)
9 changes: 5 additions & 4 deletions femmt/examples/basic_transformer_integrated.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os

def basic_example_transformer_intergrated(onelab_folder: str = None, show_visual_outputs: bool = True, is_test: bool = False):
def example_thermal_simulation(show_visual_outputs: bool = True):
def example_thermal_simulation(show_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
Expand All @@ -22,7 +22,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
"core": 5, # ferrite
"winding": 400, # copper
"air_gaps": 180, # aluminiumnitride
"insulation": 0.42 # polyethylen
"insulation": 0.42 if flag_insulation else None # polyethylen
}

# Here the case size can be determined
Expand Down Expand Up @@ -65,7 +65,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
# 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_visual_outputs, color_scheme=fmt.colors_ba_jonas,
colors_geometry=fmt.colors_geometry_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")
Expand Down Expand Up @@ -103,7 +103,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
geo.set_air_gaps(air_gaps)

# 4. set insulations
insulation = fmt.Insulation()
insulation = fmt.Insulation(flag_insulation=False)
insulation.add_core_insulations(0.001, 0.001, 0.002, 0.001)
insulation.add_winding_insulations([[0.0002, 0.001],
[0.001, 0.0002]])
Expand Down Expand Up @@ -134,6 +134,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
# other simulation options:
# -------------------------
# geo.get_inductances(I0=10, op_frequency=100000, skin_mesh_factor=0.5)
example_thermal_simulation(show_visual_outputs, flag_insulation=False)


if __name__ == "__main__":
Expand Down
8 changes: 4 additions & 4 deletions femmt/examples/basic_transformer_interleaved.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os

def basic_example_transformer_interleaved(onelab_folder: str = None, show_visual_outputs: bool = True, is_test: bool = False):
def example_thermal_simulation(show_visual_outputs: bool = True):
def example_thermal_simulation(show_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
Expand All @@ -22,7 +22,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
"core": 5, # ferrite
"winding": 400, # copper
"air_gaps": 180, # aluminiumnitride
"insulation": 0.42 # polyethylen
"insulation": 0.42 if flag_insulation else None # polyethylen
}

# Here the case size can be determined
Expand Down Expand Up @@ -65,7 +65,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
# 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_visual_outputs, color_scheme=fmt.colors_ba_jonas,
colors_geometry=fmt.colors_geometry_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")
Expand Down Expand Up @@ -131,7 +131,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
visualize_last_fem_simulation=show_visual_outputs)

# 9. start thermal simulation
example_thermal_simulation(show_visual_outputs)
example_thermal_simulation(show_visual_outputs, flag_insulation=True)


if __name__ == "__main__":
Expand Down
10 changes: 5 additions & 5 deletions femmt/examples/basic_transformer_n_winding.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


def basic_example_transformer_n_winding(onelab_folder: str = None, show_visual_outputs: bool = True, is_test: bool = False):
def example_thermal_simulation(show_visual_outputs: bool = True):
def example_thermal_simulation(show_visual_outputs: bool = True, flag_insulation: bool = True):


# Thermal simulation:
Expand All @@ -26,7 +26,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
"core": 5, # ferrite
"winding": 400, # copper
"air_gaps": 180, # aluminiumnitride
"insulation": 0.42 # polyethylen
"insulation": 0.42 if flag_insulation else None # polyethylen
}

# Here the case size can be determined
Expand Down Expand Up @@ -69,7 +69,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
# 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_visual_outputs, color_scheme=fmt.colors_ba_jonas,
colors_geometry=fmt.colors_geometry_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")
Expand Down Expand Up @@ -101,7 +101,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
geo.set_air_gaps(air_gaps)

# 4. set insulation
insulation = fmt.Insulation()
insulation = fmt.Insulation(flag_insulation=True)
insulation.add_core_insulations(0.001, 0.001, 0.002, 0.001)
# insulation.add_winding_insulations([0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002, 0.0002], 0.0005)
insulation.add_winding_insulations(
Expand Down Expand Up @@ -199,7 +199,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
geo.single_simulation(freq=250000, current=[4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
phi_deg=[0, 180, 0, 180, 0, 180, 0, 180, 0, 180, 0, 180], show_fem_simulation_results=show_visual_outputs)
# 7. prepare and start thermal simulation
example_thermal_simulation(show_visual_outputs=show_visual_outputs)
example_thermal_simulation(show_visual_outputs=show_visual_outputs, flag_insulation=True)

# read inductances
# geo.get_inductances(I0=4, op_frequency=250000, skin_mesh_factor=0.5, visualize=False)
Expand Down
10 changes: 6 additions & 4 deletions femmt/examples/basic_transformer_stacked.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
def basic_example_transformer_stacked(onelab_folder: str = None, show_visual_outputs: bool = True, is_test: bool = False):


def example_thermal_simulation(show_visual_outputs: bool = True):
def example_thermal_simulation(show_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
Expand All @@ -25,7 +25,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
"core": 5, # ferrite
"winding": 400, # copper
"air_gaps": 180, # aluminiumnitride
"insulation": 0.42 # polyethylen
"insulation": 0.42 if flag_insulation else None # polyethylen
}

# Here the case size can be determined
Expand Down Expand Up @@ -68,7 +68,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
# 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_visual_outputs, color_scheme=fmt.colors_ba_jonas,
colors_geometry=fmt.colors_geometry_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")
Expand Down Expand Up @@ -102,7 +102,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
geo.set_air_gaps(air_gaps)

# 4. set insulations
insulation = fmt.Insulation()
insulation = fmt.Insulation(flag_insulation=False)
# insulation.add_core_insulations(0.001, 0.001, 0.002, 0.001) # TODO: needed for upper and lower winding window?
insulation.add_core_insulations(0.001, 0.001, 0.001, 0.001) # [bot, top, left, right]
insulation.add_winding_insulations([[0.0002, 0.001],
Expand Down Expand Up @@ -135,6 +135,8 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
# other simulation options:
# -------------------------
# geo.get_inductances(I0=10, op_frequency=100000, skin_mesh_factor=0.5)
# 7. prepare and start thermal simulation
example_thermal_simulation(show_visual_outputs, flag_insulation=False)

if __name__ == "__main__":
basic_example_transformer_stacked(show_visual_outputs=True)
8 changes: 5 additions & 3 deletions femmt/examples/basic_transformer_stacked_center_tapped.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
def basic_example_transformer_stacked_center_tapped(onelab_folder: str = None, show_visual_outputs: bool = True, is_test: bool = False):


def example_thermal_simulation(show_visual_outputs: bool = True):
def example_thermal_simulation(show_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
Expand All @@ -25,7 +25,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
"core": 5, # ferrite
"winding": 400, # copper
"air_gaps": 180, # aluminiumnitride
"insulation": 0.42 # polyethylen
"insulation": 0.42 if flag_insulation else None# polyethylen
}

# Here the case size can be determined
Expand Down Expand Up @@ -68,7 +68,7 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
# 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_visual_outputs, color_scheme=fmt.colors_ba_jonas,
colors_geometry=fmt.colors_geometry_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")
Expand Down Expand Up @@ -130,6 +130,8 @@ def example_thermal_simulation(show_visual_outputs: bool = True):
geo.single_simulation(freq=200000, current=[20, 120, 120], phi_deg=[0, 180, 180], show_fem_simulation_results=show_visual_outputs)

geo.get_inductances(I0=1, op_frequency=200000)
# 7. prepare and start thermal simulation
example_thermal_simulation(show_visual_outputs, flag_insulation=False)

if __name__ == "__main__":
basic_example_transformer_stacked_center_tapped(show_visual_outputs=True)
Loading

0 comments on commit caf3272

Please sign in to comment.