Open pbnh opened 8 years ago
If you simply want to visualize streamlines, you can calculate them in ParaView rather than with OpenFOAM, by using the "stream tracer" filter.
Thanks, we found that, but can we get numerical data from it? We can visualize the streamlines, but that doesn't help us verify and compare our results to the experimental data.
What kind of validation data do you have?
We know the hydraulic residence time of water particles from the inlet to the outlet.
What's the plan for converting streamlines into residence time? Maybe basic Lagrangian particle tracking using particleTracks
would be a better choice. See http://www.cfd-online.com/Forums/openfoam-paraview/82036-do-particle-tracking-paraview.html#post283475
You can most likely choose in particleTracksDict
to write as CSV, which will be easier than VTK to load into some other processing scripts, e.g. with Pandas in Python, to simply calculate the residence time.
It looks like particleTracks requires a Lagrangian solver...does this mean we should use "lagrangian" instead of "simpleFoam"? http://www.openfoam.org/features/lagrangian.php
Is that true? I was under the impression you could just run particleTracks -latestTime
or something after simpleFoam
finished. If not, I would try writing the streamlines to CSV, which will make them easier to manipulate in other code. I recommend using the Pandas library, which is included in the Anaconda Python distribution (3.5). With Pandas you can do something like:
import pandas as pd
# Read CSV data
data = pd.read_csv("postProcessing/streamLines/0/some_file_name.csv")
# Columns of the CSV file can then be accessed using brackets or dot notation
data["time"] == data.time
# Calculate residence time and print the result to the terminal
res_time = data.time[-1] - data.time[0] # probably won't work!
print("Residence time:", res_time)
Ok, thanks Pete! Could we also use Matlab to read in the csv file? Also, we want to know, once the experiment reaches steady state, how long will it take for a water particle to go from the inlet to the outlet? I imagine that's what the difference in times calculated from the streamlines will tell us, right?
Sure, you could read the CSVs with Matlab. I just suggested Python since it's easier to get setup (Linux and Windows), and you can quickly run your script right from the terminal at the end of the simulation with
python res_time.py
assuming the script is named res_time.py
and in the project's root directory.
Streamlines are a little different from particle paths, which are also different from residence times [1, 2]. I don't know much about residence time, but it looks like it can be computed simply by the total volume and flow rate, which for incompressible steady flow is fixed by the inlet boundary condition.
I have the csv streamline files, but I'm not sure what each column means. I thought it would give an x,y, and z coordinate and a velocity magnitude, but the columns are x, U_0, U_1, and U_2.
I think this is defined in system/streamLines.uniformCoeffs.axis
:
uniformCoeffs
{
type uniform;
axis x; //distance;
start (0 .1397 .2286);
end (.2794 .1397 .2286);
nPoints 50;
}
}
If you change axis
from x
to xyz
I believe it will give you all three coordinates of each point along the streamline.
Thanks that worked! There are x,y,and z coordinate points now, but what do the other columns mean? Is the one without any label the velocity magnitude? What is the 0 column? And since the file is from the 95 folder timestep, does this mean that all the data is from that timestep?
If the other columns are U_0,U_1,U_2
, those are velocity components (x, y, z). I would imagine yes, you get a streamline for t=95
, which since it's a steady state simulation isn't really meaningful as a time in seconds.
In the master branch, our code generates a postProcessing folder with .vtk files of streamline data, but how do we use that data to create and analyze an image of the streamlines?