Source code for tessif.frused.hooks.ppsa

# tessif/frused/hooks/ppsa.py
# -*- coding: utf-8 -*-
"""
:mod:`~tessif.frused.hooks.ppsa` is a :mod:`tessif` module aggregating
:ref:`pypsa specific <Models_Pypsa>` hooks to improve it's integration
into tessif.
"""
import pypsa
import numpy as np


[docs]def enforce_uid(): """ test """ pass
[docs]def add_flow_bound_emissions(attribute_dict): """ Pre simulation hook for extending pypsa components to enable flow specific emissions. After applying this hook, all pypsa energy system components will have an additional input parameter called ``flow_emissions`` which allows allocating flow specific emission values. The emission values are post processed using the :class:`~tessif.transform.es2mapping.ppsa.FlowResultier`. The overriding code was inspired by the `pypsa chp example <https://www.pypsa.org/examples/chp-fixed-heat-power-ratio.html>`_ Parameters ---------- attribute_dict: dict Dictionary returned by pypsa.components.component_attrs. Used for chaining hooks. Return ------ custom_attributes: dict Extended :paramref:`~add_flow_bound_emissions.attribute_dict` carrying the parameters for using flow bound emission values. """ co2_bound_components = ['Generator', 'Link', 'StorageUnit'] # bus flow emissions for component in co2_bound_components: attribute_dict[component].loc["flow_emissions"] = [ "static", # type "t_CO2eq/MW", # unit 0., # default "flow specific emissions", # docstring "Input (optional)" # input output and required/optional ] return attribute_dict
[docs]def add_siso_transfromer_type(attribute_dict): """ Pre simulation hook for extending pypsa links to act like siso transfromers. After applying this hook, all pypsa energy system components will have an additonal input parameter called ``siso_transformer`` as well as ``flow_costs`` which allows single input single output post processing. The overriding code was inspired by the `pypsa chp example <https://www.pypsa.org/examples/chp-fixed-heat-power-ratio.html>`_ Parameters ---------- attribute_dict: dict Dictionairy returned by pypsa.components.component_attrs. Used for chaining hooks. Return ------ custom_attributes: dict Extended :paramref:`~add_siso_transfromer_label.attribute_dict` carrying the parameters for using the extendend transfromer type. """ siso_transformer_components = ['Link', ] # bus flow emissions for component in siso_transformer_components: # adding the option to tell the post processors about multiple inputs attribute_dict[component].loc["siso_transformer"] = [ "bool", # type np.nan, # unit False, # default "Link has 1 input and 1 output", # docstring # input output and required/optional "Input (optional)" ] attribute_dict[component].loc["flow_costs"] = [ "static", # type "€/MW", # unit 0., # default "flow specific costs", # docstring "Input (optional)" # input output and required/optional ] attribute_dict["Link"].loc[f"expansion_costs"] = [ "static", # type "€/MW", # unit 0., # default "expansion cost", # docstring "Input (optional)" # input output and required/optional ] return attribute_dict
# # constrain link interface for each one requested: # for i in range(additional_interfaces): # # Guarantees c_m p_b1 \leq p_g1 # rule = network.links.at["boiler", "efficiency"] # def backpressure(model, snapshot): # return c_m*network.links.at["boiler", "efficiency"]*model.link_p["boiler", snapshot] <= network.links.at["generator", "efficiency"]*model.link_p["generator", snapshot] # network.model.backpressure = Constraint( # list(snapshots), rule=backpressure)