Skip to content
Snippets Groups Projects
Commit a2ac1b05 authored by Sean Leavey's avatar Sean Leavey
Browse files

Added beam splitter component

parent 116c2d7a
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
"""
Created on Tue Dec 10 14:18:17 2013
@author: Sean
"""
import sys
sys.path.append("../")
import pykat
from pykat.utilities.optics.gaussian_beams import gauss_param
import pykat.finesse as finesse
from pykat.commands import xaxis
import pylab as pl
import numpy as np
import math
code = """
%------------------------------------------------------------------------
% Finesse input file to plot the phase of light field reflected from a
% beam splitter to show the way lengths and positions are handled
% Andreas Freise 15.08.2009
%------------------------------------------------------------------------
l l1 1 0 n1 % laser with P=1W at the default frequency
s s1 1 1 n1 n2 % space of 1m length
bs b1 1 0 0 0 n2 n3 dump dump % beam splitter as `turning mirror'
s s2 1 1 n3 n4 % another space of 1m length
ad ad1 0 n4 % amplitude detector
% for the plot we perform two sequenctial runs of Finesse
% 1) first trace: change microscopic position of beamsplitter
xaxis b1 phi lin 0 180 100
% 2) second trace: change length of space s1
% xaxis s1 L lin 1 2 100
yaxis deg % plotting the phase of the results
"""
kat = finesse.kat()
kat.parseCommands(code)
maxtem = np.arange(0, 2, 2)
for tem in maxtem:
print "Calculating maxtem ", tem, "..."
kat.maxtem = tem
r = kat.run()
pl.plot(r.x, r.y, label="maxtem={0}".format(tem))
pl.ylabel("Phase [deg]")
pl.xlabel("Tuning [deg]")
pl.legend()
pl.show()
# -*- coding: utf-8 -*-
"""
Created on Tue Dec 10 14:18:17 2013
@author: Sean
"""
import sys
sys.path.append("../")
import pykat
from pykat.utilities.optics.gaussian_beams import gauss_param
import pykat.finesse as finesse
from pykat.commands import xaxis
import pylab as pl
import numpy as np
import math
code = """
%------------------------------------------------------------------------
% Finesse input file to plot the phase of light field reflected from a
% beam splitter to show the way lengths and positions are handled
% Andreas Freise 15.08.2009
%------------------------------------------------------------------------
l l1 1 0 n1 % laser with P=1W at the default frequency
s s1 1 1 n1 n2 % space of 1m length
bs b1 1 0 0 0 n2 n3 dump dump % beam splitter as `turning mirror'
s s2 1 1 n3 n4 % another space of 1m length
ad ad1 0 n4 % amplitude detector
% for the plot we perform two sequenctial runs of Finesse
% 1) first trace: change microscopic position of beamsplitter
xaxis b1 phi lin 0 180 100
% 2) second trace: change length of space s1
% xaxis s1 L lin 1 2 100
yaxis deg % plotting the phase of the results
"""
kat = finesse.kat()
kat.parseCommands(code)
maxtem = np.arange(0, 2, 2)
for tem in maxtem:
#print "Calculating maxtem ", tem, "..."
kat.maxtem = tem
r = kat.run()
pl.plot(r.x, r.y, label="maxtem={0}".format(tem))
pl.ylabel("Phase [deg]")
pl.xlabel("Tuning [deg]")
pl.legend()
pl.show()
......@@ -227,6 +227,7 @@ class mirror(Component):
def parseFinesseText(text):
values = text.split(" ")
#if values[0] != "m" and values[0] != "m1" and values[0] != "m2":
if values[0] != "m" and values[0] != "m1" and values[0] != "m2":
raise exceptions.RuntimeError("'{0}' not a valid Finesse mirror command".format(text))
......@@ -266,7 +267,120 @@ class mirror(Component):
self._svgItem = pykat.gui.graphics.ComponentQGraphicsItem(":/resources/mirror_flat.svg", self ,[(-4,15,self.nodes[0]), (14,15,self.nodes[1])])
return self._svgItem
class beamSplitter(Component):
def __init__(self,name,node1,node2,node3,node4,R=0,T=0,phi=0,alpha=0,Rcx=0,Rcy=0,xbeta=0,ybeta=0,mass=0):
Component.__init__(self,name)
self._requested_node_names.append(node1)
self._requested_node_names.append(node2)
self._requested_node_names.append(node3)
self._requested_node_names.append(node4)
self.__R = SIfloat(R)
self.__T = SIfloat(T)
self.__alpha = SIfloat(alpha)
self.__phi = SIfloat(phi)
self.__Rcx = SIfloat(Rcx)
self.__Rcy = SIfloat(Rcy)
self.__xbeta = SIfloat(xbeta)
self.__ybeta = SIfloat(ybeta)
@property
def R(self): return Param('R', self.__R)
@R.setter
def R(self,value): self.__R = SIfloat(value)
@property
def T(self): return Param('T', self.__T)
@T.setter
def T(self,value): self.__T = SIfloat(value)
@property
def phi(self): return Param('phi', self.__phi)
@phi.setter
def phi(self,value): self.__phi = SIfloat(value)
@property
def alpha(self): return Param('alpha', self.__alpha)
@alpha.setter
def alpha(self,value): self.__alpha = SIfloat(value)
@property
def Rcx(self): return Param('Rcx', self.__Rcx)
@Rcx.setter
def Rcx(self,value): self.__Rcx = SIfloat(value)
@property
def Rcy(self): return Param('Rcy', self.__Rcy)
@Rcy.setter
def Rcy(self,value): self.__Rcy = SIfloat(value)
@property
def xbeta(self): return Param('xbeta', self.__xbeta)
@xbeta.setter
def xbeta(self,value): self.__xbeta = SIfloat(value)
@property
def ybeta(self): return Param('ybeta', self.__ybeta)
@ybeta.setter
def ybeta(self,value): self.__ybeta = SIfloat(value)
@property
def Rc(self):
if self.Rcx == self.Rcy:
return self.Rcx
else:
return [self.Rcx, self.Rcy]
@Rc.setter
def Rc(self,value):
self.Rcx = SIfloat(value)
self.Rcy = SIfloat(value)
@staticmethod
def parseFinesseText(text):
values = text.split(" ")
if values[0] != "bs" and values[0] != "bs1" and values[0] != "bs2":
raise exceptions.RuntimeError("'{0}' not a valid Finesse beam splitter command".format(text))
if len(values) != 10:
raise exceptions.RuntimeError("Beam splitter Finesse code format incorrect '{0}'".format(text))
if len(values[0])==1:
values.pop(0) # remove initial value
return beamSplitter(values[0], values[5], values[6], values[7], values[8], values[1], values[2], values[3], values[4])
else:
if values[0][1]=="1":
values.pop(0) # remove initial value
return beamSplitter(values[0], values[5], values[6], values[7], values[8], 1.0 - SIfloat(values[1]) - SIfloat(values[2]), values[1], values[3], values[4])
else:
values.pop(0) # remove initial value
return beamSplitter(values[0], values[5], values[6], values[7], values[8], values[1], 1.0 - SIfloat(values[1]) - SIfloat(values[2]), values[3], values[4])
def getFinesseText(self):
rtn = []
rtn.append('bs {0} {1} {2} {3} {4} {5} {6} {7} {8}'.format(
self.name, self.__R, self.__T, self.__phi,
self.__alpha, self.nodes[0].name,
self.nodes[1].name, self.nodes[2].name,
self.nodes[3].name))
if self.Rcx != 0: rtn.append("attr {0} Rcx {1}".format(self.name,self.__Rcx))
if self.Rcy != 0: rtn.append("attr {0} Rcy {1}".format(self.name,self.__Rcy))
if self.xbeta != 0: rtn.append("attr {0} xbeta {1}".format(self.name,self.__xbeta))
if self.ybeta != 0: rtn.append("attr {0} ybeta {1}".format(self.name,self.__ybeta))
return rtn
def getQGraphicsItem(self):
if self._svgItem == None:
# FIXME: make proper SVG component for beam splitter
self._svgItem = pykat.gui.graphics.ComponentQGraphicsItem(":/resources/mirror_flat.svg", self ,[(-4,15,self.nodes[0]), (14,15,self.nodes[1])])
return self._svgItem
class space(Component):
def __init__(self, name, node1, node2, L=0, n=1):
......
......@@ -203,6 +203,8 @@ class kat(object):
obj = pykat.components.space.parseFinesseText(line)
elif(first == "l"):
obj = pykat.components.laser.parseFinesseText(line)
elif(first[0:2] == "bs"):
obj = pykat.components.beamSplitter.parseFinesseText(line)
elif(first[0:2] == "pd"):
obj = pykat.detectors.photodiode.parseFinesseText(line)
elif(first == "xaxis" or first == "x2axis" or first == "xaxis*" or first == "x2axis*"):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment