Navigation: Optimize Commands > Define/Edit > Merit Function Aberrations

 

Merit Function Aberrations

 

Contact Us: fredsupport@photonengr.com

 

 

 

Description


Aberrations are the individual components from which the merit function is constructed.  Each aberration defines the quantity to be evaluated (ex. spot size, total power), a weighting factor determining the aberration's relative contribution to the overall merit function and the desired target value to be achieved.  All active aberrations are summed into the merit function in the following way:

 

MF = S wi(Ai-Ti)2

 

In the equation above, wi is the weighting factor for the i'th aberration, Ai is the computed quantity for the i'th aberration and Ti is the target value for the i'th aberration.  The purpose of the merit function is to provide a numerical evaluation of whether or not the current variable values have improved the configuration (lowered the merit function value) or made it worse (raised the merit function value).

 

Intrinsic Aberrations

Although the optimization engine computes each aberration definition's contribution to the merit function in the manner described above, the user may wish to know the values of each individual Ai term.  When reporting information the output window during optimization, values reported as "Intrinsic Aberrations" refer to the Ai values in the above construction of the merit function.  Values reported as "Aberrations" correspond to the wi(Ai-Ti)2 terms in the merit function construction above.

 

 

Navigation


This feature can be accessed by selecting Optimization > Define/Edit: Merit Function Aberrations from the menu.

 

 

Controls


Control

Inputs / Description

Defaults

Aberration Spreadsheet

Index column

Zero based index reference for each aberration definition.

0

Active

The aberration is active when toggled.

Checked

Description

Text description of the aberration.

 

Aberration Definition

Indicates the quantity being evaluated or designates a user-defined script which will define a custom metric.  The following aberration types are available:

User scripted aberration

Encircled spot radius

Total maximized power on the surface

In the formulation of the merit function given above in the Description section, maximizing the power on an analysis surface takes the following form; Ai = 1/Pi, where Pi is incoherent ray power of all rays passing the ray selection filter of the designated analysis surface.  If, for example, the source has power of 2, then the maximum Ai would be 0.5.  The target value for the merit function aberration would then be set as Ti = 0.5.

Total minimized power on the surface

The formulation of the aberration is Ai = Pi, where Pi is incoherent ray power of all rays passing the ray selection filter of the designated analysis surface.

RMS spot size (radius, x or y, flux weighted)

Encircled spot size (x or y)

Calculated by finding the extents of the ray intercepts in the X and Y directions and using the maximum value of the two.  If the maximum ray intercept lies outside the bounds of the analysis surface, then the merit function value is limited by the extents of the analysis surface.  If the analysis surface is sized to accommodate the maximum extents of the ray intercepts, then the merit function value reflects the ray extents.

Centroid spot position (x or y, flux weighted)

Encircled direction spread (total, x or y, flux weighted, direction cosine space)

RMS direction spread (total, x or y, flux weighted, direction cosine space)

Centroid direction (x or y, flux weighted, direction cosine space)

Irradiance P-V

Irradiance variance

Illuminance P-V

Illuminance variance

RMS color spread (total, x or y)

Calculates the x,y chromaticity coordinates for each pixel in the analysis grid. Given the variance of x and y chromaticity coordinates in the color image data grid, x_var and y_var, the following RMS color spread values are computed:

"total" = sqrt( x_var + y_var )

"x" = sqrt( x_var )

"y" = sqrt( y_var )

Encircled color spread (total, x or y)

Calculates the x,y chromaticity coordinates for each pixel in the analysis grid.  Given the range of x and y chromaticity coordinates in the color image data grid, x_span and y_span, the following encircled color spread values are computed:

"total" = largest value of either x_span or y_span

"x" = x_span

"y" = y_span

Centroid color (x or y)

Calculates the x,y chromaticity coordinates for each pixel in the analysis grid.  The flux-weighted average x chromaticity or y chromaticity value in the data grid is returned as the aberration value.

Intensity P-V

Intensity variance

 

Analysis surface to evaluate

Specifies the analysis surface used to calculate the aberration value.  The ray selection criteria defined on the designated analysis surface are included in the evaluation of the aberration value.

 

Certain aberration types require the use of an Analysis Surface or a Directional Analysis Entity (ex. Irradiance p-v can only be computed with an Analysis Surface).  The message, "The aberration type is not compatible with the analysis surface type", will be presented to the user in the event that the selected analysis entity cannot be used with the designated aberration definition.  The user will need to chose either an Analysis Surface or DAE for that aberration definition as appropriate.

 

NOTE: Detector Entities cannot be selected as the designated Analysis Surface for optimization.

 

Weight

Sets the relative contribution of the aberration value to the overall merit function value.

1

Target

Sets the desired target value which should be achieved by the aberration at the end of optimization.

0

Merit Function Error Handling During Optimization

Option 1: Immediately Halt

If the merit function cannot be evaluated, the optimization is halted.

 

Option2: Continue and apply penalty

If the merit function cannot be evaluated, a penalty value of 1020 is applied in order to drive the variable values back into a better behaved regime.

Immediately Halt

Allow Detector Entities to Generate ARNs

When checked, active detector entities will be allowed to generate ARN during optimization according to the settings of the individual detector entities.  When unchecked, ARN generation by detector entities during optimization is suppressed.

Unchecked

 

 

Application Notes


User Scripted Aberrations

The user scripted aberration allows custom calculations to be incorporated into the merit function.  To invoke the user scripted aberration, first set the Aberration Definition to user scripted aberration and then right mouse click on that same cell and select "Edit User-defined script aberration" from the list menu.

 

The user scripted aberration dialog contains a default header and example script (total power).  Three variables are pre-defined in the script aberration subroutine (EvalMzrAber):

g_ana: A Long containing the node number of the analysis surface used to calculate the aberration value.  Passed into the subroutine.

g_aber: A Double containing the calculated aberration value.  Passed out of the subroutine.

g_success: A Boolean indicating whether the aberration evaluation succeeded or failed.  Passed out of the subroutine.

 

Example: Uniformity Method 1

The following script uses the IrradianceToARN and ARNCompute2DCellStatistics commands to define the uniformity aberration quantity as g_aber = (Standard Deviation)/(Maximum Irradiance).

 

'----------------------------------------------------------------

'   Function:  Computes an optimization aberration value.

'Input  vars:  g_ana = the specified analysis surface.

'Output vars:  g_aber = the computed aberration value.

'              g_success = return code. True=success, False=fail.

'----------------------------------------------------------------

'Example: Uniformity Method 1

Sub EvalMzrAber( ByVal g_ana&, ByRef g_aber#, ByRef g_success As Boolean )

 

Dim arnStats As T_ARN_2D_CELL_STATS

Dim arnNode As Long, cnt As Long, ii As Long, jj As Long

Dim delSuccess As Boolean

 

'initialize the g_aber variable

g_aber = 0.0

 

'calculate the irradiance and its statistics

cnt = IrradianceToARN( g_ana, "ARN", arnNode )

ARNCompute2DCellStatistics arnNode, arnStats

stdDev = Sqr( arnStats.AvgSqCellVal - arnStats.AvgCellVal^2 )

 

'memory management

delSuccess = ARNDelete( arnNode )

 

'set the aberration value

g_aber = stdDev/arnStats.MaxCellVal

 

g_success = g_aber > 0.0

 

End Sub

 

Example: Uniformity Method 2

The following script uses the IrradianceToARN command to place the cell data into a 2D array, normalizes each value in the array by the maximum cell value computed using ARNCompute2DCellStatistics, and then accumulates the difference (1 - cell value) for each cell in the array as the aberration value g_aber.

 

'----------------------------------------------------------------

'   Function:  Computes an optimization aberration value.

'Input  vars:  g_ana = the specified analysis surface.

'Output vars:  g_aber = the computed aberration value.

'              g_success = return code. True=success, False=fail.

'----------------------------------------------------------------

'Example: Uniformity Method 2

Sub EvalMzrAber( ByVal g_ana&, ByRef g_aber#, ByRef g_success As Boolean )

 

Dim arnStats As T_ARN_2D_CELL_STATS

Dim arnNode As Long, cnt As Long, ii As Long, jj As Long

Dim data() As Double

Dim delSuccess As Boolean

 

'calculate the irradiance and its statistics

cnt = IrradianceToARN( g_ana, "ARN", arnNode )

ARNCompute2DCellStatistics arnNode, arnStats

 

'loop over the data, normalize each cell and accumulate the difference

'from unity across the grid

ARNGetDataAsDoubleArray arnNode, data()

g_aber = 0.0

For ii = 0 To UBound( data, 1 )

          For jj = 0 To UBound( data, 2 )

                    data( ii, jj ) = data( ii, jj )/arnStats.MaxCellVal

                    g_aber = g_aber + (1 - data( ii, jj ))

          Next jj

Next ii

'memory management

delSuccess = ARNDelete( arnNode )

 

g_success = g_aber > 0.0

 

End Sub

 

Example: Surface Power Method 1

The following script uses the GetSurfIncidentPower command to calculate the incoherent power incident on the surface of interest.  Using the Target parameter in the merit function aberration dialog will drive the calculated surface power to a specific value.  This method of calculating the surface power will not be valid for a coherent calculation (see Method 2 below) as there is no accounting for the phase between rays.

 

'----------------------------------------------------------------

'   Function:  Computes an optimization aberration value.

'Input  vars:  g_ana = the specified analysis surface.

'Output vars:  g_aber = the computed aberration value.

'              g_success = return code. True=success, False=fail.

'----------------------------------------------------------------

'Target Power - Method 1

Sub EvalMzrAber( ByVal g_ana&, ByRef g_aber#, ByRef g_success As Boolean )

 

Dim isrf As Long

Dim totPower As Double

 

'initialize the aberration value

g_aber = -1

 

'retrieve the power on the entire surface.

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

totPower = GetSurfIncidentPower( isrf )

g_aber = totPower

g_success = g_aber >= 0.0

 

End Sub

 

Example: Surface Power Method 2

The following script uses an Analysis Results Node to compute the total power contained within the region of the specified analysis surface.  This script is appropriate for calculating the coherent power, since the irradiance calculation accounts for the phases of the rays.

 

'----------------------------------------------------------------

'   Function:  Computes an optimization aberration value.

'Input  vars:  g_ana = the specified analysis surface.

'Output vars:  g_aber = the computed aberration value.

'              g_success = return code. True=success, False=fail.

'----------------------------------------------------------------

'Example: Target Power - Method 2

Sub EvalMzrAber( ByVal g_ana&, ByRef g_aber#, ByRef g_success As Boolean )

 

Dim cnt As Long, arnNode As Long

Dim totPower As Double

Dim success As Boolean

 

'initialize the aberration value

g_aber = -1

 

'calculate the irradiance and then compute its total power

cnt = IrradianceToARN( g_ana, "IrradARN", arnNode )

totPower = ARNComputeTotalPower( arnNode )

 

'memory management

success = ARNDelete( arnNode )

 

'calculate the aberration value

g_aber = totPower

 

g_success = g_aber >= 0.0

 

End Sub

 

Example: Collimating Rays

The following example shows how to use a user-scripted merit function aberration type to achieve flux-weighted collimation of a ray bundle. Typically the encircled direction spread or RMS direction spread aberration types would be used to achieve collimation but this example serves to demonstrate the approach to calculating such a quantity.  The aberration value is computed in two loops over the rayset, one to determine the average direction for rays on the surface of interest, and a second to determine the sum of all ray deviations from the average.

 

'----------------------------------------------------------------

'   Function:  Computes an optimization aberration value.

'Input  vars:  g_ana = the specified analysis surface.

'Output vars:  g_aber = the computed aberration value.

'              g_success = return code. True=success, False=fail.

'----------------------------------------------------------------

'Example: Flux Weighted Collimation

Sub EvalMzrAber( ByVal g_ana&, ByRef g_aber#, ByRef g_success As Boolean )

 

Dim ray As T_RAY

Dim ir As Long, isrf As Long

Dim a As Double, b As Double, c As Double, atot As Double, btot As Double, ctot As Double, dp As Double

Dim success As Boolean

 

g_aber = 0.0

isrf = FindFullName("Geometry.Collimating Lens.Surface 2")

If isrf >= 0 Then

 

          'find the average direction vector for rays on the surface

          success = GetFirstRay( ir, ray )

          While success

                    If ray.entity = isrf Then

                              a = ray.a : b = ray.b : c = ray.c

                              TransformDirection -1, isrf, a, b, c

                              atot = atot+a : btot = btot+b : ctot = ctot+c

                    End If

                    success = GetNextRay( ir, ray )

          Wend

          'normalize the length of the average direction vector

          SetLength3D atot, btot, ctot, 1

 

          'sum of the rayFlux*Angle, where Angle is given by the dot product of the ray's direction vector and the average

          success = GetFirstRay( ir, ray )

          While success

                    If ray.entity = isrf Then

                              a = ray.a : b = ray.b : c = ray.c

                              TransformDirection -1, isrf, a, b, c

                              dp = DotProd3D( a, b, c, atot, btot, ctot )

                              g_aber = g_aber + Asin( Sqr( 1 - dp^2 ))

                    End If

                    success = GetNextRay( ir, ray )

          Wend

End If

g_success = g_aber > 0.0

 

End Sub

 

Example: Beam Width using Second Moment calculation

The following example shows how to determine a metric for beam width (or flux weighted spot size) by using a Second Moment calculation of the Irradiance around the centroid. The aberration value is computed in two loops over the Irradiance, one to determine the beam width in the X-direction and a second to repeat the calculation in the Y-direction before returning a value which is the average of the two directions.

 

Sub EvalMzrAber( ByVal g_ana&, ByRef g_aber#, ByRef g_success As Boolean )

g_aber = 0.0

 

Dim aSigma As Double, bSigma As Double, xWidth As Double, yWidth As Double, arnNode As Long, ana As Long

 

            'This function calculates the second moment of the distribution.  The TEM00 beam radius

    'is given by 2*Sqrt( aSigma ), where aSigma is the second moment variance in the X axis.

 

          ana = g_ana

 

    'Initialize values

    aSigma = 0 : bSigma = 0

 

    IrradianceToARN(ana, "Irradiance", arnNode)

 

    'Get irradiance data

    Dim irrad() As Double, arnStats As T_ARN_2D_CELL_STATS, ptot As Double

    ARNGetDataAsDoubleArray arnNode, irrad()

    ARNCompute2DCellStatistics arnNode, arnStats

    ptot = ARNComputeTotalPower( arnNode )

 

    'Calculate pixel sizes in the A and B directions

    Dim aPitch As Double, bPitch As Double

    ARNGet2DPixelSize( arnNode, aPitch, bPitch )

 

    'Where is the maximum of the distribution?

    Dim aCenPix As Long, bCenPix As Long

    Dim aCen As Double, bCen As Double, bIsOut As Boolean

    aCen = arnStats.ACentroid_Parametric

    bCen = arnStats.BCentroid_Parametric

    ARNGetCellIndicesClosestToLocation2D( arnNode, aCen, bCen, aCenPix, bCenPix, bIsOut )

 

          'Calculate the second moment in the X direction

    Dim xPos As Double

    Dim ii As Long, jj As Long

    For ii = 0 To UBound( irrad(), 1 )

        For jj = 0 To UBound( irrad(), 2 )

            xPos    = ARNGetAAxisValueAt( arnNode, ii )

            aSigma += irrad(ii, jj) * (aPitch * bPitch) * (xPos - aCen) ^ 2

        Next

    Next

    aSigma = aSigma / ptot

          xWidth = 2* Sqr(aSigma)

 

    'Calculate the second moment in the Y direction

    Dim yPos As Double

    For ii = 0 To UBound( irrad(), 1 )

        For jj = 0 To UBound( irrad(), 2 )

            yPos    = ARNGetBAxisValueAt( arnNode, jj )

                              bSigma += irrad(ii, jj) * (aPitch * bPitch) * (yPos - bCen) ^ 2

        Next

    Next

    bSigma = bSigma / ptot

    yWidth = 2* Sqr(bSigma)

 

    g_aber = (xWidth + yWidth) / 2

    g_success = g_aber > 0.0

End Sub

 

 

Related Topics


Optimization Overview

Optimize - Variables

Optimize - Method

Optimize - Output Results

Optimize - Sensitivity Analysis

 

 

 

 

 

Copyright © Photon Engineering, LLC