Navigation: Scripting Reference Manual > FREDTools Script Library

 

FREDTools Script Library

 

Contact Us: fredsupport@photonengr.com

 

 

 

Description


The FREDTools Script Library is a collection of functional scripts which can aid users in accomplishing tasks that are not currently available in the GUI environment. Among the subroutines and functions, the user will find a routine to accumulate flux on an arbitrary surface during a raytrace, a method of decreasing raytrace time for large raysets, an encircled energy calculation for use in the script language, a routine to identify which paths involve intersections with a given object, a Fresnel lens surface generator, source spectral data parsers, and birefringent material data and General Sampled Coating data readers for text files. Note that these routines can be used individually or as a collection in the context of a FRED library object.  Please note that as of v9.70+, FRED no longer has the capability to compile scripts or text into *.frl files.

 

 

Navigation


All subroutines and functions are included with the FRED installation and are located in a script file named FREDTools.frs in the <install directory>\Samples\Scripts\Geometry\ directory. To create a FREDTools library, the following steps should be taken:

 

1.Check the script file's syntax by navigating to Menu > Script > Check Syntax.

2.Dimension an Object which will be the handle to the FRED library.

3.Use the CreateLib function to create and return the FRED library object.

 

An example of these steps is provided below using the script file FREDTools.frs and the subroutine SurfAccum:

 

Dim mylib As Object
Set mylib = CreateLib ("C:\Documents and Settings\My Documents\FRED files\FREDTools.frs")
...
mylib.SurfAccum 20, 62, True

 

 

The FREDTools Subroutines and Functions


The following Subroutines and Functions are currently included in FREDTools:

 


SurfAccum

 

SurfAccum surfid, anode, drawray

surfid (Long) - node number of target surface on which rays are to be accumulated
anode (Long) - node of existing Analysis Surface; Ray Specification must be "ALL Rays"
drawray (Boolean) - True to see rays drawn. False to suppress drawing of rays (faster).
 

This subroutine steps source rays one intersection at a time. At each intersection, rays are polled as to what surface they are on. If rays are on target surface, they are stored in a temporary buffer. After completion, rays in the temporary buffer are loaded into the main buffer for analysis with existing Analysis Surface at anode. All other rays are lost. Important: DO NOT use with totally absorbing surfaces. Enclose system in sphere to prevent over counting.


Largetraceirrad

 

largetraceirrad snode, anode, numloop, fname

snode (Long) - node of target surface
anode (Long) - node of analysis surface
numloop (Long) - number of times to loop
fname (String) - file name string

 

This subroutine traces sources multiple times and accumulates irradiance on given target surface. It also writes data to a plot file for viewing with the User-defined 3D Chart View. All rays are deleted upon completion.


Encircledenergypcnt

 

pcnt = encircledenergypcnt (sid, aid, rdist)

sid (Long) - node number of the surface where the rays reside
aid (Long) - node of the Analysis Surface used
rdist (Double) - radius of the circle

return value pcnt (Double) - percentage energy inside circle of specified radius

 

This function calculates the percent power inside a specified radius rdist on surface node sid with Analysis Surface node aid. The pixel center must be inside the radius to be counted.


Encircledenergylist

 

encircledenergylist (sid, aid)

sid (Long) - node number of the surface where the rays reside
aid (Long) - node of the Analysis Surface used
 

This subroutine prints the percent power inside concentric circles for rays on surface node sid with Analysis Surface node aid. Circles radii are at integer pixel distances.


Fpath

 

fpath sid, pc

sid (Long) - node number of surface to look for in paths
pc (Long) - number of intersections with node sid

 

After an Advanced Raytrace with path info saved, this macro finds all paths that contain an intersection with a specified node.


Sagresnel

 

sagfresnel radius, depth, numZones

radius (Double) - surface radius
depth (Double) - depth of step between zone
numZones (Long) - number of zones

 

Creates a Fresnel lens from a spherical surface by dividing it into zones of a specified depth.


Readgeneralcoating

 

readgeneralcoating fname, cname

fname - file name to read data from (no extension; assumes *.csv)

cname - name of coating

 

Reads data from a file to create a General Sampled Coating. First row contains angles. Remaining rows are (wavelength, Rp, Rs, Tp, Ts, Rp, Rs, Tp, Ts, Rp, Rs, Tp, Ts.......)


Readwavelengthdata 

 

readwavelengthdata fname, sid

fname - file name to read data from (no extension; assumes *.csv)

sid - node number of source

 

Reads spectral data from a file and assigns spectra to the specified source. Data is two columns (wavelength, weight).


Readbirefringentmaterialdata

 

readbirefringentmaterialdata fname, matname

fname - file name to read data from (no extension; assumes *.txt)

matname - name of new birefringent material

 

Reads birefringent material data from a file and and created a new material. Data is five columns (wavelength, Nord, Next, Gord, Gext).


Readdirapoddata 

 

readdirapoddata fname

fname - file name to read data from (no extension; assumes *.txt)

 

Reads Sampled (spherical angles) data from a file. Data is two or more columns (see Help Sampled Spherical Angles).


Readthinfilmdata

 

readthinfilmdata fname, cname, hmat, lmat, smat, suborder

fname - file name to read data from (no extension; assumes *.txt)

cname - name given to new coating

hmat - String name of high index material

lmat - String name of low index material

smat - String name of mid index materal

suborder - Boolean indicating whether substrate is first or last

 

Reads thin film coating data from a file. Data is two space or tab delimited columns.


 

NOTE: Since these routines are provided with no guarantee implied or otherwise, they should be utilized only after the user independently verifies functionality.

 

 

Related Topics


Scripting with Libraries

FRED Tools Script Library

 

 

 

 

 

Copyright © Photon Engineering, LLC