[Task] Solve the issue with the transformation between mass and number density
-
Locate where the issue happens.
- At line-202 in
addie/processing/mantid/master_table/mass_density_handler.py, there occurs error when callingnumber_density_value_changed,
File "/SNS/users/y8z/miniconda/envs/addie_env_3/lib/python3.6/site-packages/addie/utilities/math_tools.py", line 200, in number_density2mass_density mass_density = number_density * molecular_mass / natoms / avogadro_term TypeError: unsupported operand type(s) for *: 'float' and 'NoneType'-
We know from the error message that the error should be something to do with that some of the variables used in the math calculation is
None(i.e. no value assigned). Anyhow, we need to trace further back, by searching fornumber_density2mass_density. -
All parameters passed to
number_density2mass_densityare given in the functionnumber_density_value_changeddefined inaddie/processing/mantid/master_table/mass_density_handler.py. From there, we know, there may be something wrong with eitherself.total_number_of_atomsorself.total_molecular_mass. -
Further searching for, e.g,
self.total_molecular_massin./processing/mantid/master_table/mass_density_handler.py, we know thatself.total_molecular_massis assigned value at line-87 inaddie/processing/mantid/master_table/mass_density_handler.pyand the value comes from the function call toretrieving_molecular_mass_and_number_of_atoms_worked. -
Further searching for
retrieving_molecular_mass_and_number_of_atoms_workedwill lead us toaddie/processing/mantid/master_table/periodic_table/material_handler.py. -
Checking the codes will lead us further to
get_periodictable_formatted_element_and_number_of_atomsinaddie/processing/mantid/master_table/periodic_table/material_handler.py. -
We realize that there are three return parameters from
get_periodictable_formatted_element_and_number_of_atoms, but when we check the value assignment inretrieving_molecular_mass_and_number_of_atoms_worked, we found there are only two receivers.
- At line-202 in
-
Solve the issue.
-
The solution should be straightforward to change the following line in
addie/processing/mantid/master_table/periodic_table/material_handler.py,[formated_element, number_of_atoms] = get_periodictable_formatted_element_and_number_of_atoms( _element)to
[formated_element, number_of_atoms, case] = get_periodictable_formatted_element_and_number_of_atoms( _element)
-