Skip to content

Commit

Permalink
Merge pull request #462 from PyPSA/sec-updates
Browse files Browse the repository at this point in the history
Link to Generator fix
  • Loading branch information
trevorb1 authored Oct 28, 2024
2 parents 605ef82 + bbf30df commit b50bf9b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 26 deletions.
49 changes: 29 additions & 20 deletions workflow/scripts/add_sectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,23 @@ def get_pwr_co2_intensity(carrier: str, costs: pd.DataFrame) -> float:
different names in translation to a sector study.
"""

# the ccs case are a hack solution

match carrier:
case "gas":
return 0
case "CCGT" | "OCGT" | "ccgt" | "ocgt":
return costs.at["gas", "co2_emissions"]
case "lpg":
return costs.at["oil", "co2_emissions"]
case "CCGT-95CCS" | "CCGT-97CCS":
base = costs.at["gas", "co2_emissions"]
ccs_level = int(carrier.split("-")[1].replace("CCS", ""))
return (1 - ccs_level / 100) * base
case "coal-95CCS" | "coal-99CCS":
base = costs.at["gas", "co2_emissions"]
ccs_level = int(carrier.split("-")[1].replace("CCS", ""))
return (1 - ccs_level / 100) * base
case _:
return costs.at[carrier, "co2_emissions"]

Expand Down Expand Up @@ -378,13 +388,19 @@ def get_pwr_co2_intensity(carrier: str, costs: pd.DataFrame) -> float:
for carrier in ("oil", "coal", "gas"):
add_supply = False if carrier == "gas" else True # gas added in build_ng()
add_sector_foundation(n, carrier, add_supply, costs, center_points)
co2_intensity = get_pwr_co2_intensity(carrier, costs)
convert_generators_2_links(n, carrier, f" {carrier}", co2_intensity)

for carrier in ("OCGT", "CCGT"):
for carrier in ("OCGT", "CCGT", "CCGT-95CCS", "CCGT-97CCS"):
co2_intensity = get_pwr_co2_intensity(carrier, costs)
convert_generators_2_links(n, carrier, f" gas", co2_intensity)

for carrier in ("coal", "coal-95CCS", "coal-99CCS"):
co2_intensity = get_pwr_co2_intensity(carrier, costs)
convert_generators_2_links(n, carrier, f" coal", co2_intensity)

for carrier in ["oil"]:
co2_intensity = get_pwr_co2_intensity(carrier, costs)
convert_generators_2_links(n, carrier, f" oil", co2_intensity)

ng_options = snakemake.params.sector["natural_gas"]

# add natural gas infrastructure and data
Expand All @@ -403,7 +419,7 @@ def get_pwr_co2_intensity(carrier: str, costs: pd.DataFrame) -> float:
# this must happen after natural gas system is built
methane_options = snakemake.params.sector["methane"]
leakage_rate = methane_options.get("leakage_rate", 0)
if leakage_rate > 0.000001:
if leakage_rate > 0.00001:
gwp = methane_options.get("gwp", 1)
build_ch4_tracking(n, gwp, leakage_rate)

Expand Down Expand Up @@ -457,22 +473,15 @@ def get_pwr_co2_intensity(carrier: str, costs: pd.DataFrame) -> float:

# check for end-use brownfield requirements

if any(
[
snakemake.params.sector["service_sector"]["brownfield"],
snakemake.params.sector["transport_sector"]["brownfield"],
snakemake.params.sector["industrial_sector"]["brownfield"],
],
):
if all(n.investment_periods > 2023):
# this is quite crude assumption and should get updated
# assume a 0.5% energy growth per year
# https://www.eia.gov/todayinenergy/detail.php?id=56040
base_year = 2023
growth_multiplier = 1 - (min(n.investment_periods) - 2023) * (0.005)
else:
base_year = min(n.investment_periods)
growth_multiplier = 1
if all(n.investment_periods > 2023):
# this is quite crude assumption and should get updated
# assume a 0.5% energy growth per year
# https://www.eia.gov/todayinenergy/detail.php?id=56040
base_year = 2023
growth_multiplier = 1 - (min(n.investment_periods) - 2023) * (0.005)
else:
base_year = min(n.investment_periods)
growth_multiplier = 1

if snakemake.params.sector["transport_sector"]["brownfield"]:
ratios = get_transport_stock(snakemake.params.api["eia"], base_year)
Expand Down
8 changes: 4 additions & 4 deletions workflow/scripts/build_stock_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,22 +711,22 @@ def add_brownfield_lpg(
costs_name = "Light Duty Cars ICEV"
ratio_name = "light_duty"
# efficiency = 25.9 # mpg
efficiency = 5 # mpg
efficiency = 20 # mpg
case "med":
costs_name = "Medium Duty Trucks ICEV"
ratio_name = "med_duty"
# efficiency = 16.35 # mpg
efficiency = 3 # mpg
efficiency = 15 # mpg
case "hvy":
costs_name = "Heavy Duty Trucks ICEV"
ratio_name = "heavy_duty"
# efficiency = 5.44 # mpg
efficiency = 1 # mpg
efficiency = 5 # mpg
case "bus":
costs_name = "Buses ICEV"
ratio_name = "bus"
# efficiency = 3.67 # mpg
efficiency = 0.75 # mpg
efficiency = 3 # mpg
case _:
raise NotImplementedError

Expand Down
3 changes: 1 addition & 2 deletions workflow/scripts/solve_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,8 +1125,7 @@ def extra_functionality(n, snapshots):
if "sector" in opts:
sector_co2_limits = config["sector"]["co2"].get("policy", {})
if sector_co2_limits:
# add_sector_co2_constraints(n, config)
pass
add_sector_co2_constraints(n, config)
if config["sector"]["natural_gas"].get("force_imports_exports", False):
add_ng_import_export_limits(n, config)

Expand Down

0 comments on commit b50bf9b

Please sign in to comment.