def test_module(self, frame): # Test that get_method works when pointed to a module with the method frame.params.config.dummy_option = modules[__name__] assert get_method(frame.props[1], "dummy_option") is dummy_option assert get_method(frame.props[1], "dummy_option")(frame.props[1]) is \ frame.props[1].dummy_response
def entr_mol_phase_comp(b, p, j): if p == "Vap": return get_method(b, "entr_mol_ig_comp")(b, j, b.temperature) elif p == "Liq": return get_method(b, "entr_mol_liq_comp")(b, j, b.temperature) else: raise PropertyNotSupportedError(_invalid_phase_msg(b.name, p))
def test_method(self, frame): # Test that get_method works when provided with the method directly frame.params.config.dummy_option = dummy_option assert get_method(frame.props[1], "dummy_option") is dummy_option assert get_method(frame.props[1], "dummy_option")(frame.props[1]) is \ frame.props[1].dummy_response
def fug_phase_comp(b, p, j): if p == "Vap": return b.mole_frac_phase_comp[p, j]*b.pressure elif p == "Liq": return b.mole_frac_phase_comp[p, j] * \ get_method(b, "pressure_sat_comp")(b, j, b._teq) else: raise PropertyNotSupportedError(_invalid_phase_msg(b.name, p))
def dens_mol_phase(b, p): if p == "Vap": return b.pressure/(const.gas_constant*b.temperature) elif p == "Liq": return sum(b.mole_frac_phase_comp[p, j] * get_method(b, "dens_mol_liq_comp")(b, j, b.temperature) for j in b.components_in_phase(p)) else: raise PropertyNotSupportedError(_invalid_phase_msg(b.name, p))
def rule_mole_frac_dew_press(b, j): return (b._mole_frac_pdew[j] * get_method(b, "pressure_sat_comp")(b, j, b.temperature) == b.mole_frac_comp[j]*b.pressure_dew)
def rule_dew_press(b): return 0 == 1 - b.pressure_dew*sum( b.mole_frac_comp[j] / get_method(b, "pressure_sat_comp")(b, j, b.temperature) for j in b._params.component_list)
def rule_mole_frac_bubble_press(b, j): return b._mole_frac_pbub[j]*b.pressure_bubble == ( b.mole_frac_comp[j] * get_method(b, "pressure_sat_comp")(b, j, b.temperature))
def rule_bubble_press(b): return b.pressure_bubble == sum( b.mole_frac_comp[j] * get_method(b, "pressure_sat_comp")(b, j, b.temperature) for j in b._params.component_list)
def rule_dew_temp(b): return (b.pressure*sum( b.mole_frac_comp[j] / get_method(b, "pressure_sat_comp")(b, j, b.temperature_dew) for j in b._params.component_list) - 1 == 0)
def rule_mole_frac_bubble_temp(b, j): return b._mole_frac_tbub[j]*b.pressure == b.mole_frac_comp[j] * \ get_method(b, "pressure_sat_comp")(b, j, b.temperature_bubble)
def test_not_method_or_module(self, frame): # Test that get_method works when provided with the method directly frame.params.config.dummy_option = "foo" with pytest.raises(ConfigurationError): get_method(frame.props[1], "dummy_option")
def test_invlaid_option(self, frame): with pytest.raises(AttributeError): get_method(frame.props[1], "foo")
def test_None(self, frame): with pytest.raises(GenericPropertyPackageError): get_method(frame.props[1], "dummy_option")