Power System Platform  2026w10a-beta
Loading...
Searching...
No Matches
Transformer.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 TRANSFORMER_H
19#define TRANSFORMER_H
20
21#include "Branch.h"
22
23class TransformerForm;
24
25enum TransformerConnection {
26 GWYE_GWYE = 0,
27 WYE_GWYE,
28 GWYE_WYE,
29 WYE_WYE,
30 DELTA_GWYE,
31 DELTA_WYE,
32 GWYE_DELTA,
33 WYE_DELTA,
34 DELTA_DELTA
35};
36
38 // General
39 wxString name = "";
40 double primaryNominalVoltage = 138.0;
41 ElectricalUnit primaryNominalVoltageUnit = ElectricalUnit::UNIT_kV;
42 double secondaryNominalVoltage = 138.0;
43 ElectricalUnit secondaryNominalVoltageUnit = ElectricalUnit::UNIT_kV;
44 int baseVoltage = 0;
45 double nominalPower = 100.0;
47 double resistance = 0.0;
49 double indReactance = 1.0;
50 ElectricalUnit indReactanceUnit = ElectricalUnit::UNIT_PU;
51 TransformerConnection connection = GWYE_GWYE;
52 double turnsRatio = 1.0;
53 double phaseShift = 0.0;
54 bool useTransformerPower = false;
55
56 // Power flow (p.u.)
57 std::complex<double> current[2] = {std::complex<double>(0.0, 0.0), std::complex<double>(0.0, 0.0)};
58 std::complex<double> powerFlow[2] = {std::complex<double>(0.0, 0.0), std::complex<double>(0.0, 0.0)};
59
60 // Fault
61 double zeroResistance = 0.0;
62 double zeroIndReactance = 1.0;
63 double primaryGrndResistance = 0.0;
64 double primaryGrndReactance = 0.0;
65 double secondaryGrndResistance = 0.0;
66 double secondaryGrndReactance = 0.0;
67
68 // p.u. fault data
69 std::complex<double> faultCurrent[2][3];
70
71 // Power Quality
72 std::vector<int> harmonicOrder;
73 std::vector< std::complex<double> > harmonicCurrent[2];
74};
75
83class Transformer : public Branch
84{
85 public:
87 Transformer(wxString name);
88 virtual ~Transformer();
89
90 virtual Element* GetCopy();
91 virtual bool AddParent(Element* parent, wxPoint2DDouble position);
92 virtual bool Contains(wxPoint2DDouble position) const;
93 //virtual void Draw(wxPoint2DDouble translation, double scale) const;
94 virtual void DrawDC(wxPoint2DDouble translation, double scale, wxGraphicsContext* gc) const;
95 virtual void DrawDC(wxPoint2DDouble translation, double scale, wxDC& dc) const;
96 virtual bool Intersects(wxRect2DDouble rect) const;
97 virtual void Rotate(bool clockwise = true);
98 virtual void Move(wxPoint2DDouble position);
99 virtual void MoveNode(Element* parent, wxPoint2DDouble position);
100 virtual void StartMove(wxPoint2DDouble position);
101 virtual bool GetContextMenu(wxMenu& menu);
102 virtual wxString GetTipText() const;
103 virtual void RotateNode(Element* parent, bool clockwise);
104 virtual bool SetNodeParent(Element* parent);
105 virtual void SetPowerFlowDirection(PowerFlowDirection pfDirection);
106 virtual bool ShowForm(wxWindow* parent, Element* element);
107 virtual TransformerElectricalData GetElectricalData() const { return m_electricalData; }
108 virtual TransformerElectricalData GetPUElectricalData(double systemBasePower);
109 virtual void SetElectricaData(TransformerElectricalData electricalData) { m_electricalData = electricalData; }
110 virtual void SetNominalVoltage(std::vector<double> nominalVoltage, std::vector<ElectricalUnit> nominalVoltageUnit);
111 virtual void SetBestPositionAndRotation();
112
113 virtual rapidxml::xml_node<>* SaveElement(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* elementListNode);
114 virtual bool OpenElement(rapidxml::xml_node<>* elementNode, std::vector<Element*> parentList);
115
116 protected:
117 void UpdatePowerFlowArrowsPosition();
118 TransformerElectricalData m_electricalData;
119};
120
121#endif // TRANSFORMER_H
ElectricalUnit
Electrical units.
PowerFlowDirection
Direction of power flow arrows.
Abstract class for branch power elements.
Definition Branch.h:32
Base class of all elements of the program. This class is responsible for manage graphical and his dat...
Definition Element.h:112
Form to edit the transformer power data.
Two-winding transformer power element.
Definition Transformer.h:84
virtual void StartMove(wxPoint2DDouble position)
Update the element attributes related to the movement.
virtual wxString GetTipText() const
Get the tip text.
virtual Element * GetCopy()
Get a the element copy.
virtual bool Contains(wxPoint2DDouble position) const
Checks if the element contains a position.
virtual void SetPowerFlowDirection(PowerFlowDirection pfDirection)
Set the direction of the power flow.
virtual bool Intersects(wxRect2DDouble rect) const
Check if the element's rect intersects other rect.
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 po...
virtual void Move(wxPoint2DDouble position)
Move the element other position.
virtual void SetNominalVoltage(std::vector< double > nominalVoltage, std::vector< ElectricalUnit > nominalVoltageUnit)
Set nominal voltage of the element.
virtual void MoveNode(Element *parent, wxPoint2DDouble position)
Move a node. StartMove(wxPoint2DDouble position) before start moving.
virtual void DrawDC(wxPoint2DDouble translation, double scale, wxGraphicsContext *gc) const
Draw the element using GDI+.
virtual void Rotate(bool clockwise=true)
Rotate the element.
virtual bool ShowForm(wxWindow *parent, Element *element)
Show element data form.
virtual void RotateNode(Element *parent, bool clockwise)
Rotate a node.
virtual bool GetContextMenu(wxMenu &menu)
Get the element contex menu.
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,...