Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building support for monthly charges/costs into Calliope #727

Open
jmorrisnrel opened this issue Dec 10, 2024 · 1 comment
Open

Building support for monthly charges/costs into Calliope #727

jmorrisnrel opened this issue Dec 10, 2024 · 1 comment
Labels
enhancement has-workaround The issue describes a valid workaround until the primary issue is solved v0.7 (upcoming) version 0.7

Comments

@jmorrisnrel
Copy link

What can be improved?

Idea/Goal:
Define custom lookup arrays on specific indices to enable more advanced constraint/expression where filtering.

Background:
We have been running into models/scenarios where we want to have technologies in Calliope that have monthly bills including monthly peak energy usage charges. Examples could include certain third-party power purchase agreements or even utility tariffs and the monthly power bills that a customer sees. We have modeled this in Calliope using multiple capacity expansion transmission/conversion techs/nodes, having one enabled (via efficiency) each month which is a pretty clunky workaround.

We have been looking into the custom math options in 0.7 to see if we can simplify building this behavior/make it more efficient and have been considering adding new expressions or decision variables to track the peak demand each month so we can apply costs to it. We're struggling to work out a way to tie values on the timesteps index to months in the expression where clauses. select_from_lookup_arrays looks like it would be the right helper function if we could get a lookup array with the month for each timestep, but we don't see a way to add a lookup array to the problem formulation.

If there is a way to add a lookup array to the problem formulation, we could potentially selectively enable constraints based on month, weekday/weekend, or any other categorization of timesteps/index values. A work around could be to define a timeseries parameter at the tech (or a master template) level with the month of each timestep that we can then access in a where clause.

Adding more decision variables might not even improve the performance of the model compared to multiple techs, but wanted to flag a potential use for the ability to add custom lookup arrays or find another way to categorize index values to enable more flexible constraint definition.

Version

v0.7.0dev4

@jmorrisnrel jmorrisnrel changed the title Building support for monthly charges into Calliope Building support for monthly charges/costs into Calliope Dec 10, 2024
@brynpickering
Copy link
Member

This is a common use-case and could be dealt with in a variety of ways right now. The one I'd recommend is to create your lookup table in a CSV as:

timesteps            months    lookup_month
2005-01-01 00:00:00  1        1.0
2005-01-01 01:00:00  1        1.0
                             ... 
2005-12-31 22:00:00  12       1.0
2005-12-31 23:00:00  12       1.0

Then load it in as a data table

data_tables:
  lookup_month:
    data: <path/to/file.csv>
    rows: [timesteps, months]
    columns: parameters

And then use it in custom math:

global_expressions:
  monthly_cost:
    foreach: ["techs", "nodes", "months", "costs", "carriers"]
    where: "flow_out"
    equations:
      - expression: sum(where(flow_out, lookup_month), over=timesteps) * cost_month
 
constraints:
  max_monthly:
    foreach: ["techs", "nodes", "months", "costs", "carriers"]
    where: "flow_out"
    equations:
      - expression: sum(where(flow_out, lookup_month), over=timesteps) <= flow_out_monthly_max

where cost_month and flow_out_monthly_max are parameters you've defined indexed over the months dimension + techs/nodes/carriers etc.

@brynpickering brynpickering added has-workaround The issue describes a valid workaround until the primary issue is solved v0.7 (upcoming) version 0.7 labels Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement has-workaround The issue describes a valid workaround until the primary issue is solved v0.7 (upcoming) version 0.7
Projects
None yet
Development

No branches or pull requests

2 participants