We will be performing a major infrastructure and web site ugprades on Friday, September 27th 8:00 am - 5:00 pm MST (UTC -7).

The website will be down during that time.

Generate Code Files Independent vs. Dependent Variables

  • hebush
  • Topic Author
More
15 Dec 2021 00:16 #10396 by hebush
I am attempting to generate code files (MATLAB) for CSP and PV + battery storage base module simulations so that a user may run versions of those models in a "coupled" manner, i.e. keeping the base input values for most variables but programmatically varying others based on certain scenarios and relationships of CSP + PV + battery systems.

In the SAM application, certain variables are independent and therefore have editable fields, while others are dependent variables calculated from a combination of independent entries and are therefore not editable. I have noticed that variables of both types seem to exist in the calls to the "ssccall" function in the generated .m file. E.g. (from the PV model):
ssccall('data_set_number', data, 'batt_power_discharge_max_kwdc', 999.9993896484375);
 ssccall('data_set_number', data, 'batt_power_charge_max_kwac', 1041.666015625);
 ssccall('data_set_number', data, 'batt_power_discharge_max_kwac', 959.9993896484375);
My question is: are the functional relationships set at the GUI level for SAM or at the deeper calculation level? Is it possible to edit these input code files in a way that breaks the intended relationship? E.g.
ssccall('data_set_number', data, 'batt_power_discharge_max_kwdc', user_defined_value);
ssccall('data_set_number', data, 'batt_power_charge_max_kwac', 1041.666015625);
ssccall('data_set_number', data, 'batt_power_discharge_max_kwac', 959.9993896484375);
If I modified the script to allow the user to set the battery size via "user_defined_value" would SAM still enforce the AC-DC conversion efficiency relationship defined elsewhere or would it introduce an inconsistency?

Please Log in or Create an account to join the conversation.

  • pgilman
More
16 Dec 2021 01:09 #10403 by pgilman
Hi Evan,

In short, yes, your example could introduce an inconsistency.

For this discussion, I will use "SAM" for the code of the desktop application's user interface, and "SSC" for the code of the underlying models. These are two separate code repositories that you can see on GitHub at github.com/NREL/sam and github.com/NREL/ssc.

Many SAM inputs are also SSC inputs. For example, for the battery model, SAM's "Cell nominal voltage" is SSC's 'batt_Vnom_default'. Changing that value would not risk introducing an inconsistency.

For other inputs, SAM calculates the value of the SSC input from a different SAM input. For example, how SAM calculates the value of  'batt_power_discharge_max_kwdc' depends on the units you choose for "Desired bank power" (an input in SAM but not SSC) and whether the battery is AC- or DC-connected. The equations for the DC maximum discharge power happen to be described in SAM's Help system, but that is not true for all of these kinds of calculated inputs.

In the example you provide, the value of 'batt_power_charge_max_kwac' depends on the value of 'batt_power_discharge_max_kwdc', so if the latter is a user input, you would either have to write code to calculate the former, or make both user inputs and rely on the user toe keep them consistent.

The SAM code (written in SAM's LK script language) for those particular inputs is here:

github.com/NREL/SAM/blob/465aff8023873724daed1cec141eb06576850224/deploy/runtime/ui/Battery%20Current%20and%20Capacity.txt#L2443

The files for these user interface calculations are in this folder:

github.com/NREL/SAM/tree/develop/deploy/runtime/ui

Best regards,
Paul.

Please Log in or Create an account to join the conversation.

Moderators: pgilman
Powered by Kunena Forum