Ejemplo n.º 1
0
def pwr(rpm, MP, altitude, temp='std', alt_units='ft', temp_units='C'):
    """
    Returns horsepower for Lycoming O-360-A series engines, given:
    rpm - engine speed in revolutions per minute
    MP - manifold pressure (" HG)
    altitude - pressure altitude
    temp - ambient temperature  (optional - std temperature is used if no
           temperature is input).
    alt_units - (optional) - units for altitude, ft, m, or km
                                 (default is ft)
    temp_units - (optional) - units for temperature, C, F, K or R
                              (default is deg C)

    The function replicates Lycoming curve ??????? and is valid at mixture
    for maximum power.

    Examples:

    Determine power at 2620 rpm, 28 inches HG manifold pressure, 0 ft,
    and -10 deg C:
    >>> pwr(2620, 28, 0, -10)
    183.91485642478889

    Determine power at 2500 rpm, 25" MP, 5000 ft and 0 deg F:
    >>> pwr(2500, 25, 5000, 0, temp_units = 'F')
    164.10572738791328

    Determine power at 2200 rpm, 20" MP, 2000 metres and -5 deg C
    >>> pwr(2200, 20, 2000, -5, alt_units = 'm')
    111.72954664842844

    Determine power at 2200 rpm, 20" MP, 2000 metres and standard
    temperature:
    >>> pwr(2200, 20, 2000, alt_units = 'm')
    110.29915330621547
    """
    # convert units
    altitude = U.length_conv(altitude, from_units=alt_units, to_units='ft')
    if temp == 'std':
        temp = SA.alt2temp(altitude, temp_units=temp_units)
    temp = U.temp_conv(temp, from_units=temp_units, to_units='K')

    # get standard temperature
    temp_std = SA.alt2temp(altitude, temp_units='K')

    # get power at standard temperature
    pwr_std = _pwr_std_temp(rpm, MP, altitude)

    # correct power for non-standard temperature
    pwr = pwr_std * np.sqrt(temp_std / temp)

    return pwr
Ejemplo n.º 2
0
def pwr(rpm, MP, altitude, temp  = 'std', alt_units = 'ft', temp_units = 'C'):
    """ 
    Returns horsepower for Lycoming IO-360-A series engines, given:
    rpm - engine speed in revolutions per minute
    MP - manifold pressure (" HG)
    altitude - pressure altitude
    temp - ambient temperature  (optional - std temperature is used if no 
           temperature is input).
    alt_units - (optional) - units for altitude, ft, m, or km 
                                 (default is ft)
    temp_units - (optional) - units for temperature, C, F, K or R 
                              (default is deg C)
    
    The function replicates Lycoming curve 12700-A, and is valid at mixture 
    for maximum power.
    
    Examples:
    
    Determine power at 2620 rpm, 28 inches HG manifold pressure, 0 ft, and 
    -10 deg C:
    >>> pwr(2620, 28, 0, -10)
    197.71751932574702
    
    Determine power at 2500 rpm, 25" MP, 5000 ft and 0 deg F:
    >>> pwr(2500, 25, 5000, 0, temp_units = 'F')
    171.87810350172663
    
    Determine power at 2200 rpm, 20" MP, 2000 metres and -5 deg C
    >>> pwr(2200, 20, 2000, -5, alt_units = 'm')
    108.60284092217333
    
    Determine power at 2200 rpm, 20" MP, 2000 metres and standard 
    temperature:
    >>> pwr(2200, 20, 2000, alt_units = 'm')
    107.2124765533882
    """
    # convert units
    altitude = U.length_conv(altitude, from_units = alt_units, to_units = 'ft')
    if temp == 'std':
        temp = SA.alt2temp(altitude, temp_units = temp_units)
    temp = U.temp_conv(temp, from_units = temp_units, to_units = 'K')
    
    # get standard temperature
    temp_std = SA.alt2temp(altitude, temp_units = 'K')
    
    # get power at standard temperature
    pwr_std = _pwr_std_temp(rpm, MP, altitude)
    
    # correct power for non-standard temperature
    pwr = pwr_std * M.sqrt(temp_std / temp)
    
    return pwr
Ejemplo n.º 3
0
def pwr(rpm, MP, altitude, temp='std', alt_units='ft', temp_units='C'):
    """ 
    Returns horsepower for Lycoming IO-360-A series engines, given:
    rpm - engine speed in revolutions per minute
    MP - manifold pressure (" HG)
    altitude - pressure altitude
    temp - ambient temperature  (optional - std temperature is used if no 
           temperature is input).
    alt_units - (optional) - units for altitude, ft, m, or km 
                                 (default is ft)
    temp_units - (optional) - units for temperature, C, F, K or R 
                              (default is deg C)
    
    The function replicates Lycoming curve 12700-A, and is valid at mixture 
    for maximum power.
    
    Examples:
    
    Determine power at 2620 rpm, 28 inches HG manifold pressure, 0 ft, and 
    -10 deg C:
    >>> pwr(2620, 28, 0, -10)
    197.71751932574702
    
    Determine power at 2500 rpm, 25" MP, 5000 ft and 0 deg F:
    >>> pwr(2500, 25, 5000, 0, temp_units = 'F')
    171.87810350172663
    
    Determine power at 2200 rpm, 20" MP, 2000 metres and -5 deg C
    >>> pwr(2200, 20, 2000, -5, alt_units = 'm')
    108.60284092217333
    
    Determine power at 2200 rpm, 20" MP, 2000 metres and standard 
    temperature:
    >>> pwr(2200, 20, 2000, alt_units = 'm')
    107.2124765533882
    """
    # convert units
    altitude = U.length_conv(altitude, from_units=alt_units, to_units='ft')
    if temp == 'std':
        temp = SA.alt2temp(altitude, temp_units=temp_units)
    temp = U.temp_conv(temp, from_units=temp_units, to_units='K')

    # get standard temperature
    temp_std = SA.alt2temp(altitude, temp_units='K')

    # get power at standard temperature
    pwr_std = _pwr_std_temp(rpm, MP, altitude)

    # correct power for non-standard temperature
    pwr = pwr_std * M.sqrt(temp_std / temp)

    return pwr
Ejemplo n.º 4
0
def pwr(rpm, MP, altitude, temp  = 'std', alt_units = 'ft', temp_units = 'C'):
	""" 
	Returns horsepower for Lycoming O-360-A series engines, given:
	rpm - engine speed in revolutions per minute
	MP - manifold pressure (" HG)
	altitude - pressure altitude
	temp - ambient temperature  (optional - std temperature is used if no 
	       temperature is input).
	alt_units - (optional) - units for altitude, ft, m, or km 
	                             (default is ft)
	temp_units - (optional) - units for temperature, C, F, K or R 
	                          (default is deg C)
	
	The function replicates Lycoming curve ??????? and is valid at mixture 
	for maximum power.
	
	Examples:
	
	Determine power at 2620 rpm, 28 inches HG manifold pressure, 0 ft, 
	and -10 deg C:
	>>> pwr(2620, 28, 0, -10)
	183.91485642478889
	
	Determine power at 2500 rpm, 25" MP, 5000 ft and 0 deg F:
	>>> pwr(2500, 25, 5000, 0, temp_units = 'F')
	164.10572738791328
	
	Determine power at 2200 rpm, 20" MP, 2000 metres and -5 deg C
	>>> pwr(2200, 20, 2000, -5, alt_units = 'm')
	111.72954664842844
	
	Determine power at 2200 rpm, 20" MP, 2000 metres and standard 
	temperature:
	>>> pwr(2200, 20, 2000, alt_units = 'm')
	110.29915330621547
	"""
	# convert units
	altitude = U.length_conv(altitude, from_units = alt_units, to_units = 'ft')
	if temp == 'std':
		temp = SA.alt2temp(altitude, temp_units = temp_units)
	temp = U.temp_conv(temp, from_units = temp_units, to_units = 'K')
	
	# get standard temperature
	temp_std = SA.alt2temp(altitude, temp_units = 'K')
	
	# get power at standard temperature
	pwr_std = _pwr_std_temp(rpm, MP, altitude)
	
	# correct power for non-standard temperature
	pwr = pwr_std * M.sqrt(temp_std / temp)
	
	return pwr
Ejemplo n.º 5
0
    def test_04(self):

        # check deg F at 25,000 m
        # change order of units specifications

        T = round(SA.alt2temp(25000, temp_units='F', alt_units='m'), 2)
        self.assertEqual(T, -60.7)
Ejemplo n.º 6
0
def blade_angle2bhp(
    prop,
    blade_angle,
    rpm,
    tas,
    altitude,
    temp="std",
    power_units="hp",
    alt_units="ft",
    temp_units="C",
    speed_units="kt",
    dia_units="in",
):
    """
    Returns returns engine power, given blade angle, rpm and flight conditions.
    """
    press_ratio = SA.alt2press_ratio(altitude, alt_units=alt_units)
    if temp == "std":
        temp = SA.alt2temp(altitude, temp_units=temp_units, alt_units=alt_units)
    temp_ratio = U.temp_conv(temp, from_units=temp_units, to_units="K") / 288.15
    density_ratio = press_ratio / temp_ratio
    density = density_ratio * SA.Rho0
    #    Cp = bhp2Cp(bhp, rpm, density, prop.dia, power_units = power_units, density_units = 'kg/m**3', dia_units = dia_units)
    J = advance_ratio(tas, rpm, prop.dia, speed_units=speed_units, dia_units=dia_units)
    blade_tip_mach = tip_mach(
        tas, rpm, temp, prop.dia, speed_units=speed_units, temp_units=temp_units, dia_units=dia_units
    )

    Cp = blade_angle2cp(prop, blade_angle, J, blade_tip_mach)

    bhp = cp2bhp(Cp, rpm, density, prop.dia, power_units=power_units, density_units="kg/m**3", dia_units=dia_units)

    return bhp
Ejemplo n.º 7
0
def prop_eff(
    prop,
    bhp,
    rpm,
    tas,
    altitude,
    temp="std",
    power_units="hp",
    alt_units="ft",
    temp_units="C",
    speed_units="kt",
    dia_units="in",
):
    """
    Returns propeller efficiency based on engine power provided to the propeller.
    """
    press_ratio = SA.alt2press_ratio(altitude, alt_units=alt_units)
    if temp == "std":
        temp = SA.alt2temp(altitude, temp_units=temp_units, alt_units=alt_units)
    temp_ratio = U.temp_conv(temp, from_units=temp_units, to_units="K") / 288.15
    density_ratio = press_ratio / temp_ratio
    density = density_ratio * SA.Rho0
    Cp = bhp2Cp(bhp, rpm, density, prop.dia, power_units=power_units, density_units="kg/m**3", dia_units=dia_units)
    J = advance_ratio(tas, rpm, prop.dia, speed_units=speed_units, dia_units=dia_units)
    blade_tip_mach = tip_mach(
        tas, rpm, temp, prop.dia, speed_units=speed_units, temp_units=temp_units, dia_units=dia_units
    )

    prop_eff = cp2eff(prop, Cp, J, blade_tip_mach)

    if N.isnan(prop_eff):
        raise ValueError, "Out of range inputs"

    return prop_eff
Ejemplo n.º 8
0
def blade_angle(
    prop,
    bhp,
    rpm,
    tas,
    altitude,
    temp="std",
    power_units="hp",
    alt_units="ft",
    temp_units="C",
    speed_units="kt",
    dia_units="in",
):
    """
    Returns propeller blade angle.
    """
    press_ratio = SA.alt2press_ratio(altitude, alt_units=alt_units)
    if temp == "std":
        temp = SA.alt2temp(altitude, temp_units=temp_units, alt_units=alt_units)
    temp_ratio = U.temp_conv(temp, from_units=temp_units, to_units="K") / 288.15
    density_ratio = press_ratio / temp_ratio
    density = density_ratio * SA.Rho0
    Cp = bhp2Cp(bhp, rpm, density, prop.dia, power_units=power_units, density_units="kg/m**3", dia_units=dia_units)
    J = advance_ratio(tas, rpm, prop.dia, speed_units=speed_units, dia_units=dia_units)
    blade_tip_mach = tip_mach(
        tas, rpm, temp, prop.dia, speed_units=speed_units, temp_units=temp_units, dia_units=dia_units
    )

    blade_angle = cp2blade_angle(prop, Cp, J, blade_tip_mach)

    return blade_angle
    def test_04(self):

        # check deg F at 25,000 m
        # change order of units specifications

        T = round(SA.alt2temp(25000, temp_units='F', alt_units='m'), 2)
        self.assertEqual(T, -60.7)
Ejemplo n.º 10
0
    def test_04(self):

        # speed of sound at 10,000 m
        # Truth value from NASA RP 1046

        Value = SA.temp2speed_of_sound(SA.alt2temp(10000, alt_units="m"))
        Truth = 582.11
        self.failUnless(RE(Value, Truth) <= 1e-5)
Ejemplo n.º 11
0
    def test_02(self):

        # speed of sound in mph at 8,000 ft
        # Truth value from NASA RP 1046

        Value = SA.temp2speed_of_sound(SA.alt2temp(8000), speed_units="mph")
        Truth = 739.98
        self.failUnless(RE(Value, Truth) <= 1e-5)
Ejemplo n.º 12
0
    def test_04(self):

        # speed of sound at 10,000 m
        # Truth value from NASA RP 1046

        Value = SA.temp2speed_of_sound(SA.alt2temp(10000, alt_units='m'))
        Truth = 582.11
        self.assertTrue(RE(Value, Truth) <= 1e-5)
    def test_01(self):

        # speed of sound at 5,000 ft
        # Truth value from NASA RP 1046

        Value = SA.temp2speed_of_sound(SA.alt2temp(5000))
        Truth = 650.01
        self.failUnless(RE(Value, Truth) <= 1e-5)
Ejemplo n.º 14
0
    def test_02(self):

        # speed of sound in mph at 8,000 ft
        # Truth value from NASA RP 1046

        Value = SA.temp2speed_of_sound(SA.alt2temp(8000), speed_units='mph')
        Truth = 739.98
        self.assertTrue(RE(Value, Truth) <= 1e-5)
Ejemplo n.º 15
0
    def test_01(self):

        # speed of sound at 5,000 ft
        # Truth value from NASA RP 1046

        Value = SA.temp2speed_of_sound(SA.alt2temp(5000))
        Truth = 650.01
        self.assertTrue(RE(Value, Truth) <= 1e-5)
    def test_03(self):

        # speed of sound in km/h at 2,000 m, with temp in deg R
        # Truth value from NASA RP 1046

        Value = SA.temp2speed_of_sound(SA.alt2temp(2000, alt_units='m',
                temp_units='R'), speed_units='km/h', temp_units='R')
        Truth = 1197.1
        self.failUnless(RE(Value, Truth) <= 1e-5)
Ejemplo n.º 17
0
def MP_pred(tas, alt, rpm, rpm_base = 2700., MP_loss = 1.322, ram = 0.5, temp='std'):
    press = SA.alt2press(alt, press_units = 'in HG')
    if temp == 'std':
        temp = SA.alt2temp(alt)
    dp = A.tas2dp(tas, alt, temp, speed_units='kt', alt_units='ft', temp_units='C', press_units='in HG')
    ram_press = ram * dp
    MP_loss = MP_loss * (rpm / rpm_base) ** 1.85 # exponent from various online pressure drop calculators
#    MP_loss = MP_loss * (rpm / rpm_base)
    MP = press - MP_loss + ram_press

#    print "MP = %.3f" % MP
    return MP
Ejemplo n.º 18
0
def prop_eff(prop,
             bhp,
             rpm,
             tas,
             altitude,
             temp='std',
             power_units='hp',
             alt_units='ft',
             temp_units='C',
             speed_units='kt',
             dia_units='in'):
    """
    Returns propeller efficiency based on engine power provided to the propeller.
    """
    press_ratio = SA.alt2press_ratio(altitude, alt_units=alt_units)
    if temp == 'std':
        temp = SA.alt2temp(altitude,
                           temp_units=temp_units,
                           alt_units=alt_units)
    temp_ratio = U.temp_conv(temp, from_units=temp_units,
                             to_units='K') / 288.15
    density_ratio = press_ratio / temp_ratio
    density = density_ratio * SA.Rho0
    Cp = bhp2Cp(bhp,
                rpm,
                density,
                prop.dia,
                power_units=power_units,
                density_units='kg/m**3',
                dia_units=dia_units)
    J = advance_ratio(tas,
                      rpm,
                      prop.dia,
                      speed_units=speed_units,
                      dia_units=dia_units)
    blade_tip_mach = tip_mach(tas,
                              rpm,
                              temp,
                              prop.dia,
                              speed_units=speed_units,
                              temp_units=temp_units,
                              dia_units=dia_units)

    prop_eff = cp2eff(prop, Cp, J, blade_tip_mach)

    if N.isnan(prop_eff):
        raise ValueError('Out of range inputs')

    return prop_eff
Ejemplo n.º 19
0
def blade_angle2bhp(prop,
                    blade_angle,
                    rpm,
                    tas,
                    altitude,
                    temp='std',
                    power_units='hp',
                    alt_units='ft',
                    temp_units='C',
                    speed_units='kt',
                    dia_units='in'):
    """
    Returns returns engine power, given blade angle, rpm and flight conditions.
    """
    press_ratio = SA.alt2press_ratio(altitude, alt_units=alt_units)
    if temp == 'std':
        temp = SA.alt2temp(altitude,
                           temp_units=temp_units,
                           alt_units=alt_units)
    temp_ratio = U.temp_conv(temp, from_units=temp_units,
                             to_units='K') / 288.15
    density_ratio = press_ratio / temp_ratio
    density = density_ratio * SA.Rho0
    #    Cp = bhp2Cp(bhp, rpm, density, prop.dia, power_units = power_units, density_units = 'kg/m**3', dia_units = dia_units)
    J = advance_ratio(tas,
                      rpm,
                      prop.dia,
                      speed_units=speed_units,
                      dia_units=dia_units)
    blade_tip_mach = tip_mach(tas,
                              rpm,
                              temp,
                              prop.dia,
                              speed_units=speed_units,
                              temp_units=temp_units,
                              dia_units=dia_units)

    Cp = blade_angle2cp(prop, blade_angle, J, blade_tip_mach)

    bhp = cp2bhp(Cp,
                 rpm,
                 density,
                 prop.dia,
                 power_units=power_units,
                 density_units='kg/m**3',
                 dia_units=dia_units)

    return bhp
Ejemplo n.º 20
0
def pp(rpm, MP, altitude, temp  = 'std', alt_units = 'ft', temp_units = 'C'):
    """
    Returns percent power for Lycoming IO-360-A series engines, given:
    rpm - engine speed in revolutions per minute
    MP - manifold pressure (" HG)
    altitude - pressure altitude
    temp - ambient temperature  (optional - std temperature is used if no 
           temperature is input).
    alt_units - (optional) - units for altitude, ft, m, or km 
                                 (default is ft)
    temp_units - (optional) - units for temperature, C, F, K or R 
                              (default is deg C)
    
    The function replicates Lycoming curve 12700-A, and is valid at mixture 
    for maximum power.
    
    Note: the output is rounded off to two decimal places.
    
    Examples:
    
    Determine power at 2620 rpm, 28 inches HG manifold pressure, 0 ft, and 
    -10 deg C:
    >>> pp(2620, 28, 0, -10)
    '98.86%'
    
    Determine power at 2500 rpm, 25" MP, 5000 ft and 0 deg F:
    >>> pp(2500, 25, 5000, 0, temp_units = 'F')
    '85.94%'
    
    Determine power at 2200 rpm, 20" MP, 2000 metres and -5 deg C
    >>> pp(2200, 20, 2000, -5, alt_units = 'm')
    '54.30%'
    
    Determine power at 2200 rpm, 20" MP, 2000 metres and standard 
    temperature:
    >>> pp(2200, 20, 2000, alt_units = 'm')
    '53.61%'
    
    """
    altitude = U.length_conv(altitude, from_units = alt_units, to_units = 'ft')
    if temp == 'std':
        temp = SA.alt2temp(altitude, temp_units = temp_units)
    temp = U.temp_conv(temp, from_units = temp_units, to_units = 'C')

    pp = pwr(rpm, MP, altitude, temp) / 2
    
#   return pp
    return '%.2f' % (pp) + '%'
Ejemplo n.º 21
0
def pp(rpm, MP, altitude, temp='std', alt_units='ft', temp_units='C'):
    """
    Returns percent power for Lycoming IO-360-A series engines, given:
    rpm - engine speed in revolutions per minute
    MP - manifold pressure (" HG)
    altitude - pressure altitude
    temp - ambient temperature  (optional - std temperature is used if no 
           temperature is input).
    alt_units - (optional) - units for altitude, ft, m, or km 
                                 (default is ft)
    temp_units - (optional) - units for temperature, C, F, K or R 
                              (default is deg C)
    
    The function replicates Lycoming curve 12700-A, and is valid at mixture 
    for maximum power.
    
    Note: the output is rounded off to two decimal places.
    
    Examples:
    
    Determine power at 2620 rpm, 28 inches HG manifold pressure, 0 ft, and 
    -10 deg C:
    >>> pp(2620, 28, 0, -10)
    '98.86%'
    
    Determine power at 2500 rpm, 25" MP, 5000 ft and 0 deg F:
    >>> pp(2500, 25, 5000, 0, temp_units = 'F')
    '85.94%'
    
    Determine power at 2200 rpm, 20" MP, 2000 metres and -5 deg C
    >>> pp(2200, 20, 2000, -5, alt_units = 'm')
    '54.30%'
    
    Determine power at 2200 rpm, 20" MP, 2000 metres and standard 
    temperature:
    >>> pp(2200, 20, 2000, alt_units = 'm')
    '53.61%'
    
    """
    altitude = U.length_conv(altitude, from_units=alt_units, to_units='ft')
    if temp == 'std':
        temp = SA.alt2temp(altitude, temp_units=temp_units)
    temp = U.temp_conv(temp, from_units=temp_units, to_units='C')

    pp = pwr(rpm, MP, altitude, temp) / 2

    #   return pp
    return '%.2f' % (pp) + '%'
Ejemplo n.º 22
0
def blade_angle(prop,
                bhp,
                rpm,
                tas,
                altitude,
                temp='std',
                power_units='hp',
                alt_units='ft',
                temp_units='C',
                speed_units='kt',
                dia_units='in'):
    """
    Returns propeller blade angle.
    """
    press_ratio = SA.alt2press_ratio(altitude, alt_units=alt_units)
    if temp == 'std':
        temp = SA.alt2temp(altitude,
                           temp_units=temp_units,
                           alt_units=alt_units)
    temp_ratio = U.temp_conv(temp, from_units=temp_units,
                             to_units='K') / 288.15
    density_ratio = press_ratio / temp_ratio
    density = density_ratio * SA.Rho0
    Cp = bhp2Cp(bhp,
                rpm,
                density,
                prop.dia,
                power_units=power_units,
                density_units='kg/m**3',
                dia_units=dia_units)
    J = advance_ratio(tas,
                      rpm,
                      prop.dia,
                      speed_units=speed_units,
                      dia_units=dia_units)
    blade_tip_mach = tip_mach(tas,
                              rpm,
                              temp,
                              prop.dia,
                              speed_units=speed_units,
                              temp_units=temp_units,
                              dia_units=dia_units)

    blade_angle = cp2blade_angle(prop, Cp, J, blade_tip_mach)

    return blade_angle
Ejemplo n.º 23
0
def pp2mp(percent_power,
          rpm,
          altitude,
          temp='std',
          alt_units='ft',
          temp_units='C'):
    """
    Returns manifold pressure in inches of mercury for a given percent 
    power, rpm, altitude and temperature (temperature input is optional
    - standard temperature is used if no temperature is input).

    Note: the output is rounded off to two decimal places.
    
    Examples:
    
    Determine manifold pressure required for 62.5% power at 2550 rpm 
    at 8000 ft and 10 deg C:
    >>> pp2mp(62.5, 2550, 8000, 10)
    '19.45'
    
    Determine manifold pressure required for 75% power at 2500 rpm at 
    7500 ft at 10 deg F:
    >>> pp2mp(75, 2500, 7500, 10, temp_units = 'F')
    '22.25'
    
    
    Determine manifold pressure required for 55% power at 2400 rpm at 
    9,500 ft at standard temperature:
    >>> pp2mp(55, 2400, 9500)
    '18.18'
    """
    if percent_power <= 0:
        raise ValueError('Power input must be positive.')

    # convert units
    altitude = U.length_conv(altitude, from_units=alt_units, to_units='ft')
    if temp == 'std':
        temp = SA.alt2temp(altitude, temp_units=temp_units)
    temp = U.temp_conv(temp, from_units=temp_units, to_units='C')

    pwr_seek = percent_power * 2

    mp = pwr2mp(pwr_seek, rpm, altitude, temp)

    return mp
Ejemplo n.º 24
0
def alt_temp2density_ratio(H, temp, alt_units=default_alt_units, temp_units=default_temp_units):
    """
    Return the density ratio (atmospheric density / standard density
    for sea level).  The altitude is specified in feet ('ft'), metres ('m'),
    statute miles, ('sm') or nautical miles ('nm').  
    
    The temperature may be in deg C, F, K or R.

    If the units are not specified, the units in default_units.py are used.

    """
    if temp == 'std':
        temp = SA.alt2temp(H, temp_units=temp_units)
    press_ratio = alt2press_ratio(H, alt_units=alt_units)
    temp_ratio = temp2temp_ratio(temp, temp_units=temp_units)
    density_ratio = press_ratio / temp_ratio
    
    return density_ratio
Ejemplo n.º 25
0
def pp2rpm(percent_power,
           mp,
           altitude,
           temp='std',
           alt_units='ft',
           temp_units='C'):
    """
    Returns manifold pressure in inches of mercury for a given percent
    power, rpm, altitude and temperature (temperature input is optional -
    standard temperature is used if no temperature is input).

    Examples:

    Determine rpm required for 125 hp at 20 inches HG manifold pressure at
    8000 ft and 10 deg C:
    >>> pp2rpm(62.5, 20, 8000, 10)
    2246

    Determine rpm required for 75% power at 22 inches HG manifold pressure
    at 6500 ft and 10 deg F:
    >>> pp2rpm(75, 22, 6500, 10, temp_units = 'F')
    2345

    Determine rpm required for 55% power at at 18 inches HG manifold
    pressure at 9,500 ft at standard temperature:
    >>> pp2rpm(55, 18, 9500)
    2423
    """
    if percent_power <= 0:
        raise ValueError('Power input must be positive.')

    # convert units
    altitude = U.length_conv(altitude, from_units=alt_units, to_units='ft')
    if temp == 'std':
        temp = SA.alt2temp(altitude, temp_units=temp_units)
    temp = U.temp_conv(temp, from_units=temp_units, to_units='C')

    pwr_seek = percent_power * 1.8
    # 	print('Temp:', temp)
    print('Power seeked:', pwr_seek)
    rpm = pwr2rpm(pwr_seek, mp, altitude, temp)

    return rpm
Ejemplo n.º 26
0
def MP_pred(tas, alt, rpm, rpm_base=2700., MP_loss=1.322, ram=0.5, temp='std'):
    press = SA.alt2press(alt, press_units='in HG')
    if temp == 'std':
        temp = SA.alt2temp(alt)
    dp = A.tas2dp(tas,
                  alt,
                  temp,
                  speed_units='kt',
                  alt_units='ft',
                  temp_units='C',
                  press_units='in HG')
    ram_press = ram * dp
    MP_loss = MP_loss * (
        rpm / rpm_base
    )**1.85  # exponent from various online pressure drop calculators
    #    MP_loss = MP_loss * (rpm / rpm_base)
    MP = press - MP_loss + ram_press

    #    print "MP = %.3f" % MP
    return MP
Ejemplo n.º 27
0
def alt_temp2density_ratio(H,
                           temp,
                           alt_units=default_alt_units,
                           temp_units=default_temp_units):
    """
    Return the density ratio (atmospheric density / standard density
    for sea level).  The altitude is specified in feet ('ft'), metres ('m'),
    statute miles, ('sm') or nautical miles ('nm').  
    
    The temperature may be in deg C, F, K or R.

    If the units are not specified, the units in default_units.py are used.

    """
    if temp == 'std':
        temp = SA.alt2temp(H, temp_units=temp_units)
    press_ratio = alt2press_ratio(H, alt_units=alt_units)
    temp_ratio = temp2temp_ratio(temp, temp_units=temp_units)
    density_ratio = press_ratio / temp_ratio

    return density_ratio
Ejemplo n.º 28
0
def pp2mp(percent_power, rpm, altitude, temp = 'std', alt_units = 'ft', temp_units = 'C'):
    """
    Returns manifold pressure in inches of mercury for a given percent 
    power, rpm, altitude and temperature (temperature input is optional
    - standard temperature is used if no temperature is input).

    Note: the output is rounded off to two decimal places.
    
    Examples:
    
    Determine manifold pressure required for 62.5% power at 2550 rpm 
    at 8000 ft and 10 deg C:
    >>> pp2mp(62.5, 2550, 8000, 10)
    '19.45'
    
    Determine manifold pressure required for 75% power at 2500 rpm at 
    7500 ft at 10 deg F:
    >>> pp2mp(75, 2500, 7500, 10, temp_units = 'F')
    '22.25'
    
    
    Determine manifold pressure required for 55% power at 2400 rpm at 
    9,500 ft at standard temperature:
    >>> pp2mp(55, 2400, 9500)
    '18.18'
    """
    if percent_power <= 0:
        raise ValueError, 'Power input must be positive.'
    
    # convert units
    altitude = U.length_conv(altitude, from_units = alt_units, to_units = 'ft')
    if temp == 'std':
        temp = SA.alt2temp(altitude, temp_units = temp_units)
    temp = U.temp_conv(temp, from_units = temp_units, to_units = 'C')

    pwr_seek = percent_power * 2
    
    mp = pwr2mp(pwr_seek, rpm, altitude, temp)
    
    return mp
Ejemplo n.º 29
0
def pp2rpm(percent_power, mp, altitude, temp = 'std', alt_units = 'ft', temp_units = 'C'):
	"""
	Returns manifold pressure in inches of mercury for a given percent 
	power, rpm, altitude and temperature (temperature input is optional - 
	standard temperature is used if no temperature is input).
	
	Examples:
	
	Determine rpm required for 125 hp at 20 inches HG manifold pressure at 
	8000 ft and 10 deg C:
	>>> pp2rpm(62.5, 20, 8000, 10)
	2246
	
	Determine rpm required for 75% power at 22 inches HG manifold pressure 
	at 6500 ft and 10 deg F:
	>>> pp2rpm(75, 22, 6500, 10, temp_units = 'F')
	2345
	
	Determine rpm required for 55% power at at 18 inches HG manifold 
	pressure at 9,500 ft at standard temperature:
	>>> pp2rpm(55, 18, 9500)
	2423
	"""
	if percent_power <= 0:
		raise ValueError, 'Power input must be positive.'
	
	# convert units
	altitude = U.length_conv(altitude, from_units = alt_units, to_units = 'ft')
	if temp == 'std':
		temp = SA.alt2temp(altitude, temp_units = temp_units)
	temp = U.temp_conv(temp, from_units = temp_units, to_units = 'C')

	pwr_seek = percent_power * 1.8
# 	print 'Temp:', temp
	print 'Power seeked:', pwr_seek
	rpm = pwr2rpm(pwr_seek, mp, altitude, temp)
	
	return rpm
Ejemplo n.º 30
0
def pwr2rpm(pwr_seek,
            mp,
            altitude,
            temp='std',
            alt_units='ft',
            temp_units='C'):
    """ 
    Returns rpm for a given power, manifold pressure in inches of mercury,
    altitude and temperature (temperature input is optional - standard 
    temperature is used if no temperature is input).

    Note: the output is rounded off to the nearest rpm.
    
    Examples:
    
    Determine rpm required for 125 hp at 20 inches HG manifold pressure at 
    8000 ft and 10 deg C:
    >>> pwr2rpm(125, 20, 8000, 10)
    2477
    
    Determine rpm required for 75% power at 22 inches HG manifold pressure 
    at 6500 ft and 10 deg F:
    >>> pwr2rpm(.75 * 200, 22, 6500, 10, temp_units = 'F')
    2547
    
    Determine rpm required for 55% power at at 18 inches HG manifold 
    pressure at 9,500 ft at standard temperature:
    >>> pwr2rpm(.55 * 200, 18, 9500)
    2423
    """
    if pwr_seek <= 0:
        raise ValueError('Power input must be positive.')

    low = 1000  # initial lower guess
    high = 3500  # initial upper guess

    # convert units
    altitude = U.length_conv(altitude, from_units=alt_units, to_units='ft')
    if temp == 'std':
        temp = SA.alt2temp(altitude, temp_units=temp_units)
    temp = U.temp_conv(temp, from_units=temp_units, to_units='C')

    # confirm initial low and high are OK:
    pwr_low = pwr(low, mp, altitude, temp)
    # print "pwr_low=", pwr_low
    if pwr_low > pwr_seek:
        raise ValueError('Initial low guess too high.')

    pwr_high = pwr(high, mp, altitude, temp)
    # print "pwr_high=", pwr_high
    if pwr_high < pwr_seek:
        # print "pwr_high=", pwr_high
        print("Function called was IO.pwr(%f, %f, %f, %f)" %
              (high, mp, altitude, temp))
        raise ValueError('Initial high guess too low.')

    guess = (low + high) / 2.
    pwr_guess = pwr(guess, mp, altitude, temp)

    # keep iterating until power is within 0.1% of desired value
    while M.fabs(pwr_guess - pwr_seek) / pwr_seek > 1e-4:
        if pwr_guess > pwr_seek:
            high = guess
        else:
            low = guess

        guess = (low + high) / 2.
        pwr_guess = pwr(guess, mp, altitude, temp)

    return int(round(guess, 0))
Ejemplo n.º 31
0
def pwr2mp(pwr_seek,
           rpm,
           altitude,
           temp='std',
           alt_units='ft',
           temp_units='C'):
    """ 
    Returns manifold pressure in inches of mercury for a given power, rpm,
    altitude and temperature (temperature input is optional - standard 
    temperature is used if no temperature is input).
    
    Note: the output is rounded off to two decimal places.
    
    Examples:
    
    Determine manifold pressure required for 125 hp at 2550 rpm at 8000 ft 
    and 10 deg C:
    >>> pwr2mp(125, 2550, 8000, 10)
    '19.45'
    
    Determine manifold pressure required for 75% power at 2500 rpm at 
    7500 ft at 10 deg F:
    >>> pwr2mp(.75 * 200, 2500, 7500, 10, temp_units = 'F')
    '22.25'
    
    
    Determine manifold pressure required for 55% power at 2400 rpm at 
    9,500 ft at standard temperature:
    >>> pwr2mp(.55 * 200, 2400, 9500)
    '18.18'
    """
    if pwr_seek <= 0:
        raise ValueError('Power input must be positive.')

    low = 0  # initial lower guess
    high = 35  # initial upper guess

    # convert units
    altitude = U.length_conv(altitude, from_units=alt_units, to_units='ft')
    if temp == 'std':
        temp = SA.alt2temp(altitude, temp_units=temp_units)
    temp = U.temp_conv(temp, from_units=temp_units, to_units='C')

    # confirm initial low and high are OK:
    pwr_low = pwr(rpm, low, altitude, temp)
    if pwr_low > pwr_seek:
        raise ValueError('Initial low guess too high.')

    pwr_high = pwr(rpm, high, altitude, temp)
    if pwr_high < pwr_seek:
        raise ValueError('Initial high guess too low.')

    guess = (low + high) / 2.
    pwr_guess = pwr(rpm, guess, altitude, temp)

    # keep iterating until power is within 0.1% of desired value
    while M.fabs(pwr_guess - pwr_seek) / pwr_seek > 1e-3:
        if pwr_guess > pwr_seek:
            high = guess
        else:
            low = guess

        guess = (low + high) / 2.
        pwr_guess = pwr(rpm, guess, altitude, temp)


#   result = int(guess) + round(guess % 1, 2))
#   return guess
#   return result
    return '%.2f' % (guess)
    def test_01(self):

        # check at -1000 ft

        T = round(SA.alt2temp(-1000), 2)
        self.assertEqual(T, 16.98)
    def test_05(self):

        # check at 40 km

        T = round(SA.alt2temp(40, alt_units='km'), 2)
        self.assertEqual(T, -22.1)
Ejemplo n.º 34
0
piece.append('2100'.center(cols))
piece.append('2200'.center(cols))
piece.append('2300'.center(cols))
piece.append('2400'.center(cols))
piece.append('2200'.center(cols))
piece.append('2300'.center(cols))
piece.append('2400'.center(cols))
piece.append('2500'.center(cols))
full_line = '|'.join(piece)
print '|' + full_line + '|'


for alt in range(0, 16000, 1000):
	piece = []
	piece.append(str(alt).rjust(col1))
	temp = SA.alt2temp(alt, temp_units = 'F')
	temp = int(temp)
	piece.append(str(temp).rjust(col2))
	press = SA.alt2press(alt)

	pwr = .55 * max_pwr
	for rpm in range(2100, 2500, 100):
		mp = float(O.pwr2mp(pwr, rpm, alt))
		if press - mp < diff:
			piece.append('FT'.center(col2))
		else:
			piece.append(str(round(mp,1)).center(col2))
		
	pwr = .65 * max_pwr
	for rpm in range(2100, 2500, 100):
		mp = float(O.pwr2mp(pwr, rpm, alt))
Ejemplo n.º 35
0
    def test_06(self):

        # check at 50 km

        T = round(SA.alt2temp(50, alt_units='km'), 2)
        self.assertEqual(T, -2.5)
    def test_02(self):

        # check deg K at 10 km

        T = round(SA.alt2temp(10, alt_units='km', temp_units='K'), 2)
        self.assertEqual(T, 223.15)
Ejemplo n.º 37
0
    def test_03(self):

        # check deg R at 19 km

        T = round(SA.alt2temp(19, alt_units='km', temp_units='R'), 2)
        self.assertEqual(T, 389.97)
Ejemplo n.º 38
0
    def test_01(self):

        # check at -1000 ft

        T = round(SA.alt2temp(-1000), 2)
        self.assertEqual(T, 16.98)
Ejemplo n.º 39
0
def prop_data(prop,
              bhp,
              rpm,
              tas,
              altitude,
              temp='std',
              power_units='hp',
              alt_units='ft',
              temp_units='C',
              speed_units='kt',
              dia_units='in',
              thrust_units='lb'):
    """
    Returns advance ratio, power coefficient, thrust coefficient, blade tip
    mach number, propeller efficiency and thrust.
    
    Validated against Excel spreadsheet provided by Les Doud (Hartzell).
    """
    press_ratio = SA.alt2press_ratio(altitude, alt_units=alt_units)
    if temp == 'std':
        temp = SA.alt2temp(altitude,
                           temp_units=temp_units,
                           alt_units=alt_units)
    temp_ratio = U.temp_conv(temp, from_units=temp_units,
                             to_units='K') / 288.15
    density_ratio = press_ratio / temp_ratio
    density = density_ratio * SA.Rho0

    Cp = bhp2Cp(bhp,
                rpm,
                density,
                prop.dia,
                power_units=power_units,
                density_units='kg/m**3',
                dia_units=dia_units)
    J = advance_ratio(tas,
                      rpm,
                      prop.dia,
                      speed_units=speed_units,
                      dia_units=dia_units)
    blade_tip_mach = tip_mach(tas,
                              rpm,
                              temp,
                              prop.dia,
                              speed_units=speed_units,
                              temp_units=temp_units,
                              dia_units=dia_units)

    prop_eff = cp2eff(prop, Cp, J, blade_tip_mach)
    try:
        Ct = cp2ct(prop, Cp, J, blade_tip_mach)
    except:
        Ct = cp2ct_alt(prop,
                       Cp,
                       bhp,
                       rpm,
                       tas,
                       altitude,
                       temp=temp,
                       power_units=power_units,
                       alt_units=alt_units,
                       temp_units=temp_units,
                       speed_units=speed_units)

    if prop_eff > 0.1:
        thrust = eff2thrust(prop_eff,
                            bhp,
                            tas,
                            power_units=power_units,
                            speed_units=speed_units,
                            thrust_units=thrust_units)
    else:
        thrust = ct2thrust(Ct,
                           density,
                           rpm,
                           prop.dia,
                           thrust_units=thrust_units,
                           density_units='kg/m**3',
                           dia_units=dia_units)
    # data_block = 'J = ' + str(J) + '\nCp = ' + str(Cp) + '\n Tip mach = ' + str(blade_tip_mach) + '\n Ct = ' + str(Ct) + '\n Thrust = ' + str(thrust) + ' ' + thrust_units + '\n Prop efficiency = ' + str(prop_eff)

    print('           prop = ', prop.prop)
    print('              J = %.3f' % J)
    print('             Cp = %.5f' % Cp)
    print('       Tip Mach = %.3f' % blade_tip_mach)
    print('             Ct = %.3f' % Ct)
    print('         Thrust = %.2f' % thrust, thrust_units)
    print('Prop efficiency = %.4f' % prop_eff)
    print('      Thrust HP = %.2f' % bhp * prop_eff)

    return
Ejemplo n.º 40
0
    def test_08(self):

        # check at 80 km

        T = round(SA.alt2temp(80, alt_units='km'), 2)
        self.assertEqual(T, -76.5)
Ejemplo n.º 41
0
def pwr2rpm(pwr_seek, mp, altitude, temp = 'std', alt_units = 'ft', temp_units = 'C'):
    """ 
    Returns rpm for a given power, manifold pressure in inches of mercury,
    altitude and temperature (temperature input is optional - standard 
    temperature is used if no temperature is input).

    Note: the output is rounded off to the nearest rpm.
    
    Examples:
    
    Determine rpm required for 125 hp at 20 inches HG manifold pressure at 
    8000 ft and 10 deg C:
    >>> pwr2rpm(125, 20, 8000, 10)
    2477
    
    Determine rpm required for 75% power at 22 inches HG manifold pressure 
    at 6500 ft and 10 deg F:
    >>> pwr2rpm(.75 * 200, 22, 6500, 10, temp_units = 'F')
    2547
    
    Determine rpm required for 55% power at at 18 inches HG manifold 
    pressure at 9,500 ft at standard temperature:
    >>> pwr2rpm(.55 * 200, 18, 9500)
    2423
    """
    if pwr_seek <= 0:
        raise ValueError, 'Power input must be positive.'
    
    low = 1000 # initial lower guess
    high = 3500 # initial upper guess
    
    # convert units
    altitude = U.length_conv(altitude, from_units = alt_units, to_units = 'ft')
    if temp == 'std':
        temp = SA.alt2temp(altitude, temp_units = temp_units)
    temp = U.temp_conv(temp, from_units = temp_units, to_units = 'C')
    
    # confirm initial low and high are OK:
    pwr_low = pwr(low, mp, altitude, temp)
    # print "pwr_low=", pwr_low
    if pwr_low > pwr_seek:
        raise ValueError, 'Initial low guess too high.'
    
    pwr_high = pwr(high, mp, altitude, temp)
    # print "pwr_high=", pwr_high
    if pwr_high < pwr_seek:
        # print "pwr_high=", pwr_high
        print "Function called was IO.pwr(%f, %f, %f, %f)" % (high, mp, altitude, temp)
        raise ValueError, 'Initial high guess too low.'
    
    guess = (low + high) / 2.
    pwr_guess = pwr(guess, mp, altitude, temp)
    
    # keep iterating until power is within 0.1% of desired value
    while M.fabs(pwr_guess - pwr_seek) / pwr_seek > 1e-4:
        if pwr_guess > pwr_seek:
            high = guess
        else:
            low = guess

        guess = (low + high) / 2.
        pwr_guess = pwr(guess, mp, altitude, temp)

    return int(round(guess,0))  
Ejemplo n.º 42
0
    def test_02(self):

        # check deg K at 10 km

        T = round(SA.alt2temp(10, alt_units='km', temp_units='K'), 2)
        self.assertEqual(T, 223.15)
Ejemplo n.º 43
0
piece.append('2100'.center(cols))
piece.append('2200'.center(cols))
piece.append('2300'.center(cols))
piece.append('2400'.center(cols))
piece.append('2200'.center(cols))
piece.append('2300'.center(cols))
piece.append('2400'.center(cols))
piece.append('2500'.center(cols))
full_line = '|'.join(piece)
print('|' + full_line + '|')


for alt in range(0, 16000, 1000):
    piece = []
    piece.append(str(alt).rjust(col1))
    temp = SA.alt2temp(alt, temp_units='F')
    temp = int(temp)
    piece.append(str(temp).rjust(col2))
    press = SA.alt2press(alt)

    pwr = .55 * max_pwr
    for rpm in range(2100, 2500, 100):
        mp = float(O.pwr2mp(pwr, rpm, alt))
        if press - mp < diff:
            piece.append('FT'.center(col2))
        else:
            piece.append(str(round(mp, 1)).center(col2))

    pwr = .65 * max_pwr
    for rpm in range(2100, 2500, 100):
        mp = float(O.pwr2mp(pwr, rpm, alt))
Ejemplo n.º 44
0
def prop_data(
    prop,
    bhp,
    rpm,
    tas,
    altitude,
    temp="std",
    power_units="hp",
    alt_units="ft",
    temp_units="C",
    speed_units="kt",
    dia_units="in",
    thrust_units="lb",
):
    """
    Returns advance ratio, power coefficient, thrust coefficient, blade tip
    mach number, propeller efficiency and thrust.
    
    Validated against Excel spreadsheet provided by Les Doud (Hartzell).
    """
    press_ratio = SA.alt2press_ratio(altitude, alt_units=alt_units)
    if temp == "std":
        temp = SA.alt2temp(altitude, temp_units=temp_units, alt_units=alt_units)
    temp_ratio = U.temp_conv(temp, from_units=temp_units, to_units="K") / 288.15
    density_ratio = press_ratio / temp_ratio
    density = density_ratio * SA.Rho0

    Cp = bhp2Cp(bhp, rpm, density, prop.dia, power_units=power_units, density_units="kg/m**3", dia_units=dia_units)
    J = advance_ratio(tas, rpm, prop.dia, speed_units=speed_units, dia_units=dia_units)
    blade_tip_mach = tip_mach(
        tas, rpm, temp, prop.dia, speed_units=speed_units, temp_units=temp_units, dia_units=dia_units
    )

    prop_eff = cp2eff(prop, Cp, J, blade_tip_mach)
    try:
        Ct = cp2ct(prop, Cp, J, blade_tip_mach)
    except:
        Ct = cp2ct_alt(
            prop,
            Cp,
            bhp,
            rpm,
            tas,
            altitude,
            temp=temp,
            power_units=power_units,
            alt_units=alt_units,
            temp_units=temp_units,
            speed_units=speed_units,
        )

    if prop_eff > 0.1:
        thrust = eff2thrust(
            prop_eff, bhp, tas, power_units=power_units, speed_units=speed_units, thrust_units=thrust_units
        )
    else:
        thrust = ct2thrust(
            Ct, density, rpm, prop.dia, thrust_units=thrust_units, density_units="kg/m**3", dia_units=dia_units
        )
    # data_block = 'J = ' + str(J) + '\nCp = ' + str(Cp) + '\n Tip mach = ' + str(blade_tip_mach) + '\n Ct = ' + str(Ct) + '\n Thrust = ' + str(thrust) + ' ' + thrust_units + '\n Prop efficiency = ' + str(prop_eff)

    print "           prop = ", prop.prop
    print "              J = %.3f" % J
    print "             Cp = %.5f" % Cp
    print "       Tip Mach = %.3f" % blade_tip_mach
    print "             Ct = %.3f" % Ct
    print "         Thrust = %.2f" % thrust, thrust_units
    print "Prop efficiency = %.4f" % prop_eff
    print "      Thrust HP = %.2f" % bhp * prop_eff

    return
    def test_03(self):

        # check deg R at 19 km

        T = round(SA.alt2temp(19, alt_units='km', temp_units='R'), 2)
        self.assertEqual(T, 389.97)
    def test_06(self):

        # check at 50 km

        T = round(SA.alt2temp(50, alt_units='km'), 2)
        self.assertEqual(T, -2.5)
Ejemplo n.º 47
0
def pwr2mp(pwr_seek, rpm, altitude, temp = 'std', alt_units = 'ft', temp_units = 'C'):
    """ 
    Returns manifold pressure in inches of mercury for a given power, rpm,
    altitude and temperature (temperature input is optional - standard 
    temperature is used if no temperature is input).
    
    Note: the output is rounded off to two decimal places.
    
    Examples:
    
    Determine manifold pressure required for 125 hp at 2550 rpm at 8000 ft 
    and 10 deg C:
    >>> pwr2mp(125, 2550, 8000, 10)
    '19.45'
    
    Determine manifold pressure required for 75% power at 2500 rpm at 
    7500 ft at 10 deg F:
    >>> pwr2mp(.75 * 200, 2500, 7500, 10, temp_units = 'F')
    '22.25'
    
    
    Determine manifold pressure required for 55% power at 2400 rpm at 
    9,500 ft at standard temperature:
    >>> pwr2mp(.55 * 200, 2400, 9500)
    '18.18'
    """
    if pwr_seek <= 0:
        raise ValueError, 'Power input must be positive.'
    
    low = 0 # initial lower guess
    high = 35 # initial upper guess
    
    # convert units
    altitude = U.length_conv(altitude, from_units = alt_units, to_units = 'ft')
    if temp == 'std':
        temp = SA.alt2temp(altitude, temp_units = temp_units)
    temp = U.temp_conv(temp, from_units = temp_units, to_units = 'C')
    
    # confirm initial low and high are OK:
    pwr_low = pwr(rpm, low, altitude, temp)
    if pwr_low > pwr_seek:
        raise ValueError, 'Initial low guess too high.'
    
    pwr_high = pwr(rpm, high, altitude, temp)
    if pwr_high < pwr_seek:
        raise ValueError, 'Initial high guess too low.'
    
    guess = (low + high) / 2.
    pwr_guess = pwr(rpm, guess, altitude, temp)
    
    # keep iterating until power is within 0.1% of desired value
    while M.fabs(pwr_guess - pwr_seek) / pwr_seek > 1e-3:
        if pwr_guess > pwr_seek:
            high = guess
        else:
            low = guess

        guess = (low + high) / 2.
        pwr_guess = pwr(rpm, guess, altitude, temp)

#   result = int(guess) + round(guess % 1, 2))
#   return guess
#   return result
    return '%.2f' % (guess)
Ejemplo n.º 48
0
    def test_05(self):

        # check at 40 km

        T = round(SA.alt2temp(40, alt_units='km'), 2)
        self.assertEqual(T, -22.1)
    def test_07(self):

        # check at 60 km

        T = round(SA.alt2temp(60, alt_units='km'), 2)
        self.assertEqual(T, -27.7)
Ejemplo n.º 50
0
    def test_07(self):

        # check at 60 km

        T = round(SA.alt2temp(60, alt_units='km'), 2)
        self.assertEqual(T, -27.7)
    def test_08(self):

        # check at 80 km

        T = round(SA.alt2temp(80, alt_units='km'), 2)
        self.assertEqual(T, -76.5)