153 subroutine initialize(this, chem_spec_data, aero_rep, n_cells)
162 integer(kind=i_kind),
intent(in) :: n_cells
164 type(
property_t),
pointer :: spec_props, reactants, products
165 character(len=:),
allocatable :: key_name, spec_name, water_name, &
166 phase_name, temp_string
167 integer(kind=i_kind) :: i_spec, i_phase_inst, i_qty, i_aero_rep, &
168 i_aero_phase, num_spec_per_phase, num_phase, num_react, num_prod
169 type(
string_t),
allocatable :: unique_names(:)
170 type(
string_t),
allocatable :: react_names(:), prod_names(:)
172 integer(kind=i_kind) :: temp_int
173 real(kind=
dp) :: temp_real
174 logical :: is_aqueous
179 call assert_msg(852163263,
associated(this%property_set), &
180 "Missing property set needed to initialize reaction")
183 key_name =
"aerosol phase"
185 this%property_set%get_string(key_name, phase_name), &
186 "Missing aerosol phase in condensed-phase Arrhenius reaction")
189 key_name =
"reactants"
191 this%property_set%get_property_t(key_name, reactants), &
192 "Missing reactant species in condensed-phase Arrhenius reaction")
195 key_name =
"products"
197 this%property_set%get_property_t(key_name, products), &
198 "Missing product species in condensed-phase Arrhenius reaction")
202 call reactants%iter_reset()
206 call assert(428593951, reactants%get_property_t(val=spec_props))
208 if (spec_props%get_int(key_name, temp_int)) &
209 num_react = num_react + temp_int - 1
210 call reactants%iter_next()
211 num_react = num_react + 1
213 num_prod = products%size()
214 num_spec_per_phase = num_prod + num_react
217 call assert_msg(370755392,
associated(aero_rep), &
218 "Missing aerosol representation for condensed-phase "// &
219 "Arrhenius reaction")
220 call assert_msg(483073737,
size(aero_rep).gt.0, &
221 "Missing aerosol representation for condensed-phase "// &
222 "Arrhenius reaction")
226 do i_aero_rep = 1,
size(aero_rep)
227 num_phase = num_phase + &
228 aero_rep(i_aero_rep)%val%num_phase_instances(phase_name)
232 allocate(this%condensed_data_int(num_int_prop_ + &
233 num_phase * (num_spec_per_phase * (num_react + 3) + 1)))
234 allocate(this%condensed_data_real(num_real_prop_ + &
235 num_spec_per_phase + num_prod))
236 this%condensed_data_int(:) = int(0, kind=
i_kind)
237 this%condensed_data_real(:) = real(0.0, kind=
dp)
240 this%num_env_params = num_env_param_
243 num_react_ = num_react
245 num_aero_phase_ = num_phase
249 if (.not. this%property_set%get_real(key_name, a_))
then
252 key_name =
"time unit"
253 if (this%property_set%get_string(key_name, temp_string))
then
254 if (trim(temp_string).eq.
"MIN")
then
257 call assert_msg(390870843, trim(temp_string).eq.
"s", &
258 "Received invalid time unit: '"//temp_string//
"' in "// &
259 "condnesed-phase Arrhenius reaction. Valid units are "// &
264 if (this%property_set%get_real(key_name, temp_real))
then
265 c_ = -temp_real/
const%boltzmann
268 .not.this%property_set%get_real(key_name, temp_real), &
269 "Received both Ea and C parameter for condensed-phase "// &
270 "Arrhenius equation.")
273 if (.not. this%property_set%get_real(key_name, c_))
then
278 if (.not. this%property_set%get_real(key_name, d_))
then
282 if (.not. this%property_set%get_real(key_name, b_))
then
286 if (.not. this%property_set%get_real(key_name, e_))
then
291 allocate(react_names(num_react_))
292 allocate(prod_names(num_prod_))
295 call reactants%iter_reset()
301 chem_spec_data%get_property_set(
spec_name, spec_props), &
302 "Missing properties required for condensed-phase Arrhenius "// &
303 "reaction involving species '"//trim(
spec_name)//
"'")
306 key_name =
"molecular weight [kg mol-1]"
307 call assert_msg(409180731, spec_props%get_real(key_name, temp_real), &
308 "Missing 'molecular weight' for species '"//trim(
spec_name)// &
309 "' in condensed-phase Arrhenius reaction.")
312 call assert(186449575, reactants%get_property_t(val=spec_props))
314 if (.not.spec_props%get_int(key_name, temp_int)) temp_int = 1
315 do i_qty = 1, temp_int
322 kgm3_to_molm3_(i_spec) = 1.0/temp_real
327 call reactants%iter_next()
332 call products%iter_reset()
338 chem_spec_data%get_property_set(
spec_name, spec_props), &
339 "Missing properties required for condensed-phase Arrhenius "// &
340 "reaction involving species '"//trim(
spec_name)//
"'")
346 key_name =
"molecular weight [kg mol-1]"
347 call assert_msg(504705211, spec_props%get_real(key_name, temp_real), &
348 "Missing 'molecular weight' for species '"//trim(
spec_name)// &
349 "' in condensed phase Arrhenius reaction.")
352 kgm3_to_molm3_(num_react_+i_spec) = 1.0/temp_real
355 call assert(846924553, products%get_property_t(val=spec_props))
357 if (spec_props%get_real(key_name, temp_real))
then
358 yield_(i_spec) = temp_real
360 yield_(i_spec) = 1.0d0
367 call products%iter_next()
375 this%property_set%get_string(key_name, temp_string), &
376 "Missing units for condensed-phase Arrhenius reaction.")
377 if (trim(temp_string).eq.
"mol m-3")
then
379 key_name =
"aerosol-phase water"
381 .not.this%property_set%get_string(key_name, temp_string), &
382 "Aerosol-phase water specified for non-aqueous condensed-"// &
383 "phase Arrhenius reaction. Change units to 'M' or remove "// &
384 "aerosol-phase water")
385 else if (trim(temp_string).eq.
"M")
then
387 key_name =
"aerosol-phase water"
389 this%property_set%get_string(key_name, water_name), &
390 "Missing aerosol-phase water for aqeuous condensed-phase "// &
391 "Arrhenius reaction.")
393 call die_msg(161772048,
"Received invalid units for condensed-"// &
394 "phase Arrhenius reaction: '"//temp_string//
"'. Valid "// &
395 "units are 'mol m-3' or 'M'.")
400 do i_aero_rep = 1,
size(aero_rep)
403 num_phase = aero_rep(i_aero_rep)%val%num_phase_instances(phase_name)
404 if (num_phase.eq.0) cycle
412 phase_name = phase_name,
spec_name = water_name)
416 "Missing aerosol-phase water species '"//water_name// &
417 "' in phase '"//phase_name//
"' in aqueous condensed-"// &
418 "phase Arrhenius reacion.")
421 do i_phase_inst = 1, num_phase
422 water_(i_aero_phase + i_phase_inst) = &
423 aero_rep(i_aero_rep)%val%spec_state_id( &
432 do i_phase_inst = 1, num_phase
433 water_(i_aero_phase + i_phase_inst) = -1
439 do i_spec = 1, num_react_
443 phase_name = phase_name,
spec_name = react_names(i_spec)%string)
447 "Incorrect instances of reactant '"// &
448 react_names(i_spec)%string//
"' in phase '"//phase_name// &
449 "' in a condensed-phase Arrhenius reaction")
454 do i_phase_inst = 1, num_phase
455 react_((i_aero_phase+i_phase_inst-1)*num_react_ + i_spec) = &
456 aero_rep(i_aero_rep)%val%spec_state_id( &
465 do i_spec = 1, num_prod_
469 phase_name = phase_name,
spec_name = prod_names(i_spec)%string)
473 "Incorrect instances of product '"// &
474 prod_names(i_spec)%string//
"' in phase '"//phase_name// &
475 "' in a condensed-phase Arrhenius reaction")
480 do i_phase_inst = 1, num_phase
481 prod_((i_aero_phase+i_phase_inst-1)*num_prod_ + i_spec) = &
482 aero_rep(i_aero_rep)%val%spec_state_id( &
491 i_aero_phase = i_aero_phase + num_phase