Power System Platform  2026w10a-beta
Loading...
Searching...
No Matches
PowerElement.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 POWERELEMENT_H
19#define POWERELEMENT_H
20
21#include "../Element.h"
22#include "../../utils/ElementPlotData.h"
23
28enum class ElectricalUnit : int {
29 UNIT_PU = 0,
30 UNIT_V,
31 UNIT_kV,
32 UNIT_A,
33 UNIT_kA,
34 UNIT_W,
35 UNIT_kW,
36 UNIT_MW,
37 UNIT_VA,
38 UNIT_kVA,
39 UNIT_MVA,
40 UNIT_var,
41 UNIT_kvar,
42 UNIT_Mvar,
43 UNIT_OHM,
45 UNIT_S,
46 UNIT_S_km,
49 UNIT_NONE
50};
51
65
70enum class SwitchingType : int {
71 SW_INSERT = 0,
73};
74
86
87enum class PlotStudy : int {
88 STABILITY = 0,
90};
91
100 std::vector<SwitchingType> swType;
101 std::vector<double> swTime;
102};
103
112 double c;
113 double m;
114};
115
123class PowerElement : public Element
124{
125 public:
129 PowerElement();
133 virtual ~PowerElement() {}
134
141 virtual wxPoint2DDouble GetSwitchPoint(Element* parent,
142 wxPoint2DDouble parentPoint,
143 wxPoint2DDouble secondPoint) const;
144
149 virtual bool SwitchesContains(wxPoint2DDouble position) const;
150
154 virtual void UpdateSwitches();
155
159 //virtual void DrawSwitches() const;
160
164 virtual void DrawDCSwitches(wxGraphicsContext* gc) const;
165
166 virtual void DrawDCSwitches(wxDC& dc) const;
167
172 virtual void CalculatePowerFlowPts(std::vector<wxPoint2DDouble> edges);
173
177 //virtual void DrawPowerFlowPts() const;
178
183 virtual void DrawDCPowerFlowPts(wxGraphicsContext* gc) const;
184
185 virtual void DrawDCPowerFlowPts(wxDC& dc) const;
186
192 virtual void SetNominalVoltage(std::vector<double> nominalVoltage, std::vector<ElectricalUnit> nominalVoltageUnit);
193
198 virtual void SetSwitchingData(SwitchingData data) { m_swData = data; }
203 virtual SwitchingData GetSwitchingData() { return m_swData; }
208 virtual void SetPowerFlowDirection(PowerFlowDirection pfDirection) { m_pfDirection = pfDirection; }
213 virtual PowerFlowDirection GetPowerFlowDirection() const { return m_pfDirection; }
219 virtual bool GetPlotData(ElementPlotData& plotData, PlotStudy study = PlotStudy::STABILITY) { return false; }
224 virtual bool HaveDynamicEvent() const { return m_dynEvent; }
229 virtual void SetDynamicEvent(bool dynEvent = true) { m_dynEvent = dynEvent; }
230 virtual double GetValueFromUnit(double value, ElectricalUnit valueUnit);
231
232 virtual void SaveCADProperties(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* elementNode);
233 virtual void SaveSwitchingData(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* electricalNode);
234 virtual bool OpenElement(rapidxml::xml_node<>* elementNode, std::vector<Element*> parentList) { return true; }
235 virtual bool OpenCADProperties(rapidxml::xml_node<>* elementNode, std::vector<Element*> parentList);
236 virtual bool OpenSwitchingData(rapidxml::xml_node<>* electricalNode);
237
238 protected:
239 SwitchingData m_swData;
240 std::vector<std::vector<wxPoint2DDouble> > m_powerFlowArrow;
242
243 wxColour m_busColour;
244 wxColour m_onlineElementColour;
245 wxColour m_offlineElementColour;
246 wxColour m_closedSwitchColour;
247 wxColour m_openedSwitchColour;
248 wxColour m_powerFlowArrowColour;
249 wxColour m_dynamicEventColour;
250
251 bool m_dynEvent = false;
252};
253
254#endif // POWERELEMENT_H
ElectricalUnit
Electrical units.
FaultData
Information about fault (type and location).
@ FAULT_LINE_GROUND
@ FAULT_2LINE_GROUND
@ FAULT_THREEPHASE
PowerFlowDirection
Direction of power flow arrows.
PlotStudy
SwitchingType
Type of switching.
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.
virtual void SetNominalVoltage(std::vector< double > nominalVoltage, std::vector< ElectricalUnit > nominalVoltageUnit)
Set nominal voltage of the element.
virtual void SetSwitchingData(SwitchingData data)
Set the switching data of the element.
virtual bool GetPlotData(ElementPlotData &plotData, PlotStudy study=PlotStudy::STABILITY)
Fill the plot data.
virtual ~PowerElement()
Destructor.
virtual void SetPowerFlowDirection(PowerFlowDirection pfDirection)
Set the direction of the power flow.
PowerElement()
Constructor.
virtual void SetDynamicEvent(bool dynEvent=true)
Set if the power element have dynamic event.
virtual void CalculatePowerFlowPts(std::vector< wxPoint2DDouble > edges)
Calculate the points of the power flow arrows.
virtual void DrawDCSwitches(wxGraphicsContext *gc) const
Draw switch.
virtual bool SwitchesContains(wxPoint2DDouble position) const
Check if switch contains position.
virtual PowerFlowDirection GetPowerFlowDirection() const
Return the direction of the power flow.
virtual SwitchingData GetSwitchingData()
Returns the switching data of the element.
virtual void UpdateSwitches()
Update the switch position.
virtual void DrawDCPowerFlowPts(wxGraphicsContext *gc) const
Draw power flow arrows.
virtual wxPoint2DDouble GetSwitchPoint(Element *parent, wxPoint2DDouble parentPoint, wxPoint2DDouble secondPoint) const
Get the correct switch position.
virtual bool HaveDynamicEvent() const
Check if the power element have dynamic event.
Integration constants to calculate dynamic elements through trapezoidal integration method.
Switching data of power elements.
std::vector< double > swTime
std::vector< SwitchingType > swType