Python動力系統(tǒng)驗證三體人是否真的存在
隨機三體
目前來說我們并不關(guān)心真實的物理對象,而只想看一下三個隨機的點放在三個隨機的位置,賦予三個隨機的速度,那么這三個點會怎么走。所以其初始化過程為
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)
得到三個隨機的運動為
這幾個隨機的三體均有一個共同的結(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)定運行的三體,所以從經(jīng)驗來說,隨機三體在自然界中應(yīng)該是很難存在的——畢竟很快就解散了。
三星問題
短時間內(nèi)穩(wěn)定的三體還是有很多的,比如比如在高中出鏡率極高的三星問題:
即等距等質(zhì)量三星如何運動?現(xiàn)假設(shè)三個質(zhì)量相同的等距質(zhì)點,分別給一個隨機的速度,看看它們怎么運動。
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é)果注定分道揚鑣,像極了人生。
如果再讓它們速度相等,那么神奇的一幕出現(xiàn)了
但更神奇的是,只要對速度做出一點點的更改,例如令第三顆星在橫軸方向更改 δ ,則會出現(xiàn)如下場景
δ=0.0001
這就是所謂的蝴蝶效應(yīng),初值的一點更改,就會造成不可挽回的巨大后果,這也是動力系統(tǒng)的獨特魅力。
以上就是Python動力系統(tǒng)驗證三體人是否真的存在的詳細內(nèi)容,更多關(guān)于Python驗證三體人是否存在的資料請關(guān)注本站其它相關(guān)文章!
版權(quán)聲明:本站文章來源標注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。