DPsim
Loading...
Searching...
No Matches
SP_Ph1_NetworkInjection.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 SP {
18namespace Ph1 {
26class NetworkInjection : public CompositePowerComp<Complex>,
27 public SharedFactory<NetworkInjection>,
29 public DAEInterface {
30
31private:
32 // ### Electrical Subcomponents ###
34 std::shared_ptr<SP::Ph1::VoltageSource> mSubVoltageSource;
35
36 // #### solver ####
38 std::vector<const Matrix *> mRightVectorStamps;
39
40 // #### Powerflow section ####
42 Real mBaseVoltage;
43
44public:
47
48 // #### Powerflow section ####
57
60 Logger::Level logLevel = Logger::Level::off);
62 NetworkInjection(String name, Logger::Level logLevel = Logger::Level::off)
63 : NetworkInjection(name, name, logLevel) {}
64
66
67 // #### General ####
69 void initializeParentFromNodesAndTerminals(Real frequency) override;
70
71 // #### Powerflow section ####
73 void setParameters(Real vSetPointPerUnit);
74 // Get base voltage
75 Real getBaseVoltage() const;
77 void setBaseVoltage(Real baseVoltage);
79 void calculatePerUnitParameters(Real baseApparentPower, Real baseOmega);
81 void modifyPowerFlowBusType(PowerflowBusType powerflowBusType) override;
83 void updatePowerInjection(Complex powerInj);
84
85 // #### MNA Section ####
89 void setParameters(Complex voltageRef, Real srcFreq = 0.0);
92 void setParameters(Complex initialPhasor, Real freqStart, Real rocof,
93 Real timeStart, Real duration, bool smoothRamp = true);
96 void setParameters(Complex initialPhasor, Real modulationFrequency,
97 Real modulationAmplitude, Real baseFrequency = 0.0,
98 bool zigzag = false);
99
101 void mnaParentApplyRightSideVectorStamp(Matrix &rightVector) override;
103 void mnaCompUpdateCurrent(const Matrix &leftVector) override;
105 void mnaCompUpdateVoltage(const Matrix &leftVector) override;
107 void mnaParentPreStep(Real time, Int timeStepCount) override;
109 void mnaParentPostStep(Real time, Int timeStepCount,
110 Attribute<Matrix>::Ptr &leftVector) override;
113 AttributeBase::List &prevStepDependencies,
114 AttributeBase::List &attributeDependencies,
115 AttributeBase::List &modifiedAttributes) override;
117 void
119 AttributeBase::List &attributeDependencies,
120 AttributeBase::List &modifiedAttributes,
121 Attribute<Matrix>::Ptr &leftVector) override;
122
123 // #### DAE Section ####
125 void daeResidual(double ttime, const double state[], const double dstate_dt[],
126 double resid[], std::vector<int> &off) override;
128 Complex daeInitialize() override;
129};
130} // namespace Ph1
131} // namespace SP
132} // namespace CPS
std::vector< Ptr > List
Definition Attribute.h:123
AttributePointer< Attribute< T > > Ptr
Definition Attribute.h:250
CompositePowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
String uid()
Returns unique id.
spdlog::level::level_enum Level
Definition Logger.h:33
const Attribute< Real >::Ptr mActivePowerInjection
Active Power Injection [W].
const Attribute< Complex >::Ptr mVoltageRef
void setParameters(Real vSetPointPerUnit)
Set parameters relevant for PF solver.
Complex daeInitialize() override
Voltage Getter.
void daeResidual(double ttime, const double state[], const double dstate_dt[], double resid[], std::vector< int > &off) override
Residual function for DAE Solver.
void mnaParentApplyRightSideVectorStamp(Matrix &rightVector) override
Stamps right side (source) vector.
void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
Add MNA pre step dependencies.
void calculatePerUnitParameters(Real baseApparentPower, Real baseOmega)
Calculates component's parameters in specified per-unit system.
void mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
const Attribute< Real >::Ptr mVoltageSetPoint
Voltage set point [V].
NetworkInjection(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and logging level.
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Updates voltage across component.
NetworkInjection(String name, Logger::Level logLevel=Logger::Level::off)
Defines name and logging level.
void mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA post step operations.
void mnaParentPreStep(Real time, Int timeStepCount) override
MNA pre step operations.
void setBaseVoltage(Real baseVoltage)
Set base voltage.
const Attribute< Real >::Ptr mVoltageSetPointPerUnit
Voltage set point [pu].
void modifyPowerFlowBusType(PowerflowBusType powerflowBusType) override
Modify powerflow bus type.
const Attribute< Real >::Ptr mSrcFreq
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Returns current through the component.
void updatePowerInjection(Complex powerInj)
Update power injection.
SimPowerComp< Complex >::Ptr clone(String name) override
Returns a modified copy of the component with the given suffix added to the name and without.
const Attribute< Real >::Ptr mReactivePowerInjection
Reactive Power Injection [Var].
void initializeParentFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
std::shared_ptr< SimPowerComp< VarType > > Ptr
PowerflowBusType
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