Skip to content

Commit

Permalink
Merge pull request #391 from cpschau/interest_rate_sens
Browse files Browse the repository at this point in the history
setup for interest rate sensitivity; fix bugs
  • Loading branch information
hazemakhalek authored Nov 13, 2024
2 parents 103e7c0 + dbce0b5 commit 3221fdc
Show file tree
Hide file tree
Showing 17 changed files with 7,360 additions and 15 deletions.
655 changes: 655 additions & 0 deletions config.bright_high.yaml

Large diffs are not rendered by default.

656 changes: 656 additions & 0 deletions config.bright_low.yaml

Large diffs are not rendered by default.

656 changes: 656 additions & 0 deletions config.bright_med.yaml

Large diffs are not rendered by default.

659 changes: 659 additions & 0 deletions config.bright_ref_high.yaml

Large diffs are not rendered by default.

659 changes: 659 additions & 0 deletions config.bright_ref_low.yaml

Large diffs are not rendered by default.

659 changes: 659 additions & 0 deletions config.bright_ref_med.yaml

Large diffs are not rendered by default.

659 changes: 659 additions & 0 deletions config.bright_ref_vhigh.yaml

Large diffs are not rendered by default.

656 changes: 656 additions & 0 deletions config.bright_vhigh.yaml

Large diffs are not rendered by default.

511 changes: 511 additions & 0 deletions config.pypsa-earth_high.yaml

Large diffs are not rendered by default.

511 changes: 511 additions & 0 deletions config.pypsa-earth_low.yaml

Large diffs are not rendered by default.

511 changes: 511 additions & 0 deletions config.pypsa-earth_med.yaml

Large diffs are not rendered by default.

511 changes: 511 additions & 0 deletions config.pypsa-earth_vhigh.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scripts/override_respot.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def override_values(tech, year, dr, simpl, clusters):

def annuity_factor(v):
return (
annuity(v["lifetime"], snakemake.wildcards["discountrate"])
annuity(v["lifetime"], float(snakemake.wildcards["discountrate"]))
+ v["fixedomEuroPKW"] / v["investmentEuroPKW"] / 100
)

Expand Down
15 changes: 5 additions & 10 deletions scripts/prepare_res_potentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,7 @@ def merge_onwind(onwind, onwind_rest):


def prepare_enertile(df, df_t):
tech_dict = {
"windonshore": "onwind",
"sopv": "solar",
}
tech_dict = {"windonshore": "onwind", "sopv": "solar", "pvr": "solar-rooftop"}

regions = gpd.read_file(snakemake.input.regions_onshore_elec_s)

Expand Down Expand Up @@ -172,7 +169,7 @@ def prepare_enertile(df, df_t):
)

df = df.groupby(["Generator", "step", "simyear"], as_index=False).mean()
if technology == "solar":
if technology == "solar" or technology == "solar-rooftop":
df["flh_class"] = "Q4"
else:
df = df.groupby(["Generator", "simyear"], as_index=False).apply(
Expand All @@ -181,6 +178,7 @@ def prepare_enertile(df, df_t):

df.set_index(["Generator", "step", "simyear"], inplace=True)
df_t.set_index(["region", "step", "simyear"], inplace=True)
df_t = df_t.loc[df.index]
df_t["install_cap"] = df["p_nom_max"]
df_t["potential"] = df["potential"]
df_t["flh_class"] = df["flh_class"]
Expand Down Expand Up @@ -225,11 +223,7 @@ def prepare_enertile(df, df_t):
# Export for every simyear and flh_class the sliced installable and res_t
flh_class_dict = {"Q4": "", "Q3": "2", "Q2": "3", "Q1": "4"}
for region, simyear, flh_class in installable.index:
ir = (
installable.loc[(slice(None), simyear, flh_class)]
.interestrate.mode()
.item()
)
ir = snakemake.config["costs"]["discountrate"][0]
export_tech = technology + flh_class_dict[flh_class]
logger.info(snakemake.output.keys())
installable.loc[(slice(None), simyear, flh_class)].reset_index().to_csv(
Expand Down Expand Up @@ -272,6 +266,7 @@ def prepare_enertile(df, df_t):
}
renewables_enertile.remove("onwind_rest")
for technology in renewables_enertile:
logger.info(f"Preparing {technology} data")
prepare_enertile(
df=data[technology]["potentials"], df_t=data[technology]["hourdata"]
)
3 changes: 3 additions & 0 deletions scripts/prepare_transport_data_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ def download_CO2_emissions():
shutil.copy(src, dest)
else:
# Join the DataFrames by the 'country' column
CO2_emissions_csv = CO2_emissions_csv[
~CO2_emissions_csv["country"].apply(lambda x: isinstance(x, list))
]
merged_df = pd.merge(vehicles_csv, CO2_emissions_csv, on="country")
merged_df = merged_df[["country", "number cars", "average fuel efficiency"]]

Expand Down
13 changes: 9 additions & 4 deletions scripts/solve_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ def fix_rooftopPV_utilityScale_ratio(n, target_ratio=2):
)

# Filter for rooftop and utility-scale solar generators
rooftop_index = n.generators.loc[n.generators.carrier == "rooftop-solar"].index
rooftop_index = n.generators.loc[n.generators.carrier == "solar-rooftop"].index
utility_index = n.generators.loc[n.generators.carrier == "solar"].index

# Get the generator capacity variables (p_nom) for each generator type
Expand Down Expand Up @@ -594,7 +594,12 @@ def extra_functionality(n, snapshots):
"ratio_rooftop_to_utility_solar"
]:
fix_rooftopPV_utilityScale_ratio(
n, snakemake.config["policy_config"]["ratio_rooftop_to_utility_solar"]
n,
float(
snakemake.config["policy_config"]["renewables"][
"ratio_rooftop_to_utility_solar"
]
),
)

add_co2_sequestration_limit(n, snapshots)
Expand Down Expand Up @@ -678,8 +683,8 @@ def add_existing(n):
ll="v1.0",
opts="Co2L",
planning_horizons="2035",
sopts="365H",
discountrate=0.071,
sopts="3H",
discountrate=0.06,
demand="BI",
h2export="0",
h2mp="endogenous",
Expand Down
39 changes: 39 additions & 0 deletions submit_dr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

conda activate pypsa-earth

# rm pypsa-earth/networks/elec.nc
cp config.pypsa-earth_low.yaml config.pypsa-earth.yaml
cp config.bright_ref_low.yaml config.yaml
snakemake --profile slurm all
cp config.bright_low.yaml config.yaml
snakemake --profile slurm all

rm pypsa-earth/networks/elec.nc
cp config.pypsa-earth_med.yaml config.pypsa-earth.yaml
cp config.bright_ref_med.yaml config.yaml
snakemake --profile slurm all
cp config.bright_med.yaml config.yaml
snakemake --profile slurm all

rm pypsa-earth/networks/elec.nc
cp config.pypsa-earth_high.yaml config.pypsa-earth.yaml
cp config.bright_ref_high.yaml config.yaml
snakemake --profile slurm all
cp config.bright_high.yaml config.yaml
snakemake --profile slurm all

rm pypsa-earth/networks/elec.nc
cp config.pypsa-earth_vhigh.yaml config.pypsa-earth.yaml
cp config.bright_ref_vhigh.yaml config.yaml
snakemake --profile slurm all
cp config.bright_vhigh.yaml config.yaml
snakemake --profile slurm all

# NEXTCLOUD_URL="https://tubcloud.tu-berlin.de/remote.php/webdav/BRIGHT/results/"
# USERNAME="cpschau"
# PASSWORD=$(get_nextcloud_password)

# # Upload the file to Nextcloud via WebDAV
# tar -czf results_241031.tar.gz /results/241031/
# curl -u "$USERNAME:$PASSWORD" -T "results_241031.tar.gz" "$NEXTCLOUD_URL"

0 comments on commit 3221fdc

Please sign in to comment.