def cp2bhp(Cp, rpm, density, dia, power_units='hp', density_units='lb/ft**3', dia_units='in'): """ Returns the bhp, given propeller power coefficient (Cp), revolutions per minute (rpm), and propeller diameter. The power units may be specified as "hp", "ft-lb/mn", "ft-lb/s", "W" (watts) or "kW" (kilowatts), but default to "hp" if not specified. The density units may be specified as "lb/ft**3", "slug/ft**3" or "kg/m**3", but default to "lb/ft**3" if not specified. The diameter units may be specified as "in", "ft", or "m", but default to inches if not specified. """ # bhp = U.power_conv(bhp, from_units = power_units, to_units = 'W') density = U.density_conv(density, from_units=density_units, to_units='kg/m**3') dia = U.length_conv(dia, from_units=dia_units, to_units='m') bhp = Cp * (density * ((rpm / 60.)**3) * dia**5) bhp = U.power_conv(bhp, from_units='W', to_units=power_units) return bhp
def ct2thrust(Ct, Rho, rpm, dia, thrust_units="lb", density_units="lb/ft**3", dia_units="in"): """ Returns the thrust, given thrust coefficient, Ct, density, rpm and prop diameter. """ Rho = U.density_conv(Rho, from_units=density_units, to_units="kg/m**3") dia = U.length_conv(dia, from_units=dia_units, to_units="m") # convert rpm to revolutions / s n = rpm / 60.0 thrust = Ct * Rho * n ** 2.0 * dia ** 4.0 return U.force_conv(thrust, from_units="N", to_units=thrust_units)
def density2alt(Rho, density_units=default_density_units, alt_units=default_alt_units): """ Return the altitude corresponding to the specified density, with density in 'lb/ft**3', 'slug/ft**3' or 'kg/m**3'. The altitude is specified in feet ('ft'), metres ('m'), statute miles, ('sm') or nautical miles ('nm'). If the units are not specified, the units in default_units.py are used. Examples: Calculate the altitude in default altitude units where the density is 0.056475 in default density units: >>> density2alt(.056475) 9999.8040934937271 Calculate the altitude in metres where the density is 0.018012 kg / m cubed: >>> density2alt(.018012, alt_units = 'm', density_units = 'kg/m**3') 29999.978688508152 """ # function tested in tests/test_std_atm.py Rho = U.density_conv(Rho, from_units=density_units, to_units='kg/m**3') if Rho > Rho11: H = _density2alt_gradient(Rho, Rho0, 0, T0, L0) elif Rho > Rho20: H = _density2alt_isothermal(Rho, Rho11, 11, T11) elif Rho > Rho32: H = _density2alt_gradient(Rho, Rho20, 20, T20, L20) elif Rho > Rho47: H = _density2alt_gradient(Rho, Rho32, 32, T32, L32) elif Rho > Rho51: H = _density2alt_isothermal(Rho, Rho47, 47, T47) elif Rho > Rho71: H = _density2alt_gradient(Rho, Rho51, 51, T51, L51) else: H = _density2alt_gradient(Rho, Rho71, 71, T71, L71) if H > 84.852: print( 'This function is only implemented for altitudes of 84.852 km and below.' ) return U.len_conv(H, from_units='km', to_units=alt_units)
def kinematic_viscosity(density, dynamic_viscosity, kinematic_viscosity_units=default_kinematic_viscosity_units, density_units=default_density_units, dynamic_viscosity_units=default_dynamic_viscosity_units): """ Return kinematic viscosity given density and dynamic viscosity. """ density = U.density_conv(density, density_units, 'kg/m**3') dynamic_viscosity = U.dynamic_viscosity_conv(dynamic_viscosity, dynamic_viscosity_units, 'Pa s') kinematic_viscosity = dynamic_viscosity / density kinematic_viscosity = U.kinematic_viscosity_conv(kinematic_viscosity, 'm**2/s', kinematic_viscosity_units) return kinematic_viscosity
def density2alt(Rho, density_units=default_density_units, alt_units=default_alt_units): """ Return the altitude corresponding to the specified density, with density in 'lb/ft**3', 'slug/ft**3' or 'kg/m**3'. The altitude is specified in feet ('ft'), metres ('m'), statute miles, ('sm') or nautical miles ('nm'). If the units are not specified, the units in default_units.py are used. Examples: Calculate the altitude in default altitude units where the density is 0.056475 in default density units: >>> density2alt(.056475) 9999.8040934937271 Calculate the altitude in metres where the density is 0.018012 kg / m cubed: >>> density2alt(.018012, alt_units = 'm', density_units = 'kg/m**3') 29999.978688508152 """ # function tested in tests/test_std_atm.py Rho = U.density_conv(Rho, from_units=density_units, to_units='kg/m**3') if Rho > Rho11: H = _density2alt_gradient(Rho, Rho0, 0, T0, L0) elif Rho > Rho20: H = _density2alt_isothermal(Rho, Rho11, 11, T11) elif Rho > Rho32: H = _density2alt_gradient(Rho, Rho20, 20, T20, L20) elif Rho > Rho47: H = _density2alt_gradient(Rho, Rho32, 32, T32, L32) elif Rho > Rho51: H = _density2alt_isothermal(Rho, Rho47, 47, T47) elif Rho > Rho71: H = _density2alt_gradient(Rho, Rho51, 51, T51, L51) else: H = _density2alt_gradient(Rho, Rho71, 71, T71, L71) if H > 84.852: raise ValueError, \ 'This function is only implemented for altitudes of 84.852 km and below.' return U.len_conv(H, from_units='km', to_units=alt_units)
def ct2thrust(Ct, Rho, rpm, dia, thrust_units='lb', density_units='lb/ft**3', dia_units='in'): """ Returns the thrust, given thrust coefficient, Ct, density, rpm and prop diameter. """ Rho = U.density_conv(Rho, from_units=density_units, to_units='kg/m**3') dia = U.length_conv(dia, from_units=dia_units, to_units='m') # convert rpm to revolutions / s n = rpm / 60. thrust = Ct * Rho * n**2. * dia**4. return U.force_conv(thrust, from_units='N', to_units=thrust_units)
def kinematic_viscosity( density, dynamic_viscosity, kinematic_viscosity_units=default_kinematic_viscosity_units, density_units=default_density_units, dynamic_viscosity_units=default_dynamic_viscosity_units): """ Return kinematic viscosity given density and dynamic viscosity. """ density = U.density_conv(density, density_units, 'kg/m**3') dynamic_viscosity = U.dynamic_viscosity_conv(dynamic_viscosity, dynamic_viscosity_units, 'Pa s') kinematic_viscosity = dynamic_viscosity / density kinematic_viscosity = U.kinematic_viscosity_conv( kinematic_viscosity, 'm**2/s', kinematic_viscosity_units) return kinematic_viscosity
def bhp2Cp(bhp, rpm, density, dia, power_units="hp", density_units="lb/ft**3", dia_units="in"): """ Returns the propeller power coefficient, Cp, given power, revolutions per minute (rpm), and propeller diameter. The power units may be specified as "hp", "ft-lb/mn", "ft-lb/s", "W" (watts) or "kW" (kilowatts), but default to "hp" if not specified. The density units may be specified as "lb/ft**3", "slug/ft**3" or "kg/m**3", but default to "lb/ft**3" if not specified. The diameter units may be specified as "in", "ft", or "m", but default to inches if not specified. """ bhp = U.power_conv(bhp, from_units=power_units, to_units="W") density = U.density_conv(density, from_units=density_units, to_units="kg/m**3") dia = U.length_conv(dia, from_units=dia_units, to_units="m") Cp = bhp / (density * ((rpm / 60.0) ** 3) * dia ** 5) return Cp
def alt2density(H, alt_units=default_alt_units, density_units=default_density_units): """ Return the density given the pressure altitude. The altitude is specified in feet ('ft'), metres ('m'), statute miles, ('sm') or nautical miles ('nm'). The desired density units are specified as 'lb/ft**3', 'slug/ft**3' or 'kg/m**3'. If the units are not specified, the units in default_units.py are used. Examples: Calculate the density in lb / ft cubed at 7,500 (default altitude units): >>> alt2density(7500) 0.061046199847730374 Calculate the density in slugs / ft cubed at 5,000 (default altitude units): >>> alt2density(5000, density_units = 'slug/ft**3') 0.0020480982157718704 Calculate the density in kg / m cubed at 0 (default altitude units: >>> alt2density(0, density_units = 'kg/m**3') 1.2250000000000001 Calculate the density in kg / m cubed at 81,000 m: >>> alt2density(81000, density_units = 'kg/m**3', alt_units = 'm') 1.3320480184052337e-05 """ # function tested in tests/test_std_atm.py # get density in kg/m**3 density = Rho0 * alt2density_ratio(H, alt_units) return U.density_conv(density, from_units='kg/m**3', to_units=density_units)
def test_02(self): Value = U.density_conv(1, from_units='slug/ft**3', to_units='lb/ft**3') Truth = 32.174 print(Value, Truth) self.failUnless(RE(Value, Truth) <= 1e-5)
def test_01(self): Value = U.density_conv(1, from_units='kg/m**3', to_units='slug/ft**3') Truth = (3.6127292e-5 * 12 ** 3) / 32.174 print(Value, Truth) self.failUnless(RE(Value, Truth) <= 1e-5)
def test_02(self): Value = U.density_conv(1, from_units='slug/ft**3', to_units='lb/ft**3') Truth = 32.174 print Value, Truth self.failUnless(RE(Value, Truth) <= 1e-5)
def test_01(self): Value = U.density_conv(1, from_units='kg/m**3', to_units='slug/ft**3') Truth = (3.6127292e-5 * 12**3) / 32.174 print Value, Truth self.failUnless(RE(Value, Truth) <= 1e-5)
def test_02(self): Value = U.density_conv(1, from_units='slug/ft**3', to_units='lb/ft**3') Truth = 32.174 print((Value, Truth)) self.assertTrue(RE(Value, Truth) <= 1e-5)
def test_01(self): Value = U.density_conv(1, from_units='kg/m**3', to_units='slug/ft**3') Truth = (3.6127292e-5 * 12**3) / 32.174 print((Value, Truth)) self.assertTrue(RE(Value, Truth) <= 1e-5)