1 | !> @file lpm_init.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: lpm_init.f90 3065 2018-06-12 07:03:02Z gronemeier $ |
---|
27 | ! dz was replaced by dzw or dz(1) to allow for right vertical stretching |
---|
28 | ! |
---|
29 | ! 3049 2018-05-29 13:52:36Z Giersch |
---|
30 | ! Error messages revised |
---|
31 | ! |
---|
32 | ! 3045 2018-05-28 07:55:41Z Giersch |
---|
33 | ! Error message revised |
---|
34 | ! |
---|
35 | ! 3039 2018-05-24 13:13:11Z schwenkel |
---|
36 | ! bugfix for lcm with grid stretching |
---|
37 | ! |
---|
38 | ! 2967 2018-04-13 11:22:08Z raasch |
---|
39 | ! nesting routine is only called if nesting is switched on |
---|
40 | ! |
---|
41 | ! 2954 2018-04-09 14:35:46Z schwenkel |
---|
42 | ! Bugfix for particle initialization in case of ocean |
---|
43 | ! |
---|
44 | ! 2801 2018-02-14 16:01:55Z thiele |
---|
45 | ! Introduce particle transfer in nested models. |
---|
46 | ! |
---|
47 | ! 2718 2018-01-02 08:49:38Z maronga |
---|
48 | ! Corrected "Former revisions" section |
---|
49 | ! |
---|
50 | ! 2701 2017-12-15 15:40:50Z suehring |
---|
51 | ! Changes from last commit documented |
---|
52 | ! |
---|
53 | ! 2698 2017-12-14 18:46:24Z suehring |
---|
54 | ! Grid indices passed to lpm_boundary_conds. (responsible Philipp Thiele) |
---|
55 | ! |
---|
56 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
57 | ! Change in file header (GPL part) |
---|
58 | ! |
---|
59 | ! 2628 2017-11-20 12:40:38Z schwenkel |
---|
60 | ! Enabled particle advection with grid stretching. |
---|
61 | ! |
---|
62 | ! 2608 2017-11-13 14:04:26Z schwenkel |
---|
63 | ! Calculation of magnus equation in external module (diagnostic_quantities_mod). |
---|
64 | ! |
---|
65 | ! 2606 2017-11-10 10:36:31Z schwenkel |
---|
66 | ! Changed particle box locations: center of particle box now coincides |
---|
67 | ! with scalar grid point of same index. |
---|
68 | ! Renamed module and subroutines: lpm_pack_arrays_mod -> lpm_pack_and_sort_mod |
---|
69 | ! lpm_pack_all_arrays -> lpm_sort_in_subboxes, lpm_pack_arrays -> lpm_pack |
---|
70 | ! lpm_sort -> lpm_sort_timeloop_done |
---|
71 | ! |
---|
72 | ! 2375 2017-08-29 14:10:28Z schwenkel |
---|
73 | ! Initialization of chemical aerosol composition |
---|
74 | ! |
---|
75 | ! 2346 2017-08-09 16:39:17Z suehring |
---|
76 | ! Bugfix, correct determination of topography top index |
---|
77 | ! |
---|
78 | ! 2318 2017-07-20 17:27:44Z suehring |
---|
79 | ! Get topography top index via Function call |
---|
80 | ! |
---|
81 | ! 2317 2017-07-20 17:27:19Z suehring |
---|
82 | ! Extended particle data type. Aerosol initialization improved. |
---|
83 | ! |
---|
84 | ! 2305 2017-07-06 11:18:47Z hoffmann |
---|
85 | ! Improved calculation of particle IDs. |
---|
86 | ! |
---|
87 | ! 2274 2017-06-09 13:27:48Z Giersch |
---|
88 | ! Changed error messages |
---|
89 | ! |
---|
90 | ! 2265 2017-06-08 16:58:28Z schwenkel |
---|
91 | ! Unused variables removed. |
---|
92 | ! |
---|
93 | ! 2263 2017-06-08 14:59:01Z schwenkel |
---|
94 | ! Implemented splitting and merging algorithm |
---|
95 | ! |
---|
96 | ! 2233 2017-05-30 18:08:54Z suehring |
---|
97 | ! |
---|
98 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
99 | ! Adjustments according to new topography realization |
---|
100 | ! |
---|
101 | ! |
---|
102 | ! 2223 2017-05-15 16:38:09Z suehring |
---|
103 | ! Add check for particle release at model top |
---|
104 | ! |
---|
105 | ! 2182 2017-03-17 14:27:40Z schwenkel |
---|
106 | ! Added parameters for simplified particle initialization. |
---|
107 | ! |
---|
108 | ! 2122 2017-01-18 12:22:54Z hoffmann |
---|
109 | ! Improved initialization of equilibrium aerosol radii |
---|
110 | ! Calculation of particle ID |
---|
111 | ! |
---|
112 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
113 | ! Forced header and separation lines into 80 columns |
---|
114 | ! |
---|
115 | ! 2016-06-09 16:25:25Z suehring |
---|
116 | ! Bugfix in determining initial particle height and grid index in case of |
---|
117 | ! seed_follows_topography. |
---|
118 | ! Bugfix concerning random positions, ensure that particles do not move more |
---|
119 | ! than one grid length. |
---|
120 | ! Bugfix logarithmic interpolation. |
---|
121 | ! Initial setting of sgs_wf_part. |
---|
122 | ! |
---|
123 | ! 1890 2016-04-22 08:52:11Z hoffmann |
---|
124 | ! Initialization of aerosol equilibrium radius not possible in supersaturated |
---|
125 | ! environments. Therefore, a maximum supersaturation of -1 % is assumed during |
---|
126 | ! initialization. |
---|
127 | ! |
---|
128 | ! 1873 2016-04-18 14:50:06Z maronga |
---|
129 | ! Module renamed (removed _mod |
---|
130 | ! |
---|
131 | ! 1871 2016-04-15 11:46:09Z hoffmann |
---|
132 | ! Initialization of aerosols added. |
---|
133 | ! |
---|
134 | ! 1850 2016-04-08 13:29:27Z maronga |
---|
135 | ! Module renamed |
---|
136 | ! |
---|
137 | ! 1831 2016-04-07 13:15:51Z hoffmann |
---|
138 | ! curvature_solution_effects moved to particle_attributes |
---|
139 | ! |
---|
140 | ! 1822 2016-04-07 07:49:42Z hoffmann |
---|
141 | ! Unused variables removed. |
---|
142 | ! |
---|
143 | ! 1783 2016-03-06 18:36:17Z raasch |
---|
144 | ! netcdf module added |
---|
145 | ! |
---|
146 | ! 1725 2015-11-17 13:01:51Z hoffmann |
---|
147 | ! Bugfix: Processor-dependent seed for random function is generated before it is |
---|
148 | ! used. |
---|
149 | ! |
---|
150 | ! 1691 2015-10-26 16:17:44Z maronga |
---|
151 | ! Renamed prandtl_layer to constant_flux_layer. |
---|
152 | ! |
---|
153 | ! 1685 2015-10-08 07:32:13Z raasch |
---|
154 | ! bugfix concerning vertical index offset in case of ocean |
---|
155 | ! |
---|
156 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
157 | ! Code annotations made doxygen readable |
---|
158 | ! |
---|
159 | ! 1575 2015-03-27 09:56:27Z raasch |
---|
160 | ! initial vertical particle position is allowed to follow the topography |
---|
161 | ! |
---|
162 | ! 1359 2014-04-11 17:15:14Z hoffmann |
---|
163 | ! New particle structure integrated. |
---|
164 | ! Kind definition added to all floating point numbers. |
---|
165 | ! lpm_init changed form a subroutine to a module. |
---|
166 | ! |
---|
167 | ! 1327 2014-03-21 11:00:16Z raasch |
---|
168 | ! -netcdf_output |
---|
169 | ! |
---|
170 | ! 1322 2014-03-20 16:38:49Z raasch |
---|
171 | ! REAL functions provided with KIND-attribute |
---|
172 | ! |
---|
173 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
174 | ! ONLY-attribute added to USE-statements, |
---|
175 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
176 | ! kinds are defined in new module kinds, |
---|
177 | ! revision history before 2012 removed, |
---|
178 | ! comment fields (!:) to be used for variable explanations added to |
---|
179 | ! all variable declaration statements |
---|
180 | ! bugfix: #if defined( __parallel ) added |
---|
181 | ! |
---|
182 | ! 1314 2014-03-14 18:25:17Z suehring |
---|
183 | ! Vertical logarithmic interpolation of horizontal particle speed for particles |
---|
184 | ! between roughness height and first vertical grid level. |
---|
185 | ! |
---|
186 | ! 1092 2013-02-02 11:24:22Z raasch |
---|
187 | ! unused variables removed |
---|
188 | ! |
---|
189 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
190 | ! code put under GPL (PALM 3.9) |
---|
191 | ! |
---|
192 | ! 849 2012-03-15 10:35:09Z raasch |
---|
193 | ! routine renamed: init_particles -> lpm_init |
---|
194 | ! de_dx, de_dy, de_dz are allocated here (instead of automatic arrays in |
---|
195 | ! advec_particles), |
---|
196 | ! sort_particles renamed lpm_sort_arrays, user_init_particles renamed lpm_init |
---|
197 | ! |
---|
198 | ! 828 2012-02-21 12:00:36Z raasch |
---|
199 | ! call of init_kernels, particle feature color renamed class |
---|
200 | ! |
---|
201 | ! 824 2012-02-17 09:09:57Z raasch |
---|
202 | ! particle attributes speed_x|y|z_sgs renamed rvar1|2|3, |
---|
203 | ! array particles implemented as pointer |
---|
204 | ! |
---|
205 | ! 667 2010-12-23 12:06:00Z suehring/gryschka |
---|
206 | ! nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng for allocation |
---|
207 | ! of arrays. |
---|
208 | ! |
---|
209 | ! Revision 1.1 1999/11/25 16:22:38 raasch |
---|
210 | ! Initial revision |
---|
211 | ! |
---|
212 | ! |
---|
213 | ! Description: |
---|
214 | ! ------------ |
---|
215 | !> This routine initializes a set of particles and their attributes (position, |
---|
216 | !> radius, ..) which are used by the Lagrangian particle model (see lpm). |
---|
217 | !------------------------------------------------------------------------------! |
---|
218 | MODULE lpm_init_mod |
---|
219 | |
---|
220 | USE, INTRINSIC :: ISO_C_BINDING |
---|
221 | |
---|
222 | USE arrays_3d, & |
---|
223 | ONLY: de_dx, de_dy, de_dz, dzw, zu, zw |
---|
224 | |
---|
225 | USE control_parameters, & |
---|
226 | ONLY: cloud_droplets, constant_flux_layer, current_timestep_number, & |
---|
227 | dt_3d, dz, initializing_actions, message_string, ocean, & |
---|
228 | simulated_time |
---|
229 | |
---|
230 | USE grid_variables, & |
---|
231 | ONLY: ddx, dx, ddy, dy |
---|
232 | |
---|
233 | USE indices, & |
---|
234 | ONLY: nx, nxl, nxlg, nxrg, nxr, ny, nyn, nys, nyng, nysg, nz, nzb, & |
---|
235 | nzt, wall_flags_0 |
---|
236 | |
---|
237 | USE kinds |
---|
238 | |
---|
239 | USE lpm_collision_kernels_mod, & |
---|
240 | ONLY: init_kernels |
---|
241 | |
---|
242 | USE netcdf_interface, & |
---|
243 | ONLY: netcdf_data_format |
---|
244 | |
---|
245 | USE particle_attributes, & |
---|
246 | ONLY: alloc_factor, bc_par_b, bc_par_lr, bc_par_ns, bc_par_t, & |
---|
247 | block_offset, block_offset_def, collision_kernel, & |
---|
248 | curvature_solution_effects, density_ratio, grid_particles, & |
---|
249 | isf,i_splitting_mode, initial_weighting_factor, ibc_par_b, & |
---|
250 | ibc_par_lr, ibc_par_ns, ibc_par_t, iran_part, log_z_z0, & |
---|
251 | max_number_of_particle_groups, min_nr_particle, & |
---|
252 | number_concentration, & |
---|
253 | number_particles_per_gridbox, number_of_particles, & |
---|
254 | number_of_particle_groups, number_of_sublayers, & |
---|
255 | offset_ocean_nzt, offset_ocean_nzt_m1, & |
---|
256 | particles, particle_advection_start, particle_groups, & |
---|
257 | particle_groups_type, particles_per_point, & |
---|
258 | particle_type, pdx, pdy, pdz, prt_count, psb, psl, psn, psr, & |
---|
259 | pss, pst, radius, random_start_position, & |
---|
260 | read_particles_from_restartfile, seed_follows_topography, & |
---|
261 | sgs_wf_part, sort_count, splitting_function, splitting_mode, & |
---|
262 | total_number_of_particles, use_sgs_for_particles, & |
---|
263 | write_particle_statistics, zero_particle, z0_av_global |
---|
264 | |
---|
265 | USE pegrid |
---|
266 | |
---|
267 | USE random_function_mod, & |
---|
268 | ONLY: random_function |
---|
269 | |
---|
270 | USE surface_mod, & |
---|
271 | ONLY: get_topography_top_index_ji, surf_def_h, surf_lsm_h, surf_usm_h |
---|
272 | |
---|
273 | USE pmc_particle_interface, & |
---|
274 | ONLY: pmcp_g_init |
---|
275 | |
---|
276 | IMPLICIT NONE |
---|
277 | |
---|
278 | PRIVATE |
---|
279 | |
---|
280 | INTEGER(iwp), PARAMETER :: PHASE_INIT = 1 !< |
---|
281 | INTEGER(iwp), PARAMETER, PUBLIC :: PHASE_RELEASE = 2 !< |
---|
282 | |
---|
283 | INTERFACE lpm_init |
---|
284 | MODULE PROCEDURE lpm_init |
---|
285 | END INTERFACE lpm_init |
---|
286 | |
---|
287 | INTERFACE lpm_create_particle |
---|
288 | MODULE PROCEDURE lpm_create_particle |
---|
289 | END INTERFACE lpm_create_particle |
---|
290 | |
---|
291 | PUBLIC lpm_init, lpm_create_particle |
---|
292 | |
---|
293 | CONTAINS |
---|
294 | |
---|
295 | !------------------------------------------------------------------------------! |
---|
296 | ! Description: |
---|
297 | ! ------------ |
---|
298 | !> @todo Missing subroutine description. |
---|
299 | !------------------------------------------------------------------------------! |
---|
300 | SUBROUTINE lpm_init |
---|
301 | |
---|
302 | USE lpm_collision_kernels_mod, & |
---|
303 | ONLY: init_kernels |
---|
304 | |
---|
305 | USE pmc_interface, & |
---|
306 | ONLY: nested_run |
---|
307 | |
---|
308 | IMPLICIT NONE |
---|
309 | |
---|
310 | INTEGER(iwp) :: i !< |
---|
311 | INTEGER(iwp) :: j !< |
---|
312 | INTEGER(iwp) :: k !< |
---|
313 | |
---|
314 | REAL(wp) :: div !< |
---|
315 | REAL(wp) :: height_int !< |
---|
316 | REAL(wp) :: height_p !< |
---|
317 | REAL(wp) :: z_p !< |
---|
318 | REAL(wp) :: z0_av_local !< |
---|
319 | |
---|
320 | |
---|
321 | ! |
---|
322 | !-- In case of oceans runs, the vertical index calculations need an offset, |
---|
323 | !-- because otherwise the k indices will become negative |
---|
324 | IF ( ocean ) THEN |
---|
325 | offset_ocean_nzt = nzt |
---|
326 | offset_ocean_nzt_m1 = nzt - 1 |
---|
327 | ENDIF |
---|
328 | |
---|
329 | ! |
---|
330 | !-- Define block offsets for dividing a gridcell in 8 sub cells |
---|
331 | !-- See documentation for List of subgrid boxes |
---|
332 | !-- See pack_and_sort in lpm_pack_arrays.f90 for assignment of the subgrid boxes |
---|
333 | block_offset(0) = block_offset_def ( 0, 0, 0) |
---|
334 | block_offset(1) = block_offset_def ( 0, 0,-1) |
---|
335 | block_offset(2) = block_offset_def ( 0,-1, 0) |
---|
336 | block_offset(3) = block_offset_def ( 0,-1,-1) |
---|
337 | block_offset(4) = block_offset_def (-1, 0, 0) |
---|
338 | block_offset(5) = block_offset_def (-1, 0,-1) |
---|
339 | block_offset(6) = block_offset_def (-1,-1, 0) |
---|
340 | block_offset(7) = block_offset_def (-1,-1,-1) |
---|
341 | ! |
---|
342 | !-- Check the number of particle groups. |
---|
343 | IF ( number_of_particle_groups > max_number_of_particle_groups ) THEN |
---|
344 | WRITE( message_string, * ) 'max_number_of_particle_groups =', & |
---|
345 | max_number_of_particle_groups , & |
---|
346 | '&number_of_particle_groups reset to ', & |
---|
347 | max_number_of_particle_groups |
---|
348 | CALL message( 'lpm_init', 'PA0213', 0, 1, 0, 6, 0 ) |
---|
349 | number_of_particle_groups = max_number_of_particle_groups |
---|
350 | ENDIF |
---|
351 | ! |
---|
352 | !-- Check if downward-facing walls exist. This case, reflection boundary |
---|
353 | !-- conditions (as well as subgrid-scale velocities) may do not work |
---|
354 | !-- propably (not realized so far). |
---|
355 | IF ( surf_def_h(1)%ns >= 1 ) THEN |
---|
356 | WRITE( message_string, * ) 'Overhanging topography do not work '// & |
---|
357 | 'with particles' |
---|
358 | CALL message( 'lpm_init', 'PA0212', 0, 1, 0, 6, 0 ) |
---|
359 | |
---|
360 | ENDIF |
---|
361 | |
---|
362 | ! |
---|
363 | !-- Set default start positions, if necessary |
---|
364 | IF ( psl(1) == 9999999.9_wp ) psl(1) = 0.0_wp |
---|
365 | IF ( psr(1) == 9999999.9_wp ) psr(1) = ( nx +1 ) * dx |
---|
366 | IF ( pss(1) == 9999999.9_wp ) pss(1) = 0.0_wp |
---|
367 | IF ( psn(1) == 9999999.9_wp ) psn(1) = ( ny +1 ) * dy |
---|
368 | IF ( psb(1) == 9999999.9_wp ) psb(1) = zu(nz/2) |
---|
369 | IF ( pst(1) == 9999999.9_wp ) pst(1) = psb(1) |
---|
370 | |
---|
371 | IF ( pdx(1) == 9999999.9_wp .OR. pdx(1) == 0.0_wp ) pdx(1) = dx |
---|
372 | IF ( pdy(1) == 9999999.9_wp .OR. pdy(1) == 0.0_wp ) pdy(1) = dy |
---|
373 | IF ( pdz(1) == 9999999.9_wp .OR. pdz(1) == 0.0_wp ) pdz(1) = zu(2) - zu(1) |
---|
374 | |
---|
375 | ! |
---|
376 | !-- If number_particles_per_gridbox is set, the parametres pdx, pdy and pdz are |
---|
377 | !-- calculated diagnostically. Therfore an isotropic distribution is prescribed. |
---|
378 | IF ( number_particles_per_gridbox /= -1 .AND. & |
---|
379 | number_particles_per_gridbox >= 1 ) THEN |
---|
380 | pdx(1) = (( dx * dy * ( zu(2) - zu(1) ) ) / & |
---|
381 | REAL(number_particles_per_gridbox))**0.3333333_wp |
---|
382 | ! |
---|
383 | !-- Ensure a smooth value (two significant digits) of distance between |
---|
384 | !-- particles (pdx, pdy, pdz). |
---|
385 | div = 1000.0_wp |
---|
386 | DO WHILE ( pdx(1) < div ) |
---|
387 | div = div / 10.0_wp |
---|
388 | ENDDO |
---|
389 | pdx(1) = NINT( pdx(1) * 100.0_wp / div ) * div / 100.0_wp |
---|
390 | pdy(1) = pdx(1) |
---|
391 | pdz(1) = pdx(1) |
---|
392 | |
---|
393 | ENDIF |
---|
394 | |
---|
395 | DO j = 2, number_of_particle_groups |
---|
396 | IF ( psl(j) == 9999999.9_wp ) psl(j) = psl(j-1) |
---|
397 | IF ( psr(j) == 9999999.9_wp ) psr(j) = psr(j-1) |
---|
398 | IF ( pss(j) == 9999999.9_wp ) pss(j) = pss(j-1) |
---|
399 | IF ( psn(j) == 9999999.9_wp ) psn(j) = psn(j-1) |
---|
400 | IF ( psb(j) == 9999999.9_wp ) psb(j) = psb(j-1) |
---|
401 | IF ( pst(j) == 9999999.9_wp ) pst(j) = pst(j-1) |
---|
402 | IF ( pdx(j) == 9999999.9_wp .OR. pdx(j) == 0.0_wp ) pdx(j) = pdx(j-1) |
---|
403 | IF ( pdy(j) == 9999999.9_wp .OR. pdy(j) == 0.0_wp ) pdy(j) = pdy(j-1) |
---|
404 | IF ( pdz(j) == 9999999.9_wp .OR. pdz(j) == 0.0_wp ) pdz(j) = pdz(j-1) |
---|
405 | ENDDO |
---|
406 | |
---|
407 | ! |
---|
408 | !-- Allocate arrays required for calculating particle SGS velocities. |
---|
409 | !-- Initialize prefactor required for stoachastic Weil equation. |
---|
410 | IF ( use_sgs_for_particles .AND. .NOT. cloud_droplets ) THEN |
---|
411 | ALLOCATE( de_dx(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
412 | de_dy(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
413 | de_dz(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
414 | |
---|
415 | sgs_wf_part = 1.0_wp / 3.0_wp |
---|
416 | ENDIF |
---|
417 | |
---|
418 | ! |
---|
419 | !-- Allocate array required for logarithmic vertical interpolation of |
---|
420 | !-- horizontal particle velocities between the surface and the first vertical |
---|
421 | !-- grid level. In order to avoid repeated CPU cost-intensive CALLS of |
---|
422 | !-- intrinsic FORTRAN procedure LOG(z/z0), LOG(z/z0) is precalculated for |
---|
423 | !-- several heights. Splitting into 20 sublayers turned out to be sufficient. |
---|
424 | !-- To obtain exact height levels of particles, linear interpolation is applied |
---|
425 | !-- (see lpm_advec.f90). |
---|
426 | IF ( constant_flux_layer ) THEN |
---|
427 | |
---|
428 | ALLOCATE ( log_z_z0(0:number_of_sublayers) ) |
---|
429 | z_p = zu(nzb+1) - zw(nzb) |
---|
430 | |
---|
431 | ! |
---|
432 | !-- Calculate horizontal mean value of z0 used for logartihmic |
---|
433 | !-- interpolation. Note: this is not exact for heterogeneous z0. |
---|
434 | !-- However, sensitivity studies showed that the effect is |
---|
435 | !-- negligible. |
---|
436 | z0_av_local = SUM( surf_def_h(0)%z0 ) + SUM( surf_lsm_h%z0 ) + & |
---|
437 | SUM( surf_usm_h%z0 ) |
---|
438 | z0_av_global = 0.0_wp |
---|
439 | |
---|
440 | #if defined( __parallel ) |
---|
441 | CALL MPI_ALLREDUCE(z0_av_local, z0_av_global, 1, MPI_REAL, MPI_SUM, & |
---|
442 | comm2d, ierr ) |
---|
443 | #else |
---|
444 | z0_av_global = z0_av_local |
---|
445 | #endif |
---|
446 | |
---|
447 | z0_av_global = z0_av_global / ( ( ny + 1 ) * ( nx + 1 ) ) |
---|
448 | ! |
---|
449 | !-- Horizontal wind speed is zero below and at z0 |
---|
450 | log_z_z0(0) = 0.0_wp |
---|
451 | ! |
---|
452 | !-- Calculate vertical depth of the sublayers |
---|
453 | height_int = ( z_p - z0_av_global ) / REAL( number_of_sublayers, KIND=wp ) |
---|
454 | ! |
---|
455 | !-- Precalculate LOG(z/z0) |
---|
456 | height_p = z0_av_global |
---|
457 | DO k = 1, number_of_sublayers |
---|
458 | |
---|
459 | height_p = height_p + height_int |
---|
460 | log_z_z0(k) = LOG( height_p / z0_av_global ) |
---|
461 | |
---|
462 | ENDDO |
---|
463 | |
---|
464 | ENDIF |
---|
465 | |
---|
466 | ! |
---|
467 | !-- Check boundary condition and set internal variables |
---|
468 | SELECT CASE ( bc_par_b ) |
---|
469 | |
---|
470 | CASE ( 'absorb' ) |
---|
471 | ibc_par_b = 1 |
---|
472 | |
---|
473 | CASE ( 'reflect' ) |
---|
474 | ibc_par_b = 2 |
---|
475 | |
---|
476 | CASE DEFAULT |
---|
477 | WRITE( message_string, * ) 'unknown boundary condition ', & |
---|
478 | 'bc_par_b = "', TRIM( bc_par_b ), '"' |
---|
479 | CALL message( 'lpm_init', 'PA0217', 1, 2, 0, 6, 0 ) |
---|
480 | |
---|
481 | END SELECT |
---|
482 | SELECT CASE ( bc_par_t ) |
---|
483 | |
---|
484 | CASE ( 'absorb' ) |
---|
485 | ibc_par_t = 1 |
---|
486 | |
---|
487 | CASE ( 'reflect' ) |
---|
488 | ibc_par_t = 2 |
---|
489 | |
---|
490 | CASE ( 'nested' ) |
---|
491 | ibc_par_t = 3 |
---|
492 | |
---|
493 | CASE DEFAULT |
---|
494 | WRITE( message_string, * ) 'unknown boundary condition ', & |
---|
495 | 'bc_par_t = "', TRIM( bc_par_t ), '"' |
---|
496 | CALL message( 'lpm_init', 'PA0218', 1, 2, 0, 6, 0 ) |
---|
497 | |
---|
498 | END SELECT |
---|
499 | SELECT CASE ( bc_par_lr ) |
---|
500 | |
---|
501 | CASE ( 'cyclic' ) |
---|
502 | ibc_par_lr = 0 |
---|
503 | |
---|
504 | CASE ( 'absorb' ) |
---|
505 | ibc_par_lr = 1 |
---|
506 | |
---|
507 | CASE ( 'reflect' ) |
---|
508 | ibc_par_lr = 2 |
---|
509 | |
---|
510 | CASE ( 'nested' ) |
---|
511 | ibc_par_lr = 3 |
---|
512 | |
---|
513 | CASE DEFAULT |
---|
514 | WRITE( message_string, * ) 'unknown boundary condition ', & |
---|
515 | 'bc_par_lr = "', TRIM( bc_par_lr ), '"' |
---|
516 | CALL message( 'lpm_init', 'PA0219', 1, 2, 0, 6, 0 ) |
---|
517 | |
---|
518 | END SELECT |
---|
519 | SELECT CASE ( bc_par_ns ) |
---|
520 | |
---|
521 | CASE ( 'cyclic' ) |
---|
522 | ibc_par_ns = 0 |
---|
523 | |
---|
524 | CASE ( 'absorb' ) |
---|
525 | ibc_par_ns = 1 |
---|
526 | |
---|
527 | CASE ( 'reflect' ) |
---|
528 | ibc_par_ns = 2 |
---|
529 | |
---|
530 | CASE ( 'nested' ) |
---|
531 | ibc_par_ns = 3 |
---|
532 | |
---|
533 | CASE DEFAULT |
---|
534 | WRITE( message_string, * ) 'unknown boundary condition ', & |
---|
535 | 'bc_par_ns = "', TRIM( bc_par_ns ), '"' |
---|
536 | CALL message( 'lpm_init', 'PA0220', 1, 2, 0, 6, 0 ) |
---|
537 | |
---|
538 | END SELECT |
---|
539 | SELECT CASE ( splitting_mode ) |
---|
540 | |
---|
541 | CASE ( 'const' ) |
---|
542 | i_splitting_mode = 1 |
---|
543 | |
---|
544 | CASE ( 'cl_av' ) |
---|
545 | i_splitting_mode = 2 |
---|
546 | |
---|
547 | CASE ( 'gb_av' ) |
---|
548 | i_splitting_mode = 3 |
---|
549 | |
---|
550 | CASE DEFAULT |
---|
551 | WRITE( message_string, * ) 'unknown splitting_mode = "', & |
---|
552 | TRIM( splitting_mode ), '"' |
---|
553 | CALL message( 'lpm_init', 'PA0146', 1, 2, 0, 6, 0 ) |
---|
554 | |
---|
555 | END SELECT |
---|
556 | SELECT CASE ( splitting_function ) |
---|
557 | |
---|
558 | CASE ( 'gamma' ) |
---|
559 | isf = 1 |
---|
560 | |
---|
561 | CASE ( 'log' ) |
---|
562 | isf = 2 |
---|
563 | |
---|
564 | CASE ( 'exp' ) |
---|
565 | isf = 3 |
---|
566 | |
---|
567 | CASE DEFAULT |
---|
568 | WRITE( message_string, * ) 'unknown splitting function = "', & |
---|
569 | TRIM( splitting_function ), '"' |
---|
570 | CALL message( 'lpm_init', 'PA0147', 1, 2, 0, 6, 0 ) |
---|
571 | |
---|
572 | END SELECT |
---|
573 | |
---|
574 | |
---|
575 | ! |
---|
576 | !-- Initialize collision kernels |
---|
577 | IF ( collision_kernel /= 'none' ) CALL init_kernels |
---|
578 | |
---|
579 | ! |
---|
580 | !-- For the first model run of a possible job chain initialize the |
---|
581 | !-- particles, otherwise read the particle data from restart file. |
---|
582 | IF ( TRIM( initializing_actions ) == 'read_restart_data' & |
---|
583 | .AND. read_particles_from_restartfile ) THEN |
---|
584 | |
---|
585 | CALL lpm_read_restart_file |
---|
586 | |
---|
587 | ELSE |
---|
588 | |
---|
589 | ! |
---|
590 | !-- Allocate particle arrays and set attributes of the initial set of |
---|
591 | !-- particles, which can be also periodically released at later times. |
---|
592 | ALLOCATE( prt_count(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
593 | grid_particles(nzb+1:nzt,nys:nyn,nxl:nxr) ) |
---|
594 | |
---|
595 | number_of_particles = 0 |
---|
596 | |
---|
597 | sort_count = 0 |
---|
598 | prt_count = 0 |
---|
599 | |
---|
600 | ! |
---|
601 | !-- initialize counter for particle IDs |
---|
602 | grid_particles%id_counter = 1 |
---|
603 | |
---|
604 | ! |
---|
605 | !-- Initialize all particles with dummy values (otherwise errors may |
---|
606 | !-- occur within restart runs). The reason for this is still not clear |
---|
607 | !-- and may be presumably caused by errors in the respective user-interface. |
---|
608 | zero_particle = particle_type( 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, & |
---|
609 | 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, & |
---|
610 | 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, & |
---|
611 | 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, & |
---|
612 | 0, 0, 0_idp, .FALSE., -1 ) |
---|
613 | |
---|
614 | particle_groups = particle_groups_type( 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp ) |
---|
615 | |
---|
616 | ! |
---|
617 | !-- Set values for the density ratio and radius for all particle |
---|
618 | !-- groups, if necessary |
---|
619 | IF ( density_ratio(1) == 9999999.9_wp ) density_ratio(1) = 0.0_wp |
---|
620 | IF ( radius(1) == 9999999.9_wp ) radius(1) = 0.0_wp |
---|
621 | DO i = 2, number_of_particle_groups |
---|
622 | IF ( density_ratio(i) == 9999999.9_wp ) THEN |
---|
623 | density_ratio(i) = density_ratio(i-1) |
---|
624 | ENDIF |
---|
625 | IF ( radius(i) == 9999999.9_wp ) radius(i) = radius(i-1) |
---|
626 | ENDDO |
---|
627 | |
---|
628 | DO i = 1, number_of_particle_groups |
---|
629 | IF ( density_ratio(i) /= 0.0_wp .AND. radius(i) == 0 ) THEN |
---|
630 | WRITE( message_string, * ) 'particle group #', i, ' has a', & |
---|
631 | 'density ratio /= 0 but radius = 0' |
---|
632 | CALL message( 'lpm_init', 'PA0215', 1, 2, 0, 6, 0 ) |
---|
633 | ENDIF |
---|
634 | particle_groups(i)%density_ratio = density_ratio(i) |
---|
635 | particle_groups(i)%radius = radius(i) |
---|
636 | ENDDO |
---|
637 | |
---|
638 | ! |
---|
639 | !-- Set a seed value for the random number generator to be exclusively |
---|
640 | !-- used for the particle code. The generated random numbers should be |
---|
641 | !-- different on the different PEs. |
---|
642 | iran_part = iran_part + myid |
---|
643 | |
---|
644 | CALL lpm_create_particle (PHASE_INIT) |
---|
645 | ! |
---|
646 | !-- User modification of initial particles |
---|
647 | CALL user_lpm_init |
---|
648 | |
---|
649 | ! |
---|
650 | !-- Open file for statistical informations about particle conditions |
---|
651 | IF ( write_particle_statistics ) THEN |
---|
652 | CALL check_open( 80 ) |
---|
653 | WRITE ( 80, 8000 ) current_timestep_number, simulated_time, & |
---|
654 | number_of_particles |
---|
655 | CALL close_file( 80 ) |
---|
656 | ENDIF |
---|
657 | |
---|
658 | ENDIF |
---|
659 | |
---|
660 | IF ( nested_run ) CALL pmcp_g_init |
---|
661 | |
---|
662 | ! |
---|
663 | !-- To avoid programm abort, assign particles array to the local version of |
---|
664 | !-- first grid cell |
---|
665 | number_of_particles = prt_count(nzb+1,nys,nxl) |
---|
666 | particles => grid_particles(nzb+1,nys,nxl)%particles(1:number_of_particles) |
---|
667 | ! |
---|
668 | !-- Formats |
---|
669 | 8000 FORMAT (I6,1X,F7.2,4X,I10,71X,I10) |
---|
670 | |
---|
671 | END SUBROUTINE lpm_init |
---|
672 | |
---|
673 | !------------------------------------------------------------------------------! |
---|
674 | ! Description: |
---|
675 | ! ------------ |
---|
676 | !> @todo Missing subroutine description. |
---|
677 | !------------------------------------------------------------------------------! |
---|
678 | SUBROUTINE lpm_create_particle (phase) |
---|
679 | |
---|
680 | USE arrays_3d, & |
---|
681 | ONLY: zw |
---|
682 | USE lpm_exchange_horiz_mod, & |
---|
683 | ONLY: lpm_exchange_horiz, lpm_move_particle, realloc_particles_array |
---|
684 | |
---|
685 | USE lpm_pack_and_sort_mod, & |
---|
686 | ONLY: lpm_sort_in_subboxes |
---|
687 | |
---|
688 | USE particle_attributes, & |
---|
689 | ONLY: deleted_particles |
---|
690 | |
---|
691 | IMPLICIT NONE |
---|
692 | |
---|
693 | INTEGER(iwp) :: alloc_size !< relative increase of allocated memory for particles |
---|
694 | INTEGER(iwp) :: i !< loop variable ( particle groups ) |
---|
695 | INTEGER(iwp) :: ip !< index variable along x |
---|
696 | INTEGER(iwp) :: j !< loop variable ( particles per point ) |
---|
697 | INTEGER(iwp) :: jp !< index variable along y |
---|
698 | INTEGER(iwp) :: k !< index variable along z |
---|
699 | INTEGER(iwp) :: k_surf !< index of surface grid point |
---|
700 | INTEGER(iwp) :: kp !< index variable along z |
---|
701 | INTEGER(iwp) :: loop_stride !< loop variable for initialization |
---|
702 | INTEGER(iwp) :: n !< loop variable ( number of particles ) |
---|
703 | INTEGER(iwp) :: new_size !< new size of allocated memory for particles |
---|
704 | |
---|
705 | INTEGER(iwp), INTENT(IN) :: phase !< mode of inititialization |
---|
706 | |
---|
707 | INTEGER(iwp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: local_count !< start address of new particle |
---|
708 | INTEGER(iwp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: local_start !< start address of new particle |
---|
709 | |
---|
710 | LOGICAL :: first_stride !< flag for initialization |
---|
711 | |
---|
712 | REAL(wp) :: pos_x !< increment for particle position in x |
---|
713 | REAL(wp) :: pos_y !< increment for particle position in y |
---|
714 | REAL(wp) :: pos_z !< increment for particle position in z |
---|
715 | REAL(wp) :: rand_contr !< dummy argument for random position |
---|
716 | |
---|
717 | TYPE(particle_type),TARGET :: tmp_particle !< temporary particle used for initialization |
---|
718 | |
---|
719 | ! |
---|
720 | !-- Calculate particle positions and store particle attributes, if |
---|
721 | !-- particle is situated on this PE |
---|
722 | DO loop_stride = 1, 2 |
---|
723 | first_stride = (loop_stride == 1) |
---|
724 | IF ( first_stride ) THEN |
---|
725 | local_count = 0 ! count number of particles |
---|
726 | ELSE |
---|
727 | local_count = prt_count ! Start address of new particles |
---|
728 | ENDIF |
---|
729 | |
---|
730 | ! |
---|
731 | !-- Calculate initial_weighting_factor diagnostically |
---|
732 | IF ( number_concentration /= -1.0_wp .AND. number_concentration > 0.0_wp ) THEN |
---|
733 | initial_weighting_factor = number_concentration * 1.0E6_wp * & |
---|
734 | pdx(1) * pdy(1) * pdz(1) |
---|
735 | END IF |
---|
736 | |
---|
737 | n = 0 |
---|
738 | DO i = 1, number_of_particle_groups |
---|
739 | |
---|
740 | pos_z = psb(i) |
---|
741 | |
---|
742 | DO WHILE ( pos_z <= pst(i) ) |
---|
743 | |
---|
744 | IF ( pos_z >= zw(0) .AND. pos_z < zw(nzt) ) THEN |
---|
745 | |
---|
746 | |
---|
747 | pos_y = pss(i) |
---|
748 | |
---|
749 | DO WHILE ( pos_y <= psn(i) ) |
---|
750 | |
---|
751 | IF ( pos_y >= nys * dy .AND. & |
---|
752 | pos_y < ( nyn + 1 ) * dy ) THEN |
---|
753 | |
---|
754 | pos_x = psl(i) |
---|
755 | |
---|
756 | xloop: DO WHILE ( pos_x <= psr(i) ) |
---|
757 | |
---|
758 | IF ( pos_x >= nxl * dx .AND. & |
---|
759 | pos_x < ( nxr + 1) * dx ) THEN |
---|
760 | |
---|
761 | DO j = 1, particles_per_point |
---|
762 | |
---|
763 | |
---|
764 | n = n + 1 |
---|
765 | tmp_particle%x = pos_x |
---|
766 | tmp_particle%y = pos_y |
---|
767 | tmp_particle%z = pos_z |
---|
768 | tmp_particle%age = 0.0_wp |
---|
769 | tmp_particle%age_m = 0.0_wp |
---|
770 | tmp_particle%dt_sum = 0.0_wp |
---|
771 | tmp_particle%e_m = 0.0_wp |
---|
772 | tmp_particle%rvar1 = 0.0_wp |
---|
773 | tmp_particle%rvar2 = 0.0_wp |
---|
774 | tmp_particle%rvar3 = 0.0_wp |
---|
775 | tmp_particle%speed_x = 0.0_wp |
---|
776 | tmp_particle%speed_y = 0.0_wp |
---|
777 | tmp_particle%speed_z = 0.0_wp |
---|
778 | tmp_particle%origin_x = pos_x |
---|
779 | tmp_particle%origin_y = pos_y |
---|
780 | tmp_particle%origin_z = pos_z |
---|
781 | IF ( curvature_solution_effects ) THEN |
---|
782 | tmp_particle%aux1 = 0.0_wp ! dry aerosol radius |
---|
783 | tmp_particle%aux2 = dt_3d ! last Rosenbrock timestep |
---|
784 | ELSE |
---|
785 | tmp_particle%aux1 = 0.0_wp ! free to use |
---|
786 | tmp_particle%aux2 = 0.0_wp ! free to use |
---|
787 | ENDIF |
---|
788 | tmp_particle%radius = particle_groups(i)%radius |
---|
789 | tmp_particle%weight_factor = initial_weighting_factor |
---|
790 | tmp_particle%class = 1 |
---|
791 | tmp_particle%group = i |
---|
792 | tmp_particle%id = 0_idp |
---|
793 | tmp_particle%particle_mask = .TRUE. |
---|
794 | tmp_particle%block_nr = -1 |
---|
795 | ! |
---|
796 | !-- Determine the grid indices of the particle position |
---|
797 | ip = tmp_particle%x * ddx |
---|
798 | jp = tmp_particle%y * ddy |
---|
799 | kp = tmp_particle%z / dz(1) + 1 + offset_ocean_nzt |
---|
800 | DO WHILE( zw(kp) < tmp_particle%z ) |
---|
801 | kp = kp + 1 |
---|
802 | ENDDO |
---|
803 | DO WHILE( zw(kp-1) > tmp_particle%z ) |
---|
804 | kp = kp - 1 |
---|
805 | ENDDO |
---|
806 | ! |
---|
807 | !-- Determine surface level. Therefore, check for |
---|
808 | !-- upward-facing wall on w-grid. |
---|
809 | k_surf = get_topography_top_index_ji( jp, ip, 'w' ) |
---|
810 | |
---|
811 | IF ( seed_follows_topography ) THEN |
---|
812 | ! |
---|
813 | !-- Particle height is given relative to topography |
---|
814 | kp = kp + k_surf |
---|
815 | tmp_particle%z = tmp_particle%z + zw(k_surf) |
---|
816 | !-- Skip particle release if particle position is |
---|
817 | !-- above model top, or within topography in case |
---|
818 | !-- of overhanging structures. |
---|
819 | IF ( kp > nzt .OR. & |
---|
820 | .NOT. BTEST( wall_flags_0(kp,jp,ip), 0 ) ) THEN |
---|
821 | pos_x = pos_x + pdx(i) |
---|
822 | CYCLE xloop |
---|
823 | ENDIF |
---|
824 | ! |
---|
825 | !-- Skip particle release if particle position is |
---|
826 | !-- below surface, or within topography in case |
---|
827 | !-- of overhanging structures. |
---|
828 | ELSEIF ( .NOT. seed_follows_topography .AND. & |
---|
829 | tmp_particle%z <= zw(k_surf) .OR. & |
---|
830 | .NOT. BTEST( wall_flags_0(kp,jp,ip), 0 ) )& |
---|
831 | THEN |
---|
832 | pos_x = pos_x + pdx(i) |
---|
833 | CYCLE xloop |
---|
834 | ENDIF |
---|
835 | |
---|
836 | local_count(kp,jp,ip) = local_count(kp,jp,ip) + 1 |
---|
837 | |
---|
838 | IF ( .NOT. first_stride ) THEN |
---|
839 | IF ( ip < nxl .OR. jp < nys .OR. kp < nzb+1 ) THEN |
---|
840 | write(6,*) 'xl ',ip,jp,kp,nxl,nys,nzb+1 |
---|
841 | ENDIF |
---|
842 | IF ( ip > nxr .OR. jp > nyn .OR. kp > nzt ) THEN |
---|
843 | write(6,*) 'xu ',ip,jp,kp,nxr,nyn,nzt |
---|
844 | ENDIF |
---|
845 | grid_particles(kp,jp,ip)%particles(local_count(kp,jp,ip)) = tmp_particle |
---|
846 | |
---|
847 | ENDIF |
---|
848 | ENDDO |
---|
849 | |
---|
850 | ENDIF |
---|
851 | |
---|
852 | pos_x = pos_x + pdx(i) |
---|
853 | |
---|
854 | ENDDO xloop |
---|
855 | |
---|
856 | ENDIF |
---|
857 | |
---|
858 | pos_y = pos_y + pdy(i) |
---|
859 | |
---|
860 | ENDDO |
---|
861 | |
---|
862 | ENDIF |
---|
863 | |
---|
864 | pos_z = pos_z + pdz(i) |
---|
865 | |
---|
866 | ENDDO |
---|
867 | |
---|
868 | ENDDO |
---|
869 | |
---|
870 | IF ( first_stride ) THEN |
---|
871 | DO ip = nxl, nxr |
---|
872 | DO jp = nys, nyn |
---|
873 | DO kp = nzb+1, nzt |
---|
874 | IF ( phase == PHASE_INIT ) THEN |
---|
875 | IF ( local_count(kp,jp,ip) > 0 ) THEN |
---|
876 | alloc_size = MAX( INT( local_count(kp,jp,ip) * & |
---|
877 | ( 1.0_wp + alloc_factor / 100.0_wp ) ), & |
---|
878 | min_nr_particle ) |
---|
879 | ELSE |
---|
880 | alloc_size = min_nr_particle |
---|
881 | ENDIF |
---|
882 | ALLOCATE(grid_particles(kp,jp,ip)%particles(1:alloc_size)) |
---|
883 | DO n = 1, alloc_size |
---|
884 | grid_particles(kp,jp,ip)%particles(n) = zero_particle |
---|
885 | ENDDO |
---|
886 | ELSEIF ( phase == PHASE_RELEASE ) THEN |
---|
887 | IF ( local_count(kp,jp,ip) > 0 ) THEN |
---|
888 | new_size = local_count(kp,jp,ip) + prt_count(kp,jp,ip) |
---|
889 | alloc_size = MAX( INT( new_size * ( 1.0_wp + & |
---|
890 | alloc_factor / 100.0_wp ) ), min_nr_particle ) |
---|
891 | IF( alloc_size > SIZE( grid_particles(kp,jp,ip)%particles) ) THEN |
---|
892 | CALL realloc_particles_array(ip,jp,kp,alloc_size) |
---|
893 | ENDIF |
---|
894 | ENDIF |
---|
895 | ENDIF |
---|
896 | ENDDO |
---|
897 | ENDDO |
---|
898 | ENDDO |
---|
899 | ENDIF |
---|
900 | |
---|
901 | ENDDO |
---|
902 | |
---|
903 | |
---|
904 | |
---|
905 | local_start = prt_count+1 |
---|
906 | prt_count = local_count |
---|
907 | |
---|
908 | ! |
---|
909 | !-- Calculate particle IDs |
---|
910 | DO ip = nxl, nxr |
---|
911 | DO jp = nys, nyn |
---|
912 | DO kp = nzb+1, nzt |
---|
913 | number_of_particles = prt_count(kp,jp,ip) |
---|
914 | IF ( number_of_particles <= 0 ) CYCLE |
---|
915 | particles => grid_particles(kp,jp,ip)%particles(1:number_of_particles) |
---|
916 | |
---|
917 | DO n = local_start(kp,jp,ip), number_of_particles !only new particles |
---|
918 | |
---|
919 | particles(n)%id = 10000_idp**3 * grid_particles(kp,jp,ip)%id_counter + & |
---|
920 | 10000_idp**2 * kp + 10000_idp * jp + ip |
---|
921 | ! |
---|
922 | !-- Count the number of particles that have been released before |
---|
923 | grid_particles(kp,jp,ip)%id_counter = & |
---|
924 | grid_particles(kp,jp,ip)%id_counter + 1 |
---|
925 | |
---|
926 | ENDDO |
---|
927 | |
---|
928 | ENDDO |
---|
929 | ENDDO |
---|
930 | ENDDO |
---|
931 | |
---|
932 | ! |
---|
933 | !-- Initialize aerosol background spectrum |
---|
934 | IF ( curvature_solution_effects ) THEN |
---|
935 | CALL lpm_init_aerosols(local_start) |
---|
936 | ENDIF |
---|
937 | |
---|
938 | ! |
---|
939 | !-- Add random fluctuation to particle positions. |
---|
940 | IF ( random_start_position ) THEN |
---|
941 | DO ip = nxl, nxr |
---|
942 | DO jp = nys, nyn |
---|
943 | DO kp = nzb+1, nzt |
---|
944 | number_of_particles = prt_count(kp,jp,ip) |
---|
945 | IF ( number_of_particles <= 0 ) CYCLE |
---|
946 | particles => grid_particles(kp,jp,ip)%particles(1:number_of_particles) |
---|
947 | ! |
---|
948 | !-- Move only new particles. Moreover, limit random fluctuation |
---|
949 | !-- in order to prevent that particles move more than one grid box, |
---|
950 | !-- which would lead to problems concerning particle exchange |
---|
951 | !-- between processors in case pdx/pdy are larger than dx/dy, |
---|
952 | !-- respectively. |
---|
953 | DO n = local_start(kp,jp,ip), number_of_particles |
---|
954 | IF ( psl(particles(n)%group) /= psr(particles(n)%group) ) THEN |
---|
955 | rand_contr = ( random_function( iran_part ) - 0.5_wp ) * & |
---|
956 | pdx(particles(n)%group) |
---|
957 | particles(n)%x = particles(n)%x + & |
---|
958 | MERGE( rand_contr, SIGN( dx, rand_contr ), & |
---|
959 | ABS( rand_contr ) < dx & |
---|
960 | ) |
---|
961 | ENDIF |
---|
962 | IF ( pss(particles(n)%group) /= psn(particles(n)%group) ) THEN |
---|
963 | rand_contr = ( random_function( iran_part ) - 0.5_wp ) * & |
---|
964 | pdy(particles(n)%group) |
---|
965 | particles(n)%y = particles(n)%y + & |
---|
966 | MERGE( rand_contr, SIGN( dy, rand_contr ), & |
---|
967 | ABS( rand_contr ) < dy & |
---|
968 | ) |
---|
969 | ENDIF |
---|
970 | IF ( psb(particles(n)%group) /= pst(particles(n)%group) ) THEN |
---|
971 | rand_contr = ( random_function( iran_part ) - 0.5_wp ) * & |
---|
972 | pdz(particles(n)%group) |
---|
973 | particles(n)%z = particles(n)%z + & |
---|
974 | MERGE( rand_contr, SIGN( dzw(kp), rand_contr ), & |
---|
975 | ABS( rand_contr ) < dzw(kp) & |
---|
976 | ) |
---|
977 | ENDIF |
---|
978 | ENDDO |
---|
979 | ! |
---|
980 | !-- Identify particles located outside the model domain and reflect |
---|
981 | !-- or absorb them if necessary. |
---|
982 | CALL lpm_boundary_conds( 'bottom/top', i, j, k ) |
---|
983 | ! |
---|
984 | !-- Furthermore, remove particles located in topography. Note, as |
---|
985 | !-- the particle speed is still zero at this point, wall |
---|
986 | !-- reflection boundary conditions will not work in this case. |
---|
987 | particles => & |
---|
988 | grid_particles(kp,jp,ip)%particles(1:number_of_particles) |
---|
989 | DO n = local_start(kp,jp,ip), number_of_particles |
---|
990 | i = particles(n)%x * ddx |
---|
991 | j = particles(n)%y * ddy |
---|
992 | k = particles(n)%z / dz(1) + 1 + offset_ocean_nzt |
---|
993 | DO WHILE( zw(k) < particles(n)%z ) |
---|
994 | k = k + 1 |
---|
995 | ENDDO |
---|
996 | DO WHILE( zw(k-1) > particles(n)%z ) |
---|
997 | k = k - 1 |
---|
998 | ENDDO |
---|
999 | ! |
---|
1000 | !-- Check if particle is within topography |
---|
1001 | IF ( .NOT. BTEST( wall_flags_0(k,j,i), 0 ) ) THEN |
---|
1002 | particles(n)%particle_mask = .FALSE. |
---|
1003 | deleted_particles = deleted_particles + 1 |
---|
1004 | ENDIF |
---|
1005 | |
---|
1006 | ENDDO |
---|
1007 | ENDDO |
---|
1008 | ENDDO |
---|
1009 | ENDDO |
---|
1010 | ! |
---|
1011 | !-- Exchange particles between grid cells and processors |
---|
1012 | CALL lpm_move_particle |
---|
1013 | CALL lpm_exchange_horiz |
---|
1014 | |
---|
1015 | ENDIF |
---|
1016 | ! |
---|
1017 | !-- In case of random_start_position, delete particles identified by |
---|
1018 | !-- lpm_exchange_horiz and lpm_boundary_conds. Then sort particles into blocks, |
---|
1019 | !-- which is needed for a fast interpolation of the LES fields on the particle |
---|
1020 | !-- position. |
---|
1021 | CALL lpm_sort_in_subboxes |
---|
1022 | |
---|
1023 | ! |
---|
1024 | !-- Determine the current number of particles |
---|
1025 | DO ip = nxl, nxr |
---|
1026 | DO jp = nys, nyn |
---|
1027 | DO kp = nzb+1, nzt |
---|
1028 | number_of_particles = number_of_particles & |
---|
1029 | + prt_count(kp,jp,ip) |
---|
1030 | ENDDO |
---|
1031 | ENDDO |
---|
1032 | ENDDO |
---|
1033 | ! |
---|
1034 | !-- Calculate the number of particles of the total domain |
---|
1035 | #if defined( __parallel ) |
---|
1036 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
1037 | CALL MPI_ALLREDUCE( number_of_particles, total_number_of_particles, 1, & |
---|
1038 | MPI_INTEGER, MPI_SUM, comm2d, ierr ) |
---|
1039 | #else |
---|
1040 | total_number_of_particles = number_of_particles |
---|
1041 | #endif |
---|
1042 | |
---|
1043 | RETURN |
---|
1044 | |
---|
1045 | END SUBROUTINE lpm_create_particle |
---|
1046 | |
---|
1047 | SUBROUTINE lpm_init_aerosols(local_start) |
---|
1048 | |
---|
1049 | USE arrays_3d, & |
---|
1050 | ONLY: hyp, pt, q |
---|
1051 | |
---|
1052 | USE cloud_parameters, & |
---|
1053 | ONLY: l_d_rv, molecular_weight_of_solute, & |
---|
1054 | molecular_weight_of_water, rho_l, r_v, rho_s, vanthoff |
---|
1055 | |
---|
1056 | USE constants, & |
---|
1057 | ONLY: pi |
---|
1058 | |
---|
1059 | USE diagnostic_quantities_mod, & |
---|
1060 | ONLY: magnus |
---|
1061 | |
---|
1062 | |
---|
1063 | USE kinds |
---|
1064 | |
---|
1065 | USE particle_attributes, & |
---|
1066 | ONLY: aero_species, aero_type, aero_weight, log_sigma, na, rm |
---|
1067 | |
---|
1068 | IMPLICIT NONE |
---|
1069 | |
---|
1070 | REAL(wp) :: afactor !< curvature effects |
---|
1071 | REAL(wp) :: bfactor !< solute effects |
---|
1072 | REAL(wp) :: dlogr !< logarithmic width of radius bin |
---|
1073 | REAL(wp) :: e_a !< vapor pressure |
---|
1074 | REAL(wp) :: e_s !< saturation vapor pressure |
---|
1075 | REAL(wp) :: rmin = 0.005e-6_wp !< minimum aerosol radius |
---|
1076 | REAL(wp) :: rmax = 10.0e-6_wp !< maximum aerosol radius |
---|
1077 | REAL(wp) :: r_mid !< mean radius of bin |
---|
1078 | REAL(wp) :: r_l !< left radius of bin |
---|
1079 | REAL(wp) :: r_r !< right radius of bin |
---|
1080 | REAL(wp) :: sigma !< surface tension |
---|
1081 | REAL(wp) :: t_int !< temperature |
---|
1082 | |
---|
1083 | INTEGER(iwp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg), INTENT(IN) :: local_start !< |
---|
1084 | |
---|
1085 | INTEGER(iwp) :: n !< |
---|
1086 | INTEGER(iwp) :: ip !< |
---|
1087 | INTEGER(iwp) :: jp !< |
---|
1088 | INTEGER(iwp) :: kp !< |
---|
1089 | |
---|
1090 | ! |
---|
1091 | !-- Set constants for different aerosol species |
---|
1092 | IF ( TRIM(aero_species) .EQ. 'nacl' ) THEN |
---|
1093 | molecular_weight_of_solute = 0.05844_wp |
---|
1094 | rho_s = 2165.0_wp |
---|
1095 | vanthoff = 2.0_wp |
---|
1096 | ELSEIF ( TRIM(aero_species) .EQ. 'c3h4o4' ) THEN |
---|
1097 | molecular_weight_of_solute = 0.10406_wp |
---|
1098 | rho_s = 1600.0_wp |
---|
1099 | vanthoff = 1.37_wp |
---|
1100 | ELSEIF ( TRIM(aero_species) .EQ. 'nh4o3' ) THEN |
---|
1101 | molecular_weight_of_solute = 0.08004_wp |
---|
1102 | rho_s = 1720.0_wp |
---|
1103 | vanthoff = 2.31_wp |
---|
1104 | ELSE |
---|
1105 | WRITE( message_string, * ) 'unknown aerosol species ', & |
---|
1106 | 'aero_species = "', TRIM( aero_species ), '"' |
---|
1107 | CALL message( 'lpm_init', 'PA0470', 1, 2, 0, 6, 0 ) |
---|
1108 | ENDIF |
---|
1109 | ! |
---|
1110 | !-- The following typical aerosol spectra are taken from Jaenicke (1993): |
---|
1111 | !-- Tropospheric aerosols. Published in Aerosol-Cloud-Climate Interactions. |
---|
1112 | IF ( TRIM(aero_type) .EQ. 'polar' ) THEN |
---|
1113 | na = (/ 2.17e1, 1.86e-1, 3.04e-4 /) * 1.0E6 |
---|
1114 | rm = (/ 0.0689, 0.375, 4.29 /) * 1.0E-6 |
---|
1115 | log_sigma = (/ 0.245, 0.300, 0.291 /) |
---|
1116 | ELSEIF ( TRIM(aero_type) .EQ. 'background' ) THEN |
---|
1117 | na = (/ 1.29e2, 5.97e1, 6.35e1 /) * 1.0E6 |
---|
1118 | rm = (/ 0.0036, 0.127, 0.259 /) * 1.0E-6 |
---|
1119 | log_sigma = (/ 0.645, 0.253, 0.425 /) |
---|
1120 | ELSEIF ( TRIM(aero_type) .EQ. 'maritime' ) THEN |
---|
1121 | na = (/ 1.33e2, 6.66e1, 3.06e0 /) * 1.0E6 |
---|
1122 | rm = (/ 0.0039, 0.133, 0.29 /) * 1.0E-6 |
---|
1123 | log_sigma = (/ 0.657, 0.210, 0.396 /) |
---|
1124 | ELSEIF ( TRIM(aero_type) .EQ. 'continental' ) THEN |
---|
1125 | na = (/ 3.20e3, 2.90e3, 3.00e-1 /) * 1.0E6 |
---|
1126 | rm = (/ 0.01, 0.058, 0.9 /) * 1.0E-6 |
---|
1127 | log_sigma = (/ 0.161, 0.217, 0.380 /) |
---|
1128 | ELSEIF ( TRIM(aero_type) .EQ. 'desert' ) THEN |
---|
1129 | na = (/ 7.26e2, 1.14e3, 1.78e-1 /) * 1.0E6 |
---|
1130 | rm = (/ 0.001, 0.0188, 10.8 /) * 1.0E-6 |
---|
1131 | log_sigma = (/ 0.247, 0.770, 0.438 /) |
---|
1132 | ELSEIF ( TRIM(aero_type) .EQ. 'rural' ) THEN |
---|
1133 | na = (/ 6.65e3, 1.47e2, 1.99e3 /) * 1.0E6 |
---|
1134 | rm = (/ 0.00739, 0.0269, 0.0419 /) * 1.0E-6 |
---|
1135 | log_sigma = (/ 0.225, 0.557, 0.266 /) |
---|
1136 | ELSEIF ( TRIM(aero_type) .EQ. 'urban' ) THEN |
---|
1137 | na = (/ 9.93e4, 1.11e3, 3.64e4 /) * 1.0E6 |
---|
1138 | rm = (/ 0.00651, 0.00714, 0.0248 /) * 1.0E-6 |
---|
1139 | log_sigma = (/ 0.245, 0.666, 0.337 /) |
---|
1140 | ELSEIF ( TRIM(aero_type) .EQ. 'user' ) THEN |
---|
1141 | CONTINUE |
---|
1142 | ELSE |
---|
1143 | WRITE( message_string, * ) 'unknown aerosol type ', & |
---|
1144 | 'aero_type = "', TRIM( aero_type ), '"' |
---|
1145 | CALL message( 'lpm_init', 'PA0459', 1, 2, 0, 6, 0 ) |
---|
1146 | ENDIF |
---|
1147 | |
---|
1148 | DO ip = nxl, nxr |
---|
1149 | DO jp = nys, nyn |
---|
1150 | DO kp = nzb+1, nzt |
---|
1151 | |
---|
1152 | number_of_particles = prt_count(kp,jp,ip) |
---|
1153 | IF ( number_of_particles <= 0 ) CYCLE |
---|
1154 | particles => grid_particles(kp,jp,ip)%particles(1:number_of_particles) |
---|
1155 | |
---|
1156 | dlogr = ( LOG10(rmax) - LOG10(rmin) ) / ( number_of_particles - local_start(kp,jp,ip) + 1 ) |
---|
1157 | ! |
---|
1158 | !-- Initialize the aerosols with a predefined spectral distribution |
---|
1159 | !-- of the dry radius (logarithmically increasing bins) and a varying |
---|
1160 | !-- weighting factor |
---|
1161 | DO n = local_start(kp,jp,ip), number_of_particles !only new particles |
---|
1162 | |
---|
1163 | r_l = 10.0**( LOG10( rmin ) + (n-1) * dlogr ) |
---|
1164 | r_r = 10.0**( LOG10( rmin ) + n * dlogr ) |
---|
1165 | r_mid = SQRT( r_l * r_r ) |
---|
1166 | |
---|
1167 | particles(n)%aux1 = r_mid |
---|
1168 | particles(n)%weight_factor = & |
---|
1169 | ( na(1) / ( SQRT( 2.0 * pi ) * log_sigma(1) ) * & |
---|
1170 | EXP( - LOG10( r_mid / rm(1) )**2 / ( 2.0 * log_sigma(1)**2 ) ) + & |
---|
1171 | na(2) / ( SQRT( 2.0 * pi ) * log_sigma(2) ) * & |
---|
1172 | EXP( - LOG10( r_mid / rm(2) )**2 / ( 2.0 * log_sigma(2)**2 ) ) + & |
---|
1173 | na(3) / ( SQRT( 2.0 * pi ) * log_sigma(3) ) * & |
---|
1174 | EXP( - LOG10( r_mid / rm(3) )**2 / ( 2.0 * log_sigma(3)**2 ) ) & |
---|
1175 | ) * ( LOG10(r_r) - LOG10(r_l) ) * ( dx * dy * dzw(kp) ) |
---|
1176 | |
---|
1177 | ! |
---|
1178 | !-- Multiply weight_factor with the namelist parameter aero_weight |
---|
1179 | !-- to increase or decrease the number of simulated aerosols |
---|
1180 | particles(n)%weight_factor = particles(n)%weight_factor * aero_weight |
---|
1181 | |
---|
1182 | IF ( particles(n)%weight_factor - FLOOR(particles(n)%weight_factor,KIND=wp) & |
---|
1183 | .GT. random_function( iran_part ) ) THEN |
---|
1184 | particles(n)%weight_factor = FLOOR(particles(n)%weight_factor,KIND=wp) + 1.0 |
---|
1185 | ELSE |
---|
1186 | particles(n)%weight_factor = FLOOR(particles(n)%weight_factor,KIND=wp) |
---|
1187 | ENDIF |
---|
1188 | ! |
---|
1189 | !-- Unnecessary particles will be deleted |
---|
1190 | IF ( particles(n)%weight_factor .LE. 0.0 ) particles(n)%particle_mask = .FALSE. |
---|
1191 | |
---|
1192 | ENDDO |
---|
1193 | ! |
---|
1194 | !-- Set particle radius to equilibrium radius based on the environmental |
---|
1195 | !-- supersaturation (Khvorostyanov and Curry, 2007, JGR). This avoids |
---|
1196 | !-- the sometimes lengthy growth toward their equilibrium radius within |
---|
1197 | !-- the simulation. |
---|
1198 | t_int = pt(kp,jp,ip) * ( hyp(kp) / 100000.0_wp )**0.286_wp |
---|
1199 | |
---|
1200 | e_s = magnus( t_int ) |
---|
1201 | e_a = q(kp,jp,ip) * hyp(kp) / ( q(kp,jp,ip) + 0.622_wp ) |
---|
1202 | |
---|
1203 | sigma = 0.0761_wp - 0.000155_wp * ( t_int - 273.15_wp ) |
---|
1204 | afactor = 2.0_wp * sigma / ( rho_l * r_v * t_int ) |
---|
1205 | |
---|
1206 | bfactor = vanthoff * molecular_weight_of_water * & |
---|
1207 | rho_s / ( molecular_weight_of_solute * rho_l ) |
---|
1208 | ! |
---|
1209 | !-- The formula is only valid for subsaturated environments. For |
---|
1210 | !-- supersaturations higher than -5 %, the supersaturation is set to -5%. |
---|
1211 | IF ( e_a / e_s >= 0.95_wp ) e_a = 0.95_wp * e_s |
---|
1212 | |
---|
1213 | DO n = local_start(kp,jp,ip), number_of_particles !only new particles |
---|
1214 | ! |
---|
1215 | !-- For details on this equation, see Eq. (14) of Khvorostyanov and |
---|
1216 | !-- Curry (2007, JGR) |
---|
1217 | particles(n)%radius = bfactor**0.3333333_wp * & |
---|
1218 | particles(n)%aux1 / ( 1.0_wp - e_a / e_s )**0.3333333_wp / & |
---|
1219 | ( 1.0_wp + ( afactor / ( 3.0_wp * bfactor**0.3333333_wp * & |
---|
1220 | particles(n)%aux1 ) ) / & |
---|
1221 | ( 1.0_wp - e_a / e_s )**0.6666666_wp & |
---|
1222 | ) |
---|
1223 | |
---|
1224 | ENDDO |
---|
1225 | |
---|
1226 | ENDDO |
---|
1227 | ENDDO |
---|
1228 | ENDDO |
---|
1229 | |
---|
1230 | END SUBROUTINE lpm_init_aerosols |
---|
1231 | |
---|
1232 | END MODULE lpm_init_mod |
---|