5 - Spring Connection

Introduction

This simulation demonstrates spring-mass oscillations and is currently being expanded.

Understanding the spring-mass system

A spring connection simulation models how a mass behaves when attached to a spring under the influence of gravity. The restoring force generated by the spring obeys Hook's Law, which states that the force exerted by the spring is proportional to the displacement from its rest length.

  1. At equilibrium, the spring exerts a force that balances the weight of the mass.
  2. When displaced from equilibrium, the spring generates a restoring force that pulls the mass back towards the equilibrium position.
  3. The mass oscillates around the equilibrium position due to the interplay between the spring force and gravitational force.

Key Concepts and Formulas

  • Hooke's Law: F = -k x, where F is the restoring force, k is the spring constant, and x is the displacement from equilibrium.
  • Potential Energy in the Spring: U = 1/2 k x^2, representing the energy stored in the spring when compressed or stretched.
  • Kinetic Energy of the Mass: K = 1/2 m v^2, representing the energy of motion of the mass.
  • Total Mechanical Energy: E = K + U, which remains constant in the absence of non-conservative forces like friction.
  • Simple Harmonic Motion: The mass-spring system exhibits simple harmonic motion, characterized by sinusoidal oscillations around the equilibrium position.
  • Newton's Second Law: F = m a, where F is the net force acting on the mass, m is its mass, and a is its acceleration.
Fs=k(xL0)F_s = -k(x - L_0)
ma=k(xL0)bv+mgm a = -k (x - L_0) - b v + m g
Here, k is the spring constant, b is the damping coefficient, L₀ is the natural length of the spring, m is the mass, g is the acceleration due to gravity, x is the position of the mass, v is its velocity, and a is its acceleration.

Code Representation



// Simplifies spring-mass system
let y = 1; // Position (m)
let vy = 0; // Velocity (m/s)
const k = 100; // Spring constant (N/m)
const L0 = 0.5; // Natural length of the spring (m)
const m = 10; // Mass (kg)
const g = 9.81; // Gravitational acceleration (m/s²)
const b = 1; // Damping coefficient (kg/s)

function draw(dt){
  let Fspring = -k * (y - L0); // Spring force
   let Fgravity = m * g; // Gravitational force
   let Fdamping = -b * vy; // Damping force
   let Fnet = Fspring + Fgravity + Fdamping; // Net force
   let ay = Fnet / m; // Acceleration
   vy += ay * dt; // Update velocity
   y += vy * dt; // Update position
}

Simulation Parameters

ParameterSymbolDescription
MassmMass of the bob attached to the spring (kg).
Spring ConstantkStiffness of the spring, determining the restoring force (N/m).
Rest lengthL₀Length of the spring when no forces are applied (equilibrium) (m).
Damping CoefficientbResists motion, simulating energy loss due to friction or air resistance (kg/s).

Helpful Tips

Real-World Application
This system models a weight hanging from a ceiling by a spring, demonstrating oscillatory motion and energy conservation.
Attention!
If damping is too low, the mass may oscillate indefinitely; if too high, it may not oscillate at all. The system becomes overdamped.
Smart Tip!
Try varying different spring constants and masses to see how they affect oscillation frequency and amplitude.
Success!
You've learned how restoring force, damping, and energy conservation govern spring-mass oscillations.