|
6 | 6 | # compute sigma x and y |
7 | 7 | epsn_x = 2.5e-6 |
8 | 8 | epsn_y = 2.5e-6 |
| 9 | +B_multip = [0.5] |
9 | 10 |
|
10 | 11 | filename = '../../PyECLOUD/testing/tests_PyEC4PyHT/headtail_for_test/test_protons/SPS_Q20_proton_check_dipole_3kicks_20150212_prb.dat' |
11 | 12 | B_multip = [0.5] |
@@ -96,30 +97,30 @@ def init_master(self): |
96 | 97 | print 'Bunch initialized.' |
97 | 98 |
|
98 | 99 | #replace particles with HDTL ones |
99 | | - n_part_per_turn = 5000 |
| 100 | + self.n_part_per_turn = 5000 |
100 | 101 | appo = np.loadtxt(filename) |
101 | 102 |
|
102 | | - parid = np.reshape(appo[:,0], (-1, n_part_per_turn))[::self.n_segments,:] |
103 | | - x = np.reshape(appo[:,1], (-1, n_part_per_turn))[::self.n_segments,:] |
104 | | - xp = np.reshape(appo[:,2], (-1, n_part_per_turn))[::self.n_segments,:] |
105 | | - y = np.reshape(appo[:,3], (-1, n_part_per_turn))[::self.n_segments,:] |
106 | | - yp =np.reshape(appo[:,4], (-1, n_part_per_turn))[::self.n_segments,:] |
107 | | - z = np.reshape(appo[:,5], (-1, n_part_per_turn))[::self.n_segments,:] |
108 | | - zp = np.reshape(appo[:,6], (-1, n_part_per_turn))[::self.n_segments,:] |
| 103 | + parid = np.reshape(appo[:,0], (-1, self.n_part_per_turn))[::self.n_segments,:] |
| 104 | + x = np.reshape(appo[:,1], (-1, self.n_part_per_turn))[::self.n_segments,:] |
| 105 | + xp = np.reshape(appo[:,2], (-1, self.n_part_per_turn))[::self.n_segments,:] |
| 106 | + y = np.reshape(appo[:,3], (-1, self.n_part_per_turn))[::self.n_segments,:] |
| 107 | + yp =np.reshape(appo[:,4], (-1, self.n_part_per_turn))[::self.n_segments,:] |
| 108 | + z = np.reshape(appo[:,5], (-1, self.n_part_per_turn))[::self.n_segments,:] |
| 109 | + zp = np.reshape(appo[:,6], (-1, self.n_part_per_turn))[::self.n_segments,:] |
109 | 110 | self.N_turns = len(x[:,0]) |
110 | 111 |
|
111 | 112 | # replace first particles with HEADTAIL ones |
112 | | - bunch.x[:n_part_per_turn] = x[0,:] |
113 | | - bunch.xp[:n_part_per_turn] = xp[0,:] |
114 | | - bunch.y[:n_part_per_turn] = y[0,:] |
115 | | - bunch.yp[:n_part_per_turn] = yp[0,:] |
116 | | - bunch.z[:n_part_per_turn] = z[0,:] |
117 | | - bunch.dp[:n_part_per_turn] =zp[0,:] |
| 113 | + bunch.x[:self.n_part_per_turn] = x[0,:] |
| 114 | + bunch.xp[:self.n_part_per_turn] = xp[0,:] |
| 115 | + bunch.y[:self.n_part_per_turn] = y[0,:] |
| 116 | + bunch.yp[:self.n_part_per_turn] = yp[0,:] |
| 117 | + bunch.z[:self.n_part_per_turn] = z[0,:] |
| 118 | + bunch.dp[:self.n_part_per_turn] =zp[0,:] |
118 | 119 |
|
119 | 120 | # save id and momenta before track |
120 | | - self.id_before = bunch.id[bunch.id<=n_part_per_turn] |
121 | | - self.xp_before = bunch.xp[bunch.id<=n_part_per_turn] |
122 | | - self.yp_before = bunch.yp[bunch.id<=n_part_per_turn] |
| 121 | + self.id_before = bunch.id[bunch.id<=self.n_part_per_turn] |
| 122 | + self.xp_before = bunch.xp[bunch.id<=self.n_part_per_turn] |
| 123 | + self.yp_before = bunch.yp[bunch.id<=self.n_part_per_turn] |
123 | 124 |
|
124 | 125 | # initial slicing |
125 | 126 | from PyHEADTAIL.particles.slicing import UniformBinSlicer |
@@ -151,6 +152,24 @@ def finalize_turn_on_master(self, pieces_treated): |
151 | 152 | for ele in self.non_parallel_part: |
152 | 153 | ele.track(bunch) |
153 | 154 |
|
| 155 | + # id and momenta after track |
| 156 | + id_after = bunch.id[bunch.id<=self.n_part_per_turn] |
| 157 | + xp_after = bunch.xp[bunch.id<=self.n_part_per_turn] |
| 158 | + z_after = bunch.z[bunch.id<=self.n_part_per_turn] |
| 159 | + yp_after = bunch.yp[bunch.id<=self.n_part_per_turn] |
| 160 | + |
| 161 | + # sort id and momenta after track |
| 162 | + indsort = np.argsort(id_after) |
| 163 | + id_after = np.take(id_after, indsort) |
| 164 | + xp_after = np.take(xp_after, indsort) |
| 165 | + yp_after = np.take(yp_after, indsort) |
| 166 | + z_after = np.take(z_after, indsort) |
| 167 | + |
| 168 | + # save results |
| 169 | + import myfilemanager as mfm |
| 170 | + mfm.save_dict_to_h5('particles_at_turn_%d.h5'%self.ring_of_CPUs.i_turn,{\ |
| 171 | + |
| 172 | + |
154 | 173 | # prepare next turn (re-slice) |
155 | 174 | new_pieces_to_be_treated = bunch.extract_slices(self.slicer) |
156 | 175 | orders_to_pass = ['reset_clouds'] |
|
0 commit comments