Calculating E-field components in script
Introduction
This knowledge base article demonstrates a script utility which calculates the Re{} and Im{} components of the E field along the s, p, x and y directions for each ray in the ray buffer. In the GUI this information is printed to the output window using the Ray Report Detail feature (Menu > Tools > Reports > Ray Detail (for one ray)), but there is no direct access to this information from the scripting language.
Explanation
After polarized rays have been traced through the system, each ray’s detailed report can be queried on a ray-by-ray basis using the Ray Detail feature. Output for this detailed report is shown blow (coherent ray information excluded). The intent of the script utility is to re-calculate the Ex(real), Ex(imag), Ey(real) and Ey(imag) quantities below using the polarization information available from the scripting language.
Running the script after a raytrace will list the field components for each direction on a ray by ray basis as shown below.
Script Implementation
In FRED, a polarized field is defined by:
where d is the ray’s direction, s is perpendicular to p, and d = s x p. The quantities ap, as, and ad are the complex amplitudes along the s, p and d directions ( i.e. as = Re{as} + iIm{as} ). The scripting language provides direct access to the s components and the real and imaginary values of the field amplitudes in s and p through the use of the T_POLARIZE2 data structure. The T_RAY structure provides the remaining information required to calculate the field components along x and y as follows:
1. Compute px, py and pz from the ray’s direction vector and sx, sy, sz:
2. Compute the ray’s phase:
3. Compute the magnitudes of the s and p amplitudes:
4. Compute the relative phases of the s and p amplitudes:
5. Compute the Re{} and Im{} components of E in the s and p directions:
6. Compute the Re{} and Im{} components of E in the x and y directions:
Downloads
Script: calcRayFieldComponents.frs
FRED File: calculateExEy.frd