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

Residence time distribution (RTD) for dummies

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 3 Post By vanekp

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 6, 2013, 05:07
Default Residence time distribution (RTD) for dummies
  #1
New Member
 
Petr Vaněk
Join Date: Nov 2012
Posts: 7
Rep Power: 14
vanekp is on a distinguished road
Hello foamers,

I'm a total newbie in OpenFOAM and I'm supposed to do a RTD analysis for static mixers with quite a complex geometry. I searched the internet for a week now and I couldn't find the desired information so I'm turning to you, more advanced users.

So far I followed a procedure:
1. Steady-state solution of laminar flow with simpleFoam (which I would like to edit in future to calculate also a temperature transfer).
2. I took the U file from the last time folder and copied it into new case folder into 0.
3. I used scalarTransportFoam on calculated velocity field to inject a tracer T at the inlet boundary.

And now I got stuck with how to evaluate a concentration of the tracer at the outlet boundary so I could create RTD plot.

Could any of you give me a "cook book for dummies" how to proceed with the rest and if there would be any simpler way to deal with it then copying the U file by hand?

Thank you very much for any suggestions.
davibarreira, sourav90 and TeddyL like this.
vanekp is offline   Reply With Quote

Old   March 10, 2013, 12:38
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by vanekp View Post
Hello foamers,

I'm a total newbie in OpenFOAM and I'm supposed to do a RTD analysis for static mixers with quite a complex geometry. I searched the internet for a week now and I couldn't find the desired information so I'm turning to you, more advanced users.

So far I followed a procedure:
1. Steady-state solution of laminar flow with simpleFoam (which I would like to edit in future to calculate also a temperature transfer).
2. I took the U file from the last time folder and copied it into new case folder into 0.
3. I used scalarTransportFoam on calculated velocity field to inject a tracer T at the inlet boundary.

And now I got stuck with how to evaluate a concentration of the tracer at the outlet boundary so I could create RTD plot.

Could any of you give me a "cook book for dummies" how to proceed with the rest and if there would be any simpler way to deal with it then copying the U file by hand?

Thank you very much for any suggestions.
Calculating the average of a field on a patch could be done with the patchAverage-Utility that comes with OpenFOAM (for the written data). Calculating the average during the run can be done with a function object. The two function objects that I know are both part of swak4Foam: patchAverage and patchExpression (more general)

Copying over U: not that I know. There are functionObjects that solve the tracer during the solution of the regular fluid equations, but these won't help you
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   March 11, 2013, 06:15
Default
  #3
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
Hello Vanekp,

Maybe a different approach: if you include a unit source in your scalar transport equation, you get your residence time distribution for the entire volume. In that case, set the value at the inlet at 0, and you will see "fresh" fluid entering.

Regards,
Tom
tomf is offline   Reply With Quote

Old   March 11, 2013, 22:22
Default
  #4
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
Hi Vanekp,

I have done passive scalar transport in a manner similar to what you are doing. To answer your question about the concentration at the boundary:
  1. You will need to measure Mixing-Cup average at the outlet: Instead of just an average concentration at the outlet, you will need to determine a velocity weighted average similar to patchMassFlowAverged function object from simpleFunctionObjects. For an incompressible flow, the mass flow averaged is equal to the velocity-weighted average is equal to the mixing-cup average. This average will most accurately represent an experimental average that you can measure in the lab.
  2. The method of taking the steady-state velocity profile and decoupling the velocity and concentration field only works with the assumption that the tracer and fluid are of exactly the same physichcemical properties...i.e. its a passive scalar .
  3. If you use the function object I suggested, you will be given a text file with two columns that you can plot and visualize over time.

If you decide to move on to turbulent flow modeling, you need a few more things to correctly calculate the RTD. In scalarTransportFoam, you will need to add the affects of turbulence on your passive scalar through a transport equation similar to
Code:
                fvm::ddt(C)
              + fvm::div(phi, C)
	      + fvm::SuSp(-fvc::div(phi), C)
	      - fvm::laplacian(D, C)
              - fvm::laplacian(Dturbulent, C)
This was posted on http://www.cfd-online.com/Forums/ope...tml#post280210 and has worked for me in getting accurate RTD's derived from flows calculated from simpleFoam. Dturbulent is the turbulent viscosity divided by the turbulent Schmidt number (i.e. the gradient diffusion hypothesis). Its a simple solver to program yourself. Good luck!
chegdan is offline   Reply With Quote

Old   March 13, 2013, 04:11
Default
  #5
New Member
 
Petr Vaněk
Join Date: Nov 2012
Posts: 7
Rep Power: 14
vanekp is on a distinguished road
Thank you all for the advice.

I was told the same thing about the patchMassFlowAverage by my colleague. So far I'm interested only in laminar flows, so the adjustment is not yet necessary but in the future I'll have to do it.

So I've set up everything according to the advice, I wrote a very simple shell script, which runs the sequence mySimpleFoam (simpleFoam with added solution of temperature) -> copying the velocity fields U and phi -> running scalarTransportFoam with patchMassFlowAverage function object included. So I'm now able to get the RTD curve quite nicely.

But now I'm dealing with problems with the solution. The velocity fields seem to be calculated well and when I run the scalarTransportFoam at the beginning everything seems to go right and at one point the solution goes totally 'bananas' and the Flow Average gets even negative (and even into range of -1e15) which I don't even understant how is it possible to go negative.

Do any of you have experince with this kind of behaviour and how to resolve it?
vanekp is offline   Reply With Quote

Old   March 13, 2013, 05:16
Default
  #6
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
Hello Vanekp,

Did you also copy the phi file from the latest timestep your simpleFoam run? It is calculated during the simple loop and corrected for conservation of mass instead of interpolated from the velocity field at the startup of scalarTransportFoam. This means you have a divergence free field to start with.

You can test this quite easily by running the solver twice, once with and once without the copied phi field.

Regards,
Tom
tomf is offline   Reply With Quote

Old   March 13, 2013, 09:44
Default
  #7
New Member
 
Petr Vaněk
Join Date: Nov 2012
Posts: 7
Rep Power: 14
vanekp is on a distinguished road
Thank you for the advice.

But yes I have copied both U and phi files. But I found out, that the problem is with the solution as the solution starts to oscilate, so I'm trying to figure out where is the problem, why the solution oscilates
vanekp is offline   Reply With Quote

Old   March 27, 2013, 14:04
Default
  #8
New Member
 
Jonas L. Ansoni
Join Date: Jun 2011
Location: Brazil
Posts: 22
Rep Power: 15
Jonas Ansoni is on a distinguished road
Hello Foamers!!

I'm calculating the RTD as described by Daniel, using patchMassFlowAverged. However, I need these values ​​to calculate the variance. I made a python script to perform these calculations, but I'm having trouble reading the output file, as shown below:

Code:
#       Time       f_in      f_out
      0.002          1          0
      0.004          1 1.923e-122
      0.006          1-3.486e-112
      0.008          1-3.193e-108
       0.01          1 4.059e-107
It is possible to control the printing precision? I've tried changing the writePrecison, but it did not work.

Code:
massFlowAverageC
    {
		type patchMassFlowAverage;
		functionObjectLibs ( "libsimpleFunctionObjects.so" );
		fields ( C );
		patches ( f_in f_out );
		factor 1.0;
		verbose true;
    }
Jonas Ansoni is offline   Reply With Quote

Old   March 27, 2013, 14:15
Default
  #9
New Member
 
Jonas L. Ansoni
Join Date: Jun 2011
Location: Brazil
Posts: 22
Rep Power: 15
Jonas Ansoni is on a distinguished road
Hello Foamers!!

I'm calculating the RTD as described by Daniel, using patchMassFlowAverged. However, I need these values ​​to calculate the variance. I made a python script to perform these calculations, but I'm having trouble reading the output file, because some columns are getting together, as shown below:

Code:
#       Time       f_in      f_out
      0.002          1          0
      0.004          1 1.923e-122
      0.006          1-3.486e-112
      0.008          1-3.193e-108
       0.01          1 4.059e-107
It is possible to control the printing precision? I've tried changing the writePrecison (controlDict), but it didn't work.

Code:
massFlowAverageC
    {
		type patchMassFlowAverage;
		functionObjectLibs ( "libsimpleFunctionObjects.so" );
		fields ( C );
		patches ( f_in f_out );
		factor 1.0;
		verbose true;
    }
Thanks
Jonas Ansoni is offline   Reply With Quote

Old   March 27, 2013, 15:05
Default
  #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
what about making two function objects, one for f_in and another for f_out? they will be in separate folders and files.
chegdan is offline   Reply With Quote

Old   March 27, 2013, 21:50
Default
  #11
New Member
 
Jonas L. Ansoni
Join Date: Jun 2011
Location: Brazil
Posts: 22
Rep Power: 15
Jonas Ansoni is on a distinguished road
Hi Daniel!

Thank you for your prompt reply. I already tried that. The result was as shown below:

Code:
#       Time      f_out
      0.002          0
      0.004 1.923e-122
      0.006-3.486e-112
      0.008-3.193e-108
Best regards
Jonas
Jonas Ansoni is offline   Reply With Quote

Old   April 4, 2013, 06:34
Default
  #12
New Member
 
Petr Vaněk
Join Date: Nov 2012
Posts: 7
Rep Power: 14
vanekp is on a distinguished road
Quote:
Originally Posted by Jonas Ansoni View Post
Hi Daniel!

Thank you for your prompt reply. I already tried that. The result was as shown below:

Code:
#       Time      f_out
      0.002          0
      0.004 1.923e-122
      0.006-3.486e-112
      0.008-3.193e-108
Best regards
Jonas
I might not be the best to talk, but as I think, it should be possible to write a script that gets these values for you. The number of charakters in the lines is always the same. Might that be an idea?
vanekp is offline   Reply With Quote

Old   April 5, 2013, 14:30
Default
  #13
New Member
 
Jonas L. Ansoni
Join Date: Jun 2011
Location: Brazil
Posts: 22
Rep Power: 15
Jonas Ansoni is on a distinguished road
Good idea vanekp!!!

I did this and worked. Follows the python script to read this archive.

Code:
import numpy as np

time, c_out = np.genfromtxt(prjDirC, skiprows = 1, delimiter=(13,13), unpack=True)
Thanks...
Jonas Ansoni is offline   Reply With Quote

Old   May 14, 2014, 16:17
Default
  #14
New Member
 
jeicek
Join Date: Nov 2013
Location: Germany
Posts: 18
Rep Power: 13
jeicek is on a distinguished road
Quote:
Originally Posted by vanekp View Post
Thank you all for the advice.

I was told the same thing about the patchMassFlowAverage by my colleague. So far I'm interested only in laminar flows, so the adjustment is not yet necessary but in the future I'll have to do it.

So I've set up everything according to the advice, I wrote a very simple shell script, which runs the sequence mySimpleFoam (simpleFoam with added solution of temperature) -> copying the velocity fields U and phi -> running scalarTransportFoam with patchMassFlowAverage function object included. So I'm now able to get the RTD curve quite nicely.

But now I'm dealing with problems with the solution. The velocity fields seem to be calculated well and when I run the scalarTransportFoam at the beginning everything seems to go right and at one point the solution goes totally 'bananas' and the Flow Average gets even negative (and even into range of -1e15) which I don't even understant how is it possible to go negative.

Do any of you have experince with this kind of behaviour and how to resolve it?
Hello guys

Can anybody help me?,, How should I implement the patchMassFlowAverage function object?
jeicek is offline   Reply With Quote

Old   May 14, 2014, 16:48
Default
  #15
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 jeicek View Post
Hello guys

Can anybody help me?,, How should I implement the patchMassFlowAverage function object?

By reading through the post online and trying example like the one at

http://www.cfd-online.com/Forums/ope...tml#post416812

and looking at the wiki page here. You will need to compile the libraries outlined in the other post

http://www.cfd-online.com/Forums/ope...tml#post491866
chegdan is offline   Reply With Quote

Old   August 16, 2018, 21:46
Default Calculating RTD and T
  #16
Member
 
Chris Harding
Join Date: Dec 2016
Posts: 76
Rep Power: 10
HappyS5 is on a distinguished road
Hello,

I am doing tutorial 10 from the 3 week tutorial series. It is the RTD tutorial in the series but called tutorial 10.

The author used "ratio of that scalar mass inlet to the whole mass inlet" to calculate average T: http://cfd.at/downloads/FoamTutV4_10-ExampleTen.pdf on page with "Average value of T on the outlet for two inlets versus time" graph. I would like to know what the scalar mass inlet and whole mass inlet is. Is the scalar the "current" time and the whole mass the value placed in the documentation for "T"?

When calculating RTD, the author states: "Next, to obtain the RTD plots, simply calculate the gradient of change in average value of T on the outlet from time 0 to 120s, export the data to Excel, and plot the results." I would like to know how to calculate the gradient of change.

Thanks in advance.

Last edited by HappyS5; August 16, 2018 at 23:48.
HappyS5 is offline   Reply With Quote

Old   May 22, 2020, 08:18
Default
  #17
Senior Member
 
Franco
Join Date: Nov 2019
Location: Compičgne, France
Posts: 129
Rep Power: 7
otaolafr is on a distinguished road
Quote:
Originally Posted by HappyS5 View Post
Hello,

I am doing tutorial 10 from the 3 week tutorial series. It is the RTD tutorial in the series but called tutorial 10.

The author used "ratio of that scalar mass inlet to the whole mass inlet" to calculate average T: http://cfd.at/downloads/FoamTutV4_10-ExampleTen.pdf on page with "Average value of T on the outlet for two inlets versus time" graph. I would like to know what the scalar mass inlet and whole mass inlet is. Is the scalar the "current" time and the whole mass the value placed in the documentation for "T"?

When calculating RTD, the author states: "Next, to obtain the RTD plots, simply calculate the gradient of change in average value of T on the outlet from time 0 to 120s, export the data to Excel, and plot the results." I would like to know how to calculate the gradient of change.

Thanks in advance.
hello, the gradient of change is de derivate, dx/dt. but as it was mentioned before, i think it should be weigthed by the mass flow. as i can not compile the simplefunctionobjects (i should use only what is base in the OF v7) is there any way to achive this easily?
best regards,
franco
otaolafr is offline   Reply With Quote

Old   April 28, 2021, 02:44
Smile RTD Tutorial 10
  #18
New Member
 
Fabián Otálora
Join Date: Apr 2021
Location: Bogotá
Posts: 1
Rep Power: 0
Fabotalora is on a distinguished road
Quote:
Originally Posted by HappyS5 View Post
Hello,

I am doing tutorial 10 from the 3 week tutorial series. It is the RTD tutorial in the series but called tutorial 10.

The author used "ratio of that scalar mass inlet to the whole mass inlet" to calculate average T: http://cfd.at/downloads/FoamTutV4_10-ExampleTen.pdf on page with "Average value of T on the outlet for two inlets versus time" graph. I would like to know what the scalar mass inlet and whole mass inlet is. Is the scalar the "current" time and the whole mass the value placed in the documentation for "T"?

When calculating RTD, the author states: "Next, to obtain the RTD plots, simply calculate the gradient of change in average value of T on the outlet from time 0 to 120s, export the data to Excel, and plot the results." I would like to know how to calculate the gradient of change.

Thanks in advance.
Hello HappyS5, like you some time ago I am trying to do tutorial 10 now.
When I run "scalarTransportFoam" with the conditions indicated by the tutorial after the second iteration the values ​​of T (0 directory) show "nan", did you have this problem or does anyone know how to deal with it?

Thanks in advance!
Fabotalora 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
Residence Time Distribution with Periodic Boundary Conditions sanjose FLUENT 1 September 7, 2016 05:13
calculation the residence time distribution by CFX ahmedsalemy CFX 4 June 25, 2009 11:40
How to get residence time distribution? bigfans FLUENT 0 April 27, 2009 10:39
IcoFoam parallel woes msrinath80 OpenFOAM Running, Solving & CFD 9 July 22, 2007 03:58
Residence time distribution function Roustam Phoenics 3 February 26, 2002 09:47


All times are GMT -4. The time now is 09:19.