def test_particle_reference(): p = Particles() p.beta0 = 0.91 err = abs(p.p0c**2 + p.mass0**2 - p.energy0**2) / p.mass0**2 assert err == 0 p.beta0 = 0.9101 err = abs(p.p0c**2 + p.mass0**2 - p.energy0**2) / p.mass0**2 assert err < 1.17e-15 p.gamma0 = 1.99 err = abs(p.p0c**2 + p.mass0**2 - p.energy0**2) / p.mass0**2 assert err == 0 p.energy0 = 2 * p.mass0 err = abs(p.p0c**2 + p.mass0**2 - p.energy0**2) / p.mass0**2 assert err == 0 p.p0c = 0.1 * p.mass0 err = abs(p.p0c**2 + p.mass0**2 - p.energy0**2) / p.mass0**2 assert err == 0
p.x,p.px, p.y,p.py, p.tau,p.pt,p.delta, p.chi,p.qratio,p.mratio, p.e0,p.p0c,p.m0)) fh.close() # Load machine description sps=eval(open('sps.dat').read()) # particle starting conditions pstart=Particles( x =5e-3, px=0, y =-3e-3, py=0, tau=0.74, pt=0, e0=26.01692438e9, m0=0.93827205e9, mathlib=math) # element-by-element tracking ptrack=[]; p=pstart.copy() for iel,el in enumerate(sps.elems): ptrack.append(p.copy()) el.track(p) savedata(ptrack,'elem-by-elem2.dat.gz') # many turn tracking
p.m0, )) fh.close() # Load machine description sps = eval(open("sps.dat").read()) # particle starting conditions npart = 15 pstart = Particles( x=np.linspace(0, 5e-3, npart), px=np.zeros(npart), y=np.linspace(0, -3e-3, npart), py=np.zeros(npart), tau=0.74 * np.ones(npart), pt=np.zeros(npart), e0=26.01692438e9, m0=0.93827205e9, ) # element-by-element tracking ptrack = [] p = pstart.copy() for iel, el in enumerate(sps.elems): ptrack.append(p.copy()) el.track(p) savedata(ptrack, "elem-by-elem.dat.gz")
def test_particle_init(): p = Particles() print(p)
from pysixtrack import Particles p = Particles()