vclibpy.flowsheets package
Submodules
vclibpy.flowsheets.base module
- class vclibpy.flowsheets.base.BaseCycle(fluid: str, evaporator: HeatExchanger, condenser: HeatExchanger)[source]
Bases:
object
Base class for a heat pump. More complex systems may inherit from this class All HP have a compressor, two HE and a source and sink. Therefore, the parameters defined here are general parameters.
- Args:
fluid (str): Name of the fluid evaporator (HeatExchanger): Instance of a heat exchanger used for the evaporator condenser (HeatExchanger): Instance of a heat exchanger used for the condenser
- abstract calc_electrical_power(inputs: Inputs, fs_state: FlowsheetState)[source]
Function to calc the electrical power consumption based on the flowsheet used
- abstract calc_states(p_1, p_2, inputs: Inputs, fs_state: FlowsheetState)[source]
Function to calculate the states and mass flow rates of the flowsheet and set these into each component based on the given pressure levels p_1 and p_2.
- Args:
- p_1 (float):
Lower pressure level. If no pressure losses are assumed, this equals the evaporation pressure and the compressor inlet pressure.
- p_2 (float):
Higher pressure level. If no pressure losses are assumed, this equals the condensing pressure and the compressor outlet pressure.
inputs (Inputs): Inputs of calculation. fs_state (FlowsheetState): Flowsheet state to save important variables.
- calc_steady_state(inputs: Inputs, fluid: str | None = None, **kwargs)[source]
Calculate the steady-state performance of a vapor compression cycle based on given inputs and assumptions.
This function ensures consistent assumptions across different cycles. It calculates the performance of the heat pump under specific conditions while adhering to several general assumptions.
General Assumptions:
Isenthalpic expansion valves: The enthalpy at the inlet equals the enthalpy at the outlet.
No heat losses in any component: The heat input to the condenser equals the heat output of the evaporator plus the power input.
Input to the evaporator is always in the two-phase region.
Output of the evaporator and output of the condenser maintain a constant overheating or subcooling (can be set in Inputs).
- Args:
- inputs (Inputs):
An instance of the Inputs class containing the necessary parameters to calculate the flowsheet state.
- fluid (str):
The fluid to be used in the calculations. Required only if ‘fluid’ is not specified during the object’s initialization.
- Keyword Arguments:
- min_iteration_step (int):
The minimum step size for iterations (default: 1).
- save_path_plots (str or None):
The path to save plots (default: None). If None, no plots are created.
- show_iteration (bool):
Whether to display iteration progress (default: False).
- T_max (float):
Maximum temperature allowed (default: 273.15 + 150).
- use_quick_solver (bool):
Whether to use a quick solver (default: True).
- max_err_ntu (float):
Maximum allowable error for the heat exchanger in percent (default: 0.5).
- max_err_dT_min (float):
Maximum allowable error for minimum temperature difference in K (default: 0.1).
- max_num_iterations (int or None):
Maximum number of iterations allowed (default: None).
- Returns:
- fs_state (FlowsheetState):
An instance of the FlowsheetState class representing the calculated state of the vapor compression cycle.
- get_all_components() List[BaseComponent] [source]
- abstract get_states_in_order_for_plotting()[source]
Function to return all thermodynamic states of cycle in the correct order for plotting. Include phase change states to see if your simulation runs plausible cycles.
- Returns:
List with tuples, first entry being the state and second the mass flow rate
- plot_cycle(save_path: str, inputs: Inputs)[source]
Function to plot the resulting flowsheet of the steady state config.
- set_condenser_outlet_based_on_subcooling(p_con: float, inputs: Inputs)[source]
Calculate the outlet state of the evaporator based on the required degree of superheating.
- Args:
p_con (float): Condensing pressure inputs (Inputs): Inputs with superheating level
vclibpy.flowsheets.standard module
- class vclibpy.flowsheets.standard.StandardCycle(compressor: Compressor, expansion_valve: ExpansionValve, **kwargs)[source]
Bases:
BaseCycle
Class for a standard cycle with four components.
For the standard cycle, we have 4 possible states:
Before compressor, after evaporator
Before condenser, after compressor
Before EV, after condenser
Before Evaporator, after EV
- calc_electrical_power(inputs: Inputs, fs_state: FlowsheetState)[source]
Based on simple energy balance - Adiabatic
- calc_states(p_1, p_2, inputs: Inputs, fs_state: FlowsheetState)[source]
Function to calculate the states and mass flow rates of the flowsheet and set these into each component based on the given pressure levels p_1 and p_2.
- Args:
- p_1 (float):
Lower pressure level. If no pressure losses are assumed, this equals the evaporation pressure and the compressor inlet pressure.
- p_2 (float):
Higher pressure level. If no pressure losses are assumed, this equals the condensing pressure and the compressor outlet pressure.
inputs (Inputs): Inputs of calculation. fs_state (FlowsheetState): Flowsheet state to save important variables.
vclibpy.flowsheets.vapor_injection module
- class vclibpy.flowsheets.vapor_injection.BaseVaporInjection(high_pressure_compressor: Compressor, low_pressure_compressor: Compressor, high_pressure_valve: ExpansionValve, low_pressure_valve: ExpansionValve, **kwargs)[source]
-
Partial cycle with vapor injection, using two separated compressors and expansion valves.
Notes
See parent docstring for info on further assumptions and parameters.
- calc_electrical_power(inputs: Inputs, fs_state: FlowsheetState)[source]
Function to calc the electrical power consumption based on the flowsheet used
- calc_injection() -> (<class 'float'>, <class 'float'>, <class 'vclibpy.media.states.ThermodynamicState'>)[source]
Calculate the injection component, e.g. phase separator or heat exchanger. In this function, child classes must set inlets and calculate outlets of additional components.
- Returns:
float: Portion of vapor injected (x) float: Enthalpy of vapor injected ThermodynamicState: Inlet state of low pressure expansion valve
- calc_states(p_1, p_2, inputs: Inputs, fs_state: FlowsheetState)[source]
Function to calculate the states and mass flow rates of the flowsheet and set these into each component based on the given pressure levels p_1 and p_2.
- Args:
- p_1 (float):
Lower pressure level. If no pressure losses are assumed, this equals the evaporation pressure and the compressor inlet pressure.
- p_2 (float):
Higher pressure level. If no pressure losses are assumed, this equals the condensing pressure and the compressor outlet pressure.
inputs (Inputs): Inputs of calculation. fs_state (FlowsheetState): Flowsheet state to save important variables.
vclibpy.flowsheets.vapor_injection_economizer module
- class vclibpy.flowsheets.vapor_injection_economizer.VaporInjectionEconomizer(economizer: VaporInjectionEconomizerNTU, **kwargs)[source]
Bases:
BaseVaporInjection
Cycle with vapor injection using an economizer.
For this cycle, we have 9 relevant states:
1: Before compressor, after evaporator
2: Before condenser, after compressor
3: Before ihx, after condenser
4: Before Evaporator, after ihx
5_ihx: Before ihx, after condenser and EV
6_ihx: Before Mixing with 1_VI, after ihx
7_ihx: Before second EV, after ihx
1_VI: Before Mixing with 6_ihx, After first stage
1_VI_mixed. Before second stage of compressor, after mixing with 6_ihx
Additional Assumptions:
No heat losses in ihx
No pressure loss in ihx
No losses for splitting of streams
Isenthalpic second EV
Notes
See parent docstring for info on further assumptions and parameters.
- calc_injection()[source]
This calculation assumes that the heat transfer of the higher temperature liquid is always in the subcooling region, while the vapor injection is always a two-phase heat transfer. In reality, you would need to achieve a certain degree of superheat. Thus, a moving boundary approach would be more fitting. For simplicity, we assume no superheat.
This function iterates the amount of vapor injected. The iteration starts with close to no injection and increases the amount of injection as long as enough hotter sub-cooled liquid is present to fully vaporize the injected part.
vclibpy.flowsheets.vapor_injection_phase_separator module
- class vclibpy.flowsheets.vapor_injection_phase_separator.VaporInjectionPhaseSeparator(**kwargs)[source]
Bases:
BaseVaporInjection
Cycle with vapor injection using an adiabatic ideal phase seperator.
For this cycle, we have 9 relevant states:
1: Before compressor, after evaporator
2: Before condenser, after compressor
3: Before PS, after condenser
4: Before Evaporator, after PS
5_vips: Before PS, after first EV
6_vips: Before Mixing with 1_VI, after PS
7_vips: Before second EV, after PS
1_VI: Before Mixing with 6_vips, After first stage
1_VI_mixed. Before second stage of compressor, after mixing with 6_vips
Additional Assumptions:
Ideal mixing in compressor of state 5 and state 4
Notes
See parent docstring for info on further assumptions and parameters.
- calc_injection()[source]
Calculate the injection component, e.g. phase separator or heat exchanger. In this function, child classes must set inlets and calculate outlets of additional components.
- Returns:
float: Portion of vapor injected (x) float: Enthalpy of vapor injected ThermodynamicState: Inlet state of low pressure expansion valve