Mass and Spring: A simple EJS model

Description

The Mass and Spring system is a simple model that is often used in workshops to introduce EJS programming concepts. It shows the motion of a mass m situated at the end of a spring of length l and negligible mass. The motion is restricted to the horizontal dimension. (We choose a coordinate system in the plane with origin at the fixed end of the spring and with the X axis along the direction of the spring).

We assume that the reaction of the spring to a displacement dx from the equilibrium point can be modeled using Hooke's Law, F(dx) = -k dx , where k is a constant which depends on the physical characteristics of the spring. Thus, applying Newton's Second Law, we obtain the following second-order ordinary differential equation:

d2x / dt2 = -k/m (x-l),

where x is the horizontal position of the free end of the spring. The equations of motion are solved numerically and the results are plotted,

Credits:

The Mass and Spring Java model was developed by Wolfgang Christian and Francisco Esquembre using the Easy Java Simulations (EJS) modeling and authoring tool created by Esquembere in Murcia, Spain. It was later converted from Java to JavaScript by Wolfgang Christian and Robert Hanson using the SwingJS system developed by Hanson and his students at St. Olaf College.

Updated 10 August 2020.