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

Last change on this file since 1036 was 1036, checked in by raasch, 9 years ago

code has been put under the GNU General Public License (v3)

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