 
A Modelica compiler written in modern C++ with Python bindings.
Features
- Parsing using https://github.com/antlr/antlr4/blob/master/doc/cpp-target.md "ANTLR4 C++ Runtime".
- Listener based generators decoupled from the AST, easy to compile Modelica to new targets.
- Listener based compiler
- C++17 used throughout, minimal copying, low memory footprint, and fast.
- Python bindings planned.
- Data format for simulations HDF5
Road Map
- [x] Parsing with ANTLR.
- [x] Lisp listener for AST string output.
- [ ] Bouncing ball end-to-end prototype from Modelica -> Casadi. Simulation in Casadi or using sundials directly.
- [ ] Flesh out missing language element.
- [ ] NuSMV output for state machines to support model checking.
- [ ] Python bindings.
Documentation
Command Line Interface
This command line just prints the LISP generator output currently, but it will be extended to support various generators.
```bash $ ./cymoca -h Cymoca Modelica Compiler 0.0.9-60-g9dd7a23 usage: cymoca [options] model.mo Options:
Generic options: -h [ –help ] print help message
$ ./cymoca ./test/models/BouncingBall.mo (class(dict of comp( v(Real))(parameter g(Real))( x(Real)) )(list of eq(=(der((x)))(v))(=(der((v)))(-(g)))(when(eq block(<(x)(0))(list of eq(=(v)(-(v)))))))) ```
Install
Binary
- Binaries are provided here: releases.
- The cymoca-...-Linux.zip is statically linked so it should work on all linux variants and Mac out of the box given the following dependencies are met:
- Dependencies
Build from Source
- You can build cymoca from source using cmake. You will need the following dependencies:
- Dependencies
- Antlr4 C++ runtime:
- Casadi, optional, requires system installed headers and libraries, enabled with -DWITH_CASADI=ON
- Ubuntu 18.04: deb
- Build from Source: see script
- Gtest, optional, used for testing
- A quick example of building with cmake: ```bash git clone https://github.com/jgoppert/cymoca cd cymoca mkdir -p build cd build && cmake -DWITH_TEST=ON .. make -j4 ctest cpack -G DEB sudo dpkg -i cymoca*.deb cymoca my_model.mo ```
Contributing
- Coding standard: Google
- Changes:
- Use m_name instead of name_ for class members to make leading autocomplete nicer to work with.
- Prefer getName() to name() for getter so that all attributes are also easy to acces with get<TAB>
- Prefer setName() to set_name() for setter
- IDE Recommendations
- Vim - reliable, fast
- QtCreator - nice debugging and analysis
- VSCode - nice gui, not as quick with analysis tips, antlr support
- CLion - confused by some macros, but useful for overriding functions, antlr support
- If you want to get started, feel free to make a PR. The easiest place to start is with a new generator:
License
- BSD-3-clause, open source and free for commercial use. [LICENSE](LICENSE)