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

move villas plugin to separate repo


Signed-off-by: Markus Mirz's avatarMarkus Mirz <mmirz@eonerc.rwth-aachen.de>
parent 33f20bfd
......@@ -16,6 +16,7 @@ wheelhouse/
*.png
Examples/Notebooks/Grids/reference-results/
villas_sent_data.conf
third-party
# Folders
Libraries/
......
......@@ -205,7 +205,7 @@ add_subdirectory(docs)
if(BUILD_EXAMPLES)
add_subdirectory(Examples)
add_subdirectory(villas-dpsim/examples)
add_subdirectory(third-party/villas-dpsim/examples)
endif(BUILD_EXAMPLES)
if(WITH_PYBIND)
......
......@@ -79,12 +79,12 @@ endif()
if(WITH_SHMEM)
set(DPSIM_VILLAS_SOURCES
${CMAKE_SOURCE_DIR}/villas-dpsim/src/InterfaceShmem.cpp
${CMAKE_SOURCE_DIR}/villas-dpsim/src/PthreadPoolScheduler.cpp
${CMAKE_SOURCE_DIR}/third-party/villas-dpsim/src/InterfaceShmem.cpp
${CMAKE_SOURCE_DIR}/third-party/villas-dpsim/src/PthreadPoolScheduler.cpp
)
set(DPSIM_VILLAS_LIBRARIES ${VILLASNODE_LIBRARIES} pthread)
set(DPSIM_VILLAS_INCLUDE_DIRS ${VILLASNODE_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/villas-dpsim/include)
set(DPSIM_VILLAS_INCLUDE_DIRS ${VILLASNODE_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/third-party/villas-dpsim/include)
endif()
add_library(dpsim ${DPSIM_SOURCES} ${DPSIM_VILLAS_SOURCES})
......
nodes = {
broker1 = {
type = "mqtt"
format = "json"
host = "172.17.0.1"
in = {
subscribe = "/powerflow-dpsim"
}
out = {
publish = "/dpsim-powerflow"
}
}
dpsim1 = {
type = "shmem"
in = {
name = "/dpsim1-villas", # Name of shared memory segment for sending side
hooks = (
{
type = "stats"
}
),
signals = {
count = 30
type = "float"
}
},
out = {
name = "/villas-dpsim1" # Name of shared memory segment for receiving side
}
}
}
paths = (
{
in = "dpsim1"
out = "broker1"
hooks = (
{
type = "limit_rate"
rate = 50
}
)
}
)
\ No newline at end of file
#!/bin/bash
set -x
_stop() {
echo "Caught SIGTSTP signal!"
kill -TSTP ${CHILDS} 2>/dev/null
}
_cont() {
echo "Caught SIGCONT signal!"
kill -CONT ${CHILDS} 2>/dev/null
}
_term() {
echo "Caught SIGTERM signal!"
kill -TERM ${VN} ${CHILDS} 2>/dev/null
}
_kill() {
echo "Caught SIGKILL signal!"
kill -KILL ${VN} ${CHILDS} 2>/dev/null
}
trap _stop SIGTSTP
trap _cont SIGCONT
trap _term SIGTERM
trap _kill SIGKILL
CHILDS=""
# Start time
TIME=$(date -d "+10 seconds" +%Y%m%dT%H%M%S) #-Iseconds
echo "Start simulation at: $TIME"
# Simulation params
OPTS="--timestep 1 --duration $((5)) --system-freq 50 --start-at $TIME --solver-domain SP --solver-type NRP"
echo "Simulation params: $OPTS"
CPS_LOG_PREFIX="[Sys ] " \
build/villas-dpsim/examples/cxx/Shmem_CIGRE_MV_PowerFlowTest $OPTS & P1=$!
CHILDS=$P1
sleep 2
if true; then
VILLAS_LOG_PREFIX="[Pipe] " \
villas-pipe villas-dpsim/examples/config/shmem_CIGRE_MV_PF/Shmem_CIGRE_MV.conf dpsim1
else
VILLAS_LOG_PREFIX="[Node] " \
villas-node Configs/shmem_CIGRE_MV_PF/Shmem_CIGRE_MV.conf & VN=$!
fi
# Wait until all child processed finished
while (( $(ps --no-headers -o pid --ppid=$$ | wc -w) > 1 )); do
wait
done
#!/bin/bash
set -x
_stop() {
echo "Caught SIGTSTP signal!"
kill -TSTP ${CHILDS} 2>/dev/null
}
_cont() {
echo "Caught SIGCONT signal!"
kill -CONT ${CHILDS} 2>/dev/null
}
_term() {
echo "Caught SIGTERM signal!"
kill -TERM ${VN} ${CHILDS} 2>/dev/null
}
_kill() {
echo "Caught SIGKILL signal!"
kill -KILL ${VN} ${CHILDS} 2>/dev/null
}
trap _stop SIGTSTP
trap _cont SIGCONT
trap _term SIGTERM
trap _kill SIGKILL
CHILDS=""
# Start time
TIME=$(date -d "+10 seconds" +%Y%m%dT%H%M%S) #-Iseconds
echo "Start simulation at: $TIME"
# Simulation params
OPTS="--timestep 1 --duration $((300)) --system-freq 50 --start-at $TIME --solver-domain SP --solver-type NRP"
echo "Simulation params: $OPTS"
CPS_LOG_PREFIX="[Sys ] " \
build/Examples/Cxx/Shmem_CIGRE_MV_PowerFlowTest_LoadProfiles $OPTS & P1=$!
CHILDS=$P1
sleep 2
if false; then
VILLAS_LOG_PREFIX="[Pipe] " \
villas-pipe Configs/shmem_CIGRE_MV_PF/Shmem_CIGRE_MV.conf dpsim1
else
VILLAS_LOG_PREFIX="[Node] " \
villas-node Configs/shmem_CIGRE_MV_PF/Shmem_CIGRE_MV.conf & VN=$!
fi
# Wait until all child processed finished
while (( $(ps --no-headers -o pid --ppid=$$ | wc -w) > 1 )); do
wait
done
logging = {
level = "info";
}
nodes = {
# broker1 = {
# type = "mqtt",
# format = "json",
# username = "villas",
# password = "s3c0sim4!",
# host = "137.226.248.91",
# in = {
# subscribe = "villas-dpsim1",
# hooks = (
# { type = "stats" }
# )
# },
# out = {
# publish = "dpsim1-villas"
# }
# },
dpsim1 = {
type = "shmem",
in = {
name = "/dpsim1-villas", # Name of shared memory segment for sending side
hooks = (
{ type = "stats" }
),
signals = {
count = 64,
type = "float"
}
},
out = {
name = "/villas-dpsim1" # Name of shared memory segment for receiving side
},
queuelen = 1024, # Length of the queues
polling = true, # We can busy-wait or use pthread condition variables for synchronizations
},
profile = {
type = "file",
format = "csv",
uri = "/global/projects/dpsim/dpsim/Configs/shmem_WSCC-9bus/Load_profile_sum.csv",
in = {
rate = 10,
eof = "rewind"
hooks = (
{
type = "scale"
scale = 200000000.0
signal = 0
}
)
}
},
# oscilloscope = {
# type = "socket",
# layer = "udp",
# format = "protobuf",
# in = {
# address = "*:12000"
# }
# out = {
# address = "134.130.169.31:12000"
# }
# },
# lo = {
# type = "loopback"
# },
# web = {
# type = "websocket"
# }
ws_relay = {
type = "websocket"
destinations = [
"https://web.villas.fein-aachen.org//ws/relay/ws_dpsim1"
]
}
}
paths = (
{
in = "dpsim1",
out = "ws_relay",
hooks = (
{
type = "limit_rate",
rate = 50
}
)
},
{
in = [
"ws_relay.data[0]",
"profile.data[0]"
],
out = "dpsim1",
hooks = (
# {
# type = "limit_rate",
# rate = 50
# }
{
type = "print"
}
)
},
# {
# in = [ "lo.data[8]", "lo.data[10]" ],
# out = "oscilloscope",
# hooks = (
# { type = "scale", scale = 0.0008, offset = -180 },
# { type = "print" }
# )
# }
)
stats = 1;
logging = {
level = 4;
}
nodes = {
broker1 = {
type = "mqtt"
format = "protobuf",
username = "guest",
password = "guest",
host = "acs-os-villas",
port = 1883,
publish = "dpsim1-villas",
subscribe = "villas-dpsim1",
hooks = (
{ type = "stats" }
)
},
dpsim1 = {
type = "shmem"
in_name = "/dpsim1-villas", # Name of shared memory segment for receiving side
out_name = "/villas-dpsim1", # Name of shared memory segment for sending side
queuelen = 1024, # Length of the queues
polling = true, # We can busy-wait or use pthread condition variables for synchronizations
hooks = (
{ type = "stats" }
)
},
broker2 = {
type = "mqtt"
format = "protobuf",
username = "guest",
password = "guest",
host = "acs-os-villas",
port = 1883,
publish = "dpsim2-villas",
subscribe = "villas-dpsim2",
hooks = (
{ type = "stats" }
)
},
dpsim2 = {
type = "shmem"
in_name = "/dpsim2-villas", # Name of shared memory segment for receiving side
out_name = "/villas-dpsim2", # Name of shared memory segment for sending side
queuelen = 1024, # Length of the queues
polling = true, # We can busy-wait or use pthread condition variables for synchronizations
hooks = (
{ type = "stats" }
)
},
profile = {
type = "file",
format = "csv",
uri = "/projects/reserve/Load_profile_sum.csv"
rate = 1,
eof = "rewind"
},
oscilloscope = {
type = "socket",
layer = "udp"
format = "protobuf",
local = "*:12000"
remote = "134.130.169.31:12000"
},
lo = {
type = "loopback"
}
}
paths = (
{
in = "broker1",
out = "dpsim1",
hooks = (
{
type = "limit_rate",
rate = 50
}
)
},
{
in = "dpsim1",
out = [ "broker1", "lo"],
hooks = (
{
type = "limit_rate",
rate = 50
}
)
},
{
in = "broker2",
out = "dpsim2",
hooks = (
{
type = "limit_rate",
rate = 50
}
)
},
{
in = "dpsim2",
out = "broker2",
hooks = (
{
type = "limit_rate",
rate = 50
}
)
},
{
in = [ "lo.data[8]", "lo.data[10]" ],
out = "oscilloscope",
hooks = (
{ type = "scale", scale = 0.0008, offset = -180 },
{ type = "print" }
)
}
)
#!/bin/bash
set -x
_stop() {
echo "Caught SIGTSTP signal!"
kill -TSTP ${CHILDS} 2>/dev/null
}
_cont() {
echo "Caught SIGCONT signal!"
kill -CONT ${CHILDS} 2>/dev/null
}
_term() {
echo "Caught SIGTERM signal!"
kill -TERM ${VN} ${CHILDS} 2>/dev/null
}
_kill() {
echo "Caught SIGKILL signal!"
kill -KILL ${VN} ${CHILDS} 2>/dev/null
}
trap _stop SIGTSTP
trap _cont SIGCONT
trap _term SIGTERM
trap _kill SIGKILL
CHILDS=""
# Start time
TIME=$(date -d "+20 seconds" +%Y%m%dT%H%M%S) #-Iseconds
echo "Start simulation at: $TIME"
# Simulation params
OPTS="--timestep 0.001 --duration 3600 --start-in 5 Examples/CIM/WSCC-09_RX/*.xml"
echo "Simulation params: $OPTS"
CPS_LOG_PREFIX="[Sys ] " \
build/Examples/Cxx/Shmem_WSCC-9bus_Ctrl $OPTS & P1=$!
CHILDS=$P1
sleep 2
if false; then
VILLAS_LOG_PREFIX="[Pipe] " \
villas-pipe Configs/shmem_WSCC-9bus/Shmem_WSCC-9bus_Ctrl.conf dpsim1
else
VILLAS_LOG_PREFIX="[Node] " \
villas-node Configs/shmem_WSCC-9bus/Shmem_WSCC-9bus_Ctrl.conf & VN=$!
fi
# Wait until all child processed finished
while (( $(ps --no-headers -o pid --ppid=$$ | wc -w) > 1 )); do
wait
done
#!/bin/bash
set -x
# Start time
export TZ=UTC
TIME=$(date -d "+10 seconds" +%Y%m%dT%H%M%S) #-Iseconds
echo "Start simulation at: $TIME"
# Simulation params
OPTS="--timestep 0.001 --duration $((24*60*60)) --system-freq 60 --start-at $TIME"
echo "Simualtion params: $OPTS"
CPS_LOG_PREFIX="[Sys ] " \
build/Examples/Cxx/Shmem_WSCC-9bus_CtrlDist $OPTS --scenario 0 & P1=$!
sleep 2
#(sleep 10; echo "1 50e6"; sleep 10000) | \
CPS_LOG_PREFIX="[Load] " \
build/Examples/Cxx/Shmem_WSCC-9bus_CtrlDist $OPTS --scenario 1 & P2=$!
sleep 2
if false; then
VILLAS_LOG_PREFIX="[Pipe] " \
villas-pipe Configs/villas-shmem.conf shmem
else
VILLAS_LOG_PREFIX="[Node] " \
villas-node /projects/reserve/Shmem_WSCC-9bus_CtrlDist.conf
fi
for job in $P1 $P2; do
wait $job || exit 1
done
#!/bin/env python3
import dpsim
import villas.node
import re
from dpsim.Event import Event
import glob
import datetime
import logging
l = logging.getLogger()
l.setLevel(logging.DEBUG)
l.debug('test')
name = 'WSCC-9bus_dyn_switch'
config = './villas-node.conf'
files = glob.glob('./Examples/CIM/WSCC-09_RX_Dyn/*.xml')
# Load system toplogy from CIM files
system = dpsim.load_cim(name, files, frequency=60, log_level=0)
## Switch
sw = dpsim.dp.ph1.Switch("Switch")