diff --git a/src/mesido/esdl/esdl_heat_model.py b/src/mesido/esdl/esdl_heat_model.py index b16c2bf4..faeba848 100644 --- a/src/mesido/esdl/esdl_heat_model.py +++ b/src/mesido/esdl/esdl_heat_model.py @@ -493,6 +493,27 @@ def _get_min_voltage(self, asset: Asset) -> float: raise RuntimeError(f"{asset.name} has no inport with electricity commodity") return min_voltage + # Use this to create asset in the building? + def convert_building(self, asset: Asset) -> Tuple[Type[HeatDemand], MODIFIERS]: + """ + ... + """ + + # create heating demand and cooling demand asset? + # where do we add measure attributes -> current named insulation_levels -> attributes + # def insulation_levels(self): + # attributes = { + # "insulation_level": ["A", "B", "C"], + # "scaling_factor": [0.6, 0.9, 1.0], + # "Tmin_deg": [50, 60, 70], + # "insulation_cost_euro": [5.0e6, 2.0e6, 1.0e6], + # } + # return attributes + # since it is not only profiles that are retrieved I do not think it makes sense to populate this profiles code + + # loop over assets contained in a building here? + return + def convert_heat_buffer( self, asset: Asset ) -> Tuple[Union[Type[HeatBufferElec], Type[HeatBuffer]], MODIFIERS]: @@ -2984,5 +3005,6 @@ def __init__( }, } ) - + + # HConnection is also new in these assets being passed here self._esdl_convert(converter, assets, name_to_id_map, "MILP") diff --git a/src/mesido/esdl/esdl_model_base.py b/src/mesido/esdl/esdl_model_base.py index 2ce9556e..c1e647ac 100644 --- a/src/mesido/esdl/esdl_model_base.py +++ b/src/mesido/esdl/esdl_model_base.py @@ -61,9 +61,12 @@ def _esdl_convert( # are used to set nominals for other assets that are then parsed later. assets_sorted = assets_transport | assets_other + # Should the Hconnection be used here? for asset in list(assets.values()): converter.port_asset_type_connections(asset) + # Building asset to be used in converter, to add .... + # Heating demands in the building should be created via building? do we loop over assets in the building over here or in the buidling convert? for asset in list(assets_sorted.values()): pycml_type, modifiers = converter.convert(asset) self.add_variable(pycml_type, asset.id, **modifiers) diff --git a/src/mesido/esdl/esdl_parser.py b/src/mesido/esdl/esdl_parser.py index 89d0c534..6f8b6fd2 100644 --- a/src/mesido/esdl/esdl_parser.py +++ b/src/mesido/esdl/esdl_parser.py @@ -120,6 +120,15 @@ def read_esdl(self) -> None: asset_type = el.__class__.__name__ # Every asset should at least have a port to be connected to another asset + # Issue here since the demands in measures do not need ports (so 0) they will + # only have attributes like profiles, costs, temp values etc. + # isinstance(el, esdl.Building) + # isinstance(el, esdl.HConnection) -> need this for connections to assets in the building + # At this point there is no way to see that this is a demand in measure, building, + if el.name in [ + "HeatingDemand_1", "HeatingDemand_2", "CoolingDemand_1", "CoolingDemand_2" + ]: + continue # temporary for now assert len(el.port) >= 1 in_ports = None diff --git a/tests/models/building/model/source buildingsink with multiple demand profiles.esdl b/tests/models/building/model/source buildingsink with multiple demand profiles.esdl new file mode 100644 index 00000000..7bcd571c --- /dev/null +++ b/tests/models/building/model/source buildingsink with multiple demand profiles.esdl @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/models/building/run_case.py b/tests/models/building/run_case.py new file mode 100644 index 00000000..c256e097 --- /dev/null +++ b/tests/models/building/run_case.py @@ -0,0 +1,30 @@ +import logging +from pathlib import Path + +from mesido.esdl.esdl_parser import ESDLFileParser +from mesido.esdl.profile_parser import ProfileReaderFromFile +from mesido.workflows import EndScenarioSizingStaged, run_end_scenario_sizing + +logger = logging.getLogger("mesido") +logger.setLevel(logging.INFO) + + +if __name__ == "__main__": + import time + from mesido.workflows import EndScenarioSizingStaged, run_end_scenario_sizing + # from mesido.workflows.utils.error_types import NetworkError + + start_time = time.time() + base_folder = Path(__file__).resolve().parent + + solution = run_end_scenario_sizing( + EndScenarioSizingStaged, + base_folder=base_folder, + esdl_file_name="source buildingsink with multiple demand profiles.esdl", + esdl_parser=ESDLFileParser, + profile_reader=ProfileReaderFromFile, + # error_type_check=NetworkErrors.HEAT_AND_COOL_NETWORK_ERRORS, + ) + results = solution.extract_results() + + print("Execution time: " + time.strftime("%M:%S", time.gmtime(time.time() - start_time))) \ No newline at end of file