def calcparams_pvsyst(self, effective_irradiance, temp_cell): """ Use the :py:func:`pvsystem.calcparams_pvsyst` function, the input parameters and ``self.module_parameters`` to calculate the module currents and resistances. Parameters ---------- effective_irradiance : numeric The irradiance (W/m2) that is converted to photocurrent. temp_cell : float or Series The average cell temperature of cells within a module in C. Returns ------- See pvsystem.calcparams_pvsyst for details """ kwargs = _build_kwargs([ 'gamma_ref', 'mu_gamma', 'I_L_ref', 'I_o_ref', 'R_sh_ref', 'R_sh_0', 'R_sh_exp', 'R_s', 'alpha_sc', 'EgRef', 'irrad_ref', 'temp_ref', 'cells_in_series' ], self.module_parameters) return pvsystem.calcparams_pvsyst(effective_irradiance, temp_cell, **kwargs)
def test_calcparams_pvsyst(pvsyst_module_params): times = pd.date_range(start='2015-01-01', periods=2, freq='12H') effective_irradiance = pd.Series([0.0, 800.0], index=times) temp_cell = pd.Series([25, 50], index=times) IL, I0, Rs, Rsh, nNsVth = pvsystem.calcparams_pvsyst( effective_irradiance, temp_cell, alpha_sc=pvsyst_module_params['alpha_sc'], gamma_ref=pvsyst_module_params['gamma_ref'], mu_gamma=pvsyst_module_params['mu_gamma'], I_L_ref=pvsyst_module_params['I_L_ref'], I_o_ref=pvsyst_module_params['I_o_ref'], R_sh_ref=pvsyst_module_params['R_sh_ref'], R_sh_0=pvsyst_module_params['R_sh_0'], R_s=pvsyst_module_params['R_s'], cells_in_series=pvsyst_module_params['cells_in_series'], EgRef=pvsyst_module_params['EgRef']) assert_series_equal(IL.round(decimals=3), pd.Series([0.0, 4.8200], index=times)) assert_series_equal(I0.round(decimals=3), pd.Series([0.0, 1.47e-7], index=times)) assert_allclose(Rs, 0.500) assert_series_equal(Rsh.round(decimals=3), pd.Series([1000.0, 305.757], index=times)) assert_series_equal(nNsVth.round(decimals=4), pd.Series([1.6186, 1.7961], index=times))
def test_pvsyst_recombination_loss(method, poa, temp_cell, expected, tol): """test PVSst recombination loss""" pvsyst_fs_495 = get_pvsyst_fs_495() # first evaluate PVSyst model with thin-film recombination loss current # at reference conditions x = pvsystem.calcparams_pvsyst( effective_irradiance=poa, temp_cell=temp_cell, alpha_sc=pvsyst_fs_495['alpha_sc'], gamma_ref=pvsyst_fs_495['gamma_ref'], mu_gamma=pvsyst_fs_495['mu_gamma'], I_L_ref=pvsyst_fs_495['I_L_ref'], I_o_ref=pvsyst_fs_495['I_o_ref'], R_sh_ref=pvsyst_fs_495['R_sh_ref'], R_sh_0=pvsyst_fs_495['R_sh_0'], R_sh_exp=pvsyst_fs_495['R_sh_exp'], R_s=pvsyst_fs_495['R_s'], cells_in_series=pvsyst_fs_495['cells_in_series'], EgRef=pvsyst_fs_495['EgRef'] ) il_pvsyst, io_pvsyst, rs_pvsyst, rsh_pvsyst, nnsvt_pvsyst = x voc_est_pvsyst = estimate_voc(photocurrent=il_pvsyst, saturation_current=io_pvsyst, nNsVth=nnsvt_pvsyst) vd_pvsyst = np.linspace(0, voc_est_pvsyst, 1000) pvsyst = bishop88( diode_voltage=vd_pvsyst, photocurrent=il_pvsyst, saturation_current=io_pvsyst, resistance_series=rs_pvsyst, resistance_shunt=rsh_pvsyst, nNsVth=nnsvt_pvsyst, d2mutau=pvsyst_fs_495['d2mutau'], NsVbi=VOLTAGE_BUILTIN*pvsyst_fs_495['cells_in_series'] ) # test max power assert np.isclose(max(pvsyst[2]), expected['pmp'], *tol) # test short circuit current isc_pvsyst = np.interp(0, pvsyst[1], pvsyst[0]) assert np.isclose(isc_pvsyst, expected['isc'], *tol) # test open circuit voltage voc_pvsyst = np.interp(0, pvsyst[0][::-1], pvsyst[1][::-1]) assert np.isclose(voc_pvsyst, expected['voc'], *tol) # repeat tests as above with specialized bishop88 functions y = dict(d2mutau=pvsyst_fs_495['d2mutau'], NsVbi=VOLTAGE_BUILTIN*pvsyst_fs_495['cells_in_series']) mpp_88 = bishop88_mpp(*x, **y, method=method) assert np.isclose(mpp_88[2], expected['pmp'], *tol) isc_88 = bishop88_i_from_v(0, *x, **y, method=method) assert np.isclose(isc_88, expected['isc'], *tol) voc_88 = bishop88_v_from_i(0, *x, **y, method=method) assert np.isclose(voc_88, expected['voc'], *tol) ioc_88 = bishop88_i_from_v(voc_88, *x, **y, method=method) assert np.isclose(ioc_88, 0.0, *tol) vsc_88 = bishop88_v_from_i(isc_88, *x, **y, method=method) assert np.isclose(vsc_88, 0.0, *tol)
def maxp(temp_cell, irrad_ref, alpha_sc, gamma_ref, mu_gamma, I_L_ref, I_o_ref, R_sh_ref, R_sh_0, R_s, cells_in_series, R_sh_exp, EgRef, temp_ref): params = calcparams_pvsyst( irrad_ref, temp_cell, alpha_sc, gamma_ref, mu_gamma, I_L_ref, I_o_ref, R_sh_ref, R_sh_0, R_s, cells_in_series, R_sh_exp, EgRef, irrad_ref, temp_ref) res = bishop88_mpp(*params) return res[2]
def singlediodePVSYST(G, T, I0_ref, IL_ref, n_ref, Ns, u_sc, u_n, Rs, Rsh_ref, Rsh_0, Rsh_exp): ''' reference conditions assumed to be STC (1000 W/m^2, 25 C) G = module irradiance under test T = cell temperature under test I0_ref = diode saturation current at STC (from calc_ref_vals) IL_ref = cell photo current at STC (from calc_ref_vals) n_ref = diode ideality factor at STC (from calc_ref_vals) Nsc = number of cells in series (datasheet) u_sc = short circuit current temperature coefficient at 1000W/M^2 (datasheet) u_n = diode ideality factor temperature coefficient (solving for) Rs = series resistance (solving for) Rsh_ref = shunt resistance at 1000 W/m^2 (solving for) Rsh_0 = shunt resistance at 0 W/m^2 (solving for) Rsh_exp = shunt resistance exponential factor (solving for) ''' IL, I0, Rs, Rsh, nNsVth = calcparams_pvsyst(G, T, u_sc, n_ref, u_n, IL_ref, I0_ref, Rsh_ref, Rsh_0, Rs, Ns, Rsh_exp, EgRef=1.121, irrad_ref=1000, temp_ref=25) out = singlediode(IL, I0, Rs, Rsh, nNsVth, ivcurve_pnts=None, method='lambertw') return (out['p_mp'])
def test_pvsyst_recombination_loss(poa, temp_cell, expected, tol): """test PVSst recombination loss""" pvsyst_fs_495 = get_pvsyst_fs_495() # first evaluate PVSyst model with thin-film recombination loss current # at reference conditions x = pvsystem.calcparams_pvsyst( effective_irradiance=poa, temp_cell=temp_cell, alpha_sc=pvsyst_fs_495['alpha_sc'], gamma_ref=pvsyst_fs_495['gamma_ref'], mu_gamma=pvsyst_fs_495['mu_gamma'], I_L_ref=pvsyst_fs_495['I_L_ref'], I_o_ref=pvsyst_fs_495['I_o_ref'], R_sh_ref=pvsyst_fs_495['R_sh_ref'], R_sh_0=pvsyst_fs_495['R_sh_0'], R_sh_exp=pvsyst_fs_495['R_sh_exp'], R_s=pvsyst_fs_495['R_s'], cells_in_series=pvsyst_fs_495['cells_in_series'], EgRef=pvsyst_fs_495['EgRef'] ) il_pvsyst, io_pvsyst, rs_pvsyst, rsh_pvsyst, nnsvt_pvsyst = x voc_est_pvsyst = estimate_voc(photocurrent=il_pvsyst, saturation_current=io_pvsyst, nNsVth=nnsvt_pvsyst) vd_pvsyst = np.linspace(0, voc_est_pvsyst, 1000) pvsyst = bishop88( diode_voltage=vd_pvsyst, photocurrent=il_pvsyst, saturation_current=io_pvsyst, resistance_series=rs_pvsyst, resistance_shunt=rsh_pvsyst, nNsVth=nnsvt_pvsyst, d2mutau=pvsyst_fs_495['d2mutau'], NsVbi=VOLTAGE_BUILTIN*pvsyst_fs_495['cells_in_series'] ) # test max power assert np.isclose(max(pvsyst[2]), expected['pmp'], *tol) # test short circuit current isc_pvsyst = np.interp(0, pvsyst[1], pvsyst[0]) assert np.isclose(isc_pvsyst, expected['isc'], *tol) # test open circuit current voc_pvsyst = np.interp(0, pvsyst[0][::-1], pvsyst[1][::-1]) assert np.isclose(voc_pvsyst, expected['voc'], *tol)
def test_pvsyst_recombination_loss(pvsyst_fs_495, poa, temp_cell, expected, tol): """test PVSst recombination loss""" # first evaluate PVSyst model with thin-film recombination loss current # at reference conditions x = pvsystem.calcparams_pvsyst( effective_irradiance=poa, temp_cell=temp_cell, alpha_sc=pvsyst_fs_495['alpha_sc'], gamma_ref=pvsyst_fs_495['gamma_ref'], mu_gamma=pvsyst_fs_495['mu_gamma'], I_L_ref=pvsyst_fs_495['I_L_ref'], I_o_ref=pvsyst_fs_495['I_o_ref'], R_sh_ref=pvsyst_fs_495['R_sh_ref'], R_sh_0=pvsyst_fs_495['R_sh_0'], R_sh_exp=pvsyst_fs_495['R_sh_exp'], R_s=pvsyst_fs_495['R_s'], cells_in_series=pvsyst_fs_495['cells_in_series'], EgRef=pvsyst_fs_495['EgRef'] ) il_pvsyst, io_pvsyst, rs_pvsyst, rsh_pvsyst, nnsvt_pvsyst = x voc_est_pvsyst = estimate_voc(photocurrent=il_pvsyst, saturation_current=io_pvsyst, nNsVth=nnsvt_pvsyst) vd_pvsyst = np.linspace(0, voc_est_pvsyst, 1000) pvsyst = bishop88( diode_voltage=vd_pvsyst, photocurrent=il_pvsyst, saturation_current=io_pvsyst, resistance_series=rs_pvsyst, resistance_shunt=rsh_pvsyst, nNsVth=nnsvt_pvsyst, d2mutau=pvsyst_fs_495['d2mutau'], NsVbi=VOLTAGE_BUILTIN*pvsyst_fs_495['cells_in_series'] ) # test max power assert np.isclose(max(pvsyst[2]), expected['pmp'], *tol) # test short circuit current isc_pvsyst = np.interp(0, pvsyst[1], pvsyst[0]) assert np.isclose(isc_pvsyst, expected['isc'], *tol) # test open circuit current voc_pvsyst = np.interp(0, pvsyst[0][::-1], pvsyst[1][::-1]) assert np.isclose(voc_pvsyst, expected['voc'], *tol)
def test_fit_pvsyst_sandia(npts=3000): # get IV curve data iv_specs, ivcurves = _read_iv_curves_for_test('PVsyst_demo.csv', npts) # get known Pvsyst model parameters and five parameters from each fitted # IV curve pvsyst_specs, pvsyst = _read_pvsyst_expected('PVsyst_demo_model.csv') modeled = sdm.fit_pvsyst_sandia(ivcurves, iv_specs) # calculate IV curves using the fitted model, for comparison with input # IV curves param_res = pvsystem.calcparams_pvsyst( effective_irradiance=ivcurves['ee'], temp_cell=ivcurves['tc'], alpha_sc=iv_specs['alpha_sc'], gamma_ref=modeled['gamma_ref'], mu_gamma=modeled['mu_gamma'], I_L_ref=modeled['I_L_ref'], I_o_ref=modeled['I_o_ref'], R_sh_ref=modeled['R_sh_ref'], R_sh_0=modeled['R_sh_0'], R_s=modeled['R_s'], cells_in_series=iv_specs['cells_in_series'], EgRef=modeled['EgRef']) iv_res = pvsystem.singlediode(*param_res) # assertions assert np.allclose( ivcurves['p_mp'], iv_res['p_mp'], equal_nan=True, rtol=0.038) assert np.allclose( ivcurves['v_mp'], iv_res['v_mp'], equal_nan=True, rtol=0.029) assert np.allclose( ivcurves['i_mp'], iv_res['i_mp'], equal_nan=True, rtol=0.021) assert np.allclose( ivcurves['i_sc'], iv_res['i_sc'], equal_nan=True, rtol=0.003) assert np.allclose( ivcurves['v_oc'], iv_res['v_oc'], equal_nan=True, rtol=0.019) # cells_in_series, alpha_sc, beta_voc, descr assert all((iv_specs[k] == pvsyst_specs[k]) for k in iv_specs.keys()) # I_L_ref, I_o_ref, EgRef, R_sh_ref, R_sh_0, R_sh_exp, R_s, gamma_ref, # mu_gamma assert np.isclose(modeled['I_L_ref'], pvsyst['I_L_ref'], rtol=6.5e-5) assert np.isclose(modeled['I_o_ref'], pvsyst['I_o_ref'], rtol=0.15) assert np.isclose(modeled['R_s'], pvsyst['R_s'], rtol=0.0035) assert np.isclose(modeled['R_sh_ref'], pvsyst['R_sh_ref'], rtol=0.091) assert np.isclose(modeled['R_sh_0'], pvsyst['R_sh_0'], rtol=0.013) assert np.isclose(modeled['EgRef'], pvsyst['EgRef'], rtol=0.037) assert np.isclose(modeled['gamma_ref'], pvsyst['gamma_ref'], rtol=0.0045) assert np.isclose(modeled['mu_gamma'], pvsyst['mu_gamma'], rtol=0.064) # Iph, Io, Rsh, Rs, u mask = np.ones(modeled['u'].shape, dtype=bool) # exclude one curve with different convergence umask = mask.copy() umask[2540] = False assert all(modeled['u'][umask] == pvsyst['u'][:npts][umask]) assert np.allclose( modeled['iph'][modeled['u']], pvsyst['iph'][:npts][modeled['u']], equal_nan=True, rtol=0.0009) assert np.allclose( modeled['io'][modeled['u']], pvsyst['io'][:npts][modeled['u']], equal_nan=True, rtol=0.096) assert np.allclose( modeled['rs'][modeled['u']], pvsyst['rs'][:npts][modeled['u']], equal_nan=True, rtol=0.035) # exclude one curve with Rsh outside 63% tolerance rshmask = modeled['u'].copy() rshmask[2545] = False assert np.allclose( modeled['rsh'][rshmask], pvsyst['rsh'][:npts][rshmask], equal_nan=True, rtol=0.63)