PartMC  2.6.1
chamber.F90
Go to the documentation of this file.
1 ! Copyright (C) 2011-2012, 2016-2017 Jian Tian, Matthew West
2 ! Licensed under the GNU General Public License version 2 or (at your
3 ! option) any later version. See the file COPYING for details.
4 
5 !> \file
6 !> The pmc_chamber module.
7 
8 module pmc_chamber
9 
10  use pmc_aero_data
11  use pmc_constants
12  use pmc_env_state
13  use pmc_spec_file
14 
15  !> Unit translational diffusion coefficient (m^2 s^{-1}).
16  real(kind=dp), parameter :: chamber_unit_diff_coef = 1d0
17 
18  type chamber_t
19  !> Chamber volume (m^3).
20  real(kind=dp) :: volume = 0d0
21  !> Diffusional deposition area (m^2).
22  real(kind=dp) :: area_diffuse = 0d0
23  !> Sedimentational deposition area (m^2).
24  real(kind=dp) :: area_sedi = 0d0
25  !> Prefactor in dissusive boundary layer thickness (m).
26  real(kind=dp) :: prefactor_bl = 0d0
27  !> Exponent in dissusive boundary layer thickness.
28  real(kind=dp) :: exponent_bl = 0d0
29  end type chamber_t
30 
31 contains
32 
33 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
34 
35  !> Based on Eq. 23 in Naumann 2003 J. Aerosol. Sci.
36  real(kind=dp) function chamber_diff_coef(vol, aero_data, temp, pressure)
37 
38  !> Particle volume (m^3).
39  real(kind=dp), intent(in) :: vol
40  !> Aerosol data.
41  type(aero_data_t), intent(in) :: aero_data
42  !> Temperature (K).
43  real(kind=dp), intent(in) :: temp
44  !> Pressure (Pa).
45  real(kind=dp), intent(in) :: pressure
46 
47  real(kind=dp) :: r_eff, r_me_c, c
48 
49  r_eff = fractal_vol_to_effective_rad(aero_data%fractal, vol)
50  r_me_c = fractal_vol_to_mobility_rad_in_continuum(aero_data%fractal, vol)
51  c = fractal_slip_correct(r_eff, temp, pressure)
52 
53  chamber_diff_coef = (const%boltzmann * temp * c) &
54  / (6d0 * const%pi * const%air_dyn_visc * r_me_c)
55 
56  end function chamber_diff_coef
57 
58 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
59 
60  !> Calculate diffusional boundary layer thickness.
61  !> Based on Eq. 40 in Naumann 2003 J. Aerosol. Sci.
62  real(kind=dp) function chamber_diff_bl_thick(chamber, vol, aero_data, temp, &
63  pressure)
64 
65  !> Chamber parameters.
66  type(chamber_t) :: chamber
67  !> Particle volume (m^3).
68  real(kind=dp), intent(in) :: vol
69  !> Aerosol data.
70  type(aero_data_t), intent(in) :: aero_data
71  !> Temperature (K).
72  real(kind=dp), intent(in) :: temp
73  !> Pressure (Pa).
74  real(kind=dp), intent(in) :: pressure
75 
76  real(kind=dp) :: d
77 
78  d = chamber_diff_coef(vol, aero_data, temp, pressure)
79 
80  chamber_diff_bl_thick = chamber%prefactor_BL &
81  * (d / chamber_unit_diff_coef)**chamber%exponent_BL
82 
83  end function chamber_diff_bl_thick
84 
85 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
86 
87  !> Calculate the loss rate due to wall diffusion in chamber.
88  !> Based on Eq. 37a in Naumann 2003 J. Aerosol. Sci.
89  real(kind=dp) function chamber_loss_rate_wall(chamber, vol, aero_data, &
90  env_state)
91 
92  !> Chamber parameters.
93  type(chamber_t), intent(in) :: chamber
94  !> Particle volume (m^3).
95  real(kind=dp), intent(in) :: vol
96  !> Aerosol data.
97  type(aero_data_t), intent(in) :: aero_data
98  !> Environment state.
99  type(env_state_t), intent(in) :: env_state
100 
101  real(kind=dp) :: d, delta
102 
103  d = chamber_diff_coef(vol, aero_data, env_state%temp, env_state%pressure)
104  delta = chamber_diff_bl_thick(chamber, vol, aero_data, env_state%temp, &
105  env_state%pressure)
106 
107  chamber_loss_rate_wall = (d * chamber%area_diffuse) &
108  / (delta * chamber%volume)
109 
110  end function chamber_loss_rate_wall
111 
112 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
113 
114  !> Calculate the loss rate due to sedimentation in chamber.
115  !> Based on Eq. 37b in Naumann 2003 J. Aerosol. Sci.
116  real(kind=dp) function chamber_loss_rate_sedi(chamber, vol, density, &
117  aero_data, env_state)
118 
119  !> Chamber parameters.
120  type(chamber_t), intent(in) :: chamber
121  !> Particle volume (m^3).
122  real(kind=dp), intent(in) :: vol
123  !> Particle density (kg/m^3).
124  real(kind=dp), intent(in) :: density
125  !> Aerosol data.
126  type(aero_data_t), intent(in) :: aero_data
127  !> Environment state.
128  type(env_state_t), intent(in) :: env_state
129 
130  real(kind=dp) :: d
131 
132  d = chamber_diff_coef(vol, aero_data, env_state%temp, env_state%pressure)
133 
135  = (density * vol * const%std_grav * d * chamber%area_sedi) &
136  / (const%boltzmann * env_state%temp * chamber%volume)
137 
138  end function chamber_loss_rate_sedi
139 
140 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
141 
142  !> Read chamber specification from a spec file.
143  subroutine spec_file_read_chamber(file, chamber)
144 
145  !> Spec file.
146  type(spec_file_t), intent(inout) :: file
147  !> Chamber data.
148  type(chamber_t), intent(inout) :: chamber
149 
150  !> \page input_format_chamber Input File Format: Chamber
151  !!
152  !! The chamber model is specified by the parameters:
153  !! - \b chamber_vol (real, unit m^3): the volume of the chamber
154  !! - \b area_diffuse (real, unit m^2): the surface area in the chamber
155  !! available for wall diffusion deposition (the total surface area)
156  !! - \b area_sedi (real, unit m^2): the surface area in the chamber
157  !! available for sedimentation deposition (the floor area)
158  !! - \b prefactor_BL (real, unit m): the coefficient \f$k_{\rm D}\f$ in
159  !! the model \f$ \delta = k_{\rm D}(D/D_0)^a \f$ for boundary-layer
160  !! thickness \f$ \delta \f$
161  !! - \b exponent_BL (real, dimensionless): the exponent \f$a\f$ in
162  !! the model \f$ \delta = k_{\rm D}(D/D_0)^a \f$ for boundary-layer
163  !! thickness \f$ \delta \f$
164  !!
165  !! See also:
166  !! - \ref spec_file_format --- the input file text format
167  !! - \ref input_format_scenario --- the prescribed profiles of
168  !! other environment data
169 
170  call spec_file_read_real(file, 'chamber_vol', &
171  chamber%volume)
172  call spec_file_read_real(file, 'area_diffuse', &
173  chamber%area_diffuse)
174  call spec_file_read_real(file, 'area_sedi', &
175  chamber%area_sedi)
176  call spec_file_read_real(file, 'prefactor_BL', &
177  chamber%prefactor_BL)
178  call spec_file_read_real(file, 'exponent_BL', &
179  chamber%exponent_BL)
180 
181  end subroutine spec_file_read_chamber
182 
183 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
184 
185  !> Determines the number of bytes required to pack the given value.
186  integer function pmc_mpi_pack_size_chamber(val)
187 
188  !> Value to pack.
189  type(chamber_t), intent(in) :: val
190 
191  integer :: total_size, i, n
192 
194  pmc_mpi_pack_size_real(val%volume) &
195  + pmc_mpi_pack_size_real(val%area_diffuse) &
196  + pmc_mpi_pack_size_real(val%area_sedi) &
197  + pmc_mpi_pack_size_real(val%prefactor_BL) &
198  + pmc_mpi_pack_size_real(val%exponent_BL)
199 
200  end function pmc_mpi_pack_size_chamber
201 
202 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
203 
204  !> Packs the given value into the buffer, advancing position.
205  subroutine pmc_mpi_pack_chamber(buffer, position, val)
206 
207  !> Memory buffer.
208  character, intent(inout) :: buffer(:)
209  !> Current buffer position.
210  integer, intent(inout) :: position
211  !> Value to pack.
212  type(chamber_t), intent(in) :: val
213 
214 #ifdef PMC_USE_MPI
215  integer :: prev_position, i
216 
217  prev_position = position
218  call pmc_mpi_pack_real(buffer, position, val%volume)
219  call pmc_mpi_pack_real(buffer, position, val%area_diffuse)
220  call pmc_mpi_pack_real(buffer, position, val%area_sedi)
221  call pmc_mpi_pack_real(buffer, position, val%prefactor_BL)
222  call pmc_mpi_pack_real(buffer, position, val%exponent_BL)
223  call assert(623603534, &
224  position - prev_position <= pmc_mpi_pack_size_chamber(val))
225 #endif
226 
227  end subroutine pmc_mpi_pack_chamber
228 
229 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
230 
231  !> Unpacks the given value from the buffer, advancing position.
232  subroutine pmc_mpi_unpack_chamber(buffer, position, val)
233 
234  !> Memory buffer.
235  character, intent(inout) :: buffer(:)
236  !> Current buffer position.
237  integer, intent(inout) :: position
238  !> Value to pack.
239  type(chamber_t), intent(inout) :: val
240 
241 #ifdef PMC_USE_MPI
242  integer :: prev_position, i
243 
244  prev_position = position
245  call pmc_mpi_unpack_real(buffer, position, val%volume)
246  call pmc_mpi_unpack_real(buffer, position, val%area_diffuse)
247  call pmc_mpi_unpack_real(buffer, position, val%area_sedi)
248  call pmc_mpi_unpack_real(buffer, position, val%prefactor_BL)
249  call pmc_mpi_unpack_real(buffer, position, val%exponent_BL)
250  call assert(986998595, &
251  position - prev_position <= pmc_mpi_pack_size_chamber(val))
252 #endif
253 
254  end subroutine pmc_mpi_unpack_chamber
255 
256 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
257 
258 end module pmc_chamber
pmc_chamber::chamber_diff_coef
real(kind=dp) function chamber_diff_coef(vol, aero_data, temp, pressure)
Based on Eq. 23 in Naumann 2003 J. Aerosol. Sci.
Definition: chamber.F90:37
pmc_mpi::pmc_mpi_pack_size_real
integer function pmc_mpi_pack_size_real(val)
Determines the number of bytes required to pack the given value.
Definition: mpi.F90:365
pmc_chamber::pmc_mpi_pack_chamber
subroutine pmc_mpi_pack_chamber(buffer, position, val)
Packs the given value into the buffer, advancing position.
Definition: chamber.F90:206
pmc_constants::dp
integer, parameter dp
Kind of a double precision real number.
Definition: constants.F90:12
pmc_spec_file
Reading formatted text input.
Definition: spec_file.F90:43
pmc_chamber::pmc_mpi_pack_size_chamber
integer function pmc_mpi_pack_size_chamber(val)
Determines the number of bytes required to pack the given value.
Definition: chamber.F90:187
pmc_env_state::env_state_t
Current environment state.
Definition: env_state.F90:29
pmc_mpi::pmc_mpi_pack_real
subroutine pmc_mpi_pack_real(buffer, position, val)
Packs the given value into the buffer, advancing position.
Definition: mpi.F90:586
pmc_util::assert
subroutine assert(code, condition_ok)
Errors unless condition_ok is true.
Definition: util.F90:103
pmc_spec_file::spec_file_t
An input file with extra data for printing messages.
Definition: spec_file.F90:59
pmc_spec_file::spec_file_read_real
subroutine spec_file_read_real(file, name, var)
Read a real number from a spec file that must have the given name.
Definition: spec_file.F90:563
pmc_chamber::pmc_mpi_unpack_chamber
subroutine pmc_mpi_unpack_chamber(buffer, position, val)
Unpacks the given value from the buffer, advancing position.
Definition: chamber.F90:233
pmc_chamber::chamber_t
Definition: chamber.F90:18
pmc_chamber::chamber_diff_bl_thick
real(kind=dp) function chamber_diff_bl_thick(chamber, vol, aero_data, temp, pressure)
Calculate diffusional boundary layer thickness. Based on Eq. 40 in Naumann 2003 J....
Definition: chamber.F90:64
pmc_constants::const
type(const_t), save const
Fixed variable for accessing the constant's values.
Definition: constants.F90:73
pmc_chamber::chamber_loss_rate_sedi
real(kind=dp) function chamber_loss_rate_sedi(chamber, vol, density, aero_data, env_state)
Calculate the loss rate due to sedimentation in chamber. Based on Eq. 37b in Naumann 2003 J....
Definition: chamber.F90:118
pmc_env_state
The env_state_t structure and associated subroutines.
Definition: env_state.F90:9
pmc_aero_data::aero_data_t
Aerosol material properties and associated data.
Definition: aero_data.F90:49
pmc_constants
Physical constants.
Definition: constants.F90:9
pmc_chamber::chamber_unit_diff_coef
real(kind=dp), parameter chamber_unit_diff_coef
Unit translational diffusion coefficient (m^2 s^{-1}).
Definition: chamber.F90:16
pmc_chamber
Definition: chamber.F90:8
pmc_aero_data
The aero_data_t structure and associated subroutines.
Definition: aero_data.F90:9
pmc_chamber::chamber_loss_rate_wall
real(kind=dp) function chamber_loss_rate_wall(chamber, vol, aero_data, env_state)
Calculate the loss rate due to wall diffusion in chamber. Based on Eq. 37a in Naumann 2003 J....
Definition: chamber.F90:91
pmc_mpi::pmc_mpi_unpack_real
subroutine pmc_mpi_unpack_real(buffer, position, val)
Unpacks the given value from the buffer, advancing position.
Definition: mpi.F90:843