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:
33
34 std::shared_ptr<DP::SimNode> mNode1, mNode2;
35 std::shared_ptr<DP::Ph1::Resistor> mRes1, mRes2;
36 std::shared_ptr<DP::Ph1::CurrentSource> mSrc1, mSrc2;
38
39 // Ringbuffers for the values of previous timesteps
40 // TODO make these matrix attributes
41 std::vector<Complex> mVolt1, mVolt2, mCur1, mCur2;
45
46 Complex interpolate(std::vector<Complex> &data);
47
48public:
49 typedef std::shared_ptr<DecouplingLine> Ptr;
50
53
56
58 SimNode<Complex>::Ptr node2, Real resistance, Real inductance,
59 Real capacitance,
60 Logger::Level logLevel = Logger::Level::info);
61
62 DecouplingLine(String name, Logger::Level logLevel = Logger::Level::info);
63
65 Real resistance, Real inductance, Real capacitance);
66 void initialize(Real omega, Real timeStep);
67 void step(Real time, Int timeStepCount);
68 void postStep();
71
72 class PreStep : public Task {
73 public:
75 : Task(**line.mName + ".MnaPreStep"), mLine(line) {
76 mPrevStepDependencies.push_back(mLine.mStates);
77 mModifiedAttributes.push_back(mLine.mSrc1->mCurrentRef);
78 mModifiedAttributes.push_back(mLine.mSrc2->mCurrentRef);
79 }
80
81 void execute(Real time, Int timeStepCount);
82
83 private:
84 DecouplingLine &mLine;
85 };
86
87 class PostStep : public Task {
88 public:
90 : Task(**line.mName + ".PostStep"), mLine(line) {
91 mAttributeDependencies.push_back(mLine.mRes1->mIntfVoltage);
92 mAttributeDependencies.push_back(mLine.mRes1->mIntfCurrent);
93 mAttributeDependencies.push_back(mLine.mRes2->mIntfVoltage);
94 mAttributeDependencies.push_back(mLine.mRes2->mIntfCurrent);
95 mModifiedAttributes.push_back(mLine.mStates);
96 }
97
98 void execute(Real time, Int timeStepCount);
99
100 private:
101 DecouplingLine &mLine;
102 };
103};
104} // namespace Signal
105} // namespace CPS
AttributePointer< Attribute< T > > Ptr
Definition Attribute.h:249
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: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
std::complex< Real > Complex
Definition Definitions.h:61
unsigned int UInt
Definition Definitions.h:58