15
15
from dataclasses import dataclass
16
16
from abc import ABC , abstractmethod
17
17
from typing import Optional
18
+ import pvlib .tools as tools
18
19
19
20
from pvlib ._deprecation import deprecated
20
21
@@ -934,15 +935,13 @@ def _spectral_correction(array, pw):
934
935
)
935
936
936
937
def singlediode (self , photocurrent , saturation_current ,
937
- resistance_series , resistance_shunt , nNsVth ,
938
- ivcurve_pnts = None ):
938
+ resistance_series , resistance_shunt , nNsVth ):
939
939
"""Wrapper around the :py:func:`pvlib.pvsystem.singlediode` function.
940
940
941
941
See :py:func:`pvsystem.singlediode` for details
942
942
"""
943
943
return singlediode (photocurrent , saturation_current ,
944
- resistance_series , resistance_shunt , nNsVth ,
945
- ivcurve_pnts = ivcurve_pnts )
944
+ resistance_series , resistance_shunt , nNsVth )
946
945
947
946
def i_from_v (self , resistance_shunt , resistance_series , nNsVth , voltage ,
948
947
saturation_current , photocurrent ):
@@ -2708,8 +2707,7 @@ def sapm_effective_irradiance(poa_direct, poa_diffuse, airmass_absolute, aoi,
2708
2707
2709
2708
2710
2709
def singlediode (photocurrent , saturation_current , resistance_series ,
2711
- resistance_shunt , nNsVth , ivcurve_pnts = None ,
2712
- method = 'lambertw' ):
2710
+ resistance_shunt , nNsVth , method = 'lambertw' ):
2713
2711
r"""
2714
2712
Solve the single-diode equation to obtain a photovoltaic IV curve.
2715
2713
@@ -2762,19 +2760,13 @@ def singlediode(photocurrent, saturation_current, resistance_series,
2762
2760
junction in Kelvin, and :math:`q` is the charge of an electron
2763
2761
(coulombs). ``0 < nNsVth``. [V]
2764
2762
2765
- ivcurve_pnts : None or int, default None
2766
- Number of points in the desired IV curve. If None or 0, no points on
2767
- the IV curves will be produced.
2768
-
2769
2763
method : str, default 'lambertw'
2770
2764
Determines the method used to calculate points on the IV curve. The
2771
2765
options are ``'lambertw'``, ``'newton'``, or ``'brentq'``.
2772
2766
2773
2767
Returns
2774
2768
-------
2775
- OrderedDict or DataFrame
2776
-
2777
- The returned dict-like object always contains the keys/columns:
2769
+ DataFrame with the columns:
2778
2770
2779
2771
* i_sc - short circuit current in amperes.
2780
2772
* v_oc - open circuit voltage in volts.
@@ -2784,18 +2776,6 @@ def singlediode(photocurrent, saturation_current, resistance_series,
2784
2776
* i_x - current, in amperes, at ``v = 0.5*v_oc``.
2785
2777
* i_xx - current, in amperes, at ``V = 0.5*(v_oc+v_mp)``.
2786
2778
2787
- If ivcurve_pnts is greater than 0, the output dictionary will also
2788
- include the keys:
2789
-
2790
- * i - IV curve current in amperes.
2791
- * v - IV curve voltage in volts.
2792
-
2793
- The output will be an OrderedDict if photocurrent is a scalar,
2794
- array, or ivcurve_pnts is not None.
2795
-
2796
- The output will be a DataFrame if photocurrent is a Series and
2797
- ivcurve_pnts is None.
2798
-
2799
2779
See also
2800
2780
--------
2801
2781
calcparams_desoto
@@ -2818,13 +2798,6 @@ def singlediode(photocurrent, saturation_current, resistance_series,
2818
2798
that guarantees convergence by bounding the voltage between zero and
2819
2799
open-circuit.
2820
2800
2821
- If the method is either ``'newton'`` or ``'brentq'`` and ``ivcurve_pnts``
2822
- are indicated, then :func:`pvlib.singlediode.bishop88` [4]_ is used to
2823
- calculate the points on the IV curve points at diode voltages from zero to
2824
- open-circuit voltage with a log spacing that gets closer as voltage
2825
- increases. If the method is ``'lambertw'`` then the calculated points on
2826
- the IV curve are linearly spaced.
2827
-
2828
2801
References
2829
2802
----------
2830
2803
.. [1] S.R. Wenham, M.A. Green, M.E. Watt, "Applied Photovoltaics" ISBN
@@ -2846,11 +2819,9 @@ def singlediode(photocurrent, saturation_current, resistance_series,
2846
2819
if method .lower () == 'lambertw' :
2847
2820
out = _singlediode ._lambertw (
2848
2821
photocurrent , saturation_current , resistance_series ,
2849
- resistance_shunt , nNsVth , ivcurve_pnts
2822
+ resistance_shunt , nNsVth
2850
2823
)
2851
- i_sc , v_oc , i_mp , v_mp , p_mp , i_x , i_xx = out [:7 ]
2852
- if ivcurve_pnts :
2853
- ivcurve_i , ivcurve_v = out [7 :]
2824
+ points = out [:7 ]
2854
2825
else :
2855
2826
# Calculate points on the IV curve using either 'newton' or 'brentq'
2856
2827
# methods. Voltages are determined by first solving the single diode
@@ -2872,32 +2843,20 @@ def singlediode(photocurrent, saturation_current, resistance_series,
2872
2843
i_xx = _singlediode .bishop88_i_from_v (
2873
2844
(v_oc + v_mp ) / 2.0 , * args , method = method .lower ()
2874
2845
)
2846
+ points = i_sc , v_oc , i_mp , v_mp , p_mp , i_x , i_xx
2875
2847
2876
- # calculate the IV curve if requested using bishop88
2877
- if ivcurve_pnts :
2878
- vd = v_oc * (
2879
- (11.0 - np .logspace (np .log10 (11.0 ), 0.0 , ivcurve_pnts )) / 10.0
2880
- )
2881
- ivcurve_i , ivcurve_v , _ = _singlediode .bishop88 (vd , * args )
2848
+ points = np .atleast_1d (* points ) # covert scalars to 1d arrays
2849
+ points = np .vstack (points ).T # create DataFrame rows
2882
2850
2883
- out = OrderedDict ()
2884
- out ['i_sc' ] = i_sc
2885
- out ['v_oc' ] = v_oc
2886
- out ['i_mp' ] = i_mp
2887
- out ['v_mp' ] = v_mp
2888
- out ['p_mp' ] = p_mp
2889
- out ['i_x' ] = i_x
2890
- out ['i_xx' ] = i_xx
2891
-
2892
- if ivcurve_pnts :
2893
-
2894
- out ['v' ] = ivcurve_v
2895
- out ['i' ] = ivcurve_i
2896
-
2897
- if isinstance (photocurrent , pd .Series ) and not ivcurve_pnts :
2898
- out = pd .DataFrame (out , index = photocurrent .index )
2851
+ index = None # keep pd.Series index, if available
2852
+ if isinstance (photocurrent , pd .Series ):
2853
+ index = photocurrent .index
2899
2854
2900
- return out
2855
+ return pd .DataFrame (
2856
+ points ,
2857
+ columns = ['i_sc' , 'v_oc' , 'i_mp' , 'v_mp' , 'p_mp' , 'i_x' , 'i_xx' ],
2858
+ index = index
2859
+ )
2901
2860
2902
2861
2903
2862
def max_power_point (photocurrent , saturation_current , resistance_series ,
0 commit comments