Skip to content

Commit 426f004

Browse files
committed
Merge branch 'master' of https://github.com/Eomys/pyleecan
# Conflicts: # requirements.txt
2 parents d24f72e + 4b64e0e commit 426f004

File tree

136 files changed

+4040
-192
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+4040
-192
lines changed

Tests/Data/Load_GUI/DFIM_001.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
"Npcpp": 1,
124124
"Nslot_shift_wind": 0,
125125
"Ntcoil": 1,
126-
"__class__": "WindingDW2L",
126+
"__class__": "Winding",
127127
"coil_pitch": 0,
128128
"conductor": {
129129
"Hwire": 0.005,
@@ -348,7 +348,7 @@
348348
"Npcpp": 1,
349349
"Nslot_shift_wind": 0,
350350
"Ntcoil": 1,
351-
"__class__": "WindingDW2L",
351+
"__class__": "Winding",
352352
"coil_pitch": 0,
353353
"conductor": {
354354
"Hwire": 0.005,

Tests/Data/Load_GUI/SCIM_001.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@
166166
"Npcpp": null,
167167
"Nslot_shift_wind": null,
168168
"Ntcoil": null,
169-
"__class__": "WindingSC",
169+
"__class__": "Winding",
170170
"conductor": {
171171
"Hbar": 0.02,
172172
"Wbar": 0.01,
@@ -385,7 +385,7 @@
385385
"Npcpp": 1,
386386
"Nslot_shift_wind": 0,
387387
"Ntcoil": 1,
388-
"__class__": "WindingDW2L",
388+
"__class__": "Winding",
389389
"coil_pitch": 0,
390390
"conductor": {
391391
"Hwire": 0.005,

Tests/Functions/test_coordinate_transformation.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ def test_coordinate_transformation_Ok():
2727

2828
X_uvw = array([[1, -0.5, -0.5], [-1, 0.5, 0.5]])
2929
X_ab = array([[1, 0], [0, 1]])
30+
X_ab_wrong = array([1, 0])
3031

3132
th_90 = pi / 2
3233
th_180 = pi
3334

3435
X_dq90 = array([[0, -1], [1, 0]])
36+
X_dq90_wrong = array([[0, -1]])
3537
X_dq180 = array([[-1, 0], [0, -1]])
3638

3739
assert_array_almost_equal(ab2n(n2ab(X_uvw)), X_uvw)
@@ -40,3 +42,5 @@ def test_coordinate_transformation_Ok():
4042

4143
assert_array_almost_equal(ab2dq(X_ab, th_90), X_dq90)
4244
assert_array_almost_equal(ab2dq(X_ab, th_180), X_dq180)
45+
46+
assert_array_almost_equal(ab2dq(X_ab_wrong, th_90), X_dq90_wrong)

Tests/Functions/test_gmsh2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def test_gmsh_spm():
112112
path_save=join(save_path, "GSMH_model_spm.msh"),
113113
)
114114

115-
with open("gmsh_test_spm.json", "w") as fw:
115+
with open(join(save_path, "gmsh_test_spm.json"), "w") as fw:
116116
json.dump(gmsh_dict, fw, default=encode_complex, indent=4)
117117

118118

Tests/GUI/DMachineSetup/test_DAVDuct.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,3 +269,19 @@ def test_remove_circ(self):
269269
assert self.widget.tab_vent.widget(0).w_vent.lf_H0.value() == 10e-3
270270
assert self.widget.tab_vent.widget(0).w_vent.lf_D0.value() == 40e-3
271271
assert self.widget.tab_vent.widget(0).w_vent.lf_Alpha0.value() == 0
272+
273+
def test_check_PVentCirc(self):
274+
"""Test that check of PVentCirc"""
275+
lam = Lamination(Rint=0.1, Rext=1, is_stator=True, is_internal=True)
276+
vent = VentilationCirc(Zh=8, H0=10e-3, D0=40e-3, Alpha0=None)
277+
assert PVentCirc(vent=vent, lam=lam).check() == "You must set Alpha0 !"
278+
279+
vent = VentilationCirc(Zh=8, H0=10e-3, D0=None, Alpha0=None)
280+
assert PVentCirc(vent=vent, lam=lam).check() == "You must set D0 !"
281+
282+
vent = VentilationCirc(Zh=8, H0=None, D0=None, Alpha0=None)
283+
assert PVentCirc(vent=vent, lam=lam).check() == "You must set H0 !"
284+
285+
pvent = PVentCirc(vent=vent, lam=lam)
286+
pvent.vent.Zh = None
287+
assert pvent.check() == "You must set Zh !"

Tests/GUI/DMachineSetup/test_PHoleM50.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,3 +223,31 @@ def test_set_material_2(self):
223223

224224
assert self.widget.w_mat_2.c_mat_type.currentText() == "Magnet1"
225225
assert self.test_obj.hole[0].magnet_1.mat_type.name == "Magnet1"
226+
227+
def test_comp_output(self):
228+
"""Check that you can compute the output only if the hole is correctly set """
229+
self.test_obj = LamHole(Rint=0.1, Rext=0.2)
230+
self.test_obj.hole = list()
231+
self.test_obj.hole.append(
232+
HoleM50(
233+
H0=0.20,
234+
H1=0.11,
235+
H2=0.12,
236+
W0=0.23,
237+
W1=0.14,
238+
W2=0.15,
239+
H3=0.16,
240+
W3=0.27,
241+
H4=0.18,
242+
W4=0.19,
243+
)
244+
)
245+
self.widget.hole = self.test_obj.hole[0]
246+
self.widget.comp_output()
247+
248+
# Nan are there because the value are not correct for the sin, cos and tan methods. But with true values, it works.
249+
250+
assert self.widget.out_slot_surface.text() == "Slot suface (2 part): nan m²"
251+
assert self.widget.out_magnet_surface.text() == "Magnet surface: 0.0608 m²"
252+
assert self.widget.out_alpha.text() == "alpha: nan rad (nan°)"
253+
assert self.widget.out_W5.text() == "W5: nan m"

Tests/GUI/DMachineSetup/test_PHoleM51.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,21 +94,31 @@ def test_set_W0(self):
9494
"""Check that the Widget allow to update W0"""
9595
# Clear the field before writing the new value
9696
self.widget.lf_W0.clear()
97-
QTest.keyClicks(self.widget.lf_W0, "0.31")
97+
QTest.keyClicks(self.widget.lf_W0, "0.30")
9898
self.widget.lf_W0.editingFinished.emit() # To trigger the slot
9999

100-
assert self.widget.hole.W0 == 0.31
101-
assert self.test_obj.hole[0].W0 == 0.31
100+
assert self.widget.hole.W0 == 0.30
101+
assert self.test_obj.hole[0].W0 == 0.30
102102

103103
def test_set_W1(self):
104104
"""Check that the Widget allow to update W1"""
105105
# Clear the field before writing the new value
106106
self.widget.lf_W1.clear()
107-
QTest.keyClicks(self.widget.lf_W1, "0.32")
107+
QTest.keyClicks(self.widget.lf_W1, "0.31")
108108
self.widget.lf_W1.editingFinished.emit() # To trigger the slot
109109

110-
assert self.widget.hole.W1 == 0.32
111-
assert self.test_obj.hole[0].W1 == 0.32
110+
assert self.widget.hole.W1 == 0.31
111+
assert self.test_obj.hole[0].W1 == 0.31
112+
113+
def test_set_W2(self):
114+
"""Check that the Widget allow to update W2"""
115+
# Clear the field before writing the new value
116+
self.widget.lf_W2.clear()
117+
QTest.keyClicks(self.widget.lf_W2, "0.32")
118+
self.widget.lf_W2.editingFinished.emit() # To trigger the slot
119+
120+
assert self.widget.hole.W2 == 0.32
121+
assert self.test_obj.hole[0].W2 == 0.32
112122

113123
def test_set_W3(self):
114124
"""Check that the Widget allow to update W3"""
@@ -217,3 +227,12 @@ def test_set_material_3(self):
217227

218228
assert self.widget.w_mat_3.c_mat_type.currentText() == "Magnet3"
219229
assert self.test_obj.hole[0].magnet_2.mat_type.name == "Magnet3"
230+
231+
def test_comp_output(self):
232+
"""Check that comp_output is correctly working"""
233+
self.test_obj.hole[0].W0 = 0.5
234+
self.test_obj.hole[0].H0 = 0.00000001
235+
self.widget.hole = self.test_obj.hole[0]
236+
self.widget.comp_output()
237+
assert not (self.widget.out_alpha.text() == "alpha: ?")
238+
assert not (self.widget.out_Whole.text() == "Wslot: ?")

Tests/GUI/DMachineSetup/test_PHoleM52.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,21 @@ def test_init(self):
6262
assert self.widget.w_mat_1.c_mat_type.currentText() == "Magnet2"
6363
assert self.widget.w_mat_1.c_mat_type.currentIndex() == 1
6464

65+
self.test_obj = LamHole(Rint=0.1, Rext=0.2)
66+
self.test_obj.hole = list()
67+
self.test_obj.hole.append(HoleM52(H0=0.10, H1=0.11, H2=0.12, W0=0.13, W3=0.17))
68+
self.test_obj.hole[0].magnet_0 == None
69+
70+
self.matlib = MatLib()
71+
self.matlib.dict_mat["RefMatLib"] = [
72+
Material(name="Magnet1"),
73+
Material(name="Magnet2"),
74+
Material(name="Magnet3"),
75+
]
76+
77+
self.widget = PHoleM52(self.test_obj.hole[0], self.matlib)
78+
assert not self.widget.w_mat_1.isHidden()
79+
6580
def test_set_W0(self):
6681
"""Check that the Widget allow to update W0"""
6782
# Clear the field before writing the new value
@@ -125,3 +140,20 @@ def test_set_material_1(self):
125140

126141
assert self.widget.w_mat_1.c_mat_type.currentText() == "Magnet1"
127142
assert self.test_obj.hole[0].magnet_0.mat_type.name == "Magnet1"
143+
144+
def test_comp_output(self):
145+
"""Check that you can compute the output only if the hole is correctly set """
146+
self.test_obj = LamHole(Rint=0.1, Rext=0.2)
147+
self.test_obj.hole = list()
148+
self.test_obj.hole.append(
149+
HoleM52(H0=0.0010, H1=0.11, H2=0.00012, W0=0.0013, W3=0.0017)
150+
)
151+
self.widget.hole = self.test_obj.hole[0]
152+
self.widget.comp_output()
153+
154+
# Nan are there because the value are not correct for the sin, cos and tan methods. But with true values, it works.
155+
156+
assert self.widget.out_slot_surface.text() == "Slot suface: 0.002569 m²"
157+
assert self.widget.out_magnet_surface.text() == "Magnet surface: 0.000143 m²"
158+
assert self.widget.out_alpha.text() == "alpha: 0.166 rad (9.511°)"
159+
assert self.widget.out_W1.text() == "W1: 0.006234 m"

Tests/GUI/DMachineSetup/test_PHoleM53.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,49 @@ def test_set_material_2(self):
165165

166166
assert self.widget.w_mat_2.c_mat_type.currentText() == "Magnet1"
167167
assert self.test_obj.hole[0].magnet_1.mat_type.name == "Magnet1"
168+
169+
def test_comp_output(self):
170+
"""Check that comp_output is correctly working"""
171+
self.test_obj.hole[0] = HoleM53(
172+
H0=0.10,
173+
H1=0.0000000000011,
174+
H2=0.12,
175+
H3=0.0000000000015,
176+
W4=0.99,
177+
W1=0.14,
178+
W2=0.0000015,
179+
W3=0.0000017,
180+
)
181+
self.widget.hole = self.test_obj.hole[0]
182+
self.widget.comp_output()
183+
184+
assert self.widget.out_slot_surface.text() == "Slot suface (2 part): 0.01033 m²"
185+
assert self.widget.out_magnet_surface.text() == "Magnet surface: 4.08e-07 m²"
186+
assert self.widget.out_W5.text() == "W5: 0.01565 m"
187+
188+
def test_PHoleM53_None_Magnet(self):
189+
"""Check that you can create PHoleM53 with None for magnet_0"""
190+
self.test_obj.hole.append(
191+
HoleM53(
192+
H0=0.10,
193+
H1=0.11,
194+
H2=0.12,
195+
W4=0.13,
196+
W1=0.14,
197+
W2=0.15,
198+
W3=0.17,
199+
magnet_0=None,
200+
)
201+
)
202+
203+
self.matlib = MatLib()
204+
self.matlib.dict_mat["RefMatLib"] = [
205+
Material(name="Magnet1"),
206+
Material(name="Magnet2"),
207+
Material(name="Magnet3"),
208+
]
209+
210+
self.widget = PHoleM53(self.test_obj.hole[1], self.matlib)
211+
212+
assert self.widget.w_mat_1.isHidden()
213+
assert self.widget.w_mat_2.isHidden()

Tests/GUI/DMachineSetup/test_PHoleM57.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,20 @@ def setup_method(self, method):
3030
self.test_obj.hole.append(
3131
HoleM57(H1=0.11, H2=0.12, W0=0.13, W1=0.14, W2=0.15, W3=0.17, W4=0.19)
3232
)
33+
self.test_obj.hole.append(
34+
HoleM57(
35+
H1=0.11,
36+
H2=0.12,
37+
W0=0.13,
38+
W1=0.14,
39+
W2=0.15,
40+
W3=0.17,
41+
W4=0.19,
42+
magnet_0=None,
43+
)
44+
)
3345
self.widget = PHoleM57(self.test_obj.hole[0])
46+
self.widget2 = PHoleM57(self.test_obj.hole[1])
3447

3548
@classmethod
3649
def setup_class(cls):
@@ -57,6 +70,8 @@ def test_init(self):
5770
assert self.widget.lf_W3.value() == 0.17
5871
assert self.widget.lf_W4.value() == 0.19
5972

73+
assert self.widget.w_mat_1.isHidden() == False
74+
6075
self.test_obj.hole[0] = HoleM57(
6176
H1=0.21, H2=0.22, W0=0.23, W1=0.24, W2=0.25, W3=0.27, W4=0.29
6277
)
@@ -69,6 +84,8 @@ def test_init(self):
6984
assert self.widget.lf_W3.value() == 0.27
7085
assert self.widget.lf_W4.value() == 0.29
7186

87+
assert self.widget2.w_mat_1.isHidden() == True
88+
7289
def test_set_W0(self):
7390
"""Check that the Widget allow to update W0"""
7491
# Clear the field before writing the new value

0 commit comments

Comments
 (0)