Commit 6e63e2d9 authored by Markus Mirz's avatar Markus Mirz
Browse files

add more powerflow examples and revise solver

parent 218b96f7
......@@ -14,6 +14,7 @@ wheelhouse/
*.pdf
*.svg
*.png
Examples/Notebooks/Grids/reference-results/
# Folders
Libraries/
......
[submodule "Dependencies/libcps"]
path = Dependencies/libcps
url = ../cpowersystems.git
[submodule "Examples/CIM/grid-data"]
path = Examples/CIM/grid-data
url = ../../grid-data/cim-grid-data.git
Subproject commit 6ac46f089d543665920cbb0ef8841f8bba98ca1a
Subproject commit 811f480b1b3eea0971f432e551c8e30aebbc954c
Subproject commit 732a79cc615c5b539fba5156008a1232c358c419
......@@ -59,7 +59,7 @@ int main(int argc, char** argv){
logger->addAttribute(node->name() + ".V", node->attribute("v"));
}
Simulation sim(simName, system, 1, 120, Domain::SP, Solver::Type::NRP, Logger::Level::off, true);
Simulation sim(simName, system, 1, 1, Domain::SP, Solver::Type::NRP, Logger::Level::off, true);
sim.addLogger(logger);
sim.run();
......
......@@ -36,12 +36,12 @@ int main(int argc, char** argv){
// Find CIM files
std::list<fs::path> filenames;
if (argc <= 1) {
filenames = DPsim::Utils::findFiles({
"Rootnet_FULL_NE_13J16h_DI.xml",
"Rootnet_FULL_NE_13J16h_EQ.xml",
"Rootnet_FULL_NE_13J16h_SV.xml",
"Rootnet_FULL_NE_13J16h_TP.xml"
}, "Examples/CIM/IEEE_EU_LV_reduced", "CIMPATH");
filenames = DPsim::Utils::findFiles({
"Rootnet_FULL_NE_13J16h_DI.xml",
"Rootnet_FULL_NE_13J16h_EQ.xml",
"Rootnet_FULL_NE_13J16h_SV.xml",
"Rootnet_FULL_NE_13J16h_TP.xml"
}, "Examples/CIM/IEEE_EU_LV_reduced", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
......@@ -59,7 +59,7 @@ int main(int argc, char** argv){
logger->addAttribute(node->name() + ".V", node->attribute("v"));
}
Simulation sim(simName, system, 1, 5, Domain::SP, Solver::Type::NRP, Logger::Level::info, true);
Simulation sim(simName, system, 1, 1, Domain::SP, Solver::Type::NRP, Logger::Level::debug, true);
sim.addLogger(logger);
sim.run();
......
/**
* @author Jan Dinkelbach <jdinkelbach@eonerc.rwth-aachen.de>
* @copyright 2019, Institute for Automation of Complex Power Systems, EONERC
*
* DPsim
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
#include "cps/CIM/Reader.h"
#include <DPsim.h>
#include "cps/LoadProfileReader.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({
"LV_SOGNO.xml"
}, "Examples/CIM", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
}
String simName = "LV_SOGNO";
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;
}
/**
* @author Jan Dinkelbach <jdinkelbach@eonerc.rwth-aachen.de>
* @copyright 2019, Institute for Automation of Complex Power Systems, EONERC
*
* DPsim
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
#include "cps/CIM/Reader.h"
#include <DPsim.h>
#include "cps/LoadProfileReader.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({
"Rootnet_FULL_NE_12J12h_DI.xml",
"Rootnet_FULL_NE_12J12h_EQ.xml",
"Rootnet_FULL_NE_12J12h_SV.xml",
"Rootnet_FULL_NE_12J12h_TP.xml"
}, "Examples/CIM/Slack_TrafoTapChanger_Load", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
}
String simName = "Slack_TrafoTapChanger_Load";
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;
}
/**
* @author Jan Dinkelbach <jdinkelbach@eonerc.rwth-aachen.de>
* @copyright 2019, Institute for Automation of Complex Power Systems, EONERC
*
* DPsim
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
#include "cps/CIM/Reader.h"
#include <DPsim.h>
#include "cps/LoadProfileReader.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({
"Rootnet_FULL_NE_23J10h_DI.xml",
"Rootnet_FULL_NE_23J10h_EQ.xml",
"Rootnet_FULL_NE_23J10h_SV.xml",
"Rootnet_FULL_NE_23J10h_TP.xml"
}, "Examples/CIM/Slack_Trafo_Load", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
}
String simName = "Slack_Trafo_Load";
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;
}
/**
* @author Jan Dinkelbach <jdinkelbach@eonerc.rwth-aachen.de>
* @copyright 2019, Institute for Automation of Complex Power Systems, EONERC
*
* DPsim
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
#include "cps/CIM/Reader.h"
#include <DPsim.h>
#include "cps/LoadProfileReader.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"
}, "Examples/CIM/grid-data/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;
}
/**
* @author Jan Dinkelbach <jdinkelbach@eonerc.rwth-aachen.de>
* @copyright 2019, Institute for Automation of Complex Power Systems, EONERC
*
* DPsim
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
#include "cps/CIM/Reader.h"
#include <DPsim.h>
#include "cps/LoadProfileReader.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"
}, "Examples/CIM/grid-data/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;
}
/**
* @author Jan Dinkelbach <jdinkelbach@eonerc.rwth-aachen.de>
* @copyright 2019, Institute for Automation of Complex Power Systems, EONERC
*
* DPsim
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
#include "cps/CIM/Reader.h"
#include <DPsim.h>
#include "cps/LoadProfileReader.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"
}, "Examples/CIM/grid-data/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;
}
/**
* @author Jan Dinkelbach <jdinkelbach@eonerc.rwth-aachen.de>
* @copyright 2019, Institute for Automation of Complex Power Systems, EONERC
*
* DPsim
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
#include "cps/CIM/Reader.h"
#include <DPsim.h>
#include "cps/LoadProfileReader.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"
}, "Examples/CIM/grid-data/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;
}
......@@ -79,7 +79,7 @@ if(WITH_SHMEM)
Shmem/ShmemControllableSource.cpp
Shmem/ShmemControllableFiltSource.cpp
Shmem/Shmem_CIGRE_MV_PowerFlowTest.cpp
Shmem/Shmem_CIGRE_MV_PowerFlowTest_LoadProfiles.cpp
#Shmem/Shmem_CIGRE_MV_PowerFlowTest_LoadProfiles.cpp
)
endif()
......@@ -93,12 +93,19 @@ if(WITH_CIM)
CIM/WSCC-9bus_CIM_Dyn.cpp
CIM/WSCC-9bus_CIM_Dyn_Switch.cpp
# powerflow example
# powerflow example
CIM/Slack_Trafo_Load.cpp
CIM/Slack_TrafoTapChanger_Load.cpp
CIM/CIGRE_MV_PowerFlowTest.cpp
CIM/CIGRE_MV_PowerFlowTest_LoadProfiles.cpp
#CIM/CIGRE_MV_PowerFlowTest_LoadProfiles.cpp
CIM/IEEE_LV_PowerFlowTest.cpp
CIM/IEEE_LV_PowerFlowTest_LP.cpp
#CIM/IEEE_LV_PowerFlowTest_LP.cpp
CIM/case145.cpp
CIM/case300.cpp
CIM/case9.cpp
CIM/case14.cpp
CIM/LV_SOGNO.cpp
CIM/WSCC_9bus_mult_decoupled.cpp
CIM/WSCC_9bus_mult_coupled.cpp
......
%% Cell type:markdown id: tags:
# CIGRE MV Powerflow Solver Test
# IEEE LV Powerflow Solver Test
%% Cell type:markdown id: tags:
## Run simulation
%% Cell type:code id: tags:
``` python
%%bash
TOP=${TOP:-$(git rev-parse --show-toplevel)}
PATH=${TOP}/build/Examples/Cxx
IEEE_LV_PowerFlowTest ${TOP}/Examples/CIM/IEEE_EU_LV_reduced/*.xml
```
%% Output
CIMContentHandler: Note: 0 out of 5507 tasks remain unresolved!
%% Cell type:code id: tags:
``` python
from villas.dataprocessing.readtools import *
from villas.dataprocessing.timeseries import *
import villas.dataprocessing.validationtools as validationtools
import os
import urllib.request
```
%% Cell type:markdown id: tags:
## Read DPsim results
%% Cell type:code id: tags:
``` python
path = 'logs/'
logName = 'IEEE_EU_LV_reduced'
dpsim_result_file = path + logName + '.csv'
ts_dpsim = read_timeseries_csv(dpsim_result_file)
# Fix for dpsim naming - TODO: unify dpsim notation in log file and update villas-dataprocessing accordingly
for ts,values in ts_dpsim.items():
values.name = values.name[:-2]
```
%% Output
column number: 135
results length: 5
real column names: []
complex column names: ['N0.V', 'N1.V', 'N10.V', 'N100.V', 'N101.V', 'N102.V', 'N103.V', 'N104.V', 'N105.V', 'N106.V', 'N107.V', 'N108.V', 'N109.V', 'N11.V', 'N110.V', 'N111.V', 'N112.V', 'N113.V', 'N114.V', 'N115.V', 'N116.V', 'N117.V', 'N118.V', 'N119.V', 'N12.V', 'N120.V', 'N121.V', 'N122.V', 'N123.V', 'N124.V', 'N125.V', 'N126.V', 'N127.V', 'N128.V', 'N129.V', 'N13.V', 'N130.V', 'N131.V', 'N132.V', 'N133.V', 'N134.V', 'N14.V', 'N15.V', 'N16.V', 'N17.V', 'N18.V', 'N19.V', 'N2.V', 'N20.V', 'N21.V', 'N22.V', 'N23.V', 'N24.V', 'N25.V', 'N26.V', 'N27.V', 'N28.V', 'N29.V', 'N3.V', 'N30.V', 'N31.V', 'N32.V', 'N33.V', 'N34.V', 'N35.V', 'N36.V', 'N37.V', 'N38.V', 'N39.V', 'N4.V', 'N40.V', 'N41.V', 'N42.V', 'N43.V', 'N44.V', 'N45.V', 'N46.V', 'N47.V', 'N48.V', 'N49.V', 'N5.V', 'N50.V', 'N51.V', 'N52.V', 'N53.V', 'N54.V', 'N55.V', 'N56.V', 'N57.V', 'N58.V', 'N59.V', 'N6.V', 'N60.V', 'N61.V', 'N62.V', 'N63.V', 'N64.V', 'N65.V', 'N66.V', 'N67.V', 'N68.V', 'N69.V', 'N7.V', 'N70.V', 'N71.V', 'N72.V', 'N73.V', 'N74.V', 'N75.V', 'N76.V', 'N77.V', 'N78.V', 'N79.V', 'N8.V', 'N80.V', 'N81.V', 'N82.V', 'N83.V', 'N84.V', 'N85.V', 'N86.V', 'N87.V', 'N88.V', 'N89.V', 'N9.V', 'N90.V', 'N91.V', 'N92.V', 'N93.V', 'N94.V', 'N95.V', 'N96.V', 'N97.V', 'N98.V', 'N99.V']
%% Cell type:markdown id: tags:
## Read NEPLAN results as reference
%% Cell type:code id: tags:
``` python
if not os.path.exists('reference-results'):
os.mkdir('reference-results')
url = 'https://git.rwth-aachen.de/acs/public/simulation/reference-results/raw/master/Neplan/ReferenceGrids/IEEE_EU_LV.rlf'
neplan_result_file = 'reference-results/IEEE_EU_LV.rlf'
urllib.request.urlretrieve(url, neplan_result_file)
print(neplan_result_file)
ts_NEPLAN = read_timeseries_NEPLAN_loadflow(neplan_result_file)
# print([ts_NEPLAN[i].name for i in range(len(ts_NEPLAN))])
```
%% Output
reference-results/IEEE_EU_LV.rlf
%% Cell type:markdown id: tags:
## Comparison and assertion of results
%% Cell type:code id: