109#define DELTA_H_ this%condensed_data_real(1)
110#define DELTA_S_ this%condensed_data_real(2)
111#define DIFF_COEFF_ this%condensed_data_real(3)
112#define PRE_C_AVG_ this%condensed_data_real(4)
113#define A_ this%condensed_data_real(5)
114#define C_ this%condensed_data_real(6)
115#define CONV_ this%condensed_data_real(7)
116#define MW_ this%condensed_data_real(8)
117#define NUM_AERO_PHASE_ this%condensed_data_int(1)
118#define GAS_SPEC_ this%condensed_data_int(2)
119#define NUM_INT_PROP_ 2
120#define NUM_REAL_PROP_ 8
121#define NUM_ENV_PARAM_ 4
122#define DERIV_ID_(x) this%condensed_data_int(NUM_INT_PROP_+x)
123#define JAC_ID_(x) this%condensed_data_int(NUM_INT_PROP_+1+NUM_AERO_PHASE_+x)
124#define PHASE_INT_LOC_(x) this%condensed_data_int(NUM_INT_PROP_+2+6*NUM_AERO_PHASE_+x)
125#define PHASE_REAL_LOC_(x) this%condensed_data_int(NUM_INT_PROP_+2+7*NUM_AERO_PHASE_+x)
126#define AERO_SPEC_(x) this%condensed_data_int(PHASE_INT_LOC_(x))
127#define AERO_WATER_(x) this%condensed_data_int(PHASE_INT_LOC_(x)+1)
128#define AERO_PHASE_ID_(x) this%condensed_data_int(PHASE_INT_LOC_(x)+2)
129#define AERO_REP_ID_(x) this%condensed_data_int(PHASE_INT_LOC_(x)+3)
130#define NUM_AERO_PHASE_JAC_ELEM_(x) this%condensed_data_int(PHASE_INT_LOC_(x)+4)
131#define PHASE_JAC_ID_(x,s,e) this%condensed_data_int(PHASE_INT_LOC_(x)+4+(s-1)*NUM_AERO_PHASE_JAC_ELEM_(x)+e)
132#define SMALL_WATER_CONC_(x) this%condensed_data_real(PHASE_REAL_LOC_(x))
133#define EFF_RAD_JAC_ELEM_(x,e) this%condensed_data_real(PHASE_REAL_LOC_(x)+e)
134#define NUM_CONC_JAC_ELEM_(x,e) this%condensed_data_real(PHASE_REAL_LOC_(x)+NUM_AERO_PHASE_JAC_ELEM_(x)+e)
172 subroutine initialize(this, chem_spec_data, aero_phase, aero_rep, n_cells)
183 integer(kind=i_kind),
intent(in) :: n_cells
186 character(len=:),
allocatable :: key_name, gas_spec_name, &
187 water_name, aero_spec_name, phase_name, error_msg
188 integer(kind=i_kind) :: i_spec, i_aero_rep, n_aero_ids, i_aero_id, &
189 n_aero_jac_elem, i_phase, tmp_size
190 type(
string_t),
allocatable :: unique_spec_names(:), &
191 unique_water_names(:)
192 integer(kind=i_kind),
allocatable :: phase_ids(:)
193 real(kind=
dp) :: temp_real, n_star
196 if (.not.
associated(this%property_set))
call die_msg(318525776, &
197 "Missing property set needed to initialize reaction")
200 key_name =
"gas-phase species"
202 this%property_set%get_string(key_name, gas_spec_name), &
203 "Missing gas-phase species in phase-transfer reaction")
206 key_name =
"aerosol phase"
208 this%property_set%get_string(key_name, phase_name), &
209 "Missing aerosol phase in phase-transfer reaction")
212 key_name =
"aerosol-phase species"
214 this%property_set%get_string(key_name, aero_spec_name), &
215 "Missing aerosol-phase species in phase-transfer reaction")
218 error_msg =
" for HL partitioning reaction of gas-phase species '"// &
219 gas_spec_name//
"' to aerosol-phase species '"// &
220 aero_spec_name//
"' in phase '"//phase_name
223 key_name =
"aerosol-phase water"
225 this%property_set%get_string(key_name, water_name), &
226 "Missing aerosol-phase water"//error_msg)
229 call assert_msg(234155350,
associated(aero_rep), &
230 "Missing aerosol representation"//error_msg)
231 call assert_msg(207961800,
size(aero_rep).gt.0, &
232 "Missing aerosol representation"//error_msg)
238 do i_aero_rep = 1,
size(aero_rep)
242 unique_spec_names = aero_rep(i_aero_rep)%val%unique_names( &
243 phase_name = phase_name,
spec_name = aero_spec_name, &
244 phase_is_at_surface = .true.)
245 unique_water_names = aero_rep(i_aero_rep)%val%unique_names( &
246 phase_name = phase_name,
spec_name = water_name, &
247 phase_is_at_surface = .true.)
250 if (.not.
allocated(unique_spec_names)) cycle
253 call assert_msg(598091463,
size(unique_spec_names).eq. &
254 size(unique_water_names),
"Missing species "// &
255 aero_spec_name//
" or "//water_name//
" in phase "//phase_name// &
256 " or improper implementation of aerosol phase in aerosol "// &
257 "representation"//error_msg)
260 n_aero_ids = n_aero_ids +
size(unique_spec_names)
264 phase_ids = aero_rep(i_aero_rep)%val%phase_ids(phase_name, is_at_surface=.true.)
265 do i_phase = 1,
size(phase_ids)
266 n_aero_jac_elem = n_aero_jac_elem + &
267 aero_rep(i_aero_rep)%val%num_jac_elem(phase_ids(i_phase))
270 deallocate(unique_spec_names)
271 deallocate(unique_water_names)
276 allocate(this%condensed_data_int(num_int_prop_ + 2 + n_aero_ids * 13 + &
277 n_aero_jac_elem * 2))
278 allocate(this%condensed_data_real(num_real_prop_ + n_aero_ids + &
279 n_aero_jac_elem * 2))
280 this%condensed_data_int(:) = int(0, kind=
i_kind)
281 this%condensed_data_real(:) = real(0.0, kind=
dp)
284 this%num_env_params = num_env_param_
287 num_aero_phase_ = n_aero_ids
291 chem_spec_data%get_property_set(aero_spec_name, spec_props), &
292 "Missing aerosol species properties"//error_msg)
295 key_name =
"molecular weight [kg mol-1]"
296 call assert_msg(209812557, spec_props%get_real(key_name, mw_), &
297 "Missing property 'MW' for aerosol species"//error_msg)
301 conv_ =
const%univ_gas_const / mw_ * 1.0e6
304 key_name =
"aerosol-phase water"
306 this%property_set%get_string(key_name, water_name), &
307 "Missing aerosol-phase water"//error_msg)
311 phase_int_loc_(i_aero_id) = num_int_prop_+8*num_aero_phase_+3
312 phase_real_loc_(i_aero_id) = num_real_prop_+1
313 do i_aero_rep = 1,
size(aero_rep)
317 unique_spec_names = aero_rep(i_aero_rep)%val%unique_names( &
318 phase_name = phase_name,
spec_name = aero_spec_name, &
319 phase_is_at_surface = .true.)
320 unique_water_names = aero_rep(i_aero_rep)%val%unique_names( &
321 phase_name = phase_name,
spec_name = water_name, &
322 phase_is_at_surface = .true.)
325 phase_ids = aero_rep(i_aero_rep)%val%phase_ids(phase_name, is_at_surface=.true.)
330 do i_spec = 1,
size(unique_spec_names)
331 num_aero_phase_jac_elem_(i_aero_id) = &
332 aero_rep(i_aero_rep)%val%num_jac_elem(phase_ids(i_spec))
333 aero_spec_(i_aero_id) = &
334 aero_rep(i_aero_rep)%val%spec_state_id( &
335 unique_spec_names(i_spec)%string)
336 aero_water_(i_aero_id) = &
337 aero_rep(i_aero_rep)%val%spec_state_id( &
338 unique_water_names(i_spec)%string)
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) + 5 + &
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) + 1 + &
346 2*num_aero_phase_jac_elem_(i_aero_id - 1)
350 deallocate(unique_spec_names)
351 deallocate(unique_water_names)
356 gas_spec_ = chem_spec_data%gas_state_id(gas_spec_name)
360 "Missing gas-phase species"//error_msg)
364 chem_spec_data%get_property_set(gas_spec_name, spec_props), &
365 "Missing gas-phase species properties"//error_msg)
368 key_name =
"HLC(298K) [M Pa-1]"
369 call assert_msg(637925661, spec_props%get_real(key_name, a_), &
370 "Missing Henry's Law constant at 298 K"//error_msg)
372 key_name =
"HLC exp factor [K]"
373 call assert_msg(801365019, spec_props%get_real(key_name, c_), &
374 "Missing Henry's Law constant exponential factor"// &
385 if (spec_props%get_real(key_name, n_star))
then
387 delta_h_ = real(- 10.0d0*(n_star-1.0d0) + &
388 7.53d0*(n_star**(2.0d0/3.0d0)-1.0d0) - 1.0d0, kind=
dp)
390 delta_s_ = real(- 32.0d0*(n_star-1.0d0) + &
391 9.21d0*(n_star**(2.0d0/3.0d0)-1.0d0) - 1.3d0, kind=
dp)
393 delta_h_ = real(delta_h_ * 4184.0d0, kind=
dp)
394 delta_s_ = real(delta_s_ * 4.184d0, kind=
dp)
396 delta_h_ = real(0.0, kind=
dp)
397 delta_s_ = real(0.0, kind=
dp)
401 key_name =
"diffusion coeff [m2 s-1]"
402 call assert_msg(100205531, spec_props%get_real(key_name, diff_coeff_), &
403 "Missing diffusion coefficient for gas-phase species"//error_msg)
406 key_name =
"molecular weight [kg mol-1]"
407 call assert_msg(469582180, spec_props%get_real(key_name, temp_real), &
408 "Missing molecular weight for gas-phase species"//error_msg)
409 pre_c_avg_ = sqrt(8.0*
const%univ_gas_const/(
const%pi*temp_real))
412 tmp_size = phase_int_loc_(i_aero_id - 1) + 5 + &
413 2*num_aero_phase_jac_elem_(i_aero_id - 1) - 1
414 call assert_msg(881234422,
size(this%condensed_data_int) .eq. tmp_size, &
415 "int array size mismatch"//error_msg)
416 tmp_size = phase_real_loc_(i_aero_id - 1) + 1 + &
417 2*num_aero_phase_jac_elem_(i_aero_id - 1) - 1
418 call assert_msg(520767976,
size(this%condensed_data_real) .eq. tmp_size,&
419 "real array size mismatch"//error_msg)
431 if (
associated(this%property_set)) &
432 deallocate(this%property_set)
433 if (
allocated(this%condensed_data_real)) &
434 deallocate(this%condensed_data_real)
435 if (
allocated(this%condensed_data_int)) &
436 deallocate(this%condensed_data_int)
448 integer(kind=i_kind) :: i
Initialize the aerosol representation data, validating component data and loading any required inform...
Get the non-unique name of a chemical species by its unique name.
Interface for to_string functions.
The abstract aero_phase_data_t structure and associated subroutines.
subroutine finalize_array(this)
Finalize the aerosol phase data.
type(aero_phase_data_t) function, pointer constructor(phase_name, init_size)
Constructor for aero_phase_data_t.
subroutine finalize(this)
Finalize the aerosol phase data.
The abstract aero_rep_data_t structure and associated subroutines.
The camp_state_t structure and associated subroutines.
The chem_spec_data_t structure and associated subroutines.
integer, parameter dp
Kind of a double precision real number.
type(const_t), save const
Fixed variable for accessing the constant's values.
integer, parameter i_kind
Kind of an integer.
The property_t structure and associated subroutines.
The rxn_data_t structure and associated subroutines.
integer(kind=i_kind), parameter, public aero_rxn
Aerosol-phase reaction.
The rxn_HL_phase_transfer_t type and associated functions.
Common utility subroutines.
subroutine assert(code, condition_ok)
Errors unless condition_ok is true.
subroutine die_msg(code, error_msg)
Error immediately.
subroutine assert_msg(code, condition_ok, error_msg)
Errors unless condition_ok is true.
Pointer type for building arrays.
Pointer to aero_rep_data_t extending types.
Abstract reaction data type.
Generic test reaction data type.
String type for building arrays of string of various size.