I am not too experienced with Modelica at the moment. This document will go over my knowledge of the Modelica language so far.
This document used various version 3.4 of the Modelica programming language.
Comments in Modelica are unique, but still easy to do.
// This is a single line comment in Modelica
// Modelica doesn't support multi-line comments as far as I know.
This example works with every version of Modelica, except for some versions of OpenModelica.
/!\ This example has not been tested yet, and may not work
Modelica supports the break
keyword.
break
To this day, I am still not entirely sure what the break
keyword does, but most languages support it.
/!\ This example has not been tested yet, and may not work
A hello world program in Modelica is a bit more complicated than a Python or Perl Hello World program, but it isn't very difficult either. It is not similar to any language I am currently familiar with.
model HelloWorld "Hello World";
end HelloWorld
This example works with every version of Modelica (as far as I know)
/!\ This example has not been tested yet, and may not work
I think this is how you implement real variables in Modelica
model isReal
Real x "Real variable"
Real y "Another Real variable"
end isReal
This example works with every version of Modelica (as far as I know)
/!\ This example has not been tested yet, and may not work
I think this is how you implement const. real variables in Modelica
model isConstReal
constant Real z = -2.0 "Constant variable is negative 2";
end isConstReal
This example works with every version of Modelica (as far as I know)
/!\ This example has not been tested yet, and may not work
I think this is how you implement real parameter variables in Modelica
model isRealParam
parameter Real x_start = 5.0 "The initial value of variable x";
end isConstReal
This example works with every version of Modelica (as far as I know)
/!\ This example has not been tested yet, and may not work
Modelica seems to support equations as a form of programming. This is how I make it out so far:
model equationModel
initial equation
// Define initial equation instructions
x = x_start;
equation
// Write the equations here...
der(x) = a*x;
end equationModel;
I think der
stands for deritative
but I am not sure.
This example works with every version of Modelica (as far as I know)
/!\ This example has not been tested yet, and may not work
Modelica supports Booleans, but not implicitely (not as a keyword)
model bcbool
b = true;
c = false;
end bcbool
This example works with every version of Modelica (as far as I know)
/!\ This example has not been tested yet, and may not work
The majority of my Modelica knowledge comes from self-experimentation, and Wikipedia. Most of the examples here were dissected from ModelicaInAction by GitHub user mbonvini full credits are listed here
The majority of dissections were done from this file:
model HelloWorld "The simplest differential equation ever"
Real x "The unknown variable";
constant Real a = -2.0 "Constant that characterizes the model";
parameter Real x_start = 5.0 "Initial value of the variable x";
initial equation
// Define initial conditions here...
x = x_start;
equation
// Write the equations here...
der(x) = a*x;
end HelloWorld;
-
Modelica is a curly bracket language, and it does use semicolons at the end of each line.;
-
Modelica uses the
*.mo
file extension for normal use. -
Modelica is a software modeling language
-
Modelica is a language recognized by GitHub
-
Modelica has been around since 1997
-
Modelica may be an open source language, but I am unsure
-
No other knowledge of Modelica at the moment.
File version: 1 (2022, Monday, April 18th at 5:28 pm PST)