CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Community Contributions (https://www.cfd-online.com/Forums/openfoam-community-contributions/)
-   -   [Other] Multi species mass transport library [update] (https://www.cfd-online.com/Forums/openfoam-community-contributions/103227-multi-species-mass-transport-library-update.html)

yhaomin2007 January 10, 2018 22:44

fixedFlux boundary condition uploaded ?
 
Hi, all Foamers,

I just want to follow up this thread.
Is the fixedFlux boundary condition available now ??

It is very important for the test cases in the paper.

Thank you.


Quote:

Originally Posted by openfoamstudents (Post 398765)
Dear novyno, dear community,


Great work and thanks for this library!

In your publication in Computer Physics Communications, you mention a generic boundary condition for species mass flux, called fixedFlux.
Could you please post it here? I would like to use it for part of my bachelor thesis on silicium wafer processing.

I am trying to implement a simple surface reaction boundary with a sticking coefficient 0..1 (only valid for Ficks law, similar to the boundary fixedGradient):

// Get Species name
const word specie_(dimensionedInternalField().name());

// Get p, T, rho, moleFrac, massFrac, Alpha,diffAlpha, molarWeight
const fvPatchField<scalar>& p = patch().lookupPatchField<volScalarField, scalar>("p");
const fvPatchField<scalar>& T = patch().lookupPatchField<volScalarField, scalar>("T");
const fvPatchField<scalar>& rho = patch().lookupPatchField<volScalarField, scalar>("rho");
// const fvPatchField<scalar>& massFrac = patch().lookupPatchField<volScalarField, scalar>(specie_); // Mass fraction
const fvPatchField<scalar>& moleFrac = patch().lookupPatchField<volScalarField, scalar>("x_"+specie_); // Mole fraction
const fvPatchField<scalar>& diffAlpha = patch().lookupPatchField<volScalarField, scalar>("D_"+specie_); // Diffusion constant
const scalar molarWeight(molecularWeights[specie_]); // kg/mol

// Constants
const scalar R(8.3144621); // J/(K*mol) = kg^2*m^2*s^-2*kgmol^-1
const scalar twoPi(6.283185307179586);

gradient() = -stickingCoeff_*p*moleFrac / (sqrt(twoPi*molarWeight*R*T) * (rho*diffAlpha));

Unfortunately, in every second iteration, this formula produces a gradient only containing zeros "gradient() 25{-0}" which probably means, moleFrac is exactly zero (unphysical I think).
Can somebody help me out please?

Thanks a lot,
OpenFoamStudent


Gaozw June 29, 2018 23:27

Quote:

Originally Posted by niklas (Post 366649)
Im in the process of updating your library to 2.1.x and I have a small question.

For instance, the correct routine in Fick.C show that there is a slight chance of
making an easy mistake, (without knowing probably)

the inert species mass fraction is grabbed from thermo like this.
// Calculate inert species
volScalarField& yInert = thermo_.composition().Y()[inertIndex_];

which is set to 1 - sum of the first N-1 species, like this
yInert = 1 - yt;

since yt is just calculated in the loop
forAll(this->D_, i)

where D is
D_.setSize(species().size()-1);

and it gets the name
"D_" + species()[i],

so D is 1 less than the number of species

Now...if the inert specie is not placed in the last position in the species list,
the inertIndex will point to the wrong specie and it will use the inertspecie to calculate yt...
so basically everything will be a mess.

why dont you do it like in the YEqn.H where you check the name of the species to see if its the same as
the inert specie name
if (Y[i].name() != inertSpecie)
or
if (i != inertIndex_)

to prevent people from making this mistake and allow the inert specie to be placed anywhere in the species list.

just a thought,
N

Hi, everyone!
I am new here and trying to modfity this code. Nikilas provided a good suggestion and I noticed that some codes are needed to be modified to ensure the consistence.

In file multiSpeciesTransportModel.C and multiSpeciesTransportModel.H:

I added a private member inertSpecie_ , which is initialized as

inertSpecie_(thermo.lookup("inertSpecie")),

In the function correct() in file Fick.C, a slight change is made:

[I] volScalarField yt = 0.0*thermo_.composition().Y(0);
surfaceScalarField nt = turbulence_.phi();
label inertIndex = -1;

forAll(species(), i)
{
volScalarField& yi = thermo_.composition().Y(i);
surfaceScalarField& ni = n_[i];

if (yi.name() != inertSpecie_)
{
tmp<fv::convectionScheme<scalar> > mvConvection
(
fv::convectionScheme<scalar>::New
(
mesh_,
fields,
turbulence_.phi(),
mesh_.divScheme("div(phi,Yi_h)")
)
);

if (mesh_.relaxField("Yi"))//Mohsen
{
yi.storePrevIter();
}

tmp<fvScalarMatrix> yEqn
(
fvm::ddt(thermo_.rho(), yi)
// + fvm::div(turbulence_.phi(), yi, "div(phi,Yi_h)")
+ mvConvection->fvmDiv(turbulence_.phi(), yi)
- fvm::laplacian(D_[i],yi, "laplacian(D,Yi)")
==
Sy_
);

eqnResidual = solve(yEqn() , mesh_.solver("Yi")).initialResidual();
maxResidual = max(eqnResidual, maxResidual);

if (mesh_.relaxField("Yi"))//Mohsen
{
yi.relax(mesh_.fieldRelaxationFactor("Yi"));//Mohsen
}

yi.max(0.0);
// yi.min(1.0);

ni = yEqn().flux();

nt -= ni;
yt += yi;
}
else
{
inertIndex = i;
}
}

// Calculate inert species
volScalarField& yInert = thermo_.composition().Y()[inertIndex];
yInert = 1 - yt;
forAll(yInert.boundaryField(), boundaryI)
{
forAll(yInert.boundaryField()[boundaryI], faceI)
{
yInert.boundaryField()[boundaryI][faceI] = 1- yt.boundaryField()[boundaryI][faceI];
}
}
yInert.max(0.0);
n_[inertIndex] = nt;

updateMolarFractions();

return maxResidual;


Note that, the inertIndex is not the same inertIndex_ in multiSpeciesTransportModel.H

I hope this will be helpful.
:):):)

jherb February 17, 2019 18:43

Update of library to OpenFOAM 6
 
1 Attachment(s)
Hello,


I have created a non-complete update of the library to OpenFOAM-6.



Main changes:

- Handling of references, which are now const
- The definition of turbulence.phi() seems to have changed: It is now a volume flux, but a mass flux is need, so that has been added as additional internal variable
- Chemistry has changed so much, that I have (hopefully temporarily) disabled it.

It compiles and runs (TM). I just tested it with the testCase given in the original library without chemistry.



Any comments/improvements are welcome.

jherb February 18, 2019 17:14

2 Attachment(s)
Updates:


- To use transport const, thermo hConst change the commented lines in multiSpeciesTransportModels.C
from
Code:

// makeMultiSpeciesTransportModel(Fick, gasThermoPhysics);
 ...

to


Code:

makeMultiSpeciesTransportModel(Fick, constGasHThermoPhysics);
 ...

- If set up a test case, based on the one provided with the library, to a volume with all walls (and empty front and back) with just two different gases setup by setFields: in the top half only H2O, in the bottom half only N2. After start of the simulation, the two gases mix and the temperature starts to diverge from the starting 300 K more and more per time step.


https://www.cfd-online.com/Forums/at...1&d=1550527618



To start the attached test case, issue the following commands:
Code:

blockMesh
setFields
modifiedReactingFoam

So I guess, this is not a physical result. The picture above was created using OpenFOAM 2.3.1. The version for OpenFOAM 6 produces results looking similar, but the temperature range is even larger (from 260 K to 326 K) for t = 0.5 s


Quote:

Originally Posted by jherb (Post 725034)
Hello,


I have created a non-complete update of the library to OpenFOAM-6.



Main changes:

- Handling of references, which are now const
- The definition of turbulence.phi() seems to have changed: It is now a volume flux, but a mass flux is need, so that has been added as additional internal variable
- Chemistry has changed so much, that I have (hopefully temporarily) disabled it.

It compiles and runs (TM). I just tested it with the testCase given in the original library without chemistry.



Any comments/improvements are welcome.


nivethanakumar April 26, 2019 09:39

hello mhsn, how did u solve that error /usr/bin/ld: cannot find -llduSolvers.

sufjanst May 14, 2019 10:25

Hello everyone,


thank you so much for sharing the library! This is very helpful!


One thing I didn't understand is:

There are models to calculate the diffusion-coefficient. What happens when I want to use Schmidt-diffusion for example? The diffusion-coefficient is calculated with mu, density and the schmidt-number.

Are all models for calculating the Diffusion-coefficient like champan-enskog disabled for this model? Or are these different diffusion-coefficients?


Thank you very much!

jherb May 19, 2019 17:16

You set the diffusion model in the file constant/transportProperties, e.g.
Code:

multispeciesTransportModel SchmidtNumber<constGasHThermoPhysics>;
This means, that the diffusion is calculated using a Schmidt Number. In the correspoding file multiSpeciesMassTransportLibrary/multiSpeciesTransportModels/SchmidtNumber/SchmidtNumber.C it the number is read (also from transportProperties):
Code:

    Sc_(IOdictionary::lookupOrDefault<scalar>("Sc", 1))
It is used in same file:
Code:

            this->D_[i] = this->turbulence_.muEff() / Sc_;
and then this diffusion constant is used to calculate the diffusion of the species fractions.


If you use another mode, e.g. Fick, then you have to set
Code:

multispeciesTransportModelFick<gasHThermoPhysics>;
Then the diffusion constants for the different species are calculated based on the molar fractions.



Have a look at the README.txt file in the archive and the pdf somewhere in this thread.

Thamali August 23, 2019 09:53

Hi Jherb and all,

Thanks a lot for all who contributed to this library.
If you have updated the solver for OpenFOAM6 with chemistry, I would be grateful to have it.
Otherwise I will try do it on my own.

Thanks in advance.
Thamali

jherb August 25, 2019 15:06

You can find the current state of the port at https://github.com/jmozmoz/OFdevelopments


There are still bugs in treating the passive species. But based on a talk "Development and verification of a multi-species gas transport solver" by Vijaya Kumar G et al., at the OpenFOAM Workshop at Duisburg the problems with temperature differences due to diffusion should be solve.

PRATBHARAT March 24, 2021 01:44

Tritium transport equation
 
Dear Valerio,

First of all, I would like to thank you for this updated library. I want to use this library for tritium transport using the Champan-Enskog model for diffusion coefficient and Fick’s model for flux modelling in a porous media domain. I am not interested in reaction mechanisms for now. As per my understanding to use it on some membrane domain, I should modify the solver and change the value of porosity and tortuosity in the respective libraries. Can I use this solver on the membrane without including the flux modelling? The reason why I am asking this question is because the solubility or entrapment effects have not been considered. If the answer is not, what modifications will be required?

Also, I have a little confusion about the reaction mechanism of the solver. As I understand by going through solver, your solver can only solve the combustion reactions? Correct me if I'm wrong? So, if I want to model the co-permeation of two molecules H2, D2 through membrane, a reaction like H2+D2-> 2HD (where H is hydrogen, D is deuterium) can be modeled for the same, how should I begin to include it in the same solver?

ejaz8894 August 13, 2021 12:43

I am thanking you all for the contributions you have made. I'm currently working on icoReactingMultiphaseInterFoam solver on OpenFOAM - v2012 in order to model liquid evaporation which is using VOF (volume of fluid) based interface capturing method. I figured out that, the solver doesn't have any mass diffusivity in species transport equation. I need to modify the species transport equation for that. Can I install this "Multispecies Mass Transport Library" in OpenFOAM - v2012 & use the library in the icoReactingMultiphaseInterFoam solver? If not, what modifications do I need to make? I will really appreciate your help & suggestions. Thank you in advance!

Sk Hossen Ali November 9, 2021 23:37

Please Update the Library for New versions of OpenFOAM
 
Dear Foamers,

Thanks a lot for all the efforts till now, this is to bring to your kind attention that the libraries that you provided is not compatible with new versions of openfoam.

Please guide me on how to use the library if it is possible to run it in any currently supported versions of openfoam, or please try update it for the current versions of openfoam.

I have tried to install openfoam-2.3.0 in the ubuntu20.04LTS but did not compilled correctly. While I was trying to install Ubuntu13 it said it is no longer supported.

Thanks in advance
Sk Hossen Ali


All times are GMT -4. The time now is 02:23.