Unable to find explicit solution for "solve"

Code summary: Trying to calculate an array of 'Inet' values, one for every 'V' value. All of the other values are individul numbers. The code is below. The reason I believe it is not working is that there are 'Inet' variables on each side of the equation.
V = 0:.01:3;
syms Inet;
I = solve(Inet == Isc - Is.*(exp(q.*(V+Inet*Rs)./(n*kB*Tc))-1)-(V+Inet*Rs)./Rsh, Inet);
Here is the output warning:
Warning: Unable to find explicit solution. For options, see help.
After running the code, 'I' has no value. I would like it to be an array of 301 numbers, just like 'V'. Can anybody see what I'm doing wrong? Any help is appreciated

 Accepted Answer

Hi,
solve numeric:
% Values for constants - I took some fantasy values...
Isc = 0.1;
Is = 1;
q = 2;
Rs = 0.0135;
Rsh = -2;
n = 4;
kB = 0.4;
Tc = 10;
% Definition of V as column vector
V = (0:.01:3)';
% Solve for Inet
x0 = ones(size(V,1),1);
Inet = fsolve(@(x)solve_Inet(x,Isc,Is,q,V,Rs,Rsh,n,kB,Tc),x0);
% Inet Function
function F = solve_Inet(x,Isc,Is,q,V,Rs,Rsh,n,kB,Tc)
Inet = x;
F = Isc - Is.*(exp(q.*(V+Inet*Rs)./(n*kB*Tc))-1)-(V+Inet*Rs)./Rsh - Inet;
end
Best regards
Stephan

5 Comments

Hi Stefan, thanks for your help! Unfortunately, I got this error:
Solver stopped prematurely.
fsolve stopped because it exceeded the function evaluation limit,
options.MaxFunctionEvaluations = 30100 (the default value).
Do you know how I can avoid this?
If it helps, here are the values of my constants:
Isc = 1.1*10^4;
Is = 10^-10;
q = 1.6*10^-19;
Rs = 5*10^-7;
Rsh = 10^10;
n = 1;
kB = 1.38*10^-23;
Tc = 313;
Try:
% Values for constants - I took some fantasy values...
Isc = 1.1e4;
Is = 1e-10;
q = 1.6e-19;
Rs = 5e-7;
Rsh = 1e10;
n = 1;
kB = 1.38e-23;
Tc = 313;
% Definition of V as column vector
V = (0:.01:3)';
% Solve for Inet
x0 = ones(size(V,1),1);
opts = optimoptions(@fsolve,'MaxFunctionEvaluations',500*numel(x0));
Inet = fsolve(@(x)solve_Inet(x,Isc,Is,q,V,Rs,Rsh,n,kB,Tc),x0,opts);
plot(V,Inet)
% Inet Function
function F = solve_Inet(x,Isc,Is,q,V,Rs,Rsh,n,kB,Tc)
Inet = x;
F = Isc - Is.*(exp(q.*(V+Inet*Rs)./(n*kB*Tc))-1)-(V+Inet*Rs)./Rsh - Inet;
end
It finds a solution - plotting Inet over V gives:
plot_Inet_over_V.PNG
Yes, that's exactly what I was looking for, thank you! Could you please explain what is going on with optimoptions and why you needed a function?
Stephan
Stephan on 17 Mar 2019
Edited: Stephan on 17 Mar 2019
the standard settings use 100 * number of variables. 30100 in your case. The message you recieved told us, that this limit was reached and there is no solution found. I used optimoptions to set it to 500* number of variables, which appears to be enough for a solution.
I choosed a function - also a function handle would work - no special reason. Fsolve tries to find x that statisfies F=0.
If this was useful please accept my answer.

Sign in to comment.

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Tags

Asked:

on 17 Mar 2019

Edited:

on 17 Mar 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!