Skip to content

Commit 260eccc

Browse files
authored
Merge pull request #237 from EOMYS-Public/HoleM51_ext
Holes defined on Rext instead of Rbo
2 parents 08afef4 + 82cebec commit 260eccc

34 files changed

+170
-147
lines changed

Tests/Functions/test_gmsh2.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import json
44

55
from os import makedirs
6-
from os.path import join
6+
from os.path import join, isdir
77
from pyleecan.Functions.load import load
88
from pyleecan.Classes.Simu1 import Simu1
99
from pyleecan.Classes.Output import Output
@@ -44,7 +44,8 @@ def test_gmsh_ipm():
4444
IPMSM_A = load(join(DATA_DIR, "Machine", "IPMSM_A.json"))
4545
IPMSM_A.stator.slot.H1 = 1e-3
4646
save_path = join(save_plot_path, "GMSH")
47-
makedirs(save_path)
47+
if not isdir(save_path):
48+
makedirs(save_path)
4849
# Plot the machine
4950
# im = IPMSM_A.plot()
5051

@@ -76,7 +77,8 @@ def test_gmsh_spm():
7677
# Import the machine from a script
7778
PMSM_A = load(join(DATA_DIR, "Machine", "SPMSM_001.json"))
7879
save_path = join(save_plot_path, "GMSH")
79-
makedirs(save_path)
80+
if not isdir(save_path):
81+
makedirs(save_path)
8082
# Plot the machine
8183
# im = PMSM_A.plot()
8284

Tests/Methods/Machine/test_comp_mass.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
"test_obj": test_obj,
7676
"Mfra": 4000 * pi * (0.114 ** 2 - 0.104 ** 2),
7777
"Msha": 5000 * 1.2 * pi * 0.021 ** 2,
78-
"result_comp_surface": 0.015821060603478196,
7978
}
8079
)
8180
M_test[-1]["rotor"] = {
@@ -109,7 +108,6 @@
109108
"test_obj": IPMSM_A,
110109
"Mfra": 0,
111110
"Msha": 7650 * 0.1 * pi * (0.11064 / 2) ** 2,
112-
"result_comp_surface": 0.010592626073992478,
113111
} # No frame
114112
)
115113
M_test[-1]["rotor"] = {"Slam": 0.0082186, "Svent": 0, "Smag": 0.0189 * 0.0065 * 2 * 8}
@@ -153,13 +151,6 @@ def test_comp_surface_rotor(test_dict):
153151

154152
a = result["Syoke"]
155153

156-
"""Check that the computation of the surface is correct EXTERNAL"""
157-
test_dict["test_obj"].rotor.is_internal = False
158-
result = test_dict["test_obj"].rotor.comp_surfaces()
159-
160-
assert result["Syoke"] == test_dict["result_comp_surface"]
161-
test_dict["test_obj"].rotor.is_internal = True
162-
163154

164155
@pytest.mark.parametrize("test_dict", M_test)
165156
def test_comp_surface_stator(test_dict):

Tests/Methods/Slot/test_HoleM50_meth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,8 @@ def test_comp_radius_mid_yoke(self):
347347
H4=1e-3,
348348
)
349349
)
350-
assert test_obj.comp_radius_mid_yoke() != 0.1661908960397621
351-
assert test_obj.comp_radius_mid_yoke() == 0.1785605
350+
# Hole is defined on Rext, so mid yoke is around Rext, Rext H1
351+
assert test_obj.comp_radius_mid_yoke() == 0.324375
352352

353353
def test_comp_surface_magnet_id(self):
354354
"""check that id is 0"""

Tests/Validation/Simulation/test_FEMM_import_model.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,7 @@ def test_FEMM_import_model():
4747
simu.input.N0 = 3000 # Rotor speed [rpm]
4848

4949
# Definition of the magnetic simulation
50-
simu.mag = MagFEMM(
51-
type_BH_stator=2,
52-
type_BH_rotor=2,
53-
is_periodicity_a=True,
54-
)
50+
simu.mag = MagFEMM(type_BH_stator=2, type_BH_rotor=2, is_periodicity_a=True,)
5551
out = simu.run()
5652

5753
# Second simulation, importing femm file and FEMM_dict
@@ -63,7 +59,7 @@ def test_FEMM_import_model():
6359
is_periodicity_a=True,
6460
is_periodicity_t=False,
6561
import_file=out.simu.mag.get_path_save_fem(out),
66-
FEMM_dict=out.mag.FEA_dict,
62+
FEMM_dict_enforced=out.mag.FEA_dict,
6763
)
6864

6965
out2 = simu2.run()

pyleecan/Classes/Class_Dict.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,6 +1423,7 @@
14231423
"comp_surface",
14241424
"get_is_stator",
14251425
"get_Rbo",
1426+
"get_Rext",
14261427
"has_magnet",
14271428
"plot",
14281429
"comp_height",

pyleecan/Classes/Hole.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636
except ImportError as error:
3737
get_Rbo = error
3838

39+
try:
40+
from ..Methods.Slot.Hole.get_Rext import get_Rext
41+
except ImportError as error:
42+
get_Rext = error
43+
3944
try:
4045
from ..Methods.Slot.Hole.has_magnet import has_magnet
4146
except ImportError as error:
@@ -120,6 +125,15 @@ class Hole(FrozenClass):
120125
)
121126
else:
122127
get_Rbo = get_Rbo
128+
# cf Methods.Slot.Hole.get_Rext
129+
if isinstance(get_Rext, ImportError):
130+
get_Rext = property(
131+
fget=lambda x: raise_(
132+
ImportError("Can't use Hole method get_Rext: " + str(get_Rext))
133+
)
134+
)
135+
else:
136+
get_Rext = get_Rext
123137
# cf Methods.Slot.Hole.has_magnet
124138
if isinstance(has_magnet, ImportError):
125139
has_magnet = property(

pyleecan/Generator/ClassesRef/Slot/Hole.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Zh,-,Number of Hole around the circumference,0,int,36,0,1000,,Slot,,comp_radius,
33
mat_void,-,Material of the void part of the hole (Air in general),0,Material,,,,,,,comp_surface,,,
44
,,,,,,,,,,,get_is_stator,,,
55
,,,,,,,,,,,get_Rbo,,,
6+
,,,,,,,,,,,get_Rext,,,
67
,,,,,,,,,,,has_magnet,,,
78
,,,,,,,,,,,plot,,,
89
,,,,,,,,,,,comp_height,,,

pyleecan/Methods/Simulation/MagFEMM/comp_flux_airgap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ def comp_flux_airgap(self, output, axes_dict):
166166
)
167167
# Save meshsolution as .h5 on disk if requested
168168
if self.is_save_FEA:
169-
save_path = self.get_path_save(self.parent)
169+
save_path = output.get_path_result()
170170
save_path_fea = join(save_path, "MeshSolutionFEMM.h5")
171-
self.meshsolution.save(save_path_fea)
171+
out_dict["meshsolution"].save(save_path_fea)
172172

173173
return out_dict
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from ....Methods import ParentMissingError
2+
3+
4+
def get_Rext(self):
5+
"""Return the parent lamination exterior radius
6+
7+
Parameters
8+
----------
9+
self : Hole
10+
A Hole object
11+
12+
Returns
13+
-------
14+
Rext: float
15+
The parent lamination exterior radius [m]
16+
17+
"""
18+
19+
if self.parent is not None:
20+
return self.parent.Rext
21+
else:
22+
raise ParentMissingError("Error: The hole is not inside a Lamination")

pyleecan/Methods/Slot/HoleM50/build_geometry.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,22 @@ def build_geometry(self, alpha=0, delta=0, is_simplified=False):
3636
st = "_Stator"
3737
else:
3838
st = "_Rotor"
39-
Rbo = self.get_Rbo()
39+
Rext = self.get_Rext()
4040

4141
# magnet pole pitch angle, must be <2*pi/2*p
42-
alpham = 2 * arcsin(self.W0 / (2 * (Rbo - self.H1))) # angle (Z9,0,Z9')
42+
alpham = 2 * arcsin(self.W0 / (2 * (Rext - self.H1))) # angle (Z9,0,Z9')
4343

44-
Harc = (Rbo - self.H1) * (1 - cos(alpham / 2))
44+
Harc = (Rext - self.H1) * (1 - cos(alpham / 2))
4545
# alpha on schematics
4646
gammam = arctan((self.H0 - self.H1 - Harc) / (self.W0 / 2.0 - self.W1 / 2.0))
4747
# betam = pi/2-alpham/2-gammam;#40.5
4848
hssp = pi / self.Zh
4949

5050
x78 = (self.H3 - self.H2) / cos(gammam) # distance from 7 to 8
51-
Z9 = Rbo - Harc - self.H1 - 1j * self.W0 / 2
52-
Z8 = Rbo - self.H0 - 1j * self.W1 / 2
53-
Z7 = Rbo - self.H0 - x78 - 1j * self.W1 / 2
54-
Z1 = (Rbo - self.H1) * exp(1j * (-hssp + arcsin(self.W3 / (2 * (Rbo - self.H1)))))
51+
Z9 = Rext - Harc - self.H1 - 1j * self.W0 / 2
52+
Z8 = Rext - self.H0 - 1j * self.W1 / 2
53+
Z7 = Rext - self.H0 - x78 - 1j * self.W1 / 2
54+
Z1 = (Rext - self.H1) * exp(1j * (-hssp + arcsin(self.W3 / (2 * (Rext - self.H1)))))
5555
Z11 = (Z1 * exp(1j * hssp) + self.H4) * exp(-1j * hssp)
5656
Z10 = (Z9 * exp(1j * hssp) + self.H4) * exp(-1j * hssp)
5757

@@ -102,7 +102,7 @@ def build_geometry(self, alpha=0, delta=0, is_simplified=False):
102102
curve_list.append(Segment(Z8c, Z9))
103103
if self.H4 > 0:
104104
curve_list.append(Segment(Z9, Z10))
105-
curve_list.append(Arc1(Z10, Z11, -Rbo + self.H1, is_trigo_direction=False))
105+
curve_list.append(Arc1(Z10, Z11, -Rext + self.H1, is_trigo_direction=False))
106106
if self.H4 > 0:
107107
curve_list.append(Segment(Z11, Z1))
108108
point_ref = (Z1 + Z2 + Z3 + Z8c + Z9 + Z10 + Z11) / 7
@@ -153,7 +153,7 @@ def build_geometry(self, alpha=0, delta=0, is_simplified=False):
153153
curve_list.append(Segment(Z8cs, Z9s))
154154
if self.H4 > 0:
155155
curve_list.append(Segment(Z9s, Z10s))
156-
curve_list.append(Arc1(Z10s, Z11s, Rbo - self.H1, is_trigo_direction=True))
156+
curve_list.append(Arc1(Z10s, Z11s, Rext - self.H1, is_trigo_direction=True))
157157
if self.H4 > 0:
158158
curve_list.append(Segment(Z11s, Z1s))
159159
point_ref = (Z1s + Z2s + Z3s + Z8cs + Z9s + Z10s + Z11s) / 7
@@ -223,7 +223,7 @@ def build_geometry(self, alpha=0, delta=0, is_simplified=False):
223223
curve_list.append(Segment(Z8, Z9))
224224
if self.H4 > 0:
225225
curve_list.append(Segment(Z9, Z10))
226-
curve_list.append(Arc1(Z10, Z11, -Rbo + self.H1, is_trigo_direction=False))
226+
curve_list.append(Arc1(Z10, Z11, -Rext + self.H1, is_trigo_direction=False))
227227
if self.H4 > 0:
228228
curve_list.append(Segment(Z11, Z1))
229229
point_ref = (Z1 + Z2 + Z3 + Z8c + Z9 + Z10 + Z11) / 7
@@ -243,7 +243,7 @@ def build_geometry(self, alpha=0, delta=0, is_simplified=False):
243243
curve_list.append(Segment(Z8s, Z9s))
244244
if self.H4 > 0:
245245
curve_list.append(Segment(Z9s, Z10s))
246-
curve_list.append(Arc1(Z10s, Z11s, Rbo - self.H1, is_trigo_direction=True))
246+
curve_list.append(Arc1(Z10s, Z11s, Rext - self.H1, is_trigo_direction=True))
247247
if self.H4 > 0:
248248
curve_list.append(Segment(Z11s, Z1s))
249249
point_ref = (Z1s + Z2s + Z3s + Z8cs + Z9s + Z10s + Z11s) / 7
@@ -267,7 +267,7 @@ def build_geometry(self, alpha=0, delta=0, is_simplified=False):
267267
curve_list.append(Segment(Z8s, Z9s))
268268
if self.H4 > 0:
269269
curve_list.append(Segment(Z9s, Z10s))
270-
curve_list.append(Arc1(Z10s, Z11s, Rbo - self.H1, is_trigo_direction=True))
270+
curve_list.append(Arc1(Z10s, Z11s, Rext - self.H1, is_trigo_direction=True))
271271
if self.H4 > 0:
272272
curve_list.append(Segment(Z11s, Z1s))
273273
point_ref = (Z1s + Z2s + Z3s + Z8cs + Z9s + Z10s + Z11s) / 7
@@ -291,7 +291,7 @@ def build_geometry(self, alpha=0, delta=0, is_simplified=False):
291291
curve_list.append(Segment(Z8, Z9))
292292
if self.H4 > 0:
293293
curve_list.append(Segment(Z9, Z10))
294-
curve_list.append(Arc1(Z10, Z11, -Rbo + self.H1, is_trigo_direction=False))
294+
curve_list.append(Arc1(Z10, Z11, -Rext + self.H1, is_trigo_direction=False))
295295
if self.H4 > 0:
296296
curve_list.append(Segment(Z11, Z1))
297297
point_ref = (Z1 + Z2 + Z3 + Z8c + Z9 + Z10 + Z11) / 7
@@ -318,14 +318,14 @@ def build_geometry(self, alpha=0, delta=0, is_simplified=False):
318318
curve_list.append(Segment(Z2s, Z1s))
319319
if self.H4 > 0:
320320
curve_list.append(Segment(Z1s, Z11s))
321-
curve_list.append(Arc1(Z11s, Z10s, -Rbo + self.H1, is_trigo_direction=False))
321+
curve_list.append(Arc1(Z11s, Z10s, -Rext + self.H1, is_trigo_direction=False))
322322
if self.H4 > 0:
323323
curve_list.append(Segment(Z10s, Z9s))
324324
curve_list.append(Segment(Z9s, Z8s))
325325
curve_list.append(Segment(Z8s, Z9))
326326
if self.H4 > 0:
327327
curve_list.append(Segment(Z9, Z10))
328-
curve_list.append(Arc1(Z10, Z11, -Rbo + self.H1, is_trigo_direction=False))
328+
curve_list.append(Arc1(Z10, Z11, -Rext + self.H1, is_trigo_direction=False))
329329
if self.H4 > 0:
330330
curve_list.append(Segment(Z11, Z1))
331331

0 commit comments

Comments
 (0)