[1682] | 1 | !> @file lpm_advec.f90 |
---|
[2000] | 2 | !------------------------------------------------------------------------------! |
---|
[2696] | 3 | ! This file is part of the PALM model system. |
---|
[1036] | 4 | ! |
---|
[2000] | 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. |
---|
[1036] | 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 | ! |
---|
[2718] | 17 | ! Copyright 1997-2018 Leibniz Universitaet Hannover |
---|
[2000] | 18 | !------------------------------------------------------------------------------! |
---|
[1036] | 19 | ! |
---|
[849] | 20 | ! Current revisions: |
---|
| 21 | ! ------------------ |
---|
[2701] | 22 | ! |
---|
| 23 | ! |
---|
| 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: lpm_advec.f90 3189 2018-08-06 13:18:55Z raasch $ |
---|
[3189] | 27 | ! Bugfix: Index of the array dzw has to be k+1 during the interpolation. |
---|
| 28 | ! Otherwise k=0 causes an abortion because dzw is allocated from 1 to nzt+1 |
---|
| 29 | ! |
---|
| 30 | ! 3065 2018-06-12 07:03:02Z Giersch |
---|
[3065] | 31 | ! dz values were replaced by dzw or dz(1) to allow for right vertical stretching |
---|
| 32 | ! |
---|
| 33 | ! 2969 2018-04-13 11:55:09Z thiele |
---|
[2969] | 34 | ! Bugfix in Interpolation indices. |
---|
| 35 | ! |
---|
| 36 | ! 2886 2018-03-14 11:51:53Z thiele |
---|
[2886] | 37 | ! Bugfix in passive particle SGS Model: |
---|
| 38 | ! Sometimes the added SGS velocities would lead to a violation of the CFL |
---|
| 39 | ! criterion for single particles. For this a check was added after the |
---|
| 40 | ! calculation of SGS velocities. |
---|
| 41 | ! |
---|
| 42 | ! 2718 2018-01-02 08:49:38Z maronga |
---|
[2716] | 43 | ! Corrected "Former revisions" section |
---|
| 44 | ! |
---|
| 45 | ! 2701 2017-12-15 15:40:50Z suehring |
---|
| 46 | ! Changes from last commit documented |
---|
| 47 | ! |
---|
| 48 | ! 2698 2017-12-14 18:46:24Z suehring |
---|
[2698] | 49 | ! Particle interpolations at walls in case of SGS velocities revised and not |
---|
| 50 | ! required parts are removed. (responsible Philipp Thiele) |
---|
[2716] | 51 | ! Bugfix in get_topography_top_index |
---|
[2698] | 52 | ! |
---|
[2716] | 53 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
| 54 | ! Change in file header (GPL part) |
---|
| 55 | ! |
---|
| 56 | ! 2630 2017-11-20 12:58:20Z schwenkel |
---|
[2629] | 57 | ! Removed indices ilog and jlog which are no longer needed since particle box |
---|
| 58 | ! locations are identical to scalar boxes and topography. |
---|
| 59 | ! |
---|
[2630] | 60 | ! 2628 2017-11-20 12:40:38Z raasch |
---|
[2610] | 61 | ! bugfix in logarithmic interpolation of v-component (usws was used by mistake) |
---|
| 62 | ! |
---|
| 63 | ! 2606 2017-11-10 10:36:31Z schwenkel |
---|
[2606] | 64 | ! Changed particle box locations: center of particle box now coincides |
---|
| 65 | ! with scalar grid point of same index. |
---|
| 66 | ! Renamed module and subroutines: lpm_pack_arrays_mod -> lpm_pack_and_sort_mod |
---|
| 67 | ! lpm_pack_all_arrays -> lpm_sort_in_subboxes, lpm_pack_arrays -> lpm_pack |
---|
| 68 | ! lpm_sort -> lpm_sort_timeloop_done |
---|
| 69 | ! |
---|
| 70 | ! 2417 2017-09-06 15:22:27Z suehring |
---|
[2417] | 71 | ! Particle loops adapted for sub-box structure, i.e. for each sub-box the |
---|
| 72 | ! particle loop runs from start_index up to end_index instead from 1 to |
---|
| 73 | ! number_of_particles. This way, it is possible to skip unnecessary |
---|
| 74 | ! computations for particles that already completed the LES timestep. |
---|
| 75 | ! |
---|
| 76 | ! 2318 2017-07-20 17:27:44Z suehring |
---|
[2318] | 77 | ! Get topography top index via Function call |
---|
| 78 | ! |
---|
| 79 | ! 2317 2017-07-20 17:27:19Z suehring |
---|
[1930] | 80 | ! |
---|
[2233] | 81 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
| 82 | ! Adjustments to new topography and surface concept |
---|
| 83 | ! |
---|
[2101] | 84 | ! 2100 2017-01-05 16:40:16Z suehring |
---|
| 85 | ! Prevent extremely large SGS-velocities in regions where TKE is zero, e.g. |
---|
| 86 | ! at the begin of simulations and/or in non-turbulent regions. |
---|
| 87 | ! |
---|
[2001] | 88 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
| 89 | ! Forced header and separation lines into 80 columns |
---|
| 90 | ! |
---|
[1937] | 91 | ! 1936 2016-06-13 13:37:44Z suehring |
---|
| 92 | ! Formatting adjustments |
---|
| 93 | ! |
---|
[1930] | 94 | ! 1929 2016-06-09 16:25:25Z suehring |
---|
[1929] | 95 | ! Put stochastic equation in an extra subroutine. |
---|
| 96 | ! Set flag for stochastic equation to communicate whether a particle is near |
---|
| 97 | ! topography. This case, memory and drift term are disabled in the Weil equation. |
---|
[1889] | 98 | ! |
---|
[1929] | 99 | ! Enable vertical logarithmic interpolation also above topography. This case, |
---|
| 100 | ! set a lower limit for the friction velocity, as it can become very small |
---|
[1930] | 101 | ! in narrow street canyons, leading to too large particle speeds. |
---|
[1823] | 102 | ! |
---|
[1889] | 103 | ! 1888 2016-04-21 12:20:49Z suehring |
---|
| 104 | ! Bugfix concerning logarithmic interpolation of particle speed |
---|
| 105 | ! |
---|
[1823] | 106 | ! 1822 2016-04-07 07:49:42Z hoffmann |
---|
[1822] | 107 | ! Random velocity fluctuations for particles added. Terminal fall velocity |
---|
| 108 | ! for droplets is calculated from a parameterization (which is better than |
---|
| 109 | ! the previous, physically correct calculation, which demands a very short |
---|
| 110 | ! time step that is not used in the model). |
---|
| 111 | ! |
---|
| 112 | ! Unused variables deleted. |
---|
[1321] | 113 | ! |
---|
[1692] | 114 | ! 1691 2015-10-26 16:17:44Z maronga |
---|
| 115 | ! Renamed prandtl_layer to constant_flux_layer. |
---|
| 116 | ! |
---|
[1686] | 117 | ! 1685 2015-10-08 07:32:13Z raasch |
---|
| 118 | ! TKE check for negative values (so far, only zero value was checked) |
---|
| 119 | ! offset_ocean_nzt_m1 removed |
---|
| 120 | ! |
---|
[1683] | 121 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 122 | ! Code annotations made doxygen readable |
---|
| 123 | ! |
---|
[1584] | 124 | ! 1583 2015-04-15 12:16:27Z suehring |
---|
| 125 | ! Bugfix: particle advection within Prandtl-layer in case of Galilei |
---|
| 126 | ! transformation. |
---|
| 127 | ! |
---|
[1370] | 128 | ! 1369 2014-04-24 05:57:38Z raasch |
---|
| 129 | ! usage of module interfaces removed |
---|
| 130 | ! |
---|
[1360] | 131 | ! 1359 2014-04-11 17:15:14Z hoffmann |
---|
| 132 | ! New particle structure integrated. |
---|
| 133 | ! Kind definition added to all floating point numbers. |
---|
| 134 | ! |
---|
[1323] | 135 | ! 1322 2014-03-20 16:38:49Z raasch |
---|
| 136 | ! REAL constants defined as wp_kind |
---|
| 137 | ! |
---|
[1321] | 138 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 139 | ! ONLY-attribute added to USE-statements, |
---|
| 140 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 141 | ! kinds are defined in new module kinds, |
---|
| 142 | ! revision history before 2012 removed, |
---|
| 143 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 144 | ! all variable declaration statements |
---|
[849] | 145 | ! |
---|
[1315] | 146 | ! 1314 2014-03-14 18:25:17Z suehring |
---|
| 147 | ! Vertical logarithmic interpolation of horizontal particle speed for particles |
---|
| 148 | ! between roughness height and first vertical grid level. |
---|
| 149 | ! |
---|
[1037] | 150 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 151 | ! code put under GPL (PALM 3.9) |
---|
| 152 | ! |
---|
[850] | 153 | ! 849 2012-03-15 10:35:09Z raasch |
---|
| 154 | ! initial revision (former part of advec_particles) |
---|
[849] | 155 | ! |
---|
[850] | 156 | ! |
---|
[849] | 157 | ! Description: |
---|
| 158 | ! ------------ |
---|
[1682] | 159 | !> Calculation of new particle positions due to advection using a simple Euler |
---|
| 160 | !> scheme. Particles may feel inertia effects. SGS transport can be included |
---|
| 161 | !> using the stochastic model of Weil et al. (2004, JAS, 61, 2877-2887). |
---|
[849] | 162 | !------------------------------------------------------------------------------! |
---|
[1682] | 163 | SUBROUTINE lpm_advec (ip,jp,kp) |
---|
| 164 | |
---|
[849] | 165 | |
---|
[1320] | 166 | USE arrays_3d, & |
---|
[3065] | 167 | ONLY: de_dx, de_dy, de_dz, diss, dzw, e, km, u, v, w, zu, zw |
---|
[849] | 168 | |
---|
[1359] | 169 | USE cpulog |
---|
| 170 | |
---|
| 171 | USE pegrid |
---|
| 172 | |
---|
[1320] | 173 | USE control_parameters, & |
---|
[1691] | 174 | ONLY: atmos_ocean_sign, cloud_droplets, constant_flux_layer, dt_3d, & |
---|
[1822] | 175 | dt_3d_reached_l, dz, g, kappa, topography, u_gtrans, v_gtrans |
---|
[849] | 176 | |
---|
[1320] | 177 | USE grid_variables, & |
---|
| 178 | ONLY: ddx, dx, ddy, dy |
---|
| 179 | |
---|
| 180 | USE indices, & |
---|
[2698] | 181 | ONLY: nzb, nzt, wall_flags_0 |
---|
[1320] | 182 | |
---|
| 183 | USE kinds |
---|
| 184 | |
---|
| 185 | USE particle_attributes, & |
---|
[1822] | 186 | ONLY: block_offset, c_0, dt_min_part, grid_particles, & |
---|
[1359] | 187 | iran_part, log_z_z0, number_of_particles, number_of_sublayers, & |
---|
[1929] | 188 | particles, particle_groups, offset_ocean_nzt, sgs_wf_part, & |
---|
| 189 | use_sgs_for_particles, vertical_particle_advection, z0_av_global |
---|
[1320] | 190 | |
---|
| 191 | USE statistics, & |
---|
| 192 | ONLY: hom |
---|
[849] | 193 | |
---|
[2232] | 194 | USE surface_mod, & |
---|
[2698] | 195 | ONLY: get_topography_top_index_ji, surf_def_h, surf_lsm_h, surf_usm_h |
---|
[2232] | 196 | |
---|
[1320] | 197 | IMPLICIT NONE |
---|
[849] | 198 | |
---|
[2698] | 199 | LOGICAL :: subbox_at_wall !< flag to see if the current subgridbox is adjacent to a wall |
---|
| 200 | |
---|
[1929] | 201 | INTEGER(iwp) :: agp !< loop variable |
---|
| 202 | INTEGER(iwp) :: gp_outside_of_building(1:8) !< number of grid points used for particle interpolation in case of topography |
---|
| 203 | INTEGER(iwp) :: i !< index variable along x |
---|
| 204 | INTEGER(iwp) :: ip !< index variable along x |
---|
| 205 | INTEGER(iwp) :: j !< index variable along y |
---|
| 206 | INTEGER(iwp) :: jp !< index variable along y |
---|
| 207 | INTEGER(iwp) :: k !< index variable along z |
---|
[2232] | 208 | INTEGER(iwp) :: k_wall !< vertical index of topography top |
---|
[1929] | 209 | INTEGER(iwp) :: kp !< index variable along z |
---|
| 210 | INTEGER(iwp) :: kw !< index variable along z |
---|
| 211 | INTEGER(iwp) :: n !< loop variable over all particles in a grid box |
---|
| 212 | INTEGER(iwp) :: nb !< block number particles are sorted in |
---|
| 213 | INTEGER(iwp) :: num_gp !< number of adjacent grid points inside topography |
---|
[2232] | 214 | INTEGER(iwp) :: surf_start !< Index on surface data-type for current grid box |
---|
[849] | 215 | |
---|
[1929] | 216 | INTEGER(iwp), DIMENSION(0:7) :: start_index !< start particle index for current block |
---|
| 217 | INTEGER(iwp), DIMENSION(0:7) :: end_index !< start particle index for current block |
---|
[1359] | 218 | |
---|
[1929] | 219 | REAL(wp) :: aa !< dummy argument for horizontal particle interpolation |
---|
| 220 | REAL(wp) :: bb !< dummy argument for horizontal particle interpolation |
---|
| 221 | REAL(wp) :: cc !< dummy argument for horizontal particle interpolation |
---|
| 222 | REAL(wp) :: d_sum !< dummy argument for horizontal particle interpolation in case of topography |
---|
| 223 | REAL(wp) :: d_z_p_z0 !< inverse of interpolation length for logarithmic interpolation |
---|
| 224 | REAL(wp) :: dd !< dummy argument for horizontal particle interpolation |
---|
| 225 | REAL(wp) :: de_dx_int_l !< x/y-interpolated TKE gradient (x) at particle position at lower vertical level |
---|
| 226 | REAL(wp) :: de_dx_int_u !< x/y-interpolated TKE gradient (x) at particle position at upper vertical level |
---|
| 227 | REAL(wp) :: de_dy_int_l !< x/y-interpolated TKE gradient (y) at particle position at lower vertical level |
---|
| 228 | REAL(wp) :: de_dy_int_u !< x/y-interpolated TKE gradient (y) at particle position at upper vertical level |
---|
| 229 | REAL(wp) :: de_dt !< temporal derivative of TKE experienced by the particle |
---|
| 230 | REAL(wp) :: de_dt_min !< lower level for temporal TKE derivative |
---|
| 231 | REAL(wp) :: de_dz_int_l !< x/y-interpolated TKE gradient (z) at particle position at lower vertical level |
---|
| 232 | REAL(wp) :: de_dz_int_u !< x/y-interpolated TKE gradient (z) at particle position at upper vertical level |
---|
[1822] | 233 | REAL(wp) :: diameter !< diamter of droplet |
---|
[1929] | 234 | REAL(wp) :: diss_int_l !< x/y-interpolated dissipation at particle position at lower vertical level |
---|
| 235 | REAL(wp) :: diss_int_u !< x/y-interpolated dissipation at particle position at upper vertical level |
---|
| 236 | REAL(wp) :: dt_particle_m !< previous particle time step |
---|
[2886] | 237 | REAL(wp) :: dz_temp !< |
---|
[1929] | 238 | REAL(wp) :: e_int_l !< x/y-interpolated TKE at particle position at lower vertical level |
---|
| 239 | REAL(wp) :: e_int_u !< x/y-interpolated TKE at particle position at upper vertical level |
---|
| 240 | REAL(wp) :: e_mean_int !< horizontal mean TKE at particle height |
---|
[1682] | 241 | REAL(wp) :: exp_arg !< |
---|
| 242 | REAL(wp) :: exp_term !< |
---|
[1929] | 243 | REAL(wp) :: gg !< dummy argument for horizontal particle interpolation |
---|
| 244 | REAL(wp) :: height_p !< dummy argument for logarithmic interpolation |
---|
| 245 | REAL(wp) :: location(1:30,1:3) !< wall locations |
---|
| 246 | REAL(wp) :: log_z_z0_int !< logarithmus used for surface_layer interpolation |
---|
[1682] | 247 | REAL(wp) :: random_gauss !< |
---|
[1822] | 248 | REAL(wp) :: RL !< Lagrangian autocorrelation coefficient |
---|
| 249 | REAL(wp) :: rg1 !< Gaussian distributed random number |
---|
| 250 | REAL(wp) :: rg2 !< Gaussian distributed random number |
---|
| 251 | REAL(wp) :: rg3 !< Gaussian distributed random number |
---|
| 252 | REAL(wp) :: sigma !< velocity standard deviation |
---|
[1929] | 253 | REAL(wp) :: u_int_l !< x/y-interpolated u-component at particle position at lower vertical level |
---|
| 254 | REAL(wp) :: u_int_u !< x/y-interpolated u-component at particle position at upper vertical level |
---|
| 255 | REAL(wp) :: us_int !< friction velocity at particle grid box |
---|
[2232] | 256 | REAL(wp) :: usws_int !< surface momentum flux (u component) at particle grid box |
---|
[1929] | 257 | REAL(wp) :: v_int_l !< x/y-interpolated v-component at particle position at lower vertical level |
---|
| 258 | REAL(wp) :: v_int_u !< x/y-interpolated v-component at particle position at upper vertical level |
---|
[2232] | 259 | REAL(wp) :: vsws_int !< surface momentum flux (u component) at particle grid box |
---|
[1682] | 260 | REAL(wp) :: vv_int !< |
---|
[1929] | 261 | REAL(wp) :: w_int_l !< x/y-interpolated w-component at particle position at lower vertical level |
---|
| 262 | REAL(wp) :: w_int_u !< x/y-interpolated w-component at particle position at upper vertical level |
---|
[1822] | 263 | REAL(wp) :: w_s !< terminal velocity of droplets |
---|
[1929] | 264 | REAL(wp) :: x !< dummy argument for horizontal particle interpolation |
---|
| 265 | REAL(wp) :: y !< dummy argument for horizontal particle interpolation |
---|
| 266 | REAL(wp) :: z_p !< surface layer height (0.5 dz) |
---|
[849] | 267 | |
---|
[1822] | 268 | REAL(wp), PARAMETER :: a_rog = 9.65_wp !< parameter for fall velocity |
---|
| 269 | REAL(wp), PARAMETER :: b_rog = 10.43_wp !< parameter for fall velocity |
---|
| 270 | REAL(wp), PARAMETER :: c_rog = 0.6_wp !< parameter for fall velocity |
---|
| 271 | REAL(wp), PARAMETER :: k_cap_rog = 4.0_wp !< parameter for fall velocity |
---|
| 272 | REAL(wp), PARAMETER :: k_low_rog = 12.0_wp !< parameter for fall velocity |
---|
| 273 | REAL(wp), PARAMETER :: d0_rog = 0.745_wp !< separation diameter |
---|
| 274 | |
---|
[1929] | 275 | REAL(wp), DIMENSION(1:30) :: d_gp_pl !< dummy argument for particle interpolation scheme in case of topography |
---|
| 276 | REAL(wp), DIMENSION(1:30) :: de_dxi !< horizontal TKE gradient along x at adjacent wall |
---|
| 277 | REAL(wp), DIMENSION(1:30) :: de_dyi !< horizontal TKE gradient along y at adjacent wall |
---|
| 278 | REAL(wp), DIMENSION(1:30) :: de_dzi !< horizontal TKE gradient along z at adjacent wall |
---|
| 279 | REAL(wp), DIMENSION(1:30) :: dissi !< dissipation at adjacent wall |
---|
| 280 | REAL(wp), DIMENSION(1:30) :: ei !< TKE at adjacent wall |
---|
[849] | 281 | |
---|
[2886] | 282 | REAL(wp), DIMENSION(number_of_particles) :: term_1_2 !< flag to communicate whether a particle is near topography or not |
---|
| 283 | REAL(wp), DIMENSION(number_of_particles) :: dens_ratio !< |
---|
| 284 | REAL(wp), DIMENSION(number_of_particles) :: de_dx_int !< horizontal TKE gradient along x at particle position |
---|
| 285 | REAL(wp), DIMENSION(number_of_particles) :: de_dy_int !< horizontal TKE gradient along y at particle position |
---|
| 286 | REAL(wp), DIMENSION(number_of_particles) :: de_dz_int !< horizontal TKE gradient along z at particle position |
---|
| 287 | REAL(wp), DIMENSION(number_of_particles) :: diss_int !< dissipation at particle position |
---|
| 288 | REAL(wp), DIMENSION(number_of_particles) :: dt_gap !< remaining time until particle time integration reaches LES time |
---|
| 289 | REAL(wp), DIMENSION(number_of_particles) :: dt_particle !< particle time step |
---|
| 290 | REAL(wp), DIMENSION(number_of_particles) :: e_int !< TKE at particle position |
---|
| 291 | REAL(wp), DIMENSION(number_of_particles) :: fs_int !< weighting factor for subgrid-scale particle speed |
---|
| 292 | REAL(wp), DIMENSION(number_of_particles) :: lagr_timescale !< Lagrangian timescale |
---|
| 293 | REAL(wp), DIMENSION(number_of_particles) :: rvar1_temp !< |
---|
| 294 | REAL(wp), DIMENSION(number_of_particles) :: rvar2_temp !< |
---|
| 295 | REAL(wp), DIMENSION(number_of_particles) :: rvar3_temp !< |
---|
| 296 | REAL(wp), DIMENSION(number_of_particles) :: u_int !< u-component of particle speed |
---|
| 297 | REAL(wp), DIMENSION(number_of_particles) :: v_int !< v-component of particle speed |
---|
| 298 | REAL(wp), DIMENSION(number_of_particles) :: w_int !< w-component of particle speed |
---|
| 299 | REAL(wp), DIMENSION(number_of_particles) :: xv !< x-position |
---|
| 300 | REAL(wp), DIMENSION(number_of_particles) :: yv !< y-position |
---|
| 301 | REAL(wp), DIMENSION(number_of_particles) :: zv !< z-position |
---|
[1359] | 302 | |
---|
[1929] | 303 | REAL(wp), DIMENSION(number_of_particles, 3) :: rg !< vector of Gaussian distributed random numbers |
---|
[1359] | 304 | |
---|
| 305 | CALL cpu_log( log_point_s(44), 'lpm_advec', 'continue' ) |
---|
| 306 | |
---|
[1314] | 307 | ! |
---|
| 308 | !-- Determine height of Prandtl layer and distance between Prandtl-layer |
---|
| 309 | !-- height and horizontal mean roughness height, which are required for |
---|
| 310 | !-- vertical logarithmic interpolation of horizontal particle speeds |
---|
| 311 | !-- (for particles below first vertical grid level). |
---|
| 312 | z_p = zu(nzb+1) - zw(nzb) |
---|
[1359] | 313 | d_z_p_z0 = 1.0_wp / ( z_p - z0_av_global ) |
---|
[849] | 314 | |
---|
[1359] | 315 | start_index = grid_particles(kp,jp,ip)%start_index |
---|
| 316 | end_index = grid_particles(kp,jp,ip)%end_index |
---|
[849] | 317 | |
---|
[1359] | 318 | xv = particles(1:number_of_particles)%x |
---|
| 319 | yv = particles(1:number_of_particles)%y |
---|
| 320 | zv = particles(1:number_of_particles)%z |
---|
[849] | 321 | |
---|
[1359] | 322 | DO nb = 0, 7 |
---|
[2606] | 323 | ! |
---|
| 324 | !-- Interpolate u velocity-component |
---|
[1359] | 325 | i = ip |
---|
| 326 | j = jp + block_offset(nb)%j_off |
---|
| 327 | k = kp + block_offset(nb)%k_off |
---|
[2606] | 328 | |
---|
[1359] | 329 | DO n = start_index(nb), end_index(nb) |
---|
[1314] | 330 | ! |
---|
[1359] | 331 | !-- Interpolation of the u velocity component onto particle position. |
---|
| 332 | !-- Particles are interpolation bi-linearly in the horizontal and a |
---|
| 333 | !-- linearly in the vertical. An exception is made for particles below |
---|
| 334 | !-- the first vertical grid level in case of a prandtl layer. In this |
---|
| 335 | !-- case the horizontal particle velocity components are determined using |
---|
| 336 | !-- Monin-Obukhov relations (if branch). |
---|
| 337 | !-- First, check if particle is located below first vertical grid level |
---|
[2232] | 338 | !-- above topography (Prandtl-layer height) |
---|
| 339 | !-- Determine vertical index of topography top |
---|
[2698] | 340 | k_wall = get_topography_top_index_ji( jp, ip, 's' ) |
---|
[1929] | 341 | |
---|
[2232] | 342 | IF ( constant_flux_layer .AND. zv(n) - zw(k_wall) < z_p ) THEN |
---|
[1314] | 343 | ! |
---|
[1359] | 344 | !-- Resolved-scale horizontal particle velocity is zero below z0. |
---|
[2232] | 345 | IF ( zv(n) - zw(k_wall) < z0_av_global ) THEN |
---|
[1359] | 346 | u_int(n) = 0.0_wp |
---|
| 347 | ELSE |
---|
[1314] | 348 | ! |
---|
[1359] | 349 | !-- Determine the sublayer. Further used as index. |
---|
[2232] | 350 | height_p = ( zv(n) - zw(k_wall) - z0_av_global ) & |
---|
[1936] | 351 | * REAL( number_of_sublayers, KIND=wp ) & |
---|
[1359] | 352 | * d_z_p_z0 |
---|
[1314] | 353 | ! |
---|
[1359] | 354 | !-- Calculate LOG(z/z0) for exact particle height. Therefore, |
---|
| 355 | !-- interpolate linearly between precalculated logarithm. |
---|
[1929] | 356 | log_z_z0_int = log_z_z0(INT(height_p)) & |
---|
[1359] | 357 | + ( height_p - INT(height_p) ) & |
---|
| 358 | * ( log_z_z0(INT(height_p)+1) & |
---|
| 359 | - log_z_z0(INT(height_p)) & |
---|
| 360 | ) |
---|
[1314] | 361 | ! |
---|
[2232] | 362 | !-- Get friction velocity and momentum flux from new surface data |
---|
| 363 | !-- types. |
---|
[2628] | 364 | IF ( surf_def_h(0)%start_index(jp,ip) <= & |
---|
| 365 | surf_def_h(0)%end_index(jp,ip) ) THEN |
---|
| 366 | surf_start = surf_def_h(0)%start_index(jp,ip) |
---|
[2232] | 367 | !-- Limit friction velocity. In narrow canyons or holes the |
---|
| 368 | !-- friction velocity can become very small, resulting in a too |
---|
| 369 | !-- large particle speed. |
---|
| 370 | us_int = MAX( surf_def_h(0)%us(surf_start), 0.01_wp ) |
---|
| 371 | usws_int = surf_def_h(0)%usws(surf_start) |
---|
[2628] | 372 | ELSEIF ( surf_lsm_h%start_index(jp,ip) <= & |
---|
| 373 | surf_lsm_h%end_index(jp,ip) ) THEN |
---|
| 374 | surf_start = surf_lsm_h%start_index(jp,ip) |
---|
[2232] | 375 | us_int = MAX( surf_lsm_h%us(surf_start), 0.01_wp ) |
---|
| 376 | usws_int = surf_lsm_h%usws(surf_start) |
---|
[2628] | 377 | ELSEIF ( surf_usm_h%start_index(jp,ip) <= & |
---|
| 378 | surf_usm_h%end_index(jp,ip) ) THEN |
---|
| 379 | surf_start = surf_usm_h%start_index(jp,ip) |
---|
[2232] | 380 | us_int = MAX( surf_usm_h%us(surf_start), 0.01_wp ) |
---|
| 381 | usws_int = surf_usm_h%usws(surf_start) |
---|
| 382 | ENDIF |
---|
| 383 | |
---|
[1929] | 384 | ! |
---|
[1359] | 385 | !-- Neutral solution is applied for all situations, e.g. also for |
---|
| 386 | !-- unstable and stable situations. Even though this is not exact |
---|
| 387 | !-- this saves a lot of CPU time since several calls of intrinsic |
---|
| 388 | !-- FORTRAN procedures (LOG, ATAN) are avoided, This is justified |
---|
| 389 | !-- as sensitivity studies revealed no significant effect of |
---|
| 390 | !-- using the neutral solution also for un/stable situations. |
---|
[2232] | 391 | u_int(n) = -usws_int / ( us_int * kappa + 1E-10_wp ) & |
---|
[1929] | 392 | * log_z_z0_int - u_gtrans |
---|
| 393 | |
---|
[1359] | 394 | ENDIF |
---|
| 395 | ! |
---|
| 396 | !-- Particle above the first grid level. Bi-linear interpolation in the |
---|
| 397 | !-- horizontal and linear interpolation in the vertical direction. |
---|
[1314] | 398 | ELSE |
---|
| 399 | |
---|
[2969] | 400 | x = xv(n) - i * dx |
---|
| 401 | y = yv(n) + ( 0.5_wp - j ) * dy |
---|
[1359] | 402 | aa = x**2 + y**2 |
---|
| 403 | bb = ( dx - x )**2 + y**2 |
---|
| 404 | cc = x**2 + ( dy - y )**2 |
---|
| 405 | dd = ( dx - x )**2 + ( dy - y )**2 |
---|
| 406 | gg = aa + bb + cc + dd |
---|
[1314] | 407 | |
---|
[1359] | 408 | u_int_l = ( ( gg - aa ) * u(k,j,i) + ( gg - bb ) * u(k,j,i+1) & |
---|
| 409 | + ( gg - cc ) * u(k,j+1,i) + ( gg - dd ) * & |
---|
| 410 | u(k,j+1,i+1) ) / ( 3.0_wp * gg ) - u_gtrans |
---|
[1314] | 411 | |
---|
[1359] | 412 | IF ( k == nzt ) THEN |
---|
| 413 | u_int(n) = u_int_l |
---|
| 414 | ELSE |
---|
| 415 | u_int_u = ( ( gg-aa ) * u(k+1,j,i) + ( gg-bb ) * u(k+1,j,i+1) & |
---|
| 416 | + ( gg-cc ) * u(k+1,j+1,i) + ( gg-dd ) * & |
---|
| 417 | u(k+1,j+1,i+1) ) / ( 3.0_wp * gg ) - u_gtrans |
---|
[3189] | 418 | u_int(n) = u_int_l + ( zv(n) - zu(k) ) / dzw(k+1) * & |
---|
[1359] | 419 | ( u_int_u - u_int_l ) |
---|
| 420 | ENDIF |
---|
[1929] | 421 | |
---|
[1314] | 422 | ENDIF |
---|
| 423 | |
---|
[1359] | 424 | ENDDO |
---|
[2606] | 425 | ! |
---|
| 426 | !-- Same procedure for interpolation of the v velocity-component |
---|
[1359] | 427 | i = ip + block_offset(nb)%i_off |
---|
| 428 | j = jp |
---|
| 429 | k = kp + block_offset(nb)%k_off |
---|
[2606] | 430 | |
---|
[1359] | 431 | DO n = start_index(nb), end_index(nb) |
---|
[1685] | 432 | |
---|
[2232] | 433 | ! |
---|
| 434 | !-- Determine vertical index of topography top |
---|
[2698] | 435 | k_wall = get_topography_top_index_ji( jp,ip, 's' ) |
---|
[849] | 436 | |
---|
[2232] | 437 | IF ( constant_flux_layer .AND. zv(n) - zw(k_wall) < z_p ) THEN |
---|
| 438 | IF ( zv(n) - zw(k_wall) < z0_av_global ) THEN |
---|
[1314] | 439 | ! |
---|
[1359] | 440 | !-- Resolved-scale horizontal particle velocity is zero below z0. |
---|
| 441 | v_int(n) = 0.0_wp |
---|
| 442 | ELSE |
---|
| 443 | ! |
---|
[1929] | 444 | !-- Determine the sublayer. Further used as index. Please note, |
---|
| 445 | !-- logarithmus can not be reused from above, as in in case of |
---|
| 446 | !-- topography particle on u-grid can be above surface-layer height, |
---|
| 447 | !-- whereas it can be below on v-grid. |
---|
[2232] | 448 | height_p = ( zv(n) - zw(k_wall) - z0_av_global ) & |
---|
[1936] | 449 | * REAL( number_of_sublayers, KIND=wp ) & |
---|
[1929] | 450 | * d_z_p_z0 |
---|
| 451 | ! |
---|
| 452 | !-- Calculate LOG(z/z0) for exact particle height. Therefore, |
---|
| 453 | !-- interpolate linearly between precalculated logarithm. |
---|
| 454 | log_z_z0_int = log_z_z0(INT(height_p)) & |
---|
| 455 | + ( height_p - INT(height_p) ) & |
---|
| 456 | * ( log_z_z0(INT(height_p)+1) & |
---|
| 457 | - log_z_z0(INT(height_p)) & |
---|
| 458 | ) |
---|
| 459 | ! |
---|
[2232] | 460 | !-- Get friction velocity and momentum flux from new surface data |
---|
| 461 | !-- types. |
---|
[2628] | 462 | IF ( surf_def_h(0)%start_index(jp,ip) <= & |
---|
| 463 | surf_def_h(0)%end_index(jp,ip) ) THEN |
---|
| 464 | surf_start = surf_def_h(0)%start_index(jp,ip) |
---|
[2232] | 465 | !-- Limit friction velocity. In narrow canyons or holes the |
---|
| 466 | !-- friction velocity can become very small, resulting in a too |
---|
| 467 | !-- large particle speed. |
---|
| 468 | us_int = MAX( surf_def_h(0)%us(surf_start), 0.01_wp ) |
---|
[2610] | 469 | vsws_int = surf_def_h(0)%vsws(surf_start) |
---|
[2628] | 470 | ELSEIF ( surf_lsm_h%start_index(jp,ip) <= & |
---|
| 471 | surf_lsm_h%end_index(jp,ip) ) THEN |
---|
| 472 | surf_start = surf_lsm_h%start_index(jp,ip) |
---|
[2232] | 473 | us_int = MAX( surf_lsm_h%us(surf_start), 0.01_wp ) |
---|
[2610] | 474 | vsws_int = surf_lsm_h%vsws(surf_start) |
---|
[2628] | 475 | ELSEIF ( surf_usm_h%start_index(jp,ip) <= & |
---|
| 476 | surf_usm_h%end_index(jp,ip) ) THEN |
---|
| 477 | surf_start = surf_usm_h%start_index(jp,ip) |
---|
[2232] | 478 | us_int = MAX( surf_usm_h%us(surf_start), 0.01_wp ) |
---|
[2610] | 479 | vsws_int = surf_usm_h%vsws(surf_start) |
---|
[2232] | 480 | ENDIF |
---|
[1929] | 481 | ! |
---|
[1359] | 482 | !-- Neutral solution is applied for all situations, e.g. also for |
---|
| 483 | !-- unstable and stable situations. Even though this is not exact |
---|
| 484 | !-- this saves a lot of CPU time since several calls of intrinsic |
---|
| 485 | !-- FORTRAN procedures (LOG, ATAN) are avoided, This is justified |
---|
| 486 | !-- as sensitivity studies revealed no significant effect of |
---|
| 487 | !-- using the neutral solution also for un/stable situations. |
---|
[2232] | 488 | v_int(n) = -vsws_int / ( us_int * kappa + 1E-10_wp ) & |
---|
[1929] | 489 | * log_z_z0_int - v_gtrans |
---|
[1314] | 490 | |
---|
[1359] | 491 | ENDIF |
---|
[1929] | 492 | |
---|
[1359] | 493 | ELSE |
---|
[2969] | 494 | x = xv(n) + ( 0.5_wp - i ) * dx |
---|
| 495 | y = yv(n) - j * dy |
---|
[1359] | 496 | aa = x**2 + y**2 |
---|
| 497 | bb = ( dx - x )**2 + y**2 |
---|
| 498 | cc = x**2 + ( dy - y )**2 |
---|
| 499 | dd = ( dx - x )**2 + ( dy - y )**2 |
---|
| 500 | gg = aa + bb + cc + dd |
---|
[1314] | 501 | |
---|
[1359] | 502 | v_int_l = ( ( gg - aa ) * v(k,j,i) + ( gg - bb ) * v(k,j,i+1) & |
---|
| 503 | + ( gg - cc ) * v(k,j+1,i) + ( gg - dd ) * v(k,j+1,i+1) & |
---|
| 504 | ) / ( 3.0_wp * gg ) - v_gtrans |
---|
[1314] | 505 | |
---|
[1359] | 506 | IF ( k == nzt ) THEN |
---|
| 507 | v_int(n) = v_int_l |
---|
| 508 | ELSE |
---|
| 509 | v_int_u = ( ( gg-aa ) * v(k+1,j,i) + ( gg-bb ) * v(k+1,j,i+1) & |
---|
| 510 | + ( gg-cc ) * v(k+1,j+1,i) + ( gg-dd ) * v(k+1,j+1,i+1) & |
---|
| 511 | ) / ( 3.0_wp * gg ) - v_gtrans |
---|
[3189] | 512 | v_int(n) = v_int_l + ( zv(n) - zu(k) ) / dzw(k+1) * & |
---|
[1359] | 513 | ( v_int_u - v_int_l ) |
---|
| 514 | ENDIF |
---|
[1929] | 515 | |
---|
[1314] | 516 | ENDIF |
---|
| 517 | |
---|
[1359] | 518 | ENDDO |
---|
[2606] | 519 | ! |
---|
| 520 | !-- Same procedure for interpolation of the w velocity-component |
---|
[1359] | 521 | i = ip + block_offset(nb)%i_off |
---|
| 522 | j = jp + block_offset(nb)%j_off |
---|
[1929] | 523 | k = kp - 1 |
---|
[2606] | 524 | |
---|
[1359] | 525 | DO n = start_index(nb), end_index(nb) |
---|
[849] | 526 | |
---|
[1359] | 527 | IF ( vertical_particle_advection(particles(n)%group) ) THEN |
---|
[849] | 528 | |
---|
[2969] | 529 | x = xv(n) + ( 0.5_wp - i ) * dx |
---|
| 530 | y = yv(n) + ( 0.5_wp - j ) * dy |
---|
[849] | 531 | aa = x**2 + y**2 |
---|
| 532 | bb = ( dx - x )**2 + y**2 |
---|
| 533 | cc = x**2 + ( dy - y )**2 |
---|
| 534 | dd = ( dx - x )**2 + ( dy - y )**2 |
---|
| 535 | gg = aa + bb + cc + dd |
---|
| 536 | |
---|
[1359] | 537 | w_int_l = ( ( gg - aa ) * w(k,j,i) + ( gg - bb ) * w(k,j,i+1) & |
---|
| 538 | + ( gg - cc ) * w(k,j+1,i) + ( gg - dd ) * w(k,j+1,i+1) & |
---|
| 539 | ) / ( 3.0_wp * gg ) |
---|
[849] | 540 | |
---|
[1359] | 541 | IF ( k == nzt ) THEN |
---|
| 542 | w_int(n) = w_int_l |
---|
[849] | 543 | ELSE |
---|
[1359] | 544 | w_int_u = ( ( gg-aa ) * w(k+1,j,i) + & |
---|
| 545 | ( gg-bb ) * w(k+1,j,i+1) + & |
---|
| 546 | ( gg-cc ) * w(k+1,j+1,i) + & |
---|
| 547 | ( gg-dd ) * w(k+1,j+1,i+1) & |
---|
| 548 | ) / ( 3.0_wp * gg ) |
---|
[3189] | 549 | w_int(n) = w_int_l + ( zv(n) - zw(k) ) / dzw(k+1) * & |
---|
[1359] | 550 | ( w_int_u - w_int_l ) |
---|
[849] | 551 | ENDIF |
---|
| 552 | |
---|
[1359] | 553 | ELSE |
---|
[849] | 554 | |
---|
[1359] | 555 | w_int(n) = 0.0_wp |
---|
[849] | 556 | |
---|
[1359] | 557 | ENDIF |
---|
| 558 | |
---|
| 559 | ENDDO |
---|
| 560 | |
---|
| 561 | ENDDO |
---|
| 562 | |
---|
| 563 | !-- Interpolate and calculate quantities needed for calculating the SGS |
---|
| 564 | !-- velocities |
---|
[1822] | 565 | IF ( use_sgs_for_particles .AND. .NOT. cloud_droplets ) THEN |
---|
[2698] | 566 | |
---|
| 567 | DO nb = 0,7 |
---|
| 568 | |
---|
| 569 | subbox_at_wall = .FALSE. |
---|
| 570 | ! |
---|
| 571 | !-- In case of topography check if subbox is adjacent to a wall |
---|
| 572 | IF ( .NOT. topography == 'flat' ) THEN |
---|
| 573 | i = ip + MERGE( -1_iwp , 1_iwp, BTEST( nb, 2 ) ) |
---|
| 574 | j = jp + MERGE( -1_iwp , 1_iwp, BTEST( nb, 1 ) ) |
---|
| 575 | k = kp + MERGE( -1_iwp , 1_iwp, BTEST( nb, 0 ) ) |
---|
| 576 | IF ( .NOT. BTEST(wall_flags_0(k, jp, ip), 0) .OR. & |
---|
| 577 | .NOT. BTEST(wall_flags_0(kp, j, ip), 0) .OR. & |
---|
| 578 | .NOT. BTEST(wall_flags_0(kp, jp, i ), 0) ) & |
---|
| 579 | THEN |
---|
| 580 | subbox_at_wall = .TRUE. |
---|
| 581 | ENDIF |
---|
| 582 | ENDIF |
---|
| 583 | IF ( subbox_at_wall ) THEN |
---|
| 584 | e_int(start_index(nb):end_index(nb)) = e(kp,jp,ip) |
---|
| 585 | diss_int(start_index(nb):end_index(nb)) = diss(kp,jp,ip) |
---|
| 586 | de_dx_int(start_index(nb):end_index(nb)) = de_dx(kp,jp,ip) |
---|
| 587 | de_dy_int(start_index(nb):end_index(nb)) = de_dy(kp,jp,ip) |
---|
| 588 | de_dz_int(start_index(nb):end_index(nb)) = de_dz(kp,jp,ip) |
---|
| 589 | ! |
---|
| 590 | !-- Set flag for stochastic equation. |
---|
| 591 | term_1_2(start_index(nb):end_index(nb)) = 0.0_wp |
---|
| 592 | ELSE |
---|
[1359] | 593 | i = ip + block_offset(nb)%i_off |
---|
| 594 | j = jp + block_offset(nb)%j_off |
---|
| 595 | k = kp + block_offset(nb)%k_off |
---|
| 596 | |
---|
| 597 | DO n = start_index(nb), end_index(nb) |
---|
[849] | 598 | ! |
---|
[1359] | 599 | !-- Interpolate TKE |
---|
[2969] | 600 | x = xv(n) + ( 0.5_wp - i ) * dx |
---|
| 601 | y = yv(n) + ( 0.5_wp - j ) * dy |
---|
[1359] | 602 | aa = x**2 + y**2 |
---|
| 603 | bb = ( dx - x )**2 + y**2 |
---|
| 604 | cc = x**2 + ( dy - y )**2 |
---|
| 605 | dd = ( dx - x )**2 + ( dy - y )**2 |
---|
| 606 | gg = aa + bb + cc + dd |
---|
[849] | 607 | |
---|
[1359] | 608 | e_int_l = ( ( gg-aa ) * e(k,j,i) + ( gg-bb ) * e(k,j,i+1) & |
---|
| 609 | + ( gg-cc ) * e(k,j+1,i) + ( gg-dd ) * e(k,j+1,i+1) & |
---|
| 610 | ) / ( 3.0_wp * gg ) |
---|
| 611 | |
---|
| 612 | IF ( k+1 == nzt+1 ) THEN |
---|
| 613 | e_int(n) = e_int_l |
---|
| 614 | ELSE |
---|
| 615 | e_int_u = ( ( gg - aa ) * e(k+1,j,i) + & |
---|
| 616 | ( gg - bb ) * e(k+1,j,i+1) + & |
---|
| 617 | ( gg - cc ) * e(k+1,j+1,i) + & |
---|
| 618 | ( gg - dd ) * e(k+1,j+1,i+1) & |
---|
| 619 | ) / ( 3.0_wp * gg ) |
---|
[3189] | 620 | e_int(n) = e_int_l + ( zv(n) - zu(k) ) / dzw(k+1) * & |
---|
[1359] | 621 | ( e_int_u - e_int_l ) |
---|
| 622 | ENDIF |
---|
[849] | 623 | ! |
---|
[1685] | 624 | !-- Needed to avoid NaN particle velocities (this might not be |
---|
| 625 | !-- required any more) |
---|
| 626 | IF ( e_int(n) <= 0.0_wp ) THEN |
---|
[1359] | 627 | e_int(n) = 1.0E-20_wp |
---|
| 628 | ENDIF |
---|
| 629 | ! |
---|
| 630 | !-- Interpolate the TKE gradient along x (adopt incides i,j,k and |
---|
| 631 | !-- all position variables from above (TKE)) |
---|
| 632 | de_dx_int_l = ( ( gg - aa ) * de_dx(k,j,i) + & |
---|
| 633 | ( gg - bb ) * de_dx(k,j,i+1) + & |
---|
| 634 | ( gg - cc ) * de_dx(k,j+1,i) + & |
---|
| 635 | ( gg - dd ) * de_dx(k,j+1,i+1) & |
---|
| 636 | ) / ( 3.0_wp * gg ) |
---|
[849] | 637 | |
---|
| 638 | IF ( ( k+1 == nzt+1 ) .OR. ( k == nzb ) ) THEN |
---|
[1359] | 639 | de_dx_int(n) = de_dx_int_l |
---|
[849] | 640 | ELSE |
---|
[1359] | 641 | de_dx_int_u = ( ( gg - aa ) * de_dx(k+1,j,i) + & |
---|
| 642 | ( gg - bb ) * de_dx(k+1,j,i+1) + & |
---|
| 643 | ( gg - cc ) * de_dx(k+1,j+1,i) + & |
---|
| 644 | ( gg - dd ) * de_dx(k+1,j+1,i+1) & |
---|
| 645 | ) / ( 3.0_wp * gg ) |
---|
[3189] | 646 | de_dx_int(n) = de_dx_int_l + ( zv(n) - zu(k) ) / dzw(k+1) * & |
---|
[1359] | 647 | ( de_dx_int_u - de_dx_int_l ) |
---|
[849] | 648 | ENDIF |
---|
[1359] | 649 | ! |
---|
| 650 | !-- Interpolate the TKE gradient along y |
---|
| 651 | de_dy_int_l = ( ( gg - aa ) * de_dy(k,j,i) + & |
---|
| 652 | ( gg - bb ) * de_dy(k,j,i+1) + & |
---|
| 653 | ( gg - cc ) * de_dy(k,j+1,i) + & |
---|
| 654 | ( gg - dd ) * de_dy(k,j+1,i+1) & |
---|
| 655 | ) / ( 3.0_wp * gg ) |
---|
| 656 | IF ( ( k+1 == nzt+1 ) .OR. ( k == nzb ) ) THEN |
---|
| 657 | de_dy_int(n) = de_dy_int_l |
---|
| 658 | ELSE |
---|
| 659 | de_dy_int_u = ( ( gg - aa ) * de_dy(k+1,j,i) + & |
---|
[2698] | 660 | ( gg - bb ) * de_dy(k+1,j,i+1) + & |
---|
| 661 | ( gg - cc ) * de_dy(k+1,j+1,i) + & |
---|
| 662 | ( gg - dd ) * de_dy(k+1,j+1,i+1) & |
---|
[1359] | 663 | ) / ( 3.0_wp * gg ) |
---|
[3189] | 664 | de_dy_int(n) = de_dy_int_l + ( zv(n) - zu(k) ) / dzw(k+1) * & |
---|
[2698] | 665 | ( de_dy_int_u - de_dy_int_l ) |
---|
[1359] | 666 | ENDIF |
---|
[849] | 667 | |
---|
| 668 | ! |
---|
[1359] | 669 | !-- Interpolate the TKE gradient along z |
---|
[3065] | 670 | IF ( zv(n) < 0.5_wp * dz(1) ) THEN |
---|
[1359] | 671 | de_dz_int(n) = 0.0_wp |
---|
| 672 | ELSE |
---|
| 673 | de_dz_int_l = ( ( gg - aa ) * de_dz(k,j,i) + & |
---|
| 674 | ( gg - bb ) * de_dz(k,j,i+1) + & |
---|
| 675 | ( gg - cc ) * de_dz(k,j+1,i) + & |
---|
| 676 | ( gg - dd ) * de_dz(k,j+1,i+1) & |
---|
| 677 | ) / ( 3.0_wp * gg ) |
---|
[849] | 678 | |
---|
[1359] | 679 | IF ( ( k+1 == nzt+1 ) .OR. ( k == nzb ) ) THEN |
---|
| 680 | de_dz_int(n) = de_dz_int_l |
---|
| 681 | ELSE |
---|
| 682 | de_dz_int_u = ( ( gg - aa ) * de_dz(k+1,j,i) + & |
---|
| 683 | ( gg - bb ) * de_dz(k+1,j,i+1) + & |
---|
| 684 | ( gg - cc ) * de_dz(k+1,j+1,i) + & |
---|
| 685 | ( gg - dd ) * de_dz(k+1,j+1,i+1) & |
---|
| 686 | ) / ( 3.0_wp * gg ) |
---|
[3189] | 687 | de_dz_int(n) = de_dz_int_l + ( zv(n) - zu(k) ) / dzw(k+1) * & |
---|
[1359] | 688 | ( de_dz_int_u - de_dz_int_l ) |
---|
| 689 | ENDIF |
---|
| 690 | ENDIF |
---|
[849] | 691 | |
---|
[1359] | 692 | ! |
---|
| 693 | !-- Interpolate the dissipation of TKE |
---|
| 694 | diss_int_l = ( ( gg - aa ) * diss(k,j,i) + & |
---|
| 695 | ( gg - bb ) * diss(k,j,i+1) + & |
---|
| 696 | ( gg - cc ) * diss(k,j+1,i) + & |
---|
| 697 | ( gg - dd ) * diss(k,j+1,i+1) & |
---|
[2698] | 698 | ) / ( 3.0_wp * gg ) |
---|
[849] | 699 | |
---|
[1359] | 700 | IF ( k == nzt ) THEN |
---|
| 701 | diss_int(n) = diss_int_l |
---|
| 702 | ELSE |
---|
| 703 | diss_int_u = ( ( gg - aa ) * diss(k+1,j,i) + & |
---|
| 704 | ( gg - bb ) * diss(k+1,j,i+1) + & |
---|
| 705 | ( gg - cc ) * diss(k+1,j+1,i) + & |
---|
| 706 | ( gg - dd ) * diss(k+1,j+1,i+1) & |
---|
| 707 | ) / ( 3.0_wp * gg ) |
---|
[3189] | 708 | diss_int(n) = diss_int_l + ( zv(n) - zu(k) ) / dzw(k+1) * & |
---|
[2698] | 709 | ( diss_int_u - diss_int_l ) |
---|
[1359] | 710 | ENDIF |
---|
| 711 | |
---|
[1929] | 712 | ! |
---|
| 713 | !-- Set flag for stochastic equation. |
---|
| 714 | term_1_2(n) = 1.0_wp |
---|
[1359] | 715 | ENDDO |
---|
[2698] | 716 | ENDIF |
---|
| 717 | ENDDO |
---|
[1359] | 718 | |
---|
| 719 | DO nb = 0,7 |
---|
| 720 | i = ip + block_offset(nb)%i_off |
---|
| 721 | j = jp + block_offset(nb)%j_off |
---|
| 722 | k = kp + block_offset(nb)%k_off |
---|
[849] | 723 | |
---|
[1359] | 724 | DO n = start_index(nb), end_index(nb) |
---|
[849] | 725 | ! |
---|
[1359] | 726 | !-- Vertical interpolation of the horizontally averaged SGS TKE and |
---|
| 727 | !-- resolved-scale velocity variances and use the interpolated values |
---|
| 728 | !-- to calculate the coefficient fs, which is a measure of the ratio |
---|
| 729 | !-- of the subgrid-scale turbulent kinetic energy to the total amount |
---|
| 730 | !-- of turbulent kinetic energy. |
---|
| 731 | IF ( k == 0 ) THEN |
---|
| 732 | e_mean_int = hom(0,1,8,0) |
---|
| 733 | ELSE |
---|
| 734 | e_mean_int = hom(k,1,8,0) + & |
---|
| 735 | ( hom(k+1,1,8,0) - hom(k,1,8,0) ) / & |
---|
| 736 | ( zu(k+1) - zu(k) ) * & |
---|
| 737 | ( zv(n) - zu(k) ) |
---|
| 738 | ENDIF |
---|
[849] | 739 | |
---|
[1685] | 740 | kw = kp - 1 |
---|
[849] | 741 | |
---|
[1359] | 742 | IF ( k == 0 ) THEN |
---|
| 743 | aa = hom(k+1,1,30,0) * ( zv(n) / & |
---|
| 744 | ( 0.5_wp * ( zu(k+1) - zu(k) ) ) ) |
---|
| 745 | bb = hom(k+1,1,31,0) * ( zv(n) / & |
---|
| 746 | ( 0.5_wp * ( zu(k+1) - zu(k) ) ) ) |
---|
| 747 | cc = hom(kw+1,1,32,0) * ( zv(n) / & |
---|
| 748 | ( 1.0_wp * ( zw(kw+1) - zw(kw) ) ) ) |
---|
| 749 | ELSE |
---|
| 750 | aa = hom(k,1,30,0) + ( hom(k+1,1,30,0) - hom(k,1,30,0) ) * & |
---|
| 751 | ( ( zv(n) - zu(k) ) / ( zu(k+1) - zu(k) ) ) |
---|
| 752 | bb = hom(k,1,31,0) + ( hom(k+1,1,31,0) - hom(k,1,31,0) ) * & |
---|
| 753 | ( ( zv(n) - zu(k) ) / ( zu(k+1) - zu(k) ) ) |
---|
| 754 | cc = hom(kw,1,32,0) + ( hom(kw+1,1,32,0)-hom(kw,1,32,0) ) * & |
---|
| 755 | ( ( zv(n) - zw(kw) ) / ( zw(kw+1)-zw(kw) ) ) |
---|
| 756 | ENDIF |
---|
[849] | 757 | |
---|
[1359] | 758 | vv_int = ( 1.0_wp / 3.0_wp ) * ( aa + bb + cc ) |
---|
| 759 | ! |
---|
| 760 | !-- Needed to avoid NaN particle velocities. The value of 1.0 is just |
---|
| 761 | !-- an educated guess for the given case. |
---|
| 762 | IF ( vv_int + ( 2.0_wp / 3.0_wp ) * e_mean_int == 0.0_wp ) THEN |
---|
| 763 | fs_int(n) = 1.0_wp |
---|
| 764 | ELSE |
---|
| 765 | fs_int(n) = ( 2.0_wp / 3.0_wp ) * e_mean_int / & |
---|
| 766 | ( vv_int + ( 2.0_wp / 3.0_wp ) * e_mean_int ) |
---|
| 767 | ENDIF |
---|
[849] | 768 | |
---|
[1359] | 769 | ENDDO |
---|
| 770 | ENDDO |
---|
[849] | 771 | |
---|
[2417] | 772 | DO nb = 0, 7 |
---|
| 773 | DO n = start_index(nb), end_index(nb) |
---|
| 774 | rg(n,1) = random_gauss( iran_part, 5.0_wp ) |
---|
| 775 | rg(n,2) = random_gauss( iran_part, 5.0_wp ) |
---|
| 776 | rg(n,3) = random_gauss( iran_part, 5.0_wp ) |
---|
| 777 | ENDDO |
---|
| 778 | ENDDO |
---|
[1359] | 779 | |
---|
[2417] | 780 | DO nb = 0, 7 |
---|
| 781 | DO n = start_index(nb), end_index(nb) |
---|
[1359] | 782 | |
---|
[849] | 783 | ! |
---|
[2417] | 784 | !-- Calculate the Lagrangian timescale according to Weil et al. (2004). |
---|
[2886] | 785 | lagr_timescale(n) = ( 4.0_wp * e_int(n) + 1E-20_wp ) / & |
---|
[2417] | 786 | ( 3.0_wp * fs_int(n) * c_0 * diss_int(n) + 1E-20_wp ) |
---|
[849] | 787 | |
---|
| 788 | ! |
---|
[2417] | 789 | !-- Calculate the next particle timestep. dt_gap is the time needed to |
---|
| 790 | !-- complete the current LES timestep. |
---|
[2886] | 791 | dt_gap(n) = dt_3d - particles(n)%dt_sum |
---|
| 792 | dt_particle(n) = MIN( dt_3d, 0.025_wp * lagr_timescale(n), dt_gap(n) ) |
---|
| 793 | particles(n)%aux1 = lagr_timescale(n) |
---|
| 794 | particles(n)%aux2 = dt_gap(n) |
---|
[849] | 795 | ! |
---|
[2417] | 796 | !-- The particle timestep should not be too small in order to prevent |
---|
| 797 | !-- the number of particle timesteps of getting too large |
---|
[2886] | 798 | IF ( dt_particle(n) < dt_min_part .AND. dt_min_part < dt_gap(n) ) THEN |
---|
[2417] | 799 | dt_particle(n) = dt_min_part |
---|
| 800 | ENDIF |
---|
[2886] | 801 | rvar1_temp(n) = particles(n)%rvar1 |
---|
| 802 | rvar2_temp(n) = particles(n)%rvar2 |
---|
| 803 | rvar3_temp(n) = particles(n)%rvar3 |
---|
[849] | 804 | ! |
---|
[2417] | 805 | !-- Calculate the SGS velocity components |
---|
| 806 | IF ( particles(n)%age == 0.0_wp ) THEN |
---|
[849] | 807 | ! |
---|
[2417] | 808 | !-- For new particles the SGS components are derived from the SGS |
---|
| 809 | !-- TKE. Limit the Gaussian random number to the interval |
---|
| 810 | !-- [-5.0*sigma, 5.0*sigma] in order to prevent the SGS velocities |
---|
| 811 | !-- from becoming unrealistically large. |
---|
[2886] | 812 | rvar1_temp(n) = SQRT( 2.0_wp * sgs_wf_part * e_int(n) & |
---|
| 813 | + 1E-20_wp ) * ( rg(n,1) - 1.0_wp ) |
---|
| 814 | rvar2_temp(n) = SQRT( 2.0_wp * sgs_wf_part * e_int(n) & |
---|
| 815 | + 1E-20_wp ) * ( rg(n,2) - 1.0_wp ) |
---|
| 816 | rvar3_temp(n) = SQRT( 2.0_wp * sgs_wf_part * e_int(n) & |
---|
| 817 | + 1E-20_wp ) * ( rg(n,3) - 1.0_wp ) |
---|
[849] | 818 | |
---|
[2417] | 819 | ELSE |
---|
[849] | 820 | ! |
---|
[2417] | 821 | !-- Restriction of the size of the new timestep: compared to the |
---|
| 822 | !-- previous timestep the increase must not exceed 200%. First, |
---|
| 823 | !-- check if age > age_m, in order to prevent that particles get zero |
---|
| 824 | !-- timestep. |
---|
| 825 | dt_particle_m = MERGE( dt_particle(n), & |
---|
| 826 | particles(n)%age - particles(n)%age_m, & |
---|
| 827 | particles(n)%age - particles(n)%age_m < & |
---|
| 828 | 1E-8_wp ) |
---|
| 829 | IF ( dt_particle(n) > 2.0_wp * dt_particle_m ) THEN |
---|
| 830 | dt_particle(n) = 2.0_wp * dt_particle_m |
---|
| 831 | ENDIF |
---|
[849] | 832 | |
---|
[2417] | 833 | !-- For old particles the SGS components are correlated with the |
---|
| 834 | !-- values from the previous timestep. Random numbers have also to |
---|
| 835 | !-- be limited (see above). |
---|
| 836 | !-- As negative values for the subgrid TKE are not allowed, the |
---|
| 837 | !-- change of the subgrid TKE with time cannot be smaller than |
---|
| 838 | !-- -e_int(n)/dt_particle. This value is used as a lower boundary |
---|
| 839 | !-- value for the change of TKE |
---|
| 840 | de_dt_min = - e_int(n) / dt_particle(n) |
---|
[849] | 841 | |
---|
[2417] | 842 | de_dt = ( e_int(n) - particles(n)%e_m ) / dt_particle_m |
---|
[849] | 843 | |
---|
[2417] | 844 | IF ( de_dt < de_dt_min ) THEN |
---|
| 845 | de_dt = de_dt_min |
---|
| 846 | ENDIF |
---|
[849] | 847 | |
---|
[2886] | 848 | CALL weil_stochastic_eq(rvar1_temp(n), fs_int(n), e_int(n),& |
---|
[2417] | 849 | de_dx_int(n), de_dt, diss_int(n), & |
---|
| 850 | dt_particle(n), rg(n,1), term_1_2(n) ) |
---|
[849] | 851 | |
---|
[2886] | 852 | CALL weil_stochastic_eq(rvar2_temp(n), fs_int(n), e_int(n),& |
---|
[2417] | 853 | de_dy_int(n), de_dt, diss_int(n), & |
---|
| 854 | dt_particle(n), rg(n,2), term_1_2(n) ) |
---|
[849] | 855 | |
---|
[2886] | 856 | CALL weil_stochastic_eq(rvar3_temp(n), fs_int(n), e_int(n),& |
---|
[2417] | 857 | de_dz_int(n), de_dt, diss_int(n), & |
---|
| 858 | dt_particle(n), rg(n,3), term_1_2(n) ) |
---|
[849] | 859 | |
---|
[2417] | 860 | ENDIF |
---|
[849] | 861 | |
---|
[2886] | 862 | ENDDO |
---|
| 863 | ENDDO |
---|
| 864 | ! |
---|
| 865 | !-- Check if the added SGS velocities result in a violation of the CFL- |
---|
| 866 | !-- criterion. If yes choose a smaller timestep based on the new velocities |
---|
| 867 | !-- and calculate SGS velocities again |
---|
| 868 | dz_temp = zw(kp)-zw(kp-1) |
---|
| 869 | |
---|
| 870 | DO nb = 0, 7 |
---|
| 871 | DO n = start_index(nb), end_index(nb) |
---|
| 872 | IF ( .NOT. particles(n)%age == 0.0_wp .AND. & |
---|
| 873 | (ABS( u_int(n) + rvar1_temp(n) ) > (dx/dt_particle(n)) .OR. & |
---|
| 874 | ABS( v_int(n) + rvar2_temp(n) ) > (dy/dt_particle(n)) .OR. & |
---|
| 875 | ABS( w_int(n) + rvar3_temp(n) ) > (dz_temp/dt_particle(n)))) THEN |
---|
| 876 | |
---|
| 877 | dt_particle(n) = 0.9_wp * MIN( & |
---|
| 878 | ( dx / ABS( u_int(n) + rvar1_temp(n) ) ), & |
---|
| 879 | ( dy / ABS( v_int(n) + rvar2_temp(n) ) ), & |
---|
| 880 | ( dz_temp / ABS( w_int(n) + rvar3_temp(n) ) ) ) |
---|
| 881 | |
---|
| 882 | ! |
---|
| 883 | !-- Reset temporary SGS velocites to "current" ones |
---|
| 884 | rvar1_temp(n) = particles(n)%rvar1 |
---|
| 885 | rvar2_temp(n) = particles(n)%rvar2 |
---|
| 886 | rvar3_temp(n) = particles(n)%rvar3 |
---|
| 887 | |
---|
| 888 | de_dt_min = - e_int(n) / dt_particle(n) |
---|
| 889 | |
---|
| 890 | de_dt = ( e_int(n) - particles(n)%e_m ) / dt_particle_m |
---|
| 891 | |
---|
| 892 | IF ( de_dt < de_dt_min ) THEN |
---|
| 893 | de_dt = de_dt_min |
---|
| 894 | ENDIF |
---|
| 895 | |
---|
| 896 | CALL weil_stochastic_eq(rvar1_temp(n), fs_int(n), e_int(n),& |
---|
| 897 | de_dx_int(n), de_dt, diss_int(n), & |
---|
| 898 | dt_particle(n), rg(n,1), term_1_2(n) ) |
---|
| 899 | |
---|
| 900 | CALL weil_stochastic_eq(rvar2_temp(n), fs_int(n), e_int(n),& |
---|
| 901 | de_dy_int(n), de_dt, diss_int(n), & |
---|
| 902 | dt_particle(n), rg(n,2), term_1_2(n) ) |
---|
| 903 | |
---|
| 904 | CALL weil_stochastic_eq(rvar3_temp(n), fs_int(n), e_int(n),& |
---|
| 905 | de_dz_int(n), de_dt, diss_int(n), & |
---|
| 906 | dt_particle(n), rg(n,3), term_1_2(n) ) |
---|
| 907 | ENDIF |
---|
| 908 | |
---|
| 909 | ! |
---|
| 910 | !-- Update particle velocites |
---|
| 911 | particles(n)%rvar1 = rvar1_temp(n) |
---|
| 912 | particles(n)%rvar2 = rvar2_temp(n) |
---|
| 913 | particles(n)%rvar3 = rvar3_temp(n) |
---|
[2417] | 914 | u_int(n) = u_int(n) + particles(n)%rvar1 |
---|
| 915 | v_int(n) = v_int(n) + particles(n)%rvar2 |
---|
| 916 | w_int(n) = w_int(n) + particles(n)%rvar3 |
---|
[849] | 917 | ! |
---|
[2417] | 918 | !-- Store the SGS TKE of the current timelevel which is needed for |
---|
| 919 | !-- for calculating the SGS particle velocities at the next timestep |
---|
| 920 | particles(n)%e_m = e_int(n) |
---|
| 921 | ENDDO |
---|
[1359] | 922 | ENDDO |
---|
[2886] | 923 | |
---|
[1359] | 924 | ELSE |
---|
[849] | 925 | ! |
---|
[1359] | 926 | !-- If no SGS velocities are used, only the particle timestep has to |
---|
| 927 | !-- be set |
---|
| 928 | dt_particle = dt_3d |
---|
[849] | 929 | |
---|
[1359] | 930 | ENDIF |
---|
[849] | 931 | |
---|
[1359] | 932 | dens_ratio = particle_groups(particles(1:number_of_particles)%group)%density_ratio |
---|
[849] | 933 | |
---|
[1359] | 934 | IF ( ANY( dens_ratio == 0.0_wp ) ) THEN |
---|
[2417] | 935 | DO nb = 0, 7 |
---|
| 936 | DO n = start_index(nb), end_index(nb) |
---|
[1359] | 937 | |
---|
[849] | 938 | ! |
---|
[2417] | 939 | !-- Particle advection |
---|
| 940 | IF ( dens_ratio(n) == 0.0_wp ) THEN |
---|
[849] | 941 | ! |
---|
[2417] | 942 | !-- Pure passive transport (without particle inertia) |
---|
| 943 | particles(n)%x = xv(n) + u_int(n) * dt_particle(n) |
---|
| 944 | particles(n)%y = yv(n) + v_int(n) * dt_particle(n) |
---|
| 945 | particles(n)%z = zv(n) + w_int(n) * dt_particle(n) |
---|
[849] | 946 | |
---|
[2417] | 947 | particles(n)%speed_x = u_int(n) |
---|
| 948 | particles(n)%speed_y = v_int(n) |
---|
| 949 | particles(n)%speed_z = w_int(n) |
---|
[849] | 950 | |
---|
[2417] | 951 | ELSE |
---|
[849] | 952 | ! |
---|
[2417] | 953 | !-- Transport of particles with inertia |
---|
| 954 | particles(n)%x = particles(n)%x + particles(n)%speed_x * & |
---|
| 955 | dt_particle(n) |
---|
| 956 | particles(n)%y = particles(n)%y + particles(n)%speed_y * & |
---|
| 957 | dt_particle(n) |
---|
| 958 | particles(n)%z = particles(n)%z + particles(n)%speed_z * & |
---|
| 959 | dt_particle(n) |
---|
[849] | 960 | |
---|
| 961 | ! |
---|
[2417] | 962 | !-- Update of the particle velocity |
---|
| 963 | IF ( cloud_droplets ) THEN |
---|
| 964 | ! |
---|
| 965 | !-- Terminal velocity is computed for vertical direction (Rogers et |
---|
| 966 | !-- al., 1993, J. Appl. Meteorol.) |
---|
| 967 | diameter = particles(n)%radius * 2000.0_wp !diameter in mm |
---|
| 968 | IF ( diameter <= d0_rog ) THEN |
---|
| 969 | w_s = k_cap_rog * diameter * ( 1.0_wp - EXP( -k_low_rog * diameter ) ) |
---|
| 970 | ELSE |
---|
| 971 | w_s = a_rog - b_rog * EXP( -c_rog * diameter ) |
---|
| 972 | ENDIF |
---|
| 973 | |
---|
| 974 | ! |
---|
| 975 | !-- If selected, add random velocities following Soelch and Kaercher |
---|
| 976 | !-- (2010, Q. J. R. Meteorol. Soc.) |
---|
| 977 | IF ( use_sgs_for_particles ) THEN |
---|
[2886] | 978 | lagr_timescale(n) = km(kp,jp,ip) / MAX( e(kp,jp,ip), 1.0E-20_wp ) |
---|
| 979 | RL = EXP( -1.0_wp * dt_3d / lagr_timescale(n) ) |
---|
[2417] | 980 | sigma = SQRT( e(kp,jp,ip) ) |
---|
| 981 | |
---|
| 982 | rg1 = random_gauss( iran_part, 5.0_wp ) - 1.0_wp |
---|
| 983 | rg2 = random_gauss( iran_part, 5.0_wp ) - 1.0_wp |
---|
| 984 | rg3 = random_gauss( iran_part, 5.0_wp ) - 1.0_wp |
---|
| 985 | |
---|
| 986 | particles(n)%rvar1 = RL * particles(n)%rvar1 + & |
---|
| 987 | SQRT( 1.0_wp - RL**2 ) * sigma * rg1 |
---|
| 988 | particles(n)%rvar2 = RL * particles(n)%rvar2 + & |
---|
| 989 | SQRT( 1.0_wp - RL**2 ) * sigma * rg2 |
---|
| 990 | particles(n)%rvar3 = RL * particles(n)%rvar3 + & |
---|
| 991 | SQRT( 1.0_wp - RL**2 ) * sigma * rg3 |
---|
| 992 | |
---|
| 993 | particles(n)%speed_x = u_int(n) + particles(n)%rvar1 |
---|
| 994 | particles(n)%speed_y = v_int(n) + particles(n)%rvar2 |
---|
| 995 | particles(n)%speed_z = w_int(n) + particles(n)%rvar3 - w_s |
---|
| 996 | ELSE |
---|
| 997 | particles(n)%speed_x = u_int(n) |
---|
| 998 | particles(n)%speed_y = v_int(n) |
---|
| 999 | particles(n)%speed_z = w_int(n) - w_s |
---|
| 1000 | ENDIF |
---|
| 1001 | |
---|
| 1002 | ELSE |
---|
| 1003 | |
---|
| 1004 | IF ( use_sgs_for_particles ) THEN |
---|
| 1005 | exp_arg = particle_groups(particles(n)%group)%exp_arg |
---|
| 1006 | exp_term = EXP( -exp_arg * dt_particle(n) ) |
---|
| 1007 | ELSE |
---|
| 1008 | exp_arg = particle_groups(particles(n)%group)%exp_arg |
---|
| 1009 | exp_term = particle_groups(particles(n)%group)%exp_term |
---|
| 1010 | ENDIF |
---|
| 1011 | particles(n)%speed_x = particles(n)%speed_x * exp_term + & |
---|
| 1012 | u_int(n) * ( 1.0_wp - exp_term ) |
---|
| 1013 | particles(n)%speed_y = particles(n)%speed_y * exp_term + & |
---|
| 1014 | v_int(n) * ( 1.0_wp - exp_term ) |
---|
| 1015 | particles(n)%speed_z = particles(n)%speed_z * exp_term + & |
---|
| 1016 | ( w_int(n) - ( 1.0_wp - dens_ratio(n) ) * & |
---|
| 1017 | g / exp_arg ) * ( 1.0_wp - exp_term ) |
---|
| 1018 | ENDIF |
---|
| 1019 | |
---|
| 1020 | ENDIF |
---|
| 1021 | ENDDO |
---|
| 1022 | ENDDO |
---|
| 1023 | |
---|
| 1024 | ELSE |
---|
| 1025 | |
---|
| 1026 | DO nb = 0, 7 |
---|
| 1027 | DO n = start_index(nb), end_index(nb) |
---|
| 1028 | ! |
---|
| 1029 | !-- Transport of particles with inertia |
---|
| 1030 | particles(n)%x = xv(n) + particles(n)%speed_x * dt_particle(n) |
---|
| 1031 | particles(n)%y = yv(n) + particles(n)%speed_y * dt_particle(n) |
---|
| 1032 | particles(n)%z = zv(n) + particles(n)%speed_z * dt_particle(n) |
---|
| 1033 | ! |
---|
[1359] | 1034 | !-- Update of the particle velocity |
---|
| 1035 | IF ( cloud_droplets ) THEN |
---|
[1822] | 1036 | ! |
---|
[2417] | 1037 | !-- Terminal velocity is computed for vertical direction (Rogers et al., |
---|
| 1038 | !-- 1993, J. Appl. Meteorol.) |
---|
[1822] | 1039 | diameter = particles(n)%radius * 2000.0_wp !diameter in mm |
---|
| 1040 | IF ( diameter <= d0_rog ) THEN |
---|
| 1041 | w_s = k_cap_rog * diameter * ( 1.0_wp - EXP( -k_low_rog * diameter ) ) |
---|
| 1042 | ELSE |
---|
| 1043 | w_s = a_rog - b_rog * EXP( -c_rog * diameter ) |
---|
| 1044 | ENDIF |
---|
[1359] | 1045 | |
---|
[1822] | 1046 | ! |
---|
| 1047 | !-- If selected, add random velocities following Soelch and Kaercher |
---|
| 1048 | !-- (2010, Q. J. R. Meteorol. Soc.) |
---|
| 1049 | IF ( use_sgs_for_particles ) THEN |
---|
[2886] | 1050 | lagr_timescale(n) = km(kp,jp,ip) / MAX( e(kp,jp,ip), 1.0E-20_wp ) |
---|
| 1051 | RL = EXP( -1.0_wp * dt_3d / lagr_timescale(n) ) |
---|
[2417] | 1052 | sigma = SQRT( e(kp,jp,ip) ) |
---|
[1822] | 1053 | |
---|
[2417] | 1054 | rg1 = random_gauss( iran_part, 5.0_wp ) - 1.0_wp |
---|
| 1055 | rg2 = random_gauss( iran_part, 5.0_wp ) - 1.0_wp |
---|
| 1056 | rg3 = random_gauss( iran_part, 5.0_wp ) - 1.0_wp |
---|
[1822] | 1057 | |
---|
[2417] | 1058 | particles(n)%rvar1 = RL * particles(n)%rvar1 + & |
---|
| 1059 | SQRT( 1.0_wp - RL**2 ) * sigma * rg1 |
---|
| 1060 | particles(n)%rvar2 = RL * particles(n)%rvar2 + & |
---|
| 1061 | SQRT( 1.0_wp - RL**2 ) * sigma * rg2 |
---|
| 1062 | particles(n)%rvar3 = RL * particles(n)%rvar3 + & |
---|
| 1063 | SQRT( 1.0_wp - RL**2 ) * sigma * rg3 |
---|
[1822] | 1064 | |
---|
[2417] | 1065 | particles(n)%speed_x = u_int(n) + particles(n)%rvar1 |
---|
| 1066 | particles(n)%speed_y = v_int(n) + particles(n)%rvar2 |
---|
| 1067 | particles(n)%speed_z = w_int(n) + particles(n)%rvar3 - w_s |
---|
[1822] | 1068 | ELSE |
---|
[2417] | 1069 | particles(n)%speed_x = u_int(n) |
---|
| 1070 | particles(n)%speed_y = v_int(n) |
---|
| 1071 | particles(n)%speed_z = w_int(n) - w_s |
---|
[1822] | 1072 | ENDIF |
---|
| 1073 | |
---|
[1359] | 1074 | ELSE |
---|
[1822] | 1075 | |
---|
| 1076 | IF ( use_sgs_for_particles ) THEN |
---|
| 1077 | exp_arg = particle_groups(particles(n)%group)%exp_arg |
---|
| 1078 | exp_term = EXP( -exp_arg * dt_particle(n) ) |
---|
| 1079 | ELSE |
---|
| 1080 | exp_arg = particle_groups(particles(n)%group)%exp_arg |
---|
| 1081 | exp_term = particle_groups(particles(n)%group)%exp_term |
---|
| 1082 | ENDIF |
---|
[2417] | 1083 | particles(n)%speed_x = particles(n)%speed_x * exp_term + & |
---|
[1822] | 1084 | u_int(n) * ( 1.0_wp - exp_term ) |
---|
[2417] | 1085 | particles(n)%speed_y = particles(n)%speed_y * exp_term + & |
---|
[1822] | 1086 | v_int(n) * ( 1.0_wp - exp_term ) |
---|
[2417] | 1087 | particles(n)%speed_z = particles(n)%speed_z * exp_term + & |
---|
| 1088 | ( w_int(n) - ( 1.0_wp - dens_ratio(n) ) * g / & |
---|
| 1089 | exp_arg ) * ( 1.0_wp - exp_term ) |
---|
[1359] | 1090 | ENDIF |
---|
[2417] | 1091 | ENDDO |
---|
[1359] | 1092 | ENDDO |
---|
| 1093 | |
---|
[2417] | 1094 | ENDIF |
---|
[1359] | 1095 | |
---|
| 1096 | ! |
---|
[2417] | 1097 | !-- Store the old age of the particle ( needed to prevent that a |
---|
| 1098 | !-- particle crosses several PEs during one timestep, and for the |
---|
| 1099 | !-- evaluation of the subgrid particle velocity fluctuations ) |
---|
| 1100 | particles(1:number_of_particles)%age_m = particles(1:number_of_particles)%age |
---|
| 1101 | |
---|
| 1102 | DO nb = 0, 7 |
---|
| 1103 | DO n = start_index(nb), end_index(nb) |
---|
[1822] | 1104 | ! |
---|
[2417] | 1105 | !-- Increment the particle age and the total time that the particle |
---|
| 1106 | !-- has advanced within the particle timestep procedure |
---|
| 1107 | particles(n)%age = particles(n)%age + dt_particle(n) |
---|
| 1108 | particles(n)%dt_sum = particles(n)%dt_sum + dt_particle(n) |
---|
[1359] | 1109 | |
---|
[1822] | 1110 | ! |
---|
[2417] | 1111 | !-- Check whether there is still a particle that has not yet completed |
---|
| 1112 | !-- the total LES timestep |
---|
| 1113 | IF ( ( dt_3d - particles(n)%dt_sum ) > 1E-8_wp ) THEN |
---|
| 1114 | dt_3d_reached_l = .FALSE. |
---|
[849] | 1115 | ENDIF |
---|
[1822] | 1116 | |
---|
[1359] | 1117 | ENDDO |
---|
[849] | 1118 | ENDDO |
---|
| 1119 | |
---|
[1359] | 1120 | CALL cpu_log( log_point_s(44), 'lpm_advec', 'pause' ) |
---|
[849] | 1121 | |
---|
[1929] | 1122 | |
---|
[849] | 1123 | END SUBROUTINE lpm_advec |
---|
[1929] | 1124 | |
---|
| 1125 | ! Description: |
---|
| 1126 | ! ------------ |
---|
| 1127 | !> Calculation of subgrid-scale particle speed using the stochastic model |
---|
| 1128 | !> of Weil et al. (2004, JAS, 61, 2877-2887). |
---|
| 1129 | !------------------------------------------------------------------------------! |
---|
| 1130 | SUBROUTINE weil_stochastic_eq( v_sgs, fs_n, e_n, dedxi_n, dedt_n, diss_n, & |
---|
| 1131 | dt_n, rg_n, fac ) |
---|
| 1132 | |
---|
| 1133 | USE kinds |
---|
| 1134 | |
---|
| 1135 | USE particle_attributes, & |
---|
| 1136 | ONLY: c_0, sgs_wf_part |
---|
| 1137 | |
---|
| 1138 | IMPLICIT NONE |
---|
| 1139 | |
---|
| 1140 | REAL(wp) :: a1 !< dummy argument |
---|
| 1141 | REAL(wp) :: dedt_n !< time derivative of TKE at particle position |
---|
| 1142 | REAL(wp) :: dedxi_n !< horizontal derivative of TKE at particle position |
---|
| 1143 | REAL(wp) :: diss_n !< dissipation at particle position |
---|
| 1144 | REAL(wp) :: dt_n !< particle timestep |
---|
| 1145 | REAL(wp) :: e_n !< TKE at particle position |
---|
| 1146 | REAL(wp) :: fac !< flag to identify adjacent topography |
---|
| 1147 | REAL(wp) :: fs_n !< weighting factor to prevent that subgrid-scale particle speed becomes too large |
---|
| 1148 | REAL(wp) :: sgs_w !< constant (1/3) |
---|
| 1149 | REAL(wp) :: rg_n !< random number |
---|
| 1150 | REAL(wp) :: term1 !< memory term |
---|
| 1151 | REAL(wp) :: term2 !< drift correction term |
---|
| 1152 | REAL(wp) :: term3 !< random term |
---|
| 1153 | REAL(wp) :: v_sgs !< subgrid-scale velocity component |
---|
| 1154 | |
---|
[2100] | 1155 | !-- At first, limit TKE to a small non-zero number, in order to prevent |
---|
| 1156 | !-- the occurrence of extremely large SGS-velocities in case TKE is zero, |
---|
| 1157 | !-- (could occur at the simulation begin). |
---|
| 1158 | e_n = MAX( e_n, 1E-20_wp ) |
---|
[1929] | 1159 | ! |
---|
| 1160 | !-- Please note, terms 1 and 2 (drift and memory term, respectively) are |
---|
| 1161 | !-- multiplied by a flag to switch of both terms near topography. |
---|
| 1162 | !-- This is necessary, as both terms may cause a subgrid-scale velocity build up |
---|
| 1163 | !-- if particles are trapped in regions with very small TKE, e.g. in narrow street |
---|
| 1164 | !-- canyons resolved by only a few grid points. Hence, term 1 and term 2 are |
---|
| 1165 | !-- disabled if one of the adjacent grid points belongs to topography. |
---|
| 1166 | !-- Moreover, in this case, the previous subgrid-scale component is also set |
---|
| 1167 | !-- to zero. |
---|
| 1168 | |
---|
| 1169 | a1 = fs_n * c_0 * diss_n |
---|
| 1170 | ! |
---|
| 1171 | !-- Memory term |
---|
| 1172 | term1 = - a1 * v_sgs * dt_n / ( 4.0_wp * sgs_wf_part * e_n + 1E-20_wp ) & |
---|
| 1173 | * fac |
---|
| 1174 | ! |
---|
| 1175 | !-- Drift correction term |
---|
| 1176 | term2 = ( ( dedt_n * v_sgs / e_n ) + dedxi_n ) * 0.5_wp * dt_n & |
---|
| 1177 | * fac |
---|
| 1178 | ! |
---|
| 1179 | !-- Random term |
---|
| 1180 | term3 = SQRT( MAX( a1, 1E-20 ) ) * ( rg_n - 1.0_wp ) * SQRT( dt_n ) |
---|
| 1181 | ! |
---|
| 1182 | !-- In cese one of the adjacent grid-boxes belongs to topograhy, the previous |
---|
| 1183 | !-- subgrid-scale velocity component is set to zero, in order to prevent a |
---|
| 1184 | !-- velocity build-up. |
---|
| 1185 | !-- This case, set also previous subgrid-scale component to zero. |
---|
| 1186 | v_sgs = v_sgs * fac + term1 + term2 + term3 |
---|
| 1187 | |
---|
| 1188 | END SUBROUTINE weil_stochastic_eq |
---|