LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to put nonlinear fitting into a loop

Hey,All

 

I am a rookie to labview. I try to fit experimental data with nonlinear fitting (Lev-Mar) and attain the fitting parameter. But the fitting curve looks bad. I tried so hard to get better fitting, but the progress is so little. I wonder whether there is some way to put the fitting in a loop to get a better fitting.

 

Basically, the aim is to calculate the Young's modulus from the indentation data. The parameters in the model vi are k (Spring constant , 0.02) , poisson ratio(0.5), d0 (-77.86), and cone angel (0.314). The initial condition for E and z0 could be (115270, 1017). The attached is one set of data and the model vi. If someone has such experience, could you possibly help me out? Your help is really appreciated.

Download All
0 Kudos
Message 1 of 9
(3,030 Views)
I am currently on my smartphone, so I cannot look at your code.

If you graph the model with the initial guesses, does it look anything like your data?

Dies the covariance matrix tell you anything? Maybe the parameters are correlated.

Fitting stops when no further improvements are possible. Just refitting does typically not discover anything new.
0 Kudos
Message 2 of 9
(3,019 Views)

I don't quite see how your model can generate anything similar to your data. Can you point me to a website that describes the model?

 

 

(Also, your model is very inefficient. The globals belong before the loop because the values hopefully don't change during the execution of the FOR loop.) 

0 Kudos
Message 3 of 9
(2,997 Views)

Thanks for the quick reply and suggestion!

 

The covariance seems fine. the matrix is (102189 , 23.3397

                                                               23.3397   0.0127) .

Do you think the matrix looks fine? Is there some way to get better fitting? 

 

Thanks a lot!

0 Kudos
Message 4 of 9
(2,996 Views)

Let us leave LabVIEW out of the discussion for a moment and just talk about your data and your model.

 

From a physics point of view I could explain why I think your model function vi is flawed, but I don't have time to go through the details now.  Let me just ask you to look at the data and look at your model.  Without looking hard I see that you have a y=sqrt(x) form for your model VI and that your data appears to be constant and then has a y=x^2 dependence.  No amount of fitting and refitting and jiggering with coefficients is going to help you here.

 

Look at your model again, figure out what is going on and get back to us.  What I like to do when tweaking is wire a control to the termination cluster of the LM VI, set the max iterations to zero and it will output f(x,a) for your input guesses.  Tweak the inputs until you are at least in the ballpark with your initial guesses, and then unleash the fit.

 

Post back if you need more help after you figure out what is going on with your model.  (I have a guess based on simple physics, you should know better if you actually use an AFM).

Message 5 of 9
(2,981 Views)

Thanks for your reply!

 

It is really amazing of you. How do you know the data is collecting from AFM!

 

The relationship in my model vi between y and x is  y= x+x^0.5+constant. It is also a typical model to fit the data. It is supposed that a good fitting could be accomplished.  Attached is one snapshot of fitting result.The fitting is close to the real data, that is why i wonder whether the better fitting could be achieved by loop.

 

Thanks again for your suggestion!

 

 

0 Kudos
Message 6 of 9
(2,969 Views)

Never used an AFM in my life, but it looks like the curves I see and if I was ever planning on measuring Young's modulus I would hope to have one around.

 

I still don't see a sqrt(x) behaviour in your data, your last screenshot was about as good of a fit as I was able to get with your original model, perhaps even better.  The transition I was seeing was either very sharp, or sqrt(x)-like over a broad range of parameters.  You can try iterating by hand a couple of times.  Take your best fit and feed the parameters into your initial guesses and try again.

 

My seat-of-the-pants guess is that the force is proportional to the square of the displacement.  I don't remember my continuum mechanics well enough to know if that is the case for a conical or spherical punch.  Anyways, I also think there is some model for the constant of proportionality that depends on E and mu and the cone angle and is probably where pi comes into your model.  To get E from my fit I would have to figure out that relation I can just tell you that the guess y=a*x^2 + y0 for x>d0 works pretty well.  Not perfect, so my simplified guess could probably use some fine-tuning.

 

FitAFM.PNG

0 Kudos
Message 7 of 9
(2,959 Views)

Thanks for your reply!

 

Attached are the descriptions of the model i used in the vi and one snapshot of fitting results.

 

Speaking of the  efficience,i do happen to the efficience problem. after i run for couples of times, the program is really stuck. The parameter in the model vi are the ones i need to control for difference groups of data. Could you possibly give some instruction about the better solution? Thanks

Download All
0 Kudos
Message 8 of 9
(2,947 Views)

> The relationship in my model vi between y and x is  y= x+x^0.5+constant 

 

Perhaps you mean x*x^0.5? The SPIP appnote you posted gives force proportional to displacement^(3/2) for a spherical indenter and proportional to displacement^2 for a pyramidal one. Your data looks like a reasonable fit to either from the point of contact onwards.

0 Kudos
Message 9 of 9
(2,915 Views)