WaBis

walter.bislins.ch

Script: airspeed limits 2

JavaScript Code zum Generieren des Graphen von Bild: airspeed limits 2.png.

#INCLUDE JsGraph.inc

<jscript>
// some constants
var Rs = 287.05; // J/kg/K
var Grav = 9.80665; // m/s^2
var Kappa = 1.4; 
var Kappa_ = 0.4;

var Mach1 = 1;
var MachLimit = 0.82;
var MachSel = 0.76;
var MaxIAS = 340;
var MaxSelIAS = 300;
var StallIAS = 180;
var CleanIAS = 220;
var MinSelIAS = 260;
var MachIASx = 26000;
var SelMachIASx = 28000;
var CoffinSel = 34500;
var CoffinCorner = 45400;

var xmin1 = 0; // ft
var xmax1 = 48500; // ft
var ymin1 = 0; // kt
var ymax1 = 750; // kt
var xinc  = 500; // ft

g1 = NewGraph2D( { Id: 'graph', Width: 650, Height: 500, BorderColor: 'blue' } );

g1.SetTextAttr( 'Arial', 16, 'black', 'bold', '', 'center', 'top' );
g1.Text( 'Fluggeschwindigkeiten und Limits', 325, 500 );

g1.SetTextAttr( 'Arial', 12, 'black', 'bold', '', 'center', 'top' );
g1.Text( 'TAS', 15, 500 );
g1.SetFontWeight( 'normal' );
g1.Text( '[kt]', 15, 486 );

g1.SetTextAttr( 'Arial', 12, 'black', 'bold', '', 'right', 'top' );
g1.Text( 'ALT', 648, 22 );

g1.SetViewport( 30, 20, -10, -25 );
g1.SetWindow( xmin1, ymin1, xmax1, ymax1 );
g1.SetAlpha( 0.3 );
g1.SetLineAttr( '#DDD', 1 );
g1.Grid( 1000, 20, true, false );
g1.SetLineAttr( '#AAA', 1 );
g1.Grid( 5000, 100, true, false );
g1.SetAlpha( 1 );
g1.SetLineAttr( 'black', 1 );
g1.TicsX( 0, 5000, 6, 0, true, false );
g1.TicsY( 0, 100, 6, 0, true, false );
g1.SetTextAttr( 'Arial', 12, 'black', '', '', 'center', 'middle' );
g1.TicLabelsX( 0, 5000, -3, 0.01, 0, false, false, 'FL (#)' );
g1.TicLabelsY( 0, 100, -3, 1, 0, true, false );
g1.SetLineAttr( 'black', 2 );

g1.SetTextAttr( 'Arial', 20, 'black', 'bold', '', 'center', 'top' );
g1.Text( 'TAS = <em>f</em> ( IAS, ALT )', 15000, 680 );

g1.SetTextAttr( 'Arial', 20, 'red', 'bold', '', 'center', 'top' );
g1.Text( 'Structure Limit', 15000, 580 );
g1.Text( 'Stall Limit', 32500, 160 );

g1.SetTextAttr( 'Arial', 12, 'black', '', '', 'center', 'middle' );

// compute some limits
// mach limit and IAS limit
var xArr = [];
var yArr = [];
var x = 0; // ft
var y;
var i = 0;
while (x <= xmax1 + xinc/2) {
    y = ms_kt( TAS_h_CAS( ft_m(x), kt_ms(MaxIAS) ) );
  xArr[i] = x;
  yArr[i] = y;
  x += xinc;
  i++;
}
// draw upper limit range
g1.OpenPath();
g1.Polygon( xArr, yArr );
g1.LineTo( xmax1, ymax1 );
g1.LineTo( xmin1, ymax1 );
g1.SetBgColor( 'red' ); 
g1.SetAlpha( 0.1 );
g1.Path( 6 );
g1.SetAlpha( 1 );

// stall limit
var x = 0; // ft
var y;
var xArr = [];
var yArr = [];
var i = 0;
while (x <= xmax1 + xinc/2) {
  y = ms_kt( TAS_h_CAS( ft_m(x), kt_ms(StallIAS) ) );
  xArr[i] = x;
  yArr[i] = y;
  x += xinc;
  i++;
}
// draw lower limit range
g1.OpenPath();
g1.Polygon( xArr, yArr );
g1.LineTo( xmax1, ymin1 );
g1.LineTo( xmin1, ymin1 );
g1.SetBgColor( 'red' ); 
g1.SetAlpha( 0.1 );
g1.Path( 6 );
g1.SetAlpha( 1 );

// KIAS line grid
var CAS = 0; // kt
while (CAS <= 360) {
  var x = 0; // ft
  var y;
  var xArr = [];
  var yArr = [];
  var i = 0;
  while (x <= xmax1 + xinc/2) {
    y = ms_kt( TAS_h_CAS( ft_m(x), kt_ms(CAS) ) );
    xArr[i] = x;
    yArr[i] = y;
    x += xinc;
    i++;
  }
  g1.SetLineAttr( '#AAA', 1 );
  g1.Polygon( xArr, yArr );
  CAS += 20;
}

// struct limit line
var x = 0; // ft
var y;
var xArr = [];
var yArr = [];
var i = 0;
while (x <= xmax1 + xinc/2) {
  y = ms_kt( TAS_h_CAS( ft_m(x), kt_ms(MaxIAS) ) );
  xArr[i] = x;
  yArr[i] = y;
  x += xinc;
  i++;
}
g1.SetLineAttr( 'red', 2 );
g1.Polygon( xArr, yArr );

// stall limit line
var x = 0; // ft
var y;
var xArr = [];
var yArr = [];
var i = 0;
while (x <= xmax1 + xinc/2) {
  y = ms_kt( TAS_h_CAS( ft_m(x), kt_ms(StallIAS) ) );
  xArr[i] = x;
  yArr[i] = y;
  x += xinc;
  i++;
}
g1.SetLineAttr( 'red', 2 );
g1.Polygon( xArr, yArr );


g1.SetLineAttr( 'black', 2 );
g1.Frame();

// ----------------------------------------------------- text

g1.SetLineAttr( 'red', 1 );
var x = 12500;
var y = ms_kt( TAS_h_CAS( ft_m(x), kt_ms(MaxIAS) ) );
label( x, y, MaxIAS + ' KIAS', x+3000, y-10, 'l' );

g1.SetLineAttr( 'red', 1 );
var x = 12500;
var y = ms_kt( TAS_h_CAS( ft_m(x), kt_ms(StallIAS) ) );
label( x, y, StallIAS + ' KIAS', x+3000, y-10, 'l' );

function label( x, y, text, tx, ty, al ) {
  var box = g1.GetTextBox( text, tx, ty );
  g1.Line( box.x, box.y, box.x+box.w, box.y );
  if (al == 'l') {
    g1.Line( box.x, box.y, x, y );
  } else {
    g1.Line( box.x+box.w, box.y, x, y );
  }
  g1.Text( text, tx, ty );
}

// ----------------------------------------------------- formeln

function T_ref(h) { return (h<11000) ? 288.15 : 216.65; }
function alpha(h) { return (h<11000) ? -0.0065 : 0.0; }
function h_ref(h) { return (h<11000) ? 0.0 : 11000.0; }
function rho_ref(h) { return (h<11000) ? 1.225 : 0.364; }
function p_ref(h) { return (h<11000) ? 101325 : 22632; }

function ms_kt( v ) {
  return v * 1.944;
}

function kt_ms( v ) {
  return v / 1.944;
}

function ft_m( h ) {
  return h * 0.3048;
}

function T_h( h ) {
  return T_ref(h) + alpha(h) * (h - h_ref(h));
}

function TAS_Ma_h( Ma, h ) {
  var T = T_h(h);
  return Ma * Math.sqrt( Kappa * Rs * T );
}

function qc_h_v( h, v ) {
  var x = ((Kappa_ * rho_h(h)) / (2 * Kappa * ps_h(h))) * v * v + 1;
  x = Math.pow( x, Kappa/Kappa_) - 1;
  return ps_h(h) * x;
}

function v_h_qc( h, qc ) {
  var ps = ps_h(h);
  var x = (qc / ps) + 1;
  x = Math.pow( x, Kappa_ / Kappa ) - 1;
  x = ((2 * Kappa * ps) / (Kappa_ * rho_h(h))) * x;
  return Math.sqrt( x );
}

function CAS_h_v( h, v ) {
  var qc = qc_h_v( h, v );
  return v_h_qc( 0, qc );
}

function TAS_h_CAS( h, cas ) {
  var qc = qc_h_v( 0, cas );
  return v_h_qc( h, qc );
}

function ps_h( h ) {
  if (h < 11000) {
    var beta = Grav / (Rs * alpha(h));
    var x = 1 + ((alpha(h) * (h - h_ref(h))) / T_ref(h));
    return p_ref(h) * Math.pow( x, -beta );
  }
  else {
    var hs = Rs * T_ref(h) / Grav;
    var x = (h - h_ref(h)) / hs;
    return p_ref(h) * Math.exp( -x );
  }
}

function rho_h( h ) {
  if (h < 11000) {
    var beta = Grav / (Rs * alpha(h));
    var x = 1 + ((alpha(h) * (h - h_ref(h))) / T_ref(h));
    return rho_ref(h) * Math.pow( x, -beta-1 );
  }
  else {
    var hs = Rs * T_ref(h) / Grav;
    var x = (h - h_ref(h)) / hs;
    return rho_ref(h) * Math.exp( -x );
  }
}

</jscript>

Weitere Infos zur Seite
Erzeugt Dienstag, 26. Januar 2010
von wabis
Zum Seitenanfang
Geändert Samstag, 10. September 2016
von wabis