Ejemplo n.º 1
0
    def test_type_wind_DW1L(self):
        """Test Winding matrix plot for type_winding DW1L"""

        plt.close("all")

        test_obj = LamSlotWind(Rint=0.5, Rext=0.9, is_internal=False)
        test_obj.slot = SlotW21(Zs=24,
                                H0=20e-3,
                                H1=0,
                                H1_is_rad=False,
                                H2=0.2,
                                W0=30e-3,
                                W1=0.06,
                                W2=0.06)
        test_obj.winding = WindingDW1L(p=1, qs=3)

        test_obj.plot()
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Wind_DW1L_lam.png"))

        test_obj.plot_winding()
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Wind_DW1L_wind.png"))

        test_obj.slot.Zs = 36
        test_obj.winding = WindingDW1L(p=2, qs=3)
        test_obj.plot()
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Wind_DW1L_lam2.png"))

        test_obj.plot_winding()
        fig = plt.gcf()
        fig.savefig(join(save_path, "test_Wind_DW1L_wind2.png"))
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
stator = LamSlotWind(Rint=0.116,
                     Rext=0.2,
                     Nrvd=0,
                     L1=0.4,
                     Kf1=1,
                     is_internal=False,
                     is_stator=True)

stator.slot = SlotW22(Zs=12,
                      H0=4e-3,
                      H2=25e-3,
                      W0=0.6 * 12 * pi / 180,
                      W2=12 * pi / 180)
stator.winding = WindingDW1L(qs=3,
                             Lewout=15e-3,
                             p=1,
                             Ntcoil=12,
                             Npcpp=1,
                             Nslot_shift_wind=0)

stator.winding.conductor = CondType11(
    Nwppc_tan=1,
    Nwppc_rad=1,
    Wwire=2e-3,
    Hwire=2e-3,
    Wins_wire=1e-6,
    type_winding_shape=0,
)
# Rotor setup
rotor = LamSlotMag(Rext=0.1,
                   Rint=0.0225,
                   L1=0.4,
Ejemplo n.º 5
0
    Kf1=1,
    is_internal=False,
    is_stator=True,
)
stator.slot = SlotW21(Zs=48,
                      H0=1.0 * mm,
                      H1=0.5 * mm,
                      H2=14.5 * mm,
                      W0=2.0 * mm,
                      W1=5 * mm,
                      W2=7 * mm)
stator.winding = WindingDW1L(
    qs=3,  # number of phases
    Lewout=10 *
    mm,  # staight length of conductor outside lamination before EW-bend
    p=4,  # number of pole pairs
    Ntcoil=2,  # number of turns per coil
    Npcpp=1,  # number of parallel circuits per phase
    Nslot_shift_wind=0,  #
)
stator.winding.conductor = CondType12(
    Wwire=1.0 * mm,  # single wire without isolation
    Wins_wire=0.1 * mm,  # single wire isolation thickness
    Wins_cond=1.3 * mm,  # winding coil isolation
    Nwppc=1,  # number of strands in parallel per coil
    Kwoh=1,
)

# Rotor setup
rotor = LamHole(Rint=59 * mm / 2,
                Rext=158 * mm / 2,
Ejemplo n.º 6
0
stator = LamSlotWind(Rint=0.061,
                     Rext=0.1,
                     Nrvd=0,
                     L1=0.2,
                     Kf1=1,
                     is_internal=False,
                     is_stator=True)

stator.slot = SlotW22(Zs=36,
                      H0=0.002,
                      H2=0.022,
                      W0=0.0523598775598,
                      W2=0.0872664625997)
stator.winding = WindingDW1L(qs=3,
                             Lewout=0,
                             p=2,
                             Ntcoil=15,
                             Npcpp=1,
                             coil_pitch=9)

stator.winding.conductor = CondType12(Nwppc=1,
                                      Wwire=0.0005,
                                      Wins_wire=1e-06,
                                      Kwoh=0)
# Rotor setup
rotor = LamSquirrelCage(
    Rext=0.06,
    Rint=0,
    L1=0.2,
    Kf1=1,
    is_internal=True,
    is_stator=False,
Ejemplo n.º 7
0
    is_stator=True,
)

stator.slot = SlotW11(
    Zs=24,
    H0=0.00075,
    H1=0.4363323129985824,
    H1_is_rad=True,
    H2=0.015,
    W0=0.00268,
    W1=0.006828,
    W2=0.009,
)
stator.winding = WindingDW1L(qs=3,
                             Lewout=15e-3,
                             p=2,
                             Ntcoil=30,
                             Npcpp=1,
                             coil_pitch=6)

stator.winding.conductor = CondType12(Nwppc=1,
                                      Wwire=0.001,
                                      Kwoh=0.5,
                                      Wins_wire=1e-6)
# Rotor setup
rotor = LamHole(Rext=0.0406,
                Rint=0,
                L1=0.101,
                Kf1=0.96,
                is_internal=True,
                is_stator=False,
                Nrvd=0)
Ejemplo n.º 8
0
    is_internal=False,
    is_stator=True,
)

stator.slot = SlotW11(Zs=48,
                      H0=1e-3,
                      H1=0,
                      H2=0.0333,
                      W0=0.00193,
                      W1=0.005,
                      W2=0.008,
                      R1=0.004)
stator.winding = WindingDW1L(qs=3,
                             Lewout=0,
                             p=4,
                             Ntcoil=9,
                             Npcpp=1,
                             Nslot_shift_wind=2,
                             is_reverse_wind=True)

stator.winding.conductor = CondType11(
    Nwppc_tan=1,
    Nwppc_rad=1,
    Wwire=0.000912,
    Hwire=2e-3,
    Wins_wire=1e-6,
    type_winding_shape=0,
)
# Rotor setup
rotor = LamHole(
    Rext=80.2e-3,
Ejemplo n.º 9
0
I_2 = ImportMatrixVal(value=zeros((100, 3)))
I_3 = ImportMatrixVal(value=zeros((2, 100)))
I_4 = ImportMatrixVal(value=zeros((100)))

angle_rotor_wrong = ImportMatrixVal(value=zeros((10, 2)))
angle_rotor_wrong2 = ImportMatrixVal(value=zeros((102)))
angle_rotor = ImportMatrixVal(value=zeros((100)))

Nr_wrong = ImportMatrixVal(value=zeros((10, 2)))
Nr_wrong2 = ImportMatrixVal(value=zeros((102)))
Nr = ImportMatrixVal(value=zeros((100)))

# Winding stator only
M1 = MachineIPMSM()
M1.stator = LamSlotWind()
M1.stator.winding = WindingDW1L()
M1.stator.winding.qs = 3

# Machine without 'comp_initial_angle' method
M2 = MachineDFIM()
M2.stator = LamSlotWind()
M2.stator.winding.qs = 3
M2.rotor.winding = None

# Wrong time
test_obj = Simulation()
test_obj.input = InCurrentDQ(time=None)
InCurrentDQ_Error_test.append({
    "test_obj": test_obj,
    "exp": "ERROR: InCurrentDQ.time missing"
})