Modelica

From OpenWetWare
Jump to navigationJump to search

Examples

The following code fragment shows a very simple example of a first order system ([math]\displaystyle{ \dot x = - c \cdot x, x(0)=10 }[/math]):

<syntaxhighlight lang=modelica> model FirstOrder

 parameter Real c=1 "Time constant";
 Real x (start=10) "An unknown";

equation

 der(x) = -c*x "A first order differential equation";

end FirstOrder; </syntaxhighlight>

Interesting things to note about this example are the 'parameter' qualifier, which indicates that a given variable is time-invariant and the 'der' operator, which represents (symbolically) the time derivative of a variable. Also worth noting are the documentation strings that can be associated with declarations and equations.

The main application area of Modelica is the modeling of physical systems. The most basic structuring concepts are shown at hand of simple examples from the electrical domain: