-
Notifications
You must be signed in to change notification settings - Fork 1k
Cell Model Solutions
PVLIB-Python solves for cell voltage and current using a single-diode model (SDM), which is an electrical analog of a solar cell depicted in the following figure from the PVPMC website by Sandia National Laboratories:
The methods in pvlib.pvsystem.singlediode
, pvlib.pvsystem.i_from_v
, and pvlib.pvsystem.v_from_i
, allow a user to find the following IV-curve points at any temperature and irradiance combination:
- max power point current,
i_mp
, and voltage,v_mp
, - open circuit voltage,
v_oc
- short circuit current,
i_sc
- a set of voltage and current pairs at arbitrary points along the full curve from
i_sc
through the max power point (mpp) tov_oc
This page discusses the methods used to solve the SDM, which is an implicit equation and typically requires an iterative method.
The SDM can be transformed to an explicit Lambert W-function. Solving the Lambert W-function returns the values, w, for given values, z, that satisfy z = w * exp(w)
. Actually this solution also requires iteration, and the Lambert W-function is frequently solved using Newton's method.
Since the SDM produces a continuously differentiable and monotonic IV-curve, it can be solved using any of the standard iterative root-finding algorithms, such as:
- Newton-Raphson or Secant
- bracketed bisection methods like Brent
This method is considered safer because it is a bounded or bracketed search method. Applying this to the SDM is very straight-forward and guaranteed to converge on a solution because in PVLIB an IV curve is always monotonic and the power-voltage curve is always convex - there is only one maximum. This is because in PVLIB the entire PV system is treated as a single cell modeled by the SDM, but in a real PV system, combining many different cells, modules, and strings, possibly with non-uniform shade may yield a power curve that is not convex and an IV curve that is not monotonic. The bisection method does not require calculating derivatives, but for zero searching it requires the function to be monotonic, and bracketed by bounds greater than and less than zero, e.g.: [low_bound, high_bound]
such that low_bound < 0 < high_bound
. Brent's method is an improvement on the basic bisection method that is implemented with other root-finding algorithms in the Python SciPy optimization library.
The most common example of a root-finding algorithm is the Newton-Raphson method, which method uses the slope of the curve at an arbitrary initial location to predict where the curve will cross the x-axis. This distance from the initial location to get to the predicted zero is called the "Newton step" and is typically used as one of the convergence criteria. The Newton method converges more rapidly than bisection and is not bounded, but it has some limitations.
- It can't possibly predict where the curve crosses the x-axis if the derivative returns a slope of zero!
- If the curve has discontinuities, or is characterized by both relative flat and steep sections, then, given a poor initial starting point, the Newton step may "shoot" over the true zero into a "fake valley" with no zero.
There are methods to mitigate against these limitations, but they aren't necessary in the case of the SDM because it is smooth and monotonic, and the slope is everywhere greater than the machine precision of IEEE double precision floats, 2e-16.
One of the methods above can be used to calculate a full IV curve for a specific set of voltages. However if the user doesn't need to specify the voltages, only that they are bounded by the 1st quadrant, then the algorithm presented by J.W. Bishop in "Computer simulation of the effects of electrical mismatches in photovoltaic cell interconnection circuits", Solar Cells Vol 25, No 1, 1988, pp 73-89 presents an explicit way to do this by recognizing that the SDM is explicit for diode voltage.
-
Select a range of diode voltages,
v_diode
-
Calculate the cell current,
i
, from the explicit SDM equations:i = i_l - i_o * (exp(v_diode / v_th) - 1.0) - v_diode / r_sh
-
Back calculate the cell voltage from the resulting currents:
v = v_diode - i * r_s
- This method is just a very slight substitution into the existing SDM. It does not change the SDM governing equations.
- Bishop's method can only be used to find cell current and voltage at a specified diode voltage, and not for a specific cell voltage. Therefore it is best used to find the entire IV curve.
- Since Bishop's method is explicit, it takes less calculations than an iterative or Lambert-W approach, and therefore can produce a full IV curve in less time.
These specific points always require either a Lambert-W or iterative approach because they specify a condition to search for.
There are two approaches:
-
Find the point where the product of cell current and voltage are the maximum. This can be accomplished using a minimization algorithm such as golden-search or Brent to find the largest value assuming the maximum can be bounded by a convex region. For example, NREL-SAM uses a golden-search to find the max power point. Sidenote, typically the search algorithm finds the minimum, which is accomplished by taking the negative of the cell power. Brute force is another alternative especially if the power-voltage curve is not convex, i.e.: there are many local maxima. Luckily in PVLIB, the entire PV system is treated as a single cell, so the power-voltage curve is convex. However, in a real PV system with many different cells, modules, and strings, possibly with non-uniform shade, the power-curve may not be convex.
-
Find the point where the derivative of the power with respect to voltage,
dp/dv
is zero. This can be accomplished by using either bisection or Newton-Raphson. In the case of Newton-Raphson the second derivative,d^2p/dv^2
can be provided, or else the secant method can be used to approximate it.
The Newton-Raphson method will be faster, but due to possible limitations for Newton-Raphson discussed above, the bisection is considered the "gold" standard because it is guaranteed to find the solution.
Either bisection or Newton-Raphson can be used to find the point where the current is zero. To use the bisection method, an upper bound greater than v_oc
must be used. This is accomplished by estimating the value assuming infinite shunt resistance,
v_oc_estimate = n * n_s * v_th * log(i_l / i_o + 1.0)
and then using that estimate as the diode voltage which will always yield a negative current for this specific value. See proof in the documentation.
The Newton-Raphson method doesn't require any bounds and will converge on v_oc
faster than bisection, but due to possible limitations for Newton-Raphson discussed above, the bisection is considered the "gold" standard because it is guaranteed to find the solution.
Either bisection or Newton-Raphson can be used to find the point where the voltage is zero. To use the bisection method, a pair of voltages that bound zero volts must be used.
The Newton-Raphson method doesn't require any bounds and will converge on i_s
faster than bisection, but due to possible limitations for Newton-Raphson discussed above, the bisection is considered the "gold" standard because it is guaranteed to find the solution.
This page summarize the possible ways to solve the SDM for the desired points. In summary:
- for an arbitrary set of IV-curve points use Bishop's method
- for guaranteed max power, open circuit, and short circuit points, the "gold" method is bisection
- for max power, open circuit, and short circuit points, a possible faster calculation is the Newton-Raphson method.
- for points outside but close to quadrant 1, use Newton-Raphson but beware that as the specified location moves away from quadrant 1, both the SDM and the Newton-Raphson method may not be able to accurately provide a solution.