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