From 6ff080fbcea0fede7ebc34dad272123cf0813622 Mon Sep 17 00:00:00 2001 From: Niklas Eiling Date: Fri, 27 Dec 2024 17:09:51 +0100 Subject: [PATCH] villas-dpsim: change hil example to use VBR generator model Signed-off-by: Niklas Eiling --- dpsim-villas/examples/cxx/Fpga9BusHil.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/dpsim-villas/examples/cxx/Fpga9BusHil.cpp b/dpsim-villas/examples/cxx/Fpga9BusHil.cpp index 39ea11bd6..cbefd327a 100644 --- a/dpsim-villas/examples/cxx/Fpga9BusHil.cpp +++ b/dpsim-villas/examples/cxx/Fpga9BusHil.cpp @@ -7,10 +7,12 @@ #include #include +#include "../examples/cxx/Examples.h" #include #include #include #include +#include #include #include #include @@ -24,6 +26,9 @@ using namespace DPsim; using namespace CPS::EMT; using namespace CPS::EMT::Ph1; +const CPS::CIM::Examples::Components::GovernorKundur::Parameters govKundur; +const CPS::CIM::Examples::Components::ExcitationSystemEremia::Parameters excEremia; + const std::string buildFpgaConfig(CommandLineArgs &args) { std::filesystem::path fpgaIpPath = "/usr/local/etc/villas/node/etc/fpga/vc707-xbar-pcie/" "vc707-xbar-pcie.json"; @@ -85,7 +90,8 @@ const std::string buildFpgaConfig(CommandLineArgs &args) { std::pair>> hilTopology(CommandLineArgs &args, std::shared_ptr intf, std::shared_ptr logger) { std::string simName = "Fpga9BusHil"; auto events = std::make_shared>(); - std::list filenames = Utils::findFiles({"WSCC-09_DI.xml", "WSCC-09_EQ.xml", "WSCC-09_SV.xml", "WSCC-09_TP.xml"}, "build/_deps/cim-data-src/WSCC-09/WSCC-09", "CIMPATH"); + std::list filenames = + Utils::findFiles({"WSCC-09_Dyn_Full_DI.xml", "WSCC-09_Dyn_Full_EQ.xml", "WSCC-09_Dyn_Full_SV.xml", "WSCC-09_Dyn_Full_TP.xml"}, "build/_deps/cim-data-src/WSCC-09/WSCC-09_Dyn_Full", "CIMPATH"); // ----- POWERFLOW FOR INITIALIZATION ----- // read original network topology @@ -114,7 +120,7 @@ std::pair>> hilTopology( // ----- DYNAMIC SIMULATION ----- CPS::CIM::Reader reader2(simName); - SystemTopology sys = reader2.loadCIM(60, filenames, Domain::EMT, PhaseType::ABC, CPS::GeneratorType::IdealVoltageSource); + SystemTopology sys = reader2.loadCIM(60, filenames, Domain::EMT, PhaseType::ABC, CPS::GeneratorType::FullOrderVBR); sys.initWithPowerflow(systemPF, CPS::Domain::EMT); @@ -124,6 +130,16 @@ std::pair>> hilTopology( sys.component("LOAD6")->setParameters(Matrix({{90e6, 0, 0}, {0, 90e6, 0}, {0, 0, 90e6}}), Matrix({{30e6, 0, 0}, {0, 30e6, 0}, {0, 0, 30e6}}), 230e3, true); + auto gen1 = sys.component("GEN1"); + gen1->addGovernor(govKundur.Ta_t, govKundur.Tb, govKundur.Tc, govKundur.Fa, govKundur.Fb, govKundur.Fc, govKundur.Kg, govKundur.Tsr, govKundur.Tsm, 1, 1); + gen1->addExciter(excEremia.Ta, excEremia.Ka, excEremia.Te, excEremia.Ke, excEremia.Tf, excEremia.Kf, excEremia.Tr); + auto gen2 = sys.component("GEN2"); + gen2->addGovernor(govKundur.Ta_t, govKundur.Tb, govKundur.Tc, govKundur.Fa, govKundur.Fb, govKundur.Fc, govKundur.Kg, govKundur.Tsr, govKundur.Tsm, 1, 1); + gen2->addExciter(excEremia.Ta, excEremia.Ka, excEremia.Te, excEremia.Ke, excEremia.Tf, excEremia.Kf, excEremia.Tr); + auto gen3 = sys.component("GEN3"); + gen3->addGovernor(govKundur.Ta_t, govKundur.Tb, govKundur.Tc, govKundur.Fa, govKundur.Fb, govKundur.Fc, govKundur.Kg, govKundur.Tsr, govKundur.Tsm, 1, 1); + gen3->addExciter(excEremia.Ta, excEremia.Ka, excEremia.Te, excEremia.Ke, excEremia.Tf, excEremia.Kf, excEremia.Tr); + auto cs = Ph1::CurrentSource::make("cs"); cs->setParameters(Complex(0, 0)); cs->connect({SimNode::GND, sys.node("BUS6")}); @@ -163,7 +179,7 @@ std::pair>> hilTopology( // Additionally, the current sensor (LXSR 6-NPS) has a sensitivity of 0.1042 V/A (from datasheet), // we are using 3 turns, and we measured an offset voltage of -2.5268 V. constexpr double current_scale = 100. / (3. * 0.1042); - constexpr double current_offset = -2.5268; + constexpr double current_offset = -2.483036; auto scaledCurrent = CPS::AttributeDynamic::make(0); auto closedLoop = CPS::AttributeStatic::make(false); auto currentScaleFn = std::make_shared::Actor>([](std::shared_ptr &dependent, typename CPS::Attribute::Ptr dependency) { @@ -220,6 +236,7 @@ int main(int argc, char *argv[]) { sim.setSystem(topo.first); sim.addInterface(intf); sim.setLogStepTimes(false); + sim.doSystemMatrixRecomputation(true); for (auto event : *topo.second) { sim.addEvent(event); }