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