summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThales Lima Oliveira <thaleslima.ufu@gmail.com>2017-08-30 20:42:27 -0300
committerThales Lima Oliveira <thaleslima.ufu@gmail.com>2017-08-30 20:42:27 -0300
commit516cdb72d3ff99a1ee786d3ea24c9b579272fe76 (patch)
tree6017213d5e270f94c1063d11e793c196e3c969f8
parent1fcb990bd02da945ac0204caaed6a9aa1f6a7d5f (diff)
downloadPSP.git-516cdb72d3ff99a1ee786d3ea24c9b579272fe76.tar.gz
PSP.git-516cdb72d3ff99a1ee786d3ea24c9b579272fe76.tar.xz
PSP.git-516cdb72d3ff99a1ee786d3ea24c9b579272fe76.zip
COI (center of inertia) implemented
See Milano's book p. 342
-rw-r--r--Project/Bus.cpp8
-rw-r--r--Project/BusForm.cpp32
-rw-r--r--Project/Capacitor.cpp30
-rw-r--r--Project/Electromechanical.cpp43
-rw-r--r--Project/Electromechanical.h3
-rw-r--r--Project/FileHanding.cpp21
-rw-r--r--Project/Inductor.cpp30
-rw-r--r--Project/Line.cpp58
-rw-r--r--Project/Load.cpp38
-rw-r--r--Project/Machines.cpp36
-rw-r--r--Project/PowerElement.cpp42
-rw-r--r--Project/PowerElement.h14
-rw-r--r--Project/Project.mk2
-rw-r--r--Project/PropertiesData.h1
-rw-r--r--Project/PropertiesForm.cpp5
-rw-r--r--Project/PropertiesForm.h2
-rw-r--r--Project/PropertiesForm.wxcp77
-rw-r--r--Project/SimulationsSettingsForm.cpp4
-rw-r--r--Project/SwitchingForm.cpp5
-rw-r--r--Project/Transformer.cpp62
20 files changed, 335 insertions, 178 deletions
diff --git a/Project/Bus.cpp b/Project/Bus.cpp
index 3ccb55d..c366d76 100644
--- a/Project/Bus.cpp
+++ b/Project/Bus.cpp
@@ -35,7 +35,7 @@ void Bus::Draw(wxPoint2DDouble translation, double scale) const
glRotated(m_angle, 0.0, 0.0, 1.0);
glTranslated(-screenPt.m_x, -screenPt.m_y, 0.0);
- glColor4d(0.0, 0.5, 1.0, 0.5);
+ glColor4dv(m_selectionColour.GetRGBA());
wxPoint2DDouble pts[4] = {WorldToScreen(translation, scale, -(m_width / 2.0), -(m_height / 2.0)) -
wxPoint2DDouble(m_borderSize, m_borderSize),
@@ -56,7 +56,11 @@ void Bus::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);
- glColor4dv(m_busColour.GetRGBA());
+ if(m_dynEvent)
+ glColor4dv(m_dynamicEventColour.GetRGBA());
+ else
+ glColor4dv(m_busColour.GetRGBA());
+
DrawRectangle(m_position, m_width, m_height);
// Pop the old matrix back.
glPopMatrix();
diff --git a/Project/BusForm.cpp b/Project/BusForm.cpp
index 98ec0da..113dd24 100644
--- a/Project/BusForm.cpp
+++ b/Project/BusForm.cpp
@@ -1,8 +1,7 @@
#include "BusForm.h"
#include "Bus.h"
-BusForm::BusForm(wxWindow* parent, Bus* bus)
- : BusFormBase(parent)
+BusForm::BusForm(wxWindow* parent, Bus* bus) : BusFormBase(parent)
{
SetSize(GetBestSize());
@@ -74,13 +73,13 @@ void BusForm::OnButtonOKClick(wxCommandEvent& event)
BusElectricalData data = m_bus->GetElectricalData();
data.name = m_textCtrlName->GetValue();
if(!m_bus->DoubleFromString(m_parent, m_textCtrlNomVoltage->GetValue(), data.nominalVoltage,
- _("Value entered incorrectly in the field \"Rated voltage\".")))
+ _("Value entered incorrectly in the field \"Rated voltage\".")))
return;
data.nominalVoltageUnit = m_choiceNomVoltage->GetSelection() == 0 ? UNIT_V : UNIT_kV;
data.isVoltageControlled = m_checkBoxCtrlVoltage->GetValue();
if(data.isVoltageControlled) {
if(!m_bus->DoubleFromString(m_parent, m_textCtrlCtrlVoltage->GetValue(), data.controlledVoltage,
- _("Value entered incorrectly in the field \"Controlled voltage\".")))
+ _("Value entered incorrectly in the field \"Controlled voltage\".")))
return;
data.controlledVoltageUnitChoice = m_choiceCtrlVoltage->GetSelection();
}
@@ -115,34 +114,39 @@ void BusForm::OnButtonOKClick(wxCommandEvent& event)
}
if(!m_bus->DoubleFromString(m_parent, m_textCtrlFaultResistance->GetValue(), data.faultResistance,
- _("Value entered incorrectly in the field \"Fault resistance\".")))
+ _("Value entered incorrectly in the field \"Fault resistance\".")))
return;
if(!m_bus->DoubleFromString(m_parent, m_textCtrlFaultReactance->GetValue(), data.faultReactance,
- _("Value entered incorrectly in the field \"Fault reactance\".")))
+ _("Value entered incorrectly in the field \"Fault reactance\".")))
return;
data.plotBus = m_checkBoxPlotData->GetValue();
data.stabHasFault = m_checkBoxStabFault->GetValue();
if(!m_bus->DoubleFromString(m_parent, m_textCtrlStabFaultTime->GetValue(), data.stabFaultTime,
- _("Value entered incorrectly in the field \"Time\".")))
+ _("Value entered incorrectly in the field \"Time\".")))
return;
if(!m_bus->DoubleFromString(m_parent, m_textCtrlStabFaultLength->GetValue(), data.stabFaultLength,
- _("Value entered incorrectly in the field \"Fault lenght\".")))
+ _("Value entered incorrectly in the field \"Fault lenght\".")))
return;
if(!m_bus->DoubleFromString(m_parent, m_textCtrlStabFaultResistance->GetValue(), data.stabFaultResistance,
- _("Value entered incorrectly in the field \"Fault resistence (stability)\".")))
+ _("Value entered incorrectly in the field \"Fault resistence (stability)\".")))
return;
if(!m_bus->DoubleFromString(m_parent, m_textCtrlStabFaultReactance->GetValue(), data.stabFaultReactance,
- _("Value entered incorrectly in the field \"Fault reactance (stability)\".")))
+ _("Value entered incorrectly in the field \"Fault reactance (stability)\".")))
return;
m_bus->SetElectricalData(data);
+ if(data.stabHasFault)
+ m_bus->SetDynamicEvent(true);
+ else
+ m_bus->SetDynamicEvent(false);
+
EndModal(wxID_OK);
}
@@ -189,19 +193,19 @@ void BusForm::EnableStabFaultFields(bool enable)
void BusForm::UpdateChoiceBoxes()
{
switch(m_choiceFaultType->GetSelection()) {
- case 0: // three-phase
+ case 0: // three-phase
{
m_choiceFaultPlace->Enable(false);
} break;
- case 1: // line-to-line
- case 2: // double line-to-line
+ case 1: // line-to-line
+ case 2: // double line-to-line
{
if(m_checkBoxFault->GetValue()) m_choiceFaultPlace->Enable(true);
m_choiceFaultPlace->SetString(0, _("Lines AB"));
m_choiceFaultPlace->SetString(1, _("Lines BC"));
m_choiceFaultPlace->SetString(2, _("Lines CA"));
} break;
- case 3: // line-to-ground
+ case 3: // line-to-ground
{
if(m_checkBoxFault->GetValue()) m_choiceFaultPlace->Enable(true);
m_choiceFaultPlace->SetString(0, _("Line A"));
diff --git a/Project/Capacitor.cpp b/Project/Capacitor.cpp
index 6830ffc..75b74f4 100644
--- a/Project/Capacitor.cpp
+++ b/Project/Capacitor.cpp
@@ -1,15 +1,8 @@
#include "ReactiveShuntElementForm.h"
#include "Capacitor.h"
-Capacitor::Capacitor()
- : Shunt()
-{
-}
-Capacitor::Capacitor(wxString name)
- : Shunt()
-{
- m_electricalData.name = name;
-}
+Capacitor::Capacitor() : Shunt() {}
+Capacitor::Capacitor(wxString name) : Shunt() { m_electricalData.name = name; }
Capacitor::~Capacitor() {}
bool Capacitor::AddParent(Element* parent, wxPoint2DDouble position)
{
@@ -17,11 +10,11 @@ bool Capacitor::AddParent(Element* parent, wxPoint2DDouble position)
m_parentList.push_back(parent);
parent->AddChild(this);
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.
- m_position = parentPt + wxPoint2DDouble(0.0, 100.0); // Shifts the position to the down of the bus.
+ m_position = parentPt + wxPoint2DDouble(0.0, 100.0); // Shifts the position to the down of the bus.
m_width = 40;
m_height = 30;
m_rect = wxRect2DDouble(m_position.m_x - m_width / 2.0, m_position.m_y - m_height / 2.0, m_width, m_height);
@@ -34,7 +27,7 @@ bool Capacitor::AddParent(Element* parent, wxPoint2DDouble position)
m_inserted = true;
wxRect2DDouble genRect(0, 0, 0, 0);
- m_switchRect.push_back(genRect); // Push a general rectangle.
+ m_switchRect.push_back(genRect); // Push a general rectangle.
UpdateSwitches();
return true;
@@ -45,9 +38,12 @@ bool Capacitor::AddParent(Element* parent, wxPoint2DDouble position)
void Capacitor::Draw(wxPoint2DDouble translation, double scale) const
{
OpenGLColour elementColour;
- if(m_online)
- elementColour = m_onlineElementColour;
- else
+ if(m_online) {
+ if(m_dynEvent)
+ elementColour = m_dynamicEventColour;
+ else
+ elementColour = m_onlineElementColour;
+ } else
elementColour = m_offlineElementColour;
if(m_inserted) {
diff --git a/Project/Electromechanical.cpp b/Project/Electromechanical.cpp
index 446ade2..f72171e 100644
--- a/Project/Electromechanical.cpp
+++ b/Project/Electromechanical.cpp
@@ -17,6 +17,7 @@ Electromechanical::Electromechanical(wxWindow* parent, std::vector<Element*> ele
m_ctrlTimeStepMultiplier = 1.0 / static_cast<double>(data.controlTimeStepRatio);
m_plotTime = data.plotTime;
+ m_useCOI = data.useCOI;
}
Electromechanical::~Electromechanical() {}
@@ -469,8 +470,8 @@ bool Electromechanical::InitializeDynamicElements()
if(data.model == Machines::SM_MODEL_1) {
xq = data.transXd * k;
xd = xq;
- }
- else if(data.syncXq == 0.0) xq = data.syncXd * k;
+ } else if(data.syncXq == 0.0)
+ xq = data.syncXd * k;
// Initialize state variables
std::complex<double> eq0 = data.terminalVoltage + std::complex<double>(ra, xq) * ia;
@@ -588,6 +589,7 @@ bool Electromechanical::InitializeDynamicElements()
syncGenerator->SetElectricalData(data);
}
+ CalculateReferenceSpeed();
return true;
}
@@ -673,8 +675,8 @@ void Electromechanical::CalculateMachinesCurrents()
void Electromechanical::CalculateIntegrationConstants(SyncGenerator* syncGenerator, double id, double iq, double k)
{
+ CalculateReferenceSpeed();
auto data = syncGenerator->GetElectricalData();
- double w0 = 2.0f * M_PI * m_systemFreq;
double syncXd, syncXq, transXd, transXq, subXd, subXq;
syncXd = data.syncXd * k;
@@ -699,13 +701,13 @@ void Electromechanical::CalculateIntegrationConstants(SyncGenerator* syncGenerat
if(subTq0 == 0.0) subTq0 = subTd0;
// Speed
- data.icSpeed.m = m_timeStep / ((4.0f * data.inertia / w0) / k + m_timeStep * data.damping * k);
+ data.icSpeed.m = m_timeStep / ((4.0f * data.inertia / m_refSpeed) / k + m_timeStep * data.damping * k);
data.icSpeed.c = (1.0f - 2.0f * data.icSpeed.m * data.damping * k) * data.speed +
- data.icSpeed.m * (data.pm - data.pe + 2.0f * w0 * data.damping * k);
+ data.icSpeed.m * (data.pm - data.pe + 2.0f * m_refSpeed * data.damping * k);
// Delta
data.icDelta.m = 0.5f * m_timeStep;
- data.icDelta.c = data.delta + data.icDelta.m * (data.speed - 2.0f * w0);
+ data.icDelta.c = data.delta + data.icDelta.m * (data.speed - 2.0f * m_refSpeed);
// Eq'
if(data.model == Machines::SM_MODEL_2 || data.model == Machines::SM_MODEL_3 || data.model == Machines::SM_MODEL_4 ||
@@ -962,15 +964,14 @@ double Electromechanical::CalculateSyncMachineIntVariables(SyncGenerator* syncGe
double pe,
double k)
{
- double w0 = 2.0 * M_PI * m_systemFreq;
double error = 0.0;
auto data = syncGenerator->GetElectricalData();
// Mechanical differential equations.
double w = data.icSpeed.c + data.icSpeed.m * (data.pm - pe);
- error = std::max(error, std::abs(data.speed - w) / w0);
+ error = std::max(error, std::abs(data.speed - w) / m_refSpeed);
- m_wError += std::abs(data.speed - w) / w0;
+ m_wError += std::abs(data.speed - w) / m_refSpeed;
double delta = data.icDelta.c + data.icDelta.m * w;
error = std::max(error, std::abs(data.delta - delta));
@@ -1087,3 +1088,27 @@ double Electromechanical::CalculateSyncMachineIntVariables(SyncGenerator* syncGe
syncGenerator->SetElectricalData(data);
return error;
}
+
+void Electromechanical::CalculateReferenceSpeed()
+{
+ if(m_useCOI) {
+ double sumHW = 0.0;
+ double sumH = 0.0;
+ for(auto it = m_syncGeneratorList.begin(), itEnd = m_syncGeneratorList.end(); it != itEnd; ++it) {
+ SyncGenerator* syncGenerator = *it;
+ if(syncGenerator->IsOnline()) {
+ auto data = syncGenerator->GetElectricalData();
+ double k = 1.0; // Power base change factor.
+ if(data.useMachineBase) {
+ double oldBase = GetPowerValue(data.nominalPower, data.nominalPowerUnit);
+ k = m_powerSystemBase / oldBase;
+ }
+ sumH += data.inertia / k;
+ sumHW += data.inertia * data.speed / k;
+ }
+ }
+ m_refSpeed = sumHW / sumH;
+ } else {
+ m_refSpeed = 2.0 * M_PI * m_systemFreq;
+ }
+}
diff --git a/Project/Electromechanical.h b/Project/Electromechanical.h
index 7400944..f981353 100644
--- a/Project/Electromechanical.h
+++ b/Project/Electromechanical.h
@@ -39,6 +39,7 @@ class Electromechanical : public ElectricCalculation
void SetSyncMachinesModel();
double CalculateSyncMachineIntVariables(SyncGenerator* syncGenerator, double id, double iq, double pe, double k = 1.0);
void CalculateSyncMachineNonIntVariables(SyncGenerator* syncGenerator, double& id, double& iq, double& pe, double k = 1.0);
+ void CalculateReferenceSpeed();
void SaveData();
@@ -46,6 +47,8 @@ class Electromechanical : public ElectricCalculation
wxString m_errorMsg = _("Unknown error");
double m_systemFreq = 60.0;
+ double m_refSpeed = 2.0 * M_PI * 60.0;
+ bool m_useCOI = false;
std::vector<std::vector<std::complex<double> > > m_yBus;
std::vector<std::vector<std::complex<double> > > m_yBusU;
diff --git a/Project/FileHanding.cpp b/Project/FileHanding.cpp
index dbd40d2..f5b881d 100644
--- a/Project/FileHanding.cpp
+++ b/Project/FileHanding.cpp
@@ -868,6 +868,9 @@ bool FileHanding::OpenProject(wxFileName path)
data.stabFaultReactance = GetNodeValueDouble(stability, "FaultReactance");
bus->SetElectricalData(data);
+
+ if(data.stabHasFault) bus->SetDynamicEvent(true);
+
elementList.push_back(bus);
busList.push_back(bus);
busNode = busNode->next_sibling("Bus");
@@ -940,6 +943,9 @@ bool FileHanding::OpenProject(wxFileName path)
capacitor->SetSwitchingData(swData);
capacitor->SetElectricalData(data);
+
+ if(swData.swTime.size() != 0) capacitor->SetDynamicEvent(true);
+
elementList.push_back(capacitor);
capacitorList.push_back(capacitor);
capacitorNode = capacitorNode->next_sibling("Capacitor");
@@ -1075,6 +1081,9 @@ bool FileHanding::OpenProject(wxFileName path)
inductor->SetSwitchingData(swData);
inductor->SetElectricalData(data);
+
+ if(swData.swTime.size() != 0) inductor->SetDynamicEvent(true);
+
elementList.push_back(inductor);
inductorList.push_back(inductor);
inductorNode = inductorNode->next_sibling("Inductor");
@@ -1183,6 +1192,9 @@ bool FileHanding::OpenProject(wxFileName path)
line->SetSwitchingData(swData);
line->SetElectricalData(data);
+
+ if(swData.swTime.size() != 0) line->SetDynamicEvent(true);
+
elementList.push_back(line);
lineList.push_back(line);
lineNode = lineNode->next_sibling("Line");
@@ -1258,6 +1270,9 @@ bool FileHanding::OpenProject(wxFileName path)
load->SetSwitchingData(swData);
load->SetElectricalData(data);
+
+ if(swData.swTime.size() != 0) load->SetDynamicEvent(true);
+
elementList.push_back(load);
loadList.push_back(load);
loadNode = loadNode->next_sibling("Load");
@@ -1384,6 +1399,9 @@ bool FileHanding::OpenProject(wxFileName path)
syncGenerator->SetSwitchingData(swData);
syncGenerator->SetElectricalData(data);
+
+ if(swData.swTime.size() != 0) syncGenerator->SetDynamicEvent(true);
+
elementList.push_back(syncGenerator);
syncGeneratorList.push_back(syncGenerator);
syncGeneratorNode = syncGeneratorNode->next_sibling("SyncGenerator");
@@ -1611,6 +1629,9 @@ bool FileHanding::OpenProject(wxFileName path)
transformer->SetSwitchingData(swData);
transformer->SetElectricaData(data);
+
+ if(swData.swTime.size() != 0) transformer->SetDynamicEvent(true);
+
elementList.push_back(transformer);
transformerList.push_back(transformer);
transfomerNode = transfomerNode->next_sibling("Transfomer");
diff --git a/Project/Inductor.cpp b/Project/Inductor.cpp
index b169f8a..ca0dcd8 100644
--- a/Project/Inductor.cpp
+++ b/Project/Inductor.cpp
@@ -1,15 +1,8 @@
#include "ReactiveShuntElementForm.h"
#include "Inductor.h"
-Inductor::Inductor()
- : Shunt()
-{
-}
-Inductor::Inductor(wxString name)
- : Shunt()
-{
- m_electricalData.name = name;
-}
+Inductor::Inductor() : Shunt() {}
+Inductor::Inductor(wxString name) : Shunt() { m_electricalData.name = name; }
Inductor::~Inductor() {}
bool Inductor::AddParent(Element* parent, wxPoint2DDouble position)
{
@@ -17,11 +10,11 @@ bool Inductor::AddParent(Element* parent, wxPoint2DDouble position)
m_parentList.push_back(parent);
parent->AddChild(this);
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.
- m_position = parentPt + wxPoint2DDouble(0.0, 100.0); // Shifts the position to the down of the bus.
+ m_position = parentPt + wxPoint2DDouble(0.0, 100.0); // Shifts the position to the down of the bus.
m_width = 20.0;
m_height = 70.0;
m_rect = wxRect2DDouble(m_position.m_x - m_width / 2.0, m_position.m_y - m_height / 2.0, m_width, m_height);
@@ -34,7 +27,7 @@ bool Inductor::AddParent(Element* parent, wxPoint2DDouble position)
m_inserted = true;
wxRect2DDouble genRect(0, 0, 0, 0);
- m_switchRect.push_back(genRect); // Push a general rectangle.
+ m_switchRect.push_back(genRect); // Push a general rectangle.
UpdateSwitches();
return true;
@@ -45,9 +38,12 @@ bool Inductor::AddParent(Element* parent, wxPoint2DDouble position)
void Inductor::Draw(wxPoint2DDouble translation, double scale) const
{
OpenGLColour elementColour;
- if(m_online)
- elementColour = m_onlineElementColour;
- else
+ if(m_online) {
+ if(m_dynEvent)
+ elementColour = m_dynamicEventColour;
+ else
+ elementColour = m_onlineElementColour;
+ } else
elementColour = m_offlineElementColour;
if(m_inserted) {
diff --git a/Project/Line.cpp b/Project/Line.cpp
index ba56ebc..350d3f5 100644
--- a/Project/Line.cpp
+++ b/Project/Line.cpp
@@ -1,7 +1,6 @@
#include "Line.h"
-Line::Line()
- : Branch()
+Line::Line() : Branch()
{
for(int i = 0; i < 2; i++) {
for(int j = 0; j < 3; j++) {
@@ -10,8 +9,7 @@ Line::Line()
}
}
-Line::Line(wxString name)
- : Branch()
+Line::Line(wxString name) : Branch()
{
for(int i = 0; i < 2; i++) {
for(int j = 0; j < 3; j++) {
@@ -32,9 +30,13 @@ bool Line::Contains(wxPoint2DDouble position) const
void Line::Draw(wxPoint2DDouble translation, double scale) const
{
OpenGLColour elementColour;
- if(m_online)
- elementColour = m_onlineElementColour;
- else
+ if(m_online) {
+ if(m_dynEvent)
+ elementColour = m_dynamicEventColour;
+ else
+ elementColour = m_onlineElementColour;
+
+ } else
elementColour = m_offlineElementColour;
std::vector<wxPoint2DDouble> pointList = m_pointList;
@@ -123,10 +125,10 @@ bool Line::AddParent(Element* parent, wxPoint2DDouble position)
m_parentList.push_back(parent);
parent->AddChild(this);
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);
@@ -143,10 +145,10 @@ bool Line::AddParent(Element* parent, wxPoint2DDouble position)
else if(parent != m_parentList[0]) {
Bus* parentBus = static_cast<Bus*>(parent);
if(m_electricaData.nominalVoltage != parentBus->GetElectricalData().nominalVoltage ||
- m_electricaData.nominalVoltageUnit != parentBus->GetElectricalData().nominalVoltageUnit) {
+ m_electricaData.nominalVoltageUnit != parentBus->GetElectricalData().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;
}
@@ -154,9 +156,9 @@ bool Line::AddParent(Element* parent, wxPoint2DDouble position)
m_parentList.push_back(parent);
parent->AddChild(this);
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;
@@ -168,7 +170,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);
@@ -353,12 +355,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)) {
@@ -369,10 +371,10 @@ bool Line::SetNodeParent(Element* parent)
m_electricaData.nominalVoltage = parentBus->GetElectricalData().nominalVoltage;
m_electricaData.nominalVoltageUnit = parentBus->GetElectricalData().nominalVoltageUnit;
} else if(m_electricaData.nominalVoltage != parentBus->GetElectricalData().nominalVoltage ||
- m_electricaData.nominalVoltageUnit != parentBus->GetElectricalData().nominalVoltageUnit) {
+ m_electricaData.nominalVoltageUnit != parentBus->GetElectricalData().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;
@@ -389,8 +391,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;
@@ -492,13 +494,13 @@ wxString Line::GetTipText() const
busNumber[1] = static_cast<Bus*>(m_parentList[1])->GetElectricalData().number + 1;
tipText += _("\nP") + wxString::Format("(%d-%d) = ", busNumber[0], busNumber[1]) +
- wxString::FromDouble(m_electricaData.powerFlow[0].real(), 5) + _(" p.u.");
+ wxString::FromDouble(m_electricaData.powerFlow[0].real(), 5) + _(" p.u.");
tipText += _("\nQ") + wxString::Format("(%d-%d) = ", busNumber[0], busNumber[1]) +
- wxString::FromDouble(m_electricaData.powerFlow[0].imag(), 5) + _(" p.u.");
+ wxString::FromDouble(m_electricaData.powerFlow[0].imag(), 5) + _(" p.u.");
tipText += _("\nP") + wxString::Format("(%d-%d) = ", busNumber[1], busNumber[0]) +
- wxString::FromDouble(m_electricaData.powerFlow[1].real(), 5) + _(" p.u.");
+ wxString::FromDouble(m_electricaData.powerFlow[1].real(), 5) + _(" p.u.");
tipText += _("\nQ") + wxString::Format("(%d-%d) = ", busNumber[1], busNumber[0]) +
- wxString::FromDouble(m_electricaData.powerFlow[1].imag(), 5) + _(" p.u.");
+ wxString::FromDouble(m_electricaData.powerFlow[1].imag(), 5) + _(" p.u.");
}
return tipText;
diff --git a/Project/Load.cpp b/Project/Load.cpp
index d9574d9..c490d24 100644
--- a/Project/Load.cpp
+++ b/Project/Load.cpp
@@ -1,14 +1,7 @@
#include "Load.h"
-Load::Load()
- : Shunt()
-{
-}
-Load::Load(wxString name)
- : Shunt()
-{
- m_electricalData.name = name;
-}
+Load::Load() : Shunt() {}
+Load::Load(wxString name) : Shunt() { m_electricalData.name = name; }
Load::~Load() {}
bool Load::AddParent(Element* parent, wxPoint2DDouble position)
{
@@ -16,11 +9,11 @@ bool Load::AddParent(Element* parent, wxPoint2DDouble position)
m_parentList.push_back(parent);
parent->AddChild(this);
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.
- m_position = parentPt + wxPoint2DDouble(0.0, 100.0); // Shifts the position to the down of the bus.
+ m_position = parentPt + wxPoint2DDouble(0.0, 100.0); // Shifts the position to the down of the bus.
m_width = m_height = 20.0;
m_rect = wxRect2DDouble(m_position.m_x - 10.0, m_position.m_y - 10.0, m_width, m_height);
@@ -36,7 +29,7 @@ bool Load::AddParent(Element* parent, wxPoint2DDouble position)
m_inserted = true;
wxRect2DDouble genRect(0, 0, 0, 0);
- m_switchRect.push_back(genRect); // Push a general rectangle.
+ m_switchRect.push_back(genRect); // Push a general rectangle.
UpdateSwitches();
m_pfDirection = PF_TO_ELEMENT;
UpdatePowerFlowArrowsPosition();
@@ -49,9 +42,12 @@ bool Load::AddParent(Element* parent, wxPoint2DDouble position)
void Load::Draw(wxPoint2DDouble translation, double scale) const
{
OpenGLColour elementColour;
- if(m_online)
- elementColour = m_onlineElementColour;
- else
+ if(m_online) {
+ if(m_dynEvent)
+ elementColour = m_dynamicEventColour;
+ else
+ elementColour = m_onlineElementColour;
+ } else
elementColour = m_offlineElementColour;
if(m_inserted) {
@@ -60,10 +56,10 @@ void Load::Draw(wxPoint2DDouble translation, double scale) const
glLineWidth(1.5 + m_borderSize * 2.0);
glColor4dv(m_selectionColour.GetRGBA());
std::vector<wxPoint2DDouble> selTriangPts;
- selTriangPts.push_back(
- m_triangPts[0] + m_position + wxPoint2DDouble(-m_borderSize / scale, -m_borderSize / scale));
- selTriangPts.push_back(
- m_triangPts[1] + m_position + wxPoint2DDouble(m_borderSize / scale, -m_borderSize / scale));
+ selTriangPts.push_back(m_triangPts[0] + m_position +
+ wxPoint2DDouble(-m_borderSize / scale, -m_borderSize / scale));
+ selTriangPts.push_back(m_triangPts[1] + m_position +
+ wxPoint2DDouble(m_borderSize / scale, -m_borderSize / scale));
selTriangPts.push_back(m_triangPts[2] + m_position + wxPoint2DDouble(0.0, m_borderSize / scale));
glPushMatrix();
diff --git a/Project/Machines.cpp b/Project/Machines.cpp
index dd93bf1..883ad3a 100644
--- a/Project/Machines.cpp
+++ b/Project/Machines.cpp
@@ -1,9 +1,6 @@
#include "Machines.h"
-Machines::Machines()
- : PowerElement()
-{
-}
+Machines::Machines() : PowerElement() {}
Machines::~Machines() {}
bool Machines::AddParent(Element* parent, wxPoint2DDouble position)
{
@@ -11,11 +8,11 @@ bool Machines::AddParent(Element* parent, wxPoint2DDouble position)
m_parentList.push_back(parent);
parent->AddChild(this);
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.
- m_position = parentPt + wxPoint2DDouble(-100.0, 0.0); // Shifts the position to the left of the bus.
+ m_position = parentPt + wxPoint2DDouble(-100.0, 0.0); // Shifts the position to the left of the bus.
m_width = m_height = 50.0;
m_rect = wxRect2DDouble(m_position.m_x - 25.0, m_position.m_y - 25.0, m_width, m_height);
@@ -26,7 +23,7 @@ bool Machines::AddParent(Element* parent, wxPoint2DDouble position)
m_inserted = true;
wxRect2DDouble genRect(0, 0, 0, 0);
- m_switchRect.push_back(genRect); // Push a general rectangle.
+ m_switchRect.push_back(genRect); // Push a general rectangle.
UpdateSwitches();
UpdatePowerFlowArrowsPosition();
return true;
@@ -37,9 +34,14 @@ bool Machines::AddParent(Element* parent, wxPoint2DDouble position)
void Machines::Draw(wxPoint2DDouble translation, double scale) const
{
OpenGLColour elementColour;
- if(m_online) elementColour = m_onlineElementColour;
- else elementColour = m_offlineElementColour;
-
+ if(m_online) {
+ if(m_dynEvent)
+ elementColour = m_dynamicEventColour;
+ else
+ elementColour = m_onlineElementColour;
+ } else
+ elementColour = m_offlineElementColour;
+
if(m_inserted) {
// Draw Selection (layer 1).
if(m_selected) {
@@ -153,7 +155,7 @@ void Machines::RemoveParent(Element* parent)
bool Machines::NodeContains(wxPoint2DDouble position)
{
wxRect2DDouble nodeRect(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(nodeRect.Contains(position)) {
m_activeNodeID = 1;
@@ -168,15 +170,15 @@ bool Machines::SetNodeParent(Element* parent)
{
if(parent && m_activeNodeID != 0) {
wxRect2DDouble nodeRect(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(parent->Intersects(nodeRect)) {
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.
+ 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;
@@ -195,7 +197,7 @@ void Machines::UpdateNodes()
{
if(m_parentList[0]) {
wxRect2DDouble nodeRect(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_parentList[0]->Intersects(nodeRect)) {
m_parentList[0]->RemoveChild(this);
diff --git a/Project/PowerElement.cpp b/Project/PowerElement.cpp
index e6a04ed..2a00abf 100644
--- a/Project/PowerElement.cpp
+++ b/Project/PowerElement.cpp
@@ -3,8 +3,7 @@
#include "DegreesAndRadians.h"
#endif
-PowerElement::PowerElement()
- : Element()
+PowerElement::PowerElement() : Element()
{
m_busColour.SetRGBA(0.0, 0.3, 1.0, 1.0);
m_onlineElementColour.SetRGBA(0.2, 0.2, 0.2, 1.0);
@@ -12,15 +11,17 @@ PowerElement::PowerElement()
m_closedSwitchColour.SetRGBA(0.0, 0.4, 0.0, 1.0);
m_openedSwitchColour.SetRGBA(1.0, 0.1, 0.1, 1.0);
m_powerFlowArrowColour.SetRGBA(1.0, 0.51, 0.0, 1.0);
+ m_dynamicEventColour.SetRGBA(1.0, 0.51, 0.0, 1.0);
}
PowerElement::~PowerElement() {}
-
void PowerElement::SetNominalVoltage(std::vector<double> nominalVoltage, std::vector<ElectricalUnit> nominalVoltageUnit)
{
}
-wxPoint2DDouble PowerElement::GetSwitchPoint(Element* parent, wxPoint2DDouble parentPoint, wxPoint2DDouble secondPoint) const
+wxPoint2DDouble PowerElement::GetSwitchPoint(Element* parent,
+ wxPoint2DDouble parentPoint,
+ wxPoint2DDouble secondPoint) const
{
double swLineSize = 25.0;
wxPoint2DDouble swPoint = wxPoint2DDouble(parentPoint.m_x, parentPoint.m_y - swLineSize);
@@ -28,17 +29,18 @@ wxPoint2DDouble PowerElement::GetSwitchPoint(Element* parent, wxPoint2DDouble pa
// Rotate the second point (to compare).
double angle = parent->GetAngle();
- secondPoint = wxPoint2DDouble(std::cos(wxDegToRad(-angle)) * (secondPoint.m_x - parentPoint.m_x) -
- std::sin(wxDegToRad(-angle)) * (secondPoint.m_y - parentPoint.m_y) + parentPoint.m_x,
- std::sin(wxDegToRad(-angle)) * (secondPoint.m_x - parentPoint.m_x) +
- std::cos(wxDegToRad(-angle)) * (secondPoint.m_y - parentPoint.m_y) + parentPoint.m_y);
+ secondPoint =
+ wxPoint2DDouble(std::cos(wxDegToRad(-angle)) * (secondPoint.m_x - parentPoint.m_x) -
+ std::sin(wxDegToRad(-angle)) * (secondPoint.m_y - parentPoint.m_y) + parentPoint.m_x,
+ std::sin(wxDegToRad(-angle)) * (secondPoint.m_x - parentPoint.m_x) +
+ std::cos(wxDegToRad(-angle)) * (secondPoint.m_y - parentPoint.m_y) + parentPoint.m_y);
// Rotate
if(secondPoint.m_y > parentPoint.m_y) angle -= 180.0;
return wxPoint2DDouble(std::cos(wxDegToRad(angle)) * (swPoint.m_x - parentPoint.m_x) -
- std::sin(wxDegToRad(angle)) * (swPoint.m_y - parentPoint.m_y) + parentPoint.m_x,
- std::sin(wxDegToRad(angle)) * (swPoint.m_x - parentPoint.m_x) +
- std::cos(wxDegToRad(angle)) * (swPoint.m_y - parentPoint.m_y) + parentPoint.m_y);
+ std::sin(wxDegToRad(angle)) * (swPoint.m_y - parentPoint.m_y) + parentPoint.m_x,
+ std::sin(wxDegToRad(angle)) * (swPoint.m_x - parentPoint.m_x) +
+ std::cos(wxDegToRad(angle)) * (swPoint.m_y - parentPoint.m_y) + parentPoint.m_y);
}
bool PowerElement::SwitchesContains(wxPoint2DDouble position) const
@@ -54,10 +56,10 @@ bool PowerElement::SwitchesContains(wxPoint2DDouble position) const
void PowerElement::UpdateSwitches()
{
// General method, to one switch only.
- wxPoint2DDouble swCenter = wxPoint2DDouble(
- (m_pointList[0].m_x + m_pointList[1].m_x) / 2.0, (m_pointList[0].m_y + m_pointList[1].m_y) / 2.0);
- m_switchRect[0] = wxRect2DDouble(
- swCenter.m_x - m_switchSize / 2.0, swCenter.m_y - m_switchSize / 2.0, m_switchSize, m_switchSize);
+ wxPoint2DDouble swCenter = wxPoint2DDouble((m_pointList[0].m_x + m_pointList[1].m_x) / 2.0,
+ (m_pointList[0].m_y + m_pointList[1].m_y) / 2.0);
+ m_switchRect[0] = wxRect2DDouble(swCenter.m_x - m_switchSize / 2.0, swCenter.m_y - m_switchSize / 2.0, m_switchSize,
+ m_switchSize);
}
void PowerElement::DrawSwitches() const
@@ -74,13 +76,13 @@ void PowerElement::DrawSwitches() const
glPushMatrix();
glTranslated(m_switchRect[i].GetPosition().m_x + m_switchSize / 2.0,
- m_switchRect[i].GetPosition().m_y + m_switchSize / 2.0, 0.0);
+ m_switchRect[i].GetPosition().m_y + m_switchSize / 2.0, 0.0);
glRotated(parent->GetAngle(), 0.0, 0.0, 1.0);
glTranslated(-m_switchRect[i].GetPosition().m_x - m_switchSize / 2.0,
- -m_switchRect[i].GetPosition().m_y - m_switchSize / 2.0, 0.0);
+ -m_switchRect[i].GetPosition().m_y - m_switchSize / 2.0, 0.0);
DrawRectangle(m_switchRect[i].GetPosition() + wxPoint2DDouble(m_switchSize / 2.0, m_switchSize / 2.0),
- m_switchSize, m_switchSize);
+ m_switchSize, m_switchSize);
glPopMatrix();
}
@@ -90,7 +92,7 @@ void PowerElement::DrawSwitches() const
void PowerElement::CalculatePowerFlowPts(std::vector<wxPoint2DDouble> edges)
{
- double arrowRate = 100.0; // One arrow to each "arrowRate" distance in pixels.
+ double arrowRate = 100.0; // One arrow to each "arrowRate" distance in pixels.
if(edges.size() < 2) return;
@@ -113,7 +115,7 @@ void PowerElement::CalculatePowerFlowPts(std::vector<wxPoint2DDouble> edges)
for(int i = 0; i < numArrows; i++) {
wxPoint2DDouble arrowCenter(pt1.m_x + ((rotPt2.m_x - pt1.m_x) / double(numArrows + 1)) * double(i + 1),
- pt1.m_y + ((rotPt2.m_y - pt1.m_y) / double(numArrows + 1)) * double(i + 1));
+ pt1.m_y + ((rotPt2.m_y - pt1.m_y) / double(numArrows + 1)) * double(i + 1));
std::vector<wxPoint2DDouble> triPts;
triPts.push_back(arrowCenter + wxPoint2DDouble(5.0, 0.0));
diff --git a/Project/PowerElement.h b/Project/PowerElement.h
index 033d697..e1afc7a 100644
--- a/Project/PowerElement.h
+++ b/Project/PowerElement.h
@@ -173,13 +173,22 @@ class PowerElement : public Element
* @return Power flow direction.
*/
virtual PowerFlowDirection GetPowerFlowDirection() const { return m_pfDirection; }
-
/**
* @brief Fill the plot data.
* @param plotData Plot data to be filled.
* @return true if the plot data was successfully filled, false otherwise.
*/
virtual bool GetPlotData(ElementPlotData& plotData) { return false; }
+ /**
+ * @brief Check if the power element have dynamic event.
+ * @return true if the element have dynamic an event, false otherwise.
+ */
+ virtual bool HaveDynamicEvent() const { return m_dynEvent; }
+ /**
+ * @brief Set if the power element have dynamic event.
+ * @param dynEvent Event occurrence.
+ */
+ virtual void SetDynamicEvent(bool dynEvent = true) { m_dynEvent = dynEvent; }
protected:
SwitchingData m_swData;
std::vector<std::vector<wxPoint2DDouble> > m_powerFlowArrow;
@@ -191,6 +200,9 @@ class PowerElement : public Element
OpenGLColour m_closedSwitchColour;
OpenGLColour m_openedSwitchColour;
OpenGLColour m_powerFlowArrowColour;
+ OpenGLColour m_dynamicEventColour;
+
+ bool m_dynEvent = false;
};
#endif // POWERELEMENT_H
diff --git a/Project/Project.mk b/Project/Project.mk
index f21cde6..8377c85 100644
--- a/Project/Project.mk
+++ b/Project/Project.mk
@@ -13,7 +13,7 @@ CurrentFileName :=
CurrentFilePath :=
CurrentFileFullPath :=
User :=NDSE-69
-Date :=11/08/2017
+Date :=30/08/2017
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/PropertiesData.h b/Project/PropertiesData.h
index 4c8d2c9..634e60e 100644
--- a/Project/PropertiesData.h
+++ b/Project/PropertiesData.h
@@ -29,6 +29,7 @@ struct SimulationData {
int stabilityMaxIterations = 100;
int controlTimeStepRatio = 10;
double plotTime = 1e-2;
+ bool useCOI = true;
};
struct GeneralData {
diff --git a/Project/PropertiesForm.cpp b/Project/PropertiesForm.cpp
index 8c3fac0..dd98180 100644
--- a/Project/PropertiesForm.cpp
+++ b/Project/PropertiesForm.cpp
@@ -406,6 +406,11 @@ SimulationsSettingsFormBase::SimulationsSettingsFormBase(wxWindow* parent, wxWin
boxSizerLvl4_8->Add(m_staticTextSec_4, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxALIGN_CENTER_VERTICAL, WXC_FROM_DIP(5));
+ m_checkBoxUseCOI = new wxCheckBox(m_panelStability, wxID_ANY, _("Use center of inertia as reference"), wxDefaultPosition, wxDLG_UNIT(m_panelStability, wxSize(-1,-1)), 0);
+ m_checkBoxUseCOI->SetValue(true);
+
+ boxSizerLvl2_232->Add(m_checkBoxUseCOI, 0, wxALL, WXC_FROM_DIP(5));
+
wxBoxSizer* boxSizer_bottonButtons = new wxBoxSizer(wxHORIZONTAL);
boxSizer_lvl1_1->Add(boxSizer_bottonButtons, 0, wxALL|wxEXPAND, WXC_FROM_DIP(5));
diff --git a/Project/PropertiesForm.h b/Project/PropertiesForm.h
index cc4b7e6..c3704fb 100644
--- a/Project/PropertiesForm.h
+++ b/Project/PropertiesForm.h
@@ -109,6 +109,7 @@ protected:
wxStaticText* m_staticTextPrintTime;
wxTextCtrl* m_textCtrlPrintTime;
wxStaticText* m_staticTextSec_4;
+ wxCheckBox* m_checkBoxUseCOI;
wxButton* m_buttonOK;
wxButton* m_buttonCancel;
@@ -151,6 +152,7 @@ public:
wxStaticText* GetStaticTextPrintTime() { return m_staticTextPrintTime; }
wxTextCtrl* GetTextCtrlPrintTime() { return m_textCtrlPrintTime; }
wxStaticText* GetStaticTextSec_4() { return m_staticTextSec_4; }
+ wxCheckBox* GetCheckBoxUseCOI() { return m_checkBoxUseCOI; }
wxPanel* GetPanelStability() { return m_panelStability; }
wxNotebook* GetNotebook() { return m_notebook; }
wxButton* GetButtonOK() { return m_buttonOK; }
diff --git a/Project/PropertiesForm.wxcp b/Project/PropertiesForm.wxcp
index a63c219..685285a 100644
--- a/Project/PropertiesForm.wxcp
+++ b/Project/PropertiesForm.wxcp
@@ -1,7 +1,7 @@
{
"metadata": {
"m_generatedFilesDir": ".",
- "m_objCounter": 200,
+ "m_objCounter": 202,
"m_includeFiles": [],
"m_bitmapFunction": "wxCDAD0InitBitmapResources",
"m_bitmapsFile": "PropertiesFormBitmaps.cpp",
@@ -4509,6 +4509,81 @@
}]
}]
}]
+ }, {
+ "m_type": 4415,
+ "proportion": 0,
+ "border": 5,
+ "gbSpan": "1,1",
+ "gbPosition": "0,0",
+ "m_styles": [],
+ "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"],
+ "m_properties": [{
+ "type": "winid",
+ "m_label": "ID:",
+ "m_winid": "wxID_ANY"
+ }, {
+ "type": "string",
+ "m_label": "Size:",
+ "m_value": "-1,-1"
+ }, {
+ "type": "string",
+ "m_label": "Minimum Size:",
+ "m_value": "-1,-1"
+ }, {
+ "type": "string",
+ "m_label": "Name:",
+ "m_value": "m_checkBoxUseCOI"
+ }, {
+ "type": "multi-string",
+ "m_label": "Tooltip:",
+ "m_value": ""
+ }, {
+ "type": "colour",
+ "m_label": "Bg Colour:",
+ "colour": "<Default>"
+ }, {
+ "type": "colour",
+ "m_label": "Fg Colour:",
+ "colour": "<Default>"
+ }, {
+ "type": "font",
+ "m_label": "Font:",
+ "m_value": ""
+ }, {
+ "type": "bool",
+ "m_label": "Hidden",
+ "m_value": false
+ }, {
+ "type": "bool",
+ "m_label": "Disabled",
+ "m_value": false
+ }, {
+ "type": "bool",
+ "m_label": "Focused",
+ "m_value": false
+ }, {
+ "type": "string",
+ "m_label": "Class Name:",
+ "m_value": ""
+ }, {
+ "type": "string",
+ "m_label": "Include File:",
+ "m_value": ""
+ }, {
+ "type": "string",
+ "m_label": "Style:",
+ "m_value": ""
+ }, {
+ "type": "string",
+ "m_label": "Label:",
+ "m_value": "Use center of inertia as reference"
+ }, {
+ "type": "bool",
+ "m_label": "Value:",
+ "m_value": true
+ }],
+ "m_events": [],
+ "m_children": []
}]
}]
}]
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;
}
diff --git a/Project/SwitchingForm.cpp b/Project/SwitchingForm.cpp
index 061b0a5..29da9c2 100644
--- a/Project/SwitchingForm.cpp
+++ b/Project/SwitchingForm.cpp
@@ -60,6 +60,11 @@ void SwitchingForm::OnOKButtonClick(wxCommandEvent& event)
}
m_element->SetSwitchingData(data);
+ if(data.swTime.size() != 0)
+ m_element->SetDynamicEvent(true);
+ else
+ m_element->SetDynamicEvent(false);
+
EndModal(wxID_OK);
}
diff --git a/Project/Transformer.cpp b/Project/Transformer.cpp
index 7848abb..584a139 100644
--- a/Project/Transformer.cpp
+++ b/Project/Transformer.cpp
@@ -1,8 +1,7 @@
#include "TransformerForm.h"
#include "Transformer.h"
-Transformer::Transformer()
- : Branch()
+Transformer::Transformer() : Branch()
{
for(int i = 0; i < 2; i++) {
for(int j = 0; j < 3; j++) {
@@ -10,8 +9,7 @@ Transformer::Transformer()
}
}
}
-Transformer::Transformer(wxString name)
- : Branch()
+Transformer::Transformer(wxString name) : Branch()
{
for(int i = 0; i < 2; i++) {
for(int j = 0; j < 3; j++) {
@@ -30,10 +28,10 @@ bool Transformer::AddParent(Element* parent, wxPoint2DDouble position)
m_parentList.push_back(parent);
parent->AddChild(this);
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);
@@ -46,9 +44,9 @@ bool Transformer::AddParent(Element* parent, wxPoint2DDouble position)
m_parentList.push_back(parent);
parent->AddChild(this);
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 =
@@ -56,9 +54,10 @@ bool Transformer::AddParent(Element* parent, wxPoint2DDouble position)
// Set the transformer rectangle.
m_width = 70.0;
m_height = 40.0;
- SetPosition(m_position); // This method calculates the rectangle propely.
+ SetPosition(m_position); // This method calculates the rectangle propely.
// Set the "side" points.
- m_pointList.push_back(wxPoint2DDouble(m_rect.GetPosition() + wxPoint2DDouble(-10 - m_borderSize, m_height / 2.0)));
+ m_pointList.push_back(
+ wxPoint2DDouble(m_rect.GetPosition() + wxPoint2DDouble(-10 - m_borderSize, m_height / 2.0)));
m_pointList.push_back(
wxPoint2DDouble(m_rect.GetPosition() + wxPoint2DDouble(m_width + 10 + m_borderSize, m_height / 2.0)));
@@ -72,7 +71,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);
@@ -95,9 +94,12 @@ bool Transformer::Contains(wxPoint2DDouble position) const
void Transformer::Draw(wxPoint2DDouble translation, double scale) const
{
OpenGLColour elementColour;
- if(m_online)
- elementColour = m_onlineElementColour;
- else
+ if(m_online) {
+ if(m_dynEvent)
+ elementColour = m_dynamicEventColour;
+ else
+ elementColour = m_onlineElementColour;
+ } else
elementColour = m_offlineElementColour;
if(m_inserted) {
@@ -113,10 +115,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();
@@ -328,12 +330,12 @@ bool Transformer::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)) {
@@ -348,8 +350,8 @@ bool Transformer::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;
@@ -431,13 +433,13 @@ wxString Transformer::GetTipText() const
busNumber[1] = static_cast<Bus*>(m_parentList[1])->GetElectricalData().number + 1;
tipText += _("\nP") + wxString::Format("(%d-%d) = ", busNumber[0], busNumber[1]) +
- wxString::FromDouble(m_electricalData.powerFlow[0].real(), 5) + _(" p.u.");
+ wxString::FromDouble(m_electricalData.powerFlow[0].real(), 5) + _(" p.u.");
tipText += _("\nQ") + wxString::Format("(%d-%d) = ", busNumber[0], busNumber[1]) +
- wxString::FromDouble(m_electricalData.powerFlow[0].imag(), 5) + _(" p.u.");
+ wxString::FromDouble(m_electricalData.powerFlow[0].imag(), 5) + _(" p.u.");
tipText += _("\nP") + wxString::Format("(%d-%d) = ", busNumber[1], busNumber[0]) +
- wxString::FromDouble(m_electricalData.powerFlow[1].real(), 5) + _(" p.u.");
+ wxString::FromDouble(m_electricalData.powerFlow[1].real(), 5) + _(" p.u.");
tipText += _("\nQ") + wxString::Format("(%d-%d) = ", busNumber[1], busNumber[0]) +
- wxString::FromDouble(m_electricalData.powerFlow[1].imag(), 5) + _(" p.u.");
+ wxString::FromDouble(m_electricalData.powerFlow[1].imag(), 5) + _(" p.u.");
}
return tipText;