Power System Platform  2026w10a-beta
Loading...
Searching...
No Matches
Bus.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 BUS_H
19#define BUS_H
20
21#include "../../forms/BusForm.h"
22#include "PowerElement.h"
23
25 int number = 0;
26 wxString name = "";
27 double nominalVoltage = 138.0;
28 ElectricalUnit nominalVoltageUnit = ElectricalUnit::UNIT_kV;
29 bool isVoltageControlled = false;
30 double controlledVoltage = 1.0;
31 int controlledVoltageUnitChoice = 0; // 0 = p.u., 1 = same as nominalVoltageUnit (ElectricalUnit::UNIT_V or ElectricalUnit::UNIT_kV).
32 bool slackBus = false;
33 bool isConnected = true;
34
35 // Power flow (p.u.)
36 std::complex<double> voltage = std::complex<double>(1.0, 0.0);
37 std::complex<double> power = std::complex<double>(0.0, 0.0);
38 int busType = 2; // PQ
39
40 // Fault
41 bool hasFault = false;
43 FaultData faultLocation = FaultData::FAULT_LINE_A;
44 // p.u. fault data
45 double faultResistance = 0.0;
46 double faultReactance = 0.0;
47 std::complex<double> faultCurrent[3] = { std::complex<double>(0.0, 0.0), std::complex<double>(0.0, 0.0),
48 std::complex<double>(0.0, 0.0) };
49 std::complex<double> faultVoltage[3] = { std::complex<double>(0.0, 0.0), std::complex<double>(0.0, 0.0),
50 std::complex<double>(0.0, 0.0) };
51 double scPower = 0.0;
52
53 // Stability
54 bool plotBus = false;
55 bool stabHasFault = false;
56 double stabFaultTime = 0.0;
57 double stabFaultLength = 0.0;
58 double stabFaultResistance = 0.0;
59 double stabFaultReactance = 0.0;
60 double oldAngle = 0.0; // theta(k-1)
61 double filteredAngle = 0.0; // xt(k-1)
62 double dxt = 0.0; // Derivative of filteredAngle
63 double filteredVelocity = 0.0; // dw(k-1)
64 double ddw = 0.0; // Derivative of filteredVelocity
65 double stabFreq = 60.0;
66 std::vector<std::complex<double> > stabVoltageVector;
67 std::vector<double> stabFreqVector;
68
69 // Power Quality
70 bool plotPQData = false;
71 std::vector<int> harmonicOrder;
72 std::vector< std::complex<double> > harmonicVoltage;
73 double thd = 0.0;
74
75 std::vector<double> absImpedanceVector;
76};
77
85class Bus : public PowerElement
86{
87public:
92 Bus();
98 Bus(wxPoint2DDouble position);
105 Bus(wxPoint2DDouble position, wxString name);
106 ~Bus();
107 virtual Element* GetCopy();
116 virtual bool AddParent(Element* parent, wxPoint2DDouble position) { return true; }
117 virtual bool Contains(wxPoint2DDouble position) const;
118 virtual bool Intersects(wxRect2DDouble rect) const;
119 //virtual void Draw(wxPoint2DDouble translation, double scale) const;
120 virtual void DrawDC(wxPoint2DDouble translation, double scale, wxGraphicsContext* gc) const;
121 virtual void DrawDC(wxPoint2DDouble translation, double scale, wxDC& dc) const;
122 virtual void Rotate(bool clockwise = true);
123 virtual wxCursor GetBestPickboxCursor() const;
124 virtual void MovePickbox(wxPoint2DDouble position);
125 virtual bool PickboxContains(wxPoint2DDouble position);
126 virtual bool GetContextMenu(wxMenu& menu);
127 virtual wxString GetTipText() const;
128 virtual BusElectricalData GetElectricalData() const { return m_electricalData; }
129 virtual void SetElectricalData(const BusElectricalData& electricalData) { m_electricalData = electricalData; }
130 virtual bool ShowForm(wxWindow* parent, Element* element);
131 virtual bool GetPlotData(ElementPlotData& plotData, PlotStudy study = PlotStudy::STABILITY);
132
133 virtual rapidxml::xml_node<>* SaveElement(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* elementListNode);
134 virtual bool OpenElement(rapidxml::xml_node<>* elementNode);
135
136protected:
137 BusElectricalData m_electricalData;
138};
139
140#endif // BUS_H
ElectricalUnit
Electrical units.
FaultData
Information about fault (type and location).
@ FAULT_THREEPHASE
PlotStudy
Node for power elements. All others power elements are connected through this.
Definition Bus.h:86
virtual bool PickboxContains(wxPoint2DDouble position)
Check if a pickbox contains a point. If contains the attributes related to pickbox movement will be c...
Definition Bus.cpp:247
virtual wxString GetTipText() const
Get the tip text.
Definition Bus.cpp:361
virtual bool GetPlotData(ElementPlotData &plotData, PlotStudy study=PlotStudy::STABILITY)
Fill the plot data.
Definition Bus.cpp:404
virtual Element * GetCopy()
Get a the element copy.
Definition Bus.cpp:355
virtual bool Intersects(wxRect2DDouble rect) const
Check if the element's rect intersects other rect.
Definition Bus.cpp:240
virtual void DrawDC(wxPoint2DDouble translation, double scale, wxGraphicsContext *gc) const
Draw the element using GDI+.
Definition Bus.cpp:44
virtual bool ShowForm(wxWindow *parent, Element *element)
Show element data form.
Definition Bus.cpp:345
Bus()
Default constructor.
Definition Bus.cpp:23
virtual bool AddParent(Element *parent, wxPoint2DDouble position)
Add a parent element to the Bus.
Definition Bus.h:116
virtual wxCursor GetBestPickboxCursor() const
Get the best cursor to shown to the user when the mouse is above a pickbox.
Definition Bus.cpp:271
virtual void Rotate(bool clockwise=true)
Rotate the element.
Definition Bus.cpp:315
virtual bool Contains(wxPoint2DDouble position) const
Checks if the element contains a position.
Definition Bus.cpp:234
virtual void MovePickbox(wxPoint2DDouble position)
Move the pickbox.
Definition Bus.cpp:288
virtual bool GetContextMenu(wxMenu &menu)
Get the element contex menu.
Definition Bus.cpp:324
Base class of all elements of the program. This class is responsible for manage graphical and his dat...
Definition Element.h:112
Abstract class of power elements.