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

ScalarTransportFoam Help

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

Like Tree3Likes
  • 1 Post By r08n
  • 1 Post By chegdan
  • 1 Post By RobertHB

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 3, 2011, 04:06
Default ScalarTransportFoam Help
  #1
New Member
 
Abhinav Sharma
Join Date: Sep 2010
Posts: 28
Rep Power: 15
asharma is on a distinguished road
Hello Foamers,

I've set up my flow field model using both LES and RAS ( run with pisoFoam) for a urban street canyon, and would like to introduce scaler transport model to simulate pollutant dispersion. I understand that ScalarTransportFoam can be used here, however i will need to modify the code to introduce a source term (i've been following this tutorial) I'm not quite clear as to how to go about the entire process, ie to link the modified code after introducing the changes , to my wind field output data(output of pisoFoam run). I'm not very thorough with C ++ hoping to get familiarized with it as soon as possible!

Thank you in advance!

Regards,
Abhinav

Last edited by asharma; January 3, 2011 at 06:01.
asharma is offline   Reply With Quote

Old   January 4, 2011, 04:37
Default
  #2
New Member
 
Abhinav Sharma
Join Date: Sep 2010
Posts: 28
Rep Power: 15
asharma is on a distinguished road
I've been trying to implement a source term to scalerTransportForm coupling it to my pisoFoam solver and have attempted to include a source term as mentioned in the tutorial(mentioned above) as follows where my T is my scaler field and my source "source":-
Code:
solve
	(
	  fvm::ddt(T)
	  + fvm::div(phi, T)
	  - fvm::laplacian(DT, T)
	  ==
	  source
	);
this is in my Teqn.H file , which is called in my main .C mypisoFoam file as follows:-

Code:
for (int corr=0; corr<nCorr; corr++)
            {
		#include "TEqn.H"
I've also included the necessary input data to be read in the createFields.H file :-
Code:
Info<< "Reading field T\n" << endl;
    volScalarField T
    (
	IOobject
	(
	    "T",
	    runTime.timeName(),
	    mesh,
	    IOobject::MUST_READ,
	    IOobject::AUTO_WRITE
	    ),
	    mesh
	);
	
     Info<< " Reading source" << endl;
     volScalarField source
     (
     	IOobject
	(
	    "source",
	    runTime.timeName(),
	    mesh,
	    IOobject::MUST_READ,
	    IOobject::NO_WRITE
	    ),
	    mesh
	    );
Just to be clear, i complied all the above without any errors (yay!) , so now all i have to do is define my initial value T(scaler component) and source at my boundaries as specified in my Mesh right? The same tutorial mentions something about a non-uniform source which has got me a bit confused, non uniform in what sense?? i would really appreciate if i could get some input on if i've done this correctly?!

Regards,
Abhinav
asharma is offline   Reply With Quote

Old   January 4, 2011, 10:28
Default
  #3
Senior Member
 
santiagomarquezd's Avatar
 
Santiago Marquez Damian
Join Date: Aug 2009
Location: Santa Fe, Santa Fe, Argentina
Posts: 452
Rep Power: 23
santiagomarquezd will become famous soon enough
Abhinav, the kind of source you're using is passive, i.e. it doesn't depend on the values of T. Nevertheless this doesn't imply that this source have to be spatially constant. In the way you're defined it, it can be a completely spatially variable source. Other way is to define the source value in the transportProperties dictionary and then use:

Code:
solve
	(
	  fvm::ddt(T)
	  + fvm::div(phi, T)
	  - fvm::laplacian(DT, T)
	  ==
	  sourceValue
	);
where sourceValue is the value given by the dictionary.

Regards.
__________________
Santiago MÁRQUEZ DAMIÁN, Ph.D.
Research Scientist
Research Center for Computational Methods (CIMEC) - CONICET/UNL
Tel: 54-342-4511594 Int. 7032
Colectora Ruta Nac. 168 / Paraje El Pozo
(3000) Santa Fe - Argentina.
http://www.cimec.org.ar
santiagomarquezd is offline   Reply With Quote

Old   January 5, 2011, 04:30
Default
  #4
New Member
 
Abhinav Sharma
Join Date: Sep 2010
Posts: 28
Rep Power: 15
asharma is on a distinguished road
Thank you Santiago!
Yes i understand i'm using a passive source here, which is exactly what i want. However i'm getting a little confused on how to specify my source to a specific region in my geometry where i want my scaler T to get generated and subsequently dispersed with the prevailing wind flow regime. Is there a way to do that? Pardon me if my question seems silly!

Thanks,

Regards,
Abhinav
asharma is offline   Reply With Quote

Old   January 5, 2011, 10:05
Default
  #5
Senior Member
 
santiagomarquezd's Avatar
 
Santiago Marquez Damian
Join Date: Aug 2009
Location: Santa Fe, Santa Fe, Argentina
Posts: 452
Rep Power: 23
santiagomarquezd will become famous soon enough
Abhinav, your question is how to set the values of the source across the domain? If it's the case you have swak4Foam (http://openfoamwiki.net/index.php/Contrib/swak4Foam) to do so.

Regards
__________________
Santiago MÁRQUEZ DAMIÁN, Ph.D.
Research Scientist
Research Center for Computational Methods (CIMEC) - CONICET/UNL
Tel: 54-342-4511594 Int. 7032
Colectora Ruta Nac. 168 / Paraje El Pozo
(3000) Santa Fe - Argentina.
http://www.cimec.org.ar
santiagomarquezd is offline   Reply With Quote

Old   January 5, 2011, 10:20
Default
  #6
Member
 
Robertas N.
Join Date: Mar 2009
Location: Kaunas, Lithuania
Posts: 53
Rep Power: 17
r08n is on a distinguished road
Quote:
Originally Posted by asharma View Post
However i'm getting a little confused on how to specify my source to a specific region in my geometry where i want my scaler T to get generated and subsequently dispersed with the prevailing wind flow regime.
Easy: once the fields 'source' and 'T' are defined, you can manipulate them the same way as other fields; i.e.: define their initial values in the files 'thecase/0/T' and 'thecase/0/source'
and set the values at the appropriate regions of the mesh using setFields or
funkySetFields, or, in especially customized cases, assign the values straight in the code, e.g. point by point, like this:

Code:
source[mesh.findCell (point (x,y,z))] = value_at_xyz;
r08n is offline   Reply With Quote

Old   January 6, 2011, 02:11
Default
  #7
New Member
 
Abhinav Sharma
Join Date: Sep 2010
Posts: 28
Rep Power: 15
asharma is on a distinguished road
Hi Robertas and Santiago,

Thanks for the help! I'm pretty sure as to how to go about it now...

Regards,
Abhinav
asharma is offline   Reply With Quote

Old   January 14, 2011, 02:20
Default
  #8
New Member
 
Abhinav Sharma
Join Date: Sep 2010
Posts: 28
Rep Power: 15
asharma is on a distinguished road
Robertas , if i were to assign values straight in the code like you've mentioned, where(which file) am i suppose to add the code to?
asharma is offline   Reply With Quote

Old   January 14, 2011, 05:53
Default
  #9
Member
 
Robertas N.
Join Date: Mar 2009
Location: Kaunas, Lithuania
Posts: 53
Rep Power: 17
r08n is on a distinguished road
Quote:
Originally Posted by asharma View Post
Robertas , if i were to assign values straight in the code like you've mentioned, where(which file) am i suppose to add the code to?
It depends on the structure of your program and what you want to do. Usually, the
overall structure of the solver is like this:

Code:
// Initialization goes here;
// main loop:
while ( runTime.run() )
{
    // solution steps for equations (depend on the particular solver):
    #include "UEqn.H"
    ... // other equations, as/if needed
   // output data and such...
}
// wrap up
and all this is located in the "main" file, i.e., the file where the 'main' function is located. If the source field(s) are time-dependent,
the values should be assigned inside the main loop; but then you'll probably want to define a separate function for calculating the field values, and this function can be located in a separate file, like

Code:
// in the file "updateSource.h"
void updateSource (volScalarField& Q);
Code:
// in the file "updateSource.cpp"
void updateSource (volScalarField& Q)
{
   // the required assignments go here
}
Code:
#include "updateSource.h"

// Initialization goes here;
// main loop:
while ( runTime.run() )
{
    // update source fields
    updateSource (Q);
    // solution steps for equations (depend on the particular solver):
    #include "UEqn.H"
    ... // other equations, as/if needed
   // output data and such...
}
// wrap up
It's a matter of the general program structure, so there are no strict rules -- just considerations...
immortality likes this.
r08n is offline   Reply With Quote

Old   January 18, 2011, 13:34
Default reynolds averaged passive scalar transport
  #10
Senior Member
 
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 621
Rep Power: 0
chegdan will become famous soon enoughchegdan will become famous soon enough
Quote:
Originally Posted by asharma View Post
Hello Foamers,

I've set up my flow field model using both LES and RAS ( run with pisoFoam) for a urban street canyon, and would like to introduce scaler transport model to simulate pollutant dispersion. I understand that ScalarTransportFoam can be used here, however i will need to modify the code to introduce a source term (i've been following this tutorial) I'm not quite clear as to how to go about the entire process, ie to link the modified code after introducing the changes , to my wind field output data(output of pisoFoam run). I'm not very thorough with C ++ hoping to get familiarized with it as soon as possible!

Thank you in advance!

Regards,
Abhinav
I think the key question here is how does one model passive scalar transport in turbulent field? This should be the answer to be addressed rather than adding a source term. If you want to use a Reynolds averaged passive scalar approach then you might want to have a look at some other threads, including this one:

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

I had a similar question a while back and I give a snippet of code that has worked very well. If the code on that thread is used, then the difficult part is to estimate the turbulent mass diffusivity of the pollutant. Usually this is estimated with a constant global turbulent schmidt number (turbulent viscosity/ turbulent mass diffusivity) equal to 0.7 (from fluent documentation). There are some other nuances of that are covered in posts 17 and 18 in the provided link. Basically the gradient diffusion hypothesis is used to approximate the scalar-flux <u'\phi'> term produced during reynolds averaging. For an LES approach, the methods are a little different that could employ a subgrid scalar flux relationship. I hope this helps.

Dan
vonboett likes this.
chegdan is offline   Reply With Quote

Old   January 19, 2011, 05:09
Default
  #11
New Member
 
Abhinav Sharma
Join Date: Sep 2010
Posts: 28
Rep Power: 15
asharma is on a distinguished road
Thank you Robertas and Dan,
I apologies for the late reply as i was busy with some related but different work. Yes i see the importance of modeling scaler transport in a turbulent field to be addressed here, it was also pointed out by my mentor. I've used funkysetfields to define specific patches where i would like to introduce my scaler (i found it more convenient then manually entering the points), moreover i believe usage of a source term is not apt for my particular application(?). Actually i require a constant source of scaler to be introduced in my domain at a specified location, corresponding to emissions from vehicles passing through my street canyon. Would it be reasonable to assume a constant scaler concentration at points where i have assumed vehicle to pass, and allow scaler transport foam to calculate the dispersion with the turbulent diffusivity (by adding nut term to DT) accounted for?...
asharma is offline   Reply With Quote

Old   January 19, 2011, 10:05
Default
  #12
Senior Member
 
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 621
Rep Power: 0
chegdan will become famous soon enoughchegdan will become famous soon enough
Quote:
Originally Posted by asharma View Post
Thank you Robertas and Dan,
I apologies for the late reply as i was busy with some related but different work. Yes i see the importance of modeling scaler transport in a turbulent field to be addressed here, it was also pointed out by my mentor. I've used funkysetfields to define specific patches where i would like to introduce my scaler (i found it more convenient then manually entering the points), moreover i believe usage of a source term is not apt for my particular application(?). Actually i require a constant source of scaler to be introduced in my domain at a specified location, corresponding to emissions from vehicles passing through my street canyon. Would it be reasonable to assume a constant scaler concentration at points where i have assumed vehicle to pass, and allow scaler transport foam to calculate the dispersion with the turbulent diffusivity (by adding nut term to DT) accounted for?...
About your moving source, you might want to look at something called swak4foam (http://openfoamwiki.net/index.php/Contrib/swak4Foam) that has some functionality for sources (swakSourceFields, swakTopoSources) that are explained in the README file. It may offer different functionality than just funkySetFields. Turbulent diffusivity addition is important, with the relation to turbulent Schmidt. if there are regions of low nut, the turbulent diffusivity will be low and the molecular diffusivity will dominate. Hence why it is important to keep the molecular diffusivity in there too (I know some threads and books say to just drop that term, but its very simple to keep).


Dan
chegdan is offline   Reply With Quote

Old   August 2, 2018, 20:40
Default Need Help With Vague Tutorial From Wiki
  #13
Member
 
Chris Harding
Join Date: Dec 2016
Posts: 76
Rep Power: 9
HappyS5 is on a distinguished road
Hello,

The link to the tutorial is: http://cfd.at/downloads/FoamTutV4_10-ExampleTen.pdf

I am confused about the sudden need for a T-file in section 3.2.0. I found a T file, but now errors told me that I need DT in transport properties and I don't know how to do that. IN fact, I am new and have never used the T-file or DT specification.

If the above link does not work, try: https://wiki.openfoam.com/T-junction...and_colleagues and download PDF.

Can someone help walk me through the addition of a T-File, etc. Remember, I am new and why I am taking these tutorials.
HappyS5 is offline   Reply With Quote

Old   August 2, 2018, 23:36
Default ScalarTransport seems to be completed by time 1.
  #14
Member
 
Chris Harding
Join Date: Dec 2016
Posts: 76
Rep Power: 9
HappyS5 is on a distinguished road
Hello,

I got the scalarTransportFoam to run, but it only ran when I disabled "streamlines" and altered fvSchemes and fvSolution with example data from "Basic" pitzdaily.

My results look the same as the tutorial results, but there doesn't seem to be any calculation going on in my case. It appears that it immediately jumps to the correct result at 1st calculation. Maybe it is because diffusion is set at 0.01. (I just changed the diffusion to 1e-04 and it still jumped within 10 seconds to an analysis that stayed the same the whole time).

I need to get this correct. I would like to use "streamlines" so that I can use vtk. I want to do a Residence Time Distribution analysis.
HappyS5 is offline   Reply With Quote

Old   August 3, 2018, 02:57
Default
  #15
Senior Member
 
Robert
Join Date: May 2015
Location: Bremen, GER
Posts: 292
Rep Power: 11
RobertHB is on a distinguished road
Hello Chris,
since you got your solver to work, i suppose that you understood the the T-file is the transported species of your simulation. Like any other variable (p,U,nut,...) it needs its own file in your 0-folder. Dt is the diffusion coefficient. The parameter determines how diffusive your transport species behaves (also see Peclet number).

Quote:
Originally Posted by HappyS5 View Post
My results look the same as the tutorial results, but there doesn't seem to be any calculation going on in my case. It appears that it immediately jumps to the correct result at 1st calculation. Maybe it is because diffusion is set at 0.01. (I just changed the diffusion to 1e-04 and it still jumped within 10 seconds to an analysis that stayed the same the whole time).
Your diffusion seems to be to strong. scalarTransportFoam stops solving the underlying equations when your domain is completely saturated. So, when your transport is mainly diffusive, your species T does not need your velocity field to spread (thats the advective transport part of scalarTransportFoam). Thus saturating your domain is a fraction of the time that you expect.
Read up about the Peclet number and about what advective and diffusive transport are. To get a more advective transport, try further reducing the diffusion coefficient. Don't set it to 0. This works in OpenFoam but the results are not comparable. You need a diffusion coefficient to get meaningful results.
Quote:
I would like to use "streamlines" so that I can use vtk. I want to do a Residence Time Distribution analysis.
Maybe this thread can help you? You may not need streamlines after all.
HappyS5 likes this.
__________________
If you liked my answer to your question, please consider leaving a "Like" in return
RobertHB is offline   Reply With Quote

Old   August 4, 2018, 01:32
Default
  #16
Member
 
Chris Harding
Join Date: Dec 2016
Posts: 76
Rep Power: 9
HappyS5 is on a distinguished road
Quote:
Originally Posted by RobertHB View Post


Your diffusion seems to be to strong. scalarTransportFoam stops.
I figured out why my results are immediately presented. I had, because I thought I was suppose to according to the tutorial, copied the last velocity "U" file from a previously run project with a T pipe to my diffusion T-pipe. So, velocity did not need to be calculated.

Apparently, the solver for diffusion were happy with this velocity data because it converged immediately.
HappyS5 is offline   Reply With Quote

Old   August 21, 2020, 10:31
Default recirculating scalar
  #17
Member
 
Rosario Arnau
Join Date: Feb 2017
Location: Spain
Posts: 57
Rep Power: 9
rarnaunot is on a distinguished road
Hi foamers,

I know this is an old post but I have a question about scalars/concentration at scalarTransportFoam solver. I'have seen that there are some experts at this threat so hope one of you can help me:

In my case I have two inlets (Inlet 1 and RecirculationInt) and two outlets (Outlet and RecirculationOutlet).

The flow enters the domain by the Inlet and exits through Outlet but, the flow that enters through Inlet and RecirculationInlet exits the domain through RecirculationOutlet so that the flows going in and out are:

Inlet Flow= Q1 +Q2
RecirculationInlet= Q3
Outlet= -Q1
RecirculationOutlet= -(Q2+Q3)

Now I need to introduce an scalar so that the concentration that goes out through RecirculationOutlet need to enter again in the domain in order to avoid lossing my scalar concentration.

I'm able to calculate the surface concentration of the patch throughout:

Code:
{
Recirc_T
        {

            type            surfaceFieldValue;
            operation       areaIntegrate;
            libs ("libfieldFunctionObjects.so");
            writeArea       yes;
            regionType      patch;
            surfaceFormat   foam;
            name            RecirculationOutlet;
            enabled         true;
            writeControl   writeTime;
            //writeControl   timeStep; //Output every timestep
            //writeInterval   1; //Cada timestep, guarda valor
            valueOutput     true;
            log             false;
            writeFields     no;
            fields          
            ( T)
}
But this is just for post-processing. Does anybody know how to do this?

Thanks!

Last edited by rarnaunot; August 21, 2020 at 10:41. Reason: typo
rarnaunot 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
ScalarTransportFoam for RTD calculations santoo_cfd OpenFOAM Running, Solving & CFD 39 July 12, 2021 01:15
Problem with scalarTransportFoam illistrated using pitzDaily tutorial mlawson OpenFOAM 2 January 18, 2011 13:39
High number of iterations (scalarTransportFoam) Frithjof OpenFOAM Running, Solving & CFD 0 December 8, 2010 04:44
Modified scalarTransportFoam, but result is not right , need help panda60 OpenFOAM 2 December 2, 2009 19:50
flux seems not conserved in my modified scalarTransportFoam danielr OpenFOAM Running, Solving & CFD 3 October 5, 2009 16:05


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