Skip to content

Conversation

zolanaj
Copy link
Collaborator

@zolanaj zolanaj commented Sep 12, 2025

Fixed

  • fixed a bug in which demand and energy charges are applied to incorrect tiers in instances where tiered rates decrease as consumption increases, and the limits on the last tier are very large.

Addresses issue #410

The newly added tests failed with the previous implementation.

@zolanaj zolanaj requested a review from Bill-Becker September 15, 2025 17:06
Copy link
Collaborator

@Bill-Becker Bill-Becker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of curiosity questions, and a suggestion to make a function to use for the three similar blocks of code. Then if we want to change the logic, we'd only have to do it in that one function. Feel free to push back if there's a good reason not to.

added_power = !isempty(p.s.storage.types.elec) ? sum(p.s.storage.attr[b].max_kw for b in p.s.storage.types.elec) : 1.0e-3

electric_demand_bigM = 2 * maximum(100*p.s.electric_load.loads_kw .+
p.s.space_heating_load.loads_kw .+
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these heating and cooling loads in here because we might be converting them to electric loads with a COP as low as 1?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a COP as low as 0.5, in part because of low-COP techs like an ASHP under low temperature. I added a few notes here: 5fa0412 (lines 467-468)

#big-M used for monthly demand tiers
added_power = !isempty(p.s.storage.types.elec) ? sum(p.s.storage.attr[b].max_kw for b in p.s.storage.types.elec) : 1.0e-3

electric_demand_bigM = 2 * maximum(100*p.s.electric_load.loads_kw .+
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 100x the electric load, and then 2x the max of the load aggregation here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was an assumption from the "legacy" code in reo/ - we adopted it for use as an upper bound when charging seasonal storage systems.

b = m[Symbol(dv)]


# Implement Big-M constratint for TOU demand tiers
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional request: this code block looks very similar to the one above, so it would be helpful and DRY to make a function which could then be used by either of these functions with the different arguments. If that's more challenging than I'm thinking it would be, feel free to keep as is.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, great catch! addressed here, and marking the other related comment as resolved since it's related to this thread: 5fa0412

@zolanaj zolanaj requested a review from Bill-Becker October 3, 2025 16:16
@zolanaj
Copy link
Collaborator Author

zolanaj commented Oct 3, 2025

Ready for your re-review @Bill-Becker!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants