DPsim
DP_Ph3_SynchronGeneratorDQ.h
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 <dpsim-models/Base/Base_SynchronGenerator.h>
12 #include <dpsim-models/MNASimPowerComp.h>
13 #include <dpsim-models/Solver/MNAInterface.h>
14 
15 namespace CPS {
16 namespace DP {
17 namespace Ph3 {
19 class SynchronGeneratorDQ : public MNASimPowerComp<Complex>,
21 protected:
24 
26  SynchronGeneratorDQ(String name, String uid,
27  Logger::Level logLevel = Logger::Level::off);
29  SynchronGeneratorDQ(String name, Logger::Level logLevel = Logger::Level::off);
30 
34  Matrix abcToDq0Transform(Real theta, MatrixComp &abc);
35 
39  MatrixComp dq0ToAbcTransform(Real theta, Matrix &dq0);
40 
41  // #### Deprecated ###
43  void trapezoidalFluxStates();
44  // calculate current states using trapezoidal rule - depcrecated
45  void trapezoidalCurrentStates();
46 
47 public:
48  virtual ~SynchronGeneratorDQ();
49 
54  Real nomPower, Real nomVolt, Real nomFreq, Int poleNumber,
55  Real nomFieldCur, Real Rs, Real Ll, Real Lmd, Real Lmq, Real Rfd,
56  Real Llfd, Real Rkd, Real Llkd, Real Rkq1, Real Llkq1, Real Rkq2,
57  Real Llkq2, Real inertia, Real initActivePower, Real initReactivePower,
58  Real initTerminalVolt, Real initVoltAngle, Real initMechPower);
59 
62  void initialize(Real omega, Real timeStep);
64  void initialize(Matrix frequencies) override;
66  Real electricalTorque() const;
68  Real rotationalSpeed() const;
70  Real rotorPosition() const;
72  void step(MatrixComp &voltage, Real time);
73 
74  // #### MNA Functions ####
76  virtual void
77  mnaCompInitialize(Real omega, Real timeStep,
78  Attribute<Matrix>::Ptr leftVector) override = 0;
81  void mnaStep(Matrix &systemMatrix, Matrix &rightVector, Matrix &leftVector,
82  Real time);
84  void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override;
86  void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override;
87 
89  virtual void mnaCompUpdateVoltage(const Matrix &leftVector) override;
90 
92  void
93  mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
94  AttributeBase::List &attributeDependencies,
95  AttributeBase::List &modifiedAttributes,
96  Attribute<Matrix>::Ptr &leftVector) override;
97  void mnaCompPostStep(Real time, Int timeStepCount,
98  Attribute<Matrix>::Ptr &leftVector) override;
99 };
100 } // namespace Ph3
101 } // namespace DP
102 } // namespace CPS
Base synchronous generator model.
Synchronous generator model in dq-reference frame.
void step(MatrixComp &voltage, Real time)
Calculates flux and current from the voltage vector.
void initialize(Real omega, Real timeStep)
SynchronGeneratorDQ(String name, String uid, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and logging level.
void trapezoidalFluxStates()
calculate flux states using trapezoidal rule - depcrecated
virtual void mnaCompUpdateVoltage(const Matrix &leftVector) override
Retrieves calculated voltage from simulation for next step.
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
Matrix abcToDq0Transform(Real theta, MatrixComp &abc)
Park transform as described in Krause.
virtual void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override=0
Initializes variables of component.
void mnaStep(Matrix &systemMatrix, Matrix &rightVector, Matrix &leftVector, Real time)
MatrixComp mCompensationCurrent
Compensation current source set point.
void setParametersFundamentalPerUnit(Real nomPower, Real nomVolt, Real nomFreq, Int poleNumber, Real nomFieldCur, Real Rs, Real Ll, Real Lmd, Real Lmq, Real Rfd, Real Llfd, Real Rkd, Real Llkd, Real Rkq1, Real Llkq1, Real Rkq2, Real Llkq2, Real inertia, Real initActivePower, Real initReactivePower, Real initTerminalVolt, Real initVoltAngle, Real initMechPower)
MatrixComp dq0ToAbcTransform(Real theta, Matrix &dq0)
Inverse Park transform as described in Krause.
String uid()
Returns unique id.
Base class for all MNA components that are transmitting power.