# problems concerning mass conservativity in bubbleFoam with custom scalar transport

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

February 11, 2013, 09:51
problems concerning mass conservativity in bubbleFoam with custom scalar transport
#1
Senior Member

Join Date: Mar 2010
Location: Germany
Posts: 154
Rep Power: 9
Hi foamers,

after adding a simple scalar transport equation to bubbleFoam I'm facing problems regarding the mass conservativity of the scalar for several weeks now. My intention is to transport a passive scalar/ tracer in one of the two phases (currently within the gas phase alpha1 only). I'm therefore using phi1 within the convective part of the equation:

Code:
```        fvScalarMatrix myScalarTransportEqn (
fvm::ddt(myScalar)
+ fvm::div(phi1, myScalar)
- fvm::laplacian(D_myScalar, myScalar)
);
myScalarTransportEqn.solve();```
The resulting solver (see below) seems to run without any phase continuity errors. When computing the mass balance for the scalar I'm observing severe errors though. The solver produces mass from the very first step and in the end there's an error of more that 50%:

Code:
```Starting time loop

initial integral of scalar = domainIntegrate((myScalar*alpha1)) [0 3 0 0 0 0 0] 0.025
Courant Number mean: 0 max: 0
Time = 0.01

Max Ur Courant Number = 0
DILUPBiCG:  Solving for alpha1, Initial residual = 0, Final residual = 0, No Iterations 0
DILUPBiCG:  Solving for alpha1, Initial residual = 0, Final residual = 0, No Iterations 0
DILUPBiCG:  Solving for alpha1, Initial residual = 0, Final residual = 0, No Iterations 0
Dispersed phase volume fraction = 0.25  Min(alpha1) = 0  Max(alpha1) = 1
GAMGPCG:  Solving for p, Initial residual = 1, Final residual = 3.63861e-09, No Iterations 9
time step continuity errors : sum local = 9.76258e-12, global = -2.48287e-20, cumulative = -2.48287e-20
GAMGPCG:  Solving for p, Initial residual = 0.00150624, Final residual = 2.27757e-09, No Iterations 6
time step continuity errors : sum local = 2.54674e-10, global = -1.14032e-20, cumulative = -3.62318e-20
DILUPBiCG:  Solving for epsilon, Initial residual = 0.00556307, Final residual = 2.00741e-11, No Iterations 5
DILUPBiCG:  Solving for k, Initial residual = 1, Final residual = 2.28053e-11, No Iterations 5
DILUPBiCG:  Solving for myScalar, Initial residual = 0.212308, Final residual = 4.47246e-11, No Iterations 21
abs error of myScalar = 0.00290427
rel error of myScalar = 11.6171%
ExecutionTime = 0.12 s  ClockTime = 1 s

...

Courant Number mean: 0.0692709 max: 0.278919
Time = 5

Max Ur Courant Number = 0.204834
DILUPBiCG:  Solving for alpha1, Initial residual = 5.00392e-05, Final residual = 1.09122e-11, No Iterations 4
DILUPBiCG:  Solving for alpha1, Initial residual = 1.52951e-06, Final residual = 7.31573e-12, No Iterations 3
DILUPBiCG:  Solving for alpha1, Initial residual = 2.96263e-07, Final residual = 1.99348e-12, No Iterations 3
Dispersed phase volume fraction = 0.25  Min(alpha1) = 6.05194e-33  Max(alpha1) = 1
GAMGPCG:  Solving for p, Initial residual = 0.0077321, Final residual = 7.97984e-10, No Iterations 7
time step continuity errors : sum local = 5.03872e-12, global = 6.34931e-20, cumulative = -5.07847e-16
GAMGPCG:  Solving for p, Initial residual = 0.000680436, Final residual = 1.29913e-09, No Iterations 6
time step continuity errors : sum local = 8.1173e-12, global = -2.98023e-20, cumulative = -5.07877e-16
DILUPBiCG:  Solving for epsilon, Initial residual = 0.00491431, Final residual = 3.90082e-11, No Iterations 8
DILUPBiCG:  Solving for k, Initial residual = 0.00319378, Final residual = 4.11936e-11, No Iterations 8
DILUPBiCG:  Solving for myScalar, Initial residual = 8.51307e-05, Final residual = 5.8246e-11, No Iterations 15
abs error of myScalar = 0.0138097
rel error of myScalar = 55.2387%
ExecutionTime = 52.45 s  ClockTime = 54 s

End```
Could you please tell my what am I missing here?! I assume there's something wrong with the usage of phi1 and alpha1. Before the computation of the scalar transport the original code of bubbleFoam performs the transport of the phase fractions alpha1 and alpha2. In my opinion the change of the phase fractions needs to be considered during the computation of my own scalar transport. But all of my approaches towards the inclusion of the phase faction of the current or previous time step into the above equation failed so far.

Please find the modified solver and a simple test case attached. All changes within the code of bubbleFoam are labeled with comments CHANGE#1 through CHANGE#4 (source files bubbleFoamScalarTrans.C and createFields.H). The solver should compile and run with the OF-2.1.x git-release.

The accompanying simplified test case is a bottom driven cavity with a huge bubble inside. This bubble also contains the tracer which needs to be transported within the domain. Since there's no fluid entering/leaving the cavity the total mass of the tracer is expected to always stay constant.

cutter
Attached Images
 initial_conditions.jpg (20.6 KB, 26 views)
Attached Files
 bubbleFoamScalarTrans.tar.gz (13.0 KB, 13 views) BottomDrivenCavity.tar.gz (3.6 KB, 3 views)

 March 5, 2013, 09:03 #2 Senior Member   Join Date: Mar 2010 Location: Germany Posts: 154 Rep Power: 9 Dear Foamers, I'm sorry to bring it up again, but another three weeks passed and I didn't make any significant progress on this issue. Here's what I did so far: First of all I changed the computation of the total mass within the tank (removed factor alpha1 in integration). The field myScalar is therefore the total mass of the tracer scalar per cell in phase alpha1 (no matter what the actual cell volume and phase fraction is). I also removed the diffusive part of the equation (last line of transport equation). The simulation then yields a relative error e_rel=6.e-7, which should be enough for most engineering applications. When I open the lid and allow air to leave the cavity the error is several magnitudes larger (with correct accounting of the mass that passed through the top). To sum it up: there's still something important missing here. Could you please provide some references to literature that describes the correct treatment of passive scalar transport in multiphase CFD simulations? By the way, is there any particular reason this post got no replies at all? Is there any relevant informationion missing? I'm a non-native speaker, so please forgive me all formulations that might sound inappropriate or inpolite in your ears. I'm looking forward for your answers! Thanks cutter

 February 9, 2015, 08:25 #3 Member   A. Bernath Join Date: Jun 2011 Location: Karlsruhe, Germany Posts: 39 Rep Power: 8 Hi cutter, did you manage to solve the problem? I want to achieve the same thing as you, but I'm using the twoPhaseEulerFoam solver of OF 2.3.1. As far as I know, this solver is a further developed version of bubbleFoam and the changes address mass conservation problems, so maybe your problem has been solved with the newer version or at least gives you some hints. My problem however is already adding the transport equation: http://www.cfd-online.com/Forums/ope...oam-of231.html If you did find a solution for your problem, it could be helpful for me too. Thanks, Alex

 February 10, 2015, 05:25 #4 Senior Member   Olivier Join Date: Jun 2009 Location: France, grenoble Posts: 266 Rep Power: 11 hello, As for all scalar transport, take care at inlet / outlet when you "calculate" the flux. The common error is to calculate only the convective flux, not the diffusive one, which lead to the "conservation error" see http://www.cfd-online.com/Forums/ope...tml#post415846 Solution are: 1) calculate the total flux (with diffusion) 2) set diffusion coef to 0 at inlet/outlet boundary (work but not nice !) 3) take a look at "totaFlowRateAdvectivediffusive" BC (not tested). regards, olivier

 Tags bubblefoam, mass conservation, multiphase, scalar transport, two phase

 Thread Tools Display Modes Linear Mode

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

 Similar Threads Thread Thread Starter Forum Replies Last Post joel.lehikoinen OpenFOAM Programming & Development 9 October 3, 2013 08:00 CFDtoy Main CFD Forum 2 February 19, 2011 10:43 jannnesss CFX 0 January 8, 2010 20:53 JSM FLUENT 0 May 2, 2007 23:56 shao1 FLUENT 0 July 11, 2002 21:58

All times are GMT -4. The time now is 13:54.