DPsim
Loading...
Searching...
No Matches
SP_Ph1_NetworkInjection.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/CompositePowerComp.h>
12#include <dpsim-models/SP/SP_Ph1_VoltageSource.h>
13#include <dpsim-models/Solver/DAEInterface.h>
14#include <dpsim-models/Solver/PFSolverInterfaceBus.h>
15
16namespace CPS {
17namespace SP {
18namespace Ph1 {
26class NetworkInjection : public CompositePowerComp<Complex>,
27 public SharedFactory<NetworkInjection>,
28 public PFSolverInterfaceBus,
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:
45 const Attribute<Complex>::Ptr mVoltageRef;
46 const Attribute<Real>::Ptr mSrcFreq;
47
48 // #### Powerflow section ####
50 const Attribute<Real>::Ptr mVoltageSetPoint;
52 const Attribute<Real>::Ptr mVoltageSetPointPerUnit;
54 const Attribute<Real>::Ptr mActivePowerInjection;
56 const Attribute<Real>::Ptr mReactivePowerInjection;
57
59 NetworkInjection(String uid, String name,
60 Logger::Level logLevel = Logger::Level::off);
62 NetworkInjection(String name, Logger::Level logLevel = Logger::Level::off)
63 : NetworkInjection(name, name, logLevel) {}
64
65 SimPowerComp<Complex>::Ptr clone(String name) override;
66
67 // #### General ####
69 void initializeFromNodesAndTerminals(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
118 mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
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
CompositePowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
String uid()
Returns unique id.
const Attribute< Real >::Ptr mActivePowerInjection
Active Power Injection [W].
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 initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
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.
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].