CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   Transport of solutes (https://www.cfd-online.com/Forums/main/238814-transport-solutes.html)

Jose Manuel Olmos October 5, 2021 05:33

Transport of solutes
 
Hello everyone,

I'm trying to simulate the flow of a solution (containing a solute) inside a pipe. I'm using the icoFoam solver with some modifications on the code for including the transport of the solute (just after calculating the distribution of velocities):

fvVectorMatrix UEqn
(
fvm::ddt(U)
+ fvm::div(phi, U)
- fvm::laplacian(nu, U)
);

if (piso.momentumPredictor())
{
solve(UEqn == -fvc::grad(p));
}

// --- PISO loop
while (piso.correct())
{
volScalarField rAU(1.0/UEqn.A());
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p));
surfaceScalarField phiHbyA
(
"phiHbyA",
fvc::flux(HbyA)
+ fvc::interpolate(rAU)*fvc::ddtCorr(U, phi)
);
adjustPhi(phiHbyA, U, p);
// Update the pressure BCs to ensure flux consistency
constrainPressure(p, U, phiHbyA, rAU);

// Non-orthogonal pressure corrector loop
while (piso.correctNonOrthogonal())
{
// Pressure corrector
fvScalarMatrix pEqn
(
fvm::laplacian(rAU, p) == fvc::div(phiHbyA)
);
pEqn.setReference(pRefCell, pRefValue);
pEqn.solve();

if (piso.finalNonOrthogonalIter())
{
phi = phiHbyA - pEqn.flux();
}
}
#include "continuityErrs.H"
U = HbyA - rAU*fvc::grad(p);
U.correctBoundaryConditions();
}
// --- Mass transport

dictionary soluteSolveDict = mesh.solutionDict().subDict("solvers").subDict("C_ solutes");
forAll(soluteNameList, i)
{
fvScalarMatrix MassTransport
(
fvm::ddt(soluteList[i]) + fvm::div(phi, soluteList[i], "div(phi,C_solutes)")
- fvm::laplacian(soluteList[i].D(), soluteList[i], "laplacian(D,C_solutes)")
);
MassTransport.solve(soluteSolveDict);
}

// --- Write run time

The solver is running and the distribution of concentrations is calculated. However, it only takes part from the inlet of the pipe.. I mean, the transport of the momentum and the concentration of the solute is not "synchronized. You can see this problem in the following images, that show the distribution of velocities and concentrations at the same time:

https://ibb.co/bQLCf2v
https://ibb.co/7XSj25K

Before running the simulation, I created a new field ("concentration") with the following boundary conditions:

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

internalField uniform 0;

boundaryField
{
CAD_inlet
{
type fixedValue;
value uniform 0.01; //this is the concentration of the solute at
//the inlet
}

CAD_outlet
{
type zeroGradient;
}

CAD_wall
{
type zeroGradient;
}
}

I don't understand why the solution reach the outlet of the pipe (the velocity is non-null at this zone) but the solute is only at the first of the pipe. I would be very grateful if anyone could tell me if I'm taking any mistake on the modification of the solver or in the establishment of the boundary conditions.

Thanks in advance,
Jose Manuel

LuckyTran October 5, 2021 16:45

What is your IC for U?


It's a transient simulation, it will take time for the solute to to flow through the pipe.

Jose Manuel Olmos October 6, 2021 03:58

Hi,

This is the file for the boundary conditions of U:

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

internalField uniform (0 0 0);

boundaryField
{
CAD_wall
{
type noSlip;
}

CAD_inlet
{
type fixedValue;
value uniform (-0.00102 -0.00177 0);
}

CAD_outlet
{
type zeroGradient;
}
}

I expected that the solute reached the end of the pipe at the same time than the solvent (i.e., non-null velocity at the end of the pipe), since transport is due to diffusion but also to convection. But maybe you're right and I only have to extend the time of simulation. First, I'm going to modify the solver for including only diffusion (so the distance covered by the solute should be lower).

Thanks for your reply!

Jose Manuel Olmos October 18, 2021 10:44

Hello everyone,

Finally, I could perform the simulation correctly and the solute reaches the end of the pipe. Like Lucky Tran suggested,I only had to extend the duration of the simulation several seconds.



However, I got another problem after re-modifying the solver for including a chemical reaction affecting to the concentration of the solute.

The new code is practically the same, only with an additional term for resolving the differential equation for the concentration (highlighted in bold):

// --- Mass transport

dictionary soluteSolveDict = mesh.solutionDict().subDict("solvers").subDict("C_ solutes");
forAll(soluteNameList, i)
{
fvScalarMatrix MassTransport
(
fvm::ddt(soluteList[i]) + fvm::div(phi, soluteList[i], "div(phi,C_solutes)")
- fvm::laplacian(soluteList[i].D(), soluteList[i], "laplacian(D,C_solutes)")==
k_rate * soluteList[i] );
MassTransport.solve(soluteSolveDict);
}

I could re-build the solver, but I have the next error when trying to execute it (tetracycline is the name of the solute):


FOAM FATAL ERROR:

[C_tetracycline[0 -3 -1 0 1 0 0] ] == [C_tetracycline[0 -3 0 0 1 0 0] ]

From function void Foam::checkMethod(const Foam::fvMatrix<Type>&, const Foam::DimensionedField<Type, Foam::volMesh>&, const char*) [with Type = double]
in file /opt/openfoam8/src/finiteVolume/lnInclude/fvMatrix.C at line 1277.




It seems that there is a disagreement between the units of the concentration when trying to solve the new differential equation of the system. I can't figure out this conflict....any idea?


Thanks in advance,
Jose Manuel

LuckyTran October 18, 2021 10:51

The RHS is missing units of 1/time. I'm guessing it's in k_rate. Is k_rate a dimensioned scalar or just a simple number? There could still be other errors later but here FOAM is doing a simple check for units and here they are not matching.

Jose Manuel Olmos October 18, 2021 11:26

Right, the problem was in the units of k_rate. I defined it in units of s-1 and now the code is running!!


Thank you so much Lucky Tran!!


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