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