예제 #1
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 = MachineDFIM()
        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.mag = MatMagnetics(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.mag = MatMagnetics(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)
예제 #2
0
    def test_Lam_Mag_11_inset_2_mag(self):
        """Test machine plot with Magnet 11 inset with two magnet in the slot"""
        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,
        )
        rotor.mat_type.mag = MatMagnetics(Wlam=0.5e-3)
        rotor.slot = SlotMPolar(
            Zs=8,
            W0=pi / 12,
            H0=0.01,
            W3=pi / 18,
            magnet=[
                MagnetType11(Lmag=0.5, Hmag=0.01, Wmag=pi / 12),
                MagnetType11(Lmag=0.5, Hmag=0.01, Wmag=pi / 12),
            ],
        )

        stator = LamSlotMag(
            Rint=115e-3,
            Rext=200e-3,
            is_internal=False,
            is_stator=True,
            L1=0.4,
            Nrvd=2,
            Wrvd=0.05,
        )
        stator.slot = SlotMPolar(
            Zs=4,
            W0=pi / 10,
            H0=0.02,
            W3=2 * pi / 50,
            magnet=[
                MagnetType11(Lmag=0.35, Hmag=0.03, Wmag=pi / 10),
                MagnetType11(Lmag=0.35, Hmag=0.03, Wmag=pi / 10),
            ],
        )
        stator.mat_type.mag = MatMagnetics(Wlam=0.5e-3)

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

        stator.plot()
        fig = plt.gcf()
        self.assertEqual(len(fig.axes[0].patches), 10)
        fig.savefig(join(save_path, "test_Lam_Mag_11i_3_Mag_2-Stator.png"))
예제 #3
0
    def test_Lam_Mag_11_surface(self):
        """Test machine plot with Magnet 11 surface"""

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

        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)]
        stator.slot = SlotMPolar(Zs=4, W0=pi / 4, magnet=magnet2)
        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_11s_2-Rotor.png"))

        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"))
예제 #4
0
    def test_Lam_Mag_10_inset(self):
        """Test machine plot with Magnet 10 inset"""

        plt.close("all")
        rotor = LamSlotMag(
            Rint=40e-3,
            Rext=100e-3,
            is_internal=True,
            is_stator=False,
            L1=0.45,
            Nrvd=1,
            Wrvd=0.05,
        )
        magnet = [MagnetType10(Lmag=0.5, Hmag=0.02, Wmag=0.04)]
        rotor.slot = SlotMFlat(Zs=4, W0=0.04, H0=0.02, magnet=magnet)
        rotor.mat_type.mag = MatMagnetics(Wlam=0.5e-3)

        rotor.axial_vent.append(VentilationCirc(Zh=4, Alpha0=0, D0=2.5e-3, H0=50e-3))
        rotor.axial_vent.append(VentilationCirc(Zh=8, Alpha0=0, D0=5e-3, H0=60e-3))
        rotor.axial_vent.append(VentilationCirc(Zh=12, Alpha0=0, D0=10e-3, H0=70e-3))

        stator = LamSlotMag(
            Rint=110e-3,
            Rext=200e-3,
            is_internal=False,
            is_stator=True,
            L1=0.45,
            Nrvd=1,
            Wrvd=0.05,
        )

        magnet2 = [MagnetType10(Lmag=0.5, Hmag=0.02, Wmag=0.04)]
        stator.slot = SlotMFlat(Zs=8, W0=0.04, W3=2 * pi / 64, H0=0.02, magnet=magnet2)
        stator.mat_type.mag = MatMagnetics(Wlam=0.5e-3)

        stator.axial_vent.append(
            VentilationTrap(Zh=6, Alpha0=pi / 6, W1=10e-3, W2=20e-3, D0=0.02, H0=0.140)
        )
        stator.axial_vent.append(
            VentilationTrap(Zh=6, Alpha0=pi / 6, W1=20e-3, W2=40e-3, D0=0.02, H0=0.170)
        )

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

        stator.plot()
        fig = plt.gcf()
        self.assertEqual(len(fig.axes[0].patches), 22)
        fig.savefig(join(save_path, "test_Lam_Mag_10i_3-Stator.png"))
예제 #5
0
    def setUp(self):
        """Run at the begining of every test to setup the gui"""
        mat_lib = list()
        mat_lib.append(Material())
        mat_lib[0].name = "test_material_1"
        mat_lib[0].is_isotropic = True
        mat_lib[0].elec.rho = 0.11
        mat_lib[0].mag = MatMagnetics(mur_lin=0.12, Wlam=0.13)
        mat_lib[0].struct.rho = 0.14
        mat_lib[0].struct.Ex = 0.15
        mat_lib[0].struct.Ey = 0.152
        mat_lib[0].struct.Ez = 0.153
        mat_lib[0].struct.nu_xy = 0.16
        mat_lib[0].struct.nu_yz = 0.162
        mat_lib[0].struct.nu_xz = 0.163
        mat_lib[0].struct.Gxy = 0.17
        mat_lib[0].struct.Gyz = 0.172
        mat_lib[0].struct.Gxz = 0.173
        mat_lib[0].HT.lambda_x = 0.18
        mat_lib[0].HT.lambda_y = 0.182
        mat_lib[0].HT.lambda_z = 0.183
        mat_lib[0].HT.Cp = 0.19
        mat_lib[0].HT.alpha = 0.20
        mat_lib[0].eco.cost_unit = 0.21

        mat_lib.append(Material(name="test_material_2"))
        mat_lib.append(Material(name="test_material_3"))
        mat_lib.append(Material(name="test_material_4"))
        mat_lib.append(Material(name="test_material_5"))
        mat_lib.append(Material(name="test_material_6"))
        mat_lib.append(Material(name="test_material_7"))

        self.widget = DMatLib(matlib=mat_lib)
예제 #6
0
    def test_Lam_Mag_10_surface(self):
        """Test machine plot with Magnet 10 surface"""

        plt.close("all")
        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)]
        rotor.slot = SlotMFlat(Zs=8,
                               H0=0,
                               W0=2 * pi / 10,
                               W0_is_rad=True,
                               magnet=magnet)
        rotor.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_10s_2-Rotor.png"))

        magnet2 = [MagnetType10(Lmag=0.5, Hmag=0.02, Wmag=0.04)]
        rotor.slot = SlotMFlat(Zs=8, W0=0.04, W0_is_rad=False, magnet=magnet2)
        rotor.plot()
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Lam_Mag_10s_5-Rotor 2.png"))
예제 #7
0
    def test_set_alpha_Br(self):
        """Check that the Widget allow to update alpha_Br"""
        # Set Material for Magnet
        self.test_obj.mag = MatMagnetics()
        self.widget = DMatSetup(material=self.test_obj)

        self.widget.lf_alpha_Br.clear()  # Clear the field before writing
        value = round(uniform(0, 1), 4)
        QTest.keyClicks(self.widget.lf_alpha_Br, str(value))
        self.widget.lf_alpha_Br.editingFinished.emit()  # To trigger the slot

        self.assertEqual(self.widget.mat.mag.alpha_Br, value)
예제 #8
0
    def test_Lam_Mag_13_inset(self):
        """Test machine plot with Magnet 12 inset"""

        plt.close("all")
        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)]
        rotor.slot = SlotMFlat(Zs=8, W0=0.04, H0=0.02, W3=2 * pi / 64, magnet=magnet)
        rotor.mat_type.mag = MatMagnetics(Wlam=0.5e-3)

        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)]
        stator.slot = SlotMFlat(Zs=4, W0=0.04, H0=0.025, W3=2 * pi / 64, magnet=magnet2)
        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_13i_2-Rotor.png"))

        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"))
예제 #9
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"))
예제 #10
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"))
예제 #11
0
    def test_set_mur_lin(self):
        """Check that the Widget allow to update mur_lin"""
        self.widget.lf_mur_lin.clear()  # Clear the field before writing
        value = round(uniform(0, 1), 4)
        QTest.keyClicks(self.widget.lf_mur_lin, str(value))
        self.widget.lf_mur_lin.editingFinished.emit()  # To trigger the slot

        self.assertEqual(self.widget.mat.mag.mur_lin, value)

        # Test also for Magnet Materials
        self.test_obj.mag = MatMagnetics()
        self.widget = DMatSetup(material=self.test_obj)

        self.widget.lf_mur_lin.clear()  # Clear the field before writing
        value = round(uniform(0, 1), 4)
        QTest.keyClicks(self.widget.lf_mur_lin, str(value))
        self.widget.lf_mur_lin.editingFinished.emit()  # To trigger the slot

        self.assertEqual(self.widget.mat.mag.mur_lin, value)
예제 #12
0
    def setUp(self):
        """Run at the begining of every test to setup the gui"""
        self.work_path = join(save_path, "Material")
        # Delete old test if needed
        if isdir(self.work_path):
            rmtree(self.work_path)
        mkdir(self.work_path)
        copyfile(
            join(DATA_DIR, "Material", "Magnet1.json"),
            join(self.work_path, "Magnet1.json"),
        )

        self.test_obj = Material()
        self.test_obj.name = "Magnet1"
        self.test_obj.path = join(self.work_path, "Magnet1.json")
        self.test_obj.is_isotropic = True
        self.test_obj.elec.rho = 0.11
        self.test_obj.mag = MatMagnetics(mur_lin=0.12, Wlam=0.13)
        self.test_obj.struct.rho = 0.14
        self.test_obj.struct.Ex = 0.15
        self.test_obj.struct.Ey = 0.152
        self.test_obj.struct.Ez = 0.153
        self.test_obj.struct.nu_xy = 0.16
        self.test_obj.struct.nu_yz = 0.162
        self.test_obj.struct.nu_xz = 0.163
        self.test_obj.struct.Gxy = 0.17
        self.test_obj.struct.Gyz = 0.172
        self.test_obj.struct.Gxz = 0.173
        self.test_obj.HT.lambda_x = 0.18
        self.test_obj.HT.lambda_y = 0.182
        self.test_obj.HT.lambda_z = 0.183
        self.test_obj.HT.Cp = 0.19
        self.test_obj.HT.alpha = 0.20
        self.test_obj.eco.cost_unit = 0.21

        self.widget = DMatSetup(material=self.test_obj)
예제 #13
0
    def __init__(
        self,
        name="M400-50A",
        is_isotropic=False,
        electrical=-1,
        magnetics=-1,
        mechanics=-1,
        thermics=-1,
        economical=-1,
        desc="Lamination M400-50A",
        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 electrical == -1:
            electrical = MatElectrical()
        if magnetics == -1:
            magnetics = MatMagnetics()
        if mechanics == -1:
            mechanics = MatMechanics()
        if thermics == -1:
            thermics = MatThermics()
        if economical == -1:
            economical = MatEconomical()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                [
                    "name",
                    "is_isotropic",
                    "electrical",
                    "magnetics",
                    "mechanics",
                    "thermics",
                    "economical",
                    "desc",
                ],
            )
            # Overwrite default value with init_dict content
            if "name" in list(init_dict.keys()):
                name = init_dict["name"]
            if "is_isotropic" in list(init_dict.keys()):
                is_isotropic = init_dict["is_isotropic"]
            if "electrical" in list(init_dict.keys()):
                electrical = init_dict["electrical"]
            if "magnetics" in list(init_dict.keys()):
                magnetics = init_dict["magnetics"]
            if "mechanics" in list(init_dict.keys()):
                mechanics = init_dict["mechanics"]
            if "thermics" in list(init_dict.keys()):
                thermics = init_dict["thermics"]
            if "economical" in list(init_dict.keys()):
                economical = init_dict["economical"]
            if "desc" in list(init_dict.keys()):
                desc = init_dict["desc"]
        # Initialisation by argument
        self.parent = None
        self.name = name
        self.is_isotropic = is_isotropic
        # electrical can be None, a MatElectrical object or a dict
        if isinstance(electrical, dict):
            self.electrical = MatElectrical(init_dict=electrical)
        else:
            self.electrical = electrical
        # magnetics can be None, a MatMagnetics object or a dict
        if isinstance(magnetics, dict):
            # Call the correct constructor according to the dict
            load_dict = {
                "MatLamination": MatLamination,
                "MatMagnet": MatMagnet,
                "MatMagnetics": MatMagnetics,
            }
            obj_class = magnetics.get("__class__")
            if obj_class is None:
                self.magnetics = MatMagnetics(init_dict=magnetics)
            elif obj_class in list(load_dict.keys()):
                self.magnetics = load_dict[obj_class](init_dict=magnetics)
            else:  # Avoid generation error or wrong modification in json
                raise InitUnKnowClassError(
                    "Unknow class name in init_dict for magnetics")
        else:
            self.magnetics = magnetics
        # mechanics can be None, a MatMechanics object or a dict
        if isinstance(mechanics, dict):
            self.mechanics = MatMechanics(init_dict=mechanics)
        else:
            self.mechanics = mechanics
        # thermics can be None, a MatThermics object or a dict
        if isinstance(thermics, dict):
            self.thermics = MatThermics(init_dict=thermics)
        else:
            self.thermics = thermics
        # economical can be None, a MatEconomical object or a dict
        if isinstance(economical, dict):
            self.economical = MatEconomical(init_dict=economical)
        else:
            self.economical = economical
        self.desc = desc

        # The class is frozen, for now it's impossible to add new properties
        self._freeze()
예제 #14
0
class Material(FrozenClass):

    VERSION = 1

    # save method is available in all object
    save = save

    def __init__(
        self,
        name="M400-50A",
        is_isotropic=False,
        elec=-1,
        mag=-1,
        struct=-1,
        HT=-1,
        eco=-1,
        desc="Lamination M400-50A",
        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 elec == -1:
            elec = MatElectrical()
        if mag == -1:
            mag = MatMagnetics()
        if struct == -1:
            struct = MatStructural()
        if HT == -1:
            HT = MatHT()
        if eco == -1:
            eco = MatEconomical()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                [
                    "name", "is_isotropic", "elec", "mag", "struct", "HT",
                    "eco", "desc"
                ],
            )
            # Overwrite default value with init_dict content
            if "name" in list(init_dict.keys()):
                name = init_dict["name"]
            if "is_isotropic" in list(init_dict.keys()):
                is_isotropic = init_dict["is_isotropic"]
            if "elec" in list(init_dict.keys()):
                elec = init_dict["elec"]
            if "mag" in list(init_dict.keys()):
                mag = init_dict["mag"]
            if "struct" in list(init_dict.keys()):
                struct = init_dict["struct"]
            if "HT" in list(init_dict.keys()):
                HT = init_dict["HT"]
            if "eco" in list(init_dict.keys()):
                eco = init_dict["eco"]
            if "desc" in list(init_dict.keys()):
                desc = init_dict["desc"]
        # Initialisation by argument
        self.parent = None
        self.name = name
        self.is_isotropic = is_isotropic
        # elec can be None, a MatElectrical object or a dict
        if isinstance(elec, dict):
            self.elec = MatElectrical(init_dict=elec)
        else:
            self.elec = elec
        # mag can be None, a MatMagnetics object or a dict
        if isinstance(mag, dict):
            # Call the correct constructor according to the dict
            load_dict = {
                "MatLamination": MatLamination,
                "MatMagnet": MatMagnet,
                "MatMagnetics": MatMagnetics,
            }
            obj_class = mag.get("__class__")
            if obj_class is None:
                self.mag = MatMagnetics(init_dict=mag)
            elif obj_class in list(load_dict.keys()):
                self.mag = load_dict[obj_class](init_dict=mag)
            else:  # Avoid generation error or wrong modification in json
                raise InitUnKnowClassError(
                    "Unknow class name in init_dict for mag")
        else:
            self.mag = mag
        # struct can be None, a MatStructural object or a dict
        if isinstance(struct, dict):
            self.struct = MatStructural(init_dict=struct)
        else:
            self.struct = struct
        # HT can be None, a MatHT object or a dict
        if isinstance(HT, dict):
            self.HT = MatHT(init_dict=HT)
        else:
            self.HT = HT
        # eco can be None, a MatEconomical object or a dict
        if isinstance(eco, dict):
            self.eco = MatEconomical(init_dict=eco)
        else:
            self.eco = eco
        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)"""

        Material_str = ""
        if self.parent is None:
            Material_str += "parent = None " + linesep
        else:
            Material_str += "parent = " + str(type(
                self.parent)) + " object" + linesep
        Material_str += 'name = "' + str(self.name) + '"' + linesep
        Material_str += "is_isotropic = " + str(self.is_isotropic) + linesep
        Material_str += "elec = " + str(
            self.elec.as_dict()) + linesep + linesep
        Material_str += "mag = " + str(self.mag.as_dict()) + linesep + linesep
        Material_str += "struct = " + str(
            self.struct.as_dict()) + linesep + linesep
        Material_str += "HT = " + str(self.HT.as_dict()) + linesep + linesep
        Material_str += "eco = " + str(self.eco.as_dict()) + linesep + linesep
        Material_str += 'desc = "' + str(self.desc) + '"'
        return Material_str

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

        if type(other) != type(self):
            return False
        if other.name != self.name:
            return False
        if other.is_isotropic != self.is_isotropic:
            return False
        if other.elec != self.elec:
            return False
        if other.mag != self.mag:
            return False
        if other.struct != self.struct:
            return False
        if other.HT != self.HT:
            return False
        if other.eco != self.eco:
            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__)
        """

        Material_dict = dict()
        Material_dict["name"] = self.name
        Material_dict["is_isotropic"] = self.is_isotropic
        if self.elec is None:
            Material_dict["elec"] = None
        else:
            Material_dict["elec"] = self.elec.as_dict()
        if self.mag is None:
            Material_dict["mag"] = None
        else:
            Material_dict["mag"] = self.mag.as_dict()
        if self.struct is None:
            Material_dict["struct"] = None
        else:
            Material_dict["struct"] = self.struct.as_dict()
        if self.HT is None:
            Material_dict["HT"] = None
        else:
            Material_dict["HT"] = self.HT.as_dict()
        if self.eco is None:
            Material_dict["eco"] = None
        else:
            Material_dict["eco"] = self.eco.as_dict()
        Material_dict["desc"] = self.desc
        # The class name is added to the dict fordeserialisation purpose
        Material_dict["__class__"] = "Material"
        return Material_dict

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

        self.name = None
        self.is_isotropic = None
        if self.elec is not None:
            self.elec._set_None()
        if self.mag is not None:
            self.mag._set_None()
        if self.struct is not None:
            self.struct._set_None()
        if self.HT is not None:
            self.HT._set_None()
        if self.eco is not None:
            self.eco._set_None()
        self.desc = None

    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 material
    # Type : str
    name = property(fget=_get_name,
                    fset=_set_name,
                    doc=u"""name of the material""")

    def _get_is_isotropic(self):
        """getter of is_isotropic"""
        return self._is_isotropic

    def _set_is_isotropic(self, value):
        """setter of is_isotropic"""
        check_var("is_isotropic", value, "bool")
        self._is_isotropic = value

    # If True, uniformity in all orientations
    # Type : bool
    is_isotropic = property(
        fget=_get_is_isotropic,
        fset=_set_is_isotropic,
        doc=u"""If True, uniformity in all orientations""",
    )

    def _get_elec(self):
        """getter of elec"""
        return self._elec

    def _set_elec(self, value):
        """setter of elec"""
        check_var("elec", value, "MatElectrical")
        self._elec = value

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

    # Electrical properties of the material
    # Type : MatElectrical
    elec = property(fget=_get_elec,
                    fset=_set_elec,
                    doc=u"""Electrical properties of the material""")

    def _get_mag(self):
        """getter of mag"""
        return self._mag

    def _set_mag(self, value):
        """setter of mag"""
        check_var("mag", value, "MatMagnetics")
        self._mag = value

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

    # Magnetic properties of the material
    # Type : MatMagnetics
    mag = property(fget=_get_mag,
                   fset=_set_mag,
                   doc=u"""Magnetic properties of the material""")

    def _get_struct(self):
        """getter of struct"""
        return self._struct

    def _set_struct(self, value):
        """setter of struct"""
        check_var("struct", value, "MatStructural")
        self._struct = value

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

    # Structural properties of the material
    # Type : MatStructural
    struct = property(
        fget=_get_struct,
        fset=_set_struct,
        doc=u"""Structural properties of the material""",
    )

    def _get_HT(self):
        """getter of HT"""
        return self._HT

    def _set_HT(self, value):
        """setter of HT"""
        check_var("HT", value, "MatHT")
        self._HT = value

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

    # Heat Transfer properties of the material
    # Type : MatHT
    HT = property(fget=_get_HT,
                  fset=_set_HT,
                  doc=u"""Heat Transfer properties of the material""")

    def _get_eco(self):
        """getter of eco"""
        return self._eco

    def _set_eco(self, value):
        """setter of eco"""
        check_var("eco", value, "MatEconomical")
        self._eco = value

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

    # Economical properties of the material
    # Type : MatEconomical
    eco = property(fget=_get_eco,
                   fset=_set_eco,
                   doc=u"""Economical properties of the material""")

    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

    # material description
    # Type : str
    desc = property(fget=_get_desc,
                    fset=_set_desc,
                    doc=u"""material description""")
예제 #15
0
    def test_Lam_Wind_12_wind_22(self):
        """Test machine plot with Slot 12 and winding rad=2, tan=2
        """
        print("\nTest plot Slot 12")
        plt.close("all")
        test_obj = MachineDFIM()
        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 = [
            VentilationPolar(Zh=6, Alpha0=pi / 6, W1=pi / 6, D0=100e-3, H0=0.3)
        ]
        test_obj.rotor.slot = SlotW12(Zs=6,
                                      R2=35e-3,
                                      H0=20e-3,
                                      R1=17e-3,
                                      H1=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 = 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.9,
            Nrvd=2,
            Wrvd=0.05,
        )
        test_obj.stator.slot = SlotW12(Zs=18,
                                       R2=25e-3,
                                       H0=30e-3,
                                       R1=0,
                                       H1=150e-3)
        test_obj.stator.winding.Lewout = 60e-3
        test_obj.stator.winding = WindingDW2L(qs=3, p=3)
        test_obj.stator.mat_type.mag = MatMagnetics(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_s12_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_s12_2-Rotor.png"))
        # 2 for lam + Zs*4 for wind + 6 vents
        self.assertEqual(len(fig.axes[0].patches), 32)

        test_obj.stator.plot()
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Lam_Wind_s12_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_s12_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_s12_Tooth_out.png"))
예제 #16
0
    def __init__(
        self,
        name="M400-50A",
        is_isotropic=False,
        elec=-1,
        mag=-1,
        struct=-1,
        HT=-1,
        eco=-1,
        desc="Lamination M400-50A",
        path="",
        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 elec == -1:
            elec = MatElectrical()
        if mag == -1:
            mag = MatMagnetics()
        if struct == -1:
            struct = MatStructural()
        if HT == -1:
            HT = MatHT()
        if eco == -1:
            eco = MatEconomical()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                [
                    "name",
                    "is_isotropic",
                    "elec",
                    "mag",
                    "struct",
                    "HT",
                    "eco",
                    "desc",
                    "path",
                ],
            )
            # Overwrite default value with init_dict content
            if "name" in list(init_dict.keys()):
                name = init_dict["name"]
            if "is_isotropic" in list(init_dict.keys()):
                is_isotropic = init_dict["is_isotropic"]
            if "elec" in list(init_dict.keys()):
                elec = init_dict["elec"]
            if "mag" in list(init_dict.keys()):
                mag = init_dict["mag"]
            if "struct" in list(init_dict.keys()):
                struct = init_dict["struct"]
            if "HT" in list(init_dict.keys()):
                HT = init_dict["HT"]
            if "eco" in list(init_dict.keys()):
                eco = init_dict["eco"]
            if "desc" in list(init_dict.keys()):
                desc = init_dict["desc"]
            if "path" in list(init_dict.keys()):
                path = init_dict["path"]
        # Initialisation by argument
        self.parent = None
        self.name = name
        self.is_isotropic = is_isotropic
        # elec can be None, a MatElectrical object or a dict
        if isinstance(elec, dict):
            self.elec = MatElectrical(init_dict=elec)
        else:
            self.elec = elec
        # mag can be None, a MatMagnetics object or a dict
        if isinstance(mag, dict):
            # Check that the type is correct (including daughter)
            class_name = mag.get("__class__")
            if class_name not in [
                    "MatMagnetics", "MatLamination", "MatMagnet"
            ]:
                raise InitUnKnowClassError("Unknow class name " + class_name +
                                           " in init_dict for mag")
            # Dynamic import to call the correct constructor
            module = __import__("pyleecan.Classes." + class_name,
                                fromlist=[class_name])
            class_obj = getattr(module, class_name)
            self.mag = class_obj(init_dict=mag)
        else:
            self.mag = mag
        # struct can be None, a MatStructural object or a dict
        if isinstance(struct, dict):
            self.struct = MatStructural(init_dict=struct)
        else:
            self.struct = struct
        # HT can be None, a MatHT object or a dict
        if isinstance(HT, dict):
            self.HT = MatHT(init_dict=HT)
        else:
            self.HT = HT
        # eco can be None, a MatEconomical object or a dict
        if isinstance(eco, dict):
            self.eco = MatEconomical(init_dict=eco)
        else:
            self.eco = eco
        self.desc = desc
        self.path = path

        # The class is frozen, for now it's impossible to add new properties
        self._freeze()
예제 #17
0
from pyleecan.Classes.Material import Material
from pyleecan.Classes.MatMagnetics import MatMagnetics

Magnet_prius = Material(name="Magnet_prius")
Magnet_prius.mag = MatMagnetics()

Magnet_prius.elec.rho = 1.6e-06

Magnet_prius.mag.mur_lin = 1.05
Magnet_prius.mag.Hc = 902181.163126629
Magnet_prius.mag.alpha_Br = -0.001
Magnet_prius.mag.Brm20 = 1.24
Magnet_prius.mag.Wlam = 0

Magnet_prius.struct.rho = 7500.0
예제 #18
0
from pyleecan.Classes.Material import Material
from pyleecan.Classes.MatMagnetics import MatMagnetics
from pyleecan.Classes.ImportMatrixXls import ImportMatrixXls
from os.path import dirname, abspath, join

file_path = abspath(join(dirname(__file__), "M400-50A.xlsx"))

M400_50A = Material(name="M400-50A")
M400_50A.mag = MatMagnetics()

M400_50A.mag.mur_lin = 2500.0
M400_50A.mag.Wlam = 0.0005
M400_50A.mag.BH_curve = ImportMatrixXls(file_path=file_path, sheet="BH")

M400_50A.struct.rho = 7650.0
M400_50A.struct.Ex = 215000000000.0
M400_50A.struct.Ey = 215000000000.0
M400_50A.struct.Ez = 80000000000.0
M400_50A.struct.Gxy = 0.0
M400_50A.struct.Gxz = 2000000000.0
M400_50A.struct.Gyz = 2000000000.0
M400_50A.struct.nu_xy = 0.3
M400_50A.struct.nu_xz = 0.03
M400_50A.struct.nu_yz = 0.03
예제 #19
0
class Material(FrozenClass):

    VERSION = 1

    # save method is available in all object
    save = save

    def __init__(
        self,
        name="M400-50A",
        is_isotropic=False,
        electrical=-1,
        magnetics=-1,
        mechanics=-1,
        thermics=-1,
        economical=-1,
        desc="Lamination M400-50A",
        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 electrical == -1:
            electrical = MatElectrical()
        if magnetics == -1:
            magnetics = MatMagnetics()
        if mechanics == -1:
            mechanics = MatMechanics()
        if thermics == -1:
            thermics = MatThermics()
        if economical == -1:
            economical = MatEconomical()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                [
                    "name",
                    "is_isotropic",
                    "electrical",
                    "magnetics",
                    "mechanics",
                    "thermics",
                    "economical",
                    "desc",
                ],
            )
            # Overwrite default value with init_dict content
            if "name" in list(init_dict.keys()):
                name = init_dict["name"]
            if "is_isotropic" in list(init_dict.keys()):
                is_isotropic = init_dict["is_isotropic"]
            if "electrical" in list(init_dict.keys()):
                electrical = init_dict["electrical"]
            if "magnetics" in list(init_dict.keys()):
                magnetics = init_dict["magnetics"]
            if "mechanics" in list(init_dict.keys()):
                mechanics = init_dict["mechanics"]
            if "thermics" in list(init_dict.keys()):
                thermics = init_dict["thermics"]
            if "economical" in list(init_dict.keys()):
                economical = init_dict["economical"]
            if "desc" in list(init_dict.keys()):
                desc = init_dict["desc"]
        # Initialisation by argument
        self.parent = None
        self.name = name
        self.is_isotropic = is_isotropic
        # electrical can be None, a MatElectrical object or a dict
        if isinstance(electrical, dict):
            self.electrical = MatElectrical(init_dict=electrical)
        else:
            self.electrical = electrical
        # magnetics can be None, a MatMagnetics object or a dict
        if isinstance(magnetics, dict):
            # Call the correct constructor according to the dict
            load_dict = {
                "MatLamination": MatLamination,
                "MatMagnet": MatMagnet,
                "MatMagnetics": MatMagnetics,
            }
            obj_class = magnetics.get("__class__")
            if obj_class is None:
                self.magnetics = MatMagnetics(init_dict=magnetics)
            elif obj_class in list(load_dict.keys()):
                self.magnetics = load_dict[obj_class](init_dict=magnetics)
            else:  # Avoid generation error or wrong modification in json
                raise InitUnKnowClassError(
                    "Unknow class name in init_dict for magnetics")
        else:
            self.magnetics = magnetics
        # mechanics can be None, a MatMechanics object or a dict
        if isinstance(mechanics, dict):
            self.mechanics = MatMechanics(init_dict=mechanics)
        else:
            self.mechanics = mechanics
        # thermics can be None, a MatThermics object or a dict
        if isinstance(thermics, dict):
            self.thermics = MatThermics(init_dict=thermics)
        else:
            self.thermics = thermics
        # economical can be None, a MatEconomical object or a dict
        if isinstance(economical, dict):
            self.economical = MatEconomical(init_dict=economical)
        else:
            self.economical = economical
        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)"""

        Material_str = ""
        if self.parent is None:
            Material_str += "parent = None " + linesep
        else:
            Material_str += "parent = " + str(type(
                self.parent)) + " object" + linesep
        Material_str += 'name = "' + str(self.name) + '"' + linesep
        Material_str += "is_isotropic = " + str(self.is_isotropic) + linesep
        Material_str += ("electrical = " + str(self.electrical.as_dict()) +
                         linesep + linesep)
        Material_str += ("magnetics = " + str(self.magnetics.as_dict()) +
                         linesep + linesep)
        Material_str += ("mechanics = " + str(self.mechanics.as_dict()) +
                         linesep + linesep)
        Material_str += "thermics = " + str(
            self.thermics.as_dict()) + linesep + linesep
        Material_str += ("economical = " + str(self.economical.as_dict()) +
                         linesep + linesep)
        Material_str += 'desc = "' + str(self.desc) + '"'
        return Material_str

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

        if type(other) != type(self):
            return False
        if other.name != self.name:
            return False
        if other.is_isotropic != self.is_isotropic:
            return False
        if other.electrical != self.electrical:
            return False
        if other.magnetics != self.magnetics:
            return False
        if other.mechanics != self.mechanics:
            return False
        if other.thermics != self.thermics:
            return False
        if other.economical != self.economical:
            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__)
        """

        Material_dict = dict()
        Material_dict["name"] = self.name
        Material_dict["is_isotropic"] = self.is_isotropic
        if self.electrical is None:
            Material_dict["electrical"] = None
        else:
            Material_dict["electrical"] = self.electrical.as_dict()
        if self.magnetics is None:
            Material_dict["magnetics"] = None
        else:
            Material_dict["magnetics"] = self.magnetics.as_dict()
        if self.mechanics is None:
            Material_dict["mechanics"] = None
        else:
            Material_dict["mechanics"] = self.mechanics.as_dict()
        if self.thermics is None:
            Material_dict["thermics"] = None
        else:
            Material_dict["thermics"] = self.thermics.as_dict()
        if self.economical is None:
            Material_dict["economical"] = None
        else:
            Material_dict["economical"] = self.economical.as_dict()
        Material_dict["desc"] = self.desc
        # The class name is added to the dict fordeserialisation purpose
        Material_dict["__class__"] = "Material"
        return Material_dict

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

        self.name = None
        self.is_isotropic = None
        if self.electrical is not None:
            self.electrical._set_None()
        if self.magnetics is not None:
            self.magnetics._set_None()
        if self.mechanics is not None:
            self.mechanics._set_None()
        if self.thermics is not None:
            self.thermics._set_None()
        if self.economical is not None:
            self.economical._set_None()
        self.desc = None

    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 material
    # Type : str
    name = property(fget=_get_name,
                    fset=_set_name,
                    doc=u"""name of the material""")

    def _get_is_isotropic(self):
        """getter of is_isotropic"""
        return self._is_isotropic

    def _set_is_isotropic(self, value):
        """setter of is_isotropic"""
        check_var("is_isotropic", value, "bool")
        self._is_isotropic = value

    # If True, uniformity in all orientations
    # Type : bool
    is_isotropic = property(
        fget=_get_is_isotropic,
        fset=_set_is_isotropic,
        doc=u"""If True, uniformity in all orientations""",
    )

    def _get_electrical(self):
        """getter of electrical"""
        return self._electrical

    def _set_electrical(self, value):
        """setter of electrical"""
        check_var("electrical", value, "MatElectrical")
        self._electrical = value

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

    # Electrical properties of the material
    # Type : MatElectrical
    electrical = property(
        fget=_get_electrical,
        fset=_set_electrical,
        doc=u"""Electrical properties of the material""",
    )

    def _get_magnetics(self):
        """getter of magnetics"""
        return self._magnetics

    def _set_magnetics(self, value):
        """setter of magnetics"""
        check_var("magnetics", value, "MatMagnetics")
        self._magnetics = value

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

    # Magnetic properties of the material
    # Type : MatMagnetics
    magnetics = property(
        fget=_get_magnetics,
        fset=_set_magnetics,
        doc=u"""Magnetic properties of the material""",
    )

    def _get_mechanics(self):
        """getter of mechanics"""
        return self._mechanics

    def _set_mechanics(self, value):
        """setter of mechanics"""
        check_var("mechanics", value, "MatMechanics")
        self._mechanics = value

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

    # Mechanics properties of the material
    # Type : MatMechanics
    mechanics = property(
        fget=_get_mechanics,
        fset=_set_mechanics,
        doc=u"""Mechanics properties of the material""",
    )

    def _get_thermics(self):
        """getter of thermics"""
        return self._thermics

    def _set_thermics(self, value):
        """setter of thermics"""
        check_var("thermics", value, "MatThermics")
        self._thermics = value

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

    # Thermics properties of the material
    # Type : MatThermics
    thermics = property(
        fget=_get_thermics,
        fset=_set_thermics,
        doc=u"""Thermics properties of the material""",
    )

    def _get_economical(self):
        """getter of economical"""
        return self._economical

    def _set_economical(self, value):
        """setter of economical"""
        check_var("economical", value, "MatEconomical")
        self._economical = value

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

    # Economical properties of the material
    # Type : MatEconomical
    economical = property(
        fget=_get_economical,
        fset=_set_economical,
        doc=u"""Economical properties of the material""",
    )

    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

    # material description
    # Type : str
    desc = property(fget=_get_desc,
                    fset=_set_desc,
                    doc=u"""material description""")
예제 #20
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"))
예제 #21
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 = MachineDFIM()

        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 = 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.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 = MatMagnetics(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"))
예제 #22
0
    def test_init(self):
        """Check that the Widget spinbox initialise to the lamination value"""
        self.assertEqual(self.widget.nav_ther.currentIndex(), 1)
        self.assertEqual(self.widget.nav_meca.currentIndex(), 1)
        self.assertEqual(self.widget.le_name.text(), "Magnet1")
        self.assertEqual(self.widget.is_isotropic.checkState(), Qt.Checked)
        self.assertEqual(self.widget.lf_rho_elec.value(), 0.11)
        self.assertEqual(self.widget.lf_mur_lin.value(), 0.12)
        self.assertEqual(self.widget.lf_Wlam.value(), 0.13)
        self.assertEqual(self.widget.lf_rho_meca.value(), 0.14)
        self.assertEqual(self.widget.lf_E.value(), 0.15)
        self.assertEqual(self.widget.lf_nu.value(), 0.16)
        self.assertEqual(self.widget.lf_G.value(), 0.17)
        self.assertEqual(self.widget.lf_L.value(), 0.18)
        self.assertEqual(self.widget.lf_Cp.value(), 0.19)
        self.assertEqual(self.widget.lf_alpha.value(), 0.2)
        self.assertEqual(self.widget.lf_cost_unit.value(), 0.21)

        # Test Raw Material
        self.test_obj.mag = None
        self.widget = DMatSetup(material=self.test_obj)

        self.assertEqual(self.widget.nav_ther.currentIndex(), 1)
        self.assertEqual(self.widget.nav_meca.currentIndex(), 1)
        self.assertEqual(self.widget.le_name.text(), "Magnet1")
        self.assertEqual(self.widget.is_isotropic.checkState(), Qt.Checked)
        self.assertEqual(self.widget.lf_rho_elec.value(), 0.11)
        self.assertEqual(self.widget.lf_rho_meca.value(), 0.14)
        self.assertEqual(self.widget.lf_E.value(), 0.15)
        self.assertEqual(self.widget.lf_nu.value(), 0.16)
        self.assertEqual(self.widget.lf_G.value(), 0.17)
        self.assertEqual(self.widget.lf_L.value(), 0.18)
        self.assertEqual(self.widget.lf_Cp.value(), 0.19)
        self.assertEqual(self.widget.lf_alpha.value(), 0.2)
        self.assertEqual(self.widget.lf_cost_unit.value(), 0.21)

        # Test Magnet material Non isotropic
        self.test_obj.is_isotropic = False
        self.test_obj.mag = MatMagnetics(mur_lin=0.22,
                                         Brm20=0.23,
                                         alpha_Br=0.24)
        self.widget = DMatSetup(material=self.test_obj)

        self.assertEqual(self.widget.nav_ther.currentIndex(), 0)
        self.assertEqual(self.widget.nav_meca.currentIndex(), 0)
        self.assertEqual(self.widget.le_name.text(), "Magnet1")
        self.assertEqual(self.widget.is_isotropic.checkState(), Qt.Unchecked)
        self.assertEqual(self.widget.lf_rho_elec.value(), 0.11)
        self.assertEqual(self.widget.lf_mur_lin.value(), 0.22)
        self.assertEqual(self.widget.lf_Brm20.value(), 0.23)
        self.assertEqual(self.widget.lf_alpha_Br.value(), 0.24)
        self.assertEqual(self.widget.lf_rho_meca.value(), 0.14)

        self.assertEqual(self.widget.lf_Ex.value(), 0.15)
        self.assertEqual(self.widget.lf_Ey.value(), 0.152)
        self.assertEqual(self.widget.lf_Ez.value(), 0.153)

        self.assertEqual(self.widget.lf_nu_xy.value(), 0.16)
        self.assertEqual(self.widget.lf_nu_yz.value(), 0.162)
        self.assertEqual(self.widget.lf_nu_xz.value(), 0.163)

        self.assertEqual(self.widget.lf_Gxy.value(), 0.17)
        self.assertEqual(self.widget.lf_Gyz.value(), 0.172)
        self.assertEqual(self.widget.lf_Gxz.value(), 0.173)

        self.assertEqual(self.widget.lf_Lx.value(), 0.18)
        self.assertEqual(self.widget.lf_Ly.value(), 0.182)
        self.assertEqual(self.widget.lf_Lz.value(), 0.183)

        self.assertEqual(self.widget.lf_Cp.value(), 0.19)
        self.assertEqual(self.widget.lf_alpha.value(), 0.2)
        self.assertEqual(self.widget.lf_cost_unit.value(), 0.21)
예제 #23
0
    def __init__(
        self,
        name="M400-50A",
        is_isotropic=False,
        elec=-1,
        mag=-1,
        struct=-1,
        HT=-1,
        eco=-1,
        desc="Lamination M400-50A",
        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 elec == -1:
            elec = MatElectrical()
        if mag == -1:
            mag = MatMagnetics()
        if struct == -1:
            struct = MatStructural()
        if HT == -1:
            HT = MatHT()
        if eco == -1:
            eco = MatEconomical()
        if init_dict is not None:  # Initialisation by dict
            check_init_dict(
                init_dict,
                [
                    "name", "is_isotropic", "elec", "mag", "struct", "HT",
                    "eco", "desc"
                ],
            )
            # Overwrite default value with init_dict content
            if "name" in list(init_dict.keys()):
                name = init_dict["name"]
            if "is_isotropic" in list(init_dict.keys()):
                is_isotropic = init_dict["is_isotropic"]
            if "elec" in list(init_dict.keys()):
                elec = init_dict["elec"]
            if "mag" in list(init_dict.keys()):
                mag = init_dict["mag"]
            if "struct" in list(init_dict.keys()):
                struct = init_dict["struct"]
            if "HT" in list(init_dict.keys()):
                HT = init_dict["HT"]
            if "eco" in list(init_dict.keys()):
                eco = init_dict["eco"]
            if "desc" in list(init_dict.keys()):
                desc = init_dict["desc"]
        # Initialisation by argument
        self.parent = None
        self.name = name
        self.is_isotropic = is_isotropic
        # elec can be None, a MatElectrical object or a dict
        if isinstance(elec, dict):
            self.elec = MatElectrical(init_dict=elec)
        else:
            self.elec = elec
        # mag can be None, a MatMagnetics object or a dict
        if isinstance(mag, dict):
            # Call the correct constructor according to the dict
            load_dict = {
                "MatLamination": MatLamination,
                "MatMagnet": MatMagnet,
                "MatMagnetics": MatMagnetics,
            }
            obj_class = mag.get("__class__")
            if obj_class is None:
                self.mag = MatMagnetics(init_dict=mag)
            elif obj_class in list(load_dict.keys()):
                self.mag = load_dict[obj_class](init_dict=mag)
            else:  # Avoid generation error or wrong modification in json
                raise InitUnKnowClassError(
                    "Unknow class name in init_dict for mag")
        else:
            self.mag = mag
        # struct can be None, a MatStructural object or a dict
        if isinstance(struct, dict):
            self.struct = MatStructural(init_dict=struct)
        else:
            self.struct = struct
        # HT can be None, a MatHT object or a dict
        if isinstance(HT, dict):
            self.HT = MatHT(init_dict=HT)
        else:
            self.HT = HT
        # eco can be None, a MatEconomical object or a dict
        if isinstance(eco, dict):
            self.eco = MatEconomical(init_dict=eco)
        else:
            self.eco = eco
        self.desc = desc

        # The class is frozen, for now it's impossible to add new properties
        self._freeze()
예제 #24
0
from pyleecan.Classes.Material import Material
from pyleecan.Classes.MatMagnetics import MatMagnetics

Magnet3 = Material(name="Magnet3")
Magnet3.mag = MatMagnetics()

Magnet3.elec.rho = 1.6e-06

Magnet3.mag.mur_lin = 1.05
Magnet3.mag.Hc = 909456.817667973
Magnet3.mag.alpha_Br = 0.0
Magnet3.mag.Brm20 = 1.2
Magnet3.mag.Wlam = 0

Magnet3.struct.rho = 7500.0
예제 #25
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 = MachineDFIM()
        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 = MatMagnetics(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 = MatMagnetics(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)

        tooth = test_obj.rotor.slot.get_surface_tooth()
        tooth.plot(color="r")
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Lam_Wind_s27_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_s27_Tooth_out.png"))
예제 #26
0
파일: Magnet1.py 프로젝트: BoGuo86/pyleecan
from pyleecan.Classes.Material import Material
from pyleecan.Classes.MatMagnetics import MatMagnetics

Magnet1 = Material(name="Magnet1")
Magnet1.mag = MatMagnetics()

Magnet1.elec.rho = 1.6e-06

Magnet1.mag.mur_lin = 1.05
Magnet1.mag.Hc = 757880.681389978
Magnet1.mag.alpha_Br = 0.0
Magnet1.mag.Brm20 = 1
Magnet1.mag.Wlam = 0

Magnet1.struct.rho = 7500.0
예제 #27
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"))
예제 #28
0
파일: Magnet5.py 프로젝트: BoGuo86/pyleecan
from pyleecan.Classes.Material import Material
from pyleecan.Classes.MatMagnetics import MatMagnetics

Magnet5 = Material(name="Magnet5")
Magnet5.mag = MatMagnetics()

Magnet5.elec.rho = 1.6e-06

Magnet5.mag.mur_lin = 1.05
Magnet5.mag.Hc = 917035.624481873
Magnet5.mag.alpha_Br = 0.0
Magnet5.mag.Brm20 = 1.21
Magnet5.mag.Wlam = 0

Magnet5.struct.rho = 7500.0