Modelica

From Wikipedia, the free encyclopedia

Modelica is an object-oriented, domain-specific modeling language designed to allow convenient, component-oriented modeling of complex systems, e.g., systems containing mechanical, electrical, electronic, hydraulic, thermal, control, electric power or process-oriented subcomponents. The free Modelica language, free Modelica libraries and Modelica simulation tools are available, ready-to-use and have been utilized in demanding industrial applications, including hardware-in-the-loop simulations. The development and promotion of Modelica is organized by the non-profit Modelica Association.

While Modelica resembles object-oriented programming languages, such as C++ or Java, it differs in two important respects. First, Modelica is a modeling language rather than a true programming language. Modelica classes are not compiled, in the usual sense, but are translated into objects which are then exercised by a simulation engine. The simulation engine is not specified by the language, although certain required capabilities are outlined.

Second, although classes may contain algorithmic components similar to statements or blocks in programming languages, their primary content is a set of equations. In contrast to a typical assignment statement, such as

x := 2 + y;,

where the left-hand side of the statement is assigned a value calculated from the expression on the right-hand side, an equation may have expressions on both its right- and left-hand sides, for example,

x + y = 3 * z;.

Equations do not describe assignment but equality. In Modelica terms, equations have no pre-defined causality. The simulation engine may (and usually must) manipulate the equations symbolically to determine their order of execution and which components in the equation are inputs and which are outputs.

Modelica is one of a variety of hardware description languages, similar in nature to VHDL-AMS or Verilog-AMS (which are variants of VHDL and Verilog, respectively, that include additional functionality for describing continuous and mixed-signal behavior). Most applications of VHDL-AMS and Verilog-AMS involve electrical systems but Modelica is used in a broader range of domains (e.g. automotive powertrain applications).

Commercial front-ends for Modelica include Dymola, MathModelica System Designer and SimulationX. In addition, Dassault Systemes recently selected Modelica as a core technology for their CATIA product. The OpenModelica project goal is to create complete Modelica modeling, compilation and simulation environment based on free software distributed in source code form intended for research purposes.

[edit] Examples

The following code fragment shows a very simple example of a first order system:

model FirstOrder
  parameter Real c=1 "Time constant";
  Real x "An unknown";
equation
  der(x) = -c*x "A first order differential equation";
end FirstOrder;

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 worthing noting are the documentation strings that can be associated with declarations and equations.

Another simple example, but one that is a bit more interesting, can be seen in this model of a pendulum:

model SimplePendulum "Simple pendulum"
  parameter Modelica.SIunits.Position L = 2 "Pendulum length";
  constant Modelica.SIunits.Acceleration g = Modelica.Constants.g_n "Earth's gravitational constant";
  Modelica.SIunits.Angle theta "Pendulum angle";
  Modelica.SIunits.AngularVelocity omega "Pendulum angular velocity";
equation
  der(theta) = omega;
  der(omega) = -(g/L)*theta;
end SimplePendulum;

This example shows how to leverage the constant and type definitions found in the Modelica Standard Library. In addition to basic types and constants, the Modelica Standard Library contains a rich collection of basic components from many different engineering domains.

[edit] See also

[edit] Interesting Links

In other languages