T-junction simulation using interFoam
Hello everybody,
I'm new to OpenFOAM and I'm trying to run a simulation of a T-junction (air entering through one inlet and water through the other) in microgravity conditions (g approximately 0). Since a picture is worth a thousand words, I show you the geometry and the mesh: https://i.imgur.com/k1sQ270.jpg The mesh is done in Ansys and exported in .msh format. Then, the fluent3DMeshToFoam command is used to convert it from ASCII format to foam format. The diameter of the channels is 1 mm, through the horizontal inlet (inlet1, walls1) enters air and through the vertical inlet (inlet2, walls2) enters water, both at 0.1 m/s. I can consider the two flows to be incompressible, so I use interFoam solver. I know that the results should be something like this: https://i.imgur.com/nSLz7CU.png Air should advance through the horizontal pipe, meet the water at the junction and generate some bubbles. But when I run the simulation, air is not advancing through the channel and it's getting 'stucked' at the inlet like this: https://i.imgur.com/TEnLsg6.png I attach the three directories "0" (alpha.air, p_rgh and U files), "constant" (g, transportProperties and turbulenceProperties files) and "system" (controlDict, fvSchemes and fvSolution files) in the following link because I don't know where the problem is: https://www.mediafire.com/file/60tv4...ction.rar/file Some parameters:
How could I fix this problem? Thank you in advance, Carlos. |
Hi Carlos,
The problem is on the boundary definition of the pressure. You have to tell OpenFOAM to calculate the required pressure to provide a specific flux, not just set it to 0. Than can be done using fixedFluxPressure BC. You have to do it with both inlet1 and inlet2. 0/p_rgh: Code:
inlet1 Hope it works! |
Quote:
But I have another problem: the simulation is not behaving as expected when the two fluids meet at the junction. These are the results at t = 0.0112 (everything is OK): https://i.imgur.com/0bFi6sq.png This is the last time step where the results are the ones that I expect. From this point on, air and water mix in a strange way (screenshot at t = 0.0192): https://i.imgur.com/7Sp8EyS.png The Courant number blows up, causing the simulation to stop (the last directory that I obtain is t = 0.0272, when it should end at t = 0.2). I don't know if the problem is that the mesh is not good enough or that some files are not OK. For instance, inside "system" directory, I don't know if decomposeParDict or setFieldsDict are mandatory files :confused: I didn't include them... (soy nuevo en OpenFOAM y puede que haya cosas básicas que esté haciendo mal, no sé si el problema estará en el mallado o en alguno de los archivos) Anyone knows how to solve this problem? Thanks |
Hello again Carlos,
It seems that you have some issues with the BC of the phases. On the file alpha.air you have fixed the value of the walls to always be 0 (water). I don't know if that is a design requirement but it seems that is blowing up your simulation. Try changing it to zeroGradient, that would make the simulation more stable. You can check your mesh using the command checkMesh, that will tell you if some mesh metrics is wrong, altough if you use an external mesher you may have that information from it. The mesh do not seem to be too distorted, although the cell size can be too big to capture the interphase properly or other flux phenomenon. If you want to play around with mesh size you can use refineMesh to create a more resolute version of the current mesh. Concerning the files you mentioned, the file decomposeParDict is for paralleling your simulation. It tells OF how to split your mesh in sections for each parallel process. The file setFieldDict is for imposing a set of values inside your domain. Neither of these file is strictly mandatory. Hope that helps you! |
Good night Carlos,
Quote:
Quote:
https://i.imgur.com/8iWptG1.jpg https://i.imgur.com/Riz54nl.jpg Using the command checkMesh on this mesh, the result is the following: Code:
/*---------------------------------------------------------------------------*\ Quote:
So, following your recommendations, alpha.air, p_rgh, U and controlDict files should be like this? Code:
/*--------------------------------*- C++ -*----------------------------------*\ Code:
/*--------------------------------*- C++ -*----------------------------------*\ Code:
/*--------------------------------*- C++ -*----------------------------------*\ Code:
/*--------------------------------*- C++ -*----------------------------------*\ https://i.imgur.com/JkIEz79.png It doesn't make sense and causes the Courant number to blow up after some iterations. Why is this happening? Is there a way to restrict the entrance of air into the vertical pipe? Or is happening because the cells of the mesh are not small enough? I could improve the mesh but I should decrease the time step in order to ensure that (and this simulation already took me 3.5 hours...). I would be hugely grateful if you can help me with this issue. Thank you very much, Carlos. |
Hi again!
Its hard to tell... I've tried your set up and it worked for me. Maybe is related with he OF version, what version are you using? I've tried it with OF6. You can find the results and the case definition I've used here. https://i.ibb.co/gRnwgD8/instants.png I don't know it those are the expected results. The interface may be better resolved with a finer mesh, but that shouldn't make the entire simulation to crash. https://i.ibb.co/R0pLyBy/residuals.png https://i.ibb.co/55VmZJW/courant.png Neither the residuals nor the courant number seems to have unreasonable values. By the way, you may find interesting to use PyFoam for plotting relevant information while solving. Concerning the simulation times, you may consider using a parallel running. Add a decomposeParDict file to your system file. This file may have different configuration parameters but I recommend you to start using the scotch method, that takes care of splitting your domain for each processor. That should reduce the time of simulation. system/decomposeParDict: Code:
/*--------------------------------*- C++ -*----------------------------------*\ Code:
# Split your domain in different regions, one for each process. |
Quote:
I'm using OF6 aswell. Quote:
You say that a finer mesh shouldn't make the entire simulation to crash, but it does :( I have tried to make the time step smaller (from 5 to 1 ), but the Courant number gets very big and the simulation stops at time t = 0.01 s approximately (after running for 10 hours). Maybe the mesh is too fine? 500k cells are too many cells? (maybe I should try with 300k or so). I checked the mesh and it is OK: Code:
/*---------------------------------------------------------------------------*\ Code:
/*--------------------------------*- C++ -*----------------------------------*\ Quote:
The parallel running is great! The simulation time is really shortened. Thank you very much again :) Quote:
It is really hard. If you could help me with the new mesh problem I would be appreciated. Saludos, Carlos. |
Refinie the mesh may increase significantly the computation time. I can help you further without more details. If you say that the computation takes almost 10h to fail... It would be nice to share the computation log instead of let me waste those 10h .
If you don't know how to log the output, you can try piping the output. Code:
# Show the results on screen AND store them into "interFoam.log" Concerning PyFoam, altough it has been certainly written in python is not required to know python to use. When you install it (using pip its quite easy to do so) you get access to a bunch of executable fies with the name pyFoam... For example: Code:
# Launch interFoam and show the results. Automatically generates a log file. |
Quote:
I tried a new mesh of 428k cells. You can download the case folder here (I also included the .log file of the simulation). I used 2 different time steps: 2e-6 and 5e-6. I also installed PyFoam as you recommended. Results for 5e-6: - Execution time: 9h 25min - Residuals: https://i.imgur.com/Cr58vQu.png - Courant: https://i.imgur.com/TNM2lh9.png Results for 2e-6: - Execution time: 22h 22min - Residuals: https://i.imgur.com/PJP50Bn.png - Courant: https://i.imgur.com/nkQQexN.png Comparison using ParaView: - Time = 0.0064: https://i.imgur.com/URY0zy2.png - Time = 0.0072: https://i.imgur.com/XWs0kjg.png - Time = 0.008: https://i.imgur.com/IoCHl1S.png Is it better to use a smaller time step? The max Courant number is smaller, but the results at ParaView are very simillar... I don't know if it's worth to "lose" 13h decreasing the time step to 2 microseconds when I get no substantial improvement. Another doubt that I have is that it seems that (is barely noticeable) the bubbles are being "sucked" at the outlet. There is a small bubble deformation, but I don't know why. The boundary conditions at the outlet are zeroGradient for alpha.air and U files and fixedValue (value 0) for p_rgh file. Thank you very much, Carlos. |
Hi, nice that you managed to solve it!
Concerning the mesh resolution, you have already performed some kind of mesh sensibility analisis. It is nice that the results are pretty simillar, it is a sign that you are going in the right track. What since is enough? That is something you have to determine. What is the purpuse of the simulation? Which error is acceptable? I do not know how to help you further with the outlet issue. I am vaguely aware of wave reflection issie with some BC, but I never used them neither know if there is something implemented in OF. Good luck with the model and your way with OF |
Quote:
Right now I would like to generate a plot like this: https://i.imgur.com/Z8nISmV.jpg It shows the fraction of air at two given surfaces (located at x=7 and x=8 mm in this case) with respect to time. Do you know any way of generating two surfaces and extract the fraction of air at each time step? I think that I have to create some functions inside controlDict file but I don't know how to do it. Is there a way to get this information using PyFoam? The volume of the bubbles for example. It would be extremely useful. Thanks, Carlos |
Hi Carlos
I hope you are fine. I'm trying to run a simulation of a T-junction (cold water entering through one inlet and hot water through the other) The mesh is done in Ansys and exported in .msh format. Then, the fluent3DMeshToFoam command is used to convert it from ASCII format to foam format. but I don't understand why it doesn't work. It gets an error from me and I can not see it in Paraview. Can I take your Ansys file in this example? |
Quote:
What kind of problems are you experiencing? For exporting mesh from ANSYS to OpenFoam I think its needed to ensure that they are in ASCII format. By default they are in binary, so you just need to explore the exporting options of ANSYS Meshing to do so. Try that approach or share more information of the error you have so we can assest you better. |
Hi Everyone
|
Can you help me
Hello
I'm a new OpenFOAMer and I'm trying to run a similar question. The blockMesh has always been unsuccessful, can you give me the blockMesh file? Thank you. |
Quote:
BR |
1 Attachment(s)
Quote:
Could you help me with a similar problem? I am trying to simulate capillary-driven flow in an open microchannel. But unfortunately with all the boundary conditions, I am getting this result: Attachment 95524 This is obviously not correct. I am attaching my case files here: PLEASE CHECK Could you please let me know what's wrong? I am able to simulate closed channel but facing this problem in open channel. |
All times are GMT -4. The time now is 03:55. |