Commit a6fd90b9 authored by Georg Martin Reinke's avatar Georg Martin Reinke
Browse files

Merge branch 'development' of git.rwth-aachen.de:acs/core/simulation/dpsim into parallel


Former-commit-id: b728b877
parents 81e304de 6ee35d50
......@@ -25,7 +25,6 @@ CMakeFiles/
CMakeCache.txt
cmake_install.cmake
install_manifest.txt
Makefile
# Mac
__MACOSX
......
......@@ -12,9 +12,9 @@ before_script:
stages:
- prepare
- pre-build
- build
- test
- generate
- deploy
#- post-all
......@@ -26,7 +26,7 @@ docker:
- shell
build:linux:
stage: pre-build
stage: build
script:
- mkdir build
- cd build
......@@ -51,8 +51,8 @@ test:pytest:
tags:
- docker
build:docs:
stage: build
generate:docs:
stage: generate
script:
- make -C build docs
- make -C build docs_cxx
......@@ -66,8 +66,8 @@ build:docs:
tags:
- docker
build:packages:
stage: build
generate:packages:
stage: generate
script:
- make -C build package
only:
......@@ -88,6 +88,8 @@ build:docker:
- docker build -f Packaging/Docker/Dockerfile --build-arg DOCKER_TAG=${DOCKER_TAG} -t ${DOCKER_IMAGE}:${DOCKER_TAG} .
tags:
- shell
only:
- tags
deploy:docker:
stage: deploy
......@@ -107,7 +109,7 @@ deploy:docs:
- rsync ${RSYNC_OPTS} --delete build/Documentation/html/ ${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/doc/${CI_BUILD_REF_NAME}/sphinx
- rsync ${RSYNC_OPTS} --delete build/Documentation/Cxx/html/ ${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/doc/${CI_BUILD_REF_NAME}/doxygen
dependencies:
- build:docs
- generate:docs
only:
- tags
- master
......@@ -124,7 +126,7 @@ deploy:packages:
- rsync ${RSYNC_OPTS} build/*.tar.gz ${DEPLOY_USER}@${DEPLOY_HOST}:/var/www/dpsim/src
- ssh ${DEPLOY_USER}@${DEPLOY_HOST} createrepo /var/www/packages/redhat
dependencies:
- build:packages
- generate:packages
only:
- tags
tags:
......@@ -132,6 +134,18 @@ deploy:packages:
tags:
- shell
test:jupyter:
stage: test
script:
- make -C Examples/notebooks
image: ${DOCKER_IMAGE_DEV}:${DOCKER_TAG}
artifacts:
paths:
- Logs/
- Examples/notebooks/build
tags:
- docker
# We run the windows build at last as it takes ages to finish
#build:windows:
# stage: post-all
......
Subproject commit 3030d6552b07235e2dfea41f815d46c99797ae90
Subproject commit 1d35fd251bab2856e824fbbeb05a824bd8c96583
......@@ -7,20 +7,32 @@ DPsim
Docker
------
There is a Docker image available with all required dependecies:::
There is a Docker image available with all required dependencies::
$ cd dpsim
$ docker build -t rwthacs/dpsim -f Packaging/Docker/Dockerfile .
Alternatively, the image can be pulled from DockerHub like so::
$ docker pull rwthacs/dpsim
After running the container::
$ docker run -it -v $(pwd):/dpsim rwthacs/dpsim bash
$ cd DPsim
$ docker build -t dpsim .
$ docker run -tiv$(pwd):/dpsim dpsim bash
Setuptools
----------
Using setuptools is most likely the easiest way to install DPsim on your system.::
$ git clone --recursive git@git.rwth-aachen.de:acs/core/simulation/dpsim.git
$ git clone --recurse-submodules git@git.rwth-aachen.de:acs/core/simulation/dpsim.git
$ cd dpsim
# python3 ./setup.py install
$ python3 ./setup.py install
To build the Python package::
$ python3 setup.py bdist
CMake
-----
......@@ -28,7 +40,9 @@ CMake
Linux
*****
1. Make sure that the required dependecies are installed.
The most recent list of requirements can be found in the Dockerfiles.
1. Make sure that the required dependencies are installed.
Ubuntu/Debian:::
......@@ -46,23 +60,34 @@ Linux
Redhat/Fedora/CentOS:::
# wget https://villas.fein-aachen.org/packages/fein.repo -O /etc/yum.repos.d/fein.repo
# yum install \
gcc-c++ \
redhat-rpm-config \
rpmdevtools \
make cmake \
doxygen \
graphviz \
python3-pip \
python3-devel \
eigen3-devel \
villas-node-devel \
libcimpp16v29a
# wget https://packages.fein-aachen.org/redhat/fein.repo /etc/yum.repos.d/
# dnf -y install \
git clang gdb ccache \
redhat-rpm-config \
rpmdevtools \
make cmake ninja-build \
doxygen \
graphviz \
pandoc \
python3-pip \
pkg-config
# dnf -y install \
python3-devel \
eigen3-devel \
expat-devel \
graphviz-devel \
sundials-devel \
libcimpp16v29a \
libvillas-devel \
spdlog
# dnf -y debuginfo-install \
python3
2. Fetch sources::
$ git clone --recursive git@git.rwth-aachen.de:acs/core/simulation/dpsim.git
$ git clone --recurse-submodules git@git.rwth-aachen.de:acs/core/simulation/dpsim.git
$ cd dpsim
3. Generate a Makefile with CMake and use it to build the project::
......@@ -126,6 +151,50 @@ Python support for Windows
.. _DPsim: https://git.rwth-aachen.de/acs/core/simulation/dpsim
.. _`DPsim Libraries`: https://git.rwth-aachen.de/acs/core/simulation/dpsim-libraries
DPsim for Development
^^^^^^^^^^^^^^^^^^^^^
Docker
------
There is a Docker image available with all required dependencies::
$ cd dpsim
$ docker build -t rwthacs/dpsim-dev -f Packaging/Docker/Dockerfile.dev .
Alternatively, the image can be pulled from DockerHub like so::
$ docker pull rwthacs/dpsim-dev
To run Jupyter lab notebooks from the dpsim-validation repository, call::
$ git clone --recurse-submodules git@git.rwth-aachen.de:acs/core/simulation/dpsim-validation.git
$ cd dpsim-validation
$ docker run -it -p 8888:8888 -v $(pwd):/dpsim-validation --privileged rwthacs/dpsim-dev bash
For Windows, you might need to specify the current directory like this::
$ docker run -it -p 8888:8888 -v ${pwd}:/dpsim-validation --privileged rwthacs/dpsim-dev bash
The DPsim C++ and DPsim Python library can be build as follows::
$ cd dpsim-validation/dpsim
$ mkdir build
$ cd build
$ cmake ..
$ cmake --build . --target dpsim_python
To build everything run:::
$ cmake --build .
Finally, the Python package is added to the path and Jupyter started::
$ export PYTHONPATH=$(pwd)/Source/Python:$(pwd)/../Source/Python
$ cd /dpsim-validation
$ jupyter lab --ip="0.0.0.0" --allow-root
Documentation
^^^^^^^^^^^^^
......
C++ API
=======
.. doxygenindex::
......@@ -36,37 +36,21 @@
"metadata": {},
"outputs": [],
"source": [
"import asyncio\n",
"import time\n",
"\n",
"import asyncio\n",
"import dpsim\n",
"from dpsim.EventChannel import Event\n",
"\n",
"# Nodes\n",
"gnd = dpsim.dp.Node.GND()\n",
"n1 = dpsim.dp.Node(\"n1\")\n",
"\n",
"# Components\n",
"v1 = dpsim.dp.ph1.VoltageSource(\"v_1\", [gnd, n1], v_ref=345)\n",
"v1 = dpsim.dp.ph1.VoltageSource(\"v_1\", [gnd, n1], V_ref=complex(345,0))\n",
"\n",
"sys = dpsim.SystemTopology(50, [gnd, n1], [v1])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In Jupyter, we can start the internal event loop with the following cell magic"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"%gui asyncio"
]
},
{
"cell_type": "markdown",
"metadata": {},
......@@ -77,13 +61,41 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e0a97a8e4bbe40269faa30c15f172b3e",
"model_id": "3dceec375a504707af58740d50ff1727",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HTML(value='Simulation start is pending...')"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3df5be6a6e7b41578cdce7ecee4ff279",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"FloatProgress(value=0.0, max=3.0)"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "81cbaa74ec6d4266b3c0de1ea6b41d28",
"version_major": 2,
"version_minor": 0
},
......@@ -97,12 +109,12 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "877de605553e4c2ea3e99afdc9f95d49",
"model_id": "fdfd0ec092784c4692372afb59ce3beb",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"FloatProgress(value=0.0, max=50.0)"
"FloatProgress(value=0.0, max=6.0)"
]
},
"metadata": {},
......@@ -110,33 +122,58 @@
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ff2fdada64a943cb85a13ec09b850007",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"<Task pending coro=<Simulation.simulate() running at /Users/stv0g/workspace/rwth/acs/core/simulation/dpsim/Source/Python/dpsim/Simulation.py:121>>"
"HTML(value='Simulation start is pending...')"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ee3af88a489944f89fc943c7621de046",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"FloatProgress(value=0.0, max=9.0)"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Doing something different: 1\n",
"Doing something different: 2\n",
"Doing something different: 3\n",
"Doing something different: 4\n",
"Doing something different: 5\n"
]
}
],
"source": [
"def done(arg):\n",
" print(\"Simulation has finished\")\n",
"\n",
"# Get the default event loop\n",
"loop = asyncio.get_event_loop()\n",
"sims = []\n",
"for i in range(1, 4):\n",
" sim = dpsim.RealTimeSimulation(\"async_demo_%d\" % i, sys, timestep = i * 1e-3, duration=3*i, pbar=True)\n",
" sim.start()\n",
" \n",
" sims += [sim]\n",
"\n",
"sim = dpsim.Simulation(\"async_demo1\", sys, duration=50, loop=loop, pbar=True)\n",
"\n",
"asyncio.ensure_future(sim.simulate())"
"for i in range(1, 6):\n",
" print(\"Doing something different: %d\" % i)\n",
" await asyncio.sleep(1)\n",
" \n",
"_ = await asyncio.wait([ s.wait(Event.done) for s in sims ])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
......
This diff is collapsed.
989da8c9cb27726fdbfa460a973a58123597429f
\ No newline at end of file
......@@ -2,13 +2,13 @@
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3bf1009f7056419184ad56b50608bd37",
"model_id": "d280fc9be8b540a4957e2026e6e1ebea",
"version_major": 2,
"version_minor": 0
},
......
......@@ -25,7 +25,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
......@@ -39,13 +39,13 @@
"n4 = dpsim.dp.Node(\"n4\")\n",
"\n",
"# Components\n",
"v1 = dpsim.dp.ph1.VoltageSource(\"v_1\", [gnd, n1], v_ref=345)\n",
"r1 = dpsim.dp.ph1.Resistor(\"r1\", [n1, n2], resistance=5)\n",
"c1 = dpsim.dp.ph1.Capacitor(\"c_1\", [n2, gnd], capacitance=0.002)\n",
"rL1 = dpsim.dp.ph1.Resistor(\"r_load1\", [n2, n4], resistance=6.4)\n",
"l1 = dpsim.dp.ph1.Inductor(\"l_1\", [n4, n3], inductance=0.186)\n",
"c2 = dpsim.dp.ph1.Capacitor(\"c_2\", [n3, gnd], capacitance=0.002)\n",
"rL2 = dpsim.dp.ph1.Resistor(\"r_load2\", [n3, gnd], resistance=150)\n",
"v1 = dpsim.dp.ph1.VoltageSource(\"v_1\", [gnd, n1], V_ref=complex(345,0))\n",
"r1 = dpsim.dp.ph1.Resistor(\"r1\", [n1, n2], R=5)\n",
"c1 = dpsim.dp.ph1.Capacitor(\"c_1\", [n2, gnd], C=0.002)\n",
"rL1 = dpsim.dp.ph1.Resistor(\"r_load1\", [n2, n4], R=6.4)\n",
"l1 = dpsim.dp.ph1.Inductor(\"l_1\", [n4, n3], L=0.186)\n",
"c2 = dpsim.dp.ph1.Capacitor(\"c_2\", [n3, gnd], C=0.002)\n",
"rL2 = dpsim.dp.ph1.Resistor(\"r_load2\", [n3, gnd], R=150)\n",
"\n",
"sys = dpsim.SystemTopology(50, [gnd, n1, n2, n3, n4], [v1, r1, c1, rL1, l1, c2, rL2])\n",
"sim = dpsim.Simulation(\"progress_demo1\", sys, duration=20, timestep=0.0005)"
......@@ -53,13 +53,13 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "da5c5c0b5e044b0aab44179354d0c7d2",
"model_id": "dbd9b3be3cf74ab8b8821362f06c0350",
"version_major": 2,
"version_minor": 0
},
......@@ -73,7 +73,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "a16e104faf8f4ab289bbd5e21f3caf8d",
"model_id": "45df6c3ccd7b44088f608e2ad9eeb881",
"version_major": 2,
"version_minor": 0
},
......@@ -91,24 +91,11 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<Task pending coro=<Simulation.simulate() running at /Users/stv0g/workspace/rwth/acs/core/simulation/dpsim/Source/Python/dpsim/Simulation.py:120>>"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"import asyncio\n",
"%gui asyncio\n",
"asyncio.ensure_future(sim.simulate())"
"await sim.simulate()"
]
},
{
......@@ -127,13 +114,13 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "11403219249d49ff932abfa7b38fc5d5",
"model_id": "d75a33c30ed94e4391d125b3faf8bdde",
"version_major": 2,
"version_minor": 0
},
......@@ -147,7 +134,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ffe88e59125c483fb5419fbafc466c71",
"model_id": "7fc987a3d7a24779982f04a28064e3dd",
"version_major": 2,
"version_minor": 0
},
......@@ -158,20 +145,34 @@
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Doing something different: 1\n",
"Doing something different: 2\n",
"Doing something different: 3\n",
"Doing something different: 4\n",
"Doing something different: 5\n",
"Doing something different: 6\n",
"Doing something different: 7\n",
"Doing something different: 8\n",
"Doing something different: 9\n"
]
},
{
"data": {
"text/plain": [
"<Task pending coro=<dummy() running at <ipython-input-6-d4e77b028ebd>:4>>"
"[None, None]"
]
},
"execution_count": 6,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import asyncio\n",
"%gui asyncio\n",
"\n",
"async def dummy():\n",
" for i in range(1,10):\n",
......@@ -181,16 +182,8 @@
"sim2 = dpsim.Simulation(\"progress_demo2\", sys, duration=20, timestep=0.00005)\n",
"sim2.show_progressbar()\n",
"\n",
"asyncio.ensure_future(sim2.simulate())\n",
"asyncio.ensure_future(dummy())"
"await asyncio.gather(sim2.simulate(), dummy())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
......
......@@ -11,178 +11,101 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ccf4aa63a9814a33863c0fb2a05dc3aa",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"FloatSlider(value=0.0, description='phase [rad]', max=3.141592653589793, min=-3.141592653589793)"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3c74b1413efe40ce97a474d05e11e00b",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"FloatSlider(value=50.0, description='magnitude [V]')"
]
},