Experiment EGSnrc MC
Experiment EGSnrc MC
There are some problems in science that are so complicated that they just cannot be analysed by
formulas that you can write down on a piece of paper. This is famously a very difficult problem. How
do you solve such problems? Well, one technique is to use probability, random numbers, and
computation. These methods are known as Monte Carlo methods. They are named after the town of
Monte Carlo in the country of Monaco, which is a tiny little country on the coast of France which is
famous for its casinos, hence the name. Now, however, they are used in all fields: understand systems
like:
i. Understanding systems: cost overruns or time overruns.
ii. Finance: predicting if a commodity price is going to go up or down.
iii. Resource exploration: oil and other minerals
All of these different fields use Monte Carlo methods to gain a deeper understanding of complex
problems. Monte Carlo algorithms use a computer program, a procedure or a subroutine, called
“random number generator” (RNG). However, computers cannot really generate “random” numbers
because the output of any program is by definition-predictable; hence, it is not truly “random”.
“Monte Carlo is a numerical method to solve equations or to
calculate integrals based on random number sampling”
As applied to radiation transport applications in radiotherapy and dosimetry, the Monte Carlo
method provides a numerical solution that employs directly the fundamental microscopic physical
laws of electron-atom and photon-atom interactions. The fluences of individual particle tracks are
faithfully reproduced within our knowledge of the physical laws—the scattering and absorption cross
sections. Macroscopic features of the radiation fields, for example the average track-length per
incident photon in a given volume of space, is computed as an average over many individual particle
simulations.
The rise of the use of linear accelerators (LINACs) for radiotherapy, also directed in the need to
develop Monte Carlo methods for the purpose of dose prediction and dosimetry. LINACs employed
in radiotherapy provide energetic and penetrating source of photons that enter deep into tissue, sparing
the surface and attenuating considerably less rapidly than 60Co or 137Cs beams. Thus, the history of the
utility of the Monte Carlo method in medical physics is inextricably tied to the development of Monte
Carlo methods of electron transport in complex geometries and in the description of electromagnetic
cascades.
As for general-purpose uses in medical-related fields, with multi-material, combinatorial
geometries, the two historically dominant players in Radiation Target Practice/Dosimetry, are the
Electron Gamma Showers (EGS) and Monte Carlo N-Particle (MCNP) codes. In the last decade,
GEometry ANd Tracking (GEANT) (Brun et al., 1982; Allison et al., 2006) has also made
significant contributions as well, presently equal in use to MCNP. It should be emphasized that these
codes are very different in nature. EGS has specifically targeted the medical area, since 1984, though
it has enjoyed some use in other area of physics as well. Overall, however, considering uses over all
areas, MCNP’s state-of-art neutron transport, makes it the world leader in the nuclear and radiological
science combine. The EGS code systems are supported by practitioners representing an array of
scientific disciplines: medical physics, radiological scientists, pure and applied physicists.
1.2 Instructions:
1. Open egs_gui application on the desktop, the GUI is for compiling and executing any EGSnrc
application.
2. Notice that the Compile tab is selected by default. In the selection box in the bottom left of the
GUI, scroll down, and select myapp.
3. Click the Go button to compile it. It will take some time to compile. If you see ExitCode = 0
in the output window box, the application has compiled successfully! If you are recompiling an
application, make sure to clean first.
4. Switch to the Execute tab.
5. In the PEGS file section, check on the pegsless checkbox. This means media of the slab have been
defined in the input file already.
6. In the Input file section, click the ... button, and select the input file: slab.egsinp.
7. To run the simulation, just click Start.
8. Open egs_view utility on the desktop, to understand the geometry of the simulation.
9. Select a file containing the input file (in this case is slab.egsinp) in C:\EGSnrc\EGS_HOME\myapp
directory.
10. Click on the scene and drag with the left mouse button to rotate the view. Zoom in and out with
the mouse scroll wheel. Pan the view by holding Ctrl and dragging with the left mouse button.
11. Click File, select open tracks…, select slab.ptracks.
12. Congratulations, you created your first egs++ application, ran your first simulation and view the
particles’ tracks!
Now, let’s create dose scoring object.
13. Next, open your input file by click open with, select notepad, CRTL+C the following input block
and CRTL+V to paste them inside the existing: ausgab object definition: delimiters at the end of
your input file to add a dose scoring objects. Save the input file.
14. Run the simulation again and find the “Summary of region dosimetry” in the output.
1.3 Questions:
1. How much energy is deposited inside the tantalum (Ta) plate? What is the dose? How much
Total CPU time for this run?
2. Based on the results of the dosimetry, can you manually convert the value of deposited energy
to dose in Gray (J/kg)? Show your calculation.
3. What is the relative uncertainty on energy and dose?
4. Increase the number of electrons, ncase = 1e4 in your input file and run the simulation again.
Compare the energy deposited with ncase = 1e3. Does the deposited energy increase by a
factor 10? What happened to the uncertainty?
Now, change the source of incident particle type to photons, charge = 0 in your input file. Save and
run simulation again.
Now, change the incident particle energy to 1 MeV in slab.egsinp. Save and run the simulation again
for ncase = 104 incident photons. Load the particle tracks in egs_view.
Let’s now change the material of the plate to lead (82Pb) in slab.egsinp. Use 100 keV electrons. Save
the input file and run the simulation again for ncase = 104. Load the particle tracks in egs_view.
11. How much is the deposited energy in the lead (in percentage) from the incident energy?
12. Run 20 MeV electrons striking a water plate and interpret the results. Is deposited energy
consistent with the known stopping power value of 2.45 MeV cm2/g for 20 MeV electrons in
liquid water?
Part 2: Linear accelerator simulation
2.1 Objectives
1. To understand the workhorse for linear accelerator (LINAC) simulations using EGSnrc.
3. To analyse the phase-space for the output of the simulation and calculate dose distribution in
DOSXYZnrc.
2.2 Instructions:
1. Open BEAMnrc GUI application on the desktop, click File Specify a new accelerator (Figure
4).
1. In the window that pops up, select SYNCJAWS and click >>. Type in any name (myJaws) for the
component module under CM Identifier, and click Add then Save & close.
2. Save the accelerator module file as syncjaws.module, then click OK. This will provide the name
of the accelerator. The next window allows you to select the material data to use. Click Browse
HEN_HOUSE and select 700icru.pegs4dat. Then, click OK.
3. Compile the accelerator by clicking Execute Compile in the main BEAMnrc GUI window,
and click BUILD & COMPILE. Click KILL/CLOSE after the process is finished.
4. Now you are ready to start editing a new input file. To do this, click on Edit main input
parameters in the Selected components window. Set a title, and change the parameters to match
Figure 5.
Figure 5 - BEAMnrc: Set the main input parameters
5. When selecting source number 1, set the parameters as in Figure 6. For scoring options, set a
plane to be scored after the jaws (component 1) as in Figure 7. Click Close when finish.
8. For now, leave File containing jaw opening data: empty. We are setting up the component
module (CM) for dynamic mode - motion of the jaws that can be synchronized with other
components. Click OK, then click File in the BEAMnrc GUI Save input parameters as...
giving the file a name like example.egsinp .
Now, we want to create a new text file, that will provide the dynamic motion of the jaws. There are
examples for all of the synchronized CMs in directory;
C:\EGSnrc\HEN_HOUSE\omega\beamnrc\CMs\sample_sequences\. Open the directory.
9. Select any sequence file, click File save as the file as example.sequence in
$EGS_HOME/BEAM_syncjaws. Copy the following text below and replace the existing text
in the file. Click File Save.
Ex: 2 static fields, 1 dynamic, for 2 jaws
6
0.0 In the following; we define 2 static fields
40, 50, -1, -1, -2, -2 and 1 dynamic field in 6 steps.
51, 61, -1, -1, -2, -2
0.3 The upper Y-jaws are at 40 ≤ Z ≤ 50 and
40, 50, -1, -1, -2, -2 X-jaws at 51 ≤ Z ≤ 61. From index 0.0 to
51, 61, -1, -1, -2, -2
3.0 (30% of the simulation), the jaws are
0.3
40, 50, 2, 2, 1, 1 statically positioned. Similarly, from 0.3 to
51, 61, 2, 2, 1, 1 0.6. The repeated indices, 0.3 and 0.6,
0.6 result in simulated collimator shifts while
40, 50, 2, 2, 1, 1 the beam is off. Finally, from index 0.6 to
51, 61, 2, 2, 1, 1
1.0 (40%) there is a motion of the x-jaws
0.6
40, 50, 1, 1, -1, -1 from a nearly-closed position to a 2 × 2
51, 61, 0.05, 0.05, -0.05, -0.05 opening.
1.0
40, 50, 1, 1, -1, -1
51, 61, 1, 1, -1, -1
10. Now go back to the settings of the SYNCJAWS component module, click the Browse button
and select the example.sequence file that you just made, then click OK (make sure the mode
is set to Dynamic). Click on Preview to view the first position of the jaws, before motion
begins.
11. File in the BEAMnrc GUI Save input parameters.
12. In the BEAMnrc GUI, go to Execute Run and click the EXECUTE button. Since we
only set 100000 histories to simulate, this
will complete fairly quickly. Check the accelerator directory to find the phase-space that was
saved as output ($EGS_HOME/BEAM_syncjaws/example.egsphsp1). Click KILL/CLOSE
when the job is finished.
13. Open directory; C:\EGSnrc\EGS_HOME\BEAM_syncjaws, the 1 in *.egsphsp1 refers to the
scoring plane number of the phase-space (we scored after CM 1, but if you had more CMs
you could score multiple phase-spaces in the same simulation). Additional output is recorded
in the *.egslst file.
Now, Let’s check on the output of the BEAMnrc simulation by analyzing our phase-space using
beamdp_gui.
14. Open beamdp_gui application on the desktop, on the Select action tab, select Derive X-Y
scatter plot of particles from ph-sp data.
15. Set the parameters following Figure 9 below. Click Execute beamdp when finished.
Figure 9 – BEAMDP: parameters setting to plot X-Y scatter
16. A window pop-up saying; “xmgr/xmgrace not automatically called because you running on
Windows” which is totally fine since our system is Windows OS. The application will work
best in Linux environment. Click OK.
17. Open Microsoft Excel, open the example.egsplot file and put delimiters between the column
and plot them.
Now, let’s see how dose is scored in the phantom using Monte Carlo simulation.
18. Open DOSXYZnrc GUI on the desktop, click File Start a previous input file
19. Make sure to select the same material data file that was used in BEAMnrc (i.e.
700icru.pegs4dat from the HEN_HOUSE).
20. Set the input parameters as shown in Table 1 below.
Table 1 - DOSXYZnrc: Main input parameters
21. Save the input parameters. Compile and run the simulation to create dose calculation in the
phantom. Noted that there will be a file containing the dose distribution in 3D map on the
phantom with endian .3ddose.
It is commonly of interest to obtain profile and depth-dose curves from dose files. For the 3ddose
format, there is a tool distributed with EGSnrc that can do this called statdose (though many users
design their own analysis software like MATLAB, VDOSE and etc.).
22. Open MATLAB software on the desktop, make sure you are in C:\EGSnrc-
master\egs_home\dosxyznrc directory.
23. Find plottingMC.m file, open the Matlab script.
24. On EDITOR tab, click Run icon to run the script. Obtain a page of different plotting.
25. Based on the results of the simulation obtained, find:
i) The uncertainty or percentage of error of the simulation
ii) Maximum dose, Dmax
iii) FWHM of the beam profiles