Esempio n. 1
0
    def beam_size(tmpkat, f):
        kat = copy.deepcopy(tmpkat)
        # 1. run finesse with input laser mode matched to cavity (no thermal lens)
        out = kat.run()

        # beam at laser when matched to cold cavity
        # (note the sign flip of the real part to change direction of gauss param)
        q0 = -1.0 * out['w0'].conjugate()
        beam0 = beam_param(q=q0)
        kat.psl.npsl.node.setGauss(kat.psl, beam0)
        kat.parseKatCode("startnode npsl")

        # add thermal lens and propagate input beam to ITM
        kat.ITM_TL.f = f
        if "ITM_TL_r" in kat._kat__components:
            kat.ITM_TL_r.f = f
        out = kat.run()

        # computing beam size at ITM
        # and then we reflect of ITM, an set it as new startnode
        q_in = out['w1']
        from pykat.optics.ABCD import apply, mirror_refl
        abcd = mirror_refl(1, -2500)
        q_out = apply(abcd, q_in, 1, 1)
        beam1 = beam_param(q=q_out)
        kat.removeLine("startnode")
        kat.psl.npsl.node.removeGauss()
        if "ITM_TL_r" in kat._kat__components:
            kat.ITM.nITM1r.node.setGauss(kat.ITM, beam1)
            kat.parseKatCode("startnode nITM1r")
        else:
            kat.ITM.nITM1.node.setGauss(kat.ITM, beam1)
            kat.parseKatCode("startnode nITM1")
        out = kat.run()

        # computing beam size at WFS1 and WFS2
        q2 = out['w2']
        beam2 = beam_param(q=q2)
        q3 = out['w3']
        beam3 = beam_param(q=q3)
        print(
            "	 Sideband (input mode) beam size with thermal lens f={0}".format(
                f))
        print("	 - WFS1 w={0:.6}cm".format(100.0 * beam2.w))
        print("	   (w0={0}, z={1})".format(beam2.w0, beam2.z))
        print("	 - WFS2 w={0:.6}cm".format(100.0 * beam3.w))
        print("	   (w0={0}, z={1})".format(beam3.w0, beam3.z))
        input("Press enter to continue")
        return (beam1, beam2, beam3)
Esempio n. 2
0
	def beam_size(tmpkat, f, beam0):
		kat = copy.deepcopy(tmpkat)
		kat.psl.npsl.node.setGauss(kat.psl, beam0)
		
		# add thermal lens and propagate input beam to ITM
		kat = set_thermal_lens(kat, f)
		out = kat.run()
		# computing beam size at ITM 
		# and then we reflect of ITM, an set it as new startnode
		q_in = out['w1']
		#import pykat.optics.ABCD as ABCD
		#abcd = ABCD.mirror_refl(1,2500)
		#q_out = ABCD.apply(abcd,q_in,1,1)
		beam1 = beam_param(q=q_in)	   
		kat.removeLine("startnode")
		kat.psl.npsl.node.removeGauss()
		if "ITM_TL_r" in kat._kat__components:
			kat.ITM.nITM1r.node.setGauss(kat.ITM, beam1)
			kat.parseKatCode("startnode nITM1r")
		else:
			kat.ITM.nITM1.node.setGauss(kat.ITM, beam1)
			kat.parseKatCode("startnode nITM1")
		out = kat.run()
		# computing beam size at WFS1 and WFS2
		q2 = out['w2']
		beam2 = beam_param(q=q2)	
		q3 = out['w3']
		beam3 = beam_param(q=q3)	

		# computing beam size at pick off
		q4 = out['w4']
		beam4 = beam_param(q=q4)	
		print(" Input mode beam size with thermal lens f={0}".format(f))
		print(" - ITM  w={0:.6}cm  (w0={1}, z={2})".format(100.0*beam1.w,beam1.w0, beam1.z))
		print(" - WFS1 w={0:.6}cm  (w0={1}, z={2})".format(100.0*beam2.w,beam2.w0, beam2.z))
		print(" - WFS2 w={0:.6}cm  (w0={1}, z={2})".format(100.0*beam3.w,beam3.w0, beam3.z))
		print(" - npo2 w={0:.6}cm  (w0={1}, z={2})".format(100.0*beam4.w,beam4.w0, beam4.z))
		#raw_input("Press enter to continue")
		return [beam1, beam2, beam3, beam4]
def main():
	print("""
	--------------------------------------------------------------
	Example file for using PyKat for an FFT-based simulation
	of an Advanced LIGO arm cavity
	PyKat:   http://www.gwoptics.org/pykat
	Advanced LIGO: http://www.advancedligo.mit.edu/

	Requires surface map file: etm08_virtual.txt
	Andreas Freise 20.12.2014
	--------------------------------------------------------------
	""") 
    # defining variables as global for debugging

	tmpresultfile = 'myshelf1.dat'
	result={}

	#Advanced LIGO parameters
	# length [m] 3994.5
	# FSR [kHz] 37.5
	# T1 1.4%
	# T2 5ppm
	# finesse 445
	# FWHM [Hz] 84
	# mirror diameter: 0.32 m
	# ITM RC [m] 1934
	# ETM RC [m] 2245
	# w0 [cm] 1.2
	# w1 [cm] 5.3
	# w2 [cm] 6.2
	# z1 [m] -1834

	# loading kat file to get parameters and to compute input beam parameters
	global kat, out
	kat = pykat.finesse.kat()
	kat.verbose = False
	kat.loadKatFile('aligo_Xarm.kat')

	# setting ITM T to larger value for better plots
	kat.itmX.T=0.1
	kat.itmX.R=0.9
	Lambda = kat.lambda0
	LX=kat.LX.L.value
	kat.maxtem=0
	out = kat.run()
	w0=out.y[0][0]
	z0=-out.y[0][1]
		
	# load and create mirror maps
	global itm, etm
	surface=read_map('etm08_virtual.txt')
	itm=curvedmap('itm_Rc',surface.size,surface.step_size, -1.0*abs(kat.itmX.Rc.value))
	etm=curvedmap('etm_Rc',surface.size,surface.step_size, -1.0*abs(kat.etmX.Rc.value))
	#itm.plot()
	#etm.plot()
	# apply measured map to etm, using 20 times larger distortions
	etm.data = etm.data + surface.data*surface.scaling/etm.scaling*20

	# setup grid for FFT propagation
	[xpoints,ypoints] = surface.size
	xsize = xpoints * surface.step_size[0]
	ysize = ypoints * surface.step_size[1]
	xoffset = 0.0
	yoffset = 0.0

	global shape
	shape = grid(xpoints, ypoints, xsize, ysize, xoffset, yoffset)
	x = shape.xaxis
	y = shape.yaxis
	result['shape']=shape

	# generate roughly mode-matched input beam
	global laser
	gx = beam_param(w0=w0, z=z0)
	beam = HG_mode(gx,gx,0,0)
	laser = beam.Unm(x,y) 

	# some debugging plots
	"""
	plot_field(laser)
	Lrange= np.linspace(0,4000,200)
	plot_propagation(laser, shape, Lambda, 0, 1, Lrange, 1)
	laser1=FFT_propagate(laser,shape,Lambda,LX,1)
	laser2=np.sqrt(kat.etmX.R.value)*FFT_apply_map(laser1, etm, Lambda)
	laser3=FFT_propagate(laser2,shape,Lambda,LX,1)
	Lrange= np.linspace(0,4000,200)
	plot_propagation(laser2, shape, Lambda, 0, 1, Lrange, 1)
	plot_field(laser3)
	"""

	precompute_roundtrips(shape, laser, kat)
	
	# now save any `result' variables:
	tmpfile = shelve.open(tmpresultfile)
	tmpfile['result']=result
	tmpfile.close()
def main():
    print("""
    --------------------------------------------------------------
    Example file for using PyKat http://www.gwoptics.org/pykat

    Simple spatial filter to measure the mode content in a
    Hermite Gauss beam
    
    Andreas Freise, 18.10.2016    
    --------------------------------------------------------------
    """)
    plt.close('all')

    # wavelength
    Lambda = 1064.0E-9
    # distance to propagate/focal length of lens
    D = 10
    # mix coefficients
    c1 = 0.7
    c2 = 0.3
    # mode indices
    n1 = 2
    m1 = 3
    n2 = 1
    m2 = 0

    ######## Generate Grid stucture required for FFT propagation ####
    xpoints = 512
    ypoints = 512
    xsize = 0.05
    ysize = 0.05
    # Apply offset such that the center of the beam lies in the
    # center of a grid tile
    xoffset = -0.5 * xsize / xpoints
    yoffset = -0.5 * ysize / ypoints

    global shape
    shape = grid(xpoints, ypoints, xsize, ysize, xoffset, yoffset)
    x = shape.xaxis
    y = shape.yaxis

    ######## Generates a mixture of fields ################
    gx = beam_param(w0=2e-3, z=0)
    gy = beam_param(w0=2e-3, z=0)
    beam = HG_mode(gx, gy, n1, m1)
    field1 = beam.Unm(x, y)
    beam2 = HG_mode(gx, gy, n2, m2)
    field2 = beam2.Unm(x, y)
    global field, laser1, laser2
    field = np.sqrt(c1) * field1 + np.sqrt(c2) * field2

    ####### Apply phase plate #######################################

    laser1 = field * (np.conjugate(field1))
    laser2 = field * (np.conjugate(field2))

    ####### Propagates the field by FFT ##############################
    laser1 = FFT_propagate(laser1, shape, Lambda, D, 1)
    laser2 = FFT_propagate(laser2, shape, Lambda, D, 1)

    f = D
    #laser1 = apply_lens(laser1, shape, Lambda, f)
    #laser2 = apply_lens(laser2, shape, Lambda, f)
    laser1 = apply_thin_lens(laser1, shape, Lambda, f)
    laser2 = apply_thin_lens(laser2, shape, Lambda, f)

    laser1 = FFT_propagate(laser1, shape, Lambda, D, 1)
    laser2 = FFT_propagate(laser2, shape, Lambda, D, 1)

    # midpoint computation for even number of points only!
    midx = (xpoints) // 2
    midy = (ypoints) // 2
    coef1 = np.abs(laser1[midx, midy])
    coef2 = np.abs(laser2[midx, midy])

    ratio = (coef1 / coef2)**2
    pc2 = 1 / (1 + ratio)
    pc1 = pc2 * ratio

    print("c1 {0}, coef1 {1}, error {3} (raw output {2})".format(
        c1, pc1, coef1, np.abs(c1 - pc1)))
    print("c2 {0}, coef2 {1}, error {3} (raw output {2})".format(
        c2, pc2, coef2, np.abs(c2 - pc2)))

    # plot hand tuned for certain ranges and sizes, not automtically scaled
    fig = plt.figure(110)
    fig.clear()
    off1 = xpoints / 10
    off2 = xpoints / 6
    plt.subplot(1, 3, 1)
    plt.imshow(abs(field))
    plt.xlim(midx - off1, midx + off1)
    plt.ylim(midy - off1, midy + off1)
    plt.draw()
    plt.subplot(1, 3, 2)
    plt.imshow(abs(laser1))
    plt.xlim(midx - off2, midx + off2)
    plt.ylim(midy - off2, midy + off2)
    plt.draw()
    plt.subplot(1, 3, 3)
    plt.imshow(abs(laser2))
    plt.xlim(midx - off2, midx + off2)
    plt.ylim(midy - off2, midy + off2)
    plt.draw()
    if in_ipython():
        plt.show(block=0)
    else:
        plt.show(block=1)
Esempio n. 5
0
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from pykat.optics.ABCD import apply, mirror_trans
from pykat.optics.gaussian_beams import beam_param

nr1 = 1
nr2 = 1.44963098985906
q1 = beam_param(q=5.96343 + 3.04713j)
abcd = mirror_trans(nr1, nr2, float("inf"))
# into material
q2 = apply(abcd, q1.q, nr1, nr2)
# and out again
q3 = apply(abcd, q2.q, nr2, nr1)

print("q1 =", q1, " w0 =", q1.w0, " w =", q1.w, " z =", q1.z)
print("q2 =", q2, " w0 =", q2.w0, " w =", q2.w, " z =", q2.z)
print("q3 =", q3, " w0 =", q3.w0, " w =", q3.w, " z =", q3.z)
def main():
    print("""
    --------------------------------------------------------------
    Example file for using PyKat http://www.gwoptics.org/pykat

    Generate a HG11 mode from a HG00 mode with a simple
    phase plate.
    
    Andreas Freise, 18.10.2016    
    --------------------------------------------------------------
    """)
    plt.close('all')
    # wavelength
    Lambda = 1064.0E-9
    # distance to propagate/focal length of lens
    D = 4

    ######## Generate Grid stucture required for FFT propagation ####
    xpoints = 512
    ypoints = 512
    xsize = 0.05
    ysize = 0.05
    # Apply offset such that the center of the beam lies in the
    # center of a grid tile
    xoffset = -0.5 * xsize / xpoints
    yoffset = -0.5 * ysize / ypoints

    shape = grid(xpoints, ypoints, xsize, ysize, xoffset, yoffset)
    x = shape.xaxis
    y = shape.yaxis

    ######## Generates input beam ################
    gx = beam_param(w0=2e-3, z=0)
    gy = beam_param(w0=2e-3, z=0)
    beam = HG_mode(gx, gy, 0, 0)
    global field, laser
    field = beam.Unm(x, y)

    ####### Apply phase plate #######################################

    plate = np.ones([xpoints, ypoints])
    plate[0:xpoints // 2, 0:ypoints // 2] = -1.0
    plate[xpoints // 2:xpoints, ypoints // 2:ypoints] = -1.0

    field2 = field * plate

    ####### Propagates the field by FFT ##############################
    field2 = FFT_propagate(field2, shape, Lambda, D, 1)

    # maybe apply a thin lens
    f = D
    field2 = apply_thin_lens(field2, shape, Lambda, f)
    field2 = FFT_propagate(field2, shape, Lambda, D, 1)

    midx = (xpoints) // 2
    midy = (ypoints) // 2
    off1 = 50
    off2 = 50

    # plot hand tuned for certain ranges and sizes, not automtically scaled
    fig = plt.figure(110)
    fig.clear()
    plt.subplot(1, 3, 1)
    plt.imshow(abs(field))
    plt.xlim(midx - off1, midx + off1)
    plt.ylim(midy - off1, midy + off1)
    plt.draw()
    plt.subplot(1, 3, 2)
    plt.imshow(plate)
    #pl.xlim(midx-off2,midx+off2)
    #pl.ylim(midy-off2,midy+off2)
    plt.draw()
    plt.subplot(1, 3, 3)
    plt.imshow(abs(field2))
    plt.xlim(midx - off2, midx + off2)
    plt.ylim(midy - off2, midy + off2)
    plt.draw()
    if in_ipython():
        plt.show(block=0)
    else:
        plt.show(block=1)
Esempio n. 7
0
def main():

	print("""
	--------------------------------------------------------------
	Example file for using PyKat to automate Finesse simulations
	Finesse: http://www.gwoptics.org/finesse
	PyKat:	 https://pypi.python.org/pypi/PyKat/

	The file runs through the various Finesse simulations
	to generate the Finesse results reported in the document:
	`Comparing Finesse simulations, analytical solutions and OSCAR 
	simulations of Fabry-Perot alignment signals', LIGO-T1300345,
	freely available online: http://arxiv.org/abs/1401.5727

	Run this file after master2.py to create data which can be
	plotted using master4_plot.py. Results are saved after 
	each step and plots can be created at any time.
		
	Andreas Freise 16.01.2014
	--------------------------------------------------------------
	""")
	
	# shall we clear the workspace?
	# %reset -f

	# making these global during testing and debugging
	#global kat, out

	kat = finesse.kat(tempdir=".",tempname="test")
	kat.verbose = False

	tmpresultfile = 'myshelf2.dat'
	
	# loading data saved by master.py
	kat.loadKatFile('asc_base3.kat')
	try:
		with open(tmpresultfile, 'rb') as handle:
			result = pickle.load(handle)
	except: raise Exception("Could not open temprary results file {0}".format(tmpresultfile))
	
	# this does not work yet due to the scale command
	kat.PDrefl_p.enabled = False
	kat.PDrefl_q.enabled = False
	kat.WFS1_I.enabled = False
	kat.WFS1_Q.enabled = False
	kat.WFS2_I.enabled = False
	kat.WFS2_Q.enabled = False

	kat.ETM.phi=result['phi_tuned']

	print("--------------------------------------------------------")
	print(" 11. Do beam tracing to measure beam parameters")
	# get beam parameters at nodes: "npsl", "nITM1", "nWFS1", "nWFS2", "npo2"
	global beam1, beam2, beam3
	beam1 = get_qs(kat,1e13)
	beam2 = get_qs(kat,50e3)
	beam3 = get_qs(kat,5e3)

	# starting with cold beam at npsl
	kat.psl.npsl.node.setGauss(kat.psl, beam1[0])
	kat.parseKatCode("startnode npsl")


	# if we use bs-based cavity we try to set good beam
	# parameter for reflected beam, first by
	# computing 'average' beam from cold and hot beams
	x1=0.70
	x2=0.30
	if "ITM_TL_r" in kat._kat__components:
		beam50 = beam_param(z=(x1*beam1[1].z+x2*beam2[1].z), w0=(x1*beam1[1].w0+x2*beam2[1].w0))
		beam5  = beam_param(z=(x1*beam1[1].z+x2*beam3[1].z), w0=(x1*beam1[1].w0+x2*beam3[1].w0))
		node_text = "at ITM->nITM1r"
		t_comp=kat.ITM
		t_node=kat.ITM.nITM1r
	else:
		beam50 = beam_param(z=(x1*beam1[4].z+x2*beam2[4].z), w0=(x1*beam1[4].w0+x2*beam2[4].w0))
		beam5  = beam_param(z=(x1*beam1[4].z+x2*beam3[4].z), w0=(x1*beam1[4].w0+x2*beam3[4].w0))
		node_text = "at s2->npo2"
		t_comp=kat.s2
		t_node=kat.s2.npo2
	
	kat = set_thermal_lens(kat,50.0e3)

	print("--------------------------------------------------------")
	print(" 12. computing beam tilt with thermal lens (f={0})".format(kat.ITM_TL.f))

	print(" Setting compromise beam parameter {0}:\n w0={1}, z={2}".format(node_text, beam50.w0, beam50.z))
	t_node.node.setGauss(t_comp, beam50)
	kat.maxtem=8
	print(" Calculating maxtem = %d " % kat.maxtem)
	tmp = gravity_tilt(kat)

	kat = set_thermal_lens(kat,5e3)
	print("--------------------------------------------------------")
	print(" 13. computing beam tilt with thermal lens (f={0})".format(kat.ITM_TL.f))
	print(" Setting compromise beam parameter {0}:\n w0={1}, z={2}".format(node_text, beam5.w0, beam5.z))
	t_node.node.setGauss(t_comp, beam5)
	#maxtems = [1, 3, 5, 9, 11, 13, 15, 19, 23, 25, 27, 29]
	#maxtems = [1, 3, 5, 9, 11, 13, 15]
	maxtems = [1, 3, 5, 7]
	converge_tilt(kat, maxtems)
   
	kat.PDrefl_p.enabled = True
	kat.WFS1_I.enabled = True
	kat.WFS2_I.enabled = True
	
	kat = set_thermal_lens(kat,50e3)
	print("--------------------------------------------------------")
	print(" 12. computing alignment signal with thermal lens (f={0})".format(kat.ITM_TL.f))
	t_node.node.setGauss(t_comp, beam50)
	#maxtems = [1, 3, 5, 9, 11, 13, 15, 17, 19]
	#maxtems = [1, 3, 5, 9, 11, 13, 15]
	maxtems = [1, 3, 5, 7]
	converge_asc(kat, maxtems, 'asc_signals_50.txt')

	kat = set_thermal_lens(kat,5e3)
	print("--------------------------------------------------------")
	print(" 13. computing alignment signal with thermal lens (f={0})".format(kat.ITM_TL.f))
	t_node.node.setGauss(t_comp, beam5)
	#maxtems = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]
	#maxtems = [1, 3, 5, 9, 11, 13, 15]
	maxtems = [1, 3, 5, 7]
	converge_asc(kat, maxtems, 'asc_signals_5.txt')
Esempio n. 8
0
def get_qs(tmpkat,f):
	global kat, out	
	kat = copy.deepcopy(tmpkat)

	# measure beam parameter for the 'cold beam' i.e. the laser beam
	# matched to the cavity without any thermal lens
	nodenames=["npsl", "nITM1", "nWFS1", "nWFS2", "npo2"]
	for idx, nname in enumerate(nodenames):
		kat.parseKatCode('bp w{0} y q {1}'.format(idx, nname))

	kat.parseKatCode('yaxis re:im')
	kat.noxaxis = True
	kat.maxtem=0
	
	def beam_size(tmpkat, f, beam0):
		kat = copy.deepcopy(tmpkat)
		kat.psl.npsl.node.setGauss(kat.psl, beam0)
		
		# add thermal lens and propagate input beam to ITM
		kat = set_thermal_lens(kat, f)
		out = kat.run()
		# computing beam size at ITM 
		# and then we reflect of ITM, an set it as new startnode
		q_in = out['w1']
		#import pykat.optics.ABCD as ABCD
		#abcd = ABCD.mirror_refl(1,2500)
		#q_out = ABCD.apply(abcd,q_in,1,1)
		beam1 = beam_param(q=q_in)	   
		kat.removeLine("startnode")
		kat.psl.npsl.node.removeGauss()
		if "ITM_TL_r" in kat._kat__components:
			kat.ITM.nITM1r.node.setGauss(kat.ITM, beam1)
			kat.parseKatCode("startnode nITM1r")
		else:
			kat.ITM.nITM1.node.setGauss(kat.ITM, beam1)
			kat.parseKatCode("startnode nITM1")
		out = kat.run()
		# computing beam size at WFS1 and WFS2
		q2 = out['w2']
		beam2 = beam_param(q=q2)	
		q3 = out['w3']
		beam3 = beam_param(q=q3)	

		# computing beam size at pick off
		q4 = out['w4']
		beam4 = beam_param(q=q4)	
		print(" Input mode beam size with thermal lens f={0}".format(f))
		print(" - ITM  w={0:.6}cm  (w0={1}, z={2})".format(100.0*beam1.w,beam1.w0, beam1.z))
		print(" - WFS1 w={0:.6}cm  (w0={1}, z={2})".format(100.0*beam2.w,beam2.w0, beam2.z))
		print(" - WFS2 w={0:.6}cm  (w0={1}, z={2})".format(100.0*beam3.w,beam3.w0, beam3.z))
		print(" - npo2 w={0:.6}cm  (w0={1}, z={2})".format(100.0*beam4.w,beam4.w0, beam4.z))
		#raw_input("Press enter to continue")
		return [beam1, beam2, beam3, beam4]

	#global out
	# run finesse with input laser mode matched to cavity (no thermal lens)
	out = kat.run()
	# beam at laser when matched to cold cavity
	# (note the sign flip of the real part to change direction of gauss param)
	q0 = -1.0*out['w0'].conjugate()
	beam0 = beam_param(q=q0)
	# compute beam sizes when tracing this beam back through the system
	(beam1,beam2,beam3, beam4)=beam_size(kat,f,beam0)
	
	return (beam0, beam1, beam2,beam3, beam4)