Make code compatible with PyPSA-Eur v0.3.0

Only change was to remove the Store-Link-Bus combinations for
batteries and H2 storage from PyPSA-Eur, since they are implemented
with different names, costs and voltage level in PyPSA-Eur-Sec.

Removals are now done in a more transparent way in the config.yaml.
This commit is contained in:
Tom Brown 2020-12-09 15:18:01 +01:00
parent f34728c0c4
commit b8f1f30183
2 changed files with 17 additions and 9 deletions

View File

@ -56,6 +56,15 @@ electricity:
battery: 6
H2: 168
# regulate what components with which carriers are kept from PyPSA-Eur;
# some technologies are removed because they are implemented differently
# or have different year-dependent costs in PyPSA-Eur-Sec
pypsa_eur:
"Bus": ["AC"]
"Link": ["DC"]
"Generator": ["onwind", "offwind-ac", "offwind-dc", "solar", "ror"]
"StorageUnit": ["PHS","hydro"]
biomass:
year: 2030
scenario: "Med"

View File

@ -155,16 +155,15 @@ def remove_elec_base_techs(n):
"""remove conventional generators (e.g. OCGT) and storage units (e.g. batteries and H2)
from base electricity-only network, since they're added here differently using links
"""
to_keep = {"generators" : snakemake.config["plotting"]["vre_techs"],
"storage_units" : snakemake.config["plotting"]["renewable_storage_techs"]}
n.carriers = n.carriers.loc[to_keep["generators"] + to_keep["storage_units"]]
for components, techs in iteritems(to_keep):
df = getattr(n,components)
to_remove = df.carrier.value_counts().index^techs
print("removing {} with carrier {}".format(components,to_remove))
df.drop(df.index[df.carrier.isin(to_remove)],inplace=True)
for c in n.iterate_components(snakemake.config["pypsa_eur"]):
to_keep = snakemake.config["pypsa_eur"][c.name]
to_remove = pd.Index(c.df.carrier.unique())^to_keep
print("Removing",c.list_name,"with carrier",to_remove)
names = c.df.index[c.df.carrier.isin(to_remove)]
print(names)
n.mremove(c.name, names)
n.carriers.drop(to_remove, inplace=True, errors="ignore")
def add_co2_tracking(n):