DPsim
Loading...
Searching...
No Matches
SP_Ph1_Load.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/PowerProfile.h>
13#include <dpsim-models/SP/SP_Ph1_Capacitor.h>
14#include <dpsim-models/SP/SP_Ph1_Inductor.h>
15#include <dpsim-models/SP/SP_Ph1_PQNode.h>
16#include <dpsim-models/SP/SP_Ph1_PVNode.h>
17#include <dpsim-models/SP/SP_Ph1_Resistor.h>
18#include <dpsim-models/SP/SP_Ph1_VDNode.h>
19#include <dpsim-models/Solver/PFSolverInterfaceBus.h>
20
21namespace CPS {
22namespace SP {
23namespace Ph1 {
24class Load : public CompositePowerComp<Complex>,
25 public SharedFactory<Load>,
26 public PFSolverInterfaceBus {
27public:
29 const Attribute<Real>::Ptr mActivePower;
31 const Attribute<Real>::Ptr mReactivePower;
33 const Attribute<Real>::Ptr mActivePowerPerUnit;
35 const Attribute<Real>::Ptr mReactivePowerPerUnit;
36
37private:
39 Real mNomVoltage;
41 Real mBaseApparentPower;
43 Real mBaseOmega;
45 Real mResistance;
47 Real mConductance;
49 Real mReactance;
51 Real mInductance;
53 Real mCapacitance;
54
57 std::shared_ptr<SP::Ph1::Inductor> mSubInductor;
59 std::shared_ptr<SP::Ph1::Capacitor> mSubCapacitor;
61 std::shared_ptr<SP::Ph1::Resistor> mSubResistor;
62
63public:
65 Load(String uid, String name, Logger::Level logLevel = Logger::Level::off);
67 Load(String name, Logger::Level logLevel = Logger::Level::off)
68 : Load(name, name, logLevel) {}
69
70 void setParameters(Real activePower, Real reactivePower, Real nominalVoltage);
71
72 // #### General ####
74 void createSubComponents() override;
76 void initializeParentFromNodesAndTerminals(Real frequency) override;
80 bool use_profile = false;
82 void updatePQ(Real time);
83
84 // #### Powerflow section ####
86 Real getNomVoltage() const;
88 void calculatePerUnitParameters(Real baseApparentPower, Real baseOmega);
90 void modifyPowerFlowBusType(PowerflowBusType powerflowBusType) override;
91
92 // #### MNA section ####
94 void mnaCompUpdateCurrent(const Matrix &leftVector) override;
96 void mnaCompUpdateVoltage(const Matrix &leftVector) override;
97
99 void mnaParentPostStep(Real time, Int timeStepCount,
100 Attribute<Matrix>::Ptr &leftVector) override;
101
102 void
103 mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
104 AttributeBase::List &attributeDependencies,
105 AttributeBase::List &modifiedAttributes,
106 Attribute<Matrix>::Ptr &leftVector) override;
107};
108} // namespace Ph1
109} // namespace SP
110
111} // namespace CPS
CompositePowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
String uid()
Returns unique id.
const Attribute< Real >::Ptr mReactivePower
Reactive power [VAr].
Definition SP_Ph1_Load.h:31
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Updates internal voltage variable of the component.
void modifyPowerFlowBusType(PowerflowBusType powerflowBusType) override
Modify powerflow bus type.
const Attribute< Real >::Ptr mActivePower
Active power [Watt].
Definition SP_Ph1_Load.h:29
const Attribute< Real >::Ptr mReactivePowerPerUnit
Reactive power [pu].
Definition SP_Ph1_Load.h:35
Real getNomVoltage() const
Get nominal voltage.
PowerProfile mLoadProfile
Load profile data.
Definition SP_Ph1_Load.h:78
Load(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and logging level.
Load(String name, Logger::Level logLevel=Logger::Level::off)
Defines name and logging level.
Definition SP_Ph1_Load.h:67
void createSubComponents() override
Constructs and registers MNA subcomponents; idempotent.
void updatePQ(Real time)
Update PQ for this load for power flow calculation at next time step.
void mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA post step operations.
const Attribute< Real >::Ptr mActivePowerPerUnit
Active power [pu].
Definition SP_Ph1_Load.h:33
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Updates internal current variable of the component.
bool use_profile
Use the assigned load profile.
Definition SP_Ph1_Load.h:80
void calculatePerUnitParameters(Real baseApparentPower, Real baseOmega)
Calculates component's parameters in specified per-unit system.
void initializeParentFromNodesAndTerminals(Real frequency) override
Derives values from power flow data and pushes them to subcomponents.