Power System Platform  2026w10a-beta
Loading...
Searching...
No Matches
Electromechanical.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2017 Thales Lima Oliveira <thales@ufu.br>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#ifndef ELECTROMECHANICAL_H
19#define ELECTROMECHANICAL_H
20
21#include "ElectricCalculation.h"
22
23#include <wx/log.h>
24#include <wx/progdlg.h>
25
27
35 double xd;
37 double xq;
39 double ed;
41 double eq;
42};
43
52{
53public:
54 Electromechanical(wxWindow* parent, std::vector<Element*> elementList, SimulationData data);
56
57 bool RunStabilityCalculation();
58 wxString GetErrorMessage() const { return m_errorMsg; }
59 std::vector<double> GetTimeVector() const { return m_timeVector; }
60
61 // For tests
62 std::vector<double> GetIterationVector() const { return m_iterationsNumVector; }
63 wxString GetDebugMessage() const { return m_debugMessage; }
64
65protected:
66 void SetEventTimeList();
67 bool HasEvent(double currentTime);
68 void SetEvent(double currentTime);
69 inline bool EventTrigger(double eventTime, double currentTime);
70
71 // double GetPowerValue(double value, ElectricalUnit unit);
72
73 void InsertSyncMachinesOnYBus();
74 bool InsertIndMachinesOnYBus();
75 bool CalculateIndMachinesTransientValues(IndMotor* motor);
76 std::complex<double> GetSyncMachineAdmittance(SyncGenerator* generator);
77 std::complex<double> GetIndMachineAdmittance(IndMotor* motor);
78 bool InitializeDynamicElements();
79 bool CalculateInjectedCurrents();
80 void CalculateIntegrationConstants(SyncGenerator* syncGenerator, double id, double iq, double k = 1.0);
81 void CalculateIntegrationConstants(IndMotor* indMotor, double ir, double im, double k = 1.0);
82 bool SolveMachines();
83 void SetSyncMachinesModel();
84 SyncMachineModelData GetSyncMachineModelData(SyncGenerator* syncMachine);
85 double CalculateIntVariables(SyncGenerator* syncGenerator,
86 double id,
87 double iq,
88 double sd,
89 double sq,
90 double pe,
91 double k = 1.0);
92 double CalculateIntVariables(IndMotor* indMotor, double ir, double im, double te, double k = 1.0);
93 bool CalculateNonIntVariables(SyncGenerator* syncGenerator,
94 double& id,
95 double& iq,
96 double& sd,
97 double& sq,
98 double& pe,
99 double k = 1.0);
100 bool CalculateNonIntVariables(IndMotor* indMotor, double& ir, double& im, double& te, double k = 1.0);
101 void CalculateReferenceSpeed();
102 bool CalculateSyncMachineSaturation(SyncGenerator* syncMachine,
103 double& id,
104 double& iq,
105 double& sd,
106 double& sq,
107 bool updateCurrents = true,
108 double k = 1.0);
109 void CalculateBusesFrequency(bool hasEvent);
110
111 void SaveData();
112 void PreallocateVectors();
113
114 wxWindow* m_parent = nullptr;
115 wxString m_errorMsg = _("Unknown error");
116 SimulationData m_simData;
117
118 double m_systemFreq = 60.0;
119 double m_refSpeed = 2.0 * M_PI * 60.0;
120 bool m_useCOI = false;
121
122 std::vector<std::vector<std::complex<double> > > m_yBus;
123 std::vector<std::vector<std::complex<double> > > m_yBusU;
124 std::vector<std::vector<std::complex<double> > > m_yBusL;
125
126 std::vector<std::complex<double> > m_vBus;
127 std::vector<std::complex<double> > m_iBus;
128
129 double m_powerSystemBase = 100e6;
130 double m_simTime = 10.0;
131 double m_currentTime = 0.0;
132 double m_plotTime = 1e-2;
133 double m_timeStep = 1e-2;
134 double m_ctrlTimeStepMultiplier = 0.1;
135 double m_tolerance = 1e-8;
136 int m_maxIterations = 100;
137 double m_saturationTolerance = 1e-8;
138
139 int m_currentPoint = 0;
140
141 std::vector<double> m_eventTimeList;
142 std::vector<bool> m_eventOccurrenceList;
143
144 std::vector<double> m_timeVector;
145
146 // For tests
147 int m_iterationsNum = 0.0;
148 std::vector<double> m_iterationsNumVector;
149 wxString m_debugMessage = "";
150};
151
152#endif // ELECTROMECHANICAL_H
Solves in the time the control system. Can solve the control system directly from a ControlEditor or ...
Base class for electrical calculations providing general utility methods.
Calculates the electromechanical transient based on disturbances (e.g. system fault).
Induction motor power element.
Definition IndMotor.h:119
Synchronous generator power element.
Synchronous machine data for different models.