I want to find the the root of Nonlinear Function. So, I use fsolve method in scipy.optimize library. But, it doesn't work.
The name of the variable with the root of Nonlinear Function is "s". With the variable 's', I want to find the other variable values. I appreciate if you help me.
Code
# calculate I0 with new Rp value
from sympy import Symbol, solve, exp
import sympy as sp
from scipy.optimize import fsolve
I02 = (Isc \* (1 + Rs1 / Rp) - Voc / Rp) / (np.exp(Voc / vt1) - np.exp(Rs1 \* Isc / vt1));
Ipv2 = I02 \* ((np.exp(Voc / vt1)) - 1) + Voc / Rp;
ImpC = Pmax / VmpC;
err = abs(Imp - ImpC);
Rpnew = Rp;
while ((err \> toll) & (itI \< iter)) :
if ImpC \< Imp :
Rpnew = Rp + 0.1 \* itI;
else :
Rpnew = Rp - 0.1 \* itI;
print(itI);
# Calculate I0 with rpnew
I02 = (Isc * (1 + Rs1 / Rpnew) - Voc / Rpnew) / (np.exp(Voc / vt1) - np.exp(Rs1 * Isc / vt1));
print(I02);
Ipv2 = I02 * ((np.exp(Voc / vt1)) - 1) + Voc / Rpnew;
print(Ipv2);
x = sp.symbols('x');
eqn = Ipv2 - (I02 * (sp.exp((Vmp + (Rs1 * x)) / vt1) - 1)) - x - (Vmp + Rs1 * x) / Rpnew;
print(eqn);
print(type(eqn));
current_c = Imp;
print(current_c);
s = fsolve(func = eqn, x0 = current_c);
print(s);
ImpC = s;
itI = itI + 1;
err = abs(Imp - ImpC);
Traceback Massage
TypeError Traceback (most recent call last)
Cell In \[65\], line 43
40 print(current_c);
41 # s = fzero(eqn,current_c);
42 # s = sp.solveset(eqn, x);
\---\> 43 s = fsolve(func = eqn, x0 = current_c);
44 print(s);
45 ImpC = s;
TypeError: 'Add' object is not callable'