GithubHelp home page GithubHelp logo

ecos-platform / ecos Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 17.92 MB

A simple, fast and easy to use co-simulation engine

License: MIT License

CMake 5.36% Python 5.91% C++ 85.29% C 1.00% Thrift 1.24% Kotlin 0.96% Dockerfile 0.24%
co-simulation cpp17 fmi-standard ssp-standard

ecos's Introduction

Ecos

Ecos is a co-simulation engine.

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
  • SSP version 1.0
  • Optional sandboxed/remote model execution
  • Post-simulation plotting using matplotlib
  • Command-line-interface (CLI)
  • Simplified Python and C interface

Building

Ecos relies on vcpkg to handle dependencies.

Once installed, please add the entry VCPKG_ROOT to PATH pointing your /vcpkg folder. Alternatively, call CMake with -DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake.

Example:

//windows
cmake . -A x64 -B build -DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake" -DECOS_BUILD_EXAMPLES=ON -DECOS_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release

//linux
cmake . -B build -DCMAKE_TOOLCHAIN_FILE="/home/user/vcpkg/scripts/buildsystems/vcpkg.cmake" -DECOS_BUILD_EXAMPLES=ON -DECOS_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build

Notes on static linking and vcpkg (windows)

In order to produce executables with no DLL dependencies on windows, you need to call CMake with -DVCPKG_TARGET_TRIPLET=x64-windows-static-md

Example

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);
    
    auto sim = ss.load(std::make_unique<fixed_step_algorithm>(1.0 / 100), "initialValues");
    
    sim->init();
    sim->step_until(10);
    
    sim->terminate();
}

SSP example

using namespace ecos;

int main() {
    
    auto ss = load_ssp("quarter-truck.ssp");

    // use a fixed-step algorithm and apply parameterset from SSP file
    auto sim = ss->load(std::make_unique<fixed_step_algorithm>(1.0 / 100), "initialValues");
    
    // setup csv logging
    csv_config config;
    config.register_variable("chassis::zChassis"); // logs a single variable
    
    auto csvWriter = std::make_unique<csv_writer>("data.csv", config);
    csvWriter->enable_plotting("ChartConfig.xml"); // enable post-simulation plotting
    sim->add_listener(std::move(csvWriter));
    
    sim->init();
    sim->step_until(10);
    
    sim->terminate();
}

Command line interface

Options:
  -h [ --help ]                 Print this help message and quits.
  -v [ --version ]              Print program version.
  -i [ --interactive ]          Make execution interactive.
  -l [ --logLevel ] arg (=info) Specify log level [trace,debug,info,warn,err,of
                                f].
  --path arg                    Location of the fmu/ssp to simulate.
  --stopTime arg (=1)           Simulation end.
  --startTime arg (=0)          Simulation start.
  --stepSize arg                Simulation stepSize.
  --rtf arg (=-1)               Target real time factor (non-positive number ->
                                inf).
  --noLog                       Disable CSV logging.
  --noParallel                  Run single-threaded.
  --logConfig arg               Path to logging configuration.
  --chartConfig arg             Path to chart configuration.
  --scenarioConfig arg          Path to scenario configuration.

Python interface

To use the python interface, simply clone the project and run:

pip install ./ecospy

See here for an example.

Note: if using an old pip version, append --use-feature=in-tree-build if you get an error about ../version.txt


Compile-time requirements

  • Windows (10 >=) or Ubuntu (20.04 >=)
  • C++17 compiler (MSVC >= 16 || gcc9 >=)
  • CMake >= 3.17
  • Vcpkg

Additional Linux requirements

sudo apt install libtbb-dev

Run-time requirements

  • Python3 (required for plotting)
    • matplotlib
    • pandas

Want to build FMUs in C++? Check out FMU4cpp
Want to build FMUs in Kotlin/Java? Check out FMU4j
Want to build FMUs in Python? Check out PythonFMU
SSP generation made easy? Check out SSPgen

ecos's People

Contributors

markaren avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

ecos's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.