|
[Sponsors] |
[Other] Tabulated thermophysicalProperties library |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
September 17, 2014, 05:40 |
Tabulated thermophysicalProperties library
|
#1 |
Senior Member
Join Date: Oct 2013
Posts: 397
Rep Power: 19 |
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:
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; }
A table file looks like this: Code:
( (temperature1 ((pressure1 value11)(pressure2 value12)...) (temperature2 ((pressure1 value21)(pressure2 value22)...) ... ) |
|
March 21, 2015, 15:21 |
|
#2 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
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 |
|
March 24, 2015, 08:31 |
|
#3 |
Senior Member
Join Date: Oct 2013
Posts: 397
Rep Power: 19 |
Thanks, that should help making it more visible.
|
|
May 8, 2015, 12:36 |
|
#4 |
Senior Member
Join Date: Oct 2013
Posts: 397
Rep Power: 19 |
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.
|
|
May 13, 2015, 06:44 |
|
#5 |
Senior Member
Join Date: Oct 2013
Posts: 397
Rep Power: 19 |
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. |
|
June 29, 2015, 08:45 |
|
#6 |
New Member
Peter Bishop
Join Date: Jan 2012
Posts: 20
Rep Power: 14 |
Great work! Are there any instructions to compile this library? For which OpenFOAM version is developed?
Thanks |
|
June 29, 2015, 09:03 |
|
#7 |
Senior Member
Join Date: Oct 2013
Posts: 397
Rep Power: 19 |
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
|
|
July 25, 2015, 16:20 |
|
#8 |
New Member
Walter
Join Date: Feb 2011
Posts: 8
Rep Power: 15 |
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! |
|
July 27, 2015, 06:40 |
|
#9 |
Senior Member
Join Date: Oct 2013
Posts: 397
Rep Power: 19 |
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.
|
|
July 27, 2015, 22:27 |
|
#10 |
New Member
Walter
Join Date: Feb 2011
Posts: 8
Rep Power: 15 |
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 ################################## 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 I know that each thermo-property component (transport/thermo/eos) has its own Code:
*I.H 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. |
|
July 28, 2015, 04:59 |
|
#11 |
Senior Member
Join Date: Oct 2013
Posts: 397
Rep Power: 19 |
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.
|
|
November 3, 2015, 05:11 |
Implementation problems
|
#12 |
New Member
Ritesh Bagul
Join Date: Apr 2011
Posts: 1
Rep Power: 0 |
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 \ 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 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... Attaching the solver files: Please kindly help Last edited by wyldckat; November 7, 2015 at 13:03. Reason: Changed [QUOTE][/QUOTE] to [CODE][/CODE] |
|
November 3, 2015, 12:05 |
|
#13 |
Senior Member
Join Date: Oct 2013
Posts: 397
Rep Power: 19 |
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! |
|
November 10, 2015, 05:51 |
|
#14 |
Member
Christa
Join Date: Apr 2011
Posts: 53
Rep Power: 15 |
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; } 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. |
|
November 10, 2015, 12:25 |
|
#15 |
Senior Member
Join Date: Oct 2013
Posts: 397
Rep Power: 19 |
Code:
type heTabularThermo; Code:
thermo hTabular; I think you should use heThermo instead of heTabularThermo if I recall correctly. |
|
November 11, 2015, 05:42 |
|
#16 |
Member
Christa
Join Date: Apr 2011
Posts: 53
Rep Power: 15 |
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)...) ... ) Code:
expected " ( " while reading Tuple2, found on line 3 the label 101325 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. |
|
April 11, 2016, 16:34 |
TTable
|
#17 |
New Member
anas
Join Date: Jun 2015
Posts: 18
Rep Power: 11 |
Could you please tell me what is TTable which is used in TabularEOS.
Thanks |
|
April 12, 2016, 05:02 |
|
#18 |
Senior Member
Join Date: Oct 2013
Posts: 397
Rep Power: 19 |
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. |
|
May 24, 2017, 03:49 |
Build these codes into foam-extend version 3.0
|
#19 |
Member
Janry
Join Date: Oct 2015
Posts: 46
Rep Power: 11 |
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 |
|
July 12, 2017, 06:19 |
OpenFoam 4.x version
|
#20 |
New Member
Xavier Lamboley
Join Date: Jan 2015
Location: Bordeaux, France
Posts: 13
Rep Power: 11 |
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. |
|
|
|
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 |