153 subroutine initialize(this, chem_spec_data, aero_phase, aero_rep, n_cells)
164 integer(kind=i_kind),
intent(in) :: n_cells
166 type(
property_t),
pointer :: spec_props, reactants, products
167 character(len=:),
allocatable :: key_name, spec_name, water_name, &
168 phase_name, temp_string
169 integer(kind=i_kind) :: i_spec, i_phase_inst, i_qty, i_aero_rep, &
170 i_aero_phase, num_spec_per_phase, num_phase, num_react, num_prod
171 type(
string_t),
allocatable :: unique_names(:)
172 type(
string_t),
allocatable :: react_names(:), prod_names(:)
174 integer(kind=i_kind) :: temp_int
175 real(kind=
dp) :: temp_real
176 logical :: is_aqueous
181 call assert_msg(852163263,
associated(this%property_set), &
182 "Missing property set needed to initialize reaction")
185 key_name =
"aerosol phase"
187 this%property_set%get_string(key_name, phase_name), &
188 "Missing aerosol phase in condensed-phase Arrhenius reaction")
191 key_name =
"reactants"
193 this%property_set%get_property_t(key_name, reactants), &
194 "Missing reactant species in condensed-phase Arrhenius reaction")
197 key_name =
"products"
199 this%property_set%get_property_t(key_name, products), &
200 "Missing product species in condensed-phase Arrhenius reaction")
204 call reactants%iter_reset()
208 call assert(428593951, reactants%get_property_t(val=spec_props))
210 if (spec_props%get_int(key_name, temp_int)) &
211 num_react = num_react + temp_int - 1
212 call reactants%iter_next()
213 num_react = num_react + 1
215 num_prod = products%size()
216 num_spec_per_phase = num_prod + num_react
219 call assert_msg(370755392,
associated(aero_rep), &
220 "Missing aerosol representation for condensed-phase "// &
221 "Arrhenius reaction")
222 call assert_msg(483073737,
size(aero_rep).gt.0, &
223 "Missing aerosol representation for condensed-phase "// &
224 "Arrhenius reaction")
228 do i_aero_rep = 1,
size(aero_rep)
229 num_phase = num_phase + &
230 aero_rep(i_aero_rep)%val%num_phase_instances(phase_name)
234 allocate(this%condensed_data_int(num_int_prop_ + &
235 num_phase * (num_spec_per_phase * (num_react + 3) + 1)))
236 allocate(this%condensed_data_real(num_real_prop_ + &
237 num_spec_per_phase + num_prod))
238 this%condensed_data_int(:) = int(0, kind=
i_kind)
239 this%condensed_data_real(:) = real(0.0, kind=
dp)
242 this%num_env_params = num_env_param_
245 num_react_ = num_react
247 num_aero_phase_ = num_phase
251 if (.not. this%property_set%get_real(key_name, a_))
then
254 key_name =
"time unit"
255 if (this%property_set%get_string(key_name, temp_string))
then
256 if (trim(temp_string).eq.
"MIN")
then
259 call assert_msg(390870843, trim(temp_string).eq.
"s", &
260 "Received invalid time unit: '"//temp_string//
"' in "// &
261 "condnesed-phase Arrhenius reaction. Valid units are "// &
266 if (this%property_set%get_real(key_name, temp_real))
then
267 c_ = -temp_real/
const%boltzmann
270 .not.this%property_set%get_real(key_name, temp_real), &
271 "Received both Ea and C parameter for condensed-phase "// &
272 "Arrhenius equation.")
275 if (.not. this%property_set%get_real(key_name, c_))
then
280 if (.not. this%property_set%get_real(key_name, d_))
then
284 if (.not. this%property_set%get_real(key_name, b_))
then
288 if (.not. this%property_set%get_real(key_name, e_))
then
293 allocate(react_names(num_react_))
294 allocate(prod_names(num_prod_))
297 call reactants%iter_reset()
303 chem_spec_data%get_property_set(
spec_name, spec_props), &
304 "Missing properties required for condensed-phase Arrhenius "// &
305 "reaction involving species '"//trim(
spec_name)//
"'")
308 key_name =
"molecular weight [kg mol-1]"
309 call assert_msg(409180731, spec_props%get_real(key_name, temp_real), &
310 "Missing 'molecular weight' for species '"//trim(
spec_name)// &
311 "' in condensed-phase Arrhenius reaction.")
314 call assert(186449575, reactants%get_property_t(val=spec_props))
316 if (.not.spec_props%get_int(key_name, temp_int)) temp_int = 1
317 do i_qty = 1, temp_int
324 kgm3_to_molm3_(i_spec) = 1.0/temp_real
329 call reactants%iter_next()
334 call products%iter_reset()
340 chem_spec_data%get_property_set(
spec_name, spec_props), &
341 "Missing properties required for condensed-phase Arrhenius "// &
342 "reaction involving species '"//trim(
spec_name)//
"'")
348 key_name =
"molecular weight [kg mol-1]"
349 call assert_msg(504705211, spec_props%get_real(key_name, temp_real), &
350 "Missing 'molecular weight' for species '"//trim(
spec_name)// &
351 "' in condensed phase Arrhenius reaction.")
354 kgm3_to_molm3_(num_react_+i_spec) = 1.0/temp_real
357 call assert(846924553, products%get_property_t(val=spec_props))
359 if (spec_props%get_real(key_name, temp_real))
then
360 yield_(i_spec) = temp_real
362 yield_(i_spec) = 1.0d0
369 call products%iter_next()
377 this%property_set%get_string(key_name, temp_string), &
378 "Missing units for condensed-phase Arrhenius reaction.")
379 if (trim(temp_string).eq.
"mol m-3")
then
381 key_name =
"aerosol-phase water"
383 .not.this%property_set%get_string(key_name, temp_string), &
384 "Aerosol-phase water specified for non-aqueous condensed-"// &
385 "phase Arrhenius reaction. Change units to 'M' or remove "// &
386 "aerosol-phase water")
387 else if (trim(temp_string).eq.
"M")
then
389 key_name =
"aerosol-phase water"
391 this%property_set%get_string(key_name, water_name), &
392 "Missing aerosol-phase water for aqeuous condensed-phase "// &
393 "Arrhenius reaction.")
395 call die_msg(161772048,
"Received invalid units for condensed-"// &
396 "phase Arrhenius reaction: '"//temp_string//
"'. Valid "// &
397 "units are 'mol m-3' or 'M'.")
402 do i_aero_rep = 1,
size(aero_rep)
405 num_phase = aero_rep(i_aero_rep)%val%num_phase_instances(phase_name)
406 if (num_phase.eq.0) cycle
414 phase_name = phase_name,
spec_name = water_name)
418 "Missing aerosol-phase water species '"//water_name// &
419 "' in phase '"//phase_name//
"' in aqueous condensed-"// &
420 "phase Arrhenius reacion.")
423 do i_phase_inst = 1, num_phase
424 water_(i_aero_phase + i_phase_inst) = &
425 aero_rep(i_aero_rep)%val%spec_state_id( &
434 do i_phase_inst = 1, num_phase
435 water_(i_aero_phase + i_phase_inst) = -1
441 do i_spec = 1, num_react_
445 phase_name = phase_name,
spec_name = react_names(i_spec)%string)
449 "Incorrect instances of reactant '"// &
450 react_names(i_spec)%string//
"' in phase '"//phase_name// &
451 "' in a condensed-phase Arrhenius reaction")
456 do i_phase_inst = 1, num_phase
457 react_((i_aero_phase+i_phase_inst-1)*num_react_ + i_spec) = &
458 aero_rep(i_aero_rep)%val%spec_state_id( &
467 do i_spec = 1, num_prod_
471 phase_name = phase_name,
spec_name = prod_names(i_spec)%string)
475 "Incorrect instances of product '"// &
476 prod_names(i_spec)%string//
"' in phase '"//phase_name// &
477 "' in a condensed-phase Arrhenius reaction")
482 do i_phase_inst = 1, num_phase
483 prod_((i_aero_phase+i_phase_inst-1)*num_prod_ + i_spec) = &
484 aero_rep(i_aero_rep)%val%spec_state_id( &
493 i_aero_phase = i_aero_phase + num_phase