Skip to content
Looking for how to ...
 
Notifications
Clear all

Looking for how to call a specific entry in a table, based on values of a parameter

5 Posts
2 Users
0 Reactions
1,146 Views
Avatar
Posts: 9
Customer
Topic starter
(@8k7pkkrbp6g5io8qanhk0zkdp9n2)
Active Member
Joined: 3 years ago
I am looking for what I think is a simple answer, but just can't figure it out. I am investigating Carbon Capture and Underground Sequestration. I have data on pressure and temperature in wells potentially usable for storage. I need to calculate the density of CO2 at that T&P. I have created a table of density values indexed on T(at 0.5C intervals) and P(at 0.2 MPa intervals) from the state of the art Equation of State. It was easy to round the given well values to the levels in my table, but now I need to call the individual value of the density from the table. What is the simplest way to do this? What I am doing is similar to what Excel does with the function INDIRECT(), but the guidance in Analytical tutorials is very obscure to me. 
4 Replies
Lonnie Chrisman
Posts: 42
Admin
(@lchrisman)
Member
Joined: 14 years ago

First, I'm wondering whether there is a much simpler approach. Density is n*w/V, where n is the number of molecules, w is the molecular mass, and V is the volume of the well. Note that n*w is the total mass of the CO2 in the well. From PV=nRT, or (n/V)=P/(RT), this becomes:

density = w*(n/V) = w * P / (R*T) = (w/R) * (P/T)

where R is Avogadro's number. w/R is constant and known, so it is just a constant times the ratio of pressure and temperature.  It seems like this relationship should hold, eliminating the need for any lookup table.

To the actual question of how to manage a 2-D lookup table, in a case like this linear interpolation would be appropriate. You could again consider indexing the table of (P/T) instead, making in a 1-D table, if that part of the above argument makes sense. Or you could nest the interpolations. Let the table be DensityTable indexed by Temp_Idx and Pres_Idx.  Let P and T be the values you want density for.

LinearInterp( Pres_Idx, LinearInterp( Temp_Idx, DensityTable, T, Temp_Idx ), P, Pres_Idx )

Reply
Avatar
Posts: 9
Customer
Topic starter
(@8k7pkkrbp6g5io8qanhk0zkdp9n2)
Active Member
Joined: 3 years ago

The standard gas equation would work well if, at depth within the earth, CO2 were an ideal gas. However, at any great depth, the CO2 is generally a liquid or a supercritical fluid. The National Institute of Standards and Technology provides an excellent web calculator that applies the best known Equation of State for CO2, and this is how I created my table.

However, your nested Linear Interpolation approach may go one better than the approach I had used in creating the table (in Excel). I had rounded off the input P and T and then found the exact rounded value in the table. Thanks for the suggestion. I will try it out and then check it against the precise values for a small dataset I have.

Reply
Avatar
Posts: 9
Customer
Topic starter
(@8k7pkkrbp6g5io8qanhk0zkdp9n2)
Active Member
Joined: 3 years ago

The Linear Interpolation approach works very well! Thanks for the suggestion, which actually went one better than the precise analog to Excel that I was asking for.

Reply
Lonnie Chrisman
Posts: 42
Admin
(@lchrisman)
Member
Joined: 14 years ago

I am sharing an alternative answer to Jeremy's question here that was produced by our prototype Analytica assistant, an AI research project we are currently working on. The prototype is no where near being in a form we can make available for quite a while, unfortunately, but those who are interested may want to watch for my upcoming weekly AI series of posts that will start July 27th. Watch for it on Lumina's social media channels. Among other things, I'll be writing about progress towards an Analytica AI assistant, and AI topics that come up along the way.

I just copy/pasted Jeremy's original question into our current early prototype (without modification) and received this answer, which appears pretty good (and is a different approach from the one I suggested).

[Assistant]

To accomplish your task in Analytica, you can use associative indexing to extract the desired value of CO2 density from your two-dimensional table.

First, let's assume that you have a table named `DensityTable`, indexed by temperature (T) and pressure (P). Also, you have your rounded temperature and pressure values stored in variables `Rounded_T` and `Rounded_P`.

To access the density value at a specific temperature and pressure, you can use the following expression:

DensityValue := DensityTable[T = Rounded_T, P = Rounded_P]

Here, `DensityValue` is a new variable that stores the density of CO2 at the specific temperature and pressure from your table.

This expression uses two-dimensional associative slicing, which returns the value from `DensityTable` at the specified temperature and pressure. This is the simplest way to extract a value from a multi-dimensional table in Analytica, and it's equivalent to using the INDIRECT function in Excel to reference a cell from its address.

Remember to replace `DensityTable`, `Rounded_T` and `Rounded_P` with your actual variable and index names as needed.

Reply
Share:

Download the free edition of Analytica

The free version of Analytica lets you create and edit models with up to 101 variables, which is pretty substantial since each variable can be a multidimensional array. It also lets you run larger modes in ‘browse mode.’ Learn more about the free edition.

While Analytica doesn’t run on macOS, it does work with Parallels or VMWare through Windows.


    Analytica Cubes Pattern

    Download the free edition of Analytica

    The free version of Analytica lets you create and edit models with up to 101 variables, which is pretty substantial since each variable can be a multidimensional array. It also lets you run larger modes in ‘browse mode.’ Learn more about the free edition.

    While Analytica doesn’t run on macOS, it does work with Parallels or VMWare through Windows.


      Analytica Cubes Pattern