NREL / pysam

Python Wrapper for the System Advisor Model
http://nrel-pysam.readthedocs.io
BSD 3-Clause "New" or "Revised" License
108 stars 49 forks source link

pvsamv1 error: issue with subarray2 inputs when upgrading from 3.0.2 to 4.2.0 #155

Closed caseyzak24 closed 1 year ago

caseyzak24 commented 1 year ago

I recently upgraded from the latest 3.0.2 version to 4.2.0 and attempted to run a pvsamv1 model. Here is the result of model.export() prior to calling to calling model.execute(0):

{'AdjustmentFactors': {'constant': 1.0, 'dc_constant': 0.0},
 'BatteryCell': {},
 'BatteryDispatch': {},
 'BatterySystem': {},
 'CECPerformanceModelWithModuleDatabase': {'cec_a_ref': 1.800676,
                                           'cec_adjust': 4.027824,
                                           'cec_alpha_sc': 0.00338,
                                           'cec_area': 1.927,
                                           'cec_beta_oc': -0.142336,
                                           'cec_bifacial_ground_clearance_height': 1.0,
                                           'cec_bifacial_transmission_factor': 0.013,
                                           'cec_bifaciality': 0.65,
                                           'cec_gamma_r': -0.407,
                                           'cec_height': 0.0,
                                           'cec_i_l_ref': 9.314523,
                                           'cec_i_mp_ref': 8.8,
                                           'cec_i_o_ref': 7.86552e-11,
                                           'cec_i_sc_ref': 9.31,
                                           'cec_is_bifacial': 0.0,
                                           'cec_n_s': 72.0,
                                           'cec_r_s': 0.338902,
                                           'cec_r_sh_ref': 697.52477,
                                           'cec_standoff': 6.0,
                                           'cec_t_noct': 44.2,
                                           'cec_temp_corr_mode': 0.0,
                                           'cec_transient_thermal_model_unit_mass': 11.092,
                                           'cec_v_mp_ref': 37.5,
                                           'cec_v_oc_ref': 45.9},
 'CECPerformanceModelWithUserEnteredSpecifications': {},
 'ElectricityRates': {},
 'FuelCell': {},
 'GridLimits': {},
 'IEC61853SingleDiodeModel': {},
 'Inverter': {'inv_snl_paco': 2103416.0,
              'inverter_count': 7.0,
              'inverter_model': 0.0,
              'mppt_hi_inverter': 1200.0,
              'mppt_low_inverter': 849.0},
 'InverterCECCoefficientGenerator': {},
 'InverterCECDatabase': {'inv_snl_c0': -8.02696e-09,
                         'inv_snl_c1': 3.51398e-06,
                         'inv_snl_c2': 0.000145865,
                         'inv_snl_c3': 0.000486246,
                         'inv_snl_paco': 2103416.0,
                         'inv_snl_pdco': 2150050.0,
                         'inv_snl_pnt': 442.59,
                         'inv_snl_pso': 8719.83,
                         'inv_snl_vdcmax': 1200.0,
                         'inv_snl_vdco': 940.0,
                         'inv_tdc_cec_db': ((1.0, 52.8, -0.021),)},
 'InverterDatasheet': {},
 'InverterMermoudLejeuneModel': {},
 'InverterPartLoadCurve': {},
 'Layout': {'module_aspect_ratio': 1.7,
            'subarray1_mod_orient': 0.0,
            'subarray1_nmodx': 48.0,
            'subarray1_nmody': 1.0},
 'Lifetime': {'ac_lifetime_losses': (0.0,),
              'analysis_period': 1.0,
              'dc_degradation': (0.5,),
              'dc_lifetime_losses': (0.0,),
              'en_ac_lifetime_losses': 0.0,
              'en_dc_lifetime_losses': 0.0,
              'save_full_lifetime_variables': 1.0,
              'system_use_lifetime_output': 1.0},
 'Load': {},
 'Losses': {'acwiring_loss': 1.0,
            'calculate_bifacial_electrical_mismatch': 0.0,
            'calculate_rack_shading': 0.0,
            'dcoptimizer_loss': 0.0,
            'en_snow_model': 0.0,
            'subarray1_dcwiring_loss': 2.0,
            'subarray1_diodeconn_loss': 0.5,
            'subarray1_electrical_mismatch': 0.0,
            'subarray1_mismatch_loss': 1.0,
            'subarray1_nameplate_loss': 0.0,
            'subarray1_rack_shading': 0.0,
            'subarray1_rear_soiling_loss': 0.0,
            'subarray1_soiling': (0.5,
                                  0.5,
                                  0.4,
                                  0.6,
                                  1.5,
                                  4.2,
                                  8.3,
                                  0.3,
                                  6.6000000000000005,
                                  4.9,
                                  1.3,
                                  0.7000000000000001),
            'subarray1_tracking_loss': 0.0,
            'transformer_load_loss': 0.7000000000000001,
            'transformer_no_load_loss': 0.2,
            'transmission_loss': 0.0},
 'MermoudLejeuneSingleDiodeModel': {},
 'Module': {'module_model': 1.0},
 'Outputs': {},
 'PriceSignal': {},
 'Revenue': {},
 'SandiaPVArrayPerformanceModelWithModuleDatabase': {},
 'Shading': {'subarray1_shade_mode': 1.0},
 'SimpleEfficiencyModuleModel': {},
 'SolarResource': {'albedo': (0.3,
                              0.3,
                              0.3,
                              0.3,
                              0.3,
                              0.3,
                              0.3,
                              0.3,
                              0.3,
                              0.3,
                              0.3,
                              0.3),
                   'use_wf_albedo': 1.0,
                    'solar_resource_data': ...},  # solar_resource_data omitted for length/clarity
 'SystemCosts': {},
 'SystemDesign': {'enable_mismatch_vmax_calc': 0.0,
                  'inverter_count': 7.0,
                  'subarray1_azimuth': 180.0,
                  'subarray1_gcr': 0.33,
                  'subarray1_modules_per_string': 24.0,
                  'subarray1_nstrings': 2526.0,
                  'subarray1_tilt': 30.0,
                  'subarray1_track_mode': 0.0,
                  'subarray2_enable': 0.0,
                  'subarray3_enable': 0.0,
                  'subarray4_enable': 0.0,
                  'system_capacity': 20005920.0}}

When I call model.execute(0) I get the following error:

>       m.execute(0)
E       Exception: pvsamv1 execution error.
E           check fail: reason unassigned referenced, with 'subarray2_track_mode' for: subarray2_monthly_tilt

This same model definition ran successfully on pysam 3.0.2 with the only exception being that the new bifacial-related inputs in model.Losses were replaced with subarray1_rear_irradiance_loss.

As you can see in the model definition, subarray2_enable is set to zero, so I'm not sure why track_mode and monthly_tilt are being referenced for subarray 2 in the error message. The latest docs say that subarray2_enable depends on a large number of inverter and module inputs, but it doesn't mention how it depends on these factors. If pysam is now forcing subarray2_enable to be active under certain conditions (I could see it depending on sizing considerations), then apologies for raising a usage question as an issue; but as far as I can tell this is a bug.

cpaulgilman commented 1 year ago

Hi @caseyzak24, I'm looking into this now, but suspect that you may need to define all of those subarray2, subarray3, and subarray4 inputs even if those subarrays are not enabled.

cpaulgilman commented 1 year ago

@caseyzak24 We added some input checks to pvsamv1 that are supposed to help make sure inputs are correctly assigned. For example, to ensure that subarray2_tilt is correctly assigned based on the value of subarray2_enable and subarray2_track_mode. It looks like some of those checks are incorrect, causing the "check fail" error messages you are seeing.

We will fix this for the next update. For now, the workaround is to set inputs for all of the subarrays even if they are not enabled.

caseyzak24 commented 1 year ago

Thanks Paul,

Will you ref this issue when you make that update? I just want to make sure we get on that fixed version ASAP.

cpaulgilman commented 1 year ago

This is fixed in #1062.

Note that for scripts based on versions of SSC greater than 274 (newer than SAM 2021.12.02 Revision 2, PySAM 3.0.2), the following new pvsamv1 variables are required for Subarray 1:

And for SSC > 280 (newer than SAM 2022.11.21 Revision 3, PySAM 4.2.0), the format of the adjust input has changed: