2.4 Creating a Dynamic Model in Wolfram SystemModeler
59
From now on, the Diff Eq component will be represented by this icon wherever
it is used.
2.5 Basics of Component Modeling in WSM
In the third chapter, we will build mechanical models based on the differential equations describing this physical process, without resorting to standard libraries and the
use of ready-made components. However, it is useful to understand how they can be
used to significantly complicate the task.
In the previous section, we learned the basics of programming your own models
or components in the Modelica language.
Let us now consider the process of creating a model using ready-made components
from existing libraries. Let us find out how these two approaches are interconnected
and how, having mastered the skills of writing code in the Modelica language, one
can verify the correctness of the constructed component models.
Consider building a model that describes a simple one-dimensional spring system
with damping. In the future, copying this model or its elements, you can create much
more complex models of oscillatory systems. Perform modeling in two ways—by
writing code in the Modelica language and using ready-made components from the
built-in library.
2.5.1 Creating a Spring Pendulum Model
Let us write the equation of oscillations of the spring pendulum in the presence of
medium resistance. This is a second-order differential equation:
m
d
2 x
dt 2 + kx + γ
dx
dt
= 0
This equation can be solved analytically. A detailed theoretical analysis of this
model will be given in the third chapter.
First, we write the code in the Modelica language without using ready-made
components. Let’s prepare this differential equation of the second order to solve
using Wolfram SystemModeler package. To do this, we reduce it to a system of two
first-order equations.
dx
dt
= v
m
dv
dt
= −kx − γ v
59
From now on, the Diff Eq component will be represented by this icon wherever
it is used.
2.5 Basics of Component Modeling in WSM
In the third chapter, we will build mechanical models based on the differential equations describing this physical process, without resorting to standard libraries and the
use of ready-made components. However, it is useful to understand how they can be
used to significantly complicate the task.
In the previous section, we learned the basics of programming your own models
or components in the Modelica language.
Let us now consider the process of creating a model using ready-made components
from existing libraries. Let us find out how these two approaches are interconnected
and how, having mastered the skills of writing code in the Modelica language, one
can verify the correctness of the constructed component models.
Consider building a model that describes a simple one-dimensional spring system
with damping. In the future, copying this model or its elements, you can create much
more complex models of oscillatory systems. Perform modeling in two ways—by
writing code in the Modelica language and using ready-made components from the
built-in library.
2.5.1 Creating a Spring Pendulum Model
Let us write the equation of oscillations of the spring pendulum in the presence of
medium resistance. This is a second-order differential equation:
m
d
2 x
dt 2 + kx + γ
dx
dt
= 0
This equation can be solved analytically. A detailed theoretical analysis of this
model will be given in the third chapter.
First, we write the code in the Modelica language without using ready-made
components. Let’s prepare this differential equation of the second order to solve
using Wolfram SystemModeler package. To do this, we reduce it to a system of two
first-order equations.
dx
dt
= v
m
dv
dt
= −kx − γ v
