Exemplo n.º 1
0
def ConstructInterpolatorIsothermAtTnew(df,
                                        T_0,
                                        T_new,
                                        loading_key=None,
                                        pressure_key=None,
                                        hoa_key=None,
                                        fill_value=None):
    """
    Returns InterpolatorIsotherm from pure-component isotherm data measured at
    temperature T0 extrapolated to temperature Tnew using the heat of adsorption.

    :param df: DataFrame Pandas DataFrame with pure-component isotherm tabular
               data measured at temperature T0
    :param T_0: Float temperature at which isotherm in df was measured (T0)
    :param T_new: Float temperature at which we desire to extrapolate the isotherm
               in df
    :param loading_key: String key for loading column in df
    :param pressure_key: String key for pressure column in df
    :param hoa_key: String key for heat of adsorption column in df
    :param fill_value: Float value of loading to assume when an attempt is made
                       to interpolate at a pressure greater than the largest
                       pressure observed in the data

    HOA needs to be in units kJ/mol.
    """

    R = 8.3144621 / 1000.0  # kJ/mol/K
    n = df.shape[0]  # number of values in the isotherm
    df_new = pd.DataFrame()
    df_new[pressure_key] = np.zeros((n, ))
    df_new[loading_key] = df[loading_key].values

    # for every point, shift pressures according to Classius-Clapyeron eqn
    for i in range(n):
        p_0 = df[pressure_key].iloc[i]  # Pa
        HoA = df[hoa_key].iloc[i]  # kJ/mol (negative)
        p_new = p_0 * np.exp(HoA / R * (1.0 / T_new - 1.0 / T_0))
        df_new[pressure_key].iloc[i] = p_new

    # return a pyiast.isotherm object
    return pyiast.InterpolatorIsotherm(df_new,
                                       loading_key=loading_key,
                                       pressure_key=pressure_key,
                                       fill_value=fill_value), df_new
Exemplo n.º 2
0
plt.show()


# ## Use IAST to predict mixture data, compare to dual component GCMC

# Construct isotherm objects. Use the interpolator isotherm here, as Langmuir and Quadratic isotherms do not fit well.
# 
# We use fill_value = largest loading so that, when the linear interpolation routine calls a pressure beyond our data, it will yield this value. Essentially, the assumption is that the saturation loading = the highest loading observed in the data.

# ### Interpolator isotherm for Methane

# In[7]:

ch4_isotherm = pyiast.InterpolatorIsotherm(df_ch4, loading_key="Loading(mmol/g)",
                                           pressure_key="Pressure(bar)", 
                                           fill_value=df_ch4['Loading(mmol/g)'].max())
pyiast.plot_isotherm(ch4_isotherm)


# ### Interpolator isotherm for ethane

# In[8]:

ch3ch3_isotherm = pyiast.InterpolatorIsotherm(df_ch3ch3, loading_key="Loading(mmol/g)",
                                              pressure_key="Pressure(bar)",
                                              fill_value=df_ch3ch3["Loading(mmol/g)"].max())
pyiast.plot_isotherm(ch3ch3_isotherm)


# ## Perform IAST at same mixture conditions as binary GCMC simulations
Exemplo n.º 3
0
    # use pyIAST to fit model to data
    isotherm = pyiast.ModelIsotherm(
        df, pressure_key='P', loading_key='L', model=model)
    isotherm.print_params()

    # plot fit
    P_plot = np.linspace(0, 1, 100)

    fig = plt.figure()
    plt.scatter(df['P'], df['L'], label='Synthetic data', clip_on=False)
    plt.plot(P_plot, isotherm.loading(P_plot), label='pyIAST fit')
    plt.xlim([0, 1])
    plt.ylim(ymin=0)
    plt.xlabel('Pressure')
    plt.ylabel('Uptake')
    plt.title(model)
    plt.legend(loc='lower right')
    plt.show()

    # assert parameters are equal
    for param in isotherm.params.keys():
        np.testing.assert_almost_equal(
            isotherm.params[param], model_params[model][param], decimal=3)

# ### Quick visual test on the Interpolator isotherm

# In[7]:

isotherm = pyiast.InterpolatorIsotherm(df, pressure_key='P', loading_key='L')
pyiast.plot_isotherm(isotherm)