17 Matrix dqvector = Tdq * fabc;
25 Matrix Tdq = Matrix::Zero(2, 3);
26 Real k = sqrt(2. / 3.);
27 Tdq << k * cos(theta), k * cos(theta - 2. *
M_PI / 3.),
28 k * cos(theta + 2. *
M_PI / 3.), -k * sin(theta),
29 -k * sin(theta - 2. *
M_PI / 3.), -k * sin(theta + 2. *
M_PI / 3.);
85 SPDLOG_LOGGER_INFO(
mSLog,
86 "\n--- Parameters ---"
107 SPDLOG_LOGGER_INFO(
mSLog,
108 "\n--- Parameters ---"
110 "\ninductance: {:f}",
136 SPDLOG_LOGGER_INFO(
mSLog,
137 "\n--- Parameters ---"
139 "\ninductance: {:f}",
166 MatrixComp intfVoltageComplex = MatrixComp::Zero(3, 1);
167 MatrixComp intfCurrentComplex = MatrixComp::Zero(3, 1);
173 intfCurrentComplex(0, 0) =
185 **
mEp = intfVoltageComplex(0, 0) +
mImpedance * intfCurrentComplex(0, 0);
194 (3. / 2. * intfVoltageComplex(0, 0) * std::conj(intfCurrentComplex(0, 0)))
205 for (
UInt phase = 0; phase < 3; ++phase)
211 SPDLOG_LOGGER_INFO(
mSLog,
212 "\n--- Initialize according to powerflow ---"
213 "\nTerminal 0 voltage: {:e}<{:e}"
214 "\nVoltage behind reactance: {:e}<{:e}"
215 "\ninitial electrical power: {:e}+j{:e}"
216 "\nactive electrical power: {:e}"
217 "\nmechanical power: {:e}"
218 "\n--- End of powerflow initialization ---",
232 intfVoltageDQ(1, 0) * intfCurrentDQ(1, 0);
264 const Real denominator = 2. *
mLpd + **
mRs * timeStep;
271 for (
UInt phase = 0; phase < 3; ++phase)
279 for (
UInt phase = 0; phase < 3; ++phase)
301 attributeDependencies.push_back(leftVector);
311 for (
UInt phase = 0; phase < 3; ++phase)
317 const Matrix sourceInjection =
319 **
mRightVector = Matrix::Zero((**mRightVector).rows(), 1);
320 for (
UInt phase = 0; phase < 3; ++phase)
322 sourceInjection(phase, 0));
332 const Matrix &leftVector) {
334 (**mIntfVoltage)(0, 0) =
336 (**mIntfVoltage)(1, 0) =
338 (**mIntfVoltage)(2, 0) =
343 const Matrix &leftVector) {
AttributePointer< Attribute< T > > Ptr
Real mNomFreq
nominal frequency fn [Hz]
Real mTimeStep
Simulation time step.
Real mLmd
d-axis mutual inductance Lmd [H]
SynchronGenerator(CPS::AttributeList::Ptr attributeList)
Constructor.
Real mLlfd
field leakage inductance Llfd [H]
const Attribute< Real >::Ptr mMechPower
mechanical Power Pm [W]
Real mNomVolt
nominal voltage Vn [V] (phase-to-phase RMS)
Real mBase_L
base stator inductance
Real mBase_Z
base stator impedance
const Attribute< Real >::Ptr mRs
stator resistance Rs [Ohm]
const Attribute< Real >::Ptr mElecActivePower
Active part of the electrical power.
ParameterType mParameterType
StateType mStateType
specifies if the machine parameters are transformed to per unit
Real mNomOmega
nominal angular frequency wn [Hz]
const Attribute< Real >::Ptr mLl
leakage inductance Ll [H]
void setBaseParameters(Real nomPower, Real nomVolt, Real nomFreq)
Real mLfd
field inductance Lfd [H]
const Attribute< Real >::Ptr mLd
d-axis inductance Ld [H]
Real mNomPower
nominal power Pn [VA]
const Attribute< Real >::Ptr mOmMech
rotor speed omega_r
Real calcHfromJ(Real J, Real omegaNominal, Int polePairNumber)
const Attribute< Real >::Ptr mInertia
inertia constant H [s] for per unit or moment of inertia J [kg*m^2]
CompositePowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
void setStandardParametersPU(Real nomPower, Real nomVolt, Real nomFreq, Real Xpd, Real inertia, Real Rs=0, Real D=0)
Initializes the machine parameters.
void mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
const Attribute< Matrix >::Ptr mStatorVoltagePrevious
Stator R-L branch Norton companion state.
void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
void mnaParentInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
Initializes variables of component.
Real mThetaN
Nominal system angle.
void setStandardParametersSI(Real nomPower, Real nomVolt, Real nomFreq, Int polePairNumber, Real Rs, Real Lpd, Real inertiaJ, Real Kd=0)
Initializes the machine parameters.
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Real mKd
Absolute damping coefficient.
SimPowerComp< Real >::Ptr clone(String name) override
Returns a modified copy of the component with the given suffix added to the name and without.
void mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
Retrieves calculated voltage from simulation for next step.
Matrix mStatorConductance
SynchronGeneratorTrStab(String uid, String name, Logger::Level logLevel=Logger::Level::off)
void mnaParentApplyRightSideVectorStamp(Matrix &rightVector) override
const Attribute< Matrix >::Ptr mStatorHistoryCurrent
Matrix getParkTransformMatrixPowerInvariant(Real theta)
const Attribute< Real >::Ptr mRefDelta
const Attribute< Complex >::Ptr mEp
True after createSubComponents() runs; prevents double-construction.
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Matrix parkTransformPowerInvariant(Real theta, const Matrix &fabc)
void mnaParentPreStep(Real time, Int timeStepCount) override
Complex mImpedance
Equivalent impedance for loadflow calculation.
void initializeParentFromNodesAndTerminals(Real frequency) override
void mnaParentApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override
Stamp the stator R-L Norton conductance and history current.
const Attribute< Real >::Ptr mEp_abs
const Attribute< Real >::Ptr mDelta_p
Angle by which the emf Ep is leading the terminal voltage.
void setInitialValues(Complex elecPower, Real mechPower)
void createSubComponents() override
Constructs and registers MNA subcomponents without emf value; idempotent.
void setFundamentalParametersPU(Real nomPower, Real nomVolt, Real nomFreq, Real Ll, Real Lmd, Real Llfd, Real inertia, Real D=0)
Initializes the machine parameters.
Real mLpd
Absolute d-axis transient inductance.
const Attribute< Matrix >::Ptr mStatorSourceVoltage
const Attribute< Real >::Ptr mRefOmega
const Attribute< Real >::Ptr mEp_phase
Real mXpd
Absolute d-axis transient reactance X'd.
String uid()
Returns unique id.
AttributeList::Ptr mAttributes
Attribute List.
spdlog::level::level_enum Level
Attribute< Matrix >::Ptr mRightVector
static Real realFromVectorElement(const Matrix &mat, Matrix::Index row)
static void addToVectorElement(Matrix &mat, Matrix::Index row, Complex value, Int maxFreq=1, Int freqIdx=0)
static Real phaseDeg(Complex value)
static Real phase(Complex value)
static Real abs(Complex value)
static void addToMatrixElement(SparseMatrixRow &mat, Matrix::Index row, Matrix::Index column, Complex value, Int maxFreq=1, Int freqIdx=0)
static MatrixComp singlePhaseVariableToThreePhase(Complex var_1ph)
To convert single phase complex variables (voltages, currents) to symmetrical three phase ones.
UInt matrixNodeIndex(UInt nodeIndex)
const Attribute< MatrixVar< Real > >::Ptr mIntfCurrent
SimTerminal< Real >::Ptr terminal(UInt index)
void setVirtualNodeNumber(UInt num)
const Attribute< MatrixVar< Real > >::Ptr mIntfVoltage
std::shared_ptr< SimPowerComp< VarType > > Ptr
Complex initialSingleVoltage(UInt index)
void setTerminalNumber(UInt num)
Logger::Level mLogLevel
Component logger control for internal variables.
Logger::Log mSLog
Component logger.
static std::shared_ptr< SynchronGeneratorTrStab > make(Args &&...args)
#define RMS3PH_TO_PEAK1PH
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > Matrix
Dense matrix for real numbers.
std::complex< Real > Complex
Eigen::Matrix< Complex, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > MatrixComp
Dense matrix for complex numbers.
Eigen::SparseMatrix< Real, Eigen::RowMajor > SparseMatrixRow
Sparse matrix for real numbers (row major).