# module NumRu::Met::Themo

Thermodynamic constants and functions

by T Horinouchi

## Module constants

#### `R`

Gas constant of dry air [J.kg-1.K-1] (287.04)

#### `Rv`

Gas constant of water vapor [J.kg-1.K-1] (461.50)

#### `Cp`

heat capacity at constant pressure for dry air [J.kg-1.K-1] (1004.6)

#### `Cpv`

heat capacity at constant pressure for water vapor [J.kg-1.K-1] (1870.0)

R/Cp

#### `T0`

K - Celcius (273.15)

#### `Lat0`

Latent heat of vaporization at 0 degC [J.kg-1] (2.500780e6)

## Module functions

#### `theta_prs2tempC(theta,prs)`

derive temprature[Celcius] from potential temperature[K] and pressure[hPa]

#### `tempC_prs2theta(temp,prs)`

derive potential temperature[K] from temprature[Celcius] and pressure[hPa]

#### `q2r(q)`

specific humidity -> mixing ratio

ARGEUMENTS

• q: specific humidty

RETURN VALUE

• q/(1.0-q)

#### `r2q(r)`

mixing ratio -> specific humidity

ARGEUMENTS

• r [Numeric Scalar or Array] mixing ratio [g/g]

RETURN VALUE

• r/(1.0+r)

#### `r_p2e(r,prs)`

derive water vapor partial pressure from mixing ratio and pressure

ARGUMENTS

• r: water vapor mixing ratio[g/g]
• prs: pressure[hPa]
• rratio = R / Rv

RETURN VALUE

• e = prs*r/(rratio+r) --- water vapor pertial pressure [hPa]

#### `q_p2e(q,prs)`

derive water vapor partial pressure from specific humidity and pressure

ARGUMENTS

• q: specific humidity[g/g]
• prs: pressure[hPa]
• rratio = R / Rv

RETURN VALUE

• e = prs*q/(rratio+(1-rraio)*q) --- water vapor pertial pressure [hPa]

#### `lat(tempC)`

Returns the latent heat as a function of temperature

ARGUMENTS

• tempC (Numeric, Array of Numeric, or NArray-like classes): temperature [Celcius]

#### `t_dewpoint(r,prs)`

calculate dew point temperature using enhanced Teten''s formula from mixing ratioa and pressure. Based on thermolib3.f in APRS 4.5.1

ARGUMENTS:

• r: water vapor mixing ratio [g/g]
• prs: pressure[hPa]

CAUTION:

• shapes of the arguments must agree with each other(whether scalar or array)

RETURN VALUE:

• dew point temperature[degC]

#### `theta_es(tempC,prs)`

Saturation potential temperature (no condensate -- conserv along pseudo-adiabatic processes). In an approximate formulation theta_es = theta * exp(L r_sat / CpT).

ARGUMENTS

• tempC (Numeric, Array of Numeric, or NArray-like classes): temperature [Celcius]
• prs (Numeric, Array of Numeric, or NArray-like clasees): pressure [hPa]

RETURN VALUE

• theta_es (class dependent on arguments): saturation potential temperature

#### `theta_es_prs2tempC(th_es,prs)`

derive tempareture from saturation potential temperature. See theta_es for argument specification. This method reverses theta_es iteratively by the secont method.

#### `e_sat(tempC,prs)`

calculates saturation water vapor pressure using enhanced Teten''s formula. Based on thermolib3.f in APRS 4.5.1

ARGUMENTS:

• tempC [Numeric, Array, or NArray] temperature[degC]
• prs [Numeric, Array, or NArray] pressure[hPa]

CAUTION:

shapes of the arguments must agree with each other(whether scalar or array)

RETURN VALUE:

• esat saturation water vapor pressure [hPa]

#### `r_sat(tempC,prs)`

Same as e_sat but for saturation water vapor mixing ratio [g/g]

#### `q_sat(tempC,prs)`

Same as e_sat but for saturation water vapor specific humidity [g/g].

#### `rel_hum(tempC,e,prs)`

calculates relative humidity (from tempC,e,prs)

ARGUMENTS:

• tempC: temperature[degC]
• e: water vapor pressure[hPa]
• prs: pressure[hPa]

CAUTION:

• shapes of the arguments must agree with each other(whether scalar or array)

RETURN VALUE:

• relative humidity [hPa/hPa]