14 Bool withResistiveLosses)
17 mSeriesResistanceHalf(
Matrix::Zero(3, 3)),
18 mSeriesInductanceHalf(
Matrix::Zero(3, 3)),
19 mMagnetizingResistance(
Matrix::Zero(3, 3)),
20 mMagnetizingInductance(
Matrix::Zero(3, 3)),
21 mWithResistiveLosses(withResistiveLosses) {
22 const Matrix zero = Matrix::Zero(6, 6);
33 copy->setMagnetizingBranch(mNoLoadCurrent, mNoLoadLoss);
34 copy->setReferenceWinding(mReferenceWinding);
39 Real nomVoltagePrimary,
Real nomVoltageSecondary,
Real ratedPower,
41 if (resistance.rows() != 3 || resistance.cols() != 3 ||
42 inductance.rows() != 3 || inductance.cols() != 3)
43 throw std::invalid_argument(
"Transformer matrices must be 3 x 3.");
45 ratedPower, ratioAbs, ratioPhase,
46 resistance, inductance);
47 const Matrix zero = Matrix::Zero(6, 6);
53 if (!std::isfinite(noLoadCurrent) || !std::isfinite(noLoadLoss) ||
54 noLoadCurrent <= noLoadLoss || noLoadLoss <= 0.)
55 throw std::invalid_argument(
"Invalid transformer magnetizing branch.");
56 mNoLoadCurrent = noLoadCurrent;
57 mNoLoadLoss = noLoadLoss;
63 throw std::invalid_argument(
"Three-winding transformers are unsupported.");
64 mReferenceWinding = referenceWinding;
67void DP::Ph3::SSN::Transformer::resolveWindingRoles() {
68 switch (mReferenceWinding) {
70 mReferenceTerminal = 0;
73 mReferenceTerminal = 1;
76 throw std::invalid_argument(
"Three-winding transformers are unsupported.");
79 (mNominalVoltagePrimary >= mNominalVoltageSecondary) ? 0 : 1;
83 (mReferenceTerminal == 0) ? effectiveRatio() : 1. / effectiveRatio();
89 throw std::invalid_argument(
"Frequency must be positive.");
90 resolveWindingRoles();
91 const Real omega = 2. *
PI * frequency;
92 const Real magnetizingSusceptance =
93 std::sqrt(mNoLoadCurrent * mNoLoadCurrent - mNoLoadLoss * mNoLoadLoss) *
95 const Real magnetizingInductance = 1. / (omega * magnetizingSusceptance);
96 const Real magnetizingResistance =
99 mMagnetizingInductance =
101 mMagnetizingResistance =
105 mSeriesResistanceHalf.setZero();
106 if (mWithResistiveLosses)
111 Matrix mass = Matrix::Zero(6, 6);
112 Matrix resistance = Matrix::Zero(6, 6);
113 mass.block<3, 3>(0, 0) = mSeriesInductanceHalf + mMagnetizingInductance;
114 mass.block<3, 3>(0, 3) = mMagnetizingInductance;
115 mass.block<3, 3>(3, 0) = mMagnetizingInductance;
116 mass.block<3, 3>(3, 3) = mSeriesInductanceHalf + mMagnetizingInductance;
117 resistance.block<3, 3>(0, 0) = mSeriesResistanceHalf + mMagnetizingResistance;
118 resistance.block<3, 3>(0, 3) = mMagnetizingResistance;
119 resistance.block<3, 3>(3, 0) = mMagnetizingResistance;
120 resistance.block<3, 3>(3, 3) = mSeriesResistanceHalf + mMagnetizingResistance;
122 const Matrix inverseMass = mass.inverse();
123 const Matrix identity = Matrix::Identity(3, 3);
125 mInputTransform.setZero();
126 mOutputTransform.setZero();
127 if (mReferenceTerminal == 0) {
128 mInputTransform.block<3, 3>(0, 0) = identityComp;
129 mInputTransform.block<3, 3>(3, 3) = mRatioFromReference * identityComp;
130 mOutputTransform.block<3, 3>(0, 0) = identityComp;
131 mOutputTransform.block<3, 3>(3, 3) =
132 std::conj(mRatioFromReference) * identityComp;
134 mInputTransform.block<3, 3>(0, 3) = identityComp;
135 mInputTransform.block<3, 3>(3, 0) = mRatioFromReference * identityComp;
136 mOutputTransform.block<3, 3>(0, 3) =
137 std::conj(mRatioFromReference) * identityComp;
138 mOutputTransform.block<3, 3>(3, 0) = identityComp;
142 Matrix::Identity(6, 6), Matrix::Zero(6, 6));
156 return mOutputTransform *
mC.cast<
Complex>() * stateAndInput;
174 return mOutputTransform *
MultiPortVTypeSSNComp(String uid, String name, Logger::Level logLevel=Logger::Level::off)
virtual MatrixComp calculateSteadyStateStateFromInput(const MatrixComp &u, Real omega) const
Steady-state envelope state X_ss = (j w I - A)^-1 B u.
MatrixComp mHistoryState
Reused workspaces for the per-step history calculation.
virtual void recomputeDiscreteModel(Real omega)
Discretize the augmented model and fold it into complex dA, dB, W.
MatrixComp mW
Complex Norton matrix W = C dB + D + (2 / dt + j omega) D1.
void setParameters(const Matrix &A, const Matrix &B, const Matrix &C, const Matrix &D, const Matrix &D1=Matrix())
MatrixComp mDiscreteA
Complex envelope discrete operators (folded from the augmented model).
virtual MatrixComp calculateSteadyStateOutputFromInput(const MatrixComp &x, const MatrixComp &u) const
Attribute< MatrixComp >::Ptr inputAttribute() const override final
void initializeFromNodesAndTerminals(Real frequency) override
Initializes Component variables according to power flow data stored in Nodes.
String uid()
Returns unique id.
AttributeList::Ptr mAttributes
Attribute List.
spdlog::level::level_enum Level
static Matrix singlePhaseParameterToThreePhase(Real parameter)
To convert single phase parameters to symmetrical three phase ones.
std::shared_ptr< SimPowerComp< VarType > > Ptr
Logger::Level mLogLevel
Component logger control for internal variables.
static std::shared_ptr< T > make(Args &&...args)
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.