Esempio n. 1
0
def run(num_procs):
    from spitfire.chemistry.mechanism import ChemicalMechanismSpec
    from spitfire.chemistry.tabulation import build_nonadiabatic_defect_steady_slfm_library
    import spitfire.chemistry.analysis as sca
    import numpy as np

    test_xml = abspath(join('tests', 'test_mechanisms', 'h2-burke.xml'))
    m = ChemicalMechanismSpec(cantera_xml=test_xml, group_name='h2-burke')
    pressure = 101325.
    air = m.stream(stp_air=True)
    air.TP = 1200., pressure
    fuel = m.stream('TPY', (300., pressure, 'H2:1'))

    flamelet_specs = {
        'mech_spec': m,
        'oxy_stream': air,
        'fuel_stream': fuel,
        'grid_points': 34
    }

    l = build_nonadiabatic_defect_steady_slfm_library(
        flamelet_specs,
        verbose=False,
        diss_rate_values=np.logspace(0, 1, 4),
        integration_args={'transient_tolerance': 1e-10},
        num_procs=num_procs)
    l = sca.compute_specific_enthalpy(m, l)
    l = sca.compute_isochoric_specific_heat(m, l)
    l = sca.compute_isobaric_specific_heat(m, l)
    l = sca.compute_density(m, l)
    l = sca.compute_pressure(m, l)
    l = sca.compute_viscosity(m, l)

    return l
Esempio n. 2
0
def run():
    from spitfire.chemistry.mechanism import ChemicalMechanismSpec
    from spitfire.chemistry.tabulation import build_adiabatic_eq_library, apply_mixing_model, PDFSpec
    import spitfire.chemistry.analysis as sca

    test_xml = abspath(join('tests', 'test_mechanisms', 'h2-burke.xml'))
    m = ChemicalMechanismSpec(cantera_xml=test_xml, group_name='h2-burke')
    pressure = 101325.
    air = m.stream(stp_air=True)
    air.TP = 1200., pressure
    fuel = m.stream('TPY', (300., pressure, 'H2:1'))

    flamelet_specs = {
        'mech_spec': m,
        'oxy_stream': air,
        'fuel_stream': fuel,
        'grid_points': 34
    }

    l = build_adiabatic_eq_library(flamelet_specs, verbose=False)
    l = sca.compute_specific_enthalpy(m, l)
    l = sca.compute_isochoric_specific_heat(m, l)
    l = sca.compute_isobaric_specific_heat(m, l)
    l = sca.compute_density(m, l)
    l = sca.compute_pressure(m, l)
    l = sca.compute_viscosity(m, l)
    scaled_variance_values = np.linspace(0., 1., 5)
    l_t = apply_mixing_model(l, {
        'mixture_fraction':
        PDFSpec(pdf='ClipGauss', scaled_variance_values=scaled_variance_values)
    },
                             num_procs=1)
    return l_t
Esempio n. 3
0
def run():
    from spitfire.chemistry.mechanism import ChemicalMechanismSpec
    from spitfire.chemistry.tabulation import build_unreacted_library
    import spitfire.chemistry.analysis as sca

    test_xml = abspath(join('tests', 'test_mechanisms', 'h2-burke.xml'))
    m = ChemicalMechanismSpec(cantera_xml=test_xml, group_name='h2-burke')
    pressure = 101325.
    air = m.stream(stp_air=True)
    air.TP = 1200., pressure
    fuel = m.stream('TPY', (300., pressure, 'H2:1'))

    flamelet_specs = {
        'mech_spec': m,
        'oxy_stream': air,
        'fuel_stream': fuel,
        'grid_points': 34
    }

    l = build_unreacted_library(flamelet_specs, verbose=False)
    l = sca.compute_specific_enthalpy(m, l)
    l = sca.compute_isochoric_specific_heat(m, l)
    l = sca.compute_isobaric_specific_heat(m, l)
    l = sca.compute_density(m, l)
    l = sca.compute_pressure(m, l)
    l = sca.compute_viscosity(m, l)

    return l
def post_processing(configuration, mass_transfer, heat_transfer):
    air = mechanism.stream(stp_air=True)
    fuel = mechanism.stream('X', 'H2:1')

    mix = mechanism.mix_for_equivalence_ratio(1.0, fuel, air)
    mix.TP = 1200., 101325.

    feed = mechanism.copy_stream(mix)

    tau = 1.e-3

    extra_args = dict()
    if mass_transfer == 'open':
        if configuration == 'isobaric':
            extra_args['feed_temperature'] = feed.T
            extra_args['feed_mass_fractions'] = feed.Y
            extra_args['mixing_tau'] = tau
        elif configuration == 'isochoric':
            extra_args['feed_temperature'] = feed.T
            extra_args['feed_mass_fractions'] = feed.Y
            extra_args['feed_density'] = feed.density
            extra_args['mixing_tau'] = tau
    if heat_transfer == 'diathermal':
        extra_args['convection_coefficient'] = 1.
        extra_args['convection_temperature'] = 300.
        extra_args['radiative_emissivity'] = 1.
        extra_args['radiation_temperature'] = 300.
        extra_args['shape_dimension_dict'] = {'shape': 'sphere', 'char. length': 1.e-3}

    try:
        reactor = HomogeneousReactor(mechanism, mix,
                                     configuration=configuration,
                                     heat_transfer=heat_transfer,
                                     mass_transfer=mass_transfer,
                                     **extra_args)

        tol = np.sqrt(np.finfo(float).eps)
        test_success = True

        output_library = reactor.integrate_to_time(1e-16, minimum_time_step_count=0)
        output_library = sca.compute_specific_enthalpy(mechanism, output_library)
        output_library = sca.compute_density(mechanism, output_library)
        output_library = sca.compute_pressure(mechanism, output_library)
        output_library = sca.compute_isobaric_specific_heat(mechanism, output_library)
        output_library = sca.compute_isochoric_specific_heat(mechanism, output_library)
        output_library = sca.explosive_mode_analysis(mechanism, output_library,
                                                     configuration, heat_transfer,
                                                     True, True, True)

        test_success = test_success and np.abs(mix.T - output_library['temperature'][-1]) / mix.T < tol
        test_success = test_success and np.abs(mix.P - output_library['pressure'][-1]) / mix.P < tol
        test_success = test_success and np.abs(mix.density - output_library['density'][-1]) / mix.density < tol
        test_success = test_success and np.abs(mix.enthalpy - output_library['enthalpy'][-1]) / mix.enthalpy_mass < tol
        test_success = test_success and np.abs(mix.cv_mass - output_library['heat capacity cv'][-1]) / mix.cv_mass < tol
        test_success = test_success and np.abs(mix.cp_mass - output_library['heat capacity cp'][-1]) / mix.cp_mass < tol

        return test_success
    except:
        return False