Commit 7ff05a8c authored by Andreas Freise's avatar Andreas Freise
Browse files

trying to adapt asc example to new pykat syntax, runs up to master4, which gives wrong results

parent f05991ad
......@@ -33,6 +33,7 @@ def main():
""")
# for debugging we might need to see the temporay file:
global kat
kat = finesse.kat(tempdir=".",tempname="test")
kat.verbose = False
kat.loadKatFile('asc_base.kat')
......@@ -105,7 +106,7 @@ def pd_signal(tmpkat):
"""
kat.parseKatCode(code1)
kat.noxaxis = True
#global out
global out
out = kat.run()
print(" Cavity power: {0:.6f}W".format(out.y[0,2]))
return (out.y[0,0], out.y[0,1])
......@@ -123,8 +124,7 @@ def pd_phase(tmpkat):
# function for root finding
def PD_q_test(x):
kat.PDrefl_q.phi1=x
kat.PDrefl_q.phase1=x
out = kat.run()
print('\r root finding: function value %g ' % out.y, end=' ')
sys.stdout.flush()
......@@ -132,6 +132,8 @@ def pd_phase(tmpkat):
# do root finding
xtol=1e-8
#print("Starting values for bisect are: %e and %e \n" % (PD_q_test(60.0),PD_q_test(100.0)))
(result, info)=scipy.optimize.bisect(PD_q_test,80.0,100.0, xtol=xtol, maxiter=500, full_output=True)
......
......@@ -101,10 +101,10 @@ def main():
kat.parseKatCode(code_WFS2)
(WFS1_phase, WFS2_phase) = asc_phases(kat)
kat.WFS1_I.phi1=WFS1_phase
kat.WFS1_Q.phi1=WFS1_phase+90.0
kat.WFS2_I.phi1=WFS2_phase
kat.WFS2_Q.phi1=WFS2_phase+90.0
kat.WFS1_I.phase1=WFS1_phase
kat.WFS1_Q.phase1=WFS1_phase+90.0
kat.WFS2_I.phase1=WFS2_phase
kat.WFS2_Q.phase1=WFS2_phase+90.0
result['WFS1_phase']=WFS1_phase
result['WFS2_phase']=WFS2_phase
......@@ -183,7 +183,7 @@ def asc_phases(tmpkat):
kat.maxtem=1
def demod_phase1(x):
kat.WFS1_I.phi1=x[0]
kat.WFS1_I.phase1=x[0]
out = kat.run()
signal = out["WFS1_I"]
print('\r minimising: function value %g ' % signal, end=' ')
......@@ -191,7 +191,7 @@ def asc_phases(tmpkat):
return -1*abs(signal)
def demod_phase2(x):
kat.WFS2_I.phi1=x[0]
kat.WFS2_I.phase1=x[0]
out = kat.run()
signal = out["WFS2_I"]
print('\r minimising: function value %g ' % signal, end=' ')
......
......@@ -97,7 +97,7 @@ def asc_large(tmpkat, mir_name):
done_maxtems.append(tem)
print(" Calculating maxtem = %d " % tem)
kat.maxtem = tem
out[str(tem)] = kat.run(printout=0,printerr=1)
out[str(tem)] = kat.run()
import os.path
if os.path.isfile(tmpfilename):
shutil.copyfile(tmpfilename, backupname)
......
......@@ -190,7 +190,7 @@ def get_qs(tmpkat,f):
# add thermal lens and propagate input beam to ITM
kat = set_thermal_lens(kat, f)
out = kat.run(printout=0,printerr=0)
out = kat.run()
# computing beam size at ITM
# and then we reflect of ITM, an set it as new startnode
......@@ -207,7 +207,7 @@ def get_qs(tmpkat,f):
else:
kat.ITM.nITM1.node.setGauss(kat.ITM, beam1)
kat.parseKatCode("startnode nITM1")
out = kat.run(printout=0,printerr=0)
out = kat.run()
# computing beam size at WFS1 and WFS2
q2 = out['w2']
......@@ -228,7 +228,7 @@ def get_qs(tmpkat,f):
return [beam1, beam2, beam3, beam4]
global out
# run finesse with input laser mode matched to cavity (no thermal lens)
out = kat.run(printout=0,printerr=0)
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)
......@@ -256,13 +256,13 @@ def asc_signal(tmpkat):
signal=np.zeros((2, 2))
kat.ITM.ybeta=1e-10
kat.ETM.ybeta=0.0
out = kat.run(printout=0,printerr=0)
out = kat.run()
signal[0,0] = out["WFS1_I"]
signal[1,0] = out["WFS2_I"]
kat.ITM.ybeta=0.0
kat.ETM.ybeta=-1e-10
out = kat.run(printout=0,printerr=0)
out = kat.run()
signal[0,1] = out["WFS1_I"]
signal[1,1] = out["WFS2_I"]
signal = signal *1e10
......@@ -281,7 +281,7 @@ def gravity_tilt(tmpkat):
def compute_gravity_tilt(tmpkat):
kat = copy.deepcopy(tmpkat)
out = kat.run(printout=0,printerr=0)
out = kat.run()
y1 = out["b1"]
y2 = out["b1_1k"]
......
......@@ -146,7 +146,7 @@ def get_qs(tmpkat):
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(printout=0,printerr=0)
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)
......@@ -159,7 +159,7 @@ def get_qs(tmpkat):
kat.ITM_TL.f=f
if "ITM_TL_r" in kat._kat__components:
kat.ITM_TL_r.f=f
out = kat.run(printout=0,printerr=0)
out = kat.run()
# computing beam size at ITM
# and then we reflect of ITM, an set it as new startnode
......@@ -176,7 +176,7 @@ def get_qs(tmpkat):
else:
kat.ITM.nITM1.node.setGauss(kat.ITM, beam1)
kat.parseKatCode("startnode nITM1")
out = kat.run(printout=0,printerr=0)
out = kat.run()
# computing beam size at WFS1 and WFS2
q2 = out['w2']
......@@ -215,7 +215,7 @@ def asc_signal(tmpkat):
signal=np.zeros((2, 2))
kat.ITM.ybeta=1e-10
kat.ETM.ybeta=0.0
out = kat.run(printout=0,printerr=0)
out = kat.run()
WFS1_idx=out.ylabels.index("WFS1_I")
WFS2_idx=out.ylabels.index("WFS2_I")
signal[0,0] = out.y[WFS1_idx]
......@@ -223,7 +223,7 @@ def asc_signal(tmpkat):
kat.ITM.ybeta=0.0
kat.ETM.ybeta=-1e-10
out = kat.run(printout=0,printerr=0)
out = kat.run()
signal[0,1] = out.y[WFS1_idx]
signal[1,1] = out.y[WFS2_idx]
signal = signal *1e10
......@@ -247,7 +247,7 @@ def asc_phases(tmpkat):
def demod_phase1(x):
kat.WFS1_I.phi[0]=x
out = kat.run(printout=0,printerr=0)
out = kat.run()
WFS1_idx=out.ylabels.index("WFS1_I")
signal = out.y[WFS1_idx]
print('\r minimising: function value %g ' % signal, end=' ')
......@@ -256,7 +256,7 @@ def asc_phases(tmpkat):
def demod_phase2(x):
kat.WFS2_I.phi[0]=x
out = kat.run(printout=0,printerr=0)
out = kat.run()
WFS2_idx=out.ylabels.index("WFS2_I")
signal = out.y[WFS2_idx]
print('\r minimising: function value %g ' % signal, end=' ')
......@@ -283,7 +283,7 @@ def gravity_tilt(tmpkat):
def compute_gravity_tilt(tmpkat):
kat = copy.deepcopy(tmpkat)
out = kat.run(printout=0,printerr=0)
out = kat.run()
y1 = out["b1"]
y2 = out["b1_1k"]
......@@ -364,7 +364,7 @@ def beam_size(tmpkat, beam2, beam3):
kat.po.nWFS1.node.setGauss(kat.po,beam2)
out = kat.run(printout=0,printerr=0)
out = kat.run()
WFS1_idx=out.ylabels.index("wWFS1")
WFS2_idx=out.ylabels.index("wWFS2")
......@@ -380,7 +380,7 @@ def beam_size(tmpkat, beam2, beam3):
if "ITM_TL_r" in kat._kat__components:
kat.ITM_TL_r.f=5e3
kat.po.nWFS1.node.setGauss(kat.po,beam3)
out = kat.run(printout=0,printerr=0)
out = kat.run()
y1 = out.y[WFS1_idx]
y2 = out.y[WFS2_idx]
print(" Beam size with thermal lens f={0}".format(kat.ITM_TL.f))
......
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