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 mReactivePowerMax(mAttributes->create<Real>(
23 "Q_max", std::numeric_limits<Real>::infinity())),
24 mReactivePowerMin(mAttributes->create<Real>(
25 "Q_min", -std::numeric_limits<Real>::infinity())),
27 "Q_max_pu", std::numeric_limits<Real>::infinity())),
29 "Q_min_pu", -std::numeric_limits<Real>::infinity())) {
30
31 SPDLOG_LOGGER_INFO(mSLog, "Create {} of type {}", name, this->type());
32 mSLog->flush();
33
34 setTerminalNumber(1);
35};
36
38 Real ratedApparentPower, Real ratedVoltage, Real setPointActivePower,
39 Real setPointVoltage, PowerflowBusType powerflowBusType,
40 Real setPointReactivePower, Real qLimMax, Real qLimMin) {
41 **mSetPointActivePower = setPointActivePower;
42 **mSetPointReactivePower = setPointReactivePower;
43 **mSetPointVoltage = setPointVoltage;
44 **mReactivePowerMax = qLimMax;
45 **mReactivePowerMin = qLimMin;
46 mPowerflowBusType = powerflowBusType;
47
48 SPDLOG_LOGGER_INFO(mSLog, "Rated Apparent Power={} [VA] Rated Voltage={} [V]",
49 ratedApparentPower, ratedVoltage);
50 SPDLOG_LOGGER_INFO(mSLog,
51 "Active Power Set Point={} [W] Voltage Set Point={} [V]",
53 SPDLOG_LOGGER_INFO(mSLog, "Reactive Power Limits Qmin={} Qmax={} [VAr]",
55 mSLog->flush();
56}
57
58// #### Powerflow section ####
59
60Real SP::Ph1::SynchronGenerator::getBaseVoltage() const { return mBaseVoltage; }
61
63 mBaseVoltage = baseVoltage;
64}
65
67 Real baseApparentPower, Real baseOmega) {
68 SPDLOG_LOGGER_INFO(mSLog, "#### Calculate Per Unit Parameters for {}",
69 **mName);
70 mBaseApparentPower = baseApparentPower;
71 SPDLOG_LOGGER_INFO(mSLog, "Base Power={} [VA] Base Omega={} [1/s]",
72 mBaseApparentPower, baseOmega);
73
74 **mSetPointActivePowerPerUnit = **mSetPointActivePower / mBaseApparentPower;
76 **mSetPointReactivePower / mBaseApparentPower;
77 **mSetPointVoltagePerUnit = **mSetPointVoltage / mBaseVoltage;
78 // +/-inf limits divide to +/-inf in pu (still "unlimited"); finite limits scale.
79 **mReactivePowerMaxPerUnit = **mReactivePowerMax / mBaseApparentPower;
80 **mReactivePowerMinPerUnit = **mReactivePowerMin / mBaseApparentPower;
81 SPDLOG_LOGGER_INFO(mSLog,
82 "Active Power Set Point={} [pu] Voltage Set Point={} [pu]",
84 mSLog->flush();
85}
86
88 PowerflowBusType powerflowBusType) {
89 switch (powerflowBusType) {
90 case CPS::PowerflowBusType::PV:
91 mPowerflowBusType = powerflowBusType;
92 break;
93 case CPS::PowerflowBusType::PQ:
94 mPowerflowBusType = powerflowBusType;
95 break;
96 case CPS::PowerflowBusType::VD:
97 mPowerflowBusType = powerflowBusType;
98 break;
99 case CPS::PowerflowBusType::None:
100 break;
101 default:
102 throw std::invalid_argument(" Invalid power flow bus type ");
103 break;
104 }
105}
106
107//Method used in PF to update reactive power for PV-Bus generator
109 Complex powerInj) {
110 **mSetPointReactivePower = powerInj.imag();
112 **mSetPointReactivePower / mBaseApparentPower;
113}
114
115//Method used in PF to update active & reactive power for VD-Bus generator
117 **mSetPointActivePower = powerInj.real();
118 **mSetPointActivePowerPerUnit = **mSetPointActivePower / mBaseApparentPower;
119 **mSetPointReactivePower = powerInj.imag();
121 **mSetPointReactivePower / mBaseApparentPower;
122}
123
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].
const Attribute< Real >::Ptr mReactivePowerMax
Maximum reactive power limit [VAr] (default +inf = unlimited)
void modifyPowerFlowBusType(PowerflowBusType powerflowBusType) override
Modify powerflow bus type.
const Attribute< Real >::Ptr mSetPointReactivePowerPerUnit
Reactive power set point of the machine [pu].
const Attribute< Real >::Ptr mReactivePowerMin
Minimum reactive power limit [VAr] (default -inf = unlimited)
const Attribute< Real >::Ptr mReactivePowerMinPerUnit
Minimum reactive power limit [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)
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 mReactivePowerMaxPerUnit
Maximum reactive power limit [pu].
const Attribute< Real >::Ptr mSetPointVoltage
Voltage set point of the machine [V].
void setParameters(Real ratedApparentPower, Real ratedVoltage, Real setPointActivePower, Real setPointVoltage, PowerflowBusType powerflowBusType, Real setPointReactivepower=0, Real qLimMax=std::numeric_limits< Real >::infinity(), Real qLimMin=-std::numeric_limits< Real >::infinity())
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.