Version 1.17.35
Updates
POL_PLANEparameter to define the polarization coordinate system can now be set.- Transformation of the electric field vector after diffraction was not correct in certain cases, it has been fixed.
- When launching COPHASAL from the terminal, the working directory is now set to the terminal’s working directory, unless changed by the user.
Function for Coordinate Transformations
The function repos_matrix() has been introduced to help with coordinate transformations between surfaces. It returns two matrices: the first one is the global position vector of the surface, and the second one is the rotation matrix that transforms vectors from the global coordinate system to the local coordinate system of the surface.
local pos, rot = repos_matrix("S 3") -- pos and mat are Matrix objects
-- pos is a 3D vector representing the global position of surface S 3
-- rot is a 3x3 matrix that transforms vectors from global to local coordinates of surface S 3
User Targeted Ray Tracing
Now you can trace rays from a selected field point to a target location on a surface, or a pupil plane. This is done using the trace_ray() function. Here are some examples.
-- Trace to a point on a surface
local res = trace_ray({f = 2, w = 1, z = 1}, {1.2, 2.5}, "S 3")
-- Trace to a normalized point on the pupil plane
res = trace_ray({f = 2, w = 1, z = 1}, {0.5, -0.5}, true) -- true for ENP, false for XP
--[[
res is a table. Currently it contains the following fields:
res = {
success = <true/false>,
[error] = <error message if success is false>,
}
--]]
This is a single ray tracing function. Appropriate for sparsly probing the pupil. Unlike user rays which can be defined apriori and are traced together in a multi-threaded manner. The ray remains valid until the system is changed. An empty ray identification table by default refers to the last traced ray.
Transverse Ray Aberrations Curves
I have a script that uses the trace_ray() function to generate transverse ray aberration curves. It will be released in a future version. Here is a sample plot of the transverse ray aberrations for the Double Gauss lens at the paraxial focus.
CPH> runfile"dbgauss"
CPH> pim_reaction(true)
THI S 12 : Variable deleted!
CPH> ra = runfile"Ray_Abr"
CPH> ra.tra({f=1})

Transverse ray aberration curves for the Double Gauss lens at the paraxial image point.
Although the acript Ray_Abr.lua is not yet released, if you need this functionality sooner, please contact us. Also under development is a script to orchestrate Monte Carlo simulations for tolerance analysis.