DPsim
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 
11 using namespace CPS;
12 
14  Logger::Level logLevel)
15  : SimPowerComp<Complex>(uid, name, logLevel),
16  mBaseVoltage(mAttributes->create<Real>("base_Voltage")),
17  mSetPointActivePower(mAttributes->create<Real>("P_set")),
18  mSetPointReactivePower(mAttributes->create<Real>("Q_set")),
19  mSetPointVoltage(mAttributes->create<Real>("V_set")),
20  mSetPointActivePowerPerUnit(mAttributes->create<Real>("P_set_pu")),
21  mSetPointReactivePowerPerUnit(mAttributes->create<Real>("Q_set_pu")),
22  mSetPointVoltagePerUnit(mAttributes->create<Real>("V_set_pu")) {
23 
24  SPDLOG_LOGGER_INFO(mSLog, "Create {} of type {}", name, this->type());
25  mSLog->flush();
26 
27  setTerminalNumber(1);
28 };
29 
31  Real ratedApparentPower, Real ratedVoltage, Real setPointActivePower,
32  Real setPointVoltage, PowerflowBusType powerflowBusType,
33  Real setPointReactivePower) {
34  **mSetPointActivePower = setPointActivePower;
35  **mSetPointReactivePower = setPointReactivePower;
36  **mSetPointVoltage = setPointVoltage;
37  mPowerflowBusType = powerflowBusType;
38 
39  SPDLOG_LOGGER_INFO(mSLog, "Rated Apparent Power={} [VA] Rated Voltage={} [V]",
40  ratedApparentPower, ratedVoltage);
41  SPDLOG_LOGGER_INFO(mSLog,
42  "Active Power Set Point={} [W] Voltage Set Point={} [V]",
43  **mSetPointActivePower, **mSetPointVoltage);
44  mSLog->flush();
45 }
46 
47 // #### Powerflow section ####
49  **mBaseVoltage = baseVoltage;
50 }
51 
53  Real baseApparentPower, Real baseOmega) {
54  SPDLOG_LOGGER_INFO(mSLog, "#### Calculate Per Unit Parameters for {}",
55  **mName);
56  mBaseApparentPower = baseApparentPower;
57  SPDLOG_LOGGER_INFO(mSLog, "Base Power={} [VA] Base Omega={} [1/s]",
58  mBaseApparentPower, baseOmega);
59 
60  **mSetPointActivePowerPerUnit = **mSetPointActivePower / mBaseApparentPower;
61  **mSetPointReactivePowerPerUnit =
62  **mSetPointReactivePower / mBaseApparentPower;
63  **mSetPointVoltagePerUnit = **mSetPointVoltage / **mBaseVoltage;
64  SPDLOG_LOGGER_INFO(mSLog,
65  "Active Power Set Point={} [pu] Voltage Set Point={} [pu]",
66  **mSetPointActivePowerPerUnit, **mSetPointVoltagePerUnit);
67  mSLog->flush();
68 }
69 
71  PowerflowBusType powerflowBusType) {
72  switch (powerflowBusType) {
73  case CPS::PowerflowBusType::PV:
74  mPowerflowBusType = powerflowBusType;
75  break;
76  case CPS::PowerflowBusType::PQ:
77  throw std::invalid_argument(
78  "Setting Synchronous Generator as PQNode is currently not supported.");
79  break;
80  case CPS::PowerflowBusType::VD:
81  mPowerflowBusType = powerflowBusType;
82  break;
83  case CPS::PowerflowBusType::None:
84  break;
85  default:
86  throw std::invalid_argument(" Invalid power flow bus type ");
87  break;
88  }
89 }
90 
91 //Method used in PF to update reactive power for PV-Bus generator
93  Complex powerInj) {
94  **mSetPointReactivePower = powerInj.imag();
95  **mSetPointReactivePowerPerUnit =
96  **mSetPointReactivePower / mBaseApparentPower;
97 }
98 
99 //Method used in PF to update active & reactive power for VD-Bus generator
101  **mSetPointActivePower = powerInj.real();
102  **mSetPointActivePowerPerUnit = **mSetPointActivePower / mBaseApparentPower;
103  **mSetPointReactivePower = powerInj.imag();
104  **mSetPointReactivePowerPerUnit =
105  **mSetPointReactivePower / mBaseApparentPower;
106 }
107 
109  return Complex(**mSetPointActivePower, **mSetPointReactivePower);
110 }
String type()
Get component type (cross-platform)
void modifyPowerFlowBusType(PowerflowBusType powerflowBusType) override
Modify powerflow bus type.
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.
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.
void updatePowerInjection(Complex powerInj)
Update active & reactive power injection (VD bus)
Base class for all components that are transmitting power.
Definition: SimPowerComp.h:17
Logger::Log mSLog
Component logger.