summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThales Lima Oliveira <thaleslima.ufu@gmail.com>2017-05-23 20:18:04 -0300
committerThales Lima Oliveira <thaleslima.ufu@gmail.com>2017-05-23 20:18:04 -0300
commit2c60c7c13ecc8e45e072346193a820f697fb6fdf (patch)
tree4c25e23aec8afaf08c9cd218e1c567ac11eead15
parentf995850b38916b38718b84f4b82948479a81855a (diff)
downloadPSP.git-2c60c7c13ecc8e45e072346193a820f697fb6fdf.tar.gz
PSP.git-2c60c7c13ecc8e45e072346193a820f697fb6fdf.tar.xz
PSP.git-2c60c7c13ecc8e45e072346193a820f697fb6fdf.zip
Switching event bug fixed
-rw-r--r--Project/Electromechanical.cpp34
-rw-r--r--Project/Element.cpp5
-rw-r--r--Project/Element.h2
-rw-r--r--Project/Project.mk2
4 files changed, 21 insertions, 22 deletions
diff --git a/Project/Electromechanical.cpp b/Project/Electromechanical.cpp
index 191a1da..895a6f3 100644
--- a/Project/Electromechanical.cpp
+++ b/Project/Electromechanical.cpp
@@ -89,10 +89,11 @@ void Electromechanical::SetEvent(double currentTime)
// Insert machine (only disconnected machines)
if(swData.swType[i] == SW_INSERT && !generator->IsOnline() && generator->GetParentList().size() == 1) {
- generator->SetOnline(true);
- auto data = generator->GetPUElectricalData(m_powerSystemBase);
- int n = static_cast<Bus*>(generator->GetParentList()[0])->GetElectricalData().number;
- m_yBus[n][n] += GetSyncMachineAdmittance(generator);
+ if(generator->SetOnline(true)) {
+ auto data = generator->GetPUElectricalData(m_powerSystemBase);
+ int n = static_cast<Bus*>(generator->GetParentList()[0])->GetElectricalData().number;
+ m_yBus[n][n] += GetSyncMachineAdmittance(generator);
+ }
}
}
}
@@ -116,12 +117,13 @@ void Electromechanical::SetEvent(double currentTime)
// Insert load (only disconnected load)
if(swData.swType[i] == SW_INSERT && !load->IsOnline() && load->GetParentList().size() == 1) {
- load->SetOnline(true);
- auto data = load->GetPUElectricalData(m_powerSystemBase);
- Bus* parentBus = static_cast<Bus*>(load->GetParentList()[0]);
- int n = parentBus->GetElectricalData().number;
- std::complex<double> v = parentBus->GetElectricalData().voltage;
- m_yBus[n][n] += std::complex<double>(data.activePower, -data.reactivePower) / (v * v);
+ if(load->SetOnline(true)) {
+ auto data = load->GetPUElectricalData(m_powerSystemBase);
+ Bus* parentBus = static_cast<Bus*>(load->GetParentList()[0]);
+ int n = parentBus->GetElectricalData().number;
+ std::complex<double> v = parentBus->GetElectricalData().voltage;
+ m_yBus[n][n] += std::complex<double>(data.activePower, -data.reactivePower) / (v * v);
+ }
}
}
}
@@ -153,8 +155,7 @@ void Electromechanical::SetEvent(double currentTime)
// Insert line (only disconnected lines)
if(swData.swType[i] == SW_INSERT && !line->IsOnline() && line->GetParentList().size() == 2) {
- if(line->GetParentList()[0] && line->GetParentList()[1]) {
- line->SetOnline(true);
+ if(line->SetOnline(true)) {
auto data = line->GetElectricalData();
int n1 = static_cast<Bus*>(line->GetParentList()[0])->GetElectricalData().number;
@@ -212,8 +213,7 @@ void Electromechanical::SetEvent(double currentTime)
// Insert transformer (only disconnected transformers)
if(swData.swType[i] == SW_INSERT && !transformer->IsOnline() &&
transformer->GetParentList().size() == 2) {
- if(transformer->GetParentList()[0] && transformer->GetParentList()[1]) {
- transformer->SetOnline(true);
+ if(transformer->SetOnline(true)) {
auto data = transformer->GetElectricalData();
int n1 = static_cast<Bus*>(transformer->GetParentList()[0])->GetElectricalData().number;
@@ -260,8 +260,7 @@ void Electromechanical::SetEvent(double currentTime)
// Insert capacitor (only disconnected capacitors)
if(swData.swType[i] == SW_INSERT && !capacitor->IsOnline() && capacitor->GetParentList().size() == 1) {
- if(capacitor->GetParentList()[0]) {
- capacitor->SetOnline(true);
+ if(capacitor->SetOnline(true)) {
auto data = capacitor->GetPUElectricalData(m_powerSystemBase);
int n = static_cast<Bus*>(capacitor->GetParentList()[0])->GetElectricalData().number;
m_yBus[n][n] -= std::complex<double>(0.0, data.reactivePower);
@@ -287,8 +286,7 @@ void Electromechanical::SetEvent(double currentTime)
// Insert inductor (only disconnected inductors)
if(swData.swType[i] == SW_INSERT && !inductor->IsOnline() && inductor->GetParentList().size() == 1) {
- if(inductor->GetParentList()[0]) {
- inductor->SetOnline(true);
+ if(inductor->SetOnline(true)) {
auto data = inductor->GetPUElectricalData(m_powerSystemBase);
int n = static_cast<Bus*>(inductor->GetParentList()[0])->GetElectricalData().number;
m_yBus[n][n] -= std::complex<double>(0.0, -data.reactivePower);
diff --git a/Project/Element.cpp b/Project/Element.cpp
index 5b2b7d5..381be00 100644
--- a/Project/Element.cpp
+++ b/Project/Element.cpp
@@ -215,13 +215,14 @@ bool Element::RotatedRectanglesIntersects(wxRect2DDouble rect1,
return true;
}
-void Element::SetOnline(bool online)
+bool Element::SetOnline(bool online)
{
// Check if any parent is null.
for(auto it = m_parentList.begin(); it != m_parentList.end(); it++) {
- if(!(*it)) return;
+ if(!(*it)) return false;
}
m_online = online;
+ return true;
}
void Element::GeneralMenuItens(wxMenu& menu)
diff --git a/Project/Element.h b/Project/Element.h
index 4935f11..b8035fb 100644
--- a/Project/Element.h
+++ b/Project/Element.h
@@ -150,7 +150,7 @@ public:
* @brief Set if the element is online or offline.
* @param online True if online, false if offline.
*/
- void SetOnline(bool online = true);
+ bool SetOnline(bool online = true);
/**
* @brief Set the list of points that connect the element to the bus.
diff --git a/Project/Project.mk b/Project/Project.mk
index 04ea9da..9f59536 100644
--- a/Project/Project.mk
+++ b/Project/Project.mk
@@ -13,7 +13,7 @@ CurrentFileName :=
CurrentFilePath :=
CurrentFileFullPath :=
User :=NDSE-69
-Date :=22/05/2017
+Date :=23/05/2017
CodeLitePath :="C:/Program Files/CodeLite"
LinkerName :=C:/TDM-GCC-64/bin/g++.exe
SharedObjectLinkerName :=C:/TDM-GCC-64/bin/g++.exe -shared -fPIC