|
| 1 | +/* Copyright 2017-2020 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 <cps/CIM/Reader.h> |
| 10 | +#include <DPsim.h> |
| 11 | + |
| 12 | +using namespace std; |
| 13 | +using namespace DPsim; |
| 14 | +using namespace CPS; |
| 15 | +using namespace CPS::CIM; |
| 16 | + |
| 17 | +/* |
| 18 | + * This example runs the powerflow for the CIGRE MV benchmark system (neglecting the tap changers of the transformers) |
| 19 | + */ |
| 20 | +int main(int argc, char** argv) { |
| 21 | + |
| 22 | + // Find CIM files |
| 23 | + std::list<fs::path> filenames; |
| 24 | + if (argc <= 1) { |
| 25 | + filenames = DPsim::Utils::findFiles({ |
| 26 | + "Slack_Trafo3W_PowerFlow_EQ.xml", |
| 27 | + "Slack_Trafo3W_PowerFlow_TP.xml", |
| 28 | + "Slack_Trafo3W_PowerFlow_SV.xml", |
| 29 | + "Slack_Trafo3W_PowerFlow_SSH.xml" |
| 30 | + }, "build/_deps/cim-data-src/BasicGrids/Slack_Trafo3W_PowerFlow", "CIMPATH"); |
| 31 | + } |
| 32 | + else { |
| 33 | + filenames = std::list<fs::path>(argv + 1, argv + argc); |
| 34 | + } |
| 35 | + |
| 36 | + String simName = "Trafo3W_PFSolver"; |
| 37 | + CPS::Real system_freq = 60; |
| 38 | + |
| 39 | + CIM::Reader reader(simName, Logger::Level::debug, Logger::Level::off); |
| 40 | + SystemTopology system = reader.loadCIM( |
| 41 | + system_freq, |
| 42 | + filenames, |
| 43 | + CPS::Domain::SP, |
| 44 | + CPS::PhaseType::Single, |
| 45 | + CPS::GeneratorType::PVNode |
| 46 | + ); |
| 47 | + system.renderToFile("build/_deps/cim-data-src/BasicGrids/PowerFactory/Slack_Trafo3W_PowerFlow/Trafo3W_PowerFlowTest.svg"); |
| 48 | + |
| 49 | + auto logger = DPsim::DataLogger::make(simName); |
| 50 | + for (auto node : system.mNodes) |
| 51 | + { |
| 52 | + logger->addAttribute(node->name() + ".V", node->attribute("v")); |
| 53 | + } |
| 54 | + |
| 55 | + Simulation sim(simName, Logger::Level::debug); |
| 56 | + sim.setSystem(system); |
| 57 | + sim.setTimeStep(1); |
| 58 | + sim.setFinalTime(1); |
| 59 | + sim.setDomain(Domain::SP); |
| 60 | + sim.setSolverType(Solver::Type::NRP); |
| 61 | + sim.doInitFromNodesAndTerminals(true); |
| 62 | + sim.addLogger(logger); |
| 63 | + |
| 64 | + sim.run(); |
| 65 | + |
| 66 | + return 0; |
| 67 | +} |
0 commit comments