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/SP/SP_Ph1_Transformer.h>
10
11using namespace CPS;
12
13// #### General ####
15 Logger::Level logLevel,
16 Bool withResistiveLosses)
17 : Base::Ph1::Transformer(mAttributes),
18 CompositePowerComp<Complex>(uid, name, true, true, logLevel),
19 mBaseVoltage(mAttributes->create<Real>("base_Voltage")),
20 mCurrent(mAttributes->create<MatrixComp>("current_vector")),
21 mActivePowerBranch(mAttributes->create<Matrix>("p_branch_vector")),
22 mReactivePowerBranch(mAttributes->create<Matrix>("q_branch_vector")),
23 mActivePowerInjection(mAttributes->create<Real>("p_inj")),
24 mReactivePowerInjection(mAttributes->create<Real>("q_inj")) {
25 if (withResistiveLosses)
26 setVirtualNodeNumber(3);
27 else
28 setVirtualNodeNumber(2);
29
30 SPDLOG_LOGGER_INFO(mSLog, "Create {} {}", this->type(), name);
31 **mIntfVoltage = MatrixComp::Zero(1, 1);
32 **mIntfCurrent = MatrixComp::Zero(1, 1);
33 setTerminalNumber(2);
34
35 **mCurrent = MatrixComp::Zero(2, 1);
36 **mActivePowerBranch = Matrix::Zero(2, 1);
37 **mReactivePowerBranch = Matrix::Zero(2, 1);
38}
39
40void SP::Ph1::Transformer::setParameters(Real nomVoltageEnd1,
41 Real nomVoltageEnd2, Real ratioAbs,
42 Real ratioPhase, Real resistance,
43 Real inductance) {
44
45 // Note: to be consistent impedance values must be referred to high voltage side (and base voltage set to higher voltage)
46 Base::Ph1::Transformer::setParameters(nomVoltageEnd1, nomVoltageEnd2,
47 ratioAbs, ratioPhase, resistance,
48 inductance);
49
50 SPDLOG_LOGGER_INFO(
51 mSLog, "Nominal Voltage End 1={} [V] Nominal Voltage End 2={} [V]",
53 SPDLOG_LOGGER_INFO(
54 mSLog, "Resistance={} [Ohm] Inductance={} [H] (referred to primary side)",
56 SPDLOG_LOGGER_INFO(mSLog, "Tap Ratio={} [/] Phase Shift={} [deg]",
57 std::abs(**mRatio), std::arg(**mRatio));
58 SPDLOG_LOGGER_INFO(mSLog, "Rated Power ={} [W]", **mRatedPower);
59
60 mRatioAbs = std::abs(**mRatio);
61 mRatioPhase = std::arg(**mRatio);
62
63 mParametersSet = true;
64}
65
66void SP::Ph1::Transformer::setParameters(Real nomVoltageEnd1,
67 Real nomVoltageEnd2, Real ratedPower,
68 Real ratioAbs, Real ratioPhase,
69 Real resistance, Real inductance) {
70
71 **mRatedPower = ratedPower;
72 SPDLOG_LOGGER_INFO(mSLog, "Rated Power ={} [W]", **mRatedPower);
73
74 SP::Ph1::Transformer::setParameters(nomVoltageEnd1, nomVoltageEnd2, ratioAbs,
75 ratioPhase, resistance, inductance);
76}
77
79SimPowerComp<Complex>::Ptr SP::Ph1::Transformer::clone(String name) {
80 auto copy = Transformer::make(name, mLogLevel);
82 std::abs(**mRatio), std::arg(**mRatio), **mResistance,
83 **mInductance);
84 return copy;
85}
86
89 return;
90 mSubCompCreated = true;
91
92 // Switch terminals so that terminal 0 is always the higher-voltage side.
93 if (Math::abs(**mRatio) < 1.) {
94 **mRatio = 1. / **mRatio;
95 mRatioAbs = std::abs(**mRatio);
96 mRatioPhase = std::arg(**mRatio);
97 std::shared_ptr<SimTerminal<Complex>> tmp = mTerminals[0];
98 mTerminals[0] = mTerminals[1];
99 mTerminals[1] = tmp;
100 Real tmpVolt = mNominalVoltageEnd1;
102 mNominalVoltageEnd2 = tmpVolt;
103 SPDLOG_LOGGER_INFO(mSLog, "Switching terminals to have first terminal at "
104 "higher voltage side. Updated parameters: ");
105 SPDLOG_LOGGER_INFO(
106 mSLog, "Nominal Voltage End 1 = {} [V] Nominal Voltage End 2 = {} [V]",
108 SPDLOG_LOGGER_INFO(mSLog, "Tap Ratio = {} [ ] Phase Shift = {} [deg]",
109 mRatioAbs, mRatioPhase);
110 }
111
112 // Create series sub components
113 mSubInductor = std::make_shared<SP::Ph1::Inductor>(
114 **mUID + "_ind", **mName + "_ind", Logger::Level::off);
115 mSubInductor->setParameters(**mInductance);
116 addMNASubComponent(mSubInductor, MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
117 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT, true);
118
119 if (mNumVirtualNodes == 3) {
120 mSubResistor = std::make_shared<SP::Ph1::Resistor>(
121 **mUID + "_res", **mName + "_res", Logger::Level::off);
122 mSubResistor->setParameters(**mResistance);
123 mSubResistor->connect({node(0), mVirtualNodes[2]});
124 mSubInductor->connect({mVirtualNodes[2], mVirtualNodes[0]});
125 addMNASubComponent(mSubResistor, MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
126 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT, true);
127 } else {
128 mSubInductor->connect({node(0), mVirtualNodes[0]});
129 }
130
131 // Snubber sub-components created here (existence depends only on mBehaviour); their
132 // omega/power-dependent values are set in initializeParentFromNodesAndTerminals().
133 if (mBehaviour == TopologicalPowerComp::Behaviour::Initialization ||
134 mBehaviour == TopologicalPowerComp::Behaviour::MNASimulation) {
135
136 mSubSnubResistor1 =
137 std::make_shared<SP::Ph1::Resistor>(**mName + "_snub_res1", mLogLevel);
138 mSubSnubResistor1->connect({node(0), SP::SimNode::GND});
139 addMNASubComponent(mSubSnubResistor1,
140 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
141 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT, true);
142
143 mSubSnubResistor2 =
144 std::make_shared<SP::Ph1::Resistor>(**mName + "_snub_res2", mLogLevel);
145 mSubSnubResistor2->connect({node(1), SP::SimNode::GND});
146 addMNASubComponent(mSubSnubResistor2,
147 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
148 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT, true);
149
150 mSubSnubCapacitor2 =
151 std::make_shared<SP::Ph1::Capacitor>(**mName + "_snub_cap2", mLogLevel);
152 mSubSnubCapacitor2->connect({node(1), SP::SimNode::GND});
153 addMNASubComponent(mSubSnubCapacitor2,
154 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
155 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT, true);
156 }
157}
158
160 Real frequency) {
161 mNominalOmega = 2. * PI * frequency;
162 mReactance = mNominalOmega * **mInductance;
163 SPDLOG_LOGGER_INFO(mSLog, "Reactance={} [Ohm] (referred to primary side)",
164 mReactance);
165
166 if (mSubSnubResistor1) {
167 Real pSnub = P_SNUB_TRANSFORMER * **mRatedPower;
168 Real qSnub = Q_SNUB_TRANSFORMER * **mRatedPower;
169
170 // A snubber conductance is added on the higher voltage side
171 mSnubberResistance1 = std::pow(std::abs(mNominalVoltageEnd1), 2) / pSnub;
172 mSubSnubResistor1->setParameters(mSnubberResistance1);
173 SPDLOG_LOGGER_INFO(
174 mSLog,
175 "Snubber Resistance 1 (connected to higher voltage side {}) = {} [Ohm]",
176 node(0)->name(), Logger::realToString(mSnubberResistance1));
177 mSubSnubResistor1->setBaseVoltage(mNominalVoltageEnd1);
178
179 // A snubber conductance is added on the lower voltage side
180 mSnubberResistance2 = std::pow(std::abs(mNominalVoltageEnd2), 2) / pSnub;
181 mSubSnubResistor2->setParameters(mSnubberResistance2);
182 SPDLOG_LOGGER_INFO(
183 mSLog,
184 "Snubber Resistance 2 (connected to lower voltage side {}) = {} [Ohm]",
185 node(1)->name(), Logger::realToString(mSnubberResistance2));
186 mSubSnubResistor2->setBaseVoltage(mNominalVoltageEnd2);
187
188 // // A snubber capacitance is added to higher voltage side (not used as capacitor at high voltage side made it worse)
189 // mSnubberCapacitance1 = qSnub / std::pow(std::abs(mNominalVoltageEnd1),2) / mNominalOmega;
190 // mSubSnubCapacitor1 = std::make_shared<SP::Ph1::Capacitor>(**mName + "_snub_cap1", mLogLevel);
191 // mSubSnubCapacitor1->setParameters(mSnubberCapacitance1);
192 // mSubSnubCapacitor1->connect({ node(0), SP::SimNode::GND });
193 // SPDLOG_LOGGER_INFO(mSLog, "Snubber Capacitance 1 (connected to higher voltage side {}) = \n{} [F] \n ", node(0)->name(), Logger::realToString(mSnubberCapacitance1));
194 // mSubSnubCapacitor1->setBaseVoltage(mNominalVoltageEnd1);
195 // mSubComponents.push_back(mSubSnubCapacitor1);
196
197 // A snubber capacitance is added to lower voltage side
198 mSnubberCapacitance2 =
199 qSnub / std::pow(std::abs(mNominalVoltageEnd2), 2) / mNominalOmega;
200 mSubSnubCapacitor2->setParameters(mSnubberCapacitance2);
201 SPDLOG_LOGGER_INFO(
202 mSLog,
203 "Snubber Capacitance 2 (connected to lower voltage side {}) = {} [F]",
204 node(1)->name(), Logger::realToString(mSnubberCapacitance2));
205 mSubSnubCapacitor2->setBaseVoltage(mNominalVoltageEnd2);
206 }
207
208 // Set initial voltage of virtual node in between
209 mVirtualNodes[0]->setInitialVoltage(initialSingleVoltage(1) * **mRatio);
210
211 // Static calculations from load flow data
212 Complex impedance = {**mResistance, mReactance};
213 (**mIntfVoltage)(0, 0) =
214 mVirtualNodes[0]->initialSingleVoltage() - initialSingleVoltage(0);
215 (**mIntfCurrent)(0, 0) = (**mIntfVoltage)(0, 0) / impedance;
216
217 if (mNumVirtualNodes == 3)
218 mVirtualNodes[2]->setInitialVoltage(initialSingleVoltage(0));
219
220 SPDLOG_LOGGER_INFO(
221 mSLog,
222 "\n--- Initialization from powerflow ---"
223 "\nVoltage across: {:s}"
224 "\nCurrent: {:s}"
225 "\nTerminal 0 voltage: {:s}"
226 "\nTerminal 1 voltage: {:s}"
227 "\nVirtual Node 1 voltage: {:s}"
228 "\n--- Initialization from powerflow finished ---",
229 Logger::phasorToString((**mIntfVoltage)(0, 0)),
230 Logger::phasorToString((**mIntfCurrent)(0, 0)),
231 Logger::phasorToString(initialSingleVoltage(0)),
232 Logger::phasorToString(initialSingleVoltage(1)),
233 Logger::phasorToString(mVirtualNodes[0]->initialSingleVoltage()));
234}
235
236// #### Powerflow section ####
237
241
245
246void SP::Ph1::Transformer::setBaseVoltage(Real baseVoltage) {
247 // Note: to be consistent set base voltage to higher voltage (and impedance values must be referred to high voltage side)
248 // TODO: use attribute setter for setting base voltage
249 **mBaseVoltage = baseVoltage;
250}
251
253 Real baseOmega) {
254 SPDLOG_LOGGER_INFO(mSLog, "#### Calculate Per Unit Parameters for {}",
255 **mName);
256 mBaseApparentPower = baseApparentPower;
257 mBaseOmega = baseOmega;
258 SPDLOG_LOGGER_INFO(mSLog, "Base Power={} [VA] Base Omega={} [1/s]",
259 baseApparentPower, baseOmega);
260
261 mBaseImpedance = **mBaseVoltage * **mBaseVoltage / mBaseApparentPower;
262 mBaseAdmittance = 1.0 / mBaseImpedance;
263 mBaseCurrent = baseApparentPower /
264 (**mBaseVoltage *
265 sqrt(3)); // I_base=(S_threephase/3)/(V_line_to_line/sqrt(3))
266 SPDLOG_LOGGER_INFO(mSLog, "Base Voltage={} [V] Base Impedance={} [Ohm]",
267 **mBaseVoltage, mBaseImpedance);
268
269 mResistancePerUnit = **mResistance / mBaseImpedance;
270 mReactancePerUnit = mReactance / mBaseImpedance;
271 SPDLOG_LOGGER_INFO(mSLog, "Resistance={} [pu] Reactance={} [pu]",
272 mResistancePerUnit, mReactancePerUnit);
273
274 mBaseInductance = mBaseImpedance / mBaseOmega;
275 mInductancePerUnit = **mInductance / mBaseInductance;
276 // omega per unit=1, hence 1.0*mInductancePerUnit.
277 mLeakagePerUnit = Complex(mResistancePerUnit, 1. * mInductancePerUnit);
278 SPDLOG_LOGGER_INFO(mSLog, "Leakage Impedance={} [pu] ", mLeakagePerUnit);
279
280 mRatioAbsPerUnit = mRatioAbs / mNominalVoltageEnd1 * mNominalVoltageEnd2;
281 SPDLOG_LOGGER_INFO(mSLog, "Tap Ratio={} [pu]", mRatioAbsPerUnit);
282
283 // Calculate per unit parameters of subcomps
284 if (mSubSnubResistor1)
285 mSubSnubResistor1->calculatePerUnitParameters(mBaseApparentPower);
286 if (mSubSnubResistor2)
287 mSubSnubResistor2->calculatePerUnitParameters(mBaseApparentPower);
288 if (mSubSnubCapacitor1)
289 mSubSnubCapacitor1->calculatePerUnitParameters(mBaseApparentPower);
290 if (mSubSnubCapacitor2)
291 mSubSnubCapacitor2->calculatePerUnitParameters(mBaseApparentPower);
292}
293
295 SparseMatrixCompRow &Y) {
296 // calculate matrix stamp
297 mY_element = MatrixComp(2, 2);
298 Complex y = Complex(1, 0) / mLeakagePerUnit;
299
300 mY_element(0, 0) = y;
301 mY_element(0, 1) = -y * mRatioAbsPerUnit;
302 mY_element(1, 0) = -y * mRatioAbsPerUnit;
303 mY_element(1, 1) = y * std::pow(mRatioAbsPerUnit, 2);
304
305 //check for inf or nan
306 for (int i = 0; i < 2; i++)
307 for (int j = 0; j < 2; j++)
308 if (std::isinf(mY_element.coeff(i, j).real()) ||
309 std::isinf(mY_element.coeff(i, j).imag())) {
310 std::cout << mY_element << std::endl;
311 std::cout << "Zl:" << mLeakage << std::endl;
312 std::cout << "tap:" << mRatioAbsPerUnit << std::endl;
313 std::stringstream ss;
314 ss << "Transformer>>" << this->name()
315 << ": infinite or nan values in the element Y at: " << i << "," << j;
316 throw std::invalid_argument(ss.str());
317 }
318
319 //set the circuit matrix values
320 Y.coeffRef(this->matrixNodeIndex(0), this->matrixNodeIndex(0)) +=
321 mY_element.coeff(0, 0);
322 Y.coeffRef(this->matrixNodeIndex(0), this->matrixNodeIndex(1)) +=
323 mY_element.coeff(0, 1);
324 Y.coeffRef(this->matrixNodeIndex(1), this->matrixNodeIndex(1)) +=
325 mY_element.coeff(1, 1);
326 Y.coeffRef(this->matrixNodeIndex(1), this->matrixNodeIndex(0)) +=
327 mY_element.coeff(1, 0);
328
329 SPDLOG_LOGGER_INFO(mSLog, "#### Y matrix stamping: {}", mY_element);
330
331 if (mSubSnubResistor1)
332 mSubSnubResistor1->pfApplyAdmittanceMatrixStamp(Y);
333 if (mSubSnubResistor2)
334 mSubSnubResistor2->pfApplyAdmittanceMatrixStamp(Y);
335 if (mSubSnubCapacitor1)
336 mSubSnubCapacitor1->pfApplyAdmittanceMatrixStamp(Y);
337 if (mSubSnubCapacitor2)
338 mSubSnubCapacitor2->pfApplyAdmittanceMatrixStamp(Y);
339}
340
342 VectorComp &powerflow) {
343 **mCurrent = current * mBaseCurrent;
344 **mActivePowerBranch = powerflow.real() * mBaseApparentPower;
345 **mReactivePowerBranch = powerflow.imag() * mBaseApparentPower;
346}
347
348void SP::Ph1::Transformer::storeNodalInjection(Complex powerInjection) {
349 **mActivePowerInjection = std::real(powerInjection) * mBaseApparentPower;
350 **mReactivePowerInjection = std::imag(powerInjection) * mBaseApparentPower;
351}
352
353MatrixComp SP::Ph1::Transformer::Y_element() { return mY_element; }
354
355// #### MNA Section ####
356
358 Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
359 SPDLOG_LOGGER_INFO(
360 mSLog,
361 "\nTerminal 0 connected to {:s} = sim node {:d}"
362 "\nTerminal 1 connected to {:s} = sim node {:d}",
363 mTerminals[0]->node()->name(), mTerminals[0]->node()->matrixNodeIndex(),
364 mTerminals[1]->node()->name(), mTerminals[1]->node()->matrixNodeIndex());
365}
366
368 SparseMatrixRow &systemMatrix) {
369 // Ideal transformer equations
370 if (terminalNotGrounded(0)) {
371 Math::setMatrixElement(systemMatrix, mVirtualNodes[0]->matrixNodeIndex(),
372 mVirtualNodes[1]->matrixNodeIndex(),
373 Complex(-1.0, 0));
374 Math::setMatrixElement(systemMatrix, mVirtualNodes[1]->matrixNodeIndex(),
375 mVirtualNodes[0]->matrixNodeIndex(),
376 Complex(1.0, 0));
377 }
378 if (terminalNotGrounded(1)) {
379 Math::setMatrixElement(systemMatrix, matrixNodeIndex(1),
380 mVirtualNodes[1]->matrixNodeIndex(), **mRatio);
381 Math::setMatrixElement(systemMatrix, mVirtualNodes[1]->matrixNodeIndex(),
382 matrixNodeIndex(1), -**mRatio);
383 }
384
385 // Add subcomps to system matrix
386 for (auto subcomp : mSubComponents)
387 if (auto mnasubcomp = std::dynamic_pointer_cast<MNAInterface>(subcomp))
388 mnasubcomp->mnaApplySystemMatrixStamp(systemMatrix);
389
390 if (terminalNotGrounded(0)) {
391 SPDLOG_LOGGER_INFO(mSLog, "Add {:s} to system at ({:d},{:d})",
392 Logger::complexToString(Complex(-1.0, 0)),
393 mVirtualNodes[0]->matrixNodeIndex(),
394 mVirtualNodes[1]->matrixNodeIndex());
395 SPDLOG_LOGGER_INFO(mSLog, "Add {:s} to system at ({:d},{:d})",
396 Logger::complexToString(Complex(1.0, 0)),
397 mVirtualNodes[1]->matrixNodeIndex(),
398 mVirtualNodes[0]->matrixNodeIndex());
399 }
400 if (terminalNotGrounded(1)) {
401 SPDLOG_LOGGER_INFO(mSLog, "Add {:s} to system at ({:d},{:d})",
402 Logger::complexToString(**mRatio), matrixNodeIndex(1),
403 mVirtualNodes[1]->matrixNodeIndex());
404 SPDLOG_LOGGER_INFO(mSLog, "Add {:s} to system at ({:d},{:d})",
405 Logger::complexToString(-**mRatio),
406 mVirtualNodes[1]->matrixNodeIndex(), matrixNodeIndex(1));
407 }
408}
409
411 AttributeBase::List &prevStepDependencies,
412 AttributeBase::List &attributeDependencies,
413 AttributeBase::List &modifiedAttributes) {
414 prevStepDependencies.push_back(mIntfCurrent);
415 prevStepDependencies.push_back(mIntfVoltage);
416 modifiedAttributes.push_back(mRightVector);
417}
418
422
424 AttributeBase::List &prevStepDependencies,
425 AttributeBase::List &attributeDependencies,
426 AttributeBase::List &modifiedAttributes,
427 Attribute<Matrix>::Ptr &leftVector) {
428 attributeDependencies.push_back(leftVector);
429 modifiedAttributes.push_back(mIntfVoltage);
430 modifiedAttributes.push_back(mIntfCurrent);
431}
432
434 Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector) {
435 this->mnaUpdateVoltage(**leftVector);
436 this->mnaUpdateCurrent(**leftVector);
437}
438
439void SP::Ph1::Transformer::mnaCompUpdateCurrent(const Matrix &leftVector) {
440 (**mIntfCurrent)(0, 0) = mSubInductor->intfCurrent()(0, 0);
441 SPDLOG_LOGGER_DEBUG(mSLog, "Current {:s}",
442 Logger::phasorToString((**mIntfCurrent)(0, 0)));
443}
444
445void SP::Ph1::Transformer::mnaCompUpdateVoltage(const Matrix &leftVector) {
446 // v1 - v0
447 (**mIntfVoltage)(0, 0) = 0;
448 (**mIntfVoltage)(0, 0) =
449 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1));
450 (**mIntfVoltage)(0, 0) = (**mIntfVoltage)(0, 0) -
451 Math::complexFromVectorElement(
452 leftVector, mVirtualNodes[0]->matrixNodeIndex());
453 SPDLOG_LOGGER_DEBUG(mSLog, "Voltage {:s}",
454 Logger::phasorToString((**mIntfVoltage)(0, 0)));
455}
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.