LCOE Output from pySAM iteration different from SAM GUI

  • Adam Gallaher
  • Topic Author
More
22 Aug 2022 23:06 #11376 by Adam Gallaher
Hello Paul, 

Thank you for this, I have been able to replicate the runs for individual files. I am working on iterating a list of sites where I change a single JSON file based on nameplate capacity (for now). Currently, my code stops after one iteration with error. What would the code you provided look like if it was designed to iterate over a file? Attached is what I have so far. 

All the best, 

Adam

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

  • Paul Gilman
More
23 Aug 2022 16:56 #11377 by Paul Gilman
Hi Adam,

You could try loading the inputs from the JSON file, and then iterating over your inputs of interest:
Load inputs from JSON files
For each weather file:
   Set solar_resource_file
   For each system size:
       Set system_capacity
       Execute all modules
       Get results

I omitted the module and group names from the input variables. For example, for solar_resource_file, you would use system_model.SolarResource.solar_resource_file.

Best regards,
Paul.

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

  • Adam Gallaher
  • Topic Author
More
24 Aug 2022 13:01 #11379 by Adam Gallaher
Hello Paul, 

Thank you for your help, I just needed to reorganize a few lines of code and I was able to get it to run. I've attached my code for your reference. 

All the best, 

Adam 

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

  • Paul Gilman
More
24 Aug 2022 18:18 #11383 by Paul Gilman
Hi Adam,

There is another consideration when you are comparing results from the SAM desktop application with PySAM results.

SAM and PySAM both interface with the same SAM Simulation Core (SSC) library. SAM's user interface has internal code that calculates the value of several SSC inputs. These "calculated values" appear in blue on the input pages. You cannot edit these values directly. For example, on the Installation Costs page for the PVWatts model, you cannot edit the total installed cost value directly because SAM calculates it from the cost categories for module, inverter, land purchase, etc. When you use the code generator to create the JSON for PySAM files, SAM sets the SSC input total_installed_cost to the calculated value from the SAM user interface.

In SAM, when you change the nameplate capacity on the System Design page, the total installed cost on the Installation Costs page changes. In PySAM, when you change the value of system_capacity, you have to also recalculate the value of total_installed_cost in your Python script. One way to make it easier to make your Python script consistent with SAM is to set all of the cost categories on the Installation Costs page in SAM to zero except for the module $/Wdc cost category, which you can use to represent the total system cost. Then when you export the inputs to JSON for PySAM to use in your Python script, if you modify the system capacity, you can recalculate total installed cost ($) = module cost ($/Wdc) * system capacity (kW) * 1000 W/kW.

For the Single Owner financial model, there several inputs that depend on the nameplate capacity in addition to the total installed cost. The easiest way to remove these dependencies is to set these inputs to zero and account for their cost in the total installed cost that you calculate in your Python code. These inputs are:
  • Sales tax
  • Up-front fee (for project term debt)
  • Percent of installed cost (for all 5 possible construction period loans)
The attached .sam and .py files demonstrate this approach for  a PVWatts / Single Owner case. You can use a similar approach for other models.

To use these files:
  1. Download the pvwatts-singleowner-for-pysam.sam and pvwattsv8-single-owner-from-sam.py files and put them in an empty folder.
  2. Start SAM and open the .sam file you just downloaded.
  3. Note the inputs on the Installation Costs and Financial Parameters input pages.
  4. On the Case menu, click Generate code, and choose PySAM JSON at the bottom of the list. Save the JSON files to the same folder as the .sam and .py files.
  5. Run the Python script.
The "Input Consistency Warning" in the PySAM documentation for each compute module attempts to explain this issue. For example, the Single Owner documentation is here: nrel-pysam.readthedocs.io/en/master/modules/Singleowner.html. The documentation for each input also lists other inputs that depend on its value, for example the construction_financing_cost description on that page. We are in the process of revising the documentation to make this clearer.

Best regards,
Paul.

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

  • Adam Gallaher
  • Topic Author
More
24 Aug 2022 22:26 #11386 by Adam Gallaher
Hello Paul, 

Thank you for catching this and for providing a solution to resolve it. One thing I noticed was that you made your changes using the modules such as financial_model.SystemCosts.total_installed_cost = capacity * cost * 1000. I am curious to know if this is the better approach to changing the values in the JSON file like what I had done previously. I assume they achieve the same result but I am unsure if one is ideal to the other. 

All the best, 

Adam 

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

  • Adam Gallaher
  • Topic Author
More
25 Aug 2022 14:54 #11389 by Adam Gallaher
Hello Paul, 

Thank you for providing this information, I would not have known otherwise. I've altered my script to accept the changes you provided and after following the steps my results from pySAM and SAM are identical. 

Thank you again for your help with this. 

Adam

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

Moderators: Paul Gilman
Powered by Kunena Forum