Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Rocket Science
//all units are SI //INPUT var v=0;//start velocity var s=0;//start displacement var ts=1;//time step per calculation var md=1000;//dry mass var mf=100;//fuel mass var f=1;//fuel flow rate var Th=20000;//thrust (recommended total mass*10) var A=3.14;//cross-sectional area of rocket var Cd=0.25;//drag coeffecient of rocket var time=300;//how long to run the simulation //Calculation variables var a=0;//net acceleration var t=0;//time var p=0;//pressure var T=0;//absolute temp var L=0;//temperature lapse rate var h=0;//minimum height of band var b=0;//current band var pt=1;//pressure trigger if falling down var ac=0;//thrust acceleration var g=0;//gravitational acceleration var pa=0;//atmospheric drag for(t=0; t<time; t=t+ts){ if(0<=s){ if(s<11000){//band 0 b=0; T=288.15; h=0; L=-0.0065; p=101325*Math.pow((1-(L*s)/(T+L*s)), (0.0342/L)); } if(11000<=s&&s<20000){//band 1 b=1; T=216.65; h=11000; L=0; p=22632.1*Math.exp(-(0.0342*(s-h))/T); } if(20000<=s&&s<32000){//band 2 b=2; T=216.65; h=20000; L=0.001; p=5474.89*Math.pow((1-(L*(s-h))/(T+L*(s-h))), (0.0342/L)); } if(32000<=s&&s<47000){//band 3 b=3; T=228.65; h=32000; L=0.0028; p=868.02*Math.pow((1-(L*(s-h))/(T+L*(s-h))), (0.0342/L)); } if(47000<=s&&s<51000){//band 4 b=4; T=270.65; h=47000; L=0; p=110.91*Math.exp(-(0.0342*(s-h))/T); } if(51000<=s&&s<71000){//band 5 b=5; T=270.65; h=51000; L=-0.0028; p=66.94*Math.pow((1-(L*(s-h))/(T+L*(s-h))), (0.0342/L)); } if(71000<=s&&s<86000){//band 6 b=6; T=214.65; h=71000; L=-0.002; p=3.96*Math.pow((1-(L*(s-h))/(T+L*(s-h))), (0.0342/L)); } if(86000<=s){//band 6 b=7; T=386; p=0; h=s; } if(v<0){ pt=-1; } if(v>=0){ pt=1; } ac=(Th)/(md+mf-f*t); g=-3.98E14/(s*s+1.28E8*s+4.096E13); pa=-((p*v*v*A*Cd*0.00174)/(T+L*(s-h)))/(md+mf); if(t<(mf/f)&&s<86000){//If not empty and in atmosphere a=ac+g+pt*pa; //print("Still going, in atmosphere"); } if(t>=(mf/f)&&s<86000){//If empty and in atmosphere a=g+pt*pa; //print("free fall"); } if(t<(mf/f)&&s>=86000){//If not empty and out of atmosphere a=ac+g; //print("burning in space") } if(t>(mf/f)&&s>=86000){//If empty and out of atmosphere a=g; //print("free fall in space"); } print(t, a, v, s, p, b, pa*pt);//display s=s+0.5*ts*ts*a+ts*v;//s=s0+ut+0.5at^2 v=ts*a+v;//a=dv/dt } else{ print("Landed!"); } }
run
|
edit
|
history
|
help
0
strCompression
Prime Factors
10 bottles of juice
p
BinaryGap, javascript - Find longest sequence of zeros in binary representation of an integer.
An awkward iteration
говнокод
Palindrome
Iterator()-function
новинка