Pvwattsv8 results in SAM and PySAM

  • jbonilla
  • Topic Author
More
23 Jun 2023 12:22 #12247 by jbonilla
Pvwattsv8 results in SAM and PySAM was created by jbonilla
Hello,
I’m getting different results in SAM and PySAM. This is a nexample for Pvwattsv8 with my own custom weather file. I only changed in SAM the system capacity to 100 MW, I generate the code to PySAM JSON and import it in Python. This works fine, with minor differences.

SAM results
PySAM results
----------------------
PV capacity: 100.0 MW
PV power: 186,487,766 kWh
PV capacity factor: 21.3 %
PV LCOE nominal: 4.9 c$/kWh
 But when I change the system_capacity to 500 MW, I get quite different values for the LCOE nominal. SAM results
PySAM results
----------------------
PV capacity: 500.0 MW
PV power: 932,435,679 kWh
PV capacity factor: 21.3 %
PV LCOE nominal: 2.01 c$/kWh
This is the Python code.
import json
import PySAM.Grid as Grid
import PySAM.Pvwattsv8 as Pvwattsv8
import PySAM.Singleowner as Singleowner
import PySAM.Utilityrate5 as UtilityRate


def execute_modules(modules):
for m in modules:
m.execute()


def load_modules(path, file_names, modules, execute=False):
for f, m in zip(file_names, modules):
with open(f'{path}/{f}.json', 'r') as file:
data = json.load(file)
for k, v in data.items():
if k != "number_inputs":
m.value(k, v)
if execute:
execute_modules(modules)


def load_pv(path, file_names, execute=True) -> [Pvwattsv8, Grid, UtilityRate, Singleowner]:
pv = Pvwattsv8.new()
pv_grid = Grid.from_existing(pv)
pv_ur = UtilityRate.from_existing(pv)
pv_so = Singleowner.from_existing(pv)
modules = [pv, pv_grid, pv_ur, pv_so]
load_modules(path, file_names, modules, execute)
return modules


if __name__ == '__main__':
# PySAM JSON path and files
pv_path = '/home/javi/Documents/PycharmProjects/IDA_2023/data/PV_watt_json'
pv_file_names = ['untitled_pvwattsv8', 'untitled_grid', 'untitled_utilityrate5', 'untitled_singleowner']

# Load PV modules, execute and show results
[pv, pv_grid, pv_ur, pv_so] = load_pv(pv_path, pv_file_names)
print(f'PV capacity: {pv.value("system_capacity")/1000:,} MW')
print(f'PV power: {round(sum(pv.Outputs.gen)):,} kWh')
print(f'PV capacity factor: {round(pv.Outputs.capacity_factor, 1)} %')
print(f'PV LCOE nominal: {round(pv_so.Outputs.lcoe_nom, 2)} c$/kWh')
print('\n')

# Change capacity
capacity = 500 * 1000 # kW
pv.value('system_capacity', capacity)

# Execute and show results
execute_modules([pv, pv_grid, pv_ur, pv_so])
print(f'PV capacity: {pv.value("system_capacity")/1000:,} MW')
print(f'PV power: {round(sum(pv.Outputs.gen)):,} kWh')
print(f'PV capacity factor: {round(pv.Outputs.capacity_factor, 1)} %')
print(f'PV LCOE nominal: {round(pv_so.Outputs.lcoe_nom, 2)} c$/kWh')
Am I missing something in the Python code? Thanks.Best regards,
Javier.

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

  • pgilman
More
30 Jun 2023 15:13 #12268 by pgilman
Replied by pgilman on topic Pvwattsv8 results in SAM and PySAM
Hi Javier,

Please attach or post a copy of your Python script with correct indentation and a copy of the .sam file you are using for the comparison if you would like me to help troubleshoot.

Best regards,
Paul.

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

  • jbonilla
  • Topic Author
More
03 Jul 2023 11:48 #12271 by jbonilla
Replied by jbonilla on topic Pvwattsv8 results in SAM and PySAM
Hi Paul,

I provide a link where you can find the Python code, the SAM project and the weather CSV file, thanks.

Best regards,
Javier.

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

  • jbonilla
  • Topic Author
More
25 Jul 2023 07:13 #12348 by jbonilla
Replied by jbonilla on topic Pvwattsv8 results in SAM and PySAM
Hi Paul,

Did you have time to have a look at this? Thanks.

Best regards,
Javier.

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

  • pgilman
More
27 Jul 2023 21:19 #12355 by pgilman
Replied by pgilman on topic Pvwattsv8 results in SAM and PySAM
Hi Javier,

Thanks for the reminder.

I am getting the same results from PySAM 4.2.0 and SAM 2012.11.21 r3 SSC 280. It is possible the differences you are seeing are because the PySAM and SAM versions you are using are not consistent. To see what versions of SAM go with PySAM versions, go to the Releases list on GitHub: github.com/NREL/pysam/releases.

 

 

 

Best regards,
Paul.


 
Attachments:

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

  • jbonilla
  • Topic Author
More
28 Jul 2023 06:55 #12357 by jbonilla
Replied by jbonilla on topic Pvwattsv8 results in SAM and PySAM
Hi Paul,

Thanks for checking. I'm getting same results as yours. The issue is the nominal LCOE provided by SAM is 4.89 c$/kWh, whereas it's 2.01 c$/kWh in PySAM, for the 500 MW PV plant, The 100 MW PV plant yields the same results in SAM and PySAM.

Best regards,
Javier.

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

Moderators: pgilman
Powered by Kunena Forum