Code keeps running and running and not stopping

I have code I am trying to run and when I try to get the value for V_max, the code won't stop running. I don't get an error and it will run for hours if I let it. I have asked my TA for my class as well as several classmates and none of them can figure out what is wrong either.
h=4.136e-15;%eVs
k=8.617e-5;%eV/k
c=3e8;
theta_s=0.00467;%radians
T_c=300;
q=1.6e-19;
syms E;
%PROBLEM 1
%a
T_s=5760;
a=q*(pi/2)*(1-cos(2*theta_s))*(2/((h^3)*(c^2)));
fun1= ((E.^3)./((exp(E/(k*T_s)))-1));
Pin= a*(int(fun1,0,inf));%input power
Intensity=double(Pin); %W/m^2
%Intensity= 1.3570e3 W/m^2, this is almost the exact number for the actual
%power,which is 1350 W/m^2, just over by 7
%b
E_g=1.43;%eV
fun2= (E.^2)./((exp(E/(k*T_s))-1));
J_l= a*int(fun2,E_g,inf);%light generated current density
%c
theta_e=pi/2;
b=q*(pi/2)*(1-cos(2*theta_e))*(2/(h^3)*(c^2));
fun3= (E.^2)./(exp(E/(k*T_c))-1);
J_0= b*int(fun3,E_g,inf);%reverse saturation current density
%d
syms V;
P= V*(J_l + J_0*(exp((q*V)/(k*T_c))-1));
V_max=double(solve(P,V));
J_max= (J_l + J_0*(exp((q*V)/(k*T_c))-1));
V_max is the part of the code that is giving me problems and I can't figure out what is wrong. Please help me. Thank you!

8 commentaires

Rik
Rik le 24 Oct 2017
I don't have much experience with the solve function, but I would have thought it would time out after a while, if it is a too complicated formula.
Savanna
Savanna le 24 Oct 2017
that's what I thought too, but I had it running last night and even then it wouldn't stop running-it was running for about 8-9 hours and still nothing.
solve() has no timeout.
Savanna
Savanna le 24 Oct 2017
ok then how do I get it to finish running and actually solve for the variable I need?
Walter Roberson
Walter Roberson le 24 Oct 2017
Modifié(e) : Walter Roberson le 24 Oct 2017
You cannot: your formulae generate infinities.
... though I am finding hints that the infinities might be false constructs... checking more...
Savanna
Savanna le 24 Oct 2017
ok I'm just a bit confused since I am just copying a formula from a textbook into matlab with the limits for the integral are E=E_g to E=infinity. The other people in my class have something similar, but haven't run into this problem like I have.
I have determined that fun2 and fun3 do have closed-form integrals in the form specified, but I am still working on characterizing them.

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 24 Oct 2017

1 vote

Your J_l and J_0 both have limit() operations that look to me as if they suggest non-convergence. Trying to solve() under those conditions is going to be a failure.
Maple says that the integral of fun2 and fun3 are complex infinity; when I prod it a different way, it says the limit as E approaches infinity is undefined, as it starts to involve negative infinity plus infinity.
You should recheck your formula.

Catégories

En savoir plus sur Programming dans Centre d'aide et File Exchange

Tags

Question posée :

le 24 Oct 2017

Commenté :

le 25 Oct 2017

Community Treasure Hunt

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

Start Hunting!

Translated by