Variable from JSON for PySAM not being read

  • REFOSSENTHUSIAST
  • Topic Author
More
09 Jan 2023 03:29 #11811 by REFOSSENTHUSIAST
Variable from JSON for PySAM not being read was created by REFOSSENTHUSIAST
 
Hello,

File Attachment:

File Name: SAM to zip.zip
File Size:10 KB

As usual, thanks to NREL for this great tool.

I'm having trouble using Pvsamv1 model in PySAM. I'm basically trying to load a SAM GUI configuration using the PySAM JSON export and generate the annual hourly generation from a whole series of weather files. I was able to do this successfully for a wind model, but it's not working for my solar model. The code doesn't seem to be able to read the variable 'system_capacity' from the JSON, despite me being able to see it in the file.

I have loaded my python code showing both the working wind code and the not working PV code. And the JSON file I'm using as an input for the PV model.

Apologies for the basic question and thanks in advance for the help.

Best regards,
Henry

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

  • pgilman
More
10 Jan 2023 11:14 - 10 Jan 2023 11:18 #11822 by pgilman
Replied by pgilman on topic Variable from JSON for PySAM not being read
Hi Henry,

The 'system_capacity' input to the pvsamv1 module is an example of an interdependent variable.

In the pvsamv1 documentation, you can see a list of variables on which 'system_capacity' depends:

nrel-pysam.readthedocs.io/en/master/modules/Pvsamv1.html#PySAM.Pvsamv1.Pvsamv1.SystemDesign.system_capacity .

See the section on interdependent variables for more information:

nrel-pysam.readthedocs.io/en/master/interdependent-variables.html

However, I think the problem in your script is with the way you are importing modules from PySAM. For the wind model you have:
Code:
PySAM.Windpower as WindPower

And, then, later on:
Code:
gs_dat = dict_to_ssc_table(dic, "WindPower") Windmodel = WindPower.wrap(gs_dat)

But for the PV model:
Code:
import PySAM.Pvsamv1 as pv1

And, then:
Code:
PVmodel_dat = dict_to_ssc_table(dic, "FlatPlatePVNone") gridmodel_dat = dict_to_ssc_table(dic, "grid") PVmodel = pv1.wrap(PVmodel_dat) gridmodel = grid.wrap(gridmodel_dat)

It doesn't look like the pvsamv1 inputs are getting loaded properly. I think your call to dict_to_ssc_table() here should use 'pv1' instead of 'FlatPlatePVNone' as a parameter.

It might be easier to use the one of the methods described here to import your inputs from json instead of dict_to_ssc_table():

nrel-pysam.readthedocs.io/en/master/inputs-from-sam.html

If that information does not help, and you would like me to help troubleshoot, please attach minimal code along with a weather file that causes the error you are trying to fix.

Best regards,
Paul.

 
Last edit: 10 Jan 2023 11:18 by pgilman.

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

  • REFOSSENTHUSIAST
  • Topic Author
More
17 Jan 2023 23:52 #11838 by REFOSSENTHUSIAST
Replied by REFOSSENTHUSIAST on topic Variable from JSON for PySAM not being read
Hi Paul,Thank you for your quick response. I took my time as I wanted to fix the error. Alas, it was not to be.I've attached the minimum code, JSON and resource file. I replaced the dict_to_ssc method with the 'for m in modules' method found in the link you shared ( nrel-pysam.readthedocs.io/en/master/inputs-from-sam.html ). Unfortunately I now get the error 'AttributeError: 'value' error, could not find attribute: use_spatial_albedos' even though it is in the json (as 0).It would be very helpful if you could please review and check.On an additional note, in the code samples in the link above, the suggested code for the 'JSON for inputs' method is the same as the PySAM JSON method. Is that correct?Best regards,Henry
Attachments:

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

  • pgilman
More
18 Jan 2023 16:49 #11839 by pgilman
Replied by pgilman on topic Variable from JSON for PySAM not being read
Hi Henry,

See the attached Jupyter notebook and supporting files. My changes are marked with "#cpg", so you can search for those.

There were two problems with this once I removed file paths pointing to files outside of this collection of files:

1. The pvsamv1 JSON file sets subarray1_rotlim = 90, but the maximum allowed value is 85. I set the rotation limit to 85 in Python, but if you remove that you will see a pvsamv1 simulation error telling you about that.

2. The weather file path was being loaded from the pvsamv1 JSON file. After loading the inputs from the JSON file, you need to set solar_resource_file to the weather file path -- you can see how I did that.

Best regards,
Paul.
Attachments:

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

Moderators: pgilman
Powered by Kunena Forum