I am using /examples/codesByTopic/shanChenMultiPhase/segregation.cpp as a reference for a multiphase code that I am developing. I need to instantiate a pre-defined saturation for the segregating phase. So that when the simulation finishes, the segregated phase represents a fixed amount of pixels (in output image) in terms of density.
Any idea how this can be achieved?. I have tried assigning specific densities to different cells, but the end saturation always ends up as the same. I think there might be a density coupling missing. Not sure how that coupling should look like.
getting the exact amount of pixels is going to be tough. The system you are simulation in the segregation.cpp contains a single component that splits into a liquid and a vapor phase. The equilibrated densities of each phase depend on the equation of state and the temperature (here: G) you choose. What you could try now is to determine these equilibrium densities using the so-called Mechanical Stability Condition (there is an example of how to do this in Huang, Sukop, Lu: “Multiphase Lattice Boltzmann Methods: Theory and Application” p.33). Once these are known you could approximate (!) the total mass in the domain if each of these two phases occupies a desired number of cells. You could then adjust the initialisation in such a way that there is still a randomly distributed initial density field, but you would have to ensure that the total mass is (at least close to) correct.
At best, this is an approximation to what you want because an interface between the phases with some intermediate densities will spread over some cells.
Edit: For the particular Psi-Function that is used in the segregation.cpp, you could also use the Maxwell Construction to determine the equilibrium properties instead of the Mechanical Stability Condition.