source: palm/trunk/SOURCE/lpm_release_set.f90 @ 1355

Last change on this file since 1355 was 1329, checked in by raasch, 11 years ago

last commit documented

  • Property svn:keywords set to Id
File size: 7.4 KB
Line 
1 SUBROUTINE lpm_release_set
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!
23!
24! Former revisions:
25! -----------------
26! $Id: lpm_release_set.f90 1329 2014-03-21 11:09:15Z heinze $
27!
28! 1327 2014-03-21 11:00:16Z raasch
29! -netcdf output queries
30!
31! 1320 2014-03-20 08:40:49Z raasch
32! ONLY-attribute added to USE-statements,
33! kind-parameters added to all INTEGER and REAL declaration statements,
34! kinds are defined in new module kinds,
35! comment fields (!:) to be used for variable explanations added to
36! all variable declaration statements
37!
38! 1036 2012-10-22 13:43:42Z raasch
39! code put under GPL (PALM 3.9)
40!
41! 849 2012-03-15 10:35:09Z raasch
42! initial revision (former part of advec_particles)
43!
44!
45! Description:
46! ------------
47! Release a new set of particles and, if required, particle tails. These
48! particles/tails are added at the end of the existing arrays. Extend the
49! respective particle and tail arrays, if neccessary.
50!------------------------------------------------------------------------------!
51
52    USE control_parameters,                                                    &
53        ONLY:  iran, message_string, netcdf_data_format
54
55    USE grid_variables,                                                        &
56        ONLY:  dx, dy
57
58    USE indices,                                                               &
59        ONLY:  nxl, nxr, nyn, nys
60
61    USE kinds
62
63    USE particle_attributes,                                                   &
64        ONLY:  initial_particles, iran_part, maximum_number_of_particles,      &
65               maximum_number_of_tails, minimum_tailpoint_distance,            &
66               number_of_initial_particles, number_of_initial_tails,           &
67               number_of_particles, number_of_tails, particles,                &
68               particle_tail_coordinates, pdx, pdy, pdz, psb, psl, psn, psr,   &
69               pss, pst, random_start_position, use_particle_tails
70
71    USE random_function_mod,                                                   &
72        ONLY:  random_function
73
74    IMPLICIT NONE
75
76    INTEGER(iwp) ::  ie     !:
77    INTEGER(iwp) ::  is     !:
78    INTEGER(iwp) ::  n      !:
79    INTEGER(iwp) ::  nn     !:
80
81
82!
83!-- Check, if particle storage must be extended
84    IF ( number_of_particles + number_of_initial_particles > &
85         maximum_number_of_particles  )  THEN
86       IF ( netcdf_data_format < 3 )  THEN
87          message_string = 'maximum_number_of_particles needs to be increa' // &
88                           'sed &but this is not allowed with netcdf_data_' // &
89                           'format < 3'
90          CALL message( 'lpm_release_set', 'PA0146', 2, 2, -1, 6, 1 )
91       ELSE
92          CALL lpm_extend_particle_array( number_of_initial_particles )
93       ENDIF
94    ENDIF
95
96!
97!-- Check, if tail storage must be extended
98    IF ( use_particle_tails )  THEN
99       IF ( number_of_tails + number_of_initial_tails > &
100            maximum_number_of_tails  )  THEN
101          IF ( netcdf_data_format < 3 )  THEN
102             message_string = 'maximum_number_of_tails needs to be increas' // &
103                              'ed &but this is not allowed with netcdf_dat' // &
104                              'a_format < 3'
105             CALL message( 'lpm_release_set', 'PA0147', 2, 2, -1, 6, 1 )
106          ELSE
107             CALL lpm_extend_tail_array( number_of_initial_tails )
108          ENDIF
109       ENDIF
110    ENDIF
111
112    IF ( number_of_initial_particles /= 0 )  THEN
113
114       is = number_of_particles + 1
115       ie = number_of_particles + number_of_initial_particles
116       particles(is:ie) = initial_particles(1:number_of_initial_particles)
117!
118!--    Add random fluctuation to particle positions. Particles should
119!--    remain in the subdomain.
120       IF ( random_start_position )  THEN
121
122          DO  n = is, ie
123
124             IF ( psl(particles(n)%group) /= psr(particles(n)%group) )  THEN
125                particles(n)%x = particles(n)%x +                         &
126                                 ( random_function( iran_part ) - 0.5 ) * &
127                                 pdx(particles(n)%group)
128                IF ( particles(n)%x  <=  ( nxl - 0.5 ) * dx )  THEN
129                   particles(n)%x = ( nxl - 0.4999999999 ) * dx
130                ELSEIF ( particles(n)%x  >=  ( nxr + 0.5 ) * dx )  THEN
131                   particles(n)%x = ( nxr + 0.4999999999 ) * dx
132                ENDIF
133             ENDIF
134
135             IF ( pss(particles(n)%group) /= psn(particles(n)%group) )  THEN
136                particles(n)%y = particles(n)%y +                         &
137                                 ( random_function( iran_part ) - 0.5 ) * &
138                                 pdy(particles(n)%group)
139                IF ( particles(n)%y  <=  ( nys - 0.5 ) * dy )  THEN
140                   particles(n)%y = ( nys - 0.4999999999 ) * dy
141                ELSEIF ( particles(n)%y  >=  ( nyn + 0.5 ) * dy )  THEN
142                   particles(n)%y = ( nyn + 0.4999999999 ) * dy
143                ENDIF
144             ENDIF
145
146             IF ( psb(particles(n)%group) /= pst(particles(n)%group) )  THEN
147                particles(n)%z = particles(n)%z +                         &
148                                 ( random_function( iran_part ) - 0.5 ) * &
149                                 pdz(particles(n)%group)
150             ENDIF
151
152          ENDDO
153
154       ENDIF
155
156!
157!--    Set the beginning of the new particle tails and their age
158       IF ( use_particle_tails )  THEN
159
160          DO  n = is, ie
161!
162!--          New particles which should have a tail, already have got a
163!--          provisional tail id unequal zero (see lpm_init)
164             IF ( particles(n)%tail_id /= 0 )  THEN
165
166                number_of_tails = number_of_tails + 1
167                nn = number_of_tails
168                particles(n)%tail_id = nn   ! set the final tail id
169                particle_tail_coordinates(1,1,nn) = particles(n)%x
170                particle_tail_coordinates(1,2,nn) = particles(n)%y
171                particle_tail_coordinates(1,3,nn) = particles(n)%z
172                particle_tail_coordinates(1,4,nn) = particles(n)%class
173                particles(n)%tailpoints = 1
174
175                IF ( minimum_tailpoint_distance /= 0.0 )  THEN
176                   particle_tail_coordinates(2,1,nn) = particles(n)%x
177                   particle_tail_coordinates(2,2,nn) = particles(n)%y
178                   particle_tail_coordinates(2,3,nn) = particles(n)%z
179                   particle_tail_coordinates(2,4,nn) = particles(n)%class
180                   particle_tail_coordinates(1:2,5,nn) = 0.0
181                   particles(n)%tailpoints = 2
182                ENDIF
183
184             ENDIF
185
186          ENDDO
187
188       ENDIF
189
190       number_of_particles = number_of_particles + number_of_initial_particles
191
192    ENDIF
193
194 END SUBROUTINE lpm_release_set
Note: See TracBrowser for help on using the repository browser.