DPsim
Loading...
Searching...
No Matches
DP_Ph1_Resistor.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
15
16namespace CPS {
17namespace DP {
18namespace Ph1 {
20class Resistor : public MNASimPowerComp<Complex>,
22 public MNATearInterface,
23 public DAEInterface,
24 public SharedFactory<Resistor> {
25public:
28 Logger::Level loglevel = Logger::Level::off);
30 Resistor(String name, Logger::Level logLevel = Logger::Level::off)
31 : Resistor(name, name, logLevel) {}
32
34
35 // #### General ####
38
39 // #### MNA section ####
40 void mnaCompInitialize(Real omega, Real timeStep,
41 Attribute<Matrix>::Ptr leftVector);
42 void mnaCompInitializeHarm(Real omega, Real timeStep,
43 std::vector<Attribute<Matrix>::Ptr> leftVector);
48 Int freqIdx);
50 void mnaCompUpdateVoltage(const Matrix &leftVector);
51 void mnaCompUpdateVoltageHarm(const Matrix &leftVector, Int freqIdx);
53 void mnaCompUpdateCurrent(const Matrix &leftVector);
56 void mnaCompPostStep(Real time, Int timeStepCount,
57 Attribute<Matrix>::Ptr &leftVector);
59 void
61 AttributeBase::List &attributeDependencies,
62 AttributeBase::List &modifiedAttributes,
63 Attribute<Matrix>::Ptr &leftVector);
64
65 class MnaPostStepHarm : public Task {
66 public:
68 std::vector<Attribute<Matrix>::Ptr> &leftVectors)
69 : Task(**resistor.mName + ".MnaPostStepHarm"), mResistor(resistor),
70 mLeftVectors(leftVectors) {
71 for (UInt i = 0; i < mLeftVectors.size(); i++)
72 mAttributeDependencies.push_back(mLeftVectors[i]);
73 mModifiedAttributes.push_back(mResistor.attribute("v_intf"));
74 mModifiedAttributes.push_back(mResistor.attribute("i_intf"));
75 }
76 void execute(Real time, Int timeStepCount);
77
78 private:
79 Resistor &mResistor;
80 std::vector<Attribute<Matrix>::Ptr> mLeftVectors;
81 };
82
83 // #### MNA Tear Section ####
85
86 // #### DAE Section ####
88 void daeResidual(double ttime, const double state[], const double dstate_dt[],
89 double resid[], std::vector<int> &off);
92};
93} // namespace Ph1
94} // namespace DP
95} // namespace CPS
std::vector< Ptr > List
Definition Attribute.h:123
AttributePointer< Attribute< T > > Ptr
Definition Attribute.h:250
void execute(Real time, Int timeStepCount)
MnaPostStepHarm(Resistor &resistor, std::vector< Attribute< Matrix >::Ptr > &leftVectors)
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector)
Complex daeInitialize()
Voltage Getter.
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector)
add MNA pre and post step dependencies
void mnaCompInitializeHarm(Real omega, Real timeStep, std::vector< Attribute< Matrix >::Ptr > leftVector)
void mnaCompApplySystemMatrixStampHarm(SparseMatrixRow &systemMatrix, Int freqIdx)
Stamps system matrix considering the frequency index.
Resistor(String uid, String name, Logger::Level loglevel=Logger::Level::off)
Defines UID, name and logging level.
void mnaCompPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector)
MNA pre and post step operations.
void daeResidual(double ttime, const double state[], const double dstate_dt[], double resid[], std::vector< int > &off)
Residual Function for DAE Solver.
void mnaCompUpdateCurrent(const Matrix &leftVector)
Update interface current from MNA system result.
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix)
Stamps system matrix.
SimPowerComp< Complex >::Ptr clone(String name)
Returns a modified copy of the component with the given suffix added to the name and without.
void mnaCompUpdateVoltageHarm(const Matrix &leftVector, Int freqIdx)
void mnaTearApplyMatrixStamp(SparseMatrixRow &tearMatrix)
void mnaCompUpdateVoltage(const Matrix &leftVector)
Update interface voltage from MNA system result.
void initializeFromNodesAndTerminals(Real frequency)
Initializes component from power flow data.
Resistor(String name, Logger::Level logLevel=Logger::Level::off)
Defines name and logging level.
String uid()
Returns unique id.
spdlog::level::level_enum Level
Definition Logger.h:33
MNASimPowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
std::shared_ptr< SimPowerComp< VarType > > Ptr
std::vector< AttributeBase::Ptr > mModifiedAttributes
Definition Task.h:53
std::vector< AttributeBase::Ptr > mAttributeDependencies
Definition Task.h:52
Task()
Definition Task.h:30
std::string mName
Definition Task.h:51
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
int Int
Definition Definitions.h:61
std::complex< Real > Complex
Definition Definitions.h:63
unsigned int UInt
Definition Definitions.h:60
Eigen::SparseMatrix< Real, Eigen::RowMajor > SparseMatrixRow
Sparse matrix for real numbers (row major).
Definition Definitions.h:74