summaryrefslogtreecommitdiffstats
path: root/Project/Electromechanical.cpp
diff options
context:
space:
mode:
authorThales Lima Oliveira <thaleslima.ufu@gmail.com>2017-05-20 17:22:47 -0300
committerThales Lima Oliveira <thaleslima.ufu@gmail.com>2017-05-20 17:22:47 -0300
commit30181ca0ae73f5f7f1856ac289db8fcf849c9a84 (patch)
tree4b8de3270f4157e6dfbce05bc404cbc29333e969 /Project/Electromechanical.cpp
parent7a556cd67b60f70b9779d298ee687f66c859a529 (diff)
downloadPSP.git-30181ca0ae73f5f7f1856ac289db8fcf849c9a84.tar.gz
PSP.git-30181ca0ae73f5f7f1856ac289db8fcf849c9a84.tar.xz
PSP.git-30181ca0ae73f5f7f1856ac289db8fcf849c9a84.zip
Electromechanical class and several methods implemented
Diffstat (limited to 'Project/Electromechanical.cpp')
-rw-r--r--Project/Electromechanical.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/Project/Electromechanical.cpp b/Project/Electromechanical.cpp
new file mode 100644
index 0000000..85e10b4
--- /dev/null
+++ b/Project/Electromechanical.cpp
@@ -0,0 +1,59 @@
+#include "Electromechanical.h"
+
+Electromechanical::Electromechanical(std::vector<Element*> elementList)
+{
+ GetElementsFromList(elementList);
+ SetEventTimeList();
+}
+
+Electromechanical::~Electromechanical() {}
+void Electromechanical::SetEventTimeList()
+{
+ // Fault
+ for(auto it = m_busList.begin(), itEnd = m_busList.end(); it != itEnd; ++it) {
+ Bus* bus = *it;
+ auto data = bus->GetEletricalData();
+ if(data.stabHasFault) {
+ m_eventTimeList.push_back(data.stabFaultTime);
+ m_eventOccurrenceList.push_back(false);
+ m_eventTimeList.push_back(data.stabFaultTime + data.stabFaultLength);
+ m_eventOccurrenceList.push_back(false);
+ }
+ }
+ // Switching
+ for(auto it = m_powerElementList.begin(), itEnd = m_powerElementList.end(); it != itEnd; ++it) {
+ PowerElement* element = *it;
+ SwitchingData swData = element->GetSwitchingData();
+ for(unsigned int i = 0; i < swData.swTime.size(); ++i) {
+ m_eventTimeList.push_back(swData.swTime[i]);
+ m_eventOccurrenceList.push_back(false);
+ }
+ }
+}
+
+bool Electromechanical::HasEvent(double currentTime)
+{
+ for(unsigned int i = 0; i < m_eventTimeList.size(); ++i) {
+ if(!m_eventOccurrenceList[i]) {
+ if((m_eventTimeList[i] - m_timeStep) < currentTime && m_eventTimeList[i] >= currentTime) {
+ m_eventOccurrenceList[i] = true;
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+void Electromechanical::SetEvent(double currentTime) {}
+bool Electromechanical::RunStabilityCalculation()
+{
+ // test
+ double simTime = 10.0;
+ double currentTime = 0.0;
+ while(currentTime <= simTime) {
+ if(HasEvent(currentTime)) {
+ }
+ currentTime += m_timeStep;
+ }
+ return true;
+}