Testing the physics / aerodynamics: terminal velocity.

Hi

Out of curiosity I made a small free falling object terminal velocity (Vt) test with constant atmosphere density.

I use Vt formula from wiki

Sphere.o_CalVt = sqrt((Sphere.o_mass * 9.81 * 2) / (Sphere.o_atm * Sphere.o_area * Sphere.o_cd ))

Set falling object data

Sphere.o_mass = Cube.getMass() # Give object mass in Logic-ui (F4)
Sphere.o_area = 0.005026548 # Cross area towards motion (m2)
Sphere.o_cd = 0.34 # Coefficiency of Drag for the ball

If your object don’t reach the Vt during the fall, then adjust the start height(Loc Z) from Tranform Properties ui.

The o_velocity: current velocity (ms)
The o_alt: current altitude (m/bu)
The o_MaxV: recorded max speed during simulation (ms)
The o_CalVt: calculated Vt (ms)

``````
import Blender
import Rasterizer
import math
from math import *

# #-----------------------------------------------------------------------------
# # get controllers
controller = GameLogic.getCurrentController() # get controller
Sphere = controller.getOwner() # get your object
acc1 = controller.getActuator("acc1") # Get sensor named

# #-----------------------------------------------------------------------------
# # Initialized
if hasattr (Sphere, 'int') == False:

Sphere.int=1

Sphere.o_atm = 1.21 # atmosphere density

# Set falling object data here!!!
Sphere.o_mass = Sphere.getMass() # Give object mass in Logic-ui (F4)
Sphere.o_area = 0.005026548 # Cross area towards motion (m2)
Sphere.o_cd = 0.34 # Coefficiency of Drag for ball

Sphere.o_drag = 0.0 # (N)
Sphere.o_velocity = 0.0 # (m/s)
Sphere.o_alt = 0.0 # (m)
Sphere.o_MaxV = 0.0    # (ms)
Sphere.o_CalVt = 0.0 # (ms)

# #-----------------------------------------------------------------------------
# # Get altitude
Sphere.o_alt = round(Sphere.getPosition()[2],0)

# #-----------------------------------------------------------------------------
# # Get current velocity
Sphere.o_velocity = (hypot((Sphere.getVelocity()[0]),(hypot((Sphere.getVelocity()[1]),(Sphere.getVelocity()[2]))))) # get true

if Sphere.o_MaxV &lt; Sphere.o_velocity:
Sphere.o_MaxV = Sphere.o_velocity

# #-----------------------------------------------------------------------------
# # Calculate Drag
Sphere.o_drag = (0.5 * Sphere.o_velocity**2 * Sphere.o_atm * Sphere.o_area * Sphere.o_cd )

# #----------------------------------------------------------------------------
# # Set forces
acc1.setForce(0.0,0.0,Sphere.o_drag ,0)

# #-----------------------------------------------------------------------------
# Calculated terminal velocity
Sphere.o_CalVt = sqrt((Sphere.o_mass * 9.81 * 2)/(Sphere.o_atm * Sphere.o_area * Sphere.o_cd ))

# #-----------------------------------------------------------------------------

``````

Attachments

Physics_falling_object_Vt.blend (155 KB)

Woah nice blend man XD Awesome script too, you only have to change the mass XD

So…
sorry, but you must explain in detail, for us, python ( and math) illiterates, please!
Anyway, nothing happens in the 3D window?!
It’s just the “returning values” that counts?!
Bye

Hi
There’s not too much to explain, because I’m not too good with python or bge myself.

So, there’s a Blender gravity force set to the 9.81, which pulls down the ball object faster and faster, because there’s no drag force. The ‘Dump’ value is set to the zero, btw.

This script just calculate the drag force, which is opposite to the direction of ball velocity vector.

The drag calculation based to the atmosphere density, ball mass, cross area size towards velocity, Coefficient of Drag (Cd) value and current velocity. The atmosphere density is constant in this case

As velocity increase, the drag increase and finally the drag force is equal with gravity force and velocity don’t increase anymore: Terminal Velocity (Vt).

In 3D view don’t happen too much. Only when ball hit to the ground level. The values are more import.

Actually the script had a unnecessary lines. I removed the Sphere.o_force ‘calculation’ part and put the Sphere.o_drag straight to the “acc1.setForce(0.0,0.0,Sphere.o_drag,0)”.

I’m working with next version which can demonstrate the falling hammer object, dropped shaft first or side ways attitude. This is a basically practising for the FDM4BGE.

Ok, thank you!

The .blend file is related to this