Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NF] adding possibility to have key in notch #658

Merged
merged 58 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
e898e80
[WP] Adding new feature key
Oct 2, 2023
5e15451
[WP] Adding key to SlotM11 and possibility to have notch for slot tra…
Oct 3, 2023
a3d00b4
[WP] adding GUI to key in notch,
Oct 4, 2023
75b3cbf
[BC] test correction
Oct 5, 2023
6ffdd7d
Merge branch 'master' of https://github.com/Eomys/pyleecan into Key
Oct 5, 2023
aa1b78f
[NF] Build & Plot key
BonneelP Oct 5, 2023
389e84c
[WP] adding test for slot with key
Oct 6, 2023
f3f1d07
[WIP] Draw Keys in FEMM
BonneelP Oct 6, 2023
47da222
Merge branch 'Key' of https://github.com/EOMYS-Public/pyleecan into Key
BonneelP Oct 6, 2023
e244107
[WIP] Handles materials in Keys
BonneelP Oct 6, 2023
ae30383
[WIP] Extend Key tests to check several issues
BonneelP Oct 6, 2023
6552d62
[WIP] Keys BC in FEMM
BonneelP Oct 9, 2023
71015be
[BC] Adding missing label
BonneelP Oct 9, 2023
70196ae
[BC] Copy/Rotate error
BonneelP Oct 9, 2023
e1a7c92
[BC] Update tests
BonneelP Oct 9, 2023
0589cb9
[BC] No cut error with keys
BonneelP Oct 9, 2023
a859fc9
[CC] Updating tests
BonneelP Oct 10, 2023
856ff9f
[BC] update widget material
Oct 10, 2023
8bc3b00
Merge branch 'Key' of https://github.com/EOMYS-Public/pyleecan into Key
Oct 10, 2023
46cdcee
Merge branch 'master' of https://github.com/Eomys/pyleecan into Key
BonneelP Oct 10, 2023
83976eb
[CO] Display error in resource generation
BonneelP Oct 11, 2023
f3492b2
Merge branch 'master' of https://github.com/Eomys/pyleecan into Key
BonneelP Oct 11, 2023
49ca0e9
[WP]
Oct 11, 2023
9937814
Merge branch 'Key' of https://github.com/EOMYS-Public/pyleecan into Key
Oct 11, 2023
681d86b
[WP]Rename ventilation, add fig.tight_layout() for all plot
Oct 11, 2023
0100c72
[BC] merge typo
BonneelP Oct 11, 2023
10e7ee2
Merge branch 'Key' of https://github.com/EOMYS-Public/pyleecan into Key
BonneelP Oct 11, 2023
d891201
[CC] correction schematics HoleM58
Oct 12, 2023
2a55d09
Merge branch 'Key' of https://github.com/EOMYS-Public/pyleecan into Key
Oct 12, 2023
d407795
[BC] correction display SlotM19
Oct 12, 2023
2b9db9a
[CC] Docstring
BonneelP Oct 12, 2023
5895bec
[CC] Remove unnecessary copy
BonneelP Oct 12, 2023
873d53b
[CC] docstring
BonneelP Oct 12, 2023
ef6fce4
[CC] cleaning code and correction build geometry for SlotW16
Oct 12, 2023
dfbb35d
Merge branch 'Key' of https://github.com/EOMYS-Public/pyleecan into Key
Oct 12, 2023
25c61cb
[CO] Avoid unnecessary transformations
BonneelP Oct 12, 2023
28287e9
Merge branch 'Key' of https://github.com/EOMYS-Public/pyleecan into Key
BonneelP Oct 12, 2023
4d6a734
[CC] Comments
BonneelP Oct 12, 2023
ab41a2a
[BC] Wedge/spacer/editable combobox
BonneelP Oct 12, 2023
f65dc89
Merge branch 'Key' of https://github.com/EOMYS-Public/pyleecan into Key
BonneelP Oct 12, 2023
a067435
[Co] Remove unnecessary loop on notches
BonneelP Oct 12, 2023
e8d38e5
[CC] Comment
BonneelP Oct 12, 2023
7b18ca5
[CO] Improve duplicate filtering
BonneelP Oct 12, 2023
4de7cee
[WP] typo
AdrienLeduqueEomys Oct 13, 2023
fd2de2a
Code duplication
AdrienLeduqueEomys Oct 13, 2023
10c0083
[CC] Remove duplication
AdrienLeduqueEomys Oct 13, 2023
e752f2e
[WP] Factorisation add BH curve to femm
AdrienLeduqueEomys Oct 13, 2023
c25c090
Merge branch 'Key' of github.com:EOMYS-Public/pyleecan into Key
AdrienLeduqueEomys Oct 13, 2023
e481ef9
[CC] Remove useless code line
AdrienLeduqueEomys Oct 13, 2023
7dfe9ba
[CC] remove useless line
AdrienLeduqueEomys Oct 13, 2023
e5235b7
[CC] correction schematics and add test for key
Oct 13, 2023
e0a6787
Merge branch 'Key' of https://github.com/EOMYS-Public/pyleecan into Key
Oct 13, 2023
0c4e9a0
[CC] simplified statement
AdrienLeduqueEomys Oct 13, 2023
8b6b5b0
[CO] For test PMSLot10/11
Oct 13, 2023
596afe8
[BC] Keys with H0=0
BonneelP Oct 13, 2023
3e4930d
Merge branch 'Key' of https://github.com/EOMYS-Public/pyleecan into Key
BonneelP Oct 13, 2023
df83c30
[BC] Update test
BonneelP Oct 13, 2023
8d99769
[CC] Close plot
BonneelP Oct 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions Tests/GUI/Dialog/DMachineSetup/PMSlot/test_PMSlot10.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
from Tests.GUI import gui_option # Set unit as [m]
from pyleecan.Classes.LamSlotMag import LamSlotMag
from pyleecan.Classes.SlotM10 import SlotM10
from pyleecan.Classes.Notch import Notch
from pyleecan.GUI.Dialog.DMachineSetup.SMSlot.PMSlot10.PMSlot10 import PMSlot10
from pyleecan.Classes.Material import Material
from pyleecan.GUI.Dialog.DMatLib.DMatLib import MACH_KEY, LIB_KEY


import pytest
Expand Down Expand Up @@ -115,6 +118,50 @@ def test_check(self):
self.test_obj.slot = SlotM10(H0=0.10, Hmag=0.10, W0=0.10, Wmag=None)
assert self.widget.check(self.test_obj) == "You must set Wmag !"

def test_set_Wkey(self):
AdrienLeduqueEomys marked this conversation as resolved.
Show resolved Hide resolved
"""Check that the Widget allow to update Wkey"""
self.test_obj = LamSlotMag(Rint=0.1, Rext=0.2)
self.test_obj.slot = SlotM10(H0=0.10, W0=0.13, Wmag=0.14, Hmag=0.15)
self.material_dict = {LIB_KEY: list(), MACH_KEY: list()}
self.mat1 = Material(name="Steel1")
notch = Notch(self.mat1, None, None)
self.widget = PMSlot10(
self.test_obj, material_dict=self.material_dict, notch_obj=notch
)

self.widget.g_key.setChecked(True)
assert self.widget.g_key.isChecked()

# Check Unit
assert self.widget.unit_Wkey.text() == "[m]"
# Change value in GUI
self.widget.lf_Wkey.clear()
QTest.keyClicks(self.widget.lf_Wkey, "0.61")
self.widget.lf_Wkey.editingFinished.emit() # To trigger the slot

assert self.widget.slot.Wmag == 0.61

def test_set_Hkey(self):
"""Check that the Widget allow to update Hkey"""
self.test_obj = LamSlotMag(Rint=0.1, Rext=0.2)
self.test_obj.slot = SlotM10(H0=0.10, W0=0.13, Wmag=0.14, Hmag=0.15)
self.material_dict = {LIB_KEY: list(), MACH_KEY: list()}
self.mat1 = Material(name="Steel1")
notch = Notch(self.mat1, None, None)
self.widget = PMSlot10(
self.test_obj, material_dict=self.material_dict, notch_obj=notch
)
self.widget.g_key.setChecked(True)
assert self.widget.g_key.isChecked()
# Check Unit
assert self.widget.unit_Hkey.text() == "[m]"
# Change value in GUI
self.widget.lf_Hkey.clear()
QTest.keyClicks(self.widget.lf_Hkey, "0.61")
self.widget.lf_Hkey.editingFinished.emit() # To trigger the slot

assert self.widget.slot.Hmag == 0.61


if __name__ == "__main__":
a = TestPMSlot10()
Expand Down
52 changes: 52 additions & 0 deletions Tests/GUI/Dialog/DMachineSetup/PMSlot/test_PMSlot11.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
from pyleecan.Classes.LamSlotMag import LamSlotMag
from pyleecan.Classes.SlotM11 import SlotM11
from pyleecan.GUI.Dialog.DMachineSetup.SMSlot.PMSlot11.PMSlot11 import PMSlot11
from pyleecan.Classes.Notch import Notch
from pyleecan.Classes.Material import Material
from pyleecan.GUI.Dialog.DMatLib.DMatLib import MACH_KEY, LIB_KEY


import pytest
Expand Down Expand Up @@ -192,6 +195,55 @@ def test_check(self):
)
assert self.widget.check(self.test_obj) is None

def test_set_Wkey(self):
"""Check that the Widget allow to update Wkey"""
self.test_obj = LamSlotMag(Rint=0.1, Rext=0.2)
self.test_obj.slot = SlotM11(H0=0.10, W0=0.13, Wmag=0.14, Hmag=0.15)
self.material_dict = {LIB_KEY: list(), MACH_KEY: list()}
self.mat1 = Material(name="Steel1")
notch = Notch(self.mat1, None, None)
self.widget = PMSlot11(
self.test_obj, material_dict=self.material_dict, notch_obj=notch
)

self.widget.g_key.setChecked(True)
assert self.widget.g_key.isChecked()

self.widget.c_Wkey_unit.setCurrentIndex(0)
assert self.widget.c_Wkey_unit.currentText() == "rad"

self.widget.c_Wkey_unit.setCurrentIndex(1)
assert self.widget.c_Wkey_unit.currentText() == "deg"

self.widget.c_Wkey_unit.setCurrentIndex(0)
# Change value in GUI
self.widget.lf_Wkey.clear()
QTest.keyClicks(self.widget.lf_Wkey, "0.61")
self.widget.lf_Wkey.editingFinished.emit() # To trigger the slot

assert self.widget.slot.Wmag == 0.61
AdrienLeduqueEomys marked this conversation as resolved.
Show resolved Hide resolved

def test_set_Hkey(self):
"""Check that the Widget allow to update Hkey"""
self.test_obj = LamSlotMag(Rint=0.1, Rext=0.2)
self.test_obj.slot = SlotM11(H0=0.10, W0=0.13, Wmag=0.14, Hmag=0.15)
self.material_dict = {LIB_KEY: list(), MACH_KEY: list()}
self.mat1 = Material(name="Steel1")
notch = Notch(self.mat1, None, None)
self.widget = PMSlot11(
self.test_obj, material_dict=self.material_dict, notch_obj=notch
)
self.widget.g_key.setChecked(True)
assert self.widget.g_key.isChecked()
# Check Unit
assert self.widget.unit_Hkey.text() == "[m]"
# Change value in GUI
self.widget.lf_Hkey.clear()
QTest.keyClicks(self.widget.lf_Hkey, "0.61")
self.widget.lf_Hkey.editingFinished.emit() # To trigger the slot

assert self.widget.slot.Hmag == 0.61


if __name__ == "__main__":
a = TestPMSlot11()
Expand Down
2 changes: 1 addition & 1 deletion Tests/GUI/Dialog/DMachineSetup/PWSlot/test_PWSlot14.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def test_set_wedge(self):

# Add new type wedge
self.widget.c_wedge_type.setCurrentIndex(1)
assert str(self.widget.c_wedge_type.currentText()) == "Normal"
assert str(self.widget.c_wedge_type.currentText()) == "Standard"
assert self.test_obj.slot.wedge_type == 1


Expand Down
2 changes: 1 addition & 1 deletion Tests/GUI/Dialog/DMachineSetup/PWSlot/test_PWSlot29.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def test_set_wedge(self):
assert self.test_obj.slot.wedge_mat.name == "M400-50A"
# Add new type wedge
self.widget.c_wedge_type.setCurrentIndex(1)
assert str(self.widget.c_wedge_type.currentText()) == "Normal"
assert str(self.widget.c_wedge_type.currentText()) == "Standard"
assert self.test_obj.slot.wedge_type == 1


Expand Down
3 changes: 3 additions & 0 deletions Tests/GUI/Dialog/DMachineSetup/test_notche_addition.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ def test_notch_addition(self):
notche_wid.w_notch.lf_H0.editingFinished.emit()
assert notche_wid.w_notch.lf_W0.value() == W0
notche_wid.w_notch.lf_W0.editingFinished.emit()
# No key by default
assert not notche_wid.w_notch.g_key.isChecked()
assert notche_wid.w_notch.notch_obj.key_mat is None
# Checking plot/preview function
notche_wid.b_plot.clicked.emit()
self.widget.w_step.notches_win.b_plot.clicked.emit()
Expand Down
4 changes: 3 additions & 1 deletion Tests/Methods/Machine/test_get_polar_eq.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ def test_get_polar_eq_SCIM(self):

fig = plt.gcf()
fig.savefig(join(save_path, "test_get_polar_eq_SCIM_001.png"))
assert len(fig.axes[0].patches) == 227
# 8 Vent + 1 shaft + (2 stator + 2 rotor + 36 slot *2 layers + 28 slot * 1 layer+ 1 SCR)*2
assert len(fig.axes[0].patches) == 219


if __name__ == "__main__":
a = Test_get_polar_eq()
a.test_get_polar_eq_SCIM()
print("Done")
105 changes: 103 additions & 2 deletions Tests/Methods/Slot/test_HoleM58_meth.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest

from pyleecan.Classes.LamHole import LamHole
from pyleecan.Classes.Hole import Hole
from pyleecan.Classes.LamSlotWind import LamSlotWind
from pyleecan.Classes.MachineIPMSM import MachineIPMSM
from pyleecan.Classes.Magnet import Magnet
Expand Down Expand Up @@ -34,17 +35,84 @@
"test_obj": test_obj,
"S_exp": 2.917e-4,
"SM_exp": 1.65e-4,
"Rmin": 0.06504,
"Rmax": 0.08,
"Rmin": 0.055,
"Rmax": 0.07,
"W": 41.411e-3,
"alpha": 0.487367,
}
)

# For AlmostEqual
DELTA = 1e-3


class Test_HoleM58_meth(object):
"""Test machine plot hole 58"""

@pytest.mark.parametrize("test_dict", HoleM58_test)
def test_schematics(self, test_dict):
"""Check that the schematics is correct"""
test_obj = test_dict["test_obj"]

point_dict = test_obj.hole[0]._comp_point_coordinate()
Rbo = test_obj.hole[0].get_Rbo()

# W0
assert abs(point_dict["Z2"] - point_dict["Z11"]) == pytest.approx(
test_obj.hole[0].W0
)
assert abs(point_dict["Z8"] - point_dict["Z5"]) == pytest.approx(
test_obj.hole[0].W0
)

# W1
assert abs(point_dict["Z12"] - point_dict["Z1"]) == pytest.approx(
test_obj.hole[0].W1
)
assert abs(point_dict["Z6"] - point_dict["Z7"]) == pytest.approx(
test_obj.hole[0].W1
)

# W2
assert abs(point_dict["Z2"] - point_dict["Z1"]) == pytest.approx(
test_obj.hole[0].W2
)
assert abs(point_dict["Z6"] - point_dict["Z5"]) == pytest.approx(
test_obj.hole[0].W2
)

# H2
assert abs(point_dict["Z2"] - point_dict["Z5"]) == pytest.approx(
test_obj.hole[0].H2
)
assert abs(point_dict["Z6"] - point_dict["Z1"]) == pytest.approx(
test_obj.hole[0].H2
)
assert abs(point_dict["Z12"] - point_dict["Z7"]) == pytest.approx(
test_obj.hole[0].H2
)

# R0
assert abs(point_dict["Z4"] - point_dict["Zc1"]) == pytest.approx(
test_obj.hole[0].R0
)
assert abs(point_dict["Z3"] - point_dict["Zc1"]) == pytest.approx(
test_obj.hole[0].R0
)
assert abs(point_dict["Z10"] - point_dict["Zc2"]) == pytest.approx(
test_obj.hole[0].R0
)
assert abs(point_dict["Z9"] - point_dict["Zc2"]) == pytest.approx(
test_obj.hole[0].R0
)

assert abs(point_dict["Zc1"]) == pytest.approx(
Rbo - test_obj.hole[0].R0 - test_obj.hole[0].H1
)
assert abs(point_dict["Zc2"]) == pytest.approx(
Rbo - test_obj.hole[0].R0 - test_obj.hole[0].H1
)

@pytest.mark.parametrize("test_dict", HoleM58_test)
def test_magnet_None(self, test_dict):
"""Magnet None"""
Expand All @@ -60,3 +128,36 @@ def test_magnet_Parallel(self, test_dict):
test_obj.hole[0].magnet_0 = Magnet(type_magnetization=1)
result = test_obj.hole[0].build_geometry()
assert result[1].label == "Rotor_HoleMag_R0-T0-S0"

@pytest.mark.parametrize("test_dict", HoleM58_test)
def test_comp_radius(self, test_dict):
"""Check that comp_radius return the correct result (analytical+num)"""
test_obj = test_dict["test_obj"]
Rmin, Rmax = test_obj.hole[0].comp_radius()

Rmax_a = test_dict["Rmax"]
Rmin_a = test_dict["Rmin"]
a, b = Rmin, Rmin_a
msg = f"For Rmin: Return {a} expected {b}"
assert abs((a - b) / a - 0) < DELTA, msg
a, b = Rmax, Rmax_a
msg = f"For Rmax: Return {a} expected {b}"
assert abs((a - b) / a - 0) < DELTA, msg

Rmin_a, Rmax_a = Hole.comp_radius(test_obj.hole[0])
a, b = Rmin, Rmin_a
msg = f"For Rmin: Return {a} expected {b}"
assert abs((a - b) / a - 0) < DELTA, msg

a, b = Rmax, Rmax_a
msg = f"For Rmax: Return {a} expected {b}"
assert abs((a - b) / a - 0) < DELTA, msg


if __name__ == "__main__":
a = Test_HoleM58_meth()
for test_dict in HoleM58_test:
a.test_schematics(test_dict)
a.test_magnet_None(test_dict)
a.test_magnet_Parallel(test_dict)
print("Done")
4 changes: 2 additions & 2 deletions Tests/Methods/Slot/test_HoleM61_meth.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"carac": "magnet_0",
"Rmin_exp": 0.05984145720150872,
"Rmax_exp": 0.11,
"S_exp": 0.00136534350269306,
"S_exp": 0.0013668826437211769,
"SM_exp": 0.00015,
"hasmagnet_exp": True,
}
Expand Down Expand Up @@ -196,7 +196,7 @@
"carac": "magnet_3",
"Rmin_exp": 0.05984145720150872,
"Rmax_exp": 0.11,
"S_exp": 0.00136688264372118,
"S_exp": 0.001365343502693063,
"SM_exp": 0.0002,
"hasmagnet_exp": True,
}
Expand Down
45 changes: 35 additions & 10 deletions Tests/Methods/Slot/test_SlotW16_meth.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from pyleecan.Classes.LamSlot import LamSlot
from pyleecan.Classes.Slot import Slot
from pyleecan.Methods.Slot.SlotW16 import S16OutterError
import matplotlib.pyplot as plt
from pyleecan.Classes.Arc1 import Arc1

# For AlmostEqual
DELTA = 1e-4
Expand All @@ -19,9 +21,9 @@
slotW16_test.append(
{
"test_obj": lam,
"S_exp": 2.508259e-3,
"Aw": 0.6927673,
"SW_exp": 2.33808e-3,
"S_exp": 0.0029208336939601474,
"Aw": 0.8150115827824299,
"SW_exp": 0.0027506640918907002,
"SO_exp": 0.000170169,
"H_exp": 3.5e-2,
}
Expand All @@ -41,6 +43,20 @@
}
)

# Small H0/W0/R1
lam = LamSlot(is_internal=True, Rint=0.04, Rext=0.0746, is_stator=False)
lam.slot = SlotW16(Zs=76, H0=0.0008, H2=0.0172, R1=1e-6, W0=0.00001, W3=0.00299)
slotW16_test.append(
{
"test_obj": lam,
"S_exp": 9.278655434664112e-05,
"Aw": 0.08273823008510589,
"SW_exp": 9.278596074664111e-05,
"SO_exp": 5.935999999999972e-10,
"H_exp": 0.018,
}
)


class Test_SlotW16_meth(object):
"""pytest for SlotW16 methods"""
Expand Down Expand Up @@ -87,13 +103,22 @@ def test_build_geometry_active(self, test_dict):
test_obj = test_dict["test_obj"]
surf_list = test_obj.slot.build_geometry_active(Nrad=3, Ntan=2)

# Check label
assert surf_list[0].label == "Stator_Winding_R0-T0-S0"
assert surf_list[1].label == "Stator_Winding_R1-T0-S0"
assert surf_list[2].label == "Stator_Winding_R2-T0-S0"
assert surf_list[3].label == "Stator_Winding_R0-T1-S0"
assert surf_list[4].label == "Stator_Winding_R1-T1-S0"
assert surf_list[5].label == "Stator_Winding_R2-T1-S0"
if test_obj.is_stator == False:
# Check label
assert surf_list[0].label == "Rotor_Winding_R0-T0-S0"
assert surf_list[1].label == "Rotor_Winding_R1-T0-S0"
assert surf_list[2].label == "Rotor_Winding_R2-T0-S0"
assert surf_list[3].label == "Rotor_Winding_R0-T1-S0"
assert surf_list[4].label == "Rotor_Winding_R1-T1-S0"
assert surf_list[5].label == "Rotor_Winding_R2-T1-S0"
else:
# Check label
assert surf_list[0].label == "Stator_Winding_R0-T0-S0"
assert surf_list[1].label == "Stator_Winding_R1-T0-S0"
assert surf_list[2].label == "Stator_Winding_R2-T0-S0"
assert surf_list[3].label == "Stator_Winding_R0-T1-S0"
assert surf_list[4].label == "Stator_Winding_R1-T1-S0"
assert surf_list[5].label == "Stator_Winding_R2-T1-S0"
# Check tangential position
assert surf_list[0].point_ref.imag < 0
assert surf_list[1].point_ref.imag < 0
Expand Down
Loading