volcanic/tof.py
def calc_tof(array, dgr, T, coeff, exact=True, verb=0):
    """Function to compute TOF using the energy span model.
    Reproduces results from the AUTOF code (https://doi.org/10.1002/jcc.21669).
    Adapted from the AUTOF implementation with contribution by Pit Steinbach."""

    coeff = np.array(coeff)
    array = np.array(array)
    h = 6.62607015e-34
    k_b = 1.380649e-23
    R = 8.314462618
    n_S = array.size
    n_TS = np.count_nonzero(coeff)
    n_I = np.count_nonzero(coeff == 0)
    if verb > 1:
        print(f"Number of intermediates taken into account is {n_I}")
        print(f"Number of TS taken into account is {n_TS}")
    try:
        assert array.size == coeff.size
    except AssertionError:
        print(
            f"WARNING: The species number {n_S} does not seem to match the identified intermediates ({n_I}) plus TS ({n_TS})."
        )
    X_TOF = np.zeros((n_I, 2))
    matrix_T_I = np.zeros((n_I, 2))
    j = 0
    for i in range(n_S):
        if coeff[i] == 0:
            matrix_T_I[j, 0] = array[i]
            if i < n_S - 1:
                if coeff[i + 1] == 1:
                    matrix_T_I[j, 1] = array[i + 1]
                if coeff[i + 1] == 0:
                    if array[i + 1] > array[i]:
                        matrix_T_I[j, 1] = array[i + 1]
                    else:
                        matrix_T_I[j, 1] = array[i]
                j += 1
            if i == n_S - 1:
                if dgr > array[i]:
                    matrix_T_I[j, 1] = dgr
                else:
                    matrix_T_I[j, 1] = array[i]
    if verb > 3:
        print(f"From profile {array}, \n the reaction step matrix is: \n{matrix_T_I}")
    if exact:
        sum_span = 0
        for i in range(n_I):
            for j in range(n_I):
                if i >= j:
                    sum_span += np.exp(
                        ((matrix_T_I[i, 1] - matrix_T_I[j, 0] - dgr) * 4184) / (R * T)
                    )
                if i < j:
                    sum_span += np.exp(
                        ((matrix_T_I[i, 1] - matrix_T_I[j, 0]) * 4184) / (R * T)
                    )
        TOF = ((k_b * T) / h) * ((np.exp((-dgr * 4184) / (R * T))) / sum_span)
        for i in range(n_I):
            sum_e = 0
            for j in range(n_I):
                if i >= j:
                    sum_e += np.exp(
                        ((matrix_T_I[i, 1] - matrix_T_I[j, 0] - dgr) * 4184) / (R * T)
                    )
                if i < j:
                    sum_e += np.exp(
                        ((matrix_T_I[i, 1] - matrix_T_I[j, 0]) * 4184) / (R * T)
                    )
            X_TOF[i, 1] = np.round(sum_e / sum_span, 4)
        for j in range(n_I):
            sum_e = 0
            for i in range(n_I):
                if i >= j:
                    sum_e += np.exp(
                        ((matrix_T_I[i, 1] - matrix_T_I[j, 0] - dgr) * 4184) / (R * T)
                    )
                if i < j:
                    sum_e += np.exp(
                        ((matrix_T_I[i, 1] - matrix_T_I[j, 0]) * 4184) / (R * T)
                    )
            X_TOF[j, 0] = np.round(sum_e / sum_span, 4)
    else:
        dE = np.zeros((n_I, n_I))
        for i in range(n_I):
            for j in range(n_I):
                if i >= j:
                    dE[i, j] = matrix_T_I[i, 1] - matrix_T_I[j, 0]
                if i < j:
                    dE[i, j] = matrix_T_I[i, 1] - matrix_T_I[j, 0] + dgr
        Energy_Span = np.amax(dE)
        if verb > 2:
            print(f"Energy Span computed : {Energy_Span} kcal/mol.")
        TOF = ((k_b * T) / h) * np.exp((-(Energy_Span * 4184) / (R * T)))
        if verb > 2:
            print(f"TOF computed : {TOF} s^-1.")
        i, j = np.unravel_index(np.argmax(dE, axis=None), dE.shape)
        X_TOF[i, 1] = 1.0
        X_TOF[j, 0] = 1.0
    return TOF, X_TOF
Function to compute TOF using the energy span model.
    Reproduces results from the AUTOF code (https://doi.org/10.1002/jcc.21669).
    Adapted from the AUTOF implementation with contribution by Pit Steinbach.
Function to compute TOF using the energy span model.
Reproduces results from the AUTOF code .
Adapted from the AUTOF implementation with contribution by Pit Steinbach.
Function to compute TOF using the energy span model . Reproduces results from the AUTOF code . Adapted from the AUTOF implementation with contribution by Pit Steinbach .
def calc_tof(array, dgr, T, coeff, exact=True, verb=0):
    coeff = np.array(coeff)
    array = np.array(array)
    h = 6.62607015e-34
    k_b = 1.380649e-23
    R = 8.314462618
    n_S = array.size
    n_TS = np.count_nonzero(coeff)
    n_I = np.count_nonzero(coeff == 0)
    if verb > 1:
        print(f"Number of intermediates taken into account is {n_I}")
        print(f"Number of TS taken into account is {n_TS}")
    try:
        assert array.size == coeff.size
    except AssertionError:
        print(
            f"WARNING: The species number {n_S} does not seem to match the identified intermediates ({n_I}) plus TS ({n_TS})."
        )
    X_TOF = np.zeros((n_I, 2))
    matrix_T_I = np.zeros((n_I, 2))
    j = 0
    for i in range(n_S):
        if coeff[i] == 0:
            matrix_T_I[j, 0] = array[i]
            if i < n_S - 1:
                if coeff[i + 1] == 1:
                    matrix_T_I[j, 1] = array[i + 1]
                if coeff[i + 1] == 0:
                    if array[i + 1] > array[i]:
                        matrix_T_I[j, 1] = array[i + 1]
                    else:
                        matrix_T_I[j, 1] = array[i]
                j += 1
            if i == n_S - 1:
                if dgr > array[i]:
                    matrix_T_I[j, 1] = dgr
                else:
                    matrix_T_I[j, 1] = array[i]
    if verb > 3:
        print(f"From profile {array}, \n the reaction step matrix is: \n{matrix_T_I}")
    if exact:
        sum_span = 0
        for i in range(n_I):
            for j in range(n_I):
                if i >= j:
                    sum_span += np.exp(
                        ((matrix_T_I[i, 1] - matrix_T_I[j, 0] - dgr) * 4184) / (R * T)
                    )
                if i < j:
                    sum_span += np.exp(
                        ((matrix_T_I[i, 1] - matrix_T_I[j, 0]) * 4184) / (R * T)
                    )
        TOF = ((k_b * T) / h) * ((np.exp((-dgr * 4184) / (R * T))) / sum_span)
        for i in range(n_I):
            sum_e = 0
            for j in range(n_I):
                if i >= j:
                    sum_e += np.exp(
                        ((matrix_T_I[i, 1] - matrix_T_I[j, 0] - dgr) * 4184) / (R * T)
                    )
                if i < j:
                    sum_e += np.exp(
                        ((matrix_T_I[i, 1] - matrix_T_I[j, 0]) * 4184) / (R * T)
                    )
            X_TOF[i, 1] = np.round(sum_e / sum_span, 4)
        for j in range(n_I):
            sum_e = 0
            for i in range(n_I):
                if i >= j:
                    sum_e += np.exp(
                        ((matrix_T_I[i, 1] - matrix_T_I[j, 0] - dgr) * 4184) / (R * T)
                    )
                if i < j:
                    sum_e += np.exp(
                        ((matrix_T_I[i, 1] - matrix_T_I[j, 0]) * 4184) / (R * T)
                    )
            X_TOF[j, 0] = np.round(sum_e / sum_span, 4)
    else:
        dE = np.zeros((n_I, n_I))
        for i in range(n_I):
            for j in range(n_I):
                if i >= j:
                    dE[i, j] = matrix_T_I[i, 1] - matrix_T_I[j, 0]
                if i < j:
                    dE[i, j] = matrix_T_I[i, 1] - matrix_T_I[j, 0] + dgr
        Energy_Span = np.amax(dE)
        if verb > 2:
            print(f"Energy Span computed : {Energy_Span} kcal/mol.")
        TOF = ((k_b * T) / h) * np.exp((-(Energy_Span * 4184) / (R * T)))
        if verb > 2:
            print(f"TOF computed : {TOF} s^-1.")
        i, j = np.unravel_index(np.argmax(dE, axis=None), dE.shape)
        X_TOF[i, 1] = 1.0
        X_TOF[j, 0] = 1.0
    return TOF, X_TOF
def calc_tof ( array , dgr , T , coeff , exact = True , verb = 0 ) : coeff = np . array ( coeff ) array = np . array ( array ) h = 6.62607015e-34 k_b = 1.380649e-23 R = 8.314462618 n_S = array . size n_TS = np . count_nonzero ( coeff ) n_I = np . count_nonzero ( coeff == 0 ) if verb > 1 : print ( f"Number of intermediates taken into account is {n_I}" ) print ( f"Number of TS taken into account is {n_TS}" ) try : assert array . size == coeff . size except AssertionError : print ( f"WARNING: The species number {n_S} does not seem to match the identified intermediates ({n_I}) plus TS ({n_TS})." ) X_TOF = np . zeros ( ( n_I , 2 ) ) matrix_T_I = np . zeros ( ( n_I , 2 ) ) j = 0 for i in range ( n_S ) : if coeff [ i ] == 0 : matrix_T_I [ j , 0 ] = array [ i ] if i < n_S - 1 : if coeff [ i + 1 ] == 1 : matrix_T_I [ j , 1 ] = array [ i + 1 ] if coeff [ i + 1 ] == 0 : if array [ i + 1 ] > array [ i ] : matrix_T_I [ j , 1 ] = array [ i + 1 ] else : matrix_T_I [ j , 1 ] = array [ i ] j += 1 if i == n_S - 1 : if dgr > array [ i ] : matrix_T_I [ j , 1 ] = dgr else : matrix_T_I [ j , 1 ] = array [ i ] if verb > 3 : print ( f"From profile {array}, \n the reaction step matrix is: \n{matrix_T_I}" ) if exact : sum_span = 0 for i in range ( n_I ) : for j in range ( n_I ) : if i >= j : sum_span += np . exp ( ( ( matrix_T_I [ i , 1 ] - matrix_T_I [ j , 0 ] - dgr ) * 4184 ) / ( R * T ) ) if i < j : sum_span += np . exp ( ( ( matrix_T_I [ i , 1 ] - matrix_T_I [ j , 0 ] ) * 4184 ) / ( R * T ) ) TOF = ( ( k_b * T ) / h ) * ( ( np . exp ( ( - dgr * 4184 ) / ( R * T ) ) ) / sum_span ) for i in range ( n_I ) : sum_e = 0 for j in range ( n_I ) : if i >= j : sum_e += np . exp ( ( ( matrix_T_I [ i , 1 ] - matrix_T_I [ j , 0 ] - dgr ) * 4184 ) / ( R * T ) ) if i < j : sum_e += np . exp ( ( ( matrix_T_I [ i , 1 ] - matrix_T_I [ j , 0 ] ) * 4184 ) / ( R * T ) ) X_TOF [ i , 1 ] = np . round ( sum_e / sum_span , 4 ) for j in range ( n_I ) : sum_e = 0 for i in range ( n_I ) : if i >= j : sum_e += np . exp ( ( ( matrix_T_I [ i , 1 ] - matrix_T_I [ j , 0 ] - dgr ) * 4184 ) / ( R * T ) ) if i < j : sum_e += np . exp ( ( ( matrix_T_I [ i , 1 ] - matrix_T_I [ j , 0 ] ) * 4184 ) / ( R * T ) ) X_TOF [ j , 0 ] = np . round ( sum_e / sum_span , 4 ) else : dE = np . zeros ( ( n_I , n_I ) ) for i in range ( n_I ) : for j in range ( n_I ) : if i >= j : dE [ i , j ] = matrix_T_I [ i , 1 ] - matrix_T_I [ j , 0 ] if i < j : dE [ i , j ] = matrix_T_I [ i , 1 ] - matrix_T_I [ j , 0 ] + dgr Energy_Span = np . amax ( dE ) if verb > 2 : print ( f"Energy Span computed : {Energy_Span} kcal/mol." ) TOF = ( ( k_b * T ) / h ) * np . exp ( ( - ( Energy_Span * 4184 ) / ( R * T ) ) ) if verb > 2 : print ( f"TOF computed : {TOF} s^-1." ) i , j = np . unravel_index ( np . argmax ( dE , axis = None ) , dE . shape ) X_TOF [ i , 1 ] = 1.0 X_TOF [ j , 0 ] = 1.0 return TOF , X_TOF
Function to compute TOF using the energy span model.
Function to compute TOF using the energy span model .
"""Function to compute TOF using the energy span model.
    Reproduces results from the AUTOF code (https://doi.org/10.1002/jcc.21669).
    Adapted from the AUTOF implementation with contribution by Pit Steinbach."""
array
dgr
T
coeff
exact
verb