예제 #1
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,
        )
예제 #2
0
    def s_plot(self):
        """Plot the lamination (radial and axial) if possible

        Parameters
        ----------
        self : SLamParam
            A SLamParam object
        """

        # We use an empty lamination for the plot to avoid problem with magnet
        # or winding which are not setup yet
        if self.obj.Rint is None:
            QMessageBox().critical(
                self,
                self.tr("Error"),
                self.tr("Unable to plot the lamination "
                        "(Rint missing)"),
            )
        elif self.obj.Rext is None:
            QMessageBox().critical(
                self,
                self.tr("Error"),
                self.tr("Unable to plot the lamination "
                        "(Rext missing)"),
            )
        else:
            plot_obj = Lamination(Rint=self.obj.Rint,
                                  Rext=self.obj.Rext,
                                  axial_vent=self.obj.axial_vent)
            if self.obj.is_stator is not None:
                plot_obj.is_stator = self.obj.is_stator
            plot_obj.plot()
            gcf().canvas.set_window_title(
                self.tr("Lamination (without slots) Front view"))
예제 #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
예제 #4
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"))
예제 #5
0
    def setUp(self):
        """Run at the begining of every test to setup the gui"""

        self.test_obj = Lamination(Rint=0.1,
                                   Rext=1,
                                   is_stator=True,
                                   is_internal=True)
        self.test_obj.axial_vent.append(
            VentilationCirc(Zh=8, H0=10e-3, D0=40e-3, Alpha0=0))
        self.test_obj.axial_vent.append(
            VentilationCirc(Zh=9, H0=20e-3, D0=50e-3, Alpha0=0))

        self.widget = DAVDuct(self.test_obj)
예제 #6
0
    def comp_output(self):
        """Update the Output group according to the current value

        Parameters
        ----------
        self : WVentOut
            A WVentOut object
        """

        lam = self.parent().lam

        # Lamination output
        Rint = format(self.u.get_m(lam.Rint), ".4g")
        self.out_Rint.setText(
            self.tr("Lam. internal radius: ") + Rint + " " + self.u.get_m_name()
        )

        Rext = format(self.u.get_m(lam.Rext), ".4g")
        self.out_Rext.setText(
            self.tr("Lam. external radius: ") + Rext + " " + self.u.get_m_name()
        )
        Slam = format(self.u.get_m2(pi * (lam.Rext ** 2 - lam.Rint ** 2)), ".4g")
        self.out_lam_surface.setText(
            self.tr("Lam. surface (no slot, no vent): ")
            + Slam
            + " "
            + self.u.get_m2_name()
        )
        # Ventilation output
        try:
            lam = Lamination(Rext=lam.Rext, Rint=lam.Rint)

            lam.axial_vent = self.parent().lam.axial_vent
            Svent = format(self.u.get_m2(lam.comp_surface_axial_vent()), ".4g")
        except Exception:
            Svent = 0
            self.out_lam_vent_surface.setText(
                self.tr("Lam. surface (no slot, with vent): ?")
            )
            self.out_vent_surf.setText(self.tr("Vent surface: ?"))
        if Svent != 0:
            Slv = format(float(Slam) - float(Svent), ".4g")
            self.out_lam_vent_surface.setText(
                self.tr("Lam. surface (no slot, with vent): ")
                + Slv
                + " "
                + self.u.get_m2_name()
            )
            self.out_vent_surf.setText(
                self.tr("Vent surface: ") + Svent + " " + self.u.get_m2_name()
            )
    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.mag = 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.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), 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"))
예제 #8
0
    def test_init_all_type(self):
        """Check that you can combine several kind of ventilations
        """
        self.test_obj = Lamination(Rint=0.1,
                                   Rext=1,
                                   is_stator=True,
                                   is_internal=True)
        self.test_obj.axial_vent.append(
            VentilationCirc(Zh=8, H0=10e-3, D0=40e-3, Alpha0=0))
        self.test_obj.axial_vent.append(
            VentilationTrap(Zh=4,
                            H0=24e-3,
                            D0=34e-3,
                            W1=44e-3,
                            W2=54e-3,
                            Alpha0=0))
        self.test_obj.axial_vent.append(
            VentilationPolar(Zh=3, H0=23e-3, D0=33e-3, W1=43e-3, Alpha0=0))
        self.widget = DAVDuct(self.test_obj)

        self.assertEqual(self.widget.tab_vent.count(), 3)
        self.assertEqual(self.widget.tab_vent.currentIndex(), 0)

        # First set
        self.assertEqual(type(self.widget.tab_vent.widget(0).w_vent),
                         PVentCirc)
        self.assertEqual(
            self.widget.tab_vent.widget(0).c_vent_type.currentIndex(), 0)
        self.assertEqual(
            self.widget.tab_vent.widget(0).w_vent.si_Zh.value(), 8)

        # 2nd set
        self.assertEqual(type(self.widget.tab_vent.widget(1).w_vent),
                         PVentTrap)
        self.assertEqual(
            self.widget.tab_vent.widget(1).c_vent_type.currentIndex(), 1)
        self.assertEqual(
            self.widget.tab_vent.widget(1).w_vent.si_Zh.value(), 4)

        # 3rd set
        self.assertEqual(type(self.widget.tab_vent.widget(2).w_vent),
                         PVentPolar)
        self.assertEqual(
            self.widget.tab_vent.widget(2).c_vent_type.currentIndex(), 2)
        self.assertEqual(
            self.widget.tab_vent.widget(2).w_vent.si_Zh.value(), 3)
    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 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(
            HoleM52(Zh=8, W0=27e-3, W3=16.2e-3, H0=1e-3, H1=5e-3, H2=1e-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.09, Rext=0.12, is_internal=False, is_stator=True, L1=0.9
        )
        test_obj.stator.mat_type.magnetics = MatLamination(Wlam=0.5e-3)
        test_obj.frame = Frame(Rint=0.12, Rext=0.12, Lfra=0.7)
        self.test_obj = test_obj
예제 #11
0
    def test_Lam_Mag_12_surface(self):
        """Test machine plot with Magnet 12 surface"""

        plt.close("all")
        rotor = LamSlotMag(
            Rint=40e-3,
            Rext=90e-3,
            is_internal=True,
            is_stator=False,
            L1=0.4,
            Nrvd=2,
            Wrvd=0.05,
        )

        magnet = [MagnetType12(Lmag=0.5, Hmag=0.02, Wmag=0.06)]
        rotor.slot = SlotMFlat(Zs=8, W0=0.06, magnet=magnet)
        rotor.mat_type.mag = MatMagnetics(Wlam=0.5e-3)

        stator = Lamination(
            Rint=130e-3,
            Rext=0.2,
            is_internal=False,
            is_stator=True,
            L1=0.4,
            Nrvd=2,
            Wrvd=0.05,
        )
        stator.mat_type.mag = MatMagnetics(Wlam=0.5e-3)

        rotor.plot()
        fig = plt.gcf()
        self.assertEqual(len(fig.axes[0].patches), 10)
        fig.savefig(join(save_path, "test_Lam_Mag_12s_2-Rotor.png"))

        stator.plot()
        fig = plt.gcf()
        self.assertEqual(len(fig.axes[0].patches), 2)
        fig.savefig(join(save_path, "test_Lam_Mag_12s_3-Stator.png"))
예제 #12
0
    def __init__(self, lamination):
        """Initialize the widget according the current lamination

        Parameters
        ----------
        self : DAVDuct
            A DAVDuct widget
        lam : Lamination
            current lamination to edit
        """
        # Build the interface according to the .ui file
        QDialog.__init__(self)
        self.setupUi(self)

        self.obj = lamination  # Current object
        self.lam = Lamination(
            init_dict=Lamination.as_dict(lamination))  # Copy to modify

        # Init the GUI
        if len(self.lam.axial_vent) == 0:  # No vent => init circle
            self.lam.axial_vent.append(VentilationCirc())
            self.lam.axial_vent[0]._set_None()

        self.tab_vent.clear()
        for vent in self.lam.axial_vent:
            self.s_add(vent)
        self.tab_vent.setCurrentIndex(0)

        # Set Help URL
        self.b_help.url = "https://eomys.com/produits/manatee/howtos/article/"
        self.b_help.url += "how-to-add-ventilation-ducts"

        self.b_new.clicked.connect(self.s_add)
        self.b_remove.clicked.connect(self.s_remove)
        self.b_plot.clicked.connect(self.plot)
        self.b_cancel.clicked.connect(self.reject)
        self.b_ok.clicked.connect(self.valid_vent)
예제 #13
0
    def test_Lam_Mag_14_inset(self):
        """Test machine plot with Magnet 14 inset"""

        plt.close("all")
        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)]
        rotor.slot = SlotMPolar(Zs=4, W0=0.628, H0=0.02, magnet=magnet)
        rotor.mat_type.mag = MatMagnetics(Wlam=0.5e-3)

        stator = Lamination(
            Rint=130e-3,
            Rext=0.2,
            is_internal=False,
            is_stator=True,
            L1=0.4,
            Nrvd=5,
            Wrvd=0.02,
        )
        stator.mat_type.mag = MatMagnetics(Wlam=0.5e-3)

        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"))

        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"))
예제 #14
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()
예제 #15
0
def draw_FEMM(
    output,
    is_mmfr,
    is_mmfs,
    sym,
    is_antiper,
    type_calc_leakage,
    is_remove_vent=False,
    is_remove_slotS=False,
    is_remove_slotR=False,
    is_stator_linear_BH=False,
    is_rotor_linear_BH=False,
    kgeo_fineness=1,
    kmesh_fineness=1,
    user_FEMM_dict={},
    path_save="FEMM_model.fem",
    is_sliding_band=True,
):
    """Draws and assigns the property of the machine in FEMM
    
    Parameters
    ----------
    output : Output
        Output object
    is_mmfr : bool
        1 to compute the rotor magnetomotive force / rotor
        magnetic field
    is_mmfs : bool
        1 to compute the stator magnetomotive force/stator
        magnetic field
    type_calc_leakage : int
        0 no leakage calculation
        1 calculation using single slot
    is_remove_vent : bool
        True to remove the ventilation ducts in FEMM (Default value = False)
    is_remove_slotS : bool
        True to solve without slot effect on the Stator (Default value = False)
    is_remove_slotR : bool
        True to solve without slot effect on the Rotor (Default value = False)
    is_stator_linear_BH: bool
        1 to use linear B(H) curve according to mur_lin, 0 to use the B(H) curve
    is_rotor_linear_BH: bool
        1 to use linear B(H) curve according to mur_lin, 0 to use the B(H) curve
    kgeo_fineness : float
        global coefficient to adjust geometry fineness
        in FEMM (1: default ; > 1: finner ; < 1: less fine)
    kmesh_fineness : float
        global coefficient to adjust mesh fineness
        in FEMM (1: default ; > 1: finner ; < 1: less fine)
    sym : int
        the symmetry applied on the stator and the rotor (take into account antiperiodicity)
    is_antiper: bool
        To apply antiperiodicity boundary conditions

    Returns
    -------

    FEMM_dict : dict
        Dictionnary containing the main parameters of FEMM (including circuits and materials)
    """

    # Initialization from output for readibility
    BHs = output.geo.stator.BH_curve  # Stator B(H) curve
    BHr = output.geo.rotor.BH_curve  # Rotor B(H) curve
    Is = output.elec.Is  # Stator currents waveforms
    Ir = output.elec.Ir  # Rotor currents waveforms
    machine = output.simu.machine

    # Modifiy the machine to match the conditions
    machine = type(machine)(init_dict=machine.as_dict())
    if is_remove_slotR:  # Remove all slots on the rotor
        lam_dict = machine.rotor.as_dict()
        machine.rotor = Lamination(init_dict=lam_dict)
    if is_remove_slotS:  # Remove all slots on the stator
        lam_dict = machine.stator.as_dict()
        machine.stator = Lamination(init_dict=lam_dict)
    if is_remove_vent:  # Remove all ventilations
        machine.rotor.axial_vent = list()
        machine.stator.axial_vent = list()

    # Building geometry of the (modified) stator and the rotor
    surf_list = list()
    lam_ext = machine.get_lamination(is_internal=False)
    lam_int = machine.get_lamination(is_internal=True)
    # adding Internal Lamination surface
    surf_list.extend(lam_int.build_geometry(sym=sym))

    # adding the Airgap surface
    if is_sliding_band:
        surf_list.extend(
            get_sliding_band(
                sym=sym,
                lam_int=output.simu.machine.get_lamination(True),
                lam_ext=output.simu.machine.get_lamination(False),
            )
        )
    else:
        surf_list.extend(
            get_airgap_surface(
                lam_int=output.simu.machine.get_lamination(True),
                lam_ext=output.simu.machine.get_lamination(False),
            )
        )

    # adding External Lamination surface
    surf_list.extend(lam_ext.build_geometry(sym=sym))

    # Computing parameter (element size, arcspan...) needed to define the simulation
    FEMM_dict = comp_FEMM_dict(
        machine, kgeo_fineness, kmesh_fineness, type_calc_leakage
    )
    FEMM_dict.update(user_FEMM_dict)  # Overwrite some values if needed

    # The package must be initialized with the openfemm command.
    femm.openfemm()

    # We need to create a new Magnetostatics document to work on.
    femm.newdocument(0)

    # Minimize the main window for faster geometry creation.
    femm.main_minimize()

    # defining the problem
    femm.mi_probdef(0, "meters", FEMM_dict["pbtype"], FEMM_dict["precision"])

    # Creation of all the materials and circuit in FEMM
    prop_dict, materials, circuits = create_FEMM_materials(
        machine,
        surf_list,
        Is,
        Ir,
        BHs,
        BHr,
        is_mmfs,
        is_mmfr,
        is_stator_linear_BH,
        is_rotor_linear_BH,
        is_eddies,
        j_t0=0,
    )
    create_FEMM_boundary_conditions(sym=sym, is_antiper=is_antiper)

    # Draw and assign all the surfaces of the machine
    for surf in surf_list:
        label = surf.label
        # Get the correct element size and group according to the label
        mesh_dict = get_mesh_param(label, FEMM_dict)
        surf.draw_FEMM(
            nodeprop="None",
            maxseg=FEMM_dict["arcspan"],  # max span of arc element in degrees
            propname="None",
            elementsize=mesh_dict["element_size"],
            automesh=mesh_dict["automesh"],
            hide=False,
            group=mesh_dict["group"],
        )
        assign_FEMM_surface(
            surf, prop_dict[label], mesh_dict, machine.rotor, machine.stator
        )

    femm.mi_zoomnatural()  # Zoom out
    femm.mi_probdef(
        FEMM_dict["freqpb"],
        "meters",
        FEMM_dict["pbtype"],
        FEMM_dict["precision"],
        FEMM_dict["Lfemm"],
        FEMM_dict["minangle"],
        FEMM_dict["acsolver"],
    )
    femm.smartmesh(FEMM_dict["smart_mesh"])
    femm.mi_saveas(path_save)  # Save
    # femm.mi_close()

    FEMM_dict["materials"] = materials
    FEMM_dict["circuits"] = circuits

    return FEMM_dict
예제 #16
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):
            # 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()
예제 #17
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))
test_obj.rotor.mat_type.struct.rho = 7600
test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=1.2)
test_obj.shaft.mat_type.struct.rho = 5000
test_obj.stator = Lamination(Rint=0.078,
                             Rext=0.104,
                             is_internal=False,
                             is_stator=True,
                             L1=0.8,
                             Nrvd=0,
                             Kf1=0.95)
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.struct.rho = 8000
test_obj.frame = Frame(Rint=0.104, Rext=0.114, Lfra=1)
test_obj.frame.mat_type.struct.rho = 4000

M_test.append({
    "test_obj": test_obj,
    "Mfra": 4000 * pi * (0.114**2 - 0.104**2),
    "Msha": 5000 * 1.2 * pi * 0.021**2,
예제 #18
0
    def __init__(
        self,
        lam_list=list(),
        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,
                ["lam_list", "frame", "shaft", "name", "desc", "type_machine"],
            )
            # Overwrite default value with init_dict content
            if "lam_list" in list(init_dict.keys()):
                lam_list = init_dict["lam_list"]
            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
        # lam_list can be None or a list of Lamination object
        self.lam_list = list()
        if type(lam_list) is list:
            for obj in lam_list:
                if obj is None:  # Default value
                    self.lam_list.append(Lamination())
                elif isinstance(obj, dict):
                    # Check that the type is correct (including daughter)
                    class_name = obj.get("__class__")
                    if class_name not in [
                            "Lamination",
                            "LamHole",
                            "LamSlot",
                            "LamSlotMag",
                            "LamSlotMulti",
                            "LamSlotWind",
                            "LamSquirrelCage",
                    ]:
                        raise InitUnKnowClassError(
                            "Unknow class name " + class_name +
                            " in init_dict for lam_list")
                    # Dynamic import to call the correct constructor
                    module = __import__("pyleecan.Classes." + class_name,
                                        fromlist=[class_name])
                    class_obj = getattr(module, class_name)
                    self.lam_list.append(class_obj(init_dict=obj))
                else:
                    self.lam_list.append(obj)
        elif lam_list is None:
            self.lam_list = list()
        else:
            self.lam_list = lam_list
        # Call Machine init
        super(MachineUD, self).__init__(frame=frame,
                                        shaft=shaft,
                                        name=name,
                                        desc=desc,
                                        type_machine=type_machine)
예제 #19
0
from pyleecan.Classes.Frame import Frame
from pyleecan.Classes.Shaft import Shaft
from pyleecan.Classes.ImportMatrixXls import ImportMatrixXls

from pyleecan.Classes.Material import Material
from pyleecan.Classes.MatMagnet import MatMagnet
from pyleecan.Tests.Validation.Material.M400_50A import M400_50A
from pyleecan.Tests.Validation.Material.Magnet_prius import Magnet_prius
from pyleecan.Tests.Validation.Material.Copper1 import Copper1

# Stator setup
stator = Lamination(
    Rint=80.95e-3,
    Rext=134.62e-3,
    Nrvd=0,
    L1=0.08382,
    Kf1=0.95,
    is_internal=False,
    is_stator=True,
)

# Rotor setup
rotor = LamHole(
    Rext=80.2e-3,
    Rint=55.32e-3,
    L1=0.08382,
    Kf1=0.95,
    is_internal=True,
    is_stator=False,
    Nrvd=0,
)