Skip to content

Commit

Permalink
Merge pull request #251 from Eddy-JV/Gas_pipelines
Browse files Browse the repository at this point in the history
Final_gas_pipelines
  • Loading branch information
hazemakhalek authored Jan 31, 2024
2 parents 2cb2bce + 6996338 commit 1bfaca0
Show file tree
Hide file tree
Showing 7 changed files with 1,039 additions and 56 deletions.
28 changes: 23 additions & 5 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,33 @@ rule solve_all_networks:

rule prepare_ports:
output:
ports="data/ports.csv",
# TODO move from data to resources
ports="data/ports.csv", # TODO move from data to resources
script:
"scripts/prepare_ports.py"


rule prepare_airports:
output:
ports="data/airports.csv",
# TODO move from data to resources
ports="data/airports.csv", # TODO move from data to resources
script:
"scripts/prepare_airports.py"


if not config["custom_data"]["gas_network"]:

rule prepare_gas_network:
input:
regions_onshore=pypsaearth(
"resources/bus_regions/regions_onshore_elec_s{simpl}_{clusters}.geojson"
),
output:
clustered_gas_network="resources/gas_networks/gas_network_elec_s{simpl}_{clusters}.csv",
gas_network_fig_1="resources/gas_networks/existing_gas_pipelines_{simpl}_{clusters}.png",
gas_network_fig_2="resources/gas_networks/clustered_gas_pipelines_{simpl}_{clusters}.png",
script:
"scripts/prepare_gas_network.py"


rule prepare_sector_network:
input:
network=RDIR
Expand All @@ -141,6 +154,9 @@ rule prepare_sector_network:
shapes_path=pypsaearth(
"resources/bus_regions/regions_onshore_elec_s{simpl}_{clusters}.geojson"
),
pipelines="resources/custom_data/pipelines.csv"
if config["custom_data"]["gas_network"]
else "resources/gas_networks/gas_network_elec_s{simpl}_{clusters}.csv",
output:
RDIR
+ "/prenetworks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{sopts}_{planning_horizons}_{discountrate}_{demand}.nc",
Expand Down Expand Up @@ -177,7 +193,6 @@ rule add_export:
output:
RDIR
+ "/prenetworks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{sopts}_{planning_horizons}_{discountrate}_{demand}_{h2export}export.nc",
# TODO output file name must be adjusted and integrated in workflow
script:
"scripts/add_export.py"

Expand Down Expand Up @@ -558,6 +573,8 @@ rule prepare_db:


rule run_test:
params:
dummy="This is a dummy parameter to satisfy snakefmt",
run:
import yaml

Expand All @@ -575,6 +592,7 @@ rule run_test:
shell("snakemake --cores all solve_all_networks --forceall")



rule clean:
run:
shell("rm -r " + PYPSAEARTH_FOLDER + "/resources")
Expand Down
37 changes: 24 additions & 13 deletions config.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ scenario:
simpl: # only relevant for PyPSA-Eur
- ""
clusters: # number of nodes in Europe, any integer between 37 (1 node per country-zone) and several hundred
- 4
- 74
planning_horizons: # investment years for myopic and perfect; or costs year for overnight
- 2030
ll:
Expand All @@ -23,7 +23,7 @@ scenario:
sopts:
- "144H"
demand:
- "DF"
- "AB"

policy_config:
policy: "H2_export_yearly_constraint" #either "H2_export_yearly_constraint", "H2_export_monthly_constraint", "no_res_matching"
Expand All @@ -37,26 +37,22 @@ policy_config:
clustering_options:
alternative_clustering: true

countries: ['MA']
countries: ['NG', 'BJ']

demand_data:
update_data: true # if true, the workflow downloads the energy balances data saved in data/demand/unsd/data again. Turn on for the first run.
base_year: 2019

other_industries: false # Whether or not to include industries that are not specified. some countries have has exageratted numbers, check carefully.

H2_network: false
H2_network_limit: 2000 #GWkm
H2_repurposed_network: false


enable:
retrieve_cost_data: true # if true, the workflow overwrites the cost data saved in data/costs again

fossil_reserves:
oil: 100 #TWh Maybe reduntant

hydrogen_underground_storage: false


export:
h2export: [120] # Yearly export demand in TWh
Expand All @@ -79,10 +75,9 @@ custom_data:
h2_underground: false
add_existing: false
custom_sectors: false
gas_grid: false
gas_network: false # If "True" then a custom .csv file must be placed in "resources/custom_data/pipelines.csv" , If "False" the user can choose btw "greenfield" or Model built-in datasets. Please refer to ["sector"] below.

# Costs used in PyPSA-Earth-Sec. Year depends on the wildcard "planning_horizon" in the scenario section
costs:
costs: # Costs used in PyPSA-Earth-Sec. Year depends on the wildcard planning_horizon in the scenario section
version: v0.6.2
lifetime: 25 #default lifetime
# From a Lion Hirth paper, also reflects average of Noothout et al 2016
Expand Down Expand Up @@ -163,8 +158,21 @@ solar_thermal:
azimuth: 180.

sector:
gas_network: true
oil_network: true
gas:
spatial_gas: true # ALWAYS TRUE
network: false # ALWAYS FALSE for now (NOT USED)
network_data: GGIT # Global dataset -> 'GGIT' , European dataset -> 'IGGIELGN'
network_data_GGIT_status: ['Construction', 'Operating', 'Idle', 'Shelved', 'Mothballed', 'Proposed']
hydrogen:
network: true
network_limit: 2000 #GWkm
network_routes: gas # "gas or "greenfield". If "gas" -> the network data are fetched from ["sector"]["gas"]["network_data"]. If "greenfield" -> the network follows the topology of electrical transmission lines
gas_network_repurposing: true # If true -> ["sector"]["gas"]["network"] is automatically true
underground_storage: false

oil:
spatial_oil: true

district_heating:
potential: 0.3 #maximum fraction of urban demand which can be supplied by district heating
#increase of today's district heating demand to potential maximum district heating share
Expand Down Expand Up @@ -268,6 +276,7 @@ sector:
AP_2030: 0.004
NZ_2030: 0.02
DF_2030: 0.01
AB_2030: 0.01
BU_2050: 0.00
AP_2050: 0.06
NZ_2050: 0.28
Expand All @@ -278,6 +287,7 @@ sector:
AP_2030: 0.075
NZ_2030: 0.13
DF_2030: 0.01
AB_2030: 0.01
BU_2050: 0.00
AP_2050: 0.42
NZ_2050: 0.68
Expand All @@ -295,6 +305,7 @@ sector:
AP_2030: 0.00
NZ_2030: 0.10
DF_2030: 0.05
AB_2030: 0.05
BU_2050: 0.00
AP_2050: 0.25
NZ_2050: 0.36
Expand Down
13 changes: 13 additions & 0 deletions scripts/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,19 @@ def aggregate_fuels(sector):
return gas_fuels, oil_fuels, biomass_fuels, coal_fuels, heat, electricity


def progress_retrieve(url, file):
import urllib

from progressbar import ProgressBar

pbar = ProgressBar(0, 100)

def dlProgress(count, blockSize, totalSize):
pbar.update(int(count * blockSize * 100 / totalSize))

urllib.request.urlretrieve(url, file, reporthook=dlProgress)


def get_last_commit_message(path):
"""
Function to get the last PyPSA-Earth Git commit message
Expand Down
Loading

0 comments on commit 1bfaca0

Please sign in to comment.