Пример #1
0
def getAxisFieldFunction(fl_name):
    """
	This function will read the .FSO file and extract the axis field Ez(z). 
	"""
    fl_in = open(fl_name, "r")
    lns = fl_in.readlines()
    fl_in.close()
    func = Function()
    i_start = -1
    for i in range(len(lns)):
        if (lns[i].find("    Z(cm)      Ez(V/m)") >= 0):
            i_start = i + 1
            break
    for i in range(i_start, len(lns)):
        res_arr = lns[i].split()
        if (len(res_arr) != 2):
            break
        x = 0.01 * float(res_arr[0])
        y = float(res_arr[1])
        func.add(x, y)
    #fix for the field at the 0 region
    func1 = Function()
    for i in range(1, func.getSize()):
        ind = func.getSize() - i
        x = -func.x(ind)
        y = func.y(ind)
        func1.add(x, y)
    for i in range(func.getSize()):
        x = func.x(i)
        y = func.y(i)
        func1.add(x, y)
    return func1
Пример #2
0
		#---- here we parse the input file: 1st position - z, 4th - dB/dr(z
		z = float(res_arr[0])
		g = float(res_arr[3])
		g_func.add(z,g)

#---- let's set energy and momentum
mass = 0.938272 + 2*0.000511
eKin = 0.0025
momentum = math.sqrt(eKin*(eKin + 2*mass))
Brho = 3.33564*momentum  # [T*m]
charge = -1.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)