-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce PTES and TES constraints #1546
base: master
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
…nto ltes_stores # Bitte geben Sie eine Commit-Beschreibung ein, um zu erklären, warum dieser # Merge erforderlich ist, insbesondere wenn es einen aktualisierten # Upstream-Branch mit einem Thema-Branch zusammenführt. # # Zeilen, die mit '#' beginnen, werden ignoriert, # und eine leere Beschreibung bricht den Commit ab.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Just a few small comments. When the CI runs through, I'll test this locally.
def add_TES_etpr_constraints(n): | ||
""" | ||
Add a constraint for each TES storage unit enforcing: | ||
Store-e_nom - etpr * Link-p_nom == 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a more extensive docstring and type hinting for the input here.
""" | ||
Add constraints ensuring that for each TES unit, the charger and discharger are sized the same. | ||
Link-p_nom(charger) - efficiency * Link-p_nom(discharger) == 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a more extensive docstring and type hinting for the input here.
scripts/solve_network.py
Outdated
) | ||
tes_store_bool = n.stores.index.str.contains("water tanks|water pits") | ||
|
||
chargers_ext = n.links[tes_charger_bool].query("p_nom_extendable").index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use more descriptive variable names? (It's okay if they get long)
e.g. index_chargers_p_nom_extendable
or similar
scripts/solve_network.py
Outdated
linear_expr_list, dim="Store-ext, Link-ext", cls=type(linear_expr_list[0]) | ||
) | ||
|
||
n.model.add_constraints(merged_expr == 0, name="TES_etpr") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't we simplify the two functions to something like this:
# Extract indices of extendable TES chargers and storage units
charger_indices = n.links.index[n.links.index.str.contains("water tanks charger|water pits charger") & n.links.p_nom_extendable]
store_indices = n.stores.index[n.stores.index.str.contains("water tanks|water pits") & n.stores.e_nom_extendable]
# Extract energy-to-power ratio (ETPR) values
e2p_ratio = n.links.loc[charger_indices, "etpr"]
# Add constraints directly to the PyPSA model using vectorized operations
n.model.add_constraints(
n.model["Store-e_nom"].loc[store_indices] >= e2p_ratio.values * n.model["Link-p_nom"].loc[charger_indices],
name="TES_etpr"
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The challenge is that vectorizing these operations leads to unintended broadcasting. Since we have two different variables, p_nom and e_nom, vectorized multiplication would result in a 24x24 matrix if there are 24 chargers and 24 stores. This mismatch means the constraint wouldn’t correctly associate each TES store with its corresponding charger.
for more information, see https://pre-commit.ci
…nto ltes_stores
@amos-schledorn thanks for the review! I've implemented your suggestions. Moreover, i added error handling to ensure that the TES constraints are only applied when intended. |
Hi @fneum and @amos-schledorn, Currently, the CI is failing when running:
Reason for CI Failure: With this PR, the efficiency of both the central/decentral chargers and dischargers has been set to 1.0 according to the DEA catalogue. As a result, they can no longer act as heat vents, which prevents energy from being released. Additionally, chargers are now directly tied to the store size via the energy-to-power ratio, meaning they cannot be used independently. Possible Solution: Is there a specific reason why heat vents are currently only allowed for urban central heating? Or are there any concerns against extending this option to all systems? |
Changes proposed in this Pull Request
This pull request introduces the following adjustments to the
prepare_sector_network
andsolve_network
scripts, replacing PR #1444 (which did not work with the HiGHS solver):The following config data has been used:
Constraints
The etpr ratio constraint and the constraint enforcing equal sizing of the charger and discharger are working as intended, as shown in the figure below. In particular, the size of the store divided by 150 equals the size of both the charger and the discharger.
The annual charging and discharging process for an exemplary PTES store is illustrated in the figure below:
System Costs
System costs have increased slightly with the newly introduced constraints. This is logical given the larger capacities required when the charger and discharger can no longer be chosen independently.
Checklist
envs/environment.yaml
.config/config.default.yaml
.doc/configtables/*.csv
.doc/data_sources.rst
.doc/release_notes.rst
is added.