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