Skip to content

Comments

418 asset max size and esdl attribute used#419

Draft
KobusVanRooyen wants to merge 6 commits intomainfrom
418-asset-max-size-and-esdl-attribute-used
Draft

418 asset max size and esdl attribute used#419
KobusVanRooyen wants to merge 6 commits intomainfrom
418-asset-max-size-and-esdl-attribute-used

Conversation

@KobusVanRooyen
Copy link
Collaborator

@KobusVanRooyen KobusVanRooyen commented Feb 4, 2026

Update the esdl input variable used in MESIDO to limit the max size of an asset. Details in https://365tno.sharepoint.com/:x:/r/teams/P060.55186/TeamDocuments/Team/Work/Backend/Optimiser/ESDL%20compatibility%2020260121.xlsx?d=wbaacaf23f58f458091a47213eb3bedcd&csf=1&web=1&e=9LCNA7

  • HeatProducer, ResidualHeatSource, Heat pump (2 port and 4 port), eboiler, gasboiler -> Power [W]
  • ATES and Geothermal source -> Aggregation count, no units
  • HeatStorage (tank storage) -> Tanks storage [m3]
  • Pipe -> Diameter DNxxx -> separate PR
  • HeatExchange -> Capacity [W]

@KobusVanRooyen KobusVanRooyen linked an issue Feb 4, 2026 that may be closed by this pull request
Copy link
Collaborator

@tolga-akan tolga-akan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review is done

Copy link
Collaborator

@FJanssen-TNO FJanssen-TNO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setup seems to be okay. Haven't tested it myself, but provided a few small comments.
Test should be added to check that the constraint method is used for the newest esdl.

Comment on lines 343 to 347
if len(asset.attributes["constraint"]) > 1:
logger.warning(
f"More than 1 range constraint has been specified to "
f"asset named {asset.name}, currenlty only the 1st constraint is being used"
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens with assets that both have a profile constraint and a max power constraint. This would for instance occur on how aquathermal assets have to be implemented.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahhhh very nice catch. Thanks. Code has been updated to check type of constraints now

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several changes made to cater for this. Now checking if a constraint type exists etc

Comment on lines 349 to 352
logger.exit( # still to decide error vs warning
"Expected a range contraint (upper size limit) for asset named "
f"{asset.name}, but none has been specified."
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer a warning, as it might otherwise also break how other assets are being used, or in other workflows.

Comment on lines 368 to 377
if not max_value_range > 0.0:
get_potential_errors().add_potential_issue(
MesidoAssetIssueType.ASSET_UPPER_LIMIT,
asset.id,
f"Asset named {asset.name}: The maximum value in the range "
f"constraint for attribute {max_size_attribute} must be > 0."
)
# Raise the potential error here if applicable, with feedback to user
# Else a normal error exit might occer which will not give feedback to the user
potential_error_to_error(self._error_type_check)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you maybe generalise this part of the code as it is almost similar as in the enabled part? E.g. make small method, named "attribute_value_not_zero" or something and call it both here and in in line 388-397

Copy link
Collaborator Author

@KobusVanRooyen KobusVanRooyen Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. A function was added: _validate_attribute_value_not_zero

Copy link
Collaborator

@FJanssen-TNO FJanssen-TNO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The profile & range constraints indeed make it a bit more complicating, but I do think you found a proper way around it.
See a few generic comments from me below, besides that I think the structure of the new approach is okay.

Comment on lines +1866 to +1889
def __get_contraint_type_info(self, asset: Asset, constraint_type: esdl.Constraint) -> Union[
List[int], int
]:
"""
Get the contraint type info, if it exists, at an asset.

Arg:
asset: mesido common asset with all attributes
constraint type: the type of contraint specified (e.g. esdl.RangedConstraint,
esdl.ProfileConstraint)

Returns:
- Index of where the specific constraint is located in all the constraints specified
- Number of constraints of specific type that exists
-------

"""
idx_of_range_constraints = [
ii
for ii, xi in enumerate(asset.attributes["constraint"])
if isinstance(xi, constraint_type)
] # in the future me might want to cater for more than 1 range contraint
return idx_of_range_constraints, len(idx_of_range_constraints)

Copy link
Collaborator

@FJanssen-TNO FJanssen-TNO Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exact same method was also created in profile_parser.py.
Maybe it can be made non-private method, in for example esdl_additional_vars_mixin.py or esdl_heat_model.py such that it can be called in both sections and we don't have code duplication.

Comment on lines +70 to +74
idx_of_range_constraints = [
ii
for ii, xi in enumerate(asset.attributes["constraint"])
if isinstance(xi, constraint_type)
] # in the future me might want to cater for more than 1 range contraint
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we make a list of the indices of this type of constraint and why don't we just provide a list of the constraints are of this type?

Comment on lines +380 to +385
idx_of_range_constraints = [
ii
for ii, xi in enumerate(asset.attributes["constraint"])
if isinstance(xi, esdl.RangedConstraint)
] # in the future me might want to cater for more than 1 range contraint
len_idx_of_range_constraints = len(idx_of_range_constraints)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could aslo be replaced by __get_contraint_type_info()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Asset max size and esdl attribute used

3 participants