- Posts: 19
LCOE Output from pySAM iteration different from SAM GUI
- galla1ab
- Topic Author
Less
More
22 Aug 2022 17:06 #11376
by galla1ab
Replied by galla1ab on topic LCOE Output from pySAM iteration different from SAM GUI
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
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
Attachments:
Please Log in or Create an account to join the conversation.
- pgilman
Less
More
- Posts: 5447
23 Aug 2022 10:56 #11377
by pgilman
Replied by pgilman on topic LCOE Output from pySAM iteration different from SAM GUI
Hi Adam,
You could try loading the inputs from the JSON file, and then iterating over your inputs of interest:
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.
You could try loading the inputs from the JSON file, and then iterating over your inputs of interest:
Code:
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.
- galla1ab
- Topic Author
Less
More
- Posts: 19
24 Aug 2022 07:01 #11379
by galla1ab
Replied by galla1ab on topic LCOE Output from pySAM iteration different from SAM GUI
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
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
Attachments:
Please Log in or Create an account to join the conversation.
- pgilman
Less
More
- Posts: 5447
24 Aug 2022 12:18 #11383
by pgilman
Replied by pgilman on topic LCOE Output from pySAM iteration different from SAM GUI
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:
To use these files:
Best regards,
Paul.
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)
To use these files:
- Download the pvwatts-singleowner-for-pysam.sam and pvwattsv8-single-owner-from-sam.py files and put them in an empty folder.
- Start SAM and open the .sam file you just downloaded.
- Note the inputs on the Installation Costs and Financial Parameters input pages.
- 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.
- Run the Python script.
Best regards,
Paul.
Attachments:
Please Log in or Create an account to join the conversation.
- galla1ab
- Topic Author
Less
More
- Posts: 19
24 Aug 2022 16:26 #11386
by galla1ab
Replied by galla1ab on topic LCOE Output from pySAM iteration different from SAM GUI
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
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.
- galla1ab
- Topic Author
Less
More
- Posts: 19
25 Aug 2022 08:54 #11389
by galla1ab
Replied by galla1ab on topic LCOE Output from pySAM iteration different from SAM GUI
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
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: pgilman