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

starting to move my asc_test function in here as a clean example

(after iterating quite a bit about the format, I think this
is a good approach at automating a sequence of files,
to be continued...)
parent eb1faaf9
#
#-----------------------------------------------------------------------
# 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
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")
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])
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()
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)
Supports Markdown
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