24 integer,
parameter :: COAG_KERNEL_TYPE_LEN = 20
27 integer,
parameter :: COAG_KERNEL_TYPE_INVALID = 0
29 integer,
parameter :: COAG_KERNEL_TYPE_SEDI = 1
31 integer,
parameter :: COAG_KERNEL_TYPE_ADDITIVE = 2
33 integer,
parameter :: COAG_KERNEL_TYPE_CONSTANT = 3
35 integer,
parameter :: COAG_KERNEL_TYPE_BROWN = 4
37 integer,
parameter :: COAG_KERNEL_TYPE_ZERO = 5
48 integer,
intent(in) :: coag_kernel_type
50 if (coag_kernel_type == coag_kernel_type_invalid)
then
52 elseif (coag_kernel_type == coag_kernel_type_sedi)
then
54 elseif (coag_kernel_type == coag_kernel_type_additive)
then
56 elseif (coag_kernel_type == coag_kernel_type_constant)
then
58 elseif (coag_kernel_type == coag_kernel_type_brown)
then
60 elseif (coag_kernel_type == coag_kernel_type_zero)
then
71 subroutine kernel(coag_kernel_type, aero_particle_1, aero_particle_2, &
72 aero_data, env_state, k)
75 integer,
intent(in) :: coag_kernel_type
85 real(kind=dp),
intent(out) :: k
87 if (coag_kernel_type == coag_kernel_type_sedi)
then
88 call
kernel_sedi(aero_particle_1, aero_particle_2, &
89 aero_data, env_state, k)
90 elseif (coag_kernel_type == coag_kernel_type_additive)
then
92 aero_data, env_state, k)
93 elseif (coag_kernel_type == coag_kernel_type_constant)
then
95 aero_data, env_state, k)
96 elseif (coag_kernel_type == coag_kernel_type_brown)
then
98 aero_data, env_state, k)
99 elseif (coag_kernel_type == coag_kernel_type_zero)
then
100 call
kernel_zero(aero_particle_1, aero_particle_2, &
101 aero_data, env_state, k)
103 call
die_msg(200724934,
"Unknown kernel type: " &
116 integer,
intent(in) :: coag_kernel_type
118 real(kind=dp),
intent(in) :: v1
120 real(kind=dp),
intent(in) :: v2
126 real(kind=dp),
intent(out) :: k_min
128 real(kind=dp),
intent(out) :: k_max
130 if (coag_kernel_type == coag_kernel_type_sedi)
then
132 elseif (coag_kernel_type == coag_kernel_type_additive)
then
134 elseif (coag_kernel_type == coag_kernel_type_constant)
then
136 elseif (coag_kernel_type == coag_kernel_type_brown)
then
138 elseif (coag_kernel_type == coag_kernel_type_zero)
then
141 call
die_msg(330498208,
"Unknown kernel type: " &
152 aero_particle_2, i_class, j_class, ij_class, aero_data, &
153 aero_weight_array, env_state, k)
156 integer,
intent(in) :: coag_kernel_type
162 integer,
intent(in) :: i_class
164 integer,
intent(in) :: j_class
166 integer,
intent(in) :: ij_class
174 real(kind=dp),
intent(out) :: k
176 real(kind=dp) :: unweighted_k, i_r, j_r
178 call
kernel(coag_kernel_type, aero_particle_1, aero_particle_2, &
179 aero_data, env_state, unweighted_k)
183 i_class, j_class, ij_class)
192 subroutine bin_kernel(n_bin, bin_r, aero_data, coag_kernel_type, &
196 integer,
intent(in) :: n_bin
198 real(kind=dp),
intent(in) :: bin_r(n_bin)
202 integer,
intent(in) :: coag_kernel_type
206 real(kind=dp),
intent(out) :: k(n_bin,n_bin)
217 aero_particle_1%vol(1) =
rad2vol(bin_r(i))
218 aero_particle_2%vol(1) =
rad2vol(bin_r(j))
219 call
kernel(coag_kernel_type, aero_particle_1, aero_particle_2, &
220 aero_data, env_state, k(i,j))
234 aero_data, env_state, k_min, k_max)
239 integer,
intent(in) :: coag_kernel_type
245 real(kind=dp),
intent(out) :: k_min(bin_grid%n_bin,bin_grid%n_bin)
247 real(kind=dp),
intent(out) :: k_max(bin_grid%n_bin,bin_grid%n_bin)
251 do i = 1,bin_grid%n_bin
252 do j = 1,bin_grid%n_bin
254 i, j, aero_data, env_state, k_min(i,j), k_max(i,j))
265 b1, b2, aero_data, env_state, k_min, k_max)
270 integer,
intent(in) :: coag_kernel_type
272 integer,
intent(in) :: b1
274 integer,
intent(in) :: b2
280 real(kind=dp),
intent(out) :: k_min
282 real(kind=dp),
intent(out) :: k_max
285 integer,
parameter :: n_sample = 3
287 real(kind=dp),
parameter :: over_scale = 2d0
289 real(kind=dp) :: v1, v2, v1_high, v1_low, v2_high, v2_low
290 real(kind=dp) :: new_k_min, new_k_max
294 v1_low =
rad2vol(bin_grid%edges(b1))
295 v1_high =
rad2vol(bin_grid%edges(b1 + 1))
298 v2_low =
rad2vol(bin_grid%edges(b2))
299 v2_high =
rad2vol(bin_grid%edges(b2 + 1))
306 env_state, new_k_min, new_k_max)
307 if ((i == 1) .and. (j == 1))
then
311 k_min = min(k_min, new_k_min)
312 k_max = max(k_max, new_k_max)
317 k_max = k_max * over_scale
325 i_r, j_r, i_class, j_class, ij_class)
330 real(kind=dp),
intent(in) :: i_r
332 real(kind=dp),
intent(in) :: j_r
334 integer,
intent(in) :: i_class
336 integer,
intent(in) :: j_class
338 integer,
intent(in) :: ij_class
340 real(kind=dp) :: ij_r, i_nc, j_nc, ij_nc, nc_min
349 nc_min = min(i_nc, j_nc, ij_nc)
365 integer,
intent(in) :: i_bin
367 integer,
intent(in) :: j_bin
369 integer,
intent(in) :: i_class
371 integer,
intent(in) :: j_class
373 real(kind=dp) :: i_r, j_r, ij_r, ij_nc_i, ij_nc_j
375 i_r = bin_grid%centers(i_bin)
376 j_r = bin_grid%centers(i_bin)
382 if (ij_nc_i < ij_nc_j)
then
395 i_bin, j_bin, i_class, j_class, ij_class, f_max)
402 integer,
intent(in) :: i_bin
404 integer,
intent(in) :: j_bin
406 integer,
intent(in) :: i_class
408 integer,
intent(in) :: j_class
410 integer,
intent(in) :: ij_class
412 real(kind=dp),
intent(out) :: f_max
414 integer,
parameter :: n_sample = 5
416 real(kind=dp) :: i_r_min, i_r_max, j_r_min, j_r_max, i_r, j_r, f
417 integer :: i_sample, j_sample
419 i_r_min = bin_grid%edges(i_bin)
420 i_r_max = bin_grid%edges(i_bin + 1)
421 j_r_min = bin_grid%edges(j_bin)
422 j_r_max = bin_grid%edges(j_bin + 1)
425 do i_sample = 1,n_sample
426 do j_sample = 1,n_sample
431 f_max = max(f_max, f)
441 subroutine spec_file_read_coag_kernel_type(file, coag_kernel_type)
446 integer,
intent(out) :: coag_kernel_type
448 character(len=SPEC_LINE_MAX_VAR_LEN) :: kernel_name
463 if (trim(kernel_name) ==
'sedi')
then
464 coag_kernel_type = coag_kernel_type_sedi
465 elseif (trim(kernel_name) ==
'additive')
then
466 coag_kernel_type = coag_kernel_type_additive
467 elseif (trim(kernel_name) ==
'constant')
then
468 coag_kernel_type = coag_kernel_type_constant
469 elseif (trim(kernel_name) ==
'brown')
then
470 coag_kernel_type = coag_kernel_type_brown
471 elseif (trim(kernel_name) ==
'zero')
then
472 coag_kernel_type = coag_kernel_type_zero
475 "Unknown coagulation kernel type: " // trim(kernel_name))
478 end subroutine spec_file_read_coag_kernel_type
An input file with extra data for printing messages.
The aero_data_t structure and associated subroutines.
subroutine die_msg(code, error_msg)
Error immediately.
Additive coagulation kernel.
subroutine kernel_additive_minmax(v1, v2, aero_data, env_state, k_min, k_max)
Minimum and maximum values of the additive kernel.
real(kind=dp) elemental function rad2vol(r)
Convert radius (m) to volume (m^3).
subroutine num_conc_weighted_kernel(coag_kernel_type, aero_particle_1, aero_particle_2, i_class, j_class, ij_class, aero_data, aero_weight_array, env_state, k)
Compute the kernel value with the given number concentration weighting.
The aero_weight_t structure and associated subroutines.
subroutine kernel_additive(aero_particle_1, aero_particle_2, aero_data, env_state, k)
Additive coagulation kernel.
The aero_particle_t structure and associated subroutines.
subroutine max_coag_num_conc_factor(aero_weight_array, bin_grid, i_bin, j_bin, i_class, j_class, ij_class, f_max)
Determine the minimum and maximum number concentration factors for coagulation.
subroutine aero_particle_deallocate(aero_particle)
Deallocates memory associated with an aero_particle_t.
The env_state_t structure and associated subroutines.
subroutine aero_particle_allocate_size(aero_particle, n_spec, n_source)
Allocates an aero_particle_t of the given size.
subroutine kernel_constant(aero_particle_1, aero_particle_2, aero_data, env_state, k)
Constant coagulation kernel.
subroutine kernel_minmax(coag_kernel_type, v1, v2, aero_data, env_state, k_min, k_max)
Compute the minimum and maximum coagulation kernel.
elemental real(kind=dp) function aero_particle_radius(aero_particle)
Total radius of the particle (m).
subroutine est_k_minmax_binned_unweighted(bin_grid, coag_kernel_type, aero_data, env_state, k_min, k_max)
Estimate an array of minimum and maximum kernel values. Given particles v1 in bin b1 and v2 in bin b2...
subroutine kernel_zero_minmax(v1, v2, aero_data, env_state, k_min, k_max)
Minimum and maximum of the zero coagulation kernel.
real(kind=dp) function interp_linear_disc(x_1, x_n, n, i)
Linear interpolation over discrete indices.
character(len=coag_kernel_type_len) function coag_kernel_type_to_string(coag_kernel_type)
Return a string representation of a kernel type.
Current environment state.
subroutine est_k_minmax_for_bin_unweighted(bin_grid, coag_kernel_type, b1, b2, aero_data, env_state, k_min, k_max)
Samples within bins b1 and b2 to find the minimum and maximum value of the kernel between particles f...
An array of aerosol size distribution weighting functions.
Gravitational sedimentation coagulation kernel.
subroutine kernel_brown_minmax(v1, v2, aero_data, env_state, k_min, k_max)
Compute the minimum and maximum Brownian coagulation kernel.
real(kind=dp) function aero_weight_array_num_conc_at_radius(aero_weight_array, i_class, radius)
Compute the total number concentration at a given radius (m^3).
Constant coagulation kernel.
subroutine spec_file_read_string(file, name, var)
Read a string from a spec file that must have a given name.
The aero_weight_array_t structure and associated subroutines.
character(len=pmc_util_convert_string_len) function integer_to_string(val)
Convert an integer to a string format.
Single aerosol particle data structure.
1D grid, either logarithmic or linear.
Brownian coagulation kernel.
The bin_grid_t structure and associated subroutines.
integer function coag_dest_class(aero_weight_array, bin_grid, i_bin, j_bin, i_class, j_class)
Determine the weight class in which coagulated particles will be placed.
subroutine kernel(coag_kernel_type, aero_particle_1, aero_particle_2, aero_data, env_state, k)
Evalulate a coagulation kernel function.
subroutine kernel_zero(aero_particle_1, aero_particle_2, aero_data, env_state, k)
Zero coagulation kernel.
subroutine spec_file_die_msg(code, file, msg)
Exit with an error message containing filename and line number.
Constant kernel equal to zero.
subroutine kernel_sedi(aero_particle_1, aero_particle_2, aero_data, env_state, k)
Sedimentation coagulation kernel.
subroutine bin_kernel(n_bin, bin_r, aero_data, coag_kernel_type, env_state, k)
Computes an array of kernel values for each bin pair. k(i,j) is the kernel value at the centers of bi...
real(kind=dp) elemental function vol2rad(v)
Convert volume (m^3) to radius (m).
subroutine kernel_sedi_minmax(v1, v2, aero_data, env_state, k_min, k_max)
Minimum and maximum values of the sedimentation coagulation.
subroutine kernel_constant_minmax(v1, v2, aero_data, env_state, k_min, k_max)
Minimum and maximum values of the constant coagulation kernel.
subroutine kernel_brown(aero_particle_1, aero_particle_2, aero_data, env_state, k)
Compute the Brownian coagulation kernel.
Aerosol material properties and associated data.
real(kind=dp) function coag_num_conc_factor(aero_weight_array, i_r, j_r, i_class, j_class, ij_class)
Coagulation scale factor due to number concentrations.
Generic coagulation kernel.