Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/mesido/asset_sizing_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,9 +801,7 @@ def _make_max_size_var(name, lb, ub, nominal):
ub = bounds[f"{asset_name}.Heat_source"][1]

# Update bound to account for profile constraint being used instead of 1 value
esdl_asset_attributes = self.esdl_assets[
self.esdl_asset_name_to_id_map[asset_name]
].attributes["constraint"]
esdl_asset_attributes = self.esdl_assets[asset_name].attributes["constraint"]
if (
len(esdl_asset_attributes) > 0
and hasattr(esdl_asset_attributes.items[0], "maximum")
Expand Down Expand Up @@ -1927,9 +1925,7 @@ def __max_size_constraints(self, ensemble_member):

# Cap the heat produced via a profile. Two profile options below.
# Option 1: Profile specified in absolute values [W] via a ProfileConstraint
esdl_asset_attributes = self.esdl_assets[
self.esdl_asset_name_to_id_map[s]
].attributes["constraint"]
esdl_asset_attributes = self.esdl_assets[s].attributes["constraint"]
if (
len(esdl_asset_attributes) > 0
and hasattr(esdl_asset_attributes.items[0], "maximum")
Expand Down
4 changes: 2 additions & 2 deletions src/mesido/esdl/esdl_additional_vars_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def __limit_list_available_heat_pipe_classes_max_power(
*self.energy_system_components.get("heat_buffer", []),
*self.energy_system_components.get("heat_pump", []),
]:
esdl_asset = self.esdl_assets[self.esdl_asset_name_to_id_map[asset]]
esdl_asset = self.esdl_assets[asset]
for constraint in esdl_asset.attributes.get("constraint", []):
if constraint.name == "setpointconstraint":
time_unit = constraint.range.profileQuantityAndUnit.perTimeUnit
Expand Down Expand Up @@ -252,7 +252,7 @@ def temperature_regimes(self, carrier):
*self.energy_system_components.get("heat_exchanger", []),
*self.energy_system_components.get("heat_demand", []),
]:
esdl_asset = self.esdl_assets[self.esdl_asset_name_to_id_map[asset]]
esdl_asset = self.esdl_assets[asset]
parameters = self.parameters(0)
for i in range(len(esdl_asset.attributes["constraint"].items)):
constraint = esdl_asset.attributes["constraint"].items[i]
Expand Down
15 changes: 9 additions & 6 deletions src/mesido/esdl/esdl_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,23 +629,26 @@ def hot_cold_pipe_relations(self):
self.__unrelated_pipes.append(asset.name)
else:
pipes = self.energy_system_components.get("heat_pipe", [])
for pipe in pipes:
for pipe_id in pipes:
related = False
# test if hot_pipe
pipe = self.esdl_asset_id_to_name_map[pipe_id]
if not pipe.endswith("_ret"):
cold_pipe = f"{pipe}_ret"
if cold_pipe in pipes:
cold_pipe_id = self.esdl_asset_name_to_id_map[cold_pipe]
if cold_pipe_id in pipes:
related = True
if pipe not in self.__hot_cold_pipe_relations.keys():
self.__hot_cold_pipe_relations[pipe] = cold_pipe
self.__hot_cold_pipe_relations[pipe_id] = cold_pipe_id
elif pipe.endswith("_ret"):
hot_pipe = pipe[:-4]
if hot_pipe in pipes:
hot_pipe_id = self.esdl_asset_name_to_id_map[hot_pipe]
if hot_pipe_id in pipes:
related = True
if hot_pipe not in self.__hot_cold_pipe_relations.keys():
self.__hot_cold_pipe_relations[hot_pipe] = pipe
self.__hot_cold_pipe_relations[hot_pipe_id] = pipe_id
if not related and pipe not in self.__unrelated_pipes:
self.__unrelated_pipes.append(pipe)
self.__unrelated_pipes.append(pipe_id)

@property
def hot_to_cold_pipe_map(self) -> Dict:
Expand Down
16 changes: 8 additions & 8 deletions src/mesido/esdl/esdl_model_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _esdl_convert(

for asset in list(assets_sorted.values()):
pycml_type, modifiers = converter.convert(asset)
self.add_variable(pycml_type, asset.name, **modifiers)
self.add_variable(pycml_type, asset.id, **modifiers)

in_suf = "HeatIn"
out_suf = "HeatOut"
Expand Down Expand Up @@ -136,7 +136,7 @@ def __set_primary_secondary_heat_ports():
port_map[p.id] = getattr(component.Secondary, out_suf)

for asset in non_node_assets:
component = getattr(self, asset.name)
component = getattr(self, asset.id)
# We assume that every component has 2 ports. Essentially meaning that we are dealing
# with a single commodity for a component. Exceptions, assets that deal with multiple
# have to be specifically specified what port configuration is expected in the model.
Expand Down Expand Up @@ -322,9 +322,9 @@ def __set_pipe_port_connections(
type_node_assets: list of node assets of a specific commodity.
"""
if connected_to.id in list(port_map.keys()) and (
assets[name_to_id_map[port_map[connected_to.id].name.split(".")[0]]].asset_type
assets[port_map[connected_to.id].name.split(".")[0]].asset_type
== "Pipe"
or assets[name_to_id_map[port_map[connected_to.id].name.split(".")[0]]].asset_type
or assets[port_map[connected_to.id].name.split(".")[0]].asset_type
== "ElectricityCable"
):
self.connect(getattr(component, node_suffixes)[i], port_map[connected_to.id])
Expand All @@ -347,7 +347,7 @@ def __set_pipe_port_connections(
count += 1
self.connect_logical_links(
getattr(component, node_suffixes)[i],
getattr(getattr(self, connected_node_asset.name), node_suffixes)[idx],
getattr(getattr(self, connected_node_asset.id), node_suffixes)[idx],
)
else:
# If the Connected asset is not of type pipe, there might be
Expand All @@ -358,7 +358,7 @@ def __set_pipe_port_connections(
connections.add(conn)

for asset in [*node_assets, *bus_assets, *gas_node_assets]:
component = getattr(self, asset.name)
component = getattr(self, asset.id)

i = 1
if len(asset.in_ports) != 1 or len(asset.out_ports) != 1:
Expand Down Expand Up @@ -432,11 +432,11 @@ def __set_pipe_port_connections(
asset.asset_type == "Pipe"
or asset.asset_type == "ElectricityCable"
or assets[
name_to_id_map[port_map[connected_to.id].name.split(".")[0]]
port_map[connected_to.id].name.split(".")[0]
].asset_type
== "Pipe"
or assets[
name_to_id_map[port_map[connected_to.id].name.split(".")[0]]
port_map[connected_to.id].name.split(".")[0]
].asset_type
== "ElectricityCable"
):
Expand Down
9 changes: 6 additions & 3 deletions src/mesido/esdl/profile_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def read_profiles(
for component_type, var_name in self.component_type_to_var_name_map.items():
for component in energy_system_components.get(component_type, []):
profile = self._profiles[ensemble_member].get(component + var_name, None)
asset_power = esdl_assets[esdl_asset_names_to_ids[component]].attributes[
asset_power = esdl_assets[component].attributes[
"power"
]
if profile is not None:
Expand Down Expand Up @@ -626,6 +626,7 @@ def _load_profiles_from_source(
elif self._file_path.suffix == ".csv":
self._load_csv(
energy_system_components=energy_system_components,
esdl_asset_id_to_name_map=esdl_asset_id_to_name_map,
carrier_properties=carrier_properties,
ensemble_size=ensemble_size,
)
Expand All @@ -637,6 +638,7 @@ def _load_profiles_from_source(
def _load_csv(
self,
energy_system_components: Dict[str, Set[str]],
esdl_asset_id_to_name_map,
carrier_properties: Dict[str, Dict],
ensemble_size: int,
) -> None:
Expand Down Expand Up @@ -681,7 +683,8 @@ def _load_csv(
for component_type, var_name in self.component_type_to_var_name_map.items():
for component_name in energy_system_components.get(component_type, []):
try:
column_name = f"{component_name.replace(' ', '')}"
asset_name = esdl_asset_id_to_name_map[component_name]
column_name = f"{asset_name.replace(' ', '')}"
values = data[column_name].to_numpy()
if np.isnan(values).any():
raise Exception(
Expand Down Expand Up @@ -759,7 +762,7 @@ def variable(self, pi_header):
location_id = pi_header.find("pi:locationId", self.ns).text

try:
component_name = self.__id_map[location_id]
component_name = location_id
except KeyError:
parameter_id = pi_header.find("pi:parameterId", self.ns).text
qualifiers = pi_header.findall("pi:qualifierId", self.ns)
Expand Down
Loading