NREL / SAM

System Advisor Model (SAM)
BSD 3-Clause "New" or "Revised" License
318 stars 136 forks source link

Address SAM issue #1634 with ssc_auto_exec #1801

Closed sjanzou closed 1 week ago

sjanzou commented 2 weeks ago

The fundamental issue for the ssc_auto_exec in the EqnDatabase is that the EqnDatabase is constructed at load up on a page by page basis and has no idea on which UI variables will be available in whatever configuration the page is used. The ssc_auto_exec was constructed to avoid having to manually set each variable when the compute module referenced was called. Initially, any variables that were not to be set by the ssc_auto_exec function were designated by the UIHINT=”SIMULATION_PARAMETER” which is still in effect.

For SAM issue 1634, there is no way for ssc_auto_exec to have the same functionality as clicking the Simulate button in the UI. This is because ssc_auto_exec in constructed at page loadup when SAM starts and has no concept of a case or a configuration. That is, the list of UI variables is not available when the ssc_auto_exec function is evaluated.

To address SAM issue 1634 as much as possible, no UI variable will be used for any ssc variable that has the “REQUIRED_IF=*”. If the ssc variable is not required or has a default or a different REQUIRED_IF value, then ssc_auto_exec will skip the assignment to a UI variable.

Tested with add-temp-mspt_cmod_var branch of ssc - no equation errors image

sjanzou commented 2 weeks ago

@tyneises, can you take a look at the failing MSLF configurations?

sjanzou commented 2 weeks ago

MSLF configurations fail because REQUIRED_IF is not set for all required variables. add-temp-mspt_cmod_var and patch branch work fine for MSPT configurations. image

sjanzou commented 1 week ago

Added fcall_var_exists to facilitate desired functionality of #1634

Working and running for add-temp-mspt_cmod_var and patch branches of ssc as requested.

@tyneises, @taylorbrown75 please review and let me know if you have any questions.

sjanzou commented 1 week ago

Logic is clear and works well. I produced the following table showing performance depending on required_if type and whether the variable is defined in the UI. Works as described.

image

Seems we can stop using SIMULATION_PARAMETER? Conditional required_if works with sim_type. (i.e. use REQUIRED_IF="sim_type=1")

@taylorbrown75 thanks for the detailed review! @tyneises can we get stop using SIMULATION_PARAMETER as @taylorbrown75 suggests?