I am simulating a free fall with a function that needs to calculate the time it takes for a particular object to reach the surface, I got this program working without accounting for air resistance.. the force of air resistance(drag) is: 0.24 * v^2

Im not sure what I'm doing wrong or how I can make it work, any help would be appreciated

def jump():

    t = 0
    dt = 0.01
    v = 0
    x = 728   #starting height
    a = 9.8
    while x > 0:
        x = x - v*dt
        t = t + dt
        a = 9.8 - 0.24*(v**2)*dt #drag coefficient and calculation
        v = v + a*dt 

    return round(t, 1)

result = jump()

Output: 15.9 seconds, but it needs to be 17.2. Maybe its going wrong with the velocity updating after the acceleration?

  • 1
    $\begingroup$ Why is there a dt in the acceleration equation? $\endgroup$ – Brain Stroke Patient Oct 10 at 9:11
  • $\begingroup$ Good question.. I didnt have this before, but I saw it somewhere in someones code with a similar issue , turns out it does come closer to the answer $\endgroup$ – Casper A Oct 10 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.