15 Bool withResistiveLosses)
18 if (withResistiveLosses)
25 SPDLOG_LOGGER_INFO(
mSLog,
"Create {} {}", this->
type(), name);
40 Real nomVoltageSecondary,
45 ratioAbs, ratioPhase, resistance,
49 mSLog,
"Nominal Voltage Primary={} [V] Nominal Voltage Secondary={} [V]",
53 "Resistance={} [Ohm] Inductance={} [Ohm] (referred to primary side)",
55 SPDLOG_LOGGER_INFO(
mSLog,
"Tap Ratio={} [ ] Phase Shift={} [deg]",
63 Real nomVoltageSecondary,
72 ratioAbs, ratioPhase, resistance,
76void DP::Ph1::Transformer::resolveWindingRoles() {
77 switch (mReferenceWinding) {
79 mReferenceTerminal = 0;
82 mReferenceTerminal = 1;
85 SPDLOG_LOGGER_ERROR(mSLog,
86 "Transformer {}: three-winding transformers are "
92 (mNominalVoltagePrimary >= mNominalVoltageSecondary) ? 0 : 1;
96 mRatioFromReference = (mReferenceTerminal == 0) ? **mRatio : 1. / **mRatio;
97 mOrientationSign = (mReferenceTerminal == 0) ? 1. : -1.;
100 std::abs(mNominalVoltagePrimary - mNominalVoltageSecondary) <=
102 SPDLOG_LOGGER_WARN(mSLog,
103 "Transformer {}: both windings are nominally {} [V], so "
104 "the reference winding cannot be resolved from the "
105 "nominal voltages; winding 1 assumed. Pass an explicit "
106 "WindingReference to remove the ambiguity.",
107 this->name(), mNominalVoltagePrimary);
111 "Impedance referred to winding {} ({} [V]) {}, remaining "
112 "winding at terminal {} ({} [V]), ratio = {}",
113 mReferenceTerminal + 1, nominalVoltageAt(mReferenceTerminal),
115 ?
"(resolved from the nominal voltages)"
116 :
"(set explicitly)",
117 nonReferenceTerminal(), nominalVoltageAt(nonReferenceTerminal()),
126 resolveWindingRoles();
137 std::make_shared<DP::Ph1::Inductor>(**
mName +
"_ind2",
mLogLevel);
152 std::make_shared<DP::Ph1::Resistor>(**
mName +
"_res2",
mLogLevel);
160 mSubInductor->connect({
node(mReferenceTerminal), midpoint});
165 SPDLOG_LOGGER_WARN(
mSLog,
166 "Transformer {}: rated power is {} [VA], so the "
167 "magnetizing branch cannot be sized and is omitted",
172 if (mNoLoadCurrent <= mNoLoadLoss) {
173 SPDLOG_LOGGER_ERROR(
mSLog,
174 "Transformer {}: no-load current {} must exceed the "
175 "no-load loss {}; the magnetizing branch has no "
176 "reactive part otherwise",
177 this->
name(), mNoLoadCurrent, mNoLoadLoss);
181 mMagnetizingResistance = std::pow(
nominalVoltageAt(mReferenceTerminal), 2) /
183 mSubMagnetizingResistor =
184 std::make_shared<DP::Ph1::Resistor>(**
mName +
"_mag_res",
mLogLevel);
185 mSubMagnetizingResistor->setParameters(mMagnetizingResistance);
187 SPDLOG_LOGGER_INFO(
mSLog,
188 "Magnetizing resistance = {} [Ohm] at the T midpoint",
194 mSubMagnetizingInductor =
195 std::make_shared<DP::Ph1::Inductor>(**
mName +
"_mag_ind",
mLogLevel);
204 Real omega = 2. *
PI * frequency;
205 if (mSubMagnetizingInductor) {
206 Real magnetizingSusceptance =
207 std::sqrt(std::pow(mNoLoadCurrent, 2) - std::pow(mNoLoadLoss, 2)) *
209 mMagnetizingInductance = 1. / (omega * magnetizingSusceptance);
210 mSubMagnetizingInductor->setParameters(mMagnetizingInductance);
211 SPDLOG_LOGGER_INFO(
mSLog,
"Magnetizing inductance = {} [H]",
222 if (mSubMagnetizingInductor)
223 magnetizingAdmittance = 1. / mMagnetizingResistance +
224 1. /
Complex(0, omega * mMagnetizingInductance);
228 (referenceVoltage +
mVirtualNodes[0]->initialSingleVoltage()) /
229 (2. + halfImpedance * magnetizingAdmittance);
234 (referenceVoltage - midpointVoltage) / halfImpedance;
236 (midpointVoltage -
mVirtualNodes[0]->initialSingleVoltage()) /
241 midpointVoltage - nonReferenceCurrent * **
mResistance / 2.);
246 SPDLOG_LOGGER_INFO(
mSLog,
"Reactance={} [Ohm] (referred to primary side)",
249 mOrientationSign * (
mVirtualNodes[0]->initialSingleVoltage() -
252 (**mIntfCurrent)(0, 0) = impedanceVoltage / impedance;
256 "\n--- Initialization from powerflow ---"
257 "\nVoltage across: {:s}"
259 "\nTerminal 0 voltage: {:s}"
260 "\nTerminal 1 voltage: {:s}"
261 "\nVirtual Node 1 voltage: {:s}"
262 "\n--- Initialization from powerflow finished ---",
274 "\nTerminal 0 connected to {:s} = sim node {:d}"
275 "\nTerminal 1 connected to {:s} = sim node {:d}",
297 -mRatioFromReference);
302 if (
auto mnasubcomp = std::dynamic_pointer_cast<MNAInterface>(subcomp))
303 mnasubcomp->mnaApplySystemMatrixStamp(systemMatrix);
306 SPDLOG_LOGGER_INFO(
mSLog,
"Add {:s} to system at ({:d},{:d})",
310 SPDLOG_LOGGER_INFO(
mSLog,
"Add {:s} to system at ({:d},{:d})",
316 SPDLOG_LOGGER_INFO(
mSLog,
"Add {:s} to system at ({:d},{:d})",
320 SPDLOG_LOGGER_INFO(
mSLog,
"Add {:s} to system at ({:d},{:d})",
345 attributeDependencies.push_back(leftVector);
357 (**mIntfCurrent)(0, 0) = mOrientationSign * mSubInductor->intfCurrent()(0, 0);
362 (**mIntfVoltage)(0, 0) = 0;
364 (**mIntfVoltage)(0, 0) =
367 (**mIntfVoltage)(0, 0) =
371 SPDLOG_LOGGER_DEBUG(
mSLog,
"Voltage {:s}",
AttributePointer< Attribute< T > > Ptr
void addMNASubComponent(typename SimPowerComp< Complex >::Ptr subc, MNA_SUBCOMP_TASK_ORDER preStepOrder, MNA_SUBCOMP_TASK_ORDER postStepOrder, Bool contributeToRightVector)
CompositePowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
const Attribute< String >::Ptr mName
Human readable name.
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)
static String realToString(const Real &num)
static String phasorToString(const Complex &num)
void mnaUpdateCurrent(const Matrix &leftVector) final
void mnaUpdateVoltage(const Matrix &leftVector) final
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)
UInt matrixNodeIndex(UInt nodeIndex)
const Attribute< MatrixVar< Complex > >::Ptr mIntfCurrent
SimTerminal< Complex >::List mTerminals
SimNode< Complex >::Ptr node(UInt index)
void setVirtualNodeNumber(UInt num)
const Attribute< MatrixVar< Complex > >::Ptr mIntfVoltage
std::shared_ptr< SimPowerComp< VarType > > Ptr
SimNode< Complex >::List mVirtualNodes
std::vector< std::shared_ptr< SimPowerComp< Complex > > > mSubComponents
Bool terminalNotGrounded(UInt index)
Complex initialSingleVoltage(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::SparseMatrix< Real, Eigen::RowMajor > SparseMatrixRow
Sparse matrix for real numbers (row major).