Esempio n. 1
0
    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)
Esempio n. 2
0
    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")
Esempio n. 3
0
    def test_init_SyRM_51(self):
        """Check that the Widget initialize to the correct hole"""

        self.test_obj2.rotor.hole = list()
        self.test_obj2.rotor.hole.append(
            HoleM51(
                Zh=16,
                W0=0.11,
                W1=0.12,
                W2=0.13,
                W3=0.14,
                W4=0.15,
                W5=0.16,
                W6=0.17,
                W7=0.18,
                H0=0.19,
                H1=0.2,
                H2=0.21,
            ))
        self.test_obj2.rotor.hole[0].remove_magnet()
        self.widget2 = SMHoleMag(machine=self.test_obj2,
                                 matlib=self.matlib,
                                 is_stator=False)

        self.assertEqual(self.widget2.out_hole_pitch.text(),
                         "Slot pitch = 360 / 2p = 22.5 °")
        self.assertEqual(self.widget2.tab_hole.count(), 1)
        self.assertEqual(
            self.widget2.tab_hole.widget(0).c_hole_type.currentIndex(), 1)
        self.assertEqual(
            self.widget2.tab_hole.widget(0).c_hole_type.currentText(),
            "Slot Type 51")
        self.assertEqual(
            self.widget2.tab_hole.widget(0).c_hole_type.count(), 5)

        self.assertEqual(
            self.widget2.tab_hole.widget(0).w_hole.lf_W0.text(), "0.11")
        self.assertEqual(
            self.widget2.tab_hole.widget(0).w_hole.lf_W1.text(), "0.12")
        self.assertEqual(
            self.widget2.tab_hole.widget(0).w_hole.lf_W2.text(), "0")
        self.assertEqual(
            self.widget2.tab_hole.widget(0).w_hole.lf_W3.text(), "0")
        self.assertEqual(
            self.widget2.tab_hole.widget(0).w_hole.lf_W4.text(), "0")
        self.assertEqual(
            self.widget2.tab_hole.widget(0).w_hole.lf_W5.text(), "0")
        self.assertEqual(
            self.widget2.tab_hole.widget(0).w_hole.lf_W6.text(), "0")
        self.assertEqual(
            self.widget2.tab_hole.widget(0).w_hole.lf_W7.text(), "0")
        self.assertEqual(
            self.widget2.tab_hole.widget(0).w_hole.lf_H0.text(), "0.19")
        self.assertEqual(
            self.widget2.tab_hole.widget(0).w_hole.lf_H1.text(), "0.2")
        self.assertEqual(
            self.widget2.tab_hole.widget(0).w_hole.lf_H2.text(), "0.21")
Esempio n. 4
0
 def test_init_53(self):
     """Check that you can edit a hole 53"""
     self.test_obj.rotor.hole[0] = HoleM53(Zh=11)
     self.test_obj.rotor.hole[0].magnet_0.mat_type.name = "Magnet1"
     self.widget = SMHoleMag(machine=self.test_obj,
                             matlib=self.matlib,
                             is_stator=False)
     self.assertEqual(self.widget.out_hole_pitch.text(),
                      "Slot pitch = 360 / 2p = 32.73 °")
     self.assertEqual(
         self.widget.tab_hole.widget(0).c_hole_type.currentIndex(), 3)
     self.assertEqual(
         self.widget.tab_hole.widget(0).c_hole_type.currentText(),
         "Slot Type 53")
Esempio n. 5
0
    def test_init(self):
        """Check that the Widget spinbox initialise to the lamination value
        """
        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.widget = SMHoleMag(machine=self.machine,
                                matlib=self.matlib,
                                is_stator=False)

        # Check default (hole is set to type 50)
        self.assertEqual(self.widget.w_mat.c_mat_type.count(), 4)
        self.assertEqual(self.widget.w_mat.c_mat_type.currentText(), "Magnet1")
        self.assertEqual(self.widget.w_mat.c_mat_type.currentIndex(), 3)
        # 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(),
            "004 - Magnet1")
        # Duplicate Magnet1
        self.assertFalse(hasattr(self.widget.w_mat.mat_win, "mat_win"))
        self.widget.w_mat.mat_win.b_duplicate.clicked.emit()
        self.assertEqual(type(self.widget.w_mat.mat_win.mat_win), DMatSetup)
        # Edit Magnet1 to Magnet_test
        self.widget.w_mat.mat_win.mat_win.le_name.setText("Magnet_test_python")
        self.widget.w_mat.mat_win.mat_win.le_name.editingFinished.emit()
        self.assertEqual(self.widget.w_mat.mat_win.mat_win.mat.name,
                         "Magnet_test_python")

        self.widget.w_mat.mat_win.mat_win.lf_rho_elec.setText("1234.56789")
        self.widget.w_mat.mat_win.mat_win.lf_rho_elec.editingFinished.emit()
        self.assertEqual(self.widget.w_mat.mat_win.mat_win.mat.elec.rho,
                         1234.56789)