-
Notifications
You must be signed in to change notification settings - Fork 4
Populate
Sajid Ali edited this page Oct 19, 2022
·
1 revision
A newly created bunch has its all particle coordinates initialized to 0.0
.
- User may choose to populate the particle coordinates by directly accessing the particle data as shown in previous section.
particles = bunch.get_particles_numpy()
particles[:, 0] = 0.01
particles[:, 1:6] = 0.0
# sync to device
bunch.checkin_particles()
-
Synergia
also provides a range of bunch populate methods to initialize the particle to certain distributions. For example, the following one populate a bunch with given means and covariances,
# mean and covariance matrix. The covariances matrix is 6x6
bunch_means = np.zero(6, dtype='d')
bunch_covariances = np.array([[...], [...], [...], [...], [...], [...]])
# use the provided random number generator with an integer value of seed
dist = synergia.foundation.PCG_random_distribution(seed)
# populate a Gaussian bunch
synergia.bunch.populate_6d(dist, bunch, bunch_meas, bunch_covariances)
- A bunch can also be initialized from reading a generated particle file. The size of the bunch will be adjusted to fit all particles from the particle file.
bunch.read_file("turn_particles_0000.h5")