10 Bool withResistiveLosses)
14 mWithResistiveLosses = withResistiveLosses;
15 if (withResistiveLosses)
21 SPDLOG_LOGGER_INFO(
mSLog,
"Create {} {}", this->
type(), name);
36 Real nomVoltageSecondary,
41 ratedPower, ratioAbs, ratioPhase,
42 resistance, inductance);
46void SP::Ph3::Transformer::resolveWindingRoles() {
47 switch (mReferenceWinding) {
49 mReferenceTerminal = 0;
52 mReferenceTerminal = 1;
55 SPDLOG_LOGGER_ERROR(mSLog,
56 "Transformer {}: three-winding transformers are "
62 (mNominalVoltagePrimary >= mNominalVoltageSecondary) ? 0 : 1;
67 (mReferenceTerminal == 0) ? effectiveRatio() : 1. / effectiveRatio();
68 mOrientationSign = (mReferenceTerminal == 0) ? 1. : -1.;
72 "Impedance referred to winding {} ({} [V]), remaining winding "
73 "at terminal {} ({} [V]), ratio = {}",
74 mReferenceTerminal + 1, nominalVoltageAt(mReferenceTerminal),
75 nonReferenceTerminal(), nominalVoltageAt(nonReferenceTerminal()),
79void SP::Ph3::Transformer::createSubComponents() {
82 mSubCompCreated =
true;
84 resolveWindingRoles();
86 auto midpoint = mVirtualNodes[2];
89 std::make_shared<SP::Ph3::Inductor>(**mName +
"_ind", mLogLevel);
90 mSubInductor->setParameters(mInductance / 2.);
95 std::make_shared<SP::Ph3::Inductor>(**mName +
"_ind2", mLogLevel);
96 mSubInductor2->setParameters(mInductance / 2.);
100 if (mNumVirtualNodes == 5) {
102 std::make_shared<SP::Ph3::Resistor>(**mName +
"_res", mLogLevel);
103 mSubResistor->setParameters(mResistance / 2.);
104 mSubResistor->connect({node(mReferenceTerminal), mVirtualNodes[3]});
105 mSubInductor->connect({mVirtualNodes[3], midpoint});
110 std::make_shared<SP::Ph3::Resistor>(**mName +
"_res2", mLogLevel);
111 mSubResistor2->setParameters(mResistance / 2.);
112 mSubResistor2->connect({midpoint, mVirtualNodes[4]});
113 mSubInductor2->connect({mVirtualNodes[4], mVirtualNodes[0]});
114 addMNASubComponent(mSubResistor2,
118 mSubInductor->connect({node(mReferenceTerminal), midpoint});
119 mSubInductor2->connect({midpoint, mVirtualNodes[0]});
122 if (mRatedPower <= 0) {
123 SPDLOG_LOGGER_WARN(mSLog,
124 "Transformer {}: rated power is {} [VA], so the "
125 "magnetizing branch cannot be sized and is omitted",
126 this->name(), mRatedPower);
130 if (mNoLoadCurrent <= mNoLoadLoss) {
131 SPDLOG_LOGGER_ERROR(mSLog,
132 "Transformer {}: no-load current {} must exceed the "
134 this->name(), mNoLoadCurrent, mNoLoadLoss);
135 throw InvalidArgumentException();
138 Real magnetizingResistance =
139 std::pow(nominalVoltageAt(mReferenceTerminal), 2) /
140 (mNoLoadLoss * mRatedPower);
141 mMagnetizingResistance =
143 mSubMagnetizingResistor =
144 std::make_shared<SP::Ph3::Resistor>(**mName +
"_mag_res", mLogLevel);
145 mSubMagnetizingResistor->setParameters(mMagnetizingResistance);
147 addMNASubComponent(mSubMagnetizingResistor,
151 mSubMagnetizingInductor =
152 std::make_shared<SP::Ph3::Inductor>(**mName +
"_mag_ind", mLogLevel);
154 addMNASubComponent(mSubMagnetizingInductor,
161 Real omega = 2. *
PI * frequency;
163 if (mSubMagnetizingInductor) {
164 Real magnetizingSusceptance =
165 std::sqrt(std::pow(mNoLoadCurrent, 2) - std::pow(mNoLoadLoss, 2)) *
167 Real magnetizingInductance = 1. / (omega * magnetizingSusceptance);
168 mMagnetizingInductance =
170 mSubMagnetizingInductor->setParameters(mMagnetizingInductance);
174 mVirtualNodes[0]->setInitialVoltage(secondaryVoltage * mRatioFromReference);
187 MatrixComp impedance = MatrixComp::Zero(3, 3);
188 for (
UInt row = 0; row < 3; row++)
189 for (
UInt col = 0; col < 3; col++)
190 impedance(row, col) =
196 **
mIntfCurrent = impedance.inverse() * impedanceVoltage;
202 for (
UInt phase = 0; phase < 3; phase++) {
216 for (
UInt phase = 0; phase < 3; phase++) {
220 std::conj(mRatioFromReference));
247 attributeDependencies.push_back(leftVector);
259 (**mIntfVoltage).setZero();
260 for (
UInt phase = 0; phase < 3; phase++) {
262 (**mIntfVoltage)(phase, 0) =
265 (**mIntfVoltage)(phase, 0) =
272 **
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).