diff options
31 files changed, 649 insertions, 152 deletions
diff --git a/.codelite/.tern-port b/.codelite/.tern-port index 4dfdd5b..8706adc 100644 --- a/.codelite/.tern-port +++ b/.codelite/.tern-port @@ -1 +1 @@ -54807
\ No newline at end of file +55195
\ No newline at end of file diff --git a/.codelite/PSP.session b/.codelite/PSP.session index 6777ae1..2395bb7 100644 --- a/.codelite/PSP.session +++ b/.codelite/PSP.session @@ -1,12 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> <Session Name="C:\Users\Thales\Documents\GitHub\PSP\PSP.workspace"> - <int Value="7" Name="m_selectedTab"/> + <int Value="11" Name="m_selectedTab"/> <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\PSP.workspace" Name="m_workspaceName"/> <TabInfoArray Name="TabInfoArray"> <TabInfo> <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Workspace.cpp" Name="FileName"/> - <int Value="934" Name="FirstVisibleLine"/> - <int Value="950" Name="CurrentLine"/> + <int Value="1022" Name="FirstVisibleLine"/> + <int Value="1038" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> @@ -20,7 +20,7 @@ <TabInfo> <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\MainFrame.cpp" Name="FileName"/> <int Value="167" Name="FirstVisibleLine"/> - <int Value="188" Name="CurrentLine"/> + <int Value="0" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> @@ -54,8 +54,8 @@ </TabInfo> <TabInfo> <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Text.cpp" Name="FileName"/> - <int Value="54" Name="FirstVisibleLine"/> - <int Value="76" Name="CurrentLine"/> + <int Value="323" Name="FirstVisibleLine"/> + <int Value="344" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> @@ -67,30 +67,23 @@ <IntVector Name="CollapsedFolds"/> </TabInfo> <TabInfo> - <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\TextForm.cpp" Name="FileName"/> - <int Value="1193" Name="FirstVisibleLine"/> - <int Value="1211" Name="CurrentLine"/> - <wxArrayString Name="Bookmarks"/> - <IntVector Name="CollapsedFolds"/> - </TabInfo> - <TabInfo> - <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Bus.cpp" Name="FileName"/> + <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Transformer.cpp" Name="FileName"/> <int Value="0" Name="FirstVisibleLine"/> - <int Value="18" Name="CurrentLine"/> + <int Value="17" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> <TabInfo> - <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Bus.h" Name="FileName"/> - <int Value="13" Name="FirstVisibleLine"/> - <int Value="26" Name="CurrentLine"/> + <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Transformer.h" Name="FileName"/> + <int Value="18" Name="FirstVisibleLine"/> + <int Value="50" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> <TabInfo> - <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\wxGLString.h" Name="FileName"/> - <int Value="140" Name="FirstVisibleLine"/> - <int Value="156" Name="CurrentLine"/> + <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\TextForm.cpp" Name="FileName"/> + <int Value="0" Name="FirstVisibleLine"/> + <int Value="24" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> diff --git a/.codelite/PSP.tags b/.codelite/PSP.tags Binary files differindex ab2e805..0db3455 100644 --- a/.codelite/PSP.tags +++ b/.codelite/PSP.tags diff --git a/.codelite/compilation.db b/.codelite/compilation.db Binary files differindex b9d6d94..27843d0 100644 --- a/.codelite/compilation.db +++ b/.codelite/compilation.db diff --git a/.codelite/refactoring.db b/.codelite/refactoring.db Binary files differindex 9e1852f..958a799 100644 --- a/.codelite/refactoring.db +++ b/.codelite/refactoring.db diff --git a/Buglist.txt b/Buglist.txt new file mode 100644 index 0000000..ef6aa1d --- /dev/null +++ b/Buglist.txt @@ -0,0 +1,23 @@ +BUG LIST [pt-br] + +PRIORIDADE 1: + +PRIORIDADE 2: +-> Número do nome do transformador preenchido errado; +-> Potência reativa não está sendo distribuída apropriadamente em barras de tensão controlada caso tenha mais de uma máquina síncrona (com valores de reativos máximos/mínimos acionados); +-> Dados de elementos desconectados/offline não estão sendo zerados/reiniciados; +-> É necessário perguntar ao usuário se ele deseja trocar a tensão de todo o trecho conectado por linhas (quando é trocada a tensão de uma barra); +-> Setas de fluxo de carga de linhas e transformadores não são atualizadas quando uma barra conectada é removida. + +TODO LIST: +-> Implementar dados em relação à base de potência do elemento (e não somente do sistema). +-> Implementar fluxo de carga pelo método numérico de Newton-Raphson; +-> Textos vetorizados ou aumentar/diminuir a resolução das texturas de acordo com o zoom; +-> Separar sistemas não conectados e resolvê-los separadamente (criar lista de barras de oscilação prioritárias). + +OBJETIVOS: +-> Criar uma GUI amigável (wip); +-> Cálculo de fluxo de carga (OK); +-> Cálculo de faltas (curto simétrico e assimétrico / abertura de linhas); +-> Criar GUI para definir controles genéricos; +-> Cálculo eletromecânico.
\ No newline at end of file diff --git a/Project/Line.cpp b/Project/Line.cpp index b7b5ba7..ae5e0b3 100644 --- a/Project/Line.cpp +++ b/Project/Line.cpp @@ -1,7 +1,25 @@ #include "Line.h" -Line::Line() : Branch() {} -Line::Line(wxString name) : Branch() { m_electricaData.name = name; } +Line::Line() + : Branch() +{ + for(int i = 0; i < 2; i++) { + for(int j = 0; j < 3; j++) { + m_electricaData.faultCurrent[i][j] = std::complex<double>(0.0, 0.0); + } + } +} + +Line::Line(wxString name) + : Branch() +{ + for(int i = 0; i < 2; i++) { + for(int j = 0; j < 3; j++) { + m_electricaData.faultCurrent[i][j] = std::complex<double>(0.0, 0.0); + } + } + m_electricaData.name = name; +} Line::~Line() {} bool Line::Contains(wxPoint2DDouble position) const { @@ -43,7 +61,7 @@ void Line::Draw(wxPoint2DDouble translation, double scale) const glColor4d(0.2, 0.2, 0.2, 1.0); DrawLine(pointList); - if(m_inserted){ + if(m_inserted) { DrawSwitches(); DrawPowerFlowPts(); } @@ -98,10 +116,10 @@ bool Line::AddParent(Element* parent, wxPoint2DDouble position) m_position = position; m_parentList.push_back(parent); wxPoint2DDouble parentPt = - parent->RotateAtPosition(position, -parent->GetAngle()); // Rotate click to horizontal position. - parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus. - parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); // Rotate back. - m_pointList.push_back(parentPt); // First point + parent->RotateAtPosition(position, -parent->GetAngle()); // Rotate click to horizontal position. + parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus. + parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); // Rotate back. + m_pointList.push_back(parentPt); // First point m_pointList.push_back(GetSwitchPoint(parent, parentPt, m_position)); wxRect2DDouble genRect(0, 0, 0, 0); @@ -118,19 +136,19 @@ bool Line::AddParent(Element* parent, wxPoint2DDouble position) else if(parent != m_parentList[0]) { Bus* parentBus = (Bus*)parent; if(m_electricaData.nominalVoltage != parentBus->GetEletricalData().nominalVoltage || - m_electricaData.nominalVoltageUnit != parentBus->GetEletricalData().nominalVoltageUnit) { + m_electricaData.nominalVoltageUnit != parentBus->GetEletricalData().nominalVoltageUnit) { wxMessageDialog msgDialog(NULL, _("Unable to connect two buses with different nominal voltages.\n" "Use a transformer or edit the bus properties."), - _("Error"), wxOK | wxCENTRE | wxICON_ERROR); + _("Error"), wxOK | wxCENTRE | wxICON_ERROR); msgDialog.ShowModal(); return false; } m_parentList.push_back(parent); wxPoint2DDouble parentPt = - parent->RotateAtPosition(position, -parent->GetAngle()); // Rotate click to horizontal position. - parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus. - parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); // Rotate back. + parent->RotateAtPosition(position, -parent->GetAngle()); // Rotate click to horizontal position. + parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus. + parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); // Rotate back. // Set first switch point. wxPoint2DDouble secondPoint = parentPt; @@ -142,7 +160,7 @@ bool Line::AddParent(Element* parent, wxPoint2DDouble position) // Set the second switch point. m_pointList.push_back(GetSwitchPoint(parent, parentPt, m_pointList[m_pointList.size() - 1])); - m_pointList.push_back(parentPt); // Last point. + m_pointList.push_back(parentPt); // Last point. wxRect2DDouble genRect(0, 0, 0, 0); m_switchRect.push_back(genRect); @@ -237,7 +255,7 @@ void Line::MoveNode(Element* parent, wxPoint2DDouble position) double Line::PointToLineDistance(wxPoint2DDouble point, int* segmentNumber) const { //[Ref] http://geomalgorithms.com/a02-_lines.html - double distance = 100.0; // Big initial distance. + double distance = 100.0; // Big initial distance. wxPoint2DDouble p0 = point; for(int i = 1; i < (int)m_pointList.size() - 2; i++) { @@ -349,12 +367,12 @@ bool Line::SetNodeParent(Element* parent) wxRect2DDouble nodeRect(0, 0, 0, 0); if(m_activeNodeID == 1) { nodeRect = wxRect2DDouble(m_pointList[0].m_x - 5.0 - m_borderSize, m_pointList[0].m_y - 5.0 - m_borderSize, - 10 + 2.0 * m_borderSize, 10 + 2.0 * m_borderSize); + 10 + 2.0 * m_borderSize, 10 + 2.0 * m_borderSize); } if(m_activeNodeID == 2) { nodeRect = wxRect2DDouble(m_pointList[m_pointList.size() - 1].m_x - 5.0 - m_borderSize, - m_pointList[m_pointList.size() - 1].m_y - 5.0 - m_borderSize, - 10 + 2.0 * m_borderSize, 10 + 2.0 * m_borderSize); + m_pointList[m_pointList.size() - 1].m_y - 5.0 - m_borderSize, 10 + 2.0 * m_borderSize, + 10 + 2.0 * m_borderSize); } if(parent->Intersects(nodeRect)) { @@ -365,10 +383,10 @@ bool Line::SetNodeParent(Element* parent) m_electricaData.nominalVoltage = parentBus->GetEletricalData().nominalVoltage; m_electricaData.nominalVoltageUnit = parentBus->GetEletricalData().nominalVoltageUnit; } else if(m_electricaData.nominalVoltage != parentBus->GetEletricalData().nominalVoltage || - m_electricaData.nominalVoltageUnit != parentBus->GetEletricalData().nominalVoltageUnit) { + m_electricaData.nominalVoltageUnit != parentBus->GetEletricalData().nominalVoltageUnit) { wxMessageDialog msgDialog(NULL, _("Unable to connect two buses with different nominal voltages.\n" "Use a transformer or edit the bus properties."), - _("Error"), wxOK | wxCENTRE | wxICON_ERROR); + _("Error"), wxOK | wxCENTRE | wxICON_ERROR); msgDialog.ShowModal(); m_activeNodeID = 0; return false; @@ -385,8 +403,8 @@ bool Line::SetNodeParent(Element* parent) // Centralize the node on bus. wxPoint2DDouble parentPt = parent->RotateAtPosition( - m_pointList[0], -parent->GetAngle()); // Rotate click to horizontal position. - parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus. + m_pointList[0], -parent->GetAngle()); // Rotate click to horizontal position. + parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus. parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); m_pointList[0] = parentPt; @@ -455,13 +473,10 @@ void Line::RotateNode(Element* parent, bool clockwise) if(!clockwise) rotAngle = -m_rotationAngle; if(parent == m_parentList[0]) { - m_pointList[0] = parent->RotateAtPosition(m_pointList[0], rotAngle); - } - else if(parent == m_parentList[1]) - { - m_pointList[m_pointList.size() - 1] = - parent->RotateAtPosition(m_pointList[m_pointList.size() - 1], rotAngle); - } + m_pointList[0] = parent->RotateAtPosition(m_pointList[0], rotAngle); + } else if(parent == m_parentList[1]) { + m_pointList[m_pointList.size() - 1] = parent->RotateAtPosition(m_pointList[m_pointList.size() - 1], rotAngle); + } UpdateSwitchesPosition(); UpdatePowerFlowArrowsPosition(); } diff --git a/Project/Line.h b/Project/Line.h index 1a9aa2b..012f68d 100644 --- a/Project/Line.h +++ b/Project/Line.h @@ -28,6 +28,8 @@ struct LineElectricalData { double zeroResistance = 0.0; double zeroIndReactance = 1.0; double zeroCapSusceptance = 0.0; + // p.u. fault data + std::complex<double> faultCurrent[2][3]; }; class Line : public Branch diff --git a/Project/Project.mk b/Project/Project.mk index 8ab3b2c..78e334f 100644 --- a/Project/Project.mk +++ b/Project/Project.mk @@ -13,7 +13,7 @@ CurrentFileName := CurrentFilePath := CurrentFileFullPath := User :=Thales -Date :=07/12/2016 +Date :=08/12/2016 CodeLitePath :="C:/Program Files/CodeLite" LinkerName :=C:/TDM-GCC-64/bin/g++.exe SharedObjectLinkerName :=C:/TDM-GCC-64/bin/g++.exe -shared -fPIC diff --git a/Project/Release/Bus.cpp.o b/Project/Release/Bus.cpp.o Binary files differindex 444c5dc..54c9c29 100644 --- a/Project/Release/Bus.cpp.o +++ b/Project/Release/Bus.cpp.o diff --git a/Project/Release/ElectricCalculation.cpp.o b/Project/Release/ElectricCalculation.cpp.o Binary files differindex 7dc5f55..8fe31cc 100644 --- a/Project/Release/ElectricCalculation.cpp.o +++ b/Project/Release/ElectricCalculation.cpp.o diff --git a/Project/Release/GeneratorStabForm.cpp.o b/Project/Release/GeneratorStabForm.cpp.o Binary files differindex b8b4e6f..6e3ecd6 100644 --- a/Project/Release/GeneratorStabForm.cpp.o +++ b/Project/Release/GeneratorStabForm.cpp.o diff --git a/Project/Release/Line.cpp.o b/Project/Release/Line.cpp.o Binary files differindex 1bc1c62..0fd9f2a 100644 --- a/Project/Release/Line.cpp.o +++ b/Project/Release/Line.cpp.o diff --git a/Project/Release/LineForm.cpp.o b/Project/Release/LineForm.cpp.o Binary files differindex 023b292..4e36059 100644 --- a/Project/Release/LineForm.cpp.o +++ b/Project/Release/LineForm.cpp.o diff --git a/Project/Release/MainFrame.cpp.o b/Project/Release/MainFrame.cpp.o Binary files differindex 07fd41c..e852390 100644 --- a/Project/Release/MainFrame.cpp.o +++ b/Project/Release/MainFrame.cpp.o diff --git a/Project/Release/PSP-UFU.exe b/Project/Release/PSP-UFU.exe Binary files differindex d591cb9..bf151c3 100644 --- a/Project/Release/PSP-UFU.exe +++ b/Project/Release/PSP-UFU.exe diff --git a/Project/Release/PowerFlow.cpp.o b/Project/Release/PowerFlow.cpp.o Binary files differindex 1abafea..3f8ce8e 100644 --- a/Project/Release/PowerFlow.cpp.o +++ b/Project/Release/PowerFlow.cpp.o diff --git a/Project/Release/SyncGenerator.cpp.o b/Project/Release/SyncGenerator.cpp.o Binary files differindex 6d75910..df5cc88 100644 --- a/Project/Release/SyncGenerator.cpp.o +++ b/Project/Release/SyncGenerator.cpp.o diff --git a/Project/Release/SyncMachineForm.cpp.o b/Project/Release/SyncMachineForm.cpp.o Binary files differindex 26c6148..a2afa10 100644 --- a/Project/Release/SyncMachineForm.cpp.o +++ b/Project/Release/SyncMachineForm.cpp.o diff --git a/Project/Release/Text.cpp.o b/Project/Release/Text.cpp.o Binary files differindex 9911071..85c409a 100644 --- a/Project/Release/Text.cpp.o +++ b/Project/Release/Text.cpp.o diff --git a/Project/Release/TextForm.cpp.o b/Project/Release/TextForm.cpp.o Binary files differindex cc9a9ca..ec68417 100644 --- a/Project/Release/TextForm.cpp.o +++ b/Project/Release/TextForm.cpp.o diff --git a/Project/Release/Transformer.cpp.o b/Project/Release/Transformer.cpp.o Binary files differindex 1456ed6..3c97848 100644 --- a/Project/Release/Transformer.cpp.o +++ b/Project/Release/Transformer.cpp.o diff --git a/Project/Release/TransformerForm.cpp.o b/Project/Release/TransformerForm.cpp.o Binary files differindex 499042a..50fbf8c 100644 --- a/Project/Release/TransformerForm.cpp.o +++ b/Project/Release/TransformerForm.cpp.o diff --git a/Project/Release/Workspace.cpp.o b/Project/Release/Workspace.cpp.o Binary files differindex 1200399..9a16fe7 100644 --- a/Project/Release/Workspace.cpp.o +++ b/Project/Release/Workspace.cpp.o diff --git a/Project/SyncGenerator.cpp b/Project/SyncGenerator.cpp index b655364..463c56d 100644 --- a/Project/SyncGenerator.cpp +++ b/Project/SyncGenerator.cpp @@ -127,3 +127,11 @@ SyncGeneratorElectricalData SyncGenerator::GetPUElectricalData(double systemPowe return data; } + +void SyncGenerator::SetNominalVoltage(std::vector<double> nominalVoltage, std::vector<ElectricalUnit> nominalVoltageUnit) +{ + if(nominalVoltage.size() > 0) { + m_electricalData.nominalVoltage = nominalVoltage[0]; + m_electricalData.nominalVoltageUnit = nominalVoltageUnit[0]; + } +} diff --git a/Project/SyncGenerator.h b/Project/SyncGenerator.h index 98c0ce1..0ff3f6a 100644 --- a/Project/SyncGenerator.h +++ b/Project/SyncGenerator.h @@ -5,12 +5,13 @@ class SyncMachineForm; -struct SyncGeneratorElectricalData -{ +struct SyncGeneratorElectricalData { // General wxString name = ""; double nominalPower = 100.0; ElectricalUnit nominalPowerUnit = UNIT_MVA; + double nominalVoltage = 13.8; + ElectricalUnit nominalVoltageUnit = UNIT_kV; double activePower = 100.0; ElectricalUnit activePowerUnit = UNIT_MW; double reactivePower = 0.0; @@ -33,6 +34,9 @@ struct SyncGeneratorElectricalData double groundResistance = 0.0; double groundReactance = 0.0; bool groundNeutral = true; + // p.u. fault data + std::complex<double> faultCurrent[3] = { std::complex<double>(0.0, 0.0), std::complex<double>(0.0, 0.0), + std::complex<double>(0.0, 0.0) }; // Stability bool plotSyncMachine = false; @@ -59,22 +63,23 @@ struct SyncGeneratorElectricalData class SyncGenerator : public Machines { - public: +public: SyncGenerator(); - SyncGenerator(wxString name); + SyncGenerator(wxString name); ~SyncGenerator(); - - virtual void Init(); + + virtual void Init(); virtual void DrawSymbol() const; virtual bool GetContextMenu(wxMenu& menu); virtual bool ShowForm(wxWindow* parent, Element* element); virtual SyncGeneratorElectricalData GetElectricalData() { return m_electricalData; } - virtual SyncGeneratorElectricalData GetPUElectricalData(double systemPowerBase); + virtual SyncGeneratorElectricalData GetPUElectricalData(double systemPowerBase); virtual void SetElectricalData(SyncGeneratorElectricalData electricalData) { m_electricalData = electricalData; } - protected: + virtual void SetNominalVoltage(std::vector<double> nominalVoltage, std::vector<ElectricalUnit> nominalVoltageUnit); +protected: std::vector<wxPoint2DDouble> m_sinePts; SyncGeneratorElectricalData m_electricalData; }; -#endif // SYNCGENERATOR_H +#endif // SYNCGENERATOR_H diff --git a/Project/Text.cpp b/Project/Text.cpp index eb94de0..f9ddb71 100644 --- a/Project/Text.cpp +++ b/Project/Text.cpp @@ -174,6 +174,8 @@ void Text::UpdateText(double systemPowerBase) case UNIT_kV: { SetText(wxString::FromDouble(voltage * baseVoltage / 1e3, m_decimalPlaces) + " kV"); } break; + default: + break; } } break; case DATA_ANGLE: { @@ -183,8 +185,10 @@ void Text::UpdateText(double systemPowerBase) SetText(wxString::FromDouble(angle, m_decimalPlaces) + " rad"); } break; case UNIT_DEGREE: { - SetText(wxString::FromDouble(wxRadToDeg(angle), m_decimalPlaces) + "°"); + SetText(wxString::FromDouble(wxRadToDeg(angle), m_decimalPlaces) + (wxString)L'\u00B0'); } break; + default: + break; } } break; case DATA_SC_CURRENT: { @@ -198,19 +202,448 @@ void Text::UpdateText(double systemPowerBase) str += "\nIc = " + wxString::FromDouble(faultCurrent[2], m_decimalPlaces) + " p.u."; SetText(str); } break; + case UNIT_A: { + wxString str = "Ia = " + + wxString::FromDouble(faultCurrent[0] * baseCurrent, m_decimalPlaces) + " A"; + str += "\nIb = " + + wxString::FromDouble(faultCurrent[1] * baseCurrent, m_decimalPlaces) + " A"; + str += "\nIc = " + + wxString::FromDouble(faultCurrent[2] * baseCurrent, m_decimalPlaces) + " A"; + SetText(str); + } break; + case UNIT_kA: { + wxString str = "Ia = " + + wxString::FromDouble(faultCurrent[0] * baseCurrent / 1e3, m_decimalPlaces) + " kA"; + str += "\nIb = " + + wxString::FromDouble(faultCurrent[1] * baseCurrent / 1e3, m_decimalPlaces) + " kA"; + str += "\nIc = " + + wxString::FromDouble(faultCurrent[2] * baseCurrent / 1e3, m_decimalPlaces) + " kA"; + SetText(str); + } break; + default: + break; + } + } break; + case DATA_SC_VOLTAGE: { + double faultVoltage[3] = { std::abs(data.faultVoltage[0]), std::abs(data.faultVoltage[1]), + std::abs(data.faultVoltage[2]) }; + switch(m_unit) { + case UNIT_PU: { + wxString str = + "Va = " + wxString::FromDouble(faultVoltage[0], m_decimalPlaces) + " p.u."; + str += "\nVb = " + wxString::FromDouble(faultVoltage[1], m_decimalPlaces) + " p.u."; + str += "\nVc = " + wxString::FromDouble(faultVoltage[2], m_decimalPlaces) + " p.u."; + SetText(str); + } break; + case UNIT_V: { + wxString str = "Va = " + + wxString::FromDouble(faultVoltage[0] * baseVoltage, m_decimalPlaces) + " V"; + str += "\nVb = " + + wxString::FromDouble(faultVoltage[1] * baseVoltage, m_decimalPlaces) + " V"; + str += "\nVc = " + + wxString::FromDouble(faultVoltage[2] * baseVoltage, m_decimalPlaces) + " V"; + SetText(str); + } break; + case UNIT_kV: { + wxString str = "Va = " + + wxString::FromDouble(faultVoltage[0] * baseVoltage / 1e3, m_decimalPlaces) + " kV"; + str += "\nVb = " + + wxString::FromDouble(faultVoltage[1] * baseVoltage / 1e3, m_decimalPlaces) + " kV"; + str += "\nVc = " + + wxString::FromDouble(faultVoltage[2] * baseVoltage / 1e3, m_decimalPlaces) + " kV"; + SetText(str); + } break; + default: + break; + } + } break; + case DATA_SC_POWER: { + switch(m_unit) { + case UNIT_PU: { + SetText(wxString::FromDouble(data.scPower, m_decimalPlaces) + " p.u."); + } break; + case UNIT_VA: { + SetText(wxString::FromDouble(data.scPower * systemPowerBase, m_decimalPlaces) + " VA"); + } break; + case UNIT_kVA: { + SetText(wxString::FromDouble(data.scPower * systemPowerBase / 1e3, m_decimalPlaces) + + " kVA"); + } break; + case UNIT_MVA: { + SetText(wxString::FromDouble(data.scPower * systemPowerBase / 1e6, m_decimalPlaces) + + " MVA"); + } break; + default: + break; } - } + } break; + default: + break; } } } break; case TYPE_SYNC_GENERATOR: { - + SyncGenerator* syncGenerator = (SyncGenerator*)m_element; + if(syncGenerator) { + SyncGeneratorElectricalData data = syncGenerator->GetPUElectricalData(systemPowerBase); + double baseVoltage = data.nominalVoltage; + if(data.nominalVoltageUnit == UNIT_kV) baseVoltage *= 1e3; + double baseCurrent = systemPowerBase / (std::sqrt(3.0) * baseVoltage); + switch(m_dataType) { + case DATA_NAME: { + SetText(data.name); + } break; + case DATA_ACTIVE_POWER: { + switch(m_unit) { + case UNIT_PU: { + SetText(wxString::FromDouble(data.activePower, m_decimalPlaces) + " p.u."); + } break; + case UNIT_W: { + SetText( + wxString::FromDouble(data.activePower * systemPowerBase, m_decimalPlaces) + " W"); + } break; + case UNIT_kW: { + SetText( + wxString::FromDouble(data.activePower * systemPowerBase / 1e3, m_decimalPlaces) + + " kW"); + } break; + case UNIT_MW: { + SetText( + wxString::FromDouble(data.activePower * systemPowerBase / 1e6, m_decimalPlaces) + + " MW"); + } break; + default: + break; + } + } break; + case DATA_REACTIVE_POWER: { + switch(m_unit) { + case UNIT_PU: { + SetText(wxString::FromDouble(data.reactivePower, m_decimalPlaces) + " p.u."); + } break; + case UNIT_VAr: { + SetText(wxString::FromDouble(data.reactivePower * systemPowerBase, m_decimalPlaces) + + " VAr"); + } break; + case UNIT_kVAr: { + SetText( + wxString::FromDouble(data.reactivePower * systemPowerBase / 1e3, m_decimalPlaces) + + " kVAr"); + } break; + case UNIT_MVAr: { + SetText( + wxString::FromDouble(data.reactivePower * systemPowerBase / 1e6, m_decimalPlaces) + + " MVAr"); + } break; + default: + break; + } + } break; + case DATA_SC_CURRENT: { + double faultCurrent[3] = { std::abs(data.faultCurrent[0]), std::abs(data.faultCurrent[1]), + std::abs(data.faultCurrent[2]) }; + switch(m_unit) { + case UNIT_PU: { + wxString str = + "Ia = " + wxString::FromDouble(faultCurrent[0], m_decimalPlaces) + " p.u."; + str += "\nIb = " + wxString::FromDouble(faultCurrent[1], m_decimalPlaces) + " p.u."; + str += "\nIc = " + wxString::FromDouble(faultCurrent[2], m_decimalPlaces) + " p.u."; + SetText(str); + } break; + case UNIT_A: { + wxString str = "Ia = " + + wxString::FromDouble(faultCurrent[0] * baseCurrent, m_decimalPlaces) + " A"; + str += "\nIb = " + + wxString::FromDouble(faultCurrent[1] * baseCurrent, m_decimalPlaces) + " A"; + str += "\nIc = " + + wxString::FromDouble(faultCurrent[2] * baseCurrent, m_decimalPlaces) + " A"; + SetText(str); + } break; + case UNIT_kA: { + wxString str = "Ia = " + + wxString::FromDouble(faultCurrent[0] * baseCurrent / 1e3, m_decimalPlaces) + " kA"; + str += "\nIb = " + + wxString::FromDouble(faultCurrent[1] * baseCurrent / 1e3, m_decimalPlaces) + " kA"; + str += "\nIc = " + + wxString::FromDouble(faultCurrent[2] * baseCurrent / 1e3, m_decimalPlaces) + " kA"; + SetText(str); + } break; + default: + break; + } + } break; + default: + break; + } + } } break; case TYPE_LINE: { - + Line* line = (Line*)m_element; + if(line) { + LineElectricalData data = line->GetElectricalData(); + double baseVoltage = data.nominalVoltage; + if(data.nominalVoltageUnit == UNIT_kV) baseVoltage *= 1e3; + double baseCurrent = systemPowerBase / (std::sqrt(3.0) * baseVoltage); + switch(m_dataType) { + case DATA_NAME: { + SetText(data.name); + } break; + case DATA_PF_ACTIVE: { + double activePF = std::real(data.powerFlow[m_direction]); + switch(m_unit) { + case UNIT_PU: { + SetText(wxString::FromDouble(activePF, m_decimalPlaces) + " p.u."); + } break; + case UNIT_W: { + SetText(wxString::FromDouble(activePF * systemPowerBase, m_decimalPlaces) + " W"); + } break; + case UNIT_kW: { + SetText( + wxString::FromDouble(activePF * systemPowerBase / 1e3, m_decimalPlaces) + " kW"); + } break; + case UNIT_MW: { + SetText( + wxString::FromDouble(activePF * systemPowerBase / 1e6, m_decimalPlaces) + " MW"); + } break; + default: + break; + } + } break; + case DATA_PF_REACTIVE: { + double reactivePF = std::imag(data.powerFlow[m_direction]); + switch(m_unit) { + case UNIT_PU: { + SetText(wxString::FromDouble(reactivePF, m_decimalPlaces) + " p.u."); + } break; + case UNIT_VAr: { + SetText(wxString::FromDouble(reactivePF * systemPowerBase, m_decimalPlaces) + " VAr"); + } break; + case UNIT_kVAr: { + SetText(wxString::FromDouble(reactivePF * systemPowerBase / 1e3, m_decimalPlaces) + + " kVAr"); + } break; + case UNIT_MVAr: { + SetText(wxString::FromDouble(reactivePF * systemPowerBase / 1e6, m_decimalPlaces) + + " MVAr"); + } break; + default: + break; + } + } break; + case DATA_PF_LOSSES: { + double losses = std::abs(std::real(data.powerFlow[0]) + std::real(data.powerFlow[1])); + switch(m_unit) { + case UNIT_PU: { + SetText(wxString::FromDouble(losses, m_decimalPlaces) + " p.u."); + } break; + case UNIT_W: { + SetText(wxString::FromDouble(losses * systemPowerBase, m_decimalPlaces) + " W"); + } break; + case UNIT_kW: { + SetText(wxString::FromDouble(losses * systemPowerBase / 1e3, m_decimalPlaces) + " kW"); + } break; + case UNIT_MW: { + SetText(wxString::FromDouble(losses * systemPowerBase / 1e6, m_decimalPlaces) + " MW"); + } break; + default: + break; + } + } break; + case DATA_PF_CURRENT: { + double current = std::abs(data.current[m_direction]); + switch(m_unit) { + case UNIT_PU: { + SetText(wxString::FromDouble(current, m_decimalPlaces) + " p.u."); + } break; + case UNIT_A: { + SetText(wxString::FromDouble(current * baseCurrent, m_decimalPlaces) + " A"); + } break; + case UNIT_kA: { + SetText(wxString::FromDouble(current * baseCurrent / 1e3, m_decimalPlaces) + " kA"); + } break; + default: + break; + } + } break; + case DATA_SC_CURRENT: { + double faultCurrent[3] = { std::abs(data.faultCurrent[m_direction][0]), + std::abs(data.faultCurrent[m_direction][1]), std::abs(data.faultCurrent[m_direction][2]) }; + switch(m_unit) { + case UNIT_PU: { + wxString str = + "Ia = " + wxString::FromDouble(faultCurrent[0], m_decimalPlaces) + " p.u."; + str += "\nIb = " + wxString::FromDouble(faultCurrent[1], m_decimalPlaces) + " p.u."; + str += "\nIc = " + wxString::FromDouble(faultCurrent[2], m_decimalPlaces) + " p.u."; + SetText(str); + } break; + case UNIT_A: { + wxString str = "Ia = " + + wxString::FromDouble(faultCurrent[0] * baseCurrent, m_decimalPlaces) + " A"; + str += "\nIb = " + + wxString::FromDouble(faultCurrent[1] * baseCurrent, m_decimalPlaces) + " A"; + str += "\nIc = " + + wxString::FromDouble(faultCurrent[2] * baseCurrent, m_decimalPlaces) + " A"; + SetText(str); + } break; + case UNIT_kA: { + wxString str = "Ia = " + + wxString::FromDouble(faultCurrent[0] * baseCurrent / 1e3, m_decimalPlaces) + " kA"; + str += "\nIb = " + + wxString::FromDouble(faultCurrent[1] * baseCurrent / 1e3, m_decimalPlaces) + " kA"; + str += "\nIc = " + + wxString::FromDouble(faultCurrent[2] * baseCurrent / 1e3, m_decimalPlaces) + " kA"; + SetText(str); + } break; + default: + break; + } + } break; + default: + break; + } + } } break; case TYPE_TRANSFORMER: { + Transformer* transformer = (Transformer*)m_element; + if(transformer) { + TransformerElectricalData data = transformer->GetElectricalData(); + double baseVoltage[2] = { data.primaryNominalVoltage, data.secondaryNominalVoltage }; + + if(data.primaryNominalVoltageUnit == UNIT_kV) baseVoltage[0] *= 1e3; + if(data.secondaryNominalVoltageUnit == UNIT_kV) baseVoltage[1] *= 1e3; + double baseCurrent[2] = { systemPowerBase / (std::sqrt(3.0) * baseVoltage[0]), + systemPowerBase / (std::sqrt(3.0) * baseVoltage[1]) }; + switch(m_dataType) { + case DATA_NAME: { + SetText(data.name); + } break; + case DATA_PF_ACTIVE: { + double activePF = std::real(data.powerFlow[m_direction]); + switch(m_unit) { + case UNIT_PU: { + SetText(wxString::FromDouble(activePF, m_decimalPlaces) + " p.u."); + } break; + case UNIT_W: { + SetText(wxString::FromDouble(activePF * systemPowerBase, m_decimalPlaces) + " W"); + } break; + case UNIT_kW: { + SetText( + wxString::FromDouble(activePF * systemPowerBase / 1e3, m_decimalPlaces) + " kW"); + } break; + case UNIT_MW: { + SetText( + wxString::FromDouble(activePF * systemPowerBase / 1e6, m_decimalPlaces) + " MW"); + } break; + default: + break; + } + } break; + case DATA_PF_REACTIVE: { + double reactivePF = std::imag(data.powerFlow[m_direction]); + switch(m_unit) { + case UNIT_PU: { + SetText(wxString::FromDouble(reactivePF, m_decimalPlaces) + " p.u."); + } break; + case UNIT_VAr: { + SetText(wxString::FromDouble(reactivePF * systemPowerBase, m_decimalPlaces) + " VAr"); + } break; + case UNIT_kVAr: { + SetText(wxString::FromDouble(reactivePF * systemPowerBase / 1e3, m_decimalPlaces) + + " kVAr"); + } break; + case UNIT_MVAr: { + SetText(wxString::FromDouble(reactivePF * systemPowerBase / 1e6, m_decimalPlaces) + + " MVAr"); + } break; + default: + break; + } + } break; + case DATA_PF_LOSSES: { + double losses = std::abs(std::real(data.powerFlow[0]) + std::real(data.powerFlow[1])); + switch(m_unit) { + case UNIT_PU: { + SetText(wxString::FromDouble(losses, m_decimalPlaces) + " p.u."); + } break; + case UNIT_W: { + SetText(wxString::FromDouble(losses * systemPowerBase, m_decimalPlaces) + " W"); + } break; + case UNIT_kW: { + SetText(wxString::FromDouble(losses * systemPowerBase / 1e3, m_decimalPlaces) + " kW"); + } break; + case UNIT_MW: { + SetText(wxString::FromDouble(losses * systemPowerBase / 1e6, m_decimalPlaces) + " MW"); + } break; + default: + break; + } + } break; + case DATA_PF_CURRENT: { + double current = std::abs(data.current[m_direction]); + switch(m_unit) { + case UNIT_PU: { + SetText(wxString::FromDouble(current, m_decimalPlaces) + " p.u."); + } break; + case UNIT_A: { + SetText( + wxString::FromDouble(current * baseCurrent[m_direction], m_decimalPlaces) + " A"); + } break; + case UNIT_kA: { + SetText( + wxString::FromDouble(current * baseCurrent[m_direction] / 1e3, m_decimalPlaces) + + " kA"); + } break; + default: + break; + } + } break; + case DATA_SC_CURRENT: { + double faultCurrent[3] = { std::abs(data.faultCurrent[m_direction][0]), + std::abs(data.faultCurrent[m_direction][1]), std::abs(data.faultCurrent[m_direction][2]) }; + switch(m_unit) { + case UNIT_PU: { + wxString str = + "Ia = " + wxString::FromDouble(faultCurrent[0], m_decimalPlaces) + " p.u."; + str += "\nIb = " + wxString::FromDouble(faultCurrent[1], m_decimalPlaces) + " p.u."; + str += "\nIc = " + wxString::FromDouble(faultCurrent[2], m_decimalPlaces) + " p.u."; + SetText(str); + } break; + case UNIT_A: { + wxString str = "Ia = " + + wxString::FromDouble(faultCurrent[0] * baseCurrent[m_direction], m_decimalPlaces) + + " A"; + str += "\nIb = " + + wxString::FromDouble(faultCurrent[1] * baseCurrent[m_direction], m_decimalPlaces) + + " A"; + str += "\nIc = " + + wxString::FromDouble(faultCurrent[2] * baseCurrent[m_direction], m_decimalPlaces) + + " A"; + SetText(str); + } break; + case UNIT_kA: { + wxString str = "Ia = " + + wxString::FromDouble( + faultCurrent[0] * baseCurrent[m_direction] / 1e3, m_decimalPlaces) + + " kA"; + str += "\nIb = " + + wxString::FromDouble( + faultCurrent[1] * baseCurrent[m_direction] / 1e3, m_decimalPlaces) + + " kA"; + str += "\nIc = " + + wxString::FromDouble( + faultCurrent[2] * baseCurrent[m_direction] / 1e3, m_decimalPlaces) + + " kA"; + SetText(str); + } break; + default: + break; + } + } break; + default: + break; + } + } } break; case TYPE_LOAD: { diff --git a/Project/TextForm.cpp b/Project/TextForm.cpp index be75c81..c4f9ea1 100644 --- a/Project/TextForm.cpp +++ b/Project/TextForm.cpp @@ -747,6 +747,9 @@ bool TextForm::LoadChoices() break; } + if(m_choiceTextFromBus->IsEnabled()) m_choiceTextFromBus->SetSelection(m_text->GetDirection()); + if(m_choiceTextToBus->IsEnabled()) m_choiceTextToBus->SetSelection(m_text->GetDirection()); + m_textCtrlDecimal->SetValue(wxString::Format("%d", m_text->GetDecimalPlaces())); Preview(); @@ -1019,7 +1022,6 @@ void TextForm::DataTypeChoice() m_choiceTextToBus->Append(bus1Name); m_choiceTextFromBus->SetSelection(0); m_choiceTextToBus->SetSelection(0); - m_text->SetDirection(0); m_choiceTextFromBus->Enable(); m_choiceTextToBus->Enable(); @@ -1042,7 +1044,6 @@ void TextForm::DataTypeChoice() m_choiceTextToBus->Append(bus1Name); m_choiceTextFromBus->SetSelection(0); m_choiceTextToBus->SetSelection(0); - m_text->SetDirection(0); m_choiceTextFromBus->Enable(); m_choiceTextToBus->Enable(); @@ -1181,15 +1182,19 @@ bool TextForm::ValidateData() if(m_choiceElement->GetSelection() == -1) return false; if(m_choiceName->GetSelection() == -1) return false; if(m_choiceTextType->GetSelection() == -1) return false; - if(m_text->GetDataType() != DATA_NAME && m_choiceTextUnit->GetSelection() == -1) return false; + if(m_text->GetDataType() != DATA_NAME && m_choiceTextUnit->GetSelection() == -1) return false; if(m_text->GetElementType() == TYPE_LINE || m_text->GetElementType() == TYPE_TRANSFORMER) { - if(m_choiceTextFromBus->GetSelection() == -1) return false; - if(m_choiceTextToBus->GetSelection() == -1) return false; + if(m_text->GetDataType() != DATA_PF_LOSSES) { + if(m_choiceTextFromBus->GetSelection() == -1) return false; + if(m_choiceTextToBus->GetSelection() == -1) return false; + } } - + + if(m_choiceTextFromBus->IsEnabled() && m_choiceTextToBus->IsEnabled()) + m_text->SetDirection(m_choiceTextFromBus->GetSelection()); double decimalPlaces = m_text->GetDecimalPlaces(); if(m_textCtrlDecimal->GetValue().ToDouble(&decimalPlaces)) m_text->SetDecimalPlaces(decimalPlaces); - + m_textToEdit->SetElementType(m_text->GetElementType()); m_textToEdit->SetElementNumber(m_text->GetElementNumber()); m_textToEdit->SetElement(m_text->GetElement()); @@ -1198,17 +1203,17 @@ bool TextForm::ValidateData() m_textToEdit->SetUnit(m_text->GetUnit()); m_textToEdit->SetDecimalPlaces(decimalPlaces); m_textToEdit->UpdateText(m_systemPowerBase); - + return true; } void TextForm::OnOKButtonClick(wxCommandEvent& event) { - if(ValidateData()){ + if(ValidateData()) { EndModal(wxID_OK); } else { wxString errorMsg = _("There are blank fields."); - wxMessageDialog msgDialog(m_parent, errorMsg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR); + wxMessageDialog msgDialog(this, errorMsg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR); msgDialog.ShowModal(); } } diff --git a/Project/Transformer.cpp b/Project/Transformer.cpp index 93013e0..04770e4 100644 --- a/Project/Transformer.cpp +++ b/Project/Transformer.cpp @@ -1,8 +1,25 @@ #include "TransformerForm.h" #include "Transformer.h" -Transformer::Transformer() : Branch() {} -Transformer::Transformer(wxString name) : Branch() { m_electricalData.name = name; } +Transformer::Transformer() + : Branch() +{ + for(int i = 0; i < 2; i++) { + for(int j = 0; j < 3; j++) { + m_electricalData.faultCurrent[i][j] = std::complex<double>(0.0, 0.0); + } + } +} +Transformer::Transformer(wxString name) + : Branch() +{ + for(int i = 0; i < 2; i++) { + for(int j = 0; j < 3; j++) { + m_electricalData.faultCurrent[i][j] = std::complex<double>(0.0, 0.0); + } + } + m_electricalData.name = name; +} Transformer::~Transformer() {} bool Transformer::AddParent(Element* parent, wxPoint2DDouble position) { @@ -12,10 +29,10 @@ bool Transformer::AddParent(Element* parent, wxPoint2DDouble position) m_position = position; m_parentList.push_back(parent); wxPoint2DDouble parentPt = - parent->RotateAtPosition(position, -parent->GetAngle()); // Rotate click to horizontal position. - parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus. - parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); // Rotate back. - m_pointList.push_back(parentPt); // First point + parent->RotateAtPosition(position, -parent->GetAngle()); // Rotate click to horizontal position. + parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus. + parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); // Rotate back. + m_pointList.push_back(parentPt); // First point m_pointList.push_back(GetSwitchPoint(parent, parentPt, m_position)); wxRect2DDouble genRect(0, 0, 0, 0); @@ -27,9 +44,9 @@ bool Transformer::AddParent(Element* parent, wxPoint2DDouble position) else if(parent != m_parentList[0]) { m_parentList.push_back(parent); wxPoint2DDouble parentPt = - parent->RotateAtPosition(position, -parent->GetAngle()); // Rotate click to horizontal position. - parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus. - parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); // Rotate back. + parent->RotateAtPosition(position, -parent->GetAngle()); // Rotate click to horizontal position. + parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus. + parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); // Rotate back. // Get the average between the two bus points. m_position = @@ -53,7 +70,7 @@ bool Transformer::AddParent(Element* parent, wxPoint2DDouble position) // Set the second switch point. m_pointList.push_back(GetSwitchPoint(parent, parentPt, m_pointList[m_pointList.size() - 1])); - m_pointList.push_back(parentPt); // Last point. + m_pointList.push_back(parentPt); // Last point. m_inserted = true; wxRect2DDouble genRect(0, 0, 0, 0); @@ -88,10 +105,10 @@ void Transformer::Draw(wxPoint2DDouble translation, double scale) const glRotated(m_angle, 0.0, 0.0, 1.0); glTranslated(-m_position.m_x, -m_position.m_y, 0.0); - DrawCircle(m_rect.GetPosition() + wxPoint2DDouble(20.0, 20.0), 20 + (m_borderSize + 1.5) / scale, 20, - GL_POLYGON); - DrawCircle(m_rect.GetPosition() + wxPoint2DDouble(50.0, 20.0), 20 + (m_borderSize + 1.5) / scale, 20, - GL_POLYGON); + DrawCircle( + m_rect.GetPosition() + wxPoint2DDouble(20.0, 20.0), 20 + (m_borderSize + 1.5) / scale, 20, GL_POLYGON); + DrawCircle( + m_rect.GetPosition() + wxPoint2DDouble(50.0, 20.0), 20 + (m_borderSize + 1.5) / scale, 20, GL_POLYGON); glPopMatrix(); @@ -280,13 +297,10 @@ void Transformer::RotateNode(Element* parent, bool clockwise) if(!clockwise) rotAngle = -m_rotationAngle; if(parent == m_parentList[0]) { - m_pointList[0] = parent->RotateAtPosition(m_pointList[0], rotAngle); - } - else if(parent == m_parentList[1]) - { - m_pointList[m_pointList.size() - 1] = - parent->RotateAtPosition(m_pointList[m_pointList.size() - 1], rotAngle); - } + m_pointList[0] = parent->RotateAtPosition(m_pointList[0], rotAngle); + } else if(parent == m_parentList[1]) { + m_pointList[m_pointList.size() - 1] = parent->RotateAtPosition(m_pointList[m_pointList.size() - 1], rotAngle); + } UpdateSwitchesPosition(); UpdatePowerFlowArrowsPosition(); } @@ -297,64 +311,61 @@ bool Transformer::SetNodeParent(Element* parent) if(m_activeNodeID == 2 && parent == m_parentList[1]) return false; if(parent && m_activeNodeID != 0) { - wxRect2DDouble nodeRect(0, 0, 0, 0); - if(m_activeNodeID == 1) { - nodeRect = - wxRect2DDouble(m_pointList[0].m_x - 5.0 - m_borderSize, m_pointList[0].m_y - 5.0 - m_borderSize, - 10 + 2.0 * m_borderSize, 10 + 2.0 * m_borderSize); - } - if(m_activeNodeID == 2) { - nodeRect = wxRect2DDouble(m_pointList[m_pointList.size() - 1].m_x - 5.0 - m_borderSize, - m_pointList[m_pointList.size() - 1].m_y - 5.0 - m_borderSize, - 10 + 2.0 * m_borderSize, 10 + 2.0 * m_borderSize); - } - - if(parent->Intersects(nodeRect)) { - if(m_activeNodeID == 1) { - // Check if the user is trying to connect the same bus. - if(m_parentList[1] == parent) { - m_activeNodeID = 0; - return false; - } - - m_parentList[0] = parent; - - // Centralize the node on bus. - wxPoint2DDouble parentPt = parent->RotateAtPosition( - m_pointList[0], -parent->GetAngle()); // Rotate click to horizontal position. - parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus. - parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); - m_pointList[0] = parentPt; - - UpdateSwitchesPosition(); + wxRect2DDouble nodeRect(0, 0, 0, 0); + if(m_activeNodeID == 1) { + nodeRect = wxRect2DDouble(m_pointList[0].m_x - 5.0 - m_borderSize, m_pointList[0].m_y - 5.0 - m_borderSize, + 10 + 2.0 * m_borderSize, 10 + 2.0 * m_borderSize); + } + if(m_activeNodeID == 2) { + nodeRect = wxRect2DDouble(m_pointList[m_pointList.size() - 1].m_x - 5.0 - m_borderSize, + m_pointList[m_pointList.size() - 1].m_y - 5.0 - m_borderSize, 10 + 2.0 * m_borderSize, + 10 + 2.0 * m_borderSize); + } + + if(parent->Intersects(nodeRect)) { + if(m_activeNodeID == 1) { + // Check if the user is trying to connect the same bus. + if(m_parentList[1] == parent) { + m_activeNodeID = 0; + return false; + } + + m_parentList[0] = parent; + + // Centralize the node on bus. + wxPoint2DDouble parentPt = parent->RotateAtPosition( + m_pointList[0], -parent->GetAngle()); // Rotate click to horizontal position. + parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus. + parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); + m_pointList[0] = parentPt; + + UpdateSwitchesPosition(); UpdatePowerFlowArrowsPosition(); - return true; - } - if(m_activeNodeID == 2) { - if(m_parentList[0] == parent) { - m_activeNodeID = 0; - return false; - } - - m_parentList[1] = parent; - - wxPoint2DDouble parentPt = - parent->RotateAtPosition(m_pointList[m_pointList.size() - 1], -parent->GetAngle()); - parentPt.m_y = parent->GetPosition().m_y; - parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); - m_pointList[m_pointList.size() - 1] = parentPt; - - UpdateSwitchesPosition(); + return true; + } + if(m_activeNodeID == 2) { + if(m_parentList[0] == parent) { + m_activeNodeID = 0; + return false; + } + + m_parentList[1] = parent; + + wxPoint2DDouble parentPt = + parent->RotateAtPosition(m_pointList[m_pointList.size() - 1], -parent->GetAngle()); + parentPt.m_y = parent->GetPosition().m_y; + parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); + m_pointList[m_pointList.size() - 1] = parentPt; + + UpdateSwitchesPosition(); UpdatePowerFlowArrowsPosition(); - return true; - } - } - else - { - if(m_activeNodeID == 1) m_parentList[0] = NULL; - if(m_activeNodeID == 2) m_parentList[1] = NULL; - } - } + return true; + } + } else { + if(m_activeNodeID == 1) m_parentList[0] = NULL; + if(m_activeNodeID == 2) m_parentList[1] = NULL; + } + } return false; } diff --git a/Project/Transformer.h b/Project/Transformer.h index 8c958a1..79e2380 100644 --- a/Project/Transformer.h +++ b/Project/Transformer.h @@ -47,6 +47,8 @@ struct TransformerElectricalData { double primaryGrndReactance = 0.0; double secondaryGrndResistance = 0.0; double secondaryGrndReactance = 0.0; + // p.u. fault data + std::complex<double> faultCurrent[2][3]; }; class Transformer : public Branch diff --git a/Project/TransformerForm.cpp b/Project/TransformerForm.cpp index 3d87a13..b7ca491 100644 --- a/Project/TransformerForm.cpp +++ b/Project/TransformerForm.cpp @@ -117,7 +117,7 @@ void TransformerForm::OnStabilityButtonClick(wxCommandEvent& event) bool TransformerForm::ValidateData() { - TransformerElectricalData data; + TransformerElectricalData data = m_transformer->GetElectricalData(); data.name = m_textCtrlName->GetValue(); data.baseVoltage = m_choiceBaseVoltage->GetSelection(); |