Standard deviation for every time step

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

 April 18, 2012, 05:29 Standard deviation for every time step #1 New Member   shyam prasad Join Date: Mar 2009 Posts: 25 Rep Power: 9 Dear Foamers, I would like to track the standard deviation of a tracer in the domain with respect to time. The following is what I have appended in the controlDict to get the sum(xi-xmean)^2. Later I can manipulate this using excel or python to evaluate the standard deviation. Is there any way I can obtain standard deviation in the function objects itself. /***********************************************/ libs ( "libOpenFOAM.so" // keeps paraFoam happy "libtwoPhaseInterfaceProperties.so" "libinterfaceProperties.so" "libsimpleSwakFunctionObjects.so" "libswakFunctionObjects.so" ); functions ( deviation { type swakExpression; valueType internalField; verbose true; expression "(pow((T-0.0220541),2))"; accumulations (sum); } ); /************************************************** **/

April 18, 2012, 19:05
#2
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,953
Rep Power: 41
Quote:
 Originally Posted by shyam Dear Foamers, I would like to track the standard deviation of a tracer in the domain with respect to time. The following is what I have appended in the controlDict to get the sum(xi-xmean)^2. Later I can manipulate this using excel or python to evaluate the standard deviation. Is there any way I can obtain standard deviation in the function objects itself. /***********************************************/ libs ( "libOpenFOAM.so" // keeps paraFoam happy "libtwoPhaseInterfaceProperties.so" "libinterfaceProperties.so" "libsimpleSwakFunctionObjects.so" "libswakFunctionObjects.so" ); functions ( deviation { type swakExpression; valueType internalField; verbose true; expression "(pow((T-0.0220541),2))"; accumulations (sum); } ); /************************************************** **/
I don't quite get the problem. Is it that you're currently hardcoding Tmean? If all the cells are of equal size (but if they aren't your approach wouldn't have worked too) something like

Code:
```variables (
"Tmean=average(T);"
);
expression "pow((T-Tmean),2)";
accumulations (average);```
should do the trick. For cells of equal size you'll have to use the cell volumes as "probabilities" (that won't work with "average")

But maybe I misunderstood your question

 April 19, 2012, 00:45 #3 New Member   shyam prasad Join Date: Mar 2009 Posts: 25 Rep Power: 9 Thanks Bernhard, Would like to thank you for making swak4Foam available for the openfoam community. functions ( deviation { type swakExpression; valueType internalField; verbose true; expression "(pow((T-0.0220541),2))"; accumulations (sum); } ); I want to use the above sum as below sd = pow(sum,0.5)/no. of cells.

April 19, 2012, 07:39
#4
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,953
Rep Power: 41
Quote:
 Originally Posted by shyam Thanks Bernhard, Would like to thank you for making swak4Foam available for the openfoam community. functions ( deviation { type swakExpression; valueType internalField; verbose true; expression "(pow((T-0.0220541),2))"; accumulations (sum); } ); I want to use the above sum as below sd = pow(sum,0.5)/no. of cells.
"Number of cells" is not available as a function as usually "average" does that anyway. A workaround would be "max(id()+1)" (id() being the number of the cell) but this does NOT work in parallel (as id() is local to the CPU. For this reason there is also no "number of cells"-function)

As I said in the other posting: arithmetic mean only makes sense if all cells are of the same size (otherwise tiny cells have the same "influence" as big cells)

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post miliante OpenFOAM Running, Solving & CFD 132 October 7, 2012 22:50 Leech OpenFOAM Running, Solving & CFD 10 March 29, 2012 15:24 Artex85 OpenFOAM Running, Solving & CFD 9 January 3, 2012 09:06 Burn OpenFOAM 0 July 16, 2009 10:01 liugx212 OpenFOAM Running, Solving & CFD 3 January 4, 2006 19:07

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