def adding_assets_to_energysystem_model(dict_values, dict_model, model, **kwargs): """ Parameters ---------- dict_values: dict dict of simulation data dict_model: Updated list of assets in the oemof energy system model model: oemof.solph.network.EnergySystem Model of oemof energy system Returns ------- """ logging.info("Adding components to oemof energy system model...") # Busses have to be defined first for bus in dict_values[ENERGY_BUSSES]: D1.bus(model, dict_values[ENERGY_BUSSES][bus][LABEL], **dict_model) # Adding step by step all assets defined within the asset groups for asset_group in ACCEPTED_ASSETS_FOR_ASSET_GROUPS: if asset_group in dict_values: for asset in dict_values[asset_group]: type = dict_values[asset_group][asset][OEMOF_ASSET_TYPE] # Checking if the asset type is one accepted for the asset group (security measure) if type in ACCEPTED_ASSETS_FOR_ASSET_GROUPS[asset_group]: # if so, then the appropriate function of D1 should be called if type == OEMOF_TRANSFORMER: D1.transformer(model, dict_values[asset_group][asset], **dict_model) elif type == OEMOF_SINK: D1.sink(model, dict_values[asset_group][asset], **dict_model) elif type == OEMOF_SOURCE: D1.source(model, dict_values[asset_group][asset], **dict_model) elif type == OEMOF_GEN_STORAGE: D1.storage(model, dict_values[asset_group][asset], **dict_model) else: raise UnknownOemofAssetType( f"Asset {asset} has type {type}, " f"but this type is not a defined oemof asset type." ) else: raise WrongOemofAssetForGroupError( f"Asset {asset} has type {type}, " f"but this type is not an asset type attributed to asset group {asset_group}" f" for oemof model generation.") logging.debug("All components added.") return model
def test_transformer_fix_cap_multiple_input_busses(self, ): dict_asset = self.dict_values[ENERGY_CONVERSION][ "transformer_fix_multiple_input_busses"] D1.transformer( model=self.model, dict_asset=dict_asset, transformer=self.transformers, bus=self.busses, ) # one output bus and two input busses assert ( len([str(i) for i in self.model.entities[-1].outputs]) == 1 ), f"Amount of output busses of transformer should be one but is {len([str(i) for i in self.model.entities[-1].outputs])}." assert ( len([str(i) for i in self.model.entities[-1].inputs]) == 2 ), f"Amount of output busses of transformer should be two but is {len([str(i) for i in self.model.entities[-1].inputs])}." # checks done with helper function (see func for more information) self.helper_test_transformer_in_model_and_dict(optimize=False, dict_asset=dict_asset)