Beispiel #1
0
    def test_init(self):
        """Check that the Widget spinbox initialise to the lamination value"""

        self.assertEqual(self.widget.lf_H0.value(), 0.10)
        self.assertEqual(self.widget.lf_H1.value(), 0.11)
        self.assertEqual(self.widget.lf_H2.value(), 0.12)
        self.assertEqual(self.widget.lf_W0.value(), 0.13)
        self.assertEqual(self.widget.lf_W1.value(), 0.14)
        self.assertEqual(self.widget.lf_W2.value(), 0.15)
        # Index 0 is m
        self.assertEqual(self.widget.c_H1_unit.currentIndex(), 0)

        self.test_obj.slot = SlotW10(H0=0.20,
                                     H1=0.21,
                                     H2=0.22,
                                     W0=0.23,
                                     W1=0.24,
                                     W2=0.25,
                                     H1_is_rad=True)
        self.widget = PWSlot10(self.test_obj)
        self.assertEqual(self.widget.lf_H0.value(), 0.20)
        self.assertEqual(self.widget.lf_H1.value(), 0.21)
        self.assertEqual(self.widget.lf_H2.value(), 0.22)
        self.assertEqual(self.widget.lf_W0.value(), 0.23)
        self.assertEqual(self.widget.lf_W1.value(), 0.24)
        self.assertEqual(self.widget.lf_W2.value(), 0.25)
        # Index 1 is rad
        self.assertEqual(self.widget.c_H1_unit.currentIndex(), 1)
Beispiel #2
0
    def test_slot_10(self):
        """Check that you can generate the 3D mesh of Slot 10
        """
        # SetUp
        stator = LamSlotWind(
            Rint=0.1325,
            Rext=0.2,
            Nrvd=0,
            L1=0.35,
            Kf1=0.95,
            is_internal=False,
            is_stator=True,
        )

        stator.slot = SlotW10(Zs=36,
                              H0=1e-3,
                              H1=1.5e-3,
                              H2=30e-3,
                              W0=12e-3,
                              W1=14e-3,
                              W2=12e-3)
        gen_3D_mesh(
            lamination=stator,
            save_path=join(save_path, "Lamination.msh"),
            mesh_size=5e-3,
            Nlayer=20,
        )
    def test_save_load_machine(self):
        """Check that you can save and load a machine object
        """
        # SetUp
        test_obj = MachineSIPMSM(name="test", desc="test\non\nseveral lines")
        test_obj.stator = LamSlotWind(L1=0.45)
        test_obj.stator.slot = SlotW10(Zs=10, H0=0.21, W0=0.23)
        test_obj.stator.winding = WindingDW1L(qs=5)
        test_obj.rotor = LamSlotMag(L1=0.55)
        test_obj.rotor.slot = SlotMPolar(W0=pi / 4)
        test_obj.rotor.slot.magnet = [MagnetType11(Wmag=pi / 4, Hmag=3)]
        test_obj.shaft = Shaft(Lshaft=0.65)
        test_obj.frame = None

        # Save Test
        file_path = join(save_dir, "test_machine.json")
        if isfile(file_path):
            remove(file_path)
        self.assertFalse(isfile(file_path))
        test_obj.save(file_path)
        self.assertTrue(isfile(file_path))

        # Load Test
        result = load(file_path)
        self.assertTrue(type(result) is MachineSIPMSM)
        self.assertEqual(result.name, "test")
        self.assertEqual(result.desc, "test\non\nseveral lines")

        self.assertTrue(type(result.stator) is LamSlotWind)
        self.assertEqual(result.stator.L1, 0.45)

        self.assertTrue(type(result.stator.slot) is SlotW10)
        self.assertEqual(result.stator.slot.Zs, 10)
        self.assertEqual(result.stator.slot.H0, 0.21)
        self.assertEqual(result.stator.slot.W0, 0.23)

        self.assertTrue(type(result.stator.winding) is WindingDW1L)
        self.assertEqual(result.stator.winding.qs, 5)

        self.assertTrue(type(result.rotor) is LamSlotMag)
        self.assertEqual(result.rotor.L1, 0.55)

        self.assertTrue(type(result.rotor.slot) is SlotMPolar)
        self.assertEqual(result.rotor.slot.W0, pi / 4)

        self.assertTrue(type(result.rotor.slot.magnet) is list)
        self.assertTrue(type(result.rotor.slot.magnet[0]) is MagnetType11)
        self.assertEqual(len(result.rotor.slot.magnet), 1)
        self.assertEqual(result.rotor.slot.magnet[0].Wmag, pi / 4)
        self.assertEqual(result.rotor.slot.magnet[0].Hmag, 3)

        self.assertTrue(type(result.shaft) is Shaft)
        self.assertEqual(result.shaft.Lshaft, 0.65)

        self.assertEqual(result.frame, None)
Beispiel #4
0
    def setUp(self):
        """Run at the begining of every test to setup the gui"""

        self.test_obj = LamSlotWind(Rint=0.1, Rext=0.2)
        self.test_obj.slot = SlotW10(H0=0.10,
                                     H1=0.11,
                                     H2=0.12,
                                     W0=0.13,
                                     W1=0.14,
                                     W2=0.15,
                                     H1_is_rad=False)
        self.widget = PWSlot10(self.test_obj)
Beispiel #5
0
 def test_output_txt(self):
     """Check that the Output text is computed and correct
     """
     self.test_obj.slot = SlotW10(H0=0.005,
                                  H1=0.005,
                                  H2=0.02,
                                  W0=0.01,
                                  W1=0.02,
                                  W2=0.01,
                                  H1_is_rad=False)
     self.widget = PWSlot10(self.test_obj)
     self.assertEqual(self.widget.w_out.out_slot_height.text(),
                      "Slot height: 0.03006 m")
Beispiel #6
0
    def setUp(self):
        """Run at the begining of every test to setup the gui"""

        self.test_obj = MachineSCIM()
        self.test_obj.stator = LamSlotWind(Rint=0.1, Rext=0.2)
        self.test_obj.stator.slot = SlotW10(
            Zs=123,
            H0=0.10,
            H1=0.11,
            H2=0.12,
            W0=0.13,
            W1=0.14,
            W2=0.15,
            H1_is_rad=False,
        )
        self.widget = SWSlot(self.test_obj, matlib=[], is_stator=True)
    def test_save_load_just_name(self):
        """Save with a folder path
        """

        test_obj = SlotW10(Zs=10)

        file_path = join(getcwd(), "test_slot.json")
        if isfile(file_path):
            remove(file_path)
        self.assertFalse(isfile(file_path))
        test_obj.save("test_slot")
        self.assertTrue(isfile(file_path))

        result = load("test_slot")
        self.assertTrue(type(result) is SlotW10)
        self.assertEqual(result.Zs, 10)
    def test_build_geometry(self):
        """check that curve_list is correct"""
        test_obj = SlotW10(W0=0.2,
                           H0=0.1,
                           W1=0.4,
                           H1=0.1,
                           H1_is_rad=False,
                           H2=0.1,
                           W2=0.6)
        lam = LamSlot(is_internal=False, slot=test_obj, Rint=1)

        # Rbo=1
        Z10 = exp(1j * float(arcsin(0.1)))
        Z9 = Z10 + 0.1
        Z8 = Z10 + 0.1j + 0.2
        Z7 = Z10 + 0.2
        Z6 = Z10 + 0.2j + 0.3
        Z5 = Z10 - 0.4j + 0.3
        Z4 = Z10 - 0.2j + 0.2
        Z3 = Z10 - 0.3j + 0.2
        Z2 = Z10 - 0.2j + 0.1
        Z1 = Z10 - 0.2j

        # Creation of curve
        curve_list = list()
        curve_list.append(Segment(Z1, Z2))
        curve_list.append(Segment(Z2, Z3))
        curve_list.append(Segment(Z3, Z4))
        curve_list.append(Segment(Z4, Z5))
        curve_list.append(Segment(Z5, Z6))
        curve_list.append(Segment(Z6, Z7))
        curve_list.append(Segment(Z7, Z8))
        curve_list.append(Segment(Z8, Z9))
        curve_list.append(Segment(Z9, Z10))

        result = test_obj.build_geometry()
        self.assertEqual(len(result), len(curve_list))
        for i in range(0, len(result)):
            a = result[i].begin
            b = curve_list[i].begin
            self.assertAlmostEqual((a - b) / a, 0, delta=DELTA)

            a = result[i].end
            b = curve_list[i].end
            self.assertAlmostEqual((a - b) / a, 0, delta=DELTA)
Beispiel #9
0
def test_save_load_dict(self):
    """Test the save and load function of data structures
        """
    # SetUp
    test_obj_1 = MachineSIPMSM(name="test", desc="test\non\nseveral lines")
    test_obj_1.stator = LamSlotWind(L1=0.45)
    test_obj_1.stator.slot = SlotW10(Zs=10, H0=0.21, W0=0.23)
    test_obj_1.stator.winding = WindingDW1L(qs=5)
    test_obj_1.rotor = LamSlotMag(L1=0.55)
    test_obj_1.rotor.slot = SlotMPolar(W0=pi / 4)
    test_obj_1.rotor.slot.magnet = [MagnetType11(Wmag=pi / 4, Hmag=3)]
    test_obj_1.shaft = Shaft(Lshaft=0.65)
    test_obj_1.frame = None

    test_obj_2 = LamSlotWind(L1=0.45)

    test_obj_3 = {"H0": 0.001, "Zs": 10, "__class__": "ClassDoesntExist"}

    test_obj_4 = tuple([1, 2, 3])

    test_dict = {
        "tuple": test_obj_4,
        "list": [test_obj_1, None],
        "dict": {"test_obj_2": test_obj_2, "test_obj_list": [test_obj_3, None]},
    }

    # Save Test
    file_path = join(save_path, "test_dict.json")
    if isfile(file_path):
        remove(file_path)
    self.assertFalse(isfile(file_path))
    save_data(test_dict, file_path)
    self.assertTrue(isfile(file_path))

    # Load Test
    result_dict = load_dict(file_path)
    # set tuple to None as save will do
    test_dict["tuple"] = None
    self.assertEqual(result_dict, test_dict)
    def test_Lam_Wind_10_wind_22(self):
        """Test machine plot with Slot 10 and winding rad=2, tan=2
		"""
        print("\nTest plot Slot 10")
        plt.close("all")
        test_obj = Machine()
        test_obj.rotor = LamSlotWind(
            Rint=0.2,
            Rext=0.5,
            is_internal=True,
            is_stator=False,
            L1=0.95,
            Nrvd=1,
            Wrvd=0.05,
        )
        test_obj.rotor.slot = SlotW10(
            Zs=6,
            W0=50e-3,
            W1=90e-3,
            W2=100e-3,
            H0=20e-3,
            H1=35e-3,
            H2=130e-3,
            H1_is_rad=False,
        )
        test_obj.rotor.winding = WindingUD(user_wind_mat=wind_mat,
                                           qs=4,
                                           p=4,
                                           Lewout=60e-3)
        test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=1)
        test_obj.shaft.mat_type.name = "M270_35A"
        test_obj.shaft.mat_type.magnetics = None

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

        test_obj.stator = LamSlotWind(
            Rint=0.51,
            Rext=0.8,
            is_internal=False,
            is_stator=True,
            L1=0.95,
            Nrvd=1,
            Wrvd=0.05,
        )
        test_obj.stator.slot = SlotW10(
            Zs=6,
            W0=50e-3,
            W1=80e-3,
            W2=50e-3,
            H0=15e-3,
            H1=25e-3,
            H2=140e-3,
            H1_is_rad=False,
        )
        test_obj.stator.winding = WindingUD(user_wind_mat=wind_mat,
                                            qs=4,
                                            p=4,
                                            Lewout=60e-3)
        test_obj.stator.mat_type.name = "Param"
        test_obj.stator.mat_type.magnetics = MatLamination(Wlam=0.5e-3)
        BH = BHCurveParam(Bmax=1.5, mur_0=8585, mur_1=21.79, a=0.25575)
        test_obj.stator.mat_type.magnetics.BH_curve = BH

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

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

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

        test_obj.stator.plot()
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Lam_Wind_s10_3-Stator.png"))
        # 2 for lam + Zs*4 for wind
        self.assertEqual(len(fig.axes[0].patches), 26)
Beispiel #11
0
from pyleecan.Tests.Validation.Material.Copper1 import Copper1
from pyleecan.Tests.Validation.Material.M400_50A import M400_50A

# Stator setup
stator = LamSlotWind(Rint=0.1325,
                     Rext=0.2,
                     Nrvd=0,
                     L1=0.35,
                     Kf1=0.95,
                     is_internal=False,
                     is_stator=True)

stator.slot = SlotW10(Zs=36,
                      H0=1e-3,
                      H1=1.5e-3,
                      H2=30e-3,
                      W0=12e-3,
                      W1=14e-3,
                      W2=12e-3)
stator.winding = WindingDW2L(qs=3,
                             Lewout=15e-3,
                             p=3,
                             coil_pitch=5,
                             Ntcoil=7,
                             Npcpp=2)

stator.winding.conductor = CondType11(Nwppc_tan=1,
                                      Nwppc_rad=1,
                                      Wwire=10e-3,
                                      Hwire=2e-3,
                                      Wins_wire=0,
Beispiel #12
0
    def test_Lam_Wind_10_wind_22(self):
        """Test machine plot with Slot 10 and winding rad=2, tan=2
		"""
        print("\nTest plot Slot 10")
        plt.close("all")
        test_obj = Machine()
        test_obj.rotor = LamSlotWind(
            Rint=0.2,
            Rext=0.5,
            is_internal=True,
            is_stator=False,
            L1=0.95,
            Nrvd=1,
            Wrvd=0.05,
        )
        test_obj.rotor.slot = SlotW10(
            Zs=6,
            W0=50e-3,
            W1=90e-3,
            W2=100e-3,
            H0=20e-3,
            H1=35e-3,
            H2=130e-3,
            H1_is_rad=False,
        )
        test_obj.rotor.winding = WindingUD(
            user_wind_mat=wind_mat, qs=4, p=4, Lewout=60e-3
        )
        test_obj.shaft = Shaft(Drsh=test_obj.rotor.Rint * 2, Lshaft=1)

        test_obj.stator = LamSlotWind(
            Rint=0.51,
            Rext=0.8,
            is_internal=False,
            is_stator=True,
            L1=0.95,
            Nrvd=1,
            Wrvd=0.05,
        )
        test_obj.stator.slot = SlotW10(
            Zs=6,
            W0=50e-3,
            W1=80e-3,
            W2=50e-3,
            H0=15e-3,
            H1=25e-3,
            H2=140e-3,
            H1_is_rad=False,
        )
        test_obj.stator.winding = WindingUD(
            user_wind_mat=wind_mat, qs=4, p=4, Lewout=60e-3
        )

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

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

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

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

        lines = test_obj.stator.slot.build_geometry_half_tooth(is_top=False)
        surf = SurfLine(line_list=lines)
        surf.plot_lines()
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Lam_Wind_s10_Tooth_bottom_out.png"))

        lines = test_obj.stator.slot.build_geometry_half_tooth(is_top=True)
        surf = SurfLine(line_list=lines)
        surf.plot_lines()
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Lam_Wind_s10_Tooth_top_out.png"))

        lines = test_obj.rotor.slot.build_geometry_half_tooth(is_top=False)
        surf = SurfLine(line_list=lines)
        surf.plot_lines()
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Lam_Wind_s10_Tooth_bottom_in.png"))

        lines = test_obj.rotor.slot.build_geometry_half_tooth(is_top=True)
        surf = SurfLine(line_list=lines)
        surf.plot_lines()
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Lam_Wind_s10_Tooth_top_in.png"))

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

        tooth = test_obj.stator.slot.get_surface_tooth()
        tooth.plot(color="r")
        fig = plt.gcf()
        mesh_dict = tooth.comp_mesh_dict(5e-3)
        for line in tooth.get_lines():
            mid = line.get_middle()
            plt.text(mid.real, mid.imag, str(mesh_dict[line.label]))
        fig.savefig(join(save_path, "test_Lam_Wind_s10_Tooth_out.png"))
Beispiel #13
0
    def __init__(self, machine, matlib=[], is_stator=False):
        """Initialize the GUI according to machine

        Parameters
        ----------
        self : SWSlot
            A SWSlot widget
        machine : Machine
            current machine to edit
        matlib : list
            List of available Material
        is_stator : bool
            To adapt the GUI to set either the stator or the rotor
        """

        # Build the interface according to the .ui file
        QWidget.__init__(self)
        self.setupUi(self)

        # Saving arguments
        self.machine = machine
        self.matlib = matlib
        self.is_stator = is_stator

        self.b_help.url = "https://eomys.com/produits/manatee/howtos/article/"
        self.b_help.url += "how-to-set-up-the-slots"

        # Fill the combobox with the available slot
        self.c_slot_type.clear()
        for slot in SLOT_NAME:
            self.c_slot_type.addItem(slot)
        # Avoid erase all the parameters when navigating though the slots
        self.previous_slot = dict()
        for slot_type in INIT_INDEX:
            self.previous_slot[slot_type] = None

        if self.is_stator:
            self.obj = machine.stator
        else:
            self.obj = machine.rotor

        # If the Slot is not set, initialize it with a 1_0
        if self.obj.slot is None or type(self.obj.slot) in [SlotWind, Slot]:
            self.obj.slot = SlotW10()
            self.obj.slot._set_None()

        if self.obj.slot.Zs is None:
            self.si_Zs.clear()
        else:
            self.si_Zs.setValue(self.obj.slot.Zs)

        self.set_slot_pitch(self.obj.slot.Zs)

        # Set the correct index for the type checkbox and display the object
        index = INIT_INDEX.index(type(self.obj.slot))
        self.c_slot_type.setCurrentIndex(index)

        # Update the slot widget
        self.s_update_slot()

        # Connect the slot
        self.c_slot_type.currentIndexChanged.connect(self.s_change_slot)
        self.si_Zs.editingFinished.connect(self.set_Zs)
        self.b_plot.clicked.connect(self.s_plot)
    def test_build_geometry_wind(self):
        """Check if the surface of winding surface is correct
        """
        test_obj = SlotW10(W0=0.2,
                           H0=0.1,
                           W1=0.4,
                           H1=0.1,
                           H1_is_rad=False,
                           H2=0.1,
                           W2=0.6)
        lam = LamSlot(is_internal=False, slot=test_obj, Rint=1)

        # Rbo=1
        Z1 = exp(1j * float(arcsin(0.1)))
        Z2 = Z1 + 0.1
        Z3 = Z1 + 0.1j + 0.2
        Z4 = Z1 + 0.2
        Z5 = Z1 + 0.2j + 0.3
        Z6 = Z1 - 0.4j + 0.3
        Z7 = Z1 - 0.2j + 0.2
        Z8 = Z1 - 0.3j + 0.2
        Z9 = Z1 - 0.2j + 0.1
        Z10 = Z1 - 0.2j

        Ztan1 = (Z4 + Z7) / 2.0
        Ztan2 = (Z5 + Z6) / 2.0
        expected = list()
        # part(0,0)
        curve_list = list()
        curve_list.append(Segment(Z7, Ztan1))
        curve_list.append(Segment(Ztan1, Ztan2))
        curve_list.append(Segment(Ztan2, Z6))
        curve_list.append(Segment(Z6, Z7))
        point_ref = (Z7 + Ztan1 + Ztan2 + Z6) / 4

        surface = SurfLine(line_list=curve_list,
                           point_ref=point_ref,
                           label="WindS_R0_T0_S0")
        expected.append(surface)

        # part(0,1)
        curve_list = list()
        curve_list.append(Segment(Ztan1, Z4))
        curve_list.append(Segment(Z4, Z5))
        curve_list.append(Segment(Z5, Ztan2))
        curve_list.append(Segment(Ztan2, Ztan1))
        point_ref = (Z4 + Ztan1 + Ztan2 + Z5) / 4
        surface = SurfLine(line_list=curve_list,
                           point_ref=point_ref,
                           label="WindS_R0_T1_S0")
        expected.append(surface)

        result = test_obj.build_geometry_wind(Nrad=1, Ntan=2)
        self.assertEqual(len(result), len(expected))
        for i in range(0, len(result)):
            self.assertEqual(len(result[i].line_list),
                             len(expected[i].line_list))
            for jj in range(len(result[i].line_list)):
                a = result[i].line_list[jj].begin
                b = expected[i].line_list[jj].begin
                self.assertAlmostEqual((a - b) / a, 0, delta=DELTA)

                a = result[i].line_list[jj].end
                b = expected[i].line_list[jj].end
                self.assertAlmostEqual((a - b) / a, 0, delta=DELTA)

            self.assertTrue(result[i].label == expected[i].label)
from pyleecan.Methods.Slot.Slot.comp_height import comp_height
from pyleecan.Methods.Slot.Slot.comp_surface import comp_surface
from pyleecan.Methods.Slot.Slot.comp_angle_opening import comp_angle_opening
from pyleecan.Methods.Slot.SlotWind.comp_surface_wind import comp_surface_wind

# For AlmostEqual
DELTA = 1e-6

slotW10_test = list()

# Internal Slot
lam = LamSlot(is_internal=True, Rext=0.1325)
lam.slot = SlotW10(H0=1e-3,
                   H1=1.5e-3,
                   H2=30e-3,
                   W0=12e-3,
                   W1=14e-3,
                   W2=12e-3,
                   H1_is_rad=False)
slotW10_test.append({
    "test_obj": lam,
    "S_exp": 3.9258746e-4,
    "Aw": 0.1044713,
    "SW_exp": 3.6e-4,
    "H_exp": 3.263591e-2,
})

# Outward Slot
lam = LamSlot(is_internal=False, Rint=0.1325)
lam.slot = SlotW10(H0=1e-3,
                   H1=1.5e-3,