# What is wrong with my model of aerodynamic drag?

I am creating a JavaScript program which simulates fireworks in a 2-dimentional context launching from the ground and exploding somewhere in mid-air.

The program takes into account gravity and drag, but something is wrong with the way I am calculating acceleration due to drag.

Observe these animations:

My implementation of drag physics is producing an undesired, physically inaccurate "square" effect, where particles seem to have a different drag depending on the direction in which they are traveling (the more parallel they are to either the x or y axis, the greater the drag — with the least drag at a 45° angle from either axis). If I turn the drag "off", the firework particles explode evenly in all directions, as they should.

My calculations of acceleration due to drag are based on the following equations:

And these are the snippets of code in the program that I believe are relevant to the problem (However, please feel free to audit the entire source code on GitHub: github.com/foxyjacob/vulcan):

function calculateAccelerationDueToDrag(fluidDensity, dragCoefficient, crossSectionalArea, speed, mass) {

let acceleration = -(0.5 * fluidDensity * dragCoefficient * crossSectionalArea * (speed * speed)) / mass;

if (speed < 0) {
acceleration = -acceleration;
}

return acceleration;

}


...

let accelerationDueToDrag = [
calculateAccelerationDueToDrag(
AIR_DENSITY,
this.dragCoefficient,
this.crossSectionalArea,
lastVelocity,
this.mass
),

calculateAccelerationDueToDrag(
AIR_DENSITY,
this.dragCoefficient,
this.crossSectionalArea,
lastVelocity,
this.mass
)
];


Essentially, I am calculating each particle's acceleration, velocity, and position on the x and y axes independently.

Why is my model of drag producing this strange "square" effect?

• Would Computational Science be a better home for this question? – Qmechanic Feb 8 '18 at 21:52
• You should probably move this question to CompSci as Qmechanic suggests. However, it looks like you're calculating the magnitude drag force incorrectly. Its magnitude depends on the total magnitude of the velocity, not of either component separately. From there, you would resolve it into its components. – J. Murray Feb 8 '18 at 22:03

With a drag force proportional to velocity$^2$, you can't do the calculations for the $x$ and $y$ directions separately. $$\vec{D} = -k|\vec{v}|^2\hat{v} = -k|\vec{v}|\vec{v}$$ Therefore, $$D_{x} = -k\sqrt{v_x^2 + v_y^2}\ v_x$$ You can't just send the $x$-component of the velocity of the projectile to to the function to get the $x$-component of the drag force. Your calculateAccelerationDueToDrag() function needs to have inputs for both velocity components for both drag components.