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
Sg2 implementation #1013
Sg2 implementation #1013
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI @kandersolar from our previous discussions we are finding significant speed up from the SG2 modifications to SPA. |
Thanks for the heads up @mjprilliman! Of course it would be a much bigger job than merely dropping in a new algorithm under the hood, but rather than replacing the SPA, would it be worthwhile to implement both SPA and SG2 and allow the user to choose which one is used? (it's easy for me to make suggestions, as someone that doesn't have to put in the work to make it happen 😄) |
That may be something we consider in the future, right now we needed a solution that could go out a bit quicker. In reading SG2 it is essentially SPA modified in ~4 places from the original SPA algorithm so we'd have to weigh the workload versus potential optionality of allowing for both. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I ran some simulation run time tests for PVWatts, Detailed PV and Physical Trough in both SAM and SDKtool with results here:
simulation-runtime-results.zip
pvwattsv8 runs twice as fast with SG2 than SPA on my Windows 11 laptop with average run times of 374 ms for SPA and 174 ms for SG2.
Interesting. When @sjanzou ran comparisons for pvwattsv5 (to compare back to before original SPA was implemented) we were seeing ~3x speed increase. Hopefully 2x speed up still works for pvwattsv8 usage? |
I just ran tests comparing pvwattsv5 in SSC 279 (SPA) and SSC 280 (SG2) and see similar results to Steve's: 297 ms vs 87 ms. SSC 242 (pre-SPA) is 55 ms. The PVWatts API team will probably want to do some tests on pvwattsv8 with SG2 to see how this affects the API run times -- I know they are working on some changes to the API to speed things up as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good and great that @cpaulgilman got similar speed up results and all ssc tests pass.
-Attempt to speed up SPA implementation by integrating equations from SG2 algorithm
-Paper: https://www.sciencedirect.com/science/article/pii/S0038092X12002800
-Github: https://github.com/gschwind/sg2/tree/main/src
-Replaces const static 3D arrays of values with single line approximations to speed up runtime
-Does not replace Greenwich mean sidereal time (v0) calculation as I haven't figured out the conversion (in lib_irradproc.cpp):
-ToDo: update test results (changes on the order of 1e-4)
-ToDo: remove unused commented code