[FLASH-USERS] Plotting particle positions

John ZuHone jzuhone at space.mit.edu
Tue Nov 18 13:43:02 EST 2014


This was my original message to Joshua, but I wasn’t able to get it through to FLASH-USERS until today. I’m including it for posterity.

Hi Joshua,

First, based on what you posted from the Config and flash.par, you should have the particles inside the checkpoint files and the particle files. The reason you’re having trouble finding the particles in the files is because the way they are stored is not quite as obvious as is the case with the grid-based variables. 

The particle data is stored in a HDF5 dataset called “tracer particles” at the top level of the HDF5 file. It is a two-dimensional array of double-precision floats in the shape of (number_of_particles, number_of_particle_attributes). The order of the attributes along that second axis can be found in the top-level dataset “particle names” in the same file. 

Because things are laid out in this way, I would recommend trying to look at the particle data in yt, as it knows a bit more about the structure of FLASH files than VisIt does.  

To load up a checkpoint file in yt, you can do it like this (these instructions are assuming yt version 3.0 or higher):

import yt

ds = yt.load(“name_of_my_checkpoint_file”)

Or, if you have a particle file that was dumped at the same time as a plot file, then you can do it this way:

ds = yt.load(“name_of_my_plotfile”, particle_filename=“name_of_my_particle_file”)

Then, you can look at the raw particle positions from the entire dataset by doing this:

dd = ds.all_data()
print dd[“particle_position_x”]
print dd[“particle_position_y”]
print dd[“particle_position_z”]

or the velocities:

print dd[“particle_velocity_x”]
print dd[“particle_velocity_y”]
print dd[“particle_velocity_z”]

If you want to plot the positions, you can plot them over a slice of a grid variable such as “dens” like this:

slc = yt.SlicePlot(ds, “z”, “dens”) # Sliced along the “z” axis through the center of the domain
slc.annotate_particles(width) # for this you should replace width with the width of the slab you want
slc.save()

which will write a plot to disk. 

For more information, check out the yt docs: http://yt-project.org/doc <http://yt-project.org/doc>

Any other questions, don’t hesitate to write back. 

Best,

John Z
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://flash.rochester.edu/pipermail/flash-users/attachments/20141118/bbfb984f/attachment.htm>


More information about the flash-users mailing list