co2 sequestration depending on period
This commit is contained in:
parent
49053f3fb7
commit
f4819d0b4c
@ -43,6 +43,8 @@ from _helpers import (
|
|||||||
set_scenario_config,
|
set_scenario_config,
|
||||||
update_config_from_wildcards,
|
update_config_from_wildcards,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from prepare_sector_network import get
|
||||||
from pypsa.descriptors import get_activity_mask
|
from pypsa.descriptors import get_activity_mask
|
||||||
from pypsa.descriptors import get_switchable_as_dense as get_as_dense
|
from pypsa.descriptors import get_switchable_as_dense as get_as_dense
|
||||||
|
|
||||||
@ -287,15 +289,19 @@ def add_solar_potential_constraints(n, config):
|
|||||||
n.model.add_constraints(lhs <= rhs, name="solar_potential")
|
n.model.add_constraints(lhs <= rhs, name="solar_potential")
|
||||||
|
|
||||||
|
|
||||||
def add_co2_sequestration_limit(n, limit=200):
|
def add_co2_sequestration_limit(n, limit_dict):
|
||||||
"""
|
"""
|
||||||
Add a global constraint on the amount of Mt CO2 that can be sequestered.
|
Add a global constraint on the amount of Mt CO2 that can be sequestered.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not n.investment_periods.empty:
|
if not n.investment_periods.empty:
|
||||||
periods = n.investment_periods
|
periods = n.investment_periods
|
||||||
names = pd.Index([f"co2_sequestration_limit-{period}" for period in periods])
|
limit = pd.Series({f"co2_sequestration_limit-{period}":
|
||||||
|
limit_dict.get(period, 200) for period in periods})
|
||||||
|
names = limit.index
|
||||||
else:
|
else:
|
||||||
|
limit = get(limit_dict,
|
||||||
|
int(snakemake.wildcards.planning_horizons))
|
||||||
periods = [np.nan]
|
periods = [np.nan]
|
||||||
names = pd.Index(["co2_sequestration_limit"])
|
names = pd.Index(["co2_sequestration_limit"])
|
||||||
|
|
||||||
@ -515,8 +521,8 @@ def prepare_network(
|
|||||||
n = add_max_growth(n)
|
n = add_max_growth(n)
|
||||||
|
|
||||||
if n.stores.carrier.eq("co2 sequestered").any():
|
if n.stores.carrier.eq("co2 sequestered").any():
|
||||||
limit = co2_sequestration_potential
|
limit_dict = co2_sequestration_potential
|
||||||
add_co2_sequestration_limit(n, limit=limit)
|
add_co2_sequestration_limit(n, limit_dict=limit_dict)
|
||||||
|
|
||||||
return n
|
return n
|
||||||
|
|
||||||
@ -1116,19 +1122,19 @@ def solve_network(n, config, solving, **kwargs):
|
|||||||
|
|
||||||
return n
|
return n
|
||||||
|
|
||||||
|
#%%
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if "snakemake" not in globals():
|
if "snakemake" not in globals():
|
||||||
from _helpers import mock_snakemake
|
from _helpers import mock_snakemake
|
||||||
|
|
||||||
snakemake = mock_snakemake(
|
snakemake = mock_snakemake(
|
||||||
"solve_sector_network",
|
"solve_sector_network_myopic",
|
||||||
configfiles="../config/test/config.perfect.yaml",
|
# configfiles="../config/test/config.perfect.yaml",
|
||||||
simpl="",
|
simpl="",
|
||||||
opts="",
|
opts="",
|
||||||
clusters="37",
|
clusters="38",
|
||||||
ll="v1.0",
|
ll="vopt",
|
||||||
sector_opts="CO2L0-1H-T-H-B-I-A-dist1",
|
sector_opts="",
|
||||||
planning_horizons="2030",
|
planning_horizons="2030",
|
||||||
)
|
)
|
||||||
configure_logging(snakemake)
|
configure_logging(snakemake)
|
||||||
@ -1140,7 +1146,7 @@ if __name__ == "__main__":
|
|||||||
np.random.seed(solve_opts.get("seed", 123))
|
np.random.seed(solve_opts.get("seed", 123))
|
||||||
|
|
||||||
n = pypsa.Network(snakemake.input.network)
|
n = pypsa.Network(snakemake.input.network)
|
||||||
|
|
||||||
n = prepare_network(
|
n = prepare_network(
|
||||||
n,
|
n,
|
||||||
solve_opts,
|
solve_opts,
|
||||||
|
Loading…
Reference in New Issue
Block a user