add time dependent co2 price
This commit is contained in:
parent
e9348b8e23
commit
747bf5d815
@ -285,7 +285,6 @@ rule add_electricity:
|
|||||||
powerplants=RESOURCES + "powerplants.csv",
|
powerplants=RESOURCES + "powerplants.csv",
|
||||||
hydro_capacities=ancient("data/bundle/hydro_capacities.csv"),
|
hydro_capacities=ancient("data/bundle/hydro_capacities.csv"),
|
||||||
geth_hydro_capacities="data/geth2015_hydro_capacities.csv",
|
geth_hydro_capacities="data/geth2015_hydro_capacities.csv",
|
||||||
co2_price="data/validation/CO2_price_2019.csv",
|
|
||||||
fuel_price="data/validation/monthly_fuel_price.csv",
|
fuel_price="data/validation/monthly_fuel_price.csv",
|
||||||
load=RESOURCES + "load.csv",
|
load=RESOURCES + "load.csv",
|
||||||
nuts3_shapes=RESOURCES + "nuts3_shapes.geojson",
|
nuts3_shapes=RESOURCES + "nuts3_shapes.geojson",
|
||||||
@ -383,6 +382,7 @@ rule prepare_network:
|
|||||||
input:
|
input:
|
||||||
RESOURCES + "networks/elec_s{simpl}_{clusters}_ec.nc",
|
RESOURCES + "networks/elec_s{simpl}_{clusters}_ec.nc",
|
||||||
tech_costs=COSTS,
|
tech_costs=COSTS,
|
||||||
|
co2_price="data/validation/CO2_price_2019.csv",
|
||||||
output:
|
output:
|
||||||
RESOURCES + "networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
|
RESOURCES + "networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
|
||||||
log:
|
log:
|
||||||
|
@ -65,6 +65,7 @@ import pandas as pd
|
|||||||
import pypsa
|
import pypsa
|
||||||
from _helpers import configure_logging
|
from _helpers import configure_logging
|
||||||
from add_electricity import load_costs, update_transmission_costs
|
from add_electricity import load_costs, update_transmission_costs
|
||||||
|
from pypsa.descriptors import expand_series
|
||||||
|
|
||||||
idx = pd.IndexSlice
|
idx = pd.IndexSlice
|
||||||
|
|
||||||
@ -107,6 +108,17 @@ def add_emission_prices(n, emission_prices={"co2": 0.0}, exclude_co2=False):
|
|||||||
n.storage_units["marginal_cost"] += su_ep
|
n.storage_units["marginal_cost"] += su_ep
|
||||||
|
|
||||||
|
|
||||||
|
def add_emission_prices_t(n):
|
||||||
|
co2_price = pd.read_csv(snakemake.input.co2_price, index_col=0,
|
||||||
|
parse_dates=True)
|
||||||
|
co2_price = co2_price[~co2_price.index.duplicated()]
|
||||||
|
co2_price = co2_price.reindex(n.snapshots).fillna(method="ffill").fillna(method="bfill")
|
||||||
|
emissions = n.generators.carrier.map(n.carriers.co2_emissions)
|
||||||
|
co2_cost = (expand_series(emissions, n.snapshots).T
|
||||||
|
.mul(co2_price.iloc[:,0], axis=0))
|
||||||
|
n.generators_t.marginal_cost += (co2_cost.reindex(columns=n.generators_t.marginal_cost.columns))
|
||||||
|
|
||||||
|
|
||||||
def set_line_s_max_pu(n, s_max_pu=0.7):
|
def set_line_s_max_pu(n, s_max_pu=0.7):
|
||||||
n.lines["s_max_pu"] = s_max_pu
|
n.lines["s_max_pu"] = s_max_pu
|
||||||
logger.info(f"N-1 security margin of lines set to {s_max_pu}")
|
logger.info(f"N-1 security margin of lines set to {s_max_pu}")
|
||||||
@ -238,12 +250,13 @@ def set_line_nom_max(n, s_nom_max_set=np.inf, p_nom_max_set=np.inf):
|
|||||||
n.links.p_nom_max.clip(upper=p_nom_max_set, inplace=True)
|
n.links.p_nom_max.clip(upper=p_nom_max_set, inplace=True)
|
||||||
|
|
||||||
|
|
||||||
|
#%%
|
||||||
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(
|
||||||
"prepare_network", simpl="", clusters="40", ll="v0.3", opts="Co2L-24H"
|
"prepare_network", simpl="", clusters="37c", ll="v1.0", opts="24H-Ept"
|
||||||
)
|
)
|
||||||
configure_logging(snakemake)
|
configure_logging(snakemake)
|
||||||
|
|
||||||
@ -324,6 +337,9 @@ if __name__ == "__main__":
|
|||||||
logger.info("Setting emission prices according to config value.")
|
logger.info("Setting emission prices according to config value.")
|
||||||
add_emission_prices(n, snakemake.config["costs"]["emission_prices"])
|
add_emission_prices(n, snakemake.config["costs"]["emission_prices"])
|
||||||
break
|
break
|
||||||
|
if "ept" in o:
|
||||||
|
logger.info("Setting time dependent emission prices according spot market price")
|
||||||
|
add_emission_prices_t(n)
|
||||||
|
|
||||||
ll_type, factor = snakemake.wildcards.ll[0], snakemake.wildcards.ll[1:]
|
ll_type, factor = snakemake.wildcards.ll[0], snakemake.wildcards.ll[1:]
|
||||||
set_transmission_limit(n, ll_type, factor, costs, Nyears)
|
set_transmission_limit(n, ll_type, factor, costs, Nyears)
|
||||||
|
Loading…
Reference in New Issue
Block a user