×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Double Interpolation of Tabular Data

Double Interpolation of Tabular Data

Double Interpolation of Tabular Data

(OP)
In Excel, I have a table of data giving fluid densities (rho) with temperatures (T) and pressures (P) as parameters. In other words, my table looks like this:

DENSITY vs. T,P
P1 T1 Rho1,1
T2 Rho1,2
T3 Rho1,3
P2 T1 Rho2,1
T2 Rho2,2
T3 Rho2,3
etc.

My problem is that I want to estimate the densities at in between values of temperature and pressure and to use the estimated values in subsequent calculations. I could probably do it if I had a single interpolation, but it's looking extremely awkward. Anyone have a solution to this? (I'd prefer a non-VBA solution but would gladly accept anything that works.) Thanx.

RE: Double Interpolation of Tabular Data

Assuming that everything is linear...

If you were to graph your table you would have pressure on the X axis, Density on the Y axis and have three curves for temperature.

Imagine you want the density at P1.5, T1.5

You would enter your graph at P=1.5 on the X axis, go up to the T=1 curve and put a big black dot there.  Then you would go up to the T=2 curve and put a dot there.  Then you would draw a line between the two dots.

Next you would say, ok, T=1.5 is half way along that line.

So do your interpolation like you would if you were looking at the graph.

RE: Double Interpolation of Tabular Data

Here a simple excel file with a UDF macro for linear interpolation.
the excel file make a first linear interpolation on pressure and a second linear interpolation on temperature.
Should be better developed for upper bound, because now when p=pmax or t=tmax there is an error.
On C2 and C3 you should input the desired Pressure and temperature.
On A25:C37 there is the table.


Hope this help!

Onda

 

RE: Double Interpolation of Tabular Data

Interpolation in excel is a pain. It can be done using various lookup functions. The only way I know how to do it is to use index and match functions to find the data around the point you are interested in and then do the interpolation calculation.

For steam tables you can download a free excel add-in from http://www.cheresources.com/iapwsif97.shtml.  

Also look here http://www.techwareeng.com/products.htm for steam tables and an excel interpolation functions (I have not used these).

RE: Double Interpolation of Tabular Data

2d interpolation is handled beautifully by the free add-in xlxtrfun

Cheers

Greg Locock

SIG:Please see FAQ731-376: Eng-Tips.com Forum Policies for tips on how to make the best use of Eng-Tips.

RE: Double Interpolation of Tabular Data

You could introduce a new column that would give a calculated value between the other two columns to take care of one variable. Then use lookup values between the rows to calculate the interpolated value.

RE: Double Interpolation of Tabular Data

(OP)
"2d interpolation is handled beautifully by the free add-in xlxtrfun" - GregLocock

Greg, can you provide a link or otherwise tell us how to get to this add-in. Thanks.

RE: Double Interpolation of Tabular Data

I had the same problem the other day when I was calculating drag co-efficients on bridge superstructues. I am sure that any of the above methods work but this is how I went about the problem:

I wrote myself a VBA code

Function lin_interp(x, x1, y1, x2, y2)
lin_interp = (x - x1) / (x2 - x1) * (y2 - y1) + y1
End Function

This will give you a one-way linear interpolation if you like. So now you can apply this equation as many times as necessary to interpolate your in-between values.

For example, you know P1, P2, T1, T2, rho1, rho2 and you want to calculate rho at P1.5 and T1.5. You first run your linear interpolation to find the intermediate rho value at P1.5 and T1:

lin_interp(P1.5,P1,rho1(at T1),P2,rho2(at T1))
# This will calculate rho at P1.5 and T1.

Then you will need to calculate the intermediate rho value at P1.5 and T2:

lin_interp(P1.5,P1,rho1(at T2),P2,rho2(at T2))
# This will calulate rho at P1.5 and T2.

Now it is simply finding rho at P1.5 and T1.5.

lin_interp(T1.5,T1,rho(P1.5,T1),T2,rho(P1.5,T2)).

I haven't had a chance to look at the other solutions that have been posted but it sounds like they are easier than what I have posted.

 

RE: Double Interpolation of Tabular Data

See my example in the thread that dik has posted a link to as well! <wink>

-- MechEng2005

RE: Double Interpolation of Tabular Data

but isn't the relationship PV/T = k, ie P/T = kp.
so k = P1/(T1p1) and p2 = P1/(kT2)

RE: Double Interpolation of Tabular Data

oops ... should have read the OP "fluid", so the gas law obviously doesn't apply ... dang

RE: Double Interpolation of Tabular Data

For quick and dirty 2D interpolation I like the Shepard approach.

One does not need a regular mesh.

Each reference point has a weight inversely proportional to its distance to the point where the interpolation is desired.
Mathematically It's not very smart, and the method has serious drawbacks.   Practically it works fine for most engineering work.  Do not extrapolate.

PLease find an Excel spreadsheet.  

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources