-
Notifications
You must be signed in to change notification settings - Fork 207
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
Incorrect computation of renewable profiles when alternative clustering is enabled #1272
Comments
Hello @choiHenry, thanks a lot for investigating it! I confirm that such an issue is reproducible and agree that it absolutely makes sense to elaborate a good architecture for a solution to fix these issues. @yerbol-akhmetov has also investigated it recently, and it may be a good idea to discuss. |
Hi, @choiHenry, @ekatef, @davide-f. As far as I know, the issue arises because in the |
I suspect it affects not only renewable profiles, but also demand profile and sector demands. |
Yeah, @yerbol-akhmetov, you got the issues indeed. |
Hi @yerbol-akhmetov and @davide-f. I totally agree with you. So I think to "start from number of buses equal to number of gadm regions, if alternative clustering is selected" as you said is a good way to go. And thank you very much for sharing materials to track @davide-f. I will check and respond. |
Hi, @choiHenry. I have tried to drop duplicates as you have suggested. I have noticed the potential of RES is now at the same level as regular clustering. It is even slightly lower (~1-2%), while in alternative clustering (AC) potential was around 4 times more for Nigeria. I have checked potential in |
Many thanks @choiHenry and @yerbol-akhmetov for the exploration! What about the total demand instead? can you check that? The regions onshore have implications into the demand estimation too. It is not a stable long-term solution, as it can lead to implications into the simplify_network and alike.
Personally, I'd be in favor of a simple fix on this as the architectural one is likely heavier with longer review time. |
Thanks for the feedback, @davide-f. I have checked the demand for Voronoi, Alternative clustering, and Alternative clustering with drop duplicates for Nigeria. The results are below in MWh. The numbers are almost identical. I have tried to look into isolated buses. In With this drop duplicates, it was luck that bus "78" was dropped, because it was in the final |
Many thanks to @davide-f, @yerbol-akhmetov, and @ekatef.
I am really happy to discuss this issue. I didn't recognize before at all. Out of 583 buses in South Korea, I identified 6 as isolated. n.determine_network_topology()
non_isolated_buses = n.buses.duplicated(subset=["sub_network"], keep=False)
len(n.buses) - len(n.buses[non_isolated_buses]) And I found that luckily, when dropped-out, no buses are isolated. isoloated_buses = list(n.buses[~non_isolated_buses].index)
onshore_regions.drop_duplicates("shape_id").index.isin(isoloated_buses) This might not be a mere luck since onshore_locs = n.buses.loc[c_b & n.buses.substation_lv, ["x", "y"]] Here, substation_lv, which is True if the bus has multiple voltages, drops many isolated(though not all) buses. In my case this dropped 4 out of 6 isolated buses.
if snakemake.params.alternative_clustering:
# determine isolated buses
n.determine_network_topology()
non_isolated_buses = n.buses.duplicated(subset=["sub_network"], keep=False)
isolated_buses = n.buses[~non_isolated_buses].index
# drop isolated buses
onshore_regions = onshore_regions[~onshore_regions.name.isin(isolated_buses)]
# drop duplicates based on shape_id
onshore_regions = onshore_regions.drop_duplicates('shape_id') Actually the demand was virtually same. So this could resolve the concerns about isolated buses included in the onshore bus regions and propagates to many other rules.
I guess adding detection process could improve code stability. if snakemake.params.alternative_clustering:
# determine isolated buses
n.determine_network_topology()
non_isolated_buses = n.buses.duplicated(subset=["sub_network"], keep=False)
isolated_buses = n.buses[~non_isolated_buses].index
# drop isolated buses
onshore_regions = onshore_regions[~onshore_regions.name.isin(isolated_buses)]
# drop duplicates based on shape_id
onshore_regions = onshore_regions.drop_duplicates('shape_id')
if len(onshore_regions) < len(gadm_country):
logger.error(
f"The number of remaining of buses are less than the number of administrative clusters suggested!"
)
raise ValueError("Insufficient buses to match administrative clusters!") Finally I also have a concern that this way might not be a long-term solution. When |
Hello! Great work @choiHenry @yerbol-akhmetov @davide-f 🙂 My feeling is that we have done great progress. After checking the population distribution ( However, @choiHenry I think you may be that we may lose some administrative regions. An example for US, when three different administrative regions are being merged into a single bus region: Not sure about the particular reason of this merge. Looking into the grid topology, the network is well interconnected and there are only a few buses which shouldn't be a problem. As a comment on the long-term strategy, #1258 should not create any obstacles for the proposed solution. I'd rather expect that we may need to revise it to implement a more general approach as outlined in #486. Though, I completely agree with @davide-f that this "architectural" solution is likely to be heavier, while we need a quick fix to improve functionality of the model. So, the work on that definitely make sense 🙂 |
Thank you for reporting a really important issue @ekatef. I think I need to check this myself. I will run a scenario for "USA" and response. |
@choiHenry thank you so much for your willingness to help. I have investigated a bit the issue, and shall post to outputs in #1248. The major output is that the fix you suggested has definitely improved the situation, and your PR on than would be very much appreciated. Here are some technical hints which could be probably helpful. Let us know please if you have any technical questions on how to deal with github and git. You have contributed significantly in finding a solution, and it would be really great to have your contribution incorporated into the repo. |
Thank you @ekatef. With your encouragement, I pull-requested #1287. I am currently working on a repo machine for the country "US" to check the issue you reported and investigated in #1248. I believe to investigate propagated results of the PR could contribute to the architecturally stable solutions for building bus regions for customized administrative regions. |
Thanks @ekatef for checking the issue it details. I have looked into |
Checklist
main
branch or the latest release. Please indicate.pypsa-earth
environment. Update viaconda env update -f envs/environment.yaml
.Describe the Bug
Renewable profiles
, especiallypotential
is incorrectly computed when alternative clustering is enabled.I found why the error occurred. And also corrected. But I want to know how to modify the whole pipeline correctly.
build_renewable_profiles
rule computespotential
byHere,
availability
is calculated byAgain,
region
is read from a path designated in Snakefile which is produced from rulebuild_bus_regions
.I want to point out that onshore
region
file made bybuild_bus_regions
is pretty much overlapped.If alternative clustering is turned on, rule
build_bus_regions
calculates onshore geometries(series) byHere, investigating
get_gadm_shape
,gadm_sel
includes overlapping geometries if the number of bus regions is less than the number of administrative regions(in my casen_bus = 461, n_regions=17
).renewable profiles
This might not be a good solution but it works for just calculating potentials.
Just modifying line 518 of "build_renewable_profiles.py"
regions = regions.set_index("name").rename_axis("bus")
bywill properly calculates potentials
I think this solution seems not good enough. It just can calculate potentials but it would be more fundamentally solve the problem if the rule
build_bus_regions
modified. I think the wholegadm
could be splitted to incorporate bus regions properly. Is this right way to solve the problem. Is there any possible risks for this solution?Thank you.
The text was updated successfully, but these errors were encountered: