Skip to content

Commit

Permalink
Added enum for material libraries types.
Browse files Browse the repository at this point in the history
  • Loading branch information
MicahGale committed Sep 17, 2024
1 parent 9252022 commit e30b570
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
2 changes: 1 addition & 1 deletion montepy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from .input_parser.input_reader import read_input

# top level
from montepy.particle import Particle
from montepy.particle import Particle, LibraryType
from montepy.universe import Universe
from montepy.cell import Cell
from montepy.mcnp_problem import MCNP_Problem
Expand Down
34 changes: 32 additions & 2 deletions montepy/particle.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright 2024, Battelle Energy Alliance, LLC All Rights Reserved.
from enum import Enum, unique
from enum import StrEnum, unique


@unique
class Particle(Enum):
class Particle(StrEnum):
"""
Supported MCNP supported particles.
Expand Down Expand Up @@ -53,3 +53,33 @@ def __lt__(self, other):

def __str__(self):
return self.name.lower()


@unique
class LibraryType(StrEnum):
"""
Taken from section of 5.6.1 of LA-UR-22-30006
"""

def __new__(cls, value, particle=None):
obj = str.__new__(cls)
obj._value_ = value
obj._particle_ = particle
return obj

NEUTRON = ("NLIB", Particle.NEUTRON)
PHOTO_ATOMIC = ("PLIB", None)
PHOTO_NUCLEAR = ("PNLIB", None)
ELECTRON = ("ELIB", Particle.ELECTRON)
PROTON = ("HLIB", Particle.PROTON)
ALPHA_PARTICLE = ("ALIB", Particle.ALPHA_PARTICLE)
HELION = ("SLIB", Particle.HELION)
TRITON = ("TLIB", Particle.TRITON)
DEUTERON = ("DLIB", Particle.DEUTERON)

def __str__(self):
return self.name.lower()

def __lt__(self, other):
return self.value < other.value
6 changes: 3 additions & 3 deletions montepy/surfaces/surface_type.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright 2024, Battelle Energy Alliance, LLC All Rights Reserved.
from enum import unique, Enum
from enum import unique, StrEnum


# @unique
class SurfaceType(str, Enum):
@unique
class SurfaceType(StrEnum):
"""
An enumeration of the surface types allowed.
Expand Down

0 comments on commit e30b570

Please sign in to comment.