-
Notifications
You must be signed in to change notification settings - Fork 209
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
restore modifications for correct computation of AC hydro profiles #1293
base: main
Are you sure you want to change the base?
Conversation
Thanks for reporting @danielelerede-oet , I'll prioritize this. Unfortunate that it was not tracked during the testing of the alternative_clustering before... really need to change this architecture after the wave has passed |
Hi @davide-f , yes, I tested it on Nigeria, and compared with Voronoi clustering and previous results I already got and all works fine. We also need to test it on the US again after the fixes on the alternative clustering issue, but these modifications I performed should at least bring us back to the situation where hydro inflows were not overestimated. Just to clarify, nothing different is done with respect to #1119. |
Updateto improve validation, I've checked this PR (code name daniele), current main (upstream), current main before the recent PRs about alternative clustering (commit ef525ee) and the main with PR #1119 (commit 8073162), with/without alternative clustering on the tutorial case limited to Nigeria. Note: expected value of total energy inflow in tutorial (that adopts hydro_capacities) with no spillover is: Statistics of energy dispatch (focus hydro - storageunit):Statistics of inflowstotal inflows, calculated as the brutal sum of storage_units_t.inflow.sum().sum(): CommentOverall the PR looks quite needed. A possible issue during alternative_clustering is that:
This PR looks promising, and we can likely finalize soon. For reproducibility:config.yaml: countries: ["NG"]
run:
name: "ef525ee_tutorial" # use this to keep track of runs with different settings
cluster_options:
alternative_clustering: false # "False" use Voronoi shapes, "True" use GADM shapes with snakemake (code name _alternative) means snakemake command: Notebook attached for reproducibility if anyone is interested |
Hi @davide-f , I get the same results as you in the (expectedly obvious but always better to check), and I think it's worth to notice that the lower value we got for dispatch is actually closer to historical generation in 2013 (5.273 TWh, as from |
Hi, @danielelerede-oet, @davide-f. I have performed several runs for US with Voronoi and GADM clustering with EIA normalization for hydro using this PR. I have noticed also at the final network that capacities of hydro is very small for GADM clustering. As a result, generation for hydro was almost none. Here is the capacities in MW: |
Reassign buses for hydro powerplants
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.
Hello @yerbol-akhmetov and @danielelerede-oet :D
Great work! I have a minor restyling to avoid a double if clause :) This PR should restore the previous behavior and we can merge soon if needed fast.
Just to be sure, have you verified that the alternative approach matches the voronoi one like in previous comments?
A more long-term solution could be to avoid relying on regions onshore for hydro, but we can also keep it for another moment. If we agree on keeping the long-term solution for another moment, then I'd add an issue for that and merge this.
What do you think?
if snakemake.params.alternative_clustering: | ||
# bus to region mapping for hydro powerplants | ||
bus_to_region_id = ( | ||
ppl.drop_duplicates(subset="bus").set_index("bus")["region_id"].to_dict() | ||
) | ||
|
||
ppl = ( | ||
ppl.query('carrier == "hydro"') | ||
.reset_index(drop=True) | ||
.rename(index=lambda s: str(s) + " hydro") | ||
) | ||
|
||
with xr.open_dataarray(snakemake.input.profile_hydro) as inflow: | ||
if snakemake.params.alternative_clustering: | ||
for bus in inflow.indexes["plant"]: | ||
if bus in bus_to_region_id: | ||
region_to_update = bus_to_region_id[bus] | ||
# Update all rows in the DataFrame where region_id matches | ||
ppl.loc[ppl["region_id"] == region_to_update, "bus"] = bus | ||
|
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.
if snakemake.params.alternative_clustering: | |
# bus to region mapping for hydro powerplants | |
bus_to_region_id = ( | |
ppl.drop_duplicates(subset="bus").set_index("bus")["region_id"].to_dict() | |
) | |
ppl = ( | |
ppl.query('carrier == "hydro"') | |
.reset_index(drop=True) | |
.rename(index=lambda s: str(s) + " hydro") | |
) | |
with xr.open_dataarray(snakemake.input.profile_hydro) as inflow: | |
if snakemake.params.alternative_clustering: | |
for bus in inflow.indexes["plant"]: | |
if bus in bus_to_region_id: | |
region_to_update = bus_to_region_id[bus] | |
# Update all rows in the DataFrame where region_id matches | |
ppl.loc[ppl["region_id"] == region_to_update, "bus"] = bus | |
ppl = ( | |
ppl.query('carrier == "hydro"') | |
.reset_index(drop=True) | |
.rename(index=lambda s: str(s) + " hydro") | |
) | |
if snakemake.params.alternative_clustering: | |
# bus to region mapping for hydro powerplants | |
bus_to_region_id = ( | |
ppl.drop_duplicates(subset="bus").set_index("bus")["region_id"].to_dict() | |
) | |
with xr.open_dataarray(snakemake.input.profile_hydro) as inflow: | |
for bus in inflow.indexes["plant"]: | |
if bus in bus_to_region_id: | |
region_to_update = bus_to_region_id[bus] | |
# Update all rows in the DataFrame where region_id matches | |
ppl.loc[ppl["region_id"] == region_to_update, "bus"] = bus | |
Just a minor restyling; could you try this? [we can avoid 1 if clause]
Thank you for the comment! It would be great to refine it. I will make these changes. Update. Hi, @danielelerede-oet. Here is the PR of address restyling. |
Hello @yerbol-akhmetov and @danielelerede-oet :D @yerbol-akhmetov to clarify the image above of the dispatch comparison, what is the row of the hydro? |
Hi, @davide-f. Thanks for the comment. Yes, I will open a separate PR then (update: link to PR). And sorry about the image without proper names. Here is the hydro: Here is another results for generation. |
Changes proposed in this Pull Request
Hi @davide-f , we noticed with @yerbol-akhmetov that after merging the content of PR #1120 there were issues with renewable profiles. Indeed, that contribution was removing some of the changes introduced by PR #1119 . I restored the missing ones so that the computation of hydro profiles when using alternative clustering should be working fine again.
Checklist
envs/environment.yaml
anddoc/requirements.txt
.config.default.yaml
andconfig.tutorial.yaml
.test/
(note tests are changing the config.tutorial.yaml)doc/configtables/*.csv
and line references are adjusted indoc/configuration.rst
anddoc/tutorial.rst
.doc/release_notes.rst
is amended in the format of previous release notes, including reference to the requested PR.