NAME
Physics::RayTransfer - Object-oriented ray transfer analysis
SYNOPSIS
use Physics::RayTransfer;
my $sys = Physics::RayTransfer->new();
$sys->add_mirror;
$sys->add_space->parameter(sub{shift});
$sys->add_mirror(8);
my $d = [ map { $_ / 10 } (0..100) ];
my @data =
map { $_->[1]->w(1063e-7) }
$sys->evaluate_parameterized($d);
DESCRIPTION
This physics module is a helper for creating a system of ray transfer matrices (RTM) for analyzing optical systems. The most useful functionality is related to laser cavity stability analysis.
CLASSES
Physics::RayTransfer
This class provides the main simulation object, which houses the element objects and does the overall calculations.
METHODS
- new( [ %attributes ] )
-
Constructor. Can accept a hash of attributes. Those attributes also have accessor methods of the same name. They are:
- elements
-
An array reference of
Physics::RayTransfer::Element
objects, ordered left-to-right. The default is an empty array reference.
- add_element( Physics::RayTransfer::Element $object )
-
A helper method to push a manually constructed
Physics::RayTransfer::Element
onto theelements
attribute. - add_observer()
-
Shortcut method for adding a
Physics::RayTransfer::Observer
object as the next element in the system (on the right side). Returns the object added. - add_space( [ Num $length ] )
-
Shortcut method for adding a
Physics::RayTransfer::Space
object as the next element in the system (on the right side). Optionally takes a number representing the length of the object. Returns the object added. - add_mirror( [ Num $radius ] )
-
Shortcut method for adding a
Physics::RayTransfer::Mirror
object as the next element in the system (on the right side). Optionally takes a number representing the radius of curvature of the object's mirror. Returns the object added. - add_lens( [ Num $focal_length ] )
-
Shortcut method for adding a
Physics::RayTransfer::Lens
object as the next element in the system (on the right side). Optionally takes a number representing the focal length of the object's lens. Returns the object added. - evaluate()
-
Returns a
Physics::RayTransfer::Element
object which is equivalent to the system as a whole. See "EVALUATION" for more. - evaluate_parameterized( ArrayRef $vals )
-
Takes an array reference of values for the parameterization functions. Returns 2D array (i.e. a list of array references). Foreach value an array reference is returned containg that value and a
Physics::RayTransfer::Element
object which is equivalent to the system as a whole when that parameter is used for evaluation. See "EVALUATION" for more.
EVALUATION
The evaluation process is perhaps the important part of the simulation. It is at this point that the objects are converted into a series of matricies which are multiplied out to get the equivalent single matrix. This can either be done in a purely numerical way (evaluate
) or repeatedly for multiple values of some parameter (evaluate_parameterized
).
The conversion to a series of matricies depends on the layout of your system. The most basic is just a linear array of optical elements. In such a system there are no end mirror objects. The input ray is assumed to originate on the left. If a Physics::RayTranser::Observer
object (henceforth called "an observer") is placed somewhere in the system, this is then seen as the endpoint. If no observer is placed one will be assumed on the right side.
A more complicated system having a Physics::RayTransfer::Mirror
object (henceforth called "a mirror") as the last element on the right will have its ray start on the left, traverse the system, reflect off the mirror and then return back through the system. An observer will stop the light only on the return trip. If no observer has been placed, one will implicitly exist on the leftmost part of the system, meaning the light will travel from left to right and back to the starting point.
Finally if there are mirrors at both the left and right of the system, this triggers cavity mode, most useful for laser cavity simulation. In cavity mode, light both starts and stops at the observer, making a complete round trip inside the cavity (passing the observer once). If no observer is placed, the observer is implicitly positioned just before the right mirror (assumed to be the output coupler).
Physics::RayTransfer::Element
This class is the base class of all the individual elements of the system. Further it is the generic class used for when the elements are combined down to a single matrix. Most of the functionality in this class is present in the subclasses, except for some of the constructor defaults.
METHODS
- new( [ %attributes ] )
-
Constructor. Can accept a hash of attributes. Those attributes also have accessor methods of the same name. They are:
- a
- b
- c
- d
-
These are the holders for the
a
(1,1),b
(1,2),c
(2,1), andd
(2,2) matrix slots.a
andd
default to1
.b
andc
default to0
but this can be overridden by subclasses. - parameter
-
This is a coderef which maps an arbitrary input parameter to the relevant matrix element (either
b
orc
depending on element). This allows for plotting the behavior of systems in terms of arbitrary parameters in multiple elements. For example one might want to move a lens across a space of constant length10
:$sys->add_space->parameter(sub{shift}); $sys->add_lens(2); $sys->add_space->parameter(sub{10-shift}); my $d = [ map { $_ / 10 } (0..100) ]; my @data = $sys->evaluate_parameterized($d);
- get_parameterized( [ Num $val ] )
-
This method is meant to be subclassed with the specific behavior of the element in question. The default behavior is to return the object itself (the optional parameter value is ignored in this generic class). Most subclasses will return a new object, one in which the parameterization is used to construct the matrix.
- get( [ Num $val ] )
-
This is the generic dispatcher called when building the composite system. If an optional (numeric) parameter value is passed AND if the object has a parameterization, then it dispatches the object's
get_parameterized
method. If no parameterization is available the object itself is returned. - times( Physics::RayTransfer::Element $right )
-
This method performs matrix multiplication between the instance (the left matrix) and the passed in right matrix. The result is a new
Physics::RayTransfer::Element
object containing the result of the multiplication. - as_arrayref()
-
A simple diagnostic method which return an array reference of the
abcd
elements in order (note: this is in 1D[a, b, c, d]
). - stability( Num $lambda )
-
This method returns the value of
(a+d)/2
, this quantity is useful for judging the stability of a laser cavity. It takes a number representing the wavelength of the light used, this should be in the same units as any distances employed. - w( Num $lambda )
-
This method returns the (Gaussian) spot size of a beam in the cavity at the observer. This is given by
sqrt( abs(b) * $lambda / pi * sqrt( 1 / ( 1 - stability()**2 ) ) )
. It takes a number representing the wavelength of the light used, this should be in the same units as any distances employed.
SUBCLASSES
- Physics::RayTransfer::Observer
-
Represents the position at which to evaluate the output (or cavity operation). Has no additional attributes or methods.
- Physics::RayTransfer::Space
-
Represents an amount of free propagation distance. Has the additional attribute
length
. Itsget_parameterized
method creates a new object directly setting theb
attribute (length). - Physics::RayTransfer::Mirror
-
Represents a (possibly curved) mirror. Has the additional attribute
radius
. Itsget_parameterized
method returns a new object directly setting thec
attribute (c=-2/r
). - Physics::RayTransfer::Lens
-
Represents a lens. Has the additional attribute
f
, indicating focal length. Note that iff
is not set, thec
matrix element is set to0
. Itsget_parameterized
method returns a new object directly setting thec
attribute (c=-1/f
).
SEE ALSO
SOURCE REPOSITORY
http://github.com/jberger/Physics-RayTransfer
AUTHOR
Joel Berger, <joel.a.berger@gmail.com>
COPYRIGHT AND LICENSE
Copyright (C) 2012 by Joel Berger
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.