CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Community Contributions

[Other] Tabulated thermophysicalProperties library

Register Blogs Community New Posts Updated Threads Search

Like Tree37Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 17, 2014, 05:40
Default Tabulated thermophysicalProperties library
  #1
Senior Member
 
Join Date: Oct 2013
Posts: 397
Rep Power: 19
chriss85 will become famous soon enough
I've finally gotten around to cleaning up my code for using tabulated material properties so I can release it.

Keep in mind that it's still work in progress, so please tell me if you find any problems.

Currently there is support for:
  • Equation of state (rho(T,p))
  • Enthalpy (h(p,T))
  • Heat conductivity (kappa(T,p))
  • Viscosity (mu(T,p))
The properties will be linearly extrapolated outside the ranges of the provided tables.


The code is based on the compressibility based formulation hePsiThermo, so heRhoThermo based solvers may not be supported (or only partially, haven't tried).
Also multiphase flows are currently unsupported. If anyone wants to add them, go ahead! It basically comes down to implementing the operators in the classes properly I think.


If you use the tabulated enthalpy, it is suggested that you provide an inverted T(p,h) table and use heTabularThermo instead of hePsiThermo for much better performance.


An example thermophysicalProperties file may contain these entries:

Code:
thermoType
{
    type            heTabularThermo;
    mixture         pureMixture;
    transport       tabular;
    thermo          hTabular;
    equationOfState tabularEOS;
    specie          specie;
    energy          sensibleInternalEnergy;
}
The tables are placed in the constant directory, using these names:
  • densityTable
  • kappaTable
  • hTable
  • TTable
  • muTable
  • cpTable (if you use the enthalpy model in this library and don't use heTabularThermo model you will need the heat capacity. I strongly suggest using heTabularThermo instead.)
The code produces a libTabularThermophysicalModels library that can be included in solvers directly in code or (probably) through function objects (don't quote me on that, I don't use them).

A table file looks like this:
Code:
(
(temperature1 ((pressure1 value11)(pressure2 value12)...)
(temperature2 ((pressure1 value21)(pressure2 value22)...)
...
)
For hTable and TTable the temperatures and pressures are exchanged, so the rows of the table contain the pressure. This is neccessary because the inverted TTable is not an orthogonal grid of points anymore. Sorry for this inconsistency, feel free to modify it if this bothers you.
Attached Files
File Type: zip tabularProperties.zip (63.5 KB, 486 views)
chriss85 is offline   Reply With Quote

Old   March 21, 2015, 15:21
Default
  #2
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings Chris,

I've created a basic wiki page to help getting your library known to the community that uses OpenFOAM technology: http://openfoamwiki.net/index.php/Co...erties_library

May you or anyone else feel free to update that wiki page!

Best regards,
Bruno
wyldckat is offline   Reply With Quote

Old   March 24, 2015, 08:31
Default
  #3
Senior Member
 
Join Date: Oct 2013
Posts: 397
Rep Power: 19
chriss85 will become famous soon enough
Thanks, that should help making it more visible.
chriss85 is offline   Reply With Quote

Old   May 8, 2015, 12:36
Default
  #4
Senior Member
 
Join Date: Oct 2013
Posts: 397
Rep Power: 19
chriss85 will become famous soon enough
I have worked on some performance optimizations for this library (avoiding some unnecessary lookups and using an interpolation search instead of linear search for finding data in the tables), in a real solver I got about 20% more speed. I will post it after some cleanup.
wyldckat and liquidspoon like this.
chriss85 is offline   Reply With Quote

Old   May 13, 2015, 06:44
Default
  #5
Senior Member
 
Join Date: Oct 2013
Posts: 397
Rep Power: 19
chriss85 will become famous soon enough
For some reason I find myself unable to edit the first post so I will post the files here.

I have tested both a binary search and an interpolation search with similar results. The binary search was commented out, feel free to use it if it works better for your use case.
Attached Files
File Type: zip tabulatedProperties.zip (31.7 KB, 294 views)
wyldckat, olivierG and PeterBishop like this.
chriss85 is offline   Reply With Quote

Old   June 29, 2015, 08:45
Default
  #6
New Member
 
Peter Bishop
Join Date: Jan 2012
Posts: 20
Rep Power: 14
PeterBishop is on a distinguished road
Great work! Are there any instructions to compile this library? For which OpenFOAM version is developed?

Thanks
PeterBishop is offline   Reply With Quote

Old   June 29, 2015, 09:03
Default
  #7
Senior Member
 
Join Date: Oct 2013
Posts: 397
Rep Power: 19
chriss85 will become famous soon enough
You compile this like any other OpenFOAM library, "wmake libso" in the thermophysicalModels\basic directory (afaik). It should work with any recent version I think, I have developed it on 2.3.x. BTW, if you need different gas constant or c_v, I'm currently working on that. See here if you can check check if this is correct: http://www.cfd-online.com/Forums/ope...tml#post552547
chriss85 is offline   Reply With Quote

Old   July 25, 2015, 16:20
Default
  #8
New Member
 
Walter
Join Date: Feb 2011
Posts: 8
Rep Power: 15
wsmith02 is on a distinguished road
Hi. I was starting to work on my own arbitrary function thermo properties class, but I was pointed this way. Thanks!

I downloaded the original zip that you posted. I think i had to change a few things to get it to work at all with a solve,. unfortunately, i probably dont remember them now. I think I at least added tabularThermo/tabularThermo.C to the Make/files. Anyway, I am attaching a zip with your tabularThermo class, buoyantSimpleFoam which I modified to use the class (now tableBuoyantSimpleFoam) and the constant dir that i created from the buoyant cavity case with made up properties, just to see how it worked.

I pretty much get a seg fault right off the bat when running the solver. Any idea why that might be? The log from the solver run is included.

Is there a good way to use your property functions with either of the buoyant solvers?

Thanks again for posting your work!
Attached Files
File Type: gz all.tar.gz (55.8 KB, 100 views)
wsmith02 is offline   Reply With Quote

Old   July 27, 2015, 06:40
Default
  #9
Senior Member
 
Join Date: Oct 2013
Posts: 397
Rep Power: 19
chriss85 will become famous soon enough
You need to compile this library as it is, and then add the library to the solver which is supposed to use it under Make/options-> EXE_LIBS.
chriss85 is offline   Reply With Quote

Old   July 27, 2015, 22:27
Default
  #10
New Member
 
Walter
Join Date: Feb 2011
Posts: 8
Rep Power: 15
wsmith02 is on a distinguished road
I am trying to test out the routine and since I am interested in using something like buoyantSimple/PimpleFoam I thought I would try to implement it there.

I really hope that I am not being awfully dense, I have some experience compiling functionObjects and custom solvers, but not thermo-properties.

I have written down exactly what I have done to modify buoyantPimpleFoam into tableBuoyantPimpleFoam and put it here (as chriss85 suggested, i have not modified the thermo stuff at all):

Code:
# Starting from $WM_PROJECT_USER_DIR
mkdir -p applications/solvers/heatTransfer
cd applications/solvers/heatTransfer
cp -R $FOAM_SOLVERS/heatTransfer/buoyantPimpleFoam .
mv buoyantPimpleFoam tableBuoyantPimpleFoam
cd tableBuoyantPimpleFoam
mv buoyantPimpleFoam.C tableBuoyantPimpleFoam.C
sed -i 's/buoyantPimpleFoam/tableBuoyantPimpleFoam/g' *.*
sed -i 's/buoyantPimpleFoam/tableBuoyantPimpleFoam/g' Make/*
sed -i 's/FOAM_APPBIN/FOAM_USER_APPBIN/g' Make/*
sed -i 's/rhoThermo/tabularThermo/g' *.*


################## Manual Edit ##################################
## Add to the end of EXE_INC
" \
    -I$(WM_PROJECT_USER_DIR)/src/thermophysicalModels/basic/lnInclude "

## Add to the end of EXE_LIBS
" \
    -L$(FOAM_USER_LIBBIN) \
    -lTabularThermophysicalModels "
################## /Manual Edit ##################################
the compilation errors that I am getting are something along the lines of :

Code:
pEqn.H: In function ‘int main(int, char**)’:
pEqn.H:6:25: error: no match for ‘operator-=’ in ‘Foam::tabularThermo::rho() -= Foam::operator*(const Foam::GeometricField<double, PatchField, GeoMesh>&, const Foam::GeometricField<double, PatchField, GeoMesh>&) [with PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]((*(const Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>*)(& p_rgh)))’
pEqn.H:79:25: error: no match for ‘operator+=’ in ‘Foam::tabularThermo::rho() += Foam::operator*(const Foam::GeometricField<double, PatchField, GeoMesh>&, const Foam::GeometricField<double, PatchField, GeoMesh>&) [with PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]((*(const Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>*)(& p_rgh)))’
/opt/openfoam230/src/finiteVolume/lnInclude/readTimeControls.H:38:8: warning: unused variable ‘maxDeltaT’ [-Wunused-variable]
make: *** [Make/linux64GccDPOpt/tableBuoyantPimpleFoam.o] Error 1
So it basically looks like it is complaining about operator "+=" and "-=" definitions that dont seem to exist. These are used in the solver so I thought they would be loaded as part of that compilation and would not be required as part of the thermo-properties.

I know that each thermo-property component (transport/thermo/eos) has its own
Code:
*I.H
file that defines specific operators such as this and yours is no different.

I am using vanilla OF230 (from dpkg) and made a clean $WM_PROJECT_USER_DIR just to test this out.

Any thoughts anyone has as to how i am being so dumb would be appreciated!

Thanks.
wsmith02 is offline   Reply With Quote

Old   July 28, 2015, 04:59
Default
  #11
Senior Member
 
Join Date: Oct 2013
Posts: 397
Rep Power: 19
chriss85 will become famous soon enough
The library I created is based on psiThermo, not rhoThermo. I think this may be the difference because in psiThermo rho is a function of p and T and may not be writeable as it is the case with rhoThermo. I suggest that you either change my library so that the tables are functions of rho and T, and calculate p from rho and compressibility and have rho be writeable, or use another solver which is based on psiThermo.
wyldckat, Tobi and calf.Z like this.
chriss85 is offline   Reply With Quote

Old   November 3, 2015, 05:11
Default Implementation problems
  #12
New Member
 
Ritesh Bagul
Join Date: Apr 2011
Posts: 1
Rep Power: 0
rkbagul is on a distinguished road
Dear All,

This is very interesting thread for me as I am trying to apply tabulated property variation for simulation of flows of supercritical fluids. So, I followed above information.

I could run "wmake libso" based on the files provided by "chriss85". The library "libTabularThermophysicalModels.so" was created in "$FOAM_USER_LIBBIN".

Then I copied the "buoyantSimpleFoam" solver to user area and renamed and modified it to new name "tabsimpleFoam". I modified the Make/options file as below:

Code:
EXE_INC = \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/fvOptions/lnInclude \
    -I$(LIB_SRC)/sampling/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
    -I$(WM_PROJECT_USER_DIR)/src/thermophysicalModels/basic/lnInclude \ 
    -I$(LIB_SRC)/thermophysicalModels/radiationModels/lnInclude \
    -I$(LIB_SRC)/turbulenceModels \
    -I$(LIB_SRC)/turbulenceModels/compressible/RAS/lnInclude \
    -I$(LIB_SRC)/turbulenceModels/RAS \
  

EXE_LIBS = \
    -L$(FOAM_USER_LIBBIN) \
    -lfiniteVolume \
    -lfvOptions \
    -lsampling \
    -lmeshTools \
    -lfluidThermophysicalModels \
    -lspecie \
    -lradiationModels \
    -lcompressibleTurbulenceModel \
    -lcompressibleRASModels \
    -lmeshTools \
    -lTabularThermophysicalModels \
The solver compiled successfully with following message

Code:
SOURCE=tabsimpleFoam.C ;  g++ -m32 -Dlinux -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -O3  -DNoRepository -ftemplate-depth-100 -I/opt/openfoam231/src/finiteVolume/lnInclude -I/opt/openfoam231/src/fvOptions/lnInclude -I/opt/openfoam231/src/sampling/lnInclude -I/opt/openfoam231/src/meshTools/lnInclude -I/opt/openfoam231/src/thermophysicalModels/basic/lnInclude -I/home/ritesh/OpenFOAM/ritesh-2.3.1/src/thermophysicalModels/basic/lnInclude -I/opt/openfoam231/src/thermophysicalModels/radiationModels/lnInclude -I/opt/openfoam231/src/turbulenceModels -I/opt/openfoam231/src/turbulenceModels/compressible/RAS/lnInclude -I/opt/openfoam231/src/turbulenceModels/RAS  -IlnInclude -I. -I/opt/openfoam231/src/OpenFOAM/lnInclude -I/opt/openfoam231/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linuxGccDPOpt/tabsimpleFoam.o
g++ -m32 -Dlinux -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -O3  -DNoRepository -ftemplate-depth-100 -I/opt/openfoam231/src/finiteVolume/lnInclude -I/opt/openfoam231/src/fvOptions/lnInclude -I/opt/openfoam231/src/sampling/lnInclude -I/opt/openfoam231/src/meshTools/lnInclude -I/opt/openfoam231/src/thermophysicalModels/basic/lnInclude -I/home/ritesh/OpenFOAM/ritesh-2.3.1/src/thermophysicalModels/basic/lnInclude -I/opt/openfoam231/src/thermophysicalModels/radiationModels/lnInclude -I/opt/openfoam231/src/turbulenceModels -I/opt/openfoam231/src/turbulenceModels/compressible/RAS/lnInclude -I/opt/openfoam231/src/turbulenceModels/RAS  -IlnInclude -I. -I/opt/openfoam231/src/OpenFOAM/lnInclude -I/opt/openfoam231/src/OSspecific/POSIX/lnInclude   -fPIC -Xlinker --add-needed -Xlinker --no-as-needed Make/linuxGccDPOpt/tabsimpleFoam.o -L/opt/openfoam231/platforms/linuxGccDPOpt/lib \
-L/home/ritesh/OpenFOAM/ritesh-2.3.1/platforms/linuxGccDPOpt/lib -lfiniteVolume -lfvOptions -lsampling -lmeshTools -lfluidThermophysicalModels -lspecie -lradiationModels -lcompressibleTurbulenceModel -lcompressibleRASModels -lmeshTools -lTabularThermophysicalModels  -lOpenFOAM -ldl   -lm -o /home/ritesh/OpenFOAM/ritesh-2.3.1/platforms/linuxGccDPOpt/bin/tabsimpleFoam
However, when I used the solver to run a test case, a simple pipe with all walls and fluid at same temperature, constant directory containing the tables describing the tabular properties......it returned following message:

Code:
Create time
Create mesh for time = 0

Reading g
Reading thermophysical properties

Selecting thermodynamics package 
{
    type            heTabularThermo;
    mixture         pureMixture;
    transport       tabular;
    thermo          hTabular;
    equationOfState tabularEOS;
    specie          specie;
    energy          sensibleInternalEnergy;
}



--> FOAM FATAL ERROR: 
Unknown rhoThermo type 
thermoType
{
    type            heTabularThermo;
    mixture         pureMixture;
    transport       tabular;
    thermo          hTabular;
    equationOfState tabularEOS;
    specie          specie;
    energy          sensibleInternalEnergy;
}


Valid rhoThermo types are:

type         mixture                    transport   thermo       equationOfState           specie  energy                  

heRhoThermo  homogeneousMixture         const       hConst       incompressiblePerfectGas  specie  sensibleEnthalpy        
heRhoThermo  homogeneousMixture         const       hConst       perfectGas                specie  sensibleEnthalpy     ..etc....etc...
I am unable to make out why it did not recognise the new thermophysical model....

Attaching the solver files:

Please kindly help
Attached Files
File Type: gz tabsimpleFoam.tar.gz (3.5 KB, 56 views)

Last edited by wyldckat; November 7, 2015 at 13:03. Reason: Changed [QUOTE][/QUOTE] to [CODE][/CODE]
rkbagul is offline   Reply With Quote

Old   November 3, 2015, 12:05
Default
  #13
Senior Member
 
Join Date: Oct 2013
Posts: 397
Rep Power: 19
chriss85 will become famous soon enough
The code I published is currently only suited for the psiThermo model. For rhoThermo you will have to do the adjustments yourself I'm afraid. I would check for all files which mention psiThermo, look up some similar files in the original source and adapt them. If you know C++ this should be a possible task, unfortunately I cannot spend any time on this right now. There was a similar library released which might have used rhoThermo instead, maybe you can use that or use it as a template for the necessary changes.

Best of luck!
calf.Z likes this.
chriss85 is offline   Reply With Quote

Old   November 10, 2015, 05:51
Default
  #14
Member
 
Christa
Join Date: Apr 2011
Posts: 53
Rep Power: 15
user_of_cfx is on a distinguished road
chriss85 thank you for this amazing idea. I am surprised at the relatively limited options in the thermophysical properties tab (or maybe I just don't know how to implement an EoS other than that of perfect fluid).

Shockingly for me, I managed to compile the file properly, but I have some questions of another nature:

1. I just want to use a table to provide an EoS (rho[p,T]) and keep the rest as simple as possible. What would be a good set of parameters to use? Would for example the specifications below work well together?

Code:
thermoType
{
    type            heTabularThermo;
    mixture         pureMixture;
    transport       const;
    thermo          hConst;
    equationOfState tabularEOS;
    specie          specie;
    energy          sensibleInternalEnergy;
}
2. If the specification above is correct, then I suppose I only need to provide densityTable and that's it. Or will I also need cpTable?

I am going to try the good old trial and error to find an answer to my questions of course, but maybe a bit of a guide ("use this type with these tables etc") may be useful to other people as well as me, and save us all some time to do better things with your code


UPDATE

I seem to be getting the same error as rkbagul, but with psiThermo.

Last edited by user_of_cfx; November 10, 2015 at 12:26.
user_of_cfx is offline   Reply With Quote

Old   November 10, 2015, 12:25
Default
  #15
Senior Member
 
Join Date: Oct 2013
Posts: 397
Rep Power: 19
chriss85 will become famous soon enough
Code:
type            heTabularThermo;
means that the temperature will be determined by a table T(h,p). This is only needed if you also provide h(T,p) as a table with
Code:
thermo          hTabular;
.
I think you should use heThermo instead of heTabularThermo if I recall correctly.
chriss85 is offline   Reply With Quote

Old   November 11, 2015, 05:42
Default
  #16
Member
 
Christa
Join Date: Apr 2011
Posts: 53
Rep Power: 15
user_of_cfx is on a distinguished road
Thanks for the quick reply, I switched back to hePsiThermo (I will try heThermo as well), and it looks like I am not getting the density table syntax right. I arranged my file like this:

Code:
(
(temperature1 ((pressure1 value11)(pressure2 value12)...)
(temperature2 ((pressure1 value21)(pressure2 value22)...)
...
)
and received error in the very first line of code:

Code:
expected " ( " while reading Tuple2, found on line 3 the label 101325
(101325 being the first pressure point, or pressure1)

Reading through the forum it appears that it's some sort of bug but which was fixed in the meantime? But the posts I've seen refer to time dependent boundary conditions so the fix looks way more complicated than what I am trying to do here. I'm sorry if this is something super silly.

UPDATE Nevermind, it WAS a silly syntax error.. I should have counted the brackets *sigh* a syntax that runs:
Code:
(
(temperature1 ((pressure1 value11)(pressure2 value12)...))
(temperature2 ((pressure1 value21)(pressure2 value22)...))
...
)

Last edited by user_of_cfx; November 11, 2015 at 06:58.
user_of_cfx is offline   Reply With Quote

Old   April 11, 2016, 16:34
Default TTable
  #17
New Member
 
anas
Join Date: Jun 2015
Posts: 18
Rep Power: 11
AnasCFD is on a distinguished road
Could you please tell me what is TTable which is used in TabularEOS.

Thanks
AnasCFD is offline   Reply With Quote

Old   April 12, 2016, 05:02
Default
  #18
Senior Member
 
Join Date: Oct 2013
Posts: 397
Rep Power: 19
chriss85 will become famous soon enough
By default OpenFOAM uses Newton's method to find the temperature from the energy and pressure. This means that many evaluations of the h(p,T) function are required. Normally this is not a problem because in the case of polynomials or so this function is very cheap to evaluate. However, when you need to lookup the value in a large table it can impose a performance drop. To avoid this, you can calculate a T(p,h) table yourself in advance which is just the inverted h(p,T) table with coordinates exchanged. If you use the appropriate thermophysical model this method will be used.

By the way, I have updated a few things regarding this library, so I will release a new version soon if I can find the time. Also, please keep in mind that not all solvers are written to account for pressure dependences in h(p,T) and rho(p,T). Some solvers may require additional terms.
chriss85 is offline   Reply With Quote

Old   May 24, 2017, 03:49
Default Build these codes into foam-extend version 3.0
  #19
Member
 
Janry
Join Date: Oct 2015
Posts: 46
Rep Power: 11
qjh888 is on a distinguished road
Hi Chriss,

Thanks for your excellent work!
Currently I'm trying to build your code into foam-extend version.
However, the foam-extend 3.0 version (even more latest 4.0 version) has no hePsiThermo and fluidThermo module.

So I'm just wondering if you have interest in transfer your work into foam-extend?
That will be helped a lot!

Thanks and waiting for your reply.

Janry
tilasoldo likes this.
qjh888 is offline   Reply With Quote

Old   July 12, 2017, 06:19
Default OpenFoam 4.x version
  #20
New Member
 
Xavier Lamboley
Join Date: Jan 2015
Location: Bordeaux, France
Posts: 13
Rep Power: 11
tilasoldo is on a distinguished road
Hi chriss85,

First of all thank you for your work, I am amazed by the fact that OpenFoam still doesn't provide a solution for tabulated thermophysical properties, and you implementation is truly wonderful.

I am (also) aiming at adapting it for OpenFOAM 4.x, as some classes have changed since OF 2.3 I will publish my code as soon as I get to validate it!

Regards,
Xavier L.
parthigcar likes this.
tilasoldo is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Other] Multi species mass transport library [update] novyno OpenFOAM Community Contributions 111 November 10, 2021 00:37
ERROR: unable to find library HJH CFX 6 February 26, 2019 07:52
Forcing a solver to use your custom library. cdunn6754 OpenFOAM Programming & Development 0 March 30, 2017 17:05
Compiled library vs. inInclude Files, DSMC solver crashes after run GPesch OpenFOAM Programming & Development 8 April 18, 2013 08:17
OpenFOAM141dev linking error on IBM AIX 52 matthias OpenFOAM Installation 24 April 28, 2008 16:49


All times are GMT -4. The time now is 22:51.