From 509ba3eb92177ac9ff7ab9f0a7aaad59902c2c4c Mon Sep 17 00:00:00 2001 From: Anton Driesse Date: Fri, 9 Aug 2019 17:33:45 +0200 Subject: [PATCH 01/12] Pass through extra recombination parameters to allow use in max_power_point(). --- pvlib/pvsystem.py | 6 ++++-- pvlib/singlediode.py | 9 +++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index f040b5f519..5b14ee55de 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -2473,7 +2473,8 @@ def singlediode(photocurrent, saturation_current, resistance_series, def max_power_point(photocurrent, saturation_current, resistance_series, - resistance_shunt, nNsVth, method='brentq'): + resistance_shunt, nNsVth, d2mutau=0, NsVbi=np.Inf, + method='brentq'): """ Given the single diode equation coefficients, calculates the maximum power point (MPP). @@ -2508,7 +2509,8 @@ def max_power_point(photocurrent, saturation_current, resistance_series, """ i_mp, v_mp, p_mp = _singlediode.bishop88_mpp( photocurrent, saturation_current, resistance_series, - resistance_shunt, nNsVth, method=method.lower() + resistance_shunt, nNsVth, d2mutau=0, NsVbi=np.Inf, + method=method.lower() ) if isinstance(photocurrent, pd.Series): ivp = {'i_mp': i_mp, 'v_mp': v_mp, 'p_mp': p_mp} diff --git a/pvlib/singlediode.py b/pvlib/singlediode.py index 49f1f4ebe3..edb676e608 100644 --- a/pvlib/singlediode.py +++ b/pvlib/singlediode.py @@ -295,7 +295,8 @@ def vd_from_brent(voc, i, iph, isat, rs, rsh, gamma): def bishop88_mpp(photocurrent, saturation_current, resistance_series, - resistance_shunt, nNsVth, method='newton'): + resistance_shunt, nNsVth, d2mutau=0, NsVbi=np.Inf, + method='newton'): """ Find max power point. @@ -324,7 +325,7 @@ def bishop88_mpp(photocurrent, saturation_current, resistance_series, """ # collect args args = (photocurrent, saturation_current, resistance_series, - resistance_shunt, nNsVth) + resistance_shunt, nNsVth, d2mutau, NsVbi) # first bound the search using voc voc_est = estimate_voc(photocurrent, saturation_current, nNsVth) @@ -334,8 +335,8 @@ def fmpp(x, *a): if method.lower() == 'brentq': # break out arguments for numpy.vectorize to handle broadcasting vec_fun = np.vectorize( - lambda voc, iph, isat, rs, rsh, gamma: - brentq(fmpp, 0.0, voc, args=(iph, isat, rs, rsh, gamma)) + lambda voc, iph, isat, rs, rsh, gamma, d2mutau, NsVbi: + brentq(fmpp, 0.0, voc, args=(iph, isat, rs, rsh, gamma, d2mutau, NsVbi)) ) vd = vec_fun(voc_est, *args) elif method.lower() == 'newton': From f4f4fe0f0c2c9eff661f7e141249095e17a99626 Mon Sep 17 00:00:00 2001 From: Anton Driesse Date: Tue, 13 Aug 2019 21:59:09 +0200 Subject: [PATCH 02/12] Add recombination current parameters to the other bishop88 functions. --- pvlib/pvsystem.py | 8 ++++++++ pvlib/singlediode.py | 45 +++++++++++++++++++++++++++++++++++--------- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 5b14ee55de..1d24ffe30e 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -2492,6 +2492,14 @@ def max_power_point(photocurrent, saturation_current, resistance_series, nNsVth : numeric product of thermal voltage ``Vth`` [V], diode ideality factor ``n``, and number of serices cells ``Ns`` + d2mutau : numeric + PVSyst thin-film recombination parameter that is the ratio of thickness + of the intrinsic layer squared :math:`d^2` and the diffusion length of + charge carriers :math:`\\mu \\tau`, in volts [V], defaults to 0[V] + NsVbi : numeric + PVSyst thin-film recombination parameter that is the product of the PV + module number of series cells ``Ns`` and the builtin voltage ``Vbi`` of + the intrinsic layer, in volts [V], defaults to ``np.inf`` method : str either ``'newton'`` or ``'brentq'`` diff --git a/pvlib/singlediode.py b/pvlib/singlediode.py index edb676e608..e29e6fc1bb 100644 --- a/pvlib/singlediode.py +++ b/pvlib/singlediode.py @@ -173,7 +173,7 @@ def bishop88(diode_voltage, photocurrent, saturation_current, def bishop88_i_from_v(voltage, photocurrent, saturation_current, resistance_series, resistance_shunt, nNsVth, - method='newton'): + d2mutau=0, NsVbi=np.Inf, method='newton'): """ Find current given any voltage. @@ -192,6 +192,14 @@ def bishop88_i_from_v(voltage, photocurrent, saturation_current, nNsVth : numeric product of diode ideality factor (n), number of series cells (Ns), and thermal voltage (Vth = k_b * T / q_e) in volts [V] + d2mutau : numeric + PVSyst thin-film recombination parameter that is the ratio of thickness + of the intrinsic layer squared :math:`d^2` and the diffusion length of + charge carriers :math:`\\mu \\tau`, in volts [V], defaults to 0[V] + NsVbi : numeric + PVSyst thin-film recombination parameter that is the product of the PV + module number of series cells ``Ns`` and the builtin voltage ``Vbi`` of + the intrinsic layer, in volts [V], defaults to ``np.inf`` method : str one of two optional search methods: either ``'brentq'``, a reliable and bounded method or ``'newton'`` which is the default. @@ -203,7 +211,7 @@ def bishop88_i_from_v(voltage, photocurrent, saturation_current, """ # collect args args = (photocurrent, saturation_current, resistance_series, - resistance_shunt, nNsVth) + resistance_shunt, nNsVth, d2mutau, NsVbi) def fv(x, v, *a): # calculate voltage residual given diode voltage "x" @@ -216,8 +224,9 @@ def fv(x, v, *a): # brentq only works with scalar inputs, so we need a set up function # and np.vectorize to repeatedly call the optimizer with the right # arguments for possible array input - def vd_from_brent(voc, v, iph, isat, rs, rsh, gamma): - return brentq(fv, 0.0, voc, args=(v, iph, isat, rs, rsh, gamma)) + def vd_from_brent(voc, v, iph, isat, rs, rsh, gamma, d2mutau, NsVbi): + return brentq(fv, 0.0, voc, + args=(v, iph, isat, rs, rsh, gamma, d2mutau, NsVbi)) vd_from_brent_vectorized = np.vectorize(vd_from_brent) vd = vd_from_brent_vectorized(voc_est, voltage, *args) @@ -235,7 +244,7 @@ def vd_from_brent(voc, v, iph, isat, rs, rsh, gamma): def bishop88_v_from_i(current, photocurrent, saturation_current, resistance_series, resistance_shunt, nNsVth, - method='newton'): + d2mutau=0, NsVbi=np.Inf, method='newton'): """ Find voltage given any current. @@ -254,6 +263,14 @@ def bishop88_v_from_i(current, photocurrent, saturation_current, nNsVth : numeric product of diode ideality factor (n), number of series cells (Ns), and thermal voltage (Vth = k_b * T / q_e) in volts [V] + d2mutau : numeric + PVSyst thin-film recombination parameter that is the ratio of thickness + of the intrinsic layer squared :math:`d^2` and the diffusion length of + charge carriers :math:`\\mu \\tau`, in volts [V], defaults to 0[V] + NsVbi : numeric + PVSyst thin-film recombination parameter that is the product of the PV + module number of series cells ``Ns`` and the builtin voltage ``Vbi`` of + the intrinsic layer, in volts [V], defaults to ``np.inf`` method : str one of two optional search methods: either ``'brentq'``, a reliable and bounded method or ``'newton'`` which is the default. @@ -265,7 +282,7 @@ def bishop88_v_from_i(current, photocurrent, saturation_current, """ # collect args args = (photocurrent, saturation_current, resistance_series, - resistance_shunt, nNsVth) + resistance_shunt, nNsVth, d2mutau, NsVbi) # first bound the search using voc voc_est = estimate_voc(photocurrent, saturation_current, nNsVth) @@ -277,8 +294,9 @@ def fi(x, i, *a): # brentq only works with scalar inputs, so we need a set up function # and np.vectorize to repeatedly call the optimizer with the right # arguments for possible array input - def vd_from_brent(voc, i, iph, isat, rs, rsh, gamma): - return brentq(fi, 0.0, voc, args=(i, iph, isat, rs, rsh, gamma)) + def vd_from_brent(voc, i, iph, isat, rs, rsh, gamma, d2mutau, NsVbi): + return brentq(fi, 0.0, voc, + args=(i, iph, isat, rs, rsh, gamma, d2mutau, NsVbi)) vd_from_brent_vectorized = np.vectorize(vd_from_brent) vd = vd_from_brent_vectorized(voc_est, current, *args) @@ -313,6 +331,14 @@ def bishop88_mpp(photocurrent, saturation_current, resistance_series, nNsVth : numeric product of diode ideality factor (n), number of series cells (Ns), and thermal voltage (Vth = k_b * T / q_e) in volts [V] + d2mutau : numeric + PVSyst thin-film recombination parameter that is the ratio of thickness + of the intrinsic layer squared :math:`d^2` and the diffusion length of + charge carriers :math:`\\mu \\tau`, in volts [V], defaults to 0[V] + NsVbi : numeric + PVSyst thin-film recombination parameter that is the product of the PV + module number of series cells ``Ns`` and the builtin voltage ``Vbi`` of + the intrinsic layer, in volts [V], defaults to ``np.inf`` method : str one of two optional search methods: either ``'brentq'``, a reliable and bounded method or ``'newton'`` which is the default. @@ -336,7 +362,8 @@ def fmpp(x, *a): # break out arguments for numpy.vectorize to handle broadcasting vec_fun = np.vectorize( lambda voc, iph, isat, rs, rsh, gamma, d2mutau, NsVbi: - brentq(fmpp, 0.0, voc, args=(iph, isat, rs, rsh, gamma, d2mutau, NsVbi)) + brentq(fmpp, 0.0, voc, + args=(iph, isat, rs, rsh, gamma, d2mutau, NsVbi)) ) vd = vec_fun(voc_est, *args) elif method.lower() == 'newton': From cbb78ac1fe9e04495863bae3f6359c5476536a7a Mon Sep 17 00:00:00 2001 From: Anton Driesse Date: Tue, 13 Aug 2019 22:16:40 +0200 Subject: [PATCH 03/12] Update whatsnew. --- docs/sphinx/source/whatsnew/v0.7.0.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/sphinx/source/whatsnew/v0.7.0.rst b/docs/sphinx/source/whatsnew/v0.7.0.rst index 505bd00825..3e37bf47db 100644 --- a/docs/sphinx/source/whatsnew/v0.7.0.rst +++ b/docs/sphinx/source/whatsnew/v0.7.0.rst @@ -14,6 +14,8 @@ Enhancements ~~~~~~~~~~~~ * Created two new incidence angle modifier functions: :py:func:`pvlib.pvsystem.iam_martin_ruiz` and :py:func:`pvlib.pvsystem.iam_interp`. (:issue:`751`) +* Added recombination current parameters to bishop88 single-diode functions and also + to :py:func:`pvlib.pvsystem.max_power_point`. (:issue:`762`) Bug fixes ~~~~~~~~~ From 22637f8e30dd67f712e6fbf6f11765cb0567eb72 Mon Sep 17 00:00:00 2001 From: Anton Driesse Date: Tue, 13 Aug 2019 23:28:29 +0200 Subject: [PATCH 04/12] Add tests. --- pvlib/test/test_singlediode.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pvlib/test/test_singlediode.py b/pvlib/test/test_singlediode.py index 4ff7bc445f..44f74bc601 100644 --- a/pvlib/test/test_singlediode.py +++ b/pvlib/test/test_singlediode.py @@ -4,7 +4,8 @@ import numpy as np from pvlib import pvsystem -from pvlib.singlediode import bishop88, estimate_voc, VOLTAGE_BUILTIN +from pvlib.singlediode import (bishop88_mpp, estimate_voc, VOLTAGE_BUILTIN, + bishop88, bishop88_i_from_v, bishop88_v_from_i) import pytest from conftest import requires_scipy @@ -205,3 +206,16 @@ def test_pvsyst_recombination_loss(poa, temp_cell, expected, tol): # test open circuit current 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) + assert np.isclose(mpp_88[2], expected['pmp'], *tol) + + isc_88 = bishop88_i_from_v(0, *x, **y) + assert np.isclose(isc_88, expected['isc'], *tol) + + voc_88 = bishop88_v_from_i(0, *x, **y) + assert np.isclose(voc_88, expected['voc'], *tol) From c20fa3ef387ad26677a2ba550103c6d5daf2c4a3 Mon Sep 17 00:00:00 2001 From: Anton Driesse Date: Wed, 14 Aug 2019 12:35:30 +0200 Subject: [PATCH 05/12] Tests for both newton and brentq, and some formatting. --- pvlib/test/test_singlediode.py | 50 ++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/pvlib/test/test_singlediode.py b/pvlib/test/test_singlediode.py index 44f74bc601..c0388f10f4 100644 --- a/pvlib/test/test_singlediode.py +++ b/pvlib/test/test_singlediode.py @@ -154,9 +154,11 @@ def get_pvsyst_fs_495(): 'temp_ref': 25, 'irrad_ref': 1000, 'I_L_ref': 1.5743233463848496 } +# DeSoto @(888[W/m**2], 55[degC]) = {Pmp: 72.71, Isc: 1.402, Voc: 75.42) @pytest.mark.parametrize( 'poa, temp_cell, expected, tol', [ + # reference conditions ( get_pvsyst_fs_495()['irrad_ref'], get_pvsyst_fs_495()['temp_ref'], @@ -168,8 +170,19 @@ def get_pvsyst_fs_495(): }, (5e-4, 0.04) ), - (POA, TCELL, {'pmp': 76.26, 'isc': 1.387, 'voc': 79.29}, (1e-3, 1e-3))] -) # DeSoto @(888[W/m**2], 55[degC]) = {Pmp: 72.71, Isc: 1.402, Voc: 75.42) + # other conditions + ( + POA, + TCELL, + { + 'pmp': 76.262, + 'isc': 1.3868, + 'voc': 79.292 + }, + (1e-4, 1e-4) + ) + ] +) def test_pvsyst_recombination_loss(poa, temp_cell, expected, tol): """test PVSst recombination loss""" pvsyst_fs_495 = get_pvsyst_fs_495() @@ -200,10 +213,12 @@ def test_pvsyst_recombination_loss(poa, temp_cell, expected, tol): ) # 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 + + # test open circuit voltage voc_pvsyst = np.interp(0, pvsyst[0][::-1], pvsyst[1][::-1]) assert np.isclose(voc_pvsyst, expected['voc'], *tol) @@ -211,11 +226,34 @@ def test_pvsyst_recombination_loss(poa, temp_cell, expected, tol): y = dict(d2mutau=pvsyst_fs_495['d2mutau'], NsVbi=VOLTAGE_BUILTIN*pvsyst_fs_495['cells_in_series']) - mpp_88 = bishop88_mpp(*x, **y) + mpp_88 = bishop88_mpp(*x, **y, method='newton') + assert np.isclose(mpp_88[2], expected['pmp'], *tol) + + isc_88 = bishop88_i_from_v(0, *x, **y, method='newton') + assert np.isclose(isc_88, expected['isc'], *tol) + + voc_88 = bishop88_v_from_i(0, *x, **y, method='newton') + assert np.isclose(voc_88, expected['voc'], *tol) + + ioc_88 = bishop88_i_from_v(voc_88, *x, **y, method='newton') + assert np.isclose(ioc_88, 0.0, *tol) + + vsc_88 = bishop88_v_from_i(isc_88, *x, **y, method='newton') + assert np.isclose(vsc_88, 0.0, *tol) + + # now repeat with brentq + mpp_88 = bishop88_mpp(*x, **y, method='brentq') assert np.isclose(mpp_88[2], expected['pmp'], *tol) - isc_88 = bishop88_i_from_v(0, *x, **y) + isc_88 = bishop88_i_from_v(0, *x, **y, method='brentq') assert np.isclose(isc_88, expected['isc'], *tol) - voc_88 = bishop88_v_from_i(0, *x, **y) + voc_88 = bishop88_v_from_i(0, *x, **y, method='brentq') assert np.isclose(voc_88, expected['voc'], *tol) + + ioc_88 = bishop88_i_from_v(voc_88, *x, **y, method='brentq') + assert np.isclose(ioc_88, 0.0, *tol) + + vsc_88 = bishop88_v_from_i(isc_88, *x, **y, method='brentq') + assert np.isclose(vsc_88, 0.0, *tol) + From 149ebfef1ba01d75781f841618a5d7b6a9d8485e Mon Sep 17 00:00:00 2001 From: Anton Driesse Date: Wed, 14 Aug 2019 13:02:57 +0200 Subject: [PATCH 06/12] Delete blank line. --- pvlib/test/test_singlediode.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pvlib/test/test_singlediode.py b/pvlib/test/test_singlediode.py index c0388f10f4..6cc61e245c 100644 --- a/pvlib/test/test_singlediode.py +++ b/pvlib/test/test_singlediode.py @@ -256,4 +256,3 @@ def test_pvsyst_recombination_loss(poa, temp_cell, expected, tol): vsc_88 = bishop88_v_from_i(isc_88, *x, **y, method='brentq') assert np.isclose(vsc_88, 0.0, *tol) - From f603461c72fd3bddd67043c202954b846323428c Mon Sep 17 00:00:00 2001 From: Anton Driesse Date: Wed, 14 Aug 2019 21:33:29 +0200 Subject: [PATCH 07/12] Add scipy requirement triggered by brentq tests. --- pvlib/test/test_singlediode.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pvlib/test/test_singlediode.py b/pvlib/test/test_singlediode.py index 6cc61e245c..b42582689b 100644 --- a/pvlib/test/test_singlediode.py +++ b/pvlib/test/test_singlediode.py @@ -156,6 +156,7 @@ def get_pvsyst_fs_495(): # DeSoto @(888[W/m**2], 55[degC]) = {Pmp: 72.71, Isc: 1.402, Voc: 75.42) +@requires_scipy @pytest.mark.parametrize( 'poa, temp_cell, expected, tol', [ # reference conditions From 309c87aac8fac9fb222dbb708f4a93edd433f5b0 Mon Sep 17 00:00:00 2001 From: Anton Driesse Date: Wed, 14 Aug 2019 21:48:17 +0200 Subject: [PATCH 08/12] Add blank line. --- pvlib/test/test_singlediode.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pvlib/test/test_singlediode.py b/pvlib/test/test_singlediode.py index b42582689b..b6893e55b5 100644 --- a/pvlib/test/test_singlediode.py +++ b/pvlib/test/test_singlediode.py @@ -156,6 +156,7 @@ def get_pvsyst_fs_495(): # DeSoto @(888[W/m**2], 55[degC]) = {Pmp: 72.71, Isc: 1.402, Voc: 75.42) + @requires_scipy @pytest.mark.parametrize( 'poa, temp_cell, expected, tol', [ From dddc4cd0775b5afc249e11bafc7867d0d7b24b05 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Mon, 26 Aug 2019 15:02:12 -0600 Subject: [PATCH 09/12] docstring edits --- pvlib/pvsystem.py | 19 ++++++----- pvlib/singlediode.py | 80 +++++++++++++++++++++++++------------------- 2 files changed, 57 insertions(+), 42 deletions(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 1d24ffe30e..4158512887 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -2492,14 +2492,17 @@ def max_power_point(photocurrent, saturation_current, resistance_series, nNsVth : numeric product of thermal voltage ``Vth`` [V], diode ideality factor ``n``, and number of serices cells ``Ns`` - d2mutau : numeric - PVSyst thin-film recombination parameter that is the ratio of thickness - of the intrinsic layer squared :math:`d^2` and the diffusion length of - charge carriers :math:`\\mu \\tau`, in volts [V], defaults to 0[V] - NsVbi : numeric - PVSyst thin-film recombination parameter that is the product of the PV - module number of series cells ``Ns`` and the builtin voltage ``Vbi`` of - the intrinsic layer, in volts [V], defaults to ``np.inf`` + d2mutau : numeric, default 0 + PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon ' + '(a-Si) modules that accounts for recombination current in the ' + 'intrinsic layer. The value is the ratio of instrinsic layer thickness' + ' squared :math:`d^2` to the diffusion length of charge carriers ' + ':math:`\\mu \\tau`. [V] + NsVbi : numeric, default np.inf + PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon ' + '(a-Si) modules that is the product of the PV module number of series ' + 'cells ``Ns`` and the builtin voltage ``Vbi`` of the intrinsic layer.' + '[V]'. method : str either ``'newton'`` or ``'brentq'`` diff --git a/pvlib/singlediode.py b/pvlib/singlediode.py index e29e6fc1bb..d1fce981f0 100644 --- a/pvlib/singlediode.py +++ b/pvlib/singlediode.py @@ -94,14 +94,17 @@ def bishop88(diode_voltage, photocurrent, saturation_current, nNsVth : numeric product of thermal voltage ``Vth`` [V], diode ideality factor ``n``, and number of series cells ``Ns`` - d2mutau : numeric - PVSyst thin-film recombination parameter that is the ratio of thickness - of the intrinsic layer squared :math:`d^2` and the diffusion length of - charge carriers :math:`\\mu \\tau`, in volts [V], defaults to 0[V] - NsVbi : numeric - PVSyst thin-film recombination parameter that is the product of the PV - module number of series cells ``Ns`` and the builtin voltage ``Vbi`` of - the intrinsic layer, in volts [V], defaults to ``np.inf`` + d2mutau : numeric, default 0 + PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon ' + '(a-Si) modules that accounts for recombination current in the ' + 'intrinsic layer. The value is the ratio of instrinsic layer thickness' + ' squared :math:`d^2` to the diffusion length of charge carriers ' + ':math:`\\mu \\tau`. [V] + NsVbi : numeric, default np.inf + PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon ' + '(a-Si) modules that is the product of the PV module number of series ' + 'cells ``Ns`` and the builtin voltage ``Vbi`` of the intrinsic layer.' + '[V]' gradients : bool False returns only I, V, and P. True also returns gradients @@ -116,8 +119,8 @@ def bishop88(diode_voltage, photocurrent, saturation_current, Notes ----- The PVSyst thin-film recombination losses parameters ``d2mutau`` and - ``NsVbi`` are only applied to cadmium-telluride (CdTe) and amorphous- - silicon (a:Si) PV modules, [2]_, [3]_. The builtin voltage :math:`V_{bi}` + ``NsVbi`` should only be applied to cadmium-telluride (CdTe) and amorphous- + silicon (a-Si) PV modules, [2]_, [3]_. The builtin voltage :math:`V_{bi}` should account for all junctions. For example: tandem and triple junction cells would have builtin voltages of 1.8[V] and 2.7[V] respectively, based on the default of 0.9[V] for a single junction. The parameter ``NsVbi`` @@ -192,14 +195,17 @@ def bishop88_i_from_v(voltage, photocurrent, saturation_current, nNsVth : numeric product of diode ideality factor (n), number of series cells (Ns), and thermal voltage (Vth = k_b * T / q_e) in volts [V] - d2mutau : numeric - PVSyst thin-film recombination parameter that is the ratio of thickness - of the intrinsic layer squared :math:`d^2` and the diffusion length of - charge carriers :math:`\\mu \\tau`, in volts [V], defaults to 0[V] - NsVbi : numeric - PVSyst thin-film recombination parameter that is the product of the PV - module number of series cells ``Ns`` and the builtin voltage ``Vbi`` of - the intrinsic layer, in volts [V], defaults to ``np.inf`` + d2mutau : numeric, default 0 + PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon ' + '(a-Si) modules that accounts for recombination current in the ' + 'intrinsic layer. The value is the ratio of instrinsic layer thickness' + ' squared :math:`d^2` to the diffusion length of charge carriers ' + ':math:`\\mu \\tau`. [V] + NsVbi : numeric, default np.inf + PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon ' + '(a-Si) modules that is the product of the PV module number of series ' + 'cells ``Ns`` and the builtin voltage ``Vbi`` of the intrinsic layer.' + '[V]' method : str one of two optional search methods: either ``'brentq'``, a reliable and bounded method or ``'newton'`` which is the default. @@ -263,14 +269,17 @@ def bishop88_v_from_i(current, photocurrent, saturation_current, nNsVth : numeric product of diode ideality factor (n), number of series cells (Ns), and thermal voltage (Vth = k_b * T / q_e) in volts [V] - d2mutau : numeric - PVSyst thin-film recombination parameter that is the ratio of thickness - of the intrinsic layer squared :math:`d^2` and the diffusion length of - charge carriers :math:`\\mu \\tau`, in volts [V], defaults to 0[V] - NsVbi : numeric - PVSyst thin-film recombination parameter that is the product of the PV - module number of series cells ``Ns`` and the builtin voltage ``Vbi`` of - the intrinsic layer, in volts [V], defaults to ``np.inf`` + d2mutau : numeric, default 0 + PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon ' + '(a-Si) modules that accounts for recombination current in the ' + 'intrinsic layer. The value is the ratio of instrinsic layer thickness' + ' squared :math:`d^2` to the diffusion length of charge carriers ' + ':math:`\\mu \\tau`. [V] + NsVbi : numeric, default np.inf + PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon ' + '(a-Si) modules that is the product of the PV module number of series ' + 'cells ``Ns`` and the builtin voltage ``Vbi`` of the intrinsic layer.' + '[V]' method : str one of two optional search methods: either ``'brentq'``, a reliable and bounded method or ``'newton'`` which is the default. @@ -331,14 +340,17 @@ def bishop88_mpp(photocurrent, saturation_current, resistance_series, nNsVth : numeric product of diode ideality factor (n), number of series cells (Ns), and thermal voltage (Vth = k_b * T / q_e) in volts [V] - d2mutau : numeric - PVSyst thin-film recombination parameter that is the ratio of thickness - of the intrinsic layer squared :math:`d^2` and the diffusion length of - charge carriers :math:`\\mu \\tau`, in volts [V], defaults to 0[V] - NsVbi : numeric - PVSyst thin-film recombination parameter that is the product of the PV - module number of series cells ``Ns`` and the builtin voltage ``Vbi`` of - the intrinsic layer, in volts [V], defaults to ``np.inf`` + d2mutau : numeric, default 0 + PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon ' + '(a-Si) modules that accounts for recombination current in the ' + 'intrinsic layer. The value is the ratio of instrinsic layer thickness' + ' squared :math:`d^2` to the diffusion length of charge carriers ' + ':math:`\\mu \\tau`. [V] + NsVbi : numeric, default np.inf + PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon ' + '(a-Si) modules that is the product of the PV module number of series ' + 'cells ``Ns`` and the builtin voltage ``Vbi`` of the intrinsic layer.' + '[V]' method : str one of two optional search methods: either ``'brentq'``, a reliable and bounded method or ``'newton'`` which is the default. From 5ad5241a859404acae4622cea53c9771e5f8e2a2 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Tue, 27 Aug 2019 16:00:16 -0600 Subject: [PATCH 10/12] redo docstring edits --- pvlib/pvsystem.py | 18 +++++------ pvlib/singlediode.py | 72 ++++++++++++++++++++++---------------------- 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 4158512887..d5a0456df4 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -2493,16 +2493,16 @@ def max_power_point(photocurrent, saturation_current, resistance_series, product of thermal voltage ``Vth`` [V], diode ideality factor ``n``, and number of serices cells ``Ns`` d2mutau : numeric, default 0 - PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon ' - '(a-Si) modules that accounts for recombination current in the ' - 'intrinsic layer. The value is the ratio of instrinsic layer thickness' - ' squared :math:`d^2` to the diffusion length of charge carriers ' - ':math:`\\mu \\tau`. [V] + PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon + (a-Si) modules that accounts for recombination current in the + intrinsic layer. The value is the ratio of intrinsic layer thickness + squared :math:`d^2` to the diffusion length of charge carriers + :math:`\\mu \\tau`. [V] NsVbi : numeric, default np.inf - PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon ' - '(a-Si) modules that is the product of the PV module number of series ' - 'cells ``Ns`` and the builtin voltage ``Vbi`` of the intrinsic layer.' - '[V]'. + PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon + (a-Si) modules that is the product of the PV module number of series + cells ``Ns`` and the builtin voltage ``Vbi`` of the intrinsic layer. + [V]. method : str either ``'newton'`` or ``'brentq'`` diff --git a/pvlib/singlediode.py b/pvlib/singlediode.py index d1fce981f0..d466c778ce 100644 --- a/pvlib/singlediode.py +++ b/pvlib/singlediode.py @@ -95,16 +95,16 @@ def bishop88(diode_voltage, photocurrent, saturation_current, product of thermal voltage ``Vth`` [V], diode ideality factor ``n``, and number of series cells ``Ns`` d2mutau : numeric, default 0 - PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon ' - '(a-Si) modules that accounts for recombination current in the ' - 'intrinsic layer. The value is the ratio of instrinsic layer thickness' - ' squared :math:`d^2` to the diffusion length of charge carriers ' - ':math:`\\mu \\tau`. [V] + PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon + (a-Si) modules that accounts for recombination current in the + intrinsic layer. The value is the ratio of intrinsic layer thickness + squared :math:`d^2` to the diffusion length of charge carriers + :math:`\\mu \\tau`. [V] NsVbi : numeric, default np.inf - PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon ' - '(a-Si) modules that is the product of the PV module number of series ' - 'cells ``Ns`` and the builtin voltage ``Vbi`` of the intrinsic layer.' - '[V]' + PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon + (a-Si) modules that is the product of the PV module number of series + cells ``Ns`` and the builtin voltage ``Vbi`` of the intrinsic layer. + [V]. gradients : bool False returns only I, V, and P. True also returns gradients @@ -196,16 +196,16 @@ def bishop88_i_from_v(voltage, photocurrent, saturation_current, product of diode ideality factor (n), number of series cells (Ns), and thermal voltage (Vth = k_b * T / q_e) in volts [V] d2mutau : numeric, default 0 - PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon ' - '(a-Si) modules that accounts for recombination current in the ' - 'intrinsic layer. The value is the ratio of instrinsic layer thickness' - ' squared :math:`d^2` to the diffusion length of charge carriers ' - ':math:`\\mu \\tau`. [V] + PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon + (a-Si) modules that accounts for recombination current in the + intrinsic layer. The value is the ratio of intrinsic layer thickness + squared :math:`d^2` to the diffusion length of charge carriers + :math:`\\mu \\tau`. [V] NsVbi : numeric, default np.inf - PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon ' - '(a-Si) modules that is the product of the PV module number of series ' - 'cells ``Ns`` and the builtin voltage ``Vbi`` of the intrinsic layer.' - '[V]' + PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon + (a-Si) modules that is the product of the PV module number of series + cells ``Ns`` and the builtin voltage ``Vbi`` of the intrinsic layer. + [V]. method : str one of two optional search methods: either ``'brentq'``, a reliable and bounded method or ``'newton'`` which is the default. @@ -270,16 +270,16 @@ def bishop88_v_from_i(current, photocurrent, saturation_current, product of diode ideality factor (n), number of series cells (Ns), and thermal voltage (Vth = k_b * T / q_e) in volts [V] d2mutau : numeric, default 0 - PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon ' - '(a-Si) modules that accounts for recombination current in the ' - 'intrinsic layer. The value is the ratio of instrinsic layer thickness' - ' squared :math:`d^2` to the diffusion length of charge carriers ' - ':math:`\\mu \\tau`. [V] + PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon + (a-Si) modules that accounts for recombination current in the + intrinsic layer. The value is the ratio of intrinsic layer thickness + squared :math:`d^2` to the diffusion length of charge carriers + :math:`\\mu \\tau`. [V] NsVbi : numeric, default np.inf - PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon ' - '(a-Si) modules that is the product of the PV module number of series ' - 'cells ``Ns`` and the builtin voltage ``Vbi`` of the intrinsic layer.' - '[V]' + PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon + (a-Si) modules that is the product of the PV module number of series + cells ``Ns`` and the builtin voltage ``Vbi`` of the intrinsic layer. + [V]. method : str one of two optional search methods: either ``'brentq'``, a reliable and bounded method or ``'newton'`` which is the default. @@ -341,16 +341,16 @@ def bishop88_mpp(photocurrent, saturation_current, resistance_series, product of diode ideality factor (n), number of series cells (Ns), and thermal voltage (Vth = k_b * T / q_e) in volts [V] d2mutau : numeric, default 0 - PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon ' - '(a-Si) modules that accounts for recombination current in the ' - 'intrinsic layer. The value is the ratio of instrinsic layer thickness' - ' squared :math:`d^2` to the diffusion length of charge carriers ' - ':math:`\\mu \\tau`. [V] + PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon + (a-Si) modules that accounts for recombination current in the + intrinsic layer. The value is the ratio of intrinsic layer thickness + squared :math:`d^2` to the diffusion length of charge carriers + :math:`\\mu \\tau`. [V] NsVbi : numeric, default np.inf - PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon ' - '(a-Si) modules that is the product of the PV module number of series ' - 'cells ``Ns`` and the builtin voltage ``Vbi`` of the intrinsic layer.' - '[V]' + PVsyst parameter for cadmium-telluride (CdTe) and amorphous-silicon + (a-Si) modules that is the product of the PV module number of series + cells ``Ns`` and the builtin voltage ``Vbi`` of the intrinsic layer. + [V]. method : str one of two optional search methods: either ``'brentq'``, a reliable and bounded method or ``'newton'`` which is the default. From 1e3f8d6e7b59bc8361269bf38ff23dd53912da9e Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Tue, 27 Aug 2019 19:16:13 -0600 Subject: [PATCH 11/12] add parameterize --- pvlib/test/test_singlediode.py | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/pvlib/test/test_singlediode.py b/pvlib/test/test_singlediode.py index b6893e55b5..e5ee175101 100644 --- a/pvlib/test/test_singlediode.py +++ b/pvlib/test/test_singlediode.py @@ -185,7 +185,10 @@ def get_pvsyst_fs_495(): ) ] ) -def test_pvsyst_recombination_loss(poa, temp_cell, expected, tol): + + +@pytest.mark.parametrize('method', ['newton', 'brentq']) +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 @@ -228,33 +231,17 @@ def test_pvsyst_recombination_loss(poa, temp_cell, expected, tol): y = dict(d2mutau=pvsyst_fs_495['d2mutau'], NsVbi=VOLTAGE_BUILTIN*pvsyst_fs_495['cells_in_series']) - mpp_88 = bishop88_mpp(*x, **y, method='newton') - assert np.isclose(mpp_88[2], expected['pmp'], *tol) - - isc_88 = bishop88_i_from_v(0, *x, **y, method='newton') - assert np.isclose(isc_88, expected['isc'], *tol) - - voc_88 = bishop88_v_from_i(0, *x, **y, method='newton') - assert np.isclose(voc_88, expected['voc'], *tol) - - ioc_88 = bishop88_i_from_v(voc_88, *x, **y, method='newton') - assert np.isclose(ioc_88, 0.0, *tol) - - vsc_88 = bishop88_v_from_i(isc_88, *x, **y, method='newton') - assert np.isclose(vsc_88, 0.0, *tol) - - # now repeat with brentq - mpp_88 = bishop88_mpp(*x, **y, method='brentq') + 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='brentq') + 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='brentq') + 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='brentq') + 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='brentq') + vsc_88 = bishop88_v_from_i(isc_88, *x, **y, method=method) assert np.isclose(vsc_88, 0.0, *tol) From 581a427823f542fd1f0178894d3bcca8e5d5922e Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Wed, 28 Aug 2019 10:08:52 -0600 Subject: [PATCH 12/12] remove blank lines --- pvlib/test/test_singlediode.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pvlib/test/test_singlediode.py b/pvlib/test/test_singlediode.py index e5ee175101..c2c556cb23 100644 --- a/pvlib/test/test_singlediode.py +++ b/pvlib/test/test_singlediode.py @@ -185,8 +185,6 @@ def get_pvsyst_fs_495(): ) ] ) - - @pytest.mark.parametrize('method', ['newton', 'brentq']) def test_pvsyst_recombination_loss(method, poa, temp_cell, expected, tol): """test PVSst recombination loss"""