CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Community Contributions

[Other] Multi species mass transport library [update]

Register Blogs Community New Posts Updated Threads Search

Like Tree38Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 8, 2013, 20:33
Default Species Conservation at Solver Level
  #41
Member
 
Chris
Join Date: Aug 2012
Location: Calgary, Alberta, Canada
Posts: 77
Rep Power: 14
ChrisA is on a distinguished road
Firstly, thanks everyone who contributed to this thread, it's been very helpful with my development.

The issue I'm having is that I would like to handle the species conservation equation at the solver level (not use mstm().correct() ) for a variety of reasons.

I'd like to use diffusion coefficients from the Maxwell Stefan mass transport model and Chapman Enskogg binary diffusion coefficients.

From what I've managed to figure out I'm going to need to be able to assign a variable to my diffusion coefficients and be able to call updatecoefficients() from the mass transport model (maxwell steffan in this case). It's easy enough to say but I've had little luck, I think I have pulling the diffusion coefficients up to my solver from the mass transport model done properly but I can't seem to figure out how to call updatecoefficients().

I feel like this is a really simple thing to program with only minor changes to the code but I'm stuck as to what to do.

What I've tried is adding the function declaration for updateMolarFractions() (void updateMolarFractions(); ) to the multispeciestransportmodel header file and then calling updateMolarFractions using mstm().updateMolarFractions() (the mstm() implementation is the same as in the modified reacting foam). This compiles with /wmake libso but when i go to make the application with /wmake I get the following error: undefined reference to `Foam::multiSpeciesTransportModel::updateCoefficie nts()' Like I said, I feel this is simple and I'm just missing something basic.

Edit: managed to get it to solve for the maxwell coefficients at the solver level using the mstm pointer for the Dij information. I would still be interested to see if there's a more eloquent solution out there though.

Last edited by ChrisA; January 9, 2013 at 21:51. Reason: Further details
ChrisA is offline   Reply With Quote

Old   February 26, 2013, 12:25
Default
  #42
Senior Member
 
Olivier
Join Date: Jun 2009
Location: France, grenoble
Posts: 272
Rep Power: 18
olivierG is on a distinguished road
Hello mhsn,

Quote:
Originally Posted by mhsn View Post
Hey guys, thanks to your help, I could make modifiedReactingFoam work with openFoam2.1.1.
you may have to change some parts to be adapted to your openFoam especially in modifiedReactingFoam/Make/options and modifiedReactingFoam/Make/files

let me know if you needed that. I couldn't upload them regarding the maximum limit for the file size.
I would use the multi diffusion with 2.1.x, so can you please show the modification you have done ?

regards,
olivier
olivierG is offline   Reply With Quote

Old   February 26, 2013, 12:44
Default
  #43
New Member
 
Mhsn
Join Date: Oct 2012
Posts: 24
Rep Power: 14
mhsn is on a distinguished road
Olivier, I couldn't attach the files here. If you give me your email, I can email you the modified files.
mhsn is offline   Reply With Quote

Old   February 27, 2013, 04:06
Default
  #44
Senior Member
 
Olivier
Join Date: Jun 2009
Location: France, grenoble
Posts: 272
Rep Power: 18
olivierG is on a distinguished road
hello,

Thanks mhsn , Valerio, and Co .....
I put the 2.1.x version here if other people want it.

regards,
olivier
Attached Files
File Type: gz multiSpeciesMassTransportLibrary_2.1.x.tar.gz (36.2 KB, 600 views)
luiscardona, mhsn, Thamali and 1 others like this.
olivierG is offline   Reply With Quote

Old   March 13, 2013, 05:59
Default
  #45
New Member
 
Lei Deng
Join Date: Jun 2012
Posts: 3
Rep Power: 14
ldeng is on a distinguished road
hello everyone,

i am now using also this multispeciesLibary (champan-Enskog+ Fick) in OpenFoam-2.1.0 . i simulated a One Dimensional premixed laminar flame with reduced mechanisms (methane oxidation, 15 species, 21 reactions) in OpenFoam, and got two problems when I compared the results with cantera and original reactingFoam.

1. temperature does not match
2. production (H2O, CO2) does not match

The operating conditions and boundary conditions in cantera and openfoam are same.

i already compared all coefficient in OpenFoam and cantera, such as mixture diffusion coefficient, thermoal conductivity, viscosity, ... They are all same. I also directly replace the term -fvm::lapacian(D_[i], yi) with the unity lewis Nr. term -fvm::laplacian(turbulence.muEff(), yi) in the subclass Fick.C, and remove mass diffusion term in hs equation, the it performs just like reactingFoam. It proved that, the connection between this multispeciesLibary and themoPhysical packet in Openfoam is fine.

I am wondering the mixture mass diffusion coefficient may break the species conservation equation. I really appreciate that anyone who are using this library can share your experiences with me.

I checked the boundary condition at the inlet used in cantera for burner stabilized flame, there is a mass-flux balance boundary condition (tau_i = y_i +j_i/phi) . I think i need to apply such boundary condition in OpenFoam. i will try mix of fixed value + fixed Gradient.
Attached Files
File Type: pdf MassFraction.pdf (41.8 KB, 471 views)

Last edited by ldeng; March 14, 2013 at 05:01.
ldeng is offline   Reply With Quote

Old   March 15, 2013, 09:36
Default
  #46
Senior Member
 
Olivier
Join Date: Jun 2009
Location: France, grenoble
Posts: 272
Rep Power: 18
olivierG is on a distinguished road
hello,

I think you are right.
There is a common issue with inlet diffusion: the total flux is not only convective , but also diffusive, so if you set a fixedValue for a concentration, whit a know velocity, you will be wrong with your species flux calculation.
Take a look at this thread:
http://www.cfd-online.com/Forums/ope...chemistry.html

So try to set diffusivity to 0 at inlet, or set a mixed condition.
P.S: if you could set up a mixed condition for this, fell free to share !

regards,
olivier
ldeng likes this.
olivierG is offline   Reply With Quote

Old   March 22, 2013, 14:13
Default
  #47
Member
 
Chris
Join Date: Aug 2012
Location: Calgary, Alberta, Canada
Posts: 77
Rep Power: 14
ChrisA is on a distinguished road
Not sure if this will help, but I've managed to get around the "extra" mass due to diffusion at an inlet by correcting the inflow conditions for the mass diffusion.

I simply found the difference between my expected mass flow rate and the mass flow rate that openfoam gave me (done by integrating rho*U* inlet species concentration over a slice). We know that the difference is due to diffusion so if we assume the mass flow due to diffusion is a constant correct the inflow for that difference we arrive at a better mass flow rate. It won't be exact as the diffusion will change slightly as you change the concentration by changing the inflow velocity.. but with a few iterations you could conceivably approach the correct inflow mass flow rate.

This of course only works for specific conditions where you can assume and calculate the necessary values... and isn't ideal because it potentially requires iterative simulations... but its working for my research and might be applicable to a few other people's cases.
ChrisA is offline   Reply With Quote

Old   March 23, 2013, 07:12
Default
  #48
Senior Member
 
Olivier
Join Date: Jun 2009
Location: France, grenoble
Posts: 272
Rep Power: 18
olivierG is on a distinguished road
hello Chris,

Yes your method should work, but is case specific.
You should also take care at outlet, if you use inletOutlet condition: I've found that we can have local backflow over some face, which then lead to diffusive flux. The solution is to use zeroGradient, not inletOutlet.

regards,
olivier
olivierG is offline   Reply With Quote

Old   April 10, 2013, 00:18
Default diffusivity for species themselves?
  #49
New Member
 
何刚
Join Date: Jan 2011
Posts: 25
Rep Power: 15
hg2lf is on a distinguished road
In the file diffusivity.C:

void Foam::diffusivity::update()
{
for(label i=0;i=species_.size();i++)
{
for(label j=i;j<species_.size();j++)
{
label k=species_.size()*i+j-0.5*i*(i+1);
Dij_[k]=eps_/tau_*DijModels_[k].D();
}

}
}
"j=i" means that the diffusivity is calculated for species themselves? Maybe there are something that I haven't consider?
hg2lf is offline   Reply With Quote

Old   April 10, 2013, 17:47
Default
  #50
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings hg2lf,

Just to confirm: do you mean the code that is in the file "diffusivityModels/diffusivityModel/diffusivityModel.C"? (I've opened the one for 2.1.x.)

More specifically this piece of code?
Code:
void Foam::diffusivityModel::update()
{    
    for(label i=0; i < species_.size(); i++)
    {
        for(label j=i; j < species_.size(); j++)
        {
            label k = species_.size()*i+j-0.5*i*(i+1);
            Dij_[k] = eps_/tau_*DijModels_[k].D();
        }
    }
}
If so, here's what I can figure out:
  1. This kind of dual for loop is for going through the upper triangle of the matrix, including the diagonal.
  2. The "label k" line is for a special storage mechanism they've used, given the size of the "DijModels_" array, which is defined in the constructor of "diffusivityModel":
    Code:
    DijModels_.setSize(0.5*species.size()*(species.size()+1));
  3. If we also look at the constructor, we can see how the "DijModels_" array is initialized, namely with the following code:
    Code:
                DijModels_.set
                (
                    k,
                    binaryDiffusivityModel::New
                    (
                        species[i],
                        species[j],
                        dic_,
                        p,
                        T
                    )
                );
  4. So in conclusion, when "j=i", it should be related to the "binaryDiffusivityModel" of the "i" item of the species... which means that it's "binaryDiffusivityModel" that should tell the remaining story...
  5. Looking at "diffusivityModels/binaryDiffusivityModel/binaryDiffusivityModel.C", the following can be found:
    Code:
    Foam::binaryDiffusivityModel::binaryDiffusivityModel
    (
        const word& name1,
        const word& name2,
        const dictionary& dic,
        const volScalarField& p,
        const volScalarField& T
    )
    Which means that the "species" array is only carrying names of the species in question (I was thinking it was another model itself...). Therefore, it makes some sense that a model for the diffusion of the same species can come in handy, specially if it's the only species around
That's as far as I've looked. I'm not familiar with this library, so I don't know any specific details about it. But my estimate is that the "binaryDiffusivityModel" could refer to at least two extremes: two particles of the same "species" can repel each other or can attract each other.

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   April 11, 2013, 22:41
Default multiSpecies
  #51
New Member
 
何刚
Join Date: Jan 2011
Posts: 25
Rep Power: 15
hg2lf is on a distinguished road
Thanks,Bruno,
But I still can't understand. I need to modify this library to calculate the diffusivity for gas mixtures. So maybe the physical problem is not the same with the exist one. I'll do more work for this library, so that I could solve this problem.
Best regards.
hg2lf
hg2lf is offline   Reply With Quote

Old   April 14, 2013, 11:28
Default
  #52
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi hg2lf,

From your description, I can only guess that you need either one of the following possible solutions:
  • Perhaps you need to expand from binary to ternary? I.e. to take into account how three particles of different species interact with each other at the same time?
  • Or you need to change how the binary reactions are being used?
  • Or change completely the model for diffusion?
Either way, I'm only able to suggest that you have a look into the folders nearby the one for the code I referred, because I vaguely remember seeing that there are already some other diffusion models that can be used instead of this one... but I haven't studied them properly.

Good luck! Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   April 15, 2013, 14:48
Default
  #53
Member
 
Chris
Join Date: Aug 2012
Location: Calgary, Alberta, Canada
Posts: 77
Rep Power: 14
ChrisA is on a distinguished road
Hi hg2lf,

I can't comment on it much because I stopped using this library for my work (I'm using rhoCentralFoam so I needed a predictor step in my species equation, which this library does not allow for) but I can say that the maxwell-steffan model is a full multi-component model (handles many gas species). Ansys FLUENT uses this model, although I'm not sure if its the same implementation as is in the library.

We're also using the maxwell-steffan model for our work, although directly implemented in the solver rather than through a library.

The way it works in this library (and the model in general), to my limited understanding, is that the maxwell-steffan model uses binary diffusion coefficients to build an interaction matrix and then gets a multi component diffusion coefficient from that matrix for each species by summing the relevant terms. You can specify which binary diffusion coefficient to method to use (eg. chapman enskogg) and the maxwell-steffan model (should) reduce to the binary diffusion coefficient when only 2 gases are present.

Hope that helps,
Chris
ChrisA is offline   Reply With Quote

Old   April 16, 2013, 03:08
Default
  #54
tmu
New Member
 
Anderson
Join Date: Feb 2013
Posts: 11
Rep Power: 13
tmu is on a distinguished road
Hi Friends
I use this library for simulation laminar combustion in tube. but I have some problem:
maximum temperature in simulation differ about 100k with maximum temp in Reference. for this reason mass fraction of species have difference.
I read library an manual and compare equations in this library with Ref (for example: Theoretical and Numerical Simulation : Poinsot ). I found there are some difference.
1. In YEqn: we have the correction velocity that is added to convection velocity
to ensure conservation of species.although this term is disappeared in library.
2 . In hsEqn: we need to add one term in hs equation. although in library two terms are added.
please help me if there are any reference for this solver that speak about equation.
mhsn likes this.
tmu is offline   Reply With Quote

Old   April 18, 2013, 06:42
Default
  #55
New Member
 
何刚
Join Date: Jan 2011
Posts: 25
Rep Power: 15
hg2lf is on a distinguished road
Hello,
everyone, in the file Fick.C, in the function updateCoefficient(), the code like this:

forAll(species(), j)
{
if (j != i)
{
tmpGamma += x_[j] / Dij(i,j);
}
}

I think I could understand the question above.
hg2lf is offline   Reply With Quote

Old   April 18, 2013, 06:51
Default bug
  #56
New Member
 
何刚
Join Date: Jan 2011
Posts: 25
Rep Power: 15
hg2lf is on a distinguished road
Hello,
everyone,
In the file multiSpeciesTransportModel.C, in the function updateMolarFractions(), there is a piece of code, like this:

const scalarField& psiCells = thermo_.psi().internalField();
const scalarField& TCells = thermo_.T().internalField();
const scalarField& yCells =
thermo_.composition().Y(i).internalField();
scalarField& xCells = x_[i].internalField();
forAll(xCells, cellI)
{
xCells[cellI] = yCells[cellI] * psiCells[cellI] * TCells[cellI]
* R / W(i);
}

The code:"xells[cellI] = yCells[cellI] * psiCells[cellI] * TCells[cellI]* R / W(i);" express the idea:

x=Y*(1/RT)*T*Rcom/w(i);

the bug is w(i), which should be the molecular weight of the mixtures.

So, I think we should modified this piece of code.
hg2lf is offline   Reply With Quote

Old   April 18, 2013, 10:07
Default
  #57
New Member
 
Lei Deng
Join Date: Jun 2012
Posts: 3
Rep Power: 14
ldeng is on a distinguished road
hi hg2lf,
x(i) = p(i)/p
p(i) = rho(i) *R/w(i) *T
p = rho/psi
then x(i) = rho(i) *R/w(i) *T *psi/rho = y(i)* psi *R *T/w(i), w(i) is for pure specie
so code is correct

Last edited by ldeng; April 18, 2013 at 12:08.
ldeng is offline   Reply With Quote

Old   April 18, 2013, 14:15
Default
  #58
Member
 
Chris
Join Date: Aug 2012
Location: Calgary, Alberta, Canada
Posts: 77
Rep Power: 14
ChrisA is on a distinguished road
Quote:
Originally Posted by tmu View Post
Hi Friends

1. In YEqn: we have the correction velocity that is added to convection velocity
to ensure conservation of species.although this term is disappeared in library.
I believe that the method being used in this code is the Y(inert) = 1 - Y(everything else). You'll have to verify this though, I haven't looked at the library in a long time. The method is mentioned briefly in "Theoretical and Numerical Combustion" by Poinsot (Which I think is the book you meant to refer to in your post?) Anyway, as is mentioned there, there is an error associated with the method but if the inert species concentration is dominant in the simulation this error becomes negligible. It also disappears if the diffusion coefficients are all equal.

For reference, reactingFoam also uses this method in it's species equations.

I cannot comment too much on the heat transfer terms, in my own energy equation I'm only including the enthalpy transport term (sum of h_i*J_i, still ironing out the formulation for that myself.)

Regarding references for the library and it's equations, there should be a PDF in the earlier posts describing the equations used, there's also a paper by Valerio to look at.
ChrisA is offline   Reply With Quote

Old   April 29, 2013, 04:45
Default
  #59
New Member
 
Lei Deng
Join Date: Jun 2012
Posts: 3
Rep Power: 14
ldeng is on a distinguished road
Hi everyone,

as a conclusion to my previous diffusion flux problem:

The diffusion flux at inlet is a common issue. To avoid that we have two options:

1. specify the total flux( diffusion + convection) equals to a fixed value. it is a kind of mixture boundary condition, but difficult(my opinion) to implement into OpenFOAM.

2. close the diffusion flux(set neumann bc to zeroGradient at inlet), this is not elegant but the easiest.

because i also simulated a 1-D burner stabilized flame in Cantera. In order to obtain a better results specially near the inlet, I specified a fixed value to all species as an initial condition based on the simulated results. After the combustion proceeded, i change the BC of intermediate species back to zero. Anyway, by such approach, i got a nearly perfect results (see attachment) compared to Cantera.

regards,

lei
Attached Files
File Type: pdf results.pdf (29.4 KB, 233 views)
ldeng is offline   Reply With Quote

Old   May 5, 2013, 00:41
Default Install script
  #60
New Member
 
Ismael
Join Date: Nov 2012
Posts: 2
Rep Power: 0
idjibb is on a distinguished road
hello All,

Did anybody manage to get the install script to work for OF211 ?

regards,
idjibb is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Species Mole and Mass Fraction Macro combustion FLUENT 18 February 5, 2024 13:23
UDS and fluent internal species transport model jinsong FLUENT 0 May 3, 2018 12:37
Inconsistencies in reading .dat file during run time in new injection model Scram_1 OpenFOAM 0 March 23, 2018 23:29
Surface instabilities with 2-phase species transport richard222 Fluent Multiphase 0 May 4, 2016 05:06
Questions for a species transport problems (snapshots attached) aleisia FLUENT 2 October 9, 2011 05:40


All times are GMT -4. The time now is 16:29.