These examples cover the basic FRED scripting commands involving ray paths: "RayPathMode" - user defined mode settings, "Path" - general path information, "PathEvent" - specific event information, "PathEventIs" - query specific events Copying Raypaths to User-defined Paths
No structures are required for Ray Path commands.
A ray path is defined as a unique sequence of surface intersections. In FRED, the user is able to construct specific paths of interest prior to raytracing or determine paths resulting from a non-sequential raytrace. Ray path construction is facilitated by the "User-defined Ray Paths" dialog found on the Raytrace dropdown menu. In this dialog, the user creates and names a sequential list of surface intersections to be followed by each ray. If any ray fails to follow the designated path, that ray terminates at the last allowed intersection. In addition, FRED automatically recognizes and defines what is termed the DefaultSequential ray path (the "primary" or "imaging" path) whenever a CodeV, Zemax or OSLO lens is imported. Sequential paths offer the advantages of 1) ignoring all but the path of interest, and 2) decreasing raytrace time.
Determination of ray paths is an important aspect of stray light applications. In FRED, the determination of ray paths is accomplished by means of an "Advanced Raytrace". To activate this feature, select "Determine raypaths" in the "Advanced Raytrace" dialog box or set the "Determine ray paths" flag rayPaths in T_ADVANCEDRAYTRACE. Note that these ray paths are identified not by a name but by an zero-indexed integer value.
"RayPathMode" information Since there are two types of raytrace paths in FRED, the user must be able to determine/set the operational mode. Use the SetUserDefinedRayPathMode command to place FRED in the desired mode.
SetUserDefinedRayPathMode True 'set FRED to the ray path construction mode
Use IsUserDefinedRayPathMode to query FRED as to its current mode. In this example, if FRED is in the path construction mode then set the mode to path determination, otherwise do nothing.
If IsUserDefinedRayPathMode() Then SetUserDefinedRayPathMode False End If
"Path" information The basic attributes of ray paths can be accessed using the "Path" commands. Commands such as PathPower and PathRayCount logically apply to the path determination mode only. This example finds the number of paths whose power exceeds a threshold value of 1e-4:
thresh=1e-4 pcount=0 For i=0 To PathCount()-1 If PathPower(i)>thresh Then pcount=pcount+1 End If Next i Print "There are " & pcount " paths with power greater than " & thresh
Other commands such as PathName, PathDescription, & PathFind logically apply only to paths the user has constructed (user defined paths):
pid=PathFind("ghost path between S4 and S6") desc = PathDescription ( pid ) Print desc
Both path modes respond to the commands PathCount and PathDelete. In this example, FRED deletes all the determined paths whose power is less than 1e-5:
thresh=1e-5
while, in this example, FRED deletes the constructed path named "Trace Path 6":
pid=PathFind("Trace Path 6")
Note that paths from the determined path list which are copied to the user-defined path list are named "Trace Path #" where # is the path number.
"PathEvent" information The "PathEvent" commands allow the user to examine specific path-related information. In this example, FRED is asked to print the ordered list of node intersections associated with path identifier 6. This list only provides node numbers. It does not provide any specifics concerning the intersection:
For i=0 To PathEventCount ( 6 )-1 The PathEvent command returns all event information for a specified path. With this command, the user can find out whether an intersection is transmission/reflection/absorption, whether it is specular or scatter, the ancestary, etc. In the example below, PathEvent is used to interrogate path 6:
Dim id&, typ&, order&
To add a new user-defined path and load it with events, use PathAdd and PathAddEvent.
pathid=PathAdd("mypath","a new user path") sid1=FindName("Lens surface") sid2=FindName("Mirror 1")
"PathEventIs" queries The individual events can be queried using the "PathEventIs" commands. There is an "Is" command corresponding to each entry in the PathEvent command. For example, FRED is asked to count the number of Transmit events in path 6:
transcount=0 Copying Raypaths Raypaths exist in two forms; "Determined raypaths" & User-defined raypaths. "Determined raypaths" are obtained during an Advanced Raytrace and are deleted when the next raytrace is executed. User-defined raypaths are saved in your FRED document and can be edited/added/deleted. The command SetUserDefinedRayPathMode is used in scripting to switch between the raypath modes. This example copies raypaths determined from an Advanced Raytrace to User-defined raypaths.
For i=0 To PathCount()-1
pathnam="path " & i
See Also….
|