def test_check_fugacity_single_substance(): 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 zs = eos.getZfromPT(P, T) vs = eos.getVfromPT(P, T) zliq, zvap = np.min(zs), np.max(zs) vliq, vvap = np.min(vs), np.max(vs) fl = eos.getFugacity(P, T, vliq, zliq) fv = eos.getFugacity(P, T, vvap, zvap) np.testing.assert_allclose(fl, 8.58224011e5, 1e-3) np.testing.assert_allclose(fv, 1.93892612e5, 1e-3)
def test_Props_for_single_compound_peng_and_robinson(): k = [[0]] sglmethae = MixtureProp([methane], [1.0]) eosname = "Peng and Robinson (1976)" eos = EOS(sglmethae, k, eosname) P, T = 1e5, 150 zs = eos.getZfromPT(P, T) vs = eos.getVfromPT(P, T) zmin, zmax = np.min(zs), np.max(zs) vmin, vmax = np.min(vs), np.max(vs) PvpAW = eos.mix.substances[0].getPvpAW(T) pvp_expected = 10.47 * 1e5 # Pa pvp_returned = eos.getPvp(T, PvpAW)[0] assert eosname == eos.getEOSDisplayName() np.testing.assert_allclose(0.9845, zmax, 1e-2) np.testing.assert_allclose(0.003341, zmin, 1e-2) np.testing.assert_allclose(0.01228, vmax, 1e-2) np.testing.assert_allclose(0.00004167, vmin, 1e-2) np.testing.assert_allclose(P, eos.getP(vmax, T), 1e-3) np.testing.assert_allclose(P, eos.getP(vmin, T), 1e-3) np.testing.assert_allclose(pvp_expected, pvp_returned, 1e-3) # check equilibrium P, T = pvp_returned, 150 zs = eos.getZfromPT(P, T) vs = eos.getVfromPT(P, T) zmin, zmax = np.min(zs), np.max(zs) vmin, vmax = np.min(vs), np.max(vs) fl = eos.getFugacity(P, T, vmin, zmin) fv = eos.getFugacity(P, T, vmax, zmax) np.testing.assert_allclose(fl, fv, 1e-3) # check all properties # Tref, T, Pref, P = 300, 150, 1e5, 2e5 assert methane.hasCp() zs = eos.getZfromPT(P, T) vs = eos.getVfromPT(P, T) zsref = eos.getZfromPT(Pref, Tref) vsref = eos.getVfromPT(Pref, Tref) zliq, zvap, vliq, vvap = np.min(zs), np.max(zs), np.min(vs), np.max(vs) zliqref, zvapref, vliqref, vvapref = ( np.min(zsref), np.max(zsref), np.min(vsref), np.max(vsref), ) igprop = methane.getIGProps(Tref, T, Pref, P) ddp_liq = eos.getDeltaDepartureProps(Pref, Tref, vliqref, zliqref, P, T, vliq, zliq) ddp_vap = eos.getDeltaDepartureProps(Pref, Tref, vvapref, zvapref, P, T, vvap, zvap) pliq = igprop.subtract(ddp_liq) pvap = igprop.subtract(ddp_vap) 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 pliq.isEqual(expected_pliq) assert pvap.isEqual(expected_pvap) p2liq, p2vap = eos.getCpHSGUA(Tref, T, Pref, P) assert p2liq.isEqual(expected_pliq) assert p2vap.isEqual(expected_pvap)