Skip to content

Commit

Permalink
(EMT, DP examples) update steady state examples
Browse files Browse the repository at this point in the history
Signed-off-by: Ghassen Nakti <[email protected]>
  • Loading branch information
gnakti committed Nov 5, 2024
1 parent ebe3935 commit ff0ad3f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ using namespace CPS;

int main(int argc, char* argv[]) {

// CIM::Examples::Grids::GridForming::ScenarioConfig1 scenario;
CIM::Examples::Grids::GridForming::Yazdani scenario;
CIM::Examples::Grids::GridForming::ScenarioConfig1 scenario;
// CIM::Examples::Grids::GridForming::Yazdani scenario;

Real finalTime = 2;
Real timeStep = 0.0001;
Real timeStep = 0.00001;
String simName = "DP_Slack_PiLine_VSI_VoltageControlled_SteadyState_with_PF_Init";
Bool pvWithControl = true;

Expand All @@ -39,7 +39,7 @@ int main(int argc, char* argv[]) {
extnetPF->modifyPowerFlowBusType(PowerflowBusType::VD);

auto linePF = SP::Ph1::PiLine::make("PiLine", Logger::Level::debug);
linePF->setParameters(scenario.lineResistance, 0, 0, 0);
linePF->setParameters(scenario.lineResistance, scenario.lineInductance, scenario.lineCapacitance, scenario.lineConductance);
linePF->setBaseVoltage(scenario.systemNominalVoltage);

Complex load1_s=3*std::pow(scenario.systemNominalVoltage, 2)/(Complex(scenario.loadRes1, scenario.loadInd1*scenario.systemNominalOmega));
Expand All @@ -50,10 +50,6 @@ int main(int argc, char* argv[]) {
loadPF->setParameters(loadActivePower, loadReactivePower, scenario.systemNominalVoltage);
loadPF->modifyPowerFlowBusType(PowerflowBusType::PQ);

// auto loadPF = SP::Ph1::Load::make("Load", Logger::Level::debug);
// loadPF->setParameters(scenario.loadActivePower, scenario.loadReactivePower, scenario.systemNominalVoltage);
// loadPF->modifyPowerFlowBusType(PowerflowBusType::PQ);

// Topology
extnetPF->connect({ n1PF });
linePF->connect({ n1PF, n2PF });
Expand Down Expand Up @@ -95,15 +91,12 @@ int main(int argc, char* argv[]) {
loadDP->setParameters(loadActivePower, loadReactivePower, scenario.systemNominalVoltage);

auto pv = DP::Ph1::VSIVoltageControlDQ::make("pv", "pv", Logger::Level::debug, false);
pv->setParameters(scenario.systemNominalOmega, scenario.Vdref, scenario.Vqref);
pv->setControllerParameters(scenario.KpVoltageCtrl, scenario.KiVoltageCtrl, scenario.KpCurrCtrl, scenario.KiCurrCtrl, scenario.systemNominalOmega);
pv->setParameters(scenario.systemNominalOmega, scenario.Vdref, scenario.Vqref, scenario.Pref);
pv->setControllerParameters(scenario.KpVoltageCtrl, scenario.KiVoltageCtrl, scenario.KpCurrCtrl, scenario.KiCurrCtrl, scenario.systemNominalOmega, scenario.m_p, scenario.tau_p, scenario.tau_l);
pv->setFilterParameters(scenario.Lf, scenario.Cf, scenario.Rf, scenario.Rc);
pv->setInitialStateValues(scenario.phi_dInit, scenario.phi_qInit, scenario.gamma_dInit, scenario.gamma_qInit);
pv->withControl(pvWithControl);

// auto lineDP = DP::Ph1::PiLine::make("PiLine", Logger::Level::debug);
// lineDP->setParameters(scenario.lineResistance, scenario.lineInductance, 0, 0);

auto lineDP = DP::Ph1::Resistor::make("Line", Logger::Level::debug);
lineDP->setParameters(scenario.lineResistance);

Expand All @@ -124,13 +117,15 @@ int main(int argc, char* argv[]) {

// Logging
auto loggerDP = DataLogger::make(simNameDP);
loggerDP->logAttribute("Controlled_source_PV", pv->attribute("Vs"));
loggerDP->logAttribute("Controlled_source_PV", pv->attribute("Vs"));
loggerDP->logAttribute("Voltage_terminal_PV", n1DP->attribute("v"));
loggerDP->logAttribute("Voltage_PCC", n2DP->attribute("v"));
loggerDP->logAttribute("Strom_RLC", pv->attribute("i_intf"));
loggerDP->logAttribute("Current_terminal_PV", pv->attribute("i_intf"));
loggerDP->logAttribute("VCO_output", pv->attribute("vco_output"));
loggerDP->logAttribute("P_elec", pv->attribute("P_elec"));
loggerDP->logAttribute("Q_elec", pv->attribute("Q_elec"));



// Simulation
Simulation sim(simNameDP, Logger::Level::debug);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@ int main(int argc, char* argv[]) {
SystemComponentList{linePF, extnetPF, loadPF});

// Logging

auto loggerPF = DataLogger::make(simNamePF);
loggerPF->logAttribute("v1", n1PF->attribute("v"));
loggerPF->logAttribute("v2", n2PF->attribute("v"));


// Simulation
Simulation simPF(simNamePF, Logger::Level::debug);
Expand Down Expand Up @@ -118,17 +116,15 @@ int main(int argc, char* argv[]) {
pv->terminal(0)->setPower(initial3PhPowerVSI);

// Logging


auto loggerEMT = DataLogger::make(simNameEMT);
loggerEMT->logAttribute("Controlled_source_PV", pv->attribute("Vs"));
loggerEMT->logAttribute("Voltage_terminal_PV", n1EMT->attribute("v"));
loggerEMT->logAttribute("Voltage_PCC", n2EMT->attribute("v"));
loggerEMT->logAttribute("Strom_PV", pv->attribute("i_intf"));
loggerEMT->logAttribute("Current_terminal_PV", pv->attribute("i_intf"));
loggerEMT->logAttribute("VCO_output", pv->attribute("vco_output"));
loggerEMT->logAttribute("P_elec", pv->attribute("P_elec"));
loggerEMT->logAttribute("Q_elec", pv->attribute("Q_elec"));



// Simulation
Expand Down

0 comments on commit ff0ad3f

Please sign in to comment.