TransWikia.com

Using air resistance (drag) in Python calculation

Physics Asked by Casper A on January 16, 2021

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()
print(result)

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

One Answer

You have not factored in mass: you state in your question that the force of drag is 0.24*v^2. In your code, however, you use this as an acceleration, applying it alongside the 9.8 from gravity. This only works if the mass is one kilogram.

Modifying your function to take mass as an argument:

def jump(mass):

    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)/mass #drag coefficient and calculation
        v = v + a*dt 
        

    return round(t, 1)

If we parse mass as 0.73 kg, we get

>>> jump(0.73)
17.2

Answered by Flight_101 on January 16, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP