GithubHelp home page GithubHelp logo

jaeandersson / cymoca Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jgoppert/cymoca

0.0 0.0 0.0 2.9 MB

A Modelica compiler written in modern C++ with Python bindings.

License: BSD 3-Clause "New" or "Revised" License

Shell 2.60% C++ 66.79% C 0.29% ANTLR 12.47% Modelica 0.24% CMake 17.61%

cymoca's Introduction

cymoca

Build Status Coverage Status

A Modelica compiler written in modern C++ with Python bindings.

Features

  • Parsing using ANTLR4 C++ Runtime.
    • drawing
  • 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.

Road Map

  • Parsing with ANTLR.
  • 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.

$ ./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
    • glibc 2.2.5

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
      • Build from Source: see script
  • A quick example of building with cmake:

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
      • 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

cymoca's People

Contributors

jaeandersson avatar jgoppert avatar

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.