Python動(dòng)力系統(tǒng)驗(yàn)證三體人是否真的存在
隨機(jī)三體
目前來說我們并不關(guān)心真實(shí)的物理對(duì)象,而只想看一下三個(gè)隨機(jī)的點(diǎn)放在三個(gè)隨機(jī)的位置,賦予三個(gè)隨機(jī)的速度,那么這三個(gè)點(diǎn)會(huì)怎么走。所以其初始化過程為
m = np.random.rand(3) x = np.random.rand(3) y = np.random.rand(3) u = np.random.rand(3) v = np.random.rand(3)
得到三個(gè)隨機(jī)的運(yùn)動(dòng)為



這幾個(gè)隨機(jī)的三體均有一個(gè)共同的結(jié)局,二體尚存,三體皆四散而去,至于能不能重新相聚,那就很難說了,代碼為
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import animation
m = np.random.rand(3)
x = np.random.rand(3)
y = np.random.rand(3)
u = np.random.rand(3)
v = np.random.rand(3)
fig = plt.figure(figsize=(12,12))
ax = fig.add_subplot(xlim=(-2e11,2e11),ylim=(-2e11,2e11))
ax.grid()
trace0, = ax.plot([],[],'-', lw=0.5)
trace1, = ax.plot([],[],'-', lw=0.5)
trace2, = ax.plot([],[],'-', lw=0.5)
pt0, = ax.plot([x[0]],[y[0]] ,marker='o')
pt1, = ax.plot([x[0]],[y[0]] ,marker='o')
pt2, = ax.plot([x[0]],[y[0]] ,marker='o')
k_text = ax.text(0.05,0.85,'',transform=ax.transAxes)
textTemplate = 't = %.3f days\n'
N = 1000
dt = 36000
ts = np.arange(0,N*dt,dt)/3600/24
xs,ys = [],[]
for _ in ts:
x_ij = (x-x.reshape(3,1))
y_ij = (y-y.reshape(3,1))
r_ij = np.sqrt(x_ij**2+y_ij**2)
for i in range(3):
for j in range(3):
if i!=j :
u[i] += (m[j]*x_ij[i,j]*dt/r_ij[i,j]**3)
v[i] += (m[j]*y_ij[i,j]*dt/r_ij[i,j]**3)
x += u*dt
y += v*dt
xs.append(x.tolist())
ys.append(y.tolist())
xs = np.array(xs)
ys = np.array(ys)
def animate(n):
trace0.set_data(xs[:n,0],ys[:n,0])
trace1.set_data(xs[:n,1],ys[:n,1])
trace2.set_data(xs[:n,2],ys[:n,2])
pt0.set_data([xs[n,0]],[ys[n,0]])
pt1.set_data([xs[n,1]],[ys[n,1]])
pt2.set_data([xs[n,2]],[ys[n,2]])
k_text.set_text(textTemplate % ts[n])
return trace0, trace1, trace2, pt0, pt1, pt2, k_text
ani = animation.FuncAnimation(fig, animate,
range(N), interval=10, blit=True)
plt.show()
ani.save("3.gif")
經(jīng)過多次畫圖,基本上沒發(fā)現(xiàn)能夠穩(wěn)定運(yùn)行的三體,所以從經(jīng)驗(yàn)來說,隨機(jī)三體在自然界中應(yīng)該是很難存在的——畢竟很快就解散了。
三星問題
短時(shí)間內(nèi)穩(wěn)定的三體還是有很多的,比如比如在高中出鏡率極高的三星問題:
即等距等質(zhì)量三星如何運(yùn)動(dòng)?現(xiàn)假設(shè)三個(gè)質(zhì)量相同的等距質(zhì)點(diǎn),分別給一個(gè)隨機(jī)的速度,看看它們?cè)趺催\(yùn)動(dòng)。
m = np.ones(3) r = np.ones(3) theta = np.arange(3)*np.pi*2/3 x = r*np.cos(theta) y = r*np.sin(theta) V = np.random.rand(N) u = V*np.sin(theta) v = V*np.cos(theta)


總之只要看到它們互相靠近,那么結(jié)果注定分道揚(yáng)鑣,像極了人生。
如果再讓它們速度相等,那么神奇的一幕出現(xiàn)了


但更神奇的是,只要對(duì)速度做出一點(diǎn)點(diǎn)的更改,例如令第三顆星在橫軸方向更改 δ ,則會(huì)出現(xiàn)如下場(chǎng)景

δ=0.0001

這就是所謂的蝴蝶效應(yīng),初值的一點(diǎn)更改,就會(huì)造成不可挽回的巨大后果,這也是動(dòng)力系統(tǒng)的獨(dú)特魅力。
以上就是Python動(dòng)力系統(tǒng)驗(yàn)證三體人是否真的存在的詳細(xì)內(nèi)容,更多關(guān)于Python驗(yàn)證三體人是否存在的資料請(qǐng)關(guān)注本站其它相關(guān)文章!
版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。
關(guān)注官方微信