nrc-cnrc / EGSnrc

Toolkit for Monte Carlo simulation of ionizing radiation — Trousse d'outils logiciels pour la simulation Monte Carlo du rayonnement ionisant
http://nrc-cnrc.github.io/EGSnrc
GNU Affero General Public License v3.0
242 stars 146 forks source link

Zero electron fluence in vacuum regions #1198

Open ftessier opened 1 month ago

ftessier commented 1 month ago

Description

When using the fluence scoring object in egs++, the electron fluence is zero if the region material is vacuum.

To Reproduce

  1. Use the egs++ input below
  2. Run it with egs_app to compute the fluence in the air slab
  3. Comment out the set medium = 1 1 line in the geometry (sets the slab material to vacuum)
  4. The fluence in the slab vanishes

Expected behavior

It is expected that the slab fluence in this simulation would be equal to the source fluence when the slab material is vacuum.

EGSnrc version

v2023a

Input file to reproduce

Run control

:start run control:
    ncase = 1e5
:stop run control:

Geometry

The bug is reveal when commenting out the set medium = 1 1, so that the slab material is changed from air to vacuum. The electron fluence in the slab then vanishes, but it should stay finite even in vacuum. This only affects electrons, not photons.

:start geometry definition:

    ### a simple slab geometry
    :start geometry:
        name     = slab
        library  = egs_ndgeometry
        type     = EGS_XYZGeometry
        x-planes = -1 1
        y-planes = -1 1
        z-planes = 0 1 2 3
        :start media input:
            media = vacuum air
            set medium = 1 1    ### BUG: comment out and fluence in slab is 0
        :stop media input:
        set label = slab 1
    :stop geometry:

    ### simulation geometry
    simulation geometry = slab

:stop geometry definition:

Media

:start media definition:

    ### particle production thresholds
    ae = 0.512
    ap = 0.001
    ue = 1.511
    up = 1

    ### air
    :start air:
        density correction file = air_dry_nearsealevel
    :stop air:

:stop media definition:

Source

:start source definition:

    ### pencil beam
    :start source:
        name      = pencil_beam
        library   = egs_parallel_beam
        charge    = -1
        direction = 0 0 1
        :start spectrum:
            type = monoenergetic
            energy = 0.3
        :stop spectrum:
        :start shape:
            library  = egs_circle
            radius   = 0.5
        :stop shape:
    :stop source:

    ### use this source for the simulation
    simulation source = pencil_beam

:stop source definition:

Ausgab objects

:start ausgab object definition:

    ### generate particle tracks
    :start ausgab object:
        name    = tracks
        library = egs_track_scoring
        stop scoring = 10000
    :stop ausgab object:

    ### report fluence in all regions
    :start ausgab object:
        name              = fluence
        library           = egs_fluence_scoring
        type              = volumetric
        scoring particle  = electron
        source particle   = electron
        verbose           = no
        score primaries   = yes
        :start volumetric scoring:
            scoring regions = slab
            volumes = 1
        :stop volumetric scoring:
    :stop ausgab object:

:stop ausgab object definition:

MC transport parameters

:start MC transport parameter:

    ### energy cutoffs
    Global ECUT                     = 0.512
    Global PCUT                     = 0.001

    ### electron transport algorithm
    Electron-step algorithm         = EGSnrc
    Boundary crossing algorithm     = Exact
    Skin depth for BCA              = 1e10  # single-scattering

:stop MC transport parameter:

Viewer control

:start view control:
    set color = air    170 170 255 132
:stop view control: