Power System Platform  2026w10a-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
36{
37public:
38 PowerFlow();
39 PowerFlow(std::vector<Element*> elementList);
40 ~PowerFlow();
41 virtual bool InitPowerFlow(std::vector<BusType>& busType,
42 std::vector<std::complex<double> >& voltage,
43 std::vector<std::complex<double> >& power,
44 std::vector<std::complex<double> >& loadPower,
45 std::vector<ReactiveLimits>& reactiveLimit,
46 double systemPowerBase = 100e6,
47 double initAngle = 0.0);
48 virtual bool RunGaussSeidel(double systemPowerBase = 100e6,
49 int maxIteration = 5000,
50 double error = 1e-6,
51 double initAngle = 0.0,
52 double accFactor = 1.0);
53 virtual bool RunNewtonRaphson(double systemPowerBase = 100e6,
54 int maxIteration = 5000,
55 double error = 1e-6,
56 double initAngle = 0.0,
57 double inertia = 1.0);
58 virtual bool RunGaussNewton(double systemPowerBase = 100e6,
59 int maxIteration = 5000,
60 double error = 1e-6,
61 double initAngle = 0.0,
62 double accFactor = 1.0,
63 double gaussTol = 1e-2,
64 double inertia = 1.0);
65
66 virtual wxString GetErrorMessage() { return m_errorMsg; }
67 virtual int GetIterations() { return m_iterations; }
68 virtual void ResetVoltages();
69
70protected:
71 void GetNumPVPQ(std::vector<BusType> busType, int& numPQ, int& numPV);
72
73 //std::vector<std::vector<double> > CalculateJacobianMatrix(std::vector<std::complex<double> >& voltage,
74 // std::vector<std::complex<double> >& power,
75 // std::vector<BusType>& busType,
76 // int& numPV,
77 // int& numPQ);
78
79 std::vector<std::vector<double>> CalculateJacobianMatrix(
80 const std::vector<std::complex<double>>& voltage,
81 const std::vector<std::complex<double>>& power,
82 const std::vector<BusType>& busType,
83 int numPV,
84 int numPQ);
85
86 bool CheckReactiveLimits(std::vector<BusType>& busType,
87 std::vector<ReactiveLimits>& reactiveLimit,
88 std::vector<std::complex<double> >& power,
89 std::vector<std::complex<double> > loadPower);
90
91 double GaussSeidel(std::vector<BusType> busType,
92 std::vector<std::complex<double> >& voltage,
93 std::vector<std::complex<double> > oldVoltage,
94 std::vector<std::complex<double> >& power,
95 double accFactor);
96 void NewtonRaphson(std::vector<BusType> busType,
97 std::vector<std::complex<double> >& voltage,
98 std::vector<std::complex<double> > power,
99 int numPV,
100 int numPQ,
101 std::vector<double> dPdQ,
102 double inertia);
103 bool CalculateMotorsReactivePower(std::vector<std::complex<double> > voltage,
104 std::vector<std::complex<double> >& power);
105
106 bool HasInvalidValue(const std::vector< std::complex<double> >& voltage);
107
108 std::vector<std::vector<std::complex<double> > > m_yBus;
109 wxString m_errorMsg = "";
110 int m_numberOfBuses = 0;
111 int m_iterations = 0;
112};
113
114#endif // POWERFLOW_H
Base class for electrical calculations providing general utility methods.
Calculate the power flow.
Definition PowerFlow.h:36