Example #1
0
def thermo(mech1_str,
           mech2_str,
           temps,
           mech1_csv_str=None,
           mech2_csv_str=None,
           dct_idx='name'):
    """ Read the thermo sections of two CHEMKIN files and
        produce plots of the thermochemical parameters together
    """

    # Build dictionaries containing the thermo data strings for each species
    if dct_idx == 'name':
        mech1_thermo_dct, mech2_thermo_dct = combine.build_thermo_name_dcts(
            mech1_str, mech2_str, temps)
    elif dct_idx == 'inchi':
        mech1_thermo_dct, mech2_thermo_dct = combine.build_thermo_inchi_dcts(
            mech1_str, mech2_str, mech1_csv_str, mech2_csv_str, temps)

    # Combine the two thermo dictionaries together under a common index
    thermo_vals_dct = combine.mechanism_thermo(mech1_thermo_dct,
                                               mech2_thermo_dct)

    # Build list of CHEMKIN mechanism names for plotting
    if dct_idx == 'name':
        names = [key for key in thermo_vals_dct]
    elif dct_idx == 'inchi':
        names = [
            combine.spc_name_from_inchi(mech1_csv_str, mech2_csv_str, key)
            for key in thermo_vals_dct
        ]

    # Plot the data from both mechanisms for each species
    plotter.thermo.build(thermo_vals_dct, temps, names)
Example #2
0
def test__compare_thermo():
    """ test chemkin_io.calculator.combine.mechanism_thermo
    """

    # Build dictionaries containing the thermo data strings for each species
    # Dictionaries indexed by the given mechanism names or InCHI string
    if INDEX == 'name':
        mech1_thermo_dct, mech2_thermo_dct = combine.build_thermo_name_dcts(
            MECH1_STR, MECH2_STR, TEMPS)
    elif INDEX == 'inchi':
        mech1_thermo_dct, mech2_thermo_dct = combine.build_thermo_inchi_dcts(
            MECH1_STR, MECH2_STR, MECH1_CSV_STR, MECH2_CSV_STR, TEMPS)

    print('\nMech1 thermo dct')
    for key, val in mech1_thermo_dct.items():
        print(key)
        print(val)
    print('\n\nMech2 thermo dct')
    for key, val in mech2_thermo_dct.items():
        print(key)
        print(val)

    # Calculate Enthalpy, Entropy, Gibbs, & Heat Capacity for each species
    # Mech 1 and 2 thermo data collated for each species
    thermo_vals_dct = combine.mechanism_thermo(mech1_thermo_dct,
                                               mech2_thermo_dct)

    print('\n\n\nCombined thermo vals')
    for idx in thermo_vals_dct:

        # # Obtain the name of each species to print for ID purposes
        # if INDEX == 'name':
        #     mech1_name = idx
        #     mech2_name = idx
        # elif INDEX == 'inchi':
        #     print('\n\nInChI: ', idx)
        #     mech1_name, mech2_name = combine.mech_name_from_inchi(
        #         MECH1_CSV_STR, MECH2_CSV_STR, idx)
        # print('M1 Name: ', mech1_name)
        # print('M2 Name: ', mech2_name)

        # Print all of the thermo quantities
        mech1_vals = thermo_vals_dct[idx]['mech1']
        mech2_vals = thermo_vals_dct[idx]['mech2']
        print('\nM1 Enthalpy', mech1_vals[0])
        print('M2 Enthalpy', mech2_vals[0])
        print('M1 Heat Capacity', mech1_vals[1])
        print('M2 Heat Capacity', mech2_vals[1])
        print('M1 Entropy', mech1_vals[2])
        print('M2 Entropy', mech2_vals[2])
        print('M1 Gibbs', mech1_vals[3])
        print('M2 Gibbs', mech2_vals[3])

    print('\n\n\n\n\n\n')
    print(thermo_vals_dct)
Example #3
0
def test__compare_rates():
    """ test chemkin_io.mechparser.compare.rates
    """

    # Build dictionaries containing:
    # thermo data strings for each species, k data strings for each reaction
    # Dictionaries indexed by the given mechanism names or InCHI string
    # Build name for test but use inchi

    _, mech2_thermo_dct = combine.build_thermo_name_dcts(
        FAKE1_MECH_STR, FAKE2_MECH_STR, TEMPS)
    mech1_ktp_dct, mech2_ktp_dct = combine.build_reaction_name_dcts(
        FAKE1_MECH_STR, FAKE2_MECH_STR, T_REF, TEMPS, PRESSURES)

    _, mech2_thermo_dct = combine.build_thermo_inchi_dcts(
        FAKE1_MECH_STR, FAKE2_MECH_STR, FAKE_CSV_STR, FAKE_CSV_STR, TEMPS)
    mech1_ktp_dct, mech2_ktp_dct = combine.build_reaction_inchi_dcts(
        FAKE1_MECH_STR, FAKE2_MECH_STR, FAKE_CSV_STR, FAKE_CSV_STR, T_REF,
        TEMPS, PRESSURES)

    print('\nMech1 reaction dct')
    for key, val in mech1_ktp_dct.items():
        print(key)
        print(val)
    print('\n\nMech2 reaction dct')
    for key, val in mech2_ktp_dct.items():
        print(key)
        print(val)

    # Rate constant
    ktp_dct = combine.mechanism_rates(mech1_ktp_dct, mech2_ktp_dct,
                                      mech2_thermo_dct, TEMPS)

    # print dict
    print('\n\nktp dct')
    for rxn, mechs in ktp_dct.items():
        print(rxn)
        mech1, mech2 = mechs['mech1'], mechs['mech2']
        for (pr1, ktp1), (pr2, ktp2) in zip(mech1.items(), mech2.items()):
            print('Pressure: ', pr1, pr2)
            print('Mech1 ks: ', ktp1)
            print('Mech2 ks: ', ktp2)
            print(' ')

    print('\n\nktp dct')
    print(ktp_dct)
Example #4
0
def test__compare_thermo():
    """ test chemkin_io.calculator.combine.mechanism_thermo
    """

    # Build dictionaries containing the thermo data strings for each species
    # Dictionaries indexed by the given mechanism names or InCHI string
    # Build name for test but use inchi
    mech1_thermo_dct, mech2_thermo_dct = combine.build_thermo_name_dcts(
        FAKE1_MECH_STR, FAKE2_MECH_STR, TEMPS)

    mech1_thermo_dct, mech2_thermo_dct = combine.build_thermo_inchi_dcts(
        FAKE1_MECH_STR, FAKE2_MECH_STR,
        FAKE_CSV_STR, FAKE_CSV_STR, TEMPS)

    print('\nMech1 thermo dct')
    for key, val in mech1_thermo_dct.items():
        print(key)
        print(val)
    print('\n\nMech2 thermo dct')
    for key, val in mech2_thermo_dct.items():
        print(key)
        print(val)

    # Calculate Enthalpy, Entropy, Gibbs, & Heat Capacity for each species
    # Mech 1 and 2 thermo data collated for each species
    thermo_vals_dct = combine.mechanism_thermo(
        mech1_thermo_dct, mech2_thermo_dct)

    print('\n\n\nCombined thermo vals')
    for idx in thermo_vals_dct:

        # Print all of the thermo quantities
        print(idx, '\n')
        mech1_vals = thermo_vals_dct[idx]['mech1']
        mech2_vals = thermo_vals_dct[idx]['mech2']
        print('\nM1 Enthalpy', mech1_vals[0])
        print('M2 Enthalpy', mech2_vals[0])
        print('M1 Heat Capacity', mech1_vals[1])
        print('M2 Heat Capacity', mech2_vals[1])
        print('M1 Entropy', mech1_vals[2])
        print('M2 Entropy', mech2_vals[2])
        print('M1 Gibbs', mech1_vals[3])
        print('M2 Gibbs', mech2_vals[3])

    print(thermo_vals_dct)
Example #5
0
def rates(mech1_str,
          mech2_str,
          t_ref,
          temps,
          pressures,
          mech1_csv_str=None,
          mech2_csv_str=None,
          dct_idx='name'):
    """ Read the reaction sections of two CHEMKIN files and
        produce plots of the rate constants together
    """

    # Build dictionaries containing the thermo data strings for each species
    if dct_idx == 'name':
        _, mech2_thermo_dct = combine.build_thermo_name_dcts(
            mech1_str, mech2_str, temps)
        mech1_ktp_dct, mech2_ktp_dct = combine.build_reaction_name_dcts(
            mech1_str, mech2_str, t_ref, temps, pressures)
    elif dct_idx == 'inchi':
        _, mech2_thermo_dct = combine.build_thermo_inchi_dcts(
            mech1_str, mech2_str, mech1_csv_str, mech2_csv_str, temps)
        mech1_ktp_dct, mech2_ktp_dct = combine.build_reaction_inchi_dcts(
            mech1_str, mech2_str, mech1_csv_str, mech2_csv_str, t_ref, temps,
            pressures)

    # Combine the two thermo dictionaries together under a common index
    ktp_dct = combine.mechanism_rates(mech1_ktp_dct, mech2_ktp_dct,
                                      mech2_thermo_dct, temps)

    # Build list of CHEMKIN mechanism names for plotting
    if dct_idx == 'name':
        names = [key for key in ktp_dct]
    # elif dct_idx == 'inchi':
    #     names = [combine.rxn_name_from_inchi(mech1_csv_str, mech2_csv_str, key)
    #              for key in ktp_dct]

    # Plot the data from both mechanisms for each species
    plotter.rates.build(ktp_dct, temps, names)