air resistance (drag) - physics

edited January 2014 in Programming Questions

A friend of a friend does parachute free falls. He told us that he can feel the acceleration for about 4 seconds. From then on, it's not that exciting (he says).
I did some thought on the matter, and have come up with a problem...
Suppose that:
-There is a physical body with a given mass and size (and shape), and it is inside a gas (atmosphere) of a steady and homogeneous composition.
-There is a steady Force applied to that body (for example gravity)

implications:
1) the body will start accelerating according to its mass and the gravitational Force... (a = F/m)
2) As the body acclerates, its speed grows... 3) the drag "http://en.wikipedia.org/wiki/Drag_(physics)" is proportionate to the measure of speed, but with an opposite direction.
4)This creates a dynamic relation, which leads to a maximum possible speed for the movement of the body.

image alt text

However, my problem lies on the computational approach of the above.

If there was no drag, things would be simple:

////////////////NO DRAG CASE////////////////
PVector pos; //position
PVector vel; //velocity
PVector force; //force
PVector acc; //acceleration
float mass; // mass

[...]

acc.set(Force);
acc.div(mass); // a = F / m
vel.add(acc);
pos.add(vel);
////////////////////////////////
and that's about it..

However, in the case that we have a drag, things are abit more complicated...

///////////////DRAG CASE 1/////////////////
PVector pos; //position
PVector vel; //velocity
PVector force; //force
PVector acc; //acceleration
float mass; // mass
float sizeFactor; //size

[...]

drag.set(vel);
drag.mult(-1); //drag has an opposite direction from speed
drag.mult(sizeFactor);
force.add(drag);
acc.set(Force);
acc.div(mass); // a = F / m
vel.add(acc);
pos.add(vel);
////////////////////////////////
Drag is calculated by the previous measure of Speed, and affects its current state.
This sounds problematic...

///////////////DRAG CASE 2/////////////////
PVector pos; //position
PVector vel; //velocity
PVector force; //force
PVector acc; //acceleration
float mass; // mass
float sizeFactor; //size

[...]

acc.set(Force);
acc.div(mass); // a = F / m
vel.add(acc);
drag.set(vel);
drag.mult(-1); //drag has an opposite direction from speed
drag.mult(sizeFactor);
force.add(drag);
acc.set(Force);
acc.div(mass); // a = F / m
vel.add(acc);
pos.add(vel);
////////////////////////////////

In this case I aplied the force to get acceleration and speed, then used that speed to calculate the drag that it would create, then subtracted this drag from the Force, and reapplied the new Force to get the (allowed) speed. However, the speed that created the drag that I used actually never existed... And this seems problematic.

Both cases "work", but I was wondering if any of them is the "right one"...
Any thoughts on the matter, or any reference to a similar application of this problem would be greatly appreciated.

Thanks in advance, Kostas

Answers

  • edited January 2014

    Ok, this might seem complicated, so here is a working piece of code...

        PVector pos;
        PVector vel;
        PVector acc;
        PVector force;
        PVector drag;
        float mass;
        float size; //cross-section size
        float dcf; //drag coefficient
        float adt; //air density
        float vms; //velocity measure
        float dragFactor;
    
        void setup(){
          size(800,400);
          pos = new PVector(0,200);
          vel = new PVector(0,0);
          acc = new PVector(0,0);
          force = new PVector(1,0);
          drag = new PVector(0,0);
          dcf = 0.47; //drag coeficient for sphere = 0.47
          adt = 1.2; //air density
          size = 2; //cross-section size
          mass = 25;
    
        }
    
        void draw(){
          background(0);
          //////////////////////////////
          drag1(); //change this to noDrag or drag2 to see the difference
          /////////////////////////////
          noStroke(); fill(255);
          ellipse(pos.x,pos.y,size*3,size*3);
        }
    
        void noDrag(){
          acc.set(force);
          acc.div(mass);
          vel.add(acc);
          pos.add(vel);
        }
    
        void drag1(){
          force.set(1,0,0);
          vms = vel.mag();
          //Fd = 0.5 * adt * vms^2 * dcf * size
          drag.set(-0.5*adt*pow(vms,2)*dcf*size,0,0);
          force.add(drag);
          acc.set(force);
          acc.div(mass);
          vel.add(acc);
          pos.add(vel);
        }
    
        void drag2(){
          force.set(1,0,0);
          acc.set(force);
          acc.div(mass);
          vel.add(acc);
          vms = vel.mag();
          //Fd = 0.5 * adt * vms^2 * dcf * size
          drag.set(-0.5*adt*pow(vms,2)*dcf*size,0,0);
          force.add(drag);
          acc.set(force);
          acc.div(mass);
          vel.add(acc);
          pos.add(vel);
        }
    

    And the question is if "drag1()" or "drag2()" is computationally correct... Or if none of them is... (I suppose they can't be both)

  • edited January 2014 Answer ✓

    I think drag1() is correct. According to Newton's second law, acceleration equals the sum of all forces divided by mass. But in drag2, you added gravity to the velocity, and then the combination of gravity and drag, thus taking gravity twice into account. But if drag and gravity are equal in magnitude (as is the case when you reached terminal velocity as your friend describes, ie you are going so fast the drag equals gravity and you don't accelerate), the velocity should remain constant.

    Maybe you can add some kind of visualisation to the sketch (a simple speed gauge of some sort) to check if the physics are correct.

  • No, I guess you are right... I got abit confused with all that. Actually drag1 works, because when the speed reaches its maxLimit, it will produce a Drag equal to the Force, and so no more acceleration... (Quite obvious, but I was in a mental loop...)
    Thanks!

Sign In or Register to comment.