Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mass-Spring-Damper Simulation

Simulation and response analysis of a second-order mass-spring-damper system.

This project is a compact dynamics foundation project focused on understanding how mass, damping, stiffness, and external forcing affect the behavior of a physical system.

It connects:

  • dynamic system modeling
  • second-order system response
  • damping behavior
  • forced response analysis
  • basic control-oriented metrics
  • visualization of physical system behavior

Project Overview

A mass-spring-damper system is a standard model in physics, mechanical dynamics, and control engineering.

The governing equation is:

m x'' + c x' + k x = F(t)

where:

  • m is the mass
  • c is the damping coefficient
  • k is the spring constant
  • x is the displacement
  • F(t) is the external force input

The goal of this project is to simulate the system under different scenarios and visualize how parameter changes affect the response.


Why This Project Matters

This project provides a foundation for later projects involving:

  • DC motor simulation
  • Kalman filtering
  • dynamic system classification
  • embedded condition monitoring
  • control-oriented physical system analysis

It is intentionally simple, but it helps build intuition for how real physical systems respond over time.


Simulation Scenarios

1. Free Response and Damping Cases

The free response compares three damping regimes:

  • underdamped
  • critically damped
  • overdamped

This shows how damping changes oscillation, overshoot, and settling behavior.

2. Forced Response

The forced response uses a sinusoidal input:

F(t) = sin(2t)

This shows how the system responds to an external time-varying force.

3. Effect of Mass

The mass comparison studies:

  • m = 0.5
  • m = 1.0
  • m = 2.0

while keeping damping and stiffness fixed.

Lower mass leads to faster motion, while higher mass makes the response slower.

4. Effect of Spring Constant

The spring comparison studies:

  • k = 5.0
  • k = 10.0
  • k = 20.0

while keeping mass and damping fixed.

A larger spring constant makes the system stiffer and increases the oscillation frequency.

5. Velocity Response

The velocity response is plotted to show how system speed changes over time, not only position.

6. Response Metrics

For the underdamped case, the project computes simple transient response metrics:

  • peak displacement
  • settling time using a 2 percent tolerance band

These metrics make the simulation more control-oriented.


Results

The project demonstrates several key behaviors of second-order dynamic systems:

  • damping changes oscillation and settling behavior
  • external forcing changes the response shape
  • mass affects response speed
  • spring stiffness affects oscillation frequency
  • velocity provides additional insight into system motion
  • simple metrics help quantify transient behavior

Output Figures

Damping Cases

Comparison of underdamped, critically damped, and overdamped responses.

Damping Cases

Forced Response

System response under sinusoidal forcing.

Forced Response

Mass Effect

Effect of changing mass while keeping damping and stiffness fixed.

Mass Effect

Spring Effect

Effect of changing spring stiffness while keeping mass and damping fixed.

Spring Effect

Velocity Response

Velocity response for the forced-response case.

Velocity Response

Underdamped Metrics

Peak displacement and settling-time analysis for the underdamped response.

Underdamped Metrics


Repository Structure

mass-spring-damper-simulation/
├── results/
│   ├── damping_cases.png
│   ├── damping_comparison.png
│   ├── forced_response.png
│   ├── mass_effect.png
│   ├── spring_effect.png
│   ├── underdamped_metrics.png
│   └── velocity_response.png
├── src/
│   └── main.py
├── requirements.txt
├── .gitignore
└── README.md

Main File

The main simulation script is:

src/main.py

It generates the simulations and saves the output figures in:

results/

How to Run

Create and activate a virtual environment:

python3 -m venv venv
source venv/bin/activate

Install dependencies:

pip install -r requirements.txt

Run the simulation:

python3 src/main.py

Project Role in Portfolio

This project provides the dynamic systems foundation for later projects in:

  • Kalman filtering for DC motor estimation
  • dynamic system classification using machine learning
  • embedded AI condition monitoring
  • signal-based modeling for physical systems

Together, these projects support a broader direction:

Dynamics, control, and signal-based ML foundations

Limitations

This project is intentionally simple and simulation-based.

Current limitations:

  • no controller is implemented yet
  • only one basic second-order system is studied
  • no real sensor data is used
  • parameter studies are limited to mass and spring constant
  • the code is compact rather than structured as a larger package

These limitations are acceptable for a foundational dynamics project.


Future Work

Possible next steps:

  • implement PID control
  • compare different force inputs
  • add state-space representation
  • add parameter estimation
  • extend the project to noisy measurements
  • connect the simulation to machine learning classification
  • compare with other dynamic systems such as DC motors

Summary

This project simulates and analyzes a classic second-order dynamic system.

It shows how physical parameters affect system response and provides a foundation for later work in estimation, control, machine learning for dynamic systems, and embedded monitoring.

About

Simulation and response analysis of a second-order mass-spring-damper dynamic system with parameter studies and control-oriented metrics.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages