0

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.

Richard Wilson
  • 297
  • 4
  • 17
  • Why do you have a function repeatedly being defined inside a `for` loop? – ddejohn Sep 05 '21 at 22:48
  • BTW, you can use scientific notation in Python, e.g., `1e-20`. – ddejohn Sep 05 '21 at 22:49
  • In your `for` loop you seem to be trying to use `optimize` on a fixed function. You keep calling `optimize.newton(f, initial_guess)`, but I don't see anywhere `initial_guess` is every iterated on. I'm not familiar with that function, but it seems like you should actually be using `root` as your next "guess"... – ddejohn Sep 05 '21 at 22:50
  • Looking at `scipy.optimize.newton()`, that function only finds the root of a single-variable function. Can you clarify, are you trying to estimate the values of the two constants in your function? Or both variables and both constants? – ddejohn Sep 05 '21 at 22:58
  • I am trying to estimate the values of **Rs , Rp, n** and **Isat** by using the values of **Vpanel** and **Ipanel** as inputs. – Rodrigo Moraes Sep 05 '21 at 23:05
  • I'm not sure I see how the function you defined at the top of your post is considered an implicit function. Alas, you'll probably have better luck on the [math SE](https://math.stackexchange.com/). – ddejohn Sep 05 '21 at 23:09
  • Thanks for the comment. I'm gonna look through it. – Rodrigo Moraes Sep 05 '21 at 23:40

0 Answers0