57
EGSnrc update and Monte Carlo simulation verification Fr édéric Tessier

EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

EGSnrc update and Monte Carlo simulation verification

Frédéric Tessier

Page 2: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

EGSnrc update and Monte Carlo simulation verification

Frédéric Tessier

Ernesto Mainegra-HingAtomic relaxation and PE cross sections

Reid TownsonRadionuclide decay modelling

Dave RogersImproved kerma calculations

Page 3: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

“This talk is almost, but not quite, entirely unlike a scientific presentation.”

— paraphrasing Douglas Adams

Page 4: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto
Page 5: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

The core EGSnrc team:

Page 6: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto
Page 7: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto
Page 8: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

EGSnrc is now in the public domain

Since 2016, the EGSnrc software is distributed under the GNU Affero GPL v3.0 open source licence.

BEAMnrc is now integrated in the EGSnrc installation.

Page 9: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

EGSnrc is now hosted on github.com

https://github.com/nrc-cnrc/EGSnrc

Page 10: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto
Page 11: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

report problems

Page 12: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

submit code

Page 13: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Installing EGSnrc in a nutshell(but preferably in a Linux shell)

$ git clone https://github.com/nrc-cnrc/EGSnrc.git$ cd EGSnrc$ HEN_HOUSE/scripts/configure

Page 14: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Installing EGSnrc in a nutshell(but preferably in a Linux shell)

$ git clone https://github.com/nrc-cnrc/EGSnrc.git$ cd EGSnrc

$ git checkout develop # use the develop branch

$ HEN_HOUSE/scripts/configure

There are two main branches:

1. master: updated yearly, versioned by year (EGSnrc 2017).

2. develop: ongoing changes, versioned by commit (d3d95a3).

Cloning provides the entire commit history (try git log )

Page 15: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

git is a robust version control system

• distributed, decentralized

• offline repository

• no repository setup

• atomic commits

• commit staging

• fast, efficient

• flexible and safe

• lighthweight branches

• github, bitbucket, etc.

• commit hashescommit

author date

blobs trees

a4b710b…

author date

blobs trees

parent

SHA-1

83cb3b9…

author date

blobs trees

…parenta4b710b…

805881c…

805881c…

author date

Page 16: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Atomic relaxation and PE cross sections

Radionuclide decay modelling

Improved kerma calculations

Ernesto Mainegra-Hing

Reid Townson

Dave Rogers

Page 17: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

10 MeVelectrons

water

air

air

water

electrontracks

B = 1 T

EGSnrc can model magnetic fields, again!

Page 18: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Fields are defined in the input file:

:start MC transport parameter:

Magnetic Field = 0 0 1 # Bx By Bz (in T) Electric Field = 0 0 0 # Ex Ey Ez (in V/cm)EM ESTEPE = 0.02

:stop MC transport parameter:

EM fields requires emf_macros.mortran

Electromagnetic fields are not included by default; you have to include the EMF macros in the compilation chain, e.g.,

EGSPP_USER_MACROS = cavity.macros \$(EGS_SOURCEDIR)emf_macros.mortran

Page 19: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Malkov proposed a higher-order method

Page 20: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto
Page 21: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Zero electron rest mass for 30 days!Thank you to Shahid Naqvi

Page 22: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Wrong MS coefficients for 17 years!Thank you to John Antolak

Page 23: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

correct:

erroneous:

Page 24: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

erroneous

correct

Page 25: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

erroneous

fortunately:

correct

Page 26: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

fortunately:

correct

Page 27: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

1 MeV e–

in water1 MeV e–

in water

for eachelectronMS step

within0.1%

negligibleeffect onMS angle

Page 28: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Someone else’s bug: ESTAR I-value

Page 29: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Someone else’s bug: ESTAR I-value

custom I-value is not taken into account when custom energies are supplied

Validate against ESTAR.f program

Page 30: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto
Page 31: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Are Monte Carlo simulations traceable?

Are we doing everything we can to ensure the validity of Monte Carlo simulation?

Monte Carlo simulation results are widely trusted, for example in dosimetry protocols.

Clients have started to ask for official Monte Carlo simulation calibration certificates!

Mass measurements are in principle traceable to the BIPM kilogram in Paris (until 2018).

Page 32: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

What is software traceability anyway?

1. robust versioning, robust source code

• migrate to git version control system • port the EGSnrc core code to C++

2. automated, continuous integration testing

• compilation test on every commit (Travis CI) • run standard simulation set for numerical comparison

3. automated, ongoing key comparisons between codes

• agree on key data and key scenarios• develop a common simulation description language?

4. Monte Carlo simulation verification

Page 33: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Kawrakow’s famous Fano test graph

ion chamber response in 60Co beams

“EGSnrc is accurate to within 0.1%, with respect to its own cross sections.”

This remains a distinguishing feature of EGSnrc today!

Page 34: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

If the atomic properties are identical everywhere, a uniformfluence implies a uniform source (per unit mass).

Since the solution to the Boltzmann equation is presumed unique: turn this around to verify the Monte Carlo algorithm.

Fano theorem provides a rigorous test

A Monte Carlo simulation algorithm is essentially solving the Boltzmann transport equation, numerically:

change in fluence source atomic interactionssourceper unit mass

Page 35: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto
Page 36: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Fano theorem within a magnetic field

The magnetic field adds a Lorentz force term in the Boltzmann transport equation:

There are two choices to recovera testable Fano condition:

1. scale the magneticfield with density

2. make this gradientparallel to velocity

The condition implies that the magnetic termvanishes: a uniform isotropic source yields a uniform fluence!

Page 37: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Fano testing requires 3 ingredients

1. uniform atomic interaction cross sections:set all regions to the same material, vary the density.

2. a uniform, isotropic, density-scaled source of particles:before: parallel photon beam, regenerate photons.now: use the egs_fano_source class.

3. an infinite simulation space:before: discard photon, worry about electron range...now: use an infinite simulation space!

Page 38: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Fano testing an ion chamberExradin A12, 0.6 cm3 chamber

Page 39: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Fano testing an ion chamber

delrin1.425

C5521.76

teflon2.25

air0.001

Exradin A12, 0.6 cm3 chamber

93 regions

Page 40: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Fano testing an ion chamber1. uniform atomic interaction cross sections

air1.425

air1.76

air2.25

air0.001

Page 41: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Fano testing an ion chamber2. a uniform, isotropic, density-scaled source of particles

egs_fano_source

Page 42: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Fano testing an ion chamber3. an infinite simulation space

periodic boundary conditions

source particle

Page 43: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Fano testing an ion chamber3. an infinite simulation space

periodic boundary conditions

source particle

Page 44: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Fano testing an ion chamber

1 MeV electrons, mass = 6.285428 g

Fano value: 0.159098 MeV/g

photons

Page 45: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Fano testing an ion chamber

1 MeV electrons, mass = 6.285428 g

Fano value: 0.159098 MeV/g

electrons

Page 46: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

The dose in every region is within 0.1% of the exact Fano value

Page 47: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Fano test catches source energy error

original

Source energy error: 1.01 MeV instead of 1 MeV

Page 48: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

wrong chamber tip cavity radius:0.30533 instead of 0.30353 92

Fano test catches geometry error

original

Page 49: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Fano test catches energy cutoff errorcan it replace cutoff energy convergence tests?

original

cutoffs too high: 189 keV instead of 10 keV

Page 50: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Fano test catches MS algorithm errorcan it replace single-scattering convergence tests?

original

biased electron multiple-scattering

Page 51: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Fano test catches boundary crossing error

original

inexact boundary crossing: PRESTA-I algorithm

Page 52: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Fano test catches magnetic field error

original

= 0.05 is too large

Page 53: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

What is the Fano test really testing?it is not testing the physics!

Testing that interaction cross sectionsare the same everywhere

original

no Compton effect

Page 54: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Leading by example: August 2017

Page 55: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

Leading by example: August 2017

Page 56: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

All published Monte Carlo simulation results should to be supported by a Fano test calculation.

• Developers should enable Fano testing

• Authors should report Fano test results

• Reviewers should request Fano tests

• Editors should require Fano tests

Page 57: EGSnrc update and Monte Carlo simulation …people.na.infn.it/~mettivie/MCMA presentation/16 Aula...EGSnrc update and Monte Carlo simulation verification Frédéric Tessier Ernesto

EGSnrc update and Monte Carlo simulation verification

Frédéric Tessier