CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   OpenFoam - concentration - variable for specie (https://www.cfd-online.com/Forums/openfoam-solving/144953-openfoam-concentration-variable-specie.html)

MK. November 25, 2014 03:17

OpenFoam - concentration - variable for specie
 
Hi,

I like to calculate the concentration of an exhaust gas. I have one main inlet for air with a low temperature and 5 smaller inlets for air with a higher temperature. So I would like show and plot the concentration of the air which is coming out of the smaller inlets. So this is no multiphase model. I know in CFX that you can easy specify a variable with a transport equation and set this one for example to 0 at the main inlet and to 1 at the smaller inlet. Is there a similar way in OpenFoam. I couldn't find something like this.

Could please someone of you help me out.

cheers,

MK.

tomf November 26, 2014 06:00

Hi,

This can be done with the scalarTransport functionObject.

Code in controlDict (within the functions subDict):
Code:

    Tracer
    {
        type    scalarTransport;
        functionObjectLibs ("libutilityFunctionObjects.so");
        outputControl outputTime;
        active          true;
        autoSchemes    false;
        nCorr          0;
        resetOnStartUp false;
        fvOptions     
        {
       
        }
    }

and you would need a file called Tracer in your 0 folder, which should look something like this:

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.3.x                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      volScalarField;
    object      Tracer;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 0 0 0 0 0 0];

internalField  uniform 0;

boundaryField
{
    ".*"
    {
        type            zeroGradient;
    }
    Exhausts
    {
        type            fixedValue;
        value          uniform 1;
    }
    Main_Inlet
    {
        type            fixedValue;
        value          uniform 0;
    }
    Outlet
    {
        type            inletOutlet;
        inletValue      uniform 0;
        value          uniform 0;
    }
}

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


MK. November 26, 2014 06:48

Hi Tom,

thank you very much! It works really fine.

MK.

Naresh yathuru May 13, 2015 05:54

Hi Foamers,

Sorry for restarting the thread again.
.I m new to species transport simulations. I read a lot of treads in cfd online. i m trying to simulate CO2 emission from human. so i m using scalar transport function utility.

first i tried this
Code:

S
      {
          type            scalarTransport;
          outputControl  outputTime;
          DT              14e-6;
          userDT          true;
          resetOnStartUp  false;
          autoSchemes    true;
          fvOptions     
          {
              S-01
              {
              type            scalarExplicitSetValue;
              active          true;
              selectionMode  cellZone;
              cellZone        sampleInlet;
              scalarExplicitSetValueCoeffs
                  {
                      injectionRate
                      {
                          S  0.01; //kg/s
                      }
                  }
              }
          };
    }

from topoSet i selected a layer of cellsets and cellZones around the surface of the mannequin(sampleinlet).

Then i saw your thread . then i tried this
Code:

S
      {
          type            scalarTransport;
          outputControl  outputTime;
          DT              14e-6;
          userDT          true;
          resetOnStartUp  false;
          autoSchemes    true;
          fvOptions     
          {
             
          };
    }

and created a folder S/0
Code:

FoamFile
{
    version    2.0;
    format      ascii;
    class      volScalarField;
    object      S;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions      [0 0 0 0 0 0 0];

internalField  uniform 0;

boundaryField
{
    ".*"
    {
        type            zeroGradient;
    }
    man2new
    {
        type            fixedValue;
        value          uniform 0.01;
    }
}

Both the simulation gives me some result but they are totally different.

the question i have is why there is no dimensions specified?
When i specify kg/s ,[1 0 -1 0 0 0 0] i m getting an error. could someone please help me.
2. which of the above two procedure is correct?
3. is it the correct way to simulate co2 emission from a human body.(no reaction)

I m using OF 2.3.0 and buoyantboussinesqsimpleFoam.

Thank you
Best Regards,
Naresh

tomf May 15, 2015 06:21

Hi Naresh,

With the scalarTransport functionObject you are just following a scalar through your domain as it is being advected and diffused with the flow. So it is the equivelant of dye being released in water.

This part:

Code:

          fvOptions     
          {
              S-01
              {
              type            scalarExplicitSetValue;
              active          true;
              selectionMode  cellZone;
              cellZone        sampleInlet;
              scalarExplicitSetValueCoeffs
                  {
                      injectionRate
                      {
                          S  0.01; //kg/s
                      }
                  }
              }
          };

is injecting 0.01 /s, it is not necessarily kg/s, could also be 0.01 mol/s or whatever, it is just 0.01/s. If it is not being advected/diffused the value will increase in this cellZone.

This part:
Code:

FoamFile
{
    version    2.0;
    format      ascii;
    class      volScalarField;
    object      S;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions      [0 0 0 0 0 0 0];

internalField  uniform 0;

boundaryField
{
    ".*"
    {
        type            zeroGradient;
    }
    man2new
    {
        type            fixedValue;
        value          uniform 0.01;
    }
}

Says that you inject 0.01 (mol/kg/whatever) at the man2new patch. You have to multiply this with the flowrate form this patch to get the actual amount that you are injecting. In this case the value will not be larger than 0.01 in any cell.

You can think about the first option as a constant volumetric heating, while the second option is like injecting hot air at a constant temperature.

For your questions:
1. There is no real need for dimensions, but you can do it if you want. You can solve for kg or concentration, but not kg/s, however you can inject something per second.
2. I would use option 2 with: dimensions [1 0 0 0 0 0 0]; (I think the time is the one giving you the error, however, it is just a specification, if it does not work, you can keep the dimensions [0 0 0 0 0 0 0]; this does not change your result.
3. With this approach you are neglecting the change in density caused by the difference in species concentration. If the CO2 content is low and the velocity is high this can be a good assumption. If it is not you may need to use one of the reactingFoam family of solvers with reactions turned off.

Regards,
Tom

Naresh yathuru May 15, 2015 08:41

Hi Tom,

thanks for your detailed reply. it almost cleared all my doubts and now i have one basic doubt (mass conservation) but i might sound silly.
Quote:

Says that you inject 0.01 (mol/kg/whatever) at the man2new patch. You have to multiply this with the flowrate form this patch to get the actual amount that you are injecting. In this case the value will not be larger than 0.01 in any cell.
In my case i dont have and massflow rate on the patch man2new.


if i say i m simulating a mass source in the domain. the patch man2new generating the same air
Code:

dimensions      [1 0 0 0 0 0 0];

internalField  uniform 0;

boundaryField
{
    ".*"
    {
        type            zeroGradient;
    }
    man2new
    {
        type            fixedValue;
        value          uniform 2;
    }
}

as u can see i have large injection rate. I thought i would see a huge change in the mass flow rate. but when i monitor the inlet and outlet mass flow rates i see no change. it was the same before and after adding the mass source. i m confused . am i missing something.

Code:


MassFlows:  outlet = 0.057125518  inlet = -0.057121114
scalarTransport output:
DILUPBiCG:  Solving for S, Initial residual = 0.00041745404, Final residual = 7.9045899e-07, No Iterations 2

Thank you
regards,
naresh

tomf May 15, 2015 09:17

Hi Naresh,

I think you are missing one point: The scalar "S" does not change anything in the solution of your flow. It is a passive scalar, so it is in fact massless, but it acts as something that allows you to visualize concentration levels on different locations in the domain. It is just coloring some area and see how this color is moving along with the flow.

With buoyantBoussinesqSimpleFoam you are solving for the steady state incompressible turbulent buoyant flow of a single species gas. You can use the scalarFunctionObject as a first approximation of how a different species would spread through that flow if it were injected at a certain location, think about massless smoke/dye/ink.

Regards,
Tom

Naresh yathuru May 15, 2015 13:02

Thanks for the quick reply tom,

you are right. I missed the basic definition of a passive scalar ;) i was confused by

http://www.openfoam.org/version2.1.0/numerics.php

field source:
scalarExplicitSources
scalarExplicitsourceCoeff

it turns out that they dont exist in 2.3.0 or may be renamed as scalarsemiImplicitsources, i m not sure.
please correct me if i m wrong.
utility "scalar transport" cannot affect the flow. if i have a volumetric heat source (T=500K defined using scalar transport) that does not influence the temperature of the domain but i could only visualize the convection and diffusion of the source .

This might be a fundamental question.

regards,
Naresh

tomf May 16, 2015 11:17

I am not sure about renaming of the sources, but this may have happend.

You are right about the last part. Have a nice weekend.

Naresh yathuru May 17, 2015 05:16

Thank you tom. you too have a nice weekend.

Naresh yathuru May 19, 2015 08:08

Hi Tom,

I did some simulation with the scalasemiimplicit sources. the results are not bad.
I could not specify a mass source in the domain. so i want to use reationFoam with no combustion and reaction.

Quote:

3. With this approach you are neglecting the change in density caused by the difference in species concentration. If the CO2 content is low and the velocity is high this can be a good assumption. If it is not you may need to use one of the reactingFoam family of solvers with reactions turned off.

I have a couple of questions.
1. reactionFoam is a compressbile solver. but my case is incompressible. do i have to change something or can i use a compressible solver for incompressible simulation?
2. so I thought of using TwoliquidmixingFoam which is incompressible,steady state but it does not consider heat transfer. I can add temperature to the solver but i m not sure if it would give a better result.

Could you give your suggestions on this? Or any other easier way if u know any .
Thankyou

Regards,
Naresh

tomf May 19, 2015 08:31

Hi Naresh,

1. Incompressible flow is a limit to compressible flow where you have a fixed density. So this is a valid assumption if your density variations are small. However you can always solve for compressible flow even if there are very small density variations. It may not be the most efficient, but it should be more accurate.
2. I am not entirely sure about the possibility of using this solver for your problem. Also it is not steady-state. I have not used this solver and I am not completely familiar with it's range of applications.

Regards,
Tom

rob3rt 0ng November 23, 2015 04:53

Hi All,

I'm currently working on modelling pollutant (NOx, SOx, ppm) dispersion of in a busway region. After getting the atmospheric boundary layer (ABL) sorted out, I have a few questions of how to go with this:
1. Is scalar transport suitable for this type of problem? or should I introduce a vector inlet from the source (bus) which can't be done using scalar transport? I'd imagine because the gases diffusivities will be low and advection will be the dominant process
2. How can I specify the diffusivity value inside the controlDict function? since it's not specified in transport properties?
3. I also like to specify a different concentration values for each gases, should I create a patch for the bus or can it be just done using cellZone (which is what I'm using now)?

Any replies will be much appreciated.

Kind regards,
Robert

vkoppejan November 25, 2015 07:39

Has anyone ever tried this with multiphase solvers such as twoPhaseEulerFoam? If so, how did you link the scalar transport eqn to the right phase?

@ rob3rt 0ng

1. This is a passive scalar, so uncoupled transport wrt to the flow mass, momentum and energy equations. This seems valid for such low amounts of polution. However, for accuracy in the solver I would normalize the concentrations using a source or inlet concentration.

2. Check Naresh yathuru's post on the 13th of May.

3. Not sure what you mean by this. Sources and BC's require the definition of a patch or cellZone but there are multiple ways to do this. Btw, multiple species require multiple species transport eqns.

vkoppejan November 25, 2015 12:38

Ok I found out how to do use this for multiphase systems.

FYI, I'm modelling a liquid-solid fluidized bed, laminar flow for both phases.

To add scalarTransport follow these steps:

1: Add the the following code to the controlDict

Code:

functions
{
        Tracer
        {
                type                            scalarTransport;
                functionObjectLibs        ("libutilityFunctionObjects.so");
                outputControl                outputTime;
                active                        true;
                autoSchemes            false;
                nCorr                          0;
                resetOnStartUp        false;
                fvOptions
                {
                }

                phiName                        phi.water;
                UName                        U.water
                rhoName                      rho.water
                DT                              1e-9;
                      userDT                          true;
        }
}

2: Add the following to fvSchemes under div schemes
(of course feel free to use another scheme)

Code:

div(phi,Tracer)                                Gauss limitedLinear 1;
3: Add the following to fvSolution

Code:

    Tracer
    {
        solver          PBiCG;
        preconditioner  none;
        tolerance      1e-6;
        relTol          0;
        minIter        1;
    }

This solver was proposed for scalar in this thread:

http://www.cfd-online.com/Forums/ope...oam-of231.html

and allows you to solve systems with zeros on the diagonal (as you would get in area's where there is no tracer).

Finally you need to provide a file with tracer initial and BC's in the zero folder.

That shoud do the trick, please let me know if I've forgotten to add anything.

I'm planning on adapting the scalarTransport object to allow for more complex use of dilute species transport (maybe some simple mass transfer etc). No idea when it will be done but I'll get back to you.

rob3rt 0ng November 26, 2015 04:40

Hi Victor,

Thanks for the reply. Please also share the dilute transport case file if you have it ready ;-)

Just to clarify one thing: if I specify the real diffusivity value (m2/s) and its emission rate (kg/s), shouldn't I end up with the real concentration that doesn't need to be normalised? Can this be done in using scalarExplicitSetValue as a subfunction in controlDict or should I run this after I get the steady-state BC and use scalarTransportFoam as in the pitzDaily tutorial?

Kind regards,
Robert

vkoppejan November 26, 2015 04:52

Hi Robert,

I think this really depends on the concentrations of the species, you mentioned earlier that they were in the ppm range.

I have to admit that I'm not sure how OpenFOAM handles this but I'm always a bit weary of scalars with values in the range of the tolerance settings.

Also for, should you want to use a limiter scheme, having a scalar between 0 and 1 can be benificial.

Since the transport eqn is uncoupled , the diffusivity is constant, and were assuming Ficks Law, you should be able to transform the results in paraview to match the real life concentrations.

As always these things are case specific, perhaps you can share your findings.

Cheers,

Victor

eric November 26, 2015 07:54

Just one comment on the use of scalarTransportFoam. As it is now, turbulent diffusion is not included in the solver, only the molecular diffusion. For most industrial flows, turbulent diffusion is orders of magnitude higher than the molecular, and hence very important to include. Turbulent diffusion is not a constant, but a variable calculated as part of the flow solution from the turbulence model.

You need to modify the equation to something like this:
Code:

fvm::ddt(T)
+ fvm::div(phi, T)
- fvm::laplacian(DT + turbulence->nuEff()*1/Sc, T)

where Sc is the Schmidt number. You must also edit the createFields.H file to create the turbulence model object.

kingjewel1 November 30, 2015 12:06

Quote:

Originally Posted by eric (Post 575091)
Just one comment on the use of scalarTransportFoam. As it is now, turbulent diffusion is not included in the solver, only the molecular diffusion. For most industrial flows, turbulent diffusion is orders of magnitude higher than the molecular, and hence very important to include. Turbulent diffusion is not a constant, but a variable calculated as part of the flow solution from the turbulence model.

You need to modify the equation to something like this:
Code:

fvm::ddt(T)
+ fvm::div(phi, T)
- fvm::laplacian(DT + turbulence->nuEff()*1/Sc, T)

where Sc is the Schmidt number. You must also edit the createFields.H file to create the turbulence model object.

Hi eric,

Where is it you suggest to modify the equation? Does it mean making a separate solver etc?

rob3rt 0ng November 30, 2015 22:53

Quote:

Originally Posted by kingjewel1 (Post 575665)
Hi eric,

Where is it you suggest to modify the equation? Does it mean making a separate solver etc?

Yes, i think so. Just rename it to myScalarTurbulentTransportFoam or something like that.

Kind regards,
Robert


All times are GMT -4. The time now is 20:15.