DPsim
SP_Ph1_Resistor.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_Ph1_Resistor.h>
12 #include <dpsim-models/Definitions.h>
13 #include <dpsim-models/Logger.h>
14 #include <dpsim-models/MNASimPowerComp.h>
15 #include <dpsim-models/Solver/MNATearInterface.h>
16 #include <dpsim-models/Solver/PFSolverInterfaceBranch.h>
17 
18 namespace CPS {
19 namespace SP {
20 namespace Ph1 {
22 class Resistor : public MNASimPowerComp<Complex>,
23  public Base::Ph1::Resistor,
24  public MNATearInterface,
25  public SharedFactory<Resistor>,
27 
28 private:
30  Real mBaseApparentPower;
32  Real mBaseImpedance;
34  Real mBaseAdmittance;
36  Real mBaseVoltage;
38  Real mBaseCurrent;
39 
41  Real mResistancePerUnit;
43  Real mConductancePerUnit;
44 
45 public:
47  Resistor(String uid, String name,
48  Logger::Level logLevel = Logger::Level::off);
50  Resistor(String name, Logger::Level logLevel = Logger::Level::off)
51  : Resistor(name, name, logLevel) {}
52 
53  SimPowerComp<Complex>::Ptr clone(String name);
54 
55  // #### General ####
57  void initializeFromNodesAndTerminals(Real frequency);
58 
59  // #### Powerflow section ####
61  void setBaseVoltage(Real baseVoltage);
63  void calculatePerUnitParameters(Real baseApparentPower);
65  void pfApplyAdmittanceMatrixStamp(SparseMatrixCompRow &Y);
66 
67  // #### MNA section ####
69  void mnaCompInitialize(Real omega, Real timeStep,
70  Attribute<Matrix>::Ptr leftVector);
72  void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix);
74  void mnaCompUpdateVoltage(const Matrix &leftVector);
76  void mnaCompUpdateCurrent(const Matrix &leftVector);
78  void mnaCompPostStep(Real time, Int timeStepCount,
79  Attribute<Matrix>::Ptr &leftVector);
81  void
82  mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
83  AttributeBase::List &attributeDependencies,
84  AttributeBase::List &modifiedAttributes,
85  Attribute<Matrix>::Ptr &leftVector);
86 
87  // #### MNA Tear Section ####
88  void mnaTearApplyMatrixStamp(SparseMatrixRow &tearMatrix);
89 };
90 } // namespace Ph1
91 } // namespace SP
92 } // namespace CPS
String uid()
Returns unique id.
Base class for all MNA components that are transmitting power.
Common base class of all Component templates.
Static phasor resistor model.
void mnaCompUpdateCurrent(const Matrix &leftVector)
Update interface current from MNA system result.
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector)
add MNA pre and post step dependencies
SimPowerComp< Complex >::Ptr clone(String name)
Returns a modified copy of the component with the given suffix added to the name and without.
void mnaCompPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector)
MNA pre and post step operations.
void mnaCompUpdateVoltage(const Matrix &leftVector)
Update interface voltage from MNA system result.
Resistor(String name, Logger::Level logLevel=Logger::Level::off)
Defines name and logging level.
void setBaseVoltage(Real baseVoltage)
Set base voltage.
Resistor(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and logging level.
void initializeFromNodesAndTerminals(Real frequency)
Initializes component from power flow data.
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix)
Stamps system matrix.
void pfApplyAdmittanceMatrixStamp(SparseMatrixCompRow &Y)
Stamps admittance matrix.
void calculatePerUnitParameters(Real baseApparentPower)
Initializes component from power flow data.
Base class for all components that are transmitting power.
Definition: SimPowerComp.h:17