40 nomPower, nomVolt, nomFreq, poleNumber, nomFieldCur, Rs, Ld, Lq, Ld_t,
41 Lq_t, Ld_s, Lq_s, Ll, Td0_t, Tq0_t, Td0_s, Tq0_s, inertia);
45 "Set base parameters: \n"
46 "nomPower: {:e}\nnomVolt: {:e}\nnomFreq: {:e}\n nomFieldCur: {:e}\n",
47 nomPower, nomVolt, nomFreq, nomFieldCur);
49 SPDLOG_LOGGER_INFO(
mSLog,
50 "Set operational parameters in per unit: \n"
51 "poleNumber: {:d}\ninertia: {:e}\n"
52 "Rs: {:e}\nLd: {:e}\nLq: {:e}\nLl: {:e}\n"
53 "Ld_t: {:e}\nLq_t: {:e}\nLd_s: {:e}\nLq_s: {:e}\n"
54 "Td0_t: {:e}\nTq0_t: {:e}\nTd0_s: {:e}\nTq0_s: {:e}\n",
55 poleNumber, inertia, Rs, Ld, Lq, Ll, Ld_t, Lq_t, Ld_s,
56 Lq_s, Td0_t, Tq0_t, Td0_s, Tq0_s);
60 "Set fundamental parameters in per unit: \n"
61 "Rs: {:e}\nLl: {:e}\nLmd: {:e}\nLmq: {:e}\nRfd: {:e}\nLlfd: {:e}\nRkd: "
63 "Llkd: {:e}\nRkq1: {:e}\nLlkq1: {:e}\nRkq2: {:e}\nLlkq2: {:e}\n",
64 **
mRs, **
mLl,
mLmd,
mLmq,
mRfd,
mLlfd,
mRkd,
mLlkd,
mRkq1,
mLlkq1,
mRkq2,
74 nomPower, nomVolt, nomFreq, nomFieldCur, poleNumber, Rs, Ll, Lmd, Lmq,
75 Rfd, Llfd, Rkd, Llkd, Rkq1, Llkq1, Rkq2, Llkq2, inertia);
77 SPDLOG_LOGGER_INFO(
mSLog,
78 "Set base and fundamental parameters in per unit: \n"
79 "nomPower: {:e}\nnomVolt: {:e}\nnomFreq: "
80 "{:e}\npoleNumber: {:d}\nnomFieldCur: {:e}\n"
81 "Rs: {:e}\nLl: {:e}\nLmd: {:e}\nLmq: {:e}\nRfd: "
82 "{:e}\nLlfd: {:e}\nRkd: {:e}\n"
83 "Llkd: {:e}\nRkq1: {:e}\nLlkq1: {:e}\nRkq2: {:e}\nLlkq2: "
84 "{:e}\ninertia: {:e}",
85 nomPower, nomVolt, nomFreq, poleNumber, nomFieldCur, Rs,
86 Ll, Lmd, Lmq, Rfd, Llfd, Rkd, Llkd, Rkq1, Llkq1, Rkq2,
91 Real initReactivePower,
92 Real initTerminalVolt,
97 initTerminalVolt, initVoltAngle,
102 "Set initial values: \n"
103 "initActivePower: {:e}\ninitReactivePower: {:e}\ninitTerminalVolt: {:e}\n"
104 "initVoltAngle: {:e} \ninitMechPower: {:e}",
105 initActivePower, initReactivePower, initTerminalVolt, initVoltAngle,
112 SPDLOG_LOGGER_INFO(
mSLog,
"--- Initialization from powerflow ---");
116 Real reactivePower = -
terminal(0)->singlePower().imag();
124 SPDLOG_LOGGER_INFO(
mSLog,
125 "\nTerminal 0 voltage: {:s}"
126 "\nTerminal 0 power: {:s}"
127 "\n--- Initialization from powerflow finished ---",
131 SPDLOG_LOGGER_INFO(
mSLog,
"Initial values already set, skipping "
132 "initializeFromNodesAndTerminals.");
141 for (
UInt phase1Idx = 0; phase1Idx < 3; ++phase1Idx)
142 for (
UInt phase2Idx = 0; phase2Idx < 3; ++phase2Idx)
146 SPDLOG_LOGGER_INFO(
mSLog,
"List of index pairs of varying matrix entries: ");
148 SPDLOG_LOGGER_INFO(
mSLog,
"({}, {})", indexPair.first, indexPair.second);
163 K1a = Matrix::Zero(2, 1);
164 K1 = Matrix::Zero(2, 1);
237 SPDLOG_LOGGER_INFO(
mSLog,
"Initialize right side vector of size {}",
238 leftVector->
get().rows());
240 mSLog,
"Component affects right side vector entries {}, {} and {}",
425 attributeDependencies.push_back(leftVector);
529 K <<
K1,
K2, Matrix::Zero(2, 1), 0, 0, 0;
535 2. / 3. * sin(
mThetaMech + 2. *
M_PI / 3.), 1. / 3., 1. / 3., 1. / 3.;
562 q = 2. / 3. * cos(theta) * a + 2. / 3. * cos(theta - 2. *
M_PI / 3.) * b +
563 2. / 3. * cos(theta + 2. *
M_PI / 3.) * c;
564 d = 2. / 3. * sin(theta) * a + 2. / 3. * sin(theta - 2. *
M_PI / 3.) * b +
565 2. / 3. * sin(theta + 2. *
M_PI / 3.) * c;
566 zero = 1. / 3. * a + 1. / 3. * b + 1. / 3. * c;
568 dq0vector << q, d, zero;
580 a = cos(theta) * q + sin(theta) * d + 1. * zero;
581 b = cos(theta - 2. *
M_PI / 3.) * q + sin(theta - 2. *
M_PI / 3.) * d +
583 c = cos(theta + 2. *
M_PI / 3.) * q + sin(theta + 2. *
M_PI / 3.) * d +
586 abcVector << a, b, c;
AttributePointer< Attribute< T > > Ptr
Matrix mIsr
Vector of stator and rotor currents.
Bool mHasTurbineGovernorType1
Determines if TurbineGovernorType1 is activated.
Real mTimeStep
Simulation time step.
Real mSystemOmega
Simulation angular system speed.
Real mRkq1
q-axis damper resistance 1 Rkq1 [Ohm]
Real mLmd
d-axis mutual inductance Lmd [H]
Real mBase_I
base stator current peak
Bool mHasExciter
Determines if Exciter is activated.
const Attribute< Real >::Ptr mMechTorque
mechanical torque
void setInitialValues(Real initActivePower, Real initReactivePower, Real initTerminalVolt, Real initVoltAngle, Real initMechPower)
Real mLmq
q-axis mutual inductance Lmq [H]
std::shared_ptr< Base::Exciter > mExciter
Signal component modelling voltage regulator and exciter.
SynchronGenerator(CPS::AttributeList::Ptr attributeList)
Constructor.
std::shared_ptr< Base::Turbine > mTurbine
Modular turbine (SteamTurbine / HydroTurbine)
Real mLlfd
field leakage inductance Llfd [H]
Bool mInitialValuesSet
Flag to remember when initial values are set.
Real mLlkd
d-axis damper leakage inductance Llkd [H]
Matrix mVsr
Vector of stator and rotor voltages.
Matrix mPsisr
Vector of stator and rotor fluxes.
Real mBase_Z
base stator impedance
const Attribute< Real >::Ptr mRs
stator resistance Rs [Ohm]
Matrix mResistanceMat
resistance matrix
Bool mHasGovernorAndTurbine
Determines if modular Governor + Turbine pair is activated.
std::shared_ptr< Base::PSS > mPSS
Power system stabilizer.
std::shared_ptr< Signal::TurbineGovernor > mTurbineGovernor
Signal component modelling governor control and steam turbine (legacy)
Real mLlkq1
q-axis damper leakage inductance 1 Llkq1 [H]
std::shared_ptr< Base::Governor > mGovernor
Modular governor (SteamTurbineGovernor / HydroTurbineGovernor)
void setBaseAndFundamentalPerUnitParameters(Real nomPower, Real nomVolt, Real nomFreq, Real nomFieldCur, Int poleNumber, Real Rs, Real Ll, Real Lmd, Real Lmq, Real Rfd, Real Llfd, Real Rkd, Real Llkd, Real Rkq1, Real Llkq1, Real Rkq2, Real Llkq2, Real inertia)
Initializes the base and fundamental machine parameters in per unit.
Real mRkd
d-axis damper resistance Rkd [Ohm]
Real mRfd
field resistance Rfd [Ohm]
Real mBase_OmElec
base electrical angular frequency
const Attribute< Real >::Ptr mLl
leakage inductance Ll [H]
Real mBase_OmMech
base mechanical angular frequency
Real mRkq2
q-axis damper resistance 2 Rkq2 [Ohm]
Bool mHasPSS
Determines if PSS is activated.
Int mNumDampingWindings
Number of damping windings in q.
Real mBase_V
base stator voltage (phase-to-ground peak)
Real mNomPower
nominal power Pn [VA]
void setBaseAndOperationalPerUnitParameters(Real nomPower, Real nomVolt, Real nomFreq, Int poleNumber, Real nomFieldCur, Real Rs, Real Ld, Real Lq, Real Ld_t, Real Lq_t, Real Ld_s, Real Lq_s, Real Ll, Real Td0_t, Real Tq0_t, Real Td0_s, Real Tq0_s, Real inertia)
const Attribute< Real >::Ptr mOmMech
rotor speed omega_r
Bool mHasTurbineGovernor
Determines if legacy TurbineGovernor is activated.
Real mLlkq2
q-axis damper leakage inductance 2 Llkq2 [H]
std::shared_ptr< Signal::TurbineGovernorType1 > mTurbineGovernorType1
Signal component modelling governor control and steam turbine (TurbineGovernorType1)
const Attribute< Real >::Ptr mInertia
inertia constant H [s] for per unit or moment of inertia J [kg*m^2]
const Attribute< Real >::Ptr mElecTorque
electrical torque
Real mVc
Interface voltage phase c.
Real mLb
Auxiliar inductance.
SynchronGeneratorVBR(String name, String uid, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and logging level.
Real mPsikq1
Magnetizing flux linkage 1st damper winding q axis.
void setBaseAndFundamentalPerUnitParameters(Real nomPower, Real nomVolt, Real nomFreq, Int poleNumber, Real nomFieldCur, Real Rs, Real Ll, Real Lmd, Real Lmq, Real Rfd, Real Llfd, Real Rkd, Real Llkd, Real Rkq1, Real Llkq1, Real Rkq2, Real Llkq2, Real inertia)
Initializes the base and fundamental machine parameters in per unit.
Real mIa
Interface curent phase a.
MatrixFixedSize< 2, 2 > K1K2
Real mPsimd
Magnetizing flux linkage in d axis.
Real mVq
Interface voltage q component.
Real mV0
Interface voltage 0 component.
Matrix mConductanceMat
Equivalent Stator Conductance Matrix.
void initialize(Matrix frequencies) override
Initialize components with correct network frequencies.
Real mVa
Interface voltage phase a.
void setBaseAndOperationalPerUnitParameters(Real nomPower, Real nomVolt, Real nomFreq, Int poleNumber, Real nomFieldCur, Real Rs, Real Ld, Real Lq, Real Ld_t, Real Lq_t, Real Ld_s, Real Lq_s, Real Ll, Real Td0_t, Real Tq0_t, Real Td0_s, Real Tq0_s, Real inertia)
Real mDLmq
q dynamic inductance
void CalculateAuxiliarConstants(Real dt)
Real mLa
Auxiliar inductance.
MatrixFixedSize< 3, 3 > R_eq_vbr
Equivalent VBR Stator Resistance.
Matrix mIabc
Phase currents in pu.
Matrix mDInductanceMat
inductance matrix
void mnaCompAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
Add MNA pre step dependencies.
Real c21_omega
Auxiliar variables.
Real mId_hist
D axis stator current of from last time step.
Matrix mDVabc
Subtransient voltage in pu.
void mnaCompPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA post step operations.
MatrixFixedSize< 2, 2 > K2a
MatrixFixedSize< 3, 3 > mKrs_teta
Park Transformation Matrix.
Real mPsikd
Magnetizing flux linkage damper winding d axis.
Matrix E_eq_vbr
Equivalent VBR Stator Voltage Source.
Real mPsifd
Magnetizing flux linkage excitation.
void mnaCompPreStep(Real time, Int timeStepCount) override
MNA pre step operations.
Real mIq
Interface current q component.
void CalculateAuxiliarVariables()
MatrixFixedSize< 2, 2 > F2
Real mIq_hist
Q axis stator current of from last time step.
Matrix inverseParkTransform(Real theta, Real q, Real d, Real zero)
Inverse Park transform as described in Krause.
Real mDVa
Dynamic voltage phase a.
MatrixFixedSize< 2, 2 > E2b
Real mDVq
Dynamic d voltage.
Matrix mDVqd
Dynamic Voltage Vector.
MatrixFixedSize< 3, 3 > mKrs_teta_inv
Inverse Park Transformation Matrix.
MatrixFixedSize< 2, 2 > F2b
Real mIc
Interface curent phase c.
Matrix mVabc
Phase Voltages in pu.
MatrixFixedSize< 2, 2 > Fa
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
Initializes internal variables of the component.
Matrix mDqStatorCurrents
Dq stator current vector.
Matrix mPsikq1kq2
Q axis Rotor flux.
Real mVb
Interface voltage phase b.
Real mDLmd
d dynamic inductance
Real mPsimq
Magnetizing flux linkage in q axis.
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override
Stamps right side (source) vector.
Matrix mISourceEq
Equivalent Stator Current Source.
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
Matrix parkTransform(Real theta, Real a, Real b, Real c)
Park transform as described in Krause.
MatrixFixedSize< 3, 3 > K
Real mPsikq2
Magnetizing flux linkage 2nd damper winding q axis.
void setInitialValues(Real initActivePower, Real initReactivePower, Real initTerminalVolt, Real initVoltAngle, Real initMechPower)
Initialize states according to desired initial electrical powerflow and mechanical input power.
Real mId
Interface current d component.
Real mDVb
Dynamic voltage phase b.
Real mI0
Interface current 0 component.
MatrixFixedSize< 2, 2 > E2
Real mDVd
Dynamic q voltage.
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override
Stamps system matrix.
Real mDVc
Dynamic voltage phase c.
Real mIb
Interface curent phase b.
MatrixFixedSize< 2, 2 > K1a
Real mVfd
Voltage excitation.
Real c11
Auxiliar constants.
void initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
MatrixFixedSize< 2, 2 > Ea
Matrix mPsifdkd
D axis rotor flux.
void CalculateL()
Calculate inductance Matrix L and its derivative.
Real mVd
Interface voltage d component.
String uid()
Returns unique id.
AttributeList::Ptr mAttributes
Attribute List.
spdlog::level::level_enum Level
static String complexToString(const Complex &num)
static String phasorToString(const Complex &num)
MNASimPowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
Attribute< Matrix >::Ptr mRightVector
static void stamp3x3ConductanceMatrixNodeToGround(const Matrix &conductanceMat, SparseMatrixRow &mat, UInt nodeIndex, const Logger::Log &mSLog)
std::vector< std::pair< UInt, UInt > > mVariableSystemMatrixEntries
static Real realFromVectorElement(const Matrix &mat, Matrix::Index row)
static void setVectorElement(Matrix &mat, Matrix::Index row, Complex value, Int maxFreq=1, Int freqIdx=0, Matrix::Index colOffset=0)
static Real phase(Complex value)
static Real abs(Complex value)
UInt matrixNodeIndex(UInt nodeIndex)
const Attribute< MatrixVar< Real > >::Ptr mIntfCurrent
virtual void initialize(Matrix frequencies)
Initialize components with correct network frequencies.
SimTerminal< Real >::Ptr terminal(UInt index)
const Attribute< MatrixVar< Real > >::Ptr mIntfVoltage
Bool terminalNotGrounded(UInt index)
Complex initialSingleVoltage(UInt index)
void updateMatrixNodeIndices()
void setTerminalNumber(UInt num)
Logger::Log mSLog
Component logger.
#define RMS3PH_TO_PEAK1PH
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > Matrix
Dense matrix for real numbers.
Eigen::Matrix< Real, rows, cols, Eigen::ColMajor > MatrixFixedSize
Dense matrix for real numbers with fixed dimension.
Eigen::SparseMatrix< Real, Eigen::RowMajor > SparseMatrixRow
Sparse matrix for real numbers (row major).