Commit b70b028d authored by Andreas Freise's avatar Andreas Freise
Browse files

small fixes to examples

parent 0abb97cf
......@@ -59,6 +59,10 @@ def main():
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
......@@ -71,9 +75,10 @@ def main():
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))
# apply measured map to etm, using 10 times larger distortions
etm.data = etm.data + surface.data*surface.scaling/etm.scaling*10.0
#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
......@@ -120,7 +125,7 @@ def precompute_roundtrips(shape, laser, kat):
LX=kat.LX.L.value
R=kat.etmX.R.value*kat.itmX.R.value
Loss = 1-R
accuracy=1E-6
accuracy=100E-6
print("cavity loss: {0}".format(Loss))
N=int(required_roundtrips(Loss,accuracy))
print("required rountrips: {0} (for accuracy of {1})".format(N, accuracy))
......@@ -140,9 +145,11 @@ def precompute_roundtrips(shape, laser, kat):
p = ProgressBar(maxval=N, widgets=["f_circ:", Percentage(),"|", Timer(), "|", ETA(), Bar()])
for n in range(1,N):
f_circ = FFT_propagate(f_circ,shape,Lambda,LX,1)
#f_circ = FFT_propagate(f_circ,shape,Lambda,LX,1)
f_circ = FFT_propagate_simple(f_circ,shape.xpoints,shape.ypoints, shape.xstep, shape.ystep,Lambda,LX,1)
f_circ = np.sqrt(kat.etmX.R.value)*FFT_apply_map(f_circ, etm, Lambda)
f_circ = FFT_propagate(f_circ,shape,Lambda,LX,1)
#f_circ = FFT_propagate(f_circ,shape,Lambda,LX,1)
f_circ = FFT_propagate_simple(f_circ,shape.xpoints,shape.ypoints, shape.xstep, shape.ystep,Lambda,LX,1)
f_circ = np.sqrt(kat.itmX.R.value)*FFT_apply_map(f_circ, itm, Lambda)
f_round[:,:,n] = f_circ;
p.update(n)
......@@ -152,7 +159,7 @@ def precompute_roundtrips(shape, laser, kat):
import time
timestr = time.strftime("%Y:%m:%d-%H:%M:%S")
np.save('fround-'+timestr,f_round)
print("Saved data into file: {0}".format('fround-'+timestr))
def FFT_apply_map(field, Map, Lambda):
......
......@@ -33,7 +33,8 @@ def main():
k = 2.0*np.pi/Lambda
#filename='fround_mode_matched_no_map.npy'
filename='fround-2014:12:22-15:07:11.npy'
#filename='fround_mode_matched_10map.npy'
filename='fround-2014:12:29-19:55:28.npy'
print(" --- loading data from file {0} ---".format(filename))
global f_round
f_round=np.load(filename)
......@@ -48,7 +49,7 @@ def main():
scan_start = 0.0
scan_stop = Lambda
scan_points = 200
scan_points = 100
global scan
scan = np.linspace(scan_start, scan_stop, scan_points)
......@@ -70,7 +71,11 @@ def main():
power[i] = field_power(f_temp,result['shape'])
p.update(i)
p.finish()
fileName, fileExtension = os.path.splitext(filename)
txtfile='power_{0}.txt'.format(fileName)
np.savetxt(txtfile, power, fmt='%.18e', delimiter=' ')
# plot scan
ax,fig=plot_setup()
ax.plot(power)
......
......@@ -181,13 +181,18 @@ def get_qs(tmpkat,f):
def beam_size(tmpkat, f, beam0):
kat = copy.deepcopy(tmpkat)
print "setting q param ---------------"
kat.psl.npsl.node.setGauss(kat.psl, beam0)
kat.parseKatCode("startnode npsl")
print kat.psl.npsl.node.q
#kat.parseKatCode("startnode npsl")
print "".join(kat.generateKatScript())
# add thermal lens and propagate input beam to ITM
kat = set_thermal_lens(kat, f)
global out
print "".join(kat.generateKatScript())
out = kat.run(printout=0,printerr=0)
# computing beam size at ITM
......@@ -224,8 +229,7 @@ def get_qs(tmpkat,f):
#raw_input("Press enter to continue")
return [beam1, beam2, beam3, beam4]
global out, kat
print "".join(kat.generateKatScript())
global out
# run finesse with input laser mode matched to cavity (no thermal lens)
out = kat.run(printout=0,printerr=0)
......
......@@ -141,7 +141,7 @@ def get_qs(tmpkat):
# beam at laser when matched to cold cavity
# (note the sign flip of the real part to change direction of gauss param)
q0 = complex(-1.0*out['w0'][0],out['w0'][1])
q0 = -1.0*out['w0'].conjugate()
beam0 = gauss_param(q=q0)
kat.psl.npsl.node.setGauss(kat.psl, beam0)
kat.parseKatCode("startnode npsl")
......@@ -154,7 +154,7 @@ def get_qs(tmpkat):
# computing beam size at ITM
# and then we reflect of ITM, an set it as new startnode
q_in = complex(out['w1'][0],out['w1'][1])
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)
......@@ -170,9 +170,9 @@ def get_qs(tmpkat):
out = kat.run(printout=0,printerr=0)
# computing beam size at WFS1 and WFS2
q2 = complex(out['w2'][0],out['w2'][1])
q2 = out['w2']
beam2 = gauss_param(q=q2)
q3 = complex(out['w3'][0],out['w3'][1])
q3 = out['w3']
beam3 = gauss_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)
......
......@@ -46,17 +46,16 @@ def FFT_propagate_simple(field, xpoints, ypoints, xstep, ystep, Lambda, distance
# - distance is the ditance over which to propgagte in meters
# - Lambda is the vacuum wavelength, nr the index of refraction
k = 2.0*np.pi/Lambda*nr
plD = np.pi*Lambda*distance/nr
# compute FFT axis vectors and compute propagator
f_x = np.fft.fftshift(np.fft.fftfreq(xpoints)/xstep)
f_y = np.fft.fftshift(np.fft.fftfreq(ypoints)/ystep)
F_x, F_y = np.meshgrid(f_x,f_y)
f_r_squared = F_x**2 + F_y**2
plD = np.pi*Lambda*distance/nr
Kp=np.fft.fftshift(np.exp(1j*plD*f_r_squared))
field = np.fft.fft2(field) # perform FFT
k = 2.0*np.pi/Lambda*nr
field = field * np.exp(-1j*k*distance) * Kp # apply propagator
field = np.fft.ifft2(field) # perform reverse FFT
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment