diff --git a/examples/aligo/FFT_ArmCavity_precompute.py b/examples/aligo/FFT_ArmCavity_precompute.py index 71ad321d361ca63c84624e260095339e82f7c069..2ec234c0d32836806c9eecb38188b166a031db0a 100644 --- a/examples/aligo/FFT_ArmCavity_precompute.py +++ b/examples/aligo/FFT_ArmCavity_precompute.py @@ -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): diff --git a/examples/aligo/FFT_ArmCavity_scan.py b/examples/aligo/FFT_ArmCavity_scan.py index 08d87ab8dff99883a4574d45a0d8f6af5ccd2216..037a2e5a064d859e96a90ddd4e2373f98d598037 100644 --- a/examples/aligo/FFT_ArmCavity_scan.py +++ b/examples/aligo/FFT_ArmCavity_scan.py @@ -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) diff --git a/examples/asc_test/master4.py b/examples/asc_test/master4.py index d87e07a51441287327b78faaeca1defe75364197..9ec50ac7052e7676c17087357c8473a17f39beff 100644 --- a/examples/asc_test/master4.py +++ b/examples/asc_test/master4.py @@ -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) diff --git a/examples/asc_test/master5.py b/examples/asc_test/master5.py index 1ba4d7ff8ae0fc86a00aa28c87739b710709481c..1996b947612cd48389ccceef515c47e6052165ca 100644 --- a/examples/asc_test/master5.py +++ b/examples/asc_test/master5.py @@ -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) diff --git a/pykat/optics/fft.py b/pykat/optics/fft.py index 161a532e28d194b37985847dc9ce92ae94e13a4f..5af9fb4e161cb1a25e853e8c001f62887ad62353 100644 --- a/pykat/optics/fft.py +++ b/pykat/optics/fft.py @@ -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