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
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:
mis the masscis the damping coefficientkis the spring constantxis the displacementF(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.
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.
The free response compares three damping regimes:
- underdamped
- critically damped
- overdamped
This shows how damping changes oscillation, overshoot, and settling behavior.
The forced response uses a sinusoidal input:
F(t) = sin(2t)
This shows how the system responds to an external time-varying force.
The mass comparison studies:
m = 0.5m = 1.0m = 2.0
while keeping damping and stiffness fixed.
Lower mass leads to faster motion, while higher mass makes the response slower.
The spring comparison studies:
k = 5.0k = 10.0k = 20.0
while keeping mass and damping fixed.
A larger spring constant makes the system stiffer and increases the oscillation frequency.
The velocity response is plotted to show how system speed changes over time, not only position.
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.
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
Comparison of underdamped, critically damped, and overdamped responses.
System response under sinusoidal forcing.
Effect of changing mass while keeping damping and stiffness fixed.
Effect of changing spring stiffness while keeping mass and damping fixed.
Velocity response for the forced-response case.
Peak displacement and settling-time analysis for the underdamped response.
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
The main simulation script is:
src/main.py
It generates the simulations and saves the output figures in:
results/
Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activateInstall dependencies:
pip install -r requirements.txtRun the simulation:
python3 src/main.pyThis 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
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.
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
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.





