Sampling lagrangian data
Hi,
I tried to sample lagrangian data from a simulation with dieselFoam with the sample utility (i.e. with a sampleDict-File). I defined a plane under the keyword 'surfaces' and wanted to sample the diameter of the particles, i.e. choose d under the keyword 'Fields to sample'! When I'm running the utility no date are written!!! When I choose U instead of d everything works fine!! So, it seems that only the sampling of the lagrangian data doesn't work!! Has anybody some hints??? Thanks, Michael |
you have to write your own evaluation code if you want to do that kind of thing
|
oh, well, I have no idea of doing something like that...
I'm wondering that nobody else has that problem! Or is there another/better way to sample the langrangian data like the droplet sizes?? |
Doesn't anybody have a hint how to postprocess lagrangian data??
For example, one of my request is to get the data of the diameter of the droplets in a arbitrary plane! Then, I want this date to use in Matlab!! I hope somebody can help me... Thanks, Michael |
Hi Michael!
The "best" way to postprocess the raw lagrangian data WITHOUT PROGRAMMING is: 1. start paraFoam 2. load the lagrangian data in addition to the "regular" data 3. "Split off" the lagrangian data using the "Extract Block"-filter 4. Open a new view on the result and make that view a "Spreadsheet view". In that view you will see the raw lagrangian data 5. File->Export that view to a CSV-file The CSV can be imported into most programs (OpenOffice-Calc, Origin and I guess also MATLAB) Bernhard |
Thank you, Bernhard!
That's definitely a way to do it!! For the moment that's fine! Thanks again! But I think in the future, I'll don't get out of programming something when I'm dealing with lots of data! So, if there is somebody who has a "more comfortable" solution (i.e. with programming) for that problem I would be still interested!!! Michael |
Quote:
For myself, if there is not too much data (some thousant particles without history data) I use the PyFoam-library to parse/process it. But I may be biased, because I'm on quite good speaking terms with the author so the lack of documentation for the programming interface isn't that big a problem for me Bernhard |
Hi,
I'm using KinematicParticle class for Lagrangian particles and there is even everything ready for you. The function is called dumpParticlePositions() and you may find it around line 500 in the file: src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C Calling this function along with kinematicCloud1.evolve(); in your solver will give you every time step one file with whatever you tell the function to print for all the particles in the coud. I was actually post-processing these files in matlab 2 days ago... good luck matej |
Hi,
using KinematicParticle sounds quite good! Could you please give me some details of how to build this function in my solver and how to tell the function what quantities it should write?? Sorry for so many questions! Thanks, Michael |
it's quite simple, but not for 5 lines.
you may have a look at rhoTurbTwinParcelFoam tutorial which comes with 1.5.x installation for your inpiration. there is a solver calling intermediate clases like kinematicCloud and thermoCloud for solving Lagrangian phase. if you want to print out the data, you can add as I've written previously kinematicCloud1.dumpParticlePositions(); to the main solver where you call kinematicCloud1.evolve(); To specify what to print, you look for that function in src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C file. For example my line n this function looks like: pObj<< "v " << p.d() <<" "<< p.nParticle() <<" "<< p.stk()<<" "<< p.Ur() <<" "<< p.position().x() << " " << p.position().y() << " " where for example p.stk is particle Stokes number, which I defined as an inline function in: parcels/Templates/KinematicParcel/KinematicParcel.H and specified in: parcels/Templates/KinematicParcel/KinematicParcelI.H there you will find other variables which you may be interested in. hope it helps you. good luck matej |
Viewing Re number and relative velocity
Hi,
I want to write relative velocity and Reynolds number of each particle and then plot them,Is there any way? please help me regard |
if you want to plot it in the paraview, the simple way is to calculate it in paraview by constructing your own filter. you can use the available variables in a calculator to construct your own new variable and plot it the paraview.
if you want it to be calculated during the run and written to the field for postprocessing, you have to inicialise the variable and write it at the end of the lagrangian calculation. How to do it would mean to trace in for variable like diameter and do the same for the relative Re. good luck matej |
sampling lagrangian data
Hello Dear matej;
Thank you for your suggestion.I used calculator filter to made a new variable by name of Urel=U(droplet)-U(gas) but just exist U(droplet) in the vector variables and U(gas) is not active and does not exist in the vector variables. For your second suggestion I traced in for variable like diameter and I saw these lines in the parcelIO.C and I think that these lines write output files of particles properties,could you say me how can I add Urel and Re to these properties(d,T,m,y,.....)? I want to write Urel and Re in addition to these values. void Foam:: parcel::writeFields ( const Cloud<parcel>& c ) { Particle<parcel>::writeFields(c); label np = c.size(); IOField<scalar> d(c.fieldIOobject("d"), np); IOField<scalar> T(c.fieldIOobject("T"), np); IOField<scalar> m(c.fieldIOobject("m"), np); IOField<scalar> y(c.fieldIOobject("y"), np); IOField<scalar> yDot(c.fieldIOobject("yDot"), np); IOField<scalar> ct(c.fieldIOobject("ct"), np); IOField<scalar> ms(c.fieldIOobject("ms"), np); IOField<scalar> tTurb(c.fieldIOobject("tTurb"), np); IOField<scalar> liquidCore(c.fieldIOobject("liquidCore"), np); IOField<scalar> injector(c.fieldIOobject("injector"), np); IOField<vector> U(c.fieldIOobject("U"), np); IOField<vector> Uturb(c.fieldIOobject("Uturb"), np); IOField<vector> n(c.fieldIOobject("n"), np); label i = 0; forAllConstIter(Cloud<parcel>, c, iter) { const parcel& p = iter(); d[i] = p.d_; T[i] = p.T_; m[i] = p.m_; y[i] = p.y_; yDot[i] = p.yDot_; ct[i] = p.ct_; ms[i] = p.ms_; tTurb[i] = p.tTurb_; liquidCore[i] = p.liquidCore_; injector[i] = p.injector_; U[i] = p.U_; Uturb[i] = p.Uturb_; n[i] = p.n_; i++; } d.write(); T.write(); m.write(); y.write(); yDot.write(); ct.write(); ms.write(); tTurb.write(); liquidCore.write(); injector.write(); U.write(); Uturb.write(); n.write(); // write the liquid molar fractions if (np > 0) { Cloud<parcel>::const_iterator iter = c.begin(); const parcel& p0 = iter(); label nX = p0.X().size(); const List<word>& names = p0.liquidNames(); for (label j=0; j<nX; j++) { IOField<scalar> X(c.fieldIOobject(names[j]), np); label i = 0; forAllConstIter(Cloud<parcel>, c, iter) { const parcel& p = iter(); X[i++] = p.X()[j]; } X.write(); } } } |
sampling lagrangian data
Hello Dear matej;
Thank you for your suggestion.I used calculator filter to made a new variable by name of Urel=U(droplet)-U(gas) but just exist U(droplet) in the vector variables and U(gas) is not active and does not exist in the vector variables. For your second suggestion I traced in for variable like diameter and I saw these lines in the parcelIO.C and I think that these lines write output files of particles properties,could you say me how can I add Urel and Re to these properties(d,T,m,y,.....)? I want to write Urel and Re in addition to these values. void Foam:: parcel::writeFields ( const Cloud<parcel>& c ) { Particle<parcel>::writeFields(c); label np = c.size(); IOField<scalar> d(c.fieldIOobject("d"), np); IOField<scalar> T(c.fieldIOobject("T"), np); IOField<scalar> m(c.fieldIOobject("m"), np); IOField<scalar> y(c.fieldIOobject("y"), np); IOField<scalar> yDot(c.fieldIOobject("yDot"), np); IOField<scalar> ct(c.fieldIOobject("ct"), np); IOField<scalar> ms(c.fieldIOobject("ms"), np); IOField<scalar> tTurb(c.fieldIOobject("tTurb"), np); IOField<scalar> liquidCore(c.fieldIOobject("liquidCore"), np); IOField<scalar> injector(c.fieldIOobject("injector"), np); IOField<vector> U(c.fieldIOobject("U"), np); IOField<vector> Uturb(c.fieldIOobject("Uturb"), np); IOField<vector> n(c.fieldIOobject("n"), np); label i = 0; forAllConstIter(Cloud<parcel>, c, iter) { const parcel& p = iter(); d[i] = p.d_; T[i] = p.T_; m[i] = p.m_; y[i] = p.y_; yDot[i] = p.yDot_; ct[i] = p.ct_; ms[i] = p.ms_; tTurb[i] = p.tTurb_; liquidCore[i] = p.liquidCore_; injector[i] = p.injector_; U[i] = p.U_; Uturb[i] = p.Uturb_; n[i] = p.n_; i++; } d.write(); T.write(); m.write(); y.write(); yDot.write(); ct.write(); ms.write(); tTurb.write(); liquidCore.write(); injector.write(); U.write(); Uturb.write(); n.write(); // write the liquid molar fractions if (np > 0) { Cloud<parcel>::const_iterator iter = c.begin(); const parcel& p0 = iter(); label nX = p0.X().size(); const List<word>& names = p0.liquidNames(); for (label j=0; j<nX; j++) { IOField<scalar> X(c.fieldIOobject(names[j]), np); label i = 0; forAllConstIter(Cloud<parcel>, c, iter) { const parcel& p = iter(); X[i++] = p.X()[j]; } X.write(); } } } |
sampling lagrangian
any body can help me.
I am still waiting for a response. |
OK if we stick to kinematicCloud class you need to do few thinkg there.
I've played around a bit and here is what you should do: (I'm using 1.5-dev Foam version) In parcels/Templates/KinematicParcel/KinematicParcelI.H : define inline function for your relative Reynolds number, In KinematicParcel.H add this function to a member function list. now you need to tell the code to write this Re number out, so you need to edit KinematicParcelIO.C where you will find two member function - one is for reading the fields and the other is for writting. All you have to do now is to add IOField specification (around line 158) and then add {ReynoldsNumber function name}.write(); line compile and enjoy. I guess about the same you can do also with other particle classes, not only with kinematic one. If I do miss something here, hopefully someone more skilled will correct me. I should add do not do all of this in the main src code. You will make some errors for sure and you want at least something to work. For example I have my local intermediateWORK library which I play around with. good luck matej |
sampling lagrangian
Hello Dear
I try to do your suggustion. There is an inline function to describe Urel like this in parcelI.H: inline vector parcel::Urel(const vector& U) const { return U_ - U; } the problem is to define vector U(gas velocity) in every iteration to inline function for returning Ugas. I add this line from parcel.C : vector Up = sDB.UInterpolator().interpolate(position(), cell()) + Uturb(); after these lines in parcelIO.C file: forAllConstIter(Cloud<parcel>, c, iter) { const parcel& p = iter(); and add these lines to write function of parcelIO.C: IOField<vector> Urel(c.fieldIOobject("Urel"), np); Urel[i] = p.Urel(Up) Urel.write(); exactly like parcelIO.C method, But because I did not declare Up and Uturb() I face errors when I try to compile it. how can I add U (gas velocity) to Urel function[Urel(const vector& U)] when I call it for every iteration? |
Lagrangian particle velocity
Hi,
I am experiencing the same kind of problem in sprayFOAM solver. I want to sample droplet velocity and droplet diameter so I can postprocess in Matlab but I cant seem to find how to sample the lagrangian data since sample cmd works only for eularian phase. Also I cant seem to find 'kinematicCloud1.dumpParticlePositions()' in KinematicCloud.C file. Any help would be really appreciated Tariq |
Hope somebody is able to help me in the topic
|
Hi Everyone!
I am using icoLagrangianFoam solver of foam extend 3.1 in which I have used patch injection method to insert particles over an object. I need to calculate the number of particles getting deposited on the object surface. Can I use function lib in controlDict file for this? |
Quote:
I need to count the particle numbers in a specified area? Do you have any hints? |
Hello Foamer
I am struggling with lagrangian data sampling for sprayFoam, OF2.2.x version. Basically, i want to evaluate size distribution. So want to calculate particle diameter and velocity during run time. can someone guide me about the easiest way to do that....? Thanks |
Quote:
|
Quote:
Did you solve this problem? because I have the same now and I don't know what to do. Asmaa |
Quote:
I did something like this in PyFoam. See slide 148ff in https://openfoamwiki.net/images/0/05...ForTheLazy.pdf (to fully appreciate it a little knowledge of Pandas would be good) |
Quote:
Thank you very much for your quick reply, the presentation is very usefull and respond to a big part of what I need actually!! But in the other hand I need to extract particles that coincide with a circular surface defined by vector axis and radius and then treat those clouds. Do you have an idea how I can achieve this? Regards, Asmaa |
Quote:
|
1 Attachment(s)
Quote:
Thanks for your reply! yes it is post processing. I want to calculate the sauter mean diameter of particles that coincide with the surface below. Actually I am doing it manually using paraview, by clipping 2 cylinders then slice a plane and extract .csv file than calculate the SMD (SMD=sum(d^3)/sum(d^2)). And I have to vary the radius of cylinders at every sampling. So, I find it really painful that's why I am looking for an automatic way to do it. Any hints will be appreciated! Thanks Asmaa |
Quote:
Code:
(data["dist"] **3).sum()/(data["dist"]**2).sum() Reading the particle positions might be problematic with OF 5.0 and v1712 as in those versions the meaning of the positions-file changed. |
Thanks for your prompt responses,
[QUOTE=gschaider;677857] Code:
(data["dist"] **3).sum()/(data["dist"]**2).sum() Concerning the output of the cloud positions I don't know how it is built because it contains more than 3 components!! For exemple: (0 0.02311223035 0.01947409306 0.9574136766) 638 96587 1 Actually I am looking in the samplingSurface and cutting plane to see if I can get something through it! Asmaa |
I too have similar issue! Below is a sample 'positions' output
(0.212065 0.0952962 0.536003 0.156636) 376063 1199337 1 (0.0683043 0.384839 0.287326 0.25953) 415092 1305086 2 Not able to understand what is the data (with four components + three numbers thereafter) that OF is trying to dump in the time directory. In my case the file location is time_dir/lagrangian/reactingCloud1/positions Other files like d, U, T etc in the same directory ( time_dir/lagrangian/reactingCloud1/ ) seems to be in typical format and understandable except the 'positions' file. |
Quick'ish question: I received a private message (PM) from ashrufsyed and I came to take a quick look into this... I've learned from the PM that OpenFOAM-dev is being used... But the problem here is that I'm not familiar with how exactly people are retrieving these position files. @ashrufsyed and/or @foamiste: Please provide instructions on which tutorial case I can look into, so that I can check what's going on here?
Because my guess is that the 1st value is a time value for the particle, but it's just a guess based on other cases. The problem is what time exactly is that. |
Thanks @wyldckat for taking time to have a look at the thread!
I am using fireFoam solver (Version 17.07.24) from the github with the OF-dev (commit 1ff578) For a sample case, you can have a look at the detailedSprinklerInjection case from the github. The 'positions' file is saved in the location time_dir/lagrangian/reactingCloud1/ Regarding the first value, I don't think it correspond to time, because the sample output I posted was for 30s. Also all the four components I get are positive ( at least in my case) whereas my droplet positions actually should have negative x and y values as well |
Quote:
|
Quote:
So the question now will be how can we convert these local barycentric coordinates into the global cartesian system? Since the thread suggests that position() variable during the Cloud calculation gives the actual global coordinates, is it possible to get it directly from the OF I/O file itself (in the form an output file) ? |
Quick answer:
|
I've just gotten through all the posts as I have to do something similar. I need to determine particle properties (mass, d, nParcels, velocity) in different positions inside the domain. Don't you think it might be easier to modify the particleCollector.C file to write other properties of the parcels being collected? I am not a very good programmer but if the parcels going through the polygon can be "collected" and removed from the simulation, you can also print to a file some properties of those parcels.
|
Hello Bernhard,
I am trying to plot Lagrangian data (particle velocity along a line at a particular time) and I came across your answer regarding sampling Lagrangian data. In your answer you mentioned the following: 1. start paraFoam 2. load the lagrangian data in addition to the "regular" data 3. "Split off" the lagrangian data using the "Extract Block"-filter 4. Open a new view on the result and make that view a "Spreadsheet view". In that view you will see the raw lagrangian data 5. File->Export that view to a CSV-file I am able to extract kinematicloud but I am not able to open a new view over that and get the data (step 4). can you please explain a bit more step 4 (may be some screenshots from paraview)? I will be grateful if you or someone can help me to get the particle velocity data along a line. Best Regards Atul Jaiswal |
All times are GMT -4. The time now is 09:55. |