Ecos
Ecos: An accessible and intuitive co-simulation framework - Published in JOSS (2025)
Science Score: 95.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 4 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: joss.theoj.org -
✓Committers with academic emails
1 of 3 committers (33.3%) from academic institutions -
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords
Scientific Fields
Repository
A simple, fast and easy to use co-simulation engine.
Basic Info
Statistics
- Stars: 12
- Watchers: 1
- Forks: 3
- Open Issues: 2
- Releases: 12
Topics
Metadata Files
README.md
Ecos
Ecos (Easy co-simulation) is a fast, efficient and very easy to use co-simulation engine written in modern C++.
Ecos provides the following features:
- FMI for Co-simulation version 1.0 & 2.0.
- Partial support for FMI 3.0.
- SSP version 1.0.
- Optional per process/remote model execution.
- Post-simulation plotting using matplotlib.
- Command-line-interface (CLI).
- Simplified Python and C interface.
- Minimal (and automatically resolved) build dependencies.
Who is this for?
Ecos is a framework for performing FMI-based co-simulation. Several such libraries/tools exist and cover much of the same ground.
However, the value-proposition of Ecos is the "ease-of-deployment", while still being efficient. The library is written in Object-Oriented C++,
supports all versions of FMI for Co-simulation and provides a pypi hosted Python interface.
The framework can be used either in C++, C, Python or through a CLI.
Moreover, it provides seamless integration with plotting (for quick prototyping) and per-process execution of model instances (remoting).
The project is maintained as a mono-repo with small and few dependencies, making building from a source a breeze.
This is especially valuable in an educational setting, where emphasis should be on how to use and not how to build.
Building
Ecos bundles all required dependencies. Just build.
``` //windows cmake . -A x64 -B build -DECOSBUILDEXAMPLES=ON -DECOSBUILDTESTS=ON -DCMAKEBUILDTYPE=Release cmake --build build --config Release
//linux cmake . -B build -DECOSBUILDEXAMPLES=ON -DECOSBUILDTESTS=ON -DCMAKEBUILDTYPE=Release cmake --build build ```
Consuming C/C++ library
Ecos is compatible with CMake FetchContent:
```cmake include(FetchContent) set(ECOSBUILDCLI OFF) # Set to ON for building ecos command-line-interface set(ECOSBUILDCLIB OFF) # Set to ON for building C API set(ECOSWITHPROXYFMU OFF) # Set to ON for remoting FetchContentDeclare( ecos GITREPOSITORY https://github.com/Ecos-platform/ecos.git GITTAG gittagorcommitid ) FetchContentMakeAvailable(ecos)
addexecutable(ecosstandalone main.cpp) targetlinklibraries(ecos_standalone PRIVATE libecos) # or libecosc for C API ```
Features
Per process / remote execution
Ecos enables models to run on separate processes, possibly on another PC.
Simply prepend proxyfmu://localhost?file= to the path of the fmu(s) you load.
When targeting an external proxyfmu instance, replace localhost with host:port.
For each FMU instance created when using proxyfmu a new process is created.
When targeting localhost, Unix Domain Sockets are used, while TCP/IP is used when targeting
a remote process started with proxufmu boot --port <portNumber>.
To successfully make use of proxyfmu, make sure the executable built by the project
is located in the working directory of your application or added to PATH
when targeting localhost. Using the Python API, however, this should work out-of-the-box.
proxyfmu is implemented using simplesocket in conjunction with flexbuffers.
Ecos may be built without this feature (less dependencies, faster build) by passing
-DECOS_WITH_PROXYFMU=OFFto CMake.
Scenario configuration
Scenarios in Ecos are actions to be performed during the simulation.
Scenarios are most useful in a CLI context, and can be specified using the --scenarioConfig option.
The structure of a scenario file follows the XML schema defined in resources/scema/ScenarioConfig.xsd.
Loading a scenario through the API is demonstrated in here
CSV logging
Ecos supports CSV logging of simulation data. Which variables to log, and how often, is configurable.
In a CLI context, this is done using the --csvConfig option with a path to an XML configuration file adhering to
the CsvConfig.xsd schema located in resources/schema/. The API also provides the means to configure this programmatically.
See /examples for various demonstrations.
Plotting
Ecos supports out-of-the-box plotting of simulation data using matplotlib in both C++ and Python.
Time- and XY series plots can be configured inline or using the ChartConfig.xsd XML schema located in resources/schema/.
See /examples for demonstrations.
C++ Example
```cpp using namespace ecos;
int main() {
simulation_structure ss;
// add models
ss.add_model("chassis", "chassis.fmu");
ss.add_model("ground", "ground.fmu");
ss.add_model("wheel", "wheel.fmu");
//make connections
ss.make_connection<double>("chassis::p.e", "wheel::p1.e");
ss.make_connection<double>("wheel::p1.f", "chassis::p.f");
ss.make_connection<double>("wheel::p.e", "ground::p.e");
ss.make_connection<double>("ground::p.f", "wheel::p.f");
// setup initialValues
std::map<variable_identifier, scalar_value> map;
map["chassis::C.mChassis"] = 4000.0;
ss.add_parameter_set("initialValues", map);
double stepSize = 1.0 / 100; // 100 Hz
auto sim = ss.load(std::make_unique<fixed_step_algorithm>(stepSize));
// setup csv logging
csv_config config;
config.register_variable("chassis::*"); // logs all chassis variables
auto csvWriter = std::make_unique<csv_writer>("results.csv", config);
const auto outputPath = csvWriter->output_path();
sim->add_listener("writer", std::move(csvWriter));
// apply named set of parameters
sim->init("initialValues");
sim->step_until(10);
sim->terminate();
plot_csv(outputPath, "ChartConfig.xml"); // plot results
} ```
C++ SSP example
```cpp using namespace ecos;
int main() {
auto ss = load_ssp("quarter-truck.ssp"); // accepts .ssp file or extracted folder
double stepSize = 1.0 / 100; // 100 Hz
auto sim = ss->load(std::make_unique<fixed_step_algorithm>(stepSize));
// ... see example above for further usage
} ```
Command line interface (CLI)
Options:
-h,--help Print this help message and exit
-v,--version Display program version information and exit
-i,--interactive Make execution interactive.
--noCsv Disable CSV logging.
--noParallel Run single-threaded.
--path REQUIRED Location of the fmu/ssp to simulate.
--stopTime [1] Simulation end.
--startTime [0] Simulation start.
--stepSize REQUIRED Simulation stepSize.
--rtf [-1] Target real time factor (non-positive number -> inf).
--csvConfig Path to CSV configuration.
--chartConfig Path to chart configuration.
--scenarioConfig Path to scenario configuration.
-l,--logLevel ENUM:value in {trace->0,debug->1,info->2,warn->3,err->4,off->5} OR {0,1,2,3,4,5}
Specify log level.
Python interface
pip install ecospy
Local pip installation
To install the python package locally:
- Clone the project
- Run CMake installation (see Building)
- Run
pip install .
Note: You will need
wheelin addition to the compile-time requirements listed further below.
If using an old pip version, append--use-feature=in-tree-buildif you get an error about../version.txt
Python Example
```python print(f"Ecoslib version: {EcosLib.version()}")
EcosLib.setloglevel("debug")
fmupath = "BouncingBall.fmu" resultfile = f"results/bouncing_ball.csv"
with EcosSimulationStructure() as ss: ss.addmodel("ball", fmupath)
with(EcosSimulation(structure=ss, step_size=1/100)) as sim:
sim.add_csv_writer(result_file)
sim.init()
sim.step_until(10)
sim.terminate()
config = TimeSeriesConfig( title="BouncingBall", ylabel="Height[m]", identifiers=["ball::h"]) plotter = Plotter(resultfile, config) plotter.show() ```
Colab Notebook Example (pythonfmu + ecospy)
Compile-time requirements
- Windows (10 >=) or Ubuntu (20.04 >=)
- C++20 compiler (MSVC >= 17 || gcc11 >=)
- CMake >= 3.19
Additional Linux requirements
sudo apt install libtbb-dev unzip
Run-time requirements
- Python3 (optional, required for plotting)
- matplotlib
- pandas
Acknowledgments
This software is made possible thanks to the following third-party projects: * CLI11 * flatbuffers * pugixml * spdlog * fmi4c * subprocess.h * Catch2
Want to build FMUs in C++? Check out FMU4cpp Want to build FMUs in Python? Check out PythonFMU
Owner
- Name: Ecos-platform
- Login: Ecos-platform
- Kind: organization
- Location: Norway
- Repositories: 9
- Profile: https://github.com/Ecos-platform
JOSS Publication
Ecos: An accessible and intuitive co-simulation framework
Authors
Tags
Functional Mockup Interface Co-simulation Simulation and Modelling C/C++GitHub Events
Total
- Create event: 53
- Issues event: 29
- Release event: 13
- Watch event: 7
- Delete event: 42
- Issue comment event: 43
- Push event: 232
- Pull request event: 62
- Fork event: 2
Last Year
- Create event: 53
- Issues event: 29
- Release event: 13
- Watch event: 7
- Delete event: 42
- Issue comment event: 43
- Push event: 232
- Pull request event: 62
- Fork event: 2
Committers
Last synced: over 1 year ago
Top Committers
| Name | Commits | |
|---|---|---|
| Lars Ivar Hatledal | l****l@g****m | 174 |
| Lars Ivar Hatledal | l****t@n****o | 57 |
| Lars Ivar Hatledal | l****t@h****o | 14 |
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 22
- Total pull requests: 55
- Average time to close issues: 3 days
- Average time to close pull requests: about 7 hours
- Total issue authors: 10
- Total pull request authors: 1
- Average comments per issue: 2.59
- Average comments per pull request: 0.02
- Merged pull requests: 54
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 20
- Pull requests: 37
- Average time to close issues: 3 days
- Average time to close pull requests: about 10 hours
- Issue authors: 8
- Pull request authors: 1
- Average comments per issue: 2.65
- Average comments per pull request: 0.03
- Merged pull requests: 36
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- Tjoppen (6)
- ElektrikAkar (4)
- markaren (4)
- chrbertsch (1)
- DYHrich (1)
- levanthanh3005 (1)
- okugu (1)
- freol35241 (1)
- Terrency (1)
- elac-safran (1)
Pull Request Authors
- markaren (83)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 57 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 10
- Total maintainers: 1
pypi.org: ecospy
A simple, fast and easy to use co-simulation engine.
- Homepage: https://github.com/Ecos-platform/ecos
- Documentation: https://ecospy.readthedocs.io/
- License: MIT
-
Latest release: 0.6.2
published 7 months ago
Rankings
Maintainers (1)
Dependencies
- matplotlib *
- pandas *
- actions/checkout v2 composite
- actions/upload-artifact v2 composite
- cli11 *
- fmilib *
- libzip *
- pugixml *
- spdlog *
- thrift *
