Replies: 3 comments 4 replies
-
Thanks for your thorough suggestion. I’m curious what are the use cases for this change? What are the potential consequences in terms of execution speed and maintenance burden? And what alternatives have you considered? |
Beta Was this translation helpful? Give feedback.
-
My first thought is questioning the value of being so general that separate voltages can be passed for each set of SDE parameters (i.e., do we really need to allow 2D voltage input). I don't calculate I-V curves very often, but naively I'd have thought it more natural to use the same voltages for all curves. Users who need different voltages for different curves can always iterate and calculate one curve at a time. Maybe someone that more frequently uses these functions could comment? |
Beta Was this translation helpful? Give feedback.
-
I found pvlib actually supports case four already, and uses columns to represent a list of voltages for an IV curve. Case four functionality is used in singlediode.py. The PR #1743 also has examples of using case four in |
Beta Was this translation helpful? Give feedback.
-
A single call to
pvsystem.singlediode
using itsivcurves_pnts
parameter can calculate multiple current-voltage pairs for a set of IV curves (see this example). If theivcurve_pnts
parameter is removed (see this comment),pvsystem.i_from_v
andpvsystem.v_from_i
can be used to calculate these pairs instead. However, unlikesinglediode
, these functions do not support calculating multiple current-voltage pairs for more than one IV curve with a single function call. The linked example would need to calli_from_v
once per IV curve. Here I propose a design fori_from_v
andv_from_i
that allows calculating multiple currents/voltages for more than one IV curve with a single function call. I only discussi_from_v
, but the ideas also apply tov_from_i
.Four cases determine what$C$ be the number of IV curves and $(P_k)_{k = 1}^C$ where $P_k$ is the number of voltages for the $k$ -th IV curve. These are the four cases depending on $C$ and $(P_k)_{k = 1}^C$ :
i_from_v
should return. These cases depend on the number of IV curves passed and the number of voltages given for each IV curve. The number of IV curves is determined by the maximum length ofphotocurrent
,saturation_current
,resistance_series
,resistance_shunt
, andnNsVth
(the SDE parameters) when viewed as 1d arrays. Leti_from_v
should return one current value. This case is like passing all SDE parameters andvoltage
as scalars, 0d arrays, or 1d arrays of size one.i_from_v
should returnvoltage
as a 1d array.i_from_v
should returnvoltage
as a scalar, 0d array, or 1d array of size 1 ori_from_v
should returnvoltage
as a 2d array.i_from_v
supports the first three cases but not the fourth one. To support case four,i_from_v
will allowvoltage
to be passed as a 2d array. A limitation of 2d arrays is that they requirevoltage
is created, the voltage lists for each IV curve must be padded to the same length.When passing a 2d array for$\forall i, P_i = 1$ , this decision comes down to whether a 1d array of shape $C > 1$ and each IV curve has a different voltage at maximum power.
voltage
, we need to choose whether a column or a row represents the list of voltages for an IV curve. Since case three and case four are equivalent when(C,)
is a row vector or a column vector. To illustrate this, consider usingi_from_v
to findi_mp
givenv_mp
where(C,)
is a row vector (equivalent to(1, C)
); that is, forv_mp
asnp.array([a, b, c])
or asnp.array([[a, b, c]])
will computei_mp = np.array([d, e, f])
ori_mp = np.array([[d, e, f]])
, respectively. On the other hand, passingv_mp
asnp.array([[a], [b], [c]])
(shape:(C, 1)
) tellsi_from_v
to find the currents corresponding toa, b, c
for only one curve. In that case, we can allow broadcasting so thati_from_v
finds the currents corresponding toa, b, c
for all three curves and returns a shape(3, 3)
array.(C,)
is a column vector (equivalent to(C, 1)
); that is, forv_mp
asnp.array([a, b, c])
or asnp.array([[a], [b], [c]])
will computei_mp = np.array([d, e, f])
ori_mp = np.array([[d], [e], [f]])
, respectively. On the other hand, passingv_mp
asnp.array([[a, b, c]])
(shape:(1, C)
) tellsi_from_v
to find the currents corresponding toa, b, c
for only one curve. In that case, we can allow broadcasting so thati_from_v
finds the currents corresponding toa, b, c
for all three curves and returns a shape(3, 3)
array.I believe columns should represent the list of voltages for an IV curve; however, I have not yet found a strong reason for choosing columns over rows.
Next, it is important for the user experience that the result returned by
i_from_v
has the same dimension and Python type asvoltage
, when possible. Below is a table of examples containing the expected shapes to be returned byi_from_v
given the shapes of its parameters. In these examples, the shape(1,)
can represent scalars, 0d arrays, and 1d arrays of length one. All other shapes are at least 1d arrays.Here are the test cases for
i_from_v
case four support:Here is what the linked example looks like with case four support and
ivcurve_pnts
removed fromsinglediode
:In conclusion,
i_from_v
should allowvoltage
to be passed as a 2d array so that, with a single function call, multiple current values can be calculated for more than one IV curve. Let me know your thoughts on supporting case four and whether to choose columns or rows. My current implementation of case four support can be found here.voltage
array shapevoltage
: scalar, 0d array, or 1d arrayvoltage
: scalar, 0d array, or 1d arrayvoltage
voltage
voltage
Beta Was this translation helpful? Give feedback.
All reactions