Skip to content

Commit

Permalink
Merge pull request #116 from koen-vg/new-main
Browse files Browse the repository at this point in the history
Integrate powerplantmatching
  • Loading branch information
pz-max committed Oct 15, 2021
2 parents ce17c58 + 293450f commit 71e06f8
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 7 deletions.
14 changes: 13 additions & 1 deletion Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,24 @@ rule build_renewable_profiles:
script: "scripts/build_renewable_profiles.py"


rule build_powerplants:
input:
base_network="networks/base.nc",
pm_config="powerplantmatching_config.yaml",
custom_powerplants="data/custom_powerplants.csv"
output: "resources/powerplants.csv"
log: "logs/build_powerplants.log"
threads: 1
resources: mem=500
script: "scripts/build_powerplants.py"


rule add_electricity:
input:
base_network='networks/base.nc',
tech_costs=COSTS,
regions="resources/regions_onshore.geojson",
# powerplants='resources/powerplants.csv',
powerplants='resources/powerplants.csv',
# hydro_capacities='data/bundle/hydro_capacities.csv',
# geth_hydro_capacities='data/geth2015_hydro_capacities.csv',
load='resources/ssp2-2.6/2030/era5_2013/Africa.nc',
Expand Down
4 changes: 4 additions & 0 deletions config.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,14 @@ electricity:
Store: [battery, H2]
Link: []

conventional_carriers: ["OCGT", "CCGT", "oil"]

max_hours:
battery: 6
H2: 168

powerplants_filter:

lines:
types:
220.: "Al/St 240/40 2-bundle 220.0"
Expand Down
122 changes: 122 additions & 0 deletions configs/powerplantmatching_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# io config
entsoe_token:
google_api_key:
opsd_vres_base_year: 2016


#matching config
matching_sources:
- CARMA
- GPD
- GEO

fully_included_sources:
- CARMA
- GPD
- GEO

parallel_duke_processes: false
process_limit: 2
remove_missing_coords: true

matched_data_url:

display_net_caps: true
target_columns:
- Name
- Fueltype
- Technology
- Set
- Country
- Capacity
- Efficiency
- Duration
- Volume_Mm3
- DamHeight_m
- StorageCapacity_MWh
- DateIn
- DateRetrofit
- DateMothball
- DateOut
- lat
- lon
# - File
- EIC
- projectID

target_fueltypes:
- Bioenergy
- Geothermal
- Hard Coal
- Hydro
- Lignite
- Natural Gas
- Nuclear
- Oil
- Other
- Solar
- Waste
- Wind

target_sets:
- CHP
- PP
- Store

target_technologies:
- CCGT
- OCGT
- Steam Turbine
- Combustion Engine
- Run-Of-River
- Pumped Storage
- Reservoir
- Marine
- Onshore
- Offshore
- PV
- CSP

# heuristic config
fuel_to_lifetime:
Bioenergy: 20
Geothermal: 15
Hard Coal: 45
Hydro: 100
Lignite: 45
Natural Gas: 40
Nuclear: 50
Oil: 40
Other: 5
Solar: 25
Waste: 25
Wind: 25

# plotting config
fuel_to_color:
OCGT: darkorange
Hydro: seagreen
Pumped hydro: limegreen
Run-of-river: navy
Ror: navy
Lignite: saddlebrown
Nuclear: yellow
Solar: gold
Windoff: cornflowerblue
Windon: darkblue
Offshore: cornflowerblue
Onshore: darkblue
Wind: steelblue
Bioenergy: g
Natural Gas: red
CCGT: red
Coal: k
Hard Coal: dimgray
Oil: darkgreen
Other: silver
Waste: grey
Geothermal: orange
Battery: purple
Hydrogen Storage: teal
Electro-mechanical: teal
Total: gold
3 changes: 2 additions & 1 deletion envs/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ dependencies:
- yaml
- pytables
- lxml
- powerplantmatching>=0.4.8
- numpy
- pandas
- geopandas
Expand All @@ -40,6 +39,7 @@ dependencies:
- pre-commit
- pyomo
- matplotlib
- openjdk

# Keep in conda environment when calling ipython
- ipython
Expand All @@ -63,6 +63,7 @@ dependencies:

- pip:
- git+https://github.com/pypsa/pypsa.git#egg=pypsa
- git+https://github.com/koen-vg/powerplantmatching.git@pypsa-africa#egg=powerplantmatching
- vresutils==0.3.1
- tsam>=1.1.0
- esy-osm-pbf
Expand Down
6 changes: 3 additions & 3 deletions scripts/add_electricity.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,16 +698,16 @@ def add_nice_carrier_names(n, config=None):
admin_shapes = snakemake.input.gadm_shapes

costs = load_costs(Nyears)
# ppl = load_powerplants()
ppl = load_powerplants()

attach_load(n, regions, load, admin_shapes, countries, scale)

update_transmission_costs(n, costs)

# attach_conventional_generators(n, costs, ppl)
attach_conventional_generators(n, costs, ppl)
attach_wind_and_solar(n, costs)
# attach_hydro(n, costs, ppl)
# attach_extendable_generators(n, costs, ppl)
attach_extendable_generators(n, costs, ppl)

# estimate_renewable_capacities(n)
# attach_OPSD_renewables(n)
Expand Down
8 changes: 6 additions & 2 deletions scripts/build_powerplants.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
custom_powerplants: YearCommissioned <= 2015
"""

import yaml
import logging
from _helpers import configure_logging

Expand Down Expand Up @@ -75,12 +76,15 @@ def add_custom_powerplants(ppl):
snakemake = mock_snakemake('build_powerplants')
configure_logging(snakemake)

with open(snakemake.input.pm_config, "r") as f:
config = yaml.safe_load(f)

n = pypsa.Network(snakemake.input.base_network)
countries = n.buses.country.unique()
config['target_countries'] = countries

ppl = (pm.powerplants(from_url=True)
ppl = (pm.powerplants(from_url=False, config=config)
.powerplant.fill_missing_decommyears()
.powerplant.convert_country_to_alpha2()
.query('Fueltype not in ["Solar", "Wind"] and Country in @countries')
.replace({'Technology': {'Steam Turbine': 'OCGT'}})
.assign(Fueltype=lambda df: (
Expand Down

0 comments on commit 71e06f8

Please sign in to comment.