blob: 85e10b4d57420d7b8c49502de4a65b3edc3a58a5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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;
}
|