9 #include <dpsim-models/DP/DP_Ph3_SynchronGeneratorDQTrapez.h>
13 DP::Ph3::SynchronGeneratorDQTrapez::SynchronGeneratorDQTrapez(
14 String uid, String name, Logger::Level logLevel)
15 : SynchronGeneratorDQ(uid, name, logLevel) {}
17 DP::Ph3::SynchronGeneratorDQTrapez::SynchronGeneratorDQTrapez(
18 String name, Logger::Level logLevel)
19 : SynchronGeneratorDQ(name, name, logLevel) {}
21 void DP::Ph3::SynchronGeneratorDQTrapez::mnaCompInitialize(
26 SPDLOG_LOGGER_INFO(
mSLog,
27 "\nFluxStateSpaceMat: \n{}"
28 "\nOmegaFluxMat: \n{}"
29 "\nResistances: {} {} {}",
36 AttributeBase::List &prevStepDependencies,
37 AttributeBase::List &attributeDependencies,
38 AttributeBase::List &modifiedAttributes) {
39 modifiedAttributes.push_back(mRightVector);
40 prevStepDependencies.push_back(mIntfVoltage);
43 void DP::Ph3::SynchronGeneratorDQTrapez::mnaCompPreStep(Real time,
46 mnaCompApplyRightSideVectorStamp(**mRightVector);
49 void DP::Ph3::SynchronGeneratorDQTrapez::setMultisamplingRate(Int rate) {
50 mMultisamplingRate = rate;
56 for (Int i = 0; i < mMultisamplingRate; i++) {
59 mVdq0 = abcToDq0Transform(mThetaMech, **mIntfVoltage);
60 mVdq0 = mVdq0 / mBase_V;
61 mVsr(0, 0) = mVdq0(0, 0);
62 mVsr(3, 0) = mVdq0(1, 0);
63 mVsr(6, 0) = mVdq0(2, 0);
72 if (mHasTurbineGovernor ==
true) {
77 **mElecTorque = (mPsisr(3, 0) * mIsr(0, 0) - mPsisr(0, 0) * mIsr(3, 0));
81 mThetaMech = mThetaMech + mTimeStep * ((**mOmMech - 1) * mBase_OmMech);
84 **mOmMech = **mOmMech + mTimeStep * (1. / (2. * **mInertia) *
85 (**mMechTorque - **mElecTorque));
88 if (mNumericalMethod == NumericalMethod::Euler) {
89 mPsisr = Math::StateSpaceEuler(
91 mBase_OmElec * (mFluxStateSpaceMat + mOmegaFluxMat * **mOmMech),
92 mBase_OmElec * mVsr, mTimeStep / mMultisamplingRate);
94 mPsisr = Math::StateSpaceTrapezoidal(
96 mBase_OmElec * (mFluxStateSpaceMat + mOmegaFluxMat * **mOmMech),
97 mBase_OmElec * mVsr, mTimeStep / mMultisamplingRate);
101 mIsr = mFluxToCurrentMat * mPsisr;
104 mIdq0(0, 0) = mIsr(0, 0);
105 mIdq0(1, 0) = mIsr(3, 0);
106 mIdq0(2, 0) = mIsr(6, 0);
107 **mIntfCurrent = mBase_I * dq0ToAbcTransform(mThetaMech, mIdq0);
Real mTimeStep
Simulation time step.
Matrix mFluxStateSpaceMat
Flux state space matrix excluding omega term.
Matrix mOmegaFluxMat
Omega-flux matrix for state space system.
Matrix mIdq0
dq0 current calculated from terminal current
Matrix mVdq0
dq0 voltage calculated from terminal voltage
void mnaCompAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
Add MNA pre step dependencies.
void stepInPerUnit(Real time)
void updateMatrixNodeIndices()
Update the "cached" mMatrixNodeIndices and mMatrixNodeIndexIsGround members.
Logger::Log mSLog
Component logger.