def test_type_wind_CW2LT(self): """Test Winding matrix plot for type_winding CW2LT""" plt.close("all") test_obj = LamSlotWind(Rint=0.5, Rext=0.9, is_internal=False) test_obj.slot = SlotW22(Zs=6, H0=20e-3, H2=0.2, W0=pi / 10, W2=pi / 6) test_obj.winding = WindingCW2LT(p=2, qs=3) test_obj.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Wind_CW2LT_lam.png")) test_obj.plot_winding() fig = plt.gcf() fig.savefig(join(save_path, "test_Wind_CW2LT_wind.png")) test_obj.slot = SlotW22(Zs=12, H0=20e-3, H2=0.2, W0=pi / 12, W2=pi / 8) test_obj.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Wind_CW2LT_lam_ms=0,25.png")) test_obj.winding.p = 4 test_obj.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Wind_CW2LT_lam_p=4.png"))
def test_Lam_Wind_22_wind_22(self): """Test machine plot with Slot 22 and winding rad=2, tan=2 """ print("\nTest plot Slot 22") plt.close("all") test_obj = Machine() test_obj.rotor = LamSlotWind( Rint=0, Rext=0.5, is_internal=True, is_stator=False, L1=0.8, Nrvd=4, Wrvd=0.05, ) test_obj.rotor.slot = SlotW22(Zs=6, W0=pi / 20, W2=pi / 10, H0=20e-3, H2=150e-3) test_obj.rotor.winding = WindingUD( user_wind_mat=wind_mat, qs=4, p=4, Lewout=60e-3 ) test_obj.rotor.mat_type.mag = MatLamination(Wlam=0.5e-3) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=1) test_obj.stator = LamSlotWind( Rint=0.51, Rext=0.8, is_internal=False, is_stator=True, L1=0.8, Nrvd=4, Wrvd=0.05, ) test_obj.stator.slot = SlotW22( Zs=18, W0=pi / 20, W2=pi / 10, H0=20e-3, H2=150e-3 ) test_obj.stator.winding = WindingDW2L(qs=3, p=3) test_obj.stator.mat_type.mag = MatLamination(Wlam=0.5e-3) test_obj.stator.winding.Lewout = 60e-3 test_obj.frame = Frame(Rint=0.8, Rext=0.8, Lfra=1) test_obj.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s22_1-Machine.png")) # Rotor + Stator + 0 for frame + 0 for shaft self.assertEqual(len(fig.axes[0].patches), 63) test_obj.rotor.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s22_2-Rotor.png")) # 1 for lam + 4*Zs for wind self.assertEqual(len(fig.axes[0].patches), 25) test_obj.stator.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s22_3-Stator.png")) # 2 for lam + Zs*2 for wind self.assertEqual(len(fig.axes[0].patches), 38)
def setUp(self): """Run at the begining of every test to setup the gui""" self.test_obj = MachineSCIM() self.test_obj.stator = LamSlotWind(is_stator=True) self.test_obj.stator.slot = SlotW22(H0=0.001, H2=0.01, W0=0.1, W2=0.2) self.test_obj.stator.winding = Winding(Npcpp=10, Ntcoil=11) self.test_obj.rotor = LamSlotWind(is_stator=False) self.test_obj.rotor.slot = SlotW22(H0=0.001, H2=0.01, W0=0.1, W2=0.2) self.test_obj.rotor.winding = Winding(Npcpp=20, Ntcoil=21) self.widget_1 = SWindParam(machine=self.test_obj, matlib=[], is_stator=True) self.widget_2 = SWindParam(machine=self.test_obj, matlib=[], is_stator=False)
def get_polar_eq(self): """Returns a polar equivalent of the lamination Parameters ---------- self : LamSlotWind A LamSlotWind object to convert to polar Returns ------- polar_eq: LamSlotWind The polar equivalent of the lamination """ # Copy the lamination polar_eq = type(self)(init_dict=self.as_dict()) # Compute the polar dimension of the slot Hwind = self.slot.comp_height_wind() Histhmus = self.slot.comp_height() - Hwind Wwind = self.slot.comp_angle_wind_eq() Wisthmus = self.slot.comp_angle_opening() polar_eq.slot = SlotW22(Zs=self.slot.Zs, H0=Histhmus, W0=Wisthmus, H2=Hwind, W2=Wwind) # TODO: Polar eq for ventilations ? polar_eq.axial_vent = list() return polar_eq
def test_init_Cond22(self): self.test_obj.rotor = LamSquirrelCage(Hscr=0.21, Lscr=0.22) self.test_obj.rotor.slot = SlotW22(H0=0.001, H2=0.01, W0=0.1, W2=0.2) self.test_obj.rotor.winding.Lewout = 0.23 self.test_obj.rotor.ring_mat.name = "test2" self.test_obj.rotor.winding.conductor = CondType22() self.test_obj.rotor.winding.conductor.cond_mat.name = "test3" self.widget = SBar(machine=self.test_obj, matlib=self.matlib, is_stator=False) self.assertEqual(self.widget.lf_Hscr.value(), 0.21) self.assertEqual(self.widget.lf_Lscr.value(), 0.22) self.assertEqual(self.widget.lf_Lewout.value(), 0.23) self.assertEqual(self.widget.w_mat.c_mat_type.currentIndex(), 1) self.assertEqual(self.widget.w_mat.c_mat_type.currentText(), "test2") self.assertIs(type(self.widget.w_bar), PCondType22) self.assertEqual(self.widget.c_bar_type.currentIndex(), 1) self.assertEqual(self.widget.c_bar_type.currentText(), "Die cast bar") self.assertEqual(self.widget.w_bar.w_mat.c_mat_type.currentIndex(), 2) self.assertEqual(self.widget.w_bar.w_mat.c_mat_type.currentText(), "test3") # Check output txt self.assertEqual(self.widget.w_bar.w_out.out_Sbar.text(), "Sbar: 0.002088 m²") self.assertEqual(self.widget.w_bar.w_out.out_Sslot.text(), "Sslot: 0.002088 m²") self.assertEqual(self.widget.w_bar.w_out.out_ratio.text(), "Sbar / Sslot: 100 %")
def test_init_WRSM(self): """Check that the GUI is correctly initialize with a WRSM machine """ self.test_obj = MachineWRSM(type_machine=9) self.test_obj.stator = LamSlotWind() self.test_obj.stator.slot = SlotW22(Zs=36, H0=0.001, H2=0.01, W0=0.1, W2=0.2) self.test_obj.stator.winding = WindingDW2L(p=8, qs=4) self.test_obj.rotor = LamSlotWind() self.test_obj.rotor.slot = SlotW22(Zs=36, H0=0.001, H2=0.01, W0=0.1, W2=0.2) self.test_obj.rotor.winding = Winding(p=8, qs=4) self.widget = SWindPat(machine=self.test_obj, matlib=[], is_stator=True) self.widget2 = SWindPat(machine=self.test_obj, matlib=[], is_stator=False) # Check result stator self.assertEqual(type(self.test_obj.stator.winding), WindingDW2L) self.assertEqual(self.test_obj.stator.winding.p, 8) self.assertEqual(self.test_obj.stator.winding.qs, 4) self.assertEqual(self.widget.si_qs.isEnabled(), True) self.assertEqual(self.widget.si_coil_pitch.isHidden(), False) self.assertEqual(self.widget.si_Nslot.value(), 0) self.assertEqual(self.widget.c_wind_type.currentIndex(), 2) self.assertEqual( self.widget.c_wind_type.currentText(), "Double Layer Distributed" ) self.assertEqual(self.widget.is_reverse.checkState(), Qt.Unchecked) self.assertEqual( self.widget.out_shape.text(), "Winding Matrix shape: [2, 1, 36, 4]" ) # Check result rotor self.assertEqual(type(self.test_obj.rotor.winding), WindingCW2LT) self.assertEqual(self.test_obj.rotor.winding.p, 8) self.assertEqual(self.test_obj.rotor.winding.qs, 1) self.assertEqual(self.widget2.si_qs.value(), 1) self.assertEqual(self.widget2.si_qs.isEnabled(), False) self.assertEqual(self.widget2.si_coil_pitch.isHidden(), True) self.assertEqual(self.widget2.si_Nslot.value(), 0) self.assertEqual(self.widget2.c_wind_type.currentIndex(), 0) self.assertEqual( self.widget2.c_wind_type.currentText(), "DC wound winding for salient pole" ) self.assertEqual(self.widget2.is_reverse.checkState(), Qt.Unchecked) self.assertEqual( self.widget2.out_shape.text(), "Winding Matrix shape: [1, 2, 36, 1]" )
def test_set_slot_22(self): """Check that you can edit a Slot 22""" Zs = int(uniform(1, 100)) self.test_obj.stator.slot = SlotW22(Zs=Zs) self.widget = SWSlot(self.test_obj, matlib=[], is_stator=True) self.assertEqual(self.widget.si_Zs.value(), Zs) self.assertEqual(self.widget.c_slot_type.currentText(), "Slot Type 22") self.assertEqual(self.widget.c_slot_type.currentIndex(), 8) self.assertEqual(type(self.widget.w_slot), PWSlot22)
def setUp(self): """Run at the begining of every test to setup the gui""" self.test_obj = MachineSCIM() self.test_obj.stator = LamSlotWind() self.test_obj.stator.slot = SlotW22(Zs=36, H0=0.001, H2=0.01, W0=0.1, W2=0.2) self.test_obj.stator.winding = WindingDW2L() self.test_obj.stator.winding.qs = 6 self.test_obj.stator.winding.coil_pitch = 8 self.test_obj.stator.winding.Nslot_shift_wind = 10 self.test_obj.stator.winding.is_reverse_wind = True self.widget = SWindPat(machine=self.test_obj, matlib=[], is_stator=True)
def test_init(self): """Check that the Widget spinbox initialise to the lamination value""" self.assertEqual(self.widget.lf_H0.value(), 0.10) self.assertEqual(self.widget.lf_H2.value(), 0.12) self.assertEqual(self.widget.lf_W0.value(), 0.13) self.assertEqual(self.widget.lf_W2.value(), 0.15) self.test_obj.slot = SlotW22(H0=0.20, H2=0.22, W0=0.23, W2=0.25) self.widget = PWSlot22(self.test_obj) self.assertEqual(self.widget.lf_H0.value(), 0.20) self.assertEqual(self.widget.lf_H2.value(), 0.22) self.assertEqual(self.widget.lf_W0.value(), 0.23) self.assertEqual(self.widget.lf_W2.value(), 0.25)
def test_build_geometry(self): """check that curve_list is correct""" test_obj = SlotW22(W0=pi / 10, H0=0.1, W2=pi / 5, H2=0.1) lam = LamSlot(is_internal=False, slot=test_obj, Rint=1) Z1 = cos(pi / 20) + 1j * sin(pi / 20) Z2 = 1.1 * (cos(pi / 20) + 1j * sin(pi / 20)) Z3 = 1.1 * (cos(pi / 10) + 1j * sin(pi / 10)) Z4 = 1.2 * (cos(pi / 10) + 1j * sin(pi / 10)) Z5 = 1.2 * (cos(pi / 10) - 1j * sin(pi / 10)) Z6 = 1.1 * (cos(pi / 10) - 1j * sin(pi / 10)) Z7 = 1.1 * (cos(pi / 20) - 1j * sin(pi / 20)) Z8 = cos(pi / 20) - 1j * sin(pi / 20) [Z8, Z7, Z6, Z5, Z4, Z3, Z2, Z1] = [Z1, Z2, Z3, Z4, Z5, Z6, Z7, Z8] # Creation of curve curve_list = list() Zc = 0 # center curve_list.append(Segment(Z1, Z2)) curve_list.append(Arc2(Z2, Zc, -pi / 20)) curve_list.append(Segment(Z3, Z4)) curve_list.append(Arc2(Z4, Zc, pi / 5)) curve_list.append(Segment(Z5, Z6)) curve_list.append(Arc2(Z6, Zc, -pi / 20)) curve_list.append(Segment(Z7, Z8)) result = test_obj.build_geometry() self.assertEqual(len(result), len(curve_list)) for i in range(0, len(result)): if isinstance(result[i], Segment): 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) else: # Arc2 a = result[i].begin b = curve_list[i].begin self.assertAlmostEqual((a - b) / a, 0, delta=DELTA) a = result[i].center b = curve_list[i].center self.assertAlmostEqual(a, b) a = result[i].angle b = curve_list[i].angle self.assertAlmostEqual((a - b) / a, 0, delta=DELTA)
def test_output_txt(self): """Check that the Output text is computed and correct """ self.test_obj = LamSlotWind( Rint=0, Rext=0.5, is_internal=True, is_stator=False, L1=0.8, Nrvd=4, Wrvd=0.05, ) self.test_obj.slot = SlotW22(Zs=6, W0=pi / 20, W2=pi / 10, H0=20e-3, H2=150e-3) self.widget = PWSlot22(self.test_obj) self.assertEqual(self.widget.w_out.out_slot_height.text(), "Slot height: 0.17 m")
def setUp(self): """Run at the begining of every test to setup the gui""" self.test_obj = MachineSCIM() self.test_obj.rotor = LamSquirrelCage(Hscr=0.11, Lscr=0.12) self.test_obj.rotor.slot = SlotW22(H0=0.001, H2=0.01, W0=0.1, W2=0.2) self.test_obj.rotor.winding.Lewout = 0.13 self.test_obj.rotor.ring_mat.name = "test3" self.test_obj.rotor.winding.conductor = CondType21(Hbar=0.014, Wbar=0.015) self.test_obj.rotor.winding.conductor.cond_mat.name = "test1" 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 = SBar(machine=self.test_obj, matlib=self.matlib, is_stator=False)
def setUp(self): """Run at the begining of every test to setup the gui""" self.test_obj = LamSlotWind(Rint=0.1, Rext=0.2) self.test_obj.slot = SlotW22(H0=0.10, H2=0.12, W0=0.13, W2=0.15) self.widget = PWSlot22(self.test_obj)
from pyleecan.Tests.Validation.Material.M400_50A import M400_50A from pyleecan.Tests.Validation.Material.Magnet3 import Magnet3 from pyleecan.Tests.Validation.Material.Copper1 import Copper1 # Stator setup stator = LamSlotWind(Rint=0.116, Rext=0.2, Nrvd=0, L1=0.4, Kf1=1, is_internal=False, is_stator=True) stator.slot = SlotW22(Zs=12, H0=4e-3, H2=25e-3, W0=0.6 * 12 * pi / 180, W2=12 * pi / 180) stator.winding = WindingDW1L(qs=3, Lewout=15e-3, p=1, Ntcoil=12, Npcpp=1, Nslot_shift_wind=0) stator.winding.conductor = CondType11( Nwppc_tan=1, Nwppc_rad=1, Wwire=2e-3, Hwire=2e-3, Wins_wire=1e-6,
from pyleecan.Classes.LamSlotMag import LamSlotMag from pyleecan.Classes.SlotMPolar import SlotMPolar from pyleecan.Classes.MagnetType11 import MagnetType11 from pyleecan.Classes.Shaft import Shaft from pyleecan.Tests.Validation.Material.M400_50A import M400_50A from pyleecan.Tests.Validation.Material.Magnet1 import Magnet1 from pyleecan.Tests.Validation.Material.Copper1 import Copper1 # Stator setup stator = LamSlotWind( Rint=0.026, Rext=0.048, Nrvd=0, L1=0.09, Kf1=0.96, is_internal=False, is_stator=True ) stator.slot = SlotW22(Zs=6, H0=0.002, H2=0.01, W0=0.44, W2=0.628) stator.winding = WindingCW1L(qs=3, Lewout=0.015, p=2, Ntcoil=42, Npcpp=1) stator.winding.conductor = CondType12( Nwppc=1, Wwire=0.0011283792, Wins_wire=1e-6, Kwoh=0.5 ) # Rotor setup rotor = LamSlotMag( Rext=0.025, Rint=0.005, L1=0.09, Kf1=0.95, is_internal=True, is_stator=False, Nrvd=0 ) rotor.slot = SlotMPolar(Zs=4, W3=0, W0=1.3351769, H0=0.007) rotor.slot.magnet = [MagnetType11(Wmag=1.3351769, Hmag=0.007)] shaft = Shaft(Lshaft=0.442, Drsh=0.01) frame = None
from pyleecan.Classes.SlotW21 import SlotW21 from pyleecan.Tests.Validation.Material.Copper1 import Copper1 from pyleecan.Tests.Validation.Material.M400_50A import M400_50A # Stator setup stator = LamSlotWind(Rint=0.061, Rext=0.1, Nrvd=0, L1=0.2, Kf1=1, is_internal=False, is_stator=True) stator.slot = SlotW22(Zs=36, H0=0.002, H2=0.022, W0=0.0523598775598, W2=0.0872664625997) stator.winding = WindingDW1L(qs=3, Lewout=0, p=2, Ntcoil=15, Npcpp=1, coil_pitch=9) stator.winding.conductor = CondType12(Nwppc=1, Wwire=0.0005, Wins_wire=1e-06, Kwoh=0) # Rotor setup rotor = LamSquirrelCage(
from numpy import pi, ndarray, cos, sin from pyleecan.Classes.LamSlot import LamSlot from ddt import ddt, data from pyleecan.Methods.Slot.Slot.comp_height import comp_height from pyleecan.Methods.Slot.Slot.comp_surface import comp_surface from pyleecan.Methods.Slot.Slot.comp_angle_opening import comp_angle_opening from pyleecan.Methods.Slot.SlotWind.comp_surface_wind import comp_surface_wind # For AlmostEqual DELTA = 1e-4 slotW22_test = list() # Internal Slot lam = LamSlot(is_internal=True, Rext=1) lam.slot = SlotW22(Zs=36, W0=pi / 72, W2=pi / 36, H0=6e-3, H2=40e-3) slotW22_test.append({ "test_obj": lam, "S_exp": 3.660915e-03, "SW_exp": 3.3999e-03, "H_exp": 0.046 }) # External Slot lam = LamSlot(is_internal=False, Rint=1) lam.slot = SlotW22(Zs=36, W0=pi / 72, W2=pi / 36, H0=6e-3, H2=40e-3) slotW22_test.append({ "test_obj": lam, "S_exp": 3.844e-03, "SW_exp": 3.5814e-03, "H_exp": 0.046