Commit 294252ca authored by Daniel Brown's avatar Daniel Brown
Browse files

finishing gauss param parsing

parent 20571997
......@@ -11,16 +11,16 @@ s s1 10 1 n1 n2
m m1 1 0 0 n2 n3
pd refl n2
gauss g1 m1 n2 1e-3 0
xaxis m1 r_ap lin 0.1e-3 2e-3 10
"""
kat = finesse.kat()
kat.parseCommands(code)
maxtem = np.arange(0, 2, 2)
maxtem = np.linspace(0, 1, 2)
kat.m1.n2.q = gauss_param(w0=1e-3, z=0)
#kat.m1.n2.q = gauss_param(w0=1e-3, z=0)
for tem in maxtem:
print "Calculating maxtem ", tem, "..."
......
......@@ -12,6 +12,7 @@ from structs import *
from pykat.param import Param, putter
import pykat.exceptions as pkex
from collections import namedtuple
from pykat.utilities.optics.gaussian_beams import gauss_param
class Command(object):
def __init__(self):
......@@ -54,23 +55,29 @@ class gauss(object):
component = values[2]
node = values[3]
if values[0].endswith("**"):
if values[0]:
if len(values) == 6:
print ""
gp = gauss_param(w0=values[-2], z=values[-1])
elif len(values) == 8:
print ""
gpx = gauss_param(w0=values[-4], z=values[-3])
gpy = gauss_param(w0=values[-2], z=values[-1])
elif values[0].endswith("*"):
if len(values) == 6:
print ""
gp = gauss_param(z=values[-2], zr=values[-1])
elif len(values) == 8:
print ""
gpx = gauss_param(z=values[-4], zr=values[-3])
gpy = gauss_param(z=values[-2], zr=values[-1])
else:
if len(values) == 6:
print ""
gp = gauss_param(w=values[-2], rc=values[-1])
elif len(values) == 8:
print ""
gpx = gauss_param(w=values[-4], rc=values[-3])
gpy = gauss_param(w=values[-2], rc=values[-1])
if len(values) == 6:
kat.nodes[node].setGauss(kat.components[component], gp)
else:
kat.nodes[node].setGauss(kat.components[component], gpx, gpy)
class tf(Command):
fQ = namedtuple('fQ', ['f', 'Q'])
......
......@@ -310,6 +310,14 @@ class kat(object):
@getPerformanceData.setter
def getPerformanceData(self,value): self.__time_code = bool(value)
@property
def components(self):
return self.__components.copy()
@property
def detectors(self):
return self.__detectors.copy()
@property
def noxaxis(self): return self.__noxaxis
@noxaxis.setter
......
......@@ -24,11 +24,11 @@ class gauss_param(object):
def __init__(self, wavelength=1064e-9, nr=1, *args, **kwargs):
self.__q = None
self.__lambda = wavelength
self.__nr = nr
self.__lambda = float(wavelength)
self.__nr = float(nr)
if len(args) == 1:
self.__q = args[0]
self.__q = complex(args[0])
elif len(kwargs) == 1:
if "q" in kwargs:
......@@ -39,11 +39,11 @@ class gauss_param(object):
elif len(kwargs) == 2:
if "w0" in kwargs and "z" in kwargs:
q = float(kwargs["z"]) + 1j *float(math.pi*kwargs["w0"]**2/(self.__lambda/self.__nr) )
q = float(kwargs["z"]) + 1j *float(math.pi*float(kwargs["w0"])**2/(self.__lambda/self.__nr) )
elif "z" in kwargs and "zr" in kwargs:
q = float(kwargs["z"]) + 1j *float(kwargs["zr"])
elif "rc" in kwargs and "w" in kwargs:
one_q = 1 / kwargs["rc"] - 1j * self.__lamda / (math.pi * self.__nr * kwargs["w"]**2)
one_q = 1 / float(kwargs["rc"]) - 1j * self.__lamda / (math.pi * self.__nr * float(kwargs["w"])**2)
q = 1/one_q
else:
raise pkex.BasePyKatException("Must specify: z and w0 or z and zr or rc and w or q, to define the beam parameter")
......
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