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.
This feature can be accessed by selecting Optimization > Define/Edit: Merit Function Aberrations from the menu.
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.
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
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
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
Optimize - Sensitivity Analysis
|
|||||||||||||||||||||||||||||||||||||||||||||