maptrack.py 464 B

1234567891011121314151617181920212223242526
  1. from pytpsa import *
  2. class Drift(object):
  3. def __init__(self,l):
  4. self.l=l
  5. def track(self,m):
  6. m['x']+=self.l*m['px']
  7. return m
  8. class Kick(object):
  9. def __init__(self,k,order=1):
  10. self.k=k
  11. self.order=order
  12. def track(self,m):
  13. m['px']+=self.k*m['x']**self.order
  14. return m
  15. line=[Drift(5),Kick(0.03,1),Kick(.0003,5),Drift(5),Kick(-.03)]
  16. p=polmap(x='0.01+x',px='px')
  17. p['x'].order=1
  18. p['px'].order=1
  19. for elem in line:
  20. p=elem.track(p)