9 #include <dpsim-models/DP/DP_Ph3_SynchronGeneratorDQ.h>
19 Logger::Level logLevel)
21 Base::SynchronGenerator(mAttributes) {
22 mPhaseType = PhaseType::ABC;
29 Logger::Level logLevel)
32 DP::Ph3::SynchronGeneratorDQ::~SynchronGeneratorDQ() {}
35 Real nomPower, Real nomVolt, Real nomFreq, Int poleNumber, Real nomFieldCur,
36 Real Rs, Real Ll, Real Lmd, Real Lmq, Real Rfd, Real Llfd, Real Rkd,
37 Real Llkd, Real Rkq1, Real Llkq1, Real Rkq2, Real Llkq2, Real inertia,
38 Real initActivePower, Real initReactivePower, Real initTerminalVolt,
39 Real initVoltAngle, Real initMechPower) {
42 nomPower, nomVolt, nomFreq, nomFieldCur, poleNumber, Rs, Ll, Lmd, Lmq,
43 Rfd, Llfd, Rkd, Llkd, Rkq1, Llkq1, Rkq2, Llkq2, inertia);
44 Base::SynchronGenerator::setInitialValues(initActivePower, initReactivePower,
45 initTerminalVolt, initVoltAngle,
51 mSystemOmega = frequencies(0, 0);
54 mCompensationOn =
false;
55 mCompensationCurrent = MatrixComp::Zero(3, 1);
57 mRcomp = mRcomp * mBase_Z;
61 calcStateSpaceMatrixDQ();
66 mVdq0 = Matrix::Zero(3, 1);
67 mIdq0 = Matrix::Zero(3, 1);
68 if (mNumDampingWindings == 2) {
69 mVdq0 << mVsr(0, 0), mVsr(3, 0), mVsr(6, 0);
70 mIdq0 << mIsr(0, 0), mIsr(3, 0), mIsr(6, 0);
72 mVdq0 << mVsr(0, 0), mVsr(3, 0), mVsr(5, 0);
73 mIdq0 << mIsr(0, 0), mIsr(3, 0), mIsr(5, 0);
76 **mIntfVoltage = mBase_V * dq0ToAbcTransform(mThetaMech, mVdq0);
77 **mIntfCurrent = mBase_I * dq0ToAbcTransform(mThetaMech, mIdq0);
80 void DP::Ph3::SynchronGeneratorDQ::mnaCompApplySystemMatrixStamp(
81 SparseMatrixRow &systemMatrix) {
85 Real conductance = 1. / mRcomp;
87 if (terminalNotGrounded(0)) {
88 Math::addToMatrixElement(systemMatrix, matrixNodeIndices(0)[0],
89 matrixNodeIndices(0)[0], Complex(conductance, 0));
90 Math::addToMatrixElement(systemMatrix, matrixNodeIndices(0)[1],
91 matrixNodeIndices(0)[1], Complex(conductance, 0));
92 Math::addToMatrixElement(systemMatrix, matrixNodeIndices(0)[2],
93 matrixNodeIndices(0)[2], Complex(conductance, 0));
94 SPDLOG_LOGGER_INFO(mSLog,
"Add {} to {}, {}", conductance,
95 matrixNodeIndices(0)[0], matrixNodeIndices(0)[0]);
96 SPDLOG_LOGGER_INFO(mSLog,
"Add {} to {}, {}", conductance,
97 matrixNodeIndices(0)[1], matrixNodeIndices(0)[1]);
98 SPDLOG_LOGGER_INFO(mSLog,
"Add {} to {}, {}", conductance,
99 matrixNodeIndices(0)[2], matrixNodeIndices(0)[2]);
103 void DP::Ph3::SynchronGeneratorDQ::mnaCompApplyRightSideVectorStamp(
104 Matrix &rightVector) {
106 mCompensationCurrent = **mIntfVoltage / mRcomp;
111 if (terminalNotGrounded(0)) {
112 Math::setVectorElement(rightVector, matrixNodeIndex(0, 0),
113 -(**mIntfCurrent)(0, 0) +
114 mCompensationCurrent(0, 0));
115 Math::setVectorElement(rightVector, matrixNodeIndex(0, 1),
116 -(**mIntfCurrent)(1, 0) +
117 mCompensationCurrent(1, 0));
118 Math::setVectorElement(rightVector, matrixNodeIndex(0, 2),
119 -(**mIntfCurrent)(2, 0) +
120 mCompensationCurrent(2, 0));
125 const Matrix &leftVector) {
126 (**mIntfVoltage)(0, 0) =
127 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0, 0));
128 (**mIntfVoltage)(1, 0) =
129 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0, 1));
130 (**mIntfVoltage)(2, 0) =
131 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0, 2));
135 AttributeBase::List &prevStepDependencies,
136 AttributeBase::List &attributeDependencies,
137 AttributeBase::List &modifiedAttributes,
139 attributeDependencies.push_back(leftVector);
140 modifiedAttributes.push_back(mIntfVoltage);
143 void DP::Ph3::SynchronGeneratorDQ::mnaCompPostStep(
145 mnaCompUpdateVoltage(**leftVector);
148 Real DP::Ph3::SynchronGeneratorDQ::electricalTorque()
const {
149 return **mElecTorque * mBase_T;
152 Real DP::Ph3::SynchronGeneratorDQ::rotationalSpeed()
const {
153 return **mOmMech * mBase_OmMech;
156 Real DP::Ph3::SynchronGeneratorDQ::rotorPosition()
const {
return mThetaMech; }
159 MatrixComp &abcVector) {
161 Complex alpha(cos(2. / 3. * PI), sin(2. / 3. * PI));
162 Complex thetaCompInv(cos(-theta), sin(-theta));
164 MatrixComp abcToPnz(3, 3);
165 abcToPnz << 1, 1, 1, 1, alpha, pow(alpha, 2), 1, pow(alpha, 2), alpha;
166 abcToPnz = (1. / 3.) * abcToPnz;
168 MatrixComp pnzVector(3, 1);
169 pnzVector = abcToPnz * abcVector * thetaCompInv;
171 Matrix dq0Vector(3, 1);
172 dq0Vector << pnzVector(1, 0).real(), pnzVector(1, 0).imag(), 0;
180 Complex alpha(cos(2. / 3. * PI), sin(2. / 3. * PI));
181 Complex thetaComp(cos(theta), sin(theta));
183 MatrixComp pnzToAbc(3, 3);
184 pnzToAbc << 1, 1, 1, 1, pow(alpha, 2), alpha, 1, alpha, pow(alpha, 2);
186 MatrixComp pnzVector(3, 1);
188 pnzVector << 0, Complex(dq0(0, 0), dq0(1, 0)), 0;
190 MatrixComp abcCompVector(3, 1);
191 abcCompVector = pnzToAbc * pnzVector * thetaComp;
193 return abcCompVector;
225 void DP::Ph3::SynchronGeneratorDQ::trapezoidalCurrentStates() {
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.
Synchronous generator model in dq-reference frame.
void initialize(Real omega, Real timeStep)
SynchronGeneratorDQ(String name, String uid, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and logging level.
void trapezoidalFluxStates()
calculate flux states using trapezoidal rule - depcrecated
virtual void mnaCompUpdateVoltage(const Matrix &leftVector) override
Retrieves calculated voltage from simulation for next step.
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
Matrix abcToDq0Transform(Real theta, MatrixComp &abc)
Park transform as described in Krause.
void setParametersFundamentalPerUnit(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, Real initActivePower, Real initReactivePower, Real initTerminalVolt, Real initVoltAngle, Real initMechPower)
MatrixComp dq0ToAbcTransform(Real theta, Matrix &dq0)
Inverse Park transform as described in Krause.
Base class for all MNA components that are transmitting power.
virtual void initialize(Matrix frequencies)
Initialize components with correct network frequencies.
const Attribute< MatrixVar< Complex > >::Ptr mIntfCurrent
Current through component.
const Attribute< MatrixVar< Complex > >::Ptr mIntfVoltage
Voltage between terminals.