This quickstart walks through setting up and running a two-federate co-simulation using Python and HELICS. The example models a simple interaction between a battery federate and a charger federate — the same scenario used throughout the HELICS user guide fundamental examples. By the end, you will have a working federation that exchanges data between two independent Python processes coordinated by a HELICS broker. The full example files are available in the HELICS-Examples repository on GitHub.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/GMLC-TDC/HELICS/llms.txt
Use this file to discover all available pages before exploring further.
Install HELICS
Install HELICS and the CLI runner using pip. The Verify the installation:You should see a version string such as
[cli] extra is recommended because it provides the helics run command for launching a complete federation from a single JSON file.3.x.x (20XX-XX-XX). If the command is not found, make sure your Python environment’s bin directory is on your PATH.Create federate configuration files
Each federate is configured with a JSON file that declares its name, timing parameters, core type, and the interfaces it will use to exchange data. Create two configuration files.BatteryConfig.json — the battery federate subscribes to voltage from the charger and publishes current back:ChargerConfig.json — the charger federate publishes voltage and subscribes to current from the battery:
The
key in a publication must match the key in the corresponding subscription on the other federate. The global: true flag means the key is used as-is rather than being prefixed with the federate name.Write the federate Python scripts
Create two Python scripts. Each script registers a federate using its JSON config, enters execution mode, runs a time loop, and finalizes when done.Battery.py — subscribes to voltage, publishes current:Charger.py — publishes voltage, subscribes to current:
Create a runner file and launch the co-simulation
The HELICS runner lets you launch the broker and all federates with a single command. Create a runner JSON file:runner.json:Setting
"broker": true tells the runner to automatically launch helics_broker -f 2 --loglevel=7 before starting the federates. The -f 2 flag tells the broker to expect exactly two federates.Launch the full co-simulation:Verify the output
When the co-simulation runs successfully, you will see log output from both federates showing the time loop progressing and values being exchanged:If either federate exits immediately with an error, check that:
- The broker was started before the federates (or the runner launched it automatically).
- The publication keys in one federate’s config exactly match the subscription keys in the other.
- The number of federates the broker expects (
-f 2) matches the number of federates that actually connect.
What just happened?
The co-simulation you ran demonstrates the core HELICS workflow:- A broker started and waited for two federates to connect.
- Each federate registered its publication and subscription interfaces.
- All federates entered execution mode together, synchronized by the broker.
- At each time step, the charger published a voltage and the battery published a current. HELICS routed each value to the federate that subscribed to it.
- Both federates advanced through time in lockstep until they reached the simulation end time.
- Each federate finalized and HELICS cleaned up.
Next steps
Federates
Learn how federates register interfaces, manage time, and exchange data in depth.
Configuration reference
Explore the full set of JSON configuration options for federates, timing, and logging.
Value federates
Understand publications, subscriptions, and data types for value-based communication.
HELICS apps
Learn about the Broker, Player, Recorder, and other built-in HELICS helper tools.