AC System Capacity Concern and General Coding Advice in PySAM

  • Taylor Parsons
  • Topic Author
More
24 Apr 2025 20:55 #14003 by Taylor Parsons
Hello - [If at all possible, this is for an urgent project so I appreciate any quick help someone can give me!]

I'm trying to run an energy model in PySAM.Pvsamv1 with basic site inputs, with the goal of calculating a sub-hourly clipping loss value from a TMY, and I am troubleshooting some nonsensical results. While troubleshooting, I'm finding that Outputs.system_capacity_ac is not as expected. Here is what I am doing to define the model, after I've imported my resource data and defined variables such as dc_capacity as user inputs:

# 1) Instantiate with a full PV template
sim = Pvsam.default("FlatPlatePVNone")

# 2) Load weather & time via solar_resource_data
times = df.index
sim.value("solar_resource_data", {
    "lat"    : latitude,
    "lon"    : longitude,
    "tz"     : tz,
    "elev"   : elevation,
    "year"   : times.year.tolist(),
    "month"  : times.month.tolist(),
    "day"    : times.day.tolist(),
    "hour"   : times.hour.tolist(),
    "minute" : times.minute.tolist(),
    "gh"     : ghi.tolist(),
    "dn"     : dni.tolist(),
    "df"     : dhi.tolist(),
    "tdry"   : temp.tolist(),
    "wspd"   : wind.tolist(),
})

# 3) System sizing
sim.SystemDesign.system_capacity = dc_capacity   # kW-dc
sim.dc_ac_ratio = dc_capacity / system_ac_capacity

print("dc: ",dc_capacity)
print("ac: ",system_ac_capacity)
print("ratio: ",sim.dc_ac_ratio)


# 4) Module selection via CEC database
# look up the 0-based index of your module
cec = retrieve_sam('CECMod')
module_list = list(cec.columns)
module_idx = module_list.index(module_string)
# tell PySAM which module index to use
sim.Module.module_model = module_idx
sim.value("module_model",  0)   # exact CEC string

# 5) Tell SAM how many inverters you have
sim.SystemDesign.assign({
    "inverter_count": inverter_count
})

# 6) Choose Sandia inverter and size it
sim.Inverter.assign({
    "inverter_model": 0,  
    "inv_pd_paco"  : inverter_unit_capacity,
    "inv_pd_eff"   : inverter_efficiency,
})

# 7) Configure single-subarray system
sim.SystemDesign.assign({
    "subarray1_track_mode"         : subarray1_track_mode,
    "subarray1_backtrack"          : int(subarray1_backtrack),
    "subarray1_gcr"                : subarray1_gcr,
    "subarray1_modules_per_string" : subarray1_modules_per_string,
    "subarray1_nstrings"           : subarray1_nstrings,
    "subarray1_slope_tilt"         : subarray1_slope_tilt,
    "subarray1_slope_azm"          : subarray1_slope_azm,
    "subarray1_tilt"               : subarray1_tilt,
    "subarray1_azimuth"            : subarray1_azimuth,
})

# 9) Execute
sim.execute()

Here are a few checks, which I'm comparing to the inputs:
print("dc: ",sim.value("system_capacity"))
print("inverter unit capacity * count: ",inverter_unit_capacity * inverter_count)
print("ac: ", sim.Outputs.system_capacity_ac)
print("ratio: ",sim.dc_ac_ratio)


What I'm finding is that the first set of print statements before executing the model all have the correct DC capacity, AC capacity, and ratio, but the last set of print statements, after the model is run, have everything correct except for the AC capacity. The printed values are as follows:dc: 2804.0
ac: 2000.0
ratio: 1.402
dc: 2804.0
inverter unit capacity * count: 2000.0
ac: 40115.04
ratio: 1.402I would expect the system_capacity_ac to reflect the inverter count * the inverter capacity, or the DC capacity * DC/AC ratio, but it's showing 40115.04 kW, and I'm not sure why. What is causing the AC capacity to be overwritten in the modeling, and how do I better define my inputs?

As you can tell, I'm trying to use just enough site inputs to give me a reasonably representative energy model, noting that all I truly need is a somewhat accurate sub-hourly clipping loss %. The actual gross energy, and the actual magnitude of the loss, does not matter as much as the % loss, which I'm feeding into another model. If there is a better way of setting up a simple model for this purpose, I'd love tips.

Thank you!

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

  • Paul Gilman
More
25 Apr 2025 09:44 #14006 by Paul Gilman
Hi Taylor,

Sizing the PV system for Pvsamv1 is tricky because there are interdependent variables whose values are not automatically checked. For example, 'system_capacity' depends on 'subarray1_nstrings' and 'subarray1_modules_per_string' among many other variables lised in the variable's documentation: nrel-pysam.readthedocs.io/en/main/modules/Pvsamv1.html#PySAM.Pvsamv1.Pvsamv1.SystemDesign.system_capacity .

That means that when you set the system capacity in Step 3, you need to make sure all of those variables have consistent values. To make things even trickier, some of the variables like '6par_imp' or 'batt_chem' may not apply to your specific configuration.

This PVsamv1Tools Jupyter notebook provides some tools to help with the PV sizing process: github.com/NREL/pysam/blob/main/Examples/PVsamv1Tools.ipynb

Best regards,
Paul.
 

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

Moderators: Paul Gilman
Powered by Kunena Forum