amend solve_network
This commit is contained in:
parent
b67a00903a
commit
83ff639ad5
@ -6,16 +6,9 @@
|
|||||||
rule solve_network:
|
rule solve_network:
|
||||||
params:
|
params:
|
||||||
solving=config["solving"],
|
solving=config["solving"],
|
||||||
config_parts={
|
foresight=config["foresight"],
|
||||||
"foresight": config["foresight"],
|
planning_horizons=config["scenario"]["planning_horizons"],
|
||||||
"planning_horizons": config["scenario"]["planning_horizons"],
|
co2_sequestration_potential=config["sector"].get("co2_sequestration_potential", 200),
|
||||||
"co2_sequestration_potential": config["sector"].get(
|
|
||||||
"co2_sequestration_potential", 200
|
|
||||||
),
|
|
||||||
"H2_retrofit_capacity_per_CH4": config["sector"][
|
|
||||||
"H2_retrofit_capacity_per_CH4"
|
|
||||||
],
|
|
||||||
},
|
|
||||||
input:
|
input:
|
||||||
network=RESOURCES + "networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
|
network=RESOURCES + "networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
|
||||||
output:
|
output:
|
||||||
|
@ -85,16 +85,9 @@ ruleorder: add_existing_baseyear > add_brownfield
|
|||||||
rule solve_sector_network_myopic:
|
rule solve_sector_network_myopic:
|
||||||
params:
|
params:
|
||||||
solving=config["solving"],
|
solving=config["solving"],
|
||||||
config_parts={
|
foresight=config["foresight"],
|
||||||
"foresight": config["foresight"],
|
planning_horizons=config["scenario"]["planning_horizons"],
|
||||||
"planning_horizons": config["scenario"]["planning_horizons"],
|
co2_sequestration_potential=config["sector"].get("co2_sequestration_potential", 200),
|
||||||
"co2_sequestration_potential": config["sector"].get(
|
|
||||||
"co2_sequestration_potential", 200
|
|
||||||
),
|
|
||||||
"H2_retrofit_capacity_per_CH4": config["sector"][
|
|
||||||
"H2_retrofit_capacity_per_CH4"
|
|
||||||
],
|
|
||||||
},
|
|
||||||
input:
|
input:
|
||||||
overrides="data/override_component_attrs",
|
overrides="data/override_component_attrs",
|
||||||
network=RESULTS
|
network=RESULTS
|
||||||
|
@ -6,16 +6,9 @@
|
|||||||
rule solve_sector_network:
|
rule solve_sector_network:
|
||||||
params:
|
params:
|
||||||
solving=config["solving"],
|
solving=config["solving"],
|
||||||
config_parts={
|
foresight=config["foresight"],
|
||||||
"foresight": config["foresight"],
|
planning_horizons=config["scenario"]["planning_horizons"],
|
||||||
"planning_horizons": config["scenario"]["planning_horizons"],
|
co2_sequestration_potential=config["sector"].get("co2_sequestration_potential", 200),
|
||||||
"co2_sequestration_potential": config["sector"].get(
|
|
||||||
"co2_sequestration_potential", 200
|
|
||||||
),
|
|
||||||
"H2_retrofit_capacity_per_CH4": config["sector"][
|
|
||||||
"H2_retrofit_capacity_per_CH4"
|
|
||||||
],
|
|
||||||
},
|
|
||||||
input:
|
input:
|
||||||
overrides="data/override_component_attrs",
|
overrides="data/override_component_attrs",
|
||||||
network=RESULTS
|
network=RESULTS
|
||||||
|
@ -44,14 +44,14 @@ pypsa.pf.logger.setLevel(logging.WARNING)
|
|||||||
from pypsa.descriptors import get_switchable_as_dense as get_as_dense
|
from pypsa.descriptors import get_switchable_as_dense as get_as_dense
|
||||||
|
|
||||||
|
|
||||||
def add_land_use_constraint(n, param, config):
|
def add_land_use_constraint(n, planning_horizons_param, config):
|
||||||
if "m" in snakemake.wildcards.clusters:
|
if "m" in snakemake.wildcards.clusters:
|
||||||
_add_land_use_constraint_m(n, param, config)
|
_add_land_use_constraint_m(n, planning_horizons_param, config)
|
||||||
else:
|
else:
|
||||||
_add_land_use_constraint(n, param)
|
_add_land_use_constraint(n)
|
||||||
|
|
||||||
|
|
||||||
def _add_land_use_constraint(n, param):
|
def _add_land_use_constraint(n):
|
||||||
# warning: this will miss existing offwind which is not classed AC-DC and has carrier 'offwind'
|
# warning: this will miss existing offwind which is not classed AC-DC and has carrier 'offwind'
|
||||||
|
|
||||||
for carrier in ["solar", "onwind", "offwind-ac", "offwind-dc"]:
|
for carrier in ["solar", "onwind", "offwind-ac", "offwind-dc"]:
|
||||||
@ -80,7 +80,7 @@ def _add_land_use_constraint(n, param):
|
|||||||
n.generators.p_nom_max.clip(lower=0, inplace=True)
|
n.generators.p_nom_max.clip(lower=0, inplace=True)
|
||||||
|
|
||||||
|
|
||||||
def _add_land_use_constraint_m(n, param, config):
|
def _add_land_use_constraint_m(n, planning_horizons_param, config):
|
||||||
# if generators clustering is lower than network clustering, land_use accounting is at generators clusters
|
# if generators clustering is lower than network clustering, land_use accounting is at generators clusters
|
||||||
|
|
||||||
planning_horizons = param["planning_horizons"]
|
planning_horizons = param["planning_horizons"]
|
||||||
@ -141,7 +141,7 @@ def add_co2_sequestration_limit(n, limit=200):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def prepare_network(n, solve_opts=None, config=None, param=None):
|
def prepare_network(n, solve_opts=None, config=None, foresight_param=None, planning_horizons_param=None, co2_sequestration_potential=None):
|
||||||
if "clip_p_max_pu" in solve_opts:
|
if "clip_p_max_pu" in solve_opts:
|
||||||
for df in (
|
for df in (
|
||||||
n.generators_t.p_max_pu,
|
n.generators_t.p_max_pu,
|
||||||
@ -191,11 +191,11 @@ def prepare_network(n, solve_opts=None, config=None, param=None):
|
|||||||
n.set_snapshots(n.snapshots[:nhours])
|
n.set_snapshots(n.snapshots[:nhours])
|
||||||
n.snapshot_weightings[:] = 8760.0 / nhours
|
n.snapshot_weightings[:] = 8760.0 / nhours
|
||||||
|
|
||||||
if param["foresight"] == "myopic":
|
if foresight_param == "myopic":
|
||||||
add_land_use_constraint(n, param, config)
|
add_land_use_constraint(n, planning_horizons_param, config)
|
||||||
|
|
||||||
if n.stores.carrier.eq("co2 stored").any():
|
if n.stores.carrier.eq("co2 stored").any():
|
||||||
limit = param["co2_sequestration_potential"]
|
limit = co2_sequestration_potential_param
|
||||||
add_co2_sequestration_limit(n, limit=limit)
|
add_co2_sequestration_limit(n, limit=limit)
|
||||||
|
|
||||||
return n
|
return n
|
||||||
@ -676,7 +676,12 @@ if __name__ == "__main__":
|
|||||||
n = pypsa.Network(snakemake.input.network)
|
n = pypsa.Network(snakemake.input.network)
|
||||||
|
|
||||||
n = prepare_network(
|
n = prepare_network(
|
||||||
n, solve_opts, config=snakemake.config, param=snakemake.params["config_parts"]
|
n,
|
||||||
|
solve_opts,
|
||||||
|
config=snakemake.config,
|
||||||
|
foresight_param=snakemake.params["foresight"],
|
||||||
|
planning_horizons_param=snakemake.params["planning_horizons"],
|
||||||
|
co2_sequestration_potential=snakemake.params["co2_sequestration_potential"]
|
||||||
)
|
)
|
||||||
|
|
||||||
n = solve_network(
|
n = solve_network(
|
||||||
|
Loading…
Reference in New Issue
Block a user