Power System Platform  2026w10a-beta
Loading...
Searching...
No Matches
EMTElement.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024 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 EMTELEMENT_H
19#define EMTELEMENT_H
20
21#include "Shunt.h"
22#include <map>
23
24class wxTextFile;
25class PropertiesData;
26
28 wxString name = "";
29 wxFileName atpFile;
30 wxString atpNodeName = "";
31 double stepSize = 1e-6;
32 int cyclesToSS = 1;
33 int recordFrequency = 1;
34 bool useMedianFilter = true;
35 std::complex<double> puVoltage = std::complex<double>(1.0, 0.0);
36 double baseVoltage = 138.0e3;
37 double frequency = 60.0;
38 wxString atpWorkFolder = "";
39 wxFileName atpPath;
40
41 // Power Flow
42 std::complex<double> y0 = std::complex<double>(0.0, 0.0); // Base admittance
43 std::complex<double> power = std::complex<double>(0.0, 0.0);
44 std::complex<double> powerDiff = std::complex<double>(0.0, 0.0);
45
46 // Harmonics
47 int numMaxHarmonics = 15;
48 double harmonicsThreshold = 0.3;
49 //std::vector< std::complex<double> > currHarmonics;
50 //std::vector<int> currHarmonicsOrder;
51 std::map<int, std::complex<double> > currHarmonics;
52 std::vector< std::pair<double, double> > atpData;
53 std::vector< std::pair<double, double> > inFFTData;
54 std::vector< std::pair<double ,std::complex<double> > > outFFTData;
55};
56
64class EMTElement : public Shunt
65{
66public:
67 EMTElement();
68 EMTElement(wxString name);
70
71 virtual Element* GetCopy();
72 virtual bool AddParent(Element* parent, wxPoint2DDouble position);
73 virtual void DrawDC(wxPoint2DDouble translation, double scale, wxGraphicsContext* gc) const;
74 virtual void DrawDC(wxPoint2DDouble translation, double scale, wxDC& dc) const;
75 virtual bool Contains(wxPoint2DDouble position) const { return m_rect.Contains(position); }
76 virtual bool Intersects(wxRect2DDouble rect) const { return m_rect.Intersects(rect); }
77 virtual void Rotate(bool clockwise = true);
78 virtual bool GetContextMenu(wxMenu& menu);
79 virtual wxString GetTipText() const;
80 virtual bool ShowForm(wxWindow* parent, Element* element);
81
82 virtual rapidxml::xml_node<>* SaveElement(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* elementListNode);
83 virtual bool OpenElement(rapidxml::xml_node<>* elementNode, std::vector<Element*> parentList);
84
85 virtual EMTElementData GetEMTElementData() { return m_data; }
86 virtual void SetEMTElementData(EMTElementData data) { m_data = data; }
87
88 wxArrayString GetATPNodes(wxArrayString atpFile);
89 bool SetATPParameter(wxTextFile& atpFile, const wxString& card, const int& line, const int& initPos, const int& size, const wxString& value);
90 bool AddConnectionToNode(wxTextFile& atpFile, const wxString& node);
91 std::vector<double> MedianFilter(const std::vector<double>& data);
92 bool CalculateCurrent( wxString& errorMsg, const bool& saveFFTData = false);
93 void UpdateData(const PropertiesData* properties = nullptr, bool updateVoltageBase = false);
94
95protected:
96 std::vector<double> DoMedianFilter(double* extension, std::vector<double>& result, const int& n);
97 EMTElementData m_data;
98};
99
100#endif // EMTELEMENT_H
101
Element to connect ATP-EMTP.
Definition EMTElement.h:65
virtual void Rotate(bool clockwise=true)
Rotate the element.
virtual bool GetContextMenu(wxMenu &menu)
Get the element contex menu.
virtual void DrawDC(wxPoint2DDouble translation, double scale, wxGraphicsContext *gc) const
Draw the element using GDI+.
virtual bool Intersects(wxRect2DDouble rect) const
Check if the element's rect intersects other rect.
Definition EMTElement.h:76
virtual bool Contains(wxPoint2DDouble position) const
Checks if the element contains a position.
Definition EMTElement.h:75
virtual wxString GetTipText() const
Get the tip text.
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,...
virtual bool ShowForm(wxWindow *parent, Element *element)
Show element data form.
virtual Element * GetCopy()
Get a the element copy.
Base class of all elements of the program. This class is responsible for manage graphical and his dat...
Definition Element.h:112
General and simulation data manager.
Abstract class for shunt power elements.
Definition Shunt.h:32