Annual Energy Output for all years in VBA Code

  • pgilman
More
21 Dec 2021 14:14 #10430 by pgilman
Hi Soheb,

When you use SAM's Code Generator to generate VBA code (or code in any other language) it includes a few lines to display the values of some output variables as an example. It's up to you to write code to work with other output variables.

You could use the information in the cashflow.lk as a reference to write a VBA program to build your own cash flow table.

One way to identify the names of both input and output variables is to use SAM's LK script editor to list the variables. The variables browser shows both the variable label that you see in the user interface and the variable name. In SAM, on the File menu, click New script, and then click Variables at the top of the script editor window. For example, you could use it to find that "Electricity to grid" is year1_hourly_e_togrid:



Best regards,
Paul.

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

  • msohebzaidi
  • Topic Author
More
22 Dec 2021 22:20 - 30 Dec 2021 16:40 #10435 by msohebzaidi
Replied by msohebzaidi on topic Annual Energy Output for all years in VBA Code
Hi Paul,
The cash flow suggestion makes sense. However, when I try to output system to grid data for the life time of the project, its just getting me a number and not an array or matrix! 

Kindly look at the last line of the code and the result in the immediate window. How can I get the output for the system_to_load for 1 year but in hourly time step.
I have tried chaging the VBASSCDataGetNumber to VBASSCDataGetArray or VBASSCDataGetMatrix   but it says compile error : Argument not optional.

Please help!

Thanks Paul.

Last edit: 30 Dec 2021 16:40 by pgilman.

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

  • msohebzaidi
  • Topic Author
More
23 Dec 2021 22:44 #10437 by msohebzaidi
Replied by msohebzaidi on topic Annual Energy Output for all years in VBA Code
Hi Paul,

As you mentioned, applying degradation to rest of the year will give us accurate results for PV only type of system, as PV degrades uniformly over time. However, when we are dealing with PV + Battery system, how do we accurately assume degradation of the battery bank, as the degradation is not uniform and is dependent on the no. of cycles it undergoes....in my scenario we are dispatch battery in merchant model using the electricity prices.....so how will be get annual energy for the rest of the years and what will be the degradation % we would have to assume?

Regards

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

  • pgilman
More
30 Dec 2021 16:58 - 30 Dec 2021 17:00 #10452 by pgilman
Hi Soheb,

SAM has a separate battery life model that calculates the degradation in battery capacity over time that accounts for number of charge/discharge cycles, depth of discharge, battery temperature, and battery age, so you do not need to specify a degradation rate input to account for the battery.

The "Battery relative capacity to nameplate" (batt_capacity_percent) variable indicates the battery degradation over time. Note that this is a time series variable with a value for each time step. If you include battery replacements in your analysis, the battery capacity is restored to its nameplate value when the battery is replaced.

The time series "Electricity to grid" and "Electricity to grid from battery" outputs are (year1_hourly_e_togrid and batt_to_grid, respectively).

One way to find the names of SSC variables is to first find them on the Data Tables tab in SAM, and then open a script editor and use the script editor's variable browser to match the SAM variable name to the SSC name:

  1. Start SAM and open a file or create a new one.
  2. On the File menu, click New script to open the script editor.
  3. Click Variables in the menu bar at the top of the script editor.
  4. In the Search box, type the name of the variable label as you see it in SAM (for example "Electricity to grid from battery").
  5. Find the variable in the list -- variables are sorted by inputs and outputs and by type, and get the equivalent SSC Variable name (for example batt_to_grid).



Best regards,
Paul.
Last edit: 30 Dec 2021 17:00 by pgilman.

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

  • msohebzaidi
  • Topic Author
More
02 Jan 2022 21:34 - 03 Jan 2022 21:33 #10460 by msohebzaidi
Replied by msohebzaidi on topic Annual Energy Output for all years in VBA Code
Hi Paul,

Thanks for your feedback...What you have mentioned is something I already know. Perhaps, I am looking for a more developer level of a answer to my questions. I want to see how these variables can be extracted via the VBA code....do you have any written material from SAM which could guide me how to extract annual hourly values, or perhaps lifetime hourly values, by modifying the VBA code generated by SAM?

Currently, if I apply the steps what you have guided me through, this is what I am getting (Photo attached).

Given that system_to_grid is a lifetime hourly data, it only shows one number and is equal to 0.

Thanks Again Paul!
Last edit: 03 Jan 2022 21:33 by msohebzaidi. Reason: Error in image copied

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

  • pgilman
More
03 Jan 2022 16:57 #10467 by pgilman
Hi Soheb,

Please attach image files to your posts instead of copying and pasting them into your message, or describe the results you are getting in words. As you can see, pasted images to not always render correctly.

Best regards,
Paul.

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

Moderators: pgilman
Powered by Kunena Forum