# [Publications] Mathematics, Numerics, Derivations and OpenFOAM

 Register Blogs Members List Search Today's Posts Mark Forums Read

 January 11, 2016, 11:04 Mathematics, Numerics, Derivations and OpenFOAM #1 Super Moderator     Tobias Holzmann Join Date: Oct 2010 Location: Tussenhausen Posts: 2,708 Blog Entries: 6 Rep Power: 51 Dear all, during the derivation of the stress equations that are implemented in OpenFOAM, I started to derive the mass, momentum and (not complete) the energy equation. Furthermore, I showed and proofed that the vector form of the equations are equal to the Cartesian notation. The content is: Derivation of mass and momentum equation General conserved equation Energy equation Reynolds-Averaging Shear-Rate Tensor Mathematics Numerics Turbulence modelling More about divDevRhoREff and divDevReff Derive shear-rate tensor for pisoFoam Different notations for the NS-Equations Matrix Algebra Cauchy - Stress tensor, shear-rate tensor and pressure http://www.holzmann-cfd.de/index.php/en/publications Feel free to comment on that and I hope that it is helpful, clear and understandable. Happy new year to everybody philippose, balkrishna, olivierG and 39 others like this. __________________ Keep foaming, Tobias Holzmann Last edited by Tobi; January 22, 2016 at 05:03. Reason: Changed the link

 January 20, 2016, 13:51 #2 Senior Member   Jon Elvar Wallevik Join Date: Nov 2010 Location: Reykjavik, ICELAND Posts: 103 Rep Power: 19 Nice work Tobias! I have newer seen the name “shear rate tensor” for tau (usually referred to as the extra stress tensor, as you also use). What you probably mean with “shear rate tensor” is when “tau” represents the GNM (the Generalized Newtonian Model). But the extra stress tensor “tau” can be much nastier than GNM. Regarding Chapter 6, if you want also to explain why shear rate is calculated as is done in OpenFOAM (sqrt(2 e:e)), then in my paper I show proof of that in Section 3. It also explains the GNM and it relationship with non-Newtonian fluids, with some good references (the paper is using the MRF in OpenFOAM for non-Newtonian fluids). If you use this, please make ref to my paper. Thanks. Again, nice work man. Cheers J. P.s. the reference is... J.E. Wallevik, Effect of the hydrodynamic pressure on shaft torque for a 4-blades vane rheometer, International Journal of Heat and Fluid Flow, 50 (2014) 95–102. DOI: 10.1016/j.ijheatfluidflow.2014.06.001

 January 20, 2016, 15:11 #3 Super Moderator     Tobias Holzmann Join Date: Oct 2010 Location: Tussenhausen Posts: 2,708 Blog Entries: 6 Rep Power: 51 Hi Jon, thanks for the feedback and the hint to your paper. My colleague also uses your shear-rate calculation for visco-plastic modeling but at the moment there was no time also to include Non-Newtonian fluids. Mostly (as you already realized, I talk about Newtonian fluids). To the "extra-stress tensor" tau. In many of my literature (maybe due to the fact that most of them are German books, are using this form. Also Ferziger and Perić use this nomenclature. That the extra stress tensor could be much worser is clear, especially if we have Non-Newtonian fluids. If I have access to the paper (I think I have it at my university), I will check it out and extend it. But at the moment I have a lot of other stuff to do. By the way, there is still a problem in my reynolds-averaging that I do not know exactly. Maybe you can answer this question: I showed how we get the RANS equation and used the Buossinesq approximation where I said that the term is neglected. The question is, is it really neglected because Pope et. al. wrote that we can take this term to the pressure and get a modified pressure p': Do you know if we calculate p' in OpenFOAM or do you have any other hint to that? I am not 100% sure about it. The hint came from Gerhald Holzinger (Linz). Thanks again, Tobi __________________ Keep foaming, Tobias Holzmann

 January 21, 2016, 05:30 #4 Senior Member   Jon Elvar Wallevik Join Date: Nov 2010 Location: Reykjavik, ICELAND Posts: 103 Rep Power: 19 I will take a look,... pretty max out right now, but I will give feedback soon on this, if I have anything on this or not. cheers J.

January 22, 2016, 03:16
#5
Member

Likun
Join Date: Feb 2013
Posts: 52
Rep Power: 13
Quote:
 Originally Posted by Tobi By the way, there is still a problem in my reynolds-averaging that I do not know exactly. Maybe you can answer this question: I showed how we get the RANS equation and used the Buossinesq approximation where I said that the term is neglected. The question is, is it really neglected because Pope et. al. wrote that we can take this term to the pressure and get a modified pressure p': Do you know if we calculate p' in OpenFOAM or do you have any other hint to that? I am not 100% sure about it. The hint came from Gerhald Holzinger (Linz). Thanks again, Tobi
Hi Tobis,

I had the same question before, see this post http://www.cfd-online.com/Forums/ope...-stresses.html. And I realized that the second term is indeed negligible compared to p, unless k is very large.

Best,
Likun

 January 24, 2016, 14:00 #6 Senior Member   Jon Elvar Wallevik Join Date: Nov 2010 Location: Reykjavik, ICELAND Posts: 103 Rep Power: 19 Hi Tobi and Likun When going into the source code of simpleFoam, I cannot see it is possible that the solver is working with a modified pressure. If this were the case, the pressure equation would have to get the term 2/3*k*I from somewhere, but there is no hint of this term anywhere in the solver. However, I did another test. I went into ~/OpenFOAM/OpenFOAM-2.4.x/src/turbulenceModels/incompressible/RAS/kEpsilon/kEpsilon.C ...and did this (see the member function R() above the member divDevReff())... tmp kEpsilon::divDevReff(volVectorField& U) const { return ( // - fvm::laplacian(nuEff(), U) // - fvc::div(nuEff()*dev(T(fvc::grad(U)))) // -------------------------------------------------------- // Y16M01D24: - fvm::laplacian(nuEff(), U) - fvc::div( nuEff()*dev(T(fvc::grad(U))) - ((2.0/3.0)*I)*k_ ) ); } Thereafter, I tested pitzDaily with and without the modification, after running stressComponents, I saw no difference between the the two cases. So if one want, it is possible to add this, but at least in the pitsDaily case, it is not important. Note, with modification, you have to add div(((nuEff*dev(T(grad(U))))-((0.666667)*k))) Gauss linear; into ./system/fvSchemes (in divSchemes) J. Likun likes this.

 January 26, 2016, 06:22 #7 Super Moderator     Tobias Holzmann Join Date: Oct 2010 Location: Tussenhausen Posts: 2,708 Blog Entries: 6 Rep Power: 51 Hey Jon, thanks for the clearness. As I supposed in my paper it is neglected. Thanks for checking this. @all. I found a mistake in the enthalpy equation of chapter 3. I changed it and added one more hint. The correct diffusion term is (of course): Also the temperature equation has to be changed. The new PDF is up to date. __________________ Keep foaming, Tobias Holzmann

 January 30, 2016, 07:54 #8 Super Moderator     Tobias Holzmann Join Date: Oct 2010 Location: Tussenhausen Posts: 2,708 Blog Entries: 6 Rep Power: 51 Hi all, again I found some mistakes in my paper. I will change it the next days and let you know when it is finished and uploaded. Cheers ssss likes this. __________________ Keep foaming, Tobias Holzmann

January 31, 2016, 11:08
#9
Senior Member

Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21
Quote:
 Originally Posted by Tobi Feel free to comment on that and I hope that it is helpful, clear and understandable.
I think it would be better if your text was more in line with the books (Ferziger, Versteeg, Anderson) you reference to. Specifically for the part when you derive momentum equation (2.14). The second term in the right hand side of the equation comes with minus sign (-nabla . tau); so does components of a shear stress tensor in equations (4.1)-(4.6). Even though those minuses just cancel out in the end and the final equation (4.13) is the same as in the books, it would be more easy to follow your text if your text followed the books.

Looking at the energy equation (3.4) it is not clear where all the terms come from. I suggest that you should derive the energy equation the way you did with continuum and momentum equations, i.e. start with an infinitesimal fluid volume, formulate the equation in Cartesian scalar notation and transform it into a vector form. Here is the useful link: http://cfd.direct/openfoam/energy-equation/

Misprints:
eq. (2.21): rho was left out.
eq. (4.27): nabla was left out.

Anyway, good job!

January 31, 2016, 15:14
#10
Super Moderator

Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Quote:
 Originally Posted by Zeppo Very interesting! Can this article develop into anything big?
It could be, I can offer the LaTeX files and everybody can include some stuff.
Quote:
 I think it would be better if your text was more in line with the books (Ferziger, Versteeg, Anderson) you reference to. Specifically for the part when you derive momentum equation (2.14). The second term in the right hand side of the equation comes with minus sign (-nabla . tau); so does components of a shear stress tensor in equations (4.1)-(4.6). Even though those minuses just cancel out in the end and the final equation (4.13) is the same as in the books, it would be more easy to follow your text if your text followed the books.
Of course the minus signs will turn to "+" at least but due to my derivation we get the -nabla . tau at the beginning. I followed the book of Bird (Transport Phenomena) here very close.

Quote:
 Looking at the energy equation (3.4) it is not clear where all the terms come from. I suggest that you should derive the energy equation the way you did with continuum and momentum equations, i.e. start with an infinitesimal fluid volume, formulate the equation in Cartesian scalar notation and transform it into a vector form. Here is the useful link: http://cfd.direct/openfoam/energy-equation/
Of course it would be the best but I had no time for that and just took the term from the books. If you want, I will do the same work for energy equation to demonstrate where the terms come from (good hint). But for it was clear after the first two derivation how to do it and I was not sure if anybody is think that this could be useful. At least due to the fact, that a lot of books are out.

Quote:
 Misprints: eq. (2.21): rho was left out. eq. (4.27): nabla was left out.
Thank you for the good reviewing.

Quote:
 Anyway, good job!
Thank you again. Very nice critic. Now I can improve it more.

PS: I also found other mistakes (icoFoam) and derivation to POISSON equation. These are fixed. I will also fix the stuff you mentioned and maybe add Non-Newtonian + Energy-derivation to the documentation.

Good night to everybody.
Tobi

__________________
Keep foaming,
Tobias Holzmann

February 15, 2016, 10:09
#11
Senior Member

Join Date: Oct 2013
Posts: 397
Rep Power: 18
I have recently written a document about the derivation of the enthalpy equation from the total energy equation and the handling of source terms. I figured it might be of some interest here so I'm posting it. Please let me know what you think and if there are errors.

Edit: Some updates to the document.
Edit 2: Added heat conduction term which arises when h=h(p,T).
Attached Files
 Derivation of the enthalpy equation.pdf (107.0 KB, 130 views)

Last edited by chriss85; February 17, 2016 at 08:18.

 February 17, 2016, 04:40 #12 Senior Member   Join Date: Oct 2013 Posts: 397 Rep Power: 18 Has anyone checked the derivation for errors? I recently learned in a discussion with mkraposhin that there is also an additional heat conduction term when the enthalpy function depends on pressure. I have updated the document to reflect this. I have done some tests to investigate the influence of the additional mass and momentum source terms in the energy equation as well as the additional heat conduction term. In my case they provide small but visible differences so I would suggest to include them. Edit: Actually the inclusion of the E*S_M term in the enthalpy equation looks to be significant for my case at later times in the simulation. Last edited by chriss85; February 17, 2016 at 08:19.

 February 17, 2016, 08:40 #13 Super Moderator     Tobias Holzmann Join Date: Oct 2010 Location: Tussenhausen Posts: 2,708 Blog Entries: 6 Rep Power: 51 Hey Chris, I checked your summary and its fine. Just a few hints. You never mentioned what the term stand for. Of course it is the mass source term but you should mention that it is zero. Normally we are not dealing with fusion or sth. like that. Additional, people who are not familiar with the mathematic would not know why you multiply the continuity equation by the energy E eqn. (5). Therefore (it is my opinion) the derivation is in the wrong direction. For me it would be clear to derive the conserved energy equation and use the conti to go to the non-conserved form. You did it vice versa and hence, people can get confused why you e.g. multiply the conti by E. Nontheless, nice stuff. PS: A lot of authors use the total derivative to derive conserved equations. __________________ Keep foaming, Tobias Holzmann

February 17, 2016, 08:53
#14
Senior Member

Join Date: Oct 2013
Posts: 397
Rep Power: 18
Quote:
 Originally Posted by Tobi You never mentioned what the term stand for. Of course it is the mass source term but you should mention that it is zero. Normally we are not dealing with fusion or sth. like that.
Agreed, some explanation of the terms might be useful. I included a mass source because it can appear in ablation or evaporation models that don't implement it through a boundary condition but as source in the first cell layer. If you can point me to a proper implementation of such models through boundary conditions I would be quite happy .

Quote:
 Additional, people who are not familiar with the mathematic would not know why you multiply the continuity equation by the energy E eqn. (5). Therefore (it is my opinion) the derivation is in the wrong direction. For me it would be clear to derive the conserved energy equation and use the conti to go to the non-conserved form. You did it vice versa and hence, people can get confused why you e.g. multiply the conti by E.
In this case I started with the equation for the total energy which is present in Versteeg, "Computational Fluid Dynamics" and derived the equation which is used in the pisoCentralFoam solver by mkraposhin while considering these additional terms. I feel that this is the most generic solution because you can still just omit terms from the equations which are zero.
Quote:
 PS: A lot of authors use the total derivative to derive conserved equations.
Yes, but I wanted to show how to get to the final equation that is used in the solver.

February 17, 2016, 10:30
#15
Super Moderator

Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Quote:
 Originally Posted by chriss85 In this case I started with the equation for the total energy which is present in Versteeg, "Computational Fluid Dynamics" and derived the equation which is used in the pisoCentralFoam solver by mkraposhin while considering these additional terms. I feel that this is the most generic solution because you can still just omit terms from the equations which are zero.
I know, also in other literature you will start with the total derivative (but here you miss always the conti equation) and you start with a non-conservative form. Of course you will end up in a conservative form because you use the continuity equation but it is not as straight forward as derive the conservative form directly and then go to the non-conservative form. If you are familiar with the guys its not a problem, but for other people its "like" a mystery. For example you use the continuity equation:

and the total derivative:

Till now everything is clear for everybody. Next step is to add the continuity equation to the total derivative like:

Now (maybe) some people are wondering why you multiply the conti by . For me it is clear why you do this and why we have to multiply by . Everybody who is familiar with the mathematic background will not complain about that but beginners or non-familiar math guys get confused or do not know why has to be added

Thats the reason why I said (in my opinion) the better way would be to derive the conservative form first and then do simplifications or not. Why I tell you this, because I got really confused about all the equations. Everywhere and everybody uses other derivations, start from integrals, total derivatives etc. It like you read this book and this and you get more confused about the equations. Of course maybe I am a stupid guy who need a strict forward line (maybe); that was the reason why I derived everything out of a volume element. Then you really get the conserved equations, which can be simplified using the conti to non-conserved equations. If you did this once, of course you can do it vice versa (:

Anyway Well done.
__________________
Keep foaming,
Tobias Holzmann

 February 18, 2016, 09:57 #16 Super Moderator     Tobias Holzmann Join Date: Oct 2010 Location: Tussenhausen Posts: 2,708 Blog Entries: 6 Rep Power: 51 Dear all, I investigated time to extend the paper / summary as follow: Math section extended and cleared (also mistakes removed) Total-Derivatives and math operations included Derivation of kinetic energy done Derivation of total energy done Derivation of internal energy done Derivation of non-conserved equations of momentum, total energy, internal energy and kinetic energy added The document is now 45 pages big. Further improvements: speech and logical structure. I will need a bit more time to get it ready but I will keep you updated. Notice that the derivations are done using a volume element. Therefore we get the conservative forms straight forward. Xinze, JonW, chriss85 and 1 others like this. __________________ Keep foaming, Tobias Holzmann

 February 19, 2016, 16:19 #17 Senior Member     Matvey Kraposhin Join Date: Mar 2009 Location: Moscow, Russian Federation Posts: 355 Rep Power: 21 Dear colleagues, Do you keep in mind, that OF is intended to solve integral equations, but not differential. __________________ MDPI Fluids (Q2) special issue for OSS software: https://www.mdpi.com/journal/fluids/..._modelling_OSS GitHub: https://github.com/unicfdlab Linkedin: https://linkedin.com/in/matvey-kraposhin-413869163 RG: https://www.researchgate.net/profile/Matvey_Kraposhin

 February 20, 2016, 11:34 #18 Senior Member   Jon Elvar Wallevik Join Date: Nov 2010 Location: Reykjavik, ICELAND Posts: 103 Rep Power: 19 Dear Matvey I am pretty sure that most of us know that OF uses the finite volume approach. It is fairly straight forward to transform an integral equation into a differential one. See for example p. 387 in my PhD thesis @ http://ntnu.diva-portal.org/smash/re...2:124984&rvn=1 Also, when programming a solver, a differential approach is used (e.g. UEqn.H in interFoam), which OF transforms into an integral approach (in this case, by the fvm::div(), fvm::laplacian(), fvm::grad() and etc -class)), thus in the end, it is nicer to have the equations in its differential state, rather than in integral state. Hope this helps cheers J. Tobi and SHUBHAM9595 like this.

 February 28, 2016, 07:21 #19 Super Moderator     Tobias Holzmann Join Date: Oct 2010 Location: Tussenhausen Posts: 2,708 Blog Entries: 6 Rep Power: 51 Dear all, I am happy to announce that I have published the new paper. A lot of changes are done and can not compared to the original (: The document has 45 pages and include the following: Mathematic Notation Derivation of governing equationsContinuity Momentum Total Energy Mechanical (Kinetic) Energy Internal (Thermo) Energy Enthalpy Governing equations for engineersContinuity Momentum Enthalpy SUMMARY OF EQUATIONS Shear-Rate tensor and Navier-StokeNewtonian Fluids Relation between Cauchy, shear-rate and pressure Derivatives of momentum equations Turbulence modeling Derivations of shear-rate functions (openfoam) The equations are given in the following forms in the first part: Conserved partial Non-Conserved partial Integral Finally I added the literature I used and gave some cites. After I restarted working on the stuff, I realized that a lot of stuff is not straight forward and rearranged a lot. Furthermore the english speak was improved and checked. A few mathematic errors were found and corrected. Everything can be found on my updated page www.holzmann-cfd.de Feedback, error-report, etc. is welcomed, ramakant, JonW, Dipsomaniac and 4 others like this. __________________ Keep foaming, Tobias Holzmann

February 29, 2016, 03:41
#20
Senior Member

Join Date: Oct 2013
Posts: 397
Rep Power: 18
Quote:
 Originally Posted by Tobi Everything can be found on my updated page www.holzmann-cfd.de Feedback, error-report, etc. is welcomed,