DPsim
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 
17 namespace CPS {
18 namespace SP {
19 namespace Ph3 {
20 
21 class RxLine : public MNASimPowerComp<Real>,
22  public Base::Ph3::PiLine,
23  public SharedFactory<RxLine> {
24 protected:
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 
36 public:
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 
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.
Base class for all MNA components that are transmitting power.
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.
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.
Definition: SP_Ph3_RxLine.h:40
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.
Definition: SP_Ph3_RxLine.h:34
RxLine(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name, logging level.
Matrix mVoltage
Voltage across the component [V].
Definition: SP_Ph3_RxLine.h:26
std::shared_ptr< Inductor > mSubInductor
Inductance submodel.
Definition: SP_Ph3_RxLine.h:30
Matrix mCurrent
Current through the component [A].
Definition: SP_Ph3_RxLine.h:28
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix)
Stamps system matrix.
SimPowerComp< Real >::Ptr clone(String name)
Returns a modified copy of the component with the given suffix added to the name and without.
std::shared_ptr< Resistor > mSubResistor
Resistor submodel.
Definition: SP_Ph3_RxLine.h:32
Base class for all components that are transmitting power.
Definition: SimPowerComp.h:17