- Posts: 3
Discrepancy in NPV and total installed cost between SAM and PySAM
- Seif
- Topic Author
Less
More
07 Feb 2025 14:26 #13855
by Seif
Discrepancy in NPV and total installed cost between SAM and PySAM was created by Seif
Hello, I have a PySAM model that's giving me a bit of a hard time.
this code gives an NPV of +29k, and a total installed cost of 948k
If I take the same inputs to SAM, i.e. same hourly load distribution and a nameplate capacity of 446kWdc calculated in the code, using the Distributed Commercial Owner PVWatts model, I get very different values: NPV of +51k, and total installed cost of 783k.
The Ottawa weather file I'm using is the one you can download from the NREL website, but I attached it for convenience alongside the hourly electricity csv and the SAM file I used. I kept pretty much everything at default values. I'm also using version 6.0.0 of pySAM and the newest version of SAM (2024.12.12)
any help?
Code:
import os
import pandas as pd
import PySAM.Pvwattsv8 as pv
import PySAM.Grid as gr
import PySAM.Utilityrate5 as ur
import PySAM.Cashloan as co
import numpy as np
# Load the base load profile
base_load_profile_filename = "BaseCaseElectricity.csv"
base_load_profile = pd.read_csv(base_load_profile_filename).values.flatten()
daily_load_kWh = base_load_profile.sum() / 365
# Initialize PySAM models
system_model = pv.default("PVWattsCommercial")
grid_model = gr.from_existing(system_model, "PVWattsCommercial")
utilityrate_model = ur.from_existing(system_model, "PVWattsCommercial")
financial_model = co.from_existing(system_model, "PVWattsCommercial")
# Load weather file
weather_file = "ottawa_45.4218_-75.6912_psm3-2-2_60_2006.csv"
system_model.SolarResource.solar_resource_file = weather_file
# Set Nameplate Capacity, this gives 446 kWdc
efficiency = 0.96 # Inverter efficiency
PSH = 3.76 # Peak Sun Hours
dc_ac = 1.15 # DC to AC ratio
nameplate_capacity = dc_ac * (daily_load_kWh / (PSH * efficiency))
system_model.SystemDesign.system_capacity = nameplate_capacity
# Run the PySAM models
system_model.execute()
grid_model.execute()
utilityrate_model.execute()
financial_model.execute()
If I take the same inputs to SAM, i.e. same hourly load distribution and a nameplate capacity of 446kWdc calculated in the code, using the Distributed Commercial Owner PVWatts model, I get very different values: NPV of +51k, and total installed cost of 783k.
The Ottawa weather file I'm using is the one you can download from the NREL website, but I attached it for convenience alongside the hourly electricity csv and the SAM file I used. I kept pretty much everything at default values. I'm also using version 6.0.0 of pySAM and the newest version of SAM (2024.12.12)
any help?
Attachments:
Please Log in or Create an account to join the conversation.
- Paul Gilman
Less
More
- Posts: 5490
10 Feb 2025 16:56 #13859
by Paul Gilman
Replied by Paul Gilman on topic Discrepancy in NPV and total installed cost between SAM and PySAM
Hi Seif,
You found a tricky part of comparing SAM and PySAM results.
The main issue is that the total installed cost in SAM is calculated by code in the user interface that is not part of PySAM. One way to fix this problem is to use the module cost input on the Installation Costs page in SAM to specify the total installed cost in $/Wdc. This requires setting all of the other inputs on the Installation Costs page to zero. For example here I set the total installed cost to $1.76 W/dc so that the input and the blue calculated value are the same:
Then, in your Python script, you'll want to set the total installed cost:
financial_model.SystemCosts.total_installed_cost = nameplate_capacity * 1000 * 1.76
I also think you may have forgotten to set the load data in your script. To do that:
utilityrate_model.Load.load = base_load_profile
Attached is a modified version of your script that sets these values and also prints some helpful outputs that you can use to compare to the cash flow in SAM.
Best regards,
Paul.
You found a tricky part of comparing SAM and PySAM results.
The main issue is that the total installed cost in SAM is calculated by code in the user interface that is not part of PySAM. One way to fix this problem is to use the module cost input on the Installation Costs page in SAM to specify the total installed cost in $/Wdc. This requires setting all of the other inputs on the Installation Costs page to zero. For example here I set the total installed cost to $1.76 W/dc so that the input and the blue calculated value are the same:
Then, in your Python script, you'll want to set the total installed cost:
financial_model.SystemCosts.total_installed_cost = nameplate_capacity * 1000 * 1.76
I also think you may have forgotten to set the load data in your script. To do that:
utilityrate_model.Load.load = base_load_profile
Attached is a modified version of your script that sets these values and also prints some helpful outputs that you can use to compare to the cash flow in SAM.
Best regards,
Paul.
Attachments:
Please Log in or Create an account to join the conversation.
Moderators: Paul Gilman