Skip to content

Commit

Permalink
solve rebase conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: martin.moraga <[email protected]>
  • Loading branch information
martinmoraga committed Mar 1, 2024
1 parent 0ad16ac commit 7220abb
Show file tree
Hide file tree
Showing 27 changed files with 414 additions and 2,034 deletions.
39 changes: 20 additions & 19 deletions dpsim-models/include/dpsim-models/Base/Base_Exciter.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,30 @@

#pragma once

#include <dpsim-models/Definitions.h>

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<Base::ExciterParameters> 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<Base::ExciterParameters> 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
40 changes: 20 additions & 20 deletions dpsim-models/include/dpsim-models/Base/Base_Governor.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,30 @@

#pragma once

#include <dpsim-models/Definitions.h>

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<Base::GovernorParameters> 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<Base::GovernorParameters> 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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@

#include <dpsim-models/Base/Base_Exciter.h>
#include <dpsim-models/Base/Base_Governor.h>
#include <dpsim-models/Base/Base_PSS.h>
#include <dpsim-models/Base/Base_Turbine.h>
#include <dpsim-models/MNASimPowerComp.h>
#include <dpsim-models/Solver/MNAInterface.h>

namespace CPS {
namespace Base {
Expand Down Expand Up @@ -94,27 +97,28 @@ class ReducedOrderSynchronGenerator : public MNASimPowerComp<VarType> {
/// Add Governor/TurbineGovernor
void addTurbine(std::shared_ptr<Base::Turbine> turbine);

/// Add Governor/TurbineGovernor
//void addGovernor(std::shared_ptr<CPS::Base::GovernorParameters> governorParameters, GovernorType governorType = GovernorType::TurbineGovernorType1);
void addGovernor(std::shared_ptr<Base::Governor> 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<Signal::SteamTurbine> 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<Signal::SteamTurbineGovernor> 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<Signal::HydroTurbine> 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<Signal::HydroTurbineGovernor> hydroTurbineGovernor);

protected:
using MNASimPowerComp<VarType>::mRightVector;
using MNASimPowerComp<VarType>::mIntfVoltage;
using MNASimPowerComp<VarType>::MnaPreStep;
using MNASimPowerComp<VarType>::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,
Expand Down Expand Up @@ -254,32 +258,6 @@ class ReducedOrderSynchronGenerator : public MNASimPowerComp<VarType> {
/// 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<Signal::TurbineGovernorType1> mTurbineGovernor;
/// Signal component modelling voltage regulator and exciter
std::shared_ptr<Signal::Exciter> 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<Signal::TurbineGovernorType1> mTurbineGovernor;
/// Signal component modelling voltage regulator and exciter
std::shared_ptr<Base::Exciter> mExciter;
/// Signal component modelling voltage regulator and exciter
std::shared_ptr<Signal::PSSType2> mPSS;
///
Real mVpss = 0;

// #### Controllers ####
/// Determines if Exciter is activated
Bool mHasExciter = false;
Expand All @@ -302,34 +280,10 @@ class ReducedOrderSynchronGenerator : public MNASimPowerComp<VarType> {
///
Real mVpss = 0;

/// Signal component modelling voltage regulator and exciter
std::shared_ptr<Base::Exciter> mExciter;
/// Signal component modelling power system stabilizer
std::shared_ptr<Base::PSS> mPSS;
/// Signal component modelling Turbine
//std::shared_ptr<Signal::Turbine> mTurbine;
/// Signal component modelling governor control
std::shared_ptr<Base::Governor> mGovernor;

///
Real mVpss = 0;

/// Signal component modelling voltage regulator and exciter
std::shared_ptr<Base::Exciter> mExciter;
/// Signal component modelling power system stabilizer
std::shared_ptr<Signal::PSS1A> mPSS;
/// Signal component modelling Turbine
//std::shared_ptr<Signal::Turbine> mTurbine;
/// Signal component modelling governor control
std::shared_ptr<Base::Governor> mGovernor;

///
Real mVpss = 0;

///
Real mTimeStep;
///
Real mSimTime;
};
} // namespace Base
} // namespace CPS
} // namespace CPS
101 changes: 15 additions & 86 deletions dpsim-models/include/dpsim-models/Base/Base_SynchronGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include <dpsim-models/AttributeList.h>
#include <dpsim-models/Definitions.h>
#include <dpsim-models/Signal/ExciterDC1Simp.h>
#include <dpsim-models/Signal/TurbineGovernor.h>

Expand Down Expand Up @@ -176,10 +177,6 @@ class SynchronGenerator {
/// theta
Real mThetaMech = 0;

// ### State variables ###
/// theta
Real mThetaMech = 0;

public:
/// rotor angle delta
const Attribute<Real>::Ptr mDelta;
Expand All @@ -200,40 +197,6 @@ class SynchronGenerator {
/// Voltage excitation
const Attribute<Real>::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.
///
Expand Down Expand Up @@ -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<Real>("Rs", 0)),
mLl(attributeList->create<Real>("Ll", 0)),
mLd(attributeList->create<Real>("Ld", 0)),
mLq(attributeList->create<Real>("Lq", 0)),
mLd_t(attributeList->create<Real>("Ld_t", 0)),
mLq_t(attributeList->create<Real>("Lq_t", 0)),
mLd_s(attributeList->create<Real>("Ld_s", 0)),
mLq_s(attributeList->create<Real>("Lq_s", 0)),
mTd0_t(attributeList->create<Real>("Td0_t", 0)),
mTq0_t(attributeList->create<Real>("Tq0_t", 0)),
mTd0_s(attributeList->create<Real>("Td0_s", 0)),
mTq0_s(attributeList->create<Real>("Tq0_s", 0)),
mDelta(attributeList->create<Real>("delta_r", 0)),
mMechTorque(attributeList->create<Real>("T_m", 0)),
mInertia(attributeList->create<Real>("inertia", 0)),
mOmMech(attributeList->create<Real>("w_r", 0)),
mElecActivePower(attributeList->create<Real>("P_elec", 0)),
mElecReactivePower(attributeList->create<Real>("Q_elec", 0)),
mMechPower(attributeList->create<Real>("P_mech", 0)),
mElecTorque(attributeList->create<Real>("T_e", 0)),
mVfd(attributeList->create<Real>("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<Real>::create("Rs", attributeList, 0)),
mLl(Attribute<Real>::create("Ll", attributeList, 0)),
mLd(Attribute<Real>::create("Ld", attributeList, 0)),
mLq(Attribute<Real>::create("Lq", attributeList, 0)),
mLd_t(Attribute<Real>::create("Ld_t", attributeList, 0)),
mLq_t(Attribute<Real>::create("Lq_t", attributeList, 0)),
mLd_s(Attribute<Real>::create("Ld_s", attributeList, 0)),
mLq_s(Attribute<Real>::create("Lq_s", attributeList, 0)),
mTd0_t(Attribute<Real>::create("Td0_t", attributeList, 0)),
mTq0_t(Attribute<Real>::create("Tq0_t", attributeList, 0)),
mTd0_s(Attribute<Real>::create("Td0_s", attributeList, 0)),
mTq0_s(Attribute<Real>::create("Tq0_s", attributeList, 0)),
mDelta(Attribute<Real>::create("delta_r", attributeList, 0)),
mMechTorque(Attribute<Real>::create("T_m", attributeList, 0)),
mInertia(Attribute<Real>::create("inertia", attributeList, 0)),
mOmMech(Attribute<Real>::create("w_r", attributeList, 0)),
mElecActivePower(Attribute<Real>::create("P_elec", attributeList, 0)),
mElecReactivePower(Attribute<Real>::create("Q_elec", attributeList, 0)),
mMechPower(Attribute<Real>::create("P_mech", attributeList, 0)),
mElecTorque(Attribute<Real>::create("T_e", attributeList, 0)),
mVfd(Attribute<Real>::create("Vfd", attributeList, 0)){};
// Deprecated
Real mInitTerminalVoltage = 0;
Real mInitVoltAngle = 0;

/// Constructor
explicit SynchronGenerator(CPS::AttributeList::Ptr attributeList)
Expand All @@ -366,7 +291,8 @@ class SynchronGenerator {
mElecActivePower(attributeList->create<Real>("P_elec", 0)),
mElecReactivePower(attributeList->create<Real>("Q_elec", 0)),
mMechPower(attributeList->create<Real>("P_mech", 0)),
mElecTorque(attributeList->create<Real>("T_e", 0)){};
mElecTorque(attributeList->create<Real>("T_e", 0)),
mVfd(attributeList->create<Real>("Vfd", 0)){};

///
void setBaseParameters(Real nomPower, Real nomVolt, Real nomFreq);
Expand Down Expand Up @@ -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<Signal::TurbineGovernor> mTurbineGovernor;
/// Signal component modelling voltage regulator and exciter
std::shared_ptr<Base::Exciter> mExciter;
};
} // namespace Base
} // namespace CPS
} // namespace CPS
Loading

0 comments on commit 7220abb

Please sign in to comment.