Fluid Property evaluation (general)¶
At the moment REFPROP (NIST) can be used for property evaluations of pure fluids and mixures, TREND (RU Bochum) usage will be included in near future. They will have to be installed on your system!
First an instance of the Fluid class hast to be generated, for a given fluid model (for now: only RefProp), then the composition and state can be set. The evaluated properties are then available through the FluidState class. In general they are: “Temperature”, “Pressure”, “spec. Enthalpy”, “spec. Volume”, “spec. Entropy”, “quality”, “spec. internal Energy”
Example
import carbatpy as cb
FLUID = "Propane * Pentane"
comp = [.50, 0.5]
# old: set instances of the fluid model and the fluid
flm = cb.fprop.FluidModel(FLUID)
myFluid = cb.fprop.Fluid(flm, comp)
# new: as above
my_Fluid = cb.fprop.init_fluid(FLUID, comp)
st0 = myFluid.set_state([300., 1e5], "TP")
st1 = myFluid.set_state([300., 1e5], "TP", _TRANS_STRING)
print(st0, st1)
myFluid.print_state()
myFluid.set_composition([.2,.8])
st0 = myFluid.set_state([300., 1e5], "TP", composition =[.35, .65])
myFluid.print_state()
Created on Mon May 22 21:09:12 2023
@author: atakan
- class carbatpy.models.fluids.fluid_props.Fluid(fluidmodel, composition=None, option=1)[source]¶
Bases:
objectThe Fluid class is used to set, get, and print states of a fluid with a given
model (e.g. RefProp). The compounds are set in the fluidmodel, while the composition is also set here.
- __init__(fluidmodel, composition=None, option=1)[source]¶
Generate a Fluid instance
a FluidModel instance, the composition and an unused option has to be passed.
- Parameters:
fluidmodel (FluidModel) – the instance of the property model to be used.
composition (list, optional) – mole fractions of all compounds. The default is [1.0].
option (TYPE, optional) – unused. The default is 1.
- Return type:
None.
- calc_temp_mean(h_final)[source]¶
Calculate the thermodynamic mean temperature between the actual state
and the final enthalpy along an isobaric (Delta h /Delta s)
- Parameters:
h_final (float) – enthalpy of he final stat.
- Returns:
temp_mean – the thermodynamic mean temperature.
- Return type:
float
- set_composition(composition)[source]¶
Mainly for TREND mole fractions have to converted to mass fractions
Sets the self.composition used in the Fluid settings and the self.comp_mass and self.comp_mole by calling calc_mass_fraction()
- Parameters:
composition (list/numpy.array) – mole fractions must sum up to 1.
- Return type:
None.
- set_state(values, given='TP', wanted='T;P;H;V;S;QMASS;E', composition=None, **kwargs)[source]¶
Sets the state of a fluid and calculates the wanted
- Parameters:
values (list[2]) – the two state parameter values.
given (String, optional) – What are the two values (T,P,H,S,Q,V). The default is “TP”.
wanted (String, optional) – Which parameters shall be calculated? The default is _THERMO_STRING.
composition (list, optional) – mole fraction of each compound, must sum up to 1. When empty, the last/actual value will be used. The default is [].
kwargs (dictionary, optional) – Flags like iMass or iFlag can be passed to Refprop. with iMass=1 the input composition is taken as mass fraction, otherwise they are mole fractions. iMass is set to 1 if ‘Q’ is in wanted.
- Raises:
Exception – DESCRIPTION.
- Returns:
DESCRIPTION.
- Return type:
TYPE
- set_state_v(values, given='TP', wanted='T;P;H;V;S;QMASS;E', **kwargs)[source]¶
set many Fluid states with the values given as array(vector)
- Parameters:
values (numpy.array((N,2))) – the N value pairs to fix the states.
given (String, optional) – what are the input values?(T,P, Q, S,…). The default is “TP”.
wanted (String, optional) – with all the outputs wanted. The default is _THERMO_STRING.
- Returns:
output – all the wanted properties for the N inputs.
- Return type:
numpy.array(N, n_wanted)
- class carbatpy.models.fluids.fluid_props.FluidModel(fluid, units=21, props='REFPROP', rp_inst='', args={})[source]¶
Bases:
objectFluid model to be used Refprop or TREND
Only model, chemical compunds units and for TREND some more values are set here. The mixture composition, state etc. is set in Fluid.
- __init__(fluid, units=21, props='REFPROP', rp_inst='', args={})[source]¶
For Class Fluidmodell a fluid (mixture) must be defined, the evaluation takes place with props, units can be set and an instance can be set, the latter is important, if more than one fluid is used.
- Parameters:
fluid (String) – as defined in the props (Model), for RefProp it is “fluid1 * fluid2 * fluid3”.
units (integer, optional) – units, normally SI wuth MASS base, see props(RefProp). The default is _UNITS.
props (string, optional) – select the property model. The default is _PROPS.
rp_inst (RefProp-Instance, optional) – where Refprop is installed, for two fluids, as in heat exchangers, two installations/instances are needed. The default is rp_instance.
args (Dictionary, optional) – Further arguments passed to the module used for fluid property evaluation. for props ==”REFPROP” nothing is needed. The default is the empty dictionary _MODEL_ARGS.
- Return type:
None.
- fluid_to_list()[source]¶
conversts the fluid names string from Refprop to list for TREND
- Returns:
the fluid names in a list.
- Return type:
List of strings
- set_rp_fluid(modwf=<function REFPROPFunctionLibrary>, name='RPPREFIX')[source]¶
A new instance of Refpropdll for the given fluid. It can then be called using fluid =””
- Parameters:
fluid (string) – fluid (mixture) name, as described in REFPROP.
- Returns:
self.rp_instance – for further usage.
- Return type:
REFPROP Instance
- carbatpy.models.fluids.fluid_props.init_fluid(fluid, composition, **keywords)[source]¶
short way to define a Fluid and a FluidModel
- Parameters:
fluid (string) – The species within the fluid.
composition (List) – mole fraction for each fluid.
**keywords (TYPE) – all keywords needed for the FluidModel, if non-defults shall be set.
- Returns:
actual_fluid – Instance of the actually set Fluid.
- Return type: