Navigation: Scripting Reference Manual > Script Examples > Examples - Diffraction Grating

 

Examples - Diffraction Grating

 

Contact Us: fredsupport@photonengr.com

 

These examples cover the basic FRED scripting commands involving diffraction gratings:

"Get" - retrieve diffraction grating attributes,

"Is" - query surface,

"Set" - set diffraction grating attributes.

 

The following structures are required for diffraction gratings:

T_HOE

 

FRED supports two types of gratings, linear gratings and Holographic Optical Elements (HOE).


 

"Get" grating data

 

The "Get" commands retrieve data from diffraction gratings. In this example, the grating information from "grating plate" is retrieved. This grating has its lines oriented at angle with respect to the local x-axis, freq lp/mm. Efficiencies for each order at each wavelength is loaded into an array. Note that the (0,0) element of the array is nothing more than a placeholder and hold no meaningful information:

 

Dim angle#, freq#
Dim effic() As Double

gid=FindName("grating plate")
GetDiffractLinear gid, angle, freq

GetDiffractEfficiencyTable gid, effic

For j=0 To GetDiffractWavelengthCount(gid)-1
 Print "Wavelength ",effic(0,j)
  For i=0 To GetDiffractOrderCount(gid)-1
   Print "efficiency=", effic(i,j)," at order ",effic(i,0)
  Next i
Next j


 

"Is" query

In searching for a specific surface type, it is common practice to loop over all entities. The IsDiffractingSurface command can be used to identify a grating. In this example, all linear gratings in the system are set to 257 lp/mm.

 

For i=0 To GetEntityCount()-1

 If IsDiffractingSurface( i ) Then

  If GetDiffractType ( i ) = "Linear" Then

   SetDiffractLinear i, 0, 257

  End If

 End If

Next i


 

"Set" grating data

As should be common practice, use "Set" commands in concert with "Get" commands to insure only the specified changes are made. This example changes the specification of Source 2 to "Position" and sets its xyz location on an HOE surface:

 

Dim HO As T_HOE

Dim pType$

Dim Hcoefs()

 

hid=FindName("Mirror HOE")

GetDiffractHOE hid, HO, pType, Hcoefs

 HO.x2=-1: HO.y2=-1: HO.z2=-10: HO.isSrc2Position=True

SetDiffractHOE hid, HO, pType, Hcoefs


 

See Also….

Advanced Raytrace

Basic Raytrace

Coatings

Curves

Elements

Entity Info

General Ray Data

Importance Sampling

Linear Transforms

Materials

Ray Buffer Handling

Ray Data Get/Set

Ray Path

Raytrace Control

Scatter

Sources

Surfaces

 

 

 

 

 

Copyright © Photon Engineering, LLC