示例#1
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.")
示例#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."
    )
示例#3
0
from __future__ import print_function, division, absolute_import

from CoolProp import AbstractState

#fluid = "R407C"
#fluid = "R32[0.381109419953993]&R125[0.179558888662016]&R134A[0.439331691383991]"
#fluid = "R32[0.40]&R125[0.15]&R134A[0.45]"

fluids = ["R32", "R125", "R134a"]
moles = [0.381109419953993, 0.179558888662016, 0.439331691383991]

for backend in ["HEOS", "REFPROP"]:
    state = AbstractState(backend, '&'.join(fluids))
    state.set_mole_fractions(moles)
    print(state.get_mole_fractions())
    print(state.get_mass_fractions())
    try:
        print("Normal routines")
        print(state.T_critical())
        print(state.p_critical())
        print(True)
    except:
        try:
            print("Routine for all points")
            states = state.all_critical_points()
            for crit_state in states:
                print(crit_state.T)
                print(crit_state.p)
                print(crit_state.stable)
        except:
            print("All failed")
示例#4
0
文件: 1118.py 项目: spinnau/coolprop
from __future__ import print_function,division,absolute_import

from CoolProp import AbstractState

#fluid = "R407C"
#fluid = "R32[0.381109419953993]&R125[0.179558888662016]&R134A[0.439331691383991]"
#fluid = "R32[0.40]&R125[0.15]&R134A[0.45]"

fluids = ["R32","R125","R134a"]
moles = [0.381109419953993,0.179558888662016,0.439331691383991]

for backend in ["HEOS","REFPROP"]:
    state = AbstractState(backend, '&'.join(fluids))
    state.set_mole_fractions(moles)
    print(state.get_mole_fractions())
    print(state.get_mass_fractions())
    try:
        print("Normal routines")
        print(state.T_critical())
        print(state.p_critical())
        print(True)
    except:
        try:
            print("Routine for all points")
            states = state.all_critical_points()
            for crit_state in states:
                print(crit_state.T)
                print(crit_state.p)
                print(crit_state.stable)
        except:
示例#5
0
import CoolProp.CoolProp as CoolProp
from CoolProp.HumidAirProp import HAPropsSI
from math import sin
print("**************** INFORMATION ***************")
print("This example was auto-generated by the language-agnostic dev/scripts/example_generator.py script written by Ian Bell")
print("CoolProp version:", get_global_param_string("version"))
print("CoolProp gitrevision:", get_global_param_string("gitrevision"))
print("CoolProp Fluids:", get_global_param_string("FluidsList"))
# See http://www.coolprop.org/coolprop/HighLevelAPI.html#table-of-string-inputs-to-propssi-function for a list of inputs to high-level interface
print("*********** HIGH LEVEL INTERFACE *****************")
print("Critical temperature of water:", PropsSI("Water", "Tcrit"), "K")
print("Boiling temperature of water at 101325 Pa:", PropsSI("T", "P", 101325, "Q", 0, "Water"), "K")
print("Phase of water at 101325 Pa and 300 K:", PhaseSI("P", 101325, "Q", 0, "Water"))
print("c_p of water at 101325 Pa and 300 K:", PropsSI("C", "P", 101325, "T", 300, "Water"), "J/kg/K")
print("c_p of water (using derivatives) at 101325 Pa and 300 K:", PropsSI("d(H)/d(T)|P", "P", 101325, "T", 300, "Water"), "J/kg/K")
print("*********** HUMID AIR PROPERTIES *****************")
print("Humidity ratio of 50% rel. hum. air at 300 K, 101325 Pa:", HAPropsSI("W", "T", 300, "P", 101325, "R", 0.5), "kg_w/kg_da")
print("Relative humidity from last calculation:", HAPropsSI("R", "T", 300, "P", 101325, "W", HAPropsSI("W", "T", 300, "P", 101325, "R", 0.5)), "(fractional)")
print("*********** INCOMPRESSIBLE FLUID AND BRINES *****************")
print("Density of 50% (mass) ethylene glycol/water at 300 K, 101325 Pa:", PropsSI("D", "T", 300, "P", 101325, "INCOMP::MEG-50%"), "kg/m^3")
print("Viscosity of Therminol D12 at 350 K, 101325 Pa:", PropsSI("V", "T", 350, "P", 101325, "INCOMP::TD12"), "Pa-s")
print("*********** LOW-LEVEL INTERFACE *****************")
AS = AbstractState("HEOS", "Water&Ethanol")
z = [0.5, 0.5]
AS.set_mole_fractions(z)
AS.update(CoolProp.PQ_INPUTS, 101325, 1)
print("Normal boiling point temperature of water and ethanol:", AS.T(), "K")
print("*********** TABULAR BACKENDS *****************")
TAB = AbstractState("BICUBIC&HEOS", "R245fa")
TAB.update(CoolProp.PT_INPUTS, 101325, 300)
print("Mass density of refrigerant R245fa at 300 K, 101325 Pa:", TAB.rhomass(), "kg/m^3")