DPsim
EMT_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 EMT {
17 namespace Ph3 {
19 class SynchronGeneratorDQ : public MNASimPowerComp<Real>,
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, Matrix &abc);
35 
39  Matrix dq0ToAbcTransform(Real theta, Matrix &dq0);
40 
41 public:
43  const std::vector<String> attrParamNames = {
44  "Rs", "Ll", "Ld", "Lq", "Ld_t", "Ld_s",
45  "Lq_t", "Lq_s", "Td0_t", "Td0_s", "Tq0_t", "Tq0_s"};
46 
47  virtual ~SynchronGeneratorDQ();
48 
53  Real nomPower, Real nomVolt, Real nomFreq, Int poleNumber,
54  Real nomFieldCur, Real Rs, Real Ll, Real Lmd, Real Lmq, Real Rfd,
55  Real Llfd, Real Rkd, Real Llkd, Real Rkq1, Real Llkq1, Real Rkq2,
56  Real Llkq2, Real inertia, Real initActivePower, Real initReactivePower,
57  Real initTerminalVolt, Real initVoltAngle, Real initMechPower);
58 
60  void setParametersOperationalPerUnit(Real nomPower, Real nomVolt,
61  Real nomFreq, Int poleNumber,
62  Real nomFieldCur, Real Rs, Real Ld,
63  Real Lq, Real Ld_t, Real Lq_t, Real Ld_s,
64  Real Lq_s, Real Ll, Real Td0_t,
65  Real Tq0_t, Real Td0_s, Real Tq0_s,
66  Real inertia);
67 
69  void setInitialValues(Real initActivePower, Real initReactivePower,
70  Real initTerminalVolt, Real initVoltAngle,
71  Real initMechPower);
72 
75 
77  void initializeFromNodesAndTerminals(Real frequency) override;
80 
82  void initialize(Matrix frequencies) override;
84  Real electricalTorque() const;
86  Real rotationalSpeed() const;
88  Real rotorPosition() const;
89 
91  void step(Matrix &voltage, Real time);
92 
93  // #### MNA Functions ####
94 
96  void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override;
98  void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override;
99 
101  virtual void mnaCompUpdateVoltage(const Matrix &leftVector) override;
102  void mnaCompPostStep(Real time, Int timeStepCount,
103  Attribute<Matrix>::Ptr &leftVector) override;
104 
106  void
107  mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
108  AttributeBase::List &attributeDependencies,
109  AttributeBase::List &modifiedAttributes,
110  Attribute<Matrix>::Ptr &leftVector) override;
111 };
112 } // namespace Ph3
113 } // namespace EMT
114 } // namespace CPS
Base synchronous generator model.
Synchronous generator model in dq-reference frame.
void initialize(Matrix frequencies) override
Initialize components with correct network frequencies.
Matrix dq0ToAbcTransform(Real theta, Matrix &dq0)
Inverse Park transform as described in Krause.
virtual void mnaCompUpdateVoltage(const Matrix &leftVector) override
Retrieves calculated voltage from simulation for next step.
void applyParametersOperationalPerUnit()
Calculates fundamental from operational parameters and applies them to the model.
void initializeMatrixAndStates()
Initializes internal states and matrix.
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
void setInitialValues(Real initActivePower, Real initReactivePower, Real initTerminalVolt, Real initVoltAngle, Real initMechPower)
Initialize states according to desired initial electrical powerflow and mechanical input power.
Matrix 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)
Matrix abcToDq0Transform(Real theta, Matrix &abc)
Park transform as described in Krause.
void initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
void step(Matrix &voltage, Real time)
General step function for standalone simulation.
SynchronGeneratorDQ(String name, String uid, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and logging level.
String uid()
Returns unique id.
Base class for all MNA components that are transmitting power.