Skip to content

Update pvl_singlediode.m #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 25, 2019
Merged

Update pvl_singlediode.m #23

merged 2 commits into from
Jun 25, 2019

Conversation

joallen6
Copy link

@joallen6 joallen6 commented Feb 7, 2019

Added iteration limit on while loop. This can be infinite if inputs are unreasonable (see comments on pvl_perez). It's good form to let user know source of error.

Added iteration limit on while loop. This can be infinite if inputs are unreasonable (see comments on pvl_perez). It's good form to let user know source of error.
while max(abs(B-A))>1e-6 % set precision of estimate of Imp to 1e-6 (A)
gA=g(A,Iph,Io,a,Rs,Rsh); % value of dP/dV at left endpoint
u=(gA.*err)<0;
B(u)=p(u);
A(~u)=p(~u);
p=(A+B)/2;
err = g(p,Iph,Io,a,Rs,Rsh);

iterCount = iterCount + 1;
if iterCount > 1000
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't object to adding iterCount as insurance against some kind of erroneous behavior in the helper function g(), but perhaps reduce the limit to 50. In this bisection, convergence is achieved at an interval of width < 1e-6, from a starting interval between 0 and Iph. A reasonably large value of Iph is 10. In this case convergence is reached after ~20 iterations, assuming the code functions as intended.

50 iterations seems fine. My current data ran fine with this limit. Thanks,
@cwhanse
Copy link
Collaborator

cwhanse commented Feb 7, 2019

Please add a line to the whatsnew file, as an Enhancement.

@cwhanse cwhanse merged commit 85efebf into sandialabs:master Jun 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants