Skip to content

Commit 37bcc73

Browse files
committed
Add internal resistors to 3-phase decoupling ITM,
Signed-off-by: pipeacosta <pipeacosta@gmail.com>
1 parent 38abe56 commit 37bcc73

6 files changed

Lines changed: 34 additions & 6 deletions

File tree

dpsim-models/include/dpsim-models/Signal/DecouplingIdealTransformer_EMT_Ph3.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "dpsim-models/Definitions.h"
1414
#include "dpsim-models/EMT/EMT_Ph3_ControlledVoltageSource.h"
15+
#include "dpsim-models/MathUtils.h"
1516
#include <dpsim-models/EMT/EMT_Ph3_ControlledCurrentSource.h>
1617
#include <dpsim-models/EMT/EMT_Ph3_Resistor.h>
1718
#include <dpsim-models/SimSignalComp.h>
@@ -25,7 +26,13 @@ class DecouplingIdealTransformer_EMT_Ph3
2526
public SharedFactory<DecouplingIdealTransformer_EMT_Ph3> {
2627
protected:
2728
Real mDelay;
28-
std::shared_ptr<EMT::SimNode> mNode1, mNode2;
29+
Matrix mInternalSeriesResistance =
30+
CPS::Math::singlePhaseParameterToThreePhase(1e-6);
31+
Matrix mInternalParallelResistance =
32+
CPS::Math::singlePhaseParameterToThreePhase(1e6);
33+
34+
std::shared_ptr<EMT::SimNode> mNode1, mNode2, mVirtualNode;
35+
std::shared_ptr<EMT::Ph3::Resistor> mRes1, mRes2;
2936
std::shared_ptr<EMT::Ph3::ControlledCurrentSource> mCurrentSrc;
3037
std::shared_ptr<EMT::Ph3::ControlledVoltageSource> mVoltageSrc;
3138
Attribute<Matrix>::Ptr mSrcCurrent, mSrcVoltage;
@@ -73,6 +80,7 @@ class DecouplingIdealTransformer_EMT_Ph3
7380
void postStep();
7481
Task::List getTasks();
7582
IdentifiedObject::List getComponents();
83+
TopologicalNode::Ptr getVirtualNode();
7684

7785
class PreStep : public Task {
7886
public:

dpsim-models/src/Signal/DecouplingIdealTransformer_EMT_Ph3.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*********************************************************************************/
88

99
#include "dpsim-models/Definitions.h"
10+
#include "dpsim-models/TopologicalNode.h"
1011
#include <dpsim-models/Signal/DecouplingIdealTransformer_EMT_Ph3.h>
1112

1213
using namespace CPS;
@@ -24,6 +25,8 @@ DecouplingIdealTransformer_EMT_Ph3::DecouplingIdealTransformer_EMT_Ph3(
2425
mSrcVoltageRef(mAttributes->create<Matrix>("v_ref", Matrix::Zero(3, 1))),
2526
mSrcCurrentRef(mAttributes->create<Matrix>("i_ref", Matrix::Zero(3, 1))) {
2627

28+
mRes1 = Resistor::make(name + "_r1", logLevel);
29+
mRes2 = Resistor::make(name + "_r2", logLevel);
2730
mVoltageSrc = ControlledVoltageSource::make(name + "_v", logLevel);
2831
mCurrentSrc = ControlledCurrentSource::make(name + "_i", logLevel);
2932

@@ -37,6 +40,7 @@ void DecouplingIdealTransformer_EMT_Ph3::setParameters(
3740

3841
mNode1 = node1;
3942
mNode2 = node2;
43+
mVirtualNode = SimNode<Real>::make(name() + "_virtual", PhaseType::ABC);
4044

4145
mDelay = delay;
4246
mCouplingMethod = method;
@@ -45,10 +49,14 @@ void DecouplingIdealTransformer_EMT_Ph3::setParameters(
4549
mExtrapolationDegree = 1;
4650
}
4751

52+
mRes1->setParameters(mInternalSeriesResistance);
53+
mRes1->connect({node1, mVirtualNode});
54+
mRes2->setParameters(mInternalParallelResistance);
55+
mRes2->connect({node2, SimNode<Real>::GND});
4856
mVoltageSrc->setParameters(Matrix::Zero(3, 1));
4957
mVoltageSrcIntfCurr = voltageSrcIntfCurr;
5058
mCurrent1Extrap0 = current1Extrap0;
51-
mVoltageSrc->connect({SimNode<Real>::GND, node1});
59+
mVoltageSrc->connect({SimNode<Real>::GND, mVirtualNode});
5260
mCurrentSrc->setParameters(Matrix::Zero(3, 1));
5361
mCurrentSrc->connect({node2, SimNode<Real>::GND});
5462
}
@@ -68,6 +76,9 @@ void DecouplingIdealTransformer_EMT_Ph3::initialize(Real omega, Real timeStep) {
6876
MatrixComp cur1 = mVoltageSrc->mIntfCurrent->get();
6977
MatrixComp volt2 = mNode2->initialVoltage();
7078

79+
mVirtualNode->setInitialVoltage(mNode1->initialVoltage() -
80+
mInternalSeriesResistance * cur1);
81+
7182
SPDLOG_LOGGER_INFO(mSLog, "initial current: i_1 {}", cur1);
7283
SPDLOG_LOGGER_INFO(mSLog, "initial voltage: v_2 {}", volt2);
7384

@@ -176,5 +187,9 @@ Task::List DecouplingIdealTransformer_EMT_Ph3::getTasks() {
176187
}
177188

178189
IdentifiedObject::List DecouplingIdealTransformer_EMT_Ph3::getComponents() {
179-
return IdentifiedObject::List({mVoltageSrc, mCurrentSrc});
190+
return IdentifiedObject::List({mRes1, mRes2, mVoltageSrc, mCurrentSrc});
191+
}
192+
193+
TopologicalNode::Ptr DecouplingIdealTransformer_EMT_Ph3::getVirtualNode() {
194+
return mVirtualNode;
180195
}

dpsim/examples/cxx/Circuits/EMT_RC_split_decoupled_node_Ph3.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ void decoupleNode(SystemTopology &sys, const String &nodeName,
109109
i_inf_0, cosimMethod);
110110
sys.addComponent(idealTrafo);
111111
sys.addComponents(idealTrafo->getComponents());
112+
sys.addNode(idealTrafo->getVirtualNode());
112113
}
113114

114115
void doSim(String &name, SystemTopology &sys, Int threads, Real ts,

dpsim/src/pybind/SignalComponents.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ void addSignalComponents(py::module_ mSignal) {
9999
"node_1"_a, "node_2"_a, "delay"_a, "v_src_intf_cur"_a,
100100
"cur1_extrap_0"_a, "coupling_method"_a)
101101
.def("get_components",
102-
&CPS::Signal::DecouplingIdealTransformer_EMT_Ph3::getComponents);
102+
&CPS::Signal::DecouplingIdealTransformer_EMT_Ph3::getComponents)
103+
.def("get_virtual_node",
104+
&CPS::Signal::DecouplingIdealTransformer_EMT_Ph3::getVirtualNode);
103105

104106
py::class_<CPS::Signal::Exciter, std::shared_ptr<CPS::Signal::Exciter>,
105107
CPS::SimSignalComp>(mSignal, "Exciter", py::multiple_inheritance())

examples/Notebooks/Components/ITM.ipynb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
"\n",
113113
"sys = dpsimpy.SystemTopology(f_1, [n0, n1_1, n1_2, n2], [vs, R_1, line, itm, load])\n",
114114
"sys.add(itm.get_components())\n",
115+
"sys.add_node(itm.get_virtual_node())\n",
115116
"\n",
116117
"logger = dpsimpy.Logger(sim_name)\n",
117118
"logger.log_attribute(\"v1_1\", \"v\", n1_1)\n",
@@ -124,11 +125,12 @@
124125
"logger.log_attribute(\"v_intf_itm\", \"v_intf\", itm)\n",
125126
"logger.log_attribute(\"iload\", \"i_intf\", load)\n",
126127
"\n",
127-
"sim = dpsimpy.Simulation(sim_name)\n",
128+
"sim = dpsimpy.Simulation(sim_name, dpsimpy.LogLevel.debug)\n",
128129
"sim.set_system(sys)\n",
129130
"sim.set_time_step(time_step)\n",
130131
"sim.set_final_time(final_time)\n",
131132
"sim.set_domain(dpsimpy.Domain.EMT)\n",
133+
"sim.do_split_subnets(True)\n",
132134
"sim.add_logger(logger)\n",
133135
"\n",
134136
"sim.run()"

examples/Notebooks/Performance/EMT_RC_split_node_Ph3.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
{
1818
"cell_type": "code",
19-
"execution_count": 1,
19+
"execution_count": null,
2020
"metadata": {},
2121
"outputs": [],
2222
"source": [

0 commit comments

Comments
 (0)