DPsim
EMT_Ph3_CurrentSource.h
1 /* Copyright 2017-2020 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 #pragma once
9 
10 #include <dpsim-models/MNASimPowerComp.h>
11 #include <dpsim-models/Signal/CosineFMGenerator.h>
12 #include <dpsim-models/Signal/FrequencyRampGenerator.h>
13 #include <dpsim-models/Signal/SignalGenerator.h>
14 #include <dpsim-models/Signal/SineWaveGenerator.h>
15 #include <dpsim-models/Solver/MNAInterface.h>
16 
17 namespace CPS {
18 namespace EMT {
19 namespace Ph3 {
24 class CurrentSource : public MNASimPowerComp<Real>,
25  public SharedFactory<CurrentSource> {
26 private:
28  CPS::Signal::SignalGenerator::Ptr mSrcSig;
29 
30 protected:
31  // Updates current according to reference phasor and frequency
32  void updateCurrent(Real time);
33 
34 public:
35  const Attribute<MatrixComp>::Ptr mCurrentRef;
36  const Attribute<Real>::Ptr mSrcFreq;
37  const Attribute<Complex>::Ptr mSigOut;
38 
40  CurrentSource(String uid, String name,
41  Logger::Level logLevel = Logger::Level::off);
43  CurrentSource(String name, Logger::Level logLevel = Logger::Level::off)
44  : CurrentSource(name, name, logLevel) {}
45 
46  SimPowerComp<Real>::Ptr clone(String name) override;
47  // #### General ####
49  void initializeFromNodesAndTerminals(Real frequency) override;
51  void setParameters(MatrixComp currentRef, Real srcFreq = 50.0);
53  void setParameters(MatrixComp currentRef, Real freqStart, Real rocof,
54  Real timeStart, Real duration, bool smoothRamp = true);
56  void setParameters(MatrixComp currentRef, Real modulationFrequency,
57  Real modulationAmplitude, Real baseFrequency = 50.0,
58  bool zigzag = false);
59 
60  // #### MNA section ####
62  void mnaCompInitialize(Real omega, Real timeStep,
63  Attribute<Matrix>::Ptr leftVector) override;
65  void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override;
67  void mnaCompUpdateVoltage(const Matrix &leftVector) override;
69  void mnaCompPreStep(Real time, Int timeStepCount) override;
71  void mnaCompPostStep(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  mnaCompAddPostStepDependencies(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
Ideal current source model.
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Returns voltage through the component.
CurrentSource(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and logging level.
void setParameters(MatrixComp currentRef, Real srcFreq=50.0)
Setter for reference current.
void setParameters(MatrixComp currentRef, Real modulationFrequency, Real modulationAmplitude, Real baseFrequency=50.0, bool zigzag=false)
Setter for reference signal of type cosine frequency modulation.
void setParameters(MatrixComp currentRef, Real freqStart, Real rocof, Real timeStart, Real duration, bool smoothRamp=true)
Setter for reference signal of type frequency ramp.
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override
Stamps right side (source) vector.
void initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
void mnaCompAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
Add MNA pre step dependencies.
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 mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
Initializes internal variables of the component.
void mnaCompPreStep(Real time, Int timeStepCount) override
MNA pre step operations.
void mnaCompPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA post step operations.
String uid()
Returns unique id.
Base class for all MNA components that are transmitting power.
Base class for all components that are transmitting power.
Definition: SimPowerComp.h:17