10 Bool withResistiveLosses)
14 mWithResistiveLosses = withResistiveLosses;
15 if (withResistiveLosses)
21 SPDLOG_LOGGER_INFO(
mSLog,
"Create {} {}", this->
type(), name);
35 Real nomVoltageSecondary,
40 ratedPower, ratioAbs, ratioPhase,
41 resistance, inductance);
45void SP::Ph3::Transformer::resolveWindingRoles() {
46 switch (mReferenceWinding) {
48 mReferenceTerminal = 0;
51 mReferenceTerminal = 1;
54 SPDLOG_LOGGER_ERROR(mSLog,
55 "Transformer {}: three-winding transformers are "
61 (mNominalVoltagePrimary >= mNominalVoltageSecondary) ? 0 : 1;
65 mRatioFromReference = (mReferenceTerminal == 0) ? **mRatio : 1. / **mRatio;
66 mOrientationSign = (mReferenceTerminal == 0) ? 1. : -1.;
70 "Impedance referred to winding {} ({} [V]), remaining winding "
71 "at terminal {} ({} [V]), ratio = {}",
72 mReferenceTerminal + 1, nominalVoltageAt(mReferenceTerminal),
73 nonReferenceTerminal(), nominalVoltageAt(nonReferenceTerminal()),
77void SP::Ph3::Transformer::createSubComponents() {
80 mSubCompCreated =
true;
82 resolveWindingRoles();
84 auto midpoint = mVirtualNodes[2];
87 std::make_shared<SP::Ph3::Inductor>(**mName +
"_ind", mLogLevel);
88 mSubInductor->setParameters(mInductance / 2.);
93 std::make_shared<SP::Ph3::Inductor>(**mName +
"_ind2", mLogLevel);
94 mSubInductor2->setParameters(mInductance / 2.);
98 if (mNumVirtualNodes == 5) {
100 std::make_shared<SP::Ph3::Resistor>(**mName +
"_res", mLogLevel);
101 mSubResistor->setParameters(mResistance / 2.);
102 mSubResistor->connect({node(mReferenceTerminal), mVirtualNodes[3]});
103 mSubInductor->connect({mVirtualNodes[3], midpoint});
108 std::make_shared<SP::Ph3::Resistor>(**mName +
"_res2", mLogLevel);
109 mSubResistor2->setParameters(mResistance / 2.);
110 mSubResistor2->connect({midpoint, mVirtualNodes[4]});
111 mSubInductor2->connect({mVirtualNodes[4], mVirtualNodes[0]});
112 addMNASubComponent(mSubResistor2,
116 mSubInductor->connect({node(mReferenceTerminal), midpoint});
117 mSubInductor2->connect({midpoint, mVirtualNodes[0]});
120 if (mRatedPower <= 0) {
121 SPDLOG_LOGGER_WARN(mSLog,
122 "Transformer {}: rated power is {} [VA], so the "
123 "magnetizing branch cannot be sized and is omitted",
124 this->name(), mRatedPower);
128 if (mNoLoadCurrent <= mNoLoadLoss) {
129 SPDLOG_LOGGER_ERROR(mSLog,
130 "Transformer {}: no-load current {} must exceed the "
132 this->name(), mNoLoadCurrent, mNoLoadLoss);
133 throw InvalidArgumentException();
136 Real magnetizingResistance =
137 std::pow(nominalVoltageAt(mReferenceTerminal), 2) /
138 (mNoLoadLoss * mRatedPower);
139 mMagnetizingResistance =
141 mSubMagnetizingResistor =
142 std::make_shared<SP::Ph3::Resistor>(**mName +
"_mag_res", mLogLevel);
143 mSubMagnetizingResistor->setParameters(mMagnetizingResistance);
145 addMNASubComponent(mSubMagnetizingResistor,
149 mSubMagnetizingInductor =
150 std::make_shared<SP::Ph3::Inductor>(**mName +
"_mag_ind", mLogLevel);
152 addMNASubComponent(mSubMagnetizingInductor,
159 Real omega = 2. *
PI * frequency;
161 if (mSubMagnetizingInductor) {
162 Real magnetizingSusceptance =
163 std::sqrt(std::pow(mNoLoadCurrent, 2) - std::pow(mNoLoadLoss, 2)) *
165 Real magnetizingInductance = 1. / (omega * magnetizingSusceptance);
166 mMagnetizingInductance =
168 mSubMagnetizingInductor->setParameters(mMagnetizingInductance);
172 mVirtualNodes[0]->setInitialVoltage(secondaryVoltage * mRatioFromReference);
185 MatrixComp impedance = MatrixComp::Zero(3, 3);
186 for (
UInt row = 0; row < 3; row++)
187 for (
UInt col = 0; col < 3; col++)
188 impedance(row, col) =
194 **
mIntfCurrent = impedance.inverse() * impedanceVoltage;
200 for (
UInt phase = 0; phase < 3; phase++) {
214 for (
UInt phase = 0; phase < 3; phase++) {
218 std::conj(mRatioFromReference));
245 attributeDependencies.push_back(leftVector);
258 for (
UInt phase = 0; phase < 3; phase++) {
260 (**mIntfVoltage)(phase, 0) =
263 (**mIntfVoltage)(phase, 0) =
270 **
mIntfCurrent = mOrientationSign * mSubInductor->intfCurrent();
AttributePointer< Attribute< T > > Ptr
CompositePowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
String uid()
Returns unique id.
String type()
Get component type (cross-platform)
AttributeList::Ptr mAttributes
Attribute List.
spdlog::level::level_enum Level
static String complexToString(const Complex &num)
Attribute< Matrix >::Ptr mRightVector
void mnaApplyRightSideVectorStamp(Matrix &rightVector) final
static Complex complexFromVectorElement(const Matrix &mat, Matrix::Index row, Int maxFreq=1, Int freqIdx=0)
static void setMatrixElement(SparseMatrixRow &mat, Matrix::Index row, Matrix::Index column, Complex value, Int maxFreq=1, Int freqIdx=0)
static Matrix singlePhaseParameterToThreePhase(Real parameter)
To convert single phase parameters to symmetrical three phase ones.
UInt matrixNodeIndex(UInt nodeIndex)
const Attribute< MatrixVar< Complex > >::Ptr mIntfCurrent
void setVirtualNodeNumber(UInt num)
const Attribute< MatrixVar< Complex > >::Ptr mIntfVoltage
MatrixComp initialVoltage(UInt index)
std::shared_ptr< SimPowerComp< VarType > > Ptr
SimNode< Complex >::List mVirtualNodes
Bool terminalNotGrounded(UInt index)
void setTerminalNumber(UInt num)
Logger::Level mLogLevel
Component logger control for internal variables.
UInt mNumVirtualNodes
Determines the number of virtual or internal Nodes.
bool mParametersSet
Flag indicating that parameters are set via setParameters() function.
Logger::Log mSLog
Component logger.
static std::shared_ptr< Transformer > 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.
Eigen::SparseMatrix< Real, Eigen::RowMajor > SparseMatrixRow
Sparse matrix for real numbers (row major).