Merge pull request #910 from koen-vg/perfect-foresight-fixes
Miscellaneous perfect foresight fixes
This commit is contained in:
commit
726deef4a4
@ -64,6 +64,8 @@ Upcoming Release
|
|||||||
|
|
||||||
* The ``highs`` solver was added to the default environment file.
|
* The ``highs`` solver was added to the default environment file.
|
||||||
|
|
||||||
|
* Various minor bugfixes to the perfect foresight workflow, though perfect foresight must still be considered experimental.
|
||||||
|
|
||||||
* It is now possible to determine the directory for shared resources by setting `shared_resources` to a string.
|
* It is now possible to determine the directory for shared resources by setting `shared_resources` to a string.
|
||||||
|
|
||||||
* A ``test.sh`` script was added to the repository to run the tests locally.
|
* A ``test.sh`` script was added to the repository to run the tests locally.
|
||||||
|
@ -730,6 +730,40 @@ rule build_district_heat_share:
|
|||||||
"../scripts/build_district_heat_share.py"
|
"../scripts/build_district_heat_share.py"
|
||||||
|
|
||||||
|
|
||||||
|
rule build_existing_heating_distribution:
|
||||||
|
params:
|
||||||
|
baseyear=config["scenario"]["planning_horizons"][0],
|
||||||
|
sector=config["sector"],
|
||||||
|
existing_capacities=config["existing_capacities"],
|
||||||
|
input:
|
||||||
|
existing_heating="data/existing_infrastructure/existing_heating_raw.csv",
|
||||||
|
clustered_pop_layout=RESOURCES + "pop_layout_elec_s{simpl}_{clusters}.csv",
|
||||||
|
clustered_pop_energy_layout=RESOURCES
|
||||||
|
+ "pop_weighted_energy_totals_s{simpl}_{clusters}.csv",
|
||||||
|
district_heat_share=RESOURCES
|
||||||
|
+ "district_heat_share_elec_s{simpl}_{clusters}_{planning_horizons}.csv",
|
||||||
|
output:
|
||||||
|
existing_heating_distribution=RESOURCES
|
||||||
|
+ "existing_heating_distribution_elec_s{simpl}_{clusters}_{planning_horizons}.csv",
|
||||||
|
wildcard_constraints:
|
||||||
|
planning_horizons=config["scenario"]["planning_horizons"][0], #only applies to baseyear
|
||||||
|
threads: 1
|
||||||
|
resources:
|
||||||
|
mem_mb=2000,
|
||||||
|
log:
|
||||||
|
LOGS
|
||||||
|
+ "build_existing_heating_distribution_elec_s{simpl}_{clusters}_{planning_horizons}.log",
|
||||||
|
benchmark:
|
||||||
|
(
|
||||||
|
BENCHMARKS
|
||||||
|
+ "build_existing_heating_distribution/elec_s{simpl}_{clusters}_{planning_horizons}"
|
||||||
|
)
|
||||||
|
conda:
|
||||||
|
"../envs/environment.yaml"
|
||||||
|
script:
|
||||||
|
"../scripts/build_existing_heating_distribution.py"
|
||||||
|
|
||||||
|
|
||||||
rule prepare_sector_network:
|
rule prepare_sector_network:
|
||||||
params:
|
params:
|
||||||
co2_budget=config["co2_budget"],
|
co2_budget=config["co2_budget"],
|
||||||
|
@ -3,40 +3,6 @@
|
|||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
|
||||||
rule build_existing_heating_distribution:
|
|
||||||
params:
|
|
||||||
baseyear=config["scenario"]["planning_horizons"][0],
|
|
||||||
sector=config["sector"],
|
|
||||||
existing_capacities=config["existing_capacities"],
|
|
||||||
input:
|
|
||||||
existing_heating="data/existing_infrastructure/existing_heating_raw.csv",
|
|
||||||
clustered_pop_layout=RESOURCES + "pop_layout_elec_s{simpl}_{clusters}.csv",
|
|
||||||
clustered_pop_energy_layout=RESOURCES
|
|
||||||
+ "pop_weighted_energy_totals_s{simpl}_{clusters}.csv",
|
|
||||||
district_heat_share=RESOURCES
|
|
||||||
+ "district_heat_share_elec_s{simpl}_{clusters}_{planning_horizons}.csv",
|
|
||||||
output:
|
|
||||||
existing_heating_distribution=RESOURCES
|
|
||||||
+ "existing_heating_distribution_elec_s{simpl}_{clusters}_{planning_horizons}.csv",
|
|
||||||
wildcard_constraints:
|
|
||||||
planning_horizons=config["scenario"]["planning_horizons"][0], #only applies to baseyear
|
|
||||||
threads: 1
|
|
||||||
resources:
|
|
||||||
mem_mb=2000,
|
|
||||||
log:
|
|
||||||
LOGS
|
|
||||||
+ "build_existing_heating_distribution_elec_s{simpl}_{clusters}_{planning_horizons}.log",
|
|
||||||
benchmark:
|
|
||||||
(
|
|
||||||
BENCHMARKS
|
|
||||||
+ "build_existing_heating_distribution/elec_s{simpl}_{clusters}_{planning_horizons}"
|
|
||||||
)
|
|
||||||
conda:
|
|
||||||
"../envs/environment.yaml"
|
|
||||||
script:
|
|
||||||
"../scripts/build_existing_heating_distribution.py"
|
|
||||||
|
|
||||||
|
|
||||||
rule add_existing_baseyear:
|
rule add_existing_baseyear:
|
||||||
params:
|
params:
|
||||||
baseyear=config["scenario"]["planning_horizons"][0],
|
baseyear=config["scenario"]["planning_horizons"][0],
|
||||||
|
@ -45,38 +45,6 @@ rule add_existing_baseyear:
|
|||||||
"../scripts/add_existing_baseyear.py"
|
"../scripts/add_existing_baseyear.py"
|
||||||
|
|
||||||
|
|
||||||
rule add_brownfield:
|
|
||||||
params:
|
|
||||||
H2_retrofit=config["sector"]["H2_retrofit"],
|
|
||||||
H2_retrofit_capacity_per_CH4=config["sector"]["H2_retrofit_capacity_per_CH4"],
|
|
||||||
threshold_capacity=config["existing_capacities"]["threshold_capacity"],
|
|
||||||
input:
|
|
||||||
network=RESULTS
|
|
||||||
+ "prenetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
|
|
||||||
network_p=solved_previous_horizon, #solved network at previous time step
|
|
||||||
costs="data/costs_{planning_horizons}.csv",
|
|
||||||
cop_soil_total=RESOURCES + "cop_soil_total_elec_s{simpl}_{clusters}.nc",
|
|
||||||
cop_air_total=RESOURCES + "cop_air_total_elec_s{simpl}_{clusters}.nc",
|
|
||||||
output:
|
|
||||||
RESULTS
|
|
||||||
+ "prenetworks-brownfield/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
|
|
||||||
threads: 4
|
|
||||||
resources:
|
|
||||||
mem_mb=10000,
|
|
||||||
log:
|
|
||||||
LOGS
|
|
||||||
+ "add_brownfield_elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.log",
|
|
||||||
benchmark:
|
|
||||||
(
|
|
||||||
BENCHMARKS
|
|
||||||
+ "add_brownfield/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}"
|
|
||||||
)
|
|
||||||
conda:
|
|
||||||
"../envs/environment.yaml"
|
|
||||||
script:
|
|
||||||
"../scripts/add_brownfield.py"
|
|
||||||
|
|
||||||
|
|
||||||
rule prepare_perfect_foresight:
|
rule prepare_perfect_foresight:
|
||||||
input:
|
input:
|
||||||
**{
|
**{
|
||||||
@ -192,6 +160,3 @@ rule make_summary_perfect:
|
|||||||
"../envs/environment.yaml"
|
"../envs/environment.yaml"
|
||||||
script:
|
script:
|
||||||
"../scripts/make_summary_perfect.py"
|
"../scripts/make_summary_perfect.py"
|
||||||
|
|
||||||
|
|
||||||
ruleorder: add_existing_baseyear > add_brownfield
|
|
||||||
|
@ -162,15 +162,17 @@ def concat_networks(years):
|
|||||||
add_build_year_to_new_assets(network, year)
|
add_build_year_to_new_assets(network, year)
|
||||||
|
|
||||||
# static ----------------------------------
|
# static ----------------------------------
|
||||||
# (1) add buses and carriers
|
|
||||||
for component in network.iterate_components(["Bus", "Carrier"]):
|
|
||||||
df_year = component.df
|
|
||||||
# get missing assets
|
|
||||||
missing = get_missing(df_year, n, component.list_name)
|
|
||||||
import_components_from_dataframe(n, missing, component.name)
|
|
||||||
# (2) add generators, links, stores and loads
|
|
||||||
for component in network.iterate_components(
|
for component in network.iterate_components(
|
||||||
["Generator", "Link", "Store", "Load", "Line", "StorageUnit"]
|
[
|
||||||
|
"Bus",
|
||||||
|
"Carrier",
|
||||||
|
"Generator",
|
||||||
|
"Link",
|
||||||
|
"Store",
|
||||||
|
"Load",
|
||||||
|
"Line",
|
||||||
|
"StorageUnit",
|
||||||
|
]
|
||||||
):
|
):
|
||||||
df_year = component.df.copy()
|
df_year = component.df.copy()
|
||||||
missing = get_missing(df_year, n, component.list_name)
|
missing = get_missing(df_year, n, component.list_name)
|
||||||
@ -199,8 +201,13 @@ def concat_networks(years):
|
|||||||
pnl[k].loc[pnl_year.index, pnl_year.columns] = pnl_year
|
pnl[k].loc[pnl_year.index, pnl_year.columns] = pnl_year
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# this is to avoid adding multiple times assets with
|
# For components that aren't new, we just extend
|
||||||
# infinite lifetime as ror
|
# time-varying data from the previous investment
|
||||||
|
# period.
|
||||||
|
if i > 0:
|
||||||
|
pnl[k].loc[(year,)] = pnl[k].loc[(years[i - 1],)].values
|
||||||
|
|
||||||
|
# Now, add time-varying data for new components.
|
||||||
cols = pnl_year.columns.difference(pnl[k].columns)
|
cols = pnl_year.columns.difference(pnl[k].columns)
|
||||||
pnl[k] = pd.concat([pnl[k], pnl_year[cols]], axis=1)
|
pnl[k] = pd.concat([pnl[k], pnl_year[cols]], axis=1)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user