diff --git a/dpsim-villas/examples/cxx/Fpga9BusHil.cpp b/dpsim-villas/examples/cxx/Fpga9BusHil.cpp index 31d40e110..b0b11fc67 100644 --- a/dpsim-villas/examples/cxx/Fpga9BusHil.cpp +++ b/dpsim-villas/examples/cxx/Fpga9BusHil.cpp @@ -4,9 +4,6 @@ * SPDX-FileCopyrightText: 2024 Niklas Eiling * SPDX-License-Identifier: Apache-2.0 */ - -#include "dpsim-models/EMT/EMT_Ph3_RXLoad.h" -#include "dpsim/Definitions.h" #include #include @@ -15,9 +12,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -28,7 +27,7 @@ using namespace CPS::EMT; using namespace CPS::EMT::Ph1; const std::string buildFpgaConfig(CommandLineArgs &args) { - std::filesystem::path fpgaIpPath = "/home/eiling/projects/villas-node/etc/fpga/vc707-xbar-pcie/" + std::filesystem::path fpgaIpPath = "/usr/local/etc/villas/node/etc/fpga/vc707-xbar-pcie/" "vc707-xbar-pcie.json"; if (args.options.find("ips") != args.options.end()) { @@ -88,8 +87,7 @@ const std::string buildFpgaConfig(CommandLineArgs &args) { SystemTopology hilTopology(CommandLineArgs &args, std::shared_ptr intf, std::shared_ptr logger) { std::string simName = "Fpga9BusHil"; - 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"); + 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"); // ----- POWERFLOW FOR INITIALIZATION ----- // read original network topology @@ -118,7 +116,7 @@ SystemTopology hilTopology(CommandLineArgs &args, std::shared_ptr int // ----- DYNAMIC SIMULATION ----- CPS::CIM::Reader reader2(simName); - SystemTopology sys = reader2.loadCIM(60, filenames, Domain::EMT, PhaseType::ABC, CPS::GeneratorType::FullOrder); + SystemTopology sys = reader2.loadCIM(60, filenames, Domain::EMT, PhaseType::ABC, CPS::GeneratorType::IdealVoltageSource); sys.initWithPowerflow(systemPF, CPS::Domain::EMT); @@ -146,14 +144,22 @@ SystemTopology hilTopology(CommandLineArgs &args, std::shared_ptr int // Interface auto seqnumAttribute = CPS::AttributeStatic::make(0); auto current = CPS::AttributeStatic::make(0); + + auto scaledOutputVoltage = CPS::AttributeDynamic::make(0); + auto updateFn = + std::make_shared::Actor>([](std::shared_ptr &dependent, typename CPS::Attribute::Ptr dependency) { *dependent = *dependency / 230000; }); + scaledOutputVoltage->addTask(CPS::UpdateTaskKind::UPDATE_ON_GET, + CPS::AttributeUpdateTask::make(CPS::UpdateTaskKind::UPDATE_ON_GET, *updateFn, sys.node("BUS6")->mVoltage->deriveCoeff(0, 0))); + intf->addImport(seqnumAttribute, true, true); intf->addImport(current, true, true); // intf->addImport(cs->mCurrentRef->deriveReal(), true, true); - intf->addExport(sys.node("BUS6")->mVoltage->deriveCoeff(0, 0)); + intf->addExport(scaledOutputVoltage); // Logger if (logger) { - // logger->logAttribute("cs", cs->mCurrentRef->deriveReal()); + logger->logAttribute("v_scaled", scaledOutputVoltage); + logger->logAttribute("cs", current); logger->logAttribute("v1", sys.node("BUS1")->attribute("v")); logger->logAttribute("v2", sys.node("BUS2")->attribute("v")); logger->logAttribute("v3", sys.node("BUS3")->attribute("v"));