Commit ed0c90bf authored by Steffen Vogel's avatar Steffen Vogel 🎅🏼
Browse files

Merge branch 'pytest-jupyter' into 'development'

Use pytest to run Jupyter notebooks

See merge request acs/public/simulation/dpsim!77
parents 03c65afc 6365147a
......@@ -3,6 +3,7 @@ build/
build_*/
build-*/
dist/
outputs/
_dpsim.pyd
_dpsim.pdb
.pytest_cache/
......
......@@ -60,7 +60,6 @@ test:pytest:
- pytest -v Examples/Python/Circuits
- pytest -v Examples/Python/RealTime
#- pytest -v Examples/Python/Shmem
image: ${DOCKER_IMAGE_DEV}:${DOCKER_TAG_DEV}
dependencies:
- build:linux
......@@ -116,22 +115,20 @@ build:docker:
only:
- tags
#test:jupyter:
# stage: test
# variables:
# PYTHONPATH: "build/Source/Python:Source/Python"
# script:
# - jupyter nbconvert --to notebook --execute Examples/Notebooks/Quickstart\ Guide.ipynb
# - jupyter nbconvert --to notebook --execute Examples/Notebooks/CS_R2CL.ipynb
# - jupyter nbconvert --to notebook --execute Examples/Notebooks/WSCC_9-bus_dyn_switch.ipynb
# image: ${DOCKER_IMAGE_DEV}:${DOCKER_TAG}
# dependencies:
# - build:linux
# artifacts:
# paths:
# - build/Examples/Notebooks/
# tags:
# - docker
test:jupyter:
stage: test
variables:
PYTHONPATH: "build/Source/Python:Source/Python"
script:
- pytest -v Examples/Notebooks
image: ${DOCKER_IMAGE_DEV}:${DOCKER_TAG_DEV}
dependencies:
- build:linux
tags:
- docker
artifacts:
paths:
- outputs/Examples/Notebooks/
deploy:docker:
stage: deploy
......
Subproject commit df470be52cb7d737c42373bf8775a9b31d1ee549
Subproject commit 57fa03cde512d3e53c2b43a4468295f21b76edc5
add_subdirectory(Cxx)
add_subdirectory(Notebooks)
\ No newline at end of file
......@@ -33,18 +33,20 @@ using namespace CPS::CIM;
*/
int main(int argc, char** argv){
#ifdef _WIN32
String path("..\\..\\..\\..\\dpsim\\Examples\\CIM\\CIGRE_MV_NoTap\\");
#elif defined(__linux__) || defined(__APPLE__)
String path("Examples/CIM/CIGRE_MV_NoTap/");
#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"
}, "Examples/CIM/CIGRE_MV_NoTap", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
}
std::list<string> filenames = {
path + "Rootnet_FULL_NE_06J16h_DI.xml",
path + "Rootnet_FULL_NE_06J16h_EQ.xml",
path + "Rootnet_FULL_NE_06J16h_SV.xml",
path + "Rootnet_FULL_NE_06J16h_TP.xml"
};
String simName = "CIGRE-MV-NoTap";
CPS::Real system_freq = 50;
......
......@@ -33,12 +33,6 @@ using namespace CPS::CIM;
*/
int main(int argc, char** argv){
#ifdef _WIN32
String path("..\\..\\..\\..\\dpsim\\Examples\\CIM\\CIGRE_MV_NoTap\\");
#elif defined(__linux__) || defined(__APPLE__)
String path("Examples/CIM/CIGRE_MV_NoTap/");
#endif
#ifdef _WIN32
String loadProfilePath("..\\..\\..\\..\\dpsim\\Examples\\CSV\\CIGRE_MV_NoTap\\");
#elif defined(__linux__) || defined(__APPLE__)
......@@ -65,12 +59,20 @@ int main(int argc, char** argv){
{"LOAD-I-13", "Load_I_13"},
{"LOAD-I-14", "Load_I_14"}};
std::list<string> filenames = {
path + "Rootnet_FULL_NE_06J16h_DI.xml",
path + "Rootnet_FULL_NE_06J16h_EQ.xml",
path + "Rootnet_FULL_NE_06J16h_SV.xml",
path + "Rootnet_FULL_NE_06J16h_TP.xml"
};
// 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"
}, "Examples/CIM/CIGRE_MV_NoTap", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
}
String simName = "CIGRE-MV-NoTap-LoadProfiles";
CPS::Real system_freq = 50;
......
......@@ -33,18 +33,20 @@ using namespace CPS::CIM;
*/
int main(int argc, char** argv){
#ifdef _WIN32
String path("..\\..\\..\\..\\dpsim\\Examples\\CIM\\IEEE_EU_LV_reduced\\");
#elif defined(__linux__) || defined(__APPLE__)
String path("Examples/CIM/IEEE_EU_LV_reduced/");
#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"
}, "Examples/CIM/IEEE_EU_LV_reduced", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
}
std::list<string> filenames = {
path + "Rootnet_FULL_NE_13J16h_DI.xml",
path + "Rootnet_FULL_NE_13J16h_EQ.xml",
path + "Rootnet_FULL_NE_13J16h_SV.xml",
path + "Rootnet_FULL_NE_13J16h_TP.xml"
};
String simName = "CIGRE-LV-reduced";
CPS::Real system_freq = 50;
......
......@@ -34,24 +34,26 @@ using namespace CPS::CIM;
int main(int argc, char** argv){
#ifdef _WIN32
String path("..\\..\\..\\..\\dpsim\\Examples\\CIM\\IEEE_EU_LV_reduced\\");
#elif defined(__linux__) || defined(__APPLE__)
String path("Examples/CIM/IEEE_EU_LV_reduced/");
#endif
#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
std::list<string> filenames = {
path + "Rootnet_FULL_NE_13J16h_DI.xml",
path + "Rootnet_FULL_NE_13J16h_EQ.xml",
path + "Rootnet_FULL_NE_13J16h_SV.xml",
path + "Rootnet_FULL_NE_13J16h_TP.xml"
};
// 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"
}, "Examples/CIM/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;
......
......@@ -27,21 +27,23 @@ using namespace DPsim;
using namespace CPS::DP;
int main(int argc, char *argv[]) {
#ifdef _WIN32
String path("..\\..\\..\\..\\dpsim\\Examples\\CIM\\WSCC-09_RX\\");
#elif defined(__linux__) || defined(__APPLE__)
String path("Examples/CIM/WSCC-09_RX/");
#endif
std::list<String> filenames = {
path + "WSCC-09_RX_DI.xml",
path + "WSCC-09_RX_EQ.xml",
path + "WSCC-09_RX_SV.xml",
path + "WSCC-09_RX_TP.xml"
};
// 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";
Logger::setLogDir("logs/"+simName);
Logger::setLogDir("logs/"+simName);
CPS::CIM::Reader reader(simName, Logger::Level::DEBUG, Logger::Level::NONE);
SystemTopology sys = reader.loadCIM(60, filenames);
......@@ -57,10 +59,10 @@ int main(int argc, char *argv[]) {
logger->addAttribute("v7", sys.node<Node>("BUS7")->attribute("v"));
logger->addAttribute("v8", sys.node<Node>("BUS8")->attribute("v"));
logger->addAttribute("v9", sys.node<Node>("BUS9")->attribute("v"));
Simulation sim(simName, sys, 0.0001, 0.1,
Domain::DP, Solver::Type::MNA, Logger::Level::INFO, true);
sim.addLogger(logger);
sim.run();
......
......@@ -27,21 +27,23 @@ using namespace DPsim;
using namespace CPS::DP;
int main(int argc, char *argv[]) {
#ifdef _WIN32
String path("..\\..\\..\\..\\dpsim\\Examples\\CIM\\WSCC-09_RX_Dyn\\");
#elif defined(__linux__) || defined(__APPLE__)
String path("Examples/CIM/WSCC-09_RX_Dyn/");
#endif
std::list<String> filenames = {
path + "WSCC-09_RX_DI.xml",
path + "WSCC-09_RX_EQ.xml",
path + "WSCC-09_RX_SV.xml",
path + "WSCC-09_RX_TP.xml"
};
// 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_Dyn", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
}
String simName = "WSCC-9bus_dyn";
Logger::setLogDir("logs/"+simName);
Logger::setLogDir("logs/"+simName);
CPS::CIM::Reader reader(simName, Logger::Level::DEBUG, Logger::Level::DEBUG);
SystemTopology sys = reader.loadCIM(60, filenames);
......@@ -63,7 +65,7 @@ int main(int argc, char *argv[]) {
Simulation sim(simName, sys, 0.0001, 2,
Domain::DP, Solver::Type::MNA, Logger::Level::INFO, true);
sim.addLogger(logger);
sim.run();
......
......@@ -27,21 +27,23 @@ using namespace DPsim;
using namespace CPS::DP;
int main(int argc, char *argv[]) {
#ifdef _WIN32
String path("..\\..\\..\\..\\dpsim\\Examples\\CIM\\WSCC-09_RX_Dyn\\");
#elif defined(__linux__) || defined(__APPLE__)
String path("Examples/CIM/WSCC-09_RX_Dyn/");
#endif
std::list<String> filenames = {
path + "WSCC-09_RX_DI.xml",
path + "WSCC-09_RX_EQ.xml",
path + "WSCC-09_RX_SV.xml",
path + "WSCC-09_RX_TP.xml"
};
// 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_Dyn", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
}
String simName = "WSCC-9bus_dyn_switch";
Logger::setLogDir("logs/"+simName);
Logger::setLogDir("logs/"+simName);
CPS::CIM::Reader reader(simName, Logger::Level::DEBUG, Logger::Level::INFO);
SystemTopology sys = reader.loadCIM(60, filenames);
......
......@@ -50,18 +50,20 @@ void multiply_connected(SystemTopology& sys, int copies, Real resistance, Real i
}
int main(int argc, char *argv[]) {
#ifdef _WIN32
String path("..\\..\\..\\..\\dpsim\\Examples\\CIM\\WSCC-09_RX\\");
#elif defined(__linux__) || defined(__APPLE__)
String path("Examples/CIM/WSCC-09_RX/");
#endif
std::list<String> filenames = {
path + "WSCC-09_RX_DI.xml",
path + "WSCC-09_RX_EQ.xml",
path + "WSCC-09_RX_SV.xml",
path + "WSCC-09_RX_TP.xml"
};
// 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";
......
......@@ -78,7 +78,6 @@ if(WITH_RT)
set(RT_SOURCES
RealTime/RT_DP_CS_R_1.cpp
RealTime/RT_DP_ResVS_RL1.cpp
RealTime/RT_CIGRE_MV_PowerFlowTest.cpp
)
endif()
......@@ -116,6 +115,13 @@ if(WITH_CIM)
CIM/IEEE_LV_PowerFlowTest.cpp
CIM/IEEE_LV_PowerFlowTest_LP.cpp
)
if(WITH_RT)
list(APPEND RT_SOURCES
# The Loadflow example needs CIM++ and RT
RealTime/RT_CIGRE_MV_PowerFlowTest.cpp
)
endif()
endif()
if(WITH_CIM AND WITH_OPENMP)
......
......@@ -32,18 +32,20 @@ using namespace CPS::CIM;
*/
int main(int argc, char** argv){
#ifdef _WIN32
String path("..\\..\\..\\..\\dpsim\\Examples\\CIM\\CIGRE_MV_NoTap\\");
#elif defined(__linux__) || defined(__APPLE__)
String path("Examples/CIM/CIGRE_MV_NoTap/");
#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"
}, "Examples/CIM/CIGRE_MV_NoTap", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
}
std::list<string> filenames = {
path + "Rootnet_FULL_NE_06J16h_DI.xml",
path + "Rootnet_FULL_NE_06J16h_EQ.xml",
path + "Rootnet_FULL_NE_06J16h_SV.xml",
path + "Rootnet_FULL_NE_06J16h_TP.xml"
};
String simName = "RT_CIGRE-MV-NoTap";
CPS::Real system_freq = 50;
......
......@@ -33,19 +33,20 @@ using namespace CPS::CIM;
int main(int argc, char** argv){
CommandLineArgs args(argc, argv);
#ifdef _WIN32
String path("..\\..\\..\\..\\dpsim\\Examples\\CIM\\CIGRE_MV_NoTap\\");
#elif defined(__linux__) || defined(__APPLE__)
String path("Examples/CIM/CIGRE_MV_NoTap/");
#endif
std::list<string> filenames = {
path + "Rootnet_FULL_NE_06J16h_DI.xml",
path + "Rootnet_FULL_NE_06J16h_EQ.xml",
path + "Rootnet_FULL_NE_06J16h_SV.xml",
path + "Rootnet_FULL_NE_06J16h_TP.xml"
};
String simName = "Shmem_CIGRE-MV-NoTap";
// Find CIM files
std::list<fs::path> filenames;
if (argc <= 1) {
filenames = 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"
}, "Examples/CIM/CIGRE_MV_NoTap", "CIMPATH");
}
else {
filenames = args.filenames
}
CPS::Real system_freq = 50;
CIM::Reader reader(simName, Logger::Level::DEBUG, Logger::Level::NONE);
......
......@@ -36,24 +36,26 @@ using namespace CPS::CIM;
int main(int argc, char** argv){
CommandLineArgs args(argc, argv);
#ifdef _WIN32
String path("..\\..\\..\\..\\dpsim\\Examples\\CIM\\CIGRE_MV_NoTap\\");
#elif defined(__linux__) || defined(__APPLE__)
String path("Examples/CIM/CIGRE_MV_NoTap/");
#endif
#ifdef _WIN32
String loadProfilePath("..\\..\\..\\..\\dpsim\\Examples\\CSV\\CIGRE_MV_NoTap\\");
#elif defined(__linux__) || defined(__APPLE__)
String loadProfilePath("Examples/CSV/CIGRE_MV_NoTap/");
#endif
std::list<string> filenames = {
path + "Rootnet_FULL_NE_06J16h_DI.xml",
path + "Rootnet_FULL_NE_06J16h_EQ.xml",
path + "Rootnet_FULL_NE_06J16h_SV.xml",
path + "Rootnet_FULL_NE_06J16h_TP.xml"
};
// Find CIM files
std::list<fs::path> filenames;
if (argc <= 1) {
filenames = 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"
}, "Examples/CIM/CIGRE_MV_NoTap", "CIMPATH");
}
else {
filenames = args.filenames;
}
String simName = "Shmem_CIGRE-MV-NoTap";
CPS::Real system_freq = 50;
......
......@@ -31,19 +31,12 @@ using namespace CPS::DP::Ph1;
int main(int argc, char *argv[]) {
// Specify CIM files
#ifdef _WIN32
String path("Examples\\CIM\\WSCC-09_RX\\");
#elif defined(__linux__) || defined(__APPLE__)
String path("Examples/CIM/WSCC-09_RX/");
#endif
std::list<String> filenames = {
path + "WSCC-09_RX_DI.xml",
path + "WSCC-09_RX_EQ.xml",
path + "WSCC-09_RX_SV.xml",
path + "WSCC-09_RX_TP.xml"
};
std::list<String> 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");
String simName = "Shmem_WSCC-9bus";
......
......@@ -35,19 +35,19 @@ int main(int argc, char *argv[]) {
CommandLineArgs args(argc, argv);
// Specify CIM files
#ifdef _WIN32
String path("Examples\\CIM\\WSCC-09_RX\\");
#elif defined(__linux__) || defined(__APPLE__)
String path("Examples/CIM/WSCC-09_RX/");
#endif
std::list<String> filenames = {
path + "WSCC-09_RX_DI.xml",
path + "WSCC-09_RX_EQ.xml",
path + "WSCC-09_RX_SV.xml",
path + "WSCC-09_RX_TP.xml"
};
// 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 = args.filenames;
}
String simName = "Shmem_WSCC-9bus_Ctrl";
......
......@@ -37,15 +37,19 @@ int main(int argc, char *argv[]) {
CommandLineArgs args(argc, argv, "Shmem_WSCC-9bus_CtrlDist", 0.001, 20, 60);
if (args.scenario == 0) {
// Specify CIM files
String path("Examples/CIM/WSCC-09_RX/");
std::list<String> filenames = {
path + "WSCC-09_RX_DI.xml",
path + "WSCC-09_RX_EQ.xml",
path + "WSCC-09_RX_SV.xml",
path + "WSCC-09_RX_TP.xml"
};
// 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 = args.filenames;
}
CIM::Reader reader(args.name, Logger::Level::INFO, Logger::Level::INFO);
SystemTopology sys = reader.loadCIM(args.sysFreq, filenames);
......
find_program(JUPYTER jupyter)
if(WITH_PYTHON AND JUPYTER)
set(PYTHONPATH $<TARGET_FILE_DIR:dpsim_python>:${CMAKE_CURRENT_SOURCE_DIR}/../../Source/Python/:$ENV{PYTHONPATH})