Description This function computes the complex scalar wave field and places the real and imaginary components in separate arrays. The scalar field function operates only on unpolarized, coherent rays and ignores polarized rays. 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 detected and the value used in the calculation (to 7 significant digits). All other wavelengths are ignored.
If the optical field is represented by U, then UU* = E (power/area). This means that the units of the reals() and imags() arrays are 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 = ScalarField ( n, nCoordSys, ana, reals(), imags() )
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 ScalarField 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.
reals() As Double After the ScalarField function is called, this variable contains the real values of the analysis result and has the same dimensions as the number of pixels in x and y as defined by the T_ANALYSIS structure.
imags() As Double After the ScalarField function is called, this variable contains the imaginary values of the analysis result and has the same dimensions as the number of pixels in x and y as defined by the T_ANALYSIS structure.
Example The following script traces a source through a system and then uses LoadAnalysis in conjunction with ScalarField to retrieve the real and imaginary components of the optical field on the detector and recover the total 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 scalar field Dim reals() As Double, imags() As Double ScalarField( detSurf, -1, tAna, reals(), imags() )
'loop over field data and compute total integrated power Dim pwr As Double pwr = 0 Dim curCol As Long, curRow As Long For curCol = 0 To UBound( reals, 1 ) For curRow = 0 To UBound( reals, 2 ) pwr = pwr + (reals(curCol,curRow)^2 + imags(curCol,curRow)^2)*pxArea Next curRow Next curCol Print "Total Power: " & Chr(9) & pwr
End Sub
See Also
|