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/)
-   -   Standard deviation for every time step (https://www.cfd-online.com/Forums/openfoam-solving/100000-standard-deviation-every-time-step.html)

shyam April 18, 2012 05:29

Standard deviation for every time step
 
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);
}
);
/************************************************** **/

gschaider April 18, 2012 19:05

Quote:

Originally Posted by shyam (Post 355325)
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

shyam April 19, 2012 00:45

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.

gschaider April 19, 2012 07:39

Quote:

Originally Posted by shyam (Post 355509)
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)


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