1 | !> @file basic_constants_and_equations_mod.f90 |
---|
2 | !------------------------------------------------------------------------------! |
---|
3 | ! This file is part of the PALM model system. |
---|
4 | ! |
---|
5 | ! PALM is free software: you can redistribute it and/or modify it under the |
---|
6 | ! terms of the GNU General Public License as published by the Free Software |
---|
7 | ! Foundation, either version 3 of the License, or (at your option) any later |
---|
8 | ! version. |
---|
9 | ! |
---|
10 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
11 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
12 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
13 | ! |
---|
14 | ! You should have received a copy of the GNU General Public License along with |
---|
15 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
16 | ! |
---|
17 | ! Copyright 1997-2018 Leibniz Universitaet Hannover |
---|
18 | !------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: basic_constants_and_equations_mod.f90 3274 2018-09-24 15:42:55Z suehring $ |
---|
27 | ! New module (introduced with modularization of bulk cloud physics model) |
---|
28 | ! |
---|
29 | ! |
---|
30 | ! |
---|
31 | ! |
---|
32 | ! Description: |
---|
33 | ! ------------ |
---|
34 | !> This module contains all basic (physical) constants |
---|
35 | !> and |
---|
36 | !> functions for the calculation of diagnostic quantities. |
---|
37 | !------------------------------------------------------------------------------! |
---|
38 | MODULE basic_constants_and_equations_mod |
---|
39 | |
---|
40 | |
---|
41 | USE kinds |
---|
42 | |
---|
43 | IMPLICIT NONE |
---|
44 | |
---|
45 | REAL(wp), PARAMETER :: pi = 3.141592654_wp !< PI |
---|
46 | |
---|
47 | REAL(wp), PARAMETER :: c_p = 1005.0_wp !< heat capacity of dry air (J kg-1 K-1) |
---|
48 | REAL(wp), PARAMETER :: g = 9.81_wp !< gravitational acceleration (m s-2) |
---|
49 | REAL(wp), PARAMETER :: kappa = 0.4_wp !< von Karman constant |
---|
50 | REAL(wp), PARAMETER :: l_m = 0.33E+06_wp !< latent heat of water melting (J kg-1) |
---|
51 | REAL(wp), PARAMETER :: l_v = 2.5E+06_wp !< latent heat of water vaporization (J kg-1) |
---|
52 | REAL(wp), PARAMETER :: l_s = l_m + l_v !< latent heat of water sublimation (J kg-1) |
---|
53 | REAL(wp), PARAMETER :: molecular_weight_of_nacl = 0.05844_wp !< mol. m. NaCl (kg mol-1) |
---|
54 | REAL(wp), PARAMETER :: molecular_weight_of_c3h4o4 = 0.10406_wp !< mol. m. malonic acid (kg mol-1) |
---|
55 | REAL(wp), PARAMETER :: molecular_weight_of_nh4no3 = 0.08004_wp !< mol. m. ammonium sulfate (kg mol-1) |
---|
56 | REAL(wp), PARAMETER :: molecular_weight_of_water = 0.01801528_wp !< mol. m. H2O (kg mol-1) |
---|
57 | REAL(wp), PARAMETER :: rho_l = 1.0E3_wp !< density of water (kg m-3) |
---|
58 | REAL(wp), PARAMETER :: rho_nacl = 2165.0_wp !< density of NaCl (kg m-3) |
---|
59 | REAL(wp), PARAMETER :: rho_c3h4o4 = 1600.0_wp !< density of malonic acid (kg m-3) |
---|
60 | REAL(wp), PARAMETER :: rho_nh4no3 = 1720.0_wp !< density of ammonium sulfate (kg m-3) |
---|
61 | REAL(wp), PARAMETER :: r_d = 287.0_wp !< sp. gas const. dry air (J kg-1 K-1) |
---|
62 | REAL(wp), PARAMETER :: r_v = 461.51_wp !< sp. gas const. water vapor (J kg-1 K-1) |
---|
63 | REAL(wp), PARAMETER :: sigma_sb = 5.67E-08_wp !< Stefan-Boltzmann constant |
---|
64 | REAL(wp), PARAMETER :: solar_constant = 1368.0_wp !< solar constant at top of atmosphere |
---|
65 | REAL(wp), PARAMETER :: vanthoff_nacl = 2.0_wp !< van't Hoff factor for NaCl |
---|
66 | REAL(wp), PARAMETER :: vanthoff_c3h4o4 = 1.37_wp !< van't Hoff factor for malonic acid |
---|
67 | REAL(wp), PARAMETER :: vanthoff_nh4no3 = 2.31_wp !< van't Hoff factor for ammonium sulfate |
---|
68 | |
---|
69 | REAL(wp), PARAMETER :: p_0 = 100000.0_wp !< standard pressure reference state |
---|
70 | |
---|
71 | REAL(wp), PARAMETER :: g_d_cp = g / c_p !< precomputed g / c_p |
---|
72 | REAL(wp), PARAMETER :: lv_d_cp = l_v / c_p !< precomputed l_v / c_p |
---|
73 | REAL(wp), PARAMETER :: lv_d_rd = l_v / r_d !< precomputed l_v / r_d |
---|
74 | REAL(wp), PARAMETER :: rd_d_cp = 0.286_wp !r_d / c_p !< precomputed r_d / c_p |
---|
75 | REAL(wp), PARAMETER :: cp_d_rd = 1.0_wp/0.286_wp !c_p / r_d !< precomputed c_p / r_d |
---|
76 | |
---|
77 | REAL(wp) :: molecular_weight_of_solute = molecular_weight_of_nacl !< mol. m. NaCl (kg mol-1) |
---|
78 | REAL(wp) :: rho_s = rho_nacl !< density of NaCl (kg m-3) |
---|
79 | REAL(wp) :: vanthoff = vanthoff_nacl !< van't Hoff factor for NaCl |
---|
80 | |
---|
81 | |
---|
82 | SAVE |
---|
83 | |
---|
84 | PRIVATE magnus_0d, & |
---|
85 | magnus_1d, & |
---|
86 | ideal_gas_law_rho_0d, & |
---|
87 | ideal_gas_law_rho_1d, & |
---|
88 | ideal_gas_law_rho_pt_0d, & |
---|
89 | ideal_gas_law_rho_pt_1d, & |
---|
90 | exner_function_0d, & |
---|
91 | exner_function_1d, & |
---|
92 | exner_function_invers_0d, & |
---|
93 | exner_function_invers_1d, & |
---|
94 | barometric_formula_0d, & |
---|
95 | barometric_formula_1d |
---|
96 | |
---|
97 | INTERFACE magnus |
---|
98 | MODULE PROCEDURE magnus_0d |
---|
99 | MODULE PROCEDURE magnus_1d |
---|
100 | END INTERFACE magnus |
---|
101 | |
---|
102 | INTERFACE ideal_gas_law_rho |
---|
103 | MODULE PROCEDURE ideal_gas_law_rho_0d |
---|
104 | MODULE PROCEDURE ideal_gas_law_rho_1d |
---|
105 | END INTERFACE ideal_gas_law_rho |
---|
106 | |
---|
107 | INTERFACE ideal_gas_law_rho_pt |
---|
108 | MODULE PROCEDURE ideal_gas_law_rho_pt_0d |
---|
109 | MODULE PROCEDURE ideal_gas_law_rho_pt_1d |
---|
110 | END INTERFACE ideal_gas_law_rho_pt |
---|
111 | |
---|
112 | INTERFACE exner_function |
---|
113 | MODULE PROCEDURE exner_function_0d |
---|
114 | MODULE PROCEDURE exner_function_1d |
---|
115 | END INTERFACE exner_function |
---|
116 | |
---|
117 | INTERFACE exner_function_invers |
---|
118 | MODULE PROCEDURE exner_function_invers_0d |
---|
119 | MODULE PROCEDURE exner_function_invers_1d |
---|
120 | END INTERFACE exner_function_invers |
---|
121 | |
---|
122 | INTERFACE barometric_formula |
---|
123 | MODULE PROCEDURE barometric_formula_0d |
---|
124 | MODULE PROCEDURE barometric_formula_1d |
---|
125 | END INTERFACE barometric_formula |
---|
126 | |
---|
127 | CONTAINS |
---|
128 | |
---|
129 | !------------------------------------------------------------------------------! |
---|
130 | ! Description: |
---|
131 | ! ------------ |
---|
132 | !> This function computes the magnus formula (Press et al., 1992). |
---|
133 | !> The magnus formula is needed to calculate the saturation vapor pressure |
---|
134 | !------------------------------------------------------------------------------! |
---|
135 | FUNCTION magnus_0d( t ) |
---|
136 | |
---|
137 | IMPLICIT NONE |
---|
138 | |
---|
139 | REAL(wp), INTENT(IN) :: t !< temperature (K) |
---|
140 | |
---|
141 | REAL(wp) :: magnus_0d |
---|
142 | ! |
---|
143 | !-- Saturation vapor pressure for a specific temperature: |
---|
144 | magnus_0d = 611.2_wp * EXP( 17.62_wp * ( t - 273.15_wp ) / & |
---|
145 | ( t - 29.65_wp ) ) |
---|
146 | |
---|
147 | END FUNCTION magnus_0d |
---|
148 | |
---|
149 | !------------------------------------------------------------------------------! |
---|
150 | ! Description: |
---|
151 | ! ------------ |
---|
152 | !> This function computes the magnus formula (Press et al., 1992). |
---|
153 | !> The magnus formula is needed to calculate the saturation vapor pressure |
---|
154 | !------------------------------------------------------------------------------! |
---|
155 | FUNCTION magnus_1d( t ) |
---|
156 | |
---|
157 | IMPLICIT NONE |
---|
158 | |
---|
159 | REAL(wp), INTENT(IN), DIMENSION(:) :: t !< temperature (K) |
---|
160 | |
---|
161 | REAL(wp), DIMENSION(size(t)) :: magnus_1d |
---|
162 | ! |
---|
163 | !-- Saturation vapor pressure for a specific temperature: |
---|
164 | magnus_1d = 611.2_wp * EXP( 17.62_wp * ( t - 273.15_wp ) / & |
---|
165 | ( t - 29.65_wp ) ) |
---|
166 | |
---|
167 | END FUNCTION magnus_1d |
---|
168 | |
---|
169 | !------------------------------------------------------------------------------! |
---|
170 | ! Description: |
---|
171 | ! ------------ |
---|
172 | !> Compute the ideal gas law for scalar arguments. |
---|
173 | !------------------------------------------------------------------------------! |
---|
174 | FUNCTION ideal_gas_law_rho_0d( p, t ) |
---|
175 | |
---|
176 | IMPLICIT NONE |
---|
177 | |
---|
178 | REAL(wp), INTENT(IN) :: p !< pressure (Pa) |
---|
179 | REAL(wp), INTENT(IN) :: t !< temperature (K) |
---|
180 | |
---|
181 | REAL(wp) :: ideal_gas_law_rho_0d |
---|
182 | ! |
---|
183 | !-- compute density according to ideal gas law: |
---|
184 | ideal_gas_law_rho_0d = p / (r_d * t) |
---|
185 | |
---|
186 | END FUNCTION ideal_gas_law_rho_0d |
---|
187 | |
---|
188 | !------------------------------------------------------------------------------! |
---|
189 | ! Description: |
---|
190 | ! ------------ |
---|
191 | !> Compute the ideal gas law for 1-D array arguments. |
---|
192 | !------------------------------------------------------------------------------! |
---|
193 | FUNCTION ideal_gas_law_rho_1d( p, t ) |
---|
194 | |
---|
195 | IMPLICIT NONE |
---|
196 | |
---|
197 | REAL(wp), INTENT(IN), DIMENSION(:) :: p !< pressure (Pa) |
---|
198 | REAL(wp), INTENT(IN), DIMENSION(:) :: t !< temperature (K) |
---|
199 | |
---|
200 | REAL(wp), DIMENSION(size(p)) :: ideal_gas_law_rho_1d |
---|
201 | ! |
---|
202 | !-- compute density according to ideal gas law: |
---|
203 | ideal_gas_law_rho_1d = p / (r_d * t) |
---|
204 | |
---|
205 | END FUNCTION ideal_gas_law_rho_1d |
---|
206 | |
---|
207 | !------------------------------------------------------------------------------! |
---|
208 | ! Description: |
---|
209 | ! ------------ |
---|
210 | !> Compute the ideal gas law for scalar arguments. |
---|
211 | !------------------------------------------------------------------------------! |
---|
212 | FUNCTION ideal_gas_law_rho_pt_0d( p, t ) |
---|
213 | |
---|
214 | IMPLICIT NONE |
---|
215 | |
---|
216 | REAL(wp), INTENT(IN) :: p !< pressure (Pa) |
---|
217 | REAL(wp), INTENT(IN) :: t !< temperature (K) |
---|
218 | |
---|
219 | REAL(wp) :: ideal_gas_law_rho_pt_0d |
---|
220 | ! |
---|
221 | !-- compute density according to ideal gas law: |
---|
222 | ideal_gas_law_rho_pt_0d = p / (r_d * (1.0_wp / exner_function_invers(p)) * t) |
---|
223 | |
---|
224 | END FUNCTION ideal_gas_law_rho_pt_0d |
---|
225 | |
---|
226 | !------------------------------------------------------------------------------! |
---|
227 | ! Description: |
---|
228 | ! ------------ |
---|
229 | !> Compute the ideal gas law for 1-D array arguments. |
---|
230 | !------------------------------------------------------------------------------! |
---|
231 | FUNCTION ideal_gas_law_rho_pt_1d( p, t ) |
---|
232 | |
---|
233 | IMPLICIT NONE |
---|
234 | |
---|
235 | REAL(wp), INTENT(IN), DIMENSION(:) :: p !< pressure (Pa) |
---|
236 | REAL(wp), INTENT(IN), DIMENSION(:) :: t !< temperature (K) |
---|
237 | |
---|
238 | REAL(wp), DIMENSION(size(p)) :: ideal_gas_law_rho_pt_1d |
---|
239 | ! |
---|
240 | !-- compute density according to ideal gas law: |
---|
241 | ideal_gas_law_rho_pt_1d = p / (r_d * (1.0_wp / exner_function_invers(p)) * t) |
---|
242 | |
---|
243 | END FUNCTION ideal_gas_law_rho_pt_1d |
---|
244 | |
---|
245 | !------------------------------------------------------------------------------! |
---|
246 | ! Description: |
---|
247 | ! ------------ |
---|
248 | !> Compute the exner function for scalar arguments. |
---|
249 | !------------------------------------------------------------------------------! |
---|
250 | FUNCTION exner_function_0d( p ) |
---|
251 | |
---|
252 | IMPLICIT NONE |
---|
253 | |
---|
254 | REAL(wp), INTENT(IN) :: p !< pressure (Pa) |
---|
255 | |
---|
256 | REAL(wp) :: exner_function_0d |
---|
257 | ! |
---|
258 | !-- compute exner function: |
---|
259 | exner_function_0d = ( p / p_0 )**( rd_d_cp ) |
---|
260 | |
---|
261 | END FUNCTION exner_function_0d |
---|
262 | |
---|
263 | !------------------------------------------------------------------------------! |
---|
264 | ! Description: |
---|
265 | ! ------------ |
---|
266 | !> Compute the exner function for 1-D array arguments. |
---|
267 | !------------------------------------------------------------------------------! |
---|
268 | FUNCTION exner_function_1d( p ) |
---|
269 | |
---|
270 | IMPLICIT NONE |
---|
271 | |
---|
272 | REAL(wp), INTENT(IN), DIMENSION(:) :: p !< pressure (Pa) |
---|
273 | |
---|
274 | REAL(wp), DIMENSION(size(p)) :: exner_function_1d |
---|
275 | ! |
---|
276 | !-- compute exner function: |
---|
277 | exner_function_1d = ( p / p_0 )**( rd_d_cp ) |
---|
278 | |
---|
279 | END FUNCTION exner_function_1d |
---|
280 | |
---|
281 | !------------------------------------------------------------------------------! |
---|
282 | ! Description: |
---|
283 | ! ------------ |
---|
284 | !> Compute the exner function for scalar arguments. |
---|
285 | !------------------------------------------------------------------------------! |
---|
286 | FUNCTION exner_function_invers_0d( p ) |
---|
287 | |
---|
288 | IMPLICIT NONE |
---|
289 | |
---|
290 | REAL(wp), INTENT(IN) :: p !< pressure (Pa) |
---|
291 | |
---|
292 | REAL(wp) :: exner_function_invers_0d |
---|
293 | ! |
---|
294 | !-- compute exner function: |
---|
295 | exner_function_invers_0d = ( p_0 / p )**( rd_d_cp ) |
---|
296 | |
---|
297 | END FUNCTION exner_function_invers_0d |
---|
298 | |
---|
299 | !------------------------------------------------------------------------------! |
---|
300 | ! Description: |
---|
301 | ! ------------ |
---|
302 | !> Compute the exner function for 1-D array arguments. |
---|
303 | !------------------------------------------------------------------------------! |
---|
304 | FUNCTION exner_function_invers_1d( p ) |
---|
305 | |
---|
306 | IMPLICIT NONE |
---|
307 | |
---|
308 | REAL(wp), INTENT(IN), DIMENSION(:) :: p !< pressure (Pa) |
---|
309 | |
---|
310 | REAL(wp), DIMENSION(size(p)) :: exner_function_invers_1d |
---|
311 | ! |
---|
312 | !-- compute exner function: |
---|
313 | exner_function_invers_1d = ( p_0 / p )**( rd_d_cp ) |
---|
314 | |
---|
315 | END FUNCTION exner_function_invers_1d |
---|
316 | |
---|
317 | !------------------------------------------------------------------------------! |
---|
318 | ! Description: |
---|
319 | ! ------------ |
---|
320 | !> Compute the barometric formula for scalar arguments. |
---|
321 | !------------------------------------------------------------------------------! |
---|
322 | FUNCTION barometric_formula_0d( z, t_0, p_0) |
---|
323 | |
---|
324 | IMPLICIT NONE |
---|
325 | |
---|
326 | REAL(wp), INTENT(IN) :: z !< height (m) |
---|
327 | REAL(wp), INTENT(IN) :: t_0 !< temperature reference state (K) |
---|
328 | REAL(wp), INTENT(IN) :: p_0 !< surface pressure (Pa) |
---|
329 | |
---|
330 | REAL(wp) :: barometric_formula_0d |
---|
331 | ! |
---|
332 | !-- compute barometric formula: |
---|
333 | barometric_formula_0d = p_0 * ( (t_0 - g_d_cp * z) / t_0 )**( cp_d_rd ) |
---|
334 | |
---|
335 | END FUNCTION barometric_formula_0d |
---|
336 | |
---|
337 | !------------------------------------------------------------------------------! |
---|
338 | ! Description: |
---|
339 | ! ------------ |
---|
340 | !> Compute the barometric formula for 1-D array arguments. |
---|
341 | !------------------------------------------------------------------------------! |
---|
342 | FUNCTION barometric_formula_1d( z, t_0, p_0) |
---|
343 | |
---|
344 | IMPLICIT NONE |
---|
345 | |
---|
346 | REAL(wp), INTENT(IN), DIMENSION(:) :: z !< height (m) |
---|
347 | REAL(wp), INTENT(IN) :: t_0 !< temperature reference state (K) |
---|
348 | REAL(wp), INTENT(IN) :: p_0 !< surface pressure (Pa) |
---|
349 | |
---|
350 | REAL(wp), DIMENSION(size(z)) :: barometric_formula_1d |
---|
351 | ! |
---|
352 | !-- compute barometric formula: |
---|
353 | barometric_formula_1d = p_0 * ( (t_0 - g_d_cp * z) / t_0 )**( cp_d_rd ) |
---|
354 | |
---|
355 | END FUNCTION barometric_formula_1d |
---|
356 | |
---|
357 | END MODULE basic_constants_and_equations_mod |
---|