0

Trying to simulate an object plunging into atmosphere. It seems to work, until the velocity falls past terminal velocity... down to zero... and then back up!

Something must be wrong with how I am applying drag? I've looked at the code so long, I've managed to confuse myself.

Here I set variables/constants:

Mass = 5;                           //Object Mass
Radius = 7;                         //Radius of the blunt end facing the air stream (too sensitive!!!)
Area = power(Radius,2)*pi;          //The total area of the blunt end facing the air stream
Gravity = 9.8;                      //Earth
DragCoeff = 1.61;                   
Velocity = 10000;                   //Initial velocity straight down (vector needs to be added)
Acceleration = Gravity * (1/Mass);  //this is acceleration FORCE... subtract drag from this
Altitude = 100000;                  //initial altitude(meters) (atmosphere "begins" at 100Km)

Then, in the main loop of the program: (note, delta_time is provided by the system in microseconds from the last execution of the loop)

d_time = delta_time / 1000000;                                          //Convert delta_time to seconds    
AirDensity = 1.07* power(2.718,-.00005*Altitude);                       //How dense is the air right now?

TermVel = sqrt(2 * Mass * Gravity / AirDensity * Area * DragCoeff);     //Terminal Velocity at our altitude
Velocity = Velocity + Acceleration * d_time;                            //Acceleration added
Drag = 0.5 * AirDensity * sqr(Velocity)* DragCoeff * Area;              //Drag calculated
Velocity = Velocity - (clamp(Drag, 0, TermVel) * d_time);               //Drag subtracted
Altitude = Altitude - Velocity * d_time;                                //Update the position

Thanks ever so much for your kind help in understanding what I've done wrong here.

SS


Edit: Thanks, Jason... I think I have the correct changes made... but my mass of "5" was causing it to behave really poorly.... the velocity went way negative... so I increased the mass significantly, and it seems to behave better... I will explore it a bit more.

Does it look like I have it right?

Thank you again, ever so much.

SS

Tom 'Blue' Piddock
  • 3,637
  • 1
  • 27
  • 42
  • 1
    It seems you have made two accounts, can you simply use the one account as it will get confusing. – Tom 'Blue' Piddock Jul 17 '14 at 08:28
  • 1
    Also - just to note, you shouldn't update your question with the answer. That is why we have the answers section below. I'm going to revert the changes but leave your notes, otherwise future users visiting this question will have no clue what the original problem was. – Tom 'Blue' Piddock Jul 17 '14 at 10:05

1 Answers1

2

There are several errors here:

  1. There is not a 1/mass term in the drag calculation. Drag is a force, you need to divide by the mass to turn it into an acceleration before you apply it to the velocity.
  2. Acceleration due to gravity is 9.8m^2, regardless of mass. There is no 1/mass term here.
  3. You should not clamp drag to the terminal velocity. Drag is a force (or acceleration, if converted using F=ma) not a velocity. Clamp compares its arguments to each other, and it is simply meaningless to compare a velocity with a force/acceleration.
  4. As a corollary to the above, the terminal velocity is a phenomenon where the forces of gravity and air resistance balance. The simulation will converge to this velocity; you do not need to calculate it at any point. It should also be noted that terminal velocity doesn't really apply when objects fall from the edge of space: they build too much velocity early in the fall for drag to slow them down to their nominal terminal velocity before they smack into the ground. This is because the terminal velocity in the thinner atmosphere is much higher than that of the velocity in the lower atmosphere.
  5. You need to apply drag to the opposite direction of velocity, and ensure that the application of drag does not change the sign of velocity. Note this does not mean clamping drag to velocity, or to terminal velocity. It should be clear how to achieve this "no changing sign," but you will need to fix the other problems first.

It looks like you are trying to be physically accurate, which means this isn't really something you can construct yourself unless you understand the physics. You should find a physics reference and transcribe those equations rather than trying to synthesize your own.