84
2 Description of the Wolfram SystemModeler
end when.
The reinit function has two arguments. The first argument is a continuous variable
whose value we want to override, and the second is an expression of type Real. When
the reinit function is called, the expression of the second argument is evaluated, and
the resulting value is assigned to the variable that is the first argument.
The position of the ball during the onset of a discrete event will be very close
to zero, but, due to computational errors, may be inaccurate. We must exclude the
possibility of “failing” below the floor level. To do this, add another discrete action:
When h ≤ 0, we set h a = 0.
Now, the description of discrete actions in the program will look like this:
when h <= 0, then;
reinit (v, -0.8 · v);
reinit (h, 0);
end when.
So, this model has two continuous equations and one discrete event, and when
triggered, two actions are performed.
Run WSM and build the model according to the rules described above. It will
display like the one shown in Fig. 2.72.
Let’s experiment in 20 s to make sure that the ball correctly stops bouncing and
goes to rest on the floor, as shown in Fig. 2.73.
Let’s see how the speed of the ball changes, Fig. 2.74.
We make one more small remark about discrete s. During the simulation, events
are generated, for example, when the logical expression “if” is used by the equation,
affecting its appearance. When an event occurs, the solver stops and repeats actions
to find the exact point of the event in time. Such iterations (iterations) can take some
time, and it is recommended to try to minimize them if it is possible.
Fig. 2.72 Bouncing ball model
Précédent

- 97/274

Suivant