|
[Sponsors] |
how to calculate mass flow rate on patches and summation of that during the run? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 30, 2013, 16:11 |
how to calculate mass flow rate on patches and summation of that during the run?
|
#1 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27 |
I know I have to use such code.but I don't know where should i put this in the OF files.in solver code(where of it?)or controlDict?
Code:
// find the identification number (e.g. label) for our boundary of interest. label inletPatch = mesh.boundaryMesh().findPatchID("velocity_inlet"); // if we don't have such a patch, warn the user if (inletPatch==-1) { Info << "Failure to find patch named velocity_inlet for mass flow calc." <<endl; } else // calculate the result and do output { // the sum operator implicity loops over the boundary faces and stores the result in inFlux // note inflow is negative according to dot product. Lets multiply by -1 to // make it positive. scalar inFlux = -1.0* sum(phi.boundaryField()[inletPatch]); Info << " Inflow= " << inFlux <<" [kg/s] " ; } |
|
March 31, 2013, 06:26 |
|
#3 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27 |
thanks Fumiya
and in this thread http://www.cfd-online.com/Forums/ope...ry-values.html two files are introduced for calculating flow rate during the run. where have to add the include files and the headers themselves in the solver code? |
|
March 31, 2013, 07:06 |
|
#4 |
Senior Member
Join Date: Dec 2011
Posts: 111
Rep Power: 19 |
Although hard-coding this into the solver might give you the data you need, I suppose that it is way much easier to use some of OpenFOAM's run-time postprocessing tools, witch will give you what you need without the need to compile a single line of code.
To calculate the mass flow rates out of a patch/domain you should try something similar to this: https://www.hpc.ntnu.no/display/hpc/...Postprocessing In addition you might want to look at swak4Foam, witch you can use to create complex expressions (used in the note linked to above). If you need to integrate the mass flow over time (to find the total volume of discharged mass) you can do that as a post-processing step (for example in Octave/Matlab or similar tools). Integrating by the trapezoid rule should be straight-forward and probably accurate enough. |
|
March 31, 2013, 08:58 |
|
#5 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27 |
in this link there is the same as above.but where should i add the header files?
http://www.openfoamwiki.net/index.ph...ting_mass_flow |
|
March 31, 2013, 10:36 |
|
#6 |
Senior Member
Join Date: Dec 2011
Posts: 111
Rep Power: 19 |
I really think you should pay more attention to my answers. I certainly expect people to read and find out stuff on their own. That means that I still think you should have a look at this tutorial: https://www.hpc.ntnu.no/display/hpc/...Postprocessing
The reason for me to stress this is that I suspect that your suggested solution, that is creating and compiling a custom-made solver, is way too complicated. The thread you found is from 2005, and the wiki article you link to is not updated since 2006. That is really a long time ago in the OpenFOAM world, and a lot of new features are added since then. Another aspect is that OpenFOAM 1.3 was the newest version in 2006, and you have no guarantees that the code will compile against the 2.x.x-versions of OpenFOAM (without looking at the code at all I would guess that so many things have happened since version 1.3 that it will not compile). My suggested solution is simple, and a more or less verbatim copy of my recommended tutorial:
Good luck. |
|
March 31, 2013, 17:32 |
|
#7 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27 |
thank you very much.the thread seemed somewhat confusing but now your summary is so useful.but
1)I have one inlet and one outlet.how to introduce both patches? 2)since the boundaries are changing during the run I want to calculate mass flow rates between two times.is it possible to calculating of phi like other parameters as: patchAverage -time '.001:.002' variable patchName ? 3)how to calculate total mass balance at the end of run.does the code Code:
accumulations ( sum ); thanks. |
|
April 1, 2013, 04:14 |
|
#8 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27 |
and also i have a compressible fluid.isn't it better to use phi instead of U?
Please Give me a link for other expressions if there is.i haven't found anything. |
|
April 1, 2013, 06:39 |
|
#9 | |||
Senior Member
Join Date: Dec 2011
Posts: 111
Rep Power: 19 |
Quote:
Code:
functions { volFlowInlet { type swakExpression; valueType patch; patchName inletPatchName; verbose true; expression "U&Sf()"; accumulations ( sum ); } volFlowOutlet { type swakExpression; valueType patch; patchName outletPatchName; verbose true; expression "U&Sf()"; accumulations ( sum ); } } Quote:
Have you considered doing a volume integration to get the total mass in the domain at each time? The accumulated/lost mass between the two times will then be just the difference in total mass. Isn't that the easiest way to do it? Quote:
And yes, you can use phi instead of U&Sf(). I have never done any compressible analyses, so all my examples assume constant density (hence volume and mass flow is the same thing). You should watch out for this on your own. |
||||
April 1, 2013, 08:36 |
|
#10 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27 |
thanks a lot.since i hadn't added the functions you mentioned since first how can I obtain mass flow rate now(in the middle of run.I've stopped the run and now need to know the mass flow rates)
|
|
April 1, 2013, 08:40 |
|
#11 |
Senior Member
Join Date: Dec 2011
Posts: 111
Rep Power: 19 |
What do you mean? I don't think i understand. It should be perfectly possible to stop a run (assuming you have some saved fields), add the swak4Foam probes in controlDict and start the run again (remember to set startFrom latestTime in controlDict).
|
|
April 1, 2013, 10:35 |
|
#12 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27 |
the run is reached to a stage that i should check for equality of inflow and outflow to be exactly the same(althogh problem is unsteady compressible since inflow and outflow are in fact connected to combustion chamber that i don't need to simulate but mass since flow rate into and out from combustion chamber should be the same I have to set outflow patch to be closed when the total mass out of it be equal to inflow.it means mass flow rates should be the same.now that the first stage is ended how can i calculate the mass flow rates and modify the settings?
|
|
April 1, 2013, 10:36 |
|
#13 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27 |
and also please see is this correct?
Code:
functions { volFlowInlet { type swakExpression; valueType patch; patchName left; verbose true; expression "phi"; accumulations ( sum ); } volFlowOutlet { type swakExpression; valueType patch; patchName right; verbose true; expression "phi"; accumulations ( sum ); } } |
|
April 1, 2013, 17:25 |
|
#14 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27 |
i corrected it as below functions:
Code:
functions { flowInlet { type swakExpression; valueType patch; patchName left; expression "phi"; accumulations ( sum ); verbose true; } flowOutlet { type swakExpression; valueType patch; patchName right; expression "phi"; accumulations ( sum ); verbose true; } |
|
April 2, 2013, 01:41 |
|
#15 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27 |
dear Hakon.i did what you said.now there is swak folders that have sum of phi on cells from the time i added the function.now how can i obtain phi on before time folders?
Thanks. |
|
April 2, 2013, 04:25 |
|
#16 |
Senior Member
Join Date: Dec 2011
Posts: 111
Rep Power: 19 |
Please, I am not on-line all the time. Be patient. Do not post four follow-up posts. Think before you write. And please also remember that the people here on this forum help you as volunteers, they are not paid consultants. You should re-think the way you ask questions and treat other people. If I answer or helps you, that gives me no further obligations to answer any further questions.
I really think you should learn how to use internet search functionality, both Google and at this forum. Neither me nor other members on this forum am in a position to give you the complete and full answer all the time. In such cases I usually post from my memory, and assume that you are able to do the rest of the work yourself, like correcting bugs and do simple lookups in documentation, user manuals, examples and tutorials. You, on the other hand, simply demand that the people that helps you give you the complete solution all the time. That is not how things work (at least not for me). I really think you should consider a visit to this forum: http://www.cfd-online.com/Forums/cfd-freelancers/ Btw: I think the answer to your question is the tool execFlowFunctionObjects |
|
April 2, 2013, 06:43 |
|
#17 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27 |
im sorry my friend.we are here to help eachother.i only propound my question to reach an answer for myself and for others need it now or in future.its nice to remember we god belivers in all religions believe that all knowledge page we write or learn someone remains and help us in other world.the knowledge value is higher than this assumpsions and comparison to money.
Thank you very much again for posts |
|
April 2, 2013, 09:45 |
|
#18 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27 |
the command execFlowFunctionObjects gives this error:
Code:
--> Upgrading k to employ run-time selectable wall functions --> FOAM Warning : --> FOAM FATAL IO ERROR: cannot find file file: /home/ehsan/Desktop/WR_pimple_limited/0.000534/k at line 0. From function regIOobject::readStream() in file db/regIOobject/regIOobjectRead.C at line 73. Time = 0.000535 Reading phi Reading U Reading p Selecting thermodynamics package { type hePsiThermo; mixture pureMixture; transport sutherland; thermo janaf; equationOfState perfectGas; specie specie; energy sensibleEnthalpy; } Selecting RAS turbulence model kOmegaSST --> Upgrading k to employ run-time selectable wall functions --> FOAM Warning : --> FOAM FATAL IO ERROR: cannot find file file: /home/ehsan/Desktop/WR_pimple_limited/0.000535/k at line 0. From function regIOobject::readStream() in file db/regIOobject/regIOobjectRead.C at line 73. Time = 0.000536 Reading phi Reading U Reading p Selecting thermodynamics package { type hePsiThermo; mixture pureMixture; transport sutherland; thermo janaf; equationOfState perfectGas; specie specie; energy sensibleEnthalpy; } Selecting RAS turbulence model kOmegaSST --> Upgrading k to employ run-time selectable wall functions --> FOAM Warning : --> FOAM FATAL IO ERROR: cannot find file file: /home/ehsan/Desktop/WR_pimple_limited/0.000536/k at line 0. From function regIOobject::readStream() in file db/regIOobject/regIOobjectRead.C at line 73. Time = 0.000537 Reading phi Reading U Reading p Selecting thermodynamics package { type hePsiThermo; mixture pureMixture; transport sutherland; thermo janaf; equationOfState perfectGas; specie specie; energy sensibleEnthalpy; } Selecting RAS turbulence model kOmegaSST --> Upgrading k to employ run-time selectable wall functions --> FOAM Warning : --> FOAM FATAL IO ERROR: cannot find file file: /home/ehsan/Desktop/WR_pimple_limited/0.000537/k at line 0. From function regIOobject::readStream() in file db/regIOobject/regIOobjectRead.C at line 73. Time = 0.000538 Reading phi Reading U Reading p Selecting thermodynamics package { type hePsiThermo; mixture pureMixture; transport sutherland; thermo janaf; equationOfState perfectGas; specie specie; energy sensibleEnthalpy; } Selecting RAS turbulence model kOmegaSST --> Upgrading k to employ run-time selectable wall functions --> FOAM Warning : --> FOAM FATAL IO ERROR: cannot find file file: /home/ehsan/Desktop/WR_pimple_limited/0.000538/k at line 0. From function regIOobject::readStream() in file db/regIOobject/regIOobjectRead.C at line 73. Time = 0.000539 Reading phi Reading U Reading p Selecting thermodynamics package { type hePsiThermo; mixture pureMixture; transport sutherland; thermo janaf; equationOfState perfectGas; specie specie; energy sensibleEnthalpy; } Selecting RAS turbulence model kOmegaSST --> Upgrading k to employ run-time selectable wall functions --> FOAM Warning : --> FOAM FATAL IO ERROR: cannot find file file: /home/ehsan/Desktop/WR_pimple_limited/0.000539/k at line 0. From function regIOobject::readStream() in file db/regIOobject/regIOobjectRead.C at line 73. Time = 0.00054 Reading phi Reading U Reading p Selecting thermodynamics package { type hePsiThermo; mixture pureMixture; transport sutherland; thermo janaf; equationOfState perfectGas; specie specie; energy sensibleEnthalpy; } Selecting RAS turbulence model kOmegaSST --> Upgrading k to employ run-time selectable wall functions --> FOAM Warning : --> FOAM FATAL IO ERROR: cannot find file file: /home/ehsan/Desktop/WR_pimple_limited/0.00054/k at line 0. From function regIOobject::readStream() in file db/regIOobject/regIOobjectRead.C at line 73. Last edited by immortality; April 2, 2013 at 10:20. |
|
April 2, 2013, 16:15 |
|
#19 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27 |
its odd if nothing has made yet for mass flux post processing after run.then should i delete all folders and begin from zero again to write mass flux in folders?
|
|
April 2, 2013, 19:32 |
|
#20 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27 |
if anyone knows a post processing keyword or function please guide me.
Thanks all. |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|