carbatpy.models.cb_fluids.fluid_props

Created on Mon May 22 21:09:12 2023

@author: atakan

Attributes

VERBOSE

DEFAULTS

TREND

FLUID

Classes

FluidModelDefaults

FluidModel

Fluid model to be used Refprop or TREND

FluidState

The thermodynamic state of a fluid is stored here.

Fluid

The Fluid class is used to set, get, and print states of a fluid with a given

Functions

init_fluid(fluid, composition, **keywords)

short way to define a Fluid and a FluidModel

Module Contents

carbatpy.models.cb_fluids.fluid_props.VERBOSE = False[source]
carbatpy.models.cb_fluids.fluid_props.DEFAULTS[source]
carbatpy.models.cb_fluids.fluid_props.TREND[source]
class carbatpy.models.cb_fluids.fluid_props.FluidModelDefaults[source]
units = 21[source]
props = 'REFPROP'[source]
rp_inst = False[source]
eos_ind: List[int] | None = None[source]
eos_ind_default: int = 1[source]
mix_ind = 1[source]
trendmodel = ''[source]
path = ''[source]
dll_path = ''[source]
props_func = None[source]
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.

fluid[source]
props = 'REFPROP'[source]
units = 21[source]
fluid_to_list()[source]

Converts the fluid names string from Refprop to a list for TREND

Returns:

the fluid names in a list.

Return type:

List of strings

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”]

props[source]
verbose[source]
liq_x[source]
vap_y[source]
total_z[source]
state[source]
state_to_dict()[source]

Convert the state properties to a dictionary name:value.

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.

fluidmodel[source]
composition[source]
properties = None[source]
state_v = None[source]
option = 1[source]
no_compounds[source]
comp_mass[source]
herr = 0[source]
props[source]
val_dict[source]
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_mass_fraction()[source]

mole to mass fractions for TREND

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

calc_q_mass(q, liq_x, liq_y)[source]
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)

print_state()[source]

Print the actual state of the Fluid

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

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:

Fluid

carbatpy.models.cb_fluids.fluid_props.FLUID = 'Propane * Pentane'[source]