15 Bool withResistiveLosses)
19 if (withResistiveLosses)
26 SPDLOG_LOGGER_INFO(
mSLog,
"Create {} {}", this->
type(), name);
41 Real nomVoltageSecondary,
47 ratedPower, ratioAbs, ratioPhase,
48 resistance, inductance);
52 "Nominal Voltage Primary = {} [V] Nominal Voltage Secondary = {} [V]",
55 SPDLOG_LOGGER_INFO(
mSLog,
"Tap Ratio = {} [ ] Phase Shift = {} [deg]",
61void EMT::Ph3::Transformer::resolveWindingRoles() {
62 switch (mReferenceWinding) {
64 mReferenceTerminal = 0;
67 mReferenceTerminal = 1;
70 SPDLOG_LOGGER_ERROR(mSLog,
71 "Transformer {}: three-winding transformers are "
77 (mNominalVoltagePrimary >= mNominalVoltageSecondary) ? 0 : 1;
80 mRatioFromReference = (mReferenceTerminal == 0) ? **mRatio : 1. / **mRatio;
81 mOrientationSign = (mReferenceTerminal == 0) ? 1. : -1.;
83 if (
Math::abs(std::arg(mRatioFromReference)) > 1e-9) {
84 SPDLOG_LOGGER_ERROR(mSLog,
85 "Turns ratio {} has a phase shift of {} rad. "
86 "EMT::Ph3::Transformer models in-phase turns ratios "
87 "only; a phase-shifting winding connection is not "
90 std::arg(mRatioFromReference));
100 resolveWindingRoles();
105 std::make_shared<EMT::Ph3::Inductor>(**
mName +
"_ind",
mLogLevel);
111 std::make_shared<EMT::Ph3::Inductor>(**
mName +
"_ind2",
mLogLevel);
118 std::make_shared<EMT::Ph3::Resistor>(**
mName +
"_res",
mLogLevel);
126 std::make_shared<EMT::Ph3::Resistor>(**
mName +
"_res2",
mLogLevel);
134 mSubInductor->connect({
node(mReferenceTerminal), midpoint});
139 SPDLOG_LOGGER_WARN(
mSLog,
140 "Transformer {}: rated power is {} [VA], so the "
141 "magnetizing branch cannot be sized and is omitted",
146 if (mNoLoadCurrent <= mNoLoadLoss) {
147 SPDLOG_LOGGER_ERROR(
mSLog,
148 "Transformer {}: no-load current {} must exceed the "
150 this->
name(), mNoLoadCurrent, mNoLoadLoss);
154 Real magnetizingResistance =
157 mMagnetizingResistance =
159 mSubMagnetizingResistor =
160 std::make_shared<EMT::Ph3::Resistor>(**
mName +
"_mag_res",
mLogLevel);
161 mSubMagnetizingResistor->setParameters(mMagnetizingResistance);
167 mSubMagnetizingInductor =
168 std::make_shared<EMT::Ph3::Inductor>(**
mName +
"_mag_ind",
mLogLevel);
182 Real omega = 2. *
PI * frequency;
184 if (mSubMagnetizingInductor) {
185 Real magnetizingSusceptance =
186 std::sqrt(std::pow(mNoLoadCurrent, 2) - std::pow(mNoLoadLoss, 2)) *
188 Real magnetizingInductance = 1. / (omega * magnetizingSusceptance);
189 mMagnetizingInductance =
191 mSubMagnetizingInductor->setParameters(mMagnetizingInductance);
192 SPDLOG_LOGGER_INFO(
mSLog,
"Magnetizing inductance = {} [H]",
196 MatrixComp impedance = MatrixComp::Zero(3, 3);
207 SPDLOG_LOGGER_INFO(
mSLog,
208 "Resistance (referred to higher voltage side) = {} [Ohm]",
210 SPDLOG_LOGGER_INFO(
mSLog,
211 "Inductance (referred to higher voltage side) = {} [H]",
213 SPDLOG_LOGGER_INFO(
mSLog,
214 "Reactance (referred to higher voltage side) = {} [Ohm]",
224 MatrixComp vTerminalABC = MatrixComp::Zero(3, 1);
230 MatrixComp iInit = impedance.inverse() * vInitABC;
237 if (mSubMagnetizingInductor)
238 magnetizingAdmittance =
239 1. / mMagnetizingResistance(0, 0) +
240 1. /
Complex(0, omega * mMagnetizingInductance(0, 0));
244 (referenceVoltage +
mVirtualNodes[0]->initialSingleVoltage()) /
245 (2. + halfImpedance * magnetizingAdmittance);
250 (referenceVoltage - midpointVoltage) / halfImpedance;
252 (midpointVoltage -
mVirtualNodes[0]->initialSingleVoltage()) /
255 referenceVoltage - referenceCurrent *
mResistance(0, 0) / 2.);
257 midpointVoltage - nonReferenceCurrent *
mResistance(0, 0) / 2.);
262 "\n--- Initialization from powerflow ---"
263 "\nVoltage across: {:s}"
265 "\nTerminal 0 voltage: {:s}"
266 "\nTerminal 1 voltage: {:s}"
267 "\nVirtual Node 1 voltage: {:s}"
268 "\n--- Initialization from powerflow finished ---",
281 "\nTerminal 0 connected to {:s} = sim node {:d}"
282 "\nTerminal 1 connected to {:s} = sim node {:d}",
315 mRatioFromReference.real());
319 mRatioFromReference.real());
323 mRatioFromReference.real());
327 -mRatioFromReference.real());
331 -mRatioFromReference.real());
335 -mRatioFromReference.real());
340 if (
auto mnasubcomp = std::dynamic_pointer_cast<MNAInterface>(subcomp))
341 mnasubcomp->mnaApplySystemMatrixStamp(systemMatrix);
344 SPDLOG_LOGGER_INFO(
mSLog,
"Add {:s} to system at ({:d},{:d})",
348 SPDLOG_LOGGER_INFO(
mSLog,
"Add {:s} to system at ({:d},{:d})",
352 SPDLOG_LOGGER_INFO(
mSLog,
"Add {:s} to system at ({:d},{:d})",
357 SPDLOG_LOGGER_INFO(
mSLog,
"Add {:s} to system at ({:d},{:d})",
361 SPDLOG_LOGGER_INFO(
mSLog,
"Add {:s} to system at ({:d},{:d})",
365 SPDLOG_LOGGER_INFO(
mSLog,
"Add {:s} to system at ({:d},{:d})",
371 SPDLOG_LOGGER_INFO(
mSLog,
"Add {:s} to system at ({:d},{:d})",
374 SPDLOG_LOGGER_INFO(
mSLog,
"Add {:s} to system at ({:d},{:d})",
377 SPDLOG_LOGGER_INFO(
mSLog,
"Add {:s} to system at ({:d},{:d})",
381 SPDLOG_LOGGER_INFO(
mSLog,
"Add {:s} to system at ({:d},{:d})",
385 SPDLOG_LOGGER_INFO(
mSLog,
"Add {:s} to system at ({:d},{:d})",
389 SPDLOG_LOGGER_INFO(
mSLog,
"Add {:s} to system at ({:d},{:d})",
414 attributeDependencies.push_back(leftVector);
426 **
mIntfCurrent = mOrientationSign * mSubInductor->intfCurrent();
433 (**mIntfVoltage)(0, 0) =
435 (**mIntfVoltage)(1, 0) =
437 (**mIntfVoltage)(2, 0) =
441 (**mIntfVoltage)(0, 0) =
444 (**mIntfVoltage)(1, 0) =
447 (**mIntfVoltage)(2, 0) =
AttributePointer< Attribute< T > > Ptr
void addMNASubComponent(typename SimPowerComp< Real >::Ptr subc, MNA_SUBCOMP_TASK_ORDER preStepOrder, MNA_SUBCOMP_TASK_ORDER postStepOrder, Bool contributeToRightVector)
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override
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 matrixToString(const Matrix &mat)
static String phasorToString(const Complex &num)
Attribute< Matrix >::Ptr mRightVector
static Real realFromVectorElement(const Matrix &mat, Matrix::Index row)
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.
static Real abs(Complex value)
UInt matrixNodeIndex(UInt nodeIndex)
const Attribute< MatrixVar< Real > >::Ptr mIntfCurrent
SimTerminal< Real >::List mTerminals
SimNode< Real >::Ptr node(UInt index)
void setVirtualNodeNumber(UInt num)
const Attribute< MatrixVar< Real > >::Ptr mIntfVoltage
std::shared_ptr< SimPowerComp< VarType > > Ptr
SimNode< Real >::List mVirtualNodes
std::vector< std::shared_ptr< SimPowerComp< Real > > > 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)
#define RMS3PH_TO_PEAK1PH
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).