# Setting a mass flow with periodic boundary conditions (3D)

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

April 4, 2022, 08:33
Setting a mass flow with periodic boundary conditions (3D)
#1
New Member

Felix Asch
Join Date: Dec 2021
Posts: 2
Rep Power: 0
Dear Foamers,

I have a problem with setting a certain mass flow rate when using periodic boundary conditions in a 3D domain. I have already read various threads with similar topics, however I have not been able to find a suitable solution yet, as my problem is a bit more specific.

Here some information about my problem:
I am trying to simulate the polymer melt (non-Newtonian) in a twin screw extruder using OpenFOAM (V9 or V2112). I have a geometry conform computational mesh with the following patches: inlet, outlet, both screws (screw_l and screw_r) and the housing_wall, and the fluid domain see attached picture.

For this I simulate a small section (half conveying element) and use periodic boundary conditions (cyclic) at the inlet and outlet.
The goal is to simulate this steady-state, incompressible, isothermal and laminar with simpleFoam at a constant screw speed of 60 rpm in order to calculate the dimensionless ratios according to Pawlowski.

For the velocity (0/U) boundary conditions, I use the cylindricalInletVelocity boundary condition on the screws to set the speed. For the adhesion condition, I use noSlip or fixedValue uniform (0 0 0) on the housing wall. Inlet and outlet are defined as cyclic.

Code:
```dimensions      [0 1 -1 0 0 0 0];

internalField   uniform (0 0 0);

boundaryField
{
INLET
{
type            cyclic;
}

OUTLET
{
type            cyclic;
}

SCREW_L
{
type            cylindricalInletVelocity;
value        uniform (0 0 0);
origin          (0.0167 0 0.01);
axis            (0 0 1);
axialVelocity   constant 0;
rpm             constant -60;
}

SCREW_R
{
type            cylindricalInletVelocity;
value          uniform (0 0 0);
origin          (-0.0167 0 0.01);
axis            (0 0 1);
axialVelocity   constant 0;
rpm             constant -60;
}

WALL
{
type            fixedValue;
value           uniform (0 0 0);
}
}```
For the pressure boundary conditions (0/p) it gets a bit tricky, because the boundary conditions for the inlet and outlet have to be cyclic as well. The remaining patches (Screw_l, Screw_r and Housing_wall) should be zeroGradient in my opinion. That means I don't have a pressureInlet/ pressureOutlet per se.
Code:
```dimensions      [0 2 -2 0 0 0 0];

internalField   uniform 0;

boundaryField
{
INLET
{
type            cyclic;
}

OUTLET
{
type            cyclic;
}

SCREW_L
{
}

SCREW_R
{
}

WALL
{
}
}```

The direction of flow is the z-axis. For a flow to occur, I want to specify a mass flow or a velocity component in the flow direction (v_z) over the cross-sectional area of my flow channel, so that a pressure gradient is formed and I get a pressure driven flow. Via fvOptions and (patch-)MeanVelocity (patch = outlet) with Ubar (0 0 v_z) a flow is formed and the solution converges.
Code:
```momentumSource
{
type           patchMeanVelocityForce;
active         on;

patchMeanVelocityForceCoeffs
{
selectionMode    all;
fields        (U);
patch        OUTLET;
Ubar        (0 0 v_z);
}
}```

My problem now is that the velocity component v_z in the fvOptions (Ubar) cannot be set smaller than 0.2 m/s, otherwise the simulation stops with the follwoing error message:

Code:
```FOAM FATAL ERROR:
Continuity error cannot be removed by adjusting the outflow.
Please check the velocity boundary conditions and/or run potentialFoam to initialise the outflow.
Total flux              : 9.75213e-05
Specified mass inflow   : 5.87128e-05
Specified mass outflow  : 5.87129e-05

From function bool Foam::adjustPhi(Foam::surfaceScalarField&, const volVectorField&, Foam::volScalarField&)

FOAM exiting```

I also tried to run potentialFoam to initialise a flow but that did not work as planned.
The problem now is, that i need flow velocities (v_z) smaller than 0.2 m/s in order to specify a certain mass flow rate from experimental values. Here I do not yet understand the direct connection between the size of the velocity component (v_z) in the fvOptions and the termination of the simulation.

Is there perhaps an alternative to the function meanVelocity in the fvOptions, with which I can directly set a pressure gradient or a mass flow rate?

I would be very grateful for any tips or hints.

Have a nice day

Felix
Attached Images
 Pic_geom_cfd-online.jpg (50.3 KB, 23 views)

 April 5, 2022, 15:07 #2 Senior Member     Niels Nielsen Join Date: Mar 2009 Location: NJ - Denmark Posts: 544 Rep Power: 25 Hi Since you are using cyclic would it be possible to use the cyclic fan BC? https://www.openfoam.com/documentati...-jump-fan.html I've used ot for pumps/fans, if you have some experimental values you can input your own "Pump/fan" curve. Some of the other coupled BC's could be an option. https://www.openfoam.com/documentati...onditions.html Maybe the mappedFlowRate How to properly use mappedFlowRate Flex likes this. __________________ Linnemann PS. I do not do personal support, so please post in the forums.

April 10, 2022, 13:46
#3
New Member

Felix Asch
Join Date: Dec 2021
Posts: 2
Rep Power: 0
Hi linneman, first of all big thanks for your tips.

I have spent the last few days trying different boundary conditions, hence the late reply. It seems that the mappedFlowRate BC is what I was looking for.

I have now mapped the FlowRate of the Outlet to the Inlet. Meaning, what flows out of the outlet flows right back into the inlet, giving me periodicity of the geometry as well (i hope i understood that right?).

The mass flows confirm this assumption (massflow_outlet at t=1 corresponds to massflow_inlet at t=2, and so on, see attached figure MassFlow_1) if the BC are chosen as follows for the Inlet and Outlet:
0/p:

Code:
```inlet_new
{
}

OUTLET
{
type        fixedValue;
value        uniform 0;
}```
0/U:

Code:
```inlet_new
{
type            mappedFlowRate;
phi             phi;
rho             rho;
neigPhi         phi;
value           uniform (0 0 0); // placeholder
}

OUTLET
{
}```
If we consider a non-periodic case, like a simple pipe flow, the boundary conditions for the inlet and outlet are defined as follows according to the literature:

-Inlet as VelocityInlet and Outlet as PressureOutlet.

This should be satisfied for the constraints shown above?!

First, I would like to calculate a mass flow m0 for the condition: Pressure gradient = 0 (over my entire geometry) This should correspond to the pure drag conveying capacity of the twin screw extruder.

The problem is that I have not yet found any suitable boundary conditions or settings, with which a simulation without pressure gradient (pressure gradient = 0) can be carried out.
Is there an option for this such as in the fvOptions or can this also be done by setting the boundary condition correctly?
With the BC shown above my results are smaller than the reference values by a factor of 10.

After i got m0, I would like to specify 10-90%*m0 (for example, at the inlet at t=0), which creates a pressure gradient that in turn affects the mass flow m that forms.

Surely this should be possible by specifying a starting value vz at my mappedFlowRate?

Code:
```inlet_new
{
type            mappedFlowRate;
phi             phi;
rho             rho;
neigPhi         phi;
value           uniform (0 0 0.02); // placeholder
}```
In a short test run, I was able to use this to set a mass flow at the inlet for t=0, see figure MassFlow_2. The Problem i see right now is that for t=1 the Massflow of the Outlet (value 0) is mapped to the Inlet which disturbs the flow that forms between inlet and outlet between t=0 and t=1.

Any Ideas how i can fix this?

Felix
Attached Images
 MassFlows_1.png (49.5 KB, 9 views) MassFlow_2.png (37.1 KB, 4 views)

 Tags fvoptions, mass flow rate, openfoam, periodic bc