Template Class Generator4Param

Inheritance Relationships

Base Type

Class Documentation

template<class ScalarT, typename IdxT>
class Generator4Param : public GridKit::ModelEvaluatorImpl<ScalarT, IdxT>

Implementation of a fourth order generator model.

Public Functions

Generator4Param(BaseBus<ScalarT, IdxT> *bus, ScalarT P0 = 1.0, ScalarT Q0 = 0.0)

Constructor for a simple generator model.

Arguments passed to ModelEvaluatorImpl:

  • Number of equations = 4 differential + 2 algebraic = 6

  • Number of quadratures = 1

  • Number of optimization parameters = 1

virtual int allocate()

This function will be used to allocate sparse Jacobian matrices.

virtual int initialize()

Initialization of the generator model.

Initialization equations are derived from example 9.2 in Power System Modeling and Scripting, Federico Milano, Chapter 9, p. 225:

\[\begin{split}\begin{eqnarray*} &~& \omega_0 = 0, \\ &~& \delta_0 = \tan^{-1} \left(\frac{X_q P_0 - R_s Q_0}{V_0^2 + R_s P_0 + X_q Q_0} \right) + \theta_0, \\ &~& \phi_0 = \delta_0 - \theta_0 + \tan^{-1} \left( \frac{Q_0}{P_0} \right), \\ &~& I_{d0} = \frac{\sqrt{P_0^2 + Q_0^2}}{V_0} \sin(\phi_0), \\ &~& I_{q0} = \frac{\sqrt{P_0^2 + Q_0^2}}{V_0} \cos(\phi_0), \\ &~& E_{d0}' = V_0 \sin(\delta_0 - \theta_0) + R_s I_{d0} - X_q' I_{q0}, \\ &~& E_{q0}' = V_0 \cos(\delta_0 - \theta_0) + R_s I_{q0} + X_d' I_{d0} \end{eqnarray*}\end{split}\]

The input from exciter and governor is set to the steady state value:

\[\begin{split}\begin{eqnarray*} &~& E_{f0} = E_{q0}' + (X_d - X_d') I_{d0}, \\ &~& P_{m0} = E_{d0}' I_{d0} + E_{q0}' I_{q0} + ( X_q' - X_d') I_{d0} I_{q0} \end{eqnarray*}\end{split}\]

virtual int tagDifferentiable()

Identify differential variables.

virtual int evaluateResidual()

Computes residual vector for the generator model.

Residual equations are given per model in Power System Modeling and Scripting, Federico Milano, Chapter 15, p. 334:

\[\begin{split}\begin{eqnarray*} f_0: &~& \dot{\delta} -\omega_b (\omega - \omega_s), \\ f_1: &~& 2H/\omega_s \dot{\omega} - L_m(P_m) + E_q' I_q + E_d' I_d + (X_q' - X_d')I_d I_q + D (\omega - \omega_s), \\ f_2: &~& T_{q0}' \dot{E}_d' + E_d' - (X_q - X_q')I_q, \\ f_3: &~& T_{d0}' \dot{E}_q' + E_q' + (X_d - X_d')I_d - E_f, \\ f_4: &~& R_s I_d - X_q' I_q + V \sin(\delta - \theta) - E_d', \\ f_5: &~& R_s I_q + X_d' I_d + V \cos(\delta - \theta) - E_q', \end{eqnarray*}\end{split}\]
where \( \Omega_b \) is the synchronous frequency in [rad/s], and overdot denotes time derivative.

Generator injection active and reactive power are

\[\begin{split}\begin{eqnarray*} P_g &=& E_d' I_d + E_q' I_q + (X_q' - X_d') I_d I_q - R_s (I_d^2 + I_q^2), \\ Q_q &=& E_q' I_d - E_d' I_q - X_q' I_q^2 - X_d' I_d^2, \\ \end{eqnarray*}\end{split}\]
respectively.

State variables are: \( y_0 = \omega \), \( y_1 = \delta \), \( y_2 = E_d' \), \( y_3 = E_q' \), \( y_4 = I_d \), \( y_5 = I_q \).

virtual int evaluateAdjointResidual()

Computes adjoint residual vector for the generator model.

Adjoint residual equations are given as:

\[\begin{split}\begin{eqnarray*} f_{B0}: &~& \dot{y}_{B0} - y_{B4} V \cos(\delta - \theta) + y_{B5} V \sin(\delta - \theta), \\ f_{B1}: &~& 2H/\omega_s \dot{y}_{B1} + y_{B0} \omega_b - y_{B1} D + y_{B9} (1 - T_2/T_1) - y_{B10} K T_2/T_1 + g_{\omega}(\omega), \\ f_{B2}: &~& T_{q0}' \dot{y}_{B2} - y_{B1} I_d - y_{B2} + y_{B4} + y_{B6} I_d - y_{B7} I_q, \\ f_{B3}: &~& T_{d0}' \dot{y}_{B3} - y_{B1} I_q - y_{B3} + y_{B5} + y_{B6} I_q + y_{B7} I_d, \\ f_{B4}: &~& -y_{B1} (E_d' + (-X_d'+X_q') I_q) - y_{B3} (X_d - X_d') - y_{B4} R_s - y_{B5} X_d' + y_{B6} (E_d' + (X_q' - X_d') I_q - 2 R_s I_d) + y_{B7} (E_q' - 2 X_d' I_d), \\ f_{B5}: &~& -y_{B1} (E_q' + (-X_d'+X_q') I_d) + y_{B2} (X_q - X_q') + y_{B4} X_q' - y_{B5} R_s + y_{B6} (E_q' + (X_q' - X_d') I_d - 2 R_s I_q) - y_{B7} (E_d' + 2 X_q' I_q). \\ \end{eqnarray*}\end{split}\]

ScalarT trajectoryPenalty(ScalarT t) const

Difference between computed system state and look-up table value.

Todo:

Look-up table should probably live outside the generator model.