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