Пример #1
0
    def test_bet(self):

        # Carbon black reference material isotherm (N2 at 77K)
        Qads = np.array([
            4.39005, 4.67017, 4.79068, 4.9767, 5.14414, 5.31144, 5.47106,
            5.63297, 5.80559, 5.96663, 6.13574, 6.31214, 6.49764, 6.67154,
            6.85255, 7.04053, 7.22571, 7.40778, 7.59634, 7.7832, 7.96568,
            8.1623, 8.34863, 8.54383, 8.74695, 8.94871, 9.16214, 9.38208,
            9.61289, 9.8577, 10.12, 10.397, 10.6852, 11.0089, 11.3574, 11.7373,
            12.1611, 12.6289, 13.1794, 13.819, 14.57, 15.4858, 16.6535, 18.2409
        ])

        Prel = np.array([
            0.0433547, 0.0672921, 0.0796994, 0.0999331, 0.119912, 0.140374,
            0.159884, 0.179697, 0.200356, 0.219646, 0.239691, 0.259671,
            0.280475, 0.299907, 0.320048, 0.340746, 0.360882, 0.380708,
            0.400956, 0.421168, 0.440603, 0.460924, 0.480902, 0.500572,
            0.521144, 0.540715, 0.560852, 0.580887, 0.600803, 0.62089, 0.64084,
            0.66093, 0.68071, 0.70082, 0.72096, 0.74084, 0.76081, 0.78045,
            0.80084, 0.82107, 0.84075, 0.86069, 0.88041, 0.90023
        ])

        pmin = 0.05
        pmax = 0.3
        r = bet.bet(Prel, Qads, Pmin=pmin, Pmax=pmax, csa=0.162)
        np.testing.assert_almost_equal(r.sa, 20.7049, 3)
        np.testing.assert_almost_equal(r.sa_err, 0.0289, 4)
        np.testing.assert_almost_equal(r.C, 149.959660, 2)
        np.testing.assert_almost_equal(r.q_m, 4.7569, 4)

        Pfit, Qfit = util.restrict_isotherm(Prel, Qads, pmin, pmax)
        roq = bet.Isotherm2RoquerolBET(Pfit, Qfit)
        np.testing.assert_almost_equal(roq[0], 4.3559, 4)
        np.testing.assert_almost_equal(roq[6], 4.62074, 4)
Пример #2
0
    def test_bet(self):

        # Carbon black reference material isotherm (N2 at 77K)
        Qads = np.array([4.39005, 4.67017, 4.79068, 4.9767, 5.14414, 5.31144,
                         5.47106, 5.63297, 5.80559, 5.96663, 6.13574, 6.31214,
                         6.49764, 6.67154, 6.85255, 7.04053, 7.22571, 7.40778,
                         7.59634, 7.7832, 7.96568, 8.1623, 8.34863, 8.54383,
                         8.74695, 8.94871, 9.16214, 9.38208, 9.61289, 9.8577,
                         10.12, 10.397, 10.6852, 11.0089, 11.3574, 11.7373,
                         12.1611, 12.6289, 13.1794, 13.819, 14.57, 15.4858,
                         16.6535, 18.2409])

        Prel = np.array([0.0433547, 0.0672921, 0.0796994, 0.0999331, 0.119912,
                         0.140374, 0.159884, 0.179697, 0.200356, 0.219646,
                         0.239691, 0.259671, 0.280475, 0.299907, 0.320048,
                         0.340746, 0.360882, 0.380708, 0.400956, 0.421168,
                         0.440603, 0.460924, 0.480902, 0.500572, 0.521144,
                         0.540715, 0.560852, 0.580887, 0.600803, 0.62089,
                         0.64084, 0.66093, 0.68071, 0.70082, 0.72096, 0.74084,
                         0.76081, 0.78045, 0.80084, 0.82107, 0.84075, 0.86069,
                         0.88041, 0.90023])

        pmin = 0.05
        pmax = 0.3
        r = bet.bet(Prel, Qads, Pmin = pmin, Pmax = pmax, csa=0.162)
        np.testing.assert_almost_equal( r.sa, 20.7049, 3 )
        np.testing.assert_almost_equal( r.sa_err, 0.0289, 4 )
        np.testing.assert_almost_equal( r.C, 149.959660, 2 )
        np.testing.assert_almost_equal( r.q_m, 4.7569, 4 )

        Pfit, Qfit = util.restrict_isotherm(Prel,Qads,pmin,pmax)
        roq = bet.Isotherm2RoquerolBET(Pfit,Qfit ) 
        np.testing.assert_almost_equal( roq[0], 4.3559, 4 )
        np.testing.assert_almost_equal( roq[6], 4.62074, 4 )
Пример #3
0
    def test_restrict(self):
        s = ex.carbon_black()
        P,Q = util.restrict_isotherm( s.Prel, s.Qads, 0.05, 0.3 )
        self.assertTrue( Q.shape == P.shape )

        Qads = np.array([4.67017, 4.79068, 4.9767, 5.14414, 5.31144, 5.47106,
                         5.63297, 5.80559, 5.96663, 6.13574, 6.31214, 6.49764,
                         6.67154])
        Prel = np.array([0.0672921, 0.0796994, 0.0999331, 0.119912, 0.140374,
                         0.159884, 0.179697, 0.200356, 0.219646, 0.239691,
                         0.259671, 0.280475, 0.299907])
        self.assertTrue( (Qads == Q).all() )
        self.assertTrue( (Prel == P).all() )
Пример #4
0
    def test_restrict(self):
        s = ex.carbon_black()
        P, Q = util.restrict_isotherm(s.Prel, s.Qads, 0.05, 0.3)
        self.assertTrue(Q.shape == P.shape)

        Qads = np.array([
            4.67017, 4.79068, 4.9767, 5.14414, 5.31144, 5.47106, 5.63297,
            5.80559, 5.96663, 6.13574, 6.31214, 6.49764, 6.67154
        ])
        Prel = np.array([
            0.0672921, 0.0796994, 0.0999331, 0.119912, 0.140374, 0.159884,
            0.179697, 0.200356, 0.219646, 0.239691, 0.259671, 0.280475,
            0.299907
        ])
        self.assertTrue((Qads == Q).all())
        self.assertTrue((Prel == P).all())
Пример #5
0
def bjh_plot(x=None):
    """
    This was created assuming the matplotlib inline backend is used (%matplotlib inline)
    If %matplotlib notebook is used it may be more efficient to create a graph
    once and use the ipywidgets to update/change the data

    Takes an argument b/c wgt.observe calls BJHPlot(wgt.value) but we need the
    value of all the wgts to do the calculation so we use global vars instead
    """

    # Remove old graph but wait until new graph is made so the page won't change position
    clear_output(wait=True)

    fig = plt.figure(figsize=(15.5, 11))

    # Adjust space between VolPlot and AreaPlot
    fig.subplots_adjust(hspace=0.25)

# Create VolPlot
    vol_plot = fig.add_subplot(2, 1, 1)
    vol_plot.set_title('Cumulative Volume')
    vol_plot.grid()

    # Set x-axis (pore radius)
    vol_plot.set_xlabel('Pore Radius [$\AA$]')
    vol_plot.set_xscale('log')
    vol_plot.xaxis.set_major_formatter(matplotlib.ticker.ScalarFormatter())
    vol_plot.set_xticks([5, 10, 50, 100, 500, 1000])

    # Set y-axis 1 (cumulative pore volume)
    vol_plot.set_ylabel('Pore Volume [cm3/g]')

# Create AreaPlot
    area_plot = fig.add_subplot(2, 1, 2)
    area_plot.set_title('Cumulative Area')
    area_plot.grid()

    # Set x-axis (pore radius)
    area_plot.set_xlabel('Pore Radius [$\AA$]')
    area_plot.set_xscale('log')
    area_plot.xaxis.set_major_formatter(matplotlib.ticker.ScalarFormatter())
    area_plot.set_xticks([5, 10, 50, 100, 500, 1000])

    # Set y-axis 1 (cumulative pore area)
    area_plot.set_ylabel('Pore Area [m2/g]')

# Get currently selected widget values
    selected_cor = cor_wgt.value
    selected_thk = thk_wgt.value
    selected_iso0 = iso_wgt.value[0]
    selected_iso1 = iso_wgt.value[1]

# Restrict Prel if needed
    if selected_iso0 == 0.0 and selected_iso1 == 1.0:
        r_prel, r_qads = prel, qads
    else:
        r_prel, r_qads = util.restrict_isotherm(prel, qads, selected_iso0, selected_iso1)

# Run BJH Calculation
    bjh_data = bjh_dict[selected_cor](r_prel, r_qads, APF, DCF, thk_dict[selected_thk], adsorption)
    r, v, a = bjh_data.PoreRadii, bjh_data.cumV, bjh_data.cumA

# Plot Volume
    vol_plot.plot(r, v, 'or-', alpha=0.7)
    vol_plot.autoscale_view(True, True, True)

    # Set Volume y-axis 2 (derivative)
    d_vol_plot = vol_plot.twinx()
    d_vol_plot.set_ylabel('Derivative [cm3/g]')

    # Calculate Volume Derivative (this might differ from MicroActive)
    smooth_v = intrp.splrep(np.log(r[::-1]), v[::-1], s=0.0002)
    dV = intrp.splev(np.log(r[::-1]), smooth_v, der=1)
    dV = -dV[::-1]*np.log(10)

    # Plot Volume Derivative
    d_vol_plot.plot(r, dV, 'oc-', alpha=0.7)
    d_vol_plot.autoscale_view(True, True, True)

# Plot Area
    area_plot.plot(r, a, 'or-', alpha=0.7)
    area_plot.autoscale_view(True, True, True)

    # Set Area y-axis 2 (derivative)
    d_area_plot = area_plot.twinx()
    d_area_plot.set_ylabel('Derivative [m2/g]')

    # Calculate Area Derivative (this might differ from MicroActive)
    smooth_a = intrp.splrep(np.log(r[::-1]), a[::-1], s=0.0002)
    dA = intrp.splev(np.log(r[::-1]), smooth_a, der=1)
    dA = -dA[::-1]*np.log(10)

    # Plot Area Derivative
    d_area_plot.plot(r, dA, 'oc-', alpha=0.7)
    d_area_plot.autoscale_view(True, True, True)