Merge pull request #711 from PyPSA/biomass-transport-costs

prepare_sector: add biomass transport costs for networks wo biomass network
This commit is contained in:
lisazeyen 2023-08-02 15:12:50 +02:00 committed by GitHub
commit 9687fef2e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 8 deletions

View File

@ -295,7 +295,7 @@ rule build_biomass_potentials:
"../scripts/build_biomass_potentials.py" "../scripts/build_biomass_potentials.py"
if config["sector"]["biomass_transport"]: if config["sector"]["biomass_transport"] or config["sector"]["biomass_spatial"]:
rule build_biomass_transport_costs: rule build_biomass_transport_costs:
input: input:
@ -320,9 +320,8 @@ if config["sector"]["biomass_transport"]:
build_biomass_transport_costs_output = rules.build_biomass_transport_costs.output build_biomass_transport_costs_output = rules.build_biomass_transport_costs.output
if not config["sector"]["biomass_transport"]: if not (config["sector"]["biomass_transport"] or config["sector"]["biomass_spatial"]):
# this is effecively an `else` statement which is however not liked by snakefmt # this is effecively an `else` statement which is however not liked by snakefmt
build_biomass_transport_costs_output = {} build_biomass_transport_costs_output = {}

View File

@ -2156,12 +2156,11 @@ def add_biomass(n, costs):
) )
if options["biomass_transport"]: if options["biomass_transport"]:
transport_costs = pd.read_csv(
snakemake.input.biomass_transport_costs,
index_col=0,
).squeeze()
# add biomass transport # add biomass transport
transport_costs = pd.read_csv(
snakemake.input.biomass_transport_costs, index_col=0
)
transport_costs = transport_costs.squeeze()
biomass_transport = create_network_topology( biomass_transport = create_network_topology(
n, "biomass transport ", bidirectional=False n, "biomass transport ", bidirectional=False
) )
@ -2185,6 +2184,27 @@ def add_biomass(n, costs):
carrier="solid biomass transport", carrier="solid biomass transport",
) )
elif options["biomass_spatial"]:
# add artificial biomass generators at nodes which include transport costs
transport_costs = pd.read_csv(
snakemake.input.biomass_transport_costs, index_col=0
)
transport_costs = transport_costs.squeeze()
bus_transport_costs = spatial.biomass.nodes.to_series().apply(
lambda x: transport_costs[x[:2]]
)
average_distance = 200 # km #TODO: validate this assumption
n.madd(
"Generator",
spatial.biomass.nodes,
bus=spatial.biomass.nodes,
carrier="solid biomass",
p_nom=10000,
marginal_cost=costs.at["solid biomass", "fuel"]
+ bus_transport_costs * average_distance,
)
# AC buses with district heating # AC buses with district heating
urban_central = n.buses.index[n.buses.carrier == "urban central heat"] urban_central = n.buses.index[n.buses.carrier == "urban central heat"]
if not urban_central.empty and options["chp"]: if not urban_central.empty and options["chp"]: