Ejemplo n.º 1
0
def show_table():
    inch = 0.0254
    lambda0 = 1.054e-6
    spitfire_exit = Numeric.array((2 * inch, 5 * inch, -0.65))
    compressor_entrance = Numeric.array((45.5 * inch, 2.5 * inch, 46.5 * inch))

    optics = {}
    BLUELINE = 'bl'
    SPLIT = 'split'
    START = 'start'
    COMP = 'compressor'
    QUAD = 'quadrupler'
    IR = 'ir'
    IR_COMP = 'ir compressor'
    BE_TURN = 'be_turn'
    IZ_SCREEN = 'iz'

    optics[START] = null_optic("start", spitfire_exit)
    optics[BLUELINE] = blueline = blue_through_ylf()
    optics[SPLIT] = split1 = reflector("splitter1",
                                       center=(2 * inch, 5 * inch, 3 * inch))
    optics[IR] = irline = ir_line()

    comp = optics[COMP] = blue_compressor(38.5,
                                          1.28,
                                          lambda0,
                                          center=compressor_entrance,
                                          angle=270)
    mainbeam = beam(spitfire_exit, qtens(lambda0, spitfire.q0), lambda0)
    # print mainbeam.q
    split1.set_direction(spitfire_exit, blueline)
    blueline.set_entrance_direction(split1)
    blueline.set_exit_direction(comp)
    comp.rotate_to_axis(blueline)
    q = optics[QUAD] = quadrupler(center=(40 * inch, 2.5 * inch, 34.5 * inch),
                                  from_optic=comp[blue_compressor.TM1])
    comp.set_exit_direction(q)
    q.set_entrance_direction(comp)
    blue_sys = composite_optic("blue_sys", optics,
                               [START, SPLIT, BLUELINE, COMP, QUAD], (0, 0, 0),
                               (0, 0, 0), 0)
    irline.set_entrance_direction(spitfire_exit)

    # align compressor table to output of main IR line
    ir_sys = composite_optic("ir_sys", optics, [START, IR], (0, 0, 0),
                             (0, 0, 0), 0).clone()
    pointer = trace_path(ir_sys, mainbeam.clone())[-1]
    pointer.free_drift(1.0)
    optics[IR_COMP] = ircomp = ir_compressor(center=pointer.x0,
                                             angle=math.atan(0.2) / deg)
    ircomp.set_entrance_direction(irline)

    # now, align IZ
    ir_sys = composite_optic("ir_sys", optics, [START, IR, IR_COMP], (0, 0, 0),
                             (0, 0, 0), 0).clone()
    pointer = trace_path(ir_sys, mainbeam.clone())[-1]
    pointer.free_drift(1.0)
    bemir = optics[BE_TURN] = reflector("be turn mirror",
                                        center=pointer.x0,
                                        angle=45.0)
    bemir.transport_to_here(pointer).transform(pointer)
    pointer.free_drift(0.1)
    dz = pointer.q.next_waist()
    pointer.free_drift(dz)
    optics[IZ_SCREEN] = null_optic("IZ", pointer.x0)
    ir_sys = composite_optic("ir_sys", optics,
                             [START, IR, IR_COMP, BE_TURN, IZ_SCREEN],
                             (0, 0, 0), (0, 0, 0), 0)

    whole_table = composite_optic(
        "whole table", optics,
        [START, SPLIT, BLUELINE, COMP, QUAD, IR, IR_COMP, BE_TURN, IZ_SCREEN],
        (0, 0, 0), (0, 0, 0), 0)

    ir_trace = trace_path(ir_sys, mainbeam.clone())
    ir_trace.color = graphite.red
    blue_trace = trace_path(blue_sys, mainbeam.clone())
    blue_trace.color = graphite.blue

    if table_layout:
        g = draw_everything({"sys": whole_table},
                            ir_trace, (-.25, 5), (0, 2.5),
                            three_d=0)
        draw_trace(g, blue_trace)

        #g=draw_everything({"sys":sys}, trace, (0.5,1.1), (0.8,1.1), three_d=0)
        #g=draw_everything({"sys":sys}, trace, (0.7,1.3), (0.9,1.2), three_d=0)
        if show_qd:
            graphite.genOutput(g,
                               'QD',
                               canvasname="Compressor layout",
                               size=(900, 500))
        if show_pdf:
            graphite.genOutput(g,
                               'PDF',
                               canvasname="Tablelayout",
                               size=(900, 500))
    # print trace[0]
    plotq(blue_trace)

    if 0:
        glabel = ircomp.mark_label(ircomp.INPUT)
        m = ir_trace[(glabel, 0)]
        print("\n\n**start**\n\n")
        print(m.incoming_direction, m.direction())
        print(m.incoming_q)
        print(m.incoming_q.qi_moments()[1:3])
        print(m.incoming_q.q_moments()[1:3])
        print(m.incoming_q.qit, "\n")
        print(m.localize_transform_tensor)
        print(m.footprint_q)
        print(m.footprint_q.qi_moments()[1:3])
        print(m.footprint_q.q_moments()[1:3])
        print(m.footprint_q.qit, "\n")
        print(m.globalize_transform_tensor)
        print(m.q)
        print(m.q.qi_moments()[1:3])
        print(m.q.q_moments()[1:3])
        print(m.q.qit, "\n")

    glabel = ircomp.mark_label(ircomp.INPUT)
    # endpoint=ir_trace[(glabel,0)]  #get first hit on optic <glabel>
    endpoint = ir_trace[-1]
    q = endpoint.q

    t, qx0, qy0 = q.qi_moments()
    theta = math.atan2(t[0, 1].real, t[0, 0].real) / deg
    qxx, qyy = endpoint.transform_q_to_table(q)
    dzx, dzy = (1e6 / qxx).real, (1e6 / qyy).real
    print((
        "qxx = %.1f, dzx = %.0f, qyy=%.1f, dzy=%.0f, (in um), theta=%.1f deg" %
        (q.rw(qxx)[1] * 1e6, dzx, q.rw(qyy)[1] * 1e6, dzy, theta)))
Ejemplo n.º 2
0
def show_table():
	inch=0.0254
	lambda0=1.054e-6
	spitfire_exit=Numeric.array((2*inch, 5*inch, -0.65))
	compressor_entrance=Numeric.array((45.5*inch, 2.5*inch, 46.5*inch))
	
	optics={}
	BLUELINE='bl'
	SPLIT='split'
	START='start'
	COMP='compressor'
	QUAD='quadrupler'
	IR='ir'
	IR_COMP='ir compressor'
	BE_TURN='be_turn'
	IZ_SCREEN='iz'
	
	optics[START]=null_optic("start", spitfire_exit)
	optics[BLUELINE]=blueline=blue_through_ylf()	
	optics[SPLIT]=split1=reflector("splitter1", center=(2*inch, 5*inch, 3*inch))
	optics[IR]=irline=ir_line()
	
	comp=optics[COMP]=blue_compressor(38.5, 1.28, lambda0, center=compressor_entrance, angle=270)
	mainbeam=beam( spitfire_exit, qtens(lambda0, spitfire.q0), lambda0)
	#print mainbeam.q
	split1.set_direction(spitfire_exit, blueline)
	blueline.set_entrance_direction(split1)
	blueline.set_exit_direction(comp)
	comp.rotate_to_axis(blueline)
	q=optics[QUAD]=quadrupler(center=(40*inch, 2.5*inch, 34.5*inch), from_optic=comp[blue_compressor.TM1])
	comp.set_exit_direction(q)
	q.set_entrance_direction(comp)
	blue_sys=composite_optic("blue_sys", optics, [START, SPLIT, BLUELINE, COMP, QUAD], (0,0,0), (0,0,0), 0)
	irline.set_entrance_direction(spitfire_exit)
	
	#align compressor table to output of main IR line
	ir_sys=composite_optic("ir_sys", optics, [START, IR], (0,0,0), (0,0,0), 0).clone()
	pointer=trace_path(ir_sys, mainbeam.clone())[-1]
	pointer.free_drift(1.0)
	optics[IR_COMP]=ircomp=ir_compressor(center=pointer.x0, angle=math.atan(0.2)/deg)
	ircomp.set_entrance_direction(irline)

	#now, align IZ
	ir_sys=composite_optic("ir_sys", optics, [START, IR, IR_COMP], (0,0,0), (0,0,0), 0).clone()
	pointer=trace_path(ir_sys, mainbeam.clone())[-1]
	pointer.free_drift(1.0)
	bemir=optics[BE_TURN]=reflector("be turn mirror", center=pointer.x0, angle=45.0)
	bemir.transport_to_here(pointer).transform(pointer)
	pointer.free_drift(0.1)
	dz=pointer.q.next_waist()
	pointer.free_drift(dz)
	optics[IZ_SCREEN]=null_optic("IZ", pointer.x0)
	ir_sys=composite_optic("ir_sys", optics, [START, IR, IR_COMP, BE_TURN, IZ_SCREEN], (0,0,0), (0,0,0), 0)
	
	whole_table=composite_optic("whole table", optics, [START, SPLIT, BLUELINE, COMP, QUAD, IR, IR_COMP, BE_TURN, IZ_SCREEN], (0,0,0), (0,0,0), 0)
	
	
	ir_trace=trace_path(ir_sys, mainbeam.clone())
	ir_trace.color=graphite.red
	blue_trace=trace_path(blue_sys, mainbeam.clone())
	blue_trace.color=graphite.blue
	
	if table_layout:
		g=draw_everything({"sys":whole_table}, ir_trace, (-.25,5), (0,2.5), three_d=0)
		draw_trace(g, blue_trace)
		
		#g=draw_everything({"sys":sys}, trace, (0.5,1.1), (0.8,1.1), three_d=0)
		#g=draw_everything({"sys":sys}, trace, (0.7,1.3), (0.9,1.2), three_d=0)
		if show_qd:
			graphite.genOutput(g,'QD',canvasname="Compressor layout", size=(900,500))
		if show_pdf:
			graphite.genOutput(g,'PDF',canvasname="Tablelayout", size=(900,500))
	#print trace[0]
	plotq(blue_trace)
	
	if 0:
		glabel=ircomp.mark_label(ircomp.INPUT)
		m=ir_trace[(glabel,0)]
		print "\n\n**start**\n\n"
		print m.incoming_direction, m.direction()
		print m.incoming_q
		print m.incoming_q.qi_moments()[1:3]
		print m.incoming_q.q_moments()[1:3]
		print m.incoming_q.qit, "\n"
		print m.localize_transform_tensor
		print m.footprint_q
		print m.footprint_q.qi_moments()[1:3]
		print m.footprint_q.q_moments()[1:3]
		print m.footprint_q.qit, "\n"
		print m.globalize_transform_tensor
		print m.q
		print m.q.qi_moments()[1:3]
		print m.q.q_moments()[1:3]
		print m.q.qit, "\n"

	glabel=ircomp.mark_label(ircomp.INPUT)
	#endpoint=ir_trace[(glabel,0)]  #get first hit on optic <glabel>
	endpoint=ir_trace[-1]
	q=endpoint.q
	
	t, qx0, qy0=q.qi_moments()
	theta=math.atan2(t[0,1].real, t[0,0].real)/deg
	qxx, qyy = endpoint.transform_q_to_table(q)
	dzx, dzy = (1e6/qxx).real, (1e6/qyy).real
	print ("qxx = %.1f, dzx = %.0f, qyy=%.1f, dzy=%.0f, (in um), theta=%.1f deg" % 
			(q.rw(qxx)[1]*1e6, dzx, q.rw(qyy)[1]*1e6, dzy, theta ) )
Ejemplo n.º 3
0
def doit_bc(theta1, clen, lambda0, drawit=0):

    print("\n\n***start blue line trace***\n")
    grating_offset = -0.075
    exit_height = 0
    exit_z = -0.3
    eta1 = 0.0

    optics = {}

    END = 'end'
    optics[END] = null_optic("end", (0.15, exit_height, 0), 0)
    START = 'start'
    optics[START] = null_optic("start", (0, 0, -0.85))

    tracebeam = basebeam.clone()
    system_center = Numeric.array((-0.1, 0, -0.85))

    basebeam = beam(system_center, qtens(lambda0, q=spitfire.q0), lambda0)
    tracebeam.free_drift(-0.2)

    COMP = 'comp'
    comp = optics[COMP] = blue_compressor(theta1,
                                          clen,
                                          lambda0,
                                          center=system_center,
                                          angle=rotation)
    TM2 = 'turn2'
    optics[TM2] = reflector("output turn 2",
                            angle=0,
                            center=(0.15, exit_height, -0.6),
                            width=.025)

    optics[COMP].set_exit_direction(optics[TM2])
    optics[TM2].set_direction(optics[COMP], optics[END])

    sys_order = (START, COMP, TM2, DEMAG1, DEMAG2, END)

    GRATE = comp.mark_label(blue_compressor.GRATE)
    IR1 = comp.mark_label(blue_compressor.IR1)
    IR2 = comp.mark_label(blue_compressor.IR2)

    optic_sys = composite_optic("system",
                                optics,
                                sys_order,
                                center=optics[START].center)

    trace0 = trace_path(optic_sys, tracebeam.shift_lambda(0))
    trace0.color = graphite.green
    trace1 = trace_path(optic_sys, tracebeam.shift_lambda(-0.5e-9))
    trace1.color = graphite.blue
    trace2 = trace_path(optic_sys, tracebeam.shift_lambda(+0.5e-9))
    trace2.color = graphite.red

    try:  # if one of the traces failed, this may not work
        print("Theta1=%.3f eta=%.3f len=%.3f lambda=%.4f" %
              (theta1, eta1, clen, lambda0 * 1e6))
        d0 = trace0[-1]['total_drift']
        d1 = trace1[-1]['total_drift']
        d2 = trace2[-1]['total_drift']
        print((
            "d(lambda0-0.5nm)=%.3f m, d(lambda0+0.5nm)=%.3f m, dt/dl=%.0f ps/nm, "
            % (d1, d2, (d2 - d1) * 1e12 / clight)),
              end=' ')
        print("d2t/dl2 = %.2f ps/nm^2" % ((d2 + d1 - 2.0 * d0) *
                                          (1e12 / clight) * 4))
        spot1info = trace0[(GRATE, 0)]
        spot2info = trace0[(GRATE, 1)]
        ir1info = trace0[(IR1, 0)]
        ir2info = trace0[(IR2, 0)]
        spot_offset = spot2info['position'] - spot1info['position']
        retro_offset = ir2info['position'] - ir1info['position']
        print("Grating offset = %.3f, retro_offset=%.3f" %
              (vec_mag(spot_offset), vec_mag(retro_offset)))
        print("measured vertex length = %.3f" %
              vec_mag(comp[GRATE].center - comp[IR1].center))
        print("dispersion offset on grating = %.3f m / nm" %
              vec_mag(trace2[(GRATE, 1)]['position'] -
                      trace1[(GRATE, 1)]['position']))
        print("final q = ", trace0[-1]['q'])
    except:
        traceback.print_exc()
        pass

    if drawit:
        g = draw_everything({"sys": optic_sys},
                            trace0, (-.9, .1), (-.5, .5),
                            three_d=0)
        #g=draw_everything(optics, trace0, (-2, 2), (-2, 2))
        draw_trace(g, trace1)
        draw_trace(g, trace2)
        graphite.genOutput(g,
                           'QD',
                           canvasname="Compressor layout",
                           size=(600, 500))
Ejemplo n.º 4
0
def doit_bc(theta1, clen, lambda0, drawit=0):
	
	print "\n\n***start blue line trace***\n"
	grating_offset=-0.075
	exit_height=0
	exit_z=-0.3
	eta1=0.0
	
	optics={}
	
	END='end'
	optics[END]=null_optic("end", (0.15,exit_height,0), 0)
	START='start'
	optics[START]=null_optic("start", (0,0,-0.85))

	
	tracebeam=basebeam.clone()
	system_center=Numeric.array((-0.1, 0, -0.85))
	
	basebeam=beam(system_center, qtens(lambda0, q=spitfire.q0), lambda0)
	tracebeam.free_drift(-0.2)
		
	COMP='comp'
	comp=optics[COMP]=blue_compressor(theta1, clen, lambda0, center=system_center, angle=rotation)
	TM2='turn2'
	optics[TM2]=reflector("output turn 2", angle=0, center=(0.15,exit_height,-0.6), width=.025)

	optics[COMP].set_exit_direction(optics[TM2])
	optics[TM2].set_direction(optics[COMP], optics[END])

	sys_order=(START, COMP, TM2, DEMAG1, DEMAG2, END)

	GRATE=comp.mark_label(blue_compressor.GRATE)
	IR1=comp.mark_label(blue_compressor.IR1)
	IR2=comp.mark_label(blue_compressor.IR2)
	
	optic_sys=composite_optic("system", optics, sys_order, center=optics[START].center)
	
	trace0=trace_path(optic_sys, tracebeam.shift_lambda(0))
	trace0.color=graphite.green
	trace1=trace_path(optic_sys, tracebeam.shift_lambda(-0.5e-9))
	trace1.color=graphite.blue
	trace2=trace_path(optic_sys, tracebeam.shift_lambda(+0.5e-9))
	trace2.color=graphite.red
			
	try: #if one of the traces failed, this may not work
		print "Theta1=%.3f eta=%.3f len=%.3f lambda=%.4f" % (theta1, eta1, clen, lambda0*1e6)
		d0=trace0[-1]['total_drift']
		d1=trace1[-1]['total_drift']
		d2=trace2[-1]['total_drift']
		print ("d(lambda0-0.5nm)=%.3f m, d(lambda0+0.5nm)=%.3f m, dt/dl=%.0f ps/nm, " % (d1, d2, (d2-d1)*1e12/clight)), 
		print "d2t/dl2 = %.2f ps/nm^2" % ((d2+d1-2.0*d0)*(1e12/clight)*4)
		spot1info=trace0[(GRATE,0)] 
		spot2info=trace0[(GRATE,1)] 
		ir1info=trace0[(IR1,0)]
		ir2info=trace0[(IR2,0)]
		spot_offset=spot2info['position']-spot1info['position']
		retro_offset=ir2info['position']-ir1info['position']
		print "Grating offset = %.3f, retro_offset=%.3f" % (vec_mag(spot_offset), vec_mag(retro_offset))
		print "measured vertex length = %.3f" % vec_mag(comp[GRATE].center-comp[IR1].center)
		print "dispersion offset on grating = %.3f m / nm" % vec_mag(trace2[(GRATE,1)]['position']-trace1[(GRATE,1)]['position'])
		print "final q = ", trace0[-1]['q']
	except:
		traceback.print_exc()
		pass
				
	if drawit:
		g=draw_everything({"sys":optic_sys}, trace0, (-.9, .1), (-.5, .5), three_d=0)
		#g=draw_everything(optics, trace0, (-2, 2), (-2, 2))
		draw_trace(g, trace1)
		draw_trace(g, trace2)
		graphite.genOutput(g,'QD',canvasname="Compressor layout", size=(600,500))