Commit 69b268ef authored by Markus Mirz's avatar Markus Mirz
Browse files

merge


Former-commit-id: b3016252
parents c801a12f e10f109b
# Folders
Libraries
lib
build
Build
Results
Logs
.idea
.vs
Libraries/
Results/
Logs/
build/
VisualStudio/
# IDEs
cmake-build-debug/
.idea/
.vs/
*.json
# CMake
CMakeFiles/
......
variables:
DOCKER_IMAGE: dpsim-dev-${CI_COMMIT_REF_NAME}
DOCKER_TAG_DEV: ${CI_COMMIT_REF_NAME}
DOCKER_IMAGE_DEV: dpsim-dev
DOCKER_IMAGE_WEB: dpsim-web
GIT_SUBMODULE_STRATEGY: recursive
stages:
- prepare
- build
- docs
- test
- deploy
docker:
stage: prepare
script:
- docker build -t ${DOCKER_IMAGE} .
- docker build -t ${DOCKER_IMAGE_DEV}:${DOCKER_TAG_DEV} .
- docker images
tags:
- shell
build:
stage: build
script:
- mkdir Source/build
- cd Source/build
- mkdir build
- cd build
- cmake ..
- make
image: ${DOCKER_IMAGE}
- make -j 8
image: ${DOCKER_IMAGE_DEV}:${DOCKER_TAG_DEV}
artifacts:
paths:
- Source/build
- build
tags:
- docker
docs:
stage: docs
script:
- cd build
- cmake ..
- make docs
image: ${DOCKER_IMAGE}
- make docs_cxx
image: ${DOCKER_IMAGE_DEV}:${DOCKER_TAG_DEV}
artifacts:
paths:
- Documentation/html
- build/Documentation/html
- build/Documentation/Cxx/html
tags:
- docker
test:
stage: test
variables:
PYTHONPATH: Source/build
deploy:
stage: deploy
script:
- python3 Examples/Python/ci.py
image: ${DOCKER_IMAGE}
- docker build -f Dockerfile.webdoc -t ${DOCKER_IMAGE_WEB}:${DOCKER_TAG_DEV} .
- docker images
- docker container stop dpsim-webdoc
- docker container rm dpsim-webdoc
- docker run --name dpsim-webdoc -d -p 8080:80 ${DOCKER_IMAGE_WEB}:${DOCKER_TAG_DEV}
tags:
- docker
- shell
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_PACKAGE_VENDOR ${PROJECT_AUTHOR})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Dynamic Phasor simulation library in C++")
set(CPACK_PACKAGE_VERSION_MAJOR ${DPsim_MAJOR_VERSION})
set(CPACK_PACKAGE_VERSION_MINOR ${DPsim_MINOR_VERSION})
set(CPACK_PACKAGE_VERSION_PATCH ${DPsim_PATH_VERSION})
set(CPACK_RPM_PACKAGE_RELEASE "1")
set(CPACK_RPM_PACKAGE_LICENSE "GPLv3")
set(CPACK_RPM_PACKAGE_URL "http://www.fein-aachen.org/projects/dpsim/")
set(CPACK_RPM_PACKAGE_REQUIRES "libcimpp")
set(CPACK_RPM_PACKAGE_GROUP "Development/Libraries")
# As close as possible to Fedoras naming
set(CPACK_RPM_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}.${CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.md")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_GENERATOR "RPM;TGZ")
include(CPack)
option(CIMPP_DIR "CIM++ installation directory" ../CIMpp)
if(WIN32)
file(TO_CMAKE_PATH $ENV{APPDATA} APPDATA)
endif()
find_path(CIMPP_INCLUDE_DIR
NAMES CIMModel.hpp
PATH_SUFFIXES
cimpp/16v29a_12v08
cimpp/16v29a
cimpp/17v07
PATHS
../CIMpp/include
${APPDATA}/CIMpp/include
${CIMPP_DIR}
)
find_library(CIMPP_LIBRARY
NAMES cimpp${CIM_DIR}
PATH_SUFFIXES
lib/static
PATHS
../CIMpp
${APPDATA}/CIMpp
${CIMPP_DIR}
)
include(FindPackageHandleStandardArgs)
# 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 CIMPP_LIBRARY)
set(CIMPP_LIBRARIES ${CIMPP_LIBRARY})
set(CIMPP_INCLUDE_DIRS ${CIMPP_INCLUDE_DIR})
# We first try to find a version inside our local Libraries folder
find_path(EIGEN3_INCLUDE_DIR
NAMES signature_of_eigen3_matrix_library
PATHS
Libraries/eigen
../Eigen
)
if(NOT EIGEN3_INCLUDE_DIR)
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)
find_program(SPHINX_EXECUTABLE NAMES sphinx-build
HINTS
$ENV{SPHINX_DIR}
PATH_SUFFIXES bin
DOC "Sphinx documentation generator"
HINTS
$ENV{SPHINX_DIR}
PATH_SUFFIXES bin
DOC "Sphinx documentation generator"
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Sphinx DEFAULT_MSG
SPHINX_EXECUTABLE
SPHINX_EXECUTABLE
)
mark_as_advanced(SPHINX_EXECUTABLE)
find_path(VILLASNODE_INCLUDE_DIR
NAMES villas/shmem.h
)
find_library(VILLASNODE_LIBRARY
NAMES villas-ext
)
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set VILLASNODE_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(VILLASnode DEFAULT_MSG
VILLASNODE_LIBRARY VILLASNODE_INCLUDE_DIR)
mark_as_advanced(VILLASNODE_INCLUDE_DIR VILLASNODE_LIBRARY)
set(VILLASNODE_LIBRARIES ${VILLASNODE_LIBRARY})
set(VILLASNODE_INCLUDE_DIRS ${VILLASNODE_INCLUDE_DIR})
cmake_minimum_required(VERSION 3.9)
project(DPsim)
cmake_minimum_required(VERSION 3.5)
project(DPsim CXX)
# Enable C++11 support
set(CMAKE_CXX_STANDARD 11)
set(PROJECT_AUTHOR "Institute for Automation of Complex Power Systems, RWTH Aachen Univerity")
set(PROJECT_COPYRIGHT "2017, Institute for Automation of Complex Power Systems, RWTH Aachen Univerity")
......@@ -11,15 +14,46 @@ set(DPSIM_VERSION ${DPSIM_MAJOR_VERSION}.${DPSIM_MINOR_VERSION}.${DPSIM_PATCH_VE
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake")
set(Python_ADDITIONAL_VERSIONS 3.5 3.6 3.7)
set(CIM_DIR 16v29a)
find_package(Eigen3 3.0 REQUIRED)
find_package(CIMpp)
find_package(VILLASnode)
find_package(PythonInterp 3.5)
find_package(PythonLibs 3.5)
if(PythonInterp_FOUND AND PythonLibs_FOUND)
set(Python_FOUND ON)
endif()
if("${CMAKE_SYSTEM}" MATCHES "Linux")
set(Linux_FOUND ON)
endif()
# Options
option(BUILD_SHARED_LIBS "Build shared library" OFF)
option(WITH_RT "Enable real-time features" ${Linux_FOUND})
option(WITH_SHMEM "Enable shared memory interface" ${VILLASnode_FOUND})
option(WITH_PYTHON "Enable Python support" ${Python_FOUND})
option(WITH_CIM "Enable support for parsing CIM files" ${CIMpp_FOUND})
add_subdirectory(Documentation)
add_subdirectory(Source)
add_subdirectory(Examples/C++)
add_subdirectory(Examples/Cxx)
# 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 "Execute simulation in real time")
feature_summary(WHAT ALL VAR enabledFeaturesText)
message(STATUS "${enabledFeaturesText}")
# CPack configuration
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "My funky project")
SET(CPACK_PACKAGE_VENDOR ${PROJECT_AUTHOR})
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/ReadMe.txt")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt")
SET(CPACK_PACKAGE_VERSION_MAJOR "1")
SET(CPACK_PACKAGE_VERSION_MINOR "3")
SET(CPACK_PACKAGE_VERSION_PATCH "2")
include(DPsimPackaging)
FROM fedora:latest
MAINTAINER Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
FROM fedora:27
LABEL \
org.label-schema.schema-version = "1.0" \
org.label-schema.name = "DPsim" \
org.label-schema.license = "GPL-3.0" \
org.label-schema.vendor = "Institute for Automation of Complex Power Systems, RWTH Aachen University" \
org.label-schema.author.name = "Steffen Vogel" \
org.label-schema.author.email = "stvogel@eonerc.rwth-aachen.de" \
org.label-schema.url = "http://fein-aachen.org/projects/dpsim/" \
org.label-schema.vcs-url = "https://git.rwth-aachen.de/acs/core/simulation/DPsim"
ADD https://villas.fein-aachen.org/packages/villas.repo /etc/yum.repos.d/
RUN dnf -y update
# Toolchain
RUN dnf -y install \
git \
gcc-c++ \
make \
cmake \
eigen3-devel \
redhat-rpm-config \
make cmake \
doxygen \
libxml2-devel \
python3-pandas \
python3-numpy \
python3-sphinx
python-pip
# Dependencies
RUN dnf -y install \
python-devel \
eigen3-devel \
villas-node-devel
RUN dnf -y install villas-node-devel
# Python Packages
RUN pip install \
pandas \
numpy \
matplotlib \
sphinx
FROM nginx
COPY build/Documentation/html /usr/share/nginx/html
COPY build/Documentation/Cxx/html /usr/share/nginx/html/cxx
\ No newline at end of file
find_package(Sphinx REQUIRED)
find_package(Sphinx)
if(NOT DEFINED SPHINX_THEME)
set(SPHINX_THEME alabaster)
endif()
if(SPHINX_EXECUTABLE)
if(NOT DEFINED SPHINX_THEME_DIR)
set(SPHINX_THEME_DIR)
endif()
if(NOT DEFINED SPHINX_THEME)
set(SPHINX_THEME alabaster)
endif()
if(NOT DEFINED SPHINX_THEME_DIR)
set(SPHINX_THEME_DIR)
endif()
# configured documentation tools and intermediate build results
set(BINARY_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/_build")
# configured documentation tools and intermediate build results
set(BINARY_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/_build")
# Sphinx cache with pickled ReST documents
set(SPHINX_CACHE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_doctrees")
# Sphinx cache with pickled ReST documents
set(SPHINX_CACHE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_doctrees")
# HTML output directory
set(SPHINX_HTML_DIR "${CMAKE_CURRENT_BINARY_DIR}/html")
set(SPHINX_TITLE "${PROJECT_NAME} Documentation")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in"
"${BINARY_BUILD_DIR}/conf.py"
@ONLY
)
add_custom_target(docs
${SPHINX_EXECUTABLE}
-q -b html
-c "${BINARY_BUILD_DIR}"
-d "${SPHINX_CACHE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}"
"${SPHINX_HTML_DIR}"
COMMENT "Building HTML documentation with Sphinx"
DEPENDS dpsim)
endif()
# HTML output directory
set(SPHINX_HTML_DIR "${CMAKE_CURRENT_BINARY_DIR}/html")
# add a target to generate API documentation with Doxygen
find_package(Doxygen)
set(SPHINX_TITLE "${PROJECT_NAME} Documentation")
if(DOXYGEN_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
# HTML output directory
set(DOXYGEN_HTML_DIR "${CMAKE_CURRENT_BINARY_DIR}/Cxx")
file(MAKE_DIRECTORY ${DOXYGEN_HTML_DIR})
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in"
"${BINARY_BUILD_DIR}/conf.py"
@ONLY
)
add_custom_target(docs_cxx
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
add_custom_target(docs
${SPHINX_EXECUTABLE}
-q -b html
-c "${BINARY_BUILD_DIR}"
-d "${SPHINX_CACHE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}"
"${SPHINX_HTML_DIR}"
COMMENT "Building HTML documentation with Sphinx"
DEPENDS dpsim)
endif(DOXYGEN_FOUND)
\ No newline at end of file
05be780be3f60dd4f6e33ad4ddaa9d0c1b4f5ecf
\ No newline at end of file
......@@ -4,7 +4,7 @@ Build
Windows (Visual Studio)
-----------------------
1. Install Visual Studio 2017 C++ Desktop development package plus Windows 8.1 SDK
1. Install Visual Studio 2017 C++ Desktop development package
2. Install `Python 3`_ using the normal installer, and add Python to your PATH.
3. Create a new folder name ``Libraries`` in the repository root, download Eigen_ and copy it to ``Libraries/eigen``.
4. Install CMake_, use its GUI (with `Source` as the source path) to create project files for Visual Studio. If you installed the 64-bit version of Python, make sure to use the "Win64" version of the Visual Studio generator.
......
11333db8c2e552635ccbc25050b0393137074fce
\ No newline at end of file
cmake_minimum_required(VERSION 3.5)
project(DPsimExample)
# library configuration etc.
if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../Libraries/eigen)
set(EIGEN3_INCLUDE_DIR ../../Libraries/eigen)
else()
find_package(Eigen3 REQUIRED)
endif()
include_directories(${EIGEN3_INCLUDE_DIR} "../../Source")
if (NOT WIN32)
# needed so CIMParser and arabica (which are first compiled into static libs)
# can be included in the .so
set(CMAKE_CXX_FLAGS "-fPIC")
# we use PyArg_ParseTupleAndKeywords several times, which erroneously accepts
# a char* array instead of a const char* array
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-write-strings")
endif()
# enable C++11 support
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# add files
file(GLOB SOURCES *.cpp)
# targets
add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(DPsimExample dpsim)
/** Shared-memory interface Test
*
* @author Markus Mirz <mmirz@eonerc.rwth-aachen.de>
* @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
* @license GNU General Public License (version 3)
*
* 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/>.
*********************************************************************************/
#ifdef __linux__
#include "ShmemTest.h"
#include "../Simulation.h"
#include "../ShmemInterface.h"
#include "../Utilities.h"
using namespace DPsim;
void DPsim::shmemExample()
{
// Very simple test circuit. Just a few resistors and an inductance.
// Voltage is read from VILLASnode and current through everything is written back.
Logger log("output.log"), llog("lvector.log"), rlog("rvector.log");
ElementList comps;
ExternalVoltageSource *evs = new ExternalVoltageSource("v_s", 1, 0, Complex(0, 0), 1);
comps.push_back(evs);
comps.push_back(new LinearResistor("r_s", 1, 2, 1));
comps.push_back(new LinearResistor("r_line", 2, 3, 1));
comps.push_back(new Inductor("l_line", 3, 4, 1));
comps.push_back(new LinearResistor("r_load", 4, 0, 1000));
ShmemInterface *villas = new ShmemInterface("/villas1-in", "/villas1-out");
villas->registerVoltageSource(evs, 0, 1);
villas->registerExportedCurrent(evs, 0, 1);
// Set up simulation
Real timeStep = 0.001;
Simulation newSim(comps, 2.0*M_PI*50.0, timeStep, 0.3, log);
newSim.addExternalInterface(villas);
// Main Simulation Loop
std::cout << "Start simulation." << std::endl;
while (newSim.step(log, llog, rlog))
{
newSim.increaseByTimeStep();
updateProgressBar(newSim.getTime(), newSim.getFinalTime());
}
std::cout << "Simulation finished." << std::endl;
for (auto comp : comps) {
delete comp;
}
delete villas;
}
void DPsim::shmemRTExample()
{
// Same circuit as above, but now with realtime support.
ElementList comps;
struct shmem_conf conf;
conf.samplelen = 4;
conf.queuelen = 1024;
conf.polling = false;
Logger log;
ExternalVoltageSource *evs = new ExternalVoltageSource("v_s", 1, 0, Complex(0, 0), 1);
comps.push_back(evs);
comps.push_back(new LinearResistor("r_s", 1, 2, 1));
comps.push_back(new LinearResistor("r_line", 2, 3, 1));
comps.push_back(new Inductor("l_line", 3, 4, 1));
comps.push_back(new LinearResistor("r_load", 4, 0, 1000));
ShmemInterface *villas = new ShmemInterface("/villas1-in", "/villas1-out", &conf);
villas->registerVoltageSource(evs, 0, 1);
villas->registerExportedCurrent(evs, 0, 1);
// Set up simulation
Real timeStep = 0.001;
Simulation newSim(comps, 2.0*M_PI*50.0, timeStep, 5.0, log);
newSim.addExternalInterface(villas);
// Main Simulation Loop
std::cout << "Start simulation." << std::endl;
newSim.runRT(RTExceptions, false, log, log, log);
std::cout << "Simulation finished." << std::endl;
for (auto comp : comps) {
delete comp;
}
delete villas;
}
void DPsim::shmemDistributedDirect(int argc, char *argv[])
{
// Testing the interface with a simple circuit,
// but the load is simulated in a different instance.
// Values are exchanged using the ideal transformator model: an ideal
// current source on the supply side and an ideal voltage source on the
// supply side, whose values are received from the respective other circuit.
// Here, the two instances directly communicate with each other without using
// VILLASnode in between.
Logger log;
ElementList comps;
ShmemInterface *shmem;
struct shmem_conf conf;
conf.samplelen = 4;
conf.queuelen = 1024;
conf.polling = false;
if (argc < 2) {
std::cerr << "not enough arguments (either 0 or 1 for the test number)" << std::endl;
std::exit(1);
}
if (!strcmp(argv[1], "0")) {
comps.push_back(make_shared<VoltSourceRes>("v_s", 1, 0, Complex(10000, 0), 1));
comps.push_back(new Inductor("l_1", 1, 2, 1e-3));
ExternalVoltageSource *evs = new ExternalVoltageSource("v_t", 2, 0, Complex(0, 0), 1);
comps.push_back(evs);
shmem = new ShmemInterface("/dpsim01", "/dpsim10", &conf);
shmem->registerVoltageSource(evs, 0, 1);
shmem->registerExportedCurrent(evs, 0, 1);
} else if (!strcmp(argv[1], "1")) {
ExternalCurrentSource *ecs = new ExternalCurrentSource("v_s", 1, 0, Complex(0, 0));
comps.push_back(ecs);
comps.push_back(new LinearResistor("r_2", 1, 0, 1));
shmem = new ShmemInterface("/dpsim10", "/dpsim01", &conf);
shmem->registerCurrentSource(ecs, 0, 1);
shmem->registerExportedVoltage(1, 0, 0, 1);
} else {
std::cerr << "invalid test number" << std::endl;
std::exit(1);