|
[Sponsors] |
[swak4Foam] Run time correlation calculation along a plane using swak4foam |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 24, 2018, 06:31 |
Run time correlation calculation along a plane using swak4foam
|
#1 |
Senior Member
Manu Chakkingal
Join Date: Feb 2016
Location: Delft, Netherlands
Posts: 129
Rep Power: 10 |
Hello All
I am interested to monitor the value of my field at center of my geometry and create a field at each time step, which is equal to the product of the field at that location with the value of the field at the center of the domain (calculation of correlation). Code:
C(x,y,z,t) =T(x,y,z,t)* T(x0,y0,z0,t) groovyBC and probe measurement Now I would like to calculate the product of the velocity (y component) at the sensor1 (see below) with the Y-velocity in a particular plane What I tried Create a cloud point. Code:
functions { createMeasurement { type createSampledSet; outputControl outputTime; outputInterval 1; setName sensor1; set { type cloud; axis xyz; points ( (0.01 0.05 0.05) ); } } ...... Code:
UpCorr { functionObjectLibs ("libswakFunctionObjects.so"); type expressionField; outputControl timeStep; outputInterval 1; variables ("UpL{set'sensor1}=(U- UMean);"); expression "U.y*UpL.y"; fieldName UpCorr; verbose true; autowrite true; } What I tried and failed Create a plane as in swakexpression tutorials calculation but try with type expressionfield . Code:
functions { .... UpCorr2 { functionObjectLibs ("libswakFunctionObjects.so"); type expressionField; valueType surface; surfaceName aperturePlane; surface { type plane; basePoint (0.01 0.05 0.05); normalVector (0 1 0); interpolate true; } variables ("UpL{set'sensor1}=(U- UMean);"); expression "U.y*UpL.y"; fieldName UpCorr2; outputControlMode timeStep; outputInterval 1; verbose true; autowrite true; } .... } Thanks in advance
__________________
Regards Manu Last edited by manuc; December 27, 2018 at 07:52. |
|
December 27, 2018, 14:10 |
|
#2 |
Member
Kristjan
Join Date: Apr 2017
Location: Slovenia
Posts: 36
Rep Power: 9 |
If I'm getting this right, you're trying to post-process during runtime. Why not sample the fileld in the points you're interested in and do all the post-processing in python afterwards?
|
|
December 27, 2018, 14:23 |
|
#3 |
Senior Member
Manu Chakkingal
Join Date: Feb 2016
Location: Delft, Netherlands
Posts: 129
Rep Power: 10 |
Yes.What you understood is right. But I am interested in timeaveraged correlation.
<C(x+r,y,z,t)>=<C(x0,y0,z0,t).C(x+r,y,z,t)> For this I need to calculate runtime timeaveraged of the correlation field. If I understand correctly , if I need to do the same in python I need to save a lot of time Instances
__________________
Regards Manu |
|
December 27, 2018, 16:28 |
|
#4 |
Member
Kristjan
Join Date: Apr 2017
Location: Slovenia
Posts: 36
Rep Power: 9 |
Sorry for not going into your swak dictionaries but it seems to me you didn't try the sampling thing which is the simples, I think. Here's what I'd do first and later look for better ways to do it.
1. Sample the the field you're interested in. https://www.openfoam.com/documentati...e/userse21.php Google other sources. grep through $FOAM_TUTORIALS After your simulation is finished, you should have a directory named "postProcessing" in your case directory. Somewhere in there there will be a TXT file with time sequences of your field for all the xyz points you specified. 2. Write the python script. import numpy. Point numpy to the TXT file with genfromtxt https://www.numpy.org/devdocs/refere...enfromtxt.html You should now have a matrix with the time in your first column and field values in other columns. Might get a bit tricky with the vector components. You might either remove all of the parenthesis "()" or read the field with some other utility. See PyFoam. But you should be able to reach a point where you have a matrix with i going through the time intances and j going through your space locations. You'll also want to read a txt file with the xyz coodinates where i is the label of your point and j in [0, 1, 2] is the xyz of that point. You should now be able to calculate all the averages, derivatives, intergrals etc. much more easily than coding with swak. This should work for 100 or 1000 spatial points and let's say 10k time steps. Start with fewer points, fewer time steps, then improve the procedure. |
|
December 27, 2018, 16:47 |
|
#5 |
Senior Member
Manu Chakkingal
Join Date: Feb 2016
Location: Delft, Netherlands
Posts: 129
Rep Power: 10 |
Thanks for the message. I didn't find any tutorial yet which could do expression calculation with sampling along a plane. I don't want the calculation to happen in the whole domain which is costly. I want the correlation to be calculated in the plane interested. Use the temporal average of correlation along the plane or a line in that plane as convergence criteria. So I need to monitor in runtime and can't calculate it after simulation. What i need is to ensure the second order statistics - two point correlation, is statistically steady, which demands the calculation along the plane in runtime. I tried to use functionobject " calculateglobalvariables" . It does calculate the field at every time step only at the plane that I am interested in. But I couldn't manage to calculate it's time average during runtime. Of course , I can calculate once the simulation is complete using MATLAB or python,but then I can't use it as a convergence criteria.
What you suggest is about plotting the data I have at the end as a graph. What I am interested is monitoring this graph during runtime to ensure the statistics is converged. Hope I have made clear on what I am interested. Any suggestion in this direction would be really nice. Regards Manu
__________________
Regards Manu |
|
December 29, 2018, 19:37 |
|
#6 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Calculations on a sampledSurface can be done with swakExpression with "valueType surface;". It is not possible to write out the whole surface values. Only accumulations (min, max, average, median ...). There is a functionObject dumpSwakExpression that would write out all the values (but without the spatial information9 If you want to use an expression as a convergence criterion then the functionObject writeAndEndIfSwakExpression is your friend. Time averaging can be done with storedVariables An elaborate example for convergence checking with swak4Foam can be found in https://openfoamwiki.net/images/7/7b...onTraining.pdf If you are really hardcore there is also the possiblity to use the python-integration Sorry for being a bit cryptic but technically I'm on holiday
__________________
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 |
||
December 30, 2018, 08:14 |
|
#7 |
Senior Member
Manu Chakkingal
Join Date: Feb 2016
Location: Delft, Netherlands
Posts: 129
Rep Power: 10 |
Dear sir
Thanks for the reply. Regards Manu
__________________
Regards Manu |
|
Tags |
correlations, run-time processing, swak4foam, turbulence analysis |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to export time series of variables for one point? | mary mor | OpenFOAM Post-Processing | 8 | July 19, 2017 11:54 |
plot over time | fferroni | OpenFOAM Post-Processing | 7 | June 8, 2012 08:56 |
calculation diverge after continue to run | zhajingjing | OpenFOAM | 0 | April 28, 2010 05:35 |
Could anybody help me see this error and give help | liugx212 | OpenFOAM Running, Solving & CFD | 3 | January 4, 2006 19:07 |
Warning 097- | AB | Siemens | 6 | November 15, 2004 05:41 |