Power System Platform  2026w11a-beta
Loading...
Searching...
No Matches
SyncGenerator Class Reference

Synchronous generator power element. More...

#include <SyncGenerator.h>

Inheritance diagram for SyncGenerator:
Collaboration diagram for SyncGenerator:

Public Member Functions

 SyncGenerator (wxString name)
 
virtual ElementGetCopy ()
 Get a the element copy.
 
virtual void Init ()
 
virtual void DrawDCSymbol (wxGraphicsContext *gc) const
 
virtual void DrawDCSymbol (wxDC &dc) const
 
virtual bool GetContextMenu (wxMenu &menu)
 Get the element contex menu.
 
virtual bool ShowForm (wxWindow *parent, Element *element, wxWindow *workspace=nullptr)
 Show element data form.
 
virtual wxString GetTipText () const
 Get the tip text.
 
virtual SyncGeneratorElectricalData GetElectricalData ()
 
virtual SyncGeneratorElectricalDataGetElectricalDataRef ()
 
virtual SyncGeneratorElectricalData GetPUElectricalData (double systemPowerBase)
 
virtual void SetElectricalData (SyncGeneratorElectricalData electricalData)
 
virtual void SetNominalVoltage (std::vector< double > nominalVoltage, std::vector< ElectricalUnit > nominalVoltageUnit)
 Set nominal voltage of the element.
 
virtual void SavePlotData ()
 
virtual bool GetPlotData (ElementPlotData &plotData, PlotStudy study=PlotStudy::STABILITY)
 Fill the plot data.
 
virtual rapidxml::xml_node * SaveElement (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *elementListNode)
 
virtual bool OpenElement (rapidxml::xml_node<> *elementNode, std::vector< Element * > parentList)
 
- Public Member Functions inherited from Machines
virtual bool AddParent (Element *parent, wxPoint2DDouble position)
 Add a parent to the element. This method must be used on power elements that connect to a bus, so the parent must be a bus. The element basic points are calculated in this method, so apply this when the element is being inserted.
 
virtual bool Contains (wxPoint2DDouble position) const
 Checks if the element contains a position.
 
virtual void DrawDC (wxPoint2DDouble translation, double scale, wxGraphicsContext *gc) const
 Draw the element using GDI+.
 
virtual void DrawDC (wxPoint2DDouble translation, double scale, wxDC &dc) const
 Draw the element using wxDC.
 
virtual bool Intersects (wxRect2DDouble rect) const
 Check if the element's rect intersects other rect.
 
virtual void Move (wxPoint2DDouble position)
 Move the element other position.
 
virtual void MoveNode (Element *element, wxPoint2DDouble position)
 Move a node. StartMove(wxPoint2DDouble position) before start moving.
 
virtual void StartMove (wxPoint2DDouble position)
 Update the element attributes related to the movement.
 
virtual void RotateNode (Element *parent, bool clockwise=true)
 Rotate a node.
 
virtual void RemoveParent (Element *parent)
 Remove a parent.
 
virtual bool NodeContains (wxPoint2DDouble position)
 Check if a node contains a point. If contains, set the attributes related to node movement.
 
virtual bool SetNodeParent (Element *parent)
 Set a perent to the node. If all conditions are met, a new parent are added to the element and the points related to the nodes will be calculated.
 
virtual void UpdateNodes ()
 Update the nodes according to the parents. If a parent is removed, use this method.
 
virtual void Rotate (bool clockwise=true)
 Rotate the element.
 
virtual void SetPowerFlowDirection (PowerFlowDirection pfDirection)
 Set the direction of the power flow.
 
- Public Member Functions inherited from PowerElement
 PowerElement ()
 Constructor.
 
virtual ~PowerElement ()
 Destructor.
 
virtual wxPoint2DDouble GetSwitchPoint (Element *parent, wxPoint2DDouble parentPoint, wxPoint2DDouble secondPoint) const
 Get the correct switch position.
 
virtual bool SwitchesContains (wxPoint2DDouble position) const
 Check if switch contains position.
 
virtual void UpdateSwitches ()
 Update the switch position.
 
virtual void DrawDCSwitches (wxGraphicsContext *gc) const
 Draw switch.
 
virtual void DrawDCSwitches (wxDC &dc) const
 
virtual void CalculatePowerFlowPts (std::vector< wxPoint2DDouble > edges)
 Calculate the points of the power flow arrows.
 
virtual void DrawDCPowerFlowPts (wxGraphicsContext *gc) const
 Draw power flow arrows.
 
virtual void DrawDCPowerFlowPts (wxDC &dc) const
 
virtual void SetSwitchingData (SwitchingData data)
 Set the switching data of the element.
 
virtual SwitchingData GetSwitchingData ()
 Returns the switching data of the element.
 
virtual PowerFlowDirection GetPowerFlowDirection () const
 Return the direction of the power flow.
 
virtual bool HaveDynamicEvent () const
 Check if the power element have dynamic event.
 
virtual void SetDynamicEvent (bool dynEvent=true)
 Set if the power element have dynamic event.
 
virtual double GetValueFromUnit (double value, ElectricalUnit valueUnit)
 
virtual void SaveCADProperties (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *elementNode)
 
virtual void SaveSwitchingData (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *electricalNode)
 
virtual bool OpenCADProperties (rapidxml::xml_node<> *elementNode, std::vector< Element * > parentList)
 
virtual bool OpenSwitchingData (rapidxml::xml_node<> *electricalNode)
 
- Public Member Functions inherited from Element
 Element ()
 Constructor.
 
virtual ~Element ()
 Destructor.
 
void SetDragging (bool dragging=true)
 Set if the element are being dragged.
 
void SetHeight (double height)
 Set element height.
 
void SetPosition (const wxPoint2DDouble position)
 Set the element position and update the rectangle.
 
void SetSelected (bool selected=true)
 Set element selection.
 
void SetWidth (double width)
 Set element width.
 
void SetAngle (double angle)
 Set element angle.
 
void ShowPickbox (bool showPickbox=true)
 Set if the pickbox is shown.
 
void SetBorderSize (double borderSize)
 Set the size of the border (shown in selected elements).
 
bool SetOnline (bool online=true)
 Set if the element is online or offline.
 
virtual void SetPointList (std::vector< wxPoint2DDouble > pointList)
 Set the list of points that connect the element to the bus.
 
ElementType GetElementType ()
 
wxRect2DDouble GetRect () const
 Get the element rectangle.
 
wxPoint2DDouble GetPosition () const
 Get the element position.
 
bool IsDragging () const
 Checks if the element is being dragged.
 
double GetHeight () const
 Get the element height.
 
bool IsSelected () const
 Checks if the element is selected.
 
double GetWidth () const
 Get the element width.
 
double GetAngle () const
 Get the element angle.
 
double GetRotationAngle () const
 Get the angle of rotation.
 
bool IsPickboxShown () const
 Checks if the pickbox is shown.
 
bool IsOnline () const
 Checks if the element is online or offline.
 
virtual std::vector< wxPoint2DDouble > GetPointList () const
 Get the list of points that connect the element to bus.
 
virtual void AddParent (Element *parent)
 Add a parent to the element.
 
virtual void SetID (int id)
 Set the element ID.
 
virtual int GetID () const
 Get the element ID.
 
virtual void AddChild (Element *child)
 Add a child to the child list.
 
virtual void RemoveChild (Element *child)
 Remove a child from the list.
 
virtual void ReplaceChild (Element *oldChild, Element *newChild)
 Replace a child from the list.
 
virtual void AddPoint (wxPoint2DDouble point)
 Add point to the list of points that connect the element to the bus.
 
void SetParent (Element *parent, int num)
 
void SetChild (Element *child, int num)
 
virtual void ReplaceParent (Element *oldParent, Element *newParent)
 Replace a parent.
 
virtual bool PickboxContains (wxPoint2DDouble position)
 Check if a pickbox contains a point. If contains the attributes related to pickbox movement will be calculated.
 
virtual void MovePickbox (wxPoint2DDouble position)
 Move the pickbox.
 
virtual wxCursor GetBestPickboxCursor () const
 Get the best cursor to shown to the user when the mouse is above a pickbox.
 
virtual void ResetPickboxes ()
 Remove the pickboxes.
 
virtual void ResetNodes ()
 Remove the active nodes.
 
virtual wxPoint2DDouble WorldToScreen (wxPoint2DDouble translation, double scale, double offsetX=0.0, double offsetY=0.0) const
 Convert the element position to screen position.
 
virtual wxPoint2DDouble WorldToScreen (wxPoint2DDouble position, wxPoint2DDouble translation, double scale, double offsetX=0.0, double offsetY=0.0) const
 Convert a generic position to screen position.
 
virtual bool RotatedRectanglesIntersects (wxRect2DDouble rect1, wxRect2DDouble rect2, double angle1, double angle2) const
 Check if two roteted rectangles intersect.
 
virtual void DrawDCRectangle (wxPoint2DDouble position, double width, double height, double angle, wxDC &dc) const
 Draw a circle.
 
virtual void DrawDCRoundedRectRotated (wxDC &dc, const wxPoint2DDouble &center, double width, double height, double radius, double angleDeg, int arcSegments=8) const
 
virtual void DrawDCCircle (wxPoint2DDouble position, double radius, int numSegments, wxGraphicsContext *gc) const
 Draw a circle using device context.
 
virtual void DrawDCCircle (wxPoint2DDouble position, double radius, wxDC &dc) const
 
virtual void DrawDCArc (wxPoint2DDouble position, double radius, double initAngle, double finalAngle, int numSegments, wxGraphicsContext *gc) const
 
virtual void DrawDCArc (wxPoint2DDouble position, double radius, double initAngle, double finalAngle, wxDC &dc) const
 
virtual void DrawDCTriangle (std::vector< wxPoint2DDouble > points, wxGraphicsContext *gc) const
 Draw rectangle.
 
virtual void DrawDCTriangle (std::vector< wxPoint > points, wxDC &dc) const
 
virtual void DrawDCPickbox (wxPoint2DDouble position, wxGraphicsContext *gc) const
 Draw a point.
 
virtual wxPoint2DDouble RotateAtPosition (wxPoint2DDouble pointToRotate, double angle, bool degrees=true) const
 Rotate a point as element position being the origin.
 
virtual wxPoint2DDouble RotateLocal (wxPoint2DDouble local, double angleDeg) const
 
virtual wxPoint RotateAround (const wxPoint2DDouble &p, const wxPoint2DDouble &center, double angleDeg) const
 
virtual std::vector< Element * > GetParentList () const
 Get the parent list.
 
virtual std::vector< Element * > GetChildList () const
 Get the Child list.
 
virtual void CalculateBoundaries (wxPoint2DDouble &leftUp, wxPoint2DDouble &rightBottom) const
 Calculate the element boundaries.
 
virtual void GeneralMenuItens (wxMenu &menu)
 Insert general itens to context menu.
 
virtual double PointToLineDistance (wxPoint2DDouble point, int *segmentNumber=nullptr) const
 Calculate the distance between a line (formed by point list) and a point.
 
bool IsInserted () const
 Check if the element is properly inserted in the workspace.
 
void SetInserted (bool inserted=true)
 Set if the element is properly inserted in the workspace.
 
virtual bool OpenElement (rapidxml::xml_node<> *elementNode)
 
void SaveCADProperties (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *elementNode)
 
bool OpenCADProperties (rapidxml::xml_node<> *elementNode)
 

Protected Attributes

std::vector< wxPoint2DDouble > m_sinePts
 
SyncGeneratorElectricalData m_electricalData
 
- Protected Attributes inherited from PowerElement
SwitchingData m_swData
 
std::vector< std::vector< wxPoint2DDouble > > m_powerFlowArrow
 
PowerFlowDirection m_pfDirection = PowerFlowDirection::PF_NONE
 
wxColour m_busColour
 
wxColour m_onlineElementColour
 
wxColour m_offlineElementColour
 
wxColour m_closedSwitchColour
 
wxColour m_openedSwitchColour
 
wxColour m_powerFlowArrowColour
 
wxColour m_dynamicEventColour
 
bool m_dynEvent = false
 
- Protected Attributes inherited from Element
ElementType m_elementType = ElementType::TYPE_NONE
 
int m_elementID = 0
 
std::vector< Element * > m_parentList
 
std::vector< Element * > m_childList
 
wxRect2DDouble m_rect
 
wxPoint2DDouble m_position
 
double m_width = 0.0
 
double m_height = 0.0
 
double m_angle = 0.0
 
double m_borderSize = 2.0
 
double m_rotationAngle = 45.0
 
double m_switchSize = 10.0
 
std::vector< wxRect2DDouble > m_switchRect
 
bool m_selected = false
 
bool m_dragging = false
 
bool m_showPickbox = false
 
bool m_inserted = false
 
int m_activePickboxID = ID_PB_NONE
 
int m_activeNodeID = 0
 
std::vector< wxPoint2DDouble > m_pointList
 
std::vector< wxPoint2DDouble > m_movePts
 
wxPoint2DDouble m_moveStartPt
 
wxPoint2DDouble m_movePos
 
bool m_online = true
 
wxColour m_selectionColour
 

Additional Inherited Members

- Public Types inherited from Machines
enum  SyncMachineModel {
  SM_MODEL_1 = 0 , SM_MODEL_2 , SM_MODEL_3 , SM_MODEL_4 ,
  SM_MODEL_5
}
 
- Static Public Member Functions inherited from Element
static bool DoubleFromString (wxWindow *parent, wxString strValue, double &value, wxString errorMsg)
 Get a double value from a string. Show a error message if the conversion fail.
 
static bool IntFromString (wxWindow *parent, wxString strValue, int &value, wxString errorMsg)
 Convert a string to int. Show a error message if the conversion fail.
 
static wxString StringFromDouble (double value, int minDecimal=1, int maxDecimals=13)
 Convert a double value to string.
 
- Protected Member Functions inherited from Machines
void UpdateSwitchesPosition ()
 
void UpdatePowerFlowArrowsPosition ()
 

Detailed Description

Synchronous generator power element.

Author
Thales Lima Oliveira thale.nosp@m.s@uf.nosp@m.u.br
Date
06/10/2017

Definition at line 145 of file SyncGenerator.h.

Constructor & Destructor Documentation

◆ SyncGenerator() [1/2]

SyncGenerator::SyncGenerator ( )

Definition at line 32 of file SyncGenerator.cpp.

32 : Machines() {
33 m_elementType = TYPE_SYNC_GENERATOR;
34 Init();
35}
Abstract class for rotary machines power elements.
Definition Machines.h:34

◆ SyncGenerator() [2/2]

SyncGenerator::SyncGenerator ( wxString  name)

Definition at line 36 of file SyncGenerator.cpp.

36 : Machines()
37{
38 m_elementType = TYPE_SYNC_GENERATOR;
39 Init();
40 m_electricalData.name = name;
41}

◆ ~SyncGenerator()

SyncGenerator::~SyncGenerator ( )
virtual

Definition at line 43 of file SyncGenerator.cpp.

44{
45 if (m_electricalData.avr) delete m_electricalData.avr;
46 if (m_electricalData.speedGov) delete m_electricalData.speedGov;
47 //if (m_electricalData.avrSolver) delete m_electricalData.avrSolver;
48 //if (m_electricalData.speedGovSolver) delete m_electricalData.speedGovSolver;
49}

Member Function Documentation

◆ DrawDCSymbol() [1/2]

void SyncGenerator::DrawDCSymbol ( wxDC &  dc) const
virtual

Reimplemented from Machines.

Definition at line 84 of file SyncGenerator.cpp.

85{
86 std::vector<wxPoint> sinePts;
87 wxPoint pos = wxPoint(wxRound(m_position.m_x), wxRound(m_position.m_y));
88 for (unsigned int i = 0; i < m_sinePts.size(); i++) { sinePts.push_back(wxPoint(wxRound(m_sinePts[i].m_x), wxRound(m_sinePts[i].m_y)) + pos); }
89 dc.DrawLines(sinePts.size(), &sinePts[0]);
90}

◆ DrawDCSymbol() [2/2]

void SyncGenerator::DrawDCSymbol ( wxGraphicsContext *  gc) const
virtual

Reimplemented from Machines.

Definition at line 76 of file SyncGenerator.cpp.

77{
78 // Draw sine.
79 std::vector<wxPoint2DDouble> sinePts;
80 for (unsigned int i = 0; i < m_sinePts.size(); i++) { sinePts.push_back(m_sinePts[i] + m_position); }
81 gc->StrokeLines(sinePts.size(), &sinePts[0]);
82}

◆ GetContextMenu()

bool SyncGenerator::GetContextMenu ( wxMenu &  menu)
virtual

Get the element contex menu.

Parameters
menumenu that will be inserted the element itens.
Returns
True if was possible to build the menu, false otherwise.

Reimplemented from Element.

Definition at line 92 of file SyncGenerator.cpp.

93{
94 menu.Append(ID_EDIT_ELEMENT, _("Edit Generator"));
95
96 wxMenu* textMenu = new wxMenu();
97
98 textMenu->Append(ID_TXT_NAME, _("Name"));
99 textMenu->Append(ID_TXT_ACTIVE_POWER, _("Active power"));
100 textMenu->Append(ID_TXT_REACTIVE_POWER, _("Reactive power"));
101 textMenu->Append(ID_TXT_FAULTCURRENT, _("Fault current"));
102 textMenu->SetClientData(menu.GetClientData());
103 menu.AppendSubMenu(textMenu, _("Add text"));
104
105 GeneralMenuItens(menu);
106 return true;
107}
@ ID_EDIT_ELEMENT
Definition Element.h:75
virtual void GeneralMenuItens(wxMenu &menu)
Insert general itens to context menu.
Definition Element.cpp:388
Here is the call graph for this function:

◆ GetCopy()

Element * SyncGenerator::GetCopy ( )
virtual

Get a the element copy.

Returns
Copy of the element.

Reimplemented from Element.

Definition at line 249 of file SyncGenerator.cpp.

250{
251 auto copy = new SyncGenerator(*this);
252
253 auto data = copy->GetElectricalData();
254 data.avrSolver.reset();
255 data.speedGovSolver.reset();
256
257 // AVR
258 if (m_electricalData.avr)
259 {
260 std::vector<std::shared_ptr<ConnectionLine>> cLineList;
261 std::vector<std::shared_ptr<ControlElement>> elementList;
262
263 m_electricalData.avr->GetContainerCopy(elementList, cLineList);
264
265 auto avrCopy = new ControlElementContainer();
266 avrCopy->FillContainer(elementList, cLineList);
267
268 data.avr = avrCopy;
269 }
270 else
271 data.avr = nullptr;
272
273
274 // Speed governor
275 if (m_electricalData.speedGov)
276 {
277 std::vector<std::shared_ptr<ConnectionLine>> cLineList;
278 std::vector<std::shared_ptr<ControlElement>> elementList;
279
280 m_electricalData.speedGov->GetContainerCopy(elementList, cLineList);
281
282 auto speedGovCopy = new ControlElementContainer();
283 speedGovCopy->FillContainer(elementList, cLineList);
284
285 data.speedGov = speedGovCopy;
286 }
287 else
288 data.speedGov = nullptr;
289
290 copy->SetElectricalData(data);
291
292 return copy;
293}
Class that can contain all control elements. Can identify (using RTTI) the elements from a generic li...
Synchronous generator power element.

◆ GetElectricalData()

virtual SyncGeneratorElectricalData SyncGenerator::GetElectricalData ( )
inlinevirtual

Definition at line 160 of file SyncGenerator.h.

160{ return m_electricalData; }

◆ GetElectricalDataRef()

virtual SyncGeneratorElectricalData & SyncGenerator::GetElectricalDataRef ( )
inlinevirtual

Definition at line 161 of file SyncGenerator.h.

161{ return m_electricalData; }

◆ GetPlotData()

bool SyncGenerator::GetPlotData ( ElementPlotData plotData,
PlotStudy  study = PlotStudy::STABILITY 
)
virtual

Fill the plot data.

Parameters
plotDataPlot data to be filled.
Returns
true if the plot data was successfully filled, false otherwise.

Reimplemented from PowerElement.

Definition at line 341 of file SyncGenerator.cpp.

342{
343 if (study == PlotStudy::STABILITY) {
344 if (!m_electricalData.plotSyncMachine) return false;
345 plotData.SetName(m_electricalData.name);
346 plotData.SetCurveType(ElementPlotData::CurveType::CT_SYNC_GENERATOR);
347
348 std::vector<double> absTerminalVoltage, activePower, reactivePower;
349 for (unsigned int i = 0; i < m_electricalData.terminalVoltageVector.size(); ++i) {
350 activePower.push_back(std::real(m_electricalData.electricalPowerVector[i]));
351 reactivePower.push_back(std::imag(m_electricalData.electricalPowerVector[i]));
352 }
353 plotData.AddData(m_electricalData.terminalVoltageVector, _("Terminal voltage"));
354 plotData.AddData(activePower, _("Active power"));
355 plotData.AddData(reactivePower, _("Reactive power"));
356 plotData.AddData(m_electricalData.mechanicalPowerVector, _("Mechanical power"));
357 plotData.AddData(m_electricalData.freqVector, _("Frequency"));
358 plotData.AddData(m_electricalData.fieldVoltageVector, _("Field voltage"));
359 plotData.AddData(m_electricalData.deltaVector, _("Delta"));
360 return true;
361 }
362 return false;
363}

◆ GetPUElectricalData()

SyncGeneratorElectricalData SyncGenerator::GetPUElectricalData ( double  systemPowerBase)
virtual

Definition at line 123 of file SyncGenerator.cpp.

124{
126
127 data.name = m_electricalData.name;
128
129 data.nominalPower = m_electricalData.nominalPower;
130 data.nominalPowerUnit = m_electricalData.nominalPowerUnit;
131
132 data.nominalVoltage = m_electricalData.nominalVoltage;
133 data.nominalVoltageUnit = m_electricalData.nominalVoltageUnit;
134
135 data.activePower = m_electricalData.activePower;
136 data.activePowerUnit = m_electricalData.activePowerUnit;
137
138 data.reactivePower = m_electricalData.reactivePower;
139 data.reactivePowerUnit = m_electricalData.reactivePowerUnit;
140
141 data.haveMaxReactive = m_electricalData.haveMaxReactive;
142 data.maxReactive = m_electricalData.maxReactive;
143 data.maxReactiveUnit = m_electricalData.maxReactiveUnit;
144
145 data.haveMinReactive = m_electricalData.haveMinReactive;
146 data.minReactive = m_electricalData.minReactive;
147 data.minReactiveUnit = m_electricalData.minReactiveUnit;
148
149 data.useMachineBase = m_electricalData.useMachineBase;
150
151 data.positiveResistance = m_electricalData.positiveResistance;
152 data.positiveReactance = m_electricalData.positiveReactance;
153
154 data.negativeResistance = m_electricalData.negativeResistance;
155 data.negativeReactance = m_electricalData.negativeReactance;
156
157 data.zeroResistance = m_electricalData.zeroResistance;
158 data.zeroReactance = m_electricalData.zeroReactance;
159
160 data.groundResistance = m_electricalData.groundResistance;
161 data.groundReactance = m_electricalData.groundReactance;
162
163 data.groundNeutral = m_electricalData.groundNeutral;
164
165 data.faultCurrent[0] = m_electricalData.faultCurrent[0];
166 data.faultCurrent[1] = m_electricalData.faultCurrent[1];
167 data.faultCurrent[2] = m_electricalData.faultCurrent[2];
168
169
170 double machineBasePower = 1.0;
171 if (data.useMachineBase) { machineBasePower = GetValueFromUnit(data.nominalPower, data.nominalPowerUnit); }
172
173 // Active power
174 double activePower = GetValueFromUnit(data.activePower, data.activePowerUnit);
175 if (!m_online) activePower = 0.0;
176 if (data.activePowerUnit == ElectricalUnit::UNIT_PU) {
177 if (data.useMachineBase) data.activePower = (activePower * machineBasePower) / systemPowerBase;
178 }
179 else {
180 data.activePower = activePower / systemPowerBase;
181 }
182 data.activePowerUnit = ElectricalUnit::UNIT_PU;
183
184 // Reactive power
185 double reactivePower = GetValueFromUnit(data.reactivePower, data.reactivePowerUnit);
186 if (!m_online) reactivePower = 0.0;
187 if (data.reactivePowerUnit == ElectricalUnit::UNIT_PU) {
188 if (data.useMachineBase) data.reactivePower = (reactivePower * machineBasePower) / systemPowerBase;
189 }
190 else {
191 data.reactivePower = reactivePower / systemPowerBase;
192 }
193 data.reactivePowerUnit = ElectricalUnit::UNIT_PU;
194
195 // Max reactive power
196 double maxReactive = GetValueFromUnit(data.maxReactive, data.maxReactiveUnit);
197 if (data.maxReactiveUnit == ElectricalUnit::UNIT_PU) {
198 if (data.useMachineBase) data.maxReactive = (maxReactive * machineBasePower) / systemPowerBase;
199 }
200 else {
201 data.maxReactive = maxReactive / systemPowerBase;
202 }
203 data.maxReactiveUnit = ElectricalUnit::UNIT_PU;
204
205 // Min reactive power
206 double minReactive = GetValueFromUnit(data.minReactive, data.minReactiveUnit);
207 if (data.minReactiveUnit == ElectricalUnit::UNIT_PU) {
208 if (data.useMachineBase) data.minReactive = (minReactive * machineBasePower) / systemPowerBase;
209 }
210 else {
211 data.minReactive = minReactive / systemPowerBase;
212 }
213 data.minReactiveUnit = ElectricalUnit::UNIT_PU;
214
215 double baseVoltage = GetValueFromUnit(data.nominalVoltage, data.nominalVoltageUnit);
216 double systemBaseImpedance = (baseVoltage * baseVoltage) / systemPowerBase;
217 double machineBaseImpedance = (baseVoltage * baseVoltage) / machineBasePower;
218
219 // Fault data
220 if (data.useMachineBase) {
221 data.positiveResistance = (data.positiveResistance * machineBaseImpedance) / systemBaseImpedance;
222 data.positiveReactance = (data.positiveReactance * machineBaseImpedance) / systemBaseImpedance;
223 data.negativeResistance = (data.negativeResistance * machineBaseImpedance) / systemBaseImpedance;
224 data.negativeReactance = (data.negativeReactance * machineBaseImpedance) / systemBaseImpedance;
225 data.zeroResistance = (data.zeroResistance * machineBaseImpedance) / systemBaseImpedance;
226 data.zeroReactance = (data.zeroReactance * machineBaseImpedance) / systemBaseImpedance;
227 data.groundResistance = (data.groundResistance * machineBaseImpedance) / systemBaseImpedance;
228 data.groundReactance = (data.groundReactance * machineBaseImpedance) / systemBaseImpedance;
229 }
230
231 if (!m_online) {
232 data.faultCurrent[0] = std::complex<double>(0, 0);
233 data.faultCurrent[1] = std::complex<double>(0, 0);
234 data.faultCurrent[2] = std::complex<double>(0, 0);
235 }
236
237 return data;
238}

◆ GetTipText()

wxString SyncGenerator::GetTipText ( ) const
virtual

Get the tip text.

Returns
Tip text.

Reimplemented from Element.

Definition at line 295 of file SyncGenerator.cpp.

296{
297 wxString tipText = m_electricalData.name;
298 tipText += "\n";
299 double activePower = m_electricalData.activePower;
300 if (!m_online) activePower = 0.0;
301 tipText += _("\nP = ") + wxString::FromDouble(activePower, 5);
302 switch (m_electricalData.activePowerUnit) {
304 tipText += _(" p.u.");
305 } break;
307 tipText += _(" W");
308 } break;
310 tipText += _(" kW");
311 } break;
313 tipText += _(" MW");
314 } break;
315 default:
316 break;
317 }
318 double reactivePower = m_electricalData.reactivePower;
319 if (!m_online) reactivePower = 0.0;
320 tipText += _("\nQ = ") + wxString::FromDouble(reactivePower, 5);
321 switch (m_electricalData.reactivePowerUnit) {
323 tipText += _(" p.u.");
324 } break;
326 tipText += _(" var");
327 } break;
329 tipText += _(" kvar");
330 } break;
332 tipText += _(" Mvar");
333 } break;
334 default:
335 break;
336 }
337
338 return tipText;
339}

◆ Init()

void SyncGenerator::Init ( )
virtual

Definition at line 51 of file SyncGenerator.cpp.

52{
53 int numPtsSine = 10;
54 double mx = 15.0;
55 double my = 10.0;
56 double pi = 3.14159265359;
57
58 for (int i = 0; i <= numPtsSine; i++) {
59 double x = (2.0 * pi / double(numPtsSine)) * double(i) - pi;
60 double y = std::sin(x);
61 m_sinePts.push_back(wxPoint2DDouble((x / pi) * mx, y * my));
62 }
63
64 m_electricalData.avr = new ControlElementContainer();
65 m_electricalData.speedGov = new ControlElementContainer();
66}

◆ OpenElement()

bool SyncGenerator::OpenElement ( rapidxml::xml_node<> *  elementNode,
std::vector< Element * >  parentList 
)
virtual

Reimplemented from PowerElement.

Definition at line 463 of file SyncGenerator.cpp.

464{
465 if (!OpenCADProperties(elementNode, parentList)) return false;
466
467 auto electricalProp = elementNode->first_node("ElectricalProperties");
468 if (!electricalProp) return false;
469
470 SetOnline(XMLParser::GetNodeValueInt(electricalProp, "IsOnline"));
471 m_electricalData.name = electricalProp->first_node("Name")->value();
472 m_electricalData.nominalPower = XMLParser::GetNodeValueDouble(electricalProp, "NominalPower");
473 m_electricalData.nominalPowerUnit =
474 static_cast<ElectricalUnit>(XMLParser::GetAttributeValueInt(electricalProp, "NominalPower", "UnitID"));
475 m_electricalData.nominalVoltage = XMLParser::GetNodeValueDouble(electricalProp, "NominalVoltage");
476 m_electricalData.nominalVoltageUnit =
477 static_cast<ElectricalUnit>(XMLParser::GetAttributeValueInt(electricalProp, "NominalVoltage", "UnitID"));
478 m_electricalData.activePower = XMLParser::GetNodeValueDouble(electricalProp, "ActivePower");
479 m_electricalData.activePowerUnit =
480 static_cast<ElectricalUnit>(XMLParser::GetAttributeValueInt(electricalProp, "ActivePower", "UnitID"));
481 m_electricalData.reactivePower = XMLParser::GetNodeValueDouble(electricalProp, "ReactivePower");
482 m_electricalData.reactivePowerUnit =
483 static_cast<ElectricalUnit>(XMLParser::GetAttributeValueInt(electricalProp, "ReactivePower", "UnitID"));
484 m_electricalData.haveMaxReactive = XMLParser::GetNodeValueInt(electricalProp, "HaveMaxReactive");
485 m_electricalData.maxReactive = XMLParser::GetNodeValueDouble(electricalProp, "MaxReactive");
486 m_electricalData.maxReactiveUnit =
487 static_cast<ElectricalUnit>(XMLParser::GetAttributeValueInt(electricalProp, "MaxReactive", "UnitID"));
488 m_electricalData.haveMinReactive = XMLParser::GetNodeValueInt(electricalProp, "HaveMinReactive");
489 m_electricalData.minReactive = XMLParser::GetNodeValueDouble(electricalProp, "MinReactive");
490 m_electricalData.minReactiveUnit =
491 static_cast<ElectricalUnit>(XMLParser::GetAttributeValueInt(electricalProp, "MinReactive", "UnitID"));
492 m_electricalData.useMachineBase = XMLParser::GetNodeValueInt(electricalProp, "UseMachineBase");
493
494 auto fault = electricalProp->first_node("Fault");
495 if (!fault) return false;
496 m_electricalData.positiveResistance = XMLParser::GetNodeValueDouble(fault, "PositiveResistance");
497 m_electricalData.positiveReactance = XMLParser::GetNodeValueDouble(fault, "PositiveReactance");
498 m_electricalData.negativeResistance = XMLParser::GetNodeValueDouble(fault, "NegativeResistance");
499 m_electricalData.negativeReactance = XMLParser::GetNodeValueDouble(fault, "NegativeReactance");
500 m_electricalData.zeroResistance = XMLParser::GetNodeValueDouble(fault, "ZeroResistance");
501 m_electricalData.zeroReactance = XMLParser::GetNodeValueDouble(fault, "ZeroReactance");
502 m_electricalData.groundResistance = XMLParser::GetNodeValueDouble(fault, "GroundResistance");
503 m_electricalData.groundReactance = XMLParser::GetNodeValueDouble(fault, "GroundReactance");
504 m_electricalData.groundNeutral = XMLParser::GetNodeValueInt(fault, "GroundNeutral");
505
506 auto stability = electricalProp->first_node("Stability");
507 if (!stability) return false;
508 m_electricalData.plotSyncMachine = XMLParser::GetNodeValueInt(stability, "PlotSyncMachine");
509 m_electricalData.inertia = XMLParser::GetNodeValueDouble(stability, "Inertia");
510 m_electricalData.damping = XMLParser::GetNodeValueDouble(stability, "Damping");
511 m_electricalData.useAVR = XMLParser::GetNodeValueInt(stability, "UseAVR");
512 m_electricalData.useSpeedGovernor = XMLParser::GetNodeValueInt(stability, "UseSpeedGovernor");
513 m_electricalData.armResistance = XMLParser::GetNodeValueDouble(stability, "ArmResistance");
514 m_electricalData.potierReactance = XMLParser::GetNodeValueDouble(stability, "PotierReactance");
515 m_electricalData.satFactor = XMLParser::GetNodeValueDouble(stability, "SatFactor");
516 m_electricalData.syncXd = XMLParser::GetNodeValueDouble(stability, "SyncXd");
517 m_electricalData.syncXq = XMLParser::GetNodeValueDouble(stability, "SyncXq");
518 m_electricalData.transXd = XMLParser::GetNodeValueDouble(stability, "TransXd");
519 m_electricalData.transXq = XMLParser::GetNodeValueDouble(stability, "TransXq");
520 m_electricalData.transTd0 = XMLParser::GetNodeValueDouble(stability, "TransTd0");
521 m_electricalData.transTq0 = XMLParser::GetNodeValueDouble(stability, "TransTq0");
522 m_electricalData.subXd = XMLParser::GetNodeValueDouble(stability, "SubXd");
523 m_electricalData.subXq = XMLParser::GetNodeValueDouble(stability, "SubXq");
524 m_electricalData.subTd0 = XMLParser::GetNodeValueDouble(stability, "SubTd0");
525 m_electricalData.subTq0 = XMLParser::GetNodeValueDouble(stability, "SubTq0");
526
527 if (!OpenSwitchingData(electricalProp)) return false;
528 if (m_swData.swTime.size() != 0) SetDynamicEvent(true);
529
530 m_inserted = true;
531 return true;
532}
ElectricalUnit
Electrical units.
bool SetOnline(bool online=true)
Set if the element is online or offline.
Definition Element.cpp:378
virtual void SetDynamicEvent(bool dynEvent=true)
Set if the power element have dynamic event.
std::vector< double > swTime

◆ SaveElement()

rapidxml::xml_node * SyncGenerator::SaveElement ( rapidxml::xml_document<> &  doc,
rapidxml::xml_node<> *  elementListNode 
)
virtual

Reimplemented from Element.

Definition at line 365 of file SyncGenerator.cpp.

366{
367 auto elementNode = XMLParser::AppendNode(doc, elementListNode, "SyncGenerator");
368 XMLParser::SetNodeAttribute(doc, elementNode, "ID", m_elementID);
369
370 SaveCADProperties(doc, elementNode);
371 auto electricalProp = XMLParser::AppendNode(doc, elementNode, "ElectricalProperties");
372 auto isOnline = XMLParser::AppendNode(doc, electricalProp, "IsOnline");
373 XMLParser::SetNodeValue(doc, isOnline, m_online);
374 auto name = XMLParser::AppendNode(doc, electricalProp, "Name");
375 XMLParser::SetNodeValue(doc, name, m_electricalData.name);
376 auto nominalPower = XMLParser::AppendNode(doc, electricalProp, "NominalPower");
377 XMLParser::SetNodeValue(doc, nominalPower, m_electricalData.nominalPower);
378 XMLParser::SetNodeAttribute(doc, nominalPower, "UnitID", static_cast<int>(m_electricalData.nominalPowerUnit));
379 auto nominalVoltage = XMLParser::AppendNode(doc, electricalProp, "NominalVoltage");
380 XMLParser::SetNodeValue(doc, nominalVoltage, m_electricalData.nominalVoltage);
381 XMLParser::SetNodeAttribute(doc, nominalVoltage, "UnitID", static_cast<int>(m_electricalData.nominalVoltageUnit));
382 auto activePower = XMLParser::AppendNode(doc, electricalProp, "ActivePower");
383 XMLParser::SetNodeValue(doc, activePower, m_electricalData.activePower);
384 XMLParser::SetNodeAttribute(doc, activePower, "UnitID", static_cast<int>(m_electricalData.activePowerUnit));
385 auto reactivePower = XMLParser::AppendNode(doc, electricalProp, "ReactivePower");
386 XMLParser::SetNodeValue(doc, reactivePower, m_electricalData.reactivePower);
387 XMLParser::SetNodeAttribute(doc, reactivePower, "UnitID", static_cast<int>(m_electricalData.reactivePowerUnit));
388 auto haveMaxReactive = XMLParser::AppendNode(doc, electricalProp, "HaveMaxReactive");
389 XMLParser::SetNodeValue(doc, haveMaxReactive, m_electricalData.haveMaxReactive);
390 auto maxReactive = XMLParser::AppendNode(doc, electricalProp, "MaxReactive");
391 XMLParser::SetNodeValue(doc, maxReactive, m_electricalData.maxReactive);
392 XMLParser::SetNodeAttribute(doc, maxReactive, "UnitID", static_cast<int>(m_electricalData.maxReactiveUnit));
393 auto haveMinReactive = XMLParser::AppendNode(doc, electricalProp, "HaveMinReactive");
394 XMLParser::SetNodeValue(doc, haveMinReactive, m_electricalData.haveMinReactive);
395 auto minReactive = XMLParser::AppendNode(doc, electricalProp, "MinReactive");
396 XMLParser::SetNodeValue(doc, minReactive, m_electricalData.minReactive);
397 XMLParser::SetNodeAttribute(doc, minReactive, "UnitID", static_cast<int>(m_electricalData.minReactiveUnit));
398 auto useMachineBase = XMLParser::AppendNode(doc, electricalProp, "UseMachineBase");
399 XMLParser::SetNodeValue(doc, useMachineBase, m_electricalData.useMachineBase);
400
401 auto fault = XMLParser::AppendNode(doc, electricalProp, "Fault");
402 auto positiveResistance = XMLParser::AppendNode(doc, fault, "PositiveResistance");
403 XMLParser::SetNodeValue(doc, positiveResistance, m_electricalData.positiveResistance);
404 auto positiveReactance = XMLParser::AppendNode(doc, fault, "PositiveReactance");
405 XMLParser::SetNodeValue(doc, positiveReactance, m_electricalData.positiveReactance);
406 auto negativeResistance = XMLParser::AppendNode(doc, fault, "NegativeResistance");
407 XMLParser::SetNodeValue(doc, negativeResistance, m_electricalData.negativeResistance);
408 auto negativeReactance = XMLParser::AppendNode(doc, fault, "NegativeReactance");
409 XMLParser::SetNodeValue(doc, negativeReactance, m_electricalData.negativeReactance);
410 auto zeroResistance = XMLParser::AppendNode(doc, fault, "ZeroResistance");
411 XMLParser::SetNodeValue(doc, zeroResistance, m_electricalData.zeroResistance);
412 auto zeroReactance = XMLParser::AppendNode(doc, fault, "ZeroReactance");
413 XMLParser::SetNodeValue(doc, zeroReactance, m_electricalData.zeroReactance);
414 auto groundResistance = XMLParser::AppendNode(doc, fault, "GroundResistance");
415 XMLParser::SetNodeValue(doc, groundResistance, m_electricalData.groundResistance);
416 auto groundReactance = XMLParser::AppendNode(doc, fault, "GroundReactance");
417 XMLParser::SetNodeValue(doc, groundReactance, m_electricalData.groundReactance);
418 auto groundNeutral = XMLParser::AppendNode(doc, fault, "GroundNeutral");
419 XMLParser::SetNodeValue(doc, groundNeutral, m_electricalData.groundNeutral);
420
421 auto stability = XMLParser::AppendNode(doc, electricalProp, "Stability");
422 auto plotSyncMachine = XMLParser::AppendNode(doc, stability, "PlotSyncMachine");
423 XMLParser::SetNodeValue(doc, plotSyncMachine, m_electricalData.plotSyncMachine);
424 auto inertia = XMLParser::AppendNode(doc, stability, "Inertia");
425 XMLParser::SetNodeValue(doc, inertia, m_electricalData.inertia);
426 auto damping = XMLParser::AppendNode(doc, stability, "Damping");
427 XMLParser::SetNodeValue(doc, damping, m_electricalData.damping);
428 auto useAVR = XMLParser::AppendNode(doc, stability, "UseAVR");
429 XMLParser::SetNodeValue(doc, useAVR, m_electricalData.useAVR);
430 auto useSpeedGovernor = XMLParser::AppendNode(doc, stability, "UseSpeedGovernor");
431 XMLParser::SetNodeValue(doc, useSpeedGovernor, m_electricalData.useSpeedGovernor);
432 auto armResistance = XMLParser::AppendNode(doc, stability, "ArmResistance");
433 XMLParser::SetNodeValue(doc, armResistance, m_electricalData.armResistance);
434 auto potierReactance = XMLParser::AppendNode(doc, stability, "PotierReactance");
435 XMLParser::SetNodeValue(doc, potierReactance, m_electricalData.potierReactance);
436 auto satFactor = XMLParser::AppendNode(doc, stability, "SatFactor");
437 XMLParser::SetNodeValue(doc, satFactor, m_electricalData.satFactor);
438 auto syncXd = XMLParser::AppendNode(doc, stability, "SyncXd");
439 XMLParser::SetNodeValue(doc, syncXd, m_electricalData.syncXd);
440 auto syncXq = XMLParser::AppendNode(doc, stability, "SyncXq");
441 XMLParser::SetNodeValue(doc, syncXq, m_electricalData.syncXq);
442 auto transXd = XMLParser::AppendNode(doc, stability, "TransXd");
443 XMLParser::SetNodeValue(doc, transXd, m_electricalData.transXd);
444 auto transXq = XMLParser::AppendNode(doc, stability, "TransXq");
445 XMLParser::SetNodeValue(doc, transXq, m_electricalData.transXq);
446 auto transTd0 = XMLParser::AppendNode(doc, stability, "TransTd0");
447 XMLParser::SetNodeValue(doc, transTd0, m_electricalData.transTd0);
448 auto transTq0 = XMLParser::AppendNode(doc, stability, "TransTq0");
449 XMLParser::SetNodeValue(doc, transTq0, m_electricalData.transTq0);
450 auto subXd = XMLParser::AppendNode(doc, stability, "SubXd");
451 XMLParser::SetNodeValue(doc, subXd, m_electricalData.subXd);
452 auto subXq = XMLParser::AppendNode(doc, stability, "SubXq");
453 XMLParser::SetNodeValue(doc, subXq, m_electricalData.subXq);
454 auto subTd0 = XMLParser::AppendNode(doc, stability, "SubTd0");
455 XMLParser::SetNodeValue(doc, subTd0, m_electricalData.subTd0);
456 auto subTq0 = XMLParser::AppendNode(doc, stability, "SubTq0");
457 XMLParser::SetNodeValue(doc, subTq0, m_electricalData.subTq0);
458
459 SaveSwitchingData(doc, electricalProp);
460 return elementNode;
461}

◆ SavePlotData()

void SyncGenerator::SavePlotData ( )
virtual

Definition at line 534 of file SyncGenerator.cpp.

535{
536 m_electricalData.terminalVoltageVector.emplace_back(std::abs(m_electricalData.terminalVoltage));
537 m_electricalData.electricalPowerVector.emplace_back(m_electricalData.electricalPower);
538 m_electricalData.mechanicalPowerVector.emplace_back(m_electricalData.pm);
539 m_electricalData.freqVector.emplace_back(m_electricalData.speed / (2.0f * M_PI));
540 m_electricalData.fieldVoltageVector.emplace_back(m_electricalData.fieldVoltage);
541 m_electricalData.deltaVector.emplace_back(wxRadToDeg(m_electricalData.delta));
542}

◆ SetElectricalData()

virtual void SyncGenerator::SetElectricalData ( SyncGeneratorElectricalData  electricalData)
inlinevirtual

Definition at line 163 of file SyncGenerator.h.

163{ m_electricalData = electricalData; }

◆ SetNominalVoltage()

void SyncGenerator::SetNominalVoltage ( std::vector< double >  nominalVoltage,
std::vector< ElectricalUnit nominalVoltageUnit 
)
virtual

Set nominal voltage of the element.

Parameters
nominalVoltageValue of the nominal voltage.
nominalVoltageUnitUnit of the nominal voltage.

Reimplemented from PowerElement.

Definition at line 240 of file SyncGenerator.cpp.

242{
243 if (nominalVoltage.size() > 0) {
244 m_electricalData.nominalVoltage = nominalVoltage[0];
245 m_electricalData.nominalVoltageUnit = nominalVoltageUnit[0];
246 }
247}

◆ ShowForm()

bool SyncGenerator::ShowForm ( wxWindow *  parent,
Element element,
wxWindow *  workspace = nullptr 
)
virtual

Show element data form.

Parameters
parentForm parent
elementElement that will be edited.
Returns
True if the form is shown, false otherwise.

Reimplemented from Element.

Definition at line 109 of file SyncGenerator.cpp.

110{
111 Workspace* ws = dynamic_cast<Workspace*>(workspace);
112 if (!ws) return false;
113
114 SyncMachineForm generatorForm(parent, this, static_cast<int>(ws->GetProperties()->GetGeneralPropertiesData().plotLib));
115 generatorForm.SetTitle(_("Generator"));
116 generatorForm.CenterOnParent();
117 if (generatorForm.ShowModal() == wxID_OK) {
118 return true;
119 }
120 return false;
121}
Form to edit the synchronous machine power data.
This class manages the graphical and power elements. It is responsible for handling the user's intera...
Definition Workspace.h:103

Member Data Documentation

◆ m_electricalData

SyncGeneratorElectricalData SyncGenerator::m_electricalData
protected

Definition at line 174 of file SyncGenerator.h.

◆ m_sinePts

std::vector<wxPoint2DDouble> SyncGenerator::m_sinePts
protected

Definition at line 172 of file SyncGenerator.h.


The documentation for this class was generated from the following files: