DPsim
Loading...
Searching...
No Matches
PFSolver.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/PFSolver.h>
10#include <dpsim/SequentialScheduler.h>
11#include <iostream>
12
13using namespace DPsim;
14using namespace CPS;
15
16PFSolver::PFSolver(CPS::String name, CPS::SystemTopology system,
17 CPS::Real timeStep, CPS::Logger::Level logLevel)
18 : Solver(name + "_PF", logLevel) {
19 mSystem = system;
20 mTimeStep = timeStep;
21}
22
24 SPDLOG_LOGGER_INFO(mSLog, "#### INITIALIZATION OF POWERFLOW SOLVER ");
25 for (auto comp : mSystem.mComponents) {
26 if (std::shared_ptr<CPS::SP::Ph1::SynchronGenerator> gen =
27 std::dynamic_pointer_cast<CPS::SP::Ph1::SynchronGenerator>(comp))
28 mSynchronGenerators.push_back(gen);
29 else if (std::shared_ptr<CPS::SP::Ph1::Load> load =
30 std::dynamic_pointer_cast<CPS::SP::Ph1::Load>(comp))
31 mLoads.push_back(load);
32 else if (std::shared_ptr<CPS::SP::Ph1::Transformer> trafo =
33 std::dynamic_pointer_cast<CPS::SP::Ph1::Transformer>(comp))
34 mTransformers.push_back(trafo);
35 else if (std::shared_ptr<CPS::SP::Ph1::PiLine> line =
36 std::dynamic_pointer_cast<CPS::SP::Ph1::PiLine>(comp))
37 mLines.push_back(line);
38 else if (std::shared_ptr<CPS::SP::Ph1::NetworkInjection> extnet =
39 std::dynamic_pointer_cast<CPS::SP::Ph1::NetworkInjection>(
40 comp))
41 mExternalGrids.push_back(extnet);
42 else if (std::shared_ptr<CPS::SP::Ph1::Shunt> shunt =
43 std::dynamic_pointer_cast<CPS::SP::Ph1::Shunt>(comp))
44 mShunts.push_back(shunt);
45 else if (std::shared_ptr<CPS::SP::Ph1::SolidStateTransformer> sst =
46 std::dynamic_pointer_cast<CPS::SP::Ph1::SolidStateTransformer>(
47 comp))
48 mSolidStateTransformers.push_back(sst);
49 else if (std::shared_ptr<CPS::SP::Ph1::AvVoltageSourceInverterDQ> vsi =
50 std::dynamic_pointer_cast<
52 mAverageVoltageSourceInverters.push_back(vsi);
53 }
54 }
55
62
64 mX.setZero(mNumUnknowns);
65 mF.setZero(mNumUnknowns);
66}
67
69 SPDLOG_LOGGER_INFO(mSLog, "Assigning simulation nodes to topology nodes:");
70 UInt matrixNodeIndexIdx = 0;
71 for (UInt idx = 0; idx < mSystem.mNodes.size(); ++idx) {
72 mSystem.mNodes[idx]->setMatrixNodeIndex(0, matrixNodeIndexIdx);
73 SPDLOG_LOGGER_INFO(mSLog, "Node {}: MatrixNodeIndex {}",
74 mSystem.mNodes[idx]->uid(),
75 mSystem.mNodes[idx]->matrixNodeIndex());
76 ++matrixNodeIndexIdx;
77 }
78 SPDLOG_LOGGER_INFO(mSLog, "Number of simulation nodes: {:d}",
79 matrixNodeIndexIdx);
80}
81
83 for (auto comp : mSystem.mComponents) {
84 std::dynamic_pointer_cast<SimPowerComp<Complex>>(comp)
85 ->updateMatrixNodeIndices();
86 }
87
88 SPDLOG_LOGGER_INFO(
89 mSLog, "-- Initialize components from terminals or nodes of topology");
90 for (auto comp : mSystem.mComponents) {
91 auto pComp = std::dynamic_pointer_cast<SimPowerComp<Complex>>(comp);
92 if (!pComp)
93 continue;
95 pComp->initializeFromNodesAndTerminals(mSystem.mSystemFrequency);
96 }
97
98 SPDLOG_LOGGER_INFO(mSLog,
99 "-- Calculate per unit parameters for all components");
100 for (auto extnet : mExternalGrids) {
101 extnet->calculatePerUnitParameters(mBaseApparentPower,
102 mSystem.mSystemOmega);
103 }
104 for (auto line : mLines) {
105 line->calculatePerUnitParameters(mBaseApparentPower, mSystem.mSystemOmega);
106 }
107 for (auto trans : mTransformers) {
108 trans->calculatePerUnitParameters(mBaseApparentPower, mSystem.mSystemOmega);
109 }
110 for (auto shunt : mShunts) {
111 shunt->calculatePerUnitParameters(mBaseApparentPower, mSystem.mSystemOmega);
112 }
113 for (auto load : mLoads) {
114 load->calculatePerUnitParameters(mBaseApparentPower, mSystem.mSystemOmega);
115 }
116 for (auto gen : mSynchronGenerators) {
117 gen->calculatePerUnitParameters(mBaseApparentPower, mSystem.mSystemOmega);
118 }
119 for (auto sst : mSolidStateTransformers) {
120 sst->calculatePerUnitParameters(mBaseApparentPower, mSystem.mSystemOmega);
121 }
122}
123
125 Real maxPower = 0.;
126 if (!mSynchronGenerators.empty()) {
127 for (auto gen : mSynchronGenerators)
128 if (std::abs(gen->attributeTyped<Real>("P_set")->get()) > maxPower)
129 maxPower = std::abs(gen->attributeTyped<Real>("P_set")->get());
130 } else if (!mTransformers.empty()) {
131 for (auto trafo : mTransformers)
132 if (trafo->attributeTyped<Real>("S")->get() > maxPower)
133 maxPower = trafo->attributeTyped<Real>("S")->get();
134 }
135 if (maxPower != 0.)
136 mBaseApparentPower = pow(10, 1 + floor(log10(maxPower)));
137 else {
138 mBaseApparentPower = 100000000;
139 SPDLOG_LOGGER_WARN(mSLog,
140 "No suitable quantity found for setting "
141 "mBaseApparentPower. Using {} VA.",
143 }
144 SPDLOG_LOGGER_INFO(mSLog, "Base power = {} VA", mBaseApparentPower);
145}
146
148 mPQBusIndices.clear();
149 mPVBusIndices.clear();
150 mVDBusIndices.clear();
151
152 SPDLOG_LOGGER_INFO(mSLog, "-- Determine powerflow bus type for each node");
153
154 // Determine powerflow bus type of each node through analysis of system topology
155 for (auto node : mSystem.mNodes) {
156 bool connectedPV = false;
157 bool connectedPQ = false;
158 bool connectedVD = false;
159
160 for (auto comp : mSystem.mComponentsAtNode[node]) {
161 if (std::shared_ptr<CPS::SP::Ph1::Load> load =
162 std::dynamic_pointer_cast<CPS::SP::Ph1::Load>(comp)) {
163 if (load->mPowerflowBusType == CPS::PowerflowBusType::PQ) {
164 connectedPQ = true;
165 }
166 } else if (std::shared_ptr<CPS::SP::Ph1::SynchronGenerator> gen =
167 std::dynamic_pointer_cast<CPS::SP::Ph1::SynchronGenerator>(
168 comp)) {
169 if (gen->mPowerflowBusType == CPS::PowerflowBusType::PV) {
170 connectedPV = true;
171 } else if (gen->mPowerflowBusType == CPS::PowerflowBusType::VD) {
172 connectedVD = true;
173 }
174 } else if (std::shared_ptr<CPS::SP::Ph1::NetworkInjection> extnet =
175 std::dynamic_pointer_cast<CPS::SP::Ph1::NetworkInjection>(
176 comp)) {
177 if (extnet->mPowerflowBusType == CPS::PowerflowBusType::VD) {
178 connectedVD = true;
179 } else if (extnet->mPowerflowBusType == CPS::PowerflowBusType::PV) {
180 connectedPV = true;
181 }
182 }
183 }
184
185 // determine powerflow bus types according connected type of connected components
186 // only PQ type component connected -> set as PQ bus
187 if (!connectedPV && connectedPQ && !connectedVD) {
188 SPDLOG_LOGGER_INFO(
189 mSLog, "{}: only PQ type component connected -> set as PQ bus",
190 node->name());
191 mPQBusIndices.push_back(node->matrixNodeIndex());
192 mPQBuses.push_back(node);
193 } // no component connected -> set as PQ bus (P & Q will be zero)
194 else if (!connectedPV && !connectedPQ && !connectedVD) {
195 SPDLOG_LOGGER_INFO(mSLog, "{}: no component connected -> set as PQ bus",
196 node->name());
197 mPQBusIndices.push_back(node->matrixNodeIndex());
198 mPQBuses.push_back(node);
199 } // only PV type component connected -> set as PV bus
200 else if (connectedPV && !connectedPQ && !connectedVD) {
201 SPDLOG_LOGGER_INFO(
202 mSLog, "{}: only PV type component connected -> set as PV bus",
203 node->name());
204 mPVBusIndices.push_back(node->matrixNodeIndex());
205 mPVBuses.push_back(node);
206 } // PV and PQ type component connected -> set as PV bus (TODO: bus type should be modifiable by user afterwards)
207 else if (connectedPV && connectedPQ && !connectedVD) {
208 SPDLOG_LOGGER_INFO(
209 mSLog, "{}: PV and PQ type component connected -> set as PV bus",
210 node->name());
211 mPVBusIndices.push_back(node->matrixNodeIndex());
212 mPVBuses.push_back(node);
213 } // only VD type component connected -> set as VD bus
214 else if (!connectedPV && !connectedPQ && connectedVD) {
215 SPDLOG_LOGGER_INFO(
216 mSLog, "{}: only VD type component connected -> set as VD bus",
217 node->name());
218 mVDBusIndices.push_back(node->matrixNodeIndex());
219 mVDBuses.push_back(node);
220 } // VD and PV type component connect -> set as VD bus
221 else if (connectedPV && !connectedPQ && connectedVD) {
222 SPDLOG_LOGGER_INFO(
223 mSLog, "{}: VD and PV type component connect -> set as VD bus",
224 node->name());
225 mVDBusIndices.push_back(node->matrixNodeIndex());
226 mVDBuses.push_back(node);
227 } // VD, PV and PQ type component connect -> set as VD bus
228 else if (connectedPV && connectedPQ && connectedVD) {
229 SPDLOG_LOGGER_INFO(
230 mSLog, "{}: VD, PV and PQ type component connect -> set as VD bus",
231 node->name());
232 mVDBusIndices.push_back(node->matrixNodeIndex());
233 mVDBuses.push_back(node);
234 } else {
235 std::stringstream ss;
236 ss << "Node>>" << node->name()
237 << ": combination of connected components is invalid";
238 throw std::invalid_argument(ss.str());
239 }
240 }
241
242 mNumPQBuses = mPQBusIndices.size();
243 mNumPVBuses = mPVBusIndices.size();
244 mNumVDBuses = mVDBusIndices.size();
246
247 // Aggregate PQ bus and PV bus index vectors for easy handling in solver
249 mPQPVBusIndices.insert(mPQPVBusIndices.end(), mPQBusIndices.begin(),
250 mPQBusIndices.end());
251 mPQPVBusIndices.insert(mPQPVBusIndices.end(), mPVBusIndices.begin(),
252 mPVBusIndices.end());
253
254 SPDLOG_LOGGER_INFO(mSLog, "#### Create index vectors for power flow solver:");
255 SPDLOG_LOGGER_INFO(mSLog, "PQ Buses: {}", logVector(mPQBusIndices));
256 SPDLOG_LOGGER_INFO(mSLog, "PV Buses: {}", logVector(mPVBusIndices));
257 SPDLOG_LOGGER_INFO(mSLog, "VD Buses: {}", logVector(mVDBusIndices));
258}
259
261
262 SPDLOG_LOGGER_INFO(mSLog, "-- Determine base voltages for each node "
263 "according to connected components");
264 mSLog->flush();
265
266 for (auto node : mSystem.mNodes) {
267 CPS::Real baseVoltage_ = 0;
268 for (auto comp : mSystem.mComponentsAtNode[node]) {
269 if (std::shared_ptr<CPS::SP::Ph1::AvVoltageSourceInverterDQ> vsi =
270 std::dynamic_pointer_cast<
272 baseVoltage_ = vsi->getNomVoltage();
273 SPDLOG_LOGGER_INFO(
274 mSLog,
275 "Choose base voltage {}V of {} to convert pu-solution of {}.",
276 baseVoltage_, vsi->name(), node->name());
277 break;
278 } else if (std::shared_ptr<CPS::SP::Ph1::RXLine> rxline =
279 std::dynamic_pointer_cast<CPS::SP::Ph1::RXLine>(comp)) {
280 baseVoltage_ = rxline->getBaseVoltage();
281 SPDLOG_LOGGER_INFO(
282 mSLog,
283 "Choose base voltage {}V of {} to convert pu-solution of {}.",
284 baseVoltage_, rxline->name(), node->name());
285 break;
286 } else if (std::shared_ptr<CPS::SP::Ph1::PiLine> line =
287 std::dynamic_pointer_cast<CPS::SP::Ph1::PiLine>(comp)) {
288 baseVoltage_ = line->getBaseVoltage();
289 SPDLOG_LOGGER_INFO(
290 mSLog,
291 "Choose base voltage {}V of {} to convert pu-solution of {}.",
292 baseVoltage_, line->name(), node->name());
293 break;
294 } else if (std::shared_ptr<CPS::SP::Ph1::Transformer> trans =
295 std::dynamic_pointer_cast<CPS::SP::Ph1::Transformer>(
296 comp)) {
297 if (trans->terminal(0)->node()->name() == node->name()) {
298 baseVoltage_ = trans->getNominalVoltageEnd1();
299 SPDLOG_LOGGER_INFO(
300 mSLog,
301 "Choose base voltage {}V of {} to convert pu-solution of {}.",
302 baseVoltage_, trans->name(), node->name());
303 break;
304 } else if (trans->terminal(1)->node()->name() == node->name()) {
305 baseVoltage_ = trans->getNominalVoltageEnd2();
306 SPDLOG_LOGGER_INFO(
307 mSLog,
308 "Choose base voltage {}V of {} to convert pu-solution of {}.",
309 baseVoltage_, trans->name(), node->name());
310 break;
311 }
312 } else if (std::shared_ptr<CPS::SP::Ph1::SynchronGenerator> gen =
313 std::dynamic_pointer_cast<CPS::SP::Ph1::SynchronGenerator>(
314 comp)) {
315 baseVoltage_ = gen->getBaseVoltage();
316 SPDLOG_LOGGER_INFO(
317 mSLog,
318 "Choose base voltage {}V of {} to convert pu-solution of {}.",
319 baseVoltage_, gen->name(), node->name());
320 break;
321 } else if (std::shared_ptr<CPS::SP::Ph1::Load> load =
322 std::dynamic_pointer_cast<CPS::SP::Ph1::Load>(comp)) {
323 baseVoltage_ = load->getNomVoltage();
324 SPDLOG_LOGGER_INFO(
325 mSLog, "Choose base voltage of {} V to convert pu-solution of {}.",
326 baseVoltage_, load->name(), node->name());
327 break;
328 } else if (std::shared_ptr<CPS::SP::Ph1::NetworkInjection> extnet =
329 std::dynamic_pointer_cast<CPS::SP::Ph1::NetworkInjection>(
330 comp)) {
331 baseVoltage_ = extnet->getBaseVoltage();
332 SPDLOG_LOGGER_INFO(
333 mSLog, "Choose base voltage of {}V to convert pu-solution of {}.",
334 baseVoltage_, extnet->name(), node->name());
335 break;
336 } else {
337 SPDLOG_LOGGER_WARN(mSLog, "Unable to get base voltage at {}",
338 node->name());
339 }
340 }
341 mBaseVoltageAtNode[node] = baseVoltage_;
342 }
343}
344
345void PFSolver::setVDNode(CPS::String name) {
346 if (!mExternalGrids.empty()) {
347 if (mExternalGrids[0]->node(0)->name() == name) {
348 mExternalGrids[0]->modifyPowerFlowBusType(CPS::PowerflowBusType::VD);
349 }
350 } else {
351 for (auto gen : mSynchronGenerators) {
352 if (gen->node(0)->name() == name) {
353 gen->modifyPowerFlowBusType(CPS::PowerflowBusType::VD);
354 return;
355 }
356 }
357 throw std::invalid_argument("Invalid slack bus, no external grid or "
358 "synchronous generator attached");
359 }
360}
361
363 CPS::String name, CPS::PowerflowBusType powerFlowBusType) {
364 for (auto comp : mSystem.mComponents) {
365 if (comp->name() == name) {
366 if (std::shared_ptr<CPS::SP::Ph1::NetworkInjection> extnet =
367 std::dynamic_pointer_cast<CPS::SP::Ph1::NetworkInjection>(comp))
368 extnet->modifyPowerFlowBusType(powerFlowBusType);
369 else if (std::shared_ptr<CPS::SP::Ph1::SynchronGenerator> gen =
370 std::dynamic_pointer_cast<CPS::SP::Ph1::SynchronGenerator>(
371 comp))
372 gen->modifyPowerFlowBusType(powerFlowBusType);
373 }
374 }
375}
376
377void PFSolver::setSolverAndComponentBehaviour(Solver::Behaviour behaviour) {
378 mBehaviour = behaviour;
379 if (mBehaviour == Behaviour::Initialization) {
380 SPDLOG_LOGGER_INFO(mSLog, "-- Set solver behaviour to Initialization");
381 // TODO: solver setting specific to initialization (e.g. one single PF run)
382
383 SPDLOG_LOGGER_INFO(mSLog, "-- Set component behaviour to Initialization");
384 for (auto comp : mSystem.mComponents) {
385 auto powerComp =
386 std::dynamic_pointer_cast<CPS::TopologicalPowerComp>(comp);
387 if (powerComp)
388 powerComp->setBehaviour(
389 TopologicalPowerComp::Behaviour::Initialization);
390 }
391 } else {
392 SPDLOG_LOGGER_INFO(mSLog, "-- Set solver behaviour to Simulation");
393 // TODO: solver setting specific to simulation
394
395 SPDLOG_LOGGER_INFO(mSLog, "-- Set component behaviour to PFSimulation");
396 for (auto comp : mSystem.mComponents) {
397 auto powerComp =
398 std::dynamic_pointer_cast<CPS::TopologicalPowerComp>(comp);
399 if (powerComp)
400 powerComp->setBehaviour(TopologicalPowerComp::Behaviour::PFSimulation);
401 }
402 }
403}
404
406 int n = mSystem.mNodes.size();
407 if (n > 0) {
408 mY = CPS::SparseMatrixComp(n, n);
409 for (auto line : mLines) {
410 line->pfApplyAdmittanceMatrixStamp(mY);
411 }
412 for (auto trans : mTransformers) {
413 //to check if this transformer could be ignored
414 if (**trans->mResistance == 0 && **trans->mInductance == 0) {
415 SPDLOG_LOGGER_INFO(mSLog, "{} {} ignored for R = 0 and L = 0",
416 trans->type(), trans->name());
417 continue;
418 }
419 trans->pfApplyAdmittanceMatrixStamp(mY);
420 }
421 for (auto shunt : mShunts) {
422 shunt->pfApplyAdmittanceMatrixStamp(mY);
423 }
424 }
425 if (mLines.empty() && mTransformers.empty()) {
426 throw std::invalid_argument("There are no bus");
427 }
428}
429
430CPS::Real PFSolver::G(int i, int j) { return mY.coeff(i, j).real(); }
431
432CPS::Real PFSolver::B(int i, int j) { return mY.coeff(i, j).imag(); }
433
435 // Converged if all mismatches are below the tolerance
436 for (CPS::UInt i = 0; i < mNumUnknowns; i++) {
437 if (abs(mF(i)) > mTolerance)
438 return false;
439 }
440 return true;
441}
442
444 // Calculate the mismatch according to the initial solution
446
447 // Check whether model already converged
449
450 mIterations = 0;
451 for (unsigned i = 1; i < mMaxIterations && !isConverged; ++i) {
452
454 auto sparseJ = mJ.sparseView();
455
456 // Solve system mJ*mX = mF
457 Eigen::SparseLU<SparseMatrix> lu(sparseJ);
458
459 mX = lu.solve(mF); /* code */
460
461 // Calculate new solution based on mX increments obtained from equation system
463
464 // Calculate the mismatch according to the current solution
466
467 SPDLOG_LOGGER_DEBUG(mSLog, "Mismatch vector at iteration {}: \n {}", i, mF);
468 mSLog->flush();
469
470 // Check convergence
472 mIterations = i;
473 }
474 return isConverged;
475}
476
477void PFSolver::SolveTask::execute(Real time, Int timeStepCount) {
478 // apply keepLastSolution to save computation time
479 mSolver.generateInitialSolution(time);
480 mSolver.solvePowerflow();
481 mSolver.setSolution();
482}
483
484Task::List PFSolver::getTasks() {
485 return Task::List{std::make_shared<SolveTask>(*this)};
486}
void determinePFBusType()
Determine bus type for all buses.
Definition PFSolver.cpp:147
std::vector< std::shared_ptr< CPS::SP::Ph1::Load > > mLoads
Vector of load components.
Definition PFSolver.h:67
CPS::TopologicalNode::List mPQBuses
Vector of nodes characterized as PQ buses.
Definition PFSolver.h:32
UInt mNumPQBuses
Number of PQ nodes.
Definition PFSolver.h:24
UInt mNumVDBuses
Number of PV nodes.
Definition PFSolver.h:28
Real mTolerance
Solver tolerance.
Definition PFSolver.h:81
CPS::String logVector(std::vector< CPS::UInt > indexVector)
Logging for integer vectors.
Definition PFSolver.h:131
std::vector< std::shared_ptr< CPS::SP::Ph1::PiLine > > mLines
Vector of line components.
Definition PFSolver.h:69
CPS::Task::List getTasks() override
Get tasks for scheduler.
Definition PFSolver.cpp:484
void assignMatrixNodeIndices()
Assignment of matrix indices for nodes.
Definition PFSolver.cpp:68
std::vector< CPS::UInt > mVDBusIndices
Vector with indices of VD buses.
Definition PFSolver.h:42
void initializeComponents()
Initialization of individual components.
Definition PFSolver.cpp:82
std::vector< std::shared_ptr< CPS::SP::Ph1::SynchronGenerator > > mSynchronGenerators
Vector of synchronous generator components.
Definition PFSolver.h:65
std::vector< CPS::UInt > mPQBusIndices
Vector with indices of PQ buses.
Definition PFSolver.h:38
void modifyPowerFlowBusComponent(CPS::String name, CPS::PowerflowBusType powerFlowBusType)
Allows to modify the powerflow bus type of a specific component.
Definition PFSolver.cpp:362
std::vector< std::shared_ptr< CPS::SP::Ph1::NetworkInjection > > mExternalGrids
Vector of external grid components.
Definition PFSolver.h:73
std::vector< std::shared_ptr< CPS::SP::Ph1::SolidStateTransformer > > mSolidStateTransformers
Vector of solid state transformer components.
Definition PFSolver.h:62
std::vector< CPS::UInt > mPVBusIndices
Vector with indices of PV buses.
Definition PFSolver.h:40
void setVDNode(CPS::String name)
Set a node to VD using its name.
Definition PFSolver.cpp:345
std::vector< std::shared_ptr< CPS::SP::Ph1::Transformer > > mTransformers
Vector of transformer components.
Definition PFSolver.h:59
std::vector< std::shared_ptr< CPS::SP::Ph1::Shunt > > mShunts
Vector of shunt components.
Definition PFSolver.h:71
CPS::Bool checkConvergence()
Check whether below tolerance.
Definition PFSolver.cpp:434
CPS::Matrix mJ
Jacobian matrix.
Definition PFSolver.h:50
CPS::UInt mMaxIterations
Maximum number of iterations.
Definition PFSolver.h:83
CPS::Vector mX
Solution vector.
Definition PFSolver.h:52
std::vector< std::shared_ptr< CPS::SP::Ph1::AvVoltageSourceInverterDQ > > mAverageVoltageSourceInverters
Vector of average voltage source inverters.
Definition PFSolver.h:76
CPS::Real mBaseApparentPower
Base power of per-unit system.
Definition PFSolver.h:87
void setBaseApparentPower()
Set apparent base power of per-unit system.
Definition PFSolver.cpp:124
virtual void calculateMismatch()=0
Calculate mismatch.
CPS::SparseMatrixCompRow mY
Admittance matrix.
Definition PFSolver.h:47
UInt mNumPVBuses
Number of PV nodes.
Definition PFSolver.h:26
CPS::Real B(int i, int j)
Gets the imaginary part of admittance matrix element.
Definition PFSolver.cpp:432
void composeAdmittanceMatrix()
Compose admittance matrix.
Definition PFSolver.cpp:405
CPS::Bool isConverged
Convergence flag.
Definition PFSolver.h:89
CPS::Vector mF
Vector of mismatch values.
Definition PFSolver.h:54
CPS::UInt mIterations
Actual number of iterations.
Definition PFSolver.h:85
PFSolver(CPS::String name, CPS::SystemTopology system, Real timeStep, CPS::Logger::Level logLevel)
Constructor to be used in simulation examples.
Definition PFSolver.cpp:16
CPS::SystemTopology mSystem
System list.
Definition PFSolver.h:57
virtual void calculateJacobian()=0
Calculate the Jacobian.
void determineNodeBaseVoltages()
Determine base voltages for each node.
Definition PFSolver.cpp:260
void setSolverAndComponentBehaviour(Solver::Behaviour behaviour) override
set solver and component to initialization or simulation behaviour
Definition PFSolver.cpp:377
std::map< CPS::TopologicalNode::Ptr, CPS::Real > mBaseVoltageAtNode
Map providing determined base voltages for each node.
Definition PFSolver.h:78
virtual void setSolution()=0
Set final solution.
void initialize() override
Initialization of the solver.
Definition PFSolver.cpp:23
virtual void generateInitialSolution(Real time, bool keep_last_solution=false)=0
Generate initial solution for current time step.
virtual void updateSolution()=0
Update solution in each iteration.
Bool solvePowerflow()
Solves the powerflow problem.
Definition PFSolver.cpp:443
CPS::TopologicalNode::List mVDBuses
Vector of nodes characterized as VD buses.
Definition PFSolver.h:36
CPS::TopologicalNode::List mPVBuses
Vector of nodes characterized as PV buses.
Definition PFSolver.h:34
UInt mNumUnknowns
Number of unknowns, defining system dimension.
Definition PFSolver.h:30
CPS::Real G(int i, int j)
Gets the real part of admittance matrix element.
Definition PFSolver.cpp:430
std::vector< CPS::UInt > mPQPVBusIndices
Vector with indices of both PQ and PV buses.
Definition PFSolver.h:44
Real mTimeStep
Time step for fixed step solvers.
Definition Solver.h:47
Behaviour mBehaviour
Solver behaviour initialization or simulation.
Definition Solver.h:67
CPS::Logger::Log mSLog
Logger.
Definition Solver.h:45
Bool mInitFromNodesAndTerminals
Definition Solver.h:62