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:
28
29 std::shared_ptr<EMT::SimNode> mNode1, mNode2;
30 std::shared_ptr<EMT::Ph1::Resistor> mRes1, mRes2;
31 std::shared_ptr<EMT::Ph1::CurrentSource> mSrc1, mSrc2;
33
34 // Ringbuffers for the values of previous timesteps
35 // TODO make these matrix attributes
36 std::vector<Real> mVolt1, mVolt2, mCur1, mCur2;
40
41 Real interpolate(std::vector<Real> &data);
42
43public:
44 typedef std::shared_ptr<DecouplingLineEMT> Ptr;
45
48
51
52 DecouplingLineEMT(String name, Logger::Level logLevel = Logger::Level::info);
53
55 Real resistance, Real inductance, Real capacitance);
56 void initialize(Real omega, Real timeStep);
57 void step(Real time, Int timeStepCount);
58 void postStep();
61
62 class PreStep : public Task {
63 public:
65 : Task(**line.mName + ".MnaPreStep"), mLine(line) {
66 mPrevStepDependencies.push_back(mLine.mStates);
67 mModifiedAttributes.push_back(mLine.mSrc1->mCurrentRef);
68 mModifiedAttributes.push_back(mLine.mSrc2->mCurrentRef);
69 }
70
71 void execute(Real time, Int timeStepCount);
72
73 private:
74 DecouplingLineEMT &mLine;
75 };
76
77 class PostStep : public Task {
78 public:
80 : Task(**line.mName + ".PostStep"), mLine(line) {
81 mAttributeDependencies.push_back(mLine.mRes1->mIntfVoltage);
82 mAttributeDependencies.push_back(mLine.mRes1->mIntfCurrent);
83 mAttributeDependencies.push_back(mLine.mRes2->mIntfVoltage);
84 mAttributeDependencies.push_back(mLine.mRes2->mIntfCurrent);
85 mModifiedAttributes.push_back(mLine.mStates);
86 }
87
88 void execute(Real time, Int timeStepCount);
89
90 private:
91 DecouplingLineEMT &mLine;
92 };
93};
94} // namespace Signal
95} // namespace CPS
AttributePointer< Attribute< T > > Ptr
Definition Attribute.h:250
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:32
SimSignalComp(String uid, String name, Logger::Level logLevel=Logger::Level::off)
std::vector< AttributeBase::Ptr > mModifiedAttributes
Definition Task.h:53
std::vector< AttributeBase::Ptr > mPrevStepDependencies
Definition Task.h:54
std::vector< AttributeBase::Ptr > mAttributeDependencies
Definition Task.h:52
Task()
Definition Task.h:30
std::vector< Ptr > List
Definition Task.h:28
std::string mName
Definition Task.h:51
struct dps_magma_data data
std::string String
Definition Definitions.h:65
double Real
Definition Definitions.h:62
int Int
Definition Definitions.h:61
unsigned int UInt
Definition Definitions.h:60