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

bug in winding window calculation in integrated transformer #32

Closed gituser789 closed 1 year ago

gituser789 commented 1 year ago

Describe the bug An example code is attached, where the integrated transformer drawing works fine. By increasing the primary winding count in the upper winding window (there is enought free space, see screenshot), the geometry can not be drawn due to the windings does not fit into the winding window.

To Reproduce The following code is working. For the non-working version, change this line

top.set_interleaved_winding(winding1, 28, winding2, 7, fmt.InterleavedWindingScheme.HorizontalAlternating, 0.0005)

to

top.set_interleaved_winding(winding1, 29, winding2, 7, fmt.InterleavedWindingScheme.HorizontalAlternating, 0.0005)
import femmt as fmt
import os

example_results_folder = '/home/user/xxxxxxxx

working_directory = os.path.join(example_results_folder, "integrated-transformer")
if not os.path.exists(working_directory):
    os.mkdir(working_directory)

# 1. chose simulation type
geo = fmt.MagneticComponent(component_type=fmt.ComponentType.IntegratedTransformer, working_directory=working_directory)

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

# 2. set core parameters
core = fmt.Core(window_h=core["window_h"], window_w=core["window_w"], core_inner_diameter=core["core_inner_diameter"],
                mu_rel=3000, phi_mu_deg=12,
                sigma=0.6)
geo.set_core(core)

# 2.1 set stray path parameters
stray_path = fmt.StrayPath(start_index=0, length=geo.core.core_inner_diameter / 2 + geo.core.window_w - 0.001)
geo.set_stray_path(stray_path)

# 3. set air gap parameters
air_gaps = fmt.AirGaps(fmt.AirGapMethod.Percent, core)
air_gaps.add_air_gap(fmt.AirGapLegPosition.CenterLeg, 0.001, 25)
air_gaps.add_air_gap(fmt.AirGapLegPosition.CenterLeg, 0.001, 30)
geo.set_air_gaps(air_gaps)

# 4. set insulations
insulation = fmt.Insulation()
insulation.add_core_insulations(0.001, 0.001, 0.001, 0.001)
insulation.add_winding_insulations([0.0002, 0.0002], 0.0001)
geo.set_insulation(insulation)

# 5. create winding window and virtual winding windows (vww)
# For an integrated transformer it is not necessary to set horizontal and vertical split factors
# since this is determined by the stray_path
winding_window = fmt.WindingWindow(core, insulation, stray_path, air_gaps)
top, bot = winding_window.split_window(fmt.WindingWindowSplit.HorizontalSplit)

litz_database = fmt.litz_database()
litz_prim = litz_database["1.4x200x0.071"]
litz_sec = litz_database["2.0x800x0.05"]

# 6. set conductor parameters
winding1 = fmt.Conductor(0, fmt.Conductivity.Copper)
winding1.set_litz_round_conductor(litz_prim["conductor_radii"], litz_prim["strands_numbers"], litz_prim["strand_radii"], None, fmt.ConductorArrangement.Square)

winding2 = fmt.Conductor(1, fmt.Conductivity.Copper)
winding2.set_litz_round_conductor(litz_sec["conductor_radii"], litz_sec["strands_numbers"], litz_sec["strand_radii"], None, fmt.ConductorArrangement.Square)

# 7. add conductor to vww and add winding window to MagneticComponent
top.set_interleaved_winding(winding1, 28, winding2, 7, fmt.InterleavedWindingScheme.HorizontalAlternating, 0.0005)
bot.set_interleaved_winding(winding1, 0, winding2, 6, fmt.InterleavedWindingScheme.HorizontalAlternating, 0.0005)
geo.set_winding_window(winding_window)

# 8. start simulation with given frequency, currents and phases
geo.create_model(freq=250000, visualize_before=True)
geo.single_simulation(freq=250000, current=[8.0, 4.0], phi_deg=[0, 180])

# other simulation options:
# -------------------------
# geo.get_inductances(I0=10, op_frequency=100000, skin_mesh_factor=0.5)

Expected behavior transformer drawing will be created, also with more windings due to the free space, see screenshot.

Screenshots image

Desktop (please complete the following information): Current develop version