reskit.dac
==========

.. py:module:: reskit.dac


Submodules
----------

.. toctree::
   :maxdepth: 1

   /_readthedocs/reskit/dac/data/index
   /_readthedocs/reskit/dac/workflows/index


Classes
-------

.. autoapisummary::

   reskit.dac.DACWorkflowManager
   reskit.dac.DACWorkflowManager


Functions
---------

.. autoapisummary::

   reskit.dac.calculate_relative_humidity
   reskit.dac.lt_dac_era5_wenzel2025
   reskit.dac.ht_dac_era5_wenzel2025


Package Contents
----------------

.. py:class:: DACWorkflowManager(placements)

   Bases: :py:obj:`reskit.workflow_manager.WorkflowManager`


   The WorkflowManager class assists with the construction of more specialized WorkflowManagers,
   such as the WindWorkflowManager or the SolarWorkflowManager. In addition to providing the
   general structure for simulation workflow management, the WorkflowManager also defines
   functionalities which should be common across all WorkflowManagers.

   This includes:
     - Basic initialization
     - Time domain management
     - Reading weather data
     - Adjusting variables by a long-run-average value
     - Applying simple loss factors
     - Saving the state of WorkflowManagers to XArray datasets, either in memory or on disc

   Initialization:
   ---------------

   WorkflowManager( placements )


   __init_(self, placements)

   Initialization of an instance of the generic DACWorkflowManager class.

   :param placements: The locations that the simulation should be run for.
                      Columns must include "lon", "lat" (CRS: 4326) and "capacity"
                      -The capacity is the nominal capacity of the DAC plant in tCO2/h
   :type placements: pandas Dataframe

   :rtype: DACWorkflowManager


   .. py:attribute:: units


   .. py:method:: load_lt_dac_model_data(model)

      Function to load the DAC model data of a given model. The model data maps temperature and relative humidity to energy demand, relative productivity and water desorption.
      Description:
      The DAC model data needs columns "T" and "RH" where the temperature (°C) and relative humidity are included. Its a csv file.
      Additionally, the data needs columns:
          -"totalElectricity" where the needed electricity input in MWh/tCO2 is stated at the specified ambient conditions
          -"totalThermal" where the needed heat input in MWh/tCO2 is stated at the specified ambient conditions
          -"relProd" where the relative productivity (i.e. the cpaacity factor) is stated at the specified ambient conditions
          -"waterDesorption" where the produced water is stated in tH2O/tCO2. It might also be possible that this is negative (if water is consumed rather than produced)
      The currently available models:
          -LT_jajjawi: Data from the developed low temperature (solid sorbent) DAC model by Jajjawi et al. [1]. Here, the heat is needed at 90 °C.
          -LT_sendi: Data from the developed low temperature (solid sorbent) DAC model by Sendi et al. [2]. Here, the heat is needed at 110 °C (for steam generation). The original Sendi data has been adapted as described in Wenzel 2025 [3].

      :param model: type of DAC model to use. Valid inputs are: "LT_sendi", "LT_jajjawi" or a path to a csv with DAC model data in the same format as in ./data/
      :type model: str

      .. rubric:: References

      [1] http://dx.doi.org/10.2139/ssrn.5230783
      [2] 10.1016/j.oneear.2022.09.003
      [3] 10.1016/j.adapen.2025.100229



   .. py:method:: simulate_lt_dac_model(fillMethod = 'nearest')

      Simulate the LT DAC (Direct Air Capture) model for the specified plant locations.

      This function interpolates DAC model data to the simulation grid and calculates
      electricity, heat, and water requirements as well as CO2 output for the plants.
      It also handles points outside the convex hull of the DAC data using a specified
      fill method.

      :param fillMethod: Method to fill values for weather conditions outside the convex hull of
                         the DAC model data. Options are:
                         - "nearest" : use the nearest available datapoint (default)
                         - "offTmin" : cut off for temperatures below the DAC data range, use nearest
                         for relative humidity
      :type fillMethod: str, optional

      :raises NotImplementedError: If a filling method other than "nearest" or "offTmin" is requested.



   .. py:method:: simulate_ht_dac_model(model = 'HT_okosun')

      Simulate the high-temperature (HT), liquid-solvent DAC (Direct Air Capture) model for a given model type.

      This function maps ambient temperature and relative humidity to energy demand,
      relative productivity, and water desorption for the specified DAC model.
      Currently, only the electrified HT DAC model "HT_okosun" is available.

      :param model: Type of DAC model to use. Currently, only "HT_okosun" is implemented.
                    Default is "HT_okosun".
      :type model: str, optional

      :raises NotImplementedError: If a DAC model type other than "HT_okosun" is requested.

      .. rubric:: Notes

      The "HT_okosun" model is based on a natural gas-fired HT-DAC system [1],
      adapted to an electrified version as described in [2,3]. The electrified
      DAC model only consumes electricity.

      .. rubric:: References

      [1] 10.1016/j.apenergy.2022.119895
      [2] 10.3389/fclim.2020.618644
      [3] 10.1016/j.adapen.2025.100229



.. py:function:: calculate_relative_humidity(dewpoint_temperature, air_temperature)

   Function to calculate the relative humidity from dewpoint temperature and air temperature using the Sonntag formula.

   :param dewpoint_temperature: dewpoint temperature in °C
   :type dewpoint_temperature: float | int
   :param air_temperature: air temperature in °C
   :type air_temperature: float | int

   .. rubric:: References

   [1] https://www.npl.co.uk/resources/q-a/dew-point-and-relative-humidity


.. py:class:: DACWorkflowManager(placements)

   Bases: :py:obj:`reskit.workflow_manager.WorkflowManager`


   The WorkflowManager class assists with the construction of more specialized WorkflowManagers,
   such as the WindWorkflowManager or the SolarWorkflowManager. In addition to providing the
   general structure for simulation workflow management, the WorkflowManager also defines
   functionalities which should be common across all WorkflowManagers.

   This includes:
     - Basic initialization
     - Time domain management
     - Reading weather data
     - Adjusting variables by a long-run-average value
     - Applying simple loss factors
     - Saving the state of WorkflowManagers to XArray datasets, either in memory or on disc

   Initialization:
   ---------------

   WorkflowManager( placements )


   __init_(self, placements)

   Initialization of an instance of the generic DACWorkflowManager class.

   :param placements: The locations that the simulation should be run for.
                      Columns must include "lon", "lat" (CRS: 4326) and "capacity"
                      -The capacity is the nominal capacity of the DAC plant in tCO2/h
   :type placements: pandas Dataframe

   :rtype: DACWorkflowManager


   .. py:attribute:: units


   .. py:method:: load_lt_dac_model_data(model)

      Function to load the DAC model data of a given model. The model data maps temperature and relative humidity to energy demand, relative productivity and water desorption.
      Description:
      The DAC model data needs columns "T" and "RH" where the temperature (°C) and relative humidity are included. Its a csv file.
      Additionally, the data needs columns:
          -"totalElectricity" where the needed electricity input in MWh/tCO2 is stated at the specified ambient conditions
          -"totalThermal" where the needed heat input in MWh/tCO2 is stated at the specified ambient conditions
          -"relProd" where the relative productivity (i.e. the cpaacity factor) is stated at the specified ambient conditions
          -"waterDesorption" where the produced water is stated in tH2O/tCO2. It might also be possible that this is negative (if water is consumed rather than produced)
      The currently available models:
          -LT_jajjawi: Data from the developed low temperature (solid sorbent) DAC model by Jajjawi et al. [1]. Here, the heat is needed at 90 °C.
          -LT_sendi: Data from the developed low temperature (solid sorbent) DAC model by Sendi et al. [2]. Here, the heat is needed at 110 °C (for steam generation). The original Sendi data has been adapted as described in Wenzel 2025 [3].

      :param model: type of DAC model to use. Valid inputs are: "LT_sendi", "LT_jajjawi" or a path to a csv with DAC model data in the same format as in ./data/
      :type model: str

      .. rubric:: References

      [1] http://dx.doi.org/10.2139/ssrn.5230783
      [2] 10.1016/j.oneear.2022.09.003
      [3] 10.1016/j.adapen.2025.100229



   .. py:method:: simulate_lt_dac_model(fillMethod = 'nearest')

      Simulate the LT DAC (Direct Air Capture) model for the specified plant locations.

      This function interpolates DAC model data to the simulation grid and calculates
      electricity, heat, and water requirements as well as CO2 output for the plants.
      It also handles points outside the convex hull of the DAC data using a specified
      fill method.

      :param fillMethod: Method to fill values for weather conditions outside the convex hull of
                         the DAC model data. Options are:
                         - "nearest" : use the nearest available datapoint (default)
                         - "offTmin" : cut off for temperatures below the DAC data range, use nearest
                         for relative humidity
      :type fillMethod: str, optional

      :raises NotImplementedError: If a filling method other than "nearest" or "offTmin" is requested.



   .. py:method:: simulate_ht_dac_model(model = 'HT_okosun')

      Simulate the high-temperature (HT), liquid-solvent DAC (Direct Air Capture) model for a given model type.

      This function maps ambient temperature and relative humidity to energy demand,
      relative productivity, and water desorption for the specified DAC model.
      Currently, only the electrified HT DAC model "HT_okosun" is available.

      :param model: Type of DAC model to use. Currently, only "HT_okosun" is implemented.
                    Default is "HT_okosun".
      :type model: str, optional

      :raises NotImplementedError: If a DAC model type other than "HT_okosun" is requested.

      .. rubric:: Notes

      The "HT_okosun" model is based on a natural gas-fired HT-DAC system [1],
      adapted to an electrified version as described in [2,3]. The electrified
      DAC model only consumes electricity.

      .. rubric:: References

      [1] 10.1016/j.apenergy.2022.119895
      [2] 10.3389/fclim.2020.618644
      [3] 10.1016/j.adapen.2025.100229



.. py:function:: lt_dac_era5_wenzel2025(placements, era5_path, output_netcdf_path = None, output_variables = None, model = 'LT_jajjawi', fillMethod = 'nearest')

   Simulate LT-DAC plants using ERA5 weather data.

   This function runs a full simulation workflow for low-temperature direct air capture (LT-DAC)
   plants. It reads ERA5 weather data, calculates relative humidity, loads the specified LT-DAC
   model data, performs the simulation, and optionally saves results to a NetCDF file.

   :param placements: DataFrame specifying the plant locations and capacities.
   :type placements: pd.DataFrame
   :param era5_path: Path to the ERA5 weather data source.
   :type era5_path: str
   :param output_netcdf_path: Path to save the output NetCDF file. If None, no file is saved. Default is None.
   :type output_netcdf_path: str, optional
   :param output_variables: List of variables from the simulation to include in the output NetCDF file.
                            If None, all available variables are included. Default is None.
   :type output_variables: list of str, optional
   :param model: DAC model data to utilize. Default is "LT_jajjawi".
   :type model: str, optional
   :param fillMethod: Method for filling weather conditions outside the DAC model data hull:
                      - "nearest" : use the nearest available datapoint (default)
                      - "offTmin" : cut off for temperatures outside the model range, nearest for relative humidity
   :type fillMethod: str, optional

   :returns: Simulation results, optionally limited to `output_variables` and including all plant locations.
   :rtype: xarray.Dataset

   .. rubric:: Notes

   The simulation includes calculation of:
   - relative humidity
   - DAC capacity factor
   - electricity, heat, and water conversion factors
   - CO2, water, electricity, and heat outputs per plant


.. py:function:: ht_dac_era5_wenzel2025(placements, era5_path, output_netcdf_path = None, output_variables = None, model = 'HT_okosun')

   Simulate HT-DAC plants using ERA5 weather data.

   This function runs a full simulation workflow for high-temperature direct air capture (HT-DAC)
   plants. It reads ERA5 weather data, calculates relative humidity, runs the specified HT-DAC
   model simulation, and optionally saves results to a NetCDF file.

   :param placements: DataFrame specifying the plant locations and capacities.
   :type placements: pd.DataFrame
   :param era5_path: Path to the ERA5 weather data source.
   :type era5_path: str
   :param output_netcdf_path: Path to save the output NetCDF file. If None, no file is saved. Default is None.
   :type output_netcdf_path: str, optional
   :param output_variables: List of variables from the simulation to include in the output NetCDF file.
                            If None, all available variables are included. Default is None.
   :type output_variables: list of str, optional
   :param model: DAC model to use. Currently, only "HT_okosun" is implemented. Default is "HT_okosun".
   :type model: str, optional

   :returns: Simulation results, optionally limited to `output_variables` and including all plant locations.
   :rtype: xarray.Dataset

   :raises AssertionError: If `model` is not "HT_okosun".

   .. rubric:: Notes

   The simulation includes calculation of:
   - relative humidity
   - DAC capacity factor
   - electricity conversion factor
   - CO2 output per plant

   The simulation relies on the `DACWorkflowManager` and the specified HT-DAC model.


