Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Simple Harmonic Motion and Vibration | Dynamics and System Simulation
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python for Mechanical Engineers

bookSimple Harmonic Motion and Vibration

Simple harmonic motion (SHM) is a fundamental concept in mechanical engineering, especially when analyzing systems that oscillate, such as springs, pendulums, or vibrating beams. SHM describes the repetitive back-and-forth movement of an object about an equilibrium position, where the restoring force is proportional to the displacement and acts in the opposite direction. One of the most common physical models illustrating SHM is the mass-spring system. In its simplest form, this system consists of a mass attached to a spring, moving horizontally or vertically without any energy loss due to friction or air resistance (i.e., no damping). The equation of motion for such a system can be derived from Newton’s Second Law and Hooke’s Law:

F = m * a = -k * x

where:

  • F is the restoring force;
  • m is the mass;
  • a is the acceleration;
  • k is the spring constant;
  • x is the displacement from equilibrium.

Solving this differential equation leads to a motion that is sinusoidal in time, characteristic of SHM. In real-world engineering, understanding SHM is crucial for vibration analysis, designing suspension systems, and predicting the behavior of machinery subject to oscillatory forces.

123456789101112131415161718192021
import numpy as np def shm_displacement(t, x0, v0, m, k): """ Compute displacement over time for a mass-spring system (no damping). Parameters: t : array of time points x0 : initial displacement v0 : initial velocity m : mass (kg) k : spring constant (N/m) Returns: x : array of displacement values """ omega = np.sqrt(k / m) A = x0 B = v0 / omega x = A * np.cos(omega * t) + B * np.sin(omega * t) return x
copy

The function above, shm_displacement, models the displacement of a mass attached to a spring as it oscillates with no energy loss. The parameters include the initial displacement (x0), initial velocity (v0), mass (m), and spring constant (k). The angular frequency (omega) is determined by the physical properties of the system, specifically the mass and spring constant, and defines how quickly the system oscillates. This solution is widely used in vibration analysis to predict how a mechanical system will respond to disturbances, helping engineers avoid resonance and design safer, more reliable machines. By using this function, you can simulate how the position of the mass changes over time, which is essential for understanding and controlling vibration in mechanical systems.

12345678910111213141516171819202122
import matplotlib.pyplot as plt import numpy as np # Parameters m = 1.0 # mass (kg) k = 10.0 # spring constant (N/m) x0 = 0.1 # initial displacement (m) v0 = 0.0 # initial velocity (m/s) t = np.linspace(0, 5, 500) # time array from 0 to 5 seconds # Compute displacement x = shm_displacement(t, x0, v0, m, k) # Plotting plt.figure(figsize=(8, 4)) plt.plot(t, x, label='Displacement (m)') plt.title('Simple Harmonic Motion: Mass-Spring System') plt.xlabel('Time (s)') plt.ylabel('Displacement (m)') plt.grid(True) plt.legend() plt.show()
copy

1. What physical systems can be modeled as simple harmonic oscillators?

2. Which parameters determine the frequency of SHM?

3. How does Python help visualize vibration behavior?

question mark

What physical systems can be modeled as simple harmonic oscillators?

Select all correct answers

question mark

Which parameters determine the frequency of SHM?

Select the correct answer

question mark

How does Python help visualize vibration behavior?

Select the correct answer

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 4

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

Suggested prompts:

Can you explain how the angular frequency is calculated in this context?

What happens if I change the mass or spring constant values?

How is this function useful in real-world engineering applications?

bookSimple Harmonic Motion and Vibration

Sveip for å vise menyen

Simple harmonic motion (SHM) is a fundamental concept in mechanical engineering, especially when analyzing systems that oscillate, such as springs, pendulums, or vibrating beams. SHM describes the repetitive back-and-forth movement of an object about an equilibrium position, where the restoring force is proportional to the displacement and acts in the opposite direction. One of the most common physical models illustrating SHM is the mass-spring system. In its simplest form, this system consists of a mass attached to a spring, moving horizontally or vertically without any energy loss due to friction or air resistance (i.e., no damping). The equation of motion for such a system can be derived from Newton’s Second Law and Hooke’s Law:

F = m * a = -k * x

where:

  • F is the restoring force;
  • m is the mass;
  • a is the acceleration;
  • k is the spring constant;
  • x is the displacement from equilibrium.

Solving this differential equation leads to a motion that is sinusoidal in time, characteristic of SHM. In real-world engineering, understanding SHM is crucial for vibration analysis, designing suspension systems, and predicting the behavior of machinery subject to oscillatory forces.

123456789101112131415161718192021
import numpy as np def shm_displacement(t, x0, v0, m, k): """ Compute displacement over time for a mass-spring system (no damping). Parameters: t : array of time points x0 : initial displacement v0 : initial velocity m : mass (kg) k : spring constant (N/m) Returns: x : array of displacement values """ omega = np.sqrt(k / m) A = x0 B = v0 / omega x = A * np.cos(omega * t) + B * np.sin(omega * t) return x
copy

The function above, shm_displacement, models the displacement of a mass attached to a spring as it oscillates with no energy loss. The parameters include the initial displacement (x0), initial velocity (v0), mass (m), and spring constant (k). The angular frequency (omega) is determined by the physical properties of the system, specifically the mass and spring constant, and defines how quickly the system oscillates. This solution is widely used in vibration analysis to predict how a mechanical system will respond to disturbances, helping engineers avoid resonance and design safer, more reliable machines. By using this function, you can simulate how the position of the mass changes over time, which is essential for understanding and controlling vibration in mechanical systems.

12345678910111213141516171819202122
import matplotlib.pyplot as plt import numpy as np # Parameters m = 1.0 # mass (kg) k = 10.0 # spring constant (N/m) x0 = 0.1 # initial displacement (m) v0 = 0.0 # initial velocity (m/s) t = np.linspace(0, 5, 500) # time array from 0 to 5 seconds # Compute displacement x = shm_displacement(t, x0, v0, m, k) # Plotting plt.figure(figsize=(8, 4)) plt.plot(t, x, label='Displacement (m)') plt.title('Simple Harmonic Motion: Mass-Spring System') plt.xlabel('Time (s)') plt.ylabel('Displacement (m)') plt.grid(True) plt.legend() plt.show()
copy

1. What physical systems can be modeled as simple harmonic oscillators?

2. Which parameters determine the frequency of SHM?

3. How does Python help visualize vibration behavior?

question mark

What physical systems can be modeled as simple harmonic oscillators?

Select all correct answers

question mark

Which parameters determine the frequency of SHM?

Select the correct answer

question mark

How does Python help visualize vibration behavior?

Select the correct answer

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 4
some-alt