Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed implementation of exciter and added new turbine governor model #104

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions Examples/Cxx/Circuits/DP_ReducedOrderSG_VBR_Load_Fault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ Examples::Grids::SMIB::ScenarioConfig3 GridParams;
// Generator parameters
Examples::Components::SynchronousGeneratorKundur::MachineParameters syngenKundur;

// Excitation system
Examples::Components::ExcitationSystemEremia::Parameters excitationEremia;

void DP_1ph_SynGen_Fault(String simName, Real timeStep, Real finalTime, Real H,
Real startTimeFault, Real endTimeFault, Real logDownSampling, Real switchOpen,
Real switchClosed, int SGModel, Logger::Level logLevel) {
Real switchClosed, int SGModel, bool withExciter, Logger::Level logLevel) {

// ----- Dynamic simulation ------
String simNameDP = simName;
Expand Down Expand Up @@ -43,11 +45,22 @@ void DP_1ph_SynGen_Fault(String simName, Real timeStep, Real finalTime, Real H,
syngenKundur.Ld, syngenKundur.Lq, syngenKundur.Ll,
syngenKundur.Ld_t, syngenKundur.Lq_t, syngenKundur.Td0_t, syngenKundur.Tq0_t,
syngenKundur.Ld_s, syngenKundur.Lq_s, syngenKundur.Td0_s, syngenKundur.Tq0_s);

genDP->setInitialValues(GridParams.initComplexElectricalPower, GridParams.mechPower,
Complex(GridParams.VnomMV * cos(GridParams.initVoltAngle),
GridParams.VnomMV * sin(GridParams.initVoltAngle)));

// Exciter
std::shared_ptr<Signal::Exciter> exciterDP = nullptr;
if (withExciter) {
exciterDP = Signal::Exciter::make("SynGen_Exciter", logLevel);
exciterDP->setParameters(excitationEremia.Ta, excitationEremia.Ka,
excitationEremia.Te, excitationEremia.Ke,
excitationEremia.Tf, excitationEremia.Kf,
excitationEremia.Tr);
genDP->addExciter(exciterDP);
}

// Lod
auto load = CPS::DP::Ph1::RXLoad::make("Load", logLevel);
load->setParameters(GridParams.initActivePower, GridParams.initReactivePower,
GridParams.VnomMV);
Expand Down Expand Up @@ -84,12 +97,15 @@ void DP_1ph_SynGen_Fault(String simName, Real timeStep, Real finalTime, Real H,
loggerDP->logAttribute("v_gen", genDP->attribute("v_intf"));
loggerDP->logAttribute("i_gen", genDP->attribute("i_intf"));
loggerDP->logAttribute("Etorque", genDP->attribute("Etorque"));
//loggerDP->logAttribute("delta", genDP->attribute("delta"));
//loggerDP->logAttribute("w_r", genDP->attribute("w_r"));
loggerDP->logAttribute("delta", genDP->attribute("delta"));
loggerDP->logAttribute("w_r", genDP->attribute("w_r"));
//loggerDP->logAttribute("Edq0", genDP->attribute("Edq0_t"));
//loggerDP->logAttribute("Vdq0", genDP->attribute("Vdq0"));
//loggerDP->logAttribute("Idq0", genDP->attribute("Idq0"));
loggerDP->logAttribute("Vdq0", genDP->attribute("Vdq0"));
loggerDP->logAttribute("Idq0", genDP->attribute("Idq0"));
//loggerDP->logAttribute("Eabc", genDP->attribute("Eabc"));
if (withExciter) {
loggerDP->logAttribute("Vf", exciterDP->attribute("Vf"));
}

Simulation simDP(simNameDP, logLevel);
simDP.doInitFromNodesAndTerminals(true);
Expand Down Expand Up @@ -122,6 +138,7 @@ int main(int argc, char* argv[]) {
Real timeStep = 1e-3;
int SGModel = 4;
Real H = syngenKundur.H;
bool withExciter = false;
std::string SGModel_str = "4Order";
std::string stepSize_str = "";
std::string inertia_str = "";
Expand Down Expand Up @@ -150,6 +167,8 @@ int main(int argc, char* argv[]) {
H = args.getOptionReal("Inertia");
inertia_str = "_Inertia_" + std::to_string(H);
}
if (args.options.find("WITHEXCITER") != args.options.end())
withExciter = args.getOptionBool("WITHEXCITER");
}

Real logDownSampling;
Expand All @@ -160,5 +179,5 @@ int main(int argc, char* argv[]) {
Logger::Level logLevel = Logger::Level::off;
std::string simName = "DP_SynGen" + SGModel_str + "VBR_Load_Fault" + stepSize_str + inertia_str;
DP_1ph_SynGen_Fault(simName, timeStep, finalTime, H, startTimeFault, endTimeFault,
logDownSampling, SwitchOpen, SwitchClosed, SGModel, logLevel);
logDownSampling, SwitchOpen, SwitchClosed, SGModel, withExciter, logLevel);
}
32 changes: 26 additions & 6 deletions Examples/Cxx/Circuits/EMT_ReducedOrderSG_VBR_Load_Fault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ Examples::Grids::SMIB::ScenarioConfig3 GridParams;
// Generator parameters
Examples::Components::SynchronousGeneratorKundur::MachineParameters syngenKundur;

// Excitation system
Examples::Components::ExcitationSystemEremia::Parameters excitationEremia;

void EMT_3ph_SynGen_Load(String simName, Real timeStep, Real finalTime, Real H,
Real startTimeFault, Real endTimeFault, Real logDownSampling, Real switchOpen,
Real switchClosed, int SGModel, Logger::Level logLevel) {
Real switchClosed, int SGModel, bool withExciter, Logger::Level logLevel) {

// ----- Dynamic simulation ------
String simNameEMT = simName;
Expand Down Expand Up @@ -47,6 +49,18 @@ void EMT_3ph_SynGen_Load(String simName, Real timeStep, Real finalTime, Real H,
genEMT->setInitialValues(GridParams.initComplexElectricalPower, GridParams.mechPower,
GridParams.initTerminalVolt);

// Exciter
std::shared_ptr<Signal::Exciter> exciterEMT = nullptr;
if (withExciter) {
exciterEMT = Signal::Exciter::make("SynGen_Exciter", logLevel);
exciterEMT->setParameters(excitationEremia.Ta, excitationEremia.Ka,
excitationEremia.Te, excitationEremia.Ke,
excitationEremia.Tf, excitationEremia.Kf,
excitationEremia.Tr);
genEMT->addExciter(exciterEMT);
}

// Load
auto load = CPS::EMT::Ph3::RXLoad::make("Load", logLevel);
load->setParameters(Math::singlePhaseParameterToThreePhase(GridParams.initActivePower/3),
Math::singlePhaseParameterToThreePhase(GridParams.initReactivePower/3),
Expand Down Expand Up @@ -86,12 +100,15 @@ void EMT_3ph_SynGen_Load(String simName, Real timeStep, Real finalTime, Real H,
loggerEMT->logAttribute("v_gen", genEMT->attribute("v_intf"));
loggerEMT->logAttribute("i_gen", genEMT->attribute("i_intf"));
loggerEMT->logAttribute("Etorque", genEMT->attribute("Etorque"));
//loggerEMT->logAttribute("delta", genEMT->attribute("delta"));
//loggerEMT->logAttribute("w_r", genEMT->attribute("w_r"));
//loggerEMT->logAttribute("Vdq0", genEMT->attribute("Vdq0"));
//loggerEMT->logAttribute("Idq0", genEMT->attribute("Idq0"));
loggerEMT->logAttribute("delta", genEMT->attribute("delta"));
loggerEMT->logAttribute("w_r", genEMT->attribute("w_r"));
loggerEMT->logAttribute("Vdq0", genEMT->attribute("Vdq0"));
loggerEMT->logAttribute("Idq0", genEMT->attribute("Idq0"));
//loggerEMT->logAttribute("Edq0", genEMT->attribute("Edq0_t"));
//loggerEMT->logAttribute("Evbr", genEMT->attribute("Evbr"));
if (withExciter) {
loggerEMT->logAttribute("Vf", exciterEMT->attribute("Vf"));
}

Simulation simEMT(simNameEMT, logLevel);
simEMT.doInitFromNodesAndTerminals(true);
Expand Down Expand Up @@ -124,6 +141,7 @@ int main(int argc, char* argv[]) {
Real timeStep = 1e-3;
int SGModel = 4;
Real H = syngenKundur.H;
bool withExciter = false;
std::string SGModel_str = "4Order";
std::string stepSize_str = "";
std::string inertia_str = "";
Expand Down Expand Up @@ -152,6 +170,8 @@ int main(int argc, char* argv[]) {
H = args.getOptionReal("Inertia");
inertia_str = "_Inertia_" + std::to_string(H);
}
if (args.options.find("WITHEXCITER") != args.options.end())
withExciter = args.getOptionBool("WITHEXCITER");
}

Real logDownSampling;
Expand All @@ -162,5 +182,5 @@ int main(int argc, char* argv[]) {
Logger::Level logLevel = Logger::Level::off;
std::string simName ="EMT_SynGen" + SGModel_str + "VBR_Load_Fault" + stepSize_str + inertia_str;
EMT_3ph_SynGen_Load(simName, timeStep, finalTime, H, startTimeFault, endTimeFault,
logDownSampling, SwitchOpen, SwitchClosed, SGModel, logLevel);
logDownSampling, SwitchOpen, SwitchClosed, SGModel, withExciter, logLevel);
}
57 changes: 54 additions & 3 deletions Examples/Cxx/Circuits/SP_ReducedOrderSG_SMIB_Fault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@ Examples::Grids::SMIB::ScenarioConfig2 GridParams;
// Generator parameters
Examples::Components::SynchronousGeneratorKundur::MachineParameters syngenKundur;

// Excitation system
Examples::Components::ExcitationSystemEremia::Parameters excitationEremia;

// Turbine Goverour
Examples::Components::TurbineGovernor::TurbineGovernorPSAT1 turbineGovernor;

void SP_1ph_SynGen_Fault(String simName, Real timeStep, Real finalTime, Real H,
Real startTimeFault, Real endTimeFault, Real logDownSampling, Real switchOpen,
Real switchClosed, int SGModel, Logger::Level logLevel) {
Real switchClosed, int SGModel, bool withExciter, bool withTurbineGovernor,
Logger::Level logLevel) {

// ----- POWERFLOW FOR INITIALIZATION -----
String simNamePF = simName + "_PF";
Expand Down Expand Up @@ -102,7 +109,29 @@ void SP_1ph_SynGen_Fault(String simName, Real timeStep, Real finalTime, Real H,
syngenKundur.Ld_s, syngenKundur.Lq_s, syngenKundur.Td0_s, syngenKundur.Tq0_s);
genSP->setInitialValues(initElecPower, initMechPower, n1PF->voltage()(0,0));

//Grid bus as Slack
// Exciter
std::shared_ptr<Signal::Exciter> exciterSP = nullptr;
if (withExciter) {
exciterSP = Signal::Exciter::make("SynGen_Exciter", logLevel);
exciterSP->setParameters(excitationEremia.Ta, excitationEremia.Ka,
excitationEremia.Te, excitationEremia.Ke,
excitationEremia.Tf, excitationEremia.Kf,
excitationEremia.Tr);
genSP->addExciter(exciterSP);
}


// Turbine Governor
std::shared_ptr<Signal::TurbineGovernorType1> turbineGovernorSP = nullptr;
if (withTurbineGovernor) {
turbineGovernorSP = Signal::TurbineGovernorType1::make("SynGen_TurbineGovernor", logLevel);
turbineGovernorSP->setParameters(turbineGovernor.T3, turbineGovernor.T4,
turbineGovernor.T5, turbineGovernor.Tc, turbineGovernor.Ts, turbineGovernor.R,
turbineGovernor.Tmin, turbineGovernor.Tmax, turbineGovernor.OmegaRef);
genSP->addGovernor(turbineGovernorSP);
}

// Grid bus as Slack
auto extnetSP = SP::Ph1::NetworkInjection::make("Slack", logLevel);
extnetSP->setParameters(GridParams.VnomMV);

Expand Down Expand Up @@ -165,6 +194,16 @@ void SP_1ph_SynGen_Fault(String simName, Real timeStep, Real finalTime, Real H,
loggerSP->logAttribute("v1", n1SP->attribute("v"));
loggerSP->logAttribute("v2", n2SP->attribute("v"));

// Exciter
if (withExciter) {
loggerSP->logAttribute("Vf", exciterSP->attribute("Vf"));
}

// Turbine Governor
if (withTurbineGovernor) {
loggerSP->logAttribute("Tm", turbineGovernorSP->attribute("Tm"));
}

Simulation simSP(simNameSP, logLevel);
simSP.doInitFromNodesAndTerminals(true);
simSP.setSystem(systemSP);
Expand Down Expand Up @@ -195,6 +234,8 @@ int main(int argc, char* argv[]) {
Real finalTime = 20;
Real timeStep = 1e-3;
Real H = syngenKundur.H;
bool withExciter = false;
bool withTurbineGovernor = false;
int SGModel = 4;
std::string SGModel_str = "4Order";
std::string stepSize_str = "";
Expand Down Expand Up @@ -224,6 +265,15 @@ int main(int argc, char* argv[]) {
H = args.getOptionReal("Inertia");
inertia_str = "_Inertia_" + std::to_string(H);
}
if (args.options.find("WithExciter") != args.options.end()) {
withExciter = args.getOptionBool("WithExciter");
}
if (args.options.find("WithTurbineGovernor") != args.options.end()) {
withTurbineGovernor = args.getOptionBool("WithTurbineGovernor");
}
if (args.options.find("FinalTime") != args.options.end()) {
finalTime = args.getOptionReal("FinalTime");
}
}

Real logDownSampling;
Expand All @@ -235,5 +285,6 @@ int main(int argc, char* argv[]) {

std::string simName = "SP_SynGen" + SGModel_str + "VBR_SMIB_Fault" + stepSize_str + inertia_str;
SP_1ph_SynGen_Fault(simName, timeStep, finalTime, H, startTimeFault, endTimeFault,
logDownSampling, SwitchOpen, SwitchClosed, SGModel, logLevel);
logDownSampling, SwitchOpen, SwitchClosed, SGModel, withExciter, withTurbineGovernor,
logLevel);
}
42 changes: 35 additions & 7 deletions Examples/Cxx/Circuits/SP_ReducedOrderSG_VBR_Load_Fault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ Examples::Grids::SMIB::ScenarioConfig3 GridParams;
// Generator parameters
Examples::Components::SynchronousGeneratorKundur::MachineParameters syngenKundur;

// Excitation system
Examples::Components::ExcitationSystemEremia::Parameters excitationEremia;

void SP_1ph_SynGen_Load(String simName, Real timeStep, Real finalTime, Real H,
Real startTimeFault, Real endTimeFault, Real logDownSampling, Real switchOpen,
Real switchClosed, int SGModel, Logger::Level logLevel) {
Real switchClosed, int SGModel, bool withExciter, Logger::Level logLevel) {

// ----- Dynamic simulation ------
String simNameSP = simName;
Expand Down Expand Up @@ -45,6 +48,18 @@ void SP_1ph_SynGen_Load(String simName, Real timeStep, Real finalTime, Real H,
Complex(GridParams.VnomMV * cos(GridParams.initVoltAngle),
GridParams.VnomMV * sin(GridParams.initVoltAngle)));

// Exciter
std::shared_ptr<Signal::Exciter> exciterSP = nullptr;
if (withExciter) {
exciterSP = Signal::Exciter::make("SynGen_Exciter", logLevel);
exciterSP->setParameters(excitationEremia.Ta, excitationEremia.Ka,
excitationEremia.Te, excitationEremia.Ke,
excitationEremia.Tf, excitationEremia.Kf,
excitationEremia.Tr);
genSP->addExciter(exciterSP);
}

// Load
auto load = CPS::SP::Ph1::Load::make("Load", logLevel);
load->setParameters(GridParams.initActivePower, GridParams.initReactivePower,
GridParams.VnomMV);
Expand Down Expand Up @@ -85,12 +100,22 @@ void SP_1ph_SynGen_Load(String simName, Real timeStep, Real finalTime, Real H,
loggerSP->logAttribute("v_gen", genSP->attribute("v_intf"));
loggerSP->logAttribute("i_gen", genSP->attribute("i_intf"));
loggerSP->logAttribute("Etorque", genSP->attribute("Etorque"));
//loggerSP->logAttribute("delta", genSP->attribute("delta"));
//loggerSP->logAttribute("w_r", genSP->attribute("w_r"));
//loggerSP->logAttribute("Edq0", genSP->attribute("Edq0_t"));
//loggerSP->logAttribute("Vdq0", genSP->attribute("Vdq0"));
//loggerSP->logAttribute("Idq0", genSP->attribute("Idq0"));
loggerSP->logAttribute("delta", genSP->attribute("delta"));
loggerSP->logAttribute("w_r", genSP->attribute("w_r"));
loggerSP->logAttribute("Vdq0", genSP->attribute("Vdq0"));
loggerSP->logAttribute("Idq0", genSP->attribute("Idq0"));
//loggerSP->logAttribute("Evbr", genSP->attribute("Evbr"));
if (SGModel==6 || SGModel==7) {
loggerSP->logAttribute("Edq0_s", genSP->attribute("Edq_s"));
loggerSP->logAttribute("Edq0_t", genSP->attribute("Edq_t"));
} else {
loggerSP->logAttribute("Edq0", genSP->attribute("Edq_t"));
}

// Exciter
if (withExciter) {
loggerSP->logAttribute("Vf", exciterSP->attribute("Vf"));
}

Simulation simSP(simNameSP, logLevel);
simSP.doInitFromNodesAndTerminals(true);
Expand Down Expand Up @@ -123,6 +148,7 @@ int main(int argc, char* argv[]) {
Real finalTime = 5;
Real timeStep = 1e-3;
Real H = syngenKundur.H;
bool withExciter = false;
int SGModel = 4;
std::string SGModel_str = "4Order";
std::string stepSize_str = "";
Expand Down Expand Up @@ -152,6 +178,8 @@ int main(int argc, char* argv[]) {
H = args.getOptionReal("Inertia");
inertia_str = "_Inertia_" + std::to_string(H);
}
if (args.options.find("WITHEXCITER") != args.options.end())
withExciter = args.getOptionBool("WITHEXCITER");
}

Real logDownSampling;
Expand All @@ -162,5 +190,5 @@ int main(int argc, char* argv[]) {
Logger::Level logLevel = Logger::Level::off;
std::string simName = "SP_SynGen" + SGModel_str + "VBR_Load_Fault" + stepSize_str + inertia_str;
SP_1ph_SynGen_Load(simName, timeStep, finalTime, H, startTimeFault, endTimeFault,
logDownSampling, SwitchOpen, SwitchClosed, SGModel, logLevel);
logDownSampling, SwitchOpen, SwitchClosed, SGModel, withExciter, logLevel);
}
Loading