DPsim
Loading...
Searching...
No Matches
DecouplingLine.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
17#include <dpsim-models/Task.h>
18
19namespace CPS {
20namespace Signal {
22 public SharedFactory<DecouplingLine> {
23protected:
28
29 std::shared_ptr<DP::SimNode> mNode1, mNode2;
30 std::shared_ptr<DP::Ph1::Resistor> mRes1, mRes2;
31 std::shared_ptr<DP::Ph1::CurrentSource> mSrc1, mSrc2;
33
34 // Ringbuffers for the values of previous timesteps
35 // TODO make these matrix attributes
36 std::vector<Complex> mVolt1, mVolt2, mCur1, mCur2;
40
41 Complex interpolate(std::vector<Complex> &data);
42
43public:
44 typedef std::shared_ptr<DecouplingLine> Ptr;
45
48
51
53 SimNode<Complex>::Ptr node2, Real resistance, Real inductance,
54 Real capacitance,
55 Logger::Level logLevel = Logger::Level::info);
56
57 DecouplingLine(String name, Logger::Level logLevel = Logger::Level::info);
58
60 Real resistance, Real inductance, Real capacitance);
61 void initialize(Real omega, Real timeStep);
62 void step(Real time, Int timeStepCount);
63 void postStep();
66
67 class PreStep : public Task {
68 public:
70 : Task(**line.mName + ".MnaPreStep"), mLine(line) {
71 mPrevStepDependencies.push_back(mLine.mStates);
72 mModifiedAttributes.push_back(mLine.mSrc1->mCurrentRef);
73 mModifiedAttributes.push_back(mLine.mSrc2->mCurrentRef);
74 }
75
76 void execute(Real time, Int timeStepCount);
77
78 private:
79 DecouplingLine &mLine;
80 };
81
82 class PostStep : public Task {
83 public:
85 : Task(**line.mName + ".PostStep"), mLine(line) {
86 mAttributeDependencies.push_back(mLine.mRes1->mIntfVoltage);
87 mAttributeDependencies.push_back(mLine.mRes1->mIntfCurrent);
88 mAttributeDependencies.push_back(mLine.mRes2->mIntfVoltage);
89 mAttributeDependencies.push_back(mLine.mRes2->mIntfCurrent);
90 mModifiedAttributes.push_back(mLine.mStates);
91 }
92
93 void execute(Real time, Int timeStepCount);
94
95 private:
96 DecouplingLine &mLine;
97 };
98};
99} // namespace Signal
100} // namespace CPS
AttributePointer< Attribute< T > > Ptr
Definition Attribute.h:250
std::vector< Ptr > List
spdlog::level::level_enum Level
Definition Logger.h:33
void execute(Real time, Int timeStepCount)
PostStep(DecouplingLine &line)
void execute(Real time, Int timeStepCount)
Attribute< Complex >::Ptr mSrcCur2
std::shared_ptr< DP::Ph1::CurrentSource > mSrc1
std::shared_ptr< DP::SimNode > mNode1
std::shared_ptr< DP::SimNode > mNode2
std::shared_ptr< DecouplingLine > Ptr
std::vector< Complex > mCur2
Attribute< Complex >::Ptr mSrcCur1
std::vector< Complex > mCur1
const Attribute< Complex >::Ptr mSrcCur1Ref
std::shared_ptr< DP::Ph1::CurrentSource > mSrc2
void setParameters(SimNode< Complex >::Ptr node1, SimNode< Complex >::Ptr node2, Real resistance, Real inductance, Real capacitance)
std::vector< Complex > mVolt2
Complex interpolate(std::vector< Complex > &data)
IdentifiedObject::List getLineComponents()
const Attribute< Matrix >::Ptr mStates
FIXME: workaround for dependency analysis as long as the states aren't attributes.
std::shared_ptr< DP::Ph1::Resistor > mRes1
const Attribute< Complex >::Ptr mSrcCur2Ref
void initialize(Real omega, Real timeStep)
void step(Real time, Int timeStepCount)
std::vector< Complex > mVolt1
DecouplingLine(String name, SimNode< Complex >::Ptr node1, SimNode< Complex >::Ptr node2, Real resistance, Real inductance, Real capacitance, Logger::Level logLevel=Logger::Level::info)
std::shared_ptr< DP::Ph1::Resistor > mRes2
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
std::complex< Real > Complex
Definition Definitions.h:63
unsigned int UInt
Definition Definitions.h:60