NASA standard atmosphere

Post Reply
Henko
Posts: 814
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

NASA standard atmosphere

Post by Henko »

This function may be used in flight dynamics simulation.
It is used by the main program to present the data in the first 40 km. of altitude.
E35D28AA-9507-43F2-BA6F-ABBF44723666.png
E35D28AA-9507-43F2-BA6F-ABBF44723666.png (275.98 KiB) Viewed 8089 times
The code:

Code: Select all


graphics ! graphics clear .8,.8,.8
set orientation landscape ! set toolbar off
get screen size sx,sy
xo=80 ! dx=int((sx-xo-20)/40) ! xe=xo+40*dx
yo=20 ! dy=int((sy-yo-20)/20) ! ye=yo+20*dy
draw size 1 ! draw color .6,.6,.6
for x=xo to xe step dx ! draw line x,yo to x,ye ! next x
for y=yo to ye step dy ! draw line xo,y to xe,y ! next y
draw size 3 ! draw color 0,0,0
draw line xo,yo to xo,ye ! draw line xo,ye to xe,ye
draw font size 30 ! draw color 0,0,0
draw text "NASA standard atmosphere 0 - 40 km." at 240,20
draw font size 20 ! x=480
draw text "Temperature (degree Celcius)" at x,100
draw text "Pressure    (k-Pascal)"       at x,140
draw text "Density     (kg/m3)"          at x,180
draw size 2 ! x1=330 ! x2=460
draw color 0,0,.7 ! draw line x1,110 to x2,110
draw color 0,.5,0 ! draw line x1,150 to x2,150
draw color .7,0,0 ! draw line x1,190 to x2,190
draw font size 12 ! draw color 0,0,0
for i=0 to 40 step 2
  x=xo+i*dx ! draw text i at x-5,ye+10
  next i

' *** temperature graph ***
atm(0) ! scal=4 ! yo=20+(5-atm.t/scal)*dy
draw to xo,yo ! draw color 0,0,.7
for h=1000 to 40000 step 1000
  atm(h)
  stap=h/1000 ! x=xo+stap*dx ! y=20+(5-atm.t/scal)*dy
  draw line to x,y
  next h
for j=0 to 20
  draw text 20-j*scal at xo-26,14+j*dy
  next j

' *** pressure graph ***
atm(0) ! scal=5 ! yo=ye-atm.p/scal*dy
draw to xo,yo ! draw color 0,.5,0
for h=1000 to 40000 step 1000
  atm(h)
  stap=h/1000 ! x=xo+stap*dx ! y=ye-atm.p/scal*dy
  draw line to x,y
  next h
for j=0 to 20
  draw text 100-j*scal at xo-46,14+j*dy
  next j

' *** density graph ***
atm(0) ! scal=1.25/20! yo=ye-atm.d/scal*dy
draw to xo,yo ! draw color .7,0,0
for h=1000 to 40000 step 1000
  atm(h)
  stap=h/1000 ! x=xo+stap*dx ! y=ye-atm.d/scal*dy
  draw line to x,y
  next h
for j=0 to 20
  d=int(100*(1.25-scal*j))/100
  draw text d at xo-78,14+j*dy
  next j

do slowdown ! until touch_x(0)>0
set orientation portrait
end

' NASA standard atmosphere
'   input h in m.
'   returns density in kg/m3
'   get temperature with  atm.t in degrees Celcius
'   get pressure with     atm.p in K-Pa (Kilo-Pascal)
'   get density also with atm.d
'   1 K-Pa = 1000 N/m2 = 0,1 N/cm2 = 0,01 kg/cm2 = 
'   = 0,01 Bar = 10 mBar = 0,01 "old" Atmosphere
'
def atm(h)
to=273.1
if h<11000 then
  t=15.04-0.00649*h
  p=101.29*((t+to)/288.08)^5.256
  d=p/0.2869/(t+to)
  return d
  end if
if h<25000 then
  t=-56.46
  p=22.65*exp(1.73-0.000157*h)
  d=p/0.2869/(t+to)
  return d
  end if
t=-131.21+0.00299*h
p=2.488*((t+to)/216.6)^-11.388
d=p/0.2869/(t+to)
return d
end def

Post Reply