CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   How to update density and viscosity on PimpleFoam? (https://www.cfd-online.com/Forums/openfoam/255538-how-update-density-viscosity-pimplefoam.html)

mohammad_majidi April 15, 2024 21:23

How to update density and viscosity on PimpleFoam?
 
If I want to define density/viscosity based on the relative composition of two solvents in the flow field, how can I add this line to the main solver so I can update the value of density/viscosity at the end of each iteration in OpenFOAM? For example, /rho = /rho_w (T1) + /rho_e(T2). I have already built the main body of my solver, but I need to add this functionality at the end of the solver as well, but I'm not sure how to do it.
Any help would be greatly appreciated.

Severus April 17, 2024 12:24

Hello,
You can take a look at twoLiquidMixingFoam solver.
For example the densities (also viscosities) of the two fluids are read. The mixture density is calculated based on the composition of the solvent. This mixture density then is used when solving in the pressure equation.

Solver
https://cpp.openfoam.org/v9/twoLiqui...8C_source.html

Tutorial
https://github.com/OpenFOAM/OpenFOAM...m/lockExchange

Thanks

mohammad_majidi April 17, 2024 12:29

Thanks a lot for your reply. So, does this solver solve the convection-diffusion equation for two different scalars and then update density and viscosity with a linear relationship?Can this solver be used for turbulent flows? I'm dealing with high Reynolds numbers here.


Thanks a lot for your help.

Severus April 17, 2024 12:44

Hello,
Yes this solves the scalar transport equation of one scalar (lets say alpha1), the other will simply be alpha2= 1 - alpha1.

For example the mixture density is calculated in the following way
rho_mixture = alpha1*rho1 + alpha2*rho2

It can be used for turbulent flows (both RANS and LES modelling are possible).


You can check out this thesis, the solver is explained very well.
Jacobsen, K. Å. (2018). The dead water phenomenon. A computational fluid dynamics study (Master's thesis).
https://www.duo.uio.no/handle/10852/63453

Thanks

mo___ April 24, 2024 00:51

When I run the simulaiton using this foam you recommended, it only outputs U, p_rgh, and alpha. I don't know how I can add the contour f density or viscosity in paraview.

Severus April 24, 2024 12:01

Hello,
In Paraview, you can use the Calculator filter for this purpose.

Once you select the calculator filter, enter the formula in the box.
For density, for example let us say you call it density_effective as your Result array name.
The formula that you have to enter will be density_effective = alpha*rho_1 + (1-alpha)*rho_2. Where rho_1 and rho_2 are constants. Similar to what I also mentioned earlier in this thread.

Once you successfully implement this filter, you can see this density_effective field along with your other fields and you can now visualize it.

Thanks


All times are GMT -4. The time now is 01:35.