gtrace package¶
Subpackages¶
Submodules¶
gtrace.beam module¶
gtrace.beam
A module to define GaussianBeam class.
-
class
gtrace.beam.
GaussianBeam
(q0=2.952624674426497j, q0x=False, q0y=False, pos=[0.0, 0.0], length=1.0, dirAngle=0.0, dirVect=None, wl=1.064e-06, P=1.0, n=1.0, name='Beam', layer='main_beam')¶ Bases:
traits.has_traits.HasTraits
This 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.
=== Attributes ===
- q: q-parameter of the beam. If the beam is eliptic, q is the q-parameter
of the best matching circular mode.
qx: q-parameter of the beam in the x-direction. [complex float]
qy: q-parameter of the beam in the y-direction. [complex float]
pos: Position of the beam origin. [(2,) float array]
dirVect: Propagation direction vector. [(2,) float array]
dirAngle: Propagation direction angle measured from the positive x-axis. [float]
length: Length of the beam (used for DXF export) [float]
layer: Layer name of the beam when exported to a DXF file.
name: Name of the beam
wl: Wavelength in vacuum. Not the wavelength in the medium. [float]
n: Index of refraction of the medium the beam is passing through. [float]
P: Power [float]
wx: Beamwidth in x-direction [float]
wy: Beamwidth in y-direction [float]
optDist: Accumulated optical distance.
Gouyx: Accumulated Gouy phase in x-direction.
Gouyy: Accumulated Gouy phase in y-direction.
- Mx: 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: ABCD matrix in y-direction. The meaning is the same as Mx.
- departSurfAngle: 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: 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: 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: 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: 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.
-
ABCDTrans
(ABCDx, ABCDy=None)¶ Apply ABCD transformation to the beam.
ABCDx: ABCD matrix for x-direction
ABCDy: ABCD matrix for y-direction
-
R
(dist=0.0)¶ Returns the beam ROC at a distance dist from the origin of the beam.
-
copy
()¶ Make a deep copy.
-
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.
Arguments
cv: draw.Canvas object.
- sigma: 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. [float]
- mode: ‘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.
fontSize: Size of the font used to show supplemental informations. [float]
drawWidth: Whether to draw width or not. [Boolean]
drawPower: Whether to show the beam power. [Boolean]
drawROC: Whether to show the ROC or not. [Boolean]
drawGouy: Whether to show the Gouy phase or not. [Boolean]
drawOptDist: Whether to show the accumulated optical distance or not. [Boolean]
drawName: Whether draw the name of the beam or not. [Boolean]
-
drawWidth
(cv, sigma, mode)¶
-
drawWidthOld
(dxf, sigma, mode)¶
-
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.
-
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.
-
rotate
(angle, center=False)¶ Rotate the beam around ‘center’. If center is not given, the beam is rotated around self.pos.
Arguments
angle: Rotation angle in radians.
center: Center for rotation. [(2,) array of float]
-
translate
(trVect)¶ Translate the beam by the direction and the distance specified by a vector.
Arguments
- trVect: A vector to specify the translation direction and
distance. [(2,) float array]
-
waist
()¶ Return the tuples of waist size and distance
-
width
(dist)¶ Returns the beam width at a distance dist from the origin of the beam. The width is the readius where the light power becomes 1/e^2.
-
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.
-
gtrace.beam.
optFunForFlat
(a, Mrot, 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.
-
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.
-
gtrace.beam.
optimCrossPointFlat
(theta, q0, k, sigma)¶
-
gtrace.beam.
optimEndPointR
(theta, R, q0, k, sigma)¶
-
gtrace.beam.
optimStartPointR
(theta, R, q0, k, sigma)¶
gtrace.nonsequential module¶
gtrace.nonsequential
A module to perform non-sequential trace of a beam in an optical system.
-
gtrace.nonsequential.
non_seq_trace
(optList, src_beam, order=10, power_threshold=0.1, open_beam_length=1.0)¶ Perform non-sequential trace of the source beam, src_beam, through the optical system represented by a collection of optics, optList.
The return value of this function is a list of beams.
== Arguments ==
open_beam_length: open beams (beams not hitting anything) will have this length.
gtrace.optcomp module¶
Define optical components for gtrace.
-
class
gtrace.optcomp.
CyMirror
(HRcenter=[0.0, 0.0], normAngleHR=0.0, normVectHR=None, diameter=0.25, thickness=0.15, wedgeAngle=0.004363323129985824, inv_ROC_HR=0.00014285714285714287, inv_ROC_AR=0.0, Refl_HR=0.99, Trans_HR=0.01, Refl_AR=0.01, Trans_AR=0.99, n=1.45, name='Mirror', HRtransmissive=False, term_on_HR=False, curve_direction='h')¶ Bases:
gtrace.optcomp.Mirror
Representing a partial reflective cylindrical mirror. Note that both HR and AR surfaces are treated as cylindrical if you specify non-zero ROC for them. The curve directions of the two surfaces must be the same.
=== Attributes ===
curve_direction: Either ‘h’ or ‘v’. If it is ‘h’ the mirror is curved in horizontal plane. If ‘v’, it is vertical.
- HRcenter: The position of the center of the arc of the HR surface.
[(2,) float array]
- HRcenterC: The position of the center of the chord of the HR surface.
[(2,) float array]
normVectHR: Normal vector of the HR surface.
normAngleHR: Angle of the HR normal vector.
- ARcenter: The position of the center of the AR surface.
[(2,) float array]
normVectAR: Normal vector of the HR surface.
normAngleAR: Angle of the HR normal vector.
- HRtransmissive: A boolean value defaults to False. If True, this mirror
is supposed to transmit beams on the HR surface. Therefore, for the first encounter of a beam on the HR surface of this mirror will not increase the stray_order. This flag should be set to True for beam splitters and input test masses.
- term_on_HR: If this is True, a beam with stray_order <= self.term_on_HR_order will be terminated when
it hits on HR. This is to avoid the inifinite loop of non-sequencial trace by forming a cavity.
- term_on_HR_order: Integer to specify the upper limit of the stray order used to judge
whether to terminate the non sequential trace or not on HR reflection.
-
copy
()¶
-
draw
(cv, drawName=False)¶ Draw itself
-
get_side_info
()¶ Return information on the sides of the mirror. Returned value is a list of two tuples like [(center1, normVect1, length1), (center2, normVect2, length2)] Each tuple corresponds to a side. center1 is the coordinates of the center of the side line. normVect1 is the normal vector of the side line. length1 is the length of the side line.
-
hitFromAR
(beam, order=0, threshold=0.0, verbose=False)¶ Compute the reflected and deflected beams when an input beam hit the AR surface.
The internal reflections are computed as long as the number of internal reflections are below the
order
and the power of the reflected beams is over the threshold.
-
hitFromHR
(beam, order=0, threshold=0.0, verbose=False)¶ Compute the reflected and deflected beams when an input beam hit the HR surface.
The internal reflections are computed as long as the number of internal reflections are below the
order
and the power of the reflected beams is over the threshold.
-
isHit
(beam)¶ A function to see if a beam hits this optics or not.
Input parameters
beam
: A GaussianBeam object to be interacted by the optics.Returned value
The return value is a dictionary with the following keys:
isHit, position, distance, face
isHit
: This is a boolean to answer whether the beam hit the optics or not.position
: A numpy array containing the coordinate values of the intersection point between the beam and the optics. If isHit is False, this parameter does not mean anything.distance
The distance between the beam origin and the intersection point.face
: An optional string identifying which face of the optics was hit. For example,face
can be either “HR” or “AR” for a mirror.face
can also be “side”, meaning that the beam hits a side of the optics, which is not meant to be used, e.g. the side of a mirror. In this case, the beam have reached a dead end.
-
class
gtrace.optcomp.
Mirror
(HRcenter=[0.0, 0.0], normAngleHR=0.0, normVectHR=None, diameter=0.25, thickness=0.15, wedgeAngle=0.004363323129985824, inv_ROC_HR=0.00014285714285714287, inv_ROC_AR=0.0, Refl_HR=0.99, Trans_HR=0.01, Refl_AR=0.01, Trans_AR=0.99, n=1.45, name='Mirror', HRtransmissive=False, term_on_HR=False)¶ Bases:
gtrace.optcomp.Optics
Representing a partial reflective mirror.
=== Attributes ===
- HRcenter: The position of the center of the arc of the HR surface.
[(2,) float array]
- HRcenterC: The position of the center of the chord of the HR surface.
[(2,) float array]
normVectHR: Normal vector of the HR surface.
normAngleHR: Angle of the HR normal vector.
- ARcenter: The position of the center of the AR surface.
[(2,) float array]
normVectAR: Normal vector of the HR surface.
normAngleAR: Angle of the HR normal vector.
- HRtransmissive: A boolean value defaults to False. If True, this mirror
is supposed to transmit beams on the HR surface. Therefore, for the first encounter of a beam on the HR surface of this mirror will not increase the stray_order. This flag should be set to True for beam splitters and input test masses.
- term_on_HR: If this is True, a beam with stray_order <= self.term_on_HR_order will be terminated when
it hits on HR. This is to avoid the inifinite loop of non-sequencial trace by forming a cavity.
- term_on_HR_order: Integer to specify the upper limit of the stray order used to judge
whether to terminate the non sequential trace or not on HR reflection.
-
copy
()¶
-
draw
(cv, drawName=False)¶ Draw itself
-
get_side_info
()¶ Return information on the sides of the mirror. Returned value is a list of two tuples like [(center1, normVect1, length1), (center2, normVect2, length2)] Each tuple corresponds to a side. center1 is the coordinates of the center of the side line. normVect1 is the normal vector of the side line. length1 is the length of the side line.
-
hit
(beam, order=0, threshold=0.0, face=False)¶ A function to hit the optics with a beam.
This function attempts to hit the optics with the source beam,
beam
.Input parameters:
beam
: A GaussianBeam object to be interacted by the optics.order
: An integer to specify how many times the internal reflections are computed.threshold
The power threshold for internal reflection calculation. If the power of an auxiliary beam falls below this threshold, further propagation of this beam will not be performed.Return values
(isHit, beamDict, face)
isHit
This is a boolean to answer whether the beam hit the optics or not.beamDict
A dictionary containing resultant beams.face
:An optional string identifying which face of the optics was hit. For a mirror,
face
is any of “HR”, “AR” or “side”.
-
hitFromAR
(beam, order=0, threshold=0.0, verbose=False)¶ Compute the reflected and deflected beams when an input beam hit the AR surface.
The internal reflections are computed as long as the number of internal reflections are below the
order
and the power of the reflected beams is over the threshold.
-
hitFromHR
(beam, order=0, threshold=0.0, verbose=False)¶ Compute the reflected and deflected beams when an input beam hit the HR surface.
The internal reflections are computed as long as the number of internal reflections are below the
order
and the power of the reflected beams is over the threshold.
-
isHit
(beam)¶ A function to see if a beam hits this optics or not.
Input parameters
beam
: A GaussianBeam object to be interacted by the optics.Returned value
The return value is a dictionary with the following keys:
isHit, position, distance, face
isHit
: This is a boolean to answer whether the beam hit the optics or not.position
: A numpy array containing the coordinate values of the intersection point between the beam and the optics. If isHit is False, this parameter does not mean anything.distance
The distance between the beam origin and the intersection point.face
: An optional string identifying which face of the optics was hit. For example,face
can be either “HR” or “AR” for a mirror.face
can also be “side”, meaning that the beam hits a side of the optics, which is not meant to be used, e.g. the side of a mirror. In this case, the beam have reached a dead end.
-
rotate
(angle, center=False)¶ Rotate the mirror. If center is not specified, the center of rotation is HRcenter. If center is given (as a vector), the center of rotation is center. center is a position vector in the global coordinates.
-
translate
(trVect)¶
-
class
gtrace.optcomp.
Optics
¶ Bases:
traits.has_traits.HasTraits
A general optics class from which other specific optics classes are derived.
=== Attributes === name: Name of the optics. [string] center: Center position of the optics. [(2,) float array] rotationAngle: This angle defines the orientation of the optics.
-
hit
(order=0, threshold=0.0)¶ A function to hit the optics with a beam.
This function attempts to hit the optics with the source beam,
beam
.Input parameters:
beam
: A GaussianBeam object to be interacted by the optics.order
: An integer to specify how many times the internal reflections are computed.threshold
The power threshold for internal reflection calculation. If the power of an auxiliary beam falls below this threshold, further propagation of this beam will not be performed.Return values
(isHit, beamDict, face)
isHit
This is a boolean to answer whether the beam hit the optics or not.beamDict
A dictionary containing resultant beams.face
:An optional string identifying which face of the optics was hit. For a mirror,
face
is any of “HR”, “AR” or “side”.
-
isHit
()¶ A function to see if a beam hits this optics or not.
Input parameters
beam
: A GaussianBeam object to be interacted by the optics.Returned value
The return value is a dictionary with the following keys:
isHit, position, distance, face
isHit
: This is a boolean to answer whether the beam hit the optics or not.position
: A numpy array containing the coordinate values of the intersection point between the beam and the optics. If isHit is False, this parameter does not mean anything.distance
The distance between the beam origin and the intersection point.face
: An optional string identifying which face of the optics was hit. For example,face
can be either “HR” or “AR” for a mirror.face
can also be “side”, meaning that the beam hits a side of the optics, which is not meant to be used, e.g. the side of a mirror. In this case, the beam have reached a dead end.
-
Module contents¶
This package provides necessary classes and functions for tracing the propagation of Gaussian beams among mirrors and lenses.