Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Tutorial for algorithm developers

This tutorial turns an algorithm into an OEDISI component that can exchange data with a feeder simulator and with federates written by other groups. The algorithm we use is deliberately tiny, so the only new material is the plumbing. We build two components and run two simulations, all from the command line.

Who this is for

The reader is comfortable with Python and numerical modelling and can already write the algorithm they care about, but has probably not used HELICS or Pydantic, and is unsure what OEDISI adds on top of them.

HELICS moves bytes between processes and keeps their clocks aligned. OEDISI adds two things that a federation of separately developed algorithms needs. The first is an agreed set of typed messages, so a state estimator written at one lab can consume voltages from a feeder written at another. The second is a declarative wiring description, so a simulation is a JSON file rather than hand-edited config.

What we build

StageArtifactNew idea
1. Wrap your algorithmPowerComponent, publishing scaled real power on a scheduleHELICS time control, typed payloads
2. Describe and build itSimulation 1: PowerComponentRecordercomponent_definition.json, oedisi build
3. Add a subscriptionConstantCurrentComponent, power that responds to voltagesubscriptions, decoding typed inputs
4. Run the full simulationSimulation 2: PlayerConstantCurrentComponentRecorderdriving a component with recorded data

What this tutorial does not cover

Prerequisites

A Python 3.10+ environment with oedisi and helics installed:

pip install oedisi
oedisi --help

Stages 2–4 use the recorder and player federates from the shared component repository, so clone it and install their dependencies:

git clone https://github.com/openEDI/oedisi-components.git
cd oedisi-components && git submodule update --init --recursive && cd ..
export OEDISI_COMPONENTS="$(pwd)/oedisi-components/Components"
pip install pandas pyarrow

Working files

The finished code lives in docs/tutorial/example:

example/
├── power_component/
│   ├── component_definition.json
│   └── power_component.py
├── constant_current_component/
│   ├── component_definition.json
│   └── constant_current.py
├── components.json                # component type -> folder
├── system_power.json              # Simulation 1 wiring diagram
└── system_constant_current.json   # Simulation 2 wiring diagram
# and some additional test and data files

Next: Wrap your algorithm in a federate.