Pull requests

#36 Merged
Deleted repository
active_particles (f12c71412a1b)
enzo/enzo-3.0 enzo-3.0

Active Particle Type Counts

  1. Stephen Skory

This PR adds two new lines to the restart parameter file that lists the kind and label of particle types in the simulation. These values are read but not stored upon restart because they are calculated on the fly. This change is motivated primarily to make particle data access easier in yt. Example:

PresentParticleTypes  = DarkMatter GalaxyParticle 
ParticleTypeCounts    = 262144 1

I am not married to doing it this way (introducing the new global array GlobalActiveParticlesTypeCount), but this seemed the most straightforward.


I should have added that this is different from AppendActiveParticleType is that PresentParticleTypes lists what types are actually is being written to disk, while the former lists what is * eligible* for creation.

Update 2:

Changes in response to Matt's very useful comments.

Update 3:

After thinking about this for a couple days, I agreed with Nathan's earlier comments that calling ActiveParticleFindAll would be unnecessarily expensive. Therefore I have vastly modified how I'm doing things. Instead of a global active particle type count array, I've added ActiveParticleTypeCount attached to each grid, and modified the grid hierarchy text file accordingly. Right now this array is only updated whenever CommunicationSyncNumberOfParticles is called (so that makes an effective global type count possible if needed), which is sufficient for the current purpose of writing the information to disk. It would not be terribly difficult to add hooks to particle creation/destruction/movement so that the array stays synched more often. Here's what the particle lines in a new grid entry look like:

NumberOfParticles   = 2272
NumberOfActiveParticles = 1
PresentParticleTypes = DarkMatter GalaxyParticle (****)
ParticleTypeCounts = 2272 1 (****)
ParticleFileName = ./DD0047/data0047.cpu0002

I've starred the new lines. Perhaps someday the first two lines above can be removed as they are now superfluous.

I am about to issue a PR of changes to yt 3.0 that parses these changes and, as far as I can tell, means that yt 3.0 can handle grids with multiple kinds of active particles.

  • Learn about pull requests

Comments (3)

  1. Nathan Goldbaum

    This is great! Thanks for thinking through this Stephen.

    I think this will work in general but it's not clear that CommunicationSyncNumberOfParticles will necessarily be called in serial or statically refined runs. I'll do some quick tests to check and will update later.