DPsim
Loading...
Searching...
No Matches
DecouplingIdealTransformer_EMT_Ph1.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Institute for Automation of Complex Power Systems, EONERC, RWTH Aachen University
2// SPDX-License-Identifier: MPL-2.0
3
4#pragma once
5
6#include <vector>
7
13#include <dpsim-models/Task.h>
14
15namespace CPS {
16namespace Signal {
17
19 : public SimSignalComp,
20 public SharedFactory<DecouplingIdealTransformer_EMT_Ph1> {
21protected:
25
26 std::shared_ptr<EMT::SimNode> mNode1, mNode2, mVirtualNode;
27 std::shared_ptr<EMT::Ph1::Resistor> mRes1, mRes2;
28 std::shared_ptr<EMT::Ph1::CurrentSource> mCurrentSrc;
29 std::shared_ptr<EMT::Ph1::VoltageSource> mVoltageSrc;
31
32 // Ringbuffers for the values of previous timesteps
33 // TODO make these matrix attributes
34 std::vector<Real> mCur1, mVol2;
35
36 // Copy of the most recent elements of the ring buffers
37 // They are used to perform extrapolation
38 std::vector<Real> mCur1Extrap, mVol2Extrap;
40
47 Eigen::MatrixXd mVoltageSrcIntfCurr;
48
49 // Get an approximate value of the signal in between steps when the delay is not an integer multiple of the step size
50 Real interpolate(std::vector<Real> &data);
51
52 // Estimates the value of the input signal in the next step
53 Real extrapolate(std::vector<Real> &data);
54
55public:
56 typedef std::shared_ptr<DecouplingIdealTransformer_EMT_Ph1> Ptr;
57
62
65
67 String name, Logger::Level logLevel = Logger::Level::info);
68
70 Real delay, Matrix voltageSrcIntfCurr,
71 Real current1Extrap0,
73 void initialize(Real omega, Real timeStep);
74 void step(Real time, Int timeStepCount);
75 void postStep();
79
80 class PreStep : public Task {
81 public:
83 : Task(**itm.mName + ".MnaPreStep"), mITM(itm) {
84 mPrevStepDependencies.push_back(mITM.mStates);
85 mModifiedAttributes.push_back(mITM.mVoltageSrc->mVoltageRef);
86 mModifiedAttributes.push_back(mITM.mCurrentSrc->mCurrentRef);
87 }
88
89 void execute(Real time, Int timeStepCount);
90
91 private:
93 };
94
95 class PostStep : public Task {
96 public:
98 : Task(**itm.mName + ".PostStep"), mITM(itm) {
99 mAttributeDependencies.push_back(mITM.mVoltageSrc->mIntfVoltage);
100 mAttributeDependencies.push_back(mITM.mVoltageSrc->mIntfCurrent);
101 mAttributeDependencies.push_back(mITM.mCurrentSrc->mIntfVoltage);
102 mAttributeDependencies.push_back(mITM.mCurrentSrc->mIntfCurrent);
103 mModifiedAttributes.push_back(mITM.mStates);
104 }
105
106 void execute(Real time, Int timeStepCount);
107
108 private:
110 };
111};
112} // namespace Signal
113} // namespace CPS
AttributePointer< Attribute< T > > Ptr
Definition Attribute.h:250
std::vector< Ptr > List
spdlog::level::level_enum Level
Definition Logger.h:33
PostStep(DecouplingIdealTransformer_EMT_Ph1 &itm)
void execute(Real time, Int timeStepCount)
void setParameters(SimNode< Real >::Ptr node1, SimNode< Real >::Ptr node2, Real delay, Matrix voltageSrcIntfCurr, Real current1Extrap0, CouplingMethod method=CouplingMethod::DELAY)
DecouplingIdealTransformer_EMT_Ph1(String name, Logger::Level logLevel=Logger::Level::info)
std::shared_ptr< DecouplingIdealTransformer_EMT_Ph1 > Ptr
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
std::shared_ptr< TopologicalNode > Ptr
struct dps_magma_data data
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > Matrix
Dense matrix for real numbers.
Definition Definitions.h:81
std::string String
Definition Definitions.h:65
double Real
Definition Definitions.h:62
CouplingMethod
int Int
Definition Definitions.h:61
unsigned int UInt
Definition Definitions.h:60