作者:王一哲
日期:2020/2/28
若質量可忽略的桿子長度為
所以當兩個球距離變近時,旋轉的角速率會跟著變快。
from vpython import *
"""
1. 參數設定, 設定變數及初始值
"""
size, R, dR = 0.3, 5, 1
theta1, theta2, omega = 0, pi, 2
t, dt = 0, 0.00005
"""
2. 畫面設定
"""
scene = canvas(title="Angular Momentum Conservation", width=600, height=600, x=0, y=0, background=color.black)
b1 = sphere(pos=R*vec(cos(theta1), sin(theta1), 0), radius=size, color=color.red, make_trail=True)
b2 = sphere(pos=R*vec(cos(theta2), sin(theta2), 0), radius=size, color=color.green, make_trail=True)
stick = cylinder(pos=b2.pos, axis=b1.pos-b2.pos, radius=0.2*size, color=color.yellow)
circle = ring(pos=vec(0, 0, 0), axis=vec(0, 0, 1), radius=R, thickness=0.05*size, color=color.white)
xaxis = cylinder(pos=vec(-1.2*R, 0, 0), axis=vec(2.4*R, 0, 0), radius=0.05*size, color=color.cyan)
yaxis = cylinder(pos=vec(0, -1.2*R, 0), axis=vec(0, 2.4*R, 0), radius=0.05*size, color=color.cyan)
gd = graph(title="<i>ω</i> - t plot", width=600, height=450, x=0, y=600,
xtitle="<i>t</i>(s)", ytitle="<i>ω</i>(rad/s)")
wt_plot = gcurve(graph=gd, color=color.red)
"""
3. 物體運動部分
"""
while R >= 2*size:
rate(1000)
omega *= (R / (R-dR*dt))**2
R -= dR*dt
theta1 += omega*dt
theta2 += omega*dt
b1.pos = R*vec(cos(theta1), sin(theta1), 0)
b2.pos = R*vec(cos(theta2), sin(theta2), 0)
stick.pos = b2.pos
stick.axis = b1.pos-b2.pos
wt_plot.plot(t, omega)
t += dt
以下所有物理量單位皆為 SI 制
這個動畫是假設兩個小球旋轉半徑以固定的速率縮短,如果將兩者改為星球,計算兩者之間的重力,應該就能做出雙星系統因為重力作用一邊旋轉、一邊互相接近的動畫,有興趣的同學可以嘗試看看。
VPython