Power System Platform  2026w34a-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;
46 ElectricalUnit nominalPowerUnit = ElectricalUnit::UNIT_MVA;
47 double resistance = 0.0;
48 ElectricalUnit resistanceUnit = ElectricalUnit::UNIT_PU;
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 // On-Load Tap Changer (OLTC / Comutador sob carga)
57 bool hasTapChanger = false;
58 double nominalTurnsRatio = 1.0;
59 int oltcControlledBus = 1; // 0 = Primary (Bus 1), 1 = Secondary (Bus 2)
60 double oltcTargetVoltage = 1.0; // Target voltage in p.u.
61 double oltcVoltageDeadband = 0.005; // Voltage deadband/tolerance in p.u.
62 double oltcMinTap = 0.90; // Minimum tap in p.u.
63 double oltcMaxTap = 1.10; // Maximum tap in p.u.
64 double oltcTapStep = 0.00625; // Tap step size in p.u. (e.g. 5/8 % = 0.00625)
65 bool oltcIsDiscrete = false; // Discrete tap steps vs continuous
66
67 // Power flow (p.u.)
68 std::complex<double> current[2] = { std::complex<double>(0.0, 0.0), std::complex<double>(0.0, 0.0) };
69 std::complex<double> powerFlow[2] = { std::complex<double>(0.0, 0.0), std::complex<double>(0.0, 0.0) };
70
71 // Fault
72 double zeroResistance = 0.0;
73 double zeroIndReactance = 1.0;
74 double primaryGrndResistance = 0.0;
75 double primaryGrndReactance = 0.0;
76 double secondaryGrndResistance = 0.0;
77 double secondaryGrndReactance = 0.0;
78
79 // p.u. fault data
80 std::complex<double> faultCurrent[2][3];
81
82 // Power Quality
83 std::vector<int> harmonicOrder;
84 std::vector< std::complex<double> > harmonicCurrent[2];
85
86 // Arc Flash
87 ArcFlashProtectionData arcFlashProtection;
88};
89
98class Transformer : public Branch
99{
100public:
101 Transformer();
102 Transformer(wxString name);
103 virtual ~Transformer();
104
105 virtual Element* GetCopy();
106 virtual bool AddParent(Element* parent, wxPoint2DDouble position, bool isOpening = false);
107 virtual bool Contains(wxPoint2DDouble position) const;
108 //virtual void Draw(wxPoint2DDouble translation, double scale) const;
109 virtual void DrawDC(GUIColour* guiColour, wxPoint2DDouble translation, double scale, wxGraphicsContext* gc) const;
110 virtual void DrawDC(GUIColour* guiColour, wxPoint2DDouble translation, double scale, wxDC& dc) const;
111 virtual bool Intersects(wxRect2DDouble rect) const;
112 virtual void Rotate(bool clockwise = true);
113 virtual void Move(wxPoint2DDouble position);
114 virtual void AlignToGrid(double gridSize = 20.0) override;
115 virtual void MoveNode(Element* parent, wxPoint2DDouble position);
116 virtual void StartMove(wxPoint2DDouble position);
117 virtual bool GetContextMenu(wxMenu& menu);
118 virtual wxString GetTipText() const;
119 virtual void RotateNode(Element* parent, bool clockwise);
120 virtual bool SetNodeParent(Element* parent);
121 virtual void SetPowerFlowDirection(PowerFlowDirection pfDirection);
122 virtual bool ShowForm(wxWindow* parent, Element* element, wxWindow* workspace = nullptr);
123 virtual TransformerElectricalData GetElectricalData() const { return m_electricalData; }
124 virtual TransformerElectricalData& GetElectricalDataRef() { return m_electricalData; }
125 virtual TransformerElectricalData GetPUElectricalData(double systemBasePower) const;
126 virtual void SetElectricaData(TransformerElectricalData electricalData) { m_electricalData = electricalData; }
127 virtual void SetNominalVoltage(std::vector<double> nominalVoltage, std::vector<ElectricalUnit> nominalVoltageUnit);
128 virtual void SetBestPositionAndRotation();
129
130 virtual rapidxml::xml_node<>* SaveElement(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* elementListNode);
131 virtual bool OpenElement(rapidxml::xml_node<>* elementNode, std::vector<Element*> parentList);
132
133protected:
134 void UpdatePowerFlowArrowsPosition();
135 TransformerElectricalData m_electricalData;
136};
137
138#endif // TRANSFORMER_H
PowerFlowDirection
Direction of power flow arrows.
Element()
Constructor.
Definition Element.cpp:28
Form to edit the transformer power data and OLTC tap changer.
virtual void StartMove(wxPoint2DDouble position)
Update the element attributes related to the movement.
virtual wxString GetTipText() const
Get the tip text.
virtual void DrawDC(GUIColour *guiColour, wxPoint2DDouble translation, double scale, wxGraphicsContext *gc) const
Draw the element using GDI+.
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 bool ShowForm(wxWindow *parent, Element *element, wxWindow *workspace=nullptr)
Show element data form.
virtual void Rotate(bool clockwise=true)
Rotate the element.
virtual bool AddParent(Element *parent, wxPoint2DDouble position, bool isOpening=false)
Add a parent to the element. This method must be used on power elements that connect to a bus,...
virtual void RotateNode(Element *parent, bool clockwise)
Rotate a node.
virtual bool GetContextMenu(wxMenu &menu)
Get the element contex menu.