...
 
Commits (133)
......@@ -18,5 +18,6 @@ indent_size = 4
indent_style = spaces
indent_size = 4
[Dockerfile]
[{CMakeLists.txt,Dockerfile}]
indent_style = tab
indent_size = 2
\ No newline at end of file
......@@ -16,26 +16,47 @@ stages:
- generate
- deploy
docker:
docker:fedora:
stage: prepare
needs: []
script:
- docker build
--file Packaging/Docker/Dockerfile.dev
--tag ${DOCKER_IMAGE_DEV}:${DOCKER_TAG}
--tag ${DOCKER_IMAGE_DEV}:latest .
# build dedicated jupyter image in the future
tags:
- shell
- linux
docker:centos:
stage: prepare
needs: []
script:
- docker build
--file Packaging/Docker/Dockerfile.jupyter
--build-arg DOCKER_IMAGE=${DOCKER_IMAGE_DEV}
--build-arg DOCKER_TAG=${DOCKER_TAG}
--tag ${DOCKER_IMAGE_DEV}-jupyter:${DOCKER_TAG}
--tag ${DOCKER_IMAGE_DEV}-jupyter:latest .
--file Packaging/Docker/Dockerfile.dev-centos
--tag ${DOCKER_IMAGE_DEV}-centos:${DOCKER_TAG}
--tag ${DOCKER_IMAGE_DEV}-centos:latest .
tags:
- shell
- linux
#docker:jupyter:
# stage: prepare
# needs: []
# script:
# - docker build
# --file Packaging/Docker/Dockerfile.jupyter
# --build-arg DOCKER_IMAGE=${DOCKER_IMAGE_DEV}
# --build-arg DOCKER_TAG=${DOCKER_TAG}
# --tag ${DOCKER_IMAGE_DEV}-jupyter:${DOCKER_TAG}
# --tag ${DOCKER_IMAGE_DEV}-jupyter:latest .
# tags:
# - shell
# - linux
build:linux:
stage: build
needs: ["docker:fedora"]
script:
- mkdir -p build
- cd build
......@@ -52,8 +73,28 @@ build:linux:
tags:
- docker
build:linux-cuda:
stage: build
needs: ["docker:centos"]
script:
- mkdir -p build
- cd build
- cmake -DWITH_SPDLOG_SUBMODULE=ON ..
- make -j 32
image: ${DOCKER_IMAGE_DEV}-centos:${DOCKER_TAG}
cache:
paths:
- build
key: build-linux-cuda
artifacts:
paths:
- build
tags:
- docker
build:windows:
stage: build
needs: []
script:
- New-Item -ItemType Directory -Force -Path build
- Set-Location -Path build
......@@ -109,6 +150,7 @@ build:windows:
generate:docs:
stage: generate
needs: ["build:linux"]
script:
- make -j$(nproc) -C build docs
- make -j$(nproc) -C build docs_cxx
......@@ -124,6 +166,7 @@ generate:docs:
generate:packages:
stage: generate
needs: ["build:linux"]
script:
- make -j$(nproc) -C build package
only:
......@@ -140,6 +183,7 @@ generate:packages:
build:docker:
stage: build
needs: []
script:
- docker build
--file Packaging/Docker/Dockerfile
......@@ -158,6 +202,7 @@ build:docker:
test:jupyter:
stage: test
needs: ["build:linux"]
variables:
PYTHONPATH: "build/Source/Python:Source/Python"
script:
......@@ -171,10 +216,72 @@ test:jupyter:
paths:
- outputs/Examples/Notebooks/
.remote-gpu:
stage: test
needs: ["build:linux-cuda"]
variables:
GPU_TARGET: 'gitlab-runner@ghost'
RDIR: '/tmp/gitlab-jobs/$CI_PROJECT_NAME/$CI_JOB_ID'
CI_DIR: '$CI_BUILDS_DIR/$CI_PROJECT_PATH'
LDIR: '/cricket/bin'
TEST_FILES: ''
TEST_PARAM: ''
REMOTE_LIBS: 'linux-vdso.so.1
librt.so.1
libdl.so.2
libcudart.so.10.2
libcusolver.so.10
libstdc\+\+.so.6
libm.so.6
libgcc_s.so.1
libc.so.6
/lib64/ld-linux-x86-64.so.2
libutil.so.1
libpthread.so.0'
script:
- mkdir ~/.ssh &&
echo "-----BEGIN OPENSSH PRIVATE KEY-----" > ~/.ssh/id_rsa &&
echo $SSH_PRIVATE | sed "s/\S\{64\}/&\n/g" >> ~/.ssh/id_rsa &&
echo "-----END OPENSSH PRIVATE KEY-----" >> ~/.ssh/id_rsa &&
echo $SSH_PUBLIC > ~/.ssh/id_rsa.pub &&
echo $KNOWN_HOSTS > ~/.ssh/known_hosts && chmod 600 ~/.ssh/id_rsa
- echo "$TEST_BINARY_PATH/$TEST_BINARY $TEST_FILES" | tr -d '\n' | xargs -r -d " " -I % cp % $LDIR
- ldd $LDIR/$TEST_BINARY |
sed -n -E -e 's/^\s+\S+ => (\S+) \S+$/\1/p' |
grep -Ev "$(echo $REMOTE_LIBS | tr ' ' '|')|not" |
xargs -I % cp % $LDIR/
- ssh $GPU_TARGET mkdir -p $RDIR
- scp -r $LDIR/* $GPU_TARGET:$RDIR/
- ssh $GPU_TARGET "LD_LIBRARY_PATH=$RDIR:${LD_LIBRARY_PATH} LD_PRELOAD=$RDIR/cricket-server.so $RDIR/$TEST_BINARY" &
- sleep 2
- PATH=$LDIR:${PATH} LD_PRELOAD=$LDIR/cricket-client.so $TEST_BINARY_PATH/$TEST_BINARY $TEST_PARAM
after_script:
- ssh $GPU_TARGET rm -rf $RDIR
- ssh $GPU_TARGET pkill -fe -2 $RDIR/test_kernel
image: ${DOCKER_IMAGE_DEV}-centos:${DOCKER_TAG}
dependencies:
- build:linux-cuda
tags:
- docker
test:cuda:
extends: .remote-gpu
allow_failure: true
variables:
# Name of the test binary
TEST_BINARY: 'WSCC_9bus_mult_decoupled'
# Path where the test binary is located
TEST_BINARY_PATH: 'build/Examples/Cxx'
# Additional files that are necessary to run the application on the GPU node
TEST_FILE: ''
# Command line parameters for the test binary
TEST_PARAM: ''
# Stage deploy
##############################################################################
pages:
stage: deploy
needs: ["generate:docs"]
script:
- cp -r build/docs/sphinx/html/. public/sphinx
- cp -r build/docs/doxygen/html/. public/doxygen
......@@ -217,4 +324,4 @@ deploy:packages:
tags:
- fein-deploy
- shell
- linux
\ No newline at end of file
- linux
[submodule "Examples/CIM/grid-data"]
path = Examples/CIM/grid-data
url = ../../../grid-data/cim-grid-data.git
[submodule "Dependencies/eigen"]
path = Dependencies/eigen
url = https://github.com/eigenteam/eigen-git-mirror
[submodule "Dependencies/libcimpp"]
path = Dependencies/libcimpp
url = https://github.com/CIM-IEC/libcimpp.git
[submodule "Dependencies/spdlog"]
path = Dependencies/spdlog
url = https://github.com/gabime/spdlog
set(CIMPP_DIR Dependencies/libcimpp)
option(WITH_CIM_SUBMODULE "Build with CIMpp as submodule" OFF)
set(CIM_VERSION "16v29a")
set(USE_CIM_VERSION "IEC61970_16v29a")
include(FindPackageHandleStandardArgs)
if(WIN32 AND NOT WITH_CIM_SUBMODULE)
set(CIMPP_INCLUDE_DIR
${CMAKE_CURRENT_SOURCE_DIR}/${CIMPP_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/${CIMPP_DIR}/${CIM_VERSION}
)
find_library(CIMPP_LIBRARY
NAMES libcimpp.lib
PATH_SUFFIXES
Debug
Release
PATHS
${CMAKE_CURRENT_BINARY_DIR}/${CIMPP_DIR}
)
set(ARABICA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${CIMPP_DIR}/thirdparty/arabica/include)
find_library(ARABICA_LIBRARY
NAMES arabica.lib
PATH_SUFFIXES
Debug
Release
PATHS
${CMAKE_CURRENT_BINARY_DIR}/${CIMPP_DIR}/thirdparty/arabica
)
find_package_handle_standard_args(CIMpp DEFAULT_MSG CIMPP_LIBRARY CIMPP_INCLUDE_DIR)
mark_as_advanced(CIMPP_INCLUDE_DIR)
if(CIMPP_LIBRARY AND ARABICA_LIBRARY)
set(WITH_CIM_SUBMODULE OFF)
else()
set(WITH_CIM_SUBMODULE ON)
set(CIMPP_INCLUDE_DIR "")
set(CIMPP_LIBRARY "")
set(ARABICA_INCLUDE_DIR "")
set(ARABICA_LIBRARY "")
endif()
endif()
if (WITH_CIM_SUBMODULE)
# When adding CIMpp via a subdirectory, all the neccessary
# details about include directories, library name and path
# are associated with the CIMpp target 'libcimpp'
# We therefore do not need to keep track of CIMPP_INCLUDE_DIR
# seperately
if(NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif()
add_subdirectory(Dependencies/libcimpp)
set(CIMPP_LIBRARY libcimpp)
set(CIMPP_LIBRARIES ${CIMPP_LIBRARY})
set(CIMPP_INCLUDE_DIR "")
find_package_handle_standard_args(CIMpp DEFAULT_MSG CIMPP_LIBRARY)
elseif(NOT WIN32)
find_path(CIMPP_INCLUDE_DIR
NAMES CIMModel.hpp
PATH_SUFFIXES
cimpp/${CIM_VERSION}
${CIM_VERSION}
include/src
)
find_library(CIMPP_LIBRARY
NAMES cimpp${CIM_VERSION}
PATH_SUFFIXES
lib/static
)
# handle the QUIETLY and REQUIRED arguments and set CIMPP_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(CIMpp DEFAULT_MSG CIMPP_LIBRARY CIMPP_INCLUDE_DIR)
mark_as_advanced(CIMPP_INCLUDE_DIR)
endif()
mark_as_advanced(CIMPP_LIBRARY)
set(CIMPP_LIBRARIES ${CIMPP_LIBRARY} ${ARABICA_LIBRARY})
set(CIMPP_INCLUDE_DIRS ${CIMPP_INCLUDE_DIR} ${ARABICA_INCLUDE_DIR})
option(WITH_EIGEN_SUBMODULE "Build with Eigen as submodule" OFF)
if (WITH_EIGEN_SUBMODULE OR WIN32)
# This could be used when an optimized version of eigen is required
# add_subdirectory(Dependencies/eigen)
find_path(EIGEN3_INCLUDE_DIR
NAMES signature_of_eigen3_matrix_library
PATHS
Dependencies/eigen
)
else()
set(TEMP_PATH ${CMAKE_MODULE_PATH})
# We temporarily clear the module path to avoid recursion
set(CMAKE_MODULE_PATH "")
find_package(Eigen3 REQUIRED)
set(CMAKE_MODULE_PATH ${TEMP_PATH})
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Eigen3 REQUIRED_VARS EIGEN3_INCLUDE_DIR)
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.11)
project(DPsim CXX)
set(PROJECT_AUTHOR "Institute for Automation of Complex Power Systems, RWTH Aachen University")
set(PROJECT_COPYRIGHT "2017-2020, Institute for Automation of Complex Power Systems, RWTH Aachen University")
set(PROJECT_DESCRIPTION "C++ Power System Simulation Library")
set(PROJECT_HOMEPAGE_URL "https://dpsim.fein-aachen.org/")
set(PROJECT_VCS_URL "https://github.com/dpsim-simulator/dpsim.git")
# Required for dpsim_python
if(POLICY CMP0076)
cmake_policy(SET CMP0076 NEW)
endif()
# Allow setting Graphviz_ROOT for windows builds
if(WIN32)
cmake_policy(SET CMP0074 NEW)
endif()
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(TOPLEVEL_PROJECT ON)
else()
set(TOPLEVEL_PROJECT OFF)
set(TOPLEVEL_PROJECT OFF)
endif()
# Enable C++11 support
......@@ -13,30 +28,29 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL Intel)
# needed by icc, but for some reason not added by CMake
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
add_definitions(-D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS)
add_definitions(-D_SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake;${PROJECT_SOURCE_DIR}/models/CMake")
if(NOT WIN32)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
set(PROJECT_AUTHOR "Institute for Automation of Complex Power Systems, RWTH Aachen University")
set(PROJECT_COPYRIGHT "2017-2020, Institute for Automation of Complex Power Systems, RWTH Aachen University")
set(PROJECT_DESCRIPTION "C++ Power System Simulation Library")
set(PROJECT_HOMEPAGE_URL "http://www.fein-aachen.org/projects/dpsim/")
set(PROJECT_VCS_URL "https://git.rwth-aachen.org/acs/public/simulation/dpsim")
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include(CheckCXXCompilerFlag)
if(MSVC)
# Silence Visual Studio deprecation warnings
add_definitions(-D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS)
add_definitions(-D_SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING)
# Set exception handling for portability
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
check_cxx_compiler_flag("/W4 /WX" CXX_SUPPORTS_WERROR)
if(CXX_SUPPORTS_WERROR)
# TODO activate this again after fixing warnings
# set(DPSIM_CXX_FLAGS /W4 /WX)
endif()
else()
check_cxx_compiler_flag("-Wall -Werror" CXX_SUPPORTS_WERROR)
if(CXX_SUPPORTS_WERROR)
set(DPSIM_CXX_FLAGS -Wall -Werror)
endif()
......@@ -51,28 +65,41 @@ check_symbol_exists(getopt_long getopt.h HAVE_GETOPT)
include(GetVersion)
GetVersion(${PROJECT_SOURCE_DIR} "DPSIM")
find_package(Eigen3 3.0 REQUIRED)
option(SPDLOG_BUILD_TESTING "Build spdlog tests" OFF)
option(SPDLOG_BUILD_BENCH "Build spdlog benchmarks" OFF)
option(SPDLOG_BUILD_EXAMPLES "Build spdlog examples" OFF)
# Workaround for spdlog in Windows
# A custom FindSpdlog does not work currently
option(WITH_EIGEN_SUBMODULE "Build with Eigen as submodule" OFF)
option(WITH_SPDLOG_SUBMODULE "Build with Spdlog as submodule" OFF)
option(WITH_CIM_SUBMODULE "Build with CIMpp as submodule" OFF)
find_package(Threads REQUIRED)
if (WITH_EIGEN_SUBMODULE OR WIN32)
include(cmake/GetEigenSubmodule.cmake)
else()
find_package(Eigen3 3.0 REQUIRED)
endif()
if (WITH_SPDLOG_SUBMODULE OR WIN32)
set(SPDLOG_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/spdlog/include)
include(cmake/GetSpdlogSubmodule.cmake)
else()
find_package(spdlog REQUIRED)
find_package(fmt REQUIRED)
endif()
find_package(CIMpp)
add_subdirectory(models)
find_package(PythonInterp 3.6)
find_package(PythonLibs 3.6)
find_package(Sundials)
if (WITH_CIM_SUBMODULE OR WIN32)
include(cmake/GetCIMppSubmodule.cmake)
else()
find_package(CIMpp)
endif()
find_package(Sundials)
find_package(OpenMP)
find_package(CUDA)
find_package(GSL)
find_package(Graphviz)
find_package(PythonInterp 3.6)
find_package(PythonLibs 3.6)
find_package(NumPy)
find_package(VILLASnode)
if(PythonInterp_FOUND AND PythonLibs_FOUND)
......@@ -81,34 +108,67 @@ endif()
if("${CMAKE_SYSTEM}" MATCHES "Linux")
set(Linux_FOUND ON)
elseif("${CMAKE_SYSTEM}" MATCHES "Darwin")
set(MacOS_FOUND ON)
endif()
# Options
include(CMakeDependentOption)
option(BUILD_SHARED_LIBS "Build shared library" OFF)
option(BUILD_EXAMPLES "Build C++ examples" ON)
option(COMPARE_REFERENCE "Download reference results and compare" OFF)
option(BUILD_SHARED_LIBS "Build shared library" OFF)
option(BUILD_EXAMPLES "Build C++ examples" ON)
option(GET_GRID_DATA "Download grid data" ON)
cmake_dependent_option(WITH_GSL "Enable GSL" ON "GSL_FOUND" OFF)
cmake_dependent_option(WITH_SUNDIALS "Enable sundials solver suite" ON "Sundials_FOUND" OFF)
cmake_dependent_option(WITH_SHMEM "Enable shared memory interface" ON "VILLASnode_FOUND" OFF)
cmake_dependent_option(WITH_RT "Enable real-time features" ON "Linux_FOUND" OFF)
cmake_dependent_option(WITH_PYTHON "Enable Python support" ON "Python_FOUND" OFF)
cmake_dependent_option(WITH_CIM "Enable support for parsing CIM files" ON "CIMpp_FOUND" OFF)
cmake_dependent_option(WITH_OPENMP "Enable OpenMP-based parallelisation" ON "OPENMP_FOUND" OFF)
include(CMakeDependentOption)
cmake_dependent_option(WITH_GSL "Enable GSL" ON "GSL_FOUND" OFF)
cmake_dependent_option(WITH_SUNDIALS "Enable sundials solver suite" ON "Sundials_FOUND" OFF)
cmake_dependent_option(WITH_SHMEM "Enable shared memory interface" ON "VILLASnode_FOUND" OFF)
cmake_dependent_option(WITH_RT "Enable real-time features" ON "Linux_FOUND" OFF)
cmake_dependent_option(WITH_PYTHON "Enable Python support" ON "Python_FOUND" OFF)
cmake_dependent_option(WITH_CIM "Enable support for parsing CIM" ON "CIMpp_FOUND" OFF)
cmake_dependent_option(WITH_OPENMP "Enable OpenMP-based parallelisation" ON "OPENMP_FOUND" OFF)
cmake_dependent_option(WITH_CUDA "Enable CUDA-based parallelisation" ON "CUDA_FOUND" OFF)
cmake_dependent_option(WITH_GRAPHVIZ "Enable Graphviz Graphs" ON "GRAPHVIZ_FOUND" OFF)
if(WITH_CUDA)
# BEGIN OF WORKAROUND - enable cuda dynamic linking.
# Starting with Cmake 3.17 we can use
# set(CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT "SHARED") instead
set( CMAKE_CUDA_FLAGS "" CACHE STRING "" )
if ( CMAKE_CUDA_FLAGS )
list(REMOVE_ITEM CMAKE_CUDA_FLAGS "-cudart static")
endif()
string(APPEND CMAKE_CUDA_FLAGS "-cudart shared")
# END OF WORKAROUND
enable_language(CUDA)
# BEGIN OF WORKAROUND - enable cuda dynamic linking.
if ( CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES )
list( REMOVE_ITEM CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES "cudart_static" )
list( REMOVE_ITEM CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES "cudadevrt" )
list( APPEND CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES "cudart" )
endif()
if ( CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES )
list( REMOVE_ITEM CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES "cudart_static" )
list( REMOVE_ITEM CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES "cudadevrt" )
list( APPEND CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES "cudart" )
endif()
if ( CUDA_LIBRARIES )
list ( REMOVE_ITEM CUDA_LIBRARIES "${CUDA_cudart_static_LIBRARY}")
list ( APPEND CUDA_LIBRARIES "${CUDA_CUDART_LIBRARY}")
endif()
# END OF WORKAROUND
endif()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/Include/dpsim/Config.h.in
${CMAKE_CURRENT_BINARY_DIR}/Include/dpsim/Config.h
)
set(INCLUDE_DIRS
set(DPSIM_INCLUDE_DIRS
${CMAKE_CURRENT_BINARY_DIR}/Include
${CMAKE_CURRENT_SOURCE_DIR}/Include
)
add_subdirectory(Tests)
add_subdirectory(models)
add_subdirectory(Source)
add_subdirectory(docs)
......@@ -116,32 +176,24 @@ if(BUILD_EXAMPLES)
add_subdirectory(Examples)
endif(BUILD_EXAMPLES)
if(COMPARE_REFERENCE)
include(ExternalProject)
ExternalProject_Add(reference-results
GIT_REPOSITORY https://git.rwth-aachen.de/acs/public/simulation/reference-results.git
#GIT_TAG origin/master
PREFIX reference-results
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
endif()
#add_subdirectory(Dependencies/pybind11)
#pybind11_add_module(dpsimpy Source/pybind/main.cpp)
#target_link_libraries(dpsimpy PRIVATE dpsim)
message("Compiler Release Flags:")
message(${CMAKE_CXX_FLAGS_RELEASE})
message("Compiler Debug Flags:")
message(${CMAKE_CXX_FLAGS_DEBUG})
include(cmake/GetGridData.cmake)
message(VERBOSE "Compiler Release Flags: " ${CMAKE_CXX_FLAGS_RELEASE})
message(VERBOSE "Compiler Debug Flags: " ${CMAKE_CXX_FLAGS_DEBUG})
if(TOPLEVEL_PROJECT)
# Show feature summary
include(FeatureSummary)
add_feature_info(CIM WITH_CIM "Loading Common Information Model Files")
add_feature_info(Python WITH_PYTHON "Use DPsim as a Python module")
add_feature_info(Shmem WITH_SHMEM "Interface DPsim solvers via shared-memory interfaces")
add_feature_info(RT WITH_RT "Extended real-time features")
add_feature_info(GSL WITH_GSL "Use GNU Scientific library")
add_feature_info(CIM WITH_CIM "Loading Common Information Model Files")
add_feature_info(Python WITH_PYTHON "Use DPsim as a Python module")
add_feature_info(Shmem WITH_SHMEM "Interface DPsim solvers via shared-memory interfaces")
add_feature_info(RT WITH_RT "Extended real-time features")
add_feature_info(GSL WITH_GSL "Use GNU Scientific library")
add_feature_info(Graphviz WITH_GRAPHVIZ "Graphviz Graphs")
add_feature_info(Sundials WITH_SUNDIALS "Sundials solvers")
feature_summary(WHAT ALL VAR enabledFeaturesText)
if (FOUND_GIT_VERSION)
......
Subproject commit 22cb9414cb0c65b042717c5ccc5aee4c0cdf95c6
Subproject commit a00d674b04d3b67e5fec1da2730ff42b345f6d6b
Subproject commit 1aa9ea92e20142a1ce2f2e1ac40ed1fa781fac19
Subproject commit 5c73ab36eb46d9410da36a9048a4a5061057f4dd
......@@ -36,7 +36,7 @@ int main(int argc, char** argv){
"Rootnet_FULL_NE_06J16h_EQ.xml",
"Rootnet_FULL_NE_06J16h_SV.xml",
"Rootnet_FULL_NE_06J16h_TP.xml"
}, "Examples/CIM/grid-data/CIGRE_MV/NEPLAN/CIGRE_MV_no_tapchanger_With_LoadFlow_Results", "CIMPATH");
}, "build/_deps/cim-data-src/CIGRE_MV/NEPLAN/CIGRE_MV_no_tapchanger_With_LoadFlow_Results", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
......@@ -54,7 +54,7 @@ int main(int argc, char** argv){
logger->addAttribute(node->name() + ".V", node->attribute("v"));
}
Simulation sim(simName, system, 1, 1, Domain::SP, Solver::Type::NRP, Logger::Level::off, true);
Simulation sim(simName, system, 1, 1, Domain::SP, Solver::Type::NRP, Logger::Level::info, true);
sim.addLogger(logger);
sim.run();
......
......@@ -30,9 +30,9 @@ using namespace CPS::CIM;
int main(int argc, char** argv){
#ifdef _WIN32
String loadProfilePath("..\\..\\..\\..\\..\\sogno-grid-data-public\\Load_Data\\CIGRE_MV_NoTap\\");
String loadProfilePath("build\\_deps\\profile-data-src\\CIGRE_MV_NoTap\\load_profiles\\");
#elif defined(__linux__) || defined(__APPLE__)
String loadProfilePath("../sogno-grid-data-public/Load_Data/CIGRE_MV_NoTap/");
String loadProfilePath("build/_deps/profile-data-src/CIGRE_MV_NoTap/load_profiles/");
#endif
std::map<String,String> assignList = {
......@@ -58,26 +58,31 @@ int main(int argc, char** argv){
// 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/grid-data/CIGRE_MV/NEPLAN/CIGRE_MV_no_tapchanger_With_LoadFlow_Results", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
}
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/CIGRE_MV/NEPLAN/CIGRE_MV_no_tapchanger_With_LoadFlow_Results/", "CIMPATH");
String simName = "CIGRE-MV-NoTap-LoadProfiles";
CPS::Real system_freq = 50;
CPS::Real time_begin = 0;
CPS::Real time_step = 1;
CPS::Real time_end = 300;
if (argc > 1) {
CommandLineArgs args(argc, argv);
time_step = args.timeStep;
time_end = args.duration;
}
CIM::Reader reader(simName, Logger::Level::info, Logger::Level::off);
SystemTopology system = reader.loadCIM(system_freq, filenames, CPS::Domain::SP);
CSVReader csvreader(simName, loadProfilePath, assignList, Logger::Level::info);
csvreader.assignLoadProfile(system, 0, 1.5, 15, CSVReader::Mode::MANUAL);
csvreader.assignLoadProfile(system, time_begin, time_step, time_end, CSVReader::Mode::MANUAL);
auto logger = DPsim::DataLogger::make(simName);
for (auto node : system.mNodes)
......@@ -137,7 +142,7 @@ int main(int argc, char** argv){
}
}
Simulation sim(simName, system, 1.5, 15, Domain::SP, Solver::Type::NRP, Logger::Level::info, true);
Simulation sim(simName, system, time_step, time_end, Domain::SP, Solver::Type::NRP, Logger::Level::info, true);
sim.addLogger(logger);
sim.run();
......
......@@ -36,7 +36,7 @@ int main(int argc, char** argv){
"Rootnet_FULL_NE_13J16h_EQ.xml",
"Rootnet_FULL_NE_13J16h_SV.xml",
"Rootnet_FULL_NE_13J16h_TP.xml"
}, "Examples/CIM/grid-data/IEEE_EU_LV/IEEE_EU_LV_reduced", "CIMPATH");
}, "build/_deps/cim-data-src/IEEE_EU_LV/IEEE_EU_LV_reduced", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
......
......@@ -44,7 +44,7 @@ int main(int argc, char** argv){
"Rootnet_FULL_NE_06J16h_EQ.xml",
"Rootnet_FULL_NE_06J16h_SV.xml",
"Rootnet_FULL_NE_06J16h_TP.xml"
}, "Examples/CIM/grid-data/IEEE_EU_LV/IEEE_EU_LV_reduced", "CIMPATH");
}, "build/_deps/cim-data-src/IEEE_EU_LV/IEEE_EU_LV_reduced", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
......
......@@ -32,7 +32,7 @@ int main(int argc, char *argv[]) {
"WSCC-09_RX_EQ.xml",
"WSCC-09_RX_SV.xml",
"WSCC-09_RX_TP.xml"
}, "Examples/CIM/grid-data/WSCC-09/WSCC-09_RX", "CIMPATH");
}, "build/_deps/cim-data-src/WSCC-09/WSCC-09_RX", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
......
......@@ -32,7 +32,7 @@ int main(int argc, char *argv[]) {
"WSCC-09_RX_EQ.xml",
"WSCC-09_RX_SV.xml",
"WSCC-09_RX_TP.xml"
}, "Examples/CIM/grid-data/WSCC-09/WSCC-09_RX_Dyn", "CIMPATH");
}, "build/_deps/cim-data-src/WSCC-09/WSCC-09_RX_Dyn", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
......
......@@ -32,7 +32,7 @@ int main(int argc, char *argv[]) {
"WSCC-09_RX_EQ.xml",
"WSCC-09_RX_SV.xml",
"WSCC-09_RX_TP.xml"
}, "Examples/CIM/grid-data/WSCC-09/WSCC-09_RX_Dyn", "CIMPATH");
}, "build/_deps/cim-data-src/WSCC-09/WSCC-09_RX_Dyn", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
......
......@@ -73,18 +73,18 @@ void multiply_connected(SystemTopology& sys, int copies,
}
}
void simulateCoupled(std::list<fs::path> filenames, Int copies, Int threads, Int seq = 0) {
void simulateCoupled(std::list<fs::path> filenames, Int copies, Int threads, Int seq = 0, Logger::Level logLevel = Logger::Level::off) {
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);
CIM::Reader reader(simName, logLevel, logLevel);
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);
Simulation sim(simName, logLevel);
sim.setSystem(sys);
sim.setTimeStep(0.0001);
sim.setFinalTime(0.5);
......@@ -120,7 +120,7 @@ int main(int argc, char *argv[]) {
"WSCC-09_RX_EQ.xml",
"WSCC-09_RX_SV.xml",
"WSCC-09_RX_TP.xml"
}, "Examples/CIM/grid-data/WSCC-09/WSCC-09_RX", "CIMPATH");
}, "build/_deps/cim-data-src/WSCC-09/WSCC-09_RX", "CIMPATH");
//for (Int copies = 0; copies < 20; copies++) {
// for (Int threads = 0; threads <= 12; threads = threads+2)
......@@ -131,5 +131,5 @@ int main(int argc, char *argv[]) {
<< 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"]));
Int(args.options["threads"]), Int(args.options["seq"]), args.logLevel);
}
......@@ -104,7 +104,7 @@ int main(int argc, char *argv[]) {
"WSCC-09_RX_EQ.xml",
"WSCC-09_RX_SV.xml",
"WSCC-09_RX_TP.xml"
}, "Examples/CIM/grid-data/WSCC-09/WSCC-09_RX", "CIMPATH");
}, "build/_deps/cim-data-src/WSCC-09/WSCC-09_RX", "CIMPATH");
//for (Int copies = 0; copies < 10; copies++) {
// for (Int threads = 0; threads <= 12; threads = threads+2)
......
......@@ -119,7 +119,7 @@ int main(int argc, char *argv[]) {
"WSCC-09_RX_EQ.xml",
"WSCC-09_RX_SV.xml",
"WSCC-09_RX_TP.xml"
}, "Examples/CIM/grid-data/WSCC-09/WSCC-09_RX", "CIMPATH");
}, "build/_deps/cim-data-src/WSCC-09/WSCC-09_RX", "CIMPATH");
//for (Int copies = 0; copies < 10; copies++) {
// for (Int threads = 0; threads <= 12; threads = threads+2) {
......
......@@ -33,7 +33,7 @@ int main(int argc, char** argv){
if (argc <= 1) {
filenames = DPsim::Utils::findFiles({
"case14Both.xml"
}, "Examples/CIM/grid-data/Matpower_cases", "CIMPATH");
}, "build/_deps/cim-data-src/Matpower_cases", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
......
......@@ -33,7 +33,7 @@ int main(int argc, char** argv){
if (argc <= 1) {
filenames = DPsim::Utils::findFiles({
"case145.xml"
}, "Examples/CIM/grid-data/Matpower_cases", "CIMPATH");
}, "build/_deps/cim-data-src/Matpower_cases", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
......
......@@ -33,7 +33,7 @@ int main(int argc, char** argv){
if (argc <= 1) {
filenames = DPsim::Utils::findFiles({
"case300.xml"
}, "Examples/CIM/grid-data/Matpower_cases", "CIMPATH");
}, "build/_deps/cim-data-src/Matpower_cases", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
......
......@@ -33,7 +33,7 @@ int main(int argc, char** argv){
if (argc <= 1) {
filenames = DPsim::Utils::findFiles({
"case9.xml"
}, "Examples/CIM/grid-data/Matpower_cases", "CIMPATH");
}, "build/_deps/cim-data-src/Matpower_cases", "CIMPATH");
}
else {
filenames = std::list<fs::path>(argv + 1, argv + argc);
......
......@@ -11,20 +11,20 @@ set(CIRCUIT_SOURCES
# Dynamic phasor examples
Circuits/DP_VS_RL1.cpp
Circuits/DP_Circuits.cpp
Circuits/DP_Basics_DP_Sims.cpp
Circuits/DP_Basics_DP_Sims.cpp
Circuits/DP_PiLine.cpp
Circuits/DP_DecouplingLine.cpp
Circuits/DP_Diakoptics.cpp
Circuits/DP_VSI.cpp
# EMT examples
Circuits/EMT_CS_RL1.cpp
Circuits/EMT_VS_RL1.cpp
Circuits/EMT_Circuits.cpp
Circuits/DP_Basics_EMT_Sims.cpp
Circuits/DP_Basics_EMT_Sims.cpp
#Circuits/EMT_ResVS_RL_Switch.cpp
Circuits/EMT_VSI.cpp
# Static Phasor examples
Circuits/SP_Circuits.cpp
......@@ -32,7 +32,7 @@ set(CIRCUIT_SOURCES
Circuits/DP_EMT_RL_SourceStep.cpp
)
set(SYNCGEN_SOURCES
set(SYNCGEN_SOURCES
Components/DP_SynGenDq7odTrapez_SteadyState.cpp
Components/DP_SynGenDq7odTrapez_ThreePhFault.cpp
Components/DP_SynGenTrStab_SteadyState.cpp
......@@ -45,7 +45,7 @@ set(SYNCGEN_SOURCES
set(INVERTER_SOURCES
Components/DP_Inverter_Grid.cpp
Components/DP_Inverter_Grid_Parallel_FreqSplit.cpp
Components/DP_Inverter_Grid_Sequential_FreqSplit.cpp
Components/DP_Inverter_Grid_Sequential_FreqSplit.cpp
)
if(WITH_SUNDIALS)
......@@ -60,6 +60,11 @@ if(WITH_SUNDIALS)
set(DAE_SOURCES
DAE/DAE_DP_test.cpp
DAE/DAE_EMT_RL1.cpp
DAE/DAE_EMT_RC1.cpp
DAE/DAE_EMT_RLC1.cpp
DAE/DAE_EMT_Slack_PiLine_RXLoad.cpp
DAE/MNA_EMT_Slack_PiLine_RXLoad.cpp
)
endif()
......@@ -91,19 +96,19 @@ if(WITH_CIM)
list(APPEND INCLUDE_DIRS ${CIMPP_INCLUDE_DIRS})
set(CIM_SOURCES
CIM/dpsim-cim.cpp
CIM/dpsim-cim.cpp
CIM/WSCC-9bus_CIM.cpp
CIM/WSCC-9bus_CIM_Dyn.cpp
CIM/WSCC-9bus_CIM_Dyn_Switch.cpp
# PF(Power Flow) example
# PF(Power Flow) example
CIM/Slack_Trafo_Load.cpp
CIM/Slack_TrafoTapChanger_Load.cpp
CIM/CIGRE_MV_PowerFlowTest.cpp
CIM/CIGRE_MV_PowerFlowTest_LoadProfiles.cpp
CIM/IEEE_LV_PowerFlowTest.cpp
CIM/IEEE_LV_PowerFlowTest_LoadProfiles.cpp
CIM/case145.cpp
CIM/case300.cpp
CIM/case9.cpp
......@@ -154,7 +159,9 @@ endforeach()
if(WITH_SHMEM)
add_executable(ShmemRealtimeExample Shmem/ShmemExample.cpp)
target_link_libraries(ShmemRealtimeExample ${LIBRARIES})
target_include_directories(ShmemRealtimeExample PRIVATE ${INCLUDE_DIRS})
target_include_directories(ShmemRealtimeExample PRIVATE ${INCLUDE_DIRS})
target_compile_definitions(ShmemRealtimeExample PUBLIC REALTIME)
endif()
add_subdirectory(cim_graphviz)
add_subdirectory(signals)
\ No newline at end of file
......@@ -81,10 +81,13 @@ void DP_Ph1_VSI2_4bus_SampleGrid() {
auto Lload2 = Ph1::Inductor::make("Lload2");
Lload2->setParameters(Lload_param_100var_220v);
vsi->setParameters(2 * M_PI * 50, Complex(Vnom, 0), Pref1, Qref1, 0.25, 2, 0.001, 0.08, 3.77, 1400,
lf_param, cf_param, rf_param, rc_param);
vsi2->setParameters(2 * M_PI * 50, Complex(Vnom, 0), Pref2, Qref2, 0.25, 2, 0.001, 0.08, 3.77, 1400,
lf_param, cf_param, rf_param, rc_param);
vsi->setParameters(2 * M_PI * 50, Vnom, Pref1, Qref1);
vsi->setControllerParameters(0.25, 2, 0.001, 0.08, 3.77, 1400, 2 * M_PI * 50);
vsi->setFilterParameters(lf_param, cf_param, rf_param, rc_param);
vsi2->setParameters(2 * M_PI * 50, Vnom, Pref2, Qref2);
vsi2->setControllerParameters(0.25, 2, 0.001, 0.08, 3.77, 1400, 2 * M_PI * 50);
vsi2->setFilterParameters(lf_param, cf_param, rf_param, rc_param);
// 4Bus case study
vs->connect(SimNode::List{ SimNode::GND, n5 });
......
......@@ -55,32 +55,13 @@ void EMT_Ph3_VSI2_4bus_SampleGrid() {
auto trans_DG1 = Ph3::Transformer::make("trans_pv1", Logger::Level::debug);
auto trans_DG2 = Ph3::Transformer::make("trans_pv2", Logger::Level::debug);
Matrix rf_param = Matrix::Zero(3, 3);
rf_param <<
0.01, 0, 0,
0, 0.01, 0,
0, 0, 0.01;
Matrix lf_param = Matrix(3, 3);
lf_param <<
0.928e-3, 0, 0,
0, 0.928e-3, 0,
0, 0, 0.928e-3;
Matrix cf_param = Matrix(3, 3);
cf_param <<
789.3e-6, 0, 0,
0, 789.3e-6, 0,
0, 0, 789.3e-6;
Matrix rc_param = Matrix::Zero(3, 3);
rc_param <<
0.5, 0, 0,
0, 0.5, 0,
0, 0, 0.5;
trans_DG1->setParameters(Vnom_pv / Vnom, 0., rc_param, lf_param*0.01);
trans_DG2->setParameters(Vnom_pv / Vnom, 0., rc_param, lf_param * 0.01);
Real rf_param = 0.01;
Real lf_param = 0.928e-3;
Real cf_param = 789.3e-6;
Real rc_param = 0.5;
trans_DG1->setParameters(Vnom_pv / Vnom, 0., Matrix::Identity(3,3)*rc_param, Matrix::Identity(3,3)*lf_param*0.01);
trans_DG2->setParameters(Vnom_pv / Vnom, 0., Matrix::Identity(3,3)*rc_param, Matrix::Identity(3,3)*lf_param * 0.01);
//trans_inductor->setParameters(lf_param*0.01);
auto piline = PiLine::make("piline", Logger::Level::debug);
......@@ -90,7 +71,7 @@ void EMT_Ph3_VSI2_4bus_SampleGrid() {
0, 0.04, 0,
0, 0, 0.04;
piline->setParameters(rline_param*10, lf_param*0.0001, cf_param);
piline->setParameters(rline_param*10, Matrix::Identity(3,3)*lf_param*0.0001, Matrix::Identity(3,3)*cf_param);
auto rline2 = Resistor::make("rline2", Logger::Level::info);
rline2->setParameters(rline_param);
......@@ -127,13 +108,13 @@ void EMT_Ph3_VSI2_4bus_SampleGrid() {
auto Lload2 = Inductor::make("Lload2", Logger::Level::info);
Lload2->setParameters(Lload_param_100var_220v);
vsi->setParameters(2 * M_PI * 50, Complex(Vnom_pv, 0),
Pref1, Qref1, 0.25, 2, 0.001, 0.08, 3.77, 1400,
lf_param, cf_param, rf_param, rc_param);
vsi->setParameters(2 * M_PI * 50, Vnom_pv, Pref1, Qref1);
vsi->setControllerParameters(0.25, 2, 0.001, 0.08, 3.77, 1400, 2 * M_PI * 50);
vsi->setFilterParameters(lf_param, cf_param, rf_param, rc_param);
vsi2->setParameters(2 * M_PI * 50, Complex(Vnom, 0),
Pref2, Qref2, 0.25, 2, 0.001, 0.08, 3.77, 1400,
lf_param, cf_param, rf_param, rc_param);
vsi2->setParameters(2 * M_PI * 50, Vnom_pv, Pref2, Qref2);
vsi2->setControllerParameters(0.25, 2, 0.001, 0.08, 3.77, 1400, 2 * M_PI * 50);
vsi2->setFilterParameters(lf_param, cf_param, rf_param, rc_param);
Matrix p_load = Matrix::Zero(3, 3);
p_load <<
......
/**
*
* @author Martin Moraga <mmoraga@eonerc.rwth-aachen.de>
* @copyright 2017-2020, 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 <DPsim.h>
using namespace DPsim;
using namespace CPS::EMT;
using namespace CPS::EMT::Ph1;
int main(int argc, char* argv[])
{
Real timeStep = 0.0001;
Real finalTime = 0.1;
String simName = "DAE_EMT_VS_RC1";
Logger::setLogDir("logs/"+simName);
// Nodes
std::vector<Complex> initialVoltage_n1{ Complex(10,0), 0, 0 };
std::vector<Complex> initialVoltage_n2{ Complex(0.92, -2.89), 0, 0 };
auto n1 = SimNode::make("n1", PhaseType::Single, initialVoltage_n1);
auto n2 = SimNode::make("n2", PhaseType::Single, initialVoltage_n2);
// Components
auto vs = VoltageSource::make("vs", Logger::Level::info);
vs->setParameters(Complex(10, 0), 50);
auto r1 = Resistor::make("r_1");
r1->setParameters(5);
auto c1 = Capacitor::make("c_1", Logger::Level::info);
c1->setParameters(0.002);
// Topology
vs->connect(SimNode::List{ SimNode::GND, n1 });
r1->connect(SimNode::List{ n2, n1 });
c1->connect(SimNode::List{ SimNode::GND, n2 });
// Define system topology
auto sys = SystemTopology(50, SystemNodeList{n1, n2}, SystemComponentList{vs, r1, c1});
// Logger
auto logger = DataLogger::make(simName);
logger->addAttribute("vs", vs->attribute("v_intf"));
logger->addAttribute("i_vs", vs->attribute("i_intf"));
logger->addAttribute("vr", r1->attribute("v_intf"));
logger->addAttribute("i_r", r1->attribute("i_intf"));
logger->addAttribute("v_c1", c1->attribute("v_intf"));
logger->addAttribute("i_c1", c1->attribute("i_intf"));
logger->addAttribute("v1", n1->attribute("v"));
logger->addAttribute("v2", n2->attribute("v"));
vs->setInitialCurrent(Complex(1.816,0.5782));
Simulation sim(simName, sys, timeStep, finalTime, Domain::EMT, Solver::Type::DAE);
sim.doSplitSubnets(false);
sim.addLogger(logger);
sim.run();
return 0;
}
/**
*
* @author Martin Moraga <mmoraga@eonerc.rwth-aachen.de>
* @copyright 2017-2020, 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 <DPsim.h>
using namespace DPsim;
using namespace CPS::EMT;
using namespace CPS::EMT::Ph1;
int main(int argc, char* argv[])
{
Real timeStep = 0.0001;
Real finalTime = 0.1;
String simName = "DAE_EMT_VS_RL1";
Logger::setLogDir("logs/"+simName);
// Nodes
std::vector<Complex> initialVoltage_n1{ Complex( 10, 0), 0, 0 };
std::vector<Complex> initialVoltage_n2{ Complex( 0.8983, 2.85938), 0, 0 };
auto n1 = SimNode::make("n1", PhaseType::Single, initialVoltage_n1);
auto n2 = SimNode::make("n2", PhaseType::Single, initialVoltage_n2);
// Components
auto vs = VoltageSource::make("vs", Logger::Level::info);
vs->setParameters(Complex(10, 0), 50);
auto r1 = Resistor::make("r_1", Logger::Level::info);
r1->setParameters(5);
auto l1 = Inductor::make("l_1", Logger::Level::info);
l1->setParameters(0.005);
// Topology
vs->connect(SimNode::List{ SimNode::GND, n1 });
r1->connect(SimNode::List{ n2, n1 });
l1->connect(SimNode::List{ SimNode::GND, n2 });
// Define system topology
auto sys = SystemTopology(50, SystemNodeList{n1, n2}, SystemComponentList{vs, r1, l1});
// Logger
auto logger = DataLogger::make(simName);
logger->addAttribute("vs", vs->attribute("v_intf"));
logger->addAttribute("i_vs", vs->attribute("i_intf"));
logger->addAttribute("vr", r1->attribute("v_intf"));
logger->addAttribute("i_r", r1->attribute("i_intf"));
logger->addAttribute("v_l1", l1->attribute("v_intf"));
logger->addAttribute("i_l1", l1->attribute("i_intf"));
logger->addAttribute("v1", n1->attribute("v"));
logger->addAttribute("v2", n2->attribute("v"));
vs->setInitialCurrent(Complex(1.82034, -0.57187));
Simulation sim(simName, sys, timeStep, finalTime, Domain::EMT, Solver::Type::DAE);
sim.doSplitSubnets(false);
sim.addLogger(logger);
sim.run();
return 0;
}
/**
*
* @author Martin Moraga <mmoraga@eonerc.rwth-aachen.de>
* @copyright 2017-2020, 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 <DPsim.h>
using namespace DPsim;
using namespace CPS::EMT;
using namespace CPS::EMT::Ph1;
int main(int argc, char* argv[])
{
Real timeStep = 0.0001;
Real finalTime = 0.1;
String simName = "DAE_EMT_RLC1";
Logger::setLogDir("logs/"+simName);
// Nodes
std::vector<Complex> initialVoltage_n1{ Complex(10,0), 0, 0 };
std::vector<Complex> initialVoltage_n2{ Complex( 0.0007, -0.083), 0, 0 };
std::vector<Complex> initialVoltage_n3{ Complex( 0.0528, -6.366), 0, 0 };
auto n1 = SimNode::make("n1", PhaseType::Single, initialVoltage_n1);
auto n2 = SimNode::make("n2", PhaseType::Single, initialVoltage_n2);
auto n3 = SimNode::make("n3", PhaseType::Single, initialVoltage_n3);
// Components
auto vs = VoltageSource::make("vs", Logger::Level::info);
vs->setParameters(Complex(10, 0), 50);
auto r1 = Resistor::make("r1", Logger::Level::info);
r1->setParameters(10);
auto l1 = Inductor::make("l1", Logger::Level::info);
l1->setParameters(0.02);
auto c1 = Capacitor::make("c1", Logger::Level::info);
c1->setParameters(0.0005);
// Topology
vs->connect(SimNode::List{ SimNode::GND, n1 });
r1->connect(SimNode::List{ n2, n1 });
l1->connect(SimNode::List{ n3, n2 });
c1->connect(SimNode::List{ SimNode::GND, n3});
// Define system topology
auto sys = SystemTopology(50, SystemNodeList{n1, n2, n3}, SystemComponentList{vs, r1, l1, c1});
// vs->setInitialCurrent(0.99993);
// Logger
auto logger = DataLogger::make(simName);
logger->addAttribute("vs", vs->attribute("v_intf"));
logger->addAttribute("i_c", c1->attribute("i_intf"));
logger->addAttribute("v_l", l1->attribute("v_intf"));
logger->addAttribute("v_c", c1->attribute("v_intf"));
logger->addAttribute("v_r", r1->attribute("v_intf"));
vs->setInitialCurrent(Complex(0.99993,0.0083));
Simulation sim(simName, sys, timeStep, finalTime, Domain::EMT, Solver::Type::DAE);