carbatpy.models.components.comp

Attributes

warn

logger

POWER_IN

Classes

Component

Components of thermodynamic cycles.

FlowDevice

Components of thermodynamic cycles.

Throttle

Simple isenthalpic throttle.

HeatExchanger

Components of thermodynamic cycles.

StaticHeatExchanger

Components of thermodynamic cycles.

Start

Components of thermodynamic cycles.

Cycle

Functions

create_component(name, config)

main([dir_name, new_config])

Module Contents

carbatpy.models.components.comp.warn[source]
carbatpy.models.components.comp.logger[source]
class carbatpy.models.components.comp.Component(name, config, **kwargs)[source]

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

Parameters:
  • name (string) – name of the component to be configured, must be the same as in the config dictionary or file.

  • config (string or dictionary) – 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.

  • **kwargs (dictionary) – any further parameters which may be needed.

Return type:

None.

name[source]
config[source]
working_fluid[source]
inputs[source]
fl_name[source]
calc_type[source]
verbose[source]
logger[source]
output[source]
all_data = None[source]
warning[source]
cost = 0[source]
abstract initialize(**kwargs)[source]
abstract calculate(in_states=None, out_states=None, run_param=None, **kwargs)[source]
abstract estimate_costs(parameters=None, **kwargs)[source]
abstract plot(plot_info, **kwargs)[source]
entropy_production(temp_amb=None, **kwargs)[source]
save_results(base_dir)[source]
class carbatpy.models.components.comp.FlowDevice(name, config, **kwargs)[source]

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

Parameters:
  • name (string) – name of the component to be configured, must be the same as in the config dictionary or file.

  • config (string or dictionary) – 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.

  • **kwargs (dictionary) – any further parameters which may be needed.

Return type:

None.

initialize(**kwargs)[source]
estimate_costs(parameters=None, **kwargs)[source]
plot(plot_info=None)[source]
class carbatpy.models.components.comp.Throttle(name, config, **kwargs)[source]

Bases: FlowDevice

Simple isenthalpic throttle.

Set the basic configuration of a component.

Parameters:
  • name (string) – name of the component to be configured, must be the same as in the config dictionary or file.

  • config (string or dictionary) – 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.

  • **kwargs (dictionary) – any further parameters which may be needed.

Return type:

None.

initialize(**kwargs)[source]
calculate(in_states, out_states, run_param=None, **kwargs)[source]
class carbatpy.models.components.comp.HeatExchanger(name, config, **kwargs)[source]

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

Parameters:
  • name (string) – name of the component to be configured, must be the same as in the config dictionary or file.

  • config (string or dictionary) – 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.

  • **kwargs (dictionary) – any further parameters which may be needed.

Return type:

None.

initialize(**kwargs)[source]
abstract calculate_volume(parameters=None, **kwargs)[source]
estimate_costs(parameters=None, **kwargs)[source]
class carbatpy.models.components.comp.StaticHeatExchanger(name, config, **kwargs)[source]

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

Parameters:
  • name (string) – name of the component to be configured, must be the same as in the config dictionary or file.

  • config (string or dictionary) – 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.

  • **kwargs (dictionary) – any further parameters which may be needed.

Return type:

None.

initialize(**kwargs)[source]
set_in_out(new_state, instate=True)[source]

Replace either an old input state or output state by a new one.

Needed for the calculation of the heat exchanger.

Parameters:
  • new_state (dict) – Dictionary mapping fluid names to state arrays. Format: {"fluid-name": numpy_array_with_state}

  • instate (bool, default=True) – If True, replaces input state; if False, replaces output state.

Returns:

  • in_state (dict) – Input state dictionary to pass to calculate().

  • out_state (dict) – Output state dictionary to pass to calculate().

calculate(in_states=None, out_states=None, run_param=None, **kwargs)[source]
plot(plot_info, **kwargs)[source]

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.

Parameters:
  • plot_info (dict) –

    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-"]}

  • **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).

hex_opti_work_out(inp_act=None, out_act=None, run_p_par=None, verbose=False)[source]

Optimize the mean temperature difference by varying the working Fluid output state.

Only enthalpy is variied within +/- 5%, pressure remains unchanged.

Parameters:
  • run_p_cond (dictionary) – A value for {“m_dot”: 0.01} must be provided, it is kept constant.

  • verbose (boolean, optional) – If you want some printing. The default is False.

Return type:

None.

calculate_volume(parameters=None, **kwargs)[source]

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.

Parameters:
  • parameters (dict, optional) –

    A dictionary containing the following keys:

    Energy_storedfloat

    Energy in J. The default is 1 MWh (3.6e9 J).

    timefloat

    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’].

  • **kwargs – Additional keyword arguments (none currently implemented).

Returns:

A dictionary (vol_results) containing:

storage_volumesdict

The volumes for the entering and exiting states in m3. Example: {“state_in”: vol1, “state_out”: vol2}.

energy_densityfloat

Energy density in J/kg.

mass_storagefloat

The total mass of the storage in kg.

Energy_storedfloat

The actual energy stored in J.

Storage_costsdict

Estimated costs for the entering and exiting state for cone roof tanks in currency units.

Return type:

dict

class carbatpy.models.components.comp.Start(name, config, **kwargs)[source]

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

Parameters:
  • name (string) – name of the component to be configured, must be the same as in the config dictionary or file.

  • config (string or dictionary) – 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.

  • **kwargs (dictionary) – any further parameters which may be needed.

Return type:

None.

initialize(**kwargs)[source]

Returns the starting state of the working_fluid only.

Return type:

None.

calculate(in_states=None, out_states=None, run_param=None, **kwargs)[source]
carbatpy.models.components.comp.create_component(name, config)[source]
class carbatpy.models.components.comp.Cycle(config)[source]
config[source]
components[source]
fluids[source]
process[source]
fixed[source]
logger[source]
initialize()[source]
calculate(new_config=None, **kwargs)[source]
plot()[source]
save_results()[source]
carbatpy.models.components.comp.main(dir_name=CB_DEFAULTS['General']['CB_DATA'], new_config=None)[source]
carbatpy.models.components.comp.POWER_IN = 1000000.0[source]