DPsim
Loading...
Searching...
No Matches
PFSolverPowerPolar.h
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 <dpsim/PFSolver.h>
12
13namespace DPsim {
16protected:
18 CPS::Vector sol_P;
20 CPS::Vector sol_Q;
22 CPS::Vector sol_V;
24 CPS::Vector sol_D;
26 CPS::VectorComp sol_V_complex;
28 CPS::VectorComp sol_S_complex;
29
30 CPS::Vector Pesp;
31 CPS::Vector Qesp;
32
33 // Cache for last converged solution
34 CPS::Vector mLastConvergedV;
35 CPS::Vector mLastConvergedD;
36 bool mHasLastConvergedSolution = false;
37
38 // Core methods
40 void generateInitialSolution(Real time,
41 bool keep_last_solution = false) override;
43 void calculateJacobian() override;
45 void updateSolution() override;
47 void setSolution() override;
49 void calculateMismatch() override;
50
51 // Helper methods
53 void resize_sol(CPS::Int n);
55 void resize_complex_sol(CPS::Int n);
57 CPS::Real sol_Vr(CPS::UInt k);
59 CPS::Real sol_Vi(CPS::UInt k);
61 CPS::Complex sol_Vcx(CPS::UInt k);
63 CPS::Real P(CPS::UInt k);
65 CPS::Real Q(CPS::UInt k);
76
77public:
79 PFSolverPowerPolar(CPS::String name, const CPS::SystemTopology &system,
80 CPS::Real timeStep, CPS::Logger::Level logLevel);
82 virtual ~PFSolverPowerPolar(){};
83};
84} // namespace DPsim
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::Vector sol_P
Solution vector of active power.
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.
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::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.
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::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.
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.