Exemple #1
0
    def test_rop(self):
        fwd_rate_constants = self.store.fwd_rate_constants.copy()
        rev_rate_constants = self.store.rev_rate_constants.copy()
        fwd_rxn_rate = self.store.fwd_rxn_rate.copy()
        rev_rxn_rate = self.store.rev_rxn_rate.copy()
        conc = self.store.concs.copy()

        # create the dictionary for nu values stating if all integer
        allint = {
            'net':
            np.allclose(np.mod(self.store.gas.product_stoich_coeffs(), 1), 0)
            and np.allclose(np.mod(self.store.gas.reactant_stoich_coeffs(), 1),
                            0)
        }

        args = {
            'kf': lambda x: np.array(fwd_rate_constants, order=x, copy=True),
            'kr': lambda x: np.array(rev_rate_constants, order=x, copy=True),
            'conc': lambda x: np.array(conc, order=x, copy=True),
            'rop_fwd': lambda x: np.zeros_like(fwd_rxn_rate, order=x),
            'rop_rev': lambda x: np.zeros_like(rev_rxn_rate, order=x)
        }

        kc = [
            kernel_call('rop_eval_fwd', [fwd_rxn_rate],
                        input_mask=['kr', 'rop_rev'],
                        strict_name_match=True,
                        **args),
            kernel_call('rop_eval_rev', [rev_rxn_rate],
                        input_mask=['kf', 'rop_fwd'],
                        strict_name_match=True,
                        **args)
        ]
        self.__generic_rate_tester(get_rop, kc, allint=allint)
Exemple #2
0
    def test_set_concentrations(self):
        phi = self.store.phi_cp
        P = self.store.P
        V = self.store.V
        ref_ans = self.store.concs.copy()

        # do conp
        args = {
            'phi': lambda x: np.array(phi, order=x, copy=True),
            'P_arr': lambda x: np.array(P, order=x, copy=True),
            'conc': lambda x: np.zeros_like(ref_ans, order=x)
        }

        # create the kernel call
        kc = kernel_call('eval_', ref_ans, **args)
        self.__generic_rate_tester(get_concentrations, kc, conp=True)

        # do conv
        phi = self.store.phi_cv
        args = {
            'phi': lambda x: np.array(phi, order=x, copy=True),
            'V_arr': lambda x: np.array(V, order=x, copy=True),
            'conc': lambda x: np.zeros_like(ref_ans, order=x)
        }

        # create the kernel call
        kc = kernel_call('eval_', ref_ans, **args)
        self.__generic_rate_tester(get_concentrations, kc, conp=False)
Exemple #3
0
    def test_get_extra_var_rates(self):
        dphi = np.zeros_like(self.store.dphi_cp)
        dphi[:, 0] = self.store.conp_temperature_rates[:]
        args = {
            'phi':
            lambda x: np.array(self.store.phi_cp, order=x, copy=True),
            'wdot':
            lambda x: np.array(self.store.species_rates, order=x, copy=True),
            'P_arr':
            lambda x: np.array(self.store.P, order=x, copy=True),
            'dphi':
            lambda x: np.array(dphi, order=x, copy=True)
        }

        kc = [
            kernel_call('get_extra_var_rates', [self.store.dphi_cp],
                        input_mask=['cv', 'u'],
                        compare_mask=[
                            get_comparable((np.array([1], dtype=kint_type), ),
                                           self.store.dphi_cp)
                        ],
                        **args)
        ]

        # test conp
        self.__generic_rate_tester(get_extra_var_rates, kc, conp=True)

        dphi = np.zeros_like(self.store.dphi_cv)
        dphi[:, 0] = self.store.conv_temperature_rates[:]
        args = {
            'phi':
            lambda x: np.array(self.store.phi_cv, order=x, copy=True),
            'wdot':
            lambda x: np.array(self.store.species_rates, order=x, copy=True),
            'dphi':
            lambda x: np.array(dphi, order=x, copy=True)
        }

        # test conv
        kc = [
            kernel_call('get_extra_var_rates', [self.store.dphi_cv],
                        input_mask=['cp', 'h'],
                        compare_mask=[
                            get_comparable((np.array([1], dtype=kint_type), ),
                                           self.store.dphi_cv)
                        ],
                        **args)
        ]
        # test conv
        self.__generic_rate_tester(get_extra_var_rates, kc, conp=False)
Exemple #4
0
    def test_troe_falloff(self):
        phi = self.store.phi_cp
        ref_Pr = self.store.ref_Pr
        ref_ans = self.store.ref_Troe.copy()
        args = {
            'Pr': lambda x: np.array(ref_Pr, order=x, copy=True),
            'phi': lambda x: np.array(phi, order=x, copy=True),
            'Fi': lambda x: np.zeros_like(ref_Pr, order=x),
            'Atroe': lambda x: np.zeros_like(self.store.ref_Troe, order=x),
            'Btroe': lambda x: np.zeros_like(self.store.ref_Troe, order=x),
            'Fcent': lambda x: np.zeros_like(self.store.ref_Troe, order=x)
        }

        # get Troe reaction mask
        troe_mask = np.where(
            np.in1d(self.store.fall_inds, self.store.troe_inds))[0]
        if not troe_mask.size:
            return
        # create the kernel call
        kc = kernel_call(
            'fall_troe',
            ref_ans,
            out_mask=[0],
            compare_mask=[get_comparable((troe_mask, ), ref_ans)],
            ref_ans_compare_mask=[
                get_comparable(
                    (np.arange(self.store.troe_inds.size, dtype=kint_type), ),
                    ref_ans)
            ],
            **args)
        self.__generic_rate_tester(get_troe_kernel, kc)
Exemple #5
0
    def test_sri_falloff(self):
        ref_phi = self.store.phi_cp
        ref_Pr = self.store.ref_Pr
        ref_ans = self.store.ref_Sri.copy()
        args = {
            'Pr': lambda x: np.array(ref_Pr, order=x, copy=True),
            'phi': lambda x: np.array(ref_phi, order=x, copy=True),
            'X': lambda x: np.zeros_like(self.store.ref_Sri, order=x),
            'Fi': lambda x: np.zeros_like(ref_Pr, order=x)
        }

        # get SRI reaction mask
        sri_mask = np.where(np.in1d(self.store.fall_inds,
                                    self.store.sri_inds))[0]
        if not sri_mask.size:
            return
        # create the kernel call
        kc = kernel_call(
            'fall_sri',
            ref_ans,
            out_mask=[0],
            compare_mask=[get_comparable((sri_mask, ), ref_ans)],
            ref_ans_compare_mask=[
                get_comparable(
                    (np.arange(self.store.sri_inds.size, dtype=kint_type), ),
                    ref_ans)
            ],
            **args)
        self.__generic_rate_tester(get_sri_kernel, kc)
Exemple #6
0
    def __test(shape, check_inds=None, check_axes=None, tiling=True):
        # make a dummy array
        arr = np.arange(1, np.prod(shape) + 1).reshape(shape)
        # split
        split_arr = asplit.split_numpy_arrays(arr)[0]

        if check_inds is None:
            assert tiling
            # create the indicies to check
            check_inds = tuple(np.arange(x) for x in shape)
            check_axes = tuple(range(len(shape)))
            ans = arr.flatten(opts.order)
        elif tiling:
            assert check_axes is not None
            assert check_inds is not None
            ans = kernel_call('', arr,
                              check_axes, [check_inds])._get_comparable(
                                  arr, 0, True).flatten(opts.order)
        else:
            slicer = [slice(None)] * arr.ndim
            assert all(check_inds[0].size == ci.size for ci in check_inds[1:])
            for i, ax in enumerate(check_axes):
                slicer[ax] = check_inds[i]
            ans = arr[tuple(slicer)].flatten(opts.order)

        # and compare to the old (unsplit) matrix
        assert np.allclose(
            get_split_elements(split_arr,
                               asplit,
                               arr.shape,
                               check_inds,
                               check_axes,
                               tiling=tiling), ans)
Exemple #7
0
    def test_rev_rates(self):
        ref_fwd_rates = self.store.fwd_rate_constants.copy()
        ref_kc = self.store.equilibrium_constants.copy()
        ref_B = self.store.ref_B_rev.copy()
        ref_rev = self.store.rev_rate_constants.copy()
        args = {
            'b': lambda x: np.array(ref_B, order=x, copy=True),
            'kf': lambda x: np.array(ref_fwd_rates, order=x, copy=True),
            'Kc': lambda x: np.zeros_like(ref_kc, order=x),
            'kr': lambda x: np.zeros_like(ref_rev, order=x)
        }

        # create the dictionary for nu values stating if all integer
        allint = {
            'net':
            np.allclose(
                np.mod(
                    self.store.gas.reactant_stoich_coeffs() -
                    self.store.gas.product_stoich_coeffs(), 1), 0)
        }

        # create the kernel call
        kc = kernel_call('Kc', [ref_kc, ref_rev], out_mask=[0, 1], **args)

        self.__generic_rate_tester(get_rev_rates, kc, allint=allint)
Exemple #8
0
    def test_get_molar_rates(self):
        args = {
            'phi':
            lambda x: np.array(self.store.phi_cp, order=x, copy=True),
            'wdot':
            lambda x: np.array(self.store.species_rates, order=x, copy=True),
            'dphi':
            lambda x: np.zeros_like(self.store.phi_cp, order=x)
        }

        kc = [
            kernel_call(
                'get_molar_rates', [self.store.dphi_cp],
                input_mask=['cv', 'u'],
                compare_mask=[
                    get_comparable(
                        (2 + np.arange(self.store.gas.n_species - 1), ),
                        self.store.dphi_cp)
                ],
                **args)
        ]

        # test conp
        self.__generic_rate_tester(get_molar_rates, kc, conp=True)

        args = {
            'V_arr':
            lambda x: np.array(self.store.V, order=x, copy=True),
            'wdot':
            lambda x: np.array(self.store.species_rates, order=x, copy=True),
            'dphi':
            lambda x: np.zeros_like(self.store.phi_cp, order=x)
        }
        # test conv
        kc = [
            kernel_call(
                'get_molar_rates', [self.store.dphi_cv],
                input_mask=['cp', 'h'],
                compare_mask=[
                    get_comparable(
                        (2 + np.arange(self.store.gas.n_species - 1), ),
                        self.store.dphi_cv)
                ],
                **args)
        ]
        # test conv
        self.__generic_rate_tester(get_molar_rates, kc, conp=False)
Exemple #9
0
    def test_temperature_rates(self):
        args = {
            'wdot':
            lambda x: np.array(
                self.store.species_rates.copy(), order=x, copy=True),
            'conc':
            lambda x: np.array(self.store.concs, order=x, copy=True),
            'cp':
            lambda x: np.array(self.store.spec_cp, order=x, copy=True),
            'h':
            lambda x: np.array(self.store.spec_h, order=x, copy=True),
            'cv':
            lambda x: np.array(self.store.spec_cv, order=x, copy=True),
            'u':
            lambda x: np.array(self.store.spec_u, order=x, copy=True),
            'dphi':
            lambda x: np.zeros_like(self.store.dphi_cp, order=x)
        }

        kc = [
            kernel_call('temperature_rate', [self.store.dphi_cp],
                        input_mask=['cv', 'u'],
                        compare_mask=[
                            get_comparable((np.array([0], dtype=kint_type), ),
                                           self.store.dphi_cp)
                        ],
                        **args)
        ]

        # test conp
        self.__generic_rate_tester(get_temperature_rate, kc, conp=True)

        # test conv
        kc = [
            kernel_call('temperature_rate', [self.store.dphi_cv],
                        input_mask=['cp', 'h'],
                        compare_mask=[
                            get_comparable((np.array([0], dtype=kint_type), ),
                                           self.store.dphi_cv)
                        ],
                        **args)
        ]
        # test conv
        self.__generic_rate_tester(get_temperature_rate, kc, conp=False)
Exemple #10
0
    def test_mass_to_mole_fractions(self):
        # create a hybrid input array
        Yphi = np.concatenate((self.store.T.reshape(
            -1, 1), self.store.V.reshape(-1, 1), self.store.Y[:, :-1]),
                              axis=1)

        args = {
            'phi': lambda x: np.array(Yphi, order=x, copy=True),
            'mw_work': lambda x: np.zeros(self.store.test_size, order=x)
        }

        def __chainer(self, out_vals):
            self.kernel_args['mw_work'] = out_vals[-1][0]

        # first test w/o the splitting
        compare_mask = [
            get_comparable((np.arange(self.store.test_size), ),
                           1. / self.store.mw,
                           compare_axis=(0, ))
        ]
        kc = kernel_call('molecular_weight_inverse', [1. / self.store.mw],
                         strict_name_match=True,
                         compare_axis=(0, ),
                         compare_mask=compare_mask,
                         **args)
        mole_fractions = (
            self.store.mw *
            (self.store.Y[:, :-1] / self.store.gas.molecular_weights[:-1]).T).T
        # create a reference answer of same shape just to simply comparison
        ref_answer = np.concatenate((self.store.T.reshape(
            -1, 1), self.store.V.reshape(-1, 1), mole_fractions),
                                    axis=1)
        compare_mask = [
            get_comparable((np.arange(2, self.store.jac_dim), ), ref_answer)
        ]
        kc2 = kernel_call('mole_fraction', [ref_answer],
                          strict_name_match=True,
                          compare_mask=compare_mask,
                          compare_axis=(1, ),
                          chain=__chainer,
                          **args)
        self.__generic_conversion_tester(mass_to_mole_factions, [kc, kc2])
Exemple #11
0
    def test_reset_arrays(self):
        args = {
            'dphi':
            lambda x: np.array(self.store.dphi_cp, order=x, copy=True),
            'wdot':
            lambda x: np.array(self.store.species_rates, order=x, copy=True)
        }

        kc = [
            kernel_call('ndot_reset', [np.zeros_like(self.store.dphi_cp)],
                        strict_name_match=True,
                        input_mask=['wdot'],
                        **args),
            kernel_call('wdot_reset',
                        [np.zeros_like(self.store.species_rates)],
                        strict_name_match=True,
                        input_mask=['dphi'],
                        **args)
        ]

        # test conp
        self.__generic_rate_tester(reset_arrays, kc)
Exemple #12
0
    def test_pressure_mod(self):
        ref_pres_mod = self.store.ref_pres_mod.copy()
        ref_Pr = self.store.ref_Pr.copy()
        ref_Fi = self.store.ref_Fall.copy()
        ref_thd = self.store.ref_thd.copy()

        args = {
            'Fi': lambda x: np.array(ref_Fi, order=x, copy=True),
            'thd_conc': lambda x: np.array(ref_thd, order=x, copy=True),
            'Pr': lambda x: np.array(ref_Pr, order=x, copy=True),
            'pres_mod': lambda x: np.zeros_like(ref_pres_mod, order=x)
        }

        thd_only_inds = np.where(
            np.logical_not(np.in1d(self.store.thd_inds,
                                   self.store.fall_inds)))[0]
        fall_only_inds = np.where(
            np.in1d(self.store.thd_inds, self.store.fall_inds))[0]

        # create the kernel call
        kc = [
            kernel_call(
                'ci_thd', [ref_pres_mod],
                out_mask=[0],
                compare_mask=[get_comparable((thd_only_inds, ), ref_pres_mod)],
                input_mask=['Fi', 'Pr'],
                strict_name_match=True,
                **args),
            kernel_call('ci_fall', [ref_pres_mod],
                        out_mask=[0],
                        compare_mask=[
                            get_comparable((fall_only_inds, ), ref_pres_mod)
                        ],
                        input_mask=['thd_conc'],
                        strict_name_match=True,
                        **args)
        ]
        self.__generic_rate_tester(get_rxn_pres_mod, kc)
Exemple #13
0
    def test_thd_body_concs(self):
        phi = self.store.phi_cp
        concs = self.store.concs
        P = self.store.P
        ref_ans = self.store.ref_thd.copy()
        args = {
            'conc': lambda x: np.array(concs, order=x, copy=True),
            'phi': lambda x: np.array(phi, order=x, copy=True),
            'P_arr': lambda x: np.array(P, order=x, copy=True),
            'thd_conc': lambda x: np.zeros_like(ref_ans, order=x)
        }

        # create the kernel call
        kc = kernel_call('eval_thd_body_concs', ref_ans, **args)
        self.__generic_rate_tester(get_thd_body_concs, kc)
Exemple #14
0
    def test_reduced_pressure(self):
        phi = self.store.phi_cp.copy()
        ref_thd = self.store.ref_thd.copy()
        ref_ans = self.store.ref_Pr.copy()
        args = {
            'phi': lambda x: np.array(phi, order=x, copy=True),
            'thd_conc': lambda x: np.array(ref_thd, order=x, copy=True),
            'Pr': lambda x: np.zeros_like(ref_ans, order=x)
        }

        wrapper = kf_wrapper(self, get_reduced_pressure_kernel, **args)

        # create the kernel call
        kc = kernel_call('pred', ref_ans, **wrapper.kwargs)
        self.__generic_rate_tester(wrapper, kc, do_ratespec=True)
Exemple #15
0
    def __subtest(self, ref_ans, nicename):
        def __wrapper(opt, namestore, test_size=None, **kwargs):
            return polyfit_kernel_gen(nicename,
                                      opt,
                                      namestore,
                                      test_size=test_size)

        # create args
        args = {
            'phi': lambda x: np.array(self.store.phi_cp, order=x, copy=True),
            nicename: lambda x: np.zeros_like(ref_ans, order=x)
        }
        # create the kernel call
        kc = kernel_call('eval_' + nicename, [ref_ans], **args)

        return _generic_tester(self, __wrapper, [kc], assign_rates)
Exemple #16
0
 def test_lind_falloff(self):
     ref_ans = self.store.ref_Lind.copy()
     # get lindeman reaction mask
     lind_mask = np.where(
         np.in1d(self.store.fall_inds, self.store.lind_inds))[0]
     if not lind_mask.size:
         return
     # need a seperate answer mask to deal with the shape difference
     # in split arrays
     ans_mask = np.arange(self.store.lind_inds.size, dtype=np.int32)
     # create the kernel call
     kc = kernel_call(
         'fall_lind',
         ref_ans,
         compare_mask=[get_comparable((lind_mask, ), ref_ans)],
         ref_ans_compare_mask=[get_comparable((ans_mask, ), ref_ans)])
     self.__generic_rate_tester(get_lind_kernel, kc)
Exemple #17
0
    def test_spec_rates(self):
        args = {
            'rop_net':
            lambda x: np.array(self.store.rxn_rates, order=x, copy=True),
            'wdot': lambda x: np.zeros_like(self.store.species_rates, order=x)
        }
        wdot = self.store.species_rates
        kc = kernel_call(
            'spec_rates', [wdot],
            compare_mask=[
                get_comparable(
                    (np.arange(self.store.gas.n_species, dtype=kint_type), ),
                    wdot)
            ],
            **args)

        # test regularly
        self.__generic_rate_tester(get_spec_rates, kc)
Exemple #18
0
def test_get_comparable_nosplit(ndim, sparse):
    axis_size = 10
    # create array
    arr = np.arange(axis_size**ndim)
    arr = arr.reshape((axis_size, ) * ndim)

    if sparse:
        # set some array elements to zero to sparsify it
        choice = np.sort(np.random.choice(axis_size, 3, replace=False))
        choice1 = np.sort(np.random.choice(axis_size, 3, replace=False))
        for x1 in choice:
            for x2 in choice1:
                arr[:, x1, x2] = 0

    # create comparable object
    for i1, (masks, axes, tiling) in enumerate(compare_patterns(arr.shape)):
        comparable = get_comparable([masks], [arr],
                                    compare_axis=axes,
                                    tiling=tiling)

        namestore = None
        for i2, opts in enumerate(opts_loop(sparse=sparse)):
            kc = kernel_call('', arr, axes, masks)
            outv = arr.copy()
            if sparse and opts.jac_format == JacobianFormat.sparse:
                if csc_matrix is None:
                    raise SkipTest(
                        'Scipy required for sparse Jacobian testing')
                # get the appropriate matrix type
                matrix = csr_matrix if opts.order == 'C' else csc_matrix
                # get the sparse indicies
                matrix = matrix(arr[0, :, :])
                row, col = (matrix.indptr, matrix.indices) if opts.order == 'C' \
                    else (matrix.indices, matrix.indptr)
                # and get the sparse indicies in flat form
                matrix = coo_matrix(arr[0, :, :])
                flat_row, flat_col = matrix.row, matrix.col

                kc.input_args = {}
                kc.input_args['jac'] = arr.copy()
                namestore = type(
                    '', (object, ), {
                        'jac_row_inds': dummy_init(row),
                        'jac_col_inds': dummy_init(col),
                        'flat_jac_row_inds': dummy_init(flat_row),
                        'flat_jac_col_inds': dummy_init(flat_col)
                    })

                # and finally, sparsify array
                outv = sparsify(outv, col, row, opts.order)

            asplit = array_splitter(opts)
            kc.set_state(asplit,
                         order=opts.order,
                         namestore=namestore,
                         jac_format=opts.jac_format)

            outv = asplit.split_numpy_arrays(outv.copy())[0]
            outv = comparable(kc, outv, 0, False)
            ansv = comparable(kc, kc.transformed_ref_ans[0].copy(), 0, True)

            assert np.array_equal(outv, ansv)
Exemple #19
0
    def test_rop_net(self):
        fwd_removed = self.store.fwd_rxn_rate.copy()
        # turn off division by zero warnings temporarily
        hold = np.seterr(divide='ignore', invalid='ignore')
        fwd_removed[:, self.store.
                    thd_inds] = fwd_removed[:, self.store.
                                            thd_inds] / self.store.ref_pres_mod
        thd_in_rev = np.where(np.in1d(self.store.thd_inds,
                                      self.store.rev_inds))[0]
        rev_update_map = np.where(
            np.in1d(self.store.rev_inds, self.store.thd_inds[thd_in_rev]))[0]
        rev_removed = self.store.rev_rxn_rate.copy()
        rev_removed[:,
                    rev_update_map] = rev_removed[:,
                                                  rev_update_map] / self.store.ref_pres_mod[:,
                                                                                            thd_in_rev]
        np.seterr(**hold)

        # remove ref pres mod = 0 (this is a 0 rate)
        fwd_removed[np.where(np.isnan(fwd_removed))] = 0
        rev_removed[np.where(np.isnan(rev_removed))] = 0
        args = {
            'rop_fwd':
            lambda x: np.array(fwd_removed, order=x, copy=True),
            'rop_rev':
            lambda x: np.array(rev_removed, order=x, copy=True),
            'pres_mod':
            lambda x: np.array(self.store.ref_pres_mod, order=x, copy=True),
            'rop_net':
            lambda x: np.zeros_like(self.store.rxn_rates, order=x)
        }

        # first test w/o the splitting
        kc = kernel_call('rop_net', [self.store.rxn_rates], **args)
        self.__generic_rate_tester(get_rop_net, kc)

        def __input_mask(self, arg_name):
            # have to include this so the zero'd array propigates
            if arg_name == 'rop_net':
                return True
            names = ['fwd', 'rev', 'pres_mod']
            return next(x for x in names if x in self.name) in arg_name

        def __chainer(self, out_vals):
            self.kernel_args['rop_net'] = out_vals[-1][0]

        # next test with splitting
        kc = [
            kernel_call('rop_net_fwd', [self.store.rxn_rates],
                        input_mask=__input_mask,
                        strict_name_match=True,
                        check=False,
                        **args),
            kernel_call('rop_net_rev', [self.store.rxn_rates],
                        input_mask=__input_mask,
                        strict_name_match=True,
                        check=False,
                        chain=__chainer,
                        **args),
            kernel_call('rop_net_pres_mod', [self.store.rxn_rates],
                        input_mask=__input_mask,
                        strict_name_match=True,
                        chain=__chainer,
                        **args)
        ]
        self.__generic_rate_tester(get_rop_net, kc, do_ropsplit=True)
Exemple #20
0
    def __test_rateconst_type(self, rtype):
        """
        Performs tests for a single reaction rate type

        Parameters
        ----------
        rtype : {'simple', 'plog', 'cheb'}
            The reaction type to test
        """

        phi = self.store.phi_cp
        P = self.store.P
        ref_const = self.store.fwd_rate_constants if rtype != 'fall' else \
            self.store.fall_rate_constants

        reacs = self.store.reacs

        masks = {
            'simple': (np.array([
                i for i, x in enumerate(reacs)
                if x.match((reaction_type.elementary, reaction_type.fall,
                            reaction_type.chem))
            ]), get_simple_arrhenius_rates),
            'plog': (np.array([
                i for i, x in enumerate(reacs)
                if x.match((reaction_type.plog, ))
            ]), get_plog_arrhenius_rates),
            'cheb': (np.array([
                i for i, x in enumerate(reacs)
                if x.match((reaction_type.cheb, ))
            ]), get_cheb_arrhenius_rates),
            'fall': (np.arange(
                len([
                    i for i, x in enumerate(reacs)
                    if x.match((reaction_type.fall, reaction_type.chem))
                ])), lambda *args, **kwargs: get_simple_arrhenius_rates(
                    *args, falloff=True, **kwargs))
        }

        args = {'phi': lambda x: np.array(phi, order=x, copy=True)}
        if rtype != 'fall':
            args['kf'] = lambda x: np.zeros_like(ref_const, order=x)
        else:
            args['kf_fall'] = lambda x: np.zeros_like(ref_const, order=x)
        if rtype not in ['simple', 'fall']:
            args['P_arr'] = P

        if not masks[rtype][0].size:
            # don't have this type of reaction
            raise SkipTest(
                'Skipping reaction test for {} reactions: not present in'
                'mechanism'.format(rtype))

        kwargs = {}
        if rtype == 'plog':
            kwargs['maxP'] = np.max([
                len(rxn.rates) for rxn in self.store.gas.reactions()
                if isinstance(rxn, ct.PlogReaction)
            ])
        elif rtype == 'cheb':
            kwargs['maxP'] = np.max([
                rxn.nPressure for rxn in self.store.gas.reactions()
                if isinstance(rxn, ct.ChebyshevReaction)
            ])
            kwargs['maxT'] = np.max([
                rxn.nTemperature for rxn in self.store.gas.reactions()
                if isinstance(rxn, ct.ChebyshevReaction)
            ])

        def __simple_post(kc, out):
            if len(out[0].shape) == 3:
                # vectorized data order
                # get the new indicies

                _get_index = indexer(kc.current_split, ref_const.shape)
                inds = _get_index((self.store.thd_inds, ), (1, ))
                pmod_inds = _get_index((np.arange(self.store.thd_inds.size), ),
                                       (1, ))
                # split the pres mod
                pmod, = kc.current_split.split_numpy_arrays(
                    self.store.ref_pres_mod.copy())
                out[0][tuple(inds)] *= pmod[tuple(pmod_inds)]
            else:
                out[0][:, self.store.thd_inds] *= self.store.ref_pres_mod

        compare_mask, rate_func = masks[rtype]
        post = None if rtype not in 'simple' else __simple_post

        # see if mechanism has this type
        if not compare_mask[0].size:
            return

        compare_mask = [get_comparable((compare_mask, ), ref_const)]

        # create the kernel call
        kc = kernel_call(rtype,
                         ref_const,
                         compare_mask=compare_mask,
                         post_process=post,
                         **args)

        self.__generic_rate_tester(rate_func,
                                   kc,
                                   do_ratespec=rtype in ['simple', 'fall'],
                                   **kwargs)