Open teymourj opened 7 years ago
Hi. Thank you @teymourj for inviting me to this repo. I will start investigating the problem and examine any probable solutions. Hence providing the test case and any related papers would be very useful to start. Best.
@mojtabaAmiraslanpour all the inputs from Bashar is put in the Simulation_Src subfolder of O on the repo..
@teymourj I just took a look at the case. The first thing that comes up is that what the definition of the actual problem is? I see there are two phases of air and water settled at top and bottom of the domain respectively and meanwhile a uniform airflow is set to get entered into the domain from the left inlet boundary. There is no doubt that this actually would lead into a divergence, because the case definition seems to be wrong. Are there any papers or studies referring to this kind of problem?
Here is the image for alpha.water at time zero:
I also got to say that there are several problems regarding the case setup which can make the case stable if corrected.
@mojtabaAmiraslanpour According to the original correspondence the problem definition is "simulating flow past plate with Re=50000". I assume that there should be a plate, with no slip, boundary condition in the middle of two fluid phases. That being said I am not sure about that.
On the same topic, I would recommend decreasing the Reynolds number to laminar region in the phase of figuring out the corrected setup and BCs.
I will have the team contact Bashar to accept the github invitation and himself provide more accurate prospective on the facing issue.
@mojtabaAmiraslanpour Hi thanks a lot for your input. The case is initial investigating of flow past plate. The flow is constant due to the fact that its river or stream of constant flow rate. The speed of inlet water from the left is 0.5 m/sec. Also the plate is below the free surface by 6 cm. This is based on a previous work that was done uing ANSYS and published in Ocean Engineering as shown below: http://www.sciencedirect.com/science/article/pii/S0029801815006228 I was trying to use interFoam with omega sst, I followed the OpenFoam tutorial to do the stimulation Setup.
@Bash-hassan Hi and welcome. Thank you for sharing the paper. Now it would be more easier for me to solve the problem. I will take a look and get back later.
@Bash-hassan @teymourj I worked a day or two on the case and corrected several problems. Fortunately the case is OK now and you may run it to see if it provides correct results based on the paper or not. Regarding the problems, I will Mention all of them in the bellow comments, so you can know what I have done so far.
The case had several major and minor problems. I start with the major ones. The main issue was how you defined the inlet BC for U and alpha. In this case the inlet boundary have to get split into two upper and lower parts so you could assign two different values for them. At the lower part, the water enters with the velocity of 0.5 m/s and from the upper part the air enters the domain with the velocity of 0.01 m/s. This can be done by two methods: Method 1, The hard way: While meshing the domain, you may split the BC into two parts and re-block your domain to have another structural mesh. Method 2, The easy way: Use swak4Foam. By this toolbox we are able to utilize the famous groovyBC boundary which allows us to define arbitrary formulas on a BC. Here I have used it to split the BC into two parts. If y-coordinate of the BC exceeds 0.11m the airflow with 0.01m/s velocity will be applied to the boundary, else the water stream with the velocity of 0.5m/s will be applied.
The other two problems also deals with the BC's: at the inlet and outlet BC's you have to set "calculated" for nut parameter, since we are not allowed to put wallFunction, Dirichlet or Neumann BC's on them. Taking a look at p_rgh you have to treat it opposite to parameters like U, epsilon etc. You have to put zeroGradient BC at inlet and a fixed pressure at outlet. for incompressible cases like this you can put any values on outlet. I have used the simple zero.
The gravity acceleration direction was set wrong. It has to be in -y direction.
The other thing you had to paid attention to was the depth of the domain in a 2D problem. As you may know in OpenFOAM there is no 2D mesh. All meshes are treated in 3D, but in order to run a case in 2D we produce a mesh in 2D and extrude it by one layer to get our 3D mesh. Later in OpenFOAM we use empty BC for the newly generated back and front faces. Up to here was just a routine task but what depth we have to set for the domain while extruding it? The answer is "Any depth". There is no limit, but infact there is a point you have to take care of. The point arises when you decide to calculate the force coefficients. In the formulas to calculate the coeffs, there is a parameter named A which is the reference area. you calculate A by multiplying the length of the rod to the depth of the domain. In OpenFOAM when you use fluentMeshToFoam command it specifies a certain depth itself and doesn't let you to choose it. For example in this case it was 0.0993176. As you see this is not a round number. It is better to change it to a round number like 0.1 and then use it in the A calculation process. I have done this in makeMesh script which you can take a look at. Bases on all of these, the A value would be 0.1*0.1 = 0.01.
Regarding the turbulence, I have used the turbulence calculator of cfd-online website:
https://www.cfd-online.com/Tools/turbulence.php
As you can see I have chosen the TI to be 10% and TLS to be 0.1 (length of the rod). The other turbulence quantities are calculated:
After solving the problem remember to check for yPlus. It has to be lower than 5 to have correct results
I intentionally changed the order of air and water in transportProp. to make the case similar to as it is in the paper. As a result you have to set alpha.air parameter instead if alpha.water.
I have used two SetFields commanands to have better initial guess and faster convergence. I have provided a dummy wake behind the plate as you may see at time 0. I also set initial conditions for U. Check them all out in Paraview.
The density of air is changed based on the ratio provided in the paper.
deltaT was set to 0.001 with "adjustTimeStep" option and the maxCo was set to 10. Setting the maxCo to 1 would increase stability but takes too much time to solve. Also having a maxCo of 42 (As mentioned in the paper) resulted in divergence. 10 works just fine.
The provided mesh is good from "Orthogonality", "Skewness" and "Aspect Ratio" point of views. But I am not satisfied with the smoothing:
You may try to change the sizes of the cells so they can match each other.
I used first order scheme for U, since its more stable to start with. You may change it to a second order schemes like linearUpwind grad(U) later when the case reaches to periodic condition.
I changed some values in fvSol. for better convergence. Check them out.
I re-ordered the BCs in each file to have neat and understandable codes.
Changed the name "plate_wall" to "plate" Changed the type of the top boundary to "wall" Removed all the "inGroups" keywords from the boundary file. I don't like them :)
I used 3 processors on my computer. You may change it according to your computer.
Unfortunately the forceCoeffs function object had some kind of bug. I got 0 values for all the coefficients. I don't know why, but the "forces" function object works just fine. You may calculate the coefficients by hand if you want to compare them with the paper results.
How to run:
I have used OpenFOAM v4.1 alongside with the swak4Foam package. You have to install them before you can continue. It may work with other versions of OF too, you can test it. In order to run the case you have to just enter the following command:
./Allrun
everything runs automatically. In order to clean everything just enter:
./Allclean
Note that this script won't remove your polyMesh folder as I coded it. After using Allclean, do not forget to comment the ./makeMesh line in the Allrun script, so it will avoid producing the mesh again. You have to do sth like this:
#./makeMesh
It takes some time to run the case. I didn't run it completely myself. Try running it and give us some feedback about the results.
You can download the attached case below.
I hope it helped. Best wishes for all.
@mojtabaAmiraslanpour Then you very much ! You make it very clear for me .Since I never worked with swak4Foam , I will first find how to install swak4Foam first on my current version 3.0.1 , and how this kind of tool works and test the case to see it. In case there is compatibility issues I will install the 4.1. Your comments and advices are highly appreciated I really want to thank you for that.
@mojtabaAmiraslanpour One question Mojtaba. I never worked with ./Allrun , ./makeMesh, etc. I usually do everything manually step by step, will it be ok if I did all the steps manually? I have no idea how to construct these files that is why I use the old fashioned way.
How to run: I have used OpenFOAM v4.1 alongside with the swak4Foam package. You have to install them before you can continue. It may work with other versions of OF too, you can test it. In order to run the case you have to just enter the following command: ./Allrun everything runs automatically. In order to clean everything just enter: ./Allclean Note that this script won't remove your polyMesh folder as I coded it. After using Allclean, do not forget to comment the ./makeMesh line in the Allrun script, so it will avoid producing the mesh again. You have to do sth like this:
./makeMesh
It takes some time to run the case. I didn't run it completely myself. Try running it and give us some feedback about the results.
@mojtabaAmiraslanpour Sorry to ask some basic questions, but I have one issue. When I tried to run the command ./Allrun I got the following error:
bash: ./Allrun: Permission denied
based on some suggestions online I tried:
sudo ./Allrun
I got the error:
sudo: ./Allrun: command not found
Any idea?
@mojtabaAmiraslanpour One question Mojtaba. I never worked with ./Allrun , ./makeMesh, etc. I usually do everything manually step by step, will it be ok if I did all the steps manually? I have no idea how to construct these files that is why I use the old fashioned way.
Hi, You can also enter the commands manually. I have made the scripts so you can understand what exact steps are needed to make your case ready for a run. Try inspecting them and see what each command does. You have to completely run all the commands to make everything work correctly.
@mojtabaAmiraslanpour Sorry to ask some basic questions, but I have one issue. When I tried to run the command ./Allrun I got the following error: bash: ./Allrun: Permission denied based on some suggestions online I tried: sudo ./Allrun I got the error: sudo: ./Allrun: command not found Any idea?
This may have happened because you have extracted the files in your computer. The solution is very easy, just right click on the scripts and choose permissions tab. Next enable the option "Allow executing file as program".
@Bash-hassan I am glad that @mojtabaAmiraslanpour is handling your case as it was expected based on his previous contribution and expectation. Please consider documenting the Physics, Mesh Generation, Simulation setup and Post-processing of your case study as you move forward. I will be walking you through those steps and provide you support on that.
keep us updated on your progress.
@mojtabaAmiraslanpour Thanks a lot for the information! The simulation is running , it will take a while because I am executing two LES simulation on my HPC, so I couldnot assign it many CPU . As soon as this simulation finished I will give you the updates. many thanks again for all your help.
@teymourj thanks again for your help. Please could you explain how can I do the documenting here?
@Bash-hassan Go to the main repository. On the first page there is a tutorial how to establish a git connection with the repo and how to start editing the content. What you need to do is documenting four sections of your work; 1-General Physics, 2-Meshing, 3-Simulation Settings and 4-Post-Processing. In simple words you need to write a report for future users, but instead of saving it on your computer you will save it one clouds and everyone will have access to it.
For formatting and structure, take a look at the previously developed case studies in Open Foam.
Please let me know if you needed any help for documentation by opening another issue on this page.
@mojtabaAmiraslanpour thanks again for all your help. I ran the case during the weekend . Today I came to check the results and I found some issues. First the case ran until 20 sec and I stopped it because the result is not correct comparing to the paper. First I noticed that the drag coefficent is much higher than the paper reported, because of that I stopped the simulation and I checked the velocity field and the volume fraction of the air. As you can see in the pictures, there is a fluctuation if the velocity fields and it seems that something affecting it may be from the BC . The volume fraction is also have some issues, the water level decreased at the outlet but stayed correct at the input. Also, the major issues is that the water is going below the tip of the plate causing water fluctuation and hence the high drag coefficient.
I hope you have time to give me an advice about this situation. I will work on it to see if I can make it correct. Regards, Bashar
Velocity at 0 sec
Velocity at 1 sec
Velocity at 10 sec
Velocity at 20 sec
alpha at 0 sec
alpha at 1 sec
alpha at 10 sec
alpha at 20 sec
@Bash-hassan: Here is a general and simple guideline to save yourself and us time and effort! Try to run steady and laminar flow field to set the base settings first. Then make it unsteady laminar and the go to turbulent and unsteady. You need to validate your solutions at each stage. You can not get to the tenth floor jumping from the first stair to the tenth one!
Try to document your thoughts and theory as well that will help you to manage your settings better. This case is too complicated at this stage.
@teymourj thanks for the reply. I already restarted the case with different BC , to see the effects . Regarding starting the case with laminar flow fields, I will do this if my BC manipulation will not work. Regading the jumping to the 10 th floor ,I am so sorry that this case is too complicated, I already in the 1st floor when it comes to turbulent simulation, that's why I started with 2D RAS simulation in stead of 3D LES. However, you may have agood point . Thank you for the advice and sorry for providing complex case. Accept my apology.
@Bash-hassan There is no need to apologize. The entire point of SFO-project is to help fellows like you and we do enjoy dealing with complicated cases. We enjoy more tackling complicated cases systematically. Here is my suggestion:
1- Based on what @mojtabaAmiraslanpour has provided you setup a case study. 2- Manipulate the settings to run a laminr-steady case. This will remove any complication from your case study. 3- Validate those results against theory or previous work. 4- Then use your working setup and figure out the unsteady flow settings (i.e. time step, schemes and etc.) 5- Once you figure that out base on the physics of the flow will will adapt the mesh for a turbulent steady and then turbulent unsteady case.
This might take some time but guarantees the good and successful outcome.
Let us know if you got laminar-steady simulation going based on the provided help from Mojtaba so far.
@teymourj Thanks again! As soon as the current simulation reach few second , I will start another one with laminar settings.
Hi @Bash-hassan. As @teymourj said try to simplify the things and go through the steps one by one so you can find the problem. One thing I can suggest you is to run the case without the plate to see if the level of the water is maintained at the desired height or not. If not, then we can be sure that the problem is not relating to the plate itself. In that case, solving the problem would be more easier. Maybe the inlet and outlet BC's are set wrong.
@teymourj , I changed the simulation type in the "turbulenceProperties" from RAS to laminar. Then I run the case until it reached 5 sec then I stopped it . I checked the air and water volume fraction and its still not realistic , as shown in the attached picture. My next step will be to follow @mojtabaAmiraslanpour advice and make anew mesh without the plate and run the case with this modification, it will be basically a channel flow .
Regards,
Bashar
@Bash-hassan Any updates on this issue? Did you try running the case without the plate?
@mojtabaAmiraslanpour Thanks for asking . I spent this week running the case on my free time with different BC combination . I am sure at this moment that the main issue is with the pressure BC. I am not convinced that the plate is the issue due first to the fact the this case is already published, the 2nd thing it's assigned as a wall . I am running now a last case with another BC combination, if this won't work I will delete the plate from my Ansys case case and regenerate the mesh again. Many thanks to all your help.
@mojtabaAmiraslanpour Thanks for asking . I spent this week running the case on my free time with different BC combination . I am sure at this moment that the main issue is with the pressure BC. I am not convinced that the plate is the issue due first to the fact the this case is already published, the 2nd thing it's assigned as a wall . I am running now a last case with another BC combination, if this won't work I will delete the plate from my Ansys case case and regenerate the mesh again. Many thanks to all your help.
Great! The thing that I suggest is only to find the problem by simplifying it. Using the case without the plate will remove any complexity that can be caused by the fluid flow itself. In this way we can make sure that if the water stream is flowing permanently and can maintain its height. There can be problems in BC's but let's test it on the case without the plate and see the results. Why are you sure that the pressure BC is the main problem in here?
@Bash-hassan One more advice to have the plate "effect" in a simplified way is imposing "slip" rather than "no-slip" boundary condition (B/C) on it. The difference is than in latter B/C velocity is not set to zero on plate surfaces, hence no boundary layer and simpler flow. (Just a note to have in mind)
@mojtabaAmiraslanpour @teymourj , Sorry for the late reply. I just want to give you an update regarding the case. First to answer @mojtabaAmiraslanpour question regarding why I think its the pressure BC, when I changed the pressure BC and leaving everything else the same I got totally different behavior. I might be wrong, but please see the attached video. Also, I changed the geometry to a simple channel without the plate, I run the case after that. Unfortunately, it only run for few iteration then stopped with floating point. I will check it tomorrow to see what is the reason. animation.ogv.zip
`PIMPLE: iteration 1 smoothSolver: Solving for alpha.air, Initial residual = 3.21579e-09, Final residual = 1.9694e-13, No Iterations 1 Phase-1 volume fraction = 0.446561 Min(alpha.air) = -1.01206e-11 Max(alpha.air) = 1.00918 MULES: Correcting alpha.air MULES: Correcting alpha.air Phase-1 volume fraction = 0.446561 Min(alpha.air) = -1.01206e-11 Max(alpha.air) = 1.00918 GAMG: Solving for p_rgh, Initial residual = 0.969775, Final residual = 0.00906691, No Iterations 71 GAMG: Solving for p_rgh, Initial residual = 0.00434379, Final residual = 4.19555e-05, No Iterations 82 time step continuity errors : sum local = 5.38617e-08, global = 1.66744e-09, cumulative = 5.68965e-08 GAMG: Solving for p_rgh, Initial residual = 0.79251, Final residual = 0.0072883, No Iterations 67 GAMG: Solving for p_rgh, Initial residual = 0.00519939, Final residual = 8.86984e-07, No Iterations 139 time step continuity errors : sum local = 2.4796e-09, global = 1.90091e-13, cumulative = 5.68967e-08 smoothSolver: Solving for omega, Initial residual = 0.000189742, Final residual = 5.76609e-07, No Iterations 1 smoothSolver: Solving for k, Initial residual = 0.000470273, Final residual = 5.73378e-08, No Iterations 1 ExecutionTime = 57.53 s ClockTime = 57 s
Courant Number mean: 0.00865948 max: 54.4634 Interface Courant Number mean: 1.96996e-08 max: 0.00162935 deltaT = 9.81528e-106 Time = 0.0354285
PIMPLE: iteration 1
smoothSolver: Solving for alpha.air, Initial residual = 3.27625e-09, Final residual = 2.9823e-13, No Iterations 1
Phase-1 volume fraction = 0.446561 Min(alpha.air) = -1.01157e-11 Max(alpha.air) = 1.00918
MULES: Correcting alpha.air
MULES: Correcting alpha.air
Phase-1 volume fraction = 0.446561 Min(alpha.air) = -1.01157e-11 Max(alpha.air) = 1.00918
[0] #0 Foam::error::printStack(Foam::Ostream&) at ??:?
[0] #1 Foam::sigFpe::sigHandler(int) at ??:?
[0] #2 ? in "/lib/x86_64-linux-gnu/libc.so.6"
[0] #3 Foam::GAMGSolver::scale(Foam::Field
This is the error I got for the case without plate. Its too late , so I will work on it tomorrow. Many thanks
@teymourj , thank you for the advice. I started a case with slip BC for the plate! its still at the beginning . I will wait until it reached few second then I will check the flow fields and the volume fractions.
Many thanks for the advice.
@teymourj , Sorry for the late reply I was caught in the middle of the snow storm. Anyway, I run the same case that @mojtabaAmiraslanpour built with the only difference that the plate have a slip BC. Unfortunately , the result is also not right compared with the published work. Attached is a picture of the volume fraction of air. Also, I am still having a floating point in the case with no plate. I will build another mesh , although the previous mesh was really good since its only a channel without any additional geometry!
Thanks for the advice anyway.
Regards
@Bash-hassan I suffered from easteria as well! I hear you well here.
This is a significant improvement! You are running simulation. Are the results converging? They look converged and physical physical. At this stage there are two things you want to do:
1) When comparing your results with previous experimental and/or numerical data, make sure you are calculating the right variable and comparing "Apples to Apples". There is a common void/trap at this stage for all users at all stages. So you should spend some time with the obtained results if they are converged.
2) Again if the solution is reasonably converged try to change your numerical schemes one at a time and investigate their effect. In this fine tuning process hopefully you can validate your base case and then have a good grasp on adding more complexities to your case study to move toward your ultimate
@teymourj , I have run several simulations since @mojtabaAmiraslanpour help me setting the case. Unfortunately, until now non of them produces any close results to the original case done by Fluent. Regarding the convergence; yes the residuals and the solver are converging, however as you know, residuals are not the only indication about converged solution! We need to compare and monitor physical quantity.To compare apple to apple , I chooses to compare the reported drag coefficient in the paper to the ones I am getting from the simulations. Unfortunately its a big difference between both of them.For example in the paper they reported around 3 , I am getting some times a negative value and other times really high value up to 6! Also, I compared the flow fields which is again have a huge difference. The solution is not correct physically at this point. To be honest at this point I am doing try and error when it comes to choosing the BC. I am writing every step I done so I know what combination I used and what I got from each BC . I know this approach is not correct but I need to see if I can get the correct BC. Thank you for all your help @teymourj @mojtabaAmiraslanpour . Best wishes Bashar
@teymourj @mojtabaAmiraslanpour Hi, just to give you an update about the case . I still trying a laminar simulation with different BC combinations.The flow patterns and the volume fraction of the two phases are still not correct compared with the paper. I will try few thing more and let you know about the final results .
@Bash-hassan Hi, if possible provide the latest test case with us so I can also take a look at.
@mojtabaAmiraslanpour Thanks for your help, and again sorry to bring this case. I thought it will be easier than that but two-phase makes the simulation much complex to handle.
Regarding the case, I made another mesh without the plate based on @teymourj advice. I used to have a floating point due to the mesh , that’s why I did another simple channel case with same dimensions. I run it this time as a laminar case with exactly the same original setting that you sent in the corrected case. The only difference is the setFileds2 , I remove this file because in this case there is no need to give a jump behind the plate since there is no plate any more. The simulation run smoothly and without any errors. Again the result is not correct , there is a huge disturbance in the free surface and at the boundaries, as shown in the attached pictures.
Corrected_no_plate.zip
@mojtabaAmiraslanpour , Hi, I just want to give you an update. I made some changes in the upper BC. I got some advices from other user to change the upper BC to patch , and treat it as an atmospheric BC. When I run the simulation I got a floating point at the 2nd second
. But when I compared the behaviour of this simulation with the previous ones at the beginning of the simulation ,the result is different as shown in the attached picture.
Hope you have time to see the files. Many thanks for all your help.
Bashar
2d_vof.zip
@Bash-hassan Thanks Bashar for the update. I will take a look at that.
I want to ask for your advice regarding my free surface simulation of flow past plate. I was trying for several days to set up the correct BC for my case. I am simulating flow past plate with Re=50000. I am using interFoam to see the effect of free surface on this case. The water level is few centimetres above the pate. Its a 2D simulation with turbulent model using RAS.
I tried several BC based on the tutorial in openFoam and some suggestion in the cfd-online forum. Unfortunately, I am doing something wrong, I cant keep the water level at a constant level. After a while all the water will be washed out of the domain. I know it for sure that I made a stupid mistake in the setting but I cant see it.