DPsim
Loading...
Searching...
No Matches
DecouplingLineEMT_Ph3.h
1/* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
2 * EONERC, RWTH Aachen University
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7 *********************************************************************************/
8
9#pragma once
10
11#include "dpsim-models/Definitions.h"
12#include "dpsim-models/EMT/EMT_Ph3_ControlledCurrentSource.h"
13#include <vector>
14
15#include <dpsim-models/EMT/EMT_Ph3_Resistor.h>
16#include <dpsim-models/SimSignalComp.h>
17#include <dpsim-models/Task.h>
18
19namespace CPS {
20namespace Signal {
21class DecouplingLineEMT_Ph3 : public SimSignalComp,
22 public SharedFactory<DecouplingLineEMT_Ph3> {
23protected:
24 Real mDelay;
25 Matrix mResistance = Matrix::Zero(3, 3);
26 Matrix mInductance = Matrix::Zero(3, 3);
27 Matrix mCapacitance = Matrix::Zero(3, 3);
28 Matrix mSurgeImpedance;
29
30 std::shared_ptr<EMT::SimNode> mNode1, mNode2;
31 std::shared_ptr<EMT::Ph3::Resistor> mRes1, mRes2;
32 std::shared_ptr<EMT::Ph3::ControlledCurrentSource> mSrc1, mSrc2;
33 Attribute<Matrix>::Ptr mSrcCur1, mSrcCur2;
34
35 // Ringbuffers for the values of previous timesteps
36 // TODO make these matrix attributes
37 Matrix mVolt1, mVolt2, mCur1, mCur2;
38 UInt mBufIdx = 0;
39 UInt mBufSize;
40 Real mAlpha;
41
42 Matrix interpolate(Matrix &data);
43
44public:
45 typedef std::shared_ptr<DecouplingLineEMT_Ph3> Ptr;
46
47 const Attribute<Matrix>::Ptr mSrcCur1Ref;
48 const Attribute<Matrix>::Ptr mSrcCur2Ref;
49
51 const Attribute<Matrix>::Ptr mStates;
52
53 DecouplingLineEMT_Ph3(String name,
54 Logger::Level logLevel = Logger::Level::info);
55
56 void setParameters(SimNode<Real>::Ptr node1, SimNode<Real>::Ptr node2,
57 Matrix resistance, Matrix inductance, Matrix capacitance);
58 void initialize(Real omega, Real timeStep);
59 void step(Real time, Int timeStepCount);
60 void postStep();
61 Task::List getTasks();
62 IdentifiedObject::List getLineComponents();
63
64 class PreStep : public Task {
65 public:
66 PreStep(DecouplingLineEMT_Ph3 &line)
67 : Task(**line.mName + ".MnaPreStep"), mLine(line) {
68 mPrevStepDependencies.push_back(mLine.mStates);
69 mModifiedAttributes.push_back(mLine.mSrc1->mCurrentRef);
70 mModifiedAttributes.push_back(mLine.mSrc2->mCurrentRef);
71 }
72
73 void execute(Real time, Int timeStepCount);
74
75 private:
76 DecouplingLineEMT_Ph3 &mLine;
77 };
78
79 class PostStep : public Task {
80 public:
81 PostStep(DecouplingLineEMT_Ph3 &line)
82 : Task(**line.mName + ".PostStep"), mLine(line) {
83 mAttributeDependencies.push_back(mLine.mRes1->mIntfVoltage);
84 mAttributeDependencies.push_back(mLine.mRes1->mIntfCurrent);
85 mAttributeDependencies.push_back(mLine.mRes2->mIntfVoltage);
86 mAttributeDependencies.push_back(mLine.mRes2->mIntfCurrent);
87 mModifiedAttributes.push_back(mLine.mStates);
88 }
89
90 void execute(Real time, Int timeStepCount);
91
92 private:
93 DecouplingLineEMT_Ph3 &mLine;
94 };
95};
96} // namespace Signal
97} // namespace CPS
const Attribute< String >::Ptr mName
Human readable name.
const Attribute< Matrix >::Ptr mStates
FIXME: workaround for dependency analysis as long as the states aren't attributes.