Skip to content

Commit

Permalink
delete virtual nodes of SP Transformer
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Moraga <[email protected]>
  • Loading branch information
martinmoraga committed May 8, 2023
1 parent 827b59b commit 9be6dc9
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 248 deletions.
5 changes: 3 additions & 2 deletions dpsim-models/include/dpsim-models/SP/SP_Ph1_Inductor.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#pragma once

#include <dpsim-models/MNASimPowerComp.h>

#include <dpsim-models/Solver/MNATearInterface.h>
#include <dpsim-models/Base/Base_Ph1_Inductor.h>

Expand Down Expand Up @@ -50,7 +49,9 @@ namespace Ph1 {
/// MNA post step operations
void mnaCompPostStep(Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector);
/// Add MNA post step dependencies
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute<Matrix>::Ptr &leftVector);
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes,
Attribute<Matrix>::Ptr &leftVector);
//
void mnaTearApplyMatrixStamp(SparseMatrixRow& tearMatrix) override;
};
Expand Down
2 changes: 0 additions & 2 deletions dpsim-models/include/dpsim-models/SP/SP_Ph1_PiLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ namespace Ph1 {
PiLine(String name, Logger::Level logLevel = Logger::Level::off)
: PiLine(name, name, logLevel) { }
///
SimPowerComp<Complex>::Ptr clone(String copySuffix) override;
///
void setParameters(Real resistance, Real inductance, Real capacitance = -1, Real conductance = -1);
/// Initializes component from power flow data
void initializeFromNodesAndTerminals(Real frequency) override;
Expand Down
61 changes: 14 additions & 47 deletions dpsim-models/include/dpsim-models/SP/SP_Ph1_Transformer.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,22 @@

#pragma once

#include <dpsim-models/CompositePowerComp.h>
#include <dpsim-models/MNASimPowerComp.h>
#include <dpsim-models/Solver/PFSolverInterfaceBranch.h>
#include <dpsim-models/Solver/MNAInterface.h>
#include <dpsim-models/SP/SP_Ph1_Resistor.h>
#include <dpsim-models/SP/SP_Ph1_Inductor.h>
#include <dpsim-models/SP/SP_Ph1_Capacitor.h>
#include <dpsim-models/Base/Base_Ph1_Transformer.h>

namespace CPS {
namespace SP {
namespace Ph1 {
/// Transformer that includes an inductance and resistance
class Transformer :
public CompositePowerComp<Complex>,
public MNASimPowerComp<Complex>,
public Base::Ph1::Transformer,
public SharedFactory<Transformer>,
public PFSolverInterfaceBranch {

private:
/// Internal resistor to model losses
std::shared_ptr<SP::Ph1::Resistor> mSubResistor;
/// Internal inductor to model losses
std::shared_ptr<SP::Ph1::Inductor> mSubInductor;

/// Internal parallel resistance 1 as snubber
std::shared_ptr<SP::Ph1::Resistor> mSubSnubResistor1;
/// Internal parallel resistance 2 as snubber
std::shared_ptr<SP::Ph1::Resistor> mSubSnubResistor2;
/// Internal parallel capacitance 1 as snubber
std::shared_ptr<SP::Ph1::Capacitor> mSubSnubCapacitor1;
/// Internal parallel capacitance 2 as snubber
std::shared_ptr<SP::Ph1::Capacitor> mSubSnubCapacitor2;

/// Snubber resistance 1 [Ohm]
Real mSnubberResistance1;
/// Snubber resistance 2 [Ohm]
Real mSnubberResistance2;
/// Snubber capacitance 1 [F]
Real mSnubberCapacitance1;
/// Snubber capacitance 2 [F]
Real mSnubberCapacitance2;

/// Transformer ratio magnitude
Real mRatioAbs = 1;
/// Transformer ratio pase [deg]
Expand All @@ -59,8 +33,8 @@ namespace Ph1 {
/// Reactance [Ohm]
Real mReactance;

/// Leakage
Complex mLeakage;
/// Series impedance
Complex mImpedance;

/// base apparent power[VA]
Real mBaseApparentPower;
Expand Down Expand Up @@ -92,8 +66,6 @@ namespace Ph1 {
// #### Admittance matrix stamp ####
MatrixComp mY_element;

/// Boolean for considering resistive losses with sub resistor
Bool mWithResistiveLosses;
public:
/// base voltage [V]
const Attribute<Real>::Ptr mBaseVoltage;
Expand All @@ -114,13 +86,11 @@ namespace Ph1 {

/// Defines UID, name and logging level
Transformer(String uid, String name,
Logger::Level logLevel = Logger::Level::off, Bool withResistiveLosses = false);
Logger::Level logLevel = Logger::Level::off);
/// Defines name and logging level
Transformer(String name, Logger::Level logLevel = Logger::Level::off)
: Transformer(name, name, logLevel) { }

SimPowerComp<Complex>::Ptr clone(String name) override;

// #### General ####
/// Set transformer specific parameters (without rated power)
void setParameters(Real nomVoltageEnd1, Real nomVoltageEnd2, Real ratioAbs, Real ratioPhase, Real resistance, Real inductance);
Expand All @@ -147,22 +117,19 @@ namespace Ph1 {

// #### MNA Section ####
/// Initializes internal variables of the component
void mnaParentInitialize(Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) override;
void mnaCompInitialize(Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) override;
/// Stamps system matrix
void mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix) override;
/// Updates internal current variable of the component
void mnaCompUpdateCurrent(const Matrix& leftVector) override;
///
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes,
Attribute<Matrix>::Ptr &leftVector) override;
/// MNA post step operations
void mnaCompPostStep(Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector) override;
/// Updates internal voltage variable of the component
void mnaCompUpdateVoltage(const Matrix& leftVector) override;
/// MNA pre step operations
void mnaParentPreStep(Real time, Int timeStepCount) override;
/// MNA post step operations
void mnaParentPostStep(Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector) override;
/// Add MNA pre step dependencies
void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override;
/// Add MNA post step dependencies
void mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute<Matrix>::Ptr &leftVector) override;

/// Updates internal current variable of the component
void mnaCompUpdateCurrent(const Matrix& leftVector) override;
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion dpsim-models/src/SP/SP_Ph1_AvVoltageSourceInverterDQ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SP::Ph1::AvVoltageSourceInverterDQ::AvVoltageSourceInverterDQ(String uid, String
mPowerctrlStates(mAttributes->createDynamic<Matrix>("powerctrl_states")) {
if (withTrafo) {
setVirtualNodeNumber(4);
mConnectionTransformer = SP::Ph1::Transformer::make(**mName + "_trans", **mName + "_trans", mLogLevel, false);
mConnectionTransformer = SP::Ph1::Transformer::make(**mName + "_trans", **mName + "_trans", mLogLevel);
addMNASubComponent(mConnectionTransformer, MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT, MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT, true);
} else {
setVirtualNodeNumber(3);
Expand Down
4 changes: 3 additions & 1 deletion dpsim-models/src/SP/SP_Ph1_Inductor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ void SP::Ph1::Inductor::mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMat
mSLog->flush();
}

void SP::Ph1::Inductor::mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute<Matrix>::Ptr &leftVector) {
void SP::Ph1::Inductor::mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes,
Attribute<Matrix>::Ptr &leftVector) {
attributeDependencies.push_back(leftVector);
modifiedAttributes.push_back(mIntfVoltage);
modifiedAttributes.push_back(mIntfCurrent);
Expand Down
11 changes: 0 additions & 11 deletions dpsim-models/src/SP/SP_Ph1_PiLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,6 @@ void SP::Ph1::PiLine::setParameters(Real resistance, Real inductance, Real capac

}

/// DEPRECATED: Delete method
SimPowerComp<Complex>::Ptr SP::Ph1::PiLine::clone(String name) {
auto copy = PiLine::make(name, mLogLevel);
copy->setParameters(**mSeriesRes, **mSeriesInd, **mParallelCap, **mParallelCond);
return copy;
}

// #### Powerflow section ####
void SP::Ph1::PiLine::setBaseVoltage(Real baseVoltage) {
**mBaseVoltage = baseVoltage;
Expand Down Expand Up @@ -146,10 +139,6 @@ MatrixComp SP::Ph1::PiLine::Y_element() {

void SP::Ph1::PiLine::initializeFromNodesAndTerminals(Real frequency) {

// By default there is always a small conductance to ground to
// avoid problems with floating nodes.
**mParallelCond = (**mParallelCond >= 0) ? **mParallelCond : 1e-6;

// Static calculation
Real omega = 2. * PI * frequency;
Complex impedance = { **mSeriesRes, omega * **mSeriesInd };
Expand Down
Loading

0 comments on commit 9be6dc9

Please sign in to comment.