本文整理汇总了Python中scipy.constants.g方法的典型用法代码示例。如果您正苦于以下问题:Python constants.g方法的具体用法?Python constants.g怎么用?Python constants.g使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scipy.constants
的用法示例。
在下文中一共展示了constants.g方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: convert_accel_units_old
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import g [as 别名]
def convert_accel_units_old(acceleration, units):
"""
Converts acceleration from different units into cm/s^2
:param units: string in "g", "m/s/s", "m/s**2", "m/s^2",
"cm/s/s", "cm/s**2" or "cm/s^2" (in the last three cases, this
function simply returns `acceleration`)
:return: acceleration converted to the given units
"""
if units == "g":
return (100 * g) * acceleration
if units in ("m/s/s", "m/s**2", "m/s^2"):
return 100. * acceleration
if units in ("cm/s/s", "cm/s**2", "cm/s^2"):
return acceleration
raise ValueError("Unrecognised time history units. "
"Should take either ''g'', ''m/s/s'' or ''cm/s/s''")
示例2: get_sa_columns
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import g [as 别名]
def get_sa_columns(cls, csv_fieldnames):
"""This method is intended to be overridden by subclasses (by default
it raises :class:`NotImplementedError`) to return a `dict` of SA
column names (string), mapped to a numeric value representing the SA
period. This class will then sort and save SA periods accordingly.
You can also implement here operations which should be executed once
at the beginning of the flatfile parsing, such as e.g.
creating objects and storing them as class attributes later accessible
in :method:`parse_row`
:param csv_fieldnames: an iterable of strings representing the
header of the persed csv file
"""
# return just the U component. V and W will be handled in `parse_row`:
return OrderedDict([(k, float(k[3:].replace('_', '.'))) for k in
['U_T0_010', 'U_T0_025', 'U_T0_040', 'U_T0_050',
'U_T0_070', 'U_T0_100', 'U_T0_150', 'U_T0_200',
'U_T0_250', 'U_T0_300', 'U_T0_350', 'U_T0_400',
'U_T0_450', 'U_T0_500', 'U_T0_600', 'U_T0_700',
'U_T0_750', 'U_T0_800', 'U_T0_900', 'U_T1_000',
'U_T1_200', 'U_T1_400', 'U_T1_600', 'U_T1_800',
'U_T2_000', 'U_T2_500', 'U_T3_000', 'U_T3_500',
'U_T4_000', 'U_T4_500', 'U_T5_000', 'U_T6_000',
'U_T7_000', 'U_T8_000', 'U_T9_000', 'U_T10_000']])
示例3: calcularRendimientos_parciales
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import g [as 别名]
def calcularRendimientos_parciales(self, L):
"""Calculate the efficiency of separation process for each diameter of
solid fraction"""
entrada = self.kwargs["entrada"]
rhoS = entrada.solido.rho
rhoG = entrada.Gas.rho
muG = entrada.Gas.mu
rendimientos = []
for d in entrada.solido.diametros:
Ar = d**3*rhoG*(rhoS-rhoG)*g/muG**2
Vt = muG/d*rhoG*((14.42+1.827*Ar**0.5)**0.5-3.798)**2
if self.kwargs["modelo"] == 0:
r = Vt*L/self.Vgas/self.H
else:
r = 1-exp(-Vt*L/self.Vgas/self.H)
if r > 1:
rendimientos.append(1)
else:
rendimientos.append(r)
return rendimientos
示例4: _getBaseValue
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import g [as 别名]
def _getBaseValue(cls, data, unit, magnitud):
if data is None:
data = 0
if not magnitud:
magnitud = cls.__name__
if unit == "conf":
Config = getMainWindowConfig()
unit = cls.__units__[Config.getint('Units', magnitud)]
elif not unit:
unit = "Pa"
if unit == "barg":
data = data*k.bar+k.atm
elif unit == "psig":
data = data*k.psi+k.atm
elif unit == "kgcm2g":
data = data*k.g/k.centi**2+k.atm
elif unit in cls.rates:
data = data * cls.rates[unit]
else:
raise ValueError(
QApplication.translate("pychemqt", "Wrong input code"))
return data
示例5: Bo
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import g [as 别名]
def Bo(rhol, rhog, sigma, L):
r"""Calculates Bond number, `Bo` also known as Eotvos number.
.. math::
Bo = \frac{g(\rho_l-\rho_g)L^2}{\sigma}
Parameters
----------
rhol : float
Density of liquid, [kg/m³]
rhog : float
Density of gas, [kg/m³]
sigma : float
Surface tension, [N/m]
L : float
Characteristic length, [m]
Returns
-------
Bo : float
Bond number, [-]
"""
return (g*(rhol-rhog)*L**2/sigma)
示例6: pressure_vertical_extrapolation
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import g [as 别名]
def pressure_vertical_extrapolation(p0, temp_avg, z0, z1):
"""
Extrapolate pressure from height z0 to height z1 given the average temperature in the layer.
The hydostatic equation is used to peform the extrapolation.
Args:
p0(:obj:`pandas.Series`): pressure at height z0; units of Pascals
temp_avg(:obj:`pandas.Series`): mean temperature between z0 and z1; units of Kelvin
z0(:obj:`pandas.Series`): height above surface; units of meters
z1(:obj:`pandas.Series`): extrapolation height; units of meters
Returns:
:obj:`pandas.Series`: p1, extrapolated pressure at z1; units of Pascals
"""
# Send exception if any negative data found
if (p0[p0 < 0].size > 0) | (temp_avg[temp_avg < 0].size > 0):
raise Exception('Some of your temperature of pressure data is negative. Check your data')
R_const = 287.058 # Gas constant for dry air, units of J/kg/K
p1 = p0 * np.exp(-const.g * (z1 - z0) / R_const / temp_avg) # Pressure at z1
return p1
示例7: convert_accel_units
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import g [as 别名]
def convert_accel_units(acceleration, from_, to_='cm/s/s'): # pylint: disable=too-many-return-statements
"""
Converts acceleration from/to different units
:param acceleration: the acceleration (numeric or numpy array)
:param from_: unit of `acceleration`: string in "g", "m/s/s", "m/s**2",
"m/s^2", "cm/s/s", "cm/s**2" or "cm/s^2"
:param to_: new unit of `acceleration`: string in "g", "m/s/s", "m/s**2",
"m/s^2", "cm/s/s", "cm/s**2" or "cm/s^2". When missing, it defaults
to "cm/s/s"
:return: acceleration converted to the given units (by default, 'cm/s/s')
"""
m_sec_square = ("m/s/s", "m/s**2", "m/s^2")
cm_sec_square = ("cm/s/s", "cm/s**2", "cm/s^2")
acceleration = np.asarray(acceleration)
if from_ == 'g':
if to_ == 'g':
return acceleration
if to_ in m_sec_square:
return acceleration * g
if to_ in cm_sec_square:
return acceleration * (100 * g)
elif from_ in m_sec_square:
if to_ == 'g':
return acceleration / g
if to_ in m_sec_square:
return acceleration
if to_ in cm_sec_square:
return acceleration * 100
elif from_ in cm_sec_square:
if to_ == 'g':
return acceleration / (100 * g)
if to_ in m_sec_square:
return acceleration / 100
if to_ in cm_sec_square:
return acceleration
raise ValueError("Unrecognised time history units. "
"Should take either ''g'', ''m/s/s'' or ''cm/s/s''")
示例8: bank2turnradius
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import g [as 别名]
def bank2turnradius(self, bankangle_deg):
"""Calculates the turn radius in m, given the turn TAS and the bank angle"""
bankangle_rad = math.radians(bankangle_deg)
v_mps = co.kts2mps(self.turnspeed_ktas)
r_m = (v_mps ** 2) / (constants.g * math.tan(bankangle_rad))
return r_m
示例9: h_tubeside_laminar_condensation_Kern
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import g [as 别名]
def h_tubeside_laminar_condensation_Kern(self):
return 0.815*(k**3*rho_l*(rho_l-rho_g)*g*l/(pi*mu_l*Do*(T-Tw)))**0.25
示例10: h_tubeside_laminar_condensation_Nusselt
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import g [as 别名]
def h_tubeside_laminar_condensation_Nusselt(self):
return 0.72*eg**0.75*(k**3*rho_l*(rho_l-rho_g)*g*hlg/(mu_l*Do*(T-Tw)))**0.25
示例11: Fr
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import g [as 别名]
def Fr(V, L, g=g):
r"""Calculates Froude number `Fr` for velocity `V` and geometric length
`L`. If desired, gravity can be specified as well. Normally the function
returns the result of the equation below.
.. math::
Fr = \frac{V}{\sqrt{gL}}
Parameters
----------
V : float
Velocity of the particle or fluid, [m/s]
L : float
Characteristic length, no typical definition [m]
g : float, optional
Acceleration due to gravity, [m/s^2]
Returns
-------
Fr : float
Froude number, [-]
Notes
-----
Can be seen as a ratio of inertial force and gravity.
.. math::
Fr = \frac{\text{Inertial Force}}{\text{Gravity Force}}
Appears in problems of forced motion when gravity has same influence,
example in free liquid surfaces or multiphase flow.
Examples
--------
>>> print("%0.0f" % Fr(5, L=0.025))
102
"""
return Dimensionless(V**2/(L*g))
示例12: Ga
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import g [as 别名]
def Ga(L, rho=None, mu=None, nu=None, g=g):
r"""Calculates Galilei number `Ga`.
.. math::
Ar=\frac{gL^3}{v^2}
Inputs either of any of the following sets:
* L and kinematic viscosity `nu`
* L, density `rho` and dynamic viscosity `mu`
Parameters
----------
L : float
Characteristic length [m]
rho : float, optional
Density of bulk phase [kg/m³]
mu : float, optional
Dynamic viscosity, [Pa*s]
nu : float, optional
Kinematic viscosity, [m^2/s]
g : float, optional
Acceleration due to gravity, [m/s^2]
Returns
-------
Ga : float
Galilei number, [-]
Examples
--------
>>> print("%0.3f" % Ga(5e-4, nu=48.09e-6))
0.530
"""
if rho and mu:
nu = mu/rho
elif not nu:
raise Exception("undefined")
return Dimensionless(g*L**3/nu**2)
示例13: test_accel_units
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import g [as 别名]
def test_accel_units(self):
'''test acceleration units function'''
func = convert_accel_units
for acc in [np.nan, 0, 100, -g*5, g*6.5,
np.array([np.nan, 0, 100, g*5, g*6.5])]:
# check that cm_sec and m_sec produce the same result:
_1, _2 = func(acc, 'g', 'cm/s/s'), func(acc, 'cm/s/s', 'g')
for cmsec in ('cm/s^2', 'cm/s**2'):
self.assertNEqual(_1, func(acc, 'g', cmsec))
self.assertNEqual(_2, func(acc, cmsec, 'g'))
_1, _2 = func(acc, 'g', 'm/s/s'), func(acc, 'm/s/s', 'g')
for msec in ('m/s^2', 'm/s**2'):
self.assertNEqual(_1, func(acc, 'g', msec))
self.assertNEqual(_2, func(acc, msec, 'g'))
# assert same label is no-op:
self.assertNEqual(func(acc, 'g', 'g'), acc)
self.assertNEqual(func(acc, 'cm/s/s', 'cm/s/s'), acc)
self.assertNEqual(func(acc, 'm/s/s', 'm/s/s'), acc)
# assume input in g:
# to cm/s/s
expected = acc * (100 * g)
self.assertNEqual(func(acc, 'g', 'cm/s/s'), expected)
self.assertNEqual(func(acc, 'g', 'cm/s/s'),
convert_accel_units_old(acc, 'g'))
# to m/s/s:
expected /= 100
self.assertNEqual(func(acc, 'g', 'm/s/s'), expected)
self.assertNEqual(func(acc, 'g', 'm/s/s'),
convert_accel_units_old(acc, 'g')/100)
# check that the old calls to convert_accel_units:
# are the same as the actual:
for unit in ['g', 'cm/s/s', 'm/s/s']:
self.assertNEqual(convert_accel_units_old(acc, unit),
func(acc, unit))
with self.assertRaises(ValueError): # invalid units 'a':
func(acc, 'a')
示例14: parse_row
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import g [as 别名]
def parse_row(cls, rowdict, sa_colnames):
'''This method is intended to be overridden by subclasses (by default
is no-op) to perform any further operation on the given csv row
`rowdict` before writing it to the GM databse file. Please note that:
1. This method should process `rowdict` in place, the returned value is
ignored. Any exception raised here is hanlded in the caller method.
2. `rowdict` keys might not be the same as the csv
field names (first csv row). See `mappings` class attribute
3. The values of `rowdict` are all strings and they will be casted
later according to the column type. However, if a cast is needed
here for some custom operation, in order to convert strings to
floats or timestamps (floats denoting date-times) you can use the
static methods `timestamp` and `float`. Both methods accept also
lists or tuples to convert arrays and silenttly coerce unparsable
values to nan (Note that nan represents a missing value for any
numeric or timestamp column).
4. the `rowdict` keys 'event_id', 'station_id' and 'record_id' are
reserved and their values will be overridden anyway
:param rowdict: a row of the csv flatfile, as Python dict
:param sa_colnames: a list of strings of the column
names denoting the SA values. The list is sorted ascending
according to the relative numeric period defined in
:method:`get_sa_periods`
'''
# replace non lower case keys with their lower case counterpart:
for key in cls._non_lcase_fieldnames:
rowdict[key.lower()] = rowdict.pop(key)
# assign values (sa, event time, pga):
tofloat = cls.float
sa_ = tofloat([rowdict[p] for p in sa_colnames])
sa_unit = rowdict[cls._acc_unit_col] if cls._acc_unit_col else 'g'
sa_ = convert_accel_units(sa_, sa_unit)
rowdict['sa'] = sa_
# assign event time:
evtime_fieldnames = cls._evtime_fieldnames
dtime = ""
if len(evtime_fieldnames) == 6:
# use zfill to account for '934' formatted as '0934' for years,
# and '5' formatted as '05' for all other fields:
dtime = "{}-{}-{}T{}:{}:{}".\
format(*(rowdict[c].zfill(4 if i == 0 else 2)
for i, c in enumerate(evtime_fieldnames)))
else:
dtime = rowdict[evtime_fieldnames[0]]
rowdict['event_time'] = cls.timestamp(dtime)
# assign pga:
pga_col, pga_unit = cls._pga_col, cls._pga_unit
if not pga_unit:
pga_unit = cls._acc_unit_col if cls._acc_unit_col else 'g'
rowdict['pga'] = \
convert_accel_units(tofloat(rowdict[pga_col]), pga_unit)
示例15: thrusttoweight_takeoff
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import g [as 别名]
def thrusttoweight_takeoff(self, wingloading_pa):
"""The thrust to weight ratio required for take-off. This function is an
implementation of the following simple, analytical model:
.. math::
\\frac{\\overline{T}}{W} = 1.21\\frac{W/S}{\\rho C_\\mathrm{Lmax}^\\mathrm{TO}gd_
\\mathrm{G}}+\\frac{1}{2}\\frac{C_\\mathrm{D}^\\mathrm{TO}}{C_\\mathrm{L}^\\mathrm{TO}}
+\\frac{1}{2}\\mu_\\mathrm{R}
where :math:`\\overline{T}` is the average thrust during the take-off run,
:math:`W/S` is the wing loading, :math:`d_\\mathrm{G}` is the required ground
roll, :math:`C_\\mathrm{D}^\\mathrm{TO}` and :math:`C_\\mathrm{L}^\\mathrm{TO}`
are the 'all wheels on the runway' drag and lift coefficient respectively
in the take-off configuration, :math:`C_\\mathrm{Lmax}^\\mathrm{TO}` is the maximum
lift coefficient achieved during the take-off run (during rotation), :math:`\\rho`
is the ambient density and :math:`\\mu_\\mathrm{R}` is the coefficient of rolling
resistance on the wheels.
This is a function exposed to the user for clarity and added flexibility.
If you need to calculate the thrust to weight ratio required for take-off, use
``twrequired_to``. This corrects the output of this function to account for the
environmental conditions (including their impact on engine performance) and includes
a mapping to static thrust. ``thrusttoweight_takeoff`` should only be used if you
would like to perform these corrections in a different way than implemented in
``twrequired_to``.
If a full constraint analysis is required, ``twrequired`` should be used.
A similar 'full constraint set' function is available for calculating the
power demanded of the engine or electric motor of a propeller-driven aircraft
(to satisfy the constraint set) - this is called ``powerrequired``.
"""
groundrun_m = self.groundrun_m
# Assuming that the lift-off speed is equal to VR, which we estimate at 1.1VS1(T/O)
density_kgpm3 = self.designatm.airdens_kgpm3(self.rwyelevation_m)
vs1to_mps = np.sqrt((2 * wingloading_pa) / (density_kgpm3 * self.clmaxto))
liftoffspeed_mpstas = 1.1 * vs1to_mps
thrusttoweightreqd = (liftoffspeed_mpstas ** 2) / (2 * constants.g * groundrun_m) + \
0.5 * self.cdto / self.clto + \
0.5 * self.mu_r
return thrusttoweightreqd, liftoffspeed_mpstas