Power System Platform  2026w10a-beta
Loading...
Searching...
No Matches
ControlElementSolver.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 CONTROLELEMENTSOLVER_H
19#define CONTROLELEMENTSOLVER_H
20
21#include <wx/window.h>
22#include <vector>
23
25class ControlEditor;
26class ConnectionLine;
27class Constant;
28class Exponential;
29class Gain;
30class IOControl;
31class Limiter;
32class Multiplier;
33class RateLimiter;
34class Sum;
36
46{
47 public:
49 ControlElementSolver(ControlEditor* controlEditor, double timeStep = 1e-3, double integrationError = 1e-3);
51 double timeStep = 1e-3,
52 double integrationError = 1e-3,
53 wxWindow* parent = nullptr);
54 virtual ~ControlElementSolver();
55 virtual bool InitializeValues(bool startAllZero);
56 virtual void SolveNextStep();
57 virtual std::vector<double> GetSolutions() { return m_solutions; }
58 virtual double GetLastSolution() { return m_solutions[m_solutions.size() - 1]; }
59 virtual bool IsOK() const { return m_isOK; }
60 virtual wxString GetErrorMessage() { return m_failMessage; }
61 void SetSwitchStatus(bool value) { m_switchStatus = value; }
62 void SetCurrentTime(double value) { m_currentTime = value; }
63 void SetTerminalVoltage(double value) { m_terminalVoltage = value; }
64 void SetVelocity(double value) { m_velocity = value; }
65 void SetActivePower(double value) { m_activePower = value; }
66 void SetReactivePower(double value) { m_reactivePower = value; }
67 void SetInitialTerminalVoltage(double value) { m_initTerminalVoltage = value; }
68 void SetInitialMecPower(double value) { m_initMecPower = value; }
69 void SetInitialVelocity(double value) { m_initVelocity = value; }
70 void SetDeltaVelocity(double value) { m_deltaVelocity = value; }
71 void SetDeltaActivePower(double value) { m_deltaPe = value; }
72 double GetFieldVoltage() { return m_fieldVoltage; }
73 double GetMechanicalPower() { return m_mecPower; }
74 double GetVelocity() { return m_velocity; }
75 double GetActivePower() { return m_activePower; }
76 protected:
77 void Initialize(wxWindow* parent, double timeStep, double integrationError);
78 void FillAllConnectedChildren(ConnectionLine* parent);
79 ConnectionLine* SolveNextElement(ConnectionLine* currentLine);
80
81 ControlElementContainer* m_ctrlContainer = nullptr;
82 double m_timeStep = 1e-3;
83 double m_integrationError = 1e-5;
84 std::vector<double> m_solutions;
85 bool m_isOK = false;
86 wxString m_failMessage = _("Unknown error.");
87
89 IOControl* m_outputControl = nullptr;
90 // Inputs
91 bool m_switchStatus = false;
92 double m_currentTime = 0.0;
93 double m_terminalVoltage = 0.0;
94 double m_velocity = 0.0;
95 double m_activePower = 0.0;
96 double m_reactivePower = 0.0;
97 double m_initTerminalVoltage = 0.0;
98 double m_initMecPower = 0.0;
99 double m_initVelocity = 0.0;
100 double m_deltaVelocity = 0.0;
101 double m_deltaPe = 0.0;
102
103 /*
104 * m_inputToSolve[0] = Current line value;
105 * m_inputToSolve[1] = Current time;
106 * m_inputToSolve[2] = Switch status.
107 */
108 double* m_inputToSolve = nullptr;
109 // Outputs
110 double m_fieldVoltage = 0.0;
111 double m_mecPower = 0.0;
112};
113
114#endif // CONTROLELEMENTSOLVER_H
Connection between two control elements or other connection line and an element.
A control element that provides a constant value.
Definition Constant.h:37
Class that can contain all control elements. Can identify (using RTTI) the elements from a generic li...
Solves in the time the control system. Can solve the control system directly from a ControlEditor or ...
Generates an output following an exponential function.
Definition Exponential.h:33
Provide an output multiplying the input by a constant.
Definition Gain.h:37
Provides the communication with the power element.
Definition IOControl.h:43
Limits the input value by superior and inferior values.
Definition Limiter.h:33
Multiplies two inputs.
Definition Multiplier.h:33
Limits the rising and/or falling rate.
Definition RateLimiter.h:33
Sum the all inputs (can choose the input signal).
Definition Sum.h:34
Calculates the time response by a frequency domain transfer function.