3.2 Fundamental Principles for Mathematical Models Development
93
E =
m
2
dr
dt
2
+ k
r
2
2
Since dE/dt ≡ 0, differentiating the energy integral with respect to t, we arrive
at the expression
m
dr
dt
d
2 r
dt 2 + k
dr
dt
r =
dr
dt
m
d
2 r
dt 2 + kr
= 0
So, we get the same equation as from Newton’s law.
Hereinafter, all considered models are implemented in the Wolfram SystemModeler environment in Modelica language. Examples of the use of component modeling are discussed separately. To write code in Modelica, we write one second-order
equation in the form of a system of two first-order equations:
dx
dt
= v
m
dv
dt
= −kx
In this case, the program code looks like in Fig. 3.3.
Run a numerical experiment in the Simulation Center. Open the Experiment
Browser simultaneously with the charting window. The screen view is shown in
Fig. 3.4. Make sure from the analysis of the graphs that the total energy of the system
really remains constant (red line).
Fig. 3.3 Program code that allows, in addition to studying displacement and velocity, calculating
the potential, kinetic, and total energy of a harmonic oscillator
93
E =
m
2
dr
dt
2
+ k
r
2
2
Since dE/dt ≡ 0, differentiating the energy integral with respect to t, we arrive
at the expression
m
dr
dt
d
2 r
dt 2 + k
dr
dt
r =
dr
dt
m
d
2 r
dt 2 + kr
= 0
So, we get the same equation as from Newton’s law.
Hereinafter, all considered models are implemented in the Wolfram SystemModeler environment in Modelica language. Examples of the use of component modeling are discussed separately. To write code in Modelica, we write one second-order
equation in the form of a system of two first-order equations:
dx
dt
= v
m
dv
dt
= −kx
In this case, the program code looks like in Fig. 3.3.
Run a numerical experiment in the Simulation Center. Open the Experiment
Browser simultaneously with the charting window. The screen view is shown in
Fig. 3.4. Make sure from the analysis of the graphs that the total energy of the system
really remains constant (red line).
Fig. 3.3 Program code that allows, in addition to studying displacement and velocity, calculating
the potential, kinetic, and total energy of a harmonic oscillator
