diff --git a/docs/hugo/content/en/docs/Models/RLC-Elements/index.md b/docs/hugo/content/en/docs/Models/RLC-Elements/index.md
index e9bfbc8ea8..3d0ca55644 100644
--- a/docs/hugo/content/en/docs/Models/RLC-Elements/index.md
+++ b/docs/hugo/content/en/docs/Models/RLC-Elements/index.md
@@ -169,5 +169,5 @@ $$
a = \frac{\Delta t}{2L}, \qquad b = \frac{\Delta t \omega}{2}
$$
$$
- \langle i_{equiv} \rangle(k-1) = \frac{1 - b^2 - j2b + 2Ra + (Ra)^2 - j2Rab}{(1+Ra^2) + b^2} \langle i \rangle(k-1) + \frac{a + Ra^2 - jab}{(1+Ra)^2 + b^2} \langle v \rangle(k-1)
+ \langle i_{equiv} \rangle(k-1) = \frac{1 - b^2 - j2b - (Ra)^2}{(1+Ra)^2 + b^2} \langle i \rangle(k-1) + \frac{a + Ra^2 - jab}{(1+Ra)^2 + b^2} \langle v \rangle(k-1)
$$
\ No newline at end of file
diff --git a/docs/hugo/content/en/docs/Models/Transformer/RL-Element.svg b/docs/hugo/content/en/docs/Models/Transformer/RL-Element.svg
new file mode 100644
index 0000000000..bb15256a8d
--- /dev/null
+++ b/docs/hugo/content/en/docs/Models/Transformer/RL-Element.svg
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/docs/hugo/content/en/docs/Models/Transformer/Transformer.svg b/docs/hugo/content/en/docs/Models/Transformer/Transformer.svg
new file mode 100644
index 0000000000..1f7b6ee8de
--- /dev/null
+++ b/docs/hugo/content/en/docs/Models/Transformer/Transformer.svg
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/docs/hugo/content/en/docs/Models/Transformer/electrical_transformer.svg b/docs/hugo/content/en/docs/Models/Transformer/electrical_transformer.svg
deleted file mode 100644
index 981d502c88..0000000000
--- a/docs/hugo/content/en/docs/Models/Transformer/electrical_transformer.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/docs/hugo/content/en/docs/Models/Transformer/index.md b/docs/hugo/content/en/docs/Models/Transformer/index.md
index 4414883c63..190e4c41af 100644
--- a/docs/hugo/content/en/docs/Models/Transformer/index.md
+++ b/docs/hugo/content/en/docs/Models/Transformer/index.md
@@ -1,42 +1,176 @@
---
title: "Transformer"
linkTitle: "Transformer"
-date: 2021-07-22
+date: 2023-06-09
---
-## 2-Winding Transformer
-The transformer model is composed of an RL-segment and an ideal transformer.
-The single line diagram is depicted in the figure below.
+## 2-Winding Power Transformer
+The power transformer in DPsim based on the RL-element which is depicted in the Fig. 1.
-![Transformer](electrical_transformer.svg)
+
+
+ Fig.1 - RL Element
+
-If node reduction is not applied, two virtual nodes are created to stamp this model into the system matrix.
+An RL-element in the time domain is described by
-Furthermore, the ideal transformer has an additional equation, which requires an extension of the system matrix.
-The complete matrix stamp for the ideal transformer is
+```math
+v = L \frac{\mathrm{d} i(t)}{dt} + Ri(t)
+```
+
+```math
+i(t) = i(t-\Delta t) + \frac{1}{L} \int_{t - \Delta t}^{t} v(\tau) - R i(\tau)\ \mathrm{d} \tau
+```
+
+Applying the trapezoidal rule leads to the following algebraic equation:
+
+```math
+i(k) = G_{eq} v(k) + i_{eq}(k)
+```
+
+with
+
+```math
+a = \frac{\Delta t R}{2L}, \quad b=\frac{\Delta t}{2L} \quad \textrm{and} \quad G_{eq} = \frac{b}{1+a}
+```
+
+and
+
+```math
+i_{eq}(k) = \frac{1-a}{1+a} i(k-1) + \frac{b}{1+a} v (k-1)
+```
+
+
+
+ Fig.2 - Equivalent circuit Power transformer
+
+
+To apply this to the power transformer depicted in Fig. 2, the equations of the ideal transformer have to be considered:
+
+```math
+v(t) = v_{n0}(t) - v_{n1}^{'}(t) = v_{n0}(t) - nv_{n1}(t)
+```
+
+```math
+i(t) = \frac{i_{sec}(t)}{n}
+```
+
+so that the discretized equation for the RL-element becomes:
+
+```math
+i(k) = G_{eq} v_{n0}(k) - n G_{eq} v_{n1}(k) + i_{eq}(k)
+```
+
+with
+
+```math
+i_{eq}(k) = \frac{1-a}{1+a} i(k-1) + \frac{b}{1+a} (v_{n0}(k-1) - n v_{n1}(k-1))
+```
+
+Extending to 3 phase with the following assumptions:
+1. Symmetrical components
+2. No mutual impedances between the phases
+
+the equation system of the power transformer becomes:
```math
-\begin{array}{c|c c c}
- ~ & j & k & l \cr
- \hline
- j & & & -1 \cr
- k & & & T \cr
- l & 1 & -T & 0
-\end{array}
\begin{pmatrix}
-v_j \cr
-v_k \cr
-i_{l} \cr
+i_{a} (k) \cr
+i_{b} (k) \cr
+i_{c} (k) \cr
+i_{a, sec} (k) \cr
+i_{b, sec} (k) \cr
+i_{c, sec} (k) \cr
\end{pmatrix}
=
\begin{pmatrix}
- \cr
- \cr
- 0\cr
+ G_{eq} & 0 & 0 & -n G_{eq} & 0 & 0 \cr
+ 0 & G_{eq} & 0 & 0 & -n G_{eq} & 0 \cr
+ 0 & 0 & G_{eq} & 0 & 0 & -n G_{eq} \cr
+ n G_{eq} & 0 & 0 & -n^{2} G_{eq} & 0 & 0 \cr
+ 0 & n G_{eq} & 0 & 0 & -n^{2} G_{eq} & 0 \cr
+ 0 & 0 & n G_{eq} & 0 & 0 & -n^{2} G_{eq} \cr
\end{pmatrix}
+*
+\begin{pmatrix}
+v_{n0a} (k) \cr
+v_{n0b} (k) \cr
+v_{n0c} (k) \cr
+v_{n1a} (k) \cr
+v_{n1b} (k) \cr
+v_{n1c} (k) \cr
+\end{pmatrix} +
+\begin{pmatrix}
+i_{eq,a} (k) \cr
+i_{eq,b} (k) \cr
+i_{eq,c} (k) \cr
+n i_{eq,a} (k) \cr
+n i_{eq,b} (k) \cr
+n i_{eq,c} (k) \cr
+\end{pmatrix}
+```
+
+
+## Extension with Dynamic Phasors
+The RL-element in the DP domain is described by
+
+$$
+ \frac{\mathrm{d} \langle i \rangle (t)}{\mathrm{d}t} + j\omega \cdot \langle i \rangle (t) = \frac{\langle v \rangle (t) - R \cdot \langle i \rangle (t)}{L}
+$$
+
+Applying the trapezoidal method leads to the following algebraic equations
+```math
+\langle i \rangle (k)= \frac{(1-b^2 - (a*R)^2 -j*2b) }{(1+a*R)^2+b^2} \cdot \langle i \rangle(k-1) + \frac{a+a^2*R - j *ab}{(1+aR)^2 + b^2} \cdot ( \langle v \rangle (k) + \langle v \rangle(k-1))
+```
+with
+```math
+a = \frac{\Delta t}{2L}, \qquad b = \frac{\Delta t \omega}{2}
+```
+
+Analog to the EMT model to apply this to the power transformer depicted in Fig. 2, the equations of the ideal transformer have to be considered:
+
+```math
+\langle v \rangle (k) = \langle v_{n0} \rangle (k) - \langle v_{n1}^{'} \rangle (k), \qquad \langle v_{n1}^{'} \rangle (k) = n \langle v_{n1} \rangle (k)
+```
+
+```math
+\langle i \rangle (k) = n \langle i_{sec} \rangle (k)
+```
+so that the discretized equation for the RL-element becomes:
+```math
+\langle i \rangle (k) = Y_{eq} (\langle v_{n0} \rangle (k) - n \langle v_{n1} \rangle (k)) + \langle i_{eq} \rangle (k)
```
-The variable $j$ denotes the high voltage node while $k$ is the low voltage node.
-$l$ indicates the inserted row and column to accommodate the relation between the two voltages at the ends of the transformer.
-The transformer ratio is defined as $T = V_{j} / V_{k}$.
-A phase shift can be introduced if $T$ is considered as a complex number.
\ No newline at end of file
+where:
+
+```math
+Y_{eq} = \frac{a+a^{2}R - jab}{(1+aR)^{2} + b^{2}}
+```
+and
+
+```math
+\langle i_{eq} \rangle (k) = \frac{(1-b^{2} - (aR)^{2} -j2b) }{(1+aR)^{2}+b^{2}} \langle i \rangle(k-1) + \frac{a+a^{2}R - jab}{(1+aR)^{2} + b^{2}} \langle v \rangle(k-1)
+```
+
+Finally, the equation systems for the power transformer in the DP model is given by:
+
+```math
+\begin{pmatrix}
+\langle i \rangle (k) \cr
+\langle i_{sec} \rangle (k) \cr
+\end{pmatrix}
+=
+\begin{pmatrix}
+ Y_{eq} & -nY_{eq}\cr
+ nY_{eq} & -n^{2} Y_{eq} \cr
+\end{pmatrix}
+*
+\begin{pmatrix}
+\langle v_{n0} \rangle (k) \cr
+\langle v_{n1} \rangle (k) \cr
+\end{pmatrix} +
+\begin{pmatrix}
+\langle i_{eq} \rangle (k) \cr
+\langle n i_{eq} \rangle (k) \cr
+\end{pmatrix}
+```
diff --git a/dpsim-models/include/dpsim-models/Base/Base_Ph3_Transformer.h b/dpsim-models/include/dpsim-models/Base/Base_Ph3_Transformer.h
index b072d2b0e9..b5271dbd2f 100644
--- a/dpsim-models/include/dpsim-models/Base/Base_Ph3_Transformer.h
+++ b/dpsim-models/include/dpsim-models/Base/Base_Ph3_Transformer.h
@@ -20,8 +20,6 @@ namespace Ph3 {
Real mNominalVoltageEnd1;
/// Nominal voltage of secondary side
Real mNominalVoltageEnd2;
- /// Rated Apparent Power [VA]
- Real mRatedPower;
/// Resistance [Ohm]
Matrix mResistance;
/// Inductance [H]
@@ -35,10 +33,9 @@ namespace Ph3 {
mRatio(attributeList->create("ratio")) { };
///
- void setParameters(Real nomVoltageEnd1, Real nomVoltageEnd2, Real ratedPower, Real ratioAbs, Real ratioPhase, Matrix resistance, Matrix inductance) {
+ void setParameters(Real nomVoltageEnd1, Real nomVoltageEnd2, Real ratioAbs, Real ratioPhase, Matrix resistance, Matrix inductance) {
mNominalVoltageEnd1 = nomVoltageEnd1;
mNominalVoltageEnd2 = nomVoltageEnd2;
- mRatedPower = ratedPower;
**mRatio = std::polar(ratioAbs, ratioPhase);
mResistance = resistance;
mInductance = inductance;
diff --git a/dpsim-models/include/dpsim-models/Components.h b/dpsim-models/include/dpsim-models/Components.h
index fe843efde9..4d9ede773c 100644
--- a/dpsim-models/include/dpsim-models/Components.h
+++ b/dpsim-models/include/dpsim-models/Components.h
@@ -11,6 +11,7 @@
#include
#include
+#include
#include
#include
#include
@@ -48,6 +49,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -94,6 +96,7 @@
#include
#include
#include
+#include
#include
#include
#include
diff --git a/dpsim-models/include/dpsim-models/DP/DP_Ph1_Capacitor.h b/dpsim-models/include/dpsim-models/DP/DP_Ph1_Capacitor.h
index 88b7ac578f..988af3f506 100644
--- a/dpsim-models/include/dpsim-models/DP/DP_Ph1_Capacitor.h
+++ b/dpsim-models/include/dpsim-models/DP/DP_Ph1_Capacitor.h
@@ -57,10 +57,10 @@ namespace Ph1 {
/// Stamps right side (source) vector
void mnaCompApplyRightSideVectorStamp(Matrix& rightVector) override;
void mnaCompApplyRightSideVectorStampHarm(Matrix& rightVector) override;
+ void mnaCompApplyRightSideVectorStampHarm(Matrix& sourceVector, Int freqIdx) override;
/// Update interface voltage from MNA system result
void mnaCompUpdateVoltage(const Matrix& leftVector) override;
void mnaCompUpdateVoltageHarm(const Matrix& leftVector, Int freqIdx);
- void mnaCompApplyRightSideVectorStampHarm(Matrix& sourceVector, Int freqIdx) override;
/// Update interface current from MNA system result
void mnaCompUpdateCurrent(const Matrix& leftVector) override;
void mnaCompUpdateCurrentHarm();
diff --git a/dpsim-models/include/dpsim-models/DP/DP_Ph1_PiLine.h b/dpsim-models/include/dpsim-models/DP/DP_Ph1_PiLine.h
index 5a24a7a086..68bfc25393 100644
--- a/dpsim-models/include/dpsim-models/DP/DP_Ph1_PiLine.h
+++ b/dpsim-models/include/dpsim-models/DP/DP_Ph1_PiLine.h
@@ -11,8 +11,8 @@
#include
#include
#include
+#include
#include
-#include
#include
namespace CPS {
@@ -28,10 +28,8 @@ namespace Ph1 {
public Base::Ph1::PiLine,
public SharedFactory {
protected:
- /// Series Inductance submodel
- std::shared_ptr mSubSeriesInductor;
- /// Series Resistor submodel
- std::shared_ptr mSubSeriesResistor;
+ /// Series Resistor-Inductance submodel
+ std::shared_ptr mSubSeriesElement;
/// Parallel Resistor submodel at Terminal 0
std::shared_ptr mSubParallelResistor0;
// Parallel Capacitor submodel at Terminal 0
@@ -49,8 +47,6 @@ namespace Ph1 {
PiLine(String name, Logger::Level logLevel = Logger::Level::off)
: PiLine(name, name, logLevel) { }
- SimPowerComp::Ptr clone(String copySuffix);
-
// #### General ####
/// Initializes component from power flow data
void initializeFromNodesAndTerminals(Real frequency);
diff --git a/dpsim-models/include/dpsim-models/DP/DP_Ph1_PiLine_deprecated.h b/dpsim-models/include/dpsim-models/DP/DP_Ph1_PiLine_deprecated.h
new file mode 100644
index 0000000000..5a24a7a086
--- /dev/null
+++ b/dpsim-models/include/dpsim-models/DP/DP_Ph1_PiLine_deprecated.h
@@ -0,0 +1,79 @@
+/* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
+ * EONERC, RWTH Aachen University
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
+ *********************************************************************************/
+
+#pragma once
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace CPS {
+namespace DP {
+namespace Ph1 {
+ /// \brief PI-line dynamic phasor model
+ ///
+ /// This model consists sub components to represent the
+ /// RLC elements of a PI-line.
+ class PiLine :
+ public CompositePowerComp,
+ public MNATearInterface,
+ public Base::Ph1::PiLine,
+ public SharedFactory {
+ protected:
+ /// Series Inductance submodel
+ std::shared_ptr mSubSeriesInductor;
+ /// Series Resistor submodel
+ std::shared_ptr mSubSeriesResistor;
+ /// Parallel Resistor submodel at Terminal 0
+ std::shared_ptr mSubParallelResistor0;
+ // Parallel Capacitor submodel at Terminal 0
+ std::shared_ptr mSubParallelCapacitor0;
+ /// Parallel resistor submodel at Terminal 1
+ std::shared_ptr mSubParallelResistor1;
+ /// Parallel capacitor submodel at Terminal 1
+ std::shared_ptr mSubParallelCapacitor1;
+ /// Right side vectors of subcomponents
+ std::vector mRightVectorStamps;
+ public:
+ /// Defines UID, name and logging level
+ PiLine(String uid, String name, Logger::Level logLevel = Logger::Level::off);
+ /// Defines name and logging level
+ PiLine(String name, Logger::Level logLevel = Logger::Level::off)
+ : PiLine(name, name, logLevel) { }
+
+ SimPowerComp::Ptr clone(String copySuffix);
+
+ // #### General ####
+ /// Initializes component from power flow data
+ void initializeFromNodesAndTerminals(Real frequency);
+
+ // #### MNA section ####
+ /// Updates internal current variable of the component
+ void mnaCompUpdateCurrent(const Matrix& leftVector);
+ /// Updates internal voltage variable of the component
+ void mnaCompUpdateVoltage(const Matrix& leftVector);
+ /// MNA pre and post step operations
+ void mnaParentPreStep(Real time, Int timeStepCount) override;
+ void mnaParentPostStep(Real time, Int timeStepCount, Attribute::Ptr &leftVector) override;
+ /// add MNA pre and post step dependencies
+ void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override;
+ void mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute::Ptr &leftVector) override;
+
+ MNAInterface::List mnaTearGroundComponents();
+ void mnaTearInitialize(Real omega, Real timeStep);
+ void mnaTearApplyMatrixStamp(SparseMatrixRow& tearMatrix);
+ void mnaTearApplyVoltageStamp(Matrix& voltageVector);
+ void mnaTearPostStep(Complex voltage, Complex current);
+
+ };
+}
+}
+}
diff --git a/dpsim-models/include/dpsim-models/DP/DP_Ph1_ResIndSeries.h b/dpsim-models/include/dpsim-models/DP/DP_Ph1_ResIndSeries.h
index f72c7a28c5..b48f27d6a1 100644
--- a/dpsim-models/include/dpsim-models/DP/DP_Ph1_ResIndSeries.h
+++ b/dpsim-models/include/dpsim-models/DP/DP_Ph1_ResIndSeries.h
@@ -9,17 +9,19 @@
#pragma once
#include
-#include
+#include
namespace CPS {
namespace DP {
namespace Ph1 {
/// \brief resistor inductor series element
- class ResIndSeries :
- public MNATearInterface,
+ class ResIndSeries:
public MNASimPowerComp,
+ public MNATearInterface,
public SharedFactory {
- protected:
+ private:
+ /// Impedance
+ Complex mImpedance;
/// DC equivalent current source for harmonics [A]
MatrixComp mEquivCurrent;
/// Equivalent conductance for harmonics [S]
@@ -35,7 +37,7 @@ namespace Ph1 {
ResIndSeries(String uid, String name, Logger::Level logLevel = Logger::Level::off);
/// Defines name and log level
ResIndSeries(String name, Logger::Level logLevel = Logger::Level::off)
- : Inductor(name, name, logLevel) { }
+ : ResIndSeries(name, name, logLevel) { }
// #### General ####
/// Sets model specific parameters
@@ -45,28 +47,73 @@ namespace Ph1 {
/// Initializes state variables considering the number of frequencies
void initialize(Matrix frequencies);
/// Initializes states from power flow data
- void initializeFromNodesAndTerminals(Real frequency);
+ void initializeFromNodesAndTerminals(Real frequency) override;
+ /// Initializes auxiliar variables
+ void initVars(Real timeStep);
// #### MNA section ####
/// Initializes MNA specific variables
- void mnaCompInitialize(Real omega, Real timeStep, Attribute::Ptr leftVector);
+ void mnaCompInitialize(Real omega, Real timeStep, Attribute::Ptr leftVector) override;
+ void mnaCompInitializeHarm(Real omega, Real timeStep, std::vector::Ptr> leftVectors) override;
/// Stamps system matrix
- void mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix);
+ void mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix) override;
+ void mnaCompApplySystemMatrixStampHarm(SparseMatrixRow& systemMatrix, Int freqIdx) override;
/// Stamps right side (source) vector
- void mnaCompApplyRightSideVectorStamp(Matrix& rightVector);
+ void mnaCompApplyRightSideVectorStamp(Matrix& rightVector) override;
+ void mnaCompApplyRightSideVectorStampHarm(Matrix& rightVector) override;
/// Update interface voltage from MNA system results
- void mnaCompUpdateVoltage(const Matrix& leftVector);
+ void mnaCompUpdateVoltage(const Matrix& leftVector) override;
+ void mnaCompUpdateVoltageHarm(const Matrix& leftVector, Int freqIdx);
+ void mnaCompApplyRightSideVectorStampHarm(Matrix& sourceVector, Int freqIdx) override;
/// Update interface current from MNA system results
- void mnaCompUpdateCurrent();
-
+ void mnaCompUpdateCurrent(const Matrix& leftVector) override;
+ void mnaCompUpdateCurrentHarm();
+ /// Add MNA pre step dependencies
void mnaCompPreStep(Real time, Int timeStepCount) override;
+ /// Add MNA post step dependencies
void mnaCompPostStep(Real time, Int timeStepCount, Attribute::Ptr &leftVector) override;
-
/// Add MNA pre step dependencies
void mnaCompAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override;
-
/// Add MNA post step dependencies
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute::Ptr &leftVector) override;
+
+ class MnaPreStepHarm : public CPS::Task {
+ public:
+ MnaPreStepHarm(ResIndSeries& ResIndSeries)
+ : Task(**ResIndSeries.mName + ".MnaPreStepHarm"),
+ mResIndSeries(ResIndSeries) {
+ // actually depends on C, but then we'd have to modify the system matrix anyway
+ mModifiedAttributes.push_back(mResIndSeries.attribute("right_vector"));
+ mPrevStepDependencies.push_back(mResIndSeries.attribute("i_intf"));
+ mPrevStepDependencies.push_back(mResIndSeries.attribute("v_intf"));
+ }
+ void execute(Real time, Int timeStepCount);
+ private:
+ ResIndSeries& mResIndSeries;
+ };
+
+ class MnaPostStepHarm : public CPS::Task {
+ public:
+ MnaPostStepHarm(ResIndSeries& ResIndSeries, const std::vector::Ptr> &leftVectors)
+ : Task(**ResIndSeries.mName + ".MnaPostStepHarm"),
+ mResIndSeries(ResIndSeries), mLeftVectors(leftVectors) {
+ for (UInt i = 0; i < mLeftVectors.size(); i++)
+ mAttributeDependencies.push_back(mLeftVectors[i]);
+ mModifiedAttributes.push_back(mResIndSeries.attribute("v_intf"));
+ mModifiedAttributes.push_back(mResIndSeries.attribute("i_intf"));
+ }
+ void execute(Real time, Int timeStepCount);
+ private:
+ ResIndSeries& mResIndSeries;
+ std::vector< Attribute::Ptr > mLeftVectors;
+ };
+
+ // #### Tearing methods ####
+ void mnaTearInitialize(Real omega, Real timestep) override;
+ void mnaTearApplyMatrixStamp(SparseMatrixRow& tearMatrix) override;
+ void mnaTearApplyVoltageStamp(Matrix& voltageVector) override;
+ void mnaTearPostStep(Complex voltage, Complex current) override;
+
};
}
}
diff --git a/dpsim-models/include/dpsim-models/DP/DP_Ph1_Resistor.h b/dpsim-models/include/dpsim-models/DP/DP_Ph1_Resistor.h
index 127cea1985..ac59f9605d 100644
--- a/dpsim-models/include/dpsim-models/DP/DP_Ph1_Resistor.h
+++ b/dpsim-models/include/dpsim-models/DP/DP_Ph1_Resistor.h
@@ -71,7 +71,7 @@ namespace Ph1 {
};
// #### MNA Tear Section ####
- void mnaTearApplyMatrixStamp(SparseMatrixRow& tearMatrix);
+ void mnaTearApplyMatrixStamp(SparseMatrixRow& tearMatrix) override;
// #### DAE Section ####
///Residual Function for DAE Solver
diff --git a/dpsim-models/include/dpsim-models/DP/DP_Ph1_Transformer.h b/dpsim-models/include/dpsim-models/DP/DP_Ph1_Transformer.h
index ebc4ac8d60..0aa61d5521 100644
--- a/dpsim-models/include/dpsim-models/DP/DP_Ph1_Transformer.h
+++ b/dpsim-models/include/dpsim-models/DP/DP_Ph1_Transformer.h
@@ -8,11 +8,8 @@
#pragma once
-#include
+#include
#include
-#include
-#include
-#include
#include
namespace CPS {
@@ -20,71 +17,103 @@ namespace DP {
namespace Ph1 {
/// Transformer that includes an inductance and resistance
class Transformer :
- public CompositePowerComp,
+ public MNASimPowerComp,
public SharedFactory,
public Base::Ph1::Transformer {
- private:
- /// Internal resistor to model losses
- std::shared_ptr mSubResistor;
- /// Internal inductor to model losses
- std::shared_ptr mSubInductor;
- /// Internal parallel resistance 1 as snubber
- std::shared_ptr mSubSnubResistor1;
- /// Internal parallel resistance 2 as snubber
- std::shared_ptr mSubSnubResistor2;
- /// Internal parallel capacitance 1 as snubber
- std::shared_ptr mSubSnubCapacitor1;
- /// Internal parallel capacitance 2 as snubber
- std::shared_ptr 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;
-
- /// Boolean for considering resistive losses with sub resistor
- Bool mWithResistiveLosses;
public:
/// 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::Ptr clone(String name);
+ /// DC equivalent current source for harmonics [A]
+ MatrixComp mEquivCurrent;
+ /// Equivalent conductance for harmonics [S]
+ MatrixComp mEquivCond;
+ /// Coefficient in front of previous current value for harmonics
+ MatrixComp mPrevCurrFac;
+ public:
// #### General ####
/// Defines component parameters
void setParameters(Real nomVoltageEnd1, Real nomVoltageEnd2, Real ratioAbs, Real ratioPhase, Real resistance, Real inductance);
- /// Set transformer specific parameters
- void setParameters(Real nomVoltageEnd1, Real nomVoltageEnd2, Real ratedPower, Real ratioAbs, Real ratioPhase, Real resistance, Real inductance);
/// Initializes component from power flow data
void initializeFromNodesAndTerminals(Real frequency);
+ /// Initializes state variables considering the number of frequencies
+ void initialize(Matrix frequencies);
+ ///
+ void initVars(Real timeStep);
+
// #### MNA section ####
/// Initializes internal variables of the component
- void mnaParentInitialize(Real omega, Real timeStep, Attribute::Ptr leftVector) override;
+ void mnaCompInitialize(Real omega, Real timeStep, Attribute::Ptr leftVector) override;
+ ///
+ void mnaCompInitializeHarm(Real omega, Real timeStep, std::vector::Ptr> leftVectors) override;
/// Stamps system matrix
void mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix) override;
+ /// Stamps system matrix
+ void mnaCompApplySystemMatrixStampHarm(SparseMatrixRow& systemMatrix , int freqIdx) override;
/// Updates internal current variable of the component
void mnaCompUpdateCurrent(const Matrix& leftVector) override;
+ /// Updates internal current variable of the component
+ void mnaCompUpdateCurrentHarm();
/// Updates internal voltage variable of the component
void mnaCompUpdateVoltage(const Matrix& leftVector) override;
+ /// Updates internal voltage variable of the component for harmonics
+ void mnaCompUpdateVoltageHarm(const Matrix& leftVector, int freqIdx);
+ /// MNA pre step operations
+ void mnaCompPreStep(Real time, Int timeStepCount) override;
/// MNA pre step operations
- void mnaParentPreStep(Real time, Int timeStepCount) override;
+ void mnaCompPreStepHarm(Real time, Int timeStepCount);
/// MNA post step operations
- void mnaParentPostStep(Real time, Int timeStepCount, Attribute::Ptr &leftVector) override;
+ void mnaCompPostStep(Real time, Int timeStepCount, Attribute::Ptr &leftVector) override;
+ /// MNA post step operations
+ void mnaPostStepHarm(Real time, Int timeStepCount) ;
+ /// Stamps right side (source) vector
+ void mnaCompApplyRightSideVectorStamp(Matrix& rightVector) override;
+ /// Stamps right side (source) vector
+ void mnaCompApplyRightSideVectorStampHarm(Matrix& rightVector) override;
/// Add MNA pre step dependencies
- void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override;
+ void mnaCompAddPreStepDependencies(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::Ptr &leftVector) override;
+ void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute::Ptr &leftVector) override;
+
+ //
+ class MnaPreStepHarm : public Task {
+ public:
+ MnaPreStepHarm(Transformer& transformer)
+ : Task(**transformer.mName + ".MnaPreStepHarm"),
+ mTransformer(transformer) {
+ // actually depends on L, but then we'd have to modify the system matrix anyway
+ mModifiedAttributes.push_back(mTransformer.attribute("right_vector"));
+ mPrevStepDependencies.push_back(mTransformer.attribute("v_intf"));
+ mPrevStepDependencies.push_back(mTransformer.attribute("i_intf"));
+ }
+ void execute(Real time, Int timeStepCount);
+ private:
+ Transformer& mTransformer;
+ };
+ //
+ class MnaPostStepHarm : public Task {
+ public:
+ MnaPostStepHarm(Transformer& transformer, const std::vector::Ptr> &leftVectors)
+ : Task(**transformer.mName + ".MnaPostStepHarm"),
+ mTransformer(transformer), mLeftVectors(leftVectors) {
+ for (UInt i = 0; i < mLeftVectors.size(); i++)
+ mAttributeDependencies.push_back(mLeftVectors[i]);
+ mModifiedAttributes.push_back(mTransformer.attribute("v_intf"));
+ mModifiedAttributes.push_back(mTransformer.attribute("i_intf"));
+ }
+ void execute(Real time, Int timeStepCount);
+ private:
+ Transformer& mTransformer;
+ std::vector< Attribute::Ptr > mLeftVectors;
+ };
};
}
}
diff --git a/dpsim-models/include/dpsim-models/DP/DP_Ph1_Transformer_deprecated.h b/dpsim-models/include/dpsim-models/DP/DP_Ph1_Transformer_deprecated.h
new file mode 100644
index 0000000000..ebc4ac8d60
--- /dev/null
+++ b/dpsim-models/include/dpsim-models/DP/DP_Ph1_Transformer_deprecated.h
@@ -0,0 +1,91 @@
+/* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
+ * EONERC, RWTH Aachen University
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
+ *********************************************************************************/
+
+#pragma once
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace CPS {
+namespace DP {
+namespace Ph1 {
+ /// Transformer that includes an inductance and resistance
+ class Transformer :
+ public CompositePowerComp,
+ public SharedFactory,
+ public Base::Ph1::Transformer {
+ private:
+ /// Internal resistor to model losses
+ std::shared_ptr mSubResistor;
+ /// Internal inductor to model losses
+ std::shared_ptr mSubInductor;
+
+ /// Internal parallel resistance 1 as snubber
+ std::shared_ptr mSubSnubResistor1;
+ /// Internal parallel resistance 2 as snubber
+ std::shared_ptr mSubSnubResistor2;
+ /// Internal parallel capacitance 1 as snubber
+ std::shared_ptr mSubSnubCapacitor1;
+ /// Internal parallel capacitance 2 as snubber
+ std::shared_ptr 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;
+
+ /// Boolean for considering resistive losses with sub resistor
+ Bool mWithResistiveLosses;
+ public:
+ /// Defines UID, name and logging level
+ Transformer(String uid, String name,
+ Logger::Level logLevel = Logger::Level::off, Bool withResistiveLosses = false);
+ /// Defines name and logging level
+ Transformer(String name, Logger::Level logLevel = Logger::Level::off)
+ : Transformer(name, name, logLevel) { }
+
+ SimPowerComp::Ptr clone(String name);
+
+ // #### General ####
+ /// Defines component parameters
+ void setParameters(Real nomVoltageEnd1, Real nomVoltageEnd2, Real ratioAbs, Real ratioPhase, Real resistance, Real inductance);
+ /// Set transformer specific parameters
+ void setParameters(Real nomVoltageEnd1, Real nomVoltageEnd2, Real ratedPower, Real ratioAbs, Real ratioPhase, Real resistance, Real inductance);
+ /// Initializes component from power flow data
+ void initializeFromNodesAndTerminals(Real frequency);
+
+ // #### MNA section ####
+ /// Initializes internal variables of the component
+ void mnaParentInitialize(Real omega, Real timeStep, Attribute::Ptr leftVector) override;
+ /// Stamps system matrix
+ void mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix) override;
+ /// Updates internal current variable of the component
+ void mnaCompUpdateCurrent(const Matrix& 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::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::Ptr &leftVector) override;
+
+ };
+}
+}
+}
diff --git a/dpsim-models/include/dpsim-models/EMT/EMT_Ph1_VoltageSource.h b/dpsim-models/include/dpsim-models/EMT/EMT_Ph1_VoltageSource.h
index 0f663c5f40..6e9a990f17 100644
--- a/dpsim-models/include/dpsim-models/EMT/EMT_Ph1_VoltageSource.h
+++ b/dpsim-models/include/dpsim-models/EMT/EMT_Ph1_VoltageSource.h
@@ -25,8 +25,6 @@ namespace Ph1 {
class VoltageSource :
public MNASimPowerComp,
public SharedFactory {
- private:
- Real mTimeStep;
protected:
void updateVoltage(Real time);
public:
diff --git a/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_Inductor.h b/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_Inductor.h
index ae569e2d4f..8ecdf9d3d4 100644
--- a/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_Inductor.h
+++ b/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_Inductor.h
@@ -42,7 +42,7 @@ namespace CPS {
// #### General ####
/// Initializes component from power flow data
- void initializeFromNodesAndTerminals(Real frequency);
+ void initializeFromNodesAndTerminals(Real frequency) override;
// #### MNA section ####
/// Initializes internal variables of the component
diff --git a/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_PiLine.h b/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_PiLine.h
index 295c676089..6a166cd2ca 100644
--- a/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_PiLine.h
+++ b/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_PiLine.h
@@ -11,8 +11,8 @@
#include
#include
#include
+#include
#include
-#include
#include
namespace CPS {
@@ -27,10 +27,8 @@ namespace Ph3 {
public Base::Ph3::PiLine,
public SharedFactory {
protected:
- /// Series Inductance submodel
- std::shared_ptr mSubSeriesInductor;
- /// Series Resistor submodel
- std::shared_ptr mSubSeriesResistor;
+ /// Series Resistor-Inductance submodel
+ std::shared_ptr mSubSeriesElement;
/// Parallel Resistor submodel at Terminal 0
std::shared_ptr mSubParallelResistor0;
// Parallel Capacitor submodel at Terminal 0
diff --git a/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_PiLine_deprecated.h b/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_PiLine_deprecated.h
new file mode 100644
index 0000000000..295c676089
--- /dev/null
+++ b/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_PiLine_deprecated.h
@@ -0,0 +1,80 @@
+/* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
+ * EONERC, RWTH Aachen University
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
+ *********************************************************************************/
+
+#pragma once
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace CPS {
+namespace EMT {
+namespace Ph3 {
+ /// \brief PI-line dynamic phasor model
+ ///
+ /// This model consists sub components to represent the
+ /// RLC elements of a PI-line.
+ class PiLine :
+ public CompositePowerComp,
+ public Base::Ph3::PiLine,
+ public SharedFactory {
+ protected:
+ /// Series Inductance submodel
+ std::shared_ptr mSubSeriesInductor;
+ /// Series Resistor submodel
+ std::shared_ptr mSubSeriesResistor;
+ /// Parallel Resistor submodel at Terminal 0
+ std::shared_ptr mSubParallelResistor0;
+ // Parallel Capacitor submodel at Terminal 0
+ std::shared_ptr mSubParallelCapacitor0;
+ /// Parallel resistor submodel at Terminal 1
+ std::shared_ptr mSubParallelResistor1;
+ // Parallel capacitor submodel at Terminal 1
+ std::shared_ptr mSubParallelCapacitor1;
+ /// solver
+ std::vector mRightVectorStamps;
+ public:
+ /// Defines UID, name and logging level
+ PiLine(String uid, String name, Logger::Level logLevel = Logger::Level::off);
+ /// Defines name and logging level
+ PiLine(String name, Logger::Level logLevel = Logger::Level::off)
+ : PiLine(name, name, logLevel) { }
+
+ SimPowerComp::Ptr clone(String copySuffix);
+
+ // #### General ####
+ /// Initializes component from power flow data
+ void initializeFromNodesAndTerminals(Real frequency);
+
+ // #### MNA section ####
+ /// Updates internal current variable of the component
+ void mnaCompUpdateCurrent(const Matrix& 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::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::Ptr &leftVector) override;
+
+ //MNAInterface::List mnaTearGroundComponents();
+ /*void mnaTearInitialize(Real omega, Real timeStep);
+ void mnaTearApplyMatrixStamp(SparseMatrixRow& tearMatrix);
+ void mnaTearApplyVoltageStamp(Matrix& voltageVector);
+ void mnaTearPostStep(Matrix voltage, Matrix current);*/
+
+ };
+}
+}
+}
diff --git a/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_ResIndSeries.h b/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_ResIndSeries.h
new file mode 100644
index 0000000000..84951333bd
--- /dev/null
+++ b/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_ResIndSeries.h
@@ -0,0 +1,73 @@
+/* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
+ * EONERC, RWTH Aachen University
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
+ *********************************************************************************/
+
+#pragma once
+
+#include
+#include
+
+namespace CPS {
+ namespace EMT {
+ namespace Ph3 {
+ /// EMT ResIndSeries
+ /// Assumption: non diagonal terms are equal to zero, Z00=Z11=Z22
+ class ResIndSeries :
+ public MNASimPowerComp,
+ public SharedFactory {
+ protected:
+ /// DC equivalent current source [A]
+ Matrix mEquivCurrent;
+ /// Equivalent conductance [S]
+ Real mEquivCond;
+ /// Coefficient in front of previous current value
+ Real mPrevCurrFac;
+ public:
+ /// Inductance [H]
+ const Attribute::Ptr mInductance;
+ ///Resistance [ohm]
+ const Attribute::Ptr mResistance;
+ /// Defines UID, name, component parameters and logging level
+ ResIndSeries(String uid, String name, Logger::Level logLevel = Logger::Level::off);
+ /// Defines name, component parameters and logging level
+ ResIndSeries(String name, Logger::Level logLevel = Logger::Level::off)
+ : ResIndSeries(name, name, logLevel) { }
+ ///
+ SimPowerComp::Ptr clone(String name);
+
+ // #### General ####
+ /// Sets model specific parameters
+ void setParameters(Matrix resistanceMatrix, Matrix inductanceMatrix);
+
+ /// Initializes auxiliar variables
+ void initVars(Real timeStep);
+ /// Initializes component from power flow data
+ void initializeFromNodesAndTerminals(Real frequency) override;
+
+ // #### MNA section ####
+ /// Initializes internal variables of the component
+ void mnaCompInitialize(Real omega, Real timeStep, Attribute::Ptr leftSideVector) override;
+ /// Stamps system matrix
+ void mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix) override;
+ /// Stamps right side (source) vector
+ void mnaCompApplyRightSideVectorStamp(Matrix& rightVector) override;
+ /// Update interface voltage from MNA system result
+ void mnaCompUpdateVoltage(const Matrix& leftVector) override;
+ /// Update interface current from MNA system result
+ void mnaCompUpdateCurrent(const Matrix& leftVector) override;
+ /// MNA pre step operations
+ void mnaCompPreStep(Real time, Int timeStepCount) override;
+ /// MNA pre and post step operations
+ void mnaCompPostStep(Real time, Int timeStepCount, Attribute::Ptr &leftVector) override;
+ /// Add MNA pre step dependencies
+ void mnaCompAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override;
+ /// add MNA pre and post step dependencies
+ void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute::Ptr &leftVector) override;
+ };
+ }
+ }
+}
diff --git a/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_Resistor.h b/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_Resistor.h
index 800104e3af..607b24fc2c 100644
--- a/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_Resistor.h
+++ b/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_Resistor.h
@@ -38,19 +38,19 @@ class Resistor :
// #### MNA section ####
/// Initializes internal variables of the component
- void mnaCompInitialize(Real omega, Real timeStep, Attribute::Ptr leftSideVector);
+ void mnaCompInitialize(Real omega, Real timeStep, Attribute::Ptr leftSideVector) override;
/// Stamps system matrix
- void mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix);
+ void mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix) override;
/// Stamps right side (source) vector
- void mnaCompApplyRightSideVectorStamp(Matrix& rightVector) { }
+ void mnaCompApplyRightSideVectorStamp(Matrix& rightVector) override { }
/// Update interface voltage from MNA system result
- void mnaCompUpdateVoltage(const Matrix& leftVector);
+ void mnaCompUpdateVoltage(const Matrix& leftVector) override;
/// Update interface current from MNA system result
- void mnaCompUpdateCurrent(const Matrix& leftVector);
+ void mnaCompUpdateCurrent(const Matrix& leftVector) override;
/// MNA pre and post step operations
- void mnaCompPostStep(Real time, Int timeStepCount, Attribute::Ptr &leftVector);
+ void mnaCompPostStep(Real time, Int timeStepCount, Attribute::Ptr &leftVector) override;
/// add MNA pre and post step dependencies
- void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute::Ptr &leftVector);
+ void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute::Ptr &leftVector) override;
};
}
}
diff --git a/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_Transformer.h b/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_Transformer.h
index 177be42d61..84e8352f8d 100644
--- a/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_Transformer.h
+++ b/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_Transformer.h
@@ -8,80 +8,63 @@
#pragma once
-#include
+#include
#include
-#include
-#include
-#include
#include
namespace CPS {
namespace EMT {
namespace Ph3 {
- /// Transformer that includes an inductance and resistance
+ /// Symmetric Transformer that includes an inductance and resistance
class Transformer :
- public CompositePowerComp,
+ public MNASimPowerComp,
public SharedFactory,
public Base::Ph3::Transformer {
- private:
- /// Internal resistor to model losses
- std::shared_ptr mSubResistor;
- /// Internal inductor to model losses
- std::shared_ptr mSubInductor;
-
- /// Internal parallel resistance 1 as snubber
- std::shared_ptr mSubSnubResistor1;
- /// Internal parallel resistance 2 as snubber
- std::shared_ptr mSubSnubResistor2;
- /// Internal parallel capacitance 1 as snubber
- std::shared_ptr mSubSnubCapacitor1;
- /// Internal parallel capacitance 2 as snubber
- std::shared_ptr mSubSnubCapacitor2;
-
- /// Snubber resistance 1
- Matrix mSnubberResistance1;
- /// Snubber resistance 2
- Matrix mSnubberResistance2;
- /// Snubber capacitance 1
- Matrix mSnubberCapacitance1;
- /// Snubber capacitance 2
- Matrix mSnubberCapacitance2;
-
- /// Boolean for considering resistive losses with sub resistor
- Bool mWithResistiveLosses;
+
public:
+ /// Defines UID, name and logging level
/// 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::Ptr clone(String name);
-
+ protected:
+ /// DC equivalent current source [A]
+ Matrix mEquivCurrent;
+ /// Equivalent conductance [S]
+ Real mEquivCond;
+ /// Coefficient in front of previous current value
+ Real mPrevCurrFac ;
+ public:
// #### General ####
/// Defines component parameters
- void setParameters(Real nomVoltageEnd1, Real nomVoltageEnd2, Real ratedPower, Real ratioAbs, Real ratioPhase, Matrix resistance, Matrix inductance);
+ void setParameters(Real nomVoltageEnd1, Real nomVoltageEnd2, Real ratioAbs, Real ratioPhase, Matrix resistance, Matrix inductance);
/// Initializes component from power flow data
void initializeFromNodesAndTerminals(Real frequency);
+ /// Initializes auxiliar variables
+ void initVars(Real timeStep);
// #### MNA section ####
/// Initializes internal variables of the component
- void mnaParentInitialize(Real omega, Real timeStep, Attribute::Ptr leftVector) override;
+ void mnaCompInitialize(Real omega, Real timeStep, Attribute::Ptr leftSideVector) override;
/// Stamps system matrix
void mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix) override;
+ /// Stamps right side (source) vector
+ void mnaCompApplyRightSideVectorStamp(Matrix& rightVector) override;
/// Updates internal current variable of the component
void mnaCompUpdateCurrent(const Matrix& 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;
+ void mnaCompPreStep(Real time, Int timeStepCount) override;
/// MNA post step operations
- void mnaParentPostStep(Real time, Int timeStepCount, Attribute::Ptr &leftVector) override;
+ void mnaCompPostStep(Real time, Int timeStepCount, Attribute::Ptr &leftVector) override;
/// Add MNA pre step dependencies
- void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override;
+ void mnaCompAddPreStepDependencies(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::Ptr &leftVector) override;
+ void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute::Ptr &leftVector) override;
};
}
}
diff --git a/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_Transformer_deprecated.h b/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_Transformer_deprecated.h
new file mode 100644
index 0000000000..177be42d61
--- /dev/null
+++ b/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_Transformer_deprecated.h
@@ -0,0 +1,88 @@
+/* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
+ * EONERC, RWTH Aachen University
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
+ *********************************************************************************/
+
+#pragma once
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace CPS {
+ namespace EMT {
+ namespace Ph3 {
+ /// Transformer that includes an inductance and resistance
+ class Transformer :
+ public CompositePowerComp,
+ public SharedFactory,
+ public Base::Ph3::Transformer {
+ private:
+ /// Internal resistor to model losses
+ std::shared_ptr mSubResistor;
+ /// Internal inductor to model losses
+ std::shared_ptr mSubInductor;
+
+ /// Internal parallel resistance 1 as snubber
+ std::shared_ptr mSubSnubResistor1;
+ /// Internal parallel resistance 2 as snubber
+ std::shared_ptr mSubSnubResistor2;
+ /// Internal parallel capacitance 1 as snubber
+ std::shared_ptr mSubSnubCapacitor1;
+ /// Internal parallel capacitance 2 as snubber
+ std::shared_ptr mSubSnubCapacitor2;
+
+ /// Snubber resistance 1
+ Matrix mSnubberResistance1;
+ /// Snubber resistance 2
+ Matrix mSnubberResistance2;
+ /// Snubber capacitance 1
+ Matrix mSnubberCapacitance1;
+ /// Snubber capacitance 2
+ Matrix mSnubberCapacitance2;
+
+ /// Boolean for considering resistive losses with sub resistor
+ Bool mWithResistiveLosses;
+ public:
+ /// Defines UID, name and logging level
+ Transformer(String uid, String name,
+ Logger::Level logLevel = Logger::Level::off, Bool withResistiveLosses = false);
+ /// Defines name and logging level
+ Transformer(String name, Logger::Level logLevel = Logger::Level::off)
+ : Transformer(name, name, logLevel) { }
+
+ SimPowerComp::Ptr clone(String name);
+
+ // #### General ####
+ /// Defines component parameters
+ void setParameters(Real nomVoltageEnd1, Real nomVoltageEnd2, Real ratedPower, Real ratioAbs, Real ratioPhase, Matrix resistance, Matrix inductance);
+ /// Initializes component from power flow data
+ void initializeFromNodesAndTerminals(Real frequency);
+
+ // #### MNA section ####
+ /// Initializes internal variables of the component
+ void mnaParentInitialize(Real omega, Real timeStep, Attribute::Ptr leftVector) override;
+ /// Stamps system matrix
+ void mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix) override;
+ /// Updates internal current variable of the component
+ void mnaCompUpdateCurrent(const Matrix& 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::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::Ptr &leftVector) override;
+ };
+ }
+ }
+}
diff --git a/dpsim-models/include/dpsim-models/SP/SP_Ph1_Inductor.h b/dpsim-models/include/dpsim-models/SP/SP_Ph1_Inductor.h
index 14e81501a3..52eedbed75 100644
--- a/dpsim-models/include/dpsim-models/SP/SP_Ph1_Inductor.h
+++ b/dpsim-models/include/dpsim-models/SP/SP_Ph1_Inductor.h
@@ -9,7 +9,6 @@
#pragma once
#include
-
#include
#include
@@ -50,8 +49,11 @@ namespace Ph1 {
/// MNA post step operations
void mnaCompPostStep(Real time, Int timeStepCount, Attribute::Ptr &leftVector);
/// Add MNA post step dependencies
- void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute::Ptr &leftVector);
- void mnaTearApplyMatrixStamp(SparseMatrixRow& tearMatrix);
+ void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
+ AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes,
+ Attribute::Ptr &leftVector);
+ //
+ void mnaTearApplyMatrixStamp(SparseMatrixRow& tearMatrix) override;
};
}
}
diff --git a/dpsim-models/include/dpsim-models/SP/SP_Ph1_PiLine.h b/dpsim-models/include/dpsim-models/SP/SP_Ph1_PiLine.h
index b75ab78d0c..0d3f57d1e4 100644
--- a/dpsim-models/include/dpsim-models/SP/SP_Ph1_PiLine.h
+++ b/dpsim-models/include/dpsim-models/SP/SP_Ph1_PiLine.h
@@ -12,8 +12,8 @@
#include
#include
#include
+#include
#include
-#include
#include
namespace CPS {
@@ -71,10 +71,8 @@ namespace Ph1 {
// #### Admittance matrix stamp ####
MatrixComp mY_element;
- /// Series Inductance submodel
- std::shared_ptr mSubSeriesInductor;
- /// Series Resistor submodel
- std::shared_ptr mSubSeriesResistor;
+ /// Series Resistor-Inductance submodel
+ std::shared_ptr mSubSeriesElement;
/// Parallel Resistor submodel at Terminal 0
std::shared_ptr mSubParallelResistor0;
// Parallel Capacitor submodel at Terminal 0
@@ -97,10 +95,7 @@ namespace Ph1 {
/// Defines name and logging level
PiLine(String name, Logger::Level logLevel = Logger::Level::off)
: PiLine(name, name, logLevel) { }
- ///
- SimPowerComp::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;
diff --git a/dpsim-models/include/dpsim-models/SP/SP_Ph1_PiLine_deprecated.h b/dpsim-models/include/dpsim-models/SP/SP_Ph1_PiLine_deprecated.h
new file mode 100644
index 0000000000..b75ab78d0c
--- /dev/null
+++ b/dpsim-models/include/dpsim-models/SP/SP_Ph1_PiLine_deprecated.h
@@ -0,0 +1,141 @@
+/* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
+ * EONERC, RWTH Aachen University
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
+ *********************************************************************************/
+
+#pragma once
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace CPS {
+namespace SP {
+namespace Ph1 {
+ /// \brief PI-line static phasor model
+ ///
+ /// For MNA this model consists sub components to represent the
+ /// RLC elements of a PI-line.
+ class PiLine :
+ public CompositePowerComp,
+ public Base::Ph1::PiLine,
+ public MNATearInterface,
+ public SharedFactory,
+ public PFSolverInterfaceBranch {
+ public:
+ ///base voltage [V]
+ const Attribute::Ptr mBaseVoltage;
+
+ // #### Power flow results ####
+ /// branch Current flow [A], coef(0) has data from node 0, coef(1) from node 1.
+ const Attribute::Ptr mCurrent;
+
+ /// branch active powerflow [W], coef(0) has data from node 0, coef(1) from node 1.
+ const Attribute::Ptr mActivePowerBranch;
+
+ /// branch reactive powerflow [Var], coef(0) has data from node 0, coef(1) from node 1.
+ const Attribute::Ptr mReactivePowerBranch;
+
+ protected:
+ /// CHECK: Which of these really need to be member variables?
+ ///base current [A]
+ Real mBaseCurrent;
+ ///base apparent power [VA]
+ Real mBaseApparentPower;
+ ///base omega [1/s]
+ Real mBaseOmega;
+ ///base impedance [Ohm]
+ Real mBaseImpedance;
+ ///base admittance [S]
+ Real mBaseAdmittance;
+ ///base inductance [H]
+ Real mBaseInductance;
+ ///base capacitance [F]
+ Real mBaseCapacitance;
+
+ ///resistance in [pu]
+ Real mSeriesResPerUnit;
+ ///Capacitance of the line in [pu]
+ Real mParallelCapPerUnit;
+ ///Inductance of the line in [pu]
+ Real mSeriesIndPerUnit;
+ ///Conductance of the line in [pu]
+ Real mParallelCondPerUnit;
+
+ // #### Admittance matrix stamp ####
+ MatrixComp mY_element;
+ /// Series Inductance submodel
+ std::shared_ptr mSubSeriesInductor;
+ /// Series Resistor submodel
+ std::shared_ptr mSubSeriesResistor;
+ /// Parallel Resistor submodel at Terminal 0
+ std::shared_ptr mSubParallelResistor0;
+ // Parallel Capacitor submodel at Terminal 0
+ std::shared_ptr mSubParallelCapacitor0;
+ /// Parallel resistor submodel at Terminal 1
+ std::shared_ptr mSubParallelResistor1;
+ /// Parallel capacitor submodel at Terminal 1
+ std::shared_ptr mSubParallelCapacitor1;
+ /// Right side vectors of subcomponents
+ std::vector mRightVectorStamps;
+ public:
+ /// nodal active power injection
+ const Attribute::Ptr mActivePowerInjection;
+ /// nodal reactive power injection
+ const Attribute::Ptr mReactivePowerInjection;
+
+ // #### General ####
+ /// Defines UID, name and logging level
+ PiLine(String uid, String name, Logger::Level logLevel = Logger::Level::off);
+ /// Defines name and logging level
+ PiLine(String name, Logger::Level logLevel = Logger::Level::off)
+ : PiLine(name, name, logLevel) { }
+ ///
+ SimPowerComp::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;
+
+ // #### Powerflow section ####
+ /// Set base voltage
+ void setBaseVoltage(Real baseVoltage);
+ /// Calculates component's parameters in specified per-unit system
+ void calculatePerUnitParameters(Real baseApparentPower, Real baseOmega);
+ /// Stamps admittance matrix
+ void pfApplyAdmittanceMatrixStamp(SparseMatrixCompRow & Y) override;
+ /// updates branch current and power flow, input pu value, update with real value
+ void updateBranchFlow(VectorComp& current, VectorComp& powerflow);
+ /// stores nodal injection power in this line object
+ void storeNodalInjection(Complex powerInjection);
+
+ // #### Getter ####
+ /// get admittance matrix
+ MatrixComp Y_element();
+
+ // #### MNA section ####
+ /// Updates internal current variable of the component
+ void mnaCompUpdateCurrent(const Matrix& leftVector) override;
+ /// Updates internal voltage variable of the component
+ void mnaCompUpdateVoltage(const Matrix& leftVector) override;
+ /// MNA post-step operations
+ void mnaParentPostStep(Real time, Int timeStepCount, Attribute::Ptr &leftVector) override;
+ /// add MNA post-step dependencies
+ void mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute::Ptr &leftVector) override;
+
+ MNAInterface::List mnaTearGroundComponents() override;
+ void mnaTearInitialize(Real omega, Real timeStep) override;
+ void mnaTearApplyMatrixStamp(SparseMatrixRow& tearMatrix) override;
+ void mnaTearApplyVoltageStamp(Matrix& voltageVector) override;
+ void mnaTearPostStep(Complex voltage, Complex current) override;
+ };
+}
+}
+}
diff --git a/dpsim-models/include/dpsim-models/SP/SP_Ph1_ResIndSeries.h b/dpsim-models/include/dpsim-models/SP/SP_Ph1_ResIndSeries.h
new file mode 100644
index 0000000000..26093af8ee
--- /dev/null
+++ b/dpsim-models/include/dpsim-models/SP/SP_Ph1_ResIndSeries.h
@@ -0,0 +1,64 @@
+/* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
+ * EONERC, RWTH Aachen University
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
+ *********************************************************************************/
+
+#pragma once
+
+#include
+#include
+
+namespace CPS {
+namespace SP {
+namespace Ph1 {
+ /// Static phasor ResIndSeries model (only implemented for dynamic simulations!)
+ class ResIndSeries :
+ public MNASimPowerComp,
+ public MNATearInterface,
+ public SharedFactory {
+ private:
+ /// Impedance
+ Complex mImpedance;
+ public:
+ /// Inductance [H]
+ const Attribute::Ptr mInductance;
+ ///Resistance [ohm]
+ const Attribute::Ptr mResistance;
+ /// Defines UID, name and logging level
+ ResIndSeries(String uid, String name, Logger::Level logLevel = Logger::Level::off);
+ /// Defines name and logging level
+ ResIndSeries(String name, Logger::Level logLevel = Logger::Level::off)
+ : ResIndSeries(name, name, logLevel) { }
+
+ SimPowerComp::Ptr clone(String name);
+
+ // #### General ####
+ /// Sets model specific parameters
+ void setParameters(Real resistance, Real inductance);
+ /// Initializes component from power flow data
+ void initializeFromNodesAndTerminals(Real frequency) override;
+
+
+ // #### MNA section ####
+ /// Initializes MNA specific variables
+ void mnaCompInitialize(Real omega, Real timeStep, Attribute::Ptr leftVector) override;
+ /// Stamps system matrix
+ void mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix) override;
+ /// Update interface voltage from MNA system result
+ void mnaCompUpdateVoltage(const Matrix& leftVector) override;
+ /// Update interface current from MNA system result
+ void mnaCompUpdateCurrent(const Matrix& leftVector) override;
+ /// MNA pre and post step operations
+ void mnaCompPostStep(Real time, Int timeStepCount, Attribute::Ptr &leftVector) override;
+ /// add MNA pre and post step dependencies
+ void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute::Ptr &leftVector) override;
+
+ // #### MNA Tear Section ####
+ void mnaTearApplyMatrixStamp(SparseMatrixRow& tearMatrix) override;
+ };
+}
+}
+}
diff --git a/dpsim-models/include/dpsim-models/SP/SP_Ph1_Resistor.h b/dpsim-models/include/dpsim-models/SP/SP_Ph1_Resistor.h
index 97a532b947..8ccea3bf06 100644
--- a/dpsim-models/include/dpsim-models/SP/SP_Ph1_Resistor.h
+++ b/dpsim-models/include/dpsim-models/SP/SP_Ph1_Resistor.h
@@ -55,7 +55,7 @@ namespace Ph1 {
// #### General ####
/// Initializes component from power flow data
- void initializeFromNodesAndTerminals(Real frequency);
+ void initializeFromNodesAndTerminals(Real frequency) override;
// #### Powerflow section ####
/// Set base voltage
@@ -67,20 +67,20 @@ namespace Ph1 {
// #### MNA section ####
///
- void mnaCompInitialize(Real omega, Real timeStep, Attribute::Ptr leftVector);
+ void mnaCompInitialize(Real omega, Real timeStep, Attribute::Ptr leftVector) override;
/// Stamps system matrix
- void mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix);
+ void mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix) override;
/// Update interface voltage from MNA system result
- void mnaCompUpdateVoltage(const Matrix& leftVector);
+ void mnaCompUpdateVoltage(const Matrix& leftVector) override;
/// Update interface current from MNA system result
- void mnaCompUpdateCurrent(const Matrix& leftVector);
+ void mnaCompUpdateCurrent(const Matrix& leftVector) override;
/// MNA pre and post step operations
- void mnaCompPostStep(Real time, Int timeStepCount, Attribute::Ptr &leftVector);
+ void mnaCompPostStep(Real time, Int timeStepCount, Attribute::Ptr &leftVector) override;
/// add MNA pre and post step dependencies
- void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute