DPsim
Loading...
Searching...
No Matches
PFSolverPowerPolar.h
Go to the documentation of this file.
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#pragma once
10
11#include <map>
12
13#include <dpsim/PFSolver.h>
14
15namespace DPsim {
18protected:
31
34
35 // Cache for last converged solution
39
40 // Core methods
43 bool keep_last_solution = false) override;
45 void calculateJacobian() override;
47 void updateSolution() override;
49 void setSolution() override;
51 void calculateMismatch() override;
52
53 // Helper methods
55 void resize_sol(CPS::Int n);
79 void clearReactiveLimitState() override;
81 std::map<CPS::TopologicalNode::Ptr, bool> mQLimitConvertedAtMax;
83 std::map<CPS::TopologicalNode::Ptr, CPS::UInt> mQLimitSwitchCount;
90
91public:
94 CPS::Real timeStep, CPS::Logger::Level logLevel);
97};
98} // namespace DPsim
spdlog::level::level_enum Level
Definition Logger.h:33
std::shared_ptr< TopologicalNode > Ptr
PFSolver(CPS::String name, CPS::SystemTopology system, Real timeStep, CPS::Logger::Level logLevel)
Constructor to be used in simulation examples.
Definition PFSolver.cpp:17
CPS::Vector sol_P
Solution vector of active power.
void clearReactiveLimitState() override
Clear the Q-limit conversion bookkeeping between solves.
void resize_complex_sol(CPS::Int n)
Resize complex solution vector.
void calculateBranchFlow()
Calculate branch flows from current solution and store them in line and transformer components.
CPS::Real generatorReactivePowerPerUnit(CPS::TopologicalNode::Ptr node)
Generator reactive-power injection at a bus [pu], used by the Q-limit check.
void calculateQAtPVBuses()
Calculate the reactive power at all PV buses from current solution.
CPS::VectorComp sol_S_complex
Solution vector of representing sol_P and sol_Q as complex quantity.
PFSolverPowerPolar(CPS::String name, const CPS::SystemTopology &system, CPS::Real timeStep, CPS::Logger::Level logLevel)
Constructor to be used in simulation examples.
CPS::Real loadReactivePowerPerUnit(CPS::TopologicalNode::Ptr node)
Total local load reactive power at a bus [pu].
CPS::Vector sol_D
Solution vector of voltage angle.
CPS::Real sol_Vi(CPS::UInt k)
Calculate imaginary part of voltage from sol_V and sol_D.
std::map< CPS::TopologicalNode::Ptr, CPS::UInt > mQLimitSwitchCount
Total PV<->PQ switches per bus over the solve (anti-oscillation cap)
void calculatePAndQAtSlackBus()
Calculate P and Q at slack bus from current solution.
CPS::Vector sol_Q
Solution vector of reactive power.
CPS::Real Q(CPS::UInt k)
Calculate the reactive power at a bus from current solution.
void calculateMismatch() override
Calculate mismatch.
CPS::Bool enforceReactiveLimits() override
Q-limit PV<->PQ switching pass (overrides the base no-op)
CPS::Complex sol_Vcx(CPS::UInt k)
Calculate complex voltage from sol_V and sol_D.
void generateInitialSolution(Real time, bool keep_last_solution=false) override
Generate initial solution for current time step.
std::map< CPS::TopologicalNode::Ptr, bool > mQLimitConvertedAtMax
Buses switched PV->PQ by the Q-limit loop -> pinned at Qmax (true) or Qmin (false)
void calculateJacobian() override
Calculate the Jacobian.
void updateSolution() override
Update solution in each iteration.
void resize_sol(CPS::Int n)
Resize solution vector.
CPS::Real sol_Vr(CPS::UInt k)
Calculate real part of voltage from sol_V and sol_D.
CPS::Real P(CPS::UInt k)
Calculate active power at a bus from current solution.
void calculateNodalInjection()
Calculate nodal power injections and store them in first line or transformer (in case no line is conn...
CPS::Vector sol_V
Solution vector of voltage magnitude.
void calculatePAndQInjectionPQBuses()
Calculate complex power flowing from this node to the other nodes.
CPS::VectorComp sol_V_complex
Solution vector of representing sol_V and sol_D as complex quantity.
void setSolution() override
Set final solution.
std::string String
Definition Definitions.h:65
double Real
Definition Definitions.h:62
Eigen::Matrix< Complex, Eigen::Dynamic, 1 > VectorComp
Dense vector for complex numbers.
Definition Definitions.h:68
Eigen::Matrix< Real, Eigen::Dynamic, 1 > Vector
Dense vector for real numbers.
Definition Definitions.h:70
int Int
Definition Definitions.h:61
std::complex< Real > Complex
Definition Definitions.h:63
bool Bool
Definition Definitions.h:64
unsigned int UInt
Definition Definitions.h:60
CPS::Real Real
Definition Definitions.h:18