Skip to content

Discrete variables#255

Open
FJanssen-TNO wants to merge 85 commits intomainfrom
discrete_variables
Open

Discrete variables#255
FJanssen-TNO wants to merge 85 commits intomainfrom
discrete_variables

Conversation

@FJanssen-TNO
Copy link
Collaborator

@FJanssen-TNO FJanssen-TNO commented Feb 18, 2025

Allowing discrete variables to be created in the pycml objects.
Implemented now for variables that are only linked to the asset itself and its energysystem properties.
Not implemented for variables that are dependent on other system variables, e.g. other assets or carrier options.

@KobusVanRooyen
Copy link
Collaborator

@FJanssen-TNO I like this, and so far it looks good to me

@FJanssen-TNO FJanssen-TNO marked this pull request as ready for review March 6, 2025 13:21
other_pipe = pipes_map[other_pipe_port]
if f"{other_pipe}.Q" not in alias_relation.canonical_variables:
alias_relation.add(f"{p}.Q", f"{sign_prefix}{other_pipe}.Q")
# if self.has_related_pipe(p):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Must this till be deleted?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added

self.__gas_storage_discharge_nominals[var_name] = self.variable_nominal(
f"{storage}.GasIn.Q"
)
# self.__gas_storage_discharge_nominals[var_name] = self.variable_nominal(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Must this still be deleted?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

deleted

var_name = f"{storage}.__Q_discharge"
self.__gas_storage_discharge_map[storage] = var_name
self.__gas_storage_discharge_var[var_name] = ca.MX.sym(var_name)
# self.__gas_storage_discharge_var[var_name] = ca.MX.sym(var_name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Must this still be deleted?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

deleted

self.__heat_flow_direct_bounds[flow_dir_var] = (0.0, 0.0)
else:
self.__heat_flow_direct_bounds[flow_dir_var] = (0.0, 1.0)
# else:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Must this still be deleted?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

deleted

flow_dir_var = f"{v}__flow_direct_var"

flow_dir_var = f"{v}.__flow_direct_var"
#
Copy link
Collaborator

Choose a reason for hiding this comment

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

Must this still be deleted?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

deleted

temp = max(parameters[f"{p}.temperature"], parameters[f"{p}.T_ground"])
assert big_m > 0.0

# big_m = big_m * 10 # kvr: This was needed to get the pipeline to pass
Copy link
Collaborator

Choose a reason for hiding this comment

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

This was my temporary code which needs to be deleted. Sorry about this one

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

deleted

def __init__(self, name, **modifiers):
super().__init__(name, **modifiers)

# away to create variables with a constant value over time is using the add_variable
Copy link
Collaborator

Choose a reason for hiding this comment

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

Must this still be deleted?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

deleted


# away to create variables with a constant value over time is using the add_variable
# fixed, it does create variabeles for all timesteps
# self.add_variable(Variable, "_cost_test", min=0.0, fixed=True)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Must this still be deleted?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

deleted


self.add_variable(Variable, "dH")

print(modifiers["HeatIn"]["Heat"], modifiers["HeatOut"]["Heat"])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Must this still be deleted?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

deleted

@KobusVanRooyen
Copy link
Collaborator

@FJanssen-TNO review has been completed

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.

2 participants