[849] | 1 | SUBROUTINE lpm |
---|
[1] | 2 | |
---|
[1036] | 3 | !--------------------------------------------------------------------------------! |
---|
| 4 | ! This file is part of PALM. |
---|
| 5 | ! |
---|
| 6 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
| 7 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
| 8 | ! either version 3 of the License, or (at your option) any later 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-2012 Leibniz University Hannover |
---|
| 18 | !--------------------------------------------------------------------------------! |
---|
| 19 | ! |
---|
[230] | 20 | ! Current revisions: |
---|
[759] | 21 | ! ------------------ |
---|
[852] | 22 | ! |
---|
[829] | 23 | ! |
---|
| 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: lpm.f90 1036 2012-10-22 13:43:42Z raasch $ |
---|
| 27 | ! |
---|
[852] | 28 | ! 851 2012-03-15 14:32:58Z raasch |
---|
| 29 | ! Bugfix: resetting of particle_mask and tail mask moved from routine |
---|
| 30 | ! lpm_exchange_horiz to here (end of sub-timestep loop) |
---|
| 31 | ! |
---|
[850] | 32 | ! 849 2012-03-15 10:35:09Z raasch |
---|
| 33 | ! original routine advec_particles split into several subroutines and renamed |
---|
| 34 | ! lpm |
---|
| 35 | ! |
---|
[832] | 36 | ! 831 2012-02-22 00:29:39Z raasch |
---|
| 37 | ! thermal_conductivity_l and diff_coeff_l now depend on temperature and |
---|
| 38 | ! pressure |
---|
| 39 | ! |
---|
[829] | 40 | ! 828 2012-02-21 12:00:36Z raasch |
---|
[828] | 41 | ! fast hall/wang kernels with fixed radius/dissipation classes added, |
---|
| 42 | ! particle feature color renamed class, routine colker renamed |
---|
| 43 | ! recalculate_kernel, |
---|
| 44 | ! lower limit for droplet radius changed from 1E-7 to 1E-8 |
---|
[826] | 45 | ! |
---|
[828] | 46 | ! Bugfix: transformation factor for dissipation changed from 1E5 to 1E4 |
---|
| 47 | ! |
---|
[826] | 48 | ! 825 2012-02-19 03:03:44Z raasch |
---|
[825] | 49 | ! droplet growth by condensation may include curvature and solution effects, |
---|
| 50 | ! initialisation of temporary particle array for resorting removed, |
---|
| 51 | ! particle attributes speed_x|y|z_sgs renamed rvar1|2|3, |
---|
| 52 | ! module wang_kernel_mod renamed lpm_collision_kernels_mod, |
---|
| 53 | ! wang_collision_kernel renamed wang_kernel |
---|
[482] | 54 | ! |
---|
[800] | 55 | ! 799 2011-12-21 17:48:03Z franke |
---|
| 56 | ! Implementation of Wang collision kernel and corresponding new parameter |
---|
| 57 | ! wang_collision_kernel |
---|
| 58 | ! |
---|
[799] | 59 | ! 792 2011-12-01 raasch |
---|
| 60 | ! particle arrays (particles, particles_temp) implemented as pointers in |
---|
| 61 | ! order to speed up sorting (see routine sort_particles) |
---|
| 62 | ! |
---|
[760] | 63 | ! 759 2011-09-15 13:58:31Z raasch |
---|
| 64 | ! Splitting of parallel I/O (routine write_particles) |
---|
| 65 | ! |
---|
[1] | 66 | ! Revision 1.1 1999/11/25 16:16:06 raasch |
---|
| 67 | ! Initial revision |
---|
| 68 | ! |
---|
| 69 | ! |
---|
| 70 | ! Description: |
---|
| 71 | ! ------------ |
---|
| 72 | ! Particle advection |
---|
| 73 | !------------------------------------------------------------------------------! |
---|
| 74 | |
---|
| 75 | USE arrays_3d |
---|
| 76 | USE control_parameters |
---|
| 77 | USE cpulog |
---|
| 78 | USE interfaces |
---|
| 79 | USE particle_attributes |
---|
| 80 | USE pegrid |
---|
| 81 | USE statistics |
---|
| 82 | |
---|
| 83 | IMPLICIT NONE |
---|
| 84 | |
---|
[849] | 85 | INTEGER :: m |
---|
[1] | 86 | |
---|
[60] | 87 | |
---|
[849] | 88 | CALL cpu_log( log_point(25), 'lpm', 'start' ) |
---|
[824] | 89 | |
---|
[849] | 90 | ! |
---|
| 91 | !-- Write particle data at current time on file. |
---|
| 92 | !-- This has to be done here, before particles are further processed, |
---|
| 93 | !-- because they may be deleted within this timestep (in case that |
---|
| 94 | !-- dt_write_particle_data = dt_prel = particle_maximum_age). |
---|
| 95 | time_write_particle_data = time_write_particle_data + dt_3d |
---|
| 96 | IF ( time_write_particle_data >= dt_write_particle_data ) THEN |
---|
[1] | 97 | |
---|
[849] | 98 | CALL lpm_data_output_particles |
---|
[824] | 99 | ! |
---|
[849] | 100 | !-- The MOD function allows for changes in the output interval with restart |
---|
| 101 | !-- runs. |
---|
| 102 | time_write_particle_data = MOD( time_write_particle_data, & |
---|
| 103 | MAX( dt_write_particle_data, dt_3d ) ) |
---|
| 104 | ENDIF |
---|
[1] | 105 | |
---|
[60] | 106 | |
---|
[849] | 107 | ! |
---|
| 108 | !-- Initialize arrays for marking those particles/tails to be deleted after the |
---|
| 109 | !-- (sub-) timestep |
---|
| 110 | particle_mask = .TRUE. |
---|
| 111 | deleted_particles = 0 |
---|
[60] | 112 | |
---|
[849] | 113 | IF ( use_particle_tails ) THEN |
---|
| 114 | tail_mask = .TRUE. |
---|
| 115 | ENDIF |
---|
| 116 | deleted_tails = 0 |
---|
[1] | 117 | |
---|
| 118 | |
---|
| 119 | ! |
---|
[849] | 120 | !-- Initialize variables used for accumulating the number of particles |
---|
| 121 | !-- exchanged between the subdomains during all sub-timesteps (if sgs |
---|
| 122 | !-- velocities are included). These data are output further below on the |
---|
| 123 | !-- particle statistics file. |
---|
| 124 | trlp_count_sum = 0 |
---|
| 125 | trlp_count_recv_sum = 0 |
---|
| 126 | trrp_count_sum = 0 |
---|
| 127 | trrp_count_recv_sum = 0 |
---|
| 128 | trsp_count_sum = 0 |
---|
| 129 | trsp_count_recv_sum = 0 |
---|
| 130 | trnp_count_sum = 0 |
---|
| 131 | trnp_count_recv_sum = 0 |
---|
[1] | 132 | |
---|
| 133 | |
---|
| 134 | ! |
---|
| 135 | !-- Calculate exponential term used in case of particle inertia for each |
---|
| 136 | !-- of the particle groups |
---|
| 137 | DO m = 1, number_of_particle_groups |
---|
| 138 | IF ( particle_groups(m)%density_ratio /= 0.0 ) THEN |
---|
| 139 | particle_groups(m)%exp_arg = & |
---|
| 140 | 4.5 * particle_groups(m)%density_ratio * & |
---|
| 141 | molecular_viscosity / ( particle_groups(m)%radius )**2 |
---|
| 142 | particle_groups(m)%exp_term = EXP( -particle_groups(m)%exp_arg * & |
---|
| 143 | dt_3d ) |
---|
| 144 | ENDIF |
---|
| 145 | ENDDO |
---|
| 146 | |
---|
[849] | 147 | |
---|
[1] | 148 | ! |
---|
| 149 | !-- Particle (droplet) growth by condensation/evaporation and collision |
---|
| 150 | IF ( cloud_droplets ) THEN |
---|
| 151 | |
---|
| 152 | ! |
---|
| 153 | !-- Reset summation arrays |
---|
| 154 | ql_c = 0.0; ql_v = 0.0; ql_vp = 0.0 |
---|
| 155 | |
---|
| 156 | ! |
---|
[849] | 157 | !-- Droplet growth by condensation / evaporation |
---|
| 158 | CALL lpm_droplet_condensation |
---|
[1] | 159 | |
---|
| 160 | ! |
---|
| 161 | !-- Particle growth by collision |
---|
[849] | 162 | IF ( collision_kernel /= 'none' ) CALL lpm_droplet_collision |
---|
[825] | 163 | |
---|
[849] | 164 | ENDIF |
---|
[420] | 165 | |
---|
[1] | 166 | |
---|
| 167 | ! |
---|
[849] | 168 | !-- If particle advection includes SGS velocity components, calculate the |
---|
| 169 | !-- required SGS quantities (i.e. gradients of the TKE, as well as horizontally |
---|
| 170 | !-- averaged profiles of the SGS TKE and the resolved-scale velocity variances) |
---|
| 171 | IF ( use_sgs_for_particles ) CALL lpm_init_sgs_tke |
---|
[799] | 172 | |
---|
| 173 | |
---|
| 174 | ! |
---|
[1] | 175 | !-- Initialize the variable storing the total time that a particle has advanced |
---|
| 176 | !-- within the timestep procedure |
---|
| 177 | particles(1:number_of_particles)%dt_sum = 0.0 |
---|
| 178 | |
---|
[849] | 179 | |
---|
[1] | 180 | ! |
---|
[849] | 181 | !-- Timestep loop for particle advection. |
---|
[1] | 182 | !-- This loop has to be repeated until the advection time of every particle |
---|
[849] | 183 | !-- (within the total domain!) has reached the LES timestep (dt_3d). |
---|
| 184 | !-- In case of including the SGS velocities, the particle timestep may be |
---|
| 185 | !-- smaller than the LES timestep (because of the Lagrangian timescale restric- |
---|
| 186 | !-- tion) and particles may require to undergo several particle timesteps, |
---|
| 187 | !-- before the LES timestep is reached. Because the number of these particle |
---|
| 188 | !-- timesteps to be carried out is unknown at first, these steps are carried |
---|
| 189 | !-- out in the following infinite loop with exit condition. |
---|
[1] | 190 | DO |
---|
| 191 | |
---|
[849] | 192 | CALL cpu_log( log_point_s(44), 'lpm_advec', 'start' ) |
---|
[1] | 193 | |
---|
| 194 | ! |
---|
| 195 | !-- Initialize the switch used for the loop exit condition checked at the |
---|
| 196 | !-- end of this loop. |
---|
| 197 | !-- If at least one particle has failed to reach the LES timestep, this |
---|
| 198 | !-- switch will be set false. |
---|
| 199 | dt_3d_reached_l = .TRUE. |
---|
| 200 | |
---|
| 201 | ! |
---|
[849] | 202 | !-- Particle advection |
---|
| 203 | CALL lpm_advec |
---|
[1] | 204 | |
---|
| 205 | ! |
---|
[57] | 206 | !-- Particle reflection from walls |
---|
[849] | 207 | CALL lpm_boundary_conds( 'walls' ) |
---|
[57] | 208 | |
---|
| 209 | ! |
---|
[212] | 210 | !-- User-defined actions after the calculation of the new particle position |
---|
[849] | 211 | CALL user_lpm_advec |
---|
[57] | 212 | |
---|
| 213 | ! |
---|
[1] | 214 | !-- Find out, if all particles on every PE have completed the LES timestep |
---|
| 215 | !-- and set the switch corespondingly |
---|
| 216 | #if defined( __parallel ) |
---|
[622] | 217 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
[1] | 218 | CALL MPI_ALLREDUCE( dt_3d_reached_l, dt_3d_reached, 1, MPI_LOGICAL, & |
---|
| 219 | MPI_LAND, comm2d, ierr ) |
---|
| 220 | #else |
---|
| 221 | dt_3d_reached = dt_3d_reached_l |
---|
[799] | 222 | #endif |
---|
[1] | 223 | |
---|
[849] | 224 | CALL cpu_log( log_point_s(44), 'lpm_advec', 'stop' ) |
---|
[1] | 225 | |
---|
| 226 | ! |
---|
| 227 | !-- Increment time since last release |
---|
| 228 | IF ( dt_3d_reached ) time_prel = time_prel + dt_3d |
---|
| 229 | |
---|
| 230 | ! |
---|
| 231 | !-- If necessary, release new set of particles |
---|
| 232 | IF ( time_prel >= dt_prel .AND. end_time_prel > simulated_time .AND. & |
---|
| 233 | dt_3d_reached ) THEN |
---|
| 234 | |
---|
[849] | 235 | CALL lpm_release_set |
---|
[1] | 236 | |
---|
| 237 | ! |
---|
| 238 | !-- The MOD function allows for changes in the output interval with |
---|
| 239 | !-- restart runs. |
---|
| 240 | time_prel = MOD( time_prel, MAX( dt_prel, dt_3d ) ) |
---|
| 241 | |
---|
| 242 | ENDIF |
---|
| 243 | |
---|
| 244 | ! |
---|
[849] | 245 | !-- Horizontal boundary conditions including exchange between subdmains |
---|
| 246 | CALL lpm_exchange_horiz |
---|
[1] | 247 | |
---|
| 248 | ! |
---|
| 249 | !-- Apply boundary conditions to those particles that have crossed the top or |
---|
| 250 | !-- bottom boundary and delete those particles, which are older than allowed |
---|
[849] | 251 | CALL lpm_boundary_conds( 'bottom/top' ) |
---|
[1] | 252 | |
---|
[57] | 253 | ! |
---|
[1] | 254 | !-- Pack particles (eliminate those marked for deletion), |
---|
| 255 | !-- determine new number of particles |
---|
| 256 | IF ( number_of_particles > 0 .AND. deleted_particles > 0 ) THEN |
---|
[849] | 257 | CALL lpm_pack_arrays |
---|
[1] | 258 | ENDIF |
---|
| 259 | |
---|
[851] | 260 | ! |
---|
| 261 | !-- Initialize variables for the next (sub-) timestep, i.e. for marking those |
---|
| 262 | !-- particles to be deleted after the timestep |
---|
| 263 | particle_mask = .TRUE. |
---|
| 264 | deleted_particles = 0 |
---|
| 265 | |
---|
| 266 | IF ( use_particle_tails ) THEN |
---|
| 267 | tail_mask = .TRUE. |
---|
| 268 | ENDIF |
---|
| 269 | deleted_tails = 0 |
---|
| 270 | |
---|
| 271 | |
---|
[1] | 272 | IF ( dt_3d_reached ) EXIT |
---|
| 273 | |
---|
| 274 | ENDDO ! timestep loop |
---|
| 275 | |
---|
[849] | 276 | |
---|
[1] | 277 | ! |
---|
[116] | 278 | !-- Sort particles in the sequence the gridboxes are stored in the memory |
---|
| 279 | time_sort_particles = time_sort_particles + dt_3d |
---|
| 280 | IF ( time_sort_particles >= dt_sort_particles ) THEN |
---|
[849] | 281 | CALL lpm_sort_arrays |
---|
[116] | 282 | time_sort_particles = MOD( time_sort_particles, & |
---|
| 283 | MAX( dt_sort_particles, dt_3d ) ) |
---|
| 284 | ENDIF |
---|
| 285 | |
---|
[1] | 286 | |
---|
| 287 | ! |
---|
[849] | 288 | !-- Calculate the new liquid water content for each grid box |
---|
| 289 | IF ( cloud_droplets ) CALL lpm_calc_liquid_water_content |
---|
[1] | 290 | |
---|
| 291 | |
---|
| 292 | ! |
---|
[828] | 293 | !-- Set particle attributes. |
---|
| 294 | !-- Feature is not available if collision is activated, because the respective |
---|
| 295 | !-- particle attribute (class) is then used for storing the particle radius |
---|
| 296 | !-- class. |
---|
[849] | 297 | IF ( collision_kernel == 'none' ) CALL lpm_set_attributes |
---|
[264] | 298 | |
---|
[849] | 299 | |
---|
[264] | 300 | ! |
---|
[1] | 301 | !-- Set particle attributes defined by the user |
---|
[849] | 302 | CALL user_lpm_set_attributes |
---|
[1] | 303 | |
---|
| 304 | |
---|
| 305 | ! |
---|
[849] | 306 | !-- If required, add the current particle positions to the particle tails |
---|
| 307 | IF ( use_particle_tails ) CALL lpm_extend_tails |
---|
[1] | 308 | |
---|
| 309 | |
---|
| 310 | ! |
---|
[849] | 311 | !-- Write particle statistics (in particular the number of particles |
---|
| 312 | !-- exchanged between the subdomains) on file |
---|
| 313 | IF ( write_particle_statistics ) CALL lpm_write_exchange_statistics |
---|
[1] | 314 | |
---|
[849] | 315 | CALL cpu_log( log_point(25), 'lpm', 'stop' ) |
---|
[1] | 316 | |
---|
| 317 | |
---|
[849] | 318 | END SUBROUTINE lpm |
---|