b.copyBunchTo(b1)

twiss_analysis = BunchTwissAnalysis()

twiss_analysis.analyzeBunch(b)
print "============before=================="
print "X Twiss =", twiss_analysis.getTwiss(0)
print "Y Twiss =", twiss_analysis.getTwiss(1)
print "Z Twiss =", twiss_analysis.getTwiss(2)
#b.dumpBunch()

G = 30.0  # [T/m]
length = 0.1  # [m]
fieldSource = FieldSource(G)
tracker = RungeKuttaTracker(length)
print "Tracker Entrance plane (a,b,c,d)=", tracker.entrancePlane()
print "Tracker Exit     plane (a,b,c,d)=", tracker.exitPlane()
# the spatial eps is useless because we have quad field = 0 on axis for the syncPart
#tracker.spatialEps(0.00000000001)
# we have to specify the number of time steps
tracker.stepsNumber(40)
tracker.trackBunch(b, fieldSource)

twiss_analysis.analyzeBunch(b)
print "============after RK4 quad tracker==========="
print "Runge-Kutta N steps=", tracker.stepsNumber()
print "X Twiss =", twiss_analysis.getTwiss(0)
print "Y Twiss =", twiss_analysis.getTwiss(1)
print "Z Twiss =", twiss_analysis.getTwiss(2)
#b.dumpBunch()
示例#2
0
b.addParticle(0.002, 0.001, 0.002, 0.001, 0.005, 0.)
b.addParticle(0.0, 0.0, 0.0, 0., -0.005, 0.)

b.compress()

print "initial syncPart (px,py,pz) =", (syncPart.px(), syncPart.py(),
                                        syncPart.pz())

length = grid2D_Ez.getMaxX() - grid2D_Ez.getMinX()

tracker = RungeKuttaTracker(length)
#-------------------------------------------------------------------------------
# for the symmetric fields (if zSimmetric == +1) the grid2D has only z = 0,z_max
#-------------------------------------------------------------------------------
if (fieldSource.getSymmetry() == 1):
    tracker.entrancePlane(0, 0, -1., -grid2D_Ez.getMaxX())
else:
    tracker.entrancePlane(0, 0, -1., grid2D_Ez.getMinX())
tracker.exitPlane(0, 0, 1., -grid2D_Ez.getMaxX())
tracker.spatialEps(0.0000001)
tracker.stepsNumber(60)

print "Entrance plane (a,b,c,d)=", tracker.entrancePlane()
print "Exit     plane (a,b,c,d)=", tracker.exitPlane()
print "Length[m]=", tracker.length()

b1 = Bunch()
b.copyBunchTo(b1)

nParts = 10
s_start = grid2D_Ez.getMinX()
示例#3
0
#---- as (r_vector - r0_vector)*n_vector = 0
#---- where n_vector is a normal vector to the plane
#---- For all planes these normal vectors should be directed to the
#---- outer space.
length = qh04_pos_end - qv01_pos_start
tracker = RungeKuttaTracker(length)

#------------------------------------------------------------------------
#----- This is accuracy parameter in meters for the synchronous particle
#----- tracking using RK4. In normal circumstances it defines the
#----- size of time steps for integration, but here it is useless
#----- because the field on the axis is equal to zero.
tracker.spatialEps(0.001)

#----- palnes setup
tracker.entrancePlane(0., 0., -1., (qv01_pos_start - qv01_pos_center))
tracker.exitPlane(0., 0., 1., -(qh04_pos_end - qv01_pos_center))
print "Tracker Entrance plane (a,b,c,d)=", tracker.entrancePlane()
print "Tracker Exit     plane (a,b,c,d)=", tracker.exitPlane()

# we have to specify an initial guess for number of time steps
tracker.stepsNumber(10000)

bunch_tmp = Bunch()
bunch_ini.copyBunchTo(bunch_tmp)

n_space_parts = 1
(a_entr, b_entr, c_entr, d_entr) = tracker.entrancePlane()
(a_exit, b_exit, c_exit, d_exit) = tracker.exitPlane()
d_start = -d_entr
d_stop = d_exit
b.addParticle(0.,0.,0.,0.,0.,P)
b.compress()

# radius estimation
R = P*1.0e9/(c_light*b.charge()*1.0)
print "R[m] = ",R
n_step = 1000
time_step = (2*3.1415926*R/(c_light*P/E))/n_step

fS = FieldSource()
extEff = ExternalEffects()
print "ExternalEffects name=",extEff.name()

tracker = RungeKuttaTracker(10000.0)
print "Entrance plane (a,b,c,d)=",tracker.entrancePlane()
print "Exit     plane (a,b,c,d)=",tracker.exitPlane()
print "Length[m]=",tracker.length()

print "Start tracking."
time_start = 0.
time_max = time_step*n_step
print "================================================"
print "Step_Index    x     y   z "
tracker.track(b,time_start, time_max, time_step,fS,extEff)
print "================================================"
print "Stop tracking."

print "time step=",tracker.timeStep()
print "Stop."
b.addParticle(0.002,0.001,0.002,0.001,0.005,0.)
b.addParticle(0.0,0.0,0.0,0.,-0.005,0.)

b.compress()

print "initial syncPart (px,py,pz) =",(syncPart.px(),syncPart.py(),syncPart.pz())

length = grid2D_Ez.getMaxX()-grid2D_Ez.getMinX()

tracker = RungeKuttaTracker(length)
#-------------------------------------------------------------------------------
# for the symmetric fields (if zSimmetric == +1) the grid2D has only z = 0,z_max
#-------------------------------------------------------------------------------
if(fieldSource.getSymmetry() == 1):
	tracker.entrancePlane(0,0,-1.,-grid2D_Ez.getMaxX())
else:
	tracker.entrancePlane(0,0,-1.,grid2D_Ez.getMinX())
tracker.exitPlane(0,0,1.,-grid2D_Ez.getMaxX())
tracker.spatialEps(0.0000001)
tracker.stepsNumber(60)

print "Entrance plane (a,b,c,d)=",tracker.entrancePlane()
print "Exit     plane (a,b,c,d)=",tracker.exitPlane()
print "Length[m]=",tracker.length()
	
b1 = Bunch()
b.copyBunchTo(b1)

nParts = 10
s_start = grid2D_Ez.getMinX()