DPsim
Loading...
Searching...
No Matches
SP_Ph1_Transformer.cpp
1/* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
2 * EONERC, RWTH Aachen University
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7 *********************************************************************************/
8
9#include <dpsim-models/MathUtils.h>
10#include <dpsim-models/SP/SP_Ph1_Transformer.h>
11
12using namespace CPS;
13
14// #### General ####
16 Logger::Level logLevel,
17 Bool withResistiveLosses)
18 : Base::Ph1::Transformer(mAttributes),
19 CompositePowerComp<Complex>(uid, name, true, true, logLevel),
20 mBaseVoltage(mAttributes->create<Real>("base_Voltage")),
21 mCurrent(mAttributes->create<MatrixComp>("current_vector")),
22 mActivePowerBranch(mAttributes->create<Matrix>("p_branch_vector")),
23 mReactivePowerBranch(mAttributes->create<Matrix>("q_branch_vector")),
24 mActivePowerInjection(mAttributes->create<Real>("p_inj")),
25 mReactivePowerInjection(mAttributes->create<Real>("q_inj")) {
26 if (withResistiveLosses)
27 setVirtualNodeNumber(3);
28 else
29 setVirtualNodeNumber(2);
30
31 SPDLOG_LOGGER_INFO(mSLog, "Create {} {}", this->type(), name);
32 **mIntfVoltage = MatrixComp::Zero(1, 1);
33 **mIntfCurrent = MatrixComp::Zero(1, 1);
34 setTerminalNumber(2);
35
36 **mCurrent = MatrixComp::Zero(2, 1);
37 **mActivePowerBranch = Matrix::Zero(2, 1);
38 **mReactivePowerBranch = Matrix::Zero(2, 1);
39}
40
41void SP::Ph1::Transformer::setParameters(Real nomVoltageEnd1,
42 Real nomVoltageEnd2, Real ratioAbs,
43 Real ratioPhase, Real resistance,
44 Real inductance) {
45
46 // Note: to be consistent impedance values must be referred to high voltage side (and base voltage set to higher voltage)
47 Base::Ph1::Transformer::setParameters(nomVoltageEnd1, nomVoltageEnd2,
48 ratioAbs, ratioPhase, resistance,
49 inductance);
50
51 SPDLOG_LOGGER_INFO(
52 mSLog, "Nominal Voltage End 1={} [V] Nominal Voltage End 2={} [V]",
54 SPDLOG_LOGGER_INFO(
55 mSLog, "Resistance={} [Ohm] Inductance={} [H] (referred to primary side)",
57 SPDLOG_LOGGER_INFO(mSLog, "Tap Ratio={} [/] Phase Shift={} [deg]",
58 std::abs(**mRatio), std::arg(**mRatio));
59 SPDLOG_LOGGER_INFO(mSLog, "Rated Power ={} [VA]", **mRatedPower);
60
61 mRatioAbs = std::abs(**mRatio);
62 mRatioPhase = std::arg(**mRatio);
63
64 mParametersSet = true;
65}
66
67void SP::Ph1::Transformer::setParameters(Real nomVoltageEnd1,
68 Real nomVoltageEnd2, Real ratedPower,
69 Real ratioAbs, Real ratioPhase,
70 Real resistance, Real inductance) {
71
72 // Rated power is the nameplate apparent-power magnitude |S|, so it cannot be
73 // negative (a negative value is a caller error, not the unset default of 0).
74 if (ratedPower < 0) {
75 SPDLOG_LOGGER_ERROR(mSLog, "Rated power {} [VA] is negative; must be >= 0",
76 ratedPower);
78 }
79
80 **mRatedPower = ratedPower;
81 SPDLOG_LOGGER_INFO(mSLog, "Rated Power ={} [VA]", **mRatedPower);
82
83 SP::Ph1::Transformer::setParameters(nomVoltageEnd1, nomVoltageEnd2, ratioAbs,
84 ratioPhase, resistance, inductance);
85}
86
88SimPowerComp<Complex>::Ptr SP::Ph1::Transformer::clone(String name) {
89 auto copy = Transformer::make(name, mLogLevel);
91 std::abs(**mRatio), std::arg(**mRatio), **mResistance,
92 **mInductance);
93 return copy;
94}
95
98 return;
99 mSubCompCreated = true;
100
101 // Switch terminals so that terminal 0 is always the higher-voltage side.
102 if (Math::abs(**mRatio) < 1.) {
103 **mRatio = 1. / **mRatio;
104 mRatioAbs = std::abs(**mRatio);
105 mRatioPhase = std::arg(**mRatio);
106 std::shared_ptr<SimTerminal<Complex>> tmp = mTerminals[0];
107 mTerminals[0] = mTerminals[1];
108 mTerminals[1] = tmp;
109 Real tmpVolt = mNominalVoltageEnd1;
111 mNominalVoltageEnd2 = tmpVolt;
112 SPDLOG_LOGGER_INFO(mSLog, "Switching terminals to have first terminal at "
113 "higher voltage side. Updated parameters: ");
114 SPDLOG_LOGGER_INFO(
115 mSLog, "Nominal Voltage End 1 = {} [V] Nominal Voltage End 2 = {} [V]",
117 SPDLOG_LOGGER_INFO(mSLog, "Tap Ratio = {} [ ] Phase Shift = {} [deg]",
118 mRatioAbs, mRatioPhase);
119 // Refresh index cache after terminal swap so pfApplyAdmittanceMatrixStamp uses the correct order.
121 }
122
123 // Create series sub components
124 mSubInductor = std::make_shared<SP::Ph1::Inductor>(
125 **mUID + "_ind", **mName + "_ind", Logger::Level::off);
126 mSubInductor->setParameters(**mInductance);
127 addMNASubComponent(mSubInductor, MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
128 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT, true);
129
130 if (mNumVirtualNodes == 3) {
131 mSubResistor = std::make_shared<SP::Ph1::Resistor>(
132 **mUID + "_res", **mName + "_res", Logger::Level::off);
133 mSubResistor->setParameters(**mResistance);
134 mSubResistor->connect({node(0), mVirtualNodes[2]});
135 mSubInductor->connect({mVirtualNodes[2], mVirtualNodes[0]});
136 addMNASubComponent(mSubResistor, MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
137 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT, true);
138 } else {
139 mSubInductor->connect({node(0), mVirtualNodes[0]});
140 }
141
142 // Snubber sub-components created here; their omega/power-dependent values are set in
143 // initializeParentFromNodesAndTerminals(). Snubbers are sized off the rated power, so
144 // without a valid rating they collapse to infinite resistance and zero capacitance
145 // (NaN admittance) that poisons the system matrix; skip creating them in that case.
146 bool snubbersEnabled =
147 (mBehaviour == TopologicalPowerComp::Behaviour::Initialization ||
148 mBehaviour == TopologicalPowerComp::Behaviour::MNASimulation);
149 if (snubbersEnabled && **mRatedPower <= 0) {
150 SPDLOG_LOGGER_WARN(mSLog,
151 "Rated power is {} [VA]; snubbers disabled for this "
152 "transformer (cannot be sized off non-positive power).",
153 **mRatedPower);
154 snubbersEnabled = false;
155 }
156 if (snubbersEnabled) {
157
158 mSubSnubResistor1 =
159 std::make_shared<SP::Ph1::Resistor>(**mName + "_snub_res1", mLogLevel);
160 mSubSnubResistor1->connect({node(0), SP::SimNode::GND});
161 addMNASubComponent(mSubSnubResistor1,
162 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
163 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT, true);
164
165 mSubSnubResistor2 =
166 std::make_shared<SP::Ph1::Resistor>(**mName + "_snub_res2", mLogLevel);
167 mSubSnubResistor2->connect({node(1), SP::SimNode::GND});
168 addMNASubComponent(mSubSnubResistor2,
169 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
170 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT, true);
171
172 mSubSnubCapacitor2 =
173 std::make_shared<SP::Ph1::Capacitor>(**mName + "_snub_cap2", mLogLevel);
174 mSubSnubCapacitor2->connect({node(1), SP::SimNode::GND});
175 addMNASubComponent(mSubSnubCapacitor2,
176 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
177 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT, true);
178 }
179}
180
182 Real frequency) {
183 mNominalOmega = 2. * PI * frequency;
184 mReactance = mNominalOmega * **mInductance;
185 SPDLOG_LOGGER_INFO(mSLog, "Reactance={} [Ohm] (referred to primary side)",
186 mReactance);
187
188 if (mSubSnubResistor1) {
189 Real pSnub = P_SNUB_TRANSFORMER * **mRatedPower;
190 Real qSnub = Q_SNUB_TRANSFORMER * **mRatedPower;
191
192 // A snubber conductance is added on the higher voltage side
193 mSnubberResistance1 = std::pow(std::abs(mNominalVoltageEnd1), 2) / pSnub;
194 mSubSnubResistor1->setParameters(mSnubberResistance1);
195 SPDLOG_LOGGER_INFO(
196 mSLog,
197 "Snubber Resistance 1 (connected to higher voltage side {}) = {} [Ohm]",
198 node(0)->name(), Logger::realToString(mSnubberResistance1));
199 mSubSnubResistor1->setBaseVoltage(mNominalVoltageEnd1);
200
201 // A snubber conductance is added on the lower voltage side
202 mSnubberResistance2 = std::pow(std::abs(mNominalVoltageEnd2), 2) / pSnub;
203 mSubSnubResistor2->setParameters(mSnubberResistance2);
204 SPDLOG_LOGGER_INFO(
205 mSLog,
206 "Snubber Resistance 2 (connected to lower voltage side {}) = {} [Ohm]",
207 node(1)->name(), Logger::realToString(mSnubberResistance2));
208 mSubSnubResistor2->setBaseVoltage(mNominalVoltageEnd2);
209
210 // // A snubber capacitance is added to higher voltage side (not used as capacitor at high voltage side made it worse)
211 // mSnubberCapacitance1 = qSnub / std::pow(std::abs(mNominalVoltageEnd1),2) / mNominalOmega;
212 // mSubSnubCapacitor1 = std::make_shared<SP::Ph1::Capacitor>(**mName + "_snub_cap1", mLogLevel);
213 // mSubSnubCapacitor1->setParameters(mSnubberCapacitance1);
214 // mSubSnubCapacitor1->connect({ node(0), SP::SimNode::GND });
215 // SPDLOG_LOGGER_INFO(mSLog, "Snubber Capacitance 1 (connected to higher voltage side {}) = \n{} [F] \n ", node(0)->name(), Logger::realToString(mSnubberCapacitance1));
216 // mSubSnubCapacitor1->setBaseVoltage(mNominalVoltageEnd1);
217 // mSubComponents.push_back(mSubSnubCapacitor1);
218
219 // A snubber capacitance is added to lower voltage side
220 mSnubberCapacitance2 =
221 qSnub / std::pow(std::abs(mNominalVoltageEnd2), 2) / mNominalOmega;
222 mSubSnubCapacitor2->setParameters(mSnubberCapacitance2);
223 SPDLOG_LOGGER_INFO(
224 mSLog,
225 "Snubber Capacitance 2 (connected to lower voltage side {}) = {} [F]",
226 node(1)->name(), Logger::realToString(mSnubberCapacitance2));
227 mSubSnubCapacitor2->setBaseVoltage(mNominalVoltageEnd2);
228 }
229
230 // Set initial voltage of virtual node in between
231 mVirtualNodes[0]->setInitialVoltage(initialSingleVoltage(1) * **mRatio);
232
233 // Static calculations from load flow data
234 Complex impedance = {**mResistance, mReactance};
235 (**mIntfVoltage)(0, 0) =
236 mVirtualNodes[0]->initialSingleVoltage() - initialSingleVoltage(0);
237 (**mIntfCurrent)(0, 0) = (**mIntfVoltage)(0, 0) / impedance;
238
239 if (mNumVirtualNodes == 3)
240 mVirtualNodes[2]->setInitialVoltage(initialSingleVoltage(0));
241
242 SPDLOG_LOGGER_INFO(
243 mSLog,
244 "\n--- Initialization from powerflow ---"
245 "\nVoltage across: {:s}"
246 "\nCurrent: {:s}"
247 "\nTerminal 0 voltage: {:s}"
248 "\nTerminal 1 voltage: {:s}"
249 "\nVirtual Node 1 voltage: {:s}"
250 "\n--- Initialization from powerflow finished ---",
251 Logger::phasorToString((**mIntfVoltage)(0, 0)),
252 Logger::phasorToString((**mIntfCurrent)(0, 0)),
253 Logger::phasorToString(initialSingleVoltage(0)),
254 Logger::phasorToString(initialSingleVoltage(1)),
255 Logger::phasorToString(mVirtualNodes[0]->initialSingleVoltage()));
256}
257
258// #### Powerflow section ####
259
263
267
268void SP::Ph1::Transformer::setBaseVoltage(Real baseVoltage) {
269 // Note: to be consistent set base voltage to higher voltage (and impedance values must be referred to high voltage side)
270 // TODO: use attribute setter for setting base voltage
271 **mBaseVoltage = baseVoltage;
272}
273
275 Real baseOmega) {
276 SPDLOG_LOGGER_INFO(mSLog, "#### Calculate Per Unit Parameters for {}",
277 **mName);
278 mBaseApparentPower = baseApparentPower;
279 mBaseOmega = baseOmega;
280 SPDLOG_LOGGER_INFO(mSLog, "Base Power={} [VA] Base Omega={} [1/s]",
281 baseApparentPower, baseOmega);
282
283 mBaseImpedance = **mBaseVoltage * **mBaseVoltage / mBaseApparentPower;
284 mBaseAdmittance = 1.0 / mBaseImpedance;
285 mBaseCurrent = baseApparentPower /
286 (**mBaseVoltage *
287 sqrt(3)); // I_base=(S_threephase/3)/(V_line_to_line/sqrt(3))
288 SPDLOG_LOGGER_INFO(mSLog, "Base Voltage={} [V] Base Impedance={} [Ohm]",
289 **mBaseVoltage, mBaseImpedance);
290
291 mResistancePerUnit = **mResistance / mBaseImpedance;
292 mReactancePerUnit = mReactance / mBaseImpedance;
293 SPDLOG_LOGGER_INFO(mSLog, "Resistance={} [pu] Reactance={} [pu]",
294 mResistancePerUnit, mReactancePerUnit);
295
296 mBaseInductance = mBaseImpedance / mBaseOmega;
297 mInductancePerUnit = **mInductance / mBaseInductance;
298 // omega per unit=1, hence 1.0*mInductancePerUnit.
299 mLeakagePerUnit = Complex(mResistancePerUnit, 1. * mInductancePerUnit);
300 SPDLOG_LOGGER_INFO(mSLog, "Leakage Impedance={} [pu] ", mLeakagePerUnit);
301
302 mRatioAbsPerUnit = mRatioAbs / mNominalVoltageEnd1 * mNominalVoltageEnd2;
303 SPDLOG_LOGGER_INFO(mSLog, "Tap Ratio={} [pu]", mRatioAbsPerUnit);
304
305 // Calculate per unit parameters of subcomps
306 if (mSubSnubResistor1)
307 mSubSnubResistor1->calculatePerUnitParameters(mBaseApparentPower);
308 if (mSubSnubResistor2)
309 mSubSnubResistor2->calculatePerUnitParameters(mBaseApparentPower);
310 if (mSubSnubCapacitor1)
311 mSubSnubCapacitor1->calculatePerUnitParameters(mBaseApparentPower);
312 if (mSubSnubCapacitor2)
313 mSubSnubCapacitor2->calculatePerUnitParameters(mBaseApparentPower);
314}
315
317 SparseMatrixCompRow &Y) {
318 // calculate matrix stamp
319 mY_element = MatrixComp(2, 2);
320 Complex y = Complex(1, 0) / mLeakagePerUnit;
321
322 mY_element(0, 0) = y;
323 mY_element(0, 1) = -y * mRatioAbsPerUnit;
324 mY_element(1, 0) = -y * mRatioAbsPerUnit;
325 mY_element(1, 1) = y * std::pow(mRatioAbsPerUnit, 2);
326
327 //check for inf or nan
328 for (int i = 0; i < 2; i++)
329 for (int j = 0; j < 2; j++)
330 if (!Math::isFinite(mY_element.coeff(i, j))) {
331 SPDLOG_LOGGER_ERROR(
332 mSLog,
333 "Transformer {}: non-finite per-unit admittance {} "
334 "in element Y({},{}) (leakage {}, tap {})",
335 this->name(), Logger::complexToString(mY_element.coeff(i, j)), i, j,
336 Logger::complexToString(mLeakage), mRatioAbsPerUnit);
338 }
339
340 //set the circuit matrix values
341 Y.coeffRef(this->matrixNodeIndex(0), this->matrixNodeIndex(0)) +=
342 mY_element.coeff(0, 0);
343 Y.coeffRef(this->matrixNodeIndex(0), this->matrixNodeIndex(1)) +=
344 mY_element.coeff(0, 1);
345 Y.coeffRef(this->matrixNodeIndex(1), this->matrixNodeIndex(1)) +=
346 mY_element.coeff(1, 1);
347 Y.coeffRef(this->matrixNodeIndex(1), this->matrixNodeIndex(0)) +=
348 mY_element.coeff(1, 0);
349
350 SPDLOG_LOGGER_INFO(mSLog, "#### Y matrix stamping: {}", mY_element);
351
352 if (mSubSnubResistor1)
353 mSubSnubResistor1->pfApplyAdmittanceMatrixStamp(Y);
354 if (mSubSnubResistor2)
355 mSubSnubResistor2->pfApplyAdmittanceMatrixStamp(Y);
356 if (mSubSnubCapacitor1)
357 mSubSnubCapacitor1->pfApplyAdmittanceMatrixStamp(Y);
358 if (mSubSnubCapacitor2)
359 mSubSnubCapacitor2->pfApplyAdmittanceMatrixStamp(Y);
360}
361
363 VectorComp &powerflow) {
364 **mCurrent = current * mBaseCurrent;
365 **mActivePowerBranch = powerflow.real() * mBaseApparentPower;
366 **mReactivePowerBranch = powerflow.imag() * mBaseApparentPower;
367}
368
369void SP::Ph1::Transformer::storeNodalInjection(Complex powerInjection) {
370 **mActivePowerInjection = std::real(powerInjection) * mBaseApparentPower;
371 **mReactivePowerInjection = std::imag(powerInjection) * mBaseApparentPower;
372}
373
374MatrixComp SP::Ph1::Transformer::Y_element() { return mY_element; }
375
376// #### MNA Section ####
377
379 Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
380 SPDLOG_LOGGER_INFO(
381 mSLog,
382 "\nTerminal 0 connected to {:s} = sim node {:d}"
383 "\nTerminal 1 connected to {:s} = sim node {:d}",
384 mTerminals[0]->node()->name(), mTerminals[0]->node()->matrixNodeIndex(),
385 mTerminals[1]->node()->name(), mTerminals[1]->node()->matrixNodeIndex());
386}
387
389 SparseMatrixRow &systemMatrix) {
390 // Ideal transformer equations
391 if (terminalNotGrounded(0)) {
392 Math::setMatrixElement(systemMatrix, mVirtualNodes[0]->matrixNodeIndex(),
393 mVirtualNodes[1]->matrixNodeIndex(),
394 Complex(-1.0, 0));
395 Math::setMatrixElement(systemMatrix, mVirtualNodes[1]->matrixNodeIndex(),
396 mVirtualNodes[0]->matrixNodeIndex(),
397 Complex(1.0, 0));
398 }
399 if (terminalNotGrounded(1)) {
400 Math::setMatrixElement(systemMatrix, matrixNodeIndex(1),
401 mVirtualNodes[1]->matrixNodeIndex(), **mRatio);
402 Math::setMatrixElement(systemMatrix, mVirtualNodes[1]->matrixNodeIndex(),
403 matrixNodeIndex(1), -**mRatio);
404 }
405
406 // Add subcomps to system matrix
407 for (auto subcomp : mSubComponents)
408 if (auto mnasubcomp = std::dynamic_pointer_cast<MNAInterface>(subcomp))
409 mnasubcomp->mnaApplySystemMatrixStamp(systemMatrix);
410
411 if (terminalNotGrounded(0)) {
412 SPDLOG_LOGGER_INFO(mSLog, "Add {:s} to system at ({:d},{:d})",
413 Logger::complexToString(Complex(-1.0, 0)),
414 mVirtualNodes[0]->matrixNodeIndex(),
415 mVirtualNodes[1]->matrixNodeIndex());
416 SPDLOG_LOGGER_INFO(mSLog, "Add {:s} to system at ({:d},{:d})",
417 Logger::complexToString(Complex(1.0, 0)),
418 mVirtualNodes[1]->matrixNodeIndex(),
419 mVirtualNodes[0]->matrixNodeIndex());
420 }
421 if (terminalNotGrounded(1)) {
422 SPDLOG_LOGGER_INFO(mSLog, "Add {:s} to system at ({:d},{:d})",
423 Logger::complexToString(**mRatio), matrixNodeIndex(1),
424 mVirtualNodes[1]->matrixNodeIndex());
425 SPDLOG_LOGGER_INFO(mSLog, "Add {:s} to system at ({:d},{:d})",
426 Logger::complexToString(-**mRatio),
427 mVirtualNodes[1]->matrixNodeIndex(), matrixNodeIndex(1));
428 }
429}
430
432 AttributeBase::List &prevStepDependencies,
433 AttributeBase::List &attributeDependencies,
434 AttributeBase::List &modifiedAttributes) {
435 prevStepDependencies.push_back(mIntfCurrent);
436 prevStepDependencies.push_back(mIntfVoltage);
437 modifiedAttributes.push_back(mRightVector);
438}
439
443
445 AttributeBase::List &prevStepDependencies,
446 AttributeBase::List &attributeDependencies,
447 AttributeBase::List &modifiedAttributes,
448 Attribute<Matrix>::Ptr &leftVector) {
449 attributeDependencies.push_back(leftVector);
450 modifiedAttributes.push_back(mIntfVoltage);
451 modifiedAttributes.push_back(mIntfCurrent);
452}
453
455 Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector) {
456 this->mnaUpdateVoltage(**leftVector);
457 this->mnaUpdateCurrent(**leftVector);
458}
459
460void SP::Ph1::Transformer::mnaCompUpdateCurrent(const Matrix &leftVector) {
461 (**mIntfCurrent)(0, 0) = mSubInductor->intfCurrent()(0, 0);
462 SPDLOG_LOGGER_DEBUG(mSLog, "Current {:s}",
463 Logger::phasorToString((**mIntfCurrent)(0, 0)));
464}
465
466void SP::Ph1::Transformer::mnaCompUpdateVoltage(const Matrix &leftVector) {
467 // v1 - v0
468 (**mIntfVoltage)(0, 0) = 0;
469 (**mIntfVoltage)(0, 0) =
470 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1));
471 (**mIntfVoltage)(0, 0) = (**mIntfVoltage)(0, 0) -
472 Math::complexFromVectorElement(
473 leftVector, mVirtualNodes[0]->matrixNodeIndex());
474 SPDLOG_LOGGER_DEBUG(mSLog, "Voltage {:s}",
475 Logger::phasorToString((**mIntfVoltage)(0, 0)));
476}
const Attribute< Real >::Ptr mRatedPower
Rated Apparent Power [VA].
Real mNominalVoltageEnd2
Nominal voltage of secondary side.
Real mNominalVoltageEnd1
Nominal voltage of primary side.
const Attribute< Real >::Ptr mInductance
Inductance [H].
const Attribute< Real >::Ptr mResistance
Resistance [Ohm].
const Attribute< Complex >::Ptr mRatio
Complex transformer ratio.
void addMNASubComponent(typename SimPowerComp< Complex >::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)
const Attribute< String >::Ptr mUID
Unique identifier.
AttributeList::Ptr mAttributes
Attribute List.
void mnaUpdateCurrent(const Matrix &leftVector) final
void mnaUpdateVoltage(const Matrix &leftVector) final
Attribute< Matrix >::Ptr mRightVector
void storeNodalInjection(Complex powerInjection)
stores nodal injection power in this line object
Transformer(String uid, String name, Logger::Level logLevel=Logger::Level::off, Bool withResistiveLosses=false)
Defines UID, name and logging level.
const Attribute< Matrix >::Ptr mActivePowerBranch
branch active powerflow [W], coef(0) has data from node 0, coef(1) from node 1.
void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
Add MNA pre step dependencies.
void calculatePerUnitParameters(Real baseApparentPower, Real baseOmega)
Initializes component from power flow data.
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override
Stamps system matrix.
const Attribute< Real >::Ptr mReactivePowerInjection
nodal reactive power injection
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Updates internal voltage variable of the component.
void updateBranchFlow(VectorComp &current, VectorComp &powerflow)
updates branch current and power flow, input pu value, update with real value
void setParameters(Real nomVoltageEnd1, Real nomVoltageEnd2, Real ratioAbs, Real ratioPhase, Real resistance, Real inductance)
Set transformer specific parameters (without rated power)
void mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA post step operations.
void pfApplyAdmittanceMatrixStamp(SparseMatrixCompRow &Y) override
Stamps admittance matrix.
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Updates internal current variable of the component.
Real getNominalVoltageEnd1() const
Get nominal voltage at end 1.
void createSubComponents() override
Constructs and registers MNA subcomponents; idempotent.
void initializeParentFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
const Attribute< Matrix >::Ptr mReactivePowerBranch
branch reactive powerflow [Var], coef(0) has data from node 0, coef(1) from node 1.
void mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
void mnaParentInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
Initializes internal variables of the component.
SimPowerComp< Complex >::Ptr clone(String name) override
DEPRECATED: Delete method.
MatrixComp Y_element()
get admittance matrix
const Attribute< MatrixComp >::Ptr mCurrent
branch Current flow [A], coef(0) has data from node 0, coef(1) from node 1.
void mnaParentPreStep(Real time, Int timeStepCount) override
MNA pre step operations.
const Attribute< Real >::Ptr mBaseVoltage
base voltage [V]
Real getNominalVoltageEnd2() const
Get nominal voltage at end 2.
const Attribute< Real >::Ptr mActivePowerInjection
nodal active power injection
const Attribute< MatrixVar< Complex > >::Ptr mIntfCurrent
SimTerminal< Complex >::List mTerminals
SimNode< Complex >::Ptr node(UInt index)
const Attribute< MatrixVar< Complex > >::Ptr mIntfVoltage
SimNode< Complex >::List mVirtualNodes
std::vector< std::shared_ptr< SimPowerComp< Complex > > > mSubComponents
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.