@@ -2,48 +2,29 @@ module ThermodynamicsInterface
22
33import Thermodynamics as TD
44const PS = TD. Parameters. ThermodynamicsParameters
5- const PP = TD. PhasePartition
6-
7-
8- # Constants
5+ const PP = TD. PhasePartition # Still used in Atmos EquilMoist model rain formation
96
7+ # ##
8+ # ## Constants
9+ # ##
1010grav (tps:: PS ) = TD. Parameters. grav (tps) # Needed in parcel model
1111
12-
13- # Constants for moist air
14-
1512Rᵥ (tps:: PS ) = TD. Parameters. R_v (tps)
1613Rd (tps:: PS ) = TD. Parameters. R_d (tps)
1714Rd_over_Rv (tps:: PS ) = 1 / TD. Parameters. molmass_ratio (tps)
18- # Gas constant for mois air
19- Rₘ (tps:: PS , qₜ, qₗ, qᵢ) = TD. gas_constant_air (tps, PP (qₜ, qₗ, qᵢ)) # TODO - PP
15+
16+ # Gas constant for moist air
17+ Rₘ (tps:: PS , qₜ, qₗ, qᵢ) = TD. gas_constant_air (tps, qₜ, qₗ, qᵢ)
2018
2119Lᵥ (tps:: PS , T) = TD. latent_heat_vapor (tps, T)
2220Lₛ (tps:: PS , T) = TD. latent_heat_sublim (tps, T)
2321Lf (tps:: PS , T) = TD. latent_heat_fusion (tps, T)
2422
2523cpₘ (tps:: PS , qₜ, qₗ, qᵢ) = TD. cp_m (tps, qₜ, qₗ, qᵢ)
2624
27- # Supersaturations
28-
29- saturation_vapor_pressure_over_liquid (tps:: PS , T) =
30- TD. saturation_vapor_pressure (tps, T, TD. Liquid ())
31- saturation_vapor_pressure_over_ice (tps:: PS , T) =
32- TD. saturation_vapor_pressure (tps, T, TD. Ice ())
33-
34- # (only used in tests)
35- saturation_vapor_specific_content_over_liquid (tps:: PS , T, ρ) =
36- TD. q_vap_saturation_generic (tps, T, ρ, TD. Liquid ())
37- saturation_vapor_specific_content_over_ice (tps:: PS , T, ρ) =
38- TD. q_vap_saturation_generic (tps, T, ρ, TD. Ice ())
39-
40- supersaturation_over_liquid (tps:: PS , qₜ, qₗ, qᵢ, ρ, T) =
41- TD. supersaturation (tps, PP (qₜ, qₗ, qᵢ), ρ, T, TD. Liquid ()) # TODO - PP
42- supersaturation_over_ice (tps:: PS , qₜ, qₗ, qᵢ, ρ, T) =
43- TD. supersaturation (tps, PP (qₜ, qₗ, qᵢ), ρ, T, TD. Ice ()) # TODO - PP
44-
45-
46- # Utility functions
25+ # ##
26+ # ## Utility functions
27+ # ##
4728
4829# Get vapor specific content from total water, total liquid water and total ice
4930# water specific contents.
@@ -53,17 +34,41 @@ q_vap(q_tot, q_liq, q_ice) = q_tot - q_liq - q_ice
5334q_vap (q_tot, q_liq, q_ice, q_rai, q_sno) = q_tot - q_liq - q_ice - q_rai - q_sno
5435
5536# Get specific content from partial pressure
56- p2q (tps:: PS , T, ρ, p ) = TD. q_vap_saturation_from_density (tps, T, ρ, p )
37+ p2q (tps:: PS , T, ρ, pᵥ ) = TD. q_vap_saturation_from_density (tps, T, ρ, pᵥ )
5738
39+ # Get partial pressure from specific content
40+ q2p (tps:: PS , T, ρ, qᵥ) = qᵥ * ρ * Rᵥ (tps) * T
5841
5942# Get air density from temperature, pressure and water content
6043# (only used in tests)
6144air_density (tps:: PS , T, p, q_tot, q_liq, q_ice) =
6245 TD. air_density (tps, T, p, PP (q_tot, q_liq, q_ice))
6346
64- # Get a tuple containing total water, cloud liquid water and cloud ice specific
65- # contents from TD.PhasePartition and rain and snow specific contents.
66- # Assumes that q::PhasePartition = (q_tot, q_cloud_liq + q_rai, q_cloud_ice + q_sno)
67- q_ (q:: PP , q_rai, q_sno) = (q. tot, q. liq - q_rai, q. ice - q_sno)
47+ # ##
48+ # ## Supersaturations
49+ # ##
50+ saturation_vapor_pressure_over_liquid (tps:: PS , T) =
51+ TD. saturation_vapor_pressure (tps, T, TD. Liquid ())
52+ saturation_vapor_pressure_over_ice (tps:: PS , T) =
53+ TD. saturation_vapor_pressure (tps, T, TD. Ice ())
54+
55+ # (only used in tests)
56+ saturation_vapor_specific_content_over_liquid (tps:: PS , T, ρ) =
57+ TD. q_vap_saturation_generic (tps, T, ρ, TD. Liquid ())
58+ saturation_vapor_specific_content_over_ice (tps:: PS , T, ρ) =
59+ TD. q_vap_saturation_generic (tps, T, ρ, TD. Ice ())
60+
61+ function supersaturation_over_liquid (tps:: PS , qₜ, qₗ, qᵢ, ρ, T)
62+ pᵥ_sat = saturation_vapor_pressure_over_liquid (tps, T)
63+ qᵥ = q_vap (qₜ, qₗ, qᵢ)
64+ pᵥ = q2p (tps, T, ρ, qᵥ)
65+ return pᵥ / pᵥ_sat - 1
66+ end
67+ function supersaturation_over_ice (tps:: PS , qₜ, qₗ, qᵢ, ρ, T)
68+ pᵥ_sat = saturation_vapor_pressure_over_ice (tps, T)
69+ qᵥ = q_vap (qₜ, qₗ, qᵢ)
70+ pᵥ = q2p (tps, T, ρ, qᵥ)
71+ return pᵥ / pᵥ_sat - 1
72+ end
6873
6974end
0 commit comments