|
[Sponsors] |
June 15, 2015, 05:00 |
Tabulated fluid thermo model
|
#1 |
New Member
Luka Denies
Join Date: Oct 2014
Posts: 28
Rep Power: 12 |
I have programmed a new thermo model to use tabulated fluid properties instead of the existing models. The model covers an equation of state, the thermodynamic properties as well as transport properties. All of these must be defined by the user in two-dimensional (p,T) tables that are then interpolated.
This feature is especially useful when simulating supercritical fluids that have rapidly changing properties near the critical point. Tabulating the properties avoids real-time calculation with complex equations for each cell. The first version is available at https://github.com/ldenies/tabulatedProperties Note that the code is not very tidy and still contains some remnants of the perfectGas files that were used as a basis. One question I have is how to load the table files from the case directory. I am currently loading them directly from my home directory which is neither desirable nor flexible; see beneath. Code:
cpTable_ ("/home/luka/cp") Code:
cpTable_ (runTime.path()/"constant/cp") |
|
June 29, 2015, 14:40 |
|
#2 |
New Member
Peter Bishop
Join Date: Jan 2012
Posts: 20
Rep Power: 14 |
Hi Luka,
I really appreciate your work, maybe this can help you http://www.cfd-online.com/Forums/ope...s-library.html Have you tried just typing ("constant/cp")? |
|
July 1, 2015, 06:16 |
|
#3 |
New Member
Luka Denies
Join Date: Oct 2014
Posts: 28
Rep Power: 12 |
Hi Peter,
Thanks a lot for the link! I was not aware of this work, even though I searched the forum for exactly this before starting on programming it myself. From looking at the code, their approach is indeed to simply put Code:
"constant/kappa" |
|
July 1, 2015, 06:35 |
|
#4 |
New Member
Peter Bishop
Join Date: Jan 2012
Posts: 20
Rep Power: 14 |
Hi Luka,
I'm looking at your work and I've compiled this library on my machine with some modifications to your original make files. Can you give me an example of table file format? Thanks keep in touch |
|
July 1, 2015, 06:56 |
|
#5 |
New Member
Luka Denies
Join Date: Oct 2014
Posts: 28
Rep Power: 12 |
Hi Peter,
I've added two example files in the attachment. I am close to finishing a validation project and will push a tutorial case to the repository soon, but this should get you started. |
|
July 1, 2015, 07:31 |
|
#6 |
Senior Member
Join Date: Oct 2013
Posts: 397
Rep Power: 19 |
Hi Luka,
I'm the author of the library which was already linked to. You can indeed use relative paths so you can put the libraries in the case folder. My library uses an enhanced table class which is also capable of linear extrapolation, should values outside of the table be needed. Let me know if you have any questions. By the way, I'm still working on the cpMcv and Z terms right now. Do you think there is a valid case where these can't be derived from the gas constant and the equation of state? |
|
July 1, 2015, 07:49 |
|
#7 |
New Member
Luka Denies
Join Date: Oct 2014
Posts: 28
Rep Power: 12 |
I think as long as there is a function in place to get the density as rho(p,T), compressibility Z can always be derived from p, T and R. This is because essentially, Z just gives the difference between real gas and ideal gas behaviour. I've implemented it as following:
Code:
Z = p/(rhoTable_(p,T)*this->R()*T); |
|
July 1, 2015, 08:27 |
|
#8 |
Senior Member
Join Date: Oct 2013
Posts: 397
Rep Power: 19 |
This is correct. What I'm wondering is if I can treat the gas constant as a function of p and T instead, so that cp-cv=R stays valid?
|
|
July 1, 2015, 08:45 |
|
#9 |
New Member
Luka Denies
Join Date: Oct 2014
Posts: 28
Rep Power: 12 |
In principle, I think you could. However, it is both at odds with the definition of the gas constant and more difficult to implement because OpenFOAM already offers the cpMcv function to deal with this.
I essence, the cpMcv variable already more or less does what you suggest; it keeps cp - cv equal to some changing property f(p,T). The difference is that now you do not need to directly manipulate the gas constant R. The latter would also interfere with the calculation of Z we discussed earlier. On another note, I think it would be interesting to merge both our projects to have a single library available for the community. I intend do some test cases with both libraries and compare the performance in terms of calculation time in the near future. |
|
July 1, 2015, 10:23 |
|
#10 |
Senior Member
Join Date: Oct 2013
Posts: 397
Rep Power: 19 |
I think you might be right, I was under the impression before that cp-cv=R all the time, and that meant for me that I had to use a variable R to make the relation valid. I need to do some reading to make sure this is the correct way to go about this, but I think you might be right.
I wouldn't mind joining them, but I need the extrapolation functionality, because I sometimes get results that lie out of the tables available to me, and extrapolating produces better results than clamping the tables. I guess this could be precomputed, but it's already up and running |
|
July 2, 2015, 07:46 |
|
#11 |
New Member
Luka Denies
Join Date: Oct 2014
Posts: 28
Rep Power: 12 |
I have updated the library on github. The fluid properties are now read from the constant directory in the way that was suggested here. A tutorial case has been added including fluid property files for supercritical methane. Lastly, some of the code has been cleaned.
Chris, I also think the linear extrapolation is a useful feature. If it turns out that the native interpolation2DTable is faster (which is absolutely not sure), we could still add the extrapolation behaviour to that code instead of clamping. |
|
July 3, 2015, 11:34 |
|
#12 |
New Member
Gert-Jan Meijn
Join Date: Apr 2015
Posts: 8
Rep Power: 11 |
Hi LukaD,
I am currently working on a project in which some look-up-tables would be very convenient. Could you tell me how you make the table-files? It seems they need to be structured in a certain way... Do they come directly from a software-package or did you write something yourself? |
|
July 6, 2015, 05:53 |
|
#13 |
Senior Member
Join Date: Oct 2013
Posts: 397
Rep Power: 19 |
Table structure goes like this:
( (x1 (y11 z11)(y12 z12)...) (x2 (y21 z21)(y22 z22)...) ... ) You will have to write these files yourself using a small script. I could provide a python script if you have an input csv file like this: 0 x1 x2 ... y1 z11 z21 ... y2 z21 z22 ... ... I don't remember the exact ordering from my head, you would have to check that yourself. |
|
July 7, 2015, 09:59 |
|
#14 |
New Member
Luka Denies
Join Date: Oct 2014
Posts: 28
Rep Power: 12 |
Chris is correct, this is the structure of table files in OpenFOAM. I generated the files myself with a Python script, based on equations for the properties reported in literature.
The properties are tabulated according to pressure (p) and temperature (T). The table then becomes ( ( p1 (T1 value11) (T2 value12) (T3 value13)) ( p2 (T1 value21) (T2 value22) (T3 value23)) ); where value12 equals the property value at p1 and T2. If I am not mistaken, the module of Chris has the tables the other way around, with temperature as the first "coordinate" and pressure as the second. |
|
July 7, 2015, 10:04 |
|
#15 |
Senior Member
Join Date: Oct 2013
Posts: 397
Rep Power: 19 |
As I said, I don't remember everything without looking it up again, but the reason for my ordering was that I use a table for h(p,T) and an inverted table for T(p,h). Due to the nonlinearity here we don't get an orthogonal coordinate grid. The way the table is structured requires one coordinate for one row of entries. The coordinates for the columns may be different though. This is why my order was required. It is also possible to use the method of temperature calculation which is already present in OpenFOAM, but it is much slower (and doesn't guarantee convergence) and I don't suggest to use it.
|
|
July 22, 2015, 12:20 |
|
#16 |
New Member
Peter Bishop
Join Date: Jan 2012
Posts: 20
Rep Power: 14 |
Hi Luka,
I downloaded your code and tutorial, I'm giving a deeper look at the tables you created but I'm not able to understand which units have you considered to create every table, in particular with reference to the enthalpy. I'm comparing it with the NIST database but numbers does not match |
|
July 23, 2015, 04:48 |
|
#17 |
Senior Member
Join Date: Oct 2013
Posts: 397
Rep Power: 19 |
Not speaking for Luka, but enthalpy should be in J/kg usually.
|
|
July 29, 2015, 15:47 |
|
#18 |
New Member
Peter Bishop
Join Date: Jan 2012
Posts: 20
Rep Power: 14 |
Thank you chriss!
Enthalpy table has to be created in J/kg because in the code it is then multiplied by molar weight. The same is for the cp table. Instead as I have understood the cpMcv table needs to be created in J/kmol K because it is not multiplied by the molar weight. Luka you should check the cpMcv table in the tutorial because I think it is created with wrong units, please let me know if I'm wrong! Thanks guys |
|
August 11, 2015, 08:19 |
|
#19 |
New Member
Luka Denies
Join Date: Oct 2014
Posts: 28
Rep Power: 12 |
You are both right, the enthalpy table is indeed in J/kg. The reason why the numbers are not the same as NIST is that I used another equation of state (GERG-2004). These do not have the same zero point. However, absolute differences between states are the same for both relations yield the same enthalpy difference.
It is also correct that the cpMcv table ought to be in J/(kmol K). I will change this when I update the repository. Luckily, the tutorial does not use a value for cv and neither have I ever used it in my simulations, so the mistake should not have had an impact. |
|
January 5, 2016, 05:24 |
|
#20 |
Member
Join Date: May 2015
Posts: 68
Rep Power: 11 |
Great work as far as I can evaluate!
[QUOTE=LukaD;550354]I have programmed a new thermo model to use tabulated fluid properties instead of the existing models. The model covers an equation of state, the thermodynamic properties as well as transport properties. All of these must be defined by the user in two-dimensional (p,T) tables that are then interpolated. [QUOTE] Is it also possible to define just one property using the tables and the others let's say using icoPolynomial? Did you test this Utility with chtMultiRegionSimpleFoam? I found the myChtSimpleFoam-solver which seems to answer this question but I would like to verify. |
|
Tags |
equation of state, supercritical, tabulated, thermo |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to incorporate the temperature of fluid in pressure based cavitation model | arindamsantra7 | Main CFD Forum | 0 | September 23, 2014 11:46 |
Overflow Error in Multiphase Modelling with Two Continuous Fluids | ashtonJ | CFX | 6 | August 11, 2014 15:32 |
Modeling interface of fluid and porous, not with default setting | ftab | CFX | 27 | May 20, 2014 07:58 |
Question about CFX transitional fluid model | Anna Tian | CFX | 1 | January 28, 2013 21:14 |
How to apply negtive pressure to outlet | bioman66 | CFX | 5 | June 3, 2006 02:40 |