Skip to content

Commit 88e5dbc

Browse files
authored
Merge pull request #388 from EOMYS-Public/LSRPM
[NF] LSRPM machine
2 parents 88231a1 + 9c362e7 commit 88e5dbc

31 files changed

+4107
-1
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from os.path import join
4+
import pytest
5+
6+
import matplotlib.pyplot as plt
7+
from numpy import pi
8+
9+
from pyleecan.Classes.Frame import Frame
10+
from pyleecan.Classes.LamHole import LamHole
11+
from pyleecan.Classes.LamSlotWind import LamSlotWind
12+
from pyleecan.Classes.MachineIPMSM import MachineIPMSM
13+
from pyleecan.Classes.Magnet import Magnet
14+
from pyleecan.Classes.Shaft import Shaft
15+
from pyleecan.Classes.HoleMLSRPM import HoleMLSRPM
16+
from Tests import save_plot_path as save_path
17+
from pyleecan.Classes.SlotWLSRPM import SlotWLSRPM
18+
19+
20+
"""unittest for Lamination with Hole LSRPM plot"""
21+
22+
23+
@pytest.fixture
24+
def machine():
25+
"""Run at the begining of every test to setup the machine"""
26+
plt.close("all")
27+
test_obj = MachineIPMSM()
28+
test_obj.rotor = LamHole(
29+
Rint=14e-3, Rext=50e-3, is_stator=False, is_internal=True, L1=0.95
30+
)
31+
test_obj.rotor.hole = list()
32+
test_obj.rotor.hole.append(
33+
HoleMLSRPM(
34+
Zh=8,
35+
W0=3.88e-3,
36+
W1=12.6 / 180 * pi,
37+
W2=0.0007,
38+
H1=0.0023515058436089,
39+
R1=0.0003,
40+
R2=0.019327,
41+
R3=0.0165,
42+
)
43+
)
44+
test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=0.95)
45+
test_obj.stator = LamSlotWind(
46+
Rint=50.7e-3,
47+
Rext=72.5e-3,
48+
is_internal=False,
49+
is_stator=True,
50+
L1=0.95,
51+
slot=None,
52+
)
53+
test_obj.frame = Frame(Rint=0.12, Rext=0.12, Lfra=0.95)
54+
return test_obj
55+
56+
57+
def test_Lam_Hole_LSRPM(machine):
58+
"""Test machine plot hole LSRPM with magnet"""
59+
60+
machine.plot(is_show_fig=False)
61+
fig = plt.gcf()
62+
fig.savefig(join(save_path, "test_Lam_Hole_sLSRPM_1-Machine.png"))
63+
assert len(fig.axes[0].patches) == 29
64+
65+
machine.rotor.plot(is_show_fig=False)
66+
fig = plt.gcf()
67+
fig.savefig(join(save_path, "test_Lam_Hole_sLSRPM_2-Rotor.png"))
68+
69+
assert len(fig.axes[0].patches) == 26
70+
71+
72+
def test_Lam_Hole_LSRPM_no_mag(machine):
73+
"""Test machine plot hole LSRPM without magnet"""
74+
machine.rotor.hole[0].magnet_0 = None
75+
machine.rotor.plot(is_show_fig=False)
76+
fig = plt.gcf()
77+
78+
assert len(fig.axes[0].patches) == 10
79+
fig.savefig(
80+
join(save_path, "test_Lam_Hole_sLSRPM_3-Rotor hole without " "magnet.png")
81+
)
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# -*- coding: utf-8 -*-
2+
from os.path import join
3+
import pytest
4+
5+
import matplotlib.pyplot as plt
6+
from numpy import array, pi, zeros
7+
8+
from pyleecan.Classes.Frame import Frame
9+
from pyleecan.Classes.LamSlotWind import LamSlotWind
10+
from pyleecan.Classes.LamSquirrelCage import LamSquirrelCage
11+
from pyleecan.Classes.MachineDFIM import MachineDFIM
12+
from pyleecan.Classes.Shaft import Shaft
13+
from pyleecan.Classes.VentilationCirc import VentilationCirc
14+
from pyleecan.Classes.VentilationPolar import VentilationPolar
15+
from pyleecan.Classes.VentilationTrap import VentilationTrap
16+
from pyleecan.Classes.Winding import Winding
17+
from pyleecan.Classes.WindingUD import WindingUD
18+
from pyleecan.Classes.SlotWLSRPM import SlotWLSRPM
19+
20+
from Tests import save_plot_path as save_path
21+
22+
# from Tests.Plot.LamWind import wind_mat, wind_mat2
23+
24+
25+
"""unittest for Lamination with winding plot"""
26+
27+
28+
@pytest.fixture
29+
def machine():
30+
"""Run at the begining of every test to setup the machine"""
31+
plt.close("all")
32+
test_obj = LamSlotWind(
33+
Rint=50.7e-3,
34+
Rext=72.5e-3,
35+
is_internal=False,
36+
is_stator=True,
37+
L1=0.95,
38+
Nrvd=0,
39+
Wrvd=0,
40+
)
41+
test_obj.slot = SlotWLSRPM(
42+
Zs=12, W1=8e-3, W3=11.6e-3, H2=14.8e-3, R1=0.75e-3, H3=2e-3
43+
)
44+
45+
return test_obj
46+
47+
48+
# wind_mat = zeros((2, 2, 6, 4)) # Nrad, Ntan, Zs, qs
49+
# wind_mat[0, 0, :, :] = array(
50+
# [[1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, -1, -1, 0], [0, -1, 0, 0, 0, 1]]
51+
# ).T
52+
53+
# wind_mat[1, 0, :, :] = array(
54+
# [[0, 0, 0, 0, 0, 0], [-1, 0, -1, 0, 0, -1], [0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 0]]
55+
# ).T
56+
57+
# wind_mat[0, 1, :, :] = array(
58+
# [[-1, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, -1, 0, 0, -1]]
59+
# ).T
60+
61+
# wind_mat[1, 1, :, :] = array(
62+
# [[0, 0, 0, -1, -1, 0], [1, 0, 0, 0, 0, 1], [0, -1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0]]
63+
# ).T
64+
###
65+
wind_mat_LSRPM = zeros((2, 2, 12, 6)) # Nrad, Ntan, Zs, qs
66+
wind_mat_LSRPM[0, 0, :, :] = array(
67+
[
68+
[-1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0],
69+
[0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0],
70+
[0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1],
71+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
72+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
73+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
74+
]
75+
).T
76+
77+
wind_mat_LSRPM[1, 0, :, :] = array(
78+
[
79+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
80+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
81+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
82+
[-1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0],
83+
[0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0],
84+
[0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1],
85+
]
86+
).T
87+
88+
wind_mat_LSRPM[0, 1, :, :] = array(
89+
[
90+
[0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],
91+
[1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],
92+
[0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0],
93+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
94+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
95+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
96+
]
97+
).T
98+
99+
wind_mat_LSRPM[1, 1, :, :] = array(
100+
[
101+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
102+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
103+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
104+
[0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],
105+
[1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],
106+
[0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0],
107+
]
108+
).T
109+
110+
111+
def test_Lam_Wind_LSRPM_wind_tan(machine):
112+
"""Test machine plot with Slot LSRPM and winding rad=1, tan=2"""
113+
machine.winding = WindingUD(wind_mat=wind_mat_LSRPM, qs=6, p=4, Lewout=0)
114+
machine.plot()
115+
fig = plt.gcf()
116+
fig.savefig(join(save_path, "test_Lam_Wind_sLSRPM_2-tan-wind.png"))
117+
# 2 for lam + Zs*2 for wind
118+
# assert len(fig.axes[0].patches) == 26

Tests/Plot/test_LSRPM_plot.py

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
from os.path import join
2+
3+
import json
4+
import pytest
5+
import matplotlib.pyplot as plt
6+
7+
from numpy import array, pi, zeros
8+
from pyleecan.Classes.Frame import Frame
9+
from pyleecan.Classes.LamHole import LamHole
10+
11+
from pyleecan.Classes.LamSlotWind import LamSlotWind
12+
13+
from pyleecan.Classes.BoreLSRPM import BoreLSRPM
14+
15+
from pyleecan.Classes.MachineIPMSM import MachineIPMSM
16+
from pyleecan.Classes.Magnet import Magnet
17+
from pyleecan.Classes.Shaft import Shaft
18+
from pyleecan.Classes.HoleMLSRPM import HoleMLSRPM
19+
from Tests import save_plot_path as save_path
20+
from pyleecan.Classes.SlotWLSRPM import SlotWLSRPM
21+
from pyleecan.Classes.WindingUD import WindingUD
22+
23+
24+
from pyleecan.Classes.CondType11 import CondType11
25+
from pyleecan.Classes.Shaft import Shaft
26+
from pyleecan.Classes.Frame import Frame
27+
from pyleecan.Classes.Material import Material
28+
from pyleecan.Classes.MatMagnetics import MatMagnetics
29+
30+
from pyleecan.definitions import DATA_DIR
31+
from pyleecan.Functions.load import load
32+
33+
34+
def test_LSRPM():
35+
mm = 1e-3 # Millimeter
36+
37+
# Lamination setup
38+
stator = LamSlotWind(
39+
Rint=50.7 * mm, # internal radius [m]
40+
Rext=72.5 * mm, # external radius [m]
41+
L1=950
42+
* mm, # Lamination stack active length [m] without radial ventilation airducts
43+
# but including insulation layers between lamination sheets
44+
Nrvd=0, # Number of radial air ventilation duct
45+
Kf1=0.95, # Lamination stacking / packing factor
46+
is_internal=False,
47+
is_stator=True,
48+
)
49+
50+
# Slot setup
51+
stator.slot = SlotWLSRPM(
52+
Zs=12, W1=8e-3, W3=11.6e-3, H2=14.8e-3, R1=0.75e-3, H3=2e-3 # Slot number
53+
)
54+
55+
# Winding setup
56+
wind_mat_LSRPM = zeros((2, 2, 12, 6)) # Nrad, Ntan, Zs, qs
57+
wind_mat_LSRPM[0, 0, :, :] = array(
58+
[
59+
[-1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0],
60+
[0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0],
61+
[0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1],
62+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
63+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
64+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
65+
]
66+
).T
67+
68+
wind_mat_LSRPM[1, 0, :, :] = array(
69+
[
70+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
71+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
72+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
73+
[-1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0],
74+
[0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0],
75+
[0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1],
76+
]
77+
).T
78+
79+
wind_mat_LSRPM[0, 1, :, :] = array(
80+
[
81+
[0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],
82+
[1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],
83+
[0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0],
84+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
85+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
86+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
87+
]
88+
).T
89+
90+
wind_mat_LSRPM[1, 1, :, :] = array(
91+
[
92+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
93+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
94+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
95+
[0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],
96+
[1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],
97+
[0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0],
98+
]
99+
).T
100+
101+
stator.winding = WindingUD(wind_mat=wind_mat_LSRPM, qs=6, p=4, Lewout=0)
102+
103+
# Conductor setup
104+
stator.winding.conductor = CondType11(
105+
Nwppc_tan=1, # stator winding number of preformed wires (strands)
106+
# in parallel per coil along tangential (horizontal) direction
107+
Nwppc_rad=1, # stator winding number of preformed wires (strands)
108+
# in parallel per coil along radial (vertical) direction
109+
Wwire=0.000912, # single wire width without insulation [m]
110+
Hwire=2e-3, # single wire height without insulation [m]
111+
Wins_wire=1e-6, # winding strand insulation thickness [m]
112+
type_winding_shape=1, # type of winding shape for end winding length calculation
113+
# 0 for hairpin windings
114+
# 1 for normal windings
115+
)
116+
117+
# Rotor setup
118+
# rotor = LamHole(
119+
# Rint=14e-3, Rext=50e-3, is_stator=False, is_internal=True, L1=0.95
120+
# )
121+
122+
rotor = LamHole(
123+
Rint=14e-3,
124+
Rext=50e-3,
125+
is_internal=True,
126+
is_stator=False,
127+
L1=0.105,
128+
Nrvd=2,
129+
Wrvd=0.05,
130+
)
131+
132+
# Magnet setup
133+
rotor.hole = list()
134+
rotor.hole.append(
135+
HoleMLSRPM(
136+
Zh=8,
137+
W0=3.88e-3,
138+
W1=12.6 / 180 * pi,
139+
W2=0.0007,
140+
H1=0.0023515058436089,
141+
R1=0.0003,
142+
R2=0.019327,
143+
R3=0.0165,
144+
)
145+
)
146+
rotor.bore = BoreLSRPM(N=8, Rarc=0.0375, alpha=0)
147+
148+
# Set shaft
149+
shaft = Shaft(
150+
Drsh=rotor.Rint * 2, # Diamater of the rotor shaft [m]
151+
# used to estimate bearing diameter for friction losses
152+
Lshaft=1.2, # length of the rotor shaft [m]
153+
)
154+
155+
# Loading Materials
156+
M400_50A = load(join(DATA_DIR, "Material", "M400-50A.json"))
157+
Copper1 = load(join(DATA_DIR, "Material", "Copper1.json"))
158+
MagnetPrius = load(join(DATA_DIR, "Material", "MagnetPrius.json"))
159+
160+
# Set Materials
161+
stator.mat_type = M400_50A
162+
rotor.mat_type = M400_50A
163+
stator.winding.conductor.cond_mat = Copper1
164+
165+
# Set magnets in the rotor hole
166+
rotor.hole[0].magnet_0.mat_type = MagnetPrius
167+
rotor.hole[0].magnet_0.type_magnetization = 1
168+
169+
# matplotlib notebook
170+
LSRPM = MachineIPMSM(
171+
name="LSRPM LSEE", stator=stator, rotor=rotor, shaft=shaft, frame=None
172+
)
173+
# LSRPM.save(join(DATA_DIR, "Machine", "LSRPM_001.json"))
174+
175+
LSRPM.plot(is_show_fig=False, save_path=join(save_path, "test_LSRPM.png"))
176+
177+
178+
if __name__ == "__main__":
179+
test_LSRPM()

0 commit comments

Comments
 (0)