JKRT / OMBackend.jl

Preliminary backend for the OpenModelica.jl Modelica Compiler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Github Action CI License: OSMC-PL

About OMBackend.jl

OMBackend.jl is one component of the new OpenModelica Compiler infrastructure for Julia. It is able to transform a given Hybrid DAE and simulate it using DifferentialEquations.jl.

Dependencies

  • Julia 1.7
  • ExportAll.jl
  • MetaModelica.jl
  • Setfield.jl
  • OMCompiler.jl
  • DifferentialEquations.jl

And more..

Installation

Install dependencies with:

julia> import Pkg
julia> Pkg.build("OMBackend")

or:

julia> include("deps/build.jl")

Then precompile with:

(v1.7) pkg> activate .
julia> using OMBackend

Running tests

In the folder containing OMBackend:

julia> activate .

Then run:

(OMBackend) pkg> test

As an alternative assuming you have activated OMBackend:

julia> include("test/runtests.jl")

Example use

Assuming you use DAE.jl and a suitable frontend you can use OMBackend to simulate your Modelica models.

model BouncingBallReals
  parameter Real e=0.7;
  parameter Real g=9.81;
  Real h(start=1);
  Real v;
equation 
  der(h) = v;
  der(v) = -g;  
  when h <= 0 then
    reinit(v, -e*pre(v));
  end when;
end BouncingBallReals;

Simply pass the given DAE or FlatModelica to the function translate.

julia> OMBackend.translate(BouncingBallReals)
julia> OMBackend.simulate("BouncingBallReals", tspan = (0.0, 2.5))

image

About

Preliminary backend for the OpenModelica.jl Modelica Compiler

License:Other


Languages

Language:Julia 100.0%