Lecture 9 List的練習 完整作業參考解法
建國高中特色選修課程 - 物理現象的程式設計與模擬
作者:賴奕帆
日期:2018/8/25
Lecture 9 檢核作業
檢核作業 9-1
請嘗試用雙重甚至三重的迴圈,做出如下圖的平板甚至是立方體的圖示吧。
-
用小球繪製平板,同學可以猜猜這裡有幾個小球,如何編號呢?
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
用小球繪製立方體,老師這裡用的球比較少,因為太多會嚴重lag,共有7x7x7顆球。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
檢核作業 9-1 參考解法步驟 :
- 將在for N in range(-50,51,1)改為for N1 in range(-50,51,1),並再多一層迴圈for N2 in range(-50,51,1),注意多層迴圈的程式縮排。
- 修改pos=vector(N x 0.02 x R,0,0)為pos=vector(N1 x 0.02 x R,0,__________)。
-
若成功修改,請嘗試想想這裡到底有幾顆球,10000顆嗎?這些球是如何排列編號的呢?請嘗試用 print (balllist[???].pos) 檢視自己的想法。
-
由於這裡的物件超過一萬,所以程式明顯產生lag。
-
改換回繪製立方體,在加多一層for迴圈,由於只要7x7x7顆球,因此修改for N1 in range(???,???,1)
檢核作業 9-2
如同課堂作業9-1,請同學嘗試修改上述的arrowlist append迴圈,寫出如下圖立方體空間的引力場。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
檢核作業 9-2 參考解法步驟 :
- 將原有的平面for迴圈再多一層改為三層的立體for迴圈。
- 將arrowlist.append(arrow(pos=vector(N1xRe,N2xRe,_______)中的Z軸位置補上。
指定作業 9-1
105年 台大物理系二階段試題
在三維空間中有一xy平面,有兩個靜止的正面荷(電量為q)分別位於x軸的d/2和-d/2處,另有兩個靜止的負電荷(電量為-q)位於y軸的d/2和-d/2處,如下圖所示,請在xy平面上繪出電力線。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
並嘗試在空間中也丟入一個綠色正電荷小球,使其受到這四顆固定電荷的靜電力,觀察其運動軌跡。
指定作業 9-1 參考解法步驟 :
- 在畫面設定處,重新設定四個電荷的名稱與位置。
- 重新放置四組List的場球
"""重新放置四組List場球(2. 畫面設定)"""
field_ball_x1=[]
for N in range(0,b_N,1):
field_ball_x1.append(sphere(pos=vector(size*cos(2*pi*N/b_N), size*sin(2*pi*N/b_N),0)+Qx1.pos,
radius=0.01, color=vec(1,1,0), make_trail=True, v=vector(0,0,0)))
field_ball_x2=[]
for N in range(0,b_N,1):
field_ball_x2.append(sphere(pos=vector(size*cos(2*pi*N/b_N), size*sin(2*pi*N/b_N),0)+Qx2.pos,
radius=0.01, color=vec(1,1,0), make_trail=True, v=vector(0,0,0)))
field_ball_y1=[]
for N in range(0,b_N,1):
field_ball_y1.append(sphere(pos=vector(size*cos(2*pi*N/b_N), size*sin(2*pi*N/b_N),0)+___________,
radius=0.01, color=vec(0.8,0.8,0.3), make_trail=True, v=vector(0,0,0)))
field_ball_y2=[]
for N in range(0,b_N,1):
field_ball_y2.append(sphere(pos=vector(size*cos(2*pi*N/b_N), size*sin(2*pi*N/b_N),0)+___________,
radius=0.01, color=vec(0.8,0.8,0.3), make_trail=True, v=vector(0,0,0)))
- 重新定義每顆場球受到四個電荷的靜電力(電場)
- 在迴圈處控制四組List電場球
- 放入綠色小球,觀察它的運動狀況
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
指定作業 9-2
請同學先執行以下程式碼

-
gas collision是高三上物理 氣體動力論中常討論的問題,將空氣噴出,若碰撞到牆壁反彈,則牆壁所受到的平均力(平均壓力)的討論。
-
同學可以嘗試修改入射角度theta與每秒射出的氣體數per_N兩個基本參數玩看看。
-
請同學們嘗試將此模擬,加上上一節所教的靜電力概念,改成下圖另一個大家熟悉的金箔原子撞擊模擬。
-
希望同學們修完這九節課之後,都能有這樣的能力,加油。

指定作業 9-2 參考解法步驟 :
- 先擷取此原程式中最主要的部份,即射出粒子的程式碼,並讓粒子能超過vec(0,0,0)一段距離後就能消失。其他不需要的都先用alt+3忽略。
- 重新設定基本參數,包含萬有引力常數k,電荷電量與電荷質量等等,並且讓球射出的數量減少,調整螢幕大小。
- 讓射出的粒子加上軌跡
- 若以上設定均調整無誤,應該可以看到螢幕左側射出粒子,並於右側消失。

- 在原點畫出金原子,並定義庫倫力公式。
- 在執行迴圈處讓List內的電荷都會受到金原子庫倫力的作用。