|
[Sponsors] |
Calculating Cp, gamma and others during runtime |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 5, 2020, 16:45 |
Calculating Cp, gamma and others during runtime
|
#1 |
Senior Member
Join Date: Dec 2019
Posts: 215
Rep Power: 7 |
Hi,
I would like to calculate the specific heat capacity cp, specific heat ratio gamma and Ma number during the computation. I have compiled a new solver based on rhoCentralFoam for this purpose. In createFields.H I have added: Code:
volScalarField cp ( IOobject ( "cp", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), thermo.Cp() ); volScalarField gamma ( IOobject ( "gamma", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), thermo.gamma() ); volScalarField Ma ( IOobject ( "Ma", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), mag(U)/sqrt(thermo.gamma()*thermo.p()/thermo.rho()) ); I wanted to add also the total temperature and total pressure for compressible fluids to be calculated during runtime, but I would like to calculate them using the Mach Number, which is not calculated right at the moment. Can anyone tell what I did wrong? Kind regards, shock77 |
|
June 5, 2020, 17:28 |
|
#2 |
Senior Member
Join Date: Dec 2019
Posts: 215
Rep Power: 7 |
Just found the solution to the problem.
For anyone with the same issue: Like meantioned in this thread (How to output other properties?), it has to added, that those values are written during runtime. I have also changed IOobject::READ_IF_PRESENT to IOobject::NO_READ So in the "while (runTime.run())" loop has to be added for example: cp = thermo.Cp(); |
|
June 5, 2020, 23:43 |
Must_read_if_modified
|
#3 |
New Member
Sen Wang
Join Date: Jul 2018
Location: Singapore / Notre Dame, U.S.
Posts: 19
Blog Entries: 1
Rep Power: 7 |
Hey,
Have you tried changing IOobject::READ_IF_PRESENT to IOobject::MUST_READ_IF_MODIFIED? Since your coefficients are set to AUTO_WRITE, it means at end of each runTime iter those variables get written to the time directory. While the proposed method above will achieve the same result as your method, it could be an alternative way to solve this issue (just to add to discussion). So in this way, you don't need to add Code:
cp = thermo.Cp() |
|
June 8, 2020, 03:33 |
|
#4 |
Senior Member
Join Date: Dec 2019
Posts: 215
Rep Power: 7 |
Hi,
yes, actually I have tried it before, but without success. I think it couldnt be updated, because it didnt change, since cp and so on werent calculated for further timesteps. Kind regards, shock77 |
|
July 20, 2020, 08:34 |
|
#5 |
Senior Member
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21 |
Have you tried the function object writeObjects? https://www.openfoam.com/documentati...teObjects.html
You could try either Cp or thermo.Cp and look if you get the fields written to the time folders (depending also on the writeInterval settings) |
|
July 20, 2020, 09:58 |
|
#6 |
Senior Member
Join Date: Dec 2019
Posts: 215
Rep Power: 7 |
Hi,
I actually haven't tried that, since it worked like I have described it above. But I think it is a good idea and when I have to do sth similar, I will try that too! Kind regards, shock77 |
|
July 22, 2020, 17:58 |
|
#7 |
Senior Member
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21 |
Today, OpenFOAM 8 has been released. It includes two improvements, which might also be helpful in this regard:
objectRegistry: Added support for optionally caching temporary objects https://github.com/OpenFOAM/OpenFOAM...9dc79ea4ba08ea objectRegistry: Corrected caching of registered temporary objects https://github.com/OpenFOAM/OpenFOAM...53fc652ead5395 |
|
|
|