Skip to main content
Solved

Export total power value from objects as a detector

  • September 19, 2022
  • 2 replies
  • 481 views

Carmen Lago

Hi!

 

I desgined a great 3D matrix of spheres as a detector.

I would like to know how to export the total power value of each detector in a single file (all the values) with a ZPL macro.

 

Thanks, Carmen

Best answer by David.Nguyen

Hi Carmen,

 

Here is a simple example with 2 spheres (attached to my reply):

The code is as follows:

# Clear all detectors
clear = NSDD(1, 0, 0, 0)

# Run a raytrace
NSTR 1, 0, 0, 0, 0, 1, 0

# Read power of all objects between the first and last
# object (defined below)

# First object
first_object = 2

# Last object
last_object = 3

# Specify PRINT output file
OUTPUT "test.txt"

# Loop over the detectors
FOR object, first_object, last_object, 1
	# Record total flux of current object
	flux = NSDD(1, object, 0, 0)

	# Print flux to file specified by OUTPUT
	PRINT flux
NEXT

Please note the following about the OUTPUT keyword:

If a valid filename is provided, then subsequent PRINT commands will output to the filename specified. If a filename with no path is provided, output will be directed to the <data>\Macros folder.

 

The result gives the following values:

0.1954
0.8046

And these are the text tab of the detector viewers:

Sphere 2, NSCG Surface 1: 
Number of pixels: 4512, Total Hits = 19543

Peak Power      : 1.0460E-02 Watts
Total Power     : 1.9543E-01 Watts
Sphere 3, NSCG Surface 1: 
Number of pixels: 4512, Total Hits = 80457

Peak Power      : 1.0500E-02 Watts
Total Power     : 8.0457E-01 Watts

Let me know if you have any other question.

Take care,


David

View original
Did this topic help you find an answer to your question?

2 replies

David.Nguyen
Luminary
Forum|alt.badge.img+2
  • Luminary
  • 1112 replies
  • Answer
  • September 20, 2022

Hi Carmen,

 

Here is a simple example with 2 spheres (attached to my reply):

The code is as follows:

# Clear all detectors
clear = NSDD(1, 0, 0, 0)

# Run a raytrace
NSTR 1, 0, 0, 0, 0, 1, 0

# Read power of all objects between the first and last
# object (defined below)

# First object
first_object = 2

# Last object
last_object = 3

# Specify PRINT output file
OUTPUT "test.txt"

# Loop over the detectors
FOR object, first_object, last_object, 1
	# Record total flux of current object
	flux = NSDD(1, object, 0, 0)

	# Print flux to file specified by OUTPUT
	PRINT flux
NEXT

Please note the following about the OUTPUT keyword:

If a valid filename is provided, then subsequent PRINT commands will output to the filename specified. If a filename with no path is provided, output will be directed to the <data>\Macros folder.

 

The result gives the following values:

0.1954
0.8046

And these are the text tab of the detector viewers:

Sphere 2, NSCG Surface 1: 
Number of pixels: 4512, Total Hits = 19543

Peak Power      : 1.0460E-02 Watts
Total Power     : 1.9543E-01 Watts
Sphere 3, NSCG Surface 1: 
Number of pixels: 4512, Total Hits = 80457

Peak Power      : 1.0500E-02 Watts
Total Power     : 8.0457E-01 Watts

Let me know if you have any other question.

Take care,


David


Carmen Lago
  • Author
  • Monochrome
  • 4 replies
  • September 22, 2022

It works! Thanks David

Take care too

Carmen


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings