Пример #1
0
#[ 0.13816452,  0.154     ,  0.16983548,  0.17775321,  0.18567095,0.19358869]
#
#dphi_rms in deg. (324MHz)
#[ 13.95859799,12.80266955,11.30070564,10.92338666,10.59683631,10.79909468]
"""
n_points = len(E0L_E0TL_arr)

use_twiss_weight_x = True
use_twiss_weight_y = True
use_twiss_weight_z = True

res_sizes_trMtrx_arr = []

count = 0
for [E0L, E0TL] in E0L_E0TL_arr:
    trMtrx = Matrix(7, 7)
    bnch02.setParam("E0TL", E0TL)
    bnch02.setParam("E0L", E0L)
    bunch = Bunch()
    bunch_in.copyBunchTo(bunch)
    accLattice.trackBunch(bunch, None, None, bnch02_ind)
    transportMtrxFromInitCoords(bunch, trMtrx, use_twiss_weight_x,
                                use_twiss_weight_y, use_twiss_weight_z)
    twiss_analysis.analyzeBunch(bunch)
    x_rms = math.sqrt(
        twiss_analysis.getTwiss(0)[1] * twiss_analysis.getTwiss(0)[3]) * 1000.
    y_rms = math.sqrt(
        twiss_analysis.getTwiss(1)[1] * twiss_analysis.getTwiss(1)[3]) * 1000.
    z_rms = math.sqrt(
        twiss_analysis.getTwiss(2)[1] * twiss_analysis.getTwiss(2)[3]) * 1000.
    z_to_phase_coeff = bunch_gen.getZtoPhaseCoeff(bunch)
Пример #2
0
#---- now let's prepare array of 4x4 (transport) 
#---- and 6x6 (Twiss params transport) matrices
matrix_arr = []
for ind in range(1,g_func.getSize()):
	z0 = g_func.x(ind-1)
	z1 = g_func.x(ind)
	g0 = g_func.y(ind-1)
	g1 = g_func.y(ind)
	z_avg = (z1+z0)/2
	g_avg = (g0+g1)/2
	g_avg *= charge
	dL = z1-z0
	#print "debug dL=",dL, " y= %12.3f "%y_avg
	#---- this is a transport 4x4 matrix for coordinates x,x',y,y'
	trMtrx = Matrix(4,4)
	k2 = abs(g_avg/Brho)
	kq = math.sqrt(k2)
	sin_kL = math.sin(kq*dL)
	cos_kL = math.cos(kq*dL)
	sinh_kL = math.sinh(kq*dL)
	cosh_kL = math.cosh(kq*dL)
	if(g_avg == 0.):
		trMtrx.set(0,0,1.)
		trMtrx.set(1,1,1.)
		trMtrx.set(2,2,1.)
		trMtrx.set(3,3,1.)
		trMtrx.set(0,1,dL)
		trMtrx.set(2,3,dL)
	else:
		if(g_avg > 0.):
Пример #3
0
qv01_pos_end   = accLattice.getNodePositionsDict()[accLattice.getNodeForName("QV01")][1]
qh02_pos_end   = accLattice.getNodePositionsDict()[accLattice.getNodeForName("QH02")][1]
qv03_pos_end   = accLattice.getNodePositionsDict()[accLattice.getNodeForName("QV03")][1]
qh04_pos_end   = accLattice.getNodePositionsDict()[accLattice.getNodeForName("QH04")][1]


qv01_pos_start   = accLattice.getNodePositionsDict()[accLattice.getNodeForName("QV01")][0]
qh02_pos_start   = accLattice.getNodePositionsDict()[accLattice.getNodeForName("QH02")][0]
qv03_pos_start   = accLattice.getNodePositionsDict()[accLattice.getNodeForName("QV03")][0]
qh04_pos_start   = accLattice.getNodePositionsDict()[accLattice.getNodeForName("QH04")][0]

qv01_pos_center   = (qv01_pos_start + qv01_pos_end)/2.0

#---- qv01_3d    coordinate transformation from the lattice system
transfCoordsMatrix = Matrix(4,4)
transfCoordsMatrix.unit()
dist_from_qv01_center = 0.
transfCoordsMatrix.set(2,3,-dist_from_qv01_center)
qv01_3d.transormfMatrix(transfCoordsMatrix)

#---- qh02_3d    coordinate transformation from the lattice system
transfCoordsMatrix = Matrix(4,4)
transfCoordsMatrix.unit()
dist_from_qv01_center = qh02_pos_end - qv01_pos_end
transfCoordsMatrix.set(2,3,-dist_from_qv01_center)
qh02_3d.transormfMatrix(transfCoordsMatrix)

#---- qv03_3d    coordinate transformation from the lattice system
transfCoordsMatrix = Matrix(4,4)
transfCoordsMatrix.unit()
b_in = Bunch()
b_in.addPartAttr("macrosize")
b_in_has_ms = b_in.hasPartAttr("macrosize")
for i in range(nParticles):
    (x, xp, y, yp, z, dE) = (random.random(), random.random(), random.random(),
                             random.random(), random.random(), random.random())
    b_in.addParticle(x, xp, y, yp, z, dE)
    if (b_in_has_ms):
        b_in.partAttrValue("macrosize", i, 0, random.random())
b_in.addParticle(0., 0., 0., 0., 0., 0.)

#---- Copy the coordinates to the initial coordinates array of Particles Attribute
copyCoordsToInitCoordsAttr(b_in)

#-----set up initial transport matix, later we have to extract it from bunches
mtrxA_init = Matrix(7, 7)
mtrxA_init.zero()
for ix in range(6):
    mtrxA_init.set(ix, 6, 1.0 * ix)
mtrxA_init.set(6, 6, 1.0)
for ix in range(6):
    mtrxA_init.set(ix, ix, 1. * (ix + 1))

mtrxA_init.set(0, 1, 1.5 * .001)
mtrxA_init.set(2, 3, 1.6 * .001)
mtrxA_init.set(4, 5, 1.7 * .001)

mtrxA_init.set(1, 0, 1.4 * .001)
mtrxA_init.set(3, 2, 1.3 * .001)
mtrxA_init.set(5, 4, 1.2 * .001)