第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

大角度擺圖沒有按預期顯示

大角度擺圖沒有按預期顯示

慕絲7291255 2023-05-23 16:22:24
我正在嘗試繪制無阻尼和無驅動擺的周期和振幅之間的關系,以應對小角度近似失效時的情況,但是,我的代碼沒有達到我的預期......這是我的代碼,我使用過零法來計算周期:import numpy as npimport matplotlib.pyplot as pltfrom scipy.integrate import solve_ivpfrom itertools import chain# Second order differential equation to be solved:# d^2 theta/dt^2 = - (g/l)*sin(theta) - q* (d theta/dt) + F*sin(omega*t)# set g = l and omega = 2/3 rad per second# Let y[0] = theta, y[1] = d(theta)/dtdef derivatives(t,y,q,F):? ? return [y[1], -np.sin(y[0])-q*y[1]+F*np.sin((2/3)*t)]t = np.linspace(0.0, 100, 10000)#initial conditions:theta0, omega0theta0 = np.linspace(0.0,np.pi,100)q = 0.0? ? ? ?#alpha / (mass*g), resistive termF = 0.0? ? ? ?#G*np.sin(2*t/3)value = []amp = []period = []for i in range (len(theta0)):? ? sol = solve_ivp(derivatives, (0.0,100.0), (theta0[i], 0.0), method = 'RK45', t_eval = t,args = (q,F))? ? velocity = sol.y[1]? ? time = sol.t? ? zero_cross = 0? ? for k in range (len(velocity)-1):? ? ? ? if (velocity[k+1]*velocity[k]) < 0:? ? ? ? ? ? zero_cross += 1? ? ? ? ? ? value.append(k)? ? ? ? else:? ? ? ? ? ? zero_cross += 0? ? if zero_cross != 0:? ? ? ? amp.append(theta0[i])? ? ? # period calculated using the time evolved between the first and last zero-crossing detected? ? ? ? period.append((2*(time[value[zero_cross - 1]] - time[value[0]])) / (zero_cross -1))plt.plot(amp,period)plt.title('Period of oscillation of an undamped, undriven pendulum \nwith varying initial angular displacemnet')plt.xlabel('Initial Displacement')plt.ylabel('Period/s')plt.show()
查看完整描述

1 回答

?
一只名叫tom的貓

TA貢獻1906條經驗 獲得超3個贊

您可以將 的事件機制用于solve_ivp此類任務,它專為此類“簡單”情況而設計


def halfperiod(t,y): return y[1]

halfperiod.terminal=True  #  stop when root found

halfperiod.direction=1    #  find sign changes from negative to positive


for i in range (1,len(theta0)): # amp==0 gives no useful result

    sol = solve_ivp(derivatives, (0.0,100.0), (theta0[i], 0.0), method = 'RK45', events =(halfperiod,) )

    if sol.success and len(sol.t_events[-1])>0:

        period.append(2*sol.t_events[-1][0]) # the full period is twice the event time

        amp.append(theta0[i])

這導致情節(jié)

http://img1.sycdn.imooc.com//646c77f10001b7b303840289.jpg

查看完整回答
反對 回復 2023-05-23
  • 1 回答
  • 0 關注
  • 143 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號