예제 #1
0
def test_Wilke():
    mu = Wilke([0.05, 0.95], [1.34E-5, 9.5029E-6], [64.06, 46.07])
    assert_close(mu, 9.701614885866193e-06, rtol=1e-10)

    #    with pytest.raises(Exception):
    #        Wilke([0.05], [1.34E-5, 9.5029E-6], [64.06, 46.07])

    mu = Wilke_large([0.05, 0.95], [1.34E-5, 9.5029E-6], [64.06, 46.07])
    assert_close(mu, 9.701614885866193e-06, rtol=1e-10)

    mu = Wilke_prefactored([0.05, 0.95], [1.34E-5, 9.5029E-6],
                           *Wilke_prefactors([64.06, 46.07]))
    assert_close(mu, 9.701614885866193e-06, rtol=1e-10)

    # Large composition test
    zs = [
        0.10456352460469782, 0.10472506156674823, 0.10347781516834291,
        1.4089716440797791e-05, 0.10488254481011455, 0.10078888107401028,
        0.09902003237540975, 0.09045109410107957, 0.08642540418108867,
        0.1043609364553231, 0.10129061594674436
    ]
    mus = [
        1.1601665408586192e-05, 9.408370570946896e-06, 8.19709294177777e-06,
        1.4314548719058091e-05, 1.5057441002481923e-05, 7.5434795308593725e-06,
        7.447082353139856e-06, 7.0365592301967965e-06, 6.720364621681796e-06,
        1.2157004301638695e-05, 1.3006463728382868e-05
    ]
    MWs = [
        16.04246, 30.06904, 44.09562, 2.01588, 44.0095, 58.1222, 58.1222,
        72.14878, 72.14878, 34.08088, 64.0638
    ]

    # Make a large set of data, but don't actually use it anywhere; for easy of bencharmking
    zs_new = []
    mus_new = []
    MWs_new = []
    for i in range(20):
        zs_new.extend(zs)
        mus_new.extend(mus)
        MWs_new.extend(MWs)
    zs_large = normalize(zs_new)
    mus_large = mus_new
    MWs_large = MWs_new

    mu_expect = 9.282311227289109e-06
    assert_close(Wilke(zs, mus, MWs), mu_expect, rtol=1e-10)
    assert_close(Wilke_large(zs, mus, MWs), mu_expect, rtol=1e-10)
    prefactors = Wilke_prefactors(MWs)
    assert_close(Wilke_prefactored(zs, mus, *prefactors),
                 mu_expect,
                 rtol=1e-10)

    # Test that the prefactors really work - use a different composition
    zs_diff = normalize([.1, .2, .3, .4, .5, .6, .7, .8, .9, .10, .2])
    mu_expect = 8.238656569251283e-06
    assert_close(Wilke(zs_diff, mus, MWs), mu_expect, rtol=1e-10)
    assert_close(Wilke_large(zs_diff, mus, MWs), mu_expect, rtol=1e-10)
    assert_close(Wilke_prefactored(zs_diff, mus, *prefactors),
                 mu_expect,
                 rtol=1e-10)
예제 #2
0
def test_fire_mixing():
    LFL = fire_mixing(ys=normalize([0.0024, 0.0061, 0.0015]),
                      FLs=[.012, .053, .031])
    assert_close(LFL, 0.02751172136637642, rtol=1e-13)

    UFL = fire_mixing(ys=normalize([0.0024, 0.0061, 0.0015]),
                      FLs=[.075, .15, .32])
    assert_close(UFL, 0.12927551844869378, rtol=1e-13)
예제 #3
0
    def gammas_infinite_dilution(self):
        r'''Calculate and return the infinite dilution activity coefficients
        of each component.

        Returns
        -------
        gammas_infinite : list[float]
            Infinite dilution activity coefficients, [-]

        Notes
        -----
        The algorithm is as follows. For each component, set its composition to
        zero. Normalize the remaining compositions to 1. Create a new object
        with that composition, and calculate the activity coefficient of the
        component whose concentration was set to zero.
        '''
        T, N = self.T, self.N
        xs_base = self.xs
        if self.scalar:
            gammas_inf = [0.0] * N
            copy_fun = list
        else:
            gammas_inf = zeros(N)
            copy_fun = array
        for i in range(N):
            xs = copy_fun(xs_base)
            xs[i] = 0.0
            xs = normalize(xs)
            gammas_inf[i] = self.to_T_xs(T, xs=xs).gammas()[i]
        return gammas_inf