From e20a079bc23625f9f15a0d92bf7a5345d2dee6ad Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Wed, 20 Jun 2018 08:32:54 -0600 Subject: [PATCH 01/16] initial version of calcparams_pvsyst and test --- pvlib/pvsystem.py | 171 ++++++++++++++++++++++++++++++++++++ pvlib/test/test_pvsystem.py | 72 +++++++++++++++ 2 files changed, 243 insertions(+) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 96ac7d3d90..427b2f965b 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -307,6 +307,36 @@ def calcparams_desoto(self, effective_irradiance, temp_cell, **kwargs): return calcparams_desoto(effective_irradiance, temp_cell, **kwargs) + def calcparams_pvsyst(self, effective_irradiance, temp_cell, **kwargs): + """ + Use the :py:func:`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. + + **kwargs + See pvsystem.calcparams_desoto for details + + Returns + ------- + See pvsystem.calcparams_pvsyst for details + """ + + kwargs = _build_kwargs(['gamma_ref', 'mugamma', 'I_L_ref', 'I_o_ref', + 'R_sh_ref', 'R_sh_0', 'R_sh_exp', + 'R_s', 'alpha_sc', 'EgRef', + 'cells_in_series'], + self.module_parameters) + + return calcparams_pvsyst(effective_irradiance, temp_cell, **kwargs) + def sapm(self, effective_irradiance, temp_cell, **kwargs): """ Use the :py:func:`sapm` function, the input parameters, @@ -1172,6 +1202,147 @@ def calcparams_desoto(effective_irradiance, temp_cell, return IL, I0, Rs, Rsh, nNsVth +def calcparams_pvsyst(effective_irradiance, temp_cell, + alpha_sc, gamma_ref, mugamma, + I_L_ref, I_o_ref, + R_sh_ref, R_sh_0, R_s, + cells_in_series, + R_sh_exp=5.5, + EgRef=1.121, + irrad_ref=1000, temp_ref=25): + ''' + Calculates five parameter values for the single diode equation at + effective irradiance and cell temperature using the PVsyst v6 + model described in [1,2,3]. The five values returned by calcparams_pvsyst + can be used by singlediode to calculate an IV curve. + + Parameters + ---------- + effective_irradiance : numeric + The irradiance (W/m2) that is converted to photocurrent. + + temp_cell : numeric + The average cell temperature of cells within a module in C. + + alpha_sc : float + The short-circuit current temperature coefficient of the + module in units of A/C. + + gamma_ref : float + The diode ideality factor + + I_L_ref : float + The light-generated current (or photocurrent) at reference conditions, + in amperes. + + I_o_ref : float + The dark or diode reverse saturation current at reference conditions, + in amperes. + + R_sh_ref : float + The shunt resistance at reference conditions, in ohms. + + R_sh_0 : float + The shunt resistance at zero irradiance conditions, in ohms. + + R_s : float + The series resistance at reference conditions, in ohms. + + cells_in_series : integer + The number of cells connected in series. + + R_sh_exp : float + The exponent in the equation for shunt resistance, unitless. Defaults + to 5.5. + + EgRef : float + The energy bandgap at reference temperature in units of eV. + 1.121 eV for crystalline silicon. EgRef must be >0. + + irrad_ref : float (optional, default=1000) + Reference irradiance in W/m^2. + + temp_ref : float (optional, default=25) + Reference cell temperature in C. + + Returns + ------- + Tuple of the following results: + + photocurrent : numeric + Light-generated current in amperes at irradiance=S and + cell temperature=Tcell. + + saturation_current : numeric + Diode saturation curent in amperes at irradiance + S and cell temperature Tcell. + + resistance_series : float + Series resistance in ohms at irradiance S and cell temperature + Tcell. + + resistance_shunt : numeric + Shunt resistance in ohms at irradiance S and cell temperature + Tcell. + + nNsVth : numeric + Modified diode ideality factor at irradiance S and cell + temperature Tcell. Note that in source [1] nNsVth = a (equation + 2). nNsVth is the product of the diode ideality factor + (n), the number of series-connected cells in the module (Ns), + and the thermal voltage of a cell in the module (Vth) at a cell + temperature of Tcell. + + References + ---------- + [1] K. Sauer, T. Roessler, C. W. Hansen, Modeling the Irradiance and + Temperature Dependence of Photovoltaic Modules in PVsyst, + IEEE Journal of Photovoltaics v5(1), January 2015. + + [2] A. Mermoud, PV modules modelling, Presentation at the 2nd PV + Performance Modeling Workshop, Santa Clara, CA, May 2013 + + [3] A. Mermoud, T. Lejeune, Performance Assessment of a Simulation Model + for PV modules of any available technology, 25th European Photovoltaic + Solar Energy Conference, Valencia, Spain, Sept. 2010 + + See Also + -------- + calcparams_desoto + singlediode + + ''' + + # Boltzmann constant in J/K + k = 1.3806488e-23 + + # elementary charge in coulomb + q = 1.6021766e-19 + + # reference temperature + Tref_K = temp_ref + 273.15 + Tcell_K = temp_cell + 273.15 + + gamma = gamma_ref + mugamma * (Tcell_K - Tref_K) + nNsVth = gamma * k / q * cells_in_series + + IL = effective_irradiance / irrad_ref * \ + (I_L_ref + alpha_sc * (Tcell_K - Tref_K)) + + I0 = I_o_ref * ((Tcell_K / Tref_K) ** 3) * \ + (np.exp((q * EgRef) / (k * gamma) * (1 / Tref_K - 1 / Tcell_K))) + + Rsh_tmp = (R_sh_ref - R_sh_0 * np.exp(-R_sh_exp)) / (1.0 - np.exp(-R_sh_exp)) + Rsh_base = np.maximum(0.0, Rsh_tmp) + + Rsh = Rsh_base + (R_sh_0 - Rsh_base) * \ + np.exp(-R_sh_exp * effective_irradiance / irrad_ref) + + Rs = R_s + + return IL, I0, Rs, Rsh, nNsVth + + def retrieve_sam(name=None, path=None): ''' Retrieve latest module and inverter info from a local file or the diff --git a/pvlib/test/test_pvsystem.py b/pvlib/test/test_pvsystem.py index 289b0f6577..e6d4c800ec 100644 --- a/pvlib/test/test_pvsystem.py +++ b/pvlib/test/test_pvsystem.py @@ -174,6 +174,23 @@ def cec_module_params(sam_data): return module_parameters +@pytest.fixture(scope="session") +def pvsyst_module_params(): + module_parameters = {} + module_parameters['gamma_ref'] = 1.05 + module_parameters['mugamma'] = 0.001 + module_parameters['I_L_ref'] = 6.0 + module_parameters['I_o_ref'] = 5e-9 + module_parameters['EgRef'] = 1.121 + module_parameters['R_sh_ref'] = 300 + module_parameters['R_sh_0'] = 1000 + module_parameters['R_s'] = 0.5 + module_parameters['R_sh_exp'] = 5.5 + module_parameters['cells_in_series'] = 60 + module_parameters['alpha_sc'] = 0.001 + return module_parameters + + def test_sapm(sapm_module_params): times = pd.DatetimeIndex(start='2015-01-01', periods=5, freq='12H') @@ -386,6 +403,34 @@ def test_calcparams_desoto(cec_module_params): assert_allclose(nNsVth, 0.473) +def test_calcparams_pvsyst(pvsyst_module_params): + times = pd.DatetimeIndex(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'], + mugamma=pvsyst_module_params['mugamma'], + 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_s=pvsyst_module_params['R_s'], + EgRef=pvsyst_module_params['EgRef'], + cells_in_series=pvsyst_module_params['cells_in_series']) + + assert_series_equal(np.round(IL, 3), pd.Series([0.0, 4.800], index=times)) + assert_series_equal(np.round(I0, 3), + pd.Series([0.0, 1.47e-7], index=times)) + assert_allclose(Rs, 0.500) + assert_series_equal(np.round(Rsh, 3), + pd.Series([1000.0, 305.76], index=times)) + assert_series_equal(np.round(nNsVth, 4), + pd.Series([1.6186, 1.7961], index=times)) + + def test_PVSystem_calcparams_desoto(cec_module_params, mocker): mocker.spy(pvsystem, 'calcparams_desoto') module_parameters = cec_module_params.copy() @@ -414,6 +459,33 @@ def test_PVSystem_calcparams_desoto(cec_module_params, mocker): assert_allclose(nNsVth, 0.5, atol=0.1) +def test_PVSystem_calcparams_pvsyst(pvsyst_module_params, mocker): + mocker.spy(pvsystem, 'calcparams_pvsyst') + module_parameters = pvsyst_module_params.copy() + system = pvsystem.PVSystem(module_parameters=module_parameters) + effective_irradiance = np.array([0, 800]) + temp_cell = np.array([25, 50]) + IL, I0, Rs, Rsh, nNsVth = system.calcparams_pvsyst(effective_irradiance, + temp_cell) + pvsystem.calcparams_pvsyst.assert_called_once_with( + effective_irradiance, + temp_cell, + alpha_sc=pvsyst_module_params['alpha_sc'], + gamma_ref=pvsyst_module_params['gamma_ref'], + mugamma=pvsyst_module_params['mugamma'], + 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_s=pvsyst_module_params['R_s'], + EgRef=pvsyst_module_params['EgRef'], + cells_in_series=pvsyst_module_params['cells_in_series']) + assert_allclose(IL, np.array([0.0, 4.800]), atol=1) + assert_allclose(I0, np.array([0.0, 1.47e-7]), atol=1.0e-5) + assert_allclose(Rs, 0.5, atol=0.1) + assert_allclose(Rsh, np.array([1000, 305.76]), atol=50) + assert_allclose(nNsVth, np.array([1.6186, 1.7961]), atol=0.1) + + @pytest.fixture(params=[ { # Can handle all python scalar inputs 'Rsh': 20., From e93cd8aec409a175ca19d81d9f128315af285686 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Wed, 20 Jun 2018 09:03:36 -0600 Subject: [PATCH 02/16] fix argument list in tests --- pvlib/test/test_pvsystem.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pvlib/test/test_pvsystem.py b/pvlib/test/test_pvsystem.py index e6d4c800ec..2eb1f81c87 100644 --- a/pvlib/test/test_pvsystem.py +++ b/pvlib/test/test_pvsystem.py @@ -417,9 +417,10 @@ def test_calcparams_pvsyst(pvsyst_module_params): 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'], - EgRef=pvsyst_module_params['EgRef'], - cells_in_series=pvsyst_module_params['cells_in_series']) + cells_in_series=pvsyst_module_params['cells_in_series'], + EgRef=pvsyst_module_params['EgRef']) assert_series_equal(np.round(IL, 3), pd.Series([0.0, 4.800], index=times)) assert_series_equal(np.round(I0, 3), @@ -476,9 +477,10 @@ def test_PVSystem_calcparams_pvsyst(pvsyst_module_params, mocker): 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_ref=pvsyst_module_params['R_sh_0'], R_s=pvsyst_module_params['R_s'], - EgRef=pvsyst_module_params['EgRef'], - cells_in_series=pvsyst_module_params['cells_in_series']) + cells_in_series=pvsyst_module_params['cells_in_series'], + EgRef=pvsyst_module_params['EgRef']) assert_allclose(IL, np.array([0.0, 4.800]), atol=1) assert_allclose(I0, np.array([0.0, 1.47e-7]), atol=1.0e-5) assert_allclose(Rs, 0.5, atol=0.1) From 846c913269dbd710a0cf1e45d9a14947729d8f01 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Wed, 20 Jun 2018 10:06:12 -0600 Subject: [PATCH 03/16] Fix typo in test argument R_sh_0 --- pvlib/test/test_pvsystem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/test/test_pvsystem.py b/pvlib/test/test_pvsystem.py index 2eb1f81c87..f1e319b1e5 100644 --- a/pvlib/test/test_pvsystem.py +++ b/pvlib/test/test_pvsystem.py @@ -477,7 +477,7 @@ def test_PVSystem_calcparams_pvsyst(pvsyst_module_params, mocker): 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_ref=pvsyst_module_params['R_sh_0'], + 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']) From f4573701af92d1cc361376c331a2d0e92c863d83 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Wed, 20 Jun 2018 10:41:50 -0600 Subject: [PATCH 04/16] remove EgRef from PVSystem.test_calcparams_pvsyst --- pvlib/test/test_pvsystem.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pvlib/test/test_pvsystem.py b/pvlib/test/test_pvsystem.py index f1e319b1e5..a99ffdfd49 100644 --- a/pvlib/test/test_pvsystem.py +++ b/pvlib/test/test_pvsystem.py @@ -422,7 +422,7 @@ def test_calcparams_pvsyst(pvsyst_module_params): cells_in_series=pvsyst_module_params['cells_in_series'], EgRef=pvsyst_module_params['EgRef']) - assert_series_equal(np.round(IL, 3), pd.Series([0.0, 4.800], index=times)) + assert_series_equal(np.round(IL, 3), pd.Series([0.0, 4.8200], index=times)) assert_series_equal(np.round(I0, 3), pd.Series([0.0, 1.47e-7], index=times)) assert_allclose(Rs, 0.500) @@ -479,9 +479,9 @@ def test_PVSystem_calcparams_pvsyst(pvsyst_module_params, mocker): 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_allclose(IL, np.array([0.0, 4.800]), atol=1) + cells_in_series=pvsyst_module_params['cells_in_series']) + + assert_allclose(IL, np.array([0.0, 4.8200]), atol=1) assert_allclose(I0, np.array([0.0, 1.47e-7]), atol=1.0e-5) assert_allclose(Rs, 0.5, atol=0.1) assert_allclose(Rsh, np.array([1000, 305.76]), atol=50) From 691a9a719e984274b2aa8e2181b370bb8bfa1bab Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Wed, 20 Jun 2018 10:45:09 -0600 Subject: [PATCH 05/16] add documentation for mugamma, fix typo --- pvlib/pvsystem.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 427b2f965b..f15b772efe 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -322,7 +322,7 @@ def calcparams_pvsyst(self, effective_irradiance, temp_cell, **kwargs): The average cell temperature of cells within a module in C. **kwargs - See pvsystem.calcparams_desoto for details + See pvsystem.calcparams_pvsyst for details Returns ------- @@ -1231,6 +1231,9 @@ def calcparams_pvsyst(effective_irradiance, temp_cell, gamma_ref : float The diode ideality factor + mugamma : float + The temperature coefficient for the diode ideality factor, 1/K + I_L_ref : float The light-generated current (or photocurrent) at reference conditions, in amperes. From 36d59417cb3851ef07b483dac6387b802af7f7a1 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Wed, 20 Jun 2018 11:07:34 -0600 Subject: [PATCH 06/16] edits and fix to test error --- pvlib/test/test_pvsystem.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pvlib/test/test_pvsystem.py b/pvlib/test/test_pvsystem.py index a99ffdfd49..411a59a000 100644 --- a/pvlib/test/test_pvsystem.py +++ b/pvlib/test/test_pvsystem.py @@ -479,12 +479,13 @@ def test_PVSystem_calcparams_pvsyst(pvsyst_module_params, mocker): 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']) + cells_in_series=pvsyst_module_params['cells_in_series'], + R_sh_exp=pvsyst_module_params['R_sh_exp']) assert_allclose(IL, np.array([0.0, 4.8200]), atol=1) assert_allclose(I0, np.array([0.0, 1.47e-7]), atol=1.0e-5) assert_allclose(Rs, 0.5, atol=0.1) - assert_allclose(Rsh, np.array([1000, 305.76]), atol=50) + assert_allclose(Rsh, np.array([1000, 305.757]), atol=50) assert_allclose(nNsVth, np.array([1.6186, 1.7961]), atol=0.1) From 131ff75c93566e75ad67ad10ba0741ffdbedaf56 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Wed, 20 Jun 2018 12:18:23 -0600 Subject: [PATCH 07/16] Fix argument list and expected result --- pvlib/test/test_pvsystem.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pvlib/test/test_pvsystem.py b/pvlib/test/test_pvsystem.py index 411a59a000..6efba10535 100644 --- a/pvlib/test/test_pvsystem.py +++ b/pvlib/test/test_pvsystem.py @@ -427,7 +427,7 @@ def test_calcparams_pvsyst(pvsyst_module_params): pd.Series([0.0, 1.47e-7], index=times)) assert_allclose(Rs, 0.500) assert_series_equal(np.round(Rsh, 3), - pd.Series([1000.0, 305.76], index=times)) + pd.Series([1000.0, 305.757], index=times)) assert_series_equal(np.round(nNsVth, 4), pd.Series([1.6186, 1.7961], index=times)) @@ -480,6 +480,7 @@ def test_PVSystem_calcparams_pvsyst(pvsyst_module_params, mocker): 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'], R_sh_exp=pvsyst_module_params['R_sh_exp']) assert_allclose(IL, np.array([0.0, 4.8200]), atol=1) From 9d5d55e2ac4e039d498f9a54f837f230ad896ab4 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Wed, 20 Jun 2018 12:49:26 -0600 Subject: [PATCH 08/16] Fix error in calculation of nNsVth --- pvlib/pvsystem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index f15b772efe..25ab9ddc96 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -1327,7 +1327,7 @@ def calcparams_pvsyst(effective_irradiance, temp_cell, Tcell_K = temp_cell + 273.15 gamma = gamma_ref + mugamma * (Tcell_K - Tref_K) - nNsVth = gamma * k / q * cells_in_series + nNsVth = gamma * k / q * cells_in_series * Tcell_K IL = effective_irradiance / irrad_ref * \ (I_L_ref + alpha_sc * (Tcell_K - Tref_K)) From d1be4679848ef68a53734e71327894ef52dcac9d Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Wed, 20 Jun 2018 15:01:27 -0600 Subject: [PATCH 09/16] Add note to whatsnew.rst --- docs/sphinx/source/whatsnew/v0.6.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/sphinx/source/whatsnew/v0.6.0.rst b/docs/sphinx/source/whatsnew/v0.6.0.rst index 2f205edf04..64427f03c2 100644 --- a/docs/sphinx/source/whatsnew/v0.6.0.rst +++ b/docs/sphinx/source/whatsnew/v0.6.0.rst @@ -13,6 +13,7 @@ Enhancements * Add sea surface albedo in irradiance.py (:issue:`458`) * Implement first_solar_spectral_loss in modelchain.py (:issue:`359`) * Clarify arguments Egref and dEgdT for calcparams_desoto (:issue:`462`) +* Add pvsystem.calcparams_pvsyst to compute values for the single diode equation using the PVsyst v6 model. Bug fixes From 8d79f3d46f9df3a8e22d3be23aee30dbbf3134a2 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Wed, 20 Jun 2018 15:04:06 -0600 Subject: [PATCH 10/16] Add line to api.rst --- docs/sphinx/source/api.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/sphinx/source/api.rst b/docs/sphinx/source/api.rst index 4070ed56c3..5909db3a7a 100644 --- a/docs/sphinx/source/api.rst +++ b/docs/sphinx/source/api.rst @@ -202,6 +202,7 @@ Functions relevant for the single diode model. :toctree: generated/ pvsystem.calcparams_desoto + pvsystem.calcparams_pvsyst pvsystem.i_from_v pvsystem.singlediode pvsystem.v_from_i From 34390a9354f6ce57c77df7ad3c12ec68ec092bc4 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Thu, 21 Jun 2018 07:58:47 -0600 Subject: [PATCH 11/16] Edits to function signatures, variable names --- pvlib/pvsystem.py | 46 +++++++++++++++------------------------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 25ab9ddc96..ef3f30c233 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -1041,28 +1041,21 @@ def calcparams_desoto(effective_irradiance, temp_cell, Tuple of the following results: photocurrent : numeric - Light-generated current in amperes at irradiance=S and - cell temperature=Tcell. + Light-generated current in amperes saturation_current : numeric - Diode saturation curent in amperes at irradiance - S and cell temperature Tcell. + Diode saturation curent in amperes resistance_series : float - Series resistance in ohms at irradiance S and cell temperature - Tcell. + Series resistance in ohms resistance_shunt : numeric - Shunt resistance in ohms at irradiance S and cell temperature - Tcell. + Shunt resistance in ohms nNsVth : numeric - Modified diode ideality factor at irradiance S and cell - temperature Tcell. Note that in source [1] nNsVth = a (equation - 2). nNsVth is the product of the usual diode ideality factor - (n), the number of series-connected cells in the module (Ns), - and the thermal voltage of a cell in the module (Vth) at a cell - temperature of Tcell. + The product of the usual diode ideality factor (n, unitless), + number of cells in series (Ns), and cell thermal voltage at + specified effective irradiance and cell temperature. References ---------- @@ -1081,8 +1074,6 @@ def calcparams_desoto(effective_irradiance, temp_cell, See Also -------- - sapm - sapm_celltemp singlediode retrieve_sam @@ -1273,28 +1264,21 @@ def calcparams_pvsyst(effective_irradiance, temp_cell, Tuple of the following results: photocurrent : numeric - Light-generated current in amperes at irradiance=S and - cell temperature=Tcell. + Light-generated current in amperes saturation_current : numeric - Diode saturation curent in amperes at irradiance - S and cell temperature Tcell. + Diode saturation current in amperes resistance_series : float - Series resistance in ohms at irradiance S and cell temperature - Tcell. - + Series resistance in ohms + resistance_shunt : numeric - Shunt resistance in ohms at irradiance S and cell temperature - Tcell. + Shunt resistance in ohms nNsVth : numeric - Modified diode ideality factor at irradiance S and cell - temperature Tcell. Note that in source [1] nNsVth = a (equation - 2). nNsVth is the product of the diode ideality factor - (n), the number of series-connected cells in the module (Ns), - and the thermal voltage of a cell in the module (Vth) at a cell - temperature of Tcell. + The product of the usual diode ideality factor (n, unitless), + number of cells in series (Ns), and cell thermal voltage at + specified effective irradiance and cell temperature. References ---------- From 95bfde94f75516b61eec03d1755ddf1a11d4053a Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Sat, 23 Jun 2018 16:58:44 -0600 Subject: [PATCH 12/16] Change mugamma to mu_gamma, add issue to whatsnew text --- docs/sphinx/source/whatsnew/v0.6.0.rst | 2 +- pvlib/pvsystem.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.6.0.rst b/docs/sphinx/source/whatsnew/v0.6.0.rst index 64427f03c2..1fc8c0a241 100644 --- a/docs/sphinx/source/whatsnew/v0.6.0.rst +++ b/docs/sphinx/source/whatsnew/v0.6.0.rst @@ -13,7 +13,7 @@ Enhancements * Add sea surface albedo in irradiance.py (:issue:`458`) * Implement first_solar_spectral_loss in modelchain.py (:issue:`359`) * Clarify arguments Egref and dEgdT for calcparams_desoto (:issue:`462`) -* Add pvsystem.calcparams_pvsyst to compute values for the single diode equation using the PVsyst v6 model. +* Add pvsystem.calcparams_pvsyst to compute values for the single diode equation using the PVsyst v6 model (:issue:'470') Bug fixes diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index ef3f30c233..3573cf9812 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -329,7 +329,7 @@ def calcparams_pvsyst(self, effective_irradiance, temp_cell, **kwargs): See pvsystem.calcparams_pvsyst for details """ - kwargs = _build_kwargs(['gamma_ref', 'mugamma', 'I_L_ref', 'I_o_ref', + 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', 'cells_in_series'], @@ -1194,7 +1194,7 @@ def calcparams_desoto(effective_irradiance, temp_cell, def calcparams_pvsyst(effective_irradiance, temp_cell, - alpha_sc, gamma_ref, mugamma, + alpha_sc, gamma_ref, mu_gamma, I_L_ref, I_o_ref, R_sh_ref, R_sh_0, R_s, cells_in_series, @@ -1222,7 +1222,7 @@ def calcparams_pvsyst(effective_irradiance, temp_cell, gamma_ref : float The diode ideality factor - mugamma : float + mu_gamma : float The temperature coefficient for the diode ideality factor, 1/K I_L_ref : float @@ -1310,7 +1310,7 @@ def calcparams_pvsyst(effective_irradiance, temp_cell, Tref_K = temp_ref + 273.15 Tcell_K = temp_cell + 273.15 - gamma = gamma_ref + mugamma * (Tcell_K - Tref_K) + gamma = gamma_ref + mu_gamma * (Tcell_K - Tref_K) nNsVth = gamma * k / q * cells_in_series * Tcell_K IL = effective_irradiance / irrad_ref * \ From 75e89f0ddb2e0a99f5d2657617c5b32ad3dda8bc Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Wed, 27 Jun 2018 07:30:14 -0600 Subject: [PATCH 13/16] Change to mu_gamma in tests --- pvlib/test/test_pvsystem.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pvlib/test/test_pvsystem.py b/pvlib/test/test_pvsystem.py index 6efba10535..46fd13c8e0 100644 --- a/pvlib/test/test_pvsystem.py +++ b/pvlib/test/test_pvsystem.py @@ -178,7 +178,7 @@ def cec_module_params(sam_data): def pvsyst_module_params(): module_parameters = {} module_parameters['gamma_ref'] = 1.05 - module_parameters['mugamma'] = 0.001 + module_parameters['mu_gamma'] = 0.001 module_parameters['I_L_ref'] = 6.0 module_parameters['I_o_ref'] = 5e-9 module_parameters['EgRef'] = 1.121 @@ -413,7 +413,7 @@ def test_calcparams_pvsyst(pvsyst_module_params): temp_cell, alpha_sc=pvsyst_module_params['alpha_sc'], gamma_ref=pvsyst_module_params['gamma_ref'], - mugamma=pvsyst_module_params['mugamma'], + 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'], @@ -473,7 +473,7 @@ def test_PVSystem_calcparams_pvsyst(pvsyst_module_params, mocker): temp_cell, alpha_sc=pvsyst_module_params['alpha_sc'], gamma_ref=pvsyst_module_params['gamma_ref'], - mugamma=pvsyst_module_params['mugamma'], + 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'], From 046a3869a6a3fc53e04d60966b17c37d98ac67eb Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Thu, 5 Jul 2018 11:27:57 -0600 Subject: [PATCH 14/16] remove **kwargs from method calcparams_pvsyst signature, add irrad_ref and temp_ref keyword --- pvlib/pvsystem.py | 85 +++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 43 deletions(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 3573cf9812..dcc983b1bb 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -302,12 +302,13 @@ def calcparams_desoto(self, effective_irradiance, temp_cell, **kwargs): """ kwargs = _build_kwargs(['a_ref', 'I_L_ref', 'I_o_ref', 'R_sh_ref', - 'R_s', 'alpha_sc', 'EgRef', 'dEgdT'], + 'R_s', 'alpha_sc', 'EgRef', 'dEgdT', + 'irrad_ref', 'temp_ref'], self.module_parameters) - + return calcparams_desoto(effective_irradiance, temp_cell, **kwargs) - def calcparams_pvsyst(self, effective_irradiance, temp_cell, **kwargs): + def calcparams_pvsyst(self, effective_irradiance, temp_cell): """ Use the :py:func:`calcparams_pvsyst` function, the input parameters and ``self.module_parameters`` to calculate the @@ -321,20 +322,18 @@ def calcparams_pvsyst(self, effective_irradiance, temp_cell, **kwargs): temp_cell : float or Series The average cell temperature of cells within a module in C. - **kwargs - See pvsystem.calcparams_pvsyst for details - 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', + 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 calcparams_pvsyst(effective_irradiance, temp_cell, **kwargs) def sapm(self, effective_irradiance, temp_cell, **kwargs): @@ -492,7 +491,7 @@ def first_solar_spectral_loss(self, pw, airmass_absolute): coefficients = None return atmosphere.first_solar_spectral_correction(pw, - airmass_absolute, + airmass_absolute, module_type, coefficients) @@ -976,12 +975,12 @@ def physicaliam(aoi, n=1.526, K=4., L=0.002): def calcparams_desoto(effective_irradiance, temp_cell, - alpha_sc, a_ref, I_L_ref, I_o_ref, R_sh_ref, R_s, + alpha_sc, a_ref, I_L_ref, I_o_ref, R_sh_ref, R_s, EgRef=1.121, dEgdT=-0.0002677, irrad_ref=1000, temp_ref=25): ''' - Calculates five parameter values for the single diode equation at - effective irradiance and cell temperature using the De Soto et al. + Calculates five parameter values for the single diode equation at + effective irradiance and cell temperature using the De Soto et al. model described in [1]. The five values returned by calcparams_desoto can be used by singlediode to calculate an IV curve. @@ -998,34 +997,34 @@ def calcparams_desoto(effective_irradiance, temp_cell, module in units of A/C. a_ref : float - The product of the usual diode ideality factor (n, unitless), + The product of the usual diode ideality factor (n, unitless), number of cells in series (Ns), and cell thermal voltage at reference conditions, in units of V. I_L_ref : float The light-generated current (or photocurrent) at reference conditions, in amperes. - + I_o_ref : float The dark or diode reverse saturation current at reference conditions, in amperes. - + R_sh_ref : float The shunt resistance at reference conditions, in ohms. - + R_s : float The series resistance at reference conditions, in ohms. EgRef : float The energy bandgap at reference temperature in units of eV. - 1.121 eV for crystalline silicon. EgRef must be >0. For parameters + 1.121 eV for crystalline silicon. EgRef must be >0. For parameters from the SAM CEC module database, EgRef=1.121 is implicit for all cell types in the parameter estimation algorithm used by NREL. dEgdT : float The temperature dependence of the energy bandgap at reference - conditions in units of 1/K. May be either a scalar value - (e.g. -0.0002677 as in [1]) or a DataFrame (this may be useful if + conditions in units of 1/K. May be either a scalar value + (e.g. -0.0002677 as in [1]) or a DataFrame (this may be useful if dEgdT is a modeled as a function of temperature). For parameters from the SAM CEC module database, dEgdT=-0.0002677 is implicit for all cell types in the parameter estimation algorithm used by NREL. @@ -1053,8 +1052,8 @@ def calcparams_desoto(effective_irradiance, temp_cell, Shunt resistance in ohms nNsVth : numeric - The product of the usual diode ideality factor (n, unitless), - number of cells in series (Ns), and cell thermal voltage at + The product of the usual diode ideality factor (n, unitless), + number of cells in series (Ns), and cell thermal voltage at specified effective irradiance and cell temperature. References @@ -1164,7 +1163,7 @@ def calcparams_desoto(effective_irradiance, temp_cell, # Boltzmann constant in eV/K k = 8.617332478e-05 - + # reference temperature Tref_K = temp_ref + 273.15 Tcell_K = temp_cell + 273.15 @@ -1173,9 +1172,9 @@ def calcparams_desoto(effective_irradiance, temp_cell, nNsVth = a_ref * (Tcell_K / Tref_K) - # In the equation for IL, the single factor effective_irradiance is - # used, in place of the product S*M in [1]. effective_irradiance is - # equivalent to the product of S (irradiance reaching a module's cells) * + # In the equation for IL, the single factor effective_irradiance is + # used, in place of the product S*M in [1]. effective_irradiance is + # equivalent to the product of S (irradiance reaching a module's cells) * # M (spectral adjustment factor) as described in [1]. IL = effective_irradiance / irrad_ref * \ (I_L_ref + alpha_sc * (Tcell_K - Tref_K)) @@ -1185,7 +1184,7 @@ def calcparams_desoto(effective_irradiance, temp_cell, # Rsh = Rsh_ref * (S_ref / S) where S is broadband irradiance reaching # the module's cells. If desired this model behavior can be duplicated # by applying reflection and soiling losses to broadband plane of array - # irradiance and not applying a spectral loss modifier, i.e., + # irradiance and not applying a spectral loss modifier, i.e., # spectral_modifier = 1.0. Rsh = R_sh_ref * (irrad_ref / effective_irradiance) Rs = R_s @@ -1195,15 +1194,15 @@ def calcparams_desoto(effective_irradiance, temp_cell, def calcparams_pvsyst(effective_irradiance, temp_cell, alpha_sc, gamma_ref, mu_gamma, - I_L_ref, I_o_ref, - R_sh_ref, R_sh_0, R_s, + I_L_ref, I_o_ref, + R_sh_ref, R_sh_0, R_s, cells_in_series, R_sh_exp=5.5, EgRef=1.121, irrad_ref=1000, temp_ref=25): ''' - Calculates five parameter values for the single diode equation at - effective irradiance and cell temperature using the PVsyst v6 + Calculates five parameter values for the single diode equation at + effective irradiance and cell temperature using the PVsyst v6 model described in [1,2,3]. The five values returned by calcparams_pvsyst can be used by singlediode to calculate an IV curve. @@ -1228,17 +1227,17 @@ def calcparams_pvsyst(effective_irradiance, temp_cell, I_L_ref : float The light-generated current (or photocurrent) at reference conditions, in amperes. - + I_o_ref : float The dark or diode reverse saturation current at reference conditions, in amperes. - + R_sh_ref : float The shunt resistance at reference conditions, in ohms. - + R_sh_0 : float The shunt resistance at zero irradiance conditions, in ohms. - + R_s : float The series resistance at reference conditions, in ohms. @@ -1271,19 +1270,19 @@ def calcparams_pvsyst(effective_irradiance, temp_cell, resistance_series : float Series resistance in ohms - + resistance_shunt : numeric Shunt resistance in ohms nNsVth : numeric - The product of the usual diode ideality factor (n, unitless), - number of cells in series (Ns), and cell thermal voltage at + The product of the usual diode ideality factor (n, unitless), + number of cells in series (Ns), and cell thermal voltage at specified effective irradiance and cell temperature. References ---------- - [1] K. Sauer, T. Roessler, C. W. Hansen, Modeling the Irradiance and - Temperature Dependence of Photovoltaic Modules in PVsyst, + [1] K. Sauer, T. Roessler, C. W. Hansen, Modeling the Irradiance and + Temperature Dependence of Photovoltaic Modules in PVsyst, IEEE Journal of Photovoltaics v5(1), January 2015. [2] A. Mermoud, PV modules modelling, Presentation at the 2nd PV @@ -1297,7 +1296,7 @@ def calcparams_pvsyst(effective_irradiance, temp_cell, -------- calcparams_desoto singlediode - + ''' # Boltzmann constant in J/K @@ -1305,7 +1304,7 @@ def calcparams_pvsyst(effective_irradiance, temp_cell, # elementary charge in coulomb q = 1.6021766e-19 - + # reference temperature Tref_K = temp_ref + 273.15 Tcell_K = temp_cell + 273.15 @@ -1324,7 +1323,7 @@ def calcparams_pvsyst(effective_irradiance, temp_cell, Rsh = Rsh_base + (R_sh_0 - Rsh_base) * \ np.exp(-R_sh_exp * effective_irradiance / irrad_ref) - + Rs = R_s return IL, I0, Rs, Rsh, nNsVth From 632ff873ef2533c6b54b9b3c67fa8d009e81de16 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Fri, 6 Jul 2018 08:49:56 -0600 Subject: [PATCH 15/16] fix typo in Boltzmann constant J/K --- pvlib/pvsystem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index dcc983b1bb..9d3bea858b 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -1300,7 +1300,7 @@ def calcparams_pvsyst(effective_irradiance, temp_cell, ''' # Boltzmann constant in J/K - k = 1.3806488e-23 + k = 1.38064852e-23 # elementary charge in coulomb q = 1.6021766e-19 From 1295bcfa0be4106ef18c37a357a81a9d6fe2660d Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Fri, 6 Jul 2018 09:38:21 -0600 Subject: [PATCH 16/16] Remove scope=session from pvsyst fixture --- pvlib/test/test_pvsystem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/test/test_pvsystem.py b/pvlib/test/test_pvsystem.py index 46fd13c8e0..6931543824 100644 --- a/pvlib/test/test_pvsystem.py +++ b/pvlib/test/test_pvsystem.py @@ -174,7 +174,7 @@ def cec_module_params(sam_data): return module_parameters -@pytest.fixture(scope="session") +@pytest.fixture() def pvsyst_module_params(): module_parameters = {} module_parameters['gamma_ref'] = 1.05