Power System Platform  2026w10a-beta
Loading...
Searching...
No Matches
SyncGenerator.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 SYNCGENERATOR_H
19#define SYNCGENERATOR_H
20
21#include "Machines.h"
22
23class SyncMachineForm;
24
26 // General
27 wxString name = "";
28 double nominalPower = 100.0;
30 double nominalVoltage = 13.8;
31 ElectricalUnit nominalVoltageUnit = ElectricalUnit::UNIT_kV;
32 double activePower = 100.0;
34 double reactivePower = 0.0;
35 ElectricalUnit reactivePowerUnit = ElectricalUnit::UNIT_Mvar;
36 bool haveMaxReactive = false;
37 double maxReactive = 9999.0;
39 bool haveMinReactive = false;
40 double minReactive = -9999.0;
42 bool useMachineBase = true;
43
44 // Fault
45 double positiveResistance = 0.0;
46 double positiveReactance = 1.0;
47 double negativeResistance = 0.0;
48 double negativeReactance = 1.0;
49 double zeroResistance = 0.0;
50 double zeroReactance = 1.0;
51 double groundResistance = 0.0;
52 double groundReactance = 0.0;
53 bool groundNeutral = true;
54 // p.u. fault data
55 std::complex<double> faultCurrent[3] = { std::complex<double>(0.0, 0.0), std::complex<double>(0.0, 0.0),
56 std::complex<double>(0.0, 0.0) };
57
58 // Stability
59 bool plotSyncMachine = false;
60 double inertia = 1.0;
61 double damping = 0.0;
62 bool useAVR = false;
63 bool useSpeedGovernor = false;
64
65 double armResistance = 0.0;
66 double potierReactance = 0.0;
67 double satFactor = 0.0;
68 double ocFrequency = 60.0;
69
70 double syncXd = 0.0;
71 double syncXq = 0.0;
72 double transXd = 1.0;
73 double transXq = 0.0;
74 double transTd0 = 0.0;
75 double transTq0 = 0.0;
76 double subXd = 0.0;
77 double subXq = 0.0;
78 double subTd0 = 0.0;
79 double subTq0 = 0.0;
80
81 // Machine state variables
82 std::complex<double> terminalVoltage;
83 std::vector<double> terminalVoltageVector;
84 std::complex<double> electricalPower;
85 std::vector<std::complex<double> > electricalPowerVector;
86 double pm;
87 std::vector<double> mechanicalPowerVector;
88 double speed;
89 std::vector<double> freqVector;
90 double fieldVoltage;
91 std::vector<double> fieldVoltageVector;
92 double delta;
93 std::vector<double> deltaVector;
94
95 double initialFieldVoltage;
96
97 // Internal machine variables
98 double tranEq;
99 double tranEd;
100 double subEq;
101 double subEd;
102 double pe;
103 double id;
104 double iq;
105 double sd;
106 double sq;
107
108 // Variables to extrapolate
109 double oldId;
110 double oldIq;
111 double oldPe;
112 double oldSd;
113 double oldSq;
114
115 // Integration constants
116 IntegrationConstant icSpeed;
117 IntegrationConstant icDelta;
118 IntegrationConstant icTranEq;
119 IntegrationConstant icTranEd;
120 IntegrationConstant icSubEq;
121 IntegrationConstant icSubEd;
122
123 // Control
124 ControlElementContainer* avr = nullptr;
125 ControlElementContainer* speedGov = nullptr;
126 //std::unique_ptr<ControlElementContainer> avr;
127 //std::unique_ptr<ControlElementContainer> speedGov;
128
129 // Control solvers
130 //ControlElementSolver* avrSolver = nullptr;
131 std::shared_ptr<ControlElementSolver> avrSolver;
132 //ControlElementSolver* speedGovSolver = nullptr;
133 std::shared_ptr<ControlElementSolver> speedGovSolver;
134
135 Machines::SyncMachineModel model = Machines::SM_MODEL_1;
136};
137
146{
147public:
149 SyncGenerator(wxString name);
150 virtual ~SyncGenerator();
151
152 virtual Element* GetCopy();
153 virtual void Init();
154 //virtual void DrawSymbol() const;
155 virtual void DrawDCSymbol(wxGraphicsContext* gc) const;
156 virtual void DrawDCSymbol(wxDC& dc) const;
157 virtual bool GetContextMenu(wxMenu& menu);
158 virtual bool ShowForm(wxWindow* parent, Element* element);
159 virtual wxString GetTipText() const;
160 virtual SyncGeneratorElectricalData GetElectricalData() { return m_electricalData; }
161 virtual SyncGeneratorElectricalData GetPUElectricalData(double systemPowerBase);
162 virtual void SetElectricalData(SyncGeneratorElectricalData electricalData) { m_electricalData = electricalData; }
163 virtual void SetNominalVoltage(std::vector<double> nominalVoltage, std::vector<ElectricalUnit> nominalVoltageUnit);
164 virtual void SavePlotData();
165 virtual bool GetPlotData(ElementPlotData& plotData, PlotStudy study = PlotStudy::STABILITY);
166
167 virtual rapidxml::xml_node<>* SaveElement(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* elementListNode);
168 virtual bool OpenElement(rapidxml::xml_node<>* elementNode, std::vector<Element*> parentList);
169
170protected:
171 std::vector<wxPoint2DDouble> m_sinePts;
172
173 SyncGeneratorElectricalData m_electricalData;
174};
175
176#endif // SYNCGENERATOR_H
ElectricalUnit
Electrical units.
PlotStudy
Class that can contain all control elements. Can identify (using RTTI) the elements from a generic li...
Base class of all elements of the program. This class is responsible for manage graphical and his dat...
Definition Element.h:112
Abstract class for rotary machines power elements.
Definition Machines.h:34
Synchronous generator power element.
virtual bool GetContextMenu(wxMenu &menu)
Get the element contex menu.
virtual bool ShowForm(wxWindow *parent, Element *element)
Show element data form.
virtual bool GetPlotData(ElementPlotData &plotData, PlotStudy study=PlotStudy::STABILITY)
Fill the plot data.
virtual Element * GetCopy()
Get a the element copy.
virtual wxString GetTipText() const
Get the tip text.
virtual void SetNominalVoltage(std::vector< double > nominalVoltage, std::vector< ElectricalUnit > nominalVoltageUnit)
Set nominal voltage of the element.
Form to edit the synchronous machine power data.
Integration constants to calculate dynamic elements through trapezoidal integration method.