Power System Platform  2026w10a-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)
 Show element data form.
 
virtual wxString GetTipText () const
 Get the tip text.
 
virtual SyncGeneratorElectricalData GetElectricalData ()
 
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 31 of file SyncGenerator.cpp.

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

◆ SyncGenerator() [2/2]

SyncGenerator::SyncGenerator ( wxString  name)

Definition at line 35 of file SyncGenerator.cpp.

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

◆ ~SyncGenerator()

SyncGenerator::~SyncGenerator ( )
virtual

Definition at line 42 of file SyncGenerator.cpp.

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

Member Function Documentation

◆ DrawDCSymbol() [1/2]

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

Reimplemented from Machines.

Definition at line 83 of file SyncGenerator.cpp.

84{
85 std::vector<wxPoint> sinePts;
86 wxPoint pos = wxPoint(wxRound(m_position.m_x), wxRound(m_position.m_y));
87 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); }
88 dc.DrawLines(sinePts.size(), &sinePts[0]);
89}

◆ DrawDCSymbol() [2/2]

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

Reimplemented from Machines.

Definition at line 75 of file SyncGenerator.cpp.

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

◆ 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 91 of file SyncGenerator.cpp.

92{
93 menu.Append(ID_EDIT_ELEMENT, _("Edit Generator"));
94
95 wxMenu* textMenu = new wxMenu();
96
97 textMenu->Append(ID_TXT_NAME, _("Name"));
98 textMenu->Append(ID_TXT_ACTIVE_POWER, _("Active power"));
99 textMenu->Append(ID_TXT_REACTIVE_POWER, _("Reactive power"));
100 textMenu->Append(ID_TXT_FAULTCURRENT, _("Fault current"));
101 textMenu->SetClientData(menu.GetClientData());
102 menu.AppendSubMenu(textMenu, _("Add text"));
103
104 GeneralMenuItens(menu);
105 return true;
106}
@ ID_EDIT_ELEMENT
Definition Element.h:75
virtual void GeneralMenuItens(wxMenu &menu)
Insert general itens to context menu.
Definition Element.cpp:457
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 202 of file SyncGenerator.cpp.

203{
204 auto copy = new SyncGenerator(*this);
205
206 auto data = copy->GetElectricalData();
207
208 // AVR
209 if (m_electricalData.avr)
210 {
211 std::vector<std::shared_ptr<ConnectionLine>> cLineList;
212 std::vector<std::shared_ptr<ControlElement>> elementList;
213
214 m_electricalData.avr->GetContainerCopy(elementList, cLineList);
215
216 auto avrCopy = new ControlElementContainer();
217 avrCopy->FillContainer(elementList, cLineList);
218
219 data.avr = avrCopy;
220 }
221 else
222 data.avr = nullptr;
223
224
225 // Speed governor
226 if (m_electricalData.speedGov)
227 {
228 std::vector<std::shared_ptr<ConnectionLine>> cLineList;
229 std::vector<std::shared_ptr<ControlElement>> elementList;
230
231 m_electricalData.speedGov->GetContainerCopy(elementList, cLineList);
232
233 auto speedGovCopy = new ControlElementContainer();
234 speedGovCopy->FillContainer(elementList, cLineList);
235
236 data.speedGov = speedGovCopy;
237 }
238 else
239 data.speedGov = nullptr;
240
241 copy->SetElectricalData(data);
242
243 return copy;
244}
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; }

◆ 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 292 of file SyncGenerator.cpp.

293{
294 if (study == PlotStudy::STABILITY) {
295 if (!m_electricalData.plotSyncMachine) return false;
296 plotData.SetName(m_electricalData.name);
297 plotData.SetCurveType(ElementPlotData::CurveType::CT_SYNC_GENERATOR);
298
299 std::vector<double> absTerminalVoltage, activePower, reactivePower;
300 for (unsigned int i = 0; i < m_electricalData.terminalVoltageVector.size(); ++i) {
301 activePower.push_back(std::real(m_electricalData.electricalPowerVector[i]));
302 reactivePower.push_back(std::imag(m_electricalData.electricalPowerVector[i]));
303 }
304 plotData.AddData(m_electricalData.terminalVoltageVector, _("Terminal voltage"));
305 plotData.AddData(activePower, _("Active power"));
306 plotData.AddData(reactivePower, _("Reactive power"));
307 plotData.AddData(m_electricalData.mechanicalPowerVector, _("Mechanical power"));
308 plotData.AddData(m_electricalData.freqVector, _("Frequency"));
309 plotData.AddData(m_electricalData.fieldVoltageVector, _("Field voltage"));
310 plotData.AddData(m_electricalData.deltaVector, _("Delta"));
311 return true;
312 }
313 return false;
314}

◆ GetPUElectricalData()

SyncGeneratorElectricalData SyncGenerator::GetPUElectricalData ( double  systemPowerBase)
virtual

Definition at line 120 of file SyncGenerator.cpp.

121{
122 SyncGeneratorElectricalData data = m_electricalData;
123 double machineBasePower = 1.0;
124 if (data.useMachineBase) { machineBasePower = GetValueFromUnit(data.nominalPower, data.nominalPowerUnit); }
125
126 // Active power
127 double activePower = GetValueFromUnit(data.activePower, data.activePowerUnit);
128 if (!m_online) activePower = 0.0;
129 if (data.activePowerUnit == ElectricalUnit::UNIT_PU) {
130 if (data.useMachineBase) data.activePower = (activePower * machineBasePower) / systemPowerBase;
131 }
132 else {
133 data.activePower = activePower / systemPowerBase;
134 }
135 data.activePowerUnit = ElectricalUnit::UNIT_PU;
136
137 // Reactive power
138 double reactivePower = GetValueFromUnit(data.reactivePower, data.reactivePowerUnit);
139 if (!m_online) reactivePower = 0.0;
140 if (data.reactivePowerUnit == ElectricalUnit::UNIT_PU) {
141 if (data.useMachineBase) data.reactivePower = (reactivePower * machineBasePower) / systemPowerBase;
142 }
143 else {
144 data.reactivePower = reactivePower / systemPowerBase;
145 }
146 data.reactivePowerUnit = ElectricalUnit::UNIT_PU;
147
148 // Max reactive power
149 double maxReactive = GetValueFromUnit(data.maxReactive, data.maxReactiveUnit);
150 if (data.maxReactiveUnit == ElectricalUnit::UNIT_PU) {
151 if (data.useMachineBase) data.maxReactive = (maxReactive * machineBasePower) / systemPowerBase;
152 }
153 else {
154 data.maxReactive = maxReactive / systemPowerBase;
155 }
156 data.maxReactiveUnit = ElectricalUnit::UNIT_PU;
157
158 // Min reactive power
159 double minReactive = GetValueFromUnit(data.minReactive, data.minReactiveUnit);
160 if (data.minReactiveUnit == ElectricalUnit::UNIT_PU) {
161 if (data.useMachineBase) data.minReactive = (minReactive * machineBasePower) / systemPowerBase;
162 }
163 else {
164 data.minReactive = minReactive / systemPowerBase;
165 }
166 data.minReactiveUnit = ElectricalUnit::UNIT_PU;
167
168 double baseVoltage = GetValueFromUnit(data.nominalVoltage, data.nominalVoltageUnit);
169 double systemBaseImpedance = (baseVoltage * baseVoltage) / systemPowerBase;
170 double machineBaseImpedance = (baseVoltage * baseVoltage) / machineBasePower;
171
172 // Fault data
173 if (data.useMachineBase) {
174 data.positiveResistance = (data.positiveResistance * machineBaseImpedance) / systemBaseImpedance;
175 data.positiveReactance = (data.positiveReactance * machineBaseImpedance) / systemBaseImpedance;
176 data.negativeResistance = (data.negativeResistance * machineBaseImpedance) / systemBaseImpedance;
177 data.negativeReactance = (data.negativeReactance * machineBaseImpedance) / systemBaseImpedance;
178 data.zeroResistance = (data.zeroResistance * machineBaseImpedance) / systemBaseImpedance;
179 data.zeroReactance = (data.zeroReactance * machineBaseImpedance) / systemBaseImpedance;
180 data.groundResistance = (data.groundResistance * machineBaseImpedance) / systemBaseImpedance;
181 data.groundReactance = (data.groundReactance * machineBaseImpedance) / systemBaseImpedance;
182 }
183
184 if (!m_online) {
185 data.faultCurrent[0] = std::complex<double>(0, 0);
186 data.faultCurrent[1] = std::complex<double>(0, 0);
187 data.faultCurrent[2] = std::complex<double>(0, 0);
188 }
189
190 return data;
191}

◆ GetTipText()

wxString SyncGenerator::GetTipText ( ) const
virtual

Get the tip text.

Returns
Tip text.

Reimplemented from Element.

Definition at line 246 of file SyncGenerator.cpp.

247{
248 wxString tipText = m_electricalData.name;
249 tipText += "\n";
250 double activePower = m_electricalData.activePower;
251 if (!m_online) activePower = 0.0;
252 tipText += _("\nP = ") + wxString::FromDouble(activePower, 5);
253 switch (m_electricalData.activePowerUnit) {
255 tipText += _(" p.u.");
256 } break;
258 tipText += _(" W");
259 } break;
261 tipText += _(" kW");
262 } break;
264 tipText += _(" MW");
265 } break;
266 default:
267 break;
268 }
269 double reactivePower = m_electricalData.reactivePower;
270 if (!m_online) reactivePower = 0.0;
271 tipText += _("\nQ = ") + wxString::FromDouble(reactivePower, 5);
272 switch (m_electricalData.reactivePowerUnit) {
274 tipText += _(" p.u.");
275 } break;
277 tipText += _(" var");
278 } break;
280 tipText += _(" kvar");
281 } break;
283 tipText += _(" Mvar");
284 } break;
285 default:
286 break;
287 }
288
289 return tipText;
290}

◆ Init()

void SyncGenerator::Init ( )
virtual

Definition at line 50 of file SyncGenerator.cpp.

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

◆ OpenElement()

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

Reimplemented from PowerElement.

Definition at line 414 of file SyncGenerator.cpp.

415{
416 if (!OpenCADProperties(elementNode, parentList)) return false;
417
418 auto electricalProp = elementNode->first_node("ElectricalProperties");
419 if (!electricalProp) return false;
420
421 SetOnline(XMLParser::GetNodeValueInt(electricalProp, "IsOnline"));
422 m_electricalData.name = electricalProp->first_node("Name")->value();
423 m_electricalData.nominalPower = XMLParser::GetNodeValueDouble(electricalProp, "NominalPower");
424 m_electricalData.nominalPowerUnit =
425 static_cast<ElectricalUnit>(XMLParser::GetAttributeValueInt(electricalProp, "NominalPower", "UnitID"));
426 m_electricalData.nominalVoltage = XMLParser::GetNodeValueDouble(electricalProp, "NominalVoltage");
427 m_electricalData.nominalVoltageUnit =
428 static_cast<ElectricalUnit>(XMLParser::GetAttributeValueInt(electricalProp, "NominalVoltage", "UnitID"));
429 m_electricalData.activePower = XMLParser::GetNodeValueDouble(electricalProp, "ActivePower");
430 m_electricalData.activePowerUnit =
431 static_cast<ElectricalUnit>(XMLParser::GetAttributeValueInt(electricalProp, "ActivePower", "UnitID"));
432 m_electricalData.reactivePower = XMLParser::GetNodeValueDouble(electricalProp, "ReactivePower");
433 m_electricalData.reactivePowerUnit =
434 static_cast<ElectricalUnit>(XMLParser::GetAttributeValueInt(electricalProp, "ReactivePower", "UnitID"));
435 m_electricalData.haveMaxReactive = XMLParser::GetNodeValueInt(electricalProp, "HaveMaxReactive");
436 m_electricalData.maxReactive = XMLParser::GetNodeValueDouble(electricalProp, "MaxReactive");
437 m_electricalData.maxReactiveUnit =
438 static_cast<ElectricalUnit>(XMLParser::GetAttributeValueInt(electricalProp, "MaxReactive", "UnitID"));
439 m_electricalData.haveMinReactive = XMLParser::GetNodeValueInt(electricalProp, "HaveMinReactive");
440 m_electricalData.minReactive = XMLParser::GetNodeValueDouble(electricalProp, "MinReactive");
441 m_electricalData.minReactiveUnit =
442 static_cast<ElectricalUnit>(XMLParser::GetAttributeValueInt(electricalProp, "MinReactive", "UnitID"));
443 m_electricalData.useMachineBase = XMLParser::GetNodeValueInt(electricalProp, "UseMachineBase");
444
445 auto fault = electricalProp->first_node("Fault");
446 if (!fault) return false;
447 m_electricalData.positiveResistance = XMLParser::GetNodeValueDouble(fault, "PositiveResistance");
448 m_electricalData.positiveReactance = XMLParser::GetNodeValueDouble(fault, "PositiveReactance");
449 m_electricalData.negativeResistance = XMLParser::GetNodeValueDouble(fault, "NegativeResistance");
450 m_electricalData.negativeReactance = XMLParser::GetNodeValueDouble(fault, "NegativeReactance");
451 m_electricalData.zeroResistance = XMLParser::GetNodeValueDouble(fault, "ZeroResistance");
452 m_electricalData.zeroReactance = XMLParser::GetNodeValueDouble(fault, "ZeroReactance");
453 m_electricalData.groundResistance = XMLParser::GetNodeValueDouble(fault, "GroundResistance");
454 m_electricalData.groundReactance = XMLParser::GetNodeValueDouble(fault, "GroundReactance");
455 m_electricalData.groundNeutral = XMLParser::GetNodeValueInt(fault, "GroundNeutral");
456
457 auto stability = electricalProp->first_node("Stability");
458 if (!stability) return false;
459 m_electricalData.plotSyncMachine = XMLParser::GetNodeValueInt(stability, "PlotSyncMachine");
460 m_electricalData.inertia = XMLParser::GetNodeValueDouble(stability, "Inertia");
461 m_electricalData.damping = XMLParser::GetNodeValueDouble(stability, "Damping");
462 m_electricalData.useAVR = XMLParser::GetNodeValueInt(stability, "UseAVR");
463 m_electricalData.useSpeedGovernor = XMLParser::GetNodeValueInt(stability, "UseSpeedGovernor");
464 m_electricalData.armResistance = XMLParser::GetNodeValueDouble(stability, "ArmResistance");
465 m_electricalData.potierReactance = XMLParser::GetNodeValueDouble(stability, "PotierReactance");
466 m_electricalData.satFactor = XMLParser::GetNodeValueDouble(stability, "SatFactor");
467 m_electricalData.syncXd = XMLParser::GetNodeValueDouble(stability, "SyncXd");
468 m_electricalData.syncXq = XMLParser::GetNodeValueDouble(stability, "SyncXq");
469 m_electricalData.transXd = XMLParser::GetNodeValueDouble(stability, "TransXd");
470 m_electricalData.transXq = XMLParser::GetNodeValueDouble(stability, "TransXq");
471 m_electricalData.transTd0 = XMLParser::GetNodeValueDouble(stability, "TransTd0");
472 m_electricalData.transTq0 = XMLParser::GetNodeValueDouble(stability, "TransTq0");
473 m_electricalData.subXd = XMLParser::GetNodeValueDouble(stability, "SubXd");
474 m_electricalData.subXq = XMLParser::GetNodeValueDouble(stability, "SubXq");
475 m_electricalData.subTd0 = XMLParser::GetNodeValueDouble(stability, "SubTd0");
476 m_electricalData.subTq0 = XMLParser::GetNodeValueDouble(stability, "SubTq0");
477
478 if (!OpenSwitchingData(electricalProp)) return false;
479 if (m_swData.swTime.size() != 0) SetDynamicEvent(true);
480
481 m_inserted = true;
482 return true;
483}
ElectricalUnit
Electrical units.
bool SetOnline(bool online=true)
Set if the element is online or offline.
Definition Element.cpp:447
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 316 of file SyncGenerator.cpp.

317{
318 auto elementNode = XMLParser::AppendNode(doc, elementListNode, "SyncGenerator");
319 XMLParser::SetNodeAttribute(doc, elementNode, "ID", m_elementID);
320
321 SaveCADProperties(doc, elementNode);
322 auto electricalProp = XMLParser::AppendNode(doc, elementNode, "ElectricalProperties");
323 auto isOnline = XMLParser::AppendNode(doc, electricalProp, "IsOnline");
324 XMLParser::SetNodeValue(doc, isOnline, m_online);
325 auto name = XMLParser::AppendNode(doc, electricalProp, "Name");
326 XMLParser::SetNodeValue(doc, name, m_electricalData.name);
327 auto nominalPower = XMLParser::AppendNode(doc, electricalProp, "NominalPower");
328 XMLParser::SetNodeValue(doc, nominalPower, m_electricalData.nominalPower);
329 XMLParser::SetNodeAttribute(doc, nominalPower, "UnitID", static_cast<int>(m_electricalData.nominalPowerUnit));
330 auto nominalVoltage = XMLParser::AppendNode(doc, electricalProp, "NominalVoltage");
331 XMLParser::SetNodeValue(doc, nominalVoltage, m_electricalData.nominalVoltage);
332 XMLParser::SetNodeAttribute(doc, nominalVoltage, "UnitID", static_cast<int>(m_electricalData.nominalVoltageUnit));
333 auto activePower = XMLParser::AppendNode(doc, electricalProp, "ActivePower");
334 XMLParser::SetNodeValue(doc, activePower, m_electricalData.activePower);
335 XMLParser::SetNodeAttribute(doc, activePower, "UnitID", static_cast<int>(m_electricalData.activePowerUnit));
336 auto reactivePower = XMLParser::AppendNode(doc, electricalProp, "ReactivePower");
337 XMLParser::SetNodeValue(doc, reactivePower, m_electricalData.reactivePower);
338 XMLParser::SetNodeAttribute(doc, reactivePower, "UnitID", static_cast<int>(m_electricalData.reactivePowerUnit));
339 auto haveMaxReactive = XMLParser::AppendNode(doc, electricalProp, "HaveMaxReactive");
340 XMLParser::SetNodeValue(doc, haveMaxReactive, m_electricalData.haveMaxReactive);
341 auto maxReactive = XMLParser::AppendNode(doc, electricalProp, "MaxReactive");
342 XMLParser::SetNodeValue(doc, maxReactive, m_electricalData.maxReactive);
343 XMLParser::SetNodeAttribute(doc, maxReactive, "UnitID", static_cast<int>(m_electricalData.maxReactiveUnit));
344 auto haveMinReactive = XMLParser::AppendNode(doc, electricalProp, "HaveMinReactive");
345 XMLParser::SetNodeValue(doc, haveMinReactive, m_electricalData.haveMinReactive);
346 auto minReactive = XMLParser::AppendNode(doc, electricalProp, "MinReactive");
347 XMLParser::SetNodeValue(doc, minReactive, m_electricalData.minReactive);
348 XMLParser::SetNodeAttribute(doc, minReactive, "UnitID", static_cast<int>(m_electricalData.minReactiveUnit));
349 auto useMachineBase = XMLParser::AppendNode(doc, electricalProp, "UseMachineBase");
350 XMLParser::SetNodeValue(doc, useMachineBase, m_electricalData.useMachineBase);
351
352 auto fault = XMLParser::AppendNode(doc, electricalProp, "Fault");
353 auto positiveResistance = XMLParser::AppendNode(doc, fault, "PositiveResistance");
354 XMLParser::SetNodeValue(doc, positiveResistance, m_electricalData.positiveResistance);
355 auto positiveReactance = XMLParser::AppendNode(doc, fault, "PositiveReactance");
356 XMLParser::SetNodeValue(doc, positiveReactance, m_electricalData.positiveReactance);
357 auto negativeResistance = XMLParser::AppendNode(doc, fault, "NegativeResistance");
358 XMLParser::SetNodeValue(doc, negativeResistance, m_electricalData.negativeResistance);
359 auto negativeReactance = XMLParser::AppendNode(doc, fault, "NegativeReactance");
360 XMLParser::SetNodeValue(doc, negativeReactance, m_electricalData.negativeReactance);
361 auto zeroResistance = XMLParser::AppendNode(doc, fault, "ZeroResistance");
362 XMLParser::SetNodeValue(doc, zeroResistance, m_electricalData.zeroResistance);
363 auto zeroReactance = XMLParser::AppendNode(doc, fault, "ZeroReactance");
364 XMLParser::SetNodeValue(doc, zeroReactance, m_electricalData.zeroReactance);
365 auto groundResistance = XMLParser::AppendNode(doc, fault, "GroundResistance");
366 XMLParser::SetNodeValue(doc, groundResistance, m_electricalData.groundResistance);
367 auto groundReactance = XMLParser::AppendNode(doc, fault, "GroundReactance");
368 XMLParser::SetNodeValue(doc, groundReactance, m_electricalData.groundReactance);
369 auto groundNeutral = XMLParser::AppendNode(doc, fault, "GroundNeutral");
370 XMLParser::SetNodeValue(doc, groundNeutral, m_electricalData.groundNeutral);
371
372 auto stability = XMLParser::AppendNode(doc, electricalProp, "Stability");
373 auto plotSyncMachine = XMLParser::AppendNode(doc, stability, "PlotSyncMachine");
374 XMLParser::SetNodeValue(doc, plotSyncMachine, m_electricalData.plotSyncMachine);
375 auto inertia = XMLParser::AppendNode(doc, stability, "Inertia");
376 XMLParser::SetNodeValue(doc, inertia, m_electricalData.inertia);
377 auto damping = XMLParser::AppendNode(doc, stability, "Damping");
378 XMLParser::SetNodeValue(doc, damping, m_electricalData.damping);
379 auto useAVR = XMLParser::AppendNode(doc, stability, "UseAVR");
380 XMLParser::SetNodeValue(doc, useAVR, m_electricalData.useAVR);
381 auto useSpeedGovernor = XMLParser::AppendNode(doc, stability, "UseSpeedGovernor");
382 XMLParser::SetNodeValue(doc, useSpeedGovernor, m_electricalData.useSpeedGovernor);
383 auto armResistance = XMLParser::AppendNode(doc, stability, "ArmResistance");
384 XMLParser::SetNodeValue(doc, armResistance, m_electricalData.armResistance);
385 auto potierReactance = XMLParser::AppendNode(doc, stability, "PotierReactance");
386 XMLParser::SetNodeValue(doc, potierReactance, m_electricalData.potierReactance);
387 auto satFactor = XMLParser::AppendNode(doc, stability, "SatFactor");
388 XMLParser::SetNodeValue(doc, satFactor, m_electricalData.satFactor);
389 auto syncXd = XMLParser::AppendNode(doc, stability, "SyncXd");
390 XMLParser::SetNodeValue(doc, syncXd, m_electricalData.syncXd);
391 auto syncXq = XMLParser::AppendNode(doc, stability, "SyncXq");
392 XMLParser::SetNodeValue(doc, syncXq, m_electricalData.syncXq);
393 auto transXd = XMLParser::AppendNode(doc, stability, "TransXd");
394 XMLParser::SetNodeValue(doc, transXd, m_electricalData.transXd);
395 auto transXq = XMLParser::AppendNode(doc, stability, "TransXq");
396 XMLParser::SetNodeValue(doc, transXq, m_electricalData.transXq);
397 auto transTd0 = XMLParser::AppendNode(doc, stability, "TransTd0");
398 XMLParser::SetNodeValue(doc, transTd0, m_electricalData.transTd0);
399 auto transTq0 = XMLParser::AppendNode(doc, stability, "TransTq0");
400 XMLParser::SetNodeValue(doc, transTq0, m_electricalData.transTq0);
401 auto subXd = XMLParser::AppendNode(doc, stability, "SubXd");
402 XMLParser::SetNodeValue(doc, subXd, m_electricalData.subXd);
403 auto subXq = XMLParser::AppendNode(doc, stability, "SubXq");
404 XMLParser::SetNodeValue(doc, subXq, m_electricalData.subXq);
405 auto subTd0 = XMLParser::AppendNode(doc, stability, "SubTd0");
406 XMLParser::SetNodeValue(doc, subTd0, m_electricalData.subTd0);
407 auto subTq0 = XMLParser::AppendNode(doc, stability, "SubTq0");
408 XMLParser::SetNodeValue(doc, subTq0, m_electricalData.subTq0);
409
410 SaveSwitchingData(doc, electricalProp);
411 return elementNode;
412}

◆ SavePlotData()

void SyncGenerator::SavePlotData ( )
virtual

Definition at line 485 of file SyncGenerator.cpp.

486{
487 m_electricalData.terminalVoltageVector.emplace_back(std::abs(m_electricalData.terminalVoltage));
488 m_electricalData.electricalPowerVector.emplace_back(m_electricalData.electricalPower);
489 m_electricalData.mechanicalPowerVector.emplace_back(m_electricalData.pm);
490 m_electricalData.freqVector.emplace_back(m_electricalData.speed / (2.0f * M_PI));
491 m_electricalData.fieldVoltageVector.emplace_back(m_electricalData.fieldVoltage);
492 m_electricalData.deltaVector.emplace_back(wxRadToDeg(m_electricalData.delta));
493}

◆ SetElectricalData()

virtual void SyncGenerator::SetElectricalData ( SyncGeneratorElectricalData  electricalData)
inlinevirtual

Definition at line 162 of file SyncGenerator.h.

162{ 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 193 of file SyncGenerator.cpp.

195{
196 if (nominalVoltage.size() > 0) {
197 m_electricalData.nominalVoltage = nominalVoltage[0];
198 m_electricalData.nominalVoltageUnit = nominalVoltageUnit[0];
199 }
200}

◆ ShowForm()

bool SyncGenerator::ShowForm ( wxWindow *  parent,
Element element 
)
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 108 of file SyncGenerator.cpp.

109{
110 Workspace* ws = static_cast<Workspace*>(parent);
111 SyncMachineForm generatorForm(parent, this, static_cast<int>(ws->GetProperties()->GetGeneralPropertiesData().plotLib));
112 generatorForm.SetTitle(_("Generator"));
113 generatorForm.CenterOnParent();
114 if (generatorForm.ShowModal() == wxID_OK) {
115 return true;
116 }
117 return false;
118}
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 173 of file SyncGenerator.h.

◆ m_sinePts

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

Definition at line 171 of file SyncGenerator.h.


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