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 Tree36Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 14, 2018, 04:38
Default tabulated properties for OpenFOAM 5.x
  #21
New Member
 
Join Date: Feb 2018
Location: France
Posts: 15
Rep Power: 8
Yuusha is on a distinguished road
Hi,

tilasoldo and I have rewritten the chriss85 code for OpenFOAM 5.x. It is available at GitHUB : https://github.com/Yuusha0/tabulatedThermophysicalProperties

The tabulated tables model works with psiThermo and rhoThermo. It has been improved to work with multi species simulations. However, due to OpenFOAM design, simulations are very slow with large tables. The heTabularThermo thermophysical type currently doesn't work. Please use hePsiThermo or heRhoThermo.

Table files design is the same as chriss85 original version. A python script is provided to easily transpose tables (like h(p, T)) from (T, p) to (p, T). More informations can be found in the README.md file.

Feel free to report bugs and/or submit patch on GitHub.
Yuusha is offline   Reply With Quote

Old   July 5, 2018, 05:10
Default
  #22
New Member
 
Jan Gaertner
Join Date: Nov 2017
Posts: 17
Rep Power: 8
janGaertner is on a distinguished road
Hey,


great work Yuusha for porting it to OpenFOAM-5.x.
I have downloaded your github repo and compilation went fine. Now when I wanted to test it on one of the tutorials (buoyantPimpleFoam/hotRoom/) I get the error message of unknown rhoThermo type and a list of possible options.


This was my thermophysicalProperties file

thermoType
{
type heRhoThermo;
mixture pureMixture;
transport const;
thermo hTabular;
equationOfState tabularEOS;
specie specie;
energy sensibleEnthalpy;
}
janGaertner is offline   Reply With Quote

Old   July 8, 2018, 12:25
Default
  #23
New Member
 
Join Date: Feb 2018
Location: France
Posts: 15
Rep Power: 8
Yuusha is on a distinguished road
Hi,

Maybe I'm not as clear as I think in the README. If you want to use this class with buoyantPimpleFoam, you have to recompile it. If you have made a standard installation of OpenFOAM, in the Make/options file, under the EXE_INC, add :
  • -I{$WM_PROJECT_USER_DIR}/src/thermophysicalModels/basic/lnInclude
  • -I{$WM_PROJECT_USER_DIR}/src/thermophysicalModels/specie/lnInclude
Under the EXE_LIBS, add :
  • -L{$FOAM_USER_LIBBIN}
  • -lTabularThermophysicalModels
  • -luserspecie
I advise you to modify the name of the solver in order to . For example, you can name it myBuoyantPimpleFoam in order to diferenciate it from the OpenFOAM original.

Maybe you have to slightly adapt it function of how your OpenFOAM is installed.
Yuusha is offline   Reply With Quote

Old   July 12, 2018, 03:31
Default
  #24
New Member
 
Jan Gaertner
Join Date: Nov 2017
Posts: 17
Rep Power: 8
janGaertner is on a distinguished road
Hello Yuusha,


I have actually found a different way now. I think it is probably not as clean but for me it had worked to test the libraries.

BuoyantPimpleFoam uses the rhoThermo class, therefore I have changed the rhoThermos.C file directly to allow the tabularEOS and hTabular options and recompiled the library.

In the system/controlDict file I added then the library

Code:
libs
(
  "libuserspecie.so"
);

With this the solver worked and I could test it.


I used your code now as a basis to extend it for my work with superheated flows. I have seen that the lookup function in the tables loop always over the complete table in the worst case to find the correct index. As my tables are generally constructed with a uniform spacing the lookup can be done directly.

My tests showed an improvement of the speed of up to 20 for 200x200 tables.



If you are interested in these interpolation tables I can share this over GitHub with you.





Best,


Jan
janGaertner is offline   Reply With Quote

Old   July 12, 2018, 09:36
Default
  #25
New Member
 
Join Date: Feb 2018
Location: France
Posts: 15
Rep Power: 8
Yuusha is on a distinguished road
Hi Jan,

I'm very interested by your improvement to the table reading. Chriss85 gave an improved version of table interpolation but we were unable to compile it. So the actual version is not the best.

Can you make a pull request on GitHub ? I will test and merge your improved version.
Yuusha is offline   Reply With Quote

Old   July 16, 2018, 10:11
Default
  #26
New Member
 
Jan Gaertner
Join Date: Nov 2017
Posts: 17
Rep Power: 8
janGaertner is on a distinguished road
I am still working on the tabularThermo directory for my personal code.



I have uploaded a gitHub repo with just the tables. I don't work much with GitHub, hope you can use and compare it with these too.


https://github.com/JanGaertner/fastInterpolationTable
janGaertner is offline   Reply With Quote

Old   July 23, 2018, 08:28
Default Version 2.0
  #27
New Member
 
Join Date: Feb 2018
Location: France
Posts: 15
Rep Power: 8
Yuusha is on a distinguished road
Hi,

A new version (v2.0) of thermophysical tables is available at GitHub : https://github.com/Yuusha0/tabulated...icalProperties

It features a new uniform search model (thanks to janGaertner), a bisection search algorithm, an optional tabular enthalpy of formation (if your data come from equilibrium chemistry for example) and a test case using rhoSimpleFoam.
Yuusha is offline   Reply With Quote

Old   September 30, 2018, 04:53
Default Update to OpenFOAM 6 version
  #28
New Member
 
Join Date: Feb 2018
Location: France
Posts: 15
Rep Power: 8
Yuusha is on a distinguished road
Hi,

A new version is available at GitHub : https://github.com/Yuusha0/tabulated...icalProperties.

It features the compatibility with OpenFOAM 6 and an improved python script to import and convert thermophysical tables.

People who still use OpenFOAM 5 can still use the version 2.0.2.
john myce likes this.
Yuusha is offline   Reply With Quote

Old   November 30, 2018, 04:22
Default Incertitude about the enthalpy
  #29
Member
 
Join Date: Sep 2018
Location: France
Posts: 62
Rep Power: 7
john myce is on a distinguished road
Hello guys,

First of all, thanks a lot for providing this tabulated method.

I have a doubt regarding the enthalpy I should provide in the table. In the tutorial made by Yuusha, I cannot find where those values for the enthalpy come from for the air.

Do you think I can put the enthalpy calculated by the NIST database?

Cheers.
john myce is offline   Reply With Quote

Old   November 30, 2018, 16:21
Default
  #30
New Member
 
Join Date: Feb 2018
Location: France
Posts: 15
Rep Power: 8
Yuusha is on a distinguished road
Hi John,


You can find the link to the source for the tables in constant/thermophysicalProperties. Data come from Thermal Plasmas : Fundamentals and Applicationsby Maher I. Boulos, Pierre Fauchais, Emil Pfender (https://doi.org/10.1007/978-1-4899-1337-1).


You can use data from any sources including NIST database. If your thermophysical properties are formated in csv, you can use the python script located in the python directory. Try python3 thermophysicalTable.py --help to see available options.
wyldckat and john myce like this.
Yuusha is offline   Reply With Quote

Old   December 20, 2018, 22:58
Default
  #31
Senior Member
 
Jianrui Zeng
Join Date: May 2018
Location: China
Posts: 157
Rep Power: 7
calf.Z is on a distinguished road
Hello,

I am using tabulated tables with buoyantPimpleFoam, which is based on rhoThermo. In creatfields.H:

volScalarField rho
(
IOobject
(
"rho",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE

),
thermo.rho()
);

I want to read rho by looking up "rho" file in constant. I changed :
......
IOobject::READ_IF_PRESENT, // IOobject::NO_READ,
IOobject::AUTO_WRITE // IOobject::NO_WRITE
......

But it doesn't work. When using rhosimpleFoam which is based on psiThermo, It can read the "rho" file with the same code of rho.

I guess the difference is caused by rhothermo and psithermo? How can I look up rho in file when using buoyantPimpleFoam?

I am also confused the function of rho = thermo.rho() in buoyantPimpleFoam, does it update rho?

Can someone help me with these confusing problems? Thank you very much.
calf.Z is offline   Reply With Quote

Old   January 4, 2019, 07:48
Default
  #32
Senior Member
 
Jianrui Zeng
Join Date: May 2018
Location: China
Posts: 157
Rep Power: 7
calf.Z is on a distinguished road
Thanks for the given library, it can work in psiThermo-based solver.

I want to check if Cp is changed with T. So in EEqn.H, I add these lines below thermo.correct():
......
thermo.correct();
volScalarField cp = thermo.Cp();
Info << "Cp: " << cp << endl;


The result is Cp is almost constant and T changed a lot. It seems Cp is not read from constant/cpTable according to the change of T.

Can someone give me some ideas? Thank you.
calf.Z is offline   Reply With Quote

Old   January 4, 2019, 07:59
Default
  #33
New Member
 
Jan Gaertner
Join Date: Nov 2017
Posts: 17
Rep Power: 8
janGaertner is on a distinguished road
Quote:
Originally Posted by calf.Z View Post
Thanks for the given library, it can work in psiThermo-based solver.

I want to check if Cp is changed with T. So in EEqn.H, I add these lines below thermo.correct():
......
thermo.correct();
volScalarField cp = thermo.Cp();
Info << "Cp: " << cp << endl;


The result is Cp is almost constant and T changed a lot. It seems Cp is not read from constant/cpTable according to the change of T.

Can someone give me some ideas? Thank you.
Hey,

how is your table built up?
Note, that the cp table is called with temperature as the first argument and then pressure, which is opposite of how the function is called! (see: https://github.com/Yuusha0/tabulated...bularThermoI.H)

@Yuusha: Maybe it would be good to change this to be consistent with the function call.
janGaertner is offline   Reply With Quote

Old   January 4, 2019, 08:10
Default
  #34
Senior Member
 
Jianrui Zeng
Join Date: May 2018
Location: China
Posts: 157
Rep Power: 7
calf.Z is on a distinguished road
Quote:
Originally Posted by janGaertner View Post
Hey,

how is your table built up?
Note, that the cp table is called with temperature as the first argument and then pressure, which is opposite of how the function is called! (see: https://github.com/Yuusha0/tabulated...bularThermoI.H)

@Yuusha: Maybe it would be good to change this to be consistent with the function call.
Thank you for replying.

I just use the cpTable given in github for testing. Its format is:

(
(300 ((1.e5 693.695)))
(400 ((1.e5 693.698)))
(500 ((1.e5 693.73)))
(600 ((1.e5 693.884)))
(700 ((1.e5 694.296)))
(800 ((1.e5 695.077)))
......

Do you mean that I should change the position of p and T in hTabularThermoI.H as follows:

inline Foam::scalar Foam::hTabularThermo<EquationOfState>::Cp
(
const scalar T, const scalar p
) const
{
// Info << "cp for T= " << T << ", p= " << p << ": " << cpTable(T, p) << endl;
return cpTable(T, p) + EquationOfState::Cp(T, p);
}

Or other places should I modify? Thank you.
calf.Z is offline   Reply With Quote

Old   January 4, 2019, 08:13
Default
  #35
New Member
 
Jan Gaertner
Join Date: Nov 2017
Posts: 17
Rep Power: 8
janGaertner is on a distinguished road
No, do not change the call of the equation of state Cp. In most cases this value is zero anyways.

You would need to change the function call of the extrapolationTable.

But your test table looks correct for this. So first temperature than pressure. Maybe introduce a info statement in the file I have linked to see if this is the function actually called.

I will give some coding example a bit later.
janGaertner is offline   Reply With Quote

Old   January 4, 2019, 08:25
Default
  #36
Senior Member
 
Jianrui Zeng
Join Date: May 2018
Location: China
Posts: 157
Rep Power: 7
calf.Z is on a distinguished road
Quote:
Originally Posted by janGaertner View Post
No, do not change the call of the equation of state Cp. In most cases this value is zero anyways.

You would need to change the function call of the extrapolationTable.

But your test table looks correct for this. So first temperature than pressure. Maybe introduce a info statement in the file I have linked to see if this is the function actually called.

I will give some coding example a bit later.
I have checked the value of rho and mu after simulation. Their value is correctly read from densityTable/muTable according to T .

But cp is almost staying constant, so it is not updated and the function is not called successfully? Or should I put some info to check?

And how can I check kappa value? I also want to check the relation between kappa and T. Thank you.
calf.Z is offline   Reply With Quote

Old   January 4, 2019, 08:47
Default
  #37
New Member
 
Jan Gaertner
Join Date: Nov 2017
Posts: 17
Rep Power: 8
janGaertner is on a distinguished road
Can you show me how your thermophysicalProperties file looks like? You should use hTabular to have the value dof the cpTable.

Best thing to check if the function with the table is called is to add an Info statement by including the commented out info statement

Code:
template<class EquationOfState>
inline Foam::scalar Foam::hTabularThermo<EquationOfState>::Cp
(
    const scalar p, const scalar T
) const
{
 Info << "cp for T= " << T << ", p= " << p  << ": " << cpTable(T, p) << endl;
    return cpTable(T, p) + EquationOfState::Cp(p, T);
}
janGaertner is offline   Reply With Quote

Old   January 4, 2019, 09:19
Default
  #38
Senior Member
 
Jianrui Zeng
Join Date: May 2018
Location: China
Posts: 157
Rep Power: 7
calf.Z is on a distinguished road
Quote:
Originally Posted by janGaertner View Post
Can you show me how your thermophysicalProperties file looks like? You should use hTabular to have the value dof the cpTable.
My thermophysicalProperties :

Code:
thermoType
{
    type            heTabularThermo;
    mixture         pureMixture;
    transport       tabular;
    thermo          hTabular;
    equationOfState tabularEOS;
    specie          specie;
    energy          sensibleInternalEnergy;
}

mixture
{
    specie
    {
        molWeight   28.9;
    }
    equationOfState
    {
	fileName    "constant/densityTable";
	outOfBounds extrapolate;
    }
    thermodynamics
    {
	Cp
	{
	    fileName    "constant/cpTable";
	    outOfBounds extrapolate;
	}
	h
	{
            fileName    "constant/hTable";
	    outOfBounds extrapolate;
	}
	hf     
        {
         Hf    0;
        }
    }
    transport
    {
	mu
	{
	    fileName    "constant/muTable";
	    outOfBounds extrapolate;
        }
	kappa
	{
            fileName    "constant/kappaTable";
	    outOfBounds extrapolate;
        }

    }
}
How can I see the info statement? I can see it during wmake libso or by other methods? Thank you.
calf.Z is offline   Reply With Quote

Old   January 5, 2019, 09:32
Default
  #39
Senior Member
 
Jianrui Zeng
Join Date: May 2018
Location: China
Posts: 157
Rep Power: 7
calf.Z is on a distinguished road
Quote:
Originally Posted by janGaertner View Post

Best thing to check if the function with the table is called is to add an Info statement by including the commented out info statement

Code:
template<class EquationOfState>
inline Foam::scalar Foam::hTabularThermo<EquationOfState>::Cp
(
    const scalar p, const scalar T
) const
{
 Info << "cp for T= " << T << ", p= " << p  << ": " << cpTable(T, p) << endl;
    return cpTable(T, p) + EquationOfState::Cp(p, T);
}
Thank you for giving the hints.

I add the info statement as you suggest. Then the values of cp, rho, mu, kappa were shown in the terminal, they are all correctly read from tables.

I am confused about the difference between muTable(T, p)/kappa(T,p) and muTable(p, T)/kappa(p,T), do they have different efficiency? Which one is more suggested? Thank you.
calf.Z is offline   Reply With Quote

Old   January 5, 2019, 17:16
Default
  #40
New Member
 
Jan Gaertner
Join Date: Nov 2017
Posts: 17
Rep Power: 8
janGaertner is on a distinguished road
Quote:
Originally Posted by calf.Z View Post

I am confused about the difference between muTable(T, p)/kappa(T,p) and muTable(p, T)/kappa(p,T), do they have different efficiency? Which one is more suggested? Thank you.



What you use depends on the table you have. If your viscosity table is organized with temperature as the first argument you have to use muTable(T,p) otherwise muTable(p,T).


The efficiency of the extrapolationTable depends on the table size and the search method.

  • simple has O(n)
  • bisect has O(log n)
  • uniform has O(1)
Practically uniform and bisect have nearly the same lookup time, thus I would recommend to always use bisect method unless you know your table is truly uniformly distributed and you can use uniform method.
janGaertner 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 9, 2021 23:37
ERROR: unable to find library HJH CFX 6 February 26, 2019 06:52
Forcing a solver to use your custom library. cdunn6754 OpenFOAM Programming & Development 0 March 30, 2017 16:05
Compiled library vs. inInclude Files, DSMC solver crashes after run GPesch OpenFOAM Programming & Development 8 April 18, 2013 07:17
OpenFOAM141dev linking error on IBM AIX 52 matthias OpenFOAM Installation 24 April 28, 2008 15:49


All times are GMT -4. The time now is 12:10.