- Posts: 1
AC System Capacity Concern and General Coding Advice in PySAM
- Taylor Parsons
- Topic Author
Less
More
24 Apr 2025 20:55 #14003
by Taylor Parsons
AC System Capacity Concern and General Coding Advice in PySAM was created 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!
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
Less
More
- Posts: 5760
25 Apr 2025 09:44 #14006
by Paul Gilman
Replied by Paul Gilman on topic AC System Capacity Concern and General Coding Advice in PySAM
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.
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.
- rajeesh nre
Less
More
- Posts: 1
25 Sep 2026 04:55 - 25 Sep 2026 14:51 #14602
by rajeesh nre
Replied by rajeesh nre on topic AC System Capacity Concern and General Coding Advice in PySAM
I think the issue is that 'system_capacity_ac' in PySAM isn't simply calculated from 'inverter_unit_capacity * inverter_count'. SAM derives the AC system capacity from the inverter and PV configuration, so some of the subarray/inverter inputs can affect what you see after 'execute()'. One thing I would check first is the relationship between 'inverter_count', 'inv_pd_paco', and the inverter model. In particular, setting 'inverter_model = 0' and then manually assigning 'inv_pd_paco/inv_pd_eff' may not be doing what you expect, depending on the Pvsamv1 configuration/template you're using. The CEC module selection and the number of modules/strings can also cause SAM to recalculate the effective system capacity. I would recommend printing the relevant values immediately before and after 'execute()':
print("system_capacity:", sim.SystemDesign.system_capacity)
print("inverter_count:", sim.SystemDesign.inverter_count)
print("inv_pd_paco:", sim.Inverter.inv_pd_paco)
print("inverter_model:", sim.Inverter.inverter_model)
print("modules/string:", sim.SystemDesign.subarray1_modules_per_string)
print("strings:", sim.SystemDesign.subarray1_nstrings)
Also, I wouldn't rely on 'dc_ac_ratio' alone to define the AC capacity. In SAM, the DC/AC ratio is generally a consequence of the DC array size and inverter configuration rather than an independent value that forces 'system_capacity_ac' to equal 'DC / ratio'. The '40115.04 kW' value is especially large compared with your 2,804 kW DC array, so I'd suspect an inverter/array sizing inconsistency rather than a normal clipping-related result. Checking the effective number of modules, strings, inverter units, and inverter rated power after the model is configured should help identify where that number is coming from. For your actual goal—estimating sub-hourly clipping percentage—you probably don't need a highly detailed or perfectly calibrated SAM model. What matters is getting the DC array size, inverter AC rating, module electrical characteristics, inverter efficiency/curve, and weather/time resolution reasonably representative. Once those are consistent, you can calculate clipping as a percentage of potential DC production rather than worrying about matching the absolute annual energy exactly. I'd also try starting from a known-working Pvsamv1 SAM example with a single subarray and then changing only the weather data, module, DC size, and inverter configuration. That makes it much easier to identify which input is causing SAM to recalculate the capacity.
print("system_capacity:", sim.SystemDesign.system_capacity)
print("inverter_count:", sim.SystemDesign.inverter_count)
print("inv_pd_paco:", sim.Inverter.inv_pd_paco)
print("inverter_model:", sim.Inverter.inverter_model)
print("modules/string:", sim.SystemDesign.subarray1_modules_per_string)
print("strings:", sim.SystemDesign.subarray1_nstrings)
Also, I wouldn't rely on 'dc_ac_ratio' alone to define the AC capacity. In SAM, the DC/AC ratio is generally a consequence of the DC array size and inverter configuration rather than an independent value that forces 'system_capacity_ac' to equal 'DC / ratio'. The '40115.04 kW' value is especially large compared with your 2,804 kW DC array, so I'd suspect an inverter/array sizing inconsistency rather than a normal clipping-related result. Checking the effective number of modules, strings, inverter units, and inverter rated power after the model is configured should help identify where that number is coming from. For your actual goal—estimating sub-hourly clipping percentage—you probably don't need a highly detailed or perfectly calibrated SAM model. What matters is getting the DC array size, inverter AC rating, module electrical characteristics, inverter efficiency/curve, and weather/time resolution reasonably representative. Once those are consistent, you can calculate clipping as a percentage of potential DC production rather than worrying about matching the absolute annual energy exactly. I'd also try starting from a known-working Pvsamv1 SAM example with a single subarray and then changing only the weather data, module, DC size, and inverter configuration. That makes it much easier to identify which input is causing SAM to recalculate the capacity.
Last edit: 25 Sep 2026 14:51 by Paul Gilman.
Please Log in or Create an account to join the conversation.
Moderators: Paul Gilman




