181 subroutine initialize(this, chem_spec_data, aero_rep, n_cells)
190 integer(kind=i_kind),
intent(in) :: n_cells
192 type(
property_t),
pointer :: spec_props, b_params
193 character(len=:),
allocatable :: key_name, gas_spec_name, aero_spec_name
194 character(len=:),
allocatable :: phase_name, act_name, error_msg
195 integer(kind=i_kind) :: i_spec, i_aero_rep, n_aero_ids, i_aero_id
196 integer(kind=i_kind) :: i_phase, n_aero_jac_elem, tmp_size
197 type(
string_t),
allocatable :: unique_spec_names(:), unique_act_names(:)
198 integer(kind=i_kind),
allocatable :: phase_ids(:)
199 real(kind=
dp) :: temp_real, n_star
200 logical :: has_act_coeff
203 if (.not.
associated(this%property_set))
call die_msg(382913491, &
204 "Missing property set needed to initialize reaction")
207 key_name =
"gas-phase species"
209 this%property_set%get_string(key_name, gas_spec_name), &
210 "Missing gas-phase species in SIMPOL.1 phase transfer reaction")
213 key_name =
"aerosol phase"
215 this%property_set%get_string(key_name, phase_name), &
216 "Missing aerosol phase in SIMPOL.1 phase-transfer reaction")
219 key_name =
"aerosol-phase species"
221 this%property_set%get_string(key_name, aero_spec_name), &
222 "Missing aerosol-phase species in SIMPOL.1 phase-transfer "// &
226 error_msg =
" for SIMPOL.1 phase transfer of gas species '"// &
227 gas_spec_name//
"' to aerosol-phase species '"// &
228 aero_spec_name//
"' in phase '"//phase_name//
"'"
231 key_name =
"aerosol-phase activity coefficient"
232 has_act_coeff = this%property_set%get_string(key_name, act_name)
235 call assert_msg(260518827,
associated(aero_rep), &
236 "Missing aerosol representation"//error_msg)
237 call assert_msg(590304021,
size(aero_rep).gt.0, &
238 "Missing aerosol representation"//error_msg)
243 do i_aero_rep = 1,
size(aero_rep)
247 unique_spec_names = aero_rep(i_aero_rep)%val%unique_names( &
248 phase_name = phase_name,
spec_name = aero_spec_name)
251 if (.not.
allocated(unique_spec_names)) cycle
254 n_aero_ids = n_aero_ids +
size(unique_spec_names)
258 phase_ids = aero_rep(i_aero_rep)%val%phase_ids(phase_name, is_at_surface=.true.)
259 do i_phase = 1,
size(phase_ids)
260 n_aero_jac_elem = n_aero_jac_elem + &
261 aero_rep(i_aero_rep)%val%num_jac_elem(phase_ids(i_phase))
264 deallocate(unique_spec_names)
269 "Aerosol species not found"//error_msg)
272 allocate(this%condensed_data_int(num_int_prop_ + 2 + n_aero_ids * 13 + &
273 n_aero_jac_elem * 2))
274 allocate(this%condensed_data_real(num_real_prop_ + n_aero_jac_elem * 4))
275 this%condensed_data_int(:) = int(0, kind=
i_kind)
276 this%condensed_data_real(:) = real(0.0, kind=
dp)
279 this%num_env_params = num_env_param_
282 num_aero_phase_ = n_aero_ids
286 chem_spec_data%get_property_set(aero_spec_name, spec_props), &
287 "Missing properties"//error_msg)
290 key_name =
"molecular weight [kg mol-1]"
291 call assert_msg(839930958, spec_props%get_real(key_name, mw_), &
292 "Missing property 'MW'"//error_msg)
298 conv_ =
const%univ_gas_const / mw_ * 1.0e6
302 phase_int_loc_(i_aero_id) = num_int_prop_+12*num_aero_phase_+3
303 phase_real_loc_(i_aero_id) = num_real_prop_+1
304 do i_aero_rep = 1,
size(aero_rep)
308 unique_spec_names = aero_rep(i_aero_rep)%val%unique_names( &
309 phase_name = phase_name,
spec_name = aero_spec_name)
312 if (has_act_coeff)
then
313 unique_act_names = aero_rep(i_aero_rep)%val%unique_names( &
314 phase_name = phase_name,
spec_name = act_name)
315 call assert_msg(236251734,
size(unique_act_names).eq. &
316 size(unique_spec_names), &
317 "Mismatch of SIMPOL species and activity coeffs"// &
322 phase_ids = aero_rep(i_aero_rep)%val%phase_ids(phase_name, is_at_surface=.true.)
326 do i_spec = 1,
size(unique_spec_names)
327 num_aero_phase_jac_elem_(i_aero_id) = &
328 aero_rep(i_aero_rep)%val%num_jac_elem(phase_ids(i_spec))
329 aero_spec_(i_aero_id) = &
330 aero_rep(i_aero_rep)%val%spec_state_id( &
331 unique_spec_names(i_spec)%string)
332 if (has_act_coeff)
then
333 aero_act_id_(i_aero_id) = &
334 aero_rep(i_aero_rep)%val%spec_state_id( &
335 unique_act_names(i_spec)%string)
337 aero_act_id_(i_aero_id) = -1
339 aero_phase_id_(i_aero_id) = phase_ids(i_spec)
340 aero_rep_id_(i_aero_id) = i_aero_rep
341 i_aero_id = i_aero_id + 1
342 if (i_aero_id .le. num_aero_phase_)
then
343 phase_int_loc_(i_aero_id) = phase_int_loc_(i_aero_id - 1) + 1 + &
344 2*num_aero_phase_jac_elem_(i_aero_id - 1)
345 phase_real_loc_(i_aero_id) = phase_real_loc_(i_aero_id - 1) + &
346 4*num_aero_phase_jac_elem_(i_aero_id - 1)
350 deallocate(unique_spec_names)
357 this%property_set%get_property_t(key_name, b_params), &
358 "Missing 'B' parameters"//error_msg)
359 call assert_msg(654885723, b_params%size().eq.4, &
360 "Incorrect number of 'B' parameters"//error_msg)
361 call b_params%iter_reset()
362 call assert_msg(694024883, b_params%get_real(val = b1_), &
363 "Got non-real 'B1' parameter"//error_msg)
364 call b_params%iter_next()
365 call assert_msg(231316411, b_params%get_real(val = b2_), &
366 "Got non-real 'B2' parameter"//error_msg)
367 call b_params%iter_next()
368 call assert_msg(126167907, b_params%get_real(val = b3_), &
369 "Got non-real 'B3' parameter"//error_msg)
370 call b_params%iter_next()
371 call assert_msg(573535753, b_params%get_real(val = b4_), &
372 "Got non-real 'B4' parameter"//error_msg)
375 gas_spec_ = chem_spec_data%gas_state_id(gas_spec_name)
379 "Missing gas-phase species"//error_msg)
383 chem_spec_data%get_property_set(gas_spec_name, spec_props), &
384 "Missing properties for gas-phase species"//error_msg)
394 if (spec_props%get_real(key_name, n_star))
then
396 delta_h_ = real(- 10.0d0*(n_star-1.0d0) + &
397 7.53d0*(n_star**(2.0d0/3.0d0)-1.0d0) - 1.0d0, kind=
dp)
399 delta_s_ = real(- 32.0d0*(n_star-1.0d0) + &
400 9.21d0*(n_star**(2.0d0/3.0d0)-1.0d0) - 1.3d0, kind=
dp)
402 delta_h_ = real(delta_h_ * 4184.0d0, kind=
dp)
403 delta_s_ = real(delta_s_ * 4.184d0, kind=
dp)
405 delta_h_ = real(0.0, kind=
dp)
406 delta_s_ = real(0.0, kind=
dp)
410 key_name =
"diffusion coeff [m2 s-1]"
411 call assert_msg(948176709, spec_props%get_real(key_name, diff_coeff_), &
412 "Missing diffusion coefficient"//error_msg)
415 key_name =
"molecular weight [kg mol-1]"
416 call assert_msg(272813400, spec_props%get_real(key_name, temp_real), &
417 "Missing molecular weight"//error_msg)
418 pre_c_avg_ = sqrt(8.0*
const%univ_gas_const/(
const%pi*temp_real))
421 tmp_size = phase_int_loc_(i_aero_id - 1) + 1 + &
422 2*num_aero_phase_jac_elem_(i_aero_id - 1) - 1
423 call assert_msg(625802519,
size(this%condensed_data_int) .eq. tmp_size, &
424 "int array size mismatch"//error_msg)
425 tmp_size = phase_real_loc_(i_aero_id - 1) + &
426 4*num_aero_phase_jac_elem_(i_aero_id - 1) - 1
427 call assert_msg(391089510,
size(this%condensed_data_real) .eq. tmp_size, &
428 "real array size mismatch"//error_msg)