1 | SUBROUTINE set_particle_attributes |
---|
2 | |
---|
3 | !------------------------------------------------------------------------------! |
---|
4 | ! Current revisions: |
---|
5 | ! ----------------- |
---|
6 | ! |
---|
7 | ! |
---|
8 | ! Former revisions: |
---|
9 | ! ----------------- |
---|
10 | ! $Id: set_particle_attributes.f90 484 2010-02-05 07:36:54Z helmke $ |
---|
11 | ! |
---|
12 | ! 271 2009-03-26 00:47:14Z raasch |
---|
13 | ! Initial version |
---|
14 | ! |
---|
15 | ! Description: |
---|
16 | ! ------------ |
---|
17 | ! This routine sets certain particle attributes depending on the values that |
---|
18 | ! other PALM variables have at the current particle position. |
---|
19 | !------------------------------------------------------------------------------! |
---|
20 | |
---|
21 | USE arrays_3d |
---|
22 | USE control_parameters |
---|
23 | USE cpulog |
---|
24 | USE dvrp_variables |
---|
25 | USE grid_variables |
---|
26 | USE indices |
---|
27 | USE interfaces |
---|
28 | USE particle_attributes |
---|
29 | USE pegrid |
---|
30 | USE statistics |
---|
31 | |
---|
32 | IMPLICIT NONE |
---|
33 | |
---|
34 | INTEGER :: i, j, k, n |
---|
35 | REAL :: aa, absuv, bb, cc, dd, gg, height, pt_int, pt_int_l, pt_int_u, & |
---|
36 | u_int, u_int_l, u_int_u, v_int, v_int_l, v_int_u, w_int, & |
---|
37 | w_int_l, w_int_u, x, y |
---|
38 | |
---|
39 | |
---|
40 | CALL cpu_log( log_point_s(49), 'set_particle_attrib', 'start' ) |
---|
41 | |
---|
42 | ! |
---|
43 | !-- Set particle color |
---|
44 | IF ( particle_color == 'absuv' ) THEN |
---|
45 | |
---|
46 | ! |
---|
47 | !-- Set particle color depending on the absolute value of the horizontal |
---|
48 | !-- velocity |
---|
49 | DO n = 1, number_of_particles |
---|
50 | ! |
---|
51 | !-- Interpolate u velocity-component, determine left, front, bottom |
---|
52 | !-- index of u-array |
---|
53 | i = ( particles(n)%x + 0.5 * dx ) * ddx |
---|
54 | j = particles(n)%y * ddy |
---|
55 | k = ( particles(n)%z + 0.5 * dz * atmos_ocean_sign ) / dz & |
---|
56 | + offset_ocean_nzt ! only exact if equidistant |
---|
57 | |
---|
58 | ! |
---|
59 | !-- Interpolation of the velocity components in the xy-plane |
---|
60 | x = particles(n)%x + ( 0.5 - i ) * dx |
---|
61 | y = particles(n)%y - j * dy |
---|
62 | aa = x**2 + y**2 |
---|
63 | bb = ( dx - x )**2 + y**2 |
---|
64 | cc = x**2 + ( dy - y )**2 |
---|
65 | dd = ( dx - x )**2 + ( dy - y )**2 |
---|
66 | gg = aa + bb + cc + dd |
---|
67 | |
---|
68 | u_int_l = ( ( gg - aa ) * u(k,j,i) + ( gg - bb ) * u(k,j,i+1) & |
---|
69 | + ( gg - cc ) * u(k,j+1,i) + ( gg - dd ) * u(k,j+1,i+1) & |
---|
70 | ) / ( 3.0 * gg ) - u_gtrans |
---|
71 | IF ( k+1 == nzt+1 ) THEN |
---|
72 | u_int = u_int_l |
---|
73 | ELSE |
---|
74 | u_int_u = ( ( gg-aa ) * u(k+1,j,i) + ( gg-bb ) * u(k+1,j,i+1) & |
---|
75 | + ( gg-cc ) * u(k+1,j+1,i) + ( gg-dd ) * u(k+1,j+1,i+1) & |
---|
76 | ) / ( 3.0 * gg ) - u_gtrans |
---|
77 | u_int = u_int_l + ( particles(n)%z - zu(k) ) / dz * & |
---|
78 | ( u_int_u - u_int_l ) |
---|
79 | ENDIF |
---|
80 | |
---|
81 | ! |
---|
82 | !-- Same procedure for interpolation of the v velocity-component (adopt |
---|
83 | !-- index k from u velocity-component) |
---|
84 | i = particles(n)%x * ddx |
---|
85 | j = ( particles(n)%y + 0.5 * dy ) * ddy |
---|
86 | |
---|
87 | x = particles(n)%x - i * dx |
---|
88 | y = particles(n)%y + ( 0.5 - j ) * dy |
---|
89 | aa = x**2 + y**2 |
---|
90 | bb = ( dx - x )**2 + y**2 |
---|
91 | cc = x**2 + ( dy - y )**2 |
---|
92 | dd = ( dx - x )**2 + ( dy - y )**2 |
---|
93 | gg = aa + bb + cc + dd |
---|
94 | |
---|
95 | v_int_l = ( ( gg - aa ) * v(k,j,i) + ( gg - bb ) * v(k,j,i+1) & |
---|
96 | + ( gg - cc ) * v(k,j+1,i) + ( gg - dd ) * v(k,j+1,i+1) & |
---|
97 | ) / ( 3.0 * gg ) - v_gtrans |
---|
98 | IF ( k+1 == nzt+1 ) THEN |
---|
99 | v_int = v_int_l |
---|
100 | ELSE |
---|
101 | v_int_u = ( ( gg-aa ) * v(k+1,j,i) + ( gg-bb ) * v(k+1,j,i+1) & |
---|
102 | + ( gg-cc ) * v(k+1,j+1,i) + ( gg-dd ) * v(k+1,j+1,i+1) & |
---|
103 | ) / ( 3.0 * gg ) - v_gtrans |
---|
104 | v_int = v_int_l + ( particles(n)%z - zu(k) ) / dz * & |
---|
105 | ( v_int_u - v_int_l ) |
---|
106 | ENDIF |
---|
107 | |
---|
108 | absuv = SQRT( u_int**2 + v_int**2 ) |
---|
109 | |
---|
110 | ! |
---|
111 | !-- Limit values by the given interval and normalize to interval [0,1] |
---|
112 | absuv = MIN( absuv, color_interval(2) ) |
---|
113 | absuv = MAX( absuv, color_interval(1) ) |
---|
114 | |
---|
115 | absuv = ( absuv - color_interval(1) ) / & |
---|
116 | ( color_interval(2) - color_interval(1) ) |
---|
117 | |
---|
118 | ! |
---|
119 | !-- Number of available colors is defined in init_dvrp |
---|
120 | particles(n)%color = 1 + absuv * ( dvrp_colortable_entries_prt - 1 ) |
---|
121 | |
---|
122 | ENDDO |
---|
123 | |
---|
124 | ELSEIF ( particle_color == 'pt*' ) THEN |
---|
125 | ! |
---|
126 | !-- Set particle color depending on the resolved scale temperature |
---|
127 | !-- fluctuation. |
---|
128 | !-- First, calculate the horizontal average of the potential temperature |
---|
129 | !-- (This is also done in flow_statistics, but flow_statistics is called |
---|
130 | !-- after this routine.) |
---|
131 | sums_l(:,4,0) = 0.0 |
---|
132 | DO i = nxl, nxr |
---|
133 | DO j = nys, nyn |
---|
134 | DO k = nzb, nzt+1 |
---|
135 | sums_l(k,4,0) = sums_l(k,4,0) + pt(k,j,i) |
---|
136 | ENDDO |
---|
137 | ENDDO |
---|
138 | ENDDO |
---|
139 | |
---|
140 | #if defined( __parallel ) |
---|
141 | |
---|
142 | CALL MPI_ALLREDUCE( sums_l(nzb,4,0), sums(nzb,4), nzt+2-nzb, & |
---|
143 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
144 | |
---|
145 | #else |
---|
146 | |
---|
147 | sums(:,4) = sums_l(:,4,0) |
---|
148 | |
---|
149 | #endif |
---|
150 | |
---|
151 | sums(:,4) = sums(:,4) / ngp_2dh(0) |
---|
152 | |
---|
153 | DO n = 1, number_of_particles |
---|
154 | ! |
---|
155 | !-- Interpolate temperature to the current particle position |
---|
156 | i = particles(n)%x * ddx |
---|
157 | j = particles(n)%y * ddy |
---|
158 | k = ( particles(n)%z + 0.5 * dz * atmos_ocean_sign ) / dz & |
---|
159 | + offset_ocean_nzt ! only exact if equidistant |
---|
160 | |
---|
161 | x = particles(n)%x - i * dx |
---|
162 | y = particles(n)%y - j * dy |
---|
163 | aa = x**2 + y**2 |
---|
164 | bb = ( dx - x )**2 + y**2 |
---|
165 | cc = x**2 + ( dy - y )**2 |
---|
166 | dd = ( dx - x )**2 + ( dy - y )**2 |
---|
167 | gg = aa + bb + cc + dd |
---|
168 | |
---|
169 | pt_int_l = ( ( gg - aa ) * pt(k,j,i) + ( gg - bb ) * pt(k,j,i+1) & |
---|
170 | + ( gg - cc ) * pt(k,j+1,i) + ( gg - dd ) * pt(k,j+1,i+1) & |
---|
171 | ) / ( 3.0 * gg ) - sums(k,4) |
---|
172 | |
---|
173 | pt_int_u = ( ( gg-aa ) * pt(k+1,j,i) + ( gg-bb ) * pt(k+1,j,i+1) & |
---|
174 | + ( gg-cc ) * pt(k+1,j+1,i) + ( gg-dd ) * pt(k+1,j+1,i+1) & |
---|
175 | ) / ( 3.0 * gg ) - sums(k,4) |
---|
176 | |
---|
177 | pt_int = pt_int_l + ( particles(n)%z - zu(k) ) / dz * & |
---|
178 | ( pt_int_u - pt_int_l ) |
---|
179 | |
---|
180 | ! |
---|
181 | !-- Limit values by the given interval and normalize to interval [0,1] |
---|
182 | pt_int = MIN( pt_int, color_interval(2) ) |
---|
183 | pt_int = MAX( pt_int, color_interval(1) ) |
---|
184 | |
---|
185 | pt_int = ( pt_int - color_interval(1) ) / & |
---|
186 | ( color_interval(2) - color_interval(1) ) |
---|
187 | |
---|
188 | ! |
---|
189 | !-- Number of available colors is defined in init_dvrp |
---|
190 | particles(n)%color = 1 + pt_int * ( dvrp_colortable_entries_prt - 1 ) |
---|
191 | |
---|
192 | ENDDO |
---|
193 | |
---|
194 | ELSEIF ( particle_color == 'z' ) THEN |
---|
195 | ! |
---|
196 | !-- Set particle color depending on the height above the bottom |
---|
197 | !-- boundary (z=0) |
---|
198 | DO n = 1, number_of_particles |
---|
199 | |
---|
200 | height = particles(n)%z |
---|
201 | ! |
---|
202 | !-- Limit values by the given interval and normalize to interval [0,1] |
---|
203 | height = MIN( height, color_interval(2) ) |
---|
204 | height = MAX( height, color_interval(1) ) |
---|
205 | |
---|
206 | height = ( height - color_interval(1) ) / & |
---|
207 | ( color_interval(2) - color_interval(1) ) |
---|
208 | |
---|
209 | ! |
---|
210 | !-- Number of available colors is defined in init_dvrp |
---|
211 | particles(n)%color = 1 + height * ( dvrp_colortable_entries_prt - 1 ) |
---|
212 | |
---|
213 | ENDDO |
---|
214 | |
---|
215 | ENDIF |
---|
216 | |
---|
217 | ! |
---|
218 | !-- Set particle size for dvrp graphics |
---|
219 | IF ( particle_dvrpsize == 'absw' ) THEN |
---|
220 | |
---|
221 | DO n = 1, number_of_particles |
---|
222 | ! |
---|
223 | !-- Interpolate w-component to the current particle position |
---|
224 | i = particles(n)%x * ddx |
---|
225 | j = particles(n)%y * ddy |
---|
226 | k = particles(n)%z / dz |
---|
227 | |
---|
228 | x = particles(n)%x - i * dx |
---|
229 | y = particles(n)%y - j * dy |
---|
230 | aa = x**2 + y**2 |
---|
231 | bb = ( dx - x )**2 + y**2 |
---|
232 | cc = x**2 + ( dy - y )**2 |
---|
233 | dd = ( dx - x )**2 + ( dy - y )**2 |
---|
234 | gg = aa + bb + cc + dd |
---|
235 | |
---|
236 | w_int_l = ( ( gg - aa ) * w(k,j,i) + ( gg - bb ) * w(k,j,i+1) & |
---|
237 | + ( gg - cc ) * w(k,j+1,i) + ( gg - dd ) * w(k,j+1,i+1) & |
---|
238 | ) / ( 3.0 * gg ) |
---|
239 | |
---|
240 | IF ( k+1 == nzt+1 ) THEN |
---|
241 | w_int = w_int_l |
---|
242 | ELSE |
---|
243 | w_int_u = ( ( gg-aa ) * w(k+1,j,i) + ( gg-bb ) * w(k+1,j,i+1) & |
---|
244 | + ( gg-cc ) * w(k+1,j+1,i) + ( gg-dd ) * w(k+1,j+1,i+1) & |
---|
245 | ) / ( 3.0 * gg ) |
---|
246 | w_int = w_int_l + ( particles(n)%z - zw(k) ) / dz * & |
---|
247 | ( w_int_u - w_int_l ) |
---|
248 | ENDIF |
---|
249 | |
---|
250 | ! |
---|
251 | !-- Limit values by the given interval and normalize to interval [0,1] |
---|
252 | w_int = ABS( w_int ) |
---|
253 | w_int = MIN( w_int, dvrpsize_interval(2) ) |
---|
254 | w_int = MAX( w_int, dvrpsize_interval(1) ) |
---|
255 | |
---|
256 | w_int = ( w_int - dvrpsize_interval(1) ) / & |
---|
257 | ( dvrpsize_interval(2) - dvrpsize_interval(1) ) |
---|
258 | |
---|
259 | particles(n)%dvrp_psize = ( 0.25 + w_int * 0.6 ) * dx |
---|
260 | |
---|
261 | ENDDO |
---|
262 | |
---|
263 | ENDIF |
---|
264 | |
---|
265 | CALL cpu_log( log_point_s(49), 'set_particle_attrib', 'stop' ) |
---|
266 | |
---|
267 | |
---|
268 | END SUBROUTINE set_particle_attributes |
---|