From d7550fe1c173f1be296f1ce7991ad6d70ed90ceb Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Tue, 8 Aug 2017 19:40:23 -0300 Subject: Settings form implementation start --- Project/SimulationsSettingsForm.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Project/SimulationsSettingsForm.cpp (limited to 'Project/SimulationsSettingsForm.cpp') diff --git a/Project/SimulationsSettingsForm.cpp b/Project/SimulationsSettingsForm.cpp new file mode 100644 index 0000000..6dfb17f --- /dev/null +++ b/Project/SimulationsSettingsForm.cpp @@ -0,0 +1,20 @@ +#include "SimulationsSettingsForm.h" + +SimulationsSettingsForm::SimulationsSettingsForm(wxWindow* parent) + : SimulationsSettingsFormBase(parent) +{ +} + +SimulationsSettingsForm::~SimulationsSettingsForm() +{ +} + +void SimulationsSettingsForm::OnButtonOKClick(wxCommandEvent& event) +{ + if(ValidateData()) EndModal(wxID_OK); +} + +bool SimulationsSettingsForm::ValidateData() +{ + return true; +} -- cgit From 8a1ffbc01135a1466ad7400518e4c56a4bdc3af5 Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Wed, 9 Aug 2017 21:01:41 -0300 Subject: Stability properties implemented --- Project/SimulationsSettingsForm.cpp | 111 ++++++++++++++++++++++++++++++++++-- 1 file changed, 107 insertions(+), 4 deletions(-) (limited to 'Project/SimulationsSettingsForm.cpp') diff --git a/Project/SimulationsSettingsForm.cpp b/Project/SimulationsSettingsForm.cpp index 6dfb17f..9e38010 100644 --- a/Project/SimulationsSettingsForm.cpp +++ b/Project/SimulationsSettingsForm.cpp @@ -1,14 +1,54 @@ #include "SimulationsSettingsForm.h" +#include "PropertiesData.h" -SimulationsSettingsForm::SimulationsSettingsForm(wxWindow* parent) +SimulationsSettingsForm::SimulationsSettingsForm(wxWindow* parent, PropertiesData* properties) : SimulationsSettingsFormBase(parent) { -} + m_properties = properties; + auto data = m_properties->GetSimulationPropertiesData(); -SimulationsSettingsForm::~SimulationsSettingsForm() -{ + m_textCtrlbasePower->SetValue(Element::StringFromDouble(data.basePower)); + switch(data.basePowerUnit) { + case UNIT_VA: { + m_choiceBasePower->SetSelection(0); + } break; + case UNIT_kVA: { + m_choiceBasePower->SetSelection(1); + } break; + case UNIT_MVA: { + m_choiceBasePower->SetSelection(2); + } break; + default: { + m_choiceBasePower->SetSelection(wxNOT_FOUND); + } break; + } + m_checkBoxFaultAfterPF->SetValue(data.faultAfterPowerFlow); + m_checkBoxSCPowerAfterPF->SetValue(data.scPowerAfterPowerFlow); + switch(data.powerFlowMethod) { + case GAUSS_SEIDEL: { + m_choicePFMethod->SetSelection(0); + } break; + case NEWTON_RAPHSON: { + m_choicePFMethod->SetSelection(1); + m_textCtrlAccFactor->Enable(false); + } break; + default: { + m_choicePFMethod->SetSelection(wxNOT_FOUND); + } break; + } + m_textCtrlAccFactor->SetValue(Element::StringFromDouble(data.accFator)); + m_textCtrlPFTolerance->SetValue(wxString::Format("%g", data.powerFlowTolerance)); + m_textCtrlPFMaxIterations->SetValue(wxString::Format("%d", data.powerFlowMaxIterations)); + m_textCtrlTimeStep->SetValue(wxString::Format("%g", data.timeStep)); + m_textCtrlSimTime->SetValue(Element::StringFromDouble(data.stabilitySimulationTime)); + m_textCtrlFreq->SetValue(Element::StringFromDouble(data.stabilityFrequency)); + m_textCtrlStabTolerance->SetValue(wxString::Format("%g", data.stabilityTolerance)); + m_textCtrlStabMaxIterations->SetValue(wxString::Format("%d", data.stabilityMaxIterations)); + m_textCtrlCtrlStepRatio->SetValue(wxString::Format("%d", data.controlTimeStepRatio)); + m_textCtrlPrintTime->SetValue(wxString::Format("%g", data.plotTime)); } +SimulationsSettingsForm::~SimulationsSettingsForm() {} void SimulationsSettingsForm::OnButtonOKClick(wxCommandEvent& event) { if(ValidateData()) EndModal(wxID_OK); @@ -16,5 +56,68 @@ void SimulationsSettingsForm::OnButtonOKClick(wxCommandEvent& event) bool SimulationsSettingsForm::ValidateData() { + auto data = m_properties->GetSimulationPropertiesData(); + if(!Element::DoubleFromString(this, m_textCtrlbasePower->GetValue(), data.basePower, + _("Value entered incorrectly in the field \"Base power\"."))) + return false; + switch(m_choiceBasePower->GetSelection()) { + case 0: { + data.basePowerUnit = UNIT_VA; + } break; + case 1: { + data.basePowerUnit = UNIT_kVA; + } break; + default: { + data.basePowerUnit = UNIT_MVA; + } break; + } + data.faultAfterPowerFlow = m_checkBoxFaultAfterPF->GetValue(); + data.scPowerAfterPowerFlow = m_checkBoxSCPowerAfterPF->GetValue(); + switch(m_choicePFMethod->GetSelection()) { + case 0: { + data.powerFlowMethod = GAUSS_SEIDEL; + } break; + case 1: { + data.powerFlowMethod = NEWTON_RAPHSON; + } break; + } + if(!Element::DoubleFromString(this, m_textCtrlAccFactor->GetValue(), data.accFator, + _("Value entered incorrectly in the field \"Acceleration factor\"."))) + return false; + if(!Element::DoubleFromString(this, m_textCtrlPFTolerance->GetValue(), data.powerFlowTolerance, + _("Value entered incorrectly in the field \"Tolerance (Power flow)\"."))) + return false; + if(!Element::IntFromString(this, m_textCtrlPFMaxIterations->GetValue(), data.powerFlowMaxIterations, + _("Value entered incorrectly in the field \"Max. iterations (Power flow)\"."))) + return false; + if(!Element::DoubleFromString(this, m_textCtrlTimeStep->GetValue(), data.timeStep, + _("Value entered incorrectly in the field \"Time step\"."))) + return false; + if(!Element::DoubleFromString(this, m_textCtrlSimTime->GetValue(), data.stabilitySimulationTime, + _("Value entered incorrectly in the field \"Simulation time\"."))) + return false; + if(!Element::DoubleFromString(this, m_textCtrlFreq->GetValue(), data.stabilityFrequency, + _("Value entered incorrectly in the field \"System frequency\"."))) + return false; + if(!Element::DoubleFromString(this, m_textCtrlStabTolerance->GetValue(), data.stabilityTolerance, + _("Value entered incorrectly in the field \"Tolerance (Stability)\"."))) + return false; + if(!Element::IntFromString(this, m_textCtrlStabMaxIterations->GetValue(), data.stabilityMaxIterations, + _("Value entered incorrectly in the field \"Max. iterations (Stability)\"."))) + return false; + if(!Element::IntFromString(this, m_textCtrlCtrlStepRatio->GetValue(), data.controlTimeStepRatio, + _("Value entered incorrectly in the field \"Controls step ratio\"."))) + return false; + if(!Element::DoubleFromString(this, m_textCtrlPrintTime->GetValue(), data.plotTime, + _("Value entered incorrectly in the field \"Plot time\"."))) + return false; + m_properties->SetSimulationPropertiesData(data); return true; } +void SimulationsSettingsForm::OnPFMethodChoiceSelected(wxCommandEvent& event) +{ + if(m_choicePFMethod->GetSelection() == 0) + m_textCtrlAccFactor->Enable(); + else + m_textCtrlAccFactor->Enable(false); +} -- cgit From 516cdb72d3ff99a1ee786d3ea24c9b579272fe76 Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Wed, 30 Aug 2017 20:42:27 -0300 Subject: COI (center of inertia) implemented See Milano's book p. 342 --- Project/SimulationsSettingsForm.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Project/SimulationsSettingsForm.cpp') diff --git a/Project/SimulationsSettingsForm.cpp b/Project/SimulationsSettingsForm.cpp index 9e38010..714e49b 100644 --- a/Project/SimulationsSettingsForm.cpp +++ b/Project/SimulationsSettingsForm.cpp @@ -46,6 +46,8 @@ SimulationsSettingsForm::SimulationsSettingsForm(wxWindow* parent, PropertiesDat m_textCtrlStabMaxIterations->SetValue(wxString::Format("%d", data.stabilityMaxIterations)); m_textCtrlCtrlStepRatio->SetValue(wxString::Format("%d", data.controlTimeStepRatio)); m_textCtrlPrintTime->SetValue(wxString::Format("%g", data.plotTime)); + + m_checkBoxUseCOI->SetValue(data.useCOI); } SimulationsSettingsForm::~SimulationsSettingsForm() {} @@ -111,6 +113,8 @@ bool SimulationsSettingsForm::ValidateData() if(!Element::DoubleFromString(this, m_textCtrlPrintTime->GetValue(), data.plotTime, _("Value entered incorrectly in the field \"Plot time\"."))) return false; + data.useCOI = m_checkBoxUseCOI->GetValue(); + m_properties->SetSimulationPropertiesData(data); return true; } -- cgit