CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   mass flow split BC (http://www.cfd-online.com/Forums/openfoam-solving/109685-mass-flow-split-bc.html)

kpax November 23, 2012 11:52

mass flow split BC
 
Fellow FOAMers,

i am currently simulating the flow in a tube with one inlet and two outlets. In Fluent, there is a mass flow split BC (http://hpce.iitm.ac.in/website/Manua...ug/node246.htm):
if you set, e.g., 0.5 for both outlets, the inlet flow will be split to 50% for each outlet (no matter what the geometry looks like).

Does something like that exist in OF? I couldn't find anything... maybe it could be built from flowRateInletVelocity?


Any help or advice is appreciated.

kpax

gschaider November 23, 2012 14:02

Quote:

Originally Posted by kpax (Post 393861)
Fellow FOAMers,

i am currently simulating the flow in a tube with one inlet and two outlets. In Fluent, there is a mass flow split BC (http://hpce.iitm.ac.in/website/Manua...ug/node246.htm):
if you set, e.g., 0.5 for both outlets, the inlet flow will be split to 50% for each outlet (no matter what the geometry looks like).

Does something like that exist in OF? I couldn't find anything... maybe it could be built from flowRateInletVelocity?


Any help or advice is appreciated.

I don't think there is something built in (but I'm willing to be taught differently).
Such a boundary condition (or something more flexible;) ) can be constructed with groovyBC from the swak4Foam-suite which allows boundary conditions to access the values on other patches

kpax November 26, 2012 07:59

ok...

does someone know then how the mass flow split BC is implemented in FLUENT?

I would think that the easiest way would be to adjust the pressure at the outlets in a way that ensure the prescribed mass flow split, but i'm not sure how that could be done.
Or maybe modify the outlet velocities? That seems difficult to me because they can have arbitrary profiles..

vainilreb November 27, 2012 07:52

Well there is the mass flow BC for the inlet which calculates the velocity by the mass flow and the density. Maybe you could simply take the formula of this BC to calculate the flux over the inlet and then simply set your outlet BC with the mass flow BC, but half of the inlet mass flow.

Does this help you?

kpax November 27, 2012 09:25

well, that was my first idea too, but as far as i understand flowRateInletVelocity, it sets a uniform velocity profile at the patch (be it outlet or inlet). at the outlet, however, i certainly have a developed velocity profile, so using this BC would not give a correct solution.

any other ideas?

vainilreb November 27, 2012 09:39

If you know your inlet mass flow, you could calculate the outlet mass flow for each pipe and assume the velocity profile to be a fully developed turbulent or laminar profile... Afaik this should be implementable using Swak4Foam or groovyBC, you just have to calculate the radial gradient of the velocity.

But then this would influence the flow behaviour upstream the outlets, too. :/

Or maybe you could specify a pressure at the outlets so that the flow departs itself in two equivalent mass flows? I think knowing the real setup you're trying to simulate would help finding the best solution!

kpax November 27, 2012 09:49

hey vainilreb, thx for the swift answer!


Quote:

Originally Posted by vainilreb (Post 394401)
If you know your inlet mass flow, you could calculate the outlet mass flow for each pipe and assume the velocity profile to be a fully developed turbulent or laminar profile... Afaik this should be implementable using Swak4Foam or groovyBC, you just have to calculate the radial gradient of the velocity.

the velocity profiles at the oulets are not fully developed (i.e., parabolic), because the geometry right before the outlets is curved. so assuming anything about the velocity profile will probably give false results, imo.


Quote:

Originally Posted by vainilreb (Post 394401)
Or maybe you could specify a pressure at the outlets so that the flow departs itself in two equivalent mass flows? I think knowing the real setup you're trying to simulate would help finding the best solution!

how could this pressure be set? the simulation is transient, with a varying velocity inlet profile, so the pressure values that give the correct flow split would have to be calculated for each time step..
i could create a new solver that iteratively calculates these pressure values for every time step by applying PISO repeatedly and adjusting the p values. but i think that would be quite time-consuming, and since a simple mass flow split BC exists in fluent, i thought there must be an easier way?

vainilreb November 27, 2012 10:07

I would have made a first try by setting the pressure as fixedValue, but even then it's a tough task finding the right pressure level. I would have tried keeping pi*rē*p equal for both outlets. You could set the pressure at the smaller outlet equal to ambient pressure and calculate the pressure at the larger outlet from this value. But I can't say if it will work.

Can you give more information on flow past the outlets? If you get two equal mass flows in reality, this must result from something?

Physically you must realize an equal pressure loss from inlet to outlet1 and from inlet to outlet2... Or setup a pressure acting against the flow direction, which equals the difference in pressure loss.

gschaider November 27, 2012 10:56

Quote:

Originally Posted by vainilreb (Post 394373)
Well there is the mass flow BC for the inlet which calculates the velocity by the mass flow and the density. Maybe you could simply take the formula of this BC to calculate the flux over the inlet and then simply set your outlet BC with the mass flow BC, but half of the inlet mass flow.

But resist the temptation to fix the mass flux on the other outlet too. Fixing the velocity on all boundaries usual ends in tears (violated mass conservation)

vainilreb November 27, 2012 11:02

But it's be possible to fix all three pressure levels to get the desired mass flow without bursting into tears, does it?

gschaider November 27, 2012 13:43

Quote:

Originally Posted by vainilreb (Post 394432)
But it's be possible to fix all three pressure levels to get the desired mass flow without bursting into tears, does it?

Well. If you know the pressure that is necessary to get a specific mass flow then the question is: why do you want to do CFD in the first place. Because it seems that your system is simple enough to be treated with a Bernoulli equation

vainilreb November 29, 2012 04:34

Sounds reasonable... But I'm afraid it won't help kpax to list all the things that will NOT work? :rolleyes:

gschaider November 29, 2012 05:51

Quote:

Originally Posted by vainilreb (Post 394816)
Sounds reasonable... But I'm afraid it won't help kpax to list all the things that will NOT work? :rolleyes:

OK. To summarize. What I'd do (it would need a bit of playing):

- inlet: fixed velocity, p zeroGradient
- outlet1: fixed p. U inletOutlet
- outlet2: p zeroGradient. U mass flow set to x% of inlet

outlet2 for a first test could be a simple fixedValue with a calculated value. Later a groovyBC that gets the MF from the inlet. If you want a developed profile at the outlet you might use groovyBC to rescale the velocity on the outlet, but that might be a bit tricky: a) during startup b) if you have backflow. Underrelaxation might be your friend

kpax November 29, 2012 11:30

thx guys, I'll think I will try to implement both your idea and a pressure-adjusting solver - we'll see what works best! :>

rudolf.hellmuth September 9, 2016 06:45

I've got a slightly different, which has worked very well.

Since I knew the inlet flow rate (Q_in=40e-6 m^3 s^-1), I imposed outlet flow rates (70% / 30%), and left the velocity field as zeroGradient at the inlet. Pressure field uniform 0 at the inlet, and zeroGradient at the outlets.

The BC dictionaries follow below:

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  v1606+                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.com                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      volVectorField;
    object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 1 -1 0 0 0 0];

internalField  uniform (0 0 0);

boundaryField
{
    inlet
    {
        type            zeroGradient;
    }

    outlet1
    {
        type        flowRateInletVelocity;
        volumetricFlowRate  -28e-6;
        value      uniform (0 0 0); // placeholder
    }

    outlet2
    {
        type        flowRateInletVelocity;
        volumetricFlowRate  -12e-6;
        value      uniform (0 0 0); // placeholder
    }
    defaultFaces
    {
        type            noSlip;
    }
}

// ************************************************************************* //

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  v1606+                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.com                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      volScalarField;
    object      p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 2 -2 0 0 0 0];

internalField  uniform 0;

boundaryField
{
    inlet
    {
        type        fixedValue;   
        value      uniform 0;
    }

    outlet1
    {
        type            zeroGradient;
    }

    outlet2
    {
        type            zeroGradient;
    }

    defaultFaces
    {
        type            zeroGradient;
    }
}

// ************************************************************************* //

Cheers,
Rudolf

rudolf.hellmuth September 12, 2016 09:13

1 Attachment(s)
If you really want to impose the inlet velocity BC, you can try this coded BC for all outlets but one.

U:
Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  v1606+                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.com                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      volVectorField;
    object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 1 -1 0 0 0 0];

internalField  uniform (0 0 0);

boundaryField
{
    inlet
    {
        type            fixedValue;
        value          uniform (0.1 0 0);
    }

    outlet1
    {
        type            codedFixedValue;
        value          uniform (1 0 0);
        redirectType    flowSplit;
       
        code
        #{
            scalar flowRatio = 0.7;
            const word refPatchName = "inlet";
           
            //----------------------------------------------------------------//
            const scalar& pi = constant::mathematical::pi;
           
            const fvPatchVectorField& thisBF = *this;
            scalar thisPatchArea = gSum(thisBF.patch().magSf());
            vector nf = gSum(thisBF.patch().magSf()*thisBF.patch().nf())
                        /thisPatchArea;
           
            const volVectorField& U = thisBF.db().lookupObject<volVectorField>("U");
            const surfaceScalarField& phi = thisBF.db().lookupObject<surfaceScalarField>("phi");
           
            const label refPatchLabel = U.mesh().boundaryMesh().findPatchID(refPatchName);
            const fvPatchVectorField& refBF = U.boundaryField()[refPatchLabel];
            const fvsPatchScalarField& refBflux = phi.boundaryField()[refPatchLabel];
           
            scalar refFlowRate = gSum(refBflux);

            // Info << nl << "Flow rate at " << refPatchName
                // << ": " << refFlowRate << endl;

            operator==(-nf*flowRatio*refFlowRate/thisPatchArea);
        #};
    }

    outlet2
    {
        type    zeroGradient;
    }
    defaultFaces
    {
        type            noSlip;
    }
}

// ************************************************************************* //

p:
Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  v1606+                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.com                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      volScalarField;
    object      p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 2 -2 0 0 0 0];

internalField  uniform 0;

boundaryField
{
    inlet
    {
        type            zeroGradient;
    }

    outlet1
    {
        type            zeroGradient;
    }

    outlet2
    {
        type            fixedValue;   
        value          uniform 0;
    }

    defaultFaces
    {
        type            zeroGradient;
    }
}

// ************************************************************************* //


It is a plug flow on outlet1, but it is developed flow on outlet2. I am not sure this is how Star-CCM+ does it, because I've heard it has plug flow in both splitted BCs, which I find funny because of the reasons Bernhard Gschaider has pointed out. Probably there is some black magic behind Star-CCM+ to keep the continuity equation right.

Cheers,
Rudolf

rudolf.hellmuth September 19, 2016 06:37

I wasn't happy with the fixed constant pressure field at outlet1, because it looked very artificial to have both the pressure at the inlet and outlet2 changing depending on the split ratio. Therefore, against gschaider advices, I set all pressure BCs as zeroGradient, and I imposed the flow rates on both outlets. Of course, I had to set pRefCell=0 and pRefValue=0 in the fvSolution dictionary.

Surprisingly for me, the continuity residuals didn't explode, even when I oscillated the flow split ratio. I verified the flow rates in Paraview, which resulted in Phi.inlet = Phi.outlet1 + Phi.outlet2 for all times. Pressure at the inlet is constant, and it oscillates freely between outlets.

It seems that this is the way StarCCM+ does that, according to what I've seen from simulations using the flow split BC in StarCCM+. In Star, the split BCs have constant velocity at the outlet, and pressure is not constraint.

The OpenFOAM BC dictionaries follow:

p:
Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  v1606+                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.com                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      volScalarField;
    object      p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 2 -2 0 0 0 0];

internalField  uniform 0;

boundaryField
{
    inlet
    {
        type            zeroGradient;
    }

    outlet1
    {
        type            zeroGradient;
    }

    outlet2
    {
        type            zeroGradient;
    }

    defaultFaces
    {
        type            zeroGradient;
    }
}

U:
Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  v1606+                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.com                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      volVectorField;
    object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //


dimensions      [0 1 -1 0 0 0 0];

internalField  uniform (0 0 0);

boundaryField
{
    inlet
    {
        type            fixedValue;
        value          uniform (0.1 0 0);
    }
   
    outlet1
    {
        type            codedFixedValue;
        value          uniform (1 0 0);
        redirectType    flowSplit1;
       
        code
        #{
            scalar flowRatio = 1;
            const word refPatchName = "inlet";
           
            // ----------------------------------------------------------------//
            const scalar& pi = constant::mathematical::pi;
           
            const fvPatchVectorField& thisBF = *this;
            scalar thisPatchArea = gSum(thisBF.patch().magSf());
            vector nf = gSum(thisBF.patch().magSf()*thisBF.patch().nf())
                        /thisPatchArea;
           
            const volVectorField& U = thisBF.db().lookupObject<volVectorField>("U");
            const surfaceScalarField& phi = thisBF.db().lookupObject<surfaceScalarField>("phi");
           
            const label refPatchLabel = U.mesh().boundaryMesh().findPatchID(refPatchName);
            const fvPatchVectorField& refBF = U.boundaryField()[refPatchLabel];
            const fvsPatchScalarField& refBFlux = phi.boundaryField()[refPatchLabel];
           
            scalar refFlowRate = gSum(refBFlux);
               
            scalar t = this->db().time().value();

            operator==
            (
                -nf*flowRatio*refFlowRate/thisPatchArea
                *0.5*(sin(2*pi*t + pi) + 1.0)
            );
        #};
    }

    outlet2
    {
        type            codedFixedValue;
        value          uniform (1 0 0);
        redirectType    flowSplit2;
       
        code
        #{
            scalar flowRatio = 1;
            const word refPatchName = "inlet";
           
            // ----------------------------------------------------------------//
            const scalar& pi = constant::mathematical::pi;
           
            const fvPatchVectorField& thisBF = *this;
            scalar thisPatchArea = gSum(thisBF.patch().magSf());
            vector nf = gSum(thisBF.patch().magSf()*thisBF.patch().nf())
                        /thisPatchArea;
           
            const volVectorField& U = thisBF.db().lookupObject<volVectorField>("U");
            const surfaceScalarField& phi = thisBF.db().lookupObject<surfaceScalarField>("phi");
           
            const label refPatchLabel = U.mesh().boundaryMesh().findPatchID(refPatchName);
            const fvPatchVectorField& refBF = U.boundaryField()[refPatchLabel];
            const fvsPatchScalarField& refBFlux = phi.boundaryField()[refPatchLabel];
           
            scalar refFlowRate = gSum(refBFlux);
               
            scalar t = this->db().time().value();

            operator==
            (
                -nf*flowRatio*refFlowRate/thisPatchArea
                *0.5*(sin(2*pi*t) + 1.0)
            );
        #};
    }
    defaultFaces
    {
        type            noSlip;
    }
}

Note that the split oscillations have a phase shift = pi rad, between outlet1 and outlet2.

blockMeshDict:
Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  v1606+                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.com                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

//          outlet1
//            +-+
//            | |
//            | |
//            | |
//            | |
// +-----------+ |
// |inlet        |
// +-----------+ |
//            | |
//            | |
//            | |
//            | |
//            +-+
//          outlet2

convertToMeters 1;

vertices
(
    (0.0  -0.01 0)  //0
    (0.2  -0.01 0)
    (0.2  0.01 0)  //2
    (0.0  0.01 0)

    (0.22 -0.01 0)  //4
    (0.22  0.01 0)

    (0.2  -0.21 0)  //6
    (0.22 -0.21 0)

    (0.2  0.21 0)  //8
    (0.22  0.21 0)

    // Z
    (0.0  -0.01 0.02)  //0
    (0.2  -0.01 0.02)
    (0.2  0.01 0.02)  //2
    (0.0  0.01 0.02)

    (0.22 -0.01 0.02)  //4
    (0.22  0.01 0.02)

    (0.2  -0.21 0.02)  //6
    (0.22 -0.21 0.02)

    (0.2  0.21 0.02)  //8
    (0.22  0.21 0.02)

);

blocks
(
    // inlet block
    hex (0 1 2 3  10 11 12 13) (100 10 10) simpleGrading (1 1 1)

    // central block
    hex (1 4 5 2  11 14 15 12) (10 10 10) simpleGrading (1 1 1)

    // bottom block
    hex (6 7 4 1  16 17 14 11) (10 100 10) simpleGrading (1 1 1)

    // top block
    hex (2 5 9 8  12 15 19 18) (10 100 10) simpleGrading (1 1 1)
);

edges
(
);

boundary
(
    inlet
    {
        type patch;
        faces
        (
            (0 10 13 3)
        );
    }

    outlet1
    {
        type patch;
        faces
        (
            (6 7 17 16)
        );
    }

    outlet2
    {
        type patch;
        faces
        (
            (8 18 19 9)
        );
    }

    defaultFaces
    {
        type wall;
        faces ();
    }
);

mergePatchPairs
(
);

// ************************************************************************* //

Watch the video.

Best regards,
Rudolf


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