carbatpy.models.components.comp =============================== .. py:module:: carbatpy.models.components.comp Attributes ---------- .. autoapisummary:: carbatpy.models.components.comp.warn carbatpy.models.components.comp.logger carbatpy.models.components.comp.POWER_IN Classes ------- .. autoapisummary:: carbatpy.models.components.comp.Component carbatpy.models.components.comp.FlowDevice carbatpy.models.components.comp.Throttle carbatpy.models.components.comp.HeatExchanger carbatpy.models.components.comp.StaticHeatExchanger carbatpy.models.components.comp.Start carbatpy.models.components.comp.Cycle Functions --------- .. autoapisummary:: carbatpy.models.components.comp.create_component carbatpy.models.components.comp.main Module Contents --------------- .. py:data:: warn .. py:data:: logger .. py:class:: Component(name, config, **kwargs) Bases: :py:obj:`abc.ABC` Components of thermodynamic cycles. All components have the following attributes: - ``config``: basic configuration incl. calculation method - ``inputs``: inputs for calculations - ``output``: main results - ``all_data``: detailed data points for plotting and post-processing - ``warning``: a value and a message (0, "All o.k.") All components implement the following methods: - ``initialize``: set values that do not depend on a specific calculation - ``calculate``: main calculation routine - ``plot``: plot changes in a joint diagram - ``save_results``: save results and inputs to a directory Set the basic configuration of a component. :param name: name of the component to be configured, must be the same as in the config dictionary or file. :type name: string :param config: if it is a string it must be the filename with a yaml or json file with the dictionary information. All needed basic parameters or default parameters and calculation type are set here. Check the io_utils.py file for typical values. :type config: string or dictionary :param \*\*kwargs: any further parameters which may be needed. :type \*\*kwargs: dictionary :rtype: None. .. py:attribute:: name .. py:attribute:: config .. py:attribute:: working_fluid .. py:attribute:: inputs .. py:attribute:: fl_name .. py:attribute:: calc_type .. py:attribute:: verbose .. py:attribute:: logger .. py:attribute:: output .. py:attribute:: all_data :value: None .. py:attribute:: warning .. py:attribute:: cost :value: 0 .. py:method:: initialize(**kwargs) :abstractmethod: .. py:method:: calculate(in_states=None, out_states=None, run_param=None, **kwargs) :abstractmethod: .. py:method:: estimate_costs(parameters=None, **kwargs) :abstractmethod: .. py:method:: plot(plot_info, **kwargs) :abstractmethod: .. py:method:: entropy_production(temp_amb=None, **kwargs) .. py:method:: save_results(base_dir) .. py:class:: FlowDevice(name, config, **kwargs) Bases: :py:obj:`Component` Components of thermodynamic cycles. All components have the following attributes: - ``config``: basic configuration incl. calculation method - ``inputs``: inputs for calculations - ``output``: main results - ``all_data``: detailed data points for plotting and post-processing - ``warning``: a value and a message (0, "All o.k.") All components implement the following methods: - ``initialize``: set values that do not depend on a specific calculation - ``calculate``: main calculation routine - ``plot``: plot changes in a joint diagram - ``save_results``: save results and inputs to a directory Set the basic configuration of a component. :param name: name of the component to be configured, must be the same as in the config dictionary or file. :type name: string :param config: if it is a string it must be the filename with a yaml or json file with the dictionary information. All needed basic parameters or default parameters and calculation type are set here. Check the io_utils.py file for typical values. :type config: string or dictionary :param \*\*kwargs: any further parameters which may be needed. :type \*\*kwargs: dictionary :rtype: None. .. py:method:: initialize(**kwargs) .. py:method:: estimate_costs(parameters=None, **kwargs) .. py:method:: plot(plot_info=None) .. py:class:: Throttle(name, config, **kwargs) Bases: :py:obj:`FlowDevice` Simple isenthalpic throttle. Set the basic configuration of a component. :param name: name of the component to be configured, must be the same as in the config dictionary or file. :type name: string :param config: if it is a string it must be the filename with a yaml or json file with the dictionary information. All needed basic parameters or default parameters and calculation type are set here. Check the io_utils.py file for typical values. :type config: string or dictionary :param \*\*kwargs: any further parameters which may be needed. :type \*\*kwargs: dictionary :rtype: None. .. py:method:: initialize(**kwargs) .. py:method:: calculate(in_states, out_states, run_param=None, **kwargs) .. py:class:: HeatExchanger(name, config, **kwargs) Bases: :py:obj:`Component` Components of thermodynamic cycles. All components have the following attributes: - ``config``: basic configuration incl. calculation method - ``inputs``: inputs for calculations - ``output``: main results - ``all_data``: detailed data points for plotting and post-processing - ``warning``: a value and a message (0, "All o.k.") All components implement the following methods: - ``initialize``: set values that do not depend on a specific calculation - ``calculate``: main calculation routine - ``plot``: plot changes in a joint diagram - ``save_results``: save results and inputs to a directory Set the basic configuration of a component. :param name: name of the component to be configured, must be the same as in the config dictionary or file. :type name: string :param config: if it is a string it must be the filename with a yaml or json file with the dictionary information. All needed basic parameters or default parameters and calculation type are set here. Check the io_utils.py file for typical values. :type config: string or dictionary :param \*\*kwargs: any further parameters which may be needed. :type \*\*kwargs: dictionary :rtype: None. .. py:method:: initialize(**kwargs) .. py:method:: calculate_volume(parameters=None, **kwargs) :abstractmethod: .. py:method:: estimate_costs(parameters=None, **kwargs) .. py:class:: StaticHeatExchanger(name, config, **kwargs) Bases: :py:obj:`HeatExchanger` Components of thermodynamic cycles. All components have the following attributes: - ``config``: basic configuration incl. calculation method - ``inputs``: inputs for calculations - ``output``: main results - ``all_data``: detailed data points for plotting and post-processing - ``warning``: a value and a message (0, "All o.k.") All components implement the following methods: - ``initialize``: set values that do not depend on a specific calculation - ``calculate``: main calculation routine - ``plot``: plot changes in a joint diagram - ``save_results``: save results and inputs to a directory Set the basic configuration of a component. :param name: name of the component to be configured, must be the same as in the config dictionary or file. :type name: string :param config: if it is a string it must be the filename with a yaml or json file with the dictionary information. All needed basic parameters or default parameters and calculation type are set here. Check the io_utils.py file for typical values. :type config: string or dictionary :param \*\*kwargs: any further parameters which may be needed. :type \*\*kwargs: dictionary :rtype: None. .. py:method:: initialize(**kwargs) .. py:method:: set_in_out(new_state, instate=True) Replace either an old input state or output state by a new one. Needed for the calculation of the heat exchanger. :param new_state: Dictionary mapping fluid names to state arrays. Format: ``{"fluid-name": numpy_array_with_state}`` :type new_state: dict :param instate: If True, replaces input state; if False, replaces output state. :type instate: bool, default=True :returns: * **in_state** (*dict*) -- Input state dictionary to pass to calculate(). * **out_state** (*dict*) -- Output state dictionary to pass to calculate(). .. py:method:: calculate(in_states=None, out_states=None, run_param=None, **kwargs) .. py:method:: plot(plot_info, **kwargs) Plots the T-H_dot diagram (shifted enthalpy flow rate). This method visualizes the temperature profile against the enthalpy flow rate, allowing for the analysis of temperature differences (pinch points) within the component. :param plot_info: Configuration for the matplotlib plot. Required keys: * "fig": Matplotlib figure object. * "ax": Matplotlib axes object. * "what": List of indices [x, y], e.g., [2, 0] for (h, T). * "col": List of color/style strings, e.g., ["r:", "ko"]. * "label": List of labels for the legend. * "x-shift": List of initial shifts for the x-axis. Example: ``{"fig": fig, "ax": ax, "what": [2, 0], "col": ["r:", "k-"]}`` :type plot_info: dict :param \*\*kwargs: Additional plotting parameters passed to ax.plot(). :returns: * *list* -- A list containing the min and max values of the plotted data: [min, max]. * *float* -- The actual shift applied to the enthalpy flow rate (H_dot). .. py:method:: hex_opti_work_out(inp_act=None, out_act=None, run_p_par=None, verbose=False) Optimize the mean temperature difference by varying the working Fluid output state. Only enthalpy is variied within +/- 5%, pressure remains unchanged. :param run_p_cond: A value for {"m_dot": 0.01} must be provided, it is kept constant. :type run_p_cond: dictionary :param verbose: If you want some printing. The default is False. :type verbose: boolean, optional :rtype: None. .. py:method:: calculate_volume(parameters=None, **kwargs) Calculates the volume and mass of the thermal storage (two tanks). It is assumed that the secondary fluid entering the heat exchanger comes from one storage and the fluid leaving it is stored in the second storage. Both volumes and the total mass are calculated for an amount of thermal energy to be stored. The costs are also estimated for cone roof tanks. :param parameters: A dictionary containing the following keys: Energy_stored : float Energy in J. The default is 1 MWh (3.6e9 J). time : float Time to be stored in s. If both 'time' and 'Energy_stored' are given, 'time' is used. The default value is taken from the configuration file at ['process']['time']. :type parameters: dict, optional :param \*\*kwargs: Additional keyword arguments (none currently implemented). :returns: A dictionary (vol_results) containing: storage_volumes : dict The volumes for the entering and exiting states in m3. Example: {"state_in": vol1, "state_out": vol2}. energy_density : float Energy density in J/kg. mass_storage : float The total mass of the storage in kg. Energy_stored : float The actual energy stored in J. Storage_costs : dict Estimated costs for the entering and exiting state for cone roof tanks in currency units. :rtype: dict .. py:class:: Start(name, config, **kwargs) Bases: :py:obj:`FlowDevice` Components of thermodynamic cycles. All components have the following attributes: - ``config``: basic configuration incl. calculation method - ``inputs``: inputs for calculations - ``output``: main results - ``all_data``: detailed data points for plotting and post-processing - ``warning``: a value and a message (0, "All o.k.") All components implement the following methods: - ``initialize``: set values that do not depend on a specific calculation - ``calculate``: main calculation routine - ``plot``: plot changes in a joint diagram - ``save_results``: save results and inputs to a directory Set the basic configuration of a component. :param name: name of the component to be configured, must be the same as in the config dictionary or file. :type name: string :param config: if it is a string it must be the filename with a yaml or json file with the dictionary information. All needed basic parameters or default parameters and calculation type are set here. Check the io_utils.py file for typical values. :type config: string or dictionary :param \*\*kwargs: any further parameters which may be needed. :type \*\*kwargs: dictionary :rtype: None. .. py:method:: initialize(**kwargs) Returns the starting state of the working_fluid only. :rtype: None. .. py:method:: calculate(in_states=None, out_states=None, run_param=None, **kwargs) .. py:function:: create_component(name, config) .. py:class:: Cycle(config) .. py:attribute:: config .. py:attribute:: components .. py:attribute:: fluids .. py:attribute:: process .. py:attribute:: fixed .. py:attribute:: logger .. py:method:: initialize() .. py:method:: calculate(new_config=None, **kwargs) .. py:method:: plot() .. py:method:: save_results() .. py:function:: main(dir_name=CB_DEFAULTS['General']['CB_DATA'], new_config=None) .. py:data:: POWER_IN :value: 1000000.0