- Posts: 5422
Pvsamv1 CEC Performance Model with User Entered Specifications Option and PySAM
- pgilman
- Topic Author
Less
More
13 Nov 2024 17:16 - 13 Nov 2024 17:19 #13594
by pgilman
Pvsamv1 CEC Performance Model with User Entered Specifications Option and PySAM was created by pgilman
When you use SAM's
code generator
with the "PySAM JSON" option, it generates two JSON files: One with the case name, such as "untitled.json" and one with the case name and "_pvsamv1" appended, such as "untilted_pvsamv1.json". The latter file uses 'sixpar_' as required by PySAM, and indicated in the documentation of the
Pvsamv1 user-specified module parameters variables
.
Here's a Python script you can use to test that. First, in SAM, create a default Detailed PV / No Financial case, and then go to the Module page and choose the CEC Performance Model with User Entered Specifications option from the blue list at the top of the page. Then, on the Case menu, click Generate code, PySAM JSON.
Best regards,
Paul.
Here's a Python script you can use to test that. First, in SAM, create a default Detailed PV / No Financial case, and then go to the Module page and choose the CEC Performance Model with User Entered Specifications option from the blue list at the top of the page. Then, on the Case menu, click Generate code, PySAM JSON.
Code:
import json
import PySAM.Pvsamv1 as PV
# create a new pvsamv1 model
pv = PV.new()
# assign inputs from JSON generated by SAM
with open("untitled_pvsamv1.json", "r") as file:
data = json.load(file)
# loop through each key-value pair
for k, v in data.items():
if 'adjust_' in k: # workaround for https://github.com/NREL/pysam/issues/164
k = k.replace('adjust_', '')
if k != "number_inputs":
pv.value(k, v)
# print inputs for user-specified module parameters option to verify "sixpar" in variable names
print(pv.CECPerformanceModelWithUserEnteredSpecifications.export())
# run pvsamv1 for no bifacial
pv.execute()
# print some results
print(pv.value("annual_dc_net"))
print(pv.value("annual_ac_gross"))
# change user-specified module bifacial parameter
pv.value("sixpar_is_bifacial", 1)
# print inputs to confirm bifacial mode is enabled
print(pv.CECPerformanceModelWithUserEnteredSpecifications.export())
# run pvsamv1 for bifacial
pv.execute()
# print results -- should be higher than non-bifacial
print(pv.value("annual_dc_net"))
print(pv.value("annual_ac_gross"))
Best regards,
Paul.
Last edit: 13 Nov 2024 17:19 by pgilman.
Please Log in or Create an account to join the conversation.
Moderators: pgilman