def test_noct_sam_against_sam(): # test is constructed to reproduce output from SAM v2020.11.29. # SAM calculation is the default Detailed PV System model (CEC diode model, # NOCT cell temperature model), with the only change being the soiling # loss is set to 0. Weather input is TMY3 for Phoenix AZ. # Values are taken from the Jan 1 12:00:00 timestamp. poa_total, temp_air, wind_speed, noct, module_efficiency = ( 860.673, 25, 3, 46.4, 0.20551) poa_total_after_refl = 851.458 # from SAM output # compute effective irradiance # spectral loss coefficients fixed in lib_cec6par.cpp a = np.flipud([0.918093, 0.086257, -0.024459, 0.002816, -0.000126]) # reproduce SAM air mass calculation zen = 56.4284 elev = 358 air_mass = 1. / (tools.cosd(zen) + 0.5057 * (96.080 - zen)**-1.634) air_mass *= np.exp(-0.0001184 * elev) f1 = np.polyval(a, air_mass) effective_irradiance = f1 * poa_total_after_refl transmittance_absorptance = 0.9 array_height = 1 mount_standoff = 4.0 result = temperature.noct_sam(poa_total, temp_air, wind_speed, noct, module_efficiency, effective_irradiance, transmittance_absorptance, array_height, mount_standoff) expected = 43.0655 # rtol from limited SAM output precision assert_allclose(result, expected, rtol=1e-5)
def test_noct_sam(): poa_global, temp_air, wind_speed, noct, module_efficiency = ( 1000., 25., 1., 45., 0.2) expected = 55.230790492 result = temperature.noct_sam(poa_global, temp_air, wind_speed, noct, module_efficiency) assert_allclose(result, expected) # test with different types result = temperature.noct_sam(np.array(poa_global), np.array(temp_air), np.array(wind_speed), np.array(noct), np.array(module_efficiency)) assert_allclose(result, expected) dr = pd.date_range(start='2020-01-01 12:00:00', end='2020-01-01 13:00:00', freq='1H') result = temperature.noct_sam(pd.Series(index=dr, data=poa_global), pd.Series(index=dr, data=temp_air), pd.Series(index=dr, data=wind_speed), pd.Series(index=dr, data=noct), module_efficiency) assert_series_equal(result, pd.Series(index=dr, data=expected))
def test_noct_sam_options(): poa_global, temp_air, wind_speed, noct, module_efficiency = ( 1000., 25., 1., 45., 0.2) effective_irradiance = 1100. transmittance_absorptance = 0.8 array_height = 2 mount_standoff = 2.0 result = temperature.noct_sam(poa_global, temp_air, wind_speed, noct, module_efficiency, effective_irradiance, transmittance_absorptance, array_height, mount_standoff) expected = 60.477703576 assert_allclose(result, expected)
def test_noct_sam_errors(): with pytest.raises(ValueError): temperature.noct_sam(1000., 25., 1., 34., 0.2, array_height=3)