Navigation: Scripting Reference Manual > Functions & Subroutines > MPCSetRaySumMode

 

MPCSetRaySumMode

 

Contact Us: fredsupport@photonengr.com

 

Description

This subroutine sets the state of the MPC Coherent Ray Summation mode as well as the state of the Single precision mode flag.

 

Syntax

MPCSetRaySumMode( isActive, isSingle )

 

 

Parameters

isActive As Boolean

If True, then MPC coherent ray summation mode is made active.  If False, then the MPC coherent ray summation mode is not active and coherent field summation calculations will be performed on the CPU.

 

isSingle As Boolean

When isActive = True, the isSingle argument indicates whether single precision mode will be used (True for single precision, False for double precision).  When isActive = False, the isSingle argument has no effect.

 

Example

The following example performs irradiance calculations using the CPU and GPU (in single precision mode), differences the two results and then displays the residual.

 

Sub Main

          

    'Document cleanup

    EnableTextPrinting(True)

    DeleteRays()

    ARNDeleteAllNodes()

    ClearOutputWindow()

 

    'Source and analysis surface used

    Dim src As Long, ana As Long

    src = FindFullName( "Optical Sources.Laser Diode Beam (coherent) 1" )

    ana = FindFullName( "Analysis Surface(s).Source Analysis Small" )

 

    'Turn off GPU field summation, perform raytrace and analysis

    Dim cpuARN As Long

    Print "CPU Start: " & Time()

    MPCSetRaySumMode( False, False )

    EnableTextPrinting(False)

    DeleteRays()

    CreateSource( src )

    TraceExisting()

    IrradianceToARN( ana, "CPU Irradiance", cpuARN )

    EnableTextPrinting(True)

    Print "CPU End: " & Time()

 

    'Turn on GPU field summation, repeat raytrace and analysis

    Dim gpuARN As Long, wantSingle As Boolean

    wantSingle = False 'True for single precision mode

    Print "GPU Single?: " & wantSingle

    Print "GPU Start: " & Time()

    MPCSetRaySumMode( True, wantSingle )

    EnableTextPrinting(False)

    DeleteRays()

    CreateSource( src )

    TraceExisting()

    IrradianceToARN( ana, "GPU Irradiance", gpuARN )

    EnableTextPrinting(True)

    Print "GPU End: " & Time()

 

    'Take the difference of the two ARNs and display the residual

    Dim resARN As Long

    resARN = ARNCreateCopy( gpuARN, "Residual" )

    ARNLinearCombination( -1, resARN, 1, cpuARN )

    ARNDisplayInChart( resARN, "" )

 

End Sub

 

 

See Also

MPCAdvancedRaytrace

MPCInitAdvancedRaytrace

T_MPCADVANCEDRAYTRACE

MPCRaytrace

MPCGetRaySumMode

MPCSetSimpleTraceMode

 

 

 

 

 

Copyright © Photon Engineering, LLC