|
[Sponsors] |
October 5, 2021, 06:33 |
Transport of solutes
|
#1 |
New Member
José Manuel Olmos Martínez
Join Date: Mar 2021
Posts: 8
Rep Power: 5 |
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 |
|
October 5, 2021, 17:45 |
|
#2 |
Senior Member
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,754
Rep Power: 66 |
What is your IC for U?
It's a transient simulation, it will take time for the solute to to flow through the pipe. |
|
October 6, 2021, 04:58 |
|
#3 |
New Member
José Manuel Olmos Martínez
Join Date: Mar 2021
Posts: 8
Rep Power: 5 |
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! |
|
October 18, 2021, 11:44 |
|
#4 |
New Member
José Manuel Olmos Martínez
Join Date: Mar 2021
Posts: 8
Rep Power: 5 |
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:imensionedField<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 |
|
October 18, 2021, 11:51 |
|
#5 |
Senior Member
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,754
Rep Power: 66 |
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.
|
|
October 18, 2021, 12:26 |
|
#6 |
New Member
José Manuel Olmos Martínez
Join Date: Mar 2021
Posts: 8
Rep Power: 5 |
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!! |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How can temperature e treated as a passive scalar be used in transport equation? | granzer | OpenFOAM Running, Solving & CFD | 3 | June 6, 2021 17:35 |
[swak4Foam] swakExpression not writing to log | alexfells | OpenFOAM Community Contributions | 3 | March 16, 2020 19:19 |
thermo and transport data in fluent database | Weiqiang Liu | FLUENT | 3 | January 31, 2019 20:23 |
Solving User-defined Scalar Transport Equation properly | meepokman | Fluent UDF and Scheme Programming | 0 | July 10, 2018 08:57 |
Re: Can I simulate sediment transport with FLUENT | li li | FLUENT | 0 | October 21, 2003 21:42 |