def test_compress_fact_phase_Vap(m): assert isinstance(Cubic.compress_fact_phase(m.props[1], "Vap"), ExternalFunctionExpression) assert pytest.approx(value(f_Zv(0, Av, Bv)), rel=1e-5) == value( Cubic.compress_fact_phase(m.props[1], "Vap")) assert pytest.approx(value( Cubic.compress_fact_phase(m.props[1], "Vap")), rel=1e-5) == Zv
def test_fug_coeff_phase_comp_Vap(m): assert pytest.approx(1.05952, rel=1e-5) == value( Cubic.fug_coeff_phase_comp(m.props[1], "Vap", "a")) assert pytest.approx(0.96070, rel=1e-5) == value( Cubic.fug_coeff_phase_comp(m.props[1], "Vap", "b")) assert pytest.approx(0.87903, rel=1e-5) == value( Cubic.fug_coeff_phase_comp(m.props[1], "Vap", "c"))
def test_fug_coeff_phase_comp_Liq(m): assert pytest.approx(1.01213, rel=1e-5) == value( Cubic.fug_coeff_phase_comp(m.props[1], "Liq", "a")) assert pytest.approx(0.95919, rel=1e-5) == value( Cubic.fug_coeff_phase_comp(m.props[1], "Liq", "b")) assert pytest.approx(0.91356, rel=1e-5) == value( Cubic.fug_coeff_phase_comp(m.props[1], "Liq", "c"))
def test_fug_coeff_phase_comp_eq_Liq(m): assert pytest.approx(1.22431, rel=1e-5) == value( Cubic.fug_coeff_phase_comp_eq(m.props[1], "Liq", "a", ("Vap", "Liq"))) assert pytest.approx(0.0049604, rel=1e-5) == value( Cubic.fug_coeff_phase_comp_eq(m.props[1], "Liq", "b", ("Vap", "Liq"))) assert pytest.approx(3.19128e-05, rel=1e-5) == value( Cubic.fug_coeff_phase_comp_eq(m.props[1], "Liq", "c", ("Vap", "Liq")))
def test_vol_mol_phase(m): assert value(Cubic.vol_mol_phase(m.props[1], "Vap")) == pytest.approx(1 / 44.800, rel=1e-3) assert value(Cubic.vol_mol_phase(m.props[1], "Liq")) == pytest.approx(1 / 41.157, rel=1e-3)
def test_fug_coeff_phase_comp_eq_Vap(m): assert pytest.approx(86.9140, rel=1e-5) == value( Cubic.fug_coeff_phase_comp_eq(m.props[1], "Vap", "a", ("Vap", "Liq"))) assert pytest.approx(0.0049878, rel=1e-5) == value( Cubic.fug_coeff_phase_comp_eq(m.props[1], "Vap", "b", ("Vap", "Liq"))) assert pytest.approx(6.49776e-07, rel=1e-5) == value( Cubic.fug_coeff_phase_comp_eq(m.props[1], "Vap", "c", ("Vap", "Liq")))
def test_enth_mol_phase_comp(m): enth = { ("Liq", "a"): -23.8270, ("Vap", "a"): 345.7288, ("Liq", "b"): -407.3709, ("Vap", "b"): -385.7457, ("Liq", "c"): -757.0346, ("Vap", "c"): -1052.4697 } for j in m.params.component_list: assert pytest.approx(enth["Liq", j], rel=1e-5) == value( Cubic.enth_mol_phase_comp(m.props[1], "Liq", j)) assert pytest.approx(enth["Vap", j], rel=1e-5) == value( Cubic.enth_mol_phase_comp(m.props[1], "Vap", j)) assert pytest.approx(Hl, rel=1e-5) == value( sum( Cubic.enth_mol_phase_comp(m.props[1], "Liq", j) * m.props[1].mole_frac_phase_comp["Liq", j] for j in m.params.component_list)) assert pytest.approx(Hv, rel=1e-5) == value( sum( Cubic.enth_mol_phase_comp(m.props[1], "Vap", j) * m.props[1].mole_frac_phase_comp["Vap", j] for j in m.params.component_list))
def test_compress_fact_phase_Liq(m): assert isinstance(Cubic.compress_fact_phase(m.props[1], "Liq"), ExternalFunctionExpression) assert pytest.approx(value(f_Zl(0, Al, Bl)), rel=1e-5) == value( Cubic.compress_fact_phase(m.props[1], "Liq")) assert pytest.approx(value( Cubic.compress_fact_phase(m.props[1], "Liq")), rel=1e-5) == Zl
def test_cp_mol_phase(build_model): m = build_model assert (str(pyunits.get_units(Cubic.cp_mol_phase( m.props, "Vap"))) == 'kg*m**2/K/mol/s**2') assert (pytest.approx(value(Cubic.cp_mol_phase(m.props, "Vap")), rel=0.1) == data["cp_mol_phase"])
def test_gibbs_mol_phase_comp(m): for p in m.params.phase_list: for j in m.params.component_list: assert (pytest.approx( value(Cubic.gibbs_mol_phase_comp(m.props[1], p, j)), rel=1e-5) == value( Cubic.enth_mol_phase_comp(m.props[1], p, j) - Cubic.entr_mol_phase_comp(m.props[1], p, j) * m.props[1].temperature))
def test_enth_mol_phase_comp(m): for j in m.params.component_list: m.params.get_component(j).config.enth_mol_liq_comp = dummy_call m.params.get_component(j).config.enth_mol_ig_comp = dummy_call assert pytest.approx(-212.211, rel=1e-5) == value( Cubic.enth_mol_phase_comp(m.props[1], "Liq", j)) assert pytest.approx(-779.305, rel=1e-5) == value( Cubic.enth_mol_phase_comp(m.props[1], "Vap", j))
def test_heat_capacity_ratio_phase(build_model): m = build_model assert (str( pyunits.get_units(Cubic.heat_capacity_ratio_phase(m.props, "Vap"))) == 'None') assert (pytest.approx(value(Cubic.heat_capacity_ratio_phase( m.props, "Vap")), rel=0.1) == data["heat_capacity_ratio_phase"])
def test_isentropic_speed_sound_phase(build_model): m = build_model assert (str( pyunits.get_units(Cubic.isentropic_speed_sound_phase(m.props, "Vap"))) == 'm/s') assert (pytest.approx(value( Cubic.isentropic_speed_sound_phase(m.props, "Vap")), rel=0.1) == data["isentropic_speed_sound_phase"])
def test_fug_phase_comp_eq(m): for p in m.params.phase_list: for j in m.params.component_list: assert str(Cubic.fug_phase_comp_eq( m.props[1], p, j, ("Vap", "Liq"))) == str( m.props[1].mole_frac_phase_comp[p, j] * m.props[1].pressure * Cubic.fug_coeff_phase_comp_eq( m.props[1], p, j, ("Vap", "Liq")))
def test_energy_internal_mol_phase_comp(m): for j in m.params.component_list: m.params.config.include_enthalpy_of_formation = False m.params.get_component(j).config.enth_mol_liq_comp = dummy_call m.params.get_component(j).config.enth_mol_ig_comp = dummy_call assert pytest.approx(Ul, rel=1e-4) == value( Cubic.energy_internal_mol_phase_comp(m.props[1], "Liq", j)) assert pytest.approx(Uv, rel=1e-4) == value( Cubic.energy_internal_mol_phase_comp(m.props[1], "Vap", j))
def test_entr_mol_phase(m): for j in m.params.component_list: m.params.get_component(j).config.entr_mol_liq_comp = dummy_call m.params.get_component(j).config.entr_mol_ig_comp = dummy_call m.props[1].entr_mol_phase_comp = Var(m.params.phase_list, m.params.component_list, initialize=1) assert pytest.approx(value( Cubic.entr_mol_phase(m.props[1], "Vap")), rel=1e-5) == 39.9218 assert pytest.approx(value( Cubic.entr_mol_phase(m.props[1], "Liq")), rel=1e-5) == 41.1621
def test_entr_mol_phase_comp(m): entr = {("Liq", "a"): 45.4093, ("Vap", "a"): 59.0666, ("Liq", "b"): 51.1725, ("Vap", "b"): 53.3035, ("Liq", "c"): 60.3069, ("Vap", "c"): 42.8875} for j in m.params.component_list: m.params.get_component(j).config.entr_mol_liq_comp = dummy_call m.params.get_component(j).config.entr_mol_ig_comp = dummy_call assert pytest.approx(entr[("Liq", j)], rel=1e-5) == value( Cubic.entr_mol_phase_comp(m.props[1], "Liq", j)) assert pytest.approx(entr[("Vap", j)], rel=1e-5) == value( Cubic.entr_mol_phase_comp(m.props[1], "Vap", j))
def test_dens_mass_phase(m): m.props[1].dens_mol_phase = Var(m.params.phase_list) m.props[1].mw_phase = Var(m.params.phase_list) for p in m.params.phase_list: assert str(Cubic.dens_mass_phase(m.props[1], p)) == str( m.props[1].dens_mol_phase[p]*m.props[1].mw_phase[p])
def test_energy_internal_mol_phase_comp(m): for p in m.params.phase_list: for j in m.params.component_list: assert (str(Cubic.energy_internal_mol_phase_comp( m.props[1], p, j)) == str(m.props[1].enth_mol_phase_comp[p, j] - m.props[1].pressure * m.props[1].vol_mol_phase_comp[p, j]))
def test_gibbs_mol_phase(m): m.props[1].enth_mol_phase = Var(m.params.phase_list) m.props[1].entr_mol_phase = Var(m.params.phase_list) for p in m.params.phase_list: assert str(Cubic.gibbs_mol_phase(m.props[1], p)) == str( m.props[1].enth_mol_phase[p] - m.props[1].entr_mol_phase[p]*m.props[1].temperature)
def test_gibbs_mol_phase_comp(m): m.props[1].enth_mol_phase_comp = Var(m.params.phase_list, m.params.component_list) m.props[1].entr_mol_phase_comp = Var(m.params.phase_list, m.params.component_list) for p in m.params.phase_list: for j in m.params.component_list: assert str(Cubic.gibbs_mol_phase_comp(m.props[1], p, j)) == str( m.props[1].enth_mol_phase_comp[p, j] - m.props[1].entr_mol_phase_comp[p, j] * m.props[1].temperature)
def test_entr_mol_phase_comp(m): entr = { ("Liq", "a"): 45.8181, ("Vap", "a"): 61.5670, ("Liq", "b"): 50.7494, ("Vap", "b"): 54.1797, ("Liq", "c"): 59.1236, ("Vap", "c"): 42.2799 } for j in m.params.component_list: assert pytest.approx(entr[("Liq", j)], rel=1e-5) == value( Cubic.entr_mol_phase_comp(m.props[1], "Liq", j)) assert pytest.approx(entr[("Vap", j)], rel=1e-5) == value( Cubic.entr_mol_phase_comp(m.props[1], "Vap", j)) # With real partial molar quantities implemented, we should have that # the sum weighted by mole fraction is equal to the molar entropy assert (pytest.approx( value(Cubic.entr_mol_phase(m.props[1], "Liq")), rel=1e-5) == value( sum( Cubic.entr_mol_phase_comp(m.props[1], "Liq", j) * m.props[1].mole_frac_phase_comp["Liq", j] for j in m.params.component_list))) assert (pytest.approx( value(Cubic.entr_mol_phase(m.props[1], "Vap")), rel=1e-5) == value( sum( Cubic.entr_mol_phase_comp(m.props[1], "Vap", j) * m.props[1].mole_frac_phase_comp["Vap", j] for j in m.params.component_list)))
def test_vol_mol_phase_comp(m): vol = { ("Liq", "a"): 0.0249368, ("Vap", "a"): 0.0262974, ("Liq", "b"): 0.0236340, ("Vap", "b"): 0.0237075, ("Liq", "c"): 0.0224518, ("Vap", "c"): 0.0213573 } for j in m.params.component_list: assert pytest.approx(vol[("Liq", j)], rel=1e-5) == value( Cubic.vol_mol_phase_comp(m.props[1], "Liq", j)) assert pytest.approx(vol[("Vap", j)], rel=1e-5) == value( Cubic.vol_mol_phase_comp(m.props[1], "Vap", j)) # With real partial molar quantities implemented, we should have that # the sum weighted by mole fraction is equal to the molar volume assert (pytest.approx( value(Cubic.vol_mol_phase(m.props[1], "Liq")), rel=1e-5) == value( sum( Cubic.vol_mol_phase_comp(m.props[1], "Liq", j) * m.props[1].mole_frac_phase_comp["Liq", j] for j in m.params.component_list))) assert (pytest.approx( value(Cubic.vol_mol_phase(m.props[1], "Vap")), rel=1e-5) == value( sum( Cubic.vol_mol_phase_comp(m.props[1], "Vap", j) * m.props[1].mole_frac_phase_comp["Vap", j] for j in m.params.component_list)))
def test_energy_internal_mol_phase_invalid_phase(m_sol): with pytest.raises(PropertyNotSupportedError): Cubic.energy_internal_mol_phase_comp(m_sol.props[1], "Sol", "foo")
def test_dens_mol_phase_invalid_phase(m_sol): with pytest.raises(PropertyNotSupportedError): Cubic.dens_mol_phase(m_sol.props[1], "Sol")
def test_enth_mol_phase(m): assert pytest.approx(value(Cubic.enth_mol_phase(m.props[1], "Vap")), rel=1e-5) == Hv assert pytest.approx(value(Cubic.enth_mol_phase(m.props[1], "Liq")), rel=1e-5) == Hl
def test_fug_coeff_phase_comp_eq_invalid_phase(m_sol): with pytest.raises(PropertyNotSupportedError): Cubic.fug_coeff_phase_comp_eq( m_sol.props[1], "Sol", "foo", ("Vap", "Liq"))
def test_entr_mol_phase(m): assert pytest.approx(value(Cubic.entr_mol_phase(m.props[1], "Vap")), rel=1e-5) == 46.58858 assert pytest.approx(value(Cubic.entr_mol_phase(m.props[1], "Liq")), rel=1e-5) == 48.62807
def test_compress_fact_phase_invalid_phase(m_sol): with pytest.raises(PropertyNotSupportedError): Cubic.compress_fact_phase(m_sol.props[1], "Sol")
def test_fug_phase_comp_invalid_phase(m_sol): with pytest.raises(PropertyNotSupportedError): Cubic.fug_phase_comp(m_sol.props[1], "Sol", "foo")