
[Sponsors] 
June 7, 2011, 11:12 
Diffusive flux in interMixingFoam

#1 
New Member
Join Date: Sep 2010
Posts: 18
Rep Power: 9 
Dear Foamers,
this is my first thread started, so here is a little introduction: I've been working with OF for almost one year now and my current version is 1.7.0. My main interests are multiphase flows and in the last time a little bit of mixing. I've got a little question about the diffusive flux for alpha2>alpha3 in interMixingFoam. In alphaEqns.H there is the line Code:
phiAlpha2 = fvc::interpolate(Dc32)*mesh.magSf()*fvc::snGrad(alpha1) Sorry for bothering you if I'm wrong and thanks for your help in advance! Best regards, oswald 

May 24, 2013, 09:12 
bug in interMixingFoam?

#2 
Senior Member
Albrecht vBoetticher
Join Date: Aug 2010
Location: Zürich, Swizerland
Posts: 218
Rep Power: 10 
Any news? I wonder about the same thing. Simulating channel flow with the three phases, alpha3 seems to dissolve slowly into alpha1 while alpha2 stays niceley seperated from alpha1 as it should! If anyone please could have a look befor I do a bug report?


June 4, 2013, 10:46 

#3 
Senior Member
Albrecht vBoetticher
Join Date: Aug 2010
Location: Zürich, Swizerland
Posts: 218
Rep Power: 10 
...and by the way, maybe someone could shed some light on:
// Add the diffusive flux for alpha3>alpha2 phiAlpha2 = fvc::interpolate(Dc32)*mesh.magSf()*fvc::snGrad(al pha3); were only Dc32 adds to diffusive flux but followed by: // Solve for alpha2 fvScalarMatrix alpha2Eqn ( fvm::ddt(alpha2) + fvc::div(phiAlpha2)  fvm::laplacian(Dc23 + Dc32, alpha2) ); Dc23 and Dc32 contribute. I am sorry if this is trivial, maybe I am a bit confused looking and comparing the different multiphase solvers. Inspired by twoLiquidMixingFoam I just gave it a try to add the influence of turbulence via the turbulent schmidt number to the diffusion in interMixingFoam, and I noticed I have to account for it in the diffusive flux for alpha3>alpha 2 and in the alpha2 equation. 

June 26, 2013, 05:29 
improved interMixingFoam in respect to mixing

#4 
Senior Member
Albrecht vBoetticher
Join Date: Aug 2010
Location: Zürich, Swizerland
Posts: 218
Rep Power: 10 
So here is my adjusted alphaEqns.H and createFields.H with the following features:
the two liquids are solved for and alpha1 is derived from 1  alpha2  alpha3 the diffusive flux is added by *mesh.magSf()*fvc::snGrad(alpha2); and *mesh.magSf()*fvc::snGrad(alpha3); respectiveley, no alpha1 used here (still think this is a bug in interMixingFoam) eddy diffusion is included either by local turbulence viscosity and turbulent Schmidt number, or for laminar flow by local vorticity (grid dependent!) and mixing length derived in dependency to distance to boundary. So the reciprocal of the turbulent Schmidt number is introduced to transportProperties as well as a mixingLengthFactor which can be seen as an adjustable von Karman constant. alphaEqns.H: { word alphaScheme("div(phi,alpha)"); word alpharScheme("div(phirb,alpha)"); surfaceScalarField phir ( IOobject ( "phir", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), interface.cAlpha()*mag(phi/mesh.magSf())*interface.nHatf() //phase fraction * flux/cellsurface * cell face unit interface normal flux ); // calculate vorticity to increase diffusion at regions of high vorticity volScalarField vorticityMag ( IOobject ( "vorticityMag", runTime.timeName(), mesh, IOobject::NO_READ ), mag(fvc::curl(U)) ); for (int gCorr=0; gCorr<nAlphaCorr; gCorr++) { // Create the limiter to be used for all phasefractions scalarField allLambda(mesh.nFaces(), 1.0); // Split the limiter into a surfaceScalarField slicedSurfaceScalarField lambda ( IOobject ( "lambda", mesh.time().timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE, false ), mesh, dimless, allLambda, false // Use slices for the couples ); // Create the complete flux for alpha2 surfaceScalarField phiAlpha2 ( fvc::flux ( phi, alpha2, alphaScheme ) + fvc::flux ( fvc::flux(phir, alpha1, alpharScheme), alpha2, alpharScheme ) + fvc::flux ( fvc::flux(phir, alpha3, alpharScheme), alpha2, alpharScheme ) ); // Create the bounded (upwind) flux for alpha2 surfaceScalarField phiAlpha2BD ( upwind<scalar>(mesh, phi).flux(alpha2) ); // Calculate the flux correction for alpha2 phiAlpha2 = phiAlpha2BD; // Calculate the limiter for alpha2 MULES::limiter ( allLambda, geometricOneField(), alpha2, phiAlpha2BD, phiAlpha2, zeroField(), zeroField(), 1, 0, 3 ); // Construct the limited fluxes phiAlpha2 = phiAlpha2BD + lambda*phiAlpha2; // Create the complete flux for alpha3 surfaceScalarField phiAlpha3 ( fvc::flux ( phi, alpha3, alphaScheme ) + fvc::flux ( fvc::flux(phir, alpha1, alpharScheme), alpha3, alpharScheme ) ); // Create the bounded (upwind) flux for alpha3 surfaceScalarField phiAlpha3BD ( upwind<scalar>(mesh, phi).flux(alpha3) ); // Calculate the flux correction for alpha3 phiAlpha3 = phiAlpha3BD; // Further limit the limiter for alpha3 MULES::limiter ( allLambda, geometricOneField(), alpha3, phiAlpha3BD, phiAlpha3, zeroField(), zeroField(), 1, 0, 3 ); // Construct the limited fluxes phiAlpha3 = phiAlpha3BD + lambda*phiAlpha3; volScalarField Dc23(D23*max(alpha3, scalar(0))*pos(alpha2)); volScalarField Dc32(D23*max(alpha2, scalar(0))*pos(alpha3)); /* calculate the turbulent mixing, orienting by P. Nielsen et al.: "Turbulent diffusion of momentum and suspended particles: A finitemixinglength theory" (2004) Physics of Fluids Vol. 16 Issue 7 but take the vorticity at the cell times the average cell size as a replacement for the settling velocity used in the paper. For mixing length: By assuming that the mixing length is proportional to the distance to the bottom, lm=κz (κ is von Karman constant, z is height above bed),Prandtl obtained the logarithmic velocity profile. Assume the same but replace the von Karman constant with a model parameter, analog to the turbulent Schmidt number. See also Debris Flow: Mechanics, Prediction and Countermeasures (2007) by T. Takahashi, chapter Models for Mechanics of Flow, p.83*/ volScalarField Vc23(mixingLengthFactor*vorticityMag*cellDiameter* wallDistance*max(alpha3, scalar(0))*pos(alpha2)); volScalarField Vc32(mixingLengthFactor*vorticityMag*cellDiameter* wallDistance*max(alpha2, scalar(0))*pos(alpha3)); Info<< "Phasediffusion due to vorticity = " << " Min(vorticityMag*cellsize*wallDistance*mixingLengt hFactor) = " << (min(Vc32)).value() << " Max(vorticityMag*cellsize*wallDistance*mixingLengt hFactor) = " << (max(Vc32)).value() << endl; // Add the diffusive flux for alpha3>alpha2 phiAlpha2 = fvc::interpolate(Dc32 + Vc32 + alphatab*turbulence>nut() )*mesh.magSf()*fvc::snGrad(alpha2); // Solve for alpha2 fvScalarMatrix alpha2Eqn ( fvm::ddt(alpha2) + fvc::div(phiAlpha2) + fvm::SuSp(fvc::div(phi), alpha2)//chegdan on October 16, 2010: http://www.cfdonline.com/Forums/ope...culations.html  fvm::laplacian(Dc32 + Dc23 + Vc23 + Vc32 + alphatab*turbulence>nut() , alpha2) ); alpha2Eqn.solve(); // Add the diffusive flux for alpha2>alpha3 phiAlpha3 = fvc::interpolate(Dc23 + Vc23 + alphatab*turbulence>nut())*mesh.magSf()*fvc::snGrad(alpha3); // Solve for alpha3 //alphatab is the reciprocal of the turbulent Schmidt number, introduce turbulent mixing see book by Fox "computational models for turbulent reacting flows" fvScalarMatrix alpha3Eqn ( fvm::ddt(alpha3) + fvc::div(phiAlpha3) + fvm::SuSp(fvc::div(phi), alpha3)//chegdan on October 16, 2010: http://www.cfdonline.com/Forums/ope...culations.html  fvm::laplacian(Dc23 + Dc32 + Vc23 + Vc32 + alphatab*turbulence>nut() , alpha3) ); alpha3Eqn.solve(); // Construct the complete mass flux */ rhoPhi = (phiAlpha3 + alpha3Eqn.flux())*(rho3  rho1) + (phiAlpha2 + alpha2Eqn.flux())*(rho2  rho1) + phi*rho1; alpha1 = 1.0  alpha2  alpha3; } Info<< "Mud phase volume fraction = " << alpha2.weightedAverage(mesh.V()).value() << " Min(alpha2) = " << min(alpha2).value() << " Max(alpha2) = " << max(alpha2).value() << endl; Info<< "Granular phase volume fraction = " << alpha3.weightedAverage(mesh.V()).value() << " Min(alpha3) = " << min(alpha3).value() << " Max(alpha3) = " << max(alpha3).value() << endl; Info<< "Phasediffusion due to turbulence = " << " Min(alphatab*turb>nut()) = " << (min(turbulence>nut())*alphatab).value() << " Max(alphatab*turb>nut()) = " << (max(turbulence>nut())*alphatab).value() << endl; } createFields.H Info<< "Reading field p_rgh\n" << endl; volScalarField p_rgh ( IOobject ( "p_rgh", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); Info<< "Reading field alpha1\n" << endl; volScalarField alpha1 ( IOobject ( "alpha1", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); Info<< "Reading field alpha2\n" << endl; volScalarField alpha2 ( IOobject ( "alpha2", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); Info<< "Reading field alpha3\n" << endl; volScalarField alpha3 ( IOobject ( "alpha3", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); alpha3 == 1.0  alpha1  alpha2; Info<< "Reading field U\n" << endl; volVectorField U ( IOobject ( "U", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); #include "createPhi.H" threePhaseMixture threePhaseProperties(U, phi); const dimensionedScalar& rho1 = threePhaseProperties.rho1(); const dimensionedScalar& rho2 = threePhaseProperties.rho2(); const dimensionedScalar& rho3 = threePhaseProperties.rho3(); dimensionedScalar D23(threePhaseProperties.lookup("D23")); // Read the reciprocal of the turbulent Schmidt number dimensionedScalar alphatab(threePhaseProperties.lookup("alphatab")); // Read a constant in analogy to the von Karman constant, to gain mixing length in dependency to celldistance to wall dimensionedScalar mixingLengthFactor(threePhaseProperties.lookup("mi xingLengthFactor")); // calculate an average cell size used to gain a mixing velocity in each cell from cellvorticity, applied for eddy diffsuion volScalarField cellDiameter(pow(0.1666*fvc::surfaceSum(mesh.magSf ()), 0.5)); // get cell distances to walls volScalarField wallDistance(cellDiameter); const polyBoundaryMesh& patches = mesh.boundaryMesh(); forAll(wallDistance, cellI) { // get the position for the particle const vector& position = mesh.C()[cellI]; scalar distance = GREAT; // loop over all patches forAll(patches, patchI) { //if (isA<wallPolyPatch>(patches[patchI])) // not working { const polyPatch& patch = patches[patchI]; const vectorField& n = patch.faceNormals(); const vectorField& C = patch.faceCentres(); forAll(C, i) { vector normal = n[i]/mag(n[i]); //scalar di = mag(position  C[i]); // distance to face centre scalar di = mag( normal & ( position  C[i] ) ); distance = min(distance, di); } } } wallDistance[cellI] = distance; // Info << "distance to wall is " << distance << endl; } // Need to store rho for ddt(rho, U) volScalarField rho ( IOobject ( "rho", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT ), alpha1*rho1 + alpha2*rho2 + alpha3*rho3, alpha1.boundaryField().types() ); rho.oldTime(); // Mass flux // Initialisation does not matter because rhoPhi is reset after the // alpha solution before it is used in the U equation. surfaceScalarField rhoPhi ( IOobject ( "rho*phi", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), rho1*phi ); // Construct interface from alpha distribution threePhaseInterfaceProperties interface(threePhaseProperties); // Construct incompressible turbulence model autoPtr<incompressible::turbulenceModel> turbulence ( incompressible::turbulenceModel::New(U, phi, threePhaseProperties) ); Info<< "Calculating field g.h\n" << endl; volScalarField gh("gh", g & mesh.C()); surfaceScalarField ghf("ghf", g & mesh.Cf()); volScalarField p ( IOobject ( "p", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), p_rgh + rho*gh ); label pRefCell = 0; scalar pRefValue = 0.0; setRefCell ( p, p_rgh, mesh.solutionDict().subDict("PIMPLE"), pRefCell, pRefValue ); if (p_rgh.needReference()) { p += dimensionedScalar ( "p", p.dimensions(), pRefValue  getRefCellValue(p, pRefCell) ); p_rgh = p  rho*gh; } IObasicSourceList sources(mesh); Attatched a comparison of the dambreak tutorial at t= 0.75 without turbulence but with mixingLengthFactor 0.4 increasing the diffusion due to vorticity. Anyone knows a testCase to test the solver, or maybe someone could check the code? 

July 2, 2013, 03:26 

#5 
Senior Member
Albrecht vBoetticher
Join Date: Aug 2010
Location: Zürich, Swizerland
Posts: 218
Rep Power: 10 
Ok, in larger scale and longer runs, alpha2 and alpha3 diffuse into alpha1 when applying diffudive terms, and the massbalance (due to bounding?) is not quite right yet in the suggestion above because the liquid volume phase goes down continuously. But guess what, the regular interMixingFoam faces the same problem...
Any hints? I will try out what happends without bounding of alpha2 or alpha3. Last edited by vonboett; July 11, 2013 at 11:04. 

September 26, 2013, 05:11 

#6 
Senior Member
Albrecht vBoetticher
Join Date: Aug 2010
Location: Zürich, Swizerland
Posts: 218
Rep Power: 10 
Well, it works by now conserving the mass of the two liquids and keeping their concentrations bound between 0 and 1. But I had to introduce a solving step for the air phase. Will post the code here when tests are finished.


February 5, 2014, 12:18 
Showing both of the mixing fluids

#7 
New Member
anonymous
Join Date: Jan 2012
Location: Canada
Posts: 24
Rep Power: 7 
Hi
I was wondering if anybody knows how to show both of the phases that are mixing with each other (in the interMixingFoam solver) in the paraview simultaneously. Regards Mahyar 

February 6, 2014, 08:44 

#8 
Senior Member
Albrecht vBoetticher
Join Date: Aug 2010
Location: Zürich, Swizerland
Posts: 218
Rep Power: 10 
Well I make a threshold for alpha1 (nonmixing phase) from 0 (or maybe 0.0001) to 0.5 and color it by alpha2, then I take a threshold of this threshold for alpha3 (full range from min to max) and set the representation to Wireframe and color it by alpha3


February 9, 2014, 15:00 

#9 
New Member
anonymous
Join Date: Jan 2012
Location: Canada
Posts: 24
Rep Power: 7 
Thanks for your reply. I appreciate it.
Mahyar 

June 17, 2014, 05:13 
about the solve of interMixingFoam

#10  
New Member
k zhang
Join Date: Jun 2012
Location: China
Posts: 9
Rep Power: 7 
these days i am working in this solver. openFoam 1.6ext. the solver interMixingFoam have no UEqn.H, so i try to look for it in the .dep file,
Quote:


June 17, 2014, 05:38 

#11 
Senior Member
Albrecht vBoetticher
Join Date: Aug 2010
Location: Zürich, Swizerland
Posts: 218
Rep Power: 10 
Hi Zhang,
yes it calls UEqn.H from interFoam, thats OK since one solves only one phaseaveraged NavierStokes equation neglecting drag between phases. I would like to know who maintains this solver. To my experience, it is not performing well in mass conservation or in respect to negative phase concentrations. Let me attatch my version of alphaEqns.H that gives higher priority to correct handling of the mixing fluid, shifting the weak parts to the air phase. This is for OF 2.2.x but a version for the newes OF exists. In my case, diffusion is not so important so I don't really care about the diffusive flux. (Sorry for not yet removing old comments from the code) 

June 17, 2014, 07:27 

#12 
New Member
k zhang
Join Date: Jun 2012
Location: China
Posts: 9
Rep Power: 7 
thank u for your reply, vBoetticher. i have known the reason why it can call the UEqn.H from the interFoam.
and from your replies above, we can see you have done a lot of job about the solver. the same to u , i have not know the guy who write the solver. from the origin of OF, i guess you can ask Hrvoje Jasak, maybe you can get the answer you need. good luck! skykzhang 

July 19, 2016, 05:43 

#13  
New Member
Join Date: May 2016
Posts: 15
Rep Power: 3 
Quote:
I think I'm a little late to this party, but I hope it is still relevant. I have been playing around with interMixingFoam for a while now and since I had problems with spontaneous creation of a third phase plus not a sharp interface between third  diffusive and firstnon diffusive phase (just like tutorial) I went digging into the source code. So to answer your question. The way it is written with alpha1 is ok. It is because you have a 3 phase system with condition alpha1+alpha2+alpha3=1. So if you rewrite your code line you would get Dc32*grad(alpha1)=Dc32*grad(1alpha2alpha3)=Dc32*grad(alpha2)Dc32*grad(alpha3). Now the trick is in the way the laplacian part of differential equation is defined: laplacian(Dc23+Dc32, alpha2). this can be written in terms of divergence: div((Dc23+Dc32)*grad(alpha2)). When you combine this with the divergence term in diff. eq. and subtract the equal parts you get (here written only the diffusion part): div(Dc23*grad(alpha3)  Dc32*grad(alpha2). Exactly what you wanted  two diffusion fluxes. Now if you would write down equations for alpha3 you would be left with div(Dc32*grad(alpha2)  Dc23*grad(alpha3)). Exactly the opposite fluxes. And now if you add the fluxes, the would sum to zero. Exactly as they should in the closed system. Sorry for the long response. Hope it helps. 

July 28, 2016, 03:51 

#14  
New Member
Join Date: May 2016
Posts: 15
Rep Power: 3 
Quote:
After some days spent in the actual code I was able to find a problem. The problem is with the way mules is written into the solver. The complete flux for phase 1 is constructed and then the unbounded part of the flux is bounded by mules (this is done by calculating lambda coefficients). All good. Then the second flux is constructed and the unbounded part is again limited by mules. But it uses the same lambda coefficients (it basically overwrites it). This results in the nonsharp interface for the phase 3. Solution: give second Mules different coefficients. Cheers 

September 7, 2016, 04:33 

#15 
New Member
Join Date: May 2016
Posts: 15
Rep Power: 3 

Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Problem setting with chtmultiregionFoam  Antonin  OpenFOAM  10  April 24, 2012 09:50 
Zero Diffusive flux  Subramani Sockalingam  FLUENT  1  May 27, 2009 10:36 
Zero Diffusive flux  Subramani Sockalingam  Main CFD Forum  0  January 19, 2008 14:02 
Help: diffusive flux BC at wall  Quarkz  Main CFD Forum  7  July 17, 2005 11:24 
Replace periodic by inletoutlet pair  lego  CFX  3  November 5, 2002 21:09 