Skip to content

Commit

Permalink
fix some errors
Browse files Browse the repository at this point in the history
Signed-off-by: Glebs Ogorodniks <[email protected]>
  • Loading branch information
Gleb4x authored and martinmoraga committed Oct 19, 2023
1 parent ade1e58 commit a82ace4
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
10 changes: 9 additions & 1 deletion dpsim-models/include/dpsim-models/Signal/SteamTurbineGovernor.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ namespace Signal {
public:
// Droop, the value 1/K in the controller K(1+sT_2)
Real R;
// T_1 related to the differentiator in the controlle K(1+sT_2)/(1+sT_1)
Real T1;
// T_2 related to the differentiator in the controlle K(1+sT_2)
Real T2;
// Time constant T_3 of the actuator in the Governor
Expand Down Expand Up @@ -66,11 +68,17 @@ namespace Signal {
Real mDelPgv;
// The outpur of the Governor at k
Real mPgv;
//
Real mP1;
//
Real mP;

// ### Variables at time step k+1 ###
// The outpur of the PT1 with limiters at k+1 (Governor output)
Real mPgv_next;

//
Real mP1_next;

public:
///
explicit SteamTurbineGovernor(const String & name) : SimSignalComp(name, name) { }
Expand Down
20 changes: 17 additions & 3 deletions dpsim-models/src/Signal/SteamTurbineGovernor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ void SteamTurbineGovernor::setParameters(std::shared_ptr<Base::GovernorParameter
"Steam Governor parameters: "
"\nOmRef: {:e}"
"\nR: {:e}"
"\nT1: {:e}"
"\nT2: {:e}"
"\nT3: {:e}"
"\ndPmax: {:e}"
"\ndPmin: {:e}"
"\nPmax: {:e}"
"\nPmin: {:e}",
mParameters->OmRef, mParameters->R, mParameters->T2,
mParameters->OmRef, mParameters->R,
mParameters->T1, mParameters->T2,
mParameters->T3, mParameters->dPmax, mParameters->dPmin,
mParameters->Pmax, mParameters->Pmin);
} else {
Expand All @@ -36,6 +38,9 @@ void SteamTurbineGovernor::initialize(Real Pref) {
mPref = Pref;
mDelOm_prev = 0;
mDelOm = 0;
mP1=0;
mP1_next=0;
mP=0;
mDelPgv = 0;
mPgv = Pref;
mPgv_next = Pref;
Expand All @@ -59,12 +64,21 @@ Real SteamTurbineGovernor::step(Real Omega, Real dt) {
// write the values that were calculated in the previous step
mDelOm_prev = mDelOm;
mPgv = mPgv_next;
mP1 = mP1_next;

// Calculate the input of the governor for time step k
mDelOm = mParameters->OmRef-Omega;

// Calculate thee input of integrator in PT1 via values of controller and output of governor
mDelPgv = (1. / mParameters->R *( mDelOm + mParameters->T2 / dt * (mDelOm-mDelOm_prev)) + mPref- mPgv) * 1. / mParameters->T3;
// Transfer function 1/R (1+sT2)/(s+T1) = 1/R (T2/T1 + (T1-T2)/T1 *1/(sT1)) = P(s)/delOm(s)
if(mParameters->T1==0) {
mP = (1/mParameters->R) * (mDelOm + (mParameters->T2/dt) * (mDelOm-mDelOm_prev));
} else {
mP1_next = mP1+(dt/mParameters->T1) * (mDelOm*(mParameters->T1-mParameters->T2) / mParameters->T1-mP1);
mP = (1/mParameters->R) * (mP1+mDelOm * (mParameters->T2/mParameters->T1));
}

// Calculate thee input of integrator in PT1 via values of controller and output of governor
mDelPgv = (mP + mPref- mPgv) * 1/mParameters->T3;
if (mDelPgv<mParameters->dPmin)
mDelPgv = mParameters->dPmin;
if(mDelPgv>mParameters->dPmax)
Expand Down
4 changes: 3 additions & 1 deletion dpsim/examples/cxx/Examples.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ namespace TurbineGovernor {
Real OmRef = 1.0;
//Pilot valve droop (p.u.)
Real R = 0.04;
// PD controller time constant (s)
//Controller time constant (s)
Real T1=0;
//Controller time constant (s)
Real T2 = 0.2;
// Servo time constant (s)
Real T3 = 0.1;
Expand Down
8 changes: 5 additions & 3 deletions python/src/dpsim/matpower.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,11 @@ def create_dpsim_objects(self, domain, frequency, log_level=dpsimpy.LogLevel.inf
transf_s = self.mpc_branch_data.at[index,'rateA'] * mw_w
primary_V = tmp_fbus['Vm'][fbus_index-1] * fbus_baseV
secondary_V = tmp_tbus['Vm'][tbus_index-1] * tbus_baseV


#is there if the second condition in upper if is false: not(fbus_baseV==tbus_baseV)
if (branch_ratio==0):
branch_ratio=1

transf_ratioAbs = branch_ratio * fbus_baseV / tbus_baseV

# From MATPOWER-manual taps at “from” bus, impedance at “to” bus, i.e. ifr=x=b= 0,tap=|Vf|/|Vt|
Expand All @@ -348,8 +350,8 @@ def create_dpsim_objects(self, domain, frequency, log_level=dpsimpy.LogLevel.inf
transf_l = transf_x / self.mpc_omega
else:
transf_baseV = tbus_baseV
transf_r = self.mpc_branch_data.at[index,'r']* transf_baseZ
transf_x = self.mpc_branch_data.at[index,'x']* transf_baseZ
transf_r = self.mpc_branch_data.at[index,'r']* transf_baseZ * (branch_ratio**2)
transf_x = self.mpc_branch_data.at[index,'x']* transf_baseZ * (branch_ratio**2)
transf_l = transf_x / self.mpc_omega

# create dpsim component
Expand Down

0 comments on commit a82ace4

Please sign in to comment.