<commit_before>import sys; sys.path.append('../')
sys.path.append('../../pyoptics/')

import sixtracklib
import numpy as np

import tfsdata

twdict = tfsdata.open('twiss.out')

machine = sixtracklib.CBlock()

for i_ele, name in enumerate(twdict['name']):
	if twdict['keyword'][i_ele]=='MULTIPOLE':
		machine.add_Multipole(name=name, knl=[0.0,twdict['k1l'][i_ele]])
	elif twdict['keyword'][i_ele]=='DRIFT':
		machine.add_Drift(name=name, length=twdict['l'][i_ele])
	else:
		print('Skipped: %s'%name)

bunch=sixtracklib.CParticles(npart=2)
bunch.x[0]=0.3
bunch.y[0]=0.2

particles,ebe,tbt=machine.track_cl(bunch,nturns=1024,elembyelem=None,turnbyturn=True)

import numpy.fft as fft
spec_x = fft.fft(tbt.x[:,0])
freq = fft.fftfreq(len(spec_x))
spec_y = fft.fft(tbt.y[:,0])


import matplotlib.pyplot as pl
pl.close('all')
pl.figure(1)
ax1 = pl.subplot(2,1,1)
pl.plot(tbt.x[:,0])
ax2 = pl.subplot(2,1,2, sharex=ax1)
pl.plot(tbt.y[:,0])

pl.figure(2)
axf1 = pl.subplot(2,1,1)
pl.plot(freq, np.abs(spec_x))
axf2 = pl.subplot(2,1,2, sharex=axf1)
pl.plot(freq, np.abs(spec_y))

pl.show()<commit_msg>I would like to have longitudinal motion...<commit_after>import sys; sys.path.append('../')
sys.path.append('../../pyoptics/')

import sixtracklib
import numpy as np

from scipy.constants import c as c_light
pmass_eV = 938.272046e6

V_RF = 100e6
lag_RF = 0.5
h_RF = 9000



import tfsdata

twdict = tfsdata.open('twiss.out')

machine = sixtracklib.CBlock()

length = twdict['param']['length'] 
f_RF = h_RF*c_light/(length)

#machine.add_Cavity(voltage=V_RF,frequency=f_RF,lag=lag_RF)

for i_ele, name in enumerate(twdict['name']):
	if twdict['keyword'][i_ele]=='MULTIPOLE':
		machine.add_Multipole(name=name, knl=[twdict['k0l'][i_ele],twdict['k1l'][i_ele]], 
								angle = twdict['k0l'][i_ele])
	elif twdict['keyword'][i_ele]=='DRIFT':
		machine.add_Drift(name=name, length=twdict['l'][i_ele])
	else:
		print('Skipped: %s'%name)




p0c_eV = 6500e9
gamma0 = np.sqrt(p0c_eV**2+pmass_eV**2)/pmass_eV
beta0 = p0c_eV/np.sqrt(p0c_eV**2+pmass_eV**2)

delta = 0.#1e-3
rpp = 1./(delta+1)
pc_eV = p0c_eV/rpp
gamma = np.sqrt(1. + (pc_eV/pmass_eV)**2)
beta = np.sqrt(1.-1./gamma**2)
rvv=beta/beta0
psigma = pmass_eV*(gamma-gamma0)/(beta0*p0c_eV)

bunch=sixtracklib.CParticles(npart=1, 
		p0c=p0c_eV,
		beta0 = beta0,
		gamma0 = gamma0,
		delta = delta,
		rvv = rvv,
		rpp = rpp,
		psigma = psigma)
bunch.x[0]=0.3
bunch.y[0]=0.2

particles,ebe,tbt=machine.track_cl(bunch,nturns=1024,elembyelem=None,turnbyturn=True)

import numpy.fft as fft
spec_x = fft.fft(tbt.x[:,0])
freq = fft.fftfreq(len(spec_x))
spec_y = fft.fft(tbt.y[:,0])


import matplotlib.pyplot as pl
pl.close('all')
pl.figure(1)
ax1 = pl.subplot(2,1,1)
pl.plot(tbt.x[:,0])
ax2 = pl.subplot(2,1,2, sharex=ax1)
pl.plot(tbt.y[:,0])

pl.figure(2)
axf1 = pl.subplot(2,1,1)
pl.plot(freq, np.abs(spec_x))
axf2 = pl.subplot(2,1,2, sharex=axf1)
pl.plot(freq, np.abs(spec_y))

pl.figure(3)
axl1 = pl.subplot(2,1,1)
pl.plot(tbt.delta[:,0])


pl.show()
{'fraction_non_alphanumeric': 0.20033500837520937, 'fraction_numerical': 0.04623115577889447, 'mean_word_length': 5.577092511013216, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3495000', 'n_tokens_mistral': 1498, 'n_tokens_neox': 1444, 'n_words': 203}