One of the most basic aspects of nuclear software is how to uniquely respresent nuclide names. There exists the large number of different ways that people choose to spell these names. Functionally, there are three pieces of information that should be included in every radionuclide's name:
Some common naming conventions exist. The following are currently supported by PyNE:
A canonical form is "a representation such that every object has a unique representation." Since there are many ways to represent nuclides, PyNE chooses one of them to be the canonical form. Note: this idea of canonical forms will come up many times in PyNE.
The id integer form of nuclide names is the fundamental form of nuclide naming because
it accurately captures all of the needed information in the smallest amount of space. Given that the
Z-number may be up to three digits, A-numbers are always three digits, and the excitation level is
4 digits, all possible nuclides are represented on the range 10000000 < zzaaam < 2130000000
.
This falls well within 32 bit integers.
The id()
function converts other representations to the id format.
from pyne import nucname
nucname.id('U-235')
922350000
nucname.id('Am-242m')
952420001
While applications and backends should use the id form under-the-covers, the name form provides an easy way to covert nuclide to a consistent and human readable representation.
nucname.name(10010000)
'H1'
nucname.name('CM-244-m')
'Cm244M'
The name string representations may be anywhere from two characters (16 bits) up to six characters (48 bits). So in general, id is smaller by 50%.
Other forms do not necessarily contain all of the required information (MCNP
) or require additional
storage space (Serpent
). It may seem pedantic to quibble over the number of bits per nuclide name,
but these identifiers are used everywhere throughout nuclear code, so it behooves us to be as small
and fast as possible.
The other distinct advantage that integer forms have is that you can natively perform arithmetic on them. For example::
# Am-242m
nuc = 942420001
# Z-number
z = nuc/10000000
print z
# A-number
a = (nuc/10000)%1000
print a
# state
s = nuc%10000
print s
94 242 1
Of course, there are built in functions to do exactly this as well.
print nucname.znum(nuc)
print nucname.anum(nuc)
print nucname.snum(nuc)
94 242 1
Code internal to PyNE uses id, and except for human readability, you should too! Natural elements are specified in this form by having zero A-number and excitation flags.
nucname.id('U')
920000000
# name form
nucname.id('am242m')
952420001
# SZA form
nucname.id(1095242)
1095240002
To resolve such ambiquities when you know which form you are coming from, PyNE provides a suite of *_to_to()
functions.
nucname.sza_to_id(1095242)
952420001
nucname.zzaaam('U235')
922350
nucname.name(10010)
'H1'
nucname.serpent('AM242M')
'Am-242m'
nucname.name_zz['Sr']
38
nucname.zz_name[57]
u'La'
nucname.alara('FE56')
'fe:56'