carbatpy.models.cb_fluids.fluid_props
Created on Mon May 22 21:09:12 2023
@author: atakan
Attributes
Classes
Fluid model to be used Refprop or TREND |
|
The thermodynamic state of a fluid is stored here. |
|
The Fluid class is used to set, get, and print states of a fluid with a given |
Functions
|
short way to define a Fluid and a FluidModel |
Module Contents
- class carbatpy.models.cb_fluids.fluid_props.FluidModel(fluid, composition=[1], **kwargs)[source]
Fluid 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.
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. For Refprop: Initiates new instance for each fluid (mixture).
- Parameters:
fluid (String) – as defined in the props (Model), for RefProp it is “fluid1 * fluid2 * fluid3”.
composition (array) – of working fluid (mixture), at this level only used for TREND
**kwargs (dict) –
units, props, rp_inst, eos_ind, mix_ind, trendmodel, props_func (see dataclass FluidModelDefaults). For props=”CUSTOM”, props_func must be a callable with signature:
func(values, given) -> list[T, P, H, V, S, Q, U, ...]
returning SI values (K, Pa, J/kg, m³/kg, J/kg/K, -, J/kg).
- Return type:
None.
- class carbatpy.models.cb_fluids.fluid_props.FluidState(state, what, **kwargs)[source]
The thermodynamic state of a fluid is stored here.
Which properties (T,p,h,v,s,q,…), depends on: carbatpy.CB_DEFAULTS[“Fluid_Defaults”][“Property_Names_Short”]
- class carbatpy.models.cb_fluids.fluid_props.Fluid(fluidmodel, composition=None, option=1)[source]
The 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. The calculated values depend also on carbatpy.CB_DEFAULTS[“Fluid_Defaults”][“Property_Names_Short”].
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.
- set_composition(composition, **kwargs)[source]
Mole fractions are set and mass fractions are calculated.
Sets the self.composition used in the Fluid settings and the self.comp_mass TREND needs the mass fractions for specific (/kg) calculations. Thus calc_mass_fraction() is called.
- Parameters:
composition (list/numpy.array) – mole fractions must sum up to 1.
kwargs (dictionary, optional.) –
verbose : boolean, optional. Generate additional printig. The default is False.
- Return type:
None.
- calc_mole_fraction(comp_mass)[source]
needed for x_liq and y_vap in TREND, therefore mass fraction passed as function argument.
- set_state(values, given='TP', wanted=_THERMO_STRING, composition=None, **kwargs)[source]
Sets the state of a fluid and calculates the wanted properties.
- 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) –
- dll_selectstr, optional
is passed to Refprop. The standard value is “2dll” using the faster REFPROP2dll function, not calculating the composition of different phases. The alternative “dll” is slower but does it. Throughout it is expected that compoitions are mole fractions and qualities in mass/mass.
- i_massint (0/1), optional
should not be used, not tested.
- i_flagint (0/1), optional
should not be used, not tested.
- verboseBoolean, optional
leads to additional (printing) output. The default value is False.
- outputString, optional
what shall be the return value, the “state” as list or an instance of the “FluidState”. default is “state”
- Raises:
Exception – DESCRIPTION.
- Returns:
DESCRIPTION.
- Return type:
TYPE
- set_state_v(values, given='TP', wanted=_THERMO_STRING, **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.
kwargs (dictionary optional) – This is optional and passed to REFPROP or TREND, depending on the props settings / chosen property model. (see set_state())
- Returns:
output – all the wanted properties for the N inputs.
- Return type:
numpy.array(N, n_wanted)
- carbatpy.models.cb_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-defaults shall be set.
- Returns:
actual_fluid – Instance of the actually set Fluid.
- Return type: