Skip to content

Commit

Permalink
move method implementations into source files pt. 2
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas Schroeder <jonas.schroeder1@rwth-aachen.de>
  • Loading branch information
JTS22 committed Oct 29, 2022
1 parent 4a22958 commit 8973cc2
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace Ph1 {
///
void setParameters(Complex voltage, Real srcFreq, Real resistance);
///
void setVoltageRef(Complex voltage) { **mVoltageRef = voltage; }
void setVoltageRef(Complex voltage);

// #### MNA section ####
/// Initializes internal variables of the component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace Ph3 {

// #### Switch specific MNA section ####
/// Check if switch is closed
Bool mnaIsClosed() { return **mIsClosed; }
Bool mnaIsClosed();
/// Stamps system matrix considering the defined switch position
void mnaApplySwitchSystemMatrixStamp(Bool closed, Matrix& systemMatrix, Int freqIdx);

Expand Down
12 changes: 6 additions & 6 deletions dpsim-models/include/dpsim-models/EMT/EMT_Ph3_Switch.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ namespace Ph3 {
/// Update interface current from MNA system result
void mnaUpdateCurrent(const Matrix& leftVector);

// #### MNA section for switches ####
/// Check if switch is closed
Bool mnaIsClosed();
/// Stamps system matrix considering the defined switch position
void mnaApplySwitchSystemMatrixStamp(Bool closed, Matrix& systemMatrix, Int freqIdx);

class MnaPostStep : public Task {
public:
MnaPostStep(Switch& switchRef, Attribute<Matrix>::Ptr leftSideVector) :
Expand All @@ -66,12 +72,6 @@ namespace Ph3 {
Switch& mSwitch;
Attribute<Matrix>::Ptr mLeftVector;
};

// #### MNA section for switches ####
/// Check if switch is closed
Bool mnaIsClosed() { return **mSwitchClosed; }
/// Stamps system matrix considering the defined switch position
void mnaApplySwitchSystemMatrixStamp(Bool closed, Matrix& systemMatrix, Int freqIdx);
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ namespace Ph3 {
Matrix dq0ToAbcTransform(Real theta, Matrix& dq0);

public:
///
const std::vector<String> attrParamNames = {"Rs", "Ll", "Ld", "Lq", "Ld_t", "Ld_s", "Lq_t", "Lq_s", "Td0_t", "Td0_s", "Tq0_t", "Tq0_s"};

virtual ~SynchronGeneratorDQ();

/// Initializes the per unit or stator referred machine parameters with the machine parameters given in per unit or
Expand Down Expand Up @@ -70,14 +73,11 @@ namespace Ph3 {
///
void initialize(Matrix frequencies);
///
Real electricalTorque() { return **mElecTorque * mBase_T; }
Real electricalTorque();
///
Real rotationalSpeed() { return **mOmMech * mBase_OmMech; }
Real rotationalSpeed();
///
Real rotorPosition() { return mThetaMech; }

///
const std::vector<String> attrParamNames = {"Rs", "Ll", "Ld", "Lq", "Ld_t", "Ld_s", "Lq_t", "Lq_s", "Td0_t", "Td0_s", "Tq0_t", "Tq0_s"};
Real rotorPosition();

/// General step function for standalone simulation
void step(Matrix& voltage, Real time);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,7 @@ namespace Ph3 {
void setInitialValues(Real initActivePower, Real initReactivePower, Real initTerminalVolt, Real initVoltAngle, Real initMechPower);

/// Initialize components with correct network frequencies
void initialize(Matrix frequencies) override {
SimPowerComp<Real>::initialize(frequencies);
}
void initialize(Matrix frequencies) override;

/// Initializes component from power flow data
void initializeFromNodesAndTerminals(Real frequency);
Expand Down Expand Up @@ -244,11 +242,11 @@ namespace Ph3 {
void CalculateAuxiliarVariables();

//Matrix& rotorFluxes() { return mRotorFlux; }
Matrix& dqStatorCurrents() { return mDqStatorCurrents; }
Real electricalTorque() { return **mElecTorque * mBase_T; }
Real rotationalSpeed() { return **mOmMech * mBase_OmMech; }
Real rotorPosition() { return mThetaMech; }
Matrix& statorCurrents() { return mIabc; }
Matrix& dqStatorCurrents();
Real electricalTorque();
Real rotationalSpeed();
Real rotorPosition();
Matrix& statorCurrents();

// #### MNA section ####
/// Stamps system matrix
Expand All @@ -264,7 +262,7 @@ namespace Ph3 {
/// Add MNA post step dependencies
void mnaAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute<Matrix>::Ptr &leftVector);
/// Mark that parameter changes so that system matrix is updated
Bool hasParameterChanged() override { return 1; };
Bool hasParameterChanged() override;

class MnaPreStep : public CPS::Task {
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace CPS {
// #### General ####
void setParameters(Complex voltageRef, Real srcFreq, Real resistance);
///
void setVoltageRef(Complex voltage) { **mVoltageRef = voltage; }
void setVoltageRef(Complex voltage);

SimPowerComp<Real>::Ptr clone(String name);
/// Initializes component from power flow data
Expand Down
2 changes: 2 additions & 0 deletions dpsim-models/src/EMT/EMT_Ph1_VoltageSourceNorton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,5 @@ void EMT::Ph1::VoltageSourceNorton::mnaUpdateCurrent(const Matrix& leftVector) {
// TODO: verify signs
(**mIntfCurrent)(0,0) = mEquivCurrent - (**mIntfVoltage)(0,0) / **mResistance;
}

void EMT::Ph1::VoltageSourceNorton:setVoltageRef(Complex voltage) { **mVoltageRef = voltage; }
2 changes: 2 additions & 0 deletions dpsim-models/src/EMT/EMT_Ph3_SeriesSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ void EMT::Ph3::SeriesSwitch::mnaInitialize(Real omega, Real timeStep, Attribute<
mMnaTasks.push_back(std::make_shared<MnaPostStep>(*this, leftVector));
}

Bool EMT::Ph3::SeriesSwitch::mnaIsClosed() { return **mIsClosed; }

void EMT::Ph3::SeriesSwitch::mnaApplySystemMatrixStamp(Matrix& systemMatrix) {
Real conductance = (**mIsClosed)
? 1. / **mClosedResistance
Expand Down
2 changes: 2 additions & 0 deletions dpsim-models/src/EMT/EMT_Ph3_Switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ void EMT::Ph3::Switch::mnaInitialize(Real omega, Real timeStep, Attribute<Matrix
mMnaTasks.push_back(std::make_shared<MnaPostStep>(*this, leftVector));
}

Bool EMT::Ph3::Switch::mnaIsClosed() { return **mSwitchClosed; }

void EMT::Ph3::Switch::mnaApplySystemMatrixStamp(Matrix& systemMatrix) {
Matrix conductance = (**mSwitchClosed) ?
(**mClosedResistance).inverse() : (**mOpenResistance).inverse();
Expand Down
6 changes: 6 additions & 0 deletions dpsim-models/src/EMT/EMT_Ph3_SynchronGeneratorDQ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ EMT::Ph3::SynchronGeneratorDQ::SynchronGeneratorDQ(String name, Logger::Level lo
EMT::Ph3::SynchronGeneratorDQ::~SynchronGeneratorDQ() {
}

Real EMT::Ph3::SynchronGeneratorDQ::electricalTorque() { return **mElecTorque * mBase_T; }

Real EMT::Ph3::SynchronGeneratorDQ::rotationalSpeed() { return **mOmMech * mBase_OmMech; }

Real EMT::Ph3::SynchronGeneratorDQ::rotorPosition() { return mThetaMech; }

void EMT::Ph3::SynchronGeneratorDQ::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,
Expand Down
16 changes: 16 additions & 0 deletions dpsim-models/src/EMT/EMT_Ph3_SynchronGeneratorVBR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ EMT::Ph3::SynchronGeneratorVBR::SynchronGeneratorVBR(String name, Logger::Level
: SynchronGeneratorVBR(name, name, logLevel) {
}

void EMT::Ph3::SynchronGeneratorVBR::initialize(Matrix frequencies) {
SimPowerComp<Real>::initialize(frequencies);
}

Matrix& EMT::Ph3::SynchronGeneratorVBR::dqStatorCurrents() { return mDqStatorCurrents; }

Real EMT::Ph3::SynchronGeneratorVBR::electricalTorque() { return **mElecTorque * mBase_T; }

Real EMT::Ph3::SynchronGeneratorVBR::rotationalSpeed() { return **mOmMech * mBase_OmMech; }

Real EMT::Ph3::SynchronGeneratorVBR::rotorPosition() { return mThetaMech; }

Matrix& EMT::Ph3::SynchronGeneratorVBR::statorCurrents() { return mIabc; }

Bool EMT::Ph3::SynchronGeneratorVBR::hasParameterChanged() { return true; }

void EMT::Ph3::SynchronGeneratorVBR::setBaseAndOperationalPerUnitParameters(
Real nomPower, Real nomVolt, Real nomFreq, Int poleNumber, Real nomFieldCur,
Real Rs, Real Ld, Real Lq, Real Ld_t, Real Lq_t, Real Ld_s, Real Lq_s,
Expand Down
2 changes: 2 additions & 0 deletions dpsim-models/src/EMT/EMT_Ph3_VoltageSourceNorton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ void EMT::Ph3::VoltageSourceNorton::setParameters(Complex voltageRef, Real srcFr
mParametersSet = true;
}

void EMT::Ph3::VoltageSourceNorton::setVoltageRef(Complex voltage) { **mVoltageRef = voltage; }

SimPowerComp<Real>::Ptr EMT::Ph3::VoltageSourceNorton::clone(String name) {
auto copy = VoltageSourceNorton::make(name, mLogLevel);
copy->setParameters(**mVoltageRef, **mSrcFreq, **mResistance);
Expand Down

0 comments on commit 8973cc2

Please sign in to comment.