DPsim
EMT_Ph3_NetworkInjection.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/CompositePowerComp.h>
12 #include <dpsim-models/EMT/EMT_Ph3_VoltageSource.h>
13 #include <dpsim-models/Solver/MNAInterface.h>
14 
15 namespace CPS {
16 namespace EMT {
17 namespace Ph3 {
21 class NetworkInjection : public CompositePowerComp<Real>,
22  public SharedFactory<NetworkInjection> {
23 private:
24  // ### Electrical Subcomponents ###
26  std::shared_ptr<EMT::Ph3::VoltageSource> mSubVoltageSource;
27 
28  // #### solver ####
30  std::vector<const Matrix *> mRightVectorStamps;
31 
32 public:
33  const CPS::Attribute<MatrixComp>::Ptr mVoltageRef;
34  const CPS::Attribute<Real>::Ptr mSrcFreq;
35 
37  NetworkInjection(String uid, String name,
38  Logger::Level loglevel = Logger::Level::off);
40  NetworkInjection(String name, Logger::Level logLevel = Logger::Level::off)
41  : NetworkInjection(name, name, logLevel) {}
43  NetworkInjection(String name, Complex voltage,
44  Logger::Level logLevel = Logger::Level::off);
46  SimPowerComp<Real>::Ptr clone(String name) override;
47 
48  // #### General ####
50  void initializeFromNodesAndTerminals(Real frequency) override;
52  void setParameters(MatrixComp voltageRef, Real srcFreq = 50.0);
54  void setParameters(MatrixComp voltageRef, Real freqStart, Real rocof,
55  Real timeStart, Real duration, bool smoothRamp = true);
57  void setParameters(MatrixComp voltageRef, Real modulationFrequency,
58  Real modulationAmplitude, Real baseFrequency = 50.0,
59  bool zigzag = false);
60 
61  // #### MNA Section ####
63  void mnaParentApplyRightSideVectorStamp(Matrix &rightVector) override;
65  void mnaCompUpdateCurrent(const Matrix &leftVector) override;
67  void mnaCompUpdateVoltage(const Matrix &leftVector) override;
69  void mnaParentPreStep(Real time, Int timeStepCount) override;
71  void mnaParentPostStep(Real time, Int timeStepCount,
72  Attribute<Matrix>::Ptr &leftVector) override;
75  AttributeBase::List &prevStepDependencies,
76  AttributeBase::List &attributeDependencies,
77  AttributeBase::List &modifiedAttributes) override;
79  void
80  mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
81  AttributeBase::List &attributeDependencies,
82  AttributeBase::List &modifiedAttributes,
83  Attribute<Matrix>::Ptr &leftVector) override;
84 };
85 } // namespace Ph3
86 } // namespace EMT
87 } // namespace CPS
Base class for composite power components.
void mnaParentApplyRightSideVectorStamp(Matrix &rightVector) override
Stamps right side (source) vector.
void setParameters(MatrixComp voltageRef, Real srcFreq=50.0)
Setter for reference voltage parameters.
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Updates voltage across component.
NetworkInjection(String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name, component parameters and logging level.
void mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
void initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Returns current through the component.
NetworkInjection(String name, Complex voltage, Logger::Level logLevel=Logger::Level::off)
Defines name, component parameters and logging level.
void mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA post step operations.
SimPowerComp< Real >::Ptr clone(String name) override
Returns a modified copy of the component with the given suffix added to the name and without.
void mnaParentPreStep(Real time, Int timeStepCount) override
MNA pre step operations.
void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
Add MNA pre step dependencies.
NetworkInjection(String uid, String name, Logger::Level loglevel=Logger::Level::off)
Defines UID, name, component parameters and logging level.
String uid()
Returns unique id.
Base class for all components that are transmitting power.
Definition: SimPowerComp.h:17