forked from PyORBIT-Collaboration/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnalyticTest10.py
57 lines (44 loc) · 1.48 KB
/
AnalyticTest10.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# AnalyticTest10.py
#
# This is run using the initial parameters that Jeff provided and a bunch that
# he has also provided
import sys
from fieldtracker import MagneticFieldTracker3D
from fieldtracker import MultipoleExpansion3D
from bunch import Bunch
print "pyScript -> Begin"
# Initialize the MagneticFieldTracker3D class instance
test = MagneticFieldTracker3D()
# Initialize the Bunch to the proper initial conditions
bunch = Bunch()
bunch.addPartAttr("masscharge")
######### REF PARTICLE (at 1GeV) ########
syncPart = bunch.getSyncParticle()
syncPart.x(0.0);
syncPart.y(0.0);
syncPart.z(0.0);
syncPart.momentum(1696.037); # sets px = py = 0.0 and pz to the argument in (MeV)
######### READ IN BUNCH ########
inputFile = open('Matt_Bunch.dat','r') # open a read-only file
numParticles = 10000 # number of particles to read in
# read particles in
for i in range(numParticles):
temp = inputFile.readline()
lst = temp.split()
bunch.addParticle(float(lst[0]),float(lst[1])*1000.0,float(lst[2]),float(lst[3])*1000.0,
float(lst[4]),float(lst[5])*syncPart.momentum())
bunch.partAttrValue("masscharge",i,1,+1.0)
# Initialize the field
field = MultipoleExpansion3D("Chicane_combined_4c.dat")
# track the particles from foil #1 to foil #2
x_0 = 40.0
y_0 = 23.0
alpha = 0.0
beta = 0.0
gamma = 0.0
angles = test.track(0.309193,2.938333,x_0,y_0,alpha,beta,gamma,bunch,field,0)
# destructor
del bunch
del field
del test
print "pyScript -> Done!"