DPsim
Loading...
Searching...
No Matches
DecouplingLineEMT.h
Go to the documentation of this file.
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 <vector>
12
16#include <dpsim-models/Task.h>
17
18namespace CPS {
19namespace Signal {
21 public SharedFactory<DecouplingLineEMT> {
22protected:
32
33 std::shared_ptr<EMT::SimNode> mNode1, mNode2;
34 std::shared_ptr<EMT::Ph1::Resistor> mRes1, mRes2;
35 std::shared_ptr<EMT::Ph1::CurrentSource> mSrc1, mSrc2;
37
38 // Ringbuffers for the values of previous timesteps
39 // TODO make these matrix attributes
40 std::vector<Real> mVolt1, mVolt2, mCur1, mCur2;
44
45 Real interpolate(std::vector<Real> &data);
46
47public:
48 typedef std::shared_ptr<DecouplingLineEMT> Ptr;
49
52
55
56 DecouplingLineEMT(String name, Logger::Level logLevel = Logger::Level::info);
57
59 Real resistance, Real inductance, Real capacitance);
60 void initialize(Real omega, Real timeStep);
61 void step(Real time, Int timeStepCount);
62 void postStep();
65
66 class PreStep : public Task {
67 public:
69 : Task(**line.mName + ".MnaPreStep"), mLine(line) {
70 mPrevStepDependencies.push_back(mLine.mStates);
71 mModifiedAttributes.push_back(mLine.mSrc1->mCurrentRef);
72 mModifiedAttributes.push_back(mLine.mSrc2->mCurrentRef);
73 }
74
75 void execute(Real time, Int timeStepCount);
76
77 private:
78 DecouplingLineEMT &mLine;
79 };
80
81 class PostStep : public Task {
82 public:
84 : Task(**line.mName + ".PostStep"), mLine(line) {
85 mAttributeDependencies.push_back(mLine.mRes1->mIntfVoltage);
86 mAttributeDependencies.push_back(mLine.mRes1->mIntfCurrent);
87 mAttributeDependencies.push_back(mLine.mRes2->mIntfVoltage);
88 mAttributeDependencies.push_back(mLine.mRes2->mIntfCurrent);
89 mModifiedAttributes.push_back(mLine.mStates);
90 }
91
92 void execute(Real time, Int timeStepCount);
93
94 private:
95 DecouplingLineEMT &mLine;
96 };
97};
98} // namespace Signal
99} // namespace CPS
AttributePointer< Attribute< T > > Ptr
Definition Attribute.h:249
std::vector< Ptr > List
spdlog::level::level_enum Level
Definition Logger.h:33
PostStep(DecouplingLineEMT &line)
void execute(Real time, Int timeStepCount)
void execute(Real time, Int timeStepCount)
void initialize(Real omega, Real timeStep)
DecouplingLineEMT(String name, Logger::Level logLevel=Logger::Level::info)
Real interpolate(std::vector< Real > &data)
void setParameters(SimNode< Real >::Ptr node1, SimNode< Real >::Ptr node2, Real resistance, Real inductance, Real capacitance)
std::shared_ptr< EMT::SimNode > mNode2
Attribute< Complex >::Ptr mSrcCur2
std::shared_ptr< EMT::Ph1::Resistor > mRes2
IdentifiedObject::List getLineComponents()
std::shared_ptr< DecouplingLineEMT > Ptr
std::shared_ptr< EMT::Ph1::Resistor > mRes1
const Attribute< Real >::Ptr mSrcCur1Ref
std::shared_ptr< EMT::Ph1::CurrentSource > mSrc2
Attribute< Complex >::Ptr mSrcCur1
void step(Real time, Int timeStepCount)
const Attribute< Real >::Ptr mSrcCur2Ref
std::shared_ptr< EMT::Ph1::CurrentSource > mSrc1
std::shared_ptr< EMT::SimNode > mNode1
const Attribute< Matrix >::Ptr mStates
FIXME: workaround for dependency analysis as long as the states aren't attributes.
std::shared_ptr< SimNode< VarType > > Ptr
Definition SimNode.h:34
SimSignalComp(String uid, String name, Logger::Level logLevel=Logger::Level::off)
std::vector< AttributeBase::Ptr > mModifiedAttributes
Definition Task.h:70
std::vector< AttributeBase::Ptr > mPrevStepDependencies
Definition Task.h:71
std::vector< AttributeBase::Ptr > mAttributeDependencies
Definition Task.h:69
Task()
Definition Task.h:30
std::vector< Ptr > List
Definition Task.h:28
std::string mName
Definition Task.h:68
struct dps_magma_data data
std::string String
Definition Definitions.h:63
double Real
Definition Definitions.h:60
int Int
Definition Definitions.h:59
unsigned int UInt
Definition Definitions.h:58