From 268f48a4f3a2e14eb294a3f4e3cb0bf62b278f07 Mon Sep 17 00:00:00 2001 From: "martin.moraga" Date: Wed, 28 Feb 2024 17:37:44 +0100 Subject: [PATCH] resolve rebase conflicts Signed-off-by: martin.moraga --- .../include/dpsim-models/Base/Base_Exciter.h | 39 +- .../include/dpsim-models/Base/Base_Governor.h | 40 +- .../include/dpsim-models/Base/Base_PSS.h | 46 +- .../Base/Base_ReducedOrderSynchronGenerator.h | 96 +--- .../Base/Base_SynchronGenerator.h | 101 +--- .../include/dpsim-models/Base/Base_Turbine.h | 1 + .../include/dpsim-models/Components.h | 5 +- .../include/dpsim-models/Definitions.h | 21 - .../EMT/EMT_Ph3_SynchronGeneratorVBR.h | 12 +- dpsim-models/include/dpsim-models/Factory.h | 538 ++++++------------ .../SP/SP_Ph1_AvVoltageSourceInverterDQ.h | 2 +- .../include/dpsim-models/Signal/ExciterDC1.h | 170 +++--- .../dpsim-models/Signal/ExciterDC1Simp.h | 88 ++- .../dpsim-models/Signal/ExciterST1Simp.h | 91 ++- .../dpsim-models/Signal/ExciterStatic.h | 129 +++-- .../dpsim-models/Signal/HydroTurbine.h | 77 ++- .../Signal/HydroTurbineGovernor.h | 149 ++--- .../include/dpsim-models/Signal/PSS1A.h | 158 +++-- .../dpsim-models/Signal/SteamTurbine.h | 114 ++-- .../Signal/SteamTurbineGovernor.h | 175 +++--- .../dpsim-models/Signal/TurbineGovernor.h | 1 + .../Base_ReducedOrderSynchronGenerator.cpp | 106 +--- .../src/EMT/EMT_Ph3_SynchronGeneratorVBR.cpp | 8 +- .../SP/SP_Ph1_AvVoltageSourceInverterDQ.cpp | 2 +- dpsim-models/src/Signal/ExciterDC1Simp.cpp | 18 +- .../src/Signal/TurbineGovernorType1.cpp | 16 +- .../Circuits/DP_ReducedOrderSG_SMIB_Fault.cpp | 53 +- .../DP_ReducedOrderSG_VBR_Load_Fault.cpp | 475 ---------------- .../DP_SMIB_ReducedOrderSG_LoadStep.cpp | 17 +- .../EMT_ReducedOrderSG_SMIB_Fault.cpp | 23 +- .../EMT_ReducedOrderSG_VBR_Load_Fault.cpp | 360 ------------ .../EMT_SMIB_ReducedOrderSG_LoadStep.cpp | 35 +- .../Circuits/SP_ReducedOrderSG_SMIB_Fault.cpp | 70 +-- .../SP_ReducedOrderSG_VBR_Load_Fault.cpp | 195 ------- .../SP_SMIB_ReducedOrderSG_LoadStep.cpp | 17 +- ...rDCIM_LoadStep_TurbineGovernor_Exciter.cpp | 6 +- ...erVBR_LoadStep_TurbineGovernor_Exciter.cpp | 35 +- dpsim/examples/cxx/Examples.h | 70 +-- dpsim/src/pybind/SignalComponents.cpp | 168 +----- 39 files changed, 992 insertions(+), 2735 deletions(-) delete mode 100644 dpsim/examples/cxx/Circuits/DP_ReducedOrderSG_VBR_Load_Fault.cpp delete mode 100644 dpsim/examples/cxx/Circuits/EMT_ReducedOrderSG_VBR_Load_Fault.cpp delete mode 100644 dpsim/examples/cxx/Circuits/SP_ReducedOrderSG_VBR_Load_Fault.cpp diff --git a/dpsim-models/include/dpsim-models/Base/Base_Exciter.h b/dpsim-models/include/dpsim-models/Base/Base_Exciter.h index 1ebec13ab2..f5a02b78a6 100644 --- a/dpsim-models/include/dpsim-models/Base/Base_Exciter.h +++ b/dpsim-models/include/dpsim-models/Base/Base_Exciter.h @@ -8,29 +8,30 @@ #pragma once +#include + namespace CPS { namespace Base { - class ExciterParameters { - public: - ExciterParameters() { }; - virtual ~ExciterParameters() = default; - }; - - /// @brief Base model for exciters - class Exciter { - - public: - /// - virtual void setParameters(std::shared_ptr parameters) = 0; +class ExciterParameters { +public: + ExciterParameters(){}; + virtual ~ExciterParameters() = default; +}; - /// Initializes exciter variables - virtual void initialize(Real Vh_init, Real Ef_init) = 0; +/// @brief Base model for exciters +class Exciter { - /// @param V_pss: Output of PSS - virtual Real step(Real Vd, Real Vq, Real dt, Real Vpss = 0) = 0; - }; -} -} +public: + /// + virtual void + setParameters(std::shared_ptr parameters) = 0; + /// Initializes exciter variables + virtual void initialize(Real Vh_init, Real Ef_init) = 0; + /// @param V_pss: Output of PSS + virtual Real step(Real Vd, Real Vq, Real dt, Real Vpss = 0) = 0; +}; +} // namespace Base +} // namespace CPS \ No newline at end of file diff --git a/dpsim-models/include/dpsim-models/Base/Base_Governor.h b/dpsim-models/include/dpsim-models/Base/Base_Governor.h index 3fe5367f26..dedc422747 100644 --- a/dpsim-models/include/dpsim-models/Base/Base_Governor.h +++ b/dpsim-models/include/dpsim-models/Base/Base_Governor.h @@ -8,30 +8,30 @@ #pragma once +#include + namespace CPS { namespace Base { - class GovernorParameters { - public: - GovernorParameters() { }; - virtual ~GovernorParameters() = default; - }; - - /// @brief Base model for Governors - class Governor { - - public: - - /// - virtual void setParameters(std::shared_ptr parameters) = 0; +class GovernorParameters { +public: + GovernorParameters(){}; + virtual ~GovernorParameters() = default; +}; - /// Initializes Governor variables - virtual void initialize(Real PmRef) = 0; +/// @brief Base model for Governors +class Governor { - /// @param V_pss: Output of PSS - virtual Real step(Real Omega, Real dt) = 0; - }; -} -} +public: + /// + virtual void + setParameters(std::shared_ptr parameters) = 0; + /// Initializes Governor variables + virtual void initialize(Real PmRef) = 0; + /// @param V_pss: Output of PSS + virtual Real step(Real Omega, Real dt) = 0; +}; +} // namespace Base +} // namespace CPS diff --git a/dpsim-models/include/dpsim-models/Base/Base_PSS.h b/dpsim-models/include/dpsim-models/Base/Base_PSS.h index 92448101e2..04edafb85d 100644 --- a/dpsim-models/include/dpsim-models/Base/Base_PSS.h +++ b/dpsim-models/include/dpsim-models/Base/Base_PSS.h @@ -13,26 +13,26 @@ namespace CPS { namespace Base { - class PSSParameters { - public: - PSSParameters() { }; - virtual ~PSSParameters() = default; - }; - - /// @brief Base model for exciters - class PSS { - - public: - /// - virtual void setParameters(std::shared_ptr parameters) = 0; - - /// Initializes exciter variables - virtual void initialize(Real omega, Real activePower, Real Vd, Real Vq) = 0; - - /// @param V_pss: Output of PSS - virtual Real step(Real omega, Real activePower, Real Vd, Real Vq, Real dt) = 0; - }; -} -} - - +class PSSParameters { +public: + PSSParameters(){}; + virtual ~PSSParameters() = default; +}; + +/// @brief Base model for exciters +class PSS { + +public: + /// + virtual void + setParameters(std::shared_ptr parameters) = 0; + + /// Initializes exciter variables + virtual void initialize(Real omega, Real activePower, Real Vd, Real Vq) = 0; + + /// @param V_pss: Output of PSS + virtual Real step(Real omega, Real activePower, Real Vd, Real Vq, + Real dt) = 0; +}; +} // namespace Base +} // namespace CPS diff --git a/dpsim-models/include/dpsim-models/Base/Base_ReducedOrderSynchronGenerator.h b/dpsim-models/include/dpsim-models/Base/Base_ReducedOrderSynchronGenerator.h index b59e598bf5..08a2974cdd 100644 --- a/dpsim-models/include/dpsim-models/Base/Base_ReducedOrderSynchronGenerator.h +++ b/dpsim-models/include/dpsim-models/Base/Base_ReducedOrderSynchronGenerator.h @@ -10,7 +10,10 @@ #include #include +#include #include +#include +#include namespace CPS { namespace Base { @@ -94,27 +97,28 @@ class ReducedOrderSynchronGenerator : public MNASimPowerComp { /// Add Governor/TurbineGovernor void addTurbine(std::shared_ptr turbine); - /// Add Governor/TurbineGovernor - //void addGovernor(std::shared_ptr governorParameters, GovernorType governorType = GovernorType::TurbineGovernorType1); - void addGovernor(std::shared_ptr governor); - //Add Steam Turbine and Governor separately - //it is adviced to choose Pminit of turbine to mPref of the Governor by f_ref=f_n (50Hz/60Hz) - //void addSteamTurbine(Real Fhp, Real Fip, Real Flp, Real Tch, Real Trh, Real Tco, Real Pminit); - //void addSteamTurbine(std::shared_ptr steamTurbine); - //Add Steam Turbine Governor - //void addSteamTurbineGovernor(Real OmRef, Real Pref, Real R, Real T2, Real T3, - // Real dPmax, Real dPmin, Real Pmax, Real Pmin); - //void addSteamTurbineGovernor(std::shared_ptr steamTurbineGovernor); - //Add Hydro Turbine and Governor separately - //it is adviced to choose Pminit of turbine to mPref of the Governor by f_ref=f_n (50Hz/60Hz) - //void addHydroTurbine(Real Tw, Real Pminit); - //void addHydroTurbine(std::shared_ptr HydroTurbine); - //Add Hydrp Turbine Governor - //void addHydroTurbineGovernor(Real OmRef, Real Pref, Real R, Real T1, Real T2, Real T3, - // Real Pmax, Real Pmin); - //void addHydroTurbineGovernor(std::shared_ptr hydroTurbineGovernor); - protected: + using MNASimPowerComp::mRightVector; + using MNASimPowerComp::mIntfVoltage; + using MNASimPowerComp::MnaPreStep; + using MNASimPowerComp::MnaPostStep; + + /// + ReducedOrderSynchronGenerator(String uid, String name, + Logger::Level logLevel); + /// + void calculateVBRconstants(); + /// + void calculateResistanceMatrixConstants(); + /// + virtual void initializeResistanceMatrix() = 0; + /// + void initializeFromNodesAndTerminals(Real frequency); + /// Function to initialize the specific variables of each SG model + virtual void specificInitialization() = 0; + /// Model specific step + virtual void stepInPerUnit() = 0; + // ### MNA Section ### /// void mnaCompInitialize(Real omega, Real timeStep, @@ -254,32 +258,6 @@ class ReducedOrderSynchronGenerator : public MNASimPowerComp { /// Flag to remember when initial values are set Bool mInitialValuesSet = false; - // #### Controllers #### - /// Determines if Turbine and Governor are activated - Bool mHasTurbineGovernor = false; - /// Determines if Exciter is activated - Bool mHasExciter = false; - /// Signal component modelling governor control and steam turbine - std::shared_ptr mTurbineGovernor; - /// Signal component modelling voltage regulator and exciter - std::shared_ptr mExciter; - - // #### Controllers #### - /// Determines if Turbine and Governor are activated - Bool mHasTurbineGovernor = false; - /// Determines if Exciter is activated - Bool mHasExciter = false; - /// Determines if Exciter is activated - Bool mHasPSS = false; - /// Signal component modelling governor control and steam turbine - std::shared_ptr mTurbineGovernor; - /// Signal component modelling voltage regulator and exciter - std::shared_ptr mExciter; - /// Signal component modelling voltage regulator and exciter - std::shared_ptr mPSS; - /// - Real mVpss = 0; - // #### Controllers #### /// Determines if Exciter is activated Bool mHasExciter = false; @@ -302,34 +280,10 @@ class ReducedOrderSynchronGenerator : public MNASimPowerComp { /// Real mVpss = 0; - /// Signal component modelling voltage regulator and exciter - std::shared_ptr mExciter; - /// Signal component modelling power system stabilizer - std::shared_ptr mPSS; - /// Signal component modelling Turbine - //std::shared_ptr mTurbine; - /// Signal component modelling governor control - std::shared_ptr mGovernor; - - /// - Real mVpss = 0; - - /// Signal component modelling voltage regulator and exciter - std::shared_ptr mExciter; - /// Signal component modelling power system stabilizer - std::shared_ptr mPSS; - /// Signal component modelling Turbine - //std::shared_ptr mTurbine; - /// Signal component modelling governor control - std::shared_ptr mGovernor; - - /// - Real mVpss = 0; - /// Real mTimeStep; /// Real mSimTime; }; } // namespace Base -} // namespace CPS +} // namespace CPS \ No newline at end of file diff --git a/dpsim-models/include/dpsim-models/Base/Base_SynchronGenerator.h b/dpsim-models/include/dpsim-models/Base/Base_SynchronGenerator.h index a09e814881..d142ef0759 100644 --- a/dpsim-models/include/dpsim-models/Base/Base_SynchronGenerator.h +++ b/dpsim-models/include/dpsim-models/Base/Base_SynchronGenerator.h @@ -9,6 +9,7 @@ #pragma once #include +#include #include #include @@ -176,10 +177,6 @@ class SynchronGenerator { /// theta Real mThetaMech = 0; - // ### State variables ### - /// theta - Real mThetaMech = 0; - public: /// rotor angle delta const Attribute::Ptr mDelta; @@ -200,40 +197,6 @@ class SynchronGenerator { /// Voltage excitation const Attribute::Ptr mVfd; -protected: - /// \brief Vector of stator and rotor voltages. - /// - /// v_d - Stator voltage in d axis \n - /// v_fd - Rotor voltage field winding \n - /// v_kd - Rotor voltage damping winding in d axis \n - /// v_q - Stator voltage in q axis \n - /// v_kq1 - Rotor voltage damping winding 1 in q axis \n - /// v_kq2 - Rotor voltage damping winding 2 in q axis \n - /// v_0 - Stator voltage 0 component \n - Matrix mVsr; - /// \brief Vector of stator and rotor currents. - /// - /// i_d - stator current in d axis - /// i_fd - Rotor current field winding - /// i_kd - Rotor current damping winding in d axis - /// i_q - stator current in q axis - /// i_kq1 - Rotor current damping winding 1 in q axis - /// i_kq2 - Rotor current damping winding 2 in q axis - /// i_0 - stator current 0 component - Matrix mIsr; - /// \brief Vector of stator and rotor fluxes. - /// - /// psi_d - stator flux linkage in d axis - /// psi_fd - rotor flux linkage in field winding - /// psi_kd - rotor flux linkage in damping winding from d axis - /// psi_q - stator flux linkage in q axis - /// psi_kq1 - rotor flux linkage in damping winding 1 from q axis - /// psi_kq2 - rotor flux linkage in damping winding 2 from q axis - /// psi_0 - stator flux linkage 0 component - Matrix mPsisr; //equivalent to Fluxes - /// Initializes the per unit or stator referred machine parameters with the machine parameters given in per unit. - /// The initialization mode depends on the setting of state type. - protected: /// \brief Vector of stator and rotor voltages. /// @@ -297,53 +260,15 @@ class SynchronGenerator { /// Function parameters have to be given in real units. void initPerUnitStates(); - /// Constructor - explicit SynchronGenerator(CPS::AttributeList::Ptr attributeList) - : mRs(attributeList->create("Rs", 0)), - mLl(attributeList->create("Ll", 0)), - mLd(attributeList->create("Ld", 0)), - mLq(attributeList->create("Lq", 0)), - mLd_t(attributeList->create("Ld_t", 0)), - mLq_t(attributeList->create("Lq_t", 0)), - mLd_s(attributeList->create("Ld_s", 0)), - mLq_s(attributeList->create("Lq_s", 0)), - mTd0_t(attributeList->create("Td0_t", 0)), - mTq0_t(attributeList->create("Tq0_t", 0)), - mTd0_s(attributeList->create("Td0_s", 0)), - mTq0_s(attributeList->create("Tq0_s", 0)), - mDelta(attributeList->create("delta_r", 0)), - mMechTorque(attributeList->create("T_m", 0)), - mInertia(attributeList->create("inertia", 0)), - mOmMech(attributeList->create("w_r", 0)), - mElecActivePower(attributeList->create("P_elec", 0)), - mElecReactivePower(attributeList->create("Q_elec", 0)), - mMechPower(attributeList->create("P_mech", 0)), - mElecTorque(attributeList->create("T_e", 0)), - mVfd(attributeList->create("Vfd", 0)){}; + // #### Controllers #### + /// Determines if Turbine and Governor are activated + Bool mHasTurbineGovernor = false; + /// Determines if Exciter is activated + Bool mHasExciter = false; - /// Constructor - explicit SynchronGenerator(CPS::AttributeBase::Map &attributeList) - : mRs(Attribute::create("Rs", attributeList, 0)), - mLl(Attribute::create("Ll", attributeList, 0)), - mLd(Attribute::create("Ld", attributeList, 0)), - mLq(Attribute::create("Lq", attributeList, 0)), - mLd_t(Attribute::create("Ld_t", attributeList, 0)), - mLq_t(Attribute::create("Lq_t", attributeList, 0)), - mLd_s(Attribute::create("Ld_s", attributeList, 0)), - mLq_s(Attribute::create("Lq_s", attributeList, 0)), - mTd0_t(Attribute::create("Td0_t", attributeList, 0)), - mTq0_t(Attribute::create("Tq0_t", attributeList, 0)), - mTd0_s(Attribute::create("Td0_s", attributeList, 0)), - mTq0_s(Attribute::create("Tq0_s", attributeList, 0)), - mDelta(Attribute::create("delta_r", attributeList, 0)), - mMechTorque(Attribute::create("T_m", attributeList, 0)), - mInertia(Attribute::create("inertia", attributeList, 0)), - mOmMech(Attribute::create("w_r", attributeList, 0)), - mElecActivePower(Attribute::create("P_elec", attributeList, 0)), - mElecReactivePower(Attribute::create("Q_elec", attributeList, 0)), - mMechPower(Attribute::create("P_mech", attributeList, 0)), - mElecTorque(Attribute::create("T_e", attributeList, 0)), - mVfd(Attribute::create("Vfd", attributeList, 0)){}; + // Deprecated + Real mInitTerminalVoltage = 0; + Real mInitVoltAngle = 0; /// Constructor explicit SynchronGenerator(CPS::AttributeList::Ptr attributeList) @@ -366,7 +291,8 @@ class SynchronGenerator { mElecActivePower(attributeList->create("P_elec", 0)), mElecReactivePower(attributeList->create("Q_elec", 0)), mMechPower(attributeList->create("P_mech", 0)), - mElecTorque(attributeList->create("T_e", 0)){}; + mElecTorque(attributeList->create("T_e", 0)), + mVfd(attributeList->create("Vfd", 0)){}; /// void setBaseParameters(Real nomPower, Real nomVolt, Real nomFreq); @@ -432,10 +358,13 @@ class SynchronGenerator { Real initTerminalVolt, Real initVoltAngle, Real initMechPower); + /// Switch to determine the integration method for the machine model. + void setNumericalMethod(NumericalMethod method) { mNumericalMethod = method; } + /// Signal component modelling governor control and steam turbine std::shared_ptr mTurbineGovernor; /// Signal component modelling voltage regulator and exciter std::shared_ptr mExciter; }; } // namespace Base -} // namespace CPS +} // namespace CPS \ No newline at end of file diff --git a/dpsim-models/include/dpsim-models/Base/Base_Turbine.h b/dpsim-models/include/dpsim-models/Base/Base_Turbine.h index 28bc6638b8..a59f90c5b3 100644 --- a/dpsim-models/include/dpsim-models/Base/Base_Turbine.h +++ b/dpsim-models/include/dpsim-models/Base/Base_Turbine.h @@ -7,6 +7,7 @@ *********************************************************************************/ #pragma once +#include namespace CPS { namespace Base { diff --git a/dpsim-models/include/dpsim-models/Components.h b/dpsim-models/include/dpsim-models/Components.h index 54c69ca8d8..6e0d40c36f 100644 --- a/dpsim-models/include/dpsim-models/Components.h +++ b/dpsim-models/include/dpsim-models/Components.h @@ -123,18 +123,19 @@ #include #include #include -#include #include #include #include +#include #include #include #include #include #include #include -#include #include #include #include #include +#include +#include \ No newline at end of file diff --git a/dpsim-models/include/dpsim-models/Definitions.h b/dpsim-models/include/dpsim-models/Definitions.h index 4a7dff5e18..88eec7e6b8 100644 --- a/dpsim-models/include/dpsim-models/Definitions.h +++ b/dpsim-models/include/dpsim-models/Definitions.h @@ -140,27 +140,6 @@ class TypeException : public Exception {}; class InvalidAttributeException : public Exception {}; class InvalidArgumentException : public Exception {}; -// ### Exceptions ### -class Exception : public std::exception {}; -class AccessException : public Exception {}; -class TypeException : public Exception {}; -class InvalidAttributeException : public Exception {}; -class InvalidArgumentException : public Exception {}; - -// ### Exceptions ### -class Exception : public std::exception {}; -class AccessException : public Exception {}; -class TypeException : public Exception {}; -class InvalidAttributeException : public Exception {}; -class InvalidArgumentException : public Exception {}; - -// ### Exceptions ### -class Exception : public std::exception {}; -class AccessException : public Exception {}; -class TypeException : public Exception {}; -class InvalidAttributeException : public Exception {}; -class InvalidArgumentException : public Exception {}; - class SystemError { protected: std::error_code mErrorCode; diff --git a/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_SynchronGeneratorVBR.h b/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_SynchronGeneratorVBR.h index 4ea917f1b0..089736e35e 100644 --- a/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_SynchronGeneratorVBR.h +++ b/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_SynchronGeneratorVBR.h @@ -10,6 +10,9 @@ #include #include +#include +#include +#include #include #include #include @@ -97,13 +100,6 @@ class SynchronGeneratorVBR : public MNASimPowerComp, /// Subtransient voltage in pu Matrix mDVabc = Matrix::Zero(3, 1); - /// Phase currents in pu - Matrix mIabc = Matrix::Zero(3, 1); - ///Phase Voltages in pu - Matrix mVabc = Matrix::Zero(3, 1); - /// Subtransient voltage in pu - Matrix mDVabc = Matrix::Zero(3, 1); - /// Dq stator current vector Matrix mDqStatorCurrents = Matrix::Zero(2, 1); /// Q axis stator current of from last time step @@ -282,4 +278,4 @@ class SynchronGeneratorVBR : public MNASimPowerComp, }; } // namespace Ph3 } // namespace EMT -} // namespace CPS +} // namespace CPS \ No newline at end of file diff --git a/dpsim-models/include/dpsim-models/Factory.h b/dpsim-models/include/dpsim-models/Factory.h index b5f9b0c239..f1d730205e 100644 --- a/dpsim-models/include/dpsim-models/Factory.h +++ b/dpsim-models/include/dpsim-models/Factory.h @@ -17,6 +17,11 @@ #include #include #include +#include +#include +#include +#include +#include #include #include #include @@ -25,366 +30,187 @@ template class Creator { - template class Creator { - - public: - virtual ~Creator() {} - - virtual std::shared_ptr - Create(const std::string &name, - CPS::Logger::Level logLevel = CPS::Logger::Level::debug) = 0; - }; - - template - class DerivedCreator : public Creator { - - public: - std::shared_ptr - Create(const std::string &name, - CPS::Logger::Level logLevel = CPS::Logger::Level::debug) { - return std::shared_ptr(new DerivedClass(name, logLevel)); - } - }; - - template class Factory { - public: - static Factory &get() { - static Factory instance; - return instance; - } - - namespace PSSFactory { - void registerExciters() { - FactoryRegistration _PSS1A( - "PSS1A", new DerivedCreator); - } - } - - namespace SynchronGeneratorFactory { - namespace SP { - namespace Ph1 { - void registerSynchronGenerators() { - FactoryRegistration - _3OrderSP("3", new DerivedCreator< - CPS::SP::Ph1::SynchronGenerator3OrderVBR, - CPS::SP::Ph1::ReducedOrderSynchronGeneratorVBR>); - FactoryRegistration - _4OrderSP("4", new DerivedCreator< - CPS::SP::Ph1::SynchronGenerator4OrderVBR, +public: + virtual ~Creator() {} + + virtual std::shared_ptr + Create(const std::string &name, + CPS::Logger::Level logLevel = CPS::Logger::Level::debug) = 0; +}; + +template +class DerivedCreator : public Creator { + +public: + std::shared_ptr + Create(const std::string &name, + CPS::Logger::Level logLevel = CPS::Logger::Level::debug) { + return std::shared_ptr(new DerivedClass(name, logLevel)); + } +}; + +template class Factory { +public: + static Factory &get() { + static Factory instance; + return instance; + } + + std::vector getItems() { + std::vector items; + for (auto g : functionMap) { + items.push_back(g.first); + } + + return items; + } + + std::shared_ptr + create(std::string type, const std::string &name, + CPS::Logger::Level logLevel = CPS::Logger::Level::debug) { + + auto it = functionMap.find(type); + if (it != functionMap.end()) + return it->second->Create(name, logLevel); + else + throw CPS::SystemError("Unsupported type '" + type + "'!"); + } + + void registerExciter(const std::string &type, Creator *Fn) { + functionMap[type] = Fn; + } + +private: + Factory() {} + Factory(const Factory &); + ~Factory() { + auto i = functionMap.begin(); + while (i != functionMap.end()) { + delete (*i).second; + ++i; + } + } + + std::map *> functionMap; +}; + +template class FactoryRegistration { +public: + FactoryRegistration(std::string type, Creator *Fn) { + Factory::get().registerExciter(type, Fn); + } +}; + +namespace ExciterFactory { +void registerExciters() { + FactoryRegistration _ExciterDC1( + "DC1", new DerivedCreator); + FactoryRegistration _ExciterDC1Simp( + "DC1Simp", + new DerivedCreator); + FactoryRegistration _ExciterST1Simp( + "ST1", + new DerivedCreator); +} +} // namespace ExciterFactory + +namespace PSSFactory { +void registerExciters() { + FactoryRegistration _PSS1A( + "PSS1A", new DerivedCreator); +} +} // namespace PSSFactory + +namespace SynchronGeneratorFactory { +namespace SP { +namespace Ph1 { +void registerSynchronGenerators() { + FactoryRegistration _3OrderSP( + "3", new DerivedCreator); + FactoryRegistration _4OrderSP( + "4", new DerivedCreator); + FactoryRegistration _5OrderSP( + "5", new DerivedCreator); + FactoryRegistration + _6aOrderSP( + "6a", + new DerivedCreator); - FactoryRegistration - _5OrderSP("5", new DerivedCreator< - CPS::SP::Ph1::SynchronGenerator5OrderVBR, + FactoryRegistration + _6bOrderSP( + "6b", + new DerivedCreator); - FactoryRegistration - _6aOrderSP("6a", new DerivedCreator< - CPS::SP::Ph1::SynchronGenerator6aOrderVBR, - CPS::SP::Ph1::ReducedOrderSynchronGeneratorVBR>); - FactoryRegistration - _6bOrderSP("6b", new DerivedCreator< - CPS::SP::Ph1::SynchronGenerator6bOrderVBR, - CPS::SP::Ph1::ReducedOrderSynchronGeneratorVBR>); - } - - std::shared_ptr - create(std::string type, const std::string &name, - CPS::Logger::Level logLevel = CPS::Logger::Level::debug) { - - auto it = functionMap.find(type); - if (it != functionMap.end()) - return it->second->Create(name, logLevel); - else - throw CPS::SystemError("Unsupported type '" + type + "'!"); - } - - void registerExciter(const std::string &type, Creator *Fn) { - functionMap[type] = Fn; - } - - private: - Factory() {} - Factory(const Factory &); - ~Factory() { - auto i = functionMap.begin(); - while (i != functionMap.end()) { - delete (*i).second; - ++i; - } - } - - std::map *> functionMap; - }; - - template class FactoryRegistration { - public: - FactoryRegistration(std::string type, Creator *Fn) { - Factory::get().registerExciter(type, Fn); - } - }; - - namespace ExciterFactory { - void registerExciters() { - FactoryRegistration _ExciterDC1( - "DC1", - new DerivedCreator); - FactoryRegistration _ExciterDC1Simp( - "DC1Simp", - new DerivedCreator); - FactoryRegistration _ExciterST1Simp( - "ST1", - new DerivedCreator); - } - - std::vector getItems() { - std::vector items; - for (auto g : functionMap) { - items.push_back(g.first); - } - - return items; - } - - std::shared_ptr - create(std::string type, const std::string &name, - CPS::Logger::Level logLevel = CPS::Logger::Level::debug) { - - auto it = functionMap.find(type); - if (it != functionMap.end()) - return it->second->Create(name, logLevel); - else - throw CPS::SystemError("Unsupported type '" + type + "'!"); - } - - void registerExciter(const std::string &type, Creator *Fn) { - functionMap[type] = Fn; - } - - private: - Factory() {} - Factory(const Factory &); - ~Factory() { - auto i = functionMap.begin(); - while (i != functionMap.end()) { - delete (*i).second; - ++i; - } - } - - std::map *> functionMap; - }; - - template class FactoryRegistration { - public: - FactoryRegistration(std::string type, Creator *Fn) { - Factory::get().registerExciter(type, Fn); - } - }; - - namespace ExciterFactory { - void registerExciters() { - FactoryRegistration _ExciterDC1( - "DC1", - new DerivedCreator); - FactoryRegistration _ExciterDC1Simp( - "DC1Simp", - new DerivedCreator); - } - - std::vector getItems() { - - std::vector items; - for (auto g : functionMap) { - items.push_back(g.first); - } - - return items; - } - - std::shared_ptr - create(std::string type, const std::string &name, - CPS::Logger::Level logLevel = CPS::Logger::Level::debug) { - - auto it = functionMap.find(type); - if (it != functionMap.end()) - return it->second->Create(name, logLevel); - else - throw CPS::SystemError("Unsupported type '" + type + "'!"); - } - - void registerExciter(const std::string &type, Creator *Fn) { - - functionMap[type] = Fn; - } - - private: - Factory() {} - Factory(const Factory &); - ~Factory() { - auto i = functionMap.begin(); - while (i != functionMap.end()) { - delete (*i).second; - ++i; - } - } - - std::map *> functionMap; - }; - - template class Factory { - public: - static Factory &get() { - static Factory instance; - return instance; - } - - std::vector getItems() { - std::vector items; - for (auto g : functionMap) { - items.push_back(g.first); - } - - return items; - } - - std::shared_ptr - create(std::string type, const std::string &name, - CPS::Logger::Level logLevel = CPS::Logger::Level::debug) { - - auto it = functionMap.find(type); - if (it != functionMap.end()) - return it->second->Create(name, logLevel); - else - throw CPS::SystemError("Unsupported type '" + type + "'!"); - } - - void registerExciter(const std::string &type, Creator *Fn) { - functionMap[type] = Fn; - } - - private: - Factory() {} - Factory(const Factory &); - ~Factory() { - auto i = functionMap.begin(); - while (i != functionMap.end()) { - delete (*i).second; - ++i; - } - } - - std::map *> functionMap; - }; - - template class FactoryRegistration { - public: - FactoryRegistration(std::string type, Creator *Fn) { - Factory::get().registerExciter(type, Fn); - } - }; - - namespace ExciterFactory { - void registerExciters() { - FactoryRegistration _ExciterDC1Simp( - "DC1Simp", - new DerivedCreator); - } - } - - namespace SynchronGeneratorFactory { - namespace SP { - namespace Ph1 { - void registerSynchronGenerators() { - FactoryRegistration - _3OrderSP("3", new DerivedCreator< - CPS::SP::Ph1::SynchronGenerator3OrderVBR, - CPS::SP::Ph1::ReducedOrderSynchronGeneratorVBR>); - FactoryRegistration - _4OrderSP("4", new DerivedCreator< - CPS::SP::Ph1::SynchronGenerator4OrderVBR, - CPS::SP::Ph1::ReducedOrderSynchronGeneratorVBR>); - FactoryRegistration - _5OrderSP("5", new DerivedCreator< - CPS::SP::Ph1::SynchronGenerator5OrderVBR, - CPS::SP::Ph1::ReducedOrderSynchronGeneratorVBR>); - FactoryRegistration - _6aOrderSP("6a", new DerivedCreator< - CPS::SP::Ph1::SynchronGenerator6aOrderVBR, - CPS::SP::Ph1::ReducedOrderSynchronGeneratorVBR>); - FactoryRegistration - _6bOrderSP("6b", new DerivedCreator< - CPS::SP::Ph1::SynchronGenerator6bOrderVBR, - CPS::SP::Ph1::ReducedOrderSynchronGeneratorVBR>); - } - } // namespace Ph1 - } // namespace SP - - namespace DP { - namespace Ph1 { - void registerSynchronGenerators() { - FactoryRegistration - _3OrderSP("3", new DerivedCreator< - CPS::DP::Ph1::SynchronGenerator3OrderVBR, +} +} // namespace Ph1 +} // namespace SP + +namespace DP { +namespace Ph1 { +void registerSynchronGenerators() { + FactoryRegistration _3OrderSP( + "3", new DerivedCreator); + FactoryRegistration _4OrderSP( + "4", new DerivedCreator); + FactoryRegistration> + _4OrderDPIter( + "4PCM", new DerivedCreator< + CPS::DP::Ph1::SynchronGenerator4OrderPCM, + CPS::Base::ReducedOrderSynchronGenerator>); + FactoryRegistration> + _4OrderDPTPM("4TPM", + new DerivedCreator< + CPS::DP::Ph1::SynchronGenerator4OrderTPM, + CPS::Base::ReducedOrderSynchronGenerator>); + FactoryRegistration + _6aOrderSP( + "6a", + new DerivedCreator); - FactoryRegistration - _4OrderSP("4", new DerivedCreator< - CPS::DP::Ph1::SynchronGenerator4OrderVBR, + FactoryRegistration + _6bOrderSP( + "6b", + new DerivedCreator); - FactoryRegistration< - CPS::Base::ReducedOrderSynchronGenerator> - _4OrderDPIter( - "4PCM", - new DerivedCreator< - CPS::DP::Ph1::SynchronGenerator4OrderPCM, - CPS::Base::ReducedOrderSynchronGenerator>); - FactoryRegistration< - CPS::Base::ReducedOrderSynchronGenerator> - _4OrderDPTPM( - "4TPM", - new DerivedCreator< - CPS::DP::Ph1::SynchronGenerator4OrderTPM, - CPS::Base::ReducedOrderSynchronGenerator>); - FactoryRegistration - _6aOrderSP("6a", new DerivedCreator< - CPS::DP::Ph1::SynchronGenerator6aOrderVBR, - CPS::DP::Ph1::ReducedOrderSynchronGeneratorVBR>); - FactoryRegistration - _6bOrderSP("6b", new DerivedCreator< - CPS::DP::Ph1::SynchronGenerator6bOrderVBR, - CPS::DP::Ph1::ReducedOrderSynchronGeneratorVBR>); - FactoryRegistration< - CPS::Base::ReducedOrderSynchronGenerator> - _6OrderDPIter( - "6PCM", - new DerivedCreator< - CPS::DP::Ph1::SynchronGenerator6OrderPCM, - CPS::Base::ReducedOrderSynchronGenerator>); - } - } - } - - namespace EMT { - namespace Ph3 { - void registerSynchronGenerators() { - FactoryRegistration - _3OrderSP("3", new DerivedCreator< - CPS::EMT::Ph3::SynchronGenerator3OrderVBR, + FactoryRegistration> + _6OrderDPIter( + "6PCM", new DerivedCreator< + CPS::DP::Ph1::SynchronGenerator6OrderPCM, + CPS::Base::ReducedOrderSynchronGenerator>); +} +} // namespace Ph1 +} // namespace DP + +namespace EMT { +namespace Ph3 { +void registerSynchronGenerators() { + FactoryRegistration + _3OrderSP( + "3", + new DerivedCreator); - FactoryRegistration - _4OrderSP("4", new DerivedCreator< - CPS::EMT::Ph3::SynchronGenerator4OrderVBR, + FactoryRegistration + _4OrderSP( + "4", + new DerivedCreator); - FactoryRegistration - _6aOrderSP("6a", - new DerivedCreator< - CPS::EMT::Ph3::SynchronGenerator6aOrderVBR, - CPS::EMT::Ph3::ReducedOrderSynchronGeneratorVBR>); - FactoryRegistration - _6bOrderSP("6b", - new DerivedCreator< - CPS::EMT::Ph3::SynchronGenerator6bOrderVBR, - CPS::EMT::Ph3::ReducedOrderSynchronGeneratorVBR>); - } - } - } + FactoryRegistration + _6aOrderSP( + "6a", + new DerivedCreator); + FactoryRegistration + _6bOrderSP( + "6b", + new DerivedCreator); +} +} // namespace Ph3 +} // namespace EMT - } +} // namespace SynchronGeneratorFactory \ No newline at end of file diff --git a/dpsim-models/include/dpsim-models/SP/SP_Ph1_AvVoltageSourceInverterDQ.h b/dpsim-models/include/dpsim-models/SP/SP_Ph1_AvVoltageSourceInverterDQ.h index cd8c7a50b0..962f1bc1db 100644 --- a/dpsim-models/include/dpsim-models/SP/SP_Ph1_AvVoltageSourceInverterDQ.h +++ b/dpsim-models/include/dpsim-models/SP/SP_Ph1_AvVoltageSourceInverterDQ.h @@ -202,4 +202,4 @@ class AvVoltageSourceInverterDQ }; } // namespace Ph1 } // namespace SP -} // namespace CPS +} // namespace CPS \ No newline at end of file diff --git a/dpsim-models/include/dpsim-models/Signal/ExciterDC1.h b/dpsim-models/include/dpsim-models/Signal/ExciterDC1.h index 7bd4011630..06524d0e2e 100644 --- a/dpsim-models/include/dpsim-models/Signal/ExciterDC1.h +++ b/dpsim-models/include/dpsim-models/Signal/ExciterDC1.h @@ -8,99 +8,97 @@ #pragma once -#include #include #include +#include namespace CPS { namespace Signal { - class ExciterDC1Parameters : - public Base::ExciterParameters, - public SharedFactory { - - public: - /// Transducer time constant (s) - Real Tr = 0; - /// Amplifier time constant - Real Ta = 0; - /// Pole of the regulator inherent dynamic - Real Tb = 0; - /// Zero of the regulator inherent dynamic - Real Tc = 0; - /// Field circuit time constant - Real Tef = 0; - /// Stabilizer time constant - Real Tf = 0; - /// Amplifier gain - Real Ka = 0; - /// Field circuit integral deviation - Real Kef = 0; - /// Stabilizer gain - Real Kf = 0; - /// First ceiling coefficient - Real Aef = 0; - /// Second ceiling coefficient - Real Bef = 0; - /// - Real MaxVa = 0; - /// - Real MinVa = 0; - }; +class ExciterDC1Parameters : public Base::ExciterParameters, + public SharedFactory { + +public: + /// Transducer time constant (s) + Real Tr = 0; + /// Amplifier time constant + Real Ta = 0; + /// Pole of the regulator inherent dynamic + Real Tb = 0; + /// Zero of the regulator inherent dynamic + Real Tc = 0; + /// Field circuit time constant + Real Tef = 0; + /// Stabilizer time constant + Real Tf = 0; + /// Amplifier gain + Real Ka = 0; + /// Field circuit integral deviation + Real Kef = 0; + /// Stabilizer gain + Real Kf = 0; + /// First ceiling coefficient + Real Aef = 0; + /// Second ceiling coefficient + Real Bef = 0; + /// + Real MaxVa = 0; + /// + Real MinVa = 0; +}; - /// Type DC1 exciter - /// Ref.: IEEE Recommended Practice for Excitation System Models for Power System Stability Studies - class ExciterDC1 : - public Base::Exciter, - public SimSignalComp, - public SharedFactory { +/// Type DC1 exciter +/// Ref.: IEEE Recommended Practice for Excitation System Models for Power System Stability Studies +class ExciterDC1 : public Base::Exciter, + public SimSignalComp, + public SharedFactory { - private: - /// Exciter Parameters - std::shared_ptr mParameters; +private: + /// Exciter Parameters + std::shared_ptr mParameters; - // ### Exciter Variables #### - /// Transducer input at time k-1 - Real mVh = 0; - /// Transducer output at time k - Real mVr = 0; - /// Transducer output at time k-1 - Real mVr_prev = 0; - /// Output of stablizing feedback at time k - Real mVf = 0; - /// Output of stablizing feedback at time k-1 - Real mVf_prev = 0; - /// - Real mVb = 0; - /// - Real mVb_prev = 0; - /// Output of Regulator at time k - Real mVin = 0; - /// Output of regulator at time k-1 - Real mVin_prev = 0; - /// Output of amplifier at time k - Real mVa = 0; - /// Output of amplifiert at time k-1 - Real mVa_prev = 0; - /// - /// Exciter output at time k (induced emf by the field current under no-load conditions) - Real mEf = 0; - /// Exciter output at time k-1 - Real mEf_prev = 0; - /// Saturation function - Real mVsat = 0; - /// - Real mVref = 0; + // ### Exciter Variables #### + /// Transducer input at time k-1 + Real mVh = 0; + /// Transducer output at time k + Real mVr = 0; + /// Transducer output at time k-1 + Real mVr_prev = 0; + /// Output of stablizing feedback at time k + Real mVf = 0; + /// Output of stablizing feedback at time k-1 + Real mVf_prev = 0; + /// + Real mVb = 0; + /// + Real mVb_prev = 0; + /// Output of Regulator at time k + Real mVin = 0; + /// Output of regulator at time k-1 + Real mVin_prev = 0; + /// Output of amplifier at time k + Real mVa = 0; + /// Output of amplifiert at time k-1 + Real mVa_prev = 0; + /// + /// Exciter output at time k (induced emf by the field current under no-load conditions) + Real mEf = 0; + /// Exciter output at time k-1 + Real mEf_prev = 0; + /// Saturation function + Real mVsat = 0; + /// + Real mVref = 0; - public: - /// Constructor - ExciterDC1(const String & name, Logger::Level logLevel = Logger::Level::info); - /// Initializes exciter parameters - void setParameters(std::shared_ptr parameters) final; - /// Initializes exciter variables - void initialize(Real Vh_init, Real Vf_init) final; - /// Performs an step to update field voltage value - Real step(Real Vd, Real Vq, Real dt, Real Vpss = 0) final; - }; -} -} +public: + /// Constructor + ExciterDC1(const String &name, Logger::Level logLevel = Logger::Level::info); + /// Initializes exciter parameters + void setParameters(std::shared_ptr parameters) final; + /// Initializes exciter variables + void initialize(Real Vh_init, Real Vf_init) final; + /// Performs an step to update field voltage value + Real step(Real Vd, Real Vq, Real dt, Real Vpss = 0) final; +}; +} // namespace Signal +} // namespace CPS diff --git a/dpsim-models/include/dpsim-models/Signal/ExciterDC1Simp.h b/dpsim-models/include/dpsim-models/Signal/ExciterDC1Simp.h index 75dc53a238..b068dc7cc7 100644 --- a/dpsim-models/include/dpsim-models/Signal/ExciterDC1Simp.h +++ b/dpsim-models/include/dpsim-models/Signal/ExciterDC1Simp.h @@ -44,65 +44,45 @@ class ExciterDC1SimpParameters Real MinVa = 0; }; -private: -/// Exciter Parameters -std::shared_ptr mParameters; - -// ### Exciter Variables #### -/// Reference voltage (with effect of PSS) -Real mVref = 0; -/// Output of voltage transducer at time k-1 -Real mVr_prev = 0; -/// Output of stablizing feedback at time k-1 -Real mVf_prev = 0; -/// Output of amplifier output at time k-1 -Real mVa_prev = 0; -/// Exciter output at time k-1 -Real mEf_prev = 0; - -/// Input of voltage transducer -Real mVh; -/// Output of voltage transducer at time k-1 -Real mVr; -/// Output of stablizing feedback at time k -Real mVf; -/// Input of amplifier at time k -Real mVin; -/// Output of amplifier at time k -Real mVa; -/// Amplifier output at time k -Real mVsat; -/// Exciter output at time k (induced emf by the field current under no-load conditions) -Real mEf; +/// AVR model type 1 +/// Simplified model of IEEE DC1 type exciter. It does not model the time constants +/// Tb and Tc which are normally small and thereby ignored. +/// Ref.: Milano - Power system modelling and scripting, page 363 class ExciterDC1Simp : public Base::Exciter, public SimSignalComp, public SharedFactory { private: - // ### Exciter Parameters #### - /// Amplifier time constant (s) - Real mTa; - /// Amplifier gain (pu/pu) - Real mKa; - /// Field circuit integral deviation - Real mKef; - /// Field circuit time constant (s) - Real mTef; - /// Stabilizer gain (s pu/pu) - Real mKf; - /// Stabilizer time constant (s) - Real mTf; - /// Measurement time constant (s) - Real mTr; - /// First ceiling coefficient - Real mAef; - /// Second ceiling coefficient - Real mBef; - /// Maximum amplifier output (p.u.) - Real mMaxVa; - /// Minumum amplifier output (p.u.) - Real mMinVa; + /// Exciter Parameters + std::shared_ptr mParameters; + + // ### Exciter Variables #### + /// Reference voltage (with effect of PSS) + Real mVref = 0; + /// Output of voltage transducer at time k-1 + Real mVr_prev = 0; + /// Output of stablizing feedback at time k-1 + Real mVf_prev = 0; + /// Output of amplifier output at time k-1 + Real mVa_prev = 0; + /// Exciter output at time k-1 + Real mEf_prev = 0; + + /// Input of voltage transducer + Real mVh; + /// Output of voltage transducer at time k-1 + Real mVr; + /// Output of stablizing feedback at time k + Real mVf; + /// Input of amplifier at time k + Real mVin; + /// Output of amplifier at time k + Real mVa; + /// Amplifier output at time k + Real mVsat; + /// Exciter output at time k (induced emf by the field current under no-load conditions) + Real mEf; public: /// Constructor @@ -116,4 +96,4 @@ class ExciterDC1Simp : public Base::Exciter, Real step(Real mVd, Real mVq, Real dt, Real Vpss = 0) final; }; } // namespace Signal -} // namespace CPS +} // namespace CPS \ No newline at end of file diff --git a/dpsim-models/include/dpsim-models/Signal/ExciterST1Simp.h b/dpsim-models/include/dpsim-models/Signal/ExciterST1Simp.h index 60515eef9f..0144861248 100644 --- a/dpsim-models/include/dpsim-models/Signal/ExciterST1Simp.h +++ b/dpsim-models/include/dpsim-models/Signal/ExciterST1Simp.h @@ -8,60 +8,59 @@ #pragma once -#include #include #include +#include namespace CPS { namespace Signal { - class ExciterST1Parameters : - public Base::ExciterParameters, - public SharedFactory { +class ExciterST1Parameters : public Base::ExciterParameters, + public SharedFactory { - public: - /// Transducer time constant (s) - Real Tr = 0; - /// Amplifier gain - Real Ka = 0; - /// - Real MaxVa = 0; - /// - Real MinVa = 0; - }; +public: + /// Transducer time constant (s) + Real Tr = 0; + /// Amplifier gain + Real Ka = 0; + /// + Real MaxVa = 0; + /// + Real MinVa = 0; +}; - /// Simplified Type ST1 exciter (Regulator time constant Ta=0, without transient gain reduction: Tb=Tc=0) - /// Used in Kundur two areas system - /// Ref.: Kundur, 9.815 - class ExciterST1Simp : - public Base::Exciter, - public SimSignalComp, - public SharedFactory { +/// Simplified Type ST1 exciter (Regulator time constant Ta=0, without transient gain reduction: Tb=Tc=0) +/// Used in Kundur two areas system +/// Ref.: Kundur, 9.815 +class ExciterST1Simp : public Base::Exciter, + public SimSignalComp, + public SharedFactory { - private: - /// Exciter Parameters - std::shared_ptr mParameters; +private: + /// Exciter Parameters + std::shared_ptr mParameters; - /// Transducer input at time k-1 - Real mVh = 0; - /// Transducer output at time k - Real mVr = 0; - /// Transducer output at time k-1 - Real mVr_prev = 0; - /// Exciter output at time k (induced emf by the field current under no-load conditions) - Real mEf = 0; - /// - Real mVref = 0; + /// Transducer input at time k-1 + Real mVh = 0; + /// Transducer output at time k + Real mVr = 0; + /// Transducer output at time k-1 + Real mVr_prev = 0; + /// Exciter output at time k (induced emf by the field current under no-load conditions) + Real mEf = 0; + /// + Real mVref = 0; - public: - /// Constructor - ExciterST1Simp(const String & name, Logger::Level logLevel = Logger::Level::info); - /// Initializes exciter parameters - void setParameters(std::shared_ptr parameters) final; - /// Initializes exciter variables - void initialize(Real Vh_init, Real Vf_init) final; - /// Performs an step to update field voltage value - Real step(Real Vd, Real Vq, Real dt, Real Vpss = 0) final; - }; -} -} +public: + /// Constructor + ExciterST1Simp(const String &name, + Logger::Level logLevel = Logger::Level::info); + /// Initializes exciter parameters + void setParameters(std::shared_ptr parameters) final; + /// Initializes exciter variables + void initialize(Real Vh_init, Real Vf_init) final; + /// Performs an step to update field voltage value + Real step(Real Vd, Real Vq, Real dt, Real Vpss = 0) final; +}; +} // namespace Signal +} // namespace CPS diff --git a/dpsim-models/include/dpsim-models/Signal/ExciterStatic.h b/dpsim-models/include/dpsim-models/Signal/ExciterStatic.h index 710fd725ad..0aaff1b985 100644 --- a/dpsim-models/include/dpsim-models/Signal/ExciterStatic.h +++ b/dpsim-models/include/dpsim-models/Signal/ExciterStatic.h @@ -8,80 +8,79 @@ #pragma once -#include #include #include +#include namespace CPS { namespace Signal { - class ExciterStaticParameters : - public Base::ExciterParameters, - public SharedFactory { - - public: - /// Transducer time constant (s) (optional parameter) - Real Tr = 0; - /// Time constant of the numerator in the lead lag block (s) - Real Ta = 0; - /// Time constant of the denumerator in the lead lag block (s) - Real Tb = 0; - /// Time constant of the exciter machine (s) - Real Te = 0; - /// Proportional controller with the gain Ka - Real Ka = 0; +class ExciterStaticParameters : public Base::ExciterParameters, + public SharedFactory { + +public: + /// Transducer time constant (s) (optional parameter) + Real Tr = 0; + /// Time constant of the numerator in the lead lag block (s) + Real Ta = 0; + /// Time constant of the denumerator in the lead lag block (s) + Real Tb = 0; + /// Time constant of the exciter machine (s) + Real Te = 0; + /// Proportional controller with the gain Ka + Real Ka = 0; - /// Maximum EMF - Real MaxEfd = 0; - /// Minimum EMF - Real MinEfd = 0; + /// Maximum EMF + Real MaxEfd = 0; + /// Minimum EMF + Real MinEfd = 0; - /// Proportional gain of anti-Windup - Real Kbc = 0; - }; + /// Proportional gain of anti-Windup + Real Kbc = 0; +}; - /// Static Excitation System - /// Ref.: MatPAT Paper "Transmission System stability assesment within an integrated grid develpmpent process" Andreas Roehred - class ExciterStatic : - public Base::Exciter, - public SimSignalComp, - public SharedFactory { +/// Static Excitation System +/// Ref.: MatPAT Paper "Transmission System stability assesment within an integrated grid develpmpent process" Andreas Roehred +class ExciterStatic : public Base::Exciter, + public SimSignalComp, + public SharedFactory { - private: - /// Exciter Parameters - std::shared_ptr mParameters; - /// Set point of the exciter - Real mVref = 0; - /// Measured voltage at the terminal of generator (Input of the exciter) at step k - Real mVh = 0; - /// Transducer output at time k and k+1 - Real mVr = 0; - Real mVr_prev = 0; - /// Auxilary state variable from partial fraction decompostion (1+sT_A)/(1+sT_B) at step k and k+1 - Real mXb = 0; - Real mXb_prev = 0; - /// Input of the first lead lag block at time k (=Vref-Vh+Vpss) - Real mVin = 0; - /// Input of the second lag block 1/(1+sTe) - Real mVe; - /// Exciter output (EMF of the generator) at step k+1 - Real mEfd = 0; - /// Exciter output (EMF of the generator) at step k+1 after the windup - Real mEfdLim = 0; +private: + /// Exciter Parameters + std::shared_ptr mParameters; + /// Set point of the exciter + Real mVref = 0; + /// Measured voltage at the terminal of generator (Input of the exciter) at step k + Real mVh = 0; + /// Transducer output at time k and k+1 + Real mVr = 0; + Real mVr_prev = 0; + /// Auxilary state variable from partial fraction decompostion (1+sT_A)/(1+sT_B) at step k and k+1 + Real mXb = 0; + Real mXb_prev = 0; + /// Input of the first lead lag block at time k (=Vref-Vh+Vpss) + Real mVin = 0; + /// Input of the second lag block 1/(1+sTe) + Real mVe; + /// Exciter output (EMF of the generator) at step k+1 + Real mEfd = 0; + /// Exciter output (EMF of the generator) at step k+1 after the windup + Real mEfdLim = 0; - /// Auxiliar parameters - Real mCa; - Real mCb; + /// Auxiliar parameters + Real mCa; + Real mCb; - public: - /// Constructor - ExciterStatic(const String & name, Logger::Level logLevel = Logger::Level::info); - /// Initializes exciter parameters - void setParameters(std::shared_ptr parameters) final; - /// Initializes exciter variables - void initialize(Real Vh_init, Real Vf_init) final; - /// Performs an step to update field voltage value - Real step(Real Vd, Real Vq, Real dt, Real Vpss = 0) final; - }; -} -} \ No newline at end of file +public: + /// Constructor + ExciterStatic(const String &name, + Logger::Level logLevel = Logger::Level::info); + /// Initializes exciter parameters + void setParameters(std::shared_ptr parameters) final; + /// Initializes exciter variables + void initialize(Real Vh_init, Real Vf_init) final; + /// Performs an step to update field voltage value + Real step(Real Vd, Real Vq, Real dt, Real Vpss = 0) final; +}; +} // namespace Signal +} // namespace CPS \ No newline at end of file diff --git a/dpsim-models/include/dpsim-models/Signal/HydroTurbine.h b/dpsim-models/include/dpsim-models/Signal/HydroTurbine.h index 48060c4b8a..8dedfa6b2f 100644 --- a/dpsim-models/include/dpsim-models/Signal/HydroTurbine.h +++ b/dpsim-models/include/dpsim-models/Signal/HydroTurbine.h @@ -1,59 +1,56 @@ #pragma once -#include #include #include +#include namespace CPS { namespace Signal { - class HydroTurbineParameters : - public Base::TurbineParameters, - public SharedFactory { - - public: - /// Water starting time (s) - Real Tw; - }; +class HydroTurbineParameters : public Base::TurbineParameters, + public SharedFactory { +public: + /// Water starting time (s) + Real Tw; +}; - /// Hydro turbine model - /// Ref.: MATPAT Paper - class HydroTurbine : - public SimSignalComp, - public Base::Turbine, - public SharedFactory { +/// Hydro turbine model +/// Ref.: MATPAT Paper +class HydroTurbine : public SimSignalComp, + public Base::Turbine, + public SharedFactory { - private: - /// Turbine Parameters - std::shared_ptr mParameters; +private: + /// Turbine Parameters + std::shared_ptr mParameters; - /// Turbine variables - /// State variable after the PT1 with time constant 0.5T_w at time step k - Real mX1; - /// State variable after the PT1 with time constant 0.5T_w at time at time step k+1 - Real mX1_next; + /// Turbine variables + /// State variable after the PT1 with time constant 0.5T_w at time step k + Real mX1; + /// State variable after the PT1 with time constant 0.5T_w at time at time step k+1 + Real mX1_next; - /// Output mechanical power of the tubine in pu =mechanical torque in pu at k - Real mPm; + /// Output mechanical power of the tubine in pu =mechanical torque in pu at k + Real mPm; - public: - /// - explicit HydroTurbine(const String & name) : SimSignalComp(name, name) { } +public: + /// + explicit HydroTurbine(const String &name) : SimSignalComp(name, name) {} - /// Constructor with log level - HydroTurbine(const String & name, CPS::Logger::Level logLevel); + /// Constructor with log level + HydroTurbine(const String &name, CPS::Logger::Level logLevel); - /// Sets Parameters of the turbine - void setParameters(std::shared_ptr parameters) final; + /// Sets Parameters of the turbine + void setParameters(std::shared_ptr parameters) final; - /// Initialises the initial state of the turbine - void initialize(Real Pminit) final; + /// Initialises the initial state of the turbine + void initialize(Real Pminit) final; - ///Gets the current input Pgv(k) from fovernor and returns the current output of the system (during k) - /// and if needed caltulates the state variables for the next step - Real step(Real Pgv, Real dt) final; - }; + ///Gets the current input Pgv(k) from fovernor and returns the current output of the system (during k) + /// and if needed caltulates the state variables for the next step + Real step(Real Pgv, Real dt) final; +}; -} -} \ No newline at end of file +} // namespace Signal +} // namespace CPS \ No newline at end of file diff --git a/dpsim-models/include/dpsim-models/Signal/HydroTurbineGovernor.h b/dpsim-models/include/dpsim-models/Signal/HydroTurbineGovernor.h index c196415c22..2c55cbca0b 100644 --- a/dpsim-models/include/dpsim-models/Signal/HydroTurbineGovernor.h +++ b/dpsim-models/include/dpsim-models/Signal/HydroTurbineGovernor.h @@ -8,83 +8,84 @@ #pragma once -#include #include #include +#include namespace CPS { namespace Signal { - class HydroGorvernorParameters : - public Base::GovernorParameters, - public SharedFactory { - - public: - /// droop coefficient - Real R; - /// - Real T1; - /// - Real T2; - /// - Real T3; - /// Maximum mechanical power(pu) - Real Pmax; - /// Minimum mechanical power (pu) - Real Pmin; - // Setpoint for omega (pu). It is adviced to choose Om_ref=1 - Real OmRef; - }; - - // ### Hydro turbine governor parameters, where Omega_ref, P_ref are constant and T_1=0 ### - /// Ref.: MATPAT Paper - class HydroTurbineGovernor: - public SimSignalComp, - public Base::Governor, - public SharedFactory { - - private: - /// Governor Parameters - std::shared_ptr mParameters; - - //Setpoint for mechanical Power (pu) - Real mPref; - - // Delta Omega = Omega_ref-Omega_meas at k and at k-1 - Real mDelOm; - Real mDelOm_prev; - - // State Variable of T1 PT1 at k and at k-1 - Real mX1; - Real mX1_prev; - - // State Variable of T3 PT1 at k and at k-1 - Real mX2; - Real mX2_prev; - - // The outpur of the Governor at k - Real mPgv; - - /// Auxiliar variables - Real mCa; - Real mCb; - - public: - /// - explicit HydroTurbineGovernor(const String & name) : SimSignalComp(name, name) { } - - /// Constructor with log level - HydroTurbineGovernor(const String & name, CPS::Logger::Level logLevel); - - /// Sets Parameters of the turbine - void setParameters(std::shared_ptr parameters) final; - - /// Initialises the initial state of the turbine - void initialize(Real Pref) final; - - /// Performs a step to update all state variables and the output - Real step(Real Omega, Real dt) final; - }; - -} -} \ No newline at end of file +class HydroGorvernorParameters + : public Base::GovernorParameters, + public SharedFactory { + +public: + /// droop coefficient + Real R; + /// + Real T1; + /// + Real T2; + /// + Real T3; + /// Maximum mechanical power(pu) + Real Pmax; + /// Minimum mechanical power (pu) + Real Pmin; + // Setpoint for omega (pu). It is adviced to choose Om_ref=1 + Real OmRef; +}; + +// ### Hydro turbine governor parameters, where Omega_ref, P_ref are constant and T_1=0 ### +/// Ref.: MATPAT Paper +class HydroTurbineGovernor : public SimSignalComp, + public Base::Governor, + public SharedFactory { + +private: + /// Governor Parameters + std::shared_ptr mParameters; + + //Setpoint for mechanical Power (pu) + Real mPref; + + // Delta Omega = Omega_ref-Omega_meas at k and at k-1 + Real mDelOm; + Real mDelOm_prev; + + // State Variable of T1 PT1 at k and at k-1 + Real mX1; + Real mX1_prev; + + // State Variable of T3 PT1 at k and at k-1 + Real mX2; + Real mX2_prev; + + // The outpur of the Governor at k + Real mPgv; + + /// Auxiliar variables + Real mCa; + Real mCb; + +public: + /// + explicit HydroTurbineGovernor(const String &name) + : SimSignalComp(name, name) {} + + /// Constructor with log level + HydroTurbineGovernor(const String &name, CPS::Logger::Level logLevel); + + /// Sets Parameters of the turbine + void + setParameters(std::shared_ptr parameters) final; + + /// Initialises the initial state of the turbine + void initialize(Real Pref) final; + + /// Performs a step to update all state variables and the output + Real step(Real Omega, Real dt) final; +}; + +} // namespace Signal +} // namespace CPS \ No newline at end of file diff --git a/dpsim-models/include/dpsim-models/Signal/PSS1A.h b/dpsim-models/include/dpsim-models/Signal/PSS1A.h index 1ae58970d3..314da5a0c4 100644 --- a/dpsim-models/include/dpsim-models/Signal/PSS1A.h +++ b/dpsim-models/include/dpsim-models/Signal/PSS1A.h @@ -8,94 +8,92 @@ #pragma once -#include #include #include +#include namespace CPS { namespace Signal { - class PSS1AParameters : - public Base::PSSParameters, - public SharedFactory { - - public: - /// Gain for active power (pu/pu) - Real Kp; - /// Gain for bus voltage magnitude (pu/pu) - Real Kv; - /// Stabilizer gain (pu/pu) - Real Kw; - /// First stabilizer time constant (s) - Real T1; - /// Second stabilizer time constant (s) - Real T2; - /// Thrid stabilizer time constant (s) - Real T3; - /// Fourth stabilizer time constant (s) - Real T4; - /// Max stabilizer output signal (pu) - Real Vs_max; - /// Min stabilizer output signal (pu) - Real Vs_min; - /// Wash-out time constant (s) - Real Tw; - }; +class PSS1AParameters : public Base::PSSParameters, + public SharedFactory { + +public: + /// Gain for active power (pu/pu) + Real Kp; + /// Gain for bus voltage magnitude (pu/pu) + Real Kv; + /// Stabilizer gain (pu/pu) + Real Kw; + /// First stabilizer time constant (s) + Real T1; + /// Second stabilizer time constant (s) + Real T2; + /// Thrid stabilizer time constant (s) + Real T3; + /// Fourth stabilizer time constant (s) + Real T4; + /// Max stabilizer output signal (pu) + Real Vs_max; + /// Min stabilizer output signal (pu) + Real Vs_min; + /// Wash-out time constant (s) + Real Tw; +}; - /// Power system stabilizer type 2 - /// Ref.: Milano - Power system modelling and scripting, page 371 - class PSS1A : - public SimSignalComp, - public Base::PSS, - public SharedFactory { +/// Power system stabilizer type 2 +/// Ref.: Milano - Power system modelling and scripting, page 371 +class PSS1A : public SimSignalComp, + public Base::PSS, + public SharedFactory { - private: - // ### PSS Parameters #### - /// - std::shared_ptr mParameters; - /// - Real mA; - /// - Real mB; +private: + // ### PSS Parameters #### + /// + std::shared_ptr mParameters; + /// + Real mA; + /// + Real mB; - /// previos step value of state variable - /// - Real mV1_prev; - /// - Real mV2_prev; - /// - Real mV3_prev; - /// - Real mVs_prev; - /// - Real mOmega_prev; - /// - Real mActivePower_prev; - /// - Real mVh_prev; + /// previos step value of state variable + /// + Real mV1_prev; + /// + Real mV2_prev; + /// + Real mV3_prev; + /// + Real mVs_prev; + /// + Real mOmega_prev; + /// + Real mActivePower_prev; + /// + Real mVh_prev; - protected: - /// State Variables - /// Wash-out output - Real mV1; - /// Output of the first phase compensation block - Real mV2; - /// Output of the second phase compensation block - Real mV3; - /// PSS output at t=k - Real mVs; +protected: + /// State Variables + /// Wash-out output + Real mV1; + /// Output of the first phase compensation block + Real mV2; + /// Output of the second phase compensation block + Real mV3; + /// PSS output at t=k + Real mVs; - public: - /// - explicit PSS1A(const String & name) : SimSignalComp(name, name) { } - /// Constructor with log level - PSS1A(const String & name, CPS::Logger::Level logLevel); - /// Initializes PSS parameters - void setParameters(std::shared_ptr parameters) final; - /// Initializes PSS state variables - void initialize(Real omega, Real activePower, Real Vd, Real Vq) final; - /// - Real step(Real omega, Real activePower, Real Vd, Real Vq, Real dt) final; - }; -} -} +public: + /// + explicit PSS1A(const String &name) : SimSignalComp(name, name) {} + /// Constructor with log level + PSS1A(const String &name, CPS::Logger::Level logLevel); + /// Initializes PSS parameters + void setParameters(std::shared_ptr parameters) final; + /// Initializes PSS state variables + void initialize(Real omega, Real activePower, Real Vd, Real Vq) final; + /// + Real step(Real omega, Real activePower, Real Vd, Real Vq, Real dt) final; +}; +} // namespace Signal +} // namespace CPS diff --git a/dpsim-models/include/dpsim-models/Signal/SteamTurbine.h b/dpsim-models/include/dpsim-models/Signal/SteamTurbine.h index 638aa7971c..3b7488b224 100644 --- a/dpsim-models/include/dpsim-models/Signal/SteamTurbine.h +++ b/dpsim-models/include/dpsim-models/Signal/SteamTurbine.h @@ -1,77 +1,75 @@ #pragma once -#include #include #include +#include namespace CPS { namespace Signal { - class SteamTurbineParameters : - public Base::TurbineParameters, - public SharedFactory { - - public: - /// Power fraction of a high pressure stage - Real Fhp; - /// Power fraction of an intermediate pressure stage - Real Fip; - /// Power fraction of a low pressure stage - Real Flp; - /// Time constant of main inlet volume and steam chest (s) - Real Tch; - /// Time constant of reheater (s) - Real Trh; - /// Time constant of cross over piping and LP inlet volumes(s) - Real Tco; - }; +class SteamTurbineParameters : public Base::TurbineParameters, + public SharedFactory { + +public: + /// Power fraction of a high pressure stage + Real Fhp; + /// Power fraction of an intermediate pressure stage + Real Fip; + /// Power fraction of a low pressure stage + Real Flp; + /// Time constant of main inlet volume and steam chest (s) + Real Tch; + /// Time constant of reheater (s) + Real Trh; + /// Time constant of cross over piping and LP inlet volumes(s) + Real Tco; +}; - /// Steam turbine model - /// Single reheat turbine systems with three turbine stages coupled on one shaft (tandem compound) - /// Ref.: MATPAT Paper - class SteamTurbine : - public SimSignalComp, - public Base::Turbine, - public SharedFactory { +/// Steam turbine model +/// Single reheat turbine systems with three turbine stages coupled on one shaft (tandem compound) +/// Ref.: MATPAT Paper +class SteamTurbine : public SimSignalComp, + public Base::Turbine, + public SharedFactory { - private: - /// Turbine Parameters - std::shared_ptr mParameters; +private: + /// Turbine Parameters + std::shared_ptr mParameters; - /// Turbine variables - /// Power of low pressure stage at time step k+1 - Real mPlp_next; - /// Power of intermediate pressure stage at time step k+1; - Real mPip_next; - /// Power of high pressure stage at time step k+1; - Real mPhp_next; + /// Turbine variables + /// Power of low pressure stage at time step k+1 + Real mPlp_next; + /// Power of intermediate pressure stage at time step k+1; + Real mPip_next; + /// Power of high pressure stage at time step k+1; + Real mPhp_next; - /// Power of low pressure stage at time step k - Real mPlp; - /// Power of intermediate pressure stage at time step k; - Real mPip; - /// Power of high pressure stage at time step k; - Real mPhp; + /// Power of low pressure stage at time step k + Real mPlp; + /// Power of intermediate pressure stage at time step k; + Real mPip; + /// Power of high pressure stage at time step k; + Real mPhp; - /// Mechanical output power at time k (in pu is queal to torque) - Real mPm=0; + /// Mechanical output power at time k (in pu is queal to torque) + Real mPm = 0; - public: - /// - explicit SteamTurbine(const String & name) : SimSignalComp(name, name) { } +public: + /// + explicit SteamTurbine(const String &name) : SimSignalComp(name, name) {} - /// Constructor with log level - SteamTurbine(const String & name, CPS::Logger::Level logLevel); + /// Constructor with log level + SteamTurbine(const String &name, CPS::Logger::Level logLevel); - /// Sets Parameters of the turbine - void setParameters(std::shared_ptr parameters) final; + /// Sets Parameters of the turbine + void setParameters(std::shared_ptr parameters) final; - /// Initialises the initial state of the turbine - void initialize(Real Pminit) final; + /// Initialises the initial state of the turbine + void initialize(Real Pminit) final; - /// Performs a step to update all state variables and the output - Real step(Real Pgv, Real dt) final; - }; + /// Performs a step to update all state variables and the output + Real step(Real Pgv, Real dt) final; +}; -} -} \ No newline at end of file +} // namespace Signal +} // namespace CPS \ No newline at end of file diff --git a/dpsim-models/include/dpsim-models/Signal/SteamTurbineGovernor.h b/dpsim-models/include/dpsim-models/Signal/SteamTurbineGovernor.h index e1ec06075f..c5bb9c8183 100644 --- a/dpsim-models/include/dpsim-models/Signal/SteamTurbineGovernor.h +++ b/dpsim-models/include/dpsim-models/Signal/SteamTurbineGovernor.h @@ -8,96 +8,97 @@ #pragma once -#include #include #include +#include namespace CPS { namespace Signal { - class SteamGorvernorParameters : - public Base::GovernorParameters, - public SharedFactory { - - public: - /// Droop, the value 1/K in the controller K(1+sT_2) - Real R = 0; - /// T_1 related to the differentiator in the controlle K(1+sT_2)/(1+sT_1) - Real T1 = 0; - /// T_2 related to the differentiator in the controlle K(1+sT_2) - Real T2 = 0; - /// Time constant T_3 of the actuator in the Governor - Real T3 = 0; - - // ### Physical constraints ### - /// Maximum growth rate - Real dPmax = 0; - /// Minimum decay rate - Real dPmin = 0; - /// Maximum mechanical power(pu) - Real Pmax = 0; - /// Minimum mechanical power (pu) - Real Pmin = 0; - - /// Setpoint for omega (pu). It is adviced to choose Om_ref=1 - Real OmRef = 0; - - /// Proportional gain of anti-Windup - Real Kbc = 0; - }; - - /// Steam turbine governor, where Omega_ref, P_ref are constant and T_1=0 - /// Ref.: MATPAT Paper - class SteamTurbineGovernor: - public SimSignalComp, - public Base::Governor, - public SharedFactory { - - private: - /// Governor Parameters - std::shared_ptr mParameters; - - // ### Setpoints of the machine ### - /// Setpoint for mechanical Power (pu) - Real mPref; - - // ### State Variables ### - /// Delta Omega = Omega_ref-Omega_meas at t=k, t=k-1 and t=k-2 - Real mDelOm; - Real mDelOm_prev; - Real mDelOm_2prev; - /// Windup variable at t=k and t=k-1 - Real mP1; - Real mP1_prev; - /// p at time t=k-1 - Real mP; - /// Derivative of Pgv at time k-1 - Real mDerPgv; - /// The output of the Governor at k before the limiter - Real mPgvLim; - /// The output of the Governor at k after the limiter - Real mPgv; - - /// Auxiliar variables - Real mCa; - Real mCb; - - public: - /// - explicit SteamTurbineGovernor(const String & name) : SimSignalComp(name, name) { } - - /// Constructor with log level - SteamTurbineGovernor(const String & name, CPS::Logger::Level logLevel); - - /// Sets Parameters of the turbine - void setParameters(std::shared_ptr parameters) final; - - /// Initialises the initial state of the turbine - void initialize(Real Pref) final; - - /// Performs a step to update all state variables and the output - Real step(Real Omega, Real dt) final; - }; - -} -} \ No newline at end of file +class SteamGorvernorParameters + : public Base::GovernorParameters, + public SharedFactory { + +public: + /// Droop, the value 1/K in the controller K(1+sT_2) + Real R = 0; + /// T_1 related to the differentiator in the controlle K(1+sT_2)/(1+sT_1) + Real T1 = 0; + /// T_2 related to the differentiator in the controlle K(1+sT_2) + Real T2 = 0; + /// Time constant T_3 of the actuator in the Governor + Real T3 = 0; + + // ### Physical constraints ### + /// Maximum growth rate + Real dPmax = 0; + /// Minimum decay rate + Real dPmin = 0; + /// Maximum mechanical power(pu) + Real Pmax = 0; + /// Minimum mechanical power (pu) + Real Pmin = 0; + + /// Setpoint for omega (pu). It is adviced to choose Om_ref=1 + Real OmRef = 0; + + /// Proportional gain of anti-Windup + Real Kbc = 0; +}; + +/// Steam turbine governor, where Omega_ref, P_ref are constant and T_1=0 +/// Ref.: MATPAT Paper +class SteamTurbineGovernor : public SimSignalComp, + public Base::Governor, + public SharedFactory { + +private: + /// Governor Parameters + std::shared_ptr mParameters; + + // ### Setpoints of the machine ### + /// Setpoint for mechanical Power (pu) + Real mPref; + + // ### State Variables ### + /// Delta Omega = Omega_ref-Omega_meas at t=k, t=k-1 and t=k-2 + Real mDelOm; + Real mDelOm_prev; + Real mDelOm_2prev; + /// Windup variable at t=k and t=k-1 + Real mP1; + Real mP1_prev; + /// p at time t=k-1 + Real mP; + /// Derivative of Pgv at time k-1 + Real mDerPgv; + /// The output of the Governor at k before the limiter + Real mPgvLim; + /// The output of the Governor at k after the limiter + Real mPgv; + + /// Auxiliar variables + Real mCa; + Real mCb; + +public: + /// + explicit SteamTurbineGovernor(const String &name) + : SimSignalComp(name, name) {} + + /// Constructor with log level + SteamTurbineGovernor(const String &name, CPS::Logger::Level logLevel); + + /// Sets Parameters of the turbine + void + setParameters(std::shared_ptr parameters) final; + + /// Initialises the initial state of the turbine + void initialize(Real Pref) final; + + /// Performs a step to update all state variables and the output + Real step(Real Omega, Real dt) final; +}; + +} // namespace Signal +} // namespace CPS \ No newline at end of file diff --git a/dpsim-models/include/dpsim-models/Signal/TurbineGovernor.h b/dpsim-models/include/dpsim-models/Signal/TurbineGovernor.h index 98ebaf6086..48ecba12c0 100644 --- a/dpsim-models/include/dpsim-models/Signal/TurbineGovernor.h +++ b/dpsim-models/include/dpsim-models/Signal/TurbineGovernor.h @@ -8,6 +8,7 @@ #pragma once +#include #include #include diff --git a/dpsim-models/src/Base/Base_ReducedOrderSynchronGenerator.cpp b/dpsim-models/src/Base/Base_ReducedOrderSynchronGenerator.cpp index f1b8ef3f5d..9780ba886a 100644 --- a/dpsim-models/src/Base/Base_ReducedOrderSynchronGenerator.cpp +++ b/dpsim-models/src/Base/Base_ReducedOrderSynchronGenerator.cpp @@ -388,11 +388,6 @@ void Base::ReducedOrderSynchronGenerator::initializeFromNodesAndTerminals( (**mIntfCurrent)(1, 0) = (mInitCurrent * mBase_I * SHIFT_TO_PHASE_B).real(); (**mIntfCurrent)(2, 0) = (mInitCurrent * mBase_I * SHIFT_TO_PHASE_C).real(); - // set initial interface current - (**mIntfCurrent)(0, 0) = (mInitCurrent * mBase_I).real(); - (**mIntfCurrent)(1, 0) = (mInitCurrent * mBase_I * SHIFT_TO_PHASE_B).real(); - (**mIntfCurrent)(2, 0) = (mInitCurrent * mBase_I * SHIFT_TO_PHASE_C).real(); - // set initial interface voltage (**mIntfVoltage)(0, 0) = (mInitVoltage * mBase_V).real(); (**mIntfVoltage)(1, 0) = (mInitVoltage * mBase_V * SHIFT_TO_PHASE_B).real(); @@ -681,101 +676,6 @@ void Base::ReducedOrderSynchronGenerator::addTurbine( mHasTurbine = true; } -<<<<<<< HEAD -//Create a steam turbine via exsiting object -template -void Base::ReducedOrderSynchronGenerator::addSteamTurbine( - std::shared_ptr steamTurbine) { - mSteam = true; - mSteamTurbine = steamTurbine; - mHasTurbine = true; - if (mHasGovernor) - mHasTurbineGovernor = true; -} - -void Base::ReducedOrderSynchronGenerator::addSteamTurbineGovernor( - Real OmRef, Real Pref, Real R, Real T2, Real T3, Real dPmax, Real dPmin, - Real Pmax, Real Pmin) { - mSteam = true; - mSteamTurbineGovernor = Signal::SteamTurbineGovernor::make( - **this->mName + "_SteamTurbineGovernor", this->mLogLevel); - mSteamTurbineGovernor->setParameters(OmRef, R, T2, T3, dPmax, dPmin, Pmax, - Pmin); - mSteamTurbineGovernor->initialize(Pref); - mHasGovernor = true; - if (mHasTurbine) - mHasTurbineGovernor = true; -} -//Create a steam turbine governor via exsiting object -template -void Base::ReducedOrderSynchronGenerator::addSteamTurbineGovernor( - std::shared_ptr steamTurbineGovernor) { - mSteam = true; - mSteamTurbineGovernor = steamTurbineGovernor; - mHasGovernor = true; - if (mHasTurbine) - mHasTurbineGovernor = true; -} - -//Create a Hydro Turbine -template -void Base::ReducedOrderSynchronGenerator::addHydroTurbine( - Real Tw, Real Pminit) { - mHydro = true; - mHydroTurbine = Signal::HydroTurbine::make(**this->mName + "HydroTurbine", - this->mLogLevel); - mHydroTurbine->setParameters(Tw); - mHydroTurbine->initialize(Pminit); - mHasTurbine = true; - if (mHasGovernor) - mHasTurbineGovernor = true; -} - -//Create a Hydro turbine via exsiting object -template -void Base::ReducedOrderSynchronGenerator::addHydroTurbine( - std::shared_ptr HydroTurbine) { - mHydro = true; - mHydroTurbine = HydroTurbine; - mHasTurbine = true; - if (mHasGovernor) - mHasTurbineGovernor = true; -} - -//Create a Hydro Turbine Governor -template -void Base::ReducedOrderSynchronGenerator::addHydroTurbineGovernor( - Real OmRef, Real Pref, Real R, Real T1, Real T2, Real T3, Real Pmax, - Real Pmin) { - mHydro = true; - mHydroTurbineGovernor = Signal::HydroTurbineGovernor::make( - **this->mName + "_HydroTurbineGovernor", this->mLogLevel); - mHydroTurbineGovernor->setParameters(OmRef, R, T1, T2, T3, Pmax, Pmin); - mHydroTurbineGovernor->initialize(Pref); - mHasGovernor = true; - if (mHasTurbine) - mHasTurbineGovernor = true; -} - -//Create a Hydro turbine governor via exsiting object -template -void Base::ReducedOrderSynchronGenerator::addHydroTurbineGovernor( - std::shared_ptr hydroTurbineGovernor) { - mHydro = true; - mHydroTurbineGovernor = hydroTurbineGovernor; - mHasGovernor = true; - if (mHasTurbine) - mHasTurbineGovernor = true; -<<<<<<< HEAD ->>>>>>> 8e9cbf324 (HiWi added new Hydro and Steam Turbines and Governor models) ->>>>>>> 338446cac (added new Hydro and Steam Turbines and Governor models) -======= ->>>>>>> a32df206b (add base class for PSS) -} -* / - -======= ->>>>>>> 62767fe69 (new base class for Turbine) - // Declare specializations to move definitions to .cpp - template class CPS::Base::ReducedOrderSynchronGenerator; -template class CPS::Base::ReducedOrderSynchronGenerator; +// Declare specializations to move definitions to .cpp +template class CPS::Base::ReducedOrderSynchronGenerator; +template class CPS::Base::ReducedOrderSynchronGenerator; \ No newline at end of file diff --git a/dpsim-models/src/EMT/EMT_Ph3_SynchronGeneratorVBR.cpp b/dpsim-models/src/EMT/EMT_Ph3_SynchronGeneratorVBR.cpp index c4ed960019..d806e7a4c4 100644 --- a/dpsim-models/src/EMT/EMT_Ph3_SynchronGeneratorVBR.cpp +++ b/dpsim-models/src/EMT/EMT_Ph3_SynchronGeneratorVBR.cpp @@ -194,11 +194,11 @@ void EMT::Ph3::SynchronGeneratorVBR::mnaCompInitialize( mPsimq = mPsisr(3, 0); mPsimd = mPsisr(0, 0); - /// Init voltage excitation - mVfd = mVsr(1, 0); - **mVfd = mVsr(1, 0); + // #### VBR Model Dynamic variables ####################################### + CalculateAuxiliarConstants(mTimeStep * mBase_OmElec); + if (mNumDampingWindings == 2) mPsimq = mDLmq * (mPsikq1 / mLlkq1 + mPsikq2 / mLlkq2 + mIq); else @@ -597,4 +597,4 @@ Matrix EMT::Ph3::SynchronGeneratorVBR::inverseParkTransform(Real theta, Real q, abcVector << a, b, c; return abcVector; -} +} \ No newline at end of file diff --git a/dpsim-models/src/SP/SP_Ph1_AvVoltageSourceInverterDQ.cpp b/dpsim-models/src/SP/SP_Ph1_AvVoltageSourceInverterDQ.cpp index cc0d5cf31b..d6a3f0a172 100644 --- a/dpsim-models/src/SP/SP_Ph1_AvVoltageSourceInverterDQ.cpp +++ b/dpsim-models/src/SP/SP_Ph1_AvVoltageSourceInverterDQ.cpp @@ -428,4 +428,4 @@ void SP::Ph1::AvVoltageSourceInverterDQ::mnaCompUpdateVoltage( virtualNode->mnaUpdateVoltage(leftVector); (**mIntfVoltage)(0, 0) = Math::complexFromVectorElement(leftVector, matrixNodeIndex(0)); -} +} \ No newline at end of file diff --git a/dpsim-models/src/Signal/ExciterDC1Simp.cpp b/dpsim-models/src/Signal/ExciterDC1Simp.cpp index 27af09e19f..a273138678 100644 --- a/dpsim-models/src/Signal/ExciterDC1Simp.cpp +++ b/dpsim-models/src/Signal/ExciterDC1Simp.cpp @@ -55,15 +55,12 @@ void ExciterDC1Simp::initialize(Real Vh_init, Real Ef_init) { "\ninit Ef: {:e}", mVh, mEf); - SPDLOG_LOGGER_INFO(mSLog, - "Initially set excitation system initial values:" - "\ninit Vh: {:e}" - "\ninit Ef: {:e}", - mVh, mEf); - /// init value of transducer output mVr = mVh; + /// init value of stabilizing feedback output + mVf = 0.0; + /// ceiling function mVsat = mParameters->Aef * exp(mParameters->Bef * abs(mEf)); @@ -77,8 +74,8 @@ void ExciterDC1Simp::initialize(Real Vh_init, Real Ef_init) { /// init value of amplifier input mVin = mVa / mParameters->Ka; - /// init value of amplifier input - mVin = mVa / mKa; + /// + mVref = mVr + mVin; /// check initial conditions if (mEf - mVa / (mVsat + mParameters->Kef)) @@ -129,8 +126,5 @@ Real ExciterDC1Simp::step(Real mVd, Real mVq, Real dt, Real Vpss) { mEf = mEf_prev + dt / mParameters->Tef * (mVa_prev - (mVsat + mParameters->Kef) * mEf_prev); - // Exciter output - mEf = mEf_prev + dt / mTef * (mVa_prev - (mVsat + mKef) * mEf_prev); - return mEf; -} +} \ No newline at end of file diff --git a/dpsim-models/src/Signal/TurbineGovernorType1.cpp b/dpsim-models/src/Signal/TurbineGovernorType1.cpp index 4c8575503b..f8641d7b61 100644 --- a/dpsim-models/src/Signal/TurbineGovernorType1.cpp +++ b/dpsim-models/src/Signal/TurbineGovernorType1.cpp @@ -6,7 +6,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. *********************************************************************************/ -#include #include using namespace CPS; @@ -99,18 +98,5 @@ Real TurbineGovernorType1::step(Real Omega, Real dt) { mParameters->T4 / mParameters->T5 * (mXg2_prev + mParameters->T3 / mParameters->Tc * mXg1_prev); - /// Mechanical torque - mTm = mXg3 + mParameters->T4 / mParameters->T5 * - (mXg2 + mParameters->T3 / mParameters->Tc * mXg1); - - /// Reheat - mXg3 = - mXg3_prev + - dt / mT5 * - ((1 - mT4 / mT5) * (mXg2_prev + mT3 / mTc * mXg1_prev) - mXg3_prev); - - /// Mechanical torque - mTm = mXg3 + mT4 / mT5 * (mXg2 + mT3 / mTc * mXg1); - return mTm; -} +} \ No newline at end of file diff --git a/dpsim/examples/cxx/Circuits/DP_ReducedOrderSG_SMIB_Fault.cpp b/dpsim/examples/cxx/Circuits/DP_ReducedOrderSG_SMIB_Fault.cpp index f29658a24b..6dda05e3af 100644 --- a/dpsim/examples/cxx/Circuits/DP_ReducedOrderSG_SMIB_Fault.cpp +++ b/dpsim/examples/cxx/Circuits/DP_ReducedOrderSG_SMIB_Fault.cpp @@ -1,6 +1,6 @@ +#include "../Examples.h" #include #include -#include "../Examples.h" using namespace DPsim; using namespace CPS; @@ -16,6 +16,9 @@ const Examples::Components::SynchronousGeneratorKundur::MachineParameters int main(int argc, char *argv[]) { + // initiaize gen factory + SynchronGeneratorFactory::DP::Ph1::registerSynchronGenerators(); + //Simultion parameters Real startTimeFault = 30.0; Real endTimeFault = 30.1; @@ -28,20 +31,21 @@ int main(int argc, char *argv[]) { std::string stepSize_str = ""; std::string inertia_str = ""; - // initiaize gen factory - SynchronGeneratorFactory::DP::Ph1::registerSynchronGenerators(); - - //Simultion parameters - Real startTimeFault = 30.0; - Real endTimeFault = 30.1; - Real finalTime = 40; - Real timeStep = 100e-6; - Real H = syngenKundur.H; - Real switchClosed = GridParams.SwitchClosed; - Real switchOpen = GridParams.SwitchOpen; - std::string SGModel = "4"; - std::string stepSize_str = ""; - std::string inertia_str = ""; + // Command line args processing + CommandLineArgs args(argc, argv); + if (argc > 1) { + if (args.options.find("StepSize") != args.options.end()) { + timeStep = args.getOptionReal("StepSize"); + stepSize_str = "_StepSize_" + std::to_string(timeStep); + } + if (args.options.find("SGModel") != args.options.end()) { + SGModel = args.getOptionString("SGModel"); + } + if (args.options.find("Inertia") != args.options.end()) { + H = args.getOptionReal("Inertia"); + inertia_str = "_Inertia_" + std::to_string(H); + } + } Real logDownSampling; if (timeStep < 100e-6) @@ -124,7 +128,8 @@ int main(int argc, char *argv[]) { SimNode::make("n2DP", PhaseType::Single, initialVoltage_n2); // Synchronous generator - auto genDP = GeneratorFactory::createGenDP(SGModel, "SynGen", logLevel); + auto genDP = Factory::get().create( + SGModel, "SynGen", logLevel); genDP->setOperationalParametersPerUnit( syngenKundur.nomPower, syngenKundur.nomVoltage, syngenKundur.nomFreq, H, syngenKundur.Ld, syngenKundur.Lq, syngenKundur.Ll, syngenKundur.Ld_t, @@ -143,16 +148,10 @@ int main(int argc, char *argv[]) { lineDP->setParameters(GridParams.lineResistance, GridParams.lineInductance, GridParams.lineCapacitance, GridParams.lineConductance); - // Synchronous generator - auto genDP = Factory::get().create(SGModel, "SynGen", logLevel); - genDP->setOperationalParametersPerUnit( - syngenKundur.nomPower, syngenKundur.nomVoltage, - syngenKundur.nomFreq, H, - syngenKundur.Ld, syngenKundur.Lq, syngenKundur.Ll, - syngenKundur.Ld_t, syngenKundur.Lq_t, syngenKundur.Td0_t, syngenKundur.Tq0_t, - syngenKundur.Ld_s, syngenKundur.Lq_s, syngenKundur.Td0_s, syngenKundur.Tq0_s); - genDP->setInitialValues(initElecPower, initMechPower, n1PF->voltage()(0,0)); - genDP->setModelAsNortonSource(true); + //Breaker + auto fault = CPS::DP::Ph1::Switch::make("Br_fault", logLevel); + fault->setParameters(switchOpen, switchClosed); + fault->open(); // Topology genDP->connect({n1DP}); @@ -191,4 +190,4 @@ int main(int argc, char *argv[]) { simDP.addEvent(sw2); simDP.run(); -} +} \ No newline at end of file diff --git a/dpsim/examples/cxx/Circuits/DP_ReducedOrderSG_VBR_Load_Fault.cpp b/dpsim/examples/cxx/Circuits/DP_ReducedOrderSG_VBR_Load_Fault.cpp deleted file mode 100644 index ee86c8784a..0000000000 --- a/dpsim/examples/cxx/Circuits/DP_ReducedOrderSG_VBR_Load_Fault.cpp +++ /dev/null @@ -1,475 +0,0 @@ -#include "../Examples.h" -#include -#include - -using namespace DPsim; -using namespace CPS; -using namespace CPS::CIM; - -// Grid parameters -const Examples::Grids::SMIB::ScenarioConfig3 GridParams; - -// Generator parameters -const Examples::Components::SynchronousGeneratorKundur::MachineParameters - syngenKundur; - -// PSS -const auto pssPSAT = - Examples::Components::PowerSystemStabilizer::getPSS1AParametersPSAT(); - -// Excitation system -const auto excitationEremia = - Examples::Components::Exciter::getExciterParametersEremia(); - -// Turbine Governor Type 1 -const auto governorPSAT1 = - Examples::Components::TurbineGovernor::getTurbineGovernorPSAT1(); - -// Steam Turbine -//const Examples::Components::TurbineGovernor::SteamTurbine dSteamTurbine; -// Steam Turbine Governor -//const Examples::Components::TurbineGovernor::SteamTurbineGovernor dSteamGovernor; - -// Hydro Turbine -//const Examples::Components::TurbineGovernor::HydroTurbine dHydroTurbine; -// Hydro Turbine Governor -//const Examples::Components::TurbineGovernor::HydroTurbineGovernor dHydroGovernor; - -int main(int argc, char *argv[]) { - -<<<<<<< HEAD - // initiaize factories - ExciterFactory::registerExciters(); - SynchronGeneratorFactory::DP::Ph1::registerSynchronGenerators(); - -<<<<<<< HEAD - //Simultion parameters - Real switchClosed = GridParams.SwitchClosed; - Real switchOpen = GridParams.SwitchOpen; - Real startTimeFault = 1.0; - Real endTimeFault = 1.1; - Real finalTime = 5; - Real timeStep = 1e-3; - Real H = syngenKundur.H; - bool withPSS = false; - bool withExciter = false; - bool withTurbineGovernor = false; - std::string SGModel = "4"; - std::string stepSize_str = ""; - std::string inertia_str = ""; -======= - //Simultion parameters - Real switchClosed = GridParams.SwitchClosed; - Real switchOpen = GridParams.SwitchOpen; - Real startTimeFault = 1.0; - Real endTimeFault = 30; - Real finalTime = 60; - Real timeStep = 1e-3; - Real H = syngenKundur.H; -<<<<<<< HEAD - bool withPSS = false; - bool withExciter = false; - bool withTurbineGovernor = false; -======= - bool withExciter = true; - bool withTurbineGovernor = true; - bool hydro = true; - bool steam = false; - if (hydro == steam) - withTurbineGovernor = false; - ->>>>>>> 8e9cbf324 (HiWi added new Hydro and Steam Turbines and Governor models) - std::string SGModel = "4"; - std::string stepSize_str = ""; - std::string inertia_str = ""; ->>>>>>> 338446cac (added new Hydro and Steam Turbines and Governor models) -======= - // initiaize factories - ExciterFactory::registerExciters(); - SynchronGeneratorFactory::DP::Ph1::registerSynchronGenerators(); - - //Simultion parameters - Real switchClosed = GridParams.SwitchClosed; - Real switchOpen = GridParams.SwitchOpen; - Real startTimeFault = 1.0; - Real endTimeFault = 30; - Real finalTime = 60; - Real timeStep = 1e-3; - Real H = syngenKundur.H; - bool withPSS = false; - bool withExciter = false; - bool withTurbineGovernor = false; - //bool withExciter = true; - //bool withTurbineGovernor = true; - //bool hydro = true; - //bool steam =false; - //if ( hydro==steam) - // withTurbineGovernor=false; - - std::string SGModel = "4"; - std::string stepSize_str = ""; - std::string inertia_str = ""; - - // Command line args processing - CommandLineArgs args(argc, argv); - if (argc > 1) { - if (args.options.find("SGModel") != args.options.end()) - SGModel = args.getOptionString("SGModel"); - if (args.options.find("WITHPSS") != args.options.end()) - withPSS = args.getOptionBool("WITHPSS"); - if (args.options.find("WITHEXCITER") != args.options.end()) - withExciter = args.getOptionBool("WITHEXCITER"); - if (args.options.find("WithTurbineGovernor") != args.options.end()) - withTurbineGovernor = args.getOptionBool("WithTurbineGovernor"); - if (args.options.find("Inertia") != args.options.end()) { - H = args.getOptionReal("Inertia"); - inertia_str = "_Inertia_" + std::to_string(H); - } - if (args.options.find("StepSize") != args.options.end()) { - timeStep = args.getOptionReal("StepSize"); - stepSize_str = "_StepSize_" + std::to_string(timeStep); - } - } - - Real logDownSampling; - if (timeStep < 100e-6) - logDownSampling = floor(100e-6 / timeStep); - else - logDownSampling = 1.0; - Logger::Level logLevel = Logger::Level::debug; - std::string simName = "DP_SynGen" + SGModel + "Order_VBR_Load_Fault" + - stepSize_str + inertia_str; - - // ----- Dynamic simulation ------ - String simNameDP = simName; - Logger::setLogDir("logs/" + simNameDP); - - // Nodes - auto initVoltN1 = std::vector( - {Complex(GridParams.VnomMV * cos(GridParams.initVoltAngle), - GridParams.VnomMV * sin(GridParams.initVoltAngle))}); - auto n1DP = SimNode::make("n1DP", PhaseType::Single, initVoltN1); - - // Synchronous generator - auto genDP = Factory::get().create( - SGModel, "SynGen", logLevel); - genDP->setOperationalParametersPerUnit( - syngenKundur.nomPower, syngenKundur.nomVoltage, syngenKundur.nomFreq, H, - syngenKundur.Ld, syngenKundur.Lq, syngenKundur.Ll, syngenKundur.Ld_t, - syngenKundur.Lq_t, syngenKundur.Td0_t, syngenKundur.Tq0_t, - syngenKundur.Ld_s, syngenKundur.Lq_s, syngenKundur.Td0_s, - syngenKundur.Tq0_s); - genDP->setInitialValues( - GridParams.initComplexElectricalPower, GridParams.mechPower, - Complex(GridParams.VnomMV * cos(GridParams.initVoltAngle), - GridParams.VnomMV * sin(GridParams.initVoltAngle))); - genDP->setModelAsNortonSource(true); - - // Exciter - std::shared_ptr exciterDP = nullptr; - if (withExciter) { - exciterDP = - Factory::get().create("DC1Simp", "Exciter", logLevel); - exciterDP->setParameters(excitationEremia); - genDP->addExciter(exciterDP); - } - - // Power system stabilizer - std::shared_ptr pssDP = nullptr; - if (withPSS) { - pssDP = Signal::PSS1A::make("SynGen_PSS", logLevel); - pssDP->setParameters(pssPSAT); - genDP->addPSS(pssDP); - } - - // Turbine Governor - std::shared_ptr turbineGovernorDP = nullptr; - if (withTurbineGovernor) { - turbineGovernorDP = - Signal::TurbineGovernorType1::make("SynGen_Governor", logLevel); - turbineGovernorDP->setParameters(governorPSAT1); - genDP->addGovernor(turbineGovernorDP); - } - - /* - if (withTurbineGovernor) { - - // Steam Turbine and Governor - if(steam){ - std::shared_ptr steamTurbine = nullptr; - steamTurbine = Signal::SteamTurbine::make("SynGen_SteamTurbine", logLevel); - steamTurbine->setParameters(dSteamTurbine.Fhp, dSteamTurbine.Fip,dSteamTurbine.Flp, - dSteamTurbine.Tch, dSteamTurbine.Tco, dSteamTurbine.Trh); - genDP->addSteamTurbine(steamTurbine); - - std::shared_ptr steamTurbineGovernor = nullptr; - steamTurbineGovernor = Signal::SteamTurbineGovernor::make("SynGen_SteamTurbineGovernor", logLevel); - steamTurbineGovernor->setParameters(dSteamGovernor.OmRef, dSteamGovernor.R, dSteamGovernor.T2, dSteamGovernor.T3, - dSteamGovernor.delPmax, dSteamGovernor.delPmin, dSteamGovernor.Pmax, dSteamGovernor.Pmin); - genDP->addSteamTurbineGovernor(steamTurbineGovernor); - } - - // Hydro Turbine and Governor - if(hydro){ - std::shared_ptr hydroTurbine = nullptr; - hydroTurbine = Signal::HydroTurbine::make("SynGen_HydroTurbine", logLevel); - hydroTurbine->setParameters(dHydroTurbine.Tw); - genDP->addHydroTurbine(hydroTurbine); - - std::shared_ptr hydroTurbineGovernor = nullptr; - hydroTurbineGovernor = Signal::HydroTurbineGovernor::make("SynGen_HydroTurbineGovernor", logLevel); - hydroTurbineGovernor->setParameters(dHydroGovernor.OmRef, dHydroGovernor.R, dHydroGovernor.T1, dHydroGovernor.T2, dHydroGovernor.T3, dHydroGovernor.Pmax, dHydroGovernor.Pmin); - genDP->addHydroTurbineGovernor(hydroTurbineGovernor); - } - } - */ - - // Load - auto load = CPS::DP::Ph1::RXLoad::make("Load", logLevel); - load->setParameters(GridParams.initActivePower, GridParams.initReactivePower, - GridParams.VnomMV); - - //Breaker - auto fault = CPS::DP::Ph1::Switch::make("Br_fault", logLevel); - fault->setParameters(switchOpen, switchClosed); - fault->open(); - - // Topology - genDP->connect({n1DP}); - load->connect({n1DP}); - fault->connect({SP::SimNode::GND, n1DP}); - auto systemDP = SystemTopology(GridParams.nomFreq, SystemNodeList{n1DP}, - SystemComponentList{genDP, load, fault}); - - // Logging - auto loggerDP = DataLogger::make(simNameDP, true, logDownSampling); - loggerDP->logAttribute("v_gen", genDP->attribute("v_intf")); - loggerDP->logAttribute("i_gen", genDP->attribute("i_intf")); - loggerDP->logAttribute("Te", genDP->attribute("Te")); - loggerDP->logAttribute("delta", genDP->attribute("delta")); - loggerDP->logAttribute("w_r", genDP->attribute("w_r")); - loggerDP->logAttribute("Vdq0", genDP->attribute("Vdq0")); - loggerDP->logAttribute("Idq0", genDP->attribute("Idq0")); - loggerDP->logAttribute("Ef", genDP->attribute("Ef")); - loggerDP->logAttribute("Tm", genDP->attribute("Tm")); ->>>>>>> a32df206b (add base class for PSS) - - // Command line args processing - CommandLineArgs args(argc, argv); - if (argc > 1) { - if (args.options.find("SGModel") != args.options.end()) - SGModel = args.getOptionString("SGModel"); - if (args.options.find("WITHPSS") != args.options.end()) - withPSS = args.getOptionBool("WITHPSS"); - if (args.options.find("WITHEXCITER") != args.options.end()) - withExciter = args.getOptionBool("WITHEXCITER"); - if (args.options.find("WithTurbineGovernor") != args.options.end()) - withTurbineGovernor = args.getOptionBool("WithTurbineGovernor"); - if (args.options.find("Inertia") != args.options.end()) { - H = args.getOptionReal("Inertia"); - inertia_str = "_Inertia_" + std::to_string(H); - } - if (args.options.find("StepSize") != args.options.end()) { - timeStep = args.getOptionReal("StepSize"); - stepSize_str = "_StepSize_" + std::to_string(timeStep); - } - } - - Real logDownSampling; - if (timeStep < 100e-6) - logDownSampling = floor(100e-6 / timeStep); - else - logDownSampling = 1.0; - Logger::Level logLevel = Logger::Level::debug; - std::string simName = "DP_SynGen" + SGModel + "Order_VBR_Load_Fault" + - stepSize_str + inertia_str; - - // ----- Dynamic simulation ------ - String simNameDP = simName; - Logger::setLogDir("logs/" + simNameDP); - - // Nodes - auto initVoltN1 = std::vector( - {Complex(GridParams.VnomMV * cos(GridParams.initVoltAngle), - GridParams.VnomMV * sin(GridParams.initVoltAngle))}); - auto n1DP = SimNode::make("n1DP", PhaseType::Single, initVoltN1); - - // Synchronous generator - auto genDP = Factory::get().create( - SGModel, "SynGen", logLevel); - genDP->setOperationalParametersPerUnit( - syngenKundur.nomPower, syngenKundur.nomVoltage, syngenKundur.nomFreq, H, - syngenKundur.Ld, syngenKundur.Lq, syngenKundur.Ll, syngenKundur.Ld_t, - syngenKundur.Lq_t, syngenKundur.Td0_t, syngenKundur.Tq0_t, - syngenKundur.Ld_s, syngenKundur.Lq_s, syngenKundur.Td0_s, - syngenKundur.Tq0_s); - genDP->setInitialValues( - GridParams.initComplexElectricalPower, GridParams.mechPower, - Complex(GridParams.VnomMV * cos(GridParams.initVoltAngle), - GridParams.VnomMV * sin(GridParams.initVoltAngle))); - genDP->setModelAsNortonSource(true); - - // Exciter - std::shared_ptr exciterDP = nullptr; - if (withExciter) { - exciterDP = - Factory::get().create("DC1Simp", "Exciter", logLevel); - exciterDP->setParameters(excitationEremia); - genDP->addExciter(exciterDP); - } - - // Power system stabilizer - std::shared_ptr pssDP = nullptr; - if (withPSS) { - pssDP = Signal::PSS1A::make("SynGen_PSS", logLevel); - pssDP->setParameters(pssAndersonFarmer.Kp, pssAndersonFarmer.Kv, - pssAndersonFarmer.Kw, pssAndersonFarmer.T1, - pssAndersonFarmer.T2, pssAndersonFarmer.T3, - pssAndersonFarmer.T4, pssAndersonFarmer.Vs_max, - pssAndersonFarmer.Vs_min, pssAndersonFarmer.Tw); - genDP->addPSS(pssDP); - } - -<<<<<<< HEAD - // Turbine Governor - std::shared_ptr turbineGovernorDP = nullptr; - if (withTurbineGovernor) { - turbineGovernorDP = - Signal::TurbineGovernorType1::make("SynGen_TurbineGovernor", logLevel); - turbineGovernorDP->setParameters( - turbineGovernor.T3, turbineGovernor.T4, turbineGovernor.T5, - turbineGovernor.Tc, turbineGovernor.Ts, turbineGovernor.R, - turbineGovernor.Tmin, turbineGovernor.Tmax, turbineGovernor.OmegaRef); - genDP->addGovernor(turbineGovernorDP); - } - - //Breaker - auto fault = CPS::DP::Ph1::Switch::make("Br_fault", logLevel); - fault->setParameters(switchOpen, switchClosed); - fault->open(); -======= -<<<<<<< HEAD - // Power system stabilizer - std::shared_ptr pssDP = nullptr; - if (withPSS) { - pssDP = Signal::PSS1A::make("SynGen_PSS", logLevel); - pssDP->setParameters(pssAndersonFarmer.Kp, pssAndersonFarmer.Kv, - pssAndersonFarmer.Kw, pssAndersonFarmer.T1, - pssAndersonFarmer.T2, pssAndersonFarmer.T3, - pssAndersonFarmer.T4, pssAndersonFarmer.Vs_max, - pssAndersonFarmer.Vs_min, pssAndersonFarmer.Tw); - genDP->addPSS(pssDP); - } - - // Turbine Governor - std::shared_ptr turbineGovernorDP = nullptr; -======= ->>>>>>> 8e9cbf324 (HiWi added new Hydro and Steam Turbines and Governor models) - if (withTurbineGovernor) { - - // Steam Turbine and Governor - if (steam) { - std::shared_ptr steamTurbine = nullptr; - steamTurbine = - Signal::SteamTurbine::make("SynGen_SteamTurbine", logLevel); - steamTurbine->setParameters(dSteamTurbine.Fhp, dSteamTurbine.Fip, - dSteamTurbine.Flp, dSteamTurbine.Tch, - dSteamTurbine.Tco, dSteamTurbine.Trh); - genDP->addSteamTurbine(steamTurbine); - - std::shared_ptr steamTurbineGovernor = - nullptr; - steamTurbineGovernor = Signal::SteamTurbineGovernor::make( - "SynGen_SteamTurbineGovernor", logLevel); - steamTurbineGovernor->setParameters( - dSteamGovernor.OmRef, dSteamGovernor.R, dSteamGovernor.T2, - dSteamGovernor.T3, dSteamGovernor.delPmax, dSteamGovernor.delPmin, - dSteamGovernor.Pmax, dSteamGovernor.Pmin); - genDP->addSteamTurbineGovernor(steamTurbineGovernor); - } - - // Hydro Turbine and Governor - if (hydro) { - std::shared_ptr hydroTurbine = nullptr; - hydroTurbine = - Signal::HydroTurbine::make("SynGen_HydroTurbine", logLevel); - hydroTurbine->setParameters(dHydroTurbine.Tw); - genDP->addHydroTurbine(hydroTurbine); - - std::shared_ptr hydroTurbineGovernor = - nullptr; - hydroTurbineGovernor = Signal::HydroTurbineGovernor::make( - "SynGen_HydroTurbineGovernor", logLevel); - hydroTurbineGovernor->setParameters( - dHydroGovernor.OmRef, dHydroGovernor.R, dHydroGovernor.T1, - dHydroGovernor.T2, dHydroGovernor.T3, dHydroGovernor.Pmax, - dHydroGovernor.Pmin); - genDP->addHydroTurbineGovernor(hydroTurbineGovernor); - } - } ->>>>>>> 338446cac (added new Hydro and Steam Turbines and Governor models) - - // Topology - genDP->connect({n1DP}); - load->connect({n1DP}); - fault->connect({SP::SimNode::GND, n1DP}); - auto systemDP = SystemTopology(GridParams.nomFreq, SystemNodeList{n1DP}, - SystemComponentList{genDP, load, fault}); - - // Logging - auto loggerDP = DataLogger::make(simNameDP, true, logDownSampling); - loggerDP->logAttribute("v_gen", genDP->attribute("v_intf")); - loggerDP->logAttribute("i_gen", genDP->attribute("i_intf")); - loggerDP->logAttribute("Te", genDP->attribute("Te")); - loggerDP->logAttribute("delta", genDP->attribute("delta")); - loggerDP->logAttribute("w_r", genDP->attribute("w_r")); - loggerDP->logAttribute("Vdq0", genDP->attribute("Vdq0")); - loggerDP->logAttribute("Idq0", genDP->attribute("Idq0")); - - // Logging - auto loggerDP = DataLogger::make(simNameDP, true, logDownSampling); - loggerDP->logAttribute("v_gen", genDP->attribute("v_intf")); - loggerDP->logAttribute("i_gen", genDP->attribute("i_intf")); - loggerDP->logAttribute("Te", genDP->attribute("Te")); - loggerDP->logAttribute("delta", genDP->attribute("delta")); - loggerDP->logAttribute("w_r", genDP->attribute("w_r")); - loggerDP->logAttribute("Vdq0", genDP->attribute("Vdq0")); - loggerDP->logAttribute("Idq0", genDP->attribute("Idq0")); - loggerDP->logAttribute("Ef", genDP->attribute("Ef")); - loggerDP->logAttribute("Tm", genDP->attribute("Tm")); - -<<<<<<< HEAD - // Events - auto sw1 = SwitchEvent::make(startTimeFault, fault, true); - simDP.addEvent(sw1); -======= - // Logging - auto loggerDP = DataLogger::make(simNameDP, true, logDownSampling); -<<<<<<< HEAD - loggerDP->logAttribute("v_gen", genDP->attribute("v_intf")); - loggerDP->logAttribute("i_gen", genDP->attribute("i_intf")); - loggerDP->logAttribute("Te", genDP->attribute("Te")); - loggerDP->logAttribute("delta", genDP->attribute("delta")); - loggerDP->logAttribute("w_r", genDP->attribute("w_r")); - loggerDP->logAttribute("Vdq0", genDP->attribute("Vdq0")); - loggerDP->logAttribute("Idq0", genDP->attribute("Idq0")); - loggerDP->logAttribute("Ef", genDP->attribute("Ef")); - loggerDP->logAttribute("Tm", genDP->attribute("Tm")); -======= - loggerDP->logAttribute("v_gen", genDP->attribute("v_intf")); - loggerDP->logAttribute("i_gen", genDP->attribute("i_intf")); - loggerDP->logAttribute("Te", genDP->attribute("Te")); - loggerDP->logAttribute("delta", genDP->attribute("delta")); - loggerDP->logAttribute("w_r", genDP->attribute("w_r")); - loggerDP->logAttribute("Vdq0", genDP->attribute("Vdq0")); - loggerDP->logAttribute("Idq0", genDP->attribute("Idq0")); - loggerDP->logAttribute("Ef", genDP->attribute("Ef")); - loggerDP->logAttribute("Tm", genDP->attribute("Tm")); ->>>>>>> 8e9cbf324 (HiWi added new Hydro and Steam Turbines and Governor models) ->>>>>>> 338446cac (added new Hydro and Steam Turbines and Governor models) - - auto sw2 = SwitchEvent::make(endTimeFault, fault, false); - simDP.addEvent(sw2); - - simDP.run(); -} diff --git a/dpsim/examples/cxx/Circuits/DP_SMIB_ReducedOrderSG_LoadStep.cpp b/dpsim/examples/cxx/Circuits/DP_SMIB_ReducedOrderSG_LoadStep.cpp index 8cc377834d..7d7b456582 100644 --- a/dpsim/examples/cxx/Circuits/DP_SMIB_ReducedOrderSG_LoadStep.cpp +++ b/dpsim/examples/cxx/Circuits/DP_SMIB_ReducedOrderSG_LoadStep.cpp @@ -132,17 +132,6 @@ int main(int argc, char *argv[]) { auto n2DP = SimNode::make("n2DP", PhaseType::Single, initialVoltage_n2); - // Synchronous generator - auto genDP = GeneratorFactory::createGenDP(sgType, "SynGen", logLevel); - genDP->setOperationalParametersPerUnit( - syngenKundur.nomPower, syngenKundur.nomVoltage, syngenKundur.nomFreq, H, - syngenKundur.Ld, syngenKundur.Lq, syngenKundur.Ll, syngenKundur.Ld_t, - syngenKundur.Lq_t, syngenKundur.Td0_t, syngenKundur.Tq0_t, - syngenKundur.Ld_s, syngenKundur.Lq_s, syngenKundur.Td0_s, - syngenKundur.Tq0_s); - genDP->setInitialValues(initElecPower, initMechPower, n1PF->voltage()(0, 0)); - genDP->setModelAsNortonSource(true); - // Synchronous generator auto genDP = Factory::get().create( sgType, "SynGen", logLevel); @@ -155,6 +144,10 @@ int main(int argc, char *argv[]) { genDP->setInitialValues(initElecPower, initMechPower, n1PF->voltage()(0, 0)); genDP->setModelAsNortonSource(true); + //Grid bus as Slack + auto extnetDP = DP::Ph1::NetworkInjection::make("Slack", logLevel); + extnetDP->setParameters(gridParams.VnomMV); + // Line auto lineDP = DP::Ph1::PiLine::make("PiLine", logLevel); lineDP->setParameters(gridParams.lineResistance, gridParams.lineInductance, @@ -199,4 +192,4 @@ int main(int argc, char *argv[]) { simDP.addEvent(loadStepEvent); simDP.run(); -} +} \ No newline at end of file diff --git a/dpsim/examples/cxx/Circuits/EMT_ReducedOrderSG_SMIB_Fault.cpp b/dpsim/examples/cxx/Circuits/EMT_ReducedOrderSG_SMIB_Fault.cpp index 1bd520c487..87aa14737b 100644 --- a/dpsim/examples/cxx/Circuits/EMT_ReducedOrderSG_SMIB_Fault.cpp +++ b/dpsim/examples/cxx/Circuits/EMT_ReducedOrderSG_SMIB_Fault.cpp @@ -131,7 +131,9 @@ int main(int argc, char *argv[]) { auto n2EMT = SimNode::make("n2EMT", PhaseType::ABC, initialVoltage_n2); // Synchronous generator - auto genEMT = GeneratorFactory::createGenEMT(SGModel, "SynGen", logLevel); + auto genEMT = + Factory::get().create( + SGModel, "SynGen", logLevel); genEMT->setOperationalParametersPerUnit( syngenKundur.nomPower, syngenKundur.nomVoltage, syngenKundur.nomFreq, H, syngenKundur.Ld, syngenKundur.Lq, syngenKundur.Ll, syngenKundur.Ld_t, @@ -158,18 +160,11 @@ int main(int argc, char *argv[]) { Math::singlePhaseParameterToThreePhase(switchClosed)); fault->openSwitch(); - // Synchronous generator - auto genEMT = - Factory::get().create( - SGModel, "SynGen", logLevel); - genEMT->setOperationalParametersPerUnit( - syngenKundur.nomPower, syngenKundur.nomVoltage, syngenKundur.nomFreq, H, - syngenKundur.Ld, syngenKundur.Lq, syngenKundur.Ll, syngenKundur.Ld_t, - syngenKundur.Lq_t, syngenKundur.Td0_t, syngenKundur.Tq0_t, - syngenKundur.Ld_s, syngenKundur.Lq_s, syngenKundur.Td0_s, - syngenKundur.Tq0_s); - genEMT->setInitialValues(initElecPower, initMechPower, n1PF->voltage()(0, 0)); - genEMT->setModelAsNortonSource(true); + // Topology + genEMT->connect({n1EMT}); + lineEMT->connect({n1EMT, n2EMT}); + extnetEMT->connect({n2EMT}); + fault->connect({EMT::SimNode::GND, n1EMT}); auto systemEMT = SystemTopology(GridParams.nomFreq, SystemNodeList{n1EMT, n2EMT}, @@ -203,4 +198,4 @@ int main(int argc, char *argv[]) { simEMT.addEvent(sw2); simEMT.run(); -} +} \ No newline at end of file diff --git a/dpsim/examples/cxx/Circuits/EMT_ReducedOrderSG_VBR_Load_Fault.cpp b/dpsim/examples/cxx/Circuits/EMT_ReducedOrderSG_VBR_Load_Fault.cpp deleted file mode 100644 index 311499ac53..0000000000 --- a/dpsim/examples/cxx/Circuits/EMT_ReducedOrderSG_VBR_Load_Fault.cpp +++ /dev/null @@ -1,360 +0,0 @@ -#include "../Examples.h" -#include -#include - -using namespace DPsim; -using namespace CPS; -using namespace CPS::CIM; - -// Grid parameters -const Examples::Grids::SMIB::ScenarioConfig3 GridParams; - -// Generator parameters -const Examples::Components::SynchronousGeneratorKundur::MachineParameters - syngenKundur; - -// PSS -const auto pssPSAT = Examples::Components::PowerSystemStabilizer::getPSS1AParametersPSAT(); - -// Excitation system -const auto excitationEremia = - Examples::Components::Exciter::getExciterParametersEremia(); - -// Turbine Governor Type 1 -const auto governorPSAT1 = Examples::Components::TurbineGovernor::getTurbineGovernorPSAT1(); - - -// Steam Turbine -//const Examples::Components::TurbineGovernor::SteamTurbine dSteamTurbine; - -// Steam Turbine Governor -//Examples::Components::TurbineGovernor::SteamTurbineGovernor dSteamGovernor; - -int main(int argc, char *argv[]) { - -<<<<<<< HEAD - // initiaize factories - ExciterFactory::registerExciters(); - SynchronGeneratorFactory::EMT::Ph3::registerSynchronGenerators(); - -<<<<<<< HEAD - // Simultion parameters - Real switchClosed = GridParams.SwitchClosed; - Real switchOpen = GridParams.SwitchOpen; - Real startTimeFault = 1.0; - Real endTimeFault = 1.1; - Real finalTime = 5; - Real timeStep = 1e-3; - Real H = syngenKundur.H; - bool withPSS = false; - bool withExciter = false; - bool withTurbineGovernor = false; - std::string SGModel = "4"; - std::string stepSize_str = ""; - std::string inertia_str = ""; -======= - // Simultion parameters - Real switchClosed = GridParams.SwitchClosed; - Real switchOpen = GridParams.SwitchOpen; - Real startTimeFault = 1.0; - Real endTimeFault = 4; - Real finalTime = 20; - Real timeStep = 1e-3; - Real H = syngenKundur.H; -<<<<<<< HEAD - bool withPSS = false; - bool withExciter = false; - bool withTurbineGovernor = false; -======= - bool withExciter = true; - bool withTurbineGovernor = true; ->>>>>>> 8e9cbf324 (HiWi added new Hydro and Steam Turbines and Governor models) - std::string SGModel = "4"; - std::string stepSize_str = ""; - std::string inertia_str = ""; ->>>>>>> 338446cac (added new Hydro and Steam Turbines and Governor models) - - // Command line args processing - CommandLineArgs args(argc, argv); - if (argc > 1) { - if (args.options.find("SGModel") != args.options.end()) - SGModel = args.getOptionString("SGModel"); - if (args.options.find("WITHPSS") != args.options.end()) - withPSS = args.getOptionBool("WITHPSS"); - if (args.options.find("WITHEXCITER") != args.options.end()) - withExciter = args.getOptionBool("WITHEXCITER"); - if (args.options.find("WithTurbineGovernor") != args.options.end()) - withTurbineGovernor = args.getOptionBool("WithTurbineGovernor"); - if (args.options.find("StepSize") != args.options.end()) { - timeStep = args.getOptionReal("StepSize"); - stepSize_str = "_StepSize_" + std::to_string(timeStep); - } - if (args.options.find("Inertia") != args.options.end()) { - H = args.getOptionReal("Inertia"); - inertia_str = "_Inertia_" + std::to_string(H); - } - } -======= - // initiaize factories - ExciterFactory::registerExciters(); - SynchronGeneratorFactory::EMT::Ph3::registerSynchronGenerators(); - - // Simultion parameters - Real switchClosed = GridParams.SwitchClosed; - Real switchOpen = GridParams.SwitchOpen; - Real startTimeFault = 1.0; - Real endTimeFault = 4; - Real finalTime = 20; - Real timeStep = 1e-3; - Real H = syngenKundur.H; - bool withPSS = false; - bool withExciter = false; - bool withTurbineGovernor = false; - std::string SGModel = "4"; - std::string stepSize_str = ""; - std::string inertia_str = ""; - - // Command line args processing - CommandLineArgs args(argc, argv); - if (argc > 1) { - if (args.options.find("SGModel") != args.options.end()) - SGModel = args.getOptionString("SGModel"); - if (args.options.find("WITHPSS") != args.options.end()) - withPSS = args.getOptionBool("WITHPSS"); - if (args.options.find("WITHEXCITER") != args.options.end()) - withExciter = args.getOptionBool("WITHEXCITER"); - if (args.options.find("WithTurbineGovernor") != args.options.end()) - withTurbineGovernor = args.getOptionBool("WithTurbineGovernor"); - if (args.options.find("StepSize") != args.options.end()) { - timeStep = args.getOptionReal("StepSize"); - stepSize_str = "_StepSize_" + std::to_string(timeStep); - } - if (args.options.find("Inertia") != args.options.end()) { - H = args.getOptionReal("Inertia"); - inertia_str = "_Inertia_" + std::to_string(H); - } - } - - Real logDownSampling; - if (timeStep<100e-6) - logDownSampling = floor(100e-6 / timeStep); - else - logDownSampling = 1.0; - Logger::Level logLevel = Logger::Level::debug; - std::string simName ="EMT_SynGen" + SGModel + "Order_VBR_Load_Fault" + stepSize_str + inertia_str; - - - // ----- Dynamic simulation ------ - String simNameEMT = simName; - Logger::setLogDir("logs/"+simNameEMT); - - // Nodes - std::vector initialVoltage_n1{ GridParams.initTerminalVolt, - GridParams.initTerminalVolt * SHIFT_TO_PHASE_B, - GridParams.initTerminalVolt * SHIFT_TO_PHASE_C - }; - auto n1EMT = SimNode::make("n1EMT", PhaseType::ABC, initialVoltage_n1); - - // Components - // Synchronous generator - auto genEMT = Factory::get().create(SGModel, "SynGen", logLevel); - genEMT->setOperationalParametersPerUnit( - syngenKundur.nomPower, syngenKundur.nomVoltage, - syngenKundur.nomFreq, H, - syngenKundur.Ld, syngenKundur.Lq, syngenKundur.Ll, - syngenKundur.Ld_t, syngenKundur.Lq_t, syngenKundur.Td0_t, syngenKundur.Tq0_t, - syngenKundur.Ld_s, syngenKundur.Lq_s, syngenKundur.Td0_s, syngenKundur.Tq0_s); - genEMT->setInitialValues(GridParams.initComplexElectricalPower, GridParams.mechPower, - GridParams.initTerminalVolt); - genEMT->setModelAsNortonSource(true); - - // Exciter - std::shared_ptr exciterEMT = nullptr; - if (withExciter) { - exciterEMT = Factory::get().create("DC1Simp", "Exciter", logLevel); - exciterEMT->setParameters(excitationEremia); - genEMT->addExciter(exciterEMT); - } - - // Power system stabilizer - std::shared_ptr pssEMT = nullptr; - if (pssEMT) { - pssEMT = Signal::PSS1A::make("SynGen_PSS", logLevel); - pssEMT->setParameters(pssPSAT); - genEMT->addPSS(pssEMT); - } - - // Turbine Governor - std::shared_ptr turbineGovernorEMT = nullptr; - if (withTurbineGovernor) { - turbineGovernorEMT = Signal::TurbineGovernorType1::make("SynGen_Governor", logLevel); - turbineGovernorEMT->setParameters(governorPSAT1); - genEMT->addGovernor(turbineGovernorEMT); - } - - /* - // Steam Turbine Governor - std::shared_ptr steamTurbineGovernor = nullptr; - if (withTurbineGovernor) { - steamTurbineGovernor = Signal::SteamTurbineGovernor::make("SynGen_SteamTurbineGovernor", logLevel); - steamTurbineGovernor->setParameters(dSteamGovernor.OmRef, dSteamGovernor.R, dSteamGovernor.T2, dSteamGovernor.T3, - dSteamGovernor.delPmax, dSteamGovernor.delPmin, dSteamGovernor.Pmax, dSteamGovernor.Pmin); - genEMT->addSteamTurbineGovernor(steamTurbineGovernor); - } - */ ->>>>>>> a32df206b (add base class for PSS) - - Real logDownSampling; - if (timeStep < 100e-6) - logDownSampling = floor(100e-6 / timeStep); - else - logDownSampling = 1.0; - Logger::Level logLevel = Logger::Level::debug; - std::string simName = "EMT_SynGen" + SGModel + "Order_VBR_Load_Fault" + - stepSize_str + inertia_str; - - // ----- Dynamic simulation ------ - String simNameEMT = simName; - Logger::setLogDir("logs/" + simNameEMT); - - // Nodes - std::vector initialVoltage_n1{ - GridParams.initTerminalVolt, - GridParams.initTerminalVolt * SHIFT_TO_PHASE_B, - GridParams.initTerminalVolt * SHIFT_TO_PHASE_C}; - auto n1EMT = SimNode::make("n1EMT", PhaseType::ABC, initialVoltage_n1); - - // Components - // Synchronous generator - auto genEMT = - Factory::get().create( - SGModel, "SynGen", logLevel); - genEMT->setOperationalParametersPerUnit( - syngenKundur.nomPower, syngenKundur.nomVoltage, syngenKundur.nomFreq, H, - syngenKundur.Ld, syngenKundur.Lq, syngenKundur.Ll, syngenKundur.Ld_t, - syngenKundur.Lq_t, syngenKundur.Td0_t, syngenKundur.Tq0_t, - syngenKundur.Ld_s, syngenKundur.Lq_s, syngenKundur.Td0_s, - syngenKundur.Tq0_s); - genEMT->setInitialValues(GridParams.initComplexElectricalPower, - GridParams.mechPower, GridParams.initTerminalVolt); - genEMT->setModelAsNortonSource(true); - - // Exciter - std::shared_ptr exciterEMT = nullptr; - if (withExciter) { - exciterEMT = - Factory::get().create("DC1Simp", "Exciter", logLevel); - exciterEMT->setParameters(excitationEremia); - genEMT->addExciter(exciterEMT); - } - -<<<<<<< HEAD - // Power system stabilizer - std::shared_ptr pssEMT = nullptr; - if (withPSS) { - pssEMT = Signal::PSS1A::make("PSS", logLevel); - pssEMT->setParameters(pssAndersonFarmer.Kp, pssAndersonFarmer.Kv, - pssAndersonFarmer.Kw, pssAndersonFarmer.T1, - pssAndersonFarmer.T2, pssAndersonFarmer.T3, - pssAndersonFarmer.T4, pssAndersonFarmer.Vs_max, - pssAndersonFarmer.Vs_min, pssAndersonFarmer.Tw); - genEMT->addPSS(pssEMT); - } - - // Turbine Governor - std::shared_ptr turbineGovernorEMT = nullptr; - if (withTurbineGovernor) { - turbineGovernorEMT = - Signal::TurbineGovernorType1::make("SynGen_TurbineGovernor", logLevel); - turbineGovernorEMT->setParameters( - turbineGovernor.T3, turbineGovernor.T4, turbineGovernor.T5, - turbineGovernor.Tc, turbineGovernor.Ts, turbineGovernor.R, - turbineGovernor.Tmin, turbineGovernor.Tmax, turbineGovernor.OmegaRef); - genEMT->addGovernor(turbineGovernorEMT); - } -======= -<<<<<<< HEAD - // Power system stabilizer - std::shared_ptr pssEMT = nullptr; - if (withPSS) { - pssEMT = Signal::PSS1A::make("PSS", logLevel); - pssEMT->setParameters(pssAndersonFarmer.Kp, pssAndersonFarmer.Kv, - pssAndersonFarmer.Kw, pssAndersonFarmer.T1, - pssAndersonFarmer.T2, pssAndersonFarmer.T3, - pssAndersonFarmer.T4, pssAndersonFarmer.Vs_max, - pssAndersonFarmer.Vs_min, pssAndersonFarmer.Tw); - genEMT->addPSS(pssEMT); - } - - // Turbine Governor - std::shared_ptr turbineGovernorEMT = nullptr; -======= - // Steam Turbine - std::shared_ptr steamTurbine = nullptr; ->>>>>>> 8e9cbf324 (HiWi added new Hydro and Steam Turbines and Governor models) - if (withTurbineGovernor) { - steamTurbine = Signal::SteamTurbine::make("SynGen_SteamTurbine", logLevel); - steamTurbine->setParameters(dSteamTurbine.Fhp, dSteamTurbine.Fip, - dSteamTurbine.Flp, dSteamTurbine.Tch, - dSteamTurbine.Tco, dSteamTurbine.Trh); - genEMT->addSteamTurbine(steamTurbine); - } - - // Steam Turbine Governor - std::shared_ptr steamTurbineGovernor = nullptr; - if (withTurbineGovernor) { - steamTurbineGovernor = Signal::SteamTurbineGovernor::make( - "SynGen_SteamTurbineGovernor", logLevel); - steamTurbineGovernor->setParameters( - dSteamGovernor.OmRef, dSteamGovernor.R, dSteamGovernor.T2, - dSteamGovernor.T3, dSteamGovernor.delPmax, dSteamGovernor.delPmin, - dSteamGovernor.Pmax, dSteamGovernor.Pmin); - genEMT->addSteamTurbineGovernor(steamTurbineGovernor); - } ->>>>>>> 338446cac (added new Hydro and Steam Turbines and Governor models) - - //Breaker - auto fault = CPS::EMT::Ph3::Switch::make("Br_fault", logLevel); - fault->setParameters(Math::singlePhaseParameterToThreePhase(switchOpen), - Math::singlePhaseParameterToThreePhase(switchClosed)); - fault->openSwitch(); - - // Topology - genEMT->connect({n1EMT}); - load->connect({n1EMT}); - fault->connect({EMT::SimNode::GND, n1EMT}); - - auto systemEMT = SystemTopology(GridParams.nomFreq, SystemNodeList{n1EMT}, - SystemComponentList{genEMT, load, fault}); - - // Logging - auto loggerEMT = DataLogger::make(simNameEMT, true, logDownSampling); - loggerEMT->logAttribute("v_gen", genEMT->attribute("v_intf")); - loggerEMT->logAttribute("i_gen", genEMT->attribute("i_intf")); - loggerEMT->logAttribute("Te", genEMT->attribute("Te")); - loggerEMT->logAttribute("delta", genEMT->attribute("delta")); - loggerEMT->logAttribute("w_r", genEMT->attribute("w_r")); - loggerEMT->logAttribute("Vdq0", genEMT->attribute("Vdq0")); - loggerEMT->logAttribute("Idq0", genEMT->attribute("Idq0")); - - // Logging - auto loggerEMT = DataLogger::make(simNameEMT, true, logDownSampling); - loggerEMT->logAttribute("v_gen", genEMT->attribute("v_intf")); - loggerEMT->logAttribute("i_gen", genEMT->attribute("i_intf")); - loggerEMT->logAttribute("Te", genEMT->attribute("Te")); - loggerEMT->logAttribute("delta", genEMT->attribute("delta")); - loggerEMT->logAttribute("w_r", genEMT->attribute("w_r")); - loggerEMT->logAttribute("Vdq0", genEMT->attribute("Vdq0")); - loggerEMT->logAttribute("Idq0", genEMT->attribute("Idq0")); - loggerEMT->logAttribute("Ef", genEMT->attribute("Ef")); - loggerEMT->logAttribute("Tm", genEMT->attribute("Tm")); - - // Events - auto sw1 = SwitchEvent3Ph::make(startTimeFault, fault, true); - simEMT.addEvent(sw1); - auto sw2 = SwitchEvent3Ph::make(endTimeFault, fault, false); - simEMT.addEvent(sw2); - - simEMT.run(); - simEMT.logStepTimes(simNameEMT + "_step_times"); -} diff --git a/dpsim/examples/cxx/Circuits/EMT_SMIB_ReducedOrderSG_LoadStep.cpp b/dpsim/examples/cxx/Circuits/EMT_SMIB_ReducedOrderSG_LoadStep.cpp index 727b9e57be..6de2022a0a 100644 --- a/dpsim/examples/cxx/Circuits/EMT_SMIB_ReducedOrderSG_LoadStep.cpp +++ b/dpsim/examples/cxx/Circuits/EMT_SMIB_ReducedOrderSG_LoadStep.cpp @@ -17,24 +17,10 @@ Scenario6::GridParams gridParams; Examples::Components::SynchronousGeneratorKundur::MachineParameters syngenKundur; -<<<<<<< HEAD -<<<<<<< HEAD int main(int argc, char *argv[]) { -======= -int main(int argc, char *argv[]) { -<<<<<<< HEAD -======= // initiaize factories SynchronGeneratorFactory::EMT::Ph3::registerSynchronGenerators(); ->>>>>>> 41541d9d (add PSS type 2 and add base class for exciter) ->>>>>>> 614929412 (add PSS type 2 and add base class for exciter) -======= -int main(int argc, char* argv[]) { - - // initiaize factories - SynchronGeneratorFactory::EMT::Ph3::registerSynchronGenerators(); ->>>>>>> 8f6855f08 (resolve rebase conflicts) // Simulation parameters String simName = "EMT_SMIB_ReducedOrderSG_LoadStep"; @@ -143,21 +129,6 @@ int main(int argc, char* argv[]) { n2PF->voltage()(0, 0) * SHIFT_TO_PHASE_C}; auto n2EMT = SimNode::make("n2EMT", PhaseType::ABC, initialVoltage_n2); - // Synchronous generator - auto genEMT = GeneratorFactory::createGenEMT(sgType, "SynGen", logLevel); - genEMT->setOperationalParametersPerUnit( - syngenKundur.nomPower, syngenKundur.nomVoltage, syngenKundur.nomFreq, H, - syngenKundur.Ld, syngenKundur.Lq, syngenKundur.Ll, syngenKundur.Ld_t, - syngenKundur.Lq_t, syngenKundur.Td0_t, syngenKundur.Tq0_t, - syngenKundur.Ld_s, syngenKundur.Lq_s, syngenKundur.Td0_s, - syngenKundur.Tq0_s); - genEMT->setInitialValues(initElecPower, initMechPower, n1PF->voltage()(0, 0)); - genEMT->setModelAsNortonSource(true); - -<<<<<<< HEAD - //Grid bus as Slack - auto extnetEMT = EMT::Ph3::NetworkInjection::make("Slack", logLevel); -======= // Synchronous generator auto genEMT = Factory::get().create( @@ -170,7 +141,9 @@ int main(int argc, char* argv[]) { syngenKundur.Tq0_s); genEMT->setInitialValues(initElecPower, initMechPower, n1PF->voltage()(0, 0)); genEMT->setModelAsNortonSource(true); ->>>>>>> 614929412 (add PSS type 2 and add base class for exciter) + + //Grid bus as Slack + auto extnetEMT = EMT::Ph3::NetworkInjection::make("Slack", logLevel); // Line auto lineEMT = EMT::Ph3::PiLine::make("PiLine", logLevel); @@ -219,4 +192,4 @@ int main(int argc, char* argv[]) { simEMT.addEvent(loadStepEvent); simEMT.run(); -} +} \ No newline at end of file diff --git a/dpsim/examples/cxx/Circuits/SP_ReducedOrderSG_SMIB_Fault.cpp b/dpsim/examples/cxx/Circuits/SP_ReducedOrderSG_SMIB_Fault.cpp index 98dcd5a3db..ab8e653ba9 100644 --- a/dpsim/examples/cxx/Circuits/SP_ReducedOrderSG_SMIB_Fault.cpp +++ b/dpsim/examples/cxx/Circuits/SP_ReducedOrderSG_SMIB_Fault.cpp @@ -154,28 +154,6 @@ int main(int argc, char *argv[]) { auto n2SP = SimNode::make("n2SP", PhaseType::Single, initialVoltage_n2); - // Synchronous generator - auto genSP = GeneratorFactory::createGenSP(SGModel, "SynGen", logLevel); - genSP->setOperationalParametersPerUnit( - syngenKundur.nomPower, syngenKundur.nomVoltage, syngenKundur.nomFreq, H, - syngenKundur.Ld, syngenKundur.Lq, syngenKundur.Ll, syngenKundur.Ld_t, - syngenKundur.Lq_t, syngenKundur.Td0_t, syngenKundur.Tq0_t, - syngenKundur.Ld_s, syngenKundur.Lq_s, syngenKundur.Td0_s, - syngenKundur.Tq0_s); - genSP->setInitialValues(initElecPower, initMechPower, n1PF->voltage()(0, 0)); - genSP->setModelAsNortonSource(true); - - // Exciter - std::shared_ptr exciterSP = nullptr; - if (withExciter) { - exciterSP = Signal::Exciter::make("SynGen_Exciter", logLevel); - exciterSP->setParameters(excitationEremia.Ta, excitationEremia.Ka, - excitationEremia.Te, excitationEremia.Ke, - excitationEremia.Tf, excitationEremia.Kf, - excitationEremia.Tr); - genSP->addExciter(exciterSP); - } - // Synchronous generator auto genSP = Factory::get().create( SGModel, "SynGen", logLevel); @@ -214,6 +192,15 @@ int main(int argc, char *argv[]) { genSP->addGovernor(turbineGovernorSP); } + // Grid bus as Slack + auto extnetSP = SP::Ph1::NetworkInjection::make("Slack", logLevel); + extnetSP->setParameters(GridParams.VnomMV); + + // Line + auto lineSP = SP::Ph1::PiLine::make("PiLine", logLevel); + lineSP->setParameters(GridParams.lineResistance, GridParams.lineInductance, + GridParams.lineCapacitance, GridParams.lineConductance); + //Breaker auto fault = CPS::SP::Ph1::Switch::make("Br_fault", logLevel); fault->setParameters(switchOpen, switchClosed); @@ -229,30 +216,6 @@ int main(int argc, char *argv[]) { SystemTopology(GridParams.nomFreq, SystemNodeList{n1SP, n2SP}, SystemComponentList{genSP, lineSP, extnetSP, fault}); - // Logging - auto loggerSP = DataLogger::make(simNameSP, true, logDownSampling); - loggerSP->logAttribute("v_gen", genSP->attribute("v_intf")); - loggerSP->logAttribute("i_gen", genSP->attribute("i_intf")); - loggerSP->logAttribute("Te", genSP->attribute("Te")); - loggerSP->logAttribute("Ef", genSP->attribute("Ef")); - loggerSP->logAttribute("delta", genSP->attribute("delta")); - loggerSP->logAttribute("w_r", genSP->attribute("w_r")); - loggerSP->logAttribute("Vdq0", genSP->attribute("Vdq0")); - loggerSP->logAttribute("Idq0", genSP->attribute("Idq0")); - if (SGModel == "5b" || SGModel == "6a" || SGModel == "6b") { - loggerSP->logAttribute("Edq0_s", genSP->attribute("Edq_s")); - loggerSP->logAttribute("Edq0_t", genSP->attribute("Edq_t")); - } else { - loggerSP->logAttribute("Edq0", genSP->attribute("Edq_t")); - } - loggerSP->logAttribute("v1", n1SP->attribute("v")); - loggerSP->logAttribute("v2", n2SP->attribute("v")); - - // Exciter - if (withExciter) { - loggerSP->logAttribute("Ef", exciterSP->attribute("Ef")); - } - // Logging auto loggerSP = DataLogger::make(simNameSP, true, logDownSampling); loggerSP->logAttribute("v_gen", genSP->attribute("v_intf")); @@ -276,8 +239,21 @@ int main(int argc, char *argv[]) { if (withTurbineGovernor) loggerSP->logAttribute("Tm", turbineGovernorSP->attribute("Tm")); + Simulation simSP(simNameSP, logLevel); + simSP.doInitFromNodesAndTerminals(true); + simSP.setSystem(systemSP); + simSP.setTimeStep(timeStep); + simSP.setFinalTime(finalTime); + simSP.setDomain(Domain::SP); + simSP.addLogger(loggerSP); + simSP.doSystemMatrixRecomputation(true); + + // Events + auto sw1 = SwitchEvent::make(startTimeFault, fault, true); + simSP.addEvent(sw1); + auto sw2 = SwitchEvent::make(endTimeFault, fault, false); simSP.addEvent(sw2); simSP.run(); -} +} \ No newline at end of file diff --git a/dpsim/examples/cxx/Circuits/SP_ReducedOrderSG_VBR_Load_Fault.cpp b/dpsim/examples/cxx/Circuits/SP_ReducedOrderSG_VBR_Load_Fault.cpp deleted file mode 100644 index 361f8f333e..0000000000 --- a/dpsim/examples/cxx/Circuits/SP_ReducedOrderSG_VBR_Load_Fault.cpp +++ /dev/null @@ -1,195 +0,0 @@ -#include "../Examples.h" -#include -#include - -using namespace DPsim; -using namespace CPS; -using namespace CPS::CIM; - -// Grid parameters -const Examples::Grids::SMIB::ScenarioConfig3 GridParams; - -// Generator parameters -const Examples::Components::SynchronousGeneratorKundur::MachineParameters - syngenKundur; - -// PSS -const Examples::Components::PowerSystemStabilizer::PSS1APSAT pssAndersonFarmer; - -// Excitation system -const auto excitationEremia = - Examples::Components::Exciter::getExciterParametersEremia(); - -// Turbine Goverour -const Examples::Components::TurbineGovernor::TurbineGovernorPSAT1 - turbineGovernor; - -int main(int argc, char *argv[]) { - - // initiaize factories - ExciterFactory::registerExciters(); - SynchronGeneratorFactory::SP::Ph1::registerSynchronGenerators(); - - // Simulation parameters - Real switchClosed = GridParams.SwitchClosed; - Real switchOpen = GridParams.SwitchOpen; - Real startTimeFault = 1.0; - Real endTimeFault = 1.1; - Real finalTime = 5; - Real timeStep = 1e-3; - Real H = syngenKundur.H; - bool withPSS = false; - bool withExciter = false; - bool withTurbineGovernor = false; - std::string SGModel = "4"; - std::string stepSize_str = ""; - std::string inertia_str = ""; - - // Command line args processing - CommandLineArgs args(argc, argv); - if (argc > 1) { - if (args.options.find("SGModel") != args.options.end()) - SGModel = args.getOptionString("SGModel"); - if (args.options.find("WITHPSS") != args.options.end()) - withPSS = args.getOptionBool("WITHPSS"); - if (args.options.find("WITHEXCITER") != args.options.end()) - withExciter = args.getOptionBool("WITHEXCITER"); - if (args.options.find("WithTurbineGovernor") != args.options.end()) - withTurbineGovernor = args.getOptionBool("WithTurbineGovernor"); - if (args.options.find("Inertia") != args.options.end()) { - H = args.getOptionReal("Inertia"); - inertia_str = "_Inertia_" + std::to_string(H); - } - if (args.options.find("StepSize") != args.options.end()) { - timeStep = args.getOptionReal("StepSize"); - stepSize_str = "_StepSize_" + std::to_string(timeStep); - } - } - - Real logDownSampling; - if (timeStep < 100e-6) - logDownSampling = floor(100e-6 / timeStep); - else - logDownSampling = 1.0; - Logger::Level logLevel = Logger::Level::debug; - std::string simName = "SP_SynGen" + SGModel + "Order_VBR_Load_Fault" + - stepSize_str + inertia_str; - - // ----- Dynamic simulation ------ - String simNameSP = simName; - Logger::setLogDir("logs/" + simNameSP); - - // Nodes - auto initVoltN1 = std::vector( - {Complex(GridParams.VnomMV * cos(GridParams.initVoltAngle), - GridParams.VnomMV * sin(GridParams.initVoltAngle))}); - auto n1SP = SimNode::make("n1SP", PhaseType::Single, initVoltN1); - - // Synchronous generator - auto genSP = Factory::get().create( - SGModel, "SynGen", logLevel); - genSP->setOperationalParametersPerUnit( - syngenKundur.nomPower, syngenKundur.nomVoltage, syngenKundur.nomFreq, H, - syngenKundur.Ld, syngenKundur.Lq, syngenKundur.Ll, syngenKundur.Ld_t, - syngenKundur.Lq_t, syngenKundur.Td0_t, syngenKundur.Tq0_t, - syngenKundur.Ld_s, syngenKundur.Lq_s, syngenKundur.Td0_s, - syngenKundur.Tq0_s); - genSP->setInitialValues( - GridParams.initComplexElectricalPower, GridParams.mechPower, - Complex(GridParams.VnomMV * cos(GridParams.initVoltAngle), - GridParams.VnomMV * sin(GridParams.initVoltAngle))); - genSP->setModelAsNortonSource(true); - - // Exciter - std::shared_ptr exciterSP = nullptr; - if (withExciter) { - exciterSP = - Factory::get().create("DC1Simp", "Exciter", logLevel); - exciterSP->setParameters(excitationEremia); - genSP->addExciter(exciterSP); - } - - // Power system stabilizer - std::shared_ptr pssSP = nullptr; - if (withPSS) { - pssSP = Signal::PSS1A::make("SynGen_PSS", logLevel); - pssSP->setParameters(pssAndersonFarmer.Kp, pssAndersonFarmer.Kv, - pssAndersonFarmer.Kw, pssAndersonFarmer.T1, - pssAndersonFarmer.T2, pssAndersonFarmer.T3, - pssAndersonFarmer.T4, pssAndersonFarmer.Vs_max, - pssAndersonFarmer.Vs_min, pssAndersonFarmer.Tw); - genSP->addPSS(pssSP); - } - - // Turbine Governor - std::shared_ptr turbineGovernorSP = nullptr; - if (withTurbineGovernor) { - turbineGovernorSP = - Signal::TurbineGovernorType1::make("SynGen_TurbineGovernor", logLevel); - turbineGovernorSP->setParameters( - turbineGovernor.T3, turbineGovernor.T4, turbineGovernor.T5, - turbineGovernor.Tc, turbineGovernor.Ts, turbineGovernor.R, - turbineGovernor.Tmin, turbineGovernor.Tmax, turbineGovernor.OmegaRef); - genSP->addGovernor(turbineGovernorSP); - } - - //Breaker - auto fault = CPS::SP::Ph1::Switch::make("Br_fault", logLevel); - fault->setParameters(switchOpen, switchClosed); - fault->open(); - - // Topology - genSP->connect({n1SP}); - load->connect({n1SP}); - fault->connect({SP::SimNode::GND, n1SP}); - auto systemSP = SystemTopology(GridParams.nomFreq, SystemNodeList{n1SP}, - SystemComponentList{genSP, load, fault}); - - // Logging - auto loggerSP = DataLogger::make(simNameSP, true, logDownSampling); - loggerSP->logAttribute("v_gen", genSP->attribute("v_intf")); - loggerSP->logAttribute("i_gen", genSP->attribute("i_intf")); - loggerSP->logAttribute("Te", genSP->attribute("Te")); - loggerSP->logAttribute("delta", genSP->attribute("delta")); - loggerSP->logAttribute("w_r", genSP->attribute("w_r")); - loggerSP->logAttribute("Vdq0", genSP->attribute("Vdq0")); - loggerSP->logAttribute("Idq0", genSP->attribute("Idq0")); - if (SGModel == "6a" || SGModel == "6b") { - loggerSP->logAttribute("Edq0_s", genSP->attribute("Edq_s")); - loggerSP->logAttribute("Edq0_t", genSP->attribute("Edq_t")); - } else { - loggerSP->logAttribute("Edq0", genSP->attribute("Edq_t")); - } - - // Logging - auto loggerSP = DataLogger::make(simNameSP, true, logDownSampling); - loggerSP->logAttribute("v_gen", genSP->attribute("v_intf")); - loggerSP->logAttribute("i_gen", genSP->attribute("i_intf")); - loggerSP->logAttribute("Te", genSP->attribute("Te")); - loggerSP->logAttribute("delta", genSP->attribute("delta")); - loggerSP->logAttribute("w_r", genSP->attribute("w_r")); - loggerSP->logAttribute("Vdq0", genSP->attribute("Vdq0")); - loggerSP->logAttribute("Idq0", genSP->attribute("Idq0")); - loggerSP->logAttribute("Ef", genSP->attribute("Ef")); - loggerSP->logAttribute("Tm", genSP->attribute("Tm")); - if (SGModel == "6a" || SGModel == "6b") { - loggerSP->logAttribute("Edq0_s", genSP->attribute("Edq_s")); - loggerSP->logAttribute("Edq0_t", genSP->attribute("Edq_t")); - } else { - loggerSP->logAttribute("Edq0", genSP->attribute("Edq_t")); - } - - Simulation simSP(simNameSP, logLevel); - simSP.doInitFromNodesAndTerminals(true); - simSP.setSystem(systemSP); - simSP.setTimeStep(timeStep); - simSP.setFinalTime(finalTime); - simSP.setDomain(Domain::SP); - simSP.addLogger(loggerSP); - simSP.doSystemMatrixRecomputation(true); - - auto sw2 = SwitchEvent::make(endTimeFault, fault, false); - simSP.addEvent(sw2); - - simSP.run(); -} diff --git a/dpsim/examples/cxx/Circuits/SP_SMIB_ReducedOrderSG_LoadStep.cpp b/dpsim/examples/cxx/Circuits/SP_SMIB_ReducedOrderSG_LoadStep.cpp index 55f5d2b91f..9f0dcfae91 100644 --- a/dpsim/examples/cxx/Circuits/SP_SMIB_ReducedOrderSG_LoadStep.cpp +++ b/dpsim/examples/cxx/Circuits/SP_SMIB_ReducedOrderSG_LoadStep.cpp @@ -127,17 +127,6 @@ int main(int argc, char *argv[]) { auto n2SP = SimNode::make("n2SP", PhaseType::Single, initialVoltage_n2); - // Synchronous generator - auto genSP = GeneratorFactory::createGenSP(sgType, "SynGen", logLevel); - genSP->setOperationalParametersPerUnit( - syngenKundur.nomPower, syngenKundur.nomVoltage, syngenKundur.nomFreq, H, - syngenKundur.Ld, syngenKundur.Lq, syngenKundur.Ll, syngenKundur.Ld_t, - syngenKundur.Lq_t, syngenKundur.Td0_t, syngenKundur.Tq0_t, - syngenKundur.Ld_s, syngenKundur.Lq_s, syngenKundur.Td0_s, - syngenKundur.Tq0_s); - genSP->setInitialValues(initElecPower, initMechPower, n1PF->voltage()(0, 0)); - genSP->setModelAsNortonSource(true); - // Synchronous generator auto genSP = Factory::get().create( sgType, "SynGen", logLevel); @@ -150,6 +139,10 @@ int main(int argc, char *argv[]) { genSP->setInitialValues(initElecPower, initMechPower, n1PF->voltage()(0, 0)); genSP->setModelAsNortonSource(true); + //Grid bus as Slack + auto extnetSP = SP::Ph1::NetworkInjection::make("Slack", logLevel); + extnetSP->setParameters(gridParams.VnomMV); + // Line auto lineSP = SP::Ph1::PiLine::make("PiLine", logLevel); lineSP->setParameters(gridParams.lineResistance, gridParams.lineInductance, @@ -193,4 +186,4 @@ int main(int argc, char *argv[]) { simSP.addEvent(loadStepEvent); simSP.run(); -} +} \ No newline at end of file diff --git a/dpsim/examples/cxx/Components/EMT_SynchronGenerator9OrderDCIM_LoadStep_TurbineGovernor_Exciter.cpp b/dpsim/examples/cxx/Components/EMT_SynchronGenerator9OrderDCIM_LoadStep_TurbineGovernor_Exciter.cpp index fa535e66b7..39988978a9 100644 --- a/dpsim/examples/cxx/Components/EMT_SynchronGenerator9OrderDCIM_LoadStep_TurbineGovernor_Exciter.cpp +++ b/dpsim/examples/cxx/Components/EMT_SynchronGenerator9OrderDCIM_LoadStep_TurbineGovernor_Exciter.cpp @@ -100,10 +100,6 @@ int main(int argc, char *argv[]) { gen->addExciter(exciter); } - if (withExciter) - gen->addExciter(excEremia.Ta, excEremia.Ka, excEremia.Te, excEremia.Ke, - excEremia.Tf, excEremia.Kf, excEremia.Tr); - auto fault = CPS::EMT::Ph3::Switch::make("Br_fault", CPS::Logger::Level::info); fault->setParameters(Math::singlePhaseParameterToThreePhase(RloadOriginal), @@ -136,4 +132,4 @@ int main(int argc, char *argv[]) { sim.addEvent(sw1); sim.run(); -} +} \ No newline at end of file diff --git a/dpsim/examples/cxx/Components/EMT_SynchronGenerator9OrderVBR_LoadStep_TurbineGovernor_Exciter.cpp b/dpsim/examples/cxx/Components/EMT_SynchronGenerator9OrderVBR_LoadStep_TurbineGovernor_Exciter.cpp index 86b83a2d99..033ebed666 100644 --- a/dpsim/examples/cxx/Components/EMT_SynchronGenerator9OrderVBR_LoadStep_TurbineGovernor_Exciter.cpp +++ b/dpsim/examples/cxx/Components/EMT_SynchronGenerator9OrderVBR_LoadStep_TurbineGovernor_Exciter.cpp @@ -94,10 +94,6 @@ int main(int argc, char *argv[]) { govKundur.Tsm, initActivePower / syngenKundur.nomPower, initMechPower / syngenKundur.nomPower); - if (withExciter) - gen->addExciter(excEremia.Ta, excEremia.Ka, excEremia.Te, excEremia.Ke, - excEremia.Tf, excEremia.Kf, excEremia.Tr); - std::shared_ptr exciter = nullptr; if (withExciter) { exciter = @@ -106,6 +102,12 @@ int main(int argc, char *argv[]) { gen->addExciter(exciter); } + auto fault = + CPS::EMT::Ph3::Switch::make("Br_fault", CPS::Logger::Level::info); + fault->setParameters(Math::singlePhaseParameterToThreePhase(RloadOriginal), + Math::singlePhaseParameterToThreePhase(RloadNew)); + fault->openSwitch(); + // Connections gen->connect({n1}); fault->connect({CPS::EMT::SimNode::GND, n1}); @@ -118,20 +120,19 @@ int main(int argc, char *argv[]) { logger->logAttribute("v1", n1->attribute("v")); logger->logAttribute("i_gen", gen->attribute("i_intf")); logger->logAttribute("wr_gen", gen->attribute("w_r")); + logger->logAttribute("vf_exc_gen", gen->attribute("Vfd")); - // Log further variables if exciter connected - if (withExciter) { - logger->logAttribute("vh_exc_gen", gen->mExciter->attribute("Vh")); - logger->logAttribute("vr_exc_gen", gen->mExciter->attribute("Vr")); - logger->logAttribute("vf_exc_gen", gen->mExciter->attribute("Ef")); - } + Simulation sim(simName, Logger::Level::info); + sim.setSystem(sys); + sim.setTimeStep(timeStep); + sim.setFinalTime(finalTime); + sim.doSystemMatrixRecomputation(true); + sim.setDomain(Domain::EMT); + sim.addLogger(logger); - // Logging - auto logger = DataLogger::make(simName); - logger->logAttribute("v1", n1->attribute("v")); - logger->logAttribute("i_gen", gen->attribute("i_intf")); - logger->logAttribute("wr_gen", gen->attribute("w_r")); - logger->logAttribute("vf_exc_gen", gen->attribute("Vfd")); + // Events + auto sw1 = SwitchEvent3Ph::make(timeStepEvent, fault, true); + sim.addEvent(sw1); sim.run(); -} +} \ No newline at end of file diff --git a/dpsim/examples/cxx/Examples.h b/dpsim/examples/cxx/Examples.h index c433949f5d..b775802e0c 100644 --- a/dpsim/examples/cxx/Examples.h +++ b/dpsim/examples/cxx/Examples.h @@ -6,11 +6,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. *********************************************************************************/ -#include -#include -#include -#include - #pragma once #include @@ -68,33 +63,6 @@ namespace Exciter { // from M. Eremia, "Handbook of Electrical Power System Dynamics", 2013, p.96 and 106 // voltage-regulator -CPS::Base::ExciterParameters getExciterEremia() { - CPS::Base::ExciterParameters ExcitationSystemEremia; - ExcitationSystemEremia.Ka = 46; - ExcitationSystemEremia.Ta = 0.06; - // exciter - ExcitationSystemEremia.Kef = -0.0435; - ExcitationSystemEremia.Tef = 0.46; - // stabilizing feedback - ExcitationSystemEremia.Kf = 0.1; - ExcitationSystemEremia.Tf = 1; - // voltage transducer - ExcitationSystemEremia.Tr = 0.02; - // saturation function coefficients - ExcitationSystemEremia.Aef = 0.33; - ExcitationSystemEremia.Bef = 0.1; - - ExcitationSystemEremia.MaxVr = 1.0; - ExcitationSystemEremia.MinVr = -0.9; - - return ExcitationSystemEremia; -} - -namespace Exciter { -// Excitation system parameters (IEEE Type DC1 - simplified) -// from M. Eremia, "Handbook of Electrical Power System Dynamics", 2013, p.96 and 106 -// voltage-regulator - std::shared_ptr getExciterParametersEremia() { auto excitationSystemEremia = CPS::Signal::ExciterDC1SimpParameters::make(); @@ -123,17 +91,6 @@ getExciterParametersEremia() { return excitationSystemEremia; } -struct ExcitationKundur { - /// Exciter model used in Kundurs. It is a very simplified version of a thyristor - /// exciter (ST1 type) without transient gain reduction or derivative feedback - /// (only proportional block + terminal voltage transducer) - /// Ref.: Kundur, Power System Stability and Control, p. 865 - Real Ka = 200; - // voltage transducer - Real Tr = 0.02; -}; -} - struct ExcitationKundur { /// Exciter model used in Kundurs. It is a very simplified version of a thyristor /// exciter (ST1 type) without transient gain reduction or derivative feedback @@ -271,26 +228,6 @@ getTurbineGovernorPSAT2() { return governor; }; -// Reference speed (p.u.) -Real OmegaRef = 1.0; -// Pilot valve droop (p.u.) -Real R = 0.04; -// Maximum Torque (p.u.) -Real Tmax = 100; -// Minimim Torque (p.u.) -Real Tmin = 0.0; -// Governor time constant (s) -Real Ts = 20; -// Servo time constant (s) -Real Tc = 0.2; -// Transient gain time constant (s) -Real T3 = 0.2; -// Power fraction time constant (s) -Real T4 = 0.2; -// Reheat time constant (s) -Real T5 = 0.2; -}; - struct SteamTurbine { //Steam Turbine implemented by HiWi in August 2023, //Power fraction of a high pressure stage @@ -346,8 +283,9 @@ struct HydroTurbineGovernor { //Minimum mechanical power (pu) Real Pmin = 0; }; -} -} + +} // namespace TurbineGovernor +} // namespace Components namespace Grids { namespace CIGREHVEuropean { @@ -995,4 +933,4 @@ std::shared_ptr createEventAddPowerConsumption3Ph( } // namespace Events } // namespace Examples } // namespace CIM -} // namespace CPS +} // namespace CPS \ No newline at end of file diff --git a/dpsim/src/pybind/SignalComponents.cpp b/dpsim/src/pybind/SignalComponents.cpp index 6c6a752ea1..88d2d7373e 100644 --- a/dpsim/src/pybind/SignalComponents.cpp +++ b/dpsim/src/pybind/SignalComponents.cpp @@ -127,145 +127,27 @@ void addSignalComponents(py::module_ mSignal) { .def_readwrite("MaxVa", &CPS::Signal::ExciterST1Parameters::MaxVa) .def_readwrite("MinVa", &CPS::Signal::ExciterST1Parameters::MinVa); - py::class_, - CPS::Base::ExciterParameters>(mSignal, "ExciterStaticParameters", - py::multiple_inheritance()) - .def(py::init()) - .def_readwrite("Ta", &CPS::Signal::ExciterStaticParameters::Ta) - .def_readwrite("Tb", &CPS::Signal::ExciterStaticParameters::Tb) - .def_readwrite("Te", &CPS::Signal::ExciterStaticParameters::Te) - .def_readwrite("Ka", &CPS::Signal::ExciterStaticParameters::Ka) - .def_readwrite("MaxEfd", &CPS::Signal::ExciterStaticParameters::MaxEfd) - .def_readwrite("MinEfd", &CPS::Signal::ExciterStaticParameters::MinEfd); - py::class_, - CPS::Base::ExciterParameters>(mSignal, "ExciterDC1Parameters", - py::multiple_inheritance()) - .def(py::init()) - .def_readwrite("Tr", &CPS::Signal::ExciterDC1Parameters::Tr) - .def_readwrite("Tb", &CPS::Signal::ExciterDC1Parameters::Tb) - .def_readwrite("Tc", &CPS::Signal::ExciterDC1Parameters::Tc) - .def_readwrite("Ta", &CPS::Signal::ExciterDC1Parameters::Ta) - .def_readwrite("Ka", &CPS::Signal::ExciterDC1Parameters::Ka) - .def_readwrite("Tef", &CPS::Signal::ExciterDC1Parameters::Tef) - .def_readwrite("Kef", &CPS::Signal::ExciterDC1Parameters::Kef) - .def_readwrite("Tf", &CPS::Signal::ExciterDC1Parameters::Tf) - .def_readwrite("Kf", &CPS::Signal::ExciterDC1Parameters::Kf) - .def_readwrite("Aef", &CPS::Signal::ExciterDC1Parameters::Aef) - .def_readwrite("Bef", &CPS::Signal::ExciterDC1Parameters::Bef) - .def_readwrite("MaxVa", &CPS::Signal::ExciterDC1Parameters::MaxVa) - .def_readwrite("MinVa", &CPS::Signal::ExciterDC1Parameters::MinVa); - py::class_, - CPS::Base::ExciterParameters>(mSignal, "ExciterDC1SimpParameters", - py::multiple_inheritance()) - .def(py::init()) - .def_readwrite("Tr", &CPS::Signal::ExciterDC1SimpParameters::Tr) - .def_readwrite("Ta", &CPS::Signal::ExciterDC1SimpParameters::Ta) - .def_readwrite("Ka", &CPS::Signal::ExciterDC1SimpParameters::Ka) - .def_readwrite("Tef", &CPS::Signal::ExciterDC1SimpParameters::Tef) - .def_readwrite("Kef", &CPS::Signal::ExciterDC1SimpParameters::Kef) - .def_readwrite("Tf", &CPS::Signal::ExciterDC1SimpParameters::Tf) - .def_readwrite("Kf", &CPS::Signal::ExciterDC1SimpParameters::Kf) - .def_readwrite("Aef", &CPS::Signal::ExciterDC1SimpParameters::Aef) - .def_readwrite("Bef", &CPS::Signal::ExciterDC1SimpParameters::Bef) - .def_readwrite("MaxVa", &CPS::Signal::ExciterDC1SimpParameters::MaxVa) - .def_readwrite("MinVa", &CPS::Signal::ExciterDC1SimpParameters::MinVa); - py::class_, - CPS::Base::ExciterParameters>(mSignal, "ExciterST1Parameters", - py::multiple_inheritance()) - .def(py::init()) - .def_readwrite("Tr", &CPS::Signal::ExciterST1Parameters::Tr) - .def_readwrite("Ka", &CPS::Signal::ExciterST1Parameters::Ka) - .def_readwrite("MaxVa", &CPS::Signal::ExciterST1Parameters::MaxVa) - .def_readwrite("MinVa", &CPS::Signal::ExciterST1Parameters::MinVa); - - py::class_, - CPS::Base::GovernorParameters>( - mSignal, "TurbineGovernorType1Parameters", py::multiple_inheritance()) - .def(py::init()) - .def_readwrite("Tmax", &CPS::Signal::TurbineGovernorType1Parameters::Pmax) - .def_readwrite("Tmin", &CPS::Signal::TurbineGovernorType1Parameters::Pmin) - .def_readwrite("R", &CPS::Signal::TurbineGovernorType1Parameters::R) - .def_readwrite("T3", &CPS::Signal::TurbineGovernorType1Parameters::T3) - .def_readwrite("T4", &CPS::Signal::TurbineGovernorType1Parameters::T4) - .def_readwrite("T5", &CPS::Signal::TurbineGovernorType1Parameters::T5) - .def_readwrite("Tc", &CPS::Signal::TurbineGovernorType1Parameters::Tc) - .def_readwrite("Ts", &CPS::Signal::TurbineGovernorType1Parameters::Ts) - .def_readwrite("OmRef", - &CPS::Signal::TurbineGovernorType1Parameters::OmRef); - py::class_, - CPS::Base::GovernorParameters>(mSignal, "HydroGorvernorParameters", - py::multiple_inheritance()) - .def(py::init()) - .def_readwrite("R", &CPS::Signal::HydroGorvernorParameters::R) - .def_readwrite("T1", &CPS::Signal::HydroGorvernorParameters::T1) - .def_readwrite("T2", &CPS::Signal::HydroGorvernorParameters::T2) - .def_readwrite("T3", &CPS::Signal::HydroGorvernorParameters::T3) - .def_readwrite("Pmax", &CPS::Signal::HydroGorvernorParameters::Pmax) - .def_readwrite("Pmin", &CPS::Signal::HydroGorvernorParameters::Pmin) - .def_readwrite("OmRef", &CPS::Signal::HydroGorvernorParameters::OmRef); - py::class_, - CPS::Base::GovernorParameters>(mSignal, "SteamGorvernorParameters", - py::multiple_inheritance()) - .def(py::init()) - .def_readwrite("R", &CPS::Signal::SteamGorvernorParameters::R) - .def_readwrite("T1", &CPS::Signal::SteamGorvernorParameters::T1) - .def_readwrite("T2", &CPS::Signal::SteamGorvernorParameters::T2) - .def_readwrite("T3", &CPS::Signal::SteamGorvernorParameters::T3) - .def_readwrite("dPmax", &CPS::Signal::SteamGorvernorParameters::dPmax) - .def_readwrite("dPmin", &CPS::Signal::SteamGorvernorParameters::dPmin) - .def_readwrite("Pmax", &CPS::Signal::SteamGorvernorParameters::Pmax) - .def_readwrite("Pmin", &CPS::Signal::SteamGorvernorParameters::Pmin) - .def_readwrite("OmRef", &CPS::Signal::SteamGorvernorParameters::OmRef) - .def_readwrite("Kbc", &CPS::Signal::SteamGorvernorParameters::Kbc); + // PSS + py::class_, + CPS::Base::PSS>(mSignal, "PSS1A", py::multiple_inheritance()) + .def(py::init(), "name"_a, + "loglevel"_a = CPS::Logger::Level::off); - py::class_, - CPS::Base::GovernorParameters>( - mSignal, "TurbineGovernorType1Parameters", py::multiple_inheritance()) - .def(py::init()) - .def_readwrite("Pmax", &CPS::Signal::TurbineGovernorType1Parameters::Pmax) - .def_readwrite("Pmin", &CPS::Signal::TurbineGovernorType1Parameters::Pmin) - .def_readwrite("R", &CPS::Signal::TurbineGovernorType1Parameters::R) - .def_readwrite("T3", &CPS::Signal::TurbineGovernorType1Parameters::T3) - .def_readwrite("T4", &CPS::Signal::TurbineGovernorType1Parameters::T4) - .def_readwrite("T5", &CPS::Signal::TurbineGovernorType1Parameters::T5) - .def_readwrite("Tc", &CPS::Signal::TurbineGovernorType1Parameters::Tc) - .def_readwrite("Ts", &CPS::Signal::TurbineGovernorType1Parameters::Ts) - .def_readwrite("OmRef", - &CPS::Signal::TurbineGovernorType1Parameters::OmRef); - py::class_, - CPS::Base::GovernorParameters>(mSignal, "HydroGorvernorParameters", - py::multiple_inheritance()) - .def(py::init()) - .def_readwrite("R", &CPS::Signal::HydroGorvernorParameters::R) - .def_readwrite("T1", &CPS::Signal::HydroGorvernorParameters::T1) - .def_readwrite("T2", &CPS::Signal::HydroGorvernorParameters::T2) - .def_readwrite("T3", &CPS::Signal::HydroGorvernorParameters::T3) - .def_readwrite("Pmax", &CPS::Signal::HydroGorvernorParameters::Pmax) - .def_readwrite("Pmin", &CPS::Signal::HydroGorvernorParameters::Pmin) - .def_readwrite("OmRef", &CPS::Signal::HydroGorvernorParameters::OmRef); - py::class_, - CPS::Base::GovernorParameters>(mSignal, "SteamGorvernorParameters", - py::multiple_inheritance()) - .def(py::init()) - .def_readwrite("R", &CPS::Signal::SteamGorvernorParameters::R) - .def_readwrite("T1", &CPS::Signal::SteamGorvernorParameters::T1) - .def_readwrite("T2", &CPS::Signal::SteamGorvernorParameters::T2) - .def_readwrite("T3", &CPS::Signal::SteamGorvernorParameters::T3) - .def_readwrite("dPmax", &CPS::Signal::SteamGorvernorParameters::dPmax) - .def_readwrite("dPmin", &CPS::Signal::SteamGorvernorParameters::dPmin) - .def_readwrite("Pmax", &CPS::Signal::SteamGorvernorParameters::Pmax) - .def_readwrite("Pmin", &CPS::Signal::SteamGorvernorParameters::Pmin) - .def_readwrite("OmRef", &CPS::Signal::SteamGorvernorParameters::OmRef); + py::class_, + CPS::Base::PSSParameters>(mSignal, "PSS1AParameters", + py::multiple_inheritance()) + .def(py::init()) + .def_readwrite("Kp", &CPS::Signal::PSS1AParameters::Kp) + .def_readwrite("Kv", &CPS::Signal::PSS1AParameters::Kv) + .def_readwrite("Kw", &CPS::Signal::PSS1AParameters::Kw) + .def_readwrite("T1", &CPS::Signal::PSS1AParameters::T1) + .def_readwrite("T2", &CPS::Signal::PSS1AParameters::T2) + .def_readwrite("T3", &CPS::Signal::PSS1AParameters::T3) + .def_readwrite("T4", &CPS::Signal::PSS1AParameters::T4) + .def_readwrite("Tw", &CPS::Signal::PSS1AParameters::Tw) + .def_readwrite("Vs_max", &CPS::Signal::PSS1AParameters::Vs_max) + .def_readwrite("Vs_min", &CPS::Signal::PSS1AParameters::Vs_min); // Governos py::class_( mSignal, "TurbineGovernorType1Parameters", py::multiple_inheritance()) .def(py::init()) - .def_readwrite("Pmax", &CPS::Signal::TurbineGovernorType1Parameters::Pmax) - .def_readwrite("Pmin", &CPS::Signal::TurbineGovernorType1Parameters::Pmin) + .def_readwrite("Tmax", &CPS::Signal::TurbineGovernorType1Parameters::Pmax) + .def_readwrite("Tmin", &CPS::Signal::TurbineGovernorType1Parameters::Pmin) .def_readwrite("R", &CPS::Signal::TurbineGovernorType1Parameters::R) .def_readwrite("T3", &CPS::Signal::TurbineGovernorType1Parameters::T3) .def_readwrite("T4", &CPS::Signal::TurbineGovernorType1Parameters::T4) @@ -320,13 +202,15 @@ void addSignalComponents(py::module_ mSignal) { py::multiple_inheritance()) .def(py::init()) .def_readwrite("R", &CPS::Signal::SteamGorvernorParameters::R) + .def_readwrite("T1", &CPS::Signal::SteamGorvernorParameters::T1) .def_readwrite("T2", &CPS::Signal::SteamGorvernorParameters::T2) .def_readwrite("T3", &CPS::Signal::SteamGorvernorParameters::T3) .def_readwrite("dPmax", &CPS::Signal::SteamGorvernorParameters::dPmax) .def_readwrite("dPmin", &CPS::Signal::SteamGorvernorParameters::dPmin) .def_readwrite("Pmax", &CPS::Signal::SteamGorvernorParameters::Pmax) .def_readwrite("Pmin", &CPS::Signal::SteamGorvernorParameters::Pmin) - .def_readwrite("OmRef", &CPS::Signal::SteamGorvernorParameters::OmRef); + .def_readwrite("OmRef", &CPS::Signal::SteamGorvernorParameters::OmRef) + .def_readwrite("Kbc", &CPS::Signal::SteamGorvernorParameters::Kbc); // Turbines py::class_