adjust pipe retrofitting constraint to work with myopic
This commit is contained in:
parent
5b30f0ece6
commit
9f8b54a3ce
@ -189,25 +189,31 @@ def add_chp_constraints(n):
|
|||||||
def add_pipe_retrofit_constraint(n):
|
def add_pipe_retrofit_constraint(n):
|
||||||
"""Add constraint for retrofitting existing CH4 pipelines to H2 pipelines."""
|
"""Add constraint for retrofitting existing CH4 pipelines to H2 pipelines."""
|
||||||
|
|
||||||
gas_pipes_i = n.links[n.links.carrier=="gas pipeline"].index
|
gas_pipes_i = n.links[n.links.carrier=="gas pipeline"].query("p_nom_extendable").index
|
||||||
h2_retrofitted_i = n.links[n.links.carrier=='H2 pipeline retrofitted'].index
|
h2_retrofitted_i = n.links[n.links.carrier=='H2 pipeline retrofitted'].query("p_nom_extendable").index
|
||||||
|
h2_retrofitted_fixed_i = n.links[n.links.carrier=='H2 pipeline retrofitted'].index.difference(h2_retrofitted_i)
|
||||||
|
|
||||||
if h2_retrofitted_i.empty or gas_pipes_i.empty: return
|
if h2_retrofitted_i.empty or gas_pipes_i.empty: return
|
||||||
|
|
||||||
link_p_nom = get_var(n, "Link", "p_nom")
|
link_p_nom = get_var(n, "Link", "p_nom")
|
||||||
|
|
||||||
pipe_capacity = n.links.loc[gas_pipes_i, 'p_nom']
|
|
||||||
|
|
||||||
CH4_per_H2 = 1 / n.config["sector"]["H2_retrofit_capacity_per_CH4"]
|
CH4_per_H2 = 1 / n.config["sector"]["H2_retrofit_capacity_per_CH4"]
|
||||||
|
|
||||||
fr = "H2 pipeline retrofitted"
|
fr = "H2 pipeline retrofitted"
|
||||||
to = "gas pipeline"
|
to = "gas pipeline"
|
||||||
|
|
||||||
|
pipe_capacity = n.links.loc[gas_pipes_i, 'p_nom'].rename(index=lambda x: x.split("-2")[0])
|
||||||
|
already_retrofitted = (n.links.loc[h2_retrofitted_fixed_i, 'p_nom']
|
||||||
|
.rename(index= lambda x: x.split("-2")[0]
|
||||||
|
.replace(fr, to)).groupby(level=0).sum())
|
||||||
|
remaining_capacity = pipe_capacity - CH4_per_H2 * already_retrofitted.reindex(index=pipe_capacity.index).fillna(0)
|
||||||
|
|
||||||
lhs = linexpr(
|
lhs = linexpr(
|
||||||
(CH4_per_H2, link_p_nom.loc[h2_retrofitted_i].rename(index=lambda x: x.replace(fr, to))),
|
(CH4_per_H2, link_p_nom.loc[h2_retrofitted_i].rename(index=lambda x: x.replace(fr, to))),
|
||||||
(1, link_p_nom.loc[gas_pipes_i])
|
(1, link_p_nom.loc[gas_pipes_i])
|
||||||
)
|
)
|
||||||
|
|
||||||
define_constraints(n, lhs, "=", pipe_capacity, 'Link', 'pipe_retrofit')
|
lhs.rename(index=lambda x: x.split("-2")[0], inplace=True)
|
||||||
|
define_constraints(n, lhs, "=", remaining_capacity, 'Link', 'pipe_retrofit')
|
||||||
|
|
||||||
|
|
||||||
def add_co2_sequestration_limit(n, sns):
|
def add_co2_sequestration_limit(n, sns):
|
||||||
@ -275,12 +281,13 @@ if __name__ == "__main__":
|
|||||||
if 'snakemake' not in globals():
|
if 'snakemake' not in globals():
|
||||||
from helper import mock_snakemake
|
from helper import mock_snakemake
|
||||||
snakemake = mock_snakemake(
|
snakemake = mock_snakemake(
|
||||||
'solve_network',
|
'solve_network_myopic',
|
||||||
simpl='',
|
simpl='',
|
||||||
clusters=48,
|
opts="",
|
||||||
|
clusters="45",
|
||||||
lv=1.0,
|
lv=1.0,
|
||||||
sector_opts='Co2L0-168H-T-H-B-I-solar3-dist1',
|
sector_opts='168H-T-H-B-I-A-solar+p3-dist1',
|
||||||
planning_horizons=2050,
|
planning_horizons="2030",
|
||||||
)
|
)
|
||||||
|
|
||||||
logging.basicConfig(filename=snakemake.log.python,
|
logging.basicConfig(filename=snakemake.log.python,
|
||||||
|
Loading…
Reference in New Issue
Block a user