def test_slot_10(self): """Check that you can generate the 3D mesh of Slot 10 """ # SetUp stator = LamSlotWind( Rint=0.1325, Rext=0.2, Nrvd=0, L1=0.35, Kf1=0.95, is_internal=False, is_stator=True, ) stator.slot = SlotW10(Zs=36, H0=1e-3, H1=1.5e-3, H2=30e-3, W0=12e-3, W1=14e-3, W2=12e-3) gen_3D_mesh( lamination=stator, save_path=join(save_path, "Lamination.msh"), mesh_size=5e-3, Nlayer=20, )
def setUp(self): """Run at the begining of every test to setup the gui""" self.test_obj = MachineIPMSM(type_machine=8) self.test_obj.stator = LamSlotWind() self.test_obj.stator.winding.p = 4 self.test_obj.rotor = LamHole(Rint=0.1, Rext=0.2) self.test_obj.rotor.hole = list() self.test_obj.rotor.hole.append(HoleM50(Zh=8)) self.test_obj.rotor.hole[0].magnet_0.mat_type.name = "Magnet3" self.test_obj2 = MachineSyRM(type_machine=5) self.test_obj2.stator = LamSlotWind() self.test_obj2.stator.winding.p = 4 self.test_obj2.rotor = LamHole(Rint=0.1, Rext=0.2) self.test_obj2.rotor.hole = list() self.test_obj2.rotor.hole.append(HoleM54(Zh=16)) self.matlib = list() self.matlib.append(Material(name="Magnet1")) self.matlib.append(Material(name="Magnet2")) self.matlib.append(Material(name="Magnet3")) self.widget = SMHoleMag(machine=self.test_obj, matlib=self.matlib, is_stator=False) self.widget2 = SMHoleMag(machine=self.test_obj2, matlib=self.matlib, is_stator=False)
def setUp(self): """Run at the begining of every test to setup the machine""" plt.close("all") test_obj = LamSlotWind( Rint=92.5e-3, Rext=0.2, is_internal=True, is_stator=True, L1=0.95, Nrvd=1, Wrvd=0.05, ) test_obj.slot = SlotW16(Zs=6, W0=2 * pi / 60, W3=30e-3, H0=10e-3, H2=70e-3, R1=15e-3) test_obj.mat_type.name = "Param" test_obj.mat_type.magnetics = MatLamination(Wlam=0.5e-3) BH = BHCurveParam(Bmax=1.5, mur_0=8585, mur_1=21.79, a=0.25575) test_obj.mat_type.magnetics.BH_curve = BH self.test_obj = test_obj
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, L1=0.11, Kf1=0.12, Nrvd=12, Wrvd=0.13) self.test_obj.stator.mat_type.name = "test3" self.test_obj.rotor = LamSlotWind(is_stator=False, L1=0.21, Kf1=0.22, Nrvd=22, Wrvd=0.23) self.test_obj.rotor.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_1 = SLamParam(machine=self.test_obj, matlib=self.matlib, is_stator=True) self.widget_2 = SLamParam(machine=self.test_obj, matlib=self.matlib, is_stator=False)
def check(self): """Check that the Lamination object is correct Parameters ---------- self : LamSquirrelCage A LamSquirrelCage object Returns ------- None Raises _______ SCC_NotARotor A LamSquirrelCage Lamination can't be a stator SCC_WrongCond A LamSquirrelCage's conductor must be a type 2_1 """ LamSlotWind.check(self) if self.is_stator: raise SCC_NotARotor("A LamSquirrelCage Lamination can't be " "a stator") if not isinstance(self.winding.conductor, CondType21): raise SCC_WrongCond("A LamSquirrelCage's conductor must be " "a type 2_1")
def test_Lam_Wind_28_wind_rad_tan(self): """Test machine plot with Slot 28 and winding rad=1, tan=2 and rad=2 and tan=1 """ print("\nTest plot Slot 28") plt.close("all") test_obj = Machine() test_obj.rotor = LamSlotWind( Rint=35e-3, Rext=84e-3, is_internal=True, is_stator=False, L1=0.9, Nrvd=2, Wrvd=0.05, ) test_obj.rotor.axial_vent = [ VentilationCirc(Zh=6, Alpha0=pi / 6, D0=15e-3, H0=0.045) ] test_obj.rotor.slot = SlotW28( Zs=42, W0=3.5e-3, H0=0.45e-3, R1=3.5e-3, H3=14e-3, W3=5e-3 ) test_obj.rotor.winding = WindingCW2LT(qs=3, p=3) test_obj.rotor.mat_type.magnetics = MatLamination(Wlam=0.5e-3) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=1) test_obj.stator = LamSlotWind( Rint=85e-3, Rext=0.2, is_internal=False, is_stator=True, L1=0.9, Nrvd=2, Wrvd=0.05, ) test_obj.stator.slot = SlotW28( Zs=18, W0=7e-3, R1=10e-3, H0=5e-3, H3=30e-3, W3=5e-3 ) test_obj.stator.winding = WindingDW2L(qs=3, p=3, Lewout=60e-3) test_obj.stator.mat_type.magnetics = MatLamination(Wlam=0.5e-3) test_obj.frame = Frame(Rint=0.2, Rext=0.25, Lfra=1) test_obj.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s28_1-Machine.png")) # Rotor + stator + 2 for frame + 1 for Shaft self.assertEqual(len(fig.axes[0].patches), 133) test_obj.rotor.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s28_2-Rotor.png")) # 2 for lam + Zs*2 for wind + 6 vent self.assertEqual(len(fig.axes[0].patches), 92) test_obj.stator.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s28_3-Stator.png")) # 2 for lam, 2*Zs for wind self.assertEqual(len(fig.axes[0].patches), 38)
def test_Lam_Wind_28_wind_22(self): """Test machine plot with Slot 28 and winding rad=2, tan=2 """ plt.close("all") test_obj = Machine() test_obj.rotor = LamSlotWind( Rint=0.01, Rext=0.129, is_internal=True, is_stator=False, L1=0.9, Nrvd=2, Wrvd=0.05, ) test_obj.rotor.slot = SlotW28( Zs=6, W0=20e-3, R1=25e-3, H0=10e-3, H3=50e-3, W3=15e-3 ) test_obj.rotor.winding = WindingUD( user_wind_mat=wind_mat, qs=4, p=4, Lewout=60e-3 ) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=1) test_obj.stator = LamSlotWind( Rint=0.13, Rext=0.4, is_internal=False, is_stator=True, L1=0.9, Nrvd=2, Wrvd=0.05, ) test_obj.stator.axial_vent = [ VentilationCirc(Zh=6, Alpha0=pi / 6, D0=60e-3, H0=0.25) ] test_obj.stator.slot = SlotW28( Zs=6, W0=40e-3, R1=50e-3, H0=10e-3, H3=70e-3, W3=85e-3 ) test_obj.stator.winding = WindingUD( user_wind_mat=wind_mat, qs=4, p=4, Lewout=60e-3 ) test_obj.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s28_4-Machine.png")) # Rotor + stator + 0 for frame + 1 for shaft self.assertEqual(len(fig.axes[0].patches), 59) test_obj.rotor.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s28_5-Rotor.png")) # 2 for lam + Zs*4 for wind self.assertEqual(len(fig.axes[0].patches), 26) test_obj.stator.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s28_6-Stator.png")) # 2 for lam, 4*Zs for wind + 6 vents self.assertEqual(len(fig.axes[0].patches), 32)
def test_Lam_Wind_24_wind_22(self): """Test machine plot with Slot 24 and winding rad=2, tan=2 """ print("\nTest plot Slot 24") plt.close("all") test_obj = Machine() test_obj.rotor = LamSlotWind( Rint=0.2, Rext=0.5, is_internal=True, is_stator=False, L1=0.8, Nrvd=4, Wrvd=0.05, ) test_obj.rotor.slot = SlotW24(Zs=6, W3=100e-3, H2=150e-3) test_obj.rotor.winding = WindingUD(user_wind_mat=wind_mat, qs=4, p=4, Lewout=120e-3) test_obj.rotor.mat_type.magnetics = 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 = SlotW24(Zs=18, W3=50e-3, H2=200e-3) test_obj.stator.winding = WindingDW2L(qs=3, p=3) test_obj.stator.mat_type.magnetics = MatLamination(Wlam=0.5e-3) test_obj.stator.winding.Lewout = 120e-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_s24_1-Machine.png")) # Rotor + Stator + 0 for frame + 1 for shaft self.assertEqual(len(fig.axes[0].patches), 65) test_obj.rotor.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s24_2-Rotor.png")) # 2 for lam + 4*Zs for wind self.assertEqual(len(fig.axes[0].patches), 26) test_obj.stator.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s24_3-Stator.png")) # 2 for lam + 2*Zs 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(name="test_machine", type_machine=1) self.test_obj.stator = LamSlotWind( is_stator=True, is_internal=False, Rint=0.21, Rext=0.22 ) self.test_obj.stator.winding.p = 6 self.test_obj.rotor = LamSlotWind( is_stator=False, is_internal=True, Rint=0.11, Rext=0.12 ) self.widget = SMachineType(machine=self.test_obj, matlib=[], is_stator=False)
def test_save_folder_path(self): """Save with a folder path """ test_obj = LamSlotWind(L1=0.45) file_path = join(save_dir, "LamSlotWind.json") if isfile(file_path): remove(file_path) self.assertFalse(isfile(file_path)) test_obj.save(save_dir) self.assertTrue(isfile(file_path))
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 test_init_empty(self): """Check that the widget can open with an unknown material """ self.machine = MachineIPMSM() self.machine.stator = LamSlotWind() self.machine.rotor = LamHole() self.machine._set_None() self.machine.stator.winding.p = 4 self.machine.type_machine = 8 self.machine.rotor.hole = [HoleM50()] self.machine.rotor.hole[ 0].magnet_0.mat_type.name = "Magnet_doesnot_exist" self.widget = SMHoleMag(machine=self.machine, matlib=self.matlib, is_stator=False) # Check default material self.assertEqual(self.widget.w_mat.c_mat_type.count(), 4) self.assertEqual(self.widget.w_mat.c_mat_type.currentText(), "") self.assertEqual(self.widget.w_mat.c_mat_type.currentIndex(), -1) # Click to open matlib self.assertFalse(hasattr(self.widget, "mat_win")) self.widget.w_mat.b_matlib.clicked.emit() self.assertEqual(type(self.widget.w_mat.mat_win), DMatLib) # Check Matlib init self.assertEqual(self.widget.w_mat.mat_win.nav_mat.count(), 4) self.assertEqual( self.widget.w_mat.mat_win.nav_mat.currentItem().text(), "001 - Copper1")
def test_output_txt(self): """Check that the Output text is computed and correct """ self.test_obj = LamSlotWind( Rint=0.2, Rext=0.5, is_internal=True, is_stator=False, L1=0.85, Nrvd=3, Wrvd=0.05, ) self.test_obj.slot = SlotW21( Zs=6, W0=40e-3, W1=60e-3, W2=40e-3, H0=20e-3, H1=0, H2=130e-3, H1_is_rad=False, ) self.widget = PWSlot21(self.test_obj) self.assertEqual(self.widget.w_out.out_slot_height.text(), "Slot height: 0.1504 m")
def setUp(self): """Run at the begining of every test to setup the machine""" plt.close("all") test_obj = MachineIPMSM() test_obj.rotor = LamHole(Rint=45e-3 / 2, Rext=81.5e-3, is_stator=False, is_internal=True, L1=0.9) test_obj.rotor.hole = list() test_obj.rotor.hole.append( HoleM51( Zh=8, W0=0.016, W1=pi / 6, W2=0.004, W3=0.01, W4=0.002, W5=0.01, W6=0.002, W7=0.01, H0=0.01096, H1=0.0015, H2=0.0055, )) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=1.2) test_obj.stator = LamSlotWind(Rint=0.09, Rext=0.12, is_internal=False, is_stator=True, L1=0.9, slot=None) test_obj.frame = Frame(Rint=0.12, Rext=0.12, Lfra=0.7) self.test_obj = test_obj
def test_set_p_syrm(self): """Check that the Widget allow to update p""" self.test_obj = MachineSyRM(name="test_machine_ipmsm", type_machine=5) self.test_obj.stator = LamSlotWind(is_stator=True, is_internal=True, Rint=0.21, Rext=0.22) self.test_obj.rotor = LamHole(is_stator=False, is_internal=False, Rint=0.11, Rext=0.12) self.test_obj.rotor.hole = list() self.test_obj.rotor.hole.append(HoleM50(Zh=0)) self.widget = SMachineType(machine=self.test_obj, matlib=[], is_stator=False) # Clear the field before writing the new value self.widget.si_p.clear() value = int(uniform(3, 100)) QTest.keyClicks(self.widget.si_p, str(value)) self.widget.si_p.editingFinished.emit() # To trigger the slot self.assertEqual(self.test_obj.stator.winding.p, value) self.assertEqual(self.test_obj.rotor.hole[0].Zh, 2 * value)
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 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 = SlotW29( H0=0.10, H1=0.11, H2=0.12, W0=0.13, W1=0.14, W2=0.15 ) self.widget = PWSlot29(self.test_obj)
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, is_internal=False, Rint=0.21, Rext=0.22) self.test_obj.rotor = LamSlotWind(is_stator=False, is_internal=True, Rint=0.11, Rext=0.12) self.test_obj.frame = Frame(Rint=0.22, Rext=0.24, Lfra=0.25) self.test_obj.shaft = Shaft(Lshaft=0.333, Drsh=self.test_obj.rotor.Rint * 2) self.widget = SMachineDimension(machine=self.test_obj, 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 = SlotW28(H0=0.10, R1=0.11, H3=0.12, W0=0.13, W3=0.14) self.widget = PWSlot28(self.test_obj)
def test_save_load_machine(self): """Check that you can save and load a machine object """ # SetUp test_obj = MachineSIPMSM(name="test", desc="test\non\nseveral lines") test_obj.stator = LamSlotWind(L1=0.45) test_obj.stator.slot = SlotW10(Zs=10, H0=0.21, W0=0.23) test_obj.stator.winding = WindingDW1L(qs=5) test_obj.rotor = LamSlotMag(L1=0.55) test_obj.rotor.slot = SlotMPolar(W0=pi / 4) test_obj.rotor.slot.magnet = [MagnetType11(Wmag=pi / 4, Hmag=3)] test_obj.shaft = Shaft(Lshaft=0.65) test_obj.frame = None # Save Test file_path = join(save_dir, "test_machine.json") if isfile(file_path): remove(file_path) self.assertFalse(isfile(file_path)) test_obj.save(file_path) self.assertTrue(isfile(file_path)) # Load Test result = load(file_path) self.assertTrue(type(result) is MachineSIPMSM) self.assertEqual(result.name, "test") self.assertEqual(result.desc, "test\non\nseveral lines") self.assertTrue(type(result.stator) is LamSlotWind) self.assertEqual(result.stator.L1, 0.45) self.assertTrue(type(result.stator.slot) is SlotW10) self.assertEqual(result.stator.slot.Zs, 10) self.assertEqual(result.stator.slot.H0, 0.21) self.assertEqual(result.stator.slot.W0, 0.23) self.assertTrue(type(result.stator.winding) is WindingDW1L) self.assertEqual(result.stator.winding.qs, 5) self.assertTrue(type(result.rotor) is LamSlotMag) self.assertEqual(result.rotor.L1, 0.55) self.assertTrue(type(result.rotor.slot) is SlotMPolar) self.assertEqual(result.rotor.slot.W0, pi / 4) self.assertTrue(type(result.rotor.slot.magnet) is list) self.assertTrue(type(result.rotor.slot.magnet[0]) is MagnetType11) self.assertEqual(len(result.rotor.slot.magnet), 1) self.assertEqual(result.rotor.slot.magnet[0].Wmag, pi / 4) self.assertEqual(result.rotor.slot.magnet[0].Hmag, 3) self.assertTrue(type(result.shaft) is Shaft) self.assertEqual(result.shaft.Lshaft, 0.65) self.assertEqual(result.frame, None)
def setUp(self): """Run at the begining of every test to setup the machine""" plt.close("all") test_obj = LamSlotWind( Rint=92.5e-3, Rext=0.2, is_internal=True, is_stator=True, L1=0.95, Nrvd=1, Wrvd=0.05, ) test_obj.slot = SlotW16(Zs=6, W0=2 * pi / 60, W3=30e-3, H0=10e-3, H2=70e-3, R1=15e-3) self.test_obj = test_obj
def setUp(self): """Run at the begining of every test to setup the gui""" self.test_obj = MachineWRSM() self.test_obj.rotor = LamSlotWind(Rint=0.1, Rext=0.2) self.test_obj.rotor.slot = SlotW60( Zs=0, R1=0.10, H1=0.11, H2=0.12, W1=0.14, W2=0.15, H3=0.16, H4=0.17, W3=0.18 ) self.test_obj.rotor.winding.p = 4 self.widget = SWPole(self.test_obj, matlib=[], is_stator=False)
def setUp(self): """Run at the begining of every test to setup the gui""" self.test_obj = LamSlotWind(Rint=92.5e-3, Rext=0.2, is_internal=False) self.test_obj.slot = SlotW15(H0=0.10, H1=0.11, H2=0.12, W0=0.13, W3=0.14, R1=0.15, R2=0.16) self.widget = PWSlot15(self.test_obj)
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_Lam_Wind_15_wind_22(self): """Test machine plot with Slot 15 and winding rad=2, tan=2 """ print("\nTest plot Slot 15 rad=2, tan=2") plt.close("all") test_obj = LamSlotWind( Rint=92.5e-3, Rext=0.2, is_internal=False, is_stator=True, L1=0.95, Nrvd=1, Wrvd=0.05, ) test_obj.slot = SlotW15(Zs=6, W0=10e-3, W3=30e-3, H0=5e-3, H1=20e-3, H2=50e-3, R1=15e-3, R2=10e-3) test_obj.winding = WindingUD(user_wind_mat=wind_mat, qs=4, p=4, Lewout=60e-3) test_obj.plot() fig = plt.gcf() fig.savefig(join(save_path, "test_Lam_Wind_s15.png")) # 2 for lam + Zs*4 for wind self.assertEqual(len(fig.axes[0].patches), 26)
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 = SlotW23(H0=0.10, H1=0.11, H2=0.12, W0=0.13, W1=0.14, W2=0.15, H1_is_rad=False) self.test_obj.slot.W3 = None self.widget = PWSlot23(self.test_obj)
def test_output_txt(self): """Check that the Output text is computed and correct """ self.test_obj = LamSlotWind( Rint=0.1, Rext=0.5, is_internal=True, is_stator=False, L1=0.9, Nrvd=2 ) self.test_obj.slot = SlotW29( Zs=6, W0=0.05, H0=0.05, H1=0.1, W1=0.1, H2=0.2, W2=0.15 ) self.widget = PWSlot29(self.test_obj) self.assertEqual( self.widget.w_out.out_slot_height.text(), "Slot height: 0.3506 m" )
def test_save_load_dict(self): """Test the save and load function of data structures """ # SetUp test_obj_1 = MachineSIPMSM(name="test", desc="test\non\nseveral lines") test_obj_1.stator = LamSlotWind(L1=0.45) test_obj_1.stator.slot = SlotW10(Zs=10, H0=0.21, W0=0.23) test_obj_1.stator.winding = WindingDW1L(qs=5) test_obj_1.rotor = LamSlotMag(L1=0.55) test_obj_1.rotor.slot = SlotMPolar(W0=pi / 4) test_obj_1.rotor.slot.magnet = [MagnetType11(Wmag=pi / 4, Hmag=3)] test_obj_1.shaft = Shaft(Lshaft=0.65) test_obj_1.frame = None test_obj_2 = LamSlotWind(L1=0.45) test_obj_3 = {"H0": 0.001, "Zs": 10, "__class__": "ClassDoesntExist"} test_obj_4 = tuple([1, 2, 3]) test_dict = { "tuple": test_obj_4, "list": [test_obj_1, None], "dict": {"test_obj_2": test_obj_2, "test_obj_list": [test_obj_3, None]}, } # Save Test file_path = join(save_path, "test_dict.json") if isfile(file_path): remove(file_path) self.assertFalse(isfile(file_path)) save_data(test_dict, file_path) self.assertTrue(isfile(file_path)) # Load Test result_dict = load_dict(file_path) # set tuple to None as save will do test_dict["tuple"] = None self.assertEqual(result_dict, test_dict)
def setUp(self): """Run at the begining of every test to setup the gui""" self.test_obj = MachineSCIM() self.test_obj.stator = LamSlotWind(Rint=0.1, Rext=0.2) self.test_obj.stator.slot = SlotW10( Zs=123, H0=0.10, H1=0.11, H2=0.12, W0=0.13, W1=0.14, W2=0.15, H1_is_rad=False, ) self.widget = SWSlot(self.test_obj, matlib=[], is_stator=True)
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.9, Nrvd=1, Wrvd=0.1, ) self.test_obj.slot = SlotW25(Zs=12, W4=150e-3, W3=75e-3, H1=30e-3, H2=150e-3) self.widget = PWSlot25(self.test_obj) self.assertEqual( self.widget.w_out.out_slot_height.text(), "Slot height: 0.1789 m" )