Commit 1487f402 authored by Sean Leavey's avatar Sean Leavey
Browse files

Added lens component

parent ee9aae95
......@@ -17,6 +17,7 @@ s s1 10 1 n1 n2
m m1 1 0 0 n2 n3
gr4 grating 1500 n4 n5 n6 n7
isol isolator 60 n8 n9
lens lens 10 n10 n11
pd refl n2
......
......@@ -556,6 +556,43 @@ class isolator(Component):
self._QItem = pykat.gui.graphics.SpaceQGraphicsItem(self) # TODO: make isolator graphic
return self._QItem
class lens(Component):
def __init__(self, name, node1, node2, f):
Component.__init__(self, name)
self._requested_node_names.append(node1)
self._requested_node_names.append(node2)
self.__f = SIfloat(f)
@property
def f(self): return Param('f', self.__f)
@f.setter
def f(self, value): self.__f = SIfloat(value)
@staticmethod
def parseFinesseText(text):
values = text.split(" ")
if values[0] != "lens":
raise exceptions.RuntimeError("'{0}' not a valid Finesse lens command".format(text))
values.pop(0) # remove initial value
if len(values) == 4:
return lens(values[0], values[2], values[3], values[1])
else:
raise exceptions.RuntimeError("Lens Finesse code format incorrect '{0}'".format(text))
def getFinesseText(self):
return 'lens {0} {1} {2} {3}'.format(self.name, self.f, self.nodes[0].name, self.nodes[1].name)
def getQGraphicsItem(self):
if self._QItem == None:
self._QItem = pykat.gui.graphics.SpaceQGraphicsItem(self) # TODO: make lens graphic
return self._QItem
class laser(Component):
def __init__(self,name,node,P=1,f_offset=0,phase=0):
......
......@@ -209,6 +209,8 @@ class kat(object):
obj = pykat.components.grating.parseFinesseText(line)
elif(first[0:4] == "isol"):
obj = pykat.components.isolator.parseFinesseText(line)
elif(first[0:4] == "lens"):
obj = pykat.components.lens.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*"):
......
Markdown is supported
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