2016-08-11 11:31:29 -04:00
|
|
|
import warnings
|
2015-06-28 17:05:49 +07:00
|
|
|
|
2014-10-13 07:48:28 -04:00
|
|
|
|
2017-11-29 22:23:47 -06:00
|
|
|
class Nuclide(str):
|
2015-06-01 22:22:53 +07:00
|
|
|
"""A nuclide that can be used in a material.
|
|
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
----------
|
|
|
|
|
name : str
|
2017-07-31 08:18:55 -05:00
|
|
|
Name of the nuclide, e.g. 'U235'
|
2015-06-01 22:22:53 +07:00
|
|
|
|
|
|
|
|
Attributes
|
|
|
|
|
----------
|
|
|
|
|
name : str
|
2017-07-31 08:18:55 -05:00
|
|
|
Name of the nuclide, e.g. 'U235'
|
2015-06-01 22:22:53 +07:00
|
|
|
|
|
|
|
|
"""
|
2014-10-13 07:48:28 -04:00
|
|
|
|
2017-11-29 22:23:47 -06:00
|
|
|
def __new__(cls, name):
|
2014-10-23 22:31:55 -04:00
|
|
|
# Initialize class attributes
|
2017-11-29 22:23:47 -06:00
|
|
|
orig_name = name
|
2014-10-13 07:48:28 -04:00
|
|
|
|
2017-11-29 22:23:47 -06:00
|
|
|
if '-' in name:
|
|
|
|
|
name = name.replace('-', '')
|
|
|
|
|
name = name.replace('Nat', '0')
|
|
|
|
|
if name.endswith('m'):
|
|
|
|
|
name = name[:-1] + '_m1'
|
2016-02-07 13:24:14 -05:00
|
|
|
|
2022-09-08 14:25:22 -05:00
|
|
|
msg = ('OpenMC nuclides follow the GNDS naming convention. '
|
2021-07-31 22:33:45 +01:00
|
|
|
f'Nuclide "{orig_name}" is being renamed as "{name}".')
|
2017-11-29 22:23:47 -06:00
|
|
|
warnings.warn(msg)
|
2014-10-13 07:48:28 -04:00
|
|
|
|
2017-12-24 16:34:25 +07:00
|
|
|
return super().__new__(cls, name)
|
2015-10-08 14:23:19 -04:00
|
|
|
|
2015-04-21 09:13:38 -05:00
|
|
|
@property
|
|
|
|
|
def name(self):
|
2017-11-29 22:23:47 -06:00
|
|
|
return self
|