Aufgrund einer Störung des s3 Storage, könnten in nächster Zeit folgende GitLab Funktionen nicht zur Verfügung stehen: Container Registry, Job Artifacs,. Wir bitten um Verständnis. Es wird mit Hochdruck an der Behebung des Problems gearbeitet. Weitere Informationen zur Störung des Object Storage finden Sie hier: https://maintenance.itc.rwth-aachen.de/ticket/status/messages/59-object-storage-pilot

Commit 0459c880 authored by Markus Mirz's avatar Markus Mirz
Browse files

notebooks: pybind for mat2cim examples


Signed-off-by: Markus Mirz's avatarMarkus Mirz <mmirz@eonerc.rwth-aachen.de>
parent d78a378b
/* Copyright 2017-2020 Institute for Automation of Complex Power Systems,
* EONERC, RWTH Aachen University
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*********************************************************************************/
#include "cps/CIM/Reader.h"
#include <DPsim.h>
using namespace std;
using namespace DPsim;
using namespace CPS;
using namespace CPS::CIM;
/*
* This example runs the powerflow for the CIGRE MV benchmark system (neglecting the tap changers of the transformers)
*/
int main(int argc, char** argv){
// Find CIM files
std::list<fs::path> filenames;
if (argc <= 1) {
filenames = DPsim::Utils::findFiles({
"case14Both.xml"
}, "build/_deps/cim-data-src/Matpower_cases", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
}
String simName = "case14";
CPS::Real system_freq = 50;
CIM::Reader reader(simName, Logger::Level::info, Logger::Level::debug);
SystemTopology system = reader.loadCIM(system_freq, filenames, CPS::Domain::SP);
auto logger = DPsim::DataLogger::make(simName);
for (auto node : system.mNodes)
{
logger->addAttribute(node->name() + ".V", node->attribute("v"));
}
Simulation sim(simName, system, 1, 1, Domain::SP, Solver::Type::NRP, Logger::Level::debug, true);
sim.addLogger(logger);
sim.run();
return 0;
}
/* Copyright 2017-2020 Institute for Automation of Complex Power Systems,
* EONERC, RWTH Aachen University
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*********************************************************************************/
#include "cps/CIM/Reader.h"
#include <DPsim.h>
using namespace std;
using namespace DPsim;
using namespace CPS;
using namespace CPS::CIM;
/*
* This example runs the powerflow for the CIGRE MV benchmark system (neglecting the tap changers of the transformers)
*/
int main(int argc, char** argv){
// Find CIM files
std::list<fs::path> filenames;
if (argc <= 1) {
filenames = DPsim::Utils::findFiles({
"case145.xml"
}, "build/_deps/cim-data-src/Matpower_cases", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
}
String simName = "case145";
CPS::Real system_freq = 50;
CIM::Reader reader(simName, Logger::Level::info, Logger::Level::debug);
SystemTopology system = reader.loadCIM(system_freq, filenames, CPS::Domain::SP);
auto logger = DPsim::DataLogger::make(simName);
for (auto node : system.mNodes)
{
logger->addAttribute(node->name() + ".V", node->attribute("v"));
}
Simulation sim(simName, system, 1, 1, Domain::SP, Solver::Type::NRP, Logger::Level::debug, true);
sim.addLogger(logger);
sim.run();
return 0;
}
/* Copyright 2017-2020 Institute for Automation of Complex Power Systems,
* EONERC, RWTH Aachen University
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*********************************************************************************/
#include "cps/CIM/Reader.h"
#include <DPsim.h>
using namespace std;
using namespace DPsim;
using namespace CPS;
using namespace CPS::CIM;
/*
* This example runs the powerflow for the CIGRE MV benchmark system (neglecting the tap changers of the transformers)
*/
int main(int argc, char** argv){
// Find CIM files
std::list<fs::path> filenames;
if (argc <= 1) {
filenames = DPsim::Utils::findFiles({
"case300.xml"
}, "build/_deps/cim-data-src/Matpower_cases", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
}
String simName = "case300";
CPS::Real system_freq = 50;
CIM::Reader reader(simName, Logger::Level::info, Logger::Level::off);
SystemTopology system = reader.loadCIM(system_freq, filenames, CPS::Domain::SP);
auto logger = DPsim::DataLogger::make(simName);
for (auto node : system.mNodes)
{
logger->addAttribute(node->name() + ".V", node->attribute("v"));
}
Simulation sim(simName, system, 1, 1, Domain::SP, Solver::Type::NRP, Logger::Level::debug, true);
sim.addLogger(logger);
sim.run();
return 0;
}
/* Copyright 2017-2020 Institute for Automation of Complex Power Systems,
* EONERC, RWTH Aachen University
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*********************************************************************************/
#include "cps/CIM/Reader.h"
#include <DPsim.h>
using namespace std;
using namespace DPsim;
using namespace CPS;
using namespace CPS::CIM;
/*
* This example runs the powerflow for the CIGRE MV benchmark system (neglecting the tap changers of the transformers)
*/
int main(int argc, char** argv){
// Find CIM files
std::list<fs::path> filenames;
if (argc <= 1) {
filenames = DPsim::Utils::findFiles({
"case9.xml"
}, "build/_deps/cim-data-src/Matpower_cases", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
}
String simName = "case9";
CPS::Real system_freq = 50;
CIM::Reader reader(simName, Logger::Level::info, Logger::Level::debug);
SystemTopology system = reader.loadCIM(system_freq, filenames, CPS::Domain::SP);
auto logger = DPsim::DataLogger::make(simName);
for (auto node : system.mNodes)
{
logger->addAttribute(node->name() + ".V", node->attribute("v"));
}
Simulation sim(simName, system, 1, 1, Domain::SP, Solver::Type::NRP, Logger::Level::debug, true);
sim.addLogger(logger);
sim.run();
return 0;
}
......@@ -123,11 +123,6 @@ if(WITH_CIM)
CIM/IEEE_LV_PowerFlowTest.cpp
CIM/IEEE_LV_PowerFlowTest_LoadProfiles.cpp
# Mat2CIM examples
CIM/case145.cpp
CIM/case300.cpp
CIM/case9.cpp
CIM/case14.cpp
CIM/powerflow-cim.cpp
# WSCC examples
......
......@@ -20,11 +20,48 @@
"metadata": {},
"outputs": [],
"source": [
"%%bash\n",
"TOP=${TOP:-$(git rev-parse --show-toplevel)}\n",
"PATH=${TOP}/build/Examples/Cxx\n",
"import glob\n",
"from villas.dataprocessing.readtools import *\n",
"import dpsimpy"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"name = 'case14'\n",
"files = glob.glob('../../../build/_deps/cim-data-src/Matpower_cases/case14.xml')\n",
"print(files)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"reader = dpsimpy.CIMReader(name)\n",
"system = reader.loadCIM(50, files, dpsimpy.Domain.SP, dpsimpy.PhaseType.Single)\n",
"system"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sim = dpsimpy.Simulation(name, dpsimpy.LogLevel.info)\n",
"sim.set_system(system)\n",
"sim.set_domain(dpsimpy.Domain.SP)\n",
"sim.set_solver(dpsimpy.Solver.NRP)\n",
"\n",
"case14 ${TOP}/build/_deps/cim-data-src/Matpower_cases/case14.xml"
"logger = dpsimpy.Logger(name)\n",
"sim.add_logger(logger)\n",
"for node in system.nodes:\n",
" logger.log_attribute(node.name()+'.V', 'v', node);"
]
},
{
......@@ -33,11 +70,7 @@
"metadata": {},
"outputs": [],
"source": [
"from villas.dataprocessing.readtools import *\n",
"from villas.dataprocessing.timeseries import *\n",
"import villas.dataprocessing.validationtools as validationtools\n",
"import os\n",
"import urllib.request"
"sim.run()"
]
},
{
......@@ -53,16 +86,26 @@
"metadata": {},
"outputs": [],
"source": [
"path = 'logs/'\n",
"logName = 'case14'\n",
"dpsim_result_file = path + logName + '.csv'\n",
"\n",
"ts_dpsim = read_timeseries_csv(dpsim_result_file)\n",
"\n",
"# Fix for dpsim naming - TODO: unify dpsim notation in log file and update villas-dataprocessing accordingly\n",
"for ts,values in ts_dpsim.items():\n",
" values.name = values.name[:-2]"
"dpsim_result_file = 'logs/' + name + '.csv'\n",
"ts_dpsim = read_timeseries_csv(dpsim_result_file)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for k,v in ts_dpsim.items():\n",
" print(v.name + ':' + str(v.values[0]))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
......@@ -81,7 +124,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
"version": "3.8.7"
}
},
"nbformat": 4,
......
......@@ -20,11 +20,48 @@
"metadata": {},
"outputs": [],
"source": [
"%%bash\n",
"TOP=${TOP:-$(git rev-parse --show-toplevel)}\n",
"PATH=${TOP}/build/Examples/Cxx\n",
"import glob\n",
"from villas.dataprocessing.readtools import *\n",
"import dpsimpy"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"name = 'case145'\n",
"files = glob.glob('../../../build/_deps/cim-data-src/Matpower_cases/case145.xml')\n",
"print(files)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"reader = dpsimpy.CIMReader(name)\n",
"system = reader.loadCIM(50, files, dpsimpy.Domain.SP, dpsimpy.PhaseType.Single)\n",
"system"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sim = dpsimpy.Simulation(name)\n",
"sim.set_system(system)\n",
"sim.set_domain(dpsimpy.Domain.SP)\n",
"sim.set_solver(dpsimpy.Solver.NRP)\n",
"\n",
"case145 ${TOP}/build/_deps/cim-data-src/Matpower_cases/case145.xml"
"logger = dpsimpy.Logger(name)\n",
"sim.add_logger(logger)\n",
"for node in system.nodes:\n",
" logger.log_attribute(node.name()+'.V', 'v', node);"
]
},
{
......@@ -33,11 +70,7 @@
"metadata": {},
"outputs": [],
"source": [
"from villas.dataprocessing.readtools import *\n",
"from villas.dataprocessing.timeseries import *\n",
"import villas.dataprocessing.validationtools as validationtools\n",
"import os\n",
"import urllib.request"
"sim.run()"
]
},
{
......@@ -53,16 +86,26 @@
"metadata": {},
"outputs": [],
"source": [
"path = 'logs/'\n",
"logName = 'case145'\n",
"dpsim_result_file = path + logName + '.csv'\n",
"\n",
"ts_dpsim = read_timeseries_csv(dpsim_result_file)\n",
"\n",
"# Fix for dpsim naming - TODO: unify dpsim notation in log file and update villas-dataprocessing accordingly\n",
"for ts,values in ts_dpsim.items():\n",
" values.name = values.name[:-2]"
"dpsim_result_file = 'logs/' + name + '.csv'\n",
"ts_dpsim = read_timeseries_csv(dpsim_result_file)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for k,v in ts_dpsim.items():\n",
" print(v.name + ':' + str(v.values[0]))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
......@@ -81,7 +124,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
"version": "3.8.7"
}
},
"nbformat": 4,
......
......@@ -20,11 +20,48 @@
"metadata": {},
"outputs": [],
"source": [
"%%bash\n",
"TOP=${TOP:-$(git rev-parse --show-toplevel)}\n",
"PATH=${TOP}/build/Examples/Cxx\n",
"import glob\n",
"from villas.dataprocessing.readtools import *\n",
"import dpsimpy"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"name = 'case300'\n",
"files = glob.glob('../../../build/_deps/cim-data-src/Matpower_cases/case300.xml')\n",
"print(files)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"reader = dpsimpy.CIMReader(name)\n",
"system = reader.loadCIM(50, files, dpsimpy.Domain.SP, dpsimpy.PhaseType.Single)\n",
"system"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sim = dpsimpy.Simulation(name)\n",
"sim.set_system(system)\n",
"sim.set_domain(dpsimpy.Domain.SP)\n",
"sim.set_solver(dpsimpy.Solver.NRP)\n",
"\n",
"case300 ${TOP}/build/_deps/cim-data-src/Matpower_cases/case300.xml"
"logger = dpsimpy.Logger(name)\n",
"sim.add_logger(logger)\n",
"for node in system.nodes:\n",
" logger.log_attribute(node.name()+'.V', 'v', node);"
]
},
{
......@@ -33,11 +70,7 @@
"metadata": {},
"outputs": [],
"source": [
"from villas.dataprocessing.readtools import *\n",
"from villas.dataprocessing.timeseries import *\n",
"import villas.dataprocessing.validationtools as validationtools\n",
"import os\n",
"import urllib.request"
"sim.run()"
]
},
{
......@@ -53,16 +86,26 @@
"metadata": {},
"outputs": [],
"source": [
"path = 'logs/'\n",
"logName = 'case300'\n",
"dpsim_result_file = path + logName + '.csv'\n",
"\n",
"ts_dpsim = read_timeseries_csv(dpsim_result_file)\n",
"\n",
"# Fix for dpsim naming - TODO: unify dpsim notation in log file and update villas-dataprocessing accordingly\n",
"for ts,values in ts_dpsim.items():\n",
" values.name = values.name[:-2]"
"dpsim_result_file = 'logs/' + name + '.csv'\n",
"ts_dpsim = read_timeseries_csv(dpsim_result_file)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for k,v in ts_dpsim.items():\n",
" print(v.name + ':' + str(v.values[0]))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
......@@ -81,7 +124,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
"version": "3.8.7"
}
},
"nbformat": 4,
......
......@@ -20,11 +20,48 @@
"metadata": {},
"outputs": [],
"source": [
"%%bash\n",
"TOP=${TOP:-$(git rev-parse --show-toplevel)}\n",
"PATH=${TOP}/build/Examples/Cxx\n",
"import glob\n",
"from villas.dataprocessing.readtools import *\n",
"import dpsimpy"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"name = 'case9'\n",
"files = glob.glob('../../../build/_deps/cim-data-src/Matpower_cases/case9.xml')\n",
"print(files)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"reader = dpsimpy.CIMReader(name)\n",
"system = reader.loadCIM(50, files, dpsimpy.Domain.SP, dpsimpy.PhaseType.Single)\n",
"system"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sim = dpsimpy.Simulation(name)\n",
"sim.set_system(system)\n",
"sim.set_domain(dpsimpy.Domain.SP)\n",
"sim.set_solver(dpsimpy.Solver.NRP)\n",
"\n",
"case9 ${TOP}/build/_deps/cim-data-src/Matpower_cases/case9.xml"
"logger = dpsimpy.Logger(name)\n",
"sim.add_logger(logger)\n",
"for node in system.nodes:\n",
" logger.log_attribute(node.name()+'.V', 'v', node);"
]
},
{
......@@ -33,11 +70,7 @@
"metadata": {},
"outputs": [],
"source": [
"from villas.dataprocessing.readtools import *\n",
"from villas.dataprocessing.timeseries import *\n",
"import villas.dataprocessing.validationtools as validationtools\n",
"import os\n",
"import urllib.request"
"sim.run()"
]
},
{
......@@ -53,16 +86,26 @@
"metadata": {},
"outputs": [],
"source": [
"path = 'logs/'\n",
"logName = 'case9'\n",
"dpsim_result_file = path + logName + '.csv'\n",