rename central_fraction->district heating potential, restructure district heating share implementation

This commit is contained in:
lisazeyen 2021-09-29 14:37:36 +02:00
parent 8322350fee
commit 854bd80818

View File

@ -636,6 +636,9 @@ def prepare_data(n):
nodal_energy_totals = energy_totals.loc[pop_layout.ct].fillna(0.) nodal_energy_totals = energy_totals.loc[pop_layout.ct].fillna(0.)
nodal_energy_totals.index = pop_layout.index nodal_energy_totals.index = pop_layout.index
# district heat share not weighted by population
district_heat_share = round(nodal_energy_totals["district heat share"],
ndigits=2)
nodal_energy_totals = nodal_energy_totals.multiply(pop_layout.fraction, axis=0) nodal_energy_totals = nodal_energy_totals.multiply(pop_layout.fraction, axis=0)
# copy forward the daily average heat demand into each hour, so it can be multipled by the intraday profile # copy forward the daily average heat demand into each hour, so it can be multipled by the intraday profile
@ -758,7 +761,7 @@ def prepare_data(n):
) )
return nodal_energy_totals, heat_demand, ashp_cop, gshp_cop, solar_thermal, transport, avail_profile, dsm_profile, nodal_transport_data return nodal_energy_totals, heat_demand, ashp_cop, gshp_cop, solar_thermal, transport, avail_profile, dsm_profile, nodal_transport_data, district_heat_share
# TODO checkout PyPSA-Eur script # TODO checkout PyPSA-Eur script
@ -1386,7 +1389,7 @@ def add_heat(n, costs):
heat_load = heat_demand[[sector + " water",sector + " space"]].groupby(level=1,axis=1).sum()[nodes[name]].multiply(factor) heat_load = heat_demand[[sector + " water",sector + " space"]].groupby(level=1,axis=1).sum()[nodes[name]].multiply(factor)
if name == "urban central": if name == "urban central":
heat_load = heat_demand.groupby(level=1,axis=1).sum()[nodes[name]].multiply(factor * (1 + options['district_heating_loss'])) heat_load = heat_demand.groupby(level=1,axis=1).sum()[nodes[name]].multiply(factor * (1 + options['district_heating']['district_heating_loss']))
n.madd("Load", n.madd("Load",
nodes[name], nodes[name],
@ -1671,10 +1674,6 @@ def create_nodes_for_heat_sector():
# distribution of urban population within a country # distribution of urban population within a country
pop_layout["urban_ct_fraction"] = pop_layout["urban"] / \ pop_layout["urban_ct_fraction"] = pop_layout["urban"] / \
pop_layout["ct"].map(ct_urban.get) pop_layout["ct"].map(ct_urban.get)
# todays district heating share per country
dist_heat_share_ct = pd.read_csv(snakemake.input.dh_share, index_col=0,
usecols=[0,1]).dropna()/100
dist_heat_share = pop_layout.ct.map(dist_heat_share_ct["district heating share"])
sectors = ["residential", "services"] sectors = ["residential", "services"]
@ -1686,36 +1685,29 @@ def create_nodes_for_heat_sector():
nodes[sector + " rural"] = pop_layout.index nodes[sector + " rural"] = pop_layout.index
nodes[sector + " urban decentral"] = pop_layout.index nodes[sector + " urban decentral"] = pop_layout.index
if options["central"] and not options['district_heating_increase']: # maximum potential of urban demand covered by district heating
central_fraction = options['central_fraction'] central_fraction = options['district_heating']["potential"]
dist_fraction = central_fraction * urban_fraction # district heating share at each node
nodes["urban central"] = dist_fraction.index dist_fraction_node = district_heat_share * pop_layout["urban_ct_fraction"] / pop_layout["fraction"]
nodes["urban central"] = dist_fraction_node.index
# if district heating share larger than urban fraction -> set urban
# fraction to district heating share
urban_fraction = pd.concat([urban_fraction, dist_fraction_node],
axis=1).max(axis=1)
# difference of max potential and today's share of district heating
diff = (urban_fraction * central_fraction) - dist_fraction_node
progress = get(options["district_heating"]["potential"], investment_year)
dist_fraction_node += diff * progress
print("************************************")
print(
"the current DH share compared to the maximum possible is increased \
\n by a progress factor of ",
progress,
"resulting DH share: ",
dist_fraction_node)
print("**********************************")
# take current district heating share return nodes, dist_fraction_node, urban_fraction
if options['district_heating_increase']:
dist_fraction = dist_heat_share * \
pop_layout["urban_ct_fraction"] / pop_layout["fraction"]
nodes["urban central"] = dist_fraction.index
# if district heating share larger than urban fraction -> set urban
# fraction to district heating share
urban_fraction = pd.concat([urban_fraction, dist_fraction],
axis=1).max(axis=1)
diff = urban_fraction - dist_fraction
dist_fraction += diff * get(options["dh_strength"], investment_year)
print("************************************")
print(
"the current DH share compared to the maximum possible is increased \
\n by a factor of ",
get(options["dh_strength"], investment_year),
"resulting DH share: ",
dist_fraction)
print("**********************************")
else:
dist_fraction = urban_fraction * 0
nodes["urban central"] = dist_fraction.index
return nodes, dist_fraction, urban_fraction
def add_biomass(n, costs): def add_biomass(n, costs):
@ -2246,7 +2238,6 @@ if __name__ == "__main__":
opts="", opts="",
clusters="37", clusters="37",
lv=1.0, lv=1.0,
opts='',
sector_opts='Co2L0-168H-T-H-B-I-solar3-dist1', sector_opts='Co2L0-168H-T-H-B-I-solar3-dist1',
planning_horizons="2030", planning_horizons="2030",
) )
@ -2300,10 +2291,10 @@ if __name__ == "__main__":
if o == "biomasstransport": if o == "biomasstransport":
options["biomass_transport"] = True options["biomass_transport"] = True
nodal_energy_totals, heat_demand, ashp_cop, gshp_cop, solar_thermal, transport, avail_profile, dsm_profile, nodal_transport_data = prepare_data(n) nodal_energy_totals, heat_demand, ashp_cop, gshp_cop, solar_thermal, transport, avail_profile, dsm_profile, nodal_transport_data, district_heat_share = prepare_data(n)
if "nodistrict" in opts: if "nodistrict" in opts:
options["central"] = False options["district_heating"]["progress"] = 0.0
if "T" in opts: if "T" in opts:
add_land_transport(n, costs) add_land_transport(n, costs)