Skip to content

Compare Cases macro#1894

Merged
mjprilliman merged 20 commits into
developfrom
pv-batt-compare-cases-macro
Nov 4, 2024
Merged

Compare Cases macro#1894
mjprilliman merged 20 commits into
developfrom
pv-batt-compare-cases-macro

Conversation

@mjprilliman

Copy link
Copy Markdown
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
Copy Markdown
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

cpaulgilman commented Oct 30, 2024

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
Collaborator

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

@mjprilliman

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Collaborator

Ok, looks good.

@mjprilliman mjprilliman merged commit d7216fb into develop Nov 4, 2024
@mjprilliman mjprilliman deleted the pv-batt-compare-cases-macro branch November 4, 2024 19:06
@cpaulgilman cpaulgilman added the added to release notes PR and/or issue has been added to release notes for a public release label Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

added to release notes PR and/or issue has been added to release notes for a public release enhancement new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compare Cases Macro

3 participants