LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Curve fit with 2 independent variables

Solved!
Go to solution

Hi all,

 

What I would like to be able to do solve for viscosity for a liquid at any given Pressure and Temperature.  What I have are two 1D arrays for Pressure and Temperature and then I have a 2D (20x200) array of viscosity values.  In the 2D array the rows represent Temperature and the columns represent Pressure.  I should also point out that in the 2D array there are NaN values entered at pressure/temperature points where the liquid is no longer a liquid.

 

I know there are many posts requesting the same thing but I can not seem to wrap my mind around how to get started on this.  I know that it is most likely a nolinear fit, but I have no particular model to use.  I have attached a vi that contains a sample of the data I will be using and was hoping somebody would be able to help get started on this.

 

Thanks

Terry

0 Kudos
Message 1 of 15
(4,498 Views)

Hi Terry,

 

why don't you use the interpolation functions coming with LabVIEW?

check.png

You should check for Pressure/Temperature vector being X or Y axis…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 15
(4,487 Views)

I subscribed to this thread just to see that response. I knew LV had a function to do it, but I couldn't think of the name for the life of me!

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 3 of 15
(4,483 Views)

In addition to interpolating, if you have a model that you want to test against the data points, you can use Nonlinear Curve Fit (from the Fitting Palette).  With this, you have a Model with some unknown parameters (for example, gain and time constant) and this finds the set of parameters that makes the model best fit the data.  You can also use this to test models -- compare how well Model A fits as opposed to Model B, or what happens if you add more parameters (higher-order terms) to the model.  [In the latter case, the model, with more terms, will almost always give you a better fit, but the uncertainty in the model parameters may make adding the additional terms meaningless].

 

Bob Schor

0 Kudos
Message 4 of 15
(4,478 Views)

Hi GerdW

 

I have tried using the interpolation in LV, but this does not give me a result that I can use.  The data I am using is from NIST, which has an online page that will calculate the viscosity for a liquid.  So when I use a value that is in between, for example I have used T=15 and P=100.  The labview interpolation gives me a value of 1.6642, but the value from the NIST site is 1.6514.

 

My understanding of interpolation is the assumption is the data is linear.  If you plot the data for the entire temperature range at P=100 it is a curve.  So I don't believe interpolation is the proper function to use.

 

Terry

0 Kudos
Message 5 of 15
(4,464 Views)

Hi Terry,

 

you didn't mention any "side considerations" before!

You asked for a possibility to get a value from a table using two coordinates and I told you a simple solution…

 

When you are concerned about an error due to interpolation you need to use a finer grid (=bigger 2D array with larger XY vectors) or use Bob's approach of applying a formula.

Or you just use libraries to calculate viscosity like RefProp or FluidProp!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 15
(4,441 Views)

Addition to my last post:

See this thread

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 15
(4,402 Views)

So, what exactly is the point of the fit if you have no model. Do you just want a smoother surface? Do you want to be able to interpolate to get an arbitrary value in-between the available grid points? What is the estimated error in the Z (viscosity) values?

 

The data looks pretty featureless, so a low order 2D polynomial is probably sufficient. Have you tried?

 

Also, Interpolation does not imply lienar. There are many other interpolation modes.

Message 8 of 15
(4,397 Views)

Thanks for the suggestion, but the NIST library does not contain the fluids I am dealing with.  I only used the values to create some data to work with.

 

Terry

0 Kudos
Message 9 of 15
(4,383 Views)

Hi Altenbach,

 

Is there a built in interpolation mode that would work with my data?  Yes, I need to find arbitrary values in-between grid points.  As far as what I am looking for in error that is a good question and I need to investigate further with my team to come up with an answer.  In the mean time if you think there is another labview function that will work with my data let me know and I will present the data using the 2d interpolation and from any other method to my team.

 

Thanks

 

Terry

0 Kudos
Message 10 of 15
(4,381 Views)