FlowState Base Classes¶
mcycle.bases.flowstate.FlowState (…) |
FlowState represents the state of a flow at a point by its state properties and a mass flow rate. |
mcycle.bases.flowstatepoly.FlowStatePoly (…) |
FlowStatePoly represents the state of a flow at a point by its state properties and a mass flow rate. |
mcycle.bases.flowstatepoly.RefData (…) |
cdef class. RefData stores constant pressure thermodynamic properties of a ‘pure’ fluid or mixture thereof. Property data can be directly input, or, if only temperature data is provided, RefData will call CoolProp to compute the remaining properties. |
FlowState Class¶
-
class
mcycle.bases.flowstate.
FlowState
(unicode fluid, int phaseCP=-1, double m=nan, int inputPairCP=0, double input1=nan, double input2=nan, unicode name=u'FlowState instance')¶ Bases:
mcycle.bases.mcabstractbase.MCAB
FlowState represents the state of a flow at a point by its state properties and a mass flow rate. This class creates a CoolProp AbstractState object to store the state properties and uses the routines of CoolProp.
Parameters: fluid : str
Description of fluid passed to CoolProp.
- “fluid_name” for pure fluid. Eg, “air”, “water”, “CO2” or
- “fluid0[mole_fraction0]&fluid1[mole_fraction1]&…” for mixtures. Eg, “CO2[0.5]&CO[0.5]”.
Note
CoolProp’s mixture routines often raise errors; using mixtures should be avoided.
phaseCP : int, optional
Coolprop key for phase. See documentation. Eg, CoolProp.iphase_gas. Defaults to -1. .. note:: In MCycle, both -1 and 8 can be used for iphase_not_imposed
m : double, optional
Mass flow rate [Kg/s]. Defaults to nan.
inputPairCP : int, optional
CoolProp input pair key. See documentation. Eg. CoolProp.HmassP_INPUTS. Defaults to 0 (INPUT_PAIR_INVALID).
input1, input2 : double, optional
Repective values of inputs corresponding to inputPairCP [in SI units]. Both default to nan.
name : str, optional
Descriptive name of instance. Defaults to “FlowState instance”.
Examples
import mcycle import CoolProp >>> air = FlowState(“air”,-1,1.0,CoolProp.PT_INPUTS,101325,293.15) >>> air.rho() 1.2045751824931508 >>> air.cp() 1006.144032087035
Attributes
fluid
fluid: unicode m
m: ‘double’ name
name: unicode phaseCP
phaseCP: ‘int’ Methods
Pr
(self)double: Prandtl number [-]. T
(self)double: Static temperture [K]. V
(self)double: Volumetric flow rate [m^3/s]. copy
(self, dict kwargs={})Return a new copy of a class object. copyState
(self, int inputPairCP, …)Creates a new copy of a FlowState object. cp
(self)double: Specific mass heat capacity, const. pressure [J/K]. h
(self)double: Specific mass enthalpy [J/Kg]. k
(self)double: Thermal conductivity [W/m.K]. p
(self)double: Static pressure [Pa]. phase
(self)str: identifier of phase; ‘liq’:subcooled liquid, ‘vap’:superheated vapour, ‘satLiq’:saturated liquid, ‘satVap’:saturated vapour, ‘tp’: two-phase liquid/vapour region. rho
(self)double: Mass density [Kg/m^3]. s
(self)double: Specific mass entropy [J/Kg.K]. summary
(self, bool printSummary=True, …)Returns (and prints) a summary of FlowState properties. update
(self, dict kwargs)Update (multiple) class variables from a dictionary of keyword arguments. updateState
(self, int inputPairCP, …)Calls CoolProp’s AbstractState.update function. v
(self)double: Specific volume [m^3/Kg]. visc
(self)double: Dynamic viscosity [N.s/m^2]. x
(self)double: Quality [-]. -
Pr
(self) → double¶ double: Prandtl number [-].
Note
Linear interpolation in 2-phase region is used due to non-continuities in CoolProp’s routines.
-
T
(self) → double¶ double: Static temperture [K].
-
V
(self) → double¶ double: Volumetric flow rate [m^3/s].
-
copy
(self, dict kwargs={})¶ Return a new copy of a class object. Kwargs (as dict) are passed to update() as a shortcut of simultaneously copying and updating.
Parameters: kwargs : dict, optional
Dictionary of attributes and their updated value.
-
copyState
(self, int inputPairCP, double input1, double input2) → FlowState¶ Creates a new copy of a FlowState object. As a shortcut, args can be passed to update the object copy (see update()).
Parameters: inputPairCP : int, optional
CoolProp input pair key. See documentation. Eg. CoolProp.HmassP_INPUTS. Defaults to None.
input1, input2 : double, optional
Repective values of inputs corresponding to inputPairCP [in SI units]. Both default to None.
-
cp
(self) → double¶ double: Specific mass heat capacity, const. pressure [J/K].
Note
Linear interpolation in 2-phase region is used due to non-continuities in CoolProp’s routines.
-
fluid
¶ fluid: unicode
-
h
(self) → double¶ double: Specific mass enthalpy [J/Kg].
-
k
(self) → double¶ double: Thermal conductivity [W/m.K].
-
m
¶ m: ‘double’
-
name
¶ name: unicode
-
p
(self) → double¶ double: Static pressure [Pa].
-
phase
(self) → unicode¶ str: identifier of phase; ‘liq’:subcooled liquid, ‘vap’:superheated vapour, ‘satLiq’:saturated liquid, ‘satVap’:saturated vapour, ‘tp’: two-phase liquid/vapour region.
-
phaseCP
¶ phaseCP: ‘int’
-
rho
(self) → double¶ double: Mass density [Kg/m^3].
-
s
(self) → double¶ double: Specific mass entropy [J/Kg.K].
-
summary
(self, bool printSummary=True, unicode name=u'', int rstHeading=0)¶ Returns (and prints) a summary of FlowState properties.
Parameters: printSummary : bool, optional
If true, the summary string is printed as well as returned. Defaults to True.
name : str, optional
Name of the object, prepended to the summary heading. If None, the class name is used. Defaults to None.
-
update
(self, dict kwargs) → void¶ Update (multiple) class variables from a dictionary of keyword arguments.
Parameters: kwargs : dict
Dictionary of attributes and their updated value; kwargs={‘key’: value}.
-
updateState
(self, int inputPairCP, double input1, double input2) → void¶ Calls CoolProp’s AbstractState.update function.
Parameters: inputPairCP : int, optional
CoolProp input pair key. See documentation. Eg. CoolProp.HmassP_INPUTS.
input1, input2 : double
Repective values of inputs corresponding to inputPairCP [in SI units]. Both default to None.
-
v
(self) → double¶ double: Specific volume [m^3/Kg].
-
visc
(self) → double¶ double: Dynamic viscosity [N.s/m^2].
-
x
(self) → double¶ double: Quality [-].
FlowStatePoly Class¶
-
class
mcycle.bases.flowstatepoly.
FlowStatePoly
(RefData refData, double m=nan, int inputPairCP=0, double input1=nan, double input2=nan, unicode name=u'FlowStatePoly instance')¶ Bases:
mcycle.bases.flowstate.FlowState
FlowStatePoly represents the state of a flow at a point by its state properties and a mass flow rate. It is an alternative to FlowState that uses polynomial interpolation of a crude constant pressure reference data map to evaluate the state properties, instead of calling them from a CoolProp AbstractState object. This class was created purely to overcome short comings with CoolProp’s mixture processes. Apart from creating new objects, FlowStatePoly has been built to be used in exactly the same way as FlowState.
Note
FlowStatePoly only supports constant pressure flows and assumes no phase changes occur. It may not be used for the working fluid in a cycle, but may be used as the working fluid in certain constant pressure components.
Parameters: refData : RefData
Constant pressure fluid reference data map.
m : double, optional
Mass flow rate [Kg/s]. Defaults to nan.
inputPairCP : int, optional
CoolProp input pair key. See documentation. Eg. CoolProp.HmassP_INPUTS. Defaults to INPUT_PAIR_INVALID == 0.
Note
Only certain inputPairCP values are valid. As FlowStatePoly only supports constant pressure flows, one input variable must be a pressure. Thus, only the following inputPairCP values are valid:
- CoolProp.PT_INPUTS == 9
- CoolProp.DmassP_INPUTS == 18
- CoolProp.HmassP_INPUTS == 20
- CoolProp.PSmass_INPUTS == 22
input1,input2 : double, optional
Repective values of inputs corresponding to inputPairCP [in SI units]. Both default to nan.
Examples
>>> refData = RefData("air", 2, 101325., [200, 250, 300, 350, 400]) >>> air = FlowStatePoly(refData, 1, CoolProp.PT_INPUTS,101325.,293.15) >>> air.rho 1.20530995019 >>> air.cp 1006.12622976
Attributes
fluid
fluid: unicode m
m: ‘double’ name
name: unicode phaseCP
phaseCP: ‘int’ refData
refData: mcycle.bases.flowstatepoly.RefData Methods
Pr
(self)double: Prandtl number [-]. T
(self)double: Static temperture [K]. V
(self)double: Volumetric flow rate [m^3/s]. copy
(self, dict kwargs={})Return a new copy of a class object. copyState
(self, int inputPairCP, …)Creates a new copy of a FlowState object. cp
(self)double: Specific mass heat capacity, const. pressure [J/K]. h
(self)double: Specific mass enthalpy [J/Kg]. k
(self)double: Thermal conductivity [W/m.K]. p
(self)double: Static pressure [Pa]. phase
(self)str: identifier of phase; ‘liq’:subcooled liquid, ‘vap’:superheated vapour, ‘sp’: unknown single-phase. populate_c
(self)rho
(self)double: Mass density [Kg/m^3]. s
(self)double: Specific mass entropy [J/Kg.K]. summary
(self, bool printSummary=True, …)Returns (and prints) a summary of FlowState properties. update
(self, dict kwargs)Update (multiple) class variables from a dictionary of keyword arguments. updateState
(self, int inputPairCP, …)void: Calls CoolProp’s AbstractState.update function. v
(self)double: Specific volume [m^3/Kg]. visc
(self)double: Dynamic viscosity [N.s/m^2]. x
(self)double: Quality [-]. By definition, x = -1 for all FlowStatePoly objects. -
Pr
(self) → double¶ double: Prandtl number [-].
-
T
(self) → double¶ double: Static temperture [K].
-
V
(self) → double¶ double: Volumetric flow rate [m^3/s].
-
copy
(self, dict kwargs={})¶ Return a new copy of a class object. Kwargs (as dict) are passed to update() as a shortcut of simultaneously copying and updating.
Parameters: kwargs : dict, optional
Dictionary of attributes and their updated value.
-
copyState
(self, int inputPairCP, double input1, double input2) → FlowState¶ Creates a new copy of a FlowState object. As a shortcut, args can be passed to update the object copy (see update()).
Parameters: inputPairCP : int, optional
CoolProp input pair key. See documentation. Eg. CoolProp.HmassP_INPUTS. Defaults to None.
input1, input2 : double, optional
Repective values of inputs corresponding to inputPairCP [in SI units]. Both default to None.
-
cp
(self) → double¶ double: Specific mass heat capacity, const. pressure [J/K].
-
fluid
¶ fluid: unicode
-
h
(self) → double¶ double: Specific mass enthalpy [J/Kg].
-
k
(self) → double¶ double: Thermal conductivity [W/m.K].
-
m
¶ m: ‘double’
-
name
¶ name: unicode
-
p
(self) → double¶ double: Static pressure [Pa].
-
phase
(self) → unicode¶ str: identifier of phase; ‘liq’:subcooled liquid, ‘vap’:superheated vapour, ‘sp’: unknown single-phase.
-
phaseCP
¶ phaseCP: ‘int’
-
populate_c
(self) → void¶
-
refData
¶ refData: mcycle.bases.flowstatepoly.RefData
-
rho
(self) → double¶ double: Mass density [Kg/m^3].
-
s
(self) → double¶ double: Specific mass entropy [J/Kg.K].
-
summary
(self, bool printSummary=True, unicode name=u'', int rstHeading=0)¶ Returns (and prints) a summary of FlowState properties.
Parameters: printSummary : bool, optional
If true, the summary string is printed as well as returned. Defaults to True.
name : str, optional
Name of the object, prepended to the summary heading. If None, the class name is used. Defaults to None.
-
update
(self, dict kwargs) → void¶ Update (multiple) class variables from a dictionary of keyword arguments.
Parameters: kwargs : dict
Dictionary of attributes and their updated value; kwargs={‘key’: value}.
-
updateState
(self, int inputPairCP, double input1, double input2) → void¶ void: Calls CoolProp’s AbstractState.update function.
Parameters: inputPairCP : int, optional
CoolProp input pair key. See documentation. Eg. CoolProp.HmassP_INPUTS.
input1,input2 : double
Repective values of inputs corresponding to inputPairCP [in SI units]. One input must be equal to the pressure of refData. Both default to None.
-
v
(self) → double¶ double: Specific volume [m^3/Kg].
-
visc
(self) → double¶ double: Dynamic viscosity [N.s/m^2].
-
x
(self) → double¶ double: Quality [-]. By definition, x = -1 for all FlowStatePoly objects.
-
class
mcycle.bases.flowstatepoly.
RefData
(unicode fluid, int deg, double p, dict data, int phaseCP=-1)¶ Bases:
object
cdef class. RefData stores constant pressure thermodynamic properties of a ‘pure’ fluid or mixture thereof. Property data can be directly input, or, if only temperature data is provided, RefData will call CoolProp to compute the remaining properties.
Parameters: fluid : str
Description of fluid passed to CoolProp.
- “fluid_name” for pure fluid. Eg, “air”, “water”, “CO2” or
- “fluid0[mole_fraction0]&fluid1[mole_fraction1]&…” for mixtures. Eg, “CO2[0.5]&CO[0.5]”.
Note
CoolProp’s mixture routines often raise errors; using mixtures should be avoided.
deg : int
Polynomial degree used to fit the data using numpy.polyfit. If -1, properties will be linearly interpolated between the data values using numpy.interp.
p: double
Constant static pressure [Pa] of the property data.
data : dict
Dictionary of data map values. Data must be given as a list of floats for each of the following keys:
- ‘T’ : static temperature [K].
- ‘h’ : specific mass enthalpy [J/Kg].
- ‘rho’ : mass density [Kg/m^3].
- ‘s’ : specific mass entropy [J/Kg.K].
- ‘visc’ : dynamic viscosity [N.s/m^2].
- ‘k’ : thermal conductivity [W/m.K].
- ‘cp’ : specific mass heat capacity, const. pressure [J/K].
- ‘Pr’ : Prandtl number.
A complete map must be provided or if only temperature values are provided, MCycle will attempt to populate the data using CoolProp.
phaseCP : int, optional
Coolprop key for phase. See documentation. Eg, CoolProp.iphase_gas. Defaults to -1.
Attributes
data
data: dict deg
deg: ‘int’ fluid
fluid: unicode p
p: ‘double’ phaseCP
phaseCP: ‘int’ Methods
populateData
(self)void: Populate property data list from data[‘T’] using CoolProp. -
data
¶ data: dict
-
deg
¶ deg: ‘int’
-
fluid
¶ fluid: unicode
-
p
¶ p: ‘double’
-
phaseCP
¶ phaseCP: ‘int’
-
populateData
(self) → void¶ void: Populate property data list from data[‘T’] using CoolProp.