Closed sszustkowski closed 6 years ago
Hi Sebastian. The particles files are created using Synergia's native diagnostics. Specifically, a call such as the following can be used to add particle diagnostics to the simulation.
opts.turnsPerDiag = 1
particlediag = synergia.bunch.Diagnostics_particles("particles.h5",0,0,opts.output_dir)
bunch_simulator.add_per_turn(particlediag, opts.turnsPerDiag)
After each turn, particle data is dumped into the particles_000#.h5 file as you noted. A helpful exercise may be to open the .h5 file within IPython using tables and to explore the organization. This can be done as follows:
f = tables.open_file(inputfile, 'r')
Generally speaking, the .h5 file is organized heirarchically into a set of groups and datasets. For particles files, the 'root group' provides top level access to datasets and global attributes. In the case of the particles files, there are 7 available datasets, accessible through root:
f.root.particles
- dataset containing the array of particle coordinates in the format [x,px,y,py,z,pz,ID#]f.root.mass
- reference particle mass in GeVf.root.pz
- reference particle momentum in GeV/cf.root.s_n
- s coordinate of the reference particle - ranges from 0 to the lattice length in mf.root.rep
- how many repetitions the particle has travelled through the latticef.root.tlen
- cumulative tracked length in m (equal to f.root.rep[()]*lattice_length +f.root.s_n[()])To access the corresponding values for these datasets, you can use either the command f.root.mass.read()
to grab all particles or a more generic array indexing f.root.particles[(i)]
to get information for the i-th particle.
With regards to constructing your own .h5 files by hand, I would recommend you first check out either the tables documentation or the h5py documentation to familiarize yourself with the two most prominent Python packages for HDF5 manipulation. So long as you construct a .h5 file with the appropriate datasets as documented above, you should have no problem using the rssynergia tools to manipulate the file.
Alternatively, you could use Synergia's bunch constructor to create a bunch that's been matched to a specific lattice (see for example this brief Synergia tutorial).
There are various ways to construct bunch objects in Synergia, so this list is certainly non-exhaustive. Let me know if you have other questions.
I have noticed when I run the 8-2 IOTA example notebook, I see particles_000#.h5 being created in the directory. What is contained in the foo.h5 extension files? Since I would like to create a Poincare section for a macro particle, or even a single particle of n turns as an exercise for myself. -Sebastian