Esempio n. 1
0
def test_first_pure_substance_PR1976():

    subs = [methane]
    y = [1.0]

    eosname = "Peng and Robinson (1976)"
    mix = MixtureProp(subs, [1.0])
    eoseq = EOS(mix, [[0]], eosname)

    eos = createEOSMix(subs, eosname)

    p = 1e5
    t = 150
    pref = 1e5
    tref = 300

    zs = eoseq.getZfromPT(p, t)
    zliq = np.min(zs)
    zvap = np.max(zs)
    vliq, vvap = zliq * R_IG * t / p, zvap * R_IG * t / p

    v_allProps = eoseq.getAllProps(tref, t, pref, p)

    zs = eos.getZfromPT(p, t, y)
    zliq = np.min(zs)
    zvap = np.max(zs)
    vliq, vvap = zliq * R_IG * t / p, zvap * R_IG * t / p

    calc_allProps = eos.getAllProps(y, tref, t, pref, p)

    i = 0
    j = 1
    # assert U
    np.testing.assert_allclose(calc_allProps[i].Props.U, v_allProps[i].Props.U,
                               1e-5)
    np.testing.assert_allclose(calc_allProps[j].Props.U, v_allProps[j].Props.U,
                               1e-5)
    # assert H
    np.testing.assert_allclose(calc_allProps[i].Props.H, v_allProps[i].Props.H,
                               1e-5)
    np.testing.assert_allclose(calc_allProps[j].Props.H, v_allProps[j].Props.H,
                               1e-5)
    # assert S
    np.testing.assert_allclose(calc_allProps[i].Props.S, v_allProps[i].Props.S,
                               1e-5)
    np.testing.assert_allclose(calc_allProps[j].Props.S, v_allProps[j].Props.S,
                               1e-5)
    # assert G
    np.testing.assert_allclose(calc_allProps[i].Props.G, v_allProps[i].Props.G,
                               1e-5)
    np.testing.assert_allclose(calc_allProps[j].Props.G, v_allProps[j].Props.G,
                               1e-5)
    # assert A
    np.testing.assert_allclose(calc_allProps[i].Props.A, v_allProps[i].Props.A,
                               1e-5)
    np.testing.assert_allclose(calc_allProps[j].Props.A, v_allProps[j].Props.A,
                               1e-5)
Esempio n. 2
0
def test_get_AllProps_single_subs():
    k = [[0]]
    sglmethae = MixtureProp([methane], [1.0])
    eosname = "Peng and Robinson (1976)"
    eos = EOS(sglmethae, k, eosname)

    T, Tref = 150, 300
    P, Pref = 2e5, 1e5
    pliq, pvap = eos.getAllProps(Tref, T, Pref, P)

    expected_pliq = DeltaProp(
        32.669700, -1.224694e04, -89.121399, 1114.993043, -9766.360987, 3595.576453
    )
    expected_pvap = DeltaProp(
        32.669700, -5141.843232, -29.385790, -740.247025, -3860.999697, 540.596510
    )

    assert expected_pliq.isEqual(pliq.Props)
    assert expected_pvap.isEqual(pvap.Props)