Esempio n. 1
0
    def __init__(
        self,
        frame=-1,
        shaft=-1,
        name="default_machine",
        desc="",
        type_machine=1,
        init_dict=None,
    ):
        """Constructor of the class. Can be use in two ways :
        - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values
            for Matrix, None will initialise the property with an empty Matrix
            for pyleecan type, None will call the default constructor
        - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys

        ndarray or list can be given for Vector and Matrix
        object or dict can be given for pyleecan Object"""

        if frame == -1:
            frame = Frame()
        if shaft == -1:
            shaft = Shaft()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(init_dict,
                            ["frame", "shaft", "name", "desc", "type_machine"])
            # Overwrite default value with init_dict content
            if "frame" in list(init_dict.keys()):
                frame = init_dict["frame"]
            if "shaft" in list(init_dict.keys()):
                shaft = init_dict["shaft"]
            if "name" in list(init_dict.keys()):
                name = init_dict["name"]
            if "desc" in list(init_dict.keys()):
                desc = init_dict["desc"]
            if "type_machine" in list(init_dict.keys()):
                type_machine = init_dict["type_machine"]
        # Initialisation by argument
        self.parent = None
        # frame can be None, a Frame object or a dict
        if isinstance(frame, dict):
            self.frame = Frame(init_dict=frame)
        else:
            self.frame = frame
        # shaft can be None, a Shaft object or a dict
        if isinstance(shaft, dict):
            self.shaft = Shaft(init_dict=shaft)
        else:
            self.shaft = shaft
        self.name = name
        self.desc = desc
        self.type_machine = type_machine

        # The class is frozen, for now it's impossible to add new properties
        self._freeze()
Esempio n. 2
0
    def test_Lam_Mag_11_surface(self):
        """Test machine plot with Magnet 11 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.45,
            Nrvd=1,
            Wrvd=0.05,
        )
        magnet = [MagnetType11(Lmag=0.5, Hmag=0.01, Wmag=pi / 8)]
        test_obj.rotor.slot = SlotMPolar(Zs=8, W0=pi / 8, 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 = LamSlotMag(
            Rint=115e-3,
            Rext=200e-3,
            is_internal=False,
            is_stator=True,
            L1=0.45,
            Nrvd=1,
            Wrvd=0.05,
        )
        magnet2 = [MagnetType11(Lmag=0.5, Hmag=0.01, Wmag=pi / 4)]
        test_obj.stator.slot = SlotMPolar(Zs=4, W0=pi / 4, magnet=magnet2)
        test_obj.stator.mat_type.magnetics = MatLamination(Wlam=0.5e-3)
        test_obj.frame = Frame(Rint=200e-3, Rext=200e-3, Lfra=0.5)

        test_obj.plot()
        fig = plt.gcf()
        self.assertEqual(len(fig.axes[0].patches), 17)
        fig.savefig(join(save_path, "test_Lam_Mag_11s_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_11s_2-Rotor.png"))

        test_obj.stator.plot()
        fig = plt.gcf()
        patches = fig.axes[0].patches
        self.assertEqual(len(patches), 6)
        self.assertTrue(isinstance(patches[0], Circle))
        self.assertEqual(patches[0].get_radius(), 200e-3)
        self.assertEqual(patches[0].get_facecolor(),
                         (0.0, 0.0, 1.0, 1.0))  # Blue
        for i in range(1, 6):
            self.assertTrue(isinstance(patches[i], Polygon))
            if i == 1:  # Lamination inner
                self.assertEqual(patches[i].get_facecolor(),
                                 (1.0, 1.0, 1.0, 1.0))  # White
            else:  # Magnet
                self.assertEqual(patches[i].get_facecolor(),
                                 (0.75, 0.75, 0.75, 1.0))  # Gray
        fig.savefig(join(save_path, "test_Lam_Mag_11s_3-Stator.png"))
Esempio n. 3
0
    def setUp(self):
        """Run at the begining of every test to setup the machine"""
        plt.close("all")
        test_obj = Machine()
        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 = Lamination(Rint=0.09,
                                     Rext=0.12,
                                     is_internal=False,
                                     is_stator=True,
                                     L1=0.9)
        test_obj.frame = Frame(Rint=0.12, Rext=0.12, Lfra=0.7)
        self.test_obj = test_obj
Esempio n. 4
0
    def __init__(
        self,
        rotor=-1,
        stator=-1,
        frame=-1,
        shaft=-1,
        name="default_machine",
        desc="",
        type_machine=1,
        init_dict=None,
    ):
        """Constructor of the class. Can be use in two ways :
        - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values
            for Matrix, None will initialise the property with an empty Matrix
            for pyleecan type, None will call the default constructor
        - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys

        ndarray or list can be given for Vector and Matrix
        object or dict can be given for pyleecan Object"""

        if rotor == -1:
            rotor = Lamination()
        if stator == -1:
            stator = Lamination()
        if frame == -1:
            frame = Frame()
        if shaft == -1:
            shaft = Shaft()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                ["rotor", "stator", "frame", "shaft", "name", "desc", "type_machine"],
            )
            # Overwrite default value with init_dict content
            if "rotor" in list(init_dict.keys()):
                rotor = init_dict["rotor"]
            if "stator" in list(init_dict.keys()):
                stator = init_dict["stator"]
            if "frame" in list(init_dict.keys()):
                frame = init_dict["frame"]
            if "shaft" in list(init_dict.keys()):
                shaft = init_dict["shaft"]
            if "name" in list(init_dict.keys()):
                name = init_dict["name"]
            if "desc" in list(init_dict.keys()):
                desc = init_dict["desc"]
            if "type_machine" in list(init_dict.keys()):
                type_machine = init_dict["type_machine"]
        # Initialisation by argument
        # Call MachineDFIM init
        super(MachineSCIM, self).__init__(
            rotor=rotor,
            stator=stator,
            frame=frame,
            shaft=shaft,
            name=name,
            desc=desc,
            type_machine=type_machine,
        )
Esempio n. 5
0
    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)
Esempio n. 6
0
    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)
Esempio n. 7
0
    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_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 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_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)
Esempio n. 11
0
    def test_init_no_shaft(self):
        """Check that the Widget spinbox initialise to the lamination value"""

        self.test_obj.shaft = None
        self.widget = SMachineDimension(machine=self.test_obj,
                                        matlib=[],
                                        is_stator=False)
        self.assertEqual(self.widget.g_shaft.isChecked(), False)

        self.test_obj.shaft = Shaft(Drsh=None)
        self.widget = SMachineDimension(machine=self.test_obj,
                                        matlib=[],
                                        is_stator=False)
        self.assertEqual(self.widget.g_shaft.isChecked(), False)

        self.test_obj.shaft = Shaft(Drsh=0)
        self.widget = SMachineDimension(machine=self.test_obj,
                                        matlib=[],
                                        is_stator=False)
        self.assertEqual(self.widget.g_shaft.isChecked(), False)
    def test_Lam_Mag_14_inset(self):
        """Test machine plot with Magnet 14 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.4,
            Nrvd=5,
            Wrvd=0.02,
        )
        magnet = [MagnetType14(Lmag=0.5, Hmag=0.02, Wmag=0.628, Rtop=0.04)]
        test_obj.rotor.slot = SlotMPolar(Zs=4,
                                         W0=0.628,
                                         H0=0.02,
                                         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.4,
            Nrvd=5,
            Wrvd=0.02,
        )
        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_14i_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_14i_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_14i_3-Stator.png"))
    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
Esempio n. 14
0
    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)
Esempio n. 15
0
    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(
            HoleM52(Zh=8, W0=27e-3, W3=16.2e-3, H0=1e-3, H1=5e-3, H2=1e-3)
        )
        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
Esempio n. 16
0
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)
Esempio n. 17
0
class Machine(FrozenClass):
    """Abstract class for machines"""

    VERSION = 1

    # cf Methods.Machine.Machine.build_geometry
    build_geometry = build_geometry
    # cf Methods.Machine.Machine.check
    check = check
    # cf Methods.Machine.Machine.comp_masses
    comp_masses = comp_masses
    # cf Methods.Machine.Machine.comp_width_airgap_mag
    comp_width_airgap_mag = comp_width_airgap_mag
    # cf Methods.Machine.Machine.comp_width_airgap_mec
    comp_width_airgap_mec = comp_width_airgap_mec
    # cf Methods.Machine.Machine.get_lamination
    get_lamination = get_lamination
    # cf Methods.Machine.Machine.comp_Rgap_mec
    comp_Rgap_mec = comp_Rgap_mec
    # cf Methods.Machine.Machine.plot
    plot = plot
    # cf Methods.Machine.Machine.comp_output_geo
    comp_output_geo = comp_output_geo
    # cf Methods.Machine.Machine.comp_length_airgap_active
    comp_length_airgap_active = comp_length_airgap_active
    # cf Methods.Machine.Machine.get_polar_eq
    get_polar_eq = get_polar_eq
    # save method is available in all object
    save = save

    def __init__(
        self,
        rotor=-1,
        stator=-1,
        frame=-1,
        shaft=-1,
        name="default_machine",
        desc="",
        init_dict=None,
    ):
        """Constructor of the class. Can be use in two ways :
        - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values
            for Matrix, None will initialise the property with an empty Matrix
            for pyleecan type, None will call the default constructor
        - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys

        ndarray or list can be given for Vector and Matrix
        object or dict can be given for pyleecan Object"""

        if rotor == -1:
            rotor = Lamination()
        if stator == -1:
            stator = Lamination()
        if frame == -1:
            frame = Frame()
        if shaft == -1:
            shaft = Shaft()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                ["rotor", "stator", "frame", "shaft", "name", "desc"])
            # Overwrite default value with init_dict content
            if "rotor" in list(init_dict.keys()):
                rotor = init_dict["rotor"]
            if "stator" in list(init_dict.keys()):
                stator = init_dict["stator"]
            if "frame" in list(init_dict.keys()):
                frame = init_dict["frame"]
            if "shaft" in list(init_dict.keys()):
                shaft = init_dict["shaft"]
            if "name" in list(init_dict.keys()):
                name = init_dict["name"]
            if "desc" in list(init_dict.keys()):
                desc = init_dict["desc"]
        # Initialisation by argument
        self.parent = None
        # rotor can be None, a Lamination object or a dict
        if isinstance(rotor, dict):
            # Call the correct constructor according to the dict
            load_dict = {
                "LamHole": LamHole,
                "LamSlot": LamSlot,
                "LamSlotWind": LamSlotWind,
                "LamSlotMag": LamSlotMag,
                "LamSquirrelCage": LamSquirrelCage,
                "Lamination": Lamination,
            }
            obj_class = rotor.get("__class__")
            if obj_class is None:
                self.rotor = Lamination(init_dict=rotor)
            elif obj_class in list(load_dict.keys()):
                self.rotor = load_dict[obj_class](init_dict=rotor)
            else:  # Avoid generation error or wrong modification in json
                raise InitUnKnowClassError(
                    "Unknow class name in init_dict for rotor")
        else:
            self.rotor = rotor
        # stator can be None, a Lamination object or a dict
        if isinstance(stator, dict):
            # Call the correct constructor according to the dict
            load_dict = {
                "LamHole": LamHole,
                "LamSlot": LamSlot,
                "LamSlotWind": LamSlotWind,
                "LamSlotMag": LamSlotMag,
                "LamSquirrelCage": LamSquirrelCage,
                "Lamination": Lamination,
            }
            obj_class = stator.get("__class__")
            if obj_class is None:
                self.stator = Lamination(init_dict=stator)
            elif obj_class in list(load_dict.keys()):
                self.stator = load_dict[obj_class](init_dict=stator)
            else:  # Avoid generation error or wrong modification in json
                raise InitUnKnowClassError(
                    "Unknow class name in init_dict for stator")
        else:
            self.stator = stator
        # frame can be None, a Frame object or a dict
        if isinstance(frame, dict):
            self.frame = Frame(init_dict=frame)
        else:
            self.frame = frame
        # shaft can be None, a Shaft object or a dict
        if isinstance(shaft, dict):
            self.shaft = Shaft(init_dict=shaft)
        else:
            self.shaft = shaft
        self.name = name
        self.desc = desc

        # The class is frozen, for now it's impossible to add new properties
        self._freeze()

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        Machine_str = ""
        if self.parent is None:
            Machine_str += "parent = None " + linesep
        else:
            Machine_str += "parent = " + str(type(
                self.parent)) + " object" + linesep
        Machine_str += "rotor = " + str(
            self.rotor.as_dict()) + linesep + linesep
        Machine_str += "stator = " + str(
            self.stator.as_dict()) + linesep + linesep
        Machine_str += "frame = " + str(
            self.frame.as_dict()) + linesep + linesep
        Machine_str += "shaft = " + str(
            self.shaft.as_dict()) + linesep + linesep
        Machine_str += 'name = "' + str(self.name) + '"' + linesep
        Machine_str += 'desc = "' + str(self.desc) + '"'
        return Machine_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False
        if other.rotor != self.rotor:
            return False
        if other.stator != self.stator:
            return False
        if other.frame != self.frame:
            return False
        if other.shaft != self.shaft:
            return False
        if other.name != self.name:
            return False
        if other.desc != self.desc:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        Machine_dict = dict()
        if self.rotor is None:
            Machine_dict["rotor"] = None
        else:
            Machine_dict["rotor"] = self.rotor.as_dict()
        if self.stator is None:
            Machine_dict["stator"] = None
        else:
            Machine_dict["stator"] = self.stator.as_dict()
        if self.frame is None:
            Machine_dict["frame"] = None
        else:
            Machine_dict["frame"] = self.frame.as_dict()
        if self.shaft is None:
            Machine_dict["shaft"] = None
        else:
            Machine_dict["shaft"] = self.shaft.as_dict()
        Machine_dict["name"] = self.name
        Machine_dict["desc"] = self.desc
        # The class name is added to the dict fordeserialisation purpose
        Machine_dict["__class__"] = "Machine"
        return Machine_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        if self.rotor is not None:
            self.rotor._set_None()
        if self.stator is not None:
            self.stator._set_None()
        if self.frame is not None:
            self.frame._set_None()
        if self.shaft is not None:
            self.shaft._set_None()
        self.name = None
        self.desc = None

    def _get_rotor(self):
        """getter of rotor"""
        return self._rotor

    def _set_rotor(self, value):
        """setter of rotor"""
        check_var("rotor", value, "Lamination")
        self._rotor = value

        if self._rotor is not None:
            self._rotor.parent = self

    # Machine's Rotor
    # Type : Lamination
    rotor = property(fget=_get_rotor,
                     fset=_set_rotor,
                     doc=u"""Machine's Rotor""")

    def _get_stator(self):
        """getter of stator"""
        return self._stator

    def _set_stator(self, value):
        """setter of stator"""
        check_var("stator", value, "Lamination")
        self._stator = value

        if self._stator is not None:
            self._stator.parent = self

    # Machine's Stator
    # Type : Lamination
    stator = property(fget=_get_stator,
                      fset=_set_stator,
                      doc=u"""Machine's Stator""")

    def _get_frame(self):
        """getter of frame"""
        return self._frame

    def _set_frame(self, value):
        """setter of frame"""
        check_var("frame", value, "Frame")
        self._frame = value

        if self._frame is not None:
            self._frame.parent = self

    # Machine's Frame
    # Type : Frame
    frame = property(fget=_get_frame,
                     fset=_set_frame,
                     doc=u"""Machine's Frame""")

    def _get_shaft(self):
        """getter of shaft"""
        return self._shaft

    def _set_shaft(self, value):
        """setter of shaft"""
        check_var("shaft", value, "Shaft")
        self._shaft = value

        if self._shaft is not None:
            self._shaft.parent = self

    # Machine's Shaft
    # Type : Shaft
    shaft = property(fget=_get_shaft,
                     fset=_set_shaft,
                     doc=u"""Machine's Shaft""")

    def _get_name(self):
        """getter of name"""
        return self._name

    def _set_name(self, value):
        """setter of name"""
        check_var("name", value, "str")
        self._name = value

    # Name of the machine
    # Type : str
    name = property(fget=_get_name,
                    fset=_set_name,
                    doc=u"""Name of the machine""")

    def _get_desc(self):
        """getter of desc"""
        return self._desc

    def _set_desc(self, value):
        """setter of desc"""
        check_var("desc", value, "str")
        self._desc = value

    # Machine description
    # Type : str
    desc = property(fget=_get_desc,
                    fset=_set_desc,
                    doc=u"""Machine description""")
    def test_Lam_Wind_10_wind_22(self):
        """Test machine plot with Slot 10 and winding rad=2, tan=2
		"""
        print("\nTest plot Slot 10")
        plt.close("all")
        test_obj = Machine()
        test_obj.rotor = LamSlotWind(
            Rint=0.2,
            Rext=0.5,
            is_internal=True,
            is_stator=False,
            L1=0.95,
            Nrvd=1,
            Wrvd=0.05,
        )
        test_obj.rotor.slot = SlotW10(
            Zs=6,
            W0=50e-3,
            W1=90e-3,
            W2=100e-3,
            H0=20e-3,
            H1=35e-3,
            H2=130e-3,
            H1_is_rad=False,
        )
        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.shaft.mat_type.name = "M270_35A"
        test_obj.shaft.mat_type.magnetics = None

        test_obj.rotor.mat_type.name = "Load_M400"
        test_obj.rotor.mat_type.magnetics = MatLamination(Wlam=0.5e-3)

        test_obj.stator = LamSlotWind(
            Rint=0.51,
            Rext=0.8,
            is_internal=False,
            is_stator=True,
            L1=0.95,
            Nrvd=1,
            Wrvd=0.05,
        )
        test_obj.stator.slot = SlotW10(
            Zs=6,
            W0=50e-3,
            W1=80e-3,
            W2=50e-3,
            H0=15e-3,
            H1=25e-3,
            H2=140e-3,
            H1_is_rad=False,
        )
        test_obj.stator.winding = WindingUD(user_wind_mat=wind_mat,
                                            qs=4,
                                            p=4,
                                            Lewout=60e-3)
        test_obj.stator.mat_type.name = "Param"
        test_obj.stator.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.stator.mat_type.magnetics.BH_curve = BH

        test_obj.frame = Frame(Rint=0.8, Rext=0.9, Lfra=1)
        test_obj.frame.mat_type.name = "M330_35A"

        test_obj.plot()
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Lam_Wind_s10_1-Machine.png"))
        # Rotor + Stator + 2 for frame + 1 for Shaft
        self.assertEqual(len(fig.axes[0].patches), 55)

        test_obj.rotor.plot()
        fig = plt.gcf()
        self.assertEqual(len(fig.axes[0].patches), 26)
        fig.savefig(join(save_path, "test_Lam_Wind_s10_2-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_s10_3-Stator.png"))
        # 2 for lam + Zs*4 for wind
        self.assertEqual(len(fig.axes[0].patches), 26)
Esempio n. 19
0
    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 = MachineDFIM()
        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 = MatMagnetics(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 = MatMagnetics(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)

        tooth = test_obj.rotor.slot.get_surface_tooth()
        tooth.plot(color="r")
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Lam_Wind_s22_Tooth_in.png"))

        tooth = test_obj.stator.slot.get_surface_tooth()
        tooth.plot(color="r")
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Lam_Wind_s22_Tooth_out.png"))
Esempio n. 20
0
    def test_Lam_Wind_23_wind_22(self):
        """Test machine plot with Slot 23 and winding rad=2, tan=2
        """
        print("\nTest plot Slot 23")
        plt.close("all")
        test_obj = Machine()
        test_obj.rotor = LamSlotWind(
            Rint=0,
            Rext=0.5,
            is_internal=True,
            is_stator=False,
            L1=0.9,
            Nrvd=5,
            Wrvd=0.02,
        )
        test_obj.rotor.slot = SlotW23(Zs=6,
                                      W0=50e-3,
                                      W1=90e-3,
                                      W2=100e-3,
                                      H0=20e-3,
                                      H1=35e-3,
                                      H2=130e-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.9,
            Nrvd=5,
            Wrvd=0.02,
        )
        test_obj.stator.slot = SlotW23(Zs=18,
                                       W0=50e-3,
                                       W1=80e-3,
                                       W2=50e-3,
                                       H0=15e-3,
                                       H1=0,
                                       H2=170e-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=1, Lfra=1)

        test_obj.plot()
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Lam_Wind_s23_1-Machine.png"))
        # Rotor + Stator + 2 for frame + 0 shaft
        self.assertEqual(len(fig.axes[0].patches), 65)

        test_obj.rotor.plot()
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Lam_Wind_s23_2-Rotor.png"))
        # 1 for lam + Zs*4 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_s23_3-Stator.png"))
        # 2 for lam + Zs *2 for wind
        self.assertEqual(len(fig.axes[0].patches), 38)
Esempio n. 21
0
    def __init__(
        self,
        rotor=-1,
        stator=-1,
        frame=-1,
        shaft=-1,
        name="default_machine",
        desc="",
        type_machine=1,
        init_dict=None,
    ):
        """Constructor of the class. Can be use in two ways :
        - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values
            for Matrix, None will initialise the property with an empty Matrix
            for pyleecan type, None will call the default constructor
        - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys

        ndarray or list can be given for Vector and Matrix
        object or dict can be given for pyleecan Object"""

        if rotor == -1:
            rotor = LamSlotMag()
        if stator == -1:
            stator = LamSlotWind()
        if frame == -1:
            frame = Frame()
        if shaft == -1:
            shaft = Shaft()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                ["rotor", "stator", "frame", "shaft", "name", "desc", "type_machine"],
            )
            # Overwrite default value with init_dict content
            if "rotor" in list(init_dict.keys()):
                rotor = init_dict["rotor"]
            if "stator" in list(init_dict.keys()):
                stator = init_dict["stator"]
            if "frame" in list(init_dict.keys()):
                frame = init_dict["frame"]
            if "shaft" in list(init_dict.keys()):
                shaft = init_dict["shaft"]
            if "name" in list(init_dict.keys()):
                name = init_dict["name"]
            if "desc" in list(init_dict.keys()):
                desc = init_dict["desc"]
            if "type_machine" in list(init_dict.keys()):
                type_machine = init_dict["type_machine"]
        # Initialisation by argument
        # rotor can be None, a LamSlotMag object or a dict
        if isinstance(rotor, dict):
            self.rotor = LamSlotMag(init_dict=rotor)
        else:
            self.rotor = rotor
        # stator can be None, a LamSlotWind object or a dict
        if isinstance(stator, dict):
            # Check that the type is correct (including daughter)
            class_name = stator.get("__class__")
            if class_name not in ["LamSlotWind", "LamSquirrelCage"]:
                raise InitUnKnowClassError(
                    "Unknow class name " + class_name + " in init_dict for stator"
                )
            # Dynamic import to call the correct constructor
            module = __import__("pyleecan.Classes." + class_name, fromlist=[class_name])
            class_obj = getattr(module, class_name)
            self.stator = class_obj(init_dict=stator)
        else:
            self.stator = stator
        # Call MachineSync init
        super(MachineSIPMSM, self).__init__(
            frame=frame, shaft=shaft, name=name, desc=desc, type_machine=type_machine
        )
Esempio n. 22
0
    def test_Lam_Wind_27_wind_22(self):
        """Test machine plot with Slot 27 and winding rad=2, tan=2
        """
        print("\nTest plot Slot 27")
        plt.close("all")
        test_obj = Machine()
        test_obj.rotor = LamSlotWind(
            Rint=0.2,
            Rext=0.5,
            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=60e-3, H0=0.35)
        ]
        test_obj.rotor.slot = SlotW27(Zs=6,
                                      H0=0.05,
                                      W0=30e-3,
                                      H1=0.125,
                                      W1=0.06,
                                      H2=0.05,
                                      W2=0.09,
                                      W3=0.04)
        test_obj.rotor.mat_type.mag = MatLamination(Wlam=0.5e-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.51,
            Rext=0.8,
            is_internal=False,
            is_stator=True,
            L1=0.9,
            Nrvd=2,
            Wrvd=0.05,
        )
        test_obj.stator.slot = SlotW27(Zs=18,
                                       H0=0.05,
                                       W0=30e-3,
                                       H1=0.07,
                                       W1=0.05,
                                       H2=0.15,
                                       W2=0.1,
                                       W3=0.05)
        test_obj.stator.winding = WindingDW2L(qs=3, p=3)
        test_obj.stator.winding.Lewout = 60e-3
        test_obj.stator.mat_type.mag = MatLamination(Wlam=0.5e-3)
        test_obj.frame = Frame(Rint=0.8, Rext=0.9, Lfra=1)

        test_obj.plot()
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Lam_Wind_s27_1-Machine.png"))
        # Rotor + Stator + 2 for frame + 1 for shaft
        self.assertEqual(len(fig.axes[0].patches), 73)

        test_obj.rotor.plot()
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Lam_Wind_s27_2-Rotor.png"))
        # 2 for lam + 4*Zs for wind + 6 vent
        self.assertEqual(len(fig.axes[0].patches), 32)

        test_obj.stator.plot()
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Lam_Wind_s27_3-Stator.png"))
        # 2 for lam + 2*Zs for wind
        self.assertEqual(len(fig.axes[0].patches), 38)
Esempio n. 23
0
        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
# stator.winding.conductor.cond_mat = Copper1
rotor.hole[0].magnet_0.mat_type = Magnet_prius
rotor.hole[0].magnet_1.mat_type = Magnet_prius

CEFC_Lam = MachineIPMSM(
    name="CEFC_Lam",
    desc="Slotless machine from CEFC publication",
    stator=stator,
    rotor=rotor,
    shaft=shaft,
Esempio n. 24
0
"""
rotor.axial_vent = list()                  
rotor.axial_vent.append(VentilationCirc(
    Zh=8, 
    Alpha0=0, 
    D0=5e-3, 
    H0=40e-3
))
rotor.axial_vent.append(VentilationCirc(
    Zh=8, 
    Alpha0=pi / 8, 
    D0=7e-3, 
    H0=40e-3
))
"""
shaft = Shaft(Drsh=rotor.Rint * 2, Lshaft=1.2)

frame = Frame(Rint=stator.Rext, Rext=stator.Rext + 10 * mm, Lfra=1)

# Set Materials
stator.mat_type = M400_50A
rotor.mat_type = M400_50A
stator.winding.conductor.cond_mat = Copper1
rotor.hole[0].magnet_0.mat_type = Magnet3
rotor.hole[0].magnet_1.mat_type = Magnet3

rotor.hole[0].magnet_0.type_magnetization = 1
rotor.hole[0].magnet_1.type_magnetization = 1

IPMSM_xxx = MachineIPMSM(name="IPMSM",
                         stator=stator,
Esempio n. 25
0
    def __init__(
        self,
        rotor=-1,
        stator=-1,
        frame=-1,
        shaft=-1,
        name="default_machine",
        desc="",
        init_dict=None,
    ):
        """Constructor of the class. Can be use in two ways :
        - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values
            for Matrix, None will initialise the property with an empty Matrix
            for pyleecan type, None will call the default constructor
        - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys

        ndarray or list can be given for Vector and Matrix
        object or dict can be given for pyleecan Object"""

        if rotor == -1:
            rotor = Lamination()
        if stator == -1:
            stator = Lamination()
        if frame == -1:
            frame = Frame()
        if shaft == -1:
            shaft = Shaft()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                ["rotor", "stator", "frame", "shaft", "name", "desc"])
            # Overwrite default value with init_dict content
            if "rotor" in list(init_dict.keys()):
                rotor = init_dict["rotor"]
            if "stator" in list(init_dict.keys()):
                stator = init_dict["stator"]
            if "frame" in list(init_dict.keys()):
                frame = init_dict["frame"]
            if "shaft" in list(init_dict.keys()):
                shaft = init_dict["shaft"]
            if "name" in list(init_dict.keys()):
                name = init_dict["name"]
            if "desc" in list(init_dict.keys()):
                desc = init_dict["desc"]
        # Initialisation by argument
        self.parent = None
        # rotor can be None, a Lamination object or a dict
        if isinstance(rotor, dict):
            # Call the correct constructor according to the dict
            load_dict = {
                "LamHole": LamHole,
                "LamSlot": LamSlot,
                "LamSlotWind": LamSlotWind,
                "LamSlotMag": LamSlotMag,
                "LamSquirrelCage": LamSquirrelCage,
                "Lamination": Lamination,
            }
            obj_class = rotor.get("__class__")
            if obj_class is None:
                self.rotor = Lamination(init_dict=rotor)
            elif obj_class in list(load_dict.keys()):
                self.rotor = load_dict[obj_class](init_dict=rotor)
            else:  # Avoid generation error or wrong modification in json
                raise InitUnKnowClassError(
                    "Unknow class name in init_dict for rotor")
        else:
            self.rotor = rotor
        # stator can be None, a Lamination object or a dict
        if isinstance(stator, dict):
            # Call the correct constructor according to the dict
            load_dict = {
                "LamHole": LamHole,
                "LamSlot": LamSlot,
                "LamSlotWind": LamSlotWind,
                "LamSlotMag": LamSlotMag,
                "LamSquirrelCage": LamSquirrelCage,
                "Lamination": Lamination,
            }
            obj_class = stator.get("__class__")
            if obj_class is None:
                self.stator = Lamination(init_dict=stator)
            elif obj_class in list(load_dict.keys()):
                self.stator = load_dict[obj_class](init_dict=stator)
            else:  # Avoid generation error or wrong modification in json
                raise InitUnKnowClassError(
                    "Unknow class name in init_dict for stator")
        else:
            self.stator = stator
        # frame can be None, a Frame object or a dict
        if isinstance(frame, dict):
            self.frame = Frame(init_dict=frame)
        else:
            self.frame = frame
        # shaft can be None, a Shaft object or a dict
        if isinstance(shaft, dict):
            self.shaft = Shaft(init_dict=shaft)
        else:
            self.shaft = shaft
        self.name = name
        self.desc = desc

        # The class is frozen, for now it's impossible to add new properties
        self._freeze()
Esempio n. 26
0
    def test_Lam_Wind_21_wind_22(self):
        """Test machine plot with Slot 21 and winding rad=2, tan=2
        """
        print("\nTest plot Slot 21")
        plt.close("all")
        test_obj = Machine()

        test_obj.rotor = LamSlotWind(
            Rint=0.2,
            Rext=0.5,
            is_internal=True,
            is_stator=False,
            L1=0.85,
            Nrvd=3,
            Wrvd=0.05,
        )
        test_obj.rotor.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,
        )
        test_obj.rotor.axial_vent.append(
            VentilationTrap(Zh=6,
                            Alpha0=pi / 6,
                            W1=30e-3,
                            W2=60e-3,
                            D0=0.05,
                            H0=0.3))
        test_obj.rotor.axial_vent.append(
            VentilationTrap(Zh=6,
                            Alpha0=pi / 6,
                            W1=60e-3,
                            W2=90e-3,
                            D0=0.05,
                            H0=0.4))
        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.85,
            Nrvd=3,
            Wrvd=0.05,
        )
        test_obj.stator.slot = SlotW21(
            Zs=18,
            W0=40e-3,
            W1=60e-3,
            W2=90e-3,
            H0=15e-3,
            H1=35e-3,
            H2=140e-3,
            H1_is_rad=False,
        )
        test_obj.stator.winding = WindingDW2L(qs=3, p=3)
        test_obj.stator.axial_vent.append(
            VentilationCirc(Zh=12, Alpha0=pi / 6, D0=50e-3, H0=0.75))
        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=1, Lfra=1)

        test_obj.plot()
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Lam_Wind_s21_1-Machine.png"))
        # Rotor + Stator + 2 for frame + 1 for shaft
        self.assertEqual(len(fig.axes[0].patches), 91)

        test_obj.rotor.plot()
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Lam_Wind_s21_2-Rotor.png"))
        # 2 for lam + 4*Zs for wind + 6 vents + 6 vents
        self.assertEqual(len(fig.axes[0].patches), 38)

        test_obj.stator.plot()
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Lam_Wind_s21_3-Stator.png"))
        # 2 for lam + Zs*2 for wind + 12 vents
        self.assertEqual(len(fig.axes[0].patches), 50)

        tooth = test_obj.rotor.slot.get_surface_tooth()
        tooth.plot(color="r")
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Lam_Wind_s21_Tooth_in.png"))

        tooth = test_obj.stator.slot.get_surface_tooth()
        tooth.plot(color="r")
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Lam_Wind_s21_Tooth_out.png"))
Esempio n. 27
0
    Hwire=2e-3,
    Wins_wire=1e-6,
    type_winding_shape=0,
)
# Rotor setup
rotor = LamSlotMag(Rext=0.1,
                   Rint=0.0225,
                   L1=0.4,
                   Kf1=0.95,
                   is_internal=True,
                   is_stator=False,
                   Nrvd=0)
rotor.slot = SlotMPolar(Zs=2, W3=0, W0=2.82743338823, H0=0)
rotor.slot.magnet = [MagnetType11(Wmag=2.82743338823, Hmag=0.012)]

shaft = Shaft(Lshaft=0.442, Drsh=45e-3)
frame = None

# Set Materials
stator.mat_type = M400_50A
rotor.mat_type = M400_50A
stator.winding.conductor.cond_mat = Copper1
rotor.slot.magnet[0].mat_type = Magnet3

SPMSM_003 = MachineSIPMSM(
    name="SPMSM_003",
    desc=
    "polar SIPMSM with surface magnet from Lubin, S. Mezani, and A. Rezzoug publication",
    stator=stator,
    rotor=rotor,
    shaft=shaft,
Esempio n. 28
0
class Machine(FrozenClass):
    """Abstract class for machines"""

    VERSION = 1

    # Check ImportError to remove unnecessary dependencies in unused method
    # cf Methods.Machine.Machine.build_geometry
    if isinstance(build_geometry, ImportError):
        build_geometry = property(fget=lambda x: raise_(
            ImportError("Can't use Machine method build_geometry: " + str(
                build_geometry))))
    else:
        build_geometry = build_geometry
    # cf Methods.Machine.Machine.check
    if isinstance(check, ImportError):
        check = property(fget=lambda x: raise_(
            ImportError("Can't use Machine method check: " + str(check))))
    else:
        check = check
    # cf Methods.Machine.Machine.comp_masses
    if isinstance(comp_masses, ImportError):
        comp_masses = property(fget=lambda x: raise_(
            ImportError("Can't use Machine method comp_masses: " + str(
                comp_masses))))
    else:
        comp_masses = comp_masses
    # cf Methods.Machine.Machine.comp_width_airgap_mag
    if isinstance(comp_width_airgap_mag, ImportError):
        comp_width_airgap_mag = property(fget=lambda x: raise_(
            ImportError("Can't use Machine method comp_width_airgap_mag: " +
                        str(comp_width_airgap_mag))))
    else:
        comp_width_airgap_mag = comp_width_airgap_mag
    # cf Methods.Machine.Machine.comp_width_airgap_mec
    if isinstance(comp_width_airgap_mec, ImportError):
        comp_width_airgap_mec = property(fget=lambda x: raise_(
            ImportError("Can't use Machine method comp_width_airgap_mec: " +
                        str(comp_width_airgap_mec))))
    else:
        comp_width_airgap_mec = comp_width_airgap_mec
    # cf Methods.Machine.Machine.get_lamination
    if isinstance(get_lamination, ImportError):
        get_lamination = property(fget=lambda x: raise_(
            ImportError("Can't use Machine method get_lamination: " + str(
                get_lamination))))
    else:
        get_lamination = get_lamination
    # cf Methods.Machine.Machine.comp_Rgap_mec
    if isinstance(comp_Rgap_mec, ImportError):
        comp_Rgap_mec = property(fget=lambda x: raise_(
            ImportError("Can't use Machine method comp_Rgap_mec: " + str(
                comp_Rgap_mec))))
    else:
        comp_Rgap_mec = comp_Rgap_mec
    # cf Methods.Machine.Machine.plot
    if isinstance(plot, ImportError):
        plot = property(fget=lambda x: raise_(
            ImportError("Can't use Machine method plot: " + str(plot))))
    else:
        plot = plot
    # cf Methods.Machine.Machine.comp_output_geo
    if isinstance(comp_output_geo, ImportError):
        comp_output_geo = property(fget=lambda x: raise_(
            ImportError("Can't use Machine method comp_output_geo: " + str(
                comp_output_geo))))
    else:
        comp_output_geo = comp_output_geo
    # cf Methods.Machine.Machine.comp_length_airgap_active
    if isinstance(comp_length_airgap_active, ImportError):
        comp_length_airgap_active = property(fget=lambda x: raise_(
            ImportError("Can't use Machine method comp_length_airgap_active: "
                        + str(comp_length_airgap_active))))
    else:
        comp_length_airgap_active = comp_length_airgap_active
    # cf Methods.Machine.Machine.get_polar_eq
    if isinstance(get_polar_eq, ImportError):
        get_polar_eq = property(fget=lambda x: raise_(
            ImportError("Can't use Machine method get_polar_eq: " + str(
                get_polar_eq))))
    else:
        get_polar_eq = get_polar_eq
    # save method is available in all object
    save = save

    def __init__(
        self,
        rotor=-1,
        stator=-1,
        frame=-1,
        shaft=-1,
        name="default_machine",
        desc="",
        init_dict=None,
    ):
        """Constructor of the class. Can be use in two ways :
        - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values
            for Matrix, None will initialise the property with an empty Matrix
            for pyleecan type, None will call the default constructor
        - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys

        ndarray or list can be given for Vector and Matrix
        object or dict can be given for pyleecan Object"""

        if rotor == -1:
            rotor = Lamination()
        if stator == -1:
            stator = Lamination()
        if frame == -1:
            frame = Frame()
        if shaft == -1:
            shaft = Shaft()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                ["rotor", "stator", "frame", "shaft", "name", "desc"])
            # Overwrite default value with init_dict content
            if "rotor" in list(init_dict.keys()):
                rotor = init_dict["rotor"]
            if "stator" in list(init_dict.keys()):
                stator = init_dict["stator"]
            if "frame" in list(init_dict.keys()):
                frame = init_dict["frame"]
            if "shaft" in list(init_dict.keys()):
                shaft = init_dict["shaft"]
            if "name" in list(init_dict.keys()):
                name = init_dict["name"]
            if "desc" in list(init_dict.keys()):
                desc = init_dict["desc"]
        # Initialisation by argument
        self.parent = None
        # rotor can be None, a Lamination object or a dict
        if isinstance(rotor, dict):
            # Check that the type is correct (including daughter)
            class_name = rotor.get("__class__")
            if class_name not in [
                    "Lamination",
                    "LamHole",
                    "LamSlot",
                    "LamSlotWind",
                    "LamSlotMag",
                    "LamSquirrelCage",
            ]:
                raise InitUnKnowClassError("Unknow class name " + class_name +
                                           " in init_dict for rotor")
            # Dynamic import to call the correct constructor
            module = __import__("pyleecan.Classes." + class_name,
                                fromlist=[class_name])
            class_obj = getattr(module, class_name)
            self.rotor = class_obj(init_dict=rotor)
        else:
            self.rotor = rotor
        # stator can be None, a Lamination object or a dict
        if isinstance(stator, dict):
            # Check that the type is correct (including daughter)
            class_name = stator.get("__class__")
            if class_name not in [
                    "Lamination",
                    "LamHole",
                    "LamSlot",
                    "LamSlotWind",
                    "LamSlotMag",
                    "LamSquirrelCage",
            ]:
                raise InitUnKnowClassError("Unknow class name " + class_name +
                                           " in init_dict for stator")
            # Dynamic import to call the correct constructor
            module = __import__("pyleecan.Classes." + class_name,
                                fromlist=[class_name])
            class_obj = getattr(module, class_name)
            self.stator = class_obj(init_dict=stator)
        else:
            self.stator = stator
        # frame can be None, a Frame object or a dict
        if isinstance(frame, dict):
            self.frame = Frame(init_dict=frame)
        else:
            self.frame = frame
        # shaft can be None, a Shaft object or a dict
        if isinstance(shaft, dict):
            self.shaft = Shaft(init_dict=shaft)
        else:
            self.shaft = shaft
        self.name = name
        self.desc = desc

        # The class is frozen, for now it's impossible to add new properties
        self._freeze()

    def __str__(self):
        """Convert this objet in a readeable string (for print)"""

        Machine_str = ""
        if self.parent is None:
            Machine_str += "parent = None " + linesep
        else:
            Machine_str += "parent = " + str(type(
                self.parent)) + " object" + linesep
        Machine_str += "rotor = " + str(
            self.rotor.as_dict()) + linesep + linesep
        Machine_str += "stator = " + str(
            self.stator.as_dict()) + linesep + linesep
        Machine_str += "frame = " + str(
            self.frame.as_dict()) + linesep + linesep
        Machine_str += "shaft = " + str(
            self.shaft.as_dict()) + linesep + linesep
        Machine_str += 'name = "' + str(self.name) + '"' + linesep
        Machine_str += 'desc = "' + str(self.desc) + '"'
        return Machine_str

    def __eq__(self, other):
        """Compare two objects (skip parent)"""

        if type(other) != type(self):
            return False
        if other.rotor != self.rotor:
            return False
        if other.stator != self.stator:
            return False
        if other.frame != self.frame:
            return False
        if other.shaft != self.shaft:
            return False
        if other.name != self.name:
            return False
        if other.desc != self.desc:
            return False
        return True

    def as_dict(self):
        """Convert this objet in a json seriable dict (can be use in __init__)
        """

        Machine_dict = dict()
        if self.rotor is None:
            Machine_dict["rotor"] = None
        else:
            Machine_dict["rotor"] = self.rotor.as_dict()
        if self.stator is None:
            Machine_dict["stator"] = None
        else:
            Machine_dict["stator"] = self.stator.as_dict()
        if self.frame is None:
            Machine_dict["frame"] = None
        else:
            Machine_dict["frame"] = self.frame.as_dict()
        if self.shaft is None:
            Machine_dict["shaft"] = None
        else:
            Machine_dict["shaft"] = self.shaft.as_dict()
        Machine_dict["name"] = self.name
        Machine_dict["desc"] = self.desc
        # The class name is added to the dict fordeserialisation purpose
        Machine_dict["__class__"] = "Machine"
        return Machine_dict

    def _set_None(self):
        """Set all the properties to None (except pyleecan object)"""

        if self.rotor is not None:
            self.rotor._set_None()
        if self.stator is not None:
            self.stator._set_None()
        if self.frame is not None:
            self.frame._set_None()
        if self.shaft is not None:
            self.shaft._set_None()
        self.name = None
        self.desc = None

    def _get_rotor(self):
        """getter of rotor"""
        return self._rotor

    def _set_rotor(self, value):
        """setter of rotor"""
        check_var("rotor", value, "Lamination")
        self._rotor = value

        if self._rotor is not None:
            self._rotor.parent = self

    # Machine's Rotor
    # Type : Lamination
    rotor = property(fget=_get_rotor,
                     fset=_set_rotor,
                     doc=u"""Machine's Rotor""")

    def _get_stator(self):
        """getter of stator"""
        return self._stator

    def _set_stator(self, value):
        """setter of stator"""
        check_var("stator", value, "Lamination")
        self._stator = value

        if self._stator is not None:
            self._stator.parent = self

    # Machine's Stator
    # Type : Lamination
    stator = property(fget=_get_stator,
                      fset=_set_stator,
                      doc=u"""Machine's Stator""")

    def _get_frame(self):
        """getter of frame"""
        return self._frame

    def _set_frame(self, value):
        """setter of frame"""
        check_var("frame", value, "Frame")
        self._frame = value

        if self._frame is not None:
            self._frame.parent = self

    # Machine's Frame
    # Type : Frame
    frame = property(fget=_get_frame,
                     fset=_set_frame,
                     doc=u"""Machine's Frame""")

    def _get_shaft(self):
        """getter of shaft"""
        return self._shaft

    def _set_shaft(self, value):
        """setter of shaft"""
        check_var("shaft", value, "Shaft")
        self._shaft = value

        if self._shaft is not None:
            self._shaft.parent = self

    # Machine's Shaft
    # Type : Shaft
    shaft = property(fget=_get_shaft,
                     fset=_set_shaft,
                     doc=u"""Machine's Shaft""")

    def _get_name(self):
        """getter of name"""
        return self._name

    def _set_name(self, value):
        """setter of name"""
        check_var("name", value, "str")
        self._name = value

    # Name of the machine
    # Type : str
    name = property(fget=_get_name,
                    fset=_set_name,
                    doc=u"""Name of the machine""")

    def _get_desc(self):
        """getter of desc"""
        return self._desc

    def _set_desc(self, value):
        """setter of desc"""
        check_var("desc", value, "str")
        self._desc = value

    # Machine description
    # Type : str
    desc = property(fget=_get_desc,
                    fset=_set_desc,
                    doc=u"""Machine description""")
Esempio n. 29
0
    is_internal=True,
    is_stator=False,
    Hscr=20e-3,
    Lscr=15e-3,
    Nrvd=0,
)
rotor.axial_vent = [VentilationCirc(Zh=8, D0=20e-3, H0=70e-3, Alpha0=0)]

rotor.slot = SlotW21(Zs=28,
                     H0=3e-3,
                     W0=3e-3,
                     H1=0,
                     H2=20e-3,
                     W1=13e-3,
                     W2=10e-3)
rotor.winding = WindingSC(Ntcoil=1, qs=28, Lewout=17e-3, Npcpp=1)
rotor.winding.conductor = CondType21(Hbar=0.02, Wbar=0.01, Wins=0)

shaft = Shaft(Drsh=90e-3)

frame = None

# Set materials
stator.mat_type = M400_50A
stator.winding.conductor.cond_mat = Copper1
rotor.mat_type = M400_50A
rotor.ring_mat = Copper1
rotor.winding.conductor.cond_mat = Copper1

SCIM_001 = MachineSCIM(stator=stator, rotor=rotor, shaft=shaft, frame=frame)
Esempio n. 30
0
    def test_Lam_Wind_14_wind_22(self):
        """Test machine plot with Slot 14 and winding rad=2, tan=2
		"""
        print("\nTest plot Slot 14")
        plt.close("all")
        test_obj = MachineDFIM()
        test_obj.rotor = LamSlotWind(
            Rint=0.2,
            Rext=0.5,
            is_internal=True,
            is_stator=False,
            L1=0.95,
            Nrvd=1,
            Wrvd=0.05,
        )
        test_obj.rotor.slot = SlotW14(Zs=6,
                                      W0=100e-3,
                                      W3=200e-3,
                                      H0=15e-3,
                                      H1=25e-3,
                                      H3=140e-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.shaft.mat_type.name = "M270_35A"

        test_obj.rotor.mat_type.name = "Load_M400"
        test_obj.rotor.mat_type.mag = MatMagnetics(Wlam=0.5e-3)

        test_obj.stator = LamSlotWind(
            Rint=0.51,
            Rext=1,
            is_internal=False,
            is_stator=True,
            L1=0.95,
            Nrvd=1,
            Wrvd=0.05,
        )
        test_obj.stator.slot = SlotW14(Zs=6,
                                       W0=100e-3,
                                       W3=200e-3,
                                       H0=15e-3,
                                       H1=25e-3,
                                       H3=140e-3)
        test_obj.stator.winding = WindingUD(user_wind_mat=wind_mat,
                                            qs=4,
                                            p=4,
                                            Lewout=60e-3)

        test_obj.frame = Frame(Rint=1, Rext=1.1, Lfra=1)
        test_obj.frame.mat_type.name = "M330_35A"

        test_obj.plot()
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Lam_Wind_s14_1-Machine.png"))
        # Rotor + Stator + 2 for frame + 1 for shaft
        self.assertEqual(len(fig.axes[0].patches), 55)

        test_obj.rotor.plot()
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Lam_Wind_s14_2-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_s14_3-Stator.png"))
        # 2 for lam + Zs*4 for wind
        self.assertEqual(len(fig.axes[0].patches), 26)

        tooth = test_obj.rotor.slot.get_surface_tooth()
        tooth.plot(color="r")
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Lam_Wind_s14_Tooth_in.png"))

        tooth = test_obj.stator.slot.get_surface_tooth()
        tooth.plot(color="r")
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Lam_Wind_s14_Tooth_out.png"))