Download ModelDownload Model (Android)Download SourceembedFeedback


Horizontal Mass and Spring Harmonic Oscillator

App version by Wolfgang Christian and Loo Kang Wee Lawrence App view

Note: When running this simulation on a tablet or smart-phone, set the parameters, then press the Play button. When running this simulation on a computer, be sure to check “No sensor,” then set the parameters and press the Play button.

Mass and Spring Harmonic Oscillator

The Horizontal Mass and Spring Harmonic Oscillator mobile JavaScript model illustrates the forces and dynamics of a simple oscillator. This simulation uses the accelerometer on your mobile device to read the direction of the gravitation field g. You may need to lock the orientation of your screen to maintain a fixed view as you tilt your device. For use on computers without an accelerometer or for classroom use, the "No sensor" mode simulates a tilted device in the view. See also the Vertical Mass and Spring mobile JavaScript model.

A force body (free body) diagram showing the spring force (blue), the normal force (red), the gravitational force (black), and the force of friction (green) is shown. Users can set the initial position and velocity and you can adjust the viscous damping (friction) coefficient when the simulation is paused. Test your knowledge of oscillator dynamics by answering the following questions and comparing your answers with the simulation results. Remember to press the play button after you set the initial values.

Initial values, such as x0 and v0, can be set when the simulation is paused but not when the simulation is running. (Non-editable input fields have a grey background.) You may also drag the mass when the simulation is paused. The reset button returns the system to its default state while the reset time button returns the system to the previous values of x0 and v0.

Physics Exercises:

This simulation displays the cross section of a cylindrical mass m sliding in a hollow tube with springs and end caps. The tube walls exert a normal force that supports the mass and the caps limit the motion and cause the mass to bounce at the ends. The springs exert a Hooke's Law force Fs = -kx on the cylinder and the there is a low speed viscous drag (friction) force Fdrag=-bv that is determined by the damping coefficient b input field.

  1. Draw a force body diagram of the simple harmonic oscillator mass without tilt (θ = 0°), labeling all forces.
  2. Draw a force body diagram for the simple harmonic oscillator mass with an arbitrary nonzero tilt angle of θ, labeling all forces.
  3. What is the frequency of oscillation in radians/sec and in cycles/sec when θ = 0° and the damping coefficient = 0.05? How does this value change with an arbitrary nonzero tilt angle?
  4. Find the spring constant k and the mass of the simple harmonic oscillator by tilting and making measuring the response of the system.
  5. Rock (tilt) your mobile device back and forth so that the amplitude of oscillation becomes large enough for the mass to bounce off the bumpers. What rocking frequency did you use to achieve this large amplitude oscillator? How does this frequency compare to the frequency of oscillation you obtain in #3?
  6. Wiggle (push and pull) your device back and forth to produce an oscillation. Would you be able to tell the difference between this motion and the motion in #5 if you were a small person (Ant-Man) riding on the cylinder? (Note that this question led Albert Einstein to develop the general theory of relativity in 1916.)
  7. What is the phase shift between the position vs. time and the velocity vs. time graphs? Give a physical reason for this phase shift.
  8. What value of the damping coefficient b will cause the mass to reach its equilibrium point in the shortest possible time? Verify using the simulation.

Note: Because continuously reading the accelerometer may drain the battery on a mobile device, you must run the simulation to read the device tilt. The simulation will automatically pause after 4 minutes to conserve battery power.

Teaching and Learning Objectives:

  • Write the force law for simple harmonic motion involving a mass and a spring.
  • Solve this equation for a general harmonic expression for the one-dimensional motion using either sines or cosines.
  • Show that Newton’s Second Law forces a connection between angular velocity of the oscillation, and the spring constant and the mass.
  • Write the general harmonic function describing periodic motion. Identify angular frequency and phase angle.
  • Describe and derive the angular frequency for a specific spring/mass combination.
  • Describe why the simple harmonic oscillator’s motion diminishes over time.


Original version on Open Source Physics by Wolfgang Christian The Horizontal Mass and Spring Harmonic Oscillator mobile JavaScript model was developed by Wolfgang Christian using version 5 of the Easy Java Simulations (EJS 5) modeling tool. Although EJS is a Java program, EJS 5 creates stand alone JavaScript programs that run in almost any browser. Information about EJS is available at: <> and in the AAPT-ComPADRE Open Source Physics collection <>.


For Teachers


Software Requirements


Android iOS Windows MacOS
with best with Chrome Chrome Chrome Chrome
support fullscreen? Yes. Chrome/Opera No. Firefox/ Sumsung Internet Not yet Yes Yes
cannot work on some mobile browser that don't understand JavaScript such as..... cannot work on Internet Explorer 9 and below



Wolfgang Christian

end faq

5 1 1 1 1 1 1 1 1 1 1 Rating 5.00 (1 Vote)