DPsim
Loading...
Searching...
No Matches
DecouplingIdealTransformer_DP_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
15#include <dpsim-models/Task.h>
16
17namespace CPS {
18namespace Signal {
20 : public SimSignalComp,
21 public SharedFactory<DecouplingIdealTransformer_DP_Ph1> {
22protected:
26
27 std::shared_ptr<DP::SimNode> mNode1, mNode2, mVirtualNode;
28 std::shared_ptr<DP::Ph1::Resistor> mRes1, mRes2;
29 std::shared_ptr<DP::Ph1::ControlledCurrentSource> mCurrentSrc;
30 std::shared_ptr<DP::Ph1::ControlledVoltageSource> mVoltageSrc;
32
33 // Ringbuffers for the values of previous timesteps
34 // TODO make these matrix attributes
35 std::vector<Complex> mCur1, mVol2;
36
37 // Copy of the most recent elements of the ring buffers
38 // They are used to perform extrapolation
39 std::vector<Complex> mCur1Extrap, mVol2Extrap;
41
49
50 // Get an approximate value of the signal in between steps when the delay is not an integer multiple of the step size
51 Complex interpolate(std::vector<Complex> &data);
52
53 // Estimates the value of the input signal in the next step
54 Complex extrapolate(std::vector<Complex> &data);
55
56public:
57 typedef std::shared_ptr<DecouplingIdealTransformer_DP_Ph1> Ptr;
58
63
66
68 String name, Logger::Level logLevel = Logger::Level::info);
69
71 Real delay, Matrix voltageSrcIntfCurr,
72 Complex current1Extrap0,
74 void initialize(Real omega, Real timeStep);
75 void step(Real time, Int timeStepCount);
76 void postStep();
80
81 class PreStep : public Task {
82 public:
84 : Task(**itm.mName + ".MnaPreStep"), mITM(itm) {
85 mPrevStepDependencies.push_back(mITM.mStates);
86 mModifiedAttributes.push_back(mITM.mVoltageSrc->mVoltageRef);
87 mModifiedAttributes.push_back(mITM.mCurrentSrc->mCurrentRef);
88 }
89
90 void execute(Real time, Int timeStepCount);
91
92 private:
94 };
95
96 class PostStep : public Task {
97 public:
99 : Task(**itm.mName + ".PostStep"), mITM(itm) {
100 mAttributeDependencies.push_back(mITM.mVoltageSrc->mIntfVoltage);
101 mAttributeDependencies.push_back(mITM.mVoltageSrc->mIntfCurrent);
102 mAttributeDependencies.push_back(mITM.mCurrentSrc->mIntfVoltage);
103 mAttributeDependencies.push_back(mITM.mCurrentSrc->mIntfCurrent);
104 mModifiedAttributes.push_back(mITM.mStates);
105 }
106
107 void execute(Real time, Int timeStepCount);
108
109 private:
111 };
112};
113} // namespace Signal
114} // 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_DP_Ph1 &itm)
void execute(Real time, Int timeStepCount)
std::shared_ptr< DP::Ph1::ControlledCurrentSource > mCurrentSrc
std::shared_ptr< DP::Ph1::ControlledVoltageSource > mVoltageSrc
void setParameters(SimNode< Complex >::Ptr node1, SimNode< Complex >::Ptr node2, Real delay, Matrix voltageSrcIntfCurr, Complex current1Extrap0, CouplingMethod method=CouplingMethod::DELAY)
DecouplingIdealTransformer_DP_Ph1(String name, Logger::Level logLevel=Logger::Level::info)
const Attribute< Matrix >::Ptr mStates
FIXME: workaround for dependency analysis as long as the states aren't attributes.
std::shared_ptr< DecouplingIdealTransformer_DP_Ph1 > Ptr
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
std::complex< Real > Complex
Definition Definitions.h:63
unsigned int UInt
Definition Definitions.h:60