Skip to content

Commit

Permalink
Integrated on/off toggles for GTD in config
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenbrinkerink committed Dec 9, 2024
1 parent 974f08e commit 7c2a178
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 45 deletions.
18 changes: 13 additions & 5 deletions workflow/scripts/osemosys_global/transmission/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ def main(
region_name)

# Set residual capacity.
res_cap_trn = res_capacity_transmission(gtd_exist_corrected, gtd_planned_corrected,
res_cap_trn = res_capacity_transmission(gtd_exist_corrected, gtd_planned_corrected,
transmission_existing, transmission_planned,
res_cap_base, op_life_dict,
start_year, end_year, region_name,
RETIREMENT_YEAR_TRANSMISSION,
Expand Down Expand Up @@ -230,6 +231,8 @@ def main(
no_investment_techs = snakemake.params.no_investment_techs
transmission_parameters = snakemake.params.transmission_parameters
cross_border_trade = snakemake.params.trade
transmission_existing = snakemake.params.transmission_existing
transmission_planned = snakemake.params.transmission_planned
output_data_dir = snakemake.params.output_data_dir
input_data_dir = snakemake.params.input_data_dir
powerplant_data_dir = snakemake.params.powerplant_data_dir
Expand Down Expand Up @@ -263,17 +266,22 @@ def main(
region_name = 'GLOBAL'

custom_nodes = []
tech_capacity_trn = {'trn1': ['TRNINDEAINDNE', 5, 1975, 2030, 10, 350, 13, 4, 95],
'trn2': ['TRNINDEAINDNE', 1, 1990, 2030, 10, 350, 13, 4, 95],
'trn3': ['TRNINDEAINDNE', 2, 2035, 2030, 10, 350, 13, 4, 95],
'trn4': ['TRNINDNOINDSO', 0, 2020, 2025, 0.5, 620, 24, 4, 92]}
tech_capacity_trn = {'trn1': ['TRNINDEAINDNE', 5, 1975, 2025, 2025, 0, 350, 13, 4, 95],
'trn2': ['TRNINDEAINDNE', 1, 1990, 2025, 2025, 0, 350, 13, 4, 95],
'trn3': ['TRNINDEAINDNE', 2, 2035, 2025, 2025, 0, 350, 13, 4, 95],
'trn4': ['TRNINDEAINDNE', 0, 2020, 2025, 2025, 1, 350, 13, 4, 95],
'trn5': ['TRNINDEAINDNE', 0, 2020, 2030, 2040, 2, 350, 13, 4, 95],
'trn6': ['TRNINDEAINDNE', 0, 2020, 2040, 2050, 3, 350, 13, 4, 95],
'trn7': ['TRNINDNOINDSO', 0, 2020, 2025, 2025, 0.5, 620, 24, 4, 92]}

no_investment_techs = ["CSP", "WAV", "URN", "OTH", "WAS",
"COG", "GEO", "BIO", "PET"]
transmission_parameters = {'HVAC': [779, 95400, 6.75, 0, 3.5, 4],
'HVDC': [238, 297509, 3.5, 1.3, 3.5, 4],
'HVDC_subsea': [295, 297509, 3.5, 1.3, 3.5, 4]}
cross_border_trade = True
transmission_existing = True
transmission_planned = True
output_data_dir = 'results/data'
input_data_dir = 'resources/data'
powerplant_data_dir = 'results/data/powerplant'
Expand Down
95 changes: 55 additions & 40 deletions workflow/scripts/osemosys_global/transmission/residual_capacity.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,67 @@
from data import get_years

def res_capacity_transmission(df_exist_corrected, df_plan_corrected,
transmission_existing, transmission_planned,
res_cap_base, op_life_dict,
start_year, end_year, region_name,
retirement_year_transmission,
planned_build_year_transmission):

"""Set build year for existing capacities as the differential between assumed
retirement year and the set operational life for transmission technologies."""
df_res_cap_exist = df_exist_corrected.copy()
df_res_cap_exist['YEAR'] = retirement_year_transmission - op_life_dict.get('TRN')
df_res_cap = None

"""Set assumed build year for planned capacities from the GTD dataset that do not have
a commissioning year attached."""
df_res_cap_plan = df_plan_corrected.copy()
df_res_cap_plan.loc[df_res_cap_plan['YEAR'] == '-', 'YEAR'] = planned_build_year_transmission
if transmission_existing:
"""Set build year for existing capacities as the differential between assumed
retirement year and the set operational life for transmission technologies."""
df_res_cap_exist = df_exist_corrected.copy()
df_res_cap_exist['YEAR'] = retirement_year_transmission - op_life_dict.get('TRN')

if transmission_planned:
"""Set assumed build year for planned capacities from the GTD dataset that do not have
a commissioning year attached."""
df_res_cap_plan = df_plan_corrected.copy()
df_res_cap_plan.loc[df_res_cap_plan['YEAR'] == '-', 'YEAR'] = planned_build_year_transmission

# Combine dfs and filter out rows without capacities.
df_res_cap = pd.concat([df_res_cap_exist, df_res_cap_plan])
df_res_cap = df_res_cap.loc[df_res_cap['VALUE'] != 0
].reset_index(drop = True
).rename(columns = {'YEAR' :'build_year'})

# Set retirement years.
df_res_cap['build_year'] = df_res_cap['build_year'].astype(int)
df_res_cap['retirement_year'] = df_res_cap['build_year'] + op_life_dict.get('TRN')

# Set residual capacity for all model horizon years.
df_res_cap['YEAR'] = [get_years(start_year, end_year)] * len(df_res_cap)
df_res_cap = df_res_cap.explode('YEAR').reset_index(drop = True)

# Convert from MW to GW.
df_res_cap['VALUE'] = df_res_cap['VALUE'] / 1000

df_res_cap.loc[~
((df_res_cap["YEAR"] >= df_res_cap["build_year"])
& (df_res_cap["YEAR"] <= df_res_cap["retirement_year"])),
"VALUE",
] = 0

# Group capacities by year and technology.
df_res_cap = df_res_cap.groupby(['TECHNOLOGY', 'YEAR']).sum('VALUE').reset_index()

# Reorder columns
df_res_cap['REGION'] = region_name
df_res_cap = df_res_cap[['REGION', 'TECHNOLOGY', 'YEAR', 'VALUE']]

# Combine powerplant and transmission resisdual capacity df's.
df_res_cap = pd.concat([res_cap_base, df_res_cap]).reset_index(drop = True)
if transmission_existing and transmission_planned:
# Combine dfs and filter out rows without capacities.
df_res_cap = pd.concat([df_res_cap_exist, df_res_cap_plan])
if transmission_existing and not transmission_planned:
df_res_cap = df_res_cap_exist.copy()
if not transmission_existing and transmission_planned:
df_res_cap = df_res_cap_plan.copy()

if df_res_cap is not None:
df_res_cap = df_res_cap.loc[df_res_cap['VALUE'] != 0
].reset_index(drop = True
).rename(columns = {'YEAR' :'build_year'})

# Set retirement years.
df_res_cap['build_year'] = df_res_cap['build_year'].astype(int)
df_res_cap['retirement_year'] = df_res_cap['build_year'] + op_life_dict.get('TRN')

# Set residual capacity for all model horizon years.
df_res_cap['YEAR'] = [get_years(start_year, end_year)] * len(df_res_cap)
df_res_cap = df_res_cap.explode('YEAR').reset_index(drop = True)

# Convert from MW to GW.
df_res_cap['VALUE'] = df_res_cap['VALUE'] / 1000

df_res_cap.loc[~
((df_res_cap["YEAR"] >= df_res_cap["build_year"])
& (df_res_cap["YEAR"] <= df_res_cap["retirement_year"])),
"VALUE",
] = 0

# Group capacities by year and technology.
df_res_cap = df_res_cap.groupby(['TECHNOLOGY', 'YEAR']).sum('VALUE').reset_index()

# Reorder columns
df_res_cap['REGION'] = region_name
df_res_cap = df_res_cap[['REGION', 'TECHNOLOGY', 'YEAR', 'VALUE']]

# Combine powerplant and transmission resisdual capacity df's.
df_res_cap = pd.concat([res_cap_base, df_res_cap]).reset_index(drop = True)

else:
df_res_cap = res_cap_base.copy()

return df_res_cap

0 comments on commit 7c2a178

Please sign in to comment.