CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   InterFoam: Add an equation to only one phase (https://www.cfd-online.com/Forums/openfoam-programming-development/110512-interfoam-add-equation-only-one-phase.html)

Cyp December 17, 2012 03:46

Quote:

Originally Posted by voingiappone (Post 397830)
Hello Cyp, and thanks for the development of the equations!

Taking another way I got to the same result but in my case it was inserted in the context of the equation I shown some posts above. I left it untouched (by actually removing diffusion) as I was not able to compile the file with my poor C++ knowledge.

But let's say we can do like you kindly calculated and we end up with the equation (no flux at the interface):


This represents the interfacial jump condition however I can leave it untouched as a function of C_{\beta} right?
Now I should add it to the main equation to take into account the time dependence:

\frac{\partial C}{\partial t}+\nabla \phi C + \nabla\cdot D \nabla C = 0

which, applying your calculations, should become:

\frac{\partial C}{\partial t}+\nabla \phi C + \nabla \cdot D C\nabla \alpha= 0

But the \nabla \phi C part should be treated the same way to include the alpha dependence right? Or am I missing something?

BTW, also thanks for showing me the [math] tag! Really useful!


Hello,

Actually, \nabla \cdot D C_{eq}\nabla \alpha is an additional source term. If you re-do the equations development starting from
\frac{\partial C}{\partial t}+\nabla \cdot \phi C + \nabla\cdot D \nabla C

You will obtain (neglecting the flux term), something like :
\frac{\partial C}{\partial t}+\nabla \cdot \phi C + \nabla\cdot D \nabla C = \nabla \cdot D C_{eq}\nabla \alpha

The rhs must be treated as an explicit term in your C equation. C_{eq} is evaluated from the thermodynamics. It depends on C_{\gamma} or be constant, it's up to you. As a starting point, I suggest you to consider it as a constant value.

Regards,
Cyp

voingiappone December 18, 2012 05:33

Quote:

Originally Posted by Cyp (Post 397850)
Hello,

Actually, \nabla \cdot D C_{eq}\nabla \alpha is an additional source term. If you re-do the equations development starting from
\frac{\partial C}{\partial t}+\nabla \cdot \phi C + \nabla\cdot D \nabla C

You will obtain (neglecting the flux term), something like :
\frac{\partial C}{\partial t}+\nabla \cdot \phi C + \nabla\cdot D \nabla C = \nabla \cdot D C_{eq}\nabla \alpha

The rhs must be treated as an explicit term in your C equation. C_{eq} is evaluated from the thermodynamics. It depends on C_{\gamma} or be constant, it's up to you. As a starting point, I suggest you to consider it as a constant value.

Regards,
Cyp

Howdy Cip,

got the point! I'll see if I can find some time to implement the equation in the code and run a test simulation so I can get back here and report the result.

Thanks!

Luca

voingiappone December 18, 2012 23:17

1 Attachment(s)
Cyp,

you're the man! The problem was (almost) completely solved using your approach! I had some problems after inserting the alpha laplacian in the .C file as I had to specify to solve it as an explicit term but after figuring out how to fix that, the simulation runs smoothly.

The tracer is still coming out from the liquid phase but only to a minor extent, due to the "froth" like interface smearing you have when a lot of bubbles hit the surface but that's something that really happens in the reactor so I think that won't bother me that much.

I attach a screenshot of the simulation where you can see that.

Man, thank you so much for your help! I can now move on to my next problem: coupling my algae growth curve in the system, but that will be done afterwards and not using openFOAM.

Luca

vishal_s October 5, 2013 02:51

Hello luca,I am trying to simulate jet(liquid) in a different density medium (air) . The jet gets vaporized once it reaches it's specific vaporization temperature/pressure. I read ur thread but I am bit confused, how to add a transport scalar to the 2nd phase (air) to take into account vapor in interPhasechange Foam. What changes I have to make in the solvers??

Please help

voingiappone October 8, 2013 22:45

Quote:

Originally Posted by vishal_s (Post 455146)
take into account vapor in interPhasechange Foam

Hello vishal, first of all let me tell you that I don't use that particular software so I may not be the best person to ask to....
For what I was able to read on the forum, that solver is used when a liquid phase vaporizes into its vapor, that is you are trying to make water to vaporize in air (three phases). I don't know if you can do that with that specific solver.

It may look like you can use my approach in your situation but I think it is very different: in my case I have a low concentration parameter that changed the phase, not the liquid itself so its effect on liquid/gas properties is negligible. For this reason you have to keep in mind something:

- adding a new equation (at least in interFoam) creates a sort of new layer over with the new scalar is solved. What I mean is that your main equations get solved beforehand and then, the new one is solved using (where needed) p and U values from the main ones. This makes the new equation "phase insensitive" that's in the end the reason why I created this thread.

- when you add a new parameter with the alpha1 dependence you get two of them because:

C = C_{liq} \cdot alpha1 + C_{gas} \cdot (1 - alpha1)

for this reason, if you add a new scalar it won't get solved together with the main equations and it will have to be adjusted to consist of just one phase (because you actually only need three). So, I think this is not the right approach. Moreover in your case, the liquid phase vanishes as it vaporizes so major changes that cannot be neglected happen in the momentum equation!

The only thing I can think of is that you solve the problem using the 2 phases available and make adjustments for each time step to the gas phase. What i mean is that once solved the time step, your newly added equation can average the gas properties with those of air and then save the calculated data in a dedicated file. You may not want to average using alpha1 (or you get the liquid in the way again) but maybe with vapor pressure may work...?? Something like:

C_{air} = \frac{P^{*}(T)-P}{P^{*}(T)} \cdot (1 - alpha1)

This can be the air concentration in the vapor cloud (not in the liquid) where at the interface you have a pressuse equal to the vapor pressure for the given temperature and as you move away from the interface you have a lower pressure, up to zero where air concentration in air becomes, obviously 1. Doing this you can see the air concentration distribution. Then you can use this parameter to average gas properties between the air and the vapor values and write a dimensioned scalar file in each time step folder if you wish.
However this approach will solve the jet flow phase change using ONLY the vapour transport properties stored in the transportProperties file. If they are similar to air properties (and they may be) the solution will not be that different from the right one.

I am sorry if this is not what you are looking for but if you need help let's discuss it here. If you like it I can tell you how to do it.

Luca

vishal_s October 18, 2013 01:58

Thanks Luca. I will give a try and let you know.

Jonas Ansoni April 9, 2014 17:45

1 Attachment(s)
Quote:

Originally Posted by voingiappone (Post 398036)
Howdy Cip,

got the point! I'll see if I can find some time to implement the equation in the code and run a test simulation so I can get back here and report the result.

Thanks!

Luca

Hello Luca!

I'm having the same problem you got, as shown in attached Fig. I'm implementing the equation, but I'm having trouble to insert the term \nabla \cdot D C_{eq}\nabla\alpha.

How have you implemented this term in the .C file?

Thank you in advance

voingiappone April 10, 2014 00:27

Hi Jonas,

you did not explain which problem you are facing so I just try to guess. The only problem I had to implement the code in the C file was that you use an already calculated field (alpha1) in a laplacian so you have to calculate it as an explicit:

Code:

fvc::laplacian(DC, alpha1)
This was the only problem I had that did not let me compile the file.

Let me know if you solved the problem.

cheers

voingiappone April 10, 2014 00:28

Sorry, I forgot to specify that DC is a new variable defined as the product between the diffusion coefficient and the equilibrium concentration.

lzhou November 25, 2014 11:38

Hello Luca,

I am doing a simulation with interFoam and I would also like to add a concentration equation (the concentration of sediment actually) into the solver. The problem is similar as yours which is that I want the concentration in the air to be zero and the equation only be solved in the water zone. Reading this thread gives me a lot of help. I just want to ask how did you define the equilibrium concentration at the interface ? As the concentration in air is zero and the concentration in water is unknown and to be calculated ... Maybe I don't understand correctly...Can you please help me with this problem ?

Thanks !

voingiappone November 25, 2014 14:19

Hi Izhou!

First of all, if you're dealing with suspended solids, I seem to recall that a multiphase interFoam is available where you can model them. Did you give it a shot?

Anyway, if you want to proceed with this approach, I will tell you what I did. I went through different approaches, the most correct of which is the one where you set the eq. concentration equal to the bulk concentration, to be solved for. As you correctly noticed. I was not able at first to compile or run the code, so I changed the approach and set it as a constant. I eventually succeeded but used that with the phase change.

I was going to use this to calculate the mixing time and validating with an experiment so I made some assumptions:

- whatever the initial pulse concentration, the interface concentration would be 0.
- whatever the initial concentration, the interface concentration at t=t_mix would be exactly equal to the bulk concentration

As you can see in the various screenshots, the liquid gas interface in an air lift reactor is on the top part (bubbles excluded) so I decided to approximate the interface concentration with the perfectly mixed concentration, that is the concentration attained after t_mix by using the initial NaCl in the pulse.

This is an approximation but the error appears to be minimal when compared with a mixing time experiment in the actual reactor. If your concentrations are low enough and the instruments are sensitive enough to measure small pulses, you can actually verify this as I did and the result will not differ from the simulation. However, I don't know your situation and your simulation conditions so, the only thing is trying to set it up and verify if it works for you. If it doesn't, you should add C_eq=C as a variable and solve for it as usual. This is the case when you do have the phase change and the interface concentration is solved. I ended up with the equation (in the .cpp file):

Code:

fvm :: laplacian ( alpha1 , C )
Of course, this is only the part referring to the interface equilibrium. Either of the two approaches should do the trick.
Let me know if you made it run successfully.

Cheers

Luca

lzhou December 2, 2014 10:02

5 Attachment(s)
Hi Luca,

Thanks very much for your kindly help and I am sorry for the delay of my response.

I have tried both of the ways you remanded and I have also looked into the "multiPhaseInterFoam". I'm not sure this solver can be used to solve my problem as it seems to me that the mixture of water and sediment is not the same as the mixture of water and oil.. Meanwhile, there is another solver called "settlingFoam" which seems to be interesting, but it does not include the free surface effect so I think I still have to use your method to solve this problem.:)

My case is the water jet under a sluice gate as showed in fig.case. And I added the concentration equation into interFoam solver to calculate the suspended load concentration of sediment.

I first set the Ceq as the concentration of sediment at steady state. During the development (fig.C1_development) it seems to cause a little error at the interface but after reaching steady state the result is fine(fig.C1_steady). So I thought the problem during the development is because the Ceq should be the same as the concentration at the interface. Then I set the value of Ceq as the C value at the interface as follow:
Code:

surfaceScalarField Cf = fvc::interpolate(C);

fvScalarMatrix CEqn
    (
        fvm::ddt(C)
        + fvm::div(phiC, C)
        - fvm::laplacian(nuEff, C)
        ==
        - fvc::laplacian(nuEff*(Cf), alpha1)
    );
     
  CEqn.solve();

With this equation, the problem during the development is solved but the final result show more convection into the air phase. I didn't find any other way to have a better result...

Later in my case I have to add the falling velocity of the sediment into the concentration equation and the concentration at steady state will then no longer be uniform, so for now I will use the second way to implement the concentration equation...But I'll continue to look at this problem.

And there is another question. I don't know what is the value of DC,which is the mass diffusivity, so I just use the effective viscosity...Is this reasonable ? Do you have any suggestions ?

Thanks again for your reply and have a nice day !

Lu ZHOU

AbbasRahimi July 28, 2016 10:14

Quote:

Originally Posted by voingiappone (Post 521069)
Hi Izhou!

First of all, if you're dealing with suspended solids, I seem to recall that a multiphase interFoam is available where you can model them. Did you give it a shot?

Anyway, if you want to proceed with this approach, I will tell you what I did. I went through different approaches, the most correct of which is the one where you set the eq. concentration equal to the bulk concentration, to be solved for. As you correctly noticed. I was not able at first to compile or run the code, so I changed the approach and set it as a constant. I eventually succeeded but used that with the phase change.

I was going to use this to calculate the mixing time and validating with an experiment so I made some assumptions:

- whatever the initial pulse concentration, the interface concentration would be 0.
- whatever the initial concentration, the interface concentration at t=t_mix would be exactly equal to the bulk concentration

As you can see in the various screenshots, the liquid gas interface in an air lift reactor is on the top part (bubbles excluded) so I decided to approximate the interface concentration with the perfectly mixed concentration, that is the concentration attained after t_mix by using the initial NaCl in the pulse.

This is an approximation but the error appears to be minimal when compared with a mixing time experiment in the actual reactor. If your concentrations are low enough and the instruments are sensitive enough to measure small pulses, you can actually verify this as I did and the result will not differ from the simulation. However, I don't know your situation and your simulation conditions so, the only thing is trying to set it up and verify if it works for you. If it doesn't, you should add C_eq=C as a variable and solve for it as usual. This is the case when you do have the phase change and the interface concentration is solved. I ended up with the equation (in the .cpp file):

Code:

fvm :: laplacian ( alpha1 , C )
Of course, this is only the part referring to the interface equilibrium. Either of the two approaches should do the trick.
Let me know if you made it run successfully.

Cheers

Luca

Hi Luca,

I'm struggling with the same problem you did. I tried to used the steps you have provided to develop a new scalarTransportFoam to avoid diffusion of tracer into other phase. No success so far! Is there any chance you share the equations you put in scalarTransportFoam solver?

Thanks and regards,
Abbas

nimasam July 29, 2016 04:15

Dear Abbas

look following papers:
1- A unified single-field model framework for Volume-Of-Fluid
simulations of interfacial species transfer applied to bubbly flows

2-Numerical simulation of species transfer across fluid interfaces in
free-surface flows using OpenFOAM

AbbasRahimi July 29, 2016 09:59

Thank you Nima for response. Have you tried the work in any of these papers?

nimasam July 30, 2016 05:03

yes, i did, it works :)

AbbasRahimi July 30, 2016 21:39

Quote:

Originally Posted by nimasam (Post 612039)
yes, i did, it works :)

Is there any chance you share your code with me? My email is rahimi.abas@gmail.com

kuria May 1, 2018 08:06

Hey voingiappone

It would be great if you could upload the code you used to fix this problem :)


Thank you!

roshanak.rabiee878 November 26, 2020 16:05

mixing time tracer
 
hi
I was wondering if you solved your problem or not.
I had the same case, I want to calculate the mixing time. I created a new solver based on interFOAM and added a new transport equation. my problem is two-point?
I need to inject this tracer inside of domain, not at the inlet
time of injection is not at the beginning, it applied at a specific time and specific duration
How Can I do that? can you help me?
Quote:

Originally Posted by voingiappone (Post 397276)
Hello again everybody,

as I already explained here, I want to insert a tracer in my simulation to calculate the mixing time of the reactor.
I want to consider only the liquid phase as I am going to insert a certain amount of NaCl as tracer and follow the time evolution of the concentration with a probe.

Now I was just able to add the tracer using as a base the wiki page on how to add temperature to icoFoam. However, if I run the simulation I get my tracer propagating out of the liquid phase through the interface into the gas.

Watching this thread (http://www.cfd-online.com/Forums/ope...interfoam.html) I made an idea of how to read physical properties for different phases but I cannot figure out how to make my equation to be solved only for the liquid phase.
To put things simple, now it looks like it is just overlapping the liquid-gas system (i have a global equation, a global diffusion coefficient, etc). See attached screenshot (tracer concentration profile on the right).

Is there anybody who can help me with this task?

Thanks!


sadra2003 June 7, 2022 08:33

Quote:

Originally Posted by Jonas Ansoni (Post 485038)
Hello Luca!

I'm having the same problem you got, as shown in attached Fig. I'm implementing the equation, but I'm having trouble to insert the term \nabla \cdot D C_{eq}\nabla\alpha.

How have you implemented this term in the .C file?

Thank you in advance


Hello Jonas,

I am trying to simulate a single bubble movement in a solution of water and sugar with interIsoFoam solver, OF2112. I modified the solver and coupled the density, surface tension and viscosity of solution to the concentration of sugar which is different in various parts of the domain. In order to solve the distribution of sugar (a passive scalar) in the geometry, I added a new equation to the solver as below:

fvScalarMatrix CEqn
(
fvm::ddt(C)
+ fvm::div(phi, C)
- fvm::laplacian(dc,C)
==
fvOptions(C)
);


CEqn.relax();
fvOptions.constrain(CEqn);
CEqn.solve();
fvOptions.correct(C);

Now, the problem is, sugar concentration penetrates inside the bubble which is not correct. I would like to know how can I prevent sugar entering the bubble? I would be more than happy if you share your opinion with me.


All times are GMT -4. The time now is 21:24.