Code keeps running and running and not stopping

20 views (last 30 days)
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 Comments
Savanna
Savanna on 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.
Walter Roberson
Walter Roberson on 25 Oct 2017
I have determined that fun2 and fun3 do have closed-form integrals in the form specified, but I am still working on characterizing them.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 24 Oct 2017
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.

Categories

Find more on Programming in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!