def get_mcf(accelerator, order=1, energy_offset=None): """Return momentum compaction factor of the accelerator""" if energy_offset is None: energy_offset = _np.linspace(-1e-3, 1e-3, 11) accel = accelerator[:] _tracking.set_4d_tracking(accel) ring_length = _lattice.length(accel) dl = _np.zeros(_np.size(energy_offset)) for i in range(len(energy_offset)): fp = _tracking.find_orbit4(accel, energy_offset[i]) X0 = _np.concatenate([fp, [energy_offset[i], 0]]).tolist() T = _tracking.ring_pass(accel, X0) dl[i] = T[0][5] / ring_length polynom = _np.polyfit(energy_offset, dl, order) a = _np.fliplr([polynom])[0].tolist() a = a[1:] if len(a) == 1: a = a[0] return a
def get_mcf(accelerator, order=1, energy_offset=None): """Return momentum compaction factor of the accelerator""" if energy_offset is None: energy_offset = _np.linspace(-1e-3,1e-3,11) accel=accelerator[:] _tracking.set_4d_tracking(accel) ring_length = _lattice.length(accel) dl = _np.zeros(_np.size(energy_offset)) for i in range(len(energy_offset)): fp = _tracking.find_orbit4(accel,energy_offset[i]) X0 = _np.concatenate([fp,[energy_offset[i],0]]).tolist() T = _tracking.ring_pass(accel,X0) dl[i] = T[0][5]/ring_length polynom = _np.polyfit(energy_offset,dl,order) a = _np.fliplr([polynom])[0].tolist() a = a[1:] if len(a) == 1: a=a[0] return a
def length(self): """Lattice length in m""" return _lattice.length(self._accelerator.lattice)