upb-lea / FEM_Magnetics_Toolbox

An Open-Source FEM Magnetics Toolbox for Power Electronic Magnetic Components
https://upb-lea.github.io/FEM_Magnetics_Toolbox/
GNU General Public License v3.0
66 stars 11 forks source link

Missing conductor winding type fails when calculating the wire-volumes #28

Closed gituser789 closed 2 years ago

gituser789 commented 2 years ago

Describe the bug For foil windings, there is no winding type set. This leads to error when calculating the wire-volumes

To Reproduce on current develop branch.

import femmt as fmt
import os

# Choose wrap para type
wrap_para_type = fmt.WrapParaType.FixedThickness
# wrap_para_type = fmt.WrapParaType.Interpolate

working_directory = os.path.join(os.path.dirname(__file__), "example_results" , "inductor_foil")
if not os.path.exists(working_directory):
    os.mkdir(working_directory)

geo = fmt.MagneticComponent(component_type=fmt.ComponentType.Inductor, working_directory=working_directory, silent=False)

core_db = fmt.core_database()["PQ 40/40"]

core = fmt.Core(core_inner_diameter=core_db["core_inner_diameter"], window_w=core_db["window_w"], window_h=core_db["window_h"],
                mu_rel=3100, phi_mu_deg=12,
                sigma=0.6)
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.set_rectangular_conductor(thickness=1e-3)

vww.set_winding(winding, 5, fmt.WindingScheme.FoilVertical, wrap_para_type)
geo.set_winding_window(winding_window)

geo.create_model(freq=100000, visualize_before=True, save_png=False)

geo.single_simulation(freq=100000, current=[3], show_results=True)

Error Message

  File "xxx/FEMMT/femmt/examples/foil_winding_example.py", line 41, in <module>
    geo.single_simulation(freq=100000, current=[3], show_results=True)
  File "xxx/FEMMT/femmt/MagneticComponent.py", line 1517, in single_simulation
    self.calculate_and_write_log()
  File "xxx/FEMMT/femmt/MagneticComponent.py", line 2149, in calculate_and_write_log
    wire_weight_list = self.calculate_wire_weight()
  File "xxx/FEMMT/femmt/MagneticComponent.py", line 1355, in calculate_wire_weight
    for wire_volume in self.calculate_wire_volumes():
  File "xxx/FEMMT/femmt/MagneticComponent.py", line 1319, in calculate_wire_volumes
    winding_type = vww_winding.winding_type
AttributeError: 'Conductor' object has no attribute 'winding_type'

Process finished with exit code 1
JonasHoelscher commented 2 years ago

Fixed in a385827.