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

fixing sagnac example file

parent 53c0f8e7
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from pykat import finesse
from pykat.commands import *
import copy
import pylab as pl
from collections import namedtuple
from collections import OrderedDict
import pylab as pl
from pykat.utilities.plotting.tools import printPDF
import matplotlib
formatter = matplotlib.ticker.EngFormatter(unit='', places=0)
formatter.ENG_PREFIXES[-6] = 'u'
global fig_sagnac
import matplotlib.backends.backend_pdf
def printPDF(self, filename):
pdfp = matplotlib.backends.backend_pdf.PdfPages(filename)
pdfp.savefig(self,dpi=300,bbox_inches='tight')
pdfp.close()
def main():
print """
print("""
--------------------------------------------------------------
Example file for using PyKat to automate Finesse simulations
Finesse: http://www.gwoptics.org/finesse
......@@ -19,7 +35,7 @@ def main():
Andreas Freise 30.10.2014
--------------------------------------------------------------
"""
""")
# defining variables as global for debugging
global kat
global out
......@@ -43,18 +59,11 @@ def main():
result=OrderedDict()
legend = {}
# getting mass of the light mirror of cavity a
# getting mass of the light mirror of cavity a
global m
m = kat.M1a.mass.value
# getting the anle of incidence on end mirrors:
AoI2 = float(kat.constants['AoI2'].value) / 180.*np.pi
# fsig applied to a BS with AoI!=0 reduces the phase
# change for a given signal in meters. Thus to make the
# finesse results comaptible with the default SQL we need
# to scale the results with cos(AoI):
global AoIScale
AoIScale=np.cos(AoI2)
# setting frequency range
global f
f = namedtuple('f', ('start','stop','points','data'))
f.start=100
......@@ -63,34 +72,38 @@ def main():
kat.parseKatCode('xaxis sig1 f log {0} {1} {2}'.format(f.start, f.stop, f.points-1))
# Reading Haixing Miao's reference data:
datah1=np.loadtxt('QN_Sagnac_25ppm_loss.dat')
datah2=np.loadtxt('QN_Sagnac_lossless.dat')
datah1=np.loadtxt('QN_Sagnac_lossless.dat')
datah2=np.loadtxt('QN_Sagnac_25ppm_loss.dat')
# Reading Stefan D. example data:
data=np.loadtxt('Stefan_data.txt')
print "--------------------------------------------------------"
print " Run default file (no loss)"
print ("--------------------------------------------------------")
print (" Run default file (no loss)")
out = kat.run()
#f.data = np.logspace(np.log10(f.start), np.log10(f.stop), f.points)
f.data=out.x # getting frequency vector from Finesse instead
print "--------------------------------------------------------"
print " Computing SQL"
print ("--------------------------------------------------------")
print (" Computing SQL")
hbar=6.62606957E-34/(2.0 *np.pi)
SQL_x= np.sqrt( 4 * hbar / ( m * f.data**2 * 4 * np.pi * np.pi ))
legend['SQL']=mylegend('SQL','k')
result['SQL']=SQL_x
result['default']=out.y*AoIScale
legend['default']=mylegend('Finesse, no loss','m')
result['H1']=datah1[:,1]
legend['H1']=mylegend('Haixing, no loss','k')
legend['H1']=mylegend('Haixing, no loss','g')
legend['H1'].lt='--.'
legend['H1'].lw=2
print "--------------------------------------------------------"
print " Run file with loss (or transmission) on end mirrors"
L=12.5e-6
#L=0
#T=25e-6
T=0
result['default']=out.y*np.cos(AoI2)
legend['default']=mylegend('no loss','m')
print ("--------------------------------------------------------")
L=0
T=12.5e-6
R=1-T-L
kat.M2a.R=R
kat.M3a.R=R
......@@ -105,25 +118,37 @@ def main():
kat.M2b.L=L
kat.M3b.L=L
out=kat.run()
result['loss']=out.y*AoIScale
legend['loss']=mylegend('Finesse, 25ppm loss','b')
result['H2']=datah2[:,1]
legend['H2']=mylegend('Haixing, 25ppm loss','k')
legend['H2']=mylegend('Haixing, 25ppm loss','g')
legend['H2'].lt='-.'
legend['H2'].lw=5
result['loss']=out.y*np.cos(AoI2)
legend['loss']=mylegend('25ppm loss','b')
print "--------------------------------------------------------"
print " Additional imbalanced BS"
result['bs']=imbalanced_bs(kat)*AoIScale
legend['bs']=mylegend('Imbalanced BS 49:51','r')
#result['S_sym']=data[:,1]
#legend['S_sym']=mylegend('Stefan D, balanced','k')
#legend['S_sym'].lt='-.'
print ("--------------------------------------------------------")
print (" 3. Imbalanced BS")
#result['bs']=imbalanced_bs(kat)*np.cos(AoI2)
#legend['bs']=mylegend('Imbalanced BS 49:51','r')
#result['S_imb']=data[:,2]
#legend['S_imb']=mylegend('Stefan D, imbalanced','k')
#legend['S_imb'].lt='--.'
#print "--------------------------------------------------------"
#print " Mass asymmetry"
#result['mass']=mass(kat)*AoIScale
print ("--------------------------------------------------------")
print (" 3. Mass asymmetry")
#result['mass']=mass(kat)
#legend['mass']=mylegend('Mass asymmetry 10%','c')
print "--------------------------------------------------------"
print " Plotting results"
print ("--------------------------------------------------------")
print (" Plotting results")
plot_results(f, result, legend)
......@@ -180,7 +205,7 @@ def plot_results(f, result, legend):
pl.legend(loc=1)
pl.draw()
pl.show(block=0)
printPDF(fig, "speedmeter_plots.pdf")
#printPDF(fig, "speedmeter_plots.pdf")
if __name__ == '__main__':
......
......@@ -6,20 +6,20 @@
# Andreas Freise, 30.10.2014
#
# The parameters below don't necessarily match the current
# speedmeter design, instead they were chosen to fit an example
# file from Stefan Danilishin. However, you can easily change
# the parameters to an updated design without problem.
# speedmeter design, instead they were chosen to match Stefan
# Danilishin's Matlab example for comparison. However, you can
# easily change the parameters to an updated design without
# problem. No special tuning or so is required.
#################################################################
## general constants
const Pin 0.6 # double the power at the BS, which for this example is 0.3W
const MassM1 1m # Mass M1 in [kg]: 1 gramm
const MassM23 100 # Mass M2, M3: 100 gramm
const MassM23 100m # Mass M2, M3: 100 gramm
const T_ETM 0u # transmission of cavity end mirrors (cavity loss)
const L_ETM 0u # loss of cavity end mirrors (cavity loss)
const AoI 0 # angle of incidence on input mirror (4.4 deg)
const AoI2 0 # angle of incidence on end mirror (42.8 deg)
const AoI2 42.8
## lengths of some ray segments
const lrs2 0.250
......@@ -53,12 +53,10 @@ s rs7 $lrs7 nM6e nM7w
bs M7 1 0 0 49.39870535E0 nM7w nM7n dump dump
s rs8 $lrs8 nM7n nM1an
#attr M1a backscatter 0.6u
bs1 M1a 500u 0 0 $AoI nM1aw nM1an nM1ae nM1as
bs1 M1a 500u 0 0 4.4 nM1aw nM1an nM1ae nM1as
attr M1a Rc -7.91
attr M1a mass $MassM1
s rs12 0.6575 nM3an nM1ae
s rs12 1.315 nM3an nM1ae
bs1 M3a $T_ETM $L_ETM 0 $AoI2 nM3aw nM3an nM3aT1 nM3aT2
attr M3a mass $MassM23
s rs11 0.2 1. nM2an nM3aw
......@@ -81,8 +79,7 @@ s rs26 $lrs26 nM8n nM1bw
#################################################################
## Cavity b
#attr M1b backscatter 0.6u
bs1 M1b 500u 0 0 $AoI nM1bw nM1bn nM1be nM1bs
bs1 M1b 500u 0 0 4.4 nM1bw nM1bn nM1be nM1bs
attr M1b Rc -7.91
attr M1b mass $MassM1
s rs19 1.315 nM1be nM2bw
......@@ -115,11 +112,11 @@ s sl2 1n nl2 nl3
bs dHD .5 .5 0 0 nHD1 nout1 nout2 nl3
# homodyne detector, use 180 deg phase for normal use, i.e. output=nout1-nout2
qhdS sens 180 nout1 nout2
# re-scaling output to m/sqrt(Hz)
scale meter sens
#qhdS sens 180 nout1 nout2
# scale output to m/sqrt(Hz)
#scale meter sens
xaxis sig1 f log 100 100k 99
%xaxis sig1 f log 100 100k 99
yaxis log abs
maxtem off
......
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