example_00
Download a Jupyter notebook with this example: example_00.ipynb.
Please follow the source comments for description and instruction.
Source Code
1# -*- coding: utf-8 -*-
2"""
3.. Authors:
4 Novimir Antoniuk Pablant <npablant@pppl.gov>
5
6A simple example consisting only of a point source and a spherical crystal.
7
8Description
9-----------
10
111.
12Create a new user configuration dictionary.
13
14The entries that we put into this config will overwrite the defaults
15that are defined within xicsrt. The config can potentially contain the
16following sections:
17
18- general
19- sources
20- optics
21- filters
22- scenario
23
242.
25Create a section that contains the general raytracer configuration.
26
27number_of_iter
28 Perform raytracing the given number of times. The output from all
29 the iterations will be combined. Performing multiple iterations allows
30 a large number of rays to be traced without running into memory limits.
31save_images
32 If set to true, images will be saved to the output directory (which
33 we have not specified in this example.
34
353.
36Create the section that contains the sources.
37Then define a source, cleverly named 'source'.
38
39class_name
40 The type of source object to create.
41intensity
42 The number of rays to launch in each iteration.
43wavelength
44 The nominal wavelength of the source emission.
45spread
46 The angular spread of the source (in radians).
47
484.
49Create the section that contains the optics.
50In this case we only define one optic: a detector.
51
52class_name
53 The type of optic object to create.
54origin
55 The location of this optic.
56zaxis
57 The direction the optics is pointing. For all of the standard
58 optics that come with xicrt, the zaxis is the normal direction.
59xsize
60 The size of the optic along the xaxis.
61 Corresponds to the 'width' of the optic.
62ysize
63 The size of the optic along the yaxis.
64 Corresponds to the 'height' of the optic.
65
665.
67Finally we pass the configuration to the XICSRT raytracer to perform
68the actual raytracing. The `results` is a dictionary with the full
69trace history along with images at the detector.
70"""
71
72import numpy as np
73import xicsrt
74xicsrt.warn_version('0.8')
75
76# 1.
77config = {}
78
79# 2.
80config['general'] = {}
81config['general']['number_of_iter'] = 5
82config['general']['save_images'] = False
83
84# 3.
85config['sources'] = {}
86config['sources']['source'] = {}
87config['sources']['source']['class_name'] = 'XicsrtSourceDirected'
88config['sources']['source']['intensity'] = 1e3
89config['sources']['source']['wavelength'] = 3.9492
90config['sources']['source']['spread'] = np.radians(5.0)
91
92# 4.
93config['optics'] = {}
94config['optics']['detector'] = {}
95config['optics']['detector']['class_name'] = 'XicsrtOpticDetector'
96config['optics']['detector']['origin'] = [0.0, 0.0, 1.0]
97config['optics']['detector']['zaxis'] = [0.0, 0.0, -1]
98config['optics']['detector']['xsize'] = 0.2
99config['optics']['detector']['ysize'] = 0.2
100
101# 5.
102results = xicsrt.raytrace(config)
103