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
88 mNominalOmega = 2. * PI * frequency;
89 mReactance = mNominalOmega * **mInductance;
90 SPDLOG_LOGGER_INFO(mSLog, "Reactance={} [Ohm] (referred to primary side)",
91 mReactance);
92
93 // Component parameters are referred to higher voltage side.
94 // Switch terminals to have terminal 0 at higher voltage side
95 // if transformer is connected the other way around.
96 if (Math::abs(**mRatio) < 1.) {
97 **mRatio = 1. / **mRatio;
98 mRatioAbs = std::abs(**mRatio);
99 mRatioPhase = std::arg(**mRatio);
100 std::shared_ptr<SimTerminal<Complex>> tmp = mTerminals[0];
101 mTerminals[0] = mTerminals[1];
102 mTerminals[1] = tmp;
103 Real tmpVolt = mNominalVoltageEnd1;
105 mNominalVoltageEnd2 = tmpVolt;
106 SPDLOG_LOGGER_INFO(mSLog, "Switching terminals to have first terminal at "
107 "higher voltage side. Updated parameters: ");
108 SPDLOG_LOGGER_INFO(
109 mSLog, "Nominal Voltage End 1 = {} [V] Nominal Voltage End 2 = {} [V]",
111 SPDLOG_LOGGER_INFO(mSLog, "Tap Ratio = {} [ ] Phase Shift = {} [deg]",
112 mRatioAbs, mRatioPhase);
113 }
114
115 // Set initial voltage of virtual node in between
116 mVirtualNodes[0]->setInitialVoltage(initialSingleVoltage(1) * **mRatio);
117
118 // Static calculations from load flow data
119 Complex impedance = {**mResistance, mReactance};
120 (**mIntfVoltage)(0, 0) =
121 mVirtualNodes[0]->initialSingleVoltage() - initialSingleVoltage(0);
122 (**mIntfCurrent)(0, 0) = (**mIntfVoltage)(0, 0) / impedance;
123
124 // Create series sub components
125 mSubInductor = std::make_shared<SP::Ph1::Inductor>(
126 **mUID + "_ind", **mName + "_ind", Logger::Level::off);
127 mSubInductor->setParameters(**mInductance);
128 addMNASubComponent(mSubInductor, MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
129 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT, true);
130
131 if (mNumVirtualNodes == 3) {
132 mVirtualNodes[2]->setInitialVoltage(initialSingleVoltage(0));
133 mSubResistor = std::make_shared<SP::Ph1::Resistor>(
134 **mUID + "_res", **mName + "_res", Logger::Level::off);
135 mSubResistor->setParameters(**mResistance);
136 mSubResistor->connect({node(0), mVirtualNodes[2]});
137 mSubInductor->connect({mVirtualNodes[2], mVirtualNodes[0]});
138 addMNASubComponent(mSubResistor, MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
139 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT, true);
140 } else {
141 mSubInductor->connect({node(0), mVirtualNodes[0]});
142 }
143
144 // Create parallel sub components for init and mna behaviour
145 if (mBehaviour == TopologicalPowerComp::Behaviour::Initialization ||
146 mBehaviour == TopologicalPowerComp::Behaviour::MNASimulation) {
147
148 Real pSnub = P_SNUB_TRANSFORMER * **mRatedPower;
149 Real qSnub = Q_SNUB_TRANSFORMER * **mRatedPower;
150
151 // A snubber conductance is added on the higher voltage side
152 mSnubberResistance1 = std::pow(std::abs(mNominalVoltageEnd1), 2) / pSnub;
153 mSubSnubResistor1 =
154 std::make_shared<SP::Ph1::Resistor>(**mName + "_snub_res1", mLogLevel);
155 mSubSnubResistor1->setParameters(mSnubberResistance1);
156 mSubSnubResistor1->connect({node(0), SP::SimNode::GND});
157 SPDLOG_LOGGER_INFO(
158 mSLog,
159 "Snubber Resistance 1 (connected to higher voltage side {}) = {} [Ohm]",
160 node(0)->name(), Logger::realToString(mSnubberResistance1));
161 mSubSnubResistor1->setBaseVoltage(mNominalVoltageEnd1);
162 addMNASubComponent(mSubSnubResistor1,
163 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
164 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT, true);
165
166 // A snubber conductance is added on the lower voltage side
167 mSnubberResistance2 = std::pow(std::abs(mNominalVoltageEnd2), 2) / pSnub;
168 mSubSnubResistor2 =
169 std::make_shared<SP::Ph1::Resistor>(**mName + "_snub_res2", mLogLevel);
170 mSubSnubResistor2->setParameters(mSnubberResistance2);
171 mSubSnubResistor2->connect({node(1), SP::SimNode::GND});
172 SPDLOG_LOGGER_INFO(
173 mSLog,
174 "Snubber Resistance 2 (connected to lower voltage side {}) = {} [Ohm]",
175 node(1)->name(), Logger::realToString(mSnubberResistance2));
176 mSubSnubResistor2->setBaseVoltage(mNominalVoltageEnd2);
177 addMNASubComponent(mSubSnubResistor2,
178 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
179 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT, true);
180
181 // // A snubber capacitance is added to higher voltage side (not used as capacitor at high voltage side made it worse)
182 // mSnubberCapacitance1 = qSnub / std::pow(std::abs(mNominalVoltageEnd1),2) / mNominalOmega;
183 // mSubSnubCapacitor1 = std::make_shared<SP::Ph1::Capacitor>(**mName + "_snub_cap1", mLogLevel);
184 // mSubSnubCapacitor1->setParameters(mSnubberCapacitance1);
185 // mSubSnubCapacitor1->connect({ node(0), SP::SimNode::GND });
186 // SPDLOG_LOGGER_INFO(mSLog, "Snubber Capacitance 1 (connected to higher voltage side {}) = \n{} [F] \n ", node(0)->name(), Logger::realToString(mSnubberCapacitance1));
187 // mSubSnubCapacitor1->setBaseVoltage(mNominalVoltageEnd1);
188 // mSubComponents.push_back(mSubSnubCapacitor1);
189
190 // A snubber capacitance is added to lower voltage side
191 mSnubberCapacitance2 =
192 qSnub / std::pow(std::abs(mNominalVoltageEnd2), 2) / mNominalOmega;
193 mSubSnubCapacitor2 =
194 std::make_shared<SP::Ph1::Capacitor>(**mName + "_snub_cap2", mLogLevel);
195 mSubSnubCapacitor2->setParameters(mSnubberCapacitance2);
196 mSubSnubCapacitor2->connect({node(1), SP::SimNode::GND});
197 SPDLOG_LOGGER_INFO(
198 mSLog,
199 "Snubber Capacitance 2 (connected to lower voltage side {}) = {} [F]",
200 node(1)->name(), Logger::realToString(mSnubberCapacitance2));
201 mSubSnubCapacitor2->setBaseVoltage(mNominalVoltageEnd2);
202 addMNASubComponent(mSubSnubCapacitor2,
203 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
204 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT, true);
205 }
206
207 // Initialize electrical subcomponents
208 SPDLOG_LOGGER_INFO(mSLog, "Electrical subcomponents: ");
209 for (auto subcomp : mSubComponents) {
210 SPDLOG_LOGGER_INFO(mSLog, "- {}", subcomp->name());
211 subcomp->initialize(mFrequencies);
212 subcomp->initializeFromNodesAndTerminals(frequency);
213 }
214
215 SPDLOG_LOGGER_INFO(
216 mSLog,
217 "\n--- Initialization from powerflow ---"
218 "\nVoltage across: {:s}"
219 "\nCurrent: {:s}"
220 "\nTerminal 0 voltage: {:s}"
221 "\nTerminal 1 voltage: {:s}"
222 "\nVirtual Node 1 voltage: {:s}"
223 "\n--- Initialization from powerflow finished ---",
224 Logger::phasorToString((**mIntfVoltage)(0, 0)),
225 Logger::phasorToString((**mIntfCurrent)(0, 0)),
226 Logger::phasorToString(initialSingleVoltage(0)),
227 Logger::phasorToString(initialSingleVoltage(1)),
228 Logger::phasorToString(mVirtualNodes[0]->initialSingleVoltage()));
229}
230
231// #### Powerflow section ####
232
236
240
241void SP::Ph1::Transformer::setBaseVoltage(Real baseVoltage) {
242 // Note: to be consistent set base voltage to higher voltage (and impedance values must be referred to high voltage side)
243 // TODO: use attribute setter for setting base voltage
244 **mBaseVoltage = baseVoltage;
245}
246
248 Real baseOmega) {
249 SPDLOG_LOGGER_INFO(mSLog, "#### Calculate Per Unit Parameters for {}",
250 **mName);
251 mBaseApparentPower = baseApparentPower;
252 mBaseOmega = baseOmega;
253 SPDLOG_LOGGER_INFO(mSLog, "Base Power={} [VA] Base Omega={} [1/s]",
254 baseApparentPower, baseOmega);
255
256 mBaseImpedance = **mBaseVoltage * **mBaseVoltage / mBaseApparentPower;
257 mBaseAdmittance = 1.0 / mBaseImpedance;
258 mBaseCurrent = baseApparentPower /
259 (**mBaseVoltage *
260 sqrt(3)); // I_base=(S_threephase/3)/(V_line_to_line/sqrt(3))
261 SPDLOG_LOGGER_INFO(mSLog, "Base Voltage={} [V] Base Impedance={} [Ohm]",
262 **mBaseVoltage, mBaseImpedance);
263
264 mResistancePerUnit = **mResistance / mBaseImpedance;
265 mReactancePerUnit = mReactance / mBaseImpedance;
266 SPDLOG_LOGGER_INFO(mSLog, "Resistance={} [pu] Reactance={} [pu]",
267 mResistancePerUnit, mReactancePerUnit);
268
269 mBaseInductance = mBaseImpedance / mBaseOmega;
270 mInductancePerUnit = **mInductance / mBaseInductance;
271 // omega per unit=1, hence 1.0*mInductancePerUnit.
272 mLeakagePerUnit = Complex(mResistancePerUnit, 1. * mInductancePerUnit);
273 SPDLOG_LOGGER_INFO(mSLog, "Leakage Impedance={} [pu] ", mLeakagePerUnit);
274
275 mRatioAbsPerUnit = mRatioAbs / mNominalVoltageEnd1 * mNominalVoltageEnd2;
276 SPDLOG_LOGGER_INFO(mSLog, "Tap Ratio={} [pu]", mRatioAbsPerUnit);
277
278 // Calculate per unit parameters of subcomps
279 if (mSubSnubResistor1)
280 mSubSnubResistor1->calculatePerUnitParameters(mBaseApparentPower);
281 if (mSubSnubResistor2)
282 mSubSnubResistor2->calculatePerUnitParameters(mBaseApparentPower);
283 if (mSubSnubCapacitor1)
284 mSubSnubCapacitor1->calculatePerUnitParameters(mBaseApparentPower);
285 if (mSubSnubCapacitor2)
286 mSubSnubCapacitor2->calculatePerUnitParameters(mBaseApparentPower);
287}
288
290 SparseMatrixCompRow &Y) {
291 // calculate matrix stamp
292 mY_element = MatrixComp(2, 2);
293 Complex y = Complex(1, 0) / mLeakagePerUnit;
294
295 mY_element(0, 0) = y;
296 mY_element(0, 1) = -y * mRatioAbsPerUnit;
297 mY_element(1, 0) = -y * mRatioAbsPerUnit;
298 mY_element(1, 1) = y * std::pow(mRatioAbsPerUnit, 2);
299
300 //check for inf or nan
301 for (int i = 0; i < 2; i++)
302 for (int j = 0; j < 2; j++)
303 if (std::isinf(mY_element.coeff(i, j).real()) ||
304 std::isinf(mY_element.coeff(i, j).imag())) {
305 std::cout << mY_element << std::endl;
306 std::cout << "Zl:" << mLeakage << std::endl;
307 std::cout << "tap:" << mRatioAbsPerUnit << std::endl;
308 std::stringstream ss;
309 ss << "Transformer>>" << this->name()
310 << ": infinite or nan values in the element Y at: " << i << "," << j;
311 throw std::invalid_argument(ss.str());
312 }
313
314 //set the circuit matrix values
315 Y.coeffRef(this->matrixNodeIndex(0), this->matrixNodeIndex(0)) +=
316 mY_element.coeff(0, 0);
317 Y.coeffRef(this->matrixNodeIndex(0), this->matrixNodeIndex(1)) +=
318 mY_element.coeff(0, 1);
319 Y.coeffRef(this->matrixNodeIndex(1), this->matrixNodeIndex(1)) +=
320 mY_element.coeff(1, 1);
321 Y.coeffRef(this->matrixNodeIndex(1), this->matrixNodeIndex(0)) +=
322 mY_element.coeff(1, 0);
323
324 SPDLOG_LOGGER_INFO(mSLog, "#### Y matrix stamping: {}", mY_element);
325
326 if (mSubSnubResistor1)
327 mSubSnubResistor1->pfApplyAdmittanceMatrixStamp(Y);
328 if (mSubSnubResistor2)
329 mSubSnubResistor2->pfApplyAdmittanceMatrixStamp(Y);
330 if (mSubSnubCapacitor1)
331 mSubSnubCapacitor1->pfApplyAdmittanceMatrixStamp(Y);
332 if (mSubSnubCapacitor2)
333 mSubSnubCapacitor2->pfApplyAdmittanceMatrixStamp(Y);
334}
335
337 VectorComp &powerflow) {
338 **mCurrent = current * mBaseCurrent;
339 **mActivePowerBranch = powerflow.real() * mBaseApparentPower;
340 **mReactivePowerBranch = powerflow.imag() * mBaseApparentPower;
341}
342
343void SP::Ph1::Transformer::storeNodalInjection(Complex powerInjection) {
344 **mActivePowerInjection = std::real(powerInjection) * mBaseApparentPower;
345 **mReactivePowerInjection = std::imag(powerInjection) * mBaseApparentPower;
346}
347
348MatrixComp SP::Ph1::Transformer::Y_element() { return mY_element; }
349
350// #### MNA Section ####
351
353 Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
354 SPDLOG_LOGGER_INFO(
355 mSLog,
356 "\nTerminal 0 connected to {:s} = sim node {:d}"
357 "\nTerminal 1 connected to {:s} = sim node {:d}",
358 mTerminals[0]->node()->name(), mTerminals[0]->node()->matrixNodeIndex(),
359 mTerminals[1]->node()->name(), mTerminals[1]->node()->matrixNodeIndex());
360}
361
363 SparseMatrixRow &systemMatrix) {
364 // Ideal transformer equations
365 if (terminalNotGrounded(0)) {
366 Math::setMatrixElement(systemMatrix, mVirtualNodes[0]->matrixNodeIndex(),
367 mVirtualNodes[1]->matrixNodeIndex(),
368 Complex(-1.0, 0));
369 Math::setMatrixElement(systemMatrix, mVirtualNodes[1]->matrixNodeIndex(),
370 mVirtualNodes[0]->matrixNodeIndex(),
371 Complex(1.0, 0));
372 }
373 if (terminalNotGrounded(1)) {
374 Math::setMatrixElement(systemMatrix, matrixNodeIndex(1),
375 mVirtualNodes[1]->matrixNodeIndex(), **mRatio);
376 Math::setMatrixElement(systemMatrix, mVirtualNodes[1]->matrixNodeIndex(),
377 matrixNodeIndex(1), -**mRatio);
378 }
379
380 // Add subcomps to system matrix
381 for (auto subcomp : mSubComponents)
382 if (auto mnasubcomp = std::dynamic_pointer_cast<MNAInterface>(subcomp))
383 mnasubcomp->mnaApplySystemMatrixStamp(systemMatrix);
384
385 if (terminalNotGrounded(0)) {
386 SPDLOG_LOGGER_INFO(mSLog, "Add {:s} to system at ({:d},{:d})",
387 Logger::complexToString(Complex(-1.0, 0)),
388 mVirtualNodes[0]->matrixNodeIndex(),
389 mVirtualNodes[1]->matrixNodeIndex());
390 SPDLOG_LOGGER_INFO(mSLog, "Add {:s} to system at ({:d},{:d})",
391 Logger::complexToString(Complex(1.0, 0)),
392 mVirtualNodes[1]->matrixNodeIndex(),
393 mVirtualNodes[0]->matrixNodeIndex());
394 }
395 if (terminalNotGrounded(1)) {
396 SPDLOG_LOGGER_INFO(mSLog, "Add {:s} to system at ({:d},{:d})",
397 Logger::complexToString(**mRatio), matrixNodeIndex(1),
398 mVirtualNodes[1]->matrixNodeIndex());
399 SPDLOG_LOGGER_INFO(mSLog, "Add {:s} to system at ({:d},{:d})",
400 Logger::complexToString(-**mRatio),
401 mVirtualNodes[1]->matrixNodeIndex(), matrixNodeIndex(1));
402 }
403}
404
406 AttributeBase::List &prevStepDependencies,
407 AttributeBase::List &attributeDependencies,
408 AttributeBase::List &modifiedAttributes) {
409 prevStepDependencies.push_back(mIntfCurrent);
410 prevStepDependencies.push_back(mIntfVoltage);
411 modifiedAttributes.push_back(mRightVector);
412}
413
417
419 AttributeBase::List &prevStepDependencies,
420 AttributeBase::List &attributeDependencies,
421 AttributeBase::List &modifiedAttributes,
422 Attribute<Matrix>::Ptr &leftVector) {
423 attributeDependencies.push_back(leftVector);
424 modifiedAttributes.push_back(mIntfVoltage);
425 modifiedAttributes.push_back(mIntfCurrent);
426}
427
429 Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector) {
430 this->mnaUpdateVoltage(**leftVector);
431 this->mnaUpdateCurrent(**leftVector);
432}
433
434void SP::Ph1::Transformer::mnaCompUpdateCurrent(const Matrix &leftVector) {
435 (**mIntfCurrent)(0, 0) = mSubInductor->intfCurrent()(0, 0);
436 SPDLOG_LOGGER_DEBUG(mSLog, "Current {:s}",
437 Logger::phasorToString((**mIntfCurrent)(0, 0)));
438}
439
440void SP::Ph1::Transformer::mnaCompUpdateVoltage(const Matrix &leftVector) {
441 // v1 - v0
442 (**mIntfVoltage)(0, 0) = 0;
443 (**mIntfVoltage)(0, 0) =
444 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1));
445 (**mIntfVoltage)(0, 0) = (**mIntfVoltage)(0, 0) -
446 Math::complexFromVectorElement(
447 leftVector, mVirtualNodes[0]->matrixNodeIndex());
448 SPDLOG_LOGGER_DEBUG(mSLog, "Voltage {:s}",
449 Logger::phasorToString((**mIntfVoltage)(0, 0)));
450}
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.
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.
void initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
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.