carbatpy

Top-level package for carbatpy.

Subpackages

Submodules

Attributes

__author__

__email__

__version__

Classes

Fluid

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

FluidModel

Fluid model to be used Refprop or TREND

FlowDevice

Unified themodynamic calculations for single flow devices

Functions

init_fluid(fluid, composition, **keywords)

short way to define a Fluid and a FluidModel

Package Contents

carbatpy.__author__ = 'Burak Atakan'[source]
carbatpy.__email__ = 'burak.atakan@uni-due.de'[source]
carbatpy.__version__[source]
class carbatpy.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.

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.

calc_mass_fraction()[source]

mole to mass fractions for TREND

set_state(values, given='TP', wanted=_THERMO_STRING, 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

_update_composition(composition)[source]
_set_state_refprop(values, given, wanted, composition, **kwargs)[source]
_set_state_trend(values, given, wanted)[source]
_adjust_trend_values(values, given)[source]
_adjust_values_for_quality_pressure(values, quality_in, pressure_in)[source]
_adjust_values_for_quality_temperature(values, quality_in, temp_in)[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.

Returns:

output – all the wanted properties for the N inputs.

Return type:

numpy.array(N, n_wanted)

_set_fluid_properties(state, wanted, **kwargs)[source]

The thermodynamic state of a fluid is stored here

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

class carbatpy.FluidModel(fluid, units=_UNITS, props=_PROPS, rp_inst=rp_instance, args=_MODEL_ARGS)[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.

set_rp_fluid(modwf=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

set_tr_fluid()[source]
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

carbatpy.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:

Fluid

class carbatpy.FlowDevice(fluid, p_out, m_dot, device_type='machine', **kwargs)[source]

Unified themodynamic calculations for single flow devices

compressor()[source]

compressor or expander output state calculation

so far only for a constant isentropic efficiency, according to the pressure change an expansion or compression is detected and handled.

Parameters:
  • p_out (float) – output pressure.

  • eta_s (float) – isentropic efficiency.

  • fluid (fprop.Fluid) – entering fluid, including properties, composition, and model.

  • m_dot (float, optional) – mass flow rate (in kg/s). Default is 1

  • calc_type (string, optional) – how to calculate, so far, only one implemented. The default is “const_eta”.

  • name (string, optional) – name of the device. The default is “compressor”.

  • plot_info (dictionary, optional) – if not empty a Figure, an Axes, a list of What shall be plotted, a list with the colour/styles and a list with the labels must be passed. in “what”, the two numbers coincide with the fluid THERMO order. The x-shift can be used in cycle calculations, to shift the curves, by the value (it will be added). The names in the dictionary are: “fig”, “ax”, “what”,”col”, “label”, “x-shift”. Default is empty.

Returns:

  • state_out (array of float) – compressor output state containing [T,p,h,v,s,q].

  • work_specific (float) – work per kg of fluid, positive for compressor; units:J/kg.

pump()[source]

Calculate the exit state of a pump assuming an incompressible fluid.

Only formulated for constant isentropic efficiency

Parameters:
  • p_out (float) – output pressure.

  • eta_s (float) – isentropic efficiency.

  • fluid (fprop.Fluid) – entering fluid, including properties, composition, and model.

  • m_dot (float, optional) – mass flow rate (in kg/s). Default is 1

  • calc_type (string, optional) – how to calculate, so far, only one implemented. The default is “const_eta”.

  • name (string, optional) – name of the device. The default is “pump”.

  • plot_info (dictionary, optional) – if not empty a Figure, an Axes, a list of What shall be plotted, a list with the colour/styles and a list with the labels must be passed. in “what”, the two numbers coincide with the fluid THERMO order. The x-shift can be used in cycle calculations, to shift the curves, by the value (it will be added). The names in the dictionary are: “fig”, “ax”, “what”,”col”, “label”, “x-shift”. Default is empty.

Returns:

  • state_out (array of float) – compressor output state containing [T,p,h,v,s,q].

  • work_specific (float) – work per kg of fluid, positive for compressor; units:J/kg.

throttle()[source]

throttle output state calculation

so far only for a constant enthalpy

Parameters:
  • p_out (float) – output pressure.

  • fluid (fprop.Fluid) – entering fluid, including properties, composition, and model.

  • m_dot (float, optional) – mass flow rate (in kg/s). Default is 1

  • calc_type (string, optional) – how to calculate, so far, only one implemented. The default is “const_h”.

  • name (string, optional) – name of the device. The default is “throttle”.

  • plot_info (dictionary, optional) – if not empty a Figure, an Axes, a list of What shall be plotted, a list with the colour/styles and a list with the labels must be passed. in “what”, the two numbers coincide with the fluid THERMO order. The x-shift can be used in cycle calculations, to shift the curves, by the value (it will be added). The names in the dictionary are: “fig”, “ax”, “what”,”col”, “label”, “x-shift”. Default is empty.

Returns:

state_out – compressor output state containing [T,p,h,v,s,q].

Return type:

array of float

plot_temp_h_flow()[source]

plotting a T-H-dot diagram for simple flows (compressor, throttle etc.)

Parameters:
  • _state_in (np.array) – entering state [T,p,h,v,s,…].

  • _state_out (np.array) – exiting state.

  • _m_dot (float) – mass flow rate (kg/s).

  • _plot_info (dictionary) – if not empty a Figure, an Axes, a list of What shall be plotted, a list with the colour/styles and a list with the labels must be passed. in “what”, the two numbers coincide with the fluid THERMO order. The x-shift can be used in cycle calculations, to shift the curves, by the value (it will be added). The names in the dictionary are: “fig”, “ax”, “what”,”col”, “label”, “x-shift”.

Return type:

None.

print_device()[source]
state_w_p()[source]