SP_Ph1_SynchronGenerator.cpp 3.64 KB
Newer Older
Markus Mirz's avatar
Markus Mirz committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/**
 * @file
 * @author Jan Dinkelbach <jdinkelbach@eonerc.rwth-aachen.de>
 * @copyright 2017-2018, Institute for Automation of Complex Power Systems, EONERC
 *
 * CPowerSystems
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *********************************************************************************/

#include <cps/SP/SP_Ph1_SynchronGenerator.h>

using namespace CPS;

Jan Dinkelbach's avatar
Jan Dinkelbach committed
26
27
SP::Ph1::SynchronGenerator::SynchronGenerator(String uid, String name, Logger::Level logLevel)
 : PowerComponent<Complex>(uid, name, logLevel) {
Markus Mirz's avatar
Markus Mirz committed
28
29

    mSLog->info("Create {} of type {}", name, this->type());
Jan Dinkelbach's avatar
Jan Dinkelbach committed
30
31
32
33
34
35
36
37
    mSLog->flush();

    setTerminalNumber(1);
    
    addAttribute<Real>("P_set", &mSetPointActivePower, Flags::read | Flags::write);
    addAttribute<Real>("V_set", &mSetPointVoltage, Flags::read | Flags::write);
    addAttribute<Real>("P_set_pu", &mSetPointActivePowerPerUnit, Flags::read | Flags::write);
    addAttribute<Real>("V_set_pu", &mSetPointVoltagePerUnit, Flags::read | Flags::write);
Markus Mirz's avatar
Markus Mirz committed
38
39
};

Jan Dinkelbach's avatar
Jan Dinkelbach committed
40
41
42
43
44
45
46
void SP::Ph1::SynchronGenerator::setParameters(Real ratedApparentPower, Real ratedVoltage, Real setPointActivePower, Real setPointVoltage, Real maximumReactivePower, PowerflowBusType powerflowBusType) {
	mRatedApparentPower = ratedApparentPower;
    mRatedVoltage = ratedVoltage;
    mSetPointActivePower = setPointActivePower;
    mSetPointVoltage = setPointVoltage;
    mMaximumReactivePower = maximumReactivePower;
    mPowerflowBusType = powerflowBusType;
Markus Mirz's avatar
Markus Mirz committed
47

Jan Dinkelbach's avatar
Jan Dinkelbach committed
48
49
50
51
52
	mSLog->info("Rated Apparent Power={} [VA] Rated Voltage={} [V]", mRatedApparentPower, mRatedVoltage);
    mSLog->info("Active Power Set Point={} [W] Voltage Set Point={} [V]", mSetPointActivePower, mSetPointVoltage);
    mSLog->info("Maximum Reactive Power={} [VAr]", mMaximumReactivePower);
	mSLog->flush();
}
Markus Mirz's avatar
Markus Mirz committed
53

Jan Dinkelbach's avatar
Jan Dinkelbach committed
54
55
56
57
// #### Powerflow section ####
void SP::Ph1::SynchronGenerator::setBaseVoltage(Real baseVoltage) {
    mBaseVoltage = baseVoltage;
}
Markus Mirz's avatar
Markus Mirz committed
58

Jan Dinkelbach's avatar
Jan Dinkelbach committed
59
60
61
62
63
void SP::Ph1::SynchronGenerator::calculatePerUnitParameters(Real baseApparentPower, Real baseOmega) {
	mSLog->info("#### Calculate Per Unit Parameters for {}", mName); 
	mBaseApparentPower = baseApparentPower;
	mBaseOmega = baseOmega;
    mSLog->info("Base Power={} [VA]  Base Omega={} [1/s]", mBaseApparentPower, mBaseOmega);
Markus Mirz's avatar
Markus Mirz committed
64

Jan Dinkelbach's avatar
Jan Dinkelbach committed
65
66
67
68
69
70
71
	mSetPointActivePowerPerUnit = mSetPointActivePower/mBaseApparentPower;
	mSetPointVoltagePerUnit = mSetPointVoltage/mBaseVoltage;
	mSLog->info("Active Power Set Point={} [pu] Voltage Set Point={} [pu]", mSetPointActivePowerPerUnit, mSetPointVoltagePerUnit);
	mSLog->flush();
}

void SP::Ph1::SynchronGenerator::modifyPowerFlowBusType(PowerflowBusType powerflowBusType) {
Markus Mirz's avatar
Markus Mirz committed
72
73
74
    switch (powerflowBusType)
    {
    case CPS::PowerflowBusType::PV:
Jan Dinkelbach's avatar
Jan Dinkelbach committed
75
        mPowerflowBusType = powerflowBusType;
Markus Mirz's avatar
Markus Mirz committed
76
77
        break;
    case CPS::PowerflowBusType::PQ:
Jan Dinkelbach's avatar
Jan Dinkelbach committed
78
        throw std::invalid_argument("Setting Synchronous Generator as PQNode is currently not supported.");
Markus Mirz's avatar
Markus Mirz committed
79
80
        break;
    case CPS::PowerflowBusType::VD:
Jan Dinkelbach's avatar
Jan Dinkelbach committed
81
        mPowerflowBusType = powerflowBusType;
Markus Mirz's avatar
Markus Mirz committed
82
83
        break;
    case CPS::PowerflowBusType::None:
Jan Dinkelbach's avatar
Jan Dinkelbach committed
84
		break;
Markus Mirz's avatar
Markus Mirz committed
85
86
87
88
89
90
91
    default:
        throw std::invalid_argument(" Invalid power flow bus type ");
        break;
    }
}