Adding the Energy Equation to interFoam (OF 2.4.0)
Dear Foamers,
first of all, this is my first thread, me being new to OF and the forum as well. So I am thankful for any advice regarding anything related to CFD in general and OF and this forum in particular. Adding the Energy Equation to interFaom makes it necessary to modify the used library (A) and secondly modify the solver itself (B). I am having problems compiling said application, hence I have written this thread. I am going to describe my steps in detail in this thread. The procedure is inspired by both the documents from Damiano Natali ("interTempFoam") and Qingming Liu ("myinterFoamDiabatic"). The links are given beneath. http://www.wolfdynamics.com/images/c...erTempFoam.pdf http://www.tfd.chalmers.se/~hani/kur...gLIU-final.pdf A) Modifcation of the library 1) Copy the original folder transportModels to the user's directory cd $WM_PROJECT_USER_DIR/src/ cp -rp $FOAM_SRC/transportModels . 2) Rename the folders and files which are being modified (namely the libraries incompressibleTwoPhaseMixture and immiscibleIncompressibleTwoPhaseMixture). cd transportModels/incompressible mv incompressibleTwoPhaseMixture myIncompressibleTwoPhaseMixture cd myIncompressibleTwoPhaseMixture mv incompressibleTwoPhaseMixture.C myIncompressibleTwoPhaseMixture.C mv incompressibleTwoPhaseMixture.H myIncompressibleTwoPhaseMixture.H cd ../.. mv immiscibleIncompressibleTwoPhaseMixture myImmiscibleIncompressibleTwoPhaseMixture cd myImmiscibleIncompressibleTwoPhaseMixture mv immiscibleIncompressibleTwoPhaseMixture.C myImmiscibleIncompressibleTwoPhaseMixture.C mv immiscibleIncompressibleTwoPhaseMixture.H myImmiscibleIncompressibleTwoPhaseMixture.H 3) Change the respective file files corresponding to the the naming and path. in the folder incompressible/Make for myIncompressibleTwoPhaseMixture: Code:
myIncompressibleTwoPhaseMixture/myIncompressibleTwoPhaseMixture.C Code:
myImmiscibleIncompressibleTwoPhaseMixture.C in myIncompressibleTwoPhaseMixture.C: Code:
#include "myIncompressibleTwoPhaseMixture.H" Code:
#include "myImmiscibleIncompressibleTwoPhaseMixture.H" Code:
#include "myIncompressibleTwoPhaseMixture.H" In the file myImmiscibleIncompressibleTwoPhaseMixture/Make/options make the adaption as highlighted, so the connection to the new library is made. Code:
LIB_LIBS = \ Add the new parameters rho and Pr in myIncompressibleTwoPhaseMixture.H. Code:
dimensionedScalar rho1_; Code:
const dimensionedScalar& rho2() const Code:
tmp<surfaceScalarField> nuf() const; In myIncompressibleTwoPhaseMixture.C add the operations for the new parameters. Code:
rho2_("rho", dimDensity, nuModel2_->viscosityProperties().lookup("rho")), Code:
Code:
Foam::tmp<Foam::surfaceScalarField> Compile both libraries from the respective folder. Start with myIncompressibleTwoPhaseMixture, because myImmiscibleIncompressibleTwoPhaseMixture depends on it already being compiled beforehand. cd incompressible wclean wmake libso cd .. cd myImmiscibleIncompressibleTwoPhaseMixture wclean wmake libso Compiling works at this stage, which is good for the moment but doesn't necessarily mean to me that I did everything right. B) Modification of the solver interFoam to interTempFoam 1) Enter the destination of the new solver and copy the base solver. cd $WM_PROJECT_USER_DIR/applications/solvers/multiphase cp -rp $FOAM_APP/solvers/multiphase/interFoam . 2) Rename the folder and the .C file. mv interFoam interTempFoam cd interTempFoam mv interFoam.C interTempFoam.C 3) Adapt the file Make/files to the changed naming and path. Code:
interTempFoam.C In interTempFoam.C adapt the name of the following library being included. Code:
#include "myImmiscibleIncompressibleTwoPhaseMixture.H" Add the following lines in the file createFields.H. Code:
Info<< "Reading field U\n" << endl; Code:
const dimensionedScalar& rho2 = mixture.rho2(); Code:
// Mass flux In alphaEqn.H add: Code:
// Calculate the end-of-time-step mass flux Code:
rho == alpha1*rho1 + alpha2*rho2; Create a file named Teqn.H in the interTempFoam folder containing the Energy Equation: Code:
surfaceScalarField kappaf = incompressibleTwoPhaseMixture.kappaf(); Add the command for solving the E-Eqn in interTempFoam.C. The specific location of the added line may be object of discussion. Here is my suggestion: Code:
// --- Pressure-velocity PIMPLE corrector loop Adapt the file Make/options to the names and locations of the beforehand modified libraries. The following code is probably not correct and thus object of my questions. Code:
EXE_INC = \ Compile the solver from within its directory interTempFoam. wclean wmake <-------------------------------------------------------------------------------------------------------------------------> When I do everything as described I get the following output log: Code:
~/OpenFOAM/puhlig-2.4.0/applications/solvers/multiphase/interTempFoam$ wmake Do you have any idea how it comes to that error and how to solve it? I would very much appreciate comments from your side. Best Regards Perry |
interTempFoam in OF 2.3.1
Hi,
I'm working on the exact same problem. I've used the wolfdynamics page to make nearly same modifications as you to incorporate temperature into OpenFOAM (2.3.1), and I am getting a similar error in the end. The only differences in my procedure are: Using "mixture" in your step 7: This is used to refer to the other quantities defined in myIncompressibleTwoPhaseMixture, so that's why I've used it. Anything else gives me the error you got. Code:
surfaceScalarField kappaf = mixture.kappaf(); Code:
// --- Pressure-velocity PIMPLE corrector loop Code:
EXE_INC = \ Code:
In function `main': Does anyone have any suggestions? |
Fantastic post Perry, you are a role model for this forum. Anyway, you did some strange things:
1. Your new library has the same name as the old one 2. You include both the new and old library in the Make files, although the old one is completely redundant. |
Hi Hannah,
thank you for your reply. I implemented the first line of your TEqn.H file: Code:
surfaceScalarField kappaf = mixture.kappaf(); I just adjusted the given damBreak tutorial case (with its very coarse mesh). It completed the calculation, but with temperature values beneath zero. In consequence I will try a refined mesh and I will probably have to look into fvSchemses and fvSolution in more detail. Greetings Perry |
Hello Anton,
thanks for your feedback and the compliment. Quote:
Code:
EXE_INC = \ If NO: What do you mean? Quote:
Or didn't I? Greetings Perry |
Hi Perry,
I'm glad that little change worked. I've modified mine to exactly match yours (with the mixture.kappaf) and it now compiles, too! Thanks for your very detailed description of all of your interFoam modifications. Now to see if it actually works... Hannah |
Quote:
Code:
fvm::ddt(T) |
Unfortunately, I get a segmentation fault when I run my newly compiled interFoam with temperature for a modified damBreak case with temperature. How do I interpret the error message to identify what might be wrong?
Code:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Code:
div(rhoCpPhi,T) Gauss linearUpwind grad(T); Code:
T I'd appreciate help identifying where the error might be so that I might know what to do to fix it. mkraposhin, that's an interesting thought. Once this actually runs, then I'll be interested in getting the best solution possible. Hannah |
Quote:
immiscibleIncompressibleTwoPhaseMixture can you post your createFields.H file? |
Also, i think that it would be better to nest child class from mixture model, rather then creating new. Because at next lines OF creates turbulence model, that uses mixture model
|
Quote:
Code:
Info<< "Reading field p_rgh\n" << endl; Code:
#include "myIncompressibleTwoPhaseMixture.H" |
Sorry for the confusion, I just realized I didn't read it properly and indeed you don't have the original immiscibleIncompressibleTwoPhaseMixture in Make/*.
Quote:
|
Quote:
So, you need to change immiscibleIncompressibleTwoPhaseMixture to myImmiscibleIncompressibleTwoPhaseMixture But when you do that, i think, that solver will fail to compile, because turbulence model class depends on mixture class. Later i can try to explain how to derive your own class from class immiscibleIncompressibleTwoPhaseMixture |
O.k., i'm sorry,
i didn't read untill the end of your post, but nevertheless, turbulence model needs original data type, but not modified, that's why it fails to run and of course, you must avoid using same data type names for different classes |
2 Attachment(s)
Hi, i spend ~ 20 minutes and made child class myImmiscibleIncompressibleTwoPhaseMixture, which can do all work without substituting user type instead of original OF
Step 1. Create your new class myImmiscibleIncompressibleTwoPhaseMixture as a sub class of immiscibleIncompressibleTwoPhaseMixture, see attachment files .H and .C. Please note that for compatibility with OF you need to change all names, for example: Code:
#ifndef myImmiscibleIncompressibleTwoPhaseMixture_H Step 2. Adjust files Make/files and Make/options to include all neccesary files from OF Make/files Code:
myImmiscibleIncompressibleTwoPhaseMixture.C Code:
EXE_INC = \ Step 4. Initialize new model in new solver: - add -I../myImmiscibleIncompressibleTwoPhaseMixture \ line to Make/options EXE_INC section of your solver - add consequent lines to -L section of Make/options file of your solver - add #include "myImmiscibleIncompressibleTwoPhaseMixture.H" to solver instead of OF original solver - add initialization of your myImmiscibleIncompressibleTwoPhaseMixture class instead of OF original class in createFields.H - use method mixture.lambdaEff() to get mixture heat conduction coefficient - solve equation for temperature, formulated in volumetric fluxes: Code:
solve |
Thanks so much for your efforts. I'll go through and change all the internal names as well. Since all the new properties are defined in myIncompressibleTwoPhaseMixture (the immiscible one just calls them), that will need to be adjusted, too.
Edit: I see you've suggested moving all of the definitions into myImmiscibleIncompressibleTwoPhaseMixture. I'll incorporate that. This doesn't help explain, though, why this isn't needed for Perry and everyone else using these (http://www.wolfdynamics.com/images/c...erTempFoam.pdf, http://www.cfd-online.com/Forums/ope...interfoam.html, etc) instructions. Hannah |
3 Attachment(s)
Well those changes just produced a lot of compiling errors, but continuing to mess around with my original Make/options and #include's produced a version that compiled and ran a test case successfully. I'll look into making mkraposhin's suggested modifications to TEqn.
In the meantime, I'm attaching all of the files in case they might help someone else (using OF 2.3.1). Hannah |
I will try to compile your code and report what is wrong later.
Regarding previous version of library and solver - i made it for OF 2.4.0, not for 2.3.1 |
Hello Matvey,
first of all, thanks for taking part in the thread. Quote:
in alphaEqn.H: Code:
// Calculate the end-of-time-step mass flux Code:
rho == alpha1*rho1 + alpha2*rho2; I see that you divided the equation by (rho*cp) viewing the terms separately: Quote:
Quote:
Quote:
What does this new term do? I do not know the operation in there (SuSp(-fvc ...). Best Regards Perry |
1 Attachment(s)
@ Hannah:
Hi, i looked at your code and i understand that you mixed from all versions :) So, i used my approach to create a new class for mixture and mass flux approach for energy equation. It works for OF 2.3.1. You can find source code in the attachment. To make solver, go into folder interThermalFoam/myImmiscibleIncompressibleTwoPhaseMixture and run wmake libso then go one folder up and run wmake |
All times are GMT -4. The time now is 22:31. |