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
50
51 // state space matrices
53 Matrix mA = Matrix::Zero(6, 6);
55 Matrix mB = Matrix::Zero(6, 6);
57 Matrix mC = Matrix::Zero(2, 6);
59 Matrix mD = Matrix::Zero(2, 6);
60
61public:
62 // attributes of input references
68
69 // input, state and output vectors
82
83 PowerControllerVSI(String name, Logger::Level logLevel = Logger::Level::off);
84
86 void setParameters(Real Pref, Real Qref);
88 void setControllerParameters(Real Kp_powerCtrl, Real Ki_powerCtrl,
89 Real Kp_currCtrl, Real Ki_currCtrl,
90 Real Omega_cutoff);
92 void setInitialStateValues(Real pInit, Real qInit, Real phi_dInit,
93 Real phi_qInit, Real gamma_dInit,
94 Real gamma_qInit);
95
97 void initializeStateSpaceModel(Real omega, Real timeStep,
98 Attribute<Matrix>::Ptr leftVector);
101
103 void signalPreStep(Real time, Int timeStepCount);
105 void signalAddPreStepDependencies(AttributeBase::List &prevStepDependencies,
106 AttributeBase::List &attributeDependencies,
107 AttributeBase::List &modifiedAttributes);
109 void signalStep(Real time, Int timeStepCount);
111 void signalAddStepDependencies(AttributeBase::List &prevStepDependencies,
112 AttributeBase::List &attributeDependencies,
113 AttributeBase::List &modifiedAttributes);
114
116
117 class PreStep : public Task {
118 public:
119 PreStep(PowerControllerVSI &powerControllerVSI)
120 : Task(**powerControllerVSI.mName + ".PreStep"),
121 mPowerControllerVSI(powerControllerVSI) {
122 mPowerControllerVSI.signalAddPreStepDependencies(
124 }
125 void execute(Real time, Int timeStepCount) {
126 mPowerControllerVSI.signalPreStep(time, timeStepCount);
127 };
128
129 private:
130 PowerControllerVSI &mPowerControllerVSI;
131 };
132 class Step : public Task {
133 public:
134 Step(PowerControllerVSI &powerControllerVSI)
135 : Task(**powerControllerVSI.mName + ".Step"),
136 mPowerControllerVSI(powerControllerVSI) {
137 mPowerControllerVSI.signalAddStepDependencies(
139 }
140 void execute(Real time, Int timeStepCount) {
141 mPowerControllerVSI.signalStep(time, timeStepCount);
142 };
143
144 private:
145 PowerControllerVSI &mPowerControllerVSI;
146 };
147};
148} // namespace Signal
149} // namespace CPS
std::vector< Ptr > List
Definition Attribute.h:123
AttributePointer< Attribute< T > > Ptr
Definition Attribute.h:250
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 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 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:53
std::vector< AttributeBase::Ptr > mPrevStepDependencies
Definition Task.h:54
std::vector< AttributeBase::Ptr > mAttributeDependencies
Definition Task.h:52
Task()
Definition Task.h:30
std::vector< Ptr > List
Definition Task.h:28
std::string mName
Definition Task.h:51
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > Matrix
Dense matrix for real numbers.
Definition Definitions.h:81
std::string String
Definition Definitions.h:65
double Real
Definition Definitions.h:62
int Int
Definition Definitions.h:61