Skip to content

Sam 1783 enforce utility rate tiers#1207

Merged
brtietz merged 8 commits into
developfrom
sam_1783_enforce_sam_tiers
Sep 30, 2024
Merged

Sam 1783 enforce utility rate tiers#1207
brtietz merged 8 commits into
developfrom
sam_1783_enforce_sam_tiers

Conversation

@brtietz

@brtietz brtietz commented Sep 20, 2024

Copy link
Copy Markdown
Collaborator

Fixes NatLabRockies/SAM#1783. Tiers are now required to be the same within a month across tou periods. This is enforced seperately for demand and energy charges (e.g. the tiers within energy charges have to be consistent, but don't have to be the same as demand charges).

No changes to the the underlying calculations, just a new exception to inform users what the downstream code expects.

Test file:
sam_1873_test.zip
Feel free to suggest other tests - this just demonstrates the cases above.

@brtietz brtietz added this to the SAM Fall 2024 Release milestone Sep 20, 2024
@brtietz brtietz self-assigned this Sep 20, 2024

@sjanzou sjanzou left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please update the Demand Charge error message value on line 829.

Using the updated test file,
sam_1873_test.zip
I would suggest the following error message changes:
For the Energy Charge error message, I would suggest some additional details:
from
exec fail(lib_utility_rate_equations): Energy tier for month 0 period 2 was expected to be 200 but was 100 in tier 1. Tiers within a month should be the same for TOU rates.

To
exec fail(lib_utility_rate_equations): Energy Tier 1 Max. Usage for January Period 2 was expected to be 200 kWh but was 100 kWh. Tiers should have the same Max. Usage across Periods in the same month for TOU rates.

Similarly, I suggest changing the demand charge error message from:
exec fail(lib_utility_rate_equations): Demand tier for month 0 period 2 was expected to be 100 but was 50 in tier 1. Tiers within a month should be the same for TOU rates.

Request change to
exec fail(lib_utility_rate_equations): Demand Tier 1 Peak for January Period 2 was expected to be 100 kW but was 50 kW. Tiers should have the same Peak across Periods in the same month for TOU rates.

Comment thread shared/lib_utility_rate_equations.cpp Outdated
else if (std::fabs(tier_check[tier - 1] - m_month[m].dc_tou_ub.at(i, j)) > 1e-7) {
std::ostringstream ss;
ss << "Demand tier for month " << m << " period " << period << " was expected to be " << tier_check[tier - 1] << " but was ";
ss << m_month[m].ec_tou_ub.at(i, j) << " in tier " << tier << ". Tiers within a month should be the same for TOU rates.";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

m_month[m].ec_tou_ub.at(i, j) should be m_month[m].dc_tou_ub.at(i, j)

@brtietz

brtietz commented Sep 23, 2024

Copy link
Copy Markdown
Collaborator Author

@sjanzou Thanks, that's a much more useful message.

Is there a function that looks up month name by month that is accessible to "shared"? I see DateTime::GetMonthName in Toolbox.cpp, but not seeing anything in lib_util or otherwise accessible from this function call. Are there other functions in shared that would benefit from an analogous function there?

@brtietz

brtietz commented Sep 23, 2024

Copy link
Copy Markdown
Collaborator Author

@sjanzou Thanks, that's a much more useful message.

Is there a function that looks up month name by month that is accessible to "shared"? I see DateTime::GetMonthName in Toolbox.cpp, but not seeing anything in lib_util or otherwise accessible from this function call. Are there other functions in shared that would benefit from an analogous function there?

Never mind on this one: I found util::schedule_int_to_month (January vs jan was the search issue)

However, I'm not sure there's a function that translates ec_tou_units to a string in ssc. Is it worth adding a function for that for this error message? It's unclear to me if there are other places that would be useful.

@sjanzou

sjanzou commented Sep 24, 2024

Copy link
Copy Markdown
Collaborator

@sjanzou Thanks, that's a much more useful message.
Is there a function that looks up month name by month that is accessible to "shared"? I see DateTime::GetMonthName in Toolbox.cpp, but not seeing anything in lib_util or otherwise accessible from this function call. Are there other functions in shared that would benefit from an analogous function there?

Never mind on this one: I found util::schedule_int_to_month (January vs jan was the search issue)

However, I'm not sure there's a function that translates ec_tou_units to a string in ssc. Is it worth adding a function for that for this error message? It's unclear to me if there are other places that would be useful.

@brtietz - good point... I think it would be useful to have the index mapping from the UI. The general purpose function would be the compute_module::info function that returns the meta data for ur_ec_tou_mat
image
then does the parsing on the UNITS field. This is a touchy point of contention in separating the UI form the calculation engine. I would suggest determining the units for the error message using
image
and adding a "daily" function for the daily unit distinction. What do you think?

@brtietz brtietz requested a review from sjanzou September 26, 2024 17:16
@brtietz

brtietz commented Sep 26, 2024

Copy link
Copy Markdown
Collaborator Author

Good idea on adding a daily function. That's addressed in the latest push. This should be ready for a second review. Thanks!

@sjanzou sjanzou left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please see the comments when using different input units...

Maybe the error message should be kWh regardless of units entered for the energy change...

}

std::ostringstream ss;
ss << "Energy tier " << tier << " Max. Usage for " << util::schedule_int_to_month(m) << " period " << period << " was expected to be ";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think I may have confused the issue... consider the following rate
image

The error message generated is (which does not make sense):
image

However, with the rate
image

the error message makes sense
image

So, it seems the error message should have kWh regardless of the units entered….

@brtietz brtietz Sep 27, 2024

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch! Resolved in latest push:

image

For the following rate:

image

@sjanzou sjanzou left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SAM doesn't throw an error for different tier in different TOU periods

3 participants