Components evaluation¶
A very basic approach to calculate heat exchangers, compressores(and expanders) as well as throttles.
Heat exchangers¶
Simple heat exchangers, only thermodynamic balances are calculated (no UA), and by varying the mass flow rate and one state-point (temperature), a minimum approach temperature is satisfied, but only if the given restrictions allow it.
A jupyter-notebook (there may be installation errors shown, if Refprop and Trend are not installed):
Created on Sun May 21 08:51:33 2023
@author: atakan
- class carbatpy.models.components.heat_exchanger_thermo_v2.StaticHeatExchanger(fluids, h_dot_min, h_out_w, h_limit_s, **kwargs)[source]¶
Bases:
objectClass for static counter-flow heat exchanger
means: no time dependence and no heat transfer coefficients * areas are used (UA)! Instead a minimum approach temperature is tried to be met. At the moment, this is mainly done by varying one of the mass flow rates. But this is sometimes not enough and a variation of the working fluid pressure will soon be included. Only the first law and second law will be checked (the latter must be improved).
- __init__(fluids, h_dot_min, h_out_w, h_limit_s, **kwargs)[source]¶
class to calculate (static/steady state) heat-exchangers
includes pinch-point analysis and plotting, only implemented for simple thermodynamic calculations (no convection coefficients and heat exchanger areas regarded yet)
- Parameters:
fluids (list of 2 fprop.Fluid) – The definition of the two fluids, as they enter the heat exchangers. Typically at room temperature.
h_dot_min (float) – enthalpy flow rate (W) which has to be transfered.
h_out_w (float) – exit enthalpy of the working fluid.
h_limit_s (float,) – if there is a limit in enthalpy for the secondary fluid, it can be given here. It is also a starting value for possible iterations.
kwargs (dict, optional) –
Optional parameters for the heat exchanger configuration:
- pointsint, for how many points (array) shall the minimum approach temperature
be checked and properties be returned (for plotting etc.). default 50
- d_temp_separation_minfloat, Minimium approach temperature (
pinch point) between the two fluids. default 0.5
- calc_typestr, which calculation type shall be performed; only one implemented so
far, default “const”
name : str, name of the heat exchanger .default “evaporator”
- plot_infodict, if not None, 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.default {}
- Return type:
None.
- find_pinch(secondary=True)[source]¶
Function tries to vary the secondary fluid enthalpy until a minimum approach temperature is reached. This also changes the mass flow rate. This is then also the new exit state within the heat exchanger. If this is also not succesful, self.warning is set to 1. This should be checked. :param secondary: shall the output state of the secondary (True) or the working
(False) fluid be varied? default = True
- Returns:
the optimized enthalpy of the secondary fluid.
- Return type:
float
- pinch_calc(verbose=False)[source]¶
Calculate the changes in enthalpy and temperature in the heat exchanger
counter-flow hex assumed! Both flows are isobaric. Is used to check, whether the second law is violated. The factor can be used to vary the mass flow rate of the working fluid, until no violation is found (done in root finding).
- Parameters:
verbose (boolean, optional) – if True, several variables will be printed out. Default is False.
- Raises:
Exception – if temperatures are not consistent.
- Returns:
m_dot_s (float) – secondary fluid mass flow rate (kg/s.
d_tempall (numpy-array) – The temperature differences along the counter-flow heat exchanger.
w_array (array) – properties of the working fluid along the heat exchanger (T,p,h, etc. see fluid class).
s_array (array) – properties of the secondary fluid along the heat exchanger (T,p,h, etc. see fluid class).
- pinch_plot(plot_fname='', plotting=True)[source]¶
calculates the secondary fluid output state and mass flow, for the minimum approach temperature of the HeatExchanger instance. When wanted, this is also plotted
- Parameters:
plot_fname (string, optional) – file-name to store the plot. The default is “”.
plotting (Boolean, optional) – should it be plotted? The default is True.
- Returns:
m_dot_s (float) – mass flow raete of the secondary fluid in SI units (kg/s).
d_tempall (np.array) – the temperature differences between the two fluids along the heat exchanger.
w_array (np.array [self.points, 7]) – the states of the working fluid along the heat exchanger.
s_array (np.array [self.points, 7]) – the states of the secondary fluid along the heat exchanger.
- pinch_root(h_out_s, secondary, verbose=False)[source]¶
Function for finding the minimum mean temperature difference in a heat exchanger, while not going below the minimum approach temperature.
The output enthalpy of the secondary fluid is set (as default) and the heat exchanger is evaluated.
- Parameters:
h_out_s (float) – the output enthalpy, default would be of the secondary fluid.
secondary (boolean) – shall the secondary fluid output be varied (or the working fluid)?
- Returns:
root tries to reach a value of 0.
- Return type:
mean T-difference, float
Compressors, Expanders, Pump, and Throttle¶
A class for single flow devices.
according to the device_type it is selected: - “machine” : According to the given pressure levels, the script decides,
whether it is a compressor or an expander. At the moment the isentropic efficiency must be provided. (iso_s)
“throttle” : A throttling device (actually only iso_h)
“pump” : A pump for incompressible flow (iso_s).
Class FlowDevice functions for compressor and expander output state calcultations
so far/here: only for fixed isentropic efficiencies pumps and throttles added.
((Part of carbatpy.)) Created on Sun May 21 08:51:33 2023
@author: atakan
- class carbatpy.models.components.single_flow.FlowDevice(fluid, p_out, m_dot, device_type='machine', **kwargs)[source]¶
Bases:
objectUnified themodynamic calculations for single flow devices
- __init__(fluid, p_out, m_dot, device_type='machine', **kwargs)[source]¶
Calculate the output state and state changes for single flow devices
- Parameters:
fluid (Fluid) – The fluid at is entering state.
p_out (float) – Output pressure in Pa.
m_dot (float) – mass flow rate in kg/s.
device_type (TYPE, optional) – ‘machine’ for compressor/expander, ‘pump’, or ‘throttle’. The default is “machine”.
**kwargs –
Optional parameters for setting the configuration and parameters
- plot infodictionary,optional, default value is {} contains 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”.
- namestring, optional, the name of this specific device, the default is
”compressor”.
- calc_typestring, optional, which method shall be used (e.g.: “const_eta”,
”const_h”), default is “const_eta”.
- calc_parametersdictionary, optional, if further parameters have to be
given for the calculation. the default is None.
verbose : Boolean, optional, the default is False.
- Return type:
None.
- 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.
- 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.
- 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
Mixing Chamber (Flow Device)¶
For mixing two streams.
Started a class for flow devices, especially mixing chambers, but could also be used for heat exchangers or machines?
at the moment, the only device is for adiabtaic mixing, but also of fluid mixtures of different compounds and composition. ouputs as dictionary (state variables to be fixed?) inputs=list of states (Fluid) mix = list of 2 lists [[input 1(number), input 2 (number)], [output (number? or different?)]]
Created on Fri May 31 15:16:09 2024
@author: atakan
- class carbatpy.models.components.flow_devices.FlowDevice(inputs, outputs, flow_rates_in, mix=[], name='flow-device', **calc_parameters)[source]¶
Bases:
object- __init__(inputs, outputs, flow_rates_in, mix=[], name='flow-device', **calc_parameters)[source]¶
Flow Device = mixing chamber
At the moment the species, the mass balance, and the energy balance for an adiabatic chanber with given output pressure is calculated. Two fluids entering, at the moment only one is exiting.
- Parameters:
inputs (list of Fluids) – the (2) fluids entering with the correct states.
outputs (List of Fluids) – the (actually single) fluid state exiting.
flow_rates_in (list) – the mass flow rates in kg/s.
mix (List of two lists, optional) – In the first list the input states are numbered, in the second the output states example: [[0,1],[0]]. The default is [].
name (string, optional) – the name of the device. The default is “flow-device”.
**calc_parameters (dictionary) – example {“calc_type”: “HP”, “H”: “const”, “p_out”: 1e5}, at the moment only p_out values should be changed.
- Return type:
None.