Example #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
Example #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))
Example #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
Example #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))
Example #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))
Example #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)
Example #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)
Example #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))
Example #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)
Example #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)
Example #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)
Example #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")
Example #13
0
 def test_invlaid_option(self, frame):
     with pytest.raises(AttributeError):
         get_method(frame.props[1], "foo")
Example #14
0
 def test_None(self, frame):
     with pytest.raises(GenericPropertyPackageError):
         get_method(frame.props[1], "dummy_option")