Commit 9c9eb3dc authored by Markus Mirz's avatar Markus Mirz
Browse files

remove deprecated examples


Signed-off-by: Markus Mirz's avatarMarkus Mirz <mmirz@eonerc.rwth-aachen.de>
parent c2799db5
IEEE-09_Neplan_RX:
cmd: build/Examples/Cxx/dpsim-cim
args:
- Examples/CIM/IEEE-09_Neplan_RX/IEEE-09_Neplan_RX_DI.xml
- Examples/CIM/IEEE-09_Neplan_RX/IEEE-09_Neplan_RX_EQ.xml
- Examples/CIM/IEEE-09_Neplan_RX/IEEE-09_Neplan_RX_SV.xml
- Examples/CIM/IEEE-09_Neplan_RX/IEEE-09_Neplan_RX_TP.xml
IEEE-14_Neplan:
cmd: build/Examples/Cxx/dpsim-cim
args:
- Examples/CIM/IEEE-14_Neplan/Rootnet_FULL_NE_29J09h_DI.xml
- Examples/CIM/IEEE-14_Neplan/Rootnet_FULL_NE_29J09h_EQ.xml
- Examples/CIM/IEEE-14_Neplan/Rootnet_FULL_NE_29J09h_SV.xml
- Examples/CIM/IEEE-14_Neplan/Rootnet_FULL_NE_29J09h_TP.xml
IEEE-39_Neplan:
cmd: build/Examples/Cxx/dpsim-cim
args:
- Examples/CIM/IEEE-39_Neplan/Rootnet_FULL_NE_29J10h_DI.xml
- Examples/CIM/IEEE-39_Neplan/Rootnet_FULL_NE_29J10h_EQ.xml
- Examples/CIM/IEEE-39_Neplan/Rootnet_FULL_NE_29J10h_SV.xml
- Examples/CIM/IEEE-39_Neplan/Rootnet_FULL_NE_29J10h_TP.xml
\ No newline at end of file
/* 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>
#include <cps/CSVReader.h>
using namespace std;
using namespace DPsim;
using namespace CPS;
using namespace CPS::CIM;
/*
* This example runs the powerflow for the IEEE LV EU benchmark system
*/
int main(int argc, char** argv){
#ifdef _WIN32
String loadProfilePath("..\\..\\..\\..\\SimulationData\\Load\\IEEE_European_LV_TestFeeder_v2_Profiles\\csv\\");
#elif defined(__linux__) || defined(__APPLE__)
String loadProfilePath("../SimulationData/Load/IEEE_European_LV_TestFeeder_v2_Profiles/csv/");
#endif
// Find CIM files
std::list<fs::path> filenames;
if (argc <= 1) {
filenames = DPsim::Utils::findFiles({
"Rootnet_FULL_NE_06J16h_DI.xml",
"Rootnet_FULL_NE_06J16h_EQ.xml",
"Rootnet_FULL_NE_06J16h_SV.xml",
"Rootnet_FULL_NE_06J16h_TP.xml"
}, "build/_deps/cim-data-src/IEEE_EU_LV/IEEE_EU_LV_reduced", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
}
String simName = "IEEE-LV-reduced";
CPS::Real system_freq = 50;
/*
create assign list
*/
std::map<String, String> assignList;
for (const auto & entry : std::experimental::filesystem::directory_iterator(loadProfilePath))
{
string filename = entry.path().filename().string();
string load_number;
for (auto &c : filename) {
if (isdigit(c)) {
load_number += c;
}
}
assignList.insert(std::pair<string,string>("PQ"+load_number,"Load_profile_"+load_number));
}
CIM::Reader reader(simName, Logger::Level::info, Logger::Level::off);
SystemTopology system = reader.loadCIM(system_freq, filenames, CPS::Domain::SP);
//load profile lpreader
CSVReader csvreader(simName, loadProfilePath, assignList, Logger::Level::info);
csvreader.assignLoadProfile(system, 1, 1, 30, CSVReader::Mode::MANUAL, CSVReader::DataFormat::HHMMSS);
auto logger = DPsim::DataLogger::make(simName);
for (auto node : system.mNodes)
{
logger->addAttribute(node->name(), node->attribute("v"));
}
Simulation sim(simName, system, 1, 30, Domain::SP, Solver::Type::NRP, Logger::Level::info, 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 <iostream>
#include <list>
#include <DPsim.h>
#include <dpsim/Utils.h>
using namespace DPsim;
int main(int argc, char *argv[]) {
CommandLineArgs args(argc, argv);
String simName = "dpsim";
CIMReader reader(simName);
SystemTopology sys = reader.loadCIM(args.sysFreq, args.positionalPaths(), args.solver.domain);
Simulation sim(simName, sys, args.timeStep, args.duration, args.solver.domain, args.solver.type);
// ToDO: add DataLoggers
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;
filenames = std::list<fs::path>(argv + 2, argv + argc);
String simName = argv[1];
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;
}
......@@ -110,7 +110,6 @@ if(WITH_CIM)
list(APPEND INCLUDE_DIRS ${CIMPP_INCLUDE_DIRS})
set(CIM_SOURCES
CIM/dpsim-cim.cpp
CIM/WSCC-9bus_CIM.cpp
CIM/WSCC-9bus_CIM_Dyn.cpp
CIM/WSCC-9bus_CIM_Dyn_Switch.cpp
......@@ -121,9 +120,6 @@ if(WITH_CIM)
CIM/CIGRE_MV_PowerFlowTest.cpp
CIM/CIGRE_MV_PowerFlowTest_LoadProfiles.cpp
CIM/IEEE_LV_PowerFlowTest.cpp
CIM/IEEE_LV_PowerFlowTest_LoadProfiles.cpp
CIM/powerflow-cim.cpp
# WSCC examples
CIM/WSCC_9bus_mult_decoupled.cpp
......
% This script read the step durantion of the synchronous generator and
%calculate the average duration.
%% read
TestName = 'MultimachineTest';
GeneratorType = 'Dq';
SimulationType = 'DP';
TimeStep = '0.000050';
Path = ['../../../vsa/Results/',TestName,'/DPsim/',SimulationType,'/',GeneratorType,'/','RESERVE/'];
FileName = ['SynGen_',SimulationType,'_',GeneratorType,'_',TimeStep,'.csv'];
Log_SynGen = csvread([Path,FileName],1);
%% Calculate avarage step time
StepTimeVector = Log_SynGen(:,2);
disp(['Avarage step time for generator: ', num2str(mean(StepTimeVector)*1000), ' ms']);
\ No newline at end of file
function [ ] = CompareInductorModels(filenameVoltageInductor1, filenameVoltageInductor2, plotNode)
% Increment node to skip time column
plotNode = plotNode + 1
% Read values from CSV files
voltageInductor1 = csvread(filenameVoltageInductor1);
compOffsetDP = (size(voltageInductor1,2) - 1) / 2;
voltageInductor2 = csvread(filenameVoltageInductor2);
% Calculate DP absolute value
voltageAbs1 = voltageInductor1(:,1);
for col = 2:( compOffsetDP + 1 )
for row = 1:size(voltageInductor1,1)
voltageAbs1(row,col) = sqrt(voltageInductor1(row,col)^2 + ...
voltageInductor1(row,col+compOffsetDP)^2);
end
end
voltageAbs2 = voltageInductor2(:,1);
for col = 2:( compOffsetDP + 1 )
for row = 1:size(voltageInductor2,1)
voltageAbs2(row,col) = sqrt(voltageInductor2(row,col)^2 + ...
voltageInductor2(row,col+compOffsetDP)^2);
end
end
% Shift DP values
voltageShiftDP1 = voltageInductor1(:,1);
for col = 2:(compOffsetDP + 1)
for row = 1:size(voltageInductor1,1)
voltageShiftDP1(row,col) = voltageInductor1(row,col)*cos(2*pi*50*voltageInductor1(row,1)) - ...
voltageInductor1(row,col+compOffsetDP)*sin(2*pi*50*voltageInductor1(row,1));
end
end
voltageShiftDP2 = voltageInductor2(:,1);
for col = 2:(compOffsetDP + 1)
for row = 1:size(voltageInductor2,1)
voltageShiftDP2(row,col) = voltageInductor2(row,col)*cos(2*pi*50*voltageInductor2(row,1)) - ...
voltageInductor2(row,col+compOffsetDP)*sin(2*pi*50*voltageInductor2(row,1));
end
end
%% Plot
DPplot = plot(voltageShiftDP1(:,1),voltageShiftDP1(:,plotNode), 'g--o');
hold on
DPabsPlot = plot(voltageAbs1(:,1),voltageAbs1(:,plotNode), 'b--o');
DPplot2 = plot(voltageShiftDP2(:,1),voltageShiftDP2(:,plotNode), 'y');
DPabsPlot2 = plot(voltageAbs2(:,1),voltageAbs2(:,plotNode), 'r');
legend('Shift1', 'Abs 1', 'Shift2','Abs 2')
xlabel('time [s]')
ylabel('voltage [V]')
end
\ No newline at end of file
% model with 2 nodes
fileName1='../VisualStudio/DPsimVS2015/Logs/LeftVectorLog_SimulationExampleRXLine3_0.001.csv';
% circuit with R and L
fileName2='../VisualStudio/DPsimVS2015/Logs/LeftVectorLog_SimulationExampleRXLine2_0.001.csv'
%model with 3 nodes
fileName3='../VisualStudio/DPsimVS2015/Logs/LeftVectorLog_SimulationExampleRXLine_0.001.csv';
compareDpResults(fileName1,fileName2,2,3,'Model with 2 nodes x Resistor + Inductor');
compareDpResults(fileName3,fileName2,2,3,'Model with 3 nodes x Resistor + Inductor');
% circuit with R, L and C
fileName1='../VisualStudio/DPsimVS2015/Logs/LeftVectorLog_SimulationExamplePiLine_0.001.csv'
%model with 3 nodes
fileName2='../VisualStudio/DPsimVS2015/Logs/LeftVectorLog_SimulationExamplePiLine2_0.001.csv';
compareDpResults(fileName1,fileName2,1,1,'Model with 3 nodes x Resistor + Inductor');
clear all;
close all;
filenameDP = 'LeftVectorLog_VarFreqRXLineResLoad';
filenameEMT = 'LeftVectorLog_VarFreqRXLineResLoadEMT';
path = '../VisualStudio/DPsimVS2017/Logs/';
finalTime = '_0.4';
timeStepRef = '_5e-05';
dataType = '.csv';
%%
fprintf('Time step 50 mic sec \r')
timeStep = '_0.001';
filenameVoltageDP = strcat(path, filenameDP, timeStep, dataType);
timeStep = '_5e-05';
filenameVoltageEMT = strcat(path, filenameEMT, timeStep, dataType);
mseDP = plotDpEmtVoltage(filenameVoltageDP, filenameVoltageEMT, 3);
filenameDP = 'LeftVectorLog_VarFreqRXLineResLoad';
filenameEMT = 'LeftVectorLog_VarFreqRXLineResLoadEMT';
path = '../VisualStudio/DPsimVS2015/Logs/';
finalTime = '_0.6';
timeStepRef = '_5e-05';
dataType = '.csv';
timeStep = '_0.001';
filenameVoltageDP = strcat(path, filenameDP, timeStep, finalTime, dataType);
filenameVoltageEMT = strcat(path, filenameEMT, timeStep, finalTime, dataType);
filenameRef = strcat(path, filenameEMT, timeStepRef, finalTime, dataType);
% Read from CSV files
voltageRef = csvread(filenameRef);
voltageDP = csvread(filenameVoltageDP);
compOffsetDP = (size(voltageDP,2) - 1) / 2;
voltageEMT = csvread(filenameVoltageEMT);
% Calculate DP absolute value
voltageAbsDP = voltageDP(:,1);
for col = 2:( compOffsetDP + 1 )
for row = 1:size(voltageDP,1)
voltageAbsDP(row,col) = sqrt(voltageDP(row,col)^2 + ...
voltageDP(row,col+compOffsetDP)^2);
end
end
% Shift DP values
voltageShiftDP = voltageDP(:,1);
for col = 2:(compOffsetDP + 1)
for row = 1:size(voltageDP,1)
voltageShiftDP(row,col) = voltageDP(row,col)*cos(2*pi*50*voltageDP(row,1)) - ...
voltageDP(row,col+compOffsetDP)*sin(2*pi*50*voltageDP(row,1));
end
end
% Downsampling of reference voltage
for row = 1:size(voltageShiftDP,1)
if voltageRef(size(voltageRef,1),1) >= voltageShiftDP(row,1)
indices(row) = find(voltageRef(:,1) == voltageShiftDP(row,1),1);
end
end
for i = 1:size(indices,2)
row = indices(1,i)
for col = 1:size(voltageRef,2)
voltageRefAligned(i,col) = voltageRef(row,col);
end
end
% Calculate MSEs
mseDP = sum((voltageRefAligned - voltageShiftDP).^2) / size(voltageRefAligned,1)
mseEMT = sum((voltageRefAligned - voltageEMT).^2) / size(voltageRefAligned,1)
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# WSCC 9-bus System Tests"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Monolithic Simulation"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from villas.dataprocessing.dpsim import *\n",
"from villas.dataprocessing.plottools import *"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Read log files and list all column names"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"path_orig = '../dpsim/Logs/'\n",
"logName_orig = 'WSCC-9bus_LeftVector'\n",
"logFilename_orig = path_orig + logName_orig + '.csv'\n",
"print(logFilename_orig)\n",
"\n",
"ts_dpsim_orig = read_timeseries_dpsim(logFilename_orig)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Phasors at first time step"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"phasors_orig = get_node_voltage_phasors(ts_dpsim_orig)\n",
"for node, phasor in phasors_orig.items():\n",
" print(node + ': ' + str(phasor['abs'].values[0]) + '<' + str(phasor['phase'].values[0]))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Phasors at last time step"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for node, phasor in phasors_orig.items():\n",
" print(node + ': ' + str(phasor['abs'].values[-1]) + '<' + str(phasor['phase'].values[-1]))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Phasors at last time step in per unit"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"nominal_voltages_orig = {'node00000': 18000, 'node00001': 230000, 'node00002': 230000, \n",
" 'node00003': 230000, 'node00004': 16500, 'node00005': 230000, \n",
" 'node00006': 230000, 'node00007': 230000, 'node00008': 13800}\n",
"for node, nom_voltage in nominal_voltages_orig.items():\n",
" print(node + ': ' + str(phasors_orig[node]['abs'].values[0] / nom_voltage) + '<' + str(phasors_orig[node]['phase'].values[0]))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Plot node phase\n",
"The phase at node 8 is not initialized properly since the CIM load flow data is not accurate. Therefore, the steady-state initialization implemented in the MNA solver is executed first so that the initial phase at t=0 is already very close to the correct one.\n",
"Using PI-lines with parallel impedances to ground not only during the initialization but also the simulation or more accurate CIM load flow results would probably further improve the results because the values around n8 have still not converged completely."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plot_timeseries(1, phasors_orig['node00007']['phase'])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Plot node voltages"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plot_timeseries(2, phasors_orig['node00001']['abs'])\n",
"plot_timeseries(2, phasors_orig['node00002']['abs'])\n",
"plot_timeseries(2, phasors_orig['node00003']['abs'])\n",
"plot_timeseries(2, phasors_orig['node00005']['abs'])\n",
"plot_timeseries(2, phasors_orig['node00006']['abs'])\n",
"plot_timeseries(2, phasors_orig['node00007']['abs'])\n",
"plt.gca().axes.set_ylim([200000,240000])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The results for n2 are very good."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plot_timeseries(2, phasors_orig['node00001']['abs'])\n",
"plt.gca().axes.set_ylim([229300,229500])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Shmem Simulation"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from villas.dataprocessing.dpsim import *\n",
"from villas.dataprocessing.plottools import *"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Read log files and list all column names"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"path_shmem = 'D:/mmi/git/Simulation/dpsim/build/Logs/'\n",
"logName_shmem = 'Shmem_WSCC-9bus_LeftVector'\n",
"logFilename_shmem = path_shmem + logName_shmem + '.csv'\n",
"print(logFilename_shmem)\n",
"\n",
"ts_dpsim_shmem = read_timeseries_dpsim_cmpl(logFilename_shmem)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Phasors at first time step"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"phasors_shmem = get_node_voltage_phasors(ts_dpsim_shmem)\n",
"for node, phasor in phasors_shmem.items():\n",
" print(node + ': ' + str(phasor['abs'].values[0]) + '<' + str(phasor['phase'].values[0]))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [