MATLAB: Solving a system of 5 dependent non-linear equations

equations systemfsolvenon-linear systemobjective function is returning undefined values at initial point. fsolve cannot continue.

I am trying to solve the system of 5 non-linear equations:
Io * exp(Voc/ (m*Vt)) + Voc/Rsh - Is = 0
(Isc - (Voc - Rs*Isc)/ Rsh) * exp(-Voc/ (m*Vt)) - Io = 0
Isc - (Vmp + Rs*Imp + Rs*Isc)/ Rsh - (Isc - (Voc - Rs*Isc)/ Rsh) * exp((Vmp + Rs*Imp - Voc)/ (m*Vt)) - Imp = 0
Imp + ((-(Rsh*Isc - Voc + Rs*Isc) * exp((Vmp + Rs*Imp - Voc)/ (m*Vt))/ (Rsh * m*Vt) - 1/Rsh)/ (1 + Rs * (Rsh*Isc - Voc + Rs*Isc) * exp((Vmp + Rs*Imp - Voc)/ (m*Vt))/ (Rsh * m*Vt) + Rs/Rsh)) * Vmp = 0
(-(Rsh*Isc - Voc + Rs*Isc) * exp((Rs*Isc - Voc)/ (m*Vt))/ (Rsh * m*Vt) - 1/Rsh)/ (1 + Rs * (Rsh*Isc - Voc + Rs*Isc) * exp((Rs*Isc - Voc)/ (m*Vt))/ (Rsh * m*Vt) + Rs/Rsh) + 1/Rsh = 0
in which m, Rsh, Rs, Io and Is are the unknown variables. The other variables have the values:
Vmp = 31.1;
Imp = 8.67;
Voc = 38.2;
Isc = 9.19;
K = 1.38 * 10^-23;
T = 298.15;
q = 1.6 * 10*-19;
Vt = K*T/q;
I know the solution must be around m=62.3, Rsh=786, Rs=0.2748, Io=407.33, Is=9.1932
I have tried using the function fsolve as shown below
syms m Rsh Rs Io Is
V = [m, Rsh, Rs, Io, Is];
F = @(V) [V(4) * exp(Voc/ (V(1)*Vt)) + Voc/V(2) - V(5);
(Isc - (Voc - V(3)*Isc)/ V(2)) * exp(-Voc/ (V(1)*Vt)) - V(4);
Isc - (Vmp + V(3)*Imp + V(3)*Isc)/ V(2) - (Isc - (Voc - V(3)*Isc)/ V(2)) * exp((Vmp + V(3)*Imp - Voc)/ (V(1)*Vt)) - Imp;
Imp + ((-(V(2)*Isc - Voc + V(3)*Isc) * exp((Vmp + V(3)*Imp - Voc)/ (V(1)*Vt))/ (V(2) * V(1)*Vt) - 1/V(2))/ (1 + V(3) * (V(2)*Isc - Voc + V(3)*Isc) * exp((Vmp + V(3)*Imp - Voc)/ (V(1)*Vt))/ (V(2) * V(1)*Vt) + V(3)/V(2))) * Vmp;
(-(V(2)*Isc - Voc + V(3)*Isc) * exp((V(3)*Isc - Voc)/ (V(1)*Vt))/ (V(2) * V(1)*Vt) - 1/V(2))/ (1 + V(3) * (V(2)*Isc - Voc + V(3)*Isc) * exp((V(3)*Isc - Voc)/ (V(1)*Vt))/ (V(2) * V(1)*Vt) + V(3)/V(2)) + 1/V(2)];
InitialGuess = [50; 100; 1; 100; 10];
XY = fsolve(F, InitialGuess);
but I get the Error using trustnleqn (line 28). Objective function is returning undefined values at initial point. FSOLVE cannot continue. error message. Can someone tell how they would solve this problem?

Best Answer

Hi Frederico
1.
Actually, command fsolve works pretty well here, let me explain:
Since V(5) unknown only shows up in the 1st equation I decided to put off the 1st equation, let's solve the remaining system with fsolve
clear all;clc;close all
syms m Rsh Rs Io Is
Vmp = 31.1;
Imp = 8.67;
Voc = 38.2;
Isc = 9.19;
K = 1.38 * 10^-23;
T = 298.15;
q = -1.6 * 10^-19;
Vt = K*T/q;
V = [m, Rsh, Rs, Io];
F = @(V) [ (Isc - (Voc - V(3)*Isc)/ V(2)) * exp(-Voc/ (V(1)*Vt)) - V(4);
Isc - (Vmp + V(3)*Imp + V(3)*Isc)/ V(2) - (Isc - (Voc - V(3)*Isc)/ V(2)) * exp((Vmp + V(3)*Imp - Voc)/ (V(1)*Vt)) - Imp;
Imp + ((-(V(2)*Isc - Voc + V(3)*Isc) * exp((Vmp + V(3)*Imp - Voc)/ (V(1)*Vt))/ (V(2) * V(1)*Vt) - 1/V(2))/ (1 + V(3) * (V(2)*Isc - Voc + V(3)*Isc) * exp((Vmp + V(3)*Imp - Voc)/ (V(1)*Vt))/ (V(2) * V(1)*Vt) + V(3)/V(2))) * Vmp;
(-(V(2)*Isc - Voc + V(3)*Isc) * exp((V(3)*Isc - Voc)/ (V(1)*Vt))/ (V(2) * V(1)*Vt) - 1/V(2))/ (1 + V(3) * (V(2)*Isc - Voc + V(3)*Isc) * exp((V(3)*Isc - Voc)/ (V(1)*Vt))/ (V(2) * V(1)*Vt) + V(3)/V(2)) + 1/V(2)];
InitialGuess = [50; 0.1; .01; 1];
options = optimoptions('fsolve','Display','none','PlotFcn',@optimplotfirstorderopt,'MaxFunctionEvaluations',2000);
XY = fsolve(F, InitialGuess,options);
XY =
51.755945628868020
3.071518542695716
1.085173513887406
-1.062922141399835
2.
These are semiconductor equations, I like reading what is what, so I am putting back the initial variable names
m=XY(1)
Rsh=XY(2)
Rs=XY(3)
Io=XY(4)
3.
Now the initial equation is trivial
Is= Io * exp(Voc/ (m*Vt) )+ Voc/Rsh
Is =
12.436844990189343
4.
fsolve even produces the optimality graph ending up in 3.5e9 quite high.
5.
I was wondering, should your 1st equation have an inverted polarity, then Is would be
Is= Io * exp(-Voc/ (m*Vt) )+ Voc/Rsh
Is =
-3.101249033198816e+12
6.
Please note that function fsolve has a default amount if iterations equal to 400. If not changed, for this equations system, fsolve completes all the loops, without a solution, but warns that it may have a solution if increasing such default value.
To so, just change in advance the options field
'MaxFunctionEvaluations'
to for instance
2000
.
Frederico
Cosi fan tutte :)
If you find this answer useful would you please be so kind to consider marking my answer as Accepted Answer?
To any other reader, if you find this answer useful please consider clicking on the thumbs-up vote link
thanks in advance
John BG