gtrace.beam
gtrace.beam
A module to define GaussianBeam class.
Attributes
Classes
This is a class to represent a Gaussian beam. |
Functions
|
A function to return the distance between the point on |
|
Caltulate optimal starting point. |
|
A function to return the distance between the point on |
|
Caltulate optimal end point. |
|
A function to return the distance between the point on |
|
Caltulate optimal cross point. |
Module Contents
- gtrace.beam.pi
- gtrace.beam.array
- gtrace.beam.sqrt
- gtrace.beam.__author__ = 'Yoichi Aso'
- gtrace.beam.__copyright__ = 'Copyright 2011-2026, Yoichi Aso'
- gtrace.beam.__credits__ = ['Yoichi Aso']
- gtrace.beam.__license__ = 'BSD'
- gtrace.beam.__version__ = '0.8.0'
- gtrace.beam.__maintainer__ = 'Yoichi Aso'
- gtrace.beam.__email__ = 'asoy01@gmail.com'
- gtrace.beam.__status__ = 'Beta'
- class gtrace.beam.GaussianBeam(q0=1j * 2 * pi / 1064 * nm * 1e-06 / 2, q0x=False, q0y=False, pos=[0.0, 0.0], length=1.0, dirAngle=0.0, dirVect=None, wl=1064 * nm, P=1 * W, n=1.0, name='Beam', layer='main_beam')
Bases:
traits.api.HasTraitsThis is a class to represent a Gaussian beam. A GaussianBeam object has its origin (pos) and a propagation direction (dirVect or dirAngle). A GaussianBeam is characterized by q-parameter(s) at its origin. The beam can be either circular or elliptic. In order to deal with elliptic beams, some parameters are stored in pairs like (q0x, q0y). x and y denote the axes of the cross section of the beam. x-axis is parallel to the paper and the y-axis is perpendicular to the paper.
A beam object can be propagated through a free space or made to interact with an optics.
As a beam propagate through optical system, optical distance and Gouy phase are accumerated.
- Variables:
q (complex) – q-parameter of the beam. If the beam is eliptic, q is the q-parameter of the best matching circular mode.
qx (complex) – q-parameter of the beam in the x-direction.
qy (complex) – q-parameter of the beam in the y-direction.
pos (array) – Position of the beam origin (x, y).
dirVect (array) – Propagation direction vector.
dirAngle (float) – Propagation direction angle measured from the positive x-axis.
length (float) – Length of the beam (used for DXF export)
layer (str) – Layer name of the beam when exported to a DXF file.
name (str) – Name of the beam
wl (float) – Wavelength in vacuum. Not the wavelength in the medium.
n (float) – Index of refraction of the medium the beam is passing through.
P (float) – Power.
wx (float) – Beamwidth in x-direction.
wy (float) – Beamwidth in y-direction.
optDist (float) – Accumulated optical distance.
Gouyx (float) – Accumulated Gouy phase in x-direction.
Gouyy (float) – Accumulated Gouy phase in y-direction.
Mx (array) – ABCD matrix in x-direction. This is a 2x2 matrix representing the product of ABCD transformations applied to this beam. It defaults to an identity matrix. Whenever a beam experience an ABCD matrix transformation, such as propagation in the space or reflection by a curved mirror, the applied ABCD matrix is multiplied to this matrix, so that we can keep track of what kind of transformations were made during beam propagation.
My (array) – ABCD matrix in y-direction. The meaning is the same as Mx.
departSurfAngle (None) – The angle formed by x-axis and the normal vector of the surface from which the beam is departing. Default is None. Used by the drawing routine.
departSurfInvROC (None) – Inverse of the ROC of the surface from which the beam is departing. The ROC is positive for a concave surface seen from the beam side. Default is None. Used by the drawing routine.
incSurfAngle (None) – The angle formed by the x-arm and the normal vector of the surface to which the beam is incident. Default is None. Used by the drawing routine.
incSurfInvROC (None) – Inverse of the ROC of the surface to which the beam is incident. The ROC is positive for a concave surface seen from the beam side. Default is None. Used by the drawing routine.
stray_order (int) – An integer indicating if this beam is a stray light or not. The default value is 0. Every time a beam is reflected by an AR surface or transmits an HR surface, this couter is increased by 1.
- name
- wl
- P
- q
- qx
- qy
- qrx
- qry
- Gouyx
- Gouyy
- wx
- wy
- n
- pos
- length
- layer
- dirVect
- dirAngle
- optDist
- Mx
- My
- departSurfAngle = None
- departSurfInvROC = None
- incSurfAngle = None
- incSurfInvROC = None
- stray_order = 0
- copy()
Another beam with the same values.
Arrays are duplicated, so writing into the position or the ABCD matrix of the copy does not reach the original. Anything else the beam carries is shared with it: a list attached to a beam is the same list on the copy. That is what this has always done - the traits machinery duplicated the traits and left plain attributes pointing at the originals - and the docstring used to call it a deep copy, which it is not.
Tracing a layout copies a beam at every surface it meets, tens of thousands of times over a layout of any size, so this is written to be cheap: the values are written straight into the new object’s dictionary, where traits keeps them anyway.
Copying the dictionary rather than listing the fields is what makes the rest true. An attribute put on a beam by hand comes along, a subclass of GaussianBeam copies as itself, and a trait added here later needs nothing doing to it. The values still arrive validated, because they were validated when they were first set.
Nothing is assigned through a trait, so no change handler runs, and that is the point. Assigning them one at a time is what used to leave the reduced q, and the circular q of a beam in glass, derived from a half-built beam and needing to be put back afterwards. Here the finished values are simply carried over.
- Returns:
Of the same class as this beam.
- Return type:
- propagate(d)
Propagate the beam by a distance d from the current position. self.n is used as the index of refraction. During this process, the optical distance traveled is added to self.optDist. self.Goux and self.Gouyy are also updated to record the Gouy phase change.
- Parameters:
d (float) – Distance.
- ABCDTrans(ABCDx, ABCDy=None)
Apply ABCD transformation to the beam.
- rotate(angle, center=False)
Rotate the beam around ‘center’. If center is not given, the beam is rotated around self.pos.
- Parameters:
angle (float) – Rotation angle in radians.
center (array or boolean.) – Center of rotation. Should be an array of shape(2,). Defaults False.
- translate(trVect)
Translate the beam by the direction and the distance specified by a vector.
- Parameters:
trVect (array) – A vector to specify the translation direction and distance. Should be an array of shape(2,)
- flip(flipDirVect=True)
Change the propagation direction of the beam by 180 degrees. This is equivalent to the reflection of the beam by a spherical mirror with the same ROC as the beam.
If optional argument flipDirVect is set to False, the propagation direction of the beam is not changed.
- Parameters:
flipDirVect (boolean, optional) – Flip propagation direction. Defaults True.
- width(dist)
Returns the beam width at a distance dist from the origin of the beam. The width is the radius where the light power becomes 1/e^2.
- Parameters:
dist (float) – Distance.
- Returns:
The width of the beam in x and y direction.
- Return type:
(float, float)
- R(dist=0.0)
Returns the beam ROC at a distance dist from the origin of the beam.
dist is a geometric distance, as in propagate() and width(): self.qx and self.qy advance by dist itself, not by dist/self.n (the index of refraction is already accounted for in the q-parameters, which are related to the reduced ones qrx and qry by a factor of n).
At a waist the ROC is infinite; inf is returned there.
- Parameters:
dist (float, optional) – Distance.
- Returns:
Beam ROC.
- Return type:
(float, float)
- waist()
Return the tuples of waist size and distance
- Returns:
{“Waist Size”: (float, float), “Waist Position”: (float, float)}
- Return type:
dict
- draw(cv, sigma=3.0, mode='x', drawWidth=True, fontSize=False, drawPower=False, drawROC=False, drawGouy=False, drawOptDist=False, drawName=False, debug=False)
Draw the beam into a DXF object.
- Parameters:
cv (gtrace.draw.draw.Canvas) – gtrace canvas.
sigma (float, optional) – The width of the beam drawn is sigma * (1/e^2 radius of the beam). The default is sigma = 3. sigma = 2.7 gives 1ppm diffraction loss. Defaults 3.
mode (str, optional) – ‘avg’, ‘x’, or ‘y’. A beam can have different widths for x- and y- directions. If ‘avg’ is specified, the average of them are drawn. ‘x’ and ‘y’ specifies to show the width of the respective directions. Defaults ‘x’.
fontSize (float, optional) – Size of the font used to show supplemental informations. Defaults False.
drawWidth (boolean, optional) – Whether to draw width or not. Defaults True.
drawPower (boolean, optional) – Whether to show the beam power. Defaults False.
drawROC (boolean, optional) – Whether to show the ROC or not. Defaults False.
drawGouy (boolean, optional) – Whether to show the Gouy phase or not. Defaults False.
drawOptDist (boolean, optional) – Whether to show the accumulated optical distance or not. Defaults False.
drawName (boolean, optional) – Whether draw the name of the beam or not. Defaults False.
debug (boolean, optional) – Debug.
- drawWidth(cv, sigma, mode)
Draw width on canvas.
- Parameters:
cv (gtrace.draw.draw.Canvas) – The canvas.
sigma (float) – The width of the beam drawn is sigma * (1/e^2 radius of the beam). The default is sigma = 3. sigma = 2.7 gives 1ppm diffraction loss.
mode (str) – ‘avg’, ‘x’, or ‘y’. A beam can have different widths for x- and y- directions. If ‘avg’ is specified, the average of them are drawn. ‘x’ and ‘y’ specifies to show the width of the respective directions.
- _dirAngle_changed(old, new)
- _dirVect_changed(old, new)
- _qx_changed(old, new)
- _qy_changed(old, new)
- _qrx_changed(old, new)
- _qry_changed(old, new)
- _n_changed(old, new)
- gtrace.beam.optFunForStartPointR(phi, Mrot, R, q0, k, sigma, side)
A function to return the distance between the point on the spherical surface at an angle phi and the beam width at the same z.
- Parameters:
phi (float) – phi
Mrot (array) – Rotational transformation.
R (float) – R
q0 (complex) – Beam parameter.
k (float) – k
sigma (float) – Beam width
side – side
- Returns:
Distance between the point on the spherical surface at an angle phi and the beam width at the same z.
- Return type:
float
- gtrace.beam.optimStartPointR(theta, R, q0, k, sigma)
Caltulate optimal starting point.
Paramters
- thetafloat
theta
- Rfloat
R
- q0complex
Beam parameter.
- kfloat
k
- sigmafloat
Beam width.
- returns:
Optimal starting point.
- rtype:
(float, float)
- gtrace.beam.optFunForEndPointR(phi, Mrot, R, q0, k, sigma, side)
A function to return the distance between the point on the spherical surface at an angle phi and the beam width at the same z.
- Parameters:
phi (float) – phi
Mrot (array) – Rotational transformation.
R (float) – R
q0 (complex) – Beam parameter.
k (float) – k
sigma (float) – Beam width
side – side
- Returns:
Distance between the point on the spherical surface at an angle phi and the beam width at the same z.
- Return type:
float
- gtrace.beam.optimEndPointR(theta, R, q0, k, sigma)
Caltulate optimal end point.
Paramters
- thetafloat
theta
- Rfloat
R
- q0complex
Beam parameter.
- kfloat
k
- sigmafloat
Beam width.
- returns:
Optimal end point.
- rtype:
(float, float)
- gtrace.beam.optFunForFlat(a, Mrot, q0, k, sigma, side)
A function to return the distance between the point on the spherical surface (flat?) at an angle phi and the beam width at the same z.
- Parameters:
a (float) – a
Mrot (array) – Rotational transformation.
q0 (complex) – Beam parameter.
k (float) – k
sigma (float) – Beam width
side – side
- Returns:
Distance between the point on the spherical surface at an angle phi and the beam width at the same z.
- Return type:
float