示例#1
0
    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
示例#2
0
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))
示例#3
0
    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
示例#4
0
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))
示例#5
0
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))
示例#6
0
 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)
示例#7
0
 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)
示例#8
0
 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))
示例#9
0
 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)
示例#10
0
 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)
示例#11
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)
示例#12
0
    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")
示例#13
0
 def test_invlaid_option(self, frame):
     with pytest.raises(AttributeError):
         get_method(frame.props[1], "foo")
示例#14
0
 def test_None(self, frame):
     with pytest.raises(GenericPropertyPackageError):
         get_method(frame.props[1], "dummy_option")