summaryrefslogtreecommitdiffstats
path: root/Project/Electromechanical.h
blob: 808b9366a9ae20fcf65e1dafebdba4715d8aa3ea (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
60
61
62
#ifndef ELECTROMECHANICAL_H
#define ELECTROMECHANICAL_H

#include "ElectricCalculation.h"

#include <wx/progdlg.h>

class ControlElementSolver;

class Electromechanical : public ElectricCalculation
{
   public:
    Electromechanical(wxWindow* parent, std::vector<Element*> elementList);
    ~Electromechanical();

    bool RunStabilityCalculation();
    wxString GetErrorMessage() const { return m_errorMsg; }
    
    std::vector<double> GetTimeVector() const { return m_timeVector; }
    
   protected:
    void SetEventTimeList();
    bool HasEvent(double currentTime);
    void SetEvent(double currentTime);
    inline bool EventTrigger(double eventTime, double currentTime);
    
    double GetPowerValue(double value, ElectricalUnit unit);

    void InsertSyncMachinesOnYBus();
    std::complex<double> GetSyncMachineAdmittance(SyncGenerator* generator);
    bool InitializeDynamicElements();
    void CalculateMachinesCurrents();
    void CalculateIntegrationConstants(SyncGenerator* syncGenerator, double id, double iq);
    bool SolveSynchronousMachines();
    
    void SaveData();

    wxWindow* m_parent = NULL;
    wxString m_errorMsg = _("Unknown error");
    
    double m_systemFreq = 60.0;
    
    std::vector<std::vector<std::complex<double> > > m_yBus;
    std::vector<std::vector<std::complex<double> > > m_yBusU;
    std::vector<std::vector<std::complex<double> > > m_yBusL;
    
    std::vector<std::complex<double> > m_vBus;
    std::vector<std::complex<double> > m_iBus;
    
    double m_powerSystemBase = 100e6;

    double m_timeStep = 1e-3;
    double m_tolerance = 1e-6;
    int m_maxIterations = 100;

    std::vector<double> m_eventTimeList;
    std::vector<bool> m_eventOccurrenceList;
    
    std::vector<double> m_timeVector;
};

#endif  // ELECTROMECHANICAL_H