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

How to calculate the particles concentration?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 18, 2016, 06:09
Default How to calculate the particles concentration?
  #1
Member
 
Ping Chang
Join Date: Feb 2016
Location: Perth
Posts: 93
Rep Power: 10
chpjz0391 is on a distinguished road
Hey Foamers,
I am using simpleReactingParcelFoam to simulate the particles at steadystate.
The simulation goes well. I can get the particle mass, and number. However, I have a qustion,How can I get the concentration (kg/m^3)of the particles for a cell. I know I need to recompile the solver, and I have some codes about the concentration, but I am poor at C++. Could someone tell me how should I compile my solver in the main programme and createfield.H

the main.H
Code:
/*#################calculate the particle concentration, begin.################*/
    forAll(Conc,i)
    {
        Conc[i] = vector(0.0,0.0,0.0);
    }
    forAllConstIter(typename basicKinematicTypeCloud, kinematicCloud, iter)
    {
        const parcelType& p = iter();
        const label cellI = p.cell();
        Fluxs[cellI]+=p.nParticle()*p.mass();
    }
    forAll(mesh.V(),i)
    {
        Conc[i]/=mesh.V()[i];
    }
	/*#################calculate the particle velocity, end.################*/
Here is the cold for the field.H
Code:
/*##########################construct solid conc field.mass Concentration of the lagrangian particle [kg/(m^2*s)]##############*/

    Info<< "Creating field solid Conc\n" << endl;  // 
    volVectorField Conc
    (
        IOobject
        (
            "Conc",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        mesh,
        dimensionedVector("zero", dimMass/dimVolume, vector::zero)
    );	
	
	/*##########################################end######################################################################*/
chpjz0391 is offline   Reply With Quote

Old   May 23, 2016, 23:30
Default
  #2
Member
 
Ping Chang
Join Date: Feb 2016
Location: Perth
Posts: 93
Rep Power: 10
chpjz0391 is on a distinguished road
Hi all,
any suggestion?
chpjz0391 is offline   Reply With Quote

Old   May 24, 2016, 10:29
Default
  #3
Member
 
Brian Willis
Join Date: Mar 2011
Location: Cape Town, South Africa
Posts: 58
Rep Power: 15
Dipsomaniac is on a distinguished road
Hi Ping

Firstly concentration will be a volScalarField and not a volVectorField. Correct me if I am wrong. To compile a new solver you will need to edit the options and make files and then compile it. There are good tutorials online explaining how to compile new solvers. Google adding a scalar transport equation to simpleFoam or interFoam.

Regards,
Brian
Dipsomaniac is offline   Reply With Quote

Old   May 24, 2016, 22:05
Default
  #4
Member
 
Ping Chang
Join Date: Feb 2016
Location: Perth
Posts: 93
Rep Power: 10
chpjz0391 is on a distinguished road
Quote:
Originally Posted by Dipsomaniac View Post
Hi Ping

Firstly concentration will be a volScalarField and not a volVectorField. Correct me if I am wrong. To compile a new solver you will need to edit the options and make files and then compile it. There are good tutorials online explaining how to compile new solvers. Google adding a scalar transport equation to simpleFoam or interFoam.

Regards,
Brian
Hi Brian,

You are right, concentration is a volScalarField. I have compiled the solver, now I get the error information like this. I know little about C++ , could you tell me how should I modify this solver.


This is main solver(based on simpleReactingParcelFoam):
Code:
基于simpleReactingParcelFoam改的主程序:
```
#include "fvCFD.H"
#include "turbulentFluidThermoModel.H"
#include "basicReactingMultiphaseCloud.H"
#include "rhoCombustionModel.H"
#include "radiationModel.H"
#include "IOporosityModelList.H"
#include "fvIOoptionList.H"
#include "SLGThermo.H"
#include "simpleControl.H"
#include "basicKinematicCloud.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{
    #include "setRootCase.H"

    #include "createTime.H"
    #include "createMesh.H"
    #include "readGravitationalAcceleration.H"

    simpleControl simple(mesh);

    #include "createFields.H"
    #include "createRadiationModel.H"
    #include "createClouds.H"
    #include "createMRF.H"
    #include "createFvOptions.H"
    #include "initContinuityErrs.H"

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //



    Info<< "\nStarting time loop\n" << endl;

    while (simple.loop())
    {
        Info<< "Time = " << runTime.timeName() << nl << endl;

        parcels.evolve();

        // --- Pressure-velocity SIMPLE corrector loop
        {
         /*   #include "UEqn.H"
            #include "YEqn.H"
            #include "EEqn.H"
            #include "pEqn.H" */
        }

    /*#################calculate the particle concentration, begin.(below is my code)################*/


    forAllConstIter(typename basicKinematicTypeCloud, kinematicCloud, iter)
    {
        const parcelType& p = iter();
        const label cellI = p.cell();
        pmc[cellI]+=p.nParticles()*p.mass0();
    }
    
    
        pmc /=mesh().V();
     /*#################calculate the particle concentration, end.################*/


        turbulence->correct();

        runTime.write();


        Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;
    }

    Info<< "End\n" << endl;

    return 0;
}

// ************************************************************************* //
```

then is hte creatFields.H

```
Info<< "Creating combustion model\n" << endl;

autoPtr<combustionModels::rhoCombustionModel> combustion
(
    combustionModels::rhoCombustionModel::New(mesh)
);

rhoReactionThermo& thermo = combustion->thermo();
thermo.validate(args.executable(), "h", "e");

SLGThermo slgThermo(mesh, thermo);

basicSpecieMixture& composition = thermo.composition();
PtrList<volScalarField>& Y = composition.Y();

const word inertSpecie(thermo.lookup("inertSpecie"));

if (!composition.contains(inertSpecie))
{
    FatalErrorIn(args.executable())
        << "Specified inert specie '" << inertSpecie << "' not found in "
        << "species list. Available species:" << composition.species()
        << exit(FatalError);
}

volScalarField& p = thermo.p();
const volScalarField& T = thermo.T();
const volScalarField& psi = thermo.psi();

volScalarField rho
(
    IOobject
    (
        "rho",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::AUTO_WRITE
    ),
    thermo.rho()
);

Info<< "\nReading field U\n" << endl;
volVectorField U
(
    IOobject
    (
        "U",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ,
        IOobject::AUTO_WRITE
    ),
    mesh
);
//*******************************************//
	
	
    Info<< "Reading field pmc\n" << endl;
    volScalarField pmc
    (
        IOobject
        (
            "pmc",
            runTime.timeName(),
            mesh,
            IOobject::READ_IF_PRESENT,
            IOobject::AUTO_WRITE
        ),
        mesh
    );



	/*##########################construct solid concentration field.mass  of the lagrangian particle [kg/(m^3)]##############*/

	
	

#include "compressibleCreatePhi.H"

mesh.setFluxRequired(p.name());

dimensionedScalar rhoMax
(
    dimensionedScalar::lookupOrDefault
    (
        "rhoMax",
        simple.dict(),
        dimDensity,
        GREAT
    )
);

dimensionedScalar rhoMin
(
    dimensionedScalar::lookupOrDefault
    (
        "rhoMin",
        simple.dict(),
        dimDensity,
        0
    )
);

Info<< "Creating turbulence model\n" << endl;
autoPtr<compressible::turbulenceModel> turbulence
(
    compressible::turbulenceModel::New
    (
        rho,
        U,
        phi,
        thermo
    )
);

// Set the turbulence into the combustion model
combustion->setTurbulence(turbulence());

Info<< "Creating multi-variate interpolation scheme\n" << endl;
multivariateSurfaceInterpolationScheme<scalar>::fieldTable fields;

forAll(Y, i)
{
    fields.add(Y[i]);
}
fields.add(thermo.he());

volScalarField dQ
(
    IOobject
    (
        "dQ",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::AUTO_WRITE
    ),
    mesh,
    dimensionedScalar("dQ", dimEnergy/dimTime, 0.0)
);

The error inforamation:

```
simpleParticlesFoam.C: In function ‘int main(int, char**)’:
/opt/openfoam30/src/OpenFOAM/lnInclude/UList.H:465:18: error: invalid type in declaration before ‘::’ token
Container::const_iterator iter = (container).begin(); \
^
simpleParticlesFoam.C:89:5: note: in expansion of macro ‘forAllConstIter’
forAllConstIter(typename basicKinematicTypeCloud, kinematicCloud, iter)
^
/opt/openfoam30/src/OpenFOAM/lnInclude/UList.H:465:18: error: expected ‘;’ before ‘::’ token
Container::const_iterator iter = (container).begin(); \
^
simpleParticlesFoam.C:89:5: note: in expansion of macro ‘forAllConstIter’
forAllConstIter(typename basicKinematicTypeCloud, kinematicCloud, iter)
^
/opt/openfoam30/src/OpenFOAM/lnInclude/UList.H:465:18: error: ‘::const_iterator’ has not been declared
Container::const_iterator iter = (container).begin(); \
^
simpleParticlesFoam.C:89:5: note: in expansion of macro ‘forAllConstIter’
forAllConstIter(typename basicKinematicTypeCloud, kinematicCloud, iter)
^
simpleParticlesFoam.C:89:71: error: expected ‘;’ before ‘iter’
forAllConstIter(typename basicKinematicTypeCloud, kinematicCloud, iter)
^
/opt/openfoam30/src/OpenFOAM/lnInclude/UList.H:465:35: note: in definition of macro ‘forAllConstIter’
Container::const_iterator iter = (container).begin(); \
^
simpleParticlesFoam.C:89:71: error: ‘iter’ was not declared in this scope
forAllConstIter(typename basicKinematicTypeCloud, kinematicCloud, iter)
^
/opt/openfoam30/src/OpenFOAM/lnInclude/UList.H:465:35: note: in definition of macro ‘forAllConstIter’
Container::const_iterator iter = (container).begin(); \
^
/opt/openfoam30/src/OpenFOAM/lnInclude/UList.H:465:52: error: expected primary-expression before ‘)’ token
Container::const_iterator iter = (container).begin(); \
^
simpleParticlesFoam.C:89:5: note: in expansion of macro ‘forAllConstIter’
forAllConstIter(typename basicKinematicTypeCloud, kinematicCloud, iter)
^
/opt/openfoam30/src/OpenFOAM/lnInclude/UList.H:465:61: error: expected ‘)’ before ‘;’ token
Container::const_iterator iter = (container).begin(); \
^
simpleParticlesFoam.C:89:5: note: in expansion of macro ‘forAllConstIter’
forAllConstIter(typename basicKinematicTypeCloud, kinematicCloud, iter)
^
simpleParticlesFoam.C:89:30: warning: unused variable ‘basicKinematicTypeCloud’ [-Wunused-variable]
forAllConstIter(typename basicKinematicTypeCloud, kinematicCloud, iter)
^
/opt/openfoam30/src/OpenFOAM/lnInclude/UList.H:465:9: note: in definition of macro ‘forAllConstIter’
Container::const_iterator iter = (container).begin(); \
^
simpleParticlesFoam.C:89:71: error: ‘iter’ was not declared in this scope
forAllConstIter(typename basicKinematicTypeCloud, kinematicCloud, iter)
^
/opt/openfoam30/src/OpenFOAM/lnInclude/UList.H:466:9: note: in definition of macro ‘forAllConstIter’
iter != (container).end(); \
^
/opt/openfoam30/src/OpenFOAM/lnInclude/UList.H:466:27: error: expected primary-expression before ‘)’ token
iter != (container).end(); \
^
simpleParticlesFoam.C:89:5: note: in expansion of macro ‘forAllConstIter’
forAllConstIter(typename basicKinematicTypeCloud, kinematicCloud, iter)
^
/opt/openfoam30/src/OpenFOAM/lnInclude/UList.H:468:5: error: expected ‘;’ before ‘)’ token
)
^
simpleParticlesFoam.C:89:5: note: in expansion of macro ‘forAllConstIter’
forAllConstIter(typename basicKinematicTypeCloud, kinematicCloud, iter)
^
simpleParticlesFoam.C:97:20: error: no match for call to ‘(Foam::fvMesh) ()’
pmc /=mesh().V();
^
In file included from /opt/openfoam30/src/finiteVolume/lnInclude/fvCFD.H:7:0,
from simpleParticlesFoam.C:34:
/opt/openfoam30/src/finiteVolume/lnInclude/fvMesh.H:79:7: note: candidate is:
class fvMesh
^
In file included from /opt/openfoam30/src/OpenFOAM/lnInclude/HashTable.H:549:0,
from /opt/openfoam30/src/OpenFOAM/lnInclude/runTimeSelectionTables.H:41,
from /opt/openfoam30/src/OpenFOAM/lnInclude/token.H:49,
from /opt/openfoam30/src/OpenFOAM/lnInclude/UListIO.C:28,
from /opt/openfoam30/src/OpenFOAM/lnInclude/UList.C:225,
from /opt/openfoam30/src/OpenFOAM/lnInclude/UList.H:474,
from /opt/openfoam30/src/OpenFOAM/lnInclude/List.H:43,
from /opt/openfoam30/src/OpenFOAM/lnInclude/labelList.H:48,
from /opt/openfoam30/src/OpenFOAM/lnInclude/UPstream.H:42,
from /opt/openfoam30/src/OpenFOAM/lnInclude/Pstream.H:42,
from /opt/openfoam30/src/OpenFOAM/lnInclude/parRun.H:35,
from /opt/openfoam30/src/finiteVolume/lnInclude/fvCFD.H:4,
from simpleParticlesFoam.C:34:
/opt/openfoam30/src/OpenFOAM/lnInclude/HashTableI.H:145:11: note: T& Foam::HashTable<T, Key, Hash>:perator()(const Key&) [with T = Foam::regIOobject*; Key = Foam::word; Hash = Foam::string::hash]
inline T& Foam::HashTable<T, Key, Hash>:perator()(const Key& key)
^
/opt/openfoam30/src/OpenFOAM/lnInclude/HashTableI.H:145:11: note: candidate expects 1 argument, 0 provided
In file included from simpleParticlesFoam.C:57:0:
createFields.H:27:23: warning: unused variable ‘T’ [-Wunused-variable]
const volScalarField& T = thermo.T();
^
createFields.H:28:23: warning: unused variable ‘psi’ [-Wunused-variable]
const volScalarField& psi = thermo.psi();
^
In file included from simpleParticlesFoam.C:62:0:
/opt/openfoam30/src/finiteVolume/lnInclude/initContinuityErrs.H:37:8: warning: unused variable ‘cumulativeContErr’ [-Wunused-variable]
scalar cumulativeContErr = 0;
^
make: *** [Make/linux64GccDPInt32Opt/simpleParticlesFoam.o] Error 1
```
chpjz0391 is offline   Reply With Quote

Old   May 24, 2016, 22:56
Default
  #5
New Member
 
Joseph Urich
Join Date: Mar 2009
Location: Pittsburgh, PA
Posts: 21
Rep Power: 17
jurich is on a distinguished road
Hello Ping,

OpenFOAM version 3.0.x has something similar built in: it can calculation a void fraction. Take a look at src/lagrangian/intermediate/submodels/cloudFunctionObjects/VoidFraction to see how it works.

It is activated by adding the following

cloudVoidFraction1
{
type voidFraction;
}

to the cloudFunctions section at the end of your particle dictionary.

This is m^3/m^3. If you really need kg/m^3, you would need to copy that class and then modify it to include the particle density. It needs to be done within the particle tracking call, not in your main solver.

I hope that helps.
jurich is offline   Reply With Quote

Old   May 24, 2016, 23:02
Default
  #6
Member
 
Ping Chang
Join Date: Feb 2016
Location: Perth
Posts: 93
Rep Power: 10
chpjz0391 is on a distinguished road
Quote:
Originally Posted by jurich View Post
Hello Ping,

OpenFOAM version 3.0.x has something similar built in: it can calculation a void fraction. Take a look at src/lagrangian/intermediate/submodels/cloudFunctionObjects/VoidFraction to see how it works.

It is activated by adding the following

cloudVoidFraction1
{
type voidFraction;
}

to the cloudFunctions section at the end of your particle dictionary.

This is m^3/m^3. If you really need kg/m^3, you would need to copy that class and then modify it to include the particle density. It needs to be done within the particle tracking call, not in your main solver.

I hope that helps.
Hi,Joseph Urich

I am new to OpenFoam, could you give me more details about this function.
Could you please post some code ,so I can know how to modify.

Thank you

Kind Regards.

Ping
chpjz0391 is offline   Reply With Quote

Old   October 23, 2019, 04:10
Default
  #7
New Member
 
Hailong
Join Date: Sep 2019
Posts: 8
Rep Power: 7
nilvxingren is on a distinguished road
Hello Ping,
Have you solved this problem? I calculated a case use MPPICFoam, and need to show the cloud of particle concentration.
nilvxingren is offline   Reply With Quote

Old   August 8, 2021, 09:27
Smile use 'voidFraction' in 'cloudFunctions' of your cloudProperties dictionary
  #8
Member
 
Sourav Mandal
Join Date: Jul 2019
Posts: 55
Rep Power: 7
sourav90 is on a distinguished road
Quote:
Originally Posted by nilvxingren View Post
Hello Ping,
Have you solved this problem? I calculated a case use MPPICFoam, and need to show the cloud of particle concentration.
Hello,

The functionObject named 'voidFraction' can be used to calculate particle concentration. For details, check this thread:
output lagrangian particle volume fraction "reactingParcelFoam"
sourav90 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
Increasing particles splashed yoooodarulez Fluent Multiphase 2 August 3, 2013 07:22
Concentration of particles in sub-volume kathryn FLUENT 0 September 20, 2010 08:58
particles model ati_ros61 FLOW-3D 3 December 6, 2009 17:03
initial concentration in multicomponent mixtures isidro Siemens 0 April 26, 2004 08:40
how to calculate volume fraction of particles from x. simth FLUENT 2 April 26, 2001 16:40


All times are GMT -4. The time now is 13:50.