CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Define simple multicomponent composition

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 9, 2011, 07:37
Default Define simple multicomponent composition
  #1
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18
Cyp is on a distinguished road
Hello!

I am trying to implement multicomponent system in my model. For instance I want to consider O2, N2, CH4, CO2. For the moment I just want a simple model (no turbulence, thermo=constant). So I need to create the mass fraction fields. To clarify the post-treatment I want that my fields are named from the component name. So I code:

Code:
    wordList speciesNames
    (
        transportProperties.lookup("speciesNames")
    ); 
    speciesTable s(wordList speciesName);

    basicMultiComponentMixture& composition = s;
    PtrList<volScalarField>& Y = composition.Y();
But it doesn't compile. Because of this line:
Code:
    basicMultiComponentMixture& composition = s;
Can you see where I missed the point ?

Best regards,
Cyp
Cyp is offline   Reply With Quote

Old   February 9, 2011, 10:43
Default
  #2
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18
Cyp is on a distinguished road
I fact I understand my mistake : the object "composition" need to be initialize with the constructor.

in basicMultiComponentMixture.H, the constructor is defined as:
Code:
    basicMultiComponentMixture
    (
        const dictionary&,
        const wordList& specieNames,
        const fvMesh&
    );
So I tried to code
Code:
    basicMultiComponentMixture composition
    (
        transportProperties,
        speciesNames,
        mesh
    );
But it still does not compile with the following error:
Code:
Make/linux64GccDPOpt/icoFoam.o: In function `main':
icoFoam.C:(.text+0x1c50): undefined reference to `Foam::basicMultiComponentMixture::basicMultiComponentMixture(Foam::dictionary const&, Foam::List<Foam::word> const&, Foam::fvMesh const&)'
collect2: ld returned 1 exit status
make: *** [/gemp/csoulain/OpenFOAM/csoulain-1.7.0/applications/bin/linux64GccDPOpt/icoFoamMulti] Erreur 1
How can I correctly fill "composition" ?
Cyp is offline   Reply With Quote

Old   February 9, 2011, 11:48
Default
  #3
Senior Member
 
Martin
Join Date: Oct 2009
Location: Aachen, Germany
Posts: 255
Rep Power: 21
MartinB will become famous soon enough
Hi Cyp,

have you included "multiComponentMixture.H"?
And have you updated the Make/options file?
I suppose, you will need

EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
. . . .

EXE_LIBS = \
-lbasicThermophysicalModels \
-lspecie \
-lreactionThermophysicalModels \
. . . .

Best regards

Martin
MartinB is offline   Reply With Quote

Old   February 9, 2011, 12:03
Default
  #4
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18
Cyp is on a distinguished road
Hi Martin,
thank you for your quite quick answer !!

Indeed I haven't added these lines in my options files!
Code:
EXE_INC = \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude
thank you very much!
Cyp is offline   Reply With Quote

Old   February 9, 2011, 12:33
Default
  #5
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18
Cyp is on a distinguished road
I have another question : I want to simulate gas - liquid mass transfer. Therefore, I can define two lists of mass fraction field (one for each phase).
Code:
    PtrList<volScalarField>& Ya = composition.Y();
    PtrList<volScalarField>& Yb = composition.Y();
However, I do not know how I can write my output files as : 02-gas ; N2-gas ; 02-liquid ; N2-liquid..

Do you have an idea ?


Edit : the solution I found :

Code:
    wordList speciesNames
    (
        transportProperties.lookup("speciesNames")
    ); 

    wordList liquidNames =speciesNames;
    wordList vaporNames  =speciesNames;
    
    forAll(speciesNames,i)
    {
        liquidNames[i]+="-liq";
        vaporNames[i] +="-vap";
    };     

    basicMultiComponentMixture compositiona
    (
        transportProperties,
        vaporNames,
        mesh
    );

    basicMultiComponentMixture compositionb
    (
        transportProperties,
        liquidNames,
        mesh
    );

    PtrList<volScalarField>& Ya = compositiona.Y();
    PtrList<volScalarField>& Yb = compositionb.Y();

Last edited by Cyp; February 17, 2011 at 08:43.
Cyp is offline   Reply With Quote

Old   February 17, 2011, 08:41
Default
  #6
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18
Cyp is on a distinguished road
Hi!

Martin, the solution you mention above worked perfectly with OpenFOAM 1.7.0 installed on my desktop computer. However, it doesn't work with OF 1.7.1 installed on my own laptop.

I get the following errore message while compiling:
Code:
impesFoam2: symbol lookup error: /opt/openfoam171/lib/linux64GccDPOpt/libreactionThermophysicalModels.so: undefined symbol: _ZN4Foam11basicTh
Do you think it is a bug introduced with OF171 ?

@++
Cyp
Cyp is offline   Reply With Quote

Old   December 14, 2012, 08:23
Default same kind of problem
  #7
OMN
New Member
 
Olivier Macchion
Join Date: Jun 2010
Posts: 12
Rep Power: 15
OMN is on a distinguished road
Hello Cyp

I was wondering if you might have a look at the piece of code below. I am trying to do something similar to what you wrote in this thread, that is to say to include properties based on several species using a basicMultiComponentMixture. But I get the following error message:

createFields.H: In function ‘int main(int, char**)’:
createFields.H:50:76: error: expression list treated as compound expression in initializer [-fpermissive]
createFields.H:50:76: warning: left operand of comma operator has no effect [-Wunused-value]
createFields.H:50:76: warning: right operand of comma operator has no effect [-Wunused-value]
createFields.H:50:76: error: invalid initialization of reference of type ‘Foam::basicMultiComponentMixture&’ from expression of type ‘Foam::fvMesh’

My createFields.H is the following:
Info<< "Reading thermophysical properties\n" << endl;

IOdictionary speciesDict
(
IOobject
(
"speciesDict", // dictionary name
runTime.constant(), // the dictionary is found in constant
mesh, // registry for the dictionary
IOobject::MUST_READ, // must exist, otherwise failure
IOobject::NO_WRITE // the dictionary is only read by the solver
)
);

const wordList speciesNames
(
speciesDict.lookup("species")
);

const wordList buoyantSpeciesNames
(
speciesDict.lookup("buoyantSpecies")
);

label nSpecies = speciesNames.size();

PtrList<dimensionedScalar> M(nSpecies);

forAll(speciesNames, i)
{
const word currentSpecie = speciesNames[i];
Info<< "Reading info on specie " << currentSpecie << endl;
const dictionary& subDict = speciesDict.subDict(currentSpecie);

M.set
(
i,
new dimensionedScalar(subDict.lookup("M"))
);
}

Info<< "Creating composition\n" << endl;
// PtrList<volScalarField> Y(nSpecies);
basicMultiComponentMixture& composition(speciesDict, speciesNames, mesh);
PtrList<volScalarField>& Y = composition.Y();

Would you have any ideas? The code fails at the line:
basicMultiComponentMixture& composition(speciesDict, speciesNames, mesh);

Cheers

Olivier
OMN is offline   Reply With Quote

Old   September 19, 2014, 09:58
Default
  #8
Member
 
Timm Severin
Join Date: Mar 2014
Location: Munich
Posts: 63
Rep Power: 12
Astrodan is on a distinguished road
Hey Guys,

I know it is a long time since the last post, but I'm currently stuck at a similar problem, where I need simple support for multiple species but don't care for all the thermodynamical properties.

My approach was similar to yours, but as it turns out that the baseMultiComponent class is (by now?) an abstract class and can not be created directly. My question would be if you didn't have this problem or if any of you already wrote a simple derived class? Otherwise I'd approach this now, but giving my practice this is gonna take some debugging time afterwards .

Thanks,
-Timm
__________________
PhD Student at the Institute of Biochemical Engineering at TU München
Modelling of fluid dynamics in open photobioreactors.

System:
OpenFOAM 2.3.x, 64bit, 8 Core Xeon Workstation
Astrodan is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
The correction on pressure equation of SIMPLE algorithm in MRFSimpleFOAM solver renyun0511 OpenFOAM Running, Solving & CFD 0 November 10, 2010 02:47
How to add correcting pressure equation in SIMPLE of MRFSimpleFOAM? renyun0511 OpenFOAM Programming & Development 0 November 4, 2010 02:38
Free surface boudary conditions with SOLA-VOF Fan Main CFD Forum 10 September 9, 2006 13:24
how to define 2d blockage in cfx? ritesh CFX 0 December 30, 2005 00:13
SIMPLE algorithm Jonathan Castro Main CFD Forum 3 December 10, 1999 05:59


All times are GMT -4. The time now is 07:18.