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

Compare Cases macro #1894

Merged
merged 20 commits into from
Nov 4, 2024
Merged

Compare Cases macro #1894

merged 20 commits into from
Nov 4, 2024

Conversation

mjprilliman
Copy link
Collaborator

Description

-Add Compare Cases macro to generate html reports with simple metric table and graphical comparisons of up to 4 cases
-cases being compared must all be run prior to running macro, and must be for the same financial model
-Maximum of 4 cases
-Battery version: same metrics with a few extra battery dispatch graphs; available for PV Battery, Standalone Battery, Generic (soon to be Custom Generation) Battery
-Should work for all configs with basic annual energy and financial information; must have a cashflow, macro will exit if looking at LCOE Calculator or None financial cases
-v1 of this feature, potential for updates in the future

Fixes #1877

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • This change modifies variables in existing compute modules. Please see Checking for PySAM Incompatible API Changes.

Checklist:

If you have added a new compute module in a SSC pull request related to this one, be sure to check the Process Requirements.

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

@janinefreeman
Copy link
Collaborator

This is great! Thanks for tackling this! A few quick thoughts:

  1. Is there any way to gracefully catch that someone didn't click simulate? Right now I get an error in the lk scripting box.
  2. The Tab title in the browser still says "SAM ME Wave Energy Case Comparison"
  3. The battery compare cases macro is crashing on line 733 when I compare two default detailed PV-battery single owner cases: Macro did not finish.
    [733] referencing unassigned variable:aep_system

@cpaulgilman
Copy link
Collaborator

cpaulgilman commented Oct 30, 2024

Looks good. A few suggestions:

Fix all instances of '<title>SAM ME Wave Energy Case Comparison Report</title>', for example Lines 531 and 763.

I tested with a PTES case that does not have monthly_energy and cause a macro error in Line 150. One solution is to check for get('monthly_energy') == Null and stop the macro with a message if one of the required variables is Null.

Remove Line 974 outln(reportCode); so raw HTML does not print in console.

In table, replace "Technology" with "Performance Model".

In report footer, replace "This report was generated using the System Advisor Model testMacro" with "This report was generated using the System Advisor Model Compare Cases macro".

Center footer with '<footer style="text-align:center;">

@cpaulgilman
Copy link
Collaborator

@mjprilliman I'm getting SAM crashes testing now -- is this still in progress?

@mjprilliman
Copy link
Collaborator Author

@mjprilliman I'm getting SAM crashes testing now -- is this still in progress?

I was waiting for tests to pass, but I can look into any issues. Where is the crash happening?

@cpaulgilman
Copy link
Collaborator

Sorry, I think the crash was a false alarm. I tried cleaning and rebuilding and things are working now. The fixes for the items I listed above look good. Thanks!

A couple of things in the new build:

  • For the .sam file in combine-cases-macro-test.zip, I'm getting the following LK error when I run the "Battery Compare Cases" macro from the Custom Generation Battery case:
Macro did not finish.
[791] referencing unassigned variable:baselineCase
  • For that same file that has a PV-Battery and Custom Generation-Battery case, the "Compare Cases" macro seems to work properly, but the Battery Compare Cases generates the above error. Should there be two versions of the macro?

@mjprilliman
Copy link
Collaborator Author

Sorry, I think the crash was a false alarm. I tried cleaning and rebuilding and things are working now. The fixes for the items I listed above look good. Thanks!

A couple of things in the new build:

  • For the .sam file in combine-cases-macro-test.zip, I'm getting the following LK error when I run the "Battery Compare Cases" macro from the Custom Generation Battery case:
Macro did not finish.
[791] referencing unassigned variable:baselineCase
  • For that same file that has a PV-Battery and Custom Generation-Battery case, the "Compare Cases" macro seems to work properly, but the Battery Compare Cases generates the above error. Should there be two versions of the macro?

Thanks for finding that, there was a broken if statement for that.

Yes, there's a few extra features for the battery macro that I think are worth it. It creates a stacked graph for the annual energy of each case showing the contributions from the system and from the battery discharge. And for two battery cases, there's a waterfall chart that shows the difference in annual energy charged including steps for system and grid charging to compare the two cases.

@cpaulgilman
Copy link
Collaborator

Ok, looks good.

@mjprilliman mjprilliman merged commit d7216fb into develop Nov 4, 2024
8 checks passed
@mjprilliman mjprilliman deleted the pv-batt-compare-cases-macro branch November 4, 2024 19:06
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.

Compare Cases Macro
3 participants