source: palm/trunk/SOURCE/lpm.f90 @ 1318

Last change on this file since 1318 was 1318, checked in by raasch, 10 years ago

former files/routines cpu_log and cpu_statistics combined to one module,
which also includes the former data module cpulog from the modules-file,
module interfaces removed

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