I_FROM_V
Overview
The I_FROM_V
function calculates the device current at a given device voltage for a photovoltaic (PV) cell or module using the single diode model (SDM). This function is useful for modeling the current-voltage (IV) characteristics of solar cells and modules, which is essential for PV system design and analysis. The calculation is based on the single diode equation, as described in Jain and Kapoor (2004):
where is the output current, is the voltage, is the photocurrent, is the diode saturation current, is the series resistance, is the shunt resistance, and is the product of the diode ideality factor, number of cells in series, and cell thermal voltage. For more details, see the pvlib i_from_v documentation .
This example function is provided as-is without any representation of accuracy.
Usage
To use the function in Excel:
=I_FROM_V(voltage, photocurrent, saturation_current, resistance_series, resistance_shunt, nNsVth, [method])
voltage
(float, required): The voltage in Volts under desired IV curve conditions.photocurrent
(float, required): Light-generated current (photocurrent) in amperes under desired IV curve conditions. Often abbreviatedI_L
.saturation_current
(float, required): Diode saturation current in amperes under desired IV curve conditions. Often abbreviatedI_0
.resistance_series
(float, required): Series resistance in ohms under desired IV curve conditions. Often abbreviatedRs
.resistance_shunt
(float, required): Shunt resistance in ohms under desired IV curve conditions. Often abbreviatedRsh
.nNsVth
(float, required): Product of diode ideality factor, number of cells in series, and cell thermal voltage (V).method
(str, optional, default=“lambertw”): Solution method. One of"lambertw"
,"newton"
, or"brentq"
.
The function returns a single value (float): the device current in amperes at the specified voltage, or an error message (string) if the input is invalid.
Examples
Example 1: Typical Silicon Cell at MPP
In Excel:
=I_FROM_V(0.5, 8.0, 1e-10, 0.01, 1000, 1.5)
Expected output:
Result (A) |
---|
8.0 |
Example 2: Open Circuit Condition
In Excel:
=I_FROM_V(0.6, 8.0, 1e-10, 0.01, 1000, 1.5)
Expected output:
Result (A) |
---|
8.0 |
Example 3: High Series Resistance
In Excel:
=I_FROM_V(0.5, 8.0, 1e-10, 1.0, 1000, 1.5)
Expected output:
Result (A) |
---|
7.99 |
Example 4: Using Newton Method
In Excel:
=I_FROM_V(0.5, 8.0, 1e-10, 0.01, 1000, 1.5, "newton")
Expected output:
Result (A) |
---|
8.0 |
This means, for example, that at 0.5 V, the current is approximately 7.99 A for a typical silicon cell under standard conditions.
Python Code
import micropip
await micropip.install('pvlib')
from pvlib.pvsystem import i_from_v as pvlib_i_from_v
def i_from_v(voltage, photocurrent, saturation_current, resistance_series, resistance_shunt, nNsVth, method="lambertw"):
"""
Calculate the device current at a given device voltage for a PV cell/module using the single diode model.
Args:
voltage: Voltage in Volts (float).
photocurrent: Light-generated current in Amperes (float).
saturation_current: Diode saturation current in Amperes (float).
resistance_series: Series resistance in Ohms (float).
resistance_shunt: Shunt resistance in Ohms (float).
nNsVth: Product of diode ideality factor, number of cells in series, and cell thermal voltage (float).
method: Solution method (str), one of 'lambertw', 'newton', or 'brentq'. Default is 'lambertw'.
Returns:
Device current in Amperes (float), or an error message (str) if input is invalid.
This example function is provided as-is without any representation of accuracy.
"""
try:
V = float(voltage)
IL = float(photocurrent)
I0 = float(saturation_current)
Rs = float(resistance_series)
Rsh = float(resistance_shunt)
nNsVth_ = float(nNsVth)
if method not in ["lambertw", "newton", "brentq"]:
return "Invalid input: method must be 'lambertw', 'newton', or 'brentq'."
except Exception:
return "Invalid input: all arguments must be numbers, except method."
try:
result = pvlib_i_from_v(V, IL, I0, Rs, Rsh, nNsVth_, method=method)
except Exception as e:
return f"pvlib.i_from_v error: {e}"
return round(float(result), 2)
Live Notebook
Edit this function in a live notebook .