DPsim
Loading...
Searching...
No Matches
SP_Ph1_SynchronGenerator.cpp
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#include <dpsim-models/SP/SP_Ph1_SynchronGenerator.h>
10
11using namespace CPS;
12
14 Logger::Level logLevel)
15 : SimPowerComp<Complex>(uid, name, logLevel),
16 mSetPointActivePower(mAttributes->create<Real>("P_set")),
17 mSetPointReactivePower(mAttributes->create<Real>("Q_set")),
18 mSetPointVoltage(mAttributes->create<Real>("V_set")),
19 mSetPointActivePowerPerUnit(mAttributes->create<Real>("P_set_pu")),
20 mSetPointReactivePowerPerUnit(mAttributes->create<Real>("Q_set_pu")),
21 mSetPointVoltagePerUnit(mAttributes->create<Real>("V_set_pu")) {
22
23 SPDLOG_LOGGER_INFO(mSLog, "Create {} of type {}", name, this->type());
24 mSLog->flush();
25
26 setTerminalNumber(1);
27};
28
30 Real ratedApparentPower, Real ratedVoltage, Real setPointActivePower,
31 Real setPointVoltage, PowerflowBusType powerflowBusType,
32 Real setPointReactivePower) {
33 **mSetPointActivePower = setPointActivePower;
34 **mSetPointReactivePower = setPointReactivePower;
35 **mSetPointVoltage = setPointVoltage;
36 mPowerflowBusType = powerflowBusType;
37
38 SPDLOG_LOGGER_INFO(mSLog, "Rated Apparent Power={} [VA] Rated Voltage={} [V]",
39 ratedApparentPower, ratedVoltage);
40 SPDLOG_LOGGER_INFO(mSLog,
41 "Active Power Set Point={} [W] Voltage Set Point={} [V]",
43 mSLog->flush();
44}
45
46// #### Powerflow section ####
47
48Real SP::Ph1::SynchronGenerator::getBaseVoltage() const { return mBaseVoltage; }
49
51 mBaseVoltage = baseVoltage;
52}
53
55 Real baseApparentPower, Real baseOmega) {
56 SPDLOG_LOGGER_INFO(mSLog, "#### Calculate Per Unit Parameters for {}",
57 **mName);
58 mBaseApparentPower = baseApparentPower;
59 SPDLOG_LOGGER_INFO(mSLog, "Base Power={} [VA] Base Omega={} [1/s]",
60 mBaseApparentPower, baseOmega);
61
62 **mSetPointActivePowerPerUnit = **mSetPointActivePower / mBaseApparentPower;
64 **mSetPointReactivePower / mBaseApparentPower;
65 **mSetPointVoltagePerUnit = **mSetPointVoltage / mBaseVoltage;
66 SPDLOG_LOGGER_INFO(mSLog,
67 "Active Power Set Point={} [pu] Voltage Set Point={} [pu]",
69 mSLog->flush();
70}
71
73 PowerflowBusType powerflowBusType) {
74 switch (powerflowBusType) {
75 case CPS::PowerflowBusType::PV:
76 mPowerflowBusType = powerflowBusType;
77 break;
78 case CPS::PowerflowBusType::PQ:
79 throw std::invalid_argument(
80 "Setting Synchronous Generator as PQNode is currently not supported.");
81 break;
82 case CPS::PowerflowBusType::VD:
83 mPowerflowBusType = powerflowBusType;
84 break;
85 case CPS::PowerflowBusType::None:
86 break;
87 default:
88 throw std::invalid_argument(" Invalid power flow bus type ");
89 break;
90 }
91}
92
93//Method used in PF to update reactive power for PV-Bus generator
95 Complex powerInj) {
96 **mSetPointReactivePower = powerInj.imag();
98 **mSetPointReactivePower / mBaseApparentPower;
99}
100
101//Method used in PF to update active & reactive power for VD-Bus generator
103 **mSetPointActivePower = powerInj.real();
104 **mSetPointActivePowerPerUnit = **mSetPointActivePower / mBaseApparentPower;
105 **mSetPointReactivePower = powerInj.imag();
107 **mSetPointReactivePower / mBaseApparentPower;
108}
109
const Attribute< String >::Ptr mName
Human readable name.
String uid()
Returns unique id.
String type()
Get component type (cross-platform)
AttributeList::Ptr mAttributes
Attribute List.
PowerflowBusType mPowerflowBusType
Define the type of bus the component is modelled by.
const Attribute< Real >::Ptr mSetPointReactivePower
Reactive power set point of the machine [VAr].
void modifyPowerFlowBusType(PowerflowBusType powerflowBusType) override
Modify powerflow bus type.
const Attribute< Real >::Ptr mSetPointReactivePowerPerUnit
Reactive power set point of the machine [pu].
Complex getApparentPower() const
Get Apparent power of Powerflow solution.
void setBaseVoltage(Real baseVoltage)
Set base voltage.
void calculatePerUnitParameters(Real baseApparentPower, Real baseOmega)
Initializes component from power flow data.
const Attribute< Real >::Ptr mSetPointActivePower
Active power set point of the machine [W].
SynchronGenerator(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and logging level.
void updateReactivePowerInjection(Complex powerInj)
Update reactive power injection (PV Bus)
void setParameters(Real ratedApparentPower, Real ratedVoltage, Real setPointActivePower, Real setPointVoltage, PowerflowBusType powerflowBusType, Real setPointReactivepower=0)
Setter for synchronous generator parameters.
const Attribute< Real >::Ptr mSetPointVoltagePerUnit
Voltage set point of the machine [pu].
void updatePowerInjection(Complex powerInj)
Update active & reactive power injection (VD bus)
const Attribute< Real >::Ptr mSetPointVoltage
Voltage set point of the machine [V].
const Attribute< Real >::Ptr mSetPointActivePowerPerUnit
Active power set point of the machine [pu].
SimPowerComp(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Logger::Log mSLog
Component logger.