I need to find the values of some constants of the following implicit function, given the values of the variables.
f(Vpanel, Ipanel) = Isc - Isat(e^((Rs * Ipanel+Vpanel)/(n * Vt))-1) - (Rs*Ipanel+Vpanel)/Rp - Ipanel
I want to find a way to find the values of Rs
, Rp
, n
, Isat
.
I already know the approximate values, but the method I used was by brute force, so it is not an optimal way to do it.
It is an equation of the voltage X current of a solar panel and I need to find these values to calculate the maximum power transference of the panel. The values of the variables were already measured.
I was trying to do it with scipy
but had no success.
Here's my code:
from scipy import optimize
import numpy as np
q = 1.9*pow(10, -19)
k = 1.38*pow(10, -23)
T = 303
Isc = 0.00298
Vt = k*T/q
Vpanel = [0,0.218, 0.421, 0.635, 0.856, 1.064, 1.288, 1.477, 1.650, 1.780, 1.821, 1.846, 1.867, 1.893, 1.901, 1.922, 1.927, 1.952, 1.966, 1.973, 1.981, 1.985, 1.994, 1.997, 2.008]
Ipanel = [0.0030, 0.0030, 0.0030, 0.0030, 0.0029, 0.0029, 0.0028, 0.0028, 0.0025, 0.0021, 0.0019, 0.0017, 0.0015, 0.0013, 0.0012, 0.0010, 0.0009, 0.0007, 0.0005, 0.0005, 0.0003, 0.0003, 0.0002, 0.0002, 0]
initial_guess = [60, 1000, 1, pow(10,-20)]
for i in range(len(Vpanel)):
def f(params):
Rs, Rp, n, Isat = params
return Isc - Isat*(np.exp((Rs*Ipanel[i]+Vpanel[i])/(n*Vt))-1) - (Rs*Ipanel[i] + Vpanel[i])/Rp - Ipanel[i]
root = optimize.newton(f, initial_guess)
print(root)
The results should be(approximately): Rs = 68.33
, Rp = 8000
, n = 1.9167
, Isat = 1E-20
.
But every time I run the code, the results are the values of the initial guesses.
I don't know if the method is the correct one, but every other method of the scipy
library doesn't work so newton's one is the only one that gives any result.
Another thing is that I am using a for because I don't know how to pass the Vpanel
and Ipanel
lists as arguments to newton's method.
Sorry for the bad English, it's not my first language. Also is my first StackOverflow question, so I don't really know if I made the question correctly.