Commit f83bc49d authored by Markus Mirz's avatar Markus Mirz
Browse files

Merge branch 'rt-sim-tests' into 'master'

Rt sim tests

See merge request acs/public/simulation/dpsim!110
parents 286be261 66194ef9
......@@ -8,6 +8,7 @@ _dpsim.pyd
_dpsim.pdb
.pytest_cache/
logs/
logs_*/
wheelhouse/
*.csv
......
......@@ -53,9 +53,7 @@ find_package(PythonInterp 3.6)
find_package(PythonLibs 3.6)
find_package(Sundials)
if (NOT WIN32)
find_package(OpenMP)
endif()
find_package(OpenMP)
find_package(GSL)
find_package(VILLASnode)
......@@ -111,6 +109,11 @@ if(COMPARE_REFERENCE)
)
endif()
message("Compiler Release Flags:")
message(${CMAKE_CXX_FLAGS_RELEASE})
message("Compiler Debug Flags:")
message(${CMAKE_CXX_FLAGS_DEBUG})
if(TOPLEVEL_PROJECT)
# Show feature summary
include(FeatureSummary)
......
#!/bin/bash
for (( i = 0; i < 20; i++ ))
do
for (( j = 0; j <= 12; j = j+2 ))
do
for (( k = 1; k <= 10; k++ ))
do
sudo taskset --all-tasks --cpu-list 12-23 chrt --fifo 99 build/Examples/Cxx/WSCC_9bus_mult_coupled -ocopies=$i -othreads=$j -oseq=$k
done
done
done
#!/bin/bash
for (( i = 0; i < 20 ; i++ ))
do
for (( j = 0 ; j <= 12; j = j+2 ))
do
for (( k = 1 ; k <= 100; k++ ))
do
sudo taskset --all-tasks --cpu-list 12-23 chrt --fifo 99 build/Examples/Cxx/WSCC_9bus_mult_decoupled -ocopies=$i -othreads=$j -oseq=$k
done
done
done
\ No newline at end of file
#!/bin/bash
for (( m = 1 ; m <= 10; m++ ))
do
for (( i = 0; i < 20 ; i++ ))
do
for (( j = 0 ; j <= 12; j = j+2 ))
do
for (( k = 0 ; k <= $i+1; k++ ))
do
sudo taskset --all-tasks --cpu-list 12-23 chrt --fifo 99 build/Examples/Cxx/WSCC_9bus_mult_diakoptics -ocopies=$i -othreads=$j -osplits=$k -oseq=$m
done
done
done
done
\ No newline at end of file
#!/bin/bash
for (( j = 0; j <= 12; j = j+2 ))
do
for (( k = 1; k <= 10; k++ ))
do
sudo taskset --all-tasks --cpu-list 12-23 chrt --fifo 99 build/Examples/Cxx/DP_Inverter_Grid_Parallel_FreqSplit -othreads=$j -oseq=$k
done
done
for (( j = 0; j <= 12; j = j+2 ))
do
for (( k = 1; k <= 10; k++ ))
do
sudo taskset --all-tasks --cpu-list 12-23 chrt --fifo 99 build/Examples/Cxx/DP_Inverter_Grid_Parallel -othreads=$j -oseq=$k
done
done
\ No newline at end of file
#!/bin/bash
for (( i = 1; i <= 20; i++ ))
do
for (( j = 0; j <= 12; j = j+2 ))
do
for (( k = 1; k <= 50; k++ ))
do
sudo taskset --all-tasks --cpu-list 12-23 chrt --fifo 99 build/Examples/Cxx/DP_Multimachine_DQ_Parallel -ogen=$i -othreads=$j -oseq=$k
done
done
done
Subproject commit 2718bc9c1db2cb65c041f5387703f284a3654add
Subproject commit 4b9674ac044aac25e254017780957b22f3a15d33
/**
* @author Markus Mirz <mmirz@eonerc.rwth-aachen.de>
* @copyright 2017-2018, 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 <iostream>
#include <list>
#include <fstream>
#include <DPsim.h>
#include <dpsim/ThreadLevelScheduler.h>
using namespace DPsim;
using namespace CPS;
void multiply_connected(SystemTopology& sys, int copies,
Real resistance, Real inductance, Real capacitance) {
sys.multiply(copies);
int counter = 0;
std::vector<String> nodes = {"BUS5", "BUS8", "BUS6"};
for (auto orig_node : nodes) {
std::vector<String> nodeNames{orig_node};
for (int i = 2; i < copies+2; i++) {
nodeNames.push_back(orig_node + "_" + std::to_string(i));
}
nodeNames.push_back(orig_node);
// if only a single copy is added, it does not really make sense to
// "close the ring" by adding another line
int nlines = copies == 1 ? 1 : copies+1;
for (int i = 0; i < nlines; i++) {
// TODO lumped resistance?
auto rl_node = std::make_shared<DP::Node>("N_add_" + std::to_string(counter));
auto res = DP::Ph1::Resistor::make("R_" + std::to_string(counter));
res->setParameters(resistance);
auto ind = DP::Ph1::Inductor::make("L_" + std::to_string(counter));
ind->setParameters(inductance);
auto cap1 = DP::Ph1::Capacitor::make("C1_" + std::to_string(counter));
cap1->setParameters(capacitance / 2.);
auto cap2 = DP::Ph1::Capacitor::make("C2_" + std::to_string(counter));
cap2->setParameters(capacitance / 2.);
sys.addNode(rl_node);
res->connect({sys.node<DP::Node>(nodeNames[i]), rl_node});
ind->connect({rl_node, sys.node<DP::Node>(nodeNames[i+1])});
cap1->connect({sys.node<DP::Node>(nodeNames[i]), DP::Node::GND});
cap2->connect({sys.node<DP::Node>(nodeNames[i+1]), DP::Node::GND});
counter += 1;
sys.addComponent(res);
sys.addComponent(ind);
sys.addComponent(cap1);
sys.addComponent(cap2);
// TODO use line model
//auto line = DP::Ph1::PiLine::make("line" + std::to_string(counter));
//line->setParameters(resistance, inductance, capacitance);
//line->connect({sys.node<DP::Node>(nodeNames[i]), sys.node<DP::Node>(nodeNames[i+1])});
}
}
}
void simulateCoupled(std::list<fs::path> filenames, Int copies, Int threads, Int seq = 0) {
String simName = "WSCC_9bus_coupled_" + std::to_string(copies)
+ "_" + std::to_string(threads) + "_" + std::to_string(seq);
Logger::setLogDir("logs/"+simName);
CIM::Reader reader(simName, Logger::Level::off, Logger::Level::off);
SystemTopology sys = reader.loadCIM(60, filenames);
if (copies > 0)
multiply_connected(sys, copies, 12.5, 0.16, 1e-6);
Simulation sim(simName, Logger::Level::off);
sim.setSystem(sys);
sim.setTimeStep(0.0001);
sim.setFinalTime(0.5);
sim.setDomain(Domain::DP);
if (threads > 0)
sim.setScheduler(std::make_shared<OpenMPLevelScheduler>(threads));
// Logging
//auto logger = DataLogger::make(simName);
//for (Int cop = 1; cop <= copies; cop++) {
// for (Int bus = 1; bus <= 9; bus++) {
// String attrName = "v" + std::to_string(bus) + "_" + std::to_string(cop);
// String nodeName = "BUS" + std::to_string(bus) + "_" + std::to_string(cop);
// if (cop == 1) {
// attrName = "v" + std::to_string(bus);
// nodeName = "BUS" + std::to_string(bus);
// }
// logger->addAttribute(attrName, sys.node<DP::Node>(nodeName)->attribute("v"));
// }
//}
//sim.addLogger(logger);
sim.run();
sim.logStepTimes(simName + "_step_times");
}
int main(int argc, char *argv[]) {
CommandLineArgs args(argc, argv);
std::list<fs::path> filenames;
filenames = DPsim::Utils::findFiles({
"WSCC-09_RX_DI.xml",
"WSCC-09_RX_EQ.xml",
"WSCC-09_RX_SV.xml",
"WSCC-09_RX_TP.xml"
}, "Examples/CIM/WSCC-09_RX", "CIMPATH");
//for (Int copies = 0; copies < 20; copies++) {
// for (Int threads = 0; threads <= 12; threads = threads+2)
// simulateCoupled(filenames, copies, threads);
//}
std::cout << "Simulate with " << Int(args.options["copies"]) << " copies, "
<< Int(args.options["threads"]) << " threads, sequence number "
<< Int(args.options["seq"]) << std::endl;
simulateCoupled(filenames, Int(args.options["copies"]),
Int(args.options["threads"]), Int(args.options["seq"]));
}
......@@ -23,11 +23,14 @@
#include <fstream>
#include <DPsim.h>
#include <dpsim/ThreadLevelScheduler.h>
using namespace DPsim;
using namespace CPS;
void multiply_connected(SystemTopology& sys, int copies, Real resistance, Real inductance, Real capacitance) {
void multiply_decoupled(SystemTopology& sys, int copies,
Real resistance, Real inductance, Real capacitance) {
sys.multiply(copies);
int counter = 0;
std::vector<String> nodes = {"BUS5", "BUS8", "BUS6"};
......@@ -38,15 +41,16 @@ void multiply_connected(SystemTopology& sys, int copies, Real resistance, Real i
nodeNames.push_back(orig_node + "_" + std::to_string(i));
}
nodeNames.push_back(orig_node);
// if only a single copy is added, it doesn't really make sense to
// if only a single copy is added, it does not really make sense to
// "close the ring" by adding another line
int nlines = copies == 1 ? 1 : copies+1;
for (int i = 0; i < nlines; i++) {
auto line = Signal::DecouplingLine::make("dline_" + orig_node + "_" + std::to_string(i),
sys.node<Node<Complex>>(nodeNames[i]),
sys.node<Node<Complex>>(nodeNames[i+1]),
resistance, inductance, capacitance, Logger::Level::debug);
auto line = Signal::DecouplingLine::make(
"dline_" + orig_node + "_" + std::to_string(i),
sys.node<DP::Node>(nodeNames[i]),
sys.node<DP::Node>(nodeNames[i+1]),
resistance, inductance, capacitance, Logger::Level::info);
sys.addComponent(line);
sys.addComponents(line->getLineComponents());
counter++;
......@@ -54,40 +58,66 @@ void multiply_connected(SystemTopology& sys, int copies, Real resistance, Real i
}
}
int main(int argc, char *argv[]) {
// Find CIM files
std::list<fs::path> filenames;
if (argc <= 1) {
filenames = Utils::findFiles({
"WSCC-09_RX_DI.xml",
"WSCC-09_RX_EQ.xml",
"WSCC-09_RX_SV.xml",
"WSCC-09_RX_TP.xml"
}, "Examples/CIM/WSCC-09_RX", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
}
String simName = "WSCC-9bus";
void simulateDecoupled(std::list<fs::path> filenames, Int copies, Int threads, Int seq = 0) {
String simName = "WSCC_9bus_decoupled_" + std::to_string(copies)
+ "_" + std::to_string(threads) + "_" + std::to_string(seq);
Logger::setLogDir("logs/"+simName);
CIM::Reader reader(simName, Logger::Level::off, Logger::Level::off);
SystemTopology sys = reader.loadCIM(60, filenames);
multiply_connected(sys, 15, 12.5, 0.16, 1e-6);
Simulation sim(simName, sys, 0.0001, 0.5,
Domain::DP, Solver::Type::MNA, Logger::Level::off, false);
sim.setScheduler(std::make_shared<OpenMPLevelScheduler>(4));
if (copies > 0)
multiply_decoupled(sys, copies, 12.5, 0.16, 1e-6);
Simulation sim(simName, Logger::Level::off);
sim.setSystem(sys);
sim.setTimeStep(0.0001);
sim.setFinalTime(0.5);
sim.setDomain(Domain::DP);
if (threads > 0)
sim.setScheduler(std::make_shared<OpenMPLevelScheduler>(threads));
// Logging
//auto logger = DataLogger::make(simName);
//for (Int cop = 1; cop <= copies; cop++) {
// for (Int bus = 1; bus <= 9; bus++) {
// String attrName = "v" + std::to_string(bus) + "_" + std::to_string(cop);
// String nodeName = "BUS" + std::to_string(bus) + "_" + std::to_string(cop);
// if (cop == 1) {
// attrName = "v" + std::to_string(bus);
// nodeName = "BUS" + std::to_string(bus);
// }
// logger->addAttribute(attrName, sys.node<DP::Node>(nodeName)->attribute("v"));
// }
//}
//sim.addLogger(logger);
//std::ofstream of1("topology_graph.svg");
//sys.topologyGraph().render(of1));
//std::ofstream of2("dependency_graph.svg");
//sim.dependencyGraph().render(of2);
sim.run();
sim.logStepTimes(simName + "_step_times");
}
return 0;
int main(int argc, char *argv[]) {
CommandLineArgs args(argc, argv);
std::list<fs::path> filenames;
filenames = DPsim::Utils::findFiles({
"WSCC-09_RX_DI.xml",
"WSCC-09_RX_EQ.xml",
"WSCC-09_RX_SV.xml",
"WSCC-09_RX_TP.xml"
}, "Examples/CIM/WSCC-09_RX", "CIMPATH");
//for (Int copies = 0; copies < 10; copies++) {
// for (Int threads = 0; threads <= 12; threads = threads+2)
// simulateDecoupled(filenames, copies, threads);
//}
//simulateDecoupled(filenames, 19, 8);
std::cout << "Simulate with " << Int(args.options["copies"]) << " copies, "
<< Int(args.options["threads"]) << " threads, sequence number "
<< Int(args.options["seq"]) << std::endl;
simulateDecoupled(filenames, Int(args.options["copies"]),
Int(args.options["threads"]), Int(args.options["seq"]));
}
/**
* @author Markus Mirz <mmirz@eonerc.rwth-aachen.de>
* @copyright 2017-2018, 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 <iostream>
#include <list>
#include <fstream>
#include <DPsim.h>
#include <dpsim/ThreadLevelScheduler.h>
using namespace DPsim;
using namespace CPS;
Component::List multiply_diakoptics(SystemTopology& sys, Int copies,
Real resistance, Real inductance, Real capacitance, Int splits = 0) {
sys.multiply(copies);
int counter = 0;
std::vector<String> nodes = {"BUS5", "BUS8", "BUS6"};
Component::List tear_components;
Int splitEvery = 0;
if ((splits == 0) || (splits == copies+1)) {
splitEvery = 1;
} else {
splitEvery = Int( std::round( (copies+1) / splits) );
}
//std::cout << "split every: " << splitEvery << std::endl;
for (auto orig_node : nodes) {
std::vector<String> nodeNames{orig_node};
for (int i = 2; i < copies+2; i++) {
nodeNames.push_back(orig_node + "_" + std::to_string(i));
}
nodeNames.push_back(orig_node);
int nlines = copies == 1 ? 1 : copies+1;
for (int i = 0; i < nlines; i++) {
auto line = DP::Ph1::PiLine::make("line" + std::to_string(counter));
line->setParameters(resistance, inductance, capacitance);
line->connect({sys.node<DP::Node>(nodeNames[i]), sys.node<DP::Node>(nodeNames[i+1])});
if (i % splitEvery == 0) {
sys.addTearComponent(line);
//std::cout << "add tear line between node " << sys.node<DP::Node>(nodeNames[i])->name()
// << " and node " << sys.node<DP::Node>(nodeNames[i+1])->name() << std::endl;
}
else
sys.addComponent(line);
counter += 1;
}
}
return tear_components;
}
void simulateDiakoptics(std::list<fs::path> filenames,
Int copies, Int threads, UInt splits = 0, Int seq = 0) {
String simName = "WSCC_9bus_diakoptics_" + std::to_string(copies)
+ "_" + std::to_string(threads) + "_" + std::to_string(splits)
+ "_" + std::to_string(seq);
Logger::setLogDir("logs/"+simName);
CIM::Reader reader(simName, Logger::Level::off, Logger::Level::off);
SystemTopology sys = reader.loadCIM(60, filenames);
if (copies > 0)
Component::List tearComps = multiply_diakoptics(sys, copies, 12.5, 0.16, 1e-6, splits);
Simulation sim(simName, Logger::Level::off);
sim.setSystem(sys);
sim.setTimeStep(0.0001);
sim.setFinalTime(0.5);
sim.setDomain(Domain::DP);
if (threads > 0)
sim.setScheduler(std::make_shared<OpenMPLevelScheduler>(threads));
if (copies > 0)
sim.setTearingComponents(sys.mTearComponents);
// Logging
//auto logger = DataLogger::make(simName);
//for (Int cop = 1; cop <= copies; cop++) {
// for (Int bus = 1; bus <= 9; bus++) {
// String attrName = "v" + std::to_string(bus) + "_" + std::to_string(cop);
// String nodeName = "BUS" + std::to_string(bus) + "_" + std::to_string(cop);
// if (cop == 1) {
// attrName = "v" + std::to_string(bus);
// nodeName = "BUS" + std::to_string(bus);
// }
// logger->addAttribute(attrName, sys.node<DP::Node>(nodeName)->attribute("v"));
// }
//}
//sim.addLogger(logger);
sim.run();
sim.logStepTimes(simName + "_step_times");
}
int main(int argc, char *argv[]) {
CommandLineArgs args(argc, argv);
std::list<fs::path> filenames;
filenames = DPsim::Utils::findFiles({
"WSCC-09_RX_DI.xml",
"WSCC-09_RX_EQ.xml",
"WSCC-09_RX_SV.xml",
"WSCC-09_RX_TP.xml"
}, "Examples/CIM/WSCC-09_RX", "CIMPATH");
//for (Int copies = 0; copies < 10; copies++) {
// for (Int threads = 0; threads <= 12; threads = threads+2) {
// for (Int splits = 0; splits < copies; splits++)
// simulateDiakoptics(filenames, copies, threads, splits);
// }
//}
//simulateDiakoptics(filenames, 19, 8, 0);
std::cout << "Simulate with " << Int(args.options["copies"]) << " copies, "
<< Int(args.options["threads"]) << " threads, "
<< UInt(args.options["splits"]) << " splits, sequence number "
<< Int(args.options["seq"]) << std::endl;
simulateDiakoptics(filenames, Int(args.options["copies"]),
Int(args.options["threads"]), UInt(args.options["splits"]), Int(args.options["seq"]));
}
......@@ -9,44 +9,23 @@ endif()
# targets
set(CIRCUIT_SOURCES
# Dynamic phasor examples
Circuits/DP_VS_R1.cpp
Circuits/DP_CS_R1.cpp
Circuits/DP_VS_RL1.cpp
Circuits/DP_VS_RL2.cpp
Circuits/DP_VS_RC1.cpp
Circuits/DP_CS_R2CL.cpp
Circuits/DP_VS_CS_R4.cpp
Circuits/DP_VS_R2L3.cpp
DP_Basics/DP_VS_RL_f60.cpp
DP_Basics/DP_VS_RL_f60_largeTs.cpp
DP_Basics/DP_VS_RL_f60_vlargeTs.cpp
DP_Basics/DP_VS_RL_f500.cpp
DP_Basics/DP_VS_RL_f500_largeTs.cpp
DP_Basics/DP_VS_RL_f500_ph500.cpp
#Circuits/DP_VS_PiLine_R.cpp
Circuits/DP_Circuits.cpp
Circuits/DP_Basics_DP_Sims.cpp
Circuits/DP_PiLine.cpp
Circuits/DP_DecouplingLine.cpp
Circuits/DP_Diakoptics.cpp
#Circuits/DP_VS_Trafo_R.cpp
#Circuits/DP_ResVS_RL_Switch.cpp
# EMT examples
Circuits/EMT_VS_R1.cpp
Circuits/EMT_VS_RC1.cpp
Circuits/EMT_CS_R1.cpp
# EMT examples
Circuits/EMT_VS_RL1.cpp
Circuits/EMT_CS_R2CL.cpp
Circuits/EMT_VS_R2L3.cpp
Circuits/EMT_VS_CS_R4_AC.cpp
Circuits/EMT_VS_CS_R4_DC.cpp
DP_Basics/EMT_VS_RL_f60.cpp
DP_Basics/EMT_VS_RL_f60_largeTs.cpp
DP_Basics/EMT_VS_RL_f500.cpp
Circuits/EMT_Circuits.cpp
Circuits/DP_Basics_EMT_Sims.cpp
#Circuits/EMT_ResVS_RL_Switch.cpp
# EMT and DP studies
#VariableTimeStep/RXLine_LoadStep_FreqStep_1.cpp
Circuits/DP_EMT_RL_SourceStep.cpp
)
set(SYNCGEN_SOURCES
......@@ -54,12 +33,15 @@ set(SYNCGEN_SOURCES
Components/DP_SynGenDq7odTrapez_ThreePhFault.cpp
Components/DP_SynGenTrStab_SteadyState.cpp
Components/DP_SynGenTrStab_LoadStep.cpp
Components/DP_EMT_SynGenDq7odTrapez_SteadyState.cpp
Components/DP_EMT_SynGenDq7odTrapez_ThreePhFault.cpp
Components/DP_EMT_SynGenDq7odTrapez_LoadStep.cpp
)
set(INVERTER_SOURCES
Inverter/DP_Inverter_Grid_Test.cpp
Inverter/DP_Inverter_Grid_Test_Parallel.cpp
Inverter/DP_Vsrc_Grid_Parallel.cpp
Components/DP_Inverter_Grid.cpp
Components/DP_Inverter_Grid_Parallel_FreqSplit.cpp
Components/DP_Inverter_Grid_Sequential_FreqSplit.cpp
)
if(WITH_SUNDIALS)
......@@ -67,6 +49,9 @@ if(WITH_SUNDIALS)
Components/DP_SynGenDq7odODE_SteadyState.cpp
Components/DP_SynGenDq7odODE_ThreePhFault.cpp
Components/DP_Multimachine_DQ_Parallel.cpp
Components/DP_EMT_SynGenDq7odODE_SteadyState.cpp
Components/DP_EMT_SynGenDq7odODE_ThreePhFault.cpp
Components/DP_EMT_SynGenDq7odODE_LoadStep.cpp