Skip to content

Commit

Permalink
Added storage output fuel
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenbrinkerink committed Dec 9, 2024
1 parent 4321c53 commit feb1dcc
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
5 changes: 3 additions & 2 deletions workflow/rules/preprocess.smk
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ transmission_files = [
'transmission/OutputActivityRatio',
'transmission/ResidualCapacity',
'transmission/TECHNOLOGY',
'FUEL'
'transmission/FUEL'
]

storage_files = [
Expand All @@ -69,7 +69,8 @@ storage_files = [
'STORAGE',
'StorageLevelStart',
'TechnologyToStorage',
'TechnologyFromStorage'
'TechnologyFromStorage',
'FUEL'
]

timeslice_files = [
Expand Down
11 changes: 9 additions & 2 deletions workflow/scripts/osemosys_global/storage/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def activity_storage(storage_set, df_iar_base, df_oar_base, storage_param,

years = [get_years(start_year, end_year)]

# InputActivityRatio
# InputActivityRatio Storage object
df_storage_iar = pd.DataFrame(
list(itertools.product([region_name], storage_set['VALUE'].unique(), years, [1])),
columns=["REGION", "TECHNOLOGY", "YEAR", "MODE_OF_OPERATION"],
Expand All @@ -30,8 +30,14 @@ def activity_storage(storage_set, df_iar_base, df_oar_base, storage_param,
]

df_iar = pd.concat([df_iar_base, df_storage_iar])

# InputActivityRatio PWRTRN object for storage output
df_pwrtrn_iar = df_iar.copy().loc[df_iar['TECHNOLOGY'].str.startswith('PWRTRN')]
df_pwrtrn_iar["FUEL"] = df_pwrtrn_iar["FUEL"].str.replace('01', '03')

df_iar = pd.concat([df_iar, df_pwrtrn_iar])

# OutputActivityRatio
# OutputActivityRatio Storage object
df_storage_oar = pd.DataFrame(
list(itertools.product([region_name], storage_set['VALUE'].unique(), years, [2])),
columns=["REGION", "TECHNOLOGY", "YEAR", "MODE_OF_OPERATION"],
Expand All @@ -44,6 +50,7 @@ def activity_storage(storage_set, df_iar_base, df_oar_base, storage_param,

df_storage_oar["TECHNOLOGY"] = "PWR" + df_storage_oar["TECHNOLOGY"]
df_storage_oar["FUEL"] = "ELC" + df_storage_oar["TECHNOLOGY"].str[6:13]
df_storage_oar["FUEL"] = df_storage_oar["FUEL"].str.replace('01', '03')
df_storage_oar = df_storage_oar[
["REGION", "TECHNOLOGY", "FUEL", "MODE_OF_OPERATION", "YEAR", "VALUE"]
]
Expand Down
16 changes: 10 additions & 6 deletions workflow/scripts/osemosys_global/storage/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
from residual_capacity import res_capacity_storage

from sets import(set_unique_storage_technologies,
set_unique_technologies)
set_unique_technologies,
set_storage_fuels)

from technology_to_from_storage import (set_technology_to_storage,
set_technology_from_storage
Expand Down Expand Up @@ -98,6 +99,7 @@ def main(
op_life_storage = pd.DataFrame(columns=["REGION", "STORAGE", "VALUE"])
max_cap_invest_storage = max_cap_invest_base.copy()
tech_set = tech_set_base.copy()
fuel_set = fuel_set_base.copy()
storage_set = pd.DataFrame(columns=["VALUE"])
tech_to_storage = pd.DataFrame(columns=["REGION","TECHNOLOGY","STORAGE","MODE_OF_OPERATION", "VALUE"])
tech_from_storage = pd.DataFrame(columns=["REGION","TECHNOLOGY","STORAGE","MODE_OF_OPERATION", "VALUE"])
Expand All @@ -108,8 +110,9 @@ def main(

else:

# Set storage set
storage_set = set_unique_storage_technologies(fuel_set_base, unique_sto_techs)
# Set fuel and storage set
fuel_set = set_storage_fuels(fuel_set_base)
storage_set = set_unique_storage_technologies(fuel_set, unique_sto_techs)

# Create TechnologyToStorage and TechnologyFromStorage
tech_to_storage = set_technology_to_storage(storage_set, region_name)
Expand Down Expand Up @@ -222,6 +225,7 @@ def main(
index = None)

tech_set.to_csv(os.path.join(output_data_dir, "TECHNOLOGY.csv"), index = None)
fuel_set.to_csv(os.path.join(output_data_dir, "FUEL.csv"), index = None)
storage_set.to_csv(os.path.join(output_data_dir, "STORAGE.csv"), index = None)

tech_to_storage.to_csv(os.path.join(output_data_dir, "TechnologyToStorage.csv"), index=None)
Expand Down Expand Up @@ -276,7 +280,7 @@ def main(
file_min_cap_invest_base = f'{transmission_data_dir}/TotalAnnualMinCapacityInvestment.csv'
file_res_cap_base = f'{transmission_data_dir}/ResidualCapacity.csv'
file_tech_set = f'{transmission_data_dir}/TECHNOLOGY.csv'
file_fuel_set = f'{output_data_dir}/FUEL.csv'
file_fuel_set = f'{transmission_data_dir}/FUEL.csv'

# The below else statement defines variables if the 'transmission/main' script is to be run locally
# outside the snakemake workflow. This is relevant for testing purposes only! User inputs when running
Expand All @@ -293,7 +297,7 @@ def main(
end_year = 2050
region_name = 'GLOBAL'
custom_nodes = []
tech_capacity_sto = {'sto1': ['PWRSDSINDWE01', 2, 2010, 2025, 3, 1800, 40, 0, 87],
tech_capacity_sto = {'sto1': ['PWRSDSIDNSM01', 2, 2010, 2025, 3, 1800, 40, 0, 87],
'sto2': ['PWRLDSINDNE01', 4, 1985, 2025, 2, 3400, 19, 0.5, 82],
'sto3': ['PWRLDSINDNE01', 1, 2015, 2025, 2, 3400, 19, 0.5, 82]}
no_investment_techs = ["CSP", "WAV", "URN", "OTH", "WAS",
Expand All @@ -316,7 +320,7 @@ def main(
file_min_cap_invest_base = f'{transmission_data_dir}/TotalAnnualMinCapacityInvestment.csv'
file_res_cap_base = f'{transmission_data_dir}/ResidualCapacity.csv'
file_tech_set = f'{transmission_data_dir}/TECHNOLOGY.csv'
file_fuel_set = f'{output_data_dir}/FUEL.csv'
file_fuel_set = f'{transmission_data_dir}/FUEL.csv'

# SET INPUT DATA

Expand Down
10 changes: 10 additions & 0 deletions workflow/scripts/osemosys_global/storage/sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,14 @@ def set_unique_technologies(ar: pd.DataFrame) -> pd.DataFrame():
data = ar.copy()
data['VALUE'] = 'PWR' + data['VALUE']

return data

def set_storage_fuels(ar: pd.DataFrame) -> pd.DataFrame():
data = ar.copy()
data = data.loc[(data['VALUE'].str.startswith('ELC')) &
(data['VALUE'].str.endswith('01'))]

data['VALUE'] = data['VALUE'].str.replace('01', '03')
data = pd.concat([ar, data])

return data
2 changes: 1 addition & 1 deletion workflow/scripts/osemosys_global/transmission/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def main(
index = None)

tech_set.to_csv(os.path.join(transmission_data_dir, "TECHNOLOGY.csv"), index = None)
fuel_set.to_csv(os.path.join(output_data_dir, "FUEL.csv"), index = None)
fuel_set.to_csv(os.path.join(transmission_data_dir, "FUEL.csv"), index = None)

res_cap_trn.to_csv(os.path.join(transmission_data_dir, 'ResidualCapacity.csv'),
index = None)
Expand Down

0 comments on commit feb1dcc

Please sign in to comment.