Spatial Phase Modulation

Introduction

The phase of a ray can be modified in different ways in FRED. For phase modifications over the spatial extent of a source we can apply a phase mask via the source power apodization tab. For pure phase modifications at a surface we can consider using diffraction gratings or coatings, which lend themselves well to phase variations that can be described with some mathematical form; but not all phase variations can be neatly expressed this way.


In this example, we address how to apply an arbitrary positional phase modification to a ray as it intersects a surface. To do this we will use:

  • a (non-traceable) bicubic mesh surface to hold the XY grid of arbitrary phase values
  • a scripted coating to apply the correct phase value depending on where the ray intersected the surface.

Example


Download the example file: SpatialPhaseModulator.frd


Bicubic Mesh to Hold Positional Phase

The first component of the model to examine within the example file is a custom element geometry node on the tree that is marked as never traceable, called "Phase Map Dummy". The surface within this node is a Bicubic Mesh surface type, which allows us to store height map data as a function of X and Y.

Opening up the surface dialog for the bicubic mesh surface allows us to see that there is a grid of data already loaded into the control and the values that have been loaded in this case represent phase variations rather than height. Note that to quickly populate this grid FRED has a number of options available from the r-click context menu in the grid to read data from various files:

In this example we have already used the "Read from Image File..." option to load in the below bitmap file that represents some phase data.

To re-iterate: we do not want to raytrace this surface, it is simply being used as a convenient place to store the spatial phase information.


Scripted Coating to read Phase from the Mesh

The second component of this example is the scripted coating. Expanding the Coatings folder on the object tree will display a coating called "SLM Coating". Double click to open its dialog and we can see that this is a custom Scripted Coating type.

The idea is straightforward - whenever this coating is evaluated during the raytrace the script automatically knows the ray's intercept position on whatever surface the ray is interacting with. These are the g_x, g_y and g_z variables which are automatically at our disposal to use inside of the script. Knowing where the ray hits the surface, we take the g_x, g_y position and look up the same location on the bicubic mesh surface to evaluate the phase value at that location. After retrieving the phase value, we simply apply that as the phase coefficient of the coating and we're done.

It is this scripted coating that is applied to the "SLM Surface" to make the surface into a spatial phase modulator:


Sub EvalCoating( ByVal g_x#, ByVal g_y#, ByVal g_z#, ByVal g_cos#, ByVal g_w#, ByVal g_n0#, ByVal g_n1#, ByVal g_k0#, ByVal g_k1#, ByVal g_refl As Boolean, ByRef g_magS#, ByRef g_magP#, ByRef g_phsS#, ByRef g_phsP# )

'Reference to the geometry node with the spatial phase map
Dim phsMap As Long, phs As Double
phsMap = FindFullName( "Geometry.Phase Map Dummy.Bicubic Mesh Phase Data" )
phs = GetSampledSurfZ( phsMap, g_x, g_y )

g_magS = 1.0 'No amplitude scaling
g_phsS = phs
If g_refl Then  g_magS = sqr(1.0-g_magS^2)
g_magP = g_magS  :  g_phsP = g_phsS

End Sub

To demonstrate the behavior, run a raytrace and then go to Analyses > Coherent Scalar Wave Field. In the resulting complex field map we can see that the phase mask has been applied during the raytrace.

Note that there is no reason that this has to be a coherent raytrace, the same approach will also work for incoherent rays.

Still need help? Contact Us Contact Us