pypsa-meets-earth / pypsa-earth

PyPSA-Earth: A flexible Python-based open optimisation model to study energy system futures around the world.
https://pypsa-earth.readthedocs.io/en/latest/
226 stars 177 forks source link

Missing load for countries leads to issue in cluster_network.py #165

Closed pz-max closed 2 years ago

pz-max commented 2 years ago

AssertionError: The following countries have no load: ['MW', 'LS', 'GN', 'SZ', 'GQ', 'MG', 'MR', 'SL', 'CF', 'TD']

pz-max commented 2 years ago

Hi @euronion , just trying to create a demonstration for a continental run. The following countries have no load data (load series with 0) and lead to cluster issues. If I remember correctly, there was a GEGIS issue. Are these missing loads related to that?

Can you report the issue from GEGIS here?

euronion commented 2 years ago

Yes, GEGIS for some reason does not output demand time-series for some countries. I haven't determined the cause.

For prototyping purposes you could copy the demand profile of a neighbouring country and scale it based on the population differences. Not perfect, but suitable to have something to work with.

pz-max commented 2 years ago

Sounds like prototype like solution ;)

pz-max commented 2 years ago

In commit https://github.com/pypsa-meets-africa/pypsa-africa/commit/ee9e4821decc99f35322e4bc7cdfde7f59c97144 , I added to the notebook pypsa-africa/notebooks/0demand_gegis.ipynb a script to update the missing timeseries and export a new Africa.nc load file. This new load time series needs to be manually replaced by the old file.

countries = ['MW', 'LS', 'GN', 'SZ', 'GQ', 'MG', 'MR', 'SL', 'CF', 'TD']
gdp = [12, 1.85, 15.6, 3.96, 10, 13.72, 7.7, 3.86, 2.3, 10] # Billion USD (2020)
base_country = ['NG']
base_gdp = 432

# Updates each missing load country to Nigeria based on GDP and Nigerias timeseries
for i in range(0, len(countries), 1):
    ds.loc[dict(region_code=countries[i])] = demand.loc[dict(region_code="NG")]*(gdp[i]/base_gdp)
davide-f commented 2 years ago

In the whole workflow, there are still issues for countries with almost a single node. With the latest version, the problem arises with the following countries: ['DJ', 'BF', 'RW', 'ML']

The above is not a problem of missing input data, but rather that only a single bus with a generator is available for each of them (roughly) and this may have consequences; yet I have not investigated that deeply yet

Edit: the problem should be in the add_electricity script

Edit2: the problem may be due to the fact that the time series related to those 4 countries are identically equal to zero; by debugging the function attach_load the above can be verified

Edit3: the timeseries for those countries are zero as they are zero in the original dataset of Africa.nc; as a temporary fix, we may change the value similarly to the other countries.

pz-max commented 2 years ago

@davide-f Yep, will add these countries to pypsa-africa/notebooks/0demand_gegis.ipynb notebook. This notebook creates new time series in the Africa.nc file based on GDP

The new list of original missing load countries: ['MW', 'LS', 'GN', 'SZ', 'GQ', 'MG', 'MR', 'SL', 'CF', 'TD', 'EH', 'GM', 'LR', 'DJ', 'BF', 'RW', 'ML']