Search code examples
rubyphysicsgame-physics

Calculating current velocity of a falling object


I'm attempting to calculate the speed of a sky diver first with no chute and once deployed the object should decelerate until it reaches it's terminal velocity again. However in attempting this I've ran into some problems.

  • First of the maximum calculated velocity seems to have a higher max than the terminal velocity I calculate for it.
  • Secondly when decelerating (e.g. the cross_sectional_area is increase and/or the drag_coefficient) the drag force explodes! It gets so big that the player is probably rocketed into space if not completed squashed.

Code:

drag_coefficient     = 1.5.to_f
mass                 = 100.to_f
cross_sectional_area = 0.7.to_f
GRAVITY              = 9.8.to_f 
density              = 1.2690.to_f # Air density
  def terminal_velocity
    ((2.to_f * mass * GRAVITY / (density * drag_coefficient * cross_sectional_area)) ** 0.5.to_f).to_f
  end

  # Air resistance in N
  def drag_force
    (0.5.to_f * drag_coefficient * density * cross_sectional_area * @velocity) ** 2
  end

  # Delta time in seconds
  def tick(delta_time)
    @velocity += (acceleration * delta_time)
  end

  # Acceleration in m/s
  def acceleration
    (gravitational_force - drag_force) / mass
  end

  # Gravitational force in N
  def gravitational_force
    mass * GRAVITY
  end

I've been looking into good sources for this but it's either quite dense on the Maths or it's totally oversimplified.

Edit: Just squared the velocity and this is what I get and it looks a lot better. (Thanks PinnyM!!)

Using these variables (Calculated with a 20ms tick but only plotted the whole second values):

GRAVITY              = 9.8
drag_coefficient,    = 1.1
mass                 = 100
cross_sectional_area = 0.7
density              = 1.2690.to_f

http://savedbythegoog.appspot.com/?id=5cbe34730e3b56ec97d961704e636bab5da58225

I get the above graph for the acceleration and velocity which seem fine but there is an obvious disconnect between the terminal velocity and the velocity reached by the calculations.

Now at t=40 I change the drag_coefficient and the cross_sectional_area(Which should be a function of t to simulate the opening of the parachute but for testing I've just used a constant value). The changed variables:

drag_coefficient,    = 1.9
cross_sectional_area = 35.0

I get the following graph (Smaller t increase as the deceleration is insane): http://savedbythegoog.appspot.com/?id=fed3506199191043e94a27060dffc95800c70152

That means he's decelerating in .5 seconds which seems way too high. Is this just because the opening of the parachute is a function of t or am I missing something still. Any pointers/help is much appreciated.

Edit: inlined and simplified code. Original Gist: https://gist.github.com/anonymous/29e1ed08ad4e0d7d28a0


Solution

  • There are a number of problems here.

    First off, your drag coefficient is rather high. Anything over one is high. A poorly designed parachute can have a drag coefficient that exceeds unity. A value of 1.5? "Poorly designed" doesn't even come close to describing how poorly designed that parachute is. A well designed parachute will have a Cd of about 0.75 to 0.9.

    Secondly, your parachutist is opening his or her chute on a very cold day at the very bottom of Death Valley. The density of air at sea level at 15 C (~60 F) is 1.225 kg/m3. Air density drops rather drastically with increased altitude. If you were using some mathematically inclined language I could point you to a fairly decent model of how pressure, density, and temperature vary with altitude. Google the phrase "standard atmosphere 1976".

    There's one minor problem here: You are using ruby. I can't find an implementation of the standard atmosphere model in ruby. If you are mathematically inclined (the math is not that hard), you might want to write a ruby implementation of the standard atmosphere model. Or just stick with a density of 1.225 kg/m3. Don't use 1.269 kg/m3.

    Thirdly, and most importantly, parachutes don't instantly open and expose a drag area of 35 m2. It takes some time for the parachute to fully open. If the parachutist is falling rapidly, that deployment time lag might not be enough. Accelerations above 10g (~981 m/sec2) can be deadly. Those parachutists who love to free fall for a length of time prior to opening their chutes have parachutes that involve a pilot chute (aka a drogue chute) and a main chute. The pilot chute opens the main parachute, but along the way it slows the parachutist down a bit.

    Finally, your numerical integration is Euler's method. Understanding how Euler's method works is essential to understanding the basics of numerical solution of an initial value problem. Once you understand what it's doing and how it works is the moment you should toss it. Euler's method yields rather bad results.