Navigation: Scripting Reference Manual > Functions & Subroutines > VectorFieldToFile

 

VectorFieldToFile

 

Contact Us: fredsupport@photonengr.com

 

Description

This function computes the complex vector field and writes the result to a FRED Grid Data (FGD) file.  Only coherent polarized rays are included in the calculation; unpolarized and incoherent rays are ignored.  When a coherent field calculation encounters multiple wavelengths, the calculation will proceed using only the first wavelength which satisfies the ray filter criteria.  A warning dialog will be displayed which provides the wavelength range and the value used in the calculation (to 7 significant digits).  All other wavelengths are ignored.

 

If U represents the optical field, then UU* = E (power/area).  This means that the data values in the real and imaginary arrays have units of Sqrt(power/area).

 

Depending on the number of rays traced, it may be necessary to dimension ray index and ray counter variables as data type Huge_ instead of Long.  Please see Multi-threaded Raytracing for more information.

 

Syntax

count = VectorFieldToFile( n, nCoordSys, ana, fname )

 

Parameters

count (Long or Huge_)

Returned number of rays that were included in the calculation.

 

n As Long

Node number of the surface to be used as the ray selection filter.  Only rays which exist on this surface at the time of the VectorField call will be included in the calculation.

 

nCoordSys As Long

Node number of the entity whose coordinate system the ana structure is expressed in.  If the ana structure was initialized using the LoadAnalysis command, the value of nCoordSys should be set to -1.

 

ana As T_ANALYSIS

Structure defining a sample area over which the calculation will be performed.  This variable may be initialized manually or by calling LoadAnalysis.  If LoadAnalysis is used, note that the T_ANALYSIS structure is defined in global coordinates and therefore nCoordSys = -1.

 

fname As String

File name where results of the calculation are to be written.  If a full file path is provided (ex. C:\temp\exampleOutput.fgd), the file will be written to the location specified.  If only a file name is given (ex. exampleOutput.fgd), the file will be written to the current local working directory if the directory allows write permissions.  An error will occur when attempting to create the output file if the directory specified does not have write permissions granted.  If fname string is empty, the results are displayed in a chart window.

 

Vector Field File

The header of the *.fgd output for a vector field contains the following lines:

A_AXIS_DIM = m

..

..

B_AXIS_DIM = n

..

..

BeginData

These lines indicate that m is the number of pixels in the X-direction and n is the number of pixels in the Y-direction.  After the line, BeginData, there are n rows with 6*m columns per row, with each group of 6 corresponding to the values of X(Re), X(Im), Y(Re), Y(Im), Z(Re) and Z(Im).

 

Example

The example below demonstrates how to trace rays through a system and then use LoadAnalysis in conjunction with the VectorFieldToFile command in order to save the output as an FGD file.

 

Sub Main

 

    Dim anaSurf As Long, detSurf As Long

    anaSurf = FindFullName( "Analysis Surface(s).Detector Analysis" )

    detSurf = FindFullName( "Geometry.Detector.Surface" )

 

    DeleteRays()

    TraceCreate()

 

    'retrieve analysis surface parameters and calculate pixel area

    Dim tAna As T_ANALYSIS

    Dim pxArea As Double

    LoadAnalysis anaSurf, tAna

 

    'calculate the field

    Dim fname As String, nRays As Long

    fname = "C:\temp\vectorFieldOutput.fgd"

    nRays = VectorFieldToFile( detSurf, -1, tAna, fname )

 

    'Output information

    Print nRays & " rays were included in the analysis."

    Print "File written: " & fname

 

End Sub

 

See Also

ScalarField

ScalarFieldToFile

VectorFieldToARN

ScalarFieldToFileAS

VectorField

VectorFieldToFileAS

CreateRaysFromScalarField

CreateRaysFromScalarFieldFile

CreateRaysFromVectorField

CreateRaysFromVectorFieldFile

ClipFieldInFile

Irradiance

IrradianceToFile

IrradianceToFileAS

Intensity

EnergyDensity

T_ANALYSIS

LoadAnalysis

SetAnalysisParameters

DisplayPlotFile

 

 

 

 

 

Copyright © Photon Engineering, LLC