def s_add(self, hole=False): """Signal to add a new hole Parameters ---------- self : SMHoleMag a SMHoleMag object hole : HoleMag hole to initialize in the new page if None create a new empty HoleM50 """ # Adapt the GUI according to the machine type if self.machine.type_machine == 5: # SyRM is_mag = False else: is_mag = True # Create a new hole if needed if type(hole) is bool: self.obj.hole.append(HoleM50()) hole = self.obj.hole[-1] hole._set_None() hole_index = len(self.obj.hole) - 1 if self.machine.type_machine == 5: hole.remove_magnet() else: hole.magnet_0 = self.obj.hole[0].magnet_0 hole.Zh = self.obj.hole[0].Zh else: hole_index = self.obj.hole.index(hole) tab = WHoleMag(self.obj, is_mag=is_mag, index=hole_index) tab.saveNeeded.connect(self.emit_save) self.tab_hole.addTab(tab, "Slot " + str(hole_index + 1))
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 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 gui""" self.test_obj = LamHole(Rint=0.1, Rext=0.2) self.test_obj.hole = list() self.test_obj.hole.append( HoleM50( H0=0.10, H1=0.11, H2=0.12, W0=0.13, W1=0.14, W2=0.15, H3=0.16, W3=0.17, H4=0.18, W4=0.19, ) ) self.test_obj.hole[0].magnet_0.mat_type.name = "Magnet3" self.test_obj.hole[0].magnet_1.mat_type.name = "Magnet2" self.matlib = list() self.matlib.append(Material(name="Magnet1")) self.matlib.append(Material(name="Magnet2")) self.matlib.append(Material(name="Magnet3")) self.widget = PHoleM50(self.test_obj.hole[0], self.matlib)
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_build_geometry_one_hole_no_mag(self): """check that curve_list is correct (one hole no mag) """ test_obj = LamHole(is_internal=True, Rext=0.075) test_obj.hole = list() test_obj.hole.append( HoleM50( Zh=8, W0=52e-3, W1=0, W2=1e-3, W3=1e-3, W4=20.6e-3, H0=17.3e-3, H1=1.25e-3, H2=0.5e-3, H3=6.8e-3, H4=0, magnet_0=None, magnet_1=None, ) ) result = test_obj.hole[0].build_geometry() self.assertEqual(len(result), 1) for surf in result: self.assertTrue(type(surf) is SurfLine) self.assertEqual(result[0].label[:4], "Hole") self.assertEqual(result[0].label[-9:], "_R0_T0_S0") self.assertEqual(len(result[0].line_list), 16)
def test_build_geometry_two_hole_no_mag(self): """check that curve_list is correct (two holes no magnet) """ test_obj = LamHole(is_internal=True, Rext=0.075) test_obj.hole = list() test_obj.hole.append( HoleM50( Zh=8, W0=50e-3, W1=2e-3, W2=1e-3, W3=1e-3, W4=20.6e-3, H0=17.3e-3, H1=1.25e-3, H2=0.5e-3, H3=6.8e-3, H4=1e-3, magnet_0=None, magnet_1=None, )) result = test_obj.hole[0].build_geometry() self.assertEqual(len(result), 2) for surf in result: self.assertTrue(type(surf) is SurfLine) self.assertEqual(result[0].label, "Air") self.assertEquals(len(result[0].line_list), 11) self.assertEqual(result[1].label, "Air") self.assertEquals(len(result[1].line_list), 11)
def __init__(self, machine, matlib=[], is_stator=False): """Initialize the widget according to machine Parameters ---------- self : SMHoleMag A SMHoleMag widget machine : Machine current machine to edit matlib : list List of available Material is_stator : bool To adapt the GUI to set either the stator or the rotor """ # Build the interface according to the .ui file QWidget.__init__(self) self.setupUi(self) # Saving arguments self.machine = machine self.matlib = matlib self.is_stator = is_stator # Get the correct object to set if self.is_stator: self.obj = machine.stator else: self.obj = machine.rotor # If the hole is not set, initialize it with a HoleM50 if len(self.obj.hole) == 0: self.obj.hole.append(HoleM50()) if self.machine.type_machine == 5: # SyRM self.obj.hole[0].remove_magnet() self.obj.hole[0]._set_None() self.obj.hole[0].Zh = machine.stator.winding.p * 2 # Default value self.set_hole_pitch(self.obj.hole[0].Zh) # Update all the hole tab # (the current hole types will be initialized) # print(type(self.obj.hole[0]).__name__) self.tab_hole.clear() for hole in self.obj.hole: self.s_add(hole) self.tab_hole.setCurrentIndex(0) # Set Help URL self.b_help.url = "https://eomys.com/produits/manatee/howtos/article/" self.b_help.url += "how-to-set-up-the-slots" # Connect the slot self.b_add.clicked.connect(self.s_add) self.b_remove.clicked.connect(self.s_remove) self.b_plot.clicked.connect(self.s_plot)
def test_build_geometry_two_hole_with_magnet(self): """check that curve_list is correct (one hole) """ test_obj = LamHole(is_internal=True, is_stator=False, Rext=0.075) test_obj.hole = list() test_obj.hole.append( HoleM50( Zh=8, W0=50e-3, W1=2e-3, W2=1e-3, W3=1e-3, W4=20.6e-3, H0=17.3e-3, H1=1.25e-3, H2=0.5e-3, H3=6.8e-3, H4=1e-3, magnet_0=MagnetType10(Wmag=0.01, Hmag=0.02), ) ) result = test_obj.hole[0].build_geometry() self.assertEqual(len(result), 6) for surf in result: self.assertTrue(type(surf) is SurfLine) self.assertEqual(result[0].label[:5], "Hole_") self.assertEqual(result[0].label[-9:], "_R0_T0_S0") self.assertEqual(len(result[0].line_list), 7) self.assertEqual(result[1].label[:11], "HoleMagnet_") self.assertEqual(result[1].label[-11:], "_N_R0_T0_S0") self.assertEqual(len(result[1].line_list), 6) self.assertEqual(result[2].label[:5], "Hole_") self.assertEqual(result[2].label[-9:], "_R0_T1_S0") self.assertEqual(len(result[2].line_list), 4) self.assertEqual(result[3].label[:5], "Hole_") self.assertEqual(result[3].label[-9:], "_R0_T2_S0") self.assertEqual(len(result[3].line_list), 4) self.assertEqual(result[4].label[:11], "HoleMagnet_") self.assertEqual(result[4].label[-11:], "_N_R0_T1_S0") self.assertEqual(len(result[4].line_list), 6) self.assertEqual(result[5].label[:5], "Hole_") self.assertEqual(result[5].label[-9:], "_R0_T3_S0") self.assertEqual(len(result[5].line_list), 7)
def setUp(self): """Run at the begining of every test to setup the machine""" plt.close("all") test_obj = Machine() test_obj.rotor = LamHole(is_internal=True, Rint=0.021, Rext=0.075, is_stator=False, L1=0.7) test_obj.rotor.hole = list() test_obj.rotor.hole.append( HoleM50( Zh=8, W0=50e-3, W1=2e-3, W2=1e-3, W3=1e-3, W4=20.6e-3, H0=17.3e-3, H1=1.25e-3, H2=0.5e-3, H3=6.8e-3, H4=0, )) test_obj.rotor.axial_vent = list() test_obj.rotor.axial_vent.append( VentilationCirc(Zh=8, Alpha0=0, D0=5e-3, H0=40e-3)) test_obj.rotor.axial_vent.append( VentilationCirc(Zh=8, Alpha0=pi / 8, D0=7e-3, H0=40e-3)) test_obj.rotor.mat_type.magnetics = MatLamination(Wlam=0.5e-3) test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=1.2) test_obj.stator = Lamination(Rint=0.078, Rext=0.104, is_internal=False, is_stator=True, L1=0.8) test_obj.stator.axial_vent.append( VentilationPolar(Zh=8, H0=0.08, D0=0.01, W1=pi / 8, Alpha0=pi / 8)) test_obj.stator.axial_vent.append( VentilationPolar(Zh=8, H0=0.092, D0=0.01, W1=pi / 8, Alpha0=0)) test_obj.stator.mat_type.magnetics = MatLamination(Wlam=0.5e-3) test_obj.frame = Frame(Rint=0.104, Rext=0.114, Lfra=1) self.test_obj = test_obj
def setUp(self): """Run at the begining of every test to setup the gui""" self.test_obj = LamHole(Rint=0.1, Rext=0.2) self.test_obj.hole = list() self.test_obj.hole.append( HoleM50( H0=0.10, H1=0.11, H2=0.12, W0=0.13, W1=0.14, W2=0.15, H3=0.16, W3=0.17, H4=0.18, W4=0.19, )) self.widget = PHoleM50(self.test_obj.hole[0])
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_H1.value(), 0.11) self.assertEqual(self.widget.lf_H2.value(), 0.12) self.assertEqual(self.widget.lf_W0.value(), 0.13) self.assertEqual(self.widget.lf_W1.value(), 0.14) self.assertEqual(self.widget.lf_W2.value(), 0.15) self.assertEqual(self.widget.lf_H3.value(), 0.16) self.assertEqual(self.widget.lf_W3.value(), 0.17) self.assertEqual(self.widget.lf_H4.value(), 0.18) self.assertEqual(self.widget.lf_W4.value(), 0.19) # Check material self.assertFalse(self.widget.w_mat_0.isHidden()) self.assertEqual(self.widget.w_mat_0.c_mat_type.currentText(), "Magnet3") self.assertEqual(self.widget.w_mat_0.c_mat_type.currentIndex(), 2) self.assertFalse(self.widget.w_mat_1.isHidden()) self.assertEqual(self.widget.w_mat_1.c_mat_type.currentText(), "Magnet2") self.assertEqual(self.widget.w_mat_1.c_mat_type.currentIndex(), 1) self.test_obj.hole[0] = HoleM50( H0=0.20, H1=0.21, H2=0.22, W0=0.23, W1=0.24, W2=0.25, H3=0.26, W3=0.27, H4=0.28, W4=0.29, ) self.widget = PHoleM50(self.test_obj.hole[0]) self.assertEqual(self.widget.lf_H0.value(), 0.20) self.assertEqual(self.widget.lf_H1.value(), 0.21) self.assertEqual(self.widget.lf_H2.value(), 0.22) self.assertEqual(self.widget.lf_W0.value(), 0.23) self.assertEqual(self.widget.lf_W1.value(), 0.24) self.assertEqual(self.widget.lf_W2.value(), 0.25) self.assertEqual(self.widget.lf_H3.value(), 0.26) self.assertEqual(self.widget.lf_W3.value(), 0.27) self.assertEqual(self.widget.lf_H4.value(), 0.28) self.assertEqual(self.widget.lf_W4.value(), 0.29)
def test_build_geometry_one_hole_with_magnet(self): """check that curve_list is correct (one hole) """ test_obj = LamHole(is_internal=True, Rext=0.075) test_obj.hole = list() test_obj.hole.append( HoleM50( Zh=8, W0=52e-3, W1=0, W2=1e-3, W3=1e-3, W4=20.6e-3, H0=17.3e-3, H1=1.25e-3, H2=0.5e-3, H3=6.8e-3, H4=0, magnet_0=MagnetType10(Wmag=0.01, Hmag=0.02), )) result = test_obj.hole[0].build_geometry() self.assertEqual(len(result), 5) for surf in result: self.assertTrue(type(surf) is SurfLine) self.assertEqual(result[0].label, "Air") self.assertEquals(len(result[0].line_list), 5) self.assertEqual(result[1].label, "MagnetS_N_R0_T0_S0") self.assertEquals(len(result[1].line_list), 6) self.assertEqual(result[2].label, "Air") self.assertEquals(len(result[2].line_list), 6) self.assertEqual(result[3].label, "MagnetS_N_R0_T1_S0") self.assertEquals(len(result[3].line_list), 6) self.assertEqual(result[4].label, "Air") self.assertEquals(len(result[4].line_list), 5)
def test_comp_surface(self): """Check that the computation of the slot surface is correct """ test_obj = LamHole(is_internal=True, Rext=0.075) test_obj.hole = list() test_obj.hole.append( HoleM50( Zh=8, W0=50e-3, W1=2e-3, W2=1e-3, W3=1e-3, W4=20.6e-3, H0=17.3e-3, H1=1.25e-3, H2=0.5e-3, H3=6.8e-3, )) result = test_obj.hole[0].comp_surface() a = result b = 3.77977e-04 self.assertAlmostEqual((a - b) / a, 0, delta=DELTA)
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_H1.value(), 0.11) self.assertEqual(self.widget.lf_H2.value(), 0.12) self.assertEqual(self.widget.lf_W0.value(), 0.13) self.assertEqual(self.widget.lf_W1.value(), 0.14) self.assertEqual(self.widget.lf_W2.value(), 0.15) self.assertEqual(self.widget.lf_H3.value(), 0.16) self.assertEqual(self.widget.lf_W3.value(), 0.17) self.assertEqual(self.widget.lf_H4.value(), 0.18) self.assertEqual(self.widget.lf_W4.value(), 0.19) self.test_obj.hole[0] = HoleM50( H0=0.20, H1=0.21, H2=0.22, W0=0.23, W1=0.24, W2=0.25, H3=0.26, W3=0.27, H4=0.28, W4=0.29, ) self.widget = PHoleM50(self.test_obj.hole[0]) self.assertEqual(self.widget.lf_H0.value(), 0.20) self.assertEqual(self.widget.lf_H1.value(), 0.21) self.assertEqual(self.widget.lf_H2.value(), 0.22) self.assertEqual(self.widget.lf_W0.value(), 0.23) self.assertEqual(self.widget.lf_W1.value(), 0.24) self.assertEqual(self.widget.lf_W2.value(), 0.25) self.assertEqual(self.widget.lf_H3.value(), 0.26) self.assertEqual(self.widget.lf_W3.value(), 0.27) self.assertEqual(self.widget.lf_H4.value(), 0.28) self.assertEqual(self.widget.lf_W4.value(), 0.29)
# Rotor setup rotor = LamHole(Rint=59 * mm / 2, Rext=158 * mm / 2, is_internal=True, is_stator=False, L1=stator.L1) rotor.hole = list() rotor.hole.append( HoleM50( Zh=8, W0=43.4 * mm, W1=3.0 * mm, W2=1.0 * mm, W3=10.0 * mm, W4=22.0 * mm, H0=20.0 * mm, H1=2.0 * mm, H2=2.5 * mm, H3=6.0 * mm, H4=0.8 * mm, )) """ rotor.axial_vent = list() rotor.axial_vent.append(VentilationCirc( Zh=8, Alpha0=0, D0=5e-3, H0=40e-3 )) rotor.axial_vent.append(VentilationCirc(
test_obj.rotor = LamHole(is_internal=True, Rint=0.021, Rext=0.075, is_stator=False, L1=0.7, Nrvd=0, Kf1=0.95) test_obj.rotor.hole = list() test_obj.rotor.hole.append( HoleM50( Zh=8, W0=50e-3, W1=2e-3, W2=1e-3, W3=1e-3, W4=20.6e-3, H0=17.3e-3, H1=1.25e-3, H2=0.5e-3, H3=6.8e-3, H4=0, )) test_obj.rotor.hole[0].magnet_0.Lmag = 0.3 test_obj.rotor.hole[0].magnet_1.Lmag = 0.5 test_obj.rotor.hole[0].magnet_0.mat_type.struct.rho = 1000 test_obj.rotor.hole[0].magnet_1.mat_type.struct.rho = 1000 test_obj.rotor.axial_vent = list() test_obj.rotor.axial_vent.append( VentilationCirc(Zh=8, Alpha0=0, D0=5e-3, H0=40e-3)) test_obj.rotor.axial_vent.append( VentilationCirc(Zh=8, Alpha0=pi / 8, D0=7e-3, H0=40e-3))
Rext=80.2e-3, Rint=55.32e-3, L1=0.08382, Kf1=0.95, is_internal=True, is_stator=False, Nrvd=0, ) rotor.hole = [ HoleM50( Zh=8, H0=0.01096, H1=0.0015, H2=0.001, H3=0.0065, H4=0, W0=0.042, W1=0, W2=0, W3=0.014, W4=0.0189, ) ] rotor.hole[0].magnet_0.type_magnetization = 1 rotor.hole[0].magnet_1.type_magnetization = 1 shaft = Shaft(Lshaft=0.1, Drsh=0.11064) frame = None # Set Materials stator.mat_type = M400_50A rotor.mat_type = M400_50A
machine4 = MachineDFIM() machine4.stator = LamSlotWind() machine4.stator.winding = WindingDW2L() machine4.rotor = LamSlotWind() machine4.rotor.winding = WindingDW2L() machine4._set_None() # Empty machine machine4.type_machine = 4 machine4.stator.is_stator = True machine4.rotor.is_stator = False machine5 = MachineSyRM() machine5.stator = LamSlotWind() machine5.stator.winding = WindingDW2L() machine5.rotor = LamHole() machine5.rotor.hole = list() machine5.rotor.hole.append(HoleM50()) machine5.rotor.hole[0].remove_magnet() machine5._set_None() # Empty machine machine5.type_machine = 5 machine5.stator.is_stator = True machine5.rotor.is_stator = False machine6 = MachineSIPMSM() machine6.stator = LamSlotWind() machine6.stator.winding = WindingDW2L() machine6.rotor = LamSlotMag() machine6.rotor.slot = SlotMPolar() machine6.rotor.slot.magnet = [MagnetType11()] machine6._set_None() # Empty machine machine6.type_machine = 6 machine6.stator.is_stator = True