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