DPsim
Loading...
Searching...
No Matches
SP_Ph3_RxLine.h
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 <dpsim-models/Base/Base_Ph3_PiLine.h>
12#include <dpsim-models/MNASimPowerComp.h>
13#include <dpsim-models/SP/SP_Ph3_Inductor.h>
14#include <dpsim-models/SP/SP_Ph3_Resistor.h>
15#include <dpsim-models/Solver/MNAInterface.h>
16
17namespace CPS {
18namespace SP {
19namespace Ph3 {
20
21class RxLine : public MNASimPowerComp<Real>,
22 public Base::Ph3::PiLine,
23 public SharedFactory<RxLine> {
24protected:
26 Matrix mVoltage;
28 Matrix mCurrent;
30 std::shared_ptr<Inductor> mSubInductor;
32 std::shared_ptr<Resistor> mSubResistor;
34 std::shared_ptr<Resistor> mInitialResistor;
35
36public:
38 RxLine(String uid, String name, Logger::Level logLevel = Logger::Level::off);
40 RxLine(String name, Logger::Level logLevel = Logger::Level::off)
41 : RxLine(name, name, logLevel) {}
42
43 SimPowerComp<Real>::Ptr clone(String name);
44
45 // #### General ####
47 void initializeFromNodesAndTerminals(Real frequency);
48
49 // #### MNA section ####
51 void mnaCompInitialize(Real omega, Real timeStep,
52 Attribute<Matrix>::Ptr leftVector);
54 void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix);
56 void mnaApplyInitialSystemMatrixStamp(SparseMatrixRow &systemMatrix);
58 void mnaCompApplyRightSideVectorStamp(Matrix &rightVector);
59 void mnaCompUpdateVoltage(const Matrix &leftVector);
60 void mnaCompUpdateCurrent(const Matrix &leftVector);
61
64 AttributeBase::List &prevStepDependencies,
65 AttributeBase::List &attributeDependencies,
66 AttributeBase::List &modifiedAttributes) override;
67 void mnaCompAddPreStepDependencies(AttributeBase::List &prevStepDependencies,
68 AttributeBase::List &attributeDependencies,
69 AttributeBase::List &modifiedAttributes) {
70 mAttributeDependencies.push_back(
71 line.mSubResistor->attribute("right_vector"));
72 mAttributeDependencies.push_back(
73 line.mSubInductor->attribute("right_vector"));
74 mModifiedAttributes.push_back(line.attribute("right_vector"));
75 }
76
78 void
79 mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
80 AttributeBase::List &attributeDependencies,
81 AttributeBase::List &modifiedAttributes,
82 Attribute<Matrix>::Ptr &leftVector) override;
83 void
84 mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
85 AttributeBase::List &attributeDependencies,
86 AttributeBase::List &modifiedAttributes,
87 Attribute<Matrix>::Ptr &leftVector) {
88 mAttributeDependencies.push_back(leftVector);
89 mAttributeDependencies.push_back(line.mSubInductor->attribute("i_intf"));
90 mModifiedAttributes.push_back(line.attribute("i_intf"));
91 mModifiedAttributes.push_back(line.attribute("v_intf"));
92 }
93};
94} // namespace Ph3
95} // namespace SP
96} // namespace CPS
String uid()
Returns unique id.
MNASimPowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
void initializeFromNodesAndTerminals(Real frequency)
Initializes component from power flow data.
SimPowerComp< Real >::Ptr clone(String name)
Returns a modified copy of the component with the given suffix added to the name and without.
void mnaCompAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
Add MNA pre step dependencies.
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector)
Stamps right side (source) vector.
void mnaApplyInitialSystemMatrixStamp(SparseMatrixRow &systemMatrix)
Stamps system matrix.
RxLine(String name, Logger::Level logLevel=Logger::Level::off)
Defines name, component parameters and logging level.
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector)
Initializes internal variables of the component.
std::shared_ptr< Resistor > mInitialResistor
Inductor end to ground resistor to facilitate initialization.
RxLine(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name, logging level.
Matrix mVoltage
Voltage across the component [V].
std::shared_ptr< Inductor > mSubInductor
Inductance submodel.
Matrix mCurrent
Current through the component [A].
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix)
Stamps system matrix.
std::shared_ptr< Resistor > mSubResistor
Resistor submodel.