Navigation: Scripting Reference Manual > Functions & Subroutines > VectorField

 

VectorField

 

Contact Us: fredsupport@photonengr.com

 

Description

This function computes the complex vector field and places the real and imaginary components in separate arrays.  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 = VectorField( n, nCoordSys, ana, xReals(), xImags(), yReals(), yImags(), zReals(), zImags() )

 

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.

 

xReals() As Double

After the VectorField function is called, this variable contains the real values of the X component of the polarized field and has the same dimensions as the number of pixels in x and y as defined by the T_ANALYSIS structure.

 

xImags() As Double

After the VectorField function is called, this variable contains the imaginary values of the X component of the polarized field and has the same dimensions as the number of pixels in x and y as defined by the T_ANALYSIS structure.

 

yReals() As Double

After the VectorField function is called, this variable contains the real values of the Y component of the polarized field and has the same dimensions as the number of pixels in x and y as defined by the T_ANALYSIS structure.

 

yImags() As Double

After the VectorField function is called, this variable contains the imaginary values of the Y component of the polarized field and has the same dimensions as the number of pixels in x and y as defined by the T_ANALYSIS structure.

 

zReals() As Double

After the VectorField function is called, this variable contains the real values of the Z component of the polarized field and has the same dimensions as the number of pixels in x and y as defined by the T_ANALYSIS structure.

 

zImags() As Double

After the VectorField function is called, this variable contains the imaginary values of the Z component of the polarized field and has the same dimensions as the number of pixels in x and y as defined by the T_ANALYSIS structure.

 

 

 

 

Example

The example below demonstrates how to calculate the vector field and then combine the individual field components to recover the total integrated power.

 

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

    pxArea = Sqr(tAna.AcellX^2 + tAna.AcellY^2 + tAna.AcellZ^2)*Sqr(tAna.BcellX^2 + tAna.BcellY^2 + tAna.BcellZ^2)

    Print "Pixel Area: " & Chr(9) & pxArea

 

    'calculate the field

    Dim nRays As Long

    Dim xReals() As Double, xImags() As Double, yReals() As Double, yImags() As Double, zReals() As Double, zImags() As Double

    nRays = VectorField( detSurf, -1, tAna, xReals(), xImags(), yReals(), yImags(), zReals(), zImags() )

 

    'loop over field data and compute total integrated power

    Dim pX As Double, pY As Double, pZ As Double, pTot As Double

    Dim curCol As Long, curRow As Long

    pX   = 0

    pY   = 0

    pZ   = 0

    For curCol = 0 To UBound( xReals, 1 )

        For curRow = 0 To UBound( xReals, 2 )

            pX = pX + (xReals(curCol,curRow)^2 + xImags(curCol,curRow)^2)*pxArea

            pY = pY + (yReals(curCol,curRow)^2 + yImags(curCol,curRow)^2)*pxArea

            pZ = pZ + (zReals(curCol,curRow)^2 + zImags(curCol,curRow)^2)*pxArea

        Next curRow

    Next curCol

    pTot = pX + pY + pZ

    Print ""

    Print "X Component Power: " & Chr(9) & pX

    Print "Y Component Power: " & Chr(9) & pY

    Print "Z Component Power: " & Chr(9) & pZ

    Print "Total Power: " & Chr(9) & pTot

 

End Sub

 

See Also

Analyses Commands

ScalarField

ScalarFieldToFile

ScalarFieldToFileAS

VectorFieldToFile

VectorFieldToARN

VectorFieldToFileAS

T_ANALYSIS

LoadAnalysis

 

 

 

 

 

Copyright © Photon Engineering, LLC