CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

Mass Weighted Average

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 11, 2012, 13:40
Default Mass Weighted Average
  #1
Member
 
Brock Lee
Join Date: Sep 2012
Location: Midwest
Posts: 40
Rep Power: 10
GRAUPS is on a distinguished road
Hey guys, I'm looking to calculate a mass weighted average over a faceZone for pressure using swak4foam. Specifically, this is the equation I'm trying to implement...

Capture.PNG

My question comes when trying to implement. Is it possible in swak4foam to divide a sum by a sum within one expression? Can I do two sums separately and divide them? So far I've only seen expressions that can do one accumulation, such as the one below for mass flow rate...

Code:
mass-in
    {
        type swakExpression;
        valueType faceZone;
        zoneName interior-inlet-1;
        expression "phi*flip()";
        accumulations (
            sum
        );
        verbose true;
	autoInterpolate	true;
    }
Also, (if possible) what is the syntax for getting the absolute value and dot product within a swakExpression? Thanks in advance!
Attached Images
File Type: jpg Capture.jpg (10.7 KB, 45 views)
GRAUPS is offline   Reply With Quote

Old   December 11, 2012, 17:32
Default
  #2
Member
 
Brock Lee
Join Date: Sep 2012
Location: Midwest
Posts: 40
Rep Power: 10
GRAUPS is on a distinguished road
Ok, I think I found an equivalent expression. The following function I believe does what I need it to do...

Code:
p_stat2
    {
        type swakExpression;
        valueType faceZone;
        zoneName interior-inlet-1;
        expression "(p*phi*flip())/sum(phi*flip())";
        accumulations (
            sum
        );
        verbose true;
	autoInterpolate	true;
    }
However, I would still be interested in knowing if you can perform a dot product or an absolute value within a swakExpression?

Also, does anyone know if when you have backflow on a face, does it register as negative mass flow using the phi*flip() formulation?

Last edited by GRAUPS; December 12, 2012 at 12:37.
GRAUPS is offline   Reply With Quote

Old   December 12, 2012, 18:48
Default
  #3
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,199
Rep Power: 47
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by GRAUPS View Post
Ok, I think I found an equivalent expression. The following function I believe does what I need it to do...

Code:
p_stat2
    {
        type swakExpression;
        valueType faceZone;
        zoneName interior-inlet-1;
        expression "(p*phi*flip())/sum(phi*flip())";
        accumulations (
            sum
        );
        verbose true;
	autoInterpolate	true;
    }
However, I would still be interested in knowing if you can perform a dot product or an absolute value within a swakExpression?

Also, does anyone know if when you have backflow on a face, does it register as negative mass flow using the phi*flip() formulation?
Dot product is according to the conventions of OpenFOAM the &-operator.

Yes. You should get the correct backflow if you use flip() (the sign of phi depends on the orientation of the face. Multiplying with flip() "removes" that dependence)
__________________
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   December 12, 2012, 19:34
Default
  #4
Member
 
Brock Lee
Join Date: Sep 2012
Location: Midwest
Posts: 40
Rep Power: 10
GRAUPS is on a distinguished road
Quote:
Originally Posted by gschaider View Post
Dot product is according to the conventions of OpenFOAM the &-operator.
Awesome, thank you. And using the mag() function on a scalar I found is basically the equivalent of taking the absolute value.

Quote:
Originally Posted by gschaider View Post
Yes. You should get the correct backflow if you use flip() (the sign of phi depends on the orientation of the face. Multiplying with flip() "removes" that dependence)
Fantastic, just wanted to make sure. Thanks for your replies.
GRAUPS is offline   Reply With Quote

Old   November 26, 2015, 04:51
Default
  #5
New Member
 
Join Date: Jul 2013
Posts: 8
Rep Power: 9
Alex2 is on a distinguished road
Dear Foamers,

I want to use groovybc, in order to create a T bc for a reciculation device. To do this I have do calculate the mass-flux-weighted temperature of a face. I use the following code:

PHP Code:
    Auslasslinks_1_5    {        type            groovyBC;        valueExpression "Tein";    variables    "massenstrom=1;Taus{Ansaug_3}=sum(T*phi)/sum(phi);cp=1007;Qdot=100;Tein=Taus-Qdot/(massenstrom*cp);";    fractionExpression "1";        value           uniform 300;        refValue        $value;    } 
Unfurtunately this bc doesn't work and my simulation crashes because of the Taus{Ansaug_3} calculation. If I calculate a faceweighted temperature instead of the mass flux weighted temperature for Taus{Ansaug_3} or if I use Taus instead of Taus{Ansaug_3}, the simulation runs. So my question: Is this a bug in groovybc or is there a bug in my code?

Thank's in advance
Alex2 is offline   Reply With Quote

Old   May 3, 2019, 08:28
Default Mass averaged weighted kinetic energy
  #6
New Member
 
@moon
Join Date: Apr 2019
Posts: 8
Rep Power: 4
TRIDEV G is on a distinguished road
Hi guys
I am trying to calculate mass average weighted kinetic energy for Tank sloshing case.
The equation is similar to the one discussed in this thread.

(summation(mass*0.5*U*U)/ summation (mass))

Can someone help me with the syntax to write this expression using swak4Foam ?

Iam new to openFoam. any help will be highly apreciated.

Thank you.
TRIDEV G is offline   Reply With Quote

Old   May 3, 2019, 09:34
Default
  #7
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,199
Rep Power: 47
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by TRIDEV G View Post
Hi guys
I am trying to calculate mass average weighted kinetic energy for Tank sloshing case.
The equation is similar to the one discussed in this thread.

(summation(mass*0.5*U*U)/ summation (mass))

Can someone help me with the syntax to write this expression using swak4Foam ?

Iam new to openFoam. any help will be highly apreciated.

Thank you.

The expression for the total mass would be (assuming you have the denisty in a field rho) "sum(vol()*rho)". The sum of the kinetic energy would be "sum(vol()*rho*0.5*(U&U))" (using & for the scalar product). Now with swakExpression you could write the complete expression as "(vol()*rho*0.5*(U&U))/sum(vol()*rho)" (without the sum) and in the accumulations-list use "sum". Or you write the equation with the sum and in the accumulations use one of "min", "max", "average". But the first option needs a little less computation
__________________
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   May 6, 2019, 05:38
Default
  #8
New Member
 
@moon
Join Date: Apr 2019
Posts: 8
Rep Power: 4
TRIDEV G is on a distinguished road
Quote:
Originally Posted by gschaider View Post
The expression for the total mass would be (assuming you have the denisty in a field rho) "sum(vol()*rho)". The sum of the kinetic energy would be "sum(vol()*rho*0.5*(U&U))" (using & for the scalar product). Now with swakExpression you could write the complete expression as "(vol()*rho*0.5*(U&U))/sum(vol()*rho)" (without the sum) and in the accumulations-list use "sum". Or you write the equation with the sum and in the accumulations use one of "min", "max", "average". But the first option needs a little less computation
Hello gschaider, Thank you very much for the reply

The equation is writing results perfectly.

But I dont understand the logic behind using summation in the numerator for calculating max, min, average and not using summation for calculating sum (accumulation).

the equation calculates mass average weighted kinetic energy for each cell in the domain for each timestep and calculates sum. where is the difference coming by introducing the summation in the numerator ?

There is something that I am missing out in understanding here.
Can u please explain this??

Thanks in advance
TRIDEV G is offline   Reply With Quote

Old   March 16, 2021, 14:41
Default
  #9
New Member
 
Join Date: Oct 2019
Posts: 11
Rep Power: 3
anthony761 is on a distinguished road
Hello Foamers,

I'm new in OF, I'm studying compressible flows and for post-processing, I just want to have confirmation. I'm not sure about syntax, but I would like to calculate the mass-weighted average of one F variable, defines as \frac{\int F\rho|\vec u \cdot d\vec A|}{\int\rho|\vec u \cdot d\vec A|} at my "r1-outblock-outflow" (patch name)' so is it correct to write in my

controlDict (OpenFOAM v2006)
Code:
    weightAvgOut
    {
        #includeEtc "caseDicts/postProcessing/surfaceFieldValue/surfaceRegion.cfg"
        regionType      patch;
        name            "r1-outblock-outflow";
        operation       weightedAverage;
        weightField     phi;
        fields          (p T Ma total(p));
        writeInterval   5;
        log             true;
    }
Do you think this is right?

Also, does anyone know if OF can provide the total temperature?
anthony761 is offline   Reply With Quote

Reply

Tags
mass weighted average, swak4foam, swakexpression

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
Area weighted or mass weighted average SAM Main CFD Forum 31 April 30, 2018 04:12
Diffference between mass weighted average and Area giogio FLUENT 9 March 6, 2018 08:24
mass weighted average calculation m&s FLUENT 0 April 6, 2010 11:52
Mass Weighted Average Maryam FLUENT 0 November 12, 2008 07:06
Mass Weighted Average Maryam CFX 0 November 12, 2008 07:03


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