Skip to content

Commit

Permalink
Merge pull request #237 from EOMYS-Public/HoleM51_ext
Browse files Browse the repository at this point in the history
Holes defined on Rext instead of Rbo
  • Loading branch information
BonneelP authored Nov 16, 2020
2 parents 08afef4 + 82cebec commit 260eccc
Show file tree
Hide file tree
Showing 34 changed files with 170 additions and 147 deletions.
8 changes: 5 additions & 3 deletions Tests/Functions/test_gmsh2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import json

from os import makedirs
from os.path import join
from os.path import join, isdir
from pyleecan.Functions.load import load
from pyleecan.Classes.Simu1 import Simu1
from pyleecan.Classes.Output import Output
Expand Down Expand Up @@ -44,7 +44,8 @@ def test_gmsh_ipm():
IPMSM_A = load(join(DATA_DIR, "Machine", "IPMSM_A.json"))
IPMSM_A.stator.slot.H1 = 1e-3
save_path = join(save_plot_path, "GMSH")
makedirs(save_path)
if not isdir(save_path):
makedirs(save_path)
# Plot the machine
# im = IPMSM_A.plot()

Expand Down Expand Up @@ -76,7 +77,8 @@ def test_gmsh_spm():
# Import the machine from a script
PMSM_A = load(join(DATA_DIR, "Machine", "SPMSM_001.json"))
save_path = join(save_plot_path, "GMSH")
makedirs(save_path)
if not isdir(save_path):
makedirs(save_path)
# Plot the machine
# im = PMSM_A.plot()

Expand Down
9 changes: 0 additions & 9 deletions Tests/Methods/Machine/test_comp_mass.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
"test_obj": test_obj,
"Mfra": 4000 * pi * (0.114 ** 2 - 0.104 ** 2),
"Msha": 5000 * 1.2 * pi * 0.021 ** 2,
"result_comp_surface": 0.015821060603478196,
}
)
M_test[-1]["rotor"] = {
Expand Down Expand Up @@ -109,7 +108,6 @@
"test_obj": IPMSM_A,
"Mfra": 0,
"Msha": 7650 * 0.1 * pi * (0.11064 / 2) ** 2,
"result_comp_surface": 0.010592626073992478,
} # No frame
)
M_test[-1]["rotor"] = {"Slam": 0.0082186, "Svent": 0, "Smag": 0.0189 * 0.0065 * 2 * 8}
Expand Down Expand Up @@ -153,13 +151,6 @@ def test_comp_surface_rotor(test_dict):

a = result["Syoke"]

"""Check that the computation of the surface is correct EXTERNAL"""
test_dict["test_obj"].rotor.is_internal = False
result = test_dict["test_obj"].rotor.comp_surfaces()

assert result["Syoke"] == test_dict["result_comp_surface"]
test_dict["test_obj"].rotor.is_internal = True


@pytest.mark.parametrize("test_dict", M_test)
def test_comp_surface_stator(test_dict):
Expand Down
4 changes: 2 additions & 2 deletions Tests/Methods/Slot/test_HoleM50_meth.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,8 @@ def test_comp_radius_mid_yoke(self):
H4=1e-3,
)
)
assert test_obj.comp_radius_mid_yoke() != 0.1661908960397621
assert test_obj.comp_radius_mid_yoke() == 0.1785605
# Hole is defined on Rext, so mid yoke is around Rext, Rext H1
assert test_obj.comp_radius_mid_yoke() == 0.324375

def test_comp_surface_magnet_id(self):
"""check that id is 0"""
Expand Down
8 changes: 2 additions & 6 deletions Tests/Validation/Simulation/test_FEMM_import_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ def test_FEMM_import_model():
simu.input.N0 = 3000 # Rotor speed [rpm]

# Definition of the magnetic simulation
simu.mag = MagFEMM(
type_BH_stator=2,
type_BH_rotor=2,
is_periodicity_a=True,
)
simu.mag = MagFEMM(type_BH_stator=2, type_BH_rotor=2, is_periodicity_a=True,)
out = simu.run()

# Second simulation, importing femm file and FEMM_dict
Expand All @@ -63,7 +59,7 @@ def test_FEMM_import_model():
is_periodicity_a=True,
is_periodicity_t=False,
import_file=out.simu.mag.get_path_save_fem(out),
FEMM_dict=out.mag.FEA_dict,
FEMM_dict_enforced=out.mag.FEA_dict,
)

out2 = simu2.run()
Expand Down
1 change: 1 addition & 0 deletions pyleecan/Classes/Class_Dict.json
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,7 @@
"comp_surface",
"get_is_stator",
"get_Rbo",
"get_Rext",
"has_magnet",
"plot",
"comp_height",
Expand Down
14 changes: 14 additions & 0 deletions pyleecan/Classes/Hole.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
except ImportError as error:
get_Rbo = error

try:
from ..Methods.Slot.Hole.get_Rext import get_Rext
except ImportError as error:
get_Rext = error

try:
from ..Methods.Slot.Hole.has_magnet import has_magnet
except ImportError as error:
Expand Down Expand Up @@ -120,6 +125,15 @@ class Hole(FrozenClass):
)
else:
get_Rbo = get_Rbo
# cf Methods.Slot.Hole.get_Rext
if isinstance(get_Rext, ImportError):
get_Rext = property(
fget=lambda x: raise_(
ImportError("Can't use Hole method get_Rext: " + str(get_Rext))
)
)
else:
get_Rext = get_Rext
# cf Methods.Slot.Hole.has_magnet
if isinstance(has_magnet, ImportError):
has_magnet = property(
Expand Down
1 change: 1 addition & 0 deletions pyleecan/Generator/ClassesRef/Slot/Hole.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Zh,-,Number of Hole around the circumference,0,int,36,0,1000,,Slot,,comp_radius,
mat_void,-,Material of the void part of the hole (Air in general),0,Material,,,,,,,comp_surface,,,
,,,,,,,,,,,get_is_stator,,,
,,,,,,,,,,,get_Rbo,,,
,,,,,,,,,,,get_Rext,,,
,,,,,,,,,,,has_magnet,,,
,,,,,,,,,,,plot,,,
,,,,,,,,,,,comp_height,,,
Expand Down
4 changes: 2 additions & 2 deletions pyleecan/Methods/Simulation/MagFEMM/comp_flux_airgap.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ def comp_flux_airgap(self, output, axes_dict):
)
# Save meshsolution as .h5 on disk if requested
if self.is_save_FEA:
save_path = self.get_path_save(self.parent)
save_path = output.get_path_result()
save_path_fea = join(save_path, "MeshSolutionFEMM.h5")
self.meshsolution.save(save_path_fea)
out_dict["meshsolution"].save(save_path_fea)

return out_dict
22 changes: 22 additions & 0 deletions pyleecan/Methods/Slot/Hole/get_Rext.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from ....Methods import ParentMissingError


def get_Rext(self):
"""Return the parent lamination exterior radius
Parameters
----------
self : Hole
A Hole object
Returns
-------
Rext: float
The parent lamination exterior radius [m]
"""

if self.parent is not None:
return self.parent.Rext
else:
raise ParentMissingError("Error: The hole is not inside a Lamination")
30 changes: 15 additions & 15 deletions pyleecan/Methods/Slot/HoleM50/build_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@ def build_geometry(self, alpha=0, delta=0, is_simplified=False):
st = "_Stator"
else:
st = "_Rotor"
Rbo = self.get_Rbo()
Rext = self.get_Rext()

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

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

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

Expand Down Expand Up @@ -102,7 +102,7 @@ def build_geometry(self, alpha=0, delta=0, is_simplified=False):
curve_list.append(Segment(Z8c, Z9))
if self.H4 > 0:
curve_list.append(Segment(Z9, Z10))
curve_list.append(Arc1(Z10, Z11, -Rbo + self.H1, is_trigo_direction=False))
curve_list.append(Arc1(Z10, Z11, -Rext + self.H1, is_trigo_direction=False))
if self.H4 > 0:
curve_list.append(Segment(Z11, Z1))
point_ref = (Z1 + Z2 + Z3 + Z8c + Z9 + Z10 + Z11) / 7
Expand Down Expand Up @@ -153,7 +153,7 @@ def build_geometry(self, alpha=0, delta=0, is_simplified=False):
curve_list.append(Segment(Z8cs, Z9s))
if self.H4 > 0:
curve_list.append(Segment(Z9s, Z10s))
curve_list.append(Arc1(Z10s, Z11s, Rbo - self.H1, is_trigo_direction=True))
curve_list.append(Arc1(Z10s, Z11s, Rext - self.H1, is_trigo_direction=True))
if self.H4 > 0:
curve_list.append(Segment(Z11s, Z1s))
point_ref = (Z1s + Z2s + Z3s + Z8cs + Z9s + Z10s + Z11s) / 7
Expand Down Expand Up @@ -223,7 +223,7 @@ def build_geometry(self, alpha=0, delta=0, is_simplified=False):
curve_list.append(Segment(Z8, Z9))
if self.H4 > 0:
curve_list.append(Segment(Z9, Z10))
curve_list.append(Arc1(Z10, Z11, -Rbo + self.H1, is_trigo_direction=False))
curve_list.append(Arc1(Z10, Z11, -Rext + self.H1, is_trigo_direction=False))
if self.H4 > 0:
curve_list.append(Segment(Z11, Z1))
point_ref = (Z1 + Z2 + Z3 + Z8c + Z9 + Z10 + Z11) / 7
Expand All @@ -243,7 +243,7 @@ def build_geometry(self, alpha=0, delta=0, is_simplified=False):
curve_list.append(Segment(Z8s, Z9s))
if self.H4 > 0:
curve_list.append(Segment(Z9s, Z10s))
curve_list.append(Arc1(Z10s, Z11s, Rbo - self.H1, is_trigo_direction=True))
curve_list.append(Arc1(Z10s, Z11s, Rext - self.H1, is_trigo_direction=True))
if self.H4 > 0:
curve_list.append(Segment(Z11s, Z1s))
point_ref = (Z1s + Z2s + Z3s + Z8cs + Z9s + Z10s + Z11s) / 7
Expand All @@ -267,7 +267,7 @@ def build_geometry(self, alpha=0, delta=0, is_simplified=False):
curve_list.append(Segment(Z8s, Z9s))
if self.H4 > 0:
curve_list.append(Segment(Z9s, Z10s))
curve_list.append(Arc1(Z10s, Z11s, Rbo - self.H1, is_trigo_direction=True))
curve_list.append(Arc1(Z10s, Z11s, Rext - self.H1, is_trigo_direction=True))
if self.H4 > 0:
curve_list.append(Segment(Z11s, Z1s))
point_ref = (Z1s + Z2s + Z3s + Z8cs + Z9s + Z10s + Z11s) / 7
Expand All @@ -291,7 +291,7 @@ def build_geometry(self, alpha=0, delta=0, is_simplified=False):
curve_list.append(Segment(Z8, Z9))
if self.H4 > 0:
curve_list.append(Segment(Z9, Z10))
curve_list.append(Arc1(Z10, Z11, -Rbo + self.H1, is_trigo_direction=False))
curve_list.append(Arc1(Z10, Z11, -Rext + self.H1, is_trigo_direction=False))
if self.H4 > 0:
curve_list.append(Segment(Z11, Z1))
point_ref = (Z1 + Z2 + Z3 + Z8c + Z9 + Z10 + Z11) / 7
Expand All @@ -318,14 +318,14 @@ def build_geometry(self, alpha=0, delta=0, is_simplified=False):
curve_list.append(Segment(Z2s, Z1s))
if self.H4 > 0:
curve_list.append(Segment(Z1s, Z11s))
curve_list.append(Arc1(Z11s, Z10s, -Rbo + self.H1, is_trigo_direction=False))
curve_list.append(Arc1(Z11s, Z10s, -Rext + self.H1, is_trigo_direction=False))
if self.H4 > 0:
curve_list.append(Segment(Z10s, Z9s))
curve_list.append(Segment(Z9s, Z8s))
curve_list.append(Segment(Z8s, Z9))
if self.H4 > 0:
curve_list.append(Segment(Z9, Z10))
curve_list.append(Arc1(Z10, Z11, -Rbo + self.H1, is_trigo_direction=False))
curve_list.append(Arc1(Z10, Z11, -Rext + self.H1, is_trigo_direction=False))
if self.H4 > 0:
curve_list.append(Segment(Z11, Z1))

Expand Down
6 changes: 3 additions & 3 deletions pyleecan/Methods/Slot/HoleM50/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def check(self):
S50_SpCheckError
Slot pitch too small for the slot, reduce Zh, W3 or W0
"""
Rbo = self.get_Rbo()
Rext = self.get_Rext()

# Check that everything is set
if self.W0 is None:
Expand Down Expand Up @@ -66,8 +66,8 @@ def check(self):
if self.comp_W5() < 0:
raise S50_W5CheckError("You must have W5 >=0")

alpha_0 = 2 * arcsin(self.W0 / (2 * (Rbo - self.H1))) # W0 in rad
alpha_3 = 2 * arcsin(self.W3 / (2 * (Rbo - self.H1))) # W3 in rad
alpha_0 = 2 * arcsin(self.W0 / (2 * (Rext - self.H1))) # W0 in rad
alpha_3 = 2 * arcsin(self.W3 / (2 * (Rext - self.H1))) # W3 in rad
if alpha_0 + alpha_3 > 2 * pi / self.Zh:
raise S50_SpCheckError("Slot pitch too small for the slot, reduce Zh, W3 or W0")

Expand Down
6 changes: 3 additions & 3 deletions pyleecan/Methods/Slot/HoleM50/comp_alpha.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def comp_alpha(self):
alpha: float
Cf schematics [rad]
"""
Rbo = self.get_Rbo()
Rext = self.get_Rext()

alpham = 2 * arcsin(self.W0 / (2 * (Rbo - self.H1)))
alpham = 2 * arcsin(self.W0 / (2 * (Rext - self.H1)))

Harc = (Rbo - self.H1) * (1 - cos(alpham / 2))
Harc = (Rext - self.H1) * (1 - cos(alpham / 2))
return arctan((self.H0 - self.H1 - Harc) / (self.W0 / 2 - self.W1 / 2))
14 changes: 7 additions & 7 deletions pyleecan/Methods/Slot/HoleM50/comp_radius.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ def comp_radius(self):
(Rmin,Rmax): tuple
Radius of the circle that contains the slot [m]
"""
Rbo = self.get_Rbo()
Rext = self.get_Rext()

Rmax = Rbo - self.H1
Rmax = Rext - self.H1

# magnet pole pitch angle, must be <2*pi/2*p
alpham = 2 * arcsin(self.W0 / (2 * (Rbo - self.H1)))
alpham = 2 * arcsin(self.W0 / (2 * (Rext - self.H1)))

Harc = (Rbo - self.H1) * (1 - cos(alpham / 2))
Harc = (Rext - self.H1) * (1 - cos(alpham / 2))
gammam = arctan((self.H0 - self.H1 - Harc) / (self.W0 / 2.0 - self.W1 / 2.0))

x78 = (self.H3 - self.H2) / cos(gammam) # distance from 7 to 8
Z9 = Rbo - Harc - self.H1 - 1j * self.W0 / 2.0
Z8 = Rbo - self.H0 - 1j * self.W1 / 2.0
Z7 = Rbo - self.H0 - x78 - 1j * self.W1 / 2.0
Z9 = Rext - Harc - self.H1 - 1j * self.W0 / 2.0
Z8 = Rext - self.H0 - 1j * self.W1 / 2.0
Z7 = Rext - self.H0 - x78 - 1j * self.W1 / 2.0

# Magnet coordinate with Z8 as center and x as the top edge of the magnet
Z8b = self.W2
Expand Down
Loading

0 comments on commit 260eccc

Please sign in to comment.