Description This function performs an irradiance (power/area) calculation using rays which exist on a specific surface and writes the result of the calculation to a Fred Grid Data (FGD) file. The third argument of the command is a T_ANALYSIS structure, which defines a sampling grid (pixels, orientation and location) over which the irradiance is computed but does not define any ray selection filter operations. 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 = IrradianceToFile( 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 Irradiance 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.
Example The example below demonstrates how to use the IrradianceToFile command in conjunction with the LoadAnalysis command to populate the T_ANALYSIS structure. The output is directed to an FGD file.
Sub Main
'Document cleanup DeleteRays() ARNDeleteAllNodes() ClearOutputWindow()
'We are interested in calculating the irradiance for rays on this surface Dim nSurf As Long nSurf = FindFullName( "Geometry.Detector.Surface" )
'We want to use a T_ANALYSIS grid specification identical to 'one of our existing analysis surfaces. This specifies which 'analysis surface we want to copy the template from. Dim anaNode As Long anaNode = FindFullName( "Analysis Surface(s).Detector Analysis" )
'Use the analysis node as a template for our T_ANALYSIS structure 'by calling the LoadAnalysis function 'NOTE: The structure is expressed in GLOBAL COORDINATES Dim tAna As T_ANALYSIS LoadAnalysis( anaNode, tAna )
'Create and trace the active source EnableTextPrinting(False) TraceCreate() EnableTextPrinting(True)
'Compute the irradiance 'Note that the second argument specifies the coordinate system of the 'T_ANALYSIS structure. Since we used LoadAnalysis, this needs to be 'in Global Coordinates (i.e. -1) Dim fName As String Dim nRays As Long fName = "irradianceToFileOutput.fgd" EnableTextPrinting(False) nRays = IrradianceToFile( nSurf, -1, tAna, fName ) EnableTextPrinting(True)
'Output information Print nRays & " rays were included in the analysis." Print "File written: " & fName
End Sub
See Also
|