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

OpenFoam - concentration - variable for specie

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

Like Tree33Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 25, 2014, 04:17
Default OpenFoam - concentration - variable for specie
  #1
MK.
New Member
 
MK
Join Date: Oct 2014
Posts: 6
Rep Power: 12
MK. is on a distinguished road
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.
Kummi and akashpatel95 like this.
MK. is offline   Reply With Quote

Old   November 26, 2014, 07:00
Default
  #2
Senior Member
 
Tom Fahner
Join Date: Mar 2009
Location: Breda, Netherlands
Posts: 647
Rep Power: 32
tomf will become famous soon enoughtomf will become famous soon enough
Send a message via MSN to tomf Send a message via Skype™ to tomf
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;
    }
}

// ************************************************************************* //
tomf is offline   Reply With Quote

Old   November 26, 2014, 07:48
Default
  #3
MK.
New Member
 
MK
Join Date: Oct 2014
Posts: 6
Rep Power: 12
MK. is on a distinguished road
Hi Tom,

thank you very much! It works really fine.

MK.
HappyS5 likes this.
MK. is offline   Reply With Quote

Old   May 13, 2015, 06:54
Default
  #4
Member
 
Naresh Yathuru
Join Date: Feb 2015
Posts: 66
Rep Power: 11
Naresh yathuru is on a distinguished road
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
Kummi likes this.
Naresh yathuru is offline   Reply With Quote

Old   May 15, 2015, 07:21
Default
  #5
Senior Member
 
Tom Fahner
Join Date: Mar 2009
Location: Breda, Netherlands
Posts: 647
Rep Power: 32
tomf will become famous soon enoughtomf will become famous soon enough
Send a message via MSN to tomf Send a message via Skype™ to tomf
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
tomf is offline   Reply With Quote

Old   May 15, 2015, 09:41
Default
  #6
Member
 
Naresh Yathuru
Join Date: Feb 2015
Posts: 66
Rep Power: 11
Naresh yathuru is on a distinguished road
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
Naresh yathuru is offline   Reply With Quote

Old   May 15, 2015, 10:17
Default
  #7
Senior Member
 
Tom Fahner
Join Date: Mar 2009
Location: Breda, Netherlands
Posts: 647
Rep Power: 32
tomf will become famous soon enoughtomf will become famous soon enough
Send a message via MSN to tomf Send a message via Skype™ to tomf
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
tomf is offline   Reply With Quote

Old   May 15, 2015, 14:02
Default
  #8
Member
 
Naresh Yathuru
Join Date: Feb 2015
Posts: 66
Rep Power: 11
Naresh yathuru is on a distinguished road
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
Naresh yathuru is offline   Reply With Quote

Old   May 16, 2015, 12:17
Default
  #9
Senior Member
 
Tom Fahner
Join Date: Mar 2009
Location: Breda, Netherlands
Posts: 647
Rep Power: 32
tomf will become famous soon enoughtomf will become famous soon enough
Send a message via MSN to tomf Send a message via Skype™ to tomf
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.
tomf is offline   Reply With Quote

Old   May 17, 2015, 06:16
Default
  #10
Member
 
Naresh Yathuru
Join Date: Feb 2015
Posts: 66
Rep Power: 11
Naresh yathuru is on a distinguished road
Thank you tom. you too have a nice weekend.
Naresh yathuru is offline   Reply With Quote

Old   May 19, 2015, 09:08
Default
  #11
Member
 
Naresh Yathuru
Join Date: Feb 2015
Posts: 66
Rep Power: 11
Naresh yathuru is on a distinguished road
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
Naresh yathuru is offline   Reply With Quote

Old   May 19, 2015, 09:31
Default
  #12
Senior Member
 
Tom Fahner
Join Date: Mar 2009
Location: Breda, Netherlands
Posts: 647
Rep Power: 32
tomf will become famous soon enoughtomf will become famous soon enough
Send a message via MSN to tomf Send a message via Skype™ to tomf
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
tomf is offline   Reply With Quote

Old   November 23, 2015, 05:53
Default
  #13
Member
 
Robert Ong
Join Date: Aug 2010
Posts: 86
Rep Power: 16
rob3rt 0ng is on a distinguished road
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
rob3rt 0ng is offline   Reply With Quote

Old   November 25, 2015, 08:39
Default
  #14
Member
 
Victor Koppejan
Join Date: May 2015
Posts: 40
Rep Power: 11
vkoppejan is on a distinguished road
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.
rob3rt 0ng likes this.
vkoppejan is offline   Reply With Quote

Old   November 25, 2015, 13:38
Default
  #15
Member
 
Victor Koppejan
Join Date: May 2015
Posts: 40
Rep Power: 11
vkoppejan is on a distinguished road
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.
vkoppejan is offline   Reply With Quote

Old   November 26, 2015, 05:40
Default
  #16
Member
 
Robert Ong
Join Date: Aug 2010
Posts: 86
Rep Power: 16
rob3rt 0ng is on a distinguished road
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
rob3rt 0ng is offline   Reply With Quote

Old   November 26, 2015, 05:52
Default
  #17
Member
 
Victor Koppejan
Join Date: May 2015
Posts: 40
Rep Power: 11
vkoppejan is on a distinguished road
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
hhu_lulu likes this.
vkoppejan is offline   Reply With Quote

Old   November 26, 2015, 08:54
Default
  #18
Member
 
Knut Erik T. Giljarhus
Join Date: Mar 2009
Location: Norway
Posts: 35
Rep Power: 22
eric will become famous soon enough
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.
eric is offline   Reply With Quote

Old   November 30, 2015, 13:06
Default
  #19
Senior Member
 
Join Date: Jul 2009
Posts: 260
Rep Power: 18
kingjewel1 is on a distinguished road
Quote:
Originally Posted by eric View Post
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?
kingjewel1 is offline   Reply With Quote

Old   November 30, 2015, 23:53
Default
  #20
Member
 
Robert Ong
Join Date: Aug 2010
Posts: 86
Rep Power: 16
rob3rt 0ng is on a distinguished road
Quote:
Originally Posted by kingjewel1 View Post
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
rob3rt 0ng 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
new variable output as a file in openfoam for Ensight plot conceptone OpenFOAM Post-Processing 1 February 18, 2014 15:54
Cannot configure OpenFOAM environment variable in CAE Linux 2011 TommiPLaiho OpenFOAM Installation 9 October 15, 2013 09:44
Problem in installation of OpenFOAM sachin OpenFOAM Installation 7 January 22, 2008 02:40
Installation problems shellbell1999 OpenFOAM Installation 9 April 6, 2006 14:29
OpenFOAM Training and Workshop Zagreb 2628Jan2006 hjasak OpenFOAM 1 February 2, 2006 22:07


All times are GMT -4. The time now is 00:48.