Skip to content

Commit

Permalink
return ZERO acceptance if no tracked particle survives in at/pyat/acc…
Browse files Browse the repository at this point in the history
…eptance/boundary.py (#707)

* Update boundary.py

* return [0, 0] when all particles are lost

---------

Co-authored-by: Simon White <[email protected]>
  • Loading branch information
simoneliuzzo and swhite2401 authored Nov 30, 2023
1 parent 5b9caaf commit f9e5340
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pyat/at/acceptance/boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
grid definitions
"""

from at.lattice import Lattice, AtError
from at.lattice import Lattice, AtError, AtWarning
from typing import Optional, Sequence
from enum import Enum
import numpy
from scipy.ndimage import binary_dilation, binary_opening
from collections import namedtuple
import time
import warnings

__all__ = ['GridMode']

Expand Down Expand Up @@ -260,8 +261,10 @@ def radial_boundary(mask, grid):
return bnd

if not numpy.any(mask):
raise AtError("No particle survived, please check your grid "
"or lattice.")
msg = ("No particle survived, please check your grid "
"or lattice. Acceptance set to [0.0, 0.0].")
warnings.warn(AtWarning(msg))
return numpy.zeros(2)

if config.mode is GridMode.RADIAL:
return radial_boundary(mask, grid)
Expand Down

0 comments on commit f9e5340

Please sign in to comment.