Commit f70bd6a9 authored by William Gurecky's avatar William Gurecky
Browse files

improve parks transform

parent 068963be
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -36,6 +36,9 @@ def parks_transform(in_vec, gamma, beta_0=BETA_1, beta_d=BETA_2, beta_q=BETA_3,
             beta_q * np.sin(gamma+np.pi*2/3.)],
        ])
    if inv_transform:
        if beta_0 == 1. / np.sqrt(3.) and beta_d == beta_q == np.sqrt(2./3.):
            out_vec = np.matmul(w_matrix.T, in_vec)
        else:
            out_vec = np.matmul(np.linalg.inv(w_matrix), in_vec)
    else:
        out_vec = np.matmul(w_matrix, in_vec)
@@ -165,7 +168,7 @@ class sync_gen5(object):
        X_d_pp = self.machine_params["Xd2"]
        X_q_pp = self.machine_params["Xq2"]
        P_e = (self.x[4]*I_d + self.x[3]*I_q) + (X_d_pp - X_q_pp)*I_d*I_q
        return P_e
        return P_e * 3.

    @property
    def torque_e(self):
@@ -274,7 +277,7 @@ def test_gen5():
        w_list.append(gen5.w)
        t_list.append(t)

        aV = gen5.arm_v(R=100.0)
        aV = gen5.arm_v(R=0.0)
        V_0, V_d, V_q = 0., aV[0], aV[1]
        # Eq. 11.80
        v_0dq = np.array([V_0, V_d, V_q]) * np.sqrt(3.)
@@ -289,6 +292,15 @@ def test_gen5():
        print("Time: %0.3e, omega: %0.5e, P_e: %0.3e, P_g: %0.3e, %0.3e" % \
             (t, gen5.w, gen5.power_e, p_g, p_g_b))

        # active and reactive power
        # Eq. 3.23 from book  by Weijia Yang
        # Hydropower Plants and Power Systems
        p_EQ = np.matmul(np.array([[V_d, V_q], [V_q, -V_d]]),
                         np.array([I_d, I_q]))
        P_active = p_EQ[0] # * 3.
        P_reactive = p_EQ[1]
        print("P_EQ: ", P_active, P_reactive)

    t_list = np.asarray(t_list)
    p_e_list = np.asarray(p_e_list)
    w_list = np.asarray(w_list)