Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
""" Draw beam trace corresponding to input beam
Because the laser beam diffracts through space, we cannot
simply propagate the beam over large distances and trace it
(as opposed to rays, where we can). We must split Space()
elements into sub elements to watch the beam size expand.
We arbitrarily split Space() elements into N sub elements
before plotting.
"""
from .imagingpath import ImagingPath # Fixme: circular import fix
from .matrix import Space
N = 100
highResolution = ImagingPath()
for element in self.path.elements:
if isinstance(element, Space):
for i in range(N):
highResolution.append(Space(d=element.L / N,
n=element.frontIndex))
else:
highResolution.append(element)
beamTrace = highResolution.trace(beam)
x, y = self.rearrangeBeamTraceForPlotting(beamTrace)
lines = [Line(x, y, 'r'),
Line(x, [-v for v in y], 'r')]
return lines
Parameters
----------
upTo : float
The length of the propagation (default=Inf)
Returns
-------
transferMatrix : object of class Matrix
the corresponding matrix to the propagation
"""
if self.L <= upTo:
return self
else:
return Space(upTo, self.n, self.apertureDiameter) * DielectricInterface(1.0, self.n, self.R1,
self.apertureDiameter)
simply propagate the beam over large distances and trace it
(as opposed to rays, where we can). We must split Space()
elements into sub elements to watch the beam size expand.
We arbitrarily split Space() elements into N sub elements
before plotting.
"""
from .imagingpath import ImagingPath # Fixme: circular import fix
from .matrix import Space
N = 100
highResolution = ImagingPath()
for element in self.path.elements:
if isinstance(element, Space):
for i in range(N):
highResolution.append(Space(d=element.L / N,
n=element.frontIndex))
else:
highResolution.append(element)
beamTrace = highResolution.trace(beam)
x, y = self.rearrangeBeamTraceForPlotting(beamTrace)
lines = [Line(x, y, 'r'),
Line(x, [-v for v in y], 'r')]
return lines
f=-1.000
See Also
--------
raytracing.Matrix.forwardConjugate
Notes
-----
M2 = M1*Space(distance)
M2.isImaging == True
"""
if self.A == 0:
return (float("+inf"), None)
distance = -self.B / self.A
conjugateMatrix = self * Space(d=distance)
return (distance, conjugateMatrix)
--------
raytracing.Matrix.backwardConjugate
Notes
-----
M2 = Space(distance)*M1
M2.isImaging == True
"""
if self.D == 0:
distance = float("+inf")
conjugateMatrix = None # Unable to compute with inf
else:
distance = -self.B / self.D
conjugateMatrix = Space(d=distance) * self
return (distance, conjugateMatrix)
""" Draw beam trace corresponding to input beam
Because the laser beam diffracts through space, we cannot
simply propagate the beam over large distances and trace it
(as opposed to rays, where we can). We must split Space()
elements into sub elements to watch the beam size expand.
We arbitrarily split Space() elements into N sub elements
before plotting.
"""
from .imagingpath import ImagingPath # Fixme: circular import fix
from .matrix import Space
N = 100
highResolution = ImagingPath()
for element in self.path.elements:
if isinstance(element, Space):
for i in range(N):
highResolution.append(Space(d=element.L / N,
n=element.frontIndex))
else:
highResolution.append(element)
beamTrace = highResolution.trace(beam)
x, y = self.rearrangeBeamTraceForPlotting(beamTrace)
lines = [Line(x, y, 'r'),
Line(x, [-v for v in y], 'r')]
return lines
Parameters
----------
upTo : float
The length of the propagation (default=Inf)
Returns
-------
transferMatrix : object of class Matrix
the corresponding matrix to the propagation
"""
if self.L <= upTo:
return self
else:
return Space(upTo, self.n, self.apertureDiameter) * DielectricInterface(1.0, self.n, float("+inf"),
self.apertureDiameter)
simply propagate the beam over large distances and trace it
(as opposed to rays, where we can). We must split Space()
elements into sub elements to watch the beam size expand.
We arbitrarily split Space() elements into N sub elements
before plotting.
"""
from .imagingpath import ImagingPath # Fixme: circular import fix
from .matrix import Space
N = 100
highResolution = ImagingPath()
for element in self.path.elements:
if isinstance(element, Space):
for i in range(N):
highResolution.append(Space(d=element.L / N,
n=element.frontIndex))
else:
highResolution.append(element)
beamTrace = highResolution.trace(beam)
x, y = self.rearrangeBeamTraceForPlotting(beamTrace)
lines = [Line(x, y, 'r'),
Line(x, [-v for v in y], 'r')]
return lines
def __init__(self, d, n=1, diameter=float('+Inf'), label=''):
super(Space, self).__init__(A=1,
B=float(d),
C=0,
D=1,
physicalLength=d,
frontVertex=None,
backVertex=None,
frontIndex=n,
backIndex=n,
apertureDiameter=diameter,
label=label)