This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I am working on a problem involving a car following another car. The leading car decelerates at a rate of 3 mi/s^2 until it comes to a complete stop. To save time from writing everything, I just included the variables down below.
The given 2nd order ODE is:
(x_fc - x_lc)* (d^2x_fc/dt^2) k* (dx_fc/dt) - k*v_lc = 0
dx_fc/dt = v_fc = v_fco
x_fc(t=0) = x_fco
# leading car, lc
# following car, fc
# initial speed, mph
v_lc = 30
v_fc = 30
# deceleration of lc
da_lc = -3 #mi/s^2
v_lc = 0
# sensitivity constant, k (mph)
k = 17
# length of car, l (ft)
l = 15
# distance from front of leading to front of following, d (ft)
d = 500
# average length of car, x (ft)
x_lc = 15
x_fc = 15
def dxfc_dt(t,y):
x_fc = y[0]
v_fc = y[1]
return [v_fc,k*(v_lc - v_fc)/(x_fc - x_lc)]
time = np.linspace(0,500,100)
z2 = solve_ivp(dxfc_dt,[0,0],time)
I believe I am on the right track but am confused with how to include some of the variables into the code. How do I include the distance between the cars, their average length, and the lead car's deceleration rate?
Subreddit
Post Details
- Posted
- 3 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/learnpython...