Add process emissions to country emissions constraint, fix snapshot weighting
This commit is contained in:
parent
82ac430fd9
commit
d9ec127f99
@ -795,7 +795,7 @@ def add_co2limit_country(n, limit_countries, nyears=1.0):
|
|||||||
|
|
||||||
p = n.model["Link-p"] # dimension: (time, component)
|
p = n.model["Link-p"] # dimension: (time, component)
|
||||||
|
|
||||||
# NB: Most country-specific links retain their locational information in bus1 (except for DAC, where it is in bus2)
|
# NB: Most country-specific links retain their locational information in bus1 (except for DAC, where it is in bus2, and process emissions, where it is in bus0)
|
||||||
country = n.links.bus1.map(n.buses.location).map(n.buses.country)
|
country = n.links.bus1.map(n.buses.location).map(n.buses.country)
|
||||||
country_DAC = (
|
country_DAC = (
|
||||||
n.links[n.links.carrier == "DAC"]
|
n.links[n.links.carrier == "DAC"]
|
||||||
@ -803,6 +803,12 @@ def add_co2limit_country(n, limit_countries, nyears=1.0):
|
|||||||
.map(n.buses.country)
|
.map(n.buses.country)
|
||||||
)
|
)
|
||||||
country[country_DAC.index] = country_DAC
|
country[country_DAC.index] = country_DAC
|
||||||
|
country_process_emissions = (
|
||||||
|
n.links[n.links.carrier.str.contains("process emissions")]
|
||||||
|
.bus0.map(n.buses.location)
|
||||||
|
.map(n.buses.country)
|
||||||
|
)
|
||||||
|
country[country_process_emissions.index] = country_process_emissions
|
||||||
|
|
||||||
lhs = []
|
lhs = []
|
||||||
for port in [col[3:] for col in n.links if col.startswith("bus")]:
|
for port in [col[3:] for col in n.links if col.startswith("bus")]:
|
||||||
@ -818,13 +824,18 @@ def add_co2limit_country(n, limit_countries, nyears=1.0):
|
|||||||
|
|
||||||
idx = n.links[mask].index
|
idx = n.links[mask].index
|
||||||
|
|
||||||
|
international = n.links.carrier.map(
|
||||||
|
lambda x: 0.4 if x in ["kerosene for aviation", "shipping oil"] else 1.0
|
||||||
|
)
|
||||||
grouping = country.loc[idx]
|
grouping = country.loc[idx]
|
||||||
|
|
||||||
if not grouping.isnull().all():
|
if not grouping.isnull().all():
|
||||||
expr = (
|
expr = (
|
||||||
(p.loc[:, idx] * efficiency[idx])
|
((p.loc[:, idx] * efficiency[idx] * international[idx])
|
||||||
.groupby(grouping, axis=1)
|
.groupby(grouping, axis=1)
|
||||||
.sum()
|
.sum()
|
||||||
|
*n.snapshot_weightings.generators
|
||||||
|
)
|
||||||
.sum(dims="snapshot")
|
.sum(dims="snapshot")
|
||||||
)
|
)
|
||||||
lhs.append(expr)
|
lhs.append(expr)
|
||||||
@ -935,6 +946,10 @@ def solve_network(n, config, solving, opts="", **kwargs):
|
|||||||
f"Solving status '{status}' with termination condition '{condition}'"
|
f"Solving status '{status}' with termination condition '{condition}'"
|
||||||
)
|
)
|
||||||
if "infeasible" in condition:
|
if "infeasible" in condition:
|
||||||
|
m = n.model
|
||||||
|
labels = m.compute_infeasibilities()
|
||||||
|
print(labels)
|
||||||
|
m.print_infeasibilities()
|
||||||
raise RuntimeError("Solving status 'infeasible'")
|
raise RuntimeError("Solving status 'infeasible'")
|
||||||
|
|
||||||
return n
|
return n
|
||||||
|
Loading…
Reference in New Issue
Block a user