Skip to content

Commit

Permalink
Method implementations and declaration adjustments for EMT::Ph3::Curr…
Browse files Browse the repository at this point in the history
…entSource class

+ add implementation of "setParameters(MatrixComp currentRef, Real srcFreq = 50.0)" method in "EMT_Ph3_CurrentSource.h". Arguments are reference current (complex static phasor, amplitude and initial angle) and frequency

* rename "voltageRef" parameters to "currentRef" in all "setParameters()" method declarations in "EMT_Ph3_CurrentSource.h"
* update "clone()" method to use the newly implemented "setParameters()" method in "EMT_Ph3_CurrentSource.cpp"

Signed-off-by: Marvin Tollnitsch <marvin.tollnitsch@rwth-aachen.de>
  • Loading branch information
MarvinTollnitschRWTH committed Sep 28, 2024
1 parent 236811d commit 4844d8d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
8 changes: 4 additions & 4 deletions dpsim-models/include/dpsim-models/EMT/EMT_Ph3_CurrentSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ class CurrentSource : public MNASimPowerComp<Real>,
// #### General ####
/// Initializes component from power flow data
void initializeFromNodesAndTerminals(Real frequency) override;
/// Setter for reference voltage
void setParameters(MatrixComp voltageRef, Real srcFreq = 50.0);
/// Setter for reference current
void setParameters(MatrixComp currentRef, Real srcFreq = 50.0);
/// Setter for reference signal of type frequency ramp
void setParameters(MatrixComp voltageRef, Real freqStart, Real rocof,
void setParameters(MatrixComp currentRef, Real freqStart, Real rocof,
Real timeStart, Real duration, bool smoothRamp = true);
/// Setter for reference signal of type cosine frequency modulation
void setParameters(MatrixComp voltageRef, Real modulationFrequency,
void setParameters(MatrixComp currentRef, Real modulationFrequency,
Real modulationAmplitude, Real baseFrequency = 50.0,
bool zigzag = false);

Expand Down
33 changes: 25 additions & 8 deletions dpsim-models/src/EMT/EMT_Ph3_CurrentSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,30 @@ EMT::Ph3::CurrentSource::CurrentSource(String uid, String name,
**mIntfVoltage = Matrix::Zero(3, 1);
**mIntfCurrent = Matrix::Zero(3, 1);
}
SimPowerComp<Real>::Ptr EMT::Ph3::CurrentSource::clone(String name) {
auto copy = CurrentSource::make(name, mLogLevel);
copy->setParameters(attributeTyped<MatrixComp>("I_ref")->get(),
attributeTyped<Real>("f_src")->get());
return copy;
}

void EMT::Ph3::CurrentSource::setParameters(MatrixComp currentRef,
Real srcFreq) {
auto srcSigSine = Signal::SineWaveGenerator::make(**mName + "_sw");
// Complex(1,0) is used as initialPhasor for signal generator as only phase is used
srcSigSine->setParameters(Complex(1, 0), srcFreq);
mSrcSig = srcSigSine;

**mCurrentRef = currentRef;
mSrcFreq->setReference(mSrcSig->mFreq);

mSLog->info("\nCurrent reference phasor [I]: {:s}"
"\nFrequency [Hz]: {:s}",
Logger::matrixCompToString(currentRef),
Logger::realToString(srcFreq));

mParametersSet = true;
}

void EMT::Ph3::CurrentSource::initializeFromNodesAndTerminals(Real frequency) {
SPDLOG_LOGGER_INFO(
Expand Down Expand Up @@ -70,13 +94,6 @@ void EMT::Ph3::CurrentSource::initializeFromNodesAndTerminals(Real frequency) {
mSLog->flush();
}

SimPowerComp<Real>::Ptr EMT::Ph3::CurrentSource::clone(String name) {
auto copy = CurrentSource::make(name, mLogLevel);
// TODO: implement setParameters
// copy->setParameters(attributeTyped<MatrixComp>("I_ref")->get(), attributeTyped<Real>("f_src")->get());
return copy;
}

void EMT::Ph3::CurrentSource::mnaCompInitialize(
Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
updateMatrixNodeIndices();
Expand Down Expand Up @@ -167,4 +184,4 @@ void EMT::Ph3::CurrentSource::mnaCompUpdateVoltage(const Matrix &leftVector) {
(**mIntfVoltage)(2, 0) -
Math::realFromVectorElement(leftVector, matrixNodeIndex(0, 2));
}
}
}

0 comments on commit 4844d8d

Please sign in to comment.