CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (http://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   Sample velocities for a multiphase problem (http://www.cfd-online.com/Forums/openfoam-post-processing/112227-sample-velocities-multiphase-problem.html)

 emirust January 24, 2013 05:11

Sample velocities for a multiphase problem

1 Attachment(s)
Beloved Foamers,

I am simulating the fall of a droplet of water in oil, with interFoam. See the attached picture.

My question is how to procede to extract the terminal velocity of the drop, i.e. where the phase fraction alpha is 1.

The "sample" utility would serve, but I was wondering about the possibility of having an IF statement to only keep certain cells.

Another solution would perhaps be to extract values from a box, and run this if statement in Matlab f.eg, but I was wondering what is the best practice? I would also like to point out that I was thinking about averaging all velocities on all cells to keep out the effect of recirculation inside the drop.

So, if you skipped til the end, my question is: how to extract the terminal velocity of the droplet for this case. :)

Thank you!

 gschaider January 24, 2013 06:35

Quote:
 Originally Posted by emirust (Post 403717) Beloved Foamers, I am simulating the fall of a droplet of water in oil, with interFoam. See the attached picture. My question is how to procede to extract the terminal velocity of the drop, i.e. where the phase fraction alpha is 1. The "sample" utility would serve, but I was wondering about the possibility of having an IF statement to only keep certain cells. Another solution would perhaps be to extract values from a box, and run this if statement in Matlab f.eg, but I was wondering what is the best practice? I would also like to point out that I was thinking about averaging all velocities on all cells to keep out the effect of recirculation inside the drop. So, if you skipped til the end, my question is: how to extract the terminal velocity of the droplet for this case. :) Thank you!
Well the easiest way to circumvent the need for an IF is to let alpha1 act as an IF and base further recipes on something like "alpha1*U" (which should give you 'only' the velocity of the liquid phase. Might of course fail for very high gas velocities in regions that only have a few percent liquid).

I personally use swak4Foam for that kind of calculations and write a function object like this (I'm doing this from the top of my head. There may be syntax errors in that):
Code:

```    liquidVelocity     {         type swakExpression;         valueType internalField;         expression "alpha1*U";         accumulations (             min             max         );         verbose true;     }```
that only gives you the extremes of the liquid velocity. A more elaborate calculation (with volume weighted average and only using the component of the velocity in the down direction) would be
Code:

```    downAverage     {         type swakExpression;         valueType internalField;         variables (             "downDirection=vector(0,-1,0);"             "thres=0.5;"             "liquidVol=sum(alpha1>thres ? vol() : 0);"             "downVel=alpha1>thres ? (U & downDirection) : 0;"         );         expression "downVel*vol()/liquidVol";         accumulations (           sum         );         verbose true;     }```
An alternative that swak offers is to track the surface of the liquid and calculate the velocity of that (for an example see in the swak-distribution Examples/other/capillaryRise).

If you decide to do it this way and it works for you could I ask you to add a recipe to http://openfoamwiki.net/index.php/Co...Usage_examples as this is something that other people might be interested in. Thanks

 emirust February 12, 2013 10:39

Hello!

I haven't tracked the isosurfaces as suggested previously, but I used the following to track the drop deformation as it falls down. It might not be good enough for the wiki, so I just post it here.

This was just added at the end of the controlDict and creates a set of values that can give the horizontal and vertical diameter. This can lead to the position of the center of the drop which can be used to find the fall velocity

Code:

```libs (       "libOpenFOAM.so"  // OpenFOAM will (probably) crash if this library is not specified       "libsimpleSwakFunctionObjects.so"       "libswakFunctionObjects.so"     );   functions {     downAverage     {         type swakExpression;         valueType internalField;         variables (             "downDirection=vector(0,-1,0);"             "thres=0.5;"//which cells to keep             "liquidVol=sum(alpha1>thres ? vol() : 0);" //calculates the volume of the drop             "downVel=alpha1>thres ? (U & downDirection) : 0;" //a & b:inner vector product. Keep the y component of U.         );         expression "downVel*vol()/liquidVol";//vol():vol of the cell         accumulations (           sum         );                 verbose true;     }     createInterface     {         type createSampledSurface;         outputControl timeStep;         outputInterval 1;         surfaceName interface;         surface {             type isoSurface;             isoField alpha1;             isoValue 0.5;             interpolate true;         }     }         xDiameter     {         type swakExpression;         valueType surface;         surfaceName interface;         verbose true;         expression "pos().x";         accumulations (             min             max         );            }         yDiameter     {         type swakExpression;         valueType surface;         surfaceName interface;         verbose true;         expression "pos().y";         accumulations (             min             max         );            }```
Good luck!

 gschaider February 12, 2013 17:00

Quote:
 Originally Posted by emirust (Post 407428) Hello! I haven't tracked the isosurfaces as suggested previously, but I used the following to track the drop deformation as it falls down. It might not be good enough for the wiki, so I just post it here.
Why not? If everything there had to be perfect nothing would get posted. And if somebody doesn't like your solution he can improve it ... it's a Wiki

 Elham July 1, 2015 22:35

I try to use your subroutine at the end of controlDict to calculate droplet velocity but I don't know where I can find the calculated velocity? I mean in Paraview?

 Elham July 20, 2015 21:15

Quote:
 Originally Posted by emirust (Post 407428) Hello! I haven't tracked the isosurfaces as suggested previously, but I used the following to track the drop deformation as it falls down. It might not be good enough for the wiki, so I just post it here. This was just added at the end of the controlDict and creates a set of values that can give the horizontal and vertical diameter. This can lead to the position of the center of the drop which can be used to find the fall velocity Code: ```libs (       "libOpenFOAM.so"  // OpenFOAM will (probably) crash if this library is not specified       "libsimpleSwakFunctionObjects.so"       "libswakFunctionObjects.so"     );   functions {     downAverage     {         type swakExpression;         valueType internalField;         variables (             "downDirection=vector(0,-1,0);"             "thres=0.5;"//which cells to keep             "liquidVol=sum(alpha1>thres ? vol() : 0);" //calculates the volume of the drop             "downVel=alpha1>thres ? (U & downDirection) : 0;" //a & b:inner vector product. Keep the y component of U.         );         expression "downVel*vol()/liquidVol";//vol():vol of the cell         accumulations (           sum         );                 verbose true;     }     createInterface     {         type createSampledSurface;         outputControl timeStep;         outputInterval 1;         surfaceName interface;         surface {             type isoSurface;             isoField alpha1;             isoValue 0.5;             interpolate true;         }     }         xDiameter     {         type swakExpression;         valueType surface;         surfaceName interface;         verbose true;         expression "pos().x";         accumulations (             min             max         );            }         yDiameter     {         type swakExpression;         valueType surface;         surfaceName interface;         verbose true;         expression "pos().y";         accumulations (             min             max         );            }``` Good luck!

Hi everyone

I use the above code to calculate drop velocity but I don't know how I can sea the results? in paraFoam?

Thanks

 All times are GMT -4. The time now is 05:58.