Beispiel #1
0
def process_fluid_state(fluid_ref):
    """Check input for state object or fluid string
    
    Parameters
    ----------
        fluid_ref : str, CoolProp.AbstractState
    
    Returns
    -------
        CoolProp.AbstractState
    """
    # Process the fluid and set self._state
    if is_string(fluid_ref):
        backend, fluids   = extract_backend(fluid_ref)
        fluids, fractions = extract_fractions(fluids)
        #if backend==u'?': backend = u'HEOS'
#         # TODO: Fix the backend extraction etc
#         fluid_def = fluid_ref.split('::')
#         if len(fluid_def)==2:
#             backend = fluid_def[0]
#             fluid = fluid_def[1]
#         elif len(fluid_def)==1:
#             backend = "HEOS"
#             fluid = fluid_def[0]
#         else: 
#             raise ValueError("This is not a valid fluid_ref string: {0:s}".format(str(fluid_ref)))
        state = AbstractState(backend, '&'.join(fluids))
        #state.set_mass_fractions(fractions)
        return state 
    elif isinstance(fluid_ref, AbstractState):
        return fluid_ref
    raise TypeError("Invalid fluid_ref input, expected a string or an abstract state instance.")
Beispiel #2
0
def process_fluid_state(fluid_ref, fractions='mole'):
    """Check input for state object or fluid string

    Parameters
    ----------
        fluid_ref : str, CoolProp.AbstractState
        fractions : str, switch to set mass, volu or mole fractions

    Returns
    -------
        CoolProp.AbstractState
    """
    # Process the fluid and set self._state
    if is_string(fluid_ref):
        backend, fluids   = extract_backend(fluid_ref)
        fluids, fractions = extract_fractions(fluids)
        state = AbstractState(backend, '&'.join(fluids))
        if len(fluids) > 1 and len(fluids) == len(fractions):
            if fractions=='mass': state.set_mass_fractions(fractions)
            elif fractions=='volu': state.set_volu_fractions(fractions)
            else: state.set_mole_fractions(fractions)
        return state
    elif isinstance(fluid_ref, AbstractState):
        return fluid_ref
    raise TypeError("Invalid fluid_ref input, expected a string or an abstract state instance.")
Beispiel #3
0
def process_fluid_state(fluid_ref, fractions='mole'):
    """Check input for state object or fluid string

    Parameters
    ----------
        fluid_ref : str, CoolProp.AbstractState
        fractions : str, switch to set mass, volu or mole fractions

    Returns
    -------
        CoolProp.AbstractState
    """
    # Process the fluid and set self._state
    if is_string(fluid_ref):
        backend, fluids = extract_backend(fluid_ref)
        fluids, fractions = extract_fractions(fluids)
        state = AbstractState(backend, '&'.join(fluids))
        if len(fluids) > 1 and len(fluids) == len(fractions):
            if fractions == 'mass': state.set_mass_fractions(fractions)
            elif fractions == 'volu': state.set_volu_fractions(fractions)
            else: state.set_mole_fractions(fractions)
        return state
    elif isinstance(fluid_ref, AbstractState):
        return fluid_ref
    raise TypeError(
        "Invalid fluid_ref input, expected a string or an abstract state instance."
    )