Skip to content

Importers for the BaseModelica standard into the Julia ModelingToolkit ecosystem

License

Notifications You must be signed in to change notification settings

SciML/BaseModelica.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BaseModelica.jl

Join the chat at https://julialang.zulipchat.com #sciml-bridged Global Docs

codecov Build Status

ColPrac: Contributor's Guide on Collaborative Practices for Community Packages SciML Code Style

A parser for the Base Modelica format. Contains utilities to parse Base Modelica model files in to Julia objects, and to convert Base Modelica models to ModelingToolkit models.

So far only very simple Base Modelica models are supported. Only models with real parameters, real variables, and equations consisting of simple arithmetic equations and first order derivatives are supported. Support for the rest of the BaseModelica specification is planned to be added in the future.

Installation

Assuming that you already have Julia correctly installed, it suffices to import BaseModelica.jl in the standard way:

import Pkg;
Pkg.add("BaseModelica");

Example

A Base Modelica model is in the file ExampleFirstOrder.mo. Inside of the file is a Base Modelica model specifying a simple first order linear differential equation:

package 'FirstOrder'
  model 'FirstOrder'
    parameter Real 'x0' = 0 "Initial value for 'x'";
    Real 'x' "Real variable called 'x'";
  initial equation
    'x' = 'x0' "Set initial value of 'x' to 'x0'";
  equation
    der('x') = 1.0 - 'x'; 
  end 'FirstOrder';
end 'FirstOrder';

To parse the model in the file to ModelingToolkit, use the parse_basemodelica function:

using BaseModelica

parse_basemodelica("path/to/ExampleFirstOrder.mo")