CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

InterFoam: Add an equation to only one phase

Register Blogs Community New Posts Updated Threads Search

Like Tree10Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 17, 2012, 03:46
Default
  #21
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18
Cyp is on a distinguished road
Quote:
Originally Posted by voingiappone View Post
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

Last edited by Cyp; December 17, 2012 at 04:47.
Cyp is offline   Reply With Quote

Old   December 18, 2012, 05:33
Default
  #22
Member
 
Luca Giannelli
Join Date: Jun 2010
Location: Kobe, Japan
Posts: 58
Rep Power: 16
voingiappone is on a distinguished road
Quote:
Originally Posted by Cyp View Post
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
Cyp likes this.
voingiappone is offline   Reply With Quote

Old   December 18, 2012, 23:17
Default
  #23
Member
 
Luca Giannelli
Join Date: Jun 2010
Location: Kobe, Japan
Posts: 58
Rep Power: 16
voingiappone is on a distinguished road
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
Attached Images
File Type: jpg alpha corrected.jpg (48.8 KB, 350 views)
Cyp and raj kumar saini like this.
voingiappone is offline   Reply With Quote

Old   October 5, 2013, 02:51
Default
  #24
Member
 
vishal
Join Date: Mar 2013
Posts: 73
Rep Power: 13
vishal_s is on a distinguished road
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
vishal_s is offline   Reply With Quote

Old   October 8, 2013, 22:45
Default
  #25
Member
 
Luca Giannelli
Join Date: Jun 2010
Location: Kobe, Japan
Posts: 58
Rep Power: 16
voingiappone is on a distinguished road
Quote:
Originally Posted by vishal_s View Post
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
raj kumar saini likes this.
voingiappone is offline   Reply With Quote

Old   October 18, 2013, 01:58
Default
  #26
Member
 
vishal
Join Date: Mar 2013
Posts: 73
Rep Power: 13
vishal_s is on a distinguished road
Thanks Luca. I will give a try and let you know.
vishal_s is offline   Reply With Quote

Old   April 9, 2014, 17:45
Default
  #27
New Member
 
Jonas L. Ansoni
Join Date: Jun 2011
Location: Brazil
Posts: 22
Rep Power: 15
Jonas Ansoni is on a distinguished road
Quote:
Originally Posted by voingiappone View Post
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
Attached Images
File Type: png tracer01.PNG (21.4 KB, 126 views)
Jonas Ansoni is offline   Reply With Quote

Old   April 10, 2014, 00:27
Default
  #28
Member
 
Luca Giannelli
Join Date: Jun 2010
Location: Kobe, Japan
Posts: 58
Rep Power: 16
voingiappone is on a distinguished road
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 is offline   Reply With Quote

Old   April 10, 2014, 00:28
Default
  #29
Member
 
Luca Giannelli
Join Date: Jun 2010
Location: Kobe, Japan
Posts: 58
Rep Power: 16
voingiappone is on a distinguished road
Sorry, I forgot to specify that DC is a new variable defined as the product between the diffusion coefficient and the equilibrium concentration.
voingiappone is offline   Reply With Quote

Old   November 25, 2014, 11:38
Default
  #30
New Member
 
Lu ZHOU
Join Date: Jul 2014
Location: Lyon, France
Posts: 12
Rep Power: 12
lzhou is on a distinguished road
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 !
lzhou is offline   Reply With Quote

Old   November 25, 2014, 14:19
Default
  #31
Member
 
Luca Giannelli
Join Date: Jun 2010
Location: Kobe, Japan
Posts: 58
Rep Power: 16
voingiappone is on a distinguished road
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
voingiappone is offline   Reply With Quote

Old   December 2, 2014, 10:02
Default
  #32
New Member
 
Lu ZHOU
Join Date: Jul 2014
Location: Lyon, France
Posts: 12
Rep Power: 12
lzhou is on a distinguished road
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
Attached Images
File Type: jpg case.jpg (14.7 KB, 152 views)
File Type: jpg C1_development.jpg (14.4 KB, 148 views)
File Type: jpg C1_steady.jpg (13.7 KB, 130 views)
File Type: jpg C2_development.jpg (14.3 KB, 127 views)
File Type: jpg C2_steady.jpg (14.4 KB, 116 views)

Last edited by lzhou; December 4, 2014 at 11:22.
lzhou is offline   Reply With Quote

Old   July 28, 2016, 10:14
Default
  #33
New Member
 
Abbas Rahimi
Join Date: Jan 2013
Posts: 28
Rep Power: 13
AbbasRahimi is on a distinguished road
Quote:
Originally Posted by voingiappone View Post
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
AbbasRahimi is offline   Reply With Quote

Old   July 29, 2016, 04:15
Default
  #34
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,267
Blog Entries: 1
Rep Power: 25
nimasam is on a distinguished road
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
bharat_aero and rasool_soofi like this.
__________________
My Personal Website (http://nimasamkhaniani.ir/)
Telegram channel (https://t.me/cfd_foam)
nimasam is offline   Reply With Quote

Old   July 29, 2016, 09:59
Default
  #35
New Member
 
Abbas Rahimi
Join Date: Jan 2013
Posts: 28
Rep Power: 13
AbbasRahimi is on a distinguished road
Thank you Nima for response. Have you tried the work in any of these papers?
AbbasRahimi is offline   Reply With Quote

Old   July 30, 2016, 05:03
Default
  #36
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,267
Blog Entries: 1
Rep Power: 25
nimasam is on a distinguished road
yes, i did, it works
__________________
My Personal Website (http://nimasamkhaniani.ir/)
Telegram channel (https://t.me/cfd_foam)
nimasam is offline   Reply With Quote

Old   July 30, 2016, 21:39
Default
  #37
New Member
 
Abbas Rahimi
Join Date: Jan 2013
Posts: 28
Rep Power: 13
AbbasRahimi is on a distinguished road
Quote:
Originally Posted by nimasam View Post
yes, i did, it works
Is there any chance you share your code with me? My email is rahimi.abas@gmail.com
AbbasRahimi is offline   Reply With Quote

Old   May 1, 2018, 08:06
Default
  #38
Member
 
K
Join Date: Mar 2018
Posts: 34
Rep Power: 8
kuria is on a distinguished road
Hey voingiappone

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


Thank you!

Last edited by kuria; May 1, 2018 at 08:31. Reason: Incomplete reading of the thread
kuria is offline   Reply With Quote

Old   November 26, 2020, 16:05
Default mixing time tracer
  #39
New Member
 
roshan
Join Date: Dec 2019
Posts: 10
Rep Power: 7
roshanak.rabiee878 is on a distinguished road
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 View Post
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!
roshanak.rabiee878 is offline   Reply With Quote

Old   June 7, 2022, 08:33
Default
  #40
Member
 
sadra mahmoudi
Join Date: Feb 2021
Location: Austria
Posts: 39
Rep Power: 5
sadra2003 is on a distinguished road
Quote:
Originally Posted by Jonas Ansoni View Post
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.
sadra2003 is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Momentum equation of interFoam? cfdfans OpenFOAM 10 May 9, 2018 03:43
Solid/liquid phase change fabian_roesler OpenFOAM 10 December 24, 2012 07:37
Adding a new term in momentum equation of Interfoam udiitm OpenFOAM 5 July 29, 2012 11:52
compressible two phase flow in CFX4.4 youngan CFX 0 July 2, 2003 00:32
add user scalar in one phase zhu CFX 0 April 27, 2002 04:45


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