Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ add_subdirectory(Experimental)

if(TARGET SUNDIALS::idas)
add_subdirectory(PhasorDynamics)
add_subdirectory(Network)
endif()

add_subdirectory(Consumer)
3 changes: 3 additions & 0 deletions examples/Network/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if(GRIDKIT_ENABLE_ZMQ)
add_subdirectory(ThreeBusCoSim)
endif()
18 changes: 18 additions & 0 deletions examples/Network/ThreeBusCoSim/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
gridkit_example_add_file(ThreeBusCoSimClient.case.json)
gridkit_example_add_file(ThreeBusCoSimServer.case.json)
gridkit_example_add_file(run_cosim.sh)

add_executable(CoSimClient ThreeBusCoSimClient.cpp)
target_link_libraries(
CoSimClient
PUBLIC GridKit::phasor_dynamics_systemmodel GridKit::solvers_dyn ZMQ)

add_executable(CoSimServer ThreeBusCoSimServer.cpp)
target_link_libraries(
CoSimServer
PUBLIC GridKit::phasor_dynamics_systemmodel GridKit::solvers_dyn ZMQ)

add_test(
NAME CoSimExample
COMMAND bash run_cosim.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
12 changes: 12 additions & 0 deletions examples/Network/ThreeBusCoSim/CoSim.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

namespace GridKit
{
namespace CoSim
{
using StatusT = int;

inline constexpr StatusT STEP = 1;
inline constexpr StatusT END = 0;
} // namespace CoSim
} // namespace GridKit
10 changes: 10 additions & 0 deletions examples/Network/ThreeBusCoSim/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Three-bus co-simulation example case with constant signal source

This example duplicates the behavior of the ThreeBusConstantSource example, but
with the `ConstantSignalSource` component removed and its behavior reproduced in
the app (external to the system model) with currents being received over zmq
from another app.

Note that this example code is temporary and meant simply as an initial step
towards implementing multi-instance co-simulation with GridKit. It will be
generalized into an application that can be used for other co-simulation cases.
169 changes: 169 additions & 0 deletions examples/Network/ThreeBusCoSim/ThreeBusCoSimClient.case.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
{
"header": {
"format_version": 0.2,
"format_revision": 0,
"case_name": "ThreeBusCoSimClient",
"case_description": "3-bus test case sending voltage and receiving current",
"case_comments": "None"
},
"params": {
"freq_base": 60.0,
"va_base": 100000000.0
},
"monitors": [
{
"file_name": "mon.csv",
"format":"csv"
}
],
"buses": [
{
"number": 1,
"class": "BusInfinite",
"name": "1",
"init": {
"Vr": 1.06,
"Vi": 0.0
},
"params": {"kv": 138.0},
"mon": [
"Vm"
]
},
{
"number": 2,
"class": "Bus",
"name": "2",
"init": {
"Vr": 1.0599558398065716,
"Vi": -0.009675621941024773
},
"params": {"kv": 138.0},
"mon": [
"Vm"
]
},
{
"number": 3,
"class": "Bus",
"name": "3",
"init": {
"Vr": 0.9610827543495831,
"Vi": -0.13122476630506485
},
"params": {"kv": 138.0},
"mon": [
"Vm"
]
}
],
"signals": [
{ "signal_id": 1, "name": "vr"},
{ "signal_id": 2, "name": "vi"},
{ "signal_id": 3, "name": "ir"},
{ "signal_id": 4, "name": "ii"}
],
"devices": [
{
"class": "Branch",
"ports": {
"bus1": 1,
"bus2": 2
},
"id": "BR_0_1",
"params": {
"R": 0.05,
"X": 0.21,
"G": 0.0,
"B": 0.1
}
},
{
"class": "Branch",
"ports": {
"bus1": 1,
"bus2": 3
},
"id": "BR_0_2",
"params": {
"R": 0.06,
"X": 0.15,
"G": 0.0,
"B": 0.12
}
},
{
"class": "Branch",
"ports": {
"bus1": 2,
"bus2": 3
},
"id": "BR_1_2",
"params": {
"R": 0.08,
"X": 0.27,
"G": 0.0,
"B": 0.45
}
},
{
"class": "LoadZ",
"ports": {
"bus": 3
},
"id": "load_2_0",
"params": {
"R": 0.4447197839297772,
"X": 0.20330047265361242
}
},
{
"class": "BusFault",
"ports": {
"bus": 3
},
"id": "bus_fault_2",
"params": {
"R": 0.0,
"X": 1e-5,
"state0": false
}
},
{
"class": "Genrou",
"ports": {
"bus": 2
},
"id": "genrou_2_1",
"params": {
"p0": 0.5,
"q0": -0.07588,
"H": 2.7,
"D": 0.0,
"Ra": 0.0,
"Tdop": 7.0,
"Tdopp": 0.04,
"Tqopp": 0.05,
"Tqop": 0.75,
"Xd": 1.9,
"Xdp": 0.17,
"Xdpp": 0.15,
"Xq": 0.4,
"Xqp": 0.35,
"Xqpp": 0.15,
"Xl": 0.14999,
"S10": 0.0,
"S12": 0.0
},
"mon": [
"speed"
]
},
{
"class": "BusToSignalAdapter",
"ports": {"bus":1, "vr":1, "vi":2, "ir":3, "ii":4},
"id": "adapt3",
"params": {}
}
]
}
Loading
Loading