DPsim
Loading...
Searching...
No Matches
PowerControllerVSI.h
Go to the documentation of this file.
1/* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
2 * EONERC, RWTH Aachen University
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7 *********************************************************************************/
8
9#pragma once
10
11#include <vector>
12
15#include <dpsim-models/Task.h>
16
17namespace CPS {
18namespace Signal {
20 public SharedFactory<PowerControllerVSI> {
21
22protected:
25
26 // Power parameters
29
30 // Power controller
36
37 // Current controller
42
51
52 // state space matrices
54 Matrix mA = Matrix::Zero(6, 6);
56 Matrix mB = Matrix::Zero(6, 6);
58 Matrix mC = Matrix::Zero(2, 6);
60 Matrix mD = Matrix::Zero(2, 6);
62 Matrix mDiscreteA = Matrix::Zero(6, 6);
63 Matrix mF2Inverse = Matrix::Zero(6, 6);
64 Matrix mTransformedB = Matrix::Zero(6, 6);
65 Matrix mInputSum = Matrix::Zero(6, 1);
66
67public:
68 // attributes of input references
74
75 // input, state and output vectors
88
89 PowerControllerVSI(String name, Logger::Level logLevel = Logger::Level::off);
90
92 void setParameters(Real Pref, Real Qref);
94 void setControllerParameters(Real Kp_powerCtrl, Real Ki_powerCtrl,
95 Real Kp_currCtrl, Real Ki_currCtrl,
96 Real Omega_cutoff);
98 void setInitialStateValues(Real pInit, Real qInit, Real phi_dInit,
99 Real phi_qInit, Real gamma_dInit,
100 Real gamma_qInit);
103 void initializeSteadyState(Real pRef, Real qRef, Real iD, Real iQ,
104 Real vSourceD, Real vSourceQ);
105
107 void initializeStateSpaceModel(Real omega, Real timeStep,
108 Attribute<Matrix>::Ptr leftVector);
111
113 void signalPreStep(Real time, Int timeStepCount);
115 void signalAddPreStepDependencies(AttributeBase::List &prevStepDependencies,
116 AttributeBase::List &attributeDependencies,
117 AttributeBase::List &modifiedAttributes);
119 void signalStep(Real time, Int timeStepCount);
121 void signalAddStepDependencies(AttributeBase::List &prevStepDependencies,
122 AttributeBase::List &attributeDependencies,
123 AttributeBase::List &modifiedAttributes);
124
126
127 class PreStep : public Task {
128 public:
129 PreStep(PowerControllerVSI &powerControllerVSI)
130 : Task(**powerControllerVSI.mName + ".PreStep"),
131 mPowerControllerVSI(powerControllerVSI) {
132 mPowerControllerVSI.signalAddPreStepDependencies(
134 }
135 void execute(Real time, Int timeStepCount) {
136 mPowerControllerVSI.signalPreStep(time, timeStepCount);
137 };
138
139 private:
140 PowerControllerVSI &mPowerControllerVSI;
141 };
142 class Step : public Task {
143 public:
144 Step(PowerControllerVSI &powerControllerVSI)
145 : Task(**powerControllerVSI.mName + ".Step"),
146 mPowerControllerVSI(powerControllerVSI) {
147 mPowerControllerVSI.signalAddStepDependencies(
149 }
150 void execute(Real time, Int timeStepCount) {
151 mPowerControllerVSI.signalStep(time, timeStepCount);
152 };
153
154 private:
155 PowerControllerVSI &mPowerControllerVSI;
156 };
157};
158} // namespace Signal
159} // namespace CPS
std::vector< Ptr > List
Definition Attribute.h:123
AttributePointer< Attribute< T > > Ptr
Definition Attribute.h:249
spdlog::level::level_enum Level
Definition Logger.h:33
PreStep(PowerControllerVSI &powerControllerVSI)
void execute(Real time, Int timeStepCount)
Step(PowerControllerVSI &powerControllerVSI)
void execute(Real time, Int timeStepCount)
Real mTimeStep
Simulation time step.
void setControllerParameters(Real Kp_powerCtrl, Real Ki_powerCtrl, Real Kp_currCtrl, Real Ki_currCtrl, Real Omega_cutoff)
Setter for parameters of control loops.
const Attribute< Matrix >::Ptr mInputPrev
Previous Input.
Matrix mDiscreteA
Cached trapezoidal factors; A and time step are constant during a run.
Matrix mD
matrix D of state space model
Matrix mC
matrix C of state space model
void setParameters(Real Pref, Real Qref)
Setter for general parameters.
void signalAddStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes)
add step dependencies
const Attribute< Real >::Ptr mVc_q
Real mPInit
initial values for states
void setInitialStateValues(Real pInit, Real qInit, Real phi_dInit, Real phi_qInit, Real gamma_dInit, Real gamma_qInit)
Setter for initial state values.
const Attribute< Real >::Ptr mIrc_q
void updateBMatrixStateSpaceModel()
Update B matrix due to its dependence on the input.
const Attribute< Matrix >::Ptr mStateCurr
Current State.
void signalStep(Real time, Int timeStepCount)
step operations
PowerControllerVSI(String name, Logger::Level logLevel=Logger::Level::off)
void initializeStateSpaceModel(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector)
Initialize vectors of state space model.
const Attribute< Real >::Ptr mVc_d
These are never explicitely set to reference anything, so the outside code is responsible for setting...
void initializeSteadyState(Real pRef, Real qRef, Real iD, Real iQ, Real vSourceD, Real vSourceQ)
void signalPreStep(Real time, Int timeStepCount)
pre step operations
const Attribute< Matrix >::Ptr mOutputCurr
Current Output.
void signalAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes)
pre step dependencies
const Attribute< Matrix >::Ptr mInputCurr
Current Input.
const Attribute< Matrix >::Ptr mStatePrev
Previous State.
Matrix mA
matrix A of state space model
const Attribute< Matrix >::Ptr mOutputPrev
Previous Output.
const Attribute< Real >::Ptr mIrc_d
Matrix mB
matrix B of state space model
SimSignalComp(String uid, String name, Logger::Level logLevel=Logger::Level::off)
std::vector< AttributeBase::Ptr > mModifiedAttributes
Definition Task.h:70
std::vector< AttributeBase::Ptr > mPrevStepDependencies
Definition Task.h:71
std::vector< AttributeBase::Ptr > mAttributeDependencies
Definition Task.h:69
Task()
Definition Task.h:30
std::vector< Ptr > List
Definition Task.h:28
std::string mName
Definition Task.h:68
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > Matrix
Dense matrix for real numbers.
Definition Definitions.h:79
std::string String
Definition Definitions.h:63
double Real
Definition Definitions.h:60
int Int
Definition Definitions.h:59
bool Bool
Definition Definitions.h:62