Carbon
energypylinear
can optimize for both price and carbon as optimization objectives.
This ability comes from two things - an objective function, which can be either for price or carbon, along with accounting of both price and carbon emissions.
We can dispatch a battery to minimize carbon emissions by passing in objective='carbon'
:
Setup Interval Data
import energypylinear as epl
electricity_prices = [100, 50, 200, -100, 0, 200, 100, -100]
electricity_carbon_intensities = [0.1, 0.2, 0.1, 0.15, 0.01, 0.7, 0.5, 0.01]
Optimize for Carbon
asset = epl.Battery(
power_mw=2,
capacity_mwh=4,
efficiency_pct=0.9,
electricity_prices=electricity_prices,
electricity_carbon_intensities=electricity_carbon_intensities,
)
carbon = asset.optimize(objective="carbon", verbose=3)
carbon_account = epl.get_accounts(carbon.results, verbose=3)
print(f"{carbon_account=}")
Optimize for Money
We can compare these results above with a simulation that optimizes for price, using a energypylinear.accounting.Account
to compare both simulations.
Our optimization for price has a high negative cost.
The optimization for carbon has lower emissions, but at a higher cost:
asset = epl.Battery(
power_mw=2,
capacity_mwh=4,
efficiency_pct=0.9,
electricity_prices=electricity_prices,
electricity_carbon_intensities=electricity_carbon_intensities,
)
price = asset.optimize(
objective="price",
verbose=3
)
price_account = epl.get_accounts(price.results, verbose=3)
print(f"{price_account=}")
Calculate Variance Between Accounts
variance = price_account - carbon_account
print(f"{variance=}")
print(f"{-variance.cost / variance.emissions:.2f} $/tC")
Full Example
import energypylinear as epl
electricity_prices = [100, 50, 200, -100, 0, 200, 100, -100]
electricity_carbon_intensities = [0.1, 0.2, 0.1, 0.15, 0.01, 0.7, 0.5, 0.01]
asset = epl.Battery(
power_mw=2,
capacity_mwh=4,
efficiency_pct=0.9,
electricity_prices=electricity_prices,
electricity_carbon_intensities=electricity_carbon_intensities,
)
# optimize for carbon
carbon = asset.optimize(objective="carbon", verbose=3)
carbon_account = epl.get_accounts(carbon.results, verbose=3)
print(f"{carbon_account=}")
# optimize for money
price = asset.optimize(
objective="price",
verbose=3
)
price_account = epl.get_accounts(price.results, verbose=3)
print(f"{price_account=}")
# calculate variance (difference) between accounts
variance = price_account - carbon_account
print(f"{variance=}")
print(f"{-variance.cost / variance.emissions:.2f} $/tC")