Skip to content

Commit 3c993e4

Browse files
committed
Initial check at 0 carbon price
1 parent 3acd6f5 commit 3c993e4

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

src/muse/carbon_budget.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,23 @@ def bisection(
329329
"""
330330
from logging import getLogger
331331

332+
# Create cache for emissions at different price points
333+
emissions_cache = EmissionsCache(market, equilibrium, commodities)
334+
332335
# Carbon price and emissions threshold in the forecast year
333336
future = market.year[-1]
334337
target = carbon_budget.sel(year=future).values.item()
335338
price = market.prices.sel(year=future, commodity=commodities).mean().values.item()
336339

340+
# Test if emissions are already below the budget without imposing a carbon price
341+
if emissions_cache[0.0] < target:
342+
message = (
343+
f"Emissions for the year {int(future)} are already below the carbon budget "
344+
"without imposing a carbon price. The carbon price has been set to zero."
345+
)
346+
getLogger(__name__).warning(message)
347+
return 0.0
348+
337349
# Initial lower and upper bounds on carbon price for the bisection algorithm
338350
current = market.year[0]
339351
time_exp = int(future - current)
@@ -344,7 +356,6 @@ def bisection(
344356
) # i.e. 10% yearly increase on current price
345357

346358
# Bisection loop
347-
emissions_cache = EmissionsCache(market, equilibrium, commodities)
348359
for _ in range(max_iterations): # maximum number of iterations before terminating
349360
# Cap prices between 0.0 and price_too_high_threshold
350361
if refine_price:
@@ -392,11 +403,6 @@ def bisection(
392403
"horizon is preventing the budget from being met. "
393404
"The CO2 price in this year should be interpreted with caution."
394405
)
395-
elif all(emissions_cache[k] < target for k in emissions_cache):
396-
message = (
397-
f"Emissions for the year {int(future)} are already below the carbon budget "
398-
"without imposing a carbon price. The carbon price has been set to zero."
399-
)
400406
else:
401407
message = (
402408
f"Carbon budget could not be matched for the year {int(future)} to within "

0 commit comments

Comments
 (0)