SINGLEDIODE

This function solves the photovoltaic single-diode equation for the principal operating points on an IV curve. It is the core electrical model used after weather and module parameters have been translated into single-diode coefficients.

The governing equation is:

I = I_L - I_0 \left[\exp\left(\frac{V + I R_s}{n N_s V_{th}}\right) - 1\right] - \frac{V + I R_s}{R_{sh}}

From those coefficients the function returns i_{sc}, v_{oc}, i_{mp}, v_{mp}, p_{mp}, i_x, and i_{xx}. Different numerical methods can be selected depending on the tradeoff between speed and convergence robustness.

Excel Usage

=SINGLEDIODE(photocurrent, saturation_current, resistance_series, resistance_shunt, nNsVth, sd_solver)
  • photocurrent (float, required): Light-generated current (A). Must be >= 0.
  • saturation_current (float, required): Diode saturation current (A). Must be > 0.
  • resistance_series (float, required): Series resistance (ohms). Must be >= 0.
  • resistance_shunt (float, required): Shunt resistance (ohms). Must be > 0.
  • nNsVth (float, required): Product of ideality factor, cells in series, and thermal voltage (V). Must be > 0.
  • sd_solver (str, optional, default: “lambertw”): Root-finding algorithm.

Returns (list[list]): 2D list [[i_sc, v_oc, i_mp, v_mp, p_mp, i_x, i_xx]], or an error string.

Example 1: Standard IV key points

Inputs:

photocurrent saturation_current resistance_series resistance_shunt nNsVth sd_solver
5.5 2e-10 0.5 300 1.5 lambertw

Excel formula:

=SINGLEDIODE(5.5, 2e-10, 0.5, 300, 1.5, "lambertw")

Expected output:

Result
5.49085 36.0231 5.11038 29.057 148.492 5.43071 3.62124
Example 2: Standard IV key points using Newton solver

Inputs:

photocurrent saturation_current resistance_series resistance_shunt nNsVth sd_solver
5.5 2e-10 0.5 300 1.5 newton

Excel formula:

=SINGLEDIODE(5.5, 2e-10, 0.5, 300, 1.5, "newton")

Expected output:

Result
5.49085 36.0231 5.11038 29.057 148.492 5.43071 3.62124
Example 3: Lower shunt resistance reduces fill factor

Inputs:

photocurrent saturation_current resistance_series resistance_shunt nNsVth sd_solver
5.5 2e-10 0.5 150 1.5 lambertw

Excel formula:

=SINGLEDIODE(5.5, 2e-10, 0.5, 150, 1.5, "lambertw")

Expected output:

Result
5.48173 35.9893 5.01612 29.0464 145.7 5.36197 3.56516
Example 4: Higher series resistance case

Inputs:

photocurrent saturation_current resistance_series resistance_shunt nNsVth sd_solver
5.5 2e-10 0.9 300 1.5 lambertw

Excel formula:

=SINGLEDIODE(5.5, 2e-10, 0.9, 300, 1.5, "lambertw")

Expected output:

Result
5.48355 36.0231 5.06449 27.2753 138.135 5.42284 3.28872

Python Code

Show Code
from pvlib.pvsystem import singlediode as result_func

def singlediode(photocurrent, saturation_current, resistance_series, resistance_shunt, nNsVth, sd_solver='lambertw'):
    """
    Solve the single-diode equation to obtain a photovoltaic IV curve and its key operating points.

    See: https://pvlib-python.readthedocs.io/en/stable/reference/generated/pvlib.pvsystem.singlediode.html

    This example function is provided as-is without any representation of accuracy.

    Args:
        photocurrent (float): Light-generated current (A). Must be >= 0.
        saturation_current (float): Diode saturation current (A). Must be > 0.
        resistance_series (float): Series resistance (ohms). Must be >= 0.
        resistance_shunt (float): Shunt resistance (ohms). Must be > 0.
        nNsVth (float): Product of ideality factor, cells in series, and thermal voltage (V). Must be > 0.
        sd_solver (str, optional): Root-finding algorithm. Valid options: Lambert W, Newton, Brentq, Chandrupatla. Default is 'lambertw'.

    Returns:
        list[list]: 2D list [[i_sc, v_oc, i_mp, v_mp, p_mp, i_x, i_xx]], or an error string.
    """
    try:
        il = float(photocurrent)
        i0 = float(saturation_current)
        rs = float(resistance_series)
        rsh = float(resistance_shunt)
        nv = float(nNsVth)

        if il < 0: return "Error: photocurrent must be >= 0"
        if i0 <= 0: return "Error: saturation_current must be > 0"
        if rs < 0: return "Error: resistance_series must be >= 0"
        if rsh <= 0: return "Error: resistance_shunt must be > 0"
        if nv <= 0: return "Error: nNsVth must be > 0"

        meth = str(sd_solver) if sd_solver is not None else "lambertw"

        res = result_func(
            photocurrent=il,
            saturation_current=i0,
            resistance_series=rs,
            resistance_shunt=rsh,
            nNsVth=nv,
            method=meth
        )

        # res has keys: i_sc, v_oc, i_mp, v_mp, p_mp, i_x, i_xx
        out = [
            float(res['i_sc']),
            float(res['v_oc']),
            float(res['i_mp']),
            float(res['v_mp']),
            float(res['p_mp']),
            float(res['i_x']),
            float(res['i_xx'])
        ]
        return [out]
    except Exception as e:
        return f"Error: {str(e)}"

Online Calculator

Light-generated current (A). Must be >= 0.
Diode saturation current (A). Must be > 0.
Series resistance (ohms). Must be >= 0.
Shunt resistance (ohms). Must be > 0.
Product of ideality factor, cells in series, and thermal voltage (V). Must be > 0.
Root-finding algorithm.