Last active
November 22, 2021 17:54
-
-
Save greyltc/51eb0c76dab9d5abb053c3470edddbc7 to your computer and use it in GitHub Desktop.
analytical solution for non-ideal solar cell equation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
written by Grey Christoforo <first name [at] last name [not] net> | |
analytical solution for non-ideal solar cell equation | |
""" | |
import sympy | |
# make symbols | |
Iph, Rs, Rsh, n, I0, Vth, I, V = sympy.symbols('Iph Rs Rsh n I0 Vth I V') | |
""" | |
where | |
Iph is the photocurrent generated | |
Rs is the series resistance | |
Rsh is the shunt resistance | |
n is the diode's ideality factor | |
I0 is the diode's reverse saturation current | |
Vth is the thermal voltage (kT/q) | |
I is the current through the load | |
and | |
V is the voltage across the load | |
""" | |
# symbolic representation for solar cell equation: | |
lhs = I | |
rhs = Iph-((V+I*Rs)/Rsh)-I0*(sympy.exp((V+I*Rs)/(n*Vth))-1) | |
char_eqn = sympy.Eq(lhs, rhs) # see https://en.wikipedia.org/wiki/Theory_of_solar_cells#Characteristic_equation | |
print("Solving. Please wait...") | |
# isolate current term in solar cell equation | |
current_alone = sympy.solve(char_eqn, I)[0] | |
print(current_alone) | |
# this prints: "(Rs*(I0*Rsh + Iph*Rsh - V) - Vth*n*(Rs + Rsh)*LambertW(Rs*exp((Rs*V + Rs*(I0*Rsh + Iph*Rsh - V) + Rsh*V + log((I0*Rsh)**(Vth*n*(Rs + Rsh))))/(Vth*n*(Rs + Rsh)))/(Vth*n*(Rs + Rsh))))/(Rs*(Rs + Rsh))" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment