当前位置: 首页>>代码示例>>Python>>正文


Python CoolProp.CoolProp类代码示例

本文整理汇总了Python中CoolProp.CoolProp的典型用法代码示例。如果您正苦于以下问题:Python CoolProp类的具体用法?Python CoolProp怎么用?Python CoolProp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CoolProp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: teest_1phase_first_derivatives

def teest_1phase_first_derivatives():

    for US in [CoolProp.UNIT_SYSTEM_SI, CoolProp.UNIT_SYSTEM_KSI]:
        CP.set_standard_unit_system(US)

        S = State("R134a", dict(T=300, D=1))

        l = [
            (S.get_rho, "T", S.T, "P", S.p, S.PFC.drhodT_constp),
            (S.get_rho, "P", S.p, "T", S.T, S.PFC.drhodp_constT),
            (S.get_p, "D", S.rho, "T", S.T, S.PFC.dpdrho_constT),
            # (S.get_p,'D',S.rho,'H',S.h,S.PFC.dpdrho_consth), #(these inputs not supported)
            (S.get_p, "T", S.T, "D", S.rho, S.PFC.dpdT_constrho),
            # (S.get_p,'T',S.T,'H',S.h,S.PFC.dpdT_consth),     #(these inputs not supported)
            (S.get_h, "D", S.rho, "T", S.T, S.PFC.dhdrho_constT),
            (S.get_h, "D", S.rho, "P", S.p, S.PFC.dhdrho_constp),
            (S.get_h, "T", S.T, "D", S.rho, S.PFC.dhdT_constrho),
            (S.get_h, "T", S.T, "P", S.p, S.PFC.dhdT_constp),
            (S.get_h, "P", S.p, "T", S.T, S.PFC.dhdp_constT),
            (S.get_s, "D", S.rho, "T", S.T, S.PFC.dsdrho_constT),
            (S.get_s, "T", S.T, "D", S.rho, S.PFC.dsdT_constrho),
            (S.get_s, "D", S.rho, "P", S.p, S.PFC.dsdrho_constp),
            (S.get_s, "T", S.T, "P", S.p, S.PFC.dsdT_constp),
            (S.get_s, "P", S.p, "T", S.T, S.PFC.dsdp_constT),
        ]
        for args in l:
            yield (check_1phase_first_derivatives,) + (S,) + args
开发者ID:CoolProp,项目名称:CoolProp-museum,代码行数:27,代码来源:test_CoolPropState.py

示例2: test_State_PROPS

def test_State_PROPS():
    for parameter, SI_over_kSI in State_Props_listing:
        
        CP.set_standard_unit_system(CoolProp.unit_systems_constants.UNIT_SYSTEM_SI)
        val_SI = S.Props(parameter)
        
        CP.set_standard_unit_system(CoolProp.unit_systems_constants.UNIT_SYSTEM_KSI)
        val_kSI = S.Props(parameter)
        
        yield check, val_SI, val_kSI, SI_over_kSI
开发者ID:EdwinSoft,项目名称:coolprop,代码行数:10,代码来源:test_Units_CPState.py

示例3: draw_process

    def draw_process(self, states, line_opts={'color' : 'r', 'lw' : 1.5}):
        """ Draw process or cycle from list of State objects

        Parameters
        ----------
        states : list
            List of CoolProp.State.State objects
        line_opts : dict
            Line options (please see :func:`matplotlib.pyplot.plot`), Optional

        """

        # plot above other lines
        line_opts['zorder'] = 10

        for i, state in enumerate(states):
            if state.Fluid != self.fluid_ref:
                raise ValueError('Fluid [{0}] from State object does not match PropsPlot fluid [{1}].'.format(state.Fluid, self.fluid_ref))

            if i == 0: continue

            S2 = states[i]
            S1 = states[i-1]
            iso = False

            y_name, x_name = self.graph_type.lower().replace('t', 'T')

            x1 = getattr(S1, x_name)
            x2 = getattr(S2, x_name)
            y1 = getattr(S1, y_name)
            y2 = getattr(S2, y_name)

            # search for equal properties between states
            for iso_type in ['p', 'T', 's', 'h', 'rho']:
                if getattr(S1, iso_type) == getattr(S2, iso_type):
                    axis_limits = [[x1, x2], [y1, y2]]
                    self.draw_isolines(iso_type.upper(), [getattr(S1, iso_type)],
                                       num=1, units='kSI', line_opts=line_opts,
                                       axis_limits=axis_limits)
                    iso = True
                    break

            # connect states with straight line
            if not iso:
                # convert values to SI for plotting
                x_val = [CP.toSI(x_name.upper(), x1, 'kSI'),
                         CP.toSI(x_name.upper(), x2, 'kSI')]
                y_val = [CP.toSI(y_name.upper(), y1, 'kSI'),
                         CP.toSI(y_name.upper(), y2, 'kSI')]
                self.axis.plot(x_val, y_val, **line_opts)
开发者ID:spymate,项目名称:coolprop,代码行数:50,代码来源:Plots.py

示例4: CriticalIsotherm

def CriticalIsotherm(Fluid):
    
    return textwrap.dedent(
    """
    Along the critical isotherm where T=T\ :sub:`c`
    ================================================
    .. plot::
    
        Fluid = "{Fluid:s}"
        RPFluid = "{RPFluid:s}"
        
        #Critical isotherm
        from CoolProp.CoolProp import Props
        from numpy import linspace,array,abs
        import matplotlib.pyplot as plt

        Tc = Props(Fluid,'Tcrit')
        rhoc = Props(Fluid,'rhocrit')
        rhov = linspace(1e-12,2*rhoc)

        #All the CoolProp calculations
        p = array([Props('P','T',Tc,'D',D,Fluid) for D in rhov])
        rho = array([Props('D','T',Tc,'D',D,Fluid) for D in rhov])
        cp = array([Props('C','T',Tc,'D',D,Fluid) for D in rhov])
        cv = array([Props('O','T',Tc,'D',D,Fluid) for D in rhov])
        h0 = Props('H','T',0.95*Tc,'Q',1,Fluid)
        h = array([Props('H','T',Tc,'D',D,Fluid)-h0 for D in rhov])
        s0 = Props('S','T',0.95*Tc,'Q',1,Fluid)
        s = array([Props('S','T',Tc,'D',D,Fluid)-s0 for D in rhov])
        visc = array([Props('V','T',Tc,'D',D,Fluid) for D in rhov])
        cond = array([Props('L','T',Tc,'D',D,Fluid) for D in rhov])
            
        Rp = array([Props('P','T',Tc,'D',D,RPFluid) for D in rhov])
        Rrho = array([Props('D','T',Tc,'D',D,RPFluid) for D in rhov])
        Rcp = array([Props('C','T',Tc,'D',D,RPFluid) for D in rhov])
        Rcv = array([Props('O','T',Tc,'D',D,RPFluid) for D in rhov])
        Rh0 = Props('H','T',0.95*Tc,'Q',1,RPFluid)
        Rh = array([Props('H','T',Tc,'D',D,RPFluid)-Rh0 for D in rhov])
        Rs0 = Props('S','T',0.95*Tc,'Q',1,RPFluid)
        Rs = array([Props('S','T',Tc,'D',D,RPFluid)-Rs0 for D in rhov])
        Rvisc = array([Props('V','T',Tc,'D',D,RPFluid) for D in rhov])
        Rcond = array([Props('L','T',Tc,'D',D,RPFluid) for D in rhov])
            
        fig = plt.figure()

        ax = fig.add_axes((0.15,0.15,0.8,0.8))
        ax.semilogy(rhov/rhoc,abs(p/Rp-1)*100,'o',label='Pressure')
        ax.semilogy(rhov/rhoc,abs(cp/Rcp-1)*100,'o',label='Specific heat (cp)')
        ax.semilogy(rhov/rhoc,abs(cv/Rcv-1)*100,'o',label='Specific heat (cv)')
        ax.semilogy(rhov/rhoc,abs(h/Rh-1)*100,'o',label='Enthalpy')
        ax.semilogy(rhov/rhoc,abs(s/Rs-1)*100,'o',label='Entropy') 
        ax.semilogy(rhov/rhoc,abs(visc/Rvisc-1)*100,'^',label='Viscosity')
        ax.semilogy(rhov/rhoc,abs(cond/Rcond-1)*100,'s',label='Conductivity')
        ax.set_ylim(1e-16,100)
        ax.set_title('Critical isotherm Deviations from REFPROP 9.1')
        ax.set_xlabel(r'Reduced density $\\rho/\\rho_c$')
        ax.set_ylabel('Absolute deviation [%]')
        ax.legend(numpoints=1,loc='best')
        plt.show()
    """.format(Fluid=Fluid,RPFluid = 'REFPROP-'+CP.get_REFPROPname(Fluid)))
开发者ID:ghobold,项目名称:coolprop,代码行数:60,代码来源:FluidInfoGenerator.py

示例5: test_sat_second_derivatives

def test_sat_second_derivatives():
    for US in [CoolProp.UNIT_SYSTEM_SI, CoolProp.UNIT_SYSTEM_KSI]:
        CP.set_standard_unit_system(US)
        
        S = State('R134a',dict(T=300,Q=1))
        
        l = [(S.get_T,'P',S.p,'Q',0,S.PFC.d2Tdp2_along_sat),
             (S.get_rho,'P',S.p,'Q',0,S.PFC.d2rhodp2_along_sat_liquid),
             (S.get_rho,'P',S.p,'Q',1,S.PFC.d2rhodp2_along_sat_vapor),
             (S.get_h,'P',S.p,'Q',0,S.PFC.d2hdp2_along_sat_liquid),
             (S.get_h,'P',S.p,'Q',1,S.PFC.d2hdp2_along_sat_vapor),
             (S.get_s,'P',S.p,'Q',0,S.PFC.d2sdp2_along_sat_liquid),
             (S.get_s,'P',S.p,'Q',1,S.PFC.d2sdp2_along_sat_vapor),
            ]
        for args in l:
            yield (check_sat_second_derivatives,)+(S,)+args
开发者ID:ghobold,项目名称:coolprop,代码行数:16,代码来源:test_CoolPropState.py

示例6: check_Props

def check_Props(parameter, SI_over_kSI):
    
    CP.set_standard_unit_system(CoolProp.unit_systems_constants.UNIT_SYSTEM_SI)
    val_SI = CP.Props(parameter,'T',300.0,'D',1.0,'R134a')
    
    CP.set_standard_unit_system(CoolProp.unit_systems_constants.UNIT_SYSTEM_KSI)
    val_kSI = CP.Props(parameter,'T',300.0,'D',1.0,'R134a')
    
    try:
        val_SI = val_SI()
        val_kSI = val_kSI()
    except:
        pass
            
    print val_SI,val_kSI, val_SI/val_kSI - SI_over_kSI
    if abs(val_SI/val_kSI - SI_over_kSI) > 1e-12:
        raise ValueError(val_SI/val_kSI-SI_over_kSI)
开发者ID:EdwinSoft,项目名称:coolprop,代码行数:17,代码来源:test_Units_CPState.py

示例7: drawIsoLines

def drawIsoLines(Ref, plot, which, iValues=[], num=0, show=False, axis=None, units='kSI', line_opts=None):
    """
    Draw lines with constant values of type 'which' in terms of x and y as
    defined by 'plot'. 'iMin' and 'iMax' are minimum and maximum value
    between which 'num' get drawn.

    :Note:
        :func:`CoolProps.Plots.drawIsoLines` will be depreciated in future
        releases and replaced with :func:`CoolProps.Plots.IsoLines`

    Parameters
    -----------
    Ref : str
        The given reference fluid
    plot : str
        The plot type used
    which : str
        The iso line type
    iValues : list
        The list of constant iso line values
    num : int, Optional
        The number of iso lines
        (Default: 0 - Use iValues list only)
    show : bool, Optional
        Show the current plot
        (Default: False)
    axis : :func:`matplotlib.pyplot.gca()`, Optional
        The current axis system to be plotted to.
        (Default: create a new axis system)
    units : str
        Unit system of the input data ('kSI' or 'SI'), Optional
    line_opts : dict
        Line options (please see :func:`matplotlib.pyplot.plot`), Optional

    Examples
    --------
    >>> from matplotlib import pyplot
    >>> from CoolProp.Plots import Ts, drawIsoLines
    >>>
    >>> Ref = 'n-Pentane'
    >>> ax = Ts(Ref)
    >>> ax.set_xlim([-0.5, 1.5])
    >>> ax.set_ylim([300, 530])
    >>> quality = drawIsoLines(Ref, 'Ts', 'Q', [0.3, 0.5, 0.7, 0.8], axis=ax)
    >>> isobars = drawIsoLines(Ref, 'Ts', 'P', [100, 2000], num=5, axis=ax)
    >>> isochores = drawIsoLines(Ref, 'Ts', 'D', [2, 600], num=7, axis=ax)
    >>> pyplot.show()
    """

    # convert input data to SI units for internal use
    iValues = CP.toSI(which, iValues, units)

    isolines = IsoLines(Ref, plot, which, axis=axis)
    lines = isolines.draw_isolines(iValues, num=num, line_opts=line_opts)
    if show:
        isolines.show()
    return lines
开发者ID:spymate,项目名称:coolprop,代码行数:57,代码来源:Plots.py

示例8: teest_sat_first_derivatives

def teest_sat_first_derivatives():

    for US in [CoolProp.UNIT_SYSTEM_SI, CoolProp.UNIT_SYSTEM_KSI]:
        CP.set_standard_unit_system(US)

        S = State("R134a", dict(T=300, Q=1))

        l = [
            (S.get_T, "P", S.p, "Q", 0, S.PFC.dTdp_along_sat),
            (S.get_rho, "P", S.p, "Q", 0, S.PFC.drhodp_along_sat_liquid),
            (S.get_rho, "P", S.p, "Q", 1, S.PFC.drhodp_along_sat_vapor),
            (S.get_rho, "T", S.T, "Q", 0, S.PFC.drhodT_along_sat_liquid),
            (S.get_rho, "T", S.T, "Q", 1, S.PFC.drhodT_along_sat_vapor),
            (S.get_h, "P", S.p, "Q", 0, S.PFC.dhdp_along_sat_liquid),
            (S.get_h, "P", S.p, "Q", 1, S.PFC.dhdp_along_sat_vapor),
            (S.get_s, "P", S.p, "Q", 0, S.PFC.dsdp_along_sat_liquid),
            (S.get_s, "P", S.p, "Q", 1, S.PFC.dsdp_along_sat_vapor),
        ]
        for args in l:
            yield (check_sat_first_derivatives,) + (S,) + args
开发者ID:CoolProp,项目名称:CoolProp-museum,代码行数:20,代码来源:test_CoolPropState.py

示例9: get_global_param_string

    def get_global_param_string(self, param_name, split=False):
        """Get global parameter string from CoolProp.

        The split option was added for convenience and can be used to output
        comma separated values as a column vector in Calc. Thus, the function
        can be directly used as input for dropdown fields.
        """
        try:
            param_str = CoolProp.get_global_param_string(param_name)
            if split:
                return zip(param_str.split(','))
            else:
                return [[param_str]]
        except Exception as e:
            return [[str(e)]]
开发者ID:CoolProp,项目名称:CoolProp,代码行数:15,代码来源:coolprop.py

示例10: get_update_pair

    def get_update_pair(self):
        """Processes the values for the isoproperty and the graph dimensions
        to figure which should be used as inputs to the state update. Returns
        a tuple with the indices for the update call and the property constant.
        For an isobar in a Ts-diagram it returns the default order and the 
        correct constant for the update pair:
        get_update_pair(CoolProp.iP,CoolProp.iSmass,CoolProp.iT) -> (0,1,2,CoolProp.PSmass_INPUTS)
        other values require switching and swapping.
        """
        # Figure out if x or y-dimension should be used
        switch = self.XY_SWITCH[self.i_index][self.y_index*10+self.x_index]

        if switch is None:
            raise ValueError("This isoline cannot be calculated!")
        elif switch is False:
            pair, out1, _ = CP.generate_update_pair(self.i_index,0.0,self.x_index,1.0)
        elif switch is True:
            pair, out1, _ = CP.generate_update_pair(self.i_index,0.0,self.y_index,1.0)
        else:
            raise ValueError("Unknown error!")

        if out1==0.0: # Correct order
            swap = False
        else: # Wrong order
            swap = True

        if not switch and not swap:
            return 0,1,2,pair
        elif switch and not swap:
            return 0,2,1,pair
        elif not switch and swap:
            return 1,0,2,pair
        elif switch and swap:
            return 1,2,0,pair
        else:
            raise ValueError("Check the code, this should not happen!")
开发者ID:spinnau,项目名称:coolprop,代码行数:36,代码来源:Common.py

示例11: params_table

def params_table(Fluid):
    params = dict(mm = CP.Props(Fluid,'molemass'),
                  Tt = CP.Props(Fluid,'Ttriple'),
                  pt = CP.Props(Fluid,'ptriple'),
                  Tmin = CP.Props(Fluid,'Tmin'),
                  CAS = CP.get_CAS_code(Fluid),
                  ASHRAE = CP.get_ASHRAE34(Fluid)
                  )
    
    return textwrap.dedent(
    """
    Fluid Data
    ==========
        
    Fluid Parameters
    
    =========================  ==============================
    Mole Mass [kg/kmol]        {mm:0.5f}
    Triple Point Temp. [K]     {Tt:0.3f}
    Triple Point Press. [kPa]  {pt:0.10g}
    Minimum temperature [K]    {Tmin:0.3f}
    CAS number                 {CAS:s}
    ASHRAE classification      {ASHRAE:s}
    =========================  ==============================
    """.format(**params))
开发者ID:ghobold,项目名称:coolprop,代码行数:25,代码来源:FluidInfoGenerator.py

示例12: draw_isolines

    def draw_isolines(self, iso_type, iso_range, num=10, rounding=False,
                      units='kSI', line_opts=None, axis_limits=None):
        """ Create isolines

        Parameters
        ----------
        iso_type : str
            Type of the isolines
        iso_range : list
            Range between isolines will be created [min, max]
        num : int
            Number of the isolines within range, Optional
        units : str
            Unit system of the input data ('kSI' or 'SI'), Optional
        line_opts : dict
            Line options (please see :func:`matplotlib.pyplot.plot`), Optional
        axis_limits : list
            Limits for drawing isolines [[xmin, xmax], [ymin, ymax]], Optional

        """

        # convert input data to SI units for internal use
        iso_range = CP.toSI(iso_type, iso_range, units)
        if axis_limits is not None:
            axis_limits = [CP.toSI(self.graph_type[1].upper(), axis_limits[0], units),
                           CP.toSI(self.graph_type[0].upper(), axis_limits[1], units),
                          ]

        iso_lines = IsoLines(self.fluid_ref,
                             self.graph_type,
                             iso_type,
                             axis=self.axis)
        iso_lines.draw_isolines(iso_range, num, rounding, line_opts, axis_limits)
开发者ID:spymate,项目名称:coolprop,代码行数:33,代码来源:Plots.py

示例13: scale_plot

    def scale_plot(self, units='kSI'):
        """ Scale plot axis with units system

        Fluid properties are calculated in SI units for internal use. Axis ticks
        of the plot can be scaled to show data in other unit systems.
        """

        xscale = CP.fromSI(self.graph_type[1], 1, units)
        yscale = CP.fromSI(self.graph_type[0], 1, units)

        x_fmt = matplotlib.ticker.FuncFormatter(lambda x, pos: '{0:g}'.format(x*xscale))
        y_fmt = matplotlib.ticker.FuncFormatter(lambda y, pos: '{0:g}'.format(y*yscale))

        self.axis.xaxis.set_major_formatter(x_fmt)
        self.axis.yaxis.set_major_formatter(y_fmt)
开发者ID:Lebevc,项目名称:coolprop,代码行数:15,代码来源:Common.py

示例14: _get_index

def _get_index(prop):
    if is_string(prop):
        return CP.get_parameter_index(prop)
    elif isinstance(prop, int):
        return prop
    else:
        raise ValueError("Invalid input, expected a string or an int, not {0:s}.".format(str(prop)))
开发者ID:spinnau,项目名称:coolprop,代码行数:7,代码来源:Common.py

示例15: draw_isolines

 def draw_isolines(self, iso_type, iso_range, num=10, rounding=False, units='kSI'):
     # convert range to SI units for internal use
     iso_range = CP.toSI(iso_type, iso_range, units)
     iso_lines = IsoLines(self.fluid_ref,
                          self.graph_type,
                          iso_type,
                          axis=self.axis)
     iso_lines.draw_isolines(iso_range, num, rounding)
开发者ID:Lebevc,项目名称:coolprop,代码行数:8,代码来源:Plots.py


注:本文中的CoolProp.CoolProp类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。