Skip to content

Instantly share code, notes, and snippets.

@javisantana
Created October 15, 2012 09:51
Show Gist options
  • Save javisantana/3891753 to your computer and use it in GitHub Desktop.
Save javisantana/3891753 to your computer and use it in GitHub Desktop.
redbull stratos fall simulation
// redbull stratos fall simulation
// node fall.js > fall.json
//
// port to js from python by @pybonacci
// more info: http://pybonacci.wordpress.com/2012/10/15/el-salto-de-felix-baumgartner-en-python/
//
// >> [ std_atm.alt2density(h, alt_units='m', density_units='kg/m**3') for h in xrange(0, 43000, 1000)]
// air density each 1000 meters
var AIR_DENSITY = [1.225, 1.1116425767380347, 1.0064902527218418, 0.9091220810460088, 0.8191294202172186, 0.7361158590983954, 0.6596971404886504, 0.5895010832794331, 0.5251675031230921, 0.4663481315454516, 0.41270653342889785, 0.3639180227868754, 0.3108281589022067, 0.2654832635841079, 0.22675346883692057, 0.19367373647373748, 0.16541981206327336, 0.14128768681425868, 0.1206760556449457, 0.10307133434187116, 0.08803486247736621, 0.07487366111494297, 0.06372734460638993, 0.05428027105802167, 0.046267360336640966, 0.039465817649795336, 0.03368824062938579, 0.02877687388504317, 0.024598816068418232, 0.021042018277291016, 0.018011940446444, 0.01542875529531276, 0.013225008308169557, 0.011261986276505282, 0.0096088887240681, 0.00821392101750628, 0.007034412466278842, 0.0060351284310494364, 0.005186909284991773, 0.004465570167211259, 0.0038510093666613036, 0.0033264840369233825, 0.0028780204548397533];
var ALTITUDE = 39000;
var h = ALTITUDE;
var time = 0;
var velocity = 0;
var g = 9.81;
var C_D = 0.4;
var A = 1.0; // m^2
var m = 80 + 20; // kg: body + backpack
// return air density for altitude
function rho(h) {
var i0 = Math.floor(h/1000);
var i1 = i0 + 1;
var r0 = AIR_DENSITY[i0];
var r1 = AIR_DENSITY[i1];
var t = (h - i0*1000)/1000;
var d = (1 -t)*r0 + t*r1;
return d;
}
var data = [];
function step(dt) {
velocity += dt*(-g + rho(h) * velocity * velocity * C_D * A / (2 * m));
h += velocity*dt;
data.push({
altitude: h,
velocity: velocity,
time: time
});
time += dt;
}
while (h>0) {
step(0.5);
}
console.log(JSON.stringify(data));
@jatorre
Copy link

jatorre commented Oct 15, 2012

Ufff. This is not taking in consideration that the air density changes at different altitudes, and that at a certain altitude he opened his parachute, and therefore the acceleration and speed is not constant. That must be hard, but we have some control points. We know that at certain altitudes the speed was some specific, for example when he broke the speed of sound, and when he opened the parachute. Those could be used to create the function.

@jatorre
Copy link

jatorre commented Oct 15, 2012

For example: "If calculations prove to be accurate, and Felix is successful in his attempts to control his position, he will accelerate from standstill to the speed of sound - that's 0 to approximately 690 miles per hour in 40 seconds or less."

Taken from http://www.redbullstratos.com/science/speed-of-sound/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment