Skip to content
Snippets Groups Projects
Commit bdb772ad authored by Andreas Freise's avatar Andreas Freise
Browse files

fixing sagnac example file

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