-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrun1.py
executable file
·92 lines (63 loc) · 2.3 KB
/
run1.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import sys
import os
import math
from orbit.teapot_base import TPB
from orbit.utils import orbitFinalize
from orbit.lattice import AccLattice, AccNode,\
AccActionsContainer, AccNodeBunchTracker
from bunch import Bunch
from orbit.utils.orbit_mpi_utils import\
bunch_orbit_to_pyorbit, bunch_pyorbit_to_orbit
from orbit.teapot import TEAPOT_Lattice
from orbit.teapot import BaseTEAPOT
from libptc_orbit import *
from ext.ptc_orbit import PTC_Lattice
from ext.ptc_orbit import PTC_Node
from ext.ptc_orbit.ptc_orbit import setBunchParamsPTC, readAccelTablePTC,\
readScriptPTC, updateParamsPTC, synchronousSetPTC, synchronousAfterPTC,\
trackBunchThroughLatticePTC, trackBunchInRangePTC
PTC_File = "MAIN_1_5_KIND7_1"
length_of_name = len(PTC_File)
ptc_init_(PTC_File, length_of_name - 1)
Lattice = PTC_Lattice("TestCase")
Lattice.readPTC(PTC_File)
print Lattice.getLength(), Lattice.betax0, Lattice.betay0, Lattice.alphax0, Lattice.alphay0, Lattice.etax0, Lattice.etapx0
PhaseLength = Lattice.getLength()
print Lattice.getLength(), PhaseLength
"""
for node in Lattice.getNodes():
print node.getType(), node.getLength(), node.getParam("node_index"), node.getParam("betax"), node.getParam("betay"), node.getParam("alphax"), node.getParam("alphay"), node.getParam("etax"), node.getParam("etapx")
"""
b = Bunch()
print "Read Bunch."
runName = "PTC Test"
setBunchParamsPTC(b)
kin_Energy = b.getSyncParticle().kinEnergy()
print kin_Energy, b.charge(), b.mass()
total_macroSize=1.0e+10
bunch_orbit_to_pyorbit(Lattice.getLength(), kin_Energy, "bunch.dat", b)
nParticlesGlobal = b.getSizeGlobal()
b.macroSize(total_macroSize/nParticlesGlobal)
print nParticlesGlobal, b.macroSize()
"""
Acc_File = "ACCWAVE_40kV_280kV_350ms.DAT"
readAccelTablePTC(Acc_File)
"""
updateParamsPTC(Lattice, b)
synchronousSetPTC(-1)
"""
synchronousAfterPTC(-1)
"""
Turns = 100
for i in range(Turns):
print i
trackBunchThroughLatticePTC(Lattice, b, PhaseLength)
"""
trackBunchInRangePTC(Lattice, b, PhaseLength, 0, 500)
trackBunchInRangePTC(Lattice, b, PhaseLength, 501, 932)
trackBunchInRangePTC(Lattice, b, PhaseLength, 0, 10)
trackBunchInRangePTC(Lattice, b, PhaseLength, 11, 20)
trackBunchInRangePTC(Lattice, b, PhaseLength, 21, 932)
"""
b.dumpBunch("bunch_temp.dat")
bunch_pyorbit_to_orbit(Lattice.getLength(), b, "bunch_final.dat")