From 2771fff79ac9c3c09b70f4668e7142b2e944d1f2 Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Thu, 25 Apr 2019 01:25:41 -0300 Subject: Matpower Importer and power quality calculation Power quality in implementation --- Project/ImportForm.h | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'Project/ImportForm.h') diff --git a/Project/ImportForm.h b/Project/ImportForm.h index 280396b..b4643a5 100644 --- a/Project/ImportForm.h +++ b/Project/ImportForm.h @@ -23,7 +23,9 @@ #include #include #include +#include #include +#include class Workspace; class Bus; @@ -38,6 +40,8 @@ class Transformer; class Line; class PropertiesData; +class GraphAutoLayout; + /** * @class ImportForm * @author Thales Lima Oliveira @@ -57,6 +61,8 @@ class ImportForm : public ImportFormBase virtual void OnButtonCancelClick(wxCommandEvent& event); virtual void OnButtonOKClick(wxCommandEvent& event); bool ImportSelectedFiles(); + bool ImportCEPELFiles(); + bool ImportMatpowerFiles(); Bus* GetBusFromID(std::vector busList, int id); Workspace* m_workspace = NULL; @@ -207,4 +213,67 @@ class ParseAnarede double m_mvaBase = 100.0; }; +class ParseMatpower +{ + public: + struct BusData { + int id = 0; /**< Bus electrical ID */ + int type = 0; /**< Bus Type: 1 = PQ; 2 = PV; 3 = Ref.; 4 = isolated */ + double pd = 0.0; /**< Real power demand (MW) */ + double qd = 0.0; /**< Reactive power demand (MVAr) */ + double gs = 0.0; /**< Shunt condutance (MW, V = 1.0 p.u.) */ + double bs = 0.0; /**< Shunt susceptance (MVAr, V = 1.0 p.u.). Positive for capacitor, negative for inductor? */ + int area = 0; /**< Bus area */ + double voltage = 1.0; /**< Bus abs voltage (controlled value for PV and Ref. types) */ + double angle = 0.0; /**< Angle of voltage */ + double baseVoltage = 138; /**< Base voltage (kV)*/ + wxString busName = "Bus"; /**< Bus name */ + wxPoint2DDouble busPosition = wxPoint2DDouble(0,0); /**< Bus position */ + }; + struct GenData { + int busID = 0; /**< Bus electrical ID */ + double pg = 0.0; /**< Real power output (MW) */ + double qg = 0.0; /**< Reactive power output (MVAr) */ + double maxReactivePower = 99999.0; /**< Maximum reactive power (MVAr) */ + double minReactivePower = -9999.0; /**< Minimal reactive power (MVAr) */ + double baseMVA = 100; /**< Generator power base (MVA)*/ + bool isOnline = true; /**< Machine status (> 0 = machine in-service; <= 0 = machine out-of-service) */ + }; + struct BranchData { + std::pair busConnections = std::make_pair(0, 0); /**< Branch connection IDs */ + double resistance = 0.0; /**< Branch resistance */ + double indReactance = 0.0; /**< Branch inductive reactance */ + double capSusceptance = 0.0; /**< Branch capacitive susceptance */ + double tap = 0.0; /**< Transformer tap. If equal zero the branch is a line element */ + double phaseShift = 0.0; /**< Transformer phase shift. Positive represents delay */ + bool isOnline = true; /**< Element is online */ + }; + + ParseMatpower(wxFileName mFile); + ~ParseMatpower() { ClearData(); } + + void ClearData(); + + bool Parse(); + + std::vector GetBranchData() const { return m_branchData; } + std::vector GetBusData() const { return m_busData; } + std::vector GetGenData() const { return m_genData; } + double GetMVAPowerBase() const { return m_mvaBase; } + + BusData* GetBusDataFromID(int id); + Bus* GetBusFromID(int id, std::vector busList); + + protected: + wxStringTokenizer GetMFileTokenData(wxTextFile& mFile, wxString currentLine); + wxFileName m_mFile; + + std::vector m_busData; + std::vector m_branchData; + std::vector m_genData; + + wxString m_projectName = _("Imported project"); + double m_mvaBase = 100.0; +}; + #endif // IMPORTFORM_H -- cgit