Closed Heronimonimo closed 5 years ago
Yes, unfortunately. The reason is the implementation detail, that the clustering step tries to aggregate generators with the same carrier at the same bus together and is unable to choose between whether the aggregated plants should be extendable or not.
If we chose extendable there, it would suddenly be allowed to make money from removing unused capacity. Not choosing extendable is obviously also wrong.
In the future it would make sense to move the extendable parts of the model to later in the chain between cluster_network
and prepare_network
, but that's quite an intrusive change i will more time for than I have.
The current work-around is to add an additional carrier 'OCGT-ext' or well 'OCGT-anything' and extend the code to ignore '-ext' or '-anything' for figuring out costs and parameters. I tested that it finishes successfully with the add_electricity
rule, don't want to vouch for the rest.
For me it does not work. I get the following error:
File "/home/pypsa/pypsa-eur/.snakemake/scripts/tmpw2sfv36r.add_electricity.py", line 347
bus=ocgt['bus'],
^
SyntaxError: invalid syntax
Might this have something to do with running the model for Belgium only?
Or does this have something to do with the powerplantmatching: false
in config.yaml
?
No, it’s not your fault. There are some obvious , missing. I’ll push a fix as soon as I get to a computer.
That's a quick response, thank you!
Now I run in to this:
INFO:pypsa.io:Imported network base.nc has buses, lines, transformers
INFO:__main__:Added connection cost of 12469-18579 Eur/MW/a to offwind-ac
INFO:__main__:Added connection cost of nan-nan Eur/MW/a to offwind-dc
Traceback (most recent call last):
File "/home/.conda/envs/pypsa-eur/lib/python3.6/site-packages/xarray/backends/netCDF4_.py", line 76, in _getitem
array = getitem(original_array, key)
File "netCDF4/_netCDF4.pyx", line 4096, in netCDF4._netCDF4.Variable.__getitem__
File "/home/.conda/envs/pypsa-eur/lib/python3.6/site-packages/netCDF4/utils.py", line 432, in _out_array_shape
c = count[..., i].ravel()[0] # All elements should be identical.
IndexError: index 0 is out of bounds for axis 0 with size 0
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pypsa/pypsa-eur/.snakemake/scripts/tmpcd9bk_fk.add_electricity.py", line 510, in <module>
attach_wind_and_solar(n, costs)
File "/home/pypsa/pypsa-eur/.snakemake/scripts/tmpcd9bk_fk.add_electricity.py", line 207, in attach_wind_and_solar
p_max_pu=ds['profile'].transpose('time', 'bus').to_pandas())
File "/home/.conda/envs/pypsa-eur/lib/python3.6/site-packages/xarray/core/dataarray.py", line 1626, in to_pandas
return constructor(self.values, *indexes)
File "/home/.conda/envs/pypsa-eur/lib/python3.6/site-packages/xarray/core/dataarray.py", line 407, in values
return self.variable.values
File "/home/.conda/envs/pypsa-eur/lib/python3.6/site-packages/xarray/core/variable.py", line 387, in values
return _as_array_or_item(self._data)
File "/home/.conda/envs/pypsa-eur/lib/python3.6/site-packages/xarray/core/variable.py", line 208, in _as_array_or_item
data = np.asarray(data)
File "/home/.conda/envs/pypsa-eur/lib/python3.6/site-packages/numpy/core/numeric.py", line 492, in asarray
return array(a, dtype, copy=False, order=order)
File "/home/.conda/envs/pypsa-eur/lib/python3.6/site-packages/xarray/core/indexing.py", line 564, in __array__
return np.asarray(self.array[self.key], dtype=None)
File "/home/.conda/envs/pypsa-eur/lib/python3.6/site-packages/xarray/backends/netCDF4_.py", line 65, in __getitem__
self._getitem)
File "/home/.conda/envs/pypsa-eur/lib/python3.6/site-packages/xarray/core/indexing.py", line 784, in explicit_indexing_adapter
result = raw_indexing_method(raw_key.tuple)
File "/home/.conda/envs/pypsa-eur/lib/python3.6/site-packages/xarray/backends/netCDF4_.py", line 87, in _getitem
raise IndexError(msg)
IndexError: The indexing operation you are attempting to perform is not valid on netCDF4.Variable object. Try loading your data into memory first by calling .load().
I already removed and set up the Conda environment again because I suspected the netCDF package to be the culprit, but the error is still there.
Edit: might this be to do with only running for Belgium that doesn't have space for DC offshore? Edit 2: this issue can be closed, problem above is related to #5
Generally, all generators (including OCGT) can have both existing and new capacity at the same time. This is done by setting them extendable=true and giving them a minimum capacity p_nom_min equal the existing capacity. This should be possible here as well.
@schlachtberger The problem is not the flexibility of PyPSA but rather the simplicity of the clustering code :)
Is it correct that the model can't currently have OCGTs as existing and new capacity at the same time?