CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Define simple multicomponent composition (https://www.cfd-online.com/Forums/openfoam-programming-development/84812-define-simple-multicomponent-composition.html)

Cyp February 9, 2011 06:37

Define simple multicomponent composition
 
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 February 9, 2011 09:43

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" ?

MartinB February 9, 2011 10:48

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

Cyp February 9, 2011 11:03

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 February 9, 2011 11:33

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();


Cyp February 17, 2011 07:41

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

OMN December 14, 2012 07:23

same kind of problem
 
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

Astrodan September 19, 2014 08:58

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


All times are GMT -4. The time now is 21:35.