vclibpy.utils package
Submodules
vclibpy.utils.automation module
Functions to generate HP Maps automatically
- vclibpy.utils.automation.calc_multiple_states(save_path: Path, heat_pump: BaseCycle, inputs: List[Inputs], **kwargs)[source]
Function to calculate the flowsheet states for all given inputs. All results are stored as a .xlsx file in the given save-path
- Args:
save_path (pathlib.Path): Location where to save the results as xlsx. heat_pump (BaseCycle): A valid flowsheet inputs (List[Inputs]): A list with all inputs to simulate **kwargs: Solver settings for the flowsheet
- vclibpy.utils.automation.full_factorial_map_generation(heat_pump: ~vclibpy.flowsheets.base.BaseCycle, T_eva_in_ar: list | ~numpy.ndarray, T_con_in_ar: list | ~numpy.ndarray, n_ar: list | ~numpy.ndarray, m_flow_con: float, m_flow_eva: float, save_path: ~pathlib.Path | str, dT_eva_superheating=5, dT_con_subcooling=0, use_multiprocessing: bool = False, save_plots: bool = False, **kwargs) -> (<class 'pathlib.Path'>, <class 'pathlib.Path'>)[source]
Run a full-factorial simulation to create performance maps used in other simulation tools like Modelica or to analyze the off-design of the flowsheet. The results are stored and returned as .sdf and .csv files. Currently, only varying T_eva_in, T_con_in, and n is implemented. However, changing this to more dimensions or other variables is not much work. In this case, please raise an issue.
- Args:
heat_pump (BaseCycle): The flowsheet to use T_eva_in_ar: Array with inputs for T_eva_in T_con_in_ar: Array with inputs for T_con_in n_ar: Array with inputs for n_ar m_flow_con: Condenser mass flow rate m_flow_eva: Evaporator mass flow rate save_path: Where to save all results. dT_eva_superheating: Evaporator superheating dT_con_subcooling: Condenser subcooling use_multiprocessing:
True to use multiprocessing. May speed up the calculation. Default is False
- save_plots:
True to save plots of each steady state point. Default is False
**kwargs: Solver settings for the flowsheet
- Returns:
- tuple (pathlib.Path, pathlib.Path):
Path to the created .sdf file and to the .csv file
vclibpy.utils.nominal_design module
- vclibpy.utils.nominal_design.nominal_hp_design(heat_pump: BaseCycle, inputs: Inputs, fluid: str, dT_con: float | None = None, dT_eva: float | None = None, **kwargs) dict [source]
Function to calculate the heat pump design at a given nominal point. Args:
heat_pump (BaseCycle): A supported flowsheet inputs (Inputs):
The input values at the nominal point. If the mass flow rates are not given, you can use dT_con and dT_eva to iteratively calculate the mass flow rates in order to achieve the required temperature differences at the nominal point.
- dT_con (float):
Condenser temperature difference to calculate mass flow rate
- dT_eva (float):
Evaporator temperature difference to calculate mass flow rate
fluid (str): Fluid to be used. **kwargs:
m_flow_eva_start: Guess start-value for iteration. Default 0.2 m_flow_con_start: Guess start-value for iteration. Default 1 accuracy: Minimal accuracy for mass flow rate iteration (in kg/s).
Default 0.001 kg/s
- Returns:
- dict: A dictionary with all flowsheet states and inputs containing
information about the nominal design.
vclibpy.utils.plotting module
- vclibpy.utils.plotting.plot_cycle(med_prop: MedProp, states: List[ThermodynamicState], save_path: Path | None = None, show: bool = False)[source]
Creates T-h and p-h diagrams for a thermodynamic cycle.
- Args:
- med_prop (MedProp):
Object containing the medium properties and two-phase limits.
- states (List[ThermodynamicState]):
List of thermodynamic states defining the cycle points. Each state should contain T, p, and h properties.
- save_path (pathlib.Path, optional):
Path where the plot should be saved. If None, returns the figure and axes objects instead. Defaults to None.
- show (bool):
If True, plots are displayed. Default is False.
- Returns:
- tuple(matplotlib.figure.Figure, numpy.ndarray) or None:
If save_path is provided, saves the plot and returns None. If show is True, shows the plot.
- vclibpy.utils.plotting.plot_sdf_map(filepath_sdf: Path, nd_data: str, first_dimension: str, second_dimension: str, fluids: List[str] | None = None, flowsheets: List[str] | None = None, violin_plot_variable: str | None = None, third_dimension: str | None = None)[source]
Generate and display visualizations based on data from an SDF (Structured Data File) dataset. This function generates various types of visualizations based on the provided parameters, including 3D scatter plots, 3D surface plots, and violin plots, and displays them using Matplotlib.
- Args:
- filepath_sdf (pathlib.Path):
The path to the SDF dataset file.
- nd_data (str):
The name of the primary data to be plotted.
- first_dimension (str):
The name of the first dimension for the visualization.
- second_dimension (str):
The name of the second dimension for the visualization.
- fluids (List[str], optional):
List of specific fluids to include in the visualization. Default is None, which includes all fluids.
- flowsheets (List[str], optional):
List of specific flowsheets to include in the visualization. Default is None, which includes all flowsheets.
- violin_plot_variable (str, optional):
The variable to be used for creating violin plots. Default is None, which disables violin plots.
- third_dimension (str, optional):
The name of the third dimension for 4D visualizations. Default is None, which disables 4D plotting.
- Raises:
KeyError: If the specified data or dimensions are not found in the dataset.
Examples: >>> FILEPATH_SDF = r”HeatPumpMaps.sdf” >>> plot_sdf_map( >>> filepath_sdf=FILEPATH_SDF, >>> nd_data=”COP”, >>> first_dimension=”T_eva_in”, >>> second_dimension=”n”, >>> fluids=[“R410A”], >>> flowsheets=[“OptiHorn”], >>> )
vclibpy.utils.printing module
Created on 24.04.2023
@author: Christoph Hoeges
Last Update: 24.04.2023
vclibpy.utils.sdf_ module
- vclibpy.utils.sdf_.merge_sdfs(filepaths, save_path)[source]
Merge given files and return a merged file. Be careful if both files contain the same combination. Then, the latter element of the list will overwrite the first one.
- Args:
filepaths (list): List with paths to the files save_path (str): Save path for the new file
- vclibpy.utils.sdf_.save_to_sdf(data: dict, save_path: Path)[source]
Save given input dictionary to a sdf file in the given save_path
- Args:
- data (dict):
A dictionary with the following structure: Keys: Flowsheet_name Values: A dictionary with the following structure:
Keys: Fluids
- Values: Data dictionaries with the following structure:
A tuple with three values, in that order:
scales: Of the given nd_data, e.g. T_Amb, n
nd_data: More-dimensional data, e.g. COP
parameters: Scalar values, like m_flow_con or similar
save_path (pathlib.Path): Where to store the data flowsheet_name (str): Name of the flowsheet. This is the top level group
- Returns: