Created
April 25, 2020 01:10
-
-
Save SqrtRyan/fb3773d9484515e16cf98b4df5fd1797 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Ryan Burgert AMS326 HW3 Q1 Spring 2020 | |
| #My solution uses euler's method | |
| #Results: | |
| # Total travel time for vB = 7 is 4814.712 | |
| # Total travel time for vB = 14 is 822.863 | |
| # Total travel time for vB = 21 is 441.819 | |
| from math import cos,sqrt | |
| from rp import * | |
| def w(v0,x,a): | |
| return 4*v0*(x/a-x**2/a**2) | |
| def x_vel(vB,x,y): | |
| return -vB*(x/sqrt(x**2+y**2)) | |
| def y_vel(vB,x,y,v0,a): | |
| return -vB*(y/sqrt(x**2+y**2))+w(v0,x,a) | |
| def trajectory(vB, Δt, v0=14, a=7777): | |
| x=a | |
| y=0 | |
| yield x,y | |
| while x>0: | |
| Δx=Δt*x_vel(vB,x,y) | |
| Δy=Δt*y_vel(vB,x,y,v0,a) | |
| x+=Δx | |
| y+=Δy | |
| yield x,y | |
| def trial(vB, Δt=.001): | |
| path=list(trajectory(vB,Δt=Δt)) | |
| t=Δt*len(path) | |
| print('Total travel time for vB =',vB,'is',t) | |
| display_path(path) | |
| return path | |
| for vB in [7,14,21]: | |
| trial(vB) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment