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

InterFoam: Add an equation to only one phase

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree3Likes

Reply
 
LinkBack Thread Tools Display Modes
Old   December 17, 2012, 03:46
Default
  #21
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 229
Rep Power: 9
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: 7
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: 7
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, 119 views)
Cyp likes this.
voingiappone is offline   Reply With Quote

Old   October 5, 2013, 01:51
Default
  #24
Member
 
vishal
Join Date: Mar 2013
Posts: 55
Rep Power: 4
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, 21:45
Default
  #25
Member
 
Luca Giannelli
Join Date: Jun 2010
Location: Kobe, Japan
Posts: 58
Rep Power: 7
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
voingiappone is offline   Reply With Quote

Old   October 18, 2013, 00:58
Default
  #26
Member
 
vishal
Join Date: Mar 2013
Posts: 55
Rep Power: 4
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, 16:45
Default
  #27
New Member
 
Jonas L. Ansoni
Join Date: Jun 2011
Posts: 22
Rep Power: 6
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, 31 views)
Jonas Ansoni is offline   Reply With Quote

Old   April 9, 2014, 23:27
Default
  #28
Member
 
Luca Giannelli
Join Date: Jun 2010
Location: Kobe, Japan
Posts: 58
Rep Power: 7
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 9, 2014, 23:28
Default
  #29
Member
 
Luca Giannelli
Join Date: Jun 2010
Location: Kobe, Japan
Posts: 58
Rep Power: 7
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: 8
Rep Power: 3
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: 7
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: 8
Rep Power: 3
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, 17 views)
File Type: jpg C1_development.jpg (14.4 KB, 17 views)
File Type: jpg C1_steady.jpg (13.7 KB, 17 views)
File Type: jpg C2_development.jpg (14.3 KB, 17 views)
File Type: jpg C2_steady.jpg (14.4 KB, 18 views)

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

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Momentum equation of interFoam? cfdfans OpenFOAM 9 January 5, 2013 04:09
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 10:52
compressible two phase flow in CFX4.4 youngan CFX 0 July 1, 2003 23:32
add user scalar in one phase zhu CFX 0 April 27, 2002 03:45


All times are GMT -4. The time now is 10:15.