def test_InCurrent_Ok(self): """Check that the input current can return a correct output """ test_obj = Simulation(machine=M3) output = Output(simu=test_obj) time = ImportGenVectLin(0, 1, 16) angle = ImportGenVectLin(0, 2 * pi, 20) Is = ImportGenMatrixSin(is_transpose=True) Is.init_vector(f=[2, 2, 2], A=[2, 2, 2], Phi=[pi / 2, 0, -pi / 2], N=16, Tf=1) S = sqrt(2) Is_exp = transpose( array([ [2, S, 0, -S, -2, -S, 0, S, 2, S, 0, -S, -2, -S, 0, S], [0, S, 2, S, 0, -S, -2, -S, 0, S, 2, S, 0, -S, -2, -S], [-2, -S, 0, S, 2, S, 0, -S, -2, -S, 0, S, 2, S, 0, -S], ])) Ir = ImportGenMatrixSin(is_transpose=True) Ir.init_vector(f=[2, 2], A=[2, 2], Phi=[0, -pi / 2], N=16, Tf=1) Ir_exp = transpose( array([ [0, S, 2, S, 0, -S, -2, -S, 0, S, 2, S, 0, -S, -2, -S], [-2, -S, 0, S, 2, S, 0, -S, -2, -S, 0, S, 2, S, 0, -S], ])) angle_rotor = ImportGenVectLin(0, 2 * pi, 16) Nr = ImportMatrixVal(value=ones(16) * 10) test_obj.input = InCurrent(time=time, angle=angle, Is=Is, Ir=Ir, angle_rotor=angle_rotor, Nr=Nr) test_obj.input.gen_input() assert_array_almost_equal(output.elec.time, linspace(0, 1, 16)) assert_array_almost_equal(output.elec.angle, linspace(0, 2 * pi, 20)) assert_array_almost_equal(output.elec.Is, Is_exp) assert_array_almost_equal(output.elec.Ir, Ir_exp) assert_array_almost_equal(output.elec.angle_rotor, linspace(0, 2 * pi, 16)) assert_array_almost_equal(output.elec.Nr, ones(16) * 10)
def test_InCurrentDQ_Ok(self): """Check that the input current can return a correct output """ test_obj = Simulation(machine=M1) output = Output(simu=test_obj) time = ImportGenVectLin(0, 1, 7) angle = ImportGenVectLin(0, 2 * pi, 20) Is = ImportMatrixVal(value=transpose( array([ [2, 2, 2, 2, 2, 2, 2], [0, 0, 0, 0, 0, 0, 0], ]))) Is_exp = transpose( array([ [2, 1, -1, -2, -1, 1, 2], [-1, 1, 2, 1, -1, -2, -1], [-1, -2, -1, 1, 2, 1, -1], ])) zp = M1.stator.get_pole_pair_number() angle_rotor_initial = M1.comp_initial_angle() angle_rotor_exp = linspace(0, 2 * pi / zp, 7) + angle_rotor_initial Nr = ImportMatrixVal(value=ones(7) * 60 / zp) test_obj.input = InCurrentDQ(time=time, angle=angle, Is=Is, Ir=None, angle_rotor=None, Nr=Nr, angle_rotor_initial=angle_rotor_initial, rot_dir=1) test_obj.input.gen_input() assert_array_almost_equal(output.elec.time, linspace(0, 1, 7)) assert_array_almost_equal(output.elec.angle, linspace(0, 2 * pi, 20)) assert_array_almost_equal(output.elec.Is, Is_exp) assert_array_almost_equal(output.elec.angle_rotor, angle_rotor_exp) assert_array_almost_equal(output.elec.Nr, ones(7) * 60 / zp)
M1.stator = LamSlotWind() M1.stator.winding.qs = 3 # Winding rotor only M2 = Machine() M2.rotor = LamSlotWind() M2.rotor.winding.qs = 2 # Winding rotor + stator M3 = Machine() M3.stator = LamSlotWind() M3.stator.winding.qs = 3 M3.rotor = LamSlotWind() M3.rotor.winding.qs = 2 # Wrong time test_obj = Simulation() test_obj.input = InCurrent(time=None) InCurrent_Error_test.append({ "test_obj": test_obj, "exp": "ERROR: InCurrent.time missing" }) test_obj = Simulation() test_obj.input = InCurrent(time=time_wrong) InCurrent_Error_test.append({ "test_obj": test_obj, "exp": "ERROR: InCurrent.time should be a vector, (10, 2) shape found", }) # Wrong angle test_obj = Simulation() test_obj.input = InCurrent(time=time, angle=None)