现象一:彩虹的诞生
想象一下,当雨后的天空出现一道彩虹,那绚丽的色彩是如何形成的呢?其实,这是由于阳光穿过雨滴时发生折射、反射和色散的结果。当太阳光进入水滴时,会发生折射,然后在水滴内部反射,最后再次折射出水滴。不同颜色的光由于波长不同,折射角度不同,因此我们看到的彩虹是由红、橙、黄、绿、蓝、靛、紫七种颜色组成。
代码示例:
import matplotlib.pyplot as plt
def draw_rainbow():
colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet']
angles = [40, 38, 36, 34, 32, 30, 28]
fig, ax = plt.subplots()
ax.barh(range(len(colors)), angles, color=colors)
ax.set_xlabel('角度 (度)')
ax.set_title('彩虹色散角度')
plt.show()
draw_rainbow()
现象二:磁铁的魔力
磁铁是一种具有磁性的物质,它可以吸引铁、镍等金属。磁铁的魔力源于磁场的存在。磁场是由磁铁产生的空间区域,其中的磁性力可以作用于磁性物质。磁铁有两个磁极,分别是北极和南极,同名磁极相互排斥,异名磁极相互吸引。
代码示例:
import numpy as np
import matplotlib.pyplot as plt
def plot_magnetic_field(magnetic_field):
x = np.linspace(-5, 5, 100)
y = np.linspace(-5, 5, 100)
X, Y = np.meshgrid(x, y)
Z = np.zeros_like(X)
for i in range(len(x)):
for j in range(len(y)):
Z[i, j] = magnetic_field(X[i, j], Y[i, j])
plt.figure()
plt.contourf(X, Y, Z, levels=20)
plt.xlabel('X')
plt.ylabel('Y')
plt.title('磁场分布')
plt.show()
def magnetic_field(x, y):
return x**2 + y**2
plot_magnetic_field(magnetic_field)
现象三:光的折射
当光线从一种介质(如空气)进入另一种介质(如水)时,会发生折射现象。折射是由于光在不同介质中的传播速度不同而引起的。根据斯涅尔定律,入射角和折射角之间的关系可以用以下公式表示:
\[ n_1 \sin \theta_1 = n_2 \sin \theta_2 \]
其中,\(n_1\) 和 \(n_2\) 分别是两种介质的折射率,\(\theta_1\) 和 \(\theta_2\) 分别是入射角和折射角。
代码示例:
import numpy as np
import matplotlib.pyplot as plt
def refractive_index(n1, n2, theta1):
return n1 * np.sin(theta1) / np.sin(np.arcsin(n1 * np.sin(theta1) / n2))
def plot_refraction(n1, n2, theta1):
angles = np.linspace(0, np.pi/2, 100)
refractive_angles = refractive_index(n1, n2, angles)
plt.figure()
plt.plot(angles, refractive_angles, label='折射角')
plt.axhline(0, color='r', linestyle='--')
plt.axvline(theta1, color='g', linestyle='--')
plt.xlabel('入射角 (弧度)')
plt.ylabel('折射角 (弧度)')
plt.title('光的折射')
plt.legend()
plt.show()
plot_refraction(1, 1.33, np.pi/4)
现象四:重力的作用
地球上的物体都受到重力的作用。重力是由于地球的引力而产生的,其大小与物体的质量成正比。当我们抛出一个物体时,它会受到重力的影响而落回地面。重力加速度是一个常数,其值约为 \(9.8 \, \text{m/s}^2\)。
代码示例:
import numpy as np
import matplotlib.pyplot as plt
def gravity(mass, time):
return mass * 9.8 * time
def plot_gravity(mass, time):
velocities = np.linspace(0, 10, 100)
distances = np.zeros_like(velocities)
for i in range(len(velocities)):
distances[i] = 0.5 * 9.8 * (velocities[i]**2)
plt.figure()
plt.plot(velocities, distances, label='位移')
plt.axhline(0, color='r', linestyle='--')
plt.xlabel('速度 (m/s)')
plt.ylabel('位移 (m)')
plt.title('重力作用下的位移')
plt.legend()
plt.show()
plot_gravity(1, 2)
现象五:声音的传播
声音是一种机械波,它通过振动传播。声音的传播速度取决于介质的性质,如密度和弹性模量。在空气中,声音的传播速度约为 \(343 \, \text{m/s}\)。当我们听到声音时,实际上是空气中的分子受到振动而传递给我们的耳朵。
代码示例:
import numpy as np
import matplotlib.pyplot as plt
def sound_speed(density, elastic_modulus):
return np.sqrt(elastic_modulus / density)
def plot_sound_speed(density, elastic_modulus):
velocities = np.linspace(100, 1000, 100)
sound_speeds = sound_speed(density, elastic_modulus)
plt.figure()
plt.plot(velocities, sound_speeds, label='声音速度')
plt.axhline(343, color='r', linestyle='--')
plt.xlabel('密度 (kg/m^3)')
plt.ylabel('声音速度 (m/s)')
plt.title('声音的传播速度')
plt.legend()
plt.show()
plot_sound_speed(1.225, 1.42e11)
通过以上五个例子,我们可以看到日常生活中存在着许多奇妙的现象。通过学习这些现象背后的科学原理,我们可以更好地理解世界,并成为科学小达人。
