def test_Lam_Mag_10_surface(self): """Test machine plot with Magnet 10 surface""" plt.close("all") rotor = LamSlotMag( Rint=40e-3, Rext=200e-3, is_internal=True, is_stator=False, L1=0.5, Nrvd=0, Wrvd=0.05, ) magnet = [MagnetType10(Lmag=0.5, Hmag=0.02, Wmag=0.08)] rotor.slot = SlotMFlat(Zs=8, H0=0, W0=2 * pi / 10, W0_is_rad=True, magnet=magnet) rotor.mat_type.mag = MatMagnetics(Wlam=0.5e-3) rotor.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 10) fig.savefig(join(save_path, "test_Lam_Mag_10s_2-Rotor.png")) magnet2 = [MagnetType10(Lmag=0.5, Hmag=0.02, Wmag=0.04)] rotor.slot = SlotMFlat(Zs=8, W0=0.04, W0_is_rad=False, magnet=magnet2) rotor.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Mag_10s_5-Rotor 2.png"))
def test_Lam_Mag_10_surface(self): """Test machine plot with Magnet 10 surface""" plt.close("all") test_obj = Machine() test_obj.rotor = LamSlotMag( Rint=40e-3, Rext=200e-3, is_internal=True, is_stator=False, L1=0.5, Nrvd=0, Wrvd=0.05, ) magnet = [MagnetType10(Lmag=0.5, Hmag=0.02, Wmag=0.08)] test_obj.rotor.slot = SlotMFlat(Zs=8, H0=0, W0=2 * pi / 10, W0_is_rad=True, magnet=magnet) test_obj.rotor.mat_type.magnetics = MatLamination(Wlam=0.5e-3) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=0.55) test_obj.stator = Lamination( Rint=230e-3, Rext=0.3, is_internal=False, is_stator=True, L1=0.5, Nrvd=0, Wrvd=0.05, ) test_obj.stator.mat_type.magnetics = MatLamination(Wlam=0.5e-3) test_obj.frame = Frame(Rint=200e-3, Rext=250e-3, Lfra=0.5) test_obj.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 15) fig.savefig(join(save_path, "test_Lam_Mag_10s_1-Machine.png")) test_obj.rotor.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 10) fig.savefig(join(save_path, "test_Lam_Mag_10s_2-Rotor.png")) test_obj.stator.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 2) fig.savefig(join(save_path, "test_Lam_Mag_10s_3-Stator.png")) magnet2 = [MagnetType10(Lmag=0.5, Hmag=0.02, Wmag=0.04)] test_obj.rotor.slot = SlotMFlat(Zs=8, W0=0.04, W0_is_rad=False, magnet=magnet2) test_obj.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Mag_10s_5-Rotor 2.png"))
def test_Lam_Mag_13_inset(self): """Test machine plot with Magnet 12 inset""" plt.close("all") test_obj = Machine() test_obj.rotor = LamSlotMag( Rint=40e-3, Rext=90e-3, is_internal=True, is_stator=False, L1=0.42, Nrvd=4, Wrvd=0.02, ) magnet = [MagnetType13(Lmag=0.5, Hmag=0.02, Wmag=0.04, Rtop=0.04)] test_obj.rotor.slot = SlotMFlat(Zs=8, W0=0.04, H0=0.02, W3=2 * pi / 64, magnet=magnet) test_obj.rotor.mat_type.mag = MatLamination(Wlam=0.5e-3) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=0.55) test_obj.stator = LamSlotMag( Rint=110e-3, Rext=200e-3, is_internal=False, is_stator=True, L1=0.42, Nrvd=4, Wrvd=0.02, ) magnet2 = [MagnetType13(Lmag=0.5, Hmag=0.02, Wmag=0.04, Rtop=0.04)] test_obj.stator.slot = SlotMFlat(Zs=4, W0=0.04, H0=0.025, W3=2 * pi / 64, magnet=magnet2) test_obj.stator.mat_type.mag = MatLamination(Wlam=0.5e-3) test_obj.frame = Frame(Rint=200e-3, Rext=250e-3, Lfra=0.5) test_obj.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 19) fig.savefig(join(save_path, "test_Lam_Mag_13i_1-Machine.png")) test_obj.rotor.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 10) fig.savefig(join(save_path, "test_Lam_Mag_13i_2-Rotor.png")) test_obj.stator.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 6) fig.savefig(join(save_path, "test_Lam_Mag_13i_3-Stator.png"))
def test_Lam_Mag_10_inset(self): """Test machine plot with Magnet 10 inset""" plt.close("all") rotor = LamSlotMag( Rint=40e-3, Rext=100e-3, is_internal=True, is_stator=False, L1=0.45, Nrvd=1, Wrvd=0.05, ) magnet = [MagnetType10(Lmag=0.5, Hmag=0.02, Wmag=0.04)] rotor.slot = SlotMFlat(Zs=4, W0=0.04, H0=0.02, magnet=magnet) rotor.mat_type.mag = MatMagnetics(Wlam=0.5e-3) rotor.axial_vent.append(VentilationCirc(Zh=4, Alpha0=0, D0=2.5e-3, H0=50e-3)) rotor.axial_vent.append(VentilationCirc(Zh=8, Alpha0=0, D0=5e-3, H0=60e-3)) rotor.axial_vent.append(VentilationCirc(Zh=12, Alpha0=0, D0=10e-3, H0=70e-3)) stator = LamSlotMag( Rint=110e-3, Rext=200e-3, is_internal=False, is_stator=True, L1=0.45, Nrvd=1, Wrvd=0.05, ) magnet2 = [MagnetType10(Lmag=0.5, Hmag=0.02, Wmag=0.04)] stator.slot = SlotMFlat(Zs=8, W0=0.04, W3=2 * pi / 64, H0=0.02, magnet=magnet2) stator.mat_type.mag = MatMagnetics(Wlam=0.5e-3) stator.axial_vent.append( VentilationTrap(Zh=6, Alpha0=pi / 6, W1=10e-3, W2=20e-3, D0=0.02, H0=0.140) ) stator.axial_vent.append( VentilationTrap(Zh=6, Alpha0=pi / 6, W1=20e-3, W2=40e-3, D0=0.02, H0=0.170) ) rotor.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 30) fig.savefig(join(save_path, "test_Lam_Mag_10i_2-Rotor.png")) stator.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 22) fig.savefig(join(save_path, "test_Lam_Mag_10i_3-Stator.png"))
def test_Lam_Mag_13_inset(self): """Test machine plot with Magnet 12 inset""" plt.close("all") rotor = LamSlotMag( Rint=40e-3, Rext=90e-3, is_internal=True, is_stator=False, L1=0.42, Nrvd=4, Wrvd=0.02, ) magnet = [MagnetType13(Lmag=0.5, Hmag=0.02, Wmag=0.04, Rtop=0.04)] rotor.slot = SlotMFlat(Zs=8, W0=0.04, H0=0.02, W3=2 * pi / 64, magnet=magnet) rotor.mat_type.mag = MatMagnetics(Wlam=0.5e-3) stator = LamSlotMag( Rint=110e-3, Rext=200e-3, is_internal=False, is_stator=True, L1=0.42, Nrvd=4, Wrvd=0.02, ) magnet2 = [MagnetType13(Lmag=0.5, Hmag=0.02, Wmag=0.04, Rtop=0.04)] stator.slot = SlotMFlat(Zs=4, W0=0.04, H0=0.025, W3=2 * pi / 64, magnet=magnet2) stator.mat_type.mag = MatMagnetics(Wlam=0.5e-3) rotor.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 10) fig.savefig(join(save_path, "test_Lam_Mag_13i_2-Rotor.png")) stator.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 6) fig.savefig(join(save_path, "test_Lam_Mag_13i_3-Stator.png"))
def test_Lam_Mag_13_surface(self): """Test machine plot with Magnet 13 surface""" plt.close("all") test_obj = Machine() test_obj.rotor = LamSlotMag( Rint=40e-3, Rext=90e-3, is_internal=True, is_stator=False, L1=0.35, Nrvd=3, Wrvd=0.05, ) magnet = [MagnetType13(Lmag=0.5, Hmag=0.02, Wmag=0.08, Rtop=0.0601)] test_obj.rotor.slot = SlotMFlat(Zs=4, W0=0.08, magnet=magnet) test_obj.rotor.mat_type.magnetics = MatLamination(Wlam=0.5e-3) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=0.55) test_obj.stator = Lamination( Rint=130e-3, Rext=0.2, is_internal=False, is_stator=True, L1=0.35, Nrvd=3, Wrvd=0.05, ) test_obj.stator.mat_type.magnetics = MatLamination(Wlam=0.5e-3) test_obj.frame = Frame(Rint=200e-3, Rext=250e-3, Lfra=0.5) test_obj.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 11) fig.savefig(join(save_path, "test_Lam_Mag_13s_1-Machine.png")) test_obj.rotor.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 6) fig.savefig(join(save_path, "test_Lam_Mag_13s_2-Rotor.png")) test_obj.stator.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 2) fig.savefig(join(save_path, "test_Lam_Mag_13s_3-Stator.png"))
def test_build_geometry_out(self): """check that curve_list is correct (outwards magnet) """ lam = LamSlotMag( Rint=1, Rext=0.09, is_internal=False, is_stator=False, L1=0.45, Nrvd=1, Wrvd=0.05, ) lam.slot = SlotMFlat(Zs=8, W0=0.6, H0=0.2, magnet=[MagnetType10(Wmag=0.6, Hmag=0.2)]) test_obj = lam.slot.magnet[0] alpha = lam.slot.comp_angle_opening_magnet() Z1 = 1 * exp(-1j * alpha / 2) + 0.2 Z2 = 1 * exp(1j * alpha / 2) + 0.2 Z3 = Z1 - 0.2 Z4 = Z2 - 0.2 # Creation of curve curve_list = list() curve_list.append(Segment(Z1, Z3)) curve_list.append(Segment(Z3, Z4)) curve_list.append(Segment(Z4, Z2)) curve_list.append(Segment(Z2, Z1)) surface = test_obj.build_geometry() result = surface[0].get_lines() for i in range(0, len(result)): a = result[i].begin b = curve_list[i].begin self.assertAlmostEqual((a - b) / a, 0, delta=DELTA) a = result[i].end b = curve_list[i].end self.assertAlmostEqual((a - b) / a, 0, delta=DELTA)
def test_Lam_Mag_12_surface(self): """Test machine plot with Magnet 12 surface""" plt.close("all") rotor = LamSlotMag( Rint=40e-3, Rext=90e-3, is_internal=True, is_stator=False, L1=0.4, Nrvd=2, Wrvd=0.05, ) magnet = [MagnetType12(Lmag=0.5, Hmag=0.02, Wmag=0.06)] rotor.slot = SlotMFlat(Zs=8, W0=0.06, magnet=magnet) rotor.mat_type.mag = MatMagnetics(Wlam=0.5e-3) stator = Lamination( Rint=130e-3, Rext=0.2, is_internal=False, is_stator=True, L1=0.4, Nrvd=2, Wrvd=0.05, ) stator.mat_type.mag = MatMagnetics(Wlam=0.5e-3) rotor.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 10) fig.savefig(join(save_path, "test_Lam_Mag_12s_2-Rotor.png")) stator.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 2) fig.savefig(join(save_path, "test_Lam_Mag_12s_3-Stator.png"))
def setUp(self): """Run at the begining of every test to setup the gui""" self.test_obj = MachineSIPMSM(type_machine=6) # SPMSM # For comp_output compatibility self.test_obj.stator = LamSlotWind(Rint=0.95, Rext=0.99) self.test_obj.rotor = LamSlotMag(Rint=0.1, Rext=0.9) self.test_obj.rotor.slot = SlotMFlat(Zs=8, W0=10e-3, H0=0e-3) self.test_obj.rotor.slot.magnet = [ MagnetType13(Wmag=10e-3, Hmag=3e-3, Rtop=12e-3) ] self.test_obj.rotor.slot.magnet[0].mat_type.name = "test2" self.matlib = list() self.matlib.append(Material(name="test1")) self.matlib[-1].elec.rho = 0.31 self.matlib.append(Material(name="test2")) self.matlib[-1].elec.rho = 0.32 self.matlib.append(Material(name="test3")) self.matlib[-1].elec.rho = 0.33 self.widget = SMagnet( machine=self.test_obj, matlib=self.matlib, is_stator=False )
def test_Lam_Mag_10_inset_2_mag(self): """Test machine plot with Magnet 10 inset with two magnet in the slot""" plt.close("all") test_obj = Machine() test_obj.rotor = LamSlotMag( Rint=40e-3, Rext=100e-3, is_internal=True, is_stator=False, L1=0.45, Nrvd=1, Wrvd=0.05, ) test_obj.rotor.slot = SlotMFlat( Zs=4, W0=0.03, H0=0.02, W3=2 * pi / 60, magnet=[ MagnetType10(Lmag=0.5, Hmag=0.015, Wmag=0.03), MagnetType10(Lmag=0.5, Hmag=0.015, Wmag=0.03), ], ) test_obj.rotor.mat_type.mag = MatLamination(Wlam=0.5e-3) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=0.55) test_obj.rotor.axial_vent.append( VentilationCirc(Zh=4, Alpha0=0, D0=2.5e-3, H0=50e-3)) test_obj.rotor.axial_vent.append( VentilationCirc(Zh=8, Alpha0=0, D0=5e-3, H0=60e-3)) test_obj.rotor.axial_vent.append( VentilationCirc(Zh=12, Alpha0=0, D0=10e-3, H0=70e-3)) test_obj.stator = LamSlotMag( Rint=110e-3, Rext=200e-3, is_internal=False, is_stator=True, L1=0.45, Nrvd=1, Wrvd=0.05, ) test_obj.stator.slot = SlotMFlat( Zs=8, W0=0.03, W3=2 * pi / 64, H0=0.02, magnet=[ MagnetType10(Lmag=0.5, Hmag=0.025, Wmag=0.03), MagnetType10(Lmag=0.5, Hmag=0.025, Wmag=0.03), ], ) test_obj.stator.mat_type.mag = MatLamination(Wlam=0.5e-3) test_obj.frame = Frame(Rint=200e-3, Rext=250e-3, Lfra=0.5) test_obj.stator.axial_vent.append( VentilationTrap(Zh=6, Alpha0=pi / 6, W1=10e-3, W2=20e-3, D0=0.02, H0=0.140)) test_obj.stator.axial_vent.append( VentilationTrap(Zh=6, Alpha0=pi / 6, W1=20e-3, W2=40e-3, D0=0.02, H0=0.170)) test_obj.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 67) fig.savefig(join(save_path, "test_Lam_Mag_10i_1_Mag_2-Machine.png")) test_obj.rotor.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 34) fig.savefig(join(save_path, "test_Lam_Mag_10i_2_Mag_2-Rotor.png")) test_obj.stator.plot() fig = plt.gcf() self.assertEqual(len(fig.axes[0].patches), 30) fig.savefig(join(save_path, "test_Lam_Mag_10i_3_Mag_2-Stator.png"))
from unittest import TestCase from ddt import ddt, data from pyleecan.Classes.LamSlotMag import LamSlotMag from pyleecan.Classes.SlotMFlat import SlotMFlat from pyleecan.Classes.MagnetType10 import MagnetType10 from pyleecan.Classes.Segment import Segment from pyleecan.Methods.Machine.Magnet.comp_surface import comp_surface from numpy import exp Mag10_test = list() # Internal Slot lam = LamSlotMag(is_internal=True, Rext=0.1325) lam.slot = SlotMFlat(H0=5e-3, W0=10e-3, Zs=12) lam.slot.magnet = [MagnetType10(Hmag=5e-3, Wmag=10e-3)] Mag10_test.append({ "test_obj": lam, "S_exp": 5e-5, "Ao": 0.078449, "H_exp": 5e-3 }) # Outward Slot lam = LamSlotMag(is_internal=False, Rint=0.1325) lam.slot = SlotMFlat(H0=5e-3, W0=10e-3, Zs=12) lam.slot.magnet = [MagnetType10(Hmag=5e-3, Wmag=10e-3)] Mag10_test.append({ "test_obj": lam, "S_exp": 5e-5,