Power System Platform  2026w34a-beta
Loading...
Searching...
No Matches
PowerFlow.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2017 Thales Lima Oliveira <thales@ufu.br>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#ifndef POWERFLOW_H
19#define POWERFLOW_H
20
21#define STD_NR
22
23#include "ElectricCalculation.h"
24
25#include <wx/intl.h> //_()
26#include <wx/string.h>
27
37{
38public:
39 PowerFlow();
40 PowerFlow(std::vector<Element*> elementList);
41 ~PowerFlow();
42 virtual bool InitPowerFlow(std::vector<BusType>& busType,
43 std::vector<std::complex<double> >& voltage,
44 std::vector<std::complex<double> >& power,
45 std::vector<std::complex<double> >& loadPower,
46 std::vector<ReactiveLimits>& reactiveLimit,
47 double systemPowerBase = 100e6,
48 double initAngle = 0.0);
49 virtual bool RunGaussSeidel(double systemPowerBase = 100e6,
50 int maxIteration = 5000,
51 double error = 1e-6,
52 double initAngle = 0.0,
53 double accFactor = 1.0);
54 virtual bool RunNewtonRaphson(double systemPowerBase = 100e6,
55 int maxIteration = 5000,
56 double error = 1e-6,
57 double initAngle = 0.0,
58 double inertia = 1.0);
59 virtual bool RunGaussNewton(double systemPowerBase = 100e6,
60 int maxIteration = 5000,
61 double error = 1e-6,
62 double initAngle = 0.0,
63 double accFactor = 1.0,
64 double gaussTol = 1e-2,
65 double inertia = 1.0);
66
67 virtual wxString GetErrorMessage() { return m_errorMsg; }
68 virtual int GetIterations() { return m_iterations; }
69 virtual void ResetVoltages();
70
71protected:
72 void GetNumPVPQ(std::vector<BusType> busType, int& numPQ, int& numPV);
73
74 //std::vector<std::vector<double> > CalculateJacobianMatrix(std::vector<std::complex<double> >& voltage,
75 // std::vector<std::complex<double> >& power,
76 // std::vector<BusType>& busType,
77 // int& numPV,
78 // int& numPQ);
79
80 std::vector<std::vector<double>> CalculateJacobianMatrix(
81 const std::vector<std::complex<double>>& voltage,
82 const std::vector<std::complex<double>>& power,
83 const std::vector<BusType>& busType,
84 int numPV,
85 int numPQ);
86
87 bool CheckReactiveLimits(std::vector<BusType>& busType,
88 std::vector<ReactiveLimits>& reactiveLimit,
89 std::vector<std::complex<double> >& power,
90 std::vector<std::complex<double> > loadPower);
91
92 double GaussSeidel(std::vector<BusType> busType,
93 std::vector<std::complex<double> >& voltage,
94 std::vector<std::complex<double> > oldVoltage,
95 std::vector<std::complex<double> >& power,
96 double accFactor);
97 void NewtonRaphson(std::vector<BusType> busType,
98 std::vector<std::complex<double> >& voltage,
99 std::vector<std::complex<double> > power,
100 int numPV,
101 int numPQ,
102 std::vector<double> dPdQ,
103 double inertia);
104 bool CalculateMotorsReactivePower(std::vector<std::complex<double> > voltage,
105 std::vector<std::complex<double> >& power);
106
107 bool HasInvalidValue(const std::vector< std::complex<double> >& voltage);
108 bool AdjustTapChangers(const std::vector<std::complex<double> >& voltage, double systemPowerBase);
109
110 std::vector<std::vector<std::complex<double> > > m_yBus;
111 wxString m_errorMsg = "";
112 int m_numberOfBuses = 0;
113 int m_iterations = 0;
114 int m_tapAdjustmentsCount = 0;
115};
116
117#endif // POWERFLOW_H
Base class for electrical calculations providing general utility methods.
Calculate the power flow (including OLTC tap adjustment).
Definition PowerFlow.h:37