两个频率比较接近的简谐振动叠加后会产生拍形
两个频率比较接近的简谐振动叠加后会产生拍形。
import numpy as np
import matplotlib.pyplot as plt# Parameters
f1 = 10.0 # Frequency of the first vibration (Hz)
f2 = 10.5 # Frequency of the second vibration (Hz)
t_max = 10 # Time range (seconds)
t = np.linspace(0, t_max, 1000) # Time array# Generate two simple harmonic vibrations
A = 1.0 # Amplitude
x1 = A * np.sin(2 * np.pi * f1 * t) # First simple harmonic vibration
x2 = A * np.sin(2 * np.pi * f2 * t) # Second simple harmonic vibration# Superimpose the two vibrations
x_total = x1 + x2# Plot the results
plt.figure(figsize=(12, 6))# Plot the individual vibrations
plt.subplot(3, 1, 1)
plt.plot(t, x1, label=f'f1 = {f1} Hz')
plt.plot(t, x2, label=f'f2 = {f2} Hz')
plt.title("Individual Simple Harmonic Vibrations")
plt.xlabel("Time (s)")
plt.ylabel("Amplitude")
plt.legend()# Plot the superimposed vibration
plt.subplot(3, 1, 2)
plt.plot(t, x_total, label='Superimposed Vibration')
plt.title("Superimposed Vibration")
plt.xlabel("Time (s)")
plt.ylabel("Amplitude")
plt.legend()# Plot the envelope of the beats
beat_frequency = abs(f2 - f1) # Beat frequency
envelope = 2 * A * np.abs(np.cos(2 * np.pi * beat_frequency * t / 2))
plt.subplot(3, 1, 3)
plt.plot(t, x_total, label='Superimposed Vibration')
plt.plot(t, envelope, label='Envelope', linestyle='--', color='red')
plt.plot(t, -envelope, label='Envelope', linestyle='--', color='red')
plt.title("Beat Phenomenon Envelope")
plt.xlabel("Time (s)")
plt.ylabel("Amplitude")
plt.legend()plt.tight_layout()
plt.show()