@@ -934,15 +934,13 @@ def _spectral_correction(array, pw):
934
934
)
935
935
936
936
def singlediode (self , photocurrent , saturation_current ,
937
- resistance_series , resistance_shunt , nNsVth ,
938
- ivcurve_pnts = None ):
937
+ resistance_series , resistance_shunt , nNsVth ):
939
938
"""Wrapper around the :py:func:`pvlib.pvsystem.singlediode` function.
940
939
941
940
See :py:func:`pvsystem.singlediode` for details
942
941
"""
943
942
return singlediode (photocurrent , saturation_current ,
944
- resistance_series , resistance_shunt , nNsVth ,
945
- ivcurve_pnts = ivcurve_pnts )
943
+ resistance_series , resistance_shunt , nNsVth )
946
944
947
945
def i_from_v (self , resistance_shunt , resistance_series , nNsVth , voltage ,
948
946
saturation_current , photocurrent ):
@@ -2708,10 +2706,9 @@ def sapm_effective_irradiance(poa_direct, poa_diffuse, airmass_absolute, aoi,
2708
2706
2709
2707
2710
2708
def singlediode (photocurrent , saturation_current , resistance_series ,
2711
- resistance_shunt , nNsVth , ivcurve_pnts = None ,
2712
- method = 'lambertw' ):
2709
+ resistance_shunt , nNsVth , method = 'lambertw' ):
2713
2710
r"""
2714
- Solve the single- diode equation to obtain a photovoltaic IV curve.
2711
+ Solve the single diode equation to obtain a photovoltaic IV curve.
2715
2712
2716
2713
Solves the single diode equation [1]_
2717
2714
@@ -2724,11 +2721,10 @@ def singlediode(photocurrent, saturation_current, resistance_series,
2724
2721
\frac{V + I R_s}{R_{sh}}
2725
2722
2726
2723
for :math:`I` and :math:`V` when given :math:`I_L, I_0, R_s, R_{sh},` and
2727
- :math:`n N_s V_{th}` which are described later. Returns a DataFrame
2728
- which contains the 5 points on the I-V curve specified in
2729
- [3]_. If all :math:`I_L, I_0, R_s, R_{sh},` and
2730
- :math:`n N_s V_{th}` are scalar, a single curve is returned, if any
2731
- are Series (of the same length), multiple IV curves are calculated.
2724
+ :math:`n N_s V_{th}` which are described later. The five points on the I-V
2725
+ curve specified in [3]_ are returned. If :math:`I_L, I_0, R_s, R_{sh},`
2726
+ and :math:`n N_s V_{th}` are all scalar, a single curve is returned. If any
2727
+ are array-like (of the same length), multiple IV curves are calculated.
2732
2728
2733
2729
The input parameters can be calculated from meteorological data using a
2734
2730
function for a single diode model, e.g.,
@@ -2762,39 +2758,25 @@ def singlediode(photocurrent, saturation_current, resistance_series,
2762
2758
junction in Kelvin, and :math:`q` is the charge of an electron
2763
2759
(coulombs). ``0 < nNsVth``. [V]
2764
2760
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
2761
method : str, default 'lambertw'
2770
2762
Determines the method used to calculate points on the IV curve. The
2771
2763
options are ``'lambertw'``, ``'newton'``, or ``'brentq'``.
2772
2764
2773
2765
Returns
2774
2766
-------
2775
- OrderedDict or DataFrame
2767
+ dict or pandas.DataFrame
2768
+
2769
+ A dict is returned when the input parameters are scalars.
2776
2770
2777
- The returned dict-like object always contains the keys/columns:
2771
+ The result contains the keys/columns:
2778
2772
2779
2773
* i_sc - short circuit current in amperes.
2780
2774
* v_oc - open circuit voltage in volts.
2781
2775
* i_mp - current at maximum power point in amperes.
2782
2776
* v_mp - voltage at maximum power point in volts.
2783
2777
* p_mp - power at maximum power point in watts.
2784
2778
* i_x - current, in amperes, at ``v = 0.5*v_oc``.
2785
- * i_xx - current, in amperes, at ``V = 0.5*(v_oc+v_mp)``.
2786
-
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.
2779
+ * i_xx - current, in amperes, at ``v = 0.5*(v_oc+v_mp)``.
2798
2780
2799
2781
See also
2800
2782
--------
@@ -2818,13 +2800,6 @@ def singlediode(photocurrent, saturation_current, resistance_series,
2818
2800
that guarantees convergence by bounding the voltage between zero and
2819
2801
open-circuit.
2820
2802
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
2803
References
2829
2804
----------
2830
2805
.. [1] S.R. Wenham, M.A. Green, M.E. Watt, "Applied Photovoltaics" ISBN
@@ -2841,22 +2816,17 @@ def singlediode(photocurrent, saturation_current, resistance_series,
2841
2816
photovoltaic cell interconnection circuits" JW Bishop, Solar Cell (1988)
2842
2817
https://doi.org/10.1016/0379-6787(88)90059-2
2843
2818
"""
2819
+ args = (photocurrent , saturation_current , resistance_series ,
2820
+ resistance_shunt , nNsVth ) # collect args
2844
2821
# Calculate points on the IV curve using the LambertW solution to the
2845
2822
# single diode equation
2846
2823
if method .lower () == 'lambertw' :
2847
- out = _singlediode ._lambertw (
2848
- photocurrent , saturation_current , resistance_series ,
2849
- resistance_shunt , nNsVth , ivcurve_pnts
2850
- )
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
+ out = _singlediode ._lambertw (* args )
2825
+ points = out [:7 ]
2854
2826
else :
2855
2827
# Calculate points on the IV curve using either 'newton' or 'brentq'
2856
2828
# methods. Voltages are determined by first solving the single diode
2857
2829
# equation for the diode voltage V_d then backing out voltage
2858
- args = (photocurrent , saturation_current , resistance_series ,
2859
- resistance_shunt , nNsVth ) # collect args
2860
2830
v_oc = _singlediode .bishop88_v_from_i (
2861
2831
0.0 , * args , method = method .lower ()
2862
2832
)
@@ -2872,30 +2842,24 @@ def singlediode(photocurrent, saturation_current, resistance_series,
2872
2842
i_xx = _singlediode .bishop88_i_from_v (
2873
2843
(v_oc + v_mp ) / 2.0 , * args , method = method .lower ()
2874
2844
)
2845
+ points = i_sc , v_oc , i_mp , v_mp , p_mp , i_x , i_xx
2875
2846
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 )
2847
+ columns = ['i_sc' , 'v_oc' , 'i_mp' , 'v_mp' , 'p_mp' , 'i_x' , 'i_xx' ]
2882
2848
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
2849
+ if all (map (np .isscalar , args )):
2850
+ return {c : p for c , p in zip (columns , points )}
2891
2851
2892
- if ivcurve_pnts :
2852
+ points = np .atleast_1d (* points ) # convert scalars to 1d arrays
2853
+ points = np .vstack (points ).T # collect rows into DataFrame columns
2893
2854
2894
- out [ 'v' ] = ivcurve_v
2895
- out [ 'i' ] = ivcurve_i
2855
+ # save the first available pd.Series index, otherwise set to None
2856
+ index = next (( a . index for a in args if isinstance ( a , pd . Series )), None )
2896
2857
2897
- if isinstance (photocurrent , pd .Series ) and not ivcurve_pnts :
2898
- out = pd .DataFrame (out , index = photocurrent .index )
2858
+ out = pd .DataFrame (
2859
+ points ,
2860
+ columns = ['i_sc' , 'v_oc' , 'i_mp' , 'v_mp' , 'p_mp' , 'i_x' , 'i_xx' ],
2861
+ index = index
2862
+ )
2899
2863
2900
2864
return out
2901
2865
@@ -2936,7 +2900,7 @@ def max_power_point(photocurrent, saturation_current, resistance_series,
2936
2900
2937
2901
Returns
2938
2902
-------
2939
- OrderedDict or pandas.Datafrane
2903
+ OrderedDict or pandas.DataFrame
2940
2904
``(i_mp, v_mp, p_mp)``
2941
2905
2942
2906
Notes
0 commit comments