LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fitting Non-ideal Diode equation

Hello,

 

I have been attempting to fit the non-idea diode equation, of the form   J = J0 *exp((q/AkT)*(V-J*Rs)) + (V-J*Rs)/Rp -Jsc which is used to model a solar cell under illumation.  I have seen other posts from the past about a similar task but non resulted in a solution.  q,k, and T are known constants. (q/kT approx. equals 1/0.2525 at room temp).  The unknowns are J0, A, Rs, Rp, and Jsc (although Jsc is just a y-offset).  As you can see from the equation, the other parameters are all dependent on one another.  The Y-axis term (J) and X-axis term (V) exist both in the exponent and outside of it.  As such, the equation can NOT be solved explicitly for either one.  Additionally, the J term in the exponent is negative, making an iterative solution difficult (in successive iterations, terms alternate between positive and negative).

 

I have tried implimenting a fit following the Fit Ellipse.vi example but have been unsuccesful.  Even the creation of the diode X-Y data is proving difficult.  And without an accurate way to create the data, a fit is unlikely to succeed.  If anyone has some insight I would greatly appreciate the assistance.

 

Labview version 2009.

 

 

 

Download All
0 Kudos
Message 1 of 12
(6,134 Views)

forgot a subvi

 

 

0 Kudos
Message 2 of 12
(6,133 Views)

Do you have more reasonable input values or are the defaults OK? Seems unreasonable.

Why are you fitting a constant, all one, Y array?

0 Kudos
Message 3 of 12
(6,118 Views)

I've done this sort of thing a lot in the past using Excel's Solver.   Use your J=exp(...) equation to predict  Y values for all of your X's using coefficients (e.g. Rs, A, etc.) contained in cells.  Sum the squares of the differences of the predicted values minus the measured values (Y).  Minimize this value (sum of the squares of the error) using Excel's Solver add-in.  Solver modifies the coeeficient cells untill the sum of squared error is minimized.

 

Two thoughts: 

          figure out what algorithm Solver is using and replicate the relevant portions in LV

               -- or --

          see if you can use API calls into Excel to run Solver on your data

 

0 Kudos
Message 4 of 12
(6,105 Views)

For an experimental solar cell, the values in "Fit Diode.vi" as first guesses (data generation) are fairly reasonable.  The rp value should be large (in an ideal case - but physical systems are never ideal).  the ideality factor A (just realized it's labeled n in the vi).  

 

I am fitting one array because that's how the Fit Ellipse.vi (X and Y interleaved) and I was just trying to follow their example as I have no experience fitting implicit functions.  If there is a better way, please let me know.

 

From the perspective of the equation itself, there has been some literature publications stating that it CAN be solved explicitly by making use of the Lambert W function (which I have no idea how to impliment).  If this function exists somewhere in LabVIEW it could be helpful.

 

 

0 Kudos
Message 5 of 12
(6,104 Views)

@Zwired1 wrote:

 

Two thoughts: 

          figure out what algorithm Solver is using and replicate the relevant portions in LV

               -- or --

          see if you can use API calls into Excel to run Solver on your data

 


That's a decent idea, although it would require me to ensure excel is present on all computers if I distribute this code further.  I'll look into this.

 

0 Kudos
Message 6 of 12
(6,101 Views)

@pjr1121 wrote:

For an experimental solar cell, the values in "Fit Diode.vi" as first guesses (data generation) are fairly reasonable.  The rp value should be large (in an ideal case - but physical systems are never ideal).


Well, here's how the data looks like (white dots). Very shallow then a sharp increase over many orders of magnitude. Looks much better if N is a bit larger (e.g. 2).

 

Are you sure your model subVI is correct?

 

I still don't understand why you interlace x and y. Makes no sense here.

 

0 Kudos
Message 7 of 12
(6,095 Views)

 

 J = J0 *exp((q/AkT)*(V-J*Rs)) + (V-J*Rs)/Rp -Jsc

 

q,k, and T are known constants.

The unknowns are J0, A, Rs, Rp, and Jsc (although Jsc is just a y-offset).

The Y-axis term (J) and X-axis term (V) exist both in the exponent and outside of it.

 

You simply have J = f(V) This is not an ellipse and interlacing makes absolutely no sense. Look at a regular nonlinear fit example.

 

J=Y

V=x

fitting parameters: J0, A, Rs, Rp, Jsc

constant: q, k, T

 

Make a models that calculates J = f(V) given the parameters. Use the x, y, and a inputs of the fitting VI. Nothing else.

Use the same model VI to simulate the data. No need to have two VIs with the same functionality.

0 Kudos
Message 8 of 12
(6,086 Views)

I agree that the diode data there increases probably far too sharply.  And I think this is a result of me trying to incorporate iterative methods in the fit (inside my mathscript you will see a for loop; Change the number of iterations and you'll see the difficulty of actually generating data for a diode curve).

 

I don't know why XY are interleaved either.  That's the way it was done for the "Fit Ellipse.vi" example that comes with Labview and I just tried to emulate that code.

 

I feel that the subvi model is the first thing to tackle but it's just the equation.  Due to the form of the function, you can't just plug in the values once for the calculation.  I tried to address this by starting with j=0 on the right side, calculate j, on the left, and proceed in a for loop to recalculate j.  For many equations this approach would eventually converge on the correct output.  However here, the j term in the exponent is negative.  If you vary the number of iterations from 1 to 2 to 3 and compare the outputs, you'll see why this is a problem.

 

I'm honestly a bit lost here.

0 Kudos
Message 9 of 12
(6,085 Views)

@altenbach wrote:

 

 

Make a models that calculates J = f(V) given the parameters. Use the x, y, and a inputs of the fitting VI. Nothing else.

Use the same model VI to simulate the data. No need to have two VIs with the same functionality.


This is mathematically imposible (with my knowledge).  J= f(J,V) in the given form.  J appears both in the exponential term and in the term involving Rp.

 

Since both V and J appear in the exponential and outside it, it's not possible to either obtain J = f(V) or V = f(J).  If it were, I would find this alot easier.

0 Kudos
Message 10 of 12
(6,084 Views)