WOLFRAM SYSTEM MODELER
HelloWorldA simple model with a differential equation |
SystemModel["IntroductoryExamples.HelloWorld"]
There is a long tradition that the first example in any computer language is a trivial program printing the string "Hello World". Since Modelica, the language used in System Modeler, is an equation-based language, printing a string does not make much sense. Instead our Hello World Modelica program solves a trivial differential equation:
The variable x in this equation is a dynamic variable (here also a state variable) that can change value over time. The time derivative is the derivative of x, represented as der(x) in Modelica. The following code is used to implement this model:
model HelloWorld "A differential equation" Real x(start=1); equation der(x) = -x; end HelloWorld;
The picture below shows the variable x in a ten second simulation:
For a step by step tutorial see Hello World.