These programs were developed on Scilab 6.1, a open source software for numerical computation that can be downloaded on the software's website.
The codes were conceived while I was monitor of the subject "PME 3200 - General mechanics II". The goals of these exercises were to teach the students enrolled at the subject concepts such as: mechanical systems modelling, states vector, numerical solving of ODEs, as well as the interactions on systems with multiple degrees of freedom.
The exercises consists on the modelling of a pendulum and at each exercise more complex mechanical interactions were added to the system, accordingly to the topics the students were learning. The first exercise consists of a pendulum with viscous friction and an oscillating external momentum. On the following exercise, collision was added, and the pendulum collides with a wall at a given angle with a coefficient of restitution. At last, the mass, which was fixed to the pendulum, was replaced by a mass with a spring attached to the pendulum's joint and the system gained an additional degree of freedom.
The model images of each exercise are listed below. The video with the result of the 3rd exercise simulation can be downloaded here.
The first exercise consists of a pendulum with a mass attached to the middle of its lenght. The forces acting in the pendulum are the gravity weight, a friction viscous moment and an external oscillating momentum.
The model's state variables are:
The model's parameters are:
- = Initial angular position [rad]
- = Initial angular velocity [rad/s]
- = Initial time of the simulation [s]
- = Final time of the simulation [s]
- m = Mass of the fixed body [kg]
- L = Pendulum length [m]
- c = Viscous angular friction coefficient [Nms/rad]
- = Oscillating external momentum [Nm]
- Mo = Momentum amplitude [Nm]
- = Momentum oscillating frequency [rad/s]
- = Momentum initial fase [rad/s]
The second exercise uses a model similar to the first one. The difference is that the fixed body is attached to the edge of the pendulum and there is a wall that stops the pendulum from advancing to the left. Hence, the collision between the pendulum and the wall has also to be dealt with.
The additional parameters for the second model are:
- = Wall angular position [rad]
- e = Coefficient of restitution
- = Initial time for the momentum activation [s]
The final exercise added a spring between the mass and the pendulum joint, in a manner that the mass is still dragged by the pendulum, while moving relatively to it.
Therefore, the model gains an additional degree of freedom and the states vector is now described by:
Where x represents the position of the body relative to the pendulum (in m).
The video with the result of a simulation can be downloaded here.