Ejemplo n.º 1
0
    def test_02(self):

        # 400 kt at 30000, temp -70 deg F
        # truth value from NASA RP 1046 + correction for non-standard temp

        Value = A.cas2tas(400, 30000, -70, temp_units='F')
        Truth = 586.266
        self.assertTrue(RE(Value, Truth) <= 3e-5)
Ejemplo n.º 2
0
    def test_01(self):

        # 400 kt at 30000, std temp
        # truth value from NASA RP 1046

        Value = A.cas2tas(400, 30000)
        Truth = 602.6
        self.assertTrue(RE(Value, Truth) <= 3e-5)
Ejemplo n.º 3
0
    def test_02(self):

        # 400 kt at 30000, temp -70 deg F
        # truth value from NASA RP 1046 + correction for non-standard temp

        Value = A.cas2tas(400, 30000, -70, temp_units='F')
        Truth = 586.266
        self.failUnless(RE(Value, Truth) <= 3e-5)
Ejemplo n.º 4
0
    def test_01(self):

        # 400 kt at 30000, std temp
        # truth value from NASA RP 1046

        Value = A.cas2tas(400, 30000)
        Truth = 602.6
        self.failUnless(RE(Value, Truth) <= 3e-5)
Ejemplo n.º 5
0
def climb_data(prop, weight = 1800., alt_max = 20000., TO_fuel = 0, TO_dist = 0, \
    fuel_units = 'USG', alt_interval = 500., isa_dev = 0, temp_units = 'C', \
    rv = '8', wing_area = 110., pwr = 'max', pwr_factor=1.0, \
    climb_speed = 'max', output = 'raw'):
    """
    Returns a table of climb performance vs altitude.

    The items in each row of the table are altitude, time, fuel burned and distance.
    Time is in units of minutes, rounded to the nearest half minute.
    Fuel units are selectable, with a default of USG.
    Distances are in nm.
    
    The output may be specified as raw, latex (a LaTeX table for the POH), or array.
    
    pwr may be 'max', 'cc' (cruise climb = 2500 rpm and 25") or 2500 (2500 rpm and full throttle)
    climb_speed may be 'max' (Vy), 'cc' (120 kt to 10,000 ft, then reducing by 4 kt/1000 ft) or
                'norm' (100 kt to 10,000 ft, then reducing by 2 kt/1000 ft)
                
    Note: compared cruise range for all climb speed and power.  The predicted results are all 
          within 1.5 nm of range.  Thus there is no advantage to using anything but Vy and max
          power.
    """
    def _alt2ROC(prop, alt):
        """
        calculate ROC for an altitude
        """
        temp = SA.isa2temp(isa_dev, alt)
        calc_pwr = alt2pwr(alt, rpm = rpm, MP_max = MP_max, temp = temp) * pwr_factor
        cas = alt2roc_speed(alt, climb_speed = climb_speed)
        eas = A.cas2eas(cas, alt)
        ROC = roc(prop, alt, eas, weight, calc_pwr, rpm, rv = rv, \
            wing_area = wing_area)
        
        return ROC
    
    alt = 0
    time = 0
    fuel_used = U.avgas_conv(TO_fuel, from_units = fuel_units, to_units = 'lb')
    weight = weight - fuel_used
    dist = TO_dist
    if pwr == 'max':
        # rpm = 2700
        rpm = 2650
        MP_max = 30
    elif pwr == 'cc':
        rpm = 2500
        MP_max = 25
    elif pwr == 2500:
        rpm = 2500
        MP_max = 30
    else:
        raise ValueError, "pwr must be one of 'max', 'cc', or 2500"
    

    if output == 'raw':
        print S.center('Altitude', 10),
        print S.center('ROC', 10),
        print S.center('Time', 10),
        print S.center('Fuel Used', 10),
        print S.center('Dist', 10),
        print S.center('Speed', 10)
        
        print S.center('(ft)', 10),
        print S.center('(ft/mn)', 10),
        print S.center('(mn)', 10),
        f_units = '(' + fuel_units + ')'
        print S.center(f_units, 10),
        print S.center('(nm)', 10),
        print S.center('(KCAS)', 10)
        
        # data for MSL
        print S.rjust(locale.format('%.0f', 0, True), 7),
        # calculate ROC at MSL
        print S.rjust(locale.format('%.0f', round(_alt2ROC(prop, 0) / 10.) * 10, \
            True), 10),
        print S.rjust('%.1f' % (0), 10),
        print S.rjust('%.1f' % (TO_fuel), 10),
        print S.rjust('%.1f' % (TO_dist), 10),
        print S.rjust('%3d' % (alt2roc_speed(0, climb_speed = climb_speed)), 10)

    elif output == 'latex':
        temp = 15 + isa_dev
        MSL_line = []
        MSL_line.append(str(locale.format('%.0f', weight, True)))
        MSL_line.append('0')
        MSL_line.append(str(locale.format('%.0f', temp)))
        MSL_line.append(str(locale.format('%.0f', alt2roc_speed(0, \
            climb_speed = climb_speed))))
        MSL_line.append(str(locale.format('%.0f', round(_alt2ROC(prop, 0) / 10.)\
          * 10, True)))
        MSL_line.append('0')
        MSL_line.append(str(TO_fuel))
        MSL_line.append(str(TO_dist))
        
        print '&'.join(MSL_line) + '\\\\'
        print '\\hline'
    elif output == 'array':
        # no header rows, but make blank array
        array = [[0,0,TO_fuel,0]]
        
    calc_alt = alt_interval / 2.
    while calc_alt < alt_max:
        temp = SA.isa2temp(isa_dev, calc_alt)
        pwr = alt2pwr(calc_alt, rpm = rpm, MP_max = MP_max, temp = temp)
        calc_pwr = pwr * pwr_factor
        cas = alt2roc_speed(calc_alt, climb_speed = climb_speed)
        eas = A.cas2eas(cas, calc_alt)
        tas = A.cas2tas(cas, calc_alt, temp = temp, temp_units = temp_units)
        tas_fts = U.speed_conv(tas, from_units = 'kt', to_units = 'ft/s')
        ROC = roc(prop, calc_alt, eas, weight, calc_pwr, rpm, rv = rv, \
            wing_area = wing_area)
        roc_fts = ROC / 60
        fuel_flow = IO.pwr2ff(pwr, rpm, ff_units = 'lb/hr')
        slice_time = alt_interval / roc_fts
        slice_dist = tas_fts * slice_time
        slice_fuel = fuel_flow * slice_time / 3600
        fuel_used += slice_fuel
        fuel_out = (U.avgas_conv(fuel_used, from_units = 'lb', \
            to_units = fuel_units))
        weight -= slice_fuel
        alt += alt_interval
        cas_out = alt2roc_speed(alt, climb_speed = climb_speed)
        temp_out = SA.isa2temp(isa_dev, alt)
        ROC = _alt2ROC(prop, alt)
        time += slice_time / 60
        dist += slice_dist / 6076.115

        if output == 'raw':
            print S.rjust(locale.format('%.0f', alt, True), 7),
            # calculate ROC at the displayed altitude
            print S.rjust(locale.format('%.0f', ROC, True), 10),
            print S.rjust('%.1f' % (time), 10),
            print S.rjust('%.1f' % (fuel_out), 10),
            print S.rjust('%.1f' % (dist), 10),
            print S.rjust('%3d' % (int(cas_out)), 10)
        elif output == 'latex':
            line = []
            line.append(str(locale.format('%.0f', alt, True)))
            line.append(str(locale.format('%.0f', round(temp_out))))
            line.append(str(locale.format('%.0f', cas_out)))
            line.append(str(locale.format('%.0f', round(ROC / 10.) * 10, True)))
            line.append(str(locale.format('%.0f', time)))
            line.append(str(locale.format('%.1f', fuel_out)))
            line.append(str(locale.format('%.0f', dist)))
            print '&' + '&'.join(line) + '\\\\'
            print '\\hline'
        elif output == 'array':
            array.append([alt, time, fuel_out, dist])
        calc_alt += alt_interval
    if output == 'array':
        return array
Ejemplo n.º 6
0
def climb_data(prop, weight = 1800., alt_max = 20000., TO_fuel = 0, TO_dist = 0, \
    fuel_units = 'USG', alt_interval = 500., isa_dev = 0, temp_units = 'C', \
    rv = '8', wing_area = 110., pwr = 'max', pwr_factor=1.0, \
    climb_speed = 'max', output = 'raw'):
    """
    Returns a table of climb performance vs altitude.

    The items in each row of the table are altitude, time, fuel burned and distance.
    Time is in units of minutes, rounded to the nearest half minute.
    Fuel units are selectable, with a default of USG.
    Distances are in nm.
    
    The output may be specified as raw, latex (a LaTeX table for the POH), or array.
    
    pwr may be 'max', 'cc' (cruise climb = 2500 rpm and 25") or 2500 (2500 rpm and full throttle)
    climb_speed may be 'max' (Vy), 'cc' (120 kt to 10,000 ft, then reducing by 4 kt/1000 ft) or
                'norm' (100 kt to 10,000 ft, then reducing by 2 kt/1000 ft)
                
    Note: compared cruise range for all climb speed and power.  The predicted results are all 
          within 1.5 nm of range.  Thus there is no advantage to using anything but Vy and max
          power.
    """
    def _alt2ROC(prop, alt):
        """
        calculate ROC for an altitude
        """
        temp = SA.isa2temp(isa_dev, alt)
        calc_pwr = alt2pwr(alt, rpm=rpm, MP_max=MP_max, temp=temp) * pwr_factor
        cas = alt2roc_speed(alt, climb_speed=climb_speed)
        eas = A.cas2eas(cas, alt)
        ROC = roc(prop, alt, eas, weight, calc_pwr, rpm, rv = rv, \
            wing_area = wing_area)

        return ROC

    alt = 0
    time = 0
    fuel_used = U.avgas_conv(TO_fuel, from_units=fuel_units, to_units='lb')
    weight = weight - fuel_used
    dist = TO_dist
    if pwr == 'max':
        # rpm = 2700
        rpm = 2650
        MP_max = 30
    elif pwr == 'cc':
        rpm = 2500
        MP_max = 25
    elif pwr == 2500:
        rpm = 2500
        MP_max = 30
    else:
        raise ValueError("pwr must be one of 'max', 'cc', or 2500")

    if output == 'raw':
        print(S.center('Altitude', 10), end=' ')
        print(S.center('ROC', 10), end=' ')
        print(S.center('Time', 10), end=' ')
        print(S.center('Fuel Used', 10), end=' ')
        print(S.center('Dist', 10), end=' ')
        print(S.center('Speed', 10))

        print(S.center('(ft)', 10), end=' ')
        print(S.center('(ft/mn)', 10), end=' ')
        print(S.center('(mn)', 10), end=' ')
        f_units = '(' + fuel_units + ')'
        print(S.center(f_units, 10), end=' ')
        print(S.center('(nm)', 10), end=' ')
        print(S.center('(KCAS)', 10))

        # data for MSL
        print(S.rjust(locale.format('%.0f', 0, True), 7), end=' ')
        # calculate ROC at MSL
        print(S.rjust(locale.format('%.0f', round(_alt2ROC(prop, 0) / 10.) * 10, \
            True), 10), end=' ')
        print(S.rjust('%.1f' % (0), 10), end=' ')
        print(S.rjust('%.1f' % (TO_fuel), 10), end=' ')
        print(S.rjust('%.1f' % (TO_dist), 10), end=' ')
        print(S.rjust('%3d' % (alt2roc_speed(0, climb_speed=climb_speed)), 10))

    elif output == 'latex':
        temp = 15 + isa_dev
        MSL_line = []
        MSL_line.append(str(locale.format('%.0f', weight, True)))
        MSL_line.append('0')
        MSL_line.append(str(locale.format('%.0f', temp)))
        MSL_line.append(str(locale.format('%.0f', alt2roc_speed(0, \
            climb_speed = climb_speed))))
        MSL_line.append(str(locale.format('%.0f', round(_alt2ROC(prop, 0) / 10.)\
          * 10, True)))
        MSL_line.append('0')
        MSL_line.append(str(TO_fuel))
        MSL_line.append(str(TO_dist))

        print('&'.join(MSL_line) + '\\\\')
        print('\\hline')
    elif output == 'array':
        # no header rows, but make blank array
        array = [[0, 0, TO_fuel, 0]]

    calc_alt = alt_interval / 2.
    while calc_alt < alt_max:
        temp = SA.isa2temp(isa_dev, calc_alt)
        pwr = alt2pwr(calc_alt, rpm=rpm, MP_max=MP_max, temp=temp)
        calc_pwr = pwr * pwr_factor
        cas = alt2roc_speed(calc_alt, climb_speed=climb_speed)
        eas = A.cas2eas(cas, calc_alt)
        tas = A.cas2tas(cas, calc_alt, temp=temp, temp_units=temp_units)
        tas_fts = U.speed_conv(tas, from_units='kt', to_units='ft/s')
        ROC = roc(prop, calc_alt, eas, weight, calc_pwr, rpm, rv = rv, \
            wing_area = wing_area)
        roc_fts = ROC / 60
        fuel_flow = IO.pwr2ff(pwr, rpm, ff_units='lb/hr')
        slice_time = alt_interval / roc_fts
        slice_dist = tas_fts * slice_time
        slice_fuel = fuel_flow * slice_time / 3600
        fuel_used += slice_fuel
        fuel_out = (U.avgas_conv(fuel_used, from_units = 'lb', \
            to_units = fuel_units))
        weight -= slice_fuel
        alt += alt_interval
        cas_out = alt2roc_speed(alt, climb_speed=climb_speed)
        temp_out = SA.isa2temp(isa_dev, alt)
        ROC = _alt2ROC(prop, alt)
        time += slice_time / 60
        dist += slice_dist / 6076.115

        if output == 'raw':
            print(S.rjust(locale.format('%.0f', alt, True), 7), end=' ')
            # calculate ROC at the displayed altitude
            print(S.rjust(locale.format('%.0f', ROC, True), 10), end=' ')
            print(S.rjust('%.1f' % (time), 10), end=' ')
            print(S.rjust('%.1f' % (fuel_out), 10), end=' ')
            print(S.rjust('%.1f' % (dist), 10), end=' ')
            print(S.rjust('%3d' % (int(cas_out)), 10))
        elif output == 'latex':
            line = []
            line.append(str(locale.format('%.0f', alt, True)))
            line.append(str(locale.format('%.0f', round(temp_out))))
            line.append(str(locale.format('%.0f', cas_out)))
            line.append(str(locale.format('%.0f',
                                          round(ROC / 10.) * 10, True)))
            line.append(str(locale.format('%.0f', time)))
            line.append(str(locale.format('%.1f', fuel_out)))
            line.append(str(locale.format('%.0f', dist)))
            print('&' + '&'.join(line) + '\\\\')
            print('\\hline')
        elif output == 'array':
            array.append([alt, time, fuel_out, dist])
        calc_alt += alt_interval
    if output == 'array':
        return array