DPsim
Loading...
Searching...
No Matches
Exciter.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/MathUtils.h>
10#include <dpsim-models/Signal/Exciter.h>
11
12using namespace CPS;
13
14Signal::Exciter::Exciter(const String &name, CPS::Logger::Level logLevel)
15 : SimSignalComp(name, name, logLevel),
16 mVm(mAttributes->create<Real>("Vm", 0)),
17 mVh(mAttributes->create<Real>("Vh", 0)),
18 mVis(mAttributes->create<Real>("Vis", 0)),
19 mVse(mAttributes->create<Real>("Vse", 0)),
20 mVr(mAttributes->create<Real>("Vr", 0)),
21 mEf(mAttributes->create<Real>("Ef", 0)) {}
22
23void Signal::Exciter::setParameters(Real Ta, Real Ka, Real Te, Real Ke, Real Tf,
24 Real Kf, Real Tr, Real maxVr, Real minVr) {
25 mTa = Ta;
26 mKa = Ka;
27 mTe = Te;
28 mKe = Ke;
29 mTf = Tf;
30 mKf = Kf;
31 mTr = Tr;
32 mMaxVr = maxVr;
33 mMinVr = minVr;
34
35 SPDLOG_LOGGER_INFO(mSLog,
36 "Exciter parameters: \n"
37 "Ta: {:e}"
38 "\nKa: {:e}"
39 "\nTe: {:e}"
40 "\nKe: {:e}"
41 "\nTf: {:e}"
42 "\nKf: {:e}"
43 "\nTr: {:e}"
44 "\nMaximum regulator Voltage: {:e}"
45 "\nMinimum regulator Voltage: {:e}\n",
46 mTa, mKa, mTe, mKe, mTf, mKf, mTr, mMaxVr, mMinVr);
47}
48
49void Signal::Exciter::initialize(Real Vh_init, Real Ef_init) {
50
51 SPDLOG_LOGGER_INFO(mSLog,
52 "Initially set excitation system initial values: \n"
53 "Vh_init: {:e}\nEf_init: {:e}\n",
54 Vh_init, Ef_init);
55
56 **mVm = Vh_init;
57 **mEf = Ef_init;
58
59 // mVse is the ceiling function in PSAT
60 **mVse = **mEf * (0.33 * exp(0.1 * abs(**mEf)));
61
62 // mVis = vr2 in PSAT
63 **mVis = -mKf / mTf * **mEf;
64
65 // mVr = vr1 in PSAT
66 **mVr = mKe * **mEf + **mVse;
67 if (**mVr > mMaxVr)
68 **mVr = mMaxVr;
69 else if (**mVr < mMinVr)
70 **mVr = mMinVr;
71
72 mVref = **mVr / mKa + **mVm;
73 SPDLOG_LOGGER_INFO(mSLog,
74 "Actually applied excitation system initial values:"
75 "\nVref : {:e}"
76 "\ninit_Vm: {:e}"
77 "\ninit_Ef: {:e}"
78 "\ninit_Vc: {:e}"
79 "\ninit_Vr: {:e}"
80 "\ninit_Vr2: {:e}",
81 mVref, **mVm, **mEf, **mVse, **mVr, **mVis);
82}
83
84Real Signal::Exciter::step(Real mVd, Real mVq, Real dt) {
85 // Voltage magnitude calculation
86 **mVh = sqrt(pow(mVd, 2.) + pow(mVq, 2.));
87
88 // update state variables at time k-1
89 mVm_prev = **mVm;
90 mVis_prev = **mVis;
91 mVr_prev = **mVr;
92 mEf_prev = **mEf;
93
94 // compute state variables at time k using euler forward
95
96 // Voltage Transducer equation
97 **mVm = Math::StateSpaceEuler(mVm_prev, -1 / mTr, 1 / mTr, dt, **mVh);
98
99 // Stabilizing feedback equation
100 **mVse = mEf_prev * (0.33 * exp(0.1 * abs(mEf_prev)));
101 **mVis = Math::StateSpaceEuler(mVis_prev, -1 / mTf, -mKf / mTf / mTf, dt,
102 mEf_prev);
103
104 // Voltage regulator equation
105 **mVr =
106 Math::StateSpaceEuler(mVr_prev, -1 / mTa, mKa / mTa, dt,
107 mVref - **mVm - mVis_prev - mKf / mTf * mEf_prev);
108 if (**mVr > mMaxVr)
109 **mVr = mMaxVr;
110 else if (**mVr < mMinVr)
111 **mVr = mMinVr;
112
113 // Exciter equation
114 **mEf = Math::StateSpaceEuler(mEf_prev, -mKe / mTe, 1. / mTe, dt,
115 mVr_prev - **mVse);
116
117 return **mEf;
118}
AttributeList::Ptr mAttributes
Attribute List.
const Attribute< Real >::Ptr mEf
Exciter output at time k (induced emf by the field current under no-load conditions)
Definition Exciter.h:66
const Attribute< Real >::Ptr mVis
Output of stablizing feedback at time k.
Definition Exciter.h:60
void setParameters(Real Ta, Real Ka, Real Te, Real Ke, Real Tf, Real Kf, Real Tr, Real maxVr=1.0, Real minVr=-0.9)
Initializes exciter parameters.
Definition Exciter.cpp:23
const Attribute< Real >::Ptr mVm
Output of voltage transducer at time k-1.
Definition Exciter.h:56
Real step(Real mVd, Real mVq, Real dt)
Performs an step to update field voltage value.
Definition Exciter.cpp:84
const Attribute< Real >::Ptr mVse
Output of ceiling function at time k-1.
Definition Exciter.h:64
void initialize(Real Vh_init, Real Vf_init)
Initializes exciter variables.
Definition Exciter.cpp:49
const Attribute< Real >::Ptr mVr
Regulator output at time k.
Definition Exciter.h:62
const Attribute< Real >::Ptr mVh
Input of voltage transducer.
Definition Exciter.h:58
Logger::Log mSLog
Component logger.