bronx.meteo.thermo¶
This modules implements constants and conversions used in thermodynamics.
A brief description of the equations can be found in this document: thermo.pdf
If you find mistakes in the above document or in this module, please, send an email to sebastien.riette@meteo.fr.
Classes¶
- class bronx.meteo.thermo.Thermo(hydrometeors=None, data=None)[source]¶
Bases:
objectThis class aims at containing states parameter.
Values are retrieved by special method which can compute derived parameters. One can put anything inside this class but derived parameter computation uses defined name for some thermodynamic parameters. These names are available in the
thermo.N_*constants and comments are inC_*. Values must be all scalars or all numpy.arrays of the same shape.Example:
>>> data = Thermo() >>> print(C_T) Temperature (K) >>> data.set(N_T, 280) # in K >>> data.set(N_P, 75000) # in Pa >>> print('{:.2f}'.format(data.get(N_Theta))) 303.99 >>> import numpy as np >>> data2 = Thermo(hydrometeors=['v', ]) >>> data2.set(N_T, np.array([280, 300])) # in K >>> data2.set(N_P, np.array([75000, 101300])) # in Pa >>> data2.set(N_rv, np.array([0.05, 0.1])) # in kg/kg >>> print(' '.join(['{:.2f}'.format(r) for r in data2.get(N_rt)])) 0.05 0.10 >>> print(' '.join(['{:.2f}'.format(t) for t in data2.get(N_ThetaV)])) 312.78 315.41
- Parameters:
hydrometeors – lists the hydrometeors to consider. If None, only a subset of computations can be done. ‘v’, ‘c’, ‘r’, ‘i’, ‘s’, ‘g’ and ‘h’ are allowed.
data – A dictionary. Alternatively, data can be omited and the
set`()method can be used.
Example:
>>> data = Thermo() >>> data.set(N_T, 280) >>> data.set(N_P, 75000) # Is equivalent to... >>> data2 = Thermo(data={N_T:280, N_P:75000}) # Let's check... >>> data.get(N_T) == data2.get(N_T) True >>> data.get(N_P) == data2.get(N_P) True
- static R_T_P2rho(R, T, P)[source]¶
Computes the volumic mass of wet air (rho) from R, T and P or the volumic mass of dry air (rhod) from Rstar, T and P.
- static T2esati(T)[source]¶
Computes the water vapor pressure at saturation with respect to ice from T
- static T2esatw(T)[source]¶
Computes the water vapor pressure at saturation with respect to liquid water from T
- static T_phase2esat(T, phase)[source]¶
Computes the water vapor pressure at saturation from T and phase. Phase is given by:
‘L’, ‘E’ or ‘W’ for liquid water
‘S’, ‘G’ or ‘I’ for ice
- adjust(species, mix_rule=None, iteration=1, extra_variables=[], precision='full')[source]¶
This method returns a
Thermoinstance in which species are adjusted with respect to water vapour (others are kept untouched).species can only contain ‘c’ and/or ‘i’:
if
species == ['c'], we adjust with respect to liquid water (mix_rule must be None)if
species == ['i'], we adjust with respect to ice (mix_rule must be None)if
candiare in species, mix_rule cannot beNone, we have to choose an adjustment way:same, we keep the same partition between liquid and ice (entirely liquid if no previous cloud)0T-20, we use a linear partition between liquid and ice according to temperature between 0 and -20
Liquid/ice fraction is used to compute a weight-averaged saturation mixing ratio. Adjustment is an iterative process, iteration gives the number of iteration we must perform.
Only T and mixing ratios are set in the new object unless extra_variables is set. extra_variables is a list of variables to get from the current object and to set in the new one. If extra_variables contains thermodynamic variables, they can be in contradiction with the adjusted state; this variable is only useful for variables not impacted by adjustment (P, wind…) precision can be:
full: Cp and Lv values are evolving during the evaporation. Species are evaporated in the order given by species. Normally, the order does not matter.standard: Cp and Lv are computed from the initial state and kept constant during evaporation
- changeOrder(parameter, increasing=True)[source]¶
Modify the order of all parameters to sort according to parameter.
- evaporate(species, extra_variables=[], precision='full')[source]¶
This method returns a Thermo instance in which species are evaporated (others are kept untouched).
Only T and mixing ratios are set in the new object unless extra_variables is set. extra_variables is a list of variables to get from the current object and to set in the new one. If extra_variables contain thermodynamic variables, they can be in contradiction with the evaporated state; this variable is only useful for variables not impacted by evaporation (P, wind…) precision can be:
full: Cp and Lv values are evolving during the evaporation. Species are evaporated in the order given by species. Normally, the order does not matter.standard: Cp and Lv are computed from the initial state and kept constant during evaporation
- property hydrometeors¶
The list of hydrometeors.
- static qv_qliquid_qice2Cp(qv, qliquid, qice)[source]¶
Computes the heat capacity at constant pressure from specific contents.
- static qv_qliquid_qice_T2TV(qv, qliquid, qice, T)[source]¶
Computes the virtual temperature from qv, qliquid, qice and T.
- static qx_qt2rx(qx, qt)[source]¶
Computes mixing ratio from specific content and total specific content.
- static rv_rliquid_rice2Cph(rv, rliquid, rice)[source]¶
Computes the specific heat capacity at constant pressure from mixing-ratios.