ornlneutronimaging / ImagingReso

Resonance Imaging
http://imagingreso.readthedocs.io
BSD 3-Clause "New" or "Revised" License
4 stars 3 forks source link

Errors occur when using elements with no stable isotopes #18

Open martinwissink opened 1 year ago

martinwissink commented 1 year ago

When attempting to use stacks containing elements which do not have any stable isotopes, one of two errors is encountered due to the periodictable package not having isotopic abundance or isotopic density information:

Abundance error:

ValueError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_7788\988004739.py in 5 }, 6 } ----> 7 o_reso = Resonance(stack=_stack, energy_min=_energy_min, energy_max=_energy_max, energy_step=_energy_step,database='ENDF_VIII')

~\Anaconda3\lib\site-packages\ImagingReso\resonance.py in init(self, stack, energy_max, energy_min, energy_step, database, temperature) 87 # checking that every element of each stack is defined 88 _utilities.checking_stack(stack=stack, database=self.database) ---> 89 new_stack = self.__update_stack_with_isotopes_infos(stack=stack) 90 self.stack = new_stack 91

~\Anaconda3\lib\site-packages\ImagingReso\resonance.py in __update_stack_with_isotopes_infos(self, stack) 440 _elements = stack[_key]['elements'] 441 for _element in _elements: --> 442 _dict = _utilities.get_isotope_dicts(element=_element, database=self.database) 443 stack[_key][_element] = _dict 444

~\Anaconda3\lib\site-packages\ImagingReso_utilities.py in get_isotope_dicts(element, database) 366 _molar_mass = get_mass(element) 367 --> 368 check_iso_ratios(ratios=_isotopes_atomic_ratio, tol=0.005) 369 370 isotope_dict['isotopes']['list'] = _isotopes_list

~\Anaconda3\lib\site-packages\ImagingReso_utilities.py in check_iso_ratios(ratios, tol) 218 def check_iso_ratios(ratios: list, tol: float): 219 if abs(sum(ratios) - 1.0) >= tol: --> 220 raise ValueError("The sum of the ratios '{}' is '{}' instead of '1.0'!".format(ratios, sum(ratios))) 221 else: 222 return True

ValueError: The sum of the ratios '[0.0, 0.0]' is '0.0' instead of '1.0'!

Density error:

TypeError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_7788\1487139182.py in 5 }, 6 } ----> 7 o_reso = Resonance(stack=_stack, energy_min=_energy_min, energy_max=_energy_max, energy_step=_energy_step,database='ENDF_VIII')

~\Anaconda3\lib\site-packages\ImagingReso\resonance.py in init(self, stack, energy_max, energy_min, energy_step, database, temperature) 87 # checking that every element of each stack is defined 88 _utilities.checking_stack(stack=stack, database=self.database) ---> 89 new_stack = self.__update_stack_with_isotopes_infos(stack=stack) 90 self.stack = new_stack 91

~\Anaconda3\lib\site-packages\ImagingReso\resonance.py in __update_stack_with_isotopes_infos(self, stack) 440 _elements = stack[_key]['elements'] 441 for _element in _elements: --> 442 _dict = _utilities.get_isotope_dicts(element=_element, database=self.database) 443 stack[_key][_element] = _dict 444

~\Anaconda3\lib\site-packages\ImagingReso_utilities.py in get_isotope_dicts(element, database) 362 _isotopes_mass.append(get_mass(isotope)) 363 _isotopes_atomic_ratio.append(get_abundance(isotope)) --> 364 _isotopes_density.append(get_density(isotope)) 365 _density = get_density(element) 366 _molar_mass = get_mass(element)

~\Anaconda3\lib\site-packages\ImagingReso_utilities.py in get_density(element) 419 the density of the element in g.cm-3 units 420 """ --> 421 return pt.elements.isotope(element).density 422 423

~\Anaconda3\lib\site-packages\periodictable\density.py in density(iso_el) 66 67 if hasattr(iso_el, 'element'): ---> 68 return iso_el.element._density * (iso_el.mass/iso_el.element.mass) 69 return iso_el._density 70

TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'


The proposed workaround would be to hard code density and/or abundance information for the relevant elements. A warning should be provided to the user that there are no stable isotopes, that a default isotope has been chosen, and that it can be updated to the user-desired abundance with the _set_isotopicratio function. Hard coding could be implemented in the _getabundance and _getdensity defs in _utilities.py.

A list of the relevant elements for which cross section information is available in the ENDF/B-VIII.0 database and the current behavior and proposed workaround are given below:

• Tc: does not work (abundance error) o periodictable has density information o periodictable assumes all isotopes 0% abundance o Propose 100% 99-Tc, major 235-U fission decay product • Bi: works o periodictable has density information o periodictable assumes 100% 209-Bi • Po: does not work (abundance error) o periodictable has density information o periodictable assumes all isotopes 0% abundance o Propose 100% 210-Po, used as an alpha source • Ra: does not work (density error) o periodictable does not have density information o Propose scaling from the published density of 226-Ra (5.5 g/cm^3) using the atomic mass of each isotope o periodictable assumes all isotopes 0% abundance o Propose 100% 223-Ra, formed in decay chain of 238-U and used in cancer treatment • Ac: does not work (density error) o periodictable does not have density information o Propose scaling from the published density of 227-Ac (10 g/cm^3) using the atomic mass of each isotope o periodictable assumes all isotopes 0% abundance o Propose 100% 227-Ac, naturally occurring from 235-U decay and longest half life • Th: works o periodictable has density information o periodictable assumes 100% 232-Th • Pa: works o periodictable has density information o periodictable assumes 100% 231-Pa • U: works o periodictable has density information o periodictable assumes 0.0055% 234-U, 0.72% 235-U, 99.2745% 238-U • Np: does not work (abundance error) o periodictable has density information o periodictable assumes all isotopes 0% abundance o Propose 100% 237-Np, most common and longest half life • Pu: does not work (abundance error) o periodictable has density information o periodictable assumes all isotopes 0% abundance o Propose 100% 239-Pu • Am: does not work (abundance error) o periodictable has density information o periodictable assumes all isotopes 0% abundance o Propose 100% 241-Am • Cm: does not work (abundance error) o periodictable has density information o periodictable assumes all isotopes 0% abundance o Propose 100% 242-Cm • Bk: does not work (abundance error) o periodictable has density information o periodictable assumes all isotopes 0% abundance o Propose 100% 249-Bk • Cf: does not work (density error) o periodictable does not have density information o Propose scaling from the published density of 252-Cf (15.1 g/cm^3) using the atomic mass of each isotope o periodictable assumes all isotopes 0% abundance o Propose 100% 252-Ca • Es: does not work (density error) o periodictable does not have density information o Propose scaling from the published density of Es (8.84 g/cm^3) using the atomic mass of each isotope o periodictable assumes all isotopes 0% abundance o Propose 100% 253-Es • Fm: does not work (density error) o periodictable does not have density information o Only isotope in ENDF/VII is 255-Fm, propose using the published density of Fm (9.71 g/cm^3) without scaling o periodictable assumes all isotopes 0% abundance o Propose 100% 255-Fm

martinwissink commented 1 year ago

Here's an element that I missed: • Pm: does not work (abundance error) o periodictable has density information o periodictable assumes all isotopes 0% abundance o Propose 100% 147-Pm, only isotope with significant applications