#
Reinit

##
1
General Description

The reinit operator occurs both as a kind of statement and in the form of an equation with the same syntax. The reinit operator is used to make a discontinuous change in the value of a continuous variable at a specific time event. The reinit operator can only be applied to variables the have had the der operator applied to them. The effect of the operator is to stop simulation time, make a change to the value of one or more continuous variables and then resume the simulation. The first argument to reinit is the variable whose value should change and the second argument is the value it should change to. The reinit operator can only be used within a when clause because it is meant to represent an abrupt change, which is the difference between reinit and a statement or equation.

##
2
Bouncing Ball

##
3
Bouncing Ball Simulation

##
4
Bouncing Ball Error

If the assignment velocity := -c*velocity is used instead of reinit(velocity, -c*velocity) an overdeterminated system of equations are created.

##
5
Simulation of Bouncing Ball Error

When we try to simulate the erroneous Bouncing Ball model we get a complaint for having to many equations.

##
6
FilterBlock1

Another example of how to use reinit is the self initializing block class FilterBlock1, which when initial() becomes true defines x to be u. This causes der(x) to initially be zero according to its defining equation.

##
7
FilterBlock Simulation