用python模拟杨氏双缝干涉实验
时间: 2025-06-09 09:01:36 浏览: 12
在Python中,我们可以利用numpy和matplotlib等库模拟杨氏双缝干涉实验。这个实验基于波动理论,通常用于演示光波的叠加原理。下面是一个简单的模拟示例:
```python
import numpy as np
import matplotlib.pyplot as plt
def double_slit_interference(width, spacing, wavelength, max_distance):
# 创建波长数组
num_points = 1000
distance_array = np.linspace(0, max_distance, num_points)
# 杨氏双缝位置
slit1 = -width / 2
slit2 = width / 2
# 波动函数
def wave_function(position, phase):
return np.exp(1j * 2 * np.pi * position * wavelength / (wavelength + phase))
# 干涉相位差
phase_difference = 2 * np.pi * (distance_array - slit1 - slit2) / spacing
# 计算干涉强度
intensity = np.abs(wave_function(distance_array, slit1) + wave_function(distance_array, slit2)) ** 2
# 绘制干涉条纹
plt.plot(distance_array, intensity)
plt.xlabel('Distance from the screen (pixels)')
plt.ylabel('Intensity')
plt.title('Double Slit Interference Pattern')
plt.grid(True)
plt.xlim(0, max_distance)
# 示例参数设置
width = 0.05 # 双缝宽度
spacing = 0.01 # 相邻缝隙间距
wavelength = 0.6328 # 光波长度,这里假设是红光
max_distance = 50 # 观察区域最大距离
double_slit_interference(width, spacing, wavelength, max_distance)
```
这个脚本会生成一个二维图像,模拟了从两个缝隙到达屏幕的不同路径造成的干涉效应,表现为明暗交替的干涉条纹。
阅读全文
相关推荐

















