diff --git a/examples/asc_test/asc_base.kat b/examples/asc_test/asc_base.kat new file mode 100644 index 0000000000000000000000000000000000000000..55795c8c17c34884c30a8b20dc127aa3af465631 --- /dev/null +++ b/examples/asc_test/asc_base.kat @@ -0,0 +1,40 @@ +# +#----------------------------------------------------------------------- +# ASC_01.kat +# +# This file is an part of the Finesse ASC signal validation. +# +# Checking setup. +# +# 01.02.2013, Andreas Freise +#---------------------------------------------------------------------- +# +# + +l psl 1.0 0 npsl /* toll*/ % P=1W input laser +mod EOM 9M 0.001 1 pm 0 npsl nEOM1 +s s1 0 nEOM1 npo1 + +bs1 po 0.5 0 0 45 npo1 dump npo2 nWFS1 % 50:50 pick-off mirror +s s2 0 npo2 nL1 + +lens ITM_TL 10000G nL1 nL2 % thermal lens in ITM +s ITMsub 0 nL2 nITM1 + +m1 ITM 0.02 0 0 nITM1 nITM2 +attr ITM Rc -2500 +s s_cav 5000 nITM2 nETM1 +m1 ETM 0.001 0 0 nETM1 nETM2 +attr ETM Rc 2700 +cav c1 ITM nITM2 ETM nETM1 + +s spo1 1n nWFS1 nL1_in +lens L1 1250 nL1_in nL1_out +s spo2 5000 nL1_out nWFS2 + +%const ETM_phi 22.63754342 % on resonance +% now 0.1/1064*360 + 22.63754342 = 22.6713780064662 +%const ETM_phi 22.6713780064662 % 1e-10m off resonance + +phase 0 + diff --git a/examples/asc_test/asc_pd_phase.py b/examples/asc_test/asc_pd_phase.py new file mode 100644 index 0000000000000000000000000000000000000000..53ae0ec5b20486d50271cc8dd3e620c2c7d01a4d --- /dev/null +++ b/examples/asc_test/asc_pd_phase.py @@ -0,0 +1,44 @@ +import copy +import sys +import scipy.optimize + +from pykat import finesse + +def run(tmpkat): + + kat = copy.deepcopy(tmpkat) + + code_det = """ + pd1 PDrefl_q 9M 90 nWFS1 + %scale 2 PDrefl_q + """ + + kat.parseKatCode(code_det) + kat.noxaxis= True + + # function for root finding + def PD_q_test(x): + kat.PDrefl_q.phi[0]=x + out = kat.run(printout=0,printerr=0) + print '\r root finding: function value %g ' % out.y, + sys.stdout.flush() + return out.y + + # do root finding + xtol=1e-8 + (result, info)=scipy.optimize.bisect(PD_q_test,80.0,100.0, xtol=xtol, maxiter=500, full_output=True) + + print "" + if info.converged: + p_phase=result-90.0 + q_phase=result + print " Root has been found:" + print " p_phase %8f" % (p_phase) + print " q_phase %8f" % (q_phase) + print " (%d iterations, %g tolerance)" % (info.iterations, xtol) + return (p_phase, q_phase) + else: + raise Exception("Root has not been found") + + + diff --git a/examples/asc_test/asc_powers.py b/examples/asc_test/asc_powers.py new file mode 100644 index 0000000000000000000000000000000000000000..b79977564bd8d7b33d34a06742823ecbb222aef7 --- /dev/null +++ b/examples/asc_test/asc_powers.py @@ -0,0 +1,29 @@ +import copy +from pykat import finesse + +def run(tmpkat): + + kat = copy.deepcopy(tmpkat) + + code1 = """ + ad EOM_up 9M nEOM1 + ad EOM_low -9M nEOM1 + pd cav_pow nITM2 + ad cav_c 0 nITM2 + ad WFS1_u 9M nWFS1 + ad WFS1_l -9M nWFS1 + ad WFS1_c 0 nWFS1 + ad WFS2_u 9M nWFS2 + ad WFS2_l -9M nWFS2 + ad WFS2_c 0 nWFS2 + noxaxis + """ + + kat.parseKatCode(code1) + + out = kat.run(printout=0,printerr=0) + + code1 = code1.split("\n") + for i in range(len(out.y)): + print " %8s: %.4e" % (out.ylabels[i], out.y[i]) + diff --git a/examples/asc_test/asc_resonance.py b/examples/asc_test/asc_resonance.py new file mode 100644 index 0000000000000000000000000000000000000000..dca7a508c8e981f47327d6dc9536354a4a6cb4a5 --- /dev/null +++ b/examples/asc_test/asc_resonance.py @@ -0,0 +1,41 @@ +import copy +import sys +import scipy.optimize + +def run(tmpkat): + + kat = copy.deepcopy(tmpkat) + + code1 = """ + ad carr2 0 nITM1* + ad carr3 0 nITM2 + yaxis deg + """ + kat.parseKatCode(code1) + kat.noxaxis = True + + # function for root finding + def carrier_resonance(x): + kat.ETM.phi=x + out = kat.run(printout=0,printerr=0) + phase = (out.y[0]-out.y[1]-90)%360-180 + print '\r root finding: function value %g ' % phase , + sys.stdout.flush() + return phase + + # do root finding + xtol=1e-8 + (result, info)=scipy.optimize.bisect(carrier_resonance,0.0,40.0, xtol=xtol, maxiter=500, full_output=True) + + print "" + if info.converged: + print " Root has been found:" + print " ETM phi %8f" % (result) + print " (%d iterations, %g tolerance)" % (info.iterations, xtol) + return result + else: + raise Exception(" Root has not been found") + + +if __name__=="__main__": + run() diff --git a/examples/asc_test/master.py b/examples/asc_test/master.py new file mode 100644 index 0000000000000000000000000000000000000000..280552f4647a0974ee5f8c9160d09393e1f6dd0b --- /dev/null +++ b/examples/asc_test/master.py @@ -0,0 +1,45 @@ +from pykat import finesse +from pykat.commands import * +import pylab as pl + +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 pykat files which are used +to generate the Finesse results reported in the document: +`Comparing Finesse simulations, analytical solutions and OSCAR +simulations of Fabry-Perot alignment signals', LIGO-T1300345 + +Andreas Freise 06.12.2013 +-------------------------------------------------------------- +""" + + +kat = finesse.kat(tempdir=".",tempname="test") +#kat = finesse.kat() +kat.verbose = False +kat.loadKatFile('asc_base.kat') +kat.maxtem=3 + +print "--------------------------------------------------------" +print " 1. tunes ETM position to find resonance" +import asc_resonance +kat.ETM.phi=asc_resonance.run(kat) + +print "--------------------------------------------------------" +print " 2. print sideband and carrier powers/amplitudes" +import asc_powers +asc_powers.run(kat) + +print "--------------------------------------------------------" +print " 3. determine the optimal phase for the PDH signal" +import asc_pd_phase +(p_phase, q_phase) = asc_pd_phase.run(kat) + + + + +