Code Monkey home page Code Monkey logo

marco's Introduction

MARCO - Modelica Advanced Research COmpiler

MARCO is a prototype compiler for the Modelica language. It is written in C++ and leverages both the LLVM and MLIR infrastructures.

Building MARCO

MARCO runs natively on Linux and macOS. At the moment, Windows is not supported. Directions to obtain the required dependencies and compile the project can be found here.

Using MARCO

After installation, two executables should appear in the bin directory inside the chosen installation path.

marco

The marco executable represents the main entry point for the compiler. The list of options can be obtained by passing the --help parameter.

As an example, consider the following model involving a scalar variable and its derivative:

model SimpleFirstOrder
    Real x(start = 0, fixed = true);
equation
    der(x) = 1 - x;
end SimpleFirstOrder;

The following command takes the source file, named SimpleFirstOrder.mo, and generate a binary file named simulation. The numerical integration method is chosen with the --solver flag, and in this case consists in the explicit Euler method. The <marco_runtime_lib_folder> argument has to be replaced with the path containing the installed MARCO runtime libraries (tipically, the lib folder inside the specified installation path).

marco SimpleFirstOrder.mo -o simulation --model=SimpleFirstOrder --solver=euler-forward -L <marco_runtime_lib_folder> -Wl,-rpath,<marco_runtime_lib_folder>

As the name suggests, the simulation binary file implements the simulation that computes the evolution of the system. Additional parameters can be also be provided when running the simulation. Their list can be obtained using the --help argument.

 ./simulation --time-step=0.5 --end-time=5                                                                                                                                                                  ✔ 
"time","x"
0.000000000,0.000000000
0.500000000,0.500000000
1.000000000,0.750000000
1.500000000,0.875000000
2.000000000,0.937500000
2.500000000,0.968750000
3.000000000,0.984375000
3.500000000,0.992187500
4.000000000,0.996093750
4.500000000,0.998046875
5.000000000,0.999023438

modelica-opt

The modelica-opt executable is intended to be used mainly for debugging purposes. It accepts only MLIR code and applies the user-requested pipeline of transformations, thus allowing the user to check their correct behaviour.

How to contribute

Contributions are welcome and encouraged, both in the form of pull requests and issues reporting bugs, errors, or possible improvements.

marco's People

Contributors

mscuttari avatar camillucci avatar drblallo avatar ennioquaglia avatar danielecattaneo avatar casella avatar fedetft avatar mattecarra avatar silseva avatar stefanoazzone avatar nikolicmarina 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.